diff --git a/.eslintrc.json b/.eslintrc.json deleted file mode 100644 index 63fa0daa3aa..00000000000 --- a/.eslintrc.json +++ /dev/null @@ -1,48 +0,0 @@ -{ - "ignorePatterns": [ - "test/*/samples/**/*.js", - "!test/*/samples/**/_config.js", - "test/leak/index.js", - "**/*.ts" - ], - "rules": { - "indent": [ 2, "tab", { "SwitchCase": 1 } ], - "semi": [ 2, "always" ], - "keyword-spacing": [ 2, { "before": true, "after": true } ], - "space-before-blocks": [ 2, "always" ], - "no-mixed-spaces-and-tabs": [ 2, "smart-tabs" ], - "no-cond-assign": 0, - "no-unused-vars": 2, - "object-shorthand": [ 2, "always" ], - "no-const-assign": 2, - "no-class-assign": 2, - "no-this-before-super": 2, - "no-var": 2, - "no-unreachable": 2, - "valid-typeof": 2, - "quote-props": [ 2, "as-needed" ], - "one-var": [ 2, "never" ], - "prefer-arrow-callback": 2, - "prefer-const": [ 2, { "destructuring": "all" } ], - "arrow-spacing": 2 - }, - "env": { - "es6": true, - "browser": true, - "node": true - }, - "extends": [ - "eslint:recommended", - "plugin:import/errors", - "plugin:import/warnings" - ], - "parserOptions": { - "ecmaVersion": 2018, - "sourceType": "module" - }, - "settings": { - "import/ignore": [ 0, [ - "\\.path.js$" - ] ] - } -} diff --git a/.gitattributes b/.gitattributes index 4964429a867..94f480de94e 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1 +1 @@ -*.js eol=lf +* text=auto eol=lf \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/BUG.md b/.github/ISSUE_TEMPLATE/BUG.md deleted file mode 100644 index b19835f2ef0..00000000000 --- a/.github/ISSUE_TEMPLATE/BUG.md +++ /dev/null @@ -1,56 +0,0 @@ ---- -name: 🐞 Bug Report -about: Something went awry and you'd like to tell us about it. - ---- - - - -- Rollup Version: -- Operating System (or Browser): -- Node Version (if applicable): -- Link to reproduction (IMPORTANT, read below): - - - - -### Expected Behavior - - -### Actual Behavior - - - - - diff --git a/.github/ISSUE_TEMPLATE/DOCS.md b/.github/ISSUE_TEMPLATE/DOCS.md deleted file mode 100644 index 2ba2e444273..00000000000 --- a/.github/ISSUE_TEMPLATE/DOCS.md +++ /dev/null @@ -1,33 +0,0 @@ ---- -name: 📚 Documentation -about: Are the docs lacking or missing something? Do they need some new 🔥 hotness? Tell us here. - ---- - - - -Documentation Is: - - - -- [ ] Missing -- [ ] Needed -- [ ] Confusing -- [ ] Not Sure? - -### Please Explain in Detail... - - -### Your Proposal for Changes diff --git a/.github/ISSUE_TEMPLATE/FEATURE.md b/.github/ISSUE_TEMPLATE/FEATURE.md deleted file mode 100644 index 8e5e176d6f4..00000000000 --- a/.github/ISSUE_TEMPLATE/FEATURE.md +++ /dev/null @@ -1,24 +0,0 @@ ---- -name: ✨ Feature Request -about: Suggest an idea for this project - ---- - - - -### Feature Use Case - - -### Feature Proposal diff --git a/.github/ISSUE_TEMPLATE/MODIFICATION.md b/.github/ISSUE_TEMPLATE/MODIFICATION.md deleted file mode 100644 index 42c9260ebb7..00000000000 --- a/.github/ISSUE_TEMPLATE/MODIFICATION.md +++ /dev/null @@ -1,28 +0,0 @@ ---- -name: 🔧 Modification Request -about: Would you like something work differently? Have an alternative approach? This is the template for you. - ---- - - - - -### Expected Behavior / Situation - - -### Actual Behavior / Situation - - -### Modification Proposal diff --git a/.github/ISSUE_TEMPLATE/SUPPORT.md b/.github/ISSUE_TEMPLATE/SUPPORT.md index 6b620e67e09..ad4a36eb229 100644 --- a/.github/ISSUE_TEMPLATE/SUPPORT.md +++ b/.github/ISSUE_TEMPLATE/SUPPORT.md @@ -1,13 +1,8 @@ --- name: 🆘 Support, Help, and Advice about: 👉🏽 Need help or tech support? Please don't open an issue! Head to https://is.gd/rollup_chat or https://stackoverflow.com/questions/tagged/rollupjs. - --- -Hey there! If you need help or tech support then this is not the place to -ask. Please head to the [Rollup Discord](https://is.gd/rollup_chat) -instead or post a question to https://stackoverflow.com/questions/tagged/rollupjs. +Hey there! If you need help or tech support then this is not the place to ask. Please head to the [Rollup Discord](https://is.gd/rollup_chat) instead or post a question to https://stackoverflow.com/questions/tagged/rollupjs. -If you arrived here because you think Rollup's documentation is unclear, -insufficient or wrong, please consider creating an issue for the documentation -instead. +If you arrived here because you think Rollup's documentation is unclear, insufficient or wrong, please consider creating an issue for the documentation instead. diff --git a/.github/ISSUE_TEMPLATE/bug.yaml b/.github/ISSUE_TEMPLATE/bug.yaml new file mode 100644 index 00000000000..054a9cff79a --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug.yaml @@ -0,0 +1,61 @@ +name: 🐞 Bug Report +description: Something went awry and you'd like to tell us about it. +labels: [t¹ 🐞 bug, t⁸ ⋅ triage] +body: + - type: markdown + attributes: + value: | + ⚡️ katchow! We 💛 issues. + + 👉🏽 Need help or tech support? Please don't open an issue! + Head to https://is.gd/rollup_chat or https://stackoverflow.com/questions/tagged/rollupjs + + 👉🏽 Is this issue related to an official plugin? Please do not open an issue here, go to the plugins repository instead: https://github.com/rollup/plugins/issues + + ❤️ Rollup? Please consider supporting our collective: + 👉 https://opencollective.com/rollup/donate + - type: input + id: version + attributes: + label: Rollup Version + placeholder: e.g. vX.Y.Z + validations: + required: true + - type: input + id: os_version + attributes: + label: Operating System (or Browser) + validations: + required: true + - type: input + id: node_version + attributes: + label: Node Version (if applicable) + validations: + required: false + - type: input + id: reproduction_link + attributes: + label: Link To Reproduction + description: | + Issues without minimal reproductions will be closed! Please provide a link to one by: + 1. Using the REPL at https://rollupjs.org/repl/, or + 2. Using the StackBlitz reproduction template at https://stackblitz.com/fork/rollup-repro (allows full use of all rollup options and plugins), or + 3. Using the repl.it reproduction template at https://replit.com/@rollup/rollup-plugin-repro, or + 4. Provide a minimal repository link (Read https://gist.github.com/Rich-Harris/88c5fc2ac6dc941b22e7996af05d70ff for instructions). These may take more time to triage than the other options. + + For some bugs it this may seem like overkill but believe us, very often what seems like a "clear issue" is actually specific to some details of your setup. Having a runnable reproduction not only "proves" your bug to us but also allows us to spend all our effort fixing the bug instead of struggling to understand your issue. + validations: + required: true + - type: textarea + id: expected_behaviour + attributes: + label: Expected Behaviour + validations: + required: true + - type: textarea + id: actual_behaviour + attributes: + label: Actual Behaviour + validations: + required: true diff --git a/.github/ISSUE_TEMPLATE/docs.yaml b/.github/ISSUE_TEMPLATE/docs.yaml new file mode 100644 index 00000000000..e03da897d51 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/docs.yaml @@ -0,0 +1,37 @@ +name: 📚 Documentation +description: Are the docs lacking or missing something? Do they need some new 🔥 hotness? Tell us here. +labels: [t² 📚 documentation, t⁸ ⋅ triage] +body: + - type: markdown + attributes: + value: | + ⚡️ katchow! We 💛 issues. + + 👉🏽 Need help or tech support? Please don't open an issue! + Head to https://is.gd/rollup_chat or https://stackoverflow.com/questions/tagged/rollupjs + + 👉🏽 Is this issue related to an official plugin? Please do not open an issue here, go to the plugins repository instead: https://github.com/rollup/plugins/issues + + ❤️ Rollup? Please consider supporting our collective: + 👉 https://opencollective.com/rollup/donate + - type: checkboxes + id: documentation_is + attributes: + label: Documentation is + options: + - label: Missing + - label: Needed + - label: Confusing + - label: Not sure? + - type: textarea + id: explanation + attributes: + label: Please Explain in Detail... + validations: + required: true + - type: textarea + id: proposal + attributes: + label: Your Proposal for Changes + validations: + required: true diff --git a/.github/ISSUE_TEMPLATE/feature.yaml b/.github/ISSUE_TEMPLATE/feature.yaml new file mode 100644 index 00000000000..a38a771dcff --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature.yaml @@ -0,0 +1,28 @@ +name: ✨ Feature Request +description: Suggest an idea for this project. +labels: [t³ ✨ enhancement, t⁸ ⋅ triage] +body: + - type: markdown + attributes: + value: | + ⚡️ katchow! We 💛 issues. + + 👉🏽 Need help or tech support? Please don't open an issue! + Head to https://is.gd/rollup_chat or https://stackoverflow.com/questions/tagged/rollupjs + + 👉🏽 Is this issue related to an official plugin? Please do not open an issue here, go to the plugins repository instead: https://github.com/rollup/plugins/issues + + ❤️ Rollup? Please consider supporting our collective: + 👉 https://opencollective.com/rollup/donate + - type: textarea + id: use_case + attributes: + label: Feature Use Case + validations: + required: true + - type: textarea + id: proposal + attributes: + label: Feature Proposal + validations: + required: true diff --git a/.github/ISSUE_TEMPLATE/modification.yaml b/.github/ISSUE_TEMPLATE/modification.yaml new file mode 100644 index 00000000000..95a25825f21 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/modification.yaml @@ -0,0 +1,34 @@ +name: 🔧 Modification Request +description: Would you like something work differently? Have an alternative approach? This is the template for you. +labels: [t⁷ ⋅ modification, t⁸ ⋅ triage] +body: + - type: markdown + attributes: + value: | + ⚡️ katchow! We 💛 issues. + + 👉🏽 Need help or tech support? Please don't open an issue! + Head to https://is.gd/rollup_chat or https://stackoverflow.com/questions/tagged/rollupjs + + 👉🏽 Is this issue related to an official plugin? Please do not open an issue here, go to the plugins repository instead: https://github.com/rollup/plugins/issues + + ❤️ Rollup? Please consider supporting our collective: + 👉 https://opencollective.com/rollup/donate + - type: textarea + id: expected_behaviour + attributes: + label: Expected Behavior / Situation + validations: + required: true + - type: textarea + id: actual_behaviour + attributes: + label: Actual Behavior / Situation + validations: + required: true + - type: textarea + id: proposal + attributes: + label: Modification Proposal + validations: + required: true diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 5dbe4a48132..be17a0cc992 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -14,6 +14,7 @@ --> This PR contains: + - [ ] bugfix - [ ] feature - [ ] refactor @@ -21,15 +22,29 @@ This PR contains: - [ ] other Are tests included? -- [ ] yes (*bugfixes and features will not be merged without tests*) + +- [ ] yes (_bugfixes and features will not be merged without tests_) - [ ] no Breaking Changes? -- [ ] yes (*breaking changes will not be merged unless absolutely necessary*) + +- [ ] yes (_breaking changes will not be merged unless absolutely necessary_) - [ ] no List any relevant issue numbers: + + ### Description bundle(bundle):::command + --> generate1(".generate\nfile: main.mjs,\nformat: 'es'"):::command + + bundle + -->generate2(".generate\nfile: main.cjs,\nformat: 'cjs'"):::command +``` + +On the highest level, all of this is orchestrated by the `rollupInternal` function in [`rollup.ts`](src/rollup/rollup.ts). This function + +- Parses and normalizes the input options via [`normalizeInputOptions`](src/utils/options/normalizeInputOptions.ts) +- Initializes the [`Graph`](src/Graph.ts) instance +- Triggers the actual build phase via `Graph.build()` +- Generates the "bundle" object with the `.generate` and `.write` methods +- These methods in turn first parse and normalize the output options via [`normalizeOutputOptions`](src/utils/options/normalizeOutputOptions.ts) +- Then they create a [`Bundle`](src/Bundle.ts) instance that manages one output +- Last, they trigger the actual generate phase via `Bundle.generate()` + +### The build phase + +To understand this phase from a plugin perspective, have a look at [Build Hooks](https://rollupjs.org/plugin-development/#build-hooks), which also contains a graph to show in which order these hooks are executed. In detail, `Graph.build` performs the following steps + +- It generates the module graph. This is orchestrated by the [`ModuleLoader`](src/ModuleLoader.ts) class. This class + - Reads all entry points provided by the [`input`](https://rollupjs.org/configuration-options/#input) option and additional entry points emitted from plugins via [`this.emitFile()`](https://rollupjs.org/plugin-development/#this-emitfile). + - For each module, it first creates a [`Module`](src/Module.ts) instance. + - Then it loads and transforms the code via the corresponding plugin hooks. + - The resulting code and sourcemaps are passed to the `Module` instance via `Module.setSource()`. + - This parses the code into the Rollup AST, which consists of the classes defined in the [ast folder](src/ast/nodes). For details see also [below](#parsing-the-ast). + - In the process, it also collects all static and dynamic dependencies of the module. + - These are then again loaded and transformed by the `ModuleLoader`, a process that repeats until the graph is complete. +- It sorts the modules by their execution order to assign an `execIndex` to each module in [`executionOrder.ts`](src/utils/executionOrder.ts). +- It marks which statements in each module are included in the output, also known as "tree-shaking" + - This happens in several passes. Each pass starts with calling `.include` on the `Module` instance. + - This again calls `.include` on the top-level AST node, that is then propagated to the child nodes. At several stages, inclusion will only happen if a statement or expression has "side effects", which is determined by calling its `.hasEffects` method. Usually, it means mutating a variable that is already included or performing an action where we cannot determine whether there are side effects like calling a global function. + - Nodes that are already included are included again for each pass as it is possible that with each pass, some additional child nodes may need to be included. Whenever something new is included, another pass will be scheduled once the current pass is finished. + - In the end, it sets `.included` flags on the AST nodes that are then picked up by the rendering logic in the "generate" phase. + +### The generate phase + +To understand this phase from a plugin perspective, have a look at [Output Generation Hooks](https://rollupjs.org/plugin-development/#output-generation-hooks), which again contains a graph to show in which order these hooks are executed. In detail `Bundle.generate` performs the following steps + +- Assign modules to chunks via [`chunkAssignment.ts`](src/utils/chunkAssignment.ts) +- Determine the exports for each chunk by tracing the included inter-module dependencies +- Render the chunks, which is orchestrated by the [`renderChunks`](src/utils/renderChunks.ts) helper + - Render the chunks with placeholders for chunk hashes by calling `Chunk.render()` + - Determine how dynamic imports and `import.meta` references should be resolved and store this on the corresponding AST nodes. + - Determine the final deconflicted variable names and store those on the AST nodes as well in [`deconflictChunk.ts`](src/utils/deconflictChunk.ts) + - Render each module by calling the `.render` methods of their AST nodes. This is also where tree-shaken nodes are removed from the output. + - Render the format specific wrapper with imports and exports for this chunk by calling the corresponding [finaliser](src/finalisers). + - Transform the rendered chunks via the [`renderChunk`](https://rollupjs.org/plugin-development/#renderchunk) plugin hook + - Determine the final chunk hashes based on the actual rendered content and the chunk dependency graph and replace the placeholders + +## Parsing the AST + +Rollup parses code within the native/WebAssembly code. As most of Rollup is still TypeScript-based, this then needs to be transformed to a JavaScript representation. To do that efficiently, a binary buffer is constructed in Rust that can be passed without copying to TypeScript where it is further transformed. + +- The conversion to a buffer happens mostly within [`converter.rs`](rust/parse_ast/src/convert_ast/converter.rs). Here we also make sure that the buffer follows the format of the [ESTree specification](https://github.com/estree/estree). +- While the converter is still mostly hand-written, it relies on auto-generated constants to ensure that the encoder and decoder match. These are generated together with the decoders from [`generate-ast-converters.js`](scripts/generate-ast-converters.js) via `npm run build:ast-converters`. The definitions for the auto-generated converters can be found in [`ast-types.js`](scripts/ast-types.js), which is also the first file that needs to be extended to support additional AST nodes. + +There are two ways Rollup parses code into an abstract syntax tree + +- When a plugin calls [`this.parse`](https://rollupjs.org/plugin-development/#this-parse). This is a synchronous operation that returns a JSON-AST of the provided code. + - This will likely be deprecated eventually in favor of an asynchronous method that also does not directly return the JSON representation but rather a Proxy-based representation with efficient methods for traversal and manipulation. + - For this, the buffer is decoded within the auto-generated file [`bufferToAst.ts`](src/utils/bufferToAst.ts). +- When a module has been loaded. In this case, it is triggered in the `setSource` method of the [`Module`](src/Module.ts) class. + - Here, the buffer is directly used to generate the class-based Rollup-internal AST. + - The actual conversion happens in the auto-generated file [`bufferParsers.ts`](src/ast/bufferParsers.ts). + +In general, when extending the AST parsing capabilities, the following places need to be touched: + +- declare any new AST nodes or additional AST attributes in [`ast-types.js`](scripts/ast-types.js). +- write the encoder in Rust in [`converter.rs`](rust/parse_ast/src/convert_ast/converter.rs). +- create the corresponding TypeScript classes in [`ast/nodes`](src/ast/nodes). diff --git a/CHANGELOG-0.md b/CHANGELOG-0.md new file mode 100644 index 00000000000..bb65e75fe1c --- /dev/null +++ b/CHANGELOG-0.md @@ -0,0 +1,1841 @@ +# rollup changelog + +## 0.68.2 + +_2018-12-23_ + +### Bug Fixes + +- Do not assume hoisted variables to have been initialized (#2607) + +### Pull Requests + +- [#2607](https://github.com/rollup/rollup/pull/2607): Fix an issues where hoisted variables were assumed to have been initialized (@lye) + +## 0.68.1 + +_2018-12-19_ + +### Bug Fixes + +- Fix an issue with UMD wrappers where a variable is used without being defined (#2600) + +### Pull Requests + +- [#2600](https://github.com/rollup/rollup/pull/2600): Fix UMD and IIFE wrapper issues and add comprehensive functional wrapper tests (@lukastaegert) + +## 0.68.0 + +_2018-12-16_ + +### Breaking Changes + +- `optimizeChunks` is renamed to `experimentalOptimizeChunks` to reflect this feature is not production-ready yet ( #2575) + +### Features + +- Plugins can iterate all module ids via `this.moduleIds` (#2565) +- Plugins can get graph information about a module via `this.getModuleInfo(id)` (#2565) +- Plugins and JS API users get more information about the generated chunks: `dynamicImports`, `facadeModuleId`, `isDynamicEntry`, `name` (#2575) +- Tree-shaken dynamic imports will no longer create chunks or influence chunking in any way (#2575) +- Dynamic imports will no longer follow the `entryFileNames` but the `chunkFileNames` property reflecting those are solely internally used (#2575) +- If there are chunk naming conflicts, entry chunks will always take precedence (#2575) +- If an entry facade is created, only the facade chunk is marked as `isEntry` (#2575) +- Dynamic chunks will only be marked as `isEntry` if they are actually entry chunks as well; thus there is now a 1-to-1 correspondence between modules listed in `input` and chunks marked as `isEntry` (#2575) +- Chunks no longer contain imports for variables that are tree-shaken in the chunk but used in other chunks (#2584) +- Chunks will always import re-exported variables directly from the chunk where they are originally exported from ( #2584) +- Null characters will be pruned from chunk ids to allow for virtually created chunks and make `rollup-plugin-multi-entry` compatible with code-splitting and thus the upcoming 1.0 version (#2590) +- Simplify the UMD wrapper code as much as possible, especially if there are no exports (#2594) +- The UMD wrapper will now work in strict mode by checking for `self` before `this` when determining the global variable (#2594) + +### Bug Fixes + +- If a facade is created for a dynamic entry point, this facade will be imported instead of the facaded chunk (#2575) +- Manual chunks that include multiple entry points will have proper facades created for all entry points if necessary ( #2575) +- If missing exports are shimmed, the shim variable will not be global but created on a per-module basis and is deconflicted with variables having the same name (#2584) +- Missing export shims work properly in SystemJS (#2584) +- `preserveModules` now handles dynamic namespace imports (#2584) +- Fix chunk execution order in certain scenarios (#2584) +- Exports and assignments using destructuring syntax will properly update the exported variables when generating SystemJS output (#2587) +- Hashes in chunk names will now also take dynamic imports into account (#2596) + +### Pull Requests + +- [#2565](https://github.com/rollup/rollup/pull/2565): Provide module graph information on the plugin context ( @samccone) +- [#2575](https://github.com/rollup/rollup/pull/2575): Extend bundle information, tree-shake dynamic imports, fix dynamic import facade creation, support manual chunks with multiple entry points, make `optimizeChunks` experimental ( @lukastaegert) +- [#2577](https://github.com/rollup/rollup/pull/2577): Update dependencies (@lukastaegert) +- [#2584](https://github.com/rollup/rollup/pull/2584): Prune tree-shaken chunk imports, fix missing export shimming, support dynamic namespaces when preserving modules, improve chunk execution order (@lukastaegert) +- [#2587](https://github.com/rollup/rollup/pull/2587): Support exports using destructuring declarations and assignments in SystemJS (@lukastaegert) +- [#2590](https://github.com/rollup/rollup/pull/2590): Make sure chunk ids do not contain invalid characters to allow for chunks to correspond to virtual modules (@lukastaegert) +- [#2594](https://github.com/rollup/rollup/pull/2594): Simplify UMD wrapper code and make sure it works in strict mode ( @lukastaegert) +- [#2596](https://github.com/rollup/rollup/pull/2596): Take both static and dynamic dependencies into account when calculating hashes (@lukastaegert) + +## 0.67.4 + +_2018-12-03_ + +### Bug Fixes + +- Prevent corrupt source maps for files with very long lines (#2571) + +### Pull Requests + +- [#2571](https://github.com/rollup/rollup/pull/2571): Fix an issue with long lines in sourcemaps (@mislav) + +## 0.67.3 + +_2018-11-17_ + +### Bug Fixes + +- Make sure the ESM browser build is actually published to npm (#2560) +- Throw proper error when using `inlineDynamicImports` with `experimentalPreserveModules` (#2560) + +### Pull Requests + +- [#2552](https://github.com/rollup/rollup/pull/2552): Properly include ESM browser build in package (@lukastaegert) +- [#2560](https://github.com/rollup/rollup/pull/2560): Show proper error when using `inlineDynamicImports` with `experimentalPreserveModules` (@clarkdo) + +## 0.67.2 + +_2018-11-17_ + +### Bug Fixes + +- Prevent crash when not returning sourcemaps from `renderChunk` plugin hook (#2558) + +### Pull Requests + +- [#2558](https://github.com/rollup/rollup/pull/2558): Prevent crash when not returning sourcemaps from `renderChunk` ( @kyle1320) + +## 0.67.1 + +_2018-11-11_ + +### Bug Fixes + +- Deconflict CLI entry points with same name but on different paths if no explicit naming is used (#2548) + +### Pull Requests + +- [#2548](https://github.com/rollup/rollup/pull/2548): Deconflict CLI entry points with same name but on different paths if no explicit naming is used (@lukastaegert) + +## 0.67.0 + +_2018-11-04_ + +### Breaking Changes + +none + +### Features + +- Do not resolve external dynamic imports via plugins to match the logic for static external imports again (#2505) +- Support virtual modules created by plugins when preserving modules (#2511) +- Add new `output.sourcemapExcludeSources` option to exclude the actual sources from sourcemaps (#2531) + +### Bug Fixes + +- Fix TypeScript type for sourcemaps (#2507) +- Fix order of external and inter-chunk imports to match the proper execution order (#2508) +- Do not tree-shake children of unknown nodes to e.g. properly handle do-expressions via acorn plugin (#2510) +- Prevent memory leak when using the bundle as cache (#2522) +- Fix mis-placed semicolons for certain SystemJS exports (#2529) + +### Pull Requests + +- [#2505](https://github.com/rollup/rollup/pull/2505): Do not resolve external dynamic imports via plugins ( @lukastaegert) +- [#2507](https://github.com/rollup/rollup/pull/2507): Fix public sourcemap type (@aMarCruz) +- [#2508](https://github.com/rollup/rollup/pull/2508): Improve execution order of chunks and externals (@lukastaegert) +- [#2510](https://github.com/rollup/rollup/pull/2510): Do not tree-shake children of unknown nodes to e.g. properly handle do-expressions via acorn plugin (@devsnek) +- [#2511](https://github.com/rollup/rollup/pull/2511): Create chunks for virtual modules when preserving modules ( @lukastaegert) +- [#2522](https://github.com/rollup/rollup/pull/2522): Prevent memory leak when using the bundle as cache (@kyle1320) +- [#2529](https://github.com/rollup/rollup/pull/2529): Fix mis-placed semicolons for certain SystemJS exports ( @kyle1320) +- [#2531](https://github.com/rollup/rollup/pull/2531): add `sourcemapExcludeSources` option to exclude the source content from sourcemaps (@kitsonk) + +## 0.66.6 + +_2018-10-10_ + +- Properly deconflict function and class declaration ids of reassigned default exports ([#2502](https://github.com/rollup/rollup/pull/2502)) + +## 0.66.5 + +_2018-10-09_ + +- Remove cache from memory once no longer needed ([#2496](https://github.com/rollup/rollup/pull/2496)) +- Provide better error message when reexporting external namespace reexports ([#2499](https://github.com/rollup/rollup/pull/2499)) + +## 0.66.4 + +_2018-10-04_ + +- Fix links in warnings and errors ([#2471](https://github.com/rollup/rollup/pull/2471)) + +## 0.66.3 + +_2018-10-03_ + +- Detect side-effects in string.replace function arguments ([#2476](https://github.com/rollup/rollup/pull/2476)) +- Make sure chunk ids are assigned before creating output bundle ([#2483](https://github.com/rollup/rollup/pull/2483)) +- Use proper plugin name in error ([#2470](https://github.com/rollup/rollup/pull/2470)) +- Update TypeScript version and fix type errors ([#2488](https://github.com/rollup/rollup/pull/2488)) + +## 0.66.2 + +_2018-09-21_ + +- Add additional information to parse errors messages in JSON and other non-JS files ([#2466](https://github.com/rollup/rollup/pull/2466)) + +## 0.66.1 + +_2018-09-19_ + +- Ignore falsy plugins ([#2464](https://github.com/rollup/rollup/pull/2464)) +- Switch back to official TypeScript plugin ([#2465](https://github.com/rollup/rollup/pull/2465)) + +## 0.66.0 + +_2018-09-16_ + +- Support ES2019 optional catch bindings ([#2455](https://github.com/rollup/rollup/pull/2455)) +- Add option to transform paths within sourcemaps ([#2430](https://github.com/rollup/rollup/pull/2430)) +- Add renderStart and renderEnd plugin hooks ([#2438](https://github.com/rollup/rollup/pull/2438)) +- Expose ESM browser build and minify browser builds ([#2437](https://github.com/rollup/rollup/pull/2437) +- Associate hoisted variables in function bodys with function parameters ([#2456](https://github.com/rollup/rollup/pull/2456)) +- Fix issue when deconflicting variables used as pattern defaults ([#2446](https://github.com/rollup/rollup/pull/2446)) +- Properly deconflict default exported class and function expressions with ids ([#2458](https://github.com/rollup/rollup/pull/2458)) +- Faster internal test builds ([#2457](https://github.com/rollup/rollup/pull/2457)) +- Switch to rollup-plugin-typescript2 ([#2460](https://github.com/rollup/rollup/pull/2460)) +- Fix internal "perf" script ([#2433](https://github.com/rollup/rollup/pull/2433)) +- Test that errors are passed to the buildEnd hook ([#2450](https://github.com/rollup/rollup/pull/2450)) + +## 0.65.2 + +_2018-09-05_ + +- Prevent watch mode memory leak ([#2441](https://github.com/rollup/rollup/pull/2441)) + +## 0.65.1 + +_2018-09-05_ + +- Prevent globbing when using chokidar ([#2432](https://github.com/rollup/rollup/pull/2432)) + +## 0.65.0 + +_2018-08-25_ + +- Refactor and unify plugin system ([#2382](https://github.com/rollup/rollup/pull/2382)) +- Implement plugin cache API ([#2389](https://github.com/rollup/rollup/pull/2389)) +- Add watchChange plugin hook to watch changed files, deprecate asset dependencies ([#2405](https://github.com/rollup/rollup/pull/2405)) +- Refine asset handling ([#2369](https://github.com/rollup/rollup/pull/2369)) +- Implement `renderChunk` hook to replace `transformChunk` and `transformBundle` hooks ([#2406](https://github.com/rollup/rollup/pull/2406)) +- Add rollup version to plugin context ([#2394](https://github.com/rollup/rollup/pull/2394)) +- Do not resume stdin in watch mode to fix it for Lerna users ([#2410](https://github.com/rollup/rollup/pull/2410)) +- Allow `[format]` placeholder for id generation ([#2387](https://github.com/rollup/rollup/pull/2387)) +- Always log error stacks even when a code frame is given ([#2417](https://github.com/rollup/rollup/pull/2417)) +- Do not test module ids starting with `\0` as external ([#2400](https://github.com/rollup/rollup/pull/2400)) +- Fix tracing of namespace variables ([#2408](https://github.com/rollup/rollup/pull/2408)) +- Fix re-tracing of namespace variables ([#2420](https://github.com/rollup/rollup/pull/2420)) +- Properly wrap comment annotations in SystemJS exports ([#2408](https://github.com/rollup/rollup/pull/2408)) +- Fix renaming of destructured parameters ([#2419](https://github.com/rollup/rollup/pull/2419)) +- Do not display version in watch mode when using `--silent` ([#2392](https://github.com/rollup/rollup/pull/2392)) +- Make `cacheExpiry` an experimental option for now ([#2401](https://github.com/rollup/rollup/pull/2401)) +- Lint test configs on commit ([#2402](https://github.com/rollup/rollup/pull/2402)) +- Add code of conduct ([#2388](https://github.com/rollup/rollup/pull/2388)) +- Move to CircleCI ([#2390](https://github.com/rollup/rollup/pull/2390)) +- Update pull request template ([#2404](https://github.com/rollup/rollup/pull/2404)) + +## 0.64.1 + +_2018-08-07_ + +- Do not render initializers of hoisted variables in dead branches ([#2384](https://github.com/rollup/rollup/pull/2384)) + +## 0.64.0 + +_2018-08-07_ + +- Print memory consumption together with performance timings ([#2370](https://github.com/rollup/rollup/pull/2370)) +- Enable plugins to mark imports as external by returning false for resolveId ([#2351](https://github.com/rollup/rollup/pull/2351)) +- Always retain empty manual chunks ([#2362](https://github.com/rollup/rollup/pull/2362)) +- Ensure CLI warnings are shown on errors and add error for external id collisions ([#2334](https://github.com/rollup/rollup/pull/2334)) +- Remove unnecessary dependency, update dependencies, fix linting of test config ([#2376](https://github.com/rollup/rollup/pull/2376)) +- Add targeted Github issue templates ([#2356](https://github.com/rollup/rollup/pull/2356)) + +## 0.63.5 + +_2018-08-01_ + +- Ensure onwrite plugin hooks execute in sequence ([#2364](https://github.com/rollup/rollup/pull/2364)) +- Always warn when no name is provided for a global module ([#2359](https://github.com/rollup/rollup/pull/2359)) +- Add utility type for user created plugins ([#2355](https://github.com/rollup/rollup/pull/2355)) +- Remove deprecated es6 format from types ([#2349](https://github.com/rollup/rollup/pull/2349)) +- Mark inlineDynamicImports as optional in types ([#2348](https://github.com/rollup/rollup/pull/2348)) + +## 0.63.4 + +_2018-07-20_ + +- Use turbocolor instead of chalk ([#2339](https://github.com/rollup/rollup/pull/2339)) + +## 0.63.3 + +_2018-07-20_ + +- Handle expressions where "in" and "instanceof" are applied to primitive values ([#2344](https://github.com/rollup/rollup/pull/2344)) + +## 0.63.2 + +_2018-07-18_ + +- Fix bind order in for-of loops ([#2338](https://github.com/rollup/rollup/pull/2338)) + +## 0.63.1 + +_2018-07-18_ + +## 0.63.0 + +_2018-07-17_ + +- Fix many tree-shaking related issues ([#2315](https://github.com/rollup/rollup/pull/2315)) +- Add experimental support for top-level await ([#2235](https://github.com/rollup/rollup/pull/2235)) +- Prevent duplicate version printout in watch mode ([#2325](https://github.com/rollup/rollup/pull/2325)) +- Respect error frames provided by plugins ([#2309](https://github.com/rollup/rollup/pull/2309)) +- Add `esm` format alias to types ([#2327](https://github.com/rollup/rollup/pull/2327)) +- Further unify internal test setup ([#2329](https://github.com/rollup/rollup/pull/2329)) + +## 0.62.0 + +_2018-06-27_ + +- Add option to automatically shim missing exports ([#2118](https://github.com/rollup/rollup/pull/2118)) +- Inline dynamic imports that are also imported statically and only used in a single chunk ([#2295](https://github.com/rollup/rollup/pull/2295)) +- Handle caching and invalidation of assets ([#2267](https://github.com/rollup/rollup/pull/2267)) +- Fix plugin related types ([#2299](https://github.com/rollup/rollup/pull/2299)) + +## 0.61.2 + +_2018-06-23_ + +- Improve watcher error handling, only rebuild invalidated outputs ([#2296](https://github.com/rollup/rollup/pull/2296)) +- Update dependencies, make watcher more stable ([#2297](https://github.com/rollup/rollup/pull/2297)) + +## 0.61.1 + +_2018-06-21_ + +- Do not try to deconflict "undefined" ([#2291](https://github.com/rollup/rollup/pull/2291)) +- Properly track values for loop interator declarations and reassigned namespaces, add smoke test ([#2292](https://github.com/rollup/rollup/pull/2292)) + +## 0.61.0 + +_2018-06-20_ + +- Declare file dependencies via transform plugin hooks ([#2259](https://github.com/rollup/rollup/pull/2259)) +- Handle undefined values when evaluating conditionals ([#2264](https://github.com/rollup/rollup/pull/2264)) +- Handle known undefined properties when evaluating conditionals ([#2265](https://github.com/rollup/rollup/pull/2265)) +- Access watch events via the plugin context ([#2261](https://github.com/rollup/rollup/pull/2261)) +- Add option to suppress `__esModule` flag in output ([#2287](https://github.com/rollup/rollup/pull/2287)) +- Fix issue when re-declaring variables, track reassignments in more cases ([#2279](https://github.com/rollup/rollup/pull/2279)) +- Add VSCode debug settings ([#2276](https://github.com/rollup/rollup/pull/2276)) + +## 0.60.7 + +_2018-06-14_ + +- Fix typing issue ([#2269](https://github.com/rollup/rollup/pull/2269)) + +## 0.60.6 + +_2018-06-14_ + +- Track mutations of included virtual arrays ([#2263](https://github.com/rollup/rollup/pull/2263)) +- Update readme ([#2266](https://github.com/rollup/rollup/pull/2266)) + +## 0.60.5 + +_2018-06-14_ + +- Track deep reassignments of global and exported variables and improve performance ([#2254](https://github.com/rollup/rollup/pull/2254)) + +## 0.60.4 + +_2018-06-13_ + +- Properly handle initially uninitialized exports and exports of globals in SystemJS output ([#2258](https://github.com/rollup/rollup/pull/2258)) + +## 0.60.3 + +_2018-06-13_ + +- Fix types to allow watching an array of outputs ([#2262](https://github.com/rollup/rollup/pull/2262)) + +## 0.60.2 + +_2018-06-11_ + +- Permit setting an asset's source in `generateBundle` ([#2256](https://github.com/rollup/rollup/pull/2256)) +- Add automatic linting ([#2242](https://github.com/rollup/rollup/pull/2242)) + +## 0.60.1 + +_2018-06-07_ + +- Fix plugin regressions ([#2246](https://github.com/rollup/rollup/pull/2246)) +- Avoid conflicts for large numbers of variables ([#2244](https://github.com/rollup/rollup/pull/2244)) + +## 0.60.0 + +_2018-06-06_ + +- New plugin hooks: transformChunk, buildStart, buildEnd; extended plugin context with warn, error, resolveId, isExternal, emitAsset, setAssetSource and getAssetFileName available to any hook ([#2208](https://github.com/rollup/rollup/pull/2208)) +- [BREAKING] Deprecate the `legacy` option and thus IE8 support ([#2141](https://github.com/rollup/rollup/pull/2141)) +- Detect more known extensions and load .mjs without extension ([#2211](https://github.com/rollup/rollup/pull/2211)) +- Add compact output mode ([#2151](https://github.com/rollup/rollup/pull/2151)) +- Significantly improve sourcemap generation performance ([#2228](https://github.com/rollup/rollup/pull/2228)) +- Enable naming SystemJS modules ([#2028](https://github.com/rollup/rollup/pull/2028)) +- Do not use alternate screen if clearScreen is set in watch mode ([#2125](https://github.com/rollup/rollup/pull/2125)) +- Allow object input form for code-splitting in watch mode ([#2217](https://github.com/rollup/rollup/pull/2217)) +- Track reassignments of methods of exports from outside ([#2240](https://github.com/rollup/rollup/pull/2240)) +- Preserve id of default exported functions and classes ([#2234](https://github.com/rollup/rollup/pull/2234)) +- Add semicolons after default exports ([#2209](https://github.com/rollup/rollup/pull/2209)) +- Fix build problems on Windows ([#2232](https://github.com/rollup/rollup/pull/2232)) +- Display install size in readme ([#2196](https://github.com/rollup/rollup/pull/2196)) +- Improve preserve modules test ([#2236](https://github.com/rollup/rollup/pull/2236)) + +## 0.59.4 + +_2018-05-28_ + +- Fix performance regression when many return statements are used ([#2218](https://github.com/rollup/rollup/pull/2218)) + +## 0.59.3 + +_2018-05-24_ + +- Fix reassignment tracking for constructor parameters ([#2214](https://github.com/rollup/rollup/pull/2214)) + +## 0.59.2 + +_2018-05-21_ + +- Fix reassignment tracking in for-in loops ([#2205](https://github.com/rollup/rollup/pull/2205)) + +## 0.59.1 + +_2018-05-16_ + +- Fix infinite recursion when determining literal values of circular structures ([#2193](https://github.com/rollup/rollup/pull/2193)) +- Fix invalid code when simplifying expressions without spaces ([#2194](https://github.com/rollup/rollup/pull/2194)) + +## 0.59.0 + +_2018-05-15_ + +- Tree-shake statically analysable dynamic conditionals ([#2167](https://github.com/rollup/rollup/pull/2167)) +- Do not emit empty chunks when code-splitting or empty files when preserving modules ([#2128](https://github.com/rollup/rollup/pull/2128)) +- Support `import.meta.url` ([#2164](https://github.com/rollup/rollup/pull/2164)) +- Add `esm` format alias ([#2102](https://github.com/rollup/rollup/pull/2102)) +- Use alphanumeric base64 characters when deconflicting variables ([#2188](https://github.com/rollup/rollup/pull/2188)) +- Improve handling of external modules imported as both default and named imports ([#2136](https://github.com/rollup/rollup/pull/2136)) +- Properly deconflict named imports from other chunks ([#2177](https://github.com/rollup/rollup/pull/2177)) +- Fix an issue with namespaces containing reexports ([#2157](https://github.com/rollup/rollup/pull/2157)) +- Fix an issue with with incorrectly mapped default exports when code-splitting CJS or AMD modules ([#2178](https://github.com/rollup/rollup/pull/2178)) +- Fix an issue with wrong paths of relative external imports ([#2160](https://github.com/rollup/rollup/pull/2160)) +- Fix an issue when using default exports and `interop: false` ([#2149](https://github.com/rollup/rollup/pull/2149)) +- Fix in issue with invalid syntax in SystemJS output ([#2187](https://github.com/rollup/rollup/pull/2187)) +- Fix an issue when tree-shaking call expressions and reassigned variables ([#2186](https://github.com/rollup/rollup/pull/2186)) +- Fix file paths in source maps ([#2161](https://github.com/rollup/rollup/pull/2161)) +- Fix wrong file name in error message ([#2137](https://github.com/rollup/rollup/pull/2137)) +- Always use npm 5 on CI ([#2185](https://github.com/rollup/rollup/pull/2185)) + +## 0.58.2 + +_2018-04-23_ + +- Fix rendering of certain statically resolvable if statements ([#2146](https://github.com/rollup/rollup/pull/2146)) + +## 0.58.1 + +_2018-04-18_ + +- Fix comment detection ([#2129](https://github.com/rollup/rollup/pull/2129)) + +## 0.58.0 + +_2018-04-16_ + +- Support individual chunk names with optional content hashes ([#2068](https://github.com/rollup/rollup/pull/2068)) +- Support manually created chunks ([#2084](https://github.com/rollup/rollup/pull/2084)) +- Automatically import deep dependencies when code splitting for better performance ([#2073](https://github.com/rollup/rollup/pull/2073)) +- Automatically minify internal export/import names for esm and system output ([#2087](https://github.com/rollup/rollup/pull/2087)) +- Add option to automatically merge small chunks ([#2090](https://github.com/rollup/rollup/pull/2090)) +- Significantly improve tree-shaking performance ([#2119](https://github.com/rollup/rollup/pull/2119)) +- Enable tree-shaking for logical expressions ([#2098](https://github.com/rollup/rollup/pull/2098)) +- Rework external types and reduce type related dependencies ([#2108](https://github.com/rollup/rollup/pull/2108)) +- Support parallel dependency resolution ([#2116](https://github.com/rollup/rollup/pull/2116)) +- Improve deprecation handling ([#2076](https://github.com/rollup/rollup/pull/2076)) +- Enable `--perf` timings in watch mode ([#2065](https://github.com/rollup/rollup/pull/2065)) +- Improve performance timers ([#2111](https://github.com/rollup/rollup/pull/2111)) +- Improve error handling for plugins ([#2100](https://github.com/rollup/rollup/pull/2100)) +- Improve error when using `--dir` in a single file build ([#2123](https://github.com/rollup/rollup/pull/2123)) +- Do not warn for external imports that are unused due to tree-shaking ([#2124](https://github.com/rollup/rollup/pull/2124)) +- Update mixed export warning message ([#2107](https://github.com/rollup/rollup/pull/2107)) +- Remove duplicate badges from readme ([#2083](https://github.com/rollup/rollup/pull/2083)) +- Update readme examples ([#2086](https://github.com/rollup/rollup/pull/2086)) + +## 0.57.1 + +_2018-03-17_ + +- Improve sourcemap generation performance ([#2062](https://github.com/rollup/rollup/pull/2062)) +- Add reserved config option namespace and improve CLI interface ([#2063](https://github.com/rollup/rollup/pull/2063)) +- Fix issue with default exported function and class expressions ([#2059](https://github.com/rollup/rollup/pull/2059)) +- Replace `forEach` with faster `for` loops in some places ([#2064](https://github.com/rollup/rollup/pull/2064)) + +## 0.57.0 + +_2018-03-15_ + +- Add option to preserve the module structure instead of bundling ([#1922](https://github.com/rollup/rollup/pull/1922)) +- Enable watch mode when code-splitting ([#2035](https://github.com/rollup/rollup/pull/2035)) +- Optionally pass CLI commands to config file ([#1926](https://github.com/rollup/rollup/pull/1926)) +- Option to add correct `.toString` tags to namespaces ([#2041](https://github.com/rollup/rollup/pull/2041)) +- Option and scripts to display performance timings ([#2045](https://github.com/rollup/rollup/pull/2045)) +- Fixes for exported or early accessed namespaces + improved namespace indentation ([#2041](https://github.com/rollup/rollup/pull/2041)) +- Include missing TypeScript dependencies ([#1965](https://github.com/rollup/rollup/pull/1965)) +- Add #\_PURE annotation to frozen namespaces ([#2044](https://github.com/rollup/rollup/pull/2044)) +- Improve sourcemap and tree-shaking performance ([#2052](https://github.com/rollup/rollup/pull/2052)) +- Inline sourcemap lookups and make rollup smaller ([#2055](https://github.com/rollup/rollup/pull/2055)) +- Use updated magic-string types ([#2057](https://github.com/rollup/rollup/pull/2057)) +- [BREAKING] Revert class id preservation from #2025 ([#2048](https://github.com/rollup/rollup/pull/2048)) +- [BREAKING] Refactor missing export plugin hook ([#1987](https://github.com/rollup/rollup/pull/1987)) + +## 0.56.5 + +_2018-03-07_ + +- Preserve ids when deconflicting classes ([#2025](https://github.com/rollup/rollup/pull/2025)) +- Fix an issue with re-exported namespace imports ([#2034](https://github.com/rollup/rollup/pull/2034)) +- Prevent an infinite loop when binding member expressions ([#1963](https://github.com/rollup/rollup/pull/1963)) +- Convert code style via prettier ([#2031](https://github.com/rollup/rollup/pull/2031)) +- Fix links in documentation ([#2026](https://github.com/rollup/rollup/pull/2026)) + +## 0.56.4 + +_2018-03-05_ + +- Make rollup builds reproducible ([#2024](https://github.com/rollup/rollup/pull/2024)) +- Improve error handling for source maps ([#2012](https://github.com/rollup/rollup/pull/2012)) +- Properly handle SystemJS default exports without semicolons ([#2019](https://github.com/rollup/rollup/pull/2019)) +- Properly handle importing the same variable several times when code-splitting ([#2020](https://github.com/rollup/rollup/pull/2020)) +- Improve re-export tracing ([#2021](https://github.com/rollup/rollup/pull/2021)) +- Apply "prettier" on commit ([#2017](https://github.com/rollup/rollup/pull/2017)) +- Automatically clean up outdated tests ([#2009](https://github.com/rollup/rollup/pull/2009)) +- Add SystemJS output to form tests ([#2022](https://github.com/rollup/rollup/pull/2022)) +- Improve internal build configuration ([#2016](https://github.com/rollup/rollup/pull/2016)) + +## 0.56.3 + +_2018-02-25_ + +- Fix issues around default exports and module facades ([#2001](https://github.com/rollup/rollup/pull/2001)) +- Improve and fix internal chunk interface ([#1994](https://github.com/rollup/rollup/pull/1994)) +- Fix superfluous semicolons added after declarations ([#1999](https://github.com/rollup/rollup/pull/1999)) +- Improve code-splitting tests ([#1990](https://github.com/rollup/rollup/pull/1990)) + +## 0.56.2 + +_2018-02-19_ + +- Fix handling of reassigned default exports ([#1975](https://github.com/rollup/rollup/pull/1975)) +- Fix handling of renamed exports in entry points ([#1977](https://github.com/rollup/rollup/pull/1977)) +- Update internal TypeScript version ([#1980](https://github.com/rollup/rollup/pull/1980)) +- Omit compiled source files from published types ([#1981](https://github.com/rollup/rollup/pull/1981)) +- Fix example in readme file ([#1984](https://github.com/rollup/rollup/pull/1984)) +- Fix non-replaced dynamic imports in non-ESM output ([#1985](https://github.com/rollup/rollup/pull/1985)) + +## 0.56.1 + +_2018-02-16_ + +- Fix regression when rendering switch statements ([#1971](https://github.com/rollup/rollup/pull/1971)) + +## 0.56.0 + +_2018-02-15_ + +- Update to ECMAScript 2018 ([#1953](https://github.com/rollup/rollup/pull/1953)) +- Rework tree-shaking rendering algorithm ([#1949](https://github.com/rollup/rollup/pull/1949)) +- Tree-shake pure prototype calls on literals ([#1916](https://github.com/rollup/rollup/pull/1916)) +- Expose AST parser to plugins ([#1945](https://github.com/rollup/rollup/pull/1945)) +- Fix namespace re-export deconflicting ([#1960](https://github.com/rollup/rollup/pull/1960)) +- Allow globals to be re-exported ([#1959](https://github.com/rollup/rollup/pull/1959)) +- Fix internal performance timers ([#1966](https://github.com/rollup/rollup/pull/1966)) + +## 0.55.5 + +_2018-02-10_ + +- Remove OpenCollective dependency ([#1915](https://github.com/rollup/rollup/pull/1915)) + +## 0.55.4 + +_2018-02-09_ + +- Improve name deconflicting of external variables ([#1930](https://github.com/rollup/rollup/pull/1930)) +- Improve re-export handling ([#1947](https://github.com/rollup/rollup/pull/1947)) +- Mark preserveSymlinks option as optional ([#1939](https://github.com/rollup/rollup/pull/1939)) +- Enable code-splitting tests to check directory structures ([#1924](https://github.com/rollup/rollup/pull/1924)) +- Improve TypeScript definition test ([#1954](https://github.com/rollup/rollup/pull/1954)) + +## 0.55.3 + +_2018-02-01_ + +- Remove OpenCollective dependency ([#1915](https://github.com/rollup/rollup/pull/1915)) + +## 0.55.2 + +_2018-02-01_ + +- Add option to not follow symlinks ([#1819](https://github.com/rollup/rollup/pull/1819)) +- Fix crash in windows shell ([#1928](https://github.com/rollup/rollup/pull/1928)) +- Fix and test for external TypeScript errors ([#1903](https://github.com/rollup/rollup/pull/1903)) +- Activate OpenCollective ([#1915](https://github.com/rollup/rollup/pull/1915)) +- Optimize CI scripts ([#1921](https://github.com/rollup/rollup/pull/1921)) + +## 0.55.1 + +_2018-01-26_ + +- Improve dynamic import workflow ([#1907](https://github.com/rollup/rollup/pull/1907)) +- Properly handle multiple dynamic imports of the same module ([#1911](https://github.com/rollup/rollup/pull/1911)) +- Fix import specifier deshadowing ([#1912](https://github.com/rollup/rollup/pull/1912)) +- Allow plugin load hook to return an empty string ([#1908](https://github.com/rollup/rollup/pull/1908)) +- Let onwarn handler accept strings ([#1905](https://github.com/rollup/rollup/pull/1905)) + +## 0.55.0 + +_2018-01-23_ + +- Support code splitting ([#1841](https://github.com/rollup/rollup/pull/1841)) +- Support SystemJS as output format ([#1897](https://github.com/rollup/rollup/pull/1897)) +- Allow injecting acorn plugins ([#1857](https://github.com/rollup/rollup/pull/1857)) +- Add `missingExport` plugin hook ([#1845](https://github.com/rollup/rollup/pull/1845)) +- No longer parse config files via bublé ([#1899](https://github.com/rollup/rollup/pull/1899)) +- Use externally maintained dynamic import acorn plugin ([#1891](https://github.com/rollup/rollup/pull/1891)) +- Fix an error message ([#1886](https://github.com/rollup/rollup/pull/1886)) +- Refactor internal rendering options ([#1900](https://github.com/rollup/rollup/pull/1900)) +- Extract internal path resolution ([#1879](https://github.com/rollup/rollup/pull/1879)) +- Extract internal bundle option handling ([#1880](https://github.com/rollup/rollup/pull/1880)) +- Add import description type ([#1884](https://github.com/rollup/rollup/pull/1884)) +- Clean up watch options types ([#1860](https://github.com/rollup/rollup/pull/1860)) +- Clean up some tests ([#1888](https://github.com/rollup/rollup/pull/1888)) + +## 0.54.1 + +_2018-01-17_ + +- Fix TypeScript errors in emitted type definitions ([#1871](https://github.com/rollup/rollup/pull/1871)) + +## 0.54.0 + +_2018-01-12_ + +- Automatically inline locally resolvable dynamic imports ([#1816](https://github.com/rollup/rollup/pull/1816)) +- Preserve directives in function bodies ([#1856](https://github.com/rollup/rollup/pull/1856)) +- Refactor an error notification ([#1846](https://github.com/rollup/rollup/pull/1846)) +- Refactor a wrong import ([#1863](https://github.com/rollup/rollup/pull/1863)) +- Improve emitted TypeScript definitions ([#1864](https://github.com/rollup/rollup/pull/1864)) +- Refactor unused import ([#1866](https://github.com/rollup/rollup/pull/1866)) + +## 0.53.4 + +_2018-01-10_ + +- More type cleanup ([#1858](https://github.com/rollup/rollup/pull/1858)) +- Use chalks internal helper to detect if colors should be used ([#1853](https://github.com/rollup/rollup/pull/1853)) +- Refactor entity handling to use interfaces ([#1840](https://github.com/rollup/rollup/pull/1840)) +- Use immutable.js internal types ([#1844](https://github.com/rollup/rollup/pull/1844)) +- Ship `TypeScript` declaration files ([#1837](https://github.com/rollup/rollup/pull/1837)) + +## 0.53.3 + +_2018-01-02_ + +- Use correct name when re-exporting from external modules ([#1794](https://github.com/rollup/rollup/pull/1794)) +- Disable warnings when `resolveId` returns false ([#1825](https://github.com/rollup/rollup/pull/1825)) + +## 0.53.2 + +_2017-12-30_ + +- Properly handle output arrays in the JavaScript API ([#1827](https://github.com/rollup/rollup/pull/1827)) + +## 0.53.1 + +_2017-12-28_ + +- Properly deprecate more config options ([#1812](https://github.com/rollup/rollup/pull/1812)) +- Pass output options to `transformBundle` plugin hook ([#1813](https://github.com/rollup/rollup/pull/1813)) + +## 0.53.0 + +_2017-12-22_ + +- Experimental dynamic import support ([#1790](https://github.com/rollup/rollup/pull/1790)) +- Unify config validation ([#1805](https://github.com/rollup/rollup/pull/1805)) + +## 0.52.3 + +_2017-12-19_ + +- Properly hoist default exported functions in more situations ([#1799](https://github.com/rollup/rollup/pull/1799)) +- Allow plugin transformations to not overwrite source maps by returning null ([#1797](https://github.com/rollup/rollup/pull/1797)) +- Provide more parameters to "external" handler ([#1792](https://github.com/rollup/rollup/pull/1792)) + +## 0.52.2 + +_2017-12-15_ + +- No longer ignore side-effects in JSON.parse and JSON.stringify ([#1785](https://github.com/rollup/rollup/pull/1785)) +- Updated links in warnings ([#1776](https://github.com/rollup/rollup/pull/1776)) +- No longer prevent self-imports ([#1777](https://github.com/rollup/rollup/pull/1777)) +- Properly hoist default exported functions ([#1787](https://github.com/rollup/rollup/pull/1787)) +- Prevent corruption when re-exporting default exports ([#1765](https://github.com/rollup/rollup/pull/1765)) + +## 0.52.1 + +_2017-12-05_ + +- Improve deprecation warnings ([#1765](https://github.com/rollup/rollup/pull/1765)) +- Properly use stdin ([#1774](https://github.com/rollup/rollup/pull/1774)) +- Let --environment be used multiple times ([#1768](https://github.com/rollup/rollup/pull/1768)) +- Always transpile config files ([#1759](https://github.com/rollup/rollup/pull/1759)) +- Respect globals option in headers of UMD and IIFE files ([#1747](https://github.com/rollup/rollup/pull/1747)) + +## 0.52.0 + +_2017-11-25_ + +- Accept config as promise ([#1731](https://github.com/rollup/rollup/pull/1731)) +- Accept promises for intro/outro/banner/footer ([#1253](https://github.com/rollup/rollup/pull/1253)) +- Option to prevent freezing of namespace imports ([#1696](https://github.com/rollup/rollup/pull/1696)) +- Option to retain all output in watch mode ([#1688](https://github.com/rollup/rollup/pull/1688)) +- Options to fine-tune treeshaking ([#1760](https://github.com/rollup/rollup/pull/1760)) + +## 0.51.8 + +_2017-11-19_ + +- Fix speed problems by simplifying treeshaking reassignment handling ([#1740](https://github.com/rollup/rollup/pull/1740)) +- Update dependencies ([#1742](https://github.com/rollup/rollup/pull/1742)) + +## 0.51.7 + +_2017-11-17_ + +- Keep "this"-context when calling sequence expressions ([#1724](https://github.com/rollup/rollup/pull/1724)) + +## 0.51.6 + +_2017-11-16_ + +- Use sourcemaps to determine error locations ([#1728](https://github.com/rollup/rollup/pull/1728)) + +## 0.51.5 + +_2017-11-11_ + +- Fix regressions with uninitialised conditional expressions ([#1720](https://github.com/rollup/rollup/pull/1720)) + +## 0.51.4 + +_2017-11-11_ + +- Fix regressions preventing builds ([#1725](https://github.com/rollup/rollup/pull/1725)) + +## 0.51.3 + +_2017-11-10_ + +- Fix regression when treeshaking sequence expressions ([#1717](https://github.com/rollup/rollup/pull/1717)) + +## 0.51.2 + +_2017-11-09_ + +- Fix treeshaking regression when labels are used inside functions ([#1712](https://github.com/rollup/rollup/pull/1712)) + +## 0.51.1 + +_2017-11-08_ + +- Fix an issue with empty return statements ([#1704](https://github.com/rollup/rollup/pull/1704)) + +## 0.51.0 + +_2017-11-08_ + +- Massive improvements to the treeshaking algorithm ([#1667](https://github.com/rollup/rollup/pull/1667)) + +## 0.50.1 + +_2017-11-08_ + +- Fix treeshaking regression ([#1695](https://github.com/rollup/rollup/pull/1695)) +- Treeshaking improvements ([#1650](https://github.com/rollup/rollup/pull/1650)) +- Enable installation from Github ([#1670](https://github.com/rollup/rollup/pull/1670)) +- Update documentation ([#1660](https://github.com/rollup/rollup/pull/1660)) + +## 0.50.0 + +_2017-09-16_ + +- Many treeshaking improvements ([#1624](https://github.com/rollup/rollup/pull/1624)) +- Show finish time in watch mode ([#1620](https://github.com/rollup/rollup/pull/1620)) + +## 0.49.3 + +_2017-09-08_ + +- Respect `watch` options ([#1596](https://github.com/rollup/rollup/issues/1596)) +- Fix treeshaking regressions ([#1604](https://github.com/rollup/rollup/pull/1604)) +- Allow `-o` to work with `output.format` ([#1606](https://github.com/rollup/rollup/pull/1606)) + +## 0.49.2 + +_2017-08-29_ + +- Fix treeshaking regressions ([#1591](https://github.com/rollup/rollup/pull/1591)) + +## 0.49.1 + +_2017-08-28_ + +- Fix treeshaking regressions ([#1586](https://github.com/rollup/rollup/pull/1586)) + +## 0.49.0 + +_2017-08-27_ + +- Completely update the treeshaking algorithm ([#1582](https://github.com/rollup/rollup/pull/1582)) +- Only flip screen buffer if appropriate ([#1574](https://github.com/rollup/rollup/pull/1574)) +- Guard against two instances creating the same dir ([#1576](https://github.com/rollup/rollup/pull/1576)) + +## 0.48.2 + +- Paths is an output option ([#1569](https://github.com/rollup/rollup/pull/1569)) + +## 0.48.1 + +- Print deprecation warnings in watch mode, and fix options when watcher restarts ([#1568](https://github.com/rollup/rollup/pull/1568)) + +## 0.48.0 + +- Numerous changes to the `options` object and CLI arguments ([#1479](https://github.com/rollup/rollup/issues/1479)). See [this gist](https://gist.github.com/Rich-Harris/d472c50732dab03efeb37472b08a3f32) for a rundown. + +## 0.47.6 + +- Set `process.env.ROLLUP_WATCH` _before_ loading config file + +## 0.47.5 + +- Fix broken multi-bundle configs with `rollup.watch` ([#1532](https://github.com/rollup/rollup/issues/1532)) + +## 0.47.4 + +- Delete cached config file before reloading in watch mode + +## 0.47.3 + +- Deshadow aliased imports ([#1550](https://github.com/rollup/rollup/issues/1550)) + +## 0.47.2 + +- Rebuild with dependency that npm randomly deleted + +## 0.47.1 + +- Ignore external namespace imports when deshadowing ([#1547](https://github.com/rollup/rollup/issues/1547)) + +## 0.47.0 + +- Watch config file, restart `rollup.watch` on change ([#1535](https://github.com/rollup/rollup/issues/1535)) +- Correctly render `export { foo } from` declarations in `es` output ([#1543](https://github.com/rollup/rollup/pull/1543)) +- Reinstate missing `rollup.VERSION` + +## 0.46.3 + +- init for/for-of loop section head with correct scopes ([#1538](https://github.com/rollup/rollup/issues/1538), [#1539](https://github.com/rollup/rollup/issues/1539)) +- Fix namespace imports and re-exports in `es` output ([#1511](https://github.com/rollup/rollup/issues/1511)) +- Deshadow indirectly imported namespaces ([#1488](https://github.com/rollup/rollup/issues/1488), [#1505](https://github.com/rollup/rollup/issues/1505)) + +## 0.46.2 + +- Pass options to `bundle.write` correctly in `rollup.watch` ([#1533](https://github.com/rollup/rollup/issues/1533)) +- init for-in loop section head with correct scopes ([#1480](https://github.com/rollup/rollup/issues/1480)) +- support `--no-interop` flag ([#1524](https://github.com/rollup/rollup/issues/1524)) + +## 0.46.1 + +- Remove `rollup.watch` from browser build ([#1530](https://github.com/rollup/rollup/issues/1530)) +- Remove `source-map-support` dependency ([#1528](https://github.com/rollup/rollup/issues/1528)) + +## 0.46.0 + +- `options.format` is now required ([#1491](https://github.com/rollup/rollup/pull/1491)) +- if `options.format` is `es6`, it will now throw an error (should be `es`) ([#1491](https://github.com/rollup/rollup/pull/1491)) +- Add experimental `rollup.watch` method, replacing [rollup-watch](https://github.com/rollup/rollup-watch) ([#1491](https://github.com/rollup/rollup/pull/1491)) +- Batch warnings together in CLI output ([#1491](https://github.com/rollup/rollup/pull/1491)) +- Clear screen between rebuilds in `--watch` mode ([#1491](https://github.com/rollup/rollup/pull/1491)) +- `onwarn` function's second argument is the default handler, allowing easier filtering without reimplementing any logic ([#1491](https://github.com/rollup/rollup/pull/1491)) +- Prevent semi-colon removal after variable declaration that is for loop body ([#1275](https://github.com/rollup/rollup/issues/1275)) +- Return `exports` for namespaced but non-extended IIFE bundles ([#1492](https://github.com/rollup/rollup/issues/1492)) +- Fix scoping in switch statements ([#1498](https://github.com/rollup/rollup/pull/1498)) +- Handle side-effects in tagged template expressions ([#1508](https://github.com/rollup/rollup/pull/1508)) +- More descriptive error for missing options.format ([#1510](https://github.com/rollup/rollup/pull/1510)) +- Refactor scope handling ([#1517](https://github.com/rollup/rollup/pull/1517)) +- Handle failure of a config in multi-config build ([#1513](https://github.com/rollup/rollup/issues/1513)) + +## 0.45.2 + +- Fix interop when import is a string ([#1486](https://github.com/rollup/rollup/issues/1486)) +- Separate `resolvedIds` from `resolvedExternalIds` ([#1490](https://github.com/rollup/rollup/pull/1490)) +- Add `--extend` flag to CLI ([#1482](https://github.com/rollup/rollup/pull/1482)) + +## 0.45.1 + +- Remove `weak` from `optionalDependencies` ([#1483](https://github.com/rollup/rollup/issues/1483)) + +## 0.45.0 + +- [BREAKING] `bundle.generate(...)` returns a Promise, so that `transformBundle` plugin hooks can be asynchronous ([#1474](https://github.com/rollup/rollup/issues/1474)) + +## 0.44.0 + +- [BREAKING] Don't extend existing globals, unless `options.extend` is true ([#827](https://github.com/rollup/rollup/issues/827)) +- Fix handling of catch clause parameters ([#1462](https://github.com/rollup/rollup/issues/1462)) + +## 0.43.1 + +- Fix memory leak on incremental rebuilds ([#883](https://github.com/rollup/rollup/issues/883)) +- Allow `this.warn` and `this.error` to accept a `{line, column}` object as an alternative to a character index ([#1265](https://github.com/rollup/rollup/issues/1265)) +- Print more useful error if entry module is 'external' ([#1264](https://github.com/rollup/rollup/issues/1264)) +- Catch errors in `bundle.generate` options ([#1463](https://github.com/rollup/rollup/pull/1463)) +- Fix magic-string deprecation warning ([#1445](https://github.com/rollup/rollup/pull/1445)) + +## 0.43.0 + +- Allow config files to import JSON ([#1426](https://github.com/rollup/rollup/issues/1426)) +- Allow undefined imports in interop block ([#1341](https://github.com/rollup/rollup/issues/1341)) +- Add `process.env.ROLLUP_WATCH = 'true'` in watch mode ([#1429](https://github.com/rollup/rollup/issues/1429)) +- Add `pureExternalModules` option ([#1352](https://github.com/rollup/rollup/issues/1352)) +- Allow plugins to specify `options.entry` ([#1270](https://github.com/rollup/rollup/issues/1270)) +- Update dependencies + +## 0.42.0 + +- Deprecate `options.moduleId` in favour of `options.amd.id` ([#1365](https://github.com/rollup/rollup/pull/1365)) +- Add `options.amd.define` option to specify name of AMD `define` function ([#1365](https://github.com/rollup/rollup/pull/1365)) +- Fix incorrect class removal with `treeshake: false` ([#1375](https://github.com/rollup/rollup/pull/1375)) +- Deconflict module exports imported as namespaces ([#1384](https://github.com/rollup/rollup/issues/1384)) +- Handle bare self-imports ([#1274](https://github.com/rollup/rollup/issues/1274)) +- Allow config file to export an array of multiple configs ([#1389](https://github.com/rollup/rollup/pull/1389)) +- Handle exponentiation operator, and fail gracefully on unknown operators ([#1416](https://github.com/rollup/rollup/issues/1416)) +- Add `watch` option ([#1424](https://github.com/rollup/rollup/pull/1424)) + +## 0.41.6 + +- Preserve `originalSourceMap` on incremental rebuilds for loaders with sourcemaps ([#1336](https://github.com/rollup/rollup/issues/1336)) + +## 0.41.5 + +- Wrap ternary consequent/alternate sequences in parens ([#1273](https://github.com/rollup/rollup/issues/1273)) +- Fix erroneous warning on multiple `export * from` declarations with defaults ([#1278](https://github.com/rollup/rollup/issues/1278)) +- Prevent variable conflicts with `treeshake: false` ([#1268](https://github.com/rollup/rollup/issues/1268)) +- Allow missing `source` when collapsing sourcemaps ([#1254](https://github.com/rollup/rollup/issues/1254)) +- Allow plugins to log with strings ([#1316](https://github.com/rollup/rollup/pull/1316)) + +## 0.41.4 + +- Fix cases of multiple `export * from 'external'` declarations ([#1252](https://github.com/rollup/rollup/issues/1252)) +- Fix 'TODO' error message ([#1257](https://github.com/rollup/rollup/issues/1257)) + +## 0.41.3 + +- Don't treat `this.foo` as possible namespace ([#1258](https://github.com/rollup/rollup/issues/1258)) + +## 0.41.2 + +- Optimize `namespace['foo']` references ([#1240](https://github.com/rollup/rollup/pull/1240)) + +## 0.41.1 + +- Include `new` expressions where callee is a class with side-effects ([#980](https://github.com/rollup/rollup/issues/980) [#1233](https://github.com/rollup/rollup/issues/1233)) + +## 0.41.0 + +- Add `this.warn(...)` and `this.error(...)` methods to plugin `transform` hook contexts ([#1140](https://github.com/rollup/rollup/issues/1140)) +- `throw` always considered to be a side effect ([#1227](https://github.com/rollup/rollup/pull/1227)) + +## 0.40.2 + +- Add `file` property to sourcemaps for bundles with plugins ([#986](https://github.com/rollup/rollup/issues/986)) +- Don't require globals for empty imports ([#1217](https://github.com/rollup/rollup/issues/1217)) + +## 0.40.1 + +- Allow missing space between `export default` and declaration ([#1218](https://github.com/rollup/rollup/pull/1218)) + +## 0.40.0 + +- [BREAKING] Better, more consistent error logging ([#1212](https://github.com/rollup/rollup/pull/1212)) +- Don't use colours and emojis for non-TTY stderr ([#1201](https://github.com/rollup/rollup/issues/1201)) + +## 0.39.2 + +- Prevent mutation of cached ASTs (fixes stack overflow with rollup-watch) ([#1205](https://github.com/rollup/rollup/pull/1205)) + +## 0.39.1 + +- Ignore `var` initialisers in dead branches ([#1198](https://github.com/rollup/rollup/issues/1198)) + +## 0.39.0 + +- [BREAKING] Warnings are objects, rather than strings ([#1194](https://github.com/rollup/rollup/issues/1194)) + +## 0.38.3 + +- More informative warning for implicit external dependencies ([#1051](https://github.com/rollup/rollup/issues/1051)) +- Warn when creating browser bundle with external dependencies on Node built-ins ([#1051](https://github.com/rollup/rollup/issues/1051)) +- Statically analyse LogicalExpression nodes, for better dead code removal ([#1061](https://github.com/rollup/rollup/issues/1061)) + +## 0.38.2 + +- Preserve `var` declarations in dead branches ([#997](https://github.com/rollup/rollup/issues/997)) +- Warn if exporting a call expression that looks like a function declaration ([#1011](https://github.com/rollup/rollup/issues/1011)) +- Wrap function expressions in parentheses if necessary ([#1011](https://github.com/rollup/rollup/issues/1011)) + +## 0.38.1 + +- Fix sourcemap comment removal ([#1104](https://github.com/rollup/rollup/issues/1104)) +- Warn if empty bundle is generated ([#444](https://github.com/rollup/rollup/issues/444)) +- Support ES2017 syntax ([#492](https://github.com/rollup/rollup/issues/492)) +- Remove unused imports from external modules ([#595](https://github.com/rollup/rollup/issues/595)) +- Remove unused function and class declarations inside function bodies ([#1108](https://github.com/rollup/rollup/issues/1108), [#1178](https://github.com/rollup/rollup/issues/1178)) +- Deconflict function expression IDs ([#1176](https://github.com/rollup/rollup/issues/1176)) + +## 0.38.0 + +- [BREAKING] `export { foo as default }` creates live binding ([#1078](https://github.com/rollup/rollup/issues/1078)) +- Prevent sourceMappingURL removal edge case ([#988](https://github.com/rollup/rollup/issues/988)) +- Bind function expression IDs to the correct scope ([#1083](https://github.com/rollup/rollup/issues/1083)) +- Correctly deshadow destructured parameters with assignments ([#1008](https://github.com/rollup/rollup/issues/1008)) + +## 0.37.2 + +- Remove unused `new` expressions without side-effects ([#179](https://github.com/rollup/rollup/issues/179)) +- Only remove valid sourceMappingURL comments ([#1132](https://github.com/rollup/rollup/issues/1132)) +- Ensure blocks containing activated `var` declarations are included in output ([#1113](https://github.com/rollup/rollup/issues/1113)) +- Support plugin outros ([#1116](https://github.com/rollup/rollup/issues/1116)) + +## 0.37.1 + +- Follow symlinks ([#447](https://github.com/rollup/rollup/issues/447)) +- Fix tree-shaking of recursive functions and other cases ([#1120](https://github.com/rollup/rollup/issues/1120), [#1142](https://github.com/rollup/rollup/issues/1142)) +- Support module names that require quotes ([#582](https://github.com/rollup/rollup/issues/582), [#584](https://github.com/rollup/rollup/issues/584)) +- Fix [#957](https://github.com/rollup/rollup/issues/957) + +## 0.37.0 + +- [BREAKING] Default exports are not included in reified namespaces ([#1028](https://github.com/rollup/rollup/issues/1028)) +- Parentheses do not defeat tree-shaking ([#1101](https://github.com/rollup/rollup/issues/1101), [#1128](https://github.com/rollup/rollup/issues/1128)) +- More `legacy` fixes: do not create getters ([#1069](https://github.com/rollup/rollup/pull/1069)), do not include `__esModule` ([#1068](https://github.com/rollup/rollup/pull/1068)), quote reserved property names ([#1057](https://github.com/rollup/rollup/pull/1057)) +- Fix missing namespace member warnings ([#1045](https://github.com/rollup/rollup/issues/1045)) +- Fix TypeError in arrow function without braces returning a function ([#1062](https://github.com/rollup/rollup/pull/1062)) + +## 0.36.4 + +- Only depend on program-level call expressions ([#977](https://github.com/rollup/rollup/issues/977)) + +## 0.36.3 + +- Add `legacy` option for IE8 support ([#989](https://github.com/rollup/rollup/pull/989)) + +## 0.36.2 + +- Insert semicolons where necessary to fix broken code ([#1004](https://github.com/rollup/rollup/issues/1004)) +- Include module ID and location when warning about top-level `this` ([#1012](https://github.com/rollup/rollup/pull/1012)) +- More informative error for missing exports ([#1033](https://github.com/rollup/rollup/issues/1033)) +- `options.moduleContext` for per-module context overrides ([#1023](https://github.com/rollup/rollup/pull/1023)) + +## 0.36.1 + +- Include naked block statements ([#981](https://github.com/rollup/rollup/issues/981)) +- Correctly include falsy alternate statements in optimised if blocks ([#973](https://github.com/rollup/rollup/issues/973)) +- Prevent omission of default exports that are only used by the exporting module ([#967](https://github.com/rollup/rollup/pull/967)) +- Prevent warning on `auto` exports with ES output ([#966](https://github.com/rollup/rollup/pull/966)) + +## 0.36.0 + +- `export { foo as default }` no longer creates a live binding ([#860](https://github.com/rollup/rollup/issues/860)) + +## 0.35.15 + +- Warn on missing unused imports in deshadowing phase ([#928](https://github.com/rollup/rollup/issues/928)) +- Always add a newline to the end of bundles ([#958](https://github.com/rollup/rollup/issues/958)) + +## 0.35.14 + +- Include all parent statements of expression with effects, up to function boundary ([#930](https://github.com/rollup/rollup/issues/930)) + +## 0.35.13 + +- Include superclasses when including their subclasses ([#932](https://github.com/rollup/rollup/issues/932)) + +## 0.35.12 + +- Add `interop: false` option to disable unwrapping of external imports ([#939](https://github.com/rollup/rollup/issues/939)) + +## 0.35.11 + +- Deconflict reified namespaces with other declarations ([#910](https://github.com/rollup/rollup/issues/910)) + +## 0.35.10 + +- Only remove EmptyStatement nodes directly inside blocks ([#913](https://github.com/rollup/rollup/issues/931)) + +## 0.35.9 + +- Support Node 0.12 ([#909](https://github.com/rollup/rollup/issues/909)) + +## 0.35.8 + +- Correctly deshadow re-assigned module functions ([#910](https://github.com/rollup/rollup/issues/910)) + +## 0.35.7 + +- Refactor `flushTime.js` ([#922](https://github.com/rollup/rollup/pull/922)) + +## 0.35.6 + +- Fix browser build + +## 0.35.5 + +- Allow empty for loop heads ([#919](https://github.com/rollup/rollup/issues/919)) + +## 0.35.4 + +- Preserve effects in for-of and for-in loops ([#870](https://github.com/rollup/rollup/issues/870)) +- Remove empty statements ([#918](https://github.com/rollup/rollup/pull/918)) + +## 0.35.3 + +- Render identifiers inside template literals + +## 0.35.2 + +- Fix broken build caused by out of date locally installed dependencies + +## 0.35.1 + +- Rewrite deconflicted class identifiers ([#915](https://github.com/rollup/rollup/pull/915)) +- Include `dependencies` in `bundle.modules` objects ([#903](https://github.com/rollup/rollup/issues/903)) +- Update to Acorn 4 ([#914](https://github.com/rollup/rollup/pull/914)) + +## 0.35.0 + +- Rewrite analysis/tree-shaking code ([#902](https://github.com/rollup/rollup/pull/902)) +- Include conditional mutations of global objects ([#901](https://github.com/rollup/rollup/issues/901)) +- Only reify namespaces if necessary ([#898](https://github.com/rollup/rollup/issues/898)) +- Track mutations of aliased globals ([#893](https://github.com/rollup/rollup/issues/893)) +- Include duplicated var declarations ([#716](https://github.com/rollup/rollup/issues/716)) + +## 0.34.13 + +- Pass `{ format }` through to `transformBundle` ([#867](https://github.com/rollup/rollup/issues/867)) + +## 0.34.12 + +- Fix `rollup --watch` ([#887](https://github.com/rollup/rollup/issues/887)) +- Case-sensitive paths ([#862](https://github.com/rollup/rollup/issues/862)) + +## 0.34.11 + +- Prevent leaky state when `bundle` is reused ([#875](https://github.com/rollup/rollup/issues/875)) +- Ensure `intro` appears before interop block ([#880](https://github.com/rollup/rollup/issues/880)) + +## 0.34.10 + +- Allow custom `options.context` to replace top-level `this` ([#851](https://github.com/rollup/rollup/issues/851)) +- Fix `noConflict` when used via `rollup --config` ([#846](https://github.com/rollup/rollup/issues/846)) +- Place `outro` block _after_ export block ([#852](https://github.com/rollup/rollup/issues/852)) + +## 0.34.9 + +- Disable indentation by default, for faster bundle generation ([#812](https://github.com/rollup/rollup/pull/812)) +- More helpful error on missing entry file ([#802](https://github.com/rollup/rollup/issues/802)) +- Preserve comments before import declarations ([#815](https://github.com/rollup/rollup/pull/815)) + +## 0.34.8 + +- Wrap UMD factory function in parens to avoid lazy parsing ([#774](https://github.com/rollup/rollup/pull/774)) + +## 0.34.7 + +- Leave it up to resolveId to normalize the entry path ([#835](https://github.com/rollup/rollup/pull/835)) +- Cache decoded mappings ([#834](https://github.com/rollup/rollup/pull/834)) + +## 0.34.5 + +- Fix circular export ([#813](https://github.com/rollup/rollup/issues/813)) + +## 0.34.4 + +- Module render performance tweak ([#823](https://github.com/rollup/rollup/pull/823)) + +## 0.34.3 + +- Avoid infinite recursion in `Bundle.sort()` ([#800](https://github.com/rollup/rollup/pull/800)) + +## 0.34.2 + +- resolveId calls are cached now to improve incremental build +- Fixed error message recursion in plugins + +## 0.34.1 + +- Support `paths` config ([#754](https://github.com/rollup/rollup/issues/754)) +- Allow `export *` from external module, internally + +## 0.34.0 + +- Use resolved IDs for relative imports that are also external modules, to allow `options.globals` to work with them ([#763](https://github.com/rollup/rollup/issues/763)) +- Ensure reassigned exports are declared in an ES bundle, and remove empty `exports.foo;` statements ([#755](https://github.com/rollup/rollup/issues/755)) +- Add newline after sourcemap comment ([#756](https://github.com/rollup/rollup/issues/756)) + +## 0.33.2 + +- Add `bundle` as second argument to `ongenerate` and `onwrite` hooks ([#773](https://github.com/rollup/rollup/pull/773)) +- Warn on top-level `this` ([#770](https://github.com/rollup/rollup/issues/770)) + +## 0.33.1 + +- Fix `--no-strict` option ([#751](https://github.com/rollup/rollup/pull/751)) +- Fix Windows edge case with case-sensitive paths ([#760](https://github.com/rollup/rollup/pull/760)) + +## 0.33.0 + +- Downgrade missing transformer sourcemap to a warning, not an error, and print the name of the offending plugin if possible ([#746](https://github.com/rollup/rollup/issues/746)) +- Warn if same name is re-exported from two modules ([#722](https://github.com/rollup/rollup/issues/722)) + +## 0.32.4 + +- Add `ongenerate` and `onwrite` plugin hooks ([#742](https://github.com/rollup/rollup/pull/742)) + +## 0.32.3 + +- Generated correct sourcemaps with reified namespaces ([#668](https://github.com/rollup/rollup/issues/668)) +- Exclude plugin helper modules from sourcemaps ([#747](https://github.com/rollup/rollup/pull/747)) + +## 0.32.2 + +- Allow `--globals` to work with `--external` or `options.external` in whatever configuration ([#743](https://github.com/rollup/rollup/issues/743)) + +## 0.32.1 + +- Preserve side-effects to default exports that coincide with used named exports ([#733](https://github.com/rollup/rollup/issues/733)) +- Support `rollup -c node:pkgname` ([#736](https://github.com/rollup/rollup/issues/736)) + +## 0.32.0 + +- Deprecate `es6` format in favour of `es` ([#468](https://github.com/rollup/rollup/issues/468)) +- Add correct `jsnext:main` build ([#726](https://github.com/rollup/rollup/pull/726)) + +## 0.31.2 + +- Allow `load` plugins to provide sourcemap ([#715](https://github.com/rollup/rollup/pull/715)) +- Allow `sourceMapFile` in config options ([#717](https://github.com/rollup/rollup/issues/717)) + +## 0.31.1 + +- Logging for errors emitted by `rollup-watch` ([#712](https://github.com/rollup/rollup/issues/712)) + +## 0.31.0 + +- Rewrite top-level `this` as `undefined` ([#707](https://github.com/rollup/rollup/pull/707)) +- Pass `options.acorn` to Acorn ([#564](https://github.com/rollup/rollup/issues/564)) + +## 0.30.0 + +- Bundle CLI ([#700](https://github.com/rollup/rollup/issues/700)) +- Ensure absolute paths are normalised ([#704](https://github.com/rollup/rollup/issues/704)) +- Allow `rollup --watch` to work with targets + +## 0.29.1 + +- Merge `target` options with main options ([#701](https://github.com/rollup/rollup/issues/701)) +- Update magic-string ([#690](https://github.com/rollup/rollup/issues/690)) + +## 0.29.0 + +- `rollup --watch` ([#284](https://github.com/rollup/rollup/issues/284)) + +## 0.28.0 + +- Experimental support for incremental rebuilds ([#658](https://github.com/rollup/rollup/pull/658)) + +## 0.27.1 + +- Ensure names exported from a module are not replaced with reserved words ([#696](https://github.com/rollup/rollup/pull/696)) +- Revert ([#692](https://github.com/rollup/rollup/pull/692)) – resolved IDs must be strings + +## 0.27.0 + +- Use native promises instead of `es6-promise` ([#689](https://github.com/rollup/rollup/issues/689)) +- Support multiple targets in config files ([#655](https://github.com/rollup/rollup/issues/655)) +- Allow `resolveId` plugin functions to return non-strings ([#692](https://github.com/rollup/rollup/pull/692)) + +## 0.26.7 + +- Distinguish between default and namespace imports of external module ([#637](https://github.com/rollup/rollup/issues/637)) +- Add `__esModule` property to named exports in AMD, CJS and UMD modes ([#650](https://github.com/rollup/rollup/issues/650)) + +## 0.26.6 + +- Deconflict named imports from external modules in ES bundles ([#659](https://github.com/rollup/rollup/issues/659)) +- Support `options.preferConst` to generate `const` declarations for exports rather than `var` declarations ([#653](https://github.com/rollup/rollup/issues/653)) + +## 0.26.5 + +- Preserve `debugger` statements ([#664](https://github.com/rollup/rollup/issues/664)) +- Allow `options.external` to be a function ([#522](https://github.com/rollup/rollup/issues/522)) + +## 0.26.4 + +- Prevent plugin-provided external IDs being normalised ([#630](https://github.com/rollup/rollup/issues/630), [#633](https://github.com/rollup/rollup/issues/633)) +- Throw if module exports/re-exports the same name twice, or has multiple default exports ([#679](https://github.com/rollup/rollup/issues/679)) +- Warn about `eval` security issue ([#675](<(https://github.com/rollup/rollup/issues/675)>)) + +## 0.26.3 + +- Ensure reference is not incorrectly marked as a reassignment ([#648](https://github.com/rollup/rollup/issues/648)) + +## 0.26.2 + +- Sanity check output of `load` hook ([#607](https://github.com/rollup/rollup/issues/607)) +- Correct scoping for ID class expressions ([#626](https://github.com/rollup/rollup/issues/626)) +- Warn if named and default exports are used together in auto mode ([#587](https://github.com/rollup/rollup/issues/587)) +- Allow variable initialisers to be rewritten if necessary ([#632](https://github.com/rollup/rollup/issues/632)) +- Prevent double `var` with no-treeshake option ([#639](https://github.com/rollup/rollup/pull/639)) + +## 0.26.1 + +- Add `treeshake: false`/`--no-treeshake` option for debugging ([#505](https://github.com/rollup/rollup/issues/505)) +- Update build process to use Bublé ([#620](https://github.com/rollup/rollup/pull/620)) + +## 0.26.0 + +- Add `noConflict`/`--no-conflict` option for UMD builds ([#580](https://github.com/rollup/rollup/pull/580)) +- Normalise relative external paths ([#591](https://github.com/rollup/rollup/pull/591)) +- Report files causing transform errors ([#609](https://github.com/rollup/rollup/pull/609)) +- Handle sourcemap segments with a single member ([#619](https://github.com/rollup/rollup/pull/619)) +- Update dependencies + +## 0.25.8 + +- Unixize entry path ([#586](https://github.com/rollup/rollup/pull/586)) + +## 0.25.7 + +- Expand deshadowed shorthand properties ([#575](https://github.com/rollup/rollup/issues/575)) +- Allow external files to be non-existent ([#532](https://github.com/rollup/rollup/issues/532)) + +## 0.25.6 + +- Fix a regression introduced by #566 ([#569](https://github.com/rollup/rollup/issues/569)) +- Prune dead conditional expressions more carefully ([#567](https://github.com/rollup/rollup/issues/567)) + +## 0.25.5 + +- Make sure shorthand destructuring assignments don't break ([#528](https://github.com/rollup/rollup/issues/528)) +- Allow 'exports' key ([#542](https://github.com/rollup/rollup/issues/542)) +- Ensure `foo. bar` where `foo` is a namespace import is rewritten correctly ([#566](https://github.com/rollup/rollup/issues/566)) +- Fix an edge case for exported globals ( e.g. `export { document }`) ([#562](https://github.com/rollup/rollup/issues/562)) + +## 0.25.4 + +- Fix misnamed exports of default imports in ES bundles ([#513](https://github.com/rollup/rollup/issues/513)) +- CLI: warn on missing config ([#515](https://github.com/rollup/rollup/pull/515)) +- Detect side-effects in non-top-level member expression assignment ([#476](https://github.com/rollup/rollup/issues/476)) +- Don't remove computed property class keys ([#504](https://github.com/rollup/rollup/issues/504)) +- Augment existing global object rather than replacing ([#493](https://github.com/rollup/rollup/issues/493)) +- Don't fail on `export {}`, warn instead ([#486](https://github.com/rollup/rollup/issues/486)) + +## 0.25.3 + +- Handle non-objects and `null` in `_interopDefault` ([#474](https://github.com/rollup/rollup/issues/474)) + +## 0.25.2 + +- Skip dead branches of a conditional expression (#[465](https://github.com/rollup/rollup/pull/465)) +- Allow globals to be exported ([#472](https://github.com/rollup/rollup/pull/472)) +- Ensure reassigned exports are exported ([#484](https://github.com/rollup/rollup/issues/484)) + +## 0.25.1 + +- Throw error if namespace is called ([#446](https://github.com/rollup/rollup/issues/446)) +- Prevent shadowing bug in ES6 output ([#441](https://github.com/rollup/rollup/pull/441)) +- Prevent `var exports.foo` ([#426](https://github.com/rollup/rollup/issues/426)) +- Prevent double export of aliased symbols ([#438](https://github.com/rollup/rollup/issues/438)) +- Provide more informative error if Rollup is used in-browser without appropriate `resolveId`/`load` hooks ([#275](https://github.com/rollup/rollup/issues/275)) +- Use `_interopDefault` function to DRY out code with many external dependencies, in CommonJS output ([#458](https://github.com/rollup/rollup/pull/458)) + +## 0.25.0 + +- **breaking** Module order is determined according to spec, rather than in a way designed to prevent runtime errors. Rollup will warn if it detects runtime errors are likely ([#435](https://github.com/rollup/rollup/issues/435)) +- Prevent overly aggressive tree-shaking with complex call expressions ([#440](https://github.com/rollup/rollup/issues/440)) + +## 0.24.1 + +- Handle calls to default exports other that are not function expressions or references to function declarations ([#421](https://github.com/rollup/rollup/issues/421)) +- Ensure namespace blocks are created for chained imports ([#430](https://github.com/rollup/rollup/issues/430)) +- Include references in computed property keys ([#434](https://github.com/rollup/rollup/issues/434)) +- Use CLI `--external` option correctly ([#417](https://github.com/rollup/rollup/pull/417)) +- Allow relative imports to be treated as external, if absolute paths are provided in `options.external` ([#410](https://github.com/rollup/rollup/issues/410)) +- Make IIFE output adhere to Crockford style ([#415](https://github.com/rollup/rollup/pull/415)) + +## 0.24.0 + +- No longer attempts to resolve IDs in `options.external` ([#407](https://github.com/rollup/rollup/issues/407)) +- Fix broken sourcemap resolution in cases where some modules are transformed and others aren't ([#404](https://github.com/rollup/rollup/issues/404)) + +## 0.23.2 + +- Ensure `dest` or `sourceMapFile` is resolved against CWD for purposes of sourcemap generation ([#344](https://github.com/rollup/rollup/issues/344)) +- Support `banner`, `footer`, `intro` and `outro` options via CLI ([#330](https://github.com/rollup/rollup/issues/330)) +- Allow `options.global` to be a function rather than an object, and warn on missing names ([#293](https://github.com/rollup/rollup/issues/293)) +- Ensure side-effects are captured in cyclical call expressions ([#397](https://github.com/rollup/rollup/issues/397)) +- Fix parse error with body-less arrow function expressions ([#403](https://github.com/rollup/rollup/issues/403)) + +## 0.23.1 + +- Reinstate missing fix from ([#392](https://github.com/rollup/rollup/pull/392)) + +## 0.23.0 + +- Add `bundleTransform` plugin hook and option ([#387](https://github.com/rollup/rollup/pull/387)) +- Correctly store names in sourcemaps, regardless of transformers +- Add `--environment` option to CLI ([#388](https://github.com/rollup/rollup/pull/388)) +- Handle destructuring in exports ([#374](https://github.com/rollup/rollup/issues/374)) +- Fix UMD global exports bug introduced in 0.22.1 ([#392](https://github.com/rollup/rollup/pull/392)) + +## 0.22.2 + +- Prevent lost `var` keywords ([#390](https://github.com/rollup/rollup/issues/390)) + +## 0.22.1 + +- Update expected option keys ([#379](https://github.com/rollup/rollup/issues/379)) +- Handle transformers that return stringified sourcemaps ([#377](https://github.com/rollup/rollup/issues/377)) +- Automatically create missing namespaces if `moduleName` contains dots ([#378](https://github.com/rollup/rollup/issues/378)) +- Ignore external dependency warnings coming from config file ([#333](https://github.com/rollup/rollup/issues/333)) +- Update to latest magic-string for performance boost + +## 0.22.0 + +- Duplicate warnings are squelched ([#362](https://github.com/rollup/rollup/issues/362)) +- Plugins can manipulate or override the `options` object ([#371](https://github.com/rollup/rollup/pull/371)) + +## 0.21.3 + +- Validate option keys ([#348](https://github.com/rollup/rollup/pull/348)) +- Allow namespaces imports to sit alongside named imports ([#355](https://github.com/rollup/rollup/issues/355)) +- Count references inside destructured objects ([#364](https://github.com/rollup/rollup/issues/364)) +- Preserve top-level `delete` statements ([#352](https://github.com/rollup/rollup/issues/352)) + +## 0.21.2 + +- Missing relative imports are an error, not a warning ([#321](https://github.com/rollup/rollup/issues/321)) +- Fixed incorrectly renamed default exports in ES6 bundles ([#339](https://github.com/rollup/rollup/issues/339)) +- Fixed infinite recursion bug ([#341](https://github.com/rollup/rollup/issues/341)) + +## 0.21.1 + +- Remove `aggressive: true` (was too aggressive) ([#309](https://github.com/rollup/rollup/pull/309)) +- Handle top-level block statements ([#326](https://github.com/rollup/rollup/issues/326)) +- Optimise namespaces with default exports ([#314](https://github.com/rollup/rollup/issues/314)) + +## 0.21.0 + +- Only include statements whose side-effects are relevant (i.e. contribute to exports or affect global state) ([#253](https://github.com/rollup/rollup/pull/253)) ([#253](https://github.com/rollup/rollup/pull/253)) +- Exclude dead branches from analysis and inclusion ([#249](https://github.com/rollup/rollup/pull/249)) +- Add `aggressive: true` option to eliminate all side-effects outside entry module +- More informative error when re-exporting non-existent binding ([#274](https://github.com/rollup/rollup/issues/274)) +- Fix infinite recursion bug ([#291](https://github.com/rollup/rollup/issues/291)) +- Log errors when using `rollup --config` ([#288](https://github.com/rollup/rollup/pull/288)) +- Return rejected promises on startup instead of throwing error, if options are invalid ([#303](https://github.com/rollup/rollup/pull/303)) + +## 0.20.5 + +- Ensure re-exports don't create a local binding ([#270](https://github.com/rollup/rollup/pull/270)) + +## 0.20.4 + +- Check file exists at resolve time, to allow filenames with non-extension dots in them ([#250](https://github.com/rollup/rollup/pull/250)) +- Import `Promise` where used, for Node 0.10 support ([#254](https://github.com/rollup/rollup/issues/254)) +- Allow asynchronous transformer plugins ([#260](https://github.com/rollup/rollup/issues/260)) +- Don't assume re-exported bindings are globals when deconflicting ([#267](https://github.com/rollup/rollup/issues/267)) + +## 0.20.3 + +- Fix bug where multiple `export *` declarations caused error ([#244](https://github.com/rollup/rollup/pulls/244)) +- Missing namespace exports are a warning, not an error ([#244](https://github.com/rollup/rollup/pulls/244)) +- Plugins can provide `banner` and `footer` options (string, or function that returns a string) ([#235](https://github.com/rollup/rollup/issues/235)) +- Warn on encountering `eval` ([#186](https://github.com/rollup/rollup/issues/186)) + +## 0.20.2 + +- Handle errors in build config file +- More robust deconflicting, in cases where e.g. `foo$1` already exists +- Use Rollup CLI for own build process + +## 0.20.1 + +- Support `--config` file to enable plugins with CLI ([#226](https://github.com/rollup/rollup/pulls/226)) +- Prevent `default` being used as variable name ([#215](https://github.com/rollup/rollup/issues/215)) +- Update deps + +## 0.20.0 + +- Support for [plugins](https://github.com/rollup/rollup/wiki/Plugins) ([#207](https://github.com/rollup/rollup/pulls/207)) +- BREAKING – `options.transform`, `options.load`, `options.resolveId`, `options.resolveExternal` and `options.external` are no longer supported, and should be handled by plugins. [More info](https://github.com/rollup/rollup/wiki/Plugins) +- BREAKING – the .js extension is only added if it looks like there's no extension, allowing e.g. `import data from 'data.json'` (with the appropriate transformer). For safety, always include the file extension – import `./foo.js`, not `./foo` + +## 0.19.2 + +- Fix exporting namespaces to include all of their exports ([#204](https://github.com/rollup/rollup/issues/204)) +- Namespace exotic objects are frozen to ensure that its properties cannot be modified, reconfigured, redefined or deleted ([#203](https://github.com/rollup/rollup/pulls/203)) +- Fix `ReferenceError: Promise is not defined` in node v0.10 ([#189](https://github.com/rollup/rollup/issues/189)) + +## 0.19.1 + +- Fix `module.basename()` when used with custom `resolveId` function +- Use [rollup-babel](https://github.com/rollup/rollup-babel) to build self +- Exposed the version string through the API: `require( 'rollup' ).VERSION` + +## 0.19.0 + +- **breaking** The `transform` option is no longer passed through to custom loaders. Loaders should only concern themselves with providing source code; transformation will _always_ take place +- `options.transform` functions can return a string, or a `{code, map, ast}` object. Where possible, sourcemap chains will be flattened ([#175](https://github.com/rollup/rollup/pull/175)) +- `options.resolveId`, `options.resolveExternal` and `options.load` can each be a function or an array of functions. If an array, the first non-null/undefined return value is used. In both cases, failed resolution/loading will fall back to the defaults, unless an error is thrown. ([#174](https://github.com/rollup/rollup/pull/174)) +- New `intro` and `outro` options – similar to `banner` and `footer` except inserted _inside_ any format-specific wrapper +- Multiple var declarations in an export block (e.g. `export let a = 1, b = 2`) are split up to facilitate tree-shaking ([#171](https://github.com/rollup/rollup/issues/171)) +- More informative error when using a missing namespace property ([#169](https://github.com/rollup/rollup/pull/169)) +- Update various dependencies + +## 0.18.5 + +- Allow namespaces to be assigned to variables ([#168](https://github.com/rollup/rollup/issues/168)) +- Promote `chalk` and `source-map-support` to `dependencies`, as they're used by the CLI ([#167](https://github.com/rollup/rollup/pull/167)) + +## 0.18.4 + +- Make external modules configurable (i.e. `external.config.foo = 'bar'`) without erroring + +## 0.18.3 + +- Crop indent exclusion ranges to exclude enclosing quotes ([#166](https://github.com/rollup/rollup/issues/166)) + +## 0.18.2 + +- Include definitions of namespace members that are exported as defaults + +## 0.18.1 + +- Include `acorn.parse` in bundle, remove `sander` from dependencies, simplify build + +## 0.18.0 + +- Internal rewrite +- Reinstate statically-analysable namespace imports +- Avoid using getters in namespace blocks where possible ([#144](https://github.com/rollup/rollup/issues/144)) +- Track variable aliases ([#96](https://github.com/rollup/rollup/issues/96)) +- Prevent multiline strings being indented ([#164](https://github.com/rollup/rollup/issues/164)) + +## 0.17.4 + +- Allow imports from hidden directories (replay of [#133](https://github.com/rollup/rollup/issues/133)) + +## 0.17.3 + +- Handle parenthesised default exports ([#136](https://github.com/rollup/rollup/issues/136)) + +## 0.17.2 + +- Allow use of scoped npm packages ([#131](https://github.com/rollup/rollup/issues/131)) + +## 0.17.1 + +- Allow namespaces to be passed to a function ([#149](https://github.com/rollup/rollup/issues/149)) + +## 0.17.0 + +- Roll back to 0.15.0 and reapply subsequent fixes pending resolution of ([#132](https://github.com/rollup/rollup/issues/132)) and related issues + +## 0.16.4 + +- Fix import paths with `.` ([#133](https://github.com/rollup/rollup/issues/133)) +- Prevent sourceMappingURL confusion leading to broken sourcemap +- Add code coverage reporting [#130](https://github.com/rollup/rollup/pull/130)) +- Add `modules` property to user-facing `bundle` – an array with `{id}` objects ([#128](https://github.com/rollup/rollup/issues/128)) + +## 0.16.3 + +- Prevent adjacent blocks of multiple var declarations causing magic-string failure ([#105](https://github.com/rollup/rollup/issues/105)) + +## 0.16.2 + +- Top-level function calls and assignments to globals are treated as side-effects, and always included +- Import files from subdirectories of external packages, e.g. `import mod from 'foo/sub/mod'` ([#126](https://github.com/rollup/rollup/issues/126)) + +## 0.16.1 + +- Handle assignment patterns, and destructured/rest parameters, when analysing scopes +- Fix bug preventing project from self-building (make base `Identifier` class markable) + +## 0.16.0 + +- Internal refactoring ([#99](https://github.com/rollup/rollup/pull/99)) +- Optimisation for statically-analysable namespace imports ([#99](https://github.com/rollup/rollup/pull/99)) +- Windows support ( theoretically!) ([#117](https://github.com/rollup/rollup/pull/117) / [#119](https://github.com/rollup/rollup/pull/119)) + +## 0.15.0 + +- Load all modules specified by `import` statements, and do tree-shaking synchronously once loading is complete. This results in simpler and faster code, and enables future improvements ([#97](https://github.com/rollup/rollup/pull/97)) +- Only rewrite `foo` as `exports.foo` when it makes sense to ([#92](https://github.com/rollup/rollup/issues/92)) +- Fix bug with shadowed variables that are eventually exported ([#91](https://github.com/rollup/rollup/issues/91)) +- Exclude unused function declarations that happen to modify a used name ([#90](https://github.com/rollup/rollup/pull/90)) +- Simplify internal `Scope` model – scopes always attach to blocks, never function expressions/declarations + +## 0.14.1 + +- `export { name } from './other'` does not create a local binding ([#16](https://github.com/rollup/rollup/issues/16)) +- A single binding can be exported under multiple names ([#18](https://github.com/rollup/rollup/issues/18)) +- `useStrict` option exposed to CLI as `--strict`/`--no-strict` ([#81](https://github.com/rollup/rollup/issues/81)) +- Neater exports from ES6 bundles + +## 0.14.0 + +- Internal refactoring +- Correctly deconflict generated default export names ([#72](https://github.com/rollup/rollup/issues/72)) +- Handle `export { x } from 'y'` declarations ([#74](https://github.com/rollup/rollup/issues/74)) +- Dedupe named imports from external modules in ES6 bundles ([#77](https://github.com/rollup/rollup/issues/77)) + +## 0.13.0 + +- Support `banner` and `footer` options ([#66](https://github.com/rollup/rollup/pull/66)) +- Remove pre-existing sourcemap comments ([#66](https://github.com/rollup/rollup/pull/66)) +- Deconflict external imports ([#66](https://github.com/rollup/rollup/pull/66)) +- Use existing AST, if provided ([#66](https://github.com/rollup/rollup/pull/66)) +- Rename internal namespace exports as appropriate ([#66](https://github.com/rollup/rollup/pull/66)) +- Remove uninitialised var declarations that get exported ([#66](https://github.com/rollup/rollup/pull/66)) +- Rename variables named `exports` to avoid conflicts ([#66](https://github.com/rollup/rollup/pull/66)) + +## 0.12.1 + +- Don't attempt to mark statements belonging to external modules ([#68](https://github.com/rollup/rollup/issues/68)) +- Correctly deshadow variables that conflict with imports ([#68](https://github.com/rollup/rollup/issues/68)) + +## 0.12.0 + +- Internal re-architecting, resulting in more efficient bundling with reduced memory usage +- Shorthand properties are expanded if necessary ([#61](https://github.com/rollup/rollup/issues/61)) +- Fixed various bugs with bundle external dependencies, particularly when generating ES6 bundles ([#59](https://github.com/rollup/rollup/issues/59)) +- Add `--globals` option to CLI ([#60](https://github.com/rollup/rollup/pull/60)) +- Allow imports of external modules for side-effects ([#55](https://github.com/rollup/rollup/pull/55)) +- Prevent Rollup hanging on non-existent external module ([#54](https://github.com/rollup/rollup/pull/54)) + +## 0.11.4 + +- Side-effect preservation applies to internal default exports ([#43](https://github.com/rollup/rollup/issues/43)) + +## 0.11.3 + +- Class methods are not incorrectly renamed ([#42](https://github.com/rollup/rollup/issues/42)) +- External modules are assigned names before canonical names are determined ([#42](https://github.com/rollup/rollup/issues/42)) + +## 0.11.2 + +- Correctly handle computed properties (e.g. `foo[bar]`) when discovering dependencies ([#47](https://github.com/rollup/rollup/pull/47)) + +## 0.11.1 + +- Support for `export * from '..'` ([#46](https://github.com/rollup/rollup/pull/46)) + +## 0.11.0 + +- Experimental browser-friendly build (`dist/rollup.browser.js`) ([#25](https://github.com/rollup/rollup/issues/25)) +- Internal re-architecting to make discovery process simpler and more performant +- Preservation of side-effects that happen in a separate module to the affected definition ([#39](https://github.com/rollup/rollup/issues/39)) + +## 0.10.0 + +- Better sorting algorithm – sorting happens at the module level, rather than the statement level. This avoids certain edge cases +- IIFEs are ignored for the purposes of distinguishing between 'strong' and 'weak' dependencies +- Empty `var` declarations for exported bindings are omitted + +## 0.9.1 + +- Much faster statement insertion (fixes major 0.9.0 performance regression) + +## 0.9.0 + +- BREAKING - `resolvePath` is now `resolveId`. The returned `id` (which by default is a filepath) is passed to the `load` function, which can optionally be overridden, and which is applied to all modules including the entry module. This allows custom resolver and loading logic for integration with third party systems (e.g. JSPM) or, eventually, in-browser usage ([#30](https://github.com/rollup/rollup/issues/30)) +- A statement cannot appear after later statements from the same bundle ([#34](https://github.com/rollup/rollup/issues/34)) +- Tricky cyclical dependencies are handled ([#36](https://github.com/rollup/rollup/issues/36)) +- `sourcemap` option is used by CLI (was omitted previously) + +## 0.8.3 + +- Correctly rename functions that have arguments with the same name ([#32](https://github.com/rollup/rollup/issues/32)) +- Ensure unused default exports are given a legal name ([#33](https://github.com/rollup/rollup/issues/33)) + +## 0.8.2 + +- Support `moduleId` and `moduleName` via CLI ([#24](https://github.com/rollup/rollup/issues/24)) + +## 0.8.1 + +- Anonymous functions that are exported as default are converted to named function declarations for correct hoisting, rather than being bound to functions ([#29](https://github.com/rollup/rollup/issues/29)) +- Automatically-generated default export names are deconflicted with local definitions ([#29](https://github.com/rollup/rollup/issues/29)) + +## 0.8.0 + +- Top-level variable declarations with multiple declarators are split up, to avoid unnecessary code importing and incorrectly-ordered statements ([#26](https://github.com/rollup/rollup/issues/26)) +- `this` at the top level is `undefined` ([#28](https://github.com/rollup/rollup/issues/28)) + +## 0.7.8 + +- Avoid using `path.parse` - unsupported in node 0.10 + +## 0.7.7 + +- Promise `source-map-support` from `devDependencies` to `dependencies` ([#23](https://github.com/rollup/rollup/issues/23)) + +## 0.7.6 + +- Better placement of `export default` statements ([#21](https://github.com/rollup/rollup/issues/21)) +- Prevent function calls and property assignments from being treated as rebinding for sake of unbound default exports +- Add `--external foo,bar,baz` option to CLI (equivalent to `external: ['foo', 'bar', 'baz']`) +- Add CLI tests + +## 0.7.5 + +- Prevent accidental conflicts with the global namespace ([#20](https://github.com/rollup/rollup/issues/20)) + +## 0.7.4 + +- More precise statement re-ordering to satisfy `export default` constraint (fixes bug introduced in 0.7.3) + +## 0.7.3 + +- Default exports are not bound. To enable this, statements within a module are sorted to retain their original order ([#15](https://github.com/rollup/rollup/issues/15)) +- Better positioning of comments ([#14](https://github.com/rollup/rollup/issues/14)) +- Various fixes to get Travis-CI rigged up + +## 0.7.2 + +- Fix sourcemap paths on Windows ([#6](https://github.com/rollup/rollup/pull/6)) + +## 0.7.1 + +- Named functions can be used as default exports from a bundle +- Method calls are assumed to mutate the owner (i.e. `foo.bar()` mutates `foo`) ([#13](https://github.com/rollup/rollup/issues/13)) +- `options.indent` can be used to control indentation of resulting bundle. `options.true` (default) means ' auto', `options.false` means empty string. Alternatively specify whitespace e.g. `' '` or `'\t'` ([#5](https://github.com/rollup/rollup/issues/5)) + +## 0.7.0 + +- Ensure statements are always separated by a newline ([#9](https://github.com/rollup/rollup/pull/9)) +- Use CommonJS `exports` correctly (UMD exports) +- Throw error if `moduleName` is required but missing (UMD exports) +- Attach IIFE global to `this` rather than `window` +- Allow names inside bundle to the the names of `Object.prototype` properties ([#12](https://github.com/rollup/rollup/pull/12)) +- Keep exports live ([#11](https://github.com/rollup/rollup/pull/11)) + +## 0.6.5 + +- Add sourceMappingURL comment to code, as appropriate +- Higher resolution sourcemaps + +## 0.6.4 + +- Fix CJS bundling with default export + +## 0.6.3 + +- Fix exports and external module imports with some output formats +- Fix endless cycle bug on Windows ([#3](https://github.com/rollup/rollup/pull/3)) - thanks @Bobris + +## 0.6.2 + +- Permit assignments to properties of imported bindings + +## 0.6.1 + +- Support for basic transformers + +## 0.6.0 + +- BREAKING - `rollup.rollup` and `bundle.write` both take a single options argument +- BREAKING - external modules must be declared upfront with `options.external: [...]` +- Non-relative module paths will be resolved by looking for `jsnext:main` fields in the appropriate `package.json` files. This behaviour can be overridden by passing an alternative `resolveExternal` function +- Fix sourcemap options +- Include CLI files in npm package (duh) + +## 0.5.0 + +- Command line interface +- Sourcemap generation +- Correct behaviour with `export { x as y } from 'z'` + +## 0.4.1 + +- More import name deconflicting + +## 0.4.0 + +- Self-hosting! `rollup.rollup` now rolls up rollup +- Fix bug with comments inside a statement later being appended to it +- Prevent shadowing of external modules +- Rewrite computed property identifiers where necessary +- Preserve original statement order where possible +- Internal refactoring + +## 0.3.1 + +- Saner deconflicting +- Rename namespace imports from external modules correctly + +## 0.3.0 + +- Basic functionality present, mostly spec-compliant + +## 0.2.1 + +- Include dist files in npm package (duh) + +## 0.2.0 + +- First release capable of doing anything useful +- Still lots of basic functionality missing + +## 0.1.0 + +- Initial experiment diff --git a/CHANGELOG-1.md b/CHANGELOG-1.md new file mode 100644 index 00000000000..eec1663dee8 --- /dev/null +++ b/CHANGELOG-1.md @@ -0,0 +1,1807 @@ +# rollup changelog + +## 1.32.1 + +_2020-03-06_ + +### Bug Fixes + +- Handle default export detection for AMD and IIFE externals that do not have a prototype (#3420) +- Handle missing whitespace when the else branch of an if-statement is simplified (#3421) +- Mention the importing module when reporting errors for missing named exports (#3401) +- Add code to warning for missing output.name of IIFE bundles (#3372) + +### Pull Requests + +- [#3372](https://github.com/rollup/rollup/pull/3372): Add warning code for missing output.name of IIFE bundle that has export (@rail44) +- [#3401](https://github.com/rollup/rollup/pull/3401): Missing exports errors now print the importing module (@timiyay) +- [#3418](https://github.com/rollup/rollup/pull/3418): Structure lifecycle hooks, add links to build time hooks ( @lukastaegert) +- [#3420](https://github.com/rollup/rollup/pull/3420): Update generated code of getInteropBlock() to work with null prototype objects (@jdalton) +- [#3421](https://github.com/rollup/rollup/pull/3421): Avoid invalid code when "else" branch is simplified ( @lukastaegert) + +## 1.32.0 + +_2020-02-28_ + +### Features + +- Allow adding plugins on the command line via `--plugin ` (#3379) + +### Pull Requests + +- [#3379](https://github.com/rollup/rollup/pull/3379): introduce CLI --plugin support (@kzc) +- [#3390](https://github.com/rollup/rollup/pull/3390): fix typo: this.addWatchfile (@mistlog) +- [#3392](https://github.com/rollup/rollup/pull/3392): Bump codecov from 3.6.1 to 3.6.5 +- [#3404](https://github.com/rollup/rollup/pull/3404): Update resolveFileUrl docs (@jakearchibald) + +## 1.31.1 + +_2020-02-14_ + +### Bug Fixes + +- Make sure errored files are always re-evaluated in watch mode to avoid an issue in the typescript plugin (#3388) + +### Pull Requests + +- [#3366](https://github.com/rollup/rollup/pull/3366): Correct spelling minifaction to minification (@VictorHom) +- [#3371](https://github.com/rollup/rollup/pull/3371): Adjust bug template to mention REPL.it (@lukastaegert) +- [#3388](https://github.com/rollup/rollup/pull/3388): Run transform hooks again in watch mode on files that errored ( @lukastaegert) + +## 1.31.0 + +_2020-01-31_ + +### Features + +- Always disable tree-shaking for asm.js functions to maintain semantics (#3362) + +### Pull Requests + +- [#3362](https://github.com/rollup/rollup/pull/3362): Preserve asm.js code (@lukastaegert) + +## 1.30.1 + +_2020-01-27_ + +### Bug Fixes + +- Do not mistreat static entgry points as dynamic ones when chunking (#3357) +- Resolve a crash when chunking circular dynamic imports (#3357) + +### Pull Requests + +- [#3357](https://github.com/rollup/rollup/pull/3357): Resolve issues with circular dynamic entries (@lukastaegert) + +## 1.30.0 + +_2020-01-27_ + +### Features + +- Do not split chunks when dynamically imported modules import modules that are already loaded by all dynamic importers (#3354) +- Add `hoistTransitiveImports` option to disable hoisting imports of static dependencies into entry chunks (#3353) + +### Bug Fixes + +- Make sure polyfills are always loaded first when each static entry point contains them as first import (#3354) + +### Pull Requests + +- [#3353](https://github.com/rollup/rollup/pull/3353): Add option to avoid hoisting transitive imports (@lukastaegert) +- [#3354](https://github.com/rollup/rollup/pull/3354): Improve chunking algorithm for dynamic imports (@tjenkinson and @lukastaegert) + +## 1.29.1 + +_2020-01-21_ + +### Bug Fixes + +- Avoid crashes for circular reexports when named exports cannot be found (#3350) + +### Pull Requests + +- [#3335](https://github.com/rollup/rollup/pull/3335): Fix typo (@robbinworks) +- [#3342](https://github.com/rollup/rollup/pull/3342): Remove ":" from test file names for Windows and update dependencies (@lukastaegert) +- [#3350](https://github.com/rollup/rollup/pull/3350): Properly handle circular reexports (@lukastaegert) + +## 1.29.0 + +_2020-01-08_ + +### Features + +- Enable top-level await by default (#3089) +- Add typings for watch events (#3302) + +### Bug Fixes + +- Deconflict files that would conflict only on a case-insensitive OS (#3317) +- Do not fail in certain scenarios where a logical expression inside a sequence expression was being directly included ( #3327) + +### Pull Requests + +- [#3089](https://github.com/rollup/rollup/pull/3089): Move top-level await out of experimental (@guybedford) +- [#3302](https://github.com/rollup/rollup/pull/3302): Adds type definitions for RollupWatcher events (@NotWoods) +- [#3317](https://github.com/rollup/rollup/pull/3317): Fix module id conflict on a case insensitive OS (@yesmeck) +- [#3327](https://github.com/rollup/rollup/pull/3327): Handle deoptimizations while a node is being included ( @lukastaegert) + +## 1.28.0 + +_2020-01-04_ + +### Features + +- Allow piping in stdin via the command line interface (#3312, #3290) +- Allow plugins to mark modules as having syntheticNamedExports for e.g. better CJS interoperability (#3295) +- Ignore variable reassignments in dead code when tree-shaking to remove more unneeded code (#3212) + +### Bug Fixes + +- Properly respect tree-shaken code when generating sourcemaps (#3318) + +### Pull Requests + +- [#3212](https://github.com/rollup/rollup/pull/3212): Handle assignments in dead code (@tjenkinson) +- [#3290](https://github.com/rollup/rollup/pull/3290): Implement stdin input with optional "-" as the file name (@kzc) +- [#3295](https://github.com/rollup/rollup/pull/3295): Add syntheticNamedExports (@manucorporat) +- [#3300](https://github.com/rollup/rollup/pull/3300): Add note about setting `types` in tsconfig file (@tjenkinson) +- [#3303](https://github.com/rollup/rollup/pull/3303): Use ! to assert not-null in TypeScript (@NotWoods) +- [#3312](https://github.com/rollup/rollup/pull/3312): Implement stdin input (@lukastaegert) +- [#3318](https://github.com/rollup/rollup/pull/3318): Update magic-string and other dependencies (@lukastaegert) + +## 1.27.14 + +_2019-12-22_ + +### Bug Fixes + +- Update references to official rollup plugins in error messages (#3297, #3298) + +### Pull Requests + +- [#3286](https://github.com/rollup/rollup/pull/3286): Update link to JavaScript API documentation (@romankaravia) +- [#3294](https://github.com/rollup/rollup/pull/3294): Update deprecated references to the node-resolve plugin in the documentation (@Vlad-Shcherbina) +- [#3297](https://github.com/rollup/rollup/pull/3297): Update references to rollup-plugin-json (@cprecioso) +- [#3298](https://github.com/rollup/rollup/pull/3298): Update references to official rollup plugins (@cprecioso) + +## 1.27.13 + +_2019-12-14_ + +### Bug Fixes + +- Do not truncate environment variable values at the first colon when using the `--environment` option (#3283) + +### Pull Requests + +- [#3283](https://github.com/rollup/rollup/pull/3283): Allow environment variables to contain colons (@tlaverdure) + +## 1.27.12 + +_2019-12-13_ + +### Bug Fixes + +- Prevent invalid AMD or SystemJS code when accessing `import.meta` (#3282) + +### Pull Requests + +- [#3282](https://github.com/rollup/rollup/pull/3282): Always make "module" available for SystemJS and AMD formats if `import.meta` is accessed directly (@lukastaegert) + +## 1.27.11 + +_2019-12-12_ + +### Bug Fixes + +- Resolve a crash due to an infinite loop (#3280) + +### Pull Requests + +- [#3280](https://github.com/rollup/rollup/pull/3280): Prevent infinite deoptimizations (@lukastaegert) + +## 1.27.10 + +_2019-12-11_ + +### Bug Fixes + +- Keep track of function return values in more situations (#3278) + +### Pull Requests + +- [#3278](https://github.com/rollup/rollup/pull/3278): Avoid some unnecessary value tracking deoptimizations ( @lukastaegert) + +## 1.27.9 + +_2019-12-07_ + +### Bug Fixes + +- Fix an issue where reexports could be missing when preserving modules (#3273) +- Allow turning of color output via NO_COLOR or FORCE_COLOR=0 environment variables (#3272) + +### Pull Requests + +- [#3272](https://github.com/rollup/rollup/pull/3272): Support either NO_COLOR or FORCE_COLOR=0 to turn off color ( @kikonen) +- [#3273](https://github.com/rollup/rollup/pull/3273): Make sure that indirectly reexported modules also become chunk dependencies when preserving modules(@lukastaegert) + +## 1.27.8 + +_2019-12-02_ + +### Bug Fixes + +- Deoptimize objects when a method is called on them to make sure modifications via "this" are observed (#3266) + +### Pull Requests + +- [#3266](https://github.com/rollup/rollup/pull/3266): Workaround for various object literal mutation bugs (@kzc) + +## 1.27.7 + +_2019-12-01_ + +### Bug Fixes + +- Fix a scenario where a reassignments to computed properties were not tracked (#3267) + +### Pull Requests + +- [#3267](https://github.com/rollup/rollup/pull/3267): Fix incomplete computed property deoptimization (@lukastaegert) + +## 1.27.6 + +_2019-11-30_ + +### Bug Fixes + +- Use "auto" export mode by default for all modules when preserving modules (#3265) +- Observe "output.exports" when preserving modules and warn for mixed exports if necessary (#3265) + +### Pull Requests + +- [#3265](https://github.com/rollup/rollup/pull/3265): Use export mode "auto" by default when preserving modules ( @lukastaegert) + +## 1.27.5 + +_2019-11-25_ + +### Bug Fixes + +- Make sure namespaces for inlined dynamic imports are treated as variable accesses when deconflicting (#3256) + +### Pull Requests + +- [#3256](https://github.com/rollup/rollup/pull/3256): Avoid name conflicts when inlining dynamic imports nested in functions (@lukastaegert) +- [#3257](https://github.com/rollup/rollup/pull/3257): Update dependencies (@lukastaegert) + +## 1.27.4 + +_2019-11-22_ + +### Bug Fixes + +- Aggregate circular dependency warnings in the CLI (#3249) +- Do not defer non-aggregated handlers in the CLI (#3249) + +### Pull Requests + +- [#3249](https://github.com/rollup/rollup/pull/3249): Fix broken Windows CLI tests (@lukastaegert) +- [#3251](https://github.com/rollup/rollup/pull/3251): Add installation as a separate header (@ashrith-kulai) + +## 1.27.3 + +_2019-11-20_ + +### Bug Fixes + +- Provide better warning when empty chunks are created in a code-splitting scenario (#3244) + +### Pull Requests + +- [#3244](https://github.com/rollup/rollup/pull/3244): Clearer empty chunk warning (@tjenkinson) + +## 1.27.2 + +_2019-11-18_ + +### Bug Fixes + +- Fix an issue where live bindings were not working correctly when using `+=` in SystemJS (#3242) + +### Pull Requests + +- [#3242](https://github.com/rollup/rollup/pull/3242): Export updated assignments when using shorthand update assignment expressions in SystemJS (@lukastaegert) + +## 1.27.1 + +_2019-11-18_ + +### Bug Fixes + +- Fix an issue where code after a switch-statement with removed cases was erroneously not included (#3241) + +### Pull Requests + +- [#3237](https://github.com/rollup/rollup/pull/3237): make `acornOptions` optional in `parse()` in docs (@tjenkinson) +- [#3240](https://github.com/rollup/rollup/pull/3240): Update dependencies and fix vulnerability (@lukastaegert) +- [#3241](https://github.com/rollup/rollup/pull/3241): Do not truncate after switch-statement with removed case ( @lukastaegert) + +## 1.27.0 + +_2019-11-12_ + +### Features + +- Add support for output-specific plugins (#3218) +- Reenable parallel output processing when using the CLI (#3218) +- Warn if files are emitted that would overwrite previously emitted files (#3218) + +### Bug Fixes + +- Do not overwrite files emitted in other builds if outputs are generated in parallel (#3218) + +### Pull Requests + +- [#3218](https://github.com/rollup/rollup/pull/3218): Per output plugins (@lukastaegert) + +## 1.26.5 + +_2019-11-11_ + +### Bug Fixes + +- Fix a regression where it was no longer to pass a certain option format to generate (#3223) + +### Pull Requests + +- [#3223](https://github.com/rollup/rollup/pull/3223): Allow passing input options to output (@lukastaegert) + +## 1.26.4 + +_2019-11-09_ + +### Bug Fixes + +- Keep watching known files after a plugin error during the initial build (#3219) + +### Pull Requests + +- [#3216](https://github.com/rollup/rollup/pull/3216): Fix small typo (@kaisermann) +- [#3217](https://github.com/rollup/rollup/pull/3217): Update dependencies and fix security vulnerability ( @lukastaegert) +- [#3219](https://github.com/rollup/rollup/pull/3219): Also recover from plugin errors during the initial build ( @lukastaegert) + +## 1.26.3 + +_2019-11-02_ + +### Bug Fixes + +- Work around an incompatibility with rollup-plugin-dts (#3211) + +### Pull Requests + +- [#3211](https://github.com/rollup/rollup/pull/3211): Do no fail if the source attribute is `undefined` in an unused named export (@lukastaegert) + +## 1.26.2 + +_2019-10-31_ + +### Bug Fixes + +- Do not create invalid code when using `treeshake: false` and star re-exports (#3209) + +### Pull Requests + +- [#3209](https://github.com/rollup/rollup/pull/3209): Also remove export-all declarations when not tree-shaking ( @lukastaegert) + +## 1.26.1 + +_2019-10-31_ + +### Bug Fixes + +- Prevent an issue where outputs would overwrite files emitted by other outputs (#3201) +- Do not throw an error if the config file does not have a .js extension (#3204) + +### Pull Requests + +- [#3201](https://github.com/rollup/rollup/pull/3201): Make the CLI run generate/output in serial (@marijnh) +- [#3204](https://github.com/rollup/rollup/pull/3204): support all config file extensions (.js,.mjs,...) (@arlac77) + +## 1.26.0 + +_2019-10-27_ + +### Features + +- Only warn when no output is provided for an IIFE bundle but still produce valid code (#3181) +- Support reexporting namespaces as a binding (#3193) +- Switch from hash.js to crypto for hashing in the Node build for better performance and support for very large assets ( #3194) + +### Bug Fixes + +- Correctly handle chunks reexporting the same namespace as two different bindings (#3193) + +### Pull Requests + +- [#3181](https://github.com/rollup/rollup/pull/3181): Remove the need to provide an output name for IIFE bundles ( @bterrier) +- [#3193](https://github.com/rollup/rollup/pull/3193): Add support for "export \* as name from …" (@lukastaegert) +- [#3194](https://github.com/rollup/rollup/pull/3194): Add support for large assets (> 100 MB) (@SebastianNiemann) + +## 1.25.2 + +_2019-10-23_ + +### Bug Fixes + +- Improve performance of bundled UMD code by adding additional parentheses to enforce eager parsing (#3183) +- Improve types to tolerate passing a Rollup config with multiple outputs to `rollup.rollup` (#3184) + +### Pull Requests + +- [#3183](https://github.com/rollup/rollup/pull/3183): Add parentheses to factory function of UMD bundles (@ajihyf) +- [#3184](https://github.com/rollup/rollup/pull/3184): RollupOptions accept output as array (@imcotton) + +## 1.25.1 + +_2019-10-20_ + +### Bug Fixes + +- Handle a situation where code was not included after a switch statement (#3178) +- Handle a situation where code was not included after a do-while loop (#3180) +- Do not fail if different outputs emit the same file (#3175) +- Give access to the original acorn error for parse errors (#3176) + +### Pull Requests + +- [#3175](https://github.com/rollup/rollup/pull/3175): Disable errors for duplicate emitted file names (@marijnh) +- [#3176](https://github.com/rollup/rollup/pull/3176): Add original parser error to rollup error; Update tests ( @gribnoysup) +- [#3178](https://github.com/rollup/rollup/pull/3178): Fix switch case not being included correctly (@lukastaegert) +- [#3179](https://github.com/rollup/rollup/pull/3179): Update dependencies (@lukastaegert) +- [#3180](https://github.com/rollup/rollup/pull/3180): Handle conditional breaks in do-while loops with unconditional return (@lukastaegert) + +## 1.25.0 + +_2019-10-18_ + +### Features + +- Remove try-catch if there is no side-effect in the try-block (#3166) +- Omit side-effect-free trailing cases in switch-statements (#3166) +- Remove unused labels (#3170) + +### Bug Fixes + +- Do not remove code after labeled statements that contain a throw or return if the label is used (#3170) +- Prevent invalid code when expressions are simplified that do not follow a white-space character (#3173) +- Do not remove continue statements inside switch statements (#3166) +- Prevent trailing empty lines when tree-shaking inside switch statements (#3166) + +### Pull Requests + +- [#3166](https://github.com/rollup/rollup/pull/3166): Better try statement tree shaking (@lukastaegert) +- [#3170](https://github.com/rollup/rollup/pull/3170): Handle optional control flow in labeled statements, remove unused labels (@lukastaegert) +- [#3173](https://github.com/rollup/rollup/pull/3173): Add missing spaces in certain statements and expressions to avoid invalid code (@lukastaegert) + +## 1.24.0 + +_2019-10-15_ + +### Features + +- Respect `break`, `continue`, `return` and `throw` when tree-shaking to detect dead code (#3153) +- Do treat treat hoisted function declarations as "unknown" when checking for call side-effects (#3153) + +### Bug Fixes + +- Make sure that unknown `import.meta` properties produce valid code in SystemJS (#3152) +- Make sure `treeshake.annotations: false` is respected for class instantiation (#3153) +- Check property access side-effects for class instantiation (#3153) +- Do not suppress break statements inside labeled statements (#3153) + +### Pull Requests + +- [#3152](https://github.com/rollup/rollup/pull/3152): Allow import.meta.\* for systemjs format (@dmail) +- [#3153](https://github.com/rollup/rollup/pull/3153): Get rid of immutable.js and implement tree-shaking for broken control flow (@lukastaegert) + +## 1.23.1 + +_2019-10-05_ + +### Bug Fixes + +- Fix a regression where the node types had a specific minimal version (#3143) + +### Pull Requests + +- [#3143](https://github.com/rollup/rollup/pull/3143): Ensure that types packages have star version ranges ( @lukastaegert) + +## 1.23.0 + +_2019-10-03_ + +### Features + +- Add placeholders for extensions when preserving modules (#3116) + +### Pull Requests + +- [#3116](https://github.com/rollup/rollup/pull/3116): Include extensions in preserveModules output filenames for scriptified assets (@Andarist) +- [#3142](https://github.com/rollup/rollup/pull/3142): Fix typo (@tu4mo) + +## 1.22.0 + +_2019-09-29_ + +### Features + +- Add a new "hidden" sourcemap type that generates the map files but omits the sourcemap comment (#3120) +- Generate more efficient code when using `namespaceToStringTag: true` (#3135) +- Make sure namespace objects do not have a prototype (#3136) + +### Bug Fixes + +- Do not ignore side-effectful iterators by always preserving for..of loops for now (#3132) +- Make sure `--context` is observed as a CLI option (#3134) +- Do not require specific versions for @types dependencies (#3131) + +### Pull Requests + +- [#3120](https://github.com/rollup/rollup/pull/3120): Generate sourcemaps but omit the comment (@rohitmohan96) +- [#3131](https://github.com/rollup/rollup/pull/3131): Use asterisk for @types/\* dependencies (@frenzzy) +- [#3132](https://github.com/rollup/rollup/pull/3132): Preserve empty for...of loops (@imatlopez) +- [#3133](https://github.com/rollup/rollup/pull/3133): Update dependencies (@lukastaegert) +- [#3134](https://github.com/rollup/rollup/pull/3134): Wire up --context CLI flag (@tchetwin) +- [#3135](https://github.com/rollup/rollup/pull/3135): Remove Symbol polyfill in module namespaces (@mkubilayk) +- [#3136](https://github.com/rollup/rollup/pull/3136): Set null prototype on namespace objects (@rpamely) + +## 1.21.4 + +_2019-09-16_ + +### Bug Fixes + +- Recognize common browser globals (#3117) +- Do not treat "typeof " as a side-effect (#3117) + +### Pull Requests + +- [#3117](https://github.com/rollup/rollup/pull/3117): Add browser globals to known globals and prevent "typeof" side-effects (@lukastaegert) + +## 1.21.3 + +_2019-09-14_ + +### Bug Fixes + +- Fix a regression where modifying a watched file did not trigger a rebuild (#3112) + +### Pull Requests + +- [#3112](https://github.com/rollup/rollup/pull/3112): Fix .addWatchFile() dependencies failing to invalidate in watch mode (@tivac) + +## 1.21.2 + +_2019-09-09_ + +### Bug Fixes + +- Fix wrong deprecation message to direct to `this.emitFile` instead of `this.emitAsset` + +## 1.21.1 + +_2019-09-09_ + +### Bug Fixes + +- Allow legacy plugins to still add assets directly to the bundle object (#3105) + +### Pull Requests + +- [#3105](https://github.com/rollup/rollup/pull/3105): Allow legacy plugins to still add assets directly to the bundle object (@lukastaegert) + +## 1.21.0 + +_2019-09-08_ + +### Features + +- Respect `output.entryFileNames` when preserving modules (#3088) +- Make accessing unknown globals a side-effect unless this is deactivated via `treeshake.unknownGlobalSideEffects` ( #3068) +- Respect global objects when checking for pure global functions (#3068) +- Introduce a `type` to more easily distinguish chunks and assets in the output bundle (#3080) + +### Bug Fixes + +- Recover in watch mode when the initial build fails (#3081) +- Make sure `output.strict` is respected for SystemJS output (#3101) + +### Pull Requests + +- [#3068](https://github.com/rollup/rollup/pull/3068): Make accessing unknown globals a side-effect (@lukastaegert) +- [#3080](https://github.com/rollup/rollup/pull/3080): OutputBundle Tagged union with 'type = chunk|asset' (@askbeka) +- [#3081](https://github.com/rollup/rollup/pull/3081): Watch files onbuild, even if build fails (@mhkeller) +- [#3088](https://github.com/rollup/rollup/pull/3088): Add support for entryFileNames pattern used in combination with preserveModules option (@Andarist) +- [#3101](https://github.com/rollup/rollup/pull/3101): Remove 'use strict'; from systemjs when strict=false (@askbeka) + +## 1.20.3 + +_2019-08-28_ + +### Bug Fixes + +- Make sure file hashes change when a change of the naming pattern leads to a file name change of a dependency (#3083) +- Fix several issues where reexporting an external "default" export could lead to invalid or incorrect code (#3084) + +### Pull Requests + +- [#3078](https://github.com/rollup/rollup/pull/3078): Add github actions workflow config for windows (@shellscape) +- [#3083](https://github.com/rollup/rollup/pull/3083): Properly reflect dependency file names in hash (@lukastaegert) +- [#3084](https://github.com/rollup/rollup/pull/3084): Fix "default" reexport issues in non ESM/System formats ( @lukastaegert) + +## 1.20.2 + +_2019-08-25_ + +### Bug Fixes + +- Avoid an issue where circular namespace reexports would crash Rollup (#3074) + +### Pull Requests + +- [#3077](https://github.com/rollup/rollup/pull/3077): Handle namespaces that reexport themselves (@lukastaegert) + +## 1.20.1 + +_2019-08-22_ + +### Bug Fixes + +- Fix an issue where variable names inside dynamic import expressions were not rendered correctly (#3073) +- Fix type definition to allow a single watcher config as well as an array (#3074) + +### Pull Requests + +- [#3073](https://github.com/rollup/rollup/pull/3073): Fix wrong variable name in import expression (@lukastaegert) +- [#3074](https://github.com/rollup/rollup/pull/3074): Fixes type definition on watch and Watcher constructor ( @MicahZoltu) + +## 1.20.0 + +_2019-08-21_ + +### Features + +- Add augmentChunkHash plugin hook to be able to reflect changes in renderChunk in the chunk hash (#2921) + +### Bug Fixes + +- Do not mutate the acorn options object (#3051) +- Make sure the order of emitted chunks always reflects the order in which they were emitted (#3055) +- Do not hang when there are strings containing comment-like syntax in some scenarios (#3069) + +### Pull Requests + +- [#2921](https://github.com/rollup/rollup/pull/2921): Add augmentChunkHash plugin hook (@isidrok) +- [#2995](https://github.com/rollup/rollup/pull/2995): Add info on installing locally to docs (@mesqueeb) +- [#3037](https://github.com/rollup/rollup/pull/3037): Refresh pull request labels (@shellscape) +- [#3048](https://github.com/rollup/rollup/pull/3048): Document ROLLUP_WATCH environment variable (@shellscape) +- [#3051](https://github.com/rollup/rollup/pull/3051): Avoid changes to the original options (.acorn) object ( @LongTengDao) +- [#3052](https://github.com/rollup/rollup/pull/3052): Minor refactoring: Remove one try-catch (@KSXGitHub) +- [#3053](https://github.com/rollup/rollup/pull/3053): Refactor to use async-await in more places (@KSXGitHub) +- [#3055](https://github.com/rollup/rollup/pull/3055): Provide consistent chunking via a consistent order of entry modules when emitting chunks (@lukastaegert) +- [#3058](https://github.com/rollup/rollup/pull/3058): Remove acorn-bigint and acorn-dynamic-import from bundle ( @LongTengDao) +- [#3061](https://github.com/rollup/rollup/pull/3061): Update to acorn@7 (@lukastaegert) +- [#3063](https://github.com/rollup/rollup/pull/3063): Auto-generate license file (@lukastaegert) +- [#3069](https://github.com/rollup/rollup/pull/3069): Prevent infinite loop when scanning for line-breaks and there are comment-like strings (@lukastaegert) + +## 1.19.4 + +_2019-08-07_ + +### Bug Fixes + +- Prevent invalid code when exporting an external namespace (#3034) +- Prevent invalid or non-equivalent code when simplifying expressions in return and throw statements (#3035) + +### Pull Requests + +- [#3034](https://github.com/rollup/rollup/pull/3034): Avoid generating .\* as export (@LongTengDao) +- [#3035](https://github.com/rollup/rollup/pull/3035): Prevent ASI errors for conditional expressions (@lukastaegert) +- [#3036](https://github.com/rollup/rollup/pull/3036): Fix documents to use https, not http (@giraffate) + +## 1.19.3 + +_2019-08-06_ + +### Bug Fixes + +- Fix wrong URLs in error messages (#3033) + +### Pull Requests + +- [#3033](https://github.com/rollup/rollup/pull/3033): Fix wrong URLs in error messages (@giraffate) + +## 1.19.2 + +_2019-08-05_ + +### Bug Fixes + +- Add bin file to package + +## 1.19.1 + +_2019-08-05_ + +### Bug Fixes + +- Remove wrong extension in package.json file (#3031) + +### Pull Requests + +- [#3031](https://github.com/rollup/rollup/pull/3031): Fix wrong extension (@lukastaegert) + +## 1.19.0 + +_2019-08-05_ + +### Features + +- Implement a new unified file emission API for assets and chunks with support for explicit file names (#2999) +- Use the id of the last module in a chunk as base for the chunk name if no better name is available (#3025) +- Use the id of the last module in a chunk as base for the variable name of a chunk in some formats if no better name is available (#2999) + +### Bug Fixes + +- Do not produce invalid variable names if an empty name is chosen for a virtual module (#3026) +- Fix an issue where a module variable name would conflict with a local variable name in some formats (#3020) + +### Pull Requests + +- [#2999](https://github.com/rollup/rollup/pull/2999): Unified file emission api (@lukastaegert) +- [#3020](https://github.com/rollup/rollup/pull/3020): Switch to a code-splitting build and update dependencies ( @lukastaegert) +- [#3025](https://github.com/rollup/rollup/pull/3025): Use id of last module in chunk as name base for auto-generated chunks (@lukastaegert) +- [#3026](https://github.com/rollup/rollup/pull/3026): Avoid variable from empty module name be empty (@LongTengDao) + +## 1.18.0 + +_2019-08-01_ + +### Features + +- Add `externalLiveBindings: false` option to optimize code when live bindings are not needed (#3010) + +### Pull Requests + +- [#2997](https://github.com/rollup/rollup/pull/2997): Integrate coverage into CI setup (@lukastaegert) +- [#2998](https://github.com/rollup/rollup/pull/2998): Update readme badges (@lukastaegert) +- [#3010](https://github.com/rollup/rollup/pull/3010): Add option to prevent code for external live bindings ( @lukastaegert) + +## 1.17.0 + +_2019-07-15_ + +### Features + +- Allow plugins to access current combined sourcemap in transform hook for coverage instrumentation (#2993) + +### Pull Requests + +- [#2987](https://github.com/rollup/rollup/pull/2987): Fix code fences for link (@johanholmerin) +- [#2989](https://github.com/rollup/rollup/pull/2989): Bump lodash from 4.17.11 to 4.17.14 (@dependabot) +- [#2993](https://github.com/rollup/rollup/pull/2993): Add getCombinedSourceMap in transform plugin context (@billowz) + +## 1.16.7 + +_2019-07-09_ + +### Bug Fixes + +- Fix an issue where exported import.meta properties would lead to invalid code (#2986) + +### Pull Requests + +- [#2985](https://github.com/rollup/rollup/pull/2985): Improve sourcemap types (@jridgewell) +- [#2986](https://github.com/rollup/rollup/pull/2986): Only overwrite content when resolving import.meta properties ( @lukastaegert) + +## 1.16.6 + +_2019-07-04_ + +### Bug Fixes + +- Do not pass undefined to resolveDynamicImport for unresolvable template literals (#2984) + +### Pull Requests + +- [#2984](https://github.com/rollup/rollup/pull/2984): Always forward AST nodes for unresolvable dynamic imports ( @lukastaegert) + +## 1.16.5 + +_2019-07-04_ + +### Bug Fixes + +- onwarn should still be called when --silent is used (#2982) +- Properly clean up watchers for files that are deleted between builds (#2982) + +### Pull Requests + +- [#2981](https://github.com/rollup/rollup/pull/2981): Do not skip onwarn handler when --silent is used (@lukastaegert) +- [#2982](https://github.com/rollup/rollup/pull/2982): Make tests run on Node 12, fix watcher cleanup issue ( @lukastaegert) + +## 1.16.4 + +_2019-07-02_ + +### Bug Fixes + +- Do not show a TypeScript error when providing a location as number to this.warn and this.error (#2974) +- Use the correct TypeScript type for Sourcemap.version (#2976) + +### Pull Requests + +- [#2965](https://github.com/rollup/rollup/pull/2965): Use async readFile in getRollupDefaultPlugin (@kaksmet) +- [#2974](https://github.com/rollup/rollup/pull/2974): Align TS types, docs and implementation for this.warn and this.error (@lukastaegert) +- [#2976](https://github.com/rollup/rollup/pull/2976): Fix sourcemap type and update dependencies (@lukastaegert) + +## 1.16.3 + +_2019-06-29_ + +### Bug Fixes + +- Prevent name conflicts with unused function parameters (#2972) + +### Pull Requests + +- [#2972](https://github.com/rollup/rollup/pull/2972): Deconflict unused parameters (@lukastaegert) + +## 1.16.2 + +_2019-06-22_ + +### Bug Fixes + +- Properly wrap dynamic imports in Promises that can be caught when generating CJS output (#2958) + +### Pull Requests + +- [#2958](https://github.com/rollup/rollup/pull/2958): Make sure errors from dynamic imports can be caught ( @lukastaegert) + +## 1.16.1 + +_2019-06-21_ + +### Pull Requests + +- [#2956](https://github.com/rollup/rollup/pull/2956): Add missing CLI docs for strictDeprecations (@lukastaegert) + +## 1.16.0 + +_2019-06-21_ + +### Features + +- Add strictDeprecations option to throw when currently or upcoming deprecated features are used (#2945) +- Keep annotations and comments when simplifying logical and conditional expressions (#2955) + +### Bug Fixes + +- Generate proper namespace objects when dynamically importing external dependencies for AMD or CJS formats (#2954) +- Fix dynamically imported variables not being resolved correctly when importing from an entry chunk with only a default export (#2954) +- Do not reexport default when reexporting a namespace (#2954) + +### Pull Requests + +- [#2945](https://github.com/rollup/rollup/pull/2945): Add option to handle use of features marked for deprecation as errors (@lukastaegert) +- [#2954](https://github.com/rollup/rollup/pull/2954): Improve dynamic import interop (@lukastaegert) +- [#2955](https://github.com/rollup/rollup/pull/2955): Keep annotations and comments when simplifying logical and conditional expressions (@lukastaegert) + +## 1.15.6 + +_2019-06-16_ + +### Bug Fixes + +- No longer use an alternate screen in watch mode to allow scrolling (#2942) +- Prioritize non-external imports over external ones when resolving conflicting namespace re-exports (#2893) + +### Pull Requests + +- [#2893](https://github.com/rollup/rollup/pull/2893): Improve handling of conflicting namespace exports (@aleclarson) +- [#2942](https://github.com/rollup/rollup/pull/2942): Get rid of alternate screen and simplify screen clearing ( @lukastaegert) + +## 1.15.5 + +_2019-06-14_ + +### Bug Fixes + +- Do not include any comments for completely tree-shaken files so that `renderedLength === 0` is a reliable check ( #2940) +- Do not cause type errors when returning `null` from `resolveId` (#2941) + +### Pull Requests + +- [#2940](https://github.com/rollup/rollup/pull/2940): Completely omit files that do not have any included statements ( @lukastaegert) +- [#2941](https://github.com/rollup/rollup/pull/2941): Explicitly allow null as return value for various hooks ( @lukastaegert) + +## 1.15.4 + +_2019-06-14_ + +### Bug Fixes + +- Improve how asset and chunk URLs are resolved for UMD, IIFE and CJS output (#2937) + +### Pull Requests + +- [#2937](https://github.com/rollup/rollup/pull/2937): Fix URL resolution to work when the current script contains query parameters (@lukastaegert) + +## 1.15.3 + +_2019-06-13_ + +### Bug Fixes + +- Always reemit assets and chunks from cached transform hooks (#2936) + +### Pull Requests + +- [#2936](https://github.com/rollup/rollup/pull/2936): Fix repeated re-emission of files emitted from a transform hook ( @lukastaegert) + +## 1.15.2 + +_2019-06-13_ + +### Bug Fixes + +- Make sure chunks emitted from transform hooks are also emitted for incremental builds in watch mode (#2933) + +### Pull Requests + +- [#2933](https://github.com/rollup/rollup/pull/2933): Reemit chunks emitted from transform hooks (@lukastaegert) + +## 1.15.1 + +_2019-06-11_ + +### Bug Fixes + +- Do not fail when reexporting variables in dynamic entry points from other chunks (#2928) + +### Pull Requests + +- [#2928](https://github.com/rollup/rollup/pull/2928): Handle reexports from dynamic entries across chunk ( @lukastaegert) + +## 1.15.0 + +_2019-06-11_ + +### Features + +- Tone down try-catch deoptimization while maintaining polyfill support (#2918) + +### Bug Fixes + +- Handle feature detection with "typeof" for regular expressios (#2916) +- Deoptimize `'' + variable'` type coercion as expression statement for feature detection (#2917) +- Always observe argument side-effects when tree-shaking (#2924) + +### Pull Requests + +- [#2916](https://github.com/rollup/rollup/pull/2916): Deoptimize typeof for regular expression literals to better support es6-shim (@lukastaegert) +- [#2917](https://github.com/rollup/rollup/pull/2917): Support implicit type coercion errors in es5-shim (@lukastaegert) +- [#2918](https://github.com/rollup/rollup/pull/2918): Deoptimize try-catch less radically (@lukastaegert) +- [#2924](https://github.com/rollup/rollup/pull/2924): Do not tree-shake arguments with side-effects (@lukastaegert) + +## 1.14.6 + +_2019-06-10_ + +### Bug Fixes + +- Fix an issue where call arguments were not included in try statements (#2914) + +### Pull Requests + +- [#2914](https://github.com/rollup/rollup/pull/2914): Properly include try statements for each pass when deoptimization is deactivated (@lukastaegert) + +## 1.14.5 + +_2019-06-09_ + +### Bug Fixes + +- Keep external ids unmodified when using the object form of resolveId (#2907) +- Cache dynamic import resolutions when using Rollup cache (#2908) +- Keep all necessary parentheses when tree-shaking call arguments (#2911) + +### Pull Requests + +- [#2906](https://github.com/rollup/rollup/pull/2906): Update dependencies (@lukastaegert) +- [#2907](https://github.com/rollup/rollup/pull/2907): Do not renormalize external ids when using the object form ( @lukastaegert) +- [#2908](https://github.com/rollup/rollup/pull/2908): Cache dynamic ids if possible (@lukastaegert) +- [#2911](https://github.com/rollup/rollup/pull/2911): Fix treeshaken parameters around parentheses (@manucorporat) + +## 1.14.4 + +_2019-06-07_ + +### Bug Fixes + +- Do not omit external re-exports for `moduleSideEffects: false` (#2905) + +### Pull Requests + +- [#2905](https://github.com/rollup/rollup/pull/2905): Make sure external re-exports are included for moduleSideEffects: false (@lukastaegert) + +## 1.14.3 + +_2019-06-06_ + +### Bug Fixes + +- Generate correct external imports when importing from a directory that would be above the root of the current working directory (#2902) + +### Pull Requests + +- [#2902](https://github.com/rollup/rollup/pull/2902): Use browser relative path algorithm for chunks (@lukastaegert) + +## 1.14.2 + +_2019-06-05_ + +### Bug Fixes + +- Prevent unnecessary inclusion of external namespace import in certain situations (#2900) + +### Pull Requests + +- [#2900](https://github.com/rollup/rollup/pull/2900): Handle early bind for member expressions (@lukastaegert) + +## 1.14.1 + +_2019-06-05_ + +### Bug Fixes + +- Fix an issue where try-statements were not included properly when a variable declared inside the statement was accessed outside it (#2898) +- Fix an issue where `await` expressions were not included properly (#2899) + +### Pull Requests + +- [#2898](https://github.com/rollup/rollup/pull/2898): Properly include try-catch-statements even if they have already been included in some way (@lukastaegert) +- [#2899](https://github.com/rollup/rollup/pull/2899): Fix unintended early return in await inclusion handling ( @lukastaegert) + +## 1.14.0 + +_2019-06-05_ + +### Features + +- Deoptimize code inside and called from try-statements for feature detection (#2892) +- Tree-shake unused call arguments (#2892) + +### Pull Requests + +- [#2892](https://github.com/rollup/rollup/pull/2892): Implement try-statement-deoptimization for feature detection, tree-shake unused arguments (@lukastaegert) + +## 1.13.1 + +_2019-06-01_ + +### Bug Fixes + +- Avoid conflicts between top-level module, require etc. and CommonJS runtimes (#2889) + +### Pull Requests + +- [#2888](https://github.com/rollup/rollup/pull/2888): Enable full TypeScript strict mode (@lukastaegert) +- [#2889](https://github.com/rollup/rollup/pull/2889): Protect all module globals for CJS output from being redefined ( @lukastaegert) + +## 1.13.0 + +_2019-05-31_ + +### Features + +- Omit `exports` and `module` from SystemJS wrapper if possible (#2880) +- Try to use the first letters of names when mangling exports (#2885) + +### Bug Fixes + +- Avoid conflicts with local variables when using format specific globals to render dynamic imports and file URLs ( #2880) +- Do not produce undefined reexports when reexporting from entry points (#2885) + +### Pull Requests + +- [#2880](https://github.com/rollup/rollup/pull/2880): Deconflict global variables used inside format-specific code ( @lukastaegert) +- [#2885](https://github.com/rollup/rollup/pull/2885): Do not produce undefined reexports when reexporting from entry points and refactor chunk linking (@lukastaegert) + +## 1.12.5 + +_2019-05-30_ + +### Pull Requests + +- [#2884](https://github.com/rollup/rollup/pull/2884): Update pluginutils for new micormatch and reduced bundle size ( @lukastaegert) + +## 1.12.4 + +_2019-05-27_ + +### Bug Fixes + +- Show correct error stack trace for errors throw in "load" hooks (#2871) + +### Pull Requests + +- [#2875](https://github.com/rollup/rollup/pull/2875): Mention subfolders in docs (@lukastaegert) +- [#2871](https://github.com/rollup/rollup/pull/2871): Reserve error stack information (@LongTengDao) + +## 1.12.3 + +_2019-05-19_ + +### Bug Fixes + +- Prevent duplicate imports when exports are reexported as default exports (#2866) + +### Pull Requests + +- [#2755](https://github.com/rollup/rollup/pull/2755): Enable TypeScript strictNullChecks (@edsrzf) +- [#2866](https://github.com/rollup/rollup/pull/2866): Properly deduplicate reexported default exports (@lukastaegert) + +## 1.12.2 + +_2019-05-17_ + +### Bug Fixes + +- Do not fail when using clearScreen:false in watchMode (#2858) +- Properly resolve star reexports when preserving modules (#2860) + +### Pull Requests + +- [#2858](https://github.com/rollup/rollup/pull/2858): Declare processConfigsErr before use (@humphd) +- [#2860](https://github.com/rollup/rollup/pull/2860): Keep nested exports with preserveModules (@TomCaserta) +- [#2864](https://github.com/rollup/rollup/pull/2864): Cache transitive reexport detection (@lukastaegert) + +## 1.12.1 + +_2019-05-16_ + +### Bug Fixes + +- Extend file name sanitation to also replace "?" and "\*" e.g. when preserving modules with the updated commonjs plugin (#2860) +- Do not ignore module transformer that return an empty string (#2861) + +### Pull Requests + +- [#2860](https://github.com/rollup/rollup/pull/2860): Update to latest plugins and extend file name sanitation ( @lukastaegert) +- [#2861](https://github.com/rollup/rollup/pull/2861): Allow transformers to return an empty string (@lukastaegert) + +## 1.12.0 + +_2019-05-15_ + +### Features + +- Add `treeshake.moduleSideEffects` option to allow removing empty imports without a side-effect check (#2844) +- Extend plugin API to allow marking modules as side-effect-free (#2844) +- Extend `this.resolve` plugin context function with an option to skip the `resolveId` hook of the calling plugin ( #2844) +- Add `isEntry` flag to `this.getModuleInfo` plugin context function (#2844) +- Distribute Rollup as optimized ES2015 code (#2851) + +### Pull Requests + +- [#2844](https://github.com/rollup/rollup/pull/2844): Add options and hooks to control module side effects ( @lukastaegert) +- [#2851](https://github.com/rollup/rollup/pull/2851): Switch to ES2015 output (@lukastaegert) + +## 1.11.3 + +_2019-05-05_ + +### Bug Fixes + +- Quote es3 keywords in namespace objects (#2825) + +### Pull Requests + +- [#2825](https://github.com/rollup/rollup/pull/2825): Add es3 support for namespace object import (@sormy) + +## 1.11.2 + +_2019-05-04_ + +### Bug Fixes + +- Prevent a crash when handling circular namespace exports (#2836) + +### Pull Requests + +- [#2836](https://github.com/rollup/rollup/pull/2836): Make sure circular `export * from X` does not stack overflow ( @Swatinem) + +## 1.11.1 + +_2019-05-04_ + +### Bug Fixes + +- Fix an issue where rendered exports were reported as "removed" in the bundle information (#2835) + +### Pull Requests + +- [#2835](https://github.com/rollup/rollup/pull/2835): Fix `removedExports` to correctly track the exported item ( @Swatinem) + +## 1.11.0 + +_2019-05-03_ + +### Features + +- Add `emitChunk` plugin context function to emit additional entry chunks that can be referenced from the code (#2809) +- Allow `manualChunks` to be a function (#2831) +- Omit `.js` extensions in AMD imports to make sure an AMD `baseUrl` would work (#2809) +- Automatically use the name of the imported module as a base for dynamically imported chunks (#2809) +- Add `resolveFileUrl` plugin hook to replace `resolveAssetUrl` and handle emitted chunks as well (#2809) +- Add `resolve` plugin hook to replace `resolveId` and `isExternal` that returns an object (#2829) +- Allow `resolveDynamicImport` to return an `{id, external}` object to also resolve unresolvable dynamic imports to a module (#2829) + +### Bug Fixes + +- Do not create invalid code if a dynamic import contains nothing but reexports (#2809) +- Do not fail if modules that define a manual chunk depend on each other (#2809) +- Do not fail if a module that defines a manual chunk is the dependency of a module defining a different manual chunk ( #2809) +- No longer fail for unnamed duplicate entry points but combine them (#2809) +- Always return `string | null` from `this.resolveId` even if some `resolveId` hooks return objects (#2829) +- Show proper warnings when `resolveDynamicImport` resolves to a non-external module that does not exist (#2829) + +### Pull Requests + +- [#2809](https://github.com/rollup/rollup/pull/2809): Add hook for dynamic entry chunk emission (@lukastaegert) +- [#2821](https://github.com/rollup/rollup/pull/2821): Fix syntax error in documentation (@FFxSquall) +- [#2829](https://github.com/rollup/rollup/pull/2829): Improve id resolution (@lukastaegert) +- [#2831](https://github.com/rollup/rollup/pull/2831): Allow manualChunks to be a function (@lukastaegert) +- [#2832](https://github.com/rollup/rollup/pull/2832): Improve `generateBundle` documentation (@lukastaegert) +- [#2833](https://github.com/rollup/rollup/pull/2833): Update dependencies (@lukastaegert) + +## 1.10.1 + +_2019-04-19_ + +### Bug Fixes + +- Invalid options.format values will now trigger a helpful error (#2813) + +### Pull Requests + +- [#2812](https://github.com/rollup/rollup/pull/2812): Minor documentation update (@dnalborczyk) +- [#2813](https://github.com/rollup/rollup/pull/2813): Catch invalid options.format values (@marijnh) +- [#2816](https://github.com/rollup/rollup/pull/2816): Update all dependencies to fix security issues (@lukastaegert) + +## 1.10.0 + +_2019-04-11_ + +### Features + +- Improve generated code to polyfill `import.meta.url` (#2785) +- Add plugin hook to configure handling of `import.meta` (#2785) +- Improve generated code when accessing URLs of emitted assets (#2796) +- Add plugin hook to configure the generated code when accessing URLs of emitted assets (#2796) + +### Bug Fixes + +- No longer resolve assets to their parent URL in some cases (#2796) + +### Pull Requests + +- [#2785](https://github.com/rollup/rollup/pull/2785): Refactor handling of import.meta.url and add option to configure behaviour (@lukastaegert) +- [#2796](https://github.com/rollup/rollup/pull/2796): Improve and fix asset emission (@lukastaegert) + +## 1.9.3 + +_2019-04-10_ + +### Bug Fixes + +- Simplify return expressions that are evaluated before the surrounding function is bound (#2803) + +### Pull Requests + +- [#2803](https://github.com/rollup/rollup/pull/2803): Handle out-of-order binding of identifiers to improve tree-shaking (@lukastaegert) + +## 1.9.2 + +_2019-04-10_ + +### Bug Fixes + +- Allowing replacing `output.file` with `output.dir` in the `outputOptions` hook (#2802) + +### Pull Requests + +- [#2802](https://github.com/rollup/rollup/pull/2802): Observe modified output options in bundle.write (@lukastaegert) + +## 1.9.1 + +_2019-04-10_ + +### Bug Fixes + +- Make sure inline comments in dynamic imports are preserved (#2797) + +### Pull Requests + +- [#2797](https://github.com/rollup/rollup/pull/2797): Emit inline comments inside dynamic import (@manucorporat) + +## 1.9.0 + +_2019-04-05_ + +### Features + +- Add built-in support for bigint (#2789) + +### Pull Requests + +- [#2789](https://github.com/rollup/rollup/pull/2789): Ship with bigint support built-in (@danielgindi) +- [#2791](https://github.com/rollup/rollup/pull/2791): Use shared extractAssignedNames from rollup-pluginutils ( @lukastaegert) +- [#2792](https://github.com/rollup/rollup/pull/2792): Test that rollup-plugin-commonjs works with preserveModules ( @lukastaegert) + +## 1.8.0 + +_2019-04-02_ + +### Features + +- Support `module` as alias for `esm` and `commonjs` for `cjs` to match Node (#2783) + +### Pull Requests + +- [#2782](https://github.com/rollup/rollup/pull/2782): Inline interopDefault in config loading (@guybedford) +- [#2783](https://github.com/rollup/rollup/pull/2783): Support Node-style format aliases (@guybedford) + +## 1.7.4 + +_2019-03-28_ + +### Bug Fixes + +- Improve TypeScript type of the treeshaking options (#2779) + +### Pull Requests + +- [#2779](https://github.com/rollup/rollup/pull/2779): Make all properties in TreeshakingOptions optional (@ndelangen) + +## 1.7.3 + +_2019-03-24_ + +### Bug Fixes + +- Use getters when re-exporting live-bindings (#2765) + +### Pull Requests + +- [#2765](https://github.com/rollup/rollup/pull/2765): Support exporting live-bindings from other chunks or external dependencies (@lukastaegert) + +## 1.7.2 + +_2019-03-24_ + +### Bug Fixes + +- Make sure relative external ids are resolved correctly (#2774) + +### Pull Requests + +- [#2774](https://github.com/rollup/rollup/pull/2774): Resolve relative external ids (@lukastaegert) + +## 1.7.1 + +_2019-03-24_ + +### Bug Fixes + +- Prevent invalid code when exporting several hundred identifiers from a chunk (#2768) +- Do not wrongly deconflict labels (#2776) + +### Pull Requests + +- [#2768](https://github.com/rollup/rollup/pull/2768): Sanitize shortened internal export names (@lukastaegert) +- [#2769](https://github.com/rollup/rollup/pull/2769): Update dependencies and fix security issue (@lukastaegert) +- [#2776](https://github.com/rollup/rollup/pull/2776): Do not treat break labels as identifiers (@lukastaegert) + +## 1.7.0 + +_2019-03-20_ + +### Features + +- Sort chunk exports by name for greater consistency (#2757) + +### Bug Fixes + +- Fix a situation where tree-shakeable code would not be removed in an indeterminate manner (#2757) + +### Pull Requests + +- [#2757](https://github.com/rollup/rollup/pull/2757): Sort modules before binding, sort exports (@lukastaegert) + +## 1.6.1 + +_2019-03-20_ + +### Bug Fixes + +- Avoid name clashes of unused default exports when tree-shaking is false (#2758) +- Do not crash when generating SystemJS bundles containing array patterns with member expressions (#2760) + +### Pull Requests + +- [#2758](https://github.com/rollup/rollup/pull/2758): Make sure unused default exports are deconflicted when tree-shaking is false (@lukastaegert) +- [#2760](https://github.com/rollup/rollup/pull/2760): Handle member expressions in array patterns (@lukastaegert) + +## 1.6.0 + +_2019-03-08_ + +### Features + +- Add plugin hook to modify output options (#2736) + +### Pull Requests + +- [#2736](https://github.com/rollup/rollup/pull/2736): Add hook for modifying OutputOptions (@Comandeer) + +## 1.5.0 + +_2019-03-07_ + +### Features + +- Allow resolving to a different id while marking it as external at the same time (#2734) + +### Pull Requests + +- [#2734](https://github.com/rollup/rollup/pull/2734): Allow resolveId to return an object (@lukastaegert) + +## 1.4.2 + +_2019-03-07_ + +### Bug Fixes + +- Respect variable identity of exports when hashing (#2741) +- Resolve a situations where a variable was imported twice with the same name (#2737) + +### Pull Requests + +- [#2741](https://github.com/rollup/rollup/pull/2741): Fix hashing when different variable are exported using the same name (@lukastaegert) +- [#2737](https://github.com/rollup/rollup/pull/2737): Fix duplicate imports with conflicting names (@lukastaegert) + +## 1.4.1 + +_2019-03-04_ + +### Bug Fixes + +- Do not treat the import target "" as external by default (#2733) + +### Pull Requests + +- [#2733](https://github.com/rollup/rollup/pull/2733): Do not treat the import target "" as external by default ( @LongTengDao) + +## 1.4.0 + +_2019-03-01_ + +### Features + +- Add option to change the name of the dynamic import function to allow polyfilling it (#2723) + +### Pull Requests + +- [#2723](https://github.com/rollup/rollup/pull/2723): Add dynamicImportFunction option (@keithamus) + +## 1.3.3 + +_2019-03-01_ + +### Bug Fixes + +- Fix performance regression when handling long chains of calls to property methods (#2732) + +### Pull Requests + +- [#2730](https://github.com/rollup/rollup/pull/2730): Order types, interfaces, classes, and object members ( @lukastaegert) +- [#2732](https://github.com/rollup/rollup/pull/2732): Take chunk export mode into account when reexporting default ( @lukastaegert) + +## 1.3.2 + +_2019-02-27_ + +### Bug Fixes + +- Allow ids of default exported classes to be exported separately (#2728) + +### Pull Requests + +- [#2728](https://github.com/rollup/rollup/pull/2728): Update dependencies (@lukastaegert) + +## 1.3.1 + +_2019-02-27_ + +### Bug Fixes + +- Correctly reexport the default export from entry chunks (#2727) + +### Pull Requests + +- [#2727](https://github.com/rollup/rollup/pull/2727): Take chunk export mode into account when reexporting default ( @lukastaegert) + +## 1.3.0 + +_2019-02-26_ + +### Features + +- Treeshake call expressions prefixed with UglifyJS style `@__PURE__` annotations (#2429) + +### Pull Requests + +- [#2429](https://github.com/rollup/rollup/pull/2429): Add support for /_#**PURE**_/ comments (@conartist6 and @lukastaegert) + +## 1.2.5 + +_2019-02-26_ + +### Bug Fixes + +- Store external ids reported by plugins in watch mode (#2718) + +### Pull Requests + +- [#2718](https://github.com/rollup/rollup/pull/2718): Incremental external (@andreas-karlsson) + +## 1.2.4 + +_2019-02-26_ + +### Bug Fixes + +- Fix an issue where a variable was imported twice under the same name (#2715) + +### Pull Requests + +- [#2715](https://github.com/rollup/rollup/pull/2715): Deduplicate imports referencing default exports and their original variables (@lukastaegert) + +## 1.2.3 + +_2019-02-23_ + +### Bug Fixes + +- Use correct path when rendering dynamic imports where the entry module is empty (#2714) + +### Pull Requests + +- [#2714](https://github.com/rollup/rollup/pull/2714): Properly render dynamic imports when imported module is empty ( @lukastaegert) + +## 1.2.2 + +_2019-02-19_ + +### Bug Fixes + +- Fix wrong external imports when using the `paths` options only for some outputs (#2706) + +### Pull Requests + +- [#2706](https://github.com/rollup/rollup/pull/2706): Always recreate paths for external modules (@lukastaegert) + +## 1.2.1 + +_2019-02-17_ + +### Bug Fixes + +- Fix ESM version of Rollup (#2705) + +### Pull Requests + +- [#2705](https://github.com/rollup/rollup/pull/2705): Fix ESM version of Rollup (@lukastaegert) + +## 1.2.0 + +_2019-02-17_ + +### Features + +- Fewer renamed variables due to a completely reimplemented deconflicting logic (#2689) + +### Bug Fixes + +- Respect rendered and tree-shaken exports when determining chunk hashes (#2695) +- Fix an error when dynamic imports end up in the same chunk as one of their importees (#2677) +- Do not generate invalid code when expressions containing IIFEs are simplified (#2696) +- Do not throw an error when more than ten bundles are watched (#2700) +- Treat re-exported globals in a spec-compliant way (#2691) +- Fix issues related to wrongly renamed variables (#2689) +- Do not throw an error if config files contain non-default exports (#2673) +- Improve type of `RollupOutput.output` to guarantee at least one chunk (#2679) + +### Pull Requests + +- [#2673](https://github.com/rollup/rollup/pull/2673): Allow config files to have non-default exports (@swansontec) +- [#2677](https://github.com/rollup/rollup/pull/2677): Prevent final resolution and facade creation for inlined dynamic imports (@Rich-Harris and @lukastaegert) +- [#2679](https://github.com/rollup/rollup/pull/2679): Improve type of `RollupOutput.output` (@MattiasBuelens) +- [#2689](https://github.com/rollup/rollup/pull/2689): Reimplement variable deconflicting logic (@lukastaegert) +- [#2691](https://github.com/rollup/rollup/pull/2691): Fix CI issues and update acorn dependency (@lukastaegert) +- [#2693](https://github.com/rollup/rollup/pull/2693): Fix typo in export-globals test (@MattiasBuelens) +- [#2695](https://github.com/rollup/rollup/pull/2695): Respect rendered exports when generating chunk hashes ( @lukastaegert) +- [#2696](https://github.com/rollup/rollup/pull/2696): Correctly render function expression inside simplified expression statements (@lukastaegert) +- [#2700](https://github.com/rollup/rollup/pull/2700): Add a fix for MaxListenersExceededWarning (@luwes) +- [#2703](https://github.com/rollup/rollup/pull/2703): Update rollup-pluginutils (@lukastaegert) + +## 1.1.2 + +_2019-01-21_ + +### Bug Fixes + +- Tree-shaken dynamic imports no longer leave behind `undefined` entries in the bundle information (#2663) +- Dynamic imports in dynamically imported files could lead to crashes and would not always create new chunks (#2664) + +### Pull Requests + +- [#2663](https://github.com/rollup/rollup/pull/2663): Do not include tree-shaken dynamic imports in bundle information (@lukastaegert) +- [#2664](https://github.com/rollup/rollup/pull/2664): Properly handle dynamic imports declared in dynamically imported files (@everdimension) + +## 1.1.1 + +_2019-01-19_ + +### Bug Fixes + +- Make sure object prototype methods are not considered to be falsy when tree-shaking (#2652) + +### Pull Requests + +- [#2652](https://github.com/rollup/rollup/pull/2652): Make sure object prototype methods are not considered to be falsy (@lukastaegert) +- [#2654](https://github.com/rollup/rollup/pull/2654): Use correct signature for `this.setAssetSource` in docs ( @everdimension) +- [#2656](https://github.com/rollup/rollup/pull/2656): Swap descriptions for `[extname]` and `[ext]` in docs (@tivac) + +## 1.1.0 + +_2019-01-09_ + +### Features + +- Make `this.meta` available from the `options` plugin hook (#2642) +- Add a new `writeBundle` plugin hook that is called _after_ all files have been written (#2643) + +### Bug Fixes + +- Make sure the `acorn` import of the bundled non-ESM acorn plugins is correctly translated to ESM (#2636) +- Make sure input options are actually passed to the `buildStart` hook (#2642) + +### Pull Requests + +- [#2636](https://github.com/rollup/rollup/pull/2636): Improve how acorn is imported, update dependencies ( @lukastaegert) +- [#2642](https://github.com/rollup/rollup/pull/2642): Make this.meta available in options hook, pass input options to buildStart (@lukastaegert) +- [#2643](https://github.com/rollup/rollup/pull/2643): Implement writeBundle hook (@lukastaegert) + +## 1.0.2 + +_2019-01-05_ + +### Bug Fixes + +- Make sure the transform hook is always reevaluated when a file watched by the hook changes (#2633) +- Fix a crash when generating hashes for tree-shaken dynamic imports (#2638) +- Fix a crash and some inconsistencies when using the acorn-bigint plugin (#2640) + +### Pull Requests + +- [#2633](https://github.com/rollup/rollup/pull/2633): Document `this.addWatchFile` and make sure it also declares transform dependencies (@lukastaegert) +- [#2635](https://github.com/rollup/rollup/pull/2635): Make sure `code` is optional in warning type (@lukastaegert) +- [#2638](https://github.com/rollup/rollup/pull/2638): Do not fail when generating hashes for tree-shaken dynamic imports (@lukastaegert) +- [#2640](https://github.com/rollup/rollup/pull/2640): Always treat bigints as unknown (@lukastaegert) +- [#2641](https://github.com/rollup/rollup/pull/2641): Make sure all CLI options are listed in the summary ( @lukastaegert) + +## 1.0.1 + +_2019-01-03_ + +### Bug Fixes + +- Properly handle reexporting an external default export for non-ESM targets when using named exports mode (#2620) +- Do not (wrongly) re-declare input options in the merged `RollupOptions` type (#2622) + +### Pull Requests + +- [#2620](https://github.com/rollup/rollup/pull/2620): Fixed issue with reexporting default as default with `{exports: named, interop: true}` options (@Andarist) +- [#2622](https://github.com/rollup/rollup/pull/2622): Simplify RollupOptions (@Kinrany) +- [#2627](https://github.com/rollup/rollup/pull/2627): Show how to skip imports for optional plugins (@chris-morgan) + +## 1.0.0 + +_2018-12-28_ + +### Breaking Changes + +- Several (mostly deprecated) options have been removed or renamed (#2293, #2409): + - banner -> output.banner + - dest -> output.file + - entry -> input + - experimentalCodeSplitting -> now always active + - experimentalDynamicImport -> now always active + - experimentalPreserveModules -> preserveModules + - exports -> output.exports + - extend -> output.extend + - footer -> output.footer + - format -> output.format + - freeze -> output.freeze + - globals -> output.globals + - indent -> output.indent + - interop -> output.interop + - intro -> output.intro + - load -> use plugin API + - moduleName -> output.name + - name -> output.name + - noConflict -> output.noConflict + - output.moduleId -> output.amd.id + - outro -> output.outro + - paths -> output.paths + - preferConst -> output.preferConst + - pureExternalModules -> treeshake.pureExternalModules + - resolveExternal -> use plugin API + - resolveId -> use plugin API + - sourcemap -> output.sourcemap + - sourceMap -> output.sourcemap + - sourceMapFile -> output.sourcemapFile + - strict -> output.strict + - targets -> use output as an array + - transform -> use plugin API + - useStrict -> output.strict +- In general, output options can no longer be used as input options (#2409) +- `bundle.generate` and `bundle.write` now return a new format (#2293) +- Several plugin hooks have become deprecated and will display warnings when used (#2409): + - transformBundle + - transformChunk + - ongenerate + - onwrite +- Plugin transform dependencies are deprecated in favour of using the `this.addWatchFile` plugin context function ( #2409) +- Accessing `this.watcher` in plugin hooks is deprecated in favour of the `watchChange` plugin hook and the `this.addWatchFile` plugin context function (#2409) +- Using dynamic import statements will by default create a new chunk unless `inlineDynamicImports` is used (#2293) +- Rollup now uses acorn@6 which means that acorn plugins must be compatible with this version; acorn is now external for non-browser builds to make plugins work (#2293) + +### Features + +- The `--dir` ClI option can now be aliased as `-d` (#2293) +- The `--input` option now supports named entry points via `=` (#2293) + +### Bug Fixes + +- Both the `--input` option as well as the default CLI option now support named inputs (#2293) + +### Pull Requests + +- [#2293](https://github.com/rollup/rollup/pull/2293): Unify code paths for 1.0 relase and update documentation ( @guybedford and @lukastaegert) +- [#2409](https://github.com/rollup/rollup/pull/2409): Remove old deprecated features and add new deprecation warnings ( @guybedford) +- [#2486](https://github.com/rollup/rollup/pull/2486): Upgrade to acorn 6 (@marijnh) +- [#2611](https://github.com/rollup/rollup/pull/2611): Fix hook's name in test description (@Andarist) +- [#2612](https://github.com/rollup/rollup/pull/2612): Fix a self-contradicting comment in the docs (@LongTengDao) + +For previous changelogs, see + +- [Rollup 0.x](./CHANGELOG-0.md) diff --git a/CHANGELOG-2.md b/CHANGELOG-2.md new file mode 100644 index 00000000000..564cd9b952c --- /dev/null +++ b/CHANGELOG-2.md @@ -0,0 +1,3124 @@ +# rollup changelog + +## 2.79.1 + +_2022-09-22_ + +### Bug Fixes + +- Avoid massive performance degradation when creating thousands of chunks (#4643) + +### Pull Requests + +- [#4639](https://github.com/rollup/rollup/pull/4639): fix: typo docs and contributors link in CONTRIBUTING.md ( @takurinton) +- [#4641](https://github.com/rollup/rollup/pull/4641): Update type definition of resolveId (@ivanjonas) +- [#4643](https://github.com/rollup/rollup/pull/4643): Improve performance of chunk naming collision check ( @lukastaegert) + +## 2.79.0 + +_2022-08-31_ + +### Features + +- Add `amd.forceJsExtensionForImports` to enforce using `.js` extensions for relative AMD imports (#4607) + +### Pull Requests + +- [#4607](https://github.com/rollup/rollup/pull/4607): add option to keep extensions for amd (@wh1tevs) + +## 2.78.1 + +_2022-08-19_ + +### Bug Fixes + +- Avoid inferring "arguments" as name for a default export placeholder variable (#4613) + +### Pull Requests + +- [#4613](https://github.com/rollup/rollup/pull/4613): Prevent using arguments for generated variable names ( @lukastaegert) + +## 2.78.0 + +_2022-08-14_ + +### Features + +- Support writing plugin hooks as objects with a "handler" property (#4600) +- Allow changing execution order per plugin hook (#4600) +- Add flag to execute plugins in async parallel hooks sequentially (#4600) + +### Pull Requests + +- [#4600](https://github.com/rollup/rollup/pull/4600): Allow using objects as hooks to change execution order ( @lukastaegert) + +## 2.77.3 + +_2022-08-11_ + +### Bug Fixes + +- Correctly resolve preserveModulesRoot in Vite (#4591) + +### Pull Requests + +- [#4591](https://github.com/rollup/rollup/pull/4591): resolve currentPath (@cleverpp) + +## 2.77.2 + +_2022-07-27_ + +### Bug Fixes + +- Avoid a rendering failure when mixing outputs with inlined and non-inlined dynamic imports (#4589) + +### Pull Requests + +- [#4589](https://github.com/rollup/rollup/pull/4589): Handle generating non-inlined imports after inlined ones ( @lukastaegert) + +## 2.77.1 + +_2022-07-26_ + +### Bug Fixes + +- Ensure IIFE output generates a global variable when generating ES5 (#4588) + +### Pull Requests + +- [#4577](https://github.com/rollup/rollup/pull/4577): broken link removed (@Jawad-H) +- [#4580](https://github.com/rollup/rollup/pull/4580): Update dependencies (@lukastaegert) +- [#4584](https://github.com/rollup/rollup/pull/4584): Documentation clarity and syntax improvements (@berniegp) +- [#4588](https://github.com/rollup/rollup/pull/4588): Use var for IIFE (@lukastaegert) + +## 2.77.0 + +_2022-07-15_ + +### Features + +- Introduce `maxParallelFileOps` to limit both read and write operations, default to 20 and replaces `maxParallelFileRead` (#4570) + +### Bug Fixes + +- Avoid including variables referenced from return statements that are never reached (#4573) + +### Pull Requests + +- [#4570](https://github.com/rollup/rollup/pull/4570): Introduce maxParallelFileOps to limit parallel writes ( @lukastaegert) +- [#4572](https://github.com/rollup/rollup/pull/4572): Document more ways to read package.json in ESM (@berniegp) +- [#4573](https://github.com/rollup/rollup/pull/4573): Do not include unused return expressions (@lukastaegert) + +## 2.76.0 + +_2022-07-08_ + +### Features + +- Allow setting a `sourcmapBaseUrl` for absolute paths in sourcemaps (#4527) + +### Bug Fixes + +- Support absolute CLI plugin paths on Windows (#4533) + +### Pull Requests + +- [#4527](https://github.com/rollup/rollup/pull/4527): Add sourcemapBaseUrl option (@nickgarlis) +- [#4533](https://github.com/rollup/rollup/pull/4533): Add support for absolute plugin paths (@ygoe) +- [#4538](https://github.com/rollup/rollup/pull/4538): chore: Included githubactions in the dependabot config ( @naveensrinivasan) +- [#4546](https://github.com/rollup/rollup/pull/4546): Adapt Node versions on CI to prepare for v3 (@lukastaegert) +- [#4556](https://github.com/rollup/rollup/pull/4556): Improve error message for invalid patterns (@DysphoricUnicorn) +- [#4559](https://github.com/rollup/rollup/pull/4559): Update dependencies (@lukastaegert) +- [#4560](https://github.com/rollup/rollup/pull/4560): Bump peter-evans/create-or-update-comment from 1 to 2 ( @dependabot) +- [#4561](https://github.com/rollup/rollup/pull/4561): Bump peter-evans/find-comment from 1 to 2 (@dependabot) +- [#4562](https://github.com/rollup/rollup/pull/4562): Bump codecov/codecov-action from 1 to 3 (@dependabot) + +## 2.75.7 + +_2022-06-20_ + +### Bug Fixes + +- Mark Array.prototype.group/groupToMap as side effect free. (#4531) + +### Pull Requests + +- [#4523](https://github.com/rollup/rollup/pull/4523): chore: remove source map workaround, bump deps (@dnalborczyk) +- [#4525](https://github.com/rollup/rollup/pull/4525): Add regression tests for instanceof (@lukastaegert) +- [#4528](https://github.com/rollup/rollup/pull/4528): chore: Set permissions for GitHub actions (@naveensrinivasan) +- [#4531](https://github.com/rollup/rollup/pull/4531): fix: rename Array.prototype.group/groupToMap (@dnalborczyk) +- [#4535](https://github.com/rollup/rollup/pull/4535): chore: bump resolve from 1.22.0 to 1.22.1 (@pos777) + +## 2.75.6 + +_2022-06-07_ + +### Bug Fixes + +- Properly deoptimize "this" when using member expressions with getters/setters in for loops and update expressions ( #4522) + +### Pull Requests + +- [#4522](https://github.com/rollup/rollup/pull/4522): Refactor side effect handling for property interactions ( @lukastaegert) + +## 2.75.5 + +_2022-06-01_ + +### Bug Fixes + +- Avoid crashes when using logical expressions for unused constructor arguments (#4519) +- Fix missing parameter defaults for calls from try statements and functions returned by functions (#4520) + +### Pull Requests + +- [#4519](https://github.com/rollup/rollup/pull/4519): Try to make logical expression deoptimization more robust ( @lukastaegert) +- [#4520](https://github.com/rollup/rollup/pull/4520): Roll back parameter default tree shaking (@lukastaegert) + +## 2.75.4 + +_2022-05-31_ + +### Bug Fixes + +- Ensure parameter defaults are retained when a function is used as an object property (#4516) + +### Pull Requests + +- [#4516](https://github.com/rollup/rollup/pull/4516): Deoptimize parameter defaults when referenced from object/array/class literals (@lukastaegert) + +## 2.75.3 + +_2022-05-29_ + +### Bug Fixes + +- Retain parameter defaults for functions that are defaults themselves (#4515) +- Track mutations for objects as default values (#4515) + +### Pull Requests + +- [#4515](https://github.com/rollup/rollup/pull/4515): Ensure parameter defaults are deoptimized (@lukastaegert) + +## 2.75.1 + +_2022-05-28_ + +### Pull Requests + +- [#4513](https://github.com/rollup/rollup/pull/4513): Update link to node polyfill repo (@lukastaegert) + +## 2.75.0 + +_2022-05-27_ + +### Features + +- Re-implement default parameter tree-shaking for top-level functions (#4510) +- Do not consider calling string methods like `.trim()` on template literals a side effect (#4511) + +### Pull Requests + +- [#4510](https://github.com/rollup/rollup/pull/4510): Tree-shake parameter defaults (replaces #4498) (@lukastaegert) +- [#4511](https://github.com/rollup/rollup/pull/4511): Tree-shake side-effect-free string methods on template literals ( @lukastaegert) + +## 2.74.1 + +_2022-05-19_ + +### Bug Fixes + +- Revert #4498 until some issues are understood and resolved + +## 2.74.0 + +_2022-05-19_ + +### Features + +- Remove unneeded default values for function parameters (#4498) + +### Bug Fixes + +- Use a consistent mechanism to resolve the config file to avoid issues on Windows (#4501) +- Avoid an inaccurate warning about an event emitter leak for complicated builds (#4502) +- Ensure that reexporting values from other chunks via dynamic imports does not reference non-imported variables (#4499) + +### Pull Requests + +- [#4498](https://github.com/rollup/rollup/pull/4498): Tree shake parameter defaults (@lukastaegert) +- [#4499](https://github.com/rollup/rollup/pull/4499): Ensure reexports are available for namespaces (@lukastaegert) +- [#4501](https://github.com/rollup/rollup/pull/4501): fix: config path problem on windows (@pos777) +- [#4502](https://github.com/rollup/rollup/pull/4502): Avoid maximum listeners exceeded warning (@lukastaegert) + +## 2.73.0 + +_2022-05-13_ + +### Features + +- Do not treat Object.defineProperty/ies as side effect when called on an unused object (#4493) +- Do not assume that assigning a property can create a getter with side effects (#4493) +- Do not treat string.prototype.replace(All) as side effect when used with two literals (#4493) + +### Bug Fixes + +- Detect side effects when manually declaring getters on functions (#4493) + +### Pull Requests + +- [#4493](https://github.com/rollup/rollup/pull/4493): Handle getters on functions and improve property deoptimization ( @lukastaegert) +- [#4494](https://github.com/rollup/rollup/pull/4494): Do not treat string.replace as side effect when used with a literal (@lukastaegert) +- [#4495](https://github.com/rollup/rollup/pull/4495): Update docs for --configPlugin using typescript ( @Jimmydalecleveland) + +## 2.72.1 + +_2022-05-07_ + +### Bug Fixes + +- Improve tree-shaking of classes with super classes in certain scenarios (#4489) + +### Pull Requests + +- [#4489](https://github.com/rollup/rollup/pull/4489): Do not deoptimize entire super class when adding a property ( @lukastaegert) + +## 2.72.0 + +_2022-05-05_ + +### Features + +- Add CLI hooks to run external commands at certain points in watch mode (#4457) + +### Bug Fixes + +- Fix an issue that could accidentally treat relevant assignments as side effect free (#4486) + +### Pull Requests + +- [#4457](https://github.com/rollup/rollup/pull/4457): feat: CLI event hook flags (@Harris-Miller) +- [#4486](https://github.com/rollup/rollup/pull/4486): Fix reassignment tracking (@lukastaegert) + +## 2.71.1 + +_2022-04-30_ + +### Bug Fixes + +- Allow importing loadConfigFile without extension (#4483) + +### Pull Requests + +- [#4483](https://github.com/rollup/rollup/pull/4483): Add exports exception for loadConfigFile (@lukastaegert) + +## 2.71.0 + +_2022-04-30_ + +## Features + +- Mark `Object.hasOwn` as pure (#4482) + +### Bug Fixes + +- Prevent infinite recursion and display proper warning for recursive reexports (#4472) +- Fix type issue in TypeScript nightly (#4471) + +### Pull Requests + +- [#4467](https://github.com/rollup/rollup/pull/4467): docs: update deprecated option in tools.md (@kimjh96) +- [#4471](https://github.com/rollup/rollup/pull/4471): Fix: tsc did not build (@frank-dspeed) +- [#4472](https://github.com/rollup/rollup/pull/4472): Throw proper error when indirectly reexporting a recursive binding (@lukastaegert) +- [#4475](https://github.com/rollup/rollup/pull/4475): chore: bump deps (#4475) (@dnalborczyk) +- [#4477](https://github.com/rollup/rollup/pull/4477): chore: bump github actions (@dnalborczyk) +- [#4478](https://github.com/rollup/rollup/pull/4478): ci: test with node.js v18, remove v17 (@dnalborczyk) +- [#4479](https://github.com/rollup/rollup/pull/4479): chore(repo): replace `git.io` in the issue template (@SukkaW) +- [#4482](https://github.com/rollup/rollup/pull/4482): feat: add Object.hasOwn as pure function (@dnalborczyk) + +## 2.70.2 + +_2022-04-15_ + +### Bug Fixes + +- Do not enforce undefined return values in TypeScript types (#4463) + +### Pull Requests + +- [#4463](https://github.com/rollup/rollup/pull/4463): use void for options hook instead of undefined (@ycmjason) + +## 2.70.1 + +_2022-03-14_ + +### Bug Fixes + +- Handle unfinished hook action errors as regular errors and avoid console logging (#4434) +- Allow access to "dist" folder in a Node 17 compatible way (#4436) + +### Pull Requests + +- [#4434](https://github.com/rollup/rollup/pull/4434): Track unfinished hook actions as regular errors (@lukastaegert) +- [#4436](https://github.com/rollup/rollup/pull/4436): Update package.json (@frank-dspeed) + +## 2.70.0 + +_2022-03-07_ + +### Features + +- Make the `watchChange` and `closeWatcher` hooks asynchronous and make Rollup wait for these hooks before continuing ( #4427) + +### Bug Fixes + +- Do not abort watch mode for errors in `watchChange` but display them properly (#4427) + +### Pull Requests + +- [#4427](https://github.com/rollup/rollup/pull/4427): Do not abort watch mode on errors in watchChange (@lukastaegert) + +## 2.69.2 + +_2022-03-06_ + +### Bug Fixes + +- Mark `Object.entries` and `Object.fromEntries` as pure (#4429) +- Make sure new properties on Array.prototype and Object.prototype are not evaluated as "undefined" (#4428) + +### Pull Requests + +- [#4428](https://github.com/rollup/rollup/pull/4428): Treat unknown prototype props as unknown (@lukastaegert) +- [#4429](https://github.com/rollup/rollup/pull/4429): Treat unknown prototype props as unknown (@869288142) + +## 2.69.1 + +_2022-03-04_ + +### Bug Fixes + +- Approximate source position instead of ignoring it when using a low-resolution source map in a transform hook (#4334) + +### Pull Requests + +- [#4334](https://github.com/rollup/rollup/pull/4334): fix(sourcemap): fall back to low-resolution line mapping ( @aleclarson and @lukastaegert) + +## 2.69.0 + +_2022-03-02_ + +### Features + +- Introduce new `output.generatedCode.symbols` to control the usage of Symbols in Rollup-generated code (#4378) +- soft-deprecate `output.namespaceToStringTag` in favor of `output.generatedCode.symbols` (#4378) + +### Bug Fixes + +- Properly handle `./` and `../` as external dependencies (#4419) +- Make generated "Module" namespace toStringTag non-enumerable for correct Object.assign/spread behaviour (#4378) +- Add file name to error when top-level-await is used in disallowed formats (#4421) + +### Pull Requests + +- [#4378](https://github.com/rollup/rollup/pull/4378): Make namespace @@toStringTag "Module" non-enumerable ( @dnalborczyk and @lukastaegert) +- [#4413](https://github.com/rollup/rollup/pull/4413): refactor: some code and type fixes (@dnalborczyk) +- [#4418](https://github.com/rollup/rollup/pull/4418): chore: bump deps (@dnalborczyk) +- [#4419](https://github.com/rollup/rollup/pull/4419): Properly handle upper directories as external dependencies ( @lukastaegert) +- [#4421](https://github.com/rollup/rollup/pull/4421): Improve the error prompt and output the error file name ( @caoxiemeihao) +- [#4423](https://github.com/rollup/rollup/pull/4423): Update 999-big-list-of-options.md (@leoj3n) + +## 2.68.0 + +_2022-02-22_ + +### Features + +- provide information about cached import resolutions in `shouldTransformCachedModule` (#4414) +- Add "types" field to Rollup's package exports (#4416) + +### Pull Requests + +- [#4410](https://github.com/rollup/rollup/pull/4410): refactor: use map for declarations and name suggestions ( @dnalborczyk) +- [#4411](https://github.com/rollup/rollup/pull/4411): refactor: use map for namespace reexports by name (@dnalborczyk) +- [#4412](https://github.com/rollup/rollup/pull/4412): refactor: use includes where appropriate (@dnalborczyk) +- [#4414](https://github.com/rollup/rollup/pull/4414): Add resolved sources to shouldTransformCachedModule ( @lukastaegert) +- [#4416](https://github.com/rollup/rollup/pull/4416): Add Typescript 4.5 nodenext node12 module resolution support ( @frank-dspeed) + +## 2.67.3 + +_2022-02-18_ + +### Bug Fixes + +- Do not swallow other errors when unfinished hook actions are detected (#4409) +- Add additional information to output when there are unfinished hook actions (#4409) + +### Pull Requests + +- [#4399](https://github.com/rollup/rollup/pull/4399): docs: remove const (@TrickyPi) +- [#4401](https://github.com/rollup/rollup/pull/4401): Improve test stability by getting independent of module id ordering in more places (@lukastaegert) +- [#4403](https://github.com/rollup/rollup/pull/4403): fix: remove unnecessary property descriptor spread (@dnalborczyk) +- [#4404](https://github.com/rollup/rollup/pull/4404): refactor: use map for import descriptions + re-export descriptions (@dnalborczyk) +- [#4405](https://github.com/rollup/rollup/pull/4405): refactor: module exports to map (@dnalborczyk) +- [#4406](https://github.com/rollup/rollup/pull/4406): Fix a typo in 'Direct plugin communication' code example ( @younesmln) +- [#4407](https://github.com/rollup/rollup/pull/4407): Document how resolveId is cached (@lukastaegert) +- [#4409](https://github.com/rollup/rollup/pull/4409): Print ids for unfinished moduleParsed and shouldTransformCachedModule hooks (@lukastaegert) + +## 2.67.2 + +_2022-02-10_ + +### Bug Fixes + +- Ensure consistent order between manual chunks to fix hashing issues (#4397) + +### Pull Requests + +- [#4390](https://github.com/rollup/rollup/pull/4390): refactor: add @types/estree explicitly, fix dynamic type imports (@dnalborczyk) +- [#4391](https://github.com/rollup/rollup/pull/4391): chore: remove acorn-walk ambient type definitions (@dnalborczyk) +- [#4397](https://github.com/rollup/rollup/pull/4397): Sort manual chunks generated via a function by name ( @lukastaegert) + +## 2.67.1 + +_2022-02-07_ + +### Bug Fixes + +- Make chunk file and variable names more deterministic when emitting chunks (#4386) +- Improve default module resolver performance by using non-blocking IO (#4386) + +### Pull Requests + +- [#4373](https://github.com/rollup/rollup/pull/4373): fix: even more types (@dnalborczyk) +- [#4382](https://github.com/rollup/rollup/pull/4382): Update contribution tut link desc (@lemredd) +- [#4383](https://github.com/rollup/rollup/pull/4383): chore: bump deps (@dnalborczyk) +- [#4384](https://github.com/rollup/rollup/pull/4384): chore: move "wait" to utils + re-use (@dnalborczyk) +- [#4385](https://github.com/rollup/rollup/pull/4385): refactor: convert watch tests to async functions (@dnalborczyk) +- [#4386](https://github.com/rollup/rollup/pull/4386): refactor: use fs.promises in resolve id, Part 4 (@dnalborczyk and @lukastaegert) +- [#4389](https://github.com/rollup/rollup/pull/4389): refactor: use fs.promises in generate license file, rollup config, Part 5 (@dnalborczyk) + +## 2.67.0 + +_2022-02-02_ + +### Features + +- Improve side effect detection when using Array.prototype.groupBy/groupByToMap (#4360) +- Allow changing `moduleSideEffects` at any time during the build (#4379) +- Soft-deprecate `ModuleInfo.hasModuleSideEffects` in favour of `ModuleInfo.moduleSideEffects` (#4379) + +### Bug Fixes + +- Do not include queries and hashes in generated file names when preserving modules (#4374) + +### Pull Requests + +- [#4319](https://github.com/rollup/rollup/pull/4319): refactor: use fs, fs-extra, remove sander (@dnalborczyk) +- [#4360](https://github.com/rollup/rollup/pull/4360): feat: add Array.prototype.groupBy/groupByToMap (@dnalborczyk) +- [#4361](https://github.com/rollup/rollup/pull/4361): fix: more types (@dnalborczyk) +- [#4369](https://github.com/rollup/rollup/pull/4369): fix: remove acorn-walk patch (@dnalborczyk) +- [#4371](https://github.com/rollup/rollup/pull/4371): refactor: use fs.promises in cli/run (@dnalborczyk) +- [#4372](https://github.com/rollup/rollup/pull/4372): refactor: use fs.promises in module loader (@dnalborczyk) +- [#4374](https://github.com/rollup/rollup/pull/4374): Ignore queries and hashes in file names when preserving modules ( @lukastaegert) +- [#4375](https://github.com/rollup/rollup/pull/4375): Fix typo in \_config.js (@eltociear) +- [#4376](https://github.com/rollup/rollup/pull/4376): refactor: fs.promises, move mkdir to writeoutputfile, Part 3 ( @dnalborczyk) +- [#4379](https://github.com/rollup/rollup/pull/4379): Deprecate hasModuleSideEffects in favor of moduleSideEffects and ensure it is mutable on ModuleInfo (@lukastaegert) + +## 2.66.1 + +_2022-01-25_ + +### Bug Fixes + +- Only warn for conflicting names in namespace reexports if it actually causes problems (#4363) +- Only allow explicit exports or reexports as synthetic namespaces and hide them from namespace reexports (#4364) + +### Pull Requests + +- [#4362](https://github.com/rollup/rollup/pull/4362): refactor: convert exportsByName object to map (@dnalborczyk) +- [#4363](https://github.com/rollup/rollup/pull/4363): Do not warn unnecessarily for namespace conflicts (@lukastaegert) +- [#4364](https://github.com/rollup/rollup/pull/4364): Do not expose synthetic namespace export in entries and namespaces (@lukastaegert) + +## 2.66.0 + +_2022-01-22_ + +### Features + +- Note if a module has a default export in ModuleInfo to allow writing better proxy modules (#4356) +- Add option to wait until all imported ids have been resolved when awaiting `this.load` (#4358) + +### Pull Requests + +- [#4356](https://github.com/rollup/rollup/pull/4356): Add hasDefaultExport to ModuleInfo (@lukastaegert) +- [#4358](https://github.com/rollup/rollup/pull/4358): Add "resolveDependencies" option to "this.load" (@lukastaegert) + +## 2.65.0 + +_2022-01-21_ + +### Features + +- Add complete import resolution objects to ModuleInfo for use in `this.load` (#4354) + +### Bug Fixes + +- Use correct context in plugin hooks with `perf: true` (#4357) + +### Pull Requests + +- [#4351](https://github.com/rollup/rollup/pull/4351): refactor: re-use source mapping url (@dnalborczyk) +- [#4352](https://github.com/rollup/rollup/pull/4352): refactor: replace require-relative with built-in require.resolve (@dnalborczyk) +- [#4353](https://github.com/rollup/rollup/pull/4353): chore: bump deps (@dnalborczyk) +- [#4354](https://github.com/rollup/rollup/pull/4354): Add importedIdResolutions to moduleInfo (@lukastaegert) +- [#4355](https://github.com/rollup/rollup/pull/4355): chore: remove external from config (@dnalborczyk) +- [#4357](https://github.com/rollup/rollup/pull/4357): fix: timed plugin context (@dnalborczyk) + +## 2.64.0 + +_2022-01-14_ + +### Features + +- Allow inspecting cached modules and forcing them to be transformed again via shouldTransformCachedModule (#4320) +- Do not wait for the config file to be parsed in watch mode if it is updated before that (#4344) + +### Bug Fixes + +- Do not mutate objects returned as `meta` from the resolveId hook (#4347) + +### Pull Requests + +- [#4326](https://github.com/rollup/rollup/pull/4326): refactor: type fixes (@dnalborczyk) +- [#4339](https://github.com/rollup/rollup/pull/4339): More watch test stabilization (@lukastaegert) +- [#4340](https://github.com/rollup/rollup/pull/4340): refactor: performance timers for node.js and browser ( @dnalborczyk) +- [#4341](https://github.com/rollup/rollup/pull/4341): Implement shouldTransformCachedModule hook (@lukastaegert) +- [#4344](https://github.com/rollup/rollup/pull/4344): Directly restart Rollup when config file change is detected in watch mode (@lukastaegert) +- [#4347](https://github.com/rollup/rollup/pull/4347): Create a shallow copy when returning meta from resolveId ( @lukastaegert) + +## 2.63.0 + +_2022-01-04_ + +### Features + +- Report a helpful error if rollup exits due to an empty event loop when using `this.load` (#4320) +- Allow directly mutating ModuleInfo.meta for modules and never replace this object (#4328) +- Detect additional side effect free array prototype methods (#4332) + +### Bug Fixes + +- Do not watch if CLI watch options are specified but `--watch` is missing (#4335) + +### Pull Requests + +- [#4320](https://github.com/rollup/rollup/pull/4320): Detect unfulfilled async hook actions and report error on exit ( @kzc) +- [#4328](https://github.com/rollup/rollup/pull/4328): Make initial ModuleInfo.meta mutable and maintain object identity (@lukastaegert) +- [#4318](https://github.com/rollup/rollup/pull/4318): Stabilize watch tests (@lukastaegert) +- [#4331](https://github.com/rollup/rollup/pull/4331): Improve JS docs example (@lukastaegert) +- [#4332](https://github.com/rollup/rollup/pull/4332): add support for Array.prototype.findLast,findLastIndex ( @dnalborczyk) +- [#4333](https://github.com/rollup/rollup/pull/4333): convert utils.transform to async function (@dnalborczyk) +- [#4335](https://github.com/rollup/rollup/pull/4335): Do not watch unless --watch is specified explicitly ( @lukastaegert) +- [#4338](https://github.com/rollup/rollup/pull/4338): Add build delay for plugin event test (@lukastaegert) + +## 2.62.0 + +_2021-12-24_ + +### Features + +- Mark additional string prototype methods as side-effect-free and correct typings of existing ones (#4299) +- Mark additional array prototype methods as side-effect-free and correct typings of existing ones (#4309) +- Expose if a module is included after tree-shaking in its ModuleInfo (#4305) + +### Bug Fixes + +- Fix how fsevents is included to improve watch mode on MacOS (#4312) + +### Pull Requests + +- [#4299](https://github.com/rollup/rollup/pull/4299): Add additional string prototype methods (@dnalborczyk) +- [#4300](https://github.com/rollup/rollup/pull/4300): Bump deps, fix expected test result for core-js (@dnalborczyk) +- [#4302](https://github.com/rollup/rollup/pull/4302): Replace type assertion with type guard (@dnalborczyk) +- [#4304](https://github.com/rollup/rollup/pull/4304): Re-use reserved names set (@dnalborczyk) +- [#4305](https://github.com/rollup/rollup/pull/4305): Expose isIncluded in module info (@william57m) +- [#4306](https://github.com/rollup/rollup/pull/4306): Fix git line breaks on windows (@dnalborczyk) +- [#4307](https://github.com/rollup/rollup/pull/4307): Add macos to pipeline (@dnalborczyk) +- [#4309](https://github.com/rollup/rollup/pull/4309): Add additional array prototype methods (@dnalborczyk) +- [#4311](https://github.com/rollup/rollup/pull/4311): Add Deno instructions to docs (@jespertheend) +- [#4312](https://github.com/rollup/rollup/pull/4312): fsevents integration (@dnalborczyk) +- [#4313](https://github.com/rollup/rollup/pull/4313): Remove non-existing static functions from known globals ( @dnalborczyk) + +## 2.61.1 + +_2021-12-11_ + +### Bug Fixes + +- Only resolve this.load once the code of the module is available (#4296) + +### Pull Requests + +- [#4296](https://github.com/rollup/rollup/pull/4296): Make sure this.load waits for modules that are already loading ( @lukastaegert) +- [#4298](https://github.com/rollup/rollup/pull/4298): use set for reserved words (@dnalborczyk) + +## 2.61.0 + +_2021-12-09_ + +### Features + +- Support ergonomic brand checks for private fields (#4293) + +### Bug Fixes + +- Improve handling of directory creation on systems with restrictive open files limit (#4288) + +### Pull Requests + +- [#4288](https://github.com/rollup/rollup/pull/4288): modifymkdirpath (@mgrabowski84) +- [#4293](https://github.com/rollup/rollup/pull/4293): bump deps (@dnalborczyk) + +## 2.60.2 + +_2021-11-30_ + +### Bug Fixes + +- Produce correct output when dynamic import paths contain quotes (#4286) + +### Pull Requests + +- [#4286](https://github.com/rollup/rollup/pull/4286): Escape dynamic import paths (@danielroe) + +## 2.60.1 + +_2021-11-22_ + +### Bug Fixes + +- Make sure virtual files have proper file extensions when preserving modules (#4270) + +### Pull Requests + +- [#4270](https://github.com/rollup/rollup/pull/4270): Use entryFileNames when generating filenames for virtual modules (@BPScott) + +## 2.60.0 + +_2021-11-11_ + +### Features + +- Add `this.load` context function to load, transform and parse modules without adding them to the graph (#4234) +- Sanitize non-url-safe characters in generated chunk names by default (#4262) +- Support ESM plugins via command line (#4265) + +### Pull Requests + +- [#4234](https://github.com/rollup/rollup/pull/4234): Plugin context function for pre-loading modules (@lukastaegert) +- [#4262](https://github.com/rollup/rollup/pull/4262): exclude invalid URL chars (@danielroe) +- [#4265](https://github.com/rollup/rollup/pull/4265): support loading ESM plugins from the CLI via --plugin (@kzc) + +## 2.59.0 + +_2021-11-01_ + +### Features + +- Support static class initialization blocks (#4249) + +### Bug Fixes + +- Fix an issue with the CommonJS plugin when module.exports has inherited properties (#4256) + +### Pull Requests + +- [#4236](https://github.com/rollup/rollup/pull/4236): typescript bug class field initialization order (@dnalborczyk) +- [#4249](https://github.com/rollup/rollup/pull/4249): Support for class static initialization block (@dnalborczyk and @lukastaegert) +- [#4256](https://github.com/rollup/rollup/pull/4256): Skip inherited properties in synthetic namespaces (@lukastaegert) + +## 2.58.3 + +_2021-10-25_ + +### Bug Fixes + +- Republish 2.58.1 with npm 6 as files were missing + +## 2.58.2 + +_2021-10-25_ + +### Bug Fixes + +- Republish 2.58.1 as files were missing + +## 2.58.1 + +_2021-10-25_ + +### Bug Fixes + +- Fix an issue with the CommonJS plugin when module.exports is falsy (#4247) + +### Pull Requests + +- [#4247](https://github.com/rollup/rollup/pull/4247): Handle falsy synthetic namespaces (@lukastaegert) + +## 2.58.0 + +_2021-10-01_ + +### Features + +- Add a flag to more reliably identify entry points in the `resolveId` hook (#4230) + +### Pull Requests + +- [#4230](https://github.com/rollup/rollup/pull/4230): Add isEntry flag to resolveId and this.resolve (@lukastaegert) +- [#4233](https://github.com/rollup/rollup/pull/4233): Remove unused rollup-plugin-typescript ambient module types ( @dnalborczyk) +- [#4235](https://github.com/rollup/rollup/pull/4235): Update dependencies (@lukastaegert) + +## 2.57.0 + +_2021-09-22_ + +### Features + +- Add `generatedCode` option to allow Rollup to use es2015 features for smaller output and more efficient helpers ( #4215) +- Improve AMD and SystemJS parsing performance by wrapping relevant functions in parentheses (#4215) +- Using `preferConst` will now show a warning with `strictDeprecations: true` (#4215) + +### Bug Fixes + +- Improve ES3 syntax compatibility by more consequently quoting reserved words as props in generated code (#4215) +- Do not use `Object.assign` in generated code to ensure ES5 compatibility without the need for polyfills (#4215) +- Support live-bindings in dynamic namespace objects that contain reexported external or synthetic namespaces (#4215) +- Use correct "this" binding in dynamic import expressions for CommonJS and AMD (#4215) +- Properly handle `shimMissingExports` for exports that are only used internally (#4215) +- Prevent unhandled rejection for failed module parsing (#4228) + +### Pull Requests + +- [#4212](https://github.com/rollup/rollup/pull/4212): chore: remove unused ambient types (@dnalborczyk) +- [#4215](https://github.com/rollup/rollup/pull/4215): Use ES2015 features in generated code snippets (@lukastaegert) +- [#4219](https://github.com/rollup/rollup/pull/4219): chore: bump rollup typescript, remove unused micromatch ( @dnalborczyk) +- [#4220](https://github.com/rollup/rollup/pull/4220): chore: use forceConsistentCasingInFileNames in ts-config ( @dnalborczyk) +- [#4224](https://github.com/rollup/rollup/pull/4224): prepare for useDefineForClassFields (@dnalborczyk) +- [#4228](https://github.com/rollup/rollup/pull/4228): fix: prevent UnhandledPromiseRejectionWarning when module resolution/parsing fails (@kherock) + +## 2.56.3 + +_2021-08-23_ + +### Bug Fixes + +- Make sure moduleInfo contains complete information about imported ids in the moduleParsed hook (#4208) + +### Pull Requests + +- [#4208](https://github.com/rollup/rollup/pull/4208): `ModuleInfo.importedIds` will return null if `resolvedIds[source]` is undefined (@FoxDaxian and @lukastaegert) + +## 2.56.2 + +_2021-08-10_ + +### Bug Fixes + +- Check if after simplification, an object pattern would become an expression statement or arrow function return value ( #4204) + +### Pull Requests + +- [#4204](https://github.com/rollup/rollup/pull/4204): Do not create invalid code when simplifying object pattern assignments (@lukastaegert) + +## 2.56.1 + +_2021-08-08_ + +### Bug Fixes + +- Fix rendering of SystemJS export declarations initialized with a simplifiable expression (#4202) + +### Pull Requests + +- [#4202](https://github.com/rollup/rollup/pull/4202): Fix incorrect rendering of export declarations in SystemJS ( @lukastaegert) + +## 2.56.0 + +_2021-08-05_ + +### Features + +- Create more efficient code for SystemJS exports (#4199) +- Extend `maxParallelFileReads` option to also throttle plugin load hooks (#4200) + +### Bug Fixes + +- Return correct value for postfix update expressions of exported variables (#4194) + +### Pull Requests + +- [#4199](https://github.com/rollup/rollup/pull/4199): Refine SystemJS export rendering (@lukastaegert) +- [#4200](https://github.com/rollup/rollup/pull/4200): Restrict parallel execution of load hook (@schummar) + +## 2.55.1 + +_2021-07-29_ + +### Bug Fixes + +- Improve CLI warning message for unused external imports (#4194) + +### Pull Requests + +- [#4194](https://github.com/rollup/rollup/pull/4194): Align batch warning for UNUSED_EXTERNAL_IMPORT to individual warning (@benmccann) + +## 2.55.0 + +_2021-07-28_ + +### Features + +- Support default export live-bindings when generating ESM output (#4182) + +### Bug Fixes + +- Always write `["default"]` as computed property when used as named export (#4182) +- Do not mask default export TDZ errors (#4182) + +### Pull Requests + +- [#4182](https://github.com/rollup/rollup/pull/4182): Use mutable bindings for default exports (@lukastaegert) + +## 2.54.0 + +_2021-07-25_ + +### Features + +- Extend UMD import.meta.url polyfill to support web workers (#4186) + +### Bug Fixes + +- Resolve an issue where certain uses of classes could lead to an infinite recursion (#4189) + +### Pull Requests + +- [#4186](https://github.com/rollup/rollup/pull/4186): Fix UMD import.meta.url inside web workers (@ceifa) +- [#4188](https://github.com/rollup/rollup/pull/4188): Fix typo in renderHelpers.ts (@eltociear) +- [#4189](https://github.com/rollup/rollup/pull/4189): Move long path recursion prevention to MemberExpression ( @lukastaegert) +- [#4190](https://github.com/rollup/rollup/pull/4190): Stop recommending node-builtins (@curran) + +## 2.53.3 + +_2021-07-21_ + +### Bug Fixes + +- Solve an issue that could lead to severe memory issues and crashes when there are a lot of hoisted variables (#4183) + +### Pull Requests + +- [#4183](https://github.com/rollup/rollup/pull/4183): Avoid memory issues with hoisted variables (@lukastaegert) + +## 2.53.2 + +_2021-07-15_ + +### Bug Fixes + +- Identify additional TDZ situations in functions that are run more than once (#4177) +- Fix a scoping issue when a variable inside a catch scope matches the scope parameter's name (#4178) + +### Pull Requests + +- [#4177](https://github.com/rollup/rollup/pull/4177): Fix additional let/var init bugs (@kzc) +- [#4178](https://github.com/rollup/rollup/pull/4178): Correctly create outside variable when shadowed by catch parameter (@lukastaegert) + +## 2.53.1 + +_2021-07-11_ + +### Bug Fixes + +- Do not omit namespace reexports when `treeshake` is `false` (#4175) + +### Pull Requests + +- [#4175](https://github.com/rollup/rollup/pull/4175): Generate namespace objects when not tree-shaking (@lukastaegert) + +## 2.53.0 + +_2021-07-09_ + +### Features + +- Add `maxParallelFileReads` option to limit read operations with a default of 20 (#4170) + +### Pull Requests + +- [#4170](https://github.com/rollup/rollup/pull/4170): Limit parallel file reads to prevent "EMFILE: too many open files" error (@schummar) + +## 2.52.8 + +_2021-07-07_ + +### Bug Fixes + +- Automatically handle many use `var` before declaration and TDZ access scenarios correctly without the need for `treeshake.correctVarValueBeforeDeclaration` (#4148) + +### Pull Requests + +- [#4148](https://github.com/rollup/rollup/pull/4148): Fix var/const/let variable use before declaration (@kzc and @lukastaegert) + +## 2.52.7 + +_2021-07-02_ + +### Bug Fixes + +- Fix an issue where reassignments where not tracked through async function returns (#4163) + +### Pull Requests + +- [#4163](https://github.com/rollup/rollup/pull/4163): Deoptimize return values of async functions (@lukastaegert) + +## 2.52.6 + +_2021-07-01_ + +### Bug Fixes + +- Fix an issue where reassignments where not tracked through an await expression (#4162) + +### Pull Requests + +- [#4162](https://github.com/rollup/rollup/pull/4162): doptimize awaited expressions (@lukastaegert) + +## 2.52.5 + +_2021-07-01_ + +### Bug Fixes + +- Properly display parser errors not tied to a code location (#4160) + +### Pull Requests + +- [#4160](https://github.com/rollup/rollup/pull/4160): fix: max stack call error is caught on locate (@semoal) + +## 2.52.4 + +_2021-06-30_ + +### Bug Fixes + +- Fix an error when external namespaces are reexported across several files (#4159) + +### Pull Requests + +- [#4159](https://github.com/rollup/rollup/pull/4159): Properly handle double reexports from external namespaces ( @lukastaegert) + +## 2.52.3 + +_2021-06-25_ + +### Bug Fixes + +- Fix an issue where code was wrongly removed when using vars in nested scopes (#4149) + +### Pull Requests + +- [#4149](https://github.com/rollup/rollup/pull/4149): Make sure the initializer of hoisted variables is deoptimized ( @lukastaegert) + +## 2.52.2 + +_2021-06-21_ + +### Bug Fixes + +- Support falsy plugins in types (#4144) +- Do not require return value in renderChunkHook type (#4144) + +### Pull Requests + +- [#4144](https://github.com/rollup/rollup/pull/4144): Use TypeScript config and improve some types (@lukastaegert) + +## 2.52.1 + +_2021-06-17_ + +### Bug Fixes + +- Fix a memory leak in watch mode (#4142) + +### Pull Requests + +- [#4142](https://github.com/rollup/rollup/pull/4142): Make array and object prototype singletons immutable for now ( @lukastaegert) + +## 2.52.0 + +_2021-06-16_ + +### Features + +- Add `--configPlugin` CLI option to apply plugins to the config file for e.g. TypeScript configs (#3835) +- Add "safest" and "smallest" presets to tree-shaking options for easier configuration (#4131) +- Add `treeshake.correctVarValueBeforeDeclaration` option to deoptimize `var` declarations (#4139) + +### Pull Requests + +- [#3835](https://github.com/rollup/rollup/pull/3835): Add typescript config support (@TheRealSyler) +- [#4131](https://github.com/rollup/rollup/pull/4131): Add presets to the tree-shaking options (@lukastaegert) +- [#4139](https://github.com/rollup/rollup/pull/4139): Add option to deoptimize var declarations for tree-shaking ( @lukastaegert) +- [#4141](https://github.com/rollup/rollup/pull/4141): Update dependencies (@lukastaegert) + +## 2.51.2 + +_2021-06-11_ + +### Bug Fixes + +- Include modules imported from no-treeshake modules even if they would be empty (#4138) + +### Pull Requests + +- [#4138](https://github.com/rollup/rollup/pull/4138): Include all dependencies from modules with no-treeshake ( @lukastaegert) + +## 2.51.1 + +_2021-06-08_ + +### Bug Fixes + +- Fix error when using `defineConfig` (#4134) + +### Pull Requests + +- [#4134](https://github.com/rollup/rollup/pull/4134): export `rollup.defineConfig` at runtime (@mshrtsr) + +## 2.51.0 + +_2021-06-06_ + +### Features + +- Add a helper for IntelliSense support in config files (#4127) + +### Bug Fixes + +- Improve performance when generating source maps (#4122) + +### Pull Requests + +- [#4122](https://github.com/rollup/rollup/pull/4122): User Map to optimize performance (@izevo) +- [#4127](https://github.com/rollup/rollup/pull/4127): Export defineConfig defines the auxiliary function of the configuration (@rxliuli) + +## 2.50.6 + +_2021-06-03_ + +### Bug Fixes + +- Do not consider the object spread operator as side effect when `propertyReadSideEffects` are false (#4119) +- Detect side effects when returning thenables from async arrow functions (#4120) + +### Pull Requests + +- [#4119](https://github.com/rollup/rollup/pull/4119): Respect propertyReadSideEffects in spread elements ( @lukastaegert) +- [#4120](https://github.com/rollup/rollup/pull/4120): Detect async arrow thenable side effects (@lukastaegert) + +## 2.50.5 + +_2021-05-30_ + +### Bug Fixes + +- Detect side effects when accessing thenables (#4115) + +### Pull Requests + +- [#4114](https://github.com/rollup/rollup/pull/4114): use `colorette` instead of `turbocolor` (@ryuever) +- [#4115](https://github.com/rollup/rollup/pull/4115): Tracks side effects of thenables (@lukastaegert) + +## 2.50.4 + +_2021-05-29_ + +### Bug Fixes + +- Fix a situation where tree-shaking would stop including nodes prematurely (#4111) +- Track mutations and accessor side effects when using `__proto__` in an object literal (#4112) +- Check for getter effects when spreading an object (#4113) + +### Pull Requests + +- [#4111](https://github.com/rollup/rollup/pull/4111): Always request a new tree-shaking pass when deoptimizations of a node are first included (@lukastaegert) +- [#4112](https://github.com/rollup/rollup/pull/4112): Actually set the prototype when using a **proto** property ( @lukastaegert) +- [#4113](https://github.com/rollup/rollup/pull/4113): Track access side effects when using object spread operator ( @lukastaegert) + +## 2.50.3 + +_2021-05-28_ + +### Bug Fixes + +- Wrap parentheses around leading elements in simplified sequence expressions if this would otherwise lead to invalid code (#4110) +- Do not associate block soped variables in catch clauses with the clause parameter (#4108) +- Do not associate hoisted variables in catch clauses with outside variables if they match the parameter (#4108) +- Use correct "this" context for tagged template literal member expressions in simplified sequences (#4110) + +### Pull Requests + +- [#4108](https://github.com/rollup/rollup/pull/4108): Correctly handle catch declarations (@lukastaegert) +- [#4110](https://github.com/rollup/rollup/pull/4110): Invalid sequence expression simplification (@lukastaegert) + +## 2.50.2 + +_2021-05-27_ + +### Bug Fixes + +- Avoid unnecessary side effects when using methods like `.filter` and `.map` (#4103) +- Avoid crash when a module with moduleSideEffects no-treeshake imports a tree-shaken module (#4104) + +### Pull Requests + +- [#4103](https://github.com/rollup/rollup/pull/4103): Do not track side-effect-free array methods as side effects ( @lukastaegert) +- [#4104](https://github.com/rollup/rollup/pull/4104): Fix crash when using inlineDynamicImports with no-treeshake ( @lukastaegert) + +## 2.50.1 + +_2021-05-26_ + +### Bug Fixes + +- Do not associate pure annotations in simplified expressions with wrong elements (#4095) +- Prevent invalid code when simplified conditionals start with an IIFE function expression (#4099) + +### Pull Requests + +- [#4095](https://github.com/rollup/rollup/pull/4095): Correctly associate pure annotations and remove invalid ones ( @lukastaegert) +- [#4099](https://github.com/rollup/rollup/pull/4099): Wrap leading function expression iifes in conditionals ( @lukastaegert) + +## 2.50.0 + +_2021-05-25_ + +### Features + +- Only include last elements of comma expressions if they are used or have side effects (#4087) + +### Bug Fixes + +- Prevent a crash that could occur when calling object methods (#4091) + +### Pull Requests + +- [#4085](https://github.com/rollup/rollup/pull/4085): Switch to ESLint (@lukastaegert) +- [#4087](https://github.com/rollup/rollup/pull/4087): Drop unused last sequence element (@lukastaegert) +- [#4091](https://github.com/rollup/rollup/pull/4091): Prevent crash for recursive "this" deoptimization (@lukastaegert) + +## 2.49.0 + +_2021-05-23_ + +### Features + +- Detect side-effect-free static class methods and properties (#4018) +- Detect side-effect-free array elements (#4018) +- Do not apply deoptimizations from dead code (#4018) + +### Bug Fixes + +- Handle side effect detection for getters and setters added in untracked code (#4018) +- Track "this" mutations for methods, getters and setters (#4018) + +### Pull Requests + +- [#4018](https://github.com/rollup/rollup/pull/4018): Class method effects (@marijnh and @lukastaegert) + +## 2.48.0 + +_2021-05-15_ + +### Features + +- Add replacement to conditionally insert asset extensions in `entryFileNames` when preserving modules (#4077) + +### Bug Fixes + +- Fix crash when dynamically assigning to namespace members (#4070) +- Do not associate pure annotations in front of a semi-colon or comma with succeeding code (#4068) + +### Pull Requests + +- [#4068](https://github.com/rollup/rollup/pull/4068): ignore invalid trailing pure annotations (@kzc) +- [#4070](https://github.com/rollup/rollup/pull/4070): undefined `deoptimizePath` when the first element is empty string (@si3nloong) +- [#4071](https://github.com/rollup/rollup/pull/4071): add node.js v16 support (@dnalborczyk) +- [#4077](https://github.com/rollup/rollup/pull/4077): Add assetExtname replacement in entryFileNames (@BPScott) +- [#4080](https://github.com/rollup/rollup/pull/4080): Added Rollup logo in README.md (@priyanshurav) +- [#4081](https://github.com/rollup/rollup/pull/4081): fix comment regarding invalid annotation handling (@kzc) + +## 2.47.0 + +_2021-05-04_ + +### Features + +- Warn about ambiguous imports from combined external namespace reexports (#4064) +- In case of combined namespace reexports, always prefer local exports over external namespaces (#4064) +- Treat conflicting names in local namespace reexports as undefined (#4064) + +### Pull Requests + +- [#4064](https://github.com/rollup/rollup/pull/4064): Prefer locally defined exports and reexports over external namespaces (@lukastaegert) + +## 2.46.0 + +_2021-04-29_ + +### Features + +- Add option to disable file name sanitation (#4058) +- Add information about importers to unused external import warning (#4054) + +### Pull Requests + +- [#4042](https://github.com/rollup/rollup/pull/4042): Use Github actions only (@lukastaegert) +- [#4045](https://github.com/rollup/rollup/pull/4045): Fix REPL artefact branch reference (@lukastaegert) +- [#4046](https://github.com/rollup/rollup/pull/4046): Use codecov action for coverage (@lukastaegert) +- [#4054](https://github.com/rollup/rollup/pull/4054): Add to `UNUSED_EXTERNAL_IMPORT` warning information about the origin of the problem (@cawa-93) +- [#4058](https://github.com/rollup/rollup/pull/4058): Add sanitizeFileName option (@guybedford) + +## 2.45.2 + +_2021-04-13_ + +### Bug Fixes + +- Do not user a dynamic entry file name for naming a manual chunk (#4040) + +### Pull Requests + +- [#4040](https://github.com/rollup/rollup/pull/4040): Prioritize manual chunk name over dynamic entry id ( @lukastaegert) + +## 2.45.1 + +_2021-04-10_ + +### Bug Fixes + +- Handle falsy return values from async plugin options hooks (#4039) + +### Pull Requests + +- [#4039](https://github.com/rollup/rollup/pull/4039): Do not fail when returning null or undefined from an async options hook (@lukastaegert) + +## 2.45.0 + +_2021-04-09_ + +### Features + +- Support private class instance methods and accessors (#4034) + +### Pull Requests + +- [#4034](https://github.com/rollup/rollup/pull/4034): feat: add support for private class methods (@dnalborczyk) + +## 2.44.0 + +_2021-03-29_ + +### Features + +- Add a new option `makeAbsoluteExternalsRelative` to opt out of renormalizing absolute external ids to relative ids ( #4021) +- Extend the `resolveId` plugin hook to allow forcing or preventing renormalization of absolute external ids (#4021) +- Make the rendered code of individual modules available in the generated bundle (#4028) + +### Bug Fixes + +- Handle objects with `__proto__` properties correctly (#4019) + +### Pull Requests + +- [#4019](https://github.com/rollup/rollup/pull/4019): Deoptimize ObjectExpression when a `__proto__` property is present (@marijnh) +- [#4021](https://github.com/rollup/rollup/pull/4021): Improve absolute path handling (@lukastaegert) +- [#4026](https://github.com/rollup/rollup/pull/4026): chore: fix vscode launch config (change tdd to bdd) (@jameslahm) +- [#4027](https://github.com/rollup/rollup/pull/4027): Post comment for PRs from forks (@lukastaegert) +- [#4028](https://github.com/rollup/rollup/pull/4028): Expose rendered module code to generateBundle hook (@btd) + +## 2.43.1 + +_2021-03-28_ + +### Bug Fixes + +- Prevent infinite recursions in certain scenarios when calling object properties (#4025) + +### Pull Requests + +- [#4025](https://github.com/rollup/rollup/pull/4025): Handle recursive this mutation detection (@lukastaegert) + +## 2.43.0 + +_2021-03-27_ + +### Features + +- Track side effects of function properties in objects for better tree-shaking (#4011) + +### Pull Requests + +- [#4011](https://github.com/rollup/rollup/pull/4011): Disable pessimistic object deoptimization for calls when the called function doesn't ref this (@marijnh) +- [#4012](https://github.com/rollup/rollup/pull/4012): fix `sourcemap` reference in docs (@tjenkinson) +- [#4015](https://github.com/rollup/rollup/pull/4015): Use SIGTERM instead of SIGINT to kill test child processes in tests (@marijnh) + +## 2.42.4 + +_2021-03-24_ + +### Bug Fixes + +- Do not discard plugin return values when using perf option (#4010) + +### Pull Requests + +- [#4010](https://github.com/rollup/rollup/pull/4010): Return hook result inside promise with async timer end ( @SuperOleg39) + +## 2.42.3 + +_2021-03-22_ + +### Bug Fixes + +- Do not ignore `#__PURE__` comments in front of optional chaining expressions (#4007) + +### Pull Requests + +- [#4007](https://github.com/rollup/rollup/pull/4007): Tree-shake pure call expressions with optional chaining ( @lukastaegert) + +## 2.42.2 + +_2021-03-22_ + +### Bug Fixes + +- Use correct import.meta.url in relative imports from transpiled config files (#4005) + +### Pull Requests + +- [#4005](https://github.com/rollup/rollup/pull/4005): Use correct import.meta.url in config files (@lukastaegert) + +## 2.42.1 + +_2021-03-20_ + +### Bug Fixes + +- Do not produce unhandled Promise rejections when plugins throw while using the `perf` option (#4004) + +### Pull Requests + +- [#4004](https://github.com/rollup/rollup/pull/4004): Fixed unhandled promise rejections (@gluck) + +## 2.42.0 + +_2021-03-19_ + +### Features + +- Prevent infinite loops when several plugins are using `this.resolve` in their resolveId hook (#4000) + +### Pull Requests + +- [#4000](https://github.com/rollup/rollup/pull/4000): Break infinite loops in this.resolve (@lukastaegert) + +## 2.41.5 + +_2021-03-18_ + +### Bug Fixes + +- Make sure unused property accesses of external namespaces can be tree-shaken (#4001) + +### Pull Requests + +- [#4001](https://github.com/rollup/rollup/pull/4001): Do not count accessing members of an external namespace as side-effects (@lukastaegert) + +## 2.41.4 + +_2021-03-16_ + +### Bug Fixes + +- Do not replace external namespace imports with individual named imports to avoid changing behaviour with regard to missing exports (#3999) + +### Pull Requests + +- [#3999](https://github.com/rollup/rollup/pull/3999): Allow to safely probe external namespaces (@lukastaegert) + +## 2.41.3 + +_2021-03-16_ + +### Bug Fixes + +- Always retain arguments passed to empty object pattern parameters (#3998) + +### Pull Requests + +- [#3998](https://github.com/rollup/rollup/pull/3998): Do not create invalid code if a function argument is an empty object pattern (@lukastaegert) + +## 2.41.3 + +_2021-03-16_ + +### Bug Fixes + +- Always retain arguments passed to empty object pattern parameters (#3998) + +### Pull Requests + +- [#3998](https://github.com/rollup/rollup/pull/3998): Do not create invalid code if a function argument is an empty object pattern (@lukastaegert) + +## 2.41.2 + +_2021-03-12_ + +### Bug Fixes + +- Also remove sourcemaps comments if plugins return a pre-made ast (#3987) + +### Pull Requests + +- [#3987](https://github.com/rollup/rollup/pull/3987): Change removal of sourcemap comment (@yannayl) + +## 2.41.1 + +_2021-03-11_ + +### Pull Requests + +- [#3990](https://github.com/rollup/rollup/pull/3990): Add browser sourcemap and remove log (@lukastaegert) + +## 2.41.0 + +_2021-03-09_ + +### Features + +- Add option to `treeshake.propertyReadSideEffects` to keep all property accesses (#3985) + +### Bug Fixes + +- Also respect pure comment annotations when a plugin provides an AST in the transform hook provided they use this.parse (#3981) + +### Pull Requests + +- [#3981](https://github.com/rollup/rollup/pull/3981): Move pure comment annotation to Graph.contextParse (@yannayl) +- [#3985](https://github.com/rollup/rollup/pull/3985): implement --treeshake.propertyReadSideEffects=always to handle getters with side effects (@kzc) + +## 2.40.0 + +_2021-02-26_ + +### Features + +- Make sure that entry point variable names take precedence over variable names in dependencies when deconflicting ( #3977) + +### Bug Fixes + +- Replace `:` in generated file names to prevent invalid files on Windows (#3972) + +### Pull Requests + +- [#3972](https://github.com/rollup/rollup/pull/3972): Don't allow `:` in file names (@lukastaegert) +- [#3976](https://github.com/rollup/rollup/pull/3976): Add soft breaks to guide to improve mobile experience ( @lukastaegert) +- [#3977](https://github.com/rollup/rollup/pull/3977): Reverse module deconflicting order (@lukastaegert) + +## 2.39.1 + +_2021-02-23_ + +### Bug Fixes + +- Make sure local variables named Symbol, Object or Promise do not conflict with code generated by Rollup (#3971) + +### Pull Requests + +- [#3964](https://github.com/rollup/rollup/pull/3964): Remove extra word (@jamonholmgren) +- [#3971](https://github.com/rollup/rollup/pull/3971): Avoid conflicts with local variables named Symbol, Object, Promise (@lukastaegert) + +## 2.39.0 + +_2021-02-12_ + +### Features + +- Add "validate" option to verify generated chunks are valid JavaScript (#3952) + +### Bug Fixes + +- Always add exports properties for uninitialized named exports (#3957) +- Allow using an external namespace reexport together with named exports (#3959) +- Avoid invalid generated code in certain scenarios with SystemJS exports (#3960) + +### Pull Requests + +- [#3952](https://github.com/rollup/rollup/pull/3952): implement `validate` output option and `--validate` CLI option ( @kzc) +- [#3956](https://github.com/rollup/rollup/pull/3956): Update dependencies, fix fsevents issue (@lukastaegert) +- [#3957](https://github.com/rollup/rollup/pull/3957): Make sure uninitialised exports turn up via .hasOwnProperty for non-ES formats (@lukastaegert) +- [#3959](https://github.com/rollup/rollup/pull/3959): Allow overriding individual exports of reexported external namespaces (@lukastaegert) +- [#3960](https://github.com/rollup/rollup/pull/3960): Make sure system exports are valid JavaScript (@lukastaegert) + +## 2.38.5 + +_2021-02-05_ + +### Bug Fixes + +- Prevent invalid code when simplifying assignments and delcarations (#3951) +- Prevent behaviour-changing line-breaks when simplifying assignments in return statements (#3951) +- Slightly improve white-space rendering when simplifying certain expressions (#3951) + +### Pull Requests + +- [#3951](https://github.com/rollup/rollup/pull/3951): Wrap simplified assignments if necessary (@lukastaegert) + +## 2.38.4 + +_2021-02-02_ + +### Bug Fixes + +- Do not change logic when tree-shaking declarations in if statements or loops (#3947) + +### Pull Requests + +- [#3947](https://github.com/rollup/rollup/pull/3947): Do not tear apart declarations in loop or if bodies ( @lukastaegert) + +## 2.38.3 + +_2021-02-01_ + +### Bug Fixes + +- Prevent an unexpected live-binding when default exporting a synthetic named export (#3946) + +### Pull Requests + +- [#3945](https://github.com/rollup/rollup/pull/3945): Upgrade chokidar and fsevents for Apple M1 compatibility ( @threepointone) +- [#3946](https://github.com/rollup/rollup/pull/3946): Make sure default exports snapshot synthetic named exports ( @lukastaegert) + +## 2.38.2 + +_2021-01-31_ + +### Bug Fixes + +- Do not generate invalid code for partially tree-shaken declarations in for loops (#3943) +- Always include function bodies of functions in side-effect-free modules (#3944) + +### Pull Requests + +- [#3943](https://github.com/rollup/rollup/pull/3943): Do not partially tree-shake unused declarations in for loops ( @lukastaegert) +- [#3944](https://github.com/rollup/rollup/pull/3944): Correctly include functions with side effects from side-effect-free modules (@lukastaegert) + +## 2.38.1 + +_2021-01-28_ + +### Bug Fixes + +- Fix internal error when resolving a missing entry point in the browser build (#3935) + +### Pull Requests + +- [#3935](https://github.com/rollup/rollup/pull/3935): fix: remove isolated resolve() for compat with browser distribution (@cmorten and @lukastaegert) +- [#3936](https://github.com/rollup/rollup/pull/3936): Ensure test after() callback is always executed ( @Benjamin-Dobell) +- [#3937](https://github.com/rollup/rollup/pull/3937): Modernize references to other software (@ludofischer) + +## 2.38.0 + +_2021-01-22_ + +### Features + +- Entirely remove declared variables that only have an initializer side effect (#3933) + +### Pull Requests + +- [#3933](https://github.com/rollup/rollup/pull/3933): Tree-shake unused declarations while keeping initializer side-effects (@lukastaegert) + +## 2.37.1 + +_2021-01-20_ + +### Pull Requests + +- [#3929](https://github.com/rollup/rollup/pull/3929): Deduplicate acorn import (@lukastaegert) + +## 2.37.0 + +_2021-01-19_ + +### Features + +- Always check modules for side effects that only indirectly reexport a used variable (#3840) +- Warn if a circular dependency would cause wrong execution order when preserving modules (#3840) + +### Bug Fixes + +- Allow consuming synthetic exports via modules that reexport a namespace (#3894) +- Do not crash for circular default reexports (#3840) +- Do not crash for circular synthetic namespaces (#3840) +- Improve circular dependency execution order in certain scenarios (#3840) + +### Pull Requests + +- [#3840](https://github.com/rollup/rollup/pull/3840): Improve circular dependency execution order (@lukastaegert) +- [#3894](https://github.com/rollup/rollup/pull/3894): Always respect synthetic namespaces in namespace reexport ( @lukastaegert) + +## 2.36.2 + +_2021-01-16_ + +### Bug Fixes + +- Fix an issue where invalid code was generated for unused assignments with side effects (#3926) + +### Pull Requests + +- [#3926](https://github.com/rollup/rollup/pull/3926): Correctly simplify assignments with parentheses (@lukastaegert) + +## 2.36.1 + +_2021-01-06_ + +### Bug Fixes + +- Solve issues that result in invalid code when partially removing assignments (#3921) + +### Pull Requests + +- [#3921](https://github.com/rollup/rollup/pull/3921): Prevent invalid code when removing assignment target of side-effectful object expression (@lukastaegert) + +## 2.36.0 + +_2021-01-05_ + +### Features + +- Support partial tree-shaking of chained assignments and unused assignment targets (#3919) + +### Pull Requests + +- [#3919](https://github.com/rollup/rollup/pull/3919): Treeshake chained assignment expressions (@lukastaegert) + +## 2.35.1 + +_2020-12-14_ + +### Bug Fixes + +- Allow closing the bundle when watching in case of generate errors by adding the bundle to the error event (#3909) +- Automatically close all bundles on generate errors when watching and using the CLI (#3909) +- Try to create remaining bundles when watching and one of them throws (#3909) + +### Pull Requests + +- [#3909](https://github.com/rollup/rollup/pull/3909): Forward bundle through watch error events (@lukastaegert) + +## 2.35.0 + +_2020-12-14_ + +### Features + +- Add `closeBundle` hook that is triggered by `bundle.close()` in the JS API (#3883) + +### Pull Requests + +- [#3883](https://github.com/rollup/rollup/pull/3883): Revert pattern to folder export (@intrnl) + +## 2.34.2 + +_2020-12-06_ + +### Bug Fixes + +- Revert pattern export change (#3898) + +### Pull Requests + +- [#3898](https://github.com/rollup/rollup/pull/3898): Revert pattern to folder export (@lukastaegert) + +## 2.34.1 + +_2020-12-03_ + +### Bug Fixes + +- Avoid Node deprecation warning by using a pattern export for nested Rollup files (#3896) + +### Pull Requests + +- [#3887](https://github.com/rollup/rollup/pull/3887): Run memory leak test on all systems (@lukastaegert) +- [#3892](https://github.com/rollup/rollup/pull/3892): Add pull_request to windows github actions (@shellscape) +- [#3893](https://github.com/rollup/rollup/pull/3893): Update dependencies (@lukastaegert) +- [#3896](https://github.com/rollup/rollup/pull/3896): Replace deprecated folder package export with pattern export ( @lukastaegert) + +## 2.34.0 + +_2020-11-29_ + +### Features + +- Support RequireJS comaptible AMD ids in code-splitting builds via amd.autoId (#3867) +- Allow adding an AMD id base path (#3867) + +### Bug Fixes + +- Warn when using an constant AMD id in a code-splitting build (#3867) + +### Pull Requests + +- [#3867](https://github.com/rollup/rollup/pull/3867): Implement amd.autoId/amd.basePath options (@tjenkinson) + +## 2.33.3 + +_2020-11-18_ + +### Bug Fixes + +- Do not use `.js` extension when importing AMD files from a UMD bundle (#3872) + +### Pull Requests + +- [#3861](https://github.com/rollup/rollup/pull/3861): Update chat/support links (@shellscape) +- [#3872](https://github.com/rollup/rollup/pull/3872): Also removeExtensionFromRelativeAmdId in UMD finaliser ( @tjenkinson) + +## 2.33.2 + +_2020-11-14_ + +### Bug Fixes + +- Fix an issue where statements were ignored after a conditional return in a labeled statement (#3871) + +### Pull Requests + +- [#3871](https://github.com/rollup/rollup/pull/3871): Correctly track label usage in try statements (@Amareis) + +## 2.33.1 + +_2020-11-02_ + +### Bug Fixes + +- Add `syntheticNamedExports` to `this.getModuleInfo` to align with documentation (#3847) + +### Pull Requests + +- [#3847](https://github.com/rollup/rollup/pull/3847): Expose syntheticNamedExports to ModuleInfo (@Amareis) +- [#3852](https://github.com/rollup/rollup/pull/3852): Fix typo on docs (@jpsc) + +## 2.33.0 + +_2020-11-01_ + +### Features + +- Add parameter to "watchChange" hook to denote if a change was an addition, update or deletion (#3841) +- Add "closeWatcher" hook to allow plugins to clean up resources when the watcher is closed (#3841) +- Add "this.getWatchFiles" function to plugin context to get the current set of watched files (#3841) + +### Pull Requests + +- [#3841](https://github.com/rollup/rollup/pull/3841): Improved watcher hooks (@Amareis) +- [#3848](https://github.com/rollup/rollup/pull/3848): Add options hook to asyncpluginhooks (@intrnl) + +## 2.32.1 + +_2020-10-21_ + +### Bug Fixes + +- Print warning location for plugin warnings if only `loc` is supplied (#3824) + +### Pull Requests + +- [#3824](https://github.com/rollup/rollup/pull/3824): plugin warnings not showing warning.loc (@luciotato) + +## 2.32.0 + +_2020-10-16_ + +### Features + +- Extend `preserveEntrySignatures` with a value `"exports-only"` to allow extension only if an entry does not have exports (#3823) + +### Pull Requests + +- [#3823](https://github.com/rollup/rollup/pull/3823): Add "exports-only" option to preserveSignature (@lukastaegert) + +## 2.31.0 + +_2020-10-15_ + +### Features + +- When using the `output.moduleToStringTag` option, also add the tag to entries with exports and simulated external namespaces (#3822) +- Add the `__esModule` interop marker to IIFE global variables unless `output.esModule` is turned off (#3822) + +### Pull Requests + +- [#3822](https://github.com/rollup/rollup/pull/3822): Add module toStringTag to entries and interop namespaces ( @lukastaegert) + +## 2.30.0 + +_2020-10-13_ + +### Features + +- Add `moduleParsed` hook that is called for each module once code and AST are available (#3813) +- Include code and AST in `this.getModuleInfo` (#3813) + +### Bug Fixes + +- Provide the original Acorn AST instead of the internal one when resolving dynamic imports that contain non-trivial expressions (#3813) + +### Pull Requests + +- [#3813](https://github.com/rollup/rollup/pull/3813): Add moduleParsed plugin hook (@lukastaegert) +- [#3815](https://github.com/rollup/rollup/pull/3815): Docs: wile => while (@tjenkinson) +- [#3817](https://github.com/rollup/rollup/pull/3817): Docs: fix code snippet (@codefrau) +- [#3818](https://github.com/rollup/rollup/pull/3818): Update documentation on configuring Babel, removing the section on passing '{"modules": false}' as that is no longer needed since Babel 7 (@Robin-Hoodie) + +## 2.29.0 + +_2020-10-08_ + +### Features + +- Allow passing custom options to other plugins via `this.resolve` (#3807) +- Allow attaching custom meta information to modules when resolving, loading or transforming (#3807) +- Do not throw but return `null` when using `this.getModuleInfo` for an unknown id (#3807) + +### Bug Fixes + +- Trigger build in watch mode when files are added to a watched directory (#3812) +- Make `code` optional when transforming modules (#3807) + +### Pull Requests + +- [#3807](https://github.com/rollup/rollup/pull/3807): Implement new APIs for inter-plugin communication (@lukastaegert) +- [#3808](https://github.com/rollup/rollup/pull/3808): Document that the default value of --format is 'es' ( @jameshfisher) +- [#3812](https://github.com/rollup/rollup/pull/3812): Watch: listen for new files added to a directory (@dmitrage) + +## 2.28.2 + +_2020-09-24_ + +### Bug Fixes + +- Fix a source of possible variable name conflicts when using preserveModules with SystemJS (#3796) + +### Pull Requests + +- [#3792](https://github.com/rollup/rollup/pull/3792): add documentation for output.PreserveModulesRoot (@davidroeca) +- [#3796](https://github.com/rollup/rollup/pull/3796): Fix SystemJS default variable conflict (@lukastaegert) + +## 2.28.1 + +_2020-09-21_ + +### Bug Fixes + +- Fix a path slash issue when using the preserveModulesRoot option on Windows (#3791) + +### Pull Requests + +- [#3791](https://github.com/rollup/rollup/pull/3791): Fix preserveModulesRoot path on Windows (@lukastaegert) + +## 2.28.0 + +_2020-09-21_ + +### Features + +- Add an option to treat modules at a given path as located at root when preserving modules (#3786) + +### Pull Requests + +- [#3786](https://github.com/rollup/rollup/pull/3786): Add preserveModulesRoot config option (@davidroeca) + +## 2.27.1 + +_2020-09-17_ + +### Bug Fixes + +- Do not fail when using ES module imports in symlinked config files (#3783) + +### Pull Requests + +- [#3783](https://github.com/rollup/rollup/pull/3783): Handle loading symlinked config files (@lukastaegert) + +## 2.27.0 + +_2020-09-16_ + +### Features + +- Support specifying a file extension when reading from stdin (#3775) + +### Bug Fixes + +- Do not break logic if a branch with hoisted variables is tree-shaken in an else-if statement (#3782) + +### Pull Requests + +- [#3770](https://github.com/rollup/rollup/pull/3770): Docs: Exception for babel plugin and commonjs plugin (@jsk7) +- [#3775](https://github.com/rollup/rollup/pull/3775): add ability to specify stdin file extension via --stdin=ext ( @kzc) +- [#3782](https://github.com/rollup/rollup/pull/3782): Handle hoisted variables in dead branches of nested if statements (@lukastaegert) + +## 2.26.11 + +_2020-09-08_ + +### Bug Fixes + +- Do not fail for unknown nodes as if statement branches (#3769) + +### Pull Requests + +- [#3769](https://github.com/rollup/rollup/pull/3769): Handle debugger statements as if-statement branches ( @lukastaegert) + +## 2.26.10 + +_2020-09-04_ + +### Bug Fixes + +- Do not create invalid code when simplifying expressions in return statements that contain line comments (#3762) + +### Pull Requests + +- [#3757](https://github.com/rollup/rollup/pull/3757): Fix api docs loadconfigfile (@maxwell8888) +- [#3762](https://github.com/rollup/rollup/pull/3762): Handle line-comments when removing line-breaks to prevent ASI ( @lukastaegert) + +## 2.26.9 + +_2020-09-01_ + +### Bug Fixes + +- Add regular expression support to watch include/exclude types (#3754) + +### Pull Requests + +- [#3754](https://github.com/rollup/rollup/pull/3754): Add RegExp to the include and exclude fields of the WatcherOptions type (@dagda1) +- [#3756](https://github.com/rollup/rollup/pull/3756): Update FAQ: I think it was meant "external" instead of " other-entry.js" (@madacol) + +## 2.26.8 + +_2020-08-29_ + +### Bug Fixes + +- Make sure that both unresolved and resolved ids are passed to the `external` option in all cases (#3753) + +### Pull Requests + +- [#3753](https://github.com/rollup/rollup/pull/3753): Also pass resolved ids to external if they use the object for ( @lukastaegert) + +## 2.26.7 + +_2020-08-28_ + +### Bug Fixes + +- Avoid invalid code when rendering hoisted variable declarations from dead branches (#3752) +- Mark the `options` parameter of `this.parse` as optional for TypeScript plugins (#3750) + +### Pull Requests + +- [#3750](https://github.com/rollup/rollup/pull/3750): Make `options` of `PluginContext#parse` optional (@intrnl) +- [#3752](https://github.com/rollup/rollup/pull/3752): Extract hoisted variables from dead branches (@lukastaegert) + +## 2.26.6 + +_2020-08-27_ + +### Bug Fixes + +- Avoid conflicts between the namespace of synthetic named exports and local variables (#3747) + +### Pull Requests + +- [#3747](https://github.com/rollup/rollup/pull/3747): Properly deconflict synthetic named exports (@lukastaegert) + +## 2.26.5 + +_2020-08-22_ + +### Bug Fixes + +- Use correctly deconflicted variable names for reexported namespaces in ES formats (#3742) + +### Pull Requests + +- [#3742](https://github.com/rollup/rollup/pull/3742): Avoid variable name conflict when reexporting several namespaces from a chunk (@lukastaegert) + +## 2.26.4 + +_2020-08-19_ + +### Bug Fixes + +- Fix a situation where invalid code was rendered when dynamically importing a module with synthetic named exports when preserving modules (#3738) +- Create a proper namespace object when in a non-es format, a namespace is imported from a chunk with `default` export mode (#3738) +- Use the same variable when in a chunk, a namespace is both imported and reexported as a binding (#3738) +- Do not include the synthetic namespace in static entry points unless it is actually used (#3738) +- Make sure the chunking of one output does not interfere with the namespace objects of another output (#3738) + +### Pull Requests + +- [#3738](https://github.com/rollup/rollup/pull/3738): Improve synthetic entry handling (@lukastaegert) + +## 2.26.3 + +_2020-08-16_ + +### Bug Fixes + +- Fix a situation where line-breaks in a nested simplified conditional expression could result in broken code (#3734) + +### Pull Requests + +- [#3734](https://github.com/rollup/rollup/pull/3734): Prevent ASI when simplifying a nested logical expression ( @lukastaegert) + +## 2.26.2 + +_2020-08-16_ + +### Bug Fixes + +- Fix a situation where line-breaks in a simplified conditional expression could result in broken code (#3732) + +### Pull Requests + +- [#3732](https://github.com/rollup/rollup/pull/3732): Prevent unintended ASI for nested conditionals (@lukastaegert) + +## 2.26.1 + +_2020-08-16_ + +### Bug Fixes + +- Correctly render external namespace imports when only generating SystemJS output (#3731) + +### Pull Requests + +- [#3731](https://github.com/rollup/rollup/pull/3731): Render system namespace import (@sastan and @lukastaegert) + +## 2.26.0 + +_2020-08-15_ + +### Features + +- Add a new entry `importedBindings` to the bundle information to list bindings per dependency (#3722) + +### Bug Fixes + +- Do not render an invalid UMD wrapper when no bindings are imported from a dependency (#3724) +- Avoid situations where removing the `else` branch from an `if` statement might catch the `else` branch from another one (#3725) + +### Pull Requests + +- [#3722](https://github.com/rollup/rollup/pull/3722): Add import specifiers to bundle information (@lukastaegert) +- [#3724](https://github.com/rollup/rollup/pull/3724): Fix missing variables for UMD and IIFE builds (@lukastaegert) +- [#3725](https://github.com/rollup/rollup/pull/3725): Do not entirely remove else branch if another else branch might accidentally be referenced (@lukastaegert) + +## 2.25.0 + +_2020-08-14_ + +### Features + +- Add `--failAfterWarnings` CLI flag that will complete builds with warnings but return an error at the end (#3712) + +### Pull Requests + +- [#3712](https://github.com/rollup/rollup/pull/3712): Implement `--failAfterWarnings` flag (@tjenkinson) + +## 2.24.0 + +_2020-08-13_ + +### Features + +- Allow defining interop per dependency via a function (#3710) +- Support interop "auto" as a more compatible version of "true" (#3710) +- Support interop "default" and "esModule" to avoid unnecessary interop helpers (#3710) +- Support interop "defaultOnly" for simplified helpers and Node ESM interop compatible output (#3710) +- Respect interop option for external dynamic imports (#3710) +- Support live-bindings for external default imports in non-ES formats unless "externalLiveBindings" is "false" (#3710) +- Use shared default interop helpers for AMD, UMD and IIFE formats (#3710) +- Avoid unnecessarily deconflicted module variables in non-ES formats (#3710) +- Freeze generated interop namespace objects (#3710) +- Always mark interop helpers as pure (#3710) +- Avoid default export interop if there is already an interop namespace object (#3710) +- Sort all `require` statements to the top in CommonJS output for easier back-transpilation to ES modules by other tools (#3710) + +### Bug Fixes + +- Handle accessing `super` in static class fields (#3720) +- Deconflict the names of helper variables introduced for interop (#3710) +- Generate proper namespace objects for static namespace imports in non-ES formats (#3710) +- Do not add unused interop helpers when using the renderDynamicImport hook (#3710) + +### Pull Requests + +- [#3710](https://github.com/rollup/rollup/pull/3710): Rework interop handling (@lukastaegert) +- [#3720](https://github.com/rollup/rollup/pull/3720): Handle super in static class fields (@lukastaegert) + +## 2.23.1 + +_2020-08-07_ + +### Bug Fixes + +- Fix an issue where dynamically importing an entry point could return a malformed namespace for CJS and AMD formats ( #3709) + +### Pull Requests + +- [#3709](https://github.com/rollup/rollup/pull/3709): Properly construct namespace when dynamically importing chunks with facades in default export mode (@lukastaegert) + +## 2.23.0 + +_2020-07-23_ + +### Features + +- Handle environments with only globalThis in UMD output (#3691) + +### Pull Requests + +- [#3691](https://github.com/rollup/rollup/pull/3691): Check for globalThis in UMD wrapper (@lukastaegert) + +## 2.22.2 + +_2020-07-21_ + +### Bug Fixes + +- Always generate correct exports when an implicit entry is reexporting from another module (#3688) + +### Pull Requests + +- [#3688](https://github.com/rollup/rollup/pull/3688): Include all relevant modules to generate reexports for implicit dependencies (@lukastaegert) + +## 2.22.1 + +_2020-07-18_ + +### Bug Fixes + +- Remove unused arguments when calling a conditional expression (#3680) + +### Pull Requests + +- [#3680](https://github.com/rollup/rollup/pull/3680): Allow tree-shaking of arguments of functions that are returned by conditional expressions (@lukastaegert) + +## 2.22.0 + +_2020-07-18_ + +### Features + +- Allow resolving synthetic named exports via an arbitrary export name (#3657) +- Display a warning when the user does not explicitly select an export mode and would generate a chunk with default export mode when targeting CommonJS (#3657) + +### Pull Requests + +- [#3657](https://github.com/rollup/rollup/pull/3657): Add basic support for using a non-default export for syntheticNamedExports (@lukastaegert) +- [#3659](https://github.com/rollup/rollup/pull/3659): Warn when implicitly using default export mode (@lukastaegert) + +## 2.21.0 + +_2020-07-07_ + +### Features + +- Allow plugins to disable tree-shaking for individual modules to ensure even empty modules are associated with chunks ( #3663) + +### Pull Requests + +- [#3663](https://github.com/rollup/rollup/pull/3663): Disable treeshaking per module (@lukastaegert) + +## 2.20.0 + +_2020-07-06_ + +### Features + +- Support using a function to generate different chunk and asset naming patterns per chunk or asset (#3658) +- Add `referencedFiles` property to the chunk info in generateBundle to list referenced assets (#3661) + +### Pull Requests + +- [#3658](https://github.com/rollup/rollup/pull/3658): Add ability to use a function that returns a pattern string in all places where you could use a pattern string before (@frank-dspeed) +- [#3661](https://github.com/rollup/rollup/pull/3661): Add referenced files to bundle (@lukastaegert) + +## 2.19.0 + +_2020-07-05_ + +### Features + +- Allow plugins to return a Promise in the options hook (#3660) + +### Pull Requests + +- [#3660](https://github.com/rollup/rollup/pull/3660): Make options hooks async (@TomerAberbach) + +## 2.18.2 + +_2020-07-02_ + +### Bug Fixes + +- Do not remove spread element args when the corresponding positional parameter is unused (#3652) + +### Pull Requests + +- [#3652](https://github.com/rollup/rollup/pull/3652): Do not tree-shake arguments that contain a spread element ( @lukastaegert) + +## 2.18.1 + +_2020-06-26_ + +### Bug Fixes + +- Make sure synthetic exports are present when a module is imported dynamically (#3648) +- Strip the `rollup-plugin-` prefix off the plugin name when looking for the plugin export in a CLI plugin without a default export (#3647) +- Convert plugin names with dashes to camel case when looking for the plugin export in a CLI plugin without a default export (#3647) + +### Pull Requests + +- [#3647](https://github.com/rollup/rollup/pull/3647): Strip rollup-plugin prefix to find named plugin exports, throw when export cannot be found (@lukastaegert) +- [#3648](https://github.com/rollup/rollup/pull/3648): Always create a dynamic namespace object when a module with synthetic named exports is imported dynamically (@lukastaegert) + +## 2.18.0 + +_2020-06-22_ + +### Features + +- `inlineDynamicImports`, `manualChunks` and `preserveModules` can now be used as output options (#3645) +- Use sourcemaps for certain warnings that reference source code locations (#3645) + +### Bug Fixes + +- `this.getFileName` will now always return the correct file name for chunks when multiple outputs are created (#3645) + +### Pull Requests + +- [#3645](https://github.com/rollup/rollup/pull/3645): Per output chunking (@lukastaegert) + +## 2.17.1 + +_2020-06-19_ + +### Bug Fixes + +- Properly resolve accessing properties of namespace members again (#3643) + +### Pull Requests + +- [#3643](https://github.com/rollup/rollup/pull/3643): Fix accessing nested properties of namespaces (@lukastaegert) + +## 2.17.0 + +_2020-06-17_ + +### Features + +- When importing Rollup via package.exports, always fall back to the browser ESM build for non-Node environments (#3634) +- Create more efficient code when handling namespace mutations (#3637) + +### Bug Fixes + +- Fix a severe performance regression when the same module is imported by a lot of modules (#3641) +- Properly escape special characters in imports (#3638) + +### Pull Requests + +- [#3634](https://github.com/rollup/rollup/pull/3634): Set browser build in exports (@guybedford) +- [#3637](https://github.com/rollup/rollup/pull/3637): Do not include the whole namespace when illegally mutating a namespace (@lukastaegert) +- [#3638](https://github.com/rollup/rollup/pull/3638): Support backslash escaping, retain exact newline escaping ( @guybedford) +- [#3641](https://github.com/rollup/rollup/pull/3641): Fix performance regression when a file is imported by many importers (@lukastaegert) + +## 2.16.1 + +_2020-06-13_ + +### Bug Fixes + +- Do not produce invalid code when an external or chunk id contain quotes or line-breaks (#3632) +- Do not fail but emit a warning when mutating a namespace object (#3633) + +### Pull Requests + +- [#3632](https://github.com/rollup/rollup/pull/3632): Handle single quote escaping in ids (@guybedford) +- [#3633](https://github.com/rollup/rollup/pull/3633): Turn namespace assignment error into a warning (@guybedford) + +## 2.16.0 + +_2020-06-12_ + +### Features + +- Add support for numeric separators (#3626) +- Switch to finalized ESTree optional chaining AST (#3628) + +### Pull Requests + +- [#3626](https://github.com/rollup/rollup/pull/3626): Support numeric separator (@TrySound) +- [#3628](https://github.com/rollup/rollup/pull/3628): Acorn 7.3.0 upgrade (@guybedford) +- [#3631](https://github.com/rollup/rollup/pull/3631): Improve discoverability of `manualChunks` for code splitting ( @zlamma) + +## 2.15.0 + +_2020-06-08_ + +### Features + +- Allow to skip watching some configs via `watch: false` (#3620) +- Provide the resolved sourcemap path to `sourcemapPathTransform` (#3617) + +### Pull Requests + +- [#3617](https://github.com/rollup/rollup/pull/3617): Update sourcemapPathTransform to also take the path to the sourcemap file as a second argument (@dgoldstein0) +- [#3620](https://github.com/rollup/rollup/pull/3620): Rollup watch only one config in exported array (@luwol03) + +## 2.14.0 + +_2020-06-07_ + +### Features + +- Make `this.meta.watchMode` available for plugins to detect watch mode (#3616) + +### Bug Fixes + +- Handle exporting the same binding with different names in SystemJS (#3575) + +### Pull Requests + +- [#3575](https://github.com/rollup/rollup/pull/3575): Handle some cases of duplicate export bindings (@joeljeske) +- [#3616](https://github.com/rollup/rollup/pull/3616): Make watch mode available in plugins (@lukastaegert) + +## 2.13.1 + +_2020-06-04_ + +### Bug Fixes + +- Prevent conflicts in SystemJS when `module` is used as a top-level variable (#3614) + +### Pull Requests + +- [#3614](https://github.com/rollup/rollup/pull/3614): Handle system reserved identifier dedupes (@guybedford) + +## 2.13.0 + +_2020-06-03_ + +### Features + +- Allow to specify that an emitted chunk is only loaded after a given module has loaded to improve chunking (#3606) + +### Pull Requests + +- [#3606](https://github.com/rollup/rollup/pull/3606): Enable specifying implicit dependencies when emitting chunks ( @lukastaegert) + +## 2.12.1 + +_2020-06-02_ + +### Bug Fixes + +- Render valid imports when chunk names correspond to directory names in virtual setups (#3609) + +### Pull Requests + +- [#3609](https://github.com/rollup/rollup/pull/3609): Handle imports from chunks with names that correspond to parent directory names of other chunks (@guybedford) + +## 2.12.0 + +_2020-05-31_ + +### Features + +- Add an option `--waitForBundleInput` to let the build wait until all entry point files are available before starting ( #3577) + +### Pull Requests + +- [#3577](https://github.com/rollup/rollup/pull/3577): Wait for bundle input option (@Heerschop) + +## 2.11.2 + +_2020-05-28_ + +### Bug Fixes + +- Include side-effects in the second argument of `Array.from` (#3604) + +### Pull Requests + +- [#3604](https://github.com/rollup/rollup/pull/3604): Mark `Array.from` as side-effectful, use two-argument Array.from when mapping Sets (@lukastaegert) + +## 2.11.1 + +_2020-05-28_ + +### Bug Fixes + +- Also include side-effects in files that are marked as side-effect-free if they contain an included default export that is reexported (#3602) + +### Pull Requests + +- [#3602](https://github.com/rollup/rollup/pull/3602): Handle side-effects next to side-effect-free default exports in case the default export is reexported (@lukastaegert) + +## 2.11.0 + +_2020-05-27_ + +### Features + +- Add basic support for optional chaining (#3582) +- Provide a normalized set of options with proper default values to `buildStart` and `renderStart` (#3597) +- Do not count adding properties to the prototype of an unused class as a side-effect (#3598) +- Support providing `null` for empty setters in SystemJS via option (#3592) + +### Bug Fixes + +- Do not fail when using a `/*#__PURE__*/` annotation inside a class field (#3599) +- Allow using `--watch` and `--treeshake` together with sub-options such as `--watch.clearScreen` on the command line ( #3597) + +### Pull Requests + +- [#3582](https://github.com/rollup/rollup/pull/3582): Support optional chaining via acorn fork(@guybedford) +- [#3592](https://github.com/rollup/rollup/pull/3592): System format optional setters(@guybedford) +- [#3597](https://github.com/rollup/rollup/pull/3597): Provide normalized options (@lukastaegert) +- [#3598](https://github.com/rollup/rollup/pull/3598): Treeshake prototype modifications in classes (@lukastaegert) +- [#3599](https://github.com/rollup/rollup/pull/3599): Retain pure annotations in class fields (@lukastaegert) +- [#3601](https://github.com/rollup/rollup/pull/3601): Fix white-space in docs (@tu4mo) + +## 2.10.9 + +_2020-05-24_ + +### Bug Fixes + +- Prevent invalid exports when facades are created (#3590) + +### Pull Requests + +- [#3590](https://github.com/rollup/rollup/pull/3590): Prevent unneeded exports when entry facades are created and ensure all exported variables in facades are imported (@lukastaegert) + +## 2.10.8 + +_2020-05-23_ + +### Bug Fixes + +- Fix issues when synthetic named exports are reexported as default exports (#3586) + +### Pull Requests + +- [#3584](https://github.com/rollup/rollup/pull/3584): Clarify documentation for `output.paths` (@jacksteamdev) +- [#3585](https://github.com/rollup/rollup/pull/3585): Target Node.js v14 instead of v13 in Windows tests (@mangs) +- [#3586](https://github.com/rollup/rollup/pull/3586): Handle default reexports of synthetic named exports over several stages (@lukastaegert) + +## 2.10.7 + +_2020-05-22_ + +### Bug Fixes + +- Handle modules re-exporting namespaces without further own code (#3576) + +### Pull Requests + +- [#3576](https://github.com/rollup/rollup/pull/3576): Fix "cannot read exports of undefined" error (@guybedford) + +## 2.10.6 + +_2020-05-22_ + +### Bug Fixes + +- Fix some issues around class fields (#3580) +- Prevent a maximum call stack error when a called entity references itself in its declaration (#3581) + +### Pull Requests + +- [#3580](https://github.com/rollup/rollup/pull/3580): Update acorn class features (@guybedford) +- [#3581](https://github.com/rollup/rollup/pull/3581): Do not fail when including call arguments of recursively defined variables (@lukastaegert) + +## 2.10.5 + +_2020-05-19_ + +### Bug Fixes + +- Do not remove side-effects that may influence an included default export declaration when side-effects are disabled ( #3572) + +### Pull Requests + +- [#3572](https://github.com/rollup/rollup/pull/3572): Observe side-effects in files containing a default export declaration that reexports a variable (@lukastaegert) + +## 2.10.4 + +_2020-05-19_ + +### Bug Fixes + +- Tree-shake unused classes with fields unless there are side-effects in the field declaration (#3569) + +### Pull Requests + +- [#3569](https://github.com/rollup/rollup/pull/3569): Make sure unused classes with fields are tree-shaken if possible (@lukastaegert) + +## 2.10.3 + +_2020-05-18_ + +### Bug Fixes + +- Validate return value of sourcemapPathTransform option (#3561) + +### Pull Requests + +- [#3561](https://github.com/rollup/rollup/pull/3561): Throw error if sourcemapPathTransform-option does not return a string (@Simonwep) + +## 2.10.2 + +_2020-05-15_ + +### Bug Fixes + +- Properly include calls to mutating array methods in certain scenarios (#3559) + +### Pull Requests + +- [#3559](https://github.com/rollup/rollup/pull/3559): Make sure UnknownFooExpressions are included when referenced as return values in a MultiExpression (@lukastaegert) + +## 2.10.1 + +_2020-05-15_ + +### Bug Fixes + +- Do not throw when "undefined" is used as a default export (#3558) + +### Pull Requests + +- [#3558](https://github.com/rollup/rollup/pull/3558): Properly handle default exporting undefined (@lukastaegert) + +## 2.10.0 + +_2020-05-13_ + +### Features + +- Avoid unnecessary empty imports from a facade chunk to the original chunk (#3552) +- Pin facade creation order so that if several user-defined chunks reference the same module, the first always becomes the "actual" chunk while the later ones become facades (#3552) + +### Bug Fixes + +- Do not omit reexports from secondary chunks when creating facades for entry points without hoisting transitive dependencies (#3552) + +### Pull Requests + +- [#3552](https://github.com/rollup/rollup/pull/3552): Avoid unnecessary facade dependency inlining (@guybedford) + +## 2.9.1 + +_2020-05-11_ + +### Bug Fixes + +- Do not create unintended live-bindings or invalid reexports when reexporting global variables (#3550) + +### Pull Requests + +- [#3550](https://github.com/rollup/rollup/pull/3550): Track updates of globals that are exported as default ( @lukastaegert) + +## 2.9.0 + +_2020-05-10_ + +### Features + +- Add ids of static and dynamic imports to `this.getModuleInfo` (#3542) +- Provide `getModuleInfo` and `getModuleIds` to `manualChunks` functions (#3542) +- Add nullish coalescing support (#3548) +- Make the rebuild delay in watch mode configurable and set the default to `0` for snappy rebuilds (#3502) +- Add `this.getModuleIds` to the plugin context as future replacement for `this.moduleIds` (#3542) + +### Pull Requests + +- [#3502](https://github.com/rollup/rollup/pull/3502): Configurable build delay (@mattdesl) +- [#3542](https://github.com/rollup/rollup/pull/3542): Extend manualChunks API (@lukastaegert) +- [#3548](https://github.com/rollup/rollup/pull/3548): Support nullish coalescing with tree-shaking (@lukastaegert) + +## 2.8.2 + +_2020-05-07_ + +### Bug Fixes + +- Avoid invalid code when simplifying the body of a shorthand arrow function expression (#3540) + +### Pull Requests + +- [#3540](https://github.com/rollup/rollup/pull/3540): Wrap object expressions in parentheses if they become children of an arrow function expression (@lukastaegert) + +## 2.8.1 + +_2020-05-07_ + +### Bug Fixes + +- Allow using plugins on CLI that are exported as `exports.default` (#3529) +- Do not fail side-effect detection in nested callbacks of builtins (#3539) + +### Pull Requests + +- [#3529](https://github.com/rollup/rollup/pull/3529): Use default named export with plugins (@NotWoods) +- [#3539](https://github.com/rollup/rollup/pull/3539): Track call side-effects both by entity and CallExpression to avoid untracked side-effects in nested calls (@lukastaegert) + +## 2.8.0 + +_2020-05-06_ + +### Features + +- When a dynamically imported chunk contains more exports than the imported module namespace, do not create a facade chunk but an inline namespace (#3535) + +### Bug Fixes + +- Do not execute dynamically imported code before synchronous code in the importing module when generating CommonJS ( #3535) + +### Pull Requests + +- [#3535](https://github.com/rollup/rollup/pull/3535): Avoid dynamic facade chunks (@lukastaegert) + +## 2.7.6 + +_2020-04-30_ + +### Bug Fixes + +- Fix a type issue when a default export references a global variable (#3526) + +### Pull Requests + +- [#3526](https://github.com/rollup/rollup/pull/3526): Handles default exporting global variables (@lukastaegert) + +## 2.7.5 + +_2020-04-29_ + +### Bug Fixes + +- Prevent infinite loop when default values of function parameters in a default export contain a slash (#3522) + +### Pull Requests + +- [#3522](https://github.com/rollup/rollup/pull/3522): Avoid infinite loop when finding position for id insertion in default export (@lukastaegert) + +## 2.7.4 + +_2020-04-29_ + +### Bug Fixes + +- Fix an issue where wrong variable names were used when preserving modules (#3521) + +### Pull Requests + +- [#3521](https://github.com/rollup/rollup/pull/3521): Fix and improve default export alias logic (@lukastaegert) + +## 2.7.3 + +_2020-04-27_ + +### Bug Fixes + +- Do not access `__proto__` when running Rollup (#3518) + +### Pull Requests + +- [#3518](https://github.com/rollup/rollup/pull/3518): use acorn-class-fields and acorn-static-class-features from npm ( @nitsky) + +## 2.7.2 + +_2020-04-22_ + +### Bug Fixes + +- Prevent an infinite loop when creating separate manual chunks with circular dependencies (#3510) +- Do not fail if "super" is used in the definition of a class field (#3511) +- Throw if a plugin tries to emit a file with an absolute Windows path (#3509) + +### Pull Requests + +- [#3509](https://github.com/rollup/rollup/pull/3509): Ban emitFile via absolute paths on Windows OS (@SASUKE40) +- [#3510](https://github.com/rollup/rollup/pull/3510): Do not fail for circular imports between manual chunks ( @lukastaegert) +- [#3511](https://github.com/rollup/rollup/pull/3511): Support "super" in class fields (@lukastaegert) + +## 2.7.1 + +_2020-04-21_ + +### Bug Fixes + +- Use correct path for dynamic imports if `output.paths` is used (#3508) + +### Pull Requests + +- [#3508](https://github.com/rollup/rollup/pull/3508): Respect output.paths in dynamic imports (@lukastaegert) + +## 2.7.0 + +_2020-04-21_ + +### Features + +- Add `preserveEntrySignatures` option to control how exports of entry points are handled (#3498) +- Add `preserveSignature` flag to `this.emitFile` to control exports of emitted chunks (#3498) +- Add `output.minifyInternalExports` option to control if internal exports are minified (#3498) + +### Pull Requests + +- [#3498](https://github.com/rollup/rollup/pull/3498): Add option to configure if entry signatures are preserved ( @lukastaegert) + +## 2.6.1 + +_2020-04-12_ + +### Bug Fixes + +- Close watch mode when stdin closes in a non-TTY environment (#3493) + +### Pull Requests + +- [#3493](https://github.com/rollup/rollup/pull/3493): Ensure --watch mode exits correctly when stdin is closed ( @jakesgordon) + +## 2.6.0 + +_2020-04-10_ + +### Features + +- Allow regular expressions to declare external modules (#3482) + +### Pull Requests + +- [#3482](https://github.com/rollup/rollup/pull/3482): Allow regular expressions in config.external (@johannes-z) + +## 2.5.0 + +This version is identical to 2.4.0 + +## 2.4.0 + +_2020-04-09_ + +### Features + +- Add support for most private and public class field features (#3488) + +### Bug Fixes + +- Do not replace `this` with `undefined` in class field definitions (#3488) + +### Pull Requests + +- [#3488](https://github.com/rollup/rollup/pull/3488): Rollup class fields support (@guybedford and @lukastaegert) + +## 2.3.5 + +_2020-04-09_ + +### Bug Fixes + +- Never remove labels when tree-shaking is disabled (#3492) + +### Pull Requests + +- [#3492](https://github.com/rollup/rollup/pull/3492): Always use a new inclusion context when including declarations of variables, always inlcude labels when not treeshaking (@lukastaegert) + +## 2.3.4 + +_2020-04-07_ + +### Bug Fixes + +- Handle re-exporting synthetic exports from entry-points (#3319) +- Fix cross-chunk imports of synthetic exports (#3319) +- Handle namespace objects that contain re-exported synthetic namespaces (#3319) + +### Pull Requests + +- [#3319](https://github.com/rollup/rollup/pull/3319): Handle re-exports of synthetic named exports (@manucorporat and @lukastaegert) + +## 2.3.3 + +_2020-04-04_ + +### Bug Fixes + +- Add external namespaces to dynamic namespace objects (#3474) + +### Pull Requests + +- [#3474](https://github.com/rollup/rollup/pull/3474): Support external star exports on namespace objects (@guybedford) + +## 2.3.2 + +_2020-03-31_ + +### Bug Fixes + +- Only warn but do not fail build when a namespace is called as a function (#3475) +- Make sure pre-existing sourcemap comments are also removed when rebuilding using the cache (#3476) + +### Pull Requests + +- [#3475](https://github.com/rollup/rollup/pull/3475): Call namespace error as a warning (@guybedford) +- [#3476](https://github.com/rollup/rollup/pull/3476): Store locations for removed comments in cache (@lukastaegert) + +## 2.3.1 + +_2020-03-30_ + +### Bug Fixes + +- Do not fail if the config file returns an function returning a Promise (#3472) + +### Pull Requests + +- [#3472](https://github.com/rollup/rollup/pull/3472): Fix support for async functions as config (@lukastaegert) + +## 2.3.0 + +_2020-03-29_ + +### Features + +- Do not transpile config files with `.mjs` extension in Node 13+ or `.cjs` extension in any Node version and load them appropriately (#3445) +- Extract helper to load a config file the way rollup does it via `rollup/dist/loadConfigFile` (#3445) + +### Bug Fixes + +- Keep watching the config file if an error occurs during initial load in watch node (#3445) +- Add a helpful error message when using a transpiled config in a repository with "type": "module" (#3445) + +### Pull Requests + +- [#3445](https://github.com/rollup/rollup/pull/3445): Support native ESM configs in Node 13, support untranspiled configs (@lukastaegert) +- [#3468](https://github.com/rollup/rollup/pull/3468): Don't use esm output format alias in the documentation (@vsn4ik) + +## 2.2.0 + +_2020-03-24_ + +### Features + +- Add `renderDynamicImport` hook to rewrite dynamic import expressions (#3449) +- Add information about dynamically imported modules to `this.getModuleInfo` (#3449) + +### Bug Fixes + +- Make file emission work with Uin8Array sources when using Rollup in the browser (#3452) +- Fix types to allow watch to accept an array of configs (#3453) +- Do not strip `.js` extensions from AMD imports when the import is a user-supplied replacement for a non-resolvable dynamic import target (#3453) + +### Pull Requests + +- [#3449](https://github.com/rollup/rollup/pull/3449): Add hook to rewrite dynamic import expressions (@lukastaegert) +- [#3452](https://github.com/rollup/rollup/pull/3452): Avoid the assumption of Buffer in browser envs (@JoviDeCroock) +- [#3453](https://github.com/rollup/rollup/pull/3453): fix types since watch accepts single or array config (@lukeed) +- [#3456](https://github.com/rollup/rollup/pull/3456): fix SystemJS url in tutorial (@guybedford) + +## 2.1.0 + +_2020-03-18_ + +### Features + +- Allow specifying an importer when emitting files to resolve relative ids (#3442) + +### Pull Requests + +- [#3442](https://github.com/rollup/rollup/pull/3442): Add optional `importer` parameter to `this.emitFile` ( @lukastaegert) + +## 2.0.6 + +_2020-03-13_ + +### Bug Fixes + +- Do not use file names from different outputs when generating sourcemaps using the `dir` option (#3440) + +### Pull Requests + +- [#3440](https://github.com/rollup/rollup/pull/3440): Use correct file names when writing sourcemaps for multiple outputs (@lukastaegert) + +## 2.0.5 + +_2020-03-12_ + +### Bug Fixes + +- Fix an issue where conditional statements would assume they have the wrong test value (#3438) + +### Pull Requests + +- [#3438](https://github.com/rollup/rollup/pull/3438): Make sure logical expressions always check the left argument for side-effects (@lukastaegert) + +## 2.0.4 + +_2020-03-12_ + +### Bug Fixes + +- Avoid conflicts between namespace imports when preserving modules (#3435) + +### Pull Requests + +- [#3435](https://github.com/rollup/rollup/pull/3435): Deconflict multiple `index` imports for ES format using nested export star statements (@kamranayub) + +## 2.0.3 + +_2020-03-10_ + +### Bug Fixes + +- Add type for this.getCombinedSourcemap to transform context (#3431) + +### Pull Requests + +- [#3377](https://github.com/rollup/rollup/pull/3377): Switch to yargs-parser lib (@jamesgeorge007) +- [#3426](https://github.com/rollup/rollup/pull/3426): Use strict types with PluginDriver (@NotWoods) +- [#3431](https://github.com/rollup/rollup/pull/3431): Add missing type declaration for getCombinedSourcemap ( @Anidetrix) +- [#3432](https://github.com/rollup/rollup/pull/3432): Detail how return values from `augmentChunkHash` are used ( @jakearchibald) + +## 2.0.2 + +_2020-03-07_ + +### Bug Fixes + +- Make sure the ESM import still works (#3430) + +### Pull Requests + +- [#3430](https://github.com/rollup/rollup/pull/3430): Fix conditional exports again (@lukastaegert) + +## 2.0.1 + +_2020-03-07_ + +### Bug Fixes + +- Reenable importing rollup in Node 13.0 - 13.7 (#3428) + +### Pull Requests + +- [#3428](https://github.com/rollup/rollup/pull/3428): Fix conditional exports in Node 13.0 - 13.7 (@lukastaegert) + +## 2.0.0 + +_2020-03-06_ + +### Breaking Changes + +- Rollup now requires at least Node 10 to run, or a sufficiently modern browser (#3346) +- The file structure of Rollup's ESM builds has changed: + - The main ESM entry point is now at `rollup/dist/es/rollup.js` instead of `rollup/dist/rollup.es.js` + - The ESM browser build is at `rollup/dist/es/rollup.browser.js` instead of `rollup/dist/rollup.browser.es.js` + + In general, the ESM builds now follow the same naming scheme as the CJS builds but are located in the `rollup/dist/es` subfolder instead of `rollup/dist` (#3391) + +- The "watch.chokidar" option no longer accepts a `boolean` value but only an object of parameters that is passed to the bundled Chokidar instance. Chokidar installations by the user will be ignored in favour of the bundled instance ( #3331) +- Modules that are completely tree-shaken will no longer be listed as part of any chunks in `generateBundle` +- The `experimentalOptimizeChunks` and `chunkGroupingSize` options have been removed +- [acorn](https://github.com/acornjs/acorn) plugins can only be used if they accept a passed-in acorn instance instead of importing it themselves. See https://github.com/acornjs/acorn/pull/870#issuecomment-527339830 for what needs to be done to make plugins compatible that do not support this yet (#3391) +- Emitted chunks now have the TypeScript type `Uint8Array` instead of `Buffer`. A `Buffer` can still be used, though ( #3395) +- The TypeScript types no longer use ESTree types for AST nodes but a very generic type that does not contain information specific to certain node types (#3395) +- The signature of the `writeBundle` plugin hook has been changed to match `generateBundle`: The bundle object is now passed as second parameter instead of first and the first parameter is the output options (#3361) +- The following plugin hooks have been removed: + - ongenerate: use `generateBundle` instead + - onwrite: use `writeBundle` instead + - transformBundle: use `renderChunk` instead + - transformChunk: use `renderChunk` instead +- You can no longer access `this.watcher` on the plugin context. +- The `transform` hook can no longer return `dependencies`. +- The `treeshake.pureExternalModules` option will now show a deprecation warning when used: use `treeshake.moduleSideEffects: 'no-external'` instead +- Using `import.meta.ROLLUP_ASSET_URL_<..>` and `import.meta.ROLLUP_CHUNK_URL_<..>` in code will now show warnings: use `import.meta.ROLLUP_FILE_URL_<..>` instead +- The `resolveAssetUrl` hook will now show a deprecation warning when used: use `resolveFileUrl` instead +- The following plugin context functions will show warnings when used: + - `this.emitAsset`: use `this.emitFile` + - `this.emitChunk`: use `this.emitFile` + - `this.getAssetFileName`: use `this.getFileName` + - `this.getChunkFileName`: use `this.getFileName` + - `this.isExternal`: use `this.resolve` + - `this.resolveId`: use `this.resolve` +- Directly adding properties to the bundle object in the `generateBundle` is deprecated will show a warning (removing properties is allowed, though): Use `this.emitFile` +- Accessing `chunk.isAsset` on the bundle is deprecated: Use `chunk.type === 'asset'` instead +- The error code for a missing `name` property when targeting UMD has been changed to `MISSING_NAME_OPTION_FOR_IIFE_EXPORT` to emphasize this is needed for the IIFE part of UMD (#3393) + +### Features + +- Rollup now bundles [Chokidar](https://github.com/paulmillr/chokidar) for a better watch experience (#3331) +- Rollup now bundles [acorn](https://github.com/acornjs/acorn) again, removing its only external dependency (#3391) +- Do not consider empty imports from side-effect-free modules for chunking and hoist side-effect imports if necessary ( #3369) +- Rollup can now be imported as an ES module in Node via `import {rollup} from 'rollup'`. Note that this relies on Node's experimental [conditional package exports](https://nodejs.org/dist/latest-v13.x/docs/api/esm.html#esm_conditional_exports) feature and is therefore itself experimental (#3391) +- `systemjs` can be used as format alias for `system` (#3381) + +### Bug Fixes + +- Unknown output options now trigger a warning when using the JavaScript API (#3352) +- Rollup will no longer introduce Node types into TypeScript projects that do not use them (#3395) +- Generate correct sourcemaps when tree-shaking occurs in a multi-file bundle (#3423) + +### Pull Requests + +- [#3331](https://github.com/rollup/rollup/pull/3331): Bundle Chokidar (@lukastaegert) +- [#3343](https://github.com/rollup/rollup/pull/3343): Remove experimentalOptimizeChunks (@lukastaegert) +- [#3346](https://github.com/rollup/rollup/pull/3346): Update minimum required Node version to 10 (@lukastaegert) +- [#3352](https://github.com/rollup/rollup/pull/3352): Remove active deprecations (@lukastaegert) +- [#3361](https://github.com/rollup/rollup/pull/3361): Change writeBundle signature to match generateBundle ( @lukastaegert) +- [#3369](https://github.com/rollup/rollup/pull/3369): Avoid empty imports from side-effect-free chunks (@lukastaegert) +- [#3381](https://github.com/rollup/rollup/pull/3381): Rename esm to es everywhere, add systemjs alias (@lukastaegert) +- [#3391](https://github.com/rollup/rollup/pull/3391): Bundle acorn, allow importing Rollup as Node ES module, update dependencies (@lukastaegert) +- [#3393](https://github.com/rollup/rollup/pull/3393): Better error code for name-less umd bundle (@rail44) +- [#3395](https://github.com/rollup/rollup/pull/3395): Remove `@types` dependencies (@lukastaegert) +- [#3423](https://github.com/rollup/rollup/pull/3423): Update magic-string and fix sourcemaps (@lukastaegert) + +For previous changelogs, see + +- [Rollup 1.x](./CHANGELOG-1.md) +- [Rollup 0.x](./CHANGELOG-0.md) diff --git a/CHANGELOG-3.md b/CHANGELOG-3.md new file mode 100644 index 00000000000..ed3b067c5d4 --- /dev/null +++ b/CHANGELOG-3.md @@ -0,0 +1,1320 @@ +# rollup changelog + +## 3.29.4 + +_2023-09-28_ + +### Bug Fixes + +- Fix static analysis when an exported function uses callbacks (#5158) + +### Pull Requests + +- [#5158](https://github.com/rollup/rollup/pull/5158): Deoptimize all parameters when losing track of a function ( @lukastaegert) + +## 3.29.3 + +_2023-09-24_ + +### Bug Fixes + +- Fix a bug where code was wrongly tree-shaken after mutating function parameters (#5153) + +### Pull Requests + +- [#5145](https://github.com/rollup/rollup/pull/5145): docs: improve the docs repl appearance in the light mode ( @TrickyPi) +- [#5148](https://github.com/rollup/rollup/pull/5148): chore(deps): update dependency @vue/eslint-config-typescript to v12 (@renovate[bot]) +- [#5149](https://github.com/rollup/rollup/pull/5149): chore(deps): lock file maintenance minor/patch updates ( @renovate[bot]) +- [#5153](https://github.com/rollup/rollup/pull/5153): Fully deoptimize first level path when deoptimizing nested parameter paths (@lukastaegert) + +## 3.29.2 + +_2023-09-15_ + +### Bug Fixes + +- Export `TreeshakingPreset` type (#5131) + +### Pull Requests + +- [#5131](https://github.com/rollup/rollup/pull/5131): fix: exports `TreeshakingPreset` (@moltar) +- [#5134](https://github.com/rollup/rollup/pull/5134): docs: steps to enable symlinks on windows (@thebanjomatic) +- [#5137](https://github.com/rollup/rollup/pull/5137): chore(deps): lock file maintenance minor/patch updates ( @renovate[bot]) + +## 3.29.1 + +_2023-09-10_ + +### Bug Fixes + +- Fix time measurement of plugin hooks in watch mode (#5114) +- Ensure accessing document.currentScript in import.meta.url returns correct results (#5118) + +### Pull Requests + +- [#5114](https://github.com/rollup/rollup/pull/5114): fix(perf): avoid superfluous timer wrappings in watch mode ( @ZhengLiu2825) +- [#5118](https://github.com/rollup/rollup/pull/5118): fix: access document.currentScript at the top level (@TrickyPi) +- [#5125](https://github.com/rollup/rollup/pull/5125): chore(deps): update actions/checkout action to v4 ( @renovate[bot]) +- [#5126](https://github.com/rollup/rollup/pull/5126): chore(deps): lock file maintenance minor/patch updates ( @renovate[bot]) +- [#5129](https://github.com/rollup/rollup/pull/5129): re-enbale repl-artefacts workflow for rollup-swc branch ( @TrickyPi) + +## 3.29.0 + +_2023-09-06_ + +### Features + +- Add output.sourcemapFileNames option (#5105) +- Add generic type parameter for `api` to Plugin type (#5112) + +### Bug Fixes + +- Ensure mutations of CustomEvent details are tracked (#5123) + +### Pull Requests + +- [#5105](https://github.com/rollup/rollup/pull/5105): Added option to name sourcemap files, i.e. a output.sourcemapFileName… (@atti187) +- [#5108](https://github.com/rollup/rollup/pull/5108): chore(deps): lock file maintenance minor/patch updates ( @renovate[bot]) +- [#5109](https://github.com/rollup/rollup/pull/5109): Docs: load full path of rollup.browser.js for Rollup V4 ( @TrickyPi) +- [#5112](https://github.com/rollup/rollup/pull/5112): feat(types): add generic type for plugin api (@sxzz) +- [#5115](https://github.com/rollup/rollup/pull/5115): chore(deps): lock file maintenance minor/patch updates ( @renovate[bot]) +- [#5123](https://github.com/rollup/rollup/pull/5123): Deoptimize custom event detail (@lukastaegert) + +## 3.28.1 + +_2023-08-22_ + +### Bug Fixes + +- Ensure external files with relative import paths outside the target are rendered correctly (#5099) + +### Pull Requests + +- [#5093](https://github.com/rollup/rollup/pull/5093): chore(deps): update dependency eslint-config-prettier to v9 ( @renovate[bot]) +- [#5094](https://github.com/rollup/rollup/pull/5094): chore(deps): lock file maintenance minor/patch updates ( @renovate[bot]) +- [#5099](https://github.com/rollup/rollup/pull/5099): Fix resolution of relative external files outside target directory (@lukastaegert) +- [#5101](https://github.com/rollup/rollup/pull/5101): chore(deps): update dependency lint-staged to v14 ( @renovate[bot]) +- [#5102](https://github.com/rollup/rollup/pull/5102): chore(deps): lock file maintenance minor/patch updates ( @renovate[bot]) + +## 3.28.0 + +_2023-08-09_ + +### Features + +- Add a new property `preliminaryFileName` to generated chunks containing the file name placeholder (#5086) +- Improve performance of sourcemap generation by lazily decoding mappings (#5087) + +### Bug Fixes + +- Make the `code` property of rendered modules in the output readonly (#5091) + +### Pull Requests + +- [#5086](https://github.com/rollup/rollup/pull/5086): feat: add `preliminaryFileName` to `OutputChunk` (@lsdsjy) +- [#5087](https://github.com/rollup/rollup/pull/5087): perf(sourcemaps): add back lazy sourcemap decode and handling nullish mappings (@thebanjomatic) +- [#5091](https://github.com/rollup/rollup/pull/5091): fix: the type of RenderedModule.code is readonly (@TrickyPi) + +## 3.27.2 + +_2023-08-04_ + +### Bug Fixes + +- Revert sourcemap performance improvement for now as it causes issues with Vite (#5075) + +### Pull Requests + +- [#5075](https://github.com/rollup/rollup/pull/5075): Revert perf(sourcemap): lazy compute decoded mappings ( @thebanjomatic) + +## 3.27.1 + +_2023-08-03_ + +### Bug Fixes + +- Improve performance when generating sourcemaps (#5075) + +### Pull Requests + +- [#5075](https://github.com/rollup/rollup/pull/5075): perf(sourcemap): lazy compute decoded mappings (@thebanjomatic) + +## 3.27.0 + +_2023-07-28_ + +### Features + +- Mark `Object.values` and `Object.entries` as pure if their argument does not contain getters (#5072) + +### Pull Requests + +- [#5070](https://github.com/rollup/rollup/pull/5070): chore(deps): lock file maintenance minor/patch updates ( @renovate[bot]) +- [#5071](https://github.com/rollup/rollup/pull/5071): docs(tutorial): change the .js extension to .mjs (@TrickyPi) +- [#5072](https://github.com/rollup/rollup/pull/5072): Add known globals (@sapphi-red) +- [#5078](https://github.com/rollup/rollup/pull/5078): chore(deps): update dependency @vue/eslint-config-prettier to v8 (@renovate[bot]) +- [#5079](https://github.com/rollup/rollup/pull/5079): chore(deps): lock file maintenance minor/patch updates ( @renovate[bot]) + +## 3.26.3 + +_2023-07-17_ + +### Bug Fixes + +- Do not pass external modules to `manualChunks` to avoid breaking existing configs (#5068) + +### Pull Requests + +- [#5056](https://github.com/rollup/rollup/pull/5056): chore(deps): lock file maintenance minor/patch updates ( @renovate[bot]) +- [#5059](https://github.com/rollup/rollup/pull/5059): chore(config): migrate renovate config (@renovate[bot]) +- [#5064](https://github.com/rollup/rollup/pull/5064): chore(deps): update dependency prettier to v3 (@renovate[bot]) +- [#5065](https://github.com/rollup/rollup/pull/5065): chore(deps): update typescript-eslint monorepo to v6 (major) ( @renovate[bot]) +- [#5068](https://github.com/rollup/rollup/pull/5068): fix: don't pass external modules to the manualChunks function ( @TrickyPi) + +## 3.26.2 + +_2023-07-06_ + +### Bug Fixes + +- Improve error handling when manual chunks would contain external modules (#5050) + +### Pull Requests + +- [#5050](https://github.com/rollup/rollup/pull/5050): fix: improve error for manualChunks' modules that are resolved as an external module (@TrickyPi) + +## 3.26.1 + +_2023-07-05_ + +### Bug Fixes + +- Support `hasOwnProperty` as exported name in CommonJS (#5010) +- Properly reference browser types in package file (#5051) + +### Pull Requests + +- [#5010](https://github.com/rollup/rollup/pull/5010): safe hasOwnProperty call (@LongTengDao) +- [#5051](https://github.com/rollup/rollup/pull/5051): @rollup/browser: fix types export map entry (@developit) + +## 3.26.0 + +_2023-06-30_ + +### Features + +- Add `--filterLogs` CLI flag and `ROLLUP_FILTER_LOGS` environment variable for log filtering (#5035) + +### Pull Requests + +- [#5035](https://github.com/rollup/rollup/pull/5035): Add ability to filter logs via CLI option or environment variable (@lukastaegert) +- [#5049](https://github.com/rollup/rollup/pull/5049): chore(deps): lock file maintenance minor/patch updates ( @renovate[bot]) + +## 3.25.3 + +_2023-06-26_ + +### Bug Fixes + +- Fix error when inlining dynamic imports that contain unused reexported variables (#5047) + +### Pull Requests + +- [#5047](https://github.com/rollup/rollup/pull/5047): Do not add tree-shaken variables to namespaces when inlining dynamic imports (@lukastaegert) + +## 3.25.2 + +_2023-06-24_ + +### Bug Fixes + +- Handle plugin errors where `code` is not a string (#5042) +- Use current transformed source when generating code frames with positions in transform hooks (#5045) + +### Pull Requests + +- [#5038](https://github.com/rollup/rollup/pull/5038): chore(deps): lock file maintenance minor/patch updates ( @renovate[bot]) +- [#5040](https://github.com/rollup/rollup/pull/5040): Fix typo in index.md (@vHeemstra) +- [#5042](https://github.com/rollup/rollup/pull/5042): fix: a plugin error can contains numeric code (@TrickyPi) +- [#5045](https://github.com/rollup/rollup/pull/5045): Fix `this.error` with `pos` in `transform` hook (@sapphi-red) +- [#5046](https://github.com/rollup/rollup/pull/5046): chore(deps): update dependency locate-character to v3 ( @renovate[bot]) + +## 3.25.1 + +_2023-06-12_ + +### Bug Fixes + +- Respect `__NO_SIDE_EFFECTS__` for async functions (#5031) + +### Pull Requests + +- [#5031](https://github.com/rollup/rollup/pull/5031): fix: `__NO_SIDE_EFFECTS__` annotation for async function (@antfu) + +## 3.25.0 + +_2023-06-11_ + +### Features + +- Add `this.info` and `this.debug` plugin context logging functions (#5026) +- Add `onLog` option to read, map and filter logs (#5026) +- Add `logLevel` option to fully suppress logs by level (#5026) +- Support function logs in `this.warn`, `this.info` and `this.debug` to avoid heavy computations based on log level ( #5026) +- Add `onLog` plugin hook to read, filter and map logs from plugins (#5026) + +### Pull Requests + +- [#5026](https://github.com/rollup/rollup/pull/5026): Add Logging API (@lukastaegert) + +## 3.24.1 + +_2023-06-10_ + +### Bug Fixes + +- Fix an issue where bundles with `@rollup/plugin-commonjs` were missing internal dependencies when code-splitting ( #5029) +- Do not use `process.exit(0)` in watch mode to avoid issues in embedded scenarios (#5027) + +### Pull Requests + +- [#5027](https://github.com/rollup/rollup/pull/5027): fix turborepo with rollup --watch (@plumber-dhaval) +- [#5028](https://github.com/rollup/rollup/pull/5028): chore(deps): lock file maintenance minor/patch updates ( @renovate[bot]) +- [#5029](https://github.com/rollup/rollup/pull/5029): fix: get right sideEffectModules (@TrickyPi) + +## 3.24.0 + +_2023-06-07_ + +### Features + +- Add new annotation `/* #__NO_SIDE_EFFECTS__ */` to mark function declarations as side effect free (#5024) + +### Pull Requests + +- [#5024](https://github.com/rollup/rollup/pull/5024): feat: support `#__NO_SIDE_EFFECTS__` annotation for function declaration (@antfu) + +## 3.23.1 + +_2023-06-04_ + +### Bug Fixes + +- Ensure the last segment of sourcemapBaseUrl is never omitted (#5022) + +### Pull Requests + +- [#5006](https://github.com/rollup/rollup/pull/5006): Better workflow caching (@lukastaegert) +- [#5012](https://github.com/rollup/rollup/pull/5012): chore(deps): lock file maintenance minor/patch updates ( @renovate[bot]) +- [#5022](https://github.com/rollup/rollup/pull/5022): fix: add a trailing slash automatically for sourcemapBaseUrl ( @TrickyPi) +- [#5023](https://github.com/rollup/rollup/pull/5023): chore(deps): lock file maintenance minor/patch updates ( @renovate[bot]) + +## 3.23.0 + +_2023-05-22_ + +### Features + +- Support emitting "prebuilt chunks" from plugins (#4990) + +### Bug Fixes + +- Mark Sets and Maps as pure when they receive an array literal as argument (#5005) + +### Pull Requests + +- [#4990](https://github.com/rollup/rollup/pull/4990): feat: this.emitFile support prebuilt-chunk type (@TrickyPi) +- [#5005](https://github.com/rollup/rollup/pull/5005): feat: mark Set, Map, WeakSet and WeakMap with array arguments as pure (@TrickyPi) + +## 3.22.1 + +_2023-05-21_ + +### Bug Fixes + +- Remove force quit again as it caused some issues (#5004) + +### Pull Requests + +- [#5001](https://github.com/rollup/rollup/pull/5001): chore(deps): update dependency @rollup/plugin-commonjs to v25 ( @renovate[bot]) +- [#5002](https://github.com/rollup/rollup/pull/5002): chore(deps): update dependency eslint-plugin-unicorn to v47 ( @renovate[bot]) +- [#5003](https://github.com/rollup/rollup/pull/5003): chore(deps): lock file maintenance minor/patch updates ( @renovate[bot]) +- [#5004](https://github.com/rollup/rollup/pull/5004): Do not force quit Rollup or close stdout (@lukastaegert) + +## 3.22.0 + +_2023-05-17_ + +### Features + +- Prevent empty non-facade chunks by merging them into other suitable chunks (#4989) +- Avoid facade chunks in some situations involving reexports (#4989) +- Improve algorithm for best merge target when using `experimentalMinChunkSize` to take tree-shaking into account ( #4989) + +### Bug Fixes + +- Take side effects of external dependencies into account when merging chunks for `experimentalMinChunkSize` (#4989) + +### Pull Requests + +- [#4989](https://github.com/rollup/rollup/pull/4989): Prevent empty chunks and thoroughly improve experimentalMinChunkSize (@lukastaegert) + +## 3.21.8 + +_2023-05-16_ + +### Bug Fixes + +- Allow a namespace to properly contain itself as a named export (#4991) + +### Pull Requests + +- [#4991](https://github.com/rollup/rollup/pull/4991): Handle self-referencing namespaces (@lukastaegert) + +## 3.21.7 + +_2023-05-13_ + +### Bug Fixes + +- Show correct error on uncaught exceptions in watch mode (#4987) + +### Pull Requests + +- [#4987](https://github.com/rollup/rollup/pull/4987): Properly quit on uncaught exceptions (@lukastaegert) +- [#4988](https://github.com/rollup/rollup/pull/4988): test: add options type for function tests (@TrickyPi) + +## 3.21.6 + +_2023-05-09_ + +### Bug Fixes + +- Ensure Rollup CLI prints everything to stdout before exiting (#4980) + +### Pull Requests + +- [#4980](https://github.com/rollup/rollup/pull/4980): chore(deps): lock file maintenance minor/patch updates ( @renovate[bot]) +- [#4983](https://github.com/rollup/rollup/pull/4983): Prevent exit before stdout is drained (@lukastaegert) + +## 3.21.5 + +_2023-05-05_ + +### Bug Fixes + +- Keep all consecutive lines at the top of each module that start with a comment (#4975) +- Ensure that declarations inside switch cases do not use the same scope as the discriminator (#4979) + +### Pull Requests + +- [#4975](https://github.com/rollup/rollup/pull/4975): Keep leading comments on consecutive lines (@lukastaegert) +- [#4979](https://github.com/rollup/rollup/pull/4979): Use correct scope in switch statements (@lukastaegert) + +## 3.21.4 + +_2023-05-03_ + +### Bug Fixes + +- Resolve crash when shimming a missing export in an otherwise non-included module when preserving modules (#4971) + +### Pull Requests + +- [#4971](https://github.com/rollup/rollup/pull/4971): Handle shimming missing exports when preserving modules ( @lukastaegert) +- [#4972](https://github.com/rollup/rollup/pull/4972): Configure Renovate (@renovate[bot]) + +## 3.21.3 + +_2023-05-02_ + +### Bug Fixes + +- Run `process.exit()` when Rollup CLI finishes successfully to solve issues on some systems (#4969) + +### Pull Requests + +- [#4954](https://github.com/rollup/rollup/pull/4954): test: enable typecheck for \_config files (@antfu) +- [#4969](https://github.com/rollup/rollup/pull/4969): Automatically force close Rollup when done (@lukastaegert) + +## 3.21.2 + +_2023-04-30_ + +### Bug Fixes + +- Mark global functions that trigger iterators as impure for now (#4955) + +### Pull Requests + +- [#4955](https://github.com/rollup/rollup/pull/4955): fix: mark some known globals or their functions as impure ( @TrickyPi) + +## 3.21.1 + +_2023-04-29_ + +### Bug Fixes + +- Make sure call arguments are properly deoptimized when a function uses the `arguments` variable (#4965) + +### Pull Requests + +- [#4957](https://github.com/rollup/rollup/pull/4957): Update dependencies (@lukastaegert) +- [#4964](https://github.com/rollup/rollup/pull/4964): Fix REPL in dev (@lukastaegert) +- [#4965](https://github.com/rollup/rollup/pull/4965): Ensure arguments are deoptimized when arguments variable is used (@lukastaegert) +- [#4967](https://github.com/rollup/rollup/pull/4967): Log REPL output to console (@lukastaegert) + +## 3.21.0 + +_2023-04-23_ + +### Features + +- Support tree-shaking of named exports in dynamic imports when using destructuring and similar patterns (#4952) + +### Pull Requests + +- [#4952](https://github.com/rollup/rollup/pull/4952): feat: tree-shake deterministic dynamic imports (@antfu) + +## 3.20.7 + +_2023-04-21_ + +### Bug Fixes + +- Properly track array element mutations when iterating with a for-of loop (#4949) +- Handle default exporting an anonymous class that extends another class (#4950) + +### Pull Requests + +- [#4943](https://github.com/rollup/rollup/pull/4943): Add a test for reserved keywords used as import/export specifiers (@Andarist) +- [#4949](https://github.com/rollup/rollup/pull/4949): Deoptimize right side in for-of loops (@lukastaegert) +- [#4950](https://github.com/rollup/rollup/pull/4950): Support default exported classes that extend other classes ( @lukastaegert) + +## 3.20.6 + +_2023-04-18_ + +### Bug Fixes + +- Revert handling of non-JS import and export names due to regressions (#4914) + +### Pull Requests + +- [#4914](https://github.com/rollup/rollup/pull/4914): feat: add locales in vitepress config (@iDestin) +- [#4946](https://github.com/rollup/rollup/pull/4946): Revert #4939 for now (@lukastaegert) + +## 3.20.5 + +_2023-04-18_ + +### Bug Fixes + +- Handle import and export names that are not valid JavaScript identifiers (#4939) + +### Pull Requests + +- [#4939](https://github.com/rollup/rollup/pull/4939): Fixed imports/exports that are illegal identifiers in the es output (@Andarist) +- [#4941](https://github.com/rollup/rollup/pull/4941): Reinstate global styles (@lukastaegert) + +## 3.20.4 + +_2023-04-17_ + +### Bug Fixes + +- Do not remove breaks statements after switch statements with conditional breaks (#4937) + +### Pull Requests + +- [#4937](https://github.com/rollup/rollup/pull/4937): fix: handle conditional breaks in nested switch statement cases ( @TrickyPi and @lukastaegert) + +## 3.20.3 + +_2023-04-16_ + +### Bug Fixes + +- Reduce memory consumption for function call parameter analysis (#4938) +- Fix types for `shouldTransformCachedModule` (#4932) + +### Pull Requests + +- [#4925](https://github.com/rollup/rollup/pull/4925): chore: repl style add scoped (@btea) +- [#4926](https://github.com/rollup/rollup/pull/4926): docs: Update the x_google_ignorelist url (@jecfish) +- [#4932](https://github.com/rollup/rollup/pull/4932): Allow shouldTransformCachedModule to return null (@bluwy) +- [#4935](https://github.com/rollup/rollup/pull/4935): Bump peter-evans/create-or-update-comment from 2 to 3 ( @dependabot[bot]) +- [#4936](https://github.com/rollup/rollup/pull/4936): Disable puppeteer sandbox to fix Vercel deployment ( @lukastaegert) +- [#4938](https://github.com/rollup/rollup/pull/4938): Improve memory usage for parameter deoptimizations ( @lukastaegert) + +## 3.20.2 + +_2023-03-24_ + +### Bug Fixes + +- Fix a crash when using a manual chunk entry that is not already included in the module graph (#4921) +- Fix a crash when reporting a warning with incorrect sourcemap information (#4922) + +### Pull Requests + +- [#4921](https://github.com/rollup/rollup/pull/4921): Handle manual chunks where the entry is not part of the module graph (@lukastaegert) +- [#4922](https://github.com/rollup/rollup/pull/4922): Do not fail if the location of a warning is outside the original source (@lukastaegert) + +## 3.20.1 + +_2023-03-23_ + +### Bug Fixes + +- Fix returned file name from this.getFileName when assets are deduplicated (#4919) + +### Pull Requests + +- [#4919](https://github.com/rollup/rollup/pull/4919): Only set asset names when finalizing (@lukastaegert) + +## 3.20.0 + +_2023-03-20_ + +### Features + +- Allow dynamically imported files to have synthetic named exports when preserving modules (#4913) + +### Bug Fixes + +- Use deterministic file name when emitting several files with same source (#4912) +- Fix a crash when dynamically importing a file with synthetic named exports when preserving modules (#4913) + +### Pull Requests + +- [#4912](https://github.com/rollup/rollup/pull/4912): fix: make file name deterministic in parallel emits (fix #4909) ( @sun0day) +- [#4913](https://github.com/rollup/rollup/pull/4913): Provide synthetic namespace for dynamic imports when perserving modules (@lukastaegert) + +## 3.19.1 + +_2023-03-10_ + +### Bug Fixes + +- Produce valid code when the first statement in aclass static block is tree-shaken (#4898) + +### Pull Requests + +- [#4898](https://github.com/rollup/rollup/pull/4898): fix: set a correct node location for static blocks (@TrickyPi) +- [#4900](https://github.com/rollup/rollup/pull/4900): docs: fix table at `output.sanitizeFileName` section (@0x009922) + +## 3.19.0 + +_2023-03-09_ + +### Features + +- Make reassignment tracking of call parameters more specific to no lose information when an object is passed to a function (#4892) + +### Pull Requests + +- [#4890](https://github.com/rollup/rollup/pull/4890): Fix `npm run dev` (@lukastaegert) +- [#4892](https://github.com/rollup/rollup/pull/4892): Only selectively deoptimize call parameters (@lukastaegert) +- [#4897](https://github.com/rollup/rollup/pull/4897): Pre-render mermaid graphs on website (@lukastaegert) + +## 3.18.0 + +_2023-03-01_ + +### Features + +- Add `experimentalLogSideEffects` to log the first detected side effect in every module (#4871) +- Ignore-list sourcemaps of files inside node_modules by default (#4877) + +### Pull Requests + +- [#4871](https://github.com/rollup/rollup/pull/4871): Add experimental logging for side effects (@lukastaegert) +- [#4877](https://github.com/rollup/rollup/pull/4877): feat: mark files in a `node_modules` as ignore-listed by default (@bmeurer) +- [#4880](https://github.com/rollup/rollup/pull/4880): build: use @rollup/plugin-replace to replace chokidar fsevents ( @dnalborczyk) +- [#4887](https://github.com/rollup/rollup/pull/4887): Refactor (@dnalborczyk) + +## 3.17.3 + +_2023-02-25_ + +### Bug Fixes + +- Handle non-URL-safe characters when poly-filling import.meta.url (#4875) + +### Pull Requests + +- [#4870](https://github.com/rollup/rollup/pull/4870): fix: style optimization in dark mode (@huodoushigemi) +- [#4875](https://github.com/rollup/rollup/pull/4875): Fix transformation of `import.meta.url` in CommonJS (@fasttime) +- [#4876](https://github.com/rollup/rollup/pull/4876): fix: wrong params of the transform hook (@ZzqiZQute) +- [#4878](https://github.com/rollup/rollup/pull/4878): Improve test stability (@lukastaegert) + +## 3.17.2 + +_2023-02-20_ + +### Bug Fixes + +- Do not omit code if a file that only re-exports a used variable has `moduleSideEffects` set to `true` (#4867) +- Add missing `needsCodeReference` property in TypeScript for asset tree-shaking (#4868) +- Add correct side effect configuration for additional Object and Promise methods (#4323) + +### Pull Requests + +- [#4323](https://github.com/rollup/rollup/pull/4323): feat: add known globals (@dnalborczyk) +- [#4867](https://github.com/rollup/rollup/pull/4867): Include side effects of re-exporters unless they have moduleSideEffects: false (@lukastaegert) +- [#4868](https://github.com/rollup/rollup/pull/4868): Add `needsCodeReference` property to `EmittedAsset` (@sapphi-red) + +## 3.17.1 + +_2023-02-18_ + +### Bug Fixes + +- Add TypeScript types for `loadConfigFile` (#4853) +- Fix an issue that could include unused classes in the bundle if their super class was in a file with `moduleSideEffects: false` (#4866) + +### Pull Requests + +- [#4853](https://github.com/rollup/rollup/pull/4853): feat: export loadConfigFile type (@TrickyPi) +- [#4866](https://github.com/rollup/rollup/pull/4866): Do not mark variable access in files without side effects as TDZ (@lukastaegert) + +## 3.17.0 + +_2023-02-18_ + +### Features + +- Deprecate `experimentalDeepDynamicChunkOptimization` and always run the full chunk generation algorithm (#4862) + +### Bug Fixes + +- Fix an issue that caused very slow builds for projects with over 1000 dynamic imports when `experimentalDeepDynamicChunkOptimization` was enabled (#4862) + +### Pull Requests + +- [#4862](https://github.com/rollup/rollup/pull/4862): Improve chunking performance (@lukastaegert) + +## 3.16.0 + +_2023-02-17_ + +### Features + +- Support `output.sourcemapIgnoreList` option to mark file sources as ignored in the `x_google_ignoreList` attribute of the resulting sourcemap (#4848) +- Support sourcemaps where `sourcesContent` contains `null` entries (#4846) +- Allow explicitly passing `true` for the `cache` option to override Vite's default (#4859) + +### Bug Fixes + +- Fix an issue where unrelated side effects spilled into other chunks when using the `experimentalMinChunkSize` option ( #4851) + +### Pull Requests + +- [#4846](https://github.com/rollup/rollup/pull/4846): Update magic-string and adjust types. (@bmeurer) +- [#4848](https://github.com/rollup/rollup/pull/4848): Introduce `sourcemapIgnoreList` predicate. (@bmeurer) +- [#4851](https://github.com/rollup/rollup/pull/4851): Fix chunk graph update when merging chunks for minChunkSize ( @lukastaegert) +- [#4852](https://github.com/rollup/rollup/pull/4852): docs: make api params more readable (@cunzaizhuyi) +- [#4856](https://github.com/rollup/rollup/pull/4856): simplify code in includeStatements (@TrickyPi) +- [#4859](https://github.com/rollup/rollup/pull/4859): Allow to pass "true" to InputOptions.cache (@danielrentz) + +## 3.15.0 + +_2023-02-10_ + +### Features + +- Do not consider instantiating a constructor a side effect if it adds properties to "this" and is instantiated elsewhere (#4842) + +### Bug Fixes + +- Improve side effect detection in constructors (#4842) + +### Pull Requests + +- [#4842](https://github.com/rollup/rollup/pull/4842): fix: add this option to context.ignore (@TrickyPi) +- [#4843](https://github.com/rollup/rollup/pull/4843): fixed the logo link (@oMatheuss) +- [#4844](https://github.com/rollup/rollup/pull/4844): Update index.md (@cunzaizhuyi) +- [#4845](https://github.com/rollup/rollup/pull/4845): docs: fix style (@TrickyPi) + +## 3.14.0 + +_2023-02-05_ + +### Features + +- Add `experimentalDeepDynamicChunkOptimization` option to produce fewer chunks from dynamic imports (#4837) + +### Pull Requests + +- [#4837](https://github.com/rollup/rollup/pull/4837): Add flag to re-enable deep dynamic chunk optimization ( @lukastaegert) +- [#4839](https://github.com/rollup/rollup/pull/4839): fix: correct incorrect assertions (@TrickyPi) + +## 3.13.0 + +_2023-02-03_ + +### Features + +- Prevent chunk cycles when using `experimentalMinChunkSize` (#4723) + +### Pull Requests + +- [#4723](https://github.com/rollup/rollup/pull/4723): Improve minChunkSize algorithm (@lukastaegert) +- [#4833](https://github.com/rollup/rollup/pull/4833): docs: Fix typo (@mturoci) +- [#4835](https://github.com/rollup/rollup/pull/4835): Tables in docs (@lukastaegert) + +## 3.12.1 + +_2023-02-01_ + +### Bug Fixes + +- Handle self-references in class static blocks and construtors when the class is renamed (#4827) +- Improve warnings when creating circular chunks taht reexport variables (#4829) + +### Pull Requests + +- [#4827](https://github.com/rollup/rollup/pull/4827): fix: use the original class name in the class body (@TrickyPi) +- [#4829](https://github.com/rollup/rollup/pull/4829): Improve and fix cross-chunk-reexport warning (@lukastaegert) +- [#4830](https://github.com/rollup/rollup/pull/4830): Add Algolia doc search (@lukastaegert) +- [#4831](https://github.com/rollup/rollup/pull/4831): Add warning not to add assets directly to the bundle ( @lukastaegert) + +## 3.12.0 + +_2023-01-28_ + +### Features + +- Change generated external namespace reexport helper code for CommonJS to better work with NodeJS named export detection (#4826) + +### Pull Requests + +- [#4825](https://github.com/rollup/rollup/pull/4825): Add and use anchors for nested options (@lukastaegert) +- [#4826](https://github.com/rollup/rollup/pull/4826): Use old namespace reexport code pattern for better Node support ( @lukastaegert) + +## 3.11.0 + +_2023-01-26_ + +### Features + +- Support opt-in tree-shaking for emitted assets based on code references (#4805) + +### Bug Fixes + +- Adapt documentation references in Rollup to new website (#4807) + +### Pull Requests + +- [#4805](https://github.com/rollup/rollup/pull/4805): feat: add needsCodeReference field to EmittedAsset (@TrickyPi) +- [#4807](https://github.com/rollup/rollup/pull/4807): Rewrite website in Vitepress and merge it into the main repository (@lukastaegert) +- [#4816](https://github.com/rollup/rollup/pull/4816): web-publisher: Update docs/faqs/index.md (@PuruVJ) +- [#4819](https://github.com/rollup/rollup/pull/4819): Replace fs-extra with built-ins (@dnalborczyk) +- [#4820](https://github.com/rollup/rollup/pull/4820): Introduce timeout-minutes in Github actions ci (@dnalborczyk) +- [#4822](https://github.com/rollup/rollup/pull/4822): Tweak document landing page (@sapphi-red) +- [#4823](https://github.com/rollup/rollup/pull/4823): Minor migration guide improvements (@sapphi-red) +- [#4824](https://github.com/rollup/rollup/pull/4824): Add most options to the REPL (@lukastaegert) + +## 3.10.1 + +_2023-01-20_ + +### Bug Fixes + +- Fix some crashes when using optional chaining with namespaces and improve tree-shaking (#4812) +- Avoid wrongly removed code when using optional chaining (#4812) + +### Pull Requests + +- [#4809](https://github.com/rollup/rollup/pull/4809): fix: rollup bin file is in dist folder (@saibotsivad) +- [#4812](https://github.com/rollup/rollup/pull/4812): Rework tree-shaking support for optional chaining (@lukastaegert) + +## 3.10.0 + +_2023-01-12_ + +### Features + +- Add information about the resolving plugin to resolved ids (#4789) +- Improve treeshaking for optional chaining when the root is nullish (#4797) + +### Bug Fixes + +- Remove unnecessary internal defaults for acorn options (#4786) + +### Pull Requests + +- [#4785](https://github.com/rollup/rollup/pull/4785): Use @jridgewell/sourcemap-codec (@bluwy) +- [#4786](https://github.com/rollup/rollup/pull/4786): Remove default acorn options + other fixes (@dnalborczyk) +- [#4789](https://github.com/rollup/rollup/pull/4789): feat: add `resolvedBy` field to `ResolvedId` (@TrickyPi) +- [#4794](https://github.com/rollup/rollup/pull/4794): fix: import can be shortened (@cunzaizhuyi) +- [#4796](https://github.com/rollup/rollup/pull/4796): Update dependencies (@lukastaegert) +- [#4797](https://github.com/rollup/rollup/pull/4797): feat: treeshake for optional chaining (@antfu) + +## 3.9.1 + +_2023-01-02_ + +### Bug Fixes + +- Sort keys in generated dynamic namespace objects (#4780) +- Do not consider Array.group to be side effect free as the specs have changed (#4779) + +### Pull Requests + +- [#4777](https://github.com/rollup/rollup/pull/4777): Import from node:fs/promises (@dnalborczyk) +- [#4778](https://github.com/rollup/rollup/pull/4778): Bump deps (@dnalborczyk) +- [#4779](https://github.com/rollup/rollup/pull/4779): Remove array grouping (web compat issue) (@dnalborczyk) +- [#4780](https://github.com/rollup/rollup/pull/4780): Sort namespace object keys (@dnalborczyk) +- [#4781](https://github.com/rollup/rollup/pull/4781): Use Set and builtin-modules package (@dnalborczyk) +- [#4782](https://github.com/rollup/rollup/pull/4782): Use more restrictive types (@dnalborczyk) + +## 3.9.0 + +_2022-12-28_ + +### Features + +- Support ES2022 arbitrary module namespace identifiers (#4770) +- Add optional `version` property to plugin type (#4771) + +### Pull Requests + +- [#4768](https://github.com/rollup/rollup/pull/4768): Fix small typo in 999-big-list-of-options.md (@ericmutta) +- [#4769](https://github.com/rollup/rollup/pull/4769): docs: add a instruction about how to run one test on your local computer (@TrickyPi) +- [#4770](https://github.com/rollup/rollup/pull/4770): Add support for arbitrary module namespace identifiers ( @lukastaegert) +- [#4771](https://github.com/rollup/rollup/pull/4771): Add `version` property to Plugin type (@Septh) + +## 3.8.1 + +_2022-12-23_ + +### Bug Fixes + +- Reduce memory footprint when explicitly passing `cache: false` (#4762) +- Fix a crash when preserving modules and reexporting namespaces (#4766) + +### Pull Requests + +- [#4762](https://github.com/rollup/rollup/pull/4762): Improve AST garbage collection (@bluwy) +- [#4766](https://github.com/rollup/rollup/pull/4766): Fix handling of namespace reexports when preserving modules ( @lukastaegert) + +## 3.8.0 + +_2022-12-22_ + +### Features + +- Deduplicate ESM exports and reexports when preserving modules (#4759) + +### Bug Fixes + +- Handle files that are emitted as a side effect of the manualChunks option (#4759) + +### Pull Requests + +- [#4759](https://github.com/rollup/rollup/pull/4759): feat: deduplicate reexports and renderedExports to simplify output (@TrickyPi) +- [#4761](https://github.com/rollup/rollup/pull/4761): Support emitting files via manualChunks in output (@lukastaegert) +- [#4763](https://github.com/rollup/rollup/pull/4763): docs: update outdated info (@TrickyPi) + +## 3.7.5 + +_2022-12-17_ + +### Bug Fixes + +- Avoid name shadowing when default exporting a class that matches the name of another class (#4756) +- Do not display the error message both in a separate line and in the stack trace in rollup CLI (#4749) +- Make type of `RollupWarning.cause` compatible with `Error.cause` (#4757) +- Do not swallow side effects when interacting with modules namespaces nested in another object (#4758) + +### Pull Requests + +- [#4749](https://github.com/rollup/rollup/pull/4749): feat: simplify `stack` info in cli error (@TrickyPi) +- [#4756](https://github.com/rollup/rollup/pull/4756): Avoid name conflicts for default exported classes (@lukastaegert) +- [#4757](https://github.com/rollup/rollup/pull/4757): fix: RollupLog cause allow unknown (@Shinigami92) +- [#4758](https://github.com/rollup/rollup/pull/4758): Correctly handle side effects when a namespace is nested in an object (@lukastaegert) + +## 3.7.4 + +_2022-12-13_ + +### Bug Fixes + +- Do not remove calls to `.exec` and `.test` for included stateful regular expressions (#4742) + +### Pull Requests + +- [#4742](https://github.com/rollup/rollup/pull/4742): fix: check whether RegExp have the global or sticky flags set ( @TrickyPi) + +## 3.7.3 + +_2022-12-11_ + +### Bug Fixes + +- Ensure `this.getFileName` no longer returns a placeholder as soon as hash placeholders have been resolved (#4747) + +### Pull Requests + +- [#4747](https://github.com/rollup/rollup/pull/4747): provide hashed file name when using this.getFileName in generateBundle (@lukastaegert) + +## 3.7.2 + +_2022-12-10_ + +### Bug Fixes + +- Improve chunk generation performance when one module is dynamically imported by many other modules (#4736) + +### Pull Requests + +- [#4736](https://github.com/rollup/rollup/pull/4736): Improve chunk assignment performance (@lukastaegert) + +## 3.7.1 + +_2022-12-09_ + +### Bug Fixes + +- Ad a hint to use @rollup/plugin-json when imports from a JSON file are not found (#4741) + +### Pull Requests + +- [#4741](https://github.com/rollup/rollup/pull/4741): fix: provide json hint when importing a no export json file ( @TrickyPi) + +## 3.7.0 + +_2022-12-08_ + +### Features + +- Do not treat `.test` and `.exec` on regular expressions as side effects (#4737) + +### Pull Requests + +- [#4737](https://github.com/rollup/rollup/pull/4737): feat: add sutiable RegExp prototype methods (@TrickyPi) + +## 3.6.0 + +_2022-12-05_ + +### Features + +- extend `this.getModuleInfo` with information about exports (#4731) + +### Pull Requests + +- [#4731](https://github.com/rollup/rollup/pull/4731): feat: add `exports` and `exportedBindings` to `Module` class ( @TrickyPi) + +## 3.5.1 + +_2022-12-01_ + +### Bug Fixes + +- Accept functions returning a config in defineConfig (#4728) + +### Pull Requests + +- [#4728](https://github.com/rollup/rollup/pull/4728): Overload defineConfig to accept a RollupOptionsFunction parameter (@Septh) + +## 3.5.0 + +_2022-11-27_ + +### Features + +- Add `treeshake.manualPureFunctions` to override static analysis for explicit function names (#4718) + +### Bug Fixes + +- Do not throw when a plugin uses `this.load` without awaiting its result (#4725) + +### Pull Requests + +- [#4718](https://github.com/rollup/rollup/pull/4718): Add simple way to manually declare pure functions (@lukastaegert) +- [#4725](https://github.com/rollup/rollup/pull/4725): Fix isIncluded error when using rollup-plugin-typescript2 ( @lukastaegert) + +## 3.4.0 + +_2022-11-22_ + +### Features + +- Do not keep unused `Object.freeze` calls on object literals (#4720) + +### Pull Requests + +- [#4720](https://github.com/rollup/rollup/pull/4720): Only consider Object.freeze a side effect if the argument is used (@lukastaegert) + +## 3.3.0 + +_2022-11-12_ + +### Features + +- Add "experimentalMinChunkSize" option to merge smaller chunks into larger ones (#4705) +- Automatically deduplicate assets again when the source is a `Buffer` (#4712) +- Deduplicate `Buffer` with `string` assets (#4712) + +### Bug Fixes + +- Support plugins with object hooks when using `perf: true` (#4707) + +### Pull Requests + +- [#4702](https://github.com/rollup/rollup/pull/4702): docs: add additional tips for heap out of memory (@benmccann) +- [#4705](https://github.com/rollup/rollup/pull/4705): Allow to define minimum chunk size limit (@lukastaegert) +- [#4707](https://github.com/rollup/rollup/pull/4707): Fix perf timers for object hooks (@lukastaegert) +- [#4710](https://github.com/rollup/rollup/pull/4710): Update terser docs (@nikolas) +- [#4712](https://github.com/rollup/rollup/pull/4712): feat: deduplicate assets with buffer source (@patak-dev) + +## 3.2.5 + +_2022-11-01_ + +### Bug Fixes + +- We deconflicting classes, ensure the original class name still does not shadow variables (#4697) + +### Pull Requests + +- [#4697](https://github.com/rollup/rollup/pull/4697): Prevent class ids from shadowing other variables (@lukastaegert) + +## 3.2.4 + +_2022-10-31_ + +### Bug Fixes + +- Always use forward slashes in chunk ids when preserving modules, even on Windows (#4693) +- Escape problematic characters in ids when rewriting `import.meta.url` (#4693) + +### Pull Requests + +- [#4685](https://github.com/rollup/rollup/pull/4685): update package-lock version (@jerry-lllman) +- [#4689](https://github.com/rollup/rollup/pull/4689): Update 07-tools.md (@cokert) +- [#4693](https://github.com/rollup/rollup/pull/4693): Use correct import.meta.url slashes on Windows (@lukastaegert) + +## 3.2.3 + +_2022-10-18_ + +### Bug Fixes + +- Fix an issue whre Rollup confused `new.target` with `import.meta` (#4679) +- Ensure that Rollup does not make assumptions about the value of unknown namespace import members (#4684) + +### Pull Requests + +- [#4679](https://github.com/rollup/rollup/pull/4679): Do not rewrite new.target (@lukastaegert) +- [#4683](https://github.com/rollup/rollup/pull/4683): Remove typo in resolveId documentation (@ChrispyChris) +- [#4684](https://github.com/rollup/rollup/pull/4684): Return correct values for unknown namespace members ( @lukastaegert) + +## 3.2.2 + +_2022-10-16_ + +### Bug Fixes + +- Do not hang/crash on hashbang comments in input modules (#4676) + +### Pull Requests + +- [#4675](https://github.com/rollup/rollup/pull/4675): refactor: improve & simplify types (@sxzz) +- [#4676](https://github.com/rollup/rollup/pull/4676): Ignore hashhbang comments (@lukastaegert) + +## 3.2.1 + +_2022-10-16_ + +### Bug Fixes + +- Rewrite class declarations to preserve their .name property if necessary (#4674) + +### Pull Requests + +- [#4674](https://github.com/rollup/rollup/pull/4674): Preserve rendered class names (@lukastaegert) + +## 3.2.0 + +_2022-10-15_ + +### Features + +- Support providing Promises as plugins like Vite (#4671) + +### Pull Requests + +- [#4666](https://github.com/rollup/rollup/pull/4666): Add unicorn plugin (@lukastaegert) +- [#4667](https://github.com/rollup/rollup/pull/4667): refactor: improve types (@sxzz) +- [#4668](https://github.com/rollup/rollup/pull/4668): fix: nested plugin in options stage (@sxzz) +- [#4669](https://github.com/rollup/rollup/pull/4669): refactor: merge duplicate imports (@c0dedance) +- [#4670](https://github.com/rollup/rollup/pull/4670): docs: fix minor typo in migration documentation (@ThisIsMissEm) +- [#4671](https://github.com/rollup/rollup/pull/4671): feat: support async plugins (@sxzz) + +## 3.1.0 + +_2022-10-12_ + +### Features + +- Support using arrays of plugins as plugins like Vite (#4657) + +### Pull Requests + +- [#4657](https://github.com/rollup/rollup/pull/4657): feat: support nested plugin (@sxzz) + +## 3.0.1 + +_2022-10-12_ + +### Bug Fixes + +- Fix installation on Windows (#4662) +- Avoid missing parameters that are only used in a destructuring initializer (#4663) + +### Pull Requests + +- [#4661](https://github.com/rollup/rollup/pull/4661): Enforce type imports (@lukastaegert) +- [#4662](https://github.com/rollup/rollup/pull/4662): fix: missing "node" causes run script error (@c0dedance) +- [#4663](https://github.com/rollup/rollup/pull/4663): Ensure the initializer of a destructuring declaration is always included if the id is included (@lukastaegert) +- [#4664](https://github.com/rollup/rollup/pull/4664): fix: remove lint:js:nofix script redundancy options (@c0dedance) + +## 3.0.0 + +_2022-10-11_ + +### Breaking Changes + +#### General Changes + +- Rollup now requires at least Node 14.18.0 to run (#4548 and #4596) +- The browser build has been split into a separate package `@rollup/browser` (#4593) +- The node build uses the `node:` prefix for imports of builtin modules (#4596) +- Some previously deprecated features have been removed (#4552): + - Some plugin context functions have been removed: + - `this.emitAsset()`: use `this.emitFile()` + - `this.emitChunk()`: use `this.emitFile()` + - `this.getAssetFileName()`: use `this.getFileName()` + - `this.getChunkFileName()`: use `this.getFileName()` + - `this.isExternal()`: use `this.resolve()` + - `this.resolveId()`: use `this.resolve()` + - The `resolveAssetUrl` plugin hook has been removed: use `resolveFileUrl` + - Rollup no longer passes `assetReferenceId` or `chunkReferenceId` parameters to `resolveFileUrl` + - The `treeshake.pureExternalModules` option has been removed: use `treeshake.moduleSideEffects: 'no-external'` + - You may no longer use `true` or `false` for `output.interop`. As a replacement for `true`, you can use "compat" + - Emitted assets no longer have an `isAsset` flag in the bundle + - Rollup will no longer fix assets added directly to the bundle by adding the `type: "asset"` field +- Some features that were previously marked for deprecation now show warnings when used (#4552): + - Some options have been deprecated: + - `inlineDynamicImports` as part of the input options: use `output. inlineDynamicImports` + - `manualChunks` as part of the input options: use `output. manualChunks ` + - `maxParallelFileReads`: use `maxParallelFileOps + - `output.preferConst`: use `output.generatedCode.constBindings` + - `output.dynamicImportFunction`: use the `renderDynamicImport` plugin hook + - `output.namespaceToStringTag`: use `output.generatedCode.symbols` + - `preserveModules` as part of the input options: use `output. preserveModules ` + - You should no longer access `this.moduleIds` in plugins: use `this.getModuleIds()` + - You should no longer access `this.getModuleInfo(...).hasModuleSideEffects` in plugins: use `this.getModuleInfo(...).moduleSideEffects` +- Configuration files are only bundled if either the `--configPlugin` or the `--bundleConfigAsCjs` options are used. The configuration is bundled to an ES module unless the `--bundleConfigAsCjs` option is used. In all other cases, configuration is now loaded using Node's native mechanisms (#4574 and #4621) +- The properties attached to some errors have been changed so that there are fewer different possible properties with consistent types (#4579) +- Some errors have been replaced by others (ILLEGAL_NAMESPACE_REASSIGNMENT -> ILLEGAL_REASSIGNMENT, NON_EXISTENT_EXPORT -> MISSING_EXPORT) (#4579) +- Files in `rollup/dist/*` can only be required using their file extension (#4581) +- The `loadConfigFile` helper now has a named export of the same name instead of a default export (#4581) +- When using the API and sourcemaps, sourcemap comments are contained in the emitted files and sourcemaps are emitted as regular assets (#4605) +- Watch mode no longer uses Node's EventEmitter but a custom implementation that awaits Promises returned from event handlers (#4609) +- Assets may only be deduplicated with previously emitted assets if their source is a `string` (#4644) +- By default, Rollup will keep external dynamic imports as `import(…)` in commonjs output unless `output.dynamicImportInCjs` is set to false (#4647) + +#### Changes to Rollup Options + +- As functions passed to `output.banner/footer/intro/outro` are now called per-chunk, they should be careful to avoid performance-heavy operations (#4543) +- `entryFileNames/chunkFileNames` functions now longer have access to the rendered module information via `modules`, only to a list of included `moduleIds` (#4543) +- The path of a module is no longer prepended to the corresponding chunk when preserving modules (#4565) +- When preserving modules, the `[name]` placeholder (as well as the `chunkInfo.name` property when using a function) now includes the relative path of the chunk as well as optionally the file extension if the extension is not one of `.js`, `.jsx`, `.mjs`, `.cjs`, `.ts`, `.tsx`, `.mts`, or `.cts` (#4565) +- The `[ext]`, `[extName]` and `[assetExtName]` placeholders are no longer supported when preserving modules (#4565) +- The `perf` option no longer collects timings for the asynchronous part of plugin hooks as the readings were wildly inaccurate and very misleading, and timings are adapted to the new hashing algorithm (#4566) +- Change the default value of `makeAbsoluteExternalsRelative` to "ifRelativeSource" so that absolute external imports will no longer become relative imports in the output, while relative external imports will still be renormalized ( #4567) +- Change the default for `output.generatedCode.reservedNamesAsProps` to no longer quote properties like `default` by default (#4568) +- Change the default for `preserveEntrySignatures` to "exports-only" so that by default, empty facades for entry chunks are no longer created (#4576) +- Change the default for `output.interop` to "default" to better align with NodeJS interop (#4611) +- Change the default for `output.esModule` to "if-default-prop", which only adds \_\_esModule when the default export would be a property (#4611) +- Change the default for `output.systemNullSetters` to `true`, which requires at least SystemJS 6.3.3 (#4649) + +#### Plugin API Changes + +- Plugins that add/change/remove imports or exports in `renderChunk` should make sure to update `ChunkInfo.imports/importedBindings/exports` accordingly (#4543) +- The order of plugin hooks when generating output has changed (#4543) +- Chunk information passed to `renderChunk` now contains names with hash placeholders instead of final names, which will be replaced when used in the returned code or `ChunkInfo.imports/importedBindings/exports` (#4543 and #4631) +- Hooks defined in output plugins will now run after hooks defined in input plugins (used to be the other way around) ( #3846) + +### Features + +- Functions passed to `output.banner/footer/intro/outro` are now called per-chunk with some chunk information (#4543) +- Plugins can access the entire chunk graph via an additional parameter in `renderChunk` (#4543) +- Chunk hashes only depend on the actual content of the chunk and are otherwise stable against things like renamed/moved source files or changed module resolution order (#4543) +- The length of generated file hashes can be customized both globally and per-chunk (#4543) +- When preserving modules, the regular `entryFileNames` logic is used and the path is included in the `[name]` property. This finally gives full control over file names when preserving modules (#4565) +- `output.entryFileNames` now also supports the `[hash]` placeholder when preserving modules (#4565) +- The `perf` option will now collect (synchronous) timings for all plugin hooks, not just a small selection (#4566) +- All errors thrown by Rollup have `name: RollupError` now to make clearer that those are custom error types (#4579) +- Error properties that reference modules (such as id and ids) will now always contain the full ids. Only the error message will use shortened ids (#4579) +- Errors that are thrown in response to other errors (e.g. parse errors thrown by acorn) will now use the standardized cause property to reference the original error (#4579) +- If sourcemaps are enabled, files will contain the appropriate sourcemap comment in `generateBundle` and sourcemap files are available as regular assets (#4605) +- Returning a Promise from an event handler attached to a RollupWatcher instance will make Rollup wait for the Promise to resolve (#4609) +- There is a new value "compat" for output.interop that is similar to "auto" but uses duck-typing to determine if there is a default export (#4611) +- There is a new value "if-default-prop" for esModule that only adds an `__esModule` marker to the bundle if there is a default export that is rendered as a property (#4611) +- Rollup can statically resolve checks for `foo[Symbol.toStringTag]` to "Module" if foo is a namespace (#4611) +- There is a new CLI option `--bundleConfigAsCjs` which will force the configuration to be bundled to CommonJS (#4621) +- Import assertions for external imports that are present in the input files will be retained in ESM output (#4646) +- Rollup will warn when a module is imported with conflicting import assertions (#4646) +- Plugins can add, remove or change import assertions when resolving ids (#4646) +- The `output.externalImportAssertions` option allows to turn off emission of import assertions (#4646) +- Use `output.dynamicImportInCjs` to control if dynamic imports are emitted as `import(…)` or wrapped `require(…)` when generating commonjs output (#4647) + +### Bug Fixes + +- Chunk hashes take changes in `renderChunk`, e.g. minification, into account (#4543) +- Hashes of referenced assets are properly reflected in the chunk hash (#4543) +- No longer warn about implicitly using default export mode to not tempt users to switch to named export mode and break Node compatibility (#4624) +- Avoid performance issues when emitting thousands of assets (#4644) + +### Pull Requests + +- [#3846](https://github.com/rollup/rollup/pull/3846): [v3.0] Run output plugins last (@aleclarson) +- [#4543](https://github.com/rollup/rollup/pull/4543): [v3.0] New hashing algorithm that "fixes (nearly) everything" ( @lukastaegert) +- [#4548](https://github.com/rollup/rollup/pull/4548): [v3.0] Deprecate Node 12 (@lukastaegert) +- [#4552](https://github.com/rollup/rollup/pull/4552): [v3.0] Remove actively deprecated features, show warnings for other deprecated features (@lukastaegert) +- [#4558](https://github.com/rollup/rollup/pull/4558): [v3.0] Convert build scripts to ESM, update dependencies ( @lukastaegert) +- [#4565](https://github.com/rollup/rollup/pull/4565): [v3.0] Rework file name patterns when preserving modules ( @lukastaegert) +- [#4566](https://github.com/rollup/rollup/pull/4566): [v3.0] Restructure timings (@lukastaegert) +- [#4567](https://github.com/rollup/rollup/pull/4567): [v3.0] Change default for makeAbsoluteExternalsRelative ( @lukastaegert) +- [#4568](https://github.com/rollup/rollup/pull/4568): [v3.0] Change default for output.generatedCode.reservedNamesAsProps (@lukastaegert) +- [#4574](https://github.com/rollup/rollup/pull/4574): [v3.0] Better esm config file support (@lukastaegert) +- [#4575](https://github.com/rollup/rollup/pull/4575): [v3.0] Show deprecation warning for maxParallelFileReads ( @lukastaegert) +- [#4576](https://github.com/rollup/rollup/pull/4576): [v3.0] Change default for preserveEntrySignatures to exports-only (@lukastaegert) +- [#4579](https://github.com/rollup/rollup/pull/4579): [v3.0] Refine errors and warnings (@lukastaegert) +- [#4581](https://github.com/rollup/rollup/pull/4581): [v3.0] Use named export for loadConfigFile (@lukastaegert) +- [#4592](https://github.com/rollup/rollup/pull/4592): [v3.0] Port doc changes from #4572 and #4583 to 3.0 (@berniegp) +- [#4593](https://github.com/rollup/rollup/pull/4593): [v3.0] Browser build (@lukastaegert) +- [#4596](https://github.com/rollup/rollup/pull/4596): [v3.0] Use "node:" prefix for imports of node builtins ( @lukastaegert) +- [#4605](https://github.com/rollup/rollup/pull/4605): [v3.0] Better sourcemap emission (@lukastaegert) +- [#4609](https://github.com/rollup/rollup/pull/4609): [v3.0] Custom awaiting watch emitter (@lukastaegert) +- [#4611](https://github.com/rollup/rollup/pull/4611): [v3.0] Improve interop defaults (@lukastaegert) +- [#4621](https://github.com/rollup/rollup/pull/4621): [v3.0] Always try to load config files via Node if possible ( @lukastaegert) +- [#4624](https://github.com/rollup/rollup/pull/4624): [v3.0] Remove warning when using implicit default export mode ( @lukastaegert) +- [#4631](https://github.com/rollup/rollup/pull/4631): [v3.0] Use ASCII characters for hash placeholders (@lukastaegert) +- [#4644](https://github.com/rollup/rollup/pull/4644): [v3.0] Improve performance of asset emissions (@lukastaegert) +- [#4646](https://github.com/rollup/rollup/pull/4646): [v3.0] Basic support for import assertions (@lukastaegert) +- [#4647](https://github.com/rollup/rollup/pull/4647): [v3.0] Keep dynamic imports in CommonJS output (@lukastaegert) +- [#4649](https://github.com/rollup/rollup/pull/4649): [v3.0] Change default for systemNullSetters (@lukastaegert) +- [#4651](https://github.com/rollup/rollup/pull/4651): [v3.0] use compiler target ES2020 (@dnalborczyk) + +For previous changelogs, see + +- [Rollup 2.x](./CHANGELOG-2.md) +- [Rollup 1.x](./CHANGELOG-1.md) +- [Rollup 0.x](./CHANGELOG-0.md) diff --git a/CHANGELOG.md b/CHANGELOG.md index d451a32c84d..a8d44569da0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4502 +1,2457 @@ # rollup changelog -## 2.45.2 -*2021-04-13* +## 4.56.0 -### Bug Fixes -* Do not user a dynamic entry file name for naming a manual chunk (#4040) - -### Pull Requests -* [#4040](https://github.com/rollup/rollup/pull/4040): Prioritize manual chunk name over dynamic entry id (@lukastaegert) - -## 2.45.1 -*2021-04-10* - -### Bug Fixes -* Handle falsy return values from async plugin options hooks (#4039) - -### Pull Requests -* [#4039](https://github.com/rollup/rollup/pull/4039): Do not fail when returning null or undefined from an async options hook (@lukastaegert) - -## 2.45.0 -*2021-04-09* - -### Features -* Support private class instance methods and accessors (#4034) - -### Pull Requests -* [#4034](https://github.com/rollup/rollup/pull/4034): feat: add support for private class methods (@dnalborczyk) - -## 2.44.0 -*2021-03-29* - -### Features -* Add a new option `makeAbsoluteExternalsRelative` to opt out of renormalizing absolute external ids to relative ids (#4021) -* Extend the `resolveId` plugin hook to allow forcing or preventing renormalization of absolute external ids (#4021) -* Make the rendered code of individual modules available in the generated bundle (#4028) - -### Bug Fixes -* Handle objects with `__proto__` properties correctly (#4019) - -### Pull Requests -* [#4019](https://github.com/rollup/rollup/pull/4019): Deoptimize ObjectExpression when a `__proto__` property is present (@marijnh) -* [#4021](https://github.com/rollup/rollup/pull/4021): Improve absolute path handling (@lukastaegert) -* [#4026](https://github.com/rollup/rollup/pull/4026): chore: fix vscode launch config (change tdd to bdd) (@jameslahm) -* [#4027](https://github.com/rollup/rollup/pull/4027): Post comment for PRs from forks (@lukastaegert) -* [#4028](https://github.com/rollup/rollup/pull/4028): Expose rendered module code to generateBundle hook (@btd) - -## 2.43.1 -*2021-03-28* - -### Bug Fixes -* Prevent infinite recursions in certain scenarios when calling object properties (#4025) - -### Pull Requests -* [#4025](https://github.com/rollup/rollup/pull/4025): Handle recursive this mutation detection (@lukastaegert) - -## 2.43.0 -*2021-03-27* - -### Features -* Track side effects of function properties in objects for better tree-shaking (#4011) - -### Pull Requests -* [#4011](https://github.com/rollup/rollup/pull/4011): Disable pessimistic object deoptimization for calls when the called function doesn't ref this (@marijnh) -* [#4012](https://github.com/rollup/rollup/pull/4012): fix `sourcemap` reference in docs (@tjenkinson) -* [#4015](https://github.com/rollup/rollup/pull/4015): Use SIGTERM instead of SIGINT to kill test child processes in tests (@marijnh) - -## 2.42.4 -*2021-03-24* - -### Bug Fixes -* Do not discard plugin return values when using perf option (#4010) - -### Pull Requests -* [#4010](https://github.com/rollup/rollup/pull/4010): Return hook result inside promise with async timer end (@SuperOleg39) - -## 2.42.3 -*2021-03-22* - -### Bug Fixes -* Do not ignore `#__PURE__` comments in front of optional chaining expressions (#4007) - -### Pull Requests -* [#4007](https://github.com/rollup/rollup/pull/4007): Tree-shake pure call expressions with optional chaining (@lukastaegert) - -## 2.42.2 -*2021-03-22* - -### Bug Fixes -* Use correct import.meta.url in relative imports from transpiled config files (#4005) - -### Pull Requests -* [#4005](https://github.com/rollup/rollup/pull/4005): Use correct import.meta.url in config files (@lukastaegert) - -## 2.42.1 -*2021-03-20* - -### Bug Fixes -* Do not produce unhandled Promise rejections when plugins throw while using the `perf` option (#4004) - -### Pull Requests -* [#4004](https://github.com/rollup/rollup/pull/4004): Fixed unhandled promise rejections (@gluck) - -## 2.42.0 -*2021-03-19* - -### Features -* Prevent infinite loops when several plugins are using `this.resolve` in their resolveId hook (#4000) - -### Pull Requests -* [#4000](https://github.com/rollup/rollup/pull/4000): Break infinite loops in this.resolve (@lukastaegert) - -## 2.41.5 -*2021-03-18* - -### Bug Fixes -* Make sure unused property accesses of external namespaces can be tree-shaken (#4001) - -### Pull Requests -* [#4001](https://github.com/rollup/rollup/pull/4001): Do not count accessing members of an external namespace as side-effects (@lukastaegert) - -## 2.41.4 -*2021-03-16* - -### Bug Fixes -* Do not replace external namespace imports with individual named imports to avoid changing behaviour with regard to missing exports (#3999) - -### Pull Requests -* [#3999](https://github.com/rollup/rollup/pull/3999): Allow to safely probe external namespaces (@lukastaegert) - -## 2.41.3 -*2021-03-16* - -### Bug Fixes -* Always retain arguments passed to empty object pattern parameters (#3998) - -### Pull Requests -* [#3998](https://github.com/rollup/rollup/pull/3998): Do not create invalid code if a function argument is an empty object pattern (@lukastaegert) - -## 2.41.3 -*2021-03-16* - -### Bug Fixes -* Always retain arguments passed to empty object pattern parameters (#3998) - -### Pull Requests -* [#3998](https://github.com/rollup/rollup/pull/3998): Do not create invalid code if a function argument is an empty object pattern (@lukastaegert) - -## 2.41.2 -*2021-03-12* - -### Bug Fixes -* Also remove sourcemaps comments if plugins return a pre-made ast (#3987) - -### Pull Requests -* [#3987](https://github.com/rollup/rollup/pull/3987): Change removal of sourcemap comment (@yannayl) - -## 2.41.1 -*2021-03-11* - -### Pull Requests -* [#3990](https://github.com/rollup/rollup/pull/3990): Add browser sourcemap and remove log (@lukastaegert) - -## 2.41.0 -*2021-03-09* - -### Features -* Add option to `treeshake.propertyReadSideEffects` to keep all property accesses (#3985) - -### Bug Fixes -* Also respect pure comment annotations when a plugin provides an AST in the transform hook provided they use this.parse (#3981) - -### Pull Requests -* [#3981](https://github.com/rollup/rollup/pull/3981): Move pure comment annotation to Graph.contextParse (@yannayl) -* [#3985](https://github.com/rollup/rollup/pull/3985): implement --treeshake.propertyReadSideEffects=always to handle getters with side effects (@kzc) - -## 2.40.0 -*2021-02-26* - -### Features -* Make sure that entry point variable names take precedence over variable names in dependencies when deconflicting (#3977) - -### Bug Fixes -* Replace `:` in generated file names to prevent invalid files on Windows (#3972) - -### Pull Requests -* [#3972](https://github.com/rollup/rollup/pull/3972): Don't allow `:` in file names (@lukastaegert) -* [#3976](https://github.com/rollup/rollup/pull/3976): Add soft breaks to guide to improve mobile experience (@lukastaegert) -* [#3977](https://github.com/rollup/rollup/pull/3977): Reverse module deconflicting order (@lukastaegert) - -## 2.39.1 -*2021-02-23* - -### Bug Fixes -* Make sure local variables named Symbol, Object or Promise do not conflict with code generated by Rollup (#3971) - -### Pull Requests -* [#3964](https://github.com/rollup/rollup/pull/3964): Remove extra word (@jamonholmgren) -* [#3971](https://github.com/rollup/rollup/pull/3971): Avoid conflicts with local variables named Symbol, Object, Promise (@lukastaegert) - -## 2.39.0 -*2021-02-12* - -### Features -* Add "validate" option to verify generated chunks are valid JavaScript (#3952) - -### Bug Fixes -* Always add exports properties for uninitialized named exports (#3957) -* Allow using an external namespace reexport together with named exports (#3959) -* Avoid invalid generated code in certain scenarios with SystemJS exports (#3960) - -### Pull Requests -* [#3952](https://github.com/rollup/rollup/pull/3952): implement `validate` output option and `--validate` CLI option (@kzc) -* [#3956](https://github.com/rollup/rollup/pull/3956): Update dependencies, fix fsevents issue (@lukastaegert) -* [#3957](https://github.com/rollup/rollup/pull/3957): Make sure uninitialised exports turn up via .hasOwnProperty for non-ES formats (@lukastaegert) -* [#3959](https://github.com/rollup/rollup/pull/3959): Allow overriding individual exports of reexported external namespaces (@lukastaegert) -* [#3960](https://github.com/rollup/rollup/pull/3960): Make sure system exports are valid JavaScript - (@lukastaegert) - -## 2.38.5 -*2021-02-05* - -### Bug Fixes -* Prevent invalid code when simplifying assignments and delcarations (#3951) -* Prevent behaviour-changing line-breaks when simplifying assignments in return statements (#3951) -* Slightly improve white-space rendering when simplifying certain expressions (#3951) - -### Pull Requests -* [#3951](https://github.com/rollup/rollup/pull/3951): Wrap simplified assignments if necessary (@lukastaegert) - -## 2.38.4 -*2021-02-02* - -### Bug Fixes -* Do not change logic when tree-shaking declarations in if statements or loops (#3947) - -### Pull Requests -* [#3947](https://github.com/rollup/rollup/pull/3947): Do not tear apart declarations in loop or if bodies (@lukastaegert) - -## 2.38.3 -*2021-02-01* - -### Bug Fixes -* Prevent an unexpected live-binding when default exporting a synthetic named export (#3946) - -### Pull Requests -* [#3945](https://github.com/rollup/rollup/pull/3945): Upgrade chokidar and fsevents for Apple M1 compatibility (@threepointone) -* [#3946](https://github.com/rollup/rollup/pull/3946): Make sure default exports snapshot synthetic named exports (@lukastaegert) - -## 2.38.2 -*2021-01-31* - -### Bug Fixes -* Do not generate invalid code for partially tree-shaken declarations in for loops (#3943) -* Always include function bodies of functions in side-effect-free modules (#3944) - -### Pull Requests -* [#3943](https://github.com/rollup/rollup/pull/3943): Do not partially tree-shake unused declarations in for loops (@lukastaegert) -* [#3944](https://github.com/rollup/rollup/pull/3944): Correctly include functions with side effects from side-effect-free modules (@lukastaegert) - -## 2.38.1 -*2021-01-28* - -### Bug Fixes -* Fix internal error when resolving a missing entry point in the browser build (#3935) - -### Pull Requests -* [#3935](https://github.com/rollup/rollup/pull/3935): fix: remove isolated resolve() for compat with browser distribution (@cmorten and @lukastaegert) -* [#3936](https://github.com/rollup/rollup/pull/3936): Ensure test after() callback is always executed (@Benjamin-Dobell) -* [#3937](https://github.com/rollup/rollup/pull/3937): Modernize references to other software (@ludofischer) - -## 2.38.0 -*2021-01-22* - -### Features -* Entirely remove declared variables that only have an initializer side effect (#3933) - -### Pull Requests -* [#3933](https://github.com/rollup/rollup/pull/3933): Tree-shake unused declarations while keeping initializer side-effects (@lukastaegert) - -## 2.37.1 -*2021-01-20* - -### Pull Requests -* [#3929](https://github.com/rollup/rollup/pull/3929): Deduplicate acorn import (@lukastaegert) - -## 2.37.0 -*2021-01-19* - -### Features -* Always check modules for side effects that only indirectly reexport a used variable (#3840) -* Warn if a circular dependency would cause wrong execution order when preserving modules (#3840) - -### Bug Fixes -* Allow consuming synthetic exports via modules that reexport a namespace (#3894) -* Do not crash for circular default reexports (#3840) -* Do not crash for circular synthetic namespaces (#3840) -* Improve circular dependency execution order in certain scenarios (#3840) - -### Pull Requests -* [#3840](https://github.com/rollup/rollup/pull/3840): Improve circular dependency execution order (@lukastaegert) -* [#3894](https://github.com/rollup/rollup/pull/3894): Always respect synthetic namespaces in namespace reexport (@lukastaegert) - -## 2.36.2 -*2021-01-16* - -### Bug Fixes -* Fix an issue where invalid code was generated for unused assignments with side effects (#3926) - -### Pull Requests -* [#3926](https://github.com/rollup/rollup/pull/3926): Correctly simplify assignments with parentheses (@lukastaegert) - -## 2.36.1 -*2021-01-06* - -### Bug Fixes -* Solve issues that result in invalid code when partially removing assignments (#3921) - -### Pull Requests -* [#3921](https://github.com/rollup/rollup/pull/3921): Prevent invalid code when removing assignment target of side-effectful object expression (@lukastaegert) - -## 2.36.0 -*2021-01-05* - -### Features -* Support partial tree-shaking of chained assignments and unused assignment targets (#3919) - -### Pull Requests -* [#3919](https://github.com/rollup/rollup/pull/3919): Treeshake chained assignment expressions (@lukastaegert) - -## 2.35.1 -*2020-12-14* - -### Bug Fixes -* Allow closing the bundle when watching in case of generate errors by adding the bundle to the error event (#3909) -* Automatically close all bundles on generate errors when watching and using the CLI (#3909) -* Try to create remaining bundles when watching and one of them throws (#3909) - -### Pull Requests -* [#3909](https://github.com/rollup/rollup/pull/3909): Forward bundle through watch error events (@lukastaegert) - -## 2.35.0 -*2020-12-14* - -### Features -* Add `closeBundle` hook that is triggered by `bundle.close()` in the JS API (#3883) - -### Pull Requests -* [#3883](https://github.com/rollup/rollup/pull/3883): Revert pattern to folder export (@intrnl) - -## 2.34.2 -*2020-12-06* - -### Bug Fixes -* Revert pattern export change (#3898) - -### Pull Requests -* [#3898](https://github.com/rollup/rollup/pull/3898): Revert pattern to folder export (@lukastaegert) - -## 2.34.1 -*2020-12-03* - -### Bug Fixes -* Avoid Node deprecation warning by using a pattern export for nested Rollup files (#3896) - -### Pull Requests -* [#3887](https://github.com/rollup/rollup/pull/3887): Run memory leak test on all systems (@lukastaegert) -* [#3892](https://github.com/rollup/rollup/pull/3892): Add pull_request to windows github actions (@shellscape) -* [#3893](https://github.com/rollup/rollup/pull/3893): Update dependencies (@lukastaegert) -* [#3896](https://github.com/rollup/rollup/pull/3896): Replace deprecated folder package export with pattern export (@lukastaegert) - -## 2.34.0 -*2020-11-29* - -### Features -* Support RequireJS comaptible AMD ids in code-splitting builds via amd.autoId (#3867) -* Allow adding an AMD id base path (#3867) - -### Bug Fixes -* Warn when using an constant AMD id in a code-splitting build (#3867) - -### Pull Requests -* [#3867](https://github.com/rollup/rollup/pull/3867): Implement amd.autoId/amd.basePath options (@tjenkinson) - -## 2.33.3 -*2020-11-18* - -### Bug Fixes -* Do not use `.js` extension when importing AMD files from a UMD bundle (#3872) - -### Pull Requests -* [#3861](https://github.com/rollup/rollup/pull/3861): Update chat/support links (@shellscape) -* [#3872](https://github.com/rollup/rollup/pull/3872): Also removeExtensionFromRelativeAmdId in UMD finaliser (@tjenkinson) - -## 2.33.2 -*2020-11-14* - -### Bug Fixes -* Fix an issue where statements were ignored after a conditional return in a labeled statement (#3871) - -### Pull Requests -* [#3871](https://github.com/rollup/rollup/pull/3871): Correctly track label usage in try statements (@Amareis) - -## 2.33.1 -*2020-11-02* - -### Bug Fixes -* Add `syntheticNamedExports` to `this.getModuleInfo` to align with documentation (#3847) - -### Pull Requests -* [#3847](https://github.com/rollup/rollup/pull/3847): Expose syntheticNamedExports to ModuleInfo (@Amareis) -* [#3852](https://github.com/rollup/rollup/pull/3852): Fix typo on docs (@jpsc) - -## 2.33.0 -*2020-11-01* - -### Features -* Add parameter to "watchChange" hook to denote if a change was an addition, update or deletion (#3841) -* Add "closeWatcher" hook to allow plugins to clean up resources when the watcher is closed (#3841) -* Add "this.getWatchFiles" function to plugin context to get the current set of watched files (#3841) - -### Pull Requests -* [#3841](https://github.com/rollup/rollup/pull/3841): Improved watcher hooks (@Amareis) -* [#3848](https://github.com/rollup/rollup/pull/3848): Add options hook to asyncpluginhooks (@intrnl) - -## 2.32.1 -*2020-10-21* - -### Bug Fixes -* Print warning location for plugin warnings if only `loc` is supplied (#3824) - -### Pull Requests -* [#3824](https://github.com/rollup/rollup/pull/3824): plugin warnings not showing warning.loc (@luciotato) - -## 2.32.0 -*2020-10-16* - -### Features -* Extend `preserveEntrySignatures` with a value `"exports-only"` to allow extension only if an entry does not have exports (#3823) - -### Pull Requests -* [#3823](https://github.com/rollup/rollup/pull/3823): Add "exports-only" option to preserveSignature (@lukastaegert) - -## 2.31.0 -*2020-10-15* - -### Features -* When using the `output.moduleToStringTag` option, also add the tag to entries with exports and simulated external namespaces (#3822) -* Add the `__esModule` interop marker to IIFE global variables unless `output.esModule` is turned off (#3822) - -### Pull Requests -* [#3822](https://github.com/rollup/rollup/pull/3822): Add module toStringTag to entries and interop namespaces (@lukastaegert) - -## 2.30.0 -*2020-10-13* - -### Features -* Add `moduleParsed` hook that is called for each module once code and AST are available (#3813) -* Include code and AST in `this.getModuleInfo` (#3813) - -### Bug Fixes -* Provide the original Acorn AST instead of the internal one when resolving dynamic imports that contain non-trivial expressions (#3813) - -### Pull Requests -* [#3813](https://github.com/rollup/rollup/pull/3813): Add moduleParsed plugin hook (@lukastaegert) -* [#3815](https://github.com/rollup/rollup/pull/3815): Docs: wile => while (@tjenkinson) -* [#3817](https://github.com/rollup/rollup/pull/3817): Docs: fix code snippet (@codefrau) -* [#3818](https://github.com/rollup/rollup/pull/3818): Update documentation on configuring Babel, removing the section on passing '{"modules": false}' as that is no longer needed since Babel 7 (@Robin-Hoodie) - -## 2.29.0 -*2020-10-08* - -### Features -* Allow passing custom options to other plugins via `this.resolve` (#3807) -* Allow attaching custom meta information to modules when resolving, loading or transforming (#3807) -* Do not throw but return `null` when using `this.getModuleInfo` for an unknown id (#3807) - -### Bug Fixes -* Trigger build in watch mode when files are added to a watched directory (#3812) -* Make `code` optional when transforming modules (#3807) - -### Pull Requests -* [#3807](https://github.com/rollup/rollup/pull/3807): Implement new APIs for inter-plugin communication (@lukastaegert) -* [#3808](https://github.com/rollup/rollup/pull/3808): Document that the default value of --format is 'es' (@jameshfisher) -* [#3812](https://github.com/rollup/rollup/pull/3812): Watch: listen for new files added to a directory (@dmitrage) - -## 2.28.2 -*2020-09-24* - -### Bug Fixes -* Fix a source of possible variable name conflicts when using preserveModules with SystemJS (#3796) - -### Pull Requests -* [#3792](https://github.com/rollup/rollup/pull/3792): add documentation for output.PreserveModulesRoot (@davidroeca) -* [#3796](https://github.com/rollup/rollup/pull/3796): Fix SystemJS default variable conflict (@lukastaegert) - -## 2.28.1 -*2020-09-21* - -### Bug Fixes -* Fix a path slash issue when using the preserveModulesRoot option on Windows (#3791) - -### Pull Requests -* [#3791](https://github.com/rollup/rollup/pull/3791): Fix preserveModulesRoot path on Windows (@lukastaegert) - -## 2.28.0 -*2020-09-21* - -### Features -* Add an option to treat modules at a given path as located at root when preserving modules (#3786) - -### Pull Requests -* [#3786](https://github.com/rollup/rollup/pull/3786): Add preserveModulesRoot config option (@davidroeca) - -## 2.27.1 -*2020-09-17* - -### Bug Fixes -* Do not fail when using ES module imports in symlinked config files (#3783) - -### Pull Requests -* [#3783](https://github.com/rollup/rollup/pull/3783): Handle loading symlinked config files (@lukastaegert) - -## 2.27.0 -*2020-09-16* - -### Features -* Support specifying a file extension when reading from stdin (#3775) - -### Bug Fixes -* Do not break logic if a branch with hoisted variables is tree-shaken in an else-if statement (#3782) - -### Pull Requests -* [#3770](https://github.com/rollup/rollup/pull/3770): Docs: Exception for babel plugin and commonjs plugin (@jsk7) -* [#3775](https://github.com/rollup/rollup/pull/3775): add ability to specify stdin file extension via --stdin=ext (@kzc) -* [#3782](https://github.com/rollup/rollup/pull/3782): Handle hoisted variables in dead branches of nested if statements (@lukastaegert) - -## 2.26.11 -*2020-09-08* - -### Bug Fixes -* Do not fail for unknown nodes as if statement branches (#3769) - -### Pull Requests -* [#3769](https://github.com/rollup/rollup/pull/3769): Handle debugger statements as if-statement branches (@lukastaegert) - -## 2.26.10 -*2020-09-04* - -### Bug Fixes -* Do not create invalid code when simplifying expressions in return statements that contain line comments (#3762) - -### Pull Requests -* [#3757](https://github.com/rollup/rollup/pull/3757): Fix api docs loadconfigfile (@maxwell8888) -* [#3762](https://github.com/rollup/rollup/pull/3762): Handle line-comments when removing line-breaks to prevent ASI (@lukastaegert) - -## 2.26.9 -*2020-09-01* - -### Bug Fixes -* Add regular expression support to watch include/exclude types (#3754) - -### Pull Requests -* [#3754](https://github.com/rollup/rollup/pull/3754): Add RegExp to the include and exclude fields of the WatcherOptions type (@dagda1) -* [#3756](https://github.com/rollup/rollup/pull/3756): Update FAQ: I think it was meant "external" instead of "other-entry.js" (@madacol) - -## 2.26.8 -*2020-08-29* - -### Bug Fixes -* Make sure that both unresolved and resolved ids are passed to the `external` option in all cases (#3753) - -### Pull Requests -* [#3753](https://github.com/rollup/rollup/pull/3753): Also pass resolved ids to external if they use the object for (@lukastaegert) - -## 2.26.7 -*2020-08-28* - -### Bug Fixes -* Avoid invalid code when rendering hoisted variable declarations from dead branches (#3752) -* Mark the `options` parameter of `this.parse` as optional for TypeScript plugins (#3750) - -### Pull Requests -* [#3750](https://github.com/rollup/rollup/pull/3750): Make `options` of `PluginContext#parse` optional (@intrnl) -* [#3752](https://github.com/rollup/rollup/pull/3752): Extract hoisted variables from dead branches (@lukastaegert) - -## 2.26.6 -*2020-08-27* - -### Bug Fixes -* Avoid conflicts between the namespace of synthetic named exports and local variables (#3747) - -### Pull Requests -* [#3747](https://github.com/rollup/rollup/pull/3747): Properly deconflict synthetic named exports (@lukastaegert) - -## 2.26.5 -*2020-08-22* - -### Bug Fixes -* Use correctly deconflicted variable names for reexported namespaces in ES formats (#3742) - -### Pull Requests -* [#3742](https://github.com/rollup/rollup/pull/3742): Avoid variable name conflict when reexporting several namespaces from a chunk (@lukastaegert) - -## 2.26.4 -*2020-08-19* - -### Bug Fixes -* Fix a situation where invalid code was rendered when dynamically importing a module with synthetic named exports when preserving modules (#3738) -* Create a proper namespace object when in a non-es format, a namespace is imported from a chunk with `default` export mode (#3738) -* Use the same variable when in a chunk, a namespace is both imported and reexported as a binding (#3738) -* Do not include the synthetic namespace in static entry points unless it is actually used (#3738) -* Make sure the chunking of one output does not interfere with the namespace objects of another output (#3738) - -### Pull Requests -* [#3738](https://github.com/rollup/rollup/pull/3738): Improve synthetic entry handling (@lukastaegert) - -## 2.26.3 -*2020-08-16* - -### Bug Fixes -* Fix a situation where line-breaks in a nested simplified conditional expression could result in broken code (#3734) - -### Pull Requests -* [#3734](https://github.com/rollup/rollup/pull/3734): Prevent ASI when simplifying a nested logical expression (@lukastaegert) - -## 2.26.2 -*2020-08-16* - -### Bug Fixes -* Fix a situation where line-breaks in a simplified conditional expression could result in broken code (#3732) - -### Pull Requests -* [#3732](https://github.com/rollup/rollup/pull/3732): Prevent unintended ASI for nested conditionals (@lukastaegert) - -## 2.26.1 -*2020-08-16* - -### Bug Fixes -* Correctly render external namespace imports when only generating SystemJS output (#3731) - -### Pull Requests -* [#3731](https://github.com/rollup/rollup/pull/3731): Render system namespace import (@sastan and @lukastaegert) - -## 2.26.0 -*2020-08-15* - -### Features -* Add a new entry `importedBindings` to the bundle information to list bindings per dependency (#3722) - -### Bug Fixes -* Do not render an invalid UMD wrapper when no bindings are imported from a dependency (#3724) -* Avoid situations where removing the `else` branch from an `if` statement might catch the `else` branch from another one (#3725) - -### Pull Requests -* [#3722](https://github.com/rollup/rollup/pull/3722): Add import specifiers to bundle information (@lukastaegert) -* [#3724](https://github.com/rollup/rollup/pull/3724): Fix missing variables for UMD and IIFE builds (@lukastaegert) -* [#3725](https://github.com/rollup/rollup/pull/3725): Do not entirely remove else branch if another else branch might accidentally be referenced (@lukastaegert) - -## 2.25.0 -*2020-08-14* - -### Features -* Add `--failAfterWarnings` CLI flag that will complete builds with warnings but return an error at the end (#3712) - -### Pull Requests -* [#3712](https://github.com/rollup/rollup/pull/3712): Implement `--failAfterWarnings` flag (@tjenkinson) - -## 2.24.0 -*2020-08-13* - -### Features -* Allow defining interop per dependency via a function (#3710) -* Support interop "auto" as a more compatible version of "true" (#3710) -* Support interop "default" and "esModule" to avoid unnecessary interop helpers (#3710) -* Support interop "defaultOnly" for simplified helpers and Node ESM interop compatible output (#3710) -* Respect interop option for external dynamic imports (#3710) -* Support live-bindings for external default imports in non-ES formats unless "externalLiveBindings" is "false" (#3710) -* Use shared default interop helpers for AMD, UMD and IIFE formats (#3710) -* Avoid unnecessarily deconflicted module variables in non-ES formats (#3710) -* Freeze generated interop namespace objects (#3710) -* Always mark interop helpers as pure (#3710) -* Avoid default export interop if there is already an interop namespace object (#3710) -* Sort all `require` statements to the top in CommonJS output for easier back-transpilation to ES modules by other tools (#3710) - -### Bug Fixes -* Handle accessing `super` in static class fields (#3720) -* Deconflict the names of helper variables introduced for interop (#3710) -* Generate proper namespace objects for static namespace imports in non-ES formats (#3710) -* Do not add unused interop helpers when using the renderDynamicImport hook (#3710) - -### Pull Requests -* [#3710](https://github.com/rollup/rollup/pull/3710): Rework interop handling (@lukastaegert) -* [#3720](https://github.com/rollup/rollup/pull/3720): Handle super in static class fields (@lukastaegert) - -## 2.23.1 -*2020-08-07* - -### Bug Fixes -* Fix an issue where dynamically importing an entry point could return a malformed namespace for CJS and AMD formats (#3709) - -### Pull Requests -* [#3709](https://github.com/rollup/rollup/pull/3709): Properly construct namespace when dynamically importing chunks with facades in default export mode (@lukastaegert) - -## 2.23.0 -*2020-07-23* - -### Features -* Handle environments with only globalThis in UMD output (#3691) - -### Pull Requests -* [#3691](https://github.com/rollup/rollup/pull/3691): Check for globalThis in UMD wrapper (@lukastaegert) - -## 2.22.2 -*2020-07-21* - -### Bug Fixes -* Always generate correct exports when an implicit entry is reexporting from another module (#3688) - -### Pull Requests -* [#3688](https://github.com/rollup/rollup/pull/3688): Include all relevant modules to generate reexports for implicit dependencies (@lukastaegert) - -## 2.22.1 -*2020-07-18* - -### Bug Fixes -* Remove unused arguments when calling a conditional expression (#3680) - -### Pull Requests -* [#3680](https://github.com/rollup/rollup/pull/3680): Allow tree-shaking of arguments of functions that are returned by conditional expressions (@lukastaegert) - -## 2.22.0 -*2020-07-18* - -### Features -* Allow resolving synthetic named exports via an arbitrary export name (#3657) -* Display a warning when the user does not explicitly select an export mode and would generate a chunk with default export mode when targeting CommonJS (#3657) - -### Pull Requests -* [#3657](https://github.com/rollup/rollup/pull/3657): Add basic support for using a non-default export for syntheticNamedExports (@lukastaegert) -* [#3659](https://github.com/rollup/rollup/pull/3659): Warn when implicitly using default export mode (@lukastaegert) - -## 2.21.0 -*2020-07-07* - -### Features -* Allow plugins to disable tree-shaking for individual modules to ensure even empty modules are associated with chunks (#3663) - -### Pull Requests -* [#3663](https://github.com/rollup/rollup/pull/3663): Disable treeshaking per module (@lukastaegert) - -## 2.20.0 -*2020-07-06* - -### Features -* Support using a function to generate different chunk and asset naming patterns per chunk or asset (#3658) -* Add `referencedFiles` property to the chunk info in generateBundle to list referenced assets (#3661) - -### Pull Requests -* [#3658](https://github.com/rollup/rollup/pull/3658): Add ability to use a function that returns a pattern string in all places where you could use a pattern string before (@frank-dspeed) -* [#3661](https://github.com/rollup/rollup/pull/3661): Add referenced files to bundle (@lukastaegert) - -## 2.19.0 -*2020-07-05* - -### Features -* Allow plugins to return a Promise in the options hook (#3660) - -### Pull Requests -* [#3660](https://github.com/rollup/rollup/pull/3660): Make options hooks async (@TomerAberbach) - -## 2.18.2 -*2020-07-02* - -### Bug Fixes -* Do not remove spread element args when the corresponding positional parameter is unused (#3652) - -### Pull Requests -* [#3652](https://github.com/rollup/rollup/pull/3652): Do not tree-shake arguments that contain a spread element (@lukastaegert) - -## 2.18.1 -*2020-06-26* - -### Bug Fixes -* Make sure synthetic exports are present when a module is imported dynamically (#3648) -* Strip the `rollup-plugin-` prefix off the plugin name when looking for the plugin export in a CLI plugin without a default export (#3647) -* Convert plugin names with dashes to camel case when looking for the plugin export in a CLI plugin without a default export (#3647) - -### Pull Requests -* [#3647](https://github.com/rollup/rollup/pull/3647): Strip rollup-plugin prefix to find named plugin exports, throw when export cannot be found (@lukastaegert) -* [#3648](https://github.com/rollup/rollup/pull/3648): Always create a dynamic namespace object when a module with synthetic named exports is imported dynamically (@lukastaegert) - -## 2.18.0 -*2020-06-22* - -### Features -* `inlineDynamicImports`, `manualChunks` and `preserveModules` can now be used as output options (#3645) -* Use sourcemaps for certain warnings that reference source code locations (#3645) - -### Bug Fixes -* `this.getFileName` will now always return the correct file name for chunks when multiple outputs are created (#3645) - -### Pull Requests -* [#3645](https://github.com/rollup/rollup/pull/3645): Per output chunking (@lukastaegert) - -## 2.17.1 -*2020-06-19* - -### Bug Fixes -* Properly resolve accessing properties of namespace members again (#3643) - -### Pull Requests -* [#3643](https://github.com/rollup/rollup/pull/3643): Fix accessing nested properties of namespaces (@lukastaegert) - -## 2.17.0 -*2020-06-17* - -### Features -* When importing Rollup via package.exports, always fall back to the browser ESM build for non-Node environments (#3634) -* Create more efficient code when handling namespace mutations (#3637) - -### Bug Fixes -* Fix a severe performance regression when the same module is imported by a lot of modules (#3641) -* Properly escape special characters in imports (#3638) - -### Pull Requests -* [#3634](https://github.com/rollup/rollup/pull/3634): Set browser build in exports (@guybedford) -* [#3637](https://github.com/rollup/rollup/pull/3637): Do not include the whole namespace when illegally mutating a namespace (@lukastaegert) -* [#3638](https://github.com/rollup/rollup/pull/3638): Support backslash escaping, retain exact newline escaping (@guybedford) -* [#3641](https://github.com/rollup/rollup/pull/3641): Fix performance regression when a file is imported by many importers (@lukastaegert) - -## 2.16.1 -*2020-06-13* - -### Bug Fixes -* Do not produce invalid code when an external or chunk id contain quotes or line-breaks (#3632) -* Do not fail but emit a warning when mutating a namespace object (#3633) - -### Pull Requests -* [#3632](https://github.com/rollup/rollup/pull/3632): Handle single quote escaping in ids (@guybedford) -* [#3633](https://github.com/rollup/rollup/pull/3633): Turn namespace assignment error into a warning (@guybedford) - -## 2.16.0 -*2020-06-12* - -### Features -* Add support for numeric separators (#3626) -* Switch to finalized ESTree optional chaining AST (#3628) - -### Pull Requests -* [#3626](https://github.com/rollup/rollup/pull/3626): Support numeric separator (@TrySound) -* [#3628](https://github.com/rollup/rollup/pull/3628): Acorn 7.3.0 upgrade (@guybedford) -* [#3631](https://github.com/rollup/rollup/pull/3631): Improve discoverability of `manualChunks` for code splitting (@zlamma) - -## 2.15.0 -*2020-06-08* - -### Features -* Allow to skip watching some configs via `watch: false` (#3620) -* Provide the resolved sourcemap path to `sourcemapPathTransform` (#3617) - -### Pull Requests -* [#3617](https://github.com/rollup/rollup/pull/3617): Update sourcemapPathTransform to also take the path to the sourcemap file as a second argument (@dgoldstein0) -* [#3620](https://github.com/rollup/rollup/pull/3620): Rollup watch only one config in exported array (@luwol03) - -## 2.14.0 -*2020-06-07* - -### Features -* Make `this.meta.watchMode` available for plugins to detect watch mode (#3616) - -### Bug Fixes -* Handle exporting the same binding with different names in SystemJS (#3575) - -### Pull Requests -* [#3575](https://github.com/rollup/rollup/pull/3575): Handle some cases of duplicate export bindings (@joeljeske) -* [#3616](https://github.com/rollup/rollup/pull/3616): Make watch mode available in plugins (@lukastaegert) - -## 2.13.1 -*2020-06-04* - -### Bug Fixes -* Prevent conflicts in SystemJS when `module` is used as a top-level variable (#3614) - -### Pull Requests -* [#3614](https://github.com/rollup/rollup/pull/3614): Handle system reserved identifier dedupes (@guybedford) - -## 2.13.0 -*2020-06-03* - -### Features -* Allow to specify that an emitted chunk is only loaded after a given module has loaded to improve chunking (#3606) - -### Pull Requests -* [#3606](https://github.com/rollup/rollup/pull/3606): Enable specifying implicit dependencies when emitting chunks (@lukastaegert) - -## 2.12.1 -*2020-06-02* - -### Bug Fixes -* Render valid imports when chunk names correspond to directory names in virtual setups (#3609) - -### Pull Requests -* [#3609](https://github.com/rollup/rollup/pull/3609): Handle imports from chunks with names that correspond to parent directory names of other chunks (@guybedford) - -## 2.12.0 -*2020-05-31* - -### Features -* Add an option `--waitForBundleInput` to let the build wait until all entry point files are available before starting (#3577) - -### Pull Requests -* [#3577](https://github.com/rollup/rollup/pull/3577): Wait for bundle input option (@Heerschop) - -## 2.11.2 -*2020-05-28* - -### Bug Fixes -* Include side-effects in the second argument of `Array.from` (#3604) - -### Pull Requests -* [#3604](https://github.com/rollup/rollup/pull/3604): Mark `Array.from` as side-effectful, use two-argument Array.from when mapping Sets (@lukastaegert) - -## 2.11.1 -*2020-05-28* - -### Bug Fixes -* Also include side-effects in files that are marked as side-effect-free if they contain an included default export that is reexported (#3602) - -### Pull Requests -* [#3602](https://github.com/rollup/rollup/pull/3602): Handle side-effects next to side-effect-free default exports in case the default export is reexported (@lukastaegert) - -## 2.11.0 -*2020-05-27* +_2026-01-22_ ### Features -* Add basic support for optional chaining (#3582) -* Provide a normalized set of options with proper default values to `buildStart` and `renderStart` (#3597) -* Do not count adding properties to the prototype of an unused class as a side-effect (#3598) -* Support providing `null` for empty setters in SystemJS via option (#3592) + +- Track object property inclusions of dynamic namespace members (#6230) ### Bug Fixes -* Do not fail when using a `/*#__PURE__*/` annotation inside a class field (#3599) -* Allow using `--watch` and `--treeshake` together with sub-options such as `--watch.clearScreen` on the command line (#3597) -### Pull Requests -* [#3582](https://github.com/rollup/rollup/pull/3582): Support optional chaining via acorn fork(@guybedford) -* [#3592](https://github.com/rollup/rollup/pull/3592): System format optional setters(@guybedford) -* [#3597](https://github.com/rollup/rollup/pull/3597): Provide normalized options (@lukastaegert) -* [#3598](https://github.com/rollup/rollup/pull/3598): Treeshake prototype modifications in classes (@lukastaegert) -* [#3599](https://github.com/rollup/rollup/pull/3599): Retain pure annotations in class fields (@lukastaegert) -* [#3601](https://github.com/rollup/rollup/pull/3601): Fix white-space in docs (@tu4mo) +- Handle methods that access dynamically imported namespace members via `this` (#6230) -## 2.10.9 -*2020-05-24* +### Pull Requests -### Bug Fixes -* Prevent invalid exports when facades are created (#3590) +- [#6230](https://github.com/rollup/rollup/pull/6230): Refine namespace handling (@lukastaegert) -### Pull Requests -* [#3590](https://github.com/rollup/rollup/pull/3590): Prevent unneeded exports when entry facades are created and ensure all exported variables in facades are imported (@lukastaegert) +## 4.55.3 -## 2.10.8 -*2020-05-23* +_2026-01-21_ ### Bug Fixes -* Fix issues when synthetic named exports are reexported as default exports (#3586) -### Pull Requests -* [#3584](https://github.com/rollup/rollup/pull/3584): Clarify documentation for `output.paths` (@jacksteamdev) -* [#3585](https://github.com/rollup/rollup/pull/3585): Target Node.js v14 instead of v13 in Windows tests (@mangs) -* [#3586](https://github.com/rollup/rollup/pull/3586): Handle default reexports of synthetic named exports over several stages (@lukastaegert) +- Fix JSX semicolon insert position in variable declarations (#6241) -## 2.10.7 -*2020-05-22* +### Pull Requests -### Bug Fixes -* Handle modules re-exporting namespaces without further own code (#3576) +- [#6241](https://github.com/rollup/rollup/pull/6241): Fix JSX semicolon insertion (@lukastaegert) -### Pull Requests -* [#3576](https://github.com/rollup/rollup/pull/3576): Fix "cannot read exports of undefined" error (@guybedford) +## 4.55.2 -## 2.10.6 -*2020-05-22* +_2026-01-19_ ### Bug Fixes -* Fix some issues around class fields (#3580) -* Prevent a maximum call stack error when a called entity references itself in its declaration (#3581) -### Pull Requests -* [#3580](https://github.com/rollup/rollup/pull/3580): Update acorn class features (@guybedford) -* [#3581](https://github.com/rollup/rollup/pull/3581): Do not fail when including call arguments of recursively defined variables (@lukastaegert) +- Sort manual chunks by execution order to reduce circular dependency issues (#6240) -## 2.10.5 -*2020-05-19* +### Pull Requests -### Bug Fixes -* Do not remove side-effects that may influence an included default export declaration when side-effects are disabled (#3572) +- [#6234](https://github.com/rollup/rollup/pull/6234): chore(deps): pin cross-platform-actions/action action to 492b0c8 (@renovate[bot]) +- [#6235](https://github.com/rollup/rollup/pull/6235): chore(deps): update dependency globals to v17 (@renovate[bot], @lukastaegert) +- [#6236](https://github.com/rollup/rollup/pull/6236): fix(deps): lock file maintenance minor/patch updates (@renovate[bot]) +- [#6237](https://github.com/rollup/rollup/pull/6237): chore(deps): lock file maintenance (@renovate[bot]) +- [#6239](https://github.com/rollup/rollup/pull/6239): fix(deps): lock file maintenance minor/patch updates (@renovate[bot], @lukastaegert) +- [#6240](https://github.com/rollup/rollup/pull/6240): Sort manual chunks by module execution order (@TrickyPi) -### Pull Requests -* [#3572](https://github.com/rollup/rollup/pull/3572): Observe side-effects in files containing a default export declaration that reexports a variable (@lukastaegert) +## 4.55.1 -## 2.10.4 -*2020-05-19* +_2026-01-05_ ### Bug Fixes -* Tree-shake unused classes with fields unless there are side-effects in the field declaration (#3569) + +- Fix artifact reference for OpenBSD (#6231) ### Pull Requests -* [#3569](https://github.com/rollup/rollup/pull/3569): Make sure unused classes with fields are tree-shaken if possible (@lukastaegert) -## 2.10.3 -*2020-05-18* +- [#6231](https://github.com/rollup/rollup/pull/6231): Fix OpenBSD artifacts and ensure OIDC is working (@lukastaegert) -### Bug Fixes -* Validate return value of sourcemapPathTransform option (#3561) +## 4.55.0 -### Pull Requests -* [#3561](https://github.com/rollup/rollup/pull/3561): Throw error if sourcemapPathTransform-option does not return a string (@Simonwep) +_2026-01-05_ + +### Features -## 2.10.2 -*2020-05-15* +- Natively support ppc64 Linux Musl targets (#5997) +- Natively support loong64 Linux Musl targets (#5997) +- Natively support OpenBSD targets (#6224) ### Bug Fixes -* Properly include calls to mutating array methods in certain scenarios (#3559) -### Pull Requests -* [#3559](https://github.com/rollup/rollup/pull/3559): Make sure UnknownFooExpressions are included when referenced as return values in a MultiExpression (@lukastaegert) +- Prevent some cycles when using top-level-await (#6221) +- Warn when generating cycling manual chunks (#6225) -## 2.10.1 -*2020-05-15* +### Pull Requests -### Bug Fixes -* Do not throw when "undefined" is used as a default export (#3558) +- [#5997](https://github.com/rollup/rollup/pull/5997): Add support for ppc64 & loong64 musl linux (@fossdd) +- [#6218](https://github.com/rollup/rollup/pull/6218): fix(deps): update swc monorepo (major) (@renovate[bot], @lukastaegert) +- [#6219](https://github.com/rollup/rollup/pull/6219): fix(deps): lock file maintenance minor/patch updates (@renovate[bot]) +- [#6220](https://github.com/rollup/rollup/pull/6220): chore(deps): lock file maintenance (@renovate[bot]) +- [#6221](https://github.com/rollup/rollup/pull/6221): Handle TLA dynamic import cycles in chunkAssignment (@TrickyPi) +- [#6222](https://github.com/rollup/rollup/pull/6222): Apply to adjust the description of the command-line parameter 'rollup… (@image-gif, @lukastaegert) +- [#6223](https://github.com/rollup/rollup/pull/6223): Deduplicate CLI help file (@lukastaegert) +- [#6224](https://github.com/rollup/rollup/pull/6224): OpenBSD support (@edshot99, @lukastaegert) +- [#6225](https://github.com/rollup/rollup/pull/6225): Throw a warning for circular chunks (@TrickyPi) +- [#6226](https://github.com/rollup/rollup/pull/6226): fix(deps): update swc monorepo (major) (@renovate[bot]) +- [#6227](https://github.com/rollup/rollup/pull/6227): chore(deps): lock file maintenance minor/patch updates (@renovate[bot]) +- [#6228](https://github.com/rollup/rollup/pull/6228): chore(deps): lock file maintenance minor/patch updates (@renovate[bot]) +- [#6229](https://github.com/rollup/rollup/pull/6229): chore(deps): lock file maintenance minor/patch updates (@renovate[bot]) -### Pull Requests -* [#3558](https://github.com/rollup/rollup/pull/3558): Properly handle default exporting undefined (@lukastaegert) +## 4.54.0 -## 2.10.0 -*2020-05-13* +_2025-12-20_ ### Features -* Avoid unnecessary empty imports from a facade chunk to the original chunk (#3552) -* Pin facade creation order so that if several user-defined chunks reference the same module, the first always becomes the "actual" chunk while the later ones become facades (#3552) + +- Enable tree-shaking for `Symbol.hasInstance`, `Symbol.dispose` and `Symbol.asyncDispose` properties if unused (#6046) ### Bug Fixes -* Do not omit reexports from secondary chunks when creating facades for entry points without hoisting transitive dependencies (#3552) + +- Ensure that well-known-Symbol-valued properties are not tree-shaken except in select cases (#6046) +- Ensure namespace properties are included when referenced only from a try-catch (#6216) ### Pull Requests -* [#3552](https://github.com/rollup/rollup/pull/3552): Avoid unnecessary facade dependency inlining (@guybedford) -## 2.9.1 -*2020-05-11* +- [#6046](https://github.com/rollup/rollup/pull/6046): fix: correctly handle wellknown protocols (@cyyynthia, @lukastaegert) +- [#6201](https://github.com/rollup/rollup/pull/6201): chore(deps): update dependency lru-cache to v11 (@renovate[bot], @lukastaegert) +- [#6211](https://github.com/rollup/rollup/pull/6211): chore(deps): update msys2/setup-msys2 digest to 4f806de (@renovate[bot], @lukastaegert) +- [#6212](https://github.com/rollup/rollup/pull/6212): chore(deps): update actions/cache action to v5 (@renovate[bot]) +- [#6213](https://github.com/rollup/rollup/pull/6213): chore(deps): update github artifact actions (major) (@renovate[bot]) +- [#6214](https://github.com/rollup/rollup/pull/6214): fix(deps): lock file maintenance minor/patch updates (@renovate[bot]) +- [#6215](https://github.com/rollup/rollup/pull/6215): chore(deps): lock file maintenance (@renovate[bot]) +- [#6216](https://github.com/rollup/rollup/pull/6216): fix: include namespace variable paths during try-catch deoptimization (@schwing) -### Bug Fixes -* Do not create unintended live-bindings or invalid reexports when reexporting global variables (#3550) +## 4.53.5 -### Pull Requests -* [#3550](https://github.com/rollup/rollup/pull/3550): Track updates of globals that are exported as default (@lukastaegert) +_2025-12-16_ -## 2.9.0 -*2020-05-10* +### Bug Fixes -### Features -* Add ids of static and dynamic imports to `this.getModuleInfo` (#3542) -* Provide `getModuleInfo` and `getModuleIds` to `manualChunks` functions (#3542) -* Add nullish coalescing support (#3548) -* Make the rebuild delay in watch mode configurable and set the default to `0` for snappy rebuilds (#3502) -* Add `this.getModuleIds` to the plugin context as future replacement for `this.moduleIds` (#3542) +- Fix wrong semicolon insertion position when using JSX (#6206) +- Generate spec-compliant sourcemaps when sources content is excluded (#6196) ### Pull Requests -* [#3502](https://github.com/rollup/rollup/pull/3502): Configurable build delay (@mattdesl) -* [#3542](https://github.com/rollup/rollup/pull/3542): Extend manualChunks API (@lukastaegert) -* [#3548](https://github.com/rollup/rollup/pull/3548): Support nullish coalescing with tree-shaking (@lukastaegert) -## 2.8.2 -*2020-05-07* - -### Bug Fixes -* Avoid invalid code when simplifying the body of a shorthand arrow function expression (#3540) +- [#6196](https://github.com/rollup/rollup/pull/6196): fix: set sourcesContent to undefined instead of null when excluding sources content (@TrickyPi) +- [#6206](https://github.com/rollup/rollup/pull/6206): Fix semicolon order in JSX (@TrickyPi) -### Pull Requests -* [#3540](https://github.com/rollup/rollup/pull/3540): Wrap object expressions in parentheses if they become children of an arrow function expression (@lukastaegert) +## 4.53.4 -## 2.8.1 -*2020-05-07* +_2025-12-15_ ### Bug Fixes -* Allow using plugins on CLI that are exported as `exports.default` (#3529) -* Do not fail side-effect detection in nested callbacks of builtins (#3539) + +- Ensure `Symbol.dispose` and `Symbol.asyncDispose` properties are never removed with `(await) using` declarations. (#6209) ### Pull Requests -* [#3529](https://github.com/rollup/rollup/pull/3529): Use default named export with plugins (@NotWoods) -* [#3539](https://github.com/rollup/rollup/pull/3539): Track call side-effects both by entity and CallExpression to avoid untracked side-effects in nested calls (@lukastaegert) -## 2.8.0 -*2020-05-06* +- [#6185](https://github.com/rollup/rollup/pull/6185): chore(deps): update dependency @inquirer/prompts to v8 (@renovate[bot], @lukastaegert) +- [#6186](https://github.com/rollup/rollup/pull/6186): fix(deps): lock file maintenance minor/patch updates (@renovate[bot]) +- [#6187](https://github.com/rollup/rollup/pull/6187): chore(deps): lock file maintenance (@renovate[bot]) +- [#6188](https://github.com/rollup/rollup/pull/6188): chore(deps): lock file maintenance minor/patch updates (@renovate[bot]) +- [#6190](https://github.com/rollup/rollup/pull/6190): Fix syntax error in manualChunks example (@jonnyeom) +- [#6194](https://github.com/rollup/rollup/pull/6194): chore(deps): update actions/checkout action to v6 (@renovate[bot]) +- [#6195](https://github.com/rollup/rollup/pull/6195): fix(deps): lock file maintenance minor/patch updates (@renovate[bot], @lukastaegert) +- [#6202](https://github.com/rollup/rollup/pull/6202): fix(deps): update swc monorepo (major) (@renovate[bot]) +- [#6203](https://github.com/rollup/rollup/pull/6203): fix(deps): lock file maintenance minor/patch updates (@renovate[bot], @lukastaegert) +- [#6209](https://github.com/rollup/rollup/pull/6209): Do not tree-shake handlers for "using" (@lukastaegert) -### Features -* When a dynamically imported chunk contains more exports than the imported module namespace, do not create a facade chunk but an inline namespace (#3535) +## 4.53.3 + +_2025-11-19_ ### Bug Fixes -* Do not execute dynamically imported code before synchronous code in the importing module when generating CommonJS (#3535) -### Pull Requests -* [#3535](https://github.com/rollup/rollup/pull/3535): Avoid dynamic facade chunks (@lukastaegert) +- Fix an error where too many modules where flagged for having an unused external import (#6182) +- Fix an error where an assignment was wrongly tree-shaken when mutating it (#6183) -## 2.7.6 -*2020-04-30* +### Pull Requests -### Bug Fixes -* Fix a type issue when a default export references a global variable (#3526) +- [#6171](https://github.com/rollup/rollup/pull/6171): Add test-install CI job to test packaging, installation and importing of rollup package (@antoninkriz, @lukastaegert) +- [#6174](https://github.com/rollup/rollup/pull/6174): Re-enable TypeScript test (@lukastaegert) +- [#6180](https://github.com/rollup/rollup/pull/6180): fix(deps): lock file maintenance minor/patch updates (@renovate[bot], @lukastaegert) +- [#6182](https://github.com/rollup/rollup/pull/6182): Tracing the importers chain for exported variables in external module (@TrickyPi, @lukastaegert) +- [#6183](https://github.com/rollup/rollup/pull/6183): Check if left side is included when checking if assigning to an assignment has side effects (@lukastaegert) -### Pull Requests -* [#3526](https://github.com/rollup/rollup/pull/3526): Handles default exporting global variables (@lukastaegert) +## 4.53.2 -## 2.7.5 -*2020-04-29* +_2025-11-10_ ### Bug Fixes -* Prevent infinite loop when default values of function parameters in a default export contain a slash (#3522) + +- Do not throw when using invalid escape sequences in template literals (#6177) ### Pull Requests -* [#3522](https://github.com/rollup/rollup/pull/3522): Avoid infinite loop when finding position for id insertion in default export (@lukastaegert) -## 2.7.4 -*2020-04-29* +- [#6177](https://github.com/rollup/rollup/pull/6177): handle TemplateElement with null cooked value (@TrickyPi) + +## 4.53.1 + +_2025-11-07_ ### Bug Fixes -* Fix an issue where wrong variable names were used when preserving modules (#3521) + +- Fix install script (#6172) ### Pull Requests -* [#3521](https://github.com/rollup/rollup/pull/3521): Fix and improve default export alias logic (@lukastaegert) -## 2.7.3 -*2020-04-27* +- [#6172](https://github.com/rollup/rollup/pull/6172): fix: move patch-package from postinstall to prepare script (@mshima) -### Bug Fixes -* Do not access `__proto__` when running Rollup (#3518) +## 4.53.0 -### Pull Requests -* [#3518](https://github.com/rollup/rollup/pull/3518): use acorn-class-fields and acorn-static-class-features from npm (@nitsky) +_2025-11-07_ -## 2.7.2 -*2020-04-22* +### Features -### Bug Fixes -* Prevent an infinite loop when creating separate manual chunks with circular dependencies (#3510) -* Do not fail if "super" is used in the definition of a class field (#3511) -* Throw if a plugin tries to emit a file with an absolute Windows path (#3509) +- Improve rendering performance by caching generated variable names (#5947) ### Pull Requests -* [#3509](https://github.com/rollup/rollup/pull/3509): Ban emitFile via absolute paths on Windows OS (@SASUKE40) -* [#3510](https://github.com/rollup/rollup/pull/3510): Do not fail for circular imports between manual chunks (@lukastaegert) -* [#3511](https://github.com/rollup/rollup/pull/3511): Support "super" in class fields (@lukastaegert) -## 2.7.1 -*2020-04-21* +- [#5947](https://github.com/rollup/rollup/pull/5947): refactor: store safe variable names in cache for subsequent usage (@Aslemammad, @lukastaegert, @Service account user) +- [#6149](https://github.com/rollup/rollup/pull/6149): chore(deps): update dependency vite to v7.1.11 [security] (@renovate[bot], @Service account user) +- [#6151](https://github.com/rollup/rollup/pull/6151): fix(deps): update swc monorepo (major) (@renovate[bot], @Service account user) +- [#6152](https://github.com/rollup/rollup/pull/6152): fix(deps): lock file maintenance minor/patch updates (@renovate[bot], @Service account user) +- [#6153](https://github.com/rollup/rollup/pull/6153): chore(deps): lock file maintenance minor/patch updates (@renovate[bot], @Service account user) +- [#6155](https://github.com/rollup/rollup/pull/6155): Fix tests: Do not swallow warnings for multi-format tests (@lukastaegert, @Service account user) +- [#6159](https://github.com/rollup/rollup/pull/6159): chore(deps): update dependency eslint-plugin-unicorn to v62 (@renovate[bot]) +- [#6160](https://github.com/rollup/rollup/pull/6160): chore(deps): update github artifact actions (major) (@renovate[bot]) +- [#6161](https://github.com/rollup/rollup/pull/6161): fix(deps): lock file maintenance minor/patch updates (@renovate[bot], @lukastaegert) +- [#6164](https://github.com/rollup/rollup/pull/6164): chore(deps): update dependency @rollup/plugin-alias to v6 (@renovate[bot]) +- [#6165](https://github.com/rollup/rollup/pull/6165): chore(deps): update dependency @rollup/plugin-commonjs to v29 (@renovate[bot]) +- [#6166](https://github.com/rollup/rollup/pull/6166): fix(deps): update swc monorepo (major) (@renovate[bot], @lukastaegert) +- [#6167](https://github.com/rollup/rollup/pull/6167): chore(deps): lock file maintenance minor/patch updates (@renovate[bot], @lukastaegert) -### Bug Fixes -* Use correct path for dynamic imports if `output.paths` is used (#3508) +## 4.52.5 -### Pull Requests -* [#3508](https://github.com/rollup/rollup/pull/3508): Respect output.paths in dynamic imports (@lukastaegert) +_2025-10-18_ -## 2.7.0 -*2020-04-21* +### Bug Fixes -### Features -* Add `preserveEntrySignatures` option to control how exports of entry points are handled (#3498) -* Add `preserveSignature` flag to `this.emitFile` to control exports of emitted chunks (#3498) -* Add `output.minifyInternalExports` option to control if internal exports are minified (#3498) +- Always produce valid UUIDs as debugIds in sourcemaps (#6144) ### Pull Requests -* [#3498](https://github.com/rollup/rollup/pull/3498): Add option to configure if entry signatures are preserved (@lukastaegert) -## 2.6.1 -*2020-04-12* +- [#6135](https://github.com/rollup/rollup/pull/6135): chore(deps): lock file maintenance minor/patch updates (@renovate[bot], @lukastaegert) +- [#6140](https://github.com/rollup/rollup/pull/6140): chore(deps): update peter-evans/create-or-update-comment action to v5 (@renovate[bot]) +- [#6141](https://github.com/rollup/rollup/pull/6141): chore(deps): update peter-evans/find-comment action to v4 (@renovate[bot]) +- [#6142](https://github.com/rollup/rollup/pull/6142): fix(deps): lock file maintenance minor/patch updates (@renovate[bot], @lukastaegert) +- [#6143](https://github.com/rollup/rollup/pull/6143): chore: eslint enable concurrency option (@btea) +- [#6144](https://github.com/rollup/rollup/pull/6144): fix: generation of debugIDs with invalid length (@pablomatiasgomez, @lukastaegert) +- [#6146](https://github.com/rollup/rollup/pull/6146): chore(deps): lock file maintenance minor/patch updates (@renovate[bot], @lukastaegert) +- [#6147](https://github.com/rollup/rollup/pull/6147): chore(deps): update actions/setup-node action to v6 (@renovate[bot]) -### Bug Fixes -* Close watch mode when stdin closes in a non-TTY environment (#3493) +## 4.52.4 -### Pull Requests -* [#3493](https://github.com/rollup/rollup/pull/3493): Ensure --watch mode exits correctly when stdin is closed (@jakesgordon) +_2025-10-03_ -## 2.6.0 -*2020-04-10* +### Bug Fixes -### Features -* Allow regular expressions to declare external modules (#3482) +- Fix an issue where the wrong branch of nullish coalescing was picked (#6133) ### Pull Requests -* [#3482](https://github.com/rollup/rollup/pull/3482): Allow regular expressions in config.external (@johannes-z) -## 2.5.0 -This version is identical to 2.4.0 +- [#6128](https://github.com/rollup/rollup/pull/6128): Enable npm OIDC publishing (@lukastaegert) +- [#6133](https://github.com/rollup/rollup/pull/6133): Correct nullish coalescing branch resolution for symbol left value (@TrickyPi) +- [#6134](https://github.com/rollup/rollup/pull/6134): fix(deps): lock file maintenance minor/patch updates (@renovate[bot], @lukastaegert) -## 2.4.0 -*2020-04-09* +## 4.52.3 -### Features -* Add support for most private and public class field features (#3488) +_2025-09-27_ ### Bug Fixes -* Do not replace `this` with `undefined` in class field definitions (#3488) -### Pull Requests -* [#3488](https://github.com/rollup/rollup/pull/3488): Rollup class fields support (@guybedford and @lukastaegert) +- Fix check in native loader for environments that do not support reports (#6123) -## 2.3.5 -*2020-04-09* +### Pull Requests -### Bug Fixes -* Never remove labels when tree-shaking is disabled (#3492) +- [#6123](https://github.com/rollup/rollup/pull/6123): fix(native-loader): safely handle report.getReport() on Termux/Android (@Jobians, @lukastaegert) +- [#6124](https://github.com/rollup/rollup/pull/6124): chore(deps): pin msys2/setup-msys2 action to fb197b7 (@renovate[bot]) +- [#6125](https://github.com/rollup/rollup/pull/6125): fix(deps): lock file maintenance minor/patch updates (@renovate[bot]) +- [#6126](https://github.com/rollup/rollup/pull/6126): chore(deps): lock file maintenance minor/patch updates (@renovate[bot]) -### Pull Requests -* [#3492](https://github.com/rollup/rollup/pull/3492): Always use a new inclusion context when including declarations of variables, always inlcude labels when not treeshaking (@lukastaegert) +## 4.52.2 -## 2.3.4 -*2020-04-07* +_2025-09-23_ ### Bug Fixes -* Handle re-exporting synthetic exports from entry-points (#3319) -* Fix cross-chunk imports of synthetic exports (#3319) -* Handle namespace objects that contain re-exported synthetic namespaces (#3319) -### Pull Requests -* [#3319](https://github.com/rollup/rollup/pull/3319): Handle re-exports of synthetic named exports (@manucorporat and @lukastaegert) +- Fix Android build crashing due to failed dlopen (#6109) -## 2.3.3 -*2020-04-04* +### Pull Requests -### Bug Fixes -* Add external namespaces to dynamic namespace objects (#3474) +- [#6109](https://github.com/rollup/rollup/pull/6109): fix(rust): use prebuilt std when it is available (@cyyynthia) -### Pull Requests -* [#3474](https://github.com/rollup/rollup/pull/3474): Support external star exports on namespace objects (@guybedford) +## 4.52.1 -## 2.3.2 -*2020-03-31* +_2025-09-23_ ### Bug Fixes -* Only warn but do not fail build when a namespace is called as a function (#3475) -* Make sure pre-existing sourcemap comments are also removed when rebuilding using the cache (#3476) -### Pull Requests -* [#3475](https://github.com/rollup/rollup/pull/3475): Call namespace error as a warning (@guybedford) -* [#3476](https://github.com/rollup/rollup/pull/3476): Store locations for removed comments in cache (@lukastaegert) +- Opt-out of dynamic import optimization when using top-level await to effectively prevent deadlocks (#6121) -## 2.3.1 -*2020-03-30* +### Pull Requests -### Bug Fixes -* Do not fail if the config file returns an function returning a Promise (#3472) +- [#6121](https://github.com/rollup/rollup/pull/6121): Simplify top-level await deadlock prevention (@lukastaegert) -### Pull Requests -* [#3472](https://github.com/rollup/rollup/pull/3472): Fix support for async functions as config (@lukastaegert) +## 4.52.0 -## 2.3.0 -*2020-03-29* +_2025-09-19_ ### Features -* Do not transpile config files with `.mjs` extension in Node 13+ or `.cjs` extension in any Node version and load them appropriately (#3445) -* Extract helper to load a config file the way rollup does it via `rollup/dist/loadConfigFile` (#3445) -### Bug Fixes -* Keep watching the config file if an error occurs during initial load in watch node (#3445) -* Add a helpful error message when using a transpiled config in a repository with "type": "module" (#3445) +- Add option `output.onlyExplicitManualChunks` to turn off merging additional dependencies into manual chunks (#6087) +- Add support for x86_64-pc-windows-gnu platform (#6110) ### Pull Requests -* [#3445](https://github.com/rollup/rollup/pull/3445): Support native ESM configs in Node 13, support untranspiled configs (@lukastaegert) -* [#3468](https://github.com/rollup/rollup/pull/3468): Don't use esm output format alias in the documentation (@vsn4ik) - -## 2.2.0 -*2020-03-24* - -### Features -* Add `renderDynamicImport` hook to rewrite dynamic import expressions (#3449) -* Add information about dynamically imported modules to `this.getModuleInfo` (#3449) -### Bug Fixes -* Make file emission work with Uin8Array sources when using Rollup in the browser (#3452) -* Fix types to allow watch to accept an array of configs (#3453) -* Do not strip `.js` extensions from AMD imports when the import is a user-supplied replacement for a non-resolvable dynamic import target (#3453) +- [#6087](https://github.com/rollup/rollup/pull/6087): fix: manualChunks and non manualChunks shared dependencies are merged with the first manualChunk encountered alphabetically (@maiieul) +- [#6110](https://github.com/rollup/rollup/pull/6110): Add support x86_64-pc-windows-gnu (@lsq, @lukastaegert) +- [#6118](https://github.com/rollup/rollup/pull/6118): Automatically remove REPL artefacts label from PRs (@lukastaegert) -### Pull Requests -* [#3449](https://github.com/rollup/rollup/pull/3449): Add hook to rewrite dynamic import expressions (@lukastaegert) -* [#3452](https://github.com/rollup/rollup/pull/3452): Avoid the assumption of Buffer in browser envs (@JoviDeCroock) -* [#3453](https://github.com/rollup/rollup/pull/3453): fix types since watch accepts single or array config (@lukeed) -* [#3456](https://github.com/rollup/rollup/pull/3456): fix SystemJS url in tutorial (@guybedford) +## 4.51.0 -## 2.1.0 -*2020-03-18* +_2025-09-19_ ### Features -* Allow specifying an importer when emitting files to resolve relative ids (#3442) - -### Pull Requests -* [#3442](https://github.com/rollup/rollup/pull/3442): Add optional `importer` parameter to `this.emitFile` (@lukastaegert) -## 2.0.6 -*2020-03-13* +- Support ROLLUP_FILE_URL_OBJ placeholder to inject file URLs into the generated code (#6108) ### Bug Fixes -* Do not use file names from different outputs when generating sourcemaps using the `dir` option (#3440) - -### Pull Requests -* [#3440](https://github.com/rollup/rollup/pull/3440): Use correct file names when writing sourcemaps for multiple outputs (@lukastaegert) - -## 2.0.5 -*2020-03-12* -### Bug Fixes -* Fix an issue where conditional statements would assume they have the wrong test value (#3438) +- Improve OpenHarmony build to work in more situations (#6115) ### Pull Requests -* [#3438](https://github.com/rollup/rollup/pull/3438): Make sure logical expressions always check the left argument for side-effects (@lukastaegert) - -## 2.0.4 -*2020-03-12* -### Bug Fixes -* Avoid conflicts between namespace imports when preserving modules (#3435) +- [#6108](https://github.com/rollup/rollup/pull/6108): feat: support ROLLUP_FILE_URL_OBJ for URL object instead of string (@guybedford, @lukastaegert) +- [#6112](https://github.com/rollup/rollup/pull/6112): Disable Cargo cache for Android (@lukastaegert) +- [#6113](https://github.com/rollup/rollup/pull/6113): fix(deps): update rust crate swc_compiler_base to v35 (@renovate[bot]) +- [#6114](https://github.com/rollup/rollup/pull/6114): chore(deps): lock file maintenance minor/patch updates (@renovate[bot]) +- [#6115](https://github.com/rollup/rollup/pull/6115): Disable local_dynamic_tls for OpenHarmony (@hqzing) +- [#6116](https://github.com/rollup/rollup/pull/6116): chore(deps): lock file maintenance minor/patch updates (@renovate[bot]) +- [#6117](https://github.com/rollup/rollup/pull/6117): chore(deps): lock file maintenance (@renovate[bot]) -### Pull Requests -* [#3435](https://github.com/rollup/rollup/pull/3435): Deconflict multiple `index` imports for ES format using nested export star statements (@kamranayub) +## 4.50.2 -## 2.0.3 -*2020-03-10* +_2025-09-15_ ### Bug Fixes -* Add type for this.getCombinedSourcemap to transform context (#3431) -### Pull Requests -* [#3377](https://github.com/rollup/rollup/pull/3377): Switch to yargs-parser lib (@jamesgeorge007) -* [#3426](https://github.com/rollup/rollup/pull/3426): Use strict types with PluginDriver (@NotWoods) -* [#3431](https://github.com/rollup/rollup/pull/3431): Add missing type declaration for getCombinedSourcemap (@Anidetrix) -* [#3432](https://github.com/rollup/rollup/pull/3432): Detail how return values from `augmentChunkHash` are used (@jakearchibald) - -## 2.0.2 -*2020-03-07* - -### Bug Fixes -* Make sure the ESM import still works (#3430) +- Resolve an issue where unused destructured array pattern declarations would conflict with included variables (#6100) ### Pull Requests -* [#3430](https://github.com/rollup/rollup/pull/3430): Fix conditional exports again (@lukastaegert) -## 2.0.1 -*2020-03-07* +- [#6100](https://github.com/rollup/rollup/pull/6100): Tree-shake un-included elements in array pattern (@TrickyPi) +- [#6102](https://github.com/rollup/rollup/pull/6102): chore(deps): update actions/setup-node action to v5 (@renovate[bot]) +- [#6103](https://github.com/rollup/rollup/pull/6103): chore(deps): update dependency eslint-plugin-unicorn to v61 (@renovate[bot]) +- [#6104](https://github.com/rollup/rollup/pull/6104): fix(deps): update swc monorepo (major) (@renovate[bot]) +- [#6105](https://github.com/rollup/rollup/pull/6105): fix(deps): lock file maintenance minor/patch updates (@renovate[bot]) +- [#6107](https://github.com/rollup/rollup/pull/6107): Improve CI stability (@lukastaegert) -### Bug Fixes -* Reenable importing rollup in Node 13.0 - 13.7 (#3428) - -### Pull Requests -* [#3428](https://github.com/rollup/rollup/pull/3428): Fix conditional exports in Node 13.0 - 13.7 (@lukastaegert) - -## 2.0.0 -*2020-03-06* - -### Breaking Changes -* Rollup now requires at least Node 10 to run, or a sufficiently modern browser (#3346) -* The file structure of Rollup's ESM builds has changed: - - The main ESM entry point is now at `rollup/dist/es/rollup.js` instead of `rollup/dist/rollup.es.js` - - The ESM browser build is at `rollup/dist/es/rollup.browser.js` instead of `rollup/dist/rollup.browser.es.js` - - In general, the ESM builds now follow the same naming scheme as the CJS builds but are located in the `rollup/dist/es` subfolder instead of `rollup/dist` (#3391) -* The "watch.chokidar" option no longer accepts a `boolean` value but only an object of parameters that is passed to the bundled Chokidar instance. Chokidar installations by the user will be ignored in favour of the bundled instance (#3331) -* Modules that are completely tree-shaken will no longer be listed as part of any chunks in `generateBundle` -* The `experimentalOptimizeChunks` and `chunkGroupingSize` options have been removed -* [acorn](https://github.com/acornjs/acorn) plugins can only be used if they accept a passed-in acorn instance instead of importing it themselves. See https://github.com/acornjs/acorn/pull/870#issuecomment-527339830 for what needs to be done to make plugins compatible that do not support this yet (#3391) -* Emitted chunks now have the TypeScript type `Uint8Array` instead of `Buffer`. A `Buffer` can still be used, though (#3395) -* The TypeScript types no longer use ESTree types for AST nodes but a very generic type that does not contain information specific to certain node types (#3395) -* The signature of the `writeBundle` plugin hook has been changed to match `generateBundle`: The bundle object is now passed as second parameter instead of first and the first parameter is the output options (#3361) -* The following plugin hooks have been removed: - - ongenerate: use `generateBundle` instead - - onwrite: use `writeBundle` instead - - transformBundle: use `renderChunk` instead - - transformChunk: use `renderChunk` instead -* You can no longer access `this.watcher` on the plugin context. -* The `transform` hook can no longer return `dependencies`. -* The `treeshake.pureExternalModules` option will now show a deprecation warning when used: use `treeshake.moduleSideEffects: 'no-external'` instead -* Using `import.meta.ROLLUP_ASSET_URL_<..>` and `import.meta.ROLLUP_CHUNK_URL_<..>` in code will now show warnings: use `import.meta.ROLLUP_FILE_URL_<..>` instead -* The `resolveAssetUrl` hook will now show a deprecation warning when used: use `resolveFileUrl` instead -* The following plugin context functions will show warnings when used: - - `this.emitAsset`: use `this.emitFile` - - `this.emitChunk`: use `this.emitFile` - - `this.getAssetFileName`: use `this.getFileName` - - `this.getChunkFileName`: use `this.getFileName` - - `this.isExternal`: use `this.resolve` - - `this.resolveId`: use `this.resolve` -* Directly adding properties to the bundle object in the `generateBundle` is deprecated will show a warning (removing properties is allowed, though): Use `this.emitFile` -* Accessing `chunk.isAsset` on the bundle is deprecated: Use `chunk.type === 'asset'` instead -* The error code for a missing `name` property when targeting UMD has been changed to `MISSING_NAME_OPTION_FOR_IIFE_EXPORT` to emphasize this is needed for the IIFE part of UMD (#3393) +## 4.50.1 -### Features -* Rollup now bundles [Chokidar](https://github.com/paulmillr/chokidar) for a better watch experience (#3331) -* Rollup now bundles [acorn](https://github.com/acornjs/acorn) again, removing its only external dependency (#3391) -* Do not consider empty imports from side-effect-free modules for chunking and hoist side-effect imports if necessary (#3369) -* Rollup can now be imported as an ES module in Node via `import {rollup} from 'rollup'`. Note that this relies on Node's experimental [conditional package exports](https://nodejs.org/dist/latest-v13.x/docs/api/esm.html#esm_conditional_exports) feature and is therefore itself experimental (#3391) -* `systemjs` can be used as format alias for `system` (#3381) +_2025-09-07_ ### Bug Fixes -* Unknown output options now trigger a warning when using the JavaScript API (#3352) -* Rollup will no longer introduce Node types into TypeScript projects that do not use them (#3395) -* Generate correct sourcemaps when tree-shaking occurs in a multi-file bundle (#3423) - -### Pull Requests -* [#3331](https://github.com/rollup/rollup/pull/3331): Bundle Chokidar (@lukastaegert) -* [#3343](https://github.com/rollup/rollup/pull/3343): Remove experimentalOptimizeChunks (@lukastaegert) -* [#3346](https://github.com/rollup/rollup/pull/3346): Update minimum required Node version to 10 (@lukastaegert) -* [#3352](https://github.com/rollup/rollup/pull/3352): Remove active deprecations (@lukastaegert) -* [#3361](https://github.com/rollup/rollup/pull/3361): Change writeBundle signature to match generateBundle (@lukastaegert) -* [#3369](https://github.com/rollup/rollup/pull/3369): Avoid empty imports from side-effect-free chunks (@lukastaegert) -* [#3381](https://github.com/rollup/rollup/pull/3381): Rename esm to es everywhere, add systemjs alias (@lukastaegert) -* [#3391](https://github.com/rollup/rollup/pull/3391): Bundle acorn, allow importing Rollup as Node ES module, update dependencies (@lukastaegert) -* [#3393](https://github.com/rollup/rollup/pull/3393): Better error code for name-less umd bundle (@rail44) -* [#3395](https://github.com/rollup/rollup/pull/3395): Remove `@types` dependencies (@lukastaegert) -* [#3423](https://github.com/rollup/rollup/pull/3423): Update magic-string and fix sourcemaps (@lukastaegert) - -## 1.32.1 -*2020-03-06* -### Bug Fixes -* Handle default export detection for AMD and IIFE externals that do not have a prototype (#3420) -* Handle missing whitespace when the else branch of an if-statement is simplified (#3421) -* Mention the importing module when reporting errors for missing named exports (#3401) -* Add code to warning for missing output.name of IIFE bundles (#3372) +- Resolve a situation where a destructuring default value was removed (#6090) ### Pull Requests -* [#3372](https://github.com/rollup/rollup/pull/3372): Add warning code for missing output.name of IIFE bundle that has export (@rail44) -* [#3401](https://github.com/rollup/rollup/pull/3401): Missing exports errors now print the importing module (@timiyay) -* [#3418](https://github.com/rollup/rollup/pull/3418): Structure lifecycle hooks, add links to build time hooks (@lukastaegert) -* [#3420](https://github.com/rollup/rollup/pull/3420): Update generated code of getInteropBlock() to work with null prototype objects (@jdalton) -* [#3421](https://github.com/rollup/rollup/pull/3421): Avoid invalid code when "else" branch is simplified (@lukastaegert) - -## 1.32.0 -*2020-02-28* -### Features -* Allow adding plugins on the command line via `--plugin ` (#3379) +- [#6088](https://github.com/rollup/rollup/pull/6088): feat(www): shorter repl shareables (@cyyynthia, @lukastaegert) +- [#6090](https://github.com/rollup/rollup/pull/6090): Call includeNode for self or children nodes in includeDestructuredIfNecessary (@TrickyPi) +- [#6091](https://github.com/rollup/rollup/pull/6091): fix(deps): update rust crate swc_compiler_base to v33 (@renovate[bot]) +- [#6092](https://github.com/rollup/rollup/pull/6092): chore(deps): lock file maintenance minor/patch updates (@renovate[bot]) +- [#6094](https://github.com/rollup/rollup/pull/6094): perf: replace startsWith with strict equality (@btea) -### Pull Requests -* [#3379](https://github.com/rollup/rollup/pull/3379): introduce CLI --plugin support (@kzc) -* [#3390](https://github.com/rollup/rollup/pull/3390): fix typo: this.addWatchfile (@mistlog) -* [#3392](https://github.com/rollup/rollup/pull/3392): Bump codecov from 3.6.1 to 3.6.5 -* [#3404](https://github.com/rollup/rollup/pull/3404): Update resolveFileUrl docs (@jakearchibald) +## 4.50.0 -## 1.31.1 -*2020-02-14* +_2025-08-31_ -### Bug Fixes -* Make sure errored files are always re-evaluated in watch mode to avoid an issue in the typescript plugin (#3388) +### Features -### Pull Requests -* [#3366](https://github.com/rollup/rollup/pull/3366): Correct spelling minifaction to minification (@VictorHom) -* [#3371](https://github.com/rollup/rollup/pull/3371): Adjust bug template to mention REPL.it (@lukastaegert) -* [#3388](https://github.com/rollup/rollup/pull/3388): Run transform hooks again in watch mode on files that errored (@lukastaegert) +- Support openharmony-arm64 platform (#6081) -## 1.31.0 -*2020-01-31* +### Bug Fixes -### Features -* Always disable tree-shaking for asm.js functions to maintain semantics (#3362) +- Fix loading of extensionless imports in config files (#6084) ### Pull Requests -* [#3362](https://github.com/rollup/rollup/pull/3362): Preserve asm.js code (@lukastaegert) - -## 1.30.1 -*2020-01-27* -### Bug Fixes -* Do not mistreat static entgry points as dynamic ones when chunking (#3357) -* Resolve a crash when chunking circular dynamic imports (#3357) +- [#6081](https://github.com/rollup/rollup/pull/6081): Add support for openharmony-arm64 platform (@hqzing, @lukastaegert) +- [#6084](https://github.com/rollup/rollup/pull/6084): Return null to defer to the default resolution behavior (@TrickyPi) -### Pull Requests -* [#3357](https://github.com/rollup/rollup/pull/3357): Resolve issues with circular dynamic entries (@lukastaegert) +## 4.49.0 -## 1.30.0 -*2020-01-27* +_2025-08-27_ ### Features -* Do not split chunks when dynamically imported modules import modules that are already loaded by all dynamic importers (#3354) -* Add `hoistTransitiveImports` option to disable hoisting imports of static dependencies into entry chunks (#3353) -### Bug Fixes -* Make sure polyfills are always loaded first when each static entry point contains them as first import (#3354) +- Allow config plugins to resolve imports first before deciding whether to treat them as external (#6038) ### Pull Requests -* [#3353](https://github.com/rollup/rollup/pull/3353): Add option to avoid hoisting transitive imports (@lukastaegert) -* [#3354](https://github.com/rollup/rollup/pull/3354): Improve chunking algorithm for dynamic imports (@tjenkinson and @lukastaegert) - -## 1.29.1 -*2020-01-21* -### Bug Fixes -* Avoid crashes for circular reexports when named exports cannot be found (#3350) - -### Pull Requests -* [#3335](https://github.com/rollup/rollup/pull/3335): Fix typo (@robbinworks) -* [#3342](https://github.com/rollup/rollup/pull/3342): Remove ":" from test file names for Windows and update dependencies (@lukastaegert) -* [#3350](https://github.com/rollup/rollup/pull/3350): Properly handle circular reexports (@lukastaegert) +- [#6038](https://github.com/rollup/rollup/pull/6038): feat: Run external check in `cli/run/loadConfigFile.ts` as last in order to allow handling of e.g. workspace package imports in TS monorepos correctly (@stazz, @TrickyPi) +- [#6082](https://github.com/rollup/rollup/pull/6082): Improve build pipeline performance (@lukastaegert) -## 1.29.0 -*2020-01-08* +## 4.48.1 -### Features -* Enable top-level await by default (#3089) -* Add typings for watch events (#3302) +_2025-08-25_ ### Bug Fixes -* Deconflict files that would conflict only on a case-insensitive OS (#3317) -* Do not fail in certain scenarios where a logical expression inside a sequence expression was being directly included (#3327) + +- Correctly ignore white-space in JSX strings around line-breaks (#6051) ### Pull Requests -* [#3089](https://github.com/rollup/rollup/pull/3089): Move top-level await out of experimental (@guybedford) -* [#3302](https://github.com/rollup/rollup/pull/3302): Adds type definitions for RollupWatcher events (@NotWoods) -* [#3317](https://github.com/rollup/rollup/pull/3317): Fix module id conflict on a case insensitive OS (@yesmeck) -* [#3327](https://github.com/rollup/rollup/pull/3327): Handle deoptimizations while a node is being included (@lukastaegert) -## 1.28.0 -*2020-01-04* +- [#6051](https://github.com/rollup/rollup/pull/6051): fix: handle whitespace according to JSX common practice (@cyyynthia) +- [#6078](https://github.com/rollup/rollup/pull/6078): build: optimize pipeline take two (@cyyynthia) -### Features -* Allow piping in stdin via the command line interface (#3312, #3290) -* Allow plugins to mark modules as having syntheticNamedExports for e.g. better CJS interoperability (#3295) -* Ignore variable reassignments in dead code when tree-shaking to remove more unneeded code (#3212) +## 4.48.0 -### Bug Fixes -* Properly respect tree-shaken code when generating sourcemaps (#3318) +_2025-08-23_ -### Pull Requests -* [#3212](https://github.com/rollup/rollup/pull/3212): Handle assignments in dead code (@tjenkinson) -* [#3290](https://github.com/rollup/rollup/pull/3290): Implement stdin input with optional "-" as the file name (@kzc) -* [#3295](https://github.com/rollup/rollup/pull/3295): Add syntheticNamedExports (@manucorporat) -* [#3300](https://github.com/rollup/rollup/pull/3300): Add note about setting `types` in tsconfig file (@tjenkinson) -* [#3303](https://github.com/rollup/rollup/pull/3303): Use ! to assert not-null in TypeScript (@NotWoods) -* [#3312](https://github.com/rollup/rollup/pull/3312): Implement stdin input (@lukastaegert) -* [#3318](https://github.com/rollup/rollup/pull/3318): Update magic-string and other dependencies (@lukastaegert) +### Features -## 1.27.14 -*2019-12-22* +- If configured, also keep unparseable import attributes of external dynamic imports in the output(#6071) ### Bug Fixes -* Update references to official rollup plugins in error messages (#3297, #3298) -### Pull Requests -* [#3286](https://github.com/rollup/rollup/pull/3286): Update link to JavaScript API documentation (@romankaravia) -* [#3294](https://github.com/rollup/rollup/pull/3294): Update deprecated references to the node-resolve plugin in the documentation (@Vlad-Shcherbina) -* [#3297](https://github.com/rollup/rollup/pull/3297): Update references to rollup-plugin-json (@cprecioso) -* [#3298](https://github.com/rollup/rollup/pull/3298): Update references to official rollup plugins (@cprecioso) +- Ensure variables referenced in non-removed import attributes are included (#6071) -## 1.27.13 -*2019-12-14* +### Pull Requests -### Bug Fixes -* Do not truncate environment variable values at the first colon when using the `--environment` option (#3283) +- [#6071](https://github.com/rollup/rollup/pull/6071): Keep attributes for external dynamic imports (@TrickyPi) +- [#6079](https://github.com/rollup/rollup/pull/6079): fix(deps): update swc monorepo (major) (@renovate[bot]) +- [#6080](https://github.com/rollup/rollup/pull/6080): fix(deps): lock file maintenance minor/patch updates (@renovate[bot]) -### Pull Requests -* [#3283](https://github.com/rollup/rollup/pull/3283): Allow environment variables to contain colons (@tlaverdure) +## 4.47.1 -## 1.27.12 -*2019-12-13* +_2025-08-21_ ### Bug Fixes -* Prevent invalid AMD or SystemJS code when accessing `import.meta` (#3282) + +- Revert build process changes to investigate issues (#6077) ### Pull Requests -* [#3282](https://github.com/rollup/rollup/pull/3282): Always make "module" available for SystemJS and AMD formats if `import.meta` is accessed directly (@lukastaegert) -## 1.27.11 -*2019-12-12* +- [#6077](https://github.com/rollup/rollup/pull/6077): Revert "build: aggressively optimize wasm build, improve pipeline (#6053)" (@lukastaegert) -### Bug Fixes -* Resolve a crash due to an infinite loop (#3280) +## 4.47.0 -### Pull Requests -* [#3280](https://github.com/rollup/rollup/pull/3280): Prevent infinite deoptimizations (@lukastaegert) +_2025-08-21_ -## 1.27.10 -*2019-12-11* +### Features + +- Aggressively reduce WASM build size (#6053) ### Bug Fixes -* Keep track of function return values in more situations (#3278) -### Pull Requests -* [#3278](https://github.com/rollup/rollup/pull/3278): Avoid some unnecessary value tracking deoptimizations (@lukastaegert) +- Fix illegal instruction error on Android ARM platforms (#6072) +- Allow to pass explicit `undefined` for optional fields in Rollup types (#6061) -## 1.27.9 -*2019-12-07* +### Pull Requests -### Bug Fixes -* Fix an issue where reexports could be missing when preserving modules (#3273) -* Allow turning of color output via NO_COLOR or FORCE_COLOR=0 environment variables (#3272) +- [#6053](https://github.com/rollup/rollup/pull/6053): build: aggressively optimize wasm build, improve pipeline (@cyyynthia) +- [#6061](https://github.com/rollup/rollup/pull/6061): fix(types): add support for exactOptionalPropertyTypes (@remcohaszing, @lukastaegert) +- [#6072](https://github.com/rollup/rollup/pull/6072): build(rust): mimalloc-safe/no_opt_arch on aarch64 (@cyyynthia) -### Pull Requests -* [#3272](https://github.com/rollup/rollup/pull/3272): Support either NO_COLOR or FORCE_COLOR=0 to turn off color (@kikonen) -* [#3273](https://github.com/rollup/rollup/pull/3273): Make sure that indirectly reexported modules also become chunk dependencies when preserving modules(@lukastaegert) +## 4.46.4 -## 1.27.8 -*2019-12-02* +_2025-08-20_ ### Bug Fixes -* Deoptimize objects when a method is called on them to make sure modifications via "this" are observed (#3266) -### Pull Requests -* [#3266](https://github.com/rollup/rollup/pull/3266): Workaround for various object literal mutation bugs (@kzc) +- Do not omit synthetic namespaces when only accessed via `in` operator (#6052) -## 1.27.7 -*2019-12-01* +### Pull Requests -### Bug Fixes -* Fix a scenario where a reassignments to computed properties were not tracked (#3267) +- [#6052](https://github.com/rollup/rollup/pull/6052): fix: don't optimize `in` with `syntheticNamedExports` (@hi-ogawa) +- [#6074](https://github.com/rollup/rollup/pull/6074): Update transitive dependency to fix audit (@lukastaegert) -### Pull Requests -* [#3267](https://github.com/rollup/rollup/pull/3267): Fix incomplete computed property deoptimization (@lukastaegert) +## 4.46.3 -## 1.27.6 -*2019-11-30* +_2025-08-18_ ### Bug Fixes -* Use "auto" export mode by default for all modules when preserving modules (#3265) -* Observe "output.exports" when preserving modules and warn for mixed exports if necessary (#3265) -### Pull Requests -* [#3265](https://github.com/rollup/rollup/pull/3265): Use export mode "auto" by default when preserving modules (@lukastaegert) +- Resolve illegal instruction error on arm64 architectures (#6055) +- Resolve sourcemap generation performance regression (#6057) -## 1.27.5 -*2019-11-25* +### Pull Requests -### Bug Fixes -* Make sure namespaces for inlined dynamic imports are treated as variable accesses when deconflicting (#3256) +- [#6043](https://github.com/rollup/rollup/pull/6043): Avoid `generated by` comment diff on Windows (@sapphi-red) +- [#6048](https://github.com/rollup/rollup/pull/6048): chore(deps): update dependency cross-env to v10 (@renovate[bot], @lukastaegert) +- [#6049](https://github.com/rollup/rollup/pull/6049): fix(deps): lock file maintenance minor/patch updates (@renovate[bot]) +- [#6055](https://github.com/rollup/rollup/pull/6055): Fix illegal instruction error on arm64 by enabling `no_opt_arch` feature for mimalloc-safe (@sapphi-red) +- [#6057](https://github.com/rollup/rollup/pull/6057): fix: tweak the fallback logic for tracing segment (@TrickyPi, @lukastaegert) +- [#6062](https://github.com/rollup/rollup/pull/6062): docs: update Rust toolchain instructions (@situ2001, @lukastaegert) +- [#6063](https://github.com/rollup/rollup/pull/6063): fix(deps): lock file maintenance minor/patch updates (@renovate[bot], @lukastaegert) +- [#6067](https://github.com/rollup/rollup/pull/6067): chore(deps): update actions/checkout action to v5 (@renovate[bot], @lukastaegert) +- [#6068](https://github.com/rollup/rollup/pull/6068): chore(deps): update actions/download-artifact action to v5 (@renovate[bot]) +- [#6069](https://github.com/rollup/rollup/pull/6069): fix(deps): update rust crate swc_compiler_base to v31 (@renovate[bot], @lukastaegert) -### Pull Requests -* [#3256](https://github.com/rollup/rollup/pull/3256): Avoid name conflicts when inlining dynamic imports nested in functions (@lukastaegert) -* [#3257](https://github.com/rollup/rollup/pull/3257): Update dependencies (@lukastaegert) +## 4.46.2 -## 1.27.4 -*2019-11-22* +_2025-07-29_ ### Bug Fixes -* Aggregate circular dependency warnings in the CLI (#3249) -* Do not defer non-aggregated handlers in the CLI (#3249) -### Pull Requests -* [#3249](https://github.com/rollup/rollup/pull/3249): Fix broken Windows CLI tests (@lukastaegert) -* [#3251](https://github.com/rollup/rollup/pull/3251): Add installation as a separate header (@ashrith-kulai) +- Fix in-operator handling for external namespace and when the left side cannot be analyzed (#6041) -## 1.27.3 -*2019-11-20* +### Pull Requests -### Bug Fixes -* Provide better warning when empty chunks are created in a code-splitting scenario (#3244) +- [#6041](https://github.com/rollup/rollup/pull/6041): Correct the logic of include in BinaryExpression and don't optimize external references away (@TrickyPi, @cyyynthia, @lukastaegert) -### Pull Requests -* [#3244](https://github.com/rollup/rollup/pull/3244): Clearer empty chunk warning (@tjenkinson) +## 4.46.1 -## 1.27.2 -*2019-11-18* +_2025-07-28_ ### Bug Fixes -* Fix an issue where live bindings were not working correctly when using `+=` in SystemJS (#3242) -### Pull Requests -* [#3242](https://github.com/rollup/rollup/pull/3242): Export updated assignments when using shorthand update assignment expressions in SystemJS (@lukastaegert) +- Do not fail when using the `in` operator on external namespaces (#6036) -## 1.27.1 -*2019-11-18* +### Pull Requests -### Bug Fixes -* Fix an issue where code after a switch-statement with removed cases was erroneously not included (#3241) +- [#6036](https://github.com/rollup/rollup/pull/6036): disables optimization for external namespace when using the in operator (@TrickyPi) -### Pull Requests -* [#3237](https://github.com/rollup/rollup/pull/3237): make `acornOptions` optional in `parse()` in docs (@tjenkinson) -* [#3240](https://github.com/rollup/rollup/pull/3240): Update dependencies and fix vulnerability (@lukastaegert) -* [#3241](https://github.com/rollup/rollup/pull/3241): Do not truncate after switch-statement with removed case (@lukastaegert) +## 4.46.0 -## 1.27.0 -*2019-11-12* +_2025-07-27_ ### Features -* Add support for output-specific plugins (#3218) -* Reenable parallel output processing when using the CLI (#3218) -* Warn if files are emitted that would overwrite previously emitted files (#3218) -### Bug Fixes -* Do not overwrite files emitted in other builds if outputs are generated in parallel (#3218) +- Optimize `in` checks on namespaces to keep them treeshake-able (#6029) ### Pull Requests -* [#3218](https://github.com/rollup/rollup/pull/3218): Per output plugins (@lukastaegert) - -## 1.26.5 -*2019-11-11* -### Bug Fixes -* Fix a regression where it was no longer to pass a certain option format to generate (#3223) +- [#5991](https://github.com/rollup/rollup/pull/5991): feat: update linux-loongarch64-gnu (@wojiushixiaobai, @lukastaegert) +- [#6029](https://github.com/rollup/rollup/pull/6029): feat: optimize `in` checks on namespaces to keep them treeshake-able (@cyyynthia, @lukastaegert) +- [#6033](https://github.com/rollup/rollup/pull/6033): fix(deps): update swc monorepo (major) (@renovate[bot], @lukastaegert) -### Pull Requests -* [#3223](https://github.com/rollup/rollup/pull/3223): Allow passing input options to output (@lukastaegert) +## 4.45.3 -## 1.26.4 -*2019-11-09* +_2025-07-26_ ### Bug Fixes -* Keep watching known files after a plugin error during the initial build (#3219) -### Pull Requests -* [#3216](https://github.com/rollup/rollup/pull/3216): Fix small typo (@kaisermann) -* [#3217](https://github.com/rollup/rollup/pull/3217): Update dependencies and fix security vulnerability (@lukastaegert) -* [#3219](https://github.com/rollup/rollup/pull/3219): Also recover from plugin errors during the initial build (@lukastaegert) +- Do not fail build if a const is reassigned but warn instead (#6020) +- Fail with a helpful error message if an exported binding is not defined (#6023) -## 1.26.3 -*2019-11-02* +### Pull Requests -### Bug Fixes -* Work around an incompatibility with rollup-plugin-dts (#3211) +- [#6014](https://github.com/rollup/rollup/pull/6014): chore(deps): update dependency @vue/language-server to v3 (@renovate[bot]) +- [#6015](https://github.com/rollup/rollup/pull/6015): chore(deps): update dependency vue-tsc to v3 (@renovate[bot], @lukastaegert) +- [#6016](https://github.com/rollup/rollup/pull/6016): fix(deps): update swc monorepo (major) (@renovate[bot], @lukastaegert) +- [#6017](https://github.com/rollup/rollup/pull/6017): fix(deps): lock file maintenance minor/patch updates (@renovate[bot], @lukastaegert) +- [#6020](https://github.com/rollup/rollup/pull/6020): Make const reassignments only a warning (@lukastaegert) +- [#6023](https://github.com/rollup/rollup/pull/6023): Throw descriptive error message for used export is not defined (@TrickyPi) +- [#6027](https://github.com/rollup/rollup/pull/6027): feat: upgrade to NAPI-RS 3 stable (@Brooooooklyn) +- [#6028](https://github.com/rollup/rollup/pull/6028): Update eslint-plugin-unicorn to resolve vulnerability (@lukastaegert) +- [#6034](https://github.com/rollup/rollup/pull/6034): fix(deps): lock file maintenance minor/patch updates (@renovate[bot], @lukastaegert) -### Pull Requests -* [#3211](https://github.com/rollup/rollup/pull/3211): Do no fail if the source attribute is `undefined` in an unused named export (@lukastaegert) +## 4.45.1 -## 1.26.2 -*2019-10-31* +_2025-07-15_ ### Bug Fixes -* Do not create invalid code when using `treeshake: false` and star re-exports (#3209) -### Pull Requests -* [#3209](https://github.com/rollup/rollup/pull/3209): Also remove export-all declarations when not tree-shaking (@lukastaegert) +- Resolve crash when using certain conditional expressions (#6009) -## 1.26.1 -*2019-10-31* +### Pull Requests -### Bug Fixes -* Prevent an issue where outputs would overwrite files emitted by other outputs (#3201) -* Do not throw an error if the config file does not have a .js extension (#3204) +- [#6009](https://github.com/rollup/rollup/pull/6009): Add hasDeoptimizedCache flag for ConditionalExpression (@TrickyPi) -### Pull Requests -* [#3201](https://github.com/rollup/rollup/pull/3201): Make the CLI run generate/output in serial (@marijnh) -* [#3204](https://github.com/rollup/rollup/pull/3204): support all config file extensions (.js,.mjs,...) (@arlac77) +## 4.45.0 -## 1.26.0 -*2019-10-27* +_2025-07-12_ ### Features -* Only warn when no output is provided for an IIFE bundle but still produce valid code (#3181) -* Support reexporting namespaces as a binding (#3193) -* Switch from hash.js to crypto for hashing in the Node build for better performance and support for very large assets (#3194) + +- Improve tree-shaking when both branches of a conditional expression return the same boolean value (#6000) +- In environments that support both CJS and ESM, prefer the ESM build of Rollup (#6005) ### Bug Fixes -* Correctly handle chunks reexporting the same namespace as two different bindings (#3193) -### Pull Requests -* [#3181](https://github.com/rollup/rollup/pull/3181): Remove the need to provide an output name for IIFE bundles (@bterrier) -* [#3193](https://github.com/rollup/rollup/pull/3193): Add support for "export * as name from …" (@lukastaegert) -* [#3194](https://github.com/rollup/rollup/pull/3194): Add support for large assets (> 100 MB) (@SebastianNiemann) +- Ensure static blocks do not prevent tree-shaking if they access `this` (#6001) -## 1.25.2 -*2019-10-23* +### Pull Requests -### Bug Fixes -* Improve performance of bundled UMD code by adding additional parentheses to enforce eager parsing (#3183) -* Improve types to tolerate passing a Rollup config with multiple outputs to `rollup.rollup` (#3184) +- [#6000](https://github.com/rollup/rollup/pull/6000): feat: improve get literal value for conditional expression (@ahabhgk, @lukastaegert) +- [#6001](https://github.com/rollup/rollup/pull/6001): Correct the parent scope for static blocks (@TrickyPi, @lukastaegert) +- [#6005](https://github.com/rollup/rollup/pull/6005): fix: export field order prefer esm (@DylanPiercey) -### Pull Requests -* [#3183](https://github.com/rollup/rollup/pull/3183): Add parentheses to factory function of UMD bundles (@ajihyf) -* [#3184](https://github.com/rollup/rollup/pull/3184): RollupOptions accept output as array (@imcotton) +## 4.44.2 -## 1.25.1 -*2019-10-20* +_2025-07-04_ ### Bug Fixes -* Handle a situation where code was not included after a switch statement (#3178) -* Handle a situation where code was not included after a do-while loop (#3180) -* Do not fail if different outputs emit the same file (#3175) -* Give access to the original acorn error for parse errors (#3176) + +- Correctly handle `@__PURE__` annotations after `new` keyword (#5998) +- Generate correct source mapping for closing braces of block statements (#5999) ### Pull Requests -* [#3175](https://github.com/rollup/rollup/pull/3175): Disable errors for duplicate emitted file names (@marijnh) -* [#3176](https://github.com/rollup/rollup/pull/3176): Add original parser error to rollup error; Update tests (@gribnoysup) -* [#3178](https://github.com/rollup/rollup/pull/3178): Fix switch case not being included correctly (@lukastaegert) -* [#3179](https://github.com/rollup/rollup/pull/3179): Update dependencies (@lukastaegert) -* [#3180](https://github.com/rollup/rollup/pull/3180): Handle conditional breaks in do-while loops with unconditional return (@lukastaegert) -## 1.25.0 -*2019-10-18* +- [#5998](https://github.com/rollup/rollup/pull/5998): Support `@__PURE__` when nested after new in constructor invocations (@TrickyPi) +- [#5999](https://github.com/rollup/rollup/pull/5999): Add location info for closing brace of block statement (@TrickyPi) +- [#6002](https://github.com/rollup/rollup/pull/6002): chore(deps): update dependency vite to v7 (@renovate[bot], @lukastaegert) +- [#6004](https://github.com/rollup/rollup/pull/6004): fix(deps): lock file maintenance minor/patch updates (@renovate[bot], @lukastaegert) -### Features -* Remove try-catch if there is no side-effect in the try-block (#3166) -* Omit side-effect-free trailing cases in switch-statements (#3166) -* Remove unused labels (#3170) +## 4.44.1 + +_2025-06-26_ ### Bug Fixes -* Do not remove code after labeled statements that contain a throw or return if the label is used (#3170) -* Prevent invalid code when expressions are simplified that do not follow a white-space character (#3173) -* Do not remove continue statements inside switch statements (#3166) -* Prevent trailing empty lines when tree-shaking inside switch statements (#3166) + +- Reinstate maxParallelFileOps limit of 1000 to resolve the issue for some (#5992) ### Pull Requests -* [#3166](https://github.com/rollup/rollup/pull/3166): Better try statement tree shaking (@lukastaegert) -* [#3170](https://github.com/rollup/rollup/pull/3170): Handle optional control flow in labeled statements, remove unused labels (@lukastaegert) -* [#3173](https://github.com/rollup/rollup/pull/3173): Add missing spaces in certain statements and expressions to avoid invalid code (@lukastaegert) -## 1.24.0 -*2019-10-15* +- [#5988](https://github.com/rollup/rollup/pull/5988): fix(deps): lock file maintenance minor/patch updates (@renovate[bot], @lukastaegert) +- [#5992](https://github.com/rollup/rollup/pull/5992): Set maxParallelFileOps to 1000 (@lukastaegert) -### Features -* Respect `break`, `continue`, `return` and `throw` when tree-shaking to detect dead code (#3153) -* Do treat treat hoisted function declarations as "unknown" when checking for call side-effects (#3153) +## 4.44.0 -### Bug Fixes -* Make sure that unknown `import.meta` properties produce valid code in SystemJS (#3152) -* Make sure `treeshake.annotations: false` is respected for class instantiation (#3153) -* Check property access side-effects for class instantiation (#3153) -* Do not suppress break statements inside labeled statements (#3153) +_2025-06-19_ -### Pull Requests -* [#3152](https://github.com/rollup/rollup/pull/3152): Allow import.meta.* for systemjs format (@dmail) -* [#3153](https://github.com/rollup/rollup/pull/3153): Get rid of immutable.js and implement tree-shaking for broken control flow (@lukastaegert) +### Features -## 1.23.1 -*2019-10-05* +- Remove limit on `maxParallelFileOps` as this could break watch mode with the commonjs plugin (#5986) ### Bug Fixes -* Fix a regression where the node types had a specific minimal version (#3143) -### Pull Requests -* [#3143](https://github.com/rollup/rollup/pull/3143): Ensure that types packages have star version ranges (@lukastaegert) +- Provide better source mappings when coarse intermediate maps are used (#5985) -## 1.23.0 -*2019-10-03* +### Pull Requests -### Features -* Add placeholders for extensions when preserving modules (#3116) +- [#5984](https://github.com/rollup/rollup/pull/5984): fix(deps): lock file maintenance minor/patch updates (@renovate[bot], @lukastaegert) +- [#5985](https://github.com/rollup/rollup/pull/5985): Improve approximation of coarse sourcemap segments (@TrickyPi) +- [#5986](https://github.com/rollup/rollup/pull/5986): Remove limit on max parallel file ops (@lukastaegert) -### Pull Requests -* [#3116](https://github.com/rollup/rollup/pull/3116): Include extensions in preserveModules output filenames for scriptified assets (@Andarist) -* [#3142](https://github.com/rollup/rollup/pull/3142): Fix typo (@tu4mo) +## 4.43.0 -## 1.22.0 -*2019-09-29* +_2025-06-11_ ### Features -* Add a new "hidden" sourcemap type that generates the map files but omits the sourcemap comment (#3120) -* Generate more efficient code when using `namespaceToStringTag: true` (#3135) -* Make sure namespace objects do not have a prototype (#3136) -### Bug Fixes -* Do not ignore side-effectful iterators by always preserving for..of loops for now (#3132) -* Make sure `--context` is observed as a CLI option (#3134) -* Do not require specific versions for @types dependencies (#3131) +- Provide new `fs` option and `this.fs` API to replace file system (#5944) ### Pull Requests -* [#3120](https://github.com/rollup/rollup/pull/3120): Generate sourcemaps but omit the comment (@rohitmohan96) -* [#3131](https://github.com/rollup/rollup/pull/3131): Use asterisk for @types/* dependencies (@frenzzy) -* [#3132](https://github.com/rollup/rollup/pull/3132): Preserve empty for...of loops (@imatlopez) -* [#3133](https://github.com/rollup/rollup/pull/3133): Update dependencies (@lukastaegert) -* [#3134](https://github.com/rollup/rollup/pull/3134): Wire up --context CLI flag (@tchetwin) -* [#3135](https://github.com/rollup/rollup/pull/3135): Remove Symbol polyfill in module namespaces (@mkubilayk) -* [#3136](https://github.com/rollup/rollup/pull/3136): Set null prototype on namespace objects (@rpamely) -## 1.21.4 -*2019-09-16* +- [#5944](https://github.com/rollup/rollup/pull/5944): feat(options): Add an option for overriding the file system module in the JS API (@EggDice, @lukastaegert) -### Bug Fixes -* Recognize common browser globals (#3117) -* Do not treat "typeof " as a side-effect (#3117) +## 4.42.0 -### Pull Requests -* [#3117](https://github.com/rollup/rollup/pull/3117): Add browser globals to known globals and prevent "typeof" side-effects (@lukastaegert) +_2025-06-06_ -## 1.21.3 -*2019-09-14* +### Features -### Bug Fixes -* Fix a regression where modifying a watched file did not trigger a rebuild (#3112) +- Add option to allow the input to be located in the output in watch mode (#5966) ### Pull Requests -* [#3112](https://github.com/rollup/rollup/pull/3112): Fix .addWatchFile() dependencies failing to invalidate in watch mode (@tivac) -## 1.21.2 -*2019-09-09* +- [#5966](https://github.com/rollup/rollup/pull/5966): feat: watch mode add `allowInputInsideOutputPath` option (@btea, @lukastaegert) -### Bug Fixes -* Fix wrong deprecation message to direct to `this.emitFile` instead of `this.emitAsset` +## 4.41.2 -## 1.21.1 -*2019-09-09* +_2025-06-06_ ### Bug Fixes -* Allow legacy plugins to still add assets directly to the bundle object (#3105) - -### Pull Requests -* [#3105](https://github.com/rollup/rollup/pull/3105): Allow legacy plugins to still add assets directly to the bundle object (@lukastaegert) - -## 1.21.0 -*2019-09-08* -### Features -* Respect `output.entryFileNames` when preserving modules (#3088) -* Make accessing unknown globals a side-effect unless this is deactivated via `treeshake.unknownGlobalSideEffects` (#3068) -* Respect global objects when checking for pure global functions (#3068) -* Introduce a `type` to more easily distinguish chunks and assets in the output bundle (#3080) - -### Bug Fixes -* Recover in watch mode when the initial build fails (#3081) -* Make sure `output.strict` is respected for SystemJS output (#3101) +- Detect named export usages in dynamic imports with `then` and non-arrow function expressions (#5977) +- Do not replace usages of constant variables with their values for readability (#5968) ### Pull Requests -* [#3068](https://github.com/rollup/rollup/pull/3068): Make accessing unknown globals a side-effect (@lukastaegert) -* [#3080](https://github.com/rollup/rollup/pull/3080): OutputBundle Tagged union with 'type = chunk|asset' (@askbeka) -* [#3081](https://github.com/rollup/rollup/pull/3081): Watch files onbuild, even if build fails (@mhkeller) -* [#3088](https://github.com/rollup/rollup/pull/3088): Add support for entryFileNames pattern used in combination with preserveModules option (@Andarist) -* [#3101](https://github.com/rollup/rollup/pull/3101): Remove 'use strict'; from systemjs when strict=false (@askbeka) - -## 1.20.3 -*2019-08-28* -### Bug Fixes -* Make sure file hashes change when a change of the naming pattern leads to a file name change of a dependency (#3083) -* Fix several issues where reexporting an external "default" export could lead to invalid or incorrect code (#3084) +- [#5968](https://github.com/rollup/rollup/pull/5968): fix: preserve constant identifiers in unary expressions instead of magic numbers (@OmkarJ13, @lukastaegert) +- [#5969](https://github.com/rollup/rollup/pull/5969): chore(deps): update dependency yargs-parser to v22 (@renovate[bot], @lukastaegert) +- [#5970](https://github.com/rollup/rollup/pull/5970): chore(deps): lock file maintenance minor/patch updates (@renovate[bot]) +- [#5971](https://github.com/rollup/rollup/pull/5971): chore(deps): lock file maintenance (@renovate[bot]) +- [#5976](https://github.com/rollup/rollup/pull/5976): Update README.md (@ftlno, @lukastaegert) +- [#5977](https://github.com/rollup/rollup/pull/5977): fix: consider function expression in thenable when tree-shaking dynamic imports (@TrickyPi) +- [#5981](https://github.com/rollup/rollup/pull/5981): fix(deps): lock file maintenance minor/patch updates (@renovate[bot]) +- [#5982](https://github.com/rollup/rollup/pull/5982): Debug/fix watch pipeline (@lukastaegert) -### Pull Requests -* [#3078](https://github.com/rollup/rollup/pull/3078): Add github actions workflow config for windows (@shellscape) -* [#3083](https://github.com/rollup/rollup/pull/3083): Properly reflect dependency file names in hash (@lukastaegert) -* [#3084](https://github.com/rollup/rollup/pull/3084): Fix "default" reexport issues in non ESM/System formats (@lukastaegert) +## 4.41.1 -## 1.20.2 -*2019-08-25* +_2025-05-24_ ### Bug Fixes -* Avoid an issue where circular namespace reexports would crash Rollup (#3074) -### Pull Requests -* [#3077](https://github.com/rollup/rollup/pull/3077): Handle namespaces that reexport themselves (@lukastaegert) +- If a plugin calls `this.resolve` with `skipSelf: true`, subsequent calls when handling this by the same plugin with same parameters will return `null` to avoid infinite recursions (#5945) -## 1.20.1 -*2019-08-22* +### Pull Requests -### Bug Fixes -* Fix an issue where variable names inside dynamic import expressions were not rendered correctly (#3073) -* Fix type definition to allow a single watcher config as well as an array (#3074) +- [#5945](https://github.com/rollup/rollup/pull/5945): Avoid recursively calling a plugin's resolveId hook with same id and importer (@younggglcy, @lukastaegert) +- [#5963](https://github.com/rollup/rollup/pull/5963): fix(deps): update swc monorepo (major) (@renovate[bot]) +- [#5964](https://github.com/rollup/rollup/pull/5964): fix(deps): lock file maintenance minor/patch updates (@renovate[bot]) -### Pull Requests -* [#3073](https://github.com/rollup/rollup/pull/3073): Fix wrong variable name in import expression (@lukastaegert) -* [#3074](https://github.com/rollup/rollup/pull/3074): Fixes type definition on watch and Watcher constructor (@MicahZoltu) +## 4.41.0 -## 1.20.0 -*2019-08-21* +_2025-05-18_ ### Features -* Add augmentChunkHash plugin hook to be able to reflect changes in renderChunk in the chunk hash (#2921) - -### Bug Fixes -* Do not mutate the acorn options object (#3051) -* Make sure the order of emitted chunks always reflects the order in which they were emitted (#3055) -* Do not hang when there are strings containing comment-like syntax in some scenarios (#3069) - -### Pull Requests -* [#2921](https://github.com/rollup/rollup/pull/2921): Add augmentChunkHash plugin hook (@isidrok) -* [#2995](https://github.com/rollup/rollup/pull/2995): Add info on installing locally to docs (@mesqueeb) -* [#3037](https://github.com/rollup/rollup/pull/3037): Refresh pull request labels (@shellscape) -* [#3048](https://github.com/rollup/rollup/pull/3048): Document ROLLUP_WATCH environment variable (@shellscape) -* [#3051](https://github.com/rollup/rollup/pull/3051): Avoid changes to the original options (.acorn) object (@LongTengDao) -* [#3052](https://github.com/rollup/rollup/pull/3052): Minor refactoring: Remove one try-catch (@KSXGitHub) -* [#3053](https://github.com/rollup/rollup/pull/3053): Refactor to use async-await in more places (@KSXGitHub) -* [#3055](https://github.com/rollup/rollup/pull/3055): Provide consistent chunking via a consistent order of entry modules when emitting chunks (@lukastaegert) -* [#3058](https://github.com/rollup/rollup/pull/3058): Remove acorn-bigint and acorn-dynamic-import from bundle (@LongTengDao) -* [#3061](https://github.com/rollup/rollup/pull/3061): Update to acorn@7 (@lukastaegert) -* [#3063](https://github.com/rollup/rollup/pull/3063): Auto-generate license file (@lukastaegert) -* [#3069](https://github.com/rollup/rollup/pull/3069): Prevent infinite loop when scanning for line-breaks and there are comment-like strings (@lukastaegert) - -## 1.19.4 -*2019-08-07* -### Bug Fixes -* Prevent invalid code when exporting an external namespace (#3034) -* Prevent invalid or non-equivalent code when simplifying expressions in return and throw statements (#3035) +- Detect named exports in more dynamic import scenarios (#5954) ### Pull Requests -* [#3034](https://github.com/rollup/rollup/pull/3034): Avoid generating .* as export (@LongTengDao) -* [#3035](https://github.com/rollup/rollup/pull/3035): Prevent ASI errors for conditional expressions (@lukastaegert) -* [#3036](https://github.com/rollup/rollup/pull/3036): Fix documents to use https, not http (@giraffate) - -## 1.19.3 -*2019-08-06* -### Bug Fixes -* Fix wrong URLs in error messages (#3033) +- [#5949](https://github.com/rollup/rollup/pull/5949): ci: use node 24 (@btea, @lukastaegert) +- [#5951](https://github.com/rollup/rollup/pull/5951): chore(deps): update dependency pretty-bytes to v7 (@renovate[bot]) +- [#5952](https://github.com/rollup/rollup/pull/5952): fix(deps): update swc monorepo (major) (@renovate[bot], @lukastaegert) +- [#5953](https://github.com/rollup/rollup/pull/5953): chore(deps): lock file maintenance minor/patch updates (@renovate[bot]) +- [#5954](https://github.com/rollup/rollup/pull/5954): enhance tree-shaking for dynamic imports (@TrickyPi, @renovate[bot], @lukastaegert) +- [#5957](https://github.com/rollup/rollup/pull/5957): chore(deps): update dependency lint-staged to v16 (@renovate[bot], @lukastaegert) +- [#5958](https://github.com/rollup/rollup/pull/5958): fix(deps): update rust crate swc_compiler_base to v20 (@renovate[bot], @lukastaegert) +- [#5959](https://github.com/rollup/rollup/pull/5959): fix(deps): lock file maintenance minor/patch updates (@renovate[bot], @lukastaegert) +- [#5960](https://github.com/rollup/rollup/pull/5960): Use spawn to run CLI tests (@lukastaegert) -### Pull Requests -* [#3033](https://github.com/rollup/rollup/pull/3033): Fix wrong URLs in error messages (@giraffate) +## 4.40.2 -## 1.19.2 -*2019-08-05* +_2025-05-06_ ### Bug Fixes -* Add bin file to package -## 1.19.1 -*2019-08-05* - -### Bug Fixes -* Remove wrong extension in package.json file (#3031) +- Create correct IIFE/AMD/UMD bundles when using a mutable default export (#5934) +- Fix execution order when using top-level await for dynamic imports with inlineDynamicImports (#5937) +- Throw when the output is watched in watch mode (#5939) ### Pull Requests -* [#3031](https://github.com/rollup/rollup/pull/3031): Fix wrong extension (@lukastaegert) -## 1.19.0 -*2019-08-05* +- [#5934](https://github.com/rollup/rollup/pull/5934): fix(exports): avoid "exports is not defined" `ReferenceError` (@dasa) +- [#5937](https://github.com/rollup/rollup/pull/5937): consider TLA imports have higher execution priority (@TrickyPi) +- [#5939](https://github.com/rollup/rollup/pull/5939): fix: watch mode input should not be an output subpath (@btea) +- [#5940](https://github.com/rollup/rollup/pull/5940): chore(deps): update dependency vite to v6.3.4 [security] (@renovate[bot]) +- [#5941](https://github.com/rollup/rollup/pull/5941): chore(deps): update dependency eslint-plugin-unicorn to v59 (@renovate[bot]) +- [#5942](https://github.com/rollup/rollup/pull/5942): fix(deps): lock file maintenance minor/patch updates (@renovate[bot]) +- [#5943](https://github.com/rollup/rollup/pull/5943): fix(deps): lock file maintenance minor/patch updates (@renovate[bot]) -### Features -* Implement a new unified file emission API for assets and chunks with support for explicit file names (#2999) -* Use the id of the last module in a chunk as base for the chunk name if no better name is available (#3025) -* Use the id of the last module in a chunk as base for the variable name of a chunk in some formats if no better name is available (#2999) +## 4.40.1 + +_2025-04-28_ ### Bug Fixes -* Do not produce invalid variable names if an empty name is chosen for a virtual module (#3026) -* Fix an issue where a module variable name would conflict with a local variable name in some formats (#3020) -### Pull Requests -* [#2999](https://github.com/rollup/rollup/pull/2999): Unified file emission api (@lukastaegert) -* [#3020](https://github.com/rollup/rollup/pull/3020): Switch to a code-splitting build and update dependencies (@lukastaegert) -* [#3025](https://github.com/rollup/rollup/pull/3025): Use id of last module in chunk as name base for auto-generated chunks (@lukastaegert) -* [#3026](https://github.com/rollup/rollup/pull/3026): Avoid variable from empty module name be empty (@LongTengDao) +- Limit hash size for asset file names to the supported 21 (#5921) +- Do not inline user-defined entry chunks or chunks with explicit file name (#5923) +- Avoid top-level-await cycles when non-entry chunks use top-level await (#5930) +- Expose package.json via exports (#5931) -## 1.18.0 -*2019-08-01* +### Pull Requests -### Features -* Add `externalLiveBindings: false` option to optimize code when live bindings are not needed (#3010) +- [#5921](https://github.com/rollup/rollup/pull/5921): fix(assetFileNames): reduce max hash size to 21 (@shulaoda) +- [#5923](https://github.com/rollup/rollup/pull/5923): fix: generate the separate chunk for the entry module with explicated chunk filename or name (@TrickyPi) +- [#5926](https://github.com/rollup/rollup/pull/5926): fix(deps): update rust crate swc_compiler_base to v18 (@renovate[bot]) +- [#5927](https://github.com/rollup/rollup/pull/5927): fix(deps): lock file maintenance minor/patch updates (@renovate[bot]) +- [#5928](https://github.com/rollup/rollup/pull/5928): fix(deps): lock file maintenance minor/patch updates (@renovate[bot]) +- [#5930](https://github.com/rollup/rollup/pull/5930): Avoid chunks TLA dynamic import circular when TLA dynamic import used in non-entry modules (@TrickyPi) +- [#5931](https://github.com/rollup/rollup/pull/5931): chore: add new `./package.json` entry (@JounQin, @lukastaegert) +- [#5936](https://github.com/rollup/rollup/pull/5936): fix(deps): lock file maintenance minor/patch updates (@renovate[bot]) -### Pull Requests -* [#2997](https://github.com/rollup/rollup/pull/2997): Integrate coverage into CI setup (@lukastaegert) -* [#2998](https://github.com/rollup/rollup/pull/2998): Update readme badges (@lukastaegert) -* [#3010](https://github.com/rollup/rollup/pull/3010): Add option to prevent code for external live bindings (@lukastaegert) +## 4.40.0 -## 1.17.0 -*2019-07-15* +_2025-04-12_ ### Features -* Allow plugins to access current combined sourcemap in transform hook for coverage instrumentation (#2993) -### Pull Requests -* [#2987](https://github.com/rollup/rollup/pull/2987): Fix code fences for link (@johanholmerin) -* [#2989](https://github.com/rollup/rollup/pull/2989): Bump lodash from 4.17.11 to 4.17.14 (@dependabot) -* [#2993](https://github.com/rollup/rollup/pull/2993): Add getCombinedSourceMap in transform plugin context (@billowz) - -## 1.16.7 -*2019-07-09* +- Only show `eval` warnings on first render and only when the call is not tree-shaken (#5892) +- Tree-shake non-included dynamic import members when the handler just maps to one named export (#5898) ### Bug Fixes -* Fix an issue where exported import.meta properties would lead to invalid code (#2986) - -### Pull Requests -* [#2985](https://github.com/rollup/rollup/pull/2985): Improve sourcemap types (@jridgewell) -* [#2986](https://github.com/rollup/rollup/pull/2986): Only overwrite content when resolving import.meta properties (@lukastaegert) -## 1.16.6 -*2019-07-04* - -### Bug Fixes -* Do not pass undefined to resolveDynamicImport for unresolvable template literals (#2984) +- Consider dynamic imports nested within top-level-awaited dynamic import expressions to be awaited as well (#5900) +- Fix namespace rendering when tree-shaking is disabled (#5908) +- When using multiple transform hook filters, all of them need to be satisfied together (#5909) ### Pull Requests -* [#2984](https://github.com/rollup/rollup/pull/2984): Always forward AST nodes for unresolvable dynamic imports (@lukastaegert) - -## 1.16.5 -*2019-07-04* - -### Bug Fixes -* onwarn should still be called when --silent is used (#2982) -* Properly clean up watchers for files that are deleted between builds (#2982) -### Pull Requests -* [#2981](https://github.com/rollup/rollup/pull/2981): Do not skip onwarn handler when --silent is used (@lukastaegert) -* [#2982](https://github.com/rollup/rollup/pull/2982): Make tests run on Node 12, fix watcher cleanup issue (@lukastaegert) +- [#5892](https://github.com/rollup/rollup/pull/5892): Warn when eval or namespace calls are rendered, not when they are parsed (@SunsetFi, @lukastaegert) +- [#5898](https://github.com/rollup/rollup/pull/5898): feat: treeshake dynamic import chained member expression (@privatenumber, @lukastaegert) +- [#5900](https://github.com/rollup/rollup/pull/5900): consider the dynamic import within a TLA call expression as a TLA import (@TrickyPi) +- [#5904](https://github.com/rollup/rollup/pull/5904): fix(deps): update swc monorepo (major) (@renovate[bot]) +- [#5905](https://github.com/rollup/rollup/pull/5905): chore(deps): lock file maintenance minor/patch updates (@renovate[bot]) +- [#5908](https://github.com/rollup/rollup/pull/5908): Fix `treeshake: false` breaking destructured namespace imports (@Skn0tt) +- [#5909](https://github.com/rollup/rollup/pull/5909): Correct the behavior when multiple transform filter options are specified (@sapphi-red) +- [#5915](https://github.com/rollup/rollup/pull/5915): chore(deps): update dependency @types/picomatch to v4 (@renovate[bot]) +- [#5916](https://github.com/rollup/rollup/pull/5916): fix(deps): update rust crate swc_compiler_base to v17 (@renovate[bot]) +- [#5917](https://github.com/rollup/rollup/pull/5917): chore(deps): lock file maintenance minor/patch updates (@renovate[bot], @lukastaegert) +- [#5918](https://github.com/rollup/rollup/pull/5918): chore(deps): update dependency vite to v6.2.6 [security] (@renovate[bot], @lukastaegert) -## 1.16.4 -*2019-07-02* +## 4.39.0 -### Bug Fixes -* Do not show a TypeScript error when providing a location as number to this.warn and this.error (#2974) -* Use the correct TypeScript type for Sourcemap.version (#2976) +_2025-04-02_ -### Pull Requests -* [#2965](https://github.com/rollup/rollup/pull/2965): Use async readFile in getRollupDefaultPlugin (@kaksmet) -* [#2974](https://github.com/rollup/rollup/pull/2974): Align TS types, docs and implementation for this.warn and this.error (@lukastaegert) -* [#2976](https://github.com/rollup/rollup/pull/2976): Fix sourcemap type and update dependencies (@lukastaegert) +### Features -## 1.16.3 -*2019-06-29* +- Do not create separate facade chunks if a chunk would contain several entry modules that allow export extension if there are no export name conflicts (#5891) ### Bug Fixes -* Prevent name conflicts with unused function parameters (#2972) - -### Pull Requests -* [#2972](https://github.com/rollup/rollup/pull/2972): Deconflict unused parameters (@lukastaegert) - -## 1.16.2 -*2019-06-22* -### Bug Fixes -* Properly wrap dynamic imports in Promises that can be caught when generating CJS output (#2958) +- Mark the `id` property as optional in the filter for the `resolveId` hook (#5896) ### Pull Requests -* [#2958](https://github.com/rollup/rollup/pull/2958): Make sure errors from dynamic imports can be caught (@lukastaegert) -## 1.16.1 -*2019-06-21* +- [#5891](https://github.com/rollup/rollup/pull/5891): chunk: merge allow-extension modules (@wmertens, @lukastaegert) +- [#5893](https://github.com/rollup/rollup/pull/5893): chore(deps): update dependency vite to v6.2.4 [security] (@renovate[bot]) +- [#5896](https://github.com/rollup/rollup/pull/5896): fix: resolveId id filter is optional (@sapphi-red) -### Pull Requests -* [#2956](https://github.com/rollup/rollup/pull/2956): Add missing CLI docs for strictDeprecations (@lukastaegert) +## 4.38.0 -## 1.16.0 -*2019-06-21* +_2025-03-29_ ### Features -* Add strictDeprecations option to throw when currently or upcoming deprecated features are used (#2945) -* Keep annotations and comments when simplifying logical and conditional expressions (#2955) -### Bug Fixes -* Generate proper namespace objects when dynamically importing external dependencies for AMD or CJS formats (#2954) -* Fix dynamically imported variables not being resolved correctly when importing from an entry chunk with only a default export (#2954) -* Do not reexport default when reexporting a namespace (#2954) +- Support `.filter` option in `resolveId`, `load` and `transform` hooks (#5882) ### Pull Requests -* [#2945](https://github.com/rollup/rollup/pull/2945): Add option to handle use of features marked for deprecation as errors (@lukastaegert) -* [#2954](https://github.com/rollup/rollup/pull/2954): Improve dynamic import interop (@lukastaegert) -* [#2955](https://github.com/rollup/rollup/pull/2955): Keep annotations and comments when simplifying logical and conditional expressions (@lukastaegert) - -## 1.15.6 -*2019-06-16* -### Bug Fixes -* No longer use an alternate screen in watch mode to allow scrolling (#2942) -* Prioritize non-external imports over external ones when resolving conflicting namespace re-exports (#2893) - -### Pull Requests -* [#2893](https://github.com/rollup/rollup/pull/2893): Improve handling of conflicting namespace exports (@aleclarson) -* [#2942](https://github.com/rollup/rollup/pull/2942): Get rid of alternate screen and simplify screen clearing (@lukastaegert) +- [#5882](https://github.com/rollup/rollup/pull/5882): Add support for hook filters (@sapphi-red) +- [#5894](https://github.com/rollup/rollup/pull/5894): fix(deps): lock file maintenance minor/patch updates (@renovate[bot]) +- [#5895](https://github.com/rollup/rollup/pull/5895): chore(deps): update dependency eslint-plugin-unicorn to v58 (@renovate[bot]) -## 1.15.5 -*2019-06-14* +## 4.37.0 -### Bug Fixes -* Do not include any comments for completely tree-shaken files so that `renderedLength === 0` is a reliable check (#2940) -* Do not cause type errors when returning `null` from `resolveId` (#2941) +_2025-03-23_ -### Pull Requests -* [#2940](https://github.com/rollup/rollup/pull/2940): Completely omit files that do not have any included statements (@lukastaegert) -* [#2941](https://github.com/rollup/rollup/pull/2941): Explicitly allow null as return value for various hooks (@lukastaegert) +### Features -## 1.15.4 -*2019-06-14* +- Support Musl Linux on Riscv64 architectures (#5726) +- Handles class decorators placed before the `export` keyword (#5871) ### Bug Fixes -* Improve how asset and chunk URLs are resolved for UMD, IIFE and CJS output (#2937) + +- Log Rust panic messages to the console when using the WASM build (#5875) ### Pull Requests -* [#2937](https://github.com/rollup/rollup/pull/2937): Fix URL resolution to work when the current script contains query parameters (@lukastaegert) -## 1.15.3 -*2019-06-13* +- [#5726](https://github.com/rollup/rollup/pull/5726): Add support for linux riscv64 musl (@fossdd, @leso-kn) +- [#5871](https://github.com/rollup/rollup/pull/5871): feat: support decorators before or after export (@TrickyPi) +- [#5875](https://github.com/rollup/rollup/pull/5875): capture Rust panic messages and output them to the console. (@luyahan, @lukastaegert) +- [#5883](https://github.com/rollup/rollup/pull/5883): Pin digest of 3rd party actions (@re-taro) +- [#5885](https://github.com/rollup/rollup/pull/5885): fix(deps): lock file maintenance minor/patch updates (@renovate[bot]) -### Bug Fixes -* Always reemit assets and chunks from cached transform hooks (#2936) +## 4.36.0 -### Pull Requests -* [#2936](https://github.com/rollup/rollup/pull/2936): Fix repeated re-emission of files emitted from a transform hook (@lukastaegert) +_2025-03-17_ + +### Features -## 1.15.2 -*2019-06-13* +- Extend `renderDynamicImport` hook to provide information about static dependencies of the imported module (#5870) +- Export several additional types used by Vite (#5879) ### Bug Fixes -* Make sure chunks emitted from transform hooks are also emitted for incremental builds in watch mode (#2933) -### Pull Requests -* [#2933](https://github.com/rollup/rollup/pull/2933): Reemit chunks emitted from transform hooks (@lukastaegert) +- Do not merge chunks if that would create a top-level await cycle between chunks (#5843) -## 1.15.1 -*2019-06-11* +### Pull Requests -### Bug Fixes -* Do not fail when reexporting variables in dynamic entry points from other chunks (#2928) +- [#5843](https://github.com/rollup/rollup/pull/5843): avoiding top level await circular (@TrickyPi, @lukastaegert) +- [#5870](https://github.com/rollup/rollup/pull/5870): draft for extended renderDynamicImport hook (@iczero, @lukastaegert) +- [#5876](https://github.com/rollup/rollup/pull/5876): Update axios overrides to 1.8.2 (@vadym-khodak) +- [#5877](https://github.com/rollup/rollup/pull/5877): chore(deps): update dependency eslint-plugin-vue to v10 (@renovate[bot]) +- [#5878](https://github.com/rollup/rollup/pull/5878): fix(deps): lock file maintenance minor/patch updates (@renovate[bot]) +- [#5879](https://github.com/rollup/rollup/pull/5879): fix: export types (@sxzz) -### Pull Requests -* [#2928](https://github.com/rollup/rollup/pull/2928): Handle reexports from dynamic entries across chunk (@lukastaegert) +## 4.35.0 -## 1.15.0 -*2019-06-11* +_2025-03-08_ ### Features -* Tone down try-catch deoptimization while maintaining polyfill support (#2918) -### Bug Fixes -* Handle feature detection with "typeof" for regular expressios (#2916) -* Deoptimize `'' + variable'` type coercion as expression statement for feature detection (#2917) -* Always observe argument side-effects when tree-shaking (#2924) +- Pass build errors to the closeBundle hook (#5867) ### Pull Requests -* [#2916](https://github.com/rollup/rollup/pull/2916): Deoptimize typeof for regular expression literals to better support es6-shim (@lukastaegert) -* [#2917](https://github.com/rollup/rollup/pull/2917): Support implicit type coercion errors in es5-shim (@lukastaegert) -* [#2918](https://github.com/rollup/rollup/pull/2918): Deoptimize try-catch less radically (@lukastaegert) -* [#2924](https://github.com/rollup/rollup/pull/2924): Do not tree-shake arguments with side-effects (@lukastaegert) -## 1.14.6 -*2019-06-10* +- [#5852](https://github.com/rollup/rollup/pull/5852): chore(deps): update dependency eslint-plugin-unicorn to v57 (@renovate[bot], @lukastaegert) +- [#5862](https://github.com/rollup/rollup/pull/5862): fix(deps): update swc monorepo (major) (@renovate[bot], @lukastaegert) +- [#5867](https://github.com/rollup/rollup/pull/5867): feat(5858): make closeBundle hook receive the last error (@GauBen) +- [#5872](https://github.com/rollup/rollup/pull/5872): chore(deps): update dependency builtin-modules to v5 (@renovate[bot]) +- [#5873](https://github.com/rollup/rollup/pull/5873): chore(deps): update uraimo/run-on-arch-action action to v3 (@renovate[bot]) +- [#5874](https://github.com/rollup/rollup/pull/5874): fix(deps): lock file maintenance minor/patch updates (@renovate[bot]) -### Bug Fixes -* Fix an issue where call arguments were not included in try statements (#2914) - -### Pull Requests -* [#2914](https://github.com/rollup/rollup/pull/2914): Properly include try statements for each pass when deoptimization is deactivated (@lukastaegert) +## 4.34.9 -## 1.14.5 -*2019-06-09* +_2025-03-01_ ### Bug Fixes -* Keep external ids unmodified when using the object form of resolveId (#2907) -* Cache dynamic import resolutions when using Rollup cache (#2908) -* Keep all necessary parentheses when tree-shaking call arguments (#2911) -### Pull Requests -* [#2906](https://github.com/rollup/rollup/pull/2906): Update dependencies (@lukastaegert) -* [#2907](https://github.com/rollup/rollup/pull/2907): Do not renormalize external ids when using the object form (@lukastaegert) -* [#2908](https://github.com/rollup/rollup/pull/2908): Cache dynamic ids if possible (@lukastaegert) -* [#2911](https://github.com/rollup/rollup/pull/2911): Fix treeshaken parameters around parentheses (@manucorporat) +- Support JSX modes in WASM (#5866) +- Allow the CustomPluginOptions to be extended (#5850) -## 1.14.4 -*2019-06-07* +### Pull Requests -### Bug Fixes -* Do not omit external re-exports for `moduleSideEffects: false` (#2905) +- [#5850](https://github.com/rollup/rollup/pull/5850): Revert CustomPluginOptions to be an interface (@sapphi-red, @lukastaegert) +- [#5851](https://github.com/rollup/rollup/pull/5851): Javascript to JavaScript (@dasa, @lukastaegert) +- [#5853](https://github.com/rollup/rollup/pull/5853): chore(deps): update dependency pinia to v3 (@renovate[bot]) +- [#5854](https://github.com/rollup/rollup/pull/5854): fix(deps): update swc monorepo (major) (@renovate[bot]) +- [#5855](https://github.com/rollup/rollup/pull/5855): fix(deps): lock file maintenance minor/patch updates (@renovate[bot], @lukastaegert) +- [#5860](https://github.com/rollup/rollup/pull/5860): chore(deps): update dependency @shikijs/vitepress-twoslash to v3 (@renovate[bot]) +- [#5861](https://github.com/rollup/rollup/pull/5861): chore(deps): update dependency globals to v16 (@renovate[bot]) +- [#5863](https://github.com/rollup/rollup/pull/5863): fix(deps): lock file maintenance minor/patch updates (@renovate[bot]) +- [#5864](https://github.com/rollup/rollup/pull/5864): chore(deps): lock file maintenance minor/patch updates (@renovate[bot]) +- [#5866](https://github.com/rollup/rollup/pull/5866): Add jsx parameter to parseAsync in native.wasm.js (@TrickyPi) -### Pull Requests -* [#2905](https://github.com/rollup/rollup/pull/2905): Make sure external re-exports are included for moduleSideEffects: false (@lukastaegert) +## 4.34.8 -## 1.14.3 -*2019-06-06* +_2025-02-17_ ### Bug Fixes -* Generate correct external imports when importing from a directory that would be above the root of the current working directory (#2902) + +- Do not make assumptions about the value of nested paths in logical expressions if the expression cannot be simplified (#5846) ### Pull Requests -* [#2902](https://github.com/rollup/rollup/pull/2902): Use browser relative path algorithm for chunks (@lukastaegert) -## 1.14.2 -*2019-06-05* +- [#5846](https://github.com/rollup/rollup/pull/5846): return UnknownValue if the usedbranch is unkown and the path is not empty (@TrickyPi) + +## 4.34.7 + +_2025-02-14_ ### Bug Fixes -* Prevent unnecessary inclusion of external namespace import in certain situations (#2900) + +- Ensure that calls to parameters are included correctly when using try-catch deoptimization (#5842) ### Pull Requests -* [#2900](https://github.com/rollup/rollup/pull/2900): Handle early bind for member expressions (@lukastaegert) -## 1.14.1 -*2019-06-05* +- [#5840](https://github.com/rollup/rollup/pull/5840): fix(deps): lock file maintenance minor/patch updates (@renovate[bot]) +- [#5842](https://github.com/rollup/rollup/pull/5842): Fix prop inclusion with try-catch-deoptimization (@lukastaegert) -### Bug Fixes -* Fix an issue where try-statements were not included properly when a variable declared inside the statement was accessed outside it (#2898) -* Fix an issue where `await` expressions were not included properly (#2899) +## 4.34.6 -### Pull Requests -* [#2898](https://github.com/rollup/rollup/pull/2898): Properly include try-catch-statements even if they have already been included in some way (@lukastaegert) -* [#2899](https://github.com/rollup/rollup/pull/2899): Fix unintended early return in await inclusion handling (@lukastaegert) +_2025-02-07_ -## 1.14.0 -*2019-06-05* +### Bug Fixes -### Features -* Deoptimize code inside and called from try-statements for feature detection (#2892) -* Tree-shake unused call arguments (#2892) +- Retain "void 0" in the output for smaller output and fewer surprises (#5838) ### Pull Requests -* [#2892](https://github.com/rollup/rollup/pull/2892): Implement try-statement-deoptimization for feature detection, tree-shake unused arguments (@lukastaegert) +- [#5835](https://github.com/rollup/rollup/pull/5835): fix(deps): update swc monorepo (major) (@renovate[bot], @lukastaegert) +- [#5838](https://github.com/rollup/rollup/pull/5838): replace undefined with void 0 for operator void (@TrickyPi) + +## 4.34.5 -## 1.13.1 -*2019-06-01* +_2025-02-07_ ### Bug Fixes -* Avoid conflicts between top-level module, require etc. and CommonJS runtimes (#2889) + +- Ensure namespace reexports always include all properties of all exports (#5837) ### Pull Requests -* [#2888](https://github.com/rollup/rollup/pull/2888): Enable full TypeScript strict mode (@lukastaegert) -* [#2889](https://github.com/rollup/rollup/pull/2889): Protect all module globals for CJS output from being redefined (@lukastaegert) -## 1.13.0 -*2019-05-31* +- [#5836](https://github.com/rollup/rollup/pull/5836): fix(deps): lock file maintenance minor/patch updates (@renovate[bot]) +- [#5837](https://github.com/rollup/rollup/pull/5837): Include all paths of reexports if namespace is used (@lukastaegert) -### Features -* Omit `exports` and `module` from SystemJS wrapper if possible (#2880) -* Try to use the first letters of names when mangling exports (#2885) +## 4.34.4 + +_2025-02-05_ ### Bug Fixes -* Avoid conflicts with local variables when using format specific globals to render dynamic imports and file URLs (#2880) -* Do not produce undefined reexports when reexporting from entry points (#2885) + +- Do not tree-shake properties if a rest element is used in destructuring (#5833) ### Pull Requests -* [#2880](https://github.com/rollup/rollup/pull/2880): Deconflict global variables used inside format-specific code (@lukastaegert) -* [#2885](https://github.com/rollup/rollup/pull/2885): Do not produce undefined reexports when reexporting from entry points and refactor chunk linking (@lukastaegert) -## 1.12.5 -*2019-05-30* +- [#5833](https://github.com/rollup/rollup/pull/5833): include all properties if a rest element is destructed (@TrickyPi) -### Pull Requests -* [#2884](https://github.com/rollup/rollup/pull/2884): Update pluginutils for new micormatch and reduced bundle size (@lukastaegert) +## 4.34.3 -## 1.12.4 -*2019-05-27* +_2025-02-05_ ### Bug Fixes -* Show correct error stack trace for errors throw in "load" hooks (#2871) -### Pull Requests -* [#2875](https://github.com/rollup/rollup/pull/2875): Mention subfolders in docs (@lukastaegert) -* [#2871](https://github.com/rollup/rollup/pull/2871): Reserve error stack information (@LongTengDao) +- Ensure properties of "this" are included in getters (#5831) -## 1.12.3 -*2019-05-19* +### Pull Requests -### Bug Fixes -* Prevent duplicate imports when exports are reexported as default exports (#2866) +- [#5831](https://github.com/rollup/rollup/pull/5831): include the properties that accessed by this (@TrickyPi) -### Pull Requests -* [#2755](https://github.com/rollup/rollup/pull/2755): Enable TypeScript strictNullChecks (@edsrzf) -* [#2866](https://github.com/rollup/rollup/pull/2866): Properly deduplicate reexported default exports (@lukastaegert) +## 4.34.2 -## 1.12.2 -*2019-05-17* +_2025-02-04_ ### Bug Fixes -* Do not fail when using clearScreen:false in watchMode (#2858) -* Properly resolve star reexports when preserving modules (#2860) + +- Fix an issue where not all usages of a function were properly detected (#5827) ### Pull Requests -* [#2858](https://github.com/rollup/rollup/pull/2858): Declare processConfigsErr before use (@humphd) -* [#2860](https://github.com/rollup/rollup/pull/2860): Keep nested exports with preserveModules (@TomCaserta) -* [#2864](https://github.com/rollup/rollup/pull/2864): Cache transitive reexport detection (@lukastaegert) -## 1.12.1 -*2019-05-16* +- [#5827](https://github.com/rollup/rollup/pull/5827): Ensure that functions provided to a constructor are properly deoptimized (@lukastaegert) + +## 4.34.1 + +_2025-02-03_ ### Bug Fixes -* Extend file name sanitation to also replace "?" and "*" e.g. when preserving modules with the updated commonjs plugin (#2860) -* Do not ignore module transformer that return an empty string (#2861) + +- Ensure throwing objects includes the entire object (#5825) ### Pull Requests -* [#2860](https://github.com/rollup/rollup/pull/2860): Update to latest plugins and extend file name sanitation (@lukastaegert) -* [#2861](https://github.com/rollup/rollup/pull/2861): Allow transformers to return an empty string (@lukastaegert) -## 1.12.0 -*2019-05-15* +- [#5825](https://github.com/rollup/rollup/pull/5825): Ensure that all properties of throw statements are included (@lukastaegert) + +## 4.34.0 + +_2025-02-01_ ### Features -* Add `treeshake.moduleSideEffects` option to allow removing empty imports without a side-effect check (#2844) -* Extend plugin API to allow marking modules as side-effect-free (#2844) -* Extend `this.resolve` plugin context function with an option to skip the `resolveId` hook of the calling plugin (#2844) -* Add `isEntry` flag to `this.getModuleInfo` plugin context function (#2844) -* Distribute Rollup as optimized ES2015 code (#2851) + +- Tree-shake unused properties in object literals (re-implements #5420) (#5737) ### Pull Requests -* [#2844](https://github.com/rollup/rollup/pull/2844): Add options and hooks to control module side effects (@lukastaegert) -* [#2851](https://github.com/rollup/rollup/pull/2851): Switch to ES2015 output (@lukastaegert) -## 1.11.3 -*2019-05-05* +- [#5737](https://github.com/rollup/rollup/pull/5737): Reapply object tree-shaking (@lukastaegert, @TrickyPi) -### Bug Fixes -* Quote es3 keywords in namespace objects (#2825) +## 4.33.0 -### Pull Requests -* [#2825](https://github.com/rollup/rollup/pull/2825): Add es3 support for namespace object import (@sormy) +_2025-02-01_ + +### Features -## 1.11.2 -*2019-05-04* +- Correctly detect literal value of more negated expressions (#5812) ### Bug Fixes -* Prevent a crash when handling circular namespace exports (#2836) + +- Use the correct with/assert attribute key in dynamic imports (#5818) +- Fix an issue where logical expressions were considered to have the wrong value (#5819) ### Pull Requests -* [#2836](https://github.com/rollup/rollup/pull/2836): Make sure circular `export * from X` does not stack overflow (@Swatinem) -## 1.11.1 -*2019-05-04* +- [#5812](https://github.com/rollup/rollup/pull/5812): feat: optimize the literal value of unary expressions (@TrickyPi) +- [#5816](https://github.com/rollup/rollup/pull/5816): fix(deps): update swc monorepo (major) (@renovate[bot], @lukastaegert) +- [#5817](https://github.com/rollup/rollup/pull/5817): fix(deps): lock file maintenance minor/patch updates (@renovate[bot], @lukastaegert) +- [#5818](https://github.com/rollup/rollup/pull/5818): support for changing the attributes key for dynamic imports (@TrickyPi) +- [#5819](https://github.com/rollup/rollup/pull/5819): Return UnknownValue if getLiteralValueAtPath is called recursively within logical expressions (@TrickyPi) +- [#5820](https://github.com/rollup/rollup/pull/5820): return null (@kingma-sbw) + +## 4.32.1 + +_2025-01-28_ ### Bug Fixes -* Fix an issue where rendered exports were reported as "removed" in the bundle information (#2835) + +- Fix possible crash when optimizing logical expressions (#5804) ### Pull Requests -* [#2835](https://github.com/rollup/rollup/pull/2835): Fix `removedExports` to correctly track the exported item (@Swatinem) -## 1.11.0 -*2019-05-03* +- [#5804](https://github.com/rollup/rollup/pull/5804): fix: set hasDeoptimizedCache to true as early as possible (@TrickyPi) +- [#5813](https://github.com/rollup/rollup/pull/5813): Fix typo (@kantuni) -### Features -* Add `emitChunk` plugin context function to emit additional entry chunks that can be referenced from the code (#2809) -* Allow `manualChunks` to be a function (#2831) -* Omit `.js` extensions in AMD imports to make sure an AMD `baseUrl` would work (#2809) -* Automatically use the name of the imported module as a base for dynamically imported chunks (#2809) -* Add `resolveFileUrl` plugin hook to replace `resolveAssetUrl` and handle emitted chunks as well (#2809) -* Add `resolve` plugin hook to replace `resolveId` and `isExternal` that returns an object (#2829) -* Allow `resolveDynamicImport` to return an `{id, external}` object to also resolve unresolvable dynamic imports to a module (#2829) +## 4.32.0 -### Bug Fixes -* Do not create invalid code if a dynamic import contains nothing but reexports (#2809) -* Do not fail if modules that define a manual chunk depend on each other (#2809) -* Do not fail if a module that defines a manual chunk is the dependency of a module defining a different manual chunk (#2809) -* No longer fail for unnamed duplicate entry points but combine them (#2809) -* Always return `string | null` from `this.resolveId` even if some `resolveId` hooks return objects (#2829) -* Show proper warnings when `resolveDynamicImport` resolves to a non-external module that does not exist (#2829) +_2025-01-24_ -### Pull Requests -* [#2809](https://github.com/rollup/rollup/pull/2809): Add hook for dynamic entry chunk emission (@lukastaegert) -* [#2821](https://github.com/rollup/rollup/pull/2821): Fix syntax error in documentation (@FFxSquall) -* [#2829](https://github.com/rollup/rollup/pull/2829): Improve id resolution (@lukastaegert) -* [#2831](https://github.com/rollup/rollup/pull/2831): Allow manualChunks to be a function (@lukastaegert) -* [#2832](https://github.com/rollup/rollup/pull/2832): Improve `generateBundle` documentation (@lukastaegert) -* [#2833](https://github.com/rollup/rollup/pull/2833): Update dependencies (@lukastaegert) +### Features -## 1.10.1 -*2019-04-19* +- Add watch.onInvalidate option to trigger actions immediately when a file is changed (#5799) ### Bug Fixes -* Invalid options.format values will now trigger a helpful error (#2813) + +- Fix incorrect urls in CLI warnings (#5809) ### Pull Requests -* [#2812](https://github.com/rollup/rollup/pull/2812): Minor documentation update (@dnalborczyk) -* [#2813](https://github.com/rollup/rollup/pull/2813): Catch invalid options.format values (@marijnh) -* [#2816](https://github.com/rollup/rollup/pull/2816): Update all dependencies to fix security issues (@lukastaegert) -## 1.10.0 -*2019-04-11* +- [#5799](https://github.com/rollup/rollup/pull/5799): Feature/watch on invalidate (@drebrez, @lukastaegert) +- [#5808](https://github.com/rollup/rollup/pull/5808): chore(deps): update dependency vite to v6.0.9 [security] (@renovate[bot]) +- [#5809](https://github.com/rollup/rollup/pull/5809): fix: avoid duplicate rollupjs.org prefix (@GauBen, @lukastaegert) +- [#5810](https://github.com/rollup/rollup/pull/5810): chore(deps): update dependency @shikijs/vitepress-twoslash to v2 (@renovate[bot]) +- [#5811](https://github.com/rollup/rollup/pull/5811): fix(deps): lock file maintenance minor/patch updates (@renovate[bot]) + +## 4.31.0 + +_2025-01-19_ ### Features -* Improve generated code to polyfill `import.meta.url` (#2785) -* Add plugin hook to configure handling of `import.meta` (#2785) -* Improve generated code when accessing URLs of emitted assets (#2796) -* Add plugin hook to configure the generated code when accessing URLs of emitted assets (#2796) + +- Do not immediately quit when trying to use watch mode from within non-TTY environments (#5803) ### Bug Fixes -* No longer resolve assets to their parent URL in some cases (#2796) + +- Handle files with more than one UTF-8 BOM header (#5806) ### Pull Requests -* [#2785](https://github.com/rollup/rollup/pull/2785): Refactor handling of import.meta.url and add option to configure behaviour (@lukastaegert) -* [#2796](https://github.com/rollup/rollup/pull/2796): Improve and fix asset emission (@lukastaegert) -## 1.9.3 -*2019-04-10* +- [#5792](https://github.com/rollup/rollup/pull/5792): fix(deps): update rust crate swc_compiler_base to v8 (@renovate[bot]) +- [#5793](https://github.com/rollup/rollup/pull/5793): fix(deps): lock file maintenance minor/patch updates (@renovate[bot]) +- [#5794](https://github.com/rollup/rollup/pull/5794): chore(deps): lock file maintenance (@renovate[bot]) +- [#5801](https://github.com/rollup/rollup/pull/5801): chore(deps): update dependency eslint-config-prettier to v10 (@renovate[bot]) +- [#5802](https://github.com/rollup/rollup/pull/5802): fix(deps): lock file maintenance minor/patch updates (@renovate[bot]) +- [#5803](https://github.com/rollup/rollup/pull/5803): Support watch mode in yarn, gradle and containers (@lukastaegert) +- [#5806](https://github.com/rollup/rollup/pull/5806): fix: strip all BOMs (@TrickyPi) + +## 4.30.1 + +_2025-01-07_ ### Bug Fixes -* Simplify return expressions that are evaluated before the surrounding function is bound (#2803) + +- Prevent invalid code when simplifying unary expressions in switch cases (#5786) ### Pull Requests -* [#2803](https://github.com/rollup/rollup/pull/2803): Handle out-of-order binding of identifiers to improve tree-shaking (@lukastaegert) -## 1.9.2 -*2019-04-10* +- [#5786](https://github.com/rollup/rollup/pull/5786): fix: consider that literals cannot following switch case. (@TrickyPi) -### Bug Fixes -* Allowing replacing `output.file` with `output.dir` in the `outputOptions` hook (#2802) +## 4.30.0 -### Pull Requests -* [#2802](https://github.com/rollup/rollup/pull/2802): Observe modified output options in bundle.write (@lukastaegert) +_2025-01-06_ -## 1.9.1 -*2019-04-10* +### Features -### Bug Fixes -* Make sure inline comments in dynamic imports are preserved (#2797) +- Inline values of resolvable unary expressions for improved tree-shaking (#5775) ### Pull Requests -* [#2797](https://github.com/rollup/rollup/pull/2797): Emit inline comments inside dynamic import (@manucorporat) -## 1.9.0 -*2019-04-05* +- [#5775](https://github.com/rollup/rollup/pull/5775): feat: enhance the treehshaking for unary expression (@TrickyPi) +- [#5783](https://github.com/rollup/rollup/pull/5783): Improve CI caching for node_modules (@lukastaegert) -### Features -* Add built-in support for bigint (#2789) +## 4.29.2 -### Pull Requests -* [#2789](https://github.com/rollup/rollup/pull/2789): Ship with bigint support built-in (@danielgindi) -* [#2791](https://github.com/rollup/rollup/pull/2791): Use shared extractAssignedNames from rollup-pluginutils (@lukastaegert) -* [#2792](https://github.com/rollup/rollup/pull/2792): Test that rollup-plugin-commonjs works with preserveModules (@lukastaegert) +_2025-01-05_ -## 1.8.0 -*2019-04-02* +### Bug Fixes -### Features -* Support `module` as alias for `esm` and `commonjs` for `cjs` to match Node (#2783) +- Keep import attributes when using dynamic ESM `import()` expressions from CommonJS (#5781) ### Pull Requests -* [#2782](https://github.com/rollup/rollup/pull/2782): Inline interopDefault in config loading (@guybedford) -* [#2783](https://github.com/rollup/rollup/pull/2783): Support Node-style format aliases (@guybedford) -## 1.7.4 -*2019-03-28* +- [#5772](https://github.com/rollup/rollup/pull/5772): Improve caching on CI (@lukastaegert) +- [#5773](https://github.com/rollup/rollup/pull/5773): fix(deps): lock file maintenance minor/patch updates (@renovate[bot]) +- [#5780](https://github.com/rollup/rollup/pull/5780): feat: use picocolors instead of colorette (@re-taro) +- [#5781](https://github.com/rollup/rollup/pull/5781): fix: keep import attributes for cjs format (@TrickyPi) + +## 4.29.1 + +_2024-12-21_ ### Bug Fixes -* Improve TypeScript type of the treeshaking options (#2779) + +- Fix crash from deoptimized logical expressions (#5771) ### Pull Requests -* [#2779](https://github.com/rollup/rollup/pull/2779): Make all properties in TreeshakingOptions optional (@ndelangen) -## 1.7.3 -*2019-03-24* +- [#5769](https://github.com/rollup/rollup/pull/5769): Remove unnecessary lifetimes (@lukastaegert) +- [#5771](https://github.com/rollup/rollup/pull/5771): fix: do not optimize the literal value if the cache is deoptimized (@TrickyPi) -### Bug Fixes -* Use getters when re-exporting live-bindings (#2765) +## 4.29.0 -### Pull Requests -* [#2765](https://github.com/rollup/rollup/pull/2765): Support exporting live-bindings from other chunks or external dependencies (@lukastaegert) +_2024-12-20_ -## 1.7.2 -*2019-03-24* +### Features -### Bug Fixes -* Make sure relative external ids are resolved correctly (#2774) +- Treat objects as truthy and always check second argument to better simplify logical expressions (#5763) ### Pull Requests -* [#2774](https://github.com/rollup/rollup/pull/2774): Resolve relative external ids (@lukastaegert) -## 1.7.1 -*2019-03-24* +- [#5759](https://github.com/rollup/rollup/pull/5759): docs: add utf-8 encoding to JSON file reading (@chouchouji) +- [#5760](https://github.com/rollup/rollup/pull/5760): fix(deps): lock file maintenance minor/patch updates (@renovate[bot]) +- [#5763](https://github.com/rollup/rollup/pull/5763): fix: introduce UnknownFalsyValue for enhancing if statement tree-shaking (@TrickyPi) +- [#5766](https://github.com/rollup/rollup/pull/5766): chore(deps): update dependency @rollup/plugin-node-resolve to v16 (@renovate[bot]) +- [#5767](https://github.com/rollup/rollup/pull/5767): fix(deps): lock file maintenance minor/patch updates (@renovate[bot]) + +## 4.28.1 + +_2024-12-06_ ### Bug Fixes -* Prevent invalid code when exporting several hundred identifiers from a chunk (#2768) -* Do not wrongly deconflict labels (#2776) + +- Support running Rollup natively on LoongArch (#5749) +- Add optional `debugId` to `SourceMap` types (#5751) ### Pull Requests -* [#2768](https://github.com/rollup/rollup/pull/2768): Sanitize shortened internal export names (@lukastaegert) -* [#2769](https://github.com/rollup/rollup/pull/2769): Update dependencies and fix security issue (@lukastaegert) -* [#2776](https://github.com/rollup/rollup/pull/2776): Do not treat break labels as identifiers (@lukastaegert) -## 1.7.0 -*2019-03-20* +- [#5749](https://github.com/rollup/rollup/pull/5749): feat: add support for LoongArch (@darkyzhou) +- [#5751](https://github.com/rollup/rollup/pull/5751): feat: Add `debugId` to `SourceMap` types (@timfish, @lukastaegert) +- [#5752](https://github.com/rollup/rollup/pull/5752): chore(deps): update dependency mocha to v11 (@renovate[bot]) +- [#5753](https://github.com/rollup/rollup/pull/5753): chore(deps): update dependency vite to v6 (@renovate[bot]) +- [#5754](https://github.com/rollup/rollup/pull/5754): fix(deps): update swc monorepo (major) (@renovate[bot]) +- [#5755](https://github.com/rollup/rollup/pull/5755): chore(deps): lock file maintenance minor/patch updates (@renovate[bot]) +- [#5756](https://github.com/rollup/rollup/pull/5756): Test if saving the Cargo cache can speed up FreeBSD (@lukastaegert) + +## 4.28.0 + +_2024-11-30_ ### Features -* Sort chunk exports by name for greater consistency (#2757) -### Bug Fixes -* Fix a situation where tree-shakeable code would not be removed in an indeterminate manner (#2757) +- Allow to specify how to handle import attributes when transpiling Rollup config files (#5743) ### Pull Requests -* [#2757](https://github.com/rollup/rollup/pull/2757): Sort modules before binding, sort exports (@lukastaegert) -## 1.6.1 -*2019-03-20* +- [#5743](https://github.com/rollup/rollup/pull/5743): fix: supports modify the import attributes key in the config file (@TrickyPi, @lukastaegert) +- [#5747](https://github.com/rollup/rollup/pull/5747): chore(deps): update codecov/codecov-action action to v5 (@renovate[bot]) +- [#5748](https://github.com/rollup/rollup/pull/5748): chore(deps): lock file maintenance minor/patch updates (@renovate[bot]) -### Bug Fixes -* Avoid name clashes of unused default exports when tree-shaking is false (#2758) -* Do not crash when generating SystemJS bundles containing array patterns with member expressions (#2760) +## 4.27.4 -### Pull Requests -* [#2758](https://github.com/rollup/rollup/pull/2758): Make sure unused default exports are deconflicted when tree-shaking is false (@lukastaegert) -* [#2760](https://github.com/rollup/rollup/pull/2760): Handle member expressions in array patterns (@lukastaegert) +_2024-11-23_ -## 1.6.0 -*2019-03-08* +### Bug Fixes -### Features -* Add plugin hook to modify output options (#2736) +- Update bundled magic-string to support sourcemap debug ids (#5740) ### Pull Requests -* [#2736](https://github.com/rollup/rollup/pull/2736): Add hook for modifying OutputOptions (@Comandeer) - -## 1.5.0 -*2019-03-07* -### Features -* Allow resolving to a different id while marking it as external at the same time (#2734) +- [#5740](https://github.com/rollup/rollup/pull/5740): chore(deps): lock file maintenance minor/patch updates (@renovate[bot]) -### Pull Requests -* [#2734](https://github.com/rollup/rollup/pull/2734): Allow resolveId to return an object (@lukastaegert) +## 4.27.3 -## 1.4.2 -*2019-03-07* +_2024-11-18_ ### Bug Fixes -* Respect variable identity of exports when hashing (#2741) -* Resolve a situations where a variable was imported twice with the same name (#2737) + +- Revert object property tree-shaking for now (#5736) ### Pull Requests -* [#2741](https://github.com/rollup/rollup/pull/2741): Fix hashing when different variable are exported using the same name (@lukastaegert) -* [#2737](https://github.com/rollup/rollup/pull/2737): Fix duplicate imports with conflicting names (@lukastaegert) -## 1.4.1 -*2019-03-04* +- [#5736](https://github.com/rollup/rollup/pull/5736): Revert object tree-shaking until some issues have been resolved (@lukastaegert) -### Bug Fixes -* Do not treat the import target "" as external by default (#2733) +## 4.27.2 -### Pull Requests -* [#2733](https://github.com/rollup/rollup/pull/2733): Do not treat the import target "" as external by default (@LongTengDao) +_2024-11-15_ -## 1.4.0 -*2019-03-01* +### Bug Fixes -### Features -* Add option to change the name of the dynamic import function to allow polyfilling it (#2723) +- Ensure unused variables in patterns are always deconflicted if rendered (#5728) ### Pull Requests -* [#2723](https://github.com/rollup/rollup/pull/2723): Add dynamicImportFunction option (@keithamus) -## 1.3.3 -*2019-03-01* +- [#5728](https://github.com/rollup/rollup/pull/5728): Fix more variable deconflicting issues (@lukastaegert) + +## 4.27.1 + +_2024-11-15_ ### Bug Fixes -* Fix performance regression when handling long chains of calls to property methods (#2732) + +- Fix some situations where parameter declarations could put Rollup into an infinite loop (#5727) ### Pull Requests -* [#2730](https://github.com/rollup/rollup/pull/2730): Order types, interfaces, classes, and object members (@lukastaegert) -* [#2732](https://github.com/rollup/rollup/pull/2732): Take chunk export mode into account when reexporting default (@lukastaegert) -## 1.3.2 -*2019-02-27* +- [#5727](https://github.com/rollup/rollup/pull/5727): Debug out-of-memory issues with Rollup v4.27.0 (@lukastaegert) -### Bug Fixes -* Allow ids of default exported classes to be exported separately (#2728) +## 4.27.0 -### Pull Requests -* [#2728](https://github.com/rollup/rollup/pull/2728): Update dependencies (@lukastaegert) +_2024-11-15_ + +### Features -## 1.3.1 -*2019-02-27* +- Tree-shake unused properties in object literals (#5420) ### Bug Fixes -* Correctly reexport the default export from entry chunks (#2727) + +- Change hash length limit to 21 to avoid inconsistent hash length (#5423) ### Pull Requests -* [#2727](https://github.com/rollup/rollup/pull/2727): Take chunk export mode into account when reexporting default (@lukastaegert) -## 1.3.0 -*2019-02-26* +- [#5420](https://github.com/rollup/rollup/pull/5420): feat: implement object tree-shaking (@TrickyPi, @lukastaegert) +- [#5723](https://github.com/rollup/rollup/pull/5723): Reduce max hash size to 21 (@lukastaegert) +- [#5724](https://github.com/rollup/rollup/pull/5724): fix(deps): update swc monorepo (major) (@renovate[bot]) +- [#5725](https://github.com/rollup/rollup/pull/5725): chore(deps): lock file maintenance minor/patch updates (@renovate[bot]) -### Features -* Treeshake call expressions prefixed with UglifyJS style `@__PURE__` annotations (#2429) +## 4.26.0 -### Pull Requests -* [#2429](https://github.com/rollup/rollup/pull/2429): Add support for /*#__PURE__*/ comments (@conartist6 and @lukastaegert) +_2024-11-13_ -## 1.2.5 -*2019-02-26* +### Features -### Bug Fixes -* Store external ids reported by plugins in watch mode (#2718) +- Allow to avoid `await bundle.close()` via explicit resource management in TypeScript (#5721) ### Pull Requests -* [#2718](https://github.com/rollup/rollup/pull/2718): Incremental external (@andreas-karlsson) -## 1.2.4 -*2019-02-26* +- [#5721](https://github.com/rollup/rollup/pull/5721): feat: support `using` for `RollupBuild` (@shulaoda) -### Bug Fixes -* Fix an issue where a variable was imported twice under the same name (#2715) +## 4.25.0 -### Pull Requests -* [#2715](https://github.com/rollup/rollup/pull/2715): Deduplicate imports referencing default exports and their original variables (@lukastaegert) +_2024-11-09_ + +### Features -## 1.2.3 -*2019-02-23* +- Add `output.sourcemapDebugIds` option to add matching debug ids to sourcemaps and code for tools like Sentry or Rollbar (#5712) ### Bug Fixes -* Use correct path when rendering dynamic imports where the entry module is empty (#2714) -### Pull Requests -* [#2714](https://github.com/rollup/rollup/pull/2714): Properly render dynamic imports when imported module is empty (@lukastaegert) +- Make it easier to manually reproduce base16 hashes by using a more standard base16 conversion algorithm (#5719) -## 1.2.2 -*2019-02-19* +### Pull Requests -### Bug Fixes -* Fix wrong external imports when using the `paths` options only for some outputs (#2706) +- [#5712](https://github.com/rollup/rollup/pull/5712): feat: Add support for injecting Debug IDs (@timfish) +- [#5717](https://github.com/rollup/rollup/pull/5717): fix(deps): update swc monorepo (major) (@renovate[bot]) +- [#5718](https://github.com/rollup/rollup/pull/5718): chore(deps): lock file maintenance minor/patch updates (@renovate[bot]) +- [#5719](https://github.com/rollup/rollup/pull/5719): Use a less surprising base-16 encoding (@lukastaegert) -### Pull Requests -* [#2706](https://github.com/rollup/rollup/pull/2706): Always recreate paths for external modules (@lukastaegert) +## 4.24.4 -## 1.2.1 -*2019-02-17* +_2024-11-04_ ### Bug Fixes -* Fix ESM version of Rollup (#2705) + +- Ensure mutations by handlers in Proxy definitions are always respected when tree-shaking (#5713) ### Pull Requests -* [#2705](https://github.com/rollup/rollup/pull/2705): Fix ESM version of Rollup (@lukastaegert) -## 1.2.0 -*2019-02-17* +- [#5708](https://github.com/rollup/rollup/pull/5708): Update configuration-options document (@sacru2red, @lukastaegert) +- [#5711](https://github.com/rollup/rollup/pull/5711): chore(deps): lock file maintenance minor/patch updates (@renovate[bot]) +- [#5713](https://github.com/rollup/rollup/pull/5713): fix: Deoptimize the proxied object if its property is reassigned in the handler functions (@TrickyPi) -### Features -* Fewer renamed variables due to a completely reimplemented deconflicting logic (#2689) +## 4.24.3 -### Bug Fixes -* Respect rendered and tree-shaken exports when determining chunk hashes (#2695) -* Fix an error when dynamic imports end up in the same chunk as one of their importees (#2677) -* Do not generate invalid code when expressions containing IIFEs are simplified (#2696) -* Do not throw an error when more than ten bundles are watched (#2700) -* Treat re-exported globals in a spec-compliant way (#2691) -* Fix issues related to wrongly renamed variables (#2689) -* Do not throw an error if config files contain non-default exports (#2673) -* Improve type of `RollupOutput.output` to guarantee at least one chunk (#2679) - -### Pull Requests -* [#2673](https://github.com/rollup/rollup/pull/2673): Allow config files to have non-default exports (@swansontec) -* [#2677](https://github.com/rollup/rollup/pull/2677): Prevent final resolution and facade creation for inlined dynamic imports (@Rich-Harris and @lukastaegert) -* [#2679](https://github.com/rollup/rollup/pull/2679): Improve type of `RollupOutput.output` (@MattiasBuelens) -* [#2689](https://github.com/rollup/rollup/pull/2689): Reimplement variable deconflicting logic (@lukastaegert) -* [#2691](https://github.com/rollup/rollup/pull/2691): Fix CI issues and update acorn dependency (@lukastaegert) -* [#2693](https://github.com/rollup/rollup/pull/2693): Fix typo in export-globals test (@MattiasBuelens) -* [#2695](https://github.com/rollup/rollup/pull/2695): Respect rendered exports when generating chunk hashes (@lukastaegert) -* [#2696](https://github.com/rollup/rollup/pull/2696): Correctly render function expression inside simplified expression statements (@lukastaegert) -* [#2700](https://github.com/rollup/rollup/pull/2700): Add a fix for MaxListenersExceededWarning (@luwes) -* [#2703](https://github.com/rollup/rollup/pull/2703): Update rollup-pluginutils (@lukastaegert) - -## 1.1.2 -*2019-01-21* +_2024-10-29_ ### Bug Fixes -* Tree-shaken dynamic imports no longer leave behind `undefined` entries in the bundle information (#2663) -* Dynamic imports in dynamically imported files could lead to crashes and would not always create new chunks (#2664) + +- Slightly reduce memory consumption by specifying fixed array sizes where possible (#5703) ### Pull Requests -* [#2663](https://github.com/rollup/rollup/pull/2663): Do not include tree-shaken dynamic imports in bundle information (@lukastaegert) -* [#2664](https://github.com/rollup/rollup/pull/2664): Properly handle dynamic imports declared in dynamically imported files (@everdimension) -## 1.1.1 -*2019-01-19* +- [#5703](https://github.com/rollup/rollup/pull/5703): perf: use pre-allocated arrays for known result sizes (@GalacticHypernova) + +## 4.24.2 + +_2024-10-27_ ### Bug Fixes -* Make sure object prototype methods are not considered to be falsy when tree-shaking (#2652) + +- Add missing build dependency (#5705) ### Pull Requests -* [#2652](https://github.com/rollup/rollup/pull/2652): Make sure object prototype methods are not considered to be falsy (@lukastaegert) -* [#2654](https://github.com/rollup/rollup/pull/2654): Use correct signature for `this.setAssetSource` in docs (@everdimension) -* [#2656](https://github.com/rollup/rollup/pull/2656): Swap descriptions for `[extname]` and `[ext]` in docs (@tivac) -## 1.1.0 -*2019-01-09* +- [#5705](https://github.com/rollup/rollup/pull/5705): Fix "Couldn't find package" error when installing rollup using yarn (@tagattie) -### Features -* Make `this.meta` available from the `options` plugin hook (#2642) -* Add a new `writeBundle` plugin hook that is called *after* all files have been written (#2643) +## 4.24.1 + +_2024-10-27_ ### Bug Fixes -* Make sure the `acorn` import of the bundled non-ESM acorn plugins is correctly translated to ESM (#2636) -* Make sure input options are actually passed to the `buildStart` hook (#2642) + +- Support running Rollup natively on FreeBSD (#5698) ### Pull Requests -* [#2636](https://github.com/rollup/rollup/pull/2636): Improve how acorn is imported, update dependencies (@lukastaegert) -* [#2642](https://github.com/rollup/rollup/pull/2642): Make this.meta available in options hook, pass input options to buildStart (@lukastaegert) -* [#2643](https://github.com/rollup/rollup/pull/2643): Implement writeBundle hook (@lukastaegert) -## 1.0.2 -*2019-01-05* +- [#5689](https://github.com/rollup/rollup/pull/5689): chore(deps): lock file maintenance minor/patch updates (@renovate[bot]) +- [#5690](https://github.com/rollup/rollup/pull/5690): chore(deps): update dependency @inquirer/prompts to v7 (@renovate[bot]) +- [#5691](https://github.com/rollup/rollup/pull/5691): chore(deps): update dependency eslint-plugin-unicorn to v56 (@renovate[bot]) +- [#5692](https://github.com/rollup/rollup/pull/5692): chore(deps): lock file maintenance minor/patch updates (@renovate[bot], @lukastaegert) +- [#5695](https://github.com/rollup/rollup/pull/5695): fix(deps): update swc monorepo (major) (@renovate[bot]) +- [#5696](https://github.com/rollup/rollup/pull/5696): chore(deps): lock file maintenance minor/patch updates (@renovate[bot]) +- [#5698](https://github.com/rollup/rollup/pull/5698): Add support for FreeBSD (x64 and arm64) (@tagattie, @lukastaegert) -### Bug Fixes -* Make sure the transform hook is always reevaluated when a file watched by the hook changes (#2633) -* Fix a crash when generating hashes for tree-shaken dynamic imports (#2638) -* Fix a crash and some inconsistencies when using the acorn-bigint plugin (#2640) +## 4.24.0 + +_2024-10-02_ + +### Features + +- Support preserving and transpiling JSX syntax (#5668) ### Pull Requests -* [#2633](https://github.com/rollup/rollup/pull/2633): Document `this.addWatchFile` and make sure it also declares transform dependencies (@lukastaegert) -* [#2635](https://github.com/rollup/rollup/pull/2635): Make sure `code` is optional in warning type (@lukastaegert) -* [#2638](https://github.com/rollup/rollup/pull/2638): Do not fail when generating hashes for tree-shaken dynamic imports (@lukastaegert) -* [#2640](https://github.com/rollup/rollup/pull/2640): Always treat bigints as unknown (@lukastaegert) -* [#2641](https://github.com/rollup/rollup/pull/2641): Make sure all CLI options are listed in the summary (@lukastaegert) -## 1.0.1 -*2019-01-03* +- [#5668](https://github.com/rollup/rollup/pull/5668): Introduce JSX support (@lukastaegert, @Martin-Idel, @felixhuttmann, @AlexDroll, @tiptr) -### Bug Fixes -* Properly handle reexporting an external default export for non-ESM targets when using named exports mode (#2620) -* Do not (wrongly) re-declare input options in the merged `RollupOptions` type (#2622) - -### Pull Requests -* [#2620](https://github.com/rollup/rollup/pull/2620): Fixed issue with reexporting default as default with `{exports: named, interop: true}` options (@Andarist) -* [#2622](https://github.com/rollup/rollup/pull/2622): Simplify RollupOptions (@Kinrany) -* [#2627](https://github.com/rollup/rollup/pull/2627): Show how to skip imports for optional plugins (@chris-morgan) - -## 1.0.0 -*2018-12-28* - -### Breaking Changes -* Several (mostly deprecated) options have been removed or renamed (#2293, #2409): - - banner -> output.banner - - dest -> output.file - - entry -> input - - experimentalCodeSplitting -> now always active - - experimentalDynamicImport -> now always active - - experimentalPreserveModules -> preserveModules - - exports -> output.exports - - extend -> output.extend - - footer -> output.footer - - format -> output.format - - freeze -> output.freeze - - globals -> output.globals - - indent -> output.indent - - interop -> output.interop - - intro -> output.intro - - load -> use plugin API - - moduleName -> output.name - - name -> output.name - - noConflict -> output.noConflict - - output.moduleId -> output.amd.id - - outro -> output.outro - - paths -> output.paths - - preferConst -> output.preferConst - - pureExternalModules -> treeshake.pureExternalModules - - resolveExternal -> use plugin API - - resolveId -> use plugin API - - sourcemap -> output.sourcemap - - sourceMap -> output.sourcemap - - sourceMapFile -> output.sourcemapFile - - strict -> output.strict - - targets -> use output as an array - - transform -> use plugin API - - useStrict -> output.strict -* In general, output options can no longer be used as input options (#2409) -* `bundle.generate` and `bundle.write` now return a new format (#2293) -* Several plugin hooks have become deprecated and will display warnings when used (#2409): - - transformBundle - - transformChunk - - ongenerate - - onwrite -* Plugin transform dependencies are deprecated in favour of using the `this.addWatchFile` plugin context function (#2409) -* Accessing `this.watcher` in plugin hooks is deprecated in favour of the `watchChange` plugin hook and the `this.addWatchFile` plugin context function (#2409) -* Using dynamic import statements will by default create a new chunk unless `inlineDynamicImports` is used (#2293) -* Rollup now uses acorn@6 which means that acorn plugins must be compatible with this version; acorn is now external for non-browser builds to make plugins work (#2293) +## 4.23.0 + +_2024-10-01_ ### Features -* The `--dir` ClI option can now be aliased as `-d` (#2293) -* The `--input` option now supports named entry points via `=` (#2293) -### Bug Fixes -* Both the `--input` option as well as the default CLI option now support named inputs (#2293) +- Collect all emitted names and originalFileNames for assets (#5686) ### Pull Requests -* [#2293](https://github.com/rollup/rollup/pull/2293): Unify code paths for 1.0 relase and update documentation (@guybedford and @lukastaegert) -* [#2409](https://github.com/rollup/rollup/pull/2409): Remove old deprecated features and add new deprecation warnings (@guybedford) -* [#2486](https://github.com/rollup/rollup/pull/2486): Upgrade to acorn 6 (@marijnh) -* [#2611](https://github.com/rollup/rollup/pull/2611): Fix hook's name in test description (@Andarist) -* [#2612](https://github.com/rollup/rollup/pull/2612): Fix a self-contradicting comment in the docs (@LongTengDao) -## 0.68.2 -*2018-12-23* +- [#5686](https://github.com/rollup/rollup/pull/5686): Add names and originalFileNames to assets (@lukastaegert) + +## 4.22.5 + +_2024-09-27_ ### Bug Fixes -* Do not assume hoisted variables to have been initialized (#2607) + +- Allow parsing of certain unicode characters again (#5674) ### Pull Requests -* [#2607](https://github.com/rollup/rollup/pull/2607): Fix an issues where hoisted variables were assumed to have been initialized (@lye) -## 0.68.1 -*2018-12-19* +- [#5674](https://github.com/rollup/rollup/pull/5674): Fix panic with unicode characters (@sapphi-red, @lukastaegert) +- [#5675](https://github.com/rollup/rollup/pull/5675): chore(deps): update dependency rollup to v4.22.4 [security] (@renovate[bot]) +- [#5680](https://github.com/rollup/rollup/pull/5680): chore(deps): update dependency @rollup/plugin-commonjs to v28 (@renovate[bot], @lukastaegert) +- [#5681](https://github.com/rollup/rollup/pull/5681): chore(deps): update dependency @rollup/plugin-replace to v6 (@renovate[bot]) +- [#5682](https://github.com/rollup/rollup/pull/5682): chore(deps): update dependency @rollup/plugin-typescript to v12 (@renovate[bot]) +- [#5684](https://github.com/rollup/rollup/pull/5684): chore(deps): lock file maintenance minor/patch updates (@renovate[bot]) + +## 2.79.2 + +_2024-09-26_ ### Bug Fixes -* Fix an issue with UMD wrappers where a variable is used without being defined (#2600) + +- Fix a vulnerability in generated code that affects IIFE, UMD and CJS bundles when run in a browser context (#5671) ### Pull Requests -* [#2600](https://github.com/rollup/rollup/pull/2600): Fix UMD and IIFE wrapper issues and add comprehensive functional wrapper tests (@lukastaegert) -## 0.68.0 -*2018-12-16* +- [#5671](https://github.com/rollup/rollup/pull/5671): Fix DOM Clobbering CVE (@lukastaegert) -### Breaking Changes -* `optimizeChunks` is renamed to `experimentalOptimizeChunks` to reflect this feature is not production-ready yet (#2575) +## 3.29.5 -### Features -* Plugins can iterate all module ids via `this.moduleIds` (#2565) -* Plugins can get graph information about a module via `this.getModuleInfo(id)` (#2565) -* Plugins and JS API users get more information about the generated chunks: `dynamicImports`, `facadeModuleId`, `isDynamicEntry`, `name` (#2575) -* Tree-shaken dynamic imports will no longer create chunks or influence chunking in any way (#2575) -* Dynamic imports will no longer follow the `entryFileNames` but the `chunkFileNames` property reflecting those are solely internally used (#2575) -* If there are chunk naming conflicts, entry chunks will always take precedence (#2575) -* If an entry facade is created, only the facade chunk is marked as `isEntry` (#2575) -* Dynamic chunks will only be marked as `isEntry` if they are actually entry chunks as well; thus there is now a 1-to-1 correspondence between modules listed in `input` and chunks marked as `isEntry` (#2575) -* Chunks no longer contain imports for variables that are tree-shaken in the chunk but used in other chunks (#2584) -* Chunks will always import re-exported variables directly from the chunk where they are originally exported from (#2584) -* Null characters will be pruned from chunk ids to allow for virtually created chunks and make `rollup-plugin-multi-entry` compatible with code-splitting and thus the upcoming 1.0 version (#2590) -* Simplify the UMD wrapper code as much as possible, especially if there are no exports (#2594) -* The UMD wrapper will now work in strict mode by checking for `self` before `this` when determining the global variable (#2594) +_2024-09-21_ ### Bug Fixes -* If a facade is created for a dynamic entry point, this facade will be imported instead of the facaded chunk (#2575) -* Manual chunks that include multiple entry points will have proper facades created for all entry points if necessary (#2575) -* If missing exports are shimmed, the shim variable will not be global but created on a per-module basis and is deconflicted with variables having the same name (#2584) -* Missing export shims work properly in SystemJS (#2584) -* `preserveModules` now handles dynamic namespace imports (#2584) -* Fix chunk execution order in certain scenarios (#2584) -* Exports and assignments using destructuring syntax will properly update the exported variables when generating SystemJS output (#2587) -* Hashes in chunk names will now also take dynamic imports into account (#2596) - -### Pull Requests -* [#2565](https://github.com/rollup/rollup/pull/2565): Provide module graph information on the plugin context (@samccone) -* [#2575](https://github.com/rollup/rollup/pull/2575): Extend bundle information, tree-shake dynamic imports, fix dynamic import facade creation, support manual chunks with multiple entry points, make `optimizeChunks` experimental (@lukastaegert) -* [#2577](https://github.com/rollup/rollup/pull/2577): Update dependencies (@lukastaegert) -* [#2584](https://github.com/rollup/rollup/pull/2584): Prune tree-shaken chunk imports, fix missing export shimming, support dynamic namespaces when preserving modules, improve chunk execution order (@lukastaegert) -* [#2587](https://github.com/rollup/rollup/pull/2587): Support exports using destructuring declarations and assignments in SystemJS (@lukastaegert) -* [#2590](https://github.com/rollup/rollup/pull/2590): Make sure chunk ids do not contain invalid characters to allow for chunks to correspond to virtual modules (@lukastaegert) -* [#2594](https://github.com/rollup/rollup/pull/2594): Simplify UMD wrapper code and make sure it works in strict mode (@lukastaegert) -* [#2596](https://github.com/rollup/rollup/pull/2596): Take both static and dynamic dependencies into account when calculating hashes (@lukastaegert) - -## 0.67.4 -*2018-12-03* -### Bug Fixes -* Prevent corrupt source maps for files with very long lines (#2571) +- Fix a vulnerability in generated code that affects IIFE, UMD and CJS bundles when run in a browser context (#5671) ### Pull Requests -* [#2571](https://github.com/rollup/rollup/pull/2571): Fix an issue with long lines in sourcemaps (@mislav) -## 0.67.3 -*2018-11-17* +- [#5671](https://github.com/rollup/rollup/pull/5671): Fix DOM Clobbering CVE (@lukastaegert) + +## 4.22.4 + +_2024-09-21_ ### Bug Fixes -* Make sure the ESM browser build is actually published to npm (#2560) -* Throw proper error when using `inlineDynamicImports` with `experimentalPreserveModules` (#2560) + +- Fix a vulnerability in generated code that affects IIFE, UMD and CJS bundles when run in a browser context (#5671) ### Pull Requests -* [#2552](https://github.com/rollup/rollup/pull/2552): Properly include ESM browser build in package (@lukastaegert) -* [#2560](https://github.com/rollup/rollup/pull/2560): Show proper error when using `inlineDynamicImports` with `experimentalPreserveModules` (@clarkdo) -## 0.67.2 -*2018-11-17* +- [#5670](https://github.com/rollup/rollup/pull/5670): refactor: Use object.prototype to check for reserved properties (@YuHyeonWook) +- [#5671](https://github.com/rollup/rollup/pull/5671): Fix DOM Clobbering CVE (@lukastaegert) + +## 4.22.3 + +_2024-09-21_ ### Bug Fixes -* Prevent crash when not returning sourcemaps from `renderChunk` plugin hook (#2558) + +- Ensure that mutations in modules without side effects are observed while properly handling transitive dependencies (#5669) ### Pull Requests -* [#2558](https://github.com/rollup/rollup/pull/2558): Prevent crash when not returning sourcemaps from `renderChunk` (@kyle1320) -## 0.67.1 -*2018-11-11* +- [#5669](https://github.com/rollup/rollup/pull/5669): Ensure impure dependencies of pure modules are added (@lukastaegert) + +## 4.22.2 + +_2024-09-20_ ### Bug Fixes -* Deconflict CLI entry points with same name but on different paths if no explicit naming is used (#2548) + +- Revert fix for side effect free modules until other issues are investigated (#5667) ### Pull Requests -* [#2548](https://github.com/rollup/rollup/pull/2548): Deconflict CLI entry points with same name but on different paths if no explicit naming is used (@lukastaegert) -## 0.67.0 -*2018-11-04* +- [#5667](https://github.com/rollup/rollup/pull/5667): Partially revert #5658 and re-apply #5644 (@lukastaegert) -### Breaking Changes -none +## 4.22.1 -### Features -* Do not resolve external dynamic imports via plugins to match the logic for static external imports again (#2505) -* Support virtual modules created by plugins when preserving modules (#2511) -* Add new `output.sourcemapExcludeSources` option to exclude the actual sources from sourcemaps (#2531) +_2024-09-20_ ### Bug Fixes -* Fix TypeScript type for sourcemaps (#2507) -* Fix order of external and inter-chunk imports to match the proper execution order (#2508) -* Do not tree-shake children of unknown nodes to e.g. properly handle do-expressions via acorn plugin (#2510) -* Prevent memory leak when using the bundle as cache (#2522) -* Fix mis-placed semicolons for certain SystemJS exports (#2529) - -### Pull Requests -* [#2505](https://github.com/rollup/rollup/pull/2505): Do not resolve external dynamic imports via plugins (@lukastaegert) -* [#2507](https://github.com/rollup/rollup/pull/2507): Fix public sourcemap type (@aMarCruz) -* [#2508](https://github.com/rollup/rollup/pull/2508): Improve execution order of chunks and externals (@lukastaegert) -* [#2510](https://github.com/rollup/rollup/pull/2510): Do not tree-shake children of unknown nodes to e.g. properly handle do-expressions via acorn plugin (@devsnek) -* [#2511](https://github.com/rollup/rollup/pull/2511): Create chunks for virtual modules when preserving modules (@lukastaegert) -* [#2522](https://github.com/rollup/rollup/pull/2522): Prevent memory leak when using the bundle as cache (@kyle1320) -* [#2529](https://github.com/rollup/rollup/pull/2529): Fix mis-placed semicolons for certain SystemJS exports (@kyle1320) -* [#2531](https://github.com/rollup/rollup/pull/2531): add `sourcemapExcludeSources` option to exclude the source content from sourcemaps (@kitsonk) - -## 0.66.6 -*2018-10-10* -* Properly deconflict function and class declaration ids of reassigned default exports ([#2502](https://github.com/rollup/rollup/pull/2502)) - -## 0.66.5 -*2018-10-09* -* Remove cache from memory once no longer needed ([#2496](https://github.com/rollup/rollup/pull/2496)) -* Provide better error message when reexporting external namespace reexports ([#2499](https://github.com/rollup/rollup/pull/2499)) - -## 0.66.4 -*2018-10-04* -* Fix links in warnings and errors ([#2471](https://github.com/rollup/rollup/pull/2471)) - -## 0.66.3 -*2018-10-03* -* Detect side-effects in string.replace function arguments ([#2476](https://github.com/rollup/rollup/pull/2476)) -* Make sure chunk ids are assigned before creating output bundle ([#2483](https://github.com/rollup/rollup/pull/2483)) -* Use proper plugin name in error ([#2470](https://github.com/rollup/rollup/pull/2470)) -* Update TypeScript version and fix type errors ([#2488](https://github.com/rollup/rollup/pull/2488)) - -## 0.66.2 -*2018-09-21* -* Add additional information to parse errors messages in JSON and other non-JS files ([#2466](https://github.com/rollup/rollup/pull/2466)) - -## 0.66.1 -*2018-09-19* -* Ignore falsy plugins ([#2464](https://github.com/rollup/rollup/pull/2464)) -* Switch back to official TypeScript plugin ([#2465](https://github.com/rollup/rollup/pull/2465)) - -## 0.66.0 -*2018-09-16* -* Support ES2019 optional catch bindings ([#2455](https://github.com/rollup/rollup/pull/2455)) -* Add option to transform paths within sourcemaps ([#2430](https://github.com/rollup/rollup/pull/2430)) -* Add renderStart and renderEnd plugin hooks ([#2438](https://github.com/rollup/rollup/pull/2438)) -* Expose ESM browser build and minify browser builds ([#2437](https://github.com/rollup/rollup/pull/2437) -* Associate hoisted variables in function bodys with function parameters ([#2456](https://github.com/rollup/rollup/pull/2456)) -* Fix issue when deconflicting variables used as pattern defaults ([#2446](https://github.com/rollup/rollup/pull/2446)) -* Properly deconflict default exported class and function expressions with ids ([#2458](https://github.com/rollup/rollup/pull/2458)) -* Faster internal test builds ([#2457](https://github.com/rollup/rollup/pull/2457)) -* Switch to rollup-plugin-typescript2 ([#2460](https://github.com/rollup/rollup/pull/2460)) -* Fix internal "perf" script ([#2433](https://github.com/rollup/rollup/pull/2433)) -* Test that errors are passed to the buildEnd hook ([#2450](https://github.com/rollup/rollup/pull/2450)) - -## 0.65.2 -*2018-09-05* -* Prevent watch mode memory leak ([#2441](https://github.com/rollup/rollup/pull/2441)) - -## 0.65.1 -*2018-09-05* -* Prevent globbing when using chokidar ([#2432](https://github.com/rollup/rollup/pull/2432)) - -## 0.65.0 -*2018-08-25* -* Refactor and unify plugin system ([#2382](https://github.com/rollup/rollup/pull/2382)) -* Implement plugin cache API ([#2389](https://github.com/rollup/rollup/pull/2389)) -* Add watchChange plugin hook to watch changed files, deprecate asset dependencies ([#2405](https://github.com/rollup/rollup/pull/2405)) -* Refine asset handling ([#2369](https://github.com/rollup/rollup/pull/2369)) -* Implement `renderChunk` hook to replace `transformChunk` and `transformBundle` hooks ([#2406](https://github.com/rollup/rollup/pull/2406)) -* Add rollup version to plugin context ([#2394](https://github.com/rollup/rollup/pull/2394)) -* Do not resume stdin in watch mode to fix it for Lerna users ([#2410](https://github.com/rollup/rollup/pull/2410)) -* Allow `[format]` placeholder for id generation ([#2387](https://github.com/rollup/rollup/pull/2387)) -* Always log error stacks even when a code frame is given ([#2417](https://github.com/rollup/rollup/pull/2417)) -* Do not test module ids starting with `\0` as external ([#2400](https://github.com/rollup/rollup/pull/2400)) -* Fix tracing of namespace variables ([#2408](https://github.com/rollup/rollup/pull/2408)) -* Fix re-tracing of namespace variables ([#2420](https://github.com/rollup/rollup/pull/2420)) -* Properly wrap comment annotations in SystemJS exports ([#2408](https://github.com/rollup/rollup/pull/2408)) -* Fix renaming of destructured parameters ([#2419](https://github.com/rollup/rollup/pull/2419)) -* Do not display version in watch mode when using `--silent` ([#2392](https://github.com/rollup/rollup/pull/2392)) -* Make `cacheExpiry` an experimental option for now ([#2401](https://github.com/rollup/rollup/pull/2401)) -* Lint test configs on commit ([#2402](https://github.com/rollup/rollup/pull/2402)) -* Add code of conduct ([#2388](https://github.com/rollup/rollup/pull/2388)) -* Move to CircleCI ([#2390](https://github.com/rollup/rollup/pull/2390)) -* Update pull request template ([#2404](https://github.com/rollup/rollup/pull/2404)) - -## 0.64.1 -*2018-08-07* -* Do not render initializers of hoisted variables in dead branches ([#2384](https://github.com/rollup/rollup/pull/2384)) - -## 0.64.0 -*2018-08-07* -* Print memory consumption together with performance timings ([#2370](https://github.com/rollup/rollup/pull/2370)) -* Enable plugins to mark imports as external by returning false for resolveId ([#2351](https://github.com/rollup/rollup/pull/2351)) -* Always retain empty manual chunks ([#2362](https://github.com/rollup/rollup/pull/2362)) -* Ensure CLI warnings are shown on errors and add error for external id collisions ([#2334](https://github.com/rollup/rollup/pull/2334)) -* Remove unnecessary dependency, update dependencies, fix linting of test config ([#2376](https://github.com/rollup/rollup/pull/2376)) -* Add targeted Github issue templates ([#2356](https://github.com/rollup/rollup/pull/2356)) - -## 0.63.5 -*2018-08-01* -* Ensure onwrite plugin hooks execute in sequence ([#2364](https://github.com/rollup/rollup/pull/2364)) -* Always warn when no name is provided for a global module ([#2359](https://github.com/rollup/rollup/pull/2359)) -* Add utility type for user created plugins ([#2355](https://github.com/rollup/rollup/pull/2355)) -* Remove deprecated es6 format from types ([#2349](https://github.com/rollup/rollup/pull/2349)) -* Mark inlineDynamicImports as optional in types ([#2348](https://github.com/rollup/rollup/pull/2348)) - -## 0.63.4 -*2018-07-20* -* Use turbocolor instead of chalk ([#2339](https://github.com/rollup/rollup/pull/2339)) - -## 0.63.3 -*2018-07-20* -* Handle expressions where "in" and "instanceof" are applied to primitive values ([#2344](https://github.com/rollup/rollup/pull/2344)) - -## 0.63.2 -*2018-07-18* -* Fix bind order in for-of loops ([#2338](https://github.com/rollup/rollup/pull/2338)) - -## 0.63.1 -*2018-07-18* - -## 0.63.0 -*2018-07-17* -* Fix many tree-shaking related issues ([#2315](https://github.com/rollup/rollup/pull/2315)) -* Add experimental support for top-level await ([#2235](https://github.com/rollup/rollup/pull/2235)) -* Prevent duplicate version printout in watch mode ([#2325](https://github.com/rollup/rollup/pull/2325)) -* Respect error frames provided by plugins ([#2309](https://github.com/rollup/rollup/pull/2309)) -* Add `esm` format alias to types ([#2327](https://github.com/rollup/rollup/pull/2327)) -* Further unify internal test setup ([#2329](https://github.com/rollup/rollup/pull/2329)) - -## 0.62.0 -*2018-06-27* -* Add option to automatically shim missing exports ([#2118](https://github.com/rollup/rollup/pull/2118)) -* Inline dynamic imports that are also imported statically and only used in a single chunk ([#2295](https://github.com/rollup/rollup/pull/2295)) -* Handle caching and invalidation of assets ([#2267](https://github.com/rollup/rollup/pull/2267)) -* Fix plugin related types ([#2299](https://github.com/rollup/rollup/pull/2299)) - -## 0.61.2 -*2018-06-23* -* Improve watcher error handling, only rebuild invalidated outputs ([#2296](https://github.com/rollup/rollup/pull/2296)) -* Update dependencies, make watcher more stable ([#2297](https://github.com/rollup/rollup/pull/2297)) - -## 0.61.1 -*2018-06-21* -* Do not try to deconflict "undefined" ([#2291](https://github.com/rollup/rollup/pull/2291)) -* Properly track values for loop interator declarations and reassigned namespaces, add smoke test ([#2292](https://github.com/rollup/rollup/pull/2292)) - -## 0.61.0 -*2018-06-20* -* Declare file dependencies via transform plugin hooks ([#2259](https://github.com/rollup/rollup/pull/2259)) -* Handle undefined values when evaluating conditionals ([#2264](https://github.com/rollup/rollup/pull/2264)) -* Handle known undefined properties when evaluating conditionals ([#2265](https://github.com/rollup/rollup/pull/2265)) -* Access watch events via the plugin context ([#2261](https://github.com/rollup/rollup/pull/2261)) -* Add option to suppress `__esModule` flag in output ([#2287](https://github.com/rollup/rollup/pull/2287)) -* Fix issue when re-declaring variables, track reassignments in more cases ([#2279](https://github.com/rollup/rollup/pull/2279)) -* Add VSCode debug settings ([#2276](https://github.com/rollup/rollup/pull/2276)) - -## 0.60.7 -*2018-06-14* -* Fix typing issue ([#2269](https://github.com/rollup/rollup/pull/2269)) - -## 0.60.6 -*2018-06-14* -* Track mutations of included virtual arrays ([#2263](https://github.com/rollup/rollup/pull/2263)) -* Update readme ([#2266](https://github.com/rollup/rollup/pull/2266)) - -## 0.60.5 -*2018-06-14* -* Track deep reassignments of global and exported variables and improve performance ([#2254](https://github.com/rollup/rollup/pull/2254)) - -## 0.60.4 -*2018-06-13* -* Properly handle initially uninitialized exports and exports of globals in SystemJS output ([#2258](https://github.com/rollup/rollup/pull/2258)) - -## 0.60.3 -*2018-06-13* -* Fix types to allow watching an array of outputs ([#2262](https://github.com/rollup/rollup/pull/2262)) - -## 0.60.2 -*2018-06-11* -* Permit setting an asset's source in `generateBundle` ([#2256](https://github.com/rollup/rollup/pull/2256)) -* Add automatic linting ([#2242](https://github.com/rollup/rollup/pull/2242)) - -## 0.60.1 -*2018-06-07* -* Fix plugin regressions ([#2246](https://github.com/rollup/rollup/pull/2246)) -* Avoid conflicts for large numbers of variables ([#2244](https://github.com/rollup/rollup/pull/2244)) - -## 0.60.0 -*2018-06-06* -* New plugin hooks: transformChunk, buildStart, buildEnd; extended plugin context with warn, error, resolveId, isExternal, emitAsset, setAssetSource and getAssetFileName available to any hook ([#2208](https://github.com/rollup/rollup/pull/2208)) -* [BREAKING] Deprecate the `legacy` option and thus IE8 support ([#2141](https://github.com/rollup/rollup/pull/2141)) -* Detect more known extensions and load .mjs without extension ([#2211](https://github.com/rollup/rollup/pull/2211)) -* Add compact output mode ([#2151](https://github.com/rollup/rollup/pull/2151)) -* Significantly improve sourcemap generation performance ([#2228](https://github.com/rollup/rollup/pull/2228)) -* Enable naming SystemJS modules ([#2028](https://github.com/rollup/rollup/pull/2028)) -* Do not use alternate screen if clearScreen is set in watch mode ([#2125](https://github.com/rollup/rollup/pull/2125)) -* Allow object input form for code-splitting in watch mode ([#2217](https://github.com/rollup/rollup/pull/2217)) -* Track reassignments of methods of exports from outside ([#2240](https://github.com/rollup/rollup/pull/2240)) -* Preserve id of default exported functions and classes ([#2234](https://github.com/rollup/rollup/pull/2234)) -* Add semicolons after default exports ([#2209](https://github.com/rollup/rollup/pull/2209)) -* Fix build problems on Windows ([#2232](https://github.com/rollup/rollup/pull/2232)) -* Display install size in readme ([#2196](https://github.com/rollup/rollup/pull/2196)) -* Improve preserve modules test ([#2236](https://github.com/rollup/rollup/pull/2236)) - -## 0.59.4 -*2018-05-28* -* Fix performance regression when many return statements are used ([#2218](https://github.com/rollup/rollup/pull/2218)) - -## 0.59.3 -*2018-05-24* -* Fix reassignment tracking for constructor parameters ([#2214](https://github.com/rollup/rollup/pull/2214)) - -## 0.59.2 -*2018-05-21* -* Fix reassignment tracking in for-in loops ([#2205](https://github.com/rollup/rollup/pull/2205)) - -## 0.59.1 -*2018-05-16* -* Fix infinite recursion when determining literal values of circular structures ([#2193](https://github.com/rollup/rollup/pull/2193)) -* Fix invalid code when simplifying expressions without spaces ([#2194](https://github.com/rollup/rollup/pull/2194)) - -## 0.59.0 -*2018-05-15* -* Tree-shake statically analysable dynamic conditionals ([#2167](https://github.com/rollup/rollup/pull/2167)) -* Do not emit empty chunks when code-splitting or empty files when preserving modules ([#2128](https://github.com/rollup/rollup/pull/2128)) -* Support `import.meta.url` ([#2164](https://github.com/rollup/rollup/pull/2164)) -* Add `esm` format alias ([#2102](https://github.com/rollup/rollup/pull/2102)) -* Use alphanumeric base64 characters when deconflicting variables ([#2188](https://github.com/rollup/rollup/pull/2188)) -* Improve handling of external modules imported as both default and named imports ([#2136](https://github.com/rollup/rollup/pull/2136)) -* Properly deconflict named imports from other chunks ([#2177](https://github.com/rollup/rollup/pull/2177)) -* Fix an issue with namespaces containing reexports ([#2157](https://github.com/rollup/rollup/pull/2157)) -* Fix an issue with with incorrectly mapped default exports when code-splitting CJS or AMD modules ([#2178](https://github.com/rollup/rollup/pull/2178)) -* Fix an issue with wrong paths of relative external imports ([#2160](https://github.com/rollup/rollup/pull/2160)) -* Fix an issue when using default exports and `interop: false` ([#2149](https://github.com/rollup/rollup/pull/2149)) -* Fix in issue with invalid syntax in SystemJS output ([#2187](https://github.com/rollup/rollup/pull/2187)) -* Fix an issue when tree-shaking call expressions and reassigned variables ([#2186](https://github.com/rollup/rollup/pull/2186)) -* Fix file paths in source maps ([#2161](https://github.com/rollup/rollup/pull/2161)) -* Fix wrong file name in error message ([#2137](https://github.com/rollup/rollup/pull/2137)) -* Always use npm 5 on CI ([#2185](https://github.com/rollup/rollup/pull/2185)) - -## 0.58.2 -*2018-04-23* -* Fix rendering of certain statically resolvable if statements ([#2146](https://github.com/rollup/rollup/pull/2146)) - -## 0.58.1 -*2018-04-18* -* Fix comment detection ([#2129](https://github.com/rollup/rollup/pull/2129)) - -## 0.58.0 -*2018-04-16* -* Support individual chunk names with optional content hashes ([#2068](https://github.com/rollup/rollup/pull/2068)) -* Support manually created chunks ([#2084](https://github.com/rollup/rollup/pull/2084)) -* Automatically import deep dependencies when code splitting for better performance ([#2073](https://github.com/rollup/rollup/pull/2073)) -* Automatically minify internal export/import names for esm and system output ([#2087](https://github.com/rollup/rollup/pull/2087)) -* Add option to automatically merge small chunks ([#2090](https://github.com/rollup/rollup/pull/2090)) -* Significantly improve tree-shaking performance ([#2119](https://github.com/rollup/rollup/pull/2119)) -* Enable tree-shaking for logical expressions ([#2098](https://github.com/rollup/rollup/pull/2098)) -* Rework external types and reduce type related dependencies ([#2108](https://github.com/rollup/rollup/pull/2108)) -* Support parallel dependency resolution ([#2116](https://github.com/rollup/rollup/pull/2116)) -* Improve deprecation handling ([#2076](https://github.com/rollup/rollup/pull/2076)) -* Enable `--perf` timings in watch mode ([#2065](https://github.com/rollup/rollup/pull/2065)) -* Improve performance timers ([#2111](https://github.com/rollup/rollup/pull/2111)) -* Improve error handling for plugins ([#2100](https://github.com/rollup/rollup/pull/2100)) -* Improve error when using `--dir` in a single file build ([#2123](https://github.com/rollup/rollup/pull/2123)) -* Do not warn for external imports that are unused due to tree-shaking ([#2124](https://github.com/rollup/rollup/pull/2124)) -* Update mixed export warning message ([#2107](https://github.com/rollup/rollup/pull/2107)) -* Remove duplicate badges from readme ([#2083](https://github.com/rollup/rollup/pull/2083)) -* Update readme examples ([#2086](https://github.com/rollup/rollup/pull/2086)) - -## 0.57.1 -*2018-03-17* -* Improve sourcemap generation performance ([#2062](https://github.com/rollup/rollup/pull/2062)) -* Add reserved config option namespace and improve CLI interface ([#2063](https://github.com/rollup/rollup/pull/2063)) -* Fix issue with default exported function and class expressions ([#2059](https://github.com/rollup/rollup/pull/2059)) -* Replace `forEach` with faster `for` loops in some places ([#2064](https://github.com/rollup/rollup/pull/2064)) - -## 0.57.0 -*2018-03-15* -* Add option to preserve the module structure instead of bundling ([#1922](https://github.com/rollup/rollup/pull/1922)) -* Enable watch mode when code-splitting ([#2035](https://github.com/rollup/rollup/pull/2035)) -* Optionally pass CLI commands to config file ([#1926](https://github.com/rollup/rollup/pull/1926)) -* Option to add correct `.toString` tags to namespaces ([#2041](https://github.com/rollup/rollup/pull/2041)) -* Option and scripts to display performance timings ([#2045](https://github.com/rollup/rollup/pull/2045)) -* Fixes for exported or early accessed namespaces + improved namespace indentation ([#2041](https://github.com/rollup/rollup/pull/2041)) -* Include missing TypeScript dependencies ([#1965](https://github.com/rollup/rollup/pull/1965)) -* Add #_PURE annotation to frozen namespaces ([#2044](https://github.com/rollup/rollup/pull/2044)) -* Improve sourcemap and tree-shaking performance ([#2052](https://github.com/rollup/rollup/pull/2052)) -* Inline sourcemap lookups and make rollup smaller ([#2055](https://github.com/rollup/rollup/pull/2055)) -* Use updated magic-string types ([#2057](https://github.com/rollup/rollup/pull/2057)) -* [BREAKING] Revert class id preservation from #2025 ([#2048](https://github.com/rollup/rollup/pull/2048)) -* [BREAKING] Refactor missing export plugin hook ([#1987](https://github.com/rollup/rollup/pull/1987)) - -## 0.56.5 -*2018-03-07* -* Preserve ids when deconflicting classes ([#2025](https://github.com/rollup/rollup/pull/2025)) -* Fix an issue with re-exported namespace imports ([#2034](https://github.com/rollup/rollup/pull/2034)) -* Prevent an infinite loop when binding member expressions ([#1963](https://github.com/rollup/rollup/pull/1963)) -* Convert code style via prettier ([#2031](https://github.com/rollup/rollup/pull/2031)) -* Fix links in documentation ([#2026](https://github.com/rollup/rollup/pull/2026)) - -## 0.56.4 -*2018-03-05* -* Make rollup builds reproducible ([#2024](https://github.com/rollup/rollup/pull/2024)) -* Improve error handling for source maps ([#2012](https://github.com/rollup/rollup/pull/2012)) -* Properly handle SystemJS default exports without semicolons ([#2019](https://github.com/rollup/rollup/pull/2019)) -* Properly handle importing the same variable several times when code-splitting ([#2020](https://github.com/rollup/rollup/pull/2020)) -* Improve re-export tracing ([#2021](https://github.com/rollup/rollup/pull/2021)) -* Apply "prettier" on commit ([#2017](https://github.com/rollup/rollup/pull/2017)) -* Automatically clean up outdated tests ([#2009](https://github.com/rollup/rollup/pull/2009)) -* Add SystemJS output to form tests ([#2022](https://github.com/rollup/rollup/pull/2022)) -* Improve internal build configuration ([#2016](https://github.com/rollup/rollup/pull/2016)) - -## 0.56.3 -*2018-02-25* -* Fix issues around default exports and module facades ([#2001](https://github.com/rollup/rollup/pull/2001)) -* Improve and fix internal chunk interface ([#1994](https://github.com/rollup/rollup/pull/1994)) -* Fix superfluous semicolons added after declarations ([#1999](https://github.com/rollup/rollup/pull/1999)) -* Improve code-splitting tests ([#1990](https://github.com/rollup/rollup/pull/1990)) - -## 0.56.2 -*2018-02-19* -* Fix handling of reassigned default exports ([#1975](https://github.com/rollup/rollup/pull/1975)) -* Fix handling of renamed exports in entry points ([#1977](https://github.com/rollup/rollup/pull/1977)) -* Update internal TypeScript version ([#1980](https://github.com/rollup/rollup/pull/1980)) -* Omit compiled source files from published types ([#1981](https://github.com/rollup/rollup/pull/1981)) -* Fix example in readme file ([#1984](https://github.com/rollup/rollup/pull/1984)) -* Fix non-replaced dynamic imports in non-ESM output ([#1985](https://github.com/rollup/rollup/pull/1985)) - -## 0.56.1 -*2018-02-16* -* Fix regression when rendering switch statements ([#1971](https://github.com/rollup/rollup/pull/1971)) - -## 0.56.0 -*2018-02-15* -* Update to ECMAScript 2018 ([#1953](https://github.com/rollup/rollup/pull/1953)) -* Rework tree-shaking rendering algorithm ([#1949](https://github.com/rollup/rollup/pull/1949)) -* Tree-shake pure prototype calls on literals ([#1916](https://github.com/rollup/rollup/pull/1916)) -* Expose AST parser to plugins ([#1945](https://github.com/rollup/rollup/pull/1945)) -* Fix namespace re-export deconflicting ([#1960](https://github.com/rollup/rollup/pull/1960)) -* Allow globals to be re-exported ([#1959](https://github.com/rollup/rollup/pull/1959)) -* Fix internal performance timers ([#1966](https://github.com/rollup/rollup/pull/1966)) - -## 0.55.5 -*2018-02-10* -* Remove OpenCollective dependency ([#1915](https://github.com/rollup/rollup/pull/1915)) - -## 0.55.4 -*2018-02-09* -* Improve name deconflicting of external variables ([#1930](https://github.com/rollup/rollup/pull/1930)) -* Improve re-export handling ([#1947](https://github.com/rollup/rollup/pull/1947)) -* Mark preserveSymlinks option as optional ([#1939](https://github.com/rollup/rollup/pull/1939)) -* Enable code-splitting tests to check directory structures ([#1924](https://github.com/rollup/rollup/pull/1924)) -* Improve TypeScript definition test ([#1954](https://github.com/rollup/rollup/pull/1954)) - -## 0.55.3 -*2018-02-01* -* Remove OpenCollective dependency ([#1915](https://github.com/rollup/rollup/pull/1915)) - -## 0.55.2 -*2018-02-01* -* Add option to not follow symlinks ([#1819](https://github.com/rollup/rollup/pull/1819)) -* Fix crash in windows shell ([#1928](https://github.com/rollup/rollup/pull/1928)) -* Fix and test for external TypeScript errors ([#1903](https://github.com/rollup/rollup/pull/1903)) -* Activate OpenCollective ([#1915](https://github.com/rollup/rollup/pull/1915)) -* Optimize CI scripts ([#1921](https://github.com/rollup/rollup/pull/1921)) - -## 0.55.1 -*2018-01-26* -* Improve dynamic import workflow ([#1907](https://github.com/rollup/rollup/pull/1907)) -* Properly handle multiple dynamic imports of the same module ([#1911](https://github.com/rollup/rollup/pull/1911)) -* Fix import specifier deshadowing ([#1912](https://github.com/rollup/rollup/pull/1912)) -* Allow plugin load hook to return an empty string ([#1908](https://github.com/rollup/rollup/pull/1908)) -* Let onwarn handler accept strings ([#1905](https://github.com/rollup/rollup/pull/1905)) - -## 0.55.0 -*2018-01-23* -* Support code splitting ([#1841](https://github.com/rollup/rollup/pull/1841)) -* Support SystemJS as output format ([#1897](https://github.com/rollup/rollup/pull/1897)) -* Allow injecting acorn plugins ([#1857](https://github.com/rollup/rollup/pull/1857)) -* Add `missingExport` plugin hook ([#1845](https://github.com/rollup/rollup/pull/1845)) -* No longer parse config files via bublé ([#1899](https://github.com/rollup/rollup/pull/1899)) -* Use externally maintained dynamic import acorn plugin ([#1891](https://github.com/rollup/rollup/pull/1891)) -* Fix an error message ([#1886](https://github.com/rollup/rollup/pull/1886)) -* Refactor internal rendering options ([#1900](https://github.com/rollup/rollup/pull/1900)) -* Extract internal path resolution ([#1879](https://github.com/rollup/rollup/pull/1879)) -* Extract internal bundle option handling ([#1880](https://github.com/rollup/rollup/pull/1880)) -* Add import description type ([#1884](https://github.com/rollup/rollup/pull/1884)) -* Clean up watch options types ([#1860](https://github.com/rollup/rollup/pull/1860)) -* Clean up some tests ([#1888](https://github.com/rollup/rollup/pull/1888)) - -## 0.54.1 -*2018-01-17* -* Fix TypeScript errors in emitted type definitions ([#1871](https://github.com/rollup/rollup/pull/1871)) - -## 0.54.0 -*2018-01-12* -* Automatically inline locally resolvable dynamic imports ([#1816](https://github.com/rollup/rollup/pull/1816)) -* Preserve directives in function bodies ([#1856](https://github.com/rollup/rollup/pull/1856)) -* Refactor an error notification ([#1846](https://github.com/rollup/rollup/pull/1846)) -* Refactor a wrong import ([#1863](https://github.com/rollup/rollup/pull/1863)) -* Improve emitted TypeScript definitions ([#1864](https://github.com/rollup/rollup/pull/1864)) -* Refactor unused import ([#1866](https://github.com/rollup/rollup/pull/1866)) - -## 0.53.4 -*2018-01-10* -* More type cleanup ([#1858](https://github.com/rollup/rollup/pull/1858)) -* Use chalks internal helper to detect if colors should be used ([#1853](https://github.com/rollup/rollup/pull/1853)) -* Refactor entity handling to use interfaces ([#1840](https://github.com/rollup/rollup/pull/1840)) -* Use immutable.js internal types ([#1844](https://github.com/rollup/rollup/pull/1844)) -* Ship `TypeScript` declaration files ([#1837](https://github.com/rollup/rollup/pull/1837)) - -## 0.53.3 -*2018-01-02* -* Use correct name when re-exporting from external modules ([#1794](https://github.com/rollup/rollup/pull/1794)) -* Disable warnings when `resolveId` returns false ([#1825](https://github.com/rollup/rollup/pull/1825)) - -## 0.53.2 -*2017-12-30* -* Properly handle output arrays in the JavaScript API ([#1827](https://github.com/rollup/rollup/pull/1827)) - -## 0.53.1 -*2017-12-28* -* Properly deprecate more config options ([#1812](https://github.com/rollup/rollup/pull/1812)) -* Pass output options to `transformBundle` plugin hook ([#1813](https://github.com/rollup/rollup/pull/1813)) - -## 0.53.0 -*2017-12-22* -* Experimental dynamic import support ([#1790](https://github.com/rollup/rollup/pull/1790)) -* Unify config validation ([#1805](https://github.com/rollup/rollup/pull/1805)) - -## 0.52.3 -*2017-12-19* -* Properly hoist default exported functions in more situations ([#1799](https://github.com/rollup/rollup/pull/1799)) -* Allow plugin transformations to not overwrite source maps by returning null ([#1797](https://github.com/rollup/rollup/pull/1797)) -* Provide more parameters to "external" handler ([#1792](https://github.com/rollup/rollup/pull/1792)) - -## 0.52.2 -*2017-12-15* -* No longer ignore side-effects in JSON.parse and JSON.stringify ([#1785](https://github.com/rollup/rollup/pull/1785)) -* Updated links in warnings ([#1776](https://github.com/rollup/rollup/pull/1776)) -* No longer prevent self-imports ([#1777](https://github.com/rollup/rollup/pull/1777)) -* Properly hoist default exported functions ([#1787](https://github.com/rollup/rollup/pull/1787)) -* Prevent corruption when re-exporting default exports ([#1765](https://github.com/rollup/rollup/pull/1765)) - -## 0.52.1 -*2017-12-05* -* Improve deprecation warnings ([#1765](https://github.com/rollup/rollup/pull/1765)) -* Properly use stdin ([#1774](https://github.com/rollup/rollup/pull/1774)) -* Let --environment be used multiple times ([#1768](https://github.com/rollup/rollup/pull/1768)) -* Always transpile config files ([#1759](https://github.com/rollup/rollup/pull/1759)) -* Respect globals option in headers of UMD and IIFE files ([#1747](https://github.com/rollup/rollup/pull/1747)) - -## 0.52.0 -*2017-11-25* -* Accept config as promise ([#1731](https://github.com/rollup/rollup/pull/1731)) -* Accept promises for intro/outro/banner/footer ([#1253](https://github.com/rollup/rollup/pull/1253)) -* Option to prevent freezing of namespace imports ([#1696](https://github.com/rollup/rollup/pull/1696)) -* Option to retain all output in watch mode ([#1688](https://github.com/rollup/rollup/pull/1688)) -* Options to fine-tune treeshaking ([#1760](https://github.com/rollup/rollup/pull/1760)) - -## 0.51.8 -*2017-11-19* -* Fix speed problems by simplifying treeshaking reassignment handling ([#1740](https://github.com/rollup/rollup/pull/1740)) -* Update dependencies ([#1742](https://github.com/rollup/rollup/pull/1742)) - -## 0.51.7 -*2017-11-17* -* Keep "this"-context when calling sequence expressions ([#1724](https://github.com/rollup/rollup/pull/1724)) - -## 0.51.6 -*2017-11-16* -* Use sourcemaps to determine error locations ([#1728](https://github.com/rollup/rollup/pull/1728)) - -## 0.51.5 -*2017-11-11* -* Fix regressions with uninitialised conditional expressions ([#1720](https://github.com/rollup/rollup/pull/1720)) - -## 0.51.4 -*2017-11-11* -* Fix regressions preventing builds ([#1725](https://github.com/rollup/rollup/pull/1725)) -## 0.51.3 -*2017-11-10* -* Fix regression when treeshaking sequence expressions ([#1717](https://github.com/rollup/rollup/pull/1717)) +- Revert #5644 "stable chunk hashes" while issues are being investigated + +### Pull Requests + +- [#5663](https://github.com/rollup/rollup/pull/5663): chore(deps): update dependency inquirer to v11 (@renovate[bot], @lukastaegert) +- [#5664](https://github.com/rollup/rollup/pull/5664): chore(deps): lock file maintenance minor/patch updates (@renovate[bot]) +- [#5665](https://github.com/rollup/rollup/pull/5665): fix: type in CI file (@YuHyeonWook) +- [#5666](https://github.com/rollup/rollup/pull/5666): chore(deps): lock file maintenance minor/patch updates (@renovate[bot]) -## 0.51.2 -*2017-11-09* -* Fix treeshaking regression when labels are used inside functions ([#1712](https://github.com/rollup/rollup/pull/1712)) +## 4.22.0 -## 0.51.1 -*2017-11-08* -* Fix an issue with empty return statements ([#1704](https://github.com/rollup/rollup/pull/1704)) +_2024-09-19_ -## 0.51.0 -*2017-11-08* -* Massive improvements to the treeshaking algorithm ([#1667](https://github.com/rollup/rollup/pull/1667)) +### Features -## 0.50.1 -*2017-11-08* -* Fix treeshaking regression ([#1695](https://github.com/rollup/rollup/pull/1695)) -* Treeshaking improvements ([#1650](https://github.com/rollup/rollup/pull/1650)) -* Enable installation from Github ([#1670](https://github.com/rollup/rollup/pull/1670)) -* Update documentation ([#1660](https://github.com/rollup/rollup/pull/1660)) +- Add additional known global values to avoid access side effects (#5651) -## 0.50.0 -*2017-09-16* -* Many treeshaking improvements ([#1624](https://github.com/rollup/rollup/pull/1624)) -* Show finish time in watch mode ([#1620](https://github.com/rollup/rollup/pull/1620)) +### Bug Fixes -## 0.49.3 -*2017-09-08* -* Respect `watch` options ([#1596](https://github.com/rollup/rollup/issues/1596)) -* Fix treeshaking regressions ([#1604](https://github.com/rollup/rollup/pull/1604)) -* Allow `-o` to work with `output.format` ([#1606](https://github.com/rollup/rollup/pull/1606)) +- Ensure deterministic chunk hash generation despite async renderChunk hook (#5644) +- Improve side effect detection when using "smallest" treeshaking preset when imports are optimized away (#5658) -## 0.49.2 -*2017-08-29* -* Fix treeshaking regressions ([#1591](https://github.com/rollup/rollup/pull/1591)) +### Pull Requests -## 0.49.1 -*2017-08-28* -* Fix treeshaking regressions ([#1586](https://github.com/rollup/rollup/pull/1586)) +- [#5644](https://github.com/rollup/rollup/pull/5644): fix: apply final hashes deterministically with stable placeholders set (@mattkubej, @lukastaegert) +- [#5646](https://github.com/rollup/rollup/pull/5646): chore(deps): update dependency @mermaid-js/mermaid-cli to v11 (@renovate[bot]) +- [#5647](https://github.com/rollup/rollup/pull/5647): chore(deps): update dependency concurrently to v9 (@renovate[bot]) +- [#5648](https://github.com/rollup/rollup/pull/5648): chore(deps): lock file maintenance minor/patch updates (@renovate[bot]) +- [#5651](https://github.com/rollup/rollup/pull/5651): feat: add `AggregateError`, `FinalizationRegistry`, `WeakRef` to knownGlobals (@re-taro) +- [#5653](https://github.com/rollup/rollup/pull/5653): Fix example selection in REPL (@lukastaegert) +- [#5657](https://github.com/rollup/rollup/pull/5657): chore(deps): update dependency vite to v5.4.6 [security] (@renovate[bot]) +- [#5658](https://github.com/rollup/rollup/pull/5658): Detect variable reassignments in modules without side effects (@lukastaegert) -## 0.49.0 -*2017-08-27* -* Completely update the treeshaking algorithm ([#1582](https://github.com/rollup/rollup/pull/1582)) -* Only flip screen buffer if appropriate ([#1574](https://github.com/rollup/rollup/pull/1574)) -* Guard against two instances creating the same dir ([#1576](https://github.com/rollup/rollup/pull/1576)) +## 4.21.3 -## 0.48.2 +_2024-09-12_ -* Paths is an output option ([#1569](https://github.com/rollup/rollup/pull/1569)) +### Bug Fixes -## 0.48.1 +- Always respect side effects in left-hand side of optional chain (#5642) +- Update stack trace for augmented errors to not hide relevant information (#5640) -* Print deprecation warnings in watch mode, and fix options when watcher restarts ([#1568](https://github.com/rollup/rollup/pull/1568)) +### Pull Requests -## 0.48.0 +- [#5636](https://github.com/rollup/rollup/pull/5636): chore(deps): lock file maintenance minor/patch updates (@renovate[bot]) +- [#5637](https://github.com/rollup/rollup/pull/5637): chore(deps): lock file maintenance (@renovate[bot]) +- [#5640](https://github.com/rollup/rollup/pull/5640): fix: keep the message of stack up-to-date (@TrickyPi) +- [#5642](https://github.com/rollup/rollup/pull/5642): fix: include left-side effect of optional chaining in the end of hasEffectsAsChainElement (@TrickyPi) -* Numerous changes to the `options` object and CLI arguments ([#1479](https://github.com/rollup/rollup/issues/1479)). See [this gist](https://gist.github.com/Rich-Harris/d472c50732dab03efeb37472b08a3f32) for a rundown. +## 4.21.2 -## 0.47.6 +_2024-08-30_ -* Set `process.env.ROLLUP_WATCH` *before* loading config file +### Bug Fixes -## 0.47.5 +- Handle IIFE/UMD namespace definitions conflicting with a builtin property (#5605) -* Fix broken multi-bundle configs with `rollup.watch` ([#1532](https://github.com/rollup/rollup/issues/1532)) +### Pull Requests -## 0.47.4 +- [#5605](https://github.com/rollup/rollup/pull/5605): fix: Wrong namespace property definition (@thirumurugan-git, @lukastaegert) +- [#5630](https://github.com/rollup/rollup/pull/5630): chore(deps): lock file maintenance minor/patch updates (@renovate[bot]) +- [#5631](https://github.com/rollup/rollup/pull/5631): chore(deps): lock file maintenance (@renovate[bot]) +- [#5632](https://github.com/rollup/rollup/pull/5632): chore(deps): lock file maintenance (@renovate[bot]) -* Delete cached config file before reloading in watch mode +## 4.21.1 -## 0.47.3 +_2024-08-26_ -* Deshadow aliased imports ([#1550](https://github.com/rollup/rollup/issues/1550)) +### Bug Fixes -## 0.47.2 +- Ensure `closeWatcher` hook is called when watch mode is aborted via Ctrl+C (#5618) +- Do not produce invalid code for `import.meta.url` in compact mode (#5624) +- Do not throw when generating chunk names when preserving modules in Windows (#5625) -* Rebuild with dependency that npm randomly deleted +### Pull Requests -## 0.47.1 +- [#5591](https://github.com/rollup/rollup/pull/5591): chore(deps): update dependency @types/eslint to v9 (@renovate[bot], @lukastaegert) +- [#5618](https://github.com/rollup/rollup/pull/5618): preload the WASM file even though the version is undefined. (@TrickyPi) +- [#5619](https://github.com/rollup/rollup/pull/5619): Call and await closeWatcher hooks on exit signals (@lukastaegert) +- [#5622](https://github.com/rollup/rollup/pull/5622): chore(deps): lock file maintenance minor/patch updates (@renovate[bot], @lukastaegert) +- [#5624](https://github.com/rollup/rollup/pull/5624): fix: add space for DOCUMENT_CURRENT_SCRIPT template (@TrickyPi) +- [#5625](https://github.com/rollup/rollup/pull/5625): fix: get the right chunk name for preserve modules in Windows (@TrickyPi, @lukastaegert) -* Ignore external namespace imports when deshadowing ([#1547](https://github.com/rollup/rollup/issues/1547)) +## 4.21.0 -## 0.47.0 +_2024-08-18_ -* Watch config file, restart `rollup.watch` on change ([#1535](https://github.com/rollup/rollup/issues/1535)) -* Correctly render `export { foo } from` declarations in `es` output ([#1543](https://github.com/rollup/rollup/pull/1543)) -* Reinstate missing `rollup.VERSION` +### Features -## 0.46.3 +- Add option to configure directory for virtual modules when preserving modules (#5602) -* init for/for-of loop section head with correct scopes ([#1538](https://github.com/rollup/rollup/issues/1538), [#1539](https://github.com/rollup/rollup/issues/1539)) -* Fix namespace imports and re-exports in `es` output ([#1511](https://github.com/rollup/rollup/issues/1511)) -* Deshadow indirectly imported namespaces ([#1488](https://github.com/rollup/rollup/issues/1488), [#1505](https://github.com/rollup/rollup/issues/1505)) +### Pull Requests -## 0.46.2 +- [#5602](https://github.com/rollup/rollup/pull/5602): feat: introduce the virtualDirname option to customize the virtual directory name (@TrickyPi) +- [#5607](https://github.com/rollup/rollup/pull/5607): chore(deps): update typescript-eslint monorepo to v8 (major) (@renovate[bot], @lukastaegert) +- [#5608](https://github.com/rollup/rollup/pull/5608): chore(deps): lock file maintenance minor/patch updates (@renovate[bot]) +- [#5611](https://github.com/rollup/rollup/pull/5611): chore: fix the `noConflict` option in REPL. (@7086cmd) +- [#5613](https://github.com/rollup/rollup/pull/5613): chore(deps): lock file maintenance minor/patch updates (@renovate[bot]) +- [#5614](https://github.com/rollup/rollup/pull/5614): chore(deps): lock file maintenance (@renovate[bot]) -* Pass options to `bundle.write` correctly in `rollup.watch` ([#1533](https://github.com/rollup/rollup/issues/1533)) -* init for-in loop section head with correct scopes ([#1480](https://github.com/rollup/rollup/issues/1480)) -* support `--no-interop` flag ([#1524](https://github.com/rollup/rollup/issues/1524)) +## 4.20.0 -## 0.46.1 +_2024-08-03_ -* Remove `rollup.watch` from browser build ([#1530](https://github.com/rollup/rollup/issues/1530)) -* Remove `source-map-support` dependency ([#1528](https://github.com/rollup/rollup/issues/1528)) +### Features -## 0.46.0 +- Allow plugins to specify the original file name when emitting assets (#5596) -* `options.format` is now required ([#1491](https://github.com/rollup/rollup/pull/1491)) -* if `options.format` is `es6`, it will now throw an error (should be `es`) ([#1491](https://github.com/rollup/rollup/pull/1491)) -* Add experimental `rollup.watch` method, replacing [rollup-watch](https://github.com/rollup/rollup-watch) ([#1491](https://github.com/rollup/rollup/pull/1491)) -* Batch warnings together in CLI output ([#1491](https://github.com/rollup/rollup/pull/1491)) -* Clear screen between rebuilds in `--watch` mode ([#1491](https://github.com/rollup/rollup/pull/1491)) -* `onwarn` function's second argument is the default handler, allowing easier filtering without reimplementing any logic ([#1491](https://github.com/rollup/rollup/pull/1491)) -* Prevent semi-colon removal after variable declaration that is for loop body ([#1275](https://github.com/rollup/rollup/issues/1275)) -* Return `exports` for namespaced but non-extended IIFE bundles ([#1492](https://github.com/rollup/rollup/issues/1492)) -* Fix scoping in switch statements ([#1498](https://github.com/rollup/rollup/pull/1498)) -* Handle side-effects in tagged template expressions ([#1508](https://github.com/rollup/rollup/pull/1508)) -* More descriptive error for missing options.format ([#1510](https://github.com/rollup/rollup/pull/1510)) -* Refactor scope handling ([#1517](https://github.com/rollup/rollup/pull/1517)) -* Handle failure of a config in multi-config build ([#1513](https://github.com/rollup/rollup/issues/1513)) +### Pull Requests +- [#5596](https://github.com/rollup/rollup/pull/5596): Add originalFIleName property to emitted assets (@lukastaegert) +- [#5599](https://github.com/rollup/rollup/pull/5599): chore(deps): update dependency eslint-plugin-unicorn to v55 (@renovate[bot], @lukastaegert) +- [#5600](https://github.com/rollup/rollup/pull/5600): chore(deps): lock file maintenance minor/patch updates (@renovate[bot], @lukastaegert) -## 0.45.2 +## 4.19.2 -* Fix interop when import is a string ([#1486](https://github.com/rollup/rollup/issues/1486)) -* Separate `resolvedIds` from `resolvedExternalIds` ([#1490](https://github.com/rollup/rollup/pull/1490)) -* Add `--extend` flag to CLI ([#1482](https://github.com/rollup/rollup/pull/1482)) +_2024-08-01_ -## 0.45.1 +### Bug Fixes -* Remove `weak` from `optionalDependencies` ([#1483](https://github.com/rollup/rollup/issues/1483)) +- Avoid "cannot get value of null" error when using optional chaining with namespaces (#5597) -## 0.45.0 +### Pull Requests -* [BREAKING] `bundle.generate(...)` returns a Promise, so that `transformBundle` plugin hooks can be asynchronous ([#1474](https://github.com/rollup/rollup/issues/1474)) +- [#5597](https://github.com/rollup/rollup/pull/5597): Fix retrieval of literal values for chained namespaces (@lukastaegert) -## 0.44.0 +## 4.19.1 -* [BREAKING] Don't extend existing globals, unless `options.extend` is true ([#827](https://github.com/rollup/rollup/issues/827)) -* Fix handling of catch clause parameters ([#1462](https://github.com/rollup/rollup/issues/1462)) +_2024-07-27_ -## 0.43.1 +### Bug Fixes -* Fix memory leak on incremental rebuilds ([#883](https://github.com/rollup/rollup/issues/883)) -* Allow `this.warn` and `this.error` to accept a `{line, column}` object as an alternative to a character index ([#1265](https://github.com/rollup/rollup/issues/1265)) -* Print more useful error if entry module is 'external' ([#1264](https://github.com/rollup/rollup/issues/1264)) -* Catch errors in `bundle.generate` options ([#1463](https://github.com/rollup/rollup/pull/1463)) -* Fix magic-string deprecation warning ([#1445](https://github.com/rollup/rollup/pull/1445)) +- Do not remove parantheses when tree-shaking logical expressions (#5584) +- Do not ignore side effects in calls left of an optional chaining operator (#5589) -## 0.43.0 +### Pull Requests -* Allow config files to import JSON ([#1426](https://github.com/rollup/rollup/issues/1426)) -* Allow undefined imports in interop block ([#1341](https://github.com/rollup/rollup/issues/1341)) -* Add `process.env.ROLLUP_WATCH = 'true'` in watch mode ([#1429](https://github.com/rollup/rollup/issues/1429)) -* Add `pureExternalModules` option ([#1352](https://github.com/rollup/rollup/issues/1352)) -* Allow plugins to specify `options.entry` ([#1270](https://github.com/rollup/rollup/issues/1270)) -* Update dependencies +- [#5584](https://github.com/rollup/rollup/pull/5584): fix: find whitespace from operator position to start (@TrickyPi) +- [#5587](https://github.com/rollup/rollup/pull/5587): docs: improve command by code-group (@thinkasany, @lukastaegert) +- [#5589](https://github.com/rollup/rollup/pull/5589): Fix side effect detection in optional chains (@lukastaegert) +- [#5592](https://github.com/rollup/rollup/pull/5592): chore(deps): lock file maintenance minor/patch updates (@renovate[bot]) +- [#5593](https://github.com/rollup/rollup/pull/5593): chore(deps): lock file maintenance minor/patch updates (@renovate[bot]) +- [#5594](https://github.com/rollup/rollup/pull/5594): chore(deps): lock file maintenance (@renovate[bot]) +- [#5595](https://github.com/rollup/rollup/pull/5595): chore(deps): lock file maintenance (@renovate[bot]) -## 0.42.0 +## 4.19.0 -* Deprecate `options.moduleId` in favour of `options.amd.id` ([#1365](https://github.com/rollup/rollup/pull/1365)) -* Add `options.amd.define` option to specify name of AMD `define` function ([#1365](https://github.com/rollup/rollup/pull/1365)) -* Fix incorrect class removal with `treeshake: false` ([#1375](https://github.com/rollup/rollup/pull/1375)) -* Deconflict module exports imported as namespaces ([#1384](https://github.com/rollup/rollup/issues/1384)) -* Handle bare self-imports ([#1274](https://github.com/rollup/rollup/issues/1274)) -* Allow config file to export an array of multiple configs ([#1389](https://github.com/rollup/rollup/pull/1389)) -* Handle exponentiation operator, and fail gracefully on unknown operators ([#1416](https://github.com/rollup/rollup/issues/1416)) -* Add `watch` option ([#1424](https://github.com/rollup/rollup/pull/1424)) +_2024-07-20_ -## 0.41.6 +### Features -* Preserve `originalSourceMap` on incremental rebuilds for loaders with sourcemaps ([#1336](https://github.com/rollup/rollup/issues/1336)) +- Implement support for decorators (#5562) -## 0.41.5 +### Bug Fixes -* Wrap ternary consequent/alternate sequences in parens ([#1273](https://github.com/rollup/rollup/issues/1273)) -* Fix erroneous warning on multiple `export * from` declarations with defaults ([#1278](https://github.com/rollup/rollup/issues/1278)) -* Prevent variable conflicts with `treeshake: false` ([#1268](https://github.com/rollup/rollup/issues/1268)) -* Allow missing `source` when collapsing sourcemaps ([#1254](https://github.com/rollup/rollup/issues/1254)) -* Allow plugins to log with strings ([#1316](https://github.com/rollup/rollup/pull/1316)) +- Improve soucemap generation when tree-shaking logical expressions (#5581) -## 0.41.4 +### Pull Requests -* Fix cases of multiple `export * from 'external'` declarations ([#1252](https://github.com/rollup/rollup/issues/1252)) -* Fix 'TODO' error message ([#1257](https://github.com/rollup/rollup/issues/1257)) +- [#5562](https://github.com/rollup/rollup/pull/5562): feat: implementing decorator support (@TrickyPi, @lukastaegert) +- [#5570](https://github.com/rollup/rollup/pull/5570): refactor(finalisers): condition branch (@Simon-He95, @zhangmo8) +- [#5572](https://github.com/rollup/rollup/pull/5572): Improve chunk and asset type information in docs (@lukastaegert) +- [#5573](https://github.com/rollup/rollup/pull/5573): Switch to audit resolver to ignore requirejs vulnerability (@lukastaegert) +- [#5575](https://github.com/rollup/rollup/pull/5575): chore(deps): update dependency inquirer to v10 (@renovate[bot], @lukastaegert) +- [#5576](https://github.com/rollup/rollup/pull/5576): chore(deps): lock file maintenance minor/patch updates (@renovate[bot], @lukastaegert) +- [#5580](https://github.com/rollup/rollup/pull/5580): chore(deps): lock file maintenance minor/patch updates (@renovate[bot], @lukastaegert) +- [#5581](https://github.com/rollup/rollup/pull/5581): When tree-shaking logical expression, make sure to remove all trailing white-space. (@lukastaegert) -## 0.41.3 +## 4.18.1 -* Don't treat `this.foo` as possible namespace ([#1258](https://github.com/rollup/rollup/issues/1258)) +_2024-07-08_ -## 0.41.2 +### Bug Fixes -* Optimize `namespace['foo']` references ([#1240](https://github.com/rollup/rollup/pull/1240)) +- Prevent "%" in generated file names to ensure imports resolve (#5535) -## 0.41.1 +### Pull Requests -* Include `new` expressions where callee is a class with side-effects ([#980](https://github.com/rollup/rollup/issues/980) [#1233](https://github.com/rollup/rollup/issues/1233)) +- [#5524](https://github.com/rollup/rollup/pull/5524): chore(deps): lock file maintenance minor/patch updates (@renovate[bot]) +- [#5525](https://github.com/rollup/rollup/pull/5525): chore(deps): lock file maintenance (@renovate[bot]) +- [#5526](https://github.com/rollup/rollup/pull/5526): chore(deps): lock file maintenance minor/patch updates (@renovate[bot]) +- [#5527](https://github.com/rollup/rollup/pull/5527): chore(deps): lock file maintenance minor/patch updates (@renovate[bot]) +- [#5529](https://github.com/rollup/rollup/pull/5529): Use Spanned trait to simplify logic (@lukastaegert) +- [#5530](https://github.com/rollup/rollup/pull/5530): Fix typos in ARCHITECTURE.md (@younggglcy) +- [#5532](https://github.com/rollup/rollup/pull/5532): Use Rust macros for converters where possible (@lukastaegert) +- [#5535](https://github.com/rollup/rollup/pull/5535): fix: escape `%` if URI malformed (@baseballyama, @lukastaegert) +- [#5536](https://github.com/rollup/rollup/pull/5536): chore(deps): lock file maintenance minor/patch updates (@renovate[bot], @lukastaegert) +- [#5541](https://github.com/rollup/rollup/pull/5541): chore(deps): lock file maintenance minor/patch updates (@renovate[bot]) +- [#5542](https://github.com/rollup/rollup/pull/5542): chore(deps): lock file maintenance (@renovate[bot]) +- [#5543](https://github.com/rollup/rollup/pull/5543): Watch rust files and rebuild during dev (@lukastaegert) +- [#5544](https://github.com/rollup/rollup/pull/5544): Refactor AST converters (@lukastaegert) +- [#5545](https://github.com/rollup/rollup/pull/5545): chore(deps): update dependency @rollup/plugin-commonjs to v26 (@renovate[bot]) +- [#5546](https://github.com/rollup/rollup/pull/5546): chore(deps): update dependency nyc to v17 (@renovate[bot]) +- [#5547](https://github.com/rollup/rollup/pull/5547): chore(deps): lock file maintenance minor/patch updates (@renovate[bot]) +- [#5548](https://github.com/rollup/rollup/pull/5548): chore(deps): lock file maintenance (@renovate[bot]) +- [#5549](https://github.com/rollup/rollup/pull/5549): chore(deps): lock file maintenance (@renovate[bot]) +- [#5550](https://github.com/rollup/rollup/pull/5550): chore(deps): update dependency eslint-plugin-unicorn to v54 (@renovate[bot], @lukastaegert) +- [#5551](https://github.com/rollup/rollup/pull/5551): chore(deps): lock file maintenance minor/patch updates (@renovate[bot], @lukastaegert) +- [#5555](https://github.com/rollup/rollup/pull/5555): chore(deps): lock file maintenance minor/patch updates (@renovate[bot]) +- [#5556](https://github.com/rollup/rollup/pull/5556): chore(deps): lock file maintenance (@renovate[bot]) +- [#5558](https://github.com/rollup/rollup/pull/5558): Consider that the body of ClassBody might be of type StaticBlock (@TrickyPi) +- [#5565](https://github.com/rollup/rollup/pull/5565): refactor(ast): conditional branch (@Simon-He95) +- [#5566](https://github.com/rollup/rollup/pull/5566): chore(deps): lock file maintenance minor/patch updates (@renovate[bot]) +- [#5567](https://github.com/rollup/rollup/pull/5567): chore(deps): lock file maintenance (@renovate[bot]) -## 0.41.0 +## 4.18.0 -* Add `this.warn(...)` and `this.error(...)` methods to plugin `transform` hook contexts ([#1140](https://github.com/rollup/rollup/issues/1140)) -* `throw` always considered to be a side effect ([#1227](https://github.com/rollup/rollup/pull/1227)) +_2024-05-22_ -## 0.40.2 +### Features -* Add `file` property to sourcemaps for bundles with plugins ([#986](https://github.com/rollup/rollup/issues/986)) -* Don't require globals for empty imports ([#1217](https://github.com/rollup/rollup/issues/1217)) +- Resolve import.meta.filename and .dirname in transpiled plugins (#5520) -## 0.40.1 +### Pull Requests -* Allow missing space between `export default` and declaration ([#1218](https://github.com/rollup/rollup/pull/1218)) +- [#5504](https://github.com/rollup/rollup/pull/5504): Auto generate node index (@lukastaegert) +- [#5507](https://github.com/rollup/rollup/pull/5507): chore(deps): lock file maintenance minor/patch updates (@renovate[bot]) +- [#5508](https://github.com/rollup/rollup/pull/5508): chore(deps): lock file maintenance (@renovate[bot]) +- [#5510](https://github.com/rollup/rollup/pull/5510): Split up converter.rs into AST nodes (@lukastaegert) +- [#5512](https://github.com/rollup/rollup/pull/5512): chore(deps): update dependency builtin-modules to v4 (@renovate[bot], @lukastaegert) +- [#5514](https://github.com/rollup/rollup/pull/5514): chore(deps): lock file maintenance minor/patch updates (@renovate[bot]) +- [#5518](https://github.com/rollup/rollup/pull/5518): chore(deps): update dependency eslint-plugin-unicorn to v53 (@renovate[bot], @lukastaegert) +- [#5519](https://github.com/rollup/rollup/pull/5519): chore(deps): lock file maintenance minor/patch updates (@renovate[bot], @lukastaegert) +- [#5520](https://github.com/rollup/rollup/pull/5520): Resolve import.meta.{filename,dirname} in files imported from config (@BPScott) +- [#5521](https://github.com/rollup/rollup/pull/5521): docs: correct base32 to base36 in documentation (@highcastlee) -## 0.40.0 +## 4.17.2 -* [BREAKING] Better, more consistent error logging ([#1212](https://github.com/rollup/rollup/pull/1212)) -* Don't use colours and emojis for non-TTY stderr ([#1201](https://github.com/rollup/rollup/issues/1201)) +_2024-04-30_ -## 0.39.2 +### Bug Fixes -* Prevent mutation of cached ASTs (fixes stack overflow with rollup-watch) ([#1205](https://github.com/rollup/rollup/pull/1205)) +- Fix tree-shaking problems when using spread arguments (#5503) -## 0.39.1 +### Pull Requests -* Ignore `var` initialisers in dead branches ([#1198](https://github.com/rollup/rollup/issues/1198)) +- [#5501](https://github.com/rollup/rollup/pull/5501): Slightly improve perf report (@lukastaegert) +- [#5503](https://github.com/rollup/rollup/pull/5503): fix: rest element should deoptimize parameter values (@liuly0322) -## 0.39.0 +## 4.17.1 -* [BREAKING] Warnings are objects, rather than strings ([#1194](https://github.com/rollup/rollup/issues/1194)) +_2024-04-29_ -## 0.38.3 +### Bug Fixes -* More informative warning for implicit external dependencies ([#1051](https://github.com/rollup/rollup/issues/1051)) -* Warn when creating browser bundle with external dependencies on Node built-ins ([#1051](https://github.com/rollup/rollup/issues/1051)) -* Statically analyse LogicalExpression nodes, for better dead code removal ([#1061](https://github.com/rollup/rollup/issues/1061)) +- Prevent infinite recursions for certain constructor invocations (#5500) -## 0.38.2 +### Pull Requests -* Preserve `var` declarations in dead branches ([#997](https://github.com/rollup/rollup/issues/997)) -* Warn if exporting a call expression that looks like a function declaration ([#1011](https://github.com/rollup/rollup/issues/1011)) -* Wrap function expressions in parentheses if necessary ([#1011](https://github.com/rollup/rollup/issues/1011)) +- [#5500](https://github.com/rollup/rollup/pull/5500): fix: parameter variable infinite recursion error (@liuly0322) -## 0.38.1 +## 4.17.0 -* Fix sourcemap comment removal ([#1104](https://github.com/rollup/rollup/issues/1104)) -* Warn if empty bundle is generated ([#444](https://github.com/rollup/rollup/issues/444)) -* Support ES2017 syntax ([#492](https://github.com/rollup/rollup/issues/492)) -* Remove unused imports from external modules ([#595](https://github.com/rollup/rollup/issues/595)) -* Remove unused function and class declarations inside function bodies ([#1108](https://github.com/rollup/rollup/issues/1108), [#1178](https://github.com/rollup/rollup/issues/1178)) -* Deconflict function expression IDs ([#1176](https://github.com/rollup/rollup/issues/1176)) +_2024-04-27_ -## 0.38.0 +### Features -* [BREAKING] `export { foo as default }` creates live binding ([#1078](https://github.com/rollup/rollup/issues/1078)) -* Prevent sourceMappingURL removal edge case ([#988](https://github.com/rollup/rollup/issues/988)) -* Bind function expression IDs to the correct scope ([#1083](https://github.com/rollup/rollup/issues/1083)) -* Correctly deshadow destructured parameters with assignments ([#1008](https://github.com/rollup/rollup/issues/1008)) +- Track function call arguments to optimize functions only called once or with the same literal values (re-release from 4.16.0) (#5483) -## 0.37.2 +### Bug Fixes -* Remove unused `new` expressions without side-effects ([#179](https://github.com/rollup/rollup/issues/179)) -* Only remove valid sourceMappingURL comments ([#1132](https://github.com/rollup/rollup/issues/1132)) -* Ensure blocks containing activated `var` declarations are included in output ([#1113](https://github.com/rollup/rollup/issues/1113)) -* Support plugin outros ([#1116](https://github.com/rollup/rollup/issues/1116)) +- Reduce browser WASM size to a fraction by changing optimization settings (#5494) -## 0.37.1 +### Pull Requests -* Follow symlinks ([#447](https://github.com/rollup/rollup/issues/447)) -* Fix tree-shaking of recursive functions and other cases ([#1120](https://github.com/rollup/rollup/issues/1120), [#1142](https://github.com/rollup/rollup/issues/1142)) -* Support module names that require quotes ([#582](https://github.com/rollup/rollup/issues/582), [#584](https://github.com/rollup/rollup/issues/584)) -* Fix [#957](https://github.com/rollup/rollup/issues/957) +- [#5483](https://github.com/rollup/rollup/pull/5483): feature(fix): function parameter tracking (@liuly0322) +- [#5488](https://github.com/rollup/rollup/pull/5488): Report performance in CI (@TrickyPi) +- [#5489](https://github.com/rollup/rollup/pull/5489): Create FUNDING.json (@BenJam) +- [#5492](https://github.com/rollup/rollup/pull/5492): chore(deps): lock file maintenance minor/patch updates (@renovate[bot]) +- [#5493](https://github.com/rollup/rollup/pull/5493): chore(deps): lock file maintenance minor/patch updates (@renovate[bot]) +- [#5494](https://github.com/rollup/rollup/pull/5494): Use opt-level=z for browser wasm (@sapphi-red) -## 0.37.0 +## 4.16.4 -* [BREAKING] Default exports are not included in reified namespaces ([#1028](https://github.com/rollup/rollup/issues/1028)) -* Parentheses do not defeat tree-shaking ([#1101](https://github.com/rollup/rollup/issues/1101), [#1128](https://github.com/rollup/rollup/issues/1128)) -* More `legacy` fixes: do not create getters ([#1069](https://github.com/rollup/rollup/pull/1069)), do not include `__esModule` ([#1068](https://github.com/rollup/rollup/pull/1068)), quote reserved property names ([#1057](https://github.com/rollup/rollup/pull/1057)) -* Fix missing namespace member warnings ([#1045](https://github.com/rollup/rollup/issues/1045)) -* Fix TypeError in arrow function without braces returning a function ([#1062](https://github.com/rollup/rollup/pull/1062)) +_2024-04-23_ -## 0.36.4 +### Bug Fixes -* Only depend on program-level call expressions ([#977](https://github.com/rollup/rollup/issues/977)) +- Revert function parameter tracking logic introduced in 4.16.0 to work on some remaining issues (#5487) -## 0.36.3 +### Pull Requests -* Add `legacy` option for IE8 support ([#989](https://github.com/rollup/rollup/pull/989)) +- [#5487](https://github.com/rollup/rollup/pull/5487): Revert function parameter tracking logic for now (@lukastaegert) -## 0.36.2 +## 4.16.3 -* Insert semicolons where necessary to fix broken code ([#1004](https://github.com/rollup/rollup/issues/1004)) -* Include module ID and location when warning about top-level `this` ([#1012](https://github.com/rollup/rollup/pull/1012)) -* More informative error for missing exports ([#1033](https://github.com/rollup/rollup/issues/1033)) -* `options.moduleContext` for per-module context overrides ([#1023](https://github.com/rollup/rollup/pull/1023)) +_2024-04-23_ -## 0.36.1 +### Bug Fixes -* Include naked block statements ([#981](https://github.com/rollup/rollup/issues/981)) -* Correctly include falsy alternate statements in optimised if blocks ([#973](https://github.com/rollup/rollup/issues/973)) -* Prevent omission of default exports that are only used by the exporting module ([#967](https://github.com/rollup/rollup/pull/967)) -* Prevent warning on `auto` exports with ES output ([#966](https://github.com/rollup/rollup/pull/966)) +- Do not optimize IIFEs that have a name and are again referenced inside their definition (#5486) -## 0.36.0 +### Pull Requests -* `export { foo as default }` no longer creates a live binding ([#860](https://github.com/rollup/rollup/issues/860)) +- [#5486](https://github.com/rollup/rollup/pull/5486): fix: only optimize annoymous iife (@liuly0322) -## 0.35.15 +## 4.16.2 -* Warn on missing unused imports in deshadowing phase ([#928](https://github.com/rollup/rollup/issues/928)) -* Always add a newline to the end of bundles ([#958](https://github.com/rollup/rollup/issues/958)) +_2024-04-22_ -## 0.35.14 +### Bug Fixes -* Include all parent statements of expression with effects, up to function boundary ([#930](https://github.com/rollup/rollup/issues/930)) +- Resolve a situation condition where reassignments of function parameters were not tracked properly (#5482) +- Make sure that for armv7 packages, only one package is downloaded for the user (musl or gnu) (#5479) -## 0.35.13 +### Pull Requests -* Include superclasses when including their subclasses ([#932](https://github.com/rollup/rollup/issues/932)) +- [#5479](https://github.com/rollup/rollup/pull/5479): Add libc field to armv7 packages (@sapphi-red) +- [#5482](https://github.com/rollup/rollup/pull/5482): fix: function parameter reassigned update (@liuly0322) -## 0.35.12 +## 4.16.1 -* Add `interop: false` option to disable unwrapping of external imports ([#939](https://github.com/rollup/rollup/issues/939)) +_2024-04-21_ -## 0.35.11 +### Bug Fixes -* Deconflict reified namespaces with other declarations ([#910](https://github.com/rollup/rollup/issues/910)) +- Fix crash when rendering logical or conditional expressions (#5481) -## 0.35.10 +### Pull Requests -* Only remove EmptyStatement nodes directly inside blocks ([#913](https://github.com/rollup/rollup/issues/931)) +- [#5481](https://github.com/rollup/rollup/pull/5481): fix: conditional/logical expression should request a new tree-shaking (@liuly0322) -## 0.35.9 +## 4.16.0 -* Support Node 0.12 ([#909](https://github.com/rollup/rollup/issues/909)) +_2024-04-21_ -## 0.35.8 +### Features -* Correctly deshadow re-assigned module functions ([#910](https://github.com/rollup/rollup/issues/910)) +- Track function call arguments to optimize functions only called once or with the same literal values (#5443) -## 0.35.7 +### Pull Requests -* Refactor `flushTime.js` ([#922](https://github.com/rollup/rollup/pull/922)) +- [#5443](https://github.com/rollup/rollup/pull/5443): feat: improve tree-shaking by propagate const parameter (@liuly0322, @lukastaegert) -## 0.35.6 +## 4.15.0 -* Fix browser build +_2024-04-20_ -## 0.35.5 +### Features -* Allow empty for loop heads ([#919](https://github.com/rollup/rollup/issues/919)) +- Add output.importAttributesKey option to select whether to use "with" or "assert" for import attributes (#5474) -## 0.35.4 +### Pull Requests -* Preserve effects in for-of and for-in loops ([#870](https://github.com/rollup/rollup/issues/870)) -* Remove empty statements ([#918](https://github.com/rollup/rollup/pull/918)) +- [#5474](https://github.com/rollup/rollup/pull/5474): Add ImportAttributesKey to choose keyword ("with" | "assert") (@doubleaa93, @lukastaegert) +- [#5475](https://github.com/rollup/rollup/pull/5475): chore(deps): lock file maintenance minor/patch updates (@renovate[bot]) +- [#5477](https://github.com/rollup/rollup/pull/5477): Try to run emulated smoke tests for Linux environments (@lukastaegert) -## 0.35.3 +## 4.14.3 -* Render identifiers inside template literals +_2024-04-15_ -## 0.35.2 +### Bug Fixes -* Fix broken build caused by out of date locally installed dependencies +- Support Alpine Linux and other MUSL builds on ARM (#5471) -## 0.35.1 +### Pull Requests -* Rewrite deconflicted class identifiers ([#915](https://github.com/rollup/rollup/pull/915)) -* Include `dependencies` in `bundle.modules` objects ([#903](https://github.com/rollup/rollup/issues/903)) -* Update to Acorn 4 ([#914](https://github.com/rollup/rollup/pull/914)) +- [#5471](https://github.com/rollup/rollup/pull/5471): Add linux arm musl build (@sapphi-red) -## 0.35.0 +## 4.14.2 -* Rewrite analysis/tree-shaking code ([#902](https://github.com/rollup/rollup/pull/902)) -* Include conditional mutations of global objects ([#901](https://github.com/rollup/rollup/issues/901)) -* Only reify namespaces if necessary ([#898](https://github.com/rollup/rollup/issues/898)) -* Track mutations of aliased globals ([#893](https://github.com/rollup/rollup/issues/893)) -* Include duplicated var declarations ([#716](https://github.com/rollup/rollup/issues/716)) +_2024-04-12_ -## 0.34.13 +### Bug Fixes -* Pass `{ format }` through to `transformBundle` ([#867](https://github.com/rollup/rollup/issues/867)) +- Do not create invalid code when reexporting both a namespace and the default export from that namespace (#5466) +- Ensure ppc64 platform is properly detected (#5460) -## 0.34.12 +### Pull Requests -* Fix `rollup --watch` ([#887](https://github.com/rollup/rollup/issues/887)) -* Case-sensitive paths ([#862](https://github.com/rollup/rollup/issues/862)) +- [#5456](https://github.com/rollup/rollup/pull/5456): Add high-level architecture documentation (@lukastaegert) +- [#5460](https://github.com/rollup/rollup/pull/5460): Fix ppc64le target (@lukastaegert) +- [#5463](https://github.com/rollup/rollup/pull/5463): chore: tweak the comment about files should not be edited (@TrickyPi) +- [#5466](https://github.com/rollup/rollup/pull/5466): Ensure reexported namespaces do not prevent creation of default export helpers (@lukastaegert) +- [#5468](https://github.com/rollup/rollup/pull/5468): chore(deps): update dependency eslint-plugin-unicorn to v52 (@renovate[bot], @lukastaegert) +- [#5469](https://github.com/rollup/rollup/pull/5469): chore(deps): lock file maintenance minor/patch updates (@renovate[bot]) +- [#5470](https://github.com/rollup/rollup/pull/5470): chore(deps): lock file maintenance (@renovate[bot]) -## 0.34.11 +## 4.14.1 -* Prevent leaky state when `bundle` is reused ([#875](https://github.com/rollup/rollup/issues/875)) -* Ensure `intro` appears before interop block ([#880](https://github.com/rollup/rollup/issues/880)) +_2024-04-07_ -## 0.34.10 +### Bug Fixes -* Allow custom `options.context` to replace top-level `this` ([#851](https://github.com/rollup/rollup/issues/851)) -* Fix `noConflict` when used via `rollup --config` ([#846](https://github.com/rollup/rollup/issues/846)) -* Place `outro` block *after* export block ([#852](https://github.com/rollup/rollup/issues/852)) +- Show better error when running on musl Linux where the musl build is not supported (#5454) -## 0.34.9 +### Pull Requests -* Disable indentation by default, for faster bundle generation ([#812](https://github.com/rollup/rollup/pull/812)) -* More helpful error on missing entry file ([#802](https://github.com/rollup/rollup/issues/802)) -* Preserve comments before import declarations ([#815](https://github.com/rollup/rollup/pull/815)) +- [#5451](https://github.com/rollup/rollup/pull/5451): chore: generate string constants from config (@TrickyPi) +- [#5452](https://github.com/rollup/rollup/pull/5452): chore(deps): lock file maintenance minor/patch updates (@renovate[bot]) +- [#5453](https://github.com/rollup/rollup/pull/5453): chore(deps): lock file maintenance (@renovate[bot]) +- [#5454](https://github.com/rollup/rollup/pull/5454): Improve error message when running on unsupported MUSL Linux (@lukastaegert) +- [#5455](https://github.com/rollup/rollup/pull/5455): Remove inlining logic in AST (de-)serializer (@lukastaegert) -## 0.34.8 +## 4.14.0 -* Wrap UMD factory function in parens to avoid lazy parsing ([#774](https://github.com/rollup/rollup/pull/774)) +_2024-04-03_ -## 0.34.7 +### Features -* Leave it up to resolveId to normalize the entry path ([#835](https://github.com/rollup/rollup/pull/835)) -* Cache decoded mappings ([#834](https://github.com/rollup/rollup/pull/834)) +- Display error causes in Rollup CLI (#5422) +- Add basic support for explicit resource management via "using" and "await using" (#5423) -## 0.34.5 +### Pull Requests -* Fix circular export ([#813](https://github.com/rollup/rollup/issues/813)) +- [#5422](https://github.com/rollup/rollup/pull/5422): feat: show all cause in Error (@devohda, @lukastaegert) +- [#5444](https://github.com/rollup/rollup/pull/5444): feat: support explicit-resource-management (@TrickyPi) +- [#5445](https://github.com/rollup/rollup/pull/5445): docs: add `@shikiji/vitepress-twoslash` (@sapphi-red) +- [#5447](https://github.com/rollup/rollup/pull/5447): chore(deps): lock file maintenance minor/patch updates ( @renovate[bot]) +- [#5448](https://github.com/rollup/rollup/pull/5448): chore(deps): lock file maintenance (@renovate[bot]) -## 0.34.4 +## 4.13.2 -* Module render performance tweak ([#823](https://github.com/rollup/rollup/pull/823)) +_2024-03-28_ -## 0.34.3 +### Bug Fixes -* Avoid infinite recursion in `Bundle.sort()` ([#800](https://github.com/rollup/rollup/pull/800)) +- Ensure accessing module info is cached after the build phase for improved performance (#5438) +- Support powerpc64le CPUs (#5350) -## 0.34.2 +### Pull Requests -* resolveId calls are cached now to improve incremental build -* Fixed error message recursion in plugins +- [#5350](https://github.com/rollup/rollup/pull/5350): Add support for ppc64le (@pavolloffay, @lukastaegert) +- [#5438](https://github.com/rollup/rollup/pull/5438): Cache module info getters before output generation (@bluwy, @lukastaegert) -## 0.34.1 +## 4.13.1 -* Support `paths` config ([#754](https://github.com/rollup/rollup/issues/754)) -* Allow `export *` from external module, internally +_2024-03-27_ -## 0.34.0 +### Bug Fixes -* Use resolved IDs for relative imports that are also external modules, to allow `options.globals` to work with them ([#763](https://github.com/rollup/rollup/issues/763)) -* Ensure reassigned exports are declared in an ES bundle, and remove empty `exports.foo;` statements ([#755](https://github.com/rollup/rollup/issues/755)) -* Add newline after sourcemap comment ([#756](https://github.com/rollup/rollup/issues/756)) +- Add new linux-s390x-gnu native binary package (#5346) -## 0.33.2 +### Pull Requests -* Add `bundle` as second argument to `ongenerate` and `onwrite` hooks ([#773](https://github.com/rollup/rollup/pull/773)) -* Warn on top-level `this` ([#770](https://github.com/rollup/rollup/issues/770)) +- [#5346](https://github.com/rollup/rollup/pull/5346): Add support for linux s390x gnu (@edlerd) +- [#5430](https://github.com/rollup/rollup/pull/5430): chore(deps): update dependency @vue/eslint-config-typescript to v13 (@renovate[bot], @lukastaegert) +- [#5431](https://github.com/rollup/rollup/pull/5431): chore(deps): lock file maintenance minor/patch updates ( @renovate[bot]) +- [#5432](https://github.com/rollup/rollup/pull/5432): chore(deps): lock file maintenance minor/patch updates ( @renovate[bot]) +- [#5436](https://github.com/rollup/rollup/pull/5436): chore(deps): lock file maintenance minor/patch updates ( @renovate[bot]) +- [#5437](https://github.com/rollup/rollup/pull/5437): chore(deps): lock file maintenance minor/patch updates ( @renovate[bot]) -## 0.33.1 +## 4.13.0 -* Fix `--no-strict` option ([#751](https://github.com/rollup/rollup/pull/751)) -* Fix Windows edge case with case-sensitive paths ([#760](https://github.com/rollup/rollup/pull/760)) +_2024-03-12_ -## 0.33.0 +### Features -* Downgrade missing transformer sourcemap to a warning, not an error, and print the name of the offending plugin if possible ([#746](https://github.com/rollup/rollup/issues/746)) -* Warn if same name is re-exported from two modules ([#722](https://github.com/rollup/rollup/issues/722)) +- Ensure that the location of parse errors and other logs is encoded in the error message as well (#5424) -## 0.32.4 +### Pull Requests -* Add `ongenerate` and `onwrite` plugin hooks ([#742](https://github.com/rollup/rollup/pull/742)) +- [#5417](https://github.com/rollup/rollup/pull/5417): chore(deps): lock file maintenance minor/patch updates ( @renovate[bot]) +- [#5418](https://github.com/rollup/rollup/pull/5418): chore(deps): lock file maintenance (@renovate[bot]) +- [#5419](https://github.com/rollup/rollup/pull/5419): chore: fix typo (@OnlyWick) +- [#5424](https://github.com/rollup/rollup/pull/5424): Add locations to logs, warnings and error messages ( @lukastaegert) -## 0.32.3 +## 4.12.1 -* Generated correct sourcemaps with reified namespaces ([#668](https://github.com/rollup/rollup/issues/668)) -* Exclude plugin helper modules from sourcemaps ([#747](https://github.com/rollup/rollup/pull/747)) +_2024-03-06_ -## 0.32.2 +### Bug Fixes -* Allow `--globals` to work with `--external` or `options.external` in whatever configuration ([#743](https://github.com/rollup/rollup/issues/743)) +- Escape special characters in file references (#5404) -## 0.32.1 +### Pull Requests -* Preserve side-effects to default exports that coincide with used named exports ([#733](https://github.com/rollup/rollup/issues/733)) -* Support `rollup -c node:pkgname` ([#736](https://github.com/rollup/rollup/issues/736)) +- [#5398](https://github.com/rollup/rollup/pull/5398): Rename `getRollupEror` to `getRollupError` (@MrRefactoring) +- [#5399](https://github.com/rollup/rollup/pull/5399): chore(deps): lock file maintenance minor/patch updates ( @renovate[bot]) +- [#5404](https://github.com/rollup/rollup/pull/5404): fix: escape ids in `import.meta.ROLLUP_FILE_URL_referenceId` correctly (@sapphi-red) +- [#5406](https://github.com/rollup/rollup/pull/5406): chore(deps): lock file maintenance minor/patch updates ( @renovate[bot]) +- [#5407](https://github.com/rollup/rollup/pull/5407): chore(deps): lock file maintenance (@renovate[bot]) +- [#5411](https://github.com/rollup/rollup/pull/5411): Chunk assignment - Fix comment line breaks and typo (@yoavweiss, @lukastaegert) -## 0.32.0 +## 4.12.0 -* Deprecate `es6` format in favour of `es` ([#468](https://github.com/rollup/rollup/issues/468)) -* Add correct `jsnext:main` build ([#726](https://github.com/rollup/rollup/pull/726)) +_2024-02-16_ -## 0.31.2 +### Features -* Allow `load` plugins to provide sourcemap ([#715](https://github.com/rollup/rollup/pull/715)) -* Allow `sourceMapFile` in config options ([#717](https://github.com/rollup/rollup/issues/717)) +- Improve raw bundling performance by 10-15% when not using the cache or plugins that return an AST (#5391) -## 0.31.1 +### Pull Requests -* Logging for errors emitted by `rollup-watch` ([#712](https://github.com/rollup/rollup/issues/712)) +- [#5391](https://github.com/rollup/rollup/pull/5391): Improve performance by directly constructing AST from buffer ( @lukastaegert) +- [#5393](https://github.com/rollup/rollup/pull/5393): chore(deps): update dependency eslint-plugin-unicorn to v51 ( @renovate[bot]) +- [#5394](https://github.com/rollup/rollup/pull/5394): chore(deps): update typescript-eslint monorepo to v7 (major) ( @renovate[bot]) +- [#5395](https://github.com/rollup/rollup/pull/5395): chore(deps): lock file maintenance minor/patch updates ( @renovate[bot]) -## 0.31.0 +## 4.11.0 -* Rewrite top-level `this` as `undefined` ([#707](https://github.com/rollup/rollup/pull/707)) -* Pass `options.acorn` to Acorn ([#564](https://github.com/rollup/rollup/issues/564)) +_2024-02-15_ -## 0.30.0 +### Features -* Bundle CLI ([#700](https://github.com/rollup/rollup/issues/700)) -* Ensure absolute paths are normalised ([#704](https://github.com/rollup/rollup/issues/704)) -* Allow `rollup --watch` to work with targets +- Add `output.reexportProtoFromExternal` option to disable special code for handling `__proto__` reexports (#5380) -## 0.29.1 +### Bug Fixes -* Merge `target` options with main options ([#701](https://github.com/rollup/rollup/issues/701)) -* Update magic-string ([#690](https://github.com/rollup/rollup/issues/690)) +- Ensure namespace reexport code can be parsed by cjs-module-lexer (#5380) +- Throw when trying to reassing `const` variables (#5388) -## 0.29.0 +### Pull Requests -* `rollup --watch` ([#284](https://github.com/rollup/rollup/issues/284)) +- [#5380](https://github.com/rollup/rollup/pull/5380): fix: separately export `__proto__` for compatibility with CJS Transpiler Re-exports (@TrickyPi) +- [#5388](https://github.com/rollup/rollup/pull/5388): Add const reassign rule (@TrickyPi) -## 0.28.0 +## 4.10.0 -* Experimental support for incremental rebuilds ([#658](https://github.com/rollup/rollup/pull/658)) +_2024-02-10_ -## 0.27.1 +### Features -* Ensure names exported from a module are not replaced with reserved words ([#696](https://github.com/rollup/rollup/pull/696)) -* Revert ([#692](https://github.com/rollup/rollup/pull/692)) – resolved IDs must be strings +- Support base-36 and base-16 hashes again via new `output.hashCharacters` option (#5371) -## 0.27.0 +### Bug Fixes -* Use native promises instead of `es6-promise` ([#689](https://github.com/rollup/rollup/issues/689)) -* Support multiple targets in config files ([#655](https://github.com/rollup/rollup/issues/655)) -* Allow `resolveId` plugin functions to return non-strings ([#692](https://github.com/rollup/rollup/pull/692)) +- Do not crash process for panics in native code but throw them as JavaScript errors (#5383) -## 0.26.7 +### Pull Requests -* Distinguish between default and namespace imports of external module ([#637](https://github.com/rollup/rollup/issues/637)) -* Add `__esModule` property to named exports in AMD, CJS and UMD modes ([#650](https://github.com/rollup/rollup/issues/650)) +- [#5359](https://github.com/rollup/rollup/pull/5359): chore(deps): update actions/cache action to v4 (@renovate[bot]) +- [#5360](https://github.com/rollup/rollup/pull/5360): chore(deps): update dependency pretty-ms to v9 (@renovate[bot]) +- [#5366](https://github.com/rollup/rollup/pull/5366): chore(deps): update dependency husky to v9 (@renovate[bot]) +- [#5367](https://github.com/rollup/rollup/pull/5367): chore(deps): update peter-evans/create-or-update-comment action to v4 (@renovate[bot]) +- [#5368](https://github.com/rollup/rollup/pull/5368): chore(deps): update peter-evans/find-comment action to v3 ( @renovate[bot]) +- [#5369](https://github.com/rollup/rollup/pull/5369): chore(deps): lock file maintenance minor/patch updates ( @renovate[bot]) +- [#5370](https://github.com/rollup/rollup/pull/5370): Fix dependency range for Node types (@lukastaegert) +- [#5371](https://github.com/rollup/rollup/pull/5371): Implement "output.hashCharacters" option to define character set for file hashes (@lukastaegert) +- [#5372](https://github.com/rollup/rollup/pull/5372): Roll back vitepress as 1.0.0-rc.40 breaks the development build ( @lukastaegert) +- [#5382](https://github.com/rollup/rollup/pull/5382): Update documentation (@TrickyPi) +- [#5383](https://github.com/rollup/rollup/pull/5383): Catch Rust panics and then throw them in JS (@TrickyPi) +- [#5384](https://github.com/rollup/rollup/pull/5384): chore(deps): update codecov/codecov-action action to v4 ( @renovate[bot]) +- [#5385](https://github.com/rollup/rollup/pull/5385): chore(deps): lock file maintenance minor/patch updates ( @renovate[bot]) +- [#5386](https://github.com/rollup/rollup/pull/5386): Resolve all rollup imports to node_modules to avoid type conflict (@TrickyPi) -## 0.26.6 +## 4.9.6 -* Deconflict named imports from external modules in ES bundles ([#659](https://github.com/rollup/rollup/issues/659)) -* Support `options.preferConst` to generate `const` declarations for exports rather than `var` declarations ([#653](https://github.com/rollup/rollup/issues/653)) +_2024-01-21_ -## 0.26.5 +### Bug Fixes -* Preserve `debugger` statements ([#664](https://github.com/rollup/rollup/issues/664)) -* Allow `options.external` to be a function ([#522](https://github.com/rollup/rollup/issues/522)) +- Detect side effects when an element that was pushed into an array is modified via the array (#5352) -## 0.26.4 +### Pull Requests -* Prevent plugin-provided external IDs being normalised ([#630](https://github.com/rollup/rollup/issues/630), [#633](https://github.com/rollup/rollup/issues/633)) -* Throw if module exports/re-exports the same name twice, or has multiple default exports ([#679](https://github.com/rollup/rollup/issues/679)) -* Warn about `eval` security issue ([#675]((https://github.com/rollup/rollup/issues/675))) +- [#5337](https://github.com/rollup/rollup/pull/5337): Generate AST transformers from config (@lukastaegert) +- [#5340](https://github.com/rollup/rollup/pull/5340): Also type-check d.ts files (@lukastaegert) +- [#5348](https://github.com/rollup/rollup/pull/5348): chore(deps): lock file maintenance minor/patch updates ( @renovate[bot]) +- [#5351](https://github.com/rollup/rollup/pull/5351): chore(deps): update dependency vite to v5.0.12 [security] ( @renovate[bot]) +- [#5352](https://github.com/rollup/rollup/pull/5352): Track mutations of elements pushed into arrays (@lukastaegert) +## 4.9.5 -## 0.26.3 +_2024-01-12_ -* Ensure reference is not incorrectly marked as a reassignment ([#648](https://github.com/rollup/rollup/issues/648)) +### Bug Fixes -## 0.26.2 +- Fix issue where on Windows, Rollup would not load due to problems with the MSVC executable (#5335) -* Sanity check output of `load` hook ([#607](https://github.com/rollup/rollup/issues/607)) -* Correct scoping for ID class expressions ([#626](https://github.com/rollup/rollup/issues/626)) -* Warn if named and default exports are used together in auto mode ([#587](https://github.com/rollup/rollup/issues/587)) -* Allow variable initialisers to be rewritten if necessary ([#632](https://github.com/rollup/rollup/issues/632)) -* Prevent double `var` with no-treeshake option ([#639](https://github.com/rollup/rollup/pull/639)) +### Pull Requests -## 0.26.1 +- [#5334](https://github.com/rollup/rollup/pull/5334): Fix typo in commondir.ts (@akiomik) +- [#5335](https://github.com/rollup/rollup/pull/5335): build: static link msvc runtime on Windows x64 platform ( @Brooooooklyn) +- [#5338](https://github.com/rollup/rollup/pull/5338): chore(deps): lock file maintenance minor/patch updates ( @renovate[bot]) -* Add `treeshake: false`/`--no-treeshake` option for debugging ([#505](https://github.com/rollup/rollup/issues/505)) -* Update build process to use Bublé ([#620](https://github.com/rollup/rollup/pull/620)) +## 4.9.4 -## 0.26.0 +_2024-01-06_ -* Add `noConflict`/`--no-conflict` option for UMD builds ([#580](https://github.com/rollup/rollup/pull/580)) -* Normalise relative external paths ([#591](https://github.com/rollup/rollup/pull/591)) -* Report files causing transform errors ([#609](https://github.com/rollup/rollup/pull/609)) -* Handle sourcemap segments with a single member ([#619](https://github.com/rollup/rollup/pull/619)) -* Update dependencies +### Bug Fixes -## 0.25.8 +- Use quotes for keys in namespaces that are only numbers but are not valid integers (#5328) +- Allow to have comments between pure annotations and the annoted node (#5332) -* Unixize entry path ([#586](https://github.com/rollup/rollup/pull/586)) +### Pull Requests -## 0.25.7 +- [#5328](https://github.com/rollup/rollup/pull/5328): Correctly handling number key (@LongTengDao) +- [#5332](https://github.com/rollup/rollup/pull/5332): Handle pure annotations that are separated by a comment ( @lukastaegert) -* Expand deshadowed shorthand properties ([#575](https://github.com/rollup/rollup/issues/575)) -* Allow external files to be non-existent ([#532](https://github.com/rollup/rollup/issues/532)) +## 4.9.3 -## 0.25.6 +_2024-01-05_ -* Fix a regression introduced by #566 ([#569](https://github.com/rollup/rollup/issues/569)) -* Prune dead conditional expressions more carefully ([#567](https://github.com/rollup/rollup/issues/567)) +### Bug Fixes -## 0.25.5 +- Support `__proto__` as export/import name (#5313) +- Use ESTree AST type over custom type in user-facing types (#5323) -* Make sure shorthand destructuring assignments don't break ([#528](https://github.com/rollup/rollup/issues/528)) -* Allow 'exports' key ([#542](https://github.com/rollup/rollup/issues/542)) -* Ensure `foo. bar` where `foo` is a namespace import is rewritten correctly ([#566](https://github.com/rollup/rollup/issues/566)) -* Fix an edge case for exported globals (e.g. `export { document }`) ([#562](https://github.com/rollup/rollup/issues/562)) +### Pull Requests -## 0.25.4 +- [#5313](https://github.com/rollup/rollup/pull/5313): Correctly handling **proto** export as module object key ( @LongTengDao) +- [#5323](https://github.com/rollup/rollup/pull/5323): fix: Add estree.Program type to rollup.d.ts (@TrickyPi) +- [#5326](https://github.com/rollup/rollup/pull/5326): docs: fix grammar (@gigabites19) +- [#5329](https://github.com/rollup/rollup/pull/5329): chore(deps): update dependency @vue/eslint-config-prettier to v9 (@renovate[bot]) +- [#5330](https://github.com/rollup/rollup/pull/5330): chore(deps): lock file maintenance minor/patch updates ( @renovate[bot]) -* Fix misnamed exports of default imports in ES bundles ([#513](https://github.com/rollup/rollup/issues/513)) -* CLI: warn on missing config ([#515](https://github.com/rollup/rollup/pull/515)) -* Detect side-effects in non-top-level member expression assignment ([#476](https://github.com/rollup/rollup/issues/476)) -* Don't remove computed property class keys ([#504](https://github.com/rollup/rollup/issues/504)) -* Augment existing global object rather than replacing ([#493](https://github.com/rollup/rollup/issues/493)) -* Don't fail on `export {}`, warn instead ([#486](https://github.com/rollup/rollup/issues/486)) +## 4.9.2 -## 0.25.3 +_2023-12-30_ -* Handle non-objects and `null` in `_interopDefault` ([#474](https://github.com/rollup/rollup/issues/474)) +### Bug Fixes -## 0.25.2 +- Extend support for arbitrary namespace identifiers in SystemJS (#5321) +- Do not wrongly flag functions without side effects as side effects if moduleSideEffects is false (#5322) -* Skip dead branches of a conditional expression (#[465](https://github.com/rollup/rollup/pull/465)) -* Allow globals to be exported ([#472](https://github.com/rollup/rollup/pull/472)) -* Ensure reassigned exports are exported ([#484](https://github.com/rollup/rollup/issues/484)) +### Pull Requests -## 0.25.1 +- [#5305](https://github.com/rollup/rollup/pull/5305): Add JSDoc types to internal scripts (@lukastaegert) +- [#5309](https://github.com/rollup/rollup/pull/5309): chore(deps): update actions/download-artifact action to v4 ( @renovate[bot]) +- [#5311](https://github.com/rollup/rollup/pull/5311): chode: add node badge (@btea) +- [#5312](https://github.com/rollup/rollup/pull/5312): Remove rollup-plugin-thatworks from devDeps (@TrickyPi) +- [#5318](https://github.com/rollup/rollup/pull/5318): chore(deps): update dependency eslint-plugin-unicorn to v50 ( @renovate[bot]) +- [#5319](https://github.com/rollup/rollup/pull/5319): chore(deps): lock file maintenance minor/patch updates ( @renovate[bot]) +- [#5321](https://github.com/rollup/rollup/pull/5321): Handle arbitrary namespace identifiers in some SystemJS scenarios (@lukastaegert) +- [#5322](https://github.com/rollup/rollup/pull/5322): Do not handle declarations in modules without side effects as TDZ (@lukastaegert) -* Throw error if namespace is called ([#446](https://github.com/rollup/rollup/issues/446)) -* Prevent shadowing bug in ES6 output ([#441](https://github.com/rollup/rollup/pull/441)) -* Prevent `var exports.foo` ([#426](https://github.com/rollup/rollup/issues/426)) -* Prevent double export of aliased symbols ([#438](https://github.com/rollup/rollup/issues/438)) -* Provide more informative error if Rollup is used in-browser without appropriate `resolveId`/`load` hooks ([#275](https://github.com/rollup/rollup/issues/275)) -* Use `_interopDefault` function to DRY out code with many external dependencies, in CommonJS output ([#458](https://github.com/rollup/rollup/pull/458)) +## 4.9.1 -## 0.25.0 +_2023-12-17_ -* **breaking** Module order is determined according to spec, rather than in a way designed to prevent runtime errors. Rollup will warn if it detects runtime errors are likely ([#435](https://github.com/rollup/rollup/issues/435)) -* Prevent overly aggressive tree-shaking with complex call expressions ([#440](https://github.com/rollup/rollup/issues/440)) +### Bug Fixes -## 0.24.1 +- Fix an issue where break statements could include the wrong label (#5297) -* Handle calls to default exports other that are not function expressions or references to function declarations ([#421](https://github.com/rollup/rollup/issues/421)) -* Ensure namespace blocks are created for chained imports ([#430](https://github.com/rollup/rollup/issues/430)) -* Include references in computed property keys ([#434](https://github.com/rollup/rollup/issues/434)) -* Use CLI `--external` option correctly ([#417](https://github.com/rollup/rollup/pull/417)) -* Allow relative imports to be treated as external, if absolute paths are provided in `options.external` ([#410](https://github.com/rollup/rollup/issues/410)) -* Make IIFE output adhere to Crockford style ([#415](https://github.com/rollup/rollup/pull/415)) +### Pull Requests -## 0.24.0 +- [#5297](https://github.com/rollup/rollup/pull/5297): fix: use a new includedLabels in the body of the LabeledStatement (@TrickyPi) +- [#5300](https://github.com/rollup/rollup/pull/5300): chore(deps): lock file maintenance minor/patch updates ( @renovate[bot]) -* No longer attempts to resolve IDs in `options.external` ([#407](https://github.com/rollup/rollup/issues/407)) -* Fix broken sourcemap resolution in cases where some modules are transformed and others aren't ([#404](https://github.com/rollup/rollup/issues/404)) +## 4.9.0 -## 0.23.2 +_2023-12-13_ -* Ensure `dest` or `sourceMapFile` is resolved against CWD for purposes of sourcemap generation ([#344](https://github.com/rollup/rollup/issues/344)) -* Support `banner`, `footer`, `intro` and `outro` options via CLI ([#330](https://github.com/rollup/rollup/issues/330)) -* Allow `options.global` to be a function rather than an object, and warn on missing names ([#293](https://github.com/rollup/rollup/issues/293)) -* Ensure side-effects are captured in cyclical call expressions ([#397](https://github.com/rollup/rollup/issues/397)) -* Fix parse error with body-less arrow function expressions ([#403](https://github.com/rollup/rollup/issues/403)) +### Features -## 0.23.1 +- Fully support arbitrary strings as import and export identifiers (#5298) -* Reinstate missing fix from ([#392](https://github.com/rollup/rollup/pull/392)) +### Pull Requests -## 0.23.0 +- [#5296](https://github.com/rollup/rollup/pull/5296): Do not assume setTimeout return type (@kapouer) +- [#5298](https://github.com/rollup/rollup/pull/5298): Fully support arbitrary module namespace identifiers for all formats (@lukastaegert) -* Add `bundleTransform` plugin hook and option ([#387](https://github.com/rollup/rollup/pull/387)) -* Correctly store names in sourcemaps, regardless of transformers -* Add `--environment` option to CLI ([#388](https://github.com/rollup/rollup/pull/388)) -* Handle destructuring in exports ([#374](https://github.com/rollup/rollup/issues/374)) -* Fix UMD global exports bug introduced in 0.22.1 ([#392](https://github.com/rollup/rollup/pull/392)) +## 4.8.0 -## 0.22.2 +_2023-12-11_ -* Prevent lost `var` keywords ([#390](https://github.com/rollup/rollup/issues/390)) +### Features -## 0.22.1 +- Improve `experimentalMinChunkSize` to take already loaded modules from dynamic imports into account (#5294) -* Update expected option keys ([#379](https://github.com/rollup/rollup/issues/379)) -* Handle transformers that return stringified sourcemaps ([#377](https://github.com/rollup/rollup/issues/377)) -* Automatically create missing namespaces if `moduleName` contains dots ([#378](https://github.com/rollup/rollup/issues/378)) -* Ignore external dependency warnings coming from config file ([#333](https://github.com/rollup/rollup/issues/333)) -* Update to latest magic-string for performance boost +### Pull Requests -## 0.22.0 +- [#5294](https://github.com/rollup/rollup/pull/5294): Find more merge targets for experimentalMinChunkSize ( @lukastaegert) -* Duplicate warnings are squelched ([#362](https://github.com/rollup/rollup/issues/362)) -* Plugins can manipulate or override the `options` object ([#371](https://github.com/rollup/rollup/pull/371)) +## 4.7.0 -## 0.21.3 +_2023-12-08_ -* Validate option keys ([#348](https://github.com/rollup/rollup/pull/348)) -* Allow namespaces imports to sit alongside named imports ([#355](https://github.com/rollup/rollup/issues/355)) -* Count references inside destructured objects ([#364](https://github.com/rollup/rollup/issues/364)) -* Preserve top-level `delete` statements ([#352](https://github.com/rollup/rollup/issues/352)) +### Features -## 0.21.2 +- Add build for Linux riscv64 architecture (#5288) -* Missing relative imports are an error, not a warning ([#321](https://github.com/rollup/rollup/issues/321)) -* Fixed incorrectly renamed default exports in ES6 bundles ([#339](https://github.com/rollup/rollup/issues/339)) -* Fixed infinite recursion bug ([#341](https://github.com/rollup/rollup/issues/341)) +### Bug Fixes -## 0.21.1 +- Improve error message when native Windows build does not start (#5284) -* Remove `aggressive: true` (was too aggressive) ([#309](https://github.com/rollup/rollup/pull/309)) -* Handle top-level block statements ([#326](https://github.com/rollup/rollup/issues/326)) -* Optimise namespaces with default exports ([#314](https://github.com/rollup/rollup/issues/314)) +### Pull Requests -## 0.21.0 +- [#5278](https://github.com/rollup/rollup/pull/5278): chore(deps): lock file maintenance minor/patch updates ( @renovate[bot]) +- [#5281](https://github.com/rollup/rollup/pull/5281): Add logs and experimentalLogSideEffects to REPL (@lukastaegert) +- [#5284](https://github.com/rollup/rollup/pull/5284): Add friendly error for missing MSVC redistributable (@sapphi-red) +- [#5285](https://github.com/rollup/rollup/pull/5285): chore(deps): update dependency vite to v5.0.5 [security] ( @renovate[bot]) +- [#5288](https://github.com/rollup/rollup/pull/5288): Add support for linux riscv64 gnu (@kxxt) +- [#5290](https://github.com/rollup/rollup/pull/5290): chore(deps): lock file maintenance minor/patch updates ( @renovate[bot]) -* Only include statements whose side-effects are relevant (i.e. contribute to exports or affect global state) ([#253](https://github.com/rollup/rollup/pull/253)) ([#253](https://github.com/rollup/rollup/pull/253)) -* Exclude dead branches from analysis and inclusion ([#249](https://github.com/rollup/rollup/pull/249)) -* Add `aggressive: true` option to eliminate all side-effects outside entry module -* More informative error when re-exporting non-existent binding ([#274](https://github.com/rollup/rollup/issues/274)) -* Fix infinite recursion bug ([#291](https://github.com/rollup/rollup/issues/291)) -* Log errors when using `rollup --config` ([#288](https://github.com/rollup/rollup/pull/288)) -* Return rejected promises on startup instead of throwing error, if options are invalid ([#303](https://github.com/rollup/rollup/pull/303)) +## 4.6.1 -## 0.20.5 +_2023-11-30_ -* Ensure re-exports don't create a local binding ([#270](https://github.com/rollup/rollup/pull/270)) +### Bug Fixes -## 0.20.4 +- Resolve a situation where declaring the same `var` several times was considered a conflict (#5276) -* Check file exists at resolve time, to allow filenames with non-extension dots in them ([#250](https://github.com/rollup/rollup/pull/250)) -* Import `Promise` where used, for Node 0.10 support ([#254](https://github.com/rollup/rollup/issues/254)) -* Allow asynchronous transformer plugins ([#260](https://github.com/rollup/rollup/issues/260)) -* Don't assume re-exported bindings are globals when deconflicting ([#267](https://github.com/rollup/rollup/issues/267)) +### Pull Requests +- [#5275](https://github.com/rollup/rollup/pull/5275): Add TNG as special sponsor (@lukastaegert) +- [#5276](https://github.com/rollup/rollup/pull/5276): Allow to redeclare parameters multiple times in nested scopes ( @lukastaegert) -## 0.20.3 +## 4.6.0 -* Fix bug where multiple `export *` declarations caused error ([#244](https://github.com/rollup/rollup/pulls/244)) -* Missing namespace exports are a warning, not an error ([#244](https://github.com/rollup/rollup/pulls/244)) -* Plugins can provide `banner` and `footer` options (string, or function that returns a string) ([#235](https://github.com/rollup/rollup/issues/235)) -* Warn on encountering `eval` ([#186](https://github.com/rollup/rollup/issues/186)) +_2023-11-26_ -## 0.20.2 +### Features -* Handle errors in build config file -* More robust deconflicting, in cases where e.g. `foo$1` already exists -* Use Rollup CLI for own build process +- Allow `this.addWatchFile` in all plugin hooks (#5270) -## 0.20.1 +### Bug Fixes -* Support `--config` file to enable plugins with CLI ([#226](https://github.com/rollup/rollup/pulls/226)) -* Prevent `default` being used as variable name ([#215](https://github.com/rollup/rollup/issues/215)) -* Update deps +- Show helpful error when native binaries are not installed due to an `npm` issue (#5267) +- Do not access `this` context in `this.addWatchFile` so it does not need to be bound when passed around (#5270) -## 0.20.0 +### Pull Requests -* Support for [plugins](https://github.com/rollup/rollup/wiki/Plugins) ([#207](https://github.com/rollup/rollup/pulls/207)) -* BREAKING – `options.transform`, `options.load`, `options.resolveId`, `options.resolveExternal` and `options.external` are no longer supported, and should be handled by plugins. [More info](https://github.com/rollup/rollup/wiki/Plugins) -* BREAKING – the .js extension is only added if it looks like there's no extension, allowing e.g. `import data from 'data.json'` (with the appropriate transformer). For safety, always include the file extension – import `./foo.js`, not `./foo` +- [#5267](https://github.com/rollup/rollup/pull/5267): Add friendly error for npm bug (@sapphi-red) +- [#5270](https://github.com/rollup/rollup/pull/5270): Allow this.addWatchFile in all hooks (@lukastaegert) +- [#5272](https://github.com/rollup/rollup/pull/5272): Debug deployed graphs (@lukastaegert) -## 0.19.2 +## 4.5.2 -* Fix exporting namespaces to include all of their exports ([#204](https://github.com/rollup/rollup/issues/204)) -* Namespace exotic objects are frozen to ensure that its properties cannot be modified, reconfigured, redefined or deleted ([#203](https://github.com/rollup/rollup/pulls/203)) -* Fix `ReferenceError: Promise is not defined` in node v0.10 ([#189](https://github.com/rollup/rollup/issues/189)) +_2023-11-24_ -## 0.19.1 +### Bug Fixes -* Fix `module.basename()` when used with custom `resolveId` function -* Use [rollup-babel](https://github.com/rollup/rollup-babel) to build self -* Exposed the version string through the API: `require( 'rollup' ).VERSION` +- Handle files with UTF-8 BOM when using the commonjs plugin (#5268) -## 0.19.0 +### Pull Requests -* **breaking** The `transform` option is no longer passed through to custom loaders. Loaders should only concern themselves with providing source code; transformation will *always* take place -* `options.transform` functions can return a string, or a `{code, map, ast}` object. Where possible, sourcemap chains will be flattened ([#175](https://github.com/rollup/rollup/pull/175)) -* `options.resolveId`, `options.resolveExternal` and `options.load` can each be a function or an array of functions. If an array, the first non-null/undefined return value is used. In both cases, failed resolution/loading will fall back to the defaults, unless an error is thrown. ([#174](https://github.com/rollup/rollup/pull/174)) -* New `intro` and `outro` options – similar to `banner` and `footer` except inserted *inside* any format-specific wrapper -* Multiple var declarations in an export block (e.g. `export let a = 1, b = 2`) are split up to facilitate tree-shaking ([#171](https://github.com/rollup/rollup/issues/171)) -* More informative error when using a missing namespace property ([#169](https://github.com/rollup/rollup/pull/169)) -* Update various dependencies +- [#5268](https://github.com/rollup/rollup/pull/5268): fix: strip BOM before calling transform hook (@TrickyPi) +- [#5269](https://github.com/rollup/rollup/pull/5269): chore(deps): lock file maintenance minor/patch updates ( @renovate[bot]) -## 0.18.5 +## 4.5.1 -* Allow namespaces to be assigned to variables ([#168](https://github.com/rollup/rollup/issues/168)) -* Promote `chalk` and `source-map-support` to `dependencies`, as they're used by the CLI ([#167](https://github.com/rollup/rollup/pull/167)) +_2023-11-21_ -## 0.18.4 +### Bug Fixes -* Make external modules configurable (i.e. `external.config.foo = 'bar'`) without erroring +- Do not error when a function expression uses the same name for a parameter and its id (#5262) -## 0.18.3 +### Pull Requests -* Crop indent exclusion ranges to exclude enclosing quotes ([#166](https://github.com/rollup/rollup/issues/166)) +- [#5257](https://github.com/rollup/rollup/pull/5257): Fix graphs in docs, improve REPL colors (@lukastaegert) +- [#5262](https://github.com/rollup/rollup/pull/5262): Allow function expression parameters to shadow the function id ( @lukastaegert) -## 0.18.2 +## 4.5.0 -* Include definitions of namespace members that are exported as defaults +_2023-11-18_ -## 0.18.1 +### Bug Fixes -* Include `acorn.parse` in bundle, remove `sander` from dependencies, simplify build +- Show a proper error when using native Rollup on armv7 musl Linux (#5255) -## 0.18.0 +### Pull Requests -* Internal rewrite -* Reinstate statically-analysable namespace imports -* Avoid using getters in namespace blocks where possible ([#144](https://github.com/rollup/rollup/issues/144)) -* Track variable aliases ([#96](https://github.com/rollup/rollup/issues/96)) -* Prevent multiline strings being indented ([#164](https://github.com/rollup/rollup/issues/164)) +- [#5251](https://github.com/rollup/rollup/pull/5251): doc fix import assertions to attributes in API plugin development page (@lhapaipai) +- [#5253](https://github.com/rollup/rollup/pull/5253): chore(deps): lock file maintenance minor/patch updates ( @renovate[bot]) +- [#5255](https://github.com/rollup/rollup/pull/5255): Error for armv7 musl build (@lukastaegert) -## 0.17.4 +## 4.4.1 -* Allow imports from hidden directories (replay of [#133](https://github.com/rollup/rollup/issues/133)) +_2023-11-14_ -## 0.17.3 +### Bug Fixes -* Handle parenthesised default exports ([#136](https://github.com/rollup/rollup/issues/136)) +- Do not flag duplicate function declarations in function scopes as syntax errors (#5248) -## 0.17.2 +### Pull Requests -* Allow use of scoped npm packages ([#131](https://github.com/rollup/rollup/issues/131)) +- [#5248](https://github.com/rollup/rollup/pull/5248): Allow functions to redeclare vars and functions in function scopes (@lukastaegert) -## 0.17.1 +## 4.4.0 -* Allow namespaces to be passed to a function ([#149](https://github.com/rollup/rollup/issues/149)) +_2023-11-12_ -## 0.17.0 +### Features -* Roll back to 0.15.0 and reapply subsequent fixes pending resolution of ([#132](https://github.com/rollup/rollup/issues/132)) and related issues +- Replace SWC linting with faster internal linting to error on duplicate declarations etc. (#5207) -## 0.16.4 +### Bug Fixes -* Fix import paths with `.` ([#133](https://github.com/rollup/rollup/issues/133)) -* Prevent sourceMappingURL confusion leading to broken sourcemap -* Add code coverage reporting [#130](https://github.com/rollup/rollup/pull/130)) -* Add `modules` property to user-facing `bundle` – an array with `{id}` objects ([#128](https://github.com/rollup/rollup/issues/128)) +- Show proper error when an entry exports non-existing bindings (#5207) -## 0.16.3 +### Pull Requests -* Prevent adjacent blocks of multiple var declarations causing magic-string failure ([#105](https://github.com/rollup/rollup/issues/105)) +- [#5207](https://github.com/rollup/rollup/pull/5207): perf: run lint while constructing nodes (@sapphi-red) -## 0.16.2 +## 4.3.1 -* Top-level function calls and assignments to globals are treated as side-effects, and always included -* Import files from subdirectories of external packages, e.g. `import mod from 'foo/sub/mod'` ([#126](https://github.com/rollup/rollup/issues/126)) +_2023-11-11_ -## 0.16.1 +### Bug Fixes -* Handle assignment patterns, and destructured/rest parameters, when analysing scopes -* Fix bug preventing project from self-building (make base `Identifier` class markable) +- Fix rename error when handling errors in watch mode (#5240) +- Prevent warning when using `--forceExit` (#5245) -## 0.16.0 +### Pull Requests -* Internal refactoring ([#99](https://github.com/rollup/rollup/pull/99)) -* Optimisation for statically-analysable namespace imports ([#99](https://github.com/rollup/rollup/pull/99)) -* Windows support (theoretically!) ([#117](https://github.com/rollup/rollup/pull/117) / [#119](https://github.com/rollup/rollup/pull/119)) +- [#5240](https://github.com/rollup/rollup/pull/5240): fix: allow the name of Rollup Error to be modified (@TrickyPi) +- [#5243](https://github.com/rollup/rollup/pull/5243): chore(deps): lock file maintenance minor/patch updates ( @renovate[bot]) +- [#5245](https://github.com/rollup/rollup/pull/5245): Ensure --forceExit works without warning (@lukastaegert) -## 0.15.0 +## 4.3.0 -* Load all modules specified by `import` statements, and do tree-shaking synchronously once loading is complete. This results in simpler and faster code, and enables future improvements ([#97](https://github.com/rollup/rollup/pull/97)) -* Only rewrite `foo` as `exports.foo` when it makes sense to ([#92](https://github.com/rollup/rollup/issues/92)) -* Fix bug with shadowed variables that are eventually exported ([#91](https://github.com/rollup/rollup/issues/91)) -* Exclude unused function declarations that happen to modify a used name ([#90](https://github.com/rollup/rollup/pull/90)) -* Simplify internal `Scope` model – scopes always attach to blocks, never function expressions/declarations +_2023-11-03_ -## 0.14.1 +### Features -* `export { name } from './other'` does not create a local binding ([#16](https://github.com/rollup/rollup/issues/16)) -* A single binding can be exported under multiple names ([#18](https://github.com/rollup/rollup/issues/18)) -* `useStrict` option exposed to CLI as `--strict`/`--no-strict` ([#81](https://github.com/rollup/rollup/issues/81)) -* Neater exports from ES6 bundles +- Add `forceExit` CLI flag for situations where the CLI does not exit gracefully (#5195) -## 0.14.0 +### Bug Fixes -* Internal refactoring -* Correctly deconflict generated default export names ([#72](https://github.com/rollup/rollup/issues/72)) -* Handle `export { x } from 'y'` declarations ([#74](https://github.com/rollup/rollup/issues/74)) -* Dedupe named imports from external modules in ES6 bundles ([#77](https://github.com/rollup/rollup/issues/77)) +- Properly catch errors when removing a temporary config file fails (#5198) -## 0.13.0 +### Pull Requests -* Support `banner` and `footer` options ([#66](https://github.com/rollup/rollup/pull/66)) -* Remove pre-existing sourcemap comments ([#66](https://github.com/rollup/rollup/pull/66)) -* Deconflict external imports ([#66](https://github.com/rollup/rollup/pull/66)) -* Use existing AST, if provided ([#66](https://github.com/rollup/rollup/pull/66)) -* Rename internal namespace exports as appropriate ([#66](https://github.com/rollup/rollup/pull/66)) -* Remove uninitialised var declarations that get exported ([#66](https://github.com/rollup/rollup/pull/66)) -* Rename variables named `exports` to avoid conflicts ([#66](https://github.com/rollup/rollup/pull/66)) +- [#5195](https://github.com/rollup/rollup/pull/5195): Add `forceExit` CLI flag (@raphael-theriault-swi) +- [#5198](https://github.com/rollup/rollup/pull/5198): fix: prevent `ENOENT` error on temp config removal (@jzempel) +- [#5237](https://github.com/rollup/rollup/pull/5237): chore: remove unused files and deps (@TrickyPi) +- [#5238](https://github.com/rollup/rollup/pull/5238): chore(deps): update dependency eslint-plugin-unicorn to v49 ( @renovate[bot]) +- [#5239](https://github.com/rollup/rollup/pull/5239): chore(deps): lock file maintenance minor/patch updates ( @renovate[bot]) -## 0.12.1 +## 4.2.0 -* Don't attempt to mark statements belonging to external modules ([#68](https://github.com/rollup/rollup/issues/68)) -* Correctly deshadow variables that conflict with imports ([#68](https://github.com/rollup/rollup/issues/68)) +_2023-10-31_ -## 0.12.0 +### Features -* Internal re-architecting, resulting in more efficient bundling with reduced memory usage -* Shorthand properties are expanded if necessary ([#61](https://github.com/rollup/rollup/issues/61)) -* Fixed various bugs with bundle external dependencies, particularly when generating ES6 bundles ([#59](https://github.com/rollup/rollup/issues/59)) -* Add `--globals` option to CLI ([#60](https://github.com/rollup/rollup/pull/60)) -* Allow imports of external modules for side-effects ([#55](https://github.com/rollup/rollup/pull/55)) -* Prevent Rollup hanging on non-existent external module ([#54](https://github.com/rollup/rollup/pull/54)) +- Run parsing in multiple threads and introduce `parseAstAsync` helper function (#5202) -## 0.11.4 +### Pull Requests -* Side-effect preservation applies to internal default exports ([#43](https://github.com/rollup/rollup/issues/43)) +- [#5202](https://github.com/rollup/rollup/pull/5202): perf: introduce `parseAstAsync` and parallelize parsing AST ( @sapphi-red) -## 0.11.3 +## 4.1.6 -* Class methods are not incorrectly renamed ([#42](https://github.com/rollup/rollup/issues/42)) -* External modules are assigned names before canonical names are determined ([#42](https://github.com/rollup/rollup/issues/42)) +_2023-10-31_ -## 0.11.2 +### Bug Fixes -* Correctly handle computed properties (e.g. `foo[bar]`) when discovering dependencies ([#47](https://github.com/rollup/rollup/pull/47)) +- Fix a bug where emtpy block comments in certain positions could freeze Rollup (#5231) -## 0.11.1 +### Pull Requests -* Support for `export * from '..'` ([#46](https://github.com/rollup/rollup/pull/46)) +- [#5228](https://github.com/rollup/rollup/pull/5228): build: ensure rust toolchain components for linting are installed (@jerome-benoit) +- [#5231](https://github.com/rollup/rollup/pull/5231): Render emtpy block comments after tree-shaken statements ( @lukastaegert) +- [#5232](https://github.com/rollup/rollup/pull/5232): Revert specifying rustfmt and clippy in toolchain file as it breaks REPL build (@lukastaegert) -## 0.11.0 +## 4.1.5 -* Experimental browser-friendly build (`dist/rollup.browser.js`) ([#25](https://github.com/rollup/rollup/issues/25)) -* Internal re-architecting to make discovery process simpler and more performant -* Preservation of side-effects that happen in a separate module to the affected definition ([#39](https://github.com/rollup/rollup/issues/39)) +_2023-10-28_ -## 0.10.0 +### Bug Fixes -* Better sorting algorithm – sorting happens at the module level, rather than the statement level. This avoids certain edge cases -* IIFEs are ignored for the purposes of distinguishing between 'strong' and 'weak' dependencies -* Empty `var` declarations for exported bindings are omitted +- Fix an issue where actual entries that were also implicit entries could remain implicit (#5220) -## 0.9.1 +### Pull Requests -* Much faster statement insertion (fixes major 0.9.0 performance regression) +- [#5209](https://github.com/rollup/rollup/pull/5209): Document Vite workaround for browser build (@curran) +- [#5215](https://github.com/rollup/rollup/pull/5215): chore(deps): update dependency lint-staged to v15 ( @renovate[bot]) +- [#5216](https://github.com/rollup/rollup/pull/5216): chore(deps): lock file maintenance minor/patch updates ( @renovate[bot]) +- [#5218](https://github.com/rollup/rollup/pull/5218): Update license plugin (@lukastaegert) +- [#5219](https://github.com/rollup/rollup/pull/5219): Fix error highlight in REPL (@lukastaegert) +- [#5220](https://github.com/rollup/rollup/pull/5220): Fix race condition when emitting implicitly dependent entries ( @lukastaegert) +- [#5224](https://github.com/rollup/rollup/pull/5224): chore(deps): update actions/setup-node action to v4 ( @renovate[bot]) +- [#5225](https://github.com/rollup/rollup/pull/5225): chore(deps): lock file maintenance minor/patch updates ( @renovate[bot]) -## 0.9.0 +## 4.1.4 -* BREAKING - `resolvePath` is now `resolveId`. The returned `id` (which by default is a filepath) is passed to the `load` function, which can optionally be overridden, and which is applied to all modules including the entry module. This allows custom resolver and loading logic for integration with third party systems (e.g. JSPM) or, eventually, in-browser usage ([#30](https://github.com/rollup/rollup/issues/30)) -* A statement cannot appear after later statements from the same bundle ([#34](https://github.com/rollup/rollup/issues/34)) -* Tricky cyclical dependencies are handled ([#36](https://github.com/rollup/rollup/issues/36)) -* `sourcemap` option is used by CLI (was omitted previously) +_2023-10-16_ -## 0.8.3 +### Bug Fixes -* Correctly rename functions that have arguments with the same name ([#32](https://github.com/rollup/rollup/issues/32)) -* Ensure unused default exports are given a legal name ([#33](https://github.com/rollup/rollup/issues/33)) +- Reduce sizes @rollup/browser and @rollup/wasm-node WASM artifacts (#5204) -## 0.8.2 +### Pull Requests -* Support `moduleId` and `moduleName` via CLI ([#24](https://github.com/rollup/rollup/issues/24)) +- [#5204](https://github.com/rollup/rollup/pull/5204): perf: shrink wasm size by avoid importing browserslist ( @sapphi-red) -## 0.8.1 +## 4.1.3 -* Anonymous functions that are exported as default are converted to named function declarations for correct hoisting, rather than being bound to functions ([#29](https://github.com/rollup/rollup/issues/29)) -* Automatically-generated default export names are deconflicted with local definitions ([#29](https://github.com/rollup/rollup/issues/29)) +_2023-10-15_ -## 0.8.0 +### Bug Fixes -* Top-level variable declarations with multiple declarators are split up, to avoid unnecessary code importing and incorrectly-ordered statements ([#26](https://github.com/rollup/rollup/issues/26)) -* `this` at the top level is `undefined` ([#28](https://github.com/rollup/rollup/issues/28)) +- Fix WASM build as hash function was not exported (#5203) -## 0.7.8 +### Pull Requests -* Avoid using `path.parse` - unsupported in node 0.10 +- [#5203](https://github.com/rollup/rollup/pull/5203): fix: export xxhashBase64Url from wasm (@sapphi-red) -## 0.7.7 +## 4.1.2 -* Promise `source-map-support` from `devDependencies` to `dependencies` ([#23](https://github.com/rollup/rollup/issues/23)) +_2023-10-15_ -## 0.7.6 +_Release did not finish successfully_ -* Better placement of `export default` statements ([#21](https://github.com/rollup/rollup/issues/21)) -* Prevent function calls and property assignments from being treated as rebinding for sake of unbound default exports -* Add `--external foo,bar,baz` option to CLI (equivalent to `external: ['foo', 'bar', 'baz']`) -* Add CLI tests +## 4.1.1 -## 0.7.5 +_2023-10-15_ -* Prevent accidental conflicts with the global namespace ([#20](https://github.com/rollup/rollup/issues/20)) +### Bug Fixes -## 0.7.4 +- Improve Node parsing performance (#5201) -* More precise statement re-ordering to satisfy `export default` constraint (fixes bug introduced in 0.7.3) +### Pull Requests -## 0.7.3 +- [#5201](https://github.com/rollup/rollup/pull/5201): perf: use mimalloc for bindings_napi (@sapphi-red) -* Default exports are not bound. To enable this, statements within a module are sorted to retain their original order ([#15](https://github.com/rollup/rollup/issues/15)) -* Better positioning of comments ([#14](https://github.com/rollup/rollup/issues/14)) -* Various fixes to get Travis-CI rigged up +## 4.1.0 -## 0.7.2 +_2023-10-14_ -* Fix sourcemap paths on Windows ([#6](https://github.com/rollup/rollup/pull/6)) +### Features -## 0.7.1 +- Reduce memory usage of Rollup builds (#5133) -* Named functions can be used as default exports from a bundle -* Method calls are assumed to mutate the owner (i.e. `foo.bar()` mutates `foo`) ([#13](https://github.com/rollup/rollup/issues/13)) -* `options.indent` can be used to control indentation of resulting bundle. `options.true` (default) means 'auto', `options.false` means empty string. Alternatively specify whitespace e.g. `' '` or `'\t'` ([#5](https://github.com/rollup/rollup/issues/5)) +### Pull Requests -## 0.7.0 +- [#5133](https://github.com/rollup/rollup/pull/5133): perf: reducing ast node memory overhead (@thebanjomatic) +- [#5177](https://github.com/rollup/rollup/pull/5177): chore: explicitly set rust toolchain channel (@cijiugechu) +- [#5179](https://github.com/rollup/rollup/pull/5179): Update migration guide for Rollup 4 (@lukastaegert) +- [#5180](https://github.com/rollup/rollup/pull/5180): Resolve clippy errors (@cijiugechu) +- [#5183](https://github.com/rollup/rollup/pull/5183): Add clippy to pipeline and fix remaining issues (@lukastaegert) +- [#5184](https://github.com/rollup/rollup/pull/5184): docs: fix code example for `onLog` (@tjenkinson) +- [#5186](https://github.com/rollup/rollup/pull/5186): Improve wording for native artifacts in migration guide ( @lukastaegert) +- [#5190](https://github.com/rollup/rollup/pull/5190): test: add verifyAst type (@TrickyPi) +- [#5196](https://github.com/rollup/rollup/pull/5196): chore(deps): update dependency rollup to v4 (@renovate[bot]) +- [#5197](https://github.com/rollup/rollup/pull/5197): chore(deps): lock file maintenance minor/patch updates ( @renovate[bot]) -* Ensure statements are always separated by a newline ([#9](https://github.com/rollup/rollup/pull/9)) -* Use CommonJS `exports` correctly (UMD exports) -* Throw error if `moduleName` is required but missing (UMD exports) -* Attach IIFE global to `this` rather than `window` -* Allow names inside bundle to the the names of `Object.prototype` properties ([#12](https://github.com/rollup/rollup/pull/12)) -* Keep exports live ([#11](https://github.com/rollup/rollup/pull/11)) +## 4.0.2 -## 0.6.5 +_2023-10-06_ -* Add sourceMappingURL comment to code, as appropriate -* Higher resolution sourcemaps +### Bug Fixes -## 0.6.4 +- Fix annotation detection logic to not fail when a non-ASCII character precedes a double underscore (#5178) -* Fix CJS bundling with default export +### Pull Requests -## 0.6.3 +- [#5178](https://github.com/rollup/rollup/pull/5178): Handle special characters before double underscores ( @lukastaegert) -* Fix exports and external module imports with some output formats -* Fix endless cycle bug on Windows ([#3](https://github.com/rollup/rollup/pull/3)) - thanks @Bobris +## 4.0.1 -## 0.6.2 +_2023-10-06_ -* Permit assignments to properties of imported bindings +### Bug Fixes -## 0.6.1 +- Do not panic on trailing semicolons after class methods (#5173) +- Add artifact for arm64 linux musl target (#5176) -* Support for basic transformers +### Pull Requests -## 0.6.0 +- [#5172](https://github.com/rollup/rollup/pull/5172): chore(deps): lock file maintenance minor/patch updates ( @renovate[bot]) +- [#5173](https://github.com/rollup/rollup/pull/5173): fix: ignores empty statements in class body that is returned by SWC parser (@TrickyPi) +- [#5176](https://github.com/rollup/rollup/pull/5176): Fix linux arm musl build (@lukastaegert) -* BREAKING - `rollup.rollup` and `bundle.write` both take a single options argument -* BREAKING - external modules must be declared upfront with `options.external: [...]` -* Non-relative module paths will be resolved by looking for `jsnext:main` fields in the appropriate `package.json` files. This behaviour can be overridden by passing an alternative `resolveExternal` function -* Fix sourcemap options -* Include CLI files in npm package (duh) +## 4.0.0 -## 0.5.0 +_2023-10-05_ -* Command line interface -* Sourcemap generation -* Correct behaviour with `export { x as y } from 'z'` +### BREAKING CHANGES -## 0.4.1 +#### General Changes -* More import name deconflicting +- The minimal required Node version is now 18.0.0 (#5142) +- The browser build now relies on a WASM artifact that needs to be provided as well (#5073) +- The NodeJS build now relies on an optional native binary; for unsupported platforms, users can use the `@rollup/wasm-node` package that has the same interface as Rollup but relies on WASM artifacts (#5073) +- The `INVALID_IMPORT_ASSERTION` error code has been replaced with `INVALID_IMPORT_ATTRIBUTE` (#5073) +- Rollup will now warn for `@__PURE__` and `@__NO_SIDE_EFFECTS__` annotations in invalid locations (#5165) +- If an entry module starts with a shebang comment `#!...`, this comment will be prepended to the output for `es` and `cjs` formats (#5163) +- File hashes will now use url-safe base64 encoded hashes (#5155) +- The maximum hash length has been reduced to 22 characters (#5155) +- The `RollupWarning` type has been removed in favor of the `RollupLog` type (#5147) -## 0.4.0 +#### Changes to Rollup Options -* Self-hosting! `rollup.rollup` now rolls up rollup -* Fix bug with comments inside a statement later being appended to it -* Prevent shadowing of external modules -* Rewrite computed property identifiers where necessary -* Preserve original statement order where possible -* Internal refactoring +- Acorn plugins are no longer supported, the `acornInjectPlugins` option has been removed (#5073) +- The `acorn` option has been removed (#5073) +- `output.externalImportAssertions` has been deprecated in favor of `output.externalImportAttributes` (#5073) +- `inlineDynamicImports`, `manualChunks` and `preserveModules` have been removed on input option level: Please use the corresponding output options of the same names (#5143) +- Removed output options (#5143): + - `output.experimentalDeepDynamicChunkOptimization`: This option is no longer needed as Rollup now always runs the full chunking algorithm + - `output.dynamicImportFunction`: Use the `renderDynamicImport` plugin hook instead + - `output.namespaceToStringTag`: Use `output.generatedCode.symbols` instead + - `output.preferConst`: Use `output.generatedCode.constBindings` instead -## 0.3.1 +#### Plugin API Changes -* Saner deconflicting -* Rename namespace imports from external modules correctly +- For `this.resolve`, the default of the `skipSelf` option is now `true` (#5142) +- `this.parse` now only supports the `allowReturnOutsideFunction` option for now (#5073) +- Import assertions now use the [new import attribute AST structure](https://github.com/estree/estree/blob/master/experimental/import-attributes.md) ( #5073) +- "assertions" have been replaced with "attributes" in various places of the plugin interface (#5073) +- If the import of a module id is handled by the `load` hook of a plugin, `rollup.watch` no longer watches the actual file if the module id corresponds to a real path; if this is intended, then the plugin is responsible for calling `this.addWatchFile` for any dependency files (#5150) +- The normalized input options provided by `buildStart` and other hooks no longer contain an `onwarn` handler; plugins should use `onLog` instead (#5147) +- `this.moduleIds` has been removed from the plugin context: Use `this.getModuleIds()` instead (#5143) +- The `hasModuleSideEffects` flag has been removed from the `ModuleInfo` returned by `this.getModuleInfo()`: Use `moduleSideEffects` on the `ModuleInfo` instead (#5143) -## 0.3.0 +### Features -* Basic functionality present, mostly spec-compliant +- Improve parsing speed by switching to a native SWC-based parser (#5073) +- Rollup will now warn for `@__PURE__` and `@__NO_SIDE_EFFECTS__` annotations in invalid locations (#5165) +- The parser is now exposed as a separate export `parseAst` (#5169) -## 0.2.1 +### Bug Fixes -* Include dist files in npm package (duh) +- Rollup no longer tries to watch virtual files if their name corresponds to an actual file name; instead, plugins handle watching via `this.addWatchFile()` (#5150) -## 0.2.0 +### Pull Requests -* First release capable of doing anything useful -* Still lots of basic functionality missing +- [#5073](https://github.com/rollup/rollup/pull/5073): [v4.0] Switch parser to SWC and introduce native/WASM code ( @lukastaegert) +- [#5142](https://github.com/rollup/rollup/pull/5142): [v4.0] Set the default of skipSelf to true (@TrickyPi) +- [#5143](https://github.com/rollup/rollup/pull/5143): [v4.0] Remove deprecated features (@lukastaegert) +- [#5144](https://github.com/rollup/rollup/pull/5144): [v4.0] Imporve the performance of generating ast and rollup ast nodes (@TrickyPi) +- [#5147](https://github.com/rollup/rollup/pull/5147): [v4.0] Remove onwarn from normalized input options ( @lukastaegert) +- [#5150](https://github.com/rollup/rollup/pull/5150): [v4.0] feat: Do not watch files anymore if their content is returned by the load hook (@TrickyPi) +- [#5154](https://github.com/rollup/rollup/pull/5154): [v4.0] Add parse option to allow return outside function ( @lukastaegert) +- [#5155](https://github.com/rollup/rollup/pull/5155): [v4.0] feat: implement hashing content in Rust (@TrickyPi) +- [#5157](https://github.com/rollup/rollup/pull/5157): [v4.0] Handle empty exports (@lukastaegert) +- [#5160](https://github.com/rollup/rollup/pull/5160): chore(deps): lock file maintenance minor/patch updates ( @renovate[bot]) +- [#5163](https://github.com/rollup/rollup/pull/5163): [v4.0] feat: preserve shebang in entry module for CJS and ESM outputs (@TrickyPi) +- [#5164](https://github.com/rollup/rollup/pull/5164): [v4.0] fix: also strip BOM from code strings in JS (@TrickyPi) +- [#5165](https://github.com/rollup/rollup/pull/5165): [v4.0] warn for invalid annotations (@lukastaegert) +- [#5168](https://github.com/rollup/rollup/pull/5168): [v4.0] Ensure we support new import attribute "with" syntax ( @lukastaegert) +- [#5169](https://github.com/rollup/rollup/pull/5169): [v4.0] Expose parser (@lukastaegert) -## 0.1.0 +For previous changelogs, see -* Initial experiment +- [Rollup 3.x](./CHANGELOG-3.md) +- [Rollup 2.x](./CHANGELOG-2.md) +- [Rollup 1.x](./CHANGELOG-1.md) +- [Rollup 0.x](./CHANGELOG-0.md) diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index 4b66eeddced..f04d208f5cb 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -8,19 +8,19 @@ In the interest of fostering an open and welcoming environment, we as contributo Examples of behavior that contributes to creating a positive environment include: -* Using welcoming and inclusive language -* Being respectful of differing viewpoints and experiences -* Gracefully accepting constructive criticism -* Focusing on what is best for the community -* Showing empathy towards other community members +- Using welcoming and inclusive language +- Being respectful of differing viewpoints and experiences +- Gracefully accepting constructive criticism +- Focusing on what is best for the community +- Showing empathy towards other community members Examples of unacceptable behavior by participants include: -* The use of sexualized language or imagery and unwelcome sexual attention or advances -* Trolling, insulting/derogatory comments, and personal or political attacks -* Public or private harassment -* Publishing others' private information, such as a physical or electronic address, without explicit permission -* Other conduct which could reasonably be considered inappropriate in a professional setting +- The use of sexualized language or imagery and unwelcome sexual attention or advances +- Trolling, insulting/derogatory comments, and personal or political attacks +- Public or private harassment +- Publishing others' private information, such as a physical or electronic address, without explicit permission +- Other conduct which could reasonably be considered inappropriate in a professional setting ## Our Responsibilities diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 5e03ac786a3..45c87b1267f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -4,7 +4,8 @@ First, thank you for considering contributing to rollup! It's people like you that make the open source community such a great community! 😊 -We welcome any type of contribution, not only code. You can help with +We welcome any type of contribution, not only code. You can help with + - **QA**: file bug reports, the more details you can give the better (i.e. [REPL](https://rollupjs.org/repl/)-links or repos that demonstrate the specific issue) - **Marketing**: writing blog posts, howto's, printing stickers, ... - **Community**: presenting the project at meetups, organizing a dedicated meetup for the local community, ... @@ -13,7 +14,115 @@ We welcome any type of contribution, not only code. You can help with ## Your First Contribution -Working on your first Pull Request? You can learn how from this *free* series, [How to Contribute to an Open Source Project on GitHub](https://egghead.io/series/how-to-contribute-to-an-open-source-project-on-github). +Working on your first Pull Request? You can learn how from this _free_ course, [How to Contribute to an Open Source Project on GitHub](https://egghead.io/courses/how-to-contribute-to-an-open-source-project-on-github). + +### Setting up the Rust toolchain + +Rollup now includes some Rust code. To compile it, you need to set up the Rust toolchain. If you haven't installed it yet, please see https://www.rust-lang.org/tools/install to learn how to download Rustup and install Rust. + +Make sure you use the same toolchain version as specified in the `/rust-toolchain.toml` file. It should automatically be handled, as well as acquiring the required targets. Should you want to do it manually, use the following commands: + +```shell +# Look at the rust-toolchain.toml file for the precise toolchain used by Rollup +rustup toolchain install nightly +rustup default nightly +``` + +You should also install the `rust-src` component: + +```shell +rustup component add rust-src +``` + +In the end, run + +```shell +rustup update +``` + +If everything is set up correctly, `npm run build` should complete successfully. The first build will be rather slow, but subsequent builds will be much faster. + +For local development and tests, it is even faster to run `npm run build:quick`, which does not perform a Rust production build, does not build WASM artefacts, and only builds the CommonJS version of Rollup. Note that with this build, a few tests will fail that rely on the other artefacts, see below. + +### Git configuration to enable symlinks + +The unit tests in this projects make use of symlinks in the git project. On Windows, this may not work as expected without extra configuration. To configure git to create symlinks on windows, you need to enable the Windows "Developer Mode" setting, and also set the `core.symlinks` git feature using either of the following commands: + +```bash +# Global setting +git config --global core.symlinks true + +# Local setting +git config core.symlinks true +``` + +After applying this setting, you may need to reset your local branch to ensure the files get rewritten as symlinks. Note that this step is destructive and you will want to push any changes you have made prior to resetting your branch. + +```bash +git reset --hard +``` + +### Installing dependencies + +Running `npm install` will install the necessary dependencies. If it fails, it might be because the Rust toolchain is not yet set up for WebAssembly, see above. + +### How to run one test on your local machine + +With `npm run test` you can run all tests together. + +To save time for quick iterations, you can add `solo:true` to the `_config.js` file of any given test to run just this one test. To further speed up rebuilds, note that most tests just need the CommonJS build of Rollup. + +For those tests, it is enough to run + +```shell +npm run build:quick +npm run test:quick + +``` + +Note that this does not run the browser tests and a few CLI tests will fail. + +### How to write tests + +For any new feature or bug fix, sufficient test coverage is crucial. + +Note that Rollup does not really have unit tests, only the external APIs are tested with the full Rollup build. While this may seem unusual, the tests are still very stable and fast. This provides us with the ability to perform major refactorings of the code base while ensuring full compatibility with the previous versions. + +There are different test categories. Most of these tests are directory-based where you have a directory with a `_config.js` file that contains the test description and configuration and several code files. See [/test/types.d.ts](./test/types.d.ts) for a full list of available test configuration options for all directory based test types. By default, unless specified otherwise, the `main.js` file is the entry point for the test. To run the tests in an IDE, configure a ["Mocha" compatible test runner](https://mochajs.org/#editor-plugins) that uses `test/test.js` as the entry point. + +- **[`test/function`](./test/function/samples)**: These tests bundle to CommonJS and then run the entry point provided by `main.js`. The `assert` function from `node:assert` is injected as a global variable, so you can make inline assertions in the code. You can also use the `exports` configuration key to make assertions on the exported values. These are very stable and meaningful tests and should be your first choice for new tests. + - For regression testing when Rollup produces invalid code or crashes + - For testing plugin interactions. To do so, import `node:assert` in your `_config.js` file and make assertions in your plugin hooks as needed. + - For testing expected bundling errors, warnings and logs (use the `error`, `generateError`, `warnings` and `logs` configuration keys) + - For asserting on the generated bundle object (use the `bundle` configuration key) +- **[`test/form`](./test/form/samples)**: These tests bundle to all output formats and do not run the code. They compare the bundled code against an `_expected` directory that contains the output for all formats. If the format is not important, you can specify an `_expected.js` file instead, which will be compared against the output when bundling to ES module format. + - For testing tree-shaking + - For testing code that does not run on all supported NodeJS platforms +- **[`test/chunking-form`](./test/chunking-form/samples)**: Similar to the `form` tests, these tests support multiple output files and assets. Instead of a single file, there is a directory for each output format. +- **[`test/cli`](./test/cli/samples)**: These tests run the Rollup CLI with a given configuration. They can compare the generated files against provided files and make assertions on stderr output. They can also optionally run the generated files. +- **[`test/watch`](./test/watch)**: Test that watch mode works as expected. These tests are actually in the `index.js` file and only use the `samples` directory for input files. +- **[`test/browser`](./test/browser/samples)**: These tests bundle with the browser build of Rollup. They compare the output to an `_expected` directory and allow to make assertions on bundling errors. Note that you need to provide all input files via plugins. +- **[`test/sourcemaps`](./test/sourcemaps/samples)**: Tests to make assertions on the generated sourcemaps. +- **[`test/incremental`](./test/incremental)**: For testing the caching behaviour of Rollup. As these tests need to run Rollup more than once, it was not easily possible to implement them as directory-based tests. +- **[`test/file-hashes`](./test/file-hashes/samples)**: Relevant for testing that different outputs have different file hashes. With the new hashing algorithm, these tests are not as important as they used to be and are kept mostly for historical reasons. +- **[`test/hooks`](./test/hooks)**: Do not add new tests here. These tests were the original tests for the plugin interface. For new tests, `function` tests are preferred as they are much easier to maintain. +- **[`test/misc`](./test/misc)**: General tests that do not fit into the other categories. + +### Developing with the website + +Running + +```shell +npm run dev +``` + +will start the website locally in development mode via Vite. This will give you a live preview of the documentation. It will also verify that the documentation does not contain any dead links. + +A special feature of the website is that the REPL at `http://localhost:5173/repl/` is directly using the browser build of your local copy of Rollup created via Vite. It even supports full hot module replacement, which means that when you change anything within Rollup, the REPL will automatically rebundle the current code using your latest changes. This can come in very handy when working on a bug or tree-shaking improvement to allow extremely fast iterations. + +## Navigating the codebase + +See the [architecure documentation](ARCHITECTURE.md) for an overview of the codebase and a high-level explanation of how Rollup works. ## Submitting code @@ -27,21 +136,17 @@ It is also always helpful to have some context for your pull request. What was t ## Financial contributions -We also welcome financial contributions in full transparency on our [open collective](https://opencollective.com/rollup). -Anyone can file an expense. If the expense makes sense for the development of the community, it will be "merged" in the ledger of our open collective by the core contributors and the person who filed the expense will be reimbursed. +We also welcome financial contributions in full transparency on our [open collective](https://opencollective.com/rollup). Anyone can file an expense. If the expense makes sense for the development of the community, it will be "merged" in the ledger of our open collective by the core contributors and the person who filed the expense will be reimbursed. ## Questions -If you require technical assistance, [Stackoverflow](https://stackoverflow.com/questions/tagged/rollupjs) or [Discord](https://is.gd/rollup_chat) are usually the best places to start. -You can also create an [issue](issue) (protip: do a quick search first to see if someone else didn't ask the same question before!). +If you require technical assistance, [Stackoverflow](https://stackoverflow.com/questions/tagged/rollupjs) or [Discord](https://is.gd/rollup_chat) are usually the best places to start. You can also create an [issue](issue) ( protip: do a quick search first to see if someone else didn't ask the same question before!). ## Credits ### Contributors -Thank you to all the people who have already contributed to rollup! - - +Thank you to all the people who have already contributed to rollup! ### Backers @@ -49,20 +154,10 @@ Thank you to all our backers! [[Become a backer](https://opencollective.com/roll - ### Sponsors Thank you to all our sponsors! (please ask your company to also support this open source project by [becoming a sponsor](https://opencollective.com/rollup#sponsor)) - - - - - - - - - - + diff --git a/FUNDING.json b/FUNDING.json new file mode 100644 index 00000000000..fcb4f353de3 --- /dev/null +++ b/FUNDING.json @@ -0,0 +1,7 @@ +{ + "drips": { + "ethereum": { + "ownedBy": "0x3FF19163842E027ab536172B10123af20e3e4648" + } + } +} diff --git a/LICENSE-CORE.md b/LICENSE-CORE.md index 355c03e926f..14852a2d22a 100644 --- a/LICENSE-CORE.md +++ b/LICENSE-CORE.md @@ -2,20 +2,8 @@ The MIT License (MIT) Copyright (c) 2017 [these people](https://github.com/rollup/rollup/graphs/contributors) -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/LICENSE.md b/LICENSE.md index 3a03706b1d2..7b806824370 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -5,91 +5,23 @@ The MIT License (MIT) Copyright (c) 2017 [these people](https://github.com/rollup/rollup/graphs/contributors) -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # Licenses of bundled dependencies The published Rollup artifact additionally contains code with the following licenses: -MIT, ISC +MIT, ISC, 0BSD # Bundled dependencies: -## acorn -License: MIT -By: Marijn Haverbeke, Ingvar Stepanyan, Adrian Heine -Repository: https://github.com/acornjs/acorn.git - -> MIT License -> -> Copyright (C) 2012-2020 by various contributors (see AUTHORS) -> -> Permission is hereby granted, free of charge, to any person obtaining a copy -> of this software and associated documentation files (the "Software"), to deal -> in the Software without restriction, including without limitation the rights -> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -> copies of the Software, and to permit persons to whom the Software is -> furnished to do so, subject to the following conditions: -> -> The above copyright notice and this permission notice shall be included in -> all copies or substantial portions of the Software. -> -> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -> THE SOFTWARE. - ---------------------------------------- - -## acorn-class-fields -License: MIT -By: Adrian Heine -Repository: https://github.com/acornjs/acorn-class-fields - -> Copyright (C) 2017-2018 by Adrian Heine -> -> Permission is hereby granted, free of charge, to any person obtaining a copy -> of this software and associated documentation files (the "Software"), to deal -> in the Software without restriction, including without limitation the rights -> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -> copies of the Software, and to permit persons to whom the Software is -> furnished to do so, subject to the following conditions: -> -> The above copyright notice and this permission notice shall be included in -> all copies or substantial portions of the Software. -> -> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -> THE SOFTWARE. - ---------------------------------------- - -## acorn-private-class-elements +## @jridgewell/sourcemap-codec License: MIT -By: Adrian Heine -Repository: https://github.com/acornjs/acorn-private-class-elements +By: Justin Ridgewell +Repository: git+https://github.com/jridgewell/sourcemaps.git -> Copyright (C) 2017-2018 by Adrian Heine +> Copyright 2024 Justin Ridgewell > > Permission is hereby granted, free of charge, to any person obtaining a copy > of this software and associated documentation files (the "Software"), to deal @@ -106,73 +38,19 @@ Repository: https://github.com/acornjs/acorn-private-class-elements > FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE > AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER > LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -> THE SOFTWARE. - ---------------------------------------- - -## acorn-private-methods -License: MIT -By: Adrian Heine -Repository: https://github.com/acornjs/acorn-private-methods - -> Copyright (C) 2017-2018 by Adrian Heine -> -> Permission is hereby granted, free of charge, to any person obtaining a copy -> of this software and associated documentation files (the "Software"), to deal -> in the Software without restriction, including without limitation the rights -> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -> copies of the Software, and to permit persons to whom the Software is -> furnished to do so, subject to the following conditions: -> -> The above copyright notice and this permission notice shall be included in -> all copies or substantial portions of the Software. -> -> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -> THE SOFTWARE. - ---------------------------------------- - -## acorn-static-class-features -License: MIT -By: Adrian Heine -Repository: https://github.com/acornjs/acorn-static-class-features - -> Copyright (C) 2017-2018 by Adrian Heine -> -> Permission is hereby granted, free of charge, to any person obtaining a copy -> of this software and associated documentation files (the "Software"), to deal -> in the Software without restriction, including without limitation the rights -> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -> copies of the Software, and to permit persons to whom the Software is -> furnished to do so, subject to the following conditions: -> -> The above copyright notice and this permission notice shall be included in -> all copies or substantial portions of the Software. -> -> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -> THE SOFTWARE. +> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +> SOFTWARE. --------------------------------------- -## acorn-walk +## @rollup/pluginutils License: MIT -By: Marijn Haverbeke, Ingvar Stepanyan, Adrian Heine -Repository: https://github.com/acornjs/acorn.git +By: Rich Harris +Repository: rollup/plugins -> MIT License +> The MIT License (MIT) > -> Copyright (C) 2012-2020 by various contributors (see AUTHORS) +> Copyright (c) 2019 RollupJS Plugin Contributors (https://github.com/rollup/plugins/graphs/contributors) > > Permission is hereby granted, free of charge, to any person obtaining a copy > of this software and associated documentation files (the "Software"), to deal @@ -222,6 +100,17 @@ License: MIT By: Sindre Sorhus Repository: sindresorhus/binary-extensions +> MIT License +> +> Copyright (c) Sindre Sorhus (https://sindresorhus.com) +> Copyright (c) Paul Miller (https://paulmillr.com) +> +> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: +> +> The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. +> +> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + --------------------------------------- ## braces @@ -231,7 +120,7 @@ Repository: micromatch/braces > The MIT License (MIT) > -> Copyright (c) 2014-2018, Jon Schlinkert. +> Copyright (c) 2014-present, Jon Schlinkert. > > Permission is hereby granted, free of charge, to any person obtaining a copy > of this software and associated documentation files (the "Software"), to deal @@ -253,6 +142,23 @@ Repository: micromatch/braces --------------------------------------- +## builtin-modules +License: MIT +By: Sindre Sorhus +Repository: sindresorhus/builtin-modules + +> MIT License +> +> Copyright (c) Sindre Sorhus (https://sindresorhus.com) +> +> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: +> +> The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. +> +> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +--------------------------------------- + ## chokidar License: MIT By: Paul Miller, Elan Shanker @@ -282,25 +188,20 @@ Repository: git+https://github.com/paulmillr/chokidar.git --------------------------------------- -## colorette +## date-time License: MIT -By: Jorge Bucaran -Repository: jorgebucaran/colorette +By: Sindre Sorhus +Repository: sindresorhus/date-time -> Copyright © Jorge Bucaran <> +> MIT License > -> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: +> Copyright (c) Sindre Sorhus (https://sindresorhus.com) +> +> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: > > The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. > -> THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - ---------------------------------------- - -## date-time -License: MIT -By: Sindre Sorhus -Repository: sindresorhus/date-time +> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --------------------------------------- @@ -333,6 +234,23 @@ Repository: jonschlinkert/fill-range --------------------------------------- +## flru +License: MIT +By: Luke Edwards +Repository: lukeed/flru + +> MIT License +> +> Copyright (c) Luke Edwards (lukeed.com) +> +> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: +> +> The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. +> +> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +--------------------------------------- + ## glob-parent License: ISC By: Gulp Team, Elan Shanker, Blaine Bublitz @@ -356,39 +274,20 @@ Repository: gulpjs/glob-parent --------------------------------------- -## hash.js +## is-binary-path License: MIT -By: Fedor Indutny -Repository: git@github.com:indutny/hash.js - ---------------------------------------- - -## inherits -License: ISC -Repository: git://github.com/isaacs/inherits +By: Sindre Sorhus +Repository: sindresorhus/is-binary-path -> The ISC License +> MIT License > -> Copyright (c) Isaac Z. Schlueter +> Copyright (c) 2019 Sindre Sorhus (https://sindresorhus.com), Paul Miller (https://paulmillr.com) > -> Permission to use, copy, modify, and/or distribute this software for any -> purpose with or without fee is hereby granted, provided that the above -> copyright notice and this permission notice appear in all copies. +> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: > -> THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH -> REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND -> FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, -> INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -> LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -> OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -> PERFORMANCE OF THIS SOFTWARE. - ---------------------------------------- - -## is-binary-path -License: MIT -By: Sindre Sorhus -Repository: sindresorhus/is-binary-path +> The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. +> +> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --------------------------------------- @@ -489,14 +388,14 @@ Repository: git+https://github.com/Rich-Harris/is-reference.git ## locate-character License: MIT By: Rich Harris -Repository: Rich-Harris/locate-character +Repository: git+https://gitlab.com/Rich-Harris/locate-character.git --------------------------------------- ## magic-string License: MIT By: Rich Harris -Repository: https://github.com/rich-harris/magic-string +Repository: git+https://github.com/Rich-Harris/magic-string.git > Copyright 2018 Rich Harris > @@ -508,14 +407,14 @@ Repository: https://github.com/rich-harris/magic-string --------------------------------------- -## micromatch +## normalize-path License: MIT -By: Jon Schlinkert, Amila Welihinda, Bogdan Chadkin, Brian Woodward, Devon Govett, Elan Shanker, Fabrício Matté, Martin Kolárik, Olsten Larck, Paul Miller, Tom Byrer, Tyler Akins, Peter Bright -Repository: micromatch/micromatch +By: Jon Schlinkert, Blaine Bublitz +Repository: jonschlinkert/normalize-path > The MIT License (MIT) > -> Copyright (c) 2014-present, Jon Schlinkert. +> Copyright (c) 2014-2018, Jon Schlinkert. > > Permission is hereby granted, free of charge, to any person obtaining a copy > of this software and associated documentation files (the "Software"), to deal @@ -537,59 +436,43 @@ Repository: micromatch/micromatch --------------------------------------- -## minimalistic-assert -License: ISC -Repository: https://github.com/calvinmetcalf/minimalistic-assert.git +## parse-ms +License: MIT +By: Sindre Sorhus +Repository: sindresorhus/parse-ms -> Copyright 2015 Calvin Metcalf +> MIT License > -> Permission to use, copy, modify, and/or distribute this software for any purpose -> with or without fee is hereby granted, provided that the above copyright notice -> and this permission notice appear in all copies. +> Copyright (c) Sindre Sorhus (https://sindresorhus.com) > -> THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH -> REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND -> FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, -> INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -> LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE -> OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -> PERFORMANCE OF THIS SOFTWARE. +> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: +> +> The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. +> +> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --------------------------------------- -## normalize-path -License: MIT -By: Jon Schlinkert, Blaine Bublitz -Repository: jonschlinkert/normalize-path +## picocolors +License: ISC +By: Alexey Raspopov +Repository: alexeyraspopov/picocolors -> The MIT License (MIT) +> ISC License > -> Copyright (c) 2014-2018, Jon Schlinkert. -> -> Permission is hereby granted, free of charge, to any person obtaining a copy -> of this software and associated documentation files (the "Software"), to deal -> in the Software without restriction, including without limitation the rights -> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -> copies of the Software, and to permit persons to whom the Software is -> furnished to do so, subject to the following conditions: +> Copyright (c) 2021-2024 Oleksii Raspopov, Kostiantyn Denysov, Anton Verinov > -> The above copyright notice and this permission notice shall be included in -> all copies or substantial portions of the Software. +> Permission to use, copy, modify, and/or distribute this software for any +> purpose with or without fee is hereby granted, provided that the above +> copyright notice and this permission notice appear in all copies. > -> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -> THE SOFTWARE. - ---------------------------------------- - -## parse-ms -License: MIT -By: Sindre Sorhus -Repository: sindresorhus/parse-ms +> THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +> WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +> MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +> ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +> WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +> ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +> OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. --------------------------------------- @@ -627,6 +510,16 @@ License: MIT By: Sindre Sorhus Repository: sindresorhus/pretty-bytes +> MIT License +> +> Copyright (c) Sindre Sorhus (https://sindresorhus.com) +> +> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: +> +> The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. +> +> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + --------------------------------------- ## pretty-ms @@ -634,6 +527,16 @@ License: MIT By: Sindre Sorhus Repository: sindresorhus/pretty-ms +> MIT License +> +> Copyright (c) Sindre Sorhus (https://sindresorhus.com) +> +> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: +> +> The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. +> +> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + --------------------------------------- ## readdirp @@ -665,20 +568,6 @@ Repository: git://github.com/paulmillr/readdirp.git --------------------------------------- -## require-relative -License: MIT -By: Valerio Proietti -Repository: git://github.com/kamicane/require-relative.git - ---------------------------------------- - -## rollup-pluginutils -License: MIT -By: Rich Harris -Repository: rollup/rollup-pluginutils - ---------------------------------------- - ## signal-exit License: ISC By: Ben Coe @@ -686,7 +575,7 @@ Repository: https://github.com/tapjs/signal-exit.git > The ISC License > -> Copyright (c) 2015, Contributors +> Copyright (c) 2015-2023 Benjamin Coe, Isaac Z. Schlueter, and Contributors > > Permission to use, copy, modify, and/or distribute this software > for any purpose with or without fee is hereby granted, provided @@ -703,39 +592,20 @@ Repository: https://github.com/tapjs/signal-exit.git --------------------------------------- -## sourcemap-codec +## time-zone License: MIT -By: Rich Harris -Repository: https://github.com/Rich-Harris/sourcemap-codec +By: Sindre Sorhus +Repository: sindresorhus/time-zone -> The MIT License +> MIT License > -> Copyright (c) 2015 Rich Harris +> Copyright (c) Sindre Sorhus (https://sindresorhus.com) > -> Permission is hereby granted, free of charge, to any person obtaining a copy -> of this software and associated documentation files (the "Software"), to deal -> in the Software without restriction, including without limitation the rights -> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -> copies of the Software, and to permit persons to whom the Software is -> furnished to do so, subject to the following conditions: +> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: > -> The above copyright notice and this permission notice shall be included in -> all copies or substantial portions of the Software. +> The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. > -> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -> THE SOFTWARE. - ---------------------------------------- - -## time-zone -License: MIT -By: Sindre Sorhus -Repository: sindresorhus/time-zone +> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --------------------------------------- @@ -768,6 +638,26 @@ Repository: micromatch/to-regex-range --------------------------------------- +## tslib +License: 0BSD +By: Microsoft Corp. +Repository: https://github.com/Microsoft/tslib.git + +> Copyright (c) Microsoft Corporation. +> +> Permission to use, copy, modify, and/or distribute this software for any +> purpose with or without fee is hereby granted. +> +> THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +> REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +> AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +> INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +> LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +> OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +> PERFORMANCE OF THIS SOFTWARE. + +--------------------------------------- + ## yargs-parser License: ISC By: Ben Coe diff --git a/README.md b/README.md index be9df6aaff4..0c4fe959efe 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,14 @@ -# Rollup +

+ +

npm version + + node compatibility + install size @@ -11,7 +16,7 @@ code coverage - backers + backers sponsors @@ -19,14 +24,12 @@ license - - dependency status - Join the chat at https://is.gd/rollup_chat

+

Rollup

## Overview @@ -34,7 +37,7 @@ Rollup is a module bundler for JavaScript which compiles small pieces of code in ## Quick Start Guide -Install with `npm install --global rollup`. Rollup can be used either through a [command line interface](https://rollupjs.org/#command-line-reference) with an optional configuration file, or else through its [JavaScript API](https://rollupjs.org/guide/en/#javascript-api). Run `rollup --help` to see the available options and parameters. The starter project templates, [rollup-starter-lib](https://github.com/rollup/rollup-starter-lib) and [rollup-starter-app](https://github.com/rollup/rollup-starter-app), demonstrate common configuration options, and more detailed instructions are available throughout the [user guide](https://rollupjs.org/). +Install with `npm install --global rollup`. Rollup can be used either through a [command line interface](https://rollupjs.org/command-line-interface/) with an optional configuration file or else through its [JavaScript API](https://rollupjs.org/javascript-api/). Run `rollup --help` to see the available options and parameters. The starter project templates, [rollup-starter-lib](https://github.com/rollup/rollup-starter-lib) and [rollup-starter-app](https://github.com/rollup/rollup-starter-app), demonstrate common configuration options, and more detailed instructions are available throughout the [user guide](https://rollupjs.org/introduction/). ### Commands @@ -65,30 +68,31 @@ rollup main.js --format umd --name "myBundle" --file bundle.js Developing software is usually easier if you break your project into smaller separate pieces, since that often removes unexpected interactions and dramatically reduces the complexity of the problems you'll need to solve, and simply writing smaller projects in the first place [isn't necessarily the answer](https://medium.com/@Rich_Harris/small-modules-it-s-not-quite-that-simple-3ca532d65de4). Unfortunately, JavaScript has not historically included this capability as a core feature in the language. -This finally changed with ES modules support in JavaScript, which provides a syntax for importing and exporting functions and data so they can be shared between separate scripts. Most browsers and Node.js support ES modules. However, Node.js releases before 12.17 support ES modules only behind the `--experimental-modules` flag, and older browsers like Internet Explorer do not support ES modules at all. Rollup allows you to write your code using ES modules, and run your application even in environments that do not support ES modules natively. For environments that support them, Rollup can output optimized ES modules; for environments that don't, Rollup can compile your code to other formats such as CommonJS modules, AMD modules, and IIFE-style scripts. This means that you get to *write future-proof code*, and you also get the tremendous benefits of... +This finally changed with ES modules support in JavaScript, which provides a syntax for importing and exporting functions and data so they can be shared between separate scripts. Most browsers and Node.js support ES modules. However, Node.js releases before 12.17 support ES modules only behind the `--experimental-modules` flag, and older browsers like Internet Explorer do not support ES modules at all. Rollup allows you to write your code using ES modules, and run your application even in environments that do not support ES modules natively. For environments that support them, Rollup can output optimized ES modules; for environments that don't, Rollup can compile your code to other formats such as CommonJS modules, AMD modules, and IIFE-style scripts. This means that you get to _write future-proof code_, and you also get the tremendous benefits of... ## Tree Shaking In addition to enabling the use of ES modules, Rollup also statically analyzes and optimizes the code you are importing, and will exclude anything that isn't actually used. This allows you to build on top of existing tools and modules without adding extra dependencies or bloating the size of your project. -For example, with CommonJS, the *entire tool or library must be imported*. +For example, with CommonJS, the _entire tool or library must be imported_. ```js // import the entire utils object with CommonJS -var utils = require( 'utils' ); +var utils = require('node:utils'); var query = 'Rollup'; // use the ajax method of the utils object -utils.ajax( 'https://api.example.com?search=' + query ).then( handleResponse ); +utils.ajax('https://api.example.com?search=' + query).then(handleResponse); ``` But with ES modules, instead of importing the whole `utils` object, we can just import the one `ajax` function we need: ```js // import the ajax function with an ES import statement -import { ajax } from 'utils'; +import { ajax } from 'node:utils'; + var query = 'Rollup'; // call the ajax function -ajax( 'https://api.example.com?search=' + query ).then( handleResponse ); +ajax('https://api.example.com?search=' + query).then(handleResponse); ``` Because Rollup includes the bare minimum, it results in lighter, faster, and less complicated libraries and applications. Since this approach is based on explicit `import` and `export` statements, it is vastly more effective than simply running an automated minifier to detect unused variables in the compiled output code. @@ -105,9 +109,7 @@ To make sure your ES modules are immediately usable by tools that work with Comm ## Contributors -This project exists thanks to all the people who contribute. [[Contribute](CONTRIBUTING.md)]. - - +This project exists thanks to all the people who contribute. [[Contribute](CONTRIBUTING.md)]. . If you want to contribute yourself, head over to the [contribution guidelines](CONTRIBUTING.md). ## Backers @@ -115,23 +117,17 @@ Thank you to all our backers! 🙏 [[Become a backer](https://opencollective.com - ## Sponsors Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [[Become a sponsor](https://opencollective.com/rollup#sponsor)] - - - - - - - - - - + + +## Special Sponsor +TNG Logo +TNG has been supporting the work of [Lukas Taegert-Atkinson](https://github.com/lukastaegert) on Rollup since 2017. ## License diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 00000000000..938d5598bb4 --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,5 @@ +# Reporting a Vulnerability + +To report a vulnerability, please open a private vulnerability report at https://github.com/rollup/rollup/security. + +While the discovery of new vulnerabilities is rare, we also recommend always using the latest versions of Rollup and its official plugins to ensure your application remains as secure as possible. diff --git a/audit-resolve.json b/audit-resolve.json new file mode 100644 index 00000000000..da8434db1dd --- /dev/null +++ b/audit-resolve.json @@ -0,0 +1,46 @@ +{ + "decisions": { + "1112255|wasm-pack>binary-install>tar": { + "decision": "ignore", + "madeAt": 1768632226326, + "expiresAt": 1771224205911 + }, + "1112329|wasm-pack>binary-install>tar": { + "decision": "ignore", + "madeAt": 1768971958748, + "expiresAt": 1771563932286 + }, + "1112453|@chevrotain/cst-dts-gen>@chevrotain/gast>lodash-es": { + "decision": "ignore", + "madeAt": 1769058929105, + "expiresAt": 1771650881209 + }, + "1112453|@chevrotain/gast>lodash-es": { + "decision": "ignore", + "madeAt": 1769058929105, + "expiresAt": 1771650881209 + }, + "1112453|@mermaid-js/mermaid-cli>mermaid>@mermaid-js/parser>langium>chevrotain>@chevrotain/cst-dts-gen>@chevrotain/gast>lodash-es": { + "decision": "ignore", + "madeAt": 1769058929105, + "expiresAt": 1771650881209 + }, + "1112453|chevrotain-allstar>chevrotain>@chevrotain/cst-dts-gen>@chevrotain/gast>lodash-es": { + "decision": "ignore", + "madeAt": 1769058929105, + "expiresAt": 1771650881209 + }, + "1112455|lodash": { + "decision": "ignore", + "madeAt": 1769058974064, + "expiresAt": 1771650881209 + }, + "1112432|mocha>diff": { + "decision": "ignore", + "madeAt": 1769058983758, + "expiresAt": 1771650881209 + } + }, + "rules": {}, + "version": 1 +} diff --git a/browser/LICENSE.md b/browser/LICENSE.md new file mode 100644 index 00000000000..82cd357f8fb --- /dev/null +++ b/browser/LICENSE.md @@ -0,0 +1,163 @@ +# Rollup core license +Rollup is released under the MIT license: + +The MIT License (MIT) + +Copyright (c) 2017 [these people](https://github.com/rollup/rollup/graphs/contributors) + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +# Licenses of bundled dependencies +The published Rollup artifact additionally contains code with the following licenses: +MIT + +# Bundled dependencies: +## @jridgewell/sourcemap-codec +License: MIT +By: Justin Ridgewell +Repository: git+https://github.com/jridgewell/sourcemaps.git + +> Copyright 2024 Justin Ridgewell +> +> Permission is hereby granted, free of charge, to any person obtaining a copy +> of this software and associated documentation files (the "Software"), to deal +> in the Software without restriction, including without limitation the rights +> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +> copies of the Software, and to permit persons to whom the Software is +> furnished to do so, subject to the following conditions: +> +> The above copyright notice and this permission notice shall be included in +> all copies or substantial portions of the Software. +> +> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +> SOFTWARE. + +--------------------------------------- + +## @rollup/pluginutils +License: MIT +By: Rich Harris +Repository: rollup/plugins + +> The MIT License (MIT) +> +> Copyright (c) 2019 RollupJS Plugin Contributors (https://github.com/rollup/plugins/graphs/contributors) +> +> Permission is hereby granted, free of charge, to any person obtaining a copy +> of this software and associated documentation files (the "Software"), to deal +> in the Software without restriction, including without limitation the rights +> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +> copies of the Software, and to permit persons to whom the Software is +> furnished to do so, subject to the following conditions: +> +> The above copyright notice and this permission notice shall be included in +> all copies or substantial portions of the Software. +> +> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +> THE SOFTWARE. + +--------------------------------------- + +## builtin-modules +License: MIT +By: Sindre Sorhus +Repository: sindresorhus/builtin-modules + +> MIT License +> +> Copyright (c) Sindre Sorhus (https://sindresorhus.com) +> +> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: +> +> The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. +> +> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +--------------------------------------- + +## flru +License: MIT +By: Luke Edwards +Repository: lukeed/flru + +> MIT License +> +> Copyright (c) Luke Edwards (lukeed.com) +> +> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: +> +> The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. +> +> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +--------------------------------------- + +## is-reference +License: MIT +By: Rich Harris +Repository: git+https://github.com/Rich-Harris/is-reference.git + +--------------------------------------- + +## locate-character +License: MIT +By: Rich Harris +Repository: git+https://gitlab.com/Rich-Harris/locate-character.git + +--------------------------------------- + +## magic-string +License: MIT +By: Rich Harris +Repository: git+https://github.com/Rich-Harris/magic-string.git + +> Copyright 2018 Rich Harris +> +> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: +> +> The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. +> +> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +--------------------------------------- + +## picomatch +License: MIT +By: Jon Schlinkert +Repository: micromatch/picomatch + +> The MIT License (MIT) +> +> Copyright (c) 2017-present, Jon Schlinkert. +> +> Permission is hereby granted, free of charge, to any person obtaining a copy +> of this software and associated documentation files (the "Software"), to deal +> in the Software without restriction, including without limitation the rights +> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +> copies of the Software, and to permit persons to whom the Software is +> furnished to do so, subject to the following conditions: +> +> The above copyright notice and this permission notice shall be included in +> all copies or substantial portions of the Software. +> +> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +> THE SOFTWARE. diff --git a/browser/crypto.ts b/browser/crypto.ts deleted file mode 100644 index 294dc57ff80..00000000000 --- a/browser/crypto.ts +++ /dev/null @@ -1,3 +0,0 @@ -import sha256 from 'hash.js/lib/hash/sha/256'; - -export const createHash = () => sha256(); diff --git a/browser/error.ts b/browser/error.ts deleted file mode 100644 index 31cf10ea52a..00000000000 --- a/browser/error.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { error } from '../src/utils/error'; - -export const throwNoFileSystem = (method: string) => (..._args: any[]): never => { - error({ - code: 'NO_FS_IN_BROWSER', - message: `Cannot access the file system (via "${method}") when using the browser build of Rollup. Make sure you supply a plugin with custom resolveId and load hooks to Rollup.`, - url: 'https://rollupjs.org/guide/en/#a-simple-example' - }); -}; diff --git a/browser/fs.ts b/browser/fs.ts deleted file mode 100644 index 31337a88016..00000000000 --- a/browser/fs.ts +++ /dev/null @@ -1,4 +0,0 @@ -import { throwNoFileSystem } from './error'; - -export const readFile = throwNoFileSystem('fs.readFile'); -export const writeFile = throwNoFileSystem('fs.writeFile'); diff --git a/browser/package.json b/browser/package.json new file mode 100644 index 00000000000..b34ab0a2a5e --- /dev/null +++ b/browser/package.json @@ -0,0 +1,43 @@ +{ + "name": "@rollup/browser", + "version": "4.56.0", + "description": "Next-generation ES module bundler browser build", + "main": "dist/rollup.browser.js", + "module": "dist/es/rollup.browser.js", + "types": "dist/rollup.browser.d.ts", + "repository": { + "type": "git", + "url": "git+https://github.com/rollup/rollup.git" + }, + "keywords": [ + "modules", + "bundler", + "bundling", + "es6", + "optimizer", + "browser" + ], + "license": "MIT", + "bugs": { + "url": "https://github.com/rollup/rollup/issues" + }, + "homepage": "https://rollupjs.org/", + "dependencies": { + "@types/estree": "1.0.8" + }, + "files": [ + "dist/**/*.wasm", + "dist/**/*.js", + "dist/*.d.ts", + "dist/es/package.json", + "dist/rollup.browser.js.map" + ], + "exports": { + ".": { + "types": "./dist/rollup.browser.d.ts", + "import": "./dist/es/rollup.browser.js", + "require": "./dist/rollup.browser.js" + }, + "./dist/*": "./dist/*" + } +} diff --git a/browser/path.ts b/browser/path.ts deleted file mode 100644 index 83884c209c9..00000000000 --- a/browser/path.ts +++ /dev/null @@ -1,85 +0,0 @@ -export const absolutePath = /^(?:\/|(?:[A-Za-z]:)?[\\|/])/; -export const relativePath = /^\.?\.\//; - -export function isAbsolute(path: string) { - return absolutePath.test(path); -} - -export function isRelative(path: string) { - return relativePath.test(path); -} - -export function normalize(path: string) { - return path.replace(/\\/g, '/'); -} - -export function basename(path: string) { - return path.split(/(\/|\\)/).pop(); -} - -export function dirname(path: string) { - const match = /(\/|\\)[^/\\]*$/.exec(path); - if (!match) return '.'; - - const dir = path.slice(0, -match[0].length); - - // If `dir` is the empty string, we're at root. - return dir ? dir : '/'; -} - -export function extname(path: string) { - const match = /\.[^.]+$/.exec(basename(path)!); - if (!match) return ''; - return match[0]; -} - -export function relative(from: string, to: string) { - const fromParts = from.split(/[/\\]/).filter(Boolean); - const toParts = to.split(/[/\\]/).filter(Boolean); - - if (fromParts[0] === '.') fromParts.shift(); - if (toParts[0] === '.') toParts.shift(); - - while (fromParts[0] && toParts[0] && fromParts[0] === toParts[0]) { - fromParts.shift(); - toParts.shift(); - } - - while (toParts[0] === '..' && fromParts.length > 0) { - toParts.shift(); - fromParts.pop(); - } - - while (fromParts.pop()) { - toParts.unshift('..'); - } - - return toParts.join('/'); -} - -export function resolve(...paths: string[]) { - const firstPathSegment = paths.shift(); - if (!firstPathSegment) { - return '/'; - } - let resolvedParts = firstPathSegment.split(/[/\\]/); - - for (const path of paths) { - if (isAbsolute(path)) { - resolvedParts = path.split(/[/\\]/); - } else { - const parts = path.split(/[/\\]/); - - while (parts[0] === '.' || parts[0] === '..') { - const part = parts.shift(); - if (part === '..') { - resolvedParts.pop(); - } - } - - resolvedParts.push.apply(resolvedParts, parts); - } - } - - return resolvedParts.join('/'); -} diff --git a/browser/resolveId.ts b/browser/resolveId.ts deleted file mode 100644 index 6f7fdd03be5..00000000000 --- a/browser/resolveId.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { CustomPluginOptions, Plugin, ResolvedId } from '../src/rollup/types'; -import { PluginDriver } from '../src/utils/PluginDriver'; -import { resolveIdViaPlugins } from '../src/utils/resolveIdViaPlugins'; -import { throwNoFileSystem } from './error'; - -export async function resolveId( - source: string, - importer: string | undefined, - _preserveSymlinks: boolean, - pluginDriver: PluginDriver, - moduleLoaderResolveId: ( - source: string, - importer: string | undefined, - customOptions: CustomPluginOptions | undefined, - skip: { importer: string | undefined; plugin: Plugin; source: string }[] | null - ) => Promise, - skip: { importer: string | undefined; plugin: Plugin; source: string }[] | null, - customOptions: CustomPluginOptions | undefined -) { - const pluginResult = await resolveIdViaPlugins(source, importer,pluginDriver, moduleLoaderResolveId, skip, customOptions); - if (pluginResult == null) { - throwNoFileSystem('path.resolve'); - } - return pluginResult; -} diff --git a/browser/src/error.ts b/browser/src/error.ts new file mode 100644 index 00000000000..da47d75016f --- /dev/null +++ b/browser/src/error.ts @@ -0,0 +1,4 @@ +import { error, logNoFileSystemInBrowser } from '../../src/utils/logs'; + +export const throwNoFileSystem = (method: string) => (): never => + error(logNoFileSystemInBrowser(method)); diff --git a/browser/src/fs.ts b/browser/src/fs.ts new file mode 100644 index 00000000000..46724349e8b --- /dev/null +++ b/browser/src/fs.ts @@ -0,0 +1,20 @@ +import type { RollupFsModule } from '../../src/rollup/types'; +import { throwNoFileSystem } from './error'; +import type * as FsType from './fs.ts'; + +// Ensure this satisfies the RollupFsModule API, will be removed by tree-shaking +void (null as unknown as typeof FsType satisfies RollupFsModule); + +export const appendFile = throwNoFileSystem('fs.appendFile'); +export const copyFile = throwNoFileSystem('fs.copyFile'); +export const mkdir = throwNoFileSystem('fs.mkdir'); +export const mkdtemp = throwNoFileSystem('fs.mkdtemp'); +export const readdir = throwNoFileSystem('fs.readdir'); +export const readFile = throwNoFileSystem('fs.readFile'); +export const realpath = throwNoFileSystem('fs.realpath'); +export const rename = throwNoFileSystem('fs.rename'); +export const rmdir = throwNoFileSystem('fs.rmdir'); +export const stat = throwNoFileSystem('fs.stat'); +export const lstat = throwNoFileSystem('fs.lstat'); +export const unlink = throwNoFileSystem('fs.unlink'); +export const writeFile = throwNoFileSystem('fs.writeFile'); diff --git a/browser/src/hookActions.ts b/browser/src/hookActions.ts new file mode 100644 index 00000000000..676700b0773 --- /dev/null +++ b/browser/src/hookActions.ts @@ -0,0 +1,8 @@ +import type { PluginDriver } from '../../src/utils/PluginDriver'; + +export function catchUnfinishedHookActions( + _pluginDriver: PluginDriver, + callback: () => Promise +): Promise { + return callback(); +} diff --git a/browser/src/initWasm.ts b/browser/src/initWasm.ts new file mode 100644 index 00000000000..c3933252150 --- /dev/null +++ b/browser/src/initWasm.ts @@ -0,0 +1,5 @@ +import init from '../../wasm/bindings_wasm'; + +export default async function initWasm() { + await init(); +} diff --git a/browser/src/path.ts b/browser/src/path.ts new file mode 100644 index 00000000000..65b1d4a1284 --- /dev/null +++ b/browser/src/path.ts @@ -0,0 +1,91 @@ +const ABSOLUTE_PATH_REGEX = /^(?:\/|(?:[A-Za-z]:)?[/\\|])/; +const RELATIVE_PATH_REGEX = /^\.?\.\//; +const ALL_BACKSLASHES_REGEX = /\\/g; +const ANY_SLASH_REGEX = /[/\\]/; +const EXTNAME_REGEX = /\.[^.]+$/; + +export function isAbsolute(path: string): boolean { + return ABSOLUTE_PATH_REGEX.test(path); +} + +export function isRelative(path: string): boolean { + return RELATIVE_PATH_REGEX.test(path); +} + +export function normalize(path: string): string { + return path.replace(ALL_BACKSLASHES_REGEX, '/'); +} + +export function basename(path: string): string { + return path.split(ANY_SLASH_REGEX).pop() || ''; +} + +export function dirname(path: string): string { + const match = /[/\\][^/\\]*$/.exec(path); + if (!match) return '.'; + + const directory = path.slice(0, -match[0].length); + + // If `directory` is the empty string, we're at root. + return directory || '/'; +} + +export function extname(path: string): string { + const match = EXTNAME_REGEX.exec(basename(path)!); + return match ? match[0] : ''; +} + +export function relative(from: string, to: string): string { + const fromParts = from.split(ANY_SLASH_REGEX).filter(Boolean); + const toParts = to.split(ANY_SLASH_REGEX).filter(Boolean); + + if (fromParts[0] === '.') fromParts.shift(); + if (toParts[0] === '.') toParts.shift(); + + while (fromParts[0] && toParts[0] && fromParts[0] === toParts[0]) { + fromParts.shift(); + toParts.shift(); + } + + while (toParts[0] === '..' && fromParts.length > 0) { + toParts.shift(); + fromParts.pop(); + } + + while (fromParts.pop()) { + toParts.unshift('..'); + } + + return toParts.join('/'); +} + +export function resolve(...paths: string[]): string { + const firstPathSegment = paths.shift(); + if (!firstPathSegment) { + return '/'; + } + let resolvedParts = firstPathSegment.split(ANY_SLASH_REGEX); + + for (const path of paths) { + if (isAbsolute(path)) { + resolvedParts = path.split(ANY_SLASH_REGEX); + } else { + const parts = path.split(ANY_SLASH_REGEX); + + while (parts[0] === '.' || parts[0] === '..') { + const part = parts.shift(); + if (part === '..') { + resolvedParts.pop(); + } + } + + resolvedParts.push(...parts); + } + } + + return resolvedParts.join('/'); +} + +// Used for running the browser build locally in Vite +export const win32 = {}; +export const posix = {}; diff --git a/browser/src/performance.ts b/browser/src/performance.ts new file mode 100644 index 00000000000..c9aebffc375 --- /dev/null +++ b/browser/src/performance.ts @@ -0,0 +1,10 @@ +const global = + typeof globalThis === 'undefined' ? (typeof window === 'undefined' ? {} : window) : globalThis; + +export default 'performance' in global + ? performance + : { + now(): 0 { + return 0; + } + }; diff --git a/browser/src/process.ts b/browser/src/process.ts new file mode 100644 index 00000000000..a526f24c035 --- /dev/null +++ b/browser/src/process.ts @@ -0,0 +1,11 @@ +interface MemoryUsage { + heapUsed: 0; +} + +export default { + memoryUsage(): MemoryUsage { + return { + heapUsed: 0 + }; + } +}; diff --git a/browser/src/wasm.ts b/browser/src/wasm.ts new file mode 100644 index 00000000000..afc48773f6d --- /dev/null +++ b/browser/src/wasm.ts @@ -0,0 +1,12 @@ +export { parse, xxhashBase16, xxhashBase36, xxhashBase64Url } from '../../wasm/bindings_wasm.js'; + +import { parse } from '../../wasm/bindings_wasm.js'; + +export async function parseAsync( + code: string, + allowReturnOutsideFunction: boolean, + jsx: boolean, + _signal?: AbortSignal | undefined | null +) { + return parse(code, allowReturnOutsideFunction, jsx); +} diff --git a/build-plugins/add-cli-entry.js b/build-plugins/add-cli-entry.js deleted file mode 100644 index 9d9c681b675..00000000000 --- a/build-plugins/add-cli-entry.js +++ /dev/null @@ -1,22 +0,0 @@ -import MagicString from 'magic-string'; - -export default function addCliEntry() { - return { - name: 'add-cli-entry', - buildStart() { - this.emitFile({ - type: 'chunk', - id: 'cli/cli.ts', - fileName: 'bin/rollup', - preserveSignature: false - }); - }, - renderChunk(code, chunkInfo) { - if (chunkInfo.fileName === 'bin/rollup') { - const magicString = new MagicString(code); - magicString.prepend('#!/usr/bin/env node\n\n'); - return { code: magicString.toString(), map: magicString.generateMap({ hires: true }) }; - } - } - }; -} diff --git a/build-plugins/add-cli-entry.ts b/build-plugins/add-cli-entry.ts new file mode 100644 index 00000000000..907e25b06b4 --- /dev/null +++ b/build-plugins/add-cli-entry.ts @@ -0,0 +1,22 @@ +import { chmod } from 'node:fs/promises'; +import path from 'node:path'; +import type { Plugin } from 'rollup'; + +const CLI_CHUNK = 'bin/rollup'; + +export default function addCliEntry(): Plugin { + return { + buildStart() { + this.emitFile({ + fileName: CLI_CHUNK, + id: 'cli/cli.ts', + preserveSignature: false, + type: 'chunk' + }); + }, + name: 'add-cli-entry', + writeBundle({ dir }) { + return chmod(path.resolve(dir!, CLI_CHUNK), '755'); + } + }; +} diff --git a/build-plugins/aliases.ts b/build-plugins/aliases.ts new file mode 100644 index 00000000000..85a59dc4a2e --- /dev/null +++ b/build-plugins/aliases.ts @@ -0,0 +1,9 @@ +import { fileURLToPath } from 'node:url'; + +export const moduleAliases = { + entries: { + 'help.md': fileURLToPath(new URL('../cli/help.md', import.meta.url)), + 'package.json': fileURLToPath(new URL('../package.json', import.meta.url)) + }, + resolve: ['.js', '.json', '.md'] +}; diff --git a/build-plugins/clean-before-write.ts b/build-plugins/clean-before-write.ts new file mode 100644 index 00000000000..352ec2248f4 --- /dev/null +++ b/build-plugins/clean-before-write.ts @@ -0,0 +1,19 @@ +import { rm } from 'node:fs/promises'; +import type { Plugin } from 'rollup'; + +export default function cleanBeforeWrite(directory: string): Plugin { + let removePromise: Promise; + return { + generateBundle(_options, _bundle, isWrite) { + if (isWrite) { + // Only remove before first write, but make all writes wait on the removal + removePromise ??= rm(directory, { + force: true, + recursive: true + }); + return removePromise; + } + }, + name: 'clean-before-write' + }; +} diff --git a/build-plugins/conditional-fsevents-import.js b/build-plugins/conditional-fsevents-import.js deleted file mode 100644 index 8960e7e792b..00000000000 --- a/build-plugins/conditional-fsevents-import.js +++ /dev/null @@ -1,32 +0,0 @@ -import MagicString from 'magic-string'; - -const FSEVENTS_REQUIRE = "require('fsevents')"; -const REPLACEMENT = "require('../../../src/watch/fsevents-importer').getFsEvents()"; - -export default function conditionalFsEventsImport() { - let transformed = false; - return { - name: 'conditional-fs-events-import', - transform(code, id) { - if (id.endsWith('fsevents-handler.js')) { - transformed = true; - const requireStatementPos = code.indexOf(FSEVENTS_REQUIRE); - if (requireStatementPos < 0) { - throw new Error(`Could not find expected fsevents import "${FSEVENTS_REQUIRE}"`); - } - const magicString = new MagicString(code); - magicString.overwrite( - requireStatementPos, - requireStatementPos + FSEVENTS_REQUIRE.length, - REPLACEMENT - ); - return { code: magicString.toString(), map: magicString.generateMap({ hires: true }) }; - } - }, - buildEnd(error) { - if (!(error || transformed)) { - throw new Error('Could not find "fsevents-handler.js", was the file renamed?'); - } - } - }; -} diff --git a/build-plugins/copy-types.ts b/build-plugins/copy-types.ts new file mode 100644 index 00000000000..b9e5e7be3f1 --- /dev/null +++ b/build-plugins/copy-types.ts @@ -0,0 +1,39 @@ +import { readFile } from 'node:fs/promises'; +import path from 'node:path'; +import type { Plugin } from 'rollup'; + +function copyRollupType( + fileName: string, + inputFile = 'src/rollup/types.d.ts', + rollupImportPath?: string +): Plugin { + return { + async generateBundle(_options, _bundle, isWrite) { + if (isWrite) { + let source = await readFile(path.resolve(inputFile), 'utf8'); + if (rollupImportPath) { + source = source.replace(rollupImportPath, './rollup'); + } + this.emitFile({ fileName, source, type: 'asset' }); + } + }, + name: 'copy-rollup-type' + }; +} + +export function copyBrowserTypes(): Plugin { + return copyRollupType('rollup.browser.d.ts'); +} + +export function copyNodeTypes(): Plugin[] { + return [ + copyRollupType('rollup.d.ts'), + copyRollupType( + 'loadConfigFile.d.ts', + 'cli/run/loadConfigFileType.d.ts', + '../../src/rollup/types' + ), + copyRollupType('getLogFilter.d.ts', 'src/utils/getLogFilterType.d.ts', '../rollup/types'), + copyRollupType('parseAst.d.ts', 'src/utils/parseAstType.d.ts', '../rollup/types') + ]; +} diff --git a/build-plugins/emit-module-package-file.js b/build-plugins/emit-module-package-file.js deleted file mode 100644 index 0cdf130a02a..00000000000 --- a/build-plugins/emit-module-package-file.js +++ /dev/null @@ -1,8 +0,0 @@ -export default function emitModulePackageFile() { - return { - name: 'emit-module-package-file', - generateBundle() { - this.emitFile({ type: 'asset', fileName: 'package.json', source: `{"type":"module"}` }); - } - }; -} diff --git a/build-plugins/emit-module-package-file.ts b/build-plugins/emit-module-package-file.ts new file mode 100644 index 00000000000..0ae9d3659f3 --- /dev/null +++ b/build-plugins/emit-module-package-file.ts @@ -0,0 +1,10 @@ +import type { Plugin } from 'rollup'; + +export default function emitModulePackageFile(): Plugin { + return { + generateBundle() { + this.emitFile({ fileName: 'package.json', source: `{"type":"module"}`, type: 'asset' }); + }, + name: 'emit-module-package-file' + }; +} diff --git a/build-plugins/emit-native-entry.ts b/build-plugins/emit-native-entry.ts new file mode 100644 index 00000000000..8b4e0ffa651 --- /dev/null +++ b/build-plugins/emit-native-entry.ts @@ -0,0 +1,15 @@ +import { readFile } from 'node:fs/promises'; +import type { Plugin } from 'rollup'; + +export function emitNativeEntry(): Plugin { + return { + async generateBundle() { + this.emitFile({ + fileName: 'native.js', + source: await readFile(new URL('../native.js', import.meta.url)), + type: 'asset' + }); + }, + name: 'emit-native-entry' + }; +} diff --git a/build-plugins/emit-wasm-file.ts b/build-plugins/emit-wasm-file.ts new file mode 100644 index 00000000000..713f637c07d --- /dev/null +++ b/build-plugins/emit-wasm-file.ts @@ -0,0 +1,15 @@ +import fs from 'node:fs/promises'; +import type { Plugin } from 'rollup'; + +export default function emitWasmFile(): Plugin { + return { + async generateBundle() { + this.emitFile({ + fileName: 'bindings_wasm_bg.wasm', + source: await fs.readFile('wasm/bindings_wasm_bg.wasm'), + type: 'asset' + }); + }, + name: 'emit-wasm-file' + }; +} diff --git a/build-plugins/esm-dynamic-import.js b/build-plugins/esm-dynamic-import.js deleted file mode 100644 index 5bc8b8ea444..00000000000 --- a/build-plugins/esm-dynamic-import.js +++ /dev/null @@ -1,19 +0,0 @@ -export default function addBinShebangAndEsmImport() { - let importFound = false; - return { - name: 'esm-dynamic-import', - renderDynamicImport({ moduleId }) { - importFound = true; - if (moduleId.endsWith('loadConfigFile.ts')) { - return { left: 'import(', right: ')' }; - } - }, - generateBundle() { - if (!importFound) { - throw new Error( - 'Could not find dynamic import in "loadConfigFile.ts", was the file renamed?' - ); - } - } - }; -} diff --git a/build-plugins/esm-dynamic-import.ts b/build-plugins/esm-dynamic-import.ts new file mode 100644 index 00000000000..956310aa046 --- /dev/null +++ b/build-plugins/esm-dynamic-import.ts @@ -0,0 +1,26 @@ +import type { Plugin } from 'rollup'; + +const expectedImports = 3; + +export default function esmDynamicImport(): Plugin { + let importsFound = 0; + return { + generateBundle() { + if (importsFound !== expectedImports) { + throw new Error( + `Could not find ${expectedImports} dynamic imports in "loadConfigFile.ts" and "commandPlugin.ts", found ${importsFound}.` + ); + } + }, + name: 'esm-dynamic-import', + renderDynamicImport({ moduleId }) { + if (moduleId.endsWith('commandPlugins.ts') || moduleId.endsWith('loadConfigFile.ts')) { + importsFound++; + return { left: 'import(', right: ')' }; + } + }, + renderStart() { + importsFound = 0; + } + }; +} diff --git a/build-plugins/external-native-import.ts b/build-plugins/external-native-import.ts new file mode 100644 index 00000000000..842dfddc96b --- /dev/null +++ b/build-plugins/external-native-import.ts @@ -0,0 +1,17 @@ +import type { Plugin } from 'rollup'; + +export function externalNativeImport(): Plugin { + return { + name: 'external-native-import', + async resolveId(id, importer) { + if (id.includes('/native')) { + const resolved = await this.resolve(id, importer!, { skipSelf: true }); + const resolvedId = resolved!.id; + return { + external: 'relative', + id: resolvedId.endsWith('.js') ? resolvedId : `${resolvedId}.js` + }; + } + } + }; +} diff --git a/build-plugins/fs-events-replacement.ts b/build-plugins/fs-events-replacement.ts new file mode 100644 index 00000000000..0b8d118d1c7 --- /dev/null +++ b/build-plugins/fs-events-replacement.ts @@ -0,0 +1,31 @@ +import type { RollupReplaceOptions } from '@rollup/plugin-replace'; +import { readFile } from 'node:fs/promises'; +import { exit } from 'node:process'; + +const FSEVENTS_HANDLER = 'node_modules/chokidar/lib/fsevents-handler.js'; +const FSEVENTS_REQUIRE = "require('fsevents')"; +const FSEVENTS_REQUIRE_REPLACEMENT = + "require('../../../src/watch/fsevents-importer').getFsEvents()"; + +let fileContent: string; + +try { + fileContent = await readFile(FSEVENTS_HANDLER, 'utf8'); +} catch { + console.error(`Could not find "${FSEVENTS_HANDLER}".`); + exit(1); +} + +if (!fileContent.includes(FSEVENTS_REQUIRE)) { + console.error(`Could not find expected fsevents import "${FSEVENTS_REQUIRE}"`); + exit(1); +} + +export const fsEventsReplacement: RollupReplaceOptions = { + delimiters: ['', ''], + include: FSEVENTS_HANDLER, + preventAssignment: true, // defaults to true in next major version of plugin + values: { + [FSEVENTS_REQUIRE]: FSEVENTS_REQUIRE_REPLACEMENT + } +}; diff --git a/build-plugins/generate-license-file.js b/build-plugins/generate-license-file.js deleted file mode 100644 index 8073cf1476e..00000000000 --- a/build-plugins/generate-license-file.js +++ /dev/null @@ -1,80 +0,0 @@ -import fs from 'fs'; -import license from 'rollup-plugin-license'; - -function generateLicenseFile(dependencies) { - const coreLicense = fs.readFileSync('LICENSE-CORE.md'); - const licenses = new Set(); - const dependencyLicenseTexts = dependencies - .sort(({ name: nameA }, { name: nameB }) => (nameA > nameB ? 1 : -1)) - .map(({ name, license, licenseText, author, maintainers, contributors, repository }) => { - let text = `## ${name}\n`; - if (license) { - text += `License: ${license}\n`; - } - const names = new Set(); - if (author && author.name) { - names.add(author.name); - } - for (const person of maintainers.concat(contributors)) { - if (person && person.name) { - names.add(person.name); - } - } - if (names.size > 0) { - text += `By: ${Array.from(names).join(', ')}\n`; - } - if (repository) { - text += `Repository: ${repository.url || repository}\n`; - } - if (licenseText) { - text += - '\n' + - licenseText - .trim() - .replace(/(\r\n|\r)/gm, '\n') - .split('\n') - .map(line => `> ${line}`) - .join('\n') + - '\n'; - } - licenses.add(license); - return text; - }) - .join('\n---------------------------------------\n\n'); - const licenseText = - `# Rollup core license\n` + - `Rollup is released under the MIT license:\n\n` + - coreLicense + - `\n# Licenses of bundled dependencies\n` + - `The published Rollup artifact additionally contains code with the following licenses:\n` + - `${Array.from(licenses).join(', ')}\n\n` + - `# Bundled dependencies:\n` + - dependencyLicenseTexts; - const existingLicenseText = fs.readFileSync('LICENSE.md', 'utf8'); - if (existingLicenseText !== licenseText) { - fs.writeFileSync('LICENSE.md', licenseText); - console.warn('LICENSE.md updated. You should commit the updated file.'); - } -} - -export default function getLicenseHandler() { - const licenses = new Map(); - return { - collectLicenses() { - function addLicenses(dependencies) { - for (const dependency of dependencies) { - licenses.set(dependency.name, dependency); - } - } - - return license({ thirdParty: addLicenses }); - }, - writeLicense() { - return { - writeBundle() { - generateLicenseFile(Array.from(licenses.values())); - } - }; - } - }; -} diff --git a/build-plugins/generate-license-file.ts b/build-plugins/generate-license-file.ts new file mode 100644 index 00000000000..1b94cec4e02 --- /dev/null +++ b/build-plugins/generate-license-file.ts @@ -0,0 +1,93 @@ +import { readFile, writeFile } from 'node:fs/promises'; +import path from 'node:path'; +import type { PluginImpl } from 'rollup'; +import license, { type Dependency, type Person } from 'rollup-plugin-license'; + +async function generateLicenseFile( + directory: string, + dependencies: readonly Dependency[] +): Promise { + const coreLicense = await readFile('LICENSE-CORE.md', 'utf8'); + const licenses = new Set(); + const dependencyLicenseTexts = [...dependencies] + .filter(({ name }) => name !== '@rollup/browser') + .sort(({ name: nameA }, { name: nameB }) => (nameA! > nameB! ? 1 : -1)) + .map(({ name, license, licenseText, author, maintainers, contributors, repository }) => { + let text = `## ${name}\n`; + if (license) { + text += `License: ${license}\n`; + } + const names = new Set(); + if (author?.name) { + names.add(author.name); + } + // TODO there is an inconsistency in the rollup-plugin-license types + for (const person of [...contributors, ...(maintainers as unknown as Person[])]) { + if (person?.name) { + names.add(person.name); + } + } + if (names.size > 0) { + text += `By: ${[...names].join(', ')}\n`; + } + if (repository) { + text += `Repository: ${(typeof repository === 'object' && repository.url) || repository}\n`; + } + if (licenseText) { + text += + '\n' + + licenseText + .trim() + .replace(/(\r\n|\r)/gm, '\n') + .split('\n') + .map(line => `> ${line}`) + .join('\n') + + '\n'; + } + licenses.add(license!); + return text; + }) + .join('\n---------------------------------------\n\n'); + const licenseText = + `# Rollup core license\n` + + `Rollup is released under the MIT license:\n\n` + + coreLicense + + `\n# Licenses of bundled dependencies\n` + + `The published Rollup artifact additionally contains code with the following licenses:\n` + + `${[...licenses].join(', ')}\n\n` + + `# Bundled dependencies:\n` + + dependencyLicenseTexts; + const licenseFile = path.join(directory, 'LICENSE.md'); + const existingLicenseText = await readFile(licenseFile, 'utf8'); + if (existingLicenseText !== licenseText) { + await writeFile(licenseFile, licenseText); + console.warn('LICENSE.md updated. You should commit the updated file.'); + } +} + +interface LicenseHandler { + collectLicenses: PluginImpl; + writeLicense: PluginImpl; +} + +export default function getLicenseHandler(directory: string): LicenseHandler { + const licenses = new Map(); + function addLicenses(dependencies: readonly Dependency[]) { + for (const dependency of dependencies) { + licenses.set(dependency.name!, dependency); + } + } + return { + collectLicenses() { + return license({ thirdParty: addLicenses }); + }, + writeLicense() { + return { + name: 'write-license', + writeBundle() { + return generateLicenseFile(directory, [...licenses.values()]); + } + }; + } + }; +} diff --git a/build-plugins/get-banner.ts b/build-plugins/get-banner.ts new file mode 100644 index 00000000000..2e98867c1cb --- /dev/null +++ b/build-plugins/get-banner.ts @@ -0,0 +1,36 @@ +import { exec } from 'node:child_process'; +import { readFile } from 'node:fs/promises'; +import { env } from 'node:process'; +import { promisify } from 'node:util'; + +const execPromise = promisify(exec); + +function generateBanner(commitHash: string, version: string): string { + const date = new Date( + env.SOURCE_DATE_EPOCH ? 1000 * +env.SOURCE_DATE_EPOCH : Date.now() + ).toUTCString(); + + return `/* + @license + Rollup.js v${version} + ${date} - commit ${commitHash} + + https://github.com/rollup/rollup + + Released under the MIT License. +*/`; +} + +let getBannerPromise: Promise | null = null; + +export default function getBanner(): Promise { + return (getBannerPromise ||= Promise.all([ + execPromise('git rev-parse HEAD') + .then(({ stdout }) => stdout.trim()) + .catch(error => { + console.error('Could not determine commit hash:', error); + return 'unknown'; + }), + readFile(new URL('../package.json', import.meta.url), 'utf8') + ]).then(([commit, package_]) => generateBanner(commit, JSON.parse(package_).version))); +} diff --git a/build-plugins/load-cli-help.ts b/build-plugins/load-cli-help.ts new file mode 100644 index 00000000000..ab4d3233663 --- /dev/null +++ b/build-plugins/load-cli-help.ts @@ -0,0 +1,21 @@ +import { readFile } from 'node:fs/promises'; +import type { Plugin } from 'rollup'; + +export default function loadCliHelp(): Plugin { + return { + async load(id) { + if (id.endsWith('help.md')) { + const [rawHelpFile, packageFile] = await Promise.all([ + readFile(id, 'utf8'), + readFile(new URL('../package.json', import.meta.url), 'utf8') + ]); + const finalHelpFile = rawHelpFile + .replaceAll(/^\/\/\s*#(end)?region[^\n]*\n/gm, '') + .replace('__VERSION__', JSON.parse(packageFile).version); + return `export default ${JSON.stringify(finalHelpFile)};`; + } + return null; + }, + name: 'load-cli-help' + }; +} diff --git a/build-plugins/replace-browser-modules.js b/build-plugins/replace-browser-modules.js deleted file mode 100644 index 9e004c5ffd9..00000000000 --- a/build-plugins/replace-browser-modules.js +++ /dev/null @@ -1,27 +0,0 @@ -import path from 'path'; - -const ID_CRYPTO = path.resolve('src/utils/crypto'); -const ID_FS = path.resolve('src/utils/fs'); -const ID_PATH = path.resolve('src/utils/path'); -const ID_RESOLVEID = path.resolve('src/utils/resolveId'); - -export default function replaceBrowserModules() { - return { - name: 'replace-browser-modules', - resolveId: (source, importee) => { - if (importee && source[0] === '.') { - const resolved = path.join(path.dirname(importee), source); - switch (resolved) { - case ID_CRYPTO: - return path.resolve('browser/crypto.ts'); - case ID_FS: - return path.resolve('browser/fs.ts'); - case ID_PATH: - return path.resolve('browser/path.ts'); - case ID_RESOLVEID: - return path.resolve('browser/resolveId.ts'); - } - } - } - }; -} diff --git a/build-plugins/replace-browser-modules.ts b/build-plugins/replace-browser-modules.ts new file mode 100644 index 00000000000..84a59f85ad2 --- /dev/null +++ b/build-plugins/replace-browser-modules.ts @@ -0,0 +1,41 @@ +import path from 'node:path'; +import { fileURLToPath } from 'node:url'; +import type { Plugin as RollupPlugin } from 'rollup'; +import type { Plugin } from 'vite'; + +const resolve = (path: string) => fileURLToPath(new URL(`../${path}`, import.meta.url)); + +const JS_REPLACED_MODULES = ['fs', 'hookActions', 'path', 'performance', 'process', 'initWasm']; + +type ModulesMap = [string, string][]; + +const jsModulesMap: ModulesMap = JS_REPLACED_MODULES.flatMap(module => { + const originalId = resolve(`src/utils/${module}`); + const replacementId = resolve(`browser/src/${module}.ts`); + return [ + [originalId, replacementId], + [`${originalId}.ts`, replacementId] + ]; +}); + +const wasmModulesMap: ModulesMap = [[resolve('native'), resolve('browser/src/wasm.ts')]]; + +const resolutions: ReadonlyMap = new Map([...jsModulesMap, ...wasmModulesMap]); + +export default function replaceBrowserModules(): Plugin & RollupPlugin { + return { + apply: 'serve', + enforce: 'pre', + name: 'replace-browser-modules', + resolveId(source: string, importer: string | undefined) { + if (importer && source[0] === '.') { + return resolutions.get(path.join(path.dirname(importer), source)); + } + }, + transformIndexHtml(html) { + // Unfortunately, picomatch sneaks as a dependency into the dev bundle. + // This fixes an error. + return html.replace('', ''); + } + }; +} diff --git a/cli/cli.ts b/cli/cli.ts index 43453e7cc2f..87a9e339263 100644 --- a/cli/cli.ts +++ b/cli/cli.ts @@ -1,4 +1,6 @@ +#!/usr/bin/env node import help from 'help.md'; +import process from 'node:process'; import { version } from 'package.json'; import argParser from 'yargs-parser'; import { commandAliases } from '../src/utils/options/mergeOptions'; @@ -10,15 +12,19 @@ const command = argParser(process.argv.slice(2), { }); if (command.help || (process.argv.length <= 2 && process.stdin.isTTY)) { - console.log(`\n${help.replace('__VERSION__', version)}\n`); + console.log(`\n${help}\n`); } else if (command.version) { console.log(`rollup v${version}`); } else { try { + // eslint-disable-next-line @typescript-eslint/no-require-imports require('source-map-support').install(); - } catch (err) { + } catch { // do nothing } - run(command); + const promise = run(command); + if (command.forceExit) { + promise.then(() => process.exit()); + } } diff --git a/cli/help.md b/cli/help.md index b6b853dc50b..c042bdd359a 100644 --- a/cli/help.md +++ b/cli/help.md @@ -3,10 +3,13 @@ rollup version __VERSION__ Usage: rollup [options] -Basic options: +Options: +// #region options -c, --config Use this config file (if argument is used but value - is unspecified, defaults to rollup.config.js) + is unspecified, Rollup will try to load configuration files in + the following order: + rollup.config.mjs -> rollup.config.cjs -> rollup.config.js) -d, --dir Directory for chunks (if absent, prints to stdout) -e, --external Comma-separate list of module IDs to exclude -f, --format Type of output (amd, cjs, es, iife, umd, system) @@ -19,60 +22,90 @@ Basic options: -p, --plugin Use the plugin specified (may be repeated) -v, --version Show version number -w, --watch Watch files in bundle and rebuild on changes ---amd.id ID for AMD module (default is anonymous) --amd.autoId Generate the AMD ID based off the chunk name --amd.basePath Path to prepend to auto generated AMD ID --amd.define Function to use in place of `define` +--amd.forceJsExtensionForImports Use `.js` extension in AMD imports +--amd.id ID for AMD module (default is anonymous) --assetFileNames Name pattern for emitted assets --banner Code to insert at top of bundle (outside wrapper) --chunkFileNames Name pattern for emitted secondary chunks --compact Minify wrapper code --context Specify top-level `this` value +--no-dynamicImportInCjs Write external dynamic CommonJS imports as require --entryFileNames Name pattern for emitted entry chunks --environment Settings passed to config file (see example) --no-esModule Do not add __esModule property --exports Specify export mode (auto, default, named, none) --extend Extend global variable defined by --name +--no-externalImportAttributes Omit import attributes in "es" output --no-externalLiveBindings Do not generate code to support live bindings --failAfterWarnings Exit with an error if the build produced warnings +--filterLogs Filter log messages --footer Code to insert at end of bundle (outside wrapper) +--forceExit Force exit the process when done --no-freeze Do not freeze namespace objects +--generatedCode Which code features to use (es5/es2015) +--generatedCode.arrowFunctions Use arrow functions in generated code +--generatedCode.constBindings Use "const" in generated code +--generatedCode.objectShorthand Use shorthand properties in generated code +--no-generatedCode.reservedNamesAsProps Always quote reserved names as props +--generatedCode.symbols Use symbols in generated code +--hashCharacters Use the specified character set for file hashes --no-hoistTransitiveImports Do not hoist transitive imports into entry chunks +--importAttributesKey Use the specified keyword for import attributes --no-indent Don't indent result ---no-interop Do not include interop block --inlineDynamicImports Create single bundle when using dynamic imports +--no-interop Do not include interop block --intro Code to insert at top of bundle (inside wrapper) +--logLevel Which kind of logs to display +--no-makeAbsoluteExternalsRelative Prevent normalization of external imports +--maxParallelFileOps How many files to read in parallel --minifyInternalExports Force or disable minification of internal exports ---namespaceToStringTag Create proper `.toString` methods for namespaces --noConflict Generate a noConflict method for UMD globals --outro Code to insert at end of bundle (inside wrapper) ---preferConst Use `const` instead of `var` for exports +--perf Display performance timings --no-preserveEntrySignatures Avoid facade chunks for entry points --preserveModules Preserve module structure --preserveModulesRoot Put preserved modules under this path at root level --preserveSymlinks Do not follow symlinks when resolving files +--no-reexportProtoFromExternal Ignore `__proto__` in star re-exports +--no-sanitizeFileName Do not replace invalid characters in file names --shimMissingExports Create shim variables for missing exports --silent Don't print warnings +--sourcemapBaseUrl Emit absolute sourcemap URLs with given base +--sourcemapDebugIds Emit unique debug ids in source and sourcemaps --sourcemapExcludeSources Do not include source code in source maps --sourcemapFile Specify bundle position for source maps +--sourcemapFileNames Name pattern for emitted sourcemaps --stdin=ext Specify file extension used for stdin input --no-stdin Do not read "-" from stdin --no-strict Don't emit `"use strict";` in the generated modules --strictDeprecations Throw errors for deprecated features ---systemNullSetters Replace empty SystemJS setters with `null` +--no-systemNullSetters Do not replace empty SystemJS setters with `null` --no-treeshake Disable tree-shaking optimisations --no-treeshake.annotations Ignore pure call annotations ---no-treeshake.moduleSideEffects Assume modules have no side-effects ---no-treeshake.propertyReadSideEffects Ignore property access side-effects +--treeshake.correctVarValueBeforeDeclaration Deoptimize variables until declared +--treeshake.manualPureFunctions Manually declare functions as pure +--no-treeshake.moduleSideEffects Assume modules have no side effects +--no-treeshake.propertyReadSideEffects Ignore property access side effects --no-treeshake.tryCatchDeoptimization Do not turn off try-catch-tree-shaking --no-treeshake.unknownGlobalSideEffects Assume unknown globals do not throw +--validate Validate output --waitForBundleInput Wait for bundle input files +--watch.allowInputInsideOutputPath Whether the input path is allowed to be a + subpath of the output path --watch.buildDelay Throttle watch rebuilds --no-watch.clearScreen Do not clear the screen when rebuilding ---watch.skipWrite Do not write files to disk when watching --watch.exclude Exclude files from being watched --watch.include Limit watching to specified files ---validate Validate output +--watch.onBundleEnd Shell command to run on `"BUNDLE_END"` event +--watch.onBundleStart Shell command to run on `"BUNDLE_START"` event +--watch.onEnd Shell command to run on `"END"` event +--watch.onError Shell command to run on `"ERROR"` event +--watch.onStart Shell command to run on `"START"` event +--watch.skipWrite Do not write files to disk when watching +// #endregion options Examples: diff --git a/cli/logging.ts b/cli/logging.ts index 329db43e11f..58cb474f589 100644 --- a/cli/logging.ts +++ b/cli/logging.ts @@ -1,42 +1,59 @@ -import { bold, cyan, dim, options, red } from 'colorette'; -import { RollupError } from '../src/rollup/types'; +import process from 'node:process'; +import type { RollupError } from '../src/rollup/types'; +import { bold, cyan, dim, red } from '../src/utils/colors'; import relativeId from '../src/utils/relativeId'; -// @see https://no-color.org -// @see https://www.npmjs.com/package/chalk -if (process.env.FORCE_COLOR === '0' || process.env.NO_COLOR) { - options.enabled = false; -} - // log to stderr to keep `rollup main.js > bundle.js` from breaking -export const stderr = console.error.bind(console); +export const stderr = (...parameters: readonly unknown[]) => + process.stderr.write(`${parameters.join('')}\n`); -export function handleError(err: RollupError, recover = false) { - let description = err.message || err; - if (err.name) description = `${err.name}: ${description}`; - const message = (err.plugin ? `(plugin ${err.plugin}) ${description}` : description) || err; +export function handleError(error: RollupError, recover = false): void { + const name = error.name || (error.cause as Error)?.name; + const nameSection = name ? `${name}: ` : ''; + const pluginSection = error.plugin ? `(plugin ${error.plugin}) ` : ''; + const message = `${pluginSection}${nameSection}${error.message}`; - stderr(bold(red(`[!] ${bold(message.toString())}`))); + const outputLines = [bold(red(`[!] ${bold(message.toString())}`))]; + + if (error.url) { + outputLines.push(cyan(error.url)); + } - if (err.url) { - stderr(cyan(err.url)); + if (error.loc) { + outputLines.push( + `${relativeId((error.loc.file || error.id)!)} (${error.loc.line}:${error.loc.column})` + ); + } else if (error.id) { + outputLines.push(relativeId(error.id)); } - if (err.loc) { - stderr(`${relativeId((err.loc.file || err.id)!)} (${err.loc.line}:${err.loc.column})`); - } else if (err.id) { - stderr(relativeId(err.id)); + if (error.frame) { + outputLines.push(dim(error.frame)); } - if (err.frame) { - stderr(dim(err.frame)); + if (error.stack) { + outputLines.push(dim(error.stack?.replace(`${nameSection}${error.message}\n`, ''))); } - if (err.stack) { - stderr(dim(err.stack)); + // ES2022: Error.prototype.cause is optional + if (error.cause) { + let cause = error.cause as Error | undefined; + const causeErrorLines = []; + let indent = ''; + + while (cause) { + indent += ' '; + const message = cause.stack || cause; + causeErrorLines.push(...`[cause] ${message}`.split('\n').map(line => indent + line)); + + cause = cause.cause as Error | undefined; + } + + outputLines.push(dim(causeErrorLines.join('\n'))); } - stderr(''); + outputLines.push('', ''); + stderr(outputLines.join('\n')); if (!recover) process.exit(1); } diff --git a/cli/run/batchWarnings.ts b/cli/run/batchWarnings.ts index 508c65e325a..5dc9b7e19ba 100644 --- a/cli/run/batchWarnings.ts +++ b/cli/run/batchWarnings.ts @@ -1,60 +1,58 @@ -import { bold, gray, yellow } from 'colorette'; -import { RollupWarning } from '../../src/rollup/types'; -import { getOrCreate } from '../../src/utils/getOrCreate'; +import pc from 'picocolors'; +import type { RollupLog } from '../../src/rollup/types'; +import { bold, gray, yellow } from '../../src/utils/colors'; +import { ensureArray } from '../../src/utils/ensureArray'; +import { getLogFilter } from '../../src/utils/getLogFilter'; +import { getNewArray, getOrCreate } from '../../src/utils/getOrCreate'; +import { LOGLEVEL_DEBUG, LOGLEVEL_WARN } from '../../src/utils/logging'; +import { printQuotedStringList } from '../../src/utils/printStringList'; import relativeId from '../../src/utils/relativeId'; +import { getRollupUrl } from '../../src/utils/url'; +import { + URL_AVOIDING_EVAL, + URL_NAME_IS_NOT_EXPORTED, + URL_OUTPUT_EXPORTS, + URL_OUTPUT_GLOBALS, + URL_SOURCEMAP_IS_LIKELY_TO_BE_INCORRECT, + URL_THIS_IS_UNDEFINED, + URL_TREATING_MODULE_AS_EXTERNAL_DEPENDENCY +} from '../../src/utils/urls'; import { stderr } from '../logging'; +import type { BatchWarnings } from './loadConfigFileType'; -export interface BatchWarnings { - add: (warning: RollupWarning) => void; - readonly count: number; - flush: () => void; - readonly warningOccurred: boolean; -} - -export default function batchWarnings() { +export default function batchWarnings(command: Record): BatchWarnings { + const silent = !!command.silent; + const logFilter = generateLogFilter(command); let count = 0; - let deferredWarnings = new Map(); + const deferredWarnings = new Map(); let warningOccurred = false; + const add = (warning: RollupLog) => { + count += 1; + warningOccurred = true; + + if (silent) return; + if ((warning.code as string) in deferredHandlers) { + getOrCreate(deferredWarnings, warning.code, getNewArray).push(warning); + } else if ((warning.code as string) in immediateHandlers) { + immediateHandlers[warning.code!](warning); + } else { + title(warning.message); + defaultBody(warning); + } + }; + return { + add, + get count() { return count; }, - get warningOccurred() { - return warningOccurred; - }, - - add: (warning: RollupWarning) => { - count += 1; - warningOccurred = true; - - if (warning.code! in deferredHandlers) { - getOrCreate(deferredWarnings, warning.code!, () => []).push(warning); - } else if (warning.code! in immediateHandlers) { - immediateHandlers[warning.code!](warning); - } else { - title(warning.message); - - if (warning.url) info(warning.url); + flush() { + if (count === 0 || silent) return; - const id = (warning.loc && warning.loc.file) || warning.id; - if (id) { - const loc = warning.loc - ? `${relativeId(id)} (${warning.loc.line}:${warning.loc.column})` - : relativeId(id); - - stderr(bold(relativeId(loc))); - } - - if (warning.frame) info(warning.frame); - } - }, - - flush: () => { - if (count === 0) return; - - const codes = Array.from(deferredWarnings.keys()).sort( + const codes = [...deferredWarnings.keys()].sort( (a, b) => deferredWarnings.get(b)!.length - deferredWarnings.get(a)!.length ); @@ -62,44 +60,61 @@ export default function batchWarnings() { deferredHandlers[code](deferredWarnings.get(code)!); } - deferredWarnings = new Map(); + deferredWarnings.clear(); count = 0; + }, + + log(level, log) { + if (!logFilter(log)) return; + switch (level) { + case LOGLEVEL_WARN: { + return add(log); + } + case LOGLEVEL_DEBUG: { + if (!silent) { + stderr(bold(pc.blue(log.message))); + defaultBody(log); + } + return; + } + default: { + if (!silent) { + stderr(bold(pc.cyan(log.message))); + defaultBody(log); + } + } + } + }, + + get warningOccurred() { + return warningOccurred; } }; } -const immediateHandlers: { - [code: string]: (warning: RollupWarning) => void; -} = { - UNKNOWN_OPTION: warning => { - title(`You have passed an unrecognized option`); - stderr(warning.message); - }, - - MISSING_NODE_BUILTINS: warning => { +const immediateHandlers: Record void> = { + MISSING_NODE_BUILTINS(warning) { title(`Missing shims for Node.js built-ins`); - const detail = - warning.modules!.length === 1 - ? `'${warning.modules![0]}'` - : `${warning - .modules!.slice(0, -1) - .map((name: string) => `'${name}'`) - .join(', ')} and '${warning.modules!.slice(-1)}'`; stderr( - `Creating a browser bundle that depends on ${detail}. You might need to include https://github.com/ionic-team/rollup-plugin-node-polyfills` + `Creating a browser bundle that depends on ${printQuotedStringList( + warning.ids! + )}. You might need to include https://github.com/FredKSchott/rollup-plugin-polyfill-node` ); + }, + + UNKNOWN_OPTION(warning) { + title(`You have passed an unrecognized option`); + stderr(warning.message); } }; -const deferredHandlers: { - [code: string]: (warnings: RollupWarning[]) => void; -} = { +const deferredHandlers: Record void> = { CIRCULAR_DEPENDENCY(warnings) { title(`Circular dependenc${warnings.length > 1 ? 'ies' : 'y'}`); const displayed = warnings.length > 5 ? warnings.slice(0, 3) : warnings; for (const warning of displayed) { - stderr(warning.cycle!.join(' -> ')); + stderr(warning.ids!.map(relativeId).join(' -> ')); } if (warnings.length > displayed.length) { stderr(`...and ${warnings.length - displayed.length} more`); @@ -112,40 +127,42 @@ const deferredHandlers: { warnings.length > 1 ? 'chunks' : 'chunk' }` ); - stderr(warnings.map(warning => warning.chunkName!).join(', ')); + stderr(printQuotedStringList(warnings.map(warning => warning.names![0]))); }, EVAL(warnings) { title('Use of eval is strongly discouraged'); - info('https://rollupjs.org/guide/en/#avoiding-eval'); + info(getRollupUrl(URL_AVOIDING_EVAL)); showTruncatedWarnings(warnings); }, MISSING_EXPORT(warnings) { title('Missing exports'); - info('https://rollupjs.org/guide/en/#error-name-is-not-exported-by-module'); + info(getRollupUrl(URL_NAME_IS_NOT_EXPORTED)); for (const warning of warnings) { - stderr(bold(warning.importer!)); - stderr(`${warning.missing} is not exported by ${warning.exporter}`); + stderr(bold(relativeId(warning.id!))); + stderr(`${warning.binding} is not exported by ${relativeId(warning.exporter!)}`); stderr(gray(warning.frame!)); } }, MISSING_GLOBAL_NAME(warnings) { title(`Missing global variable ${warnings.length > 1 ? 'names' : 'name'}`); + info(getRollupUrl(URL_OUTPUT_GLOBALS)); stderr( - `Use output.globals to specify browser global variable names corresponding to external modules` + `Use "output.globals" to specify browser global variable names corresponding to external modules:` ); for (const warning of warnings) { - stderr(`${bold(warning.source!)} (guessing '${warning.guess}')`); + stderr(`${bold(warning.id!)} (guessing "${warning.names![0]}")`); } }, - MIXED_EXPORTS: warnings => { + MIXED_EXPORTS(warnings) { title('Mixing named and default exports'); - info(`https://rollupjs.org/guide/en/#outputexports`); + info(getRollupUrl(URL_OUTPUT_EXPORTS)); stderr(bold('The following entry modules are using named and default exports together:')); + warnings.sort((a, b) => (a.id! < b.id! ? -1 : 1)); const displayedWarnings = warnings.length > 5 ? warnings.slice(0, 3) : warnings; for (const warning of displayedWarnings) { stderr(relativeId(warning.id!)); @@ -154,7 +171,7 @@ const deferredHandlers: { stderr(`...and ${warnings.length - displayedWarnings.length} other entry modules`); } stderr( - `\nConsumers of your bundle will have to use chunk['default'] to access their default export, which may not be what you want. Use \`output.exports: 'named'\` to disable this warning` + `\nConsumers of your bundle will have to use chunk.default to access their default export, which may not be what you want. Use \`output.exports: "named"\` to disable this warning.` ); }, @@ -162,39 +179,30 @@ const deferredHandlers: { title(`Conflicting re-exports`); for (const warning of warnings) { stderr( - `${bold(relativeId(warning.reexporter!))} re-exports '${ - warning.name - }' from both ${relativeId(warning.sources![0])} and ${relativeId( - warning.sources![1] - )} (will be ignored)` + `"${bold(relativeId(warning.reexporter!))}" re-exports "${ + warning.binding + }" from both "${relativeId(warning.ids![0])}" and "${relativeId( + warning.ids![1] + )}" (will be ignored).` ); } }, - NON_EXISTENT_EXPORT(warnings) { - title(`Import of non-existent ${warnings.length > 1 ? 'exports' : 'export'}`); - showTruncatedWarnings(warnings); - }, - PLUGIN_WARNING(warnings) { const nestedByPlugin = nest(warnings, 'plugin'); - for (const { key: plugin, items } of nestedByPlugin) { + for (const { items } of nestedByPlugin) { const nestedByMessage = nest(items, 'message'); let lastUrl = ''; for (const { key: message, items } of nestedByMessage) { - title(`Plugin ${plugin}: ${message}`); + title(message); for (const warning of items) { if (warning.url && warning.url !== lastUrl) info((lastUrl = warning.url)); - const id = warning.id || warning.loc?.file; - if (id) { - let loc = relativeId(id); - if (warning.loc) { - loc += `: (${warning.loc.line}:${warning.loc.column})`; - } + const loc = formatLocation(warning); + if (loc) { stderr(bold(loc)); } if (warning.frame) info(warning.frame); @@ -205,63 +213,85 @@ const deferredHandlers: { SOURCEMAP_BROKEN(warnings) { title(`Broken sourcemap`); - info('https://rollupjs.org/guide/en/#warning-sourcemap-is-likely-to-be-incorrect'); - - const plugins = Array.from(new Set(warnings.map(w => w.plugin).filter(Boolean))); - const detail = - plugins.length > 1 - ? ` (such as ${plugins - .slice(0, -1) - .map(p => `'${p}'`) - .join(', ')} and '${plugins.slice(-1)}')` - : ` (such as '${plugins[0]}')`; - - stderr(`Plugins that transform code${detail} should generate accompanying sourcemaps`); + info(getRollupUrl(URL_SOURCEMAP_IS_LIKELY_TO_BE_INCORRECT)); + + const plugins = [...new Set(warnings.map(({ plugin }) => plugin).filter(Boolean))] as string[]; + stderr( + `Plugins that transform code (such as ${printQuotedStringList( + plugins + )}) should generate accompanying sourcemaps.` + ); }, THIS_IS_UNDEFINED(warnings) { - title('`this` has been rewritten to `undefined`'); - info('https://rollupjs.org/guide/en/#error-this-is-undefined'); + title('"this" has been rewritten to "undefined"'); + info(getRollupUrl(URL_THIS_IS_UNDEFINED)); showTruncatedWarnings(warnings); }, UNRESOLVED_IMPORT(warnings) { title('Unresolved dependencies'); - info('https://rollupjs.org/guide/en/#warning-treating-module-as-external-dependency'); + info(getRollupUrl(URL_TREATING_MODULE_AS_EXTERNAL_DEPENDENCY)); - const dependencies = new Map(); + const dependencies = new Map(); for (const warning of warnings) { - getOrCreate(dependencies, warning.source, () => []).push(warning.importer); + getOrCreate(dependencies, relativeId(warning.exporter!), getNewArray).push( + relativeId(warning.id!) + ); } - for (const dependency of dependencies.keys()) { - const importers = dependencies.get(dependency); - stderr(`${bold(dependency)} (imported by ${importers.join(', ')})`); + for (const [dependency, importers] of dependencies) { + stderr(`${bold(dependency)} (imported by ${printQuotedStringList(importers)})`); } }, UNUSED_EXTERNAL_IMPORT(warnings) { title('Unused external imports'); for (const warning of warnings) { - stderr(`${warning.names} imported from external module '${warning.source}' but never used`); + stderr( + warning.names + + ' imported from external module "' + + warning.exporter + + '" but never used in ' + + printQuotedStringList(warning.ids!.map(relativeId)) + + '.' + ); } } }; -function title(str: string) { - stderr(bold(yellow(`(!) ${str}`))); +function defaultBody(log: RollupLog): void { + if (log.url) { + info(log.url); + } + + const loc = formatLocation(log); + if (loc) { + stderr(bold(loc)); + } + + if (log.frame) info(log.frame); +} + +function title(string_: string): void { + stderr(bold(yellow(`(!) ${string_}`))); } -function info(url: string) { +function info(url: string): void { stderr(gray(url)); } -function nest(array: T[], prop: string) { - const nested: { items: T[]; key: string }[] = []; - const lookup = new Map(); +interface Nested { + items: T[]; + key: string; +} + +function nest>(array: readonly T[], property: string): Nested[] { + const nested: Nested[] = []; + const lookup = new Map>(); for (const item of array) { - const key = (item as any)[prop]; + const key = item[property]; getOrCreate(lookup, key, () => { const items = { items: [], @@ -275,7 +305,7 @@ function nest(array: T[], prop: string) { return nested; } -function showTruncatedWarnings(warnings: RollupWarning[]) { +function showTruncatedWarnings(warnings: readonly RollupLog[]): void { const nestedByModule = nest(warnings, 'id'); const displayedByModule = nestedByModule.length > 5 ? nestedByModule.slice(0, 3) : nestedByModule; @@ -292,3 +322,17 @@ function showTruncatedWarnings(warnings: RollupWarning[]) { stderr(`\n...and ${nestedByModule.length - displayedByModule.length} other files`); } } + +function generateLogFilter(command: Record) { + const filters = ensureArray(command.filterLogs).flatMap(filter => String(filter).split(',')); + if (process.env.ROLLUP_FILTER_LOGS) { + filters.push(...process.env.ROLLUP_FILTER_LOGS.split(',')); + } + return getLogFilter(filters); +} + +function formatLocation(log: RollupLog): string | null { + const id = log.loc?.file || log.id; + if (!id) return null; + return log.loc ? `${id}:${log.loc.line}:${log.loc.column}` : id; +} diff --git a/cli/run/build.ts b/cli/run/build.ts index 38c55e2e05f..2c99071adcb 100644 --- a/cli/run/build.ts +++ b/cli/run/build.ts @@ -1,11 +1,12 @@ -import { bold, cyan, green } from 'colorette'; +import process from 'node:process'; import ms from 'pretty-ms'; -import * as rollup from '../../src/node-entry'; -import { MergedRollupOptions } from '../../src/rollup/types'; +import { rollup } from '../../src/node-entry'; +import type { MergedRollupOptions } from '../../src/rollup/types'; +import { bold, cyan, green } from '../../src/utils/colors'; +import { logOnlyInlineSourcemapsForStdout } from '../../src/utils/logs'; import relativeId from '../../src/utils/relativeId'; import { handleError, stderr } from '../logging'; -import SOURCEMAPPING_URL from '../sourceMappingUrl'; -import { BatchWarnings } from './batchWarnings'; +import type { BatchWarnings } from './loadConfigFileType'; import { printTimings } from './timings'; export default async function build( @@ -21,39 +22,24 @@ export default async function build( let inputFiles: string | undefined; if (typeof inputOptions.input === 'string') { inputFiles = inputOptions.input; - } else if (inputOptions.input instanceof Array) { + } else if (Array.isArray(inputOptions.input)) { inputFiles = inputOptions.input.join(', '); } else if (typeof inputOptions.input === 'object' && inputOptions.input !== null) { - inputFiles = Object.keys(inputOptions.input) - .map(name => (inputOptions.input as Record)[name]) - .join(', '); + inputFiles = Object.values(inputOptions.input).join(', '); } stderr(cyan(`\n${bold(inputFiles!)} → ${bold(files.join(', '))}...`)); } - const bundle = await rollup.rollup(inputOptions as any); + await using bundle = await rollup(inputOptions as any); if (useStdout) { const output = outputOptions[0]; if (output.sourcemap && output.sourcemap !== 'inline') { - handleError({ - code: 'ONLY_INLINE_SOURCEMAPS', - message: 'Only inline sourcemaps are supported when bundling to stdout.' - }); + handleError(logOnlyInlineSourcemapsForStdout()); } - const { output: outputs } = await bundle.generate(output); for (const file of outputs) { - let source: string | Uint8Array; - if (file.type === 'asset') { - source = file.source; - } else { - source = file.code; - if (output.sourcemap === 'inline') { - source += `\n//# ${SOURCEMAPPING_URL}=${file.map!.toUrl()}\n`; - } - } if (outputs.length > 1) process.stdout.write(`\n${cyan(bold(`//→ ${file.fileName}:`))}\n`); - process.stdout.write(source as Buffer); + process.stdout.write(file.type === 'asset' ? file.source : file.code); } if (!silent) { warnings.flush(); @@ -62,7 +48,6 @@ export default async function build( } await Promise.all(outputOptions.map(bundle.write)); - await bundle.close(); if (!silent) { warnings.flush(); stderr(green(`created ${bold(files.join(', '))} in ${bold(ms(Date.now() - start))}`)); diff --git a/cli/run/commandPlugins.ts b/cli/run/commandPlugins.ts index d491ef5f647..15e5125a1a2 100644 --- a/cli/run/commandPlugins.ts +++ b/cli/run/commandPlugins.ts @@ -1,56 +1,72 @@ -import * as path from 'path'; -import { InputOptions } from '../../src/rollup/types'; +import path from 'node:path'; +import { pathToFileURL } from 'node:url'; +import type { InputOptionsWithPlugins } from '../../src/rollup/types'; +import { normalizePluginOption } from '../../src/utils/options/options'; import { stdinPlugin } from './stdin'; import { waitForInputPlugin } from './waitForInput'; -export function addCommandPluginsToInputOptions(inputOptions: InputOptions, command: any) { +export async function addCommandPluginsToInputOptions( + inputOptions: InputOptionsWithPlugins, + command: Record +): Promise { if (command.stdin !== false) { - inputOptions.plugins!.push(stdinPlugin(command.stdin)); + inputOptions.plugins.push(stdinPlugin(command.stdin)); } if (command.waitForBundleInput === true) { - inputOptions.plugins!.push(waitForInputPlugin()); + inputOptions.plugins.push(waitForInputPlugin()); } - const commandPlugin = command.plugin; + await addPluginsFromCommandOption(command.plugin, inputOptions); +} + +export async function addPluginsFromCommandOption( + commandPlugin: unknown, + inputOptions: InputOptionsWithPlugins +): Promise { if (commandPlugin) { - const plugins = Array.isArray(commandPlugin) ? commandPlugin : [commandPlugin]; + const plugins = await normalizePluginOption(commandPlugin); for (const plugin of plugins) { if (/[={}]/.test(plugin)) { // -p plugin=value // -p "{transform(c,i){...}}" - loadAndRegisterPlugin(inputOptions, plugin); + await loadAndRegisterPlugin(inputOptions, plugin); } else { // split out plugins joined by commas // -p node-resolve,commonjs,buble - plugin.split(',').forEach((plugin: string) => loadAndRegisterPlugin(inputOptions, plugin)); + for (const p of plugin.split(',')) { + await loadAndRegisterPlugin(inputOptions, p); + } } } } } -function loadAndRegisterPlugin(inputOptions: InputOptions, pluginText: string) { +async function loadAndRegisterPlugin( + inputOptions: InputOptionsWithPlugins, + pluginText: string +): Promise { let plugin: any = null; - let pluginArg: any = undefined; + let pluginArgument: any = undefined; if (pluginText[0] === '{') { // -p "{transform(c,i){...}}" plugin = new Function('return ' + pluginText); } else { - const match = pluginText.match(/^([@.\/\\\w|^{}-]+)(=(.*))?$/); + const match = pluginText.match(/^([\w./:@\\^{|}-]+)(=(.*))?$/); if (match) { // -p plugin // -p plugin=arg pluginText = match[1]; - pluginArg = new Function('return ' + match[3])(); + pluginArgument = new Function('return ' + match[3])(); } else { throw new Error(`Invalid --plugin argument format: ${JSON.stringify(pluginText)}`); } - if (!/^\.|^rollup-plugin-|[@\/\\]/.test(pluginText)) { + if (!/^\.|^rollup-plugin-|[/@\\]/.test(pluginText)) { // Try using plugin prefix variations first if applicable. // Prefix order is significant - left has higher precedence. for (const prefix of ['@rollup/plugin-', 'rollup-plugin-']) { try { - plugin = require(prefix + pluginText); + plugin = await requireOrImport(prefix + pluginText); break; - } catch (ex) { + } catch { // if this does not work, we try requiring the actual name below } } @@ -58,9 +74,14 @@ function loadAndRegisterPlugin(inputOptions: InputOptions, pluginText: string) { if (!plugin) { try { if (pluginText[0] == '.') pluginText = path.resolve(pluginText); - plugin = require(pluginText); - } catch (ex) { - throw new Error(`Cannot load plugin "${pluginText}": ${ex.message}.`); + // Windows absolute paths must be specified as file:// protocol URL + // Note that we do not have coverage for Windows-only code paths + else if (/^[A-Za-z]:\\/.test(pluginText)) { + pluginText = pathToFileURL(path.resolve(pluginText)).href; + } + plugin = await requireOrImport(pluginText); + } catch (error: any) { + throw new Error(`Cannot load plugin "${pluginText}": ${error.message}.`); } } } @@ -76,17 +97,26 @@ function loadAndRegisterPlugin(inputOptions: InputOptions, pluginText: string) { )}" for Rollup to recognize it.` ); } - inputOptions.plugins!.push( - typeof plugin === 'function' ? plugin.call(plugin, pluginArg) : plugin + inputOptions.plugins.push( + typeof plugin === 'function' ? plugin.call(plugin, pluginArgument) : plugin ); } function getCamelizedPluginBaseName(pluginText: string): string { return (pluginText.match(/(@rollup\/plugin-|rollup-plugin-)(.+)$/)?.[2] || pluginText) - .split(/[\\/]/) + .split(/[/\\]/) .slice(-1)[0] .split('.')[0] .split('-') .map((part, index) => (index === 0 || !part ? part : part[0].toUpperCase() + part.slice(1))) .join(''); } + +async function requireOrImport(pluginPath: string): Promise { + try { + // eslint-disable-next-line @typescript-eslint/no-require-imports + return require(pluginPath); + } catch { + return import(pluginPath); + } +} diff --git a/cli/run/getConfigPath.ts b/cli/run/getConfigPath.ts index 5d42f3e81a0..6cc1a80bd73 100644 --- a/cli/run/getConfigPath.ts +++ b/cli/run/getConfigPath.ts @@ -1,41 +1,38 @@ -import { readdirSync } from 'fs'; -import * as path from 'path'; -import relative from 'require-relative'; +import { readdir } from 'node:fs/promises'; +import path from 'node:path'; +import { cwd } from 'node:process'; +import { logMissingExternalConfig } from '../../src/utils/logs'; import { handleError } from '../logging'; const DEFAULT_CONFIG_BASE = 'rollup.config'; -export function getConfigPath(commandConfig: string | true): string { - const cwd = process.cwd(); +export async function getConfigPath(commandConfig: string | true): Promise { if (commandConfig === true) { - return path.resolve(findConfigFileNameInCwd()); + return path.resolve(await findConfigFileNameInCwd()); } if (commandConfig.slice(0, 5) === 'node:') { - const pkgName = commandConfig.slice(5); + const packageName = commandConfig.slice(5); try { - return relative.resolve(`rollup-config-${pkgName}`, cwd); - } catch (err) { + return require.resolve(`rollup-config-${packageName}`, { paths: [cwd()] }); + } catch { try { - return relative.resolve(pkgName, cwd); - } catch (err) { - if (err.code === 'MODULE_NOT_FOUND') { - handleError({ - code: 'MISSING_EXTERNAL_CONFIG', - message: `Could not resolve config file "${commandConfig}"` - }); + return require.resolve(packageName, { paths: [cwd()] }); + } catch (error: any) { + if (error.code === 'MODULE_NOT_FOUND') { + handleError(logMissingExternalConfig(commandConfig)); } - throw err; + throw error; } } } return path.resolve(commandConfig); } -function findConfigFileNameInCwd(): string { - const filesInWorkingDir = new Set(readdirSync(process.cwd())); - for (const extension of ['mjs', 'cjs']) { +async function findConfigFileNameInCwd(): Promise { + const filesInWorkingDirectory = new Set(await readdir(cwd())); + for (const extension of ['mjs', 'cjs', 'ts']) { const fileName = `${DEFAULT_CONFIG_BASE}.${extension}`; - if (filesInWorkingDir.has(fileName)) return fileName; + if (filesInWorkingDirectory.has(fileName)) return fileName; } return `${DEFAULT_CONFIG_BASE}.js`; } diff --git a/cli/run/index.ts b/cli/run/index.ts index 086b325d536..a7e443b0a13 100644 --- a/cli/run/index.ts +++ b/cli/run/index.ts @@ -1,21 +1,21 @@ -import { MergedRollupOptions } from '../../src/rollup/types'; +import { env } from 'node:process'; +import type { MergedRollupOptions } from '../../src/rollup/types'; +import { logDuplicateImportOptions, logFailAfterWarnings } from '../../src/utils/logs'; +import { isWatchEnabled } from '../../src/utils/options/mergeOptions'; import { getAliasName } from '../../src/utils/relativeId'; import { loadFsEvents } from '../../src/watch/fsevents-importer'; import { handleError } from '../logging'; -import { BatchWarnings } from './batchWarnings'; import build from './build'; import { getConfigPath } from './getConfigPath'; -import loadAndParseConfigFile from './loadConfigFile'; +import { loadConfigFile } from './loadConfigFile'; +import type { BatchWarnings } from './loadConfigFileType'; import loadConfigFromCommand from './loadConfigFromCommand'; -export default async function runRollup(command: any) { +export default async function runRollup(command: Record): Promise { let inputSource; if (command._.length > 0) { if (command.input) { - handleError({ - code: 'DUPLICATE_IMPORT_OPTIONS', - message: 'Either use --input, or pass input path as argument' - }); + handleError(logDuplicateImportOptions()); } inputSource = command._; } else if (typeof command.input === 'string') { @@ -25,15 +25,15 @@ export default async function runRollup(command: any) { } if (inputSource && inputSource.length > 0) { - if (inputSource.some((input: string) => input.indexOf('=') !== -1)) { + if (inputSource.some((input: string) => input.includes('='))) { command.input = {}; - inputSource.forEach((input: string) => { + for (const input of inputSource) { const equalsIndex = input.indexOf('='); - const value = input.substr(equalsIndex + 1); - let key = input.substr(0, equalsIndex); - if (!key) key = getAliasName(input); + const value = input.slice(Math.max(0, equalsIndex + 1)); + const key = input.slice(0, Math.max(0, equalsIndex)) || getAliasName(input); + command.input[key] = value; - }); + } } else { command.input = inputSource; } @@ -44,42 +44,41 @@ export default async function runRollup(command: any) { ? command.environment : [command.environment]; - environment.forEach((arg: string) => { - arg.split(',').forEach((pair: string) => { + for (const argument of environment) { + for (const pair of argument.split(',')) { const [key, ...value] = pair.split(':'); - if (value.length) { - process.env[key] = value.join(':'); - } else { - process.env[key] = String(true); - } - }); - }); + env[key] = value.length === 0 ? String(true) : value.join(':'); + } + } } - if (command.watch) { + if (isWatchEnabled(command.watch)) { await loadFsEvents(); const { watch } = await import('./watch-cli'); - watch(command); + await watch(command); } else { try { const { options, warnings } = await getConfigs(command); try { for (const inputOptions of options) { + if (!inputOptions.cache) { + // We explicitly disable the cache when unused as the CLI will not + // use the cache object on the bundle when not in watch mode. This + // improves performance as the cache is not generated. + inputOptions.cache = false; + } await build(inputOptions, warnings, command.silent); } if (command.failAfterWarnings && warnings.warningOccurred) { warnings.flush(); - handleError({ - code: 'FAIL_AFTER_WARNINGS', - message: 'Warnings occurred and --failAfterWarnings flag present' - }); + handleError(logFailAfterWarnings()); } - } catch (err) { + } catch (error: any) { warnings.flush(); - handleError(err); + handleError(error); } - } catch (err) { - handleError(err); + } catch (error: any) { + handleError(error); } } } @@ -88,9 +87,9 @@ async function getConfigs( command: any ): Promise<{ options: MergedRollupOptions[]; warnings: BatchWarnings }> { if (command.config) { - const configFile = getConfigPath(command.config); - const { options, warnings } = await loadAndParseConfigFile(configFile, command); + const configFile = await getConfigPath(command.config); + const { options, warnings } = await loadConfigFile(configFile, command, false); return { options, warnings }; } - return loadConfigFromCommand(command); + return await loadConfigFromCommand(command, false); } diff --git a/cli/run/loadConfigFile.ts b/cli/run/loadConfigFile.ts index 215c74d2064..a7e6e9fca1a 100644 --- a/cli/run/loadConfigFile.ts +++ b/cli/run/loadConfigFile.ts @@ -1,83 +1,141 @@ -import { bold } from 'colorette'; -import * as fs from 'fs'; -import * as path from 'path'; -import { pathToFileURL } from 'url'; +import { unlink, writeFile } from 'node:fs/promises'; +import path from 'node:path'; +import process from 'node:process'; +import { pathToFileURL } from 'node:url'; import * as rollup from '../../src/node-entry'; -import { MergedRollupOptions } from '../../src/rollup/types'; -import { error } from '../../src/utils/error'; +import type { + ImportAttributesKey, + InputOptionsWithPlugins, + MergedRollupOptions +} from '../../src/rollup/types'; +import { bold } from '../../src/utils/colors'; +import { + error, + logCannotBundleConfigAsEsm, + logCannotLoadConfigAsCjs, + logCannotLoadConfigAsEsm, + logMissingConfig +} from '../../src/utils/logs'; import { mergeOptions } from '../../src/utils/options/mergeOptions'; -import { GenericConfigObject } from '../../src/utils/options/options'; +import type { GenericConfigObject } from '../../src/utils/options/options'; import relativeId from '../../src/utils/relativeId'; import { stderr } from '../logging'; -import batchWarnings, { BatchWarnings } from './batchWarnings'; -import { addCommandPluginsToInputOptions } from './commandPlugins'; +import batchWarnings from './batchWarnings'; +import { addCommandPluginsToInputOptions, addPluginsFromCommandOption } from './commandPlugins'; +import type { LoadConfigFile } from './loadConfigFileType'; -function supportsNativeESM() { - return Number(/^v(\d+)/.exec(process.version)![1]) >= 13; -} - -interface NodeModuleWithCompile extends NodeModule { - _compile(code: string, filename: string): any; -} - -export default async function loadAndParseConfigFile( - fileName: string, - commandOptions: any = {} -): Promise<{ options: MergedRollupOptions[]; warnings: BatchWarnings }> { - const configs = await loadConfigFile(fileName, commandOptions); - const warnings = batchWarnings(); +export const loadConfigFile: LoadConfigFile = async ( + fileName, + commandOptions = {}, + watchMode = false +) => { + const configs = await getConfigList( + getDefaultFromCjs(await getConfigFileExport(fileName, commandOptions, watchMode)), + commandOptions + ); + const warnings = batchWarnings(commandOptions); try { - const normalizedConfigs = configs.map(config => { - const options = mergeOptions(config, commandOptions, warnings.add); - addCommandPluginsToInputOptions(options, commandOptions); - return options; - }); + const normalizedConfigs: MergedRollupOptions[] = []; + for (const config of configs) { + const options = await mergeOptions(config, watchMode, commandOptions, warnings.log); + await addCommandPluginsToInputOptions(options, commandOptions); + normalizedConfigs.push(options); + } return { options: normalizedConfigs, warnings }; - } catch (err) { + } catch (error_) { warnings.flush(); - throw err; + throw error_; } -} +}; -async function loadConfigFile( +async function getConfigFileExport( fileName: string, - commandOptions: any -): Promise { - const extension = path.extname(fileName); - const configFileExport = - extension === '.mjs' && supportsNativeESM() - ? (await import(pathToFileURL(fileName).href)).default - : extension === '.cjs' - ? getDefaultFromCjs(require(fileName)) - : await getDefaultFromTranspiledConfigFile(fileName, commandOptions.silent); - return getConfigList(configFileExport, commandOptions); + commandOptions: Record, + watchMode: boolean +) { + if (commandOptions.configPlugin || commandOptions.bundleConfigAsCjs) { + try { + return await loadTranspiledConfigFile(fileName, commandOptions); + } catch (error_: any) { + if (error_.message.includes('not defined in ES module scope')) { + return error(logCannotBundleConfigAsEsm(error_)); + } + throw error_; + } + } + let cannotLoadEsm = false; + const handleWarning = (warning: Error): void => { + if ( + warning.message?.includes('To load an ES module') || + warning.message?.includes('Failed to load the ES module') + ) { + cannotLoadEsm = true; + } + }; + process.on('warning', handleWarning); + try { + const fileUrl = pathToFileURL(fileName); + if (watchMode) { + // We are adding the current date to allow reloads in watch mode + fileUrl.search = `?${Date.now()}`; + } + return (await import(fileUrl.href)).default; + } catch (error_: any) { + if (cannotLoadEsm) { + return error(logCannotLoadConfigAsCjs(error_)); + } + if (error_.message.includes('not defined in ES module scope')) { + return error(logCannotLoadConfigAsEsm(error_)); + } + throw error_; + } finally { + process.off('warning', handleWarning); + } } -function getDefaultFromCjs(namespace: GenericConfigObject) { - return namespace.__esModule ? namespace.default : namespace; +function getDefaultFromCjs(namespace: GenericConfigObject): unknown { + return namespace.default || namespace; } -async function getDefaultFromTranspiledConfigFile( +function getConfigImportAttributesKey(input: unknown): ImportAttributesKey | undefined { + if (input === 'assert' || input === 'with') return input; + return; +} + +async function loadTranspiledConfigFile( fileName: string, - silent: boolean + commandOptions: Record ): Promise { - const warnings = batchWarnings(); - const bundle = await rollup.rollup({ - external: (id: string) => - (id[0] !== '.' && !path.isAbsolute(id)) || id.slice(-5, id.length) === '.json', + const { bundleConfigAsCjs, configPlugin, configImportAttributesKey, silent } = commandOptions; + const warnings = batchWarnings(commandOptions); + const inputOptions: InputOptionsWithPlugins = { + // Do *not* specify external callback here - instead, perform the externality check it via fallback-plugin just below this comment. + // This allows config plugin to first decide whether some import is external or not, and only then trigger the check in fallback-plugin. + // Since the check is ultra-simple during this stage of transforming the config file itself, it should be fallback instead of primary check. + // That way, e.g. importing workspace packages will work as expected - the workspace package will be bundled. input: fileName, onwarn: warnings.add, + plugins: [], treeshake: false + }; + await addPluginsFromCommandOption(configPlugin, inputOptions); + // Add plugin as *last* item after addPluginsFromCommandOption is complete. + // This plugin will trigger for imports not resolved by config plugin, and mark all non-relative imports as external. + inputOptions.plugins.push({ + name: 'external-fallback', + resolveId: source => { + const looksLikeExternal = + (source[0] !== '.' && !path.isAbsolute(source)) || source.slice(-5) === '.json'; + return looksLikeExternal ? false : null; + } }); - if (!silent && warnings.count > 0) { - stderr(bold(`loaded ${relativeId(fileName)} with warnings`)); - warnings.flush(); - } + const bundle = await rollup.rollup(inputOptions); const { output: [{ code }] } = await bundle.generate({ exports: 'named', - format: 'cjs', + format: bundleConfigAsCjs ? 'cjs' : 'es', + importAttributesKey: getConfigImportAttributesKey(configImportAttributesKey), plugins: [ { name: 'transpile-import-meta', @@ -85,56 +143,50 @@ async function getDefaultFromTranspiledConfigFile( if (property === 'url') { return `'${pathToFileURL(moduleId).href}'`; } + if (property == 'filename') { + return `'${moduleId}'`; + } + if (property == 'dirname') { + return `'${path.dirname(moduleId)}'`; + } if (property == null) { - return `{url:'${pathToFileURL(moduleId).href}'}` + return `{url:'${pathToFileURL(moduleId).href}', filename: '${moduleId}', dirname: '${path.dirname(moduleId)}'}`; } } } ] }); - return loadConfigFromBundledFile(fileName, code); + if (!silent && warnings.count > 0) { + stderr(bold(`loaded ${relativeId(fileName)} with warnings`)); + warnings.flush(); + } + return loadConfigFromWrittenFile( + path.join( + path.dirname(fileName), + `rollup.config-${Date.now()}.${bundleConfigAsCjs ? 'cjs' : 'mjs'}` + ), + code + ); } -async function loadConfigFromBundledFile(fileName: string, bundledCode: string) { - const resolvedFileName = fs.realpathSync(fileName); - const extension = path.extname(resolvedFileName); - const defaultLoader = require.extensions[extension]; - require.extensions[extension] = (module: NodeModule, requiredFileName: string) => { - if (requiredFileName === resolvedFileName) { - (module as NodeModuleWithCompile)._compile(bundledCode, requiredFileName); - } else { - defaultLoader(module, requiredFileName); - } - }; - delete require.cache[resolvedFileName]; +async function loadConfigFromWrittenFile( + bundledFileName: string, + bundledCode: string +): Promise { + await writeFile(bundledFileName, bundledCode); try { - const config = getDefaultFromCjs(require(fileName)); - require.extensions[extension] = defaultLoader; - return config; - } catch (err) { - if (err.code === 'ERR_REQUIRE_ESM') { - return error({ - code: 'TRANSPILED_ESM_CONFIG', - message: `While loading the Rollup configuration from "${relativeId( - fileName - )}", Node tried to require an ES module from a CommonJS file, which is not supported. A common cause is if there is a package.json file with "type": "module" in the same folder. You can try to fix this by changing the extension of your configuration file to ".cjs" or ".mjs" depending on the content, which will prevent Rollup from trying to preprocess the file but rather hand it to Node directly.`, - url: 'https://rollupjs.org/guide/en/#using-untranspiled-config-files' - }); - } - throw err; + return (await import(pathToFileURL(bundledFileName).href)).default; + } finally { + unlink(bundledFileName).catch(error => console.warn(error?.message || error)); } } -async function getConfigList(configFileExport: any, commandOptions: any) { +async function getConfigList(configFileExport: any, commandOptions: any): Promise { const config = await (typeof configFileExport === 'function' ? configFileExport(commandOptions) : configFileExport); if (Object.keys(config).length === 0) { - return error({ - code: 'MISSING_CONFIG', - message: 'Config file must export an options object, or an array of options objects', - url: 'https://rollupjs.org/guide/en/#configuration-files' - }); + return error(logMissingConfig()); } return Array.isArray(config) ? config : [config]; } diff --git a/cli/run/loadConfigFileType.d.ts b/cli/run/loadConfigFileType.d.ts new file mode 100644 index 00000000000..e74cfb5d127 --- /dev/null +++ b/cli/run/loadConfigFileType.d.ts @@ -0,0 +1,20 @@ +import type { LogHandler, MergedRollupOptions, RollupLog } from '../../src/rollup/types'; + +export interface BatchWarnings { + add: (warning: RollupLog) => void; + readonly count: number; + flush: () => void; + log: LogHandler; + readonly warningOccurred: boolean; +} + +export type LoadConfigFile = typeof loadConfigFile; + +export function loadConfigFile( + fileName: string, + commandOptions: any, + watchMode?: boolean +): Promise<{ + options: MergedRollupOptions[]; + warnings: BatchWarnings; +}>; diff --git a/cli/run/loadConfigFromCommand.ts b/cli/run/loadConfigFromCommand.ts index 424a484a254..d14fdd37d0d 100644 --- a/cli/run/loadConfigFromCommand.ts +++ b/cli/run/loadConfigFromCommand.ts @@ -1,17 +1,23 @@ -import { MergedRollupOptions } from '../../src/rollup/types'; +import process from 'node:process'; +import type { MergedRollupOptions } from '../../src/rollup/types'; import { mergeOptions } from '../../src/utils/options/mergeOptions'; -import batchWarnings, { BatchWarnings } from './batchWarnings'; +import batchWarnings from './batchWarnings'; import { addCommandPluginsToInputOptions } from './commandPlugins'; +import type { BatchWarnings } from './loadConfigFileType'; import { stdinName } from './stdin'; -export default function loadConfigFromCommand( - command: any -): { options: MergedRollupOptions[]; warnings: BatchWarnings } { - const warnings = batchWarnings(); - if (!command.input && (command.stdin || !process.stdin.isTTY)) { - command.input = stdinName; +export default async function loadConfigFromCommand( + commandOptions: Record, + watchMode: boolean +): Promise<{ + options: MergedRollupOptions[]; + warnings: BatchWarnings; +}> { + const warnings = batchWarnings(commandOptions); + if (!commandOptions.input && (commandOptions.stdin || !process.stdin.isTTY)) { + commandOptions.input = stdinName; } - const options = mergeOptions({ input: [] }, command, warnings.add); - addCommandPluginsToInputOptions(options, command); + const options = await mergeOptions({ input: [] }, watchMode, commandOptions, warnings.log); + await addCommandPluginsToInputOptions(options, commandOptions); return { options: [options], warnings }; } diff --git a/cli/run/resetScreen.ts b/cli/run/resetScreen.ts index 1429210affb..6045fce0b44 100644 --- a/cli/run/resetScreen.ts +++ b/cli/run/resetScreen.ts @@ -1,12 +1,12 @@ -import { MergedRollupOptions } from '../../src/rollup/types'; +import type { MergedRollupOptions } from '../../src/rollup/types'; import { stderr } from '../logging'; const CLEAR_SCREEN = '\u001Bc'; export function getResetScreen( - configs: MergedRollupOptions[], + configs: readonly MergedRollupOptions[], allowClearScreen: boolean | undefined -) { +): (heading: string) => void { let clearScreen = allowClearScreen; for (const config of configs) { if (config.watch && config.watch.clearScreen === false) { diff --git a/cli/run/stdin.ts b/cli/run/stdin.ts index 3cd6ff16725..edcd804e660 100644 --- a/cli/run/stdin.ts +++ b/cli/run/stdin.ts @@ -1,22 +1,23 @@ -import { Plugin } from '../../src/rollup/types'; +import process from 'node:process'; +import type { Plugin } from '../../src/rollup/types'; export const stdinName = '-'; let stdinResult: Promise | null = null; -export function stdinPlugin(arg: any): Plugin { - const suffix = typeof arg == 'string' && arg.length ? '.' + arg : ''; +export function stdinPlugin(argument: unknown): Plugin { + const suffix = typeof argument == 'string' && argument.length > 0 ? '.' + argument : ''; return { + load(id) { + if (id === stdinName || id.startsWith(stdinName + '.')) { + return stdinResult || (stdinResult = readStdin()); + } + }, name: 'stdin', resolveId(id) { if (id === stdinName) { return id + suffix; } - }, - load(id) { - if (id === stdinName || id.startsWith(stdinName + '.')) { - return stdinResult || (stdinResult = readStdin()); - } } }; } @@ -31,8 +32,8 @@ function readStdin(): Promise { const result = chunks.join(''); resolve(result); }) - .on('error', err => { - reject(err); + .on('error', error => { + reject(error); }); }); } diff --git a/cli/run/timings.ts b/cli/run/timings.ts index 23c967dc921..7b174cfa453 100644 --- a/cli/run/timings.ts +++ b/cli/run/timings.ts @@ -1,13 +1,12 @@ -import { bold, underline } from 'colorette'; import prettyBytes from 'pretty-bytes'; -import { SerializedTimings } from '../../src/rollup/types'; +import type { SerializedTimings } from '../../src/rollup/types'; +import { bold, underline } from '../../src/utils/colors'; -export function printTimings(timings: SerializedTimings) { - Object.keys(timings).forEach(label => { +export function printTimings(timings: SerializedTimings): void { + for (const [label, [time, memory, total]] of Object.entries(timings)) { const appliedColor = - label[0] === '#' ? (label[1] !== '#' ? underline : bold) : (text: string) => text; - const [time, memory, total] = timings[label]; + label[0] === '#' ? (label[1] === '#' ? bold : underline) : (text: string) => text; const row = `${label}: ${time.toFixed(0)}ms, ${prettyBytes(memory)} / ${prettyBytes(total)}`; console.info(appliedColor(row)); - }); + } } diff --git a/cli/run/waitForInput.ts b/cli/run/waitForInput.ts index 5c48a3f5396..fb43776a0df 100644 --- a/cli/run/waitForInput.ts +++ b/cli/run/waitForInput.ts @@ -1,16 +1,15 @@ -import { bold } from 'colorette'; -import { NormalizedInputOptions, PluginContext } from '../../src/rollup/types'; +import type { NormalizedInputOptions, Plugin, PluginContext } from '../../src/rollup/types'; +import { bold } from '../../src/utils/colors'; import { stderr } from '../logging'; -export function waitForInputPlugin() { +export function waitForInputPlugin(): Plugin { return { - name: 'wait-for-input', async buildStart(this: PluginContext, options: NormalizedInputOptions) { const inputSpecifiers = Array.isArray(options.input) ? options.input - : Object.keys(options.input as { [entryAlias: string]: string }); + : Object.keys(options.input); - let lastAwaitedSpecifier = null; + let lastAwaitedSpecifier: string | null = null; checkSpecifiers: while (true) { for (const specifier of inputSpecifiers) { if ((await this.resolve(specifier)) === null) { @@ -24,6 +23,7 @@ export function waitForInputPlugin() { } break; } - } + }, + name: 'wait-for-input' }; } diff --git a/cli/run/watch-cli.ts b/cli/run/watch-cli.ts index fb2ef95de75..0feae3f1246 100644 --- a/cli/run/watch-cli.ts +++ b/cli/run/watch-cli.ts @@ -1,122 +1,117 @@ +import type { FSWatcher } from 'chokidar'; import chokidar from 'chokidar'; -import { bold, cyan, green, underline } from 'colorette'; import dateTime from 'date-time'; -import fs from 'fs'; +import { readFile } from 'node:fs/promises'; +import process from 'node:process'; import ms from 'pretty-ms'; -import onExit from 'signal-exit'; +import { onExit } from 'signal-exit'; import * as rollup from '../../src/node-entry'; -import { MergedRollupOptions, RollupWatcher } from '../../src/rollup/types'; +import type { MergedRollupOptions, RollupWatcher } from '../../src/rollup/types'; +import { bold, cyan, green, underline } from '../../src/utils/colors'; import relativeId from '../../src/utils/relativeId'; import { handleError, stderr } from '../logging'; -import { BatchWarnings } from './batchWarnings'; import { getConfigPath } from './getConfigPath'; -import loadAndParseConfigFile from './loadConfigFile'; +import { loadConfigFile } from './loadConfigFile'; +import type { BatchWarnings } from './loadConfigFileType'; import loadConfigFromCommand from './loadConfigFromCommand'; import { getResetScreen } from './resetScreen'; import { printTimings } from './timings'; +import { createWatchHooks } from './watchHooks'; -export async function watch(command: any) { +export async function watch(command: Record): Promise { process.env.ROLLUP_WATCH = 'true'; const isTTY = process.stderr.isTTY; const silent = command.silent; - let configs: MergedRollupOptions[]; - let warnings: BatchWarnings; let watcher: RollupWatcher; - let configWatcher: fs.FSWatcher; - const configFile = command.config ? getConfigPath(command.config) : null; + let configWatcher: FSWatcher; + let resetScreen: (heading: string) => void; + const configFile = command.config ? await getConfigPath(command.config) : null; + const runWatchHook = createWatchHooks(command); onExit(close); - process.on('uncaughtException' as any, close); - if (!process.stdin.isTTY) { - process.stdin.on('end', close); - process.stdin.resume(); - } + process.on('uncaughtException', closeWithError); - if (configFile) { - let reloadingConfig = false; - let aborted = false; + async function loadConfigFromFileAndTrack(configFile: string): Promise { let configFileData: string | null = null; + let configFileRevision = 0; - configWatcher = chokidar.watch(configFile).on('change', () => reloadConfigFile()); + configWatcher = chokidar.watch(configFile).on('change', reloadConfigFile); await reloadConfigFile(); async function reloadConfigFile() { try { - const newConfigFileData = fs.readFileSync(configFile!, 'utf-8'); + const newConfigFileData = await readFile(configFile, 'utf8'); if (newConfigFileData === configFileData) { return; } - if (reloadingConfig) { - aborted = true; - return; - } + configFileRevision++; + const currentConfigFileRevision = configFileRevision; if (configFileData) { stderr(`\nReloading updated config...`); } configFileData = newConfigFileData; - reloadingConfig = true; - ({ options: configs, warnings } = await loadAndParseConfigFile(configFile!, command)); - reloadingConfig = false; - if (aborted) { - aborted = false; - reloadConfigFile(); - } else { - if (watcher) { - watcher.close(); - } - start(configs); + const { options, warnings } = await loadConfigFile(configFile, command, true); + if (currentConfigFileRevision !== configFileRevision) { + return; + } + if (watcher) { + await watcher.close(); } - } catch (err) { - configs = []; - reloadingConfig = false; - handleError(err, true); + start(options, warnings); + } catch (error: any) { + handleError(error, true); } } + } + + if (configFile) { + await loadConfigFromFileAndTrack(configFile); } else { - ({ options: configs, warnings } = await loadConfigFromCommand(command)); - start(configs); + const { options, warnings } = await loadConfigFromCommand(command, true); + await start(options, warnings); } - // tslint:disable-next-line:no-unnecessary-type-assertion - const resetScreen = getResetScreen(configs!, isTTY); - - function start(configs: MergedRollupOptions[]) { - try { - watcher = rollup.watch(configs as any); - } catch (err) { - return handleError(err); - } + async function start(configs: MergedRollupOptions[], warnings: BatchWarnings): Promise { + watcher = rollup.watch(configs as any); watcher.on('event', event => { switch (event.code) { - case 'ERROR': + case 'ERROR': { warnings.flush(); handleError(event.error, true); + runWatchHook('onError'); break; + } - case 'START': + case 'START': { if (!silent) { + if (!resetScreen) { + resetScreen = getResetScreen(configs, isTTY); + } resetScreen(underline(`rollup v${rollup.VERSION}`)); } + runWatchHook('onStart'); + break; + } - case 'BUNDLE_START': + case 'BUNDLE_START': { if (!silent) { let input = event.input; if (typeof input !== 'string') { input = Array.isArray(input) ? input.join(', ') - : Object.keys(input as Record) - .map(key => (input as Record)[key]) - .join(', '); + : Object.values(input as Record).join(', '); } stderr( cyan(`bundles ${bold(input)} → ${bold(event.output.map(relativeId).join(', '))}...`) ); } + runWatchHook('onBundleStart'); break; + } - case 'BUNDLE_END': + case 'BUNDLE_END': { warnings.flush(); if (!silent) stderr( @@ -126,15 +121,19 @@ export async function watch(command: any) { )}` ) ); + runWatchHook('onBundleEnd'); if (event.result && event.result.getTimings) { printTimings(event.result.getTimings()); } break; + } - case 'END': - if (!silent && isTTY) { + case 'END': { + runWatchHook('onEnd'); + if (!silent) { stderr(`\n[${dateTime()}] waiting for changes...`); } + } } if ('result' in event && event.result) { @@ -143,16 +142,23 @@ export async function watch(command: any) { }); } - function close(code: number | null) { - process.removeListener('uncaughtException', close); + function close(code: number | null | undefined): true { + process.removeListener('uncaughtException', closeWithError); // removing a non-existent listener is a no-op process.stdin.removeListener('end', close); - - if (watcher) watcher.close(); if (configWatcher) configWatcher.close(); - - if (code) { - process.exit(code); - } + Promise.resolve(watcher?.close()).finally(() => { + process.exit(typeof code === 'number' ? code : 0); + }); + // Tell signal-exit that we are handling this gracefully + return true; } + + // return a promise that never resolves to keep the process running + return new Promise(() => {}); +} + +function closeWithError(error: Error): void { + error.name = `Uncaught ${error.name}`; + handleError(error); } diff --git a/cli/run/watchHooks.ts b/cli/run/watchHooks.ts new file mode 100644 index 00000000000..8e8d5c17cdd --- /dev/null +++ b/cli/run/watchHooks.ts @@ -0,0 +1,36 @@ +import { execSync } from 'node:child_process'; +import type { RollupWatchHooks } from '../../src/rollup/types'; +import { bold, cyan } from '../../src/utils/colors'; +import { stderr } from '../logging'; + +function extractWatchHooks( + command: Record +): Partial> { + if (!Array.isArray(command.watch)) return {}; + + return command.watch + .filter(value => typeof value === 'object') + .reduce((accumulator, keyValueOption) => ({ ...accumulator, ...keyValueOption }), {}); +} + +export function createWatchHooks(command: Record): (hook: RollupWatchHooks) => void { + const watchHooks = extractWatchHooks(command); + + return function (hook: RollupWatchHooks): void { + if (watchHooks[hook]) { + const cmd = watchHooks[hook]!; + + if (!command.silent) { + stderr(cyan(`watch.${hook} ${bold(`$ ${cmd}`)}`)); + } + + try { + // !! important - use stderr for all writes from execSync + const stdio = [process.stdin, process.stderr, process.stderr]; + execSync(cmd, { stdio: command.silent ? 'ignore' : stdio }); + } catch (error) { + stderr((error as Error).message); + } + } + }; +} diff --git a/cli/sourceMappingUrl.ts b/cli/sourceMappingUrl.ts deleted file mode 100644 index e7c42659fde..00000000000 --- a/cli/sourceMappingUrl.ts +++ /dev/null @@ -1,4 +0,0 @@ -let SOURCEMAPPING_URL = 'sourceMa'; -SOURCEMAPPING_URL += 'ppingURL'; - -export default SOURCEMAPPING_URL; diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 00000000000..fd7d7f6985a --- /dev/null +++ b/codecov.yml @@ -0,0 +1,4 @@ +codecov: + require_ci_to_pass: no + notify: + wait_for_ci: no \ No newline at end of file diff --git a/docs/.vitepress/config.ts b/docs/.vitepress/config.ts new file mode 100644 index 00000000000..6b0be252ef1 --- /dev/null +++ b/docs/.vitepress/config.ts @@ -0,0 +1,185 @@ +import alias from '@rollup/plugin-alias'; +import { transformerTwoslash } from '@shikijs/vitepress-twoslash'; +import { defineConfig } from 'vitepress'; +import { moduleAliases } from '../../build-plugins/aliases'; +import replaceBrowserModules from '../../build-plugins/replace-browser-modules'; +import type { ShikiTransformer } from '../../node_modules/vitepress/node_modules/@shikijs/types/dist/index'; +import '../declarations.d'; +import { examplesPlugin } from './create-examples'; +import { renderMermaidGraphsPlugin } from './mermaid'; +import { replacePathPicomatch } from './replace-path-picomatch'; +import { transposeTables } from './transpose-tables'; +import { buildEnd, callback, transformPageData } from './verify-anchors'; + +export default defineConfig({ + buildEnd, + description: 'compile JS code', + head: [ + ['link', { href: '/favicon.png', rel: 'icon', type: 'image/png' }], + ['link', { href: '/favicon.png', rel: 'apple-touch-icon', sizes: '128x128' }], + ['link', { href: '/manifest.json', rel: 'manifest' }], + ['meta', { content: '#333333', name: 'theme-color' }], + ['meta', { content: 'yes', name: 'mobile-web-app-capable' }], + ['meta', { content: 'default', name: 'apple-mobile-web-app-status-bar-style' }], + ['meta', { content: 'summary_large_image', name: 'twitter:card' }], + ['meta', { content: '@rollupjs', name: 'twitter:site' }], + ['meta', { content: '@rollupjs', name: 'twitter:creator' }], + ['meta', { content: 'Rollup', name: 'twitter:title' }], + ['meta', { content: 'The JavaScript module bundler', name: 'twitter:description' }], + ['meta', { content: 'https://rollupjs.org/twitter-card.jpg', name: 'twitter:image' }] + ], + locales: { + root: { label: 'English' }, + zh: { label: '简体中文', link: 'https://cn.rollupjs.org' } + }, + markdown: { + anchor: { + callback, + level: 2 + }, + codeTransformers: [ + transformerTwoslash({ + langs: [ + // defaults + 'ts', + 'tsx', + 'js', + 'jsx', + 'json', + 'vue', + // custom + 'javascript', + 'typescript' + ], + twoslashOptions: { + compilerOptions: { + moduleResolution: 100, // bundler + types: ['node'] + } + } + }) as ShikiTransformer + ], + config(md) { + transposeTables(md); + }, + linkify: false, + toc: { + level: [2, 3, 4] + } + }, + themeConfig: { + algolia: { + apiKey: '233d24494bdf54811b5c3181883b5ee3', + appId: 'V5XQ4IDZSG', + indexName: 'rollupjs' + }, + editLink: { + pattern: 'https://github.com/rollup/rollup/edit/master/docs/:path', + text: 'Edit this page on GitHub' + }, + footer: { + copyright: 'Copyright © 2015-present Rollup contributors', + message: 'Released under the MIT License.' + }, + logo: '/rollup-logo.svg', + nav: [ + { link: '/introduction/', text: 'guide' }, + { link: '/repl/', text: 'repl' }, + { link: 'https://is.gd/rollup_chat', text: 'chat' }, + { link: 'https://opencollective.com/rollup', text: 'opencollective' } + ], + outline: 'deep', + sidebar: [ + { + items: [ + { + link: '/introduction/', + text: 'Introduction' + }, + { + link: '/command-line-interface/', + text: 'Command Line Interface' + }, + { + link: '/javascript-api/', + text: 'JavaScript API' + } + ], + text: 'Getting started' + }, + { + items: [ + { + link: '/tutorial/', + text: 'Tutorial' + }, + { + link: '/es-module-syntax/', + text: 'ES Module Syntax' + }, + { + link: '/browser/', + text: 'Running Rollup in a Browser' + }, + { + link: '/faqs/', + text: 'Frequently Asked Questions' + }, + { + link: '/troubleshooting/', + text: 'Troubleshooting' + }, + { + link: '/migration/', + text: 'Migrating to Rollup 4' + }, + { + link: '/tools/', + text: 'Other Tools' + } + ], + text: 'More info' + }, + { + items: [ + { + link: '/configuration-options/', + text: 'Configuration Options' + }, + { + link: '/plugin-development/', + text: 'Plugin Development' + } + ], + text: 'API' + } + ], + socialLinks: [ + { icon: 'github', link: 'https://github.com/rollup/rollup' }, + { icon: 'mastodon', link: 'https://m.webtoo.ls/@rollupjs' } + ] + }, + title: 'Rollup', + transformPageData, + vite: { + optimizeDeps: { exclude: ['@rollup/pluginutils'] }, + plugins: [ + replacePathPicomatch(), + replaceBrowserModules(), + renderMermaidGraphsPlugin(), + replaceBrowserModules(), + { + apply: 'build', + enforce: 'pre', + name: 'replace-local-rollup', + resolveId(source) { + if (source.includes('/browser-entry')) { + return false; + } + } + }, + examplesPlugin(), + alias(moduleAliases) + ] + } +}); diff --git a/docs/.vitepress/create-examples.ts b/docs/.vitepress/create-examples.ts new file mode 100644 index 00000000000..2342049ce86 --- /dev/null +++ b/docs/.vitepress/create-examples.ts @@ -0,0 +1,67 @@ +import { readFile } from 'node:fs/promises'; +import type { Plugin } from 'vite'; +import type { RollupOptions } from '../../src/rollup/types'; +import type { Example, Module } from '../types'; +import { getFilesInDirectory } from './helpers'; + +const examplesDirectory = new URL('../repl/examples', import.meta.url); + +export function examplesPlugin(): Plugin { + return { + async load(id) { + if (id === 'examples.json') { + const exampleFiles = await getFilesInDirectory(examplesDirectory); + const examples: Example[] = await Promise.all( + exampleFiles.map(async id => { + const { + entryModules = ['main.js'], + options = {}, + title + }: { + entryModules?: string[]; + options?: RollupOptions; + title: string; + } = JSON.parse( + await readFile(new URL(`examples/${id}/example.json`, examplesDirectory), 'utf8') + ); + const moduleFiles = await getFilesInDirectory( + new URL(`examples/${id}/modules`, examplesDirectory) + ); + const modules: Module[] = await Promise.all( + moduleFiles.map(async name => { + const code = ( + await readFile( + new URL(`examples/${id}/modules/${name}`, examplesDirectory), + 'utf8' + ) + ).trim(); + return { code, isEntry: entryModules.includes(name), name }; + }) + ); + + modules.sort((a, b) => { + if (a.name === 'main.js') return -1; + if (b.name === 'main.js') return 1; + if (a.isEntry) return -1; + if (b.isEntry) return 1; + return a.name < b.name ? -1 : 1; + }); + + return { id, modules, options, title }; + }) + ); + const examplesById: Record = {}; + for (const example of examples) { + examplesById[example.id] = example; + } + return JSON.stringify(examplesById); + } + }, + name: 'examples', + resolveId(source) { + if (source === 'examples.json') { + return source; + } + } + }; +} diff --git a/docs/.vitepress/graphs/mermaid-66d62a8a.svg b/docs/.vitepress/graphs/mermaid-66d62a8a.svg new file mode 100644 index 00000000000..c59ba875546 --- /dev/null +++ b/docs/.vitepress/graphs/mermaid-66d62a8a.svg @@ -0,0 +1 @@ +
each chunk
each chunk
next chunk
each import()
each import.meta.*
import.meta.url
other
next chunk
banner
footer
intro
outro
renderDynamicImport
resolveFileUrl
resolveImportMeta
augmentChunkHash
closeBundle
generateBundle
outputOptions
renderChunk
renderError
renderStart
writeBundle
\ No newline at end of file diff --git a/docs/.vitepress/graphs/mermaid-7a3058ce.svg b/docs/.vitepress/graphs/mermaid-7a3058ce.svg new file mode 100644 index 00000000000..dae7e276388 --- /dev/null +++ b/docs/.vitepress/graphs/mermaid-7a3058ce.svg @@ -0,0 +1 @@ +
each entry
external
non-external
not cached
no imports
cached
false
true
each import()
non-external
each import
(cached)
each import
(not cached)
external
unresolved
watchChange
closeWatcher
buildEnd
buildStart
load
moduleParsed
options
resolveDynamicImport
resolveId
shouldTransformCachedModule
transform
\ No newline at end of file diff --git a/docs/.vitepress/helpers.ts b/docs/.vitepress/helpers.ts new file mode 100644 index 00000000000..9e806c6df77 --- /dev/null +++ b/docs/.vitepress/helpers.ts @@ -0,0 +1,5 @@ +import { readdir } from 'node:fs/promises'; + +export async function getFilesInDirectory(directory: URL): Promise { + return (await readdir(directory)).filter(file => file[0] !== '.'); +} diff --git a/docs/.vitepress/legacy-slugs.json b/docs/.vitepress/legacy-slugs.json new file mode 100644 index 00000000000..b9cc67d76ff --- /dev/null +++ b/docs/.vitepress/legacy-slugs.json @@ -0,0 +1 @@ +{"introduction/index.md":{"": "introduction","Overview":"overview","Installation":"installation","Quick Start":"quick-start","The Why":"the-why","Tree-Shaking":"tree-shaking","Compatibility":"compatibility","Importing CommonJS":"importing-commonjs","Publishing ES Modules":"publishing-es-modules"},"command-line-interface/index.md":{"": "command-line-reference","Configuration Files":"configuration-files","Config Intellisense":"config-intellisense","Differences to the JavaScript API":"differences-to-the-javascript-api","Loading a configuration from a Node package":"loading-a-configuration-from-a-node-package","Caveats when using native Node ES modules":"caveats-when-using-native-node-es-modules","Getting the current directory":"getting-the-current-directory","Importing package.json":"importing-packagejson","Command line flags":"command-line-flags","-h/--help":"-h--help","-p plugin, --plugin plugin":"-p-plugin---plugin-plugin","--configPlugin plugin":"--configplugin-plugin","--bundleConfigAsCjs":"--bundleconfigascjs","-v/--version":"-v--version","-w/--watch":"-w--watch","--silent":"--silent","--failAfterWarnings":"--failafterwarnings","--environment values":"--environment-values","--waitForBundleInput":"--waitforbundleinput","--stdin=ext":"--stdinext","--no-stdin":"--no-stdin","--watch.onStart cmd, --watch.onBundleStart cmd, --watch.onBundleEnd cmd, --watch.onEnd cmd, --watch.onError cmd":"--watchonstart-cmd---watchonbundlestart-cmd---watchonbundleend-cmd---watchonend-cmd---watchonerror-cmd","Reading a file from stdin":"reading-a-file-from-stdin"},"javascript-api/index.md":{"": "javascript-api","rollup.rollup":"rolluprollup","inputOptions object":"inputoptions-object","outputOptions object":"outputoptions-object","rollup.watch":"rollupwatch","watchOptions":"watchoptions","Programmatically loading a config file":"programmatically-loading-a-config-file"},"es-module-syntax/index.md":{"": "es-module-syntax","Importing":"importing","Named Imports":"named-imports","Namespace Imports":"namespace-imports","Default Import":"default-import","Empty Import":"empty-import","Dynamic Import":"dynamic-import","Exporting":"exporting","Named exports":"named-exports","Default Export":"default-export","How bindings work":"how-bindings-work"},"tutorial/index.md":{"": "tutorial","Creating Your First Bundle":"creating-your-first-bundle","Using Config Files":"using-config-files","Installing Rollup locally":"installing-rollup-locally","Using plugins":"using-plugins","Using output plugins":"using-output-plugins","Code Splitting":"code-splitting"},"plugin-development/index.md":{"": "plugin-development","Plugins Overview":"plugins-overview","A Simple Example":"a-simple-example","Conventions":"conventions","Properties":"properties","name":"name","version?":"version","Build Hooks":"build-hooks","buildEnd":"buildend","buildStart":"buildstart","closeWatcher":"closewatcher","load":"load","moduleParsed":"moduleparsed","options":"options","resolveDynamicImport":"resolvedynamicimport","resolveId":"resolveid","shouldTransformCachedModule":"shouldtransformcachedmodule","transform":"transform","watchChange":"watchchange","Output Generation Hooks":"output-generation-hooks","augmentChunkHash":"augmentchunkhash","banner":"banner","closeBundle":"closebundle","footer":"footer","generateBundle":"generatebundle","intro":"intro","outputOptions":"outputoptions","outro":"outro","renderChunk":"renderchunk","renderDynamicImport":"renderdynamicimport","renderError":"rendererror","renderStart":"renderstart","resolveFileUrl":"resolvefileurl","resolveImportMeta":"resolveimportmeta","writeBundle":"writebundle","Plugin Context":"plugin-context","this.addWatchFile":"thisaddwatchfile","this.emitFile":"thisemitfile","this.error":"thiserror","this.getCombinedSourcemap":"thisgetcombinedsourcemap","this.getFileName":"thisgetfilename","this.getModuleIds":"thisgetmoduleids","this.getModuleInfo":"thisgetmoduleinfo","this.getWatchFiles":"thisgetwatchfiles","this.load":"thisload","this.meta":"thismeta","this.parse":"thisparse","this.resolve":"thisresolve","this.setAssetSource":"thissetassetsource","this.warn":"thiswarn","Deprecated Context Functions":"deprecated-context-functions","File URLs":"file-urls","Transformers":"transformers","Example Transformer":"example-transformer","Source Code Transformations":"source-code-transformations","Synthetic named exports":"synthetic-named-exports","Inter-plugin communication":"inter-plugin-communication","Custom resolver options":"custom-resolver-options","Custom module meta-data":"custom-module-meta-data","Direct plugin communication":"direct-plugin-communication"},"faqs/index.md":{"": "faqs","Why are ES modules better than CommonJS Modules?":"why-are-es-modules-better-than-commonjs-modules","What Is tree-shaking?":"what-is-tree-shaking","How do I use Rollup in Node.js with CommonJS modules?":"how-do-i-use-rollup-in-nodejs-with-commonjs-modules","Why isn't node-resolve a built-in feature?":"why-isnt-node-resolve-a-built-in-feature","Why do additional imports turn up in my entry chunks when code-splitting?":"why-do-additional-imports-turn-up-in-my-entry-chunks-when-code-splitting","How do I add polyfills to a Rollup bundle?":"how-do-i-add-polyfills-to-a-rollup-bundle","Is Rollup meant for building libraries or applications?":"is-rollup-meant-for-building-libraries-or-applications","How do I run Rollup itself in a browser":"how-do-i-run-rollup-itself-in-a-browser","Who made the Rollup logo? It's lovely.":"who-made-the-rollup-logo-its-lovely"},"tools/index.md":{"": "tools","With NPM Packages":"with-npm-packages","@rollup/plugin-node-resolve":"rollupplugin-node-resolve","@rollup/plugin-commonjs":"rollupplugin-commonjs","Peer dependencies":"peer-dependencies","Babel":"babel","Gulp":"gulp","Deno":"deno"},"troubleshooting/index.md":{"": "troubleshooting","Avoiding eval":"avoiding-eval","eval2 = eval":"eval2--eval","new Function":"new-function","Tree-shaking doesn't seem to be working":"tree-shaking-doesnt-seem-to-be-working","Error: [name] is not exported by [module]":"error-name-is-not-exported-by-module","Error: this is undefined":"error-this-is-undefined","Warning: Sourcemap is likely to be incorrect":"warning-sourcemap-is-likely-to-be-incorrect","Warning: Treating [module] as external dependency":"warning-treating-module-as-external-dependency","Error: EMFILE: too many open files":"error-emfile-too-many-open-files","Error: JavaScript heap out of memory":"error-javascript-heap-out-of-memory","Error: Node tried to load your configuration file as CommonJS even though it is likely an ES module":"error-node-tried-to-load-your-configuration-file-as-commonjs-even-though-it-is-likely-an-es-module"},"migration/index.md":{"": "migration","Prerequisites":"prerequisites","Using Configuration Files":"using-configuration-files","Changed Defaults":"changed-defaults","More Changed Options":"more-changed-options","Dynamic Import in CommonJS Output":"dynamic-import-in-commonjs-output","Changes to the Plugin API":"changes-to-the-plugin-api"},"configuration-options/index.md":{"": "big-list-of-options","Core functionality":"core-functionality","external":"external","input":"input","output.dir":"outputdir","output.file":"outputfile","output.format":"outputformat","output.globals":"outputglobals","output.name":"outputname","output.plugins":"outputplugins","plugins":"plugins","Advanced functionality":"advanced-functionality","cache":"cache","makeAbsoluteExternalsRelative":"makeabsoluteexternalsrelative","maxParallelFileOps":"maxparallelfileops","onwarn":"onwarn","output.assetFileNames":"outputassetfilenames","output.banner/output.footer":"outputbanneroutputfooter","output.chunkFileNames":"outputchunkfilenames","output.compact":"outputcompact","output.dynamicImportInCjs":"outputdynamicimportincjs","output.entryFileNames":"outputentryfilenames","output.extend":"outputextend","output.externalImportAssertions":"outputexternalimportassertions","output.generatedCode":"outputgeneratedcode","output.hoistTransitiveImports":"outputhoisttransitiveimports","output.inlineDynamicImports":"outputinlinedynamicimports","output.interop":"outputinterop","output.intro/output.outro":"outputintrooutputoutro","output.manualChunks":"outputmanualchunks","output.minifyInternalExports":"outputminifyinternalexports","output.paths":"outputpaths","output.preserveModules":"outputpreservemodules","output.preserveModulesRoot":"outputpreservemodulesroot","output.sourcemap":"outputsourcemap","output.sourcemapBaseUrl":"outputsourcemapbaseurl","output.sourcemapExcludeSources":"outputsourcemapexcludesources","output.sourcemapFile":"outputsourcemapfile","output.sourcemapPathTransform":"outputsourcemappathtransform","output.validate":"outputvalidate","preserveEntrySignatures":"preserveentrysignatures","strictDeprecations":"strictdeprecations","Danger zone":"danger-zone","acorn":"acorn","acornInjectPlugins":"acorninjectplugins","context":"context","moduleContext":"modulecontext","output.amd":"outputamd","output.esModule":"outputesmodule","output.exports":"outputexports","output.externalLiveBindings":"outputexternallivebindings","output.freeze":"outputfreeze","output.indent":"outputindent","output.noConflict":"outputnoconflict","output.sanitizeFileName":"outputsanitizefilename","output.strict":"outputstrict","output.systemNullSetters":"outputsystemnullsetters","preserveSymlinks":"preservesymlinks","shimMissingExports":"shimmissingexports","treeshake":"treeshake","Experimental options":"experimental-options","experimentalCacheExpiry":"experimentalcacheexpiry","experimentalMinChunkSize":"experimentalminchunksize","perf":"perf","watch":"watch-options","watch.buildDelay":"watchbuilddelay","watch.chokidar":"watchchokidar","watch.clearScreen":"watchclearscreen","watch.exclude":"watchexclude","watch.include":"watchinclude","watch.skipWrite":"watchskipwrite","Deprecated options":"deprecated-options","inlineDynamicImports":"inlinedynamicimports","manualChunks":"manualchunks","maxParallelFileReads":"maxparallelfilereads","output.dynamicImportFunction":"outputdynamicimportfunction","output.preferConst":"outputpreferconst","output.namespaceToStringTag":"outputnamespacetostringtag","preserveModules":"preservemodules"}} diff --git a/docs/.vitepress/mermaid.config.json b/docs/.vitepress/mermaid.config.json new file mode 100644 index 00000000000..5a8cafb8b6c --- /dev/null +++ b/docs/.vitepress/mermaid.config.json @@ -0,0 +1,3 @@ +{ + "themeCSS": "* { line-height: 1.5; } span.edgeLabel { padding: 2px 5px; }" +} diff --git a/docs/.vitepress/mermaid.ts b/docs/.vitepress/mermaid.ts new file mode 100644 index 00000000000..cd26014af2f --- /dev/null +++ b/docs/.vitepress/mermaid.ts @@ -0,0 +1,95 @@ +import { exec } from 'node:child_process'; +import { createHash } from 'node:crypto'; +import { readFile, writeFile } from 'node:fs/promises'; +import { fileURLToPath } from 'node:url'; +import { promisify } from 'node:util'; +import type { Plugin } from 'vite'; +import { mkdir } from '../../src/utils/fs'; +import { getFilesInDirectory } from './helpers'; + +const execPromise = promisify(exec); +const graphsDirectory = new URL('graphs/', import.meta.url); + +const mermaidRegExp = /^```mermaid\n([\S\s]*?)\n```/gm; +const greaterThanRegExp = />/g; +const svgIdRegExp = /my-svg/g; +const styleTagRegExp = / + +
+
+ parallel +
+
+ sequential +
+
+ first +
+
+ async +
+
+ sync +
+
+ +```mermaid +flowchart TB + classDef default fill:transparent, color:#000; + classDef hook-parallel fill:#ffb3b3,stroke:#000; + classDef hook-sequential fill:#ffd2b3,stroke:#000; + classDef hook-first fill:#fff2b3,stroke:#000; + classDef hook-sequential-sync fill:#ffd2b3,stroke:#f00; + classDef hook-first-sync fill:#fff2b3,stroke:#f00; + + watchchange("watchChange"):::hook-parallel + click watchchange "#watchchange" _parent + + closewatcher("closeWatcher"):::hook-parallel + click closewatcher "#closewatcher" _parent + + buildend("buildEnd"):::hook-parallel + click buildend "#buildend" _parent + + buildstart("buildStart"):::hook-parallel + click buildstart "#buildstart" _parent + + load("load"):::hook-first + click load "#load" _parent + + moduleparsed("moduleParsed"):::hook-parallel + click moduleparsed "#moduleparsed" _parent + + options("options"):::hook-sequential + click options "#options" _parent + + resolvedynamicimport("resolveDynamicImport"):::hook-first + click resolvedynamicimport "#resolvedynamicimport" _parent + + resolveid("resolveId"):::hook-first + click resolveid "#resolveid" _parent + + shouldtransformcachedmodule("shouldTransformCachedModule"):::hook-first + click shouldtransformcachedmodule "#shouldtransformcachedmodule" _parent + + transform("transform"):::hook-sequential + click transform "#transform" _parent + + options + --> buildstart + --> |each entry|resolveid + .-> |external|buildend + + resolveid + --> |non-external|load + --> |not cached|transform + --> moduleparsed + .-> |no imports|buildend + + load + --> |cached|shouldtransformcachedmodule + --> |false|moduleparsed + + shouldtransformcachedmodule + --> |true|transform + + moduleparsed + --> |"each import()"|resolvedynamicimport + --> |non-external|load + + moduleparsed + --> |"each import\n(cached)"|load + + moduleparsed + --> |"each import\n(not cached)"|resolveid + + resolvedynamicimport + .-> |external|buildend + + resolvedynamicimport + --> |unresolved|resolveid +``` + +Additionally, in watch mode the [`watchChange`](#watchchange) hook can be triggered at any time to notify a new run will be triggered once the current run has generated its outputs. Also, when watcher closes, the [`closeWatcher`](#closewatcher) hook will be triggered. + +See [Output Generation Hooks](#output-generation-hooks) for hooks that run during the output generation phase to modify the generated output. + +### buildEnd + +| | | +| --: | :-- | +| Type: | `(error?: Error) => void` | +| Kind: | async, parallel | +| Previous: | [`moduleParsed`](#moduleparsed), [`resolveId`](#resolveid) or [`resolveDynamicImport`](#resolvedynamicimport) | +| Next: | [`outputOptions`](#outputoptions) in the output generation phase as this is the last hook of the build phase | + +Called when Rollup has finished bundling, but before `generate` or `write` is called; you can also return a Promise. If an error occurred during the build, it is passed on to this hook. + +### buildStart + +| | | +| --: | :-- | +| Type: | `(options: InputOptions) => void` | +| Kind: | async, parallel | +| Previous: | [`options`](#options) | +| Next: | [`resolveId`](#resolveid) to resolve each entry point in parallel | + +Called on each `rollup.rollup` build. This is the recommended hook to use when you need access to the options passed to `rollup.rollup()` as it takes the transformations by all [`options`](#options) hooks into account and also contains the right default values for unset options. + +### closeWatcher + +| | | +| --: | :-- | +| Type: | `() => void` | +| Kind: | async, parallel | +| Previous/Next: | This hook can be triggered at any time both during the build and the output generation phases. If that is the case, the current build will still proceed but no new [`watchChange`](#watchchange) events will be triggered ever | + +Notifies a plugin when the watcher process will close so that all open resources can be closed too. If a Promise is returned, Rollup will wait for the Promise to resolve before closing the process. This hook cannot be used by output plugins. + +### load + +| | | +| --: | :-- | +| Type: | `(id: string) => LoadResult` | +| Kind: | async, first | +| Previous: | [`resolveId`](#resolveid) or [`resolveDynamicImport`](#resolvedynamicimport) where the loaded id was resolved. Additionally, this hook can be triggered at any time from plugin hooks by calling [`this.load`](#this-load) to preload the module corresponding to an id | +| Next: | [`transform`](#transform) to transform the loaded file if no cache was used, or there was no cached copy with the same `code`, otherwise [`shouldTransformCachedModule`](#shouldtransformcachedmodule) | + +```typescript +type LoadResult = string | null | SourceDescription; + +interface SourceDescription { + code: string; + map?: string | SourceMap; + ast?: ESTree.Program; + attributes?: { [key: string]: string } | null; + meta?: { [plugin: string]: any } | null; + moduleSideEffects?: boolean | 'no-treeshake' | null; + syntheticNamedExports?: boolean | string | null; +} +``` + +Defines a custom loader. Returning `null` defers to other `load` functions (and eventually the default behavior of loading from the file system). To prevent additional parsing overhead in case e.g. this hook already used [`this.parse`](#this-parse) to generate an AST for some reason, this hook can optionally return a `{ code, ast, map }` object. The `ast` must be a standard ESTree AST with `start` and `end` properties for each node. If the transformation does not move code, you can preserve existing sourcemaps by setting `map` to `null`. Otherwise, you might need to generate the source map. See the section on [source code transformations](#source-code-transformations). + +If `false` is returned for `moduleSideEffects` and no other module imports anything from this module, then this module will not be included in the bundle even if the module would have side effects. If `true` is returned, Rollup will use its default algorithm to include all statements in the module that have side effects (such as modifying a global or exported variable). If `"no-treeshake"` is returned, treeshaking will be turned off for this module and it will also be included in one of the generated chunks even if it is empty. If `null` is returned or the flag is omitted, then `moduleSideEffects` will be determined by the first `resolveId` hook that resolved this module, the [`treeshake.moduleSideEffects`](../configuration-options/index.md#treeshake-modulesideeffects) option, or eventually default to `true`. The `transform` hook can override this. + +`attributes` contain the import attributes that were used when this module was imported. At the moment, they do not influence rendering for bundled modules but rather serve documentation purposes. If `null` is returned or the flag is omitted, then `attributes` will be determined by the first `resolveId` hook that resolved this module, or the attributes present in the first import of this module. The `transform` hook can override this. + +See [synthetic named exports](#synthetic-named-exports) for the effect of the `syntheticNamedExports` option. If `null` is returned or the flag is omitted, then `syntheticNamedExports` will be determined by the first `resolveId` hook that resolved this module or eventually default to `false`. The `transform` hook can override this. + +See [custom module meta-data](#custom-module-meta-data) for how to use the `meta` option. If a `meta` object is returned by this hook, it will be merged shallowly with any `meta` object returned by the resolveId hook. If no hook returns a `meta` object it will default to an empty object. The `transform` hook can further add or replace properties of this object. + +You can use [`this.getModuleInfo`](#this-getmoduleinfo) to find out the previous values of `attributes`, `meta`, `moduleSideEffects` and `syntheticNamedExports` inside this hook. + +### moduleParsed + +| | | +| --: | :-- | +| Type: | `(moduleInfo: ModuleInfo) => void` | +| Kind: | async, parallel | +| Previous: | [`transform`](#transform) where the currently handled file was transformed | +| Next: | [`resolveId`](#resolveid) and [`resolveDynamicImport`](#resolvedynamicimport) to resolve all discovered static and dynamic imports in parallel if present, otherwise [`buildEnd`](#buildend) | + +This hook is called each time a module has been fully parsed by Rollup. See [`this.getModuleInfo`](#this-getmoduleinfo) for what information is passed to this hook. + +In contrast to the [`transform`](#transform) hook, this hook is never cached and can be used to get information about both cached and other modules, including the final shape of the `meta` property, the `code` and the `ast`. + +This hook will wait until all imports are resolved so that the information in `moduleInfo.importedIds`, `moduleInfo.dynamicallyImportedIds`, `moduleInfo.importedIdResolutions`, and `moduleInfo.dynamicallyImportedIdResolutions` is complete and accurate. Note however that information about importing modules may be incomplete as additional importers could be discovered later. If you need this information, use the [`buildEnd`](#buildend) hook. + +### onLog + +| | | +| -------------: | :----------------------------------------------------- | +| Type: | `(level: LogLevel, log: RollupLog) => boolean \| null` | +| Kind: | sync, sequential | +| Previous/Next: | This hook can be triggered at any time. | + +See the [`onLog`](../configuration-options/index.md#onlog) option for the available `Loglevel` values and the `RollupLog` type. + +A function that receives and filters logs and warnings generated by Rollup and plugins before they are passed to the [`onLog`](../configuration-options/index.md#onlog) option or printed to the console. + +If `false` is returned from this hook, the log will be filtered. Otherwise, the log will be handed to the `onLog` hook of the next plugin, the `onLog` option, or printed to the console. Plugins can also change the log level of a log or turn a log into an error by passing the log to [`this.error`](#this-error), [`this.warn`](#this-warn), [`this.info`](#this-info) or [`this.debug`](#this-debug) and returning `false`. Note that unlike other plugin hooks that add e.g. the plugin name to the log, those functions will not add or change properties of the log. Additionally, logs generated by an `onLog` hook will not be passed back to the `onLog` hook of the same plugin. If another plugin generates a log in response to such a log in its own `onLog` hook, this log will not be passed to the original `onLog` hook, either. + +```js twoslash +// ---cut-start--- +/** @returns {import('rollup').Plugin} */ +// ---cut-end--- +function plugin1() { + return { + name: 'plugin1', + buildStart() { + this.info({ message: 'Hey', pluginCode: 'SPECIAL_CODE' }); + }, + onLog(level, log) { + if (log.plugin === 'plugin1' && log.pluginCode === 'SPECIAL_CODE') { + // We turn logs into warnings based on their code. This warnings + // will not be passed back to the same plugin to avoid an + // infinite loop, but other plugins will still receive it. + this.warn(log); + return false; + } + } + }; +} + +// ---cut-start--- +/** @returns {import('rollup').Plugin} */ +// ---cut-end--- +function plugin2() { + return { + name: 'plugin2', + onLog(level, log) { + if (log.plugin === 'plugin1' && log.pluginCode === 'SPECIAL_CODE') { + // You can modify logs in this hooks as well + log.meta = 'processed by plugin 2'; + // This turns the log back to "info". If this happens in + // response to the first plugin, it will not be passed back to + // either plugin to avoid an infinite loop. If both plugins are + // active, the log will be an info log if the second plugin is + // placed after the first one + this.info(log); + return false; + } + } + }; +} +``` + +Like the [`options`](#options) hook, this hook does not have access to most [plugin context](#plugin-context) utility functions as it may be run before Rollup is fully configured. The only supported properties are [`this.meta`](#this-meta) as well as [`this.error`](#this-error), [`this.warn`](#this-warn), [`this.info`](#this-info) and [`this.debug`](#this-debug) for logging and errors. + +### options + +| | | +| --------: | :------------------------------------------------ | +| Type: | `(options: InputOptions) => InputOptions \| null` | +| Kind: | async, sequential | +| Previous: | This is the first hook of the build phase | +| Next: | [`buildStart`](#buildstart) | + +Replaces or manipulates the options object passed to `rollup.rollup`. Returning `null` does not replace anything. If you just need to read the options, it is recommended to use the [`buildStart`](#buildstart) hook as that hook has access to the options after the transformations from all `options` hooks have been taken into account. + +Like the [`onLog`](#onlog) hook, this hook does not have access to most [plugin context](#plugin-context) utility functions as it is run before Rollup is fully configured. The only supported properties are [`this.meta`](#this-meta) as well as [`this.error`](#this-error), [`this.warn`](#this-warn), [`this.info`](#this-info) and [`this.debug`](#this-debug) for logging and errors. + +### resolveDynamicImport + +| | | +| --: | :-- | +| Type: | `ResolveDynamicImportHook` | +| Kind: | async, first | +| Previous: | [`moduleParsed`](#moduleparsed) for the importing file | +| Next: | [`load`](#load) if the hook resolved with an id that has not yet been loaded, [`resolveId`](#resolveid) if the dynamic import contains a string and was not resolved by the hook, otherwise [`buildEnd`](#buildend) | + +```typescript +type ResolveDynamicImportHook = ( + specifier: string | AstNode, + importer: string, + options: { attributes: Record } +) => ResolveIdResult; +``` + +::: tip + +The return type **ResolveIdResult** is the same as that of the [`resolveId`](#resolveid) hook. + +::: + +Defines a custom resolver for dynamic imports. Returning `false` signals that the import should be kept as it is and not be passed to other resolvers thus making it external. Similar to the [`resolveId`](#resolveid) hook, you can also return an object to resolve the import to a different id while marking it as external at the same time. + +`attributes` tells you which import attributes were present in the import. I.e. `import("foo", {assert: {type: "json"}})` will pass along `attributes: {type: "json"}`. + +In case a dynamic import is passed a string as argument, a string returned from this hook will be interpreted as an existing module id while returning `null` will defer to other resolvers and eventually to `resolveId` . + +In case a dynamic import is not passed a string as argument, this hook gets access to the raw AST nodes to analyze and behaves slightly different in the following ways: + +- If all plugins return `null`, the import is treated as `external` without a warning. +- If a string is returned, this string is _not_ interpreted as a module id but is instead used as a replacement for the import argument. It is the responsibility of the plugin to make sure the generated code is valid. +- To resolve such an import to an existing module, you can still return an object `{id, external}`. + +Note that the return value of this hook will not be passed to `resolveId` afterwards; if you need access to the static resolution algorithm, you can use [`this.resolve(source, importer)`](#this-resolve) on the plugin context. + +### resolveId + +| | | +| --: | :-- | +| Type: | `ResolveIdHook` | +| Kind: | async, first | +| Previous: | [`buildStart`](#buildstart) if we are resolving an entry point, [`moduleParsed`](#moduleparsed) if we are resolving an import, or as fallback for [`resolveDynamicImport`](#resolvedynamicimport). Additionally, this hook can be triggered during the build phase from plugin hooks by calling [`this.emitFile`](#this-emitfile) to emit an entry point or at any time by calling [`this.resolve`](#this-resolve) to manually resolve an id | +| Next: | [`load`](#load) if the resolved id has not yet been loaded, otherwise [`buildEnd`](#buildend) | + +```typescript +type ResolveIdHook = ( + source: string, + importer: string | undefined, + options: { + attributes: Record; + custom?: { [plugin: string]: any }; + isEntry: boolean; + } +) => ResolveIdResult; + +type ResolveIdResult = string | null | false | PartialResolvedId; + +interface PartialResolvedId { + id: string; + external?: boolean | 'absolute' | 'relative'; + attributes?: Record | null; + meta?: { [plugin: string]: any } | null; + moduleSideEffects?: boolean | 'no-treeshake' | null; + resolvedBy?: string | null; + syntheticNamedExports?: boolean | string | null; +} +``` + +Defines a custom resolver. A resolver can be useful for e.g. locating third-party dependencies. Here `source` is the importee exactly as it is written in the import statement, i.e. for + +```js +import { foo } from '../bar.js'; +``` + +the source will be `"../bar.js"`. + +The `importer` is the fully resolved id of the importing module. When resolving entry points, importer will usually be `undefined`. An exception here are entry points generated via [`this.emitFile`](#this-emitfile) as here, you can provide an `importer` argument. + +For those cases, the `isEntry` option will tell you if we are resolving a user defined entry point, an emitted chunk, or if the `isEntry` parameter was provided for the [`this.resolve`](#this-resolve) context function. + +You can use this for instance as a mechanism to define custom proxy modules for entry points. The following plugin will proxy all entry points to inject a polyfill import. + +```js twoslash +// We prefix the polyfill id with \0 to tell other plugins not to try to load or +// transform it +const POLYFILL_ID = '\0polyfill'; +const PROXY_SUFFIX = '?inject-polyfill-proxy'; + +// ---cut-start--- +/** @returns {import('rollup').Plugin} */ +// ---cut-end--- +function injectPolyfillPlugin() { + return { + name: 'inject-polyfill', + async resolveId(source, importer, options) { + if (source === POLYFILL_ID) { + // It is important that side effects are always respected + // for polyfills, otherwise using + // "treeshake.moduleSideEffects: false" may prevent the + // polyfill from being included. + return { id: POLYFILL_ID, moduleSideEffects: true }; + } + if (options.isEntry) { + // Determine what the actual entry would have been. + const resolution = await this.resolve(source, importer, options); + // If it cannot be resolved or is external, just return it + // so that Rollup can display an error + if (!resolution || resolution.external) return resolution; + // In the load hook of the proxy, we need to know if the + // entry has a default export. There, however, we no longer + // have the full "resolution" object that may contain + // meta-data from other plugins that is only added on first + // load. Therefore we trigger loading here. + const moduleInfo = await this.load(resolution); + // We need to make sure side effects in the original entry + // point are respected even for + // treeshake.moduleSideEffects: false. "moduleSideEffects" + // is a writable property on ModuleInfo. + moduleInfo.moduleSideEffects = true; + // It is important that the new entry does not start with + // \0 and has the same directory as the original one to not + // mess up relative external import generation. Also + // keeping the name and just adding a "?query" to the end + // ensures that preserveModules will generate the original + // entry name for this entry. + return `${resolution.id}${PROXY_SUFFIX}`; + } + return null; + }, + load(id) { + if (id === POLYFILL_ID) { + // Replace with actual polyfill + return "console.log('polyfill');"; + } + if (id.endsWith(PROXY_SUFFIX)) { + const entryId = id.slice(0, -PROXY_SUFFIX.length); + // We know ModuleInfo.hasDefaultExport is reliable because + // we awaited this.load in resolveId + const { hasDefaultExport } = this.getModuleInfo(entryId); + let code = + `import ${JSON.stringify(POLYFILL_ID)};` + + `export * from ${JSON.stringify(entryId)};`; + // Namespace reexports do not reexport default, so we need + // special handling here + if (hasDefaultExport) { + code += `export { default } from ${JSON.stringify(entryId)};`; + } + return code; + } + return null; + } + }; +} +``` + +`attributes` tells you which import attributes were present in the import. I.e. `import "foo" assert {type: "json"}` will pass along `attributes: {type: "json"}`. + +Returning `null` defers to other `resolveId` functions and eventually the default resolution behavior. Returning `false` signals that `source` should be treated as an external module and not included in the bundle. If this happens for a relative import, the id will be renormalized the same way as when the `external` option is used. + +If you return an object, then it is possible to resolve an import to a different id while excluding it from the bundle at the same time. This allows you to replace dependencies with external dependencies without the need for the user to mark them as "external" manually via the `external` option: + +```js twoslash +// ---cut-start--- +/** @returns {import('rollup').Plugin} */ +// ---cut-end--- +function externalizeDependencyPlugin() { + return { + name: 'externalize-dependency', + resolveId(source) { + if (source === 'my-dependency') { + return { id: 'my-dependency-develop', external: true }; + } + return null; + } + }; +} +``` + +If `external` is `true`, then absolute ids will be converted to relative ids based on the user's choice for the [`makeAbsoluteExternalsRelative`](../configuration-options/index.md#makeabsoluteexternalsrelative) option. This choice can be overridden by passing either `external: "relative"` to always convert an absolute id to a relative id or `external: "absolute"` to keep it as an absolute id. When returning an object, relative external ids, i.e. ids starting with `./` or `../`, will _not_ be internally converted to an absolute id and converted back to a relative id in the output, but are instead included in the output unchanged. If you want relative ids to be renormalised and deduplicated instead, return an absolute file system location as `id` and choose `external: "relative"`. + +If `false` is returned for `moduleSideEffects` in the first hook that resolves a module id and no other module imports anything from this module, then this module will not be included even if the module would have side effects. If `true` is returned, Rollup will use its default algorithm to include all statements in the module that have side effects (such as modifying a global or exported variable). If `"no-treeshake"` is returned, treeshaking will be turned off for this module and it will also be included in one of the generated chunks even if it is empty. If `null` is returned or the flag is omitted, then `moduleSideEffects` will be determined by the [`treeshake.moduleSideEffects`](../configuration-options/index.md#treeshake-modulesideeffects) option or default to `true`. The `load` and `transform` hooks can override this. + +`resolvedBy` can be explicitly declared in the returned object. It will replace the corresponding field returned by [`this.resolve`](#this-resolve). + +If you return a value for `attributes` for an external module, this will determine how imports of this module will be rendered when generating `"es"` output. E.g. `{id: "foo", external: true, attributes: {type: "json"}}` will cause imports of this module appear as `import "foo" assert {type: "json"}`. If you do not pass a value, the value of the `attributes` input parameter will be used. Pass an empty object to remove any attributes. While `attributes` do not influence rendering for bundled modules, they still need to be consistent across all imports of a module, otherwise a warning is emitted. The `load` and `transform` hooks can override this. + +See [synthetic named exports](#synthetic-named-exports) for the effect of the `syntheticNamedExports` option. If `null` is returned or the flag is omitted, then `syntheticNamedExports` will default to `false`. The `load` and `transform` hooks can override this. + +See [custom module meta-data](#custom-module-meta-data) for how to use the `meta` option. If `null` is returned or the option is omitted, then `meta` will default to an empty object. The `load` and `transform` hooks can add or replace properties of this object. + +Note that while `resolveId` will be called for each import of a module and can therefore resolve to the same `id` many times, values for `external`, `attributes`, `meta`, `moduleSideEffects` or `syntheticNamedExports` can only be set once before the module is loaded. The reason is that after this call, Rollup will continue with the [`load`](#load) and [`transform`](#transform) hooks for that module that may override these values and should take precedence if they do so. + +When triggering this hook from a plugin via [`this.resolve`](#this-resolve), it is possible to pass a custom options object to this hook. While this object will be passed unmodified, plugins should follow the convention of adding a `custom` property with an object where the keys correspond to the names of the plugins that the options are intended for. For details see [custom resolver options](#custom-resolver-options). + +In watch mode or when using the cache explicitly, the resolved imports of a cached module are also taken from the cache and not determined via the `resolveId` hook again. To prevent this, you can return `true` from the [`shouldTransformCachedModule`](#shouldtransformcachedmodule) hook for that module. This will remove the module and its import resolutions from cache and call `transform` and `resolveId` again. + +### shouldTransformCachedModule + +| | | +| --: | :-- | +| Type: | `ShouldTransformCachedModuleHook` | +| Kind: | async, first | +| Previous: | [`load`](#load) where the cached file was loaded to compare its code with the cached version | +| Next: | [`moduleParsed`](#moduleparsed) if no plugin returns `true`, otherwise [`transform`](#transform) | + +```typescript +type ShouldTransformCachedModuleHook = (options: { + ast: AstNode; + code: string; + id: string; + meta: { [plugin: string]: any }; + moduleSideEffects: boolean | 'no-treeshake'; + syntheticNamedExports: boolean | string; +}) => boolean | NullValue; +``` + +If the Rollup cache is used (e.g. in watch mode or explicitly via the JavaScript API), Rollup will skip the [`transform`](#transform) hook of a module if after the [`load`](#transform) hook, the loaded `code` is identical to the code of the cached copy. To prevent this, discard the cached copy and instead transform a module, plugins can implement this hook and return `true`. + +This hook can also be used to find out which modules were cached and access their cached meta information. + +If a plugin does not return a boolean, Rollup will trigger this hook for other plugins, otherwise all remaining plugins will be skipped. + +### transform + +| | | +| --: | :-- | +| Type: | `(code: string, id: string) => TransformResult` | +| Kind: | async, sequential | +| Previous: | [`load`](#load) where the currently handled file was loaded. If caching is used and there was a cached copy of that module, [`shouldTransformCachedModule`](#shouldtransformcachedmodule) if a plugin returned `true` for that hook | +| Next: | [`moduleParsed`](#moduleparsed) once the file has been processed and parsed | + +```typescript +type TransformResult = string | null | Partial; + +interface SourceDescription { + code: string; + map?: string | SourceMap; + ast?: ESTree.Program; + attributes?: { [key: string]: string } | null; + meta?: { [plugin: string]: any } | null; + moduleSideEffects?: boolean | 'no-treeshake' | null; + syntheticNamedExports?: boolean | string | null; +} +``` + +Can be used to transform individual modules. To prevent additional parsing overhead in case e.g. this hook already used [`this.parse`](#this-parse) to generate an AST for some reason, this hook can optionally return a `{ code, ast, map }` object. The `ast` must be a standard ESTree AST with `start` and `end` properties for each node. If the transformation does not move code, you can preserve existing sourcemaps by setting `map` to `null`. Otherwise, you might need to generate the source map. See [the section on source code transformations](#source-code-transformations). + +Note that in watch mode or when using the cache explicitly, the result of this hook is cached when rebuilding and the hook is only triggered again for a module `id` if either the `code` of the module has changed or a file has changed that was added via `this.addWatchFile` or `this.emitFile` the last time the hook was triggered for this module. + +In all other cases, the [`shouldTransformCachedModule`](#shouldtransformcachedmodule) hook is triggered instead, which gives access to the cached module. Returning `true` from `shouldTransformCachedModule` will remove the module from cache and instead call `transform` again. + +You can also use the object form of the return value to configure additional properties of the module. Note that it's possible to return only properties and no code transformations. + +If `false` is returned for `moduleSideEffects` and no other module imports anything from this module, then this module will not be included even if the module would have side effects. + +If `true` is returned, Rollup will use its default algorithm to include all statements in the module that have side effects (such as modifying a global or exported variable). + +If `"no-treeshake"` is returned, treeshaking will be turned off for this module and it will also be included in one of the generated chunks even if it is empty. + +If `null` is returned or the flag is omitted, then `moduleSideEffects` will be determined by the `load` hook that loaded this module, the first `resolveId` hook that resolved this module, the [`treeshake.moduleSideEffects`](../configuration-options/index.md#treeshake-modulesideeffects) option, or eventually default to `true`. + +`attributes` contain the import attributes that were used when this module was imported. At the moment, they do not influence rendering for bundled modules but rather serve documentation purposes. If `null` is returned or the flag is omitted, then `attributes` will be determined by the `load` hook that loaded this module, the first `resolveId` hook that resolved this module, or the attributes present in the first import of this module. + +See [synthetic named exports](#synthetic-named-exports) for the effect of the `syntheticNamedExports` option. If `null` is returned or the flag is omitted, then `syntheticNamedExports` will be determined by the `load` hook that loaded this module, the first `resolveId` hook that resolved this module, the [`treeshake.moduleSideEffects`](../configuration-options/index.md#treeshake-modulesideeffects) option, or eventually default to `false`. + +See [custom module meta-data](#custom-module-meta-data) for how to use the `meta` option. If `null` is returned or the option is omitted, then `meta` will be determined by the `load` hook that loaded this module, the first `resolveId` hook that resolved this module or eventually default to an empty object. + +You can use [`this.getModuleInfo`](#this-getmoduleinfo) to find out the previous values of `attributes`, `meta`, `moduleSideEffects` and `syntheticNamedExports` inside this hook. + +### watchChange + +| | | +| --: | :-- | +| Type: | `watchChange: (id: string, change: {event: 'create' \| 'update' \| 'delete'}) => void` | +| Kind: | async, parallel | +| Previous/Next: | This hook can be triggered at any time both during the build and the output generation phases. If that is the case, the current build will still proceed but a new build will be scheduled to start once the current build has completed, starting again with [`options`](#options) | + +Notifies a plugin whenever Rollup has detected a change to a monitored file in `--watch` mode. If a build is currently running, this hook is called once the build finished. It will be called once for every file that changed. If a Promise is returned, Rollup will wait for the Promise to resolve before scheduling another build. This hook cannot be used by output plugins. The second argument contains additional details of the change event. If you need to be notified immediately when a file changed, you can use the [`watch.onInvalidate`](../configuration-options/index.md#watch-oninvalidate) configuration option. + +## Output Generation Hooks + +Output generation hooks can provide information about a generated bundle and modify a build once complete. They work the same way and have the same types as [Build Hooks](#build-hooks) but are called separately for each call to `bundle.generate(outputOptions)` or `bundle.write(outputOptions)`. Plugins that only use output generation hooks can also be passed in via the output options and therefore run only for certain outputs. + +The first hook of the output generation phase is [`outputOptions`](#outputoptions), the last one is either [`generateBundle`](#generatebundle) if the output was successfully generated via `bundle.generate(...)`, [`writeBundle`](#writebundle) if the output was successfully generated via `bundle.write(...)`, or [`renderError`](#rendererror) if an error occurred at any time during the output generation. + +
+
+ parallel +
+
+ sequential +
+
+ first +
+
+ async +
+
+ sync +
+
+ +```mermaid +flowchart TB + classDef default fill:transparent, color:#000; + classDef hook-parallel fill:#ffb3b3,stroke:#000; + classDef hook-sequential fill:#ffd2b3,stroke:#000; + classDef hook-first fill:#fff2b3,stroke:#000; + classDef hook-sequential-sync fill:#ffd2b3,stroke:#f00; + classDef hook-first-sync fill:#fff2b3,stroke:#f00; + + augmentchunkhash("augmentChunkHash"):::hook-sequential-sync + click augmentchunkhash "#augmentchunkhash" _parent + + banner("banner"):::hook-sequential + click banner "#banner" _parent + + closebundle("closeBundle"):::hook-parallel + click closebundle "#closebundle" _parent + + footer("footer"):::hook-sequential + click footer "#footer" _parent + + generatebundle("generateBundle"):::hook-sequential + click generatebundle "#generatebundle" _parent + + intro("intro"):::hook-sequential + click intro "#intro" _parent + + outputoptions("outputOptions"):::hook-sequential-sync + click outputoptions "#outputoptions" _parent + + outro("outro"):::hook-sequential + click outro "#outro" _parent + + renderchunk("renderChunk"):::hook-sequential + click renderchunk "#renderchunk" _parent + + renderdynamicimport("renderDynamicImport"):::hook-first-sync + click renderdynamicimport "#renderdynamicimport" _parent + + rendererror("renderError"):::hook-parallel + click rendererror "#rendererror" _parent + + renderstart("renderStart"):::hook-parallel + click renderstart "#renderstart" _parent + + resolvefileurl("resolveFileUrl"):::hook-first-sync + click resolvefileurl "#resolvefileurl" _parent + + resolveimportmeta("resolveImportMeta"):::hook-first-sync + click resolveimportmeta "#resolveimportmeta" _parent + + writebundle("writeBundle"):::hook-parallel + click writebundle "#writebundle" _parent + + + outputoptions + --> renderstart + --> |each chunk|beforerenderdynamicimport + + afteraddons + --> |each chunk|renderchunk + + augmentchunkhash + --> generatebundle + --> writebundle + .-> closebundle + + subgraph generateChunks [" "] + direction TB + beforerenderdynamicimport(( )) + ---> beforeresolveimportmeta(( )) + ----> beforereaddons(( )) + --> banner & footer & intro & outro + --> afteraddons(( )) + .-> |next chunk|beforerenderdynamicimport + + beforerenderdynamicimport + --> |"each import()"|renderdynamicimport + --> beforerenderdynamicimport + + beforeresolveimportmeta + --> |each import.meta.*|beforeimportmeta(( )) + --> |import.meta.url|resolvefileurl + --> afterresolveimportmeta(( )) + + beforeimportmeta + --> |other|resolveimportmeta + --> afterresolveimportmeta + + afterresolveimportmeta + --> beforeresolveimportmeta + end + + renderchunk + --> augmentchunkhash + .-> |next chunk|renderchunk + + style generateChunks stroke-width:0px; + + rendererror + .-> closebundle +``` + +Additionally, [`closeBundle`](#closebundle) can be called as the very last hook, but it is the responsibility of the User to manually call [`bundle.close()`](../javascript-api/index.md#rollup-rollup) to trigger this. The CLI will always make sure this is the case. + +### augmentChunkHash + +| | | +| --: | :-- | +| Type: | `(chunkInfo: RenderedChunk) => string` | +| Kind: | sync, sequential | +| Previous: | [`renderChunk`](#renderchunk) | +| Next: | [`renderChunk`](#renderchunk) if there are other chunks that still need to be processed, otherwise [`generateBundle`](#generatebundle) | + +See the [`renderChunk`](../plugin-development/index.md#renderchunk) hook for the `RenderedChunk` type. + +Can be used to augment the hash of individual chunks. Called for each Rollup output chunk. Returning a falsy value will not modify the hash. Truthy values will be passed to [`hash.update`](https://nodejs.org/dist/latest-v12.x/docs/api/crypto.html#crypto_hash_update_data_inputencoding). The `RenderedChunk` type is a reduced version of the `OutputChunk` type in [`generateBundle`](#generatebundle) without `code` and `map` and using placeholders for hashes in file names. + +The following plugin will invalidate the hash of chunk `foo` with the current timestamp: + +```js twoslash +// ---cut-start--- +/** @returns {import('rollup').Plugin} */ +// ---cut-end--- +function augmentWithDatePlugin() { + return { + name: 'augment-with-date', + augmentChunkHash(chunkInfo) { + if (chunkInfo.name === 'foo') { + return Date.now().toString(); + } + } + }; +} +``` + +### banner + +| | | +| --: | :-- | +| Type: | `string \| ((chunk: RenderedChunk) => string)` | +| Kind: | async, sequential | +| Previous: | [`resolveFileUrl`](#resolvefileurl) for each use of `import.meta.ROLLUP_FILE_URL_referenceId` and [`resolveImportMeta`](#resolveimportmeta) for all other accesses to `import.meta` in the current chunk | +| Next: | [`renderDynamicImport`](#renderdynamicimport) for each dynamic import expression in the next chunk if there is another one, otherwise [`renderChunk`](#renderchunk) for the first chunk | + +Cf. [`output.banner/output.footer`](../configuration-options/index.md#output-banner-output-footer). + +### closeBundle + +| | | +| --: | :-- | +| Type: | `closeBundle: (error?: Error) => Promise \| void` | +| Kind: | async, parallel | +| Previous: | [`buildEnd`](#buildend) if there was a build error, otherwise when [`bundle.close()`](../javascript-api/index.md#rollup-rollup) is called, in which case this would be the last hook to be triggered | + +Can be used to clean up any external service that may be running. Rollup's CLI will make sure this hook is called after each run, but it is the responsibility of users of the JavaScript API to manually call `bundle.close()` once they are done generating bundles. For that reason, any plugin relying on this feature should carefully mention this in its documentation. + +If a plugin wants to retain resources across builds in watch mode, they can check for [`this.meta.watchMode`](#this-meta) in this hook and perform the necessary cleanup for watch mode in [`closeWatcher`](#closewatcher). + +If an error occurs during build or the `buildEnd` hook, it is passed to this hook as first argument. + +### footer + +| | | +| --: | :-- | +| Type: | `string \| ((chunk: RenderedChunk) => string)` | +| Kind: | async, sequential | +| Previous: | [`resolveFileUrl`](#resolvefileurl) for each use of `import.meta.ROLLUP_FILE_URL_referenceId` and [`resolveImportMeta`](#resolveimportmeta) for all other accesses to `import.meta` in the current chunk | +| Next: | [`renderDynamicImport`](#renderdynamicimport) for each dynamic import expression in the next chunk if there is another one, otherwise [`renderChunk`](#renderchunk) for the first chunk | + +Cf. [`output.banner/output.footer`](../configuration-options/index.md#output-banner-output-footer). + +### generateBundle + +| | | +| --: | :-- | +| Type: | `(options: OutputOptions, bundle: { [fileName: string]: OutputAsset \| OutputChunk }, isWrite: boolean) => void` | +| Kind: | async, sequential | +| Previous: | [`augmentChunkHash`](#augmentchunkhash) | +| Next: | [`writeBundle`](#writebundle) if the output was generated via `bundle.write(...)`, otherwise this is the last hook of the output generation phase and may again be followed by [`outputOptions`](#outputoptions) if another output is generated | + +```typescript +interface OutputAsset { + fileName: string; + names: string[]; + needsCodeReference: boolean; + originalFileNames: string[]; + source: string | Uint8Array; + type: 'asset'; +} + +interface OutputChunk { + code: string; + dynamicImports: string[]; + exports: string[]; + facadeModuleId: string | null; + fileName: string; + implicitlyLoadedBefore: string[]; + imports: string[]; + importedBindings: { [imported: string]: string[] }; + isDynamicEntry: boolean; + isEntry: boolean; + isImplicitEntry: boolean; + map: SourceMap | null; + modules: { + [id: string]: { + renderedExports: string[]; + removedExports: string[]; + renderedLength: number; + originalLength: number; + code: string | null; + }; + }; + moduleIds: string[]; + name: string; + preliminaryFileName: string; + referencedFiles: string[]; + sourcemapFileName: string | null; + type: 'chunk'; +} +``` + +Called at the end of `bundle.generate()` or immediately before the files are written in `bundle.write()`. To modify the files after they have been written, use the [`writeBundle`](#writebundle) hook. `bundle` provides the full list of files being written or generated along with their details. + +You can prevent files from being emitted by deleting them from the bundle object in this hook. To emit additional files, use the [`this.emitFile`](#this-emitfile) plugin context function. + +::: danger + +Do not directly add assets to the bundle. This circumvents internal mechanisms that Rollup has for tracking assets. It can also cause your asset to miss vital properties that Rollup relies on internally and your plugin can break with minor Rollup releases. + +Instead, always use [`this.emitFile`](#this-emitfile). + +::: + +### intro + +| | | +| --: | :-- | +| Type: | `string \| ((chunk: RenderedChunk) => string)` | +| Kind: | async, sequential | +| Previous: | [`resolveFileUrl`](#resolvefileurl) for each use of `import.meta.ROLLUP_FILE_URL_referenceId` and [`resolveImportMeta`](#resolveimportmeta) for all other accesses to `import.meta` in the current chunk | +| Next: | [`renderDynamicImport`](#renderdynamicimport) for each dynamic import expression in the next chunk if there is another one, otherwise [`renderChunk`](#renderchunk) for the first chunk | + +Cf. [`output.intro/output.outro`](../configuration-options/index.md#output-intro-output-outro). + +### outputOptions + +| | | +| --: | :-- | +| Type: | `(outputOptions: OutputOptions) => OutputOptions \| null` | +| Kind: | sync, sequential | +| Previous: | [`buildEnd`](#buildend) if this is the first time an output is generated, otherwise either [`generateBundle`](#generatebundle), [`writeBundle`](#writebundle) or [`renderError`](#rendererror) depending on the previously generated output. This is the first hook of the output generation phase | +| Next: | [`renderStart`](#renderstart) | + +Replaces or manipulates the output options object passed to `bundle.generate()` or `bundle.write()`. Returning `null` does not replace anything. If you just need to read the output options, it is recommended to use the [`renderStart`](#renderstart) hook as this hook has access to the output options after the transformations from all `outputOptions` hooks have been taken into account. + +### outro + +| | | +| --: | :-- | +| Type: | `string \| ((chunk: RenderedChunk) => string)` | +| Kind: | async, sequential | +| Previous: | [`resolveFileUrl`](#resolvefileurl) for each use of `import.meta.ROLLUP_FILE_URL_referenceId` and [`resolveImportMeta`](#resolveimportmeta) for all other accesses to `import.meta` in the current chunk | +| Next: | [`renderDynamicImport`](#renderdynamicimport) for each dynamic import expression in the next chunk if there is another one, otherwise [`renderChunk`](#renderchunk) for the first chunk | + +Cf. [`output.intro/output.outro`](../configuration-options/index.md#output-intro-output-outro). + +### renderChunk + +| | | +| --: | :-- | +| Type: | `RenderChunkHook` | +| Kind: | async, sequential | +| Previous: | [`banner`](#banner), [`footer`](#footer), [`intro`](#intro), [`outro`](#outro) of the last chunk | +| Next: | [`augmentChunkHash`](#augmentchunkhash) | + +```typescript +type RenderChunkHook = ( + code: string, + chunk: RenderedChunk, + options: NormalizedOutputOptions, + meta: { chunks: Record } +) => { code: string; map?: SourceMapInput } | string | null; + +interface RenderedChunk { + dynamicImports: string[]; + exports: string[]; + facadeModuleId: string | null; + fileName: string; + implicitlyLoadedBefore: string[]; + importedBindings: { + [imported: string]: string[]; + }; + imports: string[]; + isDynamicEntry: boolean; + isEntry: boolean; + isImplicitEntry: boolean; + moduleIds: string[]; + modules: { + [id: string]: RenderedModule; + }; + name: string; + referencedFiles: string[]; + type: 'chunk'; +} +``` + +Can be used to transform individual chunks. Called for each Rollup output chunk file. Returning `null` will apply no transformations. If you change code in this hook and want to support source maps, you need to return a `map` describing your changes, see [the section on source code transformations](#source-code-transformations). + +`chunk` contains additional information about the chunk using the same `OutputChunk` type as the [`generateBundle`](#generatebundle) hook with the following differences: + +- `code` and `map` are not set. Instead, use the `code` parameter of this hook. +- all referenced chunk file names that would contain hashes will contain hash placeholders instead. This includes `fileName`, `imports`, `importedBindings`, `dynamicImports` and `implicitlyLoadedBefore`. When you use such a placeholder file name or part of it in the code returned from this hook, Rollup will replace the placeholder with the actual hash before `generateBundle`, making sure the hash reflects the actual content of the final generated chunk including all referenced file hashes. + +`chunk` is mutable and changes applied in this hook will propagate to other plugins and to the generated bundle. That means if you add or remove imports or exports in this hook, you should update `imports`, `importedBindings` and/or `exports`. + +`meta.chunks` contains information about all the chunks Rollup is generating and gives you access to their `RenderedChunk` information, again using placeholders for hashes. That means you can explore the entire chunk graph in this hook. + +### renderDynamicImport + +| | | +| --: | :-- | +| Type: | `renderDynamicImportHook` | +| Kind: | sync, first | +| Previous: | [`renderStart`](#renderstart) if this is the first chunk, otherwise [`banner`](#banner), [`footer`](#footer), [`intro`](#intro), [`outro`](#outro) of the previous chunk | +| Next: | [`resolveFileUrl`](#resolvefileurl) for each use of `import.meta.ROLLUP_FILE_URL_referenceId` and [`resolveImportMeta`](#resolveimportmeta) for all other accesses to `import.meta` in the current chunk | + +```typescript +type renderDynamicImportHook = (options: { + customResolution: string | null; + format: string; + moduleId: string; + targetModuleId: string | null; + chunk: PreRenderedChunkWithFileName; + targetChunk: PreRenderedChunkWithFileName; + getTargetChunkImports: () => DynamicImportTargetChunk[] | null; +}) => { left: string; right: string } | null; + +type PreRenderedChunkWithFileName = PreRenderedChunk & { fileName: string }; + +type DynamicImportTargetChunk = + | ImportedInternalChunk + | ImportedExternalChunk; + +interface ImportedInternalChunk { + type: 'internal'; + fileName: string; + resolvedImportPath: string; + chunk: PreRenderedChunk; +} + +interface ImportedExternalChunk { + type: 'external'; + fileName: string; + resolvedImportPath: string; +} +``` + +See the [`chunkFileNames`](../configuration-options/index.md#output-chunkfilenames) option for the `PreRenderedChunk` type. + +This hook provides fine-grained control over how dynamic imports are rendered by providing replacements for the code to the left (`import(`) and right (`)`) of the argument of the import expression. Returning `null` defers to other hooks of this type and ultimately renders a format-specific default. + +`format` is the rendered output format, `moduleId` the id of the module performing the dynamic import. If the import could be resolved to an internal or external id, then `targetModuleId` will be set to this id, otherwise it will be `null`. If the dynamic import contained a non-string expression that was resolved by a [`resolveDynamicImport`](#resolvedynamicimport) hook to a replacement string, then `customResolution` will contain that string. `chunk` and `targetChunk` provide additional information about the chunk performing the import and the chunk being imported (the target chunk), respectively. `getTargetChunkImports` returns an array containing chunks which are imported by the target chunk. If the target chunk is unresolved or external, `targetChunk` will be null and `getTargetChunkImports` will return null. + +The `PreRenderedChunkWithFileName` type is identical to the `PreRenderedChunk` type except for the addition of the `fileName` field, which contains the path and file name of the chunk. `fileName` may contain a placeholder if the chunk file name format contains a hash. + +The following code will replace all dynamic imports with a custom handler, adding `import.meta.url` as a second argument to allow the handler to resolve relative imports correctly: + +```js twoslash +// ---cut-start--- +/** @returns {import('rollup').Plugin} */ +// ---cut-end--- +function dynamicImportPolyfillPlugin() { + return { + name: 'dynamic-import-polyfill', + renderDynamicImport() { + return { + left: 'dynamicImportPolyfill(', + right: ', import.meta.url)' + }; + } + }; +} + +// input +import('./lib.js'); + +// output +dynamicImportPolyfill('./lib.js', import.meta.url); +``` + +The next plugin will make sure all dynamic imports of `esm-lib` are marked as external and retained as import expressions to e.g. allow a CommonJS build to import an ES module in Node 13+, cf. how to [import ES modules from CommonJS](https://nodejs.org/api/esm.html#esm_import_expressions) in the Node documentation. + +```js twoslash +// ---cut-start--- +/** @returns {import('rollup').Plugin} */ +// ---cut-end--- +function retainImportExpressionPlugin() { + return { + name: 'retain-import-expression', + resolveDynamicImport(specifier) { + if (specifier === 'esm-lib') return false; + return null; + }, + renderDynamicImport({ targetModuleId }) { + if (targetModuleId === 'esm-lib') { + return { + left: 'import(', + right: ')' + }; + } + } + }; +} +``` + +When a dynamic import occurs, the browser will fetch the requested module and parse it. If the target module is discovered to have imports and they have not already been fetched, the browser must perform more network requests before it can execute the module. This will incur the latency of an additional network round trip. For static modules, Rollup will hoist transitive dependencies ([`hoistTransitiveDependencies`](../configuration-options/index.md#output-hoisttransitiveimports)) to prevent this from occuring. However, dependency hoisting is currently not automatically performed for dynamic imports. + +The following plugin can achieve similar preloading behavior for dynamic imports: + +```js twoslash +// ---cut-start--- +/** @returns {import('rollup').Plugin} */ +// ---cut-end--- +function dynamicImportDependencyPreloader() { + return { + name: 'dynamic-import-dependency-preloader', + renderDynamicImport({ getTargetChunkImports }) { + const transitiveImports = getTargetChunkImports(); + if (transitiveImports && transitiveImports.length > 0) { + const preload = getTargetChunkImports() + .map( + chunk => `\t/* preload */ import(${chunk.resolvedImportPath})` + ) + .join(',\n'); + return { + left: `(\n${preload},\n\timport(`, + right: `)\n)` + }; + } else { + return null; + } + } + }; +} +``` + + +```js +// input +import('./lib.js'); + +// output +( + /* preload */ import('./dependency-1.js'), + /* preload */ import('./dependency-2.js'), + import('./lib.js'); +); +``` + + +Note that when this hook rewrites dynamic imports in non-ES formats, no interop code to make sure that e.g. the default export is available as `.default` is generated. It is the responsibility of the plugin to make sure the rewritten dynamic import returns a Promise that resolves to a proper namespace object. + +### renderError + +| | | +| --: | :-- | +| Type: | `(error: Error) => void` | +| Kind: | async, parallel | +| Previous: | Any hook from [`renderStart`](#renderstart) to [`renderChunk`](#renderchunk) | +| Next: | If it is called, this is the last hook of the output generation phase and may again be followed by [`outputOptions`](#outputoptions) if another output is generated | + +Called when Rollup encounters an error during `bundle.generate()` or `bundle.write()`. The error is passed to this hook. To get notified when generation completes successfully, use the `generateBundle` hook. + +### renderStart + +| | | +| --: | :-- | +| Type: | `(outputOptions: OutputOptions, inputOptions: InputOptions) => void` | +| Kind: | async, parallel | +| Previous: | [`outputOptions`](#outputoptions) | +| Next: | [`renderDynamicImport`](#renderdynamicimport) for each dynamic import expression in the first chunk | + +Called initially each time `bundle.generate()` or `bundle.write()` is called. To get notified when generation has completed, use the `generateBundle` and `renderError` hooks. This is the recommended hook to use when you need access to the output options passed to `bundle.generate()` or `bundle.write()` as it takes the transformations by all [`outputOptions`](#outputoptions) hooks into account and also contains the right default values for unset options. It also receives the input options passed to `rollup.rollup()` so that plugins that can be used as output plugins, i.e. plugins that only use `generate` phase hooks, can get access to them. + +### resolveFileUrl + +| | | +| --: | :-- | +| Type: | `ResolveFileUrlHook` | +| Kind: | sync, first | +| Previous: | [`renderDynamicImport`](#renderdynamicimport) for each dynamic import expression in the current chunk | +| Next: | [`banner`](#banner), [`footer`](#footer), [`intro`](#intro), [`outro`](#outro) in parallel for the current chunk | + +```typescript +type ResolveFileUrlHook = (options: { + chunkId: string; + fileName: string; + format: InternalModuleFormat; + moduleId: string; + referenceId: string; + relativePath: string; +}) => string | NullValue; +``` + +Allows to customize how Rollup resolves URLs of files that were emitted by plugins via `this.emitFile`. By default, Rollup will generate code for `import.meta.ROLLUP_FILE_URL_referenceId` that should correctly generate absolute URLs of emitted files independent of the output format and the host system where the code is deployed. + +For that, all formats except CommonJS and UMD assume that they run in a browser environment where `URL` and `document` are available. In case that fails or to generate more optimized code, this hook can be used to customize this behaviour. To do that, the following information is available: + +- `chunkId`: The id of the chunk this file is referenced from. If the chunk file name would contain a hash, this id will contain a placeholder instead. Rollup will replace this placeholder with the actual file name if it ends up in the generated code. +- `fileName`: The path and file name of the emitted file, relative to `output.dir` without a leading `./`. Again if this is a chunk that would have a hash in its name, it will contain a placeholder instead. +- `format`: The rendered output format. +- `moduleId`: The id of the original module this file is referenced from. Useful for conditionally resolving certain assets differently. +- `referenceId`: The reference id of the file. +- `relativePath`: The path and file name of the emitted file, relative to the chunk the file is referenced from. This will path will contain no leading `./` but may contain a leading `../`. + +The following plugin will always resolve all files relative to the current document: + +```js twoslash +// ---cut-start--- +/** @returns {import('rollup').Plugin} */ +// ---cut-end--- +function resolveToDocumentPlugin() { + return { + name: 'resolve-to-document', + resolveFileUrl({ fileName }) { + return `new URL('${fileName}', document.baseURI).href`; + } + }; +} +``` + +### resolveImportMeta + +| | | +| --: | :-- | +| Type: | `(property: string \| null, {chunkId: string, moduleId: string, format: string}) => string \| null` | +| Kind: | sync, first | +| Previous: | [`renderDynamicImport`](#renderdynamicimport) for each dynamic import expression in the current chunk | +| Next: | [`banner`](#banner), [`footer`](#footer), [`intro`](#intro), [`outro`](#outro) in parallel for the current chunk | + +Allows to customize how Rollup handles `import.meta` and `import.meta.someProperty`, in particular `import.meta.url`. In ES modules, `import.meta` is an object and `import.meta.url` contains the URL of the current module, e.g. `http://server.net/bundle.js` for browsers or `file:///path/to/bundle.js` in Node. + +By default, for formats other than ES modules, Rollup replaces `import.meta.url` with code that attempts to match this behaviour by returning the dynamic URL of the current chunk. Note that all formats except CommonJS and UMD assume that they run in a browser environment where `URL` and `document` are available. For other properties, `import.meta.someProperty` is replaced with `undefined` while `import.meta` is replaced with an object containing a `url` property. + +This behaviour can be changed—also for ES modules—via this hook. For each occurrence of `import.meta<.someProperty>`, this hook is called with the name of the property or `null` if `import.meta` is accessed directly. For example, the following code will resolve `import.meta.url` using the relative path of the original module to the current working directory and again resolve this path against the base URL of the current document at runtime: + +```js twoslash +// ---cut-start--- +/** @returns {import('rollup').Plugin} */ +// ---cut-end--- +function importMetaUrlCurrentModulePlugin() { + return { + name: 'import-meta-url-current-module', + resolveImportMeta(property, { moduleId }) { + if (property === 'url') { + return `new URL('${path.relative( + process.cwd(), + moduleId + )}', document.baseURI).href`; + } + return null; + } + }; +} +``` + +If the `chunkId` would contain a hash, it will contain a placeholder instead. If this placeholder ends up in the generated code, Rollup will replace it with the actual chunk hash. + +### writeBundle + +| | | +| --: | :-- | +| Type: | `(options: OutputOptions, bundle: { [fileName: string]: OutputAsset \| OutputChunk }) => void` | +| Kind: | async, parallel | +| Previous: | [`generateBundle`](#generatebundle) | +| Next: | If it is called, this is the last hook of the output generation phase and may again be followed by [`outputOptions`](#outputoptions) if another output is generated | + +Called only at the end of `bundle.write()` once all files have been written. Similar to the [`generateBundle`](#generatebundle) hook, `bundle` provides the full list of files being written along with their details. + +## Plugin Context + +A number of utility functions and informational bits can be accessed from within most [hooks](#build-hooks) via `this`: + +### this.addWatchFile + +| | | +| ----: | :--------------------- | +| Type: | `(id: string) => void` | + +Adds additional files to be monitored in watch mode so that changes to these files will trigger rebuilds. `id` can be an absolute path to a file or directory or a path relative to the current working directory. This context function can be used in all plugin hooks except `closeBundle`. However, it will not have an effect when used in [output generation hooks](#output-generation-hooks) if [`watch.skipWrite`](../configuration-options/index.md#watch-skipwrite) is set to `true`. + +Note that when emitting assets that correspond to an existing file, it is recommended to set the `originalFileName` property in the [`this.emitFile`](#this-emitfile) call instead as that will not only watch the file but also make the connection transparent to other plugins. + +**Note:** Usually in watch mode to improve rebuild speed, the `transform` hook will only be triggered for a given module if its contents actually changed. Using `this.addWatchFile` from within the `transform` hook will make sure the `transform` hook is also reevaluated for this module if the watched file changes. + +In general, it is recommended to use `this.addWatchFile` from within the hook that depends on the watched file. + +### this.debug + +| | | +| --: | :-- | +| Type: | `(log: string \| RollupLog \| (() => RollupLog \| string), position?: number \| { column: number; line: number }) => void` | + +Generate a `"debug"` log. See [`this.warn`](#this-warn) for details. Debug logs always get `code: "PLUGIN_LOG"` added by Rollup. Make sure to add a distinctive `pluginCode` to those logs for easy filtering. + +These logs are only processed if the [`logLevel`](../configuration-options/index.md#loglevel) option is explicitly set to `"debug"`, otherwise it does nothing. Therefore, it is encouraged to add helpful debug logs to plugins as that can help spot issues while they will be efficiently muted by default. If you need to do expensive computations to generate the log, make sure to use the function form so that these computations are only performed if the log is actually processed. + +```js twoslash +// ---cut-start--- +/** @returns {import('rollup').Plugin} */ +// ---cut-end--- +function plugin() { + return { + name: 'test', + transform(code, id) { + this.debug( + () => + `transforming ${id},\n` + + `module contains, ${code.split('\n').length} lines` + ); + } + }; +} +``` + +### this.emitFile + +| | | +| --: | :-- | +| Type: | `(emittedFile: EmittedChunk \| EmittedPrebuiltChunk \| EmittedAsset) => string` | + +```typescript +interface EmittedChunk { + type: 'chunk'; + id: string; + name?: string; + fileName?: string; + implicitlyLoadedAfterOneOf?: string[]; + importer?: string; + preserveSignature?: 'strict' | 'allow-extension' | 'exports-only' | false; +} + +interface EmittedPrebuiltChunk { + type: 'prebuilt-chunk'; + fileName: string; + code: string; + exports?: string[]; + map?: SourceMap; +} + +interface EmittedAsset { + type: 'asset'; + name?: string; + needsCodeReference?: boolean; + originalFileName?: string; + fileName?: string; + source?: string | Uint8Array; +} +``` + +Emits a new file that is included in the build output and returns a `referenceId` that can be used in various places to reference the emitted file. You can emit chunks, prebuilt chunks or assets. + +When emitting chunks or assets, either a `name` or a `fileName` can be supplied. If a `fileName` is provided, it will be used unmodified as the name of the generated file, throwing an error if this causes a conflict. Otherwise, if a `name` is supplied, this will be used as substitution for `[name]` in the corresponding [`output.chunkFileNames`](../configuration-options/index.md#output-chunkfilenames) or [`output.assetFileNames`](../configuration-options/index.md#output-assetfilenames) pattern, possibly adding a unique number to the end of the file name to avoid conflicts. If neither a `name` nor `fileName` is supplied, a default name will be used. Prebuilt chunks must always have a `fileName`. + +You can reference the URL of an emitted file in any code returned by a [`load`](#load) or [`transform`](#transform) plugin hook via `import.meta.ROLLUP_FILE_URL_referenceId` (returns a string) or `import.meta.ROLLUP_FILE_URL_OBJ_referenceId` (returns a URL object). See [File URLs](#file-urls) for more details and an example. + +The generated code that replaces `import.meta.ROLLUP_FILE_URL_referenceId` can be customized via the [`resolveFileUrl`](#resolvefileurl) plugin hook. You can also use [`this.getFileName(referenceId)`](#this-getfilename) to determine the file name as soon as it is available. If the file name is not set explicitly, then + +- asset file names are available starting with the [`renderStart`](#renderstart) hook. For assets that are emitted later, the file name will be available immediately after emitting the asset. +- chunk file names that do not contain a hash are available as soon as chunks are created after the `renderStart` hook. +- if a chunk file name would contain a hash, using `getFileName` in any hook before [`generateBundle`](#generatebundle) will return a name containing a placeholder instead of the actual name. If you use this file name or parts of it in a chunk you transform in [`renderChunk`](#renderchunk), Rollup will replace the placeholder with the actual hash before `generateBundle`, making sure the hash reflects the actual content of the final generated chunk including all referenced file hashes. + +If the `type` is _`chunk`_, then this emits a new chunk with the given module `id` as entry point. To resolve it, the `id` will be passed through build hooks just like regular entry points, starting with [`resolveId`](#resolveid). If an `importer` is provided, this acts as the second parameter of `resolveId` and is important to properly resolve relative paths. If it is not provided, paths will be resolved relative to the current working directory. If a value for `preserveSignature` is provided, this will override [`preserveEntrySignatures`](../configuration-options/index.md#preserveentrysignatures) for this particular chunk. + +This will not result in duplicate modules in the graph, instead if necessary, existing chunks will be split or a facade chunk with reexports will be created. Chunks with a specified `fileName` will always generate separate chunks while other emitted chunks may be deduplicated with existing chunks even if the `name` does not match. If such a chunk is not deduplicated, the [`output.chunkFileNames`](../configuration-options/index.md#output-chunkfilenames) name pattern will be used. + +By default, Rollup assumes that emitted chunks are executed independent of other entry points, possibly even before any other code is executed. This means that if an emitted chunk shares a dependency with an existing entry point, Rollup will create an additional chunk for dependencies that are shared between those entry points. Providing a non-empty array of module ids for `implicitlyLoadedAfterOneOf` will change that behaviour by giving Rollup additional information to prevent this in some cases. Those ids will be resolved the same way as the `id` property, respecting the `importer` property if it is provided. Rollup will now assume that the emitted chunk is only executed if at least one of the entry points that lead to one of the ids in `implicitlyLoadedAfterOneOf` being loaded has already been executed, creating the same chunks as if the newly emitted chunk was only reachable via dynamic import from the modules in `implicitlyLoadedAfterOneOf`. Here is an example that uses this to create a simple HTML file with several scripts, creating optimized chunks to respect their execution order: + + +```js twoslash +// rollup.config.js +// ---cut-start--- +/** @returns {import('rollup').Plugin} */ +// ---cut-end--- +function generateHtmlPlugin() { +// ---cut-start--- + /** @type {string} */ +// ---cut-end--- + let ref1; +// ---cut-start--- + /** @type {string} */ +// ---cut-end--- + let ref2; +// ---cut-start--- + /** @type {string} */ +// ---cut-end--- + let ref3; + return { + name: 'generate-html', + buildStart() { + ref1 = this.emitFile({ + type: 'chunk', + id: 'src/entry1' + }); + ref2 = this.emitFile({ + type: 'chunk', + id: 'src/entry2', + implicitlyLoadedAfterOneOf: ['src/entry1'] + }); + ref3 = this.emitFile({ + type: 'chunk', + id: 'src/entry3', + implicitlyLoadedAfterOneOf: ['src/entry2'] + }); + }, + generateBundle() { + this.emitFile({ + type: 'asset', + fileName: 'index.html', + source: ` + + + + + Title + + + + + + + ` + }); + } + }; +} + +// ---cut-start--- +/** @returns {import('rollup').RollupOptions} */ +// ---cut-end--- +export default { + input: [], + preserveEntrySignatures: false, + plugins: [generateHtmlPlugin()], + output: { + format: 'es', + dir: 'dist' + } +}; +``` + + +If there are no dynamic imports, this will create exactly three chunks where the first chunk contains all dependencies of `src/entry1`, the second chunk contains only the dependencies of `src/entry2` that are not contained in the first chunk, importing those from the first chunk, and again the same for the third chunk. + +Note that even though any module id can be used in `implicitlyLoadedAfterOneOf`, Rollup will throw an error if such an id cannot be uniquely associated with a chunk, e.g. because the `id` cannot be reached implicitly or explicitly from the existing static entry points, or because the file is completely tree-shaken. Using only entry points, either defined by the user or of previously emitted chunks, will always work, though. + +If the `type` is `prebuilt-chunk`, it emits a chunk with fixed contents provided by the `code` parameter. At the moment, `fileName` is also required to provide the name of the chunk. If it exports some variables, we should list these via the optional `exports`. Via `map` we can provide a sourcemap that corresponds to `code`. + +To reference a prebuilt chunk in imports, we need to mark the "module" as external in the [`resolveId`](#resolveid) hook as prebuilt chunks are not part of the module graph. Instead, they behave like assets with chunk meta-data: + +```js twoslash +// ---cut-start--- +/** @returns {import('rollup').Plugin} */ +// ---cut-end--- +function emitPrebuiltChunkPlugin() { + return { + name: 'emit-prebuilt-chunk', + resolveId(source) { + if (source === './my-prebuilt-chunk.js') { + return { + id: source, + external: true + }; + } + }, + buildStart() { + this.emitFile({ + type: 'prebuilt-chunk', + fileName: 'my-prebuilt-chunk.js', + code: 'export const foo = "foo"', + exports: ['foo'] + }); + } + }; +} +``` + +Then you can reference the prebuilt chunk in your code: + +```js +import { foo } from './my-prebuilt-chunk.js'; +``` + +Currently, emitting a prebuilt chunk is a basic feature. Looking forward to your feedback. + +If the `type` is _`asset`_, then this emits an arbitrary new file with the given `source` as content. It is possible to defer setting the `source` via [`this.setAssetSource(referenceId, source)`](#this-setassetsource) to a later time to be able to reference a file during the build phase while setting the source separately for each output during the generate phase. Assets with a specified `fileName` will always generate separate files while other emitted assets may be deduplicated with existing assets if they have the same source even if the `name` does not match. If an asset without a `fileName` is not deduplicated, the [`output.assetFileNames`](../configuration-options/index.md#output-assetfilenames) name pattern will be used. + +If this asset corresponds to an actual file on disk, then `originalFileName` should be set to the absolute path of the file. In that case, this property will be passed on to subsequent plugin hooks that receive a `PreRenderedAsset` or an `OutputAsset` like [`generateBundle`](#generatebundle). In watch mode, Rollup will also automatically watch this file for changes and trigger a rebuild if it changes. Therefore, it is not necessary to call `this.addWatchFile` for this file. + +If `needsCodeReference` is set to `true` and this asset is not referenced by any code in the output via `import.meta.ROLLUP_FILE_URL_referenceId`, then Rollup will not emit it. This also respects references removed via tree-shaking, i.e. if the corresponding `import.meta.ROLLUP_FILE_URL_referenceId` is part of the source code but is not actually used and the reference is removed by tree-shaking, then the asset is not emitted. + +### this.error + +| | | +| --: | :-- | +| Type: | `(error: string \| RollupLog \| Error, position?: number \| { column: number; line: number }) => never` | + +Structurally equivalent to [`this.warn`](#this-warn), except that it will also abort the bundling process with an error. See the [`onLog`](../configuration-options/index.md#onlog) option for information about the `RollupLog` type. + +If an Error instance is passed, it will be used as-is, otherwise a new Error instance will be created with the given error message and all additional provided properties. + +In all hooks except the [`onLog`](#onlog) hook, the error will be augmented with `code: "PLUGIN_ERROR"` and `plugin: plugin.name`properties. If a`code`property already exists and the code does not start with`PLUGIN_`, it will be renamed to `pluginCode`. + +In the [`onLog`](#onlog) hook, this function is an easy way to turn warnings into errors while keeping all additional properties of the warning: + +```js twoslash +// ---cut-start--- +/** @returns {import('rollup').Plugin} */ +// ---cut-end--- +function myPlugin() { + return { + name: 'my-plugin', + onLog(level, log) { + if (level === 'warn' && log.code === 'THIS_IS_NOT_OK') { + return this.error(log); + } + } + }; +} +``` + +When used in the `transform` hook, the `id` of the current module will also be added and a `position` can be supplied. This is a character index or file location which will be used to augment the log with `pos`, `loc` (a standard `{ file, line, column }` object) and `frame` (a snippet of code showing the location). + +### this.fs + +| | | +| ----: | :--------------- | +| Type: | `RollupFsModule` | + +Provides abstract access to the file system. For the `RollupFsModule` type, see the documentation of the [`fs` option](../configuration-options/index.md#fs). If plugins use this instead of directly importing `node:fs`, then they can be used in browser builds that provide an in-memory file system via the `fs` option. + +### this.getCombinedSourcemap + +| | | +| ----: | :---------------- | +| Type: | `() => SourceMap` | + +Get the combined source maps of all previous plugins. This context function can only be used in the [`transform`](#transform) plugin hook. + +### this.getFileName + +| | | +| ----: | :-------------------------------- | +| Type: | `(referenceId: string) => string` | + +Get the file name of a chunk or asset that has been emitted via [`this.emitFile`](#this-emitfile). The file name will be relative to `outputOptions.dir`. + +### this.getModuleIds + +| | | +| ----: | :------------------------------- | +| Type: | `() => IterableIterator` | + +Returns an `Iterator` that gives access to all module ids in the current graph. It can be iterated via + +```js +for (const moduleId of this.getModuleIds()) { + /* ... */ +} +``` + +or converted into an Array via `Array.from(this.getModuleIds())`. + +### this.getModuleInfo + +| | | +| ----: | :------------------------------------------- | +| Type: | `(moduleId: string) => (ModuleInfo \| null)` | + +```typescript +interface ModuleInfo { + id: string; // the id of the module, for convenience + code: string | null; // the source code of the module, `null` if external or not yet available + ast: ESTree.Program; // the parsed abstract syntax tree if available + hasDefaultExport: boolean | null; // is there a default export, `null` if external or not yet available + isEntry: boolean; // is this a user- or plugin-defined entry point + isExternal: boolean; // for external modules that are referenced but not included in the graph + isIncluded: boolean | null; // is the module included after tree-shaking, `null` if external or not yet available + importedIds: string[]; // the module ids statically imported by this module + importedIdResolutions: ResolvedId[]; // how statically imported ids were resolved, for use with this.load + importers: string[]; // the ids of all modules that statically import this module + exportedBindings: Record | null; // contains all exported variables associated with the path of `from`, `null` if external + exports: string[] | null; // all exported variables, `null` if external + dynamicallyImportedIds: string[]; // the module ids imported by this module via dynamic import() + dynamicallyImportedIdResolutions: ResolvedId[]; // how ids imported via dynamic import() were resolved + dynamicImporters: string[]; // the ids of all modules that import this module via dynamic import() + implicitlyLoadedAfterOneOf: string[]; // implicit relationships, declared via this.emitFile + implicitlyLoadedBefore: string[]; // implicit relationships, declared via this.emitFile + attributes: { [key: string]: string }; // import attributes for this module + meta: { [plugin: string]: any }; // custom module meta-data + moduleSideEffects: boolean | 'no-treeshake'; // are imports of this module included if nothing is imported from it + syntheticNamedExports: boolean | string; // final value of synthetic named exports +} + +interface ResolvedId { + id: string; // the id of the imported module + external: boolean | 'absolute'; // is this module external, "absolute" means it will not be rendered as relative in the module + attributes: { [key: string]: string }; // import attributes for this import + meta: { [plugin: string]: any }; // custom module meta-data when resolving the module + moduleSideEffects: boolean | 'no-treeshake'; // are side effects of the module observed, is tree-shaking enabled + resolvedBy: string; // which plugin resolved this module, "rollup" if resolved by Rollup itself + syntheticNamedExports: boolean | string; // does the module allow importing non-existing named exports +} +``` + +Returns additional information about the module in question. + +During the build, this object represents currently available information about the module which may be inaccurate before the [`buildEnd`](#buildend) hook: + +- `id` and `isExternal` will never change. +- `code`, `ast`, `hasDefaultExport`, `exports` and `exportedBindings` are only available after parsing, i.e. in the [`moduleParsed`](#moduleparsed) hook or after awaiting [`this.load`](#this-load). At that point, they will no longer change. +- if `isEntry` is `true`, it will no longer change. It is however possible for modules to become entry points after they are parsed, either via [`this.emitFile`](#this-emitfile) or because a plugin inspects a potential entry point via [`this.load`](#this-load) in the [`resolveId`](#resolveid) hook when resolving an entry point. Therefore, it is not recommended relying on this flag in the [`transform`](#transform) hook. It will no longer change after `buildEnd`. +- Similarly, `implicitlyLoadedAfterOneOf` can receive additional entries at any time before `buildEnd` via [`this.emitFile`](#this-emitfile). +- `importers`, `dynamicImporters` and `implicitlyLoadedBefore` will start as empty arrays, which receive additional entries as new importers and implicit dependents are discovered. They will no longer change after `buildEnd`. +- `isIncluded` is only available after `buildEnd`, at which point it will no longer change. +- `importedIds`, `importedIdResolutions`, `dynamicallyImportedIds` and `dynamicallyImportedIdResolutions` are available when a module has been parsed and its dependencies have been resolved. This is the case in the `moduleParsed` hook or after awaiting [`this.load`](#this-load) with the `resolveDependencies` flag. At that point, they will no longer change. +- `attributes`, `meta`, `moduleSideEffects` and `syntheticNamedExports` can be changed by [`load`](#load) and [`transform`](#transform) hooks. Moreover, while most properties are read-only, these properties are writable and changes will be picked up if they occur before the `buildEnd` hook is triggered. `meta` itself should not be overwritten, but it is ok to mutate its properties at any time to store meta information about a module. The advantage of doing this instead of keeping state in a plugin is that `meta` is persisted to and restored from the cache if it is used, e.g. when using watch mode from the CLI. + +Returns `null` if the module id cannot be found. + +### this.getWatchFiles + +| | | +| ----: | :--------------- | +| Type: | `() => string[]` | + +Get ids of the files which has been watched previously. Include both files added by plugins with `this.addWatchFile` and files added implicitly by Rollup during the build. + +### this.info + +| | | +| --: | :-- | +| Type: | `(log: string \| RollupLog \| (() => RollupLog \| string), position?: number \| { column: number; line: number }) => void` | + +Generate an `"info"` log. See [`this.warn`](#this-warn) for details. Info logs always get `code: "PLUGIN_LOG"` added by Rollup. As these logs are displayed by default, use them for information that is not a warning but makes sense to display to all users on every build. + +If the [`logLevel`](../configuration-options/index.md#loglevel) option is set to `"warn"` or `"silent"`, this method will do nothing. + +### this.load + +| | | +| ----: | :----- | +| Type: | `Load` | + +```typescript +type Load = (options: { + id: string; + resolveDependencies?: boolean; + attributes?: Record | null; + meta?: CustomPluginOptions | null; + moduleSideEffects?: boolean | 'no-treeshake' | null; + syntheticNamedExports?: boolean | string | null; +}) => Promise; +``` + +Loads and parses the module corresponding to the given id, attaching additional meta information to the module if provided. This will trigger the same [`load`](#load), [`transform`](#transform) and [`moduleParsed`](#moduleparsed) hooks that would be triggered if the module were imported by another module. + +This allows you to inspect the final content of modules before deciding how to resolve them in the [`resolveId`](#resolveid) hook and e.g. resolve to a proxy module instead. If the module becomes part of the graph later, there is no additional overhead from using this context function as the module will not be parsed again. The signature allows you to directly pass the return value of [`this.resolve`](#this-resolve) to this function as long as it is neither `null` nor external. + +The returned Promise will resolve once the module has been fully transformed and parsed but before any imports have been resolved. That means that the resulting `ModuleInfo` will have empty `importedIds`, `dynamicallyImportedIds`, `importedIdResolutions` and `dynamicallyImportedIdResolutions`. This helps to avoid deadlock situations when awaiting `this.load` in a `resolveId` hook. If you are interested in `importedIds` and `dynamicallyImportedIds`, you can either implement a `moduleParsed` hook or pass the `resolveDependencies` flag, which will make the Promise returned by `this.load` wait until all dependency ids have been resolved. + +Note that with regard to the `attributes`, `meta`, `moduleSideEffects` and `syntheticNamedExports` options, the same restrictions apply as for the `resolveId` hook: Their values only have an effect if the module has not been loaded yet. Thus, it is very important to use `this.resolve` first to find out if any plugins want to set special values for these options in their `resolveId` hook, and pass these options on to `this.load` if appropriate. The example below showcases how this can be handled to add a proxy module for modules containing a special code comment. Note the special handling for re-exporting the default export: + +```js twoslash +// ---cut-start--- +/** @returns {import('rollup').Plugin} */ +// ---cut-end--- +export default function addProxyPlugin() { + return { + async resolveId(source, importer, options) { + if (importer?.endsWith('?proxy')) { + // Do not proxy ids used in proxies + return null; + } + // We make sure to pass on any resolveId options to + // this.resolve to get the module id + const resolution = await this.resolve(source, importer, options); + // We can only pre-load existing and non-external ids + if (resolution && !resolution.external) { + // we pass on the entire resolution information + const moduleInfo = await this.load(resolution); + if (moduleInfo.code.includes('/* use proxy */')) { + return `${resolution.id}?proxy`; + } + } + // As we already fully resolved the module, there is no reason + // to resolve it again + return resolution; + }, + load(id) { + if (id.endsWith('?proxy')) { + const importee = id.slice(0, -'?proxy'.length); + // Note that namespace reexports do not reexport default + // exports + let code = `console.log('proxy for ${importee}'); export * from ${JSON.stringify( + importee + )};`; + // We know that while resolving the proxy, importee was + // already fully loaded and parsed, so we can rely on + // hasDefaultExport + if (this.getModuleInfo(importee).hasDefaultExport) { + code += `export { default } from ${JSON.stringify(importee)};`; + } + return code; + } + return null; + } + }; +} +``` + +If the module was already loaded, `this.load` will just wait for the parsing to complete and then return its module information. If the module was not yet imported by another module, it will not automatically trigger loading other modules imported by this module. Instead, static and dynamic dependencies will only be loaded once this module has actually been imported at least once. + +While it is safe to use `this.load` in a `resolveId` hook, you should be very careful when awaiting it in a `load` or `transform` hook. If there are cyclic dependencies in the module graph, this can easily lead to a deadlock, so any plugin needs to manually take care to avoid waiting for `this.load` inside the `load` or `transform` of the any module that is in a cycle with the loaded module. + +Here is another, more elaborate example where we scan entire dependency sub-graphs via the `resolveDependencies` option and repeated calls to `this.load`. We use a `Set` of handled module ids to handle cyclic dependencies. The goal of the plugin is to add a log to each dynamically imported chunk that just lists all modules in the chunk. While this is just a toy example, the technique could be used to e.g. create a single style tag for all CSS imported in the sub-graph. + +```js twoslash +// The leading \0 instructs other plugins not to try to resolve, load or +// transform our proxy modules +const DYNAMIC_IMPORT_PROXY_PREFIX = '\0dynamic-import:'; + +// ---cut-start--- +/** @returns {import('rollup').Plugin} */ +// ---cut-end--- +export default function dynamicChunkLogsPlugin() { + return { + name: 'dynamic-chunk-logs', + async resolveDynamicImport(specifier, importer) { + // Ignore non-static targets + if (!(typeof specifier === 'string')) return; + // Get the id and initial meta information of the import target + const resolved = await this.resolve(specifier, importer); + // Ignore external targets. Explicit externals have the + // "external" property while unresolved imports are "null". + if (resolved && !resolved.external) { + // We trigger loading the module without waiting for it + // here because meta information attached by resolveId + // hooks, that may be contained in "resolved" and that + // plugins like "commonjs" may depend upon, is only + // attached to a module the first time it is loaded. This + // ensures that this meta information is not lost when we + // later use "this.load" again in the load hook with just + // the module id. + this.load(resolved); + return `${DYNAMIC_IMPORT_PROXY_PREFIX}${resolved.id}`; + } + }, + async load(id) { + // Ignore all files except our dynamic import proxies + if (!id.startsWith('\0dynamic-import:')) return null; + const actualId = id.slice(DYNAMIC_IMPORT_PROXY_PREFIX.length); + // To allow loading modules in parallel while keeping + // complexity low, we do not directly await each "this.load" + // call but put their promises into an array where we await + // them via an async for loop. + const moduleInfoPromises = [ + this.load({ id: actualId, resolveDependencies: true }) + ]; + // We track each loaded dependency here so that we do not load + // a file twice and also do not get stuck when there are + // circular dependencies. + const dependencies = new Set([actualId]); + // "importedIdResolutions" tracks the objects created by + // resolveId hooks. We are using those instead of "importedIds" + // so that again, important meta information is not lost. + for await (const { importedIdResolutions } of moduleInfoPromises) { + for (const resolved of importedIdResolutions) { + if (!dependencies.has(resolved.id)) { + dependencies.add(resolved.id); + moduleInfoPromises.push( + this.load({ ...resolved, resolveDependencies: true }) + ); + } + } + } + // We log all modules in a dynamic chunk when it is loaded. + let code = `console.log([${[...dependencies] + .map(JSON.stringify) + .join(', ')}]); export * from ${JSON.stringify(actualId)};`; + // Namespace reexports do not reexport default exports, which + // is why we reexport it manually if it exists + if (this.getModuleInfo(actualId).hasDefaultExport) { + code += `export { default } from ${JSON.stringify(actualId)};`; + } + return code; + } + }; +} +``` + +### this.meta + +| | | +| ----: | :-------------------------------------------- | +| Type: | `{rollupVersion: string, watchMode: boolean}` | + +An object containing potentially useful Rollup metadata: + +- `rollupVersion`: The currently running version of Rollup as define in `package.json`. +- `watchMode`: `true` if Rollup was started via `rollup.watch(...)` or from the command line with `--watch`, `false` otherwise. + +`meta` is the only context property accessible from the [`options`](#options) hook. + +### this.parse + +| | | +| ----: | :--------------------------------------------------------- | +| Type: | `(code: string, options?: ParseOptions) => ESTree.Program` | + +```typescript +interface ParseOptions { + allowReturnOutsideFunction?: boolean; +} +``` + +Use Rollup's internal SWC-based parser to parse code to an [ESTree-compatible](https://github.com/estree/estree) AST. + +- `allowReturnOutsideFunction`: When `true` this allows return statements to be outside functions to e.g. support parsing CommonJS code. + +### this.resolve + +| | | +| ----: | :-------- | +| Type: | `Resolve` | + +```typescript +type Resolve = ( + source: string, + importer?: string, + options?: { + skipSelf?: boolean; + isEntry?: boolean; + attributes?: { [key: string]: string }; + custom?: { [plugin: string]: any }; + } +) => Promise; +``` + +::: tip + +The return type **ResolvedId** of this hook is defined in [`this.getModuleInfo`](#this-getmoduleinfo). + +::: + +Resolve imports to module ids (i.e. file names) using the same plugins that Rollup uses, and determine if an import should be external. If `Promise` is returned, the import could not be resolved by Rollup or any plugin but was not explicitly marked as external by the user. If an absolute external id is returned that should remain absolute in the output either via the [`makeAbsoluteExternalsRelative`](../configuration-options/index.md#makeabsoluteexternalsrelative) option or by explicit plugin choice in the [`resolveId`](#resolveid) hook, `external` will be `"absolute"` instead of `true`. + +The default of `skipSelf` is `true`, So the `resolveId` hook of the plugin from which `this.resolve` is called will be skipped when resolving. When other plugins themselves also call `this.resolve` in their `resolveId` hooks with the _exact same `source` and `importer`_ while handling the original `this.resolve` call, then the `resolveId` hook of the original plugin will be skipped for those calls as well. The rationale here is that the plugin already stated that it "does not know" how to resolve this particular combination of `source` and `importer` at this point in time. If you do not want this behaviour, set `skipSelf` to `false` and implement your own infinite loop prevention mechanism if necessary. + +You can also pass an object of plugin-specific options via the `custom` option, see [custom resolver options](#custom-resolver-options) for details. + +The value for `isEntry` you pass here will be passed along to the [`resolveId`](#resolveid) hooks handling this call, otherwise `false` will be passed if there is an importer and `true` if there is not. + +If you pass an object for `attributes`, it will simulate resolving an import with an assertion, e.g. `attributes: {type: "json"}` simulates resolving `import "foo" assert {type: "json"}`. This will be passed to any [`resolveId`](#resolveid) hooks handling this call and may ultimately become part of the returned object. + +When calling this function from a `resolveId` hook, you should always check if it makes sense for you to pass along the `isEntry`, `custom` and `attributes` options. + +The value of `resolvedBy` refers to which plugin resolved this source. If it was resolved by Rollup itself, the value will be "rollup". If a `resolveId` hook in a plugin resolves this source, the value will be the name of the plugin unless it returned an explicit value for `resolvedBy`. This flag is only for debugging and documentation purposes and is not processed further by Rollup. + +### this.setAssetSource + +| | | +| ----: | :------------------------------------------------------------ | +| Type: | `(referenceId: string, source: string \| Uint8Array) => void` | + +Set the deferred source of an asset. Note that you can also pass a Node `Buffer` as `source` as it is a sub-class of `Uint8Array`. + +### this.warn + +| | | +| --: | :-- | +| Type: | `(log: string \| RollupLog \| (() => RollupLog \| string), position?: number \| { column: number; line: number }) => void` | + +Using this method will generate warnings for a build, which are logs with log level `"warn"`. See the [`onLog`](../configuration-options/index.md#onlog) option for information about the `RollupLog` type. To generate other logs, see also [`this.info`](#this-info) and [`this.debug`](#this-debug). To generate errors, see [`this.error`](#this-error). + +Just like internally generated warnings, these logs will be first passed to and filtered by plugin [`onLog`](#onlog) hooks before they are forwarded to custom [`onLog`](../configuration-options/index.md#onlog) or [`onwarn`](../configuration-options/index.md#onwarn) handlers or printed to the console. + +The `warning` argument can be a `string` or an object with (at minimum) a `message` property: + +```js +this.warn('hmm...'); +// is equivalent to +this.warn({ + message: 'hmm...', + pluginCode: 'CODE_TO_IDENTIFY_LOG', + meta: 'Additional plugin specific information' +}); +``` + +We encourage you to use objects with a `pluginCode` property as that will allow users to easily filter for those logs in an `onLog` handler. If you need to add additional information, you can use the `meta` property. If the log contains a `code` and does not yet have a `pluginCode` property, it will be renamed to `pluginCode` as plugin warnings always get a `code` of `PLUGIN_WARNING` added by Rollup. To prevent this behavior, plugins can instead use the normalized `onLog` option passed to the [`buildStart`](#buildstart) hook. Calling this option from a plugin will not change properties when passing the log to plugin `onLog` handlers and `onLog` or `onwarn` handlers. + +If you need to do expensive computations to generate a log, you can also pass a function returning either a `string` or a `RollupLog` object. This function will only be called if the log is not filtered by the [`logLevel`](../configuration-options/index.md#loglevel) option. + +```js +// This will only run if the logLevel is set to "debug" +this.debug(() => generateExpensiveDebugLog()); +``` + +When used in the `transform` hook, the `id` of the current module will also be added and a `position` can be supplied. This is a character index or file location which will be used to augment the log with `pos`, `loc` (a standard `{ file, line, column }` object) and `frame` (a snippet of code showing the location). + +If the [`logLevel`](../configuration-options/index.md#loglevel) option is set to `"silent"`, this method will do nothing. + +## File URLs + +To reference a file URL reference from within JS code, use the `import.meta.ROLLUP_FILE_URL_referenceId` replacement. This will generate code that depends on the output format and generates a URL that points to the emitted file in the target environment. Note that all formats except CommonJS and UMD assume that they run in a browser environment where `URL` and `document` are available. + +The following example will detect imports of `.svg` files, emit the imported files as assets, and return their URLs to be used e.g. as the `src` attribute of an `img` tag: + +```js twoslash +// ---cut-start--- +/** @returns {import('rollup').Plugin} */ +// ---cut-end--- +function svgResolverPlugin() { + return { + name: 'svg-resolver', + resolveId(source, importer) { + if (source.endsWith('.svg')) { + return path.resolve(path.dirname(importer), source); + } + }, + load(id) { + if (id.endsWith('.svg')) { + const referenceId = this.emitFile({ + type: 'asset', + name: path.basename(id), + source: fs.readFileSync(id) + }); + return `export default import.meta.ROLLUP_FILE_URL_${referenceId};`; + } + } + }; +} +``` + +Usage: + +```js +import logo from '../images/logo.svg'; +const image = document.createElement('img'); +image.src = logo; +document.body.appendChild(image); +``` + +Sometimes, the code which referenced this asset is only used conditionally like in the following example: + +```js +import logo from '../images/logo.svg'; +if (COMPILER_FLAG) { + const image = document.createElement('img'); + image.src = logo; + document.body.appendChild(image); +} +``` + +If a plugin replaces `COMPILER_FLAG` with `false`, then we will get an unexpected result: The unreferenced asset is still emitted but unused. We can resolve this problem by setting `needsCodeReference` to true when calling [`this.emitFile`](#this-emitfile), like in the following code: + +```js twoslash +// ---cut-start--- +/** @returns {import('rollup').Plugin} */ +// ---cut-end--- +function svgResolverPlugin() { + return { + /* ... */ + load(id) { + if (id.endsWith('.svg')) { + const referenceId = this.emitFile({ + type: 'asset', + name: path.basename(id), + needsCodeReference: true, + source: fs.readFileSync(id) + }); + return `export default import.meta.ROLLUP_FILE_URL_${referenceId};`; + } + } + }; +} +``` + +Now the asset will only be added to the bundle if the reference `import.meta.ROLLUP_FILE_URL_referenceId` is actually used in the code. + +Similar to assets, emitted chunks can be referenced from within JS code via `import.meta.ROLLUP_FILE_URL_referenceId` as well. + +The following example will detect imports prefixed with `register-paint-worklet:` and generate the necessary code and separate chunk to generate a CSS paint worklet. Note that this will only work in modern browsers and will only work if the output format is set to `es`. + +```js twoslash +const REGISTER_WORKLET = 'register-paint-worklet:'; + +// ---cut-start--- +/** @returns {import('rollup').Plugin} */ +// ---cut-end--- +function registerPaintWorkletPlugin() { + return { + name: 'register-paint-worklet', + load(id) { + if (id.startsWith(REGISTER_WORKLET)) { + return `CSS.paintWorklet.addModule(import.meta.ROLLUP_FILE_URL_${this.emitFile( + { + type: 'chunk', + id: id.slice(REGISTER_WORKLET.length) + } + )});`; + } + }, + resolveId(source, importer) { + // We remove the prefix, resolve everything to absolute ids and + // add the prefix again. This makes sure that you can use + // relative imports to define worklets + if (source.startsWith(REGISTER_WORKLET)) { + return this.resolve( + source.slice(REGISTER_WORKLET.length), + importer + ).then(resolvedId => REGISTER_WORKLET + resolvedId.id); + } + return null; + } + }; +} +``` + +Usage: + +```js +// main.js +import 'register-paint-worklet:./worklet.js'; +import { color, size } from './config.js'; +document.body.innerHTML += `

color: ${color}, size: ${size}

`; + +// worklet.js +import { color, size } from './config.js'; +registerPaint( + 'vertical-lines', + class { + paint(ctx, geom) { + for (let x = 0; x < geom.width / size; x++) { + ctx.beginPath(); + ctx.fillStyle = color; + ctx.rect(x * size, 0, 2, geom.height); + ctx.fill(); + } + } + } +); + +// config.js +export const color = 'greenyellow'; +export const size = 6; +``` + +If you build this code, both the main chunk and the worklet will share the code from `config.js` via a shared chunk. This enables us to make use of the browser cache to reduce transmitted data and speed up loading the worklet. + +You can also use `import.meta.ROLLUP_FILE_URL_OBJ_referenceId` to get a URL object directly instead of a string. This is more efficient when you need the URL object itself, as it avoids creating the object twice: + +```js +// Using ROLLUP_FILE_URL (returns string, requires wrapping in new URL()) +const urlString = import.meta.ROLLUP_FILE_URL_referenceId; +const urlObject = new URL(urlString); + +// Using ROLLUP_FILE_URL_OBJ (returns URL object directly) +const urlObject = import.meta.ROLLUP_FILE_URL_OBJ_referenceId; +``` + +## Transformers + +Transformer plugins (i.e. those that return a `transform` function for e.g. transpiling non-JS files) should support `options.include` and `options.exclude`, both of which can be a minimatch pattern or an array of minimatch patterns. If `options.include` is omitted or of zero length, files should be included by default; otherwise they should only be included if the ID matches one of the patterns. + +The `transform` hook, if returning an object, can also include an `ast` property. Only use this feature if you know what you're doing. Note that only the last AST in a chain of transforms will be used (and if there are transforms, any ASTs generated by the `load` hook will be discarded for the transformed modules.) + +### Example Transformer + +(Use [@rollup/pluginutils](https://github.com/rollup/plugins/tree/master/packages/pluginutils) for commonly needed functions, and to implement a transformer in the recommended manner.) + +```js twoslash +import { createFilter } from '@rollup/pluginutils'; + +// ---cut-start--- +/** @returns {import('rollup').Plugin} */ +// ---cut-end--- +function transformCodePlugin(options = {}) { + const filter = createFilter(options.include, options.exclude); + + return { + name: 'transform-code', + transform(code, id) { + if (!filter(id)) return; + + // proceed with the transformation... + return { + code: generatedCode, + map: generatedSourceMap + }; + } + }; +} +``` + +### Source Code Transformations + +If a plugin transforms source code, it should generate a sourcemap automatically, unless there's a specific `sourceMap: false` option. Rollup only cares about the `mappings` property (everything else is handled automatically). [magic-string](https://github.com/Rich-Harris/magic-string) provides a simple way to generate such a map for elementary transformations like adding or removing code snippets. + +If it doesn't make sense to generate a sourcemap, (e.g. [rollup-plugin-string](https://github.com/TrySound/rollup-plugin-string)), return an empty sourcemap: + +```js +return { + code: transformedCode, + map: { mappings: '' } +}; +``` + +If the transformation does not move code, you can preserve existing sourcemaps by returning `null`: + +```js +return { + code: transformedCode, + map: null +}; +``` + +If you create a plugin that you think would be useful to others, please publish it to NPM and add submit it to [github.com/rollup/awesome](https://github.com/rollup/awesome)! + +## Synthetic named exports + +It is possible to designate a fallback export for missing exports by setting the `syntheticNamedExports` option for a module in the [`resolveId`](#resolveid), [`load`](#load) or [`transform`](#transform) hook. If a string value is used for `syntheticNamedExports`, this module will fallback the resolution of any missing named exports to properties of the named export of the given name: + +**dep.js: (`{syntheticNamedExports: '__synthetic'}`)** + +```js +export const foo = 'explicit'; +export const __synthetic = { + foo: 'foo', + bar: 'bar' +}; +``` + +**main.js:** + +```js +import { foo, bar, baz, __synthetic } from './dep.js'; + +// logs "explicit" as non-synthetic exports take precedence +console.log(foo); + +// logs "bar", picking the property from __synthetic +console.log(bar); + +// logs "undefined" +console.log(baz); + +// logs "{foo:'foo',bar:'bar'}" +console.log(__synthetic); +``` + +When used as an entry point, only explicit exports will be exposed. The synthetic fallback export, i.e. `__synthetic` in the example, will not be exposed for string values of `syntheticNamedExports`. However, if the value is `true`, the default export will be exposed. This is the only notable difference between `syntheticNamedExports: true` and `syntheticNamedExports: 'default'`. + +## Inter-plugin communication + +At some point when using many dedicated plugins, there may be the need for unrelated plugins to be able to exchange information during the build. There are several mechanisms through which Rollup makes this possible. + +### Custom resolver options + +Assume you have a plugin that should resolve an import to different ids depending on how the import was generated by another plugin. One way to achieve this would be to rewrite the import to use special proxy ids, e.g. a transpiled import via `require("foo")` in a CommonJS file could become a regular import with a special id `import "foo?require=true"` so that a resolver plugin knows this. + +The problem here, however, is that this proxy id may or may not cause unintended side effects when passed to other resolvers because it does not really correspond to a file. Moreover, if the id is created by plugin `A` and the resolution happens in plugin `B`, it creates a dependency between these plugins so that `A` is not usable without `B`. + +Custom resolver option offer a solution here by allowing to pass additional options for plugins when manually resolving a module via `this resolve`. This happens without changing the id and thus without impairing the ability for other plugins to resolve the module correctly if the intended target plugin is not present. + +```js twoslash +// ---cut-start--- +/** @returns {import('rollup').Plugin} */ +// ---cut-end--- +function requestingPlugin() { + return { + name: 'requesting', + async buildStart() { + const resolution = await this.resolve('foo', undefined, { + custom: { resolving: { specialResolution: true } } + }); + console.log(resolution.id); // "special" + } + }; +} + +// ---cut-start--- +/** @returns {import('rollup').Plugin} */ +// ---cut-end--- +function resolvingPlugin() { + return { + name: 'resolving', + resolveId(id, importer, { custom }) { + if (custom.resolving?.specialResolution) { + return 'special'; + } + return null; + } + }; +} +``` + +Note the convention that custom options should be added using a property corresponding to the plugin name of the resolving plugin. It is responsibility of the resolving plugin to specify which options it respects. + +### Custom module meta-data + +Plugins can annotate modules with custom meta-data which can be set by themselves and other plugins via the [`resolveId`](#resolveid), [`load`](#load), and [`transform`](#transform) hooks and accessed via [`this.getModuleInfo`](#this-getmoduleinfo), [`this.load`](#this-load) and the [`moduleParsed`](#moduleparsed) hook. This meta-data should always be JSON.stringifyable and will be persisted in the cache e.g. in watch mode. + +```js twoslash +// ---cut-start--- +/** @returns {import('rollup').Plugin} */ +// ---cut-end--- +function annotatingPlugin() { + return { + name: 'annotating', + transform(code, id) { + if (thisModuleIsSpecial(code, id)) { + return { meta: { annotating: { special: true } } }; + } + } + }; +} + +// ---cut-start--- +/** @returns {import('rollup').Plugin} */ +// ---cut-end--- +function readingPlugin() { + let parentApi; + return { + name: 'reading', + buildEnd() { + const specialModules = Array.from(this.getModuleIds()).filter( + id => this.getModuleInfo(id).meta.annotating?.special + ); + // do something with this list + } + }; +} +``` + +Note the convention that plugins that add or modify data should use a property corresponding to the plugin name, in this case `annotating`. On the other hand, any plugin can read all meta-data from other plugins via `this.getModuleInfo`. + +If several plugins add meta-data or meta-data is added in different hooks, then these `meta` objects will be merged shallowly. That means if plugin `first` adds `{meta: {first: {resolved: "first"}}}` in the resolveId hook and `{meta: {first: {loaded: "first"}}}` in the load hook while plugin `second` adds `{meta: {second: {transformed: "second"}}}` in the `transform` hook, then the resulting `meta` object will be `{first: {loaded: "first"}, second: {transformed: "second"}}`. Here the result of the `resolveId` hook will be overwritten by the result of the `load` hook as the plugin was both storing them under its `first` top-level property. The `transform` data of the other plugin on the other hand will be placed next to it. + +The `meta` object of a module is created as soon as Rollup starts loading a module and is updated for each lifecycle hook of the module. If you store a reference to this object, you can also update it manually. To access the meta object of a module that has not been loaded yet, you can trigger its creation and loading the module via [`this.load`](#this-load): + +```js twoslash +// ---cut-start--- +/** @returns {import('rollup').Plugin} */ +// ---cut-end--- +function plugin() { + return { + name: 'test', + buildStart() { + // trigger loading a module. We could also pass an initial + // "meta" object here, but it would be ignored if the module + // was already loaded via other means + this.load({ id: 'my-id' }); + // the module info is now available, we do not need to await + // this.load + const meta = this.getModuleInfo('my-id').meta; + // we can also modify meta manually now + meta.test = { some: 'data' }; + } + }; +} +``` + +### Direct plugin communication + +For any other kind of inter-plugin communication, we recommend the pattern below. Note that `api` will never conflict with any upcoming plugin hooks. + + +```js twoslash +/** @typedef {{ doSomething(...args: any[]): void }} ParentPluginApi */ + +/** @returns {import('rollup').Plugin} */ +// ---cut--- +function parentPlugin() { + return { + name: 'parent', + api: { + //...methods and properties exposed for other plugins + doSomething(...args) { + // do something interesting + } + } + // ...plugin hooks + }; +} + +// ---cut-start--- +/** @returns {import('rollup').Plugin} */ +// ---cut-end--- +function dependentPlugin() { +// ---cut-start--- + /** @type {ParentPluginApi} */ +// ---cut-end--- + let parentApi; + return { + name: 'dependent', + buildStart({ plugins }) { + const parentName = 'parent'; +// ---cut-start--- + /** @type {import('rollup').Plugin | undefined} */ +// ---cut-end--- + const parentPlugin = plugins.find( + plugin => plugin.name === parentName + ); + if (!parentPlugin) { + // or handle this silently if it is optional + throw new Error( + `This plugin depends on the "${parentName}" plugin.` + ); + } + // now you can access the API methods in subsequent hooks + parentApi = parentPlugin.api; + }, + transform(code, id) { + if (thereIsAReasonToDoSomething(id)) { + parentApi.doSomething(id); + } + } + }; +} +``` + diff --git a/docs/public/favicon.png b/docs/public/favicon.png new file mode 100644 index 00000000000..04ce94ed3cf Binary files /dev/null and b/docs/public/favicon.png differ diff --git a/docs/public/manifest.json b/docs/public/manifest.json new file mode 100644 index 00000000000..fcb7b7c8443 --- /dev/null +++ b/docs/public/manifest.json @@ -0,0 +1,25 @@ +{ + "name": "Rollup", + "short_name": "Rollup", + "display": "fullscreen", + "background_color": "#ff3333", + "theme_color": "#ff3333", + "scope": "/", + "icons": [ + { + "src": "/favicon.png", + "type": "image/png", + "sizes": "128x128" + } + ], + "shortcuts" : [ + { + "name": "Guide", + "url": "/introduction/" + }, + { + "name": "REPL", + "url": "/repl/" + } + ] +} diff --git a/docs/public/rollup-logo.svg b/docs/public/rollup-logo.svg new file mode 100644 index 00000000000..935338a7f31 --- /dev/null +++ b/docs/public/rollup-logo.svg @@ -0,0 +1,3 @@ + + + diff --git a/docs/public/twitter-card.jpg b/docs/public/twitter-card.jpg new file mode 100644 index 00000000000..2c918c7b4e4 Binary files /dev/null and b/docs/public/twitter-card.jpg differ diff --git a/docs/public/vitejs-logo.svg b/docs/public/vitejs-logo.svg new file mode 100644 index 00000000000..945478bead1 --- /dev/null +++ b/docs/public/vitejs-logo.svg @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/docs/repl/components/BundleOptions.vue b/docs/repl/components/BundleOptions.vue new file mode 100644 index 00000000000..a083e3b201a --- /dev/null +++ b/docs/repl/components/BundleOptions.vue @@ -0,0 +1,212 @@ + + + + + diff --git a/docs/repl/components/InputHeader.vue b/docs/repl/components/InputHeader.vue new file mode 100644 index 00000000000..a7414813587 --- /dev/null +++ b/docs/repl/components/InputHeader.vue @@ -0,0 +1,94 @@ + + + + + diff --git a/docs/repl/components/OutputStatus.vue b/docs/repl/components/OutputStatus.vue new file mode 100644 index 00000000000..a85831fd1c0 --- /dev/null +++ b/docs/repl/components/OutputStatus.vue @@ -0,0 +1,109 @@ + + + + + diff --git a/docs/repl/components/ReplEditor.vue b/docs/repl/components/ReplEditor.vue new file mode 100644 index 00000000000..ed06515569d --- /dev/null +++ b/docs/repl/components/ReplEditor.vue @@ -0,0 +1,88 @@ + + + + + diff --git a/docs/repl/components/ReplInput.vue b/docs/repl/components/ReplInput.vue new file mode 100644 index 00000000000..9d8a0f1071e --- /dev/null +++ b/docs/repl/components/ReplInput.vue @@ -0,0 +1,75 @@ + + + + + diff --git a/docs/repl/components/ReplMain.vue b/docs/repl/components/ReplMain.vue new file mode 100644 index 00000000000..9320d2fdbac --- /dev/null +++ b/docs/repl/components/ReplMain.vue @@ -0,0 +1,181 @@ + + + + + + + diff --git a/docs/repl/components/ReplModule.vue b/docs/repl/components/ReplModule.vue new file mode 100644 index 00000000000..c39d9d6d63c --- /dev/null +++ b/docs/repl/components/ReplModule.vue @@ -0,0 +1,204 @@ + + + + + diff --git a/docs/repl/components/ReplOutput.vue b/docs/repl/components/ReplOutput.vue new file mode 100644 index 00000000000..65bd5a3f9ee --- /dev/null +++ b/docs/repl/components/ReplOutput.vue @@ -0,0 +1,32 @@ + + + diff --git a/docs/repl/components/RollupVersion.vue b/docs/repl/components/RollupVersion.vue new file mode 100644 index 00000000000..4aae784072d --- /dev/null +++ b/docs/repl/components/RollupVersion.vue @@ -0,0 +1,51 @@ + + + + + + + diff --git a/docs/repl/components/SelectOption.vue b/docs/repl/components/SelectOption.vue new file mode 100644 index 00000000000..6ba47665c2d --- /dev/null +++ b/docs/repl/components/SelectOption.vue @@ -0,0 +1,47 @@ + + + + + diff --git a/docs/repl/components/StatusMessage.vue b/docs/repl/components/StatusMessage.vue new file mode 100644 index 00000000000..615eb0481ad --- /dev/null +++ b/docs/repl/components/StatusMessage.vue @@ -0,0 +1,67 @@ + + + + + diff --git a/docs/repl/examples/00/example.json b/docs/repl/examples/00/example.json new file mode 100644 index 00000000000..64ee77b4684 --- /dev/null +++ b/docs/repl/examples/00/example.json @@ -0,0 +1,9 @@ +{ + "title": "Named exports", + "options": { + "output": { + "exports": "auto", + "esModule": "if-default-prop" + } + } +} diff --git a/docs/repl/examples/00/modules/main.js b/docs/repl/examples/00/modules/main.js new file mode 100644 index 00000000000..a88f397e682 --- /dev/null +++ b/docs/repl/examples/00/modules/main.js @@ -0,0 +1,17 @@ +// NAMED EXPORTS +// There are many ways to export bindings +// from an ES2015 module +export var foo = 1; + +export function bar() { + // try changing this to `foo++` + // when generating CommonJS + return foo; +} + +function baz() { + return bar(); +} + +export * from './qux'; +export { baz }; diff --git a/docs/repl/examples/00/modules/qux.js b/docs/repl/examples/00/modules/qux.js new file mode 100644 index 00000000000..be346645bd2 --- /dev/null +++ b/docs/repl/examples/00/modules/qux.js @@ -0,0 +1 @@ +export const qux = 'QUX'; diff --git a/docs/repl/examples/01/example.json b/docs/repl/examples/01/example.json new file mode 100644 index 00000000000..552e7b13123 --- /dev/null +++ b/docs/repl/examples/01/example.json @@ -0,0 +1,6 @@ +{ + "title": "Tree-shaking", + "options": { + "treeshake": true + } +} diff --git a/docs/repl/examples/01/modules/main.js b/docs/repl/examples/01/modules/main.js new file mode 100644 index 00000000000..140917331c5 --- /dev/null +++ b/docs/repl/examples/01/modules/main.js @@ -0,0 +1,4 @@ +// TREE-SHAKING +import { cube } from './maths.js'; + +console.log(cube(5)); // 125 diff --git a/docs/repl/examples/01/modules/maths.js b/docs/repl/examples/01/modules/maths.js new file mode 100644 index 00000000000..e289b8977a3 --- /dev/null +++ b/docs/repl/examples/01/modules/maths.js @@ -0,0 +1,21 @@ +// maths.js + +// This function isn't used anywhere, so +// Rollup excludes it from the bundle... +export const square = x => x * x; + +// This function gets included +// rewrite this as `square(x) * x` +// and see what happens! +export const cube = x => x * x * x; + +// This "side effect" creates a global +// variable and will not be removed. +window.effect1 = 'created'; + +const includeEffect = false; +if (includeEffect) { + // On the other hand, this is never + // executed and thus removed. + window.effect1 = 'not created'; +} diff --git a/docs/repl/examples/02/example.json b/docs/repl/examples/02/example.json new file mode 100644 index 00000000000..354307d986f --- /dev/null +++ b/docs/repl/examples/02/example.json @@ -0,0 +1,9 @@ +{ + "title": "Default exports", + "options": { + "output": { + "exports": "auto", + "esModule": "if-default-prop" + } + } +} diff --git a/docs/repl/examples/02/modules/answer.js b/docs/repl/examples/02/modules/answer.js new file mode 100644 index 00000000000..126e6c004c5 --- /dev/null +++ b/docs/repl/examples/02/modules/answer.js @@ -0,0 +1,3 @@ +// Internal default exports are turned +// into variables +export default 42; diff --git a/docs/repl/examples/02/modules/main.js b/docs/repl/examples/02/modules/main.js new file mode 100644 index 00000000000..f2c968312bd --- /dev/null +++ b/docs/repl/examples/02/modules/main.js @@ -0,0 +1,6 @@ +// DEFAULT EXPORTS +// Default exports from the 'entry module' are +// exported from the bundle +import answer from './answer.js'; + +export default () => console.log('the answer is ' + answer); diff --git a/docs/repl/examples/03/example.json b/docs/repl/examples/03/example.json new file mode 100644 index 00000000000..4f513f9753a --- /dev/null +++ b/docs/repl/examples/03/example.json @@ -0,0 +1,3 @@ +{ + "title": "Static namespaces" +} diff --git a/docs/repl/examples/03/modules/assert.js b/docs/repl/examples/03/modules/assert.js new file mode 100644 index 00000000000..2ed2e039fcd --- /dev/null +++ b/docs/repl/examples/03/modules/assert.js @@ -0,0 +1,13 @@ +export function equal(a, b, message) { + if (!message) message = format('%s does not equal %s', a, b); + if (a != b) throw new Error(message); +} + +export function ok(value, message) { + if (!message) message = format('%s is not truthy', value); + if (!value) throw new Error(message); +} + +export function format(string_, ...arguments_) { + return string_.replace(/%s/g, () => arguments_.shift()); +} diff --git a/docs/repl/examples/03/modules/main.js b/docs/repl/examples/03/modules/main.js new file mode 100644 index 00000000000..0a59a45ee15 --- /dev/null +++ b/docs/repl/examples/03/modules/main.js @@ -0,0 +1,8 @@ +// STATIC NAMESPACES +// ES6 modules let you import all of another module's +// exports as a namespace... +import * as assert from './assert'; + +// ...but we can statically resolve this to the +// original function definition +assert.equal(1 + 1, 2); diff --git a/docs/repl/examples/04/example.json b/docs/repl/examples/04/example.json new file mode 100644 index 00000000000..9cea5f04503 --- /dev/null +++ b/docs/repl/examples/04/example.json @@ -0,0 +1,8 @@ +{ + "title": "Dynamic namespaces", + "options": { + "output": { + "freeze": "true" + } + } +} diff --git a/docs/repl/examples/04/modules/constants.js b/docs/repl/examples/04/modules/constants.js new file mode 100644 index 00000000000..dbbe643a03f --- /dev/null +++ b/docs/repl/examples/04/modules/constants.js @@ -0,0 +1,4 @@ +export const π = 3.141_59; +export const e = 2.718_28; +export const φ = 1.618_03; +export const λ = 1.303_57; diff --git a/docs/repl/examples/04/modules/main.js b/docs/repl/examples/04/modules/main.js new file mode 100644 index 00000000000..b121ecfb909 --- /dev/null +++ b/docs/repl/examples/04/modules/main.js @@ -0,0 +1,10 @@ +// DYNAMIC NAMESPACES +// In some cases, you don't know which exports will +// be accessed until you actually run the code. In +// these cases, Rollup creates a namespace object +// for dynamic lookup +import * as constants from './constants'; + +for (const key of Object.keys(constants)) { + console.log(`The value of ${key} is ${constants[key]}`); +} diff --git a/docs/repl/examples/05/example.json b/docs/repl/examples/05/example.json new file mode 100644 index 00000000000..8012aa73295 --- /dev/null +++ b/docs/repl/examples/05/example.json @@ -0,0 +1,12 @@ +{ + "title": "External imports", + "options": { + "output": { + "globals": { + "jquery": "$", + "$": "jquery" + }, + "interop": "default" + } + } +} diff --git a/docs/repl/examples/05/modules/main.js b/docs/repl/examples/05/modules/main.js new file mode 100644 index 00000000000..e339d2ea38a --- /dev/null +++ b/docs/repl/examples/05/modules/main.js @@ -0,0 +1,6 @@ +// EXTERNAL IMPORTS +// You can import external modules into your bundle – +// it doesn't matter if they're ES2015 or legacy +import $ from 'jquery'; + +$('body').html('

Hello world!

'); diff --git a/docs/repl/examples/06/example.json b/docs/repl/examples/06/example.json new file mode 100644 index 00000000000..0ee4fdecdc9 --- /dev/null +++ b/docs/repl/examples/06/example.json @@ -0,0 +1,8 @@ +{ + "title": "Dynamic imports", + "options": { + "output": { + "inlineDynamicImports": false + } + } +} diff --git a/docs/repl/examples/06/modules/main.js b/docs/repl/examples/06/modules/main.js new file mode 100644 index 00000000000..4b203614fa4 --- /dev/null +++ b/docs/repl/examples/06/modules/main.js @@ -0,0 +1,14 @@ +// DYNAMIC IMPORTS +// Rollup supports automatic chunking and lazy-loading +// via dynamic imports utilizing the import mechanism +// of the host system. +import square from './square.js'; + +// Directly use some math +console.log(square(2)); + +// Dynamically import the rest +import('./maths.js').then(maths => { + console.log(maths.square(5)); + console.log(maths.cube(5)); +}); diff --git a/docs/repl/examples/06/modules/maths.js b/docs/repl/examples/06/modules/maths.js new file mode 100644 index 00000000000..f2197ae0d34 --- /dev/null +++ b/docs/repl/examples/06/modules/maths.js @@ -0,0 +1,5 @@ +import square from './square.js'; + +export { default as square } from './square.js'; + +export const cube = x => square(x) * x; diff --git a/docs/repl/examples/06/modules/square.js b/docs/repl/examples/06/modules/square.js new file mode 100644 index 00000000000..8818ad256d3 --- /dev/null +++ b/docs/repl/examples/06/modules/square.js @@ -0,0 +1,3 @@ +// Modules shared between the entry chunk and the +// dynamic chunk are merged into the entry chunk. +export default x => x * x; diff --git a/docs/repl/examples/07/example.json b/docs/repl/examples/07/example.json new file mode 100644 index 00000000000..2e559572a75 --- /dev/null +++ b/docs/repl/examples/07/example.json @@ -0,0 +1,10 @@ +{ + "title": "Multiple Entry Modules", + "entryModules": ["main.js", "otherEntry.js"], + "options": { + "output": { + "minifyInternalExports": false, + "preserveModules": false + } + } +} diff --git a/docs/repl/examples/07/modules/cube.js b/docs/repl/examples/07/modules/cube.js new file mode 100644 index 00000000000..fab93feba86 --- /dev/null +++ b/docs/repl/examples/07/modules/cube.js @@ -0,0 +1,8 @@ +import square from './square.js'; + +// Everything used by both entry modules will become +// a separate chunk that is imported by both entry +// chunks to avoid code duplication +export default function cube(x) { + return square(x) * x; +} diff --git a/docs/repl/examples/07/modules/hyperCube.js b/docs/repl/examples/07/modules/hyperCube.js new file mode 100644 index 00000000000..6b1f4ce7a18 --- /dev/null +++ b/docs/repl/examples/07/modules/hyperCube.js @@ -0,0 +1,7 @@ +import cube from './cube.js'; + +// This is only imported by one entry module and +// shares a chunk with that module +export default function hyperCube(x) { + return cube(x) * x; +} diff --git a/docs/repl/examples/07/modules/main.js b/docs/repl/examples/07/modules/main.js new file mode 100644 index 00000000000..3bb2bad9628 --- /dev/null +++ b/docs/repl/examples/07/modules/main.js @@ -0,0 +1,4 @@ +// MULTIPLE ENTRY MODULES +import hyperCube from './hyperCube.js'; + +console.log(hyperCube(5)); diff --git a/docs/repl/examples/07/modules/otherEntry.js b/docs/repl/examples/07/modules/otherEntry.js new file mode 100644 index 00000000000..e89a0a7c494 --- /dev/null +++ b/docs/repl/examples/07/modules/otherEntry.js @@ -0,0 +1,4 @@ +// Additional entry modules create new chunks +import cube from './cube.js'; + +console.log(cube(5)); diff --git a/docs/repl/examples/07/modules/square.js b/docs/repl/examples/07/modules/square.js new file mode 100644 index 00000000000..2f879d490ba --- /dev/null +++ b/docs/repl/examples/07/modules/square.js @@ -0,0 +1,4 @@ +// This is also shared between the entry chunks +export default function square(x) { + return x * x; +} diff --git a/docs/repl/examples/08/example.json b/docs/repl/examples/08/example.json new file mode 100644 index 00000000000..f085d76c5cd --- /dev/null +++ b/docs/repl/examples/08/example.json @@ -0,0 +1,8 @@ +{ + "title": "JSX", + "options": { + "jsx": { + "mode": "preserve" + } + } +} diff --git a/docs/repl/examples/08/modules/main.js b/docs/repl/examples/08/modules/main.js new file mode 100644 index 00000000000..e9744cbb67b --- /dev/null +++ b/docs/repl/examples/08/modules/main.js @@ -0,0 +1,6 @@ +// JSX SUPPORT +// Try different jsx.mode and see how it is transformed +import './other.js'; +const Foo = ({ world }) =>
Hello {world}!
; + +console.log(); diff --git a/docs/repl/examples/08/modules/other.js b/docs/repl/examples/08/modules/other.js new file mode 100644 index 00000000000..724d561c110 --- /dev/null +++ b/docs/repl/examples/08/modules/other.js @@ -0,0 +1,2 @@ +const Foo = () =>
This is deconflicted!
; +console.log(); diff --git a/docs/repl/font/fontello.eot b/docs/repl/font/fontello.eot new file mode 100755 index 00000000000..04482469f2c Binary files /dev/null and b/docs/repl/font/fontello.eot differ diff --git a/docs/repl/font/fontello.svg b/docs/repl/font/fontello.svg new file mode 100755 index 00000000000..62802757e76 --- /dev/null +++ b/docs/repl/font/fontello.svg @@ -0,0 +1,24 @@ + + + +Copyright (C) 2019 by original authors @ fontello.com + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/repl/font/fontello.ttf b/docs/repl/font/fontello.ttf new file mode 100755 index 00000000000..5ca21991c75 Binary files /dev/null and b/docs/repl/font/fontello.ttf differ diff --git a/docs/repl/font/fontello.woff b/docs/repl/font/fontello.woff new file mode 100755 index 00000000000..5511994f507 Binary files /dev/null and b/docs/repl/font/fontello.woff differ diff --git a/docs/repl/helpers/editor.ts b/docs/repl/helpers/editor.ts new file mode 100644 index 00000000000..576a548fdba --- /dev/null +++ b/docs/repl/helpers/editor.ts @@ -0,0 +1,177 @@ +import { closeBrackets, closeBracketsKeymap } from '@codemirror/autocomplete'; +import { defaultKeymap, history, historyKeymap } from '@codemirror/commands'; +import { javascript } from '@codemirror/lang-javascript'; +import { HighlightStyle, indentOnInput, syntaxHighlighting } from '@codemirror/language'; +import type { StateEffectType } from '@codemirror/state'; +import { EditorState, StateEffect, StateField } from '@codemirror/state'; +import type { ViewUpdate } from '@codemirror/view'; +import { Decoration, dropCursor, EditorView, keymap, lineNumbers } from '@codemirror/view'; +import { tags } from '@lezer/highlight'; +import type { LogLevel } from '../../../src/rollup/types'; + +export type AddLogs = StateEffectType<{ + messages: [level: LogLevel | 'error', { message: string; pos: number }][]; +}>; + +export const addLogs: AddLogs = StateEffect.define<{ + messages: [level: LogLevel | 'error', { message: string; pos: number }][]; +}>(); + +const logsField = StateField.define({ + create() { + return Decoration.none; + }, + provide: field => EditorView.decorations.from(field), + update(logs, transaction) { + let hasLog = false; + for (const effect of transaction.effects) { + if (effect.is(addLogs)) { + if (!hasLog) { + hasLog = true; + logs = Decoration.none; + } + logs = logs.update({ + add: effect.value.messages + .sort((a, b) => a[1].pos - b[1].pos) + .map(([level, { pos, message }]) => + Decoration.mark({ + attributes: { + class: `cm-rollup-${level}`, + title: message + } + }).range(pos, pos + 1) + ) + }); + } + } + return logs; + } +}); + +const theme = EditorView.baseTheme({ + '&.cm-editor.cm-focused': { + outline: 'none' + }, + '.cm-content': { + caretColor: '#fff', + // caretColor: 'var(--vp-c-neutral)', + color: '#A6ACCD', + fontFamily: 'var(--vp-font-family-mono)', + fontSize: '14px', + height: '100%', + lineHeight: '24px', + padding: '8px' + }, + '.cm-gutters': { + // we are hard-coding to dark mode colors until we figure out how to switch + // colors in code mirror + backgroundColor: '#161618', + // backgroundColor: 'var(--vp-code-block-bg)', + border: 'none', + borderBottomLeftRadius: '8px', + borderRight: '#000', + // borderRight: '1px solid var(--vp-code-block-divider-color)', + borderTopLeftRadius: '8px', + color: 'rgba(235,235,245,0.38)', + // color: 'var(--vp-code-line-number-color)', + minWidth: '32px' + }, + '.cm-gutters .cm-gutterElement': { + textAlign: 'center' + }, + '.cm-lineNumbers': { + alignItems: 'center', + width: '100%' + }, + '.cm-rollup-error': { + backgroundColor: 'var(--error-background)', + borderRadius: '2px', + color: 'var(--error-color)', + margin: '-2px', + padding: '2px' + }, + '.cm-rollup-error > span': { + color: 'var(--error-color)' + }, + '.cm-rollup-info': { + backgroundColor: 'var(--log-background)', + borderRadius: '2px', + color: 'var(--log-color)', + margin: '-2px', + padding: '2px' + }, + '.cm-rollup-info > span': { + color: 'var(--log-color)' + }, + '.cm-rollup-warn': { + backgroundColor: 'var(--warning-background)', + borderRadius: '2px', + color: 'var(--warning-color)', + margin: '-2px', + padding: '2px' + }, + '.cm-rollup-warn > span': { + color: 'var(--warning-color)' + }, + '.cm-scroller': { + borderBottomLeftRadius: '8px', + borderBottomRightRadius: '8px', + fontFamily: 'var(--vp-font-family-mono)', + fontSize: '14px', + fontWeight: '400', + lineHeight: '24px', + marginTop: '2px' + } +}); + +const highlightStyle = HighlightStyle.define([ + { color: '#676E95', fontStyle: 'italic', tag: tags.comment }, + { color: '#C3E88D', tag: tags.string }, + { color: '#FF9CAC', tag: tags.literal }, + // names + { color: '#A6ACCD', tag: tags.name }, + { color: '#f07178', tag: tags.variableName }, + { color: '#82AAFF', tag: tags.propertyName }, + // punctuation + { color: '#89DDFF', tag: tags.punctuation }, + { color: '#89DDFF', tag: tags.operator }, + // keywords + { color: '#89DDFF', tag: tags.keyword }, + { color: '#C792EA', tag: tags.definitionKeyword } +]); + +export const createEditor = ( + parent: HTMLElement, + document_: string, + onUpdate: ( + update: ViewUpdate & { + changedRanges: { + fromA: number; + fromB: number; + toA: number; + toB: number; + }[]; + } + ) => void, + readonly: boolean +) => + new EditorView({ + doc: document_, + extensions: [ + lineNumbers(), + history(), + dropCursor(), + indentOnInput(), + syntaxHighlighting(highlightStyle, { fallback: true }), + closeBrackets(), + keymap.of([...closeBracketsKeymap, ...defaultKeymap, ...historyKeymap]), + javascript(), + EditorState.readOnly.of(readonly), + EditorView.lineWrapping, + EditorState.tabSize.of(2), + EditorView.updateListener.of(onUpdate as any), + logsField, + theme + ], + parent + }); diff --git a/docs/repl/helpers/importRollup.ts b/docs/repl/helpers/importRollup.ts new file mode 100644 index 00000000000..d1bbf4128b1 --- /dev/null +++ b/docs/repl/helpers/importRollup.ts @@ -0,0 +1,17 @@ +export * from '../../../src/browser-entry'; +import type * as Rollup from '../../../src/browser-entry'; + +let updateListener: null | ((instance: typeof Rollup) => void) = null; +export const onUpdate = (listener: (instance: typeof Rollup) => void) => { + updateListener = listener; +}; + +if (import.meta.hot) { + // This will enable HMR for any changes within the Rollup sources + import.meta.hot.accept(newModule => { + if (newModule && updateListener) { + newModule.onUpdate(updateListener); + updateListener(newModule as unknown as typeof Rollup); + } + }); +} diff --git a/docs/repl/helpers/messages.ts b/docs/repl/helpers/messages.ts new file mode 100644 index 00000000000..a526f9584f9 --- /dev/null +++ b/docs/repl/helpers/messages.ts @@ -0,0 +1,3 @@ +export function getFileNameFromMessage({ id, loc }: { id?: string; loc?: { file?: string } }) { + return (loc && loc.file) || id; +} diff --git a/docs/repl/helpers/path.ts b/docs/repl/helpers/path.ts new file mode 100644 index 00000000000..7082119a052 --- /dev/null +++ b/docs/repl/helpers/path.ts @@ -0,0 +1,76 @@ +export const absolutePath = /^(?:\/|(?:[A-Za-z]:)?[/\\|])/; +export const relativePath = /^\.?\.\//; + +export function isAbsolute(path: string) { + return absolutePath.test(path); +} + +export function isRelative(path: string) { + return relativePath.test(path); +} + +export function basename(path: string) { + return path.split(/(\/|\\)/).pop(); +} + +export function dirname(path: string) { + const match = /([/\\])[^/\\]*$/.exec(path); + if (!match) return '.'; + + const directory = path.slice(0, -match[0].length); + + // If `dir` is the empty string, we're at root. + return directory || '/'; +} + +export function extname(path: string) { + const match = /\.[^.]+$/.exec(basename(path)!); + if (!match) return ''; + return match[0]; +} + +export function relative(from: string, to: string) { + const fromParts = from.split(/[/\\]/).filter(Boolean); + const toParts = to.split(/[/\\]/).filter(Boolean); + + while (fromParts[0] && toParts[0] && fromParts[0] === toParts[0]) { + fromParts.shift(); + toParts.shift(); + } + + while (toParts[0] === '.' || toParts[0] === '..') { + const toPart = toParts.shift(); + if (toPart === '..') { + fromParts.pop(); + } + } + + while (fromParts.pop()) { + toParts.unshift('..'); + } + + return toParts.join('/'); +} + +const ANY_SLASH_REGEX = /[/\\]/; +const TRAILING_SLASH_REGEX = /[/\\]$/; + +export function resolve(...paths: string[]) { + let resolvedParts = paths.shift()!.replace(TRAILING_SLASH_REGEX, '').split(ANY_SLASH_REGEX); + for (const path of paths) { + const parts = path.replace(TRAILING_SLASH_REGEX, '').split(ANY_SLASH_REGEX); + if (isAbsolute(path)) { + resolvedParts = parts; + } else { + while (parts[0] === '.' || parts[0] === '..') { + const part = parts.shift(); + if (part === '..') { + resolvedParts.pop(); + } + } + resolvedParts.push(...parts); + } + } + + return resolvedParts.join('/'); +} diff --git a/docs/repl/helpers/query.ts b/docs/repl/helpers/query.ts new file mode 100644 index 00000000000..91bc0f601ee --- /dev/null +++ b/docs/repl/helpers/query.ts @@ -0,0 +1,117 @@ +import { watch } from 'vue'; +import type { OutputOptions, RollupOptions } from '../../../src/rollup/types'; +import type { Module } from '../../types'; +import { useModules } from '../stores/modules'; +import { useOptions } from '../stores/options'; +import { useRollup } from '../stores/rollup'; + +export async function useUpdateStoresFromQuery() { + // Necessary for SSR + if (typeof window === 'undefined') return; + const modulesStore = useModules(); + const optionsStore = useOptions(); + const rollupStore = useRollup(); + const urlParameters = new URLSearchParams(location.search); + const query = Object.fromEntries(urlParameters as unknown as Iterable<[string, string]>); + try { + if (query.shareable) { + const rawJson = atob(query.shareable.replace(/_/g, '/').replace(/-/g, '+')); + const json = rawJson[0] === '%' ? decodeURIComponent(rawJson) : rawJson; + const { + modules: queryModules, + options: queryOptions, + example + }: { + example: string; + modules: Module[]; + options: RollupOptions | OutputOptions; + } = JSON.parse(json); + modulesStore.set(queryModules, example); + optionsStore.setAll('output' in queryOptions ? queryOptions : { output: queryOptions }); + } else if (query.gist) { + const result = await ( + await fetch(`https://api.github.com/gists/${query.gist}`, { + headers: { Accept: 'application/vnd.github.v3+json' }, + method: 'GET' + }) + ).json(); + const entryModules = query.entry ? query.entry.split(',') : []; + modulesStore.set( + [ + result.files['main.js'] || { content: '', filename: 'main.js' }, + ...Object.keys(result.files) + .filter(fileName => fileName !== 'main.js') + .map(fileName => result.files[fileName]) + ].map(module => ({ + code: module.content, + isEntry: entryModules.includes(module.filename), + name: module.filename + })), + '' + ); + } else if (modulesStore.modules.length === 0) { + modulesStore.selectExample('00'); + } + } catch (error) { + console.error(error); + modulesStore.selectExample('00'); + } + + if (query.pr) { + if (/^\d+$/.test(query.pr)) { + rollupStore.requestRollup({ type: 'pr', version: query.pr }); + } else { + rollupStore.requestError(new Error(`Unexpected pull request number in URL: ${query.pr}`)); + } + } else if (import.meta.env.DEV && (query.local || !query.version)) { + rollupStore.requestRollup({ type: 'local', version: undefined }); + } else { + if (!query.version || /^\d+\.\d+\.\d+(-\d+)?$/.test(query.version)) { + rollupStore.requestRollup({ type: 'version', version: query.version }); + } else { + rollupStore.requestError(new Error(`Unexpected Rollup version in URL: ${query.version}`)); + } + } +} + +export function useSyncQueryWithStores() { + const modulesStore = useModules(); + const optionsStore = useOptions(); + const rollupStore = useRollup(); + watch( + [ + () => modulesStore.modules, + () => optionsStore.optionsObject, + () => modulesStore.selectedExample, + () => rollupStore.request, + () => rollupStore.loaded.instance?.VERSION + ], + ([modules, options, selectedExample, rollupRequest, rollupVersion]) => { + const parameters: Record = {}; + if (rollupRequest?.type === 'pr') { + parameters.pr = rollupRequest.version; + } else if (import.meta.env.DEV && rollupRequest?.type === 'local') { + parameters.local = 'true'; + } else { + const version = rollupVersion || rollupRequest?.version; + if (version) { + parameters.version = version; + } + } + + const json = JSON.stringify({ + example: selectedExample, + modules, + options + }); + + parameters.shareable = btoa(json).replace(/\//g, '_').replace(/\+/g, '-'); + const queryString = Object.keys(parameters) + .map(key => `${key}=${parameters[key]}`) + .join('&'); + const url = `?${queryString}`; + history.replaceState({}, '', url); + }, + { deep: true } + ); +} diff --git a/docs/repl/helpers/rollupVersion.ts b/docs/repl/helpers/rollupVersion.ts new file mode 100644 index 00000000000..5e57df140f1 --- /dev/null +++ b/docs/repl/helpers/rollupVersion.ts @@ -0,0 +1,5 @@ +export const isRollupVersionAtLeast = (version: string, major: number, minor: number) => { + if (!version) return true; + const [currentMajor, currentMinor] = version.split('.').map(Number); + return currentMajor > major || (currentMajor === major && currentMinor >= minor); +}; diff --git a/docs/repl/images/select-arrow-dark.svg b/docs/repl/images/select-arrow-dark.svg new file mode 100644 index 00000000000..e27817a5d1c --- /dev/null +++ b/docs/repl/images/select-arrow-dark.svg @@ -0,0 +1,6 @@ + + + + + diff --git a/docs/repl/images/select-arrow.svg b/docs/repl/images/select-arrow.svg new file mode 100644 index 00000000000..69106c5a629 --- /dev/null +++ b/docs/repl/images/select-arrow.svg @@ -0,0 +1,6 @@ + + + + + diff --git a/docs/repl/index.md b/docs/repl/index.md new file mode 100644 index 00000000000..4e4cbff7e97 --- /dev/null +++ b/docs/repl/index.md @@ -0,0 +1,10 @@ +--- +layout: home +title: REPL +--- + + + + diff --git a/docs/repl/stores/currentSection.ts b/docs/repl/stores/currentSection.ts new file mode 100644 index 00000000000..bd7bdb082f8 --- /dev/null +++ b/docs/repl/stores/currentSection.ts @@ -0,0 +1,12 @@ +import { defineStore } from 'pinia'; +import { ref } from 'vue'; + +export const useCurrentSection = defineStore('currentSection', () => { + const section = ref(null); + return { + section, + set(value: string) { + section.value = value; + } + }; +}); diff --git a/docs/repl/stores/drawerOpen.ts b/docs/repl/stores/drawerOpen.ts new file mode 100644 index 00000000000..6641b172fa7 --- /dev/null +++ b/docs/repl/stores/drawerOpen.ts @@ -0,0 +1,13 @@ +import { defineStore } from 'pinia'; +import { ref } from 'vue'; + +export const useDrawerOpen = defineStore('drawerOpen', () => { + const isOpen = ref(false); + const toggle = () => { + isOpen.value = !isOpen.value; + }; + const close = () => { + isOpen.value = false; + }; + return { close, isOpen, toggle }; +}); diff --git a/docs/repl/stores/modules.ts b/docs/repl/stores/modules.ts new file mode 100644 index 00000000000..e257b7108d3 --- /dev/null +++ b/docs/repl/stores/modules.ts @@ -0,0 +1,55 @@ +import examplesById from 'examples.json'; +import { defineStore } from 'pinia'; +import { ref, watch } from 'vue'; +import type { Module } from '../../types'; +import { useOptions } from './options'; + +const areModulesEqual = (modulesA: Module[], modulesB: Module[]) => + modulesA.length === modulesB.length && + modulesA.every( + (module, index) => + module.name === modulesB[index].name && + module.code === modulesB[index].code && + module.isEntry === modulesB[index].isEntry + ); + +export const useModules = defineStore('modules', () => { + const optionsStore = useOptions(); + const modules = ref([]); + const selectedExample = ref(null); + + watch( + modules, + modulesValue => { + if ( + selectedExample.value && + !( + examplesById[selectedExample.value] && + areModulesEqual(modulesValue, examplesById[selectedExample.value].modules) + ) + ) { + selectedExample.value = null; + } + }, + { deep: true } + ); + + return { + modules, + selectedExample, + selectExample(value: string) { + const { modules: exampleModules, options } = examplesById[value]; + modules.value = exampleModules.map((module: Module) => ({ + ...module + })); + selectedExample.value = value; + if (options) { + optionsStore.setAll(options); + } + }, + set(newModules: Module[], newSelectedExample: string) { + selectedExample.value = newSelectedExample; + modules.value = newModules; + } + }; +}); diff --git a/docs/repl/stores/options.ts b/docs/repl/stores/options.ts new file mode 100644 index 00000000000..048efe83c1c --- /dev/null +++ b/docs/repl/stores/options.ts @@ -0,0 +1,710 @@ +import { defineStore } from 'pinia'; +import type { Ref } from 'vue'; +import { computed, ref, shallowRef, watchEffect } from 'vue'; +import type { RollupOptions } from '../../../src/rollup/types'; +import { useModules } from './modules'; +import { useRollupOutput } from './rollupOutput'; + +interface BaseOptionType { + available: Ref; + defaultValue: T | undefined; + name: string; + required: Ref; + type: string; + value: Ref; +} + +interface OptionTypeSelect extends BaseOptionType { + options: Ref; + type: 'select'; +} + +interface OptionTypeString extends BaseOptionType { + placeholder: string | undefined; + type: 'string'; +} + +interface OptionTypeStringMapping extends BaseOptionType> { + keys: Ref; + type: 'string-mapping'; +} + +interface OptionTypeNumber extends BaseOptionType { + placeholder: string | undefined; + type: 'number'; +} + +type OptionType = + | OptionTypeSelect + | OptionTypeString + | OptionTypeStringMapping + | OptionTypeNumber; + +const mapOptions = { + number({ defaultValue, name, placeholder, required, value }: OptionTypeNumber) { + return { + name, + placeholder, + removable: !required.value, + type: 'number', + value: value.value === undefined ? defaultValue : value.value + } as const; + }, + select({ defaultValue, name, options, required, value }: OptionTypeSelect) { + return { + name, + options: options.value, + removable: !required.value, + type: 'select', + value: + value.value === undefined || !options.value.includes(value.value) + ? defaultValue + : value.value + } as const; + }, + string({ defaultValue, name, placeholder, required, value }: OptionTypeString) { + return { + name, + placeholder, + removable: !required.value, + type: 'string', + value: value.value === undefined ? defaultValue : value.value + } as const; + }, + 'string-mapping'({ defaultValue, keys, name, required, value }: OptionTypeStringMapping) { + return { + keys: keys.value, + name, + removable: !required.value, + type: 'string-mapping', + value: value.value === undefined ? defaultValue : value.value + } as const; + } +}; + +type Option = ReturnType<(typeof mapOptions)[keyof typeof mapOptions]>; + +const alwaysTrue = computed(() => true); +const alwaysFalse = computed(() => false); + +const allFormats = ['es', 'amd', 'cjs', 'iife', 'umd', 'system']; +const codeSplittingFormats = ['es', 'amd', 'cjs', 'system']; +const amdFormats = new Set(['amd', 'umd']); +const iifeFormats = new Set(['iife', 'umd']); +const interopFormats = new Set(['amd', 'cjs', 'iife', 'umd']); + +const isOptionShown = ({ required, available, value }: OptionType) => + available.value && (required.value || value.value !== undefined); + +export const useOptions = defineStore('options2', () => { + const rollupOutputStore = useRollupOutput(); + const modulesStore = useModules(); + + const outputHasMultipleChunks = computed(() => rollupOutputStore.output?.output.length > 1); + const isAmdFormat = computed(() => { + const { value } = optionOutputFormat.value; + return value != null && amdFormats.has(value); + }); + const isIifeFormat = computed(() => { + const { value } = optionOutputFormat.value; + return value != null && iifeFormats.has(value); + }); + const isInteropFormat = computed(() => { + const { value } = optionOutputFormat.value; + return value != null && interopFormats.has(value); + }); + const externalImports = computed(() => rollupOutputStore.output?.externalImports || []); + const isJsxEnabled = computed(() => optionJsx.value.value === true); + const isTreeshakeEnabled = computed(() => + [undefined, true].includes(optionTreeshake.value.value as any) + ); + + const optionContext = getString({ + defaultValue: 'undefined', + name: 'context' + }); + const optionExperimentalLogSideEffects = getBoolean({ + name: 'experimentalLogSideEffects' + }); + const optionOutputAmdAutoId = getBoolean({ + available: () => isAmdFormat.value, + name: 'output.amd.autoId' + }); + const optionOutputAmdBasePath = getString({ + available: optionOutputAmdAutoId.value, + name: 'output.amd.basePath' + }); + const optionOutputAmdDefine = getString({ + available: isAmdFormat, + defaultValue: 'define', + name: 'output.amd.define' + }); + const optionOutputAmdForceJsExtensionForImports = getBoolean({ + available: isAmdFormat, + name: 'output.amd.forceJsExtensionForImports' + }); + const optionOutputAmdId = getString({ + available: () => + isAmdFormat.value && !outputHasMultipleChunks.value && !optionOutputAmdAutoId.value.value, + name: 'output.amd.id', + placeholder: 'leave blank for anonymous module' + }); + const optionOutputBanner = getString({ + name: 'output.banner' + }); + const optionOutputChunkFileNames = getString({ + available: alwaysTrue, + defaultValue: '[name]-[hash].js', + name: 'output.chunkFileNames' + }); + const optionOutputCompact = getBoolean({ + name: 'output.compact' + }); + const optionOutputDynamicImportInCjs = getBoolean({ + available: () => optionOutputFormat.value.value === 'cjs', + defaultValue: true, + name: 'output.dynamicImportInCjs' + }); + const optionOutputEntryFileNames = getString({ + available: alwaysTrue, + defaultValue: '[name].js', + name: 'output.entryFileNames' + }); + const optionOutputEsModule = getSelect({ + available: isInteropFormat, + defaultValue: 'if-default-prop', + name: 'output.esModule', + options: () => [false, true, 'if-default-prop'] + }); + const optionOutputExperimentalMinChunkSize = getNumber({ + defaultValue: 0, + name: 'output.experimentalMinChunkSize' + }); + const optionOutputExports = getSelect({ + available: isInteropFormat, + defaultValue: 'auto', + name: 'output.exports', + options: () => ['auto', 'default', 'named', 'none'] + }); + const optionOutputExtend = getBoolean({ + available: isIifeFormat, + name: 'output.extend' + }); + const optionOutputExternalLiveBindings = getBoolean({ + available: isInteropFormat, + defaultValue: true, + name: 'output.externalLiveBindings' + }); + const optionOutputExternalImportAttributes = getBoolean({ + available: () => optionOutputFormat.value.value === 'es', + defaultValue: true, + name: 'output.externalImportAttributes' + }); + const optionOutputFreeze = getBoolean({ + defaultValue: true, + name: 'output.freeze' + }); + const optionOutputFooter = getString({ + name: 'output.footer' + }); + const optionOutputFormat = getSelect({ + defaultValue: 'es', + name: 'output.format', + options: () => + optionOutputPreserveModules.value.value === true || outputHasMultipleChunks.value + ? codeSplittingFormats + : allFormats, + required: () => true + }); + const optionOutputGeneratedCodeArrowFunctions = getBoolean({ + name: 'output.generatedCode.arrowFunctions' + }); + const optionOutputGeneratedCodeConstBindings = getBoolean({ + name: 'output.generatedCode.constBindings' + }); + const optionOutputGeneratedCodeObjectShorthand = getBoolean({ + name: 'output.generatedCode.objectShorthand' + }); + const optionOutputGeneratedCodePreset = getSelect({ + defaultValue: null, + name: 'output.generatedCode.preset', + options: () => [null, 'es5', 'es2015'] + }); + const optionOutputGeneratedCodeReservedNamesAsProperties = getBoolean({ + defaultValue: true, + name: 'output.generatedCode.reservedNamesAsProps' + }); + const optionOutputGeneratedCodeSymbols = getBoolean({ + name: 'output.generatedCode.symbols' + }); + const optionOutputGlobals = getStringMapping({ + available: () => isIifeFormat.value && externalImports.value.length > 0, + keys: externalImports, + name: 'output.globals', + required: () => true + }); + const optionOutputHashCharacters = getSelect({ + defaultValue: 'base64', + name: 'output.hashCharacters', + options: () => ['base64', 'base36', 'hex'] + }); + const optionOutputHoistTransitiveImports = getBoolean({ + available: alwaysTrue, + defaultValue: true, + name: 'output.hoistTransitiveImports' + }); + const optionOutputImportAttributesKey = getSelect({ + defaultValue: 'assert', + name: 'output.importAttributesKey', + options: () => ['with', 'assert'] + }); + const optionOutputIndent = getBoolean({ + available: () => ['amd', 'iife', 'umd', 'system'].includes(optionOutputFormat.value.value!), + defaultValue: true, + name: 'output.indent' + }); + const optionOutputInlineDynamicImports = getBoolean({ + available: () => { + const modules = modulesStore.modules; + if (!modules) return false; + let entryPoints = 0; + for (const { isEntry } of modules) { + if (isEntry) { + entryPoints++; + if (entryPoints > 1) { + return false; + } + } + } + return true; + }, + name: 'output.inlineDynamicImports' + }); + const optionOutputInterop = getSelect({ + available: () => { + const { value } = optionOutputFormat.value; + return value != null && interopFormats.has(value); + }, + defaultValue: 'default', + name: 'output.interop', + options: () => ['compat', 'auto', 'esModule', 'default', 'defaultOnly'] + }); + const optionOutputIntro = getString({ + name: 'output.intro' + }); + const optionOutputMinifyInternalExports = getBoolean({ + available: alwaysTrue, + name: 'output.minifyInternalExports' + }); + const optionOutputNoConflict = getBoolean({ + available: () => optionOutputFormat.value.value === 'umd', + name: 'output.noConflict' + }); + const optionOutputName = getString({ + available: isIifeFormat, + defaultValue: 'myBundle', + name: 'output.name', + required: () => rollupOutputStore.output.output[0]?.exports.length > 0 + }); + const optionOutputOutro = getString({ + name: 'output.outro' + }); + const optionOutputPaths = getStringMapping({ + available: () => externalImports.value.length > 0 && optionOutputFormat.value.value !== 'iife', + keys: externalImports, + name: 'output.paths' + }); + const optionOutputPreserveModules = getBoolean({ + available: () => { + const { value } = optionOutputFormat.value; + return value == null || codeSplittingFormats.includes(value); + }, + name: 'output.preserveModules' + }); + const optionOutputPreserveModulesRoot = getString({ + available: optionOutputPreserveModules.value, + name: 'output.preserveModulesRoot' + }); + const optionOutputReexportProtoFromExternal = getBoolean({ + available: () => + isInteropFormat.value && optionOutputExternalLiveBindings.value.value === false, + defaultValue: true, + name: 'output.reexportProtoFromExternal' + }); + const optionOutputSanitizeFileName = getBoolean({ + available: alwaysTrue, + defaultValue: true, + name: 'output.sanitizeFileName' + }); + const optionOutputSourcemap = getBoolean({ + name: 'output.sourcemap' + }); + const optionOutputSourcemapBaseUrl = getString({ + available: optionOutputSourcemap.value, + name: 'output.sourcemapBaseUrl' + }); + const optionOutputSourcemapExcludeSources = getBoolean({ + available: optionOutputSourcemap.value, + name: 'output.sourcemapExcludeSources' + }); + const optionOutputSourcemapFileNames = getString({ + available: alwaysTrue, + defaultValue: undefined, + name: 'output.sourcemapFileNames' + }); + const optionOutputStrict = getBoolean({ + available: () => + optionOutputFormat.value.value !== undefined && optionOutputFormat.value.value !== 'es', + defaultValue: true, + name: 'output.strict' + }); + const optionOutputSystemNullSetters = getBoolean({ + available: () => optionOutputFormat.value.value === 'system', + defaultValue: true, + name: 'output.systemNullSetters' + }); + const optionOutputValidate = getBoolean({ + name: 'output.validate' + }); + const optionPreserveEntrySignatures = getSelect({ + available: alwaysTrue, + defaultValue: 'exports-only', + name: 'preserveEntrySignatures', + options: () => ['strict', 'allow-extension', 'exports-only', false] + }); + const optionShimMissingExports = getBoolean({ + defaultValue: false, + name: 'shimMissingExports' + }); + const optionJsx = getSelect({ + defaultValue: false, + name: 'jsx', + options: () => [false, true, 'preserve', 'preserve-react', 'react', 'react-jsx'] + }); + const optionJsxFactory = getString({ + available: isJsxEnabled, + name: 'jsx.factory' + }); + const optionJsxFragment = getString({ + available: computed(() => isJsxEnabled.value && optionJsxMode.value.value !== 'automatic'), + name: 'jsx.fragment' + }); + const optionJsxImportSource = getString({ + available: isJsxEnabled, + name: 'jsx.importSource' + }); + const optionJsxJsxImportSource = getString({ + available: computed(() => isJsxEnabled.value && optionJsxMode.value.value === 'automatic'), + name: 'jsx.jsxImportSource' + }); + const optionJsxMode = getSelect({ + available: isJsxEnabled, + defaultValue: 'classic', + name: 'jsx.mode', + options: () => ['classic', 'automatic', 'preserve'] + }); + const optionJsxPreset = getSelect({ + available: isJsxEnabled, + defaultValue: null, + name: 'jsx.preset', + options: () => [null, 'preserve', 'preserve-react', 'react', 'react-jsx'] + }); + const optionTreeshake = getSelect({ + defaultValue: true, + name: 'treeshake', + options: () => [false, true, 'smallest', 'safest', 'recommended'] + }); + const optionTreeshakeAnnotations = getBoolean({ + available: isTreeshakeEnabled, + defaultValue: true, + name: 'treeshake.annotations' + }); + const optionTreeshakeCorrectVariableValueBeforeDeclaration = getBoolean({ + available: isTreeshakeEnabled, + defaultValue: false, + name: 'treeshake.correctVarValueBeforeDeclaration' + }); + const optionTreeshakeModuleSideEffects = getSelect({ + available: isTreeshakeEnabled, + defaultValue: true, + name: 'treeshake.moduleSideEffects', + options: () => [false, true, 'no-external'] + }); + const optionTreeshakePreset = getSelect({ + available: isTreeshakeEnabled, + defaultValue: null, + name: 'treeshake.preset', + options: () => [null, 'smallest', 'safest', 'recommended'] + }); + const optionTreeshakePropertyReadSideEffects = getSelect({ + available: isTreeshakeEnabled, + defaultValue: true, + name: 'treeshake.propertyReadSideEffects', + options: () => [false, true, 'always'] + }); + const optionTreeshakeTryCatchDeoptimization = getBoolean({ + available: isTreeshakeEnabled, + defaultValue: true, + name: 'treeshake.tryCatchDeoptimization' + }); + const optionTreeshakeUnknownGlobalSideEffects = getBoolean({ + available: isTreeshakeEnabled, + defaultValue: true, + name: 'treeshake.unknownGlobalSideEffects' + }); + + const optionList: OptionType[] = [ + optionContext, + optionExperimentalLogSideEffects, + optionJsx, + optionJsxMode, + optionJsxFactory, + optionJsxFragment, + optionJsxImportSource, + optionJsxJsxImportSource, + optionJsxPreset, + optionOutputAmdAutoId, + optionOutputAmdBasePath, + optionOutputAmdDefine, + optionOutputAmdForceJsExtensionForImports, + optionOutputAmdId, + optionOutputBanner, + optionOutputChunkFileNames, + optionOutputCompact, + optionOutputDynamicImportInCjs, + optionOutputEntryFileNames, + optionOutputEsModule, + optionOutputExperimentalMinChunkSize, + optionOutputExports, + optionOutputExtend, + optionOutputExternalLiveBindings, + optionOutputExternalImportAttributes, + optionOutputFreeze, + optionOutputFooter, + optionOutputFormat, + optionOutputGeneratedCodeArrowFunctions, + optionOutputGeneratedCodeConstBindings, + optionOutputGeneratedCodeObjectShorthand, + optionOutputGeneratedCodePreset, + optionOutputGeneratedCodeReservedNamesAsProperties, + optionOutputGeneratedCodeSymbols, + optionOutputGlobals, + optionOutputHashCharacters, + optionOutputHoistTransitiveImports, + optionOutputImportAttributesKey, + optionOutputIndent, + optionOutputInlineDynamicImports, + optionOutputInterop, + optionOutputIntro, + optionOutputMinifyInternalExports, + optionOutputNoConflict, + optionOutputName, + optionOutputOutro, + optionOutputPaths, + optionOutputPreserveModules, + optionOutputPreserveModulesRoot, + optionOutputReexportProtoFromExternal, + optionOutputSourcemap, + optionOutputSourcemapFileNames, + optionOutputSanitizeFileName, + optionOutputSourcemapBaseUrl, + optionOutputSourcemapExcludeSources, + optionOutputStrict, + optionOutputValidate, + optionPreserveEntrySignatures, + optionOutputSystemNullSetters, + optionShimMissingExports, + optionTreeshake, + optionTreeshakeAnnotations, + optionTreeshakeCorrectVariableValueBeforeDeclaration, + optionTreeshakeModuleSideEffects, + optionTreeshakePreset, + optionTreeshakePropertyReadSideEffects, + optionTreeshakeTryCatchDeoptimization, + optionTreeshakeUnknownGlobalSideEffects + ]; + const options = computed(() => + optionList + .filter(isOptionShown) + .map((option: OptionType) => mapOptions[option.type](option as any)) + ); + + return { + additionalAvailableOptions: computed(() => + optionList + .filter(option => option.available.value && !isOptionShown(option)) + .map(({ name }) => name) + ), + addOption(optionName: string) { + const option = optionList.find(({ name }) => name === optionName)!; + option.value.value = option.defaultValue; + }, + options, + optionsObject: getOptionsObject(options), + set(name: string, value: any) { + optionList.find(option => option.name === name)!.value.value = value; + }, + setAll(options: RollupOptions) { + for (const { name, value } of optionList) { + const path = name.split('.'); + let key: string | undefined; + let subOptions: any = options; + while ((key = path.shift())) { + subOptions = subOptions?.[key]; + } + value.value = + ['jsx', 'treeshake'].includes(name) && typeof subOptions === 'object' ? true : subOptions; + } + } + }; +}); + +function getBoolean({ + available, + defaultValue, + name +}: { + available?: (() => boolean) | Ref; + defaultValue?: boolean; + name: string; +}): OptionTypeSelect { + return getSelect({ + available, + defaultValue: defaultValue || false, + name, + options: () => [false, true] + }); +} + +function getSelect({ + available, + defaultValue, + name, + options, + required +}: { + available?: (() => boolean) | Ref; + defaultValue: T; + name: string; + options: () => T[]; + required?: () => boolean; +}): OptionTypeSelect { + return { + available: typeof available === 'function' ? computed(available) : available || alwaysTrue, + defaultValue, + name, + options: computed(options), + required: required ? computed(required) : alwaysFalse, + type: 'select', + value: ref(undefined) + }; +} + +function getString({ + available, + defaultValue, + name, + placeholder, + required +}: { + available?: (() => boolean) | Ref; + defaultValue?: string; + name: string; + placeholder?: string; + required?: () => boolean; +}): OptionTypeString { + return { + available: typeof available === 'function' ? computed(available) : available || alwaysTrue, + defaultValue: defaultValue ?? '', + name, + placeholder, + required: required ? computed(required) : alwaysFalse, + type: 'string', + value: ref(undefined) + }; +} + +function getStringMapping({ + available, + keys, + name, + required +}: { + available?: () => boolean; + keys: Ref; + name: string; + placeholder?: string; + required?: () => boolean; +}): OptionTypeStringMapping { + return { + available: available ? computed(available) : alwaysTrue, + defaultValue: {}, + keys, + name, + required: required ? computed(required) : alwaysFalse, + type: 'string-mapping', + value: shallowRef(undefined) + }; +} + +function getNumber({ + available, + defaultValue, + name, + placeholder, + required +}: { + available?: (() => boolean) | Ref; + defaultValue?: number; + name: string; + placeholder?: string; + required?: () => boolean; +}): OptionTypeNumber { + return { + available: typeof available === 'function' ? computed(available) : available || alwaysTrue, + defaultValue: defaultValue ?? 0, + name, + placeholder, + required: required ? computed(required) : alwaysFalse, + type: 'number', + value: ref(undefined) + }; +} + +function getOptionsObject(options: Ref): Ref { + let previousOptions = options.value.filter(({ value }) => value !== undefined); + const result = shallowRef({}); + watchEffect( + () => { + const filteredOptions = options.value.filter(({ value }) => value !== undefined); + if ( + filteredOptions.length === previousOptions.length && + filteredOptions.every( + ({ name, value }, index) => + name === previousOptions[index].name && value === previousOptions[index].value + ) + ) { + return; + } + previousOptions = filteredOptions; + const object = {}; + for (const { name, value } of filteredOptions) { + const path = name.split('.'); + const valueKey = path.pop()!; + let key: string | undefined; + let subOptions: any = object; + while ((key = path.shift())) { + // Special logic to handle jsx/treeshake option + if (subOptions[key] === true) { + subOptions[key] = {}; + } + subOptions = subOptions[key] ??= {}; + } + subOptions[valueKey] = value; + } + result.value = object; + }, + { flush: 'post' } + ); + return result; +} diff --git a/docs/repl/stores/rollup.ts b/docs/repl/stores/rollup.ts new file mode 100644 index 00000000000..fb2d84df2d7 --- /dev/null +++ b/docs/repl/stores/rollup.ts @@ -0,0 +1,141 @@ +import { defineStore } from 'pinia'; +import { ref } from 'vue'; +import type { RollupBuild, RollupOptions } from '../../../src/rollup/types'; +import type * as Rollup from '../helpers/importRollup'; +import { isRollupVersionAtLeast } from '../helpers/rollupVersion'; + +const ROLLUP_JS_FILE = 'rollup.browser.js'; +const ROLLUP_WASM_FILE = 'bindings_wasm_bg.wasm'; + +function isLoadLocalRollup({ type }: RollupRequest) { + return import.meta.env.DEV && type === 'local'; +} + +function getFullUrlFromUnpkg(version: string | undefined, file: string) { + return `https://unpkg.com/@rollup/browser${version ? `@${version}` : ''}/dist/${file}`; +} + +function getFullUrlFromAWS(version: string, file: string) { + return `https://rollup-ci-artefacts.s3.amazonaws.com/${version}/${file}`; +} + +function getRollupJsUrl({ type, version }: RollupRequest) { + if (type === 'pr') { + return getFullUrlFromAWS(version, ROLLUP_JS_FILE); + } else if (version) { + if (isRollupVersionAtLeast(version, 3, 0)) { + return getFullUrlFromUnpkg(version, ROLLUP_JS_FILE); + } + if (isRollupVersionAtLeast(version, 1, 0)) { + return `https://unpkg.com/rollup@${version}/dist/rollup.browser.js`; + } + throw new Error('The REPL only supports Rollup versions >= 1.0.0.'); + } + return getFullUrlFromUnpkg(undefined, ROLLUP_JS_FILE); +} + +function getRollupWasmFileUrl({ type, version }: RollupRequest) { + if (type === 'pr') { + return getFullUrlFromAWS(version, ROLLUP_WASM_FILE); + } else if (type === 'version') { + if (!version) { + return getFullUrlFromUnpkg(undefined, ROLLUP_WASM_FILE); + } else if (isRollupVersionAtLeast(version, 4, 0)) { + return getFullUrlFromUnpkg(version, ROLLUP_WASM_FILE); + } + } +} + +async function loadRollup(rollupRequest: RollupRequest): Promise { + if (isLoadLocalRollup(rollupRequest)) { + return import('../helpers/importRollup'); + } + const url = getRollupJsUrl(rollupRequest); + const rollupWasmFileUrl = getRollupWasmFileUrl(rollupRequest); + const preloadRollupWasmFile = rollupWasmFileUrl && fetch(rollupWasmFileUrl).catch(() => {}); + return new Promise((fulfil, reject) => { + const script = document.createElement('script'); + script.src = url; + script.addEventListener('load', async () => { + if (preloadRollupWasmFile) { + await preloadRollupWasmFile; + } + fulfil((window as any).rollup); + }); + script.addEventListener('error', () => { + reject( + new Error( + rollupRequest.type === 'pr' + ? `Could not load Rollup from PR #${rollupRequest.version}.` + : `Could not load Rollup from ${url}.` + ) + ); + }); + document.querySelector('head')!.append(script); + }); +} + +interface LoadedRollup { + error: false; + instance: { + VERSION: string; + rollup: (options: RollupOptions) => Promise; + }; +} + +export type RequestedRollupInstance = + | LoadedRollup + | { + [key in keyof LoadedRollup]: key extends 'error' ? false | Error : null; + }; + +type RollupRequest = + | { + type: 'version' | 'local'; + version: string | undefined; + } + | { type: 'pr'; version: string }; + +export const useRollup = defineStore('rollup', () => { + const loaded = ref({ + error: false, + instance: null + }); + const request = ref(null); + + async function requestRollup(rollupRequest: RollupRequest) { + try { + request.value = rollupRequest; + const instance = await loadRollup(rollupRequest); + if (isLoadLocalRollup(rollupRequest)) { + instance.onUpdate(newInstance => { + loaded.value = { error: false, instance: newInstance }; + }); + } + loaded.value = { + error: false, + instance + }; + } catch (error) { + console.error(error); + loaded.value = { + error: error as Error, + instance: null + }; + } + } + + function requestError(error: Error) { + loaded.value = { + error, + instance: null + }; + } + + return { + loaded, + request, + requestError, + requestRollup + }; +}); diff --git a/docs/repl/stores/rollupOutput.ts b/docs/repl/stores/rollupOutput.ts new file mode 100644 index 00000000000..88da2684ae5 --- /dev/null +++ b/docs/repl/stores/rollupOutput.ts @@ -0,0 +1,189 @@ +import { defineStore } from 'pinia'; +import { ref, watch } from 'vue'; +import type { + LogLevel, + OutputOptions, + RollupError, + RollupLog, + RollupOptions, + RollupOutput +} from '../../../src/rollup/types'; +import type { Module } from '../../types'; +import { getFileNameFromMessage } from '../helpers/messages'; +import { dirname, resolve } from '../helpers/path'; +import { useModules } from './modules'; +import { useOptions } from './options'; +import type { RequestedRollupInstance } from './rollup'; +import { useRollup } from './rollup'; + +interface GeneratedRollupOutput { + error: RollupError | null; + externalImports: string[]; + logs: [LogLevel, RollupLog][]; + output: RollupOutput['output'] | never[]; +} + +interface BundleRequest { + modules: Module[]; + options: OutputOptions; + rollup: RequestedRollupInstance; + setOutput(output: GeneratedRollupOutput): void; +} + +function logWarning(message: RollupLog) { + console.group(getFileNameFromMessage(message) || 'general error'); + console.warn(message.stack || message.message, { ...message }); + console.groupEnd(); +} + +function hashOptionsAndRollupVersion({ options, rollup: { instance } }: BundleRequest) { + return JSON.stringify({ o: options, v: instance?.VERSION }); +} + +const LEADING_SLASH_REGEX = /^[/\\]/; + +async function bundle({ rollup: { instance }, modules, options, setOutput }: BundleRequest) { + if (modules.length === 0 || !instance) { + return; + } + if (import.meta.env.PROD) { + console.clear(); + } + console.group(`running Rollup version ${instance.VERSION}`); + + const modulesById = new Map(); + for (const module of modules) { + modulesById.set(module.name, module); + } + + const logs: [LogLevel, RollupLog][] = []; + const externalImports = new Set(); + + const rollupOptions: RollupOptions = { + ...options, + input: modules.filter((module, index) => index === 0 || module.isEntry).map(({ name }) => name), + onLog(level, log) { + logs.push([level, log]); + }, + plugins: [ + { + buildStart() { + externalImports.clear(); + }, + load(id) { + return (modulesById.get(id) || modulesById.get(id.replace(LEADING_SLASH_REGEX, ''))) + ?.code; + }, + name: 'browser-resolve', + resolveId(importee, importer) { + if (!importer) { + return resolve('/', importee); + } + if (importee[0] !== '.') { + externalImports.add(importee); + return false; + } + + let resolved = resolve('/', dirname(importer), importee); + if (modulesById.has(resolved.replace(LEADING_SLASH_REGEX, ''))) return resolved; + + resolved += '.js'; + if (modulesById.has(resolved.replace(LEADING_SLASH_REGEX, ''))) return resolved; + + throw new Error(`Could not resolve '${importee}' from '${importer}'.`); + } + } + ] + }; + + console.log('%coptions:', 'font-weight: bold; color: blue', rollupOptions); + try { + const generated = await ( + await instance.rollup(rollupOptions) + ).generate((rollupOptions as { output?: OutputOptions }).output || {}); + console.log('%coutput:', 'font-weight: bold; color: green', generated.output); + setOutput({ + error: null, + externalImports: [...externalImports].sort((a, b) => (a < b ? -1 : 1)), + logs, + output: generated.output + }); + } catch (error) { + console.log( + '%cerror:', + 'font-weight: bold; color: red', + error, + JSON.parse(JSON.stringify(error)) + ); + setOutput({ error: error as Error, externalImports: [], logs, output: [] }); + logWarning(error as Error); + } + console.groupEnd(); +} + +export const useRollupOutput = defineStore('rollupOutput', () => { + const rollupStore = useRollup(); + const modulesStore = useModules(); + const optionsStore = useOptions(); + const output = ref({ + error: null, + externalImports: [], + logs: [], + output: [] + }); + let bundleDebounceTimeout: ReturnType | undefined; + let nextBundleRequest: BundleRequest | null = null; + let completedRequestHash = ''; + + // TODO instead of debouncing we should bundle in a worker + function requestBundle(bundleRequest: BundleRequest) { + // We are currently bundling, queue this request for when we are done + if (nextBundleRequest) { + nextBundleRequest = bundleRequest; + return; + } + // Otherwise, restart the debounce-timeout + clearTimeout(bundleDebounceTimeout); + if (bundleRequest.rollup.error) { + bundleRequest.setOutput({ + error: bundleRequest.rollup.error, + externalImports: [], + logs: [], + output: [] + }); + return; + } + if (!bundleRequest.rollup.instance) { + return; + } + bundleDebounceTimeout = setTimeout( + async () => { + nextBundleRequest = bundleRequest; + await bundle(bundleRequest); + completedRequestHash = hashOptionsAndRollupVersion(bundleRequest); + const currentBundleRequest = nextBundleRequest; + nextBundleRequest = null; + if (currentBundleRequest !== bundleRequest) { + requestBundle(currentBundleRequest); + } + }, + // Do not debounce on Rollup version or options change + completedRequestHash === hashOptionsAndRollupVersion(bundleRequest) ? 100 : 0 + ); + } + + watch( + [() => rollupStore.loaded, () => modulesStore.modules, () => optionsStore.optionsObject as any], + ([rollup, modules, options]) => + requestBundle({ + modules, + options, + rollup, + setOutput(value: GeneratedRollupOutput) { + output.value = value; + } + }), + { deep: true } + ); + return { output }; +}); diff --git a/docs/tools/index.md b/docs/tools/index.md new file mode 100755 index 00000000000..bb01487dde5 --- /dev/null +++ b/docs/tools/index.md @@ -0,0 +1,282 @@ +--- +title: Integrating Rollup With Other Tools +--- + +# {{ $frontmatter.title }} + +[[toc]] + +## With NPM Packages + +At some point, it's likely that your project will depend on packages installed from NPM into your `node_modules` folder. Unlike other bundlers such as Webpack and Browserify, Rollup doesn't know "out of the box" how to handle these dependencies - we need to add some configuration. + +Let's add a simple dependency called [the-answer](https://www.npmjs.com/package/the-answer), which exports the answer to the question of life, the universe and everything: + +```shell +npm install the-answer +# or `npm i the-answer` +``` + +If we update our `src/main.js` file… + +```js +// src/main.js +import answer from 'the-answer'; + +export default function () { + console.log('the answer is ' + answer); +} +``` + +…and run Rollup… + +```shell +npm run build +``` + +…we'll see a warning like this: + +``` +(!) Unresolved dependencies +https://github.com/rollup/rollup/wiki/Troubleshooting#treating-module-as-external-dependency +the-answer (imported by main.js) +``` + +The resulting `bundle.js` will still work in Node.js, because the `import` declaration gets turned into a CommonJS `require` statement, but `the-answer` does _not_ get included in the bundle. For that, we need a plugin. + +### @rollup/plugin-node-resolve + +The [@rollup/plugin-node-resolve](https://github.com/rollup/plugins/tree/master/packages/node-resolve) plugin teaches Rollup how to find external modules. Install it… + +```shell +npm install --save-dev @rollup/plugin-node-resolve +``` + +…and add it to your config file: + +```js twoslash +// rollup.config.js +import resolve from '@rollup/plugin-node-resolve'; + +// ---cut-start--- +/** @type {import('rollup').RollupOptions} */ +// ---cut-end--- +export default { + input: 'src/main.js', + output: { + file: 'bundle.js', + format: 'cjs' + }, + plugins: [resolve()] +}; +``` + +This time, when you `npm run build`, no warning is emitted — the bundle contains the imported module. + +### @rollup/plugin-commonjs + +Some libraries expose ES modules that you can import as-is — `the-answer` is one such module. But at the moment, the majority of packages on NPM are exposed as CommonJS modules instead. Until that changes, we need to convert CommonJS to ES2015 before Rollup can process them. + +The [@rollup/plugin-commonjs](https://github.com/rollup/plugins/tree/master/packages/commonjs) plugin does exactly that. + +Note that most of the time `@rollup/plugin-commonjs` should go _before_ other plugins that transform your modules — this is to prevent other plugins from making changes that break the CommonJS detection. An exception for this rule is the Babel plugin, if you're using it then place it before the commonjs one. + +## Peer dependencies + +Let's say that you're building a library that has a peer dependency, such as React or Lodash. If you set up externals as described above, your rollup will bundle _all_ imports: + +```js +import answer from 'the-answer'; +import _ from 'lodash'; +``` + +You can finely tune which imports are bundled and which are treated as external. For this example, we'll treat `lodash` as external, but not `the-answer`. + +Here is the config file: + +```js twoslash +// rollup.config.js +import resolve from '@rollup/plugin-node-resolve'; + +// ---cut-start--- +/** @type {import('rollup').RollupOptions} */ +// ---cut-end--- +export default { + input: 'src/main.js', + output: { + file: 'bundle.js', + format: 'cjs' + }, + plugins: [ + resolve({ + // pass custom options to the resolve plugin + moduleDirectories: ['node_modules'] + }) + ], + // indicate which modules should be treated as external + external: ['lodash'] +}; +``` + +Voilà, `lodash` will now be treated as external, and not be bundled with your library. + +The `external` key accepts either an array of module names, or a function which takes the module name and returns true if it should be treated as external. For example: + +```js twoslash +// ---cut-start--- +/** @type {import('rollup').RollupOptions} */ +// ---cut-end--- +export default { + // ... + external: id => /lodash/.test(id) +}; +``` + +You might use this form if you're using [babel-plugin-lodash](https://github.com/lodash/babel-plugin-lodash) to cherry-pick `lodash` modules. In this case, Babel will convert your import statements to look like this: + +```js +import _merge from 'lodash/merge'; +``` + +The array form of `external` does not handle wildcards, so this import will only be treated as external in the functional form. + +## Babel + +Many developers use [Babel](https://babeljs.io/) in their projects in order to use the latest JavaScript features that aren't yet supported by browsers and Node.js. + +The easiest way to use both Babel and Rollup is with [@rollup/plugin-babel](https://github.com/rollup/plugins/tree/master/packages/babel). First, install the plugin: + +```shell +npm i -D @rollup/plugin-babel @rollup/plugin-node-resolve +``` + +Add it to `rollup.config.js`: + +```js twoslash +// rollup.config.js +import resolve from '@rollup/plugin-node-resolve'; +import babel from '@rollup/plugin-babel'; + +// ---cut-start--- +/** @type {import('rollup').RollupOptions} */ +// ---cut-end--- +export default { + input: 'src/main.js', + output: { + file: 'bundle.js', + format: 'cjs' + }, + plugins: [resolve(), babel({ babelHelpers: 'bundled' })] +}; +``` + +Before Babel will actually compile your code, it needs to be configured. Create a new file, `src/.babelrc.json`: + +```json +{ + "presets": ["@babel/env"] +} +``` + +We're putting our `.babelrc.json` file in `src`, rather than the project root. This allows us to have a different `.babelrc.json` for things like tests, if we need that later – See the [Babel documentation](https://babeljs.io/docs/en/config-files#project-wide-configuration) for more information on both project wide and file relative configuration. + +Now, before we run rollup, we need to install [`babel-core`](https://babeljs.io/docs/en/babel-core) and the [`env`](https://babeljs.io/docs/en/babel-preset-env) preset: + +```shell +npm i -D @babel/core @babel/preset-env +``` + +Running Rollup now will create a bundle - except we're not actually using any ES2015 features. Let's change that by editing `src/main.js`: + +```js +// src/main.js +import answer from 'the-answer'; + +export default () => { + console.log(`the answer is ${answer}`); +}; +``` + +Run Rollup with `npm run build`, and check the bundle: + +```js +'use strict'; + +var index = 42; + +var main = function () { + console.log('the answer is ' + index); +}; + +module.exports = main; +``` + +## Gulp + +Rollup returns Promises which are understood by gulp so integration is relatively painless. + +The syntax is very similar to the configuration file, but the properties are split across two different operations corresponding to the [JavaScript API](../javascript-api/index.md): + +```js twoslash +const gulp = require('gulp'); +const rollup = require('rollup'); +const rollupTypescript = require('@rollup/plugin-typescript'); + +gulp.task('build', () => { + return rollup + .rollup({ + input: './src/main.ts', + plugins: [rollupTypescript()] + }) + .then(bundle => { + return bundle.write({ + file: './dist/library.js', + format: 'umd', + name: 'library', + sourcemap: true + }); + }); +}); +``` + +You may also use the `async/await` syntax: + +```js twoslash +const gulp = require('gulp'); +const rollup = require('rollup'); +const rollupTypescript = require('@rollup/plugin-typescript'); + +gulp.task('build', async function () { + const bundle = await rollup.rollup({ + input: './src/main.ts', + plugins: [rollupTypescript()] + }); + + await bundle.write({ + file: './dist/library.js', + format: 'umd', + name: 'library', + sourcemap: true + }); +}); +``` + +## Deno + +If you like to run Rollup in Deno you can use [esm.sh](https://esm.sh/) like so: + +```js +import { rollup } from "https://esm.sh/@rollup/browser"; + +const bundle = await rollup({ //... +``` + +But it is not suitable for complex compiling. Alternatively you can install rollup from npm: + +```js +import { rollup } from "npm:rollup"; + +const bundle = await rollup({ //... +``` + +Notice: Deno will request some permissions when running Rollup. diff --git a/docs/troubleshooting/index.md b/docs/troubleshooting/index.md new file mode 100644 index 00000000000..fbadba6a4ed --- /dev/null +++ b/docs/troubleshooting/index.md @@ -0,0 +1,131 @@ +--- +title: Troubleshooting +--- + +# {{ $frontmatter.title }} + +[[toc]] + +If you get stuck, please try discussing the issue on the [Rollup Discord](https://is.gd/rollup_chat) or posting a question to [Stackoverflow](https://stackoverflow.com/questions/tagged/rollupjs). If you've found a bug, or Rollup can't meet your needs, please try [raising an issue](https://github.com/rollup/rollup/issues). Lastly, you may try contacting [@RollupJS](https://twitter.com/RollupJS) on Twitter. + +## Avoiding `eval` + +You probably already know that '`eval` is evil', at least according to some people. But it's particularly harmful with Rollup, because of how it works – unlike other module bundlers, which wrap each module in a function, Rollup puts all your code in the same scope. + +That's more efficient, but it means that the shared scope is 'polluted' whenever you use `eval`, whereas with a different bundler, modules that _didn't_ use eval would not be polluted. A minifier can't mangle variable names in polluted code, because it can't guarantee that the code to be evaluated doesn't reference those variable names. + +Furthermore, **it poses a security risk** in that a malicious module could access another module's private variables with `eval('SUPER_SEKRIT')`. + +Luckily, unless you _really do_ intend for the evaluated code to have access to local variables (in which case you're probably doing something wrong!), you can achieve the same effect in one of two ways: + +### eval2 = eval + +Simply 'copying' `eval` provides you with a function that does exactly the same thing, but which runs in the global scope rather than the local one: + +```js +var eval2 = eval; + +(function () { + var foo = 42; + eval('console.log("with eval:",foo)'); // logs 'with eval: 42' + eval2('console.log("with eval2:",foo)'); // throws ReferenceError +})(); +``` + +### `new Function` + +Using the [Function constructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function) generates a function from the supplied string. Again, it runs in the global scope. If you need to call the function repeatedly, this is much, _much_ faster than using `eval`. + +## Tree-shaking doesn't seem to be working + +Sometimes, you'll end up with code in your bundle that doesn't seem like it should be there. For example, if you import a utility from `lodash-es`, you might expect that you'll get the bare minimum of code necessary for that utility to work. + +But Rollup has to be conservative about what code it removes in order to guarantee that the end result will run correctly. If an imported module appears to have _side effects_, either on bits of the module that you're using or on the global environment, Rollup plays it safe and includes those side effects. + +Because static analysis in a dynamic language like JavaScript is hard, there will occasionally be false positives. Lodash is a good example of a module that _looks_ like it has lots of side effects, even in places that it doesn't. You can often mitigate those false positives by importing submodules (e.g. `import map from 'lodash-es/map'` rather than `import { map } from 'lodash-es'`). + +Rollup's static analysis will improve over time, but it will never be perfect in all cases – that's just JavaScript. + +## Error: "[name] is not exported by [module]" + +Occasionally you will see an error message like this: + +> 'foo' is not exported by bar.js (imported by baz.js) + +Import declarations must have corresponding export declarations in the imported module. For example, if you have `import a from './a.js'` in a module, and a.js doesn't have an `export default` declaration, or `import {foo} from './b.js'`, and b.js doesn't export `foo`, Rollup cannot bundle the code. + +This error frequently occurs with CommonJS modules converted by [rollup-plugin-commonjs](https://github.com/rollup/rollup-plugin-commonjs), this package has been deprecated and is no longer maintained. Please use [@rollup/plugin-commonjs](https://github.com/rollup/plugins/tree/master/packages/commonjs#custom-named-exports). + +## Error: "this is undefined" + +In a JavaScript module, `this` is `undefined` at the top level (i.e., outside functions). Because of that, Rollup will rewrite any `this` references to `undefined` so that the resulting behaviour matches what will happen when modules are natively supported. + +There are occasional valid reasons for `this` to mean something else. If you're getting errors in your bundle, you can use `options.context` and `options.moduleContext` to change this behaviour. + +## Warning: "Sourcemap is likely to be incorrect" + +You'll see this warning if you generate a sourcemap with your bundle (`sourcemap: true` or `sourcemap: 'inline'`) but you're using one or more plugins that transformed code without generating a sourcemap for the transformation. + +Usually, a plugin will only omit the sourcemap if it (the plugin, not the bundle) was configured with `sourcemap: false` – so all you need to do is change that. If the plugin doesn't generate a sourcemap, consider raising an issue with the plugin author. + +## Warning: "Treating [module] as external dependency" + +Rollup will only resolve _relative_ module IDs by default. This means that an import statement like this… + +```js +import moment from 'moment'; +``` + +…won't result in `moment` being included in your bundle – instead, it will be an external dependency that is required at runtime. If that's what you want, you can suppress this warning with the `external` option, which makes your intentions explicit: + +```js twoslash +// rollup.config.js +// ---cut-start--- +/** @type {import('rollup').RollupOptions} */ +// ---cut-end--- +export default { + entry: 'src/index.js', + dest: 'bundle.js', + format: 'cjs', + external: ['moment'] // <-- suppresses the warning +}; +``` + +If you _do_ want to include the module in your bundle, you need to tell Rollup how to find it. In most cases, this is a question of using [@rollup/plugin-node-resolve](https://github.com/rollup/plugins/tree/master/packages/node-resolve). + +Some modules, like `events` or `util`, are built in to Node.js. If you want to include those (for example, so that your bundle runs in the browser), you may need to include [rollup-plugin-polyfill-node](https://github.com/FredKSchott/rollup-plugin-polyfill-node). + +## Error: "EMFILE: too many open files" + +For large projects, you may run into an EMFILE error when running Rollup in watch mode on macOS. If you experience this, disabling FSEvents may eliminate the problem: + +```js twoslash +// rollup.config.js +// ---cut-start--- +/** @type {import('rollup').RollupOptions} */ +// ---cut-end--- +export default { + /* ..., */ + watch: { + chokidar: { + useFsEvents: false + } + } +}; +``` + +## Error: JavaScript heap out of memory + +As Rollup needs to keep all module information in memory simultaneously to be able to analyze relevant side effects for tree-shaking, it is possible that bundling large projects reaches Node's memory limit. If this happens, it can help to increase this limit by running Rollup via + +```shell +node --max-old-space-size=8192 node_modules/rollup/dist/bin/rollup -c +``` + +increasing `--max-old-space-size` as needed. Note that this number can safely surpass your available physical memory. In that case, Node will start paging memory to disk as needed. + +You may reduce memory pressure by introducing code splitting by using dynamic imports, importing just specific modules rather than whole dependencies, disabling sourcemaps, or increasing the size of your swap space. + +## Error: Node tried to load your configuration file as CommonJS even though it is likely an ES module + +By default, Rollup will use Node's native module mechanism to load your Rollup configuration. That means if you use ES imports and exports in your configuration, you either need to define `"type": "module"` in your `package.json` file or use the `.mjs` extension for your configuration. See also [Configuration Files](../command-line-interface/index.md#configuration-files) and [Caveats when using native Node ES modules](../command-line-interface/index.md#caveats-when-using-native-node-es-modules) for more information. diff --git a/docs/tsconfig.json b/docs/tsconfig.json new file mode 100644 index 00000000000..0013bd95bde --- /dev/null +++ b/docs/tsconfig.json @@ -0,0 +1,41 @@ +{ + "compilerOptions": { + "allowUnreachableCode": false, + "allowUnusedLabels": false, + "baseUrl": "./", + "esModuleInterop": true, + "forceConsistentCasingInFileNames": true, + "isolatedModules": true, + "jsx": "preserve", + "lib": [ + "ESNext", + "DOM" + ], + "module": "ESNext", + "moduleResolution": "Bundler", + "noEmit": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "resolveJsonModule": true, + "strict": true, + "target": "ESNext", + "types": [ + "vite/client", + "node" + ], + "useDefineForClassFields": false + }, + "include": [ + "**/*", + ".vitepress/**/*", + "types", + "../src", + "../typings" + ], + "exclude": [ + "**/node_modules/**", + "**/dist/**", + ".vitepress/cache/**", + ".vitepress/dist/**/*" + ] +} diff --git a/docs/tutorial/index.md b/docs/tutorial/index.md new file mode 100755 index 00000000000..987b32f2fa1 --- /dev/null +++ b/docs/tutorial/index.md @@ -0,0 +1,441 @@ +--- +title: Tutorial +--- + +# {{ $frontmatter.title }} + +[[toc]] + +## Creating Your First Bundle + +_Before we begin, you'll need to have [Node.js](https://nodejs.org) installed so that you can use [NPM](https://npmjs.com). You'll also need to know how to access the [command line](https://www.codecademy.com/learn/learn-the-command-line) on your machine._ + +The easiest way to use Rollup is via the Command Line Interface (or CLI). For now, we'll install it globally (later on we'll learn how to install it locally to your project so that your build process is portable, but don't worry about that yet). Type this into the command line: + +```shell +npm install rollup --global +# or `npm i rollup -g` for short +``` + +You can now run the `rollup` command. Try it! + +```shell +rollup +``` + +Because no arguments were passed, Rollup prints usage instructions. This is the same as running `rollup --help`, or `rollup -h`. + +Let's create a simple project: + +```shell +mkdir -p my-rollup-project/src +cd my-rollup-project +``` + +First, we need an _entry point_. Paste this into a new file called `src/main.js`: + +```js +// src/main.js +import foo from './foo.js'; +export default function () { + console.log(foo); +} +``` + +Then, let's create the `foo.js` module that our entry point imports: + +```js +// src/foo.js +export default 'hello world!'; +``` + +Now we're ready to create a bundle: + +```shell +rollup src/main.js -f cjs +``` + +The `-f` option (short for `--format`) specifies what kind of bundle we're creating — in this case, CommonJS (which will run in Node.js). Because we didn't specify an output file, it will be printed straight to `stdout`: + +```js +'use strict'; + +const foo = 'hello world!'; + +const main = function () { + console.log(foo); +}; + +module.exports = main; +``` + +You can save the bundle as a file like so: + +```shell +rollup src/main.js -o bundle.js -f cjs +``` + +(You could also do `rollup src/main.js -f cjs > bundle.js`, but as we'll see later, this is less flexible if you're generating sourcemaps.) + +Try running the code: + +``` +node +> var myBundle = require('./bundle.js'); +> myBundle(); +'hello world!' +``` + +Congratulations! You've created your first bundle with Rollup. + +## Using Config Files + +So far, so good, but as we start adding more options it becomes a bit of a nuisance to type out the command. + +To save repeating ourselves, we can create a config file containing all the options we need. A config file is written in JavaScript and is more flexible than the raw CLI. + +Create a file in the project root called `rollup.config.mjs`, and add the following code: + +```js twoslash +// rollup.config.mjs +// ---cut-start--- +/** @type {import('rollup').RollupOptions} */ +// ---cut-end--- +export default { + input: 'src/main.js', + output: { + file: 'bundle.js', + format: 'cjs' + } +}; +``` + +(Note that you can use CJS modules and therefore `module.exports = {/* config */}`) + +To use the config file, we use the `--config` or `-c` flag: + +```shell +rm bundle.js # so we can check the command works! +rollup -c +``` + +You can override any of the options in the config file with the equivalent command line options: + +```shell +rollup -c -o bundle-2.js # `-o` is equivalent to `--file` (formerly "output") +``` + +_Note: Rollup itself processes the config file, which is why we're able to use `export default` syntax – the code isn't being transpiled with Babel or anything similar, so you can only use ES2015 features that are supported in the version of Node.js that you're running._ + +You can, if you like, specify a different config file from the default `rollup.config.mjs`: + +```shell +rollup --config rollup.config.dev.mjs +rollup --config rollup.config.prod.mjs +``` + +## Installing Rollup locally + +When working within teams or distributed environments it can be wise to add Rollup as a _local_ dependency. Installing Rollup locally prevents the requirement that multiple contributors install Rollup separately as an extra step, and ensures that all contributors are using the same version of Rollup. + +To install Rollup locally with NPM: + +```shell +npm install rollup --save-dev +``` + +Or with Yarn: + +```shell +yarn -D add rollup +``` + +After installing, Rollup can be run within the root directory of your project: + +```shell +npx rollup --config +``` + +Or with Yarn: + +```shell +yarn rollup --config +``` + +Once installed, it's common practice to add a single build script to `package.json`, providing a convenient command for all contributors. e.g. + +```json +{ + "scripts": { + "build": "rollup --config" + } +} +``` + +_Note: Once installed locally, both NPM and Yarn will resolve the dependency's bin file and execute Rollup when called from a package script._ + +## Using plugins + +So far, we've created a simple bundle from an entry point and a module imported via a relative path. As you build more complex bundles, you'll often need more flexibility – importing modules installed with NPM, compiling code with Babel, working with JSON files and so on. + +For that, we use _plugins_, which change the behaviour of Rollup at key points in the bundling process. A list of awesome plugins is maintained on [the Rollup Awesome List](https://github.com/rollup/awesome). + +For this tutorial, we'll use [@rollup/plugin-json](https://github.com/rollup/plugins/tree/master/packages/json), which allows Rollup to import data from a JSON file. + +Create a file in the project root called `package.json`, and add the following content: + +```json +{ + "name": "rollup-tutorial", + "version": "1.0.0", + "scripts": { + "build": "rollup -c" + } +} +``` + +Install @rollup/plugin-json as a development dependency: + +```shell +npm install --save-dev @rollup/plugin-json +``` + +(We're using `--save-dev` rather than `--save` because our code doesn't actually depend on the plugin when it runs – only when we're building the bundle.) + +Update your `src/main.js` file so that it imports from your package.json instead of `src/foo.js`: + +```js +// src/main.js +import { version } from '../package.json'; + +export default function () { + console.log('version ' + version); +} +``` + +Edit your `rollup.config.mjs` file to include the JSON plugin: + +```js twoslash +// rollup.config.mjs +import json from '@rollup/plugin-json'; + +// ---cut-start--- +/** @type {import('rollup').RollupOptions} */ +// ---cut-end--- +export default { + input: 'src/main.js', + output: { + file: 'bundle.js', + format: 'cjs' + }, + plugins: [json()] +}; +``` + +Run Rollup with `npm run build`. The result should look like this: + +```js +'use strict'; + +var version = '1.0.0'; + +function main() { + console.log('version ' + version); +} + +module.exports = main; +``` + +_Note: Only the data we actually need gets imported – `name` and `devDependencies` and other parts of `package.json` are ignored. That's **tree-shaking** in action._ + +## Using output plugins + +Some plugins can also be applied specifically to some outputs. See [plugin hooks](../plugin-development/index.md#build-hooks) for the technical details of what output-specific plugins can do. In a nut-shell, those plugins can only modify code after the main analysis of Rollup has completed. Rollup will warn if an incompatible plugin is used as an output-specific plugin. One possible use-case is minification of bundles to be consumed in a browser. + +Let us extend the previous example to provide a minified build together with the non-minified one. To that end, we install `@rollup/plugin-terser`: + +```shell +npm install --save-dev @rollup/plugin-terser +``` + +Edit your `rollup.config.mjs` file to add a second minified output. As format, we choose `iife`. This format wraps the code so that it can be consumed via a `script` tag in the browser while avoiding unwanted interactions with other code. As we have an export, we need to provide the name of a global variable that will be created by our bundle so that other code can access our export via this variable. + +```js twoslash +// rollup.config.mjs +import json from '@rollup/plugin-json'; +import terser from '@rollup/plugin-terser'; + +// ---cut-start--- +/** @type {import('rollup').RollupOptions} */ +// ---cut-end--- +export default { + input: 'src/main.js', + output: [ + { + file: 'bundle.js', + format: 'cjs' + }, + { + file: 'bundle.min.js', + format: 'iife', + name: 'version', + plugins: [terser()] + } + ], + plugins: [json()] +}; +``` + +Besides `bundle.js`, Rollup will now create a second file `bundle.min.js`: + +```js +var version = (function () { + 'use strict'; + var n = '1.0.0'; + return function () { + console.log('version ' + n); + }; +})(); +``` + +## Code Splitting + +For code splitting, there are cases where Rollup splits code into chunks automatically, like dynamic loading or multiple entry points, and there is a way to explicitly tell Rollup which modules to split into separate chunks via the [`output.manualChunks`](../configuration-options/index.md#output-manualchunks) option. + +To use the code splitting feature to achieve the lazy dynamic loading (where some imported module(s) is only loaded after executing a function), we go back to the original example and modify `src/main.js` to load `src/foo.js` dynamically instead of statically: + +```js +// src/main.js +export default function () { + import('./foo.js').then(({ default: foo }) => console.log(foo)); +} +``` + +Rollup will use the dynamic import to create a separate chunk that is only loaded on demand. In order for Rollup to know where to place the second chunk, instead of passing the `--file` option we set a folder to output to with the `--dir` option: + +```shell +rollup src/main.js -f cjs -d dist +``` + +This will create a folder `dist` containing two files, `main.js` and `chunk-[hash].js`, where `[hash]` is a content based hash string. You can supply your own naming patterns by specifying the [`output.chunkFileNames`](../configuration-options/index.md#output-chunkfilenames) and [`output.entryFileNames`](../configuration-options/index.md#output-entryfilenames) options. + +You can still run your code as before with the same output, albeit a little slower as loading and parsing of `./foo.js` will only commence once we call the exported function for the first time. + +```shell +node -e "require('./dist/main.js')()" +``` + +If we do not use the `--dir` option, Rollup will again print the chunks to `stdout`, adding comments to highlight the chunk boundaries: + +```js +//→ main.js: +'use strict'; + +function main() { + Promise.resolve(require('./chunk-b8774ea3.js')).then(({ default: foo }) => + console.log(foo) + ); +} + +module.exports = main; + +//→ chunk-b8774ea3.js: +('use strict'); + +var foo = 'hello world!'; + +exports.default = foo; +``` + +This is useful if you want to load and parse expensive features only once they are used. + +A different use for code-splitting is the ability to specify several entry points that share some dependencies. Again we extend our example to add a second entry point `src/main2.js` that statically imports `src/foo.js` just like we did in the original example: + +```js +// src/main2.js +import foo from './foo.js'; +export default function () { + console.log(foo); +} +``` + +If we supply both entry points to rollup, three chunks are created: + +```shell +rollup src/main.js src/main2.js -f cjs +``` + +will output + +```js +//→ main.js: +'use strict'; + +function main() { + Promise.resolve(require('./chunk-b8774ea3.js')).then(({ default: foo }) => + console.log(foo) + ); +} + +module.exports = main; + +//→ main2.js: +('use strict'); + +var foo_js = require('./chunk-b8774ea3.js'); + +function main2() { + console.log(foo_js.default); +} + +module.exports = main2; + +//→ chunk-b8774ea3.js: +('use strict'); + +var foo = 'hello world!'; + +exports.default = foo; +``` + +Notice how both entry points import the same shared chunk. Rollup will never duplicate code and instead create additional chunks to only ever load the bare minimum necessary. Again, passing the `--dir` option will write the files to disk. + +You can build the same code for the browser via native ES modules, an AMD loader or SystemJS. + +For example, with `-f es` for native modules: + +```shell +rollup src/main.js src/main2.js -f es -d dist +``` + +```html + + +``` + +Or alternatively, for SystemJS with `-f system`: + +```shell +rollup src/main.js src/main2.js -f system -d dist +``` + +Install SystemJS via + +```shell +npm install --save-dev systemjs +``` + +And then load either or both entry points in an HTML page as needed: + +```html + + + +``` + +See [rollup-starter-code-splitting](https://github.com/rollup/rollup-starter-code-splitting) for an example on how to set up a web app that uses native ES modules on browsers that support them with a fallback to SystemJS if necessary. diff --git a/docs/types.d.ts b/docs/types.d.ts new file mode 100644 index 00000000000..e64df0b5dbf --- /dev/null +++ b/docs/types.d.ts @@ -0,0 +1,14 @@ +import type { RollupOptions } from '../src/rollup/types'; + +export interface Module { + code: string; + isEntry: boolean; + name: string; +} + +export interface Example { + id: string; + modules: Module[]; + options: RollupOptions; + title: string; +} diff --git a/eslint.config.mjs b/eslint.config.mjs new file mode 100644 index 00000000000..4ae84cccb75 --- /dev/null +++ b/eslint.config.mjs @@ -0,0 +1,191 @@ +import eslint from '@eslint/js'; +import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended'; +import eslintPluginUnicorn from 'eslint-plugin-unicorn'; +import pluginVue from 'eslint-plugin-vue'; +import globals from 'globals'; +import tseslint from 'typescript-eslint'; + +export default tseslint.config( + eslint.configs.recommended, + ...tseslint.configs.strict, + ...tseslint.configs.stylistic, + ...pluginVue.configs['flat/recommended'], + { + ignores: [ + '**/node_modules', + '**/dist', + '**/perf', + '**/tmp', + '**/coverage', + '**/_tmp', + '**/cache', + '**/native.d.ts', + 'rust', + 'test/*/samples/**/*.*', + '!test/*/samples/**/_config.js', + '!test/*/samples/**/rollup.config.js', + '!**/.vitepress', + 'wasm/', + 'wasm-node/' + ] + }, + { + languageOptions: { + globals: { + ...globals.browser, + ...globals.node + } + }, + plugins: { + unicorn: eslintPluginUnicorn + }, + rules: { + '@typescript-eslint/consistent-type-assertions': [ + 'error', + { + assertionStyle: 'as', + objectLiteralTypeAssertions: 'allow' + } + ], + '@typescript-eslint/consistent-type-definitions': ['error', 'interface'], + '@typescript-eslint/consistent-type-imports': 'error', + '@typescript-eslint/member-ordering': [ + 'error', + { + default: { + memberTypes: [], + order: 'alphabetically' + } + } + ], + '@typescript-eslint/no-dynamic-delete': 'off', + '@typescript-eslint/no-empty-function': 'off', + '@typescript-eslint/no-explicit-any': 'off', + '@typescript-eslint/no-invalid-void-type': 'off', + '@typescript-eslint/no-non-null-assertion': 'off', + '@typescript-eslint/no-unused-vars': [ + 'error', + { + argsIgnorePattern: '^_', + ignoreRestSiblings: true, + varsIgnorePattern: '^_' + } + ], + '@typescript-eslint/prefer-for-of': 'off', + '@typescript-eslint/prefer-literal-enum-member': 'off', + 'dot-notation': 'error', + 'no-constant-condition': [ + 'error', + { + checkLoops: false + } + ], + 'no-prototype-builtins': 'off', + 'object-shorthand': 'error', + 'prefer-const': [ + 'error', + { + destructuring: 'all' + } + ], + 'prefer-object-spread': 'error', + 'sort-imports': [ + 'error', + { + ignoreCase: true, + ignoreDeclarationSort: true, + ignoreMemberSort: false + } + ], + 'sort-keys': [ + 'error', + 'asc', + { + caseSensitive: false + } + ], + 'unicorn/consistent-destructuring': 'off', + 'unicorn/filename-case': 'off', + 'unicorn/no-array-callback-reference': 'off', + 'unicorn/no-array-reduce': 'off', + 'unicorn/no-await-expression-member': 'off', + 'unicorn/no-empty-file': 'off', + 'unicorn/no-for-loop': 'off', + 'unicorn/no-nested-ternary': 'off', + 'unicorn/no-null': 'off', + 'unicorn/no-this-assignment': 'off', + 'unicorn/no-useless-undefined': 'off', + 'unicorn/number-literal-case': 'off', + 'unicorn/prefer-at': 'off', + 'unicorn/prefer-code-point': 'off', + 'unicorn/prefer-math-trunc': 'off', + 'unicorn/prefer-number-properties': 'off', + 'unicorn/prefer-string-raw': 'off', + 'unicorn/prefer-string-replace-all': 'off', + 'unicorn/prefer-structured-clone': 'off', + 'unicorn/prefer-top-level-await': 'off', + 'unicorn/prevent-abbreviations': [ + 'error', + { + replacements: { + dir: false + } + } + ] + } + }, + { + files: ['**/*.js'], + rules: { + '@typescript-eslint/explicit-module-boundary-types': 'off', + '@typescript-eslint/no-require-imports': 'off', + 'unicorn/no-process-exit': 'off', + 'unicorn/prefer-module': 'off' + } + }, + { + files: ['./*.ts', 'cli/**/*.ts'], + rules: { + 'unicorn/no-process-exit': 'off' + } + }, + { + files: ['**/*.js', 'cli/**/*.ts'], + rules: { + '@typescript-eslint/no-var-requires': 'off' + } + }, + { + files: ['test/**/*.js'], + languageOptions: { + globals: { + ...globals.mocha + } + }, + rules: { + 'sort-keys': 'off' + } + }, + { + files: ['docs/repl/examples/**/*.js'], + rules: { + 'no-undef': 'off', + 'unicorn/prevent-abbreviations': 'off' + } + }, + { + files: ['test/**/_config.js'], + rules: { + 'no-undef': 'off' + } + }, + { + files: ['*.vue', '**/*.vue'], + languageOptions: { + parserOptions: { + parser: '@typescript-eslint/parser' + } + } + }, + eslintPluginPrettierRecommended +); diff --git a/native.d.ts b/native.d.ts new file mode 100644 index 00000000000..3bf4896c396 --- /dev/null +++ b/native.d.ts @@ -0,0 +1,11 @@ +/* auto-generated by NAPI-RS */ +/* eslint-disable */ +export declare function parse(code: string, allowReturnOutsideFunction: boolean, jsx: boolean): Buffer + +export declare function parseAsync(code: string, allowReturnOutsideFunction: boolean, jsx: boolean, signal?: AbortSignal | undefined | null): Promise + +export declare function xxhashBase16(input: Uint8Array): string + +export declare function xxhashBase36(input: Uint8Array): string + +export declare function xxhashBase64Url(input: Uint8Array): string diff --git a/native.js b/native.js new file mode 100644 index 00000000000..e498482457a --- /dev/null +++ b/native.js @@ -0,0 +1,132 @@ +const { existsSync } = require('node:fs'); +const path = require('node:path'); +const { platform, arch, report } = require('node:process'); + +const isMusl = () => { + try { + return !report.getReport().header.glibcVersionRuntime; + } catch { + return false; + } +}; + +const isMingw32 = () => { + try { + return report.getReport().header.osName.startsWith('MINGW32_NT'); + } catch { + return false; + } +}; + +const bindingsByPlatformAndArch = { + android: { + arm: { base: 'android-arm-eabi' }, + arm64: { base: 'android-arm64' } + }, + darwin: { + arm64: { base: 'darwin-arm64' }, + x64: { base: 'darwin-x64' } + }, + freebsd: { + arm64: { base: 'freebsd-arm64' }, + x64: { base: 'freebsd-x64' } + }, + linux: { + arm: { base: 'linux-arm-gnueabihf', musl: 'linux-arm-musleabihf' }, + arm64: { base: 'linux-arm64-gnu', musl: 'linux-arm64-musl' }, + loong64: { base: 'linux-loong64-gnu', musl: 'linux-loong64-musl' }, + ppc64: { base: 'linux-ppc64-gnu', musl: 'linux-ppc64-musl' }, + riscv64: { base: 'linux-riscv64-gnu', musl: 'linux-riscv64-musl' }, + s390x: { base: 'linux-s390x-gnu', musl: null }, + x64: { base: 'linux-x64-gnu', musl: 'linux-x64-musl' } + }, + openbsd: { + x64: { base: 'openbsd-x64' } + }, + openharmony: { + arm64: { base: 'openharmony-arm64' } + }, + win32: { + arm64: { base: 'win32-arm64-msvc' }, + ia32: { base: 'win32-ia32-msvc' }, + x64: { + base: isMingw32() ? 'win32-x64-gnu' : 'win32-x64-msvc' + } + } +}; + +const msvcLinkFilenameByArch = { + arm64: 'vc_redist.arm64.exe', + ia32: 'vc_redist.x86.exe', + x64: 'vc_redist.x64.exe' +}; + +const packageBase = getPackageBase(); +const localName = `./rollup.${packageBase}.node`; +const requireWithFriendlyError = id => { + try { + return require(id); + } catch (error) { + if ( + platform === 'win32' && + error instanceof Error && + error.code === 'ERR_DLOPEN_FAILED' && + error.message.includes('The specified module could not be found') + ) { + const msvcDownloadLink = `https://aka.ms/vs/17/release/${msvcLinkFilenameByArch[arch]}`; + throw new Error( + `Failed to load module ${id}. ` + + 'Required DLL was not found. ' + + 'This error usually happens when Microsoft Visual C++ Redistributable is not installed. ' + + `You can download it from ${msvcDownloadLink}`, + { cause: error } + ); + } + + throw new Error( + `Cannot find module ${id}. ` + + `npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). ` + + 'Please try `npm i` again after removing both package-lock.json and node_modules directory.', + { cause: error } + ); + } +}; + +const { parse, parseAsync, xxhashBase64Url, xxhashBase36, xxhashBase16 } = requireWithFriendlyError( + existsSync(path.join(__dirname, localName)) ? localName : `@rollup/rollup-${packageBase}` +); + +function getPackageBase() { + const imported = bindingsByPlatformAndArch[platform]?.[arch]; + if (!imported) { + throwUnsupportedError(false); + } + if ('musl' in imported && isMusl()) { + return imported.musl || throwUnsupportedError(true); + } + return imported.base; +} + +function throwUnsupportedError(isMusl) { + throw new Error( + `Your current platform "${platform}${isMusl ? ' (musl)' : ''}" and architecture "${arch}" combination is not yet supported by the native Rollup build. Please use the WASM build "@rollup/wasm-node" instead. + +The following platform-architecture combinations are supported: +${Object.entries(bindingsByPlatformAndArch) + .flatMap(([platformName, architectures]) => + Object.entries(architectures).flatMap(([architectureName, { musl }]) => { + const name = `${platformName}-${architectureName}`; + return musl ? [name, `${name} (musl)`] : [name]; + }) + ) + .join('\n')} + +If this is important to you, please consider supporting Rollup to make a native build for your platform and architecture available.` + ); +} + +module.exports.parse = parse; +module.exports.parseAsync = parseAsync; +module.exports.xxhashBase64Url = xxhashBase64Url; +module.exports.xxhashBase36 = xxhashBase36; +module.exports.xxhashBase16 = xxhashBase16; diff --git a/native.wasm.js b/native.wasm.js new file mode 100644 index 00000000000..e7114ca0422 --- /dev/null +++ b/native.wasm.js @@ -0,0 +1,13 @@ +const { + parse, + xxhashBase64Url, + xxhashBase36, + xxhashBase16 +} = require('./wasm-node/bindings_wasm.js'); + +exports.parse = parse; +exports.parseAsync = async (code, allowReturnOutsideFunction, jsx, _signal) => + parse(code, allowReturnOutsideFunction, jsx); +exports.xxhashBase64Url = xxhashBase64Url; +exports.xxhashBase36 = xxhashBase36; +exports.xxhashBase16 = xxhashBase16; diff --git a/npm/android-arm-eabi/README.md b/npm/android-arm-eabi/README.md new file mode 100644 index 00000000000..b75a36c99c9 --- /dev/null +++ b/npm/android-arm-eabi/README.md @@ -0,0 +1,3 @@ +# `@rollup/rollup-android-arm-eabi` + +This is the **armv7-linux-androideabi** binary for `rollup` diff --git a/npm/android-arm-eabi/package.json b/npm/android-arm-eabi/package.json new file mode 100644 index 00000000000..d1db488a6fb --- /dev/null +++ b/npm/android-arm-eabi/package.json @@ -0,0 +1,22 @@ +{ + "name": "@rollup/rollup-android-arm-eabi", + "version": "0.0.0", + "os": [ + "android" + ], + "cpu": [ + "arm" + ], + "files": [ + "rollup.android-arm-eabi.node" + ], + "description": "Native bindings for Rollup", + "author": "Lukas Taegert-Atkinson", + "homepage": "https://rollupjs.org/", + "license": "MIT", + "repository": { + "type": "git", + "url": "git+https://github.com/rollup/rollup.git" + }, + "main": "./rollup.android-arm-eabi.node" +} diff --git a/npm/android-arm64/README.md b/npm/android-arm64/README.md new file mode 100644 index 00000000000..7aa827a92db --- /dev/null +++ b/npm/android-arm64/README.md @@ -0,0 +1,3 @@ +# `@rollup/rollup-android-arm64` + +This is the **aarch64-linux-android** binary for `rollup` diff --git a/npm/android-arm64/package.json b/npm/android-arm64/package.json new file mode 100644 index 00000000000..c29dc6ad1fb --- /dev/null +++ b/npm/android-arm64/package.json @@ -0,0 +1,22 @@ +{ + "name": "@rollup/rollup-android-arm64", + "version": "0.0.0", + "os": [ + "android" + ], + "cpu": [ + "arm64" + ], + "files": [ + "rollup.android-arm64.node" + ], + "description": "Native bindings for Rollup", + "author": "Lukas Taegert-Atkinson", + "homepage": "https://rollupjs.org/", + "license": "MIT", + "repository": { + "type": "git", + "url": "git+https://github.com/rollup/rollup.git" + }, + "main": "./rollup.android-arm64.node" +} diff --git a/npm/darwin-arm64/README.md b/npm/darwin-arm64/README.md new file mode 100644 index 00000000000..c29619c3090 --- /dev/null +++ b/npm/darwin-arm64/README.md @@ -0,0 +1,3 @@ +# `@rollup/rollup-darwin-arm64` + +This is the **aarch64-apple-darwin** binary for `rollup` diff --git a/npm/darwin-arm64/package.json b/npm/darwin-arm64/package.json new file mode 100644 index 00000000000..0d682d657d3 --- /dev/null +++ b/npm/darwin-arm64/package.json @@ -0,0 +1,22 @@ +{ + "name": "@rollup/rollup-darwin-arm64", + "version": "0.0.0", + "os": [ + "darwin" + ], + "cpu": [ + "arm64" + ], + "files": [ + "rollup.darwin-arm64.node" + ], + "description": "Native bindings for Rollup", + "author": "Lukas Taegert-Atkinson", + "homepage": "https://rollupjs.org/", + "license": "MIT", + "repository": { + "type": "git", + "url": "git+https://github.com/rollup/rollup.git" + }, + "main": "./rollup.darwin-arm64.node" +} diff --git a/npm/darwin-x64/README.md b/npm/darwin-x64/README.md new file mode 100644 index 00000000000..156d37a8778 --- /dev/null +++ b/npm/darwin-x64/README.md @@ -0,0 +1,3 @@ +# `@rollup/rollup-darwin-x64` + +This is the **x86_64-apple-darwin** binary for `rollup` diff --git a/npm/darwin-x64/package.json b/npm/darwin-x64/package.json new file mode 100644 index 00000000000..b53a05b4252 --- /dev/null +++ b/npm/darwin-x64/package.json @@ -0,0 +1,22 @@ +{ + "name": "@rollup/rollup-darwin-x64", + "version": "0.0.0", + "os": [ + "darwin" + ], + "cpu": [ + "x64" + ], + "files": [ + "rollup.darwin-x64.node" + ], + "description": "Native bindings for Rollup", + "author": "Lukas Taegert-Atkinson", + "homepage": "https://rollupjs.org/", + "license": "MIT", + "repository": { + "type": "git", + "url": "git+https://github.com/rollup/rollup.git" + }, + "main": "./rollup.darwin-x64.node" +} diff --git a/npm/freebsd-arm64/README.md b/npm/freebsd-arm64/README.md new file mode 100644 index 00000000000..c655ee95615 --- /dev/null +++ b/npm/freebsd-arm64/README.md @@ -0,0 +1,3 @@ +# `@rollup/rollup-freebsd-arm64` + +This is the **aarch64-unknown-freebsd** binary for `rollup` diff --git a/npm/freebsd-arm64/package.json b/npm/freebsd-arm64/package.json new file mode 100644 index 00000000000..497e39dafbc --- /dev/null +++ b/npm/freebsd-arm64/package.json @@ -0,0 +1,22 @@ +{ + "name": "@rollup/rollup-freebsd-arm64", + "version": "0.0.0", + "os": [ + "freebsd" + ], + "cpu": [ + "arm64" + ], + "files": [ + "rollup.freebsd-arm64.node" + ], + "description": "Native bindings for Rollup", + "author": "Lukas Taegert-Atkinson", + "homepage": "https://rollupjs.org/", + "license": "MIT", + "repository": { + "type": "git", + "url": "git+https://github.com/rollup/rollup.git" + }, + "main": "./rollup.freebsd-arm64.node" +} diff --git a/npm/freebsd-x64/README.md b/npm/freebsd-x64/README.md new file mode 100644 index 00000000000..aaafb00a15d --- /dev/null +++ b/npm/freebsd-x64/README.md @@ -0,0 +1,3 @@ +# `@rollup/rollup-freebsd-x64` + +This is the **x86_64-unknown-freebsd** binary for `rollup` diff --git a/npm/freebsd-x64/package.json b/npm/freebsd-x64/package.json new file mode 100644 index 00000000000..f49e1a07136 --- /dev/null +++ b/npm/freebsd-x64/package.json @@ -0,0 +1,22 @@ +{ + "name": "@rollup/rollup-freebsd-x64", + "version": "0.0.0", + "os": [ + "freebsd" + ], + "cpu": [ + "x64" + ], + "files": [ + "rollup.freebsd-x64.node" + ], + "description": "Native bindings for Rollup", + "author": "Lukas Taegert-Atkinson", + "homepage": "https://rollupjs.org/", + "license": "MIT", + "repository": { + "type": "git", + "url": "git+https://github.com/rollup/rollup.git" + }, + "main": "./rollup.freebsd-x64.node" +} diff --git a/npm/linux-arm-gnueabihf/README.md b/npm/linux-arm-gnueabihf/README.md new file mode 100644 index 00000000000..1b58b1c47e3 --- /dev/null +++ b/npm/linux-arm-gnueabihf/README.md @@ -0,0 +1,3 @@ +# `@rollup/rollup-linux-arm-gnueabihf` + +This is the **armv7-unknown-linux-gnueabihf** binary for `rollup` diff --git a/npm/linux-arm-gnueabihf/package.json b/npm/linux-arm-gnueabihf/package.json new file mode 100644 index 00000000000..3234dd28a0c --- /dev/null +++ b/npm/linux-arm-gnueabihf/package.json @@ -0,0 +1,25 @@ +{ + "name": "@rollup/rollup-linux-arm-gnueabihf", + "version": "0.0.0", + "os": [ + "linux" + ], + "cpu": [ + "arm" + ], + "files": [ + "rollup.linux-arm-gnueabihf.node" + ], + "description": "Native bindings for Rollup", + "author": "Lukas Taegert-Atkinson", + "homepage": "https://rollupjs.org/", + "license": "MIT", + "repository": { + "type": "git", + "url": "git+https://github.com/rollup/rollup.git" + }, + "libc": [ + "glibc" + ], + "main": "./rollup.linux-arm-gnueabihf.node" +} diff --git a/npm/linux-arm-musleabihf/README.md b/npm/linux-arm-musleabihf/README.md new file mode 100644 index 00000000000..09798f728bd --- /dev/null +++ b/npm/linux-arm-musleabihf/README.md @@ -0,0 +1,3 @@ +# `@rollup/rollup-linux-arm-musleabihf` + +This is the **armv7-unknown-linux-musleabihf** binary for `rollup` diff --git a/npm/linux-arm-musleabihf/package.json b/npm/linux-arm-musleabihf/package.json new file mode 100644 index 00000000000..d40faca21c6 --- /dev/null +++ b/npm/linux-arm-musleabihf/package.json @@ -0,0 +1,25 @@ +{ + "name": "@rollup/rollup-linux-arm-musleabihf", + "version": "0.0.0", + "os": [ + "linux" + ], + "cpu": [ + "arm" + ], + "files": [ + "rollup.linux-arm-musleabihf.node" + ], + "description": "Native bindings for Rollup", + "author": "Lukas Taegert-Atkinson", + "homepage": "https://rollupjs.org/", + "license": "MIT", + "repository": { + "type": "git", + "url": "git+https://github.com/rollup/rollup.git" + }, + "libc": [ + "musl" + ], + "main": "./rollup.linux-arm-musleabihf.node" +} diff --git a/npm/linux-arm64-gnu/README.md b/npm/linux-arm64-gnu/README.md new file mode 100644 index 00000000000..48e68cb4cde --- /dev/null +++ b/npm/linux-arm64-gnu/README.md @@ -0,0 +1,3 @@ +# `@rollup/rollup-linux-arm64-gnu` + +This is the **aarch64-unknown-linux-gnu** binary for `rollup` diff --git a/npm/linux-arm64-gnu/package.json b/npm/linux-arm64-gnu/package.json new file mode 100644 index 00000000000..5095bca2444 --- /dev/null +++ b/npm/linux-arm64-gnu/package.json @@ -0,0 +1,25 @@ +{ + "name": "@rollup/rollup-linux-arm64-gnu", + "version": "0.0.0", + "os": [ + "linux" + ], + "cpu": [ + "arm64" + ], + "files": [ + "rollup.linux-arm64-gnu.node" + ], + "description": "Native bindings for Rollup", + "author": "Lukas Taegert-Atkinson", + "homepage": "https://rollupjs.org/", + "license": "MIT", + "repository": { + "type": "git", + "url": "git+https://github.com/rollup/rollup.git" + }, + "libc": [ + "glibc" + ], + "main": "./rollup.linux-arm64-gnu.node" +} diff --git a/npm/linux-arm64-musl/README.md b/npm/linux-arm64-musl/README.md new file mode 100644 index 00000000000..3db2751ae02 --- /dev/null +++ b/npm/linux-arm64-musl/README.md @@ -0,0 +1,3 @@ +# `@rollup/rollup-linux-arm64-musl` + +This is the **aarch64-unknown-linux-musl** binary for `rollup` diff --git a/npm/linux-arm64-musl/package.json b/npm/linux-arm64-musl/package.json new file mode 100644 index 00000000000..d4caf5e8793 --- /dev/null +++ b/npm/linux-arm64-musl/package.json @@ -0,0 +1,25 @@ +{ + "name": "@rollup/rollup-linux-arm64-musl", + "version": "0.0.0", + "os": [ + "linux" + ], + "cpu": [ + "arm64" + ], + "files": [ + "rollup.linux-arm64-musl.node" + ], + "description": "Native bindings for Rollup", + "author": "Lukas Taegert-Atkinson", + "homepage": "https://rollupjs.org/", + "license": "MIT", + "repository": { + "type": "git", + "url": "git+https://github.com/rollup/rollup.git" + }, + "libc": [ + "musl" + ], + "main": "./rollup.linux-arm64-musl.node" +} diff --git a/npm/linux-loong64-gnu/README.md b/npm/linux-loong64-gnu/README.md new file mode 100644 index 00000000000..b8ac344f8df --- /dev/null +++ b/npm/linux-loong64-gnu/README.md @@ -0,0 +1,3 @@ +# `@rollup/rollup-linux-loong64-gnu` + +This is the **loongarch64-unknown-linux-gnu** binary for `rollup` diff --git a/npm/linux-loong64-gnu/package.json b/npm/linux-loong64-gnu/package.json new file mode 100644 index 00000000000..fd16c2637a3 --- /dev/null +++ b/npm/linux-loong64-gnu/package.json @@ -0,0 +1,25 @@ +{ + "name": "@rollup/rollup-linux-loong64-gnu", + "version": "0.0.0", + "os": [ + "linux" + ], + "cpu": [ + "loong64" + ], + "files": [ + "rollup.linux-loong64-gnu.node" + ], + "description": "Native bindings for Rollup", + "author": "Lukas Taegert-Atkinson", + "homepage": "https://rollupjs.org/", + "license": "MIT", + "repository": { + "type": "git", + "url": "git+https://github.com/rollup/rollup.git" + }, + "libc": [ + "glibc" + ], + "main": "./rollup.linux-loong64-gnu.node" +} diff --git a/npm/linux-loong64-musl/README.md b/npm/linux-loong64-musl/README.md new file mode 100644 index 00000000000..471875c26ce --- /dev/null +++ b/npm/linux-loong64-musl/README.md @@ -0,0 +1,3 @@ +# `@rollup/rollup-linux-loong64-musl` + +This is the **loongarch64-unknown-linux-musl** binary for `rollup` diff --git a/npm/linux-loong64-musl/package.json b/npm/linux-loong64-musl/package.json new file mode 100644 index 00000000000..e5ad45c8fe3 --- /dev/null +++ b/npm/linux-loong64-musl/package.json @@ -0,0 +1,25 @@ +{ + "name": "@rollup/rollup-linux-loong64-musl", + "version": "0.0.0", + "os": [ + "linux" + ], + "cpu": [ + "loong64" + ], + "files": [ + "rollup.linux-loong64-musl.node" + ], + "description": "Native bindings for Rollup", + "author": "Lukas Taegert-Atkinson", + "homepage": "https://rollupjs.org/", + "license": "MIT", + "repository": { + "type": "git", + "url": "git+https://github.com/rollup/rollup.git" + }, + "libc": [ + "musl" + ], + "main": "./rollup.linux-loong64-musl.node" +} diff --git a/npm/linux-ppc64-gnu/README.md b/npm/linux-ppc64-gnu/README.md new file mode 100644 index 00000000000..78d2e95e86e --- /dev/null +++ b/npm/linux-ppc64-gnu/README.md @@ -0,0 +1,3 @@ +# `@rollup/rollup-linux-ppc64-gnu` + +This is the **powerpc64le-unknown-linux-gnu** binary for `rollup` diff --git a/npm/linux-ppc64-gnu/package.json b/npm/linux-ppc64-gnu/package.json new file mode 100644 index 00000000000..55c632d4da6 --- /dev/null +++ b/npm/linux-ppc64-gnu/package.json @@ -0,0 +1,25 @@ +{ + "name": "@rollup/rollup-linux-ppc64-gnu", + "version": "0.0.0", + "os": [ + "linux" + ], + "cpu": [ + "ppc64" + ], + "files": [ + "rollup.linux-ppc64-gnu.node" + ], + "description": "Native bindings for Rollup", + "author": "Lukas Taegert-Atkinson", + "homepage": "https://rollupjs.org/", + "license": "MIT", + "repository": { + "type": "git", + "url": "git+https://github.com/rollup/rollup.git" + }, + "libc": [ + "glibc" + ], + "main": "./rollup.linux-ppc64-gnu.node" +} diff --git a/npm/linux-ppc64-musl/README.md b/npm/linux-ppc64-musl/README.md new file mode 100644 index 00000000000..dbfcfd1c13b --- /dev/null +++ b/npm/linux-ppc64-musl/README.md @@ -0,0 +1,3 @@ +# `@rollup/rollup-linux-ppc64-musl` + +This is the **powerpc64le-unknown-linux-musl** binary for `rollup` diff --git a/npm/linux-ppc64-musl/package.json b/npm/linux-ppc64-musl/package.json new file mode 100644 index 00000000000..ce6cf5add72 --- /dev/null +++ b/npm/linux-ppc64-musl/package.json @@ -0,0 +1,25 @@ +{ + "name": "@rollup/rollup-linux-ppc64-musl", + "version": "0.0.0", + "os": [ + "linux" + ], + "cpu": [ + "ppc64" + ], + "files": [ + "rollup.linux-ppc64-musl.node" + ], + "description": "Native bindings for Rollup", + "author": "Lukas Taegert-Atkinson", + "homepage": "https://rollupjs.org/", + "license": "MIT", + "repository": { + "type": "git", + "url": "git+https://github.com/rollup/rollup.git" + }, + "libc": [ + "musl" + ], + "main": "./rollup.linux-ppc64-musl.node" +} diff --git a/npm/linux-riscv64-gnu/README.md b/npm/linux-riscv64-gnu/README.md new file mode 100644 index 00000000000..49600dc45e4 --- /dev/null +++ b/npm/linux-riscv64-gnu/README.md @@ -0,0 +1,3 @@ +# `@rollup/rollup-linux-riscv64-gnu` + +This is the **riscv64gc-unknown-linux-gnu** binary for `rollup` diff --git a/npm/linux-riscv64-gnu/package.json b/npm/linux-riscv64-gnu/package.json new file mode 100644 index 00000000000..fa21a27ecd4 --- /dev/null +++ b/npm/linux-riscv64-gnu/package.json @@ -0,0 +1,25 @@ +{ + "name": "@rollup/rollup-linux-riscv64-gnu", + "version": "0.0.0", + "os": [ + "linux" + ], + "cpu": [ + "riscv64" + ], + "files": [ + "rollup.linux-riscv64-gnu.node" + ], + "description": "Native bindings for Rollup", + "author": "Lukas Taegert-Atkinson", + "homepage": "https://rollupjs.org/", + "license": "MIT", + "repository": { + "type": "git", + "url": "git+https://github.com/rollup/rollup.git" + }, + "libc": [ + "glibc" + ], + "main": "./rollup.linux-riscv64-gnu.node" +} diff --git a/npm/linux-riscv64-musl/README.md b/npm/linux-riscv64-musl/README.md new file mode 100644 index 00000000000..55e4c1a1127 --- /dev/null +++ b/npm/linux-riscv64-musl/README.md @@ -0,0 +1,3 @@ +# `@rollup/rollup-linux-riscv64-musl` + +This is the **riscv64gc-unknown-linux-musl** binary for `rollup` diff --git a/npm/linux-riscv64-musl/package.json b/npm/linux-riscv64-musl/package.json new file mode 100644 index 00000000000..52354b9e4fc --- /dev/null +++ b/npm/linux-riscv64-musl/package.json @@ -0,0 +1,25 @@ +{ + "name": "@rollup/rollup-linux-riscv64-musl", + "version": "0.0.0", + "os": [ + "linux" + ], + "cpu": [ + "riscv64" + ], + "files": [ + "rollup.linux-riscv64-musl.node" + ], + "description": "Native bindings for Rollup", + "author": "Lukas Taegert-Atkinson", + "homepage": "https://rollupjs.org/", + "license": "MIT", + "repository": { + "type": "git", + "url": "git+https://github.com/rollup/rollup.git" + }, + "libc": [ + "musl" + ], + "main": "./rollup.linux-riscv64-musl.node" +} diff --git a/npm/linux-s390x-gnu/README.md b/npm/linux-s390x-gnu/README.md new file mode 100644 index 00000000000..55818914c2f --- /dev/null +++ b/npm/linux-s390x-gnu/README.md @@ -0,0 +1,3 @@ +# `@rollup/rollup-linux-s390x-gnu` + +This is the **s390x-unknown-linux-gnu** binary for `rollup` diff --git a/npm/linux-s390x-gnu/package.json b/npm/linux-s390x-gnu/package.json new file mode 100644 index 00000000000..13030677b08 --- /dev/null +++ b/npm/linux-s390x-gnu/package.json @@ -0,0 +1,25 @@ +{ + "name": "@rollup/rollup-linux-s390x-gnu", + "version": "0.0.0", + "os": [ + "linux" + ], + "cpu": [ + "s390x" + ], + "files": [ + "rollup.linux-s390x-gnu.node" + ], + "description": "Native bindings for Rollup", + "author": "Lukas Taegert-Atkinson", + "homepage": "https://rollupjs.org/", + "license": "MIT", + "repository": { + "type": "git", + "url": "git+https://github.com/rollup/rollup.git" + }, + "libc": [ + "glibc" + ], + "main": "./rollup.linux-s390x-gnu.node" +} diff --git a/npm/linux-x64-gnu/README.md b/npm/linux-x64-gnu/README.md new file mode 100644 index 00000000000..cabe280f1a2 --- /dev/null +++ b/npm/linux-x64-gnu/README.md @@ -0,0 +1,3 @@ +# `@rollup/rollup-linux-x64-gnu` + +This is the **x86_64-unknown-linux-gnu** binary for `rollup` diff --git a/npm/linux-x64-gnu/package.json b/npm/linux-x64-gnu/package.json new file mode 100644 index 00000000000..43386f288d8 --- /dev/null +++ b/npm/linux-x64-gnu/package.json @@ -0,0 +1,25 @@ +{ + "name": "@rollup/rollup-linux-x64-gnu", + "version": "0.0.0", + "os": [ + "linux" + ], + "cpu": [ + "x64" + ], + "files": [ + "rollup.linux-x64-gnu.node" + ], + "description": "Native bindings for Rollup", + "author": "Lukas Taegert-Atkinson", + "homepage": "https://rollupjs.org/", + "license": "MIT", + "repository": { + "type": "git", + "url": "git+https://github.com/rollup/rollup.git" + }, + "libc": [ + "glibc" + ], + "main": "./rollup.linux-x64-gnu.node" +} diff --git a/npm/linux-x64-musl/README.md b/npm/linux-x64-musl/README.md new file mode 100644 index 00000000000..5848a6c6e36 --- /dev/null +++ b/npm/linux-x64-musl/README.md @@ -0,0 +1,3 @@ +# `@rollup/rollup-linux-x64-musl` + +This is the **x86_64-unknown-linux-musl** binary for `rollup` diff --git a/npm/linux-x64-musl/package.json b/npm/linux-x64-musl/package.json new file mode 100644 index 00000000000..0f900815a3c --- /dev/null +++ b/npm/linux-x64-musl/package.json @@ -0,0 +1,25 @@ +{ + "name": "@rollup/rollup-linux-x64-musl", + "version": "0.0.0", + "os": [ + "linux" + ], + "cpu": [ + "x64" + ], + "files": [ + "rollup.linux-x64-musl.node" + ], + "description": "Native bindings for Rollup", + "author": "Lukas Taegert-Atkinson", + "homepage": "https://rollupjs.org/", + "license": "MIT", + "repository": { + "type": "git", + "url": "git+https://github.com/rollup/rollup.git" + }, + "libc": [ + "musl" + ], + "main": "./rollup.linux-x64-musl.node" +} diff --git a/npm/openbsd-x64/README.md b/npm/openbsd-x64/README.md new file mode 100644 index 00000000000..8f599d029ad --- /dev/null +++ b/npm/openbsd-x64/README.md @@ -0,0 +1,3 @@ +# `@rollup/rollup-openbsd-x64` + +This is the **x86_64-unknown-openbsd** binary for `rollup` diff --git a/npm/openbsd-x64/package.json b/npm/openbsd-x64/package.json new file mode 100644 index 00000000000..deb0d40aed1 --- /dev/null +++ b/npm/openbsd-x64/package.json @@ -0,0 +1,22 @@ +{ + "name": "@rollup/rollup-openbsd-x64", + "version": "0.0.0", + "os": [ + "openbsd" + ], + "cpu": [ + "x64" + ], + "files": [ + "rollup.openbsd-x64.node" + ], + "description": "Native bindings for Rollup", + "author": "Lukas Taegert-Atkinson", + "homepage": "https://rollupjs.org/", + "license": "MIT", + "repository": { + "type": "git", + "url": "git+https://github.com/rollup/rollup.git" + }, + "main": "./rollup.openbsd-x64.node" +} diff --git a/npm/openharmony-arm64/README.md b/npm/openharmony-arm64/README.md new file mode 100644 index 00000000000..60cfd5ca828 --- /dev/null +++ b/npm/openharmony-arm64/README.md @@ -0,0 +1,3 @@ +# `@rollup/rollup-openharmony-arm64` + +This is the **aarch64-unknown-linux-ohos** binary for `rollup` diff --git a/npm/openharmony-arm64/package.json b/npm/openharmony-arm64/package.json new file mode 100644 index 00000000000..321c1226846 --- /dev/null +++ b/npm/openharmony-arm64/package.json @@ -0,0 +1,22 @@ +{ + "name": "@rollup/rollup-openharmony-arm64", + "version": "0.0.0", + "os": [ + "openharmony" + ], + "cpu": [ + "arm64" + ], + "files": [ + "rollup.openharmony-arm64.node" + ], + "description": "Native bindings for Rollup", + "author": "Lukas Taegert-Atkinson", + "homepage": "https://rollupjs.org/", + "license": "MIT", + "repository": { + "type": "git", + "url": "git+https://github.com/rollup/rollup.git" + }, + "main": "./rollup.openharmony-arm64.node" +} diff --git a/npm/win32-arm64-msvc/README.md b/npm/win32-arm64-msvc/README.md new file mode 100644 index 00000000000..26ef53bf780 --- /dev/null +++ b/npm/win32-arm64-msvc/README.md @@ -0,0 +1,3 @@ +# `@rollup/rollup-win32-arm64-msvc` + +This is the **aarch64-pc-windows-msvc** binary for `rollup` diff --git a/npm/win32-arm64-msvc/package.json b/npm/win32-arm64-msvc/package.json new file mode 100644 index 00000000000..5f7e7256236 --- /dev/null +++ b/npm/win32-arm64-msvc/package.json @@ -0,0 +1,22 @@ +{ + "name": "@rollup/rollup-win32-arm64-msvc", + "version": "0.0.0", + "os": [ + "win32" + ], + "cpu": [ + "arm64" + ], + "files": [ + "rollup.win32-arm64-msvc.node" + ], + "description": "Native bindings for Rollup", + "author": "Lukas Taegert-Atkinson", + "homepage": "https://rollupjs.org/", + "license": "MIT", + "repository": { + "type": "git", + "url": "git+https://github.com/rollup/rollup.git" + }, + "main": "./rollup.win32-arm64-msvc.node" +} diff --git a/npm/win32-ia32-msvc/README.md b/npm/win32-ia32-msvc/README.md new file mode 100644 index 00000000000..9a03e8c74ad --- /dev/null +++ b/npm/win32-ia32-msvc/README.md @@ -0,0 +1,3 @@ +# `@rollup/rollup-win32-ia32-msvc` + +This is the **i686-pc-windows-msvc** binary for `rollup` diff --git a/npm/win32-ia32-msvc/package.json b/npm/win32-ia32-msvc/package.json new file mode 100644 index 00000000000..bf2509665ee --- /dev/null +++ b/npm/win32-ia32-msvc/package.json @@ -0,0 +1,22 @@ +{ + "name": "@rollup/rollup-win32-ia32-msvc", + "version": "0.0.0", + "os": [ + "win32" + ], + "cpu": [ + "ia32" + ], + "files": [ + "rollup.win32-ia32-msvc.node" + ], + "description": "Native bindings for Rollup", + "author": "Lukas Taegert-Atkinson", + "homepage": "https://rollupjs.org/", + "license": "MIT", + "repository": { + "type": "git", + "url": "git+https://github.com/rollup/rollup.git" + }, + "main": "./rollup.win32-ia32-msvc.node" +} diff --git a/npm/win32-x64-gnu/README.md b/npm/win32-x64-gnu/README.md new file mode 100644 index 00000000000..e8a624b097b --- /dev/null +++ b/npm/win32-x64-gnu/README.md @@ -0,0 +1,3 @@ +# `@rollup/rollup-win32-x64-gnu` + +This is the **x86_64-pc-windows-gnu** binary for `rollup` diff --git a/npm/win32-x64-gnu/package.json b/npm/win32-x64-gnu/package.json new file mode 100644 index 00000000000..edb3c0ba6db --- /dev/null +++ b/npm/win32-x64-gnu/package.json @@ -0,0 +1,22 @@ +{ + "name": "@rollup/rollup-win32-x64-gnu", + "version": "0.0.0", + "os": [ + "win32" + ], + "cpu": [ + "x64" + ], + "files": [ + "rollup.win32-x64-gnu.node" + ], + "description": "Native bindings for Rollup", + "author": "Lukas Taegert-Atkinson", + "homepage": "https://rollupjs.org/", + "license": "MIT", + "repository": { + "type": "git", + "url": "git+https://github.com/rollup/rollup.git" + }, + "main": "./rollup.win32-x64-gnu.node" +} diff --git a/npm/win32-x64-msvc/README.md b/npm/win32-x64-msvc/README.md new file mode 100644 index 00000000000..7382dbc4f92 --- /dev/null +++ b/npm/win32-x64-msvc/README.md @@ -0,0 +1,3 @@ +# `@rollup/rollup-win32-x64-msvc` + +This is the **x86_64-pc-windows-msvc** binary for `rollup` diff --git a/npm/win32-x64-msvc/package.json b/npm/win32-x64-msvc/package.json new file mode 100644 index 00000000000..91cfcb0204b --- /dev/null +++ b/npm/win32-x64-msvc/package.json @@ -0,0 +1,22 @@ +{ + "name": "@rollup/rollup-win32-x64-msvc", + "version": "0.0.0", + "os": [ + "win32" + ], + "cpu": [ + "x64" + ], + "files": [ + "rollup.win32-x64-msvc.node" + ], + "description": "Native bindings for Rollup", + "author": "Lukas Taegert-Atkinson", + "homepage": "https://rollupjs.org/", + "license": "MIT", + "repository": { + "type": "git", + "url": "git+https://github.com/rollup/rollup.git" + }, + "main": "./rollup.win32-x64-msvc.node" +} diff --git a/package-lock.json b/package-lock.json index d7aa7716fa9..e9604120e98 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,4879 +1,17827 @@ { "name": "rollup", - "version": "2.45.2", - "lockfileVersion": 1, + "version": "4.56.0", + "lockfileVersion": 3, "requires": true, - "dependencies": { - "@babel/code-frame": { - "version": "7.12.13", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.12.13.tgz", - "integrity": "sha512-HV1Cm0Q3ZrpCR93tkWOYiuYIgLxZXZFVG2VgK+MBWjUqZTundupbfx2aXarXuw5Ko5aMcjtJgbSs4vUGBS5v6g==", - "dev": true, - "requires": { - "@babel/highlight": "^7.12.13" - } - }, - "@babel/core": { - "version": "7.12.16", - "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.12.16.tgz", - "integrity": "sha512-t/hHIB504wWceOeaOoONOhu+gX+hpjfeN6YRBT209X/4sibZQfSF1I0HFRRlBe97UZZosGx5XwUg1ZgNbelmNw==", - "dev": true, - "requires": { - "@babel/code-frame": "^7.12.13", - "@babel/generator": "^7.12.15", - "@babel/helper-module-transforms": "^7.12.13", - "@babel/helpers": "^7.12.13", - "@babel/parser": "^7.12.16", - "@babel/template": "^7.12.13", - "@babel/traverse": "^7.12.13", - "@babel/types": "^7.12.13", - "convert-source-map": "^1.7.0", - "debug": "^4.1.0", - "gensync": "^1.0.0-beta.1", - "json5": "^2.1.2", - "lodash": "^4.17.19", - "semver": "^5.4.1", - "source-map": "^0.5.0" - }, - "dependencies": { - "json5": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.0.tgz", - "integrity": "sha512-f+8cldu7X/y7RAJurMEJmdoKXGB/X550w2Nr3tTbezL6RwEE/iMcm+tZnXeoZtKuOq6ft8+CqzEkrIgx1fPoQA==", - "dev": true, - "requires": { - "minimist": "^1.2.5" - } - }, - "semver": { - "version": "5.7.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", - "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", - "dev": true - }, - "source-map": { - "version": "0.5.7", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", - "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=", - "dev": true - } + "packages": { + "": { + "name": "rollup", + "version": "4.56.0", + "license": "MIT", + "dependencies": { + "@types/estree": "1.0.8" + }, + "bin": { + "rollup": "dist/bin/rollup" + }, + "devDependencies": { + "@codemirror/commands": "^6.10.1", + "@codemirror/lang-javascript": "^6.2.4", + "@codemirror/language": "^6.12.1", + "@codemirror/search": "^6.6.0", + "@codemirror/state": "^6.5.3", + "@codemirror/view": "^6.39.10", + "@eslint/js": "^9.39.2", + "@inquirer/prompts": "^7.10.1", + "@jridgewell/sourcemap-codec": "^1.5.5", + "@mermaid-js/mermaid-cli": "^11.12.0", + "@napi-rs/cli": "3.4.1", + "@rollup/plugin-alias": "^6.0.0", + "@rollup/plugin-buble": "^1.0.3", + "@rollup/plugin-commonjs": "^29.0.0", + "@rollup/plugin-json": "^6.1.0", + "@rollup/plugin-node-resolve": "^16.0.3", + "@rollup/plugin-replace": "^6.0.3", + "@rollup/plugin-terser": "^0.4.4", + "@rollup/plugin-typescript": "^12.3.0", + "@rollup/pluginutils": "^5.3.0", + "@shikijs/vitepress-twoslash": "^3.21.0", + "@types/mocha": "^10.0.10", + "@types/node": "^20.19.28", + "@types/picomatch": "^4.0.2", + "@types/semver": "^7.7.1", + "@types/yargs-parser": "^21.0.3", + "@vue/language-server": "^3.2.2", + "acorn": "^8.15.0", + "acorn-import-assertions": "^1.9.0", + "acorn-jsx": "^5.3.2", + "buble": "^0.20.0", + "builtin-modules": "^5.0.0", + "chokidar": "^3.6.0", + "concurrently": "^9.2.1", + "core-js": "3.38.1", + "cross-env": "^10.1.0", + "date-time": "^4.0.0", + "es5-shim": "^4.6.7", + "es6-shim": "^0.35.8", + "eslint": "^9.39.2", + "eslint-config-prettier": "^10.1.8", + "eslint-plugin-prettier": "^5.5.4", + "eslint-plugin-unicorn": "^62.0.0", + "eslint-plugin-vue": "^10.6.2", + "fixturify": "^3.0.0", + "flru": "^1.0.2", + "fs-extra": "^11.3.3", + "github-api": "^3.4.0", + "globals": "^17.0.0", + "husky": "^9.1.7", + "is-reference": "^3.0.3", + "lint-staged": "^16.2.7", + "locate-character": "^3.0.0", + "magic-string": "^0.30.21", + "memfs": "^4.51.1", + "mocha": "^11.7.5", + "nodemon": "^3.1.11", + "npm-audit-resolver": "^3.0.0-RC.0", + "nyc": "^17.1.0", + "patch-package": "^8.0.1", + "picocolors": "^1.1.1", + "picomatch": "^4.0.3", + "pinia": "^3.0.4", + "prettier": "^3.7.4", + "prettier-plugin-organize-imports": "^4.3.0", + "pretty-bytes": "^7.1.0", + "pretty-ms": "^9.3.0", + "requirejs": "^2.3.8", + "rollup": "^4.55.1", + "rollup-plugin-license": "^3.6.0", + "semver": "^7.7.3", + "shx": "^0.4.0", + "signal-exit": "^4.1.0", + "source-map": "^0.7.6", + "source-map-support": "^0.5.21", + "systemjs": "^6.15.1", + "terser": "^5.44.1", + "tslib": "^2.8.1", + "typescript": "^5.9.3", + "typescript-eslint": "^8.53.0", + "vite": "^7.3.1", + "vitepress": "^1.6.4", + "vue": "^3.5.26", + "vue-eslint-parser": "^10.2.0", + "vue-tsc": "^3.2.2", + "wasm-pack": "^0.13.1", + "yargs-parser": "^21.1.1" + }, + "engines": { + "node": ">=18.0.0", + "npm": ">=8.0.0" + }, + "optionalDependencies": { + "fsevents": "~2.3.2" } }, - "@babel/generator": { - "version": "7.12.15", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.12.15.tgz", - "integrity": "sha512-6F2xHxBiFXWNSGb7vyCUTBF8RCLY66rS0zEPcP8t/nQyXjha5EuK4z7H5o7fWG8B4M7y6mqVWq1J+1PuwRhecQ==", + "node_modules/@algolia/abtesting": { + "version": "1.12.3", + "resolved": "https://registry.npmjs.org/@algolia/abtesting/-/abtesting-1.12.3.tgz", + "integrity": "sha512-0SpSdnME0RCS6UHSs9XD3ox4bMcCg1JTmjAJ3AU6rcTlX54CZOAEPc2as8uSghX6wfKGT0HWes4TeUpjJMg6FQ==", "dev": true, - "requires": { - "@babel/types": "^7.12.13", - "jsesc": "^2.5.1", - "source-map": "^0.5.0" + "license": "MIT", + "dependencies": { + "@algolia/client-common": "5.46.3", + "@algolia/requester-browser-xhr": "5.46.3", + "@algolia/requester-fetch": "5.46.3", + "@algolia/requester-node-http": "5.46.3" }, + "engines": { + "node": ">= 14.0.0" + } + }, + "node_modules/@algolia/autocomplete-core": { + "version": "1.17.7", + "resolved": "https://registry.npmjs.org/@algolia/autocomplete-core/-/autocomplete-core-1.17.7.tgz", + "integrity": "sha512-BjiPOW6ks90UKl7TwMv7oNQMnzU+t/wk9mgIDi6b1tXpUek7MW0lbNOUHpvam9pe3lVCf4xPFT+lK7s+e+fs7Q==", + "dev": true, + "license": "MIT", "dependencies": { - "jsesc": { - "version": "2.5.2", - "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz", - "integrity": "sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA==", - "dev": true - }, - "source-map": { - "version": "0.5.7", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", - "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=", - "dev": true - } + "@algolia/autocomplete-plugin-algolia-insights": "1.17.7", + "@algolia/autocomplete-shared": "1.17.7" } }, - "@babel/helper-function-name": { - "version": "7.12.13", - "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.12.13.tgz", - "integrity": "sha512-TZvmPn0UOqmvi5G4vvw0qZTpVptGkB1GL61R6lKvrSdIxGm5Pky7Q3fpKiIkQCAtRCBUwB0PaThlx9vebCDSwA==", + "node_modules/@algolia/autocomplete-plugin-algolia-insights": { + "version": "1.17.7", + "resolved": "https://registry.npmjs.org/@algolia/autocomplete-plugin-algolia-insights/-/autocomplete-plugin-algolia-insights-1.17.7.tgz", + "integrity": "sha512-Jca5Ude6yUOuyzjnz57og7Et3aXjbwCSDf/8onLHSQgw1qW3ALl9mrMWaXb5FmPVkV3EtkD2F/+NkT6VHyPu9A==", "dev": true, - "requires": { - "@babel/helper-get-function-arity": "^7.12.13", - "@babel/template": "^7.12.13", - "@babel/types": "^7.12.13" + "license": "MIT", + "dependencies": { + "@algolia/autocomplete-shared": "1.17.7" + }, + "peerDependencies": { + "search-insights": ">= 1 < 3" } }, - "@babel/helper-get-function-arity": { - "version": "7.12.13", - "resolved": "https://registry.npmjs.org/@babel/helper-get-function-arity/-/helper-get-function-arity-7.12.13.tgz", - "integrity": "sha512-DjEVzQNz5LICkzN0REdpD5prGoidvbdYk1BVgRUOINaWJP2t6avB27X1guXK1kXNrX0WMfsrm1A/ZBthYuIMQg==", + "node_modules/@algolia/autocomplete-preset-algolia": { + "version": "1.17.7", + "resolved": "https://registry.npmjs.org/@algolia/autocomplete-preset-algolia/-/autocomplete-preset-algolia-1.17.7.tgz", + "integrity": "sha512-ggOQ950+nwbWROq2MOCIL71RE0DdQZsceqrg32UqnhDz8FlO9rL8ONHNsI2R1MH0tkgVIDKI/D0sMiUchsFdWA==", "dev": true, - "requires": { - "@babel/types": "^7.12.13" + "license": "MIT", + "dependencies": { + "@algolia/autocomplete-shared": "1.17.7" + }, + "peerDependencies": { + "@algolia/client-search": ">= 4.9.1 < 6", + "algoliasearch": ">= 4.9.1 < 6" } }, - "@babel/helper-member-expression-to-functions": { - "version": "7.12.16", - "resolved": "https://registry.npmjs.org/@babel/helper-member-expression-to-functions/-/helper-member-expression-to-functions-7.12.16.tgz", - "integrity": "sha512-zYoZC1uvebBFmj1wFAlXwt35JLEgecefATtKp20xalwEK8vHAixLBXTGxNrVGEmTT+gzOThUgr8UEdgtalc1BQ==", + "node_modules/@algolia/autocomplete-shared": { + "version": "1.17.7", + "resolved": "https://registry.npmjs.org/@algolia/autocomplete-shared/-/autocomplete-shared-1.17.7.tgz", + "integrity": "sha512-o/1Vurr42U/qskRSuhBH+VKxMvkkUVTLU6WZQr+L5lGZZLYWyhdzWjW0iGXY7EkwRTjBqvN2EsR81yCTGV/kmg==", "dev": true, - "requires": { - "@babel/types": "^7.12.13" + "license": "MIT", + "peerDependencies": { + "@algolia/client-search": ">= 4.9.1 < 6", + "algoliasearch": ">= 4.9.1 < 6" } }, - "@babel/helper-module-imports": { - "version": "7.12.13", - "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.12.13.tgz", - "integrity": "sha512-NGmfvRp9Rqxy0uHSSVP+SRIW1q31a7Ji10cLBcqSDUngGentY4FRiHOFZFE1CLU5eiL0oE8reH7Tg1y99TDM/g==", + "node_modules/@algolia/client-abtesting": { + "version": "5.46.3", + "resolved": "https://registry.npmjs.org/@algolia/client-abtesting/-/client-abtesting-5.46.3.tgz", + "integrity": "sha512-i2C8sBcl3EKXuCd5nlGohW+pZ9pY3P3JKJ2OYqsbCPg6wURiR32hNDiDvDq7/dqJ7KWWwC2snxJhokZzGlckgQ==", "dev": true, - "requires": { - "@babel/types": "^7.12.13" + "license": "MIT", + "dependencies": { + "@algolia/client-common": "5.46.3", + "@algolia/requester-browser-xhr": "5.46.3", + "@algolia/requester-fetch": "5.46.3", + "@algolia/requester-node-http": "5.46.3" + }, + "engines": { + "node": ">= 14.0.0" } }, - "@babel/helper-module-transforms": { - "version": "7.12.13", - "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.12.13.tgz", - "integrity": "sha512-acKF7EjqOR67ASIlDTupwkKM1eUisNAjaSduo5Cz+793ikfnpe7p4Q7B7EWU2PCoSTPWsQkR7hRUWEIZPiVLGA==", + "node_modules/@algolia/client-analytics": { + "version": "5.46.3", + "resolved": "https://registry.npmjs.org/@algolia/client-analytics/-/client-analytics-5.46.3.tgz", + "integrity": "sha512-uFmD7m3LOym1SAURHeiqupHT9jui+9HK0lAiIvm077gXEscOM5KKXM4rg/ICzQ3UDHLZEA0Lb5TglWsXnieE6w==", "dev": true, - "requires": { - "@babel/helper-module-imports": "^7.12.13", - "@babel/helper-replace-supers": "^7.12.13", - "@babel/helper-simple-access": "^7.12.13", - "@babel/helper-split-export-declaration": "^7.12.13", - "@babel/helper-validator-identifier": "^7.12.11", - "@babel/template": "^7.12.13", - "@babel/traverse": "^7.12.13", - "@babel/types": "^7.12.13", - "lodash": "^4.17.19" + "license": "MIT", + "dependencies": { + "@algolia/client-common": "5.46.3", + "@algolia/requester-browser-xhr": "5.46.3", + "@algolia/requester-fetch": "5.46.3", + "@algolia/requester-node-http": "5.46.3" + }, + "engines": { + "node": ">= 14.0.0" } }, - "@babel/helper-optimise-call-expression": { - "version": "7.12.13", - "resolved": "https://registry.npmjs.org/@babel/helper-optimise-call-expression/-/helper-optimise-call-expression-7.12.13.tgz", - "integrity": "sha512-BdWQhoVJkp6nVjB7nkFWcn43dkprYauqtk++Py2eaf/GRDFm5BxRqEIZCiHlZUGAVmtwKcsVL1dC68WmzeFmiA==", + "node_modules/@algolia/client-common": { + "version": "5.46.3", + "resolved": "https://registry.npmjs.org/@algolia/client-common/-/client-common-5.46.3.tgz", + "integrity": "sha512-SN+yK840nXa+2+mF72hrDfGd8+B7eBjF8TK/8KoRMdjlAkO/P3o3vtpjKRKI/Sk4L8kYYkB/avW8l+cwR+O1Ew==", "dev": true, - "requires": { - "@babel/types": "^7.12.13" + "license": "MIT", + "engines": { + "node": ">= 14.0.0" } }, - "@babel/helper-replace-supers": { - "version": "7.12.13", - "resolved": "https://registry.npmjs.org/@babel/helper-replace-supers/-/helper-replace-supers-7.12.13.tgz", - "integrity": "sha512-pctAOIAMVStI2TMLhozPKbf5yTEXc0OJa0eENheb4w09SrgOWEs+P4nTOZYJQCqs8JlErGLDPDJTiGIp3ygbLg==", + "node_modules/@algolia/client-insights": { + "version": "5.46.3", + "resolved": "https://registry.npmjs.org/@algolia/client-insights/-/client-insights-5.46.3.tgz", + "integrity": "sha512-5ic1liG0VucNPi6gKCWh5bEUGWQfyEmVeXiNKS+rOSppg7B7nKH0PEEJOFXBbHmgK5aPfNNZINiKcyUoH4XsFA==", "dev": true, - "requires": { - "@babel/helper-member-expression-to-functions": "^7.12.13", - "@babel/helper-optimise-call-expression": "^7.12.13", - "@babel/traverse": "^7.12.13", - "@babel/types": "^7.12.13" + "license": "MIT", + "dependencies": { + "@algolia/client-common": "5.46.3", + "@algolia/requester-browser-xhr": "5.46.3", + "@algolia/requester-fetch": "5.46.3", + "@algolia/requester-node-http": "5.46.3" + }, + "engines": { + "node": ">= 14.0.0" } }, - "@babel/helper-simple-access": { - "version": "7.12.13", - "resolved": "https://registry.npmjs.org/@babel/helper-simple-access/-/helper-simple-access-7.12.13.tgz", - "integrity": "sha512-0ski5dyYIHEfwpWGx5GPWhH35j342JaflmCeQmsPWcrOQDtCN6C1zKAVRFVbK53lPW2c9TsuLLSUDf0tIGJ5hA==", + "node_modules/@algolia/client-personalization": { + "version": "5.46.3", + "resolved": "https://registry.npmjs.org/@algolia/client-personalization/-/client-personalization-5.46.3.tgz", + "integrity": "sha512-f4HNitgTip8tntKgluYBTc1LWSOkbNCdxZvRA3rRBZnEAYSvLe7jpE+AxRep6RY+prSWwMtyeCFhA/F1Um+TuQ==", "dev": true, - "requires": { - "@babel/types": "^7.12.13" + "license": "MIT", + "dependencies": { + "@algolia/client-common": "5.46.3", + "@algolia/requester-browser-xhr": "5.46.3", + "@algolia/requester-fetch": "5.46.3", + "@algolia/requester-node-http": "5.46.3" + }, + "engines": { + "node": ">= 14.0.0" } }, - "@babel/helper-split-export-declaration": { - "version": "7.12.13", - "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.12.13.tgz", - "integrity": "sha512-tCJDltF83htUtXx5NLcaDqRmknv652ZWCHyoTETf1CXYJdPC7nohZohjUgieXhv0hTJdRf2FjDueFehdNucpzg==", + "node_modules/@algolia/client-query-suggestions": { + "version": "5.46.3", + "resolved": "https://registry.npmjs.org/@algolia/client-query-suggestions/-/client-query-suggestions-5.46.3.tgz", + "integrity": "sha512-/AaVqah2aYyJj7Cazu5QRkgcV3HF3lkBJo5TRkgqQ26xR4iHNRbLF2YsWJfJpJEFghlTF2HOCh7IgzaUCnM+8A==", "dev": true, - "requires": { - "@babel/types": "^7.12.13" + "license": "MIT", + "dependencies": { + "@algolia/client-common": "5.46.3", + "@algolia/requester-browser-xhr": "5.46.3", + "@algolia/requester-fetch": "5.46.3", + "@algolia/requester-node-http": "5.46.3" + }, + "engines": { + "node": ">= 14.0.0" } }, - "@babel/helper-validator-identifier": { - "version": "7.12.11", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.12.11.tgz", - "integrity": "sha512-np/lG3uARFybkoHokJUmf1QfEvRVCPbmQeUQpKow5cQ3xWrV9i3rUHodKDJPQfTVX61qKi+UdYk8kik84n7XOw==", - "dev": true + "node_modules/@algolia/client-search": { + "version": "5.46.3", + "resolved": "https://registry.npmjs.org/@algolia/client-search/-/client-search-5.46.3.tgz", + "integrity": "sha512-hfpCIukPuwkrlwsYfJEWdU5R5bduBHEq2uuPcqmgPgNq5MSjmiNIzRuzxGZZgiBKcre6gZT00DR7G1AFn//wiQ==", + "dev": true, + "license": "MIT", + "peer": true, + "dependencies": { + "@algolia/client-common": "5.46.3", + "@algolia/requester-browser-xhr": "5.46.3", + "@algolia/requester-fetch": "5.46.3", + "@algolia/requester-node-http": "5.46.3" + }, + "engines": { + "node": ">= 14.0.0" + } }, - "@babel/helpers": { - "version": "7.12.13", - "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.12.13.tgz", - "integrity": "sha512-oohVzLRZ3GQEk4Cjhfs9YkJA4TdIDTObdBEZGrd6F/T0GPSnuV6l22eMcxlvcvzVIPH3VTtxbseudM1zIE+rPQ==", + "node_modules/@algolia/ingestion": { + "version": "1.46.3", + "resolved": "https://registry.npmjs.org/@algolia/ingestion/-/ingestion-1.46.3.tgz", + "integrity": "sha512-ChVzNkCzAVxKozTnTgPWCG69WQLjzW7X6OqD91zUh8U38ZhPEX/t3qGhXs+M9ZNaHcJ7xToMB3jywNwONhpLGA==", "dev": true, - "requires": { - "@babel/template": "^7.12.13", - "@babel/traverse": "^7.12.13", - "@babel/types": "^7.12.13" + "license": "MIT", + "dependencies": { + "@algolia/client-common": "5.46.3", + "@algolia/requester-browser-xhr": "5.46.3", + "@algolia/requester-fetch": "5.46.3", + "@algolia/requester-node-http": "5.46.3" + }, + "engines": { + "node": ">= 14.0.0" } }, - "@babel/highlight": { - "version": "7.12.13", - "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.12.13.tgz", - "integrity": "sha512-kocDQvIbgMKlWxXe9fof3TQ+gkIPOUSEYhJjqUjvKMez3krV7vbzYCDq39Oj11UAVK7JqPVGQPlgE85dPNlQww==", + "node_modules/@algolia/monitoring": { + "version": "1.46.3", + "resolved": "https://registry.npmjs.org/@algolia/monitoring/-/monitoring-1.46.3.tgz", + "integrity": "sha512-MZa+Z5iPmVMxVAQ0aq4HpGsja5utSLEMcOuY01X8D46vvMrSPkP8DnlDFtu1PgJ0RwyIGqqx7v+ClFo6iRJ6bA==", "dev": true, - "requires": { - "@babel/helper-validator-identifier": "^7.12.11", - "chalk": "^2.0.0", - "js-tokens": "^4.0.0" + "license": "MIT", + "dependencies": { + "@algolia/client-common": "5.46.3", + "@algolia/requester-browser-xhr": "5.46.3", + "@algolia/requester-fetch": "5.46.3", + "@algolia/requester-node-http": "5.46.3" + }, + "engines": { + "node": ">= 14.0.0" } }, - "@babel/parser": { - "version": "7.12.16", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.12.16.tgz", - "integrity": "sha512-c/+u9cqV6F0+4Hpq01jnJO+GLp2DdT63ppz9Xa+6cHaajM9VFzK/iDXiKK65YtpeVwu+ctfS6iqlMqRgQRzeCw==", - "dev": true + "node_modules/@algolia/recommend": { + "version": "5.46.3", + "resolved": "https://registry.npmjs.org/@algolia/recommend/-/recommend-5.46.3.tgz", + "integrity": "sha512-cr3atJRJBKgAKZl/Oxo4sig6Se0+ukbyIOOluPV5H+ZAXVcxuMoXQgwQ1M5UHPnCnEsZ4uBXhBmilRgUQpUegw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@algolia/client-common": "5.46.3", + "@algolia/requester-browser-xhr": "5.46.3", + "@algolia/requester-fetch": "5.46.3", + "@algolia/requester-node-http": "5.46.3" + }, + "engines": { + "node": ">= 14.0.0" + } }, - "@babel/template": { - "version": "7.12.13", - "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.12.13.tgz", - "integrity": "sha512-/7xxiGA57xMo/P2GVvdEumr8ONhFOhfgq2ihK3h1e6THqzTAkHbkXgB0xI9yeTfIUoH3+oAeHhqm/I43OTbbjA==", - "dev": true, - "requires": { - "@babel/code-frame": "^7.12.13", - "@babel/parser": "^7.12.13", - "@babel/types": "^7.12.13" - } - }, - "@babel/traverse": { - "version": "7.12.13", - "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.12.13.tgz", - "integrity": "sha512-3Zb4w7eE/OslI0fTp8c7b286/cQps3+vdLW3UcwC8VSJC6GbKn55aeVVu2QJNuCDoeKyptLOFrPq8WqZZBodyA==", - "dev": true, - "requires": { - "@babel/code-frame": "^7.12.13", - "@babel/generator": "^7.12.13", - "@babel/helper-function-name": "^7.12.13", - "@babel/helper-split-export-declaration": "^7.12.13", - "@babel/parser": "^7.12.13", - "@babel/types": "^7.12.13", - "debug": "^4.1.0", - "globals": "^11.1.0", - "lodash": "^4.17.19" + "node_modules/@algolia/requester-browser-xhr": { + "version": "5.46.3", + "resolved": "https://registry.npmjs.org/@algolia/requester-browser-xhr/-/requester-browser-xhr-5.46.3.tgz", + "integrity": "sha512-/Ku9GImJf2SKoRM2S3e03MjCVaWJCP5olih4k54DRhNDdmxBkd3nsWuUXvDElY3Ucw/arBYGs5SYz79SoS5APw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@algolia/client-common": "5.46.3" }, + "engines": { + "node": ">= 14.0.0" + } + }, + "node_modules/@algolia/requester-fetch": { + "version": "5.46.3", + "resolved": "https://registry.npmjs.org/@algolia/requester-fetch/-/requester-fetch-5.46.3.tgz", + "integrity": "sha512-Uw+SPy/zpfwbH1AxQaeOWvWVzPEcO0XbtLbbSz0HPcEIiBGWyfa9LUCxD5UferbDjrSQNVimmzl3FaWi4u8Ykw==", + "dev": true, + "license": "MIT", "dependencies": { - "globals": { - "version": "11.12.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", - "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==", - "dev": true - } + "@algolia/client-common": "5.46.3" + }, + "engines": { + "node": ">= 14.0.0" } }, - "@babel/types": { - "version": "7.12.13", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.12.13.tgz", - "integrity": "sha512-oKrdZTld2im1z8bDwTOQvUbxKwE+854zc16qWZQlcTqMN00pWxHQ4ZeOq0yDMnisOpRykH2/5Qqcrk/OlbAjiQ==", + "node_modules/@algolia/requester-node-http": { + "version": "5.46.3", + "resolved": "https://registry.npmjs.org/@algolia/requester-node-http/-/requester-node-http-5.46.3.tgz", + "integrity": "sha512-4No9iTjr1GZ0JWsFbQJj9aZBnmKyY1sTxOoEud9+SGe3U6iAulF0A0lI4cWi/F/Gcfg8V3jkaddcqSQKDnE45w==", "dev": true, - "requires": { - "@babel/helper-validator-identifier": "^7.12.11", - "lodash": "^4.17.19", - "to-fast-properties": "^2.0.0" + "license": "MIT", + "dependencies": { + "@algolia/client-common": "5.46.3" + }, + "engines": { + "node": ">= 14.0.0" } }, - "@eslint/eslintrc": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-0.3.0.tgz", - "integrity": "sha512-1JTKgrOKAHVivSvOYw+sJOunkBjUOvjqWk1DPja7ZFhIS2mX/4EgTT8M7eTK9jrKhL/FvXXEbQwIs3pg1xp3dg==", + "node_modules/@alloc/quick-lru": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/@alloc/quick-lru/-/quick-lru-5.2.0.tgz", + "integrity": "sha512-UrcABB+4bUrFABwbluTIBErXwvbsU/V7TZWfmbgJfbkwiBuziS9gxdODUyuiecfdGQ85jglMW6juS3+z5TsKLw==", "dev": true, - "requires": { - "ajv": "^6.12.4", - "debug": "^4.1.1", - "espree": "^7.3.0", - "globals": "^12.1.0", - "ignore": "^4.0.6", - "import-fresh": "^3.2.1", - "js-yaml": "^3.13.1", - "lodash": "^4.17.20", - "minimatch": "^3.0.4", - "strip-json-comments": "^3.1.1" + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, - "@istanbuljs/load-nyc-config": { + "node_modules/@antfu/install-pkg": { "version": "1.1.0", - "resolved": "https://registry.npmjs.org/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz", - "integrity": "sha512-VjeHSlIzpv/NyD3N0YuHfXOPDIixcA1q2ZV98wsMqcYlPmv2n3Yb2lYP9XMElnaFVXg5A7YLTeLu6V84uQDjmQ==", + "resolved": "https://registry.npmjs.org/@antfu/install-pkg/-/install-pkg-1.1.0.tgz", + "integrity": "sha512-MGQsmw10ZyI+EJo45CdSER4zEb+p31LpDAFp2Z3gkSd1yqVZGi0Ebx++YTEMonJy4oChEMLsxZ64j8FH6sSqtQ==", "dev": true, - "requires": { - "camelcase": "^5.3.1", - "find-up": "^4.1.0", - "get-package-type": "^0.1.0", - "js-yaml": "^3.13.1", - "resolve-from": "^5.0.0" - }, + "license": "MIT", "dependencies": { - "camelcase": { - "version": "5.3.1", - "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", - "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==", - "dev": true - }, - "find-up": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", - "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", - "dev": true, - "requires": { - "locate-path": "^5.0.0", - "path-exists": "^4.0.0" - } - }, - "locate-path": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", - "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", - "dev": true, - "requires": { - "p-locate": "^4.1.0" - } - }, - "p-limit": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", - "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", - "dev": true, - "requires": { - "p-try": "^2.0.0" - } - }, - "p-locate": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", - "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", - "dev": true, - "requires": { - "p-limit": "^2.2.0" - } - }, - "p-try": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", - "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", - "dev": true - }, - "path-exists": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", - "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", - "dev": true - }, - "resolve-from": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-5.0.0.tgz", - "integrity": "sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==", - "dev": true - } + "package-manager-detector": "^1.3.0", + "tinyexec": "^1.0.1" + }, + "funding": { + "url": "https://github.com/sponsors/antfu" } }, - "@istanbuljs/schema": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/@istanbuljs/schema/-/schema-0.1.2.tgz", - "integrity": "sha512-tsAQNx32a8CoFhjhijUIhI4kccIAgmGhy8LZMZgGfmXcpMbPRUqn5LWmgRttILi6yeGmBJd2xsPkFMs0PzgPCw==", - "dev": true - }, - "@rollup/plugin-alias": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/@rollup/plugin-alias/-/plugin-alias-3.1.2.tgz", - "integrity": "sha512-wzDnQ6v7CcoRzS0qVwFPrFdYA4Qlr+ookA217Y2Z3DPZE1R8jrFNM3jvGgOf6o6DMjbnQIn5lCIJgHPe1Bt3uw==", + "node_modules/@babel/code-frame": { + "version": "7.28.6", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.28.6.tgz", + "integrity": "sha512-JYgintcMjRiCvS8mMECzaEn+m3PfoQiyqukOMCCVQtoJGYJw8j/8LBJEiqkHLkfwCcs74E3pbAUFNg7d9VNJ+Q==", "dev": true, - "requires": { - "slash": "^3.0.0" + "license": "MIT", + "dependencies": { + "@babel/helper-validator-identifier": "^7.28.5", + "js-tokens": "^4.0.0", + "picocolors": "^1.1.1" + }, + "engines": { + "node": ">=6.9.0" } }, - "@rollup/plugin-buble": { - "version": "0.21.3", - "resolved": "https://registry.npmjs.org/@rollup/plugin-buble/-/plugin-buble-0.21.3.tgz", - "integrity": "sha512-Iv8cCuFPnMdqV4pcyU+OrfjOfagPArRQ1PyQjx5KgHk3dARedI+8PNTLSMpJts0lQJr8yF2pAU4GxpxCBJ9HYw==", + "node_modules/@babel/compat-data": { + "version": "7.28.6", + "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.28.6.tgz", + "integrity": "sha512-2lfu57JtzctfIrcGMz992hyLlByuzgIk58+hhGCxjKZ3rWI82NnVLjXcaTqkI2NvlcvOskZaiZ5kjUALo3Lpxg==", "dev": true, - "requires": { - "@rollup/pluginutils": "^3.0.8", - "@types/buble": "^0.19.2", - "buble": "^0.20.0" + "license": "MIT", + "engines": { + "node": ">=6.9.0" } }, - "@rollup/plugin-commonjs": { - "version": "18.0.0-1", - "resolved": "https://registry.npmjs.org/@rollup/plugin-commonjs/-/plugin-commonjs-18.0.0-1.tgz", - "integrity": "sha512-DjOATQ12VbKdXHpmvu+dhaUFVVOieoN748ssdoeZZpHq/DHVOUXHKTWva137kC6oMRpspYJu8ve7ksSAynuKwg==", + "node_modules/@babel/core": { + "version": "7.28.6", + "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.28.6.tgz", + "integrity": "sha512-H3mcG6ZDLTlYfaSNi0iOKkigqMFvkTKlGUYlD8GW7nNOYRrevuA46iTypPyv+06V3fEmvvazfntkBU34L0azAw==", "dev": true, - "requires": { - "@rollup/pluginutils": "^3.1.0", - "commondir": "^1.0.1", - "estree-walker": "^2.0.1", - "glob": "^7.1.6", - "is-reference": "^1.2.1", - "magic-string": "^0.25.7", - "resolve": "^1.17.0" - }, + "license": "MIT", + "peer": true, "dependencies": { - "estree-walker": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz", - "integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==", - "dev": true - }, - "is-reference": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/is-reference/-/is-reference-1.2.1.tgz", - "integrity": "sha512-U82MsXXiFIrjCK4otLT+o2NA2Cd2g5MLoOVXUZjIOhLurrRxpEXzI8O0KZHr3IjLvlAH1kTPYSuqer5T9ZVBKQ==", - "dev": true, - "requires": { - "@types/estree": "*" - } - } + "@babel/code-frame": "^7.28.6", + "@babel/generator": "^7.28.6", + "@babel/helper-compilation-targets": "^7.28.6", + "@babel/helper-module-transforms": "^7.28.6", + "@babel/helpers": "^7.28.6", + "@babel/parser": "^7.28.6", + "@babel/template": "^7.28.6", + "@babel/traverse": "^7.28.6", + "@babel/types": "^7.28.6", + "@jridgewell/remapping": "^2.3.5", + "convert-source-map": "^2.0.0", + "debug": "^4.1.0", + "gensync": "^1.0.0-beta.2", + "json5": "^2.2.3", + "semver": "^6.3.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/babel" } }, - "@rollup/plugin-json": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/@rollup/plugin-json/-/plugin-json-4.1.0.tgz", - "integrity": "sha512-yfLbTdNS6amI/2OpmbiBoW12vngr5NW2jCJVZSBEz+H5KfUJZ2M7sDjk0U6GOOdCWFVScShte29o9NezJ53TPw==", + "node_modules/@babel/core/node_modules/convert-source-map": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-2.0.0.tgz", + "integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==", "dev": true, - "requires": { - "@rollup/pluginutils": "^3.0.8" - } + "license": "MIT" }, - "@rollup/plugin-node-resolve": { - "version": "11.1.1", - "resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-11.1.1.tgz", - "integrity": "sha512-zlBXR4eRS+2m79TsUZWhsd0slrHUYdRx4JF+aVQm+MI0wsKdlpC2vlDVjmlGvtZY1vsefOT9w3JxvmWSBei+Lg==", + "node_modules/@babel/generator": { + "version": "7.28.6", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.28.6.tgz", + "integrity": "sha512-lOoVRwADj8hjf7al89tvQ2a1lf53Z+7tiXMgpZJL3maQPDxh0DgLMN62B2MKUOFcoodBHLMbDM6WAbKgNy5Suw==", "dev": true, - "requires": { - "@rollup/pluginutils": "^3.1.0", - "@types/resolve": "1.17.1", - "builtin-modules": "^3.1.0", - "deepmerge": "^4.2.2", - "is-module": "^1.0.0", - "resolve": "^1.19.0" + "license": "MIT", + "dependencies": { + "@babel/parser": "^7.28.6", + "@babel/types": "^7.28.6", + "@jridgewell/gen-mapping": "^0.3.12", + "@jridgewell/trace-mapping": "^0.3.28", + "jsesc": "^3.0.2" + }, + "engines": { + "node": ">=6.9.0" } }, - "@rollup/plugin-replace": { - "version": "2.3.4", - "resolved": "https://registry.npmjs.org/@rollup/plugin-replace/-/plugin-replace-2.3.4.tgz", - "integrity": "sha512-waBhMzyAtjCL1GwZes2jaE9MjuQ/DQF2BatH3fRivUF3z0JBFrU0U6iBNC/4WR+2rLKhaAhPWDNPYp4mI6RqdQ==", + "node_modules/@babel/helper-compilation-targets": { + "version": "7.28.6", + "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.28.6.tgz", + "integrity": "sha512-JYtls3hqi15fcx5GaSNL7SCTJ2MNmjrkHXg4FSpOA/grxK8KwyZ5bubHsCq8FXCkua6xhuaaBit+3b7+VZRfcA==", "dev": true, - "requires": { - "@rollup/pluginutils": "^3.1.0", - "magic-string": "^0.25.7" + "license": "MIT", + "dependencies": { + "@babel/compat-data": "^7.28.6", + "@babel/helper-validator-option": "^7.27.1", + "browserslist": "^4.24.0", + "lru-cache": "^5.1.1", + "semver": "^6.3.1" + }, + "engines": { + "node": ">=6.9.0" } }, - "@rollup/pluginutils": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-3.1.0.tgz", - "integrity": "sha512-GksZ6pr6TpIjHm8h9lSQ8pi8BE9VeubNT0OMJ3B5uZJ8pz73NPiqOtCog/x2/QzM1ENChPKxMDhiQuRHsqc+lg==", + "node_modules/@babel/helper-globals": { + "version": "7.28.0", + "resolved": "https://registry.npmjs.org/@babel/helper-globals/-/helper-globals-7.28.0.tgz", + "integrity": "sha512-+W6cISkXFa1jXsDEdYA8HeevQT/FULhxzR99pxphltZcVaugps53THCeiWA8SguxxpSp3gKPiuYfSWopkLQ4hw==", "dev": true, - "requires": { - "@types/estree": "0.0.39", - "estree-walker": "^1.0.1", - "picomatch": "^2.2.2" + "license": "MIT", + "engines": { + "node": ">=6.9.0" } }, - "@types/braces": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/@types/braces/-/braces-3.0.0.tgz", - "integrity": "sha512-TbH79tcyi9FHwbyboOKeRachRq63mSuWYXOflsNO9ZyE5ClQ/JaozNKl+aWUq87qPNsXasXxi2AbgfwIJ+8GQw==", - "dev": true + "node_modules/@babel/helper-module-imports": { + "version": "7.28.6", + "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.28.6.tgz", + "integrity": "sha512-l5XkZK7r7wa9LucGw9LwZyyCUscb4x37JWTPz7swwFE/0FMQAGpiWUZn8u9DzkSBWEcK25jmvubfpw2dnAMdbw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/traverse": "^7.28.6", + "@babel/types": "^7.28.6" + }, + "engines": { + "node": ">=6.9.0" + } }, - "@types/buble": { - "version": "0.19.2", - "resolved": "https://registry.npmjs.org/@types/buble/-/buble-0.19.2.tgz", - "integrity": "sha512-uUD8zIfXMKThmFkahTXDGI3CthFH1kMg2dOm3KLi4GlC5cbARA64bEcUMbbWdWdE73eoc/iBB9PiTMqH0dNS2Q==", + "node_modules/@babel/helper-module-transforms": { + "version": "7.28.6", + "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.28.6.tgz", + "integrity": "sha512-67oXFAYr2cDLDVGLXTEABjdBJZ6drElUSI7WKp70NrpyISso3plG9SAGEF6y7zbha/wOzUByWWTJvEDVNIUGcA==", "dev": true, - "requires": { - "magic-string": "^0.25.0" + "license": "MIT", + "dependencies": { + "@babel/helper-module-imports": "^7.28.6", + "@babel/helper-validator-identifier": "^7.28.5", + "@babel/traverse": "^7.28.6" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0" } }, - "@types/estree": { - "version": "0.0.39", - "resolved": "https://registry.npmjs.org/@types/estree/-/estree-0.0.39.tgz", - "integrity": "sha512-EYNwp3bU+98cpU4lAWYYL7Zz+2gryWH1qbdDTidVd6hkiR6weksdbMadyXKXNPEkQFhXM+hVO9ZygomHXp+AIw==", - "dev": true + "node_modules/@babel/helper-string-parser": { + "version": "7.27.1", + "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.27.1.tgz", + "integrity": "sha512-qMlSxKbpRlAridDExk92nSobyDdpPijUq2DW6oDnUqd0iOGxmQjyqhMIihI9+zv4LPyZdRje2cavWPbCbWm3eA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } }, - "@types/fs-extra": { - "version": "8.1.1", - "resolved": "https://registry.npmjs.org/@types/fs-extra/-/fs-extra-8.1.1.tgz", - "integrity": "sha512-TcUlBem321DFQzBNuz8p0CLLKp0VvF/XH9E4KHNmgwyp4E3AfgI5cjiIVZWlbfThBop2qxFIh4+LeY6hVWWZ2w==", + "node_modules/@babel/helper-validator-identifier": { + "version": "7.28.5", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.28.5.tgz", + "integrity": "sha512-qSs4ifwzKJSV39ucNjsvc6WVHs6b7S03sOh2OcHF9UHfVPqWWALUsNUVzhSBiItjRZoLHx7nIarVjqKVusUZ1Q==", "dev": true, - "requires": { - "@types/node": "*" + "license": "MIT", + "engines": { + "node": ">=6.9.0" } }, - "@types/glob": { - "version": "7.1.3", - "resolved": "https://registry.npmjs.org/@types/glob/-/glob-7.1.3.tgz", - "integrity": "sha512-SEYeGAIQIQX8NN6LDKprLjbrd5dARM5EXsd8GI/A5l0apYI1fGMWgPHSe4ZKL4eozlAyI+doUE9XbYS4xCkQ1w==", + "node_modules/@babel/helper-validator-option": { + "version": "7.27.1", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.27.1.tgz", + "integrity": "sha512-YvjJow9FxbhFFKDSuFnVCe2WxXk1zWc22fFePVNEaWJEu8IrZVlda6N0uHwzZrUM1il7NC9Mlp4MaJYbYd9JSg==", "dev": true, - "requires": { - "@types/minimatch": "*", - "@types/node": "*" + "license": "MIT", + "engines": { + "node": ">=6.9.0" } }, - "@types/json5": { - "version": "0.0.29", - "resolved": "https://registry.npmjs.org/@types/json5/-/json5-0.0.29.tgz", - "integrity": "sha1-7ihweulOEdK4J7y+UnC86n8+ce4=", - "dev": true + "node_modules/@babel/helpers": { + "version": "7.28.6", + "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.28.6.tgz", + "integrity": "sha512-xOBvwq86HHdB7WUDTfKfT/Vuxh7gElQ+Sfti2Cy6yIWNW05P8iUslOVcZ4/sKbE+/jQaukQAdz/gf3724kYdqw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/template": "^7.28.6", + "@babel/types": "^7.28.6" + }, + "engines": { + "node": ">=6.9.0" + } }, - "@types/micromatch": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/@types/micromatch/-/micromatch-4.0.1.tgz", - "integrity": "sha512-my6fLBvpY70KattTNzYOK6KU1oR1+UCz9ug/JbcF5UrEmeCt9P7DV2t7L8+t18mMPINqGQCE4O8PLOPbI84gxw==", + "node_modules/@babel/parser": { + "version": "7.28.6", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.28.6.tgz", + "integrity": "sha512-TeR9zWR18BvbfPmGbLampPMW+uW1NZnJlRuuHso8i87QZNq2JRF9i6RgxRqtEq+wQGsS19NNTWr2duhnE49mfQ==", "dev": true, - "requires": { - "@types/braces": "*" + "license": "MIT", + "dependencies": { + "@babel/types": "^7.28.6" + }, + "bin": { + "parser": "bin/babel-parser.js" + }, + "engines": { + "node": ">=6.0.0" } }, - "@types/minimatch": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/@types/minimatch/-/minimatch-3.0.3.tgz", - "integrity": "sha512-tHq6qdbT9U1IRSGf14CL0pUlULksvY9OZ+5eEgl1N7t+OA3tGvNpxJCzuKQlsNgCVwbAs670L1vcVQi8j9HjnA==", - "dev": true + "node_modules/@babel/template": { + "version": "7.28.6", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.28.6.tgz", + "integrity": "sha512-YA6Ma2KsCdGb+WC6UpBVFJGXL58MDA6oyONbjyF/+5sBgxY/dwkhLogbMT2GXXyU84/IhRw/2D1Os1B/giz+BQ==", + "dev": true, + "license": "MIT", + "peer": true, + "dependencies": { + "@babel/code-frame": "^7.28.6", + "@babel/parser": "^7.28.6", + "@babel/types": "^7.28.6" + }, + "engines": { + "node": ">=6.9.0" + } }, - "@types/node": { - "version": "10.17.51", - "resolved": "https://registry.npmjs.org/@types/node/-/node-10.17.51.tgz", - "integrity": "sha512-KANw+MkL626tq90l++hGelbl67irOJzGhUJk6a1Bt8QHOeh9tztJx+L0AqttraWKinmZn7Qi5lJZJzx45Gq0dg==", - "dev": true + "node_modules/@babel/traverse": { + "version": "7.28.6", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.28.6.tgz", + "integrity": "sha512-fgWX62k02qtjqdSNTAGxmKYY/7FSL9WAS1o2Hu5+I5m9T0yxZzr4cnrfXQ/MX0rIifthCSs6FKTlzYbJcPtMNg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/code-frame": "^7.28.6", + "@babel/generator": "^7.28.6", + "@babel/helper-globals": "^7.28.0", + "@babel/parser": "^7.28.6", + "@babel/template": "^7.28.6", + "@babel/types": "^7.28.6", + "debug": "^4.3.1" + }, + "engines": { + "node": ">=6.9.0" + } }, - "@types/parse-json": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/@types/parse-json/-/parse-json-4.0.0.tgz", - "integrity": "sha512-//oorEZjL6sbPcKUaCdIGlIUeH26mgzimjBB77G6XRgnDl/L5wOnpyBGRe/Mmf5CVW3PwEBE1NjiMZ/ssFh4wA==", - "dev": true + "node_modules/@babel/types": { + "version": "7.28.6", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.28.6.tgz", + "integrity": "sha512-0ZrskXVEHSWIqZM/sQZ4EV3jZJXRkio/WCxaqKZP1g//CEWEPSfeZFcms4XeKBCHU0ZKnIkdJeU/kF+eRp5lBg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-string-parser": "^7.27.1", + "@babel/helper-validator-identifier": "^7.28.5" + }, + "engines": { + "node": ">=6.9.0" + } }, - "@types/require-relative": { - "version": "0.8.0", - "resolved": "https://registry.npmjs.org/@types/require-relative/-/require-relative-0.8.0.tgz", - "integrity": "sha512-3xDLWkeSGvkRmTWOhJS+WjqT7QT8oacisRorMQypA9Y3BSRnpzu0J0+YJUcNY4Kmg8vY+A4vAwc8qwM82k3cMA==", - "dev": true + "node_modules/@braintree/sanitize-url": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/@braintree/sanitize-url/-/sanitize-url-7.1.1.tgz", + "integrity": "sha512-i1L7noDNxtFyL5DmZafWy1wRVhGehQmzZaz1HiN5e7iylJMSZR7ekOV7NsIqa5qBldlLrsKv4HbgFUVlQrz8Mw==", + "dev": true, + "license": "MIT" }, - "@types/resolve": { - "version": "1.17.1", - "resolved": "https://registry.npmjs.org/@types/resolve/-/resolve-1.17.1.tgz", - "integrity": "sha512-yy7HuzQhj0dhGpD8RLXSZWEkLsV9ibvxvi6EiJ3bkqLAO1RGo0WbkWQiwpRlSFymTJRz0d3k5LM3kkx8ArDbLw==", + "node_modules/@chevrotain/cst-dts-gen": { + "version": "11.0.3", + "resolved": "https://registry.npmjs.org/@chevrotain/cst-dts-gen/-/cst-dts-gen-11.0.3.tgz", + "integrity": "sha512-BvIKpRLeS/8UbfxXxgC33xOumsacaeCKAjAeLyOn7Pcp95HiRbrpl14S+9vaZLolnbssPIUuiUd8IvgkRyt6NQ==", "dev": true, - "requires": { - "@types/node": "*" + "license": "Apache-2.0", + "dependencies": { + "@chevrotain/gast": "11.0.3", + "@chevrotain/types": "11.0.3", + "lodash-es": "4.17.21" } }, - "@types/rimraf": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/@types/rimraf/-/rimraf-2.0.4.tgz", - "integrity": "sha512-8gBudvllD2A/c0CcEX/BivIDorHFt5UI5m46TsNj8DjWCCTTZT74kEe4g+QsY7P/B9WdO98d82zZgXO/RQzu2Q==", + "node_modules/@chevrotain/cst-dts-gen/node_modules/lodash-es": { + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/lodash-es/-/lodash-es-4.17.21.tgz", + "integrity": "sha512-mKnC+QJ9pWVzv+C4/U3rRsHapFfHvQFoFB92e52xeyGMcX6/OlIl78je1u8vePzYZSkkogMPJ2yjxxsb89cxyw==", "dev": true, - "requires": { - "@types/glob": "*", - "@types/node": "*" + "license": "MIT" + }, + "node_modules/@chevrotain/gast": { + "version": "11.0.3", + "resolved": "https://registry.npmjs.org/@chevrotain/gast/-/gast-11.0.3.tgz", + "integrity": "sha512-+qNfcoNk70PyS/uxmj3li5NiECO+2YKZZQMbmjTqRI3Qchu8Hig/Q9vgkHpI3alNjr7M+a2St5pw5w5F6NL5/Q==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@chevrotain/types": "11.0.3", + "lodash-es": "4.17.21" } }, - "@types/signal-exit": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/@types/signal-exit/-/signal-exit-3.0.0.tgz", - "integrity": "sha512-MaJ+16SOXz0Z27EMf3d88+B6UDglq1sn140a+5X/ROLkIcEfRq0CPg+1B2efF1GXQn4n+aKH4ti2hHG4Ya+Dzg==", - "dev": true + "node_modules/@chevrotain/gast/node_modules/lodash-es": { + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/lodash-es/-/lodash-es-4.17.21.tgz", + "integrity": "sha512-mKnC+QJ9pWVzv+C4/U3rRsHapFfHvQFoFB92e52xeyGMcX6/OlIl78je1u8vePzYZSkkogMPJ2yjxxsb89cxyw==", + "dev": true, + "license": "MIT" }, - "@types/yargs-parser": { - "version": "20.2.0", - "resolved": "https://registry.npmjs.org/@types/yargs-parser/-/yargs-parser-20.2.0.tgz", - "integrity": "sha512-37RSHht+gzzgYeobbG+KWryeAW8J33Nhr69cjTqSYymXVZEN9NbRYWoYlRtDhHKPVT1FyNKwaTPC1NynKZpzRA==", - "dev": true + "node_modules/@chevrotain/regexp-to-ast": { + "version": "11.0.3", + "resolved": "https://registry.npmjs.org/@chevrotain/regexp-to-ast/-/regexp-to-ast-11.0.3.tgz", + "integrity": "sha512-1fMHaBZxLFvWI067AVbGJav1eRY7N8DDvYCTwGBiE/ytKBgP8azTdgyrKyWZ9Mfh09eHWb5PgTSO8wi7U824RA==", + "dev": true, + "license": "Apache-2.0" }, - "@ungap/promise-all-settled": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/@ungap/promise-all-settled/-/promise-all-settled-1.1.2.tgz", - "integrity": "sha512-sL/cEvJWAnClXw0wHk85/2L0G6Sj8UB0Ctc1TEMbKSsmpRosqhwj9gWgFRZSrBr2f9tiXISwNhCPmlfqUqyb9Q==", - "dev": true + "node_modules/@chevrotain/types": { + "version": "11.0.3", + "resolved": "https://registry.npmjs.org/@chevrotain/types/-/types-11.0.3.tgz", + "integrity": "sha512-gsiM3G8b58kZC2HaWR50gu6Y1440cHiJ+i3JUvcp/35JchYejb2+5MVeJK0iKThYpAa/P2PYFV4hoi44HD+aHQ==", + "dev": true, + "license": "Apache-2.0" }, - "acorn": { - "version": "8.0.5", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.0.5.tgz", - "integrity": "sha512-v+DieK/HJkJOpFBETDJioequtc3PfxsWMaxIdIwujtF7FEV/MAyDQLlm6/zPvr7Mix07mLh6ccVwIsloceodlg==", - "dev": true + "node_modules/@chevrotain/utils": { + "version": "11.0.3", + "resolved": "https://registry.npmjs.org/@chevrotain/utils/-/utils-11.0.3.tgz", + "integrity": "sha512-YslZMgtJUyuMbZ+aKvfF3x1f5liK4mWNxghFRv7jqRR9C3R3fAOGTTKvxXDa2Y1s9zSbcpuO0cAxDYsc9SrXoQ==", + "dev": true, + "license": "Apache-2.0" }, - "acorn-class-fields": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/acorn-class-fields/-/acorn-class-fields-1.0.0.tgz", - "integrity": "sha512-l+1FokF34AeCXGBHkrXFmml9nOIRI+2yBnBpO5MaVAaTIJ96irWLtcCxX+7hAp6USHFCe+iyyBB4ZhxV807wmA==", + "node_modules/@codemirror/autocomplete": { + "version": "6.20.0", + "resolved": "https://registry.npmjs.org/@codemirror/autocomplete/-/autocomplete-6.20.0.tgz", + "integrity": "sha512-bOwvTOIJcG5FVo5gUUupiwYh8MioPLQ4UcqbcRf7UQ98X90tCa9E1kZ3Z7tqwpZxYyOvh1YTYbmZE9RTfTp5hg==", "dev": true, - "requires": { - "acorn-private-class-elements": "^1.0.0" + "license": "MIT", + "dependencies": { + "@codemirror/language": "^6.0.0", + "@codemirror/state": "^6.0.0", + "@codemirror/view": "^6.17.0", + "@lezer/common": "^1.0.0" } }, - "acorn-dynamic-import": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/acorn-dynamic-import/-/acorn-dynamic-import-4.0.0.tgz", - "integrity": "sha512-d3OEjQV4ROpoflsnUA8HozoIR504TFxNivYEUi6uwz0IYhBkTDXGuWlNdMtybRt3nqVx/L6XqMt0FxkXuWKZhw==", - "dev": true - }, - "acorn-jsx": { - "version": "5.3.1", - "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.1.tgz", - "integrity": "sha512-K0Ptm/47OKfQRpNQ2J/oIN/3QYiK6FwW+eJbILhsdxh2WTLdl+30o8aGdTbm5JbffpFFAg/g+zi1E+jvJha5ng==", - "dev": true - }, - "acorn-private-class-elements": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/acorn-private-class-elements/-/acorn-private-class-elements-1.0.0.tgz", - "integrity": "sha512-zYNcZtxKgVCg1brS39BEou86mIao1EV7eeREG+6WMwKbuYTeivRRs6S2XdWnboRde6G9wKh2w+WBydEyJsJ6mg==", - "dev": true - }, - "acorn-private-methods": { - "version": "1.0.0", - "resolved": "https://greenlight.jfrog.io/artifactory/api/npm/npm/acorn-private-methods/-/acorn-private-methods-1.0.0.tgz", - "integrity": "sha1-tI9MA6FRzIJi9vXKj1f3xawkUYQ=", + "node_modules/@codemirror/commands": { + "version": "6.10.1", + "resolved": "https://registry.npmjs.org/@codemirror/commands/-/commands-6.10.1.tgz", + "integrity": "sha512-uWDWFypNdQmz2y1LaNJzK7fL7TYKLeUAU0npEC685OKTF3KcQ2Vu3klIM78D7I6wGhktme0lh3CuQLv0ZCrD9Q==", "dev": true, - "requires": { - "acorn-private-class-elements": "^1.0.0" + "license": "MIT", + "dependencies": { + "@codemirror/language": "^6.0.0", + "@codemirror/state": "^6.4.0", + "@codemirror/view": "^6.27.0", + "@lezer/common": "^1.1.0" } }, - "acorn-static-class-features": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/acorn-static-class-features/-/acorn-static-class-features-1.0.0.tgz", - "integrity": "sha512-XZJECjbmMOKvMHiNzbiPXuXpLAJfN3dAKtfIYbk1eHiWdsutlek+gS7ND4B8yJ3oqvHo1NxfafnezVmq7NXK0A==", + "node_modules/@codemirror/lang-javascript": { + "version": "6.2.4", + "resolved": "https://registry.npmjs.org/@codemirror/lang-javascript/-/lang-javascript-6.2.4.tgz", + "integrity": "sha512-0WVmhp1QOqZ4Rt6GlVGwKJN3KW7Xh4H2q8ZZNGZaP6lRdxXJzmjm4FqvmOojVj6khWJHIb9sp7U/72W7xQgqAA==", "dev": true, - "requires": { - "acorn-private-class-elements": "^1.0.0" + "license": "MIT", + "dependencies": { + "@codemirror/autocomplete": "^6.0.0", + "@codemirror/language": "^6.6.0", + "@codemirror/lint": "^6.0.0", + "@codemirror/state": "^6.0.0", + "@codemirror/view": "^6.17.0", + "@lezer/common": "^1.0.0", + "@lezer/javascript": "^1.0.0" } }, - "acorn-walk": { - "version": "8.0.2", - "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.0.2.tgz", - "integrity": "sha512-+bpA9MJsHdZ4bgfDcpk0ozQyhhVct7rzOmO0s1IIr0AGGgKBljss8n2zp11rRP2wid5VGeh04CgeKzgat5/25A==", - "dev": true + "node_modules/@codemirror/language": { + "version": "6.12.1", + "resolved": "https://registry.npmjs.org/@codemirror/language/-/language-6.12.1.tgz", + "integrity": "sha512-Fa6xkSiuGKc8XC8Cn96T+TQHYj4ZZ7RdFmXA3i9xe/3hLHfwPZdM+dqfX0Cp0zQklBKhVD8Yzc8LS45rkqcwpQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@codemirror/state": "^6.0.0", + "@codemirror/view": "^6.23.0", + "@lezer/common": "^1.5.0", + "@lezer/highlight": "^1.0.0", + "@lezer/lr": "^1.0.0", + "style-mod": "^4.0.0" + } }, - "aggregate-error": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/aggregate-error/-/aggregate-error-3.1.0.tgz", - "integrity": "sha512-4I7Td01quW/RpocfNayFdFVk1qSuoh0E7JrbRJ16nH01HhKFQ88INq9Sd+nd72zqRySlr9BmDA8xlEJ6vJMrYA==", + "node_modules/@codemirror/lint": { + "version": "6.9.2", + "resolved": "https://registry.npmjs.org/@codemirror/lint/-/lint-6.9.2.tgz", + "integrity": "sha512-sv3DylBiIyi+xKwRCJAAsBZZZWo82shJ/RTMymLabAdtbkV5cSKwWDeCgtUq3v8flTaXS2y1kKkICuRYtUswyQ==", "dev": true, - "requires": { - "clean-stack": "^2.0.0", - "indent-string": "^4.0.0" + "license": "MIT", + "dependencies": { + "@codemirror/state": "^6.0.0", + "@codemirror/view": "^6.35.0", + "crelt": "^1.0.5" } }, - "ajv": { - "version": "6.12.6", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", - "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", + "node_modules/@codemirror/search": { + "version": "6.6.0", + "resolved": "https://registry.npmjs.org/@codemirror/search/-/search-6.6.0.tgz", + "integrity": "sha512-koFuNXcDvyyotWcgOnZGmY7LZqEOXZaaxD/j6n18TCLx2/9HieZJ5H6hs1g8FiRxBD0DNfs0nXn17g872RmYdw==", "dev": true, - "requires": { - "fast-deep-equal": "^3.1.1", - "fast-json-stable-stringify": "^2.0.0", - "json-schema-traverse": "^0.4.1", - "uri-js": "^4.2.2" + "license": "MIT", + "dependencies": { + "@codemirror/state": "^6.0.0", + "@codemirror/view": "^6.37.0", + "crelt": "^1.0.5" } }, - "ansi-colors": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.1.tgz", - "integrity": "sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA==", - "dev": true + "node_modules/@codemirror/state": { + "version": "6.5.4", + "resolved": "https://registry.npmjs.org/@codemirror/state/-/state-6.5.4.tgz", + "integrity": "sha512-8y7xqG/hpB53l25CIoit9/ngxdfoG+fx+V3SHBrinnhOtLvKHRyAJJuHzkWrR4YXXLX8eXBsejgAAxHUOdW1yw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@marijn/find-cluster-break": "^1.0.0" + } }, - "ansi-escapes": { - "version": "4.3.1", - "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-4.3.1.tgz", - "integrity": "sha512-JWF7ocqNrp8u9oqpgV+wH5ftbt+cfvv+PTjOvKLT3AdYly/LmORARfEVT1iyjwN+4MqE5UmVKoAdIBqeoCHgLA==", + "node_modules/@codemirror/view": { + "version": "6.39.11", + "resolved": "https://registry.npmjs.org/@codemirror/view/-/view-6.39.11.tgz", + "integrity": "sha512-bWdeR8gWM87l4DB/kYSF9A+dVackzDb/V56Tq7QVrQ7rn86W0rgZFtlL3g3pem6AeGcb9NQNoy3ao4WpW4h5tQ==", "dev": true, - "requires": { - "type-fest": "^0.11.0" - }, + "license": "MIT", "dependencies": { - "type-fest": { - "version": "0.11.0", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.11.0.tgz", - "integrity": "sha512-OdjXJxnCN1AvyLSzeKIgXTXxV+99ZuXl3Hpo9XpJAv9MBcHrrJOQ5kV7ypXOuQie+AmWG25hLbiKdwYTifzcfQ==", - "dev": true - } + "@codemirror/state": "^6.5.0", + "crelt": "^1.0.6", + "style-mod": "^4.1.0", + "w3c-keyname": "^2.2.4" } }, - "ansi-regex": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz", - "integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==", - "dev": true + "node_modules/@docsearch/css": { + "version": "3.8.2", + "resolved": "https://registry.npmjs.org/@docsearch/css/-/css-3.8.2.tgz", + "integrity": "sha512-y05ayQFyUmCXze79+56v/4HpycYF3uFqB78pLPrSV5ZKAlDuIAAJNhaRi8tTdRNXh05yxX/TyNnzD6LwSM89vQ==", + "dev": true, + "license": "MIT" }, - "ansi-styles": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", - "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "node_modules/@docsearch/js": { + "version": "3.8.2", + "resolved": "https://registry.npmjs.org/@docsearch/js/-/js-3.8.2.tgz", + "integrity": "sha512-Q5wY66qHn0SwA7Taa0aDbHiJvaFJLOJyHmooQ7y8hlwwQLQ/5WwCcoX0g7ii04Qi2DJlHsd0XXzJ8Ypw9+9YmQ==", "dev": true, - "requires": { - "color-convert": "^1.9.0" + "license": "MIT", + "dependencies": { + "@docsearch/react": "3.8.2", + "preact": "^10.0.0" } }, - "anymatch": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.1.tgz", - "integrity": "sha512-mM8522psRCqzV+6LhomX5wgp25YVibjh8Wj23I5RPkPppSVSjyKD2A2mBJmWGa+KN7f2D6LNh9jkBCeyLktzjg==", + "node_modules/@docsearch/js/node_modules/@docsearch/react": { + "version": "3.8.2", + "resolved": "https://registry.npmjs.org/@docsearch/react/-/react-3.8.2.tgz", + "integrity": "sha512-xCRrJQlTt8N9GU0DG4ptwHRkfnSnD/YpdeaXe02iKfqs97TkZJv60yE+1eq/tjPcVnTW8dP5qLP7itifFVV5eg==", "dev": true, - "requires": { - "normalize-path": "^3.0.0", - "picomatch": "^2.0.4" + "license": "MIT", + "dependencies": { + "@algolia/autocomplete-core": "1.17.7", + "@algolia/autocomplete-preset-algolia": "1.17.7", + "@docsearch/css": "3.8.2", + "algoliasearch": "^5.14.2" + }, + "peerDependencies": { + "@types/react": ">= 16.8.0 < 19.0.0", + "react": ">= 16.8.0 < 19.0.0", + "react-dom": ">= 16.8.0 < 19.0.0", + "search-insights": ">= 1 < 3" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "react": { + "optional": true + }, + "react-dom": { + "optional": true + }, + "search-insights": { + "optional": true + } } }, - "append-transform": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/append-transform/-/append-transform-2.0.0.tgz", - "integrity": "sha512-7yeyCEurROLQJFv5Xj4lEGTy0borxepjFv1g22oAdqFu//SrAlDl1O1Nxx15SH1RoliUml6p8dwJW9jvZughhg==", + "node_modules/@docsearch/js/node_modules/scheduler": { + "version": "0.23.2", + "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.23.2.tgz", + "integrity": "sha512-UOShsPwz7NrMUqhR6t0hWjFduvOzbtv7toDH1/hIrfRNIDBnnBWd0CwJTGvTpngVlmwGCdP9/Zl/tVrDqcuYzQ==", "dev": true, - "requires": { - "default-require-extensions": "^3.0.0" + "license": "MIT", + "optional": true, + "dependencies": { + "loose-envify": "^1.1.0" } }, - "archy": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/archy/-/archy-1.0.0.tgz", - "integrity": "sha1-+cjBN1fMHde8N5rHeyxipcKGjEA=", - "dev": true - }, - "argparse": { - "version": "1.0.10", - "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", - "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", + "node_modules/@emmetio/abbreviation": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/@emmetio/abbreviation/-/abbreviation-2.3.3.tgz", + "integrity": "sha512-mgv58UrU3rh4YgbE/TzgLQwJ3pFsHHhCLqY20aJq+9comytTXUDNGG/SMtSeMJdkpxgXSXunBGLD8Boka3JyVA==", "dev": true, - "requires": { - "sprintf-js": "~1.0.2" + "license": "MIT", + "dependencies": { + "@emmetio/scanner": "^1.0.4" } }, - "array-find-index": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/array-find-index/-/array-find-index-1.0.2.tgz", - "integrity": "sha1-3wEKoSh+Fku9pvlyOwqWoexBh6E=", - "dev": true - }, - "array-includes": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/array-includes/-/array-includes-3.1.2.tgz", - "integrity": "sha512-w2GspexNQpx+PutG3QpT437/BenZBj0M/MZGn5mzv/MofYqo0xmRHzn4lFsoDlWJ+THYsGJmFlW68WlDFx7VRw==", + "node_modules/@emmetio/css-abbreviation": { + "version": "2.1.8", + "resolved": "https://registry.npmjs.org/@emmetio/css-abbreviation/-/css-abbreviation-2.1.8.tgz", + "integrity": "sha512-s9yjhJ6saOO/uk1V74eifykk2CBYi01STTK3WlXWGOepyKa23ymJ053+DNQjpFcy1ingpaO7AxCcwLvHFY9tuw==", "dev": true, - "requires": { - "call-bind": "^1.0.0", - "define-properties": "^1.1.3", - "es-abstract": "^1.18.0-next.1", - "get-intrinsic": "^1.0.1", - "is-string": "^1.0.5" + "license": "MIT", + "dependencies": { + "@emmetio/scanner": "^1.0.4" } }, - "array.prototype.flat": { - "version": "1.2.4", - "resolved": "https://registry.npmjs.org/array.prototype.flat/-/array.prototype.flat-1.2.4.tgz", - "integrity": "sha512-4470Xi3GAPAjZqFcljX2xzckv1qeKPizoNkiS0+O4IoPR2ZNpcjE0pkhdihlDouK+x6QOast26B4Q/O9DJnwSg==", + "node_modules/@emmetio/css-parser": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/@emmetio/css-parser/-/css-parser-0.4.1.tgz", + "integrity": "sha512-2bC6m0MV/voF4CTZiAbG5MWKbq5EBmDPKu9Sb7s7nVcEzNQlrZP6mFFFlIaISM8X6514H9shWMme1fCm8cWAfQ==", "dev": true, - "requires": { - "call-bind": "^1.0.0", - "define-properties": "^1.1.3", - "es-abstract": "^1.18.0-next.1" + "license": "MIT", + "dependencies": { + "@emmetio/stream-reader": "^2.2.0", + "@emmetio/stream-reader-utils": "^0.1.0" } }, - "astral-regex": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/astral-regex/-/astral-regex-2.0.0.tgz", - "integrity": "sha512-Z7tMw1ytTXt5jqMcOP+OQteU1VuNK9Y02uuJtKQ1Sv69jXQKKg5cibLwGJow8yzZP+eAc18EmLGPal0bp36rvQ==", - "dev": true + "node_modules/@emmetio/html-matcher": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/@emmetio/html-matcher/-/html-matcher-1.3.0.tgz", + "integrity": "sha512-NTbsvppE5eVyBMuyGfVu2CRrLvo7J4YHb6t9sBFLyY03WYhXET37qA4zOYUjBWFCRHO7pS1B9khERtY0f5JXPQ==", + "dev": true, + "license": "ISC", + "dependencies": { + "@emmetio/scanner": "^1.0.0" + } }, - "balanced-match": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", - "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", - "dev": true + "node_modules/@emmetio/scanner": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/@emmetio/scanner/-/scanner-1.0.4.tgz", + "integrity": "sha512-IqRuJtQff7YHHBk4G8YZ45uB9BaAGcwQeVzgj/zj8/UdOhtQpEIupUhSk8dys6spFIWVZVeK20CzGEnqR5SbqA==", + "dev": true, + "license": "MIT" }, - "binary-extensions": { + "node_modules/@emmetio/stream-reader": { "version": "2.2.0", - "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz", - "integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==", - "dev": true + "resolved": "https://registry.npmjs.org/@emmetio/stream-reader/-/stream-reader-2.2.0.tgz", + "integrity": "sha512-fXVXEyFA5Yv3M3n8sUGT7+fvecGrZP4k6FnWWMSZVQf69kAq0LLpaBQLGcPR30m3zMmKYhECP4k/ZkzvhEW5kw==", + "dev": true, + "license": "MIT" }, - "brace-expansion": { - "version": "1.1.11", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "node_modules/@emmetio/stream-reader-utils": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/@emmetio/stream-reader-utils/-/stream-reader-utils-0.1.0.tgz", + "integrity": "sha512-ZsZ2I9Vzso3Ho/pjZFsmmZ++FWeEd/txqybHTm4OgaZzdS8V9V/YYWQwg5TC38Z7uLWUV1vavpLLbjJtKubR1A==", "dev": true, - "requires": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" - } + "license": "MIT" }, - "braces": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", - "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "node_modules/@emnapi/core": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/@emnapi/core/-/core-1.8.1.tgz", + "integrity": "sha512-AvT9QFpxK0Zd8J0jopedNm+w/2fIzvtPKPjqyw9jwvBaReTTqPBk9Hixaz7KbjimP+QNz605/XnjFcDAL2pqBg==", "dev": true, - "requires": { - "fill-range": "^7.0.1" + "license": "MIT", + "optional": true, + "dependencies": { + "@emnapi/wasi-threads": "1.1.0", + "tslib": "^2.4.0" } }, - "browser-stdout": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", - "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==", - "dev": true - }, - "buble": { - "version": "0.20.0", - "resolved": "https://registry.npmjs.org/buble/-/buble-0.20.0.tgz", - "integrity": "sha512-/1gnaMQE8xvd5qsNBl+iTuyjJ9XxeaVxAMF86dQ4EyxFJOZtsgOS8Ra+7WHgZTam5IFDtt4BguN0sH0tVTKrOw==", + "node_modules/@emnapi/runtime": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-1.8.1.tgz", + "integrity": "sha512-mehfKSMWjjNol8659Z8KxEMrdSJDDot5SXMq00dM8BN4o+CLNXQ0xH2V7EchNHV4RmbZLmmPdEaXZc5H2FXmDg==", "dev": true, - "requires": { - "acorn": "^6.4.1", - "acorn-dynamic-import": "^4.0.0", - "acorn-jsx": "^5.2.0", - "chalk": "^2.4.2", - "magic-string": "^0.25.7", - "minimist": "^1.2.5", - "regexpu-core": "4.5.4" - }, + "license": "MIT", + "optional": true, "dependencies": { - "acorn": { - "version": "6.4.2", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-6.4.2.tgz", - "integrity": "sha512-XtGIhXwF8YM8bJhGxG5kXgjkEuNGLTkoYqVE+KMR+aspr4KGYmKYg7yUe3KghyQ9yheNwLnjmzh/7+gfDBmHCQ==", - "dev": true - } + "tslib": "^2.4.0" } }, - "buffer-from": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz", - "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==", - "dev": true - }, - "builtin-modules": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-3.2.0.tgz", - "integrity": "sha512-lGzLKcioL90C7wMczpkY0n/oART3MbBa8R9OFGE1rJxoVI86u4WAGfEk8Wjv10eKSyTHVGkSo3bvBylCEtk7LA==", - "dev": true - }, - "caching-transform": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/caching-transform/-/caching-transform-4.0.0.tgz", - "integrity": "sha512-kpqOvwXnjjN44D89K5ccQC+RUrsy7jB/XLlRrx0D7/2HNcTPqzsb6XgYoErwko6QsV184CA2YgS1fxDiiDZMWA==", + "node_modules/@emnapi/wasi-threads": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@emnapi/wasi-threads/-/wasi-threads-1.1.0.tgz", + "integrity": "sha512-WI0DdZ8xFSbgMjR1sFsKABJ/C5OnRrjT06JXbZKexJGrDuPTzZdDYfFlsgcCXCyf+suG5QU2e/y1Wo2V/OapLQ==", "dev": true, - "requires": { - "hasha": "^5.0.0", - "make-dir": "^3.0.0", - "package-hash": "^4.0.0", - "write-file-atomic": "^3.0.0" + "license": "MIT", + "optional": true, + "dependencies": { + "tslib": "^2.4.0" } }, - "call-bind": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.2.tgz", - "integrity": "sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA==", + "node_modules/@epic-web/invariant": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@epic-web/invariant/-/invariant-1.0.0.tgz", + "integrity": "sha512-lrTPqgvfFQtR/eY/qkIzp98OGdNJu0m5ji3q/nJI8v3SXkRKEnWiOxMmbvcSoAIzv/cGiuvRy57k4suKQSAdwA==", "dev": true, - "requires": { - "function-bind": "^1.1.1", - "get-intrinsic": "^1.0.2" + "license": "MIT" + }, + "node_modules/@esbuild/aix-ppc64": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.27.2.tgz", + "integrity": "sha512-GZMB+a0mOMZs4MpDbj8RJp4cw+w1WV5NYD6xzgvzUJ5Ek2jerwfO2eADyI6ExDSUED+1X8aMbegahsJi+8mgpw==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "aix" + ], + "engines": { + "node": ">=18" } }, - "callsites": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", - "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", - "dev": true - }, - "camelcase": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.2.0.tgz", - "integrity": "sha512-c7wVvbw3f37nuobQNtgsgG9POC9qMbNuMQmTCqZv23b6MIz0fcYpBiOlv9gEN/hdLdnZTDQhg6e9Dq5M1vKvfg==", - "dev": true - }, - "chalk": { - "version": "2.4.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", - "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "node_modules/@esbuild/android-arm": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.27.2.tgz", + "integrity": "sha512-DVNI8jlPa7Ujbr1yjU2PfUSRtAUZPG9I1RwW4F4xFB1Imiu2on0ADiI/c3td+KmDtVKNbi+nffGDQMfcIMkwIA==", + "cpu": [ + "arm" + ], "dev": true, - "requires": { - "ansi-styles": "^3.2.1", - "escape-string-regexp": "^1.0.5", - "supports-color": "^5.3.0" + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" } }, - "chokidar": { - "version": "3.5.1", - "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.1.tgz", - "integrity": "sha512-9+s+Od+W0VJJzawDma/gvBNQqkTiqYTWLuZoyAsivsI4AaWTCzHG06/TMjsf1cYe9Cb97UCEhjz7HvnPk2p/tw==", + "node_modules/@esbuild/android-arm64": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.27.2.tgz", + "integrity": "sha512-pvz8ZZ7ot/RBphf8fv60ljmaoydPU12VuXHImtAs0XhLLw+EXBi2BLe3OYSBslR4rryHvweW5gmkKFwTiFy6KA==", + "cpu": [ + "arm64" + ], "dev": true, - "requires": { - "anymatch": "~3.1.1", - "braces": "~3.0.2", - "fsevents": "~2.3.1", - "glob-parent": "~5.1.0", - "is-binary-path": "~2.1.0", - "is-glob": "~4.0.1", - "normalize-path": "~3.0.0", - "readdirp": "~3.5.0" + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" } }, - "clean-stack": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/clean-stack/-/clean-stack-2.2.0.tgz", - "integrity": "sha512-4diC9HaTE+KRAMWhDhrGOECgWZxoevMc5TlkObMqNSsVU62PYzXZ/SMTjzyGAFF1YusgxGcSWTEXBhp0CPwQ1A==", - "dev": true - }, - "cli-cursor": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-3.1.0.tgz", - "integrity": "sha512-I/zHAwsKf9FqGoXM4WWRACob9+SNukZTd94DWF57E4toouRulbCxcUh6RKUEOQlYTHJnzkPMySvPNaaSLNfLZw==", + "node_modules/@esbuild/android-x64": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.27.2.tgz", + "integrity": "sha512-z8Ank4Byh4TJJOh4wpz8g2vDy75zFL0TlZlkUkEwYXuPSgX8yzep596n6mT7905kA9uHZsf/o2OJZubl2l3M7A==", + "cpu": [ + "x64" + ], "dev": true, - "requires": { - "restore-cursor": "^3.1.0" + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" } }, - "cli-truncate": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/cli-truncate/-/cli-truncate-2.1.0.tgz", - "integrity": "sha512-n8fOixwDD6b/ObinzTrp1ZKFzbgvKZvuz/TvejnLn1aQfC6r52XEx85FmuC+3HI+JM7coBRXUvNqEU2PHVrHpg==", - "dev": true, - "requires": { - "slice-ansi": "^3.0.0", - "string-width": "^4.2.0" - }, - "dependencies": { - "ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "requires": { - "color-convert": "^2.0.1" - } - }, - "color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "requires": { - "color-name": "~1.1.4" - } - }, - "color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true - }, - "slice-ansi": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-3.0.0.tgz", - "integrity": "sha512-pSyv7bSTC7ig9Dcgbw9AuRNUb5k5V6oDudjZoMBSr13qpLBG7tB+zgCkARjq7xIUgdz5P1Qe8u+rSGdouOOIyQ==", - "dev": true, - "requires": { - "ansi-styles": "^4.0.0", - "astral-regex": "^2.0.0", - "is-fullwidth-code-point": "^3.0.0" - } - } + "node_modules/@esbuild/darwin-arm64": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.27.2.tgz", + "integrity": "sha512-davCD2Zc80nzDVRwXTcQP/28fiJbcOwvdolL0sOiOsbwBa72kegmVU0Wrh1MYrbuCL98Omp5dVhQFWRKR2ZAlg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" } }, - "cliui": { - "version": "7.0.4", - "resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz", - "integrity": "sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==", + "node_modules/@esbuild/darwin-x64": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.27.2.tgz", + "integrity": "sha512-ZxtijOmlQCBWGwbVmwOF/UCzuGIbUkqB1faQRf5akQmxRJ1ujusWsb3CVfk/9iZKr2L5SMU5wPBi1UWbvL+VQA==", + "cpu": [ + "x64" + ], "dev": true, - "requires": { - "string-width": "^4.2.0", - "strip-ansi": "^6.0.0", - "wrap-ansi": "^7.0.0" + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" } }, - "color-convert": { - "version": "1.9.3", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", - "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "node_modules/@esbuild/freebsd-arm64": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.27.2.tgz", + "integrity": "sha512-lS/9CN+rgqQ9czogxlMcBMGd+l8Q3Nj1MFQwBZJyoEKI50XGxwuzznYdwcav6lpOGv5BqaZXqvBSiB/kJ5op+g==", + "cpu": [ + "arm64" + ], "dev": true, - "requires": { - "color-name": "1.1.3" + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" } }, - "color-name": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", - "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", - "dev": true - }, - "colorette": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/colorette/-/colorette-1.2.1.tgz", - "integrity": "sha512-puCDz0CzydiSYOrnXpz/PKd69zRrribezjtE9yd4zvytoRc8+RY/KJPvtPFKZS3E3wP6neGyMe0vOTlHO5L3Pw==", - "dev": true - }, - "commander": { - "version": "6.2.1", - "resolved": "https://registry.npmjs.org/commander/-/commander-6.2.1.tgz", - "integrity": "sha512-U7VdrJFnJgo4xjrHpTzu0yrHPGImdsmD95ZlgYSEajAn2JKzDhDTPG9kBTefmObL2w/ngeZnilk+OV9CG3d7UA==", - "dev": true - }, - "commenting": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/commenting/-/commenting-1.1.0.tgz", - "integrity": "sha512-YeNK4tavZwtH7jEgK1ZINXzLKm6DZdEMfsaaieOsCAN0S8vsY7UeuO3Q7d/M018EFgE+IeUAuBOKkFccBZsUZA==", - "dev": true - }, - "commondir": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/commondir/-/commondir-1.0.1.tgz", - "integrity": "sha1-3dgA2gxmEnOTzKWVDqloo6rxJTs=", - "dev": true - }, - "concat-map": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", - "dev": true - }, - "contains-path": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/contains-path/-/contains-path-0.1.0.tgz", - "integrity": "sha1-/ozxhP9mcLa67wGp1IYaXL7EEgo=", - "dev": true - }, - "convert-source-map": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.7.0.tgz", - "integrity": "sha512-4FJkXzKXEDB1snCFZlLP4gpC3JILicCpGbzG9f9G7tGqGCzETQ2hWPrcinA9oU4wtf2biUaEH5065UnMeR33oA==", + "node_modules/@esbuild/freebsd-x64": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.27.2.tgz", + "integrity": "sha512-tAfqtNYb4YgPnJlEFu4c212HYjQWSO/w/h/lQaBK7RbwGIkBOuNKQI9tqWzx7Wtp7bTPaGC6MJvWI608P3wXYA==", + "cpu": [ + "x64" + ], "dev": true, - "requires": { - "safe-buffer": "~5.1.1" - }, - "dependencies": { - "safe-buffer": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", - "dev": true - } + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" } }, - "core-js": { - "version": "3.8.3", - "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.8.3.tgz", - "integrity": "sha512-KPYXeVZYemC2TkNEkX/01I+7yd+nX3KddKwZ1Ww7SKWdI2wQprSgLmrTddT8nw92AjEklTsPBoSdQBhbI1bQ6Q==", - "dev": true - }, - "cosmiconfig": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-7.0.0.tgz", - "integrity": "sha512-pondGvTuVYDk++upghXJabWzL6Kxu6f26ljFw64Swq9v6sQPUL3EUlVDV56diOjpCayKihL6hVe8exIACU4XcA==", + "node_modules/@esbuild/linux-arm": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.27.2.tgz", + "integrity": "sha512-vWfq4GaIMP9AIe4yj1ZUW18RDhx6EPQKjwe7n8BbIecFtCQG4CfHGaHuh7fdfq+y3LIA2vGS/o9ZBGVxIDi9hw==", + "cpu": [ + "arm" + ], "dev": true, - "requires": { - "@types/parse-json": "^4.0.0", - "import-fresh": "^3.2.1", - "parse-json": "^5.0.0", - "path-type": "^4.0.0", - "yaml": "^1.10.0" - }, - "dependencies": { - "parse-json": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-5.2.0.tgz", - "integrity": "sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg==", - "dev": true, - "requires": { - "@babel/code-frame": "^7.0.0", - "error-ex": "^1.3.1", - "json-parse-even-better-errors": "^2.3.0", - "lines-and-columns": "^1.1.6" - } - }, - "path-type": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz", - "integrity": "sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==", - "dev": true - } + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" } }, - "cross-spawn": { - "version": "7.0.3", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", - "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", + "node_modules/@esbuild/linux-arm64": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.27.2.tgz", + "integrity": "sha512-hYxN8pr66NsCCiRFkHUAsxylNOcAQaxSSkHMMjcpx0si13t1LHFphxJZUiGwojB1a/Hd5OiPIqDdXONia6bhTw==", + "cpu": [ + "arm64" + ], "dev": true, - "requires": { - "path-key": "^3.1.0", - "shebang-command": "^2.0.0", - "which": "^2.0.1" + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" } }, - "date-time": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/date-time/-/date-time-3.1.0.tgz", - "integrity": "sha512-uqCUKXE5q1PNBXjPqvwhwJf9SwMoAHBgWJ6DcrnS5o+W2JOiIILl0JEdVD8SGujrNS02GGxgwAg2PN2zONgtjg==", + "node_modules/@esbuild/linux-ia32": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.27.2.tgz", + "integrity": "sha512-MJt5BRRSScPDwG2hLelYhAAKh9imjHK5+NE/tvnRLbIqUWa+0E9N4WNMjmp/kXXPHZGqPLxggwVhz7QP8CTR8w==", + "cpu": [ + "ia32" + ], "dev": true, - "requires": { - "time-zone": "^1.0.0" + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" } }, - "debug": { - "version": "4.3.1", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.1.tgz", - "integrity": "sha512-doEwdvm4PCeK4K3RQN2ZC2BYUBaxwLARCqZmMjtF8a51J2Rb0xpVloFRnCODwqjpwnAoao4pelN8l3RJdv3gRQ==", + "node_modules/@esbuild/linux-loong64": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.27.2.tgz", + "integrity": "sha512-lugyF1atnAT463aO6KPshVCJK5NgRnU4yb3FUumyVz+cGvZbontBgzeGFO1nF+dPueHD367a2ZXe1NtUkAjOtg==", + "cpu": [ + "loong64" + ], "dev": true, - "requires": { - "ms": "2.1.2" + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" } }, - "decamelize": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-4.0.0.tgz", - "integrity": "sha512-9iE1PgSik9HeIIw2JO94IidnE3eBoQrFJ3w7sFuzSX4DpmZ3v5sZpUiV5Swcf6mQEF+Y0ru8Neo+p+nyh2J+hQ==", - "dev": true - }, - "dedent": { - "version": "0.7.0", - "resolved": "https://registry.npmjs.org/dedent/-/dedent-0.7.0.tgz", - "integrity": "sha1-JJXduvbrh0q7Dhvp3yLS5aVEMmw=", - "dev": true - }, - "deep-extend": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.6.0.tgz", - "integrity": "sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA==", - "dev": true - }, - "deep-is": { - "version": "0.1.3", - "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.3.tgz", - "integrity": "sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ=", - "dev": true - }, - "deepmerge": { - "version": "4.2.2", - "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.2.2.tgz", - "integrity": "sha512-FJ3UgI4gIl+PHZm53knsuSFpE+nESMr7M4v9QcgB7S63Kj/6WqMiFQJpBBYz1Pt+66bZpP3Q7Lye0Oo9MPKEdg==", - "dev": true - }, - "default-require-extensions": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/default-require-extensions/-/default-require-extensions-3.0.0.tgz", - "integrity": "sha512-ek6DpXq/SCpvjhpFsLFRVtIxJCRw6fUR42lYMVZuUMK7n8eMz4Uh5clckdBjEpLhn/gEBZo7hDJnJcwdKLKQjg==", + "node_modules/@esbuild/linux-mips64el": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.27.2.tgz", + "integrity": "sha512-nlP2I6ArEBewvJ2gjrrkESEZkB5mIoaTswuqNFRv/WYd+ATtUpe9Y09RnJvgvdag7he0OWgEZWhviS1OTOKixw==", + "cpu": [ + "mips64el" + ], "dev": true, - "requires": { - "strip-bom": "^4.0.0" - }, - "dependencies": { - "strip-bom": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-4.0.0.tgz", - "integrity": "sha512-3xurFv5tEgii33Zi8Jtp55wEIILR9eh34FAW00PZf+JnSsTmV/ioewSgQl97JHvgjoRGwPShsWm+IdrxB35d0w==", - "dev": true - } + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" } }, - "define-properties": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.3.tgz", - "integrity": "sha512-3MqfYKj2lLzdMSf8ZIZE/V+Zuy+BgD6f164e8K2w7dgnpKArBDerGYpM46IYYcjnkdPNMjPk9A6VFB8+3SKlXQ==", + "node_modules/@esbuild/linux-ppc64": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.27.2.tgz", + "integrity": "sha512-C92gnpey7tUQONqg1n6dKVbx3vphKtTHJaNG2Ok9lGwbZil6DrfyecMsp9CrmXGQJmZ7iiVXvvZH6Ml5hL6XdQ==", + "cpu": [ + "ppc64" + ], "dev": true, - "requires": { - "object-keys": "^1.0.12" + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" } }, - "detect-indent": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/detect-indent/-/detect-indent-6.0.0.tgz", - "integrity": "sha512-oSyFlqaTHCItVRGK5RmrmjB+CmaMOW7IaNA/kdxqhoa6d17j/5ce9O9eWXmV/KEdRwqpQA+Vqe8a8Bsybu4YnA==", - "dev": true - }, - "diff": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/diff/-/diff-5.0.0.tgz", - "integrity": "sha512-/VTCrvm5Z0JGty/BWHljh+BAiw3IK+2j87NGMu8Nwc/f48WoDAC395uomO9ZD117ZOBaHmkX1oyLvkVM/aIT3w==", - "dev": true - }, - "doctrine": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz", - "integrity": "sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w==", + "node_modules/@esbuild/linux-riscv64": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.27.2.tgz", + "integrity": "sha512-B5BOmojNtUyN8AXlK0QJyvjEZkWwy/FKvakkTDCziX95AowLZKR6aCDhG7LeF7uMCXEJqwa8Bejz5LTPYm8AvA==", + "cpu": [ + "riscv64" + ], "dev": true, - "requires": { - "esutils": "^2.0.2" + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" } }, - "emoji-regex": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", - "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", - "dev": true - }, - "end-of-stream": { - "version": "1.4.4", - "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz", - "integrity": "sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==", + "node_modules/@esbuild/linux-s390x": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.27.2.tgz", + "integrity": "sha512-p4bm9+wsPwup5Z8f4EpfN63qNagQ47Ua2znaqGH6bqLlmJ4bx97Y9JdqxgGZ6Y8xVTixUnEkoKSHcpRlDnNr5w==", + "cpu": [ + "s390x" + ], "dev": true, - "requires": { - "once": "^1.4.0" + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" } }, - "enquirer": { - "version": "2.3.6", - "resolved": "https://registry.npmjs.org/enquirer/-/enquirer-2.3.6.tgz", - "integrity": "sha512-yjNnPr315/FjS4zIsUxYguYUPP2e1NK4d7E7ZOLiyYCcbFBiTMyID+2wvm2w6+pZ/odMA7cRkjhsPbltwBOrLg==", + "node_modules/@esbuild/linux-x64": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.27.2.tgz", + "integrity": "sha512-uwp2Tip5aPmH+NRUwTcfLb+W32WXjpFejTIOWZFw/v7/KnpCDKG66u4DLcurQpiYTiYwQ9B7KOeMJvLCu/OvbA==", + "cpu": [ + "x64" + ], "dev": true, - "requires": { - "ansi-colors": "^4.1.1" + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" } }, - "ensure-posix-path": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/ensure-posix-path/-/ensure-posix-path-1.1.1.tgz", - "integrity": "sha512-VWU0/zXzVbeJNXvME/5EmLuEj2TauvoaTz6aFYK1Z92JCBlDlZ3Gu0tuGR42kpW1754ywTs+QB0g5TP0oj9Zaw==", - "dev": true - }, - "entities": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/entities/-/entities-2.0.3.tgz", - "integrity": "sha512-MyoZ0jgnLvB2X3Lg5HqpFmn1kybDiIfEQmKzTb5apr51Rb+T3KdmMiqa70T+bhGnyv7bQ6WMj2QMHpGMmlrUYQ==", - "dev": true - }, - "error-ex": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz", - "integrity": "sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g==", + "node_modules/@esbuild/netbsd-arm64": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.27.2.tgz", + "integrity": "sha512-Kj6DiBlwXrPsCRDeRvGAUb/LNrBASrfqAIok+xB0LxK8CHqxZ037viF13ugfsIpePH93mX7xfJp97cyDuTZ3cw==", + "cpu": [ + "arm64" + ], "dev": true, - "requires": { - "is-arrayish": "^0.2.1" + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" } }, - "es-abstract": { - "version": "1.18.0-next.2", - "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.18.0-next.2.tgz", - "integrity": "sha512-Ih4ZMFHEtZupnUh6497zEL4y2+w8+1ljnCyaTa+adcoafI1GOvMwFlDjBLfWR7y9VLfrjRJe9ocuHY1PSR9jjw==", - "dev": true, - "requires": { - "call-bind": "^1.0.2", - "es-to-primitive": "^1.2.1", - "function-bind": "^1.1.1", - "get-intrinsic": "^1.0.2", - "has": "^1.0.3", - "has-symbols": "^1.0.1", - "is-callable": "^1.2.2", - "is-negative-zero": "^2.0.1", - "is-regex": "^1.1.1", - "object-inspect": "^1.9.0", - "object-keys": "^1.1.1", - "object.assign": "^4.1.2", - "string.prototype.trimend": "^1.0.3", - "string.prototype.trimstart": "^1.0.3" - } - }, - "es-to-primitive": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.2.1.tgz", - "integrity": "sha512-QCOllgZJtaUo9miYBcLChTUaHNjJF3PYs1VidD7AwiEj1kYxKeQTctLAezAOH5ZKRH0g2IgPn6KwB4IT8iRpvA==", + "node_modules/@esbuild/netbsd-x64": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.27.2.tgz", + "integrity": "sha512-HwGDZ0VLVBY3Y+Nw0JexZy9o/nUAWq9MlV7cahpaXKW6TOzfVno3y3/M8Ga8u8Yr7GldLOov27xiCnqRZf0tCA==", + "cpu": [ + "x64" + ], "dev": true, - "requires": { - "is-callable": "^1.1.4", - "is-date-object": "^1.0.1", - "is-symbol": "^1.0.2" + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" } }, - "es5-shim": { - "version": "4.5.15", - "resolved": "https://registry.npmjs.org/es5-shim/-/es5-shim-4.5.15.tgz", - "integrity": "sha512-FYpuxEjMeDvU4rulKqFdukQyZSTpzhg4ScQHrAosrlVpR6GFyaw14f74yn2+4BugniIS0Frpg7TvwZocU4ZMTw==", - "dev": true + "node_modules/@esbuild/openbsd-arm64": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.27.2.tgz", + "integrity": "sha512-DNIHH2BPQ5551A7oSHD0CKbwIA/Ox7+78/AWkbS5QoRzaqlev2uFayfSxq68EkonB+IKjiuxBFoV8ESJy8bOHA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } }, - "es6-error": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/es6-error/-/es6-error-4.1.1.tgz", - "integrity": "sha512-Um/+FxMr9CISWh0bi5Zv0iOD+4cFh5qLeks1qhAopKVAJw3drgKbKySikp7wGhDL0HPeaja0P5ULZrxLkniUVg==", - "dev": true + "node_modules/@esbuild/openbsd-x64": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.27.2.tgz", + "integrity": "sha512-/it7w9Nb7+0KFIzjalNJVR5bOzA9Vay+yIPLVHfIQYG/j+j9VTH84aNB8ExGKPU4AzfaEvN9/V4HV+F+vo8OEg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } }, - "es6-shim": { - "version": "0.35.6", - "resolved": "https://registry.npmjs.org/es6-shim/-/es6-shim-0.35.6.tgz", - "integrity": "sha512-EmTr31wppcaIAgblChZiuN/l9Y7DPyw8Xtbg7fIVngn6zMW+IEBJDJngeKC3x6wr0V/vcA2wqeFnaw1bFJbDdA==", - "dev": true + "node_modules/@esbuild/openharmony-arm64": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/openharmony-arm64/-/openharmony-arm64-0.27.2.tgz", + "integrity": "sha512-LRBbCmiU51IXfeXk59csuX/aSaToeG7w48nMwA6049Y4J4+VbWALAuXcs+qcD04rHDuSCSRKdmY63sruDS5qag==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ], + "engines": { + "node": ">=18" + } }, - "escalade": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", - "integrity": "sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==", - "dev": true + "node_modules/@esbuild/sunos-x64": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.27.2.tgz", + "integrity": "sha512-kMtx1yqJHTmqaqHPAzKCAkDaKsffmXkPHThSfRwZGyuqyIeBvf08KSsYXl+abf5HDAPMJIPnbBfXvP2ZC2TfHg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=18" + } }, - "escape-string-regexp": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", - "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", - "dev": true + "node_modules/@esbuild/win32-arm64": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.27.2.tgz", + "integrity": "sha512-Yaf78O/B3Kkh+nKABUF++bvJv5Ijoy9AN1ww904rOXZFLWVc5OLOfL56W+C8F9xn5JQZa3UX6m+IktJnIb1Jjg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } }, - "eslint": { - "version": "7.19.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-7.19.0.tgz", - "integrity": "sha512-CGlMgJY56JZ9ZSYhJuhow61lMPPjUzWmChFya71Z/jilVos7mR/jPgaEfVGgMBY5DshbKdG8Ezb8FDCHcoMEMg==", + "node_modules/@esbuild/win32-ia32": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.27.2.tgz", + "integrity": "sha512-Iuws0kxo4yusk7sw70Xa2E2imZU5HoixzxfGCdxwBdhiDgt9vX9VUCBhqcwY7/uh//78A1hMkkROMJq9l27oLQ==", + "cpu": [ + "ia32" + ], "dev": true, - "requires": { - "@babel/code-frame": "^7.0.0", - "@eslint/eslintrc": "^0.3.0", - "ajv": "^6.10.0", - "chalk": "^4.0.0", - "cross-spawn": "^7.0.2", - "debug": "^4.0.1", - "doctrine": "^3.0.0", - "enquirer": "^2.3.5", - "eslint-scope": "^5.1.1", - "eslint-utils": "^2.1.0", - "eslint-visitor-keys": "^2.0.0", - "espree": "^7.3.1", - "esquery": "^1.2.0", - "esutils": "^2.0.2", - "file-entry-cache": "^6.0.0", - "functional-red-black-tree": "^1.0.1", - "glob-parent": "^5.0.0", - "globals": "^12.1.0", - "ignore": "^4.0.6", - "import-fresh": "^3.0.0", - "imurmurhash": "^0.1.4", - "is-glob": "^4.0.0", - "js-yaml": "^3.13.1", - "json-stable-stringify-without-jsonify": "^1.0.1", - "levn": "^0.4.1", - "lodash": "^4.17.20", - "minimatch": "^3.0.4", - "natural-compare": "^1.4.0", - "optionator": "^0.9.1", - "progress": "^2.0.0", - "regexpp": "^3.1.0", - "semver": "^7.2.1", - "strip-ansi": "^6.0.0", - "strip-json-comments": "^3.1.0", - "table": "^6.0.4", - "text-table": "^0.2.0", - "v8-compile-cache": "^2.0.3" - }, - "dependencies": { - "ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "requires": { - "color-convert": "^2.0.1" - } - }, - "chalk": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz", - "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==", - "dev": true, - "requires": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - } - }, - "color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "requires": { - "color-name": "~1.1.4" - } - }, - "color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true - }, - "has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "dev": true - }, - "supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dev": true, - "requires": { - "has-flag": "^4.0.0" - } - } + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" } }, - "eslint-import-resolver-node": { - "version": "0.3.4", - "resolved": "https://registry.npmjs.org/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.4.tgz", - "integrity": "sha512-ogtf+5AB/O+nM6DIeBUNr2fuT7ot9Qg/1harBfBtaP13ekEWFQEEMP94BCB7zaNW3gyY+8SHYF00rnqYwXKWOA==", + "node_modules/@esbuild/win32-x64": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.27.2.tgz", + "integrity": "sha512-sRdU18mcKf7F+YgheI/zGf5alZatMUTKj/jNS6l744f9u3WFu4v7twcUI9vu4mknF4Y9aDlblIie0IM+5xxaqQ==", + "cpu": [ + "x64" + ], "dev": true, - "requires": { - "debug": "^2.6.9", - "resolve": "^1.13.1" - }, - "dependencies": { - "debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "dev": true, - "requires": { - "ms": "2.0.0" - } - }, - "ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", - "dev": true - } + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" } }, - "eslint-module-utils": { - "version": "2.6.0", - "resolved": "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.6.0.tgz", - "integrity": "sha512-6j9xxegbqe8/kZY8cYpcp0xhbK0EgJlg3g9mib3/miLaExuuwc3n5UEfSnU6hWMbT0FAYVvDbL9RrRgpUeQIvA==", + "node_modules/@eslint-community/eslint-utils": { + "version": "4.9.1", + "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.9.1.tgz", + "integrity": "sha512-phrYmNiYppR7znFEdqgfWHXR6NCkZEK7hwWDHZUjit/2/U0r6XvkDl0SYnoM51Hq7FhCGdLDT6zxCCOY1hexsQ==", "dev": true, - "requires": { - "debug": "^2.6.9", - "pkg-dir": "^2.0.0" - }, + "license": "MIT", "dependencies": { - "debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "dev": true, - "requires": { - "ms": "2.0.0" - } - }, - "ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", - "dev": true - } + "eslint-visitor-keys": "^3.4.3" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + }, + "peerDependencies": { + "eslint": "^6.0.0 || ^7.0.0 || >=8.0.0" } }, - "eslint-plugin-import": { - "version": "2.22.1", - "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.22.1.tgz", - "integrity": "sha512-8K7JjINHOpH64ozkAhpT3sd+FswIZTfMZTjdx052pnWrgRCVfp8op9tbjpAk3DdUeI/Ba4C8OjdC0r90erHEOw==", + "node_modules/@eslint-community/eslint-utils/node_modules/eslint-visitor-keys": { + "version": "3.4.3", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz", + "integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==", "dev": true, - "requires": { - "array-includes": "^3.1.1", - "array.prototype.flat": "^1.2.3", - "contains-path": "^0.1.0", - "debug": "^2.6.9", - "doctrine": "1.5.0", - "eslint-import-resolver-node": "^0.3.4", - "eslint-module-utils": "^2.6.0", - "has": "^1.0.3", - "minimatch": "^3.0.4", - "object.values": "^1.1.1", - "read-pkg-up": "^2.0.0", - "resolve": "^1.17.0", - "tsconfig-paths": "^3.9.0" + "license": "Apache-2.0", + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" }, - "dependencies": { - "debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "dev": true, - "requires": { - "ms": "2.0.0" - } - }, - "doctrine": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-1.5.0.tgz", - "integrity": "sha1-N53Ocw9hZvds76TmcHoVmwLFpvo=", - "dev": true, - "requires": { - "esutils": "^2.0.2", - "isarray": "^1.0.0" - } - }, - "ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", - "dev": true - } + "funding": { + "url": "https://opencollective.com/eslint" } }, - "eslint-scope": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz", - "integrity": "sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw==", + "node_modules/@eslint-community/regexpp": { + "version": "4.12.2", + "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.12.2.tgz", + "integrity": "sha512-EriSTlt5OC9/7SXkRSCAhfSxxoSUgBm33OH+IkwbdpgoqsSsUg7y3uh+IICI/Qg4BBWr3U2i39RpmycbxMq4ew==", "dev": true, - "requires": { - "esrecurse": "^4.3.0", - "estraverse": "^4.1.1" + "license": "MIT", + "engines": { + "node": "^12.0.0 || ^14.0.0 || >=16.0.0" } }, - "eslint-utils": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-2.1.0.tgz", - "integrity": "sha512-w94dQYoauyvlDc43XnGB8lU3Zt713vNChgt4EWwhXAP2XkBvndfxF0AgIqKOOasjPIPzj9JqgwkwbCYD0/V3Zg==", + "node_modules/@eslint/config-array": { + "version": "0.21.1", + "resolved": "https://registry.npmjs.org/@eslint/config-array/-/config-array-0.21.1.tgz", + "integrity": "sha512-aw1gNayWpdI/jSYVgzN5pL0cfzU02GT3NBpeT/DXbx1/1x7ZKxFPd9bwrzygx/qiwIQiJ1sw/zD8qY/kRvlGHA==", "dev": true, - "requires": { - "eslint-visitor-keys": "^1.1.0" - }, + "license": "Apache-2.0", "dependencies": { - "eslint-visitor-keys": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.3.0.tgz", - "integrity": "sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ==", - "dev": true - } + "@eslint/object-schema": "^2.1.7", + "debug": "^4.3.1", + "minimatch": "^3.1.2" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" } }, - "eslint-visitor-keys": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-2.0.0.tgz", - "integrity": "sha512-QudtT6av5WXels9WjIM7qz1XD1cWGvX4gGXvp/zBn9nXG02D0utdU3Em2m/QjTnrsk6bBjmCygl3rmj118msQQ==", - "dev": true - }, - "espree": { - "version": "7.3.1", - "resolved": "https://registry.npmjs.org/espree/-/espree-7.3.1.tgz", - "integrity": "sha512-v3JCNCE64umkFpmkFGqzVKsOT0tN1Zr+ueqLZfpV1Ob8e+CEgPWa+OxCoGH3tnhimMKIaBm4m/vaRpJ/krRz2g==", + "node_modules/@eslint/config-helpers": { + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/@eslint/config-helpers/-/config-helpers-0.4.2.tgz", + "integrity": "sha512-gBrxN88gOIf3R7ja5K9slwNayVcZgK6SOUORm2uBzTeIEfeVaIhOpCtTox3P6R7o2jLFwLFTLnC7kU/RGcYEgw==", "dev": true, - "requires": { - "acorn": "^7.4.0", - "acorn-jsx": "^5.3.1", - "eslint-visitor-keys": "^1.3.0" - }, + "license": "Apache-2.0", "dependencies": { - "acorn": { - "version": "7.4.1", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.4.1.tgz", - "integrity": "sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A==", - "dev": true - }, - "eslint-visitor-keys": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.3.0.tgz", - "integrity": "sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ==", - "dev": true - } + "@eslint/core": "^0.17.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" } }, - "esprima": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", - "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", - "dev": true - }, - "esquery": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.4.0.tgz", - "integrity": "sha512-cCDispWt5vHHtwMY2YrAQ4ibFkAL8RbH5YGBnZBc90MolvvfkkQcJro/aZiAQUlQ3qgrYS6D6v8Gc5G5CQsc9w==", + "node_modules/@eslint/core": { + "version": "0.17.0", + "resolved": "https://registry.npmjs.org/@eslint/core/-/core-0.17.0.tgz", + "integrity": "sha512-yL/sLrpmtDaFEiUj1osRP4TI2MDz1AddJL+jZ7KSqvBuliN4xqYY54IfdN8qD8Toa6g1iloph1fxQNkjOxrrpQ==", "dev": true, - "requires": { - "estraverse": "^5.1.0" - }, + "license": "Apache-2.0", "dependencies": { - "estraverse": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.2.0.tgz", - "integrity": "sha512-BxbNGGNm0RyRYvUdHpIwv9IWzeM9XClbOxwoATuFdOE7ZE6wHL+HQ5T8hoPM+zHvmKzzsEqhgy0GrQ5X13afiQ==", - "dev": true - } + "@types/json-schema": "^7.0.15" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" } }, - "esrecurse": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.3.0.tgz", - "integrity": "sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==", + "node_modules/@eslint/eslintrc": { + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-3.3.3.tgz", + "integrity": "sha512-Kr+LPIUVKz2qkx1HAMH8q1q6azbqBAsXJUxBl/ODDuVPX45Z9DfwB8tPjTi6nNZ8BuM3nbJxC5zCAg5elnBUTQ==", "dev": true, - "requires": { - "estraverse": "^5.2.0" - }, + "license": "MIT", "dependencies": { - "estraverse": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.2.0.tgz", - "integrity": "sha512-BxbNGGNm0RyRYvUdHpIwv9IWzeM9XClbOxwoATuFdOE7ZE6wHL+HQ5T8hoPM+zHvmKzzsEqhgy0GrQ5X13afiQ==", - "dev": true - } + "ajv": "^6.12.4", + "debug": "^4.3.2", + "espree": "^10.0.1", + "globals": "^14.0.0", + "ignore": "^5.2.0", + "import-fresh": "^3.2.1", + "js-yaml": "^4.1.1", + "minimatch": "^3.1.2", + "strip-json-comments": "^3.1.1" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" } }, - "estraverse": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", - "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==", - "dev": true - }, - "estree-walker": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-1.0.1.tgz", - "integrity": "sha512-1fMXF3YP4pZZVozF8j/ZLfvnR8NSIljt56UhbZ5PeeDmmGHpgpdwQt7ITlGvYaQukCvuBRMLEiKiYC+oeIg4cg==", - "dev": true - }, - "esutils": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", - "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", - "dev": true - }, - "execa": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/execa/-/execa-5.0.0.tgz", - "integrity": "sha512-ov6w/2LCiuyO4RLYGdpFGjkcs0wMTgGE8PrkTHikeUy5iJekXyPIKUjifk5CsE0pt7sMCrMZ3YNqoCj6idQOnQ==", + "node_modules/@eslint/eslintrc/node_modules/globals": { + "version": "14.0.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-14.0.0.tgz", + "integrity": "sha512-oahGvuMGQlPw/ivIYBjVSrWAfWLBeku5tpPE2fOPLi+WHffIWbuh2tCjhyQhTBPMf5E9jDEH4FOmTYgYwbKwtQ==", "dev": true, - "requires": { - "cross-spawn": "^7.0.3", - "get-stream": "^6.0.0", - "human-signals": "^2.1.0", - "is-stream": "^2.0.0", - "merge-stream": "^2.0.0", - "npm-run-path": "^4.0.1", - "onetime": "^5.1.2", - "signal-exit": "^3.0.3", - "strip-final-newline": "^2.0.0" + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, - "fast-deep-equal": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", - "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", - "dev": true - }, - "fast-json-stable-stringify": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", - "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==", - "dev": true - }, - "fast-levenshtein": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", - "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=", - "dev": true - }, - "figures": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/figures/-/figures-3.2.0.tgz", - "integrity": "sha512-yaduQFRKLXYOGgEn6AZau90j3ggSOyiqXU0F9JZfeXYhNa+Jk4X+s45A2zg5jns87GAFa34BBm2kXw4XpNcbdg==", + "node_modules/@eslint/js": { + "version": "9.39.2", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.39.2.tgz", + "integrity": "sha512-q1mjIoW1VX4IvSocvM/vbTiveKC4k9eLrajNEuSsmjymSDEbpGddtpfOoN7YGAqBK3NG+uqo8ia4PDTt8buCYA==", "dev": true, - "requires": { - "escape-string-regexp": "^1.0.5" + "license": "MIT", + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://eslint.org/donate" } }, - "file-entry-cache": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-6.0.0.tgz", - "integrity": "sha512-fqoO76jZ3ZnYrXLDRxBR1YvOvc0k844kcOg40bgsPrE25LAb/PDqTY+ho64Xh2c8ZXgIKldchCFHczG2UVRcWA==", + "node_modules/@eslint/object-schema": { + "version": "2.1.7", + "resolved": "https://registry.npmjs.org/@eslint/object-schema/-/object-schema-2.1.7.tgz", + "integrity": "sha512-VtAOaymWVfZcmZbp6E2mympDIHvyjXs/12LqWYjVw6qjrfF+VK+fyG33kChz3nnK+SU5/NeHOqrTEHS8sXO3OA==", "dev": true, - "requires": { - "flat-cache": "^3.0.4" + "license": "Apache-2.0", + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" } }, - "fill-range": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", - "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "node_modules/@eslint/plugin-kit": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/@eslint/plugin-kit/-/plugin-kit-0.4.1.tgz", + "integrity": "sha512-43/qtrDUokr7LJqoF2c3+RInu/t4zfrpYdoSDfYyhg52rwLV6TnOvdG4fXm7IkSB3wErkcmJS9iEhjVtOSEjjA==", "dev": true, - "requires": { - "to-regex-range": "^5.0.1" + "license": "Apache-2.0", + "dependencies": { + "@eslint/core": "^0.17.0", + "levn": "^0.4.1" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" } }, - "find-cache-dir": { - "version": "3.3.1", - "resolved": "https://registry.npmjs.org/find-cache-dir/-/find-cache-dir-3.3.1.tgz", - "integrity": "sha512-t2GDMt3oGC/v+BMwzmllWDuJF/xcDtE5j/fCGbqDD7OLuJkj0cfh1YSA5VKPvwMeLFLNDBkwOKZ2X85jGLVftQ==", + "node_modules/@floating-ui/core": { + "version": "1.7.3", + "resolved": "https://registry.npmjs.org/@floating-ui/core/-/core-1.7.3.tgz", + "integrity": "sha512-sGnvb5dmrJaKEZ+LDIpguvdX3bDlEllmv4/ClQ9awcmCZrlx5jQyyMWFM5kBI+EyNOCDDiKk8il0zeuX3Zlg/w==", "dev": true, - "requires": { - "commondir": "^1.0.1", - "make-dir": "^3.0.2", - "pkg-dir": "^4.1.0" - }, + "license": "MIT", "dependencies": { - "find-up": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", - "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", - "dev": true, - "requires": { - "locate-path": "^5.0.0", - "path-exists": "^4.0.0" - } - }, - "locate-path": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", - "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", - "dev": true, - "requires": { - "p-locate": "^4.1.0" - } - }, - "p-limit": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", - "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", - "dev": true, - "requires": { - "p-try": "^2.0.0" - } - }, - "p-locate": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", - "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", - "dev": true, - "requires": { - "p-limit": "^2.2.0" - } - }, - "p-try": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", - "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", - "dev": true - }, - "path-exists": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", - "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", - "dev": true - }, - "pkg-dir": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-4.2.0.tgz", - "integrity": "sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ==", - "dev": true, - "requires": { - "find-up": "^4.0.0" - } - } + "@floating-ui/utils": "^0.2.10" } }, - "find-up": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-2.1.0.tgz", - "integrity": "sha1-RdG35QbHF93UgndaK3eSCjwMV6c=", + "node_modules/@floating-ui/dom": { + "version": "1.7.4", + "resolved": "https://registry.npmjs.org/@floating-ui/dom/-/dom-1.7.4.tgz", + "integrity": "sha512-OOchDgh4F2CchOX94cRVqhvy7b3AFb+/rQXyswmzmGakRfkMgoWVjfnLWkRirfLEfuD4ysVW16eXzwt3jHIzKA==", "dev": true, - "requires": { - "locate-path": "^2.0.0" + "license": "MIT", + "dependencies": { + "@floating-ui/core": "^1.7.3", + "@floating-ui/utils": "^0.2.10" } }, - "fixturify": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/fixturify/-/fixturify-2.1.0.tgz", - "integrity": "sha512-gHq6UCv8DE91EpiaRSzrmvLoRvFOBzI961IQ3gXE5wfmMM1TtApDcZAonG2hnp6GJrVFCxHwP01wSw9VQJiJ1w==", + "node_modules/@floating-ui/react": { + "version": "0.27.16", + "resolved": "https://registry.npmjs.org/@floating-ui/react/-/react-0.27.16.tgz", + "integrity": "sha512-9O8N4SeG2z++TSM8QA/KTeKFBVCNEz/AGS7gWPJf6KFRzmRWixFRnCnkPHRDwSVZW6QPDO6uT0P2SpWNKCc9/g==", "dev": true, - "requires": { - "@types/fs-extra": "^8.1.0", - "@types/minimatch": "^3.0.3", - "@types/rimraf": "^2.0.3", - "fs-extra": "^8.1.0", - "matcher-collection": "^2.0.1", - "walk-sync": "^2.0.2" + "license": "MIT", + "dependencies": { + "@floating-ui/react-dom": "^2.1.6", + "@floating-ui/utils": "^0.2.10", + "tabbable": "^6.0.0" + }, + "peerDependencies": { + "react": ">=17.0.0", + "react-dom": ">=17.0.0" } }, - "flat": { - "version": "5.0.2", - "resolved": "https://registry.npmjs.org/flat/-/flat-5.0.2.tgz", - "integrity": "sha512-b6suED+5/3rTpUBdG1gupIl8MPFCAMA0QXwmljLhvCUKcUvdE4gWky9zpuGCcXHOsz4J9wPGNWq6OKpmIzz3hQ==", - "dev": true - }, - "flat-cache": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-3.0.4.tgz", - "integrity": "sha512-dm9s5Pw7Jc0GvMYbshN6zchCA9RgQlzzEZX3vylR9IqFfS8XciblUXOKfW6SiuJ0e13eDYZoZV5wdrev7P3Nwg==", + "node_modules/@floating-ui/react-dom": { + "version": "2.1.6", + "resolved": "https://registry.npmjs.org/@floating-ui/react-dom/-/react-dom-2.1.6.tgz", + "integrity": "sha512-4JX6rEatQEvlmgU80wZyq9RT96HZJa88q8hp0pBd+LrczeDI4o6uA2M+uvxngVHo4Ihr8uibXxH6+70zhAFrVw==", "dev": true, - "requires": { - "flatted": "^3.1.0", - "rimraf": "^3.0.2" + "license": "MIT", + "dependencies": { + "@floating-ui/dom": "^1.7.4" + }, + "peerDependencies": { + "react": ">=16.8.0", + "react-dom": ">=16.8.0" } }, - "flatted": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.1.1.tgz", - "integrity": "sha512-zAoAQiudy+r5SvnSw3KJy5os/oRJYHzrzja/tBDqrZtNhUw8bt6y8OBzMWcjWr+8liV8Eb6yOhw8WZ7VFZ5ZzA==", - "dev": true + "node_modules/@floating-ui/utils": { + "version": "0.2.10", + "resolved": "https://registry.npmjs.org/@floating-ui/utils/-/utils-0.2.10.tgz", + "integrity": "sha512-aGTxbpbg8/b5JfU1HXSrbH3wXZuLPJcNEcZQFMxLs3oSzgtVu6nFPkbbGGUvBcUjKV2YyB9Wxxabo+HEH9tcRQ==", + "dev": true, + "license": "MIT" }, - "foreground-child": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-2.0.0.tgz", - "integrity": "sha512-dCIq9FpEcyQyXKCkyzmlPTFNgrCzPudOe+mhvJU5zAtlBnGVy2yKxtfsxK2tQBThwq225jcvBjpw1Gr40uzZCA==", + "node_modules/@headlessui/react": { + "version": "2.2.9", + "resolved": "https://registry.npmjs.org/@headlessui/react/-/react-2.2.9.tgz", + "integrity": "sha512-Mb+Un58gwBn0/yWZfyrCh0TJyurtT+dETj7YHleylHk5od3dv2XqETPGWMyQ5/7sYN7oWdyM1u9MvC0OC8UmzQ==", "dev": true, - "requires": { - "cross-spawn": "^7.0.0", - "signal-exit": "^3.0.2" + "license": "MIT", + "dependencies": { + "@floating-ui/react": "^0.26.16", + "@react-aria/focus": "^3.20.2", + "@react-aria/interactions": "^3.25.0", + "@tanstack/react-virtual": "^3.13.9", + "use-sync-external-store": "^1.5.0" + }, + "engines": { + "node": ">=10" + }, + "peerDependencies": { + "react": "^18 || ^19 || ^19.0.0-rc", + "react-dom": "^18 || ^19 || ^19.0.0-rc" } }, - "fromentries": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/fromentries/-/fromentries-1.3.2.tgz", - "integrity": "sha512-cHEpEQHUg0f8XdtZCc2ZAhrHzKzT0MrFUTcvx+hfxYu7rGMDc5SKoXFh+n4YigxsHXRzc6OrCshdR1bWH6HHyg==", - "dev": true - }, - "fs-extra": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-8.1.0.tgz", - "integrity": "sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==", + "node_modules/@headlessui/react/node_modules/@floating-ui/react": { + "version": "0.26.28", + "resolved": "https://registry.npmjs.org/@floating-ui/react/-/react-0.26.28.tgz", + "integrity": "sha512-yORQuuAtVpiRjpMhdc0wJj06b9JFjrYF4qp96j++v2NBpbi6SEGF7donUJ3TMieerQ6qVkAv1tgr7L4r5roTqw==", "dev": true, - "requires": { - "graceful-fs": "^4.2.0", - "jsonfile": "^4.0.0", - "universalify": "^0.1.0" + "license": "MIT", + "dependencies": { + "@floating-ui/react-dom": "^2.1.2", + "@floating-ui/utils": "^0.2.8", + "tabbable": "^6.0.0" + }, + "peerDependencies": { + "react": ">=16.8.0", + "react-dom": ">=16.8.0" } }, - "fs.realpath": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", - "dev": true + "node_modules/@headlessui/tailwindcss": { + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/@headlessui/tailwindcss/-/tailwindcss-0.2.2.tgz", + "integrity": "sha512-xNe42KjdyA4kfUKLLPGzME9zkH7Q3rOZ5huFihWNWOQFxnItxPB3/67yBI8/qBfY8nwBRx5GHn4VprsoluVMGw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + }, + "peerDependencies": { + "tailwindcss": "^3.0 || ^4.0" + } }, - "fsevents": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", - "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", - "optional": true + "node_modules/@humanfs/core": { + "version": "0.19.1", + "resolved": "https://registry.npmjs.org/@humanfs/core/-/core-0.19.1.tgz", + "integrity": "sha512-5DyQ4+1JEUzejeK1JGICcideyfUbGixgS9jNgex5nqkW+cY7WZhxBigmieN5Qnw9ZosSNVC9KQKyb+GUaGyKUA==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=18.18.0" + } }, - "function-bind": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", - "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", - "dev": true + "node_modules/@humanfs/node": { + "version": "0.16.7", + "resolved": "https://registry.npmjs.org/@humanfs/node/-/node-0.16.7.tgz", + "integrity": "sha512-/zUx+yOsIrG4Y43Eh2peDeKCxlRt/gET6aHfaKpuq267qXdYDFViVHfMaLyygZOnl0kGWxFIgsBy8QFuTLUXEQ==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@humanfs/core": "^0.19.1", + "@humanwhocodes/retry": "^0.4.0" + }, + "engines": { + "node": ">=18.18.0" + } }, - "functional-red-black-tree": { + "node_modules/@humanwhocodes/module-importer": { "version": "1.0.1", - "resolved": "https://registry.npmjs.org/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz", - "integrity": "sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc=", - "dev": true - }, - "gensync": { - "version": "1.0.0-beta.2", - "resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.2.tgz", - "integrity": "sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg==", - "dev": true - }, - "get-caller-file": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", - "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", - "dev": true - }, - "get-intrinsic": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.1.1.tgz", - "integrity": "sha512-kWZrnVM42QCiEA2Ig1bG8zjoIMOgxWwYCEeNdwY6Tv/cOSeGpcoX4pXHfKUxNKVoArnrEr2e9srnAxxGIraS9Q==", + "resolved": "https://registry.npmjs.org/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz", + "integrity": "sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA==", "dev": true, - "requires": { - "function-bind": "^1.1.1", - "has": "^1.0.3", - "has-symbols": "^1.0.1" + "license": "Apache-2.0", + "engines": { + "node": ">=12.22" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/nzakas" } }, - "get-own-enumerable-property-symbols": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/get-own-enumerable-property-symbols/-/get-own-enumerable-property-symbols-3.0.2.tgz", - "integrity": "sha512-I0UBV/XOz1XkIJHEUDMZAbzCThU/H8DxmSfmdGcKPnVhu2VfFqr34jr9777IyaTYvxjedWhqVIilEDsCdP5G6g==", - "dev": true + "node_modules/@humanwhocodes/retry": { + "version": "0.4.3", + "resolved": "https://registry.npmjs.org/@humanwhocodes/retry/-/retry-0.4.3.tgz", + "integrity": "sha512-bV0Tgo9K4hfPCek+aMAn81RppFKv2ySDQeMoSZuvTASywNTnVJCArCZE2FWqpvIatKu7VMRLWlR1EazvVhDyhQ==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=18.18" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/nzakas" + } }, - "get-package-type": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/get-package-type/-/get-package-type-0.1.0.tgz", - "integrity": "sha512-pjzuKtY64GYfWizNAJ0fr9VqttZkNiK2iS430LtIHzjBEr6bX8Am2zm4sW4Ro5wjWW5cAlRL1qAMTcXbjNAO2Q==", - "dev": true + "node_modules/@iconify-json/simple-icons": { + "version": "1.2.66", + "resolved": "https://registry.npmjs.org/@iconify-json/simple-icons/-/simple-icons-1.2.66.tgz", + "integrity": "sha512-D1OnnXwiQXFkVMw5M+Bt8mPsXeMkQyGmMdrmN7lsQlKMUkfLOp6JWhnUJ92po51WXT046aF/zzqSmkKqg08p4Q==", + "dev": true, + "license": "CC0-1.0", + "dependencies": { + "@iconify/types": "*" + } }, - "get-stdin": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-8.0.0.tgz", - "integrity": "sha512-sY22aA6xchAzprjyqmSEQv4UbAAzRN0L2dQB0NlN5acTTK9Don6nhoc3eAbUnpZiCANAMfd/+40kVdKfFygohg==", - "dev": true + "node_modules/@iconify/types": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@iconify/types/-/types-2.0.0.tgz", + "integrity": "sha512-+wluvCrRhXrhyOmRDJ3q8mux9JkKy5SJ/v8ol2tu4FVjyYvtEzkc/3pK15ET6RKg4b4w4BmTk1+gsCUhf21Ykg==", + "dev": true, + "license": "MIT" }, - "get-stream": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-6.0.0.tgz", - "integrity": "sha512-A1B3Bh1UmL0bidM/YX2NsCOTnGJePL9rO/M+Mw3m9f2gUpfokS0hi5Eah0WSUEWZdZhIZtMjkIYS7mDfOqNHbg==", - "dev": true + "node_modules/@iconify/utils": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@iconify/utils/-/utils-3.1.0.tgz", + "integrity": "sha512-Zlzem1ZXhI1iHeeERabLNzBHdOa4VhQbqAcOQaMKuTuyZCpwKbC2R4Dd0Zo3g9EAc+Y4fiarO8HIHRAth7+skw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@antfu/install-pkg": "^1.1.0", + "@iconify/types": "^2.0.0", + "mlly": "^1.8.0" + } }, - "get-symbol-from-current-process-h": { + "node_modules/@inquirer/ansi": { "version": "1.0.2", - "resolved": "https://registry.npmjs.org/get-symbol-from-current-process-h/-/get-symbol-from-current-process-h-1.0.2.tgz", - "integrity": "sha512-syloC6fsCt62ELLrr1VKBM1ggOpMdetX9hTrdW77UQdcApPHLmf7CI7OKcN1c9kYuNxKcDe4iJ4FY9sX3aw2xw==", - "dev": true - }, - "get-uv-event-loop-napi-h": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/get-uv-event-loop-napi-h/-/get-uv-event-loop-napi-h-1.0.6.tgz", - "integrity": "sha512-t5c9VNR84nRoF+eLiz6wFrEp1SE2Acg0wS+Ysa2zF0eROes+LzOfuTaVHxGy8AbS8rq7FHEJzjnCZo1BupwdJg==", + "resolved": "https://registry.npmjs.org/@inquirer/ansi/-/ansi-1.0.2.tgz", + "integrity": "sha512-S8qNSZiYzFd0wAcyG5AXCvUHC5Sr7xpZ9wZ2py9XR88jUz8wooStVx5M6dRzczbBWjic9NP7+rY0Xi7qqK/aMQ==", "dev": true, - "requires": { - "get-symbol-from-current-process-h": "^1.0.1" + "license": "MIT", + "engines": { + "node": ">=18" } }, - "glob": { - "version": "7.1.6", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz", - "integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==", + "node_modules/@inquirer/checkbox": { + "version": "4.3.2", + "resolved": "https://registry.npmjs.org/@inquirer/checkbox/-/checkbox-4.3.2.tgz", + "integrity": "sha512-VXukHf0RR1doGe6Sm4F0Em7SWYLTHSsbGfJdS9Ja2bX5/D5uwVOEjr07cncLROdBvmnvCATYEWlHqYmXv2IlQA==", "dev": true, - "requires": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" + "license": "MIT", + "dependencies": { + "@inquirer/ansi": "^1.0.2", + "@inquirer/core": "^10.3.2", + "@inquirer/figures": "^1.0.15", + "@inquirer/type": "^3.0.10", + "yoctocolors-cjs": "^2.1.3" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "@types/node": ">=18" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + } } }, - "glob-parent": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.1.tgz", - "integrity": "sha512-FnI+VGOpnlGHWZxthPGR+QhR78fuiK0sNLkHQv+bL9fQi57lNNdquIbna/WrfROrolq8GK5Ek6BiMwqL/voRYQ==", + "node_modules/@inquirer/confirm": { + "version": "5.1.21", + "resolved": "https://registry.npmjs.org/@inquirer/confirm/-/confirm-5.1.21.tgz", + "integrity": "sha512-KR8edRkIsUayMXV+o3Gv+q4jlhENF9nMYUZs9PA2HzrXeHI8M5uDag70U7RJn9yyiMZSbtF5/UexBtAVtZGSbQ==", "dev": true, - "requires": { - "is-glob": "^4.0.1" + "license": "MIT", + "dependencies": { + "@inquirer/core": "^10.3.2", + "@inquirer/type": "^3.0.10" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "@types/node": ">=18" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + } } }, - "globals": { - "version": "12.4.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-12.4.0.tgz", - "integrity": "sha512-BWICuzzDvDoH54NHKCseDanAhE3CeDorgDL5MT6LMXXj2WCnd9UC2szdk4AWLfjdgNBCXLUanXYcpBBKOSWGwg==", + "node_modules/@inquirer/core": { + "version": "10.3.2", + "resolved": "https://registry.npmjs.org/@inquirer/core/-/core-10.3.2.tgz", + "integrity": "sha512-43RTuEbfP8MbKzedNqBrlhhNKVwoK//vUFNW3Q3vZ88BLcrs4kYpGg+B2mm5p2K/HfygoCxuKwJJiv8PbGmE0A==", "dev": true, - "requires": { - "type-fest": "^0.8.1" + "license": "MIT", + "dependencies": { + "@inquirer/ansi": "^1.0.2", + "@inquirer/figures": "^1.0.15", + "@inquirer/type": "^3.0.10", + "cli-width": "^4.1.0", + "mute-stream": "^2.0.0", + "signal-exit": "^4.1.0", + "wrap-ansi": "^6.2.0", + "yoctocolors-cjs": "^2.1.3" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "@types/node": ">=18" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + } } }, - "graceful-fs": { - "version": "4.2.6", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.6.tgz", - "integrity": "sha512-nTnJ528pbqxYanhpDYsi4Rd8MAeaBA67+RZ10CM1m3bTAVFEDcd5AuA4a6W5YkGZ1iNXHzZz8T6TBKLeBuNriQ==", - "dev": true + "node_modules/@inquirer/editor": { + "version": "4.2.23", + "resolved": "https://registry.npmjs.org/@inquirer/editor/-/editor-4.2.23.tgz", + "integrity": "sha512-aLSROkEwirotxZ1pBaP8tugXRFCxW94gwrQLxXfrZsKkfjOYC1aRvAZuhpJOb5cu4IBTJdsCigUlf2iCOu4ZDQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@inquirer/core": "^10.3.2", + "@inquirer/external-editor": "^1.0.3", + "@inquirer/type": "^3.0.10" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "@types/node": ">=18" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + } + } }, - "growl": { - "version": "1.10.5", - "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.5.tgz", - "integrity": "sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA==", - "dev": true + "node_modules/@inquirer/expand": { + "version": "4.0.23", + "resolved": "https://registry.npmjs.org/@inquirer/expand/-/expand-4.0.23.tgz", + "integrity": "sha512-nRzdOyFYnpeYTTR2qFwEVmIWypzdAx/sIkCMeTNTcflFOovfqUk+HcFhQQVBftAh9gmGrpFj6QcGEqrDMDOiew==", + "dev": true, + "license": "MIT", + "dependencies": { + "@inquirer/core": "^10.3.2", + "@inquirer/type": "^3.0.10", + "yoctocolors-cjs": "^2.1.3" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "@types/node": ">=18" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + } + } }, - "has": { + "node_modules/@inquirer/external-editor": { "version": "1.0.3", - "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", - "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", + "resolved": "https://registry.npmjs.org/@inquirer/external-editor/-/external-editor-1.0.3.tgz", + "integrity": "sha512-RWbSrDiYmO4LbejWY7ttpxczuwQyZLBUyygsA9Nsv95hpzUWwnNTVQmAq3xuh7vNwCp07UTmE5i11XAEExx4RA==", "dev": true, - "requires": { - "function-bind": "^1.1.1" + "license": "MIT", + "dependencies": { + "chardet": "^2.1.1", + "iconv-lite": "^0.7.0" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "@types/node": ">=18" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + } } }, - "has-flag": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", - "dev": true - }, - "has-symbols": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.1.tgz", - "integrity": "sha512-PLcsoqu++dmEIZB+6totNFKq/7Do+Z0u4oT0zKOJNl3lYK6vGwwu2hjHs+68OEZbTjiUE9bgOABXbP/GvrS0Kg==", - "dev": true - }, - "hash.js": { - "version": "1.1.7", - "resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.1.7.tgz", - "integrity": "sha512-taOaskGt4z4SOANNseOviYDvjEJinIkRgmp7LbKP2YTTmVxWBl87s/uzK9r+44BclBSp2X7K1hqeNfz9JbBeXA==", + "node_modules/@inquirer/figures": { + "version": "1.0.15", + "resolved": "https://registry.npmjs.org/@inquirer/figures/-/figures-1.0.15.tgz", + "integrity": "sha512-t2IEY+unGHOzAaVM5Xx6DEWKeXlDDcNPeDyUpsRc6CUhBfU3VQOEl+Vssh7VNp1dR8MdUJBWhuObjXCsVpjN5g==", "dev": true, - "requires": { - "inherits": "^2.0.3", - "minimalistic-assert": "^1.0.1" + "license": "MIT", + "engines": { + "node": ">=18" } }, - "hasha": { - "version": "5.2.2", - "resolved": "https://registry.npmjs.org/hasha/-/hasha-5.2.2.tgz", - "integrity": "sha512-Hrp5vIK/xr5SkeN2onO32H0MgNZ0f17HRNH39WfL0SYUNOTZ5Lz1TJ8Pajo/87dYGEFlLMm7mIc/k/s6Bvz9HQ==", + "node_modules/@inquirer/input": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/@inquirer/input/-/input-4.3.1.tgz", + "integrity": "sha512-kN0pAM4yPrLjJ1XJBjDxyfDduXOuQHrBB8aLDMueuwUGn+vNpF7Gq7TvyVxx8u4SHlFFj4trmj+a2cbpG4Jn1g==", "dev": true, - "requires": { - "is-stream": "^2.0.0", - "type-fest": "^0.8.0" + "license": "MIT", + "dependencies": { + "@inquirer/core": "^10.3.2", + "@inquirer/type": "^3.0.10" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "@types/node": ">=18" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + } } }, - "he": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz", - "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==", - "dev": true - }, - "hosted-git-info": { - "version": "2.8.8", - "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.8.tgz", - "integrity": "sha512-f/wzC2QaWBs7t9IYqB4T3sR1xviIViXJRJTWBlx2Gf3g0Xi5vI7Yy4koXQ1c9OYDGHN9sBy1DQ2AB8fqZBWhUg==", - "dev": true - }, - "html-escaper": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/html-escaper/-/html-escaper-2.0.2.tgz", - "integrity": "sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==", - "dev": true - }, - "human-signals": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-2.1.0.tgz", - "integrity": "sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw==", - "dev": true - }, - "husky": { - "version": "5.0.9", - "resolved": "https://registry.npmjs.org/husky/-/husky-5.0.9.tgz", - "integrity": "sha512-0SjcaY21a+IRdx7p7r/X33Vc09UR2m8SbP8yfkhUX2/jAmwcz+GR7i9jXkp2pP3GfX23JhMkVP6SWwXB18uXtg==", - "dev": true - }, - "ignore": { - "version": "4.0.6", - "resolved": "https://registry.npmjs.org/ignore/-/ignore-4.0.6.tgz", - "integrity": "sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg==", - "dev": true - }, - "import-fresh": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.0.tgz", - "integrity": "sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw==", + "node_modules/@inquirer/number": { + "version": "3.0.23", + "resolved": "https://registry.npmjs.org/@inquirer/number/-/number-3.0.23.tgz", + "integrity": "sha512-5Smv0OK7K0KUzUfYUXDXQc9jrf8OHo4ktlEayFlelCjwMXz0299Y8OrI+lj7i4gCBY15UObk76q0QtxjzFcFcg==", "dev": true, - "requires": { - "parent-module": "^1.0.0", - "resolve-from": "^4.0.0" + "license": "MIT", + "dependencies": { + "@inquirer/core": "^10.3.2", + "@inquirer/type": "^3.0.10" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "@types/node": ">=18" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + } } }, - "imurmurhash": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", - "integrity": "sha1-khi5srkoojixPcT7a21XbyMUU+o=", - "dev": true - }, - "indent-string": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-4.0.0.tgz", - "integrity": "sha512-EdDDZu4A2OyIK7Lr/2zG+w5jmbuk1DVBnEwREQvBzspBJkCEbRa8GxU1lghYcaGJCnRWibjDXlq779X1/y5xwg==", - "dev": true + "node_modules/@inquirer/password": { + "version": "4.0.23", + "resolved": "https://registry.npmjs.org/@inquirer/password/-/password-4.0.23.tgz", + "integrity": "sha512-zREJHjhT5vJBMZX/IUbyI9zVtVfOLiTO66MrF/3GFZYZ7T4YILW5MSkEYHceSii/KtRk+4i3RE7E1CUXA2jHcA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@inquirer/ansi": "^1.0.2", + "@inquirer/core": "^10.3.2", + "@inquirer/type": "^3.0.10" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "@types/node": ">=18" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + } + } }, - "inflight": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", - "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "node_modules/@inquirer/prompts": { + "version": "7.10.1", + "resolved": "https://registry.npmjs.org/@inquirer/prompts/-/prompts-7.10.1.tgz", + "integrity": "sha512-Dx/y9bCQcXLI5ooQ5KyvA4FTgeo2jYj/7plWfV5Ak5wDPKQZgudKez2ixyfz7tKXzcJciTxqLeK7R9HItwiByg==", "dev": true, - "requires": { - "once": "^1.3.0", - "wrappy": "1" + "license": "MIT", + "dependencies": { + "@inquirer/checkbox": "^4.3.2", + "@inquirer/confirm": "^5.1.21", + "@inquirer/editor": "^4.2.23", + "@inquirer/expand": "^4.0.23", + "@inquirer/input": "^4.3.1", + "@inquirer/number": "^3.0.23", + "@inquirer/password": "^4.0.23", + "@inquirer/rawlist": "^4.1.11", + "@inquirer/search": "^3.2.2", + "@inquirer/select": "^4.4.2" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "@types/node": ">=18" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + } } }, - "inherits": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", - "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", - "dev": true - }, - "ini": { - "version": "1.3.8", - "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.8.tgz", - "integrity": "sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==", - "dev": true - }, - "interpret": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/interpret/-/interpret-1.4.0.tgz", - "integrity": "sha512-agE4QfB2Lkp9uICn7BAqoscw4SZP9kTE2hxiFI3jBPmXJfdqiahTbUuKGsMoN2GtqL9AxhYioAcVvgsb1HvRbA==", - "dev": true - }, - "is-arrayish": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", - "integrity": "sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0=", - "dev": true - }, - "is-binary-path": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", - "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", + "node_modules/@inquirer/rawlist": { + "version": "4.1.11", + "resolved": "https://registry.npmjs.org/@inquirer/rawlist/-/rawlist-4.1.11.tgz", + "integrity": "sha512-+LLQB8XGr3I5LZN/GuAHo+GpDJegQwuPARLChlMICNdwW7OwV2izlCSCxN6cqpL0sMXmbKbFcItJgdQq5EBXTw==", "dev": true, - "requires": { - "binary-extensions": "^2.0.0" + "license": "MIT", + "dependencies": { + "@inquirer/core": "^10.3.2", + "@inquirer/type": "^3.0.10", + "yoctocolors-cjs": "^2.1.3" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "@types/node": ">=18" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + } } }, - "is-callable": { - "version": "1.2.3", - "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.3.tgz", - "integrity": "sha512-J1DcMe8UYTBSrKezuIUTUwjXsho29693unXM2YhJUTR2txK/eG47bvNa/wipPFmZFgr/N6f1GA66dv0mEyTIyQ==", - "dev": true - }, - "is-core-module": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.2.0.tgz", - "integrity": "sha512-XRAfAdyyY5F5cOXn7hYQDqh2Xmii+DEfIcQGxK/uNwMHhIkPWO0g8msXcbzLe+MpGoR951MlqM/2iIlU4vKDdQ==", + "node_modules/@inquirer/search": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/@inquirer/search/-/search-3.2.2.tgz", + "integrity": "sha512-p2bvRfENXCZdWF/U2BXvnSI9h+tuA8iNqtUKb9UWbmLYCRQxd8WkvwWvYn+3NgYaNwdUkHytJMGG4MMLucI1kA==", "dev": true, - "requires": { - "has": "^1.0.3" + "license": "MIT", + "dependencies": { + "@inquirer/core": "^10.3.2", + "@inquirer/figures": "^1.0.15", + "@inquirer/type": "^3.0.10", + "yoctocolors-cjs": "^2.1.3" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "@types/node": ">=18" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + } } }, - "is-date-object": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.2.tgz", - "integrity": "sha512-USlDT524woQ08aoZFzh3/Z6ch9Y/EWXEHQ/AaRN0SkKq4t2Jw2R2339tSXmwuVoY7LLlBCbOIlx2myP/L5zk0g==", - "dev": true - }, - "is-extglob": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", - "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=", - "dev": true - }, - "is-fullwidth-code-point": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", - "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", - "dev": true - }, - "is-glob": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.1.tgz", - "integrity": "sha512-5G0tKtBTFImOqDnLB2hG6Bp2qcKEFduo4tZu9MT/H6NQv/ghhy30o55ufafxJ/LdH79LLs2Kfrn85TLKyA7BUg==", + "node_modules/@inquirer/select": { + "version": "4.4.2", + "resolved": "https://registry.npmjs.org/@inquirer/select/-/select-4.4.2.tgz", + "integrity": "sha512-l4xMuJo55MAe+N7Qr4rX90vypFwCajSakx59qe/tMaC1aEHWLyw68wF4o0A4SLAY4E0nd+Vt+EyskeDIqu1M6w==", "dev": true, - "requires": { - "is-extglob": "^2.1.1" + "license": "MIT", + "dependencies": { + "@inquirer/ansi": "^1.0.2", + "@inquirer/core": "^10.3.2", + "@inquirer/figures": "^1.0.15", + "@inquirer/type": "^3.0.10", + "yoctocolors-cjs": "^2.1.3" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "@types/node": ">=18" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + } } }, - "is-module": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-module/-/is-module-1.0.0.tgz", - "integrity": "sha1-Mlj7afeMFNW4FdZkM2tM/7ZEFZE=", - "dev": true - }, - "is-negative-zero": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/is-negative-zero/-/is-negative-zero-2.0.1.tgz", - "integrity": "sha512-2z6JzQvZRa9A2Y7xC6dQQm4FSTSTNWjKIYYTt4246eMTJmIo0Q+ZyOsU66X8lxK1AbB92dFeglPLrhwpeRKO6w==", - "dev": true - }, - "is-number": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", - "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", - "dev": true - }, - "is-obj": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/is-obj/-/is-obj-1.0.1.tgz", - "integrity": "sha1-PkcprB9f3gJc19g6iW2rn09n2w8=", - "dev": true - }, - "is-plain-obj": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-2.1.0.tgz", - "integrity": "sha512-YWnfyRwxL/+SsrWYfOpUtz5b3YD+nyfkHvjbcanzk8zgyO4ASD67uVMRt8k5bM4lLMDnXfriRhOpemw+NfT1eA==", - "dev": true - }, - "is-reference": { - "version": "git+https://github.com/lukastaegert/is-reference.git#54335717efde771de5395d00d6a9edf2d557f2ff", - "from": "git+https://github.com/lukastaegert/is-reference.git#update-class-features", + "node_modules/@inquirer/type": { + "version": "3.0.10", + "resolved": "https://registry.npmjs.org/@inquirer/type/-/type-3.0.10.tgz", + "integrity": "sha512-BvziSRxfz5Ov8ch0z/n3oijRSEcEsHnhggm4xFZe93DHcUCTlutlq9Ox4SVENAfcRD22UQq7T/atg9Wr3k09eA==", "dev": true, - "requires": { - "@types/estree": "*" + "license": "MIT", + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "@types/node": ">=18" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + } } }, - "is-regex": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.1.2.tgz", - "integrity": "sha512-axvdhb5pdhEVThqJzYXwMlVuZwC+FF2DpcOhTS+y/8jVq4trxyPgfcwIxIKiyeuLlSQYKkmUaPQJ8ZE4yNKXDg==", + "node_modules/@isaacs/cliui": { + "version": "8.0.2", + "resolved": "https://registry.npmjs.org/@isaacs/cliui/-/cliui-8.0.2.tgz", + "integrity": "sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA==", "dev": true, - "requires": { - "call-bind": "^1.0.2", - "has-symbols": "^1.0.1" + "license": "ISC", + "dependencies": { + "string-width": "^5.1.2", + "string-width-cjs": "npm:string-width@^4.2.0", + "strip-ansi": "^7.0.1", + "strip-ansi-cjs": "npm:strip-ansi@^6.0.1", + "wrap-ansi": "^8.1.0", + "wrap-ansi-cjs": "npm:wrap-ansi@^7.0.0" + }, + "engines": { + "node": ">=12" } }, - "is-regexp": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-regexp/-/is-regexp-1.0.0.tgz", - "integrity": "sha1-/S2INUXEa6xaYz57mgnof6LLUGk=", - "dev": true - }, - "is-stream": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.0.tgz", - "integrity": "sha512-XCoy+WlUr7d1+Z8GgSuXmpuUFC9fOhRXglJMx+dwLKTkL44Cjd4W1Z5P+BQZpr+cR93aGP4S/s7Ftw6Nd/kiEw==", - "dev": true - }, - "is-string": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/is-string/-/is-string-1.0.5.tgz", - "integrity": "sha512-buY6VNRjhQMiF1qWDouloZlQbRhDPCebwxSjxMjxgemYT46YMd2NR0/H+fBhEfWX4A/w9TBJ+ol+okqJKFE6vQ==", - "dev": true + "node_modules/@isaacs/cliui/node_modules/emoji-regex": { + "version": "9.2.2", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-9.2.2.tgz", + "integrity": "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==", + "dev": true, + "license": "MIT" }, - "is-symbol": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.3.tgz", - "integrity": "sha512-OwijhaRSgqvhm/0ZdAcXNZt9lYdKFpcRDT5ULUuYXPoT794UNOdU+gpT6Rzo7b4V2HUl/op6GqY894AZwv9faQ==", + "node_modules/@isaacs/cliui/node_modules/string-width": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-5.1.2.tgz", + "integrity": "sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA==", "dev": true, - "requires": { - "has-symbols": "^1.0.1" + "license": "MIT", + "dependencies": { + "eastasianwidth": "^0.2.0", + "emoji-regex": "^9.2.2", + "strip-ansi": "^7.0.1" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, - "is-typedarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", - "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=", - "dev": true - }, - "is-windows": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-windows/-/is-windows-1.0.2.tgz", - "integrity": "sha512-eXK1UInq2bPmjyX6e3VHIzMLobc4J94i4AWn+Hpq3OU5KkrRC96OAcR3PRJ/pGu6m8TRnBHP9dkXQVsT/COVIA==", - "dev": true - }, - "isarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", - "dev": true - }, - "isexe": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", - "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", - "dev": true - }, - "istanbul-lib-coverage": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/istanbul-lib-coverage/-/istanbul-lib-coverage-3.0.0.tgz", - "integrity": "sha512-UiUIqxMgRDET6eR+o5HbfRYP1l0hqkWOs7vNxC/mggutCMUIhWMm8gAHb8tHlyfD3/l6rlgNA5cKdDzEAf6hEg==", - "dev": true - }, - "istanbul-lib-hook": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/istanbul-lib-hook/-/istanbul-lib-hook-3.0.0.tgz", - "integrity": "sha512-Pt/uge1Q9s+5VAZ+pCo16TYMWPBIl+oaNIjgLQxcX0itS6ueeaA+pEfThZpH8WxhFgCiEb8sAJY6MdUKgiIWaQ==", + "node_modules/@isaacs/cliui/node_modules/wrap-ansi": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-8.1.0.tgz", + "integrity": "sha512-si7QWI6zUMq56bESFvagtmzMdGOtoxfR+Sez11Mobfc7tm+VkUckk9bW2UeffTGVUbOksxmSw0AA2gs8g71NCQ==", "dev": true, - "requires": { - "append-transform": "^2.0.0" + "license": "MIT", + "dependencies": { + "ansi-styles": "^6.1.0", + "string-width": "^5.0.1", + "strip-ansi": "^7.0.1" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" } }, - "istanbul-lib-instrument": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/istanbul-lib-instrument/-/istanbul-lib-instrument-4.0.3.tgz", - "integrity": "sha512-BXgQl9kf4WTCPCCpmFGoJkz/+uhvm7h7PFKUYxh7qarQd3ER33vHG//qaE8eN25l07YqZPpHXU9I09l/RD5aGQ==", + "node_modules/@istanbuljs/load-nyc-config": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz", + "integrity": "sha512-VjeHSlIzpv/NyD3N0YuHfXOPDIixcA1q2ZV98wsMqcYlPmv2n3Yb2lYP9XMElnaFVXg5A7YLTeLu6V84uQDjmQ==", "dev": true, - "requires": { - "@babel/core": "^7.7.5", - "@istanbuljs/schema": "^0.1.2", - "istanbul-lib-coverage": "^3.0.0", - "semver": "^6.3.0" - }, + "license": "ISC", "dependencies": { - "semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", - "dev": true - } + "camelcase": "^5.3.1", + "find-up": "^4.1.0", + "get-package-type": "^0.1.0", + "js-yaml": "^3.13.1", + "resolve-from": "^5.0.0" + }, + "engines": { + "node": ">=8" } }, - "istanbul-lib-processinfo": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/istanbul-lib-processinfo/-/istanbul-lib-processinfo-2.0.2.tgz", - "integrity": "sha512-kOwpa7z9hme+IBPZMzQ5vdQj8srYgAtaRqeI48NGmAQ+/5yKiHLV0QbYqQpxsdEF0+w14SoB8YbnHKcXE2KnYw==", + "node_modules/@istanbuljs/load-nyc-config/node_modules/argparse": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", "dev": true, - "requires": { - "archy": "^1.0.0", - "cross-spawn": "^7.0.0", - "istanbul-lib-coverage": "^3.0.0-alpha.1", - "make-dir": "^3.0.0", - "p-map": "^3.0.0", - "rimraf": "^3.0.0", - "uuid": "^3.3.3" - }, + "license": "MIT", "dependencies": { - "p-map": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/p-map/-/p-map-3.0.0.tgz", - "integrity": "sha512-d3qXVTF/s+W+CdJ5A29wywV2n8CQQYahlgz2bFiA+4eVNJbHJodPZ+/gXwPGh0bOqA+j8S+6+ckmvLGPk1QpxQ==", - "dev": true, - "requires": { - "aggregate-error": "^3.0.0" - } - } + "sprintf-js": "~1.0.2" } }, - "istanbul-lib-report": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/istanbul-lib-report/-/istanbul-lib-report-3.0.0.tgz", - "integrity": "sha512-wcdi+uAKzfiGT2abPpKZ0hSU1rGQjUQnLvtY5MpQ7QCTahD3VODhcu4wcfY1YtkGaDD5yuydOLINXsfbus9ROw==", + "node_modules/@istanbuljs/load-nyc-config/node_modules/find-up": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", + "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", "dev": true, - "requires": { - "istanbul-lib-coverage": "^3.0.0", - "make-dir": "^3.0.0", - "supports-color": "^7.1.0" - }, + "license": "MIT", "dependencies": { - "has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "dev": true - }, - "supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dev": true, - "requires": { - "has-flag": "^4.0.0" - } - } + "locate-path": "^5.0.0", + "path-exists": "^4.0.0" + }, + "engines": { + "node": ">=8" } }, - "istanbul-lib-source-maps": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/istanbul-lib-source-maps/-/istanbul-lib-source-maps-4.0.0.tgz", - "integrity": "sha512-c16LpFRkR8vQXyHZ5nLpY35JZtzj1PQY1iZmesUbf1FZHbIupcWfjgOXBY9YHkLEQ6puz1u4Dgj6qmU/DisrZg==", + "node_modules/@istanbuljs/load-nyc-config/node_modules/js-yaml": { + "version": "3.14.2", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.2.tgz", + "integrity": "sha512-PMSmkqxr106Xa156c2M265Z+FTrPl+oxd/rgOQy2tijQeK5TxQ43psO1ZCwhVOSdnn+RzkzlRz/eY4BgJBYVpg==", "dev": true, - "requires": { - "debug": "^4.1.1", - "istanbul-lib-coverage": "^3.0.0", - "source-map": "^0.6.1" - }, + "license": "MIT", "dependencies": { - "source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "dev": true - } + "argparse": "^1.0.7", + "esprima": "^4.0.0" + }, + "bin": { + "js-yaml": "bin/js-yaml.js" } }, - "istanbul-reports": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/istanbul-reports/-/istanbul-reports-3.0.2.tgz", - "integrity": "sha512-9tZvz7AiR3PEDNGiV9vIouQ/EAcqMXFmkcA1CDFTwOB98OZVDL0PH9glHotf5Ugp6GCOTypfzGWI/OqjWNCRUw==", + "node_modules/@istanbuljs/load-nyc-config/node_modules/locate-path": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", + "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", "dev": true, - "requires": { - "html-escaper": "^2.0.0", - "istanbul-lib-report": "^3.0.0" + "license": "MIT", + "dependencies": { + "p-locate": "^4.1.0" + }, + "engines": { + "node": ">=8" } }, - "jest-worker": { - "version": "26.6.2", - "resolved": "https://registry.npmjs.org/jest-worker/-/jest-worker-26.6.2.tgz", - "integrity": "sha512-KWYVV1c4i+jbMpaBC+U++4Va0cp8OisU185o73T1vo99hqi7w8tSJfUXYswwqqrjzwxa6KpRK54WhPvwf5w6PQ==", + "node_modules/@istanbuljs/load-nyc-config/node_modules/p-limit": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", + "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", "dev": true, - "requires": { - "@types/node": "*", - "merge-stream": "^2.0.0", - "supports-color": "^7.0.0" + "license": "MIT", + "dependencies": { + "p-try": "^2.0.0" }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/@istanbuljs/load-nyc-config/node_modules/p-locate": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", + "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", + "dev": true, + "license": "MIT", "dependencies": { - "has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "dev": true - }, - "supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dev": true, - "requires": { - "has-flag": "^4.0.0" - } - } + "p-limit": "^2.2.0" + }, + "engines": { + "node": ">=8" } }, - "js-tokens": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", - "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", - "dev": true + "node_modules/@istanbuljs/load-nyc-config/node_modules/resolve-from": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-5.0.0.tgz", + "integrity": "sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } }, - "js-yaml": { - "version": "3.14.0", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.0.tgz", - "integrity": "sha512-/4IbIeHcD9VMHFqDR/gQ7EdZdLimOvW2DdcxFjdyyZ9NsbS+ccrXqVWDtab/lRl5AlUqmpBx8EhPaWR+OtY17A==", + "node_modules/@istanbuljs/schema": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/@istanbuljs/schema/-/schema-0.1.3.tgz", + "integrity": "sha512-ZXRY4jNvVgSVQ8DL3LTcakaAtXwTVUxE81hslsyD2AtoXW/wVob10HkOJ1X/pAlcI7D+2YoZKg5do8G/w6RYgA==", "dev": true, - "requires": { - "argparse": "^1.0.7", - "esprima": "^4.0.0" + "license": "MIT", + "engines": { + "node": ">=8" } }, - "jsesc": { - "version": "0.5.0", - "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-0.5.0.tgz", - "integrity": "sha1-597mbjXW/Bb3EP6R1c9p9w8IkR0=", - "dev": true + "node_modules/@johnsoncodehk/pug-beautify": { + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/@johnsoncodehk/pug-beautify/-/pug-beautify-0.2.2.tgz", + "integrity": "sha512-qqNS/YD0Nck5wtQLCPHAfGVgWbbGafxSPjNh0ekYPFSNNqnDH2kamnduzYly8IiADmeVx/MfAE1njMEjVeHTMA==", + "dev": true, + "license": "MIT" }, - "json-parse-even-better-errors": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.1.tgz", - "integrity": "sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w==", - "dev": true + "node_modules/@jridgewell/gen-mapping": { + "version": "0.3.13", + "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.13.tgz", + "integrity": "sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.5.0", + "@jridgewell/trace-mapping": "^0.3.24" + } }, - "json-schema-traverse": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", - "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", - "dev": true + "node_modules/@jridgewell/remapping": { + "version": "2.3.5", + "resolved": "https://registry.npmjs.org/@jridgewell/remapping/-/remapping-2.3.5.tgz", + "integrity": "sha512-LI9u/+laYG4Ds1TDKSJW2YPrIlcVYOwi2fUC6xB43lueCjgxV4lffOCZCtYFiH6TNOX+tQKXx97T4IKHbhyHEQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/gen-mapping": "^0.3.5", + "@jridgewell/trace-mapping": "^0.3.24" + } }, - "json-stable-stringify-without-jsonify": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", - "integrity": "sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE=", - "dev": true + "node_modules/@jridgewell/resolve-uri": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz", + "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.0.0" + } }, - "json5": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.1.tgz", - "integrity": "sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow==", + "node_modules/@jridgewell/source-map": { + "version": "0.3.11", + "resolved": "https://registry.npmjs.org/@jridgewell/source-map/-/source-map-0.3.11.tgz", + "integrity": "sha512-ZMp1V8ZFcPG5dIWnQLr3NSI1MiCU7UETdS/A0G8V/XWHvJv3ZsFqutJn1Y5RPmAPX6F3BiE397OqveU/9NCuIA==", "dev": true, - "requires": { - "minimist": "^1.2.0" + "license": "MIT", + "dependencies": { + "@jridgewell/gen-mapping": "^0.3.5", + "@jridgewell/trace-mapping": "^0.3.25" } }, - "jsonc-parser": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/jsonc-parser/-/jsonc-parser-3.0.0.tgz", - "integrity": "sha512-fQzRfAbIBnR0IQvftw9FJveWiHp72Fg20giDrHz6TdfB12UH/uue0D3hm57UB5KgAVuniLMCaS8P1IMj9NR7cA==", - "dev": true + "node_modules/@jridgewell/sourcemap-codec": { + "version": "1.5.5", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.5.tgz", + "integrity": "sha512-cYQ9310grqxueWbl+WuIUIaiUaDcj7WOq5fVhEljNVgRfOUhY9fy2zTvfoqWsnebh8Sl70VScFbICvJnLKB0Og==", + "dev": true, + "license": "MIT" }, - "jsonfile": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", - "integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=", + "node_modules/@jridgewell/trace-mapping": { + "version": "0.3.31", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.31.tgz", + "integrity": "sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==", "dev": true, - "requires": { - "graceful-fs": "^4.1.6" + "license": "MIT", + "dependencies": { + "@jridgewell/resolve-uri": "^3.1.0", + "@jridgewell/sourcemap-codec": "^1.4.14" } }, - "levn": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz", - "integrity": "sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==", + "node_modules/@jsonjoy.com/base64": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@jsonjoy.com/base64/-/base64-1.1.2.tgz", + "integrity": "sha512-q6XAnWQDIMA3+FTiOYajoYqySkO+JSat0ytXGSuRdq9uXE7o92gzuQwQM14xaCRlBLGq3v5miDGC4vkVTn54xA==", "dev": true, - "requires": { - "prelude-ls": "^1.2.1", - "type-check": "~0.4.0" + "license": "Apache-2.0", + "engines": { + "node": ">=10.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/streamich" + }, + "peerDependencies": { + "tslib": "2" } }, - "lines-and-columns": { - "version": "1.1.6", - "resolved": "https://registry.npmjs.org/lines-and-columns/-/lines-and-columns-1.1.6.tgz", - "integrity": "sha1-HADHQ7QzzQpOgHWPe2SldEDZ/wA=", - "dev": true + "node_modules/@jsonjoy.com/buffers": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/@jsonjoy.com/buffers/-/buffers-1.2.1.tgz", + "integrity": "sha512-12cdlDwX4RUM3QxmUbVJWqZ/mrK6dFQH4Zxq6+r1YXKXYBNgZXndx2qbCJwh3+WWkCSn67IjnlG3XYTvmvYtgA==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=10.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/streamich" + }, + "peerDependencies": { + "tslib": "2" + } }, - "linkify-it": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-3.0.2.tgz", - "integrity": "sha512-gDBO4aHNZS6coiZCKVhSNh43F9ioIL4JwRjLZPkoLIY4yZFwg264Y5lu2x6rb1Js42Gh6Yqm2f6L2AJcnkzinQ==", + "node_modules/@jsonjoy.com/codegen": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@jsonjoy.com/codegen/-/codegen-1.0.0.tgz", + "integrity": "sha512-E8Oy+08cmCf0EK/NMxpaJZmOxPqM+6iSe2S4nlSBrPZOORoDJILxtbSUEDKQyTamm/BVAhIGllOBNU79/dwf0g==", "dev": true, - "requires": { - "uc.micro": "^1.0.1" + "license": "Apache-2.0", + "engines": { + "node": ">=10.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/streamich" + }, + "peerDependencies": { + "tslib": "2" } }, - "lint-staged": { - "version": "10.5.4", - "resolved": "https://registry.npmjs.org/lint-staged/-/lint-staged-10.5.4.tgz", - "integrity": "sha512-EechC3DdFic/TdOPgj/RB3FicqE6932LTHCUm0Y2fsD9KGlLB+RwJl2q1IYBIvEsKzDOgn0D4gll+YxG5RsrKg==", + "node_modules/@jsonjoy.com/json-pack": { + "version": "1.21.0", + "resolved": "https://registry.npmjs.org/@jsonjoy.com/json-pack/-/json-pack-1.21.0.tgz", + "integrity": "sha512-+AKG+R2cfZMShzrF2uQw34v3zbeDYUqnQ+jg7ORic3BGtfw9p/+N6RJbq/kkV8JmYZaINknaEQ2m0/f693ZPpg==", "dev": true, - "requires": { - "chalk": "^4.1.0", - "cli-truncate": "^2.1.0", - "commander": "^6.2.0", - "cosmiconfig": "^7.0.0", - "debug": "^4.2.0", - "dedent": "^0.7.0", - "enquirer": "^2.3.6", - "execa": "^4.1.0", - "listr2": "^3.2.2", - "log-symbols": "^4.0.0", - "micromatch": "^4.0.2", - "normalize-path": "^3.0.0", - "please-upgrade-node": "^3.2.0", - "string-argv": "0.3.1", - "stringify-object": "^3.3.0" - }, - "dependencies": { - "ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "requires": { - "color-convert": "^2.0.1" - } - }, - "chalk": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz", - "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==", - "dev": true, - "requires": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - } - }, - "color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "requires": { - "color-name": "~1.1.4" - } - }, - "color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true - }, - "execa": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/execa/-/execa-4.1.0.tgz", - "integrity": "sha512-j5W0//W7f8UxAn8hXVnwG8tLwdiUy4FJLcSupCg6maBYZDpyBvTApK7KyuI4bKj8KOh1r2YH+6ucuYtJv1bTZA==", - "dev": true, - "requires": { - "cross-spawn": "^7.0.0", - "get-stream": "^5.0.0", - "human-signals": "^1.1.1", - "is-stream": "^2.0.0", - "merge-stream": "^2.0.0", - "npm-run-path": "^4.0.0", - "onetime": "^5.1.0", - "signal-exit": "^3.0.2", - "strip-final-newline": "^2.0.0" - } - }, - "get-stream": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-5.2.0.tgz", - "integrity": "sha512-nBF+F1rAZVCu/p7rjzgA+Yb4lfYXrpl7a6VmJrU8wF9I1CKvP/QwPNZHnOlwbTkY6dvtFIzFMSyQXbLoTQPRpA==", - "dev": true, - "requires": { - "pump": "^3.0.0" - } - }, - "has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "dev": true - }, - "human-signals": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-1.1.1.tgz", - "integrity": "sha512-SEQu7vl8KjNL2eoGBLF3+wAjpsNfA9XMlXAYj/3EdaNfAlxKthD1xjEQfGOUhllCGGJVNY34bRr6lPINhNjyZw==", - "dev": true - }, - "supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dev": true, - "requires": { - "has-flag": "^4.0.0" - } - } + "license": "Apache-2.0", + "dependencies": { + "@jsonjoy.com/base64": "^1.1.2", + "@jsonjoy.com/buffers": "^1.2.0", + "@jsonjoy.com/codegen": "^1.0.0", + "@jsonjoy.com/json-pointer": "^1.0.2", + "@jsonjoy.com/util": "^1.9.0", + "hyperdyperid": "^1.2.0", + "thingies": "^2.5.0", + "tree-dump": "^1.1.0" + }, + "engines": { + "node": ">=10.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/streamich" + }, + "peerDependencies": { + "tslib": "2" } }, - "listr2": { - "version": "3.3.1", - "resolved": "https://registry.npmjs.org/listr2/-/listr2-3.3.1.tgz", - "integrity": "sha512-8Zoxe7s/8nNr4bJ8bdAduHD8uJce+exmMmUWTXlq0WuUdffnH3muisHPHPFtW2vvOfohIsq7FGCaguUxN/h3Iw==", + "node_modules/@jsonjoy.com/json-pointer": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@jsonjoy.com/json-pointer/-/json-pointer-1.0.2.tgz", + "integrity": "sha512-Fsn6wM2zlDzY1U+v4Nc8bo3bVqgfNTGcn6dMgs6FjrEnt4ZCe60o6ByKRjOGlI2gow0aE/Q41QOigdTqkyK5fg==", "dev": true, - "requires": { - "chalk": "^4.1.0", - "cli-truncate": "^2.1.0", - "figures": "^3.2.0", - "indent-string": "^4.0.0", - "log-update": "^4.0.0", - "p-map": "^4.0.0", - "rxjs": "^6.6.3", - "through": "^2.3.8", - "wrap-ansi": "^7.0.0" + "license": "Apache-2.0", + "dependencies": { + "@jsonjoy.com/codegen": "^1.0.0", + "@jsonjoy.com/util": "^1.9.0" + }, + "engines": { + "node": ">=10.0" }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/streamich" + }, + "peerDependencies": { + "tslib": "2" + } + }, + "node_modules/@jsonjoy.com/util": { + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/@jsonjoy.com/util/-/util-1.9.0.tgz", + "integrity": "sha512-pLuQo+VPRnN8hfPqUTLTHk126wuYdXVxE6aDmjSeV4NCAgyxWbiOIeNJVtID3h1Vzpoi9m4jXezf73I6LgabgQ==", + "dev": true, + "license": "Apache-2.0", "dependencies": { - "ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "requires": { - "color-convert": "^2.0.1" - } - }, - "chalk": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz", - "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==", - "dev": true, - "requires": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - } - }, - "color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "requires": { - "color-name": "~1.1.4" - } - }, - "color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true - }, - "has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "dev": true - }, - "supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dev": true, - "requires": { - "has-flag": "^4.0.0" - } - } + "@jsonjoy.com/buffers": "^1.0.0", + "@jsonjoy.com/codegen": "^1.0.0" + }, + "engines": { + "node": ">=10.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/streamich" + }, + "peerDependencies": { + "tslib": "2" } }, - "load-json-file": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-2.0.0.tgz", - "integrity": "sha1-eUfkIUmvgNaWy/eXvKq8/h/inKg=", + "node_modules/@korzio/djv-draft-04": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/@korzio/djv-draft-04/-/djv-draft-04-2.0.1.tgz", + "integrity": "sha512-MeTVcNsfCIYxK6T7jW1sroC7dBAb4IfLmQe6RoCqlxHN5NFkzNpgdnBPR+/0D2wJDUJHM9s9NQv+ouhxKjvUjg==", + "dev": true, + "license": "MIT", + "optional": true + }, + "node_modules/@lezer/common": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/@lezer/common/-/common-1.5.0.tgz", + "integrity": "sha512-PNGcolp9hr4PJdXR4ix7XtixDrClScvtSCYW3rQG106oVMOOI+jFb+0+J3mbeL/53g1Zd6s0kJzaw6Ri68GmAA==", + "dev": true, + "license": "MIT" + }, + "node_modules/@lezer/highlight": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/@lezer/highlight/-/highlight-1.2.3.tgz", + "integrity": "sha512-qXdH7UqTvGfdVBINrgKhDsVTJTxactNNxLk7+UMwZhU13lMHaOBlJe9Vqp907ya56Y3+ed2tlqzys7jDkTmW0g==", "dev": true, - "requires": { - "graceful-fs": "^4.1.2", - "parse-json": "^2.2.0", - "pify": "^2.0.0", - "strip-bom": "^3.0.0" + "license": "MIT", + "dependencies": { + "@lezer/common": "^1.3.0" } }, - "locate-character": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/locate-character/-/locate-character-2.0.5.tgz", - "integrity": "sha512-n2GmejDXtOPBAZdIiEFy5dJ5N38xBCXLNOtw2WpB9kGh6pnrEuKlwYI+Tkpofc4wDtVXHtoAOJaMRlYG/oYaxg==", - "dev": true + "node_modules/@lezer/javascript": { + "version": "1.5.4", + "resolved": "https://registry.npmjs.org/@lezer/javascript/-/javascript-1.5.4.tgz", + "integrity": "sha512-vvYx3MhWqeZtGPwDStM2dwgljd5smolYD2lR2UyFcHfxbBQebqx8yjmFmxtJ/E6nN6u1D9srOiVWm3Rb4tmcUA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@lezer/common": "^1.2.0", + "@lezer/highlight": "^1.1.3", + "@lezer/lr": "^1.3.0" + } }, - "locate-path": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-2.0.0.tgz", - "integrity": "sha1-K1aLJl7slExtnA3pw9u7ygNUzY4=", + "node_modules/@lezer/lr": { + "version": "1.4.7", + "resolved": "https://registry.npmjs.org/@lezer/lr/-/lr-1.4.7.tgz", + "integrity": "sha512-wNIFWdSUfX9Jc6ePMzxSPVgTVB4EOfDIwLQLWASyiUdHKaMsiilj9bYiGkGQCKVodd0x6bgQCV207PILGFCF9Q==", "dev": true, - "requires": { - "p-locate": "^2.0.0", - "path-exists": "^3.0.0" + "license": "MIT", + "dependencies": { + "@lezer/common": "^1.0.0" } }, - "lodash": { - "version": "4.17.20", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.20.tgz", - "integrity": "sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA==", - "dev": true + "node_modules/@marijn/find-cluster-break": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@marijn/find-cluster-break/-/find-cluster-break-1.0.2.tgz", + "integrity": "sha512-l0h88YhZFyKdXIFNfSWpyjStDjGHwZ/U7iobcK1cQQD8sejsONdQtTVU+1wVN1PBw40PiiHB1vA5S7VTfQiP9g==", + "dev": true, + "license": "MIT" }, - "lodash.differencewith": { - "version": "4.5.0", - "resolved": "https://registry.npmjs.org/lodash.differencewith/-/lodash.differencewith-4.5.0.tgz", - "integrity": "sha1-uvr7yRi1UVTheRdqALsK76rIVLc=", - "dev": true + "node_modules/@mermaid-js/mermaid-cli": { + "version": "11.12.0", + "resolved": "https://registry.npmjs.org/@mermaid-js/mermaid-cli/-/mermaid-cli-11.12.0.tgz", + "integrity": "sha512-a0swOS6PByXKi0dZnLQQIhbtUEu7ubc6bojmIqXqvUPq7mIJukCNEvVBTv6IAbuEWqB3Ti8QntupoGdz3ej+kg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@mermaid-js/mermaid-zenuml": "^0.2.0", + "chalk": "^5.0.1", + "commander": "^14.0.0", + "import-meta-resolve": "^4.1.0", + "mermaid": "^11.0.2" + }, + "bin": { + "mmdc": "src/cli.js" + }, + "engines": { + "node": "^18.19 || >=20.0" + }, + "peerDependencies": { + "puppeteer": "^23" + } }, - "lodash.flatten": { - "version": "4.4.0", - "resolved": "https://registry.npmjs.org/lodash.flatten/-/lodash.flatten-4.4.0.tgz", - "integrity": "sha1-8xwiIlqWMtK7+OSt2+8kCqdlph8=", - "dev": true + "node_modules/@mermaid-js/mermaid-zenuml": { + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/@mermaid-js/mermaid-zenuml/-/mermaid-zenuml-0.2.2.tgz", + "integrity": "sha512-sUjwk4NWUpy9uaHypYSIGJDks10ZaZo5CHH9lx9xcmyqv9w7yvd4vecUmlUQxmlHStYO+aqSkYKX5/gFjDfypw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@zenuml/core": "^3.35.2" + }, + "peerDependencies": { + "mermaid": "^10 || ^11" + } }, - "lodash.flattendeep": { - "version": "4.4.0", - "resolved": "https://registry.npmjs.org/lodash.flattendeep/-/lodash.flattendeep-4.4.0.tgz", - "integrity": "sha1-+wMJF/hqMTTlvJvsDWngAT3f7bI=", - "dev": true + "node_modules/@mermaid-js/parser": { + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/@mermaid-js/parser/-/parser-0.6.3.tgz", + "integrity": "sha512-lnjOhe7zyHjc+If7yT4zoedx2vo4sHaTmtkl1+or8BRTnCtDmcTpAjpzDSfCZrshM5bCoz0GyidzadJAH1xobA==", + "dev": true, + "license": "MIT", + "dependencies": { + "langium": "3.3.1" + } }, - "log-symbols": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.0.0.tgz", - "integrity": "sha512-FN8JBzLx6CzeMrB0tg6pqlGU1wCrXW+ZXGH481kfsBqer0hToTIiHdjH4Mq8xJUbvATujKCvaREGWpGUionraA==", + "node_modules/@napi-rs/cli": { + "version": "3.4.1", + "resolved": "https://registry.npmjs.org/@napi-rs/cli/-/cli-3.4.1.tgz", + "integrity": "sha512-ayhm+NfrP5Hmh7vy5pfyYm/ktYtLh2PrgdLuqHTAubO7RoO2JkUE4F991AtgYxNewwXI8+guZLxU8itV7QnDrQ==", "dev": true, - "requires": { - "chalk": "^4.0.0" + "license": "MIT", + "dependencies": { + "@inquirer/prompts": "^7.8.4", + "@napi-rs/cross-toolchain": "^1.0.3", + "@napi-rs/wasm-tools": "^1.0.1", + "@octokit/rest": "^22.0.0", + "clipanion": "^4.0.0-rc.4", + "colorette": "^2.0.20", + "debug": "^4.4.1", + "emnapi": "^1.5.0", + "es-toolkit": "^1.39.10", + "js-yaml": "^4.1.0", + "semver": "^7.7.2", + "typanion": "^3.14.0" + }, + "bin": { + "napi": "dist/cli.js", + "napi-raw": "cli.mjs" }, + "engines": { + "node": ">= 16" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/Brooooooklyn" + }, + "peerDependencies": { + "@emnapi/runtime": "^1.5.0" + }, + "peerDependenciesMeta": { + "@emnapi/runtime": { + "optional": true + }, + "emnapi": { + "optional": true + } + } + }, + "node_modules/@napi-rs/cross-toolchain": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@napi-rs/cross-toolchain/-/cross-toolchain-1.0.3.tgz", + "integrity": "sha512-ENPfLe4937bsKVTDA6zdABx4pq9w0tHqRrJHyaGxgaPq03a2Bd1unD5XSKjXJjebsABJ+MjAv1A2OvCgK9yehg==", + "dev": true, + "license": "MIT", + "workspaces": [ + ".", + "arm64/*", + "x64/*" + ], "dependencies": { - "ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "requires": { - "color-convert": "^2.0.1" - } + "@napi-rs/lzma": "^1.4.5", + "@napi-rs/tar": "^1.1.0", + "debug": "^4.4.1" + }, + "peerDependencies": { + "@napi-rs/cross-toolchain-arm64-target-aarch64": "^1.0.3", + "@napi-rs/cross-toolchain-arm64-target-armv7": "^1.0.3", + "@napi-rs/cross-toolchain-arm64-target-ppc64le": "^1.0.3", + "@napi-rs/cross-toolchain-arm64-target-s390x": "^1.0.3", + "@napi-rs/cross-toolchain-arm64-target-x86_64": "^1.0.3", + "@napi-rs/cross-toolchain-x64-target-aarch64": "^1.0.3", + "@napi-rs/cross-toolchain-x64-target-armv7": "^1.0.3", + "@napi-rs/cross-toolchain-x64-target-ppc64le": "^1.0.3", + "@napi-rs/cross-toolchain-x64-target-s390x": "^1.0.3", + "@napi-rs/cross-toolchain-x64-target-x86_64": "^1.0.3" + }, + "peerDependenciesMeta": { + "@napi-rs/cross-toolchain-arm64-target-aarch64": { + "optional": true }, - "chalk": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz", - "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==", - "dev": true, - "requires": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - } + "@napi-rs/cross-toolchain-arm64-target-armv7": { + "optional": true }, - "color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "requires": { - "color-name": "~1.1.4" - } + "@napi-rs/cross-toolchain-arm64-target-ppc64le": { + "optional": true }, - "color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true + "@napi-rs/cross-toolchain-arm64-target-s390x": { + "optional": true }, - "has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "dev": true + "@napi-rs/cross-toolchain-arm64-target-x86_64": { + "optional": true }, - "supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dev": true, - "requires": { - "has-flag": "^4.0.0" - } + "@napi-rs/cross-toolchain-x64-target-aarch64": { + "optional": true + }, + "@napi-rs/cross-toolchain-x64-target-armv7": { + "optional": true + }, + "@napi-rs/cross-toolchain-x64-target-ppc64le": { + "optional": true + }, + "@napi-rs/cross-toolchain-x64-target-s390x": { + "optional": true + }, + "@napi-rs/cross-toolchain-x64-target-x86_64": { + "optional": true } } }, - "log-update": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/log-update/-/log-update-4.0.0.tgz", - "integrity": "sha512-9fkkDevMefjg0mmzWFBW8YkFP91OrizzkW3diF7CpG+S2EYdy4+TVfGwz1zeF8x7hCx1ovSPTOE9Ngib74qqUg==", + "node_modules/@napi-rs/lzma": { + "version": "1.4.5", + "resolved": "https://registry.npmjs.org/@napi-rs/lzma/-/lzma-1.4.5.tgz", + "integrity": "sha512-zS5LuN1OBPAyZpda2ZZgYOEDC+xecUdAGnrvbYzjnLXkrq/OBC3B9qcRvlxbDR3k5H/gVfvef1/jyUqPknqjbg==", "dev": true, - "requires": { - "ansi-escapes": "^4.3.0", - "cli-cursor": "^3.1.0", - "slice-ansi": "^4.0.0", - "wrap-ansi": "^6.2.0" + "license": "MIT", + "engines": { + "node": ">= 10" }, - "dependencies": { - "ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "requires": { - "color-convert": "^2.0.1" - } - }, - "color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "requires": { - "color-name": "~1.1.4" - } - }, - "color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true - }, - "wrap-ansi": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-6.2.0.tgz", - "integrity": "sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==", - "dev": true, - "requires": { - "ansi-styles": "^4.0.0", - "string-width": "^4.1.0", - "strip-ansi": "^6.0.0" - } - } + "funding": { + "type": "github", + "url": "https://github.com/sponsors/Brooooooklyn" + }, + "optionalDependencies": { + "@napi-rs/lzma-android-arm-eabi": "1.4.5", + "@napi-rs/lzma-android-arm64": "1.4.5", + "@napi-rs/lzma-darwin-arm64": "1.4.5", + "@napi-rs/lzma-darwin-x64": "1.4.5", + "@napi-rs/lzma-freebsd-x64": "1.4.5", + "@napi-rs/lzma-linux-arm-gnueabihf": "1.4.5", + "@napi-rs/lzma-linux-arm64-gnu": "1.4.5", + "@napi-rs/lzma-linux-arm64-musl": "1.4.5", + "@napi-rs/lzma-linux-ppc64-gnu": "1.4.5", + "@napi-rs/lzma-linux-riscv64-gnu": "1.4.5", + "@napi-rs/lzma-linux-s390x-gnu": "1.4.5", + "@napi-rs/lzma-linux-x64-gnu": "1.4.5", + "@napi-rs/lzma-linux-x64-musl": "1.4.5", + "@napi-rs/lzma-wasm32-wasi": "1.4.5", + "@napi-rs/lzma-win32-arm64-msvc": "1.4.5", + "@napi-rs/lzma-win32-ia32-msvc": "1.4.5", + "@napi-rs/lzma-win32-x64-msvc": "1.4.5" } }, - "lru-cache": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", - "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "node_modules/@napi-rs/lzma-android-arm-eabi": { + "version": "1.4.5", + "resolved": "https://registry.npmjs.org/@napi-rs/lzma-android-arm-eabi/-/lzma-android-arm-eabi-1.4.5.tgz", + "integrity": "sha512-Up4gpyw2SacmyKWWEib06GhiDdF+H+CCU0LAV8pnM4aJIDqKKd5LHSlBht83Jut6frkB0vwEPmAkv4NjQ5u//Q==", + "cpu": [ + "arm" + ], "dev": true, - "requires": { - "yallist": "^4.0.0" + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">= 10" } }, - "magic-string": { - "version": "0.25.7", - "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.25.7.tgz", - "integrity": "sha512-4CrMT5DOHTDk4HYDlzmwu4FVCcIYI8gauveasrdCu2IKIFOJ3f0v/8MDGJCDL9oD2ppz/Av1b0Nj345H9M+XIA==", + "node_modules/@napi-rs/lzma-android-arm64": { + "version": "1.4.5", + "resolved": "https://registry.npmjs.org/@napi-rs/lzma-android-arm64/-/lzma-android-arm64-1.4.5.tgz", + "integrity": "sha512-uwa8sLlWEzkAM0MWyoZJg0JTD3BkPknvejAFG2acUA1raXM8jLrqujWCdOStisXhqQjZ2nDMp3FV6cs//zjfuQ==", + "cpu": [ + "arm64" + ], "dev": true, - "requires": { - "sourcemap-codec": "^1.4.4" + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">= 10" } }, - "make-dir": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz", - "integrity": "sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw==", + "node_modules/@napi-rs/lzma-darwin-arm64": { + "version": "1.4.5", + "resolved": "https://registry.npmjs.org/@napi-rs/lzma-darwin-arm64/-/lzma-darwin-arm64-1.4.5.tgz", + "integrity": "sha512-0Y0TQLQ2xAjVabrMDem1NhIssOZzF/y/dqetc6OT8mD3xMTDtF8u5BqZoX3MyPc9FzpsZw4ksol+w7DsxHrpMA==", + "cpu": [ + "arm64" + ], "dev": true, - "requires": { - "semver": "^6.0.0" - }, - "dependencies": { - "semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", - "dev": true - } + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 10" } }, - "markdown-it": { - "version": "12.0.2", - "resolved": "https://registry.npmjs.org/markdown-it/-/markdown-it-12.0.2.tgz", - "integrity": "sha512-4Lkvjbv2kK+moL9TbeV+6/NHx+1Q+R/NIdUlFlkqkkzUcTod4uiyTJRiBidKR9qXSdkNFkgv+AELY8KN9vSgVA==", + "node_modules/@napi-rs/lzma-darwin-x64": { + "version": "1.4.5", + "resolved": "https://registry.npmjs.org/@napi-rs/lzma-darwin-x64/-/lzma-darwin-x64-1.4.5.tgz", + "integrity": "sha512-vR2IUyJY3En+V1wJkwmbGWcYiT8pHloTAWdW4pG24+51GIq+intst6Uf6D/r46citObGZrlX0QvMarOkQeHWpw==", + "cpu": [ + "x64" + ], "dev": true, - "requires": { - "argparse": "^2.0.1", - "entities": "~2.0.0", - "linkify-it": "^3.0.1", - "mdurl": "^1.0.1", - "uc.micro": "^1.0.5" - }, - "dependencies": { - "argparse": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", - "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", - "dev": true - } + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 10" } }, - "markdownlint": { - "version": "0.22.0", - "resolved": "https://registry.npmjs.org/markdownlint/-/markdownlint-0.22.0.tgz", - "integrity": "sha512-J4B+iMc12pOdp/wfYi03W2qfAfEyiZzq3qvQh/8vOMNU8vXYY6Jg440EY7dWTBCqROhb1i4nAn3BTByJ5kdx1w==", - "dev": true, - "requires": { - "markdown-it": "12.0.2" - } - }, - "markdownlint-cli": { - "version": "0.26.0", - "resolved": "https://registry.npmjs.org/markdownlint-cli/-/markdownlint-cli-0.26.0.tgz", - "integrity": "sha512-biLfeGNZG9nw0yJbtFBzRlew2/P5w7JSseKwolSox3zejs7dLpGvPgqbC+iqJnqqGWcWLtXaXh8bBEKWmfl10A==", - "dev": true, - "requires": { - "commander": "~6.2.1", - "deep-extend": "~0.6.0", - "get-stdin": "~8.0.0", - "glob": "~7.1.6", - "ignore": "~5.1.8", - "js-yaml": "~3.14.1", - "jsonc-parser": "~3.0.0", - "lodash.differencewith": "~4.5.0", - "lodash.flatten": "~4.4.0", - "markdownlint": "~0.22.0", - "markdownlint-rule-helpers": "~0.13.0", - "minimatch": "~3.0.4", - "minimist": "~1.2.5", - "rc": "~1.2.8" - }, - "dependencies": { - "ignore": { - "version": "5.1.8", - "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.1.8.tgz", - "integrity": "sha512-BMpfD7PpiETpBl/A6S498BaIJ6Y/ABT93ETbby2fP00v4EbvPBXWEoaR1UBPKs3iR53pJY7EtZk5KACI57i1Uw==", - "dev": true - }, - "js-yaml": { - "version": "3.14.1", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz", - "integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==", - "dev": true, - "requires": { - "argparse": "^1.0.7", - "esprima": "^4.0.0" - } - } + "node_modules/@napi-rs/lzma-freebsd-x64": { + "version": "1.4.5", + "resolved": "https://registry.npmjs.org/@napi-rs/lzma-freebsd-x64/-/lzma-freebsd-x64-1.4.5.tgz", + "integrity": "sha512-XpnYQC5SVovO35tF0xGkbHYjsS6kqyNCjuaLQ2dbEblFRr5cAZVvsJ/9h7zj/5FluJPJRDojVNxGyRhTp4z2lw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">= 10" } }, - "markdownlint-rule-helpers": { - "version": "0.13.0", - "resolved": "https://registry.npmjs.org/markdownlint-rule-helpers/-/markdownlint-rule-helpers-0.13.0.tgz", - "integrity": "sha512-rRY0itbcHG4e+ntz0bbY3AIceSJMKS0TafEMgEtKVHRZ54/JUSy6/4ypCL618RlJvYRej+xMLxX5nkJqIeTZaQ==", - "dev": true + "node_modules/@napi-rs/lzma-linux-arm-gnueabihf": { + "version": "1.4.5", + "resolved": "https://registry.npmjs.org/@napi-rs/lzma-linux-arm-gnueabihf/-/lzma-linux-arm-gnueabihf-1.4.5.tgz", + "integrity": "sha512-ic1ZZMoRfRMwtSwxkyw4zIlbDZGC6davC9r+2oX6x9QiF247BRqqT94qGeL5ZP4Vtz0Hyy7TEViWhx5j6Bpzvw==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } }, - "matcher-collection": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/matcher-collection/-/matcher-collection-2.0.1.tgz", - "integrity": "sha512-daE62nS2ZQsDg9raM0IlZzLmI2u+7ZapXBwdoeBUKAYERPDDIc0qNqA8E0Rp2D+gspKR7BgIFP52GeujaGXWeQ==", + "node_modules/@napi-rs/lzma-linux-arm64-gnu": { + "version": "1.4.5", + "resolved": "https://registry.npmjs.org/@napi-rs/lzma-linux-arm64-gnu/-/lzma-linux-arm64-gnu-1.4.5.tgz", + "integrity": "sha512-asEp7FPd7C1Yi6DQb45a3KPHKOFBSfGuJWXcAd4/bL2Fjetb2n/KK2z14yfW8YC/Fv6x3rBM0VAZKmJuz4tysg==", + "cpu": [ + "arm64" + ], "dev": true, - "requires": { - "@types/minimatch": "^3.0.3", - "minimatch": "^3.0.2" + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" } }, - "mdurl": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/mdurl/-/mdurl-1.0.1.tgz", - "integrity": "sha1-/oWy7HWlkDfyrf7BAP1sYBdhFS4=", - "dev": true + "node_modules/@napi-rs/lzma-linux-arm64-musl": { + "version": "1.4.5", + "resolved": "https://registry.npmjs.org/@napi-rs/lzma-linux-arm64-musl/-/lzma-linux-arm64-musl-1.4.5.tgz", + "integrity": "sha512-yWjcPDgJ2nIL3KNvi4536dlT/CcCWO0DUyEOlBs/SacG7BeD6IjGh6yYzd3/X1Y3JItCbZoDoLUH8iB1lTXo3w==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } }, - "merge-stream": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz", - "integrity": "sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==", - "dev": true + "node_modules/@napi-rs/lzma-linux-ppc64-gnu": { + "version": "1.4.5", + "resolved": "https://registry.npmjs.org/@napi-rs/lzma-linux-ppc64-gnu/-/lzma-linux-ppc64-gnu-1.4.5.tgz", + "integrity": "sha512-0XRhKuIU/9ZjT4WDIG/qnX7Xz7mSQHYZo9Gb3MP2gcvBgr6BA4zywQ9k3gmQaPn9ECE+CZg2V7DV7kT+x2pUMQ==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } }, - "micromatch": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.2.tgz", - "integrity": "sha512-y7FpHSbMUMoyPbYUSzO6PaZ6FyRnQOpHuKwbo1G+Knck95XVU4QAiKdGEnj5wwoS7PlOgthX/09u5iFJ+aYf5Q==", + "node_modules/@napi-rs/lzma-linux-riscv64-gnu": { + "version": "1.4.5", + "resolved": "https://registry.npmjs.org/@napi-rs/lzma-linux-riscv64-gnu/-/lzma-linux-riscv64-gnu-1.4.5.tgz", + "integrity": "sha512-QrqDIPEUUB23GCpyQj/QFyMlr8SGxxyExeZz9OWFnHfb70kXdTLWrHS/hEI1Ru+lSbQ/6xRqeoGyQ4Aqdg+/RA==", + "cpu": [ + "riscv64" + ], "dev": true, - "requires": { - "braces": "^3.0.1", - "picomatch": "^2.0.5" + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" } }, - "mimic-fn": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz", - "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==", - "dev": true + "node_modules/@napi-rs/lzma-linux-s390x-gnu": { + "version": "1.4.5", + "resolved": "https://registry.npmjs.org/@napi-rs/lzma-linux-s390x-gnu/-/lzma-linux-s390x-gnu-1.4.5.tgz", + "integrity": "sha512-k8RVM5aMhW86E9H0QXdquwojew4H3SwPxbRVbl49/COJQWCUjGi79X6mYruMnMPEznZinUiT1jgKbFo2A00NdA==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } }, - "minimalistic-assert": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz", - "integrity": "sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A==", - "dev": true + "node_modules/@napi-rs/lzma-linux-x64-gnu": { + "version": "1.4.5", + "resolved": "https://registry.npmjs.org/@napi-rs/lzma-linux-x64-gnu/-/lzma-linux-x64-gnu-1.4.5.tgz", + "integrity": "sha512-6rMtBgnIq2Wcl1rQdZsnM+rtCcVCbws1nF8S2NzaUsVaZv8bjrPiAa0lwg4Eqnn1d9lgwqT+cZgm5m+//K08Kw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } }, - "minimatch": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "node_modules/@napi-rs/lzma-linux-x64-musl": { + "version": "1.4.5", + "resolved": "https://registry.npmjs.org/@napi-rs/lzma-linux-x64-musl/-/lzma-linux-x64-musl-1.4.5.tgz", + "integrity": "sha512-eiadGBKi7Vd0bCArBUOO/qqRYPHt/VQVvGyYvDFt6C2ZSIjlD+HuOl+2oS1sjf4CFjK4eDIog6EdXnL0NE6iyQ==", + "cpu": [ + "x64" + ], "dev": true, - "requires": { - "brace-expansion": "^1.1.7" + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" } }, - "minimist": { - "version": "1.2.5", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", - "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==", - "dev": true + "node_modules/@napi-rs/lzma-wasm32-wasi": { + "version": "1.4.5", + "resolved": "https://registry.npmjs.org/@napi-rs/lzma-wasm32-wasi/-/lzma-wasm32-wasi-1.4.5.tgz", + "integrity": "sha512-+VyHHlr68dvey6fXc2hehw9gHVFIW3TtGF1XkcbAu65qVXsA9D/T+uuoRVqhE+JCyFHFrO0ixRbZDRK1XJt1sA==", + "cpu": [ + "wasm32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "@napi-rs/wasm-runtime": "^1.0.3" + }, + "engines": { + "node": ">=14.0.0" + } }, - "mkdirp": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", - "integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==", - "dev": true + "node_modules/@napi-rs/lzma-win32-arm64-msvc": { + "version": "1.4.5", + "resolved": "https://registry.npmjs.org/@napi-rs/lzma-win32-arm64-msvc/-/lzma-win32-arm64-msvc-1.4.5.tgz", + "integrity": "sha512-eewnqvIyyhHi3KaZtBOJXohLvwwN27gfS2G/YDWdfHlbz1jrmfeHAmzMsP5qv8vGB+T80TMHNkro4kYjeh6Deg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10" + } }, - "mocha": { - "version": "8.3.0", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-8.3.0.tgz", - "integrity": "sha512-TQqyC89V1J/Vxx0DhJIXlq9gbbL9XFNdeLQ1+JsnZsVaSOV1z3tWfw0qZmQJGQRIfkvZcs7snQnZnOCKoldq1Q==", - "dev": true, - "requires": { - "@ungap/promise-all-settled": "1.1.2", - "ansi-colors": "4.1.1", - "browser-stdout": "1.3.1", - "chokidar": "3.5.1", - "debug": "4.3.1", - "diff": "5.0.0", - "escape-string-regexp": "4.0.0", - "find-up": "5.0.0", - "glob": "7.1.6", - "growl": "1.10.5", - "he": "1.2.0", - "js-yaml": "4.0.0", - "log-symbols": "4.0.0", - "minimatch": "3.0.4", - "ms": "2.1.3", - "nanoid": "3.1.20", - "serialize-javascript": "5.0.1", - "strip-json-comments": "3.1.1", - "supports-color": "8.1.1", - "which": "2.0.2", - "wide-align": "1.1.3", - "workerpool": "6.1.0", - "yargs": "16.2.0", - "yargs-parser": "20.2.4", - "yargs-unparser": "2.0.0" - }, - "dependencies": { - "argparse": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", - "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", - "dev": true - }, - "escape-string-regexp": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", - "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", - "dev": true - }, - "find-up": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", - "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==", - "dev": true, - "requires": { - "locate-path": "^6.0.0", - "path-exists": "^4.0.0" - } - }, - "has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "dev": true - }, - "js-yaml": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.0.0.tgz", - "integrity": "sha512-pqon0s+4ScYUvX30wxQi3PogGFAlUyH0awepWvwkj4jD4v+ova3RiYw8bmA6x2rDrEaj8i/oWKoRxpVNW+Re8Q==", - "dev": true, - "requires": { - "argparse": "^2.0.1" - } - }, - "locate-path": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", - "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", - "dev": true, - "requires": { - "p-locate": "^5.0.0" - } - }, - "ms": { - "version": "2.1.3", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", - "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", - "dev": true - }, - "p-limit": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", - "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", - "dev": true, - "requires": { - "yocto-queue": "^0.1.0" - } - }, - "p-locate": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz", - "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==", - "dev": true, - "requires": { - "p-limit": "^3.0.2" - } - }, - "path-exists": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", - "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", - "dev": true - }, - "supports-color": { - "version": "8.1.1", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", - "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", - "dev": true, - "requires": { - "has-flag": "^4.0.0" - } - } + "node_modules/@napi-rs/lzma-win32-ia32-msvc": { + "version": "1.4.5", + "resolved": "https://registry.npmjs.org/@napi-rs/lzma-win32-ia32-msvc/-/lzma-win32-ia32-msvc-1.4.5.tgz", + "integrity": "sha512-OeacFVRCJOKNU/a0ephUfYZ2Yt+NvaHze/4TgOwJ0J0P4P7X1mHzN+ig9Iyd74aQDXYqc7kaCXA2dpAOcH87Cg==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10" } }, - "moment": { - "version": "2.27.0", - "resolved": "https://registry.npmjs.org/moment/-/moment-2.27.0.tgz", - "integrity": "sha512-al0MUK7cpIcglMv3YF13qSgdAIqxHTO7brRtaz3DlSULbqfazqkc5kEjNrLDOM7fsjshoFIihnU8snrP7zUvhQ==", - "dev": true + "node_modules/@napi-rs/lzma-win32-x64-msvc": { + "version": "1.4.5", + "resolved": "https://registry.npmjs.org/@napi-rs/lzma-win32-x64-msvc/-/lzma-win32-x64-msvc-1.4.5.tgz", + "integrity": "sha512-T4I1SamdSmtyZgDXGAGP+y5LEK5vxHUFwe8mz6D4R7Sa5/WCxTcCIgPJ9BD7RkpO17lzhlaM2vmVvMy96Lvk9Q==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10" + } }, - "ms": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", - "dev": true + "node_modules/@napi-rs/tar": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@napi-rs/tar/-/tar-1.1.0.tgz", + "integrity": "sha512-7cmzIu+Vbupriudo7UudoMRH2OA3cTw67vva8MxeoAe5S7vPFI7z0vp0pMXiA25S8IUJefImQ90FeJjl8fjEaQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 10" + }, + "optionalDependencies": { + "@napi-rs/tar-android-arm-eabi": "1.1.0", + "@napi-rs/tar-android-arm64": "1.1.0", + "@napi-rs/tar-darwin-arm64": "1.1.0", + "@napi-rs/tar-darwin-x64": "1.1.0", + "@napi-rs/tar-freebsd-x64": "1.1.0", + "@napi-rs/tar-linux-arm-gnueabihf": "1.1.0", + "@napi-rs/tar-linux-arm64-gnu": "1.1.0", + "@napi-rs/tar-linux-arm64-musl": "1.1.0", + "@napi-rs/tar-linux-ppc64-gnu": "1.1.0", + "@napi-rs/tar-linux-s390x-gnu": "1.1.0", + "@napi-rs/tar-linux-x64-gnu": "1.1.0", + "@napi-rs/tar-linux-x64-musl": "1.1.0", + "@napi-rs/tar-wasm32-wasi": "1.1.0", + "@napi-rs/tar-win32-arm64-msvc": "1.1.0", + "@napi-rs/tar-win32-ia32-msvc": "1.1.0", + "@napi-rs/tar-win32-x64-msvc": "1.1.0" + } }, - "nanoid": { - "version": "3.1.20", - "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.1.20.tgz", - "integrity": "sha512-a1cQNyczgKbLX9jwbS/+d7W8fX/RfgYR7lVWwWOGIPNgK2m0MWvrGF6/m4kk6U3QcFMnZf3RIhL0v2Jgh/0Uxw==", - "dev": true + "node_modules/@napi-rs/tar-android-arm-eabi": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@napi-rs/tar-android-arm-eabi/-/tar-android-arm-eabi-1.1.0.tgz", + "integrity": "sha512-h2Ryndraj/YiKgMV/r5by1cDusluYIRT0CaE0/PekQ4u+Wpy2iUVqvzVU98ZPnhXaNeYxEvVJHNGafpOfaD0TA==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">= 10" + } }, - "natural-compare": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", - "integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=", - "dev": true + "node_modules/@napi-rs/tar-android-arm64": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@napi-rs/tar-android-arm64/-/tar-android-arm64-1.1.0.tgz", + "integrity": "sha512-DJFyQHr1ZxNZorm/gzc1qBNLF/FcKzcH0V0Vwan5P+o0aE2keQIGEjJ09FudkF9v6uOuJjHCVDdK6S6uHtShAw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">= 10" + } }, - "node-addon-api": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-3.1.0.tgz", - "integrity": "sha512-flmrDNB06LIl5lywUz7YlNGZH/5p0M7W28k8hzd9Lshtdh1wshD2Y+U4h9LD6KObOy1f+fEVdgprPrEymjM5uw==", - "dev": true + "node_modules/@napi-rs/tar-darwin-arm64": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@napi-rs/tar-darwin-arm64/-/tar-darwin-arm64-1.1.0.tgz", + "integrity": "sha512-Zz2sXRzjIX4e532zD6xm2SjXEym6MkvfCvL2RMpG2+UwNVDVscHNcz3d47Pf3sysP2e2af7fBB3TIoK2f6trPw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 10" + } }, - "node-fetch": { - "version": "2.6.1", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz", - "integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==", - "dev": true + "node_modules/@napi-rs/tar-darwin-x64": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@napi-rs/tar-darwin-x64/-/tar-darwin-x64-1.1.0.tgz", + "integrity": "sha512-EI+CptIMNweT0ms9S3mkP/q+J6FNZ1Q6pvpJOEcWglRfyfQpLqjlC0O+dptruTPE8VamKYuqdjxfqD8hifZDOA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 10" + } }, - "node-gyp-build": { - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-4.2.3.tgz", - "integrity": "sha512-MN6ZpzmfNCRM+3t57PTJHgHyw/h4OWnZ6mR8P5j/uZtqQr46RRuDE/P+g3n0YR/AiYXeWixZZzaip77gdICfRg==", - "dev": true + "node_modules/@napi-rs/tar-freebsd-x64": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@napi-rs/tar-freebsd-x64/-/tar-freebsd-x64-1.1.0.tgz", + "integrity": "sha512-J0PIqX+pl6lBIAckL/c87gpodLbjZB1OtIK+RDscKC9NLdpVv6VGOxzUV/fYev/hctcE8EfkLbgFOfpmVQPg2g==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">= 10" + } }, - "node-preload": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/node-preload/-/node-preload-0.2.1.tgz", - "integrity": "sha512-RM5oyBy45cLEoHqCeh+MNuFAxO0vTFBLskvQbOKnEE7YTTSN4tbN8QWDIPQ6L+WvKsB/qLEGpYe2ZZ9d4W9OIQ==", + "node_modules/@napi-rs/tar-linux-arm-gnueabihf": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@napi-rs/tar-linux-arm-gnueabihf/-/tar-linux-arm-gnueabihf-1.1.0.tgz", + "integrity": "sha512-SLgIQo3f3EjkZ82ZwvrEgFvMdDAhsxCYjyoSuWfHCz0U16qx3SuGCp8+FYOPYCECHN3ZlGjXnoAIt9ERd0dEUg==", + "cpu": [ + "arm" + ], "dev": true, - "requires": { - "process-on-spawn": "^1.0.0" + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" } }, - "normalize-package-data": { - "version": "2.5.0", - "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.5.0.tgz", - "integrity": "sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA==", + "node_modules/@napi-rs/tar-linux-arm64-gnu": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@napi-rs/tar-linux-arm64-gnu/-/tar-linux-arm64-gnu-1.1.0.tgz", + "integrity": "sha512-d014cdle52EGaH6GpYTQOP9Py7glMO1zz/+ynJPjjzYFSxvdYx0byrjumZk2UQdIyGZiJO2MEFpCkEEKFSgPYA==", + "cpu": [ + "arm64" + ], "dev": true, - "requires": { - "hosted-git-info": "^2.1.4", - "resolve": "^1.10.0", - "semver": "2 || 3 || 4 || 5", - "validate-npm-package-license": "^3.0.1" - }, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@napi-rs/tar-linux-arm64-musl": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@napi-rs/tar-linux-arm64-musl/-/tar-linux-arm64-musl-1.1.0.tgz", + "integrity": "sha512-L/y1/26q9L/uBqiW/JdOb/Dc94egFvNALUZV2WCGKQXc6UByPBMgdiEyW2dtoYxYYYYc+AKD+jr+wQPcvX2vrQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@napi-rs/tar-linux-ppc64-gnu": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@napi-rs/tar-linux-ppc64-gnu/-/tar-linux-ppc64-gnu-1.1.0.tgz", + "integrity": "sha512-EPE1K/80RQvPbLRJDJs1QmCIcH+7WRi0F73+oTe1582y9RtfGRuzAkzeBuAGRXAQEjRQw/RjtNqr6UTJ+8UuWQ==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@napi-rs/tar-linux-s390x-gnu": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@napi-rs/tar-linux-s390x-gnu/-/tar-linux-s390x-gnu-1.1.0.tgz", + "integrity": "sha512-B2jhWiB1ffw1nQBqLUP1h4+J1ovAxBOoe5N2IqDMOc63fsPZKNqF1PvO/dIem8z7LL4U4bsfmhy3gBfu547oNQ==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@napi-rs/tar-linux-x64-gnu": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@napi-rs/tar-linux-x64-gnu/-/tar-linux-x64-gnu-1.1.0.tgz", + "integrity": "sha512-tbZDHnb9617lTnsDMGo/eAMZxnsQFnaRe+MszRqHguKfMwkisc9CCJnks/r1o84u5fECI+J/HOrKXgczq/3Oww==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@napi-rs/tar-linux-x64-musl": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@napi-rs/tar-linux-x64-musl/-/tar-linux-x64-musl-1.1.0.tgz", + "integrity": "sha512-dV6cODlzbO8u6Anmv2N/ilQHq/AWz0xyltuXoLU3yUyXbZcnWYZuB2rL8OBGPmqNcD+x9NdScBNXh7vWN0naSQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@napi-rs/tar-wasm32-wasi": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@napi-rs/tar-wasm32-wasi/-/tar-wasm32-wasi-1.1.0.tgz", + "integrity": "sha512-jIa9nb2HzOrfH0F8QQ9g3WE4aMH5vSI5/1NYVNm9ysCmNjCCtMXCAhlI3WKCdm/DwHf0zLqdrrtDFXODcNaqMw==", + "cpu": [ + "wasm32" + ], + "dev": true, + "license": "MIT", + "optional": true, "dependencies": { - "semver": { - "version": "5.7.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", - "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", - "dev": true - } + "@napi-rs/wasm-runtime": "^1.0.3" + }, + "engines": { + "node": ">=14.0.0" } }, - "normalize-path": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", - "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", - "dev": true + "node_modules/@napi-rs/tar-win32-arm64-msvc": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@napi-rs/tar-win32-arm64-msvc/-/tar-win32-arm64-msvc-1.1.0.tgz", + "integrity": "sha512-vfpG71OB0ijtjemp3WTdmBKJm9R70KM8vsSExMsIQtV0lVzP07oM1CW6JbNRPXNLhRoue9ofYLiUDk8bE0Hckg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10" + } }, - "npm-run-path": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-4.0.1.tgz", - "integrity": "sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw==", + "node_modules/@napi-rs/tar-win32-ia32-msvc": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@napi-rs/tar-win32-ia32-msvc/-/tar-win32-ia32-msvc-1.1.0.tgz", + "integrity": "sha512-hGPyPW60YSpOSgzfy68DLBHgi6HxkAM+L59ZZZPMQ0TOXjQg+p2EW87+TjZfJOkSpbYiEkULwa/f4a2hcVjsqQ==", + "cpu": [ + "ia32" + ], "dev": true, - "requires": { - "path-key": "^3.0.0" + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10" } }, - "nyc": { - "version": "15.1.0", - "resolved": "https://registry.npmjs.org/nyc/-/nyc-15.1.0.tgz", - "integrity": "sha512-jMW04n9SxKdKi1ZMGhvUTHBN0EICCRkHemEoE5jm6mTYcqcdas0ATzgUgejlQUHMvpnOZqGB5Xxsv9KxJW1j8A==", + "node_modules/@napi-rs/tar-win32-x64-msvc": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@napi-rs/tar-win32-x64-msvc/-/tar-win32-x64-msvc-1.1.0.tgz", + "integrity": "sha512-L6Ed1DxXK9YSCMyvpR8MiNAyKNkQLjsHsHK9E0qnHa8NzLFqzDKhvs5LfnWxM2kJ+F7m/e5n9zPm24kHb3LsVw==", + "cpu": [ + "x64" + ], "dev": true, - "requires": { - "@istanbuljs/load-nyc-config": "^1.0.0", - "@istanbuljs/schema": "^0.1.2", - "caching-transform": "^4.0.0", - "convert-source-map": "^1.7.0", - "decamelize": "^1.2.0", - "find-cache-dir": "^3.2.0", + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@napi-rs/wasm-runtime": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@napi-rs/wasm-runtime/-/wasm-runtime-1.1.1.tgz", + "integrity": "sha512-p64ah1M1ld8xjWv3qbvFwHiFVWrq1yFvV4f7w+mzaqiR4IlSgkqhcRdHwsGgomwzBH51sRY4NEowLxnaBjcW/A==", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "@emnapi/core": "^1.7.1", + "@emnapi/runtime": "^1.7.1", + "@tybys/wasm-util": "^0.10.1" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/Brooooooklyn" + } + }, + "node_modules/@napi-rs/wasm-tools": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@napi-rs/wasm-tools/-/wasm-tools-1.0.1.tgz", + "integrity": "sha512-enkZYyuCdo+9jneCPE/0fjIta4wWnvVN9hBo2HuiMpRF0q3lzv1J6b/cl7i0mxZUKhBrV3aCKDBQnCOhwKbPmQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 10" + }, + "optionalDependencies": { + "@napi-rs/wasm-tools-android-arm-eabi": "1.0.1", + "@napi-rs/wasm-tools-android-arm64": "1.0.1", + "@napi-rs/wasm-tools-darwin-arm64": "1.0.1", + "@napi-rs/wasm-tools-darwin-x64": "1.0.1", + "@napi-rs/wasm-tools-freebsd-x64": "1.0.1", + "@napi-rs/wasm-tools-linux-arm64-gnu": "1.0.1", + "@napi-rs/wasm-tools-linux-arm64-musl": "1.0.1", + "@napi-rs/wasm-tools-linux-x64-gnu": "1.0.1", + "@napi-rs/wasm-tools-linux-x64-musl": "1.0.1", + "@napi-rs/wasm-tools-wasm32-wasi": "1.0.1", + "@napi-rs/wasm-tools-win32-arm64-msvc": "1.0.1", + "@napi-rs/wasm-tools-win32-ia32-msvc": "1.0.1", + "@napi-rs/wasm-tools-win32-x64-msvc": "1.0.1" + } + }, + "node_modules/@napi-rs/wasm-tools-android-arm-eabi": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@napi-rs/wasm-tools-android-arm-eabi/-/wasm-tools-android-arm-eabi-1.0.1.tgz", + "integrity": "sha512-lr07E/l571Gft5v4aA1dI8koJEmF1F0UigBbsqg9OWNzg80H3lDPO+auv85y3T/NHE3GirDk7x/D3sLO57vayw==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@napi-rs/wasm-tools-android-arm64": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@napi-rs/wasm-tools-android-arm64/-/wasm-tools-android-arm64-1.0.1.tgz", + "integrity": "sha512-WDR7S+aRLV6LtBJAg5fmjKkTZIdrEnnQxgdsb7Cf8pYiMWBHLU+LC49OUVppQ2YSPY0+GeYm9yuZWW3kLjJ7Bg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@napi-rs/wasm-tools-darwin-arm64": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@napi-rs/wasm-tools-darwin-arm64/-/wasm-tools-darwin-arm64-1.0.1.tgz", + "integrity": "sha512-qWTI+EEkiN0oIn/N2gQo7+TVYil+AJ20jjuzD2vATS6uIjVz+Updeqmszi7zq7rdFTLp6Ea3/z4kDKIfZwmR9g==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@napi-rs/wasm-tools-darwin-x64": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@napi-rs/wasm-tools-darwin-x64/-/wasm-tools-darwin-x64-1.0.1.tgz", + "integrity": "sha512-bA6hubqtHROR5UI3tToAF/c6TDmaAgF0SWgo4rADHtQ4wdn0JeogvOk50gs2TYVhKPE2ZD2+qqt7oBKB+sxW3A==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@napi-rs/wasm-tools-freebsd-x64": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@napi-rs/wasm-tools-freebsd-x64/-/wasm-tools-freebsd-x64-1.0.1.tgz", + "integrity": "sha512-90+KLBkD9hZEjPQW1MDfwSt5J1L46EUKacpCZWyRuL6iIEO5CgWU0V/JnEgFsDOGyyYtiTvHc5bUdUTWd4I9Vg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@napi-rs/wasm-tools-linux-arm64-gnu": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@napi-rs/wasm-tools-linux-arm64-gnu/-/wasm-tools-linux-arm64-gnu-1.0.1.tgz", + "integrity": "sha512-rG0QlS65x9K/u3HrKafDf8cFKj5wV2JHGfl8abWgKew0GVPyp6vfsDweOwHbWAjcHtp2LHi6JHoW80/MTHm52Q==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@napi-rs/wasm-tools-linux-arm64-musl": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@napi-rs/wasm-tools-linux-arm64-musl/-/wasm-tools-linux-arm64-musl-1.0.1.tgz", + "integrity": "sha512-jAasbIvjZXCgX0TCuEFQr+4D6Lla/3AAVx2LmDuMjgG4xoIXzjKWl7c4chuaD+TI+prWT0X6LJcdzFT+ROKGHQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@napi-rs/wasm-tools-linux-x64-gnu": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@napi-rs/wasm-tools-linux-x64-gnu/-/wasm-tools-linux-x64-gnu-1.0.1.tgz", + "integrity": "sha512-Plgk5rPqqK2nocBGajkMVbGm010Z7dnUgq0wtnYRZbzWWxwWcXfZMPa8EYxrK4eE8SzpI7VlZP1tdVsdjgGwMw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@napi-rs/wasm-tools-linux-x64-musl": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@napi-rs/wasm-tools-linux-x64-musl/-/wasm-tools-linux-x64-musl-1.0.1.tgz", + "integrity": "sha512-GW7AzGuWxtQkyHknHWYFdR0CHmW6is8rG2Rf4V6GNmMpmwtXt/ItWYWtBe4zqJWycMNazpfZKSw/BpT7/MVCXQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@napi-rs/wasm-tools-wasm32-wasi": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@napi-rs/wasm-tools-wasm32-wasi/-/wasm-tools-wasm32-wasi-1.0.1.tgz", + "integrity": "sha512-/nQVSTrqSsn7YdAc2R7Ips/tnw5SPUcl3D7QrXCNGPqjbatIspnaexvaOYNyKMU6xPu+pc0BTnKVmqhlJJCPLA==", + "cpu": [ + "wasm32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "@napi-rs/wasm-runtime": "^1.0.3" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/@napi-rs/wasm-tools-win32-arm64-msvc": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@napi-rs/wasm-tools-win32-arm64-msvc/-/wasm-tools-win32-arm64-msvc-1.0.1.tgz", + "integrity": "sha512-PFi7oJIBu5w7Qzh3dwFea3sHRO3pojMsaEnUIy22QvsW+UJfNQwJCryVrpoUt8m4QyZXI+saEq/0r4GwdoHYFQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@napi-rs/wasm-tools-win32-ia32-msvc": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@napi-rs/wasm-tools-win32-ia32-msvc/-/wasm-tools-win32-ia32-msvc-1.0.1.tgz", + "integrity": "sha512-gXkuYzxQsgkj05Zaq+KQTkHIN83dFAwMcTKa2aQcpYPRImFm2AQzEyLtpXmyCWzJ0F9ZYAOmbSyrNew8/us6bw==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@napi-rs/wasm-tools-win32-x64-msvc": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@napi-rs/wasm-tools-win32-x64-msvc/-/wasm-tools-win32-x64-msvc-1.0.1.tgz", + "integrity": "sha512-rEAf05nol3e3eei2sRButmgXP+6ATgm0/38MKhz9Isne82T4rPIMYsCIFj0kOisaGeVwoi2fnm7O9oWp5YVnYQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@nodelib/fs.scandir": { + "version": "2.1.5", + "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", + "integrity": "sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@nodelib/fs.stat": "2.0.5", + "run-parallel": "^1.1.9" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/@nodelib/fs.stat": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz", + "integrity": "sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 8" + } + }, + "node_modules/@nodelib/fs.walk": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz", + "integrity": "sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@nodelib/fs.scandir": "2.1.5", + "fastq": "^1.6.0" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/@npmcli/ci-detect": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/@npmcli/ci-detect/-/ci-detect-3.0.2.tgz", + "integrity": "sha512-P7nZG0skRVa9lH0OQmFG62CrzOySUiuPbKopjVAj3sXP0m1om9XfIvTp46h+NvlpTyd121JekiXFZj+1pnbm9g==", + "deprecated": "this package has been deprecated, use `ci-info` instead", + "dev": true, + "license": "ISC", + "engines": { + "node": "^14.17.0 || ^16.13.0 || >=18.0.0" + } + }, + "node_modules/@octokit/auth-token": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/@octokit/auth-token/-/auth-token-6.0.0.tgz", + "integrity": "sha512-P4YJBPdPSpWTQ1NU4XYdvHvXJJDxM6YwpS0FZHRgP7YFkdVxsWcpWGy/NVqlAA7PcPCnMacXlRm1y2PFZRWL/w==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 20" + } + }, + "node_modules/@octokit/core": { + "version": "7.0.6", + "resolved": "https://registry.npmjs.org/@octokit/core/-/core-7.0.6.tgz", + "integrity": "sha512-DhGl4xMVFGVIyMwswXeyzdL4uXD5OGILGX5N8Y+f6W7LhC1Ze2poSNrkF/fedpVDHEEZ+PHFW0vL14I+mm8K3Q==", + "dev": true, + "license": "MIT", + "peer": true, + "dependencies": { + "@octokit/auth-token": "^6.0.0", + "@octokit/graphql": "^9.0.3", + "@octokit/request": "^10.0.6", + "@octokit/request-error": "^7.0.2", + "@octokit/types": "^16.0.0", + "before-after-hook": "^4.0.0", + "universal-user-agent": "^7.0.0" + }, + "engines": { + "node": ">= 20" + } + }, + "node_modules/@octokit/endpoint": { + "version": "11.0.2", + "resolved": "https://registry.npmjs.org/@octokit/endpoint/-/endpoint-11.0.2.tgz", + "integrity": "sha512-4zCpzP1fWc7QlqunZ5bSEjxc6yLAlRTnDwKtgXfcI/FxxGoqedDG8V2+xJ60bV2kODqcGB+nATdtap/XYq2NZQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@octokit/types": "^16.0.0", + "universal-user-agent": "^7.0.2" + }, + "engines": { + "node": ">= 20" + } + }, + "node_modules/@octokit/graphql": { + "version": "9.0.3", + "resolved": "https://registry.npmjs.org/@octokit/graphql/-/graphql-9.0.3.tgz", + "integrity": "sha512-grAEuupr/C1rALFnXTv6ZQhFuL1D8G5y8CN04RgrO4FIPMrtm+mcZzFG7dcBm+nq+1ppNixu+Jd78aeJOYxlGA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@octokit/request": "^10.0.6", + "@octokit/types": "^16.0.0", + "universal-user-agent": "^7.0.0" + }, + "engines": { + "node": ">= 20" + } + }, + "node_modules/@octokit/openapi-types": { + "version": "27.0.0", + "resolved": "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-27.0.0.tgz", + "integrity": "sha512-whrdktVs1h6gtR+09+QsNk2+FO+49j6ga1c55YZudfEG+oKJVvJLQi3zkOm5JjiUXAagWK2tI2kTGKJ2Ys7MGA==", + "dev": true, + "license": "MIT" + }, + "node_modules/@octokit/plugin-paginate-rest": { + "version": "14.0.0", + "resolved": "https://registry.npmjs.org/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-14.0.0.tgz", + "integrity": "sha512-fNVRE7ufJiAA3XUrha2omTA39M6IXIc6GIZLvlbsm8QOQCYvpq/LkMNGyFlB1d8hTDzsAXa3OKtybdMAYsV/fw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@octokit/types": "^16.0.0" + }, + "engines": { + "node": ">= 20" + }, + "peerDependencies": { + "@octokit/core": ">=6" + } + }, + "node_modules/@octokit/plugin-request-log": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/@octokit/plugin-request-log/-/plugin-request-log-6.0.0.tgz", + "integrity": "sha512-UkOzeEN3W91/eBq9sPZNQ7sUBvYCqYbrrD8gTbBuGtHEuycE4/awMXcYvx6sVYo7LypPhmQwwpUe4Yyu4QZN5Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 20" + }, + "peerDependencies": { + "@octokit/core": ">=6" + } + }, + "node_modules/@octokit/plugin-rest-endpoint-methods": { + "version": "17.0.0", + "resolved": "https://registry.npmjs.org/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-17.0.0.tgz", + "integrity": "sha512-B5yCyIlOJFPqUUeiD0cnBJwWJO8lkJs5d8+ze9QDP6SvfiXSz1BF+91+0MeI1d2yxgOhU/O+CvtiZ9jSkHhFAw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@octokit/types": "^16.0.0" + }, + "engines": { + "node": ">= 20" + }, + "peerDependencies": { + "@octokit/core": ">=6" + } + }, + "node_modules/@octokit/request": { + "version": "10.0.7", + "resolved": "https://registry.npmjs.org/@octokit/request/-/request-10.0.7.tgz", + "integrity": "sha512-v93h0i1yu4idj8qFPZwjehoJx4j3Ntn+JhXsdJrG9pYaX6j/XRz2RmasMUHtNgQD39nrv/VwTWSqK0RNXR8upA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@octokit/endpoint": "^11.0.2", + "@octokit/request-error": "^7.0.2", + "@octokit/types": "^16.0.0", + "fast-content-type-parse": "^3.0.0", + "universal-user-agent": "^7.0.2" + }, + "engines": { + "node": ">= 20" + } + }, + "node_modules/@octokit/request-error": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/@octokit/request-error/-/request-error-7.1.0.tgz", + "integrity": "sha512-KMQIfq5sOPpkQYajXHwnhjCC0slzCNScLHs9JafXc4RAJI+9f+jNDlBNaIMTvazOPLgb4BnlhGJOTbnN0wIjPw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@octokit/types": "^16.0.0" + }, + "engines": { + "node": ">= 20" + } + }, + "node_modules/@octokit/rest": { + "version": "22.0.1", + "resolved": "https://registry.npmjs.org/@octokit/rest/-/rest-22.0.1.tgz", + "integrity": "sha512-Jzbhzl3CEexhnivb1iQ0KJ7s5vvjMWcmRtq5aUsKmKDrRW6z3r84ngmiFKFvpZjpiU/9/S6ITPFRpn5s/3uQJw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@octokit/core": "^7.0.6", + "@octokit/plugin-paginate-rest": "^14.0.0", + "@octokit/plugin-request-log": "^6.0.0", + "@octokit/plugin-rest-endpoint-methods": "^17.0.0" + }, + "engines": { + "node": ">= 20" + } + }, + "node_modules/@octokit/types": { + "version": "16.0.0", + "resolved": "https://registry.npmjs.org/@octokit/types/-/types-16.0.0.tgz", + "integrity": "sha512-sKq+9r1Mm4efXW1FCk7hFSeJo4QKreL/tTbR0rz/qx/r1Oa2VV83LTA/H/MuCOX7uCIJmQVRKBcbmWoySjAnSg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@octokit/openapi-types": "^27.0.0" + } + }, + "node_modules/@pkgjs/parseargs": { + "version": "0.11.0", + "resolved": "https://registry.npmjs.org/@pkgjs/parseargs/-/parseargs-0.11.0.tgz", + "integrity": "sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==", + "dev": true, + "license": "MIT", + "optional": true, + "engines": { + "node": ">=14" + } + }, + "node_modules/@pkgr/core": { + "version": "0.2.9", + "resolved": "https://registry.npmjs.org/@pkgr/core/-/core-0.2.9.tgz", + "integrity": "sha512-QNqXyfVS2wm9hweSYD2O7F0G06uurj9kZ96TRQE5Y9hU7+tgdZwIkbAKc5Ocy1HxEY2kuDQa6cQ1WRs/O5LFKA==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^12.20.0 || ^14.18.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/pkgr" + } + }, + "node_modules/@puppeteer/browsers": { + "version": "2.6.1", + "resolved": "https://registry.npmjs.org/@puppeteer/browsers/-/browsers-2.6.1.tgz", + "integrity": "sha512-aBSREisdsGH890S2rQqK82qmQYU3uFpSH8wcZWHgHzl3LfzsxAKbLNiAG9mO8v1Y0UICBeClICxPJvyr0rcuxg==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "debug": "^4.4.0", + "extract-zip": "^2.0.1", + "progress": "^2.0.3", + "proxy-agent": "^6.5.0", + "semver": "^7.6.3", + "tar-fs": "^3.0.6", + "unbzip2-stream": "^1.4.3", + "yargs": "^17.7.2" + }, + "bin": { + "browsers": "lib/cjs/main-cli.js" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/@react-aria/focus": { + "version": "3.21.3", + "resolved": "https://registry.npmjs.org/@react-aria/focus/-/focus-3.21.3.tgz", + "integrity": "sha512-FsquWvjSCwC2/sBk4b+OqJyONETUIXQ2vM0YdPAuC+QFQh2DT6TIBo6dOZVSezlhudDla69xFBd6JvCFq1AbUw==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@react-aria/interactions": "^3.26.0", + "@react-aria/utils": "^3.32.0", + "@react-types/shared": "^3.32.1", + "@swc/helpers": "^0.5.0", + "clsx": "^2.0.0" + }, + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1", + "react-dom": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1" + } + }, + "node_modules/@react-aria/interactions": { + "version": "3.26.0", + "resolved": "https://registry.npmjs.org/@react-aria/interactions/-/interactions-3.26.0.tgz", + "integrity": "sha512-AAEcHiltjfbmP1i9iaVw34Mb7kbkiHpYdqieWufldh4aplWgsF11YQZOfaCJW4QoR2ML4Zzoa9nfFwLXA52R7Q==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@react-aria/ssr": "^3.9.10", + "@react-aria/utils": "^3.32.0", + "@react-stately/flags": "^3.1.2", + "@react-types/shared": "^3.32.1", + "@swc/helpers": "^0.5.0" + }, + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1", + "react-dom": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1" + } + }, + "node_modules/@react-aria/ssr": { + "version": "3.9.10", + "resolved": "https://registry.npmjs.org/@react-aria/ssr/-/ssr-3.9.10.tgz", + "integrity": "sha512-hvTm77Pf+pMBhuBm760Li0BVIO38jv1IBws1xFm1NoL26PU+fe+FMW5+VZWyANR6nYL65joaJKZqOdTQMkO9IQ==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@swc/helpers": "^0.5.0" + }, + "engines": { + "node": ">= 12" + }, + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1" + } + }, + "node_modules/@react-aria/utils": { + "version": "3.32.0", + "resolved": "https://registry.npmjs.org/@react-aria/utils/-/utils-3.32.0.tgz", + "integrity": "sha512-/7Rud06+HVBIlTwmwmJa2W8xVtgxgzm0+kLbuFooZRzKDON6hhozS1dOMR/YLMxyJOaYOTpImcP4vRR9gL1hEg==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@react-aria/ssr": "^3.9.10", + "@react-stately/flags": "^3.1.2", + "@react-stately/utils": "^3.11.0", + "@react-types/shared": "^3.32.1", + "@swc/helpers": "^0.5.0", + "clsx": "^2.0.0" + }, + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1", + "react-dom": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1" + } + }, + "node_modules/@react-stately/flags": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/@react-stately/flags/-/flags-3.1.2.tgz", + "integrity": "sha512-2HjFcZx1MyQXoPqcBGALwWWmgFVUk2TuKVIQxCbRq7fPyWXIl6VHcakCLurdtYC2Iks7zizvz0Idv48MQ38DWg==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@swc/helpers": "^0.5.0" + } + }, + "node_modules/@react-stately/utils": { + "version": "3.11.0", + "resolved": "https://registry.npmjs.org/@react-stately/utils/-/utils-3.11.0.tgz", + "integrity": "sha512-8LZpYowJ9eZmmYLpudbo/eclIRnbhWIJZ994ncmlKlouNzKohtM8qTC6B1w1pwUbiwGdUoyzLuQbeaIor5Dvcw==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@swc/helpers": "^0.5.0" + }, + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1" + } + }, + "node_modules/@react-types/shared": { + "version": "3.32.1", + "resolved": "https://registry.npmjs.org/@react-types/shared/-/shared-3.32.1.tgz", + "integrity": "sha512-famxyD5emrGGpFuUlgOP6fVW2h/ZaF405G5KDi3zPHzyjAWys/8W6NAVJtNbkCkhedmvL0xOhvt8feGXyXaw5w==", + "dev": true, + "license": "Apache-2.0", + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1" + } + }, + "node_modules/@rollup/plugin-alias": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/@rollup/plugin-alias/-/plugin-alias-6.0.0.tgz", + "integrity": "sha512-tPCzJOtS7uuVZd+xPhoy5W4vThe6KWXNmsFCNktaAh5RTqcLiSfT4huPQIXkgJ6YCOjJHvecOAzQxLFhPxKr+g==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=20.19.0" + }, + "peerDependencies": { + "rollup": ">=4.0.0" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + } + } + }, + "node_modules/@rollup/plugin-buble": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@rollup/plugin-buble/-/plugin-buble-1.0.3.tgz", + "integrity": "sha512-QYD9BKkJoof0FdCFeSYYhF6/Y8e0Mnf+098xGgmWOFJ4UPHlWujjqOYeVwEm2hJPOmlR5k7HPUdAjqtOWhN64Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "@rollup/pluginutils": "^5.0.1", + "@types/buble": "^0.19.2", + "buble": "^0.20.0" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "rollup": "^1.20.0||^2.0.0||^3.0.0||^4.0.0" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + } + } + }, + "node_modules/@rollup/plugin-commonjs": { + "version": "29.0.0", + "resolved": "https://registry.npmjs.org/@rollup/plugin-commonjs/-/plugin-commonjs-29.0.0.tgz", + "integrity": "sha512-U2YHaxR2cU/yAiwKJtJRhnyLk7cifnQw0zUpISsocBDoHDJn+HTV74ABqnwr5bEgWUwFZC9oFL6wLe21lHu5eQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@rollup/pluginutils": "^5.0.1", + "commondir": "^1.0.1", + "estree-walker": "^2.0.2", + "fdir": "^6.2.0", + "is-reference": "1.2.1", + "magic-string": "^0.30.3", + "picomatch": "^4.0.2" + }, + "engines": { + "node": ">=16.0.0 || 14 >= 14.17" + }, + "peerDependencies": { + "rollup": "^2.68.0||^3.0.0||^4.0.0" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + } + } + }, + "node_modules/@rollup/plugin-commonjs/node_modules/is-reference": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/is-reference/-/is-reference-1.2.1.tgz", + "integrity": "sha512-U82MsXXiFIrjCK4otLT+o2NA2Cd2g5MLoOVXUZjIOhLurrRxpEXzI8O0KZHr3IjLvlAH1kTPYSuqer5T9ZVBKQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/estree": "*" + } + }, + "node_modules/@rollup/plugin-json": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/@rollup/plugin-json/-/plugin-json-6.1.0.tgz", + "integrity": "sha512-EGI2te5ENk1coGeADSIwZ7G2Q8CJS2sF120T7jLw4xFw9n7wIOXHo+kIYRAoVpJAN+kmqZSoO3Fp4JtoNF4ReA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@rollup/pluginutils": "^5.1.0" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "rollup": "^1.20.0||^2.0.0||^3.0.0||^4.0.0" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + } + } + }, + "node_modules/@rollup/plugin-node-resolve": { + "version": "16.0.3", + "resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-16.0.3.tgz", + "integrity": "sha512-lUYM3UBGuM93CnMPG1YocWu7X802BrNF3jW2zny5gQyLQgRFJhV1Sq0Zi74+dh/6NBx1DxFC4b4GXg9wUCG5Qg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@rollup/pluginutils": "^5.0.1", + "@types/resolve": "1.20.2", + "deepmerge": "^4.2.2", + "is-module": "^1.0.0", + "resolve": "^1.22.1" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "rollup": "^2.78.0||^3.0.0||^4.0.0" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + } + } + }, + "node_modules/@rollup/plugin-replace": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/@rollup/plugin-replace/-/plugin-replace-6.0.3.tgz", + "integrity": "sha512-J4RZarRvQAm5IF0/LwUUg+obsm+xZhYnbMXmXROyoSE1ATJe3oXSb9L5MMppdxP2ylNSjv6zFBwKYjcKMucVfA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@rollup/pluginutils": "^5.0.1", + "magic-string": "^0.30.3" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "rollup": "^1.20.0||^2.0.0||^3.0.0||^4.0.0" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + } + } + }, + "node_modules/@rollup/plugin-terser": { + "version": "0.4.4", + "resolved": "https://registry.npmjs.org/@rollup/plugin-terser/-/plugin-terser-0.4.4.tgz", + "integrity": "sha512-XHeJC5Bgvs8LfukDwWZp7yeqin6ns8RTl2B9avbejt6tZqsqvVoWI7ZTQrcNsfKEDWBTnTxM8nMDkO2IFFbd0A==", + "dev": true, + "license": "MIT", + "dependencies": { + "serialize-javascript": "^6.0.1", + "smob": "^1.0.0", + "terser": "^5.17.4" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "rollup": "^2.0.0||^3.0.0||^4.0.0" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + } + } + }, + "node_modules/@rollup/plugin-typescript": { + "version": "12.3.0", + "resolved": "https://registry.npmjs.org/@rollup/plugin-typescript/-/plugin-typescript-12.3.0.tgz", + "integrity": "sha512-7DP0/p7y3t67+NabT9f8oTBFE6gGkto4SA6Np2oudYmZE/m1dt8RB0SjL1msMxFpLo631qjRCcBlAbq1ml/Big==", + "dev": true, + "license": "MIT", + "dependencies": { + "@rollup/pluginutils": "^5.1.0", + "resolve": "^1.22.1" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "rollup": "^2.14.0||^3.0.0||^4.0.0", + "tslib": "*", + "typescript": ">=3.7.0" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + }, + "tslib": { + "optional": true + } + } + }, + "node_modules/@rollup/pluginutils": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-5.3.0.tgz", + "integrity": "sha512-5EdhGZtnu3V88ces7s53hhfK5KSASnJZv8Lulpc04cWO3REESroJXg73DFsOmgbU2BhwV0E20bu2IDZb3VKW4Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/estree": "^1.0.0", + "estree-walker": "^2.0.2", + "picomatch": "^4.0.2" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "rollup": "^1.20.0||^2.0.0||^3.0.0||^4.0.0" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + } + } + }, + "node_modules/@rollup/rollup-android-arm-eabi": { + "version": "4.55.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.55.1.tgz", + "integrity": "sha512-9R0DM/ykwfGIlNu6+2U09ga0WXeZ9MRC2Ter8jnz8415VbuIykVuc6bhdrbORFZANDmTDvq26mJrEVTl8TdnDg==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ] + }, + "node_modules/@rollup/rollup-android-arm64": { + "version": "4.55.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.55.1.tgz", + "integrity": "sha512-eFZCb1YUqhTysgW3sj/55du5cG57S7UTNtdMjCW7LwVcj3dTTcowCsC8p7uBdzKsZYa8J7IDE8lhMI+HX1vQvg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ] + }, + "node_modules/@rollup/rollup-darwin-arm64": { + "version": "4.55.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.55.1.tgz", + "integrity": "sha512-p3grE2PHcQm2e8PSGZdzIhCKbMCw/xi9XvMPErPhwO17vxtvCN5FEA2mSLgmKlCjHGMQTP6phuQTYWUnKewwGg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@rollup/rollup-darwin-x64": { + "version": "4.55.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.55.1.tgz", + "integrity": "sha512-rDUjG25C9qoTm+e02Esi+aqTKSBYwVTaoS1wxcN47/Luqef57Vgp96xNANwt5npq9GDxsH7kXxNkJVEsWEOEaQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@rollup/rollup-freebsd-arm64": { + "version": "4.55.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.55.1.tgz", + "integrity": "sha512-+JiU7Jbp5cdxekIgdte0jfcu5oqw4GCKr6i3PJTlXTCU5H5Fvtkpbs4XJHRmWNXF+hKmn4v7ogI5OQPaupJgOg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ] + }, + "node_modules/@rollup/rollup-freebsd-x64": { + "version": "4.55.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.55.1.tgz", + "integrity": "sha512-V5xC1tOVWtLLmr3YUk2f6EJK4qksksOYiz/TCsFHu/R+woubcLWdC9nZQmwjOAbmExBIVKsm1/wKmEy4z4u4Bw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ] + }, + "node_modules/@rollup/rollup-linux-arm-gnueabihf": { + "version": "4.55.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.55.1.tgz", + "integrity": "sha512-Rn3n+FUk2J5VWx+ywrG/HGPTD9jXNbicRtTM11e/uorplArnXZYsVifnPPqNNP5BsO3roI4n8332ukpY/zN7rQ==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm-musleabihf": { + "version": "4.55.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.55.1.tgz", + "integrity": "sha512-grPNWydeKtc1aEdrJDWk4opD7nFtQbMmV7769hiAaYyUKCT1faPRm2av8CX1YJsZ4TLAZcg9gTR1KvEzoLjXkg==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm64-gnu": { + "version": "4.55.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.55.1.tgz", + "integrity": "sha512-a59mwd1k6x8tXKcUxSyISiquLwB5pX+fJW9TkWU46lCqD/GRDe9uDN31jrMmVP3feI3mhAdvcCClhV8V5MhJFQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm64-musl": { + "version": "4.55.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.55.1.tgz", + "integrity": "sha512-puS1MEgWX5GsHSoiAsF0TYrpomdvkaXm0CofIMG5uVkP6IBV+ZO9xhC5YEN49nsgYo1DuuMquF9+7EDBVYu4uA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-loong64-gnu": { + "version": "4.55.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-gnu/-/rollup-linux-loong64-gnu-4.55.1.tgz", + "integrity": "sha512-r3Wv40in+lTsULSb6nnoudVbARdOwb2u5fpeoOAZjFLznp6tDU8kd+GTHmJoqZ9lt6/Sys33KdIHUaQihFcu7g==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-loong64-musl": { + "version": "4.55.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-musl/-/rollup-linux-loong64-musl-4.55.1.tgz", + "integrity": "sha512-MR8c0+UxAlB22Fq4R+aQSPBayvYa3+9DrwG/i1TKQXFYEaoW3B5b/rkSRIypcZDdWjWnpcvxbNaAJDcSbJU3Lw==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-ppc64-gnu": { + "version": "4.55.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-gnu/-/rollup-linux-ppc64-gnu-4.55.1.tgz", + "integrity": "sha512-3KhoECe1BRlSYpMTeVrD4sh2Pw2xgt4jzNSZIIPLFEsnQn9gAnZagW9+VqDqAHgm1Xc77LzJOo2LdigS5qZ+gw==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-ppc64-musl": { + "version": "4.55.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-musl/-/rollup-linux-ppc64-musl-4.55.1.tgz", + "integrity": "sha512-ziR1OuZx0vdYZZ30vueNZTg73alF59DicYrPViG0NEgDVN8/Jl87zkAPu4u6VjZST2llgEUjaiNl9JM6HH1Vdw==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-riscv64-gnu": { + "version": "4.55.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.55.1.tgz", + "integrity": "sha512-uW0Y12ih2XJRERZ4jAfKamTyIHVMPQnTZcQjme2HMVDAHY4amf5u414OqNYC+x+LzRdRcnIG1YodLrrtA8xsxw==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-riscv64-musl": { + "version": "4.55.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-musl/-/rollup-linux-riscv64-musl-4.55.1.tgz", + "integrity": "sha512-u9yZ0jUkOED1BFrqu3BwMQoixvGHGZ+JhJNkNKY/hyoEgOwlqKb62qu+7UjbPSHYjiVy8kKJHvXKv5coH4wDeg==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-s390x-gnu": { + "version": "4.55.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.55.1.tgz", + "integrity": "sha512-/0PenBCmqM4ZUd0190j7J0UsQ/1nsi735iPRakO8iPciE7BQ495Y6msPzaOmvx0/pn+eJVVlZrNrSh4WSYLxNg==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-x64-gnu": { + "version": "4.55.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.55.1.tgz", + "integrity": "sha512-a8G4wiQxQG2BAvo+gU6XrReRRqj+pLS2NGXKm8io19goR+K8lw269eTrPkSdDTALwMmJp4th2Uh0D8J9bEV1vg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-x64-musl": { + "version": "4.55.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.55.1.tgz", + "integrity": "sha512-bD+zjpFrMpP/hqkfEcnjXWHMw5BIghGisOKPj+2NaNDuVT+8Ds4mPf3XcPHuat1tz89WRL+1wbcxKY3WSbiT7w==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-openbsd-x64": { + "version": "4.55.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-openbsd-x64/-/rollup-openbsd-x64-4.55.1.tgz", + "integrity": "sha512-eLXw0dOiqE4QmvikfQ6yjgkg/xDM+MdU9YJuP4ySTibXU0oAvnEWXt7UDJmD4UkYialMfOGFPJnIHSe/kdzPxg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ] + }, + "node_modules/@rollup/rollup-openharmony-arm64": { + "version": "4.55.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-openharmony-arm64/-/rollup-openharmony-arm64-4.55.1.tgz", + "integrity": "sha512-xzm44KgEP11te3S2HCSyYf5zIzWmx3n8HDCc7EE59+lTcswEWNpvMLfd9uJvVX8LCg9QWG67Xt75AuHn4vgsXw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ] + }, + "node_modules/@rollup/rollup-win32-arm64-msvc": { + "version": "4.55.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.55.1.tgz", + "integrity": "sha512-yR6Bl3tMC/gBok5cz/Qi0xYnVbIxGx5Fcf/ca0eB6/6JwOY+SRUcJfI0OpeTpPls7f194as62thCt/2BjxYN8g==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-ia32-msvc": { + "version": "4.55.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.55.1.tgz", + "integrity": "sha512-3fZBidchE0eY0oFZBnekYCfg+5wAB0mbpCBuofh5mZuzIU/4jIVkbESmd2dOsFNS78b53CYv3OAtwqkZZmU5nA==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-x64-gnu": { + "version": "4.55.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-gnu/-/rollup-win32-x64-gnu-4.55.1.tgz", + "integrity": "sha512-xGGY5pXj69IxKb4yv/POoocPy/qmEGhimy/FoTpTSVju3FYXUQQMFCaZZXJVidsmGxRioZAwpThl/4zX41gRKg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-x64-msvc": { + "version": "4.55.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.55.1.tgz", + "integrity": "sha512-SPEpaL6DX4rmcXtnhdrQYgzQ5W2uW3SCJch88lB2zImhJRhIIK44fkUrgIV/Q8yUNfw5oyZ5vkeQsZLhCb06lw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@shikijs/core": { + "version": "3.21.0", + "resolved": "https://registry.npmjs.org/@shikijs/core/-/core-3.21.0.tgz", + "integrity": "sha512-AXSQu/2n1UIQekY8euBJlvFYZIw0PHY63jUzGbrOma4wPxzznJXTXkri+QcHeBNaFxiiOljKxxJkVSoB3PjbyA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@shikijs/types": "3.21.0", + "@shikijs/vscode-textmate": "^10.0.2", + "@types/hast": "^3.0.4", + "hast-util-to-html": "^9.0.5" + } + }, + "node_modules/@shikijs/engine-javascript": { + "version": "3.21.0", + "resolved": "https://registry.npmjs.org/@shikijs/engine-javascript/-/engine-javascript-3.21.0.tgz", + "integrity": "sha512-ATwv86xlbmfD9n9gKRiwuPpWgPENAWCLwYCGz9ugTJlsO2kOzhOkvoyV/UD+tJ0uT7YRyD530x6ugNSffmvIiQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@shikijs/types": "3.21.0", + "@shikijs/vscode-textmate": "^10.0.2", + "oniguruma-to-es": "^4.3.4" + } + }, + "node_modules/@shikijs/engine-oniguruma": { + "version": "3.21.0", + "resolved": "https://registry.npmjs.org/@shikijs/engine-oniguruma/-/engine-oniguruma-3.21.0.tgz", + "integrity": "sha512-OYknTCct6qiwpQDqDdf3iedRdzj6hFlOPv5hMvI+hkWfCKs5mlJ4TXziBG9nyabLwGulrUjHiCq3xCspSzErYQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@shikijs/types": "3.21.0", + "@shikijs/vscode-textmate": "^10.0.2" + } + }, + "node_modules/@shikijs/langs": { + "version": "3.21.0", + "resolved": "https://registry.npmjs.org/@shikijs/langs/-/langs-3.21.0.tgz", + "integrity": "sha512-g6mn5m+Y6GBJ4wxmBYqalK9Sp0CFkUqfNzUy2pJglUginz6ZpWbaWjDB4fbQ/8SHzFjYbtU6Ddlp1pc+PPNDVA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@shikijs/types": "3.21.0" + } + }, + "node_modules/@shikijs/themes": { + "version": "3.21.0", + "resolved": "https://registry.npmjs.org/@shikijs/themes/-/themes-3.21.0.tgz", + "integrity": "sha512-BAE4cr9EDiZyYzwIHEk7JTBJ9CzlPuM4PchfcA5ao1dWXb25nv6hYsoDiBq2aZK9E3dlt3WB78uI96UESD+8Mw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@shikijs/types": "3.21.0" + } + }, + "node_modules/@shikijs/transformers": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/@shikijs/transformers/-/transformers-2.5.0.tgz", + "integrity": "sha512-SI494W5X60CaUwgi8u4q4m4s3YAFSxln3tzNjOSYqq54wlVgz0/NbbXEb3mdLbqMBztcmS7bVTaEd2w0qMmfeg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@shikijs/core": "2.5.0", + "@shikijs/types": "2.5.0" + } + }, + "node_modules/@shikijs/transformers/node_modules/@shikijs/core": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/@shikijs/core/-/core-2.5.0.tgz", + "integrity": "sha512-uu/8RExTKtavlpH7XqnVYBrfBkUc20ngXiX9NSrBhOVZYv/7XQRKUyhtkeflY5QsxC0GbJThCerruZfsUaSldg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@shikijs/engine-javascript": "2.5.0", + "@shikijs/engine-oniguruma": "2.5.0", + "@shikijs/types": "2.5.0", + "@shikijs/vscode-textmate": "^10.0.2", + "@types/hast": "^3.0.4", + "hast-util-to-html": "^9.0.4" + } + }, + "node_modules/@shikijs/transformers/node_modules/@shikijs/engine-javascript": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/@shikijs/engine-javascript/-/engine-javascript-2.5.0.tgz", + "integrity": "sha512-VjnOpnQf8WuCEZtNUdjjwGUbtAVKuZkVQ/5cHy/tojVVRIRtlWMYVjyWhxOmIq05AlSOv72z7hRNRGVBgQOl0w==", + "dev": true, + "license": "MIT", + "dependencies": { + "@shikijs/types": "2.5.0", + "@shikijs/vscode-textmate": "^10.0.2", + "oniguruma-to-es": "^3.1.0" + } + }, + "node_modules/@shikijs/transformers/node_modules/@shikijs/engine-oniguruma": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/@shikijs/engine-oniguruma/-/engine-oniguruma-2.5.0.tgz", + "integrity": "sha512-pGd1wRATzbo/uatrCIILlAdFVKdxImWJGQ5rFiB5VZi2ve5xj3Ax9jny8QvkaV93btQEwR/rSz5ERFpC5mKNIw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@shikijs/types": "2.5.0", + "@shikijs/vscode-textmate": "^10.0.2" + } + }, + "node_modules/@shikijs/transformers/node_modules/@shikijs/types": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/@shikijs/types/-/types-2.5.0.tgz", + "integrity": "sha512-ygl5yhxki9ZLNuNpPitBWvcy9fsSKKaRuO4BAlMyagszQidxcpLAr0qiW/q43DtSIDxO6hEbtYLiFZNXO/hdGw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@shikijs/vscode-textmate": "^10.0.2", + "@types/hast": "^3.0.4" + } + }, + "node_modules/@shikijs/transformers/node_modules/oniguruma-to-es": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/oniguruma-to-es/-/oniguruma-to-es-3.1.1.tgz", + "integrity": "sha512-bUH8SDvPkH3ho3dvwJwfonjlQ4R80vjyvrU8YpxuROddv55vAEJrTuCuCVUhhsHbtlD9tGGbaNApGQckXhS8iQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "emoji-regex-xs": "^1.0.0", + "regex": "^6.0.1", + "regex-recursion": "^6.0.2" + } + }, + "node_modules/@shikijs/twoslash": { + "version": "3.21.0", + "resolved": "https://registry.npmjs.org/@shikijs/twoslash/-/twoslash-3.21.0.tgz", + "integrity": "sha512-iH360udAYON2JwfIldoCiMZr9MljuQA5QRBivKLpEuEpmVCSwrR+0WTQ0eS1ptgGBdH9weFiIsA5wJDzsEzTYg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@shikijs/core": "3.21.0", + "@shikijs/types": "3.21.0", + "twoslash": "^0.3.6" + }, + "peerDependencies": { + "typescript": ">=5.5.0" + } + }, + "node_modules/@shikijs/types": { + "version": "3.21.0", + "resolved": "https://registry.npmjs.org/@shikijs/types/-/types-3.21.0.tgz", + "integrity": "sha512-zGrWOxZ0/+0ovPY7PvBU2gIS9tmhSUUt30jAcNV0Bq0gb2S98gwfjIs1vxlmH5zM7/4YxLamT6ChlqqAJmPPjA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@shikijs/vscode-textmate": "^10.0.2", + "@types/hast": "^3.0.4" + } + }, + "node_modules/@shikijs/vitepress-twoslash": { + "version": "3.21.0", + "resolved": "https://registry.npmjs.org/@shikijs/vitepress-twoslash/-/vitepress-twoslash-3.21.0.tgz", + "integrity": "sha512-R9qylCClKnLlPlWloY9SGdvr5X6smanxdPq7O1bxe7SL89j4/v9fMUUAWM6yPHf4jmGZuRGm/9IFRBdaAmm5Rw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@shikijs/twoslash": "3.21.0", + "floating-vue": "^5.2.2", + "lz-string": "^1.5.0", + "magic-string": "^0.30.21", + "markdown-it": "^14.1.0", + "mdast-util-from-markdown": "^2.0.2", + "mdast-util-gfm": "^3.1.0", + "mdast-util-to-hast": "^13.2.1", + "ohash": "^2.0.11", + "shiki": "3.21.0", + "twoslash": "^0.3.6", + "twoslash-vue": "^0.3.6", + "vue": "^3.5.26" + } + }, + "node_modules/@shikijs/vscode-textmate": { + "version": "10.0.2", + "resolved": "https://registry.npmjs.org/@shikijs/vscode-textmate/-/vscode-textmate-10.0.2.tgz", + "integrity": "sha512-83yeghZ2xxin3Nj8z1NMd/NCuca+gsYXswywDy5bHvwlWL8tpTQmzGeUuHd9FC3E/SBEMvzJRwWEOz5gGes9Qg==", + "dev": true, + "license": "MIT" + }, + "node_modules/@swc/helpers": { + "version": "0.5.18", + "resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.5.18.tgz", + "integrity": "sha512-TXTnIcNJQEKwThMMqBXsZ4VGAza6bvN4pa41Rkqoio6QBKMvo+5lexeTMScGCIxtzgQJzElcvIltani+adC5PQ==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "tslib": "^2.8.0" + } + }, + "node_modules/@tanstack/react-virtual": { + "version": "3.13.18", + "resolved": "https://registry.npmjs.org/@tanstack/react-virtual/-/react-virtual-3.13.18.tgz", + "integrity": "sha512-dZkhyfahpvlaV0rIKnvQiVoWPyURppl6w4m9IwMDpuIjcJ1sD9YGWrt0wISvgU7ewACXx2Ct46WPgI6qAD4v6A==", + "dev": true, + "license": "MIT", + "dependencies": { + "@tanstack/virtual-core": "3.13.18" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/tannerlinsley" + }, + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0", + "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0" + } + }, + "node_modules/@tanstack/virtual-core": { + "version": "3.13.18", + "resolved": "https://registry.npmjs.org/@tanstack/virtual-core/-/virtual-core-3.13.18.tgz", + "integrity": "sha512-Mx86Hqu1k39icq2Zusq+Ey2J6dDWTjDvEv43PJtRCoEYTLyfaPnxIQ6iy7YAOK0NV/qOEmZQ/uCufrppZxTgcg==", + "dev": true, + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/tannerlinsley" + } + }, + "node_modules/@tootallnate/quickjs-emscripten": { + "version": "0.23.0", + "resolved": "https://registry.npmjs.org/@tootallnate/quickjs-emscripten/-/quickjs-emscripten-0.23.0.tgz", + "integrity": "sha512-C5Mc6rdnsaJDjO3UpGW/CQTHtCKaYlScZTly4JIu97Jxo/odCiH0ITnDXSJPTOrEKk/ycSZ0AOgTmkDtkOsvIA==", + "dev": true, + "license": "MIT" + }, + "node_modules/@tybys/wasm-util": { + "version": "0.10.1", + "resolved": "https://registry.npmjs.org/@tybys/wasm-util/-/wasm-util-0.10.1.tgz", + "integrity": "sha512-9tTaPJLSiejZKx+Bmog4uSubteqTvFrVrURwkmHixBo0G4seD0zUxp98E1DzUBJxLQ3NPwXrGKDiVjwx/DpPsg==", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "tslib": "^2.4.0" + } + }, + "node_modules/@types/buble": { + "version": "0.19.2", + "resolved": "https://registry.npmjs.org/@types/buble/-/buble-0.19.2.tgz", + "integrity": "sha512-uUD8zIfXMKThmFkahTXDGI3CthFH1kMg2dOm3KLi4GlC5cbARA64bEcUMbbWdWdE73eoc/iBB9PiTMqH0dNS2Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "magic-string": "^0.25.0" + } + }, + "node_modules/@types/buble/node_modules/magic-string": { + "version": "0.25.9", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.25.9.tgz", + "integrity": "sha512-RmF0AsMzgt25qzqqLc1+MbHmhdx0ojF2Fvs4XnOqz2ZOBXzzkEwc/dJQZCYHAn7v1jbVOjAZfK8msRn4BxO4VQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "sourcemap-codec": "^1.4.8" + } + }, + "node_modules/@types/d3": { + "version": "7.4.3", + "resolved": "https://registry.npmjs.org/@types/d3/-/d3-7.4.3.tgz", + "integrity": "sha512-lZXZ9ckh5R8uiFVt8ogUNf+pIrK4EsWrx2Np75WvF/eTpJ0FMHNhjXk8CKEx/+gpHbNQyJWehbFaTvqmHWB3ww==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/d3-array": "*", + "@types/d3-axis": "*", + "@types/d3-brush": "*", + "@types/d3-chord": "*", + "@types/d3-color": "*", + "@types/d3-contour": "*", + "@types/d3-delaunay": "*", + "@types/d3-dispatch": "*", + "@types/d3-drag": "*", + "@types/d3-dsv": "*", + "@types/d3-ease": "*", + "@types/d3-fetch": "*", + "@types/d3-force": "*", + "@types/d3-format": "*", + "@types/d3-geo": "*", + "@types/d3-hierarchy": "*", + "@types/d3-interpolate": "*", + "@types/d3-path": "*", + "@types/d3-polygon": "*", + "@types/d3-quadtree": "*", + "@types/d3-random": "*", + "@types/d3-scale": "*", + "@types/d3-scale-chromatic": "*", + "@types/d3-selection": "*", + "@types/d3-shape": "*", + "@types/d3-time": "*", + "@types/d3-time-format": "*", + "@types/d3-timer": "*", + "@types/d3-transition": "*", + "@types/d3-zoom": "*" + } + }, + "node_modules/@types/d3-array": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/@types/d3-array/-/d3-array-3.2.2.tgz", + "integrity": "sha512-hOLWVbm7uRza0BYXpIIW5pxfrKe0W+D5lrFiAEYR+pb6w3N2SwSMaJbXdUfSEv+dT4MfHBLtn5js0LAWaO6otw==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/d3-axis": { + "version": "3.0.6", + "resolved": "https://registry.npmjs.org/@types/d3-axis/-/d3-axis-3.0.6.tgz", + "integrity": "sha512-pYeijfZuBd87T0hGn0FO1vQ/cgLk6E1ALJjfkC0oJ8cbwkZl3TpgS8bVBLZN+2jjGgg38epgxb2zmoGtSfvgMw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/d3-selection": "*" + } + }, + "node_modules/@types/d3-brush": { + "version": "3.0.6", + "resolved": "https://registry.npmjs.org/@types/d3-brush/-/d3-brush-3.0.6.tgz", + "integrity": "sha512-nH60IZNNxEcrh6L1ZSMNA28rj27ut/2ZmI3r96Zd+1jrZD++zD3LsMIjWlvg4AYrHn/Pqz4CF3veCxGjtbqt7A==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/d3-selection": "*" + } + }, + "node_modules/@types/d3-chord": { + "version": "3.0.6", + "resolved": "https://registry.npmjs.org/@types/d3-chord/-/d3-chord-3.0.6.tgz", + "integrity": "sha512-LFYWWd8nwfwEmTZG9PfQxd17HbNPksHBiJHaKuY1XeqscXacsS2tyoo6OdRsjf+NQYeB6XrNL3a25E3gH69lcg==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/d3-color": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/@types/d3-color/-/d3-color-3.1.3.tgz", + "integrity": "sha512-iO90scth9WAbmgv7ogoq57O9YpKmFBbmoEoCHDB2xMBY0+/KVrqAaCDyCE16dUspeOvIxFFRI+0sEtqDqy2b4A==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/d3-contour": { + "version": "3.0.6", + "resolved": "https://registry.npmjs.org/@types/d3-contour/-/d3-contour-3.0.6.tgz", + "integrity": "sha512-BjzLgXGnCWjUSYGfH1cpdo41/hgdWETu4YxpezoztawmqsvCeep+8QGfiY6YbDvfgHz/DkjeIkkZVJavB4a3rg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/d3-array": "*", + "@types/geojson": "*" + } + }, + "node_modules/@types/d3-delaunay": { + "version": "6.0.4", + "resolved": "https://registry.npmjs.org/@types/d3-delaunay/-/d3-delaunay-6.0.4.tgz", + "integrity": "sha512-ZMaSKu4THYCU6sV64Lhg6qjf1orxBthaC161plr5KuPHo3CNm8DTHiLw/5Eq2b6TsNP0W0iJrUOFscY6Q450Hw==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/d3-dispatch": { + "version": "3.0.7", + "resolved": "https://registry.npmjs.org/@types/d3-dispatch/-/d3-dispatch-3.0.7.tgz", + "integrity": "sha512-5o9OIAdKkhN1QItV2oqaE5KMIiXAvDWBDPrD85e58Qlz1c1kI/J0NcqbEG88CoTwJrYe7ntUCVfeUl2UJKbWgA==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/d3-drag": { + "version": "3.0.7", + "resolved": "https://registry.npmjs.org/@types/d3-drag/-/d3-drag-3.0.7.tgz", + "integrity": "sha512-HE3jVKlzU9AaMazNufooRJ5ZpWmLIoc90A37WU2JMmeq28w1FQqCZswHZ3xR+SuxYftzHq6WU6KJHvqxKzTxxQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/d3-selection": "*" + } + }, + "node_modules/@types/d3-dsv": { + "version": "3.0.7", + "resolved": "https://registry.npmjs.org/@types/d3-dsv/-/d3-dsv-3.0.7.tgz", + "integrity": "sha512-n6QBF9/+XASqcKK6waudgL0pf/S5XHPPI8APyMLLUHd8NqouBGLsU8MgtO7NINGtPBtk9Kko/W4ea0oAspwh9g==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/d3-ease": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/@types/d3-ease/-/d3-ease-3.0.2.tgz", + "integrity": "sha512-NcV1JjO5oDzoK26oMzbILE6HW7uVXOHLQvHshBUW4UMdZGfiY6v5BeQwh9a9tCzv+CeefZQHJt5SRgK154RtiA==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/d3-fetch": { + "version": "3.0.7", + "resolved": "https://registry.npmjs.org/@types/d3-fetch/-/d3-fetch-3.0.7.tgz", + "integrity": "sha512-fTAfNmxSb9SOWNB9IoG5c8Hg6R+AzUHDRlsXsDZsNp6sxAEOP0tkP3gKkNSO/qmHPoBFTxNrjDprVHDQDvo5aA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/d3-dsv": "*" + } + }, + "node_modules/@types/d3-force": { + "version": "3.0.10", + "resolved": "https://registry.npmjs.org/@types/d3-force/-/d3-force-3.0.10.tgz", + "integrity": "sha512-ZYeSaCF3p73RdOKcjj+swRlZfnYpK1EbaDiYICEEp5Q6sUiqFaFQ9qgoshp5CzIyyb/yD09kD9o2zEltCexlgw==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/d3-format": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/@types/d3-format/-/d3-format-3.0.4.tgz", + "integrity": "sha512-fALi2aI6shfg7vM5KiR1wNJnZ7r6UuggVqtDA+xiEdPZQwy/trcQaHnwShLuLdta2rTymCNpxYTiMZX/e09F4g==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/d3-geo": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@types/d3-geo/-/d3-geo-3.1.0.tgz", + "integrity": "sha512-856sckF0oP/diXtS4jNsiQw/UuK5fQG8l/a9VVLeSouf1/PPbBE1i1W852zVwKwYCBkFJJB7nCFTbk6UMEXBOQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/geojson": "*" + } + }, + "node_modules/@types/d3-hierarchy": { + "version": "3.1.7", + "resolved": "https://registry.npmjs.org/@types/d3-hierarchy/-/d3-hierarchy-3.1.7.tgz", + "integrity": "sha512-tJFtNoYBtRtkNysX1Xq4sxtjK8YgoWUNpIiUee0/jHGRwqvzYxkq0hGVbbOGSz+JgFxxRu4K8nb3YpG3CMARtg==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/d3-interpolate": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/@types/d3-interpolate/-/d3-interpolate-3.0.4.tgz", + "integrity": "sha512-mgLPETlrpVV1YRJIglr4Ez47g7Yxjl1lj7YKsiMCb27VJH9W8NVM6Bb9d8kkpG/uAQS5AmbA48q2IAolKKo1MA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/d3-color": "*" + } + }, + "node_modules/@types/d3-path": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/@types/d3-path/-/d3-path-3.1.1.tgz", + "integrity": "sha512-VMZBYyQvbGmWyWVea0EHs/BwLgxc+MKi1zLDCONksozI4YJMcTt8ZEuIR4Sb1MMTE8MMW49v0IwI5+b7RmfWlg==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/d3-polygon": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/@types/d3-polygon/-/d3-polygon-3.0.2.tgz", + "integrity": "sha512-ZuWOtMaHCkN9xoeEMr1ubW2nGWsp4nIql+OPQRstu4ypeZ+zk3YKqQT0CXVe/PYqrKpZAi+J9mTs05TKwjXSRA==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/d3-quadtree": { + "version": "3.0.6", + "resolved": "https://registry.npmjs.org/@types/d3-quadtree/-/d3-quadtree-3.0.6.tgz", + "integrity": "sha512-oUzyO1/Zm6rsxKRHA1vH0NEDG58HrT5icx/azi9MF1TWdtttWl0UIUsjEQBBh+SIkrpd21ZjEv7ptxWys1ncsg==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/d3-random": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/@types/d3-random/-/d3-random-3.0.3.tgz", + "integrity": "sha512-Imagg1vJ3y76Y2ea0871wpabqp613+8/r0mCLEBfdtqC7xMSfj9idOnmBYyMoULfHePJyxMAw3nWhJxzc+LFwQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/d3-scale": { + "version": "4.0.9", + "resolved": "https://registry.npmjs.org/@types/d3-scale/-/d3-scale-4.0.9.tgz", + "integrity": "sha512-dLmtwB8zkAeO/juAMfnV+sItKjlsw2lKdZVVy6LRr0cBmegxSABiLEpGVmSJJ8O08i4+sGR6qQtb6WtuwJdvVw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/d3-time": "*" + } + }, + "node_modules/@types/d3-scale-chromatic": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@types/d3-scale-chromatic/-/d3-scale-chromatic-3.1.0.tgz", + "integrity": "sha512-iWMJgwkK7yTRmWqRB5plb1kadXyQ5Sj8V/zYlFGMUBbIPKQScw+Dku9cAAMgJG+z5GYDoMjWGLVOvjghDEFnKQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/d3-selection": { + "version": "3.0.11", + "resolved": "https://registry.npmjs.org/@types/d3-selection/-/d3-selection-3.0.11.tgz", + "integrity": "sha512-bhAXu23DJWsrI45xafYpkQ4NtcKMwWnAC/vKrd2l+nxMFuvOT3XMYTIj2opv8vq8AO5Yh7Qac/nSeP/3zjTK0w==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/d3-shape": { + "version": "3.1.8", + "resolved": "https://registry.npmjs.org/@types/d3-shape/-/d3-shape-3.1.8.tgz", + "integrity": "sha512-lae0iWfcDeR7qt7rA88BNiqdvPS5pFVPpo5OfjElwNaT2yyekbM0C9vK+yqBqEmHr6lDkRnYNoTBYlAgJa7a4w==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/d3-path": "*" + } + }, + "node_modules/@types/d3-time": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/@types/d3-time/-/d3-time-3.0.4.tgz", + "integrity": "sha512-yuzZug1nkAAaBlBBikKZTgzCeA+k1uy4ZFwWANOfKw5z5LRhV0gNA7gNkKm7HoK+HRN0wX3EkxGk0fpbWhmB7g==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/d3-time-format": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/@types/d3-time-format/-/d3-time-format-4.0.3.tgz", + "integrity": "sha512-5xg9rC+wWL8kdDj153qZcsJ0FWiFt0J5RB6LYUNZjwSnesfblqrI/bJ1wBdJ8OQfncgbJG5+2F+qfqnqyzYxyg==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/d3-timer": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/@types/d3-timer/-/d3-timer-3.0.2.tgz", + "integrity": "sha512-Ps3T8E8dZDam6fUyNiMkekK3XUsaUEik+idO9/YjPtfj2qruF8tFBXS7XhtE4iIXBLxhmLjP3SXpLhVf21I9Lw==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/d3-transition": { + "version": "3.0.9", + "resolved": "https://registry.npmjs.org/@types/d3-transition/-/d3-transition-3.0.9.tgz", + "integrity": "sha512-uZS5shfxzO3rGlu0cC3bjmMFKsXv+SmZZcgp0KD22ts4uGXp5EVYGzu/0YdwZeKmddhcAccYtREJKkPfXkZuCg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/d3-selection": "*" + } + }, + "node_modules/@types/d3-zoom": { + "version": "3.0.8", + "resolved": "https://registry.npmjs.org/@types/d3-zoom/-/d3-zoom-3.0.8.tgz", + "integrity": "sha512-iqMC4/YlFCSlO8+2Ii1GGGliCAY4XdeG748w5vQUbevlbDu0zSjH/+jojorQVBK/se0j6DUFNPBGSqD3YWYnDw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/d3-interpolate": "*", + "@types/d3-selection": "*" + } + }, + "node_modules/@types/debug": { + "version": "4.1.12", + "resolved": "https://registry.npmjs.org/@types/debug/-/debug-4.1.12.tgz", + "integrity": "sha512-vIChWdVG3LG1SMxEvI/AK+FWJthlrqlTu7fbrlywTkkaONwk/UAGaULXRlf8vkzFBLVm0zkMdCquhL5aOjhXPQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/ms": "*" + } + }, + "node_modules/@types/estree": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.8.tgz", + "integrity": "sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w==", + "license": "MIT" + }, + "node_modules/@types/fs-extra": { + "version": "9.0.13", + "resolved": "https://registry.npmjs.org/@types/fs-extra/-/fs-extra-9.0.13.tgz", + "integrity": "sha512-nEnwB++1u5lVDM2UI4c1+5R+FYaKfaAzS4OococimjVm3nQw3TuzH5UNsocrcTBbhnerblyHj4A49qXbIiZdpA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/@types/geojson": { + "version": "7946.0.16", + "resolved": "https://registry.npmjs.org/@types/geojson/-/geojson-7946.0.16.tgz", + "integrity": "sha512-6C8nqWur3j98U6+lXDfTUWIfgvZU+EumvpHKcYjujKH7woYyLj2sUmff0tRhrqM7BohUw7Pz3ZB1jj2gW9Fvmg==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/glob": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/@types/glob/-/glob-8.1.0.tgz", + "integrity": "sha512-IO+MJPVhoqz+28h1qLAcBEH2+xHMK6MTyHJc7MTnnYb6wsoLR29POVGJ7LycmVXIqyy/4/2ShP5sUwTXuOwb/w==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/minimatch": "^5.1.2", + "@types/node": "*" + } + }, + "node_modules/@types/glob/node_modules/@types/minimatch": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/@types/minimatch/-/minimatch-5.1.2.tgz", + "integrity": "sha512-K0VQKziLUWkVKiRVrx4a40iPaxTUefQmjtkQofBkYRcoaaL/8rhwDWww9qWbrgicNOgnpIsMxyNIUM4+n6dUIA==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/hast": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/@types/hast/-/hast-3.0.4.tgz", + "integrity": "sha512-WPs+bbQw5aCj+x6laNGWLH3wviHtoCv/P3+otBhbOhJgG8qtpdAMlTCxLtsTWA7LH1Oh/bFCHsBn0TPS5m30EQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/unist": "*" + } + }, + "node_modules/@types/json-schema": { + "version": "7.0.15", + "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz", + "integrity": "sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/linkify-it": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/@types/linkify-it/-/linkify-it-5.0.0.tgz", + "integrity": "sha512-sVDA58zAw4eWAffKOaQH5/5j3XeayukzDk+ewSsnv3p4yJEZHCCzMDiZM8e0OUrRvmpGZ85jf4yDHkHsgBNr9Q==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/markdown-it": { + "version": "14.1.2", + "resolved": "https://registry.npmjs.org/@types/markdown-it/-/markdown-it-14.1.2.tgz", + "integrity": "sha512-promo4eFwuiW+TfGxhi+0x3czqTYJkG8qB17ZUJiVF10Xm7NLVRSLUsfRTU/6h1e24VvRnXCx+hG7li58lkzog==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/linkify-it": "^5", + "@types/mdurl": "^2" + } + }, + "node_modules/@types/mdast": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/@types/mdast/-/mdast-4.0.4.tgz", + "integrity": "sha512-kGaNbPh1k7AFzgpud/gMdvIm5xuECykRR+JnWKQno9TAXVa6WIVCGTPvYGekIDL4uwCZQSYbUxNBSb1aUo79oA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/unist": "*" + } + }, + "node_modules/@types/mdurl": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@types/mdurl/-/mdurl-2.0.0.tgz", + "integrity": "sha512-RGdgjQUZba5p6QEFAVx2OGb8rQDL/cPRG7GiedRzMcJ1tYnUANBncjbSB1NRGwbvjcPeikRABz2nshyPk1bhWg==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/minimatch": { + "version": "3.0.5", + "resolved": "https://registry.npmjs.org/@types/minimatch/-/minimatch-3.0.5.tgz", + "integrity": "sha512-Klz949h02Gz2uZCMGwDUSDS1YBlTdDDgbWHi+81l29tQALUtvz4rAYi5uoVhE5Lagoq6DeqAUlbrHvW/mXDgdQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/mocha": { + "version": "10.0.10", + "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-10.0.10.tgz", + "integrity": "sha512-xPyYSz1cMPnJQhl0CLMH68j3gprKZaTjG3s5Vi+fDgx+uhG9NOXwbVt52eFS8ECyXhyKcjDLCBEqBExKuiZb7Q==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/ms": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/@types/ms/-/ms-2.1.0.tgz", + "integrity": "sha512-GsCCIZDE/p3i96vtEqx+7dBUGXrc7zeSK3wwPHIaRThS+9OhWIXRqzs4d6k1SVU8g91DrNRWxWUGhp5KXQb2VA==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/node": { + "version": "20.19.30", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.19.30.tgz", + "integrity": "sha512-WJtwWJu7UdlvzEAUm484QNg5eAoq5QR08KDNx7g45Usrs2NtOPiX8ugDqmKdXkyL03rBqU5dYNYVQetEpBHq2g==", + "dev": true, + "license": "MIT", + "dependencies": { + "undici-types": "~6.21.0" + } + }, + "node_modules/@types/picomatch": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/@types/picomatch/-/picomatch-4.0.2.tgz", + "integrity": "sha512-qHHxQ+P9PysNEGbALT8f8YOSHW0KJu6l2xU8DYY0fu/EmGxXdVnuTLvFUvBgPJMSqXq29SYHveejeAha+4AYgA==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/resolve": { + "version": "1.20.2", + "resolved": "https://registry.npmjs.org/@types/resolve/-/resolve-1.20.2.tgz", + "integrity": "sha512-60BCwRFOZCQhDncwQdxxeOEEkbc5dIMccYLwbxsS4TUNeVECQ/pBJ0j09mrHOl/JJvpRPGwO9SvE4nR2Nb/a4Q==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/rimraf": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/@types/rimraf/-/rimraf-3.0.2.tgz", + "integrity": "sha512-F3OznnSLAUxFrCEu/L5PY8+ny8DtcFRjx7fZZ9bycvXRi3KPTRS9HOitGZwvPg0juRhXFWIeKX58cnX5YqLohQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/glob": "*", + "@types/node": "*" + } + }, + "node_modules/@types/semver": { + "version": "7.7.1", + "resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.7.1.tgz", + "integrity": "sha512-FmgJfu+MOcQ370SD0ev7EI8TlCAfKYU+B4m5T3yXc1CiRN94g/SZPtsCkk506aUDtlMnFZvasDwHHUcZUEaYuA==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/trusted-types": { + "version": "2.0.7", + "resolved": "https://registry.npmjs.org/@types/trusted-types/-/trusted-types-2.0.7.tgz", + "integrity": "sha512-ScaPdn1dQczgbl0QFTeTOmVHFULt394XJgOQNoyVhZ6r2vLnMLJfBPd53SB52T/3G36VI1/g2MZaX0cwDuXsfw==", + "dev": true, + "license": "MIT", + "optional": true + }, + "node_modules/@types/unist": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/@types/unist/-/unist-3.0.3.tgz", + "integrity": "sha512-ko/gIFJRv177XgZsZcBwnqJN5x/Gien8qNOn0D5bQU/zAzVf9Zt3BlcUiLqhV9y4ARk0GbT3tnUiPNgnTXzc/Q==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/web-bluetooth": { + "version": "0.0.21", + "resolved": "https://registry.npmjs.org/@types/web-bluetooth/-/web-bluetooth-0.0.21.tgz", + "integrity": "sha512-oIQLCGWtcFZy2JW77j9k8nHzAOpqMHLQejDA48XXMWH6tjCQHz5RCFz1bzsmROyL6PUm+LLnUiI4BCn221inxA==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/yargs-parser": { + "version": "21.0.3", + "resolved": "https://registry.npmjs.org/@types/yargs-parser/-/yargs-parser-21.0.3.tgz", + "integrity": "sha512-I4q9QU9MQv4oEOz4tAHJtNz1cwuLxn2F3xcc2iV5WdqLPpUnj30aUuxt1mAxYTG+oe8CZMV/+6rU4S4gRDzqtQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/yauzl": { + "version": "2.10.3", + "resolved": "https://registry.npmjs.org/@types/yauzl/-/yauzl-2.10.3.tgz", + "integrity": "sha512-oJoftv0LSuaDZE3Le4DbKX+KS9G36NzOeSap90UIK0yMA/NhKJhqlSGtNDORNRaIbQfzjXDrQa0ytJ6mNRGz/Q==", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/@typescript-eslint/eslint-plugin": { + "version": "8.53.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.53.0.tgz", + "integrity": "sha512-eEXsVvLPu8Z4PkFibtuFJLJOTAV/nPdgtSjkGoPpddpFk3/ym2oy97jynY6ic2m6+nc5M8SE1e9v/mHKsulcJg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@eslint-community/regexpp": "^4.12.2", + "@typescript-eslint/scope-manager": "8.53.0", + "@typescript-eslint/type-utils": "8.53.0", + "@typescript-eslint/utils": "8.53.0", + "@typescript-eslint/visitor-keys": "8.53.0", + "ignore": "^7.0.5", + "natural-compare": "^1.4.0", + "ts-api-utils": "^2.4.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "@typescript-eslint/parser": "^8.53.0", + "eslint": "^8.57.0 || ^9.0.0", + "typescript": ">=4.8.4 <6.0.0" + } + }, + "node_modules/@typescript-eslint/eslint-plugin/node_modules/ignore": { + "version": "7.0.5", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-7.0.5.tgz", + "integrity": "sha512-Hs59xBNfUIunMFgWAbGX5cq6893IbWg4KnrjbYwX3tx0ztorVgTDA6B2sxf8ejHJ4wz8BqGUMYlnzNBer5NvGg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 4" + } + }, + "node_modules/@typescript-eslint/parser": { + "version": "8.53.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.53.0.tgz", + "integrity": "sha512-npiaib8XzbjtzS2N4HlqPvlpxpmZ14FjSJrteZpPxGUaYPlvhzlzUZ4mZyABo0EFrOWnvyd0Xxroq//hKhtAWg==", + "dev": true, + "license": "MIT", + "peer": true, + "dependencies": { + "@typescript-eslint/scope-manager": "8.53.0", + "@typescript-eslint/types": "8.53.0", + "@typescript-eslint/typescript-estree": "8.53.0", + "@typescript-eslint/visitor-keys": "8.53.0", + "debug": "^4.4.3" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^8.57.0 || ^9.0.0", + "typescript": ">=4.8.4 <6.0.0" + } + }, + "node_modules/@typescript-eslint/project-service": { + "version": "8.53.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/project-service/-/project-service-8.53.0.tgz", + "integrity": "sha512-Bl6Gdr7NqkqIP5yP9z1JU///Nmes4Eose6L1HwpuVHwScgDPPuEWbUVhvlZmb8hy0vX9syLk5EGNL700WcBlbg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/tsconfig-utils": "^8.53.0", + "@typescript-eslint/types": "^8.53.0", + "debug": "^4.4.3" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "typescript": ">=4.8.4 <6.0.0" + } + }, + "node_modules/@typescript-eslint/scope-manager": { + "version": "8.53.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.53.0.tgz", + "integrity": "sha512-kWNj3l01eOGSdVBnfAF2K1BTh06WS0Yet6JUgb9Cmkqaz3Jlu0fdVUjj9UI8gPidBWSMqDIglmEXifSgDT/D0g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/types": "8.53.0", + "@typescript-eslint/visitor-keys": "8.53.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/tsconfig-utils": { + "version": "8.53.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/tsconfig-utils/-/tsconfig-utils-8.53.0.tgz", + "integrity": "sha512-K6Sc0R5GIG6dNoPdOooQ+KtvT5KCKAvTcY8h2rIuul19vxH5OTQk7ArKkd4yTzkw66WnNY0kPPzzcmWA+XRmiA==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "typescript": ">=4.8.4 <6.0.0" + } + }, + "node_modules/@typescript-eslint/type-utils": { + "version": "8.53.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.53.0.tgz", + "integrity": "sha512-BBAUhlx7g4SmcLhn8cnbxoxtmS7hcq39xKCgiutL3oNx1TaIp+cny51s8ewnKMpVUKQUGb41RAUWZ9kxYdovuw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/types": "8.53.0", + "@typescript-eslint/typescript-estree": "8.53.0", + "@typescript-eslint/utils": "8.53.0", + "debug": "^4.4.3", + "ts-api-utils": "^2.4.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^8.57.0 || ^9.0.0", + "typescript": ">=4.8.4 <6.0.0" + } + }, + "node_modules/@typescript-eslint/types": { + "version": "8.53.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.53.0.tgz", + "integrity": "sha512-Bmh9KX31Vlxa13+PqPvt4RzKRN1XORYSLlAE+sO1i28NkisGbTtSLFVB3l7PWdHtR3E0mVMuC7JilWJ99m2HxQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/typescript-estree": { + "version": "8.53.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.53.0.tgz", + "integrity": "sha512-pw0c0Gdo7Z4xOG987u3nJ8akL9093yEEKv8QTJ+Bhkghj1xyj8cgPaavlr9rq8h7+s6plUJ4QJYw2gCZodqmGw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/project-service": "8.53.0", + "@typescript-eslint/tsconfig-utils": "8.53.0", + "@typescript-eslint/types": "8.53.0", + "@typescript-eslint/visitor-keys": "8.53.0", + "debug": "^4.4.3", + "minimatch": "^9.0.5", + "semver": "^7.7.3", + "tinyglobby": "^0.2.15", + "ts-api-utils": "^2.4.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "typescript": ">=4.8.4 <6.0.0" + } + }, + "node_modules/@typescript-eslint/typescript-estree/node_modules/brace-expansion": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.2.tgz", + "integrity": "sha512-Jt0vHyM+jmUBqojB7E1NIYadt0vI0Qxjxd2TErW94wDz+E2LAm5vKMXXwg6ZZBTHPuUlDgQHKXvjGBdfcF1ZDQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "node_modules/@typescript-eslint/typescript-estree/node_modules/minimatch": { + "version": "9.0.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", + "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/@typescript-eslint/utils": { + "version": "8.53.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.53.0.tgz", + "integrity": "sha512-XDY4mXTez3Z1iRDI5mbRhH4DFSt46oaIFsLg+Zn97+sYrXACziXSQcSelMybnVZ5pa1P6xYkPr5cMJyunM1ZDA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@eslint-community/eslint-utils": "^4.9.1", + "@typescript-eslint/scope-manager": "8.53.0", + "@typescript-eslint/types": "8.53.0", + "@typescript-eslint/typescript-estree": "8.53.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^8.57.0 || ^9.0.0", + "typescript": ">=4.8.4 <6.0.0" + } + }, + "node_modules/@typescript-eslint/visitor-keys": { + "version": "8.53.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.53.0.tgz", + "integrity": "sha512-LZ2NqIHFhvFwxG0qZeLL9DvdNAHPGCY5dIRwBhyYeU+LfLhcStE1ImjsuTG/WaVh3XysGaeLW8Rqq7cGkPCFvw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/types": "8.53.0", + "eslint-visitor-keys": "^4.2.1" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript/vfs": { + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/@typescript/vfs/-/vfs-1.6.2.tgz", + "integrity": "sha512-hoBwJwcbKHmvd2QVebiytN1aELvpk9B74B4L1mFm/XT1Q/VOYAWl2vQ9AWRFtQq8zmz6enTpfTV8WRc4ATjW/g==", + "dev": true, + "license": "MIT", + "dependencies": { + "debug": "^4.1.1" + }, + "peerDependencies": { + "typescript": "*" + } + }, + "node_modules/@ungap/structured-clone": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/@ungap/structured-clone/-/structured-clone-1.3.0.tgz", + "integrity": "sha512-WmoN8qaIAo7WTYWbAZuG8PYEhn5fkz7dZrqTBZ7dtt//lL2Gwms1IcnQ5yHqjDfX8Ft5j4YzDM23f87zBfDe9g==", + "dev": true, + "license": "ISC" + }, + "node_modules/@vitejs/plugin-vue": { + "version": "5.2.4", + "resolved": "https://registry.npmjs.org/@vitejs/plugin-vue/-/plugin-vue-5.2.4.tgz", + "integrity": "sha512-7Yx/SXSOcQq5HiiV3orevHUFn+pmMB4cgbEkDYgnkUWb0WfeQ/wa2yFv6D5ICiCQOVpjA7vYDXrC7AGO8yjDHA==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^18.0.0 || >=20.0.0" + }, + "peerDependencies": { + "vite": "^5.0.0 || ^6.0.0", + "vue": "^3.2.25" + } + }, + "node_modules/@volar/language-core": { + "version": "2.4.27", + "resolved": "https://registry.npmjs.org/@volar/language-core/-/language-core-2.4.27.tgz", + "integrity": "sha512-DjmjBWZ4tJKxfNC1F6HyYERNHPYS7L7OPFyCrestykNdUZMFYzI9WTyvwPcaNaHlrEUwESHYsfEw3isInncZxQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@volar/source-map": "2.4.27" + } + }, + "node_modules/@volar/language-server": { + "version": "2.4.27", + "resolved": "https://registry.npmjs.org/@volar/language-server/-/language-server-2.4.27.tgz", + "integrity": "sha512-SymGNkErcHg8GjiG65iQN8sLkhqu1pwKhFySmxeBuYq5xFYagKBW36eiNITXQTdvT0tutI1GXcXdq/FdE/IyjA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@volar/language-core": "2.4.27", + "@volar/language-service": "2.4.27", + "@volar/typescript": "2.4.27", + "path-browserify": "^1.0.1", + "request-light": "^0.7.0", + "vscode-languageserver": "^9.0.1", + "vscode-languageserver-protocol": "^3.17.5", + "vscode-languageserver-textdocument": "^1.0.11", + "vscode-uri": "^3.0.8" + } + }, + "node_modules/@volar/language-service": { + "version": "2.4.27", + "resolved": "https://registry.npmjs.org/@volar/language-service/-/language-service-2.4.27.tgz", + "integrity": "sha512-SxKZ8yLhpWa7Y5e/RDxtNfm7j7xsXp/uf2urijXEffRNpPSmVdfzQrFFy5d7l8PNpZy+bHg+yakmqBPjQN+MOw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@volar/language-core": "2.4.27", + "vscode-languageserver-protocol": "^3.17.5", + "vscode-languageserver-textdocument": "^1.0.11", + "vscode-uri": "^3.0.8" + } + }, + "node_modules/@volar/source-map": { + "version": "2.4.27", + "resolved": "https://registry.npmjs.org/@volar/source-map/-/source-map-2.4.27.tgz", + "integrity": "sha512-ynlcBReMgOZj2i6po+qVswtDUeeBRCTgDurjMGShbm8WYZgJ0PA4RmtebBJ0BCYol1qPv3GQF6jK7C9qoVc7lg==", + "dev": true, + "license": "MIT" + }, + "node_modules/@volar/typescript": { + "version": "2.4.27", + "resolved": "https://registry.npmjs.org/@volar/typescript/-/typescript-2.4.27.tgz", + "integrity": "sha512-eWaYCcl/uAPInSK2Lze6IqVWaBu/itVqR5InXcHXFyles4zO++Mglt3oxdgj75BDcv1Knr9Y93nowS8U3wqhxg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@volar/language-core": "2.4.27", + "path-browserify": "^1.0.1", + "vscode-uri": "^3.0.8" + } + }, + "node_modules/@vscode/emmet-helper": { + "version": "2.11.0", + "resolved": "https://registry.npmjs.org/@vscode/emmet-helper/-/emmet-helper-2.11.0.tgz", + "integrity": "sha512-QLxjQR3imPZPQltfbWRnHU6JecWTF1QSWhx3GAKQpslx7y3Dp6sIIXhKjiUJ/BR9FX8PVthjr9PD6pNwOJfAzw==", + "dev": true, + "license": "MIT", + "dependencies": { + "emmet": "^2.4.3", + "jsonc-parser": "^2.3.0", + "vscode-languageserver-textdocument": "^1.0.1", + "vscode-languageserver-types": "^3.15.1", + "vscode-uri": "^3.0.8" + } + }, + "node_modules/@vscode/l10n": { + "version": "0.0.18", + "resolved": "https://registry.npmjs.org/@vscode/l10n/-/l10n-0.0.18.tgz", + "integrity": "sha512-KYSIHVmslkaCDyw013pphY+d7x1qV8IZupYfeIfzNA+nsaWHbn5uPuQRvdRFsa9zFzGeudPuoGoZ1Op4jrJXIQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/@vue/compiler-core": { + "version": "3.5.26", + "resolved": "https://registry.npmjs.org/@vue/compiler-core/-/compiler-core-3.5.26.tgz", + "integrity": "sha512-vXyI5GMfuoBCnv5ucIT7jhHKl55Y477yxP6fc4eUswjP8FG3FFVFd41eNDArR+Uk3QKn2Z85NavjaxLxOC19/w==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/parser": "^7.28.5", + "@vue/shared": "3.5.26", + "entities": "^7.0.0", + "estree-walker": "^2.0.2", + "source-map-js": "^1.2.1" + } + }, + "node_modules/@vue/compiler-dom": { + "version": "3.5.26", + "resolved": "https://registry.npmjs.org/@vue/compiler-dom/-/compiler-dom-3.5.26.tgz", + "integrity": "sha512-y1Tcd3eXs834QjswshSilCBnKGeQjQXB6PqFn/1nxcQw4pmG42G8lwz+FZPAZAby6gZeHSt/8LMPfZ4Rb+Bd/A==", + "dev": true, + "license": "MIT", + "dependencies": { + "@vue/compiler-core": "3.5.26", + "@vue/shared": "3.5.26" + } + }, + "node_modules/@vue/compiler-sfc": { + "version": "3.5.26", + "resolved": "https://registry.npmjs.org/@vue/compiler-sfc/-/compiler-sfc-3.5.26.tgz", + "integrity": "sha512-egp69qDTSEZcf4bGOSsprUr4xI73wfrY5oRs6GSgXFTiHrWj4Y3X5Ydtip9QMqiCMCPVwLglB9GBxXtTadJ3mA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/parser": "^7.28.5", + "@vue/compiler-core": "3.5.26", + "@vue/compiler-dom": "3.5.26", + "@vue/compiler-ssr": "3.5.26", + "@vue/shared": "3.5.26", + "estree-walker": "^2.0.2", + "magic-string": "^0.30.21", + "postcss": "^8.5.6", + "source-map-js": "^1.2.1" + } + }, + "node_modules/@vue/compiler-ssr": { + "version": "3.5.26", + "resolved": "https://registry.npmjs.org/@vue/compiler-ssr/-/compiler-ssr-3.5.26.tgz", + "integrity": "sha512-lZT9/Y0nSIRUPVvapFJEVDbEXruZh2IYHMk2zTtEgJSlP5gVOqeWXH54xDKAaFS4rTnDeDBQUYDtxKyoW9FwDw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@vue/compiler-dom": "3.5.26", + "@vue/shared": "3.5.26" + } + }, + "node_modules/@vue/devtools-api": { + "version": "7.7.9", + "resolved": "https://registry.npmjs.org/@vue/devtools-api/-/devtools-api-7.7.9.tgz", + "integrity": "sha512-kIE8wvwlcZ6TJTbNeU2HQNtaxLx3a84aotTITUuL/4bzfPxzajGBOoqjMhwZJ8L9qFYDU/lAYMEEm11dnZOD6g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@vue/devtools-kit": "^7.7.9" + } + }, + "node_modules/@vue/devtools-kit": { + "version": "7.7.9", + "resolved": "https://registry.npmjs.org/@vue/devtools-kit/-/devtools-kit-7.7.9.tgz", + "integrity": "sha512-PyQ6odHSgiDVd4hnTP+aDk2X4gl2HmLDfiyEnn3/oV+ckFDuswRs4IbBT7vacMuGdwY/XemxBoh302ctbsptuA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@vue/devtools-shared": "^7.7.9", + "birpc": "^2.3.0", + "hookable": "^5.5.3", + "mitt": "^3.0.1", + "perfect-debounce": "^1.0.0", + "speakingurl": "^14.0.1", + "superjson": "^2.2.2" + } + }, + "node_modules/@vue/devtools-shared": { + "version": "7.7.9", + "resolved": "https://registry.npmjs.org/@vue/devtools-shared/-/devtools-shared-7.7.9.tgz", + "integrity": "sha512-iWAb0v2WYf0QWmxCGy0seZNDPdO3Sp5+u78ORnyeonS6MT4PC7VPrryX2BpMJrwlDeaZ6BD4vP4XKjK0SZqaeA==", + "dev": true, + "license": "MIT", + "dependencies": { + "rfdc": "^1.4.1" + } + }, + "node_modules/@vue/language-core": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/@vue/language-core/-/language-core-3.2.2.tgz", + "integrity": "sha512-5DAuhxsxBN9kbriklh3Q5AMaJhyOCNiQJvCskN9/30XOpdLiqZU9Q+WvjArP17ubdGEyZtBzlIeG5nIjEbNOrQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@volar/language-core": "2.4.27", + "@vue/compiler-dom": "^3.5.0", + "@vue/shared": "^3.5.0", + "alien-signals": "^3.0.0", + "muggle-string": "^0.4.1", + "path-browserify": "^1.0.1", + "picomatch": "^4.0.2" + } + }, + "node_modules/@vue/language-server": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/@vue/language-server/-/language-server-3.2.2.tgz", + "integrity": "sha512-E9QUhvqzVlAZVxoGcmUjWdZgEyb0dr+DPW7TtUecGOAJIIyEedzPDW6sCZflW10MdDm5y7omdqPs8zIvr7tyPQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@volar/language-server": "2.4.27", + "@vue/language-core": "3.2.2", + "@vue/language-service": "3.2.2", + "@vue/typescript-plugin": "3.2.2", + "vscode-uri": "^3.0.8" + }, + "bin": { + "vue-language-server": "bin/vue-language-server.js" + }, + "peerDependencies": { + "typescript": "*" + } + }, + "node_modules/@vue/language-service": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/@vue/language-service/-/language-service-3.2.2.tgz", + "integrity": "sha512-sv6mug6j1GsJSIOsYS+3x2Lq69VS7BXUUP1qD6tBxr7WlENwU8rXSk3a/FJAVw807AMQIPi+U1LkqdxHQkCzjw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@volar/language-service": "2.4.27", + "@vue/language-core": "3.2.2", + "@vue/shared": "^3.5.0", + "path-browserify": "^1.0.1", + "volar-service-css": "0.0.68", + "volar-service-emmet": "0.0.68", + "volar-service-html": "0.0.68", + "volar-service-json": "0.0.68", + "volar-service-pug": "0.0.68", + "volar-service-pug-beautify": "0.0.68", + "volar-service-typescript": "0.0.68", + "vscode-html-languageservice": "^5.2.0", + "vscode-uri": "^3.0.8" + } + }, + "node_modules/@vue/reactivity": { + "version": "3.5.26", + "resolved": "https://registry.npmjs.org/@vue/reactivity/-/reactivity-3.5.26.tgz", + "integrity": "sha512-9EnYB1/DIiUYYnzlnUBgwU32NNvLp/nhxLXeWRhHUEeWNTn1ECxX8aGO7RTXeX6PPcxe3LLuNBFoJbV4QZ+CFQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@vue/shared": "3.5.26" + } + }, + "node_modules/@vue/runtime-core": { + "version": "3.5.26", + "resolved": "https://registry.npmjs.org/@vue/runtime-core/-/runtime-core-3.5.26.tgz", + "integrity": "sha512-xJWM9KH1kd201w5DvMDOwDHYhrdPTrAatn56oB/LRG4plEQeZRQLw0Bpwih9KYoqmzaxF0OKSn6swzYi84e1/Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "@vue/reactivity": "3.5.26", + "@vue/shared": "3.5.26" + } + }, + "node_modules/@vue/runtime-dom": { + "version": "3.5.26", + "resolved": "https://registry.npmjs.org/@vue/runtime-dom/-/runtime-dom-3.5.26.tgz", + "integrity": "sha512-XLLd/+4sPC2ZkN/6+V4O4gjJu6kSDbHAChvsyWgm1oGbdSO3efvGYnm25yCjtFm/K7rrSDvSfPDgN1pHgS4VNQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@vue/reactivity": "3.5.26", + "@vue/runtime-core": "3.5.26", + "@vue/shared": "3.5.26", + "csstype": "^3.2.3" + } + }, + "node_modules/@vue/server-renderer": { + "version": "3.5.26", + "resolved": "https://registry.npmjs.org/@vue/server-renderer/-/server-renderer-3.5.26.tgz", + "integrity": "sha512-TYKLXmrwWKSodyVuO1WAubucd+1XlLg4set0YoV+Hu8Lo79mp/YMwWV5mC5FgtsDxX3qo1ONrxFaTP1OQgy1uA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@vue/compiler-ssr": "3.5.26", + "@vue/shared": "3.5.26" + }, + "peerDependencies": { + "vue": "3.5.26" + } + }, + "node_modules/@vue/shared": { + "version": "3.5.26", + "resolved": "https://registry.npmjs.org/@vue/shared/-/shared-3.5.26.tgz", + "integrity": "sha512-7Z6/y3uFI5PRoKeorTOSXKcDj0MSasfNNltcslbFrPpcw6aXRUALq4IfJlaTRspiWIUOEZbrpM+iQGmCOiWe4A==", + "dev": true, + "license": "MIT" + }, + "node_modules/@vue/typescript-plugin": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/@vue/typescript-plugin/-/typescript-plugin-3.2.2.tgz", + "integrity": "sha512-7mQeWWMAVeloiN0y2ZCX/kSiGbGjvI4TEc3f9at4qVdUuhMnRZ4JBE5TQFnZEybGoHdEfj86fgW+ve2Jg7z99g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@volar/typescript": "2.4.27", + "@vue/language-core": "3.2.2", + "@vue/shared": "^3.5.0", + "path-browserify": "^1.0.1", + "vue-component-meta": "3.2.2" + } + }, + "node_modules/@vueuse/core": { + "version": "12.8.2", + "resolved": "https://registry.npmjs.org/@vueuse/core/-/core-12.8.2.tgz", + "integrity": "sha512-HbvCmZdzAu3VGi/pWYm5Ut+Kd9mn1ZHnn4L5G8kOQTPs/IwIAmJoBrmYk2ckLArgMXZj0AW3n5CAejLUO+PhdQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/web-bluetooth": "^0.0.21", + "@vueuse/metadata": "12.8.2", + "@vueuse/shared": "12.8.2", + "vue": "^3.5.13" + }, + "funding": { + "url": "https://github.com/sponsors/antfu" + } + }, + "node_modules/@vueuse/integrations": { + "version": "12.8.2", + "resolved": "https://registry.npmjs.org/@vueuse/integrations/-/integrations-12.8.2.tgz", + "integrity": "sha512-fbGYivgK5uBTRt7p5F3zy6VrETlV9RtZjBqd1/HxGdjdckBgBM4ugP8LHpjolqTj14TXTxSK1ZfgPbHYyGuH7g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@vueuse/core": "12.8.2", + "@vueuse/shared": "12.8.2", + "vue": "^3.5.13" + }, + "funding": { + "url": "https://github.com/sponsors/antfu" + }, + "peerDependencies": { + "async-validator": "^4", + "axios": "^1", + "change-case": "^5", + "drauu": "^0.4", + "focus-trap": "^7", + "fuse.js": "^7", + "idb-keyval": "^6", + "jwt-decode": "^4", + "nprogress": "^0.2", + "qrcode": "^1.5", + "sortablejs": "^1", + "universal-cookie": "^7" + }, + "peerDependenciesMeta": { + "async-validator": { + "optional": true + }, + "axios": { + "optional": true + }, + "change-case": { + "optional": true + }, + "drauu": { + "optional": true + }, + "focus-trap": { + "optional": true + }, + "fuse.js": { + "optional": true + }, + "idb-keyval": { + "optional": true + }, + "jwt-decode": { + "optional": true + }, + "nprogress": { + "optional": true + }, + "qrcode": { + "optional": true + }, + "sortablejs": { + "optional": true + }, + "universal-cookie": { + "optional": true + } + } + }, + "node_modules/@vueuse/metadata": { + "version": "12.8.2", + "resolved": "https://registry.npmjs.org/@vueuse/metadata/-/metadata-12.8.2.tgz", + "integrity": "sha512-rAyLGEuoBJ/Il5AmFHiziCPdQzRt88VxR+Y/A/QhJ1EWtWqPBBAxTAFaSkviwEuOEZNtW8pvkPgoCZQ+HxqW1A==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/antfu" + } + }, + "node_modules/@vueuse/shared": { + "version": "12.8.2", + "resolved": "https://registry.npmjs.org/@vueuse/shared/-/shared-12.8.2.tgz", + "integrity": "sha512-dznP38YzxZoNloI0qpEfpkms8knDtaoQ6Y/sfS0L7Yki4zh40LFHEhur0odJC6xTHG5dxWVPiUWBXn+wCG2s5w==", + "dev": true, + "license": "MIT", + "dependencies": { + "vue": "^3.5.13" + }, + "funding": { + "url": "https://github.com/sponsors/antfu" + } + }, + "node_modules/@yarnpkg/lockfile": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@yarnpkg/lockfile/-/lockfile-1.1.0.tgz", + "integrity": "sha512-GpSwvyXOcOOlV70vbnzjj4fW5xW/FdUF6nQEt1ENy7m4ZCczi1+/buVUPAqmGfqznsORNFzUMjctTIp8a9tuCQ==", + "dev": true, + "license": "BSD-2-Clause" + }, + "node_modules/@zenuml/core": { + "version": "3.45.4", + "resolved": "https://registry.npmjs.org/@zenuml/core/-/core-3.45.4.tgz", + "integrity": "sha512-y2s6F0urvcnzB/Rx5oPVLUn9zlq+cnwTMXAlEH46tdItQtqU8fTRYqrGGOuJVIKZcbZwgtpFzpSzzcC0YtjLqQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@floating-ui/react": "^0.27.16", + "@headlessui/react": "^2.2.9", + "@headlessui/tailwindcss": "^0.2.2", + "antlr4": "~4.11.0", + "class-variance-authority": "^0.7.1", + "clsx": "^2.1.1", + "color-string": "^2.1.4", + "dompurify": "^3.3.1", + "highlight.js": "^10.7.3", + "html-to-image": "^1.11.13", + "immer": "^10.2.0", + "jotai": "^2.16.1", + "lodash": "^4.17.21", + "marked": "^4.3.0", + "pako": "^2.1.0", + "pino": "^8.21.0", + "radash": "^12.1.1", + "ramda": "^0.28.0", + "react": "^19.2.3", + "react-dom": "^19.2.3", + "tailwind-merge": "^3.4.0", + "tailwindcss": "^3.4.19" + }, + "engines": { + "node": ">=20" + } + }, + "node_modules/acorn": { + "version": "8.15.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.15.0.tgz", + "integrity": "sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg==", + "dev": true, + "license": "MIT", + "peer": true, + "bin": { + "acorn": "bin/acorn" + }, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/acorn-import-assertions": { + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/acorn-import-assertions/-/acorn-import-assertions-1.9.0.tgz", + "integrity": "sha512-cmMwop9x+8KFhxvKrKfPYmN6/pKTYYHBqLa0DfvVZcKMJWNyWLnaqND7dx/qn66R7ewM1UX5XMaDVP5wlVTaVA==", + "deprecated": "package has been renamed to acorn-import-attributes", + "dev": true, + "license": "MIT", + "peerDependencies": { + "acorn": "^8" + } + }, + "node_modules/acorn-jsx": { + "version": "5.3.2", + "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz", + "integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==", + "dev": true, + "license": "MIT", + "peerDependencies": { + "acorn": "^6.0.0 || ^7.0.0 || ^8.0.0" + } + }, + "node_modules/agent-base": { + "version": "7.1.4", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.4.tgz", + "integrity": "sha512-MnA+YT8fwfJPgBx3m60MNqakm30XOkyIoH1y6huTQvC0PwZG7ki8NacLBcrPbNoo8vEZy7Jpuk7+jMO+CUovTQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 14" + } + }, + "node_modules/aggregate-error": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/aggregate-error/-/aggregate-error-3.1.0.tgz", + "integrity": "sha512-4I7Td01quW/RpocfNayFdFVk1qSuoh0E7JrbRJ16nH01HhKFQ88INq9Sd+nd72zqRySlr9BmDA8xlEJ6vJMrYA==", + "dev": true, + "license": "MIT", + "dependencies": { + "clean-stack": "^2.0.0", + "indent-string": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/aggregate-error/node_modules/indent-string": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-4.0.0.tgz", + "integrity": "sha512-EdDDZu4A2OyIK7Lr/2zG+w5jmbuk1DVBnEwREQvBzspBJkCEbRa8GxU1lghYcaGJCnRWibjDXlq779X1/y5xwg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/ajv": { + "version": "6.12.6", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", + "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", + "dev": true, + "license": "MIT", + "dependencies": { + "fast-deep-equal": "^3.1.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/epoberezkin" + } + }, + "node_modules/algoliasearch": { + "version": "5.46.3", + "resolved": "https://registry.npmjs.org/algoliasearch/-/algoliasearch-5.46.3.tgz", + "integrity": "sha512-n/NdPglzmkcNYZfIT3Fo8pnDR/lKiK1kZ1Yaa315UoLyHymADhWw15+bzN5gBxrCA8KyeNu0JJD6mLtTov43lQ==", + "dev": true, + "license": "MIT", + "peer": true, + "dependencies": { + "@algolia/abtesting": "1.12.3", + "@algolia/client-abtesting": "5.46.3", + "@algolia/client-analytics": "5.46.3", + "@algolia/client-common": "5.46.3", + "@algolia/client-insights": "5.46.3", + "@algolia/client-personalization": "5.46.3", + "@algolia/client-query-suggestions": "5.46.3", + "@algolia/client-search": "5.46.3", + "@algolia/ingestion": "1.46.3", + "@algolia/monitoring": "1.46.3", + "@algolia/recommend": "5.46.3", + "@algolia/requester-browser-xhr": "5.46.3", + "@algolia/requester-fetch": "5.46.3", + "@algolia/requester-node-http": "5.46.3" + }, + "engines": { + "node": ">= 14.0.0" + } + }, + "node_modules/alien-signals": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/alien-signals/-/alien-signals-3.1.2.tgz", + "integrity": "sha512-d9dYqZTS90WLiU0I5c6DHj/HcKkF8ZyGN3G5x8wSbslulz70KOxaqCT0hQCo9KOyhVqzqGojvNdJXoTumZOtcw==", + "dev": true, + "license": "MIT" + }, + "node_modules/ansi-escapes": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-7.2.0.tgz", + "integrity": "sha512-g6LhBsl+GBPRWGWsBtutpzBYuIIdBkLEvad5C/va/74Db018+5TZiyA26cZJAr3Rft5lprVqOIPxf5Vid6tqAw==", + "dev": true, + "license": "MIT", + "dependencies": { + "environment": "^1.0.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/ansi-regex": { + "version": "6.2.2", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.2.2.tgz", + "integrity": "sha512-Bq3SmSpyFHaWjPk8If9yc6svM8c56dB5BAtW4Qbw5jHTwwXXcTLoRMkpDJp6VL0XzlWaCHTXrkFURMYmD0sLqg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/ansi-regex?sponsor=1" + } + }, + "node_modules/ansi-styles": { + "version": "6.2.3", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.2.3.tgz", + "integrity": "sha512-4Dj6M28JB+oAH8kFkTLUo+a2jwOFkuqb3yucU0CANcRRUbxS0cP0nZYCGjcc3BNXwRIsUVmDGgzawme7zvJHvg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/antlr4": { + "version": "4.11.0", + "resolved": "https://registry.npmjs.org/antlr4/-/antlr4-4.11.0.tgz", + "integrity": "sha512-GUGlpE2JUjAN+G8G5vY+nOoeyNhHsXoIJwP1XF1oRw89vifA1K46T6SEkwLwr7drihN7I/lf0DIjKc4OZvBX8w==", + "dev": true, + "license": "BSD-3-Clause", + "engines": { + "node": ">=14" + } + }, + "node_modules/any-promise": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/any-promise/-/any-promise-1.3.0.tgz", + "integrity": "sha512-7UvmKalWRt1wgjL1RrGxoSJW/0QZFIegpeGvZG9kjp8vrRu55XTHbwnqq2GpXm9uLbcuhxm3IqX9OB4MZR1b2A==", + "dev": true, + "license": "MIT" + }, + "node_modules/anymatch": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz", + "integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==", + "dev": true, + "license": "ISC", + "dependencies": { + "normalize-path": "^3.0.0", + "picomatch": "^2.0.4" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/anymatch/node_modules/picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/append-transform": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/append-transform/-/append-transform-2.0.0.tgz", + "integrity": "sha512-7yeyCEurROLQJFv5Xj4lEGTy0borxepjFv1g22oAdqFu//SrAlDl1O1Nxx15SH1RoliUml6p8dwJW9jvZughhg==", + "dev": true, + "license": "MIT", + "dependencies": { + "default-require-extensions": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/archy": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/archy/-/archy-1.0.0.tgz", + "integrity": "sha512-Xg+9RwCg/0p32teKdGMPTPnVXKD0w3DfHnFTficozsAgsvq2XenPJq/MYpzzQ/v8zrOyJn6Ds39VA4JIDwFfqw==", + "dev": true, + "license": "MIT" + }, + "node_modules/arg": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/arg/-/arg-5.0.2.tgz", + "integrity": "sha512-PYjyFOLKQ9y57JvQ6QLo8dAgNqswh8M1RMJYdQduT6xbWSgK36P/Z/v+p888pM69jMMfS8Xd8F6I1kQ/I9HUGg==", + "dev": true, + "license": "MIT" + }, + "node_modules/argparse": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", + "dev": true, + "license": "Python-2.0" + }, + "node_modules/array-find-index": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/array-find-index/-/array-find-index-1.0.2.tgz", + "integrity": "sha512-M1HQyIXcBGtVywBt8WVdim+lrNaK7VHp99Qt5pSNziXznKHViIBbXWtfRTpEFpF/c4FdfxNAsCCwPp5phBYJtw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/ast-types": { + "version": "0.13.4", + "resolved": "https://registry.npmjs.org/ast-types/-/ast-types-0.13.4.tgz", + "integrity": "sha512-x1FCFnFifvYDDzTaLII71vG5uvDwgtmDTEVWAxrgeiR8VjMONcCXJx7E+USjDtHlwFmt9MysbqgF9b9Vjr6w+w==", + "dev": true, + "license": "MIT", + "dependencies": { + "tslib": "^2.0.1" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==", + "dev": true, + "license": "MIT" + }, + "node_modules/atomic-sleep": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/atomic-sleep/-/atomic-sleep-1.0.0.tgz", + "integrity": "sha512-kNOjDqAh7px0XWNI+4QbzoiR/nTkHAWNud2uvnJquD1/x5a7EQZMJT0AczqK0Qn67oY/TTQ1LbUKajZpp3I9tQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8.0.0" + } + }, + "node_modules/audit-resolve-core": { + "version": "3.0.0-3", + "resolved": "https://registry.npmjs.org/audit-resolve-core/-/audit-resolve-core-3.0.0-3.tgz", + "integrity": "sha512-37Qkk1EerVIzSF824BytESWeEtUcbAmdWyTGA/MqnHgVzO+PnU9oNqOpZTMst54xLpJci70Jszq/sLogqfvHmQ==", + "dev": true, + "license": "Apache 2.0", + "dependencies": { + "debug": "^4.3.1", + "djv": "^2.1.4", + "yargs-parser": "^21.0.0" + } + }, + "node_modules/axios": { + "version": "1.13.2", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.13.2.tgz", + "integrity": "sha512-VPk9ebNqPcy5lRGuSlKx752IlDatOjT9paPlm8A7yOuW2Fbvp4X3JznJtT4f0GzGLLiWE9W8onz51SqLYwzGaA==", + "dev": true, + "license": "MIT", + "dependencies": { + "follow-redirects": "^1.15.6", + "form-data": "^4.0.4", + "proxy-from-env": "^1.1.0" + } + }, + "node_modules/b4a": { + "version": "1.7.3", + "resolved": "https://registry.npmjs.org/b4a/-/b4a-1.7.3.tgz", + "integrity": "sha512-5Q2mfq2WfGuFp3uS//0s6baOJLMoVduPYVeNmDYxu5OUA1/cBfvr2RIS7vi62LdNj/urk1hfmj867I3qt6uZ7Q==", + "dev": true, + "license": "Apache-2.0", + "peerDependencies": { + "react-native-b4a": "*" + }, + "peerDependenciesMeta": { + "react-native-b4a": { + "optional": true + } + } + }, + "node_modules/balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "dev": true, + "license": "MIT" + }, + "node_modules/bare-events": { + "version": "2.8.2", + "resolved": "https://registry.npmjs.org/bare-events/-/bare-events-2.8.2.tgz", + "integrity": "sha512-riJjyv1/mHLIPX4RwiK+oW9/4c3TEUeORHKefKAKnZ5kyslbN+HXowtbaVEqt4IMUB7OXlfixcs6gsFeo/jhiQ==", + "dev": true, + "license": "Apache-2.0", + "peerDependencies": { + "bare-abort-controller": "*" + }, + "peerDependenciesMeta": { + "bare-abort-controller": { + "optional": true + } + } + }, + "node_modules/bare-fs": { + "version": "4.5.2", + "resolved": "https://registry.npmjs.org/bare-fs/-/bare-fs-4.5.2.tgz", + "integrity": "sha512-veTnRzkb6aPHOvSKIOy60KzURfBdUflr5VReI+NSaPL6xf+XLdONQgZgpYvUuZLVQ8dCqxpBAudaOM1+KpAUxw==", + "dev": true, + "license": "Apache-2.0", + "optional": true, + "dependencies": { + "bare-events": "^2.5.4", + "bare-path": "^3.0.0", + "bare-stream": "^2.6.4", + "bare-url": "^2.2.2", + "fast-fifo": "^1.3.2" + }, + "engines": { + "bare": ">=1.16.0" + }, + "peerDependencies": { + "bare-buffer": "*" + }, + "peerDependenciesMeta": { + "bare-buffer": { + "optional": true + } + } + }, + "node_modules/bare-os": { + "version": "3.6.2", + "resolved": "https://registry.npmjs.org/bare-os/-/bare-os-3.6.2.tgz", + "integrity": "sha512-T+V1+1srU2qYNBmJCXZkUY5vQ0B4FSlL3QDROnKQYOqeiQR8UbjNHlPa+TIbM4cuidiN9GaTaOZgSEgsvPbh5A==", + "dev": true, + "license": "Apache-2.0", + "optional": true, + "engines": { + "bare": ">=1.14.0" + } + }, + "node_modules/bare-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/bare-path/-/bare-path-3.0.0.tgz", + "integrity": "sha512-tyfW2cQcB5NN8Saijrhqn0Zh7AnFNsnczRcuWODH0eYAXBsJ5gVxAUuNr7tsHSC6IZ77cA0SitzT+s47kot8Mw==", + "dev": true, + "license": "Apache-2.0", + "optional": true, + "dependencies": { + "bare-os": "^3.0.1" + } + }, + "node_modules/bare-stream": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/bare-stream/-/bare-stream-2.7.0.tgz", + "integrity": "sha512-oyXQNicV1y8nc2aKffH+BUHFRXmx6VrPzlnaEvMhram0nPBrKcEdcyBg5r08D0i8VxngHFAiVyn1QKXpSG0B8A==", + "dev": true, + "license": "Apache-2.0", + "optional": true, + "dependencies": { + "streamx": "^2.21.0" + }, + "peerDependencies": { + "bare-buffer": "*", + "bare-events": "*" + }, + "peerDependenciesMeta": { + "bare-buffer": { + "optional": true + }, + "bare-events": { + "optional": true + } + } + }, + "node_modules/bare-url": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/bare-url/-/bare-url-2.3.2.tgz", + "integrity": "sha512-ZMq4gd9ngV5aTMa5p9+UfY0b3skwhHELaDkhEHetMdX0LRkW9kzaym4oo/Eh+Ghm0CCDuMTsRIGM/ytUc1ZYmw==", + "dev": true, + "license": "Apache-2.0", + "optional": true, + "dependencies": { + "bare-path": "^3.0.0" + } + }, + "node_modules/base64-js": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", + "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT" + }, + "node_modules/baseline-browser-mapping": { + "version": "2.9.14", + "resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.9.14.tgz", + "integrity": "sha512-B0xUquLkiGLgHhpPBqvl7GWegWBUNuujQ6kXd/r1U38ElPT6Ok8KZ8e+FpUGEc2ZoRQUzq/aUnaKFc/svWUGSg==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "baseline-browser-mapping": "dist/cli.js" + } + }, + "node_modules/basic-ftp": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/basic-ftp/-/basic-ftp-5.1.0.tgz", + "integrity": "sha512-RkaJzeJKDbaDWTIPiJwubyljaEPwpVWkm9Rt5h9Nd6h7tEXTJ3VB4qxdZBioV7JO5yLUaOKwz7vDOzlncUsegw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10.0.0" + } + }, + "node_modules/before-after-hook": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/before-after-hook/-/before-after-hook-4.0.0.tgz", + "integrity": "sha512-q6tR3RPqIB1pMiTRMFcZwuG5T8vwp+vUvEG0vuI6B+Rikh5BfPp2fQ82c925FOs+b0lcFQ8CFrL+KbilfZFhOQ==", + "dev": true, + "license": "Apache-2.0" + }, + "node_modules/binary-extensions": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.3.0.tgz", + "integrity": "sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/binary-install": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/binary-install/-/binary-install-1.1.2.tgz", + "integrity": "sha512-ZS2cqFHPZOy4wLxvzqfQvDjCOifn+7uCPqNmYRIBM/03+yllON+4fNnsD0VJdW0p97y+E+dTRNPStWNqMBq+9g==", + "deprecated": "Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.", + "dev": true, + "license": "MIT", + "dependencies": { + "axios": "^0.26.1", + "rimraf": "^3.0.2", + "tar": "^6.1.11" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/birpc": { + "version": "2.9.0", + "resolved": "https://registry.npmjs.org/birpc/-/birpc-2.9.0.tgz", + "integrity": "sha512-KrayHS5pBi69Xi9JmvoqrIgYGDkD6mcSe/i6YKi3w5kekCLzrX4+nawcXqrj2tIp50Kw/mT/s3p+GVK0A0sKxw==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/antfu" + } + }, + "node_modules/boolbase": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/boolbase/-/boolbase-1.0.0.tgz", + "integrity": "sha512-JZOSA7Mo9sNGB8+UjSgzdLtokWAky1zbztM3WRLCbZ70/3cTANmQmOdR7y2g+J0e2WXywy1yS468tY+IruqEww==", + "dev": true, + "license": "ISC" + }, + "node_modules/brace-expansion": { + "version": "1.1.12", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.12.tgz", + "integrity": "sha512-9T9UjW3r0UW5c1Q7GTwllptXwhvYmEzFhzMfZ9H7FQWt+uZePjZPjBP/W1ZEyZ1twGWom5/56TF4lPcqjnDHcg==", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/braces": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", + "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", + "dev": true, + "license": "MIT", + "dependencies": { + "fill-range": "^7.1.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/browser-stdout": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", + "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==", + "dev": true, + "license": "ISC" + }, + "node_modules/browserslist": { + "version": "4.28.1", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.28.1.tgz", + "integrity": "sha512-ZC5Bd0LgJXgwGqUknZY/vkUQ04r8NXnJZ3yYi4vDmSiZmC/pdSN0NbNRPxZpbtO4uAfDUAFffO8IZoM3Gj8IkA==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/browserslist" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "peer": true, + "dependencies": { + "baseline-browser-mapping": "^2.9.0", + "caniuse-lite": "^1.0.30001759", + "electron-to-chromium": "^1.5.263", + "node-releases": "^2.0.27", + "update-browserslist-db": "^1.2.0" + }, + "bin": { + "browserslist": "cli.js" + }, + "engines": { + "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7" + } + }, + "node_modules/buble": { + "version": "0.20.0", + "resolved": "https://registry.npmjs.org/buble/-/buble-0.20.0.tgz", + "integrity": "sha512-/1gnaMQE8xvd5qsNBl+iTuyjJ9XxeaVxAMF86dQ4EyxFJOZtsgOS8Ra+7WHgZTam5IFDtt4BguN0sH0tVTKrOw==", + "dev": true, + "license": "MIT", + "dependencies": { + "acorn": "^6.4.1", + "acorn-dynamic-import": "^4.0.0", + "acorn-jsx": "^5.2.0", + "chalk": "^2.4.2", + "magic-string": "^0.25.7", + "minimist": "^1.2.5", + "regexpu-core": "4.5.4" + }, + "bin": { + "buble": "bin/buble" + } + }, + "node_modules/buble/node_modules/acorn": { + "version": "6.4.2", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-6.4.2.tgz", + "integrity": "sha512-XtGIhXwF8YM8bJhGxG5kXgjkEuNGLTkoYqVE+KMR+aspr4KGYmKYg7yUe3KghyQ9yheNwLnjmzh/7+gfDBmHCQ==", + "dev": true, + "license": "MIT", + "peer": true, + "bin": { + "acorn": "bin/acorn" + }, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/buble/node_modules/acorn-dynamic-import": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/acorn-dynamic-import/-/acorn-dynamic-import-4.0.0.tgz", + "integrity": "sha512-d3OEjQV4ROpoflsnUA8HozoIR504TFxNivYEUi6uwz0IYhBkTDXGuWlNdMtybRt3nqVx/L6XqMt0FxkXuWKZhw==", + "deprecated": "This is probably built in to whatever tool you're using. If you still need it... idk", + "dev": true, + "license": "MIT", + "peerDependencies": { + "acorn": "^6.0.0" + } + }, + "node_modules/buble/node_modules/ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "dev": true, + "license": "MIT", + "dependencies": { + "color-convert": "^1.9.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/buble/node_modules/chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/buble/node_modules/escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.8.0" + } + }, + "node_modules/buble/node_modules/has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=4" + } + }, + "node_modules/buble/node_modules/magic-string": { + "version": "0.25.9", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.25.9.tgz", + "integrity": "sha512-RmF0AsMzgt25qzqqLc1+MbHmhdx0ojF2Fvs4XnOqz2ZOBXzzkEwc/dJQZCYHAn7v1jbVOjAZfK8msRn4BxO4VQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "sourcemap-codec": "^1.4.8" + } + }, + "node_modules/buble/node_modules/supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dev": true, + "license": "MIT", + "dependencies": { + "has-flag": "^3.0.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/buffer": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz", + "integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT", + "dependencies": { + "base64-js": "^1.3.1", + "ieee754": "^1.1.13" + } + }, + "node_modules/buffer-crc32": { + "version": "0.2.13", + "resolved": "https://registry.npmjs.org/buffer-crc32/-/buffer-crc32-0.2.13.tgz", + "integrity": "sha512-VO9Ht/+p3SN7SKWqcrgEzjGbRSJYTx+Q1pTQC0wrWqHx0vpJraQ6GtHx8tvcg1rlK1byhU5gccxgOgj7B0TDkQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": "*" + } + }, + "node_modules/buffer-from": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", + "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/builtin-modules": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-5.0.0.tgz", + "integrity": "sha512-bkXY9WsVpY7CvMhKSR6pZilZu9Ln5WDrKVBUXf2S443etkmEO4V58heTecXcUIsNsi4Rx8JUO4NfX1IcQl4deg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18.20" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/caching-transform": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/caching-transform/-/caching-transform-4.0.0.tgz", + "integrity": "sha512-kpqOvwXnjjN44D89K5ccQC+RUrsy7jB/XLlRrx0D7/2HNcTPqzsb6XgYoErwko6QsV184CA2YgS1fxDiiDZMWA==", + "dev": true, + "license": "MIT", + "dependencies": { + "hasha": "^5.0.0", + "make-dir": "^3.0.0", + "package-hash": "^4.0.0", + "write-file-atomic": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/call-bind": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.8.tgz", + "integrity": "sha512-oKlSFMcMwpUg2ednkhQ454wfWiU/ul3CkJe/PEHcTKuiX6RpbehUiFMXu13HalGZxfUwCQzZG747YXBn1im9ww==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.0", + "es-define-property": "^1.0.0", + "get-intrinsic": "^1.2.4", + "set-function-length": "^1.2.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/call-bind-apply-helpers": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz", + "integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/call-bound": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/call-bound/-/call-bound-1.0.4.tgz", + "integrity": "sha512-+ys997U96po4Kx/ABpBCqhA9EuxJaQWDQg7295H4hBphv3IZg0boBKuwYpt4YXp6MZ5AmZQnU/tyMTlRpaSejg==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.2", + "get-intrinsic": "^1.3.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/callsites": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", + "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/camelcase": { + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", + "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/camelcase-css": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/camelcase-css/-/camelcase-css-2.0.1.tgz", + "integrity": "sha512-QOSvevhslijgYwRx6Rv7zKdMF8lbRmx+uQGx2+vDc+KI/eBnsy9kit5aj23AgGu3pa4t9AgwbnXWqS+iOY+2aA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 6" + } + }, + "node_modules/caniuse-lite": { + "version": "1.0.30001764", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001764.tgz", + "integrity": "sha512-9JGuzl2M+vPL+pz70gtMF9sHdMFbY9FJaQBi186cHKH3pSzDvzoUJUPV6fqiKIMyXbud9ZLg4F3Yza1vJ1+93g==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/caniuse-lite" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "CC-BY-4.0" + }, + "node_modules/ccount": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/ccount/-/ccount-2.0.1.tgz", + "integrity": "sha512-eyrF0jiFpY+3drT6383f1qhkbGsLSifNAjA61IUjZjmLCWjItY6LB9ft9YhoDgwfmclB2zhu51Lc7+95b8NRAg==", + "dev": true, + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/chalk": { + "version": "5.6.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-5.6.2.tgz", + "integrity": "sha512-7NzBL0rN6fMUW+f7A6Io4h40qQlG+xGmtMxfbnH/K7TAtt8JQWVQK+6g0UXKMeVJoyV5EkkNsErQ8pVD3bLHbA==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^12.17.0 || ^14.13 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/change-case": { + "version": "5.4.4", + "resolved": "https://registry.npmjs.org/change-case/-/change-case-5.4.4.tgz", + "integrity": "sha512-HRQyTk2/YPEkt9TnUPbOpr64Uw3KOicFWPVBb+xiHvd6eBx/qPr9xqfBFDT8P2vWsvvz4jbEkfDe71W3VyNu2w==", + "dev": true, + "license": "MIT" + }, + "node_modules/character-entities": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/character-entities/-/character-entities-2.0.2.tgz", + "integrity": "sha512-shx7oQ0Awen/BRIdkjkvz54PnEEI/EjwXDSIZp86/KKdbafHh1Df/RYGBhn4hbe2+uKC9FnT5UCEdyPz3ai9hQ==", + "dev": true, + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/character-entities-html4": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/character-entities-html4/-/character-entities-html4-2.1.0.tgz", + "integrity": "sha512-1v7fgQRj6hnSwFpq1Eu0ynr/CDEw0rXo2B61qXrLNdHZmPKgb7fqS1a2JwF0rISo9q77jDI8VMEHoApn8qDoZA==", + "dev": true, + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/character-entities-legacy": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/character-entities-legacy/-/character-entities-legacy-3.0.0.tgz", + "integrity": "sha512-RpPp0asT/6ufRm//AJVwpViZbGM/MkjQFxJccQRHmISF/22NBtsHqAWmL+/pmkPWoIUJdWyeVleTl1wydHATVQ==", + "dev": true, + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/character-parser": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/character-parser/-/character-parser-2.2.0.tgz", + "integrity": "sha512-+UqJQjFEFaTAs3bNsF2j2kEN1baG/zghZbdqoYEDxGZtJo9LBzl1A+m0D4n3qKx8N2FNv8/Xp6yV9mQmBuptaw==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-regex": "^1.0.3" + } + }, + "node_modules/chardet": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/chardet/-/chardet-2.1.1.tgz", + "integrity": "sha512-PsezH1rqdV9VvyNhxxOW32/d75r01NY7TQCmOqomRo15ZSOKbpTFVsfjghxo6JloQUCGnH4k1LGu0R4yCLlWQQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/chevrotain": { + "version": "11.0.3", + "resolved": "https://registry.npmjs.org/chevrotain/-/chevrotain-11.0.3.tgz", + "integrity": "sha512-ci2iJH6LeIkvP9eJW6gpueU8cnZhv85ELY8w8WiFtNjMHA5ad6pQLaJo9mEly/9qUyCpvqX8/POVUTf18/HFdw==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@chevrotain/cst-dts-gen": "11.0.3", + "@chevrotain/gast": "11.0.3", + "@chevrotain/regexp-to-ast": "11.0.3", + "@chevrotain/types": "11.0.3", + "@chevrotain/utils": "11.0.3", + "lodash-es": "4.17.21" + } + }, + "node_modules/chevrotain-allstar": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/chevrotain-allstar/-/chevrotain-allstar-0.3.1.tgz", + "integrity": "sha512-b7g+y9A0v4mxCW1qUhf3BSVPg+/NvGErk/dOkrDaHA0nQIQGAtrOjlX//9OQtRlSCy+x9rfB5N8yC71lH1nvMw==", + "dev": true, + "license": "MIT", + "dependencies": { + "lodash-es": "^4.17.21" + }, + "peerDependencies": { + "chevrotain": "^11.0.0" + } + }, + "node_modules/chevrotain/node_modules/lodash-es": { + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/lodash-es/-/lodash-es-4.17.21.tgz", + "integrity": "sha512-mKnC+QJ9pWVzv+C4/U3rRsHapFfHvQFoFB92e52xeyGMcX6/OlIl78je1u8vePzYZSkkogMPJ2yjxxsb89cxyw==", + "dev": true, + "license": "MIT" + }, + "node_modules/chokidar": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz", + "integrity": "sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==", + "dev": true, + "license": "MIT", + "dependencies": { + "anymatch": "~3.1.2", + "braces": "~3.0.2", + "glob-parent": "~5.1.2", + "is-binary-path": "~2.1.0", + "is-glob": "~4.0.1", + "normalize-path": "~3.0.0", + "readdirp": "~3.6.0" + }, + "engines": { + "node": ">= 8.10.0" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + }, + "optionalDependencies": { + "fsevents": "~2.3.2" + } + }, + "node_modules/chownr": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/chownr/-/chownr-2.0.0.tgz", + "integrity": "sha512-bIomtDF5KGpdogkLd9VspvFzk9KfpyyGlS8YFVZl7TGPBHL5snIOnxeshwVgPteQ9b4Eydl+pVbIyE1DcvCWgQ==", + "dev": true, + "license": "ISC", + "engines": { + "node": ">=10" + } + }, + "node_modules/chromium-bidi": { + "version": "0.11.0", + "resolved": "https://registry.npmjs.org/chromium-bidi/-/chromium-bidi-0.11.0.tgz", + "integrity": "sha512-6CJWHkNRoyZyjV9Rwv2lYONZf1Xm0IuDyNq97nwSsxxP3wf5Bwy15K5rOvVKMtJ127jJBmxFUanSAOjgFRxgrA==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "mitt": "3.0.1", + "zod": "3.23.8" + }, + "peerDependencies": { + "devtools-protocol": "*" + } + }, + "node_modules/ci-info": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-4.3.1.tgz", + "integrity": "sha512-Wdy2Igu8OcBpI2pZePZ5oWjPC38tmDVx5WKUXKwlLYkA0ozo85sLsLvkBbBn/sZaSCMFOGZJ14fvW9t5/d7kdA==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/sibiraj-s" + } + ], + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/class-variance-authority": { + "version": "0.7.1", + "resolved": "https://registry.npmjs.org/class-variance-authority/-/class-variance-authority-0.7.1.tgz", + "integrity": "sha512-Ka+9Trutv7G8M6WT6SeiRWz792K5qEqIGEGzXKhAE6xOWAY6pPH8U+9IY3oCMv6kqTmLsv7Xh/2w2RigkePMsg==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "clsx": "^2.1.1" + }, + "funding": { + "url": "https://polar.sh/cva" + } + }, + "node_modules/clean-regexp": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/clean-regexp/-/clean-regexp-1.0.0.tgz", + "integrity": "sha512-GfisEZEJvzKrmGWkvfhgzcz/BllN1USeqD2V6tg14OAOgaCD2Z/PUEuxnAZ/nPvmaHRG7a8y77p1T/IRQ4D1Hw==", + "dev": true, + "license": "MIT", + "dependencies": { + "escape-string-regexp": "^1.0.5" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/clean-regexp/node_modules/escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.8.0" + } + }, + "node_modules/clean-stack": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/clean-stack/-/clean-stack-2.2.0.tgz", + "integrity": "sha512-4diC9HaTE+KRAMWhDhrGOECgWZxoevMc5TlkObMqNSsVU62PYzXZ/SMTjzyGAFF1YusgxGcSWTEXBhp0CPwQ1A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/cli-cursor": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-5.0.0.tgz", + "integrity": "sha512-aCj4O5wKyszjMmDT4tZj93kxyydN/K5zPWSCe6/0AV/AA1pqe5ZBIw0a2ZfPQV7lL5/yb5HsUreJ6UFAF1tEQw==", + "dev": true, + "license": "MIT", + "dependencies": { + "restore-cursor": "^5.0.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/cli-truncate": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/cli-truncate/-/cli-truncate-5.1.1.tgz", + "integrity": "sha512-SroPvNHxUnk+vIW/dOSfNqdy1sPEFkrTk6TUtqLCnBlo3N7TNYYkzzN7uSD6+jVjrdO4+p8nH7JzH6cIvUem6A==", + "dev": true, + "license": "MIT", + "dependencies": { + "slice-ansi": "^7.1.0", + "string-width": "^8.0.0" + }, + "engines": { + "node": ">=20" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/cli-width": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/cli-width/-/cli-width-4.1.0.tgz", + "integrity": "sha512-ouuZd4/dm2Sw5Gmqy6bGyNNNe1qt9RpmxveLSO7KcgsTnU7RXfsw+/bukWGo1abgBiMAic068rclZsO4IWmmxQ==", + "dev": true, + "license": "ISC", + "engines": { + "node": ">= 12" + } + }, + "node_modules/clipanion": { + "version": "4.0.0-rc.4", + "resolved": "https://registry.npmjs.org/clipanion/-/clipanion-4.0.0-rc.4.tgz", + "integrity": "sha512-CXkMQxU6s9GklO/1f714dkKBMu1lopS1WFF0B8o4AxPykR1hpozxSiUZ5ZUeBjfPgCWqbcNOtZVFhB8Lkfp1+Q==", + "dev": true, + "license": "MIT", + "workspaces": [ + "website" + ], + "dependencies": { + "typanion": "^3.8.0" + }, + "peerDependencies": { + "typanion": "*" + } + }, + "node_modules/cliui": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz", + "integrity": "sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==", + "dev": true, + "license": "ISC", + "dependencies": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.1", + "wrap-ansi": "^7.0.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/cliui/node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/cliui/node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "license": "MIT", + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/cliui/node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/cliui/node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true, + "license": "MIT" + }, + "node_modules/cliui/node_modules/is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/cliui/node_modules/string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dev": true, + "license": "MIT", + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/cliui/node_modules/strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/cliui/node_modules/wrap-ansi": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } + }, + "node_modules/clsx": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/clsx/-/clsx-2.1.1.tgz", + "integrity": "sha512-eYm0QWBtUrBWZWG0d386OGAw16Z995PiOVo2B7bjWSbHedGl5e0ZWaq65kOGgUSNesEIDkB9ISbTg/JK9dhCZA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "dev": true, + "license": "MIT", + "dependencies": { + "color-name": "1.1.3" + } + }, + "node_modules/color-convert/node_modules/color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==", + "dev": true, + "license": "MIT" + }, + "node_modules/color-name": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-2.1.0.tgz", + "integrity": "sha512-1bPaDNFm0axzE4MEAzKPuqKWeRaT43U/hyxKPBdqTfmPF+d6n7FSoTFxLVULUJOmiLp01KjhIPPH+HrXZJN4Rg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12.20" + } + }, + "node_modules/color-string": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/color-string/-/color-string-2.1.4.tgz", + "integrity": "sha512-Bb6Cq8oq0IjDOe8wJmi4JeNn763Xs9cfrBcaylK1tPypWzyoy2G3l90v9k64kjphl/ZJjPIShFztenRomi8WTg==", + "dev": true, + "license": "MIT", + "dependencies": { + "color-name": "^2.0.0" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/colorette": { + "version": "2.0.20", + "resolved": "https://registry.npmjs.org/colorette/-/colorette-2.0.20.tgz", + "integrity": "sha512-IfEDxwoWIjkeXL1eXcDiow4UbKjhLdq6/EuSVR9GMN7KVH3r9gQ83e73hsz1Nd1T3ijd5xv1wcWRYO+D6kCI2w==", + "dev": true, + "license": "MIT" + }, + "node_modules/combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "dev": true, + "license": "MIT", + "dependencies": { + "delayed-stream": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/comma-separated-tokens": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/comma-separated-tokens/-/comma-separated-tokens-2.0.3.tgz", + "integrity": "sha512-Fu4hJdvzeylCfQPp9SGWidpzrMs7tTrlu6Vb8XGaRGck8QSNZJJp538Wrb60Lax4fPwR64ViY468OIUTbRlGZg==", + "dev": true, + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/commander": { + "version": "14.0.2", + "resolved": "https://registry.npmjs.org/commander/-/commander-14.0.2.tgz", + "integrity": "sha512-TywoWNNRbhoD0BXs1P3ZEScW8W5iKrnbithIl0YH+uCmBd0QpPOA8yc82DS3BIE5Ma6FnBVUsJ7wVUDz4dvOWQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=20" + } + }, + "node_modules/commenting": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/commenting/-/commenting-1.1.0.tgz", + "integrity": "sha512-YeNK4tavZwtH7jEgK1ZINXzLKm6DZdEMfsaaieOsCAN0S8vsY7UeuO3Q7d/M018EFgE+IeUAuBOKkFccBZsUZA==", + "dev": true, + "license": "MIT" + }, + "node_modules/commondir": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/commondir/-/commondir-1.0.1.tgz", + "integrity": "sha512-W9pAhw0ja1Edb5GVdIF1mjZw/ASI0AlShXM83UUGe2DVr5TdAPEA1OA8m/g8zWp9x6On7gqufY+FatDbC3MDQg==", + "dev": true, + "license": "MIT" + }, + "node_modules/concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", + "dev": true, + "license": "MIT" + }, + "node_modules/concat-stream": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-2.0.0.tgz", + "integrity": "sha512-MWufYdFw53ccGjCA+Ol7XJYpAlW6/prSMzuPOTRnJGcGzuhLn4Scrz7qf6o8bROZ514ltazcIFJZevcfbo0x7A==", + "dev": true, + "engines": [ + "node >= 6.0" + ], + "license": "MIT", + "dependencies": { + "buffer-from": "^1.0.0", + "inherits": "^2.0.3", + "readable-stream": "^3.0.2", + "typedarray": "^0.0.6" + } + }, + "node_modules/concurrently": { + "version": "9.2.1", + "resolved": "https://registry.npmjs.org/concurrently/-/concurrently-9.2.1.tgz", + "integrity": "sha512-fsfrO0MxV64Znoy8/l1vVIjjHa29SZyyqPgQBwhiDcaW8wJc2W3XWVOGx4M3oJBnv/zdUZIIp1gDeS98GzP8Ng==", + "dev": true, + "license": "MIT", + "dependencies": { + "chalk": "4.1.2", + "rxjs": "7.8.2", + "shell-quote": "1.8.3", + "supports-color": "8.1.1", + "tree-kill": "1.2.2", + "yargs": "17.7.2" + }, + "bin": { + "conc": "dist/bin/concurrently.js", + "concurrently": "dist/bin/concurrently.js" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/open-cli-tools/concurrently?sponsor=1" + } + }, + "node_modules/concurrently/node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "license": "MIT", + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/concurrently/node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/concurrently/node_modules/chalk/node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "license": "MIT", + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/concurrently/node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/concurrently/node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true, + "license": "MIT" + }, + "node_modules/confbox": { + "version": "0.1.8", + "resolved": "https://registry.npmjs.org/confbox/-/confbox-0.1.8.tgz", + "integrity": "sha512-RMtmw0iFkeR4YV+fUOSucriAQNb9g8zFR52MWCtl+cCZOFRNL6zeB395vPzFhEjjn4fMxXudmELnl/KF/WrK6w==", + "dev": true, + "license": "MIT" + }, + "node_modules/convert-source-map": { + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.9.0.tgz", + "integrity": "sha512-ASFBup0Mz1uyiIjANan1jzLQami9z1PoYSZCiiYW2FczPbenXc45FZdBZLzOT+r6+iciuEModtmCti+hjaAk0A==", + "dev": true, + "license": "MIT" + }, + "node_modules/copy-anything": { + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/copy-anything/-/copy-anything-4.0.5.tgz", + "integrity": "sha512-7Vv6asjS4gMOuILabD3l739tsaxFQmC+a7pLZm02zyvs8p977bL3zEgq3yDk5rn9B0PbYgIv++jmHcuUab4RhA==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-what": "^5.2.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/mesqueeb" + } + }, + "node_modules/core-js": { + "version": "3.38.1", + "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.38.1.tgz", + "integrity": "sha512-OP35aUorbU3Zvlx7pjsFdu1rGNnD4pgw/CWoYzRY3t2EzoVT7shKHY1dlAy3f41cGIO7ZDPQimhGFTlEYkG/Hw==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/core-js" + } + }, + "node_modules/core-js-compat": { + "version": "3.47.0", + "resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.47.0.tgz", + "integrity": "sha512-IGfuznZ/n7Kp9+nypamBhvwdwLsW6KC8IOaURw2doAK5e98AG3acVLdh0woOnEqCfUtS+Vu882JE4k/DAm3ItQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "browserslist": "^4.28.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/core-js" + } + }, + "node_modules/cose-base": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/cose-base/-/cose-base-1.0.3.tgz", + "integrity": "sha512-s9whTXInMSgAp/NVXVNuVxVKzGH2qck3aQlVHxDCdAEPgtMKwc4Wq6/QKhgdEdgbLSi9rBTAcPoRa6JpiG4ksg==", + "dev": true, + "license": "MIT", + "dependencies": { + "layout-base": "^1.0.0" + } + }, + "node_modules/cosmiconfig": { + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-9.0.0.tgz", + "integrity": "sha512-itvL5h8RETACmOTFc4UfIyB2RfEHi71Ax6E/PivVxq9NseKbOWpeyHEOIbmAw1rs8Ak0VursQNww7lf7YtUwzg==", + "dev": true, + "license": "MIT", + "dependencies": { + "env-paths": "^2.2.1", + "import-fresh": "^3.3.0", + "js-yaml": "^4.1.0", + "parse-json": "^5.2.0" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/d-fischer" + }, + "peerDependencies": { + "typescript": ">=4.9.5" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/crelt": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/crelt/-/crelt-1.0.6.tgz", + "integrity": "sha512-VQ2MBenTq1fWZUH9DJNGti7kKv6EeAuYr3cLwxUWhIu1baTaXh4Ib5W2CqHVqib4/MqbYGJqiL3Zb8GJZr3l4g==", + "dev": true, + "license": "MIT" + }, + "node_modules/cross-env": { + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/cross-env/-/cross-env-10.1.0.tgz", + "integrity": "sha512-GsYosgnACZTADcmEyJctkJIoqAhHjttw7RsFrVoJNXbsWWqaq6Ym+7kZjq6mS45O0jij6vtiReppKQEtqWy6Dw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@epic-web/invariant": "^1.0.0", + "cross-spawn": "^7.0.6" + }, + "bin": { + "cross-env": "dist/bin/cross-env.js", + "cross-env-shell": "dist/bin/cross-env-shell.js" + }, + "engines": { + "node": ">=20" + } + }, + "node_modules/cross-spawn": { + "version": "7.0.6", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", + "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==", + "dev": true, + "license": "MIT", + "dependencies": { + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/cssesc": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/cssesc/-/cssesc-3.0.0.tgz", + "integrity": "sha512-/Tb/JcjK111nNScGob5MNtsntNM1aCNUDipB/TkwZFhyDrrE47SOx/18wF2bbjgc3ZzCSKW1T5nt5EbFoAz/Vg==", + "dev": true, + "license": "MIT", + "bin": { + "cssesc": "bin/cssesc" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/csstype": { + "version": "3.2.3", + "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.2.3.tgz", + "integrity": "sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/cytoscape": { + "version": "3.33.1", + "resolved": "https://registry.npmjs.org/cytoscape/-/cytoscape-3.33.1.tgz", + "integrity": "sha512-iJc4TwyANnOGR1OmWhsS9ayRS3s+XQ185FmuHObThD+5AeJCakAAbWv8KimMTt08xCCLNgneQwFp+JRJOr9qGQ==", + "dev": true, + "license": "MIT", + "peer": true, + "engines": { + "node": ">=0.10" + } + }, + "node_modules/cytoscape-cose-bilkent": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/cytoscape-cose-bilkent/-/cytoscape-cose-bilkent-4.1.0.tgz", + "integrity": "sha512-wgQlVIUJF13Quxiv5e1gstZ08rnZj2XaLHGoFMYXz7SkNfCDOOteKBE6SYRfA9WxxI/iBc3ajfDoc6hb/MRAHQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "cose-base": "^1.0.0" + }, + "peerDependencies": { + "cytoscape": "^3.2.0" + } + }, + "node_modules/cytoscape-fcose": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/cytoscape-fcose/-/cytoscape-fcose-2.2.0.tgz", + "integrity": "sha512-ki1/VuRIHFCzxWNrsshHYPs6L7TvLu3DL+TyIGEsRcvVERmxokbf5Gdk7mFxZnTdiGtnA4cfSmjZJMviqSuZrQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "cose-base": "^2.2.0" + }, + "peerDependencies": { + "cytoscape": "^3.2.0" + } + }, + "node_modules/cytoscape-fcose/node_modules/cose-base": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/cose-base/-/cose-base-2.2.0.tgz", + "integrity": "sha512-AzlgcsCbUMymkADOJtQm3wO9S3ltPfYOFD5033keQn9NJzIbtnZj+UdBJe7DYml/8TdbtHJW3j58SOnKhWY/5g==", + "dev": true, + "license": "MIT", + "dependencies": { + "layout-base": "^2.0.0" + } + }, + "node_modules/cytoscape-fcose/node_modules/layout-base": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/layout-base/-/layout-base-2.0.1.tgz", + "integrity": "sha512-dp3s92+uNI1hWIpPGH3jK2kxE2lMjdXdr+DH8ynZHpd6PUlH6x6cbuXnoMmiNumznqaNO31xu9e79F0uuZ0JFg==", + "dev": true, + "license": "MIT" + }, + "node_modules/d3": { + "version": "7.9.0", + "resolved": "https://registry.npmjs.org/d3/-/d3-7.9.0.tgz", + "integrity": "sha512-e1U46jVP+w7Iut8Jt8ri1YsPOvFpg46k+K8TpCb0P+zjCkjkPnV7WzfDJzMHy1LnA+wj5pLT1wjO901gLXeEhA==", + "dev": true, + "license": "ISC", + "dependencies": { + "d3-array": "3", + "d3-axis": "3", + "d3-brush": "3", + "d3-chord": "3", + "d3-color": "3", + "d3-contour": "4", + "d3-delaunay": "6", + "d3-dispatch": "3", + "d3-drag": "3", + "d3-dsv": "3", + "d3-ease": "3", + "d3-fetch": "3", + "d3-force": "3", + "d3-format": "3", + "d3-geo": "3", + "d3-hierarchy": "3", + "d3-interpolate": "3", + "d3-path": "3", + "d3-polygon": "3", + "d3-quadtree": "3", + "d3-random": "3", + "d3-scale": "4", + "d3-scale-chromatic": "3", + "d3-selection": "3", + "d3-shape": "3", + "d3-time": "3", + "d3-time-format": "4", + "d3-timer": "3", + "d3-transition": "3", + "d3-zoom": "3" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-array": { + "version": "3.2.4", + "resolved": "https://registry.npmjs.org/d3-array/-/d3-array-3.2.4.tgz", + "integrity": "sha512-tdQAmyA18i4J7wprpYq8ClcxZy3SC31QMeByyCFyRt7BVHdREQZ5lpzoe5mFEYZUWe+oq8HBvk9JjpibyEV4Jg==", + "dev": true, + "license": "ISC", + "dependencies": { + "internmap": "1 - 2" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-axis": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/d3-axis/-/d3-axis-3.0.0.tgz", + "integrity": "sha512-IH5tgjV4jE/GhHkRV0HiVYPDtvfjHQlQfJHs0usq7M30XcSBvOotpmH1IgkcXsO/5gEQZD43B//fc7SRT5S+xw==", + "dev": true, + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-brush": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/d3-brush/-/d3-brush-3.0.0.tgz", + "integrity": "sha512-ALnjWlVYkXsVIGlOsuWH1+3udkYFI48Ljihfnh8FZPF2QS9o+PzGLBslO0PjzVoHLZ2KCVgAM8NVkXPJB2aNnQ==", + "dev": true, + "license": "ISC", + "dependencies": { + "d3-dispatch": "1 - 3", + "d3-drag": "2 - 3", + "d3-interpolate": "1 - 3", + "d3-selection": "3", + "d3-transition": "3" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-chord": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/d3-chord/-/d3-chord-3.0.1.tgz", + "integrity": "sha512-VE5S6TNa+j8msksl7HwjxMHDM2yNK3XCkusIlpX5kwauBfXuyLAtNg9jCp/iHH61tgI4sb6R/EIMWCqEIdjT/g==", + "dev": true, + "license": "ISC", + "dependencies": { + "d3-path": "1 - 3" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-color": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/d3-color/-/d3-color-3.1.0.tgz", + "integrity": "sha512-zg/chbXyeBtMQ1LbD/WSoW2DpC3I0mpmPdW+ynRTj/x2DAWYrIY7qeZIHidozwV24m4iavr15lNwIwLxRmOxhA==", + "dev": true, + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-contour": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/d3-contour/-/d3-contour-4.0.2.tgz", + "integrity": "sha512-4EzFTRIikzs47RGmdxbeUvLWtGedDUNkTcmzoeyg4sP/dvCexO47AaQL7VKy/gul85TOxw+IBgA8US2xwbToNA==", + "dev": true, + "license": "ISC", + "dependencies": { + "d3-array": "^3.2.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-delaunay": { + "version": "6.0.4", + "resolved": "https://registry.npmjs.org/d3-delaunay/-/d3-delaunay-6.0.4.tgz", + "integrity": "sha512-mdjtIZ1XLAM8bm/hx3WwjfHt6Sggek7qH043O8KEjDXN40xi3vx/6pYSVTwLjEgiXQTbvaouWKynLBiUZ6SK6A==", + "dev": true, + "license": "ISC", + "dependencies": { + "delaunator": "5" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-dispatch": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/d3-dispatch/-/d3-dispatch-3.0.1.tgz", + "integrity": "sha512-rzUyPU/S7rwUflMyLc1ETDeBj0NRuHKKAcvukozwhshr6g6c5d8zh4c2gQjY2bZ0dXeGLWc1PF174P2tVvKhfg==", + "dev": true, + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-drag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/d3-drag/-/d3-drag-3.0.0.tgz", + "integrity": "sha512-pWbUJLdETVA8lQNJecMxoXfH6x+mO2UQo8rSmZ+QqxcbyA3hfeprFgIT//HW2nlHChWeIIMwS2Fq+gEARkhTkg==", + "dev": true, + "license": "ISC", + "dependencies": { + "d3-dispatch": "1 - 3", + "d3-selection": "3" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-dsv": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/d3-dsv/-/d3-dsv-3.0.1.tgz", + "integrity": "sha512-UG6OvdI5afDIFP9w4G0mNq50dSOsXHJaRE8arAS5o9ApWnIElp8GZw1Dun8vP8OyHOZ/QJUKUJwxiiCCnUwm+Q==", + "dev": true, + "license": "ISC", + "dependencies": { + "commander": "7", + "iconv-lite": "0.6", + "rw": "1" + }, + "bin": { + "csv2json": "bin/dsv2json.js", + "csv2tsv": "bin/dsv2dsv.js", + "dsv2dsv": "bin/dsv2dsv.js", + "dsv2json": "bin/dsv2json.js", + "json2csv": "bin/json2dsv.js", + "json2dsv": "bin/json2dsv.js", + "json2tsv": "bin/json2dsv.js", + "tsv2csv": "bin/dsv2dsv.js", + "tsv2json": "bin/dsv2json.js" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-dsv/node_modules/commander": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-7.2.0.tgz", + "integrity": "sha512-QrWXB+ZQSVPmIWIhtEO9H+gwHaMGYiF5ChvoJ+K9ZGHG/sVsa6yiesAD1GC/x46sET00Xlwo1u49RVVVzvcSkw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 10" + } + }, + "node_modules/d3-dsv/node_modules/iconv-lite": { + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz", + "integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==", + "dev": true, + "license": "MIT", + "dependencies": { + "safer-buffer": ">= 2.1.2 < 3.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/d3-ease": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/d3-ease/-/d3-ease-3.0.1.tgz", + "integrity": "sha512-wR/XK3D3XcLIZwpbvQwQ5fK+8Ykds1ip7A2Txe0yxncXSdq1L9skcG7blcedkOX+ZcgxGAmLX1FrRGbADwzi0w==", + "dev": true, + "license": "BSD-3-Clause", + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-fetch": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/d3-fetch/-/d3-fetch-3.0.1.tgz", + "integrity": "sha512-kpkQIM20n3oLVBKGg6oHrUchHM3xODkTzjMoj7aWQFq5QEM+R6E4WkzT5+tojDY7yjez8KgCBRoj4aEr99Fdqw==", + "dev": true, + "license": "ISC", + "dependencies": { + "d3-dsv": "1 - 3" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-force": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/d3-force/-/d3-force-3.0.0.tgz", + "integrity": "sha512-zxV/SsA+U4yte8051P4ECydjD/S+qeYtnaIyAs9tgHCqfguma/aAQDjo85A9Z6EKhBirHRJHXIgJUlffT4wdLg==", + "dev": true, + "license": "ISC", + "dependencies": { + "d3-dispatch": "1 - 3", + "d3-quadtree": "1 - 3", + "d3-timer": "1 - 3" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-format": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/d3-format/-/d3-format-3.1.2.tgz", + "integrity": "sha512-AJDdYOdnyRDV5b6ArilzCPPwc1ejkHcoyFarqlPqT7zRYjhavcT3uSrqcMvsgh2CgoPbK3RCwyHaVyxYcP2Arg==", + "dev": true, + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-geo": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/d3-geo/-/d3-geo-3.1.1.tgz", + "integrity": "sha512-637ln3gXKXOwhalDzinUgY83KzNWZRKbYubaG+fGVuc/dxO64RRljtCTnf5ecMyE1RIdtqpkVcq0IbtU2S8j2Q==", + "dev": true, + "license": "ISC", + "dependencies": { + "d3-array": "2.5.0 - 3" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-hierarchy": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/d3-hierarchy/-/d3-hierarchy-3.1.2.tgz", + "integrity": "sha512-FX/9frcub54beBdugHjDCdikxThEqjnR93Qt7PvQTOHxyiNCAlvMrHhclk3cD5VeAaq9fxmfRp+CnWw9rEMBuA==", + "dev": true, + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-interpolate": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/d3-interpolate/-/d3-interpolate-3.0.1.tgz", + "integrity": "sha512-3bYs1rOD33uo8aqJfKP3JWPAibgw8Zm2+L9vBKEHJ2Rg+viTR7o5Mmv5mZcieN+FRYaAOWX5SJATX6k1PWz72g==", + "dev": true, + "license": "ISC", + "dependencies": { + "d3-color": "1 - 3" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-path": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/d3-path/-/d3-path-3.1.0.tgz", + "integrity": "sha512-p3KP5HCf/bvjBSSKuXid6Zqijx7wIfNW+J/maPs+iwR35at5JCbLUT0LzF1cnjbCHWhqzQTIN2Jpe8pRebIEFQ==", + "dev": true, + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-polygon": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/d3-polygon/-/d3-polygon-3.0.1.tgz", + "integrity": "sha512-3vbA7vXYwfe1SYhED++fPUQlWSYTTGmFmQiany/gdbiWgU/iEyQzyymwL9SkJjFFuCS4902BSzewVGsHHmHtXg==", + "dev": true, + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-quadtree": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/d3-quadtree/-/d3-quadtree-3.0.1.tgz", + "integrity": "sha512-04xDrxQTDTCFwP5H6hRhsRcb9xxv2RzkcsygFzmkSIOJy3PeRJP7sNk3VRIbKXcog561P9oU0/rVH6vDROAgUw==", + "dev": true, + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-random": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/d3-random/-/d3-random-3.0.1.tgz", + "integrity": "sha512-FXMe9GfxTxqd5D6jFsQ+DJ8BJS4E/fT5mqqdjovykEB2oFbTMDVdg1MGFxfQW+FBOGoB++k8swBrgwSHT1cUXQ==", + "dev": true, + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-sankey": { + "version": "0.12.3", + "resolved": "https://registry.npmjs.org/d3-sankey/-/d3-sankey-0.12.3.tgz", + "integrity": "sha512-nQhsBRmM19Ax5xEIPLMY9ZmJ/cDvd1BG3UVvt5h3WRxKg5zGRbvnteTyWAbzeSvlh3tW7ZEmq4VwR5mB3tutmQ==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "d3-array": "1 - 2", + "d3-shape": "^1.2.0" + } + }, + "node_modules/d3-sankey/node_modules/d3-array": { + "version": "2.12.1", + "resolved": "https://registry.npmjs.org/d3-array/-/d3-array-2.12.1.tgz", + "integrity": "sha512-B0ErZK/66mHtEsR1TkPEEkwdy+WDesimkM5gpZr5Dsg54BiTA5RXtYW5qTLIAcekaS9xfZrzBLF/OAkB3Qn1YQ==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "internmap": "^1.0.0" + } + }, + "node_modules/d3-sankey/node_modules/d3-path": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/d3-path/-/d3-path-1.0.9.tgz", + "integrity": "sha512-VLaYcn81dtHVTjEHd8B+pbe9yHWpXKZUC87PzoFmsFrJqgFwDe/qxfp5MlfsfM1V5E/iVt0MmEbWQ7FVIXh/bg==", + "dev": true, + "license": "BSD-3-Clause" + }, + "node_modules/d3-sankey/node_modules/d3-shape": { + "version": "1.3.7", + "resolved": "https://registry.npmjs.org/d3-shape/-/d3-shape-1.3.7.tgz", + "integrity": "sha512-EUkvKjqPFUAZyOlhY5gzCxCeI0Aep04LwIRpsZ/mLFelJiUfnK56jo5JMDSE7yyP2kLSb6LtF+S5chMk7uqPqw==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "d3-path": "1" + } + }, + "node_modules/d3-sankey/node_modules/internmap": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/internmap/-/internmap-1.0.1.tgz", + "integrity": "sha512-lDB5YccMydFBtasVtxnZ3MRBHuaoE8GKsppq+EchKL2U4nK/DmEpPHNH8MZe5HkMtpSiTSOZwfN0tzYjO/lJEw==", + "dev": true, + "license": "ISC" + }, + "node_modules/d3-scale": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/d3-scale/-/d3-scale-4.0.2.tgz", + "integrity": "sha512-GZW464g1SH7ag3Y7hXjf8RoUuAFIqklOAq3MRl4OaWabTFJY9PN/E1YklhXLh+OQ3fM9yS2nOkCoS+WLZ6kvxQ==", + "dev": true, + "license": "ISC", + "dependencies": { + "d3-array": "2.10.0 - 3", + "d3-format": "1 - 3", + "d3-interpolate": "1.2.0 - 3", + "d3-time": "2.1.1 - 3", + "d3-time-format": "2 - 4" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-scale-chromatic": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/d3-scale-chromatic/-/d3-scale-chromatic-3.1.0.tgz", + "integrity": "sha512-A3s5PWiZ9YCXFye1o246KoscMWqf8BsD9eRiJ3He7C9OBaxKhAd5TFCdEx/7VbKtxxTsu//1mMJFrEt572cEyQ==", + "dev": true, + "license": "ISC", + "dependencies": { + "d3-color": "1 - 3", + "d3-interpolate": "1 - 3" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-selection": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/d3-selection/-/d3-selection-3.0.0.tgz", + "integrity": "sha512-fmTRWbNMmsmWq6xJV8D19U/gw/bwrHfNXxrIN+HfZgnzqTHp9jOmKMhsTUjXOJnZOdZY9Q28y4yebKzqDKlxlQ==", + "dev": true, + "license": "ISC", + "peer": true, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-shape": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/d3-shape/-/d3-shape-3.2.0.tgz", + "integrity": "sha512-SaLBuwGm3MOViRq2ABk3eLoxwZELpH6zhl3FbAoJ7Vm1gofKx6El1Ib5z23NUEhF9AsGl7y+dzLe5Cw2AArGTA==", + "dev": true, + "license": "ISC", + "dependencies": { + "d3-path": "^3.1.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-time": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/d3-time/-/d3-time-3.1.0.tgz", + "integrity": "sha512-VqKjzBLejbSMT4IgbmVgDjpkYrNWUYJnbCGo874u7MMKIWsILRX+OpX/gTk8MqjpT1A/c6HY2dCA77ZN0lkQ2Q==", + "dev": true, + "license": "ISC", + "dependencies": { + "d3-array": "2 - 3" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-time-format": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/d3-time-format/-/d3-time-format-4.1.0.tgz", + "integrity": "sha512-dJxPBlzC7NugB2PDLwo9Q8JiTR3M3e4/XANkreKSUxF8vvXKqm1Yfq4Q5dl8budlunRVlUUaDUgFt7eA8D6NLg==", + "dev": true, + "license": "ISC", + "dependencies": { + "d3-time": "1 - 3" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-timer": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/d3-timer/-/d3-timer-3.0.1.tgz", + "integrity": "sha512-ndfJ/JxxMd3nw31uyKoY2naivF+r29V+Lc0svZxe1JvvIRmi8hUsrMvdOwgS1o6uBHmiz91geQ0ylPP0aj1VUA==", + "dev": true, + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-transition": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/d3-transition/-/d3-transition-3.0.1.tgz", + "integrity": "sha512-ApKvfjsSR6tg06xrL434C0WydLr7JewBB3V+/39RMHsaXTOG0zmt/OAXeng5M5LBm0ojmxJrpomQVZ1aPvBL4w==", + "dev": true, + "license": "ISC", + "dependencies": { + "d3-color": "1 - 3", + "d3-dispatch": "1 - 3", + "d3-ease": "1 - 3", + "d3-interpolate": "1 - 3", + "d3-timer": "1 - 3" + }, + "engines": { + "node": ">=12" + }, + "peerDependencies": { + "d3-selection": "2 - 3" + } + }, + "node_modules/d3-zoom": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/d3-zoom/-/d3-zoom-3.0.0.tgz", + "integrity": "sha512-b8AmV3kfQaqWAuacbPuNbL6vahnOJflOhexLzMMNLga62+/nh0JzvJ0aO/5a5MVgUFGS7Hu1P9P03o3fJkDCyw==", + "dev": true, + "license": "ISC", + "dependencies": { + "d3-dispatch": "1 - 3", + "d3-drag": "2 - 3", + "d3-interpolate": "1 - 3", + "d3-selection": "2 - 3", + "d3-transition": "2 - 3" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/dagre-d3-es": { + "version": "7.0.13", + "resolved": "https://registry.npmjs.org/dagre-d3-es/-/dagre-d3-es-7.0.13.tgz", + "integrity": "sha512-efEhnxpSuwpYOKRm/L5KbqoZmNNukHa/Flty4Wp62JRvgH2ojwVgPgdYyr4twpieZnyRDdIH7PY2mopX26+j2Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "d3": "^7.9.0", + "lodash-es": "^4.17.21" + } + }, + "node_modules/data-uri-to-buffer": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-6.0.2.tgz", + "integrity": "sha512-7hvf7/GW8e86rW0ptuwS3OcBGDjIi6SZva7hCyWC0yYry2cOPmLIjXAUHI6DK2HsnwJd9ifmt57i8eV2n4YNpw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 14" + } + }, + "node_modules/date-time": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/date-time/-/date-time-4.0.0.tgz", + "integrity": "sha512-I53Xcn8FBobcKFcNUfZUSE6O3HeRdp1IOLWyHkipi5S07sEZbTwP+xTrPp5Ch6q6iyFkC06B14+bm96FrdfIEA==", + "dev": true, + "license": "MIT", + "dependencies": { + "time-zone": "^2.0.0" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/dayjs": { + "version": "1.11.19", + "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.19.tgz", + "integrity": "sha512-t5EcLVS6QPBNqM2z8fakk/NKel+Xzshgt8FFKAn+qwlD1pzZWxh0nVCrvFK7ZDb6XucZeF9z8C7CBWTRIVApAw==", + "dev": true, + "license": "MIT" + }, + "node_modules/debug": { + "version": "4.4.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz", + "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==", + "dev": true, + "license": "MIT", + "dependencies": { + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/decamelize": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", + "integrity": "sha512-z2S+W9X73hAUUki+N+9Za2lBlun89zigOyGrsax+KUQ6wKW4ZoWpEYBkGhQjwAjjDCkWxhY0VKEhk8wzY7F5cA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/decode-named-character-reference": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/decode-named-character-reference/-/decode-named-character-reference-1.2.0.tgz", + "integrity": "sha512-c6fcElNV6ShtZXmsgNgFFV5tVX2PaV4g+MOAkb8eXHvn6sryJBrZa9r0zV6+dtTyoCKxtDy5tyQ5ZwQuidtd+Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "character-entities": "^2.0.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/deep-is": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz", + "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/deepmerge": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.3.1.tgz", + "integrity": "sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/default-require-extensions": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/default-require-extensions/-/default-require-extensions-3.0.1.tgz", + "integrity": "sha512-eXTJmRbm2TIt9MgWTsOH1wEuhew6XGZcMeGKCtLedIg/NCsg1iBePXkceTdK4Fii7pzmN9tGsZhKzZ4h7O/fxw==", + "dev": true, + "license": "MIT", + "dependencies": { + "strip-bom": "^4.0.0" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/default-shell": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/default-shell/-/default-shell-1.0.1.tgz", + "integrity": "sha512-/Os8tTMPSriNHCsVj3VLjMZblIl1sIg8EXz3qg7C5K+y9calfTA/qzlfPvCQ+LEgLWmtZ9wCnzE1w+S6TPPFyQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=4" + } + }, + "node_modules/define-data-property": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/define-data-property/-/define-data-property-1.1.4.tgz", + "integrity": "sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A==", + "dev": true, + "license": "MIT", + "dependencies": { + "es-define-property": "^1.0.0", + "es-errors": "^1.3.0", + "gopd": "^1.0.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/degenerator": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/degenerator/-/degenerator-5.0.1.tgz", + "integrity": "sha512-TllpMR/t0M5sqCXfj85i4XaAzxmS5tVA16dqvdkMwGmzI+dXLXnw3J+3Vdv7VKw+ThlTMboK6i9rnZ6Nntj5CQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "ast-types": "^0.13.4", + "escodegen": "^2.1.0", + "esprima": "^4.0.1" + }, + "engines": { + "node": ">= 14" + } + }, + "node_modules/delaunator": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/delaunator/-/delaunator-5.0.1.tgz", + "integrity": "sha512-8nvh+XBe96aCESrGOqMp/84b13H9cdKbG5P2ejQCh4d4sK9RL4371qou9drQjMhvnPmhWl5hnmqbEE0fXr9Xnw==", + "dev": true, + "license": "ISC", + "dependencies": { + "robust-predicates": "^3.0.2" + } + }, + "node_modules/delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/dequal": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/dequal/-/dequal-2.0.3.tgz", + "integrity": "sha512-0je+qPKHEMohvfRTCEo3CrPG6cAzAYgmzKyxRiYSSDkS6eGJdyVJm7WaYA5ECaAD9wLB2T4EEeymA5aFVcYXCA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/devlop": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/devlop/-/devlop-1.1.0.tgz", + "integrity": "sha512-RWmIqhcFf1lRYBvNmr7qTNuyCt/7/ns2jbpp1+PalgE/rDQcBT0fioSMUpJ93irlUhC5hrg4cYqe6U+0ImW0rA==", + "dev": true, + "license": "MIT", + "dependencies": { + "dequal": "^2.0.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/devtools-protocol": { + "version": "0.0.1367902", + "resolved": "https://registry.npmjs.org/devtools-protocol/-/devtools-protocol-0.0.1367902.tgz", + "integrity": "sha512-XxtPuC3PGakY6PD7dG66/o8KwJ/LkH2/EKe19Dcw58w53dv4/vSQEkn/SzuyhHE2q4zPgCkxQBxus3VV4ql+Pg==", + "dev": true, + "license": "BSD-3-Clause", + "peer": true + }, + "node_modules/didyoumean": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/didyoumean/-/didyoumean-1.2.2.tgz", + "integrity": "sha512-gxtyfqMg7GKyhQmb056K7M3xszy/myH8w+B4RT+QXBQsvAOdc3XymqDDPHx1BgPgsdAA5SIifona89YtRATDzw==", + "dev": true, + "license": "Apache-2.0" + }, + "node_modules/diff": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-7.0.0.tgz", + "integrity": "sha512-PJWHUb1RFevKCwaFA9RlG5tCd+FO5iRh9A8HEtkmBH2Li03iJriB6m6JIN4rGz3K3JLawI7/veA1xzRKP6ISBw==", + "dev": true, + "license": "BSD-3-Clause", + "engines": { + "node": ">=0.3.1" + } + }, + "node_modules/djv": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/djv/-/djv-2.1.4.tgz", + "integrity": "sha512-giDn+BVbtLlwtkvtcsZjbjzpALHB77skiv3FIu6Wp8b5j8BunDcVJYH0cGUaexp6s0Sb7IkquXXjsLBJhXwQpA==", + "dev": true, + "license": "MIT", + "optionalDependencies": { + "@korzio/djv-draft-04": "^2.0.1" + } + }, + "node_modules/dlv": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/dlv/-/dlv-1.1.3.tgz", + "integrity": "sha512-+HlytyjlPKnIG8XuRG8WvmBP8xs8P71y+SKKS6ZXWoEgLuePxtDoUEiH7WkdePWrQ5JBpE6aoVqfZfJUQkjXwA==", + "dev": true, + "license": "MIT" + }, + "node_modules/dompurify": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/dompurify/-/dompurify-3.3.1.tgz", + "integrity": "sha512-qkdCKzLNtrgPFP1Vo+98FRzJnBRGe4ffyCea9IwHB1fyxPOeNTHpLKYGd4Uk9xvNoH0ZoOjwZxNptyMwqrId1Q==", + "dev": true, + "license": "(MPL-2.0 OR Apache-2.0)", + "optionalDependencies": { + "@types/trusted-types": "^2.0.7" + } + }, + "node_modules/dunder-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz", + "integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.1", + "es-errors": "^1.3.0", + "gopd": "^1.2.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/eastasianwidth": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz", + "integrity": "sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==", + "dev": true, + "license": "MIT" + }, + "node_modules/electron-to-chromium": { + "version": "1.5.267", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.267.tgz", + "integrity": "sha512-0Drusm6MVRXSOJpGbaSVgcQsuB4hEkMpHXaVstcPmhu5LIedxs1xNK/nIxmQIU/RPC0+1/o0AVZfBTkTNJOdUw==", + "dev": true, + "license": "ISC" + }, + "node_modules/emmet": { + "version": "2.4.11", + "resolved": "https://registry.npmjs.org/emmet/-/emmet-2.4.11.tgz", + "integrity": "sha512-23QPJB3moh/U9sT4rQzGgeyyGIrcM+GH5uVYg2C6wZIxAIJq7Ng3QLT79tl8FUwDXhyq9SusfknOrofAKqvgyQ==", + "dev": true, + "license": "MIT", + "workspaces": [ + "./packages/scanner", + "./packages/abbreviation", + "./packages/css-abbreviation", + "./" + ], + "dependencies": { + "@emmetio/abbreviation": "^2.3.3", + "@emmetio/css-abbreviation": "^2.1.8" + } + }, + "node_modules/emnapi": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/emnapi/-/emnapi-1.8.1.tgz", + "integrity": "sha512-34i2BbgHx1LnEO4JCGQYo6h6s4e4KrdWtdTHfllBNLbXSHPmdIHplxKejfabsRK+ukNciqVdalB+fxMibqHdaQ==", + "dev": true, + "license": "MIT", + "peerDependencies": { + "node-addon-api": ">= 6.1.0" + }, + "peerDependenciesMeta": { + "node-addon-api": { + "optional": true + } + } + }, + "node_modules/emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "dev": true, + "license": "MIT" + }, + "node_modules/emoji-regex-xs": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex-xs/-/emoji-regex-xs-1.0.0.tgz", + "integrity": "sha512-LRlerrMYoIDrT6jgpeZ2YYl/L8EulRTt5hQcYjy5AInh7HWXKimpqx68aknBFpGL2+/IcogTcaydJEgaTmOpDg==", + "dev": true, + "license": "MIT" + }, + "node_modules/end-of-stream": { + "version": "1.4.5", + "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.5.tgz", + "integrity": "sha512-ooEGc6HP26xXq/N+GCGOT0JKCLDGrq2bQUZrQ7gyrJiZANJ/8YDTxTpQBXGMn+WbIQXNVpyWymm7KYVICQnyOg==", + "dev": true, + "license": "MIT", + "dependencies": { + "once": "^1.4.0" + } + }, + "node_modules/ensure-posix-path": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ensure-posix-path/-/ensure-posix-path-1.1.1.tgz", + "integrity": "sha512-VWU0/zXzVbeJNXvME/5EmLuEj2TauvoaTz6aFYK1Z92JCBlDlZ3Gu0tuGR42kpW1754ywTs+QB0g5TP0oj9Zaw==", + "dev": true, + "license": "ISC" + }, + "node_modules/entities": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/entities/-/entities-7.0.0.tgz", + "integrity": "sha512-FDWG5cmEYf2Z00IkYRhbFrwIwvdFKH07uV8dvNy0omp/Qb1xcyCWp2UDtcwJF4QZZvk0sLudP6/hAu42TaqVhQ==", + "dev": true, + "license": "BSD-2-Clause", + "engines": { + "node": ">=0.12" + }, + "funding": { + "url": "https://github.com/fb55/entities?sponsor=1" + } + }, + "node_modules/env-paths": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/env-paths/-/env-paths-2.2.1.tgz", + "integrity": "sha512-+h1lkLKhZMTYjog1VEpJNG7NZJWcuc2DDk/qsqSTRRCOXiLjeQ1d1/udrUGhqMxUgAlwKNZ0cf2uqan5GLuS2A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/environment": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/environment/-/environment-1.1.0.tgz", + "integrity": "sha512-xUtoPkMggbz0MPyPiIWr1Kp4aeWJjDZ6SMvURhimjdZgsRuDplF5/s9hcgGhyXMhs+6vpnuoiZ2kFiu3FMnS8Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/error-ex": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.4.tgz", + "integrity": "sha512-sqQamAnR14VgCr1A618A3sGrygcpK+HEbenA/HiEAkkUwcZIIB/tgWqHFxWgOyDh4nB4JCRimh79dR5Ywc9MDQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-arrayish": "^0.2.1" + } + }, + "node_modules/es-define-property": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz", + "integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-errors": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz", + "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-object-atoms": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.1.tgz", + "integrity": "sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA==", + "dev": true, + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-set-tostringtag": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/es-set-tostringtag/-/es-set-tostringtag-2.1.0.tgz", + "integrity": "sha512-j6vWzfrGVfyXxge+O0x5sh6cvxAog0a/4Rdd2K36zCMV5eJ+/+tOAngRO8cODMNWbVRdVlmGZQL2YS3yR8bIUA==", + "dev": true, + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.6", + "has-tostringtag": "^1.0.2", + "hasown": "^2.0.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-toolkit": { + "version": "1.44.0", + "resolved": "https://registry.npmjs.org/es-toolkit/-/es-toolkit-1.44.0.tgz", + "integrity": "sha512-6penXeZalaV88MM3cGkFZZfOoLGWshWWfdy0tWw/RlVVyhvMaWSBTOvXNeiW3e5FwdS5ePW0LGEu17zT139ktg==", + "dev": true, + "license": "MIT", + "workspaces": [ + "docs", + "benchmarks" + ] + }, + "node_modules/es5-shim": { + "version": "4.6.7", + "resolved": "https://registry.npmjs.org/es5-shim/-/es5-shim-4.6.7.tgz", + "integrity": "sha512-jg21/dmlrNQI7JyyA2w7n+yifSxBng0ZralnSfVZjoCawgNTCnS+yBCyVM9DL5itm7SUnDGgv7hcq2XCZX4iRQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/es6-error": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/es6-error/-/es6-error-4.1.1.tgz", + "integrity": "sha512-Um/+FxMr9CISWh0bi5Zv0iOD+4cFh5qLeks1qhAopKVAJw3drgKbKySikp7wGhDL0HPeaja0P5ULZrxLkniUVg==", + "dev": true, + "license": "MIT" + }, + "node_modules/es6-shim": { + "version": "0.35.8", + "resolved": "https://registry.npmjs.org/es6-shim/-/es6-shim-0.35.8.tgz", + "integrity": "sha512-Twf7I2v4/1tLoIXMT8HlqaBSS5H2wQTs2wx3MNYCI8K1R1/clXyCazrcVCPm/FuO9cyV8+leEaZOWD5C253NDg==", + "dev": true, + "license": "MIT" + }, + "node_modules/esbuild": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.27.2.tgz", + "integrity": "sha512-HyNQImnsOC7X9PMNaCIeAm4ISCQXs5a5YasTXVliKv4uuBo1dKrG0A+uQS8M5eXjVMnLg3WgXaKvprHlFJQffw==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "bin": { + "esbuild": "bin/esbuild" + }, + "engines": { + "node": ">=18" + }, + "optionalDependencies": { + "@esbuild/aix-ppc64": "0.27.2", + "@esbuild/android-arm": "0.27.2", + "@esbuild/android-arm64": "0.27.2", + "@esbuild/android-x64": "0.27.2", + "@esbuild/darwin-arm64": "0.27.2", + "@esbuild/darwin-x64": "0.27.2", + "@esbuild/freebsd-arm64": "0.27.2", + "@esbuild/freebsd-x64": "0.27.2", + "@esbuild/linux-arm": "0.27.2", + "@esbuild/linux-arm64": "0.27.2", + "@esbuild/linux-ia32": "0.27.2", + "@esbuild/linux-loong64": "0.27.2", + "@esbuild/linux-mips64el": "0.27.2", + "@esbuild/linux-ppc64": "0.27.2", + "@esbuild/linux-riscv64": "0.27.2", + "@esbuild/linux-s390x": "0.27.2", + "@esbuild/linux-x64": "0.27.2", + "@esbuild/netbsd-arm64": "0.27.2", + "@esbuild/netbsd-x64": "0.27.2", + "@esbuild/openbsd-arm64": "0.27.2", + "@esbuild/openbsd-x64": "0.27.2", + "@esbuild/openharmony-arm64": "0.27.2", + "@esbuild/sunos-x64": "0.27.2", + "@esbuild/win32-arm64": "0.27.2", + "@esbuild/win32-ia32": "0.27.2", + "@esbuild/win32-x64": "0.27.2" + } + }, + "node_modules/escalade": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz", + "integrity": "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/escape-string-regexp": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", + "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/escodegen": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/escodegen/-/escodegen-2.1.0.tgz", + "integrity": "sha512-2NlIDTwUWJN0mRPQOdtQBzbUHvdGY2P1VXSyU83Q3xKxM7WHX2Ql8dKq782Q9TgQUNOLEzEYu9bzLNj1q88I5w==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "esprima": "^4.0.1", + "estraverse": "^5.2.0", + "esutils": "^2.0.2" + }, + "bin": { + "escodegen": "bin/escodegen.js", + "esgenerate": "bin/esgenerate.js" + }, + "engines": { + "node": ">=6.0" + }, + "optionalDependencies": { + "source-map": "~0.6.1" + } + }, + "node_modules/escodegen/node_modules/source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true, + "license": "BSD-3-Clause", + "optional": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/eslint": { + "version": "9.39.2", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-9.39.2.tgz", + "integrity": "sha512-LEyamqS7W5HB3ujJyvi0HQK/dtVINZvd5mAAp9eT5S/ujByGjiZLCzPcHVzuXbpJDJF/cxwHlfceVUDZ2lnSTw==", + "dev": true, + "license": "MIT", + "peer": true, + "dependencies": { + "@eslint-community/eslint-utils": "^4.8.0", + "@eslint-community/regexpp": "^4.12.1", + "@eslint/config-array": "^0.21.1", + "@eslint/config-helpers": "^0.4.2", + "@eslint/core": "^0.17.0", + "@eslint/eslintrc": "^3.3.1", + "@eslint/js": "9.39.2", + "@eslint/plugin-kit": "^0.4.1", + "@humanfs/node": "^0.16.6", + "@humanwhocodes/module-importer": "^1.0.1", + "@humanwhocodes/retry": "^0.4.2", + "@types/estree": "^1.0.6", + "ajv": "^6.12.4", + "chalk": "^4.0.0", + "cross-spawn": "^7.0.6", + "debug": "^4.3.2", + "escape-string-regexp": "^4.0.0", + "eslint-scope": "^8.4.0", + "eslint-visitor-keys": "^4.2.1", + "espree": "^10.4.0", + "esquery": "^1.5.0", + "esutils": "^2.0.2", + "fast-deep-equal": "^3.1.3", + "file-entry-cache": "^8.0.0", + "find-up": "^5.0.0", + "glob-parent": "^6.0.2", + "ignore": "^5.2.0", + "imurmurhash": "^0.1.4", + "is-glob": "^4.0.0", + "json-stable-stringify-without-jsonify": "^1.0.1", + "lodash.merge": "^4.6.2", + "minimatch": "^3.1.2", + "natural-compare": "^1.4.0", + "optionator": "^0.9.3" + }, + "bin": { + "eslint": "bin/eslint.js" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://eslint.org/donate" + }, + "peerDependencies": { + "jiti": "*" + }, + "peerDependenciesMeta": { + "jiti": { + "optional": true + } + } + }, + "node_modules/eslint-config-prettier": { + "version": "10.1.8", + "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-10.1.8.tgz", + "integrity": "sha512-82GZUjRS0p/jganf6q1rEO25VSoHH0hKPCTrgillPjdI/3bgBhAE1QzHrHTizjpRvy6pGAvKjDJtk2pF9NDq8w==", + "dev": true, + "license": "MIT", + "peer": true, + "bin": { + "eslint-config-prettier": "bin/cli.js" + }, + "funding": { + "url": "https://opencollective.com/eslint-config-prettier" + }, + "peerDependencies": { + "eslint": ">=7.0.0" + } + }, + "node_modules/eslint-plugin-prettier": { + "version": "5.5.5", + "resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-5.5.5.tgz", + "integrity": "sha512-hscXkbqUZ2sPithAuLm5MXL+Wph+U7wHngPBv9OMWwlP8iaflyxpjTYZkmdgB4/vPIhemRlBEoLrH7UC1n7aUw==", + "dev": true, + "license": "MIT", + "dependencies": { + "prettier-linter-helpers": "^1.0.1", + "synckit": "^0.11.12" + }, + "engines": { + "node": "^14.18.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint-plugin-prettier" + }, + "peerDependencies": { + "@types/eslint": ">=8.0.0", + "eslint": ">=8.0.0", + "eslint-config-prettier": ">= 7.0.0 <10.0.0 || >=10.1.0", + "prettier": ">=3.0.0" + }, + "peerDependenciesMeta": { + "@types/eslint": { + "optional": true + }, + "eslint-config-prettier": { + "optional": true + } + } + }, + "node_modules/eslint-plugin-unicorn": { + "version": "62.0.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-unicorn/-/eslint-plugin-unicorn-62.0.0.tgz", + "integrity": "sha512-HIlIkGLkvf29YEiS/ImuDZQbP12gWyx5i3C6XrRxMvVdqMroCI9qoVYCoIl17ChN+U89pn9sVwLxhIWj5nEc7g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-validator-identifier": "^7.28.5", + "@eslint-community/eslint-utils": "^4.9.0", + "@eslint/plugin-kit": "^0.4.0", + "change-case": "^5.4.4", + "ci-info": "^4.3.1", + "clean-regexp": "^1.0.0", + "core-js-compat": "^3.46.0", + "esquery": "^1.6.0", + "find-up-simple": "^1.0.1", + "globals": "^16.4.0", + "indent-string": "^5.0.0", + "is-builtin-module": "^5.0.0", + "jsesc": "^3.1.0", + "pluralize": "^8.0.0", + "regexp-tree": "^0.1.27", + "regjsparser": "^0.13.0", + "semver": "^7.7.3", + "strip-indent": "^4.1.1" + }, + "engines": { + "node": "^20.10.0 || >=21.0.0" + }, + "funding": { + "url": "https://github.com/sindresorhus/eslint-plugin-unicorn?sponsor=1" + }, + "peerDependencies": { + "eslint": ">=9.38.0" + } + }, + "node_modules/eslint-plugin-unicorn/node_modules/globals": { + "version": "16.5.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-16.5.0.tgz", + "integrity": "sha512-c/c15i26VrJ4IRt5Z89DnIzCGDn9EcebibhAOjw5ibqEHsE1wLUgkPn9RDmNcUKyU87GeaL633nyJ+pplFR2ZQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/eslint-plugin-vue": { + "version": "10.7.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-vue/-/eslint-plugin-vue-10.7.0.tgz", + "integrity": "sha512-r2XFCK4qlo1sxEoAMIoTTX0PZAdla0JJDt1fmYiworZUX67WeEGqm+JbyAg3M+pGiJ5U6Mp5WQbontXWtIW7TA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@eslint-community/eslint-utils": "^4.4.0", + "natural-compare": "^1.4.0", + "nth-check": "^2.1.1", + "postcss-selector-parser": "^7.1.0", + "semver": "^7.6.3", + "xml-name-validator": "^4.0.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "peerDependencies": { + "@stylistic/eslint-plugin": "^2.0.0 || ^3.0.0 || ^4.0.0 || ^5.0.0", + "@typescript-eslint/parser": "^7.0.0 || ^8.0.0", + "eslint": "^8.57.0 || ^9.0.0", + "vue-eslint-parser": "^10.0.0" + }, + "peerDependenciesMeta": { + "@stylistic/eslint-plugin": { + "optional": true + }, + "@typescript-eslint/parser": { + "optional": true + } + } + }, + "node_modules/eslint-scope": { + "version": "8.4.0", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-8.4.0.tgz", + "integrity": "sha512-sNXOfKCn74rt8RICKMvJS7XKV/Xk9kA7DyJr8mJik3S7Cwgy3qlkkmyS2uQB3jiJg6VNdZd/pDBJu0nvG2NlTg==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "esrecurse": "^4.3.0", + "estraverse": "^5.2.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/eslint-visitor-keys": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.2.1.tgz", + "integrity": "sha512-Uhdk5sfqcee/9H/rCOJikYz67o0a2Tw2hGRPOG2Y1R2dg7brRe1uG0yaNQDHu+TO/uQPF/5eCapvYSmHUjt7JQ==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/eslint/node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "license": "MIT", + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/eslint/node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/eslint/node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/eslint/node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true, + "license": "MIT" + }, + "node_modules/eslint/node_modules/glob-parent": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-6.0.2.tgz", + "integrity": "sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==", + "dev": true, + "license": "ISC", + "dependencies": { + "is-glob": "^4.0.3" + }, + "engines": { + "node": ">=10.13.0" + } + }, + "node_modules/eslint/node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "license": "MIT", + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/espree": { + "version": "10.4.0", + "resolved": "https://registry.npmjs.org/espree/-/espree-10.4.0.tgz", + "integrity": "sha512-j6PAQ2uUr79PZhBjP5C5fhl8e39FmRnOjsD5lGnWrFU8i2G776tBK7+nP8KuQUTTyAZUwfQqXAgrVH5MbH9CYQ==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "acorn": "^8.15.0", + "acorn-jsx": "^5.3.2", + "eslint-visitor-keys": "^4.2.1" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/esprima": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", + "dev": true, + "license": "BSD-2-Clause", + "bin": { + "esparse": "bin/esparse.js", + "esvalidate": "bin/esvalidate.js" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/esquery": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.7.0.tgz", + "integrity": "sha512-Ap6G0WQwcU/LHsvLwON1fAQX9Zp0A2Y6Y/cJBl9r/JbW90Zyg4/zbG6zzKa2OTALELarYHmKu0GhpM5EO+7T0g==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "estraverse": "^5.1.0" + }, + "engines": { + "node": ">=0.10" + } + }, + "node_modules/esrecurse": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.3.0.tgz", + "integrity": "sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "estraverse": "^5.2.0" + }, + "engines": { + "node": ">=4.0" + } + }, + "node_modules/estraverse": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", + "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", + "dev": true, + "license": "BSD-2-Clause", + "engines": { + "node": ">=4.0" + } + }, + "node_modules/estree-walker": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz", + "integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==", + "dev": true, + "license": "MIT" + }, + "node_modules/esutils": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", + "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", + "dev": true, + "license": "BSD-2-Clause", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/eventemitter3": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-5.0.1.tgz", + "integrity": "sha512-GWkBvjiSZK87ELrYOSESUYeVIc9mvLLf/nXalMOS5dYrgZq9o5OVkbZAVM06CVxYsCwH9BDZFPlQTlPA1j4ahA==", + "dev": true, + "license": "MIT" + }, + "node_modules/events-universal": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/events-universal/-/events-universal-1.0.1.tgz", + "integrity": "sha512-LUd5euvbMLpwOF8m6ivPCbhQeSiYVNb8Vs0fQ8QjXo0JTkEHpz8pxdQf0gStltaPpw0Cca8b39KxvK9cfKRiAw==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "bare-events": "^2.7.0" + } + }, + "node_modules/execa": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/execa/-/execa-1.0.0.tgz", + "integrity": "sha512-adbxcyWV46qiHyvSp50TKt05tB4tK3HcmF7/nxfAdhnox83seTDbwnaqKO4sXRy7roHAIFqJP/Rw/AuEbX61LA==", + "dev": true, + "license": "MIT", + "dependencies": { + "cross-spawn": "^6.0.0", + "get-stream": "^4.0.0", + "is-stream": "^1.1.0", + "npm-run-path": "^2.0.0", + "p-finally": "^1.0.0", + "signal-exit": "^3.0.0", + "strip-eof": "^1.0.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/execa/node_modules/cross-spawn": { + "version": "6.0.6", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-6.0.6.tgz", + "integrity": "sha512-VqCUuhcd1iB+dsv8gxPttb5iZh/D0iubSP21g36KXdEuf6I5JiioesUVjpCdHV9MZRUfVFlvwtIUyPfxo5trtw==", + "dev": true, + "license": "MIT", + "dependencies": { + "nice-try": "^1.0.4", + "path-key": "^2.0.1", + "semver": "^5.5.0", + "shebang-command": "^1.2.0", + "which": "^1.2.9" + }, + "engines": { + "node": ">=4.8" + } + }, + "node_modules/execa/node_modules/get-stream": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-4.1.0.tgz", + "integrity": "sha512-GMat4EJ5161kIy2HevLlr4luNjBgvmj413KaQA7jt4V8B4RDsfpHk7WQ9GVqfYyyx8OS/L66Kox+rJRNklLK7w==", + "dev": true, + "license": "MIT", + "dependencies": { + "pump": "^3.0.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/execa/node_modules/is-stream": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", + "integrity": "sha512-uQPm8kcs47jx38atAcWTVxyltQYoPT68y9aWYdV6yWXSyW8mzSat0TL6CiWdZeCdF3KrAvpVtnHbTv4RN+rqdQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/execa/node_modules/path-key": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-2.0.1.tgz", + "integrity": "sha512-fEHGKCSmUSDPv4uoj8AlD+joPlq3peND+HRYyxFz4KPw4z926S/b8rIuFs2FYJg3BwsxJf6A9/3eIdLaYC+9Dw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=4" + } + }, + "node_modules/execa/node_modules/shebang-command": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz", + "integrity": "sha512-EV3L1+UQWGor21OmnvojK36mhg+TyIKDh3iFBKBohr5xeXIhNBcx8oWdgkTEEQ+BEFFYdLRuqMfd5L84N1V5Vg==", + "dev": true, + "license": "MIT", + "dependencies": { + "shebang-regex": "^1.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/execa/node_modules/shebang-regex": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-1.0.0.tgz", + "integrity": "sha512-wpoSFAxys6b2a2wHZ1XpDSgD7N9iVjg29Ph9uV/uaP9Ex/KXlkTZTeddxDPSYQpgvzKLGJke2UU0AzoGCjNIvQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/execa/node_modules/signal-exit": { + "version": "3.0.7", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz", + "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==", + "dev": true, + "license": "ISC" + }, + "node_modules/execa/node_modules/which": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", + "integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==", + "dev": true, + "license": "ISC", + "dependencies": { + "isexe": "^2.0.0" + }, + "bin": { + "which": "bin/which" + } + }, + "node_modules/extract-zip": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extract-zip/-/extract-zip-2.0.1.tgz", + "integrity": "sha512-GDhU9ntwuKyGXdZBUgTIe+vXnWj0fppUEtMDL0+idd5Sta8TGpHssn/eusA9mrPr9qNDym6SxAYZjNvCn/9RBg==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "debug": "^4.1.1", + "get-stream": "^5.1.0", + "yauzl": "^2.10.0" + }, + "bin": { + "extract-zip": "cli.js" + }, + "engines": { + "node": ">= 10.17.0" + }, + "optionalDependencies": { + "@types/yauzl": "^2.9.1" + } + }, + "node_modules/fast-content-type-parse": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/fast-content-type-parse/-/fast-content-type-parse-3.0.0.tgz", + "integrity": "sha512-ZvLdcY8P+N8mGQJahJV5G4U88CSvT1rP8ApL6uETe88MBXrBHAkZlSEySdUlyztF7ccb+Znos3TFqaepHxdhBg==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/fastify" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/fastify" + } + ], + "license": "MIT" + }, + "node_modules/fast-deep-equal": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", + "dev": true, + "license": "MIT" + }, + "node_modules/fast-diff": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/fast-diff/-/fast-diff-1.3.0.tgz", + "integrity": "sha512-VxPP4NqbUjj6MaAOafWeUn2cXWLcCtljklUtZf0Ind4XQ+QPtmA0b18zZy0jIQx+ExRVCR/ZQpBmik5lXshNsw==", + "dev": true, + "license": "Apache-2.0" + }, + "node_modules/fast-fifo": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/fast-fifo/-/fast-fifo-1.3.2.tgz", + "integrity": "sha512-/d9sfos4yxzpwkDkuN7k2SqFKtYNmCTzgfEpz82x34IM9/zc8KGxQoXg1liNC/izpRM/MBdt44Nmx41ZWqk+FQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/fast-glob": { + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.3.tgz", + "integrity": "sha512-7MptL8U0cqcFdzIzwOTHoilX9x5BrNqye7Z/LuC7kCMRio1EMSyqRK3BEAUD7sXRq4iT4AzTVuZdhgQ2TCvYLg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@nodelib/fs.stat": "^2.0.2", + "@nodelib/fs.walk": "^1.2.3", + "glob-parent": "^5.1.2", + "merge2": "^1.3.0", + "micromatch": "^4.0.8" + }, + "engines": { + "node": ">=8.6.0" + } + }, + "node_modules/fast-json-stable-stringify": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", + "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==", + "dev": true, + "license": "MIT" + }, + "node_modules/fast-levenshtein": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", + "integrity": "sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==", + "dev": true, + "license": "MIT" + }, + "node_modules/fast-redact": { + "version": "3.5.0", + "resolved": "https://registry.npmjs.org/fast-redact/-/fast-redact-3.5.0.tgz", + "integrity": "sha512-dwsoQlS7h9hMeYUq1W++23NDcBLV4KqONnITDV9DjfS3q1SgDGVrBdvvTLUotWtPSD7asWDV9/CmsZPy8Hf70A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/fastq": { + "version": "1.20.1", + "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.20.1.tgz", + "integrity": "sha512-GGToxJ/w1x32s/D2EKND7kTil4n8OVk/9mycTc4VDza13lOvpUZTGX3mFSCtV9ksdGBVzvsyAVLM6mHFThxXxw==", + "dev": true, + "license": "ISC", + "dependencies": { + "reusify": "^1.0.4" + } + }, + "node_modules/fd-slicer": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/fd-slicer/-/fd-slicer-1.1.0.tgz", + "integrity": "sha512-cE1qsB/VwyQozZ+q1dGxR8LBYNZeofhEdUNGSMbQD3Gw2lAzX9Zb3uIU6Ebc/Fmyjo9AWWfnn0AUCHqtevs/8g==", + "dev": true, + "license": "MIT", + "dependencies": { + "pend": "~1.2.0" + } + }, + "node_modules/fdir": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz", + "integrity": "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12.0.0" + }, + "peerDependencies": { + "picomatch": "^3 || ^4" + }, + "peerDependenciesMeta": { + "picomatch": { + "optional": true + } + } + }, + "node_modules/file-entry-cache": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-8.0.0.tgz", + "integrity": "sha512-XXTUwCvisa5oacNGRP9SfNtYBNAMi+RPwBFmblZEF7N7swHYQS6/Zfk7SRwx4D5j3CH211YNRco1DEMNVfZCnQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "flat-cache": "^4.0.0" + }, + "engines": { + "node": ">=16.0.0" + } + }, + "node_modules/fill-range": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", + "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", + "dev": true, + "license": "MIT", + "dependencies": { + "to-regex-range": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/find-cache-dir": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/find-cache-dir/-/find-cache-dir-3.3.2.tgz", + "integrity": "sha512-wXZV5emFEjrridIgED11OoUKLxiYjAcqot/NJdAkOhlJ+vGzwhOAfcG5OX1jP+S0PcjEn8bdMJv+g2jwQ3Onig==", + "dev": true, + "license": "MIT", + "dependencies": { + "commondir": "^1.0.1", + "make-dir": "^3.0.2", + "pkg-dir": "^4.1.0" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/avajs/find-cache-dir?sponsor=1" + } + }, + "node_modules/find-up": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", + "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==", + "dev": true, + "license": "MIT", + "dependencies": { + "locate-path": "^6.0.0", + "path-exists": "^4.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/find-up-simple": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/find-up-simple/-/find-up-simple-1.0.1.tgz", + "integrity": "sha512-afd4O7zpqHeRyg4PfDQsXmlDe2PfdHtJt6Akt8jOWaApLOZk5JXs6VMR29lz03pRe9mpykrRCYIYxaJYcfpncQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/find-yarn-workspace-root": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/find-yarn-workspace-root/-/find-yarn-workspace-root-2.0.0.tgz", + "integrity": "sha512-1IMnbjt4KzsQfnhnzNd8wUEgXZ44IzZaZmnLYx7D5FZlaHt2gW20Cri8Q+E/t5tIj4+epTBub+2Zxu/vNILzqQ==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "micromatch": "^4.0.2" + } + }, + "node_modules/fixturify": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/fixturify/-/fixturify-3.0.0.tgz", + "integrity": "sha512-PFOf/DT9/t2NCiVyiQ5cBMJtGZfWh3aeOV8XVqQQOPBlTv8r6l0k75/hm36JOaiJlrWFk/8aYFyOKAvOkrkjrw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/fs-extra": "^9.0.13", + "@types/minimatch": "^3.0.3", + "@types/rimraf": "^3.0.2", + "fs-extra": "^10.1.0", + "matcher-collection": "^2.0.1", + "walk-sync": "^3.0.0" + }, + "engines": { + "node": "14.* || >= 16.*" + } + }, + "node_modules/fixturify/node_modules/fs-extra": { + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz", + "integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "graceful-fs": "^4.2.0", + "jsonfile": "^6.0.1", + "universalify": "^2.0.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/flat": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/flat/-/flat-5.0.2.tgz", + "integrity": "sha512-b6suED+5/3rTpUBdG1gupIl8MPFCAMA0QXwmljLhvCUKcUvdE4gWky9zpuGCcXHOsz4J9wPGNWq6OKpmIzz3hQ==", + "dev": true, + "license": "BSD-3-Clause", + "bin": { + "flat": "cli.js" + } + }, + "node_modules/flat-cache": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-4.0.1.tgz", + "integrity": "sha512-f7ccFPK3SXFHpx15UIGyRJ/FJQctuKZ0zVuN3frBo4HnK3cay9VEW0R6yPYFHC0AgqhukPzKjq22t5DmAyqGyw==", + "dev": true, + "license": "MIT", + "dependencies": { + "flatted": "^3.2.9", + "keyv": "^4.5.4" + }, + "engines": { + "node": ">=16" + } + }, + "node_modules/flatted": { + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.3.3.tgz", + "integrity": "sha512-GX+ysw4PBCz0PzosHDepZGANEuFCMLrnRTiEy9McGjmkCQYwRq4A/X786G/fjM/+OjsWSU1ZrY5qyARZmO/uwg==", + "dev": true, + "license": "ISC" + }, + "node_modules/floating-vue": { + "version": "5.2.2", + "resolved": "https://registry.npmjs.org/floating-vue/-/floating-vue-5.2.2.tgz", + "integrity": "sha512-afW+h2CFafo+7Y9Lvw/xsqjaQlKLdJV7h1fCHfcYQ1C4SVMlu7OAekqWgu5d4SgvkBVU0pVpLlVsrSTBURFRkg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@floating-ui/dom": "~1.1.1", + "vue-resize": "^2.0.0-alpha.1" + }, + "peerDependencies": { + "@nuxt/kit": "^3.2.0", + "vue": "^3.2.0" + }, + "peerDependenciesMeta": { + "@nuxt/kit": { + "optional": true + } + } + }, + "node_modules/floating-vue/node_modules/@floating-ui/dom": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@floating-ui/dom/-/dom-1.1.1.tgz", + "integrity": "sha512-TpIO93+DIujg3g7SykEAGZMDtbJRrmnYRCNYSjJlvIbGhBjRSNTLVbNeDQBrzy9qDgUbiWdc7KA0uZHZ2tJmiw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@floating-ui/core": "^1.1.0" + } + }, + "node_modules/flru": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/flru/-/flru-1.0.2.tgz", + "integrity": "sha512-kWyh8ADvHBFz6ua5xYOPnUroZTT/bwWfrCeL0Wj1dzG4/YOmOcfJ99W8dOVyyynJN35rZ9aCOtHChqQovV7yog==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/focus-trap": { + "version": "7.8.0", + "resolved": "https://registry.npmjs.org/focus-trap/-/focus-trap-7.8.0.tgz", + "integrity": "sha512-/yNdlIkpWbM0ptxno3ONTuf+2g318kh2ez3KSeZN5dZ8YC6AAmgeWz+GasYYiBJPFaYcSAPeu4GfhUaChzIJXA==", + "dev": true, + "license": "MIT", + "peer": true, + "dependencies": { + "tabbable": "^6.4.0" + } + }, + "node_modules/follow-redirects": { + "version": "1.15.11", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.11.tgz", + "integrity": "sha512-deG2P0JfjrTxl50XGCDyfI97ZGVCxIpfKYmfyrQ54n5FO/0gfIES8C/Psl6kWVDolizcaaxZJnTS0QSMxvnsBQ==", + "dev": true, + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/RubenVerborgh" + } + ], + "license": "MIT", + "engines": { + "node": ">=4.0" + }, + "peerDependenciesMeta": { + "debug": { + "optional": true + } + } + }, + "node_modules/foreground-child": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.3.1.tgz", + "integrity": "sha512-gIXjKqtFuWEgzFRJA9WCQeSJLZDjgJUOMCMzxtvFq/37KojM1BFGufqsCy0r4qSQmYLsZYMeyRqzIWOMup03sw==", + "dev": true, + "license": "ISC", + "dependencies": { + "cross-spawn": "^7.0.6", + "signal-exit": "^4.0.1" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/form-data": { + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.5.tgz", + "integrity": "sha512-8RipRLol37bNs2bhoV67fiTEvdTrbMUYcFTiy3+wuuOnUog2QBHCZWXDRijWQfAkhBj2Uf5UnVaiWwA5vdd82w==", + "dev": true, + "license": "MIT", + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "es-set-tostringtag": "^2.1.0", + "hasown": "^2.0.2", + "mime-types": "^2.1.12" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/fromentries": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/fromentries/-/fromentries-1.3.2.tgz", + "integrity": "sha512-cHEpEQHUg0f8XdtZCc2ZAhrHzKzT0MrFUTcvx+hfxYu7rGMDc5SKoXFh+n4YigxsHXRzc6OrCshdR1bWH6HHyg==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT" + }, + "node_modules/fs-extra": { + "version": "11.3.3", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-11.3.3.tgz", + "integrity": "sha512-VWSRii4t0AFm6ixFFmLLx1t7wS1gh+ckoa84aOeapGum0h+EZd1EhEumSB+ZdDLnEPuucsVB9oB7cxJHap6Afg==", + "dev": true, + "license": "MIT", + "dependencies": { + "graceful-fs": "^4.2.0", + "jsonfile": "^6.0.1", + "universalify": "^2.0.0" + }, + "engines": { + "node": ">=14.14" + } + }, + "node_modules/fs-minipass": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-2.1.0.tgz", + "integrity": "sha512-V/JgOLFCS+R6Vcq0slCuaeWEdNC3ouDlJMNIsacH2VtALiu9mV4LPrHc5cDl8k5aw6J8jwgWWpiTo5RYhmIzvg==", + "dev": true, + "license": "ISC", + "dependencies": { + "minipass": "^3.0.0" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/fs-minipass/node_modules/minipass": { + "version": "3.3.6", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-3.3.6.tgz", + "integrity": "sha512-DxiNidxSEK+tHG6zOIklvNOwm3hvCrbUrdtzY74U6HKTJxvIDfOUL5W5P2Ghd3DTkhhKPYGqeNUIh5qcM4YBfw==", + "dev": true, + "license": "ISC", + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/fs-minipass/node_modules/yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", + "dev": true, + "license": "ISC" + }, + "node_modules/fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==", + "dev": true, + "license": "ISC" + }, + "node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "hasInstallScript": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/function-bind": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", + "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/gensync": { + "version": "1.0.0-beta.2", + "resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.2.tgz", + "integrity": "sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/get-caller-file": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", + "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", + "dev": true, + "license": "ISC", + "engines": { + "node": "6.* || 8.* || >= 10.*" + } + }, + "node_modules/get-east-asian-width": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/get-east-asian-width/-/get-east-asian-width-1.4.0.tgz", + "integrity": "sha512-QZjmEOC+IT1uk6Rx0sX22V6uHWVwbdbxf1faPqJ1QhLdGgsRGCZoyaQBm/piRdJy/D2um6hM1UP7ZEeQ4EkP+Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/get-intrinsic": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz", + "integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.2", + "es-define-property": "^1.0.1", + "es-errors": "^1.3.0", + "es-object-atoms": "^1.1.1", + "function-bind": "^1.1.2", + "get-proto": "^1.0.1", + "gopd": "^1.2.0", + "has-symbols": "^1.1.0", + "hasown": "^2.0.2", + "math-intrinsics": "^1.1.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-package-type": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/get-package-type/-/get-package-type-0.1.0.tgz", + "integrity": "sha512-pjzuKtY64GYfWizNAJ0fr9VqttZkNiK2iS430LtIHzjBEr6bX8Am2zm4sW4Ro5wjWW5cAlRL1qAMTcXbjNAO2Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8.0.0" + } + }, + "node_modules/get-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz", + "integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==", + "dev": true, + "license": "MIT", + "dependencies": { + "dunder-proto": "^1.0.1", + "es-object-atoms": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/get-stream": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-5.2.0.tgz", + "integrity": "sha512-nBF+F1rAZVCu/p7rjzgA+Yb4lfYXrpl7a6VmJrU8wF9I1CKvP/QwPNZHnOlwbTkY6dvtFIzFMSyQXbLoTQPRpA==", + "dev": true, + "license": "MIT", + "dependencies": { + "pump": "^3.0.0" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/get-uri": { + "version": "6.0.5", + "resolved": "https://registry.npmjs.org/get-uri/-/get-uri-6.0.5.tgz", + "integrity": "sha512-b1O07XYq8eRuVzBNgJLstU6FYc1tS6wnMtF1I1D9lE8LxZSOGZ7LhxN54yPP6mGw5f2CkXY2BQUL9Fx41qvcIg==", + "dev": true, + "license": "MIT", + "dependencies": { + "basic-ftp": "^5.0.2", + "data-uri-to-buffer": "^6.0.2", + "debug": "^4.3.4" + }, + "engines": { + "node": ">= 14" + } + }, + "node_modules/github-api": { + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/github-api/-/github-api-3.4.0.tgz", + "integrity": "sha512-2yYqYS6Uy4br1nw0D3VrlYWxtGTkUhIZrumBrcBwKdBOzMT8roAe8IvI6kjIOkxqxapKR5GkEsHtz3Du/voOpA==", + "dev": true, + "license": "BSD-3-Clause-Clear", + "dependencies": { + "axios": "^0.21.1", + "debug": "^2.2.0", + "js-base64": "^2.1.9", + "utf8": "^2.1.1" + } + }, + "node_modules/github-api/node_modules/debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "dev": true, + "license": "MIT", + "dependencies": { + "ms": "2.0.0" + } + }, + "node_modules/github-api/node_modules/ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", + "dev": true, + "license": "MIT" + }, + "node_modules/glob": { + "version": "10.5.0", + "resolved": "https://registry.npmjs.org/glob/-/glob-10.5.0.tgz", + "integrity": "sha512-DfXN8DfhJ7NH3Oe7cFmu3NCu1wKbkReJ8TorzSAFbSKrlNaQSKfIzqYqVY8zlbs2NLBbWpRiU52GX2PbaBVNkg==", + "dev": true, + "license": "ISC", + "dependencies": { + "foreground-child": "^3.1.0", + "jackspeak": "^3.1.2", + "minimatch": "^9.0.4", + "minipass": "^7.1.2", + "package-json-from-dist": "^1.0.0", + "path-scurry": "^1.11.1" + }, + "bin": { + "glob": "dist/esm/bin.mjs" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "dev": true, + "license": "ISC", + "dependencies": { + "is-glob": "^4.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/glob-to-regex.js": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/glob-to-regex.js/-/glob-to-regex.js-1.2.0.tgz", + "integrity": "sha512-QMwlOQKU/IzqMUOAZWubUOT8Qft+Y0KQWnX9nK3ch0CJg0tTp4TvGZsTfudYKv2NzoQSyPcnA6TYeIQ3jGichQ==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=10.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/streamich" + }, + "peerDependencies": { + "tslib": "2" + } + }, + "node_modules/glob/node_modules/brace-expansion": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.2.tgz", + "integrity": "sha512-Jt0vHyM+jmUBqojB7E1NIYadt0vI0Qxjxd2TErW94wDz+E2LAm5vKMXXwg6ZZBTHPuUlDgQHKXvjGBdfcF1ZDQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "node_modules/glob/node_modules/minimatch": { + "version": "9.0.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", + "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/globals": { + "version": "17.0.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-17.0.0.tgz", + "integrity": "sha512-gv5BeD2EssA793rlFWVPMMCqefTlpusw6/2TbAVMy0FzcG8wKJn4O+NqJ4+XWmmwrayJgw5TzrmWjFgmz1XPqw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/gopd": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz", + "integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/graceful-fs": { + "version": "4.2.11", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", + "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==", + "dev": true, + "license": "ISC" + }, + "node_modules/hachure-fill": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/hachure-fill/-/hachure-fill-0.5.2.tgz", + "integrity": "sha512-3GKBOn+m2LX9iq+JC1064cSFprJY4jL1jCXTcpnfER5HYE2l/4EfWSGzkPa/ZDBmYI0ZOEj5VHV/eKnPGkHuOg==", + "dev": true, + "license": "MIT" + }, + "node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/has-property-descriptors": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.2.tgz", + "integrity": "sha512-55JNKuIW+vq4Ke1BjOTjM2YctQIvCT7GFzHwmfZPGo5wnrgkid0YQtnAleFSqumZm4az3n2BS+erby5ipJdgrg==", + "dev": true, + "license": "MIT", + "dependencies": { + "es-define-property": "^1.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-symbols": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz", + "integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-tostringtag": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/has-tostringtag/-/has-tostringtag-1.0.2.tgz", + "integrity": "sha512-NqADB8VjPFLM2V0VvHUewwwsw0ZWBaIdgo+ieHtK3hasLz4qeCRjYcqfB6AQrBggRKppKF8L52/VqdVsO47Dlw==", + "dev": true, + "license": "MIT", + "dependencies": { + "has-symbols": "^1.0.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/hasha": { + "version": "5.2.2", + "resolved": "https://registry.npmjs.org/hasha/-/hasha-5.2.2.tgz", + "integrity": "sha512-Hrp5vIK/xr5SkeN2onO32H0MgNZ0f17HRNH39WfL0SYUNOTZ5Lz1TJ8Pajo/87dYGEFlLMm7mIc/k/s6Bvz9HQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-stream": "^2.0.0", + "type-fest": "^0.8.0" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/hasown": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz", + "integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/hast-util-to-html": { + "version": "9.0.5", + "resolved": "https://registry.npmjs.org/hast-util-to-html/-/hast-util-to-html-9.0.5.tgz", + "integrity": "sha512-OguPdidb+fbHQSU4Q4ZiLKnzWo8Wwsf5bZfbvu7//a9oTYoqD/fWpe96NuHkoS9h0ccGOTe0C4NGXdtS0iObOw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/hast": "^3.0.0", + "@types/unist": "^3.0.0", + "ccount": "^2.0.0", + "comma-separated-tokens": "^2.0.0", + "hast-util-whitespace": "^3.0.0", + "html-void-elements": "^3.0.0", + "mdast-util-to-hast": "^13.0.0", + "property-information": "^7.0.0", + "space-separated-tokens": "^2.0.0", + "stringify-entities": "^4.0.0", + "zwitch": "^2.0.4" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/hast-util-whitespace": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/hast-util-whitespace/-/hast-util-whitespace-3.0.0.tgz", + "integrity": "sha512-88JUN06ipLwsnv+dVn+OIYOvAuvBMy/Qoi6O7mQHxdPXpjy+Cd6xRkWwux7DKO+4sYILtLBRIKgsdpS2gQc7qw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/hast": "^3.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/he": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz", + "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==", + "dev": true, + "license": "MIT", + "bin": { + "he": "bin/he" + } + }, + "node_modules/highlight.js": { + "version": "10.7.3", + "resolved": "https://registry.npmjs.org/highlight.js/-/highlight.js-10.7.3.tgz", + "integrity": "sha512-tzcUFauisWKNHaRkN4Wjl/ZA07gENAjFl3J/c480dprkGTg5EQstgaNFqBfUqCq54kZRIEcreTsAgF/m2quD7A==", + "dev": true, + "license": "BSD-3-Clause", + "engines": { + "node": "*" + } + }, + "node_modules/hookable": { + "version": "5.5.3", + "resolved": "https://registry.npmjs.org/hookable/-/hookable-5.5.3.tgz", + "integrity": "sha512-Yc+BQe8SvoXH1643Qez1zqLRmbA5rCL+sSmk6TVos0LWVfNIB7PGncdlId77WzLGSIB5KaWgTaNTs2lNVEI6VQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/html-escaper": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/html-escaper/-/html-escaper-2.0.2.tgz", + "integrity": "sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==", + "dev": true, + "license": "MIT" + }, + "node_modules/html-to-image": { + "version": "1.11.13", + "resolved": "https://registry.npmjs.org/html-to-image/-/html-to-image-1.11.13.tgz", + "integrity": "sha512-cuOPoI7WApyhBElTTb9oqsawRvZ0rHhaHwghRLlTuffoD1B2aDemlCruLeZrUIIdvG7gs9xeELEPm6PhuASqrg==", + "dev": true, + "license": "MIT" + }, + "node_modules/html-void-elements": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/html-void-elements/-/html-void-elements-3.0.0.tgz", + "integrity": "sha512-bEqo66MRXsUGxWHV5IP0PUiAWwoEjba4VCzg0LjFJBpchPaTfyfCKTG6bc5F8ucKec3q5y6qOdGyYTSBEvhCrg==", + "dev": true, + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/http-proxy-agent": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-7.0.2.tgz", + "integrity": "sha512-T1gkAiYYDWYx3V5Bmyu7HcfcvL7mUrTWiM6yOfa3PIphViJ/gFPbvidQ+veqSOHci/PxBcDabeUNCzpOODJZig==", + "dev": true, + "license": "MIT", + "dependencies": { + "agent-base": "^7.1.0", + "debug": "^4.3.4" + }, + "engines": { + "node": ">= 14" + } + }, + "node_modules/https-proxy-agent": { + "version": "7.0.6", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-7.0.6.tgz", + "integrity": "sha512-vK9P5/iUfdl95AI+JVyUuIcVtd4ofvtrOr3HNtM2yxC9bnMbEdp3x01OhQNnjb8IJYi38VlTE3mBXwcfvywuSw==", + "dev": true, + "license": "MIT", + "dependencies": { + "agent-base": "^7.1.2", + "debug": "4" + }, + "engines": { + "node": ">= 14" + } + }, + "node_modules/husky": { + "version": "9.1.7", + "resolved": "https://registry.npmjs.org/husky/-/husky-9.1.7.tgz", + "integrity": "sha512-5gs5ytaNjBrh5Ow3zrvdUUY+0VxIuWVL4i9irt6friV+BqdCfmV11CQTWMiBYWHbXhco+J1kHfTOUkePhCDvMA==", + "dev": true, + "license": "MIT", + "bin": { + "husky": "bin.js" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/typicode" + } + }, + "node_modules/hyperdyperid": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/hyperdyperid/-/hyperdyperid-1.2.0.tgz", + "integrity": "sha512-Y93lCzHYgGWdrJ66yIktxiaGULYc6oGiABxhcO5AufBeOyoIdZF7bIfLaOrbM0iGIOXQQgxxRrFEnb+Y6w1n4A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10.18" + } + }, + "node_modules/iconv-lite": { + "version": "0.7.2", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.7.2.tgz", + "integrity": "sha512-im9DjEDQ55s9fL4EYzOAv0yMqmMBSZp6G0VvFyTMPKWxiSBHUj9NW/qqLmXUwXrrM7AvqSlTCfvqRb0cM8yYqw==", + "dev": true, + "license": "MIT", + "dependencies": { + "safer-buffer": ">= 2.1.2 < 3.0.0" + }, + "engines": { + "node": ">=0.10.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/ieee754": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", + "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "BSD-3-Clause" + }, + "node_modules/ignore": { + "version": "5.3.2", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.2.tgz", + "integrity": "sha512-hsBTNUqQTDwkWtcdYI2i06Y/nUBEsNEDJKjWdigLvegy8kDuJAS8uRlpkkcQpyEXL0Z/pjDy5HBmMjRCJ2gq+g==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 4" + } + }, + "node_modules/ignore-by-default": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/ignore-by-default/-/ignore-by-default-1.0.1.tgz", + "integrity": "sha512-Ius2VYcGNk7T90CppJqcIkS5ooHUZyIQK+ClZfMfMNFEF9VSE73Fq+906u/CWu92x4gzZMWOwfFYckPObzdEbA==", + "dev": true, + "license": "ISC" + }, + "node_modules/immer": { + "version": "10.2.0", + "resolved": "https://registry.npmjs.org/immer/-/immer-10.2.0.tgz", + "integrity": "sha512-d/+XTN3zfODyjr89gM3mPq1WNX2B8pYsu7eORitdwyA2sBubnTl3laYlBk4sXY5FUa5qTZGBDPJICVbvqzjlbw==", + "dev": true, + "license": "MIT", + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/immer" + } + }, + "node_modules/import-fresh": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.1.tgz", + "integrity": "sha512-TR3KfrTZTYLPB6jUjfx6MF9WcWrHL9su5TObK4ZkYgBdWKPOFoSoQIdEuTuR82pmtxH2spWG9h6etwfr1pLBqQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "parent-module": "^1.0.0", + "resolve-from": "^4.0.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/import-meta-resolve": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/import-meta-resolve/-/import-meta-resolve-4.2.0.tgz", + "integrity": "sha512-Iqv2fzaTQN28s/FwZAoFq0ZSs/7hMAHJVX+w8PZl3cY19Pxk6jFFalxQoIfW2826i/fDLXv8IiEZRIT0lDuWcg==", + "dev": true, + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/imurmurhash": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", + "integrity": "sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.8.19" + } + }, + "node_modules/indent-string": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-5.0.0.tgz", + "integrity": "sha512-m6FAo/spmsW2Ab2fU35JTYwtOKa2yAwXSwgjSv1TJzh4Mh7mC3lzAOVLBprb72XsTrgkEIsl7YrFNAiDiRhIGg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", + "deprecated": "This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.", + "dev": true, + "license": "ISC", + "dependencies": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "dev": true, + "license": "ISC" + }, + "node_modules/internmap": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/internmap/-/internmap-2.0.3.tgz", + "integrity": "sha512-5Hh7Y1wQbvY5ooGgPbDaL5iYLAPzMTUrjMulskHLH6wnv/A+1q5rgEaiuqEjB+oxGXIVZs1FF+R/KPN3ZSQYYg==", + "dev": true, + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/interpret": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/interpret/-/interpret-1.4.0.tgz", + "integrity": "sha512-agE4QfB2Lkp9uICn7BAqoscw4SZP9kTE2hxiFI3jBPmXJfdqiahTbUuKGsMoN2GtqL9AxhYioAcVvgsb1HvRbA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/ip-address": { + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/ip-address/-/ip-address-10.1.0.tgz", + "integrity": "sha512-XXADHxXmvT9+CRxhXg56LJovE+bmWnEWB78LB83VZTprKTmaC5QfruXocxzTZ2Kl0DNwKuBdlIhjL8LeY8Sf8Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 12" + } + }, + "node_modules/is-arrayish": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", + "integrity": "sha512-zz06S8t0ozoDXMG+ube26zeCTNXcKIPJZJi8hBrF4idCLms4CG9QtK7qBl1boi5ODzFpjswb5JPmHCbMpjaYzg==", + "dev": true, + "license": "MIT" + }, + "node_modules/is-binary-path": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", + "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", + "dev": true, + "license": "MIT", + "dependencies": { + "binary-extensions": "^2.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/is-builtin-module": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/is-builtin-module/-/is-builtin-module-5.0.0.tgz", + "integrity": "sha512-f4RqJKBUe5rQkJ2eJEJBXSticB3hGbN9j0yxxMQFqIW89Jp9WYFtzfTcRlstDKVUTRzSOTLKRfO9vIztenwtxA==", + "dev": true, + "license": "MIT", + "dependencies": { + "builtin-modules": "^5.0.0" + }, + "engines": { + "node": ">=18.20" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/is-core-module": { + "version": "2.16.1", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.16.1.tgz", + "integrity": "sha512-UfoeMA6fIJ8wTYFEUjelnaGI67v6+N7qXJEvQuIGa99l4xsCruSYOVSQ0uPANn4dAzm8lkYPaKLrrijLq7x23w==", + "dev": true, + "license": "MIT", + "dependencies": { + "hasown": "^2.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-docker": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/is-docker/-/is-docker-2.2.1.tgz", + "integrity": "sha512-F+i2BKsFrH66iaUFc0woD8sLy8getkwTwtOBjvs56Cx4CgJDeKQeqfz8wAYiSb8JOprWhHH5p77PbmYCvvUuXQ==", + "dev": true, + "license": "MIT", + "bin": { + "is-docker": "cli.js" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/is-expression": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/is-expression/-/is-expression-4.0.0.tgz", + "integrity": "sha512-zMIXX63sxzG3XrkHkrAPvm/OVZVSCPNkwMHU8oTX7/U3AL78I0QXCEICXUM13BIa8TYGZ68PiTKfQz3yaTNr4A==", + "dev": true, + "license": "MIT", + "dependencies": { + "acorn": "^7.1.1", + "object-assign": "^4.1.1" + } + }, + "node_modules/is-expression/node_modules/acorn": { + "version": "7.4.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.4.1.tgz", + "integrity": "sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A==", + "dev": true, + "license": "MIT", + "bin": { + "acorn": "bin/acorn" + }, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-fullwidth-code-point": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-5.1.0.tgz", + "integrity": "sha512-5XHYaSyiqADb4RnZ1Bdad6cPp8Toise4TzEjcOYDHZkTCbKgiUl7WTUCpNWHuxmDt91wnsZBc9xinNzopv3JMQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "get-east-asian-width": "^1.3.1" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/is-glob": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", + "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-extglob": "^2.1.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-module": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-module/-/is-module-1.0.0.tgz", + "integrity": "sha512-51ypPSPCoTEIN9dy5Oy+h4pShgJmPCygKfyRCISBI+JoWT/2oJvK8QPxmwv7b/p239jXrm9M1mlQbyKJ5A152g==", + "dev": true, + "license": "MIT" + }, + "node_modules/is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.12.0" + } + }, + "node_modules/is-path-inside": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-3.0.3.tgz", + "integrity": "sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/is-plain-obj": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-1.1.0.tgz", + "integrity": "sha512-yvkRyxmFKEOQ4pNXCmJG5AEQNlXJS5LaONXo5/cLdTZdWvsZ1ioJEonLGAosKlMWE8lwUy/bJzMjcw8az73+Fg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-reference": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/is-reference/-/is-reference-3.0.3.tgz", + "integrity": "sha512-ixkJoqQvAP88E6wLydLGGqCJsrFUnqoH6HnaczB8XmDH1oaWU+xxdptvikTgaEhtZ53Ky6YXiBuUI2WXLMCwjw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/estree": "^1.0.6" + } + }, + "node_modules/is-regex": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.2.1.tgz", + "integrity": "sha512-MjYsKHO5O7mCsmRGxWcLWheFqN9DJ/2TmngvjKXihe6efViPqc274+Fx/4fYj/r03+ESvBdTXK0V6tA3rgez1g==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "gopd": "^1.2.0", + "has-tostringtag": "^1.0.2", + "hasown": "^2.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-stream": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.1.tgz", + "integrity": "sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/is-typedarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", + "integrity": "sha512-cyA56iCMHAh5CdzjJIa4aohJyeO1YbwLi3Jc35MmRU6poroFjIGZzUzupGiRPOjgHg9TLu43xbpwXk523fMxKA==", + "dev": true, + "license": "MIT" + }, + "node_modules/is-unicode-supported": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/is-unicode-supported/-/is-unicode-supported-0.1.0.tgz", + "integrity": "sha512-knxG2q4UC3u8stRGyAVJCOdxFmv5DZiRcdlIaAQXAbSfJya+OhopNotLQrstBhququ4ZpuKbDc/8S6mgXgPFPw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/is-what": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/is-what/-/is-what-5.5.0.tgz", + "integrity": "sha512-oG7cgbmg5kLYae2N5IVd3jm2s+vldjxJzK1pcu9LfpGuQ93MQSzo0okvRna+7y5ifrD+20FE8FvjusyGaz14fw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/mesqueeb" + } + }, + "node_modules/is-windows": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-windows/-/is-windows-1.0.2.tgz", + "integrity": "sha512-eXK1UInq2bPmjyX6e3VHIzMLobc4J94i4AWn+Hpq3OU5KkrRC96OAcR3PRJ/pGu6m8TRnBHP9dkXQVsT/COVIA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-wsl": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-2.2.0.tgz", + "integrity": "sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-docker": "^2.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/isarray": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-2.0.5.tgz", + "integrity": "sha512-xHjhDr3cNBK0BzdUJSPXZntQUx/mwMS5Rw4A7lPJ90XGAO6ISP/ePDNuo0vhqOZU+UD5JoodwCAAoZQd3FeAKw==", + "dev": true, + "license": "MIT" + }, + "node_modules/isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", + "dev": true, + "license": "ISC" + }, + "node_modules/istanbul-lib-coverage": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/istanbul-lib-coverage/-/istanbul-lib-coverage-3.2.2.tgz", + "integrity": "sha512-O8dpsF+r0WV/8MNRKfnmrtCWhuKjxrq2w+jpzBL5UZKTi2LeVWnWOmWRxFlesJONmc+wLAGvKQZEOanko0LFTg==", + "dev": true, + "license": "BSD-3-Clause", + "engines": { + "node": ">=8" + } + }, + "node_modules/istanbul-lib-hook": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/istanbul-lib-hook/-/istanbul-lib-hook-3.0.0.tgz", + "integrity": "sha512-Pt/uge1Q9s+5VAZ+pCo16TYMWPBIl+oaNIjgLQxcX0itS6ueeaA+pEfThZpH8WxhFgCiEb8sAJY6MdUKgiIWaQ==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "append-transform": "^2.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/istanbul-lib-instrument": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/istanbul-lib-instrument/-/istanbul-lib-instrument-6.0.3.tgz", + "integrity": "sha512-Vtgk7L/R2JHyyGW07spoFlB8/lpjiOLTjMdms6AFMraYt3BaJauod/NGrfnVG/y4Ix1JEuMRPDPEj2ua+zz1/Q==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "@babel/core": "^7.23.9", + "@babel/parser": "^7.23.9", + "@istanbuljs/schema": "^0.1.3", + "istanbul-lib-coverage": "^3.2.0", + "semver": "^7.5.4" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/istanbul-lib-processinfo": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/istanbul-lib-processinfo/-/istanbul-lib-processinfo-2.0.3.tgz", + "integrity": "sha512-NkwHbo3E00oybX6NGJi6ar0B29vxyvNwoC7eJ4G4Yq28UfY758Hgn/heV8VRFhevPED4LXfFz0DQ8z/0kw9zMg==", + "dev": true, + "license": "ISC", + "dependencies": { + "archy": "^1.0.0", + "cross-spawn": "^7.0.3", + "istanbul-lib-coverage": "^3.2.0", + "p-map": "^3.0.0", + "rimraf": "^3.0.0", + "uuid": "^8.3.2" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/istanbul-lib-processinfo/node_modules/uuid": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "dev": true, + "license": "MIT", + "bin": { + "uuid": "dist/bin/uuid" + } + }, + "node_modules/istanbul-lib-report": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/istanbul-lib-report/-/istanbul-lib-report-3.0.1.tgz", + "integrity": "sha512-GCfE1mtsHGOELCU8e/Z7YWzpmybrx/+dSTfLrvY8qRmaY6zXTKWn6WQIjaAFw069icm6GVMNkgu0NzI4iPZUNw==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "istanbul-lib-coverage": "^3.0.0", + "make-dir": "^4.0.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/istanbul-lib-report/node_modules/make-dir": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-4.0.0.tgz", + "integrity": "sha512-hXdUTZYIVOt1Ex//jAQi+wTZZpUpwBj/0QsOzqegb3rGMMeJiSEu5xLHnYfBrRV4RH2+OCSOO95Is/7x1WJ4bw==", + "dev": true, + "license": "MIT", + "dependencies": { + "semver": "^7.5.3" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/istanbul-lib-report/node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "license": "MIT", + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/istanbul-lib-source-maps": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/istanbul-lib-source-maps/-/istanbul-lib-source-maps-4.0.1.tgz", + "integrity": "sha512-n3s8EwkdFIJCG3BPKBYvskgXGoy88ARzvegkitk60NxRdwltLOTaH7CUiMRXvwYorl0Q712iEjcWB+fK/MrWVw==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "debug": "^4.1.1", + "istanbul-lib-coverage": "^3.0.0", + "source-map": "^0.6.1" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/istanbul-lib-source-maps/node_modules/source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true, + "license": "BSD-3-Clause", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/istanbul-reports": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/istanbul-reports/-/istanbul-reports-3.2.0.tgz", + "integrity": "sha512-HGYWWS/ehqTV3xN10i23tkPkpH46MLCIMFNCaaKNavAXTF1RkqxawEPtnjnGZ6XKSInBKkiOA5BKS+aZiY3AvA==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "html-escaper": "^2.0.0", + "istanbul-lib-report": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/jackspeak": { + "version": "3.4.3", + "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-3.4.3.tgz", + "integrity": "sha512-OGlZQpz2yfahA/Rd1Y8Cd9SIEsqvXkLVoSw/cgwhnhFMDbsQFeZYoJJ7bIZBS9BcamUW96asq/npPWugM+RQBw==", + "dev": true, + "license": "BlueOak-1.0.0", + "dependencies": { + "@isaacs/cliui": "^8.0.2" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + }, + "optionalDependencies": { + "@pkgjs/parseargs": "^0.11.0" + } + }, + "node_modules/jiti": { + "version": "1.21.7", + "resolved": "https://registry.npmjs.org/jiti/-/jiti-1.21.7.tgz", + "integrity": "sha512-/imKNG4EbWNrVjoNC/1H5/9GFy+tqjGBHCaSsN+P2RnPqjsLmv6UD3Ej+Kj8nBWaRAwyk7kK5ZUc+OEatnTR3A==", + "dev": true, + "license": "MIT", + "peer": true, + "bin": { + "jiti": "bin/jiti.js" + } + }, + "node_modules/jotai": { + "version": "2.16.2", + "resolved": "https://registry.npmjs.org/jotai/-/jotai-2.16.2.tgz", + "integrity": "sha512-DH0lBiTXvewsxtqqwjDW6Hg9JPTDnq9LcOsXSFWCAUEt+qj5ohl9iRVX9zQXPPHKLXCdH+5mGvM28fsXMl17/g==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12.20.0" + }, + "peerDependencies": { + "@babel/core": ">=7.0.0", + "@babel/template": ">=7.0.0", + "@types/react": ">=17.0.0", + "react": ">=17.0.0" + }, + "peerDependenciesMeta": { + "@babel/core": { + "optional": true + }, + "@babel/template": { + "optional": true + }, + "@types/react": { + "optional": true + }, + "react": { + "optional": true + } + } + }, + "node_modules/js-base64": { + "version": "2.6.4", + "resolved": "https://registry.npmjs.org/js-base64/-/js-base64-2.6.4.tgz", + "integrity": "sha512-pZe//GGmwJndub7ZghVHz7vjb2LgC1m8B07Au3eYqeqv9emhESByMXxaEgkUkEqJe87oBbSniGYoQNIBklc7IQ==", + "dev": true, + "license": "BSD-3-Clause" + }, + "node_modules/js-tokens": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/js-yaml": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.1.tgz", + "integrity": "sha512-qQKT4zQxXl8lLwBtHMWwaTcGfFOZviOJet3Oy/xmGk2gZH677CJM9EvtfdSkgWcATZhj/55JZ0rmy3myCT5lsA==", + "dev": true, + "license": "MIT", + "dependencies": { + "argparse": "^2.0.1" + }, + "bin": { + "js-yaml": "bin/js-yaml.js" + } + }, + "node_modules/jsesc": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-3.1.0.tgz", + "integrity": "sha512-/sM3dO2FOzXjKQhJuo0Q173wf2KOo8t4I8vHy6lF9poUp7bKT0/NHE8fPX23PwfhnykfqnC2xRxOnVw5XuGIaA==", + "dev": true, + "license": "MIT", + "bin": { + "jsesc": "bin/jsesc" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/json-buffer": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.1.tgz", + "integrity": "sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/json-parse-even-better-errors": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.1.tgz", + "integrity": "sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w==", + "dev": true, + "license": "MIT" + }, + "node_modules/json-schema-traverse": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", + "dev": true, + "license": "MIT" + }, + "node_modules/json-stable-stringify": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/json-stable-stringify/-/json-stable-stringify-1.3.0.tgz", + "integrity": "sha512-qtYiSSFlwot9XHtF9bD9c7rwKjr+RecWT//ZnPvSmEjpV5mmPOCN4j8UjY5hbjNkOwZ/jQv3J6R1/pL7RwgMsg==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind": "^1.0.8", + "call-bound": "^1.0.4", + "isarray": "^2.0.5", + "jsonify": "^0.0.1", + "object-keys": "^1.1.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/json-stable-stringify-without-jsonify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", + "integrity": "sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==", + "dev": true, + "license": "MIT" + }, + "node_modules/json5": { + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz", + "integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==", + "dev": true, + "license": "MIT", + "bin": { + "json5": "lib/cli.js" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/jsonc-parser": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/jsonc-parser/-/jsonc-parser-2.3.1.tgz", + "integrity": "sha512-H8jvkz1O50L3dMZCsLqiuB2tA7muqbSg1AtGEkN0leAqGjsUzDJir3Zwr02BhqdcITPg3ei3mZ+HjMocAknhhg==", + "dev": true, + "license": "MIT" + }, + "node_modules/jsonfile": { + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.2.0.tgz", + "integrity": "sha512-FGuPw30AdOIUTRMC2OMRtQV+jkVj2cfPqSeWXv1NEAJ1qZ5zb1X6z1mFhbfOB/iy3ssJCD+3KuZ8r8C3uVFlAg==", + "dev": true, + "license": "MIT", + "dependencies": { + "universalify": "^2.0.0" + }, + "optionalDependencies": { + "graceful-fs": "^4.1.6" + } + }, + "node_modules/jsonify": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/jsonify/-/jsonify-0.0.1.tgz", + "integrity": "sha512-2/Ki0GcmuqSrgFyelQq9M05y7PS0mEwuIzrf3f1fPqkVDVRvZrPZtVSMHxdgo8Aq0sxAOb/cr2aqqA3LeWHVPg==", + "dev": true, + "license": "Public Domain", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/jsonlines": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/jsonlines/-/jsonlines-0.1.1.tgz", + "integrity": "sha512-ekDrAGso79Cvf+dtm+mL8OBI2bmAOt3gssYs833De/C9NmIpWDWyUO4zPgB5x2/OhY366dkhgfPMYfwZF7yOZA==", + "dev": true, + "license": "MIT" + }, + "node_modules/katex": { + "version": "0.16.27", + "resolved": "https://registry.npmjs.org/katex/-/katex-0.16.27.tgz", + "integrity": "sha512-aeQoDkuRWSqQN6nSvVCEFvfXdqo1OQiCmmW1kc9xSdjutPv7BGO7pqY9sQRJpMOGrEdfDgF2TfRXe5eUAD2Waw==", + "dev": true, + "funding": [ + "https://opencollective.com/katex", + "https://github.com/sponsors/katex" + ], + "license": "MIT", + "dependencies": { + "commander": "^8.3.0" + }, + "bin": { + "katex": "cli.js" + } + }, + "node_modules/katex/node_modules/commander": { + "version": "8.3.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-8.3.0.tgz", + "integrity": "sha512-OkTL9umf+He2DZkUq8f8J9of7yL6RJKI24dVITBmNfZBmri9zYZQrKkuXiKhyfPSu8tUhnVBB1iKXevvnlR4Ww==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 12" + } + }, + "node_modules/keyv": { + "version": "4.5.4", + "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.5.4.tgz", + "integrity": "sha512-oxVHkHR/EJf2CNXnWxRLW6mg7JyCCUcG0DtEGmL2ctUo1PNTin1PUil+r/+4r5MpVgC/fn1kjsx7mjSujKqIpw==", + "dev": true, + "license": "MIT", + "dependencies": { + "json-buffer": "3.0.1" + } + }, + "node_modules/khroma": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/khroma/-/khroma-2.1.0.tgz", + "integrity": "sha512-Ls993zuzfayK269Svk9hzpeGUKob/sIgZzyHYdjQoAdQetRKpOLj+k/QQQ/6Qi0Yz65mlROrfd+Ev+1+7dz9Kw==", + "dev": true + }, + "node_modules/klaw-sync": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/klaw-sync/-/klaw-sync-6.0.0.tgz", + "integrity": "sha512-nIeuVSzdCCs6TDPTqI8w1Yre34sSq7AkZ4B3sfOBbI2CgVSB4Du4aLQijFU2+lhAFCwt9+42Hel6lQNIv6AntQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "graceful-fs": "^4.1.11" + } + }, + "node_modules/langium": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/langium/-/langium-3.3.1.tgz", + "integrity": "sha512-QJv/h939gDpvT+9SiLVlY7tZC3xB2qK57v0J04Sh9wpMb6MP1q8gB21L3WIo8T5P1MSMg3Ep14L7KkDCFG3y4w==", + "dev": true, + "license": "MIT", + "dependencies": { + "chevrotain": "~11.0.3", + "chevrotain-allstar": "~0.3.0", + "vscode-languageserver": "~9.0.1", + "vscode-languageserver-textdocument": "~1.0.11", + "vscode-uri": "~3.0.8" + }, + "engines": { + "node": ">=16.0.0" + } + }, + "node_modules/langium/node_modules/vscode-uri": { + "version": "3.0.8", + "resolved": "https://registry.npmjs.org/vscode-uri/-/vscode-uri-3.0.8.tgz", + "integrity": "sha512-AyFQ0EVmsOZOlAnxoFOGOq1SQDWAB7C6aqMGS23svWAllfOaxbuFvcT8D1i8z3Gyn8fraVeZNNmN6e9bxxXkKw==", + "dev": true, + "license": "MIT" + }, + "node_modules/layout-base": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/layout-base/-/layout-base-1.0.2.tgz", + "integrity": "sha512-8h2oVEZNktL4BH2JCOI90iD1yXwL6iNW7KcCKT2QZgQJR2vbqDsldCTPRU9NifTCqHZci57XvQQ15YTu+sTYPg==", + "dev": true, + "license": "MIT" + }, + "node_modules/levn": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz", + "integrity": "sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "prelude-ls": "^1.2.1", + "type-check": "~0.4.0" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/lilconfig": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/lilconfig/-/lilconfig-3.1.3.tgz", + "integrity": "sha512-/vlFKAoH5Cgt3Ie+JLhRbwOsCQePABiU3tJ1egGvyQ+33R/vcwM2Zl2QR/LzjsBeItPt3oSVXapn+m4nQDvpzw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/antonk52" + } + }, + "node_modules/lines-and-columns": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/lines-and-columns/-/lines-and-columns-1.2.4.tgz", + "integrity": "sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==", + "dev": true, + "license": "MIT" + }, + "node_modules/linkify-it": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-5.0.0.tgz", + "integrity": "sha512-5aHCbzQRADcdP+ATqnDuhhJ/MRIqDkZX5pyjFHRRysS8vZ5AbqGEoFIb6pYHPZ+L/OC2Lc+xT8uHVVR5CAK/wQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "uc.micro": "^2.0.0" + } + }, + "node_modules/lint-staged": { + "version": "16.2.7", + "resolved": "https://registry.npmjs.org/lint-staged/-/lint-staged-16.2.7.tgz", + "integrity": "sha512-lDIj4RnYmK7/kXMya+qJsmkRFkGolciXjrsZ6PC25GdTfWOAWetR0ZbsNXRAj1EHHImRSalc+whZFg56F5DVow==", + "dev": true, + "license": "MIT", + "dependencies": { + "commander": "^14.0.2", + "listr2": "^9.0.5", + "micromatch": "^4.0.8", + "nano-spawn": "^2.0.0", + "pidtree": "^0.6.0", + "string-argv": "^0.3.2", + "yaml": "^2.8.1" + }, + "bin": { + "lint-staged": "bin/lint-staged.js" + }, + "engines": { + "node": ">=20.17" + }, + "funding": { + "url": "https://opencollective.com/lint-staged" + } + }, + "node_modules/listr2": { + "version": "9.0.5", + "resolved": "https://registry.npmjs.org/listr2/-/listr2-9.0.5.tgz", + "integrity": "sha512-ME4Fb83LgEgwNw96RKNvKV4VTLuXfoKudAmm2lP8Kk87KaMK0/Xrx/aAkMWmT8mDb+3MlFDspfbCs7adjRxA2g==", + "dev": true, + "license": "MIT", + "dependencies": { + "cli-truncate": "^5.0.0", + "colorette": "^2.0.20", + "eventemitter3": "^5.0.1", + "log-update": "^6.1.0", + "rfdc": "^1.4.1", + "wrap-ansi": "^9.0.0" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/listr2/node_modules/emoji-regex": { + "version": "10.6.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-10.6.0.tgz", + "integrity": "sha512-toUI84YS5YmxW219erniWD0CIVOo46xGKColeNQRgOzDorgBi1v4D71/OFzgD9GO2UGKIv1C3Sp8DAn0+j5w7A==", + "dev": true, + "license": "MIT" + }, + "node_modules/listr2/node_modules/string-width": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-7.2.0.tgz", + "integrity": "sha512-tsaTIkKW9b4N+AEj+SVA+WhJzV7/zMhcSu78mLKWSk7cXMOSHsBKFWUs0fWwq8QyK3MgJBQRX6Gbi4kYbdvGkQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "emoji-regex": "^10.3.0", + "get-east-asian-width": "^1.0.0", + "strip-ansi": "^7.1.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/listr2/node_modules/wrap-ansi": { + "version": "9.0.2", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-9.0.2.tgz", + "integrity": "sha512-42AtmgqjV+X1VpdOfyTGOYRi0/zsoLqtXQckTmqTeybT+BDIbM/Guxo7x3pE2vtpr1ok6xRqM9OpBe+Jyoqyww==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-styles": "^6.2.1", + "string-width": "^7.0.0", + "strip-ansi": "^7.1.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } + }, + "node_modules/locate-character": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/locate-character/-/locate-character-3.0.0.tgz", + "integrity": "sha512-SW13ws7BjaeJ6p7Q6CO2nchbYEc3X3J6WrmTTDto7yMPqVSZTUyY5Tjbid+Ab8gLnATtygYtiDIJGQRRn2ZOiA==", + "dev": true, + "license": "MIT" + }, + "node_modules/locate-path": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", + "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", + "dev": true, + "license": "MIT", + "dependencies": { + "p-locate": "^5.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/lodash": { + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", + "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", + "dev": true, + "license": "MIT" + }, + "node_modules/lodash-es": { + "version": "4.17.22", + "resolved": "https://registry.npmjs.org/lodash-es/-/lodash-es-4.17.22.tgz", + "integrity": "sha512-XEawp1t0gxSi9x01glktRZ5HDy0HXqrM0x5pXQM98EaI0NxO6jVM7omDOxsuEo5UIASAnm2bRp1Jt/e0a2XU8Q==", + "dev": true, + "license": "MIT" + }, + "node_modules/lodash.flattendeep": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/lodash.flattendeep/-/lodash.flattendeep-4.4.0.tgz", + "integrity": "sha512-uHaJFihxmJcEX3kT4I23ABqKKalJ/zDrDg0lsFtc1h+3uw49SIJ5beyhx5ExVRti3AvKoOJngIj7xz3oylPdWQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/lodash.merge": { + "version": "4.6.2", + "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", + "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/log-symbols": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.1.0.tgz", + "integrity": "sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg==", + "dev": true, + "license": "MIT", + "dependencies": { + "chalk": "^4.1.0", + "is-unicode-supported": "^0.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/log-symbols/node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "license": "MIT", + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/log-symbols/node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/log-symbols/node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/log-symbols/node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true, + "license": "MIT" + }, + "node_modules/log-symbols/node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "license": "MIT", + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/log-update": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/log-update/-/log-update-6.1.0.tgz", + "integrity": "sha512-9ie8ItPR6tjY5uYJh8K/Zrv/RMZ5VOlOWvtZdEHYSTFKZfIBPQa9tOAEeAWhd+AnIneLJ22w5fjOYtoutpWq5w==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-escapes": "^7.0.0", + "cli-cursor": "^5.0.0", + "slice-ansi": "^7.1.0", + "strip-ansi": "^7.1.0", + "wrap-ansi": "^9.0.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/log-update/node_modules/emoji-regex": { + "version": "10.6.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-10.6.0.tgz", + "integrity": "sha512-toUI84YS5YmxW219erniWD0CIVOo46xGKColeNQRgOzDorgBi1v4D71/OFzgD9GO2UGKIv1C3Sp8DAn0+j5w7A==", + "dev": true, + "license": "MIT" + }, + "node_modules/log-update/node_modules/string-width": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-7.2.0.tgz", + "integrity": "sha512-tsaTIkKW9b4N+AEj+SVA+WhJzV7/zMhcSu78mLKWSk7cXMOSHsBKFWUs0fWwq8QyK3MgJBQRX6Gbi4kYbdvGkQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "emoji-regex": "^10.3.0", + "get-east-asian-width": "^1.0.0", + "strip-ansi": "^7.1.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/log-update/node_modules/wrap-ansi": { + "version": "9.0.2", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-9.0.2.tgz", + "integrity": "sha512-42AtmgqjV+X1VpdOfyTGOYRi0/zsoLqtXQckTmqTeybT+BDIbM/Guxo7x3pE2vtpr1ok6xRqM9OpBe+Jyoqyww==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-styles": "^6.2.1", + "string-width": "^7.0.0", + "strip-ansi": "^7.1.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } + }, + "node_modules/longest-streak": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/longest-streak/-/longest-streak-3.1.0.tgz", + "integrity": "sha512-9Ri+o0JYgehTaVBBDoMqIl8GXtbWg711O3srftcHhZ0dqnETqLaoIK0x17fUw9rFSlK/0NlsKe0Ahhyl5pXE2g==", + "dev": true, + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/loose-envify": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz", + "integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "js-tokens": "^3.0.0 || ^4.0.0" + }, + "bin": { + "loose-envify": "cli.js" + } + }, + "node_modules/lru-cache": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", + "integrity": "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==", + "dev": true, + "license": "ISC", + "dependencies": { + "yallist": "^3.0.2" + } + }, + "node_modules/lz-string": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/lz-string/-/lz-string-1.5.0.tgz", + "integrity": "sha512-h5bgJWpxJNswbU7qCrV0tIKQCaS3blPDrqKWx+QxzuzL1zGUzij9XCWLrSLsJPu5t+eWA/ycetzYAO5IOMcWAQ==", + "dev": true, + "license": "MIT", + "bin": { + "lz-string": "bin/bin.js" + } + }, + "node_modules/magic-string": { + "version": "0.30.21", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.21.tgz", + "integrity": "sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.5.5" + } + }, + "node_modules/make-dir": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz", + "integrity": "sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw==", + "dev": true, + "license": "MIT", + "dependencies": { + "semver": "^6.0.0" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/mark.js": { + "version": "8.11.1", + "resolved": "https://registry.npmjs.org/mark.js/-/mark.js-8.11.1.tgz", + "integrity": "sha512-1I+1qpDt4idfgLQG+BNWmrqku+7/2bi5nLf4YwF8y8zXvmfiTBY3PV3ZibfrjBueCByROpuBjLLFCajqkgYoLQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/markdown-it": { + "version": "14.1.0", + "resolved": "https://registry.npmjs.org/markdown-it/-/markdown-it-14.1.0.tgz", + "integrity": "sha512-a54IwgWPaeBCAAsv13YgmALOF1elABB08FxO9i+r4VFk5Vl4pKokRPeX8u5TCgSsPi6ec1otfLjdOpVcgbpshg==", + "dev": true, + "license": "MIT", + "dependencies": { + "argparse": "^2.0.1", + "entities": "^4.4.0", + "linkify-it": "^5.0.0", + "mdurl": "^2.0.0", + "punycode.js": "^2.3.1", + "uc.micro": "^2.1.0" + }, + "bin": { + "markdown-it": "bin/markdown-it.mjs" + } + }, + "node_modules/markdown-it/node_modules/entities": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz", + "integrity": "sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==", + "dev": true, + "license": "BSD-2-Clause", + "engines": { + "node": ">=0.12" + }, + "funding": { + "url": "https://github.com/fb55/entities?sponsor=1" + } + }, + "node_modules/markdown-table": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/markdown-table/-/markdown-table-3.0.4.tgz", + "integrity": "sha512-wiYz4+JrLyb/DqW2hkFJxP7Vd7JuTDm77fvbM8VfEQdmSMqcImWeeRbHwZjBjIFki/VaMK2BhFi7oUUZeM5bqw==", + "dev": true, + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/marked": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/marked/-/marked-4.3.0.tgz", + "integrity": "sha512-PRsaiG84bK+AMvxziE/lCFss8juXjNaWzVbN5tXAm4XjeaS9NAHhop+PjQxz2A9h8Q4M/xGmzP8vqNwy6JeK0A==", + "dev": true, + "license": "MIT", + "bin": { + "marked": "bin/marked.js" + }, + "engines": { + "node": ">= 12" + } + }, + "node_modules/matcher-collection": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/matcher-collection/-/matcher-collection-2.0.1.tgz", + "integrity": "sha512-daE62nS2ZQsDg9raM0IlZzLmI2u+7ZapXBwdoeBUKAYERPDDIc0qNqA8E0Rp2D+gspKR7BgIFP52GeujaGXWeQ==", + "dev": true, + "license": "ISC", + "dependencies": { + "@types/minimatch": "^3.0.3", + "minimatch": "^3.0.2" + }, + "engines": { + "node": "6.* || 8.* || >= 10.*" + } + }, + "node_modules/math-intrinsics": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz", + "integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/mdast-util-find-and-replace": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/mdast-util-find-and-replace/-/mdast-util-find-and-replace-3.0.2.tgz", + "integrity": "sha512-Tmd1Vg/m3Xz43afeNxDIhWRtFZgM2VLyaf4vSTYwudTyeuTneoL3qtWMA5jeLyz/O1vDJmmV4QuScFCA2tBPwg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/mdast": "^4.0.0", + "escape-string-regexp": "^5.0.0", + "unist-util-is": "^6.0.0", + "unist-util-visit-parents": "^6.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/mdast-util-find-and-replace/node_modules/escape-string-regexp": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-5.0.0.tgz", + "integrity": "sha512-/veY75JbMK4j1yjvuUxuVsiS/hr/4iHs9FTT6cgTexxdE0Ly/glccBAkloH/DofkjRbZU3bnoj38mOmhkZ0lHw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/mdast-util-from-markdown": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/mdast-util-from-markdown/-/mdast-util-from-markdown-2.0.2.tgz", + "integrity": "sha512-uZhTV/8NBuw0WHkPTrCqDOl0zVe1BIng5ZtHoDk49ME1qqcjYmmLmOf0gELgcRMxN4w2iuIeVso5/6QymSrgmA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/mdast": "^4.0.0", + "@types/unist": "^3.0.0", + "decode-named-character-reference": "^1.0.0", + "devlop": "^1.0.0", + "mdast-util-to-string": "^4.0.0", + "micromark": "^4.0.0", + "micromark-util-decode-numeric-character-reference": "^2.0.0", + "micromark-util-decode-string": "^2.0.0", + "micromark-util-normalize-identifier": "^2.0.0", + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0", + "unist-util-stringify-position": "^4.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/mdast-util-gfm": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/mdast-util-gfm/-/mdast-util-gfm-3.1.0.tgz", + "integrity": "sha512-0ulfdQOM3ysHhCJ1p06l0b0VKlhU0wuQs3thxZQagjcjPrlFRqY215uZGHHJan9GEAXd9MbfPjFJz+qMkVR6zQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "mdast-util-from-markdown": "^2.0.0", + "mdast-util-gfm-autolink-literal": "^2.0.0", + "mdast-util-gfm-footnote": "^2.0.0", + "mdast-util-gfm-strikethrough": "^2.0.0", + "mdast-util-gfm-table": "^2.0.0", + "mdast-util-gfm-task-list-item": "^2.0.0", + "mdast-util-to-markdown": "^2.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/mdast-util-gfm-autolink-literal": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/mdast-util-gfm-autolink-literal/-/mdast-util-gfm-autolink-literal-2.0.1.tgz", + "integrity": "sha512-5HVP2MKaP6L+G6YaxPNjuL0BPrq9orG3TsrZ9YXbA3vDw/ACI4MEsnoDpn6ZNm7GnZgtAcONJyPhOP8tNJQavQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/mdast": "^4.0.0", + "ccount": "^2.0.0", + "devlop": "^1.0.0", + "mdast-util-find-and-replace": "^3.0.0", + "micromark-util-character": "^2.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/mdast-util-gfm-footnote": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/mdast-util-gfm-footnote/-/mdast-util-gfm-footnote-2.1.0.tgz", + "integrity": "sha512-sqpDWlsHn7Ac9GNZQMeUzPQSMzR6Wv0WKRNvQRg0KqHh02fpTz69Qc1QSseNX29bhz1ROIyNyxExfawVKTm1GQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/mdast": "^4.0.0", + "devlop": "^1.1.0", + "mdast-util-from-markdown": "^2.0.0", + "mdast-util-to-markdown": "^2.0.0", + "micromark-util-normalize-identifier": "^2.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/mdast-util-gfm-strikethrough": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/mdast-util-gfm-strikethrough/-/mdast-util-gfm-strikethrough-2.0.0.tgz", + "integrity": "sha512-mKKb915TF+OC5ptj5bJ7WFRPdYtuHv0yTRxK2tJvi+BDqbkiG7h7u/9SI89nRAYcmap2xHQL9D+QG/6wSrTtXg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/mdast": "^4.0.0", + "mdast-util-from-markdown": "^2.0.0", + "mdast-util-to-markdown": "^2.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/mdast-util-gfm-table": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/mdast-util-gfm-table/-/mdast-util-gfm-table-2.0.0.tgz", + "integrity": "sha512-78UEvebzz/rJIxLvE7ZtDd/vIQ0RHv+3Mh5DR96p7cS7HsBhYIICDBCu8csTNWNO6tBWfqXPWekRuj2FNOGOZg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/mdast": "^4.0.0", + "devlop": "^1.0.0", + "markdown-table": "^3.0.0", + "mdast-util-from-markdown": "^2.0.0", + "mdast-util-to-markdown": "^2.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/mdast-util-gfm-task-list-item": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/mdast-util-gfm-task-list-item/-/mdast-util-gfm-task-list-item-2.0.0.tgz", + "integrity": "sha512-IrtvNvjxC1o06taBAVJznEnkiHxLFTzgonUdy8hzFVeDun0uTjxxrRGVaNFqkU1wJR3RBPEfsxmU6jDWPofrTQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/mdast": "^4.0.0", + "devlop": "^1.0.0", + "mdast-util-from-markdown": "^2.0.0", + "mdast-util-to-markdown": "^2.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/mdast-util-phrasing": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/mdast-util-phrasing/-/mdast-util-phrasing-4.1.0.tgz", + "integrity": "sha512-TqICwyvJJpBwvGAMZjj4J2n0X8QWp21b9l0o7eXyVJ25YNWYbJDVIyD1bZXE6WtV6RmKJVYmQAKWa0zWOABz2w==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/mdast": "^4.0.0", + "unist-util-is": "^6.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/mdast-util-to-hast": { + "version": "13.2.1", + "resolved": "https://registry.npmjs.org/mdast-util-to-hast/-/mdast-util-to-hast-13.2.1.tgz", + "integrity": "sha512-cctsq2wp5vTsLIcaymblUriiTcZd0CwWtCbLvrOzYCDZoWyMNV8sZ7krj09FSnsiJi3WVsHLM4k6Dq/yaPyCXA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/hast": "^3.0.0", + "@types/mdast": "^4.0.0", + "@ungap/structured-clone": "^1.0.0", + "devlop": "^1.0.0", + "micromark-util-sanitize-uri": "^2.0.0", + "trim-lines": "^3.0.0", + "unist-util-position": "^5.0.0", + "unist-util-visit": "^5.0.0", + "vfile": "^6.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/mdast-util-to-markdown": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/mdast-util-to-markdown/-/mdast-util-to-markdown-2.1.2.tgz", + "integrity": "sha512-xj68wMTvGXVOKonmog6LwyJKrYXZPvlwabaryTjLh9LuvovB/KAH+kvi8Gjj+7rJjsFi23nkUxRQv1KqSroMqA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/mdast": "^4.0.0", + "@types/unist": "^3.0.0", + "longest-streak": "^3.0.0", + "mdast-util-phrasing": "^4.0.0", + "mdast-util-to-string": "^4.0.0", + "micromark-util-classify-character": "^2.0.0", + "micromark-util-decode-string": "^2.0.0", + "unist-util-visit": "^5.0.0", + "zwitch": "^2.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/mdast-util-to-string": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/mdast-util-to-string/-/mdast-util-to-string-4.0.0.tgz", + "integrity": "sha512-0H44vDimn51F0YwvxSJSm0eCDOJTRlmN0R1yBh4HLj9wiV1Dn0QoXGbvFAWj2hSItVTlCmBF1hqKlIyUBVFLPg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/mdast": "^4.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/mdurl": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/mdurl/-/mdurl-2.0.0.tgz", + "integrity": "sha512-Lf+9+2r+Tdp5wXDXC4PcIBjTDtq4UKjCPMQhKIuzpJNW0b96kVqSwW0bT7FhRSfmAiFYgP+SCRvdrDozfh0U5w==", + "dev": true, + "license": "MIT" + }, + "node_modules/memfs": { + "version": "4.52.0", + "resolved": "https://registry.npmjs.org/memfs/-/memfs-4.52.0.tgz", + "integrity": "sha512-dG5ZY1wUCPWhtl4M2mlc7Wx4OrMGtiI79axnScxwDoPR/25biQYrYm21OpKyZcnKv8pvWaX95SRtZgecZ84gFg==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@jsonjoy.com/json-pack": "^1.11.0", + "@jsonjoy.com/util": "^1.9.0", + "glob-to-regex.js": "^1.0.1", + "thingies": "^2.5.0", + "tree-dump": "^1.0.3", + "tslib": "^2.0.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/streamich" + } + }, + "node_modules/merge-options": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/merge-options/-/merge-options-1.0.1.tgz", + "integrity": "sha512-iuPV41VWKWBIOpBsjoxjDZw8/GbSfZ2mk7N1453bwMrfzdrIk7EzBd+8UVR6rkw67th7xnk9Dytl3J+lHPdxvg==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-plain-obj": "^1.1" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/merge2": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz", + "integrity": "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 8" + } + }, + "node_modules/mermaid": { + "version": "11.12.2", + "resolved": "https://registry.npmjs.org/mermaid/-/mermaid-11.12.2.tgz", + "integrity": "sha512-n34QPDPEKmaeCG4WDMGy0OT6PSyxKCfy2pJgShP+Qow2KLrvWjclwbc3yXfSIf4BanqWEhQEpngWwNp/XhZt6w==", + "dev": true, + "license": "MIT", + "peer": true, + "dependencies": { + "@braintree/sanitize-url": "^7.1.1", + "@iconify/utils": "^3.0.1", + "@mermaid-js/parser": "^0.6.3", + "@types/d3": "^7.4.3", + "cytoscape": "^3.29.3", + "cytoscape-cose-bilkent": "^4.1.0", + "cytoscape-fcose": "^2.2.0", + "d3": "^7.9.0", + "d3-sankey": "^0.12.3", + "dagre-d3-es": "7.0.13", + "dayjs": "^1.11.18", + "dompurify": "^3.2.5", + "katex": "^0.16.22", + "khroma": "^2.1.0", + "lodash-es": "^4.17.21", + "marked": "^16.2.1", + "roughjs": "^4.6.6", + "stylis": "^4.3.6", + "ts-dedent": "^2.2.0", + "uuid": "^11.1.0" + } + }, + "node_modules/mermaid/node_modules/marked": { + "version": "16.4.2", + "resolved": "https://registry.npmjs.org/marked/-/marked-16.4.2.tgz", + "integrity": "sha512-TI3V8YYWvkVf3KJe1dRkpnjs68JUPyEa5vjKrp1XEEJUAOaQc+Qj+L1qWbPd0SJuAdQkFU0h73sXXqwDYxsiDA==", + "dev": true, + "license": "MIT", + "bin": { + "marked": "bin/marked.js" + }, + "engines": { + "node": ">= 20" + } + }, + "node_modules/micromark": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/micromark/-/micromark-4.0.2.tgz", + "integrity": "sha512-zpe98Q6kvavpCr1NPVSCMebCKfD7CA2NqZ+rykeNhONIJBpc1tFKt9hucLGwha3jNTNI8lHpctWJWoimVF4PfA==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "@types/debug": "^4.0.0", + "debug": "^4.0.0", + "decode-named-character-reference": "^1.0.0", + "devlop": "^1.0.0", + "micromark-core-commonmark": "^2.0.0", + "micromark-factory-space": "^2.0.0", + "micromark-util-character": "^2.0.0", + "micromark-util-chunked": "^2.0.0", + "micromark-util-combine-extensions": "^2.0.0", + "micromark-util-decode-numeric-character-reference": "^2.0.0", + "micromark-util-encode": "^2.0.0", + "micromark-util-normalize-identifier": "^2.0.0", + "micromark-util-resolve-all": "^2.0.0", + "micromark-util-sanitize-uri": "^2.0.0", + "micromark-util-subtokenize": "^2.0.0", + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" + } + }, + "node_modules/micromark-core-commonmark": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/micromark-core-commonmark/-/micromark-core-commonmark-2.0.3.tgz", + "integrity": "sha512-RDBrHEMSxVFLg6xvnXmb1Ayr2WzLAWjeSATAoxwKYJV94TeNavgoIdA0a9ytzDSVzBy2YKFK+emCPOEibLeCrg==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "decode-named-character-reference": "^1.0.0", + "devlop": "^1.0.0", + "micromark-factory-destination": "^2.0.0", + "micromark-factory-label": "^2.0.0", + "micromark-factory-space": "^2.0.0", + "micromark-factory-title": "^2.0.0", + "micromark-factory-whitespace": "^2.0.0", + "micromark-util-character": "^2.0.0", + "micromark-util-chunked": "^2.0.0", + "micromark-util-classify-character": "^2.0.0", + "micromark-util-html-tag-name": "^2.0.0", + "micromark-util-normalize-identifier": "^2.0.0", + "micromark-util-resolve-all": "^2.0.0", + "micromark-util-subtokenize": "^2.0.0", + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" + } + }, + "node_modules/micromark-factory-destination": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-factory-destination/-/micromark-factory-destination-2.0.1.tgz", + "integrity": "sha512-Xe6rDdJlkmbFRExpTOmRj9N3MaWmbAgdpSrBQvCFqhezUn4AHqJHbaEnfbVYYiexVSs//tqOdY/DxhjdCiJnIA==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "micromark-util-character": "^2.0.0", + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" + } + }, + "node_modules/micromark-factory-label": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-factory-label/-/micromark-factory-label-2.0.1.tgz", + "integrity": "sha512-VFMekyQExqIW7xIChcXn4ok29YE3rnuyveW3wZQWWqF4Nv9Wk5rgJ99KzPvHjkmPXF93FXIbBp6YdW3t71/7Vg==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "devlop": "^1.0.0", + "micromark-util-character": "^2.0.0", + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" + } + }, + "node_modules/micromark-factory-space": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-factory-space/-/micromark-factory-space-2.0.1.tgz", + "integrity": "sha512-zRkxjtBxxLd2Sc0d+fbnEunsTj46SWXgXciZmHq0kDYGnck/ZSGj9/wULTV95uoeYiK5hRXP2mJ98Uo4cq/LQg==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "micromark-util-character": "^2.0.0", + "micromark-util-types": "^2.0.0" + } + }, + "node_modules/micromark-factory-title": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-factory-title/-/micromark-factory-title-2.0.1.tgz", + "integrity": "sha512-5bZ+3CjhAd9eChYTHsjy6TGxpOFSKgKKJPJxr293jTbfry2KDoWkhBb6TcPVB4NmzaPhMs1Frm9AZH7OD4Cjzw==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "micromark-factory-space": "^2.0.0", + "micromark-util-character": "^2.0.0", + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" + } + }, + "node_modules/micromark-factory-whitespace": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-factory-whitespace/-/micromark-factory-whitespace-2.0.1.tgz", + "integrity": "sha512-Ob0nuZ3PKt/n0hORHyvoD9uZhr+Za8sFoP+OnMcnWK5lngSzALgQYKMr9RJVOWLqQYuyn6ulqGWSXdwf6F80lQ==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "micromark-factory-space": "^2.0.0", + "micromark-util-character": "^2.0.0", + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" + } + }, + "node_modules/micromark-util-character": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/micromark-util-character/-/micromark-util-character-2.1.1.tgz", + "integrity": "sha512-wv8tdUTJ3thSFFFJKtpYKOYiGP2+v96Hvk4Tu8KpCAsTMs6yi+nVmGh1syvSCsaxz45J6Jbw+9DD6g97+NV67Q==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" + } + }, + "node_modules/micromark-util-chunked": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-util-chunked/-/micromark-util-chunked-2.0.1.tgz", + "integrity": "sha512-QUNFEOPELfmvv+4xiNg2sRYeS/P84pTW0TCgP5zc9FpXetHY0ab7SxKyAQCNCc1eK0459uoLI1y5oO5Vc1dbhA==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "micromark-util-symbol": "^2.0.0" + } + }, + "node_modules/micromark-util-classify-character": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-util-classify-character/-/micromark-util-classify-character-2.0.1.tgz", + "integrity": "sha512-K0kHzM6afW/MbeWYWLjoHQv1sgg2Q9EccHEDzSkxiP/EaagNzCm7T/WMKZ3rjMbvIpvBiZgwR3dKMygtA4mG1Q==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "micromark-util-character": "^2.0.0", + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" + } + }, + "node_modules/micromark-util-combine-extensions": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-util-combine-extensions/-/micromark-util-combine-extensions-2.0.1.tgz", + "integrity": "sha512-OnAnH8Ujmy59JcyZw8JSbK9cGpdVY44NKgSM7E9Eh7DiLS2E9RNQf0dONaGDzEG9yjEl5hcqeIsj4hfRkLH/Bg==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "micromark-util-chunked": "^2.0.0", + "micromark-util-types": "^2.0.0" + } + }, + "node_modules/micromark-util-decode-numeric-character-reference": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/micromark-util-decode-numeric-character-reference/-/micromark-util-decode-numeric-character-reference-2.0.2.tgz", + "integrity": "sha512-ccUbYk6CwVdkmCQMyr64dXz42EfHGkPQlBj5p7YVGzq8I7CtjXZJrubAYezf7Rp+bjPseiROqe7G6foFd+lEuw==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "micromark-util-symbol": "^2.0.0" + } + }, + "node_modules/micromark-util-decode-string": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-util-decode-string/-/micromark-util-decode-string-2.0.1.tgz", + "integrity": "sha512-nDV/77Fj6eH1ynwscYTOsbK7rR//Uj0bZXBwJZRfaLEJ1iGBR6kIfNmlNqaqJf649EP0F3NWNdeJi03elllNUQ==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "decode-named-character-reference": "^1.0.0", + "micromark-util-character": "^2.0.0", + "micromark-util-decode-numeric-character-reference": "^2.0.0", + "micromark-util-symbol": "^2.0.0" + } + }, + "node_modules/micromark-util-encode": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-util-encode/-/micromark-util-encode-2.0.1.tgz", + "integrity": "sha512-c3cVx2y4KqUnwopcO9b/SCdo2O67LwJJ/UyqGfbigahfegL9myoEFoDYZgkT7f36T0bLrM9hZTAaAyH+PCAXjw==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT" + }, + "node_modules/micromark-util-html-tag-name": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-util-html-tag-name/-/micromark-util-html-tag-name-2.0.1.tgz", + "integrity": "sha512-2cNEiYDhCWKI+Gs9T0Tiysk136SnR13hhO8yW6BGNyhOC4qYFnwF1nKfD3HFAIXA5c45RrIG1ub11GiXeYd1xA==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT" + }, + "node_modules/micromark-util-normalize-identifier": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-util-normalize-identifier/-/micromark-util-normalize-identifier-2.0.1.tgz", + "integrity": "sha512-sxPqmo70LyARJs0w2UclACPUUEqltCkJ6PhKdMIDuJ3gSf/Q+/GIe3WKl0Ijb/GyH9lOpUkRAO2wp0GVkLvS9Q==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "micromark-util-symbol": "^2.0.0" + } + }, + "node_modules/micromark-util-resolve-all": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-util-resolve-all/-/micromark-util-resolve-all-2.0.1.tgz", + "integrity": "sha512-VdQyxFWFT2/FGJgwQnJYbe1jjQoNTS4RjglmSjTUlpUMa95Htx9NHeYW4rGDJzbjvCsl9eLjMQwGeElsqmzcHg==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "micromark-util-types": "^2.0.0" + } + }, + "node_modules/micromark-util-sanitize-uri": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-util-sanitize-uri/-/micromark-util-sanitize-uri-2.0.1.tgz", + "integrity": "sha512-9N9IomZ/YuGGZZmQec1MbgxtlgougxTodVwDzzEouPKo3qFWvymFHWcnDi2vzV1ff6kas9ucW+o3yzJK9YB1AQ==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "micromark-util-character": "^2.0.0", + "micromark-util-encode": "^2.0.0", + "micromark-util-symbol": "^2.0.0" + } + }, + "node_modules/micromark-util-subtokenize": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/micromark-util-subtokenize/-/micromark-util-subtokenize-2.1.0.tgz", + "integrity": "sha512-XQLu552iSctvnEcgXw6+Sx75GflAPNED1qx7eBJ+wydBb2KCbRZe+NwvIEEMM83uml1+2WSXpBAcp9IUCgCYWA==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "devlop": "^1.0.0", + "micromark-util-chunked": "^2.0.0", + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" + } + }, + "node_modules/micromark-util-symbol": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-util-symbol/-/micromark-util-symbol-2.0.1.tgz", + "integrity": "sha512-vs5t8Apaud9N28kgCrRUdEed4UJ+wWNvicHLPxCa9ENlYuAY31M0ETy5y1vA33YoNPDFTghEbnh6efaE8h4x0Q==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT" + }, + "node_modules/micromark-util-types": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/micromark-util-types/-/micromark-util-types-2.0.2.tgz", + "integrity": "sha512-Yw0ECSpJoViF1qTU4DC6NwtC4aWGt1EkzaQB8KPPyCRR8z9TWeV0HbEFGTO+ZY1wB22zmxnJqhPyTpOVCpeHTA==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT" + }, + "node_modules/micromatch": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz", + "integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==", + "dev": true, + "license": "MIT", + "dependencies": { + "braces": "^3.0.3", + "picomatch": "^2.3.1" + }, + "engines": { + "node": ">=8.6" + } + }, + "node_modules/micromatch/node_modules/picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "dev": true, + "license": "MIT", + "dependencies": { + "mime-db": "1.52.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mimic-function": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/mimic-function/-/mimic-function-5.0.1.tgz", + "integrity": "sha512-VP79XUPxV2CigYP3jWwAUFSku2aKqBH7uTAapFWCBqutsbmDo96KY5o8uh6U+/YSIn5OxJnXp73beVkpqMIGhA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/minimist": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", + "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/minipass": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.2.tgz", + "integrity": "sha512-qOOzS1cBTWYF4BH8fVePDBOO9iptMnGUEZwNc/cMWnTV2nVLZ7VoNWEPHkYczZA0pdoA7dl6e7FL659nX9S2aw==", + "dev": true, + "license": "ISC", + "engines": { + "node": ">=16 || 14 >=14.17" + } + }, + "node_modules/minisearch": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/minisearch/-/minisearch-7.2.0.tgz", + "integrity": "sha512-dqT2XBYUOZOiC5t2HRnwADjhNS2cecp9u+TJRiJ1Qp/f5qjkeT5APcGPjHw+bz89Ms8Jp+cG4AlE+QZ/QnDglg==", + "dev": true, + "license": "MIT" + }, + "node_modules/minizlib": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/minizlib/-/minizlib-2.1.2.tgz", + "integrity": "sha512-bAxsR8BVfj60DWXHE3u30oHzfl4G7khkSuPW+qvpd7jFRHm7dLxOjUk1EHACJ/hxLY8phGJ0YhYHZo7jil7Qdg==", + "dev": true, + "license": "MIT", + "dependencies": { + "minipass": "^3.0.0", + "yallist": "^4.0.0" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/minizlib/node_modules/minipass": { + "version": "3.3.6", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-3.3.6.tgz", + "integrity": "sha512-DxiNidxSEK+tHG6zOIklvNOwm3hvCrbUrdtzY74U6HKTJxvIDfOUL5W5P2Ghd3DTkhhKPYGqeNUIh5qcM4YBfw==", + "dev": true, + "license": "ISC", + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/minizlib/node_modules/yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", + "dev": true, + "license": "ISC" + }, + "node_modules/mitt": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/mitt/-/mitt-3.0.1.tgz", + "integrity": "sha512-vKivATfr97l2/QBCYAkXYDbrIWPM2IIKEl7YPhjCvKlG3kE2gm+uBo6nEXK3M5/Ffh/FLpKExzOQ3JJoJGFKBw==", + "dev": true, + "license": "MIT" + }, + "node_modules/mkdirp": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", + "integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==", + "dev": true, + "license": "MIT", + "bin": { + "mkdirp": "bin/cmd.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/mlly": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/mlly/-/mlly-1.8.0.tgz", + "integrity": "sha512-l8D9ODSRWLe2KHJSifWGwBqpTZXIXTeo8mlKjY+E2HAakaTeNpqAyBZ8GSqLzHgw4XmHmC8whvpjJNMbFZN7/g==", + "dev": true, + "license": "MIT", + "dependencies": { + "acorn": "^8.15.0", + "pathe": "^2.0.3", + "pkg-types": "^1.3.1", + "ufo": "^1.6.1" + } + }, + "node_modules/mocha": { + "version": "11.7.5", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-11.7.5.tgz", + "integrity": "sha512-mTT6RgopEYABzXWFx+GcJ+ZQ32kp4fMf0xvpZIIfSq9Z8lC/++MtcCnQ9t5FP2veYEP95FIYSvW+U9fV4xrlig==", + "dev": true, + "license": "MIT", + "dependencies": { + "browser-stdout": "^1.3.1", + "chokidar": "^4.0.1", + "debug": "^4.3.5", + "diff": "^7.0.0", + "escape-string-regexp": "^4.0.0", + "find-up": "^5.0.0", + "glob": "^10.4.5", + "he": "^1.2.0", + "is-path-inside": "^3.0.3", + "js-yaml": "^4.1.0", + "log-symbols": "^4.1.0", + "minimatch": "^9.0.5", + "ms": "^2.1.3", + "picocolors": "^1.1.1", + "serialize-javascript": "^6.0.2", + "strip-json-comments": "^3.1.1", + "supports-color": "^8.1.1", + "workerpool": "^9.2.0", + "yargs": "^17.7.2", + "yargs-parser": "^21.1.1", + "yargs-unparser": "^2.0.0" + }, + "bin": { + "_mocha": "bin/_mocha", + "mocha": "bin/mocha.js" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + } + }, + "node_modules/mocha/node_modules/brace-expansion": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.2.tgz", + "integrity": "sha512-Jt0vHyM+jmUBqojB7E1NIYadt0vI0Qxjxd2TErW94wDz+E2LAm5vKMXXwg6ZZBTHPuUlDgQHKXvjGBdfcF1ZDQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "node_modules/mocha/node_modules/chokidar": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-4.0.3.tgz", + "integrity": "sha512-Qgzu8kfBvo+cA4962jnP1KkS6Dop5NS6g7R5LFYJr4b8Ub94PPQXUksCw9PvXoeXPRRddRNC5C1JQUR2SMGtnA==", + "dev": true, + "license": "MIT", + "dependencies": { + "readdirp": "^4.0.1" + }, + "engines": { + "node": ">= 14.16.0" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/mocha/node_modules/minimatch": { + "version": "9.0.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", + "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/mocha/node_modules/readdirp": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-4.1.2.tgz", + "integrity": "sha512-GDhwkLfywWL2s6vEjyhri+eXmfH6j1L7JE27WhqLeYzoh/A3DBaYGEj2H/HFZCn/kMfim73FXxEJTw06WtxQwg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 14.18.0" + }, + "funding": { + "type": "individual", + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/moment": { + "version": "2.30.1", + "resolved": "https://registry.npmjs.org/moment/-/moment-2.30.1.tgz", + "integrity": "sha512-uEmtNhbDOrWPFS+hdjFCBfy9f2YoyzRpwcl+DqpC6taX21FzsTLQVbMV/W7PzNSX6x/bhC1zA3c2UQ5NzH6how==", + "dev": true, + "license": "MIT", + "engines": { + "node": "*" + } + }, + "node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "dev": true, + "license": "MIT" + }, + "node_modules/muggle-string": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/muggle-string/-/muggle-string-0.4.1.tgz", + "integrity": "sha512-VNTrAak/KhO2i8dqqnqnAHOa3cYBwXEZe9h+D5h/1ZqFSTEFHdM65lR7RoIqq3tBBYavsOXV84NoHXZ0AkPyqQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/mute-stream": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-2.0.0.tgz", + "integrity": "sha512-WWdIxpyjEn+FhQJQQv9aQAYlHoNVdzIzUySNV1gHUPDSdZJ3yZn7pAAbQcV7B56Mvu881q9FZV+0Vx2xC44VWA==", + "dev": true, + "license": "ISC", + "engines": { + "node": "^18.17.0 || >=20.5.0" + } + }, + "node_modules/mz": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/mz/-/mz-2.7.0.tgz", + "integrity": "sha512-z81GNO7nnYMEhrGh9LeymoE4+Yr0Wn5McHIZMK5cfQCl+NDX08sCZgUc9/6MHni9IWuFLm1Z3HTCXu2z9fN62Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "any-promise": "^1.0.0", + "object-assign": "^4.0.1", + "thenify-all": "^1.0.0" + } + }, + "node_modules/nano-spawn": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/nano-spawn/-/nano-spawn-2.0.0.tgz", + "integrity": "sha512-tacvGzUY5o2D8CBh2rrwxyNojUsZNU2zjNTzKQrkgGJQTbGAfArVWXSKMBokBeeg6C7OLRGUEyoFlYbfeWQIqw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=20.17" + }, + "funding": { + "url": "https://github.com/sindresorhus/nano-spawn?sponsor=1" + } + }, + "node_modules/nanoid": { + "version": "3.3.11", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.11.tgz", + "integrity": "sha512-N8SpfPUnUp1bK+PMYW8qSWdl9U+wwNWI4QKxOYDy9JAro3WMX7p2OeVRF9v+347pnakNevPmiHhNmZ2HbFA76w==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "bin": { + "nanoid": "bin/nanoid.cjs" + }, + "engines": { + "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" + } + }, + "node_modules/natural-compare": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", + "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==", + "dev": true, + "license": "MIT" + }, + "node_modules/netmask": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/netmask/-/netmask-2.0.2.tgz", + "integrity": "sha512-dBpDMdxv9Irdq66304OLfEmQ9tbNRFnFTuZiLo+bD+r332bBmMJ8GBLXklIXXgxd3+v9+KUnZaUR5PJMa75Gsg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4.0" + } + }, + "node_modules/nice-try": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/nice-try/-/nice-try-1.0.5.tgz", + "integrity": "sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/node-preload": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/node-preload/-/node-preload-0.2.1.tgz", + "integrity": "sha512-RM5oyBy45cLEoHqCeh+MNuFAxO0vTFBLskvQbOKnEE7YTTSN4tbN8QWDIPQ6L+WvKsB/qLEGpYe2ZZ9d4W9OIQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "process-on-spawn": "^1.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/node-releases": { + "version": "2.0.27", + "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.27.tgz", + "integrity": "sha512-nmh3lCkYZ3grZvqcCH+fjmQ7X+H0OeZgP40OierEaAptX4XofMh5kwNbWh7lBduUzCcV/8kZ+NDLCwm2iorIlA==", + "dev": true, + "license": "MIT" + }, + "node_modules/nodemon": { + "version": "3.1.11", + "resolved": "https://registry.npmjs.org/nodemon/-/nodemon-3.1.11.tgz", + "integrity": "sha512-is96t8F/1//UHAjNPHpbsNY46ELPpftGUoSVNXwUfMk/qdjSylYrWSu1XavVTBOn526kFiOR733ATgNBCQyH0g==", + "dev": true, + "license": "MIT", + "dependencies": { + "chokidar": "^3.5.2", + "debug": "^4", + "ignore-by-default": "^1.0.1", + "minimatch": "^3.1.2", + "pstree.remy": "^1.1.8", + "semver": "^7.5.3", + "simple-update-notifier": "^2.0.0", + "supports-color": "^5.5.0", + "touch": "^3.1.0", + "undefsafe": "^2.0.5" + }, + "bin": { + "nodemon": "bin/nodemon.js" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/nodemon" + } + }, + "node_modules/nodemon/node_modules/has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=4" + } + }, + "node_modules/nodemon/node_modules/supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dev": true, + "license": "MIT", + "dependencies": { + "has-flag": "^3.0.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/normalize-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", + "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/npm-audit-resolver": { + "version": "3.0.0-RC.0", + "resolved": "https://registry.npmjs.org/npm-audit-resolver/-/npm-audit-resolver-3.0.0-RC.0.tgz", + "integrity": "sha512-UuVC7HIxGMhkGfj6IcilBO0cbAz/Y1OhRHA49g3ccpyHDy6Bpd4nkPnLe+xuyZmTgUjiac509IIN3YPVdJZ0Hw==", + "dev": true, + "license": "Apache 2.0", + "dependencies": { + "@npmcli/ci-detect": "^3.0.2", + "audit-resolve-core": "^3.0.0-3", + "chalk": "^4.1.2", + "concat-stream": "^2.0.0", + "djv": "^2.1.4", + "jsonlines": "^0.1.1", + "read": "^2.0.0", + "spawn-shell": "^2.1.0", + "yargs-parser": "^21.1.1", + "yargs-unparser": "^2.0.0" + }, + "bin": { + "check-audit": "check.js", + "resolve-audit": "resolve.js" + } + }, + "node_modules/npm-audit-resolver/node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "license": "MIT", + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/npm-audit-resolver/node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/npm-audit-resolver/node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/npm-audit-resolver/node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true, + "license": "MIT" + }, + "node_modules/npm-audit-resolver/node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "license": "MIT", + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/npm-run-path": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-2.0.2.tgz", + "integrity": "sha512-lJxZYlT4DW/bRUtFh1MQIWqmLwQfAxnqWG4HhEdjMlkrJYnJn0Jrr2u3mgxqaWsdiBc76TYkTG/mhrnYTuzfHw==", + "dev": true, + "license": "MIT", + "dependencies": { + "path-key": "^2.0.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/npm-run-path/node_modules/path-key": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-2.0.1.tgz", + "integrity": "sha512-fEHGKCSmUSDPv4uoj8AlD+joPlq3peND+HRYyxFz4KPw4z926S/b8rIuFs2FYJg3BwsxJf6A9/3eIdLaYC+9Dw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=4" + } + }, + "node_modules/nth-check": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/nth-check/-/nth-check-2.1.1.tgz", + "integrity": "sha512-lqjrjmaOoAnWfMmBPL+XNnynZh2+swxiX3WUE0s4yEHI6m+AwrK2UZOimIRl3X/4QctVqS8AiZjFqyOGrMXb/w==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "boolbase": "^1.0.0" + }, + "funding": { + "url": "https://github.com/fb55/nth-check?sponsor=1" + } + }, + "node_modules/nyc": { + "version": "17.1.0", + "resolved": "https://registry.npmjs.org/nyc/-/nyc-17.1.0.tgz", + "integrity": "sha512-U42vQ4czpKa0QdI1hu950XuNhYqgoM+ZF1HT+VuUHL9hPfDPVvNQyltmMqdE9bUHMVa+8yNbc3QKTj8zQhlVxQ==", + "dev": true, + "license": "ISC", + "dependencies": { + "@istanbuljs/load-nyc-config": "^1.0.0", + "@istanbuljs/schema": "^0.1.2", + "caching-transform": "^4.0.0", + "convert-source-map": "^1.7.0", + "decamelize": "^1.2.0", + "find-cache-dir": "^3.2.0", + "find-up": "^4.1.0", + "foreground-child": "^3.3.0", + "get-package-type": "^0.1.0", + "glob": "^7.1.6", + "istanbul-lib-coverage": "^3.0.0", + "istanbul-lib-hook": "^3.0.0", + "istanbul-lib-instrument": "^6.0.2", + "istanbul-lib-processinfo": "^2.0.2", + "istanbul-lib-report": "^3.0.0", + "istanbul-lib-source-maps": "^4.0.0", + "istanbul-reports": "^3.0.2", + "make-dir": "^3.0.0", + "node-preload": "^0.2.1", + "p-map": "^3.0.0", + "process-on-spawn": "^1.0.0", + "resolve-from": "^5.0.0", + "rimraf": "^3.0.0", + "signal-exit": "^3.0.2", + "spawn-wrap": "^2.0.0", + "test-exclude": "^6.0.0", + "yargs": "^15.0.2" + }, + "bin": { + "nyc": "bin/nyc.js" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/nyc/node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/nyc/node_modules/cliui": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-6.0.0.tgz", + "integrity": "sha512-t6wbgtoCXvAzst7QgXxJYqPt0usEfbgQdftEPbLL/cvv6HPE5VgvqCuAIDR0NgU52ds6rFwqrgakNLrHEjCbrQ==", + "dev": true, + "license": "ISC", + "dependencies": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.0", + "wrap-ansi": "^6.2.0" + } + }, + "node_modules/nyc/node_modules/find-up": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", + "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", + "dev": true, + "license": "MIT", + "dependencies": { + "locate-path": "^5.0.0", + "path-exists": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/nyc/node_modules/glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "deprecated": "Glob versions prior to v9 are no longer supported", + "dev": true, + "license": "ISC", + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/nyc/node_modules/is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/nyc/node_modules/locate-path": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", + "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", + "dev": true, + "license": "MIT", + "dependencies": { + "p-locate": "^4.1.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/nyc/node_modules/p-limit": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", + "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", + "dev": true, + "license": "MIT", + "dependencies": { + "p-try": "^2.0.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/nyc/node_modules/p-locate": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", + "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", + "dev": true, + "license": "MIT", + "dependencies": { + "p-limit": "^2.2.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/nyc/node_modules/resolve-from": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-5.0.0.tgz", + "integrity": "sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/nyc/node_modules/signal-exit": { + "version": "3.0.7", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz", + "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==", + "dev": true, + "license": "ISC" + }, + "node_modules/nyc/node_modules/string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dev": true, + "license": "MIT", + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/nyc/node_modules/strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/nyc/node_modules/y18n": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.3.tgz", + "integrity": "sha512-JKhqTOwSrqNA1NY5lSztJ1GrBiUodLMmIZuLiDaMRJ+itFd+ABVE8XBjOvIWL+rSqNDC74LCSFmlb/U4UZ4hJQ==", + "dev": true, + "license": "ISC" + }, + "node_modules/nyc/node_modules/yargs": { + "version": "15.4.1", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-15.4.1.tgz", + "integrity": "sha512-aePbxDmcYW++PaqBsJ+HYUFwCdv4LVvdnhBy78E57PIor8/OVvhMrADFFEDh8DHDFRv/O9i3lPhsENjO7QX0+A==", + "dev": true, + "license": "MIT", + "dependencies": { + "cliui": "^6.0.0", + "decamelize": "^1.2.0", "find-up": "^4.1.0", + "get-caller-file": "^2.0.1", + "require-directory": "^2.1.1", + "require-main-filename": "^2.0.0", + "set-blocking": "^2.0.0", + "string-width": "^4.2.0", + "which-module": "^2.0.0", + "y18n": "^4.0.0", + "yargs-parser": "^18.1.2" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/nyc/node_modules/yargs-parser": { + "version": "18.1.3", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-18.1.3.tgz", + "integrity": "sha512-o50j0JeToy/4K6OZcaQmW6lyXXKhq7csREXcDwk2omFPJEwUNOVtJKvmDr9EI1fAJZUyZcRF7kxGBWmRXudrCQ==", + "dev": true, + "license": "ISC", + "dependencies": { + "camelcase": "^5.0.0", + "decamelize": "^1.2.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/object-hash": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/object-hash/-/object-hash-3.0.0.tgz", + "integrity": "sha512-RSn9F68PjH9HqtltsSnqYC1XXoWe9Bju5+213R98cNGttag9q9yAOTzdbsqvIa7aNm5WffBZFpWYr2aWrklWAw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 6" + } + }, + "node_modules/object-keys": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz", + "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/ohash": { + "version": "2.0.11", + "resolved": "https://registry.npmjs.org/ohash/-/ohash-2.0.11.tgz", + "integrity": "sha512-RdR9FQrFwNBNXAr4GixM8YaRZRJ5PUWbKYbE5eOsrwAjJW0q2REGcf79oYPsLyskQCZG1PLN+S/K1V00joZAoQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/on-exit-leak-free": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/on-exit-leak-free/-/on-exit-leak-free-2.1.2.tgz", + "integrity": "sha512-0eJJY6hXLGf1udHwfNftBqH+g73EU4B504nZeKpz1sYRKafAghwxEJunB2O7rDZkL4PGfsMVnTXZ2EjibbqcsA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "dev": true, + "license": "ISC", + "dependencies": { + "wrappy": "1" + } + }, + "node_modules/onetime": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/onetime/-/onetime-7.0.0.tgz", + "integrity": "sha512-VXJjc87FScF88uafS3JllDgvAm+c/Slfz06lorj2uAY34rlUu0Nt+v8wreiImcrgAjjIHp1rXpTDlLOGw29WwQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "mimic-function": "^5.0.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/oniguruma-parser": { + "version": "0.12.1", + "resolved": "https://registry.npmjs.org/oniguruma-parser/-/oniguruma-parser-0.12.1.tgz", + "integrity": "sha512-8Unqkvk1RYc6yq2WBYRj4hdnsAxVze8i7iPfQr8e4uSP3tRv0rpZcbGUDvxfQQcdwHt/e9PrMvGCsa8OqG9X3w==", + "dev": true, + "license": "MIT" + }, + "node_modules/oniguruma-to-es": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/oniguruma-to-es/-/oniguruma-to-es-4.3.4.tgz", + "integrity": "sha512-3VhUGN3w2eYxnTzHn+ikMI+fp/96KoRSVK9/kMTcFqj1NRDh2IhQCKvYxDnWePKRXY/AqH+Fuiyb7VHSzBjHfA==", + "dev": true, + "license": "MIT", + "dependencies": { + "oniguruma-parser": "^0.12.1", + "regex": "^6.0.1", + "regex-recursion": "^6.0.2" + } + }, + "node_modules/open": { + "version": "7.4.2", + "resolved": "https://registry.npmjs.org/open/-/open-7.4.2.tgz", + "integrity": "sha512-MVHddDVweXZF3awtlAS+6pgKLlm/JgxZ90+/NBurBoQctVOOB/zDdVjcyPzQ+0laDGbsWgrRkflI65sQeOgT9Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-docker": "^2.0.0", + "is-wsl": "^2.1.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/optionator": { + "version": "0.9.4", + "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.4.tgz", + "integrity": "sha512-6IpQ7mKUxRcZNLIObR0hz7lxsapSSIYNZJwXPGeF0mTVqGKFIXj1DQcMoT22S3ROcLyY/rz0PWaWZ9ayWmad9g==", + "dev": true, + "license": "MIT", + "dependencies": { + "deep-is": "^0.1.3", + "fast-levenshtein": "^2.0.6", + "levn": "^0.4.1", + "prelude-ls": "^1.2.1", + "type-check": "^0.4.0", + "word-wrap": "^1.2.5" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/p-finally": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/p-finally/-/p-finally-1.0.0.tgz", + "integrity": "sha512-LICb2p9CB7FS+0eR1oqWnHhp0FljGLZCWBE9aix0Uye9W8LTQPwMTYVGWQWIw9RdQiDg4+epXQODwIYJtSJaow==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=4" + } + }, + "node_modules/p-limit": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", + "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "yocto-queue": "^0.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/p-locate": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz", + "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==", + "dev": true, + "license": "MIT", + "dependencies": { + "p-limit": "^3.0.2" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/p-map": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/p-map/-/p-map-3.0.0.tgz", + "integrity": "sha512-d3qXVTF/s+W+CdJ5A29wywV2n8CQQYahlgz2bFiA+4eVNJbHJodPZ+/gXwPGh0bOqA+j8S+6+ckmvLGPk1QpxQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "aggregate-error": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/p-try": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", + "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/pac-proxy-agent": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/pac-proxy-agent/-/pac-proxy-agent-7.2.0.tgz", + "integrity": "sha512-TEB8ESquiLMc0lV8vcd5Ql/JAKAoyzHFXaStwjkzpOpC5Yv+pIzLfHvjTSdf3vpa2bMiUQrg9i6276yn8666aA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@tootallnate/quickjs-emscripten": "^0.23.0", + "agent-base": "^7.1.2", + "debug": "^4.3.4", + "get-uri": "^6.0.1", + "http-proxy-agent": "^7.0.0", + "https-proxy-agent": "^7.0.6", + "pac-resolver": "^7.0.1", + "socks-proxy-agent": "^8.0.5" + }, + "engines": { + "node": ">= 14" + } + }, + "node_modules/pac-resolver": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/pac-resolver/-/pac-resolver-7.0.1.tgz", + "integrity": "sha512-5NPgf87AT2STgwa2ntRMr45jTKrYBGkVU36yT0ig/n/GMAa3oPqhZfIQ2kMEimReg0+t9kZViDVZ83qfVUlckg==", + "dev": true, + "license": "MIT", + "dependencies": { + "degenerator": "^5.0.0", + "netmask": "^2.0.2" + }, + "engines": { + "node": ">= 14" + } + }, + "node_modules/package-hash": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/package-hash/-/package-hash-4.0.0.tgz", + "integrity": "sha512-whdkPIooSu/bASggZ96BWVvZTRMOFxnyUG5PnTSGKoJE2gd5mbVNmR2Nj20QFzxYYgAXpoqC+AiXzl+UMRh7zQ==", + "dev": true, + "license": "ISC", + "dependencies": { + "graceful-fs": "^4.1.15", + "hasha": "^5.0.0", + "lodash.flattendeep": "^4.4.0", + "release-zalgo": "^1.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/package-json-from-dist": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/package-json-from-dist/-/package-json-from-dist-1.0.1.tgz", + "integrity": "sha512-UEZIS3/by4OC8vL3P2dTXRETpebLI2NiI5vIrjaD/5UtrkFX/tNbwjTSRAGC/+7CAo2pIcBaRgWmcBBHcsaCIw==", + "dev": true, + "license": "BlueOak-1.0.0" + }, + "node_modules/package-manager-detector": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/package-manager-detector/-/package-manager-detector-1.6.0.tgz", + "integrity": "sha512-61A5ThoTiDG/C8s8UMZwSorAGwMJ0ERVGj2OjoW5pAalsNOg15+iQiPzrLJ4jhZ1HJzmC2PIHT2oEiH3R5fzNA==", + "dev": true, + "license": "MIT" + }, + "node_modules/package-name-regex": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/package-name-regex/-/package-name-regex-2.0.6.tgz", + "integrity": "sha512-gFL35q7kbE/zBaPA3UKhp2vSzcPYx2ecbYuwv1ucE9Il6IIgBDweBlH8D68UFGZic2MkllKa2KHCfC1IQBQUYA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/dword-design" + } + }, + "node_modules/pako": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/pako/-/pako-2.1.0.tgz", + "integrity": "sha512-w+eufiZ1WuJYgPXbV/PO3NCMEc3xqylkKHzp8bxp1uW4qaSNQUkwmLLEc3kKsfz8lpV1F8Ht3U1Cm+9Srog2ug==", + "dev": true, + "license": "(MIT AND Zlib)" + }, + "node_modules/parent-module": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", + "integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==", + "dev": true, + "license": "MIT", + "dependencies": { + "callsites": "^3.0.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/parse-json": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-5.2.0.tgz", + "integrity": "sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/code-frame": "^7.0.0", + "error-ex": "^1.3.1", + "json-parse-even-better-errors": "^2.3.0", + "lines-and-columns": "^1.1.6" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/parse-ms": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/parse-ms/-/parse-ms-4.0.0.tgz", + "integrity": "sha512-TXfryirbmq34y8QBwgqCVLi+8oA3oWx2eAnSn62ITyEhEYaWRlVZ2DvMM9eZbMs/RfxPu/PK/aBLyGj4IrqMHw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/patch-package": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/patch-package/-/patch-package-8.0.1.tgz", + "integrity": "sha512-VsKRIA8f5uqHQ7NGhwIna6Bx6D9s/1iXlA1hthBVBEbkq+t4kXD0HHt+rJhf/Z+Ci0F/HCB2hvn0qLdLG+Qxlw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@yarnpkg/lockfile": "^1.1.0", + "chalk": "^4.1.2", + "ci-info": "^3.7.0", + "cross-spawn": "^7.0.3", + "find-yarn-workspace-root": "^2.0.0", + "fs-extra": "^10.0.0", + "json-stable-stringify": "^1.0.2", + "klaw-sync": "^6.0.0", + "minimist": "^1.2.6", + "open": "^7.4.2", + "semver": "^7.5.3", + "slash": "^2.0.0", + "tmp": "^0.2.4", + "yaml": "^2.2.2" + }, + "bin": { + "patch-package": "index.js" + }, + "engines": { + "node": ">=14", + "npm": ">5" + } + }, + "node_modules/patch-package/node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "license": "MIT", + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/patch-package/node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/patch-package/node_modules/ci-info": { + "version": "3.9.0", + "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-3.9.0.tgz", + "integrity": "sha512-NIxF55hv4nSqQswkAeiOi1r83xy8JldOFDTWiug55KBu9Jnblncd2U6ViHmYgHf01TPZS77NJBhBMKdWj9HQMQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/sibiraj-s" + } + ], + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/patch-package/node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/patch-package/node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true, + "license": "MIT" + }, + "node_modules/patch-package/node_modules/fs-extra": { + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz", + "integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "graceful-fs": "^4.2.0", + "jsonfile": "^6.0.1", + "universalify": "^2.0.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/patch-package/node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "license": "MIT", + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/path-browserify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-browserify/-/path-browserify-1.0.1.tgz", + "integrity": "sha512-b7uo2UCUOYZcnF/3ID0lulOJi/bafxa1xPe7ZPsammBSpjSWQkjNxlt635YGS2MiR9GjvuXCtz2emr3jbsz98g==", + "dev": true, + "license": "MIT" + }, + "node_modules/path-data-parser": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/path-data-parser/-/path-data-parser-0.1.0.tgz", + "integrity": "sha512-NOnmBpt5Y2RWbuv0LMzsayp3lVylAHLPUTut412ZA3l+C4uw4ZVkQbjShYCQ8TCpUMdPapr4YjUqLYD6v68j+w==", + "dev": true, + "license": "MIT" + }, + "node_modules/path-exists": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/path-parse": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", + "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", + "dev": true, + "license": "MIT" + }, + "node_modules/path-scurry": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-1.11.1.tgz", + "integrity": "sha512-Xa4Nw17FS9ApQFJ9umLiJS4orGjm7ZzwUrwamcGQuHSzDyth9boKDaycYdDcZDuqYATXw4HFXgaqWTctW/v1HA==", + "dev": true, + "license": "BlueOak-1.0.0", + "dependencies": { + "lru-cache": "^10.2.0", + "minipass": "^5.0.0 || ^6.0.2 || ^7.0.0" + }, + "engines": { + "node": ">=16 || 14 >=14.18" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/path-scurry/node_modules/lru-cache": { + "version": "11.2.4", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.2.4.tgz", + "integrity": "sha512-B5Y16Jr9LB9dHVkh6ZevG+vAbOsNOYCX+sXvFWFu7B3Iz5mijW3zdbMyhsh8ANd2mSWBYdJgnqi+mL7/LrOPYg==", + "dev": true, + "license": "BlueOak-1.0.0", + "engines": { + "node": "20 || >=22" + } + }, + "node_modules/pathe": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/pathe/-/pathe-2.0.3.tgz", + "integrity": "sha512-WUjGcAqP1gQacoQe+OBJsFA7Ld4DyXuUIjZ5cc75cLHvJ7dtNsTugphxIADwspS+AraAUePCKrSVtPLFj/F88w==", + "dev": true, + "license": "MIT" + }, + "node_modules/pend": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/pend/-/pend-1.2.0.tgz", + "integrity": "sha512-F3asv42UuXchdzt+xXqfW1OGlVBe+mxa2mqI0pg5yAHZPvFmY3Y6drSf/GQ1A86WgWEN9Kzh/WrgKa6iGcHXLg==", + "dev": true, + "license": "MIT" + }, + "node_modules/perfect-debounce": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/perfect-debounce/-/perfect-debounce-1.0.0.tgz", + "integrity": "sha512-xCy9V055GLEqoFaHoC1SoLIaLmWctgCUaBaWxDZ7/Zx4CTyX7cJQLJOok/orfjZAh9kEYpjJa4d0KcJmCbctZA==", + "dev": true, + "license": "MIT" + }, + "node_modules/picocolors": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", + "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==", + "dev": true, + "license": "ISC" + }, + "node_modules/picomatch": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.3.tgz", + "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/pidtree": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/pidtree/-/pidtree-0.6.0.tgz", + "integrity": "sha512-eG2dWTVw5bzqGRztnHExczNxt5VGsE6OwTeCG3fdUf9KBsZzO3R5OIIIzWR+iZA0NtZ+RDVdaoE2dK1cn6jH4g==", + "dev": true, + "license": "MIT", + "bin": { + "pidtree": "bin/pidtree.js" + }, + "engines": { + "node": ">=0.10" + } + }, + "node_modules/pify": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "integrity": "sha512-udgsAY+fTnvv7kI7aaxbqwWNb0AHiB0qBO89PZKPkoTmGOgdbrHDKD+0B2X4uTfJ/FT1R09r9gTsjUjNJotuog==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/pinia": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/pinia/-/pinia-3.0.4.tgz", + "integrity": "sha512-l7pqLUFTI/+ESXn6k3nu30ZIzW5E2WZF/LaHJEpoq6ElcLD+wduZoB2kBN19du6K/4FDpPMazY2wJr+IndBtQw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@vue/devtools-api": "^7.7.7" + }, + "funding": { + "url": "https://github.com/sponsors/posva" + }, + "peerDependencies": { + "typescript": ">=4.5.0", + "vue": "^3.5.11" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/pino": { + "version": "8.21.0", + "resolved": "https://registry.npmjs.org/pino/-/pino-8.21.0.tgz", + "integrity": "sha512-ip4qdzjkAyDDZklUaZkcRFb2iA118H9SgRh8yzTkSQK8HilsOJF7rSY8HoW5+I0M46AZgX/pxbprf2vvzQCE0Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "atomic-sleep": "^1.0.0", + "fast-redact": "^3.1.1", + "on-exit-leak-free": "^2.1.0", + "pino-abstract-transport": "^1.2.0", + "pino-std-serializers": "^6.0.0", + "process-warning": "^3.0.0", + "quick-format-unescaped": "^4.0.3", + "real-require": "^0.2.0", + "safe-stable-stringify": "^2.3.1", + "sonic-boom": "^3.7.0", + "thread-stream": "^2.6.0" + }, + "bin": { + "pino": "bin.js" + } + }, + "node_modules/pino-abstract-transport": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/pino-abstract-transport/-/pino-abstract-transport-1.2.0.tgz", + "integrity": "sha512-Guhh8EZfPCfH+PMXAb6rKOjGQEoy0xlAIn+irODG5kgfYV+BQ0rGYYWTIel3P5mmyXqkYkPmdIkywsn6QKUR1Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "readable-stream": "^4.0.0", + "split2": "^4.0.0" + } + }, + "node_modules/pino-std-serializers": { + "version": "6.2.2", + "resolved": "https://registry.npmjs.org/pino-std-serializers/-/pino-std-serializers-6.2.2.tgz", + "integrity": "sha512-cHjPPsE+vhj/tnhCy/wiMh3M3z3h/j15zHQX+S9GkTBgqJuTuJzYJ4gUyACLhDaJ7kk9ba9iRDmbH2tJU03OiA==", + "dev": true, + "license": "MIT" + }, + "node_modules/pirates": { + "version": "4.0.7", + "resolved": "https://registry.npmjs.org/pirates/-/pirates-4.0.7.tgz", + "integrity": "sha512-TfySrs/5nm8fQJDcBDuUng3VOUKsd7S+zqvbOTiGXHfxX4wK31ard+hoNuvkicM/2YFzlpDgABOevKSsB4G/FA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 6" + } + }, + "node_modules/pkg-dir": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-4.2.0.tgz", + "integrity": "sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "find-up": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/pkg-dir/node_modules/find-up": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", + "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", + "dev": true, + "license": "MIT", + "dependencies": { + "locate-path": "^5.0.0", + "path-exists": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/pkg-dir/node_modules/locate-path": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", + "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", + "dev": true, + "license": "MIT", + "dependencies": { + "p-locate": "^4.1.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/pkg-dir/node_modules/p-limit": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", + "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", + "dev": true, + "license": "MIT", + "dependencies": { + "p-try": "^2.0.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/pkg-dir/node_modules/p-locate": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", + "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", + "dev": true, + "license": "MIT", + "dependencies": { + "p-limit": "^2.2.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/pkg-types": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/pkg-types/-/pkg-types-1.3.1.tgz", + "integrity": "sha512-/Jm5M4RvtBFVkKWRu2BLUTNP8/M2a+UwuAX+ae4770q1qVGtfjG+WTCupoZixokjmHiry8uI+dlY8KXYV5HVVQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "confbox": "^0.1.8", + "mlly": "^1.7.4", + "pathe": "^2.0.1" + } + }, + "node_modules/pluralize": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/pluralize/-/pluralize-8.0.0.tgz", + "integrity": "sha512-Nc3IT5yHzflTfbjgqWcCPpo7DaKy4FnpB0l/zCAW0Tc7jxAiuqSxHasntB3D7887LSrA93kDJ9IXovxJYxyLCA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=4" + } + }, + "node_modules/points-on-curve": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/points-on-curve/-/points-on-curve-0.2.0.tgz", + "integrity": "sha512-0mYKnYYe9ZcqMCWhUjItv/oHjvgEsfKvnUTg8sAtnHr3GVy7rGkXCb6d5cSyqrWqL4k81b9CPg3urd+T7aop3A==", + "dev": true, + "license": "MIT" + }, + "node_modules/points-on-path": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/points-on-path/-/points-on-path-0.2.1.tgz", + "integrity": "sha512-25ClnWWuw7JbWZcgqY/gJ4FQWadKxGWk+3kR/7kD0tCaDtPPMj7oHu2ToLaVhfpnHrZzYby2w6tUA0eOIuUg8g==", + "dev": true, + "license": "MIT", + "dependencies": { + "path-data-parser": "0.1.0", + "points-on-curve": "0.2.0" + } + }, + "node_modules/postcss": { + "version": "8.5.6", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.6.tgz", + "integrity": "sha512-3Ybi1tAuwAP9s0r1UQ2J4n5Y0G05bJkpUIO0/bI9MhwmD70S5aTWbXGBwxHrelT+XM1k6dM0pk+SwNkpTRN7Pg==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/postcss" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "peer": true, + "dependencies": { + "nanoid": "^3.3.11", + "picocolors": "^1.1.1", + "source-map-js": "^1.2.1" + }, + "engines": { + "node": "^10 || ^12 || >=14" + } + }, + "node_modules/postcss-import": { + "version": "15.1.0", + "resolved": "https://registry.npmjs.org/postcss-import/-/postcss-import-15.1.0.tgz", + "integrity": "sha512-hpr+J05B2FVYUAXHeK1YyI267J/dDDhMU6B6civm8hSY1jYJnBXxzKDKDswzJmtLHryrjhnDjqqp/49t8FALew==", + "dev": true, + "license": "MIT", + "dependencies": { + "postcss-value-parser": "^4.0.0", + "read-cache": "^1.0.0", + "resolve": "^1.1.7" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "postcss": "^8.0.0" + } + }, + "node_modules/postcss-js": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/postcss-js/-/postcss-js-4.1.0.tgz", + "integrity": "sha512-oIAOTqgIo7q2EOwbhb8UalYePMvYoIeRY2YKntdpFQXNosSu3vLrniGgmH9OKs/qAkfoj5oB3le/7mINW1LCfw==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "camelcase-css": "^2.0.1" + }, + "engines": { + "node": "^12 || ^14 || >= 16" + }, + "peerDependencies": { + "postcss": "^8.4.21" + } + }, + "node_modules/postcss-load-config": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/postcss-load-config/-/postcss-load-config-6.0.1.tgz", + "integrity": "sha512-oPtTM4oerL+UXmx+93ytZVN82RrlY/wPUV8IeDxFrzIjXOLF1pN+EmKPLbubvKHT2HC20xXsCAH2Z+CKV6Oz/g==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "lilconfig": "^3.1.1" + }, + "engines": { + "node": ">= 18" + }, + "peerDependencies": { + "jiti": ">=1.21.0", + "postcss": ">=8.0.9", + "tsx": "^4.8.1", + "yaml": "^2.4.2" + }, + "peerDependenciesMeta": { + "jiti": { + "optional": true + }, + "postcss": { + "optional": true + }, + "tsx": { + "optional": true + }, + "yaml": { + "optional": true + } + } + }, + "node_modules/postcss-nested": { + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/postcss-nested/-/postcss-nested-6.2.0.tgz", + "integrity": "sha512-HQbt28KulC5AJzG+cZtj9kvKB93CFCdLvog1WFLf1D+xmMvPGlBstkpTEZfK5+AN9hfJocyBFCNiqyS48bpgzQ==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "postcss-selector-parser": "^6.1.1" + }, + "engines": { + "node": ">=12.0" + }, + "peerDependencies": { + "postcss": "^8.2.14" + } + }, + "node_modules/postcss-nested/node_modules/postcss-selector-parser": { + "version": "6.1.2", + "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-6.1.2.tgz", + "integrity": "sha512-Q8qQfPiZ+THO/3ZrOrO0cJJKfpYCagtMUkXbnEfmgUjwXg6z/WBeOyS9APBBPCTSiDV+s4SwQGu8yFsiMRIudg==", + "dev": true, + "license": "MIT", + "dependencies": { + "cssesc": "^3.0.0", + "util-deprecate": "^1.0.2" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/postcss-selector-parser": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-7.1.1.tgz", + "integrity": "sha512-orRsuYpJVw8LdAwqqLykBj9ecS5/cRHlI5+nvTo8LcCKmzDmqVORXtOIYEEQuL9D4BxtA1lm5isAqzQZCoQ6Eg==", + "dev": true, + "license": "MIT", + "dependencies": { + "cssesc": "^3.0.0", + "util-deprecate": "^1.0.2" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/postcss-value-parser": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/postcss-value-parser/-/postcss-value-parser-4.2.0.tgz", + "integrity": "sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/preact": { + "version": "10.28.2", + "resolved": "https://registry.npmjs.org/preact/-/preact-10.28.2.tgz", + "integrity": "sha512-lbteaWGzGHdlIuiJ0l2Jq454m6kcpI1zNje6d8MlGAFlYvP2GO4ibnat7P74Esfz4sPTdM6UxtTwh/d3pwM9JA==", + "dev": true, + "license": "MIT", + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/preact" + } + }, + "node_modules/prelude-ls": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", + "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/prettier": { + "version": "3.8.0", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.8.0.tgz", + "integrity": "sha512-yEPsovQfpxYfgWNhCfECjG5AQaO+K3dp6XERmOepyPDVqcJm+bjyCVO3pmU+nAPe0N5dDvekfGezt/EIiRe1TA==", + "dev": true, + "license": "MIT", + "peer": true, + "bin": { + "prettier": "bin/prettier.cjs" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/prettier/prettier?sponsor=1" + } + }, + "node_modules/prettier-linter-helpers": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/prettier-linter-helpers/-/prettier-linter-helpers-1.0.1.tgz", + "integrity": "sha512-SxToR7P8Y2lWmv/kTzVLC1t/GDI2WGjMwNhLLE9qtH8Q13C+aEmuRlzDst4Up4s0Wc8sF2M+J57iB3cMLqftfg==", + "dev": true, + "license": "MIT", + "dependencies": { + "fast-diff": "^1.1.2" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/prettier-plugin-organize-imports": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/prettier-plugin-organize-imports/-/prettier-plugin-organize-imports-4.3.0.tgz", + "integrity": "sha512-FxFz0qFhyBsGdIsb697f/EkvHzi5SZOhWAjxcx2dLt+Q532bAlhswcXGYB1yzjZ69kW8UoadFBw7TyNwlq96Iw==", + "dev": true, + "license": "MIT", + "peerDependencies": { + "prettier": ">=2.0", + "typescript": ">=2.9", + "vue-tsc": "^2.1.0 || 3" + }, + "peerDependenciesMeta": { + "vue-tsc": { + "optional": true + } + } + }, + "node_modules/pretty-bytes": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/pretty-bytes/-/pretty-bytes-7.1.0.tgz", + "integrity": "sha512-nODzvTiYVRGRqAOvE84Vk5JDPyyxsVk0/fbA/bq7RqlnhksGpset09XTxbpvLTIjoaF7K8Z8DG8yHtKGTPSYRw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=20" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/pretty-ms": { + "version": "9.3.0", + "resolved": "https://registry.npmjs.org/pretty-ms/-/pretty-ms-9.3.0.tgz", + "integrity": "sha512-gjVS5hOP+M3wMm5nmNOucbIrqudzs9v/57bWRHQWLYklXqoXKrVfYW2W9+glfGsqtPgpiz5WwyEEB+ksXIx3gQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "parse-ms": "^4.0.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/process-on-spawn": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/process-on-spawn/-/process-on-spawn-1.1.0.tgz", + "integrity": "sha512-JOnOPQ/8TZgjs1JIH/m9ni7FfimjNa/PRx7y/Wb5qdItsnhO0jE4AT7fC0HjC28DUQWDr50dwSYZLdRMlqDq3Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "fromentries": "^1.2.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/process-warning": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/process-warning/-/process-warning-3.0.0.tgz", + "integrity": "sha512-mqn0kFRl0EoqhnL0GQ0veqFHyIN1yig9RHh/InzORTUiZHFRAur+aMtRkELNwGs9aNwKS6tg/An4NYBPGwvtzQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/progress": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz", + "integrity": "sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/property-information": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/property-information/-/property-information-7.1.0.tgz", + "integrity": "sha512-TwEZ+X+yCJmYfL7TPUOcvBZ4QfoT5YenQiJuX//0th53DE6w0xxLEtfK3iyryQFddXuvkIk51EEgrJQ0WJkOmQ==", + "dev": true, + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/proxy-agent": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/proxy-agent/-/proxy-agent-6.5.0.tgz", + "integrity": "sha512-TmatMXdr2KlRiA2CyDu8GqR8EjahTG3aY3nXjdzFyoZbmB8hrBsTyMezhULIXKnC0jpfjlmiZ3+EaCzoInSu/A==", + "dev": true, + "license": "MIT", + "dependencies": { + "agent-base": "^7.1.2", + "debug": "^4.3.4", + "http-proxy-agent": "^7.0.1", + "https-proxy-agent": "^7.0.6", + "lru-cache": "^7.14.1", + "pac-proxy-agent": "^7.1.0", + "proxy-from-env": "^1.1.0", + "socks-proxy-agent": "^8.0.5" + }, + "engines": { + "node": ">= 14" + } + }, + "node_modules/proxy-agent/node_modules/lru-cache": { + "version": "7.18.3", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-7.18.3.tgz", + "integrity": "sha512-jumlc0BIUrS3qJGgIkWZsyfAM7NCWiBcCDhnd+3NNM5KbBmLTgHVfWBcg6W+rLUsIpzpERPsvwUP7CckAQSOoA==", + "dev": true, + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/proxy-from-env": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", + "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==", + "dev": true, + "license": "MIT" + }, + "node_modules/pstree.remy": { + "version": "1.1.8", + "resolved": "https://registry.npmjs.org/pstree.remy/-/pstree.remy-1.1.8.tgz", + "integrity": "sha512-77DZwxQmxKnu3aR542U+X8FypNzbfJ+C5XQDk3uWjWxn6151aIMGthWYRXTqT1E5oJvg+ljaa2OJi+VfvCOQ8w==", + "dev": true, + "license": "MIT" + }, + "node_modules/pug-error": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/pug-error/-/pug-error-2.1.0.tgz", + "integrity": "sha512-lv7sU9e5Jk8IeUheHata6/UThZ7RK2jnaaNztxfPYUY+VxZyk/ePVaNZ/vwmH8WqGvDz3LrNYt/+gA55NDg6Pg==", + "dev": true, + "license": "MIT" + }, + "node_modules/pug-lexer": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/pug-lexer/-/pug-lexer-5.0.1.tgz", + "integrity": "sha512-0I6C62+keXlZPZkOJeVam9aBLVP2EnbeDw3An+k0/QlqdwH6rv8284nko14Na7c0TtqtogfWXcRoFE4O4Ff20w==", + "dev": true, + "license": "MIT", + "dependencies": { + "character-parser": "^2.2.0", + "is-expression": "^4.0.0", + "pug-error": "^2.0.0" + } + }, + "node_modules/pug-parser": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/pug-parser/-/pug-parser-6.0.0.tgz", + "integrity": "sha512-ukiYM/9cH6Cml+AOl5kETtM9NR3WulyVP2y4HOU45DyMim1IeP/OOiyEWRr6qk5I5klpsBnbuHpwKmTx6WURnw==", + "dev": true, + "license": "MIT", + "dependencies": { + "pug-error": "^2.0.0", + "token-stream": "1.0.0" + } + }, + "node_modules/pump": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.3.tgz", + "integrity": "sha512-todwxLMY7/heScKmntwQG8CXVkWUOdYxIvY2s0VWAAMh/nd8SoYiRaKjlr7+iCs984f2P8zvrfWcDDYVb73NfA==", + "dev": true, + "license": "MIT", + "dependencies": { + "end-of-stream": "^1.1.0", + "once": "^1.3.1" + } + }, + "node_modules/punycode": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", + "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/punycode.js": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/punycode.js/-/punycode.js-2.3.1.tgz", + "integrity": "sha512-uxFIHU0YlHYhDQtV4R9J6a52SLx28BCjT+4ieh7IGbgwVJWO+km431c4yRlREUAsAmt/uMjQUyQHNEPf0M39CA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/puppeteer": { + "version": "23.11.1", + "resolved": "https://registry.npmjs.org/puppeteer/-/puppeteer-23.11.1.tgz", + "integrity": "sha512-53uIX3KR5en8l7Vd8n5DUv90Ae9QDQsyIthaUFVzwV6yU750RjqRznEtNMBT20VthqAdemnJN+hxVdmMHKt7Zw==", + "deprecated": "< 24.15.0 is no longer supported", + "dev": true, + "hasInstallScript": true, + "license": "Apache-2.0", + "peer": true, + "dependencies": { + "@puppeteer/browsers": "2.6.1", + "chromium-bidi": "0.11.0", + "cosmiconfig": "^9.0.0", + "devtools-protocol": "0.0.1367902", + "puppeteer-core": "23.11.1", + "typed-query-selector": "^2.12.0" + }, + "bin": { + "puppeteer": "lib/cjs/puppeteer/node/cli.js" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/puppeteer-core": { + "version": "23.11.1", + "resolved": "https://registry.npmjs.org/puppeteer-core/-/puppeteer-core-23.11.1.tgz", + "integrity": "sha512-3HZ2/7hdDKZvZQ7dhhITOUg4/wOrDRjyK2ZBllRB0ZCOi9u0cwq1ACHDjBB+nX+7+kltHjQvBRdeY7+W0T+7Gg==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@puppeteer/browsers": "2.6.1", + "chromium-bidi": "0.11.0", + "debug": "^4.4.0", + "devtools-protocol": "0.0.1367902", + "typed-query-selector": "^2.12.0", + "ws": "^8.18.0" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/queue-microtask": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", + "integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT" + }, + "node_modules/quick-format-unescaped": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/quick-format-unescaped/-/quick-format-unescaped-4.0.4.tgz", + "integrity": "sha512-tYC1Q1hgyRuHgloV/YXs2w15unPVh8qfu/qCTfhTYamaw7fyhumKa2yGpdSo87vY32rIclj+4fWYQXUMs9EHvg==", + "dev": true, + "license": "MIT" + }, + "node_modules/radash": { + "version": "12.1.1", + "resolved": "https://registry.npmjs.org/radash/-/radash-12.1.1.tgz", + "integrity": "sha512-h36JMxKRqrAxVD8201FrCpyeNuUY9Y5zZwujr20fFO77tpUtGa6EZzfKw/3WaiBX95fq7+MpsuMLNdSnORAwSA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=14.18.0" + } + }, + "node_modules/ramda": { + "version": "0.28.0", + "resolved": "https://registry.npmjs.org/ramda/-/ramda-0.28.0.tgz", + "integrity": "sha512-9QnLuG/kPVgWvMQ4aODhsBUFKOUmnbUnsSXACv+NCQZcHbeb+v8Lodp8OVxtRULN1/xOyYLLaL6npE6dMq5QTA==", + "dev": true, + "license": "MIT", + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/ramda" + } + }, + "node_modules/randombytes": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", + "integrity": "sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "safe-buffer": "^5.1.0" + } + }, + "node_modules/react": { + "version": "19.2.3", + "resolved": "https://registry.npmjs.org/react/-/react-19.2.3.tgz", + "integrity": "sha512-Ku/hhYbVjOQnXDZFv2+RibmLFGwFdeeKHFcOTlrt7xplBnya5OGn/hIRDsqDiSUcfORsDC7MPxwork8jBwsIWA==", + "dev": true, + "license": "MIT", + "peer": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/react-dom": { + "version": "19.2.3", + "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-19.2.3.tgz", + "integrity": "sha512-yELu4WmLPw5Mr/lmeEpox5rw3RETacE++JgHqQzd2dg+YbJuat3jH4ingc+WPZhxaoFzdv9y33G+F7Nl5O0GBg==", + "dev": true, + "license": "MIT", + "peer": true, + "dependencies": { + "scheduler": "^0.27.0" + }, + "peerDependencies": { + "react": "^19.2.3" + } + }, + "node_modules/read": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/read/-/read-2.1.0.tgz", + "integrity": "sha512-bvxi1QLJHcaywCAEsAk4DG3nVoqiY2Csps3qzWalhj5hFqRn1d/OixkFXtLO1PrgHUcAP0FNaSY/5GYNfENFFQ==", + "dev": true, + "license": "ISC", + "dependencies": { + "mute-stream": "~1.0.0" + }, + "engines": { + "node": "^14.17.0 || ^16.13.0 || >=18.0.0" + } + }, + "node_modules/read-cache": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/read-cache/-/read-cache-1.0.0.tgz", + "integrity": "sha512-Owdv/Ft7IjOgm/i0xvNDZ1LrRANRfew4b2prF3OWMQLxLfu3bS8FVhCsrSCMK4lR56Y9ya+AThoTpDCTxCmpRA==", + "dev": true, + "license": "MIT", + "dependencies": { + "pify": "^2.3.0" + } + }, + "node_modules/read/node_modules/mute-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-1.0.0.tgz", + "integrity": "sha512-avsJQhyd+680gKXyG/sQc0nXaC6rBkPOfyHYcFb9+hdkqQkR9bdnkJ0AMZhke0oesPqIO+mFFJ+IdBc7mst4IA==", + "dev": true, + "license": "ISC", + "engines": { + "node": "^14.17.0 || ^16.13.0 || >=18.0.0" + } + }, + "node_modules/readable-stream": { + "name": "@built-in/readable-stream", + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@built-in/readable-stream/-/readable-stream-1.0.0.tgz", + "integrity": "sha512-IoCpt9IBf6r8KXnABN2jeD06EWnp0LDF3ZSJQ3UFkIhbDVfyjlEqr1MpgK17o731fISX0wIQ9plT6IrnhXrGAw==", + "dev": true, + "license": "Unlicense" + }, + "node_modules/readdirp": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", + "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", + "dev": true, + "license": "MIT", + "dependencies": { + "picomatch": "^2.2.1" + }, + "engines": { + "node": ">=8.10.0" + } + }, + "node_modules/readdirp/node_modules/picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/real-require": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/real-require/-/real-require-0.2.0.tgz", + "integrity": "sha512-57frrGM/OCTLqLOAh0mhVA9VBMHd+9U7Zb2THMGdBUoZVOtGbJzjxsYGDJ3A9AYYCP4hn6y1TVbaOfzWtm5GFg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 12.13.0" + } + }, + "node_modules/rechoir": { + "version": "0.6.2", + "resolved": "https://registry.npmjs.org/rechoir/-/rechoir-0.6.2.tgz", + "integrity": "sha512-HFM8rkZ+i3zrV+4LQjwQ0W+ez98pApMGM3HUrN04j3CqzPOzl9nmP15Y8YXNm8QHGv/eacOVEjqhmWpkRV0NAw==", + "dev": true, + "dependencies": { + "resolve": "^1.1.6" + }, + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/regenerate": { + "version": "1.4.2", + "resolved": "https://registry.npmjs.org/regenerate/-/regenerate-1.4.2.tgz", + "integrity": "sha512-zrceR/XhGYU/d/opr2EKO7aRHUeiBI8qjtfHqADTwZd6Szfy16la6kqD0MIUs5z5hx6AaKa+PixpPrR289+I0A==", + "dev": true, + "license": "MIT" + }, + "node_modules/regenerate-unicode-properties": { + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/regenerate-unicode-properties/-/regenerate-unicode-properties-8.2.0.tgz", + "integrity": "sha512-F9DjY1vKLo/tPePDycuH3dn9H1OTPIkVD9Kz4LODu+F2C75mgjAJ7x/gwy6ZcSNRAAkhNlJSOHRe8k3p+K9WhA==", + "dev": true, + "license": "MIT", + "dependencies": { + "regenerate": "^1.4.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/regex": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/regex/-/regex-6.1.0.tgz", + "integrity": "sha512-6VwtthbV4o/7+OaAF9I5L5V3llLEsoPyq9P1JVXkedTP33c7MfCG0/5NOPcSJn0TzXcG9YUrR0gQSWioew3LDg==", + "dev": true, + "license": "MIT", + "dependencies": { + "regex-utilities": "^2.3.0" + } + }, + "node_modules/regex-recursion": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/regex-recursion/-/regex-recursion-6.0.2.tgz", + "integrity": "sha512-0YCaSCq2VRIebiaUviZNs0cBz1kg5kVS2UKUfNIx8YVs1cN3AV7NTctO5FOKBA+UT2BPJIWZauYHPqJODG50cg==", + "dev": true, + "license": "MIT", + "dependencies": { + "regex-utilities": "^2.3.0" + } + }, + "node_modules/regex-utilities": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/regex-utilities/-/regex-utilities-2.3.0.tgz", + "integrity": "sha512-8VhliFJAWRaUiVvREIiW2NXXTmHs4vMNnSzuJVhscgmGav3g9VDxLrQndI3dZZVVdp0ZO/5v0xmX516/7M9cng==", + "dev": true, + "license": "MIT" + }, + "node_modules/regexp-tree": { + "version": "0.1.27", + "resolved": "https://registry.npmjs.org/regexp-tree/-/regexp-tree-0.1.27.tgz", + "integrity": "sha512-iETxpjK6YoRWJG5o6hXLwvjYAoW+FEZn9os0PD/b6AP6xQwsa/Y7lCVgIixBbUPMfhu+i2LtdeAqVTgGlQarfA==", + "dev": true, + "license": "MIT", + "bin": { + "regexp-tree": "bin/regexp-tree" + } + }, + "node_modules/regexpu-core": { + "version": "4.5.4", + "resolved": "https://registry.npmjs.org/regexpu-core/-/regexpu-core-4.5.4.tgz", + "integrity": "sha512-BtizvGtFQKGPUcTy56o3nk1bGRp4SZOTYrDtGNlqCQufptV5IkkLN6Emw+yunAJjzf+C9FQFtvq7IoA3+oMYHQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "regenerate": "^1.4.0", + "regenerate-unicode-properties": "^8.0.2", + "regjsgen": "^0.5.0", + "regjsparser": "^0.6.0", + "unicode-match-property-ecmascript": "^1.0.4", + "unicode-match-property-value-ecmascript": "^1.1.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/regexpu-core/node_modules/jsesc": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-0.5.0.tgz", + "integrity": "sha512-uZz5UnB7u4T9LvwmFqXii7pZSouaRPorGs5who1Ip7VO0wxanFvBL7GkM6dTHlgX+jhBApRetaWpnDabOeTcnA==", + "dev": true, + "bin": { + "jsesc": "bin/jsesc" + } + }, + "node_modules/regexpu-core/node_modules/regjsparser": { + "version": "0.6.9", + "resolved": "https://registry.npmjs.org/regjsparser/-/regjsparser-0.6.9.tgz", + "integrity": "sha512-ZqbNRz1SNjLAiYuwY0zoXW8Ne675IX5q+YHioAGbCw4X96Mjl2+dcX9B2ciaeyYjViDAfvIjFpQjJgLttTEERQ==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "jsesc": "~0.5.0" + }, + "bin": { + "regjsparser": "bin/parser" + } + }, + "node_modules/regjsgen": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/regjsgen/-/regjsgen-0.5.2.tgz", + "integrity": "sha512-OFFT3MfrH90xIW8OOSyUrk6QHD5E9JOTeGodiJeBS3J6IwlgzJMNE/1bZklWz5oTg+9dCMyEetclvCVXOPoN3A==", + "dev": true, + "license": "MIT" + }, + "node_modules/regjsparser": { + "version": "0.13.0", + "resolved": "https://registry.npmjs.org/regjsparser/-/regjsparser-0.13.0.tgz", + "integrity": "sha512-NZQZdC5wOE/H3UT28fVGL+ikOZcEzfMGk/c3iN9UGxzWHMa1op7274oyiUVrAG4B2EuFhus8SvkaYnhvW92p9Q==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "jsesc": "~3.1.0" + }, + "bin": { + "regjsparser": "bin/parser" + } + }, + "node_modules/release-zalgo": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/release-zalgo/-/release-zalgo-1.0.0.tgz", + "integrity": "sha512-gUAyHVHPPC5wdqX/LG4LWtRYtgjxyX78oanFNTMMyFEfOqdC54s3eE82imuWKbOeqYht2CrNf64Qb8vgmmtZGA==", + "dev": true, + "license": "ISC", + "dependencies": { + "es6-error": "^4.0.1" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/request-light": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/request-light/-/request-light-0.7.0.tgz", + "integrity": "sha512-lMbBMrDoxgsyO+yB3sDcrDuX85yYt7sS8BfQd11jtbW/z5ZWgLZRcEGLsLoYw7I0WSUGQBs8CC8ScIxkTX1+6Q==", + "dev": true, + "license": "MIT" + }, + "node_modules/require-directory": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", + "integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/require-main-filename": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-2.0.0.tgz", + "integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==", + "dev": true, + "license": "ISC" + }, + "node_modules/requirejs": { + "version": "2.3.8", + "resolved": "https://registry.npmjs.org/requirejs/-/requirejs-2.3.8.tgz", + "integrity": "sha512-7/cTSLOdYkNBNJcDMWf+luFvMriVm7eYxp4BcFCsAX0wF421Vyce5SXP17c+Jd5otXKGNehIonFlyQXSowL6Mw==", + "dev": true, + "license": "MIT", + "bin": { + "r_js": "bin/r.js", + "r.js": "bin/r.js" + }, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/resolve": { + "version": "1.22.11", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.11.tgz", + "integrity": "sha512-RfqAvLnMl313r7c9oclB1HhUEAezcpLjz95wFH4LVuhk9JF/r22qmVP9AMmOU4vMX7Q8pN8jwNg/CSpdFnMjTQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-core-module": "^2.16.1", + "path-parse": "^1.0.7", + "supports-preserve-symlinks-flag": "^1.0.0" + }, + "bin": { + "resolve": "bin/resolve" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/resolve-from": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", + "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=4" + } + }, + "node_modules/restore-cursor": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-5.1.0.tgz", + "integrity": "sha512-oMA2dcrw6u0YfxJQXm342bFKX/E4sG9rbTzO9ptUcR/e8A33cHuvStiYOwH7fszkZlZ1z/ta9AAoPk2F4qIOHA==", + "dev": true, + "license": "MIT", + "dependencies": { + "onetime": "^7.0.0", + "signal-exit": "^4.1.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/reusify": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.1.0.tgz", + "integrity": "sha512-g6QUff04oZpHs0eG5p83rFLhHeV00ug/Yf9nZM6fLeUrPguBTkTQOdpAWWspMh55TZfVQDPaN3NQJfbVRAxdIw==", + "dev": true, + "license": "MIT", + "engines": { + "iojs": ">=1.0.0", + "node": ">=0.10.0" + } + }, + "node_modules/rfdc": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/rfdc/-/rfdc-1.4.1.tgz", + "integrity": "sha512-q1b3N5QkRUWUl7iyylaaj3kOpIT0N2i9MqIEQXP73GVsN9cw3fdx8X63cEmWhJGi2PPCF23Ijp7ktmd39rawIA==", + "dev": true, + "license": "MIT" + }, + "node_modules/rimraf": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", + "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", + "deprecated": "Rimraf versions prior to v4 are no longer supported", + "dev": true, + "license": "ISC", + "dependencies": { + "glob": "^7.1.3" + }, + "bin": { + "rimraf": "bin.js" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/rimraf/node_modules/glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "deprecated": "Glob versions prior to v9 are no longer supported", + "dev": true, + "license": "ISC", + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/robust-predicates": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/robust-predicates/-/robust-predicates-3.0.2.tgz", + "integrity": "sha512-IXgzBWvWQwE6PrDI05OvmXUIruQTcoMDzRsOd5CDvHCVLcLHMTSYvOK5Cm46kWqlV3yAbuSpBZdJ5oP5OUoStg==", + "dev": true, + "license": "Unlicense" + }, + "node_modules/rollup": { + "version": "4.55.1", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.55.1.tgz", + "integrity": "sha512-wDv/Ht1BNHB4upNbK74s9usvl7hObDnvVzknxqY/E/O3X6rW1U1rV1aENEfJ54eFZDTNo7zv1f5N4edCluH7+A==", + "dev": true, + "license": "MIT", + "peer": true, + "dependencies": { + "@types/estree": "1.0.8" + }, + "bin": { + "rollup": "dist/bin/rollup" + }, + "engines": { + "node": ">=18.0.0", + "npm": ">=8.0.0" + }, + "optionalDependencies": { + "@rollup/rollup-android-arm-eabi": "4.55.1", + "@rollup/rollup-android-arm64": "4.55.1", + "@rollup/rollup-darwin-arm64": "4.55.1", + "@rollup/rollup-darwin-x64": "4.55.1", + "@rollup/rollup-freebsd-arm64": "4.55.1", + "@rollup/rollup-freebsd-x64": "4.55.1", + "@rollup/rollup-linux-arm-gnueabihf": "4.55.1", + "@rollup/rollup-linux-arm-musleabihf": "4.55.1", + "@rollup/rollup-linux-arm64-gnu": "4.55.1", + "@rollup/rollup-linux-arm64-musl": "4.55.1", + "@rollup/rollup-linux-loong64-gnu": "4.55.1", + "@rollup/rollup-linux-loong64-musl": "4.55.1", + "@rollup/rollup-linux-ppc64-gnu": "4.55.1", + "@rollup/rollup-linux-ppc64-musl": "4.55.1", + "@rollup/rollup-linux-riscv64-gnu": "4.55.1", + "@rollup/rollup-linux-riscv64-musl": "4.55.1", + "@rollup/rollup-linux-s390x-gnu": "4.55.1", + "@rollup/rollup-linux-x64-gnu": "4.55.1", + "@rollup/rollup-linux-x64-musl": "4.55.1", + "@rollup/rollup-openbsd-x64": "4.55.1", + "@rollup/rollup-openharmony-arm64": "4.55.1", + "@rollup/rollup-win32-arm64-msvc": "4.55.1", + "@rollup/rollup-win32-ia32-msvc": "4.55.1", + "@rollup/rollup-win32-x64-gnu": "4.55.1", + "@rollup/rollup-win32-x64-msvc": "4.55.1", + "fsevents": "~2.3.2" + } + }, + "node_modules/rollup-plugin-license": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/rollup-plugin-license/-/rollup-plugin-license-3.6.0.tgz", + "integrity": "sha512-1ieLxTCaigI5xokIfszVDRoy6c/Wmlot1fDEnea7Q/WXSR8AqOjYljHDLObAx7nFxHC2mbxT3QnTSPhaic2IYw==", + "dev": true, + "license": "MIT", + "dependencies": { + "commenting": "~1.1.0", + "fdir": "^6.4.3", + "lodash": "~4.17.21", + "magic-string": "~0.30.0", + "moment": "~2.30.1", + "package-name-regex": "~2.0.6", + "spdx-expression-validate": "~2.0.0", + "spdx-satisfies": "~5.0.1" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "rollup": "^1.0.0 || ^2.0.0 || ^3.0.0 || ^4.0.0" + } + }, + "node_modules/roughjs": { + "version": "4.6.6", + "resolved": "https://registry.npmjs.org/roughjs/-/roughjs-4.6.6.tgz", + "integrity": "sha512-ZUz/69+SYpFN/g/lUlo2FXcIjRkSu3nDarreVdGGndHEBJ6cXPdKguS8JGxwj5HA5xIbVKSmLgr5b3AWxtRfvQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "hachure-fill": "^0.5.2", + "path-data-parser": "^0.1.0", + "points-on-curve": "^0.2.0", + "points-on-path": "^0.2.1" + } + }, + "node_modules/run-parallel": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", + "integrity": "sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT", + "dependencies": { + "queue-microtask": "^1.2.2" + } + }, + "node_modules/rw": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/rw/-/rw-1.3.3.tgz", + "integrity": "sha512-PdhdWy89SiZogBLaw42zdeqtRJ//zFd2PgQavcICDUgJT5oW10QCRKbJ6bg4r0/UY2M6BWd5tkxuGFRvCkgfHQ==", + "dev": true, + "license": "BSD-3-Clause" + }, + "node_modules/rxjs": { + "version": "7.8.2", + "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.8.2.tgz", + "integrity": "sha512-dhKf903U/PQZY6boNNtAGdWbG85WAbjT/1xYoZIC7FAY0yWapOBQVsVrDl58W86//e1VpMNBtRV4MaXfdMySFA==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "tslib": "^2.1.0" + } + }, + "node_modules/safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT" + }, + "node_modules/safe-stable-stringify": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/safe-stable-stringify/-/safe-stable-stringify-2.5.0.tgz", + "integrity": "sha512-b3rppTKm9T+PsVCBEOUR46GWI7fdOs00VKZ1+9c1EWDaDMvjQc6tUwuFyIprgGgTcWoVHSKrU8H31ZHA2e0RHA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + } + }, + "node_modules/safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", + "dev": true, + "license": "MIT" + }, + "node_modules/scheduler": { + "version": "0.27.0", + "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.27.0.tgz", + "integrity": "sha512-eNv+WrVbKu1f3vbYJT/xtiF5syA5HPIMtf9IgY/nKg0sWqzAUEvqY/xm7OcZc/qafLx/iO9FgOmeSAp4v5ti/Q==", + "dev": true, + "license": "MIT" + }, + "node_modules/search-insights": { + "version": "2.17.3", + "resolved": "https://registry.npmjs.org/search-insights/-/search-insights-2.17.3.tgz", + "integrity": "sha512-RQPdCYTa8A68uM2jwxoY842xDhvx3E5LFL1LxvxCNMev4o5mLuokczhzjAgGwUZBAmOKZknArSxLKmXtIi2AxQ==", + "dev": true, + "license": "MIT", + "peer": true + }, + "node_modules/semver": { + "version": "7.7.3", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.3.tgz", + "integrity": "sha512-SdsKMrI9TdgjdweUSR9MweHA4EJ8YxHn8DFaDisvhVlUOe4BF1tLD7GAj0lIqWVl+dPb/rExr0Btby5loQm20Q==", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/serialize-javascript": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.2.tgz", + "integrity": "sha512-Saa1xPByTTq2gdeFZYLLo+RFE35NHZkAbqZeWNd3BpzppeVisAqpDjcp8dyf6uIvEqJRd46jemmyA4iFIeVk8g==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "randombytes": "^2.1.0" + } + }, + "node_modules/set-blocking": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", + "integrity": "sha512-KiKBS8AnWGEyLzofFfmvKwpdPzqiy16LvQfK3yv/fVH7Bj13/wl3JSR1J+rfgRE9q7xUJK4qvgS8raSOeLUehw==", + "dev": true, + "license": "ISC" + }, + "node_modules/set-function-length": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.2.2.tgz", + "integrity": "sha512-pgRc4hJ4/sNjWCSS9AmnS40x3bNMDTknHgL5UaMBTMyJnU90EgWh1Rz+MC9eFu4BuN/UwZjKQuY/1v3rM7HMfg==", + "dev": true, + "license": "MIT", + "dependencies": { + "define-data-property": "^1.1.4", + "es-errors": "^1.3.0", + "function-bind": "^1.1.2", + "get-intrinsic": "^1.2.4", + "gopd": "^1.0.1", + "has-property-descriptors": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/shebang-command": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "dev": true, + "license": "MIT", + "dependencies": { + "shebang-regex": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/shebang-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/shell-quote": { + "version": "1.8.3", + "resolved": "https://registry.npmjs.org/shell-quote/-/shell-quote-1.8.3.tgz", + "integrity": "sha512-ObmnIF4hXNg1BqhnHmgbDETF8dLPCggZWBjkQfhZpbszZnYur5DUljTcCHii5LC3J5E0yeO/1LIMyH+UvHQgyw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/shelljs": { + "version": "0.9.2", + "resolved": "https://registry.npmjs.org/shelljs/-/shelljs-0.9.2.tgz", + "integrity": "sha512-S3I64fEiKgTZzKCC46zT/Ib9meqofLrQVbpSswtjFfAVDW+AZ54WTnAM/3/yENoxz/V1Cy6u3kiiEbQ4DNphvw==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "execa": "^1.0.0", + "fast-glob": "^3.3.2", + "interpret": "^1.0.0", + "rechoir": "^0.6.2" + }, + "bin": { + "shjs": "bin/shjs" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/shiki": { + "version": "3.21.0", + "resolved": "https://registry.npmjs.org/shiki/-/shiki-3.21.0.tgz", + "integrity": "sha512-N65B/3bqL/TI2crrXr+4UivctrAGEjmsib5rPMMPpFp1xAx/w03v8WZ9RDDFYteXoEgY7qZ4HGgl5KBIu1153w==", + "dev": true, + "license": "MIT", + "dependencies": { + "@shikijs/core": "3.21.0", + "@shikijs/engine-javascript": "3.21.0", + "@shikijs/engine-oniguruma": "3.21.0", + "@shikijs/langs": "3.21.0", + "@shikijs/themes": "3.21.0", + "@shikijs/types": "3.21.0", + "@shikijs/vscode-textmate": "^10.0.2", + "@types/hast": "^3.0.4" + } + }, + "node_modules/shx": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/shx/-/shx-0.4.0.tgz", + "integrity": "sha512-Z0KixSIlGPpijKgcH6oCMCbltPImvaKy0sGH8AkLRXw1KyzpKtaCTizP2xen+hNDqVF4xxgvA0KXSb9o4Q6hnA==", + "dev": true, + "license": "MIT", + "dependencies": { + "minimist": "^1.2.8", + "shelljs": "^0.9.2" + }, + "bin": { + "shx": "lib/cli.js" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/signal-exit": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", + "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==", + "dev": true, + "license": "ISC", + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/simple-update-notifier": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/simple-update-notifier/-/simple-update-notifier-2.0.0.tgz", + "integrity": "sha512-a2B9Y0KlNXl9u/vsW6sTIu9vGEpfKu2wRV6l1H3XEas/0gUIzGzBoP/IouTcUQbm9JWZLH3COxyn03TYlFax6w==", + "dev": true, + "license": "MIT", + "dependencies": { + "semver": "^7.5.3" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/slash": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/slash/-/slash-2.0.0.tgz", + "integrity": "sha512-ZYKh3Wh2z1PpEXWr0MpSBZ0V6mZHAQfYevttO11c51CaWjGTaadiKZ+wVt1PbMlDV5qhMFslpZCemhwOK7C89A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/slice-ansi": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-7.1.2.tgz", + "integrity": "sha512-iOBWFgUX7caIZiuutICxVgX1SdxwAVFFKwt1EvMYYec/NWO5meOJ6K5uQxhrYBdQJne4KxiqZc+KptFOWFSI9w==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-styles": "^6.2.1", + "is-fullwidth-code-point": "^5.0.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/chalk/slice-ansi?sponsor=1" + } + }, + "node_modules/smart-buffer": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/smart-buffer/-/smart-buffer-4.2.0.tgz", + "integrity": "sha512-94hK0Hh8rPqQl2xXc3HsaBoOXKV20MToPkcXvwbISWLEs+64sBq5kFgn2kJDHb1Pry9yrP0dxrCI9RRci7RXKg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 6.0.0", + "npm": ">= 3.0.0" + } + }, + "node_modules/smob": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/smob/-/smob-1.5.0.tgz", + "integrity": "sha512-g6T+p7QO8npa+/hNx9ohv1E5pVCmWrVCUzUXJyLdMmftX6ER0oiWY/w9knEonLpnOp6b6FenKnMfR8gqwWdwig==", + "dev": true, + "license": "MIT" + }, + "node_modules/socks": { + "version": "2.8.7", + "resolved": "https://registry.npmjs.org/socks/-/socks-2.8.7.tgz", + "integrity": "sha512-HLpt+uLy/pxB+bum/9DzAgiKS8CX1EvbWxI4zlmgGCExImLdiad2iCwXT5Z4c9c3Eq8rP2318mPW2c+QbtjK8A==", + "dev": true, + "license": "MIT", + "dependencies": { + "ip-address": "^10.0.1", + "smart-buffer": "^4.2.0" + }, + "engines": { + "node": ">= 10.0.0", + "npm": ">= 3.0.0" + } + }, + "node_modules/socks-proxy-agent": { + "version": "8.0.5", + "resolved": "https://registry.npmjs.org/socks-proxy-agent/-/socks-proxy-agent-8.0.5.tgz", + "integrity": "sha512-HehCEsotFqbPW9sJ8WVYB6UbmIMv7kUUORIF2Nncq4VQvBfNBLibW9YZR5dlYCSUhwcD628pRllm7n+E+YTzJw==", + "dev": true, + "license": "MIT", + "dependencies": { + "agent-base": "^7.1.2", + "debug": "^4.3.4", + "socks": "^2.8.3" + }, + "engines": { + "node": ">= 14" + } + }, + "node_modules/sonic-boom": { + "version": "3.8.1", + "resolved": "https://registry.npmjs.org/sonic-boom/-/sonic-boom-3.8.1.tgz", + "integrity": "sha512-y4Z8LCDBuum+PBP3lSV7RHrXscqksve/bi0as7mhwVnBW+/wUqKT/2Kb7um8yqcFy0duYbbPxzt89Zy2nOCaxg==", + "dev": true, + "license": "MIT", + "dependencies": { + "atomic-sleep": "^1.0.0" + } + }, + "node_modules/source-map": { + "version": "0.7.6", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.7.6.tgz", + "integrity": "sha512-i5uvt8C3ikiWeNZSVZNWcfZPItFQOsYTUAOkcUPGd8DqDy1uOUikjt5dG+uRlwyvR108Fb9DOd4GvXfT0N2/uQ==", + "dev": true, + "license": "BSD-3-Clause", + "engines": { + "node": ">= 12" + } + }, + "node_modules/source-map-js": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz", + "integrity": "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==", + "dev": true, + "license": "BSD-3-Clause", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/source-map-support": { + "version": "0.5.21", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz", + "integrity": "sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==", + "dev": true, + "license": "MIT", + "dependencies": { + "buffer-from": "^1.0.0", + "source-map": "^0.6.0" + } + }, + "node_modules/source-map-support/node_modules/source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true, + "license": "BSD-3-Clause", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/sourcemap-codec": { + "version": "1.4.8", + "resolved": "https://registry.npmjs.org/sourcemap-codec/-/sourcemap-codec-1.4.8.tgz", + "integrity": "sha512-9NykojV5Uih4lgo5So5dtw+f0JgJX30KCNI8gwhz2J9A15wD0Ml6tjHKwf6fTSa6fAdVBdZeNOs9eJ71qCk8vA==", + "deprecated": "Please use @jridgewell/sourcemap-codec instead", + "dev": true, + "license": "MIT" + }, + "node_modules/space-separated-tokens": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/space-separated-tokens/-/space-separated-tokens-2.0.2.tgz", + "integrity": "sha512-PEGlAwrG8yXGXRjW32fGbg66JAlOAwbObuqVoJpv/mRgoWDQfgH1wDPvtzWyUSNAXBGSk8h755YDbbcEy3SH2Q==", + "dev": true, + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/spawn-shell": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/spawn-shell/-/spawn-shell-2.1.0.tgz", + "integrity": "sha512-mjlYAQbZPHd4YsoHEe+i0Xbp9sJefMKN09JPp80TqrjC5NSuo+y1RG3NBireJlzl1dDV2NIkIfgS6coXtyqN/A==", + "dev": true, + "license": "MIT", + "dependencies": { + "default-shell": "^1.0.1", + "merge-options": "~1.0.1", + "npm-run-path": "^2.0.2" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/spawn-wrap": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/spawn-wrap/-/spawn-wrap-2.0.0.tgz", + "integrity": "sha512-EeajNjfN9zMnULLwhZZQU3GWBoFNkbngTUPfaawT4RkMiviTxcX0qfhVbGey39mfctfDHkWtuecgQ8NJcyQWHg==", + "dev": true, + "license": "ISC", + "dependencies": { "foreground-child": "^2.0.0", - "get-package-type": "^0.1.0", - "glob": "^7.1.6", - "istanbul-lib-coverage": "^3.0.0", - "istanbul-lib-hook": "^3.0.0", - "istanbul-lib-instrument": "^4.0.0", - "istanbul-lib-processinfo": "^2.0.2", - "istanbul-lib-report": "^3.0.0", - "istanbul-lib-source-maps": "^4.0.0", - "istanbul-reports": "^3.0.2", + "is-windows": "^1.0.2", "make-dir": "^3.0.0", - "node-preload": "^0.2.1", - "p-map": "^3.0.0", - "process-on-spawn": "^1.0.0", - "resolve-from": "^5.0.0", "rimraf": "^3.0.0", "signal-exit": "^3.0.2", - "spawn-wrap": "^2.0.0", - "test-exclude": "^6.0.0", - "yargs": "^15.0.2" + "which": "^2.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/spawn-wrap/node_modules/foreground-child": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-2.0.0.tgz", + "integrity": "sha512-dCIq9FpEcyQyXKCkyzmlPTFNgrCzPudOe+mhvJU5zAtlBnGVy2yKxtfsxK2tQBThwq225jcvBjpw1Gr40uzZCA==", + "dev": true, + "license": "ISC", + "dependencies": { + "cross-spawn": "^7.0.0", + "signal-exit": "^3.0.2" + }, + "engines": { + "node": ">=8.0.0" + } + }, + "node_modules/spawn-wrap/node_modules/signal-exit": { + "version": "3.0.7", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz", + "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==", + "dev": true, + "license": "ISC" + }, + "node_modules/spdx-compare": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/spdx-compare/-/spdx-compare-1.0.0.tgz", + "integrity": "sha512-C1mDZOX0hnu0ep9dfmuoi03+eOdDoz2yvK79RxbcrVEG1NO1Ph35yW102DHWKN4pk80nwCgeMmSY5L25VE4D9A==", + "dev": true, + "license": "MIT", + "dependencies": { + "array-find-index": "^1.0.2", + "spdx-expression-parse": "^3.0.0", + "spdx-ranges": "^2.0.0" + } + }, + "node_modules/spdx-exceptions": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.5.0.tgz", + "integrity": "sha512-PiU42r+xO4UbUS1buo3LPJkjlO7430Xn5SVAhdpzzsPHsjbYVflnnFdATgabnLude+Cqu25p6N+g2lw/PFsa4w==", + "dev": true, + "license": "CC-BY-3.0" + }, + "node_modules/spdx-expression-parse": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-3.0.1.tgz", + "integrity": "sha512-cbqHunsQWnJNE6KhVSMsMeH5H/L9EpymbzqTQ3uLwNCLZ1Q481oWaofqH7nO6V07xlXwY6PhQdQ2IedWx/ZK4Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "spdx-exceptions": "^2.1.0", + "spdx-license-ids": "^3.0.0" + } + }, + "node_modules/spdx-expression-validate": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/spdx-expression-validate/-/spdx-expression-validate-2.0.0.tgz", + "integrity": "sha512-b3wydZLM+Tc6CFvaRDBOF9d76oGIHNCLYFeHbftFXUWjnfZWganmDmvtM5sm1cRwJc/VDBMLyGGrsLFd1vOxbg==", + "dev": true, + "license": "(MIT AND CC-BY-3.0)", + "dependencies": { + "spdx-expression-parse": "^3.0.0" + } + }, + "node_modules/spdx-license-ids": { + "version": "3.0.22", + "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.22.tgz", + "integrity": "sha512-4PRT4nh1EImPbt2jASOKHX7PB7I+e4IWNLvkKFDxNhJlfjbYlleYQh285Z/3mPTHSAK/AvdMmw5BNNuYH8ShgQ==", + "dev": true, + "license": "CC0-1.0" + }, + "node_modules/spdx-ranges": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/spdx-ranges/-/spdx-ranges-2.1.1.tgz", + "integrity": "sha512-mcdpQFV7UDAgLpXEE/jOMqvK4LBoO0uTQg0uvXUewmEFhpiZx5yJSZITHB8w1ZahKdhfZqP5GPEOKLyEq5p8XA==", + "dev": true, + "license": "(MIT AND CC-BY-3.0)" + }, + "node_modules/spdx-satisfies": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/spdx-satisfies/-/spdx-satisfies-5.0.1.tgz", + "integrity": "sha512-Nwor6W6gzFp8XX4neaKQ7ChV4wmpSh2sSDemMFSzHxpTw460jxFYeOn+jq4ybnSSw/5sc3pjka9MQPouksQNpw==", + "dev": true, + "license": "MIT", + "dependencies": { + "spdx-compare": "^1.0.0", + "spdx-expression-parse": "^3.0.0", + "spdx-ranges": "^2.0.0" + } + }, + "node_modules/speakingurl": { + "version": "14.0.1", + "resolved": "https://registry.npmjs.org/speakingurl/-/speakingurl-14.0.1.tgz", + "integrity": "sha512-1POYv7uv2gXoyGFpBCmpDVSNV74IfsWlDW216UPjbWufNf+bSU6GdbDsxdcxtfwb4xlI3yxzOTKClUosxARYrQ==", + "dev": true, + "license": "BSD-3-Clause", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/split2": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/split2/-/split2-4.2.0.tgz", + "integrity": "sha512-UcjcJOWknrNkF6PLX83qcHM6KHgVKNkV62Y8a5uYDVv9ydGQVwAHMKqHdJje1VTWpljG0WYpCDhrCdAOYH4TWg==", + "dev": true, + "license": "ISC", + "engines": { + "node": ">= 10.x" + } + }, + "node_modules/sprintf-js": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", + "integrity": "sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==", + "dev": true, + "license": "BSD-3-Clause" + }, + "node_modules/streamx": { + "version": "2.23.0", + "resolved": "https://registry.npmjs.org/streamx/-/streamx-2.23.0.tgz", + "integrity": "sha512-kn+e44esVfn2Fa/O0CPFcex27fjIL6MkVae0Mm6q+E6f0hWv578YCERbv+4m02cjxvDsPKLnmxral/rR6lBMAg==", + "dev": true, + "license": "MIT", + "dependencies": { + "events-universal": "^1.0.0", + "fast-fifo": "^1.3.2", + "text-decoder": "^1.1.0" + } + }, + "node_modules/string-argv": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/string-argv/-/string-argv-0.3.2.tgz", + "integrity": "sha512-aqD2Q0144Z+/RqG52NeHEkZauTAUWJO8c6yTftGJKO3Tja5tUgIfmIl6kExvhtxSDP7fXB6DvzkfMpCd/F3G+Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.6.19" + } + }, + "node_modules/string-width": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-8.1.0.tgz", + "integrity": "sha512-Kxl3KJGb/gxkaUMOjRsQ8IrXiGW75O4E3RPjFIINOVH8AMl2SQ/yWdTzWwF3FevIX9LcMAjJW+GRwAlAbTSXdg==", + "dev": true, + "license": "MIT", + "dependencies": { + "get-east-asian-width": "^1.3.0", + "strip-ansi": "^7.1.0" + }, + "engines": { + "node": ">=20" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/string-width-cjs": { + "name": "string-width", + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dev": true, + "license": "MIT", + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/string-width-cjs/node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/string-width-cjs/node_modules/is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/string-width-cjs/node_modules/strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-regex": "^5.0.1" }, + "engines": { + "node": ">=8" + } + }, + "node_modules/stringify-entities": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/stringify-entities/-/stringify-entities-4.0.4.tgz", + "integrity": "sha512-IwfBptatlO+QCJUo19AqvrPNqlVMpW9YEL2LIVY+Rpv2qsjCGxaDLNRgeGsQWJhfItebuJhsGSLjaBbNSQ+ieg==", + "dev": true, + "license": "MIT", "dependencies": { - "ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "requires": { - "color-convert": "^2.0.1" - } - }, - "camelcase": { - "version": "5.3.1", - "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", - "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==", - "dev": true - }, - "cliui": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/cliui/-/cliui-6.0.0.tgz", - "integrity": "sha512-t6wbgtoCXvAzst7QgXxJYqPt0usEfbgQdftEPbLL/cvv6HPE5VgvqCuAIDR0NgU52ds6rFwqrgakNLrHEjCbrQ==", - "dev": true, - "requires": { - "string-width": "^4.2.0", - "strip-ansi": "^6.0.0", - "wrap-ansi": "^6.2.0" - } - }, - "color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "requires": { - "color-name": "~1.1.4" - } - }, - "color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true - }, - "decamelize": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", - "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=", - "dev": true - }, - "find-up": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", - "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", - "dev": true, - "requires": { - "locate-path": "^5.0.0", - "path-exists": "^4.0.0" - } - }, - "locate-path": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", - "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", - "dev": true, - "requires": { - "p-locate": "^4.1.0" - } - }, - "p-limit": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", - "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", - "dev": true, - "requires": { - "p-try": "^2.0.0" - } - }, - "p-locate": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", - "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", - "dev": true, - "requires": { - "p-limit": "^2.2.0" - } - }, - "p-map": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/p-map/-/p-map-3.0.0.tgz", - "integrity": "sha512-d3qXVTF/s+W+CdJ5A29wywV2n8CQQYahlgz2bFiA+4eVNJbHJodPZ+/gXwPGh0bOqA+j8S+6+ckmvLGPk1QpxQ==", - "dev": true, - "requires": { - "aggregate-error": "^3.0.0" - } - }, - "p-try": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", - "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", - "dev": true - }, - "path-exists": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", - "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", - "dev": true - }, - "resolve-from": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-5.0.0.tgz", - "integrity": "sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==", - "dev": true - }, - "wrap-ansi": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-6.2.0.tgz", - "integrity": "sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==", - "dev": true, - "requires": { - "ansi-styles": "^4.0.0", - "string-width": "^4.1.0", - "strip-ansi": "^6.0.0" - } - }, - "y18n": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.1.tgz", - "integrity": "sha512-wNcy4NvjMYL8gogWWYAO7ZFWFfHcbdbE57tZO8e4cbpj8tfUcwrwqSl3ad8HxpYWCdXcJUCeKKZS62Av1affwQ==", - "dev": true - }, - "yargs": { - "version": "15.4.1", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-15.4.1.tgz", - "integrity": "sha512-aePbxDmcYW++PaqBsJ+HYUFwCdv4LVvdnhBy78E57PIor8/OVvhMrADFFEDh8DHDFRv/O9i3lPhsENjO7QX0+A==", - "dev": true, - "requires": { - "cliui": "^6.0.0", - "decamelize": "^1.2.0", - "find-up": "^4.1.0", - "get-caller-file": "^2.0.1", - "require-directory": "^2.1.1", - "require-main-filename": "^2.0.0", - "set-blocking": "^2.0.0", - "string-width": "^4.2.0", - "which-module": "^2.0.0", - "y18n": "^4.0.0", - "yargs-parser": "^18.1.2" - } - }, - "yargs-parser": { - "version": "18.1.3", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-18.1.3.tgz", - "integrity": "sha512-o50j0JeToy/4K6OZcaQmW6lyXXKhq7csREXcDwk2omFPJEwUNOVtJKvmDr9EI1fAJZUyZcRF7kxGBWmRXudrCQ==", - "dev": true, - "requires": { - "camelcase": "^5.0.0", - "decamelize": "^1.2.0" - } - } + "character-entities-html4": "^2.0.0", + "character-entities-legacy": "^3.0.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" } }, - "object-inspect": { - "version": "1.9.0", - "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.9.0.tgz", - "integrity": "sha512-i3Bp9iTqwhaLZBxGkRfo5ZbE07BQRT7MGu8+nNgwW9ItGp1TzCTw2DLEoWwjClxBjOFI/hWljTAmYGCEwmtnOw==", - "dev": true + "node_modules/strip-ansi": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.2.tgz", + "integrity": "sha512-gmBGslpoQJtgnMAvOVqGZpEz9dyoKTCzy2nfz/n8aIFhN/jCE/rCmcxabB6jOOHV+0WNnylOxaxBQPSvcWklhA==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-regex": "^6.0.1" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/strip-ansi?sponsor=1" + } }, - "object-keys": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz", - "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==", - "dev": true + "node_modules/strip-ansi-cjs": { + "name": "strip-ansi", + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } }, - "object.assign": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.2.tgz", - "integrity": "sha512-ixT2L5THXsApyiUPYKmW+2EHpXXe5Ii3M+f4e+aJFAHao5amFRW6J0OO6c/LU8Be47utCx2GL89hxGB6XSmKuQ==", + "node_modules/strip-ansi-cjs/node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", "dev": true, - "requires": { - "call-bind": "^1.0.0", - "define-properties": "^1.1.3", - "has-symbols": "^1.0.1", - "object-keys": "^1.1.1" + "license": "MIT", + "engines": { + "node": ">=8" } }, - "object.values": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/object.values/-/object.values-1.1.2.tgz", - "integrity": "sha512-MYC0jvJopr8EK6dPBiO8Nb9mvjdypOachO5REGk6MXzujbBrAisKo3HmdEI6kZDL6fC31Mwee/5YbtMebixeag==", + "node_modules/strip-bom": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-4.0.0.tgz", + "integrity": "sha512-3xurFv5tEgii33Zi8Jtp55wEIILR9eh34FAW00PZf+JnSsTmV/ioewSgQl97JHvgjoRGwPShsWm+IdrxB35d0w==", "dev": true, - "requires": { - "call-bind": "^1.0.0", - "define-properties": "^1.1.3", - "es-abstract": "^1.18.0-next.1", - "has": "^1.0.3" + "license": "MIT", + "engines": { + "node": ">=8" } }, - "once": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", - "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "node_modules/strip-eof": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/strip-eof/-/strip-eof-1.0.0.tgz", + "integrity": "sha512-7FCwGGmx8mD5xQd3RPUvnSpUXHM3BWuzjtpD4TXsfcZ9EL4azvVVUscFYwD9nx8Kh+uCBC00XBtAykoMHwTh8Q==", "dev": true, - "requires": { - "wrappy": "1" + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/strip-indent": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/strip-indent/-/strip-indent-4.1.1.tgz", + "integrity": "sha512-SlyRoSkdh1dYP0PzclLE7r0M9sgbFKKMFXpFRUMNuKhQSbC6VQIGzq3E0qsfvGJaUFJPGv6Ws1NZ/haTAjfbMA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/strip-json-comments": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", + "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/style-mod": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/style-mod/-/style-mod-4.1.3.tgz", + "integrity": "sha512-i/n8VsZydrugj3Iuzll8+x/00GH2vnYsk1eomD8QiRrSAeW6ItbCQDtfXCeJHd0iwiNagqjQkvpvREEPtW3IoQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/stylis": { + "version": "4.3.6", + "resolved": "https://registry.npmjs.org/stylis/-/stylis-4.3.6.tgz", + "integrity": "sha512-yQ3rwFWRfwNUY7H5vpU0wfdkNSnvnJinhF9830Swlaxl03zsOjCfmX0ugac+3LtK0lYSgwL/KXc8oYL3mG4YFQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/sucrase": { + "version": "3.35.1", + "resolved": "https://registry.npmjs.org/sucrase/-/sucrase-3.35.1.tgz", + "integrity": "sha512-DhuTmvZWux4H1UOnWMB3sk0sbaCVOoQZjv8u1rDoTV0HTdGem9hkAZtl4JZy8P2z4Bg0nT+YMeOFyVr4zcG5Tw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/gen-mapping": "^0.3.2", + "commander": "^4.0.0", + "lines-and-columns": "^1.1.6", + "mz": "^2.7.0", + "pirates": "^4.0.1", + "tinyglobby": "^0.2.11", + "ts-interface-checker": "^0.1.9" + }, + "bin": { + "sucrase": "bin/sucrase", + "sucrase-node": "bin/sucrase-node" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + } + }, + "node_modules/sucrase/node_modules/commander": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/commander/-/commander-4.1.1.tgz", + "integrity": "sha512-NOKm8xhkzAjzFx8B2v5OAHT+u5pRQc2UCa2Vq9jYL/31o2wi9mxBA7LIFs3sV5VSC49z6pEhfbMULvShKj26WA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 6" + } + }, + "node_modules/superjson": { + "version": "2.2.6", + "resolved": "https://registry.npmjs.org/superjson/-/superjson-2.2.6.tgz", + "integrity": "sha512-H+ue8Zo4vJmV2nRjpx86P35lzwDT3nItnIsocgumgr0hHMQ+ZGq5vrERg9kJBo5AWGmxZDhzDo+WVIJqkB0cGA==", + "dev": true, + "license": "MIT", + "dependencies": { + "copy-anything": "^4" + }, + "engines": { + "node": ">=16" + } + }, + "node_modules/supports-color": { + "version": "8.1.1", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", + "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/supports-color?sponsor=1" + } + }, + "node_modules/supports-preserve-symlinks-flag": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", + "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/synckit": { + "version": "0.11.12", + "resolved": "https://registry.npmjs.org/synckit/-/synckit-0.11.12.tgz", + "integrity": "sha512-Bh7QjT8/SuKUIfObSXNHNSK6WHo6J1tHCqJsuaFDP7gP0fkzSfTxI8y85JrppZ0h8l0maIgc2tfuZQ6/t3GtnQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@pkgr/core": "^0.2.9" + }, + "engines": { + "node": "^14.18.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/synckit" + } + }, + "node_modules/systemjs": { + "version": "6.15.1", + "resolved": "https://registry.npmjs.org/systemjs/-/systemjs-6.15.1.tgz", + "integrity": "sha512-Nk8c4lXvMB98MtbmjX7JwJRgJOL8fluecYCfCeYBznwmpOs8Bf15hLM6z4z71EDAhQVrQrI+wt1aLWSXZq+hXA==", + "dev": true, + "license": "MIT" + }, + "node_modules/tabbable": { + "version": "6.4.0", + "resolved": "https://registry.npmjs.org/tabbable/-/tabbable-6.4.0.tgz", + "integrity": "sha512-05PUHKSNE8ou2dwIxTngl4EzcnsCDZGJ/iCLtDflR/SHB/ny14rXc+qU5P4mG9JkusiV7EivzY9Mhm55AzAvCg==", + "dev": true, + "license": "MIT" + }, + "node_modules/tailwind-merge": { + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/tailwind-merge/-/tailwind-merge-3.4.0.tgz", + "integrity": "sha512-uSaO4gnW+b3Y2aWoWfFpX62vn2sR3skfhbjsEnaBI81WD1wBLlHZe5sWf0AqjksNdYTbGBEd0UasQMT3SNV15g==", + "dev": true, + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/dcastil" + } + }, + "node_modules/tailwindcss": { + "version": "3.4.19", + "resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-3.4.19.tgz", + "integrity": "sha512-3ofp+LL8E+pK/JuPLPggVAIaEuhvIz4qNcf3nA1Xn2o/7fb7s/TYpHhwGDv1ZU3PkBluUVaF8PyCHcm48cKLWQ==", + "dev": true, + "license": "MIT", + "peer": true, + "dependencies": { + "@alloc/quick-lru": "^5.2.0", + "arg": "^5.0.2", + "chokidar": "^3.6.0", + "didyoumean": "^1.2.2", + "dlv": "^1.1.3", + "fast-glob": "^3.3.2", + "glob-parent": "^6.0.2", + "is-glob": "^4.0.3", + "jiti": "^1.21.7", + "lilconfig": "^3.1.3", + "micromatch": "^4.0.8", + "normalize-path": "^3.0.0", + "object-hash": "^3.0.0", + "picocolors": "^1.1.1", + "postcss": "^8.4.47", + "postcss-import": "^15.1.0", + "postcss-js": "^4.0.1", + "postcss-load-config": "^4.0.2 || ^5.0 || ^6.0", + "postcss-nested": "^6.2.0", + "postcss-selector-parser": "^6.1.2", + "resolve": "^1.22.8", + "sucrase": "^3.35.0" + }, + "bin": { + "tailwind": "lib/cli.js", + "tailwindcss": "lib/cli.js" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/tailwindcss/node_modules/glob-parent": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-6.0.2.tgz", + "integrity": "sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==", + "dev": true, + "license": "ISC", + "dependencies": { + "is-glob": "^4.0.3" + }, + "engines": { + "node": ">=10.13.0" + } + }, + "node_modules/tailwindcss/node_modules/postcss-selector-parser": { + "version": "6.1.2", + "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-6.1.2.tgz", + "integrity": "sha512-Q8qQfPiZ+THO/3ZrOrO0cJJKfpYCagtMUkXbnEfmgUjwXg6z/WBeOyS9APBBPCTSiDV+s4SwQGu8yFsiMRIudg==", + "dev": true, + "license": "MIT", + "dependencies": { + "cssesc": "^3.0.0", + "util-deprecate": "^1.0.2" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/tar": { + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/tar/-/tar-6.2.1.tgz", + "integrity": "sha512-DZ4yORTwrbTj/7MZYq2w+/ZFdI6OZ/f9SFHR+71gIVUZhOQPHzVCLpvRnPgyaMpfWxxk/4ONva3GQSyNIKRv6A==", + "dev": true, + "license": "ISC", + "dependencies": { + "chownr": "^2.0.0", + "fs-minipass": "^2.0.0", + "minipass": "^5.0.0", + "minizlib": "^2.1.1", + "mkdirp": "^1.0.3", + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/tar-fs": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-3.1.1.tgz", + "integrity": "sha512-LZA0oaPOc2fVo82Txf3gw+AkEd38szODlptMYejQUhndHMLQ9M059uXR+AfS7DNo0NpINvSqDsvyaCrBVkptWg==", + "dev": true, + "license": "MIT", + "dependencies": { + "pump": "^3.0.0", + "tar-stream": "^3.1.5" + }, + "optionalDependencies": { + "bare-fs": "^4.0.1", + "bare-path": "^3.0.0" + } + }, + "node_modules/tar-stream": { + "version": "3.1.7", + "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-3.1.7.tgz", + "integrity": "sha512-qJj60CXt7IU1Ffyc3NJMjh6EkuCFej46zUqJ4J7pqYlThyd9bO0XBTmcOIhSzZJVWfsLks0+nle/j538YAW9RQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "b4a": "^1.6.4", + "fast-fifo": "^1.2.0", + "streamx": "^2.15.0" + } + }, + "node_modules/tar/node_modules/minipass": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-5.0.0.tgz", + "integrity": "sha512-3FnjYuehv9k6ovOEbyOswadCDPX1piCfhV8ncmYtHOjuPwylVWsghTLo7rabjC3Rx5xD4HDx8Wm1xnMF7S5qFQ==", + "dev": true, + "license": "ISC", + "engines": { + "node": ">=8" + } + }, + "node_modules/tar/node_modules/yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", + "dev": true, + "license": "ISC" + }, + "node_modules/terser": { + "version": "5.46.0", + "resolved": "https://registry.npmjs.org/terser/-/terser-5.46.0.tgz", + "integrity": "sha512-jTwoImyr/QbOWFFso3YoU3ik0jBBDJ6JTOQiy/J2YxVJdZCc+5u7skhNwiOR3FQIygFqVUPHl7qbbxtjW2K3Qg==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "@jridgewell/source-map": "^0.3.3", + "acorn": "^8.15.0", + "commander": "^2.20.0", + "source-map-support": "~0.5.20" + }, + "bin": { + "terser": "bin/terser" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/terser/node_modules/commander": { + "version": "2.20.3", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", + "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/test-exclude": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/test-exclude/-/test-exclude-6.0.0.tgz", + "integrity": "sha512-cAGWPIyOHU6zlmg88jwm7VRyXnMN7iV68OGAbYDk/Mh/xC/pzVPlQtY6ngoIH/5/tciuhGfvESU8GrHrcxD56w==", + "dev": true, + "license": "ISC", + "dependencies": { + "@istanbuljs/schema": "^0.1.2", + "glob": "^7.1.4", + "minimatch": "^3.0.4" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/test-exclude/node_modules/glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "deprecated": "Glob versions prior to v9 are no longer supported", + "dev": true, + "license": "ISC", + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/text-decoder": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/text-decoder/-/text-decoder-1.2.3.tgz", + "integrity": "sha512-3/o9z3X0X0fTupwsYvR03pJ/DjWuqqrfwBgTQzdWDiQSm9KitAyz/9WqsT2JQW7KV2m+bC2ol/zqpW37NHxLaA==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "b4a": "^1.6.4" + } + }, + "node_modules/thenify": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/thenify/-/thenify-3.3.1.tgz", + "integrity": "sha512-RVZSIV5IG10Hk3enotrhvz0T9em6cyHBLkH/YAZuKqd8hRkKhSfCGIcP2KUY0EPxndzANBmNllzWPwak+bheSw==", + "dev": true, + "license": "MIT", + "dependencies": { + "any-promise": "^1.0.0" + } + }, + "node_modules/thenify-all": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/thenify-all/-/thenify-all-1.6.0.tgz", + "integrity": "sha512-RNxQH/qI8/t3thXJDwcstUO4zeqo64+Uy/+sNVRBx4Xn2OX+OZ9oP+iJnNFqplFra2ZUVeKCSa2oVWi3T4uVmA==", + "dev": true, + "license": "MIT", + "dependencies": { + "thenify": ">= 3.1.0 < 4" + }, + "engines": { + "node": ">=0.8" + } + }, + "node_modules/thingies": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/thingies/-/thingies-2.5.0.tgz", + "integrity": "sha512-s+2Bwztg6PhWUD7XMfeYm5qliDdSiZm7M7n8KjTkIsm3l/2lgVRc2/Gx/v+ZX8lT4FMA+i8aQvhcWylldc+ZNw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10.18" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/streamich" + }, + "peerDependencies": { + "tslib": "^2" + } + }, + "node_modules/thread-stream": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/thread-stream/-/thread-stream-2.7.0.tgz", + "integrity": "sha512-qQiRWsU/wvNolI6tbbCKd9iKaTnCXsTwVxhhKM6nctPdujTyztjlbUkUTUymidWcMnZ5pWR0ej4a0tjsW021vw==", + "dev": true, + "license": "MIT", + "dependencies": { + "real-require": "^0.2.0" + } + }, + "node_modules/through": { + "version": "2.3.8", + "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", + "integrity": "sha512-w89qg7PI8wAdvX60bMDP+bFoD5Dvhm9oLheFp5O4a2QF0cSBGsBX4qZmadPMvVqlLJBBci+WqGGOAPvcDeNSVg==", + "dev": true, + "license": "MIT" + }, + "node_modules/time-zone": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/time-zone/-/time-zone-2.0.0.tgz", + "integrity": "sha512-2cp/YLRm7ly33CzvySyXqo/QEOu4KMn6fCof0gpqosWY3PEJUJJhXP/Cb2wXFUuCzWWJYEmPvdHNzjLlfXC49A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/tinyexec": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/tinyexec/-/tinyexec-1.0.2.tgz", + "integrity": "sha512-W/KYk+NFhkmsYpuHq5JykngiOCnxeVL8v8dFnqxSD8qEEdRfXk1SDM6JzNqcERbcGYj9tMrDQBYV9cjgnunFIg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + } + }, + "node_modules/tinyglobby": { + "version": "0.2.15", + "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.15.tgz", + "integrity": "sha512-j2Zq4NyQYG5XMST4cbs02Ak8iJUdxRM0XI5QyxXuZOzKOINmWurp3smXu3y5wDcJrptwpSjgXHzIQxR0omXljQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "fdir": "^6.5.0", + "picomatch": "^4.0.3" + }, + "engines": { + "node": ">=12.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/SuperchupuDev" + } + }, + "node_modules/tmp": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.2.5.tgz", + "integrity": "sha512-voyz6MApa1rQGUxT3E+BK7/ROe8itEx7vD8/HEvt4xwXucvQ5G5oeEiHkmHZJuBO21RpOf+YYm9MOivj709jow==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=14.14" + } + }, + "node_modules/to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-number": "^7.0.0" + }, + "engines": { + "node": ">=8.0" + } + }, + "node_modules/token-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/token-stream/-/token-stream-1.0.0.tgz", + "integrity": "sha512-VSsyNPPW74RpHwR8Fc21uubwHY7wMDeJLys2IX5zJNih+OnAnaifKHo+1LHT7DAdloQ7apeaaWg8l7qnf/TnEg==", + "dev": true, + "license": "MIT" + }, + "node_modules/touch": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/touch/-/touch-3.1.1.tgz", + "integrity": "sha512-r0eojU4bI8MnHr8c5bNo7lJDdI2qXlWWJk6a9EAFG7vbhTjElYhBVS3/miuE0uOuoLdb8Mc/rVfsmm6eo5o9GA==", + "dev": true, + "license": "ISC", + "bin": { + "nodetouch": "bin/nodetouch.js" + } + }, + "node_modules/tree-dump": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/tree-dump/-/tree-dump-1.1.0.tgz", + "integrity": "sha512-rMuvhU4MCDbcbnleZTFezWsaZXRFemSqAM+7jPnzUl1fo9w3YEKOxAeui0fz3OI4EU4hf23iyA7uQRVko+UaBA==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=10.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/streamich" + }, + "peerDependencies": { + "tslib": "2" } }, - "onetime": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/onetime/-/onetime-5.1.2.tgz", - "integrity": "sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg==", + "node_modules/tree-kill": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/tree-kill/-/tree-kill-1.2.2.tgz", + "integrity": "sha512-L0Orpi8qGpRG//Nd+H90vFB+3iHnue1zSSGmNOOCh1GLJ7rUKVwV2HvijphGQS2UmhUZewS9VgvxYIdgr+fG1A==", "dev": true, - "requires": { - "mimic-fn": "^2.1.0" + "license": "MIT", + "bin": { + "tree-kill": "cli.js" } }, - "optionator": { - "version": "0.9.1", - "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.1.tgz", - "integrity": "sha512-74RlY5FCnhq4jRxVUPKDaRwrVNXMqsGsiW6AJw4XK8hmtm10wC0ypZBLw5IIp85NZMr91+qd1RvvENwg7jjRFw==", + "node_modules/trim-lines": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/trim-lines/-/trim-lines-3.0.1.tgz", + "integrity": "sha512-kRj8B+YHZCc9kQYdWfJB2/oUl9rA99qbowYYBtr4ui4mZyAQ2JpvVBd/6U2YloATfqBhBTSMhTpgBHtU0Mf3Rg==", "dev": true, - "requires": { - "deep-is": "^0.1.3", - "fast-levenshtein": "^2.0.6", - "levn": "^0.4.1", - "prelude-ls": "^1.2.1", - "type-check": "^0.4.0", - "word-wrap": "^1.2.3" + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" } }, - "p-limit": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-1.3.0.tgz", - "integrity": "sha512-vvcXsLAJ9Dr5rQOPk7toZQZJApBl2K4J6dANSsEuh6QI41JYcsS/qhTGa9ErIUUgK3WNQoJYvylxvjqmiqEA9Q==", + "node_modules/ts-api-utils": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-2.4.0.tgz", + "integrity": "sha512-3TaVTaAv2gTiMB35i3FiGJaRfwb3Pyn/j3m/bfAvGe8FB7CF6u+LMYqYlDh7reQf7UNvoTvdfAqHGmPGOSsPmA==", "dev": true, - "requires": { - "p-try": "^1.0.0" + "license": "MIT", + "engines": { + "node": ">=18.12" + }, + "peerDependencies": { + "typescript": ">=4.8.4" } }, - "p-locate": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-2.0.0.tgz", - "integrity": "sha1-IKAQOyIqcMj9OcwuWAaA893l7EM=", + "node_modules/ts-dedent": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/ts-dedent/-/ts-dedent-2.2.0.tgz", + "integrity": "sha512-q5W7tVM71e2xjHZTlgfTDoPF/SmqKG5hddq9SzR49CH2hayqRKJtQ4mtRlSxKaJlR/+9rEM+mnBHf7I2/BQcpQ==", "dev": true, - "requires": { - "p-limit": "^1.1.0" + "license": "MIT", + "engines": { + "node": ">=6.10" } }, - "p-map": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/p-map/-/p-map-4.0.0.tgz", - "integrity": "sha512-/bjOqmgETBYB5BoEeGVea8dmvHb2m9GLy1E9W43yeyfP6QQCZGFNa+XRceJEuDB6zqr+gKpIAmlLebMpykw/MQ==", + "node_modules/ts-interface-checker": { + "version": "0.1.13", + "resolved": "https://registry.npmjs.org/ts-interface-checker/-/ts-interface-checker-0.1.13.tgz", + "integrity": "sha512-Y/arvbn+rrz3JCKl9C4kVNfTfSm2/mEp5FSz5EsZSANGPSlQrpRI5M4PKF+mJnE52jOO90PnPSc3Ur3bTQw0gA==", "dev": true, - "requires": { - "aggregate-error": "^3.0.0" - } + "license": "Apache-2.0" }, - "p-try": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/p-try/-/p-try-1.0.0.tgz", - "integrity": "sha1-y8ec26+P1CKOE/Yh8rGiN8GyB7M=", - "dev": true + "node_modules/tslib": { + "version": "2.8.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz", + "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==", + "dev": true, + "license": "0BSD", + "peer": true }, - "package-hash": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/package-hash/-/package-hash-4.0.0.tgz", - "integrity": "sha512-whdkPIooSu/bASggZ96BWVvZTRMOFxnyUG5PnTSGKoJE2gd5mbVNmR2Nj20QFzxYYgAXpoqC+AiXzl+UMRh7zQ==", + "node_modules/twoslash": { + "version": "0.3.6", + "resolved": "https://registry.npmjs.org/twoslash/-/twoslash-0.3.6.tgz", + "integrity": "sha512-VuI5OKl+MaUO9UIW3rXKoPgHI3X40ZgB/j12VY6h98Ae1mCBihjPvhOPeJWlxCYcmSbmeZt5ZKkK0dsVtp+6pA==", "dev": true, - "requires": { - "graceful-fs": "^4.1.15", - "hasha": "^5.0.0", - "lodash.flattendeep": "^4.4.0", - "release-zalgo": "^1.0.0" + "license": "MIT", + "dependencies": { + "@typescript/vfs": "^1.6.2", + "twoslash-protocol": "0.3.6" + }, + "peerDependencies": { + "typescript": "^5.5.0" } }, - "package-name-regex": { - "version": "1.0.8", - "resolved": "https://registry.npmjs.org/package-name-regex/-/package-name-regex-1.0.8.tgz", - "integrity": "sha512-g3vB2J62dLqf4m50VM4tJUC4sixw3JB+Igd0cF3P/gJhAvmvsmFEV2eWZTeLbwfkKEWTf3+gwQ2C6JFFRxWHEQ==", - "dev": true - }, - "parent-module": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", - "integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==", + "node_modules/twoslash-protocol": { + "version": "0.3.6", + "resolved": "https://registry.npmjs.org/twoslash-protocol/-/twoslash-protocol-0.3.6.tgz", + "integrity": "sha512-FHGsJ9Q+EsNr5bEbgG3hnbkvEBdW5STgPU824AHUjB4kw0Dn4p8tABT7Ncg1Ie6V0+mDg3Qpy41VafZXcQhWMA==", "dev": true, - "requires": { - "callsites": "^3.0.0" - } + "license": "MIT" }, - "parse-json": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-2.2.0.tgz", - "integrity": "sha1-9ID0BDTvgHQfhGkJn43qGPVaTck=", + "node_modules/twoslash-vue": { + "version": "0.3.6", + "resolved": "https://registry.npmjs.org/twoslash-vue/-/twoslash-vue-0.3.6.tgz", + "integrity": "sha512-HXYxU+Y7jZiMXJN4980fQNMYflLD8uqKey1qVW5ri8bqYTm2t5ILmOoCOli7esdCHlMq4/No3iQUWBWDhZNs9w==", "dev": true, - "requires": { - "error-ex": "^1.2.0" + "license": "MIT", + "dependencies": { + "@vue/language-core": "^3.2.0", + "twoslash": "0.3.6", + "twoslash-protocol": "0.3.6" + }, + "funding": { + "url": "https://github.com/sponsors/antfu" + }, + "peerDependencies": { + "typescript": "^5.5.0" } }, - "parse-ms": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/parse-ms/-/parse-ms-2.1.0.tgz", - "integrity": "sha512-kHt7kzLoS9VBZfUsiKjv43mr91ea+U05EyKkEtqp7vNbHxmaVuEqN7XxeEVnGrMtYOAxGrDElSi96K7EgO1zCA==", - "dev": true - }, - "path-exists": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", - "integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=", - "dev": true - }, - "path-is-absolute": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", - "dev": true - }, - "path-key": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", - "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", - "dev": true + "node_modules/typanion": { + "version": "3.14.0", + "resolved": "https://registry.npmjs.org/typanion/-/typanion-3.14.0.tgz", + "integrity": "sha512-ZW/lVMRabETuYCd9O9ZvMhAh8GslSqaUjxmK/JLPCh6l73CvLBiuXswj/+7LdnWOgYsQ130FqLzFz5aGT4I3Ug==", + "dev": true, + "license": "MIT", + "workspaces": [ + "website" + ] }, - "path-parse": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", - "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==", - "dev": true + "node_modules/type-check": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", + "integrity": "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==", + "dev": true, + "license": "MIT", + "dependencies": { + "prelude-ls": "^1.2.1" + }, + "engines": { + "node": ">= 0.8.0" + } }, - "path-type": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/path-type/-/path-type-2.0.0.tgz", - "integrity": "sha1-8BLMuEFbcJb8LaoQVMPXI4lZTHM=", + "node_modules/type-fest": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.8.1.tgz", + "integrity": "sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA==", "dev": true, - "requires": { - "pify": "^2.0.0" + "license": "(MIT OR CC0-1.0)", + "engines": { + "node": ">=8" } }, - "picomatch": { - "version": "2.2.2", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.2.2.tgz", - "integrity": "sha512-q0M/9eZHzmr0AulXyPwNfZjtwZ/RBZlbN3K3CErVrk50T2ASYI7Bye0EvekFY3IP1Nt2DHu0re+V2ZHIpMkuWg==", - "dev": true + "node_modules/typed-query-selector": { + "version": "2.12.0", + "resolved": "https://registry.npmjs.org/typed-query-selector/-/typed-query-selector-2.12.0.tgz", + "integrity": "sha512-SbklCd1F0EiZOyPiW192rrHZzZ5sBijB6xM+cpmrwDqObvdtunOHHIk9fCGsoK5JVIYXoyEp4iEdE3upFH3PAg==", + "dev": true, + "license": "MIT" }, - "pify": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", - "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", - "dev": true + "node_modules/typedarray": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", + "integrity": "sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA==", + "dev": true, + "license": "MIT" }, - "pinst": { - "version": "2.1.4", - "resolved": "https://registry.npmjs.org/pinst/-/pinst-2.1.4.tgz", - "integrity": "sha512-T44k87is/GiSjONFxSl/uL6yGqwVpojdnUfbYzNeatDTM8uRCoCEQjuQ0g1oW6XENfbdO2XKtMfdGlDSQ19MJA==", + "node_modules/typedarray-to-buffer": { + "version": "3.1.5", + "resolved": "https://registry.npmjs.org/typedarray-to-buffer/-/typedarray-to-buffer-3.1.5.tgz", + "integrity": "sha512-zdu8XMNEDepKKR+XYOXAVPtWui0ly0NtohUscw+UmaHiAWT8hrV1rr//H6V+0DvJ3OQ19S979M0laLfX8rm82Q==", "dev": true, - "requires": { - "fromentries": "^1.3.2", - "write-json-file": "^4.3.0" + "license": "MIT", + "dependencies": { + "is-typedarray": "^1.0.0" } }, - "pkg-dir": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-2.0.0.tgz", - "integrity": "sha1-9tXREJ4Z1j7fQo4L1X4Sd3YVM0s=", + "node_modules/typescript": { + "version": "5.9.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz", + "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==", "dev": true, - "requires": { - "find-up": "^2.1.0" + "license": "Apache-2.0", + "peer": true, + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" } }, - "please-upgrade-node": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/please-upgrade-node/-/please-upgrade-node-3.2.0.tgz", - "integrity": "sha512-gQR3WpIgNIKwBMVLkpMUeR3e1/E1y42bqDQZfql+kDeXd8COYfM8PQA4X6y7a8u9Ua9FHmsrrmirW2vHs45hWg==", + "node_modules/typescript-auto-import-cache": { + "version": "0.3.6", + "resolved": "https://registry.npmjs.org/typescript-auto-import-cache/-/typescript-auto-import-cache-0.3.6.tgz", + "integrity": "sha512-RpuHXrknHdVdK7wv/8ug3Fr0WNsNi5l5aB8MYYuXhq2UH5lnEB1htJ1smhtD5VeCsGr2p8mUDtd83LCQDFVgjQ==", "dev": true, - "requires": { - "semver-compare": "^1.0.0" + "license": "MIT", + "dependencies": { + "semver": "^7.3.8" } }, - "prelude-ls": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", - "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==", - "dev": true - }, - "prettier": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.2.1.tgz", - "integrity": "sha512-PqyhM2yCjg/oKkFPtTGUojv7gnZAoG80ttl45O6x2Ug/rMJw4wcc9k6aaf2hibP7BGVCCM33gZoGjyvt9mm16Q==", - "dev": true - }, - "pretty-bytes": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/pretty-bytes/-/pretty-bytes-5.5.0.tgz", - "integrity": "sha512-p+T744ZyjjiaFlMUZZv6YPC5JrkNj8maRmPaQCWFJFplUAzpIUTRaTcS+7wmZtUoFXHtESJb23ISliaWyz3SHA==", - "dev": true - }, - "pretty-ms": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/pretty-ms/-/pretty-ms-7.0.1.tgz", - "integrity": "sha512-973driJZvxiGOQ5ONsFhOF/DtzPMOMtgC11kCpUrPGMTgqp2q/1gwzCquocrN33is0VZ5GFHXZYMM9l6h67v2Q==", + "node_modules/typescript-eslint": { + "version": "8.53.0", + "resolved": "https://registry.npmjs.org/typescript-eslint/-/typescript-eslint-8.53.0.tgz", + "integrity": "sha512-xHURCQNxZ1dsWn0sdOaOfCSQG0HKeqSj9OexIxrz6ypU6wHYOdX2I3D2b8s8wFSsSOYJb+6q283cLiLlkEsBYw==", "dev": true, - "requires": { - "parse-ms": "^2.1.0" + "license": "MIT", + "dependencies": { + "@typescript-eslint/eslint-plugin": "8.53.0", + "@typescript-eslint/parser": "8.53.0", + "@typescript-eslint/typescript-estree": "8.53.0", + "@typescript-eslint/utils": "8.53.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^8.57.0 || ^9.0.0", + "typescript": ">=4.8.4 <6.0.0" } }, - "process-on-spawn": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/process-on-spawn/-/process-on-spawn-1.0.0.tgz", - "integrity": "sha512-1WsPDsUSMmZH5LeMLegqkPDrsGgsWwk1Exipy2hvB0o/F0ASzbpIctSCcZIK1ykJvtTJULEH+20WOFjMvGnCTg==", + "node_modules/uc.micro": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/uc.micro/-/uc.micro-2.1.0.tgz", + "integrity": "sha512-ARDJmphmdvUk6Glw7y9DQ2bFkKBHwQHLi2lsaH6PPmz/Ka9sFOBsBluozhDltWmnv9u/cF6Rt87znRTPV+yp/A==", "dev": true, - "requires": { - "fromentries": "^1.2.0" - } + "license": "MIT" }, - "progress": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz", - "integrity": "sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==", - "dev": true + "node_modules/ufo": { + "version": "1.6.3", + "resolved": "https://registry.npmjs.org/ufo/-/ufo-1.6.3.tgz", + "integrity": "sha512-yDJTmhydvl5lJzBmy/hyOAA0d+aqCBuwl818haVdYCRrWV84o7YyeVm4QlVHStqNrrJSTb6jKuFAVqAFsr+K3Q==", + "dev": true, + "license": "MIT" }, - "pump": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz", - "integrity": "sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==", + "node_modules/unbzip2-stream": { + "version": "1.4.3", + "resolved": "https://registry.npmjs.org/unbzip2-stream/-/unbzip2-stream-1.4.3.tgz", + "integrity": "sha512-mlExGW4w71ebDJviH16lQLtZS32VKqsSfk80GCfUlwT/4/hNRFsoscrF/c++9xinkMzECL1uL9DDwXqFWkruPg==", "dev": true, - "requires": { - "end-of-stream": "^1.1.0", - "once": "^1.3.1" + "license": "MIT", + "dependencies": { + "buffer": "^5.2.1", + "through": "^2.3.8" } }, - "punycode": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", - "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==", - "dev": true + "node_modules/undefsafe": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/undefsafe/-/undefsafe-2.0.5.tgz", + "integrity": "sha512-WxONCrssBM8TSPRqN5EmsjVrsv4A8X12J4ArBiiayv3DyyG3ZlIg6yysuuSYdZsVz3TKcTg2fd//Ujd4CHV1iA==", + "dev": true, + "license": "MIT" }, - "querystringify": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/querystringify/-/querystringify-2.2.0.tgz", - "integrity": "sha512-FIqgj2EUvTa7R50u0rGsyTftzjYmv/a3hO345bZNrqabNqjtgiDMgmo4mkUjd+nzU5oF3dClKqFIPUKybUyqoQ==", - "dev": true + "node_modules/undici-types": { + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz", + "integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==", + "dev": true, + "license": "MIT" }, - "randombytes": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", - "integrity": "sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==", + "node_modules/unicode-canonical-property-names-ecmascript": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/unicode-canonical-property-names-ecmascript/-/unicode-canonical-property-names-ecmascript-1.0.4.tgz", + "integrity": "sha512-jDrNnXWHd4oHiTZnx/ZG7gtUTVp+gCcTTKr8L0HjlwphROEW3+Him+IpvC+xcJEFegapiMZyZe02CyuOnRmbnQ==", "dev": true, - "requires": { - "safe-buffer": "^5.1.0" + "license": "MIT", + "engines": { + "node": ">=4" } }, - "rc": { - "version": "1.2.8", - "resolved": "https://registry.npmjs.org/rc/-/rc-1.2.8.tgz", - "integrity": "sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw==", + "node_modules/unicode-match-property-ecmascript": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/unicode-match-property-ecmascript/-/unicode-match-property-ecmascript-1.0.4.tgz", + "integrity": "sha512-L4Qoh15vTfntsn4P1zqnHulG0LdXgjSO035fEpdtp6YxXhMT51Q6vgM5lYdG/5X3MjS+k/Y9Xw4SFCY9IkR0rg==", "dev": true, - "requires": { - "deep-extend": "^0.6.0", - "ini": "~1.3.0", - "minimist": "^1.2.0", - "strip-json-comments": "~2.0.1" - }, + "license": "MIT", "dependencies": { - "strip-json-comments": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", - "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=", - "dev": true - } + "unicode-canonical-property-names-ecmascript": "^1.0.4", + "unicode-property-aliases-ecmascript": "^1.0.4" + }, + "engines": { + "node": ">=4" } }, - "read-pkg": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-2.0.0.tgz", - "integrity": "sha1-jvHAYjxqbbDcZxPEv6xGMysjaPg=", + "node_modules/unicode-match-property-value-ecmascript": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/unicode-match-property-value-ecmascript/-/unicode-match-property-value-ecmascript-1.2.0.tgz", + "integrity": "sha512-wjuQHGQVofmSJv1uVISKLE5zO2rNGzM/KCYZch/QQvez7C1hUhBIuZ701fYXExuufJFMPhv2SyL8CyoIfMLbIQ==", "dev": true, - "requires": { - "load-json-file": "^2.0.0", - "normalize-package-data": "^2.3.2", - "path-type": "^2.0.0" + "license": "MIT", + "engines": { + "node": ">=4" } }, - "read-pkg-up": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-2.0.0.tgz", - "integrity": "sha1-a3KoBImE4MQeeVEP1en6mbO1Sb4=", + "node_modules/unicode-property-aliases-ecmascript": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/unicode-property-aliases-ecmascript/-/unicode-property-aliases-ecmascript-1.1.0.tgz", + "integrity": "sha512-PqSoPh/pWetQ2phoj5RLiaqIk4kCNwoV3CI+LfGmWLKI3rE3kl1h59XpX2BjgDrmbxD9ARtQobPGU1SguCYuQg==", "dev": true, - "requires": { - "find-up": "^2.0.0", - "read-pkg": "^2.0.0" + "license": "MIT", + "engines": { + "node": ">=4" } }, - "readdirp": { - "version": "3.5.0", - "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.5.0.tgz", - "integrity": "sha512-cMhu7c/8rdhkHXWsY+osBhfSy0JikwpHK/5+imo+LpeasTF8ouErHrlYkwT0++njiyuDvc7OFY5T3ukvZ8qmFQ==", + "node_modules/unist-util-is": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-6.0.1.tgz", + "integrity": "sha512-LsiILbtBETkDz8I9p1dQ0uyRUWuaQzd/cuEeS1hoRSyW5E5XGmTzlwY1OrNzzakGowI9Dr/I8HVaw4hTtnxy8g==", "dev": true, - "requires": { - "picomatch": "^2.2.1" + "license": "MIT", + "dependencies": { + "@types/unist": "^3.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" } }, - "rechoir": { - "version": "0.6.2", - "resolved": "https://registry.npmjs.org/rechoir/-/rechoir-0.6.2.tgz", - "integrity": "sha1-hSBLVNuoLVdC4oyWdW70OvUOM4Q=", + "node_modules/unist-util-position": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/unist-util-position/-/unist-util-position-5.0.0.tgz", + "integrity": "sha512-fucsC7HjXvkB5R3kTCO7kUjRdrS0BJt3M/FPxmHMBOm8JQi2BsHAHFsy27E0EolP8rp0NzXsJ+jNPyDWvOJZPA==", "dev": true, - "requires": { - "resolve": "^1.1.6" + "license": "MIT", + "dependencies": { + "@types/unist": "^3.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" } }, - "regenerate": { - "version": "1.4.2", - "resolved": "https://registry.npmjs.org/regenerate/-/regenerate-1.4.2.tgz", - "integrity": "sha512-zrceR/XhGYU/d/opr2EKO7aRHUeiBI8qjtfHqADTwZd6Szfy16la6kqD0MIUs5z5hx6AaKa+PixpPrR289+I0A==", - "dev": true - }, - "regenerate-unicode-properties": { - "version": "8.2.0", - "resolved": "https://registry.npmjs.org/regenerate-unicode-properties/-/regenerate-unicode-properties-8.2.0.tgz", - "integrity": "sha512-F9DjY1vKLo/tPePDycuH3dn9H1OTPIkVD9Kz4LODu+F2C75mgjAJ7x/gwy6ZcSNRAAkhNlJSOHRe8k3p+K9WhA==", + "node_modules/unist-util-stringify-position": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/unist-util-stringify-position/-/unist-util-stringify-position-4.0.0.tgz", + "integrity": "sha512-0ASV06AAoKCDkS2+xw5RXJywruurpbC4JZSm7nr7MOt1ojAzvyyaO+UxZf18j8FCF6kmzCZKcAgN/yu2gm2XgQ==", "dev": true, - "requires": { - "regenerate": "^1.4.0" + "license": "MIT", + "dependencies": { + "@types/unist": "^3.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" } }, - "regexpp": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-3.1.0.tgz", - "integrity": "sha512-ZOIzd8yVsQQA7j8GCSlPGXwg5PfmA1mrq0JP4nGhh54LaKN3xdai/vHUDu74pKwV8OxseMS65u2NImosQcSD0Q==", - "dev": true + "node_modules/unist-util-visit": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-5.0.0.tgz", + "integrity": "sha512-MR04uvD+07cwl/yhVuVWAtw+3GOR/knlL55Nd/wAdblk27GCVt3lqpTivy/tkJcZoNPzTwS1Y+KMojlLDhoTzg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/unist": "^3.0.0", + "unist-util-is": "^6.0.0", + "unist-util-visit-parents": "^6.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } }, - "regexpu-core": { - "version": "4.5.4", - "resolved": "https://registry.npmjs.org/regexpu-core/-/regexpu-core-4.5.4.tgz", - "integrity": "sha512-BtizvGtFQKGPUcTy56o3nk1bGRp4SZOTYrDtGNlqCQufptV5IkkLN6Emw+yunAJjzf+C9FQFtvq7IoA3+oMYHQ==", + "node_modules/unist-util-visit-parents": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-6.0.2.tgz", + "integrity": "sha512-goh1s1TBrqSqukSc8wrjwWhL0hiJxgA8m4kFxGlQ+8FYQ3C/m11FcTs4YYem7V664AhHVvgoQLk890Ssdsr2IQ==", "dev": true, - "requires": { - "regenerate": "^1.4.0", - "regenerate-unicode-properties": "^8.0.2", - "regjsgen": "^0.5.0", - "regjsparser": "^0.6.0", - "unicode-match-property-ecmascript": "^1.0.4", - "unicode-match-property-value-ecmascript": "^1.1.0" + "license": "MIT", + "dependencies": { + "@types/unist": "^3.0.0", + "unist-util-is": "^6.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" } }, - "regjsgen": { - "version": "0.5.2", - "resolved": "https://registry.npmjs.org/regjsgen/-/regjsgen-0.5.2.tgz", - "integrity": "sha512-OFFT3MfrH90xIW8OOSyUrk6QHD5E9JOTeGodiJeBS3J6IwlgzJMNE/1bZklWz5oTg+9dCMyEetclvCVXOPoN3A==", - "dev": true + "node_modules/universal-user-agent": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-7.0.3.tgz", + "integrity": "sha512-TmnEAEAsBJVZM/AADELsK76llnwcf9vMKuPz8JflO1frO8Lchitr0fNaN9d+Ap0BjKtqWqd/J17qeDnXh8CL2A==", + "dev": true, + "license": "ISC" }, - "regjsparser": { - "version": "0.6.7", - "resolved": "https://registry.npmjs.org/regjsparser/-/regjsparser-0.6.7.tgz", - "integrity": "sha512-ib77G0uxsA2ovgiYbCVGx4Pv3PSttAx2vIwidqQzbL2U5S4Q+j00HdSAneSBuyVcMvEnTXMjiGgB+DlXozVhpQ==", + "node_modules/universalify": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.1.tgz", + "integrity": "sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw==", "dev": true, - "requires": { - "jsesc": "~0.5.0" + "license": "MIT", + "engines": { + "node": ">= 10.0.0" } }, - "release-zalgo": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/release-zalgo/-/release-zalgo-1.0.0.tgz", - "integrity": "sha1-CXALflB0Mpc5Mw5TXFqQ+2eFFzA=", + "node_modules/update-browserslist-db": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.2.3.tgz", + "integrity": "sha512-Js0m9cx+qOgDxo0eMiFGEueWztz+d4+M3rGlmKPT+T4IS/jP4ylw3Nwpu6cpTTP8R1MAC1kF4VbdLt3ARf209w==", "dev": true, - "requires": { - "es6-error": "^4.0.1" + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/browserslist" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "escalade": "^3.2.0", + "picocolors": "^1.1.1" + }, + "bin": { + "update-browserslist-db": "cli.js" + }, + "peerDependencies": { + "browserslist": ">= 4.21.0" } }, - "require-directory": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", - "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=", - "dev": true - }, - "require-from-string": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz", - "integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==", - "dev": true - }, - "require-main-filename": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-2.0.0.tgz", - "integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==", - "dev": true - }, - "require-relative": { - "version": "0.8.7", - "resolved": "https://registry.npmjs.org/require-relative/-/require-relative-0.8.7.tgz", - "integrity": "sha1-eZlTn8ngR6N5KPoZb44VY9q9Nt4=", - "dev": true - }, - "requirejs": { - "version": "2.3.6", - "resolved": "https://registry.npmjs.org/requirejs/-/requirejs-2.3.6.tgz", - "integrity": "sha512-ipEzlWQe6RK3jkzikgCupiTbTvm4S0/CAU5GlgptkN5SO6F3u0UD0K18wy6ErDqiCyP4J4YYe1HuAShvsxePLg==", - "dev": true - }, - "requires-port": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz", - "integrity": "sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8=", - "dev": true - }, - "resolve": { - "version": "1.20.0", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.20.0.tgz", - "integrity": "sha512-wENBPt4ySzg4ybFQW2TT1zMQucPK95HSh/nq2CFTZVOGut2+pQvSsgtda4d26YrYcr067wjbmzOG8byDPBX63A==", + "node_modules/uri-js": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", + "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", "dev": true, - "requires": { - "is-core-module": "^2.2.0", - "path-parse": "^1.0.6" + "license": "BSD-2-Clause", + "dependencies": { + "punycode": "^2.1.0" } }, - "resolve-from": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", - "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", - "dev": true - }, - "restore-cursor": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-3.1.0.tgz", - "integrity": "sha512-l+sSefzHpj5qimhFSE5a8nufZYAM3sBSVMAPtYkmC+4EH2anSGaEMXSD0izRQbu9nfyQ9y5JrVmp7E8oZrUjvA==", + "node_modules/use-sync-external-store": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/use-sync-external-store/-/use-sync-external-store-1.6.0.tgz", + "integrity": "sha512-Pp6GSwGP/NrPIrxVFAIkOQeyw8lFenOHijQWkUTrDvrF4ALqylP2C/KCkeS9dpUM3KvYRQhna5vt7IL95+ZQ9w==", "dev": true, - "requires": { - "onetime": "^5.1.0", - "signal-exit": "^3.0.2" + "license": "MIT", + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0" } }, - "rimraf": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", - "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", + "node_modules/utf8": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/utf8/-/utf8-2.1.2.tgz", + "integrity": "sha512-QXo+O/QkLP/x1nyi54uQiG0XrODxdysuQvE5dtVqv7F5K2Qb6FsN+qbr6KhF5wQ20tfcV3VQp0/2x1e1MRSPWg==", "dev": true, - "requires": { - "glob": "^7.1.3" - } + "license": "MIT" + }, + "node_modules/util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==", + "dev": true, + "license": "MIT" }, - "rollup": { - "version": "2.38.5", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.38.5.tgz", - "integrity": "sha512-VoWt8DysFGDVRGWuHTqZzT02J0ASgjVq/hPs9QcBOGMd7B+jfTr/iqMVEyOi901rE3xq+Deq66GzIT1yt7sGwQ==", + "node_modules/uuid": { + "version": "11.1.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-11.1.0.tgz", + "integrity": "sha512-0/A9rDy9P7cJ+8w1c9WD9V//9Wj15Ce2MPz8Ri6032usz+NfePxx5AcN3bN+r6ZL6jEo066/yNYB3tn4pQEx+A==", "dev": true, - "requires": { - "fsevents": "~2.3.1" + "funding": [ + "https://github.com/sponsors/broofa", + "https://github.com/sponsors/ctavan" + ], + "license": "MIT", + "bin": { + "uuid": "dist/esm/bin/uuid" } }, - "rollup-plugin-license": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/rollup-plugin-license/-/rollup-plugin-license-2.2.0.tgz", - "integrity": "sha512-xXb1vviEwlJMX+VGUSsglcMA/Rh9d2QzEm94awy4FlnsPqGrXoTYYGOR3UXR6gYIxiJFkr7qmkKF/NXfre/y8g==", - "dev": true, - "requires": { - "commenting": "1.1.0", - "glob": "7.1.6", - "lodash": "4.17.19", - "magic-string": "0.25.7", - "mkdirp": "1.0.4", - "moment": "2.27.0", - "package-name-regex": "1.0.8", - "spdx-expression-validate": "2.0.0", - "spdx-satisfies": "5.0.0" - }, - "dependencies": { - "lodash": { - "version": "4.17.19", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.19.tgz", - "integrity": "sha512-JNvd8XER9GQX0v2qJgsaN/mzFCNA5BRe/j8JN9d+tWyGLSodKQHKFicdwNYzWwI3wjRnaKPsGj1XkBjx/F96DQ==", - "dev": true - } + "node_modules/vfile": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/vfile/-/vfile-6.0.3.tgz", + "integrity": "sha512-KzIbH/9tXat2u30jf+smMwFCsno4wHVdNmzFyL+T/L3UGqqk6JKfVqOFOZEpZSHADH1k40ab6NUIXZq422ov3Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/unist": "^3.0.0", + "vfile-message": "^4.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" } }, - "rollup-plugin-string": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/rollup-plugin-string/-/rollup-plugin-string-3.0.0.tgz", - "integrity": "sha512-vqyzgn9QefAgeKi+Y4A7jETeIAU1zQmS6VotH6bzm/zmUQEnYkpIGRaOBPY41oiWYV4JyBoGAaBjYMYuv+6wVw==", + "node_modules/vfile-message": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/vfile-message/-/vfile-message-4.0.3.tgz", + "integrity": "sha512-QTHzsGd1EhbZs4AsQ20JX1rC3cOlt/IWJruk893DfLRr57lcnOeMaWG4K0JrRta4mIJZKth2Au3mM3u03/JWKw==", "dev": true, - "requires": { - "rollup-pluginutils": "^2.4.1" + "license": "MIT", + "dependencies": { + "@types/unist": "^3.0.0", + "unist-util-stringify-position": "^4.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" } }, - "rollup-plugin-terser": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/rollup-plugin-terser/-/rollup-plugin-terser-7.0.2.tgz", - "integrity": "sha512-w3iIaU4OxcF52UUXiZNsNeuXIMDvFrr+ZXK6bFZ0Q60qyVfq4uLptoS4bbq3paG3x216eQllFZX7zt6TIImguQ==", + "node_modules/vite": { + "version": "7.3.1", + "resolved": "https://registry.npmjs.org/vite/-/vite-7.3.1.tgz", + "integrity": "sha512-w+N7Hifpc3gRjZ63vYBXA56dvvRlNWRczTdmCBBa+CotUzAPf5b7YMdMR/8CQoeYE5LX3W4wj6RYTgonm1b9DA==", "dev": true, - "requires": { - "@babel/code-frame": "^7.10.4", - "jest-worker": "^26.2.1", - "serialize-javascript": "^4.0.0", - "terser": "^5.0.0" + "license": "MIT", + "peer": true, + "dependencies": { + "esbuild": "^0.27.0", + "fdir": "^6.5.0", + "picomatch": "^4.0.3", + "postcss": "^8.5.6", + "rollup": "^4.43.0", + "tinyglobby": "^0.2.15" + }, + "bin": { + "vite": "bin/vite.js" + }, + "engines": { + "node": "^20.19.0 || >=22.12.0" }, - "dependencies": { - "commander": { - "version": "2.20.3", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", - "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", - "dev": true + "funding": { + "url": "https://github.com/vitejs/vite?sponsor=1" + }, + "optionalDependencies": { + "fsevents": "~2.3.3" + }, + "peerDependencies": { + "@types/node": "^20.19.0 || >=22.12.0", + "jiti": ">=1.21.0", + "less": "^4.0.0", + "lightningcss": "^1.21.0", + "sass": "^1.70.0", + "sass-embedded": "^1.70.0", + "stylus": ">=0.54.8", + "sugarss": "^5.0.0", + "terser": "^5.16.0", + "tsx": "^4.8.1", + "yaml": "^2.4.2" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + }, + "jiti": { + "optional": true + }, + "less": { + "optional": true + }, + "lightningcss": { + "optional": true + }, + "sass": { + "optional": true }, - "serialize-javascript": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-4.0.0.tgz", - "integrity": "sha512-GaNA54380uFefWghODBWEGisLZFj00nS5ACs6yHa9nLqlLpVLO8ChDGeKRjZnV4Nh4n0Qi7nhYZD/9fCPzEqkw==", - "dev": true, - "requires": { - "randombytes": "^2.1.0" - } + "sass-embedded": { + "optional": true + }, + "stylus": { + "optional": true + }, + "sugarss": { + "optional": true }, "terser": { - "version": "5.5.1", - "resolved": "https://registry.npmjs.org/terser/-/terser-5.5.1.tgz", - "integrity": "sha512-6VGWZNVP2KTUcltUQJ25TtNjx/XgdDsBDKGt8nN0MpydU36LmbPPcMBd2kmtZNNGVVDLg44k7GKeHHj+4zPIBQ==", - "dev": true, - "requires": { - "commander": "^2.20.0", - "source-map": "~0.7.2", - "source-map-support": "~0.5.19" - } + "optional": true + }, + "tsx": { + "optional": true + }, + "yaml": { + "optional": true } } }, - "rollup-plugin-thatworks": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/rollup-plugin-thatworks/-/rollup-plugin-thatworks-1.0.4.tgz", - "integrity": "sha512-RxlYx/oolwXW7akleFzRmJ8gQrWUK4NSZw8E+LHJTWHiA1mhseIMurz8IkyDAG4fwensXHocNYvKUHivhN9EXw==", - "dev": true - }, - "rollup-plugin-typescript": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/rollup-plugin-typescript/-/rollup-plugin-typescript-1.0.1.tgz", - "integrity": "sha512-rwJDNn9jv/NsKZuyBb/h0jsclP4CJ58qbvZt2Q9zDIGILF2LtdtvCqMOL+Gq9IVq5MTrTlHZNrn8h7VjQgd8tw==", - "dev": true, - "requires": { - "resolve": "^1.10.0", - "rollup-pluginutils": "^2.5.0" - } - }, - "rollup-pluginutils": { - "version": "2.8.2", - "resolved": "https://registry.npmjs.org/rollup-pluginutils/-/rollup-pluginutils-2.8.2.tgz", - "integrity": "sha512-EEp9NhnUkwY8aif6bxgovPHMoMoNr2FulJziTndpt5H9RdwC47GSGuII9XxpSdzVGM0GWrNPHV6ie1LTNJPaLQ==", + "node_modules/vitepress": { + "version": "1.6.4", + "resolved": "https://registry.npmjs.org/vitepress/-/vitepress-1.6.4.tgz", + "integrity": "sha512-+2ym1/+0VVrbhNyRoFFesVvBvHAVMZMK0rw60E3X/5349M1GuVdKeazuksqopEdvkKwKGs21Q729jX81/bkBJg==", "dev": true, - "requires": { - "estree-walker": "^0.6.1" - }, + "license": "MIT", "dependencies": { - "estree-walker": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-0.6.1.tgz", - "integrity": "sha512-SqmZANLWS0mnatqbSfRP5g8OXZC12Fgg1IwNtLsyHDzJizORW4khDfjPqJZsemPWBB2uqykUah5YpQ6epsqC/w==", - "dev": true + "@docsearch/css": "3.8.2", + "@docsearch/js": "3.8.2", + "@iconify-json/simple-icons": "^1.2.21", + "@shikijs/core": "^2.1.0", + "@shikijs/transformers": "^2.1.0", + "@shikijs/types": "^2.1.0", + "@types/markdown-it": "^14.1.2", + "@vitejs/plugin-vue": "^5.2.1", + "@vue/devtools-api": "^7.7.0", + "@vue/shared": "^3.5.13", + "@vueuse/core": "^12.4.0", + "@vueuse/integrations": "^12.4.0", + "focus-trap": "^7.6.4", + "mark.js": "8.11.1", + "minisearch": "^7.1.1", + "shiki": "^2.1.0", + "vite": "^5.4.14", + "vue": "^3.5.13" + }, + "bin": { + "vitepress": "bin/vitepress.js" + }, + "peerDependencies": { + "markdown-it-mathjax3": "^4", + "postcss": "^8" + }, + "peerDependenciesMeta": { + "markdown-it-mathjax3": { + "optional": true + }, + "postcss": { + "optional": true } } }, - "rxjs": { - "version": "6.6.3", - "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.6.3.tgz", - "integrity": "sha512-trsQc+xYYXZ3urjOiJOuCOa5N3jAZ3eiSpQB5hIT8zGlL2QfnHLJ2r7GMkBGuIausdJN1OneaI6gQlsqNHHmZQ==", + "node_modules/vitepress/node_modules/@shikijs/core": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/@shikijs/core/-/core-2.5.0.tgz", + "integrity": "sha512-uu/8RExTKtavlpH7XqnVYBrfBkUc20ngXiX9NSrBhOVZYv/7XQRKUyhtkeflY5QsxC0GbJThCerruZfsUaSldg==", "dev": true, - "requires": { - "tslib": "^1.9.0" - }, + "license": "MIT", "dependencies": { - "tslib": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", - "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==", - "dev": true - } + "@shikijs/engine-javascript": "2.5.0", + "@shikijs/engine-oniguruma": "2.5.0", + "@shikijs/types": "2.5.0", + "@shikijs/vscode-textmate": "^10.0.2", + "@types/hast": "^3.0.4", + "hast-util-to-html": "^9.0.4" } }, - "safe-buffer": { - "version": "5.2.1", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", - "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", - "dev": true - }, - "sander": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/sander/-/sander-0.6.0.tgz", - "integrity": "sha1-rxYkzX+2362Y6+9WUxn5IAeNqSU=", - "dev": true, - "requires": { - "graceful-fs": "^4.1.3", - "mkdirp": "^0.5.1", - "rimraf": "^2.5.2" - }, - "dependencies": { - "mkdirp": { - "version": "0.5.5", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz", - "integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==", - "dev": true, - "requires": { - "minimist": "^1.2.5" - } - }, - "rimraf": { - "version": "2.7.1", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz", - "integrity": "sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w==", - "dev": true, - "requires": { - "glob": "^7.1.3" - } - } + "node_modules/vitepress/node_modules/@shikijs/engine-javascript": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/@shikijs/engine-javascript/-/engine-javascript-2.5.0.tgz", + "integrity": "sha512-VjnOpnQf8WuCEZtNUdjjwGUbtAVKuZkVQ/5cHy/tojVVRIRtlWMYVjyWhxOmIq05AlSOv72z7hRNRGVBgQOl0w==", + "dev": true, + "license": "MIT", + "dependencies": { + "@shikijs/types": "2.5.0", + "@shikijs/vscode-textmate": "^10.0.2", + "oniguruma-to-es": "^3.1.0" } }, - "semver": { - "version": "7.3.4", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.4.tgz", - "integrity": "sha512-tCfb2WLjqFAtXn4KEdxIhalnRtoKFN7nAwj0B3ZXCbQloV2tq5eDbcTmT68JJD3nRJq24/XgxtQKFIpQdtvmVw==", + "node_modules/vitepress/node_modules/@shikijs/engine-oniguruma": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/@shikijs/engine-oniguruma/-/engine-oniguruma-2.5.0.tgz", + "integrity": "sha512-pGd1wRATzbo/uatrCIILlAdFVKdxImWJGQ5rFiB5VZi2ve5xj3Ax9jny8QvkaV93btQEwR/rSz5ERFpC5mKNIw==", "dev": true, - "requires": { - "lru-cache": "^6.0.0" + "license": "MIT", + "dependencies": { + "@shikijs/types": "2.5.0", + "@shikijs/vscode-textmate": "^10.0.2" } }, - "semver-compare": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/semver-compare/-/semver-compare-1.0.0.tgz", - "integrity": "sha1-De4hahyUGrN+nvsXiPavxf9VN/w=", - "dev": true - }, - "serialize-javascript": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-5.0.1.tgz", - "integrity": "sha512-SaaNal9imEO737H2c05Og0/8LUXG7EnsZyMa8MzkmuHoELfT6txuj0cMqRj6zfPKnmQ1yasR4PCJc8x+M4JSPA==", + "node_modules/vitepress/node_modules/@shikijs/langs": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/@shikijs/langs/-/langs-2.5.0.tgz", + "integrity": "sha512-Qfrrt5OsNH5R+5tJ/3uYBBZv3SuGmnRPejV9IlIbFH3HTGLDlkqgHymAlzklVmKBjAaVmkPkyikAV/sQ1wSL+w==", "dev": true, - "requires": { - "randombytes": "^2.1.0" + "license": "MIT", + "dependencies": { + "@shikijs/types": "2.5.0" } }, - "set-blocking": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", - "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=", - "dev": true - }, - "setimmediate-napi": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/setimmediate-napi/-/setimmediate-napi-1.0.6.tgz", - "integrity": "sha512-sdNXN15Av1jPXuSal4Mk4tEAKn0+8lfF9Z50/negaQMrAIO9c1qM0eiCh8fT6gctp0RiCObk+6/Xfn5RMGdZoA==", + "node_modules/vitepress/node_modules/@shikijs/themes": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/@shikijs/themes/-/themes-2.5.0.tgz", + "integrity": "sha512-wGrk+R8tJnO0VMzmUExHR+QdSaPUl/NKs+a4cQQRWyoc3YFbUzuLEi/KWK1hj+8BfHRKm2jNhhJck1dfstJpiw==", "dev": true, - "requires": { - "get-symbol-from-current-process-h": "^1.0.1", - "get-uv-event-loop-napi-h": "^1.0.5" + "license": "MIT", + "dependencies": { + "@shikijs/types": "2.5.0" } }, - "shebang-command": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", - "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "node_modules/vitepress/node_modules/@shikijs/types": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/@shikijs/types/-/types-2.5.0.tgz", + "integrity": "sha512-ygl5yhxki9ZLNuNpPitBWvcy9fsSKKaRuO4BAlMyagszQidxcpLAr0qiW/q43DtSIDxO6hEbtYLiFZNXO/hdGw==", "dev": true, - "requires": { - "shebang-regex": "^3.0.0" + "license": "MIT", + "dependencies": { + "@shikijs/vscode-textmate": "^10.0.2", + "@types/hast": "^3.0.4" } }, - "shebang-regex": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", - "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", - "dev": true - }, - "shelljs": { - "version": "0.8.4", - "resolved": "https://registry.npmjs.org/shelljs/-/shelljs-0.8.4.tgz", - "integrity": "sha512-7gk3UZ9kOfPLIAbslLzyWeGiEqx9e3rxwZM0KE6EL8GlGwjym9Mrlx5/p33bWTu9YG6vcS4MBxYZDHYr5lr8BQ==", + "node_modules/vitepress/node_modules/oniguruma-to-es": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/oniguruma-to-es/-/oniguruma-to-es-3.1.1.tgz", + "integrity": "sha512-bUH8SDvPkH3ho3dvwJwfonjlQ4R80vjyvrU8YpxuROddv55vAEJrTuCuCVUhhsHbtlD9tGGbaNApGQckXhS8iQ==", "dev": true, - "requires": { - "glob": "^7.0.0", - "interpret": "^1.0.0", - "rechoir": "^0.6.2" + "license": "MIT", + "dependencies": { + "emoji-regex-xs": "^1.0.0", + "regex": "^6.0.1", + "regex-recursion": "^6.0.2" } }, - "shx": { - "version": "0.3.3", - "resolved": "https://registry.npmjs.org/shx/-/shx-0.3.3.tgz", - "integrity": "sha512-nZJ3HFWVoTSyyB+evEKjJ1STiixGztlqwKLTUNV5KqMWtGey9fTd4KU1gdZ1X9BV6215pswQ/Jew9NsuS/fNDA==", + "node_modules/vitepress/node_modules/shiki": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/shiki/-/shiki-2.5.0.tgz", + "integrity": "sha512-mI//trrsaiCIPsja5CNfsyNOqgAZUb6VpJA+340toL42UpzQlXpwRV9nch69X6gaUxrr9kaOOa6e3y3uAkGFxQ==", "dev": true, - "requires": { - "minimist": "^1.2.3", - "shelljs": "^0.8.4" + "license": "MIT", + "dependencies": { + "@shikijs/core": "2.5.0", + "@shikijs/engine-javascript": "2.5.0", + "@shikijs/engine-oniguruma": "2.5.0", + "@shikijs/langs": "2.5.0", + "@shikijs/themes": "2.5.0", + "@shikijs/types": "2.5.0", + "@shikijs/vscode-textmate": "^10.0.2", + "@types/hast": "^3.0.4" } }, - "signal-exit": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.3.tgz", - "integrity": "sha512-VUJ49FC8U1OxwZLxIbTTrDvLnf/6TDgxZcK8wxR8zs13xpx7xbG60ndBlhNrFi2EMuFRoeDoJO7wthSLq42EjA==", - "dev": true - }, - "slash": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", - "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==", - "dev": true - }, - "slice-ansi": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-4.0.0.tgz", - "integrity": "sha512-qMCMfhY040cVHT43K9BFygqYbUPFZKHOg7K73mtTWJRb8pyP3fzf4Ixd5SzdEJQ6MRUg/WBnOLxghZtKKurENQ==", + "node_modules/volar-service-css": { + "version": "0.0.68", + "resolved": "https://registry.npmjs.org/volar-service-css/-/volar-service-css-0.0.68.tgz", + "integrity": "sha512-lJSMh6f3QzZ1tdLOZOzovLX0xzAadPhx8EKwraDLPxBndLCYfoTvnNuiFFV8FARrpAlW5C0WkH+TstPaCxr00Q==", "dev": true, - "requires": { - "ansi-styles": "^4.0.0", - "astral-regex": "^2.0.0", - "is-fullwidth-code-point": "^3.0.0" - }, - "dependencies": { - "ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "requires": { - "color-convert": "^2.0.1" - } - }, - "color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "requires": { - "color-name": "~1.1.4" - } - }, - "color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true + "license": "MIT", + "dependencies": { + "vscode-css-languageservice": "^6.3.0", + "vscode-languageserver-textdocument": "^1.0.11", + "vscode-uri": "^3.0.8" + }, + "peerDependencies": { + "@volar/language-service": "~2.4.0" + }, + "peerDependenciesMeta": { + "@volar/language-service": { + "optional": true } } }, - "sort-keys": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/sort-keys/-/sort-keys-4.2.0.tgz", - "integrity": "sha512-aUYIEU/UviqPgc8mHR6IW1EGxkAXpeRETYcrzg8cLAvUPZcpAlleSXHV2mY7G12GphSH6Gzv+4MMVSSkbdteHg==", + "node_modules/volar-service-emmet": { + "version": "0.0.68", + "resolved": "https://registry.npmjs.org/volar-service-emmet/-/volar-service-emmet-0.0.68.tgz", + "integrity": "sha512-nHvixrRQ83EzkQ4G/jFxu9Y4eSsXS/X2cltEPDM+K9qZmIv+Ey1w0tg1+6caSe8TU5Hgw4oSTwNMf/6cQb3LzQ==", "dev": true, - "requires": { - "is-plain-obj": "^2.0.0" + "license": "MIT", + "dependencies": { + "@emmetio/css-parser": "^0.4.1", + "@emmetio/html-matcher": "^1.3.0", + "@vscode/emmet-helper": "^2.9.3", + "vscode-uri": "^3.0.8" + }, + "peerDependencies": { + "@volar/language-service": "~2.4.0" + }, + "peerDependenciesMeta": { + "@volar/language-service": { + "optional": true + } } }, - "source-map": { - "version": "0.7.3", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.7.3.tgz", - "integrity": "sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ==", - "dev": true - }, - "source-map-support": { - "version": "0.5.19", - "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.19.tgz", - "integrity": "sha512-Wonm7zOCIJzBGQdB+thsPar0kYuCIzYvxZwlBa87yi/Mdjv7Tip2cyVbLj5o0cFPN4EVkuTwb3GDDyUx2DGnGw==", + "node_modules/volar-service-html": { + "version": "0.0.68", + "resolved": "https://registry.npmjs.org/volar-service-html/-/volar-service-html-0.0.68.tgz", + "integrity": "sha512-fru9gsLJxy33xAltXOh4TEdi312HP80hpuKhpYQD4O5hDnkNPEBdcQkpB+gcX0oK0VxRv1UOzcGQEUzWCVHLfA==", "dev": true, - "requires": { - "buffer-from": "^1.0.0", - "source-map": "^0.6.0" - }, + "license": "MIT", "dependencies": { - "source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "dev": true + "vscode-html-languageservice": "^5.3.0", + "vscode-languageserver-textdocument": "^1.0.11", + "vscode-uri": "^3.0.8" + }, + "peerDependencies": { + "@volar/language-service": "~2.4.0" + }, + "peerDependenciesMeta": { + "@volar/language-service": { + "optional": true } } }, - "sourcemap-codec": { - "version": "1.4.8", - "resolved": "https://registry.npmjs.org/sourcemap-codec/-/sourcemap-codec-1.4.8.tgz", - "integrity": "sha512-9NykojV5Uih4lgo5So5dtw+f0JgJX30KCNI8gwhz2J9A15wD0Ml6tjHKwf6fTSa6fAdVBdZeNOs9eJ71qCk8vA==", - "dev": true - }, - "spawn-wrap": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/spawn-wrap/-/spawn-wrap-2.0.0.tgz", - "integrity": "sha512-EeajNjfN9zMnULLwhZZQU3GWBoFNkbngTUPfaawT4RkMiviTxcX0qfhVbGey39mfctfDHkWtuecgQ8NJcyQWHg==", + "node_modules/volar-service-json": { + "version": "0.0.68", + "resolved": "https://registry.npmjs.org/volar-service-json/-/volar-service-json-0.0.68.tgz", + "integrity": "sha512-2d73Khlffwa0o6B6nA4vCyvqqTBuik1aj1i+EPC8a2UdmjMBAvHhGUcUiF3EscGhenv42UxL7f3tWbsITBNGZg==", "dev": true, - "requires": { - "foreground-child": "^2.0.0", - "is-windows": "^1.0.2", - "make-dir": "^3.0.0", - "rimraf": "^3.0.0", - "signal-exit": "^3.0.2", - "which": "^2.0.1" + "license": "MIT", + "dependencies": { + "vscode-json-languageservice": "^5.4.0", + "vscode-uri": "^3.0.8" + }, + "peerDependencies": { + "@volar/language-service": "~2.4.0" + }, + "peerDependenciesMeta": { + "@volar/language-service": { + "optional": true + } } }, - "spdx-compare": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/spdx-compare/-/spdx-compare-1.0.0.tgz", - "integrity": "sha512-C1mDZOX0hnu0ep9dfmuoi03+eOdDoz2yvK79RxbcrVEG1NO1Ph35yW102DHWKN4pk80nwCgeMmSY5L25VE4D9A==", + "node_modules/volar-service-pug": { + "version": "0.0.68", + "resolved": "https://registry.npmjs.org/volar-service-pug/-/volar-service-pug-0.0.68.tgz", + "integrity": "sha512-/nZ8fYKDDrV/fqlBoMACWaghFfaIFZMH+qO9YiRsdGbekAvSZqjQAKl1DSJwWqAkabA68Md51mRIdzYzqleipQ==", "dev": true, - "requires": { - "array-find-index": "^1.0.2", - "spdx-expression-parse": "^3.0.0", - "spdx-ranges": "^2.0.0" + "license": "MIT", + "dependencies": { + "@volar/language-service": "~2.4.0", + "muggle-string": "^0.4.1", + "pug-lexer": "^5.0.1", + "pug-parser": "^6.0.0", + "volar-service-html": "0.0.68", + "vscode-html-languageservice": "^5.3.0", + "vscode-languageserver-textdocument": "^1.0.11" } }, - "spdx-correct": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.1.1.tgz", - "integrity": "sha512-cOYcUWwhCuHCXi49RhFRCyJEK3iPj1Ziz9DpViV3tbZOwXD49QzIN3MpOLJNxh2qwq2lJJZaKMVw9qNi4jTC0w==", + "node_modules/volar-service-pug-beautify": { + "version": "0.0.68", + "resolved": "https://registry.npmjs.org/volar-service-pug-beautify/-/volar-service-pug-beautify-0.0.68.tgz", + "integrity": "sha512-CUKfD2l9aPam7jeZT0bQtAOfSWm6XmOmTXOfYDMILuK6+5uYiMKbPW2y+OdK2FnHjcAC53GnHpUrIbfxojRoFQ==", "dev": true, - "requires": { - "spdx-expression-parse": "^3.0.0", - "spdx-license-ids": "^3.0.0" + "license": "MIT", + "dependencies": { + "@johnsoncodehk/pug-beautify": "^0.2.2" + }, + "peerDependencies": { + "@volar/language-service": "~2.4.0" + }, + "peerDependenciesMeta": { + "@volar/language-service": { + "optional": true + } } }, - "spdx-exceptions": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.3.0.tgz", - "integrity": "sha512-/tTrYOC7PPI1nUAgx34hUpqXuyJG+DTHJTnIULG4rDygi4xu/tfgmq1e1cIRwRzwZgo4NLySi+ricLkZkw4i5A==", - "dev": true - }, - "spdx-expression-parse": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-3.0.1.tgz", - "integrity": "sha512-cbqHunsQWnJNE6KhVSMsMeH5H/L9EpymbzqTQ3uLwNCLZ1Q481oWaofqH7nO6V07xlXwY6PhQdQ2IedWx/ZK4Q==", + "node_modules/volar-service-typescript": { + "version": "0.0.68", + "resolved": "https://registry.npmjs.org/volar-service-typescript/-/volar-service-typescript-0.0.68.tgz", + "integrity": "sha512-z7B/7CnJ0+TWWFp/gh2r5/QwMObHNDiQiv4C9pTBNI2Wxuwymd4bjEORzrJ/hJ5Yd5+OzeYK+nFCKevoGEEeKw==", "dev": true, - "requires": { - "spdx-exceptions": "^2.1.0", - "spdx-license-ids": "^3.0.0" + "license": "MIT", + "dependencies": { + "path-browserify": "^1.0.1", + "semver": "^7.6.2", + "typescript-auto-import-cache": "^0.3.5", + "vscode-languageserver-textdocument": "^1.0.11", + "vscode-nls": "^5.2.0", + "vscode-uri": "^3.0.8" + }, + "peerDependencies": { + "@volar/language-service": "~2.4.0" + }, + "peerDependenciesMeta": { + "@volar/language-service": { + "optional": true + } } }, - "spdx-expression-validate": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/spdx-expression-validate/-/spdx-expression-validate-2.0.0.tgz", - "integrity": "sha512-b3wydZLM+Tc6CFvaRDBOF9d76oGIHNCLYFeHbftFXUWjnfZWganmDmvtM5sm1cRwJc/VDBMLyGGrsLFd1vOxbg==", + "node_modules/vscode-css-languageservice": { + "version": "6.3.9", + "resolved": "https://registry.npmjs.org/vscode-css-languageservice/-/vscode-css-languageservice-6.3.9.tgz", + "integrity": "sha512-1tLWfp+TDM5ZuVWht3jmaY5y7O6aZmpeXLoHl5bv1QtRsRKt4xYGRMmdJa5Pqx/FTkgRbsna9R+Gn2xE+evVuA==", "dev": true, - "requires": { - "spdx-expression-parse": "^3.0.0" + "license": "MIT", + "dependencies": { + "@vscode/l10n": "^0.0.18", + "vscode-languageserver-textdocument": "^1.0.12", + "vscode-languageserver-types": "3.17.5", + "vscode-uri": "^3.1.0" } }, - "spdx-license-ids": { - "version": "3.0.7", - "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.7.tgz", - "integrity": "sha512-U+MTEOO0AiDzxwFvoa4JVnMV6mZlJKk2sBLt90s7G0Gd0Mlknc7kxEn3nuDPNZRta7O2uy8oLcZLVT+4sqNZHQ==", - "dev": true - }, - "spdx-ranges": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/spdx-ranges/-/spdx-ranges-2.1.1.tgz", - "integrity": "sha512-mcdpQFV7UDAgLpXEE/jOMqvK4LBoO0uTQg0uvXUewmEFhpiZx5yJSZITHB8w1ZahKdhfZqP5GPEOKLyEq5p8XA==", - "dev": true - }, - "spdx-satisfies": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/spdx-satisfies/-/spdx-satisfies-5.0.0.tgz", - "integrity": "sha512-/hGhwh20BeGmkA+P/lm06RvXD94JduwNxtx/oX3B5ClPt1/u/m5MCaDNo1tV3Y9laLkQr/NRde63b9lLMhlNfw==", + "node_modules/vscode-html-languageservice": { + "version": "5.6.1", + "resolved": "https://registry.npmjs.org/vscode-html-languageservice/-/vscode-html-languageservice-5.6.1.tgz", + "integrity": "sha512-5Mrqy5CLfFZUgkyhNZLA1Ye5g12Cb/v6VM7SxUzZUaRKWMDz4md+y26PrfRTSU0/eQAl3XpO9m2og+GGtDMuaA==", "dev": true, - "requires": { - "spdx-compare": "^1.0.0", - "spdx-expression-parse": "^3.0.0", - "spdx-ranges": "^2.0.0" + "license": "MIT", + "dependencies": { + "@vscode/l10n": "^0.0.18", + "vscode-languageserver-textdocument": "^1.0.12", + "vscode-languageserver-types": "^3.17.5", + "vscode-uri": "^3.1.0" } }, - "sprintf-js": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", - "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", - "dev": true - }, - "string-argv": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/string-argv/-/string-argv-0.3.1.tgz", - "integrity": "sha512-a1uQGz7IyVy9YwhqjZIZu1c8JO8dNIe20xBmSS6qu9kv++k3JGzCVmprbNN5Kn+BgzD5E7YYwg1CcjuJMRNsvg==", - "dev": true - }, - "string-width": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.0.tgz", - "integrity": "sha512-zUz5JD+tgqtuDjMhwIg5uFVV3dtqZ9yQJlZVfq4I01/K5Paj5UHj7VyrQOJvzawSVlKpObApbfD0Ed6yJc+1eg==", + "node_modules/vscode-json-languageservice": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/vscode-json-languageservice/-/vscode-json-languageservice-5.7.1.tgz", + "integrity": "sha512-sMK2F8p7St0lJCr/4IfbQRoEUDUZRR7Ud0IiSl8I/JtN+m9Gv+FJlNkSAYns2R7Ebm/PKxqUuWYOfBej/rAdBQ==", "dev": true, - "requires": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.0" + "license": "MIT", + "dependencies": { + "@vscode/l10n": "^0.0.18", + "jsonc-parser": "^3.3.1", + "vscode-languageserver-textdocument": "^1.0.12", + "vscode-languageserver-types": "^3.17.5", + "vscode-uri": "^3.1.0" } }, - "string.prototype.trimend": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/string.prototype.trimend/-/string.prototype.trimend-1.0.3.tgz", - "integrity": "sha512-ayH0pB+uf0U28CtjlLvL7NaohvR1amUvVZk+y3DYb0Ey2PUV5zPkkKy9+U1ndVEIXO8hNg18eIv9Jntbii+dKw==", + "node_modules/vscode-json-languageservice/node_modules/jsonc-parser": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/jsonc-parser/-/jsonc-parser-3.3.1.tgz", + "integrity": "sha512-HUgH65KyejrUFPvHFPbqOY0rsFip3Bo5wb4ngvdi1EpCYWUQDC5V+Y7mZws+DLkr4M//zQJoanu1SP+87Dv1oQ==", "dev": true, - "requires": { - "call-bind": "^1.0.0", - "define-properties": "^1.1.3" - } + "license": "MIT" }, - "string.prototype.trimstart": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/string.prototype.trimstart/-/string.prototype.trimstart-1.0.3.tgz", - "integrity": "sha512-oBIBUy5lea5tt0ovtOFiEQaBkoBBkyJhZXzJYrSmDo5IUUqbOPvVezuRs/agBIdZ2p2Eo1FD6bD9USyBLfl3xg==", + "node_modules/vscode-jsonrpc": { + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/vscode-jsonrpc/-/vscode-jsonrpc-8.2.0.tgz", + "integrity": "sha512-C+r0eKJUIfiDIfwJhria30+TYWPtuHJXHtI7J0YlOmKAo7ogxP20T0zxB7HZQIFhIyvoBPwWskjxrvAtfjyZfA==", "dev": true, - "requires": { - "call-bind": "^1.0.0", - "define-properties": "^1.1.3" + "license": "MIT", + "engines": { + "node": ">=14.0.0" } }, - "stringify-object": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/stringify-object/-/stringify-object-3.3.0.tgz", - "integrity": "sha512-rHqiFh1elqCQ9WPLIC8I0Q/g/wj5J1eMkyoiD6eoQApWHP0FtlK7rqnhmabL5VUY9JQCcqwwvlOaSuutekgyrw==", + "node_modules/vscode-languageserver": { + "version": "9.0.1", + "resolved": "https://registry.npmjs.org/vscode-languageserver/-/vscode-languageserver-9.0.1.tgz", + "integrity": "sha512-woByF3PDpkHFUreUa7Hos7+pUWdeWMXRd26+ZX2A8cFx6v/JPTtd4/uN0/jB6XQHYaOlHbio03NTHCqrgG5n7g==", "dev": true, - "requires": { - "get-own-enumerable-property-symbols": "^3.0.0", - "is-obj": "^1.0.1", - "is-regexp": "^1.0.0" + "license": "MIT", + "dependencies": { + "vscode-languageserver-protocol": "3.17.5" + }, + "bin": { + "installServerIntoExtension": "bin/installServerIntoExtension" } }, - "strip-ansi": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz", - "integrity": "sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==", + "node_modules/vscode-languageserver-protocol": { + "version": "3.17.5", + "resolved": "https://registry.npmjs.org/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.17.5.tgz", + "integrity": "sha512-mb1bvRJN8SVznADSGWM9u/b07H7Ecg0I3OgXDuLdn307rl/J3A9YD6/eYOssqhecL27hK1IPZAsaqh00i/Jljg==", "dev": true, - "requires": { - "ansi-regex": "^5.0.0" + "license": "MIT", + "dependencies": { + "vscode-jsonrpc": "8.2.0", + "vscode-languageserver-types": "3.17.5" } }, - "strip-bom": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", - "integrity": "sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM=", - "dev": true - }, - "strip-final-newline": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/strip-final-newline/-/strip-final-newline-2.0.0.tgz", - "integrity": "sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA==", - "dev": true + "node_modules/vscode-languageserver-textdocument": { + "version": "1.0.12", + "resolved": "https://registry.npmjs.org/vscode-languageserver-textdocument/-/vscode-languageserver-textdocument-1.0.12.tgz", + "integrity": "sha512-cxWNPesCnQCcMPeenjKKsOCKQZ/L6Tv19DTRIGuLWe32lyzWhihGVJ/rcckZXJxfdKCFvRLS3fpBIsV/ZGX4zA==", + "dev": true, + "license": "MIT" }, - "strip-json-comments": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", - "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", - "dev": true + "node_modules/vscode-languageserver-types": { + "version": "3.17.5", + "resolved": "https://registry.npmjs.org/vscode-languageserver-types/-/vscode-languageserver-types-3.17.5.tgz", + "integrity": "sha512-Ld1VelNuX9pdF39h2Hgaeb5hEZM2Z3jUrrMgWQAu82jMtZp7p3vJT3BzToKtZI7NgQssZje5o0zryOrhQvzQAg==", + "dev": true, + "license": "MIT" }, - "supports-color": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", - "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "node_modules/vscode-nls": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/vscode-nls/-/vscode-nls-5.2.0.tgz", + "integrity": "sha512-RAaHx7B14ZU04EU31pT+rKz2/zSl7xMsfIZuo8pd+KZO6PXtQmpevpq3vxvWNcrGbdmhM/rr5Uw5Mz+NBfhVng==", "dev": true, - "requires": { - "has-flag": "^3.0.0" - } + "license": "MIT" }, - "systemjs": { - "version": "6.8.3", - "resolved": "https://registry.npmjs.org/systemjs/-/systemjs-6.8.3.tgz", - "integrity": "sha512-UcTY+FEA1B7e+bpJk1TI+a9Na6LG7wFEqW7ED16cLqLuQfI/9Ri0rsXm3tKlIgNoHyLHZycjdAOijzNbzelgwA==", - "dev": true + "node_modules/vscode-uri": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/vscode-uri/-/vscode-uri-3.1.0.tgz", + "integrity": "sha512-/BpdSx+yCQGnCvecbyXdxHDkuk55/G3xwnC0GqY4gmQ3j+A+g8kzzgB4Nk/SINjqn6+waqw3EgbVF2QKExkRxQ==", + "dev": true, + "license": "MIT" }, - "table": { - "version": "6.0.7", - "resolved": "https://registry.npmjs.org/table/-/table-6.0.7.tgz", - "integrity": "sha512-rxZevLGTUzWna/qBLObOe16kB2RTnnbhciwgPbMMlazz1yZGVEgnZK762xyVdVznhqxrfCeBMmMkgOOaPwjH7g==", - "dev": true, - "requires": { - "ajv": "^7.0.2", - "lodash": "^4.17.20", - "slice-ansi": "^4.0.0", - "string-width": "^4.2.0" - }, - "dependencies": { - "ajv": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-7.1.0.tgz", - "integrity": "sha512-svS9uILze/cXbH0z2myCK2Brqprx/+JJYK5pHicT/GQiBfzzhUVAIT6MwqJg8y4xV/zoGsUeuPuwtoiKSGE15g==", - "dev": true, - "requires": { - "fast-deep-equal": "^3.1.1", - "json-schema-traverse": "^1.0.0", - "require-from-string": "^2.0.2", - "uri-js": "^4.2.2" - } - }, - "json-schema-traverse": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", - "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==", - "dev": true + "node_modules/vue": { + "version": "3.5.26", + "resolved": "https://registry.npmjs.org/vue/-/vue-3.5.26.tgz", + "integrity": "sha512-SJ/NTccVyAoNUJmkM9KUqPcYlY+u8OVL1X5EW9RIs3ch5H2uERxyyIUI4MRxVCSOiEcupX9xNGde1tL9ZKpimA==", + "dev": true, + "license": "MIT", + "peer": true, + "dependencies": { + "@vue/compiler-dom": "3.5.26", + "@vue/compiler-sfc": "3.5.26", + "@vue/runtime-dom": "3.5.26", + "@vue/server-renderer": "3.5.26", + "@vue/shared": "3.5.26" + }, + "peerDependencies": { + "typescript": "*" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true } } }, - "terser": { - "version": "5.6.0-beta", - "resolved": "https://registry.npmjs.org/terser/-/terser-5.6.0-beta.tgz", - "integrity": "sha512-XqPZwi17FkFr42a6eGITU4ZHPixz1ZmuM9URQ/waMwxHenKjrxPndHtnuhNJ399P8tWFQuzZTTdN4ce3e2s28Q==", + "node_modules/vue-component-meta": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/vue-component-meta/-/vue-component-meta-3.2.2.tgz", + "integrity": "sha512-i1sAzQwHBXKvIFxxEoFL8+YzaJfIwyAypFOcElwXga2+J+ZxrhySiPRbnZuT9mHOEj40rkEm8Sw/93jumk7haA==", "dev": true, - "requires": { - "commander": "^2.20.0", - "source-map": "~0.7.2", - "source-map-support": "~0.5.19" - }, + "license": "MIT", "dependencies": { - "commander": { - "version": "2.20.3", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", - "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", - "dev": true + "@volar/typescript": "2.4.27", + "@vue/language-core": "3.2.2", + "path-browserify": "^1.0.1" + }, + "peerDependencies": { + "typescript": "*" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true } } }, - "test-exclude": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/test-exclude/-/test-exclude-6.0.0.tgz", - "integrity": "sha512-cAGWPIyOHU6zlmg88jwm7VRyXnMN7iV68OGAbYDk/Mh/xC/pzVPlQtY6ngoIH/5/tciuhGfvESU8GrHrcxD56w==", + "node_modules/vue-eslint-parser": { + "version": "10.2.0", + "resolved": "https://registry.npmjs.org/vue-eslint-parser/-/vue-eslint-parser-10.2.0.tgz", + "integrity": "sha512-CydUvFOQKD928UzZhTp4pr2vWz1L+H99t7Pkln2QSPdvmURT0MoC4wUccfCnuEaihNsu9aYYyk+bep8rlfkUXw==", "dev": true, - "requires": { - "@istanbuljs/schema": "^0.1.2", - "glob": "^7.1.4", - "minimatch": "^3.0.4" + "license": "MIT", + "peer": true, + "dependencies": { + "debug": "^4.4.0", + "eslint-scope": "^8.2.0", + "eslint-visitor-keys": "^4.2.0", + "espree": "^10.3.0", + "esquery": "^1.6.0", + "semver": "^7.6.3" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://github.com/sponsors/mysticatea" + }, + "peerDependencies": { + "eslint": "^8.57.0 || ^9.0.0" } }, - "text-table": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", - "integrity": "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=", - "dev": true - }, - "through": { - "version": "2.3.8", - "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", - "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=", - "dev": true - }, - "time-zone": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/time-zone/-/time-zone-1.0.0.tgz", - "integrity": "sha1-mcW/VZWJZq9tBtg73zgA3IL67F0=", - "dev": true - }, - "to-fast-properties": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz", - "integrity": "sha1-3F5pjL0HkmW8c+A3doGk5Og/YW4=", - "dev": true - }, - "to-regex-range": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", - "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "node_modules/vue-resize": { + "version": "2.0.0-alpha.1", + "resolved": "https://registry.npmjs.org/vue-resize/-/vue-resize-2.0.0-alpha.1.tgz", + "integrity": "sha512-7+iqOueLU7uc9NrMfrzbG8hwMqchfVfSzpVlCMeJQe4pyibqyoifDNbKTZvwxZKDvGkB+PdFeKvnGZMoEb8esg==", "dev": true, - "requires": { - "is-number": "^7.0.0" + "license": "MIT", + "peerDependencies": { + "vue": "^3.0.0" } }, - "tsconfig-paths": { - "version": "3.9.0", - "resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.9.0.tgz", - "integrity": "sha512-dRcuzokWhajtZWkQsDVKbWyY+jgcLC5sqJhg2PSgf4ZkH2aHPvaOY8YWGhmjb68b5qqTfasSsDO9k7RUiEmZAw==", + "node_modules/vue-tsc": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/vue-tsc/-/vue-tsc-3.2.2.tgz", + "integrity": "sha512-r9YSia/VgGwmbbfC06hDdAatH634XJ9nVl6Zrnz1iK4ucp8Wu78kawplXnIDa3MSu1XdQQePTHLXYwPDWn+nyQ==", "dev": true, - "requires": { - "@types/json5": "^0.0.29", - "json5": "^1.0.1", - "minimist": "^1.2.0", - "strip-bom": "^3.0.0" + "license": "MIT", + "peer": true, + "dependencies": { + "@volar/typescript": "2.4.27", + "@vue/language-core": "3.2.2" + }, + "bin": { + "vue-tsc": "bin/vue-tsc.js" + }, + "peerDependencies": { + "typescript": ">=5.0.0" } }, - "tslib": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.1.0.tgz", - "integrity": "sha512-hcVC3wYEziELGGmEEXue7D75zbwIIVUMWAVbHItGPx0ziyXxrOMQx4rQEVEV45Ut/1IotuEvwqPopzIOkDMf0A==", - "dev": true + "node_modules/w3c-keyname": { + "version": "2.2.8", + "resolved": "https://registry.npmjs.org/w3c-keyname/-/w3c-keyname-2.2.8.tgz", + "integrity": "sha512-dpojBhNsCNN7T82Tm7k26A6G9ML3NkhDsnw9n/eoxSRlVBB4CEtIQ/KTCLI2Fwf3ataSXRhYFkQi3SlnFwPvPQ==", + "dev": true, + "license": "MIT" }, - "tslint": { - "version": "6.1.3", - "resolved": "https://registry.npmjs.org/tslint/-/tslint-6.1.3.tgz", - "integrity": "sha512-IbR4nkT96EQOvKE2PW/djGz8iGNeJ4rF2mBfiYaR/nvUWYKJhLwimoJKgjIFEIDibBtOevj7BqCRL4oHeWWUCg==", + "node_modules/walk-sync": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/walk-sync/-/walk-sync-3.0.0.tgz", + "integrity": "sha512-41TvKmDGVpm2iuH7o+DAOt06yyu/cSHpX3uzAwetzASvlNtVddgIjXIb2DfB/Wa20B1Jo86+1Dv1CraSU7hWdw==", "dev": true, - "requires": { - "@babel/code-frame": "^7.0.0", - "builtin-modules": "^1.1.1", - "chalk": "^2.3.0", - "commander": "^2.12.1", - "diff": "^4.0.1", - "glob": "^7.1.1", - "js-yaml": "^3.13.1", - "minimatch": "^3.0.4", - "mkdirp": "^0.5.3", - "resolve": "^1.3.2", - "semver": "^5.3.0", - "tslib": "^1.13.0", - "tsutils": "^2.29.0" - }, - "dependencies": { - "builtin-modules": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-1.1.1.tgz", - "integrity": "sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=", - "dev": true - }, - "commander": { - "version": "2.20.3", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", - "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", - "dev": true - }, - "diff": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", - "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", - "dev": true - }, - "mkdirp": { - "version": "0.5.5", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz", - "integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==", - "dev": true, - "requires": { - "minimist": "^1.2.5" - } - }, - "semver": { - "version": "5.7.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", - "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", - "dev": true - }, - "tslib": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", - "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==", - "dev": true - } + "license": "MIT", + "dependencies": { + "@types/minimatch": "^3.0.4", + "ensure-posix-path": "^1.1.0", + "matcher-collection": "^2.0.1", + "minimatch": "^3.0.4" + }, + "engines": { + "node": "10.* || >= 12.*" } }, - "tsutils": { - "version": "2.29.0", - "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-2.29.0.tgz", - "integrity": "sha512-g5JVHCIJwzfISaXpXE1qvNalca5Jwob6FjI4AoPlqMusJ6ftFE7IkkFoMhVLRgK+4Kx3gkzb8UZK5t5yTTvEmA==", + "node_modules/wasm-pack": { + "version": "0.13.1", + "resolved": "https://registry.npmjs.org/wasm-pack/-/wasm-pack-0.13.1.tgz", + "integrity": "sha512-P9exD4YkjpDbw68xUhF3MDm/CC/3eTmmthyG5bHJ56kalxOTewOunxTke4SyF8MTXV6jUtNjXggPgrGmMtczGg==", "dev": true, - "requires": { - "tslib": "^1.8.1" - }, + "hasInstallScript": true, + "license": "MIT OR Apache-2.0", "dependencies": { - "tslib": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", - "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==", - "dev": true - } + "binary-install": "^1.0.1" + }, + "bin": { + "wasm-pack": "run.js" } }, - "type-check": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", - "integrity": "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==", + "node_modules/which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", "dev": true, - "requires": { - "prelude-ls": "^1.2.1" + "license": "ISC", + "dependencies": { + "isexe": "^2.0.0" + }, + "bin": { + "node-which": "bin/node-which" + }, + "engines": { + "node": ">= 8" } }, - "type-fest": { - "version": "0.8.1", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.8.1.tgz", - "integrity": "sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA==", - "dev": true + "node_modules/which-module": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.1.tgz", + "integrity": "sha512-iBdZ57RDvnOR9AGBhML2vFZf7h8vmBjhoaZqODJBFWHVtKkDmKuHai3cx5PgVMrX5YDNp27AofYbAwctSS+vhQ==", + "dev": true, + "license": "ISC" }, - "typedarray-to-buffer": { - "version": "3.1.5", - "resolved": "https://registry.npmjs.org/typedarray-to-buffer/-/typedarray-to-buffer-3.1.5.tgz", - "integrity": "sha512-zdu8XMNEDepKKR+XYOXAVPtWui0ly0NtohUscw+UmaHiAWT8hrV1rr//H6V+0DvJ3OQ19S979M0laLfX8rm82Q==", + "node_modules/word-wrap": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.5.tgz", + "integrity": "sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==", "dev": true, - "requires": { - "is-typedarray": "^1.0.0" + "license": "MIT", + "engines": { + "node": ">=0.10.0" } }, - "typescript": { - "version": "4.1.5", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.1.5.tgz", - "integrity": "sha512-6OSu9PTIzmn9TCDiovULTnET6BgXtDYL4Gg4szY+cGsc3JP1dQL8qvE8kShTRx1NIw4Q9IBHlwODjkjWEtMUyA==", - "dev": true - }, - "uc.micro": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/uc.micro/-/uc.micro-1.0.6.tgz", - "integrity": "sha512-8Y75pvTYkLJW2hWQHXxoqRgV7qb9B+9vFEtidML+7koHUFapnVJAZ6cKs+Qjz5Aw3aZWHMC6u0wJE3At+nSGwA==", - "dev": true - }, - "unicode-canonical-property-names-ecmascript": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/unicode-canonical-property-names-ecmascript/-/unicode-canonical-property-names-ecmascript-1.0.4.tgz", - "integrity": "sha512-jDrNnXWHd4oHiTZnx/ZG7gtUTVp+gCcTTKr8L0HjlwphROEW3+Him+IpvC+xcJEFegapiMZyZe02CyuOnRmbnQ==", - "dev": true + "node_modules/workerpool": { + "version": "9.3.4", + "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-9.3.4.tgz", + "integrity": "sha512-TmPRQYYSAnnDiEB0P/Ytip7bFGvqnSU6I2BcuSw7Hx+JSg/DsUi5ebYfc8GYaSdpuvOcEs6dXxPurOYpe9QFwg==", + "dev": true, + "license": "Apache-2.0" }, - "unicode-match-property-ecmascript": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/unicode-match-property-ecmascript/-/unicode-match-property-ecmascript-1.0.4.tgz", - "integrity": "sha512-L4Qoh15vTfntsn4P1zqnHulG0LdXgjSO035fEpdtp6YxXhMT51Q6vgM5lYdG/5X3MjS+k/Y9Xw4SFCY9IkR0rg==", + "node_modules/wrap-ansi": { + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-6.2.0.tgz", + "integrity": "sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==", "dev": true, - "requires": { - "unicode-canonical-property-names-ecmascript": "^1.0.4", - "unicode-property-aliases-ecmascript": "^1.0.4" + "license": "MIT", + "dependencies": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=8" } }, - "unicode-match-property-value-ecmascript": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/unicode-match-property-value-ecmascript/-/unicode-match-property-value-ecmascript-1.2.0.tgz", - "integrity": "sha512-wjuQHGQVofmSJv1uVISKLE5zO2rNGzM/KCYZch/QQvez7C1hUhBIuZ701fYXExuufJFMPhv2SyL8CyoIfMLbIQ==", - "dev": true - }, - "unicode-property-aliases-ecmascript": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/unicode-property-aliases-ecmascript/-/unicode-property-aliases-ecmascript-1.1.0.tgz", - "integrity": "sha512-PqSoPh/pWetQ2phoj5RLiaqIk4kCNwoV3CI+LfGmWLKI3rE3kl1h59XpX2BjgDrmbxD9ARtQobPGU1SguCYuQg==", - "dev": true - }, - "universalify": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", - "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==", - "dev": true + "node_modules/wrap-ansi-cjs": { + "name": "wrap-ansi", + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } }, - "uri-js": { - "version": "4.4.1", - "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", - "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", + "node_modules/wrap-ansi-cjs/node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", "dev": true, - "requires": { - "punycode": "^2.1.0" + "license": "MIT", + "engines": { + "node": ">=8" } }, - "url-parse": { - "version": "1.4.7", - "resolved": "https://registry.npmjs.org/url-parse/-/url-parse-1.4.7.tgz", - "integrity": "sha512-d3uaVyzDB9tQoSXFvuSUNFibTd9zxd2bkVrDRvF5TmvWWQwqE4lgYJ5m+x1DbecWkw+LK4RNl2CU1hHuOKPVlg==", + "node_modules/wrap-ansi-cjs/node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", "dev": true, - "requires": { - "querystringify": "^2.1.1", - "requires-port": "^1.0.0" + "license": "MIT", + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" } }, - "uuid": { - "version": "3.4.0", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", - "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==", - "dev": true + "node_modules/wrap-ansi-cjs/node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } }, - "v8-compile-cache": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.2.0.tgz", - "integrity": "sha512-gTpR5XQNKFwOd4clxfnhaqvfqMpqEwr4tOtCyz4MtYZX2JYhfr1JvBFKdS+7K/9rfpZR3VLX+YWBbKoxCgS43Q==", - "dev": true + "node_modules/wrap-ansi-cjs/node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true, + "license": "MIT" }, - "validate-npm-package-license": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz", - "integrity": "sha512-DpKm2Ui/xN7/HQKCtpZxoRWBhZ9Z0kqtygG8XCgNQ8ZlDnxuQmWhj566j8fN4Cu3/JmbhsDo7fcAJq4s9h27Ew==", + "node_modules/wrap-ansi-cjs/node_modules/is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", "dev": true, - "requires": { - "spdx-correct": "^3.0.0", - "spdx-expression-parse": "^3.0.0" + "license": "MIT", + "engines": { + "node": ">=8" } }, - "walk-sync": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/walk-sync/-/walk-sync-2.2.0.tgz", - "integrity": "sha512-IC8sL7aB4/ZgFcGI2T1LczZeFWZ06b3zoHH7jBPyHxOtIIz1jppWHjjEXkOFvFojBVAK9pV7g47xOZ4LW3QLfg==", + "node_modules/wrap-ansi-cjs/node_modules/string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", "dev": true, - "requires": { - "@types/minimatch": "^3.0.3", - "ensure-posix-path": "^1.1.0", - "matcher-collection": "^2.0.0", - "minimatch": "^3.0.4" + "license": "MIT", + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" } }, - "weak-napi": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/weak-napi/-/weak-napi-2.0.2.tgz", - "integrity": "sha512-LcOSVFrghtVXf4QH+DLIy8iPiCktV7lVbqRDYP+bDPpLzC41RCHQPMyQOnPpWO41Ie4CmnDxS+mbL72r5xFMMQ==", + "node_modules/wrap-ansi-cjs/node_modules/strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", "dev": true, - "requires": { - "node-addon-api": "^3.0.0", - "node-gyp-build": "^4.2.1", - "setimmediate-napi": "^1.0.3" + "license": "MIT", + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" } }, - "which": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", - "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "node_modules/wrap-ansi/node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", "dev": true, - "requires": { - "isexe": "^2.0.0" + "license": "MIT", + "engines": { + "node": ">=8" } }, - "which-module": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.0.tgz", - "integrity": "sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=", - "dev": true - }, - "wide-align": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.3.tgz", - "integrity": "sha512-QGkOQc8XL6Bt5PwnsExKBPuMKBxnGxWWW3fU55Xt4feHozMUhdUMaBCk290qpm/wG5u/RSKzwdAC4i51YigihA==", + "node_modules/wrap-ansi/node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", "dev": true, - "requires": { - "string-width": "^1.0.2 || 2" + "license": "MIT", + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/wrap-ansi/node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "license": "MIT", "dependencies": { - "ansi-regex": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", - "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", - "dev": true - }, - "is-fullwidth-code-point": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", - "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", - "dev": true - }, - "string-width": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", - "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", - "dev": true, - "requires": { - "is-fullwidth-code-point": "^2.0.0", - "strip-ansi": "^4.0.0" - } - }, - "strip-ansi": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", - "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", - "dev": true, - "requires": { - "ansi-regex": "^3.0.0" - } - } + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" } }, - "word-wrap": { - "version": "1.2.3", - "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz", - "integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==", - "dev": true + "node_modules/wrap-ansi/node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true, + "license": "MIT" }, - "workerpool": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-6.1.0.tgz", - "integrity": "sha512-toV7q9rWNYha963Pl/qyeZ6wG+3nnsyvolaNUS8+R5Wtw6qJPTxIlOP1ZSvcGhEJw+l3HMMmtiNo9Gl61G4GVg==", - "dev": true + "node_modules/wrap-ansi/node_modules/is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } }, - "wrap-ansi": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", - "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", + "node_modules/wrap-ansi/node_modules/string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", "dev": true, - "requires": { - "ansi-styles": "^4.0.0", - "string-width": "^4.1.0", - "strip-ansi": "^6.0.0" + "license": "MIT", + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" }, + "engines": { + "node": ">=8" + } + }, + "node_modules/wrap-ansi/node_modules/strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "license": "MIT", "dependencies": { - "ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "requires": { - "color-convert": "^2.0.1" - } - }, - "color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "requires": { - "color-name": "~1.1.4" - } - }, - "color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true - } + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" } }, - "wrappy": { + "node_modules/wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", - "dev": true + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", + "dev": true, + "license": "ISC" }, - "write-file-atomic": { + "node_modules/write-file-atomic": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-3.0.3.tgz", "integrity": "sha512-AvHcyZ5JnSfq3ioSyjrBkH9yW4m7Ayk8/9My/DD9onKeu/94fwrMocemO2QAJFAlnnDN+ZDS+ZjAR5ua1/PV/Q==", "dev": true, - "requires": { + "license": "ISC", + "dependencies": { "imurmurhash": "^0.1.4", "is-typedarray": "^1.0.0", "signal-exit": "^3.0.2", "typedarray-to-buffer": "^3.1.5" } }, - "write-json-file": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/write-json-file/-/write-json-file-4.3.0.tgz", - "integrity": "sha512-PxiShnxf0IlnQuMYOPPhPkhExoCQuTUNPOa/2JWCYTmBquU9njyyDuwRKN26IZBlp4yn1nt+Agh2HOOBl+55HQ==", + "node_modules/write-file-atomic/node_modules/signal-exit": { + "version": "3.0.7", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz", + "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==", "dev": true, - "requires": { - "detect-indent": "^6.0.0", - "graceful-fs": "^4.1.15", - "is-plain-obj": "^2.0.0", - "make-dir": "^3.0.0", - "sort-keys": "^4.0.0", - "write-file-atomic": "^3.0.0" - } + "license": "ISC" }, - "y18n": { - "version": "5.0.5", - "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.5.tgz", - "integrity": "sha512-hsRUr4FFrvhhRH12wOdfs38Gy7k2FFzB9qgN9v3aLykRq0dRcdcpz5C9FxdS2NuhOrI/628b/KSTJ3rwHysYSg==", - "dev": true + "node_modules/ws": { + "version": "8.19.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.19.0.tgz", + "integrity": "sha512-blAT2mjOEIi0ZzruJfIhb3nps74PRWTCz1IjglWEEpQl5XS/UNama6u2/rjFkDDouqr4L67ry+1aGIALViWjDg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10.0.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": ">=5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } + } }, - "yallist": { + "node_modules/xml-name-validator": { "version": "4.0.0", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", - "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", - "dev": true + "resolved": "https://registry.npmjs.org/xml-name-validator/-/xml-name-validator-4.0.0.tgz", + "integrity": "sha512-ICP2e+jsHvAj2E2lIHxa5tjXRlKDJo4IdvPvCXbXQGdzSfmSpNVyIKMvoZHjDY9DP0zV17iI85o90vRFXNccRw==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=12" + } }, - "yaml": { - "version": "1.10.0", - "resolved": "https://registry.npmjs.org/yaml/-/yaml-1.10.0.tgz", - "integrity": "sha512-yr2icI4glYaNG+KWONODapy2/jDdMSDnrONSjblABjD9B4Z5LgiircSt8m8sRZFNi08kG9Sm0uSHtEmP3zaEGg==", - "dev": true + "node_modules/y18n": { + "version": "5.0.8", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", + "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", + "dev": true, + "license": "ISC", + "engines": { + "node": ">=10" + } + }, + "node_modules/yallist": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz", + "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==", + "dev": true, + "license": "ISC" + }, + "node_modules/yaml": { + "version": "2.8.2", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.8.2.tgz", + "integrity": "sha512-mplynKqc1C2hTVYxd0PU2xQAc22TI1vShAYGksCCfxbn/dFwnHTNi1bvYsBTkhdUNtGIf5xNOg938rrSSYvS9A==", + "dev": true, + "license": "ISC", + "peer": true, + "bin": { + "yaml": "bin.mjs" + }, + "engines": { + "node": ">= 14.6" + }, + "funding": { + "url": "https://github.com/sponsors/eemeli" + } }, - "yargs": { - "version": "16.2.0", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-16.2.0.tgz", - "integrity": "sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw==", + "node_modules/yargs": { + "version": "17.7.2", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.7.2.tgz", + "integrity": "sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==", "dev": true, - "requires": { - "cliui": "^7.0.2", + "license": "MIT", + "dependencies": { + "cliui": "^8.0.1", "escalade": "^3.1.1", "get-caller-file": "^2.0.5", "require-directory": "^2.1.1", - "string-width": "^4.2.0", + "string-width": "^4.2.3", "y18n": "^5.0.5", - "yargs-parser": "^20.2.2" + "yargs-parser": "^21.1.1" + }, + "engines": { + "node": ">=12" } }, - "yargs-parser": { - "version": "20.2.4", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.4.tgz", - "integrity": "sha512-WOkpgNhPTlE73h4VFAFsOnomJVaovO8VqLDzy5saChRBFQFBoMYirowyW+Q9HB4HFF4Z7VZTiG3iSzJJA29yRA==", - "dev": true + "node_modules/yargs-parser": { + "version": "21.1.1", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz", + "integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==", + "dev": true, + "license": "ISC", + "engines": { + "node": ">=12" + } }, - "yargs-unparser": { + "node_modules/yargs-unparser": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/yargs-unparser/-/yargs-unparser-2.0.0.tgz", "integrity": "sha512-7pRTIA9Qc1caZ0bZ6RYRGbHJthJWuakf+WmHK0rVeLkNrrGhfoabBNdue6kdINI6r4if7ocq9aD/n7xwKOdzOA==", "dev": true, - "requires": { + "license": "MIT", + "dependencies": { "camelcase": "^6.0.0", "decamelize": "^4.0.0", "flat": "^5.0.2", "is-plain-obj": "^2.1.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/yargs-unparser/node_modules/camelcase": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.3.0.tgz", + "integrity": "sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/yargs-unparser/node_modules/decamelize": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-4.0.0.tgz", + "integrity": "sha512-9iE1PgSik9HeIIw2JO94IidnE3eBoQrFJ3w7sFuzSX4DpmZ3v5sZpUiV5Swcf6mQEF+Y0ru8Neo+p+nyh2J+hQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/yargs-unparser/node_modules/is-plain-obj": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-2.1.0.tgz", + "integrity": "sha512-YWnfyRwxL/+SsrWYfOpUtz5b3YD+nyfkHvjbcanzk8zgyO4ASD67uVMRt8k5bM4lLMDnXfriRhOpemw+NfT1eA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/yargs/node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/yargs/node_modules/is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" } }, - "yocto-queue": { + "node_modules/yargs/node_modules/string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dev": true, + "license": "MIT", + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/yargs/node_modules/strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/yauzl": { + "version": "2.10.0", + "resolved": "https://registry.npmjs.org/yauzl/-/yauzl-2.10.0.tgz", + "integrity": "sha512-p4a9I6X6nu6IhoGmBqAcbJy1mlC4j27vEPZX9F4L4/vZT3Lyq1VkFHw/V/PUcB9Buo+DG3iHkT0x3Qya58zc3g==", + "dev": true, + "license": "MIT", + "dependencies": { + "buffer-crc32": "~0.2.3", + "fd-slicer": "~1.1.0" + } + }, + "node_modules/yocto-queue": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", "integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==", - "dev": true + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/yoctocolors-cjs": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/yoctocolors-cjs/-/yoctocolors-cjs-2.1.3.tgz", + "integrity": "sha512-U/PBtDf35ff0D8X8D0jfdzHYEPFxAI7jJlxZXwCSez5M3190m+QobIfh+sWDWSHMCWWJN2AWamkegn6vr6YBTw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/zod": { + "version": "3.23.8", + "resolved": "https://registry.npmjs.org/zod/-/zod-3.23.8.tgz", + "integrity": "sha512-XBx9AXhXktjUqnepgTiE5flcKIYWi/rme0Eaj+5Y0lftuGBq+jyRu/md4WnuxqgP1ubdpNCsYEYPxrzVHD8d6g==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/colinhacks" + } + }, + "node_modules/zwitch": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/zwitch/-/zwitch-2.0.4.tgz", + "integrity": "sha512-bXE4cR/kVZhKZX/RjPEflHaKVhUVl85noU3v6b8apfQEc1x4A+zBxjZ4lN8LqGd6WZ3dl98pY4o717VFmoPp+A==", + "dev": true, + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } } } } diff --git a/package.json b/package.json index 55e97e499b9..ccb4d4a4156 100644 --- a/package.json +++ b/package.json @@ -1,48 +1,104 @@ { "name": "rollup", - "version": "2.45.2", + "version": "4.56.0", "description": "Next-generation ES module bundler", "main": "dist/rollup.js", "module": "dist/es/rollup.js", - "typings": "dist/rollup.d.ts", + "types": "dist/rollup.d.ts", "bin": { "rollup": "dist/bin/rollup" }, + "napi": { + "binaryName": "rollup", + "packageName": "@rollup/rollup", + "targets": [ + "aarch64-apple-darwin", + "aarch64-linux-android", + "aarch64-pc-windows-msvc", + "aarch64-unknown-freebsd", + "aarch64-unknown-linux-gnu", + "aarch64-unknown-linux-musl", + "armv7-linux-androideabi", + "armv7-unknown-linux-gnueabihf", + "armv7-unknown-linux-musleabihf", + "i686-pc-windows-msvc", + "loongarch64-unknown-linux-gnu", + "loongarch64-unknown-linux-musl", + "riscv64gc-unknown-linux-gnu", + "riscv64gc-unknown-linux-musl", + "powerpc64le-unknown-linux-gnu", + "powerpc64le-unknown-linux-musl", + "s390x-unknown-linux-gnu", + "x86_64-apple-darwin", + "x86_64-pc-windows-gnu", + "x86_64-pc-windows-msvc", + "x86_64-unknown-freebsd", + "x86_64-unknown-linux-gnu", + "x86_64-unknown-linux-musl", + "x86_64-unknown-openbsd", + "aarch64-unknown-linux-ohos" + ] + }, "scripts": { - "build": "shx rm -rf dist && git rev-parse HEAD > .commithash && rollup -c && shx cp src/rollup/types.d.ts dist/rollup.d.ts && shx chmod a+x dist/bin/rollup", - "build:cjs": "shx rm -rf dist && rollup -c --configTest && shx cp src/rollup/types.d.ts dist/rollup.d.ts && shx chmod a+x dist/bin/rollup", - "build:bootstrap": "dist/bin/rollup -c && shx cp src/rollup/types.d.ts dist/rollup.d.ts && shx chmod a+x dist/bin/rollup", - "ci:lint": "npm run lint:nofix", - "ci:test": "npm run build:cjs && npm run build:bootstrap && npm run test:all", - "ci:test:only": "npm run build:cjs && npm run build:bootstrap && npm run test:only", - "ci:coverage": "npm run build:cjs && nyc --reporter lcovonly mocha", - "lint": "npm run lint:ts -- --fix && npm run lint:js -- --fix && npm run lint:markdown", - "lint:nofix": "npm run lint:ts && npm run lint:js && npm run lint:markdown", - "lint:ts": "tslint --project .", - "lint:js": "eslint test/test.js test/*/index.js test/utils.js test/**/_config.js", - "lint:markdown": "markdownlint --config markdownlint.json docs/**/*.md", - "perf": "npm run build:cjs && node --expose-gc scripts/perf.js", - "perf:debug": "node --inspect-brk scripts/perf-debug.js", - "perf:init": "node scripts/perf-init.js", - "postinstall": "husky install", - "postpublish": "pinst --enable && git push && git push --tags", - "prepare": "npm run build", - "prepublishOnly": "pinst --disable && npm ci && npm run lint:nofix && npm run security && npm run build:bootstrap && npm run test:all", - "security": "npm audit", + "build": "concurrently -c green,blue \"npm run build:wasm\" \"npm:build:ast-converters\" && concurrently -c green,blue \"npm run build:napi -- --release\" \"npm:build:js\" && npm run build:copy-native", + "build:quick": "concurrently -c green,blue 'npm:build:napi' 'npm:build:cjs' && npm run build:copy-native", + "build:napi": "napi build --cwd rust/bindings_napi --platform --dts ../../native.d.ts --no-js --output-dir ../.. --package-json-path ../../package.json", + "build:wasm": "wasm-pack build rust/bindings_wasm --out-dir ../../wasm --target web --no-pack && shx rm wasm/.gitignore", + "build:wasm:node": "wasm-pack build rust/bindings_wasm --out-dir ../../wasm-node --target nodejs --no-pack && shx rm wasm-node/.gitignore", + "update:napi": "npm run build:napi && npm run build:copy-native", + "build:js": "rollup --config rollup.config.ts --configPlugin typescript --forceExit", + "build:js:node": "rollup --config rollup.config.ts --configPlugin typescript --configIsBuildNode --forceExit", + "build:prepare": "concurrently -c green,blue \"npm run build:napi -- --release\" \"npm:build:js:node\" && npm run build:copy-native", + "update:js": "npm run build:js && npm run build:copy-native", + "build:copy-native": "shx mkdir -p dist && shx cp rollup.*.node dist/", + "dev": "concurrently -kc green,blue 'nodemon --watch rust -e rs --exec \"npm run build:wasm\"' 'vitepress dev docs'", + "build:cjs": "rollup --config rollup.config.ts --configPlugin typescript --configTest --forceExit", + "build:bootstrap": "shx mv dist dist-build && node dist-build/bin/rollup --config rollup.config.ts --configPlugin typescript --forceExit && shx rm -rf dist-build", + "build:bootstrap:cjs": "shx mv dist dist-build && node dist-build/bin/rollup --config rollup.config.ts --configPlugin typescript --configTest --forceExit && shx rm -rf dist-build", + "build:docs": "vitepress build docs", + "build:ast-converters": "node scripts/generate-ast-converters.js", + "preview:docs": "vitepress preview docs", + "ci:artifacts": "napi artifacts", + "ci:lint": "concurrently -c red,yellow,green,blue 'npm:lint:js:nofix' 'npm:lint:native-js' 'npm:lint:markdown:nofix' 'npm:lint:rust:nofix'", + "ci:test:all": "concurrently --kill-others-on-fail -c green,blue,magenta,cyan 'npm:test:only' 'npm:test:typescript' 'npm:test:leak' 'npm:test:browser'", + "ci:coverage": "NODE_OPTIONS=--no-experimental-require-module nyc --reporter lcovonly mocha", + "lint": "concurrently -c red,yellow,green,blue 'npm:lint:js' 'npm:lint:native-js' 'npm:lint:markdown' 'npm:lint:rust'", + "lint:js": "eslint . --fix --cache --concurrency auto", + "lint:js:nofix": "eslint . --cache --concurrency auto", + "lint:native-js": "node scripts/lint-native-js.js", + "lint:markdown": "prettier --write \"**/*.md\"", + "lint:markdown:nofix": "prettier --check \"**/*.md\"", + "lint:rust": "cd rust && cargo fmt && cargo clippy --fix --allow-dirty", + "lint:rust:nofix": "cd rust && cargo fmt --check && cargo clippy", + "perf": "npm run build:bootstrap:cjs && node --expose-gc scripts/perf-report/index.js", + "prepare": "husky && npm run prepare:patch && node scripts/check-release.js || npm run build:prepare", + "prepare:patch": "patch-package", + "prepublishOnly": "node scripts/check-release.js && node scripts/prepublish.js", + "postpublish": "node scripts/postpublish.js", + "prepublish:napi": "napi prepublish --no-gh-release", + "release": "node scripts/prepare-release.js", + "release:docs": "git fetch --update-head-ok origin master:master && git branch --force documentation-published master && git push origin documentation-published", + "check-audit": "check-audit", + "resolve-audit": "resolve-audit", "test": "npm run build && npm run test:all", + "test:update-snapshots": "node scripts/update-snapshots.js", "test:cjs": "npm run build:cjs && npm run test:only", "test:quick": "mocha -b test/test.js", - "test:all": "npm run test:only && npm run test:browser && npm run test:typescript && npm run test:leak && npm run test:package", + "test:all": "concurrently --kill-others-on-fail -c green,blue,magenta,cyan,red 'npm:test:only' 'npm:test:browser' 'npm:test:typescript' 'npm:test:package' 'npm:test:options'", "test:coverage": "npm run build:cjs && shx rm -rf coverage/* && nyc --reporter html mocha test/test.js", "test:coverage:browser": "npm run build && shx rm -rf coverage/* && nyc mocha test/browser/index.js", - "test:leak": "node --expose-gc test/leak/index.js", + "test:leak": "npm install --no-save weak-napi && node --expose-gc test/leak/index.js", "test:package": "node scripts/test-package.js", + "test:options": "node scripts/test-options.js", "test:only": "mocha test/test.js", - "test:typescript": "shx rm -rf test/typescript/dist && shx cp -r dist test/typescript/ && tsc --noEmit -p test/typescript && tsc --noEmit", + "test:typescript": "shx rm -rf test/typescript/dist && shx cp -r dist test/typescript/ && tsc --noEmit -p test/typescript && tsc --noEmit -p . && tsc --noEmit -p scripts && vue-tsc --noEmit -p docs", "test:browser": "mocha test/browser/index.js", - "watch": "rollup -cw" + "watch": "rollup --config rollup.config.ts --configPlugin typescript --watch" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/rollup/rollup.git" }, - "repository": "rollup/rollup", "keywords": [ "modules", "bundler", @@ -57,93 +113,149 @@ }, "homepage": "https://rollupjs.org/", "optionalDependencies": { - "fsevents": "~2.3.1" + "fsevents": "~2.3.2" + }, + "dependencies": { + "@types/estree": "1.0.8" + }, + "devDependenciesComments": { + "core-js": "We only update manually as every update requires a snapshot update" }, "devDependencies": { - "@rollup/plugin-alias": "^3.1.2", - "@rollup/plugin-buble": "^0.21.3", - "@rollup/plugin-commonjs": "^18.0.0-1", - "@rollup/plugin-json": "^4.1.0", - "@rollup/plugin-node-resolve": "^11.1.1", - "@rollup/plugin-replace": "^2.3.4", - "@types/micromatch": "^4.0.1", - "@types/node": "^10.17.51", - "@types/require-relative": "^0.8.0", - "@types/signal-exit": "^3.0.0", - "@types/yargs-parser": "^20.2.0", - "acorn": "^8.0.5", - "acorn-class-fields": "^1.0.0", - "acorn-jsx": "^5.3.1", - "acorn-private-methods": "^1.0.0", - "acorn-static-class-features": "^1.0.0", - "acorn-walk": "^8.0.2", + "@codemirror/commands": "^6.10.1", + "@codemirror/lang-javascript": "^6.2.4", + "@codemirror/language": "^6.12.1", + "@codemirror/search": "^6.6.0", + "@codemirror/state": "^6.5.3", + "@codemirror/view": "^6.39.10", + "@eslint/js": "^9.39.2", + "@inquirer/prompts": "^7.10.1", + "@jridgewell/sourcemap-codec": "^1.5.5", + "@mermaid-js/mermaid-cli": "^11.12.0", + "@napi-rs/cli": "3.4.1", + "@rollup/plugin-alias": "^6.0.0", + "@rollup/plugin-buble": "^1.0.3", + "@rollup/plugin-commonjs": "^29.0.0", + "@rollup/plugin-json": "^6.1.0", + "@rollup/plugin-node-resolve": "^16.0.3", + "@rollup/plugin-replace": "^6.0.3", + "@rollup/plugin-terser": "^0.4.4", + "@rollup/plugin-typescript": "^12.3.0", + "@rollup/pluginutils": "^5.3.0", + "@shikijs/vitepress-twoslash": "^3.21.0", + "@types/mocha": "^10.0.10", + "@types/node": "^20.19.28", + "@types/picomatch": "^4.0.2", + "@types/semver": "^7.7.1", + "@types/yargs-parser": "^21.0.3", + "@vue/language-server": "^3.2.2", + "acorn": "^8.15.0", + "acorn-import-assertions": "^1.9.0", + "acorn-jsx": "^5.3.2", "buble": "^0.20.0", - "chokidar": "^3.5.1", - "colorette": "^1.2.1", - "core-js": "^3.8.3", - "date-time": "^3.1.0", - "es5-shim": "^4.5.15", - "es6-shim": "^0.35.6", - "eslint": "^7.19.0", - "eslint-plugin-import": "^2.22.1", - "execa": "^5.0.0", - "fixturify": "^2.1.0", - "hash.js": "^1.1.7", - "husky": "^5.0.9", - "is-reference": "git+https://github.com/lukastaegert/is-reference.git#update-class-features", - "lint-staged": "^10.5.4", - "locate-character": "^2.0.5", - "magic-string": "^0.25.7", - "markdownlint-cli": "^0.26.0", - "micromatch": "^4.0.2", - "mocha": "^8.3.0", - "node-fetch": "^2.6.1", - "nyc": "^15.1.0", - "pinst": "^2.1.4", - "prettier": "^2.2.1", - "pretty-bytes": "^5.5.0", - "pretty-ms": "^7.0.1", - "require-relative": "^0.8.7", - "requirejs": "^2.3.6", - "rollup": "^2.38.5", - "rollup-plugin-license": "^2.2.0", - "rollup-plugin-string": "^3.0.0", - "rollup-plugin-terser": "^7.0.2", - "rollup-plugin-thatworks": "^1.0.4", - "rollup-plugin-typescript": "^1.0.1", - "rollup-pluginutils": "^2.8.2", - "sander": "^0.6.0", - "shx": "^0.3.3", - "signal-exit": "^3.0.3", - "source-map": "^0.7.3", - "source-map-support": "^0.5.19", - "sourcemap-codec": "^1.4.8", - "systemjs": "^6.8.3", - "terser": "^5.6.0-beta", - "tslib": "^2.1.0", - "tslint": "^6.1.3", - "typescript": "^4.1.5", - "url-parse": "^1.4.7", - "weak-napi": "^2.0.2", - "yargs-parser": "^20.2.4" + "builtin-modules": "^5.0.0", + "chokidar": "^3.6.0", + "concurrently": "^9.2.1", + "core-js": "3.38.1", + "cross-env": "^10.1.0", + "date-time": "^4.0.0", + "es5-shim": "^4.6.7", + "es6-shim": "^0.35.8", + "eslint": "^9.39.2", + "eslint-config-prettier": "^10.1.8", + "eslint-plugin-prettier": "^5.5.4", + "eslint-plugin-unicorn": "^62.0.0", + "eslint-plugin-vue": "^10.6.2", + "fixturify": "^3.0.0", + "flru": "^1.0.2", + "fs-extra": "^11.3.3", + "github-api": "^3.4.0", + "globals": "^17.0.0", + "husky": "^9.1.7", + "is-reference": "^3.0.3", + "lint-staged": "^16.2.7", + "locate-character": "^3.0.0", + "magic-string": "^0.30.21", + "memfs": "^4.51.1", + "mocha": "^11.7.5", + "nodemon": "^3.1.11", + "npm-audit-resolver": "^3.0.0-RC.0", + "nyc": "^17.1.0", + "patch-package": "^8.0.1", + "picocolors": "^1.1.1", + "picomatch": "^4.0.3", + "pinia": "^3.0.4", + "prettier": "^3.7.4", + "prettier-plugin-organize-imports": "^4.3.0", + "pretty-bytes": "^7.1.0", + "pretty-ms": "^9.3.0", + "requirejs": "^2.3.8", + "rollup": "^4.55.1", + "rollup-plugin-license": "^3.6.0", + "semver": "^7.7.3", + "shx": "^0.4.0", + "signal-exit": "^4.1.0", + "source-map": "^0.7.6", + "source-map-support": "^0.5.21", + "systemjs": "^6.15.1", + "terser": "^5.44.1", + "tslib": "^2.8.1", + "typescript": "^5.9.3", + "typescript-eslint": "^8.53.0", + "vite": "^7.3.1", + "vitepress": "^1.6.4", + "vue": "^3.5.26", + "vue-eslint-parser": "^10.2.0", + "vue-tsc": "^3.2.2", + "wasm-pack": "^0.13.1", + "yargs-parser": "^21.1.1" + }, + "overrides": { + "axios": "^1.13.2", + "esbuild": ">0.24.2", + "readable-stream": "npm:@built-in/readable-stream@1", + "semver": "^7.7.3", + "vite": "$vite", + "path-scurry": { + "lru-cache": "^11.2.4" + } + }, + "comments": { + "vue-tsc": "This is necessary so that prettier-plugin-organize-imports works correctly in Vue templatges" }, "files": [ + "dist/*.node", "dist/**/*.js", "dist/*.d.ts", "dist/bin/rollup", - "dist/rollup.browser.js.map" + "dist/es/package.json" ], "engines": { - "node": ">=10.0.0" + "node": ">=18.0.0", + "npm": ">=8.0.0" }, "exports": { ".": { - "node": { - "require": "./dist/rollup.js", - "import": "./dist/es/rollup.js" - }, - "default": "./dist/es/rollup.browser.js" + "types": "./dist/rollup.d.ts", + "import": "./dist/es/rollup.js", + "require": "./dist/rollup.js" + }, + "./loadConfigFile": { + "types": "./dist/loadConfigFile.d.ts", + "require": "./dist/loadConfigFile.js", + "default": "./dist/loadConfigFile.js" + }, + "./getLogFilter": { + "types": "./dist/getLogFilter.d.ts", + "import": "./dist/es/getLogFilter.js", + "require": "./dist/getLogFilter.js" + }, + "./parseAst": { + "types": "./dist/parseAst.d.ts", + "import": "./dist/es/parseAst.js", + "require": "./dist/parseAst.js" }, - "./dist/": "./dist/" + "./dist/*": "./dist/*", + "./package.json": "./package.json" } } diff --git a/patches/@types+rimraf+3.0.2.patch b/patches/@types+rimraf+3.0.2.patch new file mode 100644 index 00000000000..cf1f70564d7 --- /dev/null +++ b/patches/@types+rimraf+3.0.2.patch @@ -0,0 +1,13 @@ +diff --git a/node_modules/@types/rimraf/index.d.ts b/node_modules/@types/rimraf/index.d.ts +index 4f89241..282933a 100755 +--- a/node_modules/@types/rimraf/index.d.ts ++++ b/node_modules/@types/rimraf/index.d.ts +@@ -30,7 +30,7 @@ declare namespace rimraf { + emfileWait?: number | undefined; + /** @default false */ + disableGlob?: boolean | undefined; +- glob?: glob.IOptions | false | undefined; ++ glob?: any; + + unlink?: typeof fs.unlink | undefined; + chmod?: typeof fs.chmod | undefined; diff --git a/patches/@vueuse+core+12.8.2.patch b/patches/@vueuse+core+12.8.2.patch new file mode 100644 index 00000000000..b35a8faea83 --- /dev/null +++ b/patches/@vueuse+core+12.8.2.patch @@ -0,0 +1,34 @@ +diff --git a/node_modules/@vueuse/core/index.d.mts b/node_modules/@vueuse/core/index.d.mts +index d7817ae..a22a85c 100644 +--- a/node_modules/@vueuse/core/index.d.mts ++++ b/node_modules/@vueuse/core/index.d.mts +@@ -624,7 +624,7 @@ interface UseBluetoothRequestDeviceOptions { + * of BluetoothServiceUUIDs, a name parameter, and a namePrefix parameter. + * + */ +- filters?: BluetoothLEScanFilter[] | undefined; ++ filters?: any; + /** + * + * An array of BluetoothServiceUUIDs. +@@ -632,7 +632,7 @@ interface UseBluetoothRequestDeviceOptions { + * @see https://developer.mozilla.org/en-US/docs/Web/API/BluetoothRemoteGATTService/uuid + * + */ +- optionalServices?: BluetoothServiceUUID[] | undefined; ++ optionalServices?: any; + } + interface UseBluetoothOptions extends UseBluetoothRequestDeviceOptions, ConfigurableNavigator { + /** +@@ -655,9 +655,9 @@ declare function useBluetooth(options?: UseBluetoothOptions): UseBluetoothReturn + interface UseBluetoothReturn { + isSupported: ComputedRef; + isConnected: Readonly>; +- device: ShallowRef; ++ device: ShallowRef; + requestDevice: () => Promise; +- server: ShallowRef; ++ server: ShallowRef; + error: ShallowRef; + } + diff --git a/patches/vitepress+1.6.4.patch b/patches/vitepress+1.6.4.patch new file mode 100644 index 00000000000..8e64eef5065 --- /dev/null +++ b/patches/vitepress+1.6.4.patch @@ -0,0 +1,12 @@ +diff --git a/node_modules/vitepress/dist/node/index.d.ts b/node_modules/vitepress/dist/node/index.d.ts +index 03aef89..c8103db 100644 +--- a/node_modules/vitepress/dist/node/index.d.ts ++++ b/node_modules/vitepress/dist/node/index.d.ts +@@ -1950,7 +1950,6 @@ interface TocPluginOptions { + } + + declare namespace anchor { +- export type Token = Token + export type State = StateCore + export type RenderHref = (slug: string, state: State) => string; + export type RenderAttrs = (slug: string, state: State) => Record; diff --git a/renovate.json b/renovate.json new file mode 100644 index 00000000000..2f564bd38a5 --- /dev/null +++ b/renovate.json @@ -0,0 +1,61 @@ +{ + "$schema": "https://docs.renovatebot.com/renovate-schema.json", + "extends": [ + "config:recommended" + ], + "dependencyDashboard": true, + "configMigration": true, + "rangeStrategy": "bump", + "prHourlyLimit": 0, + "packageRules": [ + { + "matchUpdateTypes": [ + "minor", + "patch", + "lockFileMaintenance", + "pin" + ], + "groupName": "minor/patch updates", + "automerge": true, + "automergeType": "pr", + "platformAutomerge": true + }, + { + "matchPackageNames": [ + "node", + "npm", + "fsevents", + "core-js", + "@napi-rs/cli" + ], + "enabled": false + }, + { + "matchPackageNames": [ + "@types/node", + "yargs-parser", + "@inquirer/prompts" + ], + "matchUpdateTypes": [ + "major" + ], + "enabled": false + } + ], + "pinDigests": true, + "automerge": false, + "internalChecksFilter": "strict", + "lockFileMaintenance": { + "enabled": true, + "schedule": [ + "* 18-23 * * 4", + "* 0-5 * * 5" + ] + }, + "minimumReleaseAge": "3 days", + "schedule": [ + "* 18-23 * * 4", + "* 0-5 * * 5" + ], + "automergeStrategy": "squash" +} diff --git a/rollup.config.js b/rollup.config.js deleted file mode 100644 index 4dddad1bb99..00000000000 --- a/rollup.config.js +++ /dev/null @@ -1,165 +0,0 @@ -import alias from '@rollup/plugin-alias'; -import commonjs from '@rollup/plugin-commonjs'; -import json from '@rollup/plugin-json'; -import resolve from '@rollup/plugin-node-resolve'; -import fs from 'fs'; -import path from 'path'; -import { string } from 'rollup-plugin-string'; -import { terser } from 'rollup-plugin-terser'; -import typescript from 'rollup-plugin-typescript'; -import addCliEntry from './build-plugins/add-cli-entry.js'; -import conditionalFsEventsImport from './build-plugins/conditional-fsevents-import'; -import emitModulePackageFile from './build-plugins/emit-module-package-file.js'; -import esmDynamicImport from './build-plugins/esm-dynamic-import.js'; -import getLicenseHandler from './build-plugins/generate-license-file'; -import replaceBrowserModules from './build-plugins/replace-browser-modules.js'; -import pkg from './package.json'; - -const commitHash = (function () { - try { - return fs.readFileSync('.commithash', 'utf-8'); - } catch (err) { - return 'unknown'; - } -})(); - -const now = new Date( - process.env.SOURCE_DATE_EPOCH ? process.env.SOURCE_DATE_EPOCH * 1000 : new Date().getTime() -).toUTCString(); - -const banner = `/* - @license - Rollup.js v${pkg.version} - ${now} - commit ${commitHash} - - https://github.com/rollup/rollup - - Released under the MIT License. -*/`; - -const onwarn = warning => { - // eslint-disable-next-line no-console - console.error( - 'Building Rollup produced warnings that need to be resolved. ' + - 'Please keep in mind that the browser build may never have external dependencies!' - ); - throw new Error(warning.message); -}; - -const moduleAliases = { - resolve: ['.js', '.json', '.md'], - entries: [ - { find: 'help.md', replacement: path.resolve('cli/help.md') }, - { find: 'package.json', replacement: path.resolve('package.json') }, - { find: 'acorn', replacement: path.resolve('node_modules/acorn/dist/acorn.mjs') } - ] -}; - -const treeshake = { - moduleSideEffects: false, - propertyReadSideEffects: false, - tryCatchDeoptimization: false -}; - -const nodePlugins = [ - alias(moduleAliases), - resolve(), - json(), - conditionalFsEventsImport(), - string({ include: '**/*.md' }), - commonjs({ include: 'node_modules/**' }), - typescript() -]; - -export default command => { - const { collectLicenses, writeLicense } = getLicenseHandler(); - const commonJSBuild = { - input: { - 'rollup.js': 'src/node-entry.ts', - 'loadConfigFile.js': 'cli/run/loadConfigFile.ts' - }, - onwarn, - plugins: [ - ...nodePlugins, - addCliEntry(), - esmDynamicImport(), - !command.configTest && collectLicenses() - ], - // fsevents is a dependency of chokidar that cannot be bundled as it contains binary code - external: [ - 'assert', - 'crypto', - 'events', - 'fs', - 'fsevents', - 'module', - 'path', - 'os', - 'stream', - 'url', - 'util' - ], - treeshake, - strictDeprecations: true, - output: { - banner, - chunkFileNames: 'shared/[name].js', - dir: 'dist', - entryFileNames: '[name]', - // TODO Only loadConfigFile is using default exports mode; this should be changed in Rollup@3 - exports: 'auto', - externalLiveBindings: false, - format: 'cjs', - freeze: false, - interop: id => { - if (id === 'fsevents') { - return 'defaultOnly'; - } - return 'default'; - }, - manualChunks: { rollup: ['src/node-entry.ts'] }, - sourcemap: true - } - }; - - if (command.configTest) { - return commonJSBuild; - } - - const esmBuild = { - ...commonJSBuild, - input: { 'rollup.js': 'src/node-entry.ts' }, - plugins: [...nodePlugins, emitModulePackageFile(), collectLicenses()], - output: { - ...commonJSBuild.output, - dir: 'dist/es', - format: 'es', - sourcemap: false, - minifyInternalExports: false - } - }; - - const browserBuilds = { - input: 'src/browser-entry.ts', - onwarn, - plugins: [ - replaceBrowserModules(), - alias(moduleAliases), - resolve({ browser: true }), - json(), - commonjs(), - typescript(), - terser({ module: true, output: { comments: 'some' } }), - collectLicenses(), - writeLicense() - ], - treeshake, - strictDeprecations: true, - output: [ - { file: 'dist/rollup.browser.js', format: 'umd', name: 'rollup', banner, sourcemap: true }, - { file: 'dist/es/rollup.browser.js', format: 'es', banner } - ] - }; - - return [commonJSBuild, esmBuild, browserBuilds]; -}; diff --git a/rollup.config.ts b/rollup.config.ts new file mode 100644 index 00000000000..360377fab65 --- /dev/null +++ b/rollup.config.ts @@ -0,0 +1,163 @@ +import alias from '@rollup/plugin-alias'; +import commonjs from '@rollup/plugin-commonjs'; +import json from '@rollup/plugin-json'; +import { nodeResolve } from '@rollup/plugin-node-resolve'; +import replace from '@rollup/plugin-replace'; +import terser from '@rollup/plugin-terser'; +import typescript from '@rollup/plugin-typescript'; +import { fileURLToPath } from 'node:url'; +import type { Plugin, RollupOptions, WarningHandlerWithDefault } from 'rollup'; +import addCliEntry from './build-plugins/add-cli-entry'; +import { moduleAliases } from './build-plugins/aliases'; +import cleanBeforeWrite from './build-plugins/clean-before-write'; +import { copyBrowserTypes, copyNodeTypes } from './build-plugins/copy-types'; +import emitModulePackageFile from './build-plugins/emit-module-package-file'; +import { emitNativeEntry } from './build-plugins/emit-native-entry'; +import emitWasmFile from './build-plugins/emit-wasm-file'; +import esmDynamicImport from './build-plugins/esm-dynamic-import'; +import { externalNativeImport } from './build-plugins/external-native-import'; +import { fsEventsReplacement } from './build-plugins/fs-events-replacement'; +import getLicenseHandler from './build-plugins/generate-license-file'; +import getBanner from './build-plugins/get-banner'; +import loadCliHelp from './build-plugins/load-cli-help'; +import replaceBrowserModules from './build-plugins/replace-browser-modules'; +import './typings/declarations'; + +const onwarn: WarningHandlerWithDefault = warning => { + console.error( + 'Building Rollup produced warnings that need to be resolved. ' + + 'Please keep in mind that the browser build may never have external dependencies!' + ); + + throw Object.assign(new Error(), warning); +}; + +const treeshake = { + moduleSideEffects: false, + propertyReadSideEffects: false, + tryCatchDeoptimization: false +}; + +const nodePlugins: readonly Plugin[] = [ + replace(fsEventsReplacement), + alias(moduleAliases), + nodeResolve({ preferBuiltins: true }), + json(), + loadCliHelp(), + commonjs({ + ignoreTryCatch: false, + include: 'node_modules/**' + }), + typescript(), + cleanBeforeWrite('dist'), + externalNativeImport() +]; + +export default async function getConfig( + command: Record +): Promise { + const { collectLicenses, writeLicense } = getLicenseHandler( + fileURLToPath(new URL('.', import.meta.url)) + ); + + const commonJSBuild: RollupOptions = { + // 'fsevents' is a dependency of 'chokidar' that cannot be bundled as it contains binary code + external: ['fsevents'], + input: { + 'getLogFilter.js': 'src/utils/getLogFilter.ts', + 'loadConfigFile.js': 'cli/run/loadConfigFile.ts', + 'parseAst.js': 'src/utils/parseAst.ts', + 'rollup.js': 'src/node-entry.ts' + }, + onwarn, + output: { + banner: getBanner, + chunkFileNames: 'shared/[name].js', + dir: 'dist', + entryFileNames: '[name]', + exports: 'named', + externalLiveBindings: false, + format: 'cjs', + freeze: false, + generatedCode: 'es2015', + interop: 'default', + sourcemap: true + }, + plugins: [ + ...nodePlugins, + emitNativeEntry(), + addCliEntry(), + esmDynamicImport(), + !command.configTest && collectLicenses(), + copyNodeTypes() + ], + strictDeprecations: true, + treeshake + }; + + if (command.configTest) { + return commonJSBuild; + } + + const esmBuild: RollupOptions = { + ...commonJSBuild, + input: { + 'getLogFilter.js': 'src/utils/getLogFilter.ts', + 'parseAst.js': 'src/utils/parseAst.ts', + 'rollup.js': 'src/node-entry.ts' + }, + output: { + ...commonJSBuild.output, + dir: 'dist/es', + format: 'es', + minifyInternalExports: false, + sourcemap: false + }, + plugins: [...nodePlugins, emitModulePackageFile(), collectLicenses(), writeLicense()] + }; + + if (command.configIsBuildNode) { + return [commonJSBuild, esmBuild]; + } + + const { collectLicenses: collectLicensesBrowser, writeLicense: writeLicenseBrowser } = + getLicenseHandler(fileURLToPath(new URL('browser', import.meta.url))); + + const browserBuilds: RollupOptions = { + input: 'src/browser-entry.ts', + onwarn, + output: [ + { + banner: getBanner, + file: 'browser/dist/rollup.browser.js', + format: 'umd', + name: 'rollup', + plugins: [copyBrowserTypes()], + sourcemap: true + }, + { + banner: getBanner, + file: 'browser/dist/es/rollup.browser.js', + format: 'es', + plugins: [emitModulePackageFile()] + } + ], + plugins: [ + replaceBrowserModules(), + alias(moduleAliases), + nodeResolve({ browser: true }), + json(), + commonjs(), + typescript(), + terser({ module: true, output: { comments: 'some' } }), + collectLicensesBrowser(), + writeLicenseBrowser(), + cleanBeforeWrite('browser/dist'), + emitWasmFile() + ], + strictDeprecations: true, + treeshake + }; + + return [commonJSBuild, esmBuild, browserBuilds]; +} diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 00000000000..34aeaf8a1a9 --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,4 @@ +[toolchain] +profile = "default" +channel = "nightly-2025-07-25" +components = ["rust-src"] diff --git a/rust/Cargo.lock b/rust/Cargo.lock new file mode 100644 index 00000000000..aea3204b241 --- /dev/null +++ b/rust/Cargo.lock @@ -0,0 +1,2043 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "ahash" +version = "0.8.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a15f179cd60c4584b8a8c596927aadc462e27f2ca70c04e0071964a73ba7a75" +dependencies = [ + "cfg-if", + "once_cell", + "version_check", + "zerocopy", +] + +[[package]] +name = "aho-corasick" +version = "1.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddd31a130427c27518df266943a5308ed92d4b226cc639f5a8f1002816174301" +dependencies = [ + "memchr", +] + +[[package]] +name = "allocator-api2" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" + +[[package]] +name = "anyhow" +version = "1.0.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a23eb6b1614318a8071c9b2521f36b424b2c83db5eb3a0fead4a6c0809af6e61" + +[[package]] +name = "ar_archive_writer" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0c269894b6fe5e9d7ada0cf69b5bf847ff35bc25fc271f08e1d080fce80339a" +dependencies = [ + "object", +] + +[[package]] +name = "arrayvec" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" + +[[package]] +name = "ascii" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d92bec98840b8f03a5ff5413de5293bfcd8bf96467cf5452609f939ec6f5de16" + +[[package]] +name = "ast_node" +version = "5.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2eb025ef00a6da925cf40870b9c8d008526b6004ece399cb0974209720f0b194" +dependencies = [ + "quote", + "swc_macros_common", + "syn", +] + +[[package]] +name = "autocfg" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" + +[[package]] +name = "base-encode" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a17bd29f7c70f32e9387f4d4acfa5ea7b7749ef784fb78cf382df97069337b8c" + +[[package]] +name = "base64" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" + +[[package]] +name = "base64-simd" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "339abbe78e73178762e23bea9dfd08e697eb3f3301cd4be981c0f78ba5859195" +dependencies = [ + "outref", + "vsimd", +] + +[[package]] +name = "better_scoped_tls" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7cd228125315b132eed175bf47619ac79b945b26e56b848ba203ae4ea8603609" +dependencies = [ + "scoped-tls", +] + +[[package]] +name = "bindings_napi" +version = "0.0.0" +dependencies = [ + "mimalloc-safe", + "napi", + "napi-build", + "napi-derive", + "parse_ast", + "xxhash", +] + +[[package]] +name = "bindings_wasm" +version = "0.0.0" +dependencies = [ + "console_error_panic_hook", + "js-sys", + "parse_ast", + "wasm-bindgen", + "xxhash", +] + +[[package]] +name = "bitflags" +version = "2.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "812e12b5285cc515a9c72a5c1d3b6d46a19dac5acfef5265968c166106e31dd3" + +[[package]] +name = "bitvec" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" +dependencies = [ + "funty", + "radium", + "tap", + "wyz", +] + +[[package]] +name = "bstr" +version = "1.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63044e1ae8e69f3b5a92c736ca6269b8d12fa7efe39bf34ddb06d102cf0e2cab" +dependencies = [ + "memchr", + "serde", +] + +[[package]] +name = "bumpalo" +version = "3.19.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5dd9dc738b7a8311c7ade152424974d8115f2cdad61e8dab8dac9f2362298510" +dependencies = [ + "allocator-api2", +] + +[[package]] +name = "bytes" +version = "1.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b35204fbdc0b3f4446b89fc1ac2cf84a8a68971995d0bf2e925ec7cd960f9cb3" + +[[package]] +name = "bytes-str" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c60b5ce37e0b883c37eb89f79a1e26fbe9c1081945d024eee93e8d91a7e18b3" +dependencies = [ + "bytes", + "serde", +] + +[[package]] +name = "castaway" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dec551ab6e7578819132c713a93c022a05d60159dc86e7a7050223577484c55a" +dependencies = [ + "rustversion", +] + +[[package]] +name = "cc" +version = "1.2.52" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd4932aefd12402b36c60956a4fe0035421f544799057659ff86f923657aada3" +dependencies = [ + "find-msvc-tools", + "shlex", +] + +[[package]] +name = "cfg-if" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" + +[[package]] +name = "cmake" +version = "0.1.57" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75443c44cd6b379beb8c5b45d85d0773baf31cce901fe7bb252f4eff3008ef7d" +dependencies = [ + "cc", +] + +[[package]] +name = "compact_str" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f86b9c4c00838774a6d902ef931eff7470720c51d90c2e32cfe15dc304737b3f" +dependencies = [ + "castaway", + "cfg-if", + "itoa", + "ryu", + "static_assertions", +] + +[[package]] +name = "console_error_panic_hook" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a06aeb73f470f66dcdbf7223caeebb85984942f22f1adb2a088cf9668146bbbc" +dependencies = [ + "cfg-if", + "wasm-bindgen", +] + +[[package]] +name = "convert_case" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "633458d4ef8c78b72454de2d54fd6ab2e60f9e02be22f3c6104cdc8a4e0fceb9" +dependencies = [ + "unicode-segmentation", +] + +[[package]] +name = "ctor" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "424e0138278faeb2b401f174ad17e715c829512d74f3d1e81eb43365c2e0590e" +dependencies = [ + "ctor-proc-macro", + "dtor", +] + +[[package]] +name = "ctor-proc-macro" +version = "0.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52560adf09603e58c9a7ee1fe1dcb95a16927b17c127f0ac02d6e768a0e25bc1" + +[[package]] +name = "dashmap" +version = "5.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "978747c1d849a7d2ee5e8adc0159961c48fb7e5db2f06af6723b80123bb53856" +dependencies = [ + "cfg-if", + "hashbrown 0.14.5", + "lock_api", + "once_cell", + "parking_lot_core", +] + +[[package]] +name = "data-encoding" +version = "2.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7a1e2f27636f116493b8b860f5546edb47c8d8f8ea73e1d2a20be88e28d1fea" + +[[package]] +name = "debugid" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef552e6f588e446098f6ba40d89ac146c8c7b64aade83c051ee00bb5d2bc18d" +dependencies = [ + "serde", + "uuid", +] + +[[package]] +name = "displaydoc" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "dtor" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "404d02eeb088a82cfd873006cb713fe411306c7d182c344905e101fb1167d301" +dependencies = [ + "dtor-proc-macro", +] + +[[package]] +name = "dtor-proc-macro" +version = "0.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f678cf4a922c215c63e0de95eb1ff08a958a81d47e485cf9da1e27bf6305cfa5" + +[[package]] +name = "either" +version = "1.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" + +[[package]] +name = "equivalent" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" + +[[package]] +name = "find-msvc-tools" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f449e6c6c08c865631d4890cfacf252b3d396c9bcc83adb6623cdb02a8336c41" + +[[package]] +name = "fixedbitset" +version = "0.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d674e81391d1e1ab681a28d99df07927c6d4aa5b027d7da16ba32d1d21ecd99" + +[[package]] +name = "foldhash" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb" + +[[package]] +name = "form_urlencoded" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb4cb245038516f5f85277875cdaa4f7d2c9a0fa0468de06ed190163b1581fcf" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "from_variant" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5ff35a391aef949120a0340d690269b3d9f63460a6106e99bd07b961f345ea9" +dependencies = [ + "swc_macros_common", + "syn", +] + +[[package]] +name = "funty" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" + +[[package]] +name = "futures" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65bc07b1a8bc7c85c5f2e110c476c7389b4554ba72af57d8445ea63a576b0876" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-channel" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" + +[[package]] +name = "futures-executor" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e28d1d997f585e54aebc3f97d39e72338912123a67330d723fdbb564d646c9f" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-io" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6" + +[[package]] +name = "futures-macro" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "futures-sink" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e575fab7d1e0dcb8d0c7bcf9a63ee213816ab51902e6d244a95819acacf1d4f7" + +[[package]] +name = "futures-task" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f90f7dce0722e95104fcb095585910c0977252f286e354b5e3bd38902cd99988" + +[[package]] +name = "futures-util" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" +dependencies = [ + "futures-channel", + "futures-core", + "futures-io", + "futures-macro", + "futures-sink", + "futures-task", + "memchr", + "pin-project-lite", + "pin-utils", + "slab", +] + +[[package]] +name = "globset" +version = "0.4.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52dfc19153a48bde0cbd630453615c8151bce3a5adfac7a0aebfbf0a1e1f57e3" +dependencies = [ + "aho-corasick", + "bstr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "hashbrown" +version = "0.14.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" +dependencies = [ + "ahash", + "allocator-api2", +] + +[[package]] +name = "hashbrown" +version = "0.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100" +dependencies = [ + "allocator-api2", + "equivalent", + "foldhash", +] + +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + +[[package]] +name = "hermit-abi" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc0fef456e4baa96da950455cd02c081ca953b141298e41db3fc7e36b1da849c" + +[[package]] +name = "hstr" +version = "3.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "faa57007c3c9dab34df2fa4c1fb52fe9c34ec5a27ed9d8edea53254b50cd7887" +dependencies = [ + "hashbrown 0.14.5", + "new_debug_unreachable", + "once_cell", + "rustc-hash", + "serde", + "triomphe", +] + +[[package]] +name = "icu_collections" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c6b649701667bbe825c3b7e6388cb521c23d88644678e83c0c4d0a621a34b43" +dependencies = [ + "displaydoc", + "potential_utf", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_locale_core" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edba7861004dd3714265b4db54a3c390e880ab658fec5f7db895fae2046b5bb6" +dependencies = [ + "displaydoc", + "litemap", + "tinystr", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_normalizer" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f6c8828b67bf8908d82127b2054ea1b4427ff0230ee9141c54251934ab1b599" +dependencies = [ + "icu_collections", + "icu_normalizer_data", + "icu_properties", + "icu_provider", + "smallvec", + "zerovec", +] + +[[package]] +name = "icu_normalizer_data" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7aedcccd01fc5fe81e6b489c15b247b8b0690feb23304303a9e560f37efc560a" + +[[package]] +name = "icu_properties" +version = "2.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "020bfc02fe870ec3a66d93e677ccca0562506e5872c650f893269e08615d74ec" +dependencies = [ + "icu_collections", + "icu_locale_core", + "icu_properties_data", + "icu_provider", + "zerotrie", + "zerovec", +] + +[[package]] +name = "icu_properties_data" +version = "2.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "616c294cf8d725c6afcd8f55abc17c56464ef6211f9ed59cccffe534129c77af" + +[[package]] +name = "icu_provider" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85962cf0ce02e1e0a629cc34e7ca3e373ce20dda4c4d7294bbd0bf1fdb59e614" +dependencies = [ + "displaydoc", + "icu_locale_core", + "writeable", + "yoke", + "zerofrom", + "zerotrie", + "zerovec", +] + +[[package]] +name = "idna" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b0875f23caa03898994f6ddc501886a45c7d3d62d04d2d90788d47be1b1e4de" +dependencies = [ + "idna_adapter", + "smallvec", + "utf8_iter", +] + +[[package]] +name = "idna_adapter" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3acae9609540aa318d1bc588455225fb2085b9ed0c4f6bd0d9d5bcd86f1a0344" +dependencies = [ + "icu_normalizer", + "icu_properties", +] + +[[package]] +name = "if_chain" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd62e6b5e86ea8eeeb8db1de02880a6abc01a397b2ebb64b5d74ac255318f5cb" + +[[package]] +name = "indexmap" +version = "2.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7714e70437a7dc3ac8eb7e6f8df75fd8eb422675fc7678aff7364301092b1017" +dependencies = [ + "equivalent", + "hashbrown 0.16.1", +] + +[[package]] +name = "is-macro" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d57a3e447e24c22647738e4607f1df1e0ec6f72e16182c4cd199f647cdfb0e4" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "itoa" +version = "1.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92ecc6618181def0457392ccd0ee51198e065e016d1d527a7ac1b6dc7c1f09d2" + +[[package]] +name = "js-sys" +version = "0.3.85" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c942ebf8e95485ca0d52d97da7c5a2c387d0e7f0ba4c35e93bfcaee045955b3" +dependencies = [ + "once_cell", + "wasm-bindgen", +] + +[[package]] +name = "libc" +version = "0.2.180" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bcc35a38544a891a5f7c865aca548a982ccb3b8650a5b06d0fd33a10283c56fc" + +[[package]] +name = "libloading" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "754ca22de805bb5744484a5b151a9e1a8e837d5dc232c2d7d8c2e3492edc8b60" +dependencies = [ + "cfg-if", + "windows-link", +] + +[[package]] +name = "libmimalloc-sys2" +version = "0.1.52" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "485536c42886efc110f22bd03c543604e1a3ef7ffe13a29f114b2ed36d62afe3" +dependencies = [ + "cc", + "cmake", + "libc", +] + +[[package]] +name = "litemap" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6373607a59f0be73a39b6fe456b8192fcc3585f602af20751600e974dd455e77" + +[[package]] +name = "lock_api" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "224399e74b87b5f3557511d98dff8b14089b3dadafcab6bb93eab67d3aace965" +dependencies = [ + "scopeguard", +] + +[[package]] +name = "memchr" +version = "2.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f52b00d39961fc5b2736ea853c9cc86238e165017a493d1d5c8eac6bdc4cc273" + +[[package]] +name = "mimalloc-safe" +version = "0.1.56" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a022c8c9ec9504034b60dd4cf12914cc348a19765dfdde50c1c1cc04961eb28" +dependencies = [ + "libmimalloc-sys2", +] + +[[package]] +name = "napi" +version = "3.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "909805cbad4d569e69b80e101290fe72e92b9742ba9e333b0c1e83b22fb7447b" +dependencies = [ + "bitflags", + "ctor", + "futures", + "napi-build", + "napi-sys", + "nohash-hasher", + "rustc-hash", +] + +[[package]] +name = "napi-build" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d376940fd5b723c6893cd1ee3f33abbfd86acb1cd1ec079f3ab04a2a3bc4d3b1" + +[[package]] +name = "napi-derive" +version = "3.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04ba21bbdf40b33496b4ee6eadfc64d17a6a6cde57cd31549117b0882d1fef86" +dependencies = [ + "convert_case", + "ctor", + "napi-derive-backend", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "napi-derive-backend" +version = "5.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9a63791e230572c3218a7acd86ca0a0529fc64294bcbea567cf906d7b04e077" +dependencies = [ + "convert_case", + "proc-macro2", + "quote", + "semver", + "syn", +] + +[[package]] +name = "napi-sys" +version = "3.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8eb602b84d7c1edae45e50bbf1374696548f36ae179dfa667f577e384bb90c2b" +dependencies = [ + "libloading", +] + +[[package]] +name = "new_debug_unreachable" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "650eef8c711430f1a879fdd01d4745a7deea475becfb90269c06775983bbf086" + +[[package]] +name = "nohash-hasher" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bf50223579dc7cdcfb3bfcacf7069ff68243f8c363f62ffa99cf000a6b9c451" + +[[package]] +name = "num-bigint" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9" +dependencies = [ + "num-integer", + "num-traits", + "serde", +] + +[[package]] +name = "num-integer" +version = "0.1.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" +dependencies = [ + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + +[[package]] +name = "num_cpus" +version = "1.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91df4bbde75afed763b708b7eee1e8e7651e02d97f6d5dd763e89367e957b23b" +dependencies = [ + "hermit-abi", + "libc", +] + +[[package]] +name = "object" +version = "0.32.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441" +dependencies = [ + "memchr", +] + +[[package]] +name = "once_cell" +version = "1.21.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" + +[[package]] +name = "outref" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a80800c0488c3a21695ea981a54918fbb37abf04f4d0720c453632255e2ff0e" + +[[package]] +name = "par-core" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e96cbd21255b7fb29a5d51ef38a779b517a91abd59e2756c039583f43ef4c90f" +dependencies = [ + "once_cell", +] + +[[package]] +name = "par-iter" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3eae0176a010bb94b9a67f0eb9da0fd31410817d58850649c54f485124c9a71a" +dependencies = [ + "either", + "par-core", +] + +[[package]] +name = "parking_lot" +version = "0.12.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93857453250e3077bd71ff98b6a65ea6621a19bb0f559a85248955ac12c45a1a" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2621685985a2ebf1c516881c026032ac7deafcda1a2c9b7850dc81e3dfcb64c1" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-link", +] + +[[package]] +name = "parse_ast" +version = "0.0.0" +dependencies = [ + "anyhow", + "parking_lot", + "swc_atoms", + "swc_common", + "swc_compiler_base", + "swc_config", + "swc_ecma_ast", + "swc_ecma_parser", +] + +[[package]] +name = "pathdiff" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df94ce210e5bc13cb6651479fa48d14f601d9858cfe0467f43ae157023b938d3" + +[[package]] +name = "percent-encoding" +version = "2.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" + +[[package]] +name = "petgraph" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3672b37090dbd86368a4145bc067582552b29c27377cad4e0a306c97f9bd7772" +dependencies = [ + "fixedbitset", + "indexmap", +] + +[[package]] +name = "phf" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd6780a80ae0c52cc120a26a1a42c1ae51b247a253e4e06113d23d2c2edd078" +dependencies = [ + "phf_macros", + "phf_shared", +] + +[[package]] +name = "phf_generator" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c80231409c20246a13fddb31776fb942c38553c51e871f8cbd687a4cfb5843d" +dependencies = [ + "phf_shared", + "rand", +] + +[[package]] +name = "phf_macros" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f84ac04429c13a7ff43785d75ad27569f2951ce0ffd30a3321230db2fc727216" +dependencies = [ + "phf_generator", + "phf_shared", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "phf_shared" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67eabc2ef2a60eb7faa00097bd1ffdb5bd28e62bf39990626a582201b7a754e5" +dependencies = [ + "siphasher 1.0.1", +] + +[[package]] +name = "pin-project-lite" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "potential_utf" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b73949432f5e2a09657003c25bca5e19a0e9c84f8058ca374f49e0ebe605af77" +dependencies = [ + "zerovec", +] + +[[package]] +name = "proc-macro2" +version = "1.0.105" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "535d180e0ecab6268a3e718bb9fd44db66bbbc256257165fc699dadf70d16fe7" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "psm" +version = "0.1.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d11f2fedc3b7dafdc2851bc52f277377c5473d378859be234bc7ebb593144d01" +dependencies = [ + "ar_archive_writer", + "cc", +] + +[[package]] +name = "quote" +version = "1.0.43" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc74d9a594b72ae6656596548f56f667211f8a97b3d4c3d467150794690dc40a" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "radium" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" + +[[package]] +name = "radix_fmt" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce082a9940a7ace2ad4a8b7d0b1eac6aa378895f18be598230c5f2284ac05426" + +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" + +[[package]] +name = "redox_syscall" +version = "0.5.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d" +dependencies = [ + "bitflags", +] + +[[package]] +name = "regex" +version = "1.12.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "843bc0191f75f3e22651ae5f1e72939ab2f72a4bc30fa80a066bd66edefc24d4" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5276caf25ac86c8d810222b3dbb938e512c55c6831a10f3e6ed1c93b84041f1c" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a2d987857b319362043e95f5353c0535c1f58eec5336fdfcf626430af7def58" + +[[package]] +name = "regress" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2057b2325e68a893284d1538021ab90279adac1139957ca2a74426c6f118fb48" +dependencies = [ + "hashbrown 0.16.1", + "memchr", +] + +[[package]] +name = "rustc-hash" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "357703d41365b4b27c590e3ed91eabb1b663f07c4c084095e60cbed4362dff0d" + +[[package]] +name = "rustversion" +version = "1.0.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d" + +[[package]] +name = "ryu" +version = "1.0.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a50f4cf475b65d88e057964e0e9bb1f0aa9bbb2036dc65c64596b42932536984" + +[[package]] +name = "ryu-js" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd29631678d6fb0903b69223673e122c32e9ae559d0960a38d574695ebc0ea15" + +[[package]] +name = "scoped-tls" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294" + +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "semver" +version = "1.0.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d767eb0aabc880b29956c35734170f26ed551a859dbd361d140cdbeca61ab1e2" + +[[package]] +name = "seq-macro" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bc711410fbe7399f390ca1c3b60ad0f53f80e95c5eb935e52268a0e2cd49acc" + +[[package]] +name = "serde" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e" +dependencies = [ + "serde_core", + "serde_derive", +] + +[[package]] +name = "serde_core" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.149" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83fc039473c5595ace860d8c4fafa220ff474b3fc6bfdb4293327f1a37e94d86" +dependencies = [ + "itoa", + "memchr", + "serde", + "serde_core", + "zmij", +] + +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + +[[package]] +name = "siphasher" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d" + +[[package]] +name = "siphasher" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56199f7ddabf13fe5074ce809e7d3f42b42ae711800501b5b16ea82ad029c39d" + +[[package]] +name = "slab" +version = "0.4.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a2ae44ef20feb57a68b23d846850f861394c2e02dc425a50098ae8c90267589" + +[[package]] +name = "smallvec" +version = "1.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" + +[[package]] +name = "smartstring" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fb72c633efbaa2dd666986505016c32c3044395ceaf881518399d2f4127ee29" +dependencies = [ + "autocfg", + "static_assertions", + "version_check", +] + +[[package]] +name = "stable_deref_trait" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" + +[[package]] +name = "stacker" +version = "0.1.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1f8b29fb42aafcea4edeeb6b2f2d7ecd0d969c48b4cf0d2e64aafc471dd6e59" +dependencies = [ + "cc", + "cfg-if", + "libc", + "psm", + "windows-sys", +] + +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + +[[package]] +name = "string_enum" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae36a4951ca7bd1cfd991c241584a9824a70f6aff1e7d4f693fb3f2465e4030e" +dependencies = [ + "quote", + "swc_macros_common", + "syn", +] + +[[package]] +name = "swc_allocator" +version = "4.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d7eefd2c8b228a8c73056482b2ae4b3a1071fbe07638e3b55ceca8570cc48bb" +dependencies = [ + "allocator-api2", + "bumpalo", + "hashbrown 0.14.5", + "rustc-hash", +] + +[[package]] +name = "swc_atoms" +version = "9.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4ccbe2ecad10ad7432100f878a107b1d972a8aee83ca53184d00c23a078bb8a" +dependencies = [ + "hstr", + "once_cell", + "serde", +] + +[[package]] +name = "swc_common" +version = "18.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1c06698254e9b47daaf9bbb062af489a350bd8d10dfaab0cabbd32d46cec69d" +dependencies = [ + "anyhow", + "ast_node", + "better_scoped_tls", + "bytes-str", + "either", + "from_variant", + "num-bigint", + "once_cell", + "parking_lot", + "rustc-hash", + "serde", + "siphasher 0.3.11", + "swc_atoms", + "swc_eq_ignore_macros", + "swc_sourcemap", + "swc_visit", + "tracing", + "unicode-width", + "url", +] + +[[package]] +name = "swc_compiler_base" +version = "45.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05764fac0b452c050eec49135de597223166590b9992ce9096628db06fce5ae3" +dependencies = [ + "anyhow", + "base64", + "bytes-str", + "once_cell", + "pathdiff", + "rustc-hash", + "serde", + "serde_json", + "swc_atoms", + "swc_common", + "swc_config", + "swc_ecma_ast", + "swc_ecma_codegen", + "swc_ecma_minifier", + "swc_ecma_parser", + "swc_ecma_visit", + "swc_sourcemap", + "swc_timer", +] + +[[package]] +name = "swc_config" +version = "3.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72e90b52ee734ded867104612218101722ad87ff4cf74fe30383bd244a533f97" +dependencies = [ + "anyhow", + "bytes-str", + "dashmap", + "globset", + "indexmap", + "once_cell", + "regex", + "regress", + "rustc-hash", + "serde", + "serde_json", + "swc_config_macro", + "swc_sourcemap", +] + +[[package]] +name = "swc_config_macro" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b416e8ce6de17dc5ea496e10c7012b35bbc0e3fef38d2e065eed936490db0b3" +dependencies = [ + "proc-macro2", + "quote", + "swc_macros_common", + "syn", +] + +[[package]] +name = "swc_ecma_ast" +version = "19.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "724195600825cbdd2a899d5473d2ce1f24ae418bff1231f160ecf38a3bc81f46" +dependencies = [ + "bitflags", + "is-macro", + "num-bigint", + "once_cell", + "phf", + "rustc-hash", + "serde", + "string_enum", + "swc_atoms", + "swc_common", + "swc_visit", + "unicode-id-start", +] + +[[package]] +name = "swc_ecma_codegen" +version = "21.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c77d9d21345ca986ae3b5ff1a4fa3607b15b07ed397506e6dba32e867cf40fd" +dependencies = [ + "ascii", + "compact_str", + "memchr", + "num-bigint", + "once_cell", + "regex", + "rustc-hash", + "ryu-js", + "serde", + "swc_allocator", + "swc_atoms", + "swc_common", + "swc_ecma_ast", + "swc_ecma_codegen_macros", + "swc_sourcemap", + "tracing", +] + +[[package]] +name = "swc_ecma_codegen_macros" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e276dc62c0a2625a560397827989c82a93fd545fcf6f7faec0935a82cc4ddbb8" +dependencies = [ + "proc-macro2", + "swc_macros_common", + "syn", +] + +[[package]] +name = "swc_ecma_minifier" +version = "42.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e55ced848cae0fa5e33e465540bbeafd70645f4099b8b9b3ca66e66d95f52300" +dependencies = [ + "arrayvec", + "bitflags", + "indexmap", + "num-bigint", + "num_cpus", + "once_cell", + "par-core", + "par-iter", + "parking_lot", + "phf", + "radix_fmt", + "rustc-hash", + "ryu-js", + "serde", + "serde_json", + "swc_atoms", + "swc_common", + "swc_config", + "swc_ecma_ast", + "swc_ecma_codegen", + "swc_ecma_parser", + "swc_ecma_transforms_base", + "swc_ecma_transforms_optimization", + "swc_ecma_usage_analyzer", + "swc_ecma_utils", + "swc_ecma_visit", + "swc_timer", + "tracing", +] + +[[package]] +name = "swc_ecma_parser" +version = "32.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1d0c36843109fff178bbedc439b4190daa865d78e553134243a4df220329fdd" +dependencies = [ + "bitflags", + "either", + "num-bigint", + "phf", + "rustc-hash", + "seq-macro", + "serde", + "smartstring", + "stacker", + "swc_atoms", + "swc_common", + "swc_ecma_ast", + "tracing", +] + +[[package]] +name = "swc_ecma_transforms_base" +version = "35.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83f9f0dee4466e6eeb7042f2a0fc6c84298dfa914baff5bcfb44beb9f24b215f" +dependencies = [ + "better_scoped_tls", + "indexmap", + "once_cell", + "par-core", + "phf", + "rustc-hash", + "serde", + "swc_atoms", + "swc_common", + "swc_ecma_ast", + "swc_ecma_parser", + "swc_ecma_utils", + "swc_ecma_visit", + "tracing", +] + +[[package]] +name = "swc_ecma_transforms_optimization" +version = "37.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3bc5e01b1e5c696b4784a133a5ee28ca8b309800d858ab63509069df8fe30181" +dependencies = [ + "bytes-str", + "dashmap", + "indexmap", + "once_cell", + "par-core", + "petgraph", + "rustc-hash", + "serde_json", + "swc_atoms", + "swc_common", + "swc_ecma_ast", + "swc_ecma_parser", + "swc_ecma_transforms_base", + "swc_ecma_utils", + "swc_ecma_visit", + "tracing", +] + +[[package]] +name = "swc_ecma_usage_analyzer" +version = "27.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e5215c48b139422dcf54958d746b5e9a7b31bab8fc126f28e4049c4985505d5" +dependencies = [ + "bitflags", + "indexmap", + "rustc-hash", + "swc_atoms", + "swc_common", + "swc_ecma_ast", + "swc_ecma_utils", + "swc_ecma_visit", + "swc_timer", + "tracing", +] + +[[package]] +name = "swc_ecma_utils" +version = "25.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dd5ee449d21110a271e73d0a9f7640a8854a62cb0e2cb0c9db3445383598e21" +dependencies = [ + "indexmap", + "num_cpus", + "once_cell", + "par-core", + "rustc-hash", + "ryu-js", + "swc_atoms", + "swc_common", + "swc_ecma_ast", + "swc_ecma_visit", + "tracing", +] + +[[package]] +name = "swc_ecma_visit" +version = "19.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a69d63f7f704a2ec937edef90a3eba1f64602eceb60c8deb260c01131f680e8b" +dependencies = [ + "new_debug_unreachable", + "num-bigint", + "swc_atoms", + "swc_common", + "swc_ecma_ast", + "swc_visit", + "tracing", +] + +[[package]] +name = "swc_eq_ignore_macros" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c16ce73424a6316e95e09065ba6a207eba7765496fed113702278b7711d4b632" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "swc_macros_common" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aae1efbaa74943dc5ad2a2fb16cbd78b77d7e4d63188f3c5b4df2b4dcd2faaae" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "swc_sourcemap" +version = "9.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de08ef00f816acdd1a58ee8a81c0e1a59eefef2093aefe5611f256fa6b64c4d7" +dependencies = [ + "base64-simd", + "bitvec", + "bytes-str", + "data-encoding", + "debugid", + "if_chain", + "rustc-hash", + "serde", + "serde_json", + "unicode-id-start", + "url", +] + +[[package]] +name = "swc_timer" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4db06b46cc832f7cf83c2ce21905fc465d01443a2bdccf63644383e1f5847532" +dependencies = [ + "tracing", +] + +[[package]] +name = "swc_visit" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62fb71484b486c185e34d2172f0eabe7f4722742aad700f426a494bb2de232a2" +dependencies = [ + "either", + "new_debug_unreachable", +] + +[[package]] +name = "syn" +version = "2.0.114" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4d107df263a3013ef9b1879b0df87d706ff80f65a86ea879bd9c31f9b307c2a" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "synstructure" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tap" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" + +[[package]] +name = "tinystr" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42d3e9c45c09de15d06dd8acf5f4e0e399e85927b7f00711024eb7ae10fa4869" +dependencies = [ + "displaydoc", + "zerovec", +] + +[[package]] +name = "tracing" +version = "0.1.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63e71662fa4b2a2c3a26f570f037eb95bb1f85397f3cd8076caed2f026a6d100" +dependencies = [ + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7490cfa5ec963746568740651ac6781f701c9c5ea257c58e057f3ba8cf69e8da" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tracing-core" +version = "0.1.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db97caf9d906fbde555dd62fa95ddba9eecfd14cb388e4f491a66d74cd5fb79a" +dependencies = [ + "once_cell", +] + +[[package]] +name = "triomphe" +version = "0.1.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd69c5aa8f924c7519d6372789a74eac5b94fb0f8fcf0d4a97eb0bfc3e785f39" +dependencies = [ + "serde", + "stable_deref_trait", +] + +[[package]] +name = "unicode-id-start" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81b79ad29b5e19de4260020f8919b443b2ef0277d242ce532ec7b7a2cc8b6007" + +[[package]] +name = "unicode-ident" +version = "1.0.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9312f7c4f6ff9069b165498234ce8be658059c6728633667c526e27dc2cf1df5" + +[[package]] +name = "unicode-segmentation" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493" + +[[package]] +name = "unicode-width" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4ac048d71ede7ee76d585517add45da530660ef4390e49b098733c6e897f254" + +[[package]] +name = "url" +version = "2.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff67a8a4397373c3ef660812acab3268222035010ab8680ec4215f38ba3d0eed" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", + "serde", +] + +[[package]] +name = "utf8_iter" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" + +[[package]] +name = "uuid" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2e054861b4bd027cd373e18e8d8d8e6548085000e41290d95ce0c373a654b4a" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "version_check" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" + +[[package]] +name = "vsimd" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c3082ca00d5a5ef149bb8b555a72ae84c9c59f7250f013ac822ac2e49b19c64" + +[[package]] +name = "wasm-bindgen" +version = "0.2.108" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64024a30ec1e37399cf85a7ffefebdb72205ca1c972291c51512360d90bd8566" +dependencies = [ + "cfg-if", + "once_cell", + "rustversion", + "wasm-bindgen-macro", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.108" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "008b239d9c740232e71bd39e8ef6429d27097518b6b30bdf9086833bd5b6d608" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.108" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5256bae2d58f54820e6490f9839c49780dff84c65aeab9e772f15d5f0e913a55" +dependencies = [ + "bumpalo", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.108" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f01b580c9ac74c8d8f0c0e4afb04eeef2acf145458e52c03845ee9cd23e3d12" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "windows-link" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" + +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "writeable" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9edde0db4769d2dc68579893f2306b26c6ecfbe0ef499b013d731b7b9247e0b9" + +[[package]] +name = "wyz" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" +dependencies = [ + "tap", +] + +[[package]] +name = "xxhash" +version = "0.0.0" +dependencies = [ + "base-encode", + "xxhash-rust", +] + +[[package]] +name = "xxhash-rust" +version = "0.8.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fdd20c5420375476fbd4394763288da7eb0cc0b8c11deed431a91562af7335d3" + +[[package]] +name = "yoke" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72d6e5c6afb84d73944e5cedb052c4680d5657337201555f9f2a16b7406d4954" +dependencies = [ + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b659052874eb698efe5b9e8cf382204678a0086ebf46982b79d6ca3182927e5d" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] + +[[package]] +name = "zerocopy" +version = "0.8.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "668f5168d10b9ee831de31933dc111a459c97ec93225beb307aed970d1372dfd" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.8.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c7962b26b0a8685668b671ee4b54d007a67d4eaf05fda79ac0ecf41e32270f1" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "zerofrom" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50cc42e0333e05660c3587f3bf9d0478688e15d870fab3346451ce7f8c9fbea5" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d71e5d6e06ab090c67b5e44993ec16b72dcbaabc526db883a360057678b48502" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] + +[[package]] +name = "zerotrie" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a59c17a5562d507e4b54960e8569ebee33bee890c70aa3fe7b97e85a9fd7851" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", +] + +[[package]] +name = "zerovec" +version = "0.11.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c28719294829477f525be0186d13efa9a3c602f7ec202ca9e353d310fb9a002" +dependencies = [ + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eadce39539ca5cb3985590102671f2567e659fca9666581ad3411d59207951f3" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "zmij" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd8f3f50b848df28f887acb68e41201b5aea6bc8a8dacc00fb40635ff9a72fea" diff --git a/rust/Cargo.toml b/rust/Cargo.toml new file mode 100644 index 00000000000..a71ac5aa28c --- /dev/null +++ b/rust/Cargo.toml @@ -0,0 +1,14 @@ +[workspace] +resolver = "2" +members = [ + "bindings_napi", + "bindings_wasm", + "parse_ast", + "xxhash" +] + +[profile.release] +strip = true +lto = true +opt-level = 3 +codegen-units = 1 diff --git a/rust/bindings_napi/.cargo/config.toml b/rust/bindings_napi/.cargo/config.toml new file mode 100644 index 00000000000..802ca66fe55 --- /dev/null +++ b/rust/bindings_napi/.cargo/config.toml @@ -0,0 +1,11 @@ +[build] +rustflags = "-Z location-detail=none" + +[target.loongarch64-unknown-linux-gnu] +linker = "loongarch64-linux-gnu-gcc" + +[target.aarch64-unknown-linux-gnu] +linker = "aarch64-linux-gnu-gcc" + +[target.armv7-unknown-linux-gnueabihf] +linker = "arm-linux-gnueabihf-gcc" diff --git a/rust/bindings_napi/Cargo.toml b/rust/bindings_napi/Cargo.toml new file mode 100644 index 00000000000..44bb221c958 --- /dev/null +++ b/rust/bindings_napi/Cargo.toml @@ -0,0 +1,46 @@ +[package] +name = "bindings_napi" +version = "0.0.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[lib] +crate-type = ["cdylib"] + +[dependencies] +# Default enable napi4 feature, see https://nodejs.org/api/n-api.html#node-api-version-matrix +napi = { version = "3.8.2", default-features = false, features = ["napi4"] } +napi-derive = "3.5.1" +parse_ast = { path = "../parse_ast" } +xxhash = { path = "../xxhash" } + +[target.'cfg(not(any(target_os = "linux", target_os = "freebsd")))'.dependencies] +mimalloc-safe = { version = "0.1.56" } + +# Readable version of the target specifier +# cfg( +# any( +# all( +# target_os = "linux", +# not(target_arch = "loongarch64"), +# not(all(target_arch = "riscv64", target_env = "musl")), +# not(target_env = "ohos") +# ), +# all( +# target_os = "freebsd", +# not(target_arch = "aarch64") +# ) +# ) +# ) +[target.'cfg(any(all(target_os = "linux", not(target_arch = "loongarch64"), not(all(target_arch = "riscv64", target_env = "musl")), not(target_env = "ohos")), all(target_os = "freebsd", not(target_arch = "aarch64"))))'.dependencies] +mimalloc-safe = { version = "0.1.56", features = ["local_dynamic_tls"] } + +# Disable architecture specific optimizations on aarch64 platforms +# Mimalloc assumes `armv8.1-a` is supported, which is not always the case +# Ref: https://github.com/rollup/rollup/issues/6047 +[target.'cfg(all(target_arch = "aarch64", not(target_vendor = "apple")))'.dependencies] +mimalloc-safe = { version = "0.1.56", features = ["no_opt_arch"] } + +[build-dependencies] +napi-build = "2.3.1" diff --git a/rust/bindings_napi/build.rs b/rust/bindings_napi/build.rs new file mode 100644 index 00000000000..1f866b6a3c3 --- /dev/null +++ b/rust/bindings_napi/build.rs @@ -0,0 +1,5 @@ +extern crate napi_build; + +fn main() { + napi_build::setup(); +} diff --git a/rust/bindings_napi/src/lib.rs b/rust/bindings_napi/src/lib.rs new file mode 100644 index 00000000000..101411df0b7 --- /dev/null +++ b/rust/bindings_napi/src/lib.rs @@ -0,0 +1,79 @@ +use napi::{bindgen_prelude::*, ScopedTask}; +use napi_derive::napi; +use parse_ast::parse_ast; + +#[cfg(all( + not(all(target_os = "linux", target_arch = "loongarch64")), + not(all(target_os = "linux", target_arch = "riscv64", target_env = "musl")), + not(all(target_os = "linux", target_env = "ohos")), + not(all(target_os = "freebsd", target_arch = "aarch64")), + not(debug_assertions) +))] +#[global_allocator] +static ALLOC: mimalloc_safe::MiMalloc = mimalloc_safe::MiMalloc; + +pub struct ParseTask { + pub code: String, + pub allow_return_outside_function: bool, + pub jsx: bool, +} + +#[napi] +impl<'task> ScopedTask<'task> for ParseTask { + type Output = Vec; + type JsValue = BufferSlice<'task>; + + fn compute(&mut self) -> Result { + Ok(parse_ast( + self.code.clone(), + self.allow_return_outside_function, + self.jsx, + )) + } + + fn resolve(&mut self, env: &'task Env, output: Self::Output) -> Result { + BufferSlice::from_data(env, output) + } +} + +#[napi] +pub fn parse<'env>( + env: &'env Env, + code: String, + allow_return_outside_function: bool, + jsx: bool, +) -> Result> { + BufferSlice::from_data(env, parse_ast(code, allow_return_outside_function, jsx)) +} + +#[napi] +pub fn parse_async( + code: String, + allow_return_outside_function: bool, + jsx: bool, + signal: Option, +) -> AsyncTask { + AsyncTask::with_optional_signal( + ParseTask { + code, + allow_return_outside_function, + jsx, + }, + signal, + ) +} + +#[napi] +pub fn xxhash_base64_url(input: &[u8]) -> String { + xxhash::xxhash_base64_url(input) +} + +#[napi] +pub fn xxhash_base36(input: &[u8]) -> String { + xxhash::xxhash_base36(input) +} + +#[napi] +pub fn xxhash_base16(input: &[u8]) -> String { + xxhash::xxhash_base16(input) +} diff --git a/rust/bindings_wasm/.cargo/config.toml b/rust/bindings_wasm/.cargo/config.toml new file mode 100644 index 00000000000..edbec3411c5 --- /dev/null +++ b/rust/bindings_wasm/.cargo/config.toml @@ -0,0 +1,6 @@ +[build] +rustflags = "-C opt-level=z -Z location-detail=none" + +[unstable] +build-std = ["std", "core", "alloc", "panic_abort"] +build-std-features = ["panic_immediate_abort", "optimize_for_size"] diff --git a/rust/bindings_wasm/Cargo.toml b/rust/bindings_wasm/Cargo.toml new file mode 100644 index 00000000000..5aebd268cc6 --- /dev/null +++ b/rust/bindings_wasm/Cargo.toml @@ -0,0 +1,28 @@ +[package] +name = "bindings_wasm" +version = "0.0.0" +edition = "2021" + +[dependencies] +wasm-bindgen = "0.2.106" +parse_ast = { path = "../parse_ast" } +xxhash = { path = "../xxhash" } +js-sys = "0.3.83" +console_error_panic_hook = "0.1.7" + +[lib] +crate-type = ["cdylib", "rlib"] + +# Fix for rust 1.87.0, see https://github.com/rustwasm/wasm-pack/issues/1441#issuecomment-2886461752 +# Flags based on https://github.com/WebAssembly/binaryen/wiki/Optimizer-Cookbook +[package.metadata.wasm-pack.profile.release] +wasm-opt = [ + "--enable-bulk-memory", + "--enable-nontrapping-float-to-int", + "--generate-global-effects", + "--merge-similar-functions", + "--flatten", "--rereloop", "-O1", + "--gufa-optimizing", + "--flatten", "--rereloop", + "--converge", "-Os", +] diff --git a/rust/bindings_wasm/src/lib.rs b/rust/bindings_wasm/src/lib.rs new file mode 100644 index 00000000000..fbf83bec832 --- /dev/null +++ b/rust/bindings_wasm/src/lib.rs @@ -0,0 +1,27 @@ +use js_sys::Uint8Array; +use parse_ast::parse_ast; +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +pub fn parse(code: String, allow_return_outside_function: bool, jsx: bool) -> Vec { + console_error_panic_hook::set_once(); + parse_ast(code, allow_return_outside_function, jsx) +} + +#[wasm_bindgen(js_name=xxhashBase64Url)] +pub fn xxhash_base64_url(input: Uint8Array) -> String { + console_error_panic_hook::set_once(); + xxhash::xxhash_base64_url(&input.to_vec()) +} + +#[wasm_bindgen(js_name=xxhashBase36)] +pub fn xxhash_base36(input: Uint8Array) -> String { + console_error_panic_hook::set_once(); + xxhash::xxhash_base36(&input.to_vec()) +} + +#[wasm_bindgen(js_name=xxhashBase16)] +pub fn xxhash_base16(input: Uint8Array) -> String { + console_error_panic_hook::set_once(); + xxhash::xxhash_base16(&input.to_vec()) +} diff --git a/rust/parse_ast/Cargo.toml b/rust/parse_ast/Cargo.toml new file mode 100644 index 00000000000..6a8971e0eda --- /dev/null +++ b/rust/parse_ast/Cargo.toml @@ -0,0 +1,16 @@ +[package] +name = "parse_ast" +version = "0.0.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +anyhow = "1.0.100" +swc_atoms = "9.0.0" +swc_compiler_base = "45.0.0" +swc_config = "3.1.2" +swc_common = { version = "18.0.1", features = ["parking_lot"] } +swc_ecma_ast = "19.0.0" +swc_ecma_parser = "32.0.0" +parking_lot = "0.12.5" diff --git a/rust/parse_ast/src/ast_nodes/array_expression.rs b/rust/parse_ast/src/ast_nodes/array_expression.rs new file mode 100644 index 00000000000..5ed818fb4fd --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/array_expression.rs @@ -0,0 +1,31 @@ +use swc_ecma_ast::ArrayLit; + +use crate::convert_ast::converter::ast_constants::{ + ARRAY_EXPRESSION_ELEMENTS_OFFSET, ARRAY_EXPRESSION_RESERVED_BYTES, TYPE_ARRAY_EXPRESSION, +}; +use crate::convert_ast::converter::AstConverter; + +impl AstConverter<'_> { + pub(crate) fn store_array_expression(&mut self, array_literal: &ArrayLit) { + let end_position = self.add_type_and_start( + &TYPE_ARRAY_EXPRESSION, + &array_literal.span, + ARRAY_EXPRESSION_RESERVED_BYTES, + false, + ); + // elements + self.convert_item_list( + &array_literal.elems, + end_position + ARRAY_EXPRESSION_ELEMENTS_OFFSET, + |ast_converter, element| match element { + Some(element) => { + ast_converter.convert_expression_or_spread(element); + true + } + None => false, + }, + ); + // end + self.add_end(end_position, &array_literal.span); + } +} diff --git a/rust/parse_ast/src/ast_nodes/array_pattern.rs b/rust/parse_ast/src/ast_nodes/array_pattern.rs new file mode 100644 index 00000000000..5f3559e829a --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/array_pattern.rs @@ -0,0 +1,31 @@ +use swc_ecma_ast::ArrayPat; + +use crate::convert_ast::converter::ast_constants::{ + ARRAY_PATTERN_ELEMENTS_OFFSET, ARRAY_PATTERN_RESERVED_BYTES, TYPE_ARRAY_PATTERN, +}; +use crate::convert_ast::converter::AstConverter; + +impl AstConverter<'_> { + pub(crate) fn store_array_pattern(&mut self, array_pattern: &ArrayPat) { + let end_position = self.add_type_and_start( + &TYPE_ARRAY_PATTERN, + &array_pattern.span, + ARRAY_PATTERN_RESERVED_BYTES, + false, + ); + // elements + self.convert_item_list( + &array_pattern.elems, + end_position + ARRAY_PATTERN_ELEMENTS_OFFSET, + |ast_converter, element| match element { + Some(element) => { + ast_converter.convert_pattern(element); + true + } + None => false, + }, + ); + // end + self.add_end(end_position, &array_pattern.span); + } +} diff --git a/rust/parse_ast/src/ast_nodes/arrow_function_expression.rs b/rust/parse_ast/src/ast_nodes/arrow_function_expression.rs new file mode 100644 index 00000000000..a4fa4e23a32 --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/arrow_function_expression.rs @@ -0,0 +1,64 @@ +use swc_ecma_ast::{ArrowExpr, BlockStmtOrExpr}; + +use crate::convert_ast::annotations::AnnotationKind; +use crate::convert_ast::converter::ast_constants::{ + ARROW_FUNCTION_EXPRESSION_ANNOTATIONS_OFFSET, ARROW_FUNCTION_EXPRESSION_BODY_OFFSET, + ARROW_FUNCTION_EXPRESSION_PARAMS_OFFSET, ARROW_FUNCTION_EXPRESSION_RESERVED_BYTES, + TYPE_ARROW_FUNCTION_EXPRESSION, +}; +use crate::convert_ast::converter::{convert_annotation, AstConverter}; +use crate::store_arrow_function_expression_flags; + +impl AstConverter<'_> { + pub(crate) fn store_arrow_function_expression(&mut self, arrow_expression: &ArrowExpr) { + let end_position = self.add_type_and_start( + &TYPE_ARROW_FUNCTION_EXPRESSION, + &arrow_expression.span, + ARROW_FUNCTION_EXPRESSION_RESERVED_BYTES, + false, + ); + // annotations + let annotations = self + .index_converter + .take_collected_annotations(AnnotationKind::NoSideEffects); + if !annotations.is_empty() { + self.convert_item_list( + &annotations, + end_position + ARROW_FUNCTION_EXPRESSION_ANNOTATIONS_OFFSET, + |ast_converter, annotation| { + convert_annotation(&mut ast_converter.buffer, annotation); + true + }, + ); + } + // flags + store_arrow_function_expression_flags!( + self, + end_position, + async => arrow_expression.is_async, + expression => matches!(&*arrow_expression.body, BlockStmtOrExpr::Expr(_)), + generator => arrow_expression.is_generator + ); + // params + self.convert_item_list( + &arrow_expression.params, + end_position + ARROW_FUNCTION_EXPRESSION_PARAMS_OFFSET, + |ast_converter, param| { + ast_converter.convert_pattern(param); + true + }, + ); + // body + self.update_reference_position(end_position + ARROW_FUNCTION_EXPRESSION_BODY_OFFSET); + match &*arrow_expression.body { + BlockStmtOrExpr::BlockStmt(block_statement) => { + self.store_block_statement(block_statement, true) + } + BlockStmtOrExpr::Expr(expression) => { + self.convert_expression(expression); + } + } + // end + self.add_end(end_position, &arrow_expression.span); + } +} diff --git a/rust/parse_ast/src/ast_nodes/assignment_expression.rs b/rust/parse_ast/src/ast_nodes/assignment_expression.rs new file mode 100644 index 00000000000..4651e18856b --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/assignment_expression.rs @@ -0,0 +1,39 @@ +use swc_ecma_ast::{AssignExpr, AssignOp}; + +use crate::convert_ast::converter::string_constants::{ + STRING_ADDASSIGN, STRING_ANDASSIGN, STRING_ASSIGN, STRING_BITANDASSIGN, STRING_BITORASSIGN, + STRING_BITXORASSIGN, STRING_DIVASSIGN, STRING_EXPASSIGN, STRING_LSHIFTASSIGN, STRING_MODASSIGN, + STRING_MULASSIGN, STRING_NULLISHASSIGN, STRING_ORASSIGN, STRING_RSHIFTASSIGN, STRING_SUBASSIGN, + STRING_ZEROFILLRSHIFTASSIGN, +}; +use crate::convert_ast::converter::AstConverter; +use crate::store_assignment_expression; + +impl AstConverter<'_> { + pub(crate) fn store_assignment_expression(&mut self, assignment_expression: &AssignExpr) { + store_assignment_expression!( + self, + span => assignment_expression.span, + operator => match assignment_expression.op { + AssignOp::Assign => &STRING_ASSIGN, + AssignOp::AddAssign => &STRING_ADDASSIGN, + AssignOp::SubAssign => &STRING_SUBASSIGN, + AssignOp::MulAssign => &STRING_MULASSIGN, + AssignOp::DivAssign => &STRING_DIVASSIGN, + AssignOp::ModAssign => &STRING_MODASSIGN, + AssignOp::LShiftAssign => &STRING_LSHIFTASSIGN, + AssignOp::RShiftAssign => &STRING_RSHIFTASSIGN, + AssignOp::ZeroFillRShiftAssign => &STRING_ZEROFILLRSHIFTASSIGN, + AssignOp::BitOrAssign => &STRING_BITORASSIGN, + AssignOp::BitXorAssign => &STRING_BITXORASSIGN, + AssignOp::BitAndAssign => &STRING_BITANDASSIGN, + AssignOp::ExpAssign => &STRING_EXPASSIGN, + AssignOp::AndAssign => &STRING_ANDASSIGN, + AssignOp::OrAssign => &STRING_ORASSIGN, + AssignOp::NullishAssign => &STRING_NULLISHASSIGN, + }, + left => [assignment_expression.left, convert_pattern_or_expression], + right => [assignment_expression.right, convert_expression] + ); + } +} diff --git a/rust/parse_ast/src/ast_nodes/assignment_pattern.rs b/rust/parse_ast/src/ast_nodes/assignment_pattern.rs new file mode 100644 index 00000000000..0e8f8c1df2f --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/assignment_pattern.rs @@ -0,0 +1,52 @@ +use swc_common::Span; +use swc_ecma_ast::{AssignPat, Expr, Ident, Pat}; + +use crate::convert_ast::converter::ast_constants::{ + ASSIGNMENT_PATTERN_LEFT_OFFSET, ASSIGNMENT_PATTERN_RESERVED_BYTES, + ASSIGNMENT_PATTERN_RIGHT_OFFSET, TYPE_ASSIGNMENT_PATTERN, +}; +use crate::convert_ast::converter::AstConverter; + +impl AstConverter<'_> { + pub(crate) fn store_assignment_pattern_and_get_left_position( + &mut self, + span: &Span, + left: PatternOrIdentifier, + right: &Expr, + ) -> u32 { + let end_position = self.add_type_and_start( + &TYPE_ASSIGNMENT_PATTERN, + span, + ASSIGNMENT_PATTERN_RESERVED_BYTES, + false, + ); + // left + self.update_reference_position(end_position + ASSIGNMENT_PATTERN_LEFT_OFFSET); + let left_position = (self.buffer.len() >> 2) as u32; + match left { + PatternOrIdentifier::Pattern(pattern) => { + self.convert_pattern(pattern); + } + PatternOrIdentifier::Identifier(identifier) => self.convert_identifier(identifier), + } + // right + self.update_reference_position(end_position + ASSIGNMENT_PATTERN_RIGHT_OFFSET); + self.convert_expression(right); + // end + self.add_end(end_position, span); + left_position + } + + pub(crate) fn convert_assignment_pattern(&mut self, assignment_pattern: &AssignPat) { + self.store_assignment_pattern_and_get_left_position( + &assignment_pattern.span, + PatternOrIdentifier::Pattern(&assignment_pattern.left), + &assignment_pattern.right, + ); + } +} + +pub(crate) enum PatternOrIdentifier<'a> { + Pattern(&'a Pat), + Identifier(&'a Ident), +} diff --git a/rust/parse_ast/src/ast_nodes/await_expression.rs b/rust/parse_ast/src/ast_nodes/await_expression.rs new file mode 100644 index 00000000000..ce21a3cb99b --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/await_expression.rs @@ -0,0 +1,14 @@ +use swc_ecma_ast::AwaitExpr; + +use crate::convert_ast::converter::AstConverter; +use crate::store_await_expression; + +impl AstConverter<'_> { + pub(crate) fn store_await_expression(&mut self, await_expression: &AwaitExpr) { + store_await_expression!( + self, + span => await_expression.span, + argument => [await_expression.arg, convert_expression] + ); + } +} diff --git a/rust/parse_ast/src/ast_nodes/binary_expression.rs b/rust/parse_ast/src/ast_nodes/binary_expression.rs new file mode 100644 index 00000000000..a4bf5fe1434 --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/binary_expression.rs @@ -0,0 +1,69 @@ +use swc_ecma_ast::{BinExpr, BinaryOp}; + +use crate::convert_ast::converter::ast_constants::{ + BINARY_EXPRESSION_LEFT_OFFSET, BINARY_EXPRESSION_OPERATOR_OFFSET, + BINARY_EXPRESSION_RESERVED_BYTES, BINARY_EXPRESSION_RIGHT_OFFSET, TYPE_BINARY_EXPRESSION, + TYPE_LOGICAL_EXPRESSION, +}; +use crate::convert_ast::converter::string_constants::{ + STRING_ADD, STRING_BITAND, STRING_BITOR, STRING_BITXOR, STRING_DIV, STRING_EQEQ, STRING_EQEQEQ, + STRING_EXP, STRING_GT, STRING_GTEQ, STRING_IN, STRING_INSTANCEOF, STRING_LOGICALAND, + STRING_LOGICALOR, STRING_LSHIFT, STRING_LT, STRING_LTEQ, STRING_MOD, STRING_MUL, STRING_NOTEQ, + STRING_NOTEQEQ, STRING_NULLISHCOALESCING, STRING_RSHIFT, STRING_SUB, STRING_ZEROFILLRSHIFT, +}; +use crate::convert_ast::converter::AstConverter; + +impl AstConverter<'_> { + pub(crate) fn store_binary_expression(&mut self, binary_expression: &BinExpr) { + let end_position = self.add_type_and_start( + match binary_expression.op { + BinaryOp::LogicalOr | BinaryOp::LogicalAnd | BinaryOp::NullishCoalescing => { + &TYPE_LOGICAL_EXPRESSION + } + _ => &TYPE_BINARY_EXPRESSION, + }, + &binary_expression.span, + BINARY_EXPRESSION_RESERVED_BYTES, + false, + ); + // left + self.update_reference_position(end_position + BINARY_EXPRESSION_LEFT_OFFSET); + self.convert_expression(&binary_expression.left); + // operator + let operator_position = end_position + BINARY_EXPRESSION_OPERATOR_OFFSET; + self.buffer[operator_position..operator_position + 4].copy_from_slice( + match binary_expression.op { + BinaryOp::EqEq => &STRING_EQEQ, + BinaryOp::NotEq => &STRING_NOTEQ, + BinaryOp::EqEqEq => &STRING_EQEQEQ, + BinaryOp::NotEqEq => &STRING_NOTEQEQ, + BinaryOp::Lt => &STRING_LT, + BinaryOp::LtEq => &STRING_LTEQ, + BinaryOp::Gt => &STRING_GT, + BinaryOp::GtEq => &STRING_GTEQ, + BinaryOp::LShift => &STRING_LSHIFT, + BinaryOp::RShift => &STRING_RSHIFT, + BinaryOp::ZeroFillRShift => &STRING_ZEROFILLRSHIFT, + BinaryOp::Add => &STRING_ADD, + BinaryOp::Sub => &STRING_SUB, + BinaryOp::Mul => &STRING_MUL, + BinaryOp::Div => &STRING_DIV, + BinaryOp::Mod => &STRING_MOD, + BinaryOp::BitOr => &STRING_BITOR, + BinaryOp::BitXor => &STRING_BITXOR, + BinaryOp::BitAnd => &STRING_BITAND, + BinaryOp::LogicalOr => &STRING_LOGICALOR, + BinaryOp::LogicalAnd => &STRING_LOGICALAND, + BinaryOp::In => &STRING_IN, + BinaryOp::InstanceOf => &STRING_INSTANCEOF, + BinaryOp::Exp => &STRING_EXP, + BinaryOp::NullishCoalescing => &STRING_NULLISHCOALESCING, + }, + ); + // right + self.update_reference_position(end_position + BINARY_EXPRESSION_RIGHT_OFFSET); + self.convert_expression(&binary_expression.right); + // end + self.add_end(end_position, &binary_expression.span); + } +} diff --git a/rust/parse_ast/src/ast_nodes/block_statement.rs b/rust/parse_ast/src/ast_nodes/block_statement.rs new file mode 100644 index 00000000000..93f180b5310 --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/block_statement.rs @@ -0,0 +1,43 @@ +use swc_ecma_ast::{BlockStmt, Expr, Lit, Stmt}; + +use crate::convert_ast::converter::ast_constants::{ + BLOCK_STATEMENT_BODY_OFFSET, BLOCK_STATEMENT_RESERVED_BYTES, TYPE_BLOCK_STATEMENT, +}; +use crate::convert_ast::converter::AstConverter; + +impl AstConverter<'_> { + pub(crate) fn store_block_statement( + &mut self, + block_statement: &BlockStmt, + check_directive: bool, + ) { + let end_position = self.add_type_and_start( + &TYPE_BLOCK_STATEMENT, + &block_statement.span, + BLOCK_STATEMENT_RESERVED_BYTES, + false, + ); + // body + let mut keep_checking_directives = check_directive; + self.convert_item_list_with_state( + &block_statement.stmts, + end_position + BLOCK_STATEMENT_BODY_OFFSET, + &mut keep_checking_directives, + |ast_converter, statement, can_be_directive| { + if *can_be_directive { + if let Stmt::Expr(expression) = statement { + if let Expr::Lit(Lit::Str(string)) = &*expression.expr { + ast_converter.store_directive(expression, string.value.as_atom().unwrap()); + return (true, None); + } + } + } + *can_be_directive = false; + ast_converter.convert_statement(statement); + (true, None) + }, + ); + // end + self.add_end(end_position, &block_statement.span); + } +} diff --git a/rust/parse_ast/src/ast_nodes/break_statement.rs b/rust/parse_ast/src/ast_nodes/break_statement.rs new file mode 100644 index 00000000000..dad051d1a4a --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/break_statement.rs @@ -0,0 +1,14 @@ +use swc_ecma_ast::BreakStmt; + +use crate::convert_ast::converter::AstConverter; +use crate::store_break_statement; + +impl AstConverter<'_> { + pub(crate) fn store_break_statement(&mut self, break_statement: &BreakStmt) { + store_break_statement!( + self, + span => break_statement.span, + label => [break_statement.label, convert_identifier] + ); + } +} diff --git a/rust/parse_ast/src/ast_nodes/call_expression.rs b/rust/parse_ast/src/ast_nodes/call_expression.rs new file mode 100644 index 00000000000..dfc701bc5a8 --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/call_expression.rs @@ -0,0 +1,92 @@ +use swc_common::Span; +use swc_ecma_ast::{Expr, ExprOrSpread, OptCall, Super}; + +use crate::convert_ast::annotations::AnnotationKind; +use crate::convert_ast::converter::ast_constants::{ + CALL_EXPRESSION_ANNOTATIONS_OFFSET, CALL_EXPRESSION_ARGUMENTS_OFFSET, + CALL_EXPRESSION_CALLEE_OFFSET, CALL_EXPRESSION_RESERVED_BYTES, TYPE_CALL_EXPRESSION, +}; +use crate::convert_ast::converter::{convert_annotation, AstConverter}; +use crate::store_call_expression_flags; + +impl AstConverter<'_> { + pub(crate) fn store_call_expression( + &mut self, + span: &Span, + is_optional: bool, + callee: &StoredCallee, + arguments: &[ExprOrSpread], + is_chained: bool, + ) { + let end_position = self.add_type_and_start( + &TYPE_CALL_EXPRESSION, + span, + CALL_EXPRESSION_RESERVED_BYTES, + false, + ); + // annotations + let annotations = self + .index_converter + .take_collected_annotations(AnnotationKind::Pure); + if !annotations.is_empty() { + self.convert_item_list( + &annotations, + end_position + CALL_EXPRESSION_ANNOTATIONS_OFFSET, + |ast_converter, annotation| { + convert_annotation(&mut ast_converter.buffer, annotation); + true + }, + ); + } + // flags + store_call_expression_flags!(self, end_position, optional => is_optional); + // callee + self.update_reference_position(end_position + CALL_EXPRESSION_CALLEE_OFFSET); + match callee { + StoredCallee::Expression(Expr::OptChain(optional_chain_expression)) => { + self.store_chain_expression(optional_chain_expression, is_chained); + } + StoredCallee::Expression(Expr::Call(call_expression)) => { + self.convert_call_expression(call_expression, false, is_chained); + } + StoredCallee::Expression(Expr::Member(member_expression)) => { + self.convert_member_expression(member_expression, false, is_chained); + } + StoredCallee::Expression(callee_expression) => { + self.convert_expression(callee_expression); + } + StoredCallee::Super(callee_super) => self.store_super_element(callee_super), + } + // arguments + self.convert_item_list( + arguments, + end_position + CALL_EXPRESSION_ARGUMENTS_OFFSET, + |ast_converter, argument| { + ast_converter.convert_expression_or_spread(argument); + true + }, + ); + // end + self.add_end(end_position, span); + } + + pub(crate) fn convert_optional_call( + &mut self, + optional_call: &OptCall, + is_optional: bool, + is_chained: bool, + ) { + self.store_call_expression( + &optional_call.span, + is_optional, + &StoredCallee::Expression(&optional_call.callee), + &optional_call.args, + is_chained, + ); + } +} + +pub(crate) enum StoredCallee<'a> { + Expression(&'a Expr), + Super(&'a Super), +} diff --git a/rust/parse_ast/src/ast_nodes/catch_clause.rs b/rust/parse_ast/src/ast_nodes/catch_clause.rs new file mode 100644 index 00000000000..aa8208b0441 --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/catch_clause.rs @@ -0,0 +1,28 @@ +use swc_ecma_ast::CatchClause; + +use crate::convert_ast::converter::ast_constants::{ + CATCH_CLAUSE_BODY_OFFSET, CATCH_CLAUSE_PARAM_OFFSET, CATCH_CLAUSE_RESERVED_BYTES, + TYPE_CATCH_CLAUSE, +}; +use crate::convert_ast::converter::AstConverter; + +impl AstConverter<'_> { + pub(crate) fn store_catch_clause(&mut self, catch_clause: &CatchClause) { + let end_position = self.add_type_and_start( + &TYPE_CATCH_CLAUSE, + &catch_clause.span, + CATCH_CLAUSE_RESERVED_BYTES, + false, + ); + // param + if let Some(pattern) = catch_clause.param.as_ref() { + self.update_reference_position(end_position + CATCH_CLAUSE_PARAM_OFFSET); + self.convert_pattern(pattern); + } + // body + self.update_reference_position(end_position + CATCH_CLAUSE_BODY_OFFSET); + self.store_block_statement(&catch_clause.body, false); + // end + self.add_end(end_position, &catch_clause.span); + } +} diff --git a/rust/parse_ast/src/ast_nodes/chain_expression.rs b/rust/parse_ast/src/ast_nodes/chain_expression.rs new file mode 100644 index 00000000000..758efbd864d --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/chain_expression.rs @@ -0,0 +1,36 @@ +use swc_ecma_ast::OptChainExpr; + +use crate::convert_ast::converter::ast_constants::{ + CHAIN_EXPRESSION_EXPRESSION_OFFSET, CHAIN_EXPRESSION_RESERVED_BYTES, TYPE_CHAIN_EXPRESSION, +}; +use crate::convert_ast::converter::AstConverter; + +impl AstConverter<'_> { + pub(crate) fn store_chain_expression( + &mut self, + optional_chain_expression: &OptChainExpr, + is_chained: bool, + ) { + if is_chained { + self.convert_optional_chain_base( + &optional_chain_expression.base, + optional_chain_expression.optional, + ); + } else { + let end_position = self.add_type_and_start( + &TYPE_CHAIN_EXPRESSION, + &optional_chain_expression.span, + CHAIN_EXPRESSION_RESERVED_BYTES, + false, + ); + // expression + self.update_reference_position(end_position + CHAIN_EXPRESSION_EXPRESSION_OFFSET); + self.convert_optional_chain_base( + &optional_chain_expression.base, + optional_chain_expression.optional, + ); + // end + self.add_end(end_position, &optional_chain_expression.span); + } + } +} diff --git a/rust/parse_ast/src/ast_nodes/class_body.rs b/rust/parse_ast/src/ast_nodes/class_body.rs new file mode 100644 index 00000000000..54172e1310f --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/class_body.rs @@ -0,0 +1,28 @@ +use swc_ecma_ast::ClassMember; + +use crate::convert_ast::converter::ast_constants::{ + CLASS_BODY_BODY_OFFSET, CLASS_BODY_RESERVED_BYTES, TYPE_CLASS_BODY, +}; +use crate::convert_ast::converter::AstConverter; + +impl AstConverter<'_> { + pub(crate) fn store_class_body(&mut self, class_members: &[ClassMember], start: u32, end: u32) { + let end_position = + self.add_type_and_explicit_start(&TYPE_CLASS_BODY, start, CLASS_BODY_RESERVED_BYTES); + let class_members_filtered: Vec<&ClassMember> = class_members + .iter() + .filter(|class_member| !matches!(class_member, ClassMember::Empty(_))) + .collect(); + // body + self.convert_item_list( + &class_members_filtered, + end_position + CLASS_BODY_BODY_OFFSET, + |ast_converter, class_member| { + ast_converter.convert_class_member(class_member); + true + }, + ); + // end + self.add_explicit_end(end_position, end); + } +} diff --git a/rust/parse_ast/src/ast_nodes/class_declaration.rs b/rust/parse_ast/src/ast_nodes/class_declaration.rs new file mode 100644 index 00000000000..a88cac0576c --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/class_declaration.rs @@ -0,0 +1,19 @@ +use swc_ecma_ast::ClassDecl; + +use crate::convert_ast::converter::ast_constants::TYPE_CLASS_DECLARATION; +use crate::convert_ast::converter::AstConverter; + +impl AstConverter<'_> { + pub(crate) fn store_class_declaration( + &mut self, + class_declaration: &ClassDecl, + outside_class_span_decorators_insert_position: Option, + ) { + self.store_class_node( + &TYPE_CLASS_DECLARATION, + Some(&class_declaration.ident), + &class_declaration.class, + outside_class_span_decorators_insert_position, + ); + } +} diff --git a/rust/parse_ast/src/ast_nodes/class_expression.rs b/rust/parse_ast/src/ast_nodes/class_expression.rs new file mode 100644 index 00000000000..71f8291d5ca --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/class_expression.rs @@ -0,0 +1,19 @@ +use swc_ecma_ast::ClassExpr; + +use crate::convert_ast::converter::AstConverter; + +impl AstConverter<'_> { + pub(crate) fn store_class_expression( + &mut self, + class_expression: &ClassExpr, + node_type: &[u8; 4], + outside_class_span_decorators_insert_position: Option, + ) { + self.store_class_node( + node_type, + class_expression.ident.as_ref(), + &class_expression.class, + outside_class_span_decorators_insert_position, + ); + } +} diff --git a/rust/parse_ast/src/ast_nodes/conditional_expression.rs b/rust/parse_ast/src/ast_nodes/conditional_expression.rs new file mode 100644 index 00000000000..a4fe7856454 --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/conditional_expression.rs @@ -0,0 +1,16 @@ +use swc_ecma_ast::CondExpr; + +use crate::convert_ast::converter::AstConverter; +use crate::store_conditional_expression; + +impl AstConverter<'_> { + pub(crate) fn store_conditional_expression(&mut self, conditional_expression: &CondExpr) { + store_conditional_expression!( + self, + span => conditional_expression.span, + test => [conditional_expression.test, convert_expression], + consequent => [conditional_expression.cons, convert_expression], + alternate => [conditional_expression.alt, convert_expression] + ); + } +} diff --git a/rust/parse_ast/src/ast_nodes/continue_statement.rs b/rust/parse_ast/src/ast_nodes/continue_statement.rs new file mode 100644 index 00000000000..190046ea555 --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/continue_statement.rs @@ -0,0 +1,14 @@ +use swc_ecma_ast::ContinueStmt; + +use crate::convert_ast::converter::AstConverter; +use crate::store_continue_statement; + +impl AstConverter<'_> { + pub(crate) fn store_continue_statement(&mut self, continue_statement: &ContinueStmt) { + store_continue_statement!( + self, + span => continue_statement.span, + label => [continue_statement.label, convert_identifier] + ); + } +} diff --git a/rust/parse_ast/src/ast_nodes/debugger_statement.rs b/rust/parse_ast/src/ast_nodes/debugger_statement.rs new file mode 100644 index 00000000000..f55c5d8fde7 --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/debugger_statement.rs @@ -0,0 +1,10 @@ +use swc_ecma_ast::DebuggerStmt; + +use crate::convert_ast::converter::AstConverter; +use crate::store_debugger_statement; + +impl AstConverter<'_> { + pub(crate) fn store_debugger_statement(&mut self, debugger_statement: &DebuggerStmt) { + store_debugger_statement!(self, span => debugger_statement.span); + } +} diff --git a/rust/parse_ast/src/ast_nodes/decorator.rs b/rust/parse_ast/src/ast_nodes/decorator.rs new file mode 100644 index 00000000000..9ec035096c3 --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/decorator.rs @@ -0,0 +1,10 @@ +use swc_ecma_ast::Decorator; + +use crate::convert_ast::converter::AstConverter; +use crate::store_decorator; + +impl AstConverter<'_> { + pub(crate) fn store_decorator(&mut self, decorator: &Decorator) { + store_decorator!(self, span => decorator.span, expression=>[decorator.expr, convert_expression]); + } +} diff --git a/rust/parse_ast/src/ast_nodes/directive.rs b/rust/parse_ast/src/ast_nodes/directive.rs new file mode 100644 index 00000000000..fb11b705b93 --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/directive.rs @@ -0,0 +1,15 @@ +use swc_ecma_ast::ExprStmt; + +use crate::convert_ast::converter::AstConverter; +use crate::store_directive; + +impl AstConverter<'_> { + pub(crate) fn store_directive(&mut self, expression_statement: &ExprStmt, directive: &str) { + store_directive!( + self, + span => expression_statement.span, + directive => directive, + expression => [expression_statement.expr, convert_expression] + ); + } +} diff --git a/rust/parse_ast/src/ast_nodes/do_while_statement.rs b/rust/parse_ast/src/ast_nodes/do_while_statement.rs new file mode 100644 index 00000000000..a966232d16b --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/do_while_statement.rs @@ -0,0 +1,15 @@ +use swc_ecma_ast::DoWhileStmt; + +use crate::convert_ast::converter::AstConverter; +use crate::store_do_while_statement; + +impl AstConverter<'_> { + pub(crate) fn store_do_while_statement(&mut self, do_while_statement: &DoWhileStmt) { + store_do_while_statement!( + self, + span => do_while_statement.span, + body => [do_while_statement.body, convert_statement], + test => [do_while_statement.test, convert_expression] + ); + } +} diff --git a/rust/parse_ast/src/ast_nodes/empty_statement.rs b/rust/parse_ast/src/ast_nodes/empty_statement.rs new file mode 100644 index 00000000000..4916ce5d0e3 --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/empty_statement.rs @@ -0,0 +1,10 @@ +use swc_ecma_ast::EmptyStmt; + +use crate::convert_ast::converter::AstConverter; +use crate::store_empty_statement; + +impl AstConverter<'_> { + pub(crate) fn store_empty_statement(&mut self, empty_statement: &EmptyStmt) { + store_empty_statement!(self, span => empty_statement.span); + } +} diff --git a/rust/parse_ast/src/ast_nodes/export_all_declaration.rs b/rust/parse_ast/src/ast_nodes/export_all_declaration.rs new file mode 100644 index 00000000000..c04e81f03f4 --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/export_all_declaration.rs @@ -0,0 +1,45 @@ +use swc_common::Span; +use swc_ecma_ast::{ExportAll, ModuleExportName, ObjectLit, Str}; + +use crate::convert_ast::converter::ast_constants::{ + EXPORT_ALL_DECLARATION_ATTRIBUTES_OFFSET, EXPORT_ALL_DECLARATION_EXPORTED_OFFSET, + EXPORT_ALL_DECLARATION_RESERVED_BYTES, EXPORT_ALL_DECLARATION_SOURCE_OFFSET, + TYPE_EXPORT_ALL_DECLARATION, +}; +use crate::convert_ast::converter::AstConverter; + +impl AstConverter<'_> { + pub(crate) fn store_export_all_declaration( + &mut self, + span: &Span, + source: &Str, + attributes: &Option>, + exported: Option<&ModuleExportName>, + ) { + let end_position = self.add_type_and_start( + &TYPE_EXPORT_ALL_DECLARATION, + span, + EXPORT_ALL_DECLARATION_RESERVED_BYTES, + false, + ); + // exported + if let Some(exported) = exported { + self.update_reference_position(end_position + EXPORT_ALL_DECLARATION_EXPORTED_OFFSET); + self.convert_module_export_name(exported); + } + // source + self.update_reference_position(end_position + EXPORT_ALL_DECLARATION_SOURCE_OFFSET); + self.store_literal_string(source); + // attributes + self.store_import_attributes( + attributes, + end_position + EXPORT_ALL_DECLARATION_ATTRIBUTES_OFFSET, + ); + // end + self.add_end(end_position, span); + } + + pub(crate) fn convert_export_all(&mut self, export_all: &ExportAll) { + self.store_export_all_declaration(&export_all.span, &export_all.src, &export_all.with, None); + } +} diff --git a/rust/parse_ast/src/ast_nodes/export_default_declaration.rs b/rust/parse_ast/src/ast_nodes/export_default_declaration.rs new file mode 100644 index 00000000000..d46b4f13b5c --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/export_default_declaration.rs @@ -0,0 +1,118 @@ +use swc_common::Span; +use swc_ecma_ast::{ClassExpr, DefaultDecl, ExportDefaultDecl, ExportDefaultExpr, Expr, FnExpr}; + +use crate::convert_ast::converter::ast_constants::{ + EXPORT_DEFAULT_DECLARATION_DECLARATION_OFFSET, EXPORT_DEFAULT_DECLARATION_RESERVED_BYTES, + TYPE_CLASS_DECLARATION, TYPE_EXPORT_DEFAULT_DECLARATION, TYPE_FUNCTION_DECLARATION, +}; + +use crate::convert_ast::converter::{get_outside_class_span_decorators_info, AstConverter}; + +impl AstConverter<'_> { + pub(crate) fn store_export_default_declaration( + &mut self, + span: &Span, + expression: StoredDefaultExportExpression, + module_item_insert_position: &mut u32, + ) { + let ( + mut outside_class_span_decorators_insert_position, + are_decorators_before_export, + are_decorators_after_export, + outside_class_span_decorators, + ) = get_outside_class_span_decorators_info( + span, + match expression { + StoredDefaultExportExpression::Class(class_expression) => Some(&class_expression.class), + _ => None, + }, + ); + + if are_decorators_before_export { + self.store_outside_class_span_decorators( + outside_class_span_decorators, + &mut outside_class_span_decorators_insert_position, + ); + *module_item_insert_position = (self.buffer.len() as u32) >> 2; + } + + let end_position = self.add_type_and_start( + &TYPE_EXPORT_DEFAULT_DECLARATION, + span, + EXPORT_DEFAULT_DECLARATION_RESERVED_BYTES, + matches!( + expression, + StoredDefaultExportExpression::Expression(Expr::Fn(_) | Expr::Arrow(_)) + | StoredDefaultExportExpression::Function(_) + ), + ); + + if are_decorators_after_export { + self.store_outside_class_span_decorators( + outside_class_span_decorators, + &mut outside_class_span_decorators_insert_position, + ); + } + // declaration + self.update_reference_position(end_position + EXPORT_DEFAULT_DECLARATION_DECLARATION_OFFSET); + match expression { + StoredDefaultExportExpression::Expression(expression) => { + self.convert_expression(expression); + } + StoredDefaultExportExpression::Class(class_expression) => { + self.store_class_expression( + class_expression, + &TYPE_CLASS_DECLARATION, + outside_class_span_decorators_insert_position, + ); + } + StoredDefaultExportExpression::Function(function_expression) => self.convert_function( + &function_expression.function, + &TYPE_FUNCTION_DECLARATION, + function_expression.ident.as_ref(), + ), + } + // end + self.add_end(end_position, span); + } + + pub(crate) fn convert_export_default_declaration( + &mut self, + export_default_declaration: &ExportDefaultDecl, + module_item_insert_position: &mut u32, + ) { + self.store_export_default_declaration( + &export_default_declaration.span, + match &export_default_declaration.decl { + DefaultDecl::Class(class_expression) => { + StoredDefaultExportExpression::Class(class_expression) + } + DefaultDecl::Fn(function_expression) => { + StoredDefaultExportExpression::Function(function_expression) + } + DefaultDecl::TsInterfaceDecl(_) => { + unimplemented!("Cannot convert ExportDefaultDeclaration with TsInterfaceDecl") + } + }, + module_item_insert_position, + ); + } + + pub(crate) fn convert_export_default_expression( + &mut self, + export_default_expression: &ExportDefaultExpr, + module_item_insert_position: &mut u32, + ) { + self.store_export_default_declaration( + &export_default_expression.span, + StoredDefaultExportExpression::Expression(&export_default_expression.expr), + module_item_insert_position, + ); + } +} + +pub(crate) enum StoredDefaultExportExpression<'a> { + Expression(&'a Expr), + Class(&'a ClassExpr), + Function(&'a FnExpr), +} diff --git a/rust/parse_ast/src/ast_nodes/export_named_declaration.rs b/rust/parse_ast/src/ast_nodes/export_named_declaration.rs new file mode 100644 index 00000000000..2786e6e744e --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/export_named_declaration.rs @@ -0,0 +1,105 @@ +use swc_common::Span; +use swc_ecma_ast::{Decl, ExportDecl, ExportSpecifier, ObjectLit, Str, VarDeclKind}; + +use crate::convert_ast::converter::ast_constants::{ + EXPORT_NAMED_DECLARATION_ATTRIBUTES_OFFSET, EXPORT_NAMED_DECLARATION_DECLARATION_OFFSET, + EXPORT_NAMED_DECLARATION_RESERVED_BYTES, EXPORT_NAMED_DECLARATION_SOURCE_OFFSET, + EXPORT_NAMED_DECLARATION_SPECIFIERS_OFFSET, TYPE_EXPORT_NAMED_DECLARATION, +}; + +use crate::convert_ast::converter::{get_outside_class_span_decorators_info, AstConverter}; + +impl AstConverter<'_> { + pub(crate) fn store_export_named_declaration( + &mut self, + span: &Span, + specifiers: &[ExportSpecifier], + src: Option<&Str>, + declaration: Option<&Decl>, + with: &Option>, + module_item_insert_position: Option<&mut u32>, + ) { + let ( + mut outside_class_span_decorators_insert_position, + are_decorators_before_export, + are_decorators_after_export, + outside_class_span_decorators, + ) = get_outside_class_span_decorators_info( + span, + match declaration { + Some(Decl::Class(class_declaration)) => Some(&class_declaration.class), + _ => None, + }, + ); + + if are_decorators_before_export { + self.store_outside_class_span_decorators( + outside_class_span_decorators, + &mut outside_class_span_decorators_insert_position, + ); + if let Some(module_item_insert_position) = module_item_insert_position { + *module_item_insert_position = (self.buffer.len() as u32) >> 2; + } + } + + let end_position = self.add_type_and_start( + &TYPE_EXPORT_NAMED_DECLARATION, + span, + EXPORT_NAMED_DECLARATION_RESERVED_BYTES, + match declaration { + Some(Decl::Fn(_)) => true, + Some(Decl::Var(variable_declaration)) => variable_declaration.kind == VarDeclKind::Const, + _ => false, + }, + ); + + if are_decorators_after_export { + self.store_outside_class_span_decorators( + outside_class_span_decorators, + &mut outside_class_span_decorators_insert_position, + ); + } + + // specifiers + self.convert_item_list( + specifiers, + end_position + EXPORT_NAMED_DECLARATION_SPECIFIERS_OFFSET, + |ast_converter, specifier| { + ast_converter.convert_export_specifier(specifier); + true + }, + ); + // declaration + if let Some(declaration) = declaration { + self.update_reference_position(end_position + EXPORT_NAMED_DECLARATION_DECLARATION_OFFSET); + self.convert_declaration(declaration, outside_class_span_decorators_insert_position); + } + // source + if let Some(src) = src { + self.update_reference_position(end_position + EXPORT_NAMED_DECLARATION_SOURCE_OFFSET); + self.store_literal_string(src); + } + // attributes + self.store_import_attributes( + with, + end_position + EXPORT_NAMED_DECLARATION_ATTRIBUTES_OFFSET, + ); + // end + self.add_end(end_position, span); + } + + pub(crate) fn convert_export_declaration( + &mut self, + export_declaration: &ExportDecl, + module_item_insert_position: &mut u32, + ) { + self.store_export_named_declaration( + &export_declaration.span, + &[], + None, + Some(&export_declaration.decl), + &None, + Some(module_item_insert_position), + ); + } +} diff --git a/rust/parse_ast/src/ast_nodes/export_specifier.rs b/rust/parse_ast/src/ast_nodes/export_specifier.rs new file mode 100644 index 00000000000..fd36159f4c1 --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/export_specifier.rs @@ -0,0 +1,15 @@ +use swc_ecma_ast::ExportNamedSpecifier; + +use crate::convert_ast::converter::AstConverter; +use crate::store_export_specifier; + +impl AstConverter<'_> { + pub(crate) fn store_export_specifier(&mut self, export_named_specifier: &ExportNamedSpecifier) { + store_export_specifier!( + self, + span => &export_named_specifier.span, + local => [export_named_specifier.orig, convert_module_export_name], + exported => [export_named_specifier.exported, convert_module_export_name] + ); + } +} diff --git a/rust/parse_ast/src/ast_nodes/expression_statement.rs b/rust/parse_ast/src/ast_nodes/expression_statement.rs new file mode 100644 index 00000000000..e75ef2a6bf3 --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/expression_statement.rs @@ -0,0 +1,14 @@ +use swc_ecma_ast::ExprStmt; + +use crate::convert_ast::converter::AstConverter; +use crate::store_expression_statement; + +impl AstConverter<'_> { + pub(crate) fn store_expression_statement(&mut self, expression_statement: &ExprStmt) { + store_expression_statement!( + self, + span => &expression_statement.span, + expression => [expression_statement.expr, convert_expression] + ); + } +} diff --git a/rust/parse_ast/src/ast_nodes/for_in_statement.rs b/rust/parse_ast/src/ast_nodes/for_in_statement.rs new file mode 100644 index 00000000000..4814af463a5 --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/for_in_statement.rs @@ -0,0 +1,16 @@ +use swc_ecma_ast::ForInStmt; + +use crate::convert_ast::converter::AstConverter; +use crate::store_for_in_statement; + +impl AstConverter<'_> { + pub(crate) fn store_for_in_statement(&mut self, for_in_statement: &ForInStmt) { + store_for_in_statement!( + self, + span => &for_in_statement.span, + left => [for_in_statement.left, convert_for_head], + right => [for_in_statement.right, convert_expression], + body => [for_in_statement.body, convert_statement] + ); + } +} diff --git a/rust/parse_ast/src/ast_nodes/for_of_statement.rs b/rust/parse_ast/src/ast_nodes/for_of_statement.rs new file mode 100644 index 00000000000..c051ce2bd17 --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/for_of_statement.rs @@ -0,0 +1,17 @@ +use swc_ecma_ast::ForOfStmt; + +use crate::convert_ast::converter::AstConverter; +use crate::{store_for_of_statement, store_for_of_statement_flags}; + +impl AstConverter<'_> { + pub(crate) fn store_for_of_statement(&mut self, for_of_statement: &ForOfStmt) { + store_for_of_statement!( + self, + span => &for_of_statement.span, + await => for_of_statement.is_await, + left => [for_of_statement.left, convert_for_head], + right => [for_of_statement.right, convert_expression], + body => [for_of_statement.body, convert_statement] + ); + } +} diff --git a/rust/parse_ast/src/ast_nodes/for_statement.rs b/rust/parse_ast/src/ast_nodes/for_statement.rs new file mode 100644 index 00000000000..b11716af6fb --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/for_statement.rs @@ -0,0 +1,17 @@ +use swc_ecma_ast::ForStmt; + +use crate::convert_ast::converter::AstConverter; +use crate::store_for_statement; + +impl AstConverter<'_> { + pub(crate) fn store_for_statement(&mut self, for_statement: &ForStmt) { + store_for_statement!( + self, + span => &for_statement.span, + init => [for_statement.init, convert_variable_declaration_or_expression], + test => [for_statement.test, convert_expression], + update => [for_statement.update, convert_expression], + body => [for_statement.body, convert_statement] + ); + } +} diff --git a/rust/parse_ast/src/ast_nodes/function_declaration.rs b/rust/parse_ast/src/ast_nodes/function_declaration.rs new file mode 100644 index 00000000000..c9908cdbd9c --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/function_declaration.rs @@ -0,0 +1,5 @@ +use crate::convert_ast::converter::AstConverter; + +impl AstConverter<'_> { + // included in shared/function_node.rs +} diff --git a/rust/parse_ast/src/ast_nodes/function_expression.rs b/rust/parse_ast/src/ast_nodes/function_expression.rs new file mode 100644 index 00000000000..c9908cdbd9c --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/function_expression.rs @@ -0,0 +1,5 @@ +use crate::convert_ast::converter::AstConverter; + +impl AstConverter<'_> { + // included in shared/function_node.rs +} diff --git a/rust/parse_ast/src/ast_nodes/identifier.rs b/rust/parse_ast/src/ast_nodes/identifier.rs new file mode 100644 index 00000000000..1d4a0012fb2 --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/identifier.rs @@ -0,0 +1,36 @@ +use swc_ecma_ast::{BindingIdent, Ident, IdentName}; + +use crate::convert_ast::converter::ast_constants::{ + IDENTIFIER_NAME_OFFSET, IDENTIFIER_RESERVED_BYTES, TYPE_IDENTIFIER, +}; +use crate::convert_ast::converter::AstConverter; + +impl AstConverter<'_> { + pub(crate) fn store_identifier(&mut self, start: u32, end: u32, name: &str) { + let end_position = + self.add_type_and_explicit_start(&TYPE_IDENTIFIER, start, IDENTIFIER_RESERVED_BYTES); + // name + self.convert_string(name, end_position + IDENTIFIER_NAME_OFFSET); + // end + self.add_explicit_end(end_position, end); + } + + pub(crate) fn convert_binding_identifier(&mut self, binding_identifier: &BindingIdent) { + self.convert_identifier(&binding_identifier.id); + } + + pub(crate) fn convert_identifier(&mut self, identifier: &Ident) { + self.store_identifier( + identifier.span.lo.0 - 1, + identifier.span.hi.0 - 1, + &identifier.sym, + ); + } + pub(crate) fn convert_identifier_name(&mut self, identifier: &IdentName) { + self.store_identifier( + identifier.span.lo.0 - 1, + identifier.span.hi.0 - 1, + &identifier.sym, + ); + } +} diff --git a/rust/parse_ast/src/ast_nodes/if_statement.rs b/rust/parse_ast/src/ast_nodes/if_statement.rs new file mode 100644 index 00000000000..9b5931c6b86 --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/if_statement.rs @@ -0,0 +1,16 @@ +use swc_ecma_ast::IfStmt; + +use crate::convert_ast::converter::AstConverter; +use crate::store_if_statement; + +impl AstConverter<'_> { + pub(crate) fn store_if_statement(&mut self, if_statement: &IfStmt) { + store_if_statement!( + self, + span => &if_statement.span, + test => [if_statement.test, convert_expression], + consequent => [if_statement.cons, convert_statement], + alternate => [if_statement.alt, convert_statement] + ); + } +} diff --git a/rust/parse_ast/src/ast_nodes/import_attribute.rs b/rust/parse_ast/src/ast_nodes/import_attribute.rs new file mode 100644 index 00000000000..25c806afc5a --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/import_attribute.rs @@ -0,0 +1,53 @@ +use swc_common::Spanned; +use swc_ecma_ast::{KeyValueProp, ObjectLit, Prop, PropOrSpread}; + +use crate::convert_ast::converter::ast_constants::{ + IMPORT_ATTRIBUTE_KEY_OFFSET, IMPORT_ATTRIBUTE_RESERVED_BYTES, IMPORT_ATTRIBUTE_VALUE_OFFSET, + TYPE_IMPORT_ATTRIBUTE, +}; +use crate::convert_ast::converter::AstConverter; + +impl AstConverter<'_> { + pub(crate) fn store_import_attribute(&mut self, key_value_property: &KeyValueProp) { + // type + let end_position = self.add_type_and_start( + &TYPE_IMPORT_ATTRIBUTE, + &key_value_property.span(), + IMPORT_ATTRIBUTE_RESERVED_BYTES, + false, + ); + // key + self.update_reference_position(end_position + IMPORT_ATTRIBUTE_KEY_OFFSET); + self.convert_property_name(&key_value_property.key); + // value + self.update_reference_position(end_position + IMPORT_ATTRIBUTE_VALUE_OFFSET); + self.convert_expression(&key_value_property.value); + self.add_end(end_position, &key_value_property.span()); + } + + pub(crate) fn store_import_attributes( + &mut self, + with: &Option>, + reference_position: usize, + ) { + match with { + Some(ref with) => { + self.convert_item_list( + &with.props, + reference_position, + |ast_converter, prop| match prop { + PropOrSpread::Prop(prop) => match &**prop { + Prop::KeyValue(key_value_property) => { + ast_converter.store_import_attribute(key_value_property); + true + } + _ => panic!("Non key-value property in import declaration attributes"), + }, + PropOrSpread::Spread(_) => panic!("Spread in import declaration attributes"), + }, + ); + } + None => self.buffer.resize(self.buffer.len() + 4, 0), + } + } +} diff --git a/rust/parse_ast/src/ast_nodes/import_declaration.rs b/rust/parse_ast/src/ast_nodes/import_declaration.rs new file mode 100644 index 00000000000..c5f4798bf2a --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/import_declaration.rs @@ -0,0 +1,37 @@ +use swc_ecma_ast::ImportDecl; + +use crate::convert_ast::converter::ast_constants::{ + IMPORT_DECLARATION_ATTRIBUTES_OFFSET, IMPORT_DECLARATION_RESERVED_BYTES, + IMPORT_DECLARATION_SOURCE_OFFSET, IMPORT_DECLARATION_SPECIFIERS_OFFSET, TYPE_IMPORT_DECLARATION, +}; +use crate::convert_ast::converter::AstConverter; + +impl AstConverter<'_> { + pub(crate) fn store_import_declaration(&mut self, import_declaration: &ImportDecl) { + let end_position = self.add_type_and_start( + &TYPE_IMPORT_DECLARATION, + &import_declaration.span, + IMPORT_DECLARATION_RESERVED_BYTES, + false, + ); + // specifiers + self.convert_item_list( + &import_declaration.specifiers, + end_position + IMPORT_DECLARATION_SPECIFIERS_OFFSET, + |ast_converter, import_specifier| { + ast_converter.convert_import_specifier(import_specifier); + true + }, + ); + // source + self.update_reference_position(end_position + IMPORT_DECLARATION_SOURCE_OFFSET); + self.store_literal_string(&import_declaration.src); + // attributes + self.store_import_attributes( + &import_declaration.with, + end_position + IMPORT_DECLARATION_ATTRIBUTES_OFFSET, + ); + // end + self.add_end(end_position, &import_declaration.span); + } +} diff --git a/rust/parse_ast/src/ast_nodes/import_default_specifier.rs b/rust/parse_ast/src/ast_nodes/import_default_specifier.rs new file mode 100644 index 00000000000..8f436c237b3 --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/import_default_specifier.rs @@ -0,0 +1,17 @@ +use swc_ecma_ast::ImportDefaultSpecifier; + +use crate::convert_ast::converter::AstConverter; +use crate::store_import_default_specifier; + +impl AstConverter<'_> { + pub(crate) fn store_import_default_specifier( + &mut self, + import_default_specifier: &ImportDefaultSpecifier, + ) { + store_import_default_specifier!( + self, + span => &import_default_specifier.span, + local => [import_default_specifier.local, convert_identifier] + ); + } +} diff --git a/rust/parse_ast/src/ast_nodes/import_expression.rs b/rust/parse_ast/src/ast_nodes/import_expression.rs new file mode 100644 index 00000000000..101adee31d6 --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/import_expression.rs @@ -0,0 +1,29 @@ +use swc_common::Span; +use swc_ecma_ast::ExprOrSpread; + +use crate::convert_ast::converter::ast_constants::{ + IMPORT_EXPRESSION_OPTIONS_OFFSET, IMPORT_EXPRESSION_RESERVED_BYTES, + IMPORT_EXPRESSION_SOURCE_OFFSET, TYPE_IMPORT_EXPRESSION, +}; +use crate::convert_ast::converter::AstConverter; + +impl AstConverter<'_> { + pub(crate) fn store_import_expression(&mut self, span: &Span, arguments: &[ExprOrSpread]) { + let end_position = self.add_type_and_start( + &TYPE_IMPORT_EXPRESSION, + span, + IMPORT_EXPRESSION_RESERVED_BYTES, + false, + ); + // source + self.update_reference_position(end_position + IMPORT_EXPRESSION_SOURCE_OFFSET); + self.convert_expression(&arguments.first().unwrap().expr); + // options + if let Some(argument) = arguments.get(1) { + self.update_reference_position(end_position + IMPORT_EXPRESSION_OPTIONS_OFFSET); + self.convert_expression_or_spread(argument); + } + // end + self.add_end(end_position, span); + } +} diff --git a/rust/parse_ast/src/ast_nodes/import_namespace_specifier.rs b/rust/parse_ast/src/ast_nodes/import_namespace_specifier.rs new file mode 100644 index 00000000000..17ac2d9168a --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/import_namespace_specifier.rs @@ -0,0 +1,17 @@ +use swc_ecma_ast::ImportStarAsSpecifier; + +use crate::convert_ast::converter::AstConverter; +use crate::store_import_namespace_specifier; + +impl AstConverter<'_> { + pub(crate) fn store_import_namespace_specifier( + &mut self, + import_namespace_specifier: &ImportStarAsSpecifier, + ) { + store_import_namespace_specifier!( + self, + span => &import_namespace_specifier.span, + local => [import_namespace_specifier.local, convert_identifier] + ); + } +} diff --git a/rust/parse_ast/src/ast_nodes/import_specifier.rs b/rust/parse_ast/src/ast_nodes/import_specifier.rs new file mode 100644 index 00000000000..4a1e657f4aa --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/import_specifier.rs @@ -0,0 +1,15 @@ +use swc_ecma_ast::ImportNamedSpecifier; + +use crate::convert_ast::converter::AstConverter; +use crate::store_import_specifier; + +impl AstConverter<'_> { + pub(crate) fn store_import_specifier(&mut self, import_named_specifier: &ImportNamedSpecifier) { + store_import_specifier!( + self, + span => &import_named_specifier.span, + imported => [import_named_specifier.imported, convert_module_export_name], + local => [import_named_specifier.local, convert_identifier] + ); + } +} diff --git a/rust/parse_ast/src/ast_nodes/jsx_attribute.rs b/rust/parse_ast/src/ast_nodes/jsx_attribute.rs new file mode 100644 index 00000000000..c49fe3132bc --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/jsx_attribute.rs @@ -0,0 +1,15 @@ +use swc_ecma_ast::JSXAttr; + +use crate::convert_ast::converter::AstConverter; +use crate::store_jsx_attribute; + +impl AstConverter<'_> { + pub(crate) fn store_jsx_attribute(&mut self, jsx_attribute: &JSXAttr) { + store_jsx_attribute!( + self, + span => jsx_attribute.span, + name => [jsx_attribute.name, convert_jsx_attribute_name], + value => [jsx_attribute.value, convert_jsx_attribute_value] + ); + } +} diff --git a/rust/parse_ast/src/ast_nodes/jsx_closing_element.rs b/rust/parse_ast/src/ast_nodes/jsx_closing_element.rs new file mode 100644 index 00000000000..e75deaa4507 --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/jsx_closing_element.rs @@ -0,0 +1,14 @@ +use swc_ecma_ast::JSXClosingElement; + +use crate::convert_ast::converter::AstConverter; +use crate::store_jsx_closing_element; + +impl AstConverter<'_> { + pub(crate) fn store_jsx_closing_element(&mut self, jsx_closing_element: &JSXClosingElement) { + store_jsx_closing_element!( + self, + span => jsx_closing_element.span, + name => [jsx_closing_element.name, convert_jsx_element_name] + ); + } +} diff --git a/rust/parse_ast/src/ast_nodes/jsx_closing_fragment.rs b/rust/parse_ast/src/ast_nodes/jsx_closing_fragment.rs new file mode 100644 index 00000000000..759570c4142 --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/jsx_closing_fragment.rs @@ -0,0 +1,13 @@ +use swc_ecma_ast::JSXClosingFragment; + +use crate::convert_ast::converter::AstConverter; +use crate::store_jsx_closing_fragment; + +impl AstConverter<'_> { + pub(crate) fn store_jsx_closing_fragment(&mut self, jsx_closing_fragment: &JSXClosingFragment) { + store_jsx_closing_fragment!( + self, + span => jsx_closing_fragment.span + ); + } +} diff --git a/rust/parse_ast/src/ast_nodes/jsx_element.rs b/rust/parse_ast/src/ast_nodes/jsx_element.rs new file mode 100644 index 00000000000..378f3853598 --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/jsx_element.rs @@ -0,0 +1,16 @@ +use swc_ecma_ast::JSXElement; + +use crate::convert_ast::converter::AstConverter; +use crate::store_jsx_element; + +impl AstConverter<'_> { + pub(crate) fn store_jsx_element(&mut self, jsx_element: &JSXElement) { + store_jsx_element!( + self, + span => jsx_element.span, + openingElement => [jsx_element.opening, store_jsx_opening_element], + children => [jsx_element.children, convert_jsx_element_child], + closingElement => [jsx_element.closing, store_jsx_closing_element] + ); + } +} diff --git a/rust/parse_ast/src/ast_nodes/jsx_empty_expression.rs b/rust/parse_ast/src/ast_nodes/jsx_empty_expression.rs new file mode 100644 index 00000000000..2ef27eed5f0 --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/jsx_empty_expression.rs @@ -0,0 +1,16 @@ +use crate::convert_ast::converter::ast_constants::{ + JSX_EMPTY_EXPRESSION_RESERVED_BYTES, TYPE_JSX_EMPTY_EXPRESSION, +}; +use crate::convert_ast::converter::AstConverter; + +impl AstConverter<'_> { + pub(crate) fn store_jsx_empty_expression(&mut self, start: u32, end: u32) { + let end_position = self.add_type_and_explicit_start( + &TYPE_JSX_EMPTY_EXPRESSION, + start, + JSX_EMPTY_EXPRESSION_RESERVED_BYTES, + ); + // end + self.add_explicit_end(end_position, end); + } +} diff --git a/rust/parse_ast/src/ast_nodes/jsx_expression_container.rs b/rust/parse_ast/src/ast_nodes/jsx_expression_container.rs new file mode 100644 index 00000000000..4d88e111de8 --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/jsx_expression_container.rs @@ -0,0 +1,31 @@ +use swc_ecma_ast::{JSXExpr, JSXExprContainer}; + +use crate::convert_ast::converter::ast_constants::{ + JSX_EXPRESSION_CONTAINER_EXPRESSION_OFFSET, JSX_EXPRESSION_CONTAINER_RESERVED_BYTES, + TYPE_JSX_EXPRESSION_CONTAINER, +}; +use crate::convert_ast::converter::AstConverter; + +impl AstConverter<'_> { + pub(crate) fn store_jsx_expression_container(&mut self, jsx_expr_container: &JSXExprContainer) { + let end_position = self.add_type_and_start( + &TYPE_JSX_EXPRESSION_CONTAINER, + &jsx_expr_container.span, + JSX_EXPRESSION_CONTAINER_RESERVED_BYTES, + false, + ); + // expression + self.update_reference_position(end_position + JSX_EXPRESSION_CONTAINER_EXPRESSION_OFFSET); + match &jsx_expr_container.expr { + JSXExpr::Expr(expression) => { + self.convert_expression(expression); + } + JSXExpr::JSXEmptyExpr(jsx_empty_expr) => { + // The span does not consider the size of the container, hence we use the container span + self.store_jsx_empty_expression(jsx_expr_container.span.lo.0, jsx_empty_expr.span.hi.0 - 1); + } + } + // end + self.add_end(end_position, &jsx_expr_container.span); + } +} diff --git a/rust/parse_ast/src/ast_nodes/jsx_fragment.rs b/rust/parse_ast/src/ast_nodes/jsx_fragment.rs new file mode 100644 index 00000000000..df0a34bab54 --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/jsx_fragment.rs @@ -0,0 +1,16 @@ +use swc_ecma_ast::JSXFragment; + +use crate::convert_ast::converter::AstConverter; +use crate::store_jsx_fragment; + +impl AstConverter<'_> { + pub(crate) fn store_jsx_fragment(&mut self, jsx_fragment: &JSXFragment) { + store_jsx_fragment!( + self, + span => jsx_fragment.span, + openingFragment => [jsx_fragment.opening, store_jsx_opening_fragment], + children => [jsx_fragment.children, convert_jsx_element_child], + closingFragment => [jsx_fragment.closing, store_jsx_closing_fragment] + ); + } +} diff --git a/rust/parse_ast/src/ast_nodes/jsx_identifier.rs b/rust/parse_ast/src/ast_nodes/jsx_identifier.rs new file mode 100644 index 00000000000..ef9c1466881 --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/jsx_identifier.rs @@ -0,0 +1,14 @@ +use swc_common::Span; + +use crate::convert_ast::converter::AstConverter; +use crate::store_jsx_identifier; + +impl AstConverter<'_> { + pub(crate) fn store_jsx_identifier(&mut self, span: &Span, name: &str) { + store_jsx_identifier!( + self, + span => span, + name => name + ); + } +} diff --git a/rust/parse_ast/src/ast_nodes/jsx_member_expression.rs b/rust/parse_ast/src/ast_nodes/jsx_member_expression.rs new file mode 100644 index 00000000000..356951eab70 --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/jsx_member_expression.rs @@ -0,0 +1,29 @@ +use swc_ecma_ast::JSXMemberExpr; + +use crate::convert_ast::converter::ast_constants::{ + JSX_MEMBER_EXPRESSION_OBJECT_OFFSET, JSX_MEMBER_EXPRESSION_PROPERTY_OFFSET, + JSX_MEMBER_EXPRESSION_RESERVED_BYTES, TYPE_JSX_MEMBER_EXPRESSION, +}; +use crate::convert_ast::converter::AstConverter; + +impl AstConverter<'_> { + pub(crate) fn store_jsx_member_expression(&mut self, jsx_member_expression: &JSXMemberExpr) { + let end_position = self.add_type_and_start( + &TYPE_JSX_MEMBER_EXPRESSION, + &jsx_member_expression.span, + JSX_MEMBER_EXPRESSION_RESERVED_BYTES, + false, + ); + // object + self.update_reference_position(end_position + JSX_MEMBER_EXPRESSION_OBJECT_OFFSET); + self.convert_jsx_object(&jsx_member_expression.obj); + // property + self.update_reference_position(end_position + JSX_MEMBER_EXPRESSION_PROPERTY_OFFSET); + self.store_jsx_identifier( + &jsx_member_expression.prop.span, + &jsx_member_expression.prop.sym, + ); + // end + self.add_end(end_position, &jsx_member_expression.span); + } +} diff --git a/rust/parse_ast/src/ast_nodes/jsx_namespaced_name.rs b/rust/parse_ast/src/ast_nodes/jsx_namespaced_name.rs new file mode 100644 index 00000000000..5fc80c5be1b --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/jsx_namespaced_name.rs @@ -0,0 +1,29 @@ +use swc_ecma_ast::JSXNamespacedName; + +use crate::convert_ast::converter::ast_constants::{ + JSX_NAMESPACED_NAME_NAMESPACE_OFFSET, JSX_NAMESPACED_NAME_NAME_OFFSET, + JSX_NAMESPACED_NAME_RESERVED_BYTES, TYPE_JSX_NAMESPACED_NAME, +}; +use crate::convert_ast::converter::AstConverter; + +impl AstConverter<'_> { + pub(crate) fn store_jsx_namespaced_name(&mut self, jsx_namespaced_name: &JSXNamespacedName) { + let end_position = self.add_type_and_start( + &TYPE_JSX_NAMESPACED_NAME, + &jsx_namespaced_name.ns.span, + JSX_NAMESPACED_NAME_RESERVED_BYTES, + false, + ); + // namespace + self.update_reference_position(end_position + JSX_NAMESPACED_NAME_NAMESPACE_OFFSET); + self.store_jsx_identifier(&jsx_namespaced_name.ns.span, &jsx_namespaced_name.ns.sym); + // name + self.update_reference_position(end_position + JSX_NAMESPACED_NAME_NAME_OFFSET); + self.store_jsx_identifier( + &jsx_namespaced_name.name.span, + &jsx_namespaced_name.name.sym, + ); + // end + self.add_end(end_position, &jsx_namespaced_name.name.span); + } +} diff --git a/rust/parse_ast/src/ast_nodes/jsx_opening_element.rs b/rust/parse_ast/src/ast_nodes/jsx_opening_element.rs new file mode 100644 index 00000000000..f8687480069 --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/jsx_opening_element.rs @@ -0,0 +1,43 @@ +use swc_common::Spanned; +use swc_ecma_ast::JSXOpeningElement; + +use crate::convert_ast::converter::ast_constants::{ + JSX_OPENING_ELEMENT_ATTRIBUTES_OFFSET, JSX_OPENING_ELEMENT_NAME_OFFSET, + JSX_OPENING_ELEMENT_RESERVED_BYTES, TYPE_JSX_OPENING_ELEMENT, +}; +use crate::convert_ast::converter::AstConverter; +use crate::store_jsx_opening_element_flags; + +impl AstConverter<'_> { + pub(crate) fn store_jsx_opening_element(&mut self, jsx_opening_element: &JSXOpeningElement) { + let end_position = self.add_type_and_start( + &TYPE_JSX_OPENING_ELEMENT, + &jsx_opening_element.span, + JSX_OPENING_ELEMENT_RESERVED_BYTES, + false, + ); + // flags + store_jsx_opening_element_flags!( + self, + end_position, + selfClosing => jsx_opening_element.self_closing + ); + // name + self.update_reference_position(end_position + JSX_OPENING_ELEMENT_NAME_OFFSET); + self.convert_jsx_element_name(&jsx_opening_element.name); + // attributes + let mut previous_element_end = jsx_opening_element.name.span().hi.0; + self.convert_item_list_with_state( + &jsx_opening_element.attrs, + end_position + JSX_OPENING_ELEMENT_ATTRIBUTES_OFFSET, + &mut previous_element_end, + |ast_converter, jsx_attribute, previous_end| { + ast_converter.convert_jsx_attribute_or_spread(jsx_attribute, *previous_end); + *previous_end = jsx_attribute.span().hi.0; + (true, None) + }, + ); + // end + self.add_end(end_position, &jsx_opening_element.span); + } +} diff --git a/rust/parse_ast/src/ast_nodes/jsx_opening_fragment.rs b/rust/parse_ast/src/ast_nodes/jsx_opening_fragment.rs new file mode 100644 index 00000000000..3d06ec7a2a5 --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/jsx_opening_fragment.rs @@ -0,0 +1,13 @@ +use swc_ecma_ast::JSXOpeningFragment; + +use crate::convert_ast::converter::AstConverter; +use crate::store_jsx_opening_fragment; + +impl AstConverter<'_> { + pub(crate) fn store_jsx_opening_fragment(&mut self, jsx_opening_fragment: &JSXOpeningFragment) { + store_jsx_opening_fragment!( + self, + span => jsx_opening_fragment.span + ); + } +} diff --git a/rust/parse_ast/src/ast_nodes/jsx_spread_attribute.rs b/rust/parse_ast/src/ast_nodes/jsx_spread_attribute.rs new file mode 100644 index 00000000000..ad264b32ed0 --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/jsx_spread_attribute.rs @@ -0,0 +1,32 @@ +use swc_common::Spanned; +use swc_ecma_ast::SpreadElement; + +use crate::convert_ast::converter::analyze_code::find_first_occurrence_outside_comment; +use crate::convert_ast::converter::ast_constants::{ + JSX_SPREAD_ATTRIBUTE_ARGUMENT_OFFSET, JSX_SPREAD_ATTRIBUTE_RESERVED_BYTES, + TYPE_JSX_SPREAD_ATTRIBUTE, +}; +use crate::convert_ast::converter::AstConverter; + +impl AstConverter<'_> { + pub(crate) fn store_jsx_spread_attribute( + &mut self, + spread_element: &SpreadElement, + previous_element_end: u32, + ) { + let end_position = self.add_type_and_explicit_start( + &TYPE_JSX_SPREAD_ATTRIBUTE, + find_first_occurrence_outside_comment(self.code, b'{', previous_element_end), + JSX_SPREAD_ATTRIBUTE_RESERVED_BYTES, + ); + // argument + self.update_reference_position(end_position + JSX_SPREAD_ATTRIBUTE_ARGUMENT_OFFSET); + self.convert_expression(&spread_element.expr); + // end + self.add_explicit_end( + end_position, + find_first_occurrence_outside_comment(self.code, b'}', spread_element.expr.span().hi.0 - 1) + + 1, + ); + } +} diff --git a/rust/parse_ast/src/ast_nodes/jsx_spread_child.rs b/rust/parse_ast/src/ast_nodes/jsx_spread_child.rs new file mode 100644 index 00000000000..ea2fb976ca2 --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/jsx_spread_child.rs @@ -0,0 +1,14 @@ +use swc_ecma_ast::JSXSpreadChild; + +use crate::convert_ast::converter::AstConverter; +use crate::store_jsx_spread_child; + +impl AstConverter<'_> { + pub(crate) fn store_jsx_spread_child(&mut self, jsx_spread_child: &JSXSpreadChild) { + store_jsx_spread_child!( + self, + span => jsx_spread_child.span, + expression => [jsx_spread_child.expr, convert_expression] + ); + } +} diff --git a/rust/parse_ast/src/ast_nodes/jsx_text.rs b/rust/parse_ast/src/ast_nodes/jsx_text.rs new file mode 100644 index 00000000000..64cc91a57ab --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/jsx_text.rs @@ -0,0 +1,15 @@ +use swc_ecma_ast::JSXText; + +use crate::convert_ast::converter::AstConverter; +use crate::store_jsx_text; + +impl AstConverter<'_> { + pub(crate) fn store_jsx_text(&mut self, jsx_text: &JSXText) { + store_jsx_text!( + self, + span => jsx_text.span, + value => &jsx_text.value, + raw => &jsx_text.raw + ); + } +} diff --git a/rust/parse_ast/src/ast_nodes/labeled_statement.rs b/rust/parse_ast/src/ast_nodes/labeled_statement.rs new file mode 100644 index 00000000000..9734adb45e0 --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/labeled_statement.rs @@ -0,0 +1,15 @@ +use swc_ecma_ast::LabeledStmt; + +use crate::convert_ast::converter::AstConverter; +use crate::store_labeled_statement; + +impl AstConverter<'_> { + pub(crate) fn store_labeled_statement(&mut self, labeled_statement: &LabeledStmt) { + store_labeled_statement!( + self, + span => &labeled_statement.span, + label => [labeled_statement.label, convert_identifier], + body => [labeled_statement.body, convert_statement] + ); + } +} diff --git a/rust/parse_ast/src/ast_nodes/literal_big_int.rs b/rust/parse_ast/src/ast_nodes/literal_big_int.rs new file mode 100644 index 00000000000..190d02b67b3 --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/literal_big_int.rs @@ -0,0 +1,15 @@ +use swc_ecma_ast::BigInt; + +use crate::convert_ast::converter::AstConverter; +use crate::store_literal_big_int; + +impl AstConverter<'_> { + pub(crate) fn store_literal_bigint(&mut self, bigint: &BigInt) { + store_literal_big_int!( + self, + span => &bigint.span, + bigint => &bigint.value.to_str_radix(10), + raw => bigint.raw.as_ref().unwrap() + ); + } +} diff --git a/rust/parse_ast/src/ast_nodes/literal_boolean.rs b/rust/parse_ast/src/ast_nodes/literal_boolean.rs new file mode 100644 index 00000000000..088ae52dc35 --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/literal_boolean.rs @@ -0,0 +1,14 @@ +use swc_ecma_ast::Bool; + +use crate::convert_ast::converter::AstConverter; +use crate::{store_literal_boolean, store_literal_boolean_flags}; + +impl AstConverter<'_> { + pub(crate) fn store_literal_boolean(&mut self, literal: &Bool) { + store_literal_boolean!( + self, + span => &literal.span, + value => literal.value + ); + } +} diff --git a/rust/parse_ast/src/ast_nodes/literal_null.rs b/rust/parse_ast/src/ast_nodes/literal_null.rs new file mode 100644 index 00000000000..c17bea0d039 --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/literal_null.rs @@ -0,0 +1,13 @@ +use swc_ecma_ast::Null; + +use crate::convert_ast::converter::AstConverter; +use crate::store_literal_null; + +impl AstConverter<'_> { + pub(crate) fn store_literal_null(&mut self, literal: &Null) { + store_literal_null!( + self, + span => &literal.span + ); + } +} diff --git a/rust/parse_ast/src/ast_nodes/literal_number.rs b/rust/parse_ast/src/ast_nodes/literal_number.rs new file mode 100644 index 00000000000..295b0b0cd6e --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/literal_number.rs @@ -0,0 +1,15 @@ +use swc_ecma_ast::Number; + +use crate::convert_ast::converter::AstConverter; +use crate::store_literal_number; + +impl AstConverter<'_> { + pub(crate) fn store_literal_number(&mut self, literal: &Number) { + store_literal_number!( + self, + span => &literal.span, + raw => literal.raw, + value => literal.value + ); + } +} diff --git a/rust/parse_ast/src/ast_nodes/literal_reg_exp.rs b/rust/parse_ast/src/ast_nodes/literal_reg_exp.rs new file mode 100644 index 00000000000..595a62bc67e --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/literal_reg_exp.rs @@ -0,0 +1,15 @@ +use swc_ecma_ast::Regex; + +use crate::convert_ast::converter::AstConverter; +use crate::store_literal_reg_exp; + +impl AstConverter<'_> { + pub(crate) fn store_literal_regex(&mut self, regex: &Regex) { + store_literal_reg_exp!( + self, + span => ®ex.span, + flags => ®ex.flags, + pattern => ®ex.exp + ); + } +} diff --git a/rust/parse_ast/src/ast_nodes/literal_string.rs b/rust/parse_ast/src/ast_nodes/literal_string.rs new file mode 100644 index 00000000000..c8e2344077f --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/literal_string.rs @@ -0,0 +1,15 @@ +use swc_ecma_ast::Str; + +use crate::convert_ast::converter::AstConverter; +use crate::store_literal_string; + +impl AstConverter<'_> { + pub(crate) fn store_literal_string(&mut self, literal: &Str) { + store_literal_string!( + self, + span => &literal.span, + value => literal.value.as_atom().map_or("", |atom| atom.as_ref()), + raw => &literal.raw + ); + } +} diff --git a/rust/parse_ast/src/ast_nodes/logical_expression.rs b/rust/parse_ast/src/ast_nodes/logical_expression.rs new file mode 100644 index 00000000000..c65bb83e2d0 --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/logical_expression.rs @@ -0,0 +1,5 @@ +use crate::convert_ast::converter::AstConverter; + +impl AstConverter<'_> { + // included in binary_expression.rs +} diff --git a/rust/parse_ast/src/ast_nodes/member_expression.rs b/rust/parse_ast/src/ast_nodes/member_expression.rs new file mode 100644 index 00000000000..2453c900c32 --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/member_expression.rs @@ -0,0 +1,110 @@ +use swc_common::Span; +use swc_ecma_ast::{ + ComputedPropName, Expr, IdentName, MemberExpr, MemberProp, PrivateName, Super, SuperProp, + SuperPropExpr, +}; + +use crate::convert_ast::converter::ast_constants::{ + MEMBER_EXPRESSION_OBJECT_OFFSET, MEMBER_EXPRESSION_PROPERTY_OFFSET, + MEMBER_EXPRESSION_RESERVED_BYTES, TYPE_MEMBER_EXPRESSION, +}; +use crate::convert_ast::converter::AstConverter; +use crate::store_member_expression_flags; + +impl AstConverter<'_> { + pub(crate) fn store_member_expression( + &mut self, + span: &Span, + is_optional: bool, + object: &ExpressionOrSuper, + property: MemberOrSuperProp, + is_chained: bool, + ) { + let end_position = self.add_type_and_start( + &TYPE_MEMBER_EXPRESSION, + span, + MEMBER_EXPRESSION_RESERVED_BYTES, + false, + ); + // object + self.update_reference_position(end_position + MEMBER_EXPRESSION_OBJECT_OFFSET); + match object { + ExpressionOrSuper::Expression(Expr::OptChain(optional_chain_expression)) => { + self.store_chain_expression(optional_chain_expression, is_chained); + } + ExpressionOrSuper::Expression(Expr::Call(call_expression)) => { + self.convert_call_expression(call_expression, false, is_chained); + } + ExpressionOrSuper::Expression(Expr::Member(member_expression)) => { + self.convert_member_expression(member_expression, false, is_chained); + } + ExpressionOrSuper::Expression(expression) => { + self.convert_expression(expression); + } + ExpressionOrSuper::Super(super_token) => self.store_super_element(super_token), + } + // flags + store_member_expression_flags!( + self, + end_position, + computed => matches!(property, MemberOrSuperProp::Computed(_)), + optional => is_optional + ); + // property + self.update_reference_position(end_position + MEMBER_EXPRESSION_PROPERTY_OFFSET); + match property { + MemberOrSuperProp::Identifier(ident) => self.convert_identifier_name(ident), + MemberOrSuperProp::Computed(computed) => { + self.convert_expression(&computed.expr); + } + MemberOrSuperProp::PrivateName(private_name) => self.store_private_identifier(private_name), + } + // end + self.add_end(end_position, span); + } + + pub(crate) fn convert_member_expression( + &mut self, + member_expression: &MemberExpr, + is_optional: bool, + is_chained: bool, + ) { + self.store_member_expression( + &member_expression.span, + is_optional, + &ExpressionOrSuper::Expression(&member_expression.obj), + match &member_expression.prop { + MemberProp::Ident(identifier) => MemberOrSuperProp::Identifier(identifier), + MemberProp::PrivateName(private_name) => MemberOrSuperProp::PrivateName(private_name), + MemberProp::Computed(computed) => MemberOrSuperProp::Computed(computed), + }, + is_chained, + ); + } + + pub(crate) fn convert_super_property(&mut self, super_property: &SuperPropExpr) { + self.store_member_expression( + &super_property.span, + false, + &ExpressionOrSuper::Super(&super_property.obj), + match &super_property.prop { + SuperProp::Ident(identifier) => MemberOrSuperProp::Identifier(identifier), + SuperProp::Computed(computed_property_name) => { + MemberOrSuperProp::Computed(computed_property_name) + } + }, + false, + ); + } +} + +pub(crate) enum MemberOrSuperProp<'a> { + Identifier(&'a IdentName), + PrivateName(&'a PrivateName), + Computed(&'a ComputedPropName), +} + +pub(crate) enum ExpressionOrSuper<'a> { + Expression(&'a Expr), + Super(&'a Super), +} diff --git a/rust/parse_ast/src/ast_nodes/meta_property.rs b/rust/parse_ast/src/ast_nodes/meta_property.rs new file mode 100644 index 00000000000..97994fe41d9 --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/meta_property.rs @@ -0,0 +1,54 @@ +use swc_ecma_ast::{MetaPropExpr, MetaPropKind}; + +use crate::convert_ast::converter::ast_constants::{ + META_PROPERTY_META_OFFSET, META_PROPERTY_PROPERTY_OFFSET, META_PROPERTY_RESERVED_BYTES, + TYPE_META_PROPERTY, +}; +use crate::convert_ast::converter::AstConverter; + +impl AstConverter<'_> { + pub(crate) fn store_meta_property(&mut self, meta_property_expression: &MetaPropExpr) { + let end_position = self.add_type_and_start( + &TYPE_META_PROPERTY, + &meta_property_expression.span, + META_PROPERTY_RESERVED_BYTES, + false, + ); + match meta_property_expression.kind { + MetaPropKind::ImportMeta => { + // meta + self.update_reference_position(end_position + META_PROPERTY_META_OFFSET); + self.store_identifier( + meta_property_expression.span.lo.0 - 1, + meta_property_expression.span.lo.0 + 5, + "import", + ); + // property + self.update_reference_position(end_position + META_PROPERTY_PROPERTY_OFFSET); + self.store_identifier( + meta_property_expression.span.hi.0 - 5, + meta_property_expression.span.hi.0 - 1, + "meta", + ); + } + MetaPropKind::NewTarget => { + // meta + self.update_reference_position(end_position + META_PROPERTY_META_OFFSET); + self.store_identifier( + meta_property_expression.span.lo.0 - 1, + meta_property_expression.span.lo.0 + 2, + "new", + ); + // property + self.update_reference_position(end_position + META_PROPERTY_PROPERTY_OFFSET); + self.store_identifier( + meta_property_expression.span.hi.0 - 7, + meta_property_expression.span.hi.0 - 1, + "target", + ); + } + } + // end + self.add_end(end_position, &meta_property_expression.span); + } +} diff --git a/rust/parse_ast/src/ast_nodes/method_definition.rs b/rust/parse_ast/src/ast_nodes/method_definition.rs new file mode 100644 index 00000000000..e783e552acb --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/method_definition.rs @@ -0,0 +1,159 @@ +use swc_common::{Span, Spanned}; +use swc_ecma_ast::{ + ClassMethod, Constructor, Function, MethodKind, ParamOrTsParamProp, Pat, PrivateMethod, + PrivateName, PropName, +}; + +use crate::convert_ast::converter::analyze_code::find_first_occurrence_outside_comment; +use crate::convert_ast::converter::ast_constants::{ + METHOD_DEFINITION_DECORATORS_OFFSET, METHOD_DEFINITION_KEY_OFFSET, METHOD_DEFINITION_KIND_OFFSET, + METHOD_DEFINITION_RESERVED_BYTES, METHOD_DEFINITION_VALUE_OFFSET, TYPE_FUNCTION_EXPRESSION, + TYPE_METHOD_DEFINITION, +}; +use crate::convert_ast::converter::string_constants::{ + STRING_CONSTRUCTOR, STRING_GET, STRING_METHOD, STRING_SET, +}; +use crate::convert_ast::converter::AstConverter; +use crate::store_method_definition_flags; + +impl AstConverter<'_> { + pub(crate) fn store_method_definition( + &mut self, + span: &Span, + kind: &MethodKind, + is_static: bool, + key: PropOrPrivateName, + is_computed: bool, + function: &Function, + ) { + let end_position = self.add_type_and_start( + &TYPE_METHOD_DEFINITION, + span, + METHOD_DEFINITION_RESERVED_BYTES, + false, + ); + // flags + store_method_definition_flags!(self, end_position, static => is_static, computed => is_computed); + // decorators + self.convert_item_list( + &function.decorators, + end_position + METHOD_DEFINITION_DECORATORS_OFFSET, + |ast_convertor, decorator| { + ast_convertor.store_decorator(decorator); + true + }, + ); + // kind + let kind_position = end_position + METHOD_DEFINITION_KIND_OFFSET; + self.buffer[kind_position..kind_position + 4].copy_from_slice(match kind { + MethodKind::Method => &STRING_METHOD, + MethodKind::Getter => &STRING_GET, + MethodKind::Setter => &STRING_SET, + }); + // key + self.update_reference_position(end_position + METHOD_DEFINITION_KEY_OFFSET); + let key_end = match key { + PropOrPrivateName::PropName(prop_name) => { + self.convert_property_name(prop_name); + prop_name.span().hi.0 - 1 + } + PropOrPrivateName::PrivateName(private_name) => { + self.store_private_identifier(private_name); + private_name.span.hi.0 - 1 + } + }; + // value + self.update_reference_position(end_position + METHOD_DEFINITION_VALUE_OFFSET); + let function_start = find_first_occurrence_outside_comment(self.code, b'(', key_end); + let parameters: Vec<&Pat> = function.params.iter().map(|param| ¶m.pat).collect(); + self.store_function_node( + &TYPE_FUNCTION_EXPRESSION, + function_start, + function.span.hi.0 - 1, + function.is_async, + function.is_generator, + None, + ¶meters, + function.body.as_ref().unwrap(), + false, + ); + // end + self.add_end(end_position, span); + } + + pub(crate) fn convert_constructor(&mut self, constructor: &Constructor) { + let end_position = self.add_type_and_start( + &TYPE_METHOD_DEFINITION, + &constructor.span, + METHOD_DEFINITION_RESERVED_BYTES, + false, + ); + // key + self.update_reference_position(end_position + METHOD_DEFINITION_KEY_OFFSET); + self.convert_property_name(&constructor.key); + // flags + store_method_definition_flags!(self, end_position, static => false, computed => false); + // kind + let kind_position = end_position + METHOD_DEFINITION_KIND_OFFSET; + self.buffer[kind_position..kind_position + 4].copy_from_slice(&STRING_CONSTRUCTOR); + // value + match &constructor.body { + Some(block_statement) => { + self.update_reference_position(end_position + METHOD_DEFINITION_VALUE_OFFSET); + let key_end = constructor.key.span().hi.0 - 1; + let function_start = find_first_occurrence_outside_comment(self.code, b'(', key_end); + let parameters: Vec<&Pat> = constructor + .params + .iter() + .map(|param| match param { + ParamOrTsParamProp::Param(param) => ¶m.pat, + ParamOrTsParamProp::TsParamProp(_) => panic!("TsParamProp in constructor"), + }) + .collect(); + self.store_function_node( + &TYPE_FUNCTION_EXPRESSION, + function_start, + block_statement.span.hi.0 - 1, + false, + false, + None, + ¶meters, + block_statement, + false, + ); + } + None => { + panic!("Getter property without body"); + } + } + // end + self.add_end(end_position, &constructor.span); + } + + pub(crate) fn convert_method(&mut self, method: &ClassMethod) { + self.store_method_definition( + &method.span, + &method.kind, + method.is_static, + PropOrPrivateName::PropName(&method.key), + matches!(method.key, PropName::Computed(_)), + &method.function, + ); + } + + pub(crate) fn convert_private_method(&mut self, private_method: &PrivateMethod) { + self.store_method_definition( + &private_method.span, + &private_method.kind, + private_method.is_static, + PropOrPrivateName::PrivateName(&private_method.key), + false, + &private_method.function, + ); + } +} + +pub(crate) enum PropOrPrivateName<'a> { + PropName(&'a PropName), + PrivateName(&'a PrivateName), +} diff --git a/rust/parse_ast/src/ast_nodes/mod.rs b/rust/parse_ast/src/ast_nodes/mod.rs new file mode 100644 index 00000000000..ab7560659a2 --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/mod.rs @@ -0,0 +1,96 @@ +pub(crate) mod array_expression; +pub(crate) mod array_pattern; +pub(crate) mod arrow_function_expression; +pub(crate) mod assignment_expression; +pub(crate) mod assignment_pattern; +pub(crate) mod await_expression; +pub(crate) mod binary_expression; +pub(crate) mod block_statement; +pub(crate) mod break_statement; +pub(crate) mod call_expression; +pub(crate) mod catch_clause; +pub(crate) mod chain_expression; +pub(crate) mod class_body; +pub(crate) mod class_declaration; +pub(crate) mod class_expression; +pub(crate) mod conditional_expression; +pub(crate) mod continue_statement; +pub(crate) mod debugger_statement; +pub(crate) mod decorator; +pub(crate) mod directive; +pub(crate) mod do_while_statement; +pub(crate) mod empty_statement; +pub(crate) mod export_all_declaration; +pub(crate) mod export_default_declaration; +pub(crate) mod export_named_declaration; +pub(crate) mod export_specifier; +pub(crate) mod expression_statement; +pub(crate) mod for_in_statement; +pub(crate) mod for_of_statement; +pub(crate) mod for_statement; +pub(crate) mod function_declaration; +pub(crate) mod function_expression; +pub(crate) mod identifier; +pub(crate) mod if_statement; +pub(crate) mod import_attribute; +pub(crate) mod import_declaration; +pub(crate) mod import_default_specifier; +pub(crate) mod import_expression; +pub(crate) mod import_namespace_specifier; +pub(crate) mod import_specifier; +pub(crate) mod jsx_attribute; +pub(crate) mod jsx_closing_element; +pub(crate) mod jsx_closing_fragment; +pub(crate) mod jsx_element; +pub(crate) mod jsx_empty_expression; +pub(crate) mod jsx_expression_container; +pub(crate) mod jsx_fragment; +pub(crate) mod jsx_identifier; +pub(crate) mod jsx_member_expression; +pub(crate) mod jsx_namespaced_name; +pub(crate) mod jsx_opening_element; +pub(crate) mod jsx_opening_fragment; +pub(crate) mod jsx_spread_attribute; +pub(crate) mod jsx_spread_child; +pub(crate) mod jsx_text; +pub(crate) mod labeled_statement; +pub(crate) mod literal_big_int; +pub(crate) mod literal_boolean; +pub(crate) mod literal_null; +pub(crate) mod literal_number; +pub(crate) mod literal_reg_exp; +pub(crate) mod literal_string; +pub(crate) mod logical_expression; +pub(crate) mod member_expression; +pub(crate) mod meta_property; +pub(crate) mod method_definition; +pub(crate) mod new_expression; +pub(crate) mod object_expression; +pub(crate) mod object_pattern; +pub(crate) mod panic_error; +pub(crate) mod parse_error; +pub(crate) mod private_identifier; +pub(crate) mod program; +pub(crate) mod property; +pub(crate) mod property_definition; +pub(crate) mod rest_element; +pub(crate) mod return_statement; +pub(crate) mod sequence_expression; +pub(crate) mod shared; +pub(crate) mod spread_element; +pub(crate) mod static_block; +pub(crate) mod super_element; +pub(crate) mod switch_case; +pub(crate) mod switch_statement; +pub(crate) mod tagged_template_expression; +pub(crate) mod template_element; +pub(crate) mod template_literal; +pub(crate) mod this_expression; +pub(crate) mod throw_statement; +pub(crate) mod try_statement; +pub(crate) mod unary_expression; +pub(crate) mod update_expression; +pub(crate) mod variable_declaration; +pub(crate) mod variable_declarator; +pub(crate) mod while_statement; +pub(crate) mod yield_expression; diff --git a/rust/parse_ast/src/ast_nodes/new_expression.rs b/rust/parse_ast/src/ast_nodes/new_expression.rs new file mode 100644 index 00000000000..26fd14128f3 --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/new_expression.rs @@ -0,0 +1,52 @@ +use swc_common::Spanned; +use swc_ecma_ast::NewExpr; + +use crate::convert_ast::annotations::AnnotationKind; +use crate::convert_ast::converter::ast_constants::{ + NEW_EXPRESSION_ANNOTATIONS_OFFSET, NEW_EXPRESSION_ARGUMENTS_OFFSET, NEW_EXPRESSION_CALLEE_OFFSET, + NEW_EXPRESSION_RESERVED_BYTES, TYPE_NEW_EXPRESSION, +}; +use crate::convert_ast::converter::{convert_annotation, AstConverter}; + +impl AstConverter<'_> { + pub(crate) fn store_new_expression(&mut self, new_expression: &NewExpr) { + let end_position = self.add_type_and_start( + &TYPE_NEW_EXPRESSION, + &new_expression.span, + NEW_EXPRESSION_RESERVED_BYTES, + true, + ); + self.move_to_specific_index(new_expression.callee.span_lo().0 - 2); + // annotations + let annotations = self + .index_converter + .take_collected_annotations(AnnotationKind::Pure); + if !annotations.is_empty() { + self.convert_item_list( + &annotations, + end_position + NEW_EXPRESSION_ANNOTATIONS_OFFSET, + |ast_converter, annotation| { + convert_annotation(&mut ast_converter.buffer, annotation); + true + }, + ); + } + // callee + self.update_reference_position(end_position + NEW_EXPRESSION_CALLEE_OFFSET); + self.convert_expression(&new_expression.callee); + // arguments + self.convert_item_list( + match &new_expression.args { + Some(arguments) => arguments, + None => &[], + }, + end_position + NEW_EXPRESSION_ARGUMENTS_OFFSET, + |ast_converter, expression_or_spread| { + ast_converter.convert_expression_or_spread(expression_or_spread); + true + }, + ); + // end + self.add_end(end_position, &new_expression.span); + } +} diff --git a/rust/parse_ast/src/ast_nodes/object_expression.rs b/rust/parse_ast/src/ast_nodes/object_expression.rs new file mode 100644 index 00000000000..8d34d54b6e3 --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/object_expression.rs @@ -0,0 +1,14 @@ +use swc_ecma_ast::ObjectLit; + +use crate::convert_ast::converter::AstConverter; +use crate::store_object_expression; + +impl AstConverter<'_> { + pub(crate) fn store_object_expression(&mut self, object_literal: &ObjectLit) { + store_object_expression!( + self, + span => &object_literal.span, + properties => [object_literal.props, convert_property_or_spread] + ); + } +} diff --git a/rust/parse_ast/src/ast_nodes/object_pattern.rs b/rust/parse_ast/src/ast_nodes/object_pattern.rs new file mode 100644 index 00000000000..66fad8638df --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/object_pattern.rs @@ -0,0 +1,14 @@ +use swc_ecma_ast::ObjectPat; + +use crate::convert_ast::converter::AstConverter; +use crate::store_object_pattern; + +impl AstConverter<'_> { + pub(crate) fn store_object_pattern(&mut self, object_pattern: &ObjectPat) { + store_object_pattern!( + self, + span => &object_pattern.span, + properties => [object_pattern.props, convert_object_pattern_property] + ); + } +} diff --git a/rust/parse_ast/src/ast_nodes/panic_error.rs b/rust/parse_ast/src/ast_nodes/panic_error.rs new file mode 100644 index 00000000000..bf290bcb4d7 --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/panic_error.rs @@ -0,0 +1,16 @@ +use crate::convert_ast::converter::ast_constants::{ + PANIC_ERROR_MESSAGE_OFFSET, PANIC_ERROR_RESERVED_BYTES, TYPE_PANIC_ERROR, +}; +use crate::convert_ast::converter::{convert_string, update_reference_position}; + +pub(crate) fn get_panic_error_buffer(message: &str) -> Vec { + // type + let mut buffer = TYPE_PANIC_ERROR.to_vec(); + // reserve for start and end even though they are unused + let end_position = buffer.len() + 4; + buffer.resize(end_position + PANIC_ERROR_RESERVED_BYTES, 0); + // message + update_reference_position(&mut buffer, end_position + PANIC_ERROR_MESSAGE_OFFSET); + convert_string(&mut buffer, message); + buffer +} diff --git a/rust/parse_ast/src/ast_nodes/parse_error.rs b/rust/parse_ast/src/ast_nodes/parse_error.rs new file mode 100644 index 00000000000..22026546025 --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/parse_error.rs @@ -0,0 +1,18 @@ +use crate::convert_ast::converter::ast_constants::{ + PARSE_ERROR_MESSAGE_OFFSET, PARSE_ERROR_RESERVED_BYTES, TYPE_PARSE_ERROR, +}; +use crate::convert_ast::converter::update_reference_position; + +pub(crate) fn get_parse_error_buffer(error_buffer: &[u8], utf_16_pos: &u32) -> Vec { + // type + let mut buffer = TYPE_PARSE_ERROR.to_vec(); + // start + buffer.extend_from_slice(&utf_16_pos.to_ne_bytes()); + // end + let end_position = buffer.len(); + buffer.resize(end_position + PARSE_ERROR_RESERVED_BYTES, 0); + // message, the string is already converted to a buffer via convert_string + update_reference_position(&mut buffer, end_position + PARSE_ERROR_MESSAGE_OFFSET); + buffer.extend_from_slice(&error_buffer[4..]); + buffer +} diff --git a/rust/parse_ast/src/ast_nodes/private_identifier.rs b/rust/parse_ast/src/ast_nodes/private_identifier.rs new file mode 100644 index 00000000000..83ebb2be256 --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/private_identifier.rs @@ -0,0 +1,14 @@ +use swc_ecma_ast::PrivateName; + +use crate::convert_ast::converter::AstConverter; +use crate::store_private_identifier; + +impl AstConverter<'_> { + pub(crate) fn store_private_identifier(&mut self, private_name: &PrivateName) { + store_private_identifier!( + self, + span => &private_name.span, + name => &private_name.name + ); + } +} diff --git a/rust/parse_ast/src/ast_nodes/program.rs b/rust/parse_ast/src/ast_nodes/program.rs new file mode 100644 index 00000000000..2c5541eede6 --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/program.rs @@ -0,0 +1,91 @@ +use swc_ecma_ast::{Expr, Lit, ModuleItem, Program, Stmt}; + +use crate::convert_ast::converter::ast_constants::{ + PROGRAM_BODY_OFFSET, PROGRAM_INVALID_ANNOTATIONS_OFFSET, PROGRAM_RESERVED_BYTES, TYPE_PROGRAM, +}; +use crate::convert_ast::converter::{convert_annotation, AstConverter}; + +impl AstConverter<'_> { + pub(crate) fn store_program(&mut self, body: ModuleItemsOrStatements) { + let end_position = + self.add_type_and_explicit_start(&TYPE_PROGRAM, 0u32, PROGRAM_RESERVED_BYTES); + // body + let mut keep_checking_directives = true; + match body { + ModuleItemsOrStatements::ModuleItems(module_items) => { + self.convert_item_list_with_state( + module_items, + end_position + PROGRAM_BODY_OFFSET, + &mut keep_checking_directives, + |ast_converter, module_item, can_be_directive| { + if *can_be_directive { + if let ModuleItem::Stmt(Stmt::Expr(expression)) = module_item { + if let Expr::Lit(Lit::Str(string)) = &*expression.expr { + ast_converter.store_directive(expression, string.value.as_atom().unwrap()); + return (true, None); + } + }; + *can_be_directive = false; + } + + let mut module_item_insert_position = ast_converter.buffer.len() as u32 >> 2; + ast_converter.convert_module_item(module_item, &mut module_item_insert_position); + (true, Some(module_item_insert_position)) + }, + ); + } + ModuleItemsOrStatements::Statements(statements) => { + self.convert_item_list_with_state( + statements, + end_position + PROGRAM_BODY_OFFSET, + &mut keep_checking_directives, + |ast_converter, statement, can_be_directive| { + if *can_be_directive { + if let Stmt::Expr(expression) = statement { + if let Expr::Lit(Lit::Str(string)) = &*expression.expr { + ast_converter.store_directive(expression, string.value.as_atom().unwrap()); + return (true, None); + } + }; + *can_be_directive = false; + } + ast_converter.convert_statement(statement); + (true, None) + }, + ); + } + } + // end + self.add_explicit_end(end_position, self.code.len() as u32); + // annotations, these need to come after end so that trailing comments are + // included + self.index_converter.invalidate_collected_annotations(); + let invalid_annotations = self.index_converter.take_invalid_annotations(); + if !invalid_annotations.is_empty() { + self.convert_item_list( + &invalid_annotations, + end_position + PROGRAM_INVALID_ANNOTATIONS_OFFSET, + |ast_converter, annotation| { + convert_annotation(&mut ast_converter.buffer, annotation); + true + }, + ); + } + } + + pub(crate) fn convert_program(&mut self, node: &Program) { + match node { + Program::Module(module) => { + self.store_program(ModuleItemsOrStatements::ModuleItems(&module.body)); + } + Program::Script(script) => { + self.store_program(ModuleItemsOrStatements::Statements(&script.body)); + } + } + } +} + +pub(crate) enum ModuleItemsOrStatements<'a> { + ModuleItems(&'a Vec), + Statements(&'a Vec), +} diff --git a/rust/parse_ast/src/ast_nodes/property.rs b/rust/parse_ast/src/ast_nodes/property.rs new file mode 100644 index 00000000000..d896048fe3c --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/property.rs @@ -0,0 +1,248 @@ +use swc_common::{Span, Spanned}; +use swc_ecma_ast::{ + AssignPatProp, BlockStmt, Expr, GetterProp, Ident, KeyValuePatProp, KeyValueProp, MethodProp, + Pat, Prop, PropName, SetterProp, +}; + +use crate::ast_nodes::assignment_pattern::PatternOrIdentifier; +use crate::convert_ast::converter::analyze_code::find_first_occurrence_outside_comment; +use crate::convert_ast::converter::ast_constants::{ + PROPERTY_KEY_OFFSET, PROPERTY_KIND_OFFSET, PROPERTY_RESERVED_BYTES, PROPERTY_VALUE_OFFSET, + TYPE_FUNCTION_EXPRESSION, TYPE_PROPERTY, +}; +use crate::convert_ast::converter::string_constants::{STRING_GET, STRING_INIT, STRING_SET}; +use crate::convert_ast::converter::AstConverter; +use crate::store_property_flags; + +impl AstConverter<'_> { + pub(crate) fn convert_property(&mut self, property: &Prop) { + match property { + Prop::Getter(getter_property) => self.convert_getter_property(getter_property), + Prop::KeyValue(key_value_property) => self.convert_key_value_property(key_value_property), + Prop::Method(method_property) => self.convert_method_property(method_property), + Prop::Setter(setter_property) => self.convert_setter_property(setter_property), + Prop::Shorthand(identifier) => self.convert_shorthand_property(identifier), + Prop::Assign(_) => unimplemented!("Cannot convert Prop::Assign"), + } + } + + pub(crate) fn convert_assignment_pattern_property( + &mut self, + assignment_pattern_property: &AssignPatProp, + ) { + self.store_shorthand_property( + &assignment_pattern_property.span, + &assignment_pattern_property.key, + &assignment_pattern_property.value, + ); + } + + pub(crate) fn convert_key_value_pattern_property( + &mut self, + key_value_pattern_property: &KeyValuePatProp, + ) { + self.store_key_value_property( + &key_value_pattern_property.key, + PatternOrExpression::Pattern(&key_value_pattern_property.value), + ); + } + + fn store_key_value_property(&mut self, property_name: &PropName, value: PatternOrExpression) { + let end_position = self.add_type_and_start( + &TYPE_PROPERTY, + &property_name.span(), + PROPERTY_RESERVED_BYTES, + false, + ); + // key + self.update_reference_position(end_position + PROPERTY_KEY_OFFSET); + self.convert_property_name(property_name); + // flags + store_property_flags!( + self, + end_position, + method => false, + shorthand => false, + computed => matches!(property_name, PropName::Computed(_)) + ); + // kind + let kind_position = end_position + PROPERTY_KIND_OFFSET; + self.buffer[kind_position..kind_position + 4].copy_from_slice(&STRING_INIT); + // value + self.update_reference_position(end_position + PROPERTY_VALUE_OFFSET); + match value { + PatternOrExpression::Pattern(pattern) => self.convert_pattern(pattern), + PatternOrExpression::Expression(expression) => self.convert_expression(expression), + }; + // end + self.add_end(end_position, &value.span()); + } + + fn store_getter_setter_property( + &mut self, + span: &Span, + kind: &[u8; 4], + key: &PropName, + body: &Option, + param: Option<&Pat>, + ) { + let end_position = + self.add_type_and_start(&TYPE_PROPERTY, span, PROPERTY_RESERVED_BYTES, false); + // key + self.update_reference_position(end_position + PROPERTY_KEY_OFFSET); + self.convert_property_name(key); + let key_end = key.span().hi.0 - 1; + // flags + store_property_flags!( + self, + end_position, + method => false, + shorthand => false, + computed => matches!(key, PropName::Computed(_)) + ); + // kind + let kind_position = end_position + PROPERTY_KIND_OFFSET; + self.buffer[kind_position..kind_position + 4].copy_from_slice(kind); + // value + let block_statement = body.as_ref().expect("Getter/setter property without body"); + self.update_reference_position(end_position + PROPERTY_VALUE_OFFSET); + let parameters = match param { + Some(pattern) => vec![pattern], + None => vec![], + }; + self.store_function_node( + &TYPE_FUNCTION_EXPRESSION, + find_first_occurrence_outside_comment(self.code, b'(', key_end), + block_statement.span.hi.0 - 1, + false, + false, + None, + ¶meters, + block_statement, + false, + ); + // end + self.add_end(end_position, span); + } + + fn convert_method_property(&mut self, method_property: &MethodProp) { + let end_position = self.add_type_and_start( + &TYPE_PROPERTY, + &method_property.function.span, + PROPERTY_RESERVED_BYTES, + false, + ); + // key + self.update_reference_position(end_position + PROPERTY_KEY_OFFSET); + self.convert_property_name(&method_property.key); + let key_end = &method_property.key.span().hi.0 - 1; + let function_start = find_first_occurrence_outside_comment(self.code, b'(', key_end); + // flags + store_property_flags!( + self, + end_position, + method => true, + shorthand => false, + computed => matches!(&method_property.key, PropName::Computed(_)) + ); + // kind + let kind_position = end_position + PROPERTY_KIND_OFFSET; + self.buffer[kind_position..kind_position + 4].copy_from_slice(&STRING_INIT); + // value + self.update_reference_position(end_position + PROPERTY_VALUE_OFFSET); + let function = &method_property.function; + let parameters: Vec<&Pat> = function.params.iter().map(|param| ¶m.pat).collect(); + self.store_function_node( + &TYPE_FUNCTION_EXPRESSION, + function_start, + function.span.hi.0 - 1, + function.is_async, + function.is_generator, + None, + ¶meters, + function.body.as_ref().unwrap(), + false, + ); + // end + self.add_end(end_position, &method_property.function.span); + } + + fn store_shorthand_property( + &mut self, + span: &Span, + key: &Ident, + assignment_value: &Option>, + ) { + let end_position = + self.add_type_and_start(&TYPE_PROPERTY, span, PROPERTY_RESERVED_BYTES, false); + match assignment_value { + Some(value) => { + // value + self.update_reference_position(end_position + PROPERTY_VALUE_OFFSET); + let left_position = self.store_assignment_pattern_and_get_left_position( + span, + PatternOrIdentifier::Identifier(key), + value, + ); + // key, reuse identifier to avoid converting positions out of order + let key_position = end_position + PROPERTY_KEY_OFFSET; + self.buffer[key_position..key_position + 4].copy_from_slice(&left_position.to_ne_bytes()); + } + None => { + // value + self.update_reference_position(end_position + PROPERTY_VALUE_OFFSET); + self.convert_identifier(key); + } + } + // flags + store_property_flags!( + self, + end_position, + method => false, + shorthand => true, + computed => false + ); + // kind + let kind_position = end_position + PROPERTY_KIND_OFFSET; + self.buffer[kind_position..kind_position + 4].copy_from_slice(&STRING_INIT); + // end + self.add_end(end_position, span); + } + + fn convert_getter_property(&mut self, getter_property: &GetterProp) { + self.store_getter_setter_property( + &getter_property.span, + &STRING_GET, + &getter_property.key, + &getter_property.body, + None, + ); + } + + fn convert_key_value_property(&mut self, key_value_property: &KeyValueProp) { + self.store_key_value_property( + &key_value_property.key, + PatternOrExpression::Expression(&key_value_property.value), + ); + } + + fn convert_setter_property(&mut self, setter_property: &SetterProp) { + self.store_getter_setter_property( + &setter_property.span, + &STRING_SET, + &setter_property.key, + &setter_property.body, + Some(&*setter_property.param), + ); + } + + fn convert_shorthand_property(&mut self, identifier: &Ident) { + self.store_shorthand_property(&identifier.span, identifier, &None); + } +} + +#[derive(Spanned)] +pub(crate) enum PatternOrExpression<'a> { + Pattern(&'a Pat), + Expression(&'a Expr), +} diff --git a/rust/parse_ast/src/ast_nodes/property_definition.rs b/rust/parse_ast/src/ast_nodes/property_definition.rs new file mode 100644 index 00000000000..b9b4ac2dcca --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/property_definition.rs @@ -0,0 +1,77 @@ +use swc_common::Span; +use swc_ecma_ast::{ClassProp, Decorator, Expr, PrivateProp, PropName}; + +use crate::ast_nodes::method_definition::PropOrPrivateName; +use crate::convert_ast::converter::ast_constants::{ + PROPERTY_DEFINITION_DECORATORS_OFFSET, PROPERTY_DEFINITION_KEY_OFFSET, + PROPERTY_DEFINITION_RESERVED_BYTES, PROPERTY_DEFINITION_VALUE_OFFSET, TYPE_PROPERTY_DEFINITION, +}; +use crate::convert_ast::converter::AstConverter; +use crate::store_property_definition_flags; + +impl AstConverter<'_> { + pub(crate) fn store_property_definition( + &mut self, + span: &Span, + is_computed: bool, + is_static: bool, + key: PropOrPrivateName, + value: &Option<&Expr>, + decorators: &[Decorator], + ) { + let end_position = self.add_type_and_start( + &TYPE_PROPERTY_DEFINITION, + span, + PROPERTY_DEFINITION_RESERVED_BYTES, + false, + ); + // flags + store_property_definition_flags!(self, end_position, static => is_static, computed => is_computed); + // decorators + self.convert_item_list( + decorators, + end_position + PROPERTY_DEFINITION_DECORATORS_OFFSET, + |ast_converter, decorator| { + ast_converter.store_decorator(decorator); + true + }, + ); + // key + self.update_reference_position(end_position + PROPERTY_DEFINITION_KEY_OFFSET); + match key { + PropOrPrivateName::PropName(prop_name) => { + self.convert_property_name(prop_name); + } + PropOrPrivateName::PrivateName(private_name) => self.store_private_identifier(private_name), + } + // value + if let Some(expression) = value { + self.update_reference_position(end_position + PROPERTY_DEFINITION_VALUE_OFFSET); + self.convert_expression(expression); + } + // end + self.add_end(end_position, span); + } + + pub(crate) fn convert_class_property(&mut self, class_property: &ClassProp) { + self.store_property_definition( + &class_property.span, + matches!(&class_property.key, PropName::Computed(_)), + class_property.is_static, + PropOrPrivateName::PropName(&class_property.key), + &class_property.value.as_deref(), + &class_property.decorators, + ); + } + + pub(crate) fn convert_private_property(&mut self, private_property: &PrivateProp) { + self.store_property_definition( + &private_property.span, + false, + private_property.is_static, + PropOrPrivateName::PrivateName(&private_property.key), + &private_property.value.as_deref(), + &private_property.decorators, + ); + } +} diff --git a/rust/parse_ast/src/ast_nodes/rest_element.rs b/rust/parse_ast/src/ast_nodes/rest_element.rs new file mode 100644 index 00000000000..f856c7b0705 --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/rest_element.rs @@ -0,0 +1,22 @@ +use swc_ecma_ast::RestPat; + +use crate::convert_ast::converter::ast_constants::{ + REST_ELEMENT_ARGUMENT_OFFSET, REST_ELEMENT_RESERVED_BYTES, TYPE_REST_ELEMENT, +}; +use crate::convert_ast::converter::AstConverter; + +impl AstConverter<'_> { + pub(crate) fn store_rest_element(&mut self, rest_pattern: &RestPat) { + let end_position = self.add_type_and_start( + &TYPE_REST_ELEMENT, + &rest_pattern.dot3_token, + REST_ELEMENT_RESERVED_BYTES, + false, + ); + // argument + self.update_reference_position(end_position + REST_ELEMENT_ARGUMENT_OFFSET); + self.convert_pattern(&rest_pattern.arg); + // end + self.add_end(end_position, &rest_pattern.span); + } +} diff --git a/rust/parse_ast/src/ast_nodes/return_statement.rs b/rust/parse_ast/src/ast_nodes/return_statement.rs new file mode 100644 index 00000000000..f4b552bfb53 --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/return_statement.rs @@ -0,0 +1,14 @@ +use swc_ecma_ast::ReturnStmt; + +use crate::convert_ast::converter::AstConverter; +use crate::store_return_statement; + +impl AstConverter<'_> { + pub(crate) fn store_return_statement(&mut self, return_statement: &ReturnStmt) { + store_return_statement!( + self, + span => return_statement.span, + argument => [return_statement.arg, convert_expression] + ); + } +} diff --git a/rust/parse_ast/src/ast_nodes/sequence_expression.rs b/rust/parse_ast/src/ast_nodes/sequence_expression.rs new file mode 100644 index 00000000000..4e65e5fd618 --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/sequence_expression.rs @@ -0,0 +1,14 @@ +use swc_ecma_ast::SeqExpr; + +use crate::convert_ast::converter::AstConverter; +use crate::store_sequence_expression; + +impl AstConverter<'_> { + pub(crate) fn store_sequence_expression(&mut self, sequence_expression: &SeqExpr) { + store_sequence_expression!( + self, + span => &sequence_expression.span, + expressions => [sequence_expression.exprs, convert_expression] + ); + } +} diff --git a/rust/parse_ast/src/ast_nodes/shared/class_node.rs b/rust/parse_ast/src/ast_nodes/shared/class_node.rs new file mode 100644 index 00000000000..672df2bdd19 --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/shared/class_node.rs @@ -0,0 +1,67 @@ +use swc_common::Spanned; +use swc_ecma_ast::{Class, Ident}; + +use crate::convert_ast::converter::analyze_code::find_first_occurrence_outside_comment; +use crate::convert_ast::converter::ast_constants::{ + CLASS_DECLARATION_BODY_OFFSET, CLASS_DECLARATION_DECORATORS_OFFSET, CLASS_DECLARATION_ID_OFFSET, + CLASS_DECLARATION_RESERVED_BYTES, CLASS_DECLARATION_SUPER_CLASS_OFFSET, +}; +use crate::convert_ast::converter::AstConverter; + +impl AstConverter<'_> { + pub(crate) fn store_class_node( + &mut self, + node_type: &[u8; 4], + identifier: Option<&Ident>, + class: &Class, + outside_class_span_decorators_insert_position: Option, + ) { + let end_position = self.add_type_and_start( + node_type, + &class.span, + CLASS_DECLARATION_RESERVED_BYTES, + false, + ); + let mut body_start_search = class.span.lo.0 - 1; + // decorators + if let Some(outside_class_span_decorators_insert_position) = + outside_class_span_decorators_insert_position + { + self.buffer[end_position + CLASS_DECLARATION_DECORATORS_OFFSET + ..end_position + CLASS_DECLARATION_DECORATORS_OFFSET + 4] + .copy_from_slice(&outside_class_span_decorators_insert_position.to_ne_bytes()); + } else { + self.convert_item_list( + &class.decorators, + end_position + CLASS_DECLARATION_DECORATORS_OFFSET, + |ast_converter, decorator| { + ast_converter.store_decorator(decorator); + true + }, + ); + } + + if !class.decorators.is_empty() { + body_start_search = class.decorators.last().unwrap().span.hi.0 - 1; + } + // id + if let Some(identifier) = identifier { + self.update_reference_position(end_position + CLASS_DECLARATION_ID_OFFSET); + self.convert_identifier(identifier); + body_start_search = identifier.span.hi.0 - 1; + } + // super_class + if let Some(super_class) = class.super_class.as_ref() { + self.update_reference_position(end_position + CLASS_DECLARATION_SUPER_CLASS_OFFSET); + self.convert_expression(super_class); + body_start_search = super_class.span().hi.0 - 1; + } + // body + self.update_reference_position(end_position + CLASS_DECLARATION_BODY_OFFSET); + let class_body_start = + find_first_occurrence_outside_comment(self.code, b'{', body_start_search); + self.store_class_body(&class.body, class_body_start, class.span.hi.0 - 1); + // end + self.add_end(end_position, &class.span); + } +} diff --git a/rust/parse_ast/src/ast_nodes/shared/function_node.rs b/rust/parse_ast/src/ast_nodes/shared/function_node.rs new file mode 100644 index 00000000000..2555f6e8507 --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/shared/function_node.rs @@ -0,0 +1,91 @@ +use swc_ecma_ast::{BlockStmt, Function, Ident, Pat}; + +use crate::convert_ast::annotations::AnnotationKind; +use crate::convert_ast::converter::ast_constants::{ + FUNCTION_DECLARATION_ANNOTATIONS_OFFSET, FUNCTION_DECLARATION_BODY_OFFSET, + FUNCTION_DECLARATION_ID_OFFSET, FUNCTION_DECLARATION_PARAMS_OFFSET, + FUNCTION_DECLARATION_RESERVED_BYTES, +}; +use crate::convert_ast::converter::{convert_annotation, AstConverter}; +use crate::store_function_declaration_flags; + +impl AstConverter<'_> { + pub(crate) fn convert_function( + &mut self, + function: &Function, + node_type: &[u8; 4], + identifier: Option<&Ident>, + ) { + let parameters: Vec<&Pat> = function.params.iter().map(|param| ¶m.pat).collect(); + self.store_function_node( + node_type, + function.span.lo.0 - 1, + function.span.hi.0 - 1, + function.is_async, + function.is_generator, + identifier, + ¶meters, + function.body.as_ref().unwrap(), + true, + ); + } + + #[allow(clippy::too_many_arguments)] + pub(crate) fn store_function_node( + &mut self, + node_type: &[u8; 4], + start: u32, + end: u32, + is_async: bool, + is_generator: bool, + identifier: Option<&Ident>, + parameters: &[&Pat], + body: &BlockStmt, + observe_annotations: bool, + ) { + let end_position = + self.add_type_and_explicit_start(node_type, start, FUNCTION_DECLARATION_RESERVED_BYTES); + // flags + store_function_declaration_flags!( + self, + end_position, + async => is_async, + generator => is_generator + ); + // annotations + if observe_annotations { + let annotations = self + .index_converter + .take_collected_annotations(AnnotationKind::NoSideEffects); + if !annotations.is_empty() { + self.convert_item_list( + &annotations, + end_position + FUNCTION_DECLARATION_ANNOTATIONS_OFFSET, + |ast_converter, annotation| { + convert_annotation(&mut ast_converter.buffer, annotation); + true + }, + ); + } + } + // id + if let Some(ident) = identifier { + self.update_reference_position(end_position + FUNCTION_DECLARATION_ID_OFFSET); + self.convert_identifier(ident); + } + // params + self.convert_item_list( + parameters, + end_position + FUNCTION_DECLARATION_PARAMS_OFFSET, + |ast_converter, param| { + ast_converter.convert_pattern(param); + true + }, + ); + // body + self.update_reference_position(end_position + FUNCTION_DECLARATION_BODY_OFFSET); + self.store_block_statement(body, true); + // end + self.add_explicit_end(end_position, end); + } +} diff --git a/rust/parse_ast/src/ast_nodes/shared/mod.rs b/rust/parse_ast/src/ast_nodes/shared/mod.rs new file mode 100644 index 00000000000..3bc8a0f680a --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/shared/mod.rs @@ -0,0 +1,2 @@ +mod class_node; +mod function_node; diff --git a/rust/parse_ast/src/ast_nodes/spread_element.rs b/rust/parse_ast/src/ast_nodes/spread_element.rs new file mode 100644 index 00000000000..6c68d4e5f10 --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/spread_element.rs @@ -0,0 +1,27 @@ +use swc_common::{Span, Spanned}; +use swc_ecma_ast::{Expr, SpreadElement}; + +use crate::convert_ast::converter::ast_constants::{ + SPREAD_ELEMENT_ARGUMENT_OFFSET, SPREAD_ELEMENT_RESERVED_BYTES, TYPE_SPREAD_ELEMENT, +}; +use crate::convert_ast::converter::AstConverter; + +impl AstConverter<'_> { + pub(crate) fn store_spread_element(&mut self, dot_span: &Span, argument: &Expr) { + let end_position = self.add_type_and_start( + &TYPE_SPREAD_ELEMENT, + dot_span, + SPREAD_ELEMENT_RESERVED_BYTES, + false, + ); + // argument + self.update_reference_position(end_position + SPREAD_ELEMENT_ARGUMENT_OFFSET); + self.convert_expression(argument); + // end + self.add_end(end_position, &argument.span()); + } + + pub(crate) fn convert_spread_element(&mut self, spread_element: &SpreadElement) { + self.store_spread_element(&spread_element.dot3_token, &spread_element.expr); + } +} diff --git a/rust/parse_ast/src/ast_nodes/static_block.rs b/rust/parse_ast/src/ast_nodes/static_block.rs new file mode 100644 index 00000000000..df25ca2608f --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/static_block.rs @@ -0,0 +1,14 @@ +use swc_ecma_ast::StaticBlock; + +use crate::convert_ast::converter::AstConverter; +use crate::store_static_block; + +impl AstConverter<'_> { + pub(crate) fn store_static_block(&mut self, static_block: &StaticBlock) { + store_static_block!( + self, + span => &static_block.span, + body => [static_block.body.stmts, convert_statement] + ); + } +} diff --git a/rust/parse_ast/src/ast_nodes/super_element.rs b/rust/parse_ast/src/ast_nodes/super_element.rs new file mode 100644 index 00000000000..c5d661ba867 --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/super_element.rs @@ -0,0 +1,13 @@ +use swc_ecma_ast::Super; + +use crate::convert_ast::converter::AstConverter; +use crate::store_super_element; + +impl AstConverter<'_> { + pub(crate) fn store_super_element(&mut self, super_token: &Super) { + store_super_element!( + self, + span => &super_token.span + ); + } +} diff --git a/rust/parse_ast/src/ast_nodes/switch_case.rs b/rust/parse_ast/src/ast_nodes/switch_case.rs new file mode 100644 index 00000000000..e8acf09022d --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/switch_case.rs @@ -0,0 +1,15 @@ +use swc_ecma_ast::SwitchCase; + +use crate::convert_ast::converter::AstConverter; +use crate::store_switch_case; + +impl AstConverter<'_> { + pub(crate) fn store_switch_case(&mut self, switch_case: &SwitchCase) { + store_switch_case!( + self, + span => &switch_case.span, + test => [switch_case.test, convert_expression], + consequent => [switch_case.cons, convert_statement] + ); + } +} diff --git a/rust/parse_ast/src/ast_nodes/switch_statement.rs b/rust/parse_ast/src/ast_nodes/switch_statement.rs new file mode 100644 index 00000000000..e5975da4fda --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/switch_statement.rs @@ -0,0 +1,15 @@ +use swc_ecma_ast::SwitchStmt; + +use crate::convert_ast::converter::AstConverter; +use crate::store_switch_statement; + +impl AstConverter<'_> { + pub(crate) fn store_switch_statement(&mut self, switch_statement: &SwitchStmt) { + store_switch_statement!( + self, + span => &switch_statement.span, + discriminant => [switch_statement.discriminant, convert_expression], + cases => [switch_statement.cases, store_switch_case] + ); + } +} diff --git a/rust/parse_ast/src/ast_nodes/tagged_template_expression.rs b/rust/parse_ast/src/ast_nodes/tagged_template_expression.rs new file mode 100644 index 00000000000..b4978d887b0 --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/tagged_template_expression.rs @@ -0,0 +1,15 @@ +use swc_ecma_ast::TaggedTpl; + +use crate::convert_ast::converter::AstConverter; +use crate::store_tagged_template_expression; + +impl AstConverter<'_> { + pub(crate) fn store_tagged_template_expression(&mut self, tagged_template: &TaggedTpl) { + store_tagged_template_expression!( + self, + span => &tagged_template.span, + tag => [tagged_template.tag, convert_expression], + quasi => [tagged_template.tpl, store_template_literal] + ); + } +} diff --git a/rust/parse_ast/src/ast_nodes/template_element.rs b/rust/parse_ast/src/ast_nodes/template_element.rs new file mode 100644 index 00000000000..9147dc65a62 --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/template_element.rs @@ -0,0 +1,16 @@ +use swc_ecma_ast::TplElement; + +use crate::convert_ast::converter::AstConverter; +use crate::{store_template_element, store_template_element_flags}; + +impl AstConverter<'_> { + pub(crate) fn store_template_element(&mut self, template_element: &TplElement) { + store_template_element!( + self, + span => &template_element.span, + tail => template_element.tail, + cooked => template_element.cooked.as_ref().and_then(|s| s.as_atom()), + raw => &template_element.raw + ); + } +} diff --git a/rust/parse_ast/src/ast_nodes/template_literal.rs b/rust/parse_ast/src/ast_nodes/template_literal.rs new file mode 100644 index 00000000000..cbde87f963f --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/template_literal.rs @@ -0,0 +1,63 @@ +use swc_ecma_ast::Tpl; + +use crate::convert_ast::converter::ast_constants::{ + TEMPLATE_LITERAL_EXPRESSIONS_OFFSET, TEMPLATE_LITERAL_QUASIS_OFFSET, + TEMPLATE_LITERAL_RESERVED_BYTES, TYPE_TEMPLATE_LITERAL, +}; +use crate::convert_ast::converter::AstConverter; + +impl AstConverter<'_> { + pub(crate) fn store_template_literal(&mut self, template_literal: &Tpl) { + let end_position = self.add_type_and_start( + &TYPE_TEMPLATE_LITERAL, + &template_literal.span, + TEMPLATE_LITERAL_RESERVED_BYTES, + false, + ); + // quasis, we manually do an item list here + self.update_reference_position(end_position + TEMPLATE_LITERAL_QUASIS_OFFSET); + self + .buffer + .extend_from_slice(&(template_literal.quasis.len() as u32).to_ne_bytes()); + let mut next_quasi_position = self.buffer.len(); + // make room for the positions of the quasis + self + .buffer + .resize(self.buffer.len() + template_literal.quasis.len() * 4, 0); + let mut quasis = template_literal.quasis.iter(); + // convert first quasi + let first_quasi = quasis.next().unwrap(); + let insert_position = (self.buffer.len() as u32) >> 2; + self.store_template_element(first_quasi); + self.buffer[next_quasi_position..next_quasi_position + 4] + .copy_from_slice(&insert_position.to_ne_bytes()); + next_quasi_position += 4; + // now convert expressions, interleaved with quasis + self.update_reference_position(end_position + TEMPLATE_LITERAL_EXPRESSIONS_OFFSET); + self + .buffer + .extend_from_slice(&(template_literal.exprs.len() as u32).to_ne_bytes()); + let mut next_expression_position = self.buffer.len(); + // make room for the positions of the expressions + self + .buffer + .resize(self.buffer.len() + template_literal.exprs.len() * 4, 0); + for expression in template_literal.exprs.as_slice() { + // convert expression + let insert_position = (self.buffer.len() as u32) >> 2; + self.convert_expression(expression); + self.buffer[next_expression_position..next_expression_position + 4] + .copy_from_slice(&insert_position.to_ne_bytes()); + next_expression_position += 4; + // convert next quasi + let next_quasi = quasis.next().unwrap(); + let insert_position = (self.buffer.len() as u32) >> 2; + self.store_template_element(next_quasi); + self.buffer[next_quasi_position..next_quasi_position + 4] + .copy_from_slice(&insert_position.to_ne_bytes()); + next_quasi_position += 4; + } + // end + self.add_end(end_position, &template_literal.span); + } +} diff --git a/rust/parse_ast/src/ast_nodes/this_expression.rs b/rust/parse_ast/src/ast_nodes/this_expression.rs new file mode 100644 index 00000000000..ebe3bd4c5f6 --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/this_expression.rs @@ -0,0 +1,10 @@ +use swc_ecma_ast::ThisExpr; + +use crate::convert_ast::converter::AstConverter; +use crate::store_this_expression; + +impl AstConverter<'_> { + pub(crate) fn store_this_expression(&mut self, this_expression: &ThisExpr) { + store_this_expression!(self, span => this_expression.span); + } +} diff --git a/rust/parse_ast/src/ast_nodes/throw_statement.rs b/rust/parse_ast/src/ast_nodes/throw_statement.rs new file mode 100644 index 00000000000..96f3128a0da --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/throw_statement.rs @@ -0,0 +1,14 @@ +use swc_ecma_ast::ThrowStmt; + +use crate::convert_ast::converter::AstConverter; +use crate::store_throw_statement; + +impl AstConverter<'_> { + pub(crate) fn store_throw_statement(&mut self, throw_statement: &ThrowStmt) { + store_throw_statement!( + self, + span => &throw_statement.span, + argument => [throw_statement.arg, convert_expression] + ); + } +} diff --git a/rust/parse_ast/src/ast_nodes/try_statement.rs b/rust/parse_ast/src/ast_nodes/try_statement.rs new file mode 100644 index 00000000000..66728a0e0c3 --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/try_statement.rs @@ -0,0 +1,33 @@ +use swc_ecma_ast::TryStmt; + +use crate::convert_ast::converter::ast_constants::{ + TRY_STATEMENT_BLOCK_OFFSET, TRY_STATEMENT_FINALIZER_OFFSET, TRY_STATEMENT_HANDLER_OFFSET, + TRY_STATEMENT_RESERVED_BYTES, TYPE_TRY_STATEMENT, +}; +use crate::convert_ast::converter::AstConverter; + +impl AstConverter<'_> { + pub(crate) fn store_try_statement(&mut self, try_statement: &TryStmt) { + let end_position = self.add_type_and_start( + &TYPE_TRY_STATEMENT, + &try_statement.span, + TRY_STATEMENT_RESERVED_BYTES, + false, + ); + // block + self.update_reference_position(end_position + TRY_STATEMENT_BLOCK_OFFSET); + self.store_block_statement(&try_statement.block, false); + // handler + if let Some(catch_clause) = try_statement.handler.as_ref() { + self.update_reference_position(end_position + TRY_STATEMENT_HANDLER_OFFSET); + self.store_catch_clause(catch_clause); + } + // finalizer + if let Some(block_statement) = try_statement.finalizer.as_ref() { + self.update_reference_position(end_position + TRY_STATEMENT_FINALIZER_OFFSET); + self.store_block_statement(block_statement, false); + } + // end + self.add_end(end_position, &try_statement.span); + } +} diff --git a/rust/parse_ast/src/ast_nodes/unary_expression.rs b/rust/parse_ast/src/ast_nodes/unary_expression.rs new file mode 100644 index 00000000000..d1affc5e481 --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/unary_expression.rs @@ -0,0 +1,26 @@ +use swc_ecma_ast::{UnaryExpr, UnaryOp}; + +use crate::convert_ast::converter::string_constants::{ + STRING_BANG, STRING_DELETE, STRING_MINUS, STRING_PLUS, STRING_TILDE, STRING_TYPEOF, STRING_VOID, +}; +use crate::convert_ast::converter::AstConverter; +use crate::store_unary_expression; + +impl AstConverter<'_> { + pub(crate) fn store_unary_expression(&mut self, unary_expression: &UnaryExpr) { + store_unary_expression!( + self, + span => &unary_expression.span, + operator => match unary_expression.op { + UnaryOp::Minus => &STRING_MINUS, + UnaryOp::Plus => &STRING_PLUS, + UnaryOp::Bang => &STRING_BANG, + UnaryOp::Tilde => &STRING_TILDE, + UnaryOp::TypeOf => &STRING_TYPEOF, + UnaryOp::Void => &STRING_VOID, + UnaryOp::Delete => &STRING_DELETE, + }, + argument => [unary_expression.arg, convert_expression] + ); + } +} diff --git a/rust/parse_ast/src/ast_nodes/update_expression.rs b/rust/parse_ast/src/ast_nodes/update_expression.rs new file mode 100644 index 00000000000..87a6548171b --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/update_expression.rs @@ -0,0 +1,20 @@ +use swc_ecma_ast::{UpdateExpr, UpdateOp}; + +use crate::convert_ast::converter::string_constants::{STRING_MINUSMINUS, STRING_PLUSPLUS}; +use crate::convert_ast::converter::AstConverter; +use crate::{store_update_expression, store_update_expression_flags}; + +impl AstConverter<'_> { + pub(crate) fn store_update_expression(&mut self, update_expression: &UpdateExpr) { + store_update_expression!( + self, + span => &update_expression.span, + prefix => update_expression.prefix, + operator => match update_expression.op { + UpdateOp::PlusPlus => &STRING_PLUSPLUS, + UpdateOp::MinusMinus => &STRING_MINUSMINUS, + }, + argument => [update_expression.arg, convert_expression] + ); + } +} diff --git a/rust/parse_ast/src/ast_nodes/variable_declaration.rs b/rust/parse_ast/src/ast_nodes/variable_declaration.rs new file mode 100644 index 00000000000..8e889e408c2 --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/variable_declaration.rs @@ -0,0 +1,61 @@ +use swc_common::Span; +use swc_ecma_ast::{UsingDecl, VarDecl, VarDeclKind, VarDeclarator}; + +use crate::convert_ast::converter::ast_constants::{ + TYPE_VARIABLE_DECLARATION, VARIABLE_DECLARATION_DECLARATIONS_OFFSET, + VARIABLE_DECLARATION_KIND_OFFSET, VARIABLE_DECLARATION_RESERVED_BYTES, +}; +use crate::convert_ast::converter::string_constants::{ + STRING_AWAIT_USING, STRING_CONST, STRING_LET, STRING_USING, STRING_VAR, +}; +use crate::convert_ast::converter::AstConverter; + +impl AstConverter<'_> { + pub(crate) fn store_variable_declaration(&mut self, variable_declaration: &VariableDeclaration) { + let (kind, span, decls): (&[u8; 4], Span, &Vec) = match variable_declaration { + VariableDeclaration::Var(value) => ( + match value.kind { + VarDeclKind::Var => &STRING_VAR, + VarDeclKind::Let => &STRING_LET, + VarDeclKind::Const => &STRING_CONST, + }, + value.span, + &value.decls, + ), + &VariableDeclaration::Using(value) => ( + if value.is_await { + &STRING_AWAIT_USING + } else { + &STRING_USING + }, + value.span, + &value.decls, + ), + }; + let end_position = self.add_type_and_start( + &TYPE_VARIABLE_DECLARATION, + &span, + VARIABLE_DECLARATION_RESERVED_BYTES, + kind == &STRING_CONST, + ); + // declarations + self.convert_item_list( + decls, + end_position + VARIABLE_DECLARATION_DECLARATIONS_OFFSET, + |ast_converter, variable_declarator| { + ast_converter.store_variable_declarator(variable_declarator); + true + }, + ); + // kind + let kind_position = end_position + VARIABLE_DECLARATION_KIND_OFFSET; + self.buffer[kind_position..kind_position + 4].copy_from_slice(kind); + // end + self.add_end(end_position, &span); + } +} + +pub(crate) enum VariableDeclaration<'a> { + Var(&'a VarDecl), + Using(&'a UsingDecl), +} diff --git a/rust/parse_ast/src/ast_nodes/variable_declarator.rs b/rust/parse_ast/src/ast_nodes/variable_declarator.rs new file mode 100644 index 00000000000..2d7fe6b02a2 --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/variable_declarator.rs @@ -0,0 +1,44 @@ +use swc_ecma_ast::{Expr, VarDeclarator}; + +use crate::convert_ast::annotations::AnnotationKind; +use crate::convert_ast::converter::ast_constants::{ + TYPE_VARIABLE_DECLARATOR, VARIABLE_DECLARATOR_ID_OFFSET, VARIABLE_DECLARATOR_INIT_OFFSET, + VARIABLE_DECLARATOR_RESERVED_BYTES, +}; +use crate::convert_ast::converter::AstConverter; + +impl AstConverter<'_> { + pub(crate) fn store_variable_declarator(&mut self, variable_declarator: &VarDeclarator) { + let end_position = self.add_type_and_start( + &TYPE_VARIABLE_DECLARATOR, + &variable_declarator.span, + VARIABLE_DECLARATOR_RESERVED_BYTES, + false, + ); + let forwarded_annotations = match &variable_declarator.init { + Some(expression) => match &**expression { + Expr::Arrow(_) => { + let annotations = self + .index_converter + .take_collected_annotations(AnnotationKind::NoSideEffects); + Some(annotations) + } + _ => None, + }, + None => None, + }; + // id + self.update_reference_position(end_position + VARIABLE_DECLARATOR_ID_OFFSET); + self.convert_pattern(&variable_declarator.name); + // init + if let Some(annotations) = forwarded_annotations { + self.index_converter.add_collected_annotations(annotations); + } + if let Some(init) = variable_declarator.init.as_ref() { + self.update_reference_position(end_position + VARIABLE_DECLARATOR_INIT_OFFSET); + self.convert_expression(init); + } + // end + self.add_end(end_position, &variable_declarator.span); + } +} diff --git a/rust/parse_ast/src/ast_nodes/while_statement.rs b/rust/parse_ast/src/ast_nodes/while_statement.rs new file mode 100644 index 00000000000..5fa94904187 --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/while_statement.rs @@ -0,0 +1,15 @@ +use swc_ecma_ast::WhileStmt; + +use crate::convert_ast::converter::AstConverter; +use crate::store_while_statement; + +impl AstConverter<'_> { + pub(crate) fn store_while_statement(&mut self, while_statement: &WhileStmt) { + store_while_statement!( + self, + span => &while_statement.span, + test => [while_statement.test, convert_expression], + body => [while_statement.body, convert_statement] + ); + } +} diff --git a/rust/parse_ast/src/ast_nodes/yield_expression.rs b/rust/parse_ast/src/ast_nodes/yield_expression.rs new file mode 100644 index 00000000000..35085d2872b --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/yield_expression.rs @@ -0,0 +1,15 @@ +use swc_ecma_ast::YieldExpr; + +use crate::convert_ast::converter::AstConverter; +use crate::{store_yield_expression, store_yield_expression_flags}; + +impl AstConverter<'_> { + pub(crate) fn store_yield_expression(&mut self, yield_expression: &YieldExpr) { + store_yield_expression!( + self, + span => yield_expression.span, + delegate => yield_expression.delegate, + argument => [yield_expression.arg, convert_expression] + ); + } +} diff --git a/rust/parse_ast/src/convert_ast.rs b/rust/parse_ast/src/convert_ast.rs new file mode 100644 index 00000000000..9b9b1086064 --- /dev/null +++ b/rust/parse_ast/src/convert_ast.rs @@ -0,0 +1,2 @@ +pub(crate) mod annotations; +pub(crate) mod converter; diff --git a/rust/parse_ast/src/convert_ast/annotations.rs b/rust/parse_ast/src/convert_ast/annotations.rs new file mode 100644 index 00000000000..0ac6f31164a --- /dev/null +++ b/rust/parse_ast/src/convert_ast/annotations.rs @@ -0,0 +1,146 @@ +use std::cell::RefCell; + +use swc_common::comments::{Comment, Comments}; +use swc_common::BytePos; + +#[derive(Default)] +pub(crate) struct SequentialComments { + annotations: RefCell>, +} + +impl SequentialComments { + pub(crate) fn add_comment(&self, comment: Comment) { + if comment.text.starts_with('#') && comment.text.contains("sourceMappingURL=") { + self.annotations.borrow_mut().push(AnnotationWithType { + comment, + kind: CommentKind::Annotation(AnnotationKind::SourceMappingUrl), + }); + return; + } + let mut search_position = comment + .text + .chars() + .nth(0) + .map(|first_char| first_char.len_utf8()) + .unwrap_or(0); + while let Some(Some(match_position)) = comment.text.get(search_position..).map(|s| s.find("__")) + { + search_position += match_position; + // Using a byte reference avoids UTF8 character boundary checks + match &comment.text.as_bytes()[search_position - 1] { + b'@' | b'#' => { + let annotation_slice = &comment.text[search_position..]; + if annotation_slice.starts_with("__PURE__") { + self.annotations.borrow_mut().push(AnnotationWithType { + comment, + kind: CommentKind::Annotation(AnnotationKind::Pure), + }); + return; + } + if annotation_slice.starts_with("__NO_SIDE_EFFECTS__") { + self.annotations.borrow_mut().push(AnnotationWithType { + comment, + kind: CommentKind::Annotation(AnnotationKind::NoSideEffects), + }); + return; + } + } + _ => {} + } + search_position += 2; + } + self.annotations.borrow_mut().push(AnnotationWithType { + comment, + kind: CommentKind::Comment, + }); + } + + pub(crate) fn take_annotations(self) -> Vec { + self.annotations.take() + } +} + +impl Comments for SequentialComments { + fn add_leading(&self, _: BytePos, comment: Comment) { + self.add_comment(comment); + } + + #[cfg_attr(not(debug_assertions), inline(always))] + fn add_leading_comments(&self, _: BytePos, _: Vec) { + panic!("add_leading_comments"); + } + + #[cfg_attr(not(debug_assertions), inline(always))] + fn has_leading(&self, _: BytePos) -> bool { + panic!("has_leading"); + } + + #[cfg_attr(not(debug_assertions), inline(always))] + fn move_leading(&self, _: BytePos, _: BytePos) { + panic!("move_leading"); + } + + #[cfg_attr(not(debug_assertions), inline(always))] + fn take_leading(&self, _: BytePos) -> Option> { + panic!("take_leading"); + } + + #[cfg_attr(not(debug_assertions), inline(always))] + fn get_leading(&self, _: BytePos) -> Option> { + panic!("get_leading"); + } + + #[cfg_attr(not(debug_assertions), inline(always))] + fn add_trailing(&self, _: BytePos, comment: Comment) { + self.add_comment(comment); + } + + #[cfg_attr(not(debug_assertions), inline(always))] + fn add_trailing_comments(&self, _: BytePos, _: Vec) { + panic!("add_trailing_comments"); + } + + #[cfg_attr(not(debug_assertions), inline(always))] + fn has_trailing(&self, _: BytePos) -> bool { + panic!("has_trailing"); + } + + #[cfg_attr(not(debug_assertions), inline(always))] + fn move_trailing(&self, _: BytePos, _: BytePos) { + panic!("move_trailing"); + } + + #[cfg_attr(not(debug_assertions), inline(always))] + fn take_trailing(&self, _: BytePos) -> Option> { + panic!("take_trailing"); + } + + #[cfg_attr(not(debug_assertions), inline(always))] + fn get_trailing(&self, _: BytePos) -> Option> { + panic!("get_trailing"); + } + + #[cfg_attr(not(debug_assertions), inline(always))] + fn add_pure_comment(&self, _: BytePos) { + panic!("add_pure_comment"); + } +} + +#[derive(Debug)] +pub(crate) struct AnnotationWithType { + pub(crate) comment: Comment, + pub(crate) kind: CommentKind, +} + +#[derive(Clone, Debug)] +pub(crate) enum CommentKind { + Annotation(AnnotationKind), + Comment, +} + +#[derive(Clone, PartialEq, Debug)] +pub(crate) enum AnnotationKind { + Pure, + NoSideEffects, + SourceMappingUrl, +} diff --git a/rust/parse_ast/src/convert_ast/converter.rs b/rust/parse_ast/src/convert_ast/converter.rs new file mode 100644 index 00000000000..bad0dfa4d5d --- /dev/null +++ b/rust/parse_ast/src/convert_ast/converter.rs @@ -0,0 +1,858 @@ +use swc_common::Span; +use swc_ecma_ast::{ + AssignTarget, AssignTargetPat, CallExpr, Callee, Class, ClassMember, Decl, Decorator, + ExportSpecifier, Expr, ExprOrSpread, ForHead, ImportSpecifier, JSXAttrName, JSXAttrOrSpread, + JSXAttrValue, JSXElementChild, JSXElementName, JSXObject, Lit, ModuleDecl, ModuleExportName, + ModuleItem, NamedExport, ObjectPatProp, OptChainBase, ParenExpr, Pat, Program, PropName, + PropOrSpread, SimpleAssignTarget, Stmt, VarDeclOrExpr, +}; + +use crate::ast_nodes::call_expression::StoredCallee; +use crate::ast_nodes::variable_declaration::VariableDeclaration; +use crate::convert_ast::annotations::{AnnotationKind, AnnotationWithType}; +use crate::convert_ast::converter::ast_constants::{ + TYPE_CLASS_EXPRESSION, TYPE_FUNCTION_DECLARATION, TYPE_FUNCTION_EXPRESSION, +}; +use crate::convert_ast::converter::string_constants::{ + STRING_NOSIDEEFFECTS, STRING_PURE, STRING_SOURCEMAP, +}; +use crate::convert_ast::converter::utf16_positions::{ + ConvertedAnnotation, Utf8ToUtf16ByteIndexConverterAndAnnotationHandler, +}; + +pub(crate) mod analyze_code; +pub(crate) mod string_constants; +mod utf16_positions; + +pub(crate) mod ast_constants; +mod ast_macros; + +pub(crate) struct AstConverter<'a> { + pub(crate) buffer: Vec, + pub(crate) code: &'a [u8], + pub(crate) index_converter: Utf8ToUtf16ByteIndexConverterAndAnnotationHandler<'a>, +} + +impl<'a> AstConverter<'a> { + pub(crate) fn new(code: &'a str, annotations: &'a [AnnotationWithType]) -> Self { + Self { + // This is just a wild guess and should be revisited from time to time + buffer: Vec::with_capacity(20 * code.len()), + code: code.as_bytes(), + index_converter: Utf8ToUtf16ByteIndexConverterAndAnnotationHandler::new(code, annotations), + } + } + + pub(crate) fn convert_ast_to_buffer(mut self, node: &Program) -> Vec { + self.convert_program(node); + self.buffer.shrink_to_fit(); + self.buffer + } + + // === helpers + pub(crate) fn add_type_and_start( + &mut self, + node_type: &[u8; 4], + span: &Span, + reserved_bytes: usize, + keep_annotations: bool, + ) -> usize { + // type + self.buffer.extend_from_slice(node_type); + // start + let start = self + .index_converter + .convert(span.lo.0 - 1, keep_annotations); + self.buffer.extend_from_slice(&start.to_ne_bytes()); + // end + let end_position = self.buffer.len(); + // reserved bytes + self.buffer.resize(end_position + reserved_bytes, 0); + end_position + } + + pub(crate) fn add_type_and_explicit_start( + &mut self, + node_type: &[u8; 4], + start: u32, + reserved_bytes: usize, + ) -> usize { + // type + self.buffer.extend_from_slice(node_type); + // start + self + .buffer + .extend_from_slice(&self.index_converter.convert(start, false).to_ne_bytes()); + // end + let end_position = self.buffer.len(); + // reserved bytes + self.buffer.resize(end_position + reserved_bytes, 0); + end_position + } + + pub(crate) fn add_end(&mut self, end_position: usize, span: &Span) { + self.buffer[end_position..end_position + 4].copy_from_slice( + &self + .index_converter + .convert(span.hi.0 - 1, false) + .to_ne_bytes(), + ); + } + + pub(crate) fn add_explicit_end(&mut self, end_position: usize, end: u32) { + self.buffer[end_position..end_position + 4] + .copy_from_slice(&self.index_converter.convert(end, false).to_ne_bytes()); + } + + pub(crate) fn convert_item_list( + &mut self, + item_list: &[T], + reference_position: usize, + convert_item: F, + ) where + F: Fn(&mut AstConverter, &T) -> bool, + { + self.convert_item_list_internal( + item_list, + Some(reference_position), + None, + |ast_converter, item, _state: Option<&mut ()>| (convert_item(ast_converter, item), None), + ) + } + + pub(crate) fn convert_item_list_with_state( + &mut self, + item_list: &[T], + reference_position: usize, + state: &mut S, + convert_item: F, + ) where + F: Fn(&mut AstConverter, &T, &mut S) -> (bool, Option), + { + self.convert_item_list_internal( + item_list, + Some(reference_position), + Some(state), + |ast_converter, item, state| convert_item(ast_converter, item, state.unwrap()), + ) + } + + fn convert_item_list_internal( + &mut self, + item_list: &[T], + reference_position: Option, + mut state: Option<&mut S>, + convert_item: F, + ) where + F: Fn(&mut AstConverter, &T, Option<&mut S>) -> (bool, Option), + { + // for an empty list, we leave the referenced position at zero + if item_list.is_empty() { + return; + } + + if let Some(pos) = reference_position { + self.update_reference_position(pos); + } + + // store number of items in first position + self + .buffer + .extend_from_slice(&(item_list.len() as u32).to_ne_bytes()); + let mut reference_position = self.buffer.len(); + + // make room for the reference positions of the items + self + .buffer + .resize(self.buffer.len() + item_list.len() * 4, 0); + + for item in item_list { + let mut insert_position = self.buffer.len() as u32 >> 2; + let (should_update_reference_position, explicit_insert_position) = + convert_item(self, item, state.as_deref_mut()); + if should_update_reference_position { + if let Some(explicit_insert_position) = explicit_insert_position { + insert_position = explicit_insert_position; + } + self.buffer[reference_position..reference_position + 4] + .copy_from_slice(&insert_position.to_ne_bytes()); + } + reference_position += 4; + } + } + + // TODO SWC deduplicate strings and see if we can easily compare atoms + pub(crate) fn convert_string(&mut self, string: &str, reference_position: usize) { + self.update_reference_position(reference_position); + convert_string(&mut self.buffer, string); + } + + pub(crate) fn update_reference_position(&mut self, reference_position: usize) { + let insert_position = (self.buffer.len() as u32) >> 2; + self.buffer[reference_position..reference_position + 4] + .copy_from_slice(&insert_position.to_ne_bytes()); + } + + // === shared enums + pub(crate) fn convert_call_expression( + &mut self, + call_expression: &CallExpr, + is_optional: bool, + is_chained: bool, + ) { + match &call_expression.callee { + Callee::Import(_) => { + self.store_import_expression(&call_expression.span, &call_expression.args) + } + Callee::Expr(callee_expression) => self.store_call_expression( + &call_expression.span, + is_optional, + &StoredCallee::Expression(callee_expression), + &call_expression.args, + is_chained, + ), + Callee::Super(callee_super) => self.store_call_expression( + &call_expression.span, + is_optional, + &StoredCallee::Super(callee_super), + &call_expression.args, + is_chained, + ), + } + } + + pub(crate) fn store_outside_class_span_decorators( + &mut self, + outside_class_span_decorators: Option<&Vec>, + outside_class_span_decorators_insert_position: &mut Option, + ) { + if let Some(outside_class_span_decorators) = outside_class_span_decorators { + *outside_class_span_decorators_insert_position = Some((self.buffer.len() as u32) >> 2); + self.convert_item_list_internal( + outside_class_span_decorators, + None, + None, + |ast_converter, decorator, _state: Option<&mut ()>| { + ast_converter.store_decorator(decorator); + (true, None) + }, + ); + } + } + + pub(crate) fn convert_class_member(&mut self, class_member: &ClassMember) { + match class_member { + ClassMember::ClassProp(class_property) => self.convert_class_property(class_property), + ClassMember::Constructor(constructor) => self.convert_constructor(constructor), + ClassMember::Method(method) => self.convert_method(method), + ClassMember::PrivateMethod(private_method) => self.convert_private_method(private_method), + ClassMember::PrivateProp(private_property) => self.convert_private_property(private_property), + ClassMember::StaticBlock(static_block) => self.store_static_block(static_block), + ClassMember::TsIndexSignature(_) => { + unimplemented!("Cannot convert ClassMember::TsIndexSignature") + } + ClassMember::AutoAccessor(_) => unimplemented!("Cannot convert ClassMember::AutoAccessor"), + ClassMember::Empty(_) => {} + } + } + + pub(crate) fn convert_declaration( + &mut self, + declaration: &Decl, + outside_class_span_decorators_insert_position: Option, + ) { + match declaration { + Decl::Var(variable_declaration) => { + self.store_variable_declaration(&VariableDeclaration::Var(variable_declaration)) + } + Decl::Fn(function_declaration) => self.convert_function( + &function_declaration.function, + &TYPE_FUNCTION_DECLARATION, + Some(&function_declaration.ident), + ), + Decl::Class(class_declaration) => self.store_class_declaration( + class_declaration, + outside_class_span_decorators_insert_position, + ), + Decl::Using(using_declaration) => { + self.store_variable_declaration(&VariableDeclaration::Using(using_declaration)) + } + Decl::TsInterface(_) => unimplemented!("Cannot convert Decl::TsInterface"), + Decl::TsTypeAlias(_) => unimplemented!("Cannot convert Decl::TsTypeAlias"), + Decl::TsEnum(_) => unimplemented!("Cannot convert Decl::TsEnum"), + Decl::TsModule(_) => unimplemented!("Cannot convert Decl::TsModule"), + } + } + + fn convert_export_named_declaration( + &mut self, + export_named_declaration: &NamedExport, + module_item_insert_position: &mut u32, + ) { + match export_named_declaration.specifiers.first() { + Some(ExportSpecifier::Namespace(export_namespace_specifier)) => self + .store_export_all_declaration( + &export_named_declaration.span, + export_named_declaration.src.as_ref().unwrap(), + &export_named_declaration.with, + Some(&export_namespace_specifier.name), + ), + None | Some(ExportSpecifier::Named(_)) => self.store_export_named_declaration( + &export_named_declaration.span, + &export_named_declaration.specifiers, + export_named_declaration.src.as_deref(), + None, + &export_named_declaration.with, + Some(module_item_insert_position), + ), + Some(ExportSpecifier::Default(_)) => panic!("Unexpected default export specifier"), + } + } + + pub(crate) fn convert_export_specifier(&mut self, export_specifier: &ExportSpecifier) { + match export_specifier { + ExportSpecifier::Named(export_named_specifier) => { + self.store_export_specifier(export_named_specifier) + } + ExportSpecifier::Namespace(_) => unimplemented!("Cannot convert ExportSpecifier::Namespace"), + ExportSpecifier::Default(_) => unimplemented!("Cannot convert ExportSpecifier::Default"), + } + } + + pub(crate) fn convert_expression(&mut self, expression: &Expr) { + match expression { + Expr::Array(array_literal) => { + self.store_array_expression(array_literal); + } + Expr::Arrow(arrow_expression) => { + self.store_arrow_function_expression(arrow_expression); + } + Expr::Assign(assignment_expression) => { + self.store_assignment_expression(assignment_expression); + } + Expr::Await(await_expression) => { + self.store_await_expression(await_expression); + } + Expr::Bin(binary_expression) => { + self.store_binary_expression(binary_expression); + } + Expr::Call(call_expression) => { + self.convert_call_expression(call_expression, false, false); + } + Expr::Class(class_expression) => { + self.store_class_expression(class_expression, &TYPE_CLASS_EXPRESSION, None); + } + Expr::Cond(conditional_expression) => { + self.store_conditional_expression(conditional_expression); + } + Expr::Fn(function_expression) => { + self.convert_function( + &function_expression.function, + &TYPE_FUNCTION_EXPRESSION, + function_expression.ident.as_ref(), + ); + } + Expr::Ident(identifier) => { + self.convert_identifier(identifier); + } + Expr::Lit(literal) => { + self.convert_literal(literal); + } + Expr::Member(member_expression) => { + self.convert_member_expression(member_expression, false, false); + } + Expr::MetaProp(meta_property) => { + self.store_meta_property(meta_property); + } + Expr::New(new_expression) => { + self.store_new_expression(new_expression); + } + Expr::Object(object_literal) => { + self.store_object_expression(object_literal); + } + Expr::OptChain(optional_chain_expression) => { + self.store_chain_expression(optional_chain_expression, false); + } + Expr::Paren(parenthesized_expression) => { + self.convert_parenthesized_expression(parenthesized_expression) + } + Expr::PrivateName(private_name) => { + self.store_private_identifier(private_name); + } + Expr::Seq(sequence_expression) => { + self.store_sequence_expression(sequence_expression); + } + Expr::SuperProp(super_property) => { + self.convert_super_property(super_property); + } + Expr::TaggedTpl(tagged_template_expression) => { + self.store_tagged_template_expression(tagged_template_expression); + } + Expr::This(this_expression) => { + self.store_this_expression(this_expression); + } + Expr::Tpl(template_literal) => { + self.store_template_literal(template_literal); + } + Expr::Unary(unary_expression) => { + self.store_unary_expression(unary_expression); + } + Expr::Update(update_expression) => { + self.store_update_expression(update_expression); + } + Expr::Yield(yield_expression) => { + self.store_yield_expression(yield_expression); + } + Expr::JSXMember(_) => unimplemented!("Cannot convert Expr::JSXMember"), + Expr::JSXNamespacedName(_) => unimplemented!("Cannot convert Expr::JSXNamespacedName"), + Expr::JSXEmpty(_) => unimplemented!("Cannot convert Expr::JSXEmpty"), + Expr::JSXElement(jsx_element) => { + self.store_jsx_element(jsx_element); + } + Expr::JSXFragment(jsx_fragment) => { + self.store_jsx_fragment(jsx_fragment); + } + Expr::TsTypeAssertion(_) => unimplemented!("Cannot convert Expr::TsTypeAssertion"), + Expr::TsConstAssertion(_) => unimplemented!("Cannot convert Expr::TsConstAssertion"), + Expr::TsNonNull(_) => unimplemented!("Cannot convert Expr::TsNonNull"), + Expr::TsAs(_) => unimplemented!("Cannot convert Expr::TsAs"), + Expr::TsInstantiation(_) => unimplemented!("Cannot convert Expr::TsInstantiation"), + Expr::TsSatisfies(_) => unimplemented!("Cannot convert Expr::TsSatisfies"), + Expr::Invalid(_) => unimplemented!("Cannot convert Expr::Invalid"), + } + } + + pub(crate) fn convert_expression_or_spread(&mut self, expression_or_spread: &ExprOrSpread) { + match expression_or_spread.spread { + Some(spread_span) => self.store_spread_element(&spread_span, &expression_or_spread.expr), + None => { + self.convert_expression(&expression_or_spread.expr); + } + } + } + + pub(crate) fn convert_for_head(&mut self, for_head: &ForHead) { + match for_head { + ForHead::VarDecl(variable_declaration) => { + self.store_variable_declaration(&VariableDeclaration::Var(variable_declaration)) + } + ForHead::Pat(pattern) => { + self.convert_pattern(pattern); + } + ForHead::UsingDecl(using_declaration) => { + self.store_variable_declaration(&VariableDeclaration::Using(using_declaration)) + } + } + } + + pub(crate) fn convert_import_specifier(&mut self, import_specifier: &ImportSpecifier) { + match import_specifier { + ImportSpecifier::Named(import_named_specifier) => { + self.store_import_specifier(import_named_specifier) + } + ImportSpecifier::Default(import_default_specifier) => { + self.store_import_default_specifier(import_default_specifier) + } + ImportSpecifier::Namespace(import_namespace_specifier) => { + self.store_import_namespace_specifier(import_namespace_specifier) + } + } + } + + pub(crate) fn convert_jsx_attribute_name(&mut self, jsx_attribute_name: &JSXAttrName) { + match jsx_attribute_name { + JSXAttrName::Ident(identifier) => { + self.store_jsx_identifier(&identifier.span, &identifier.sym); + } + JSXAttrName::JSXNamespacedName(jsx_namespaced_name) => { + self.store_jsx_namespaced_name(jsx_namespaced_name); + } + } + } + + pub(crate) fn convert_jsx_attribute_or_spread( + &mut self, + jsx_attribute_or_spread: &JSXAttrOrSpread, + previous_element_end: u32, + ) { + match jsx_attribute_or_spread { + JSXAttrOrSpread::JSXAttr(jsx_attribute) => { + self.store_jsx_attribute(jsx_attribute); + } + JSXAttrOrSpread::SpreadElement(spread_element) => { + self.store_jsx_spread_attribute(spread_element, previous_element_end); + } + } + } + + pub(crate) fn convert_jsx_attribute_value(&mut self, jsx_attribute_value: &JSXAttrValue) { + match jsx_attribute_value { + JSXAttrValue::Str(string_literal) => self.store_literal_string(string_literal), + JSXAttrValue::JSXExprContainer(expression_container) => { + self.store_jsx_expression_container(expression_container) + } + JSXAttrValue::JSXElement(jsx_element) => self.store_jsx_element(jsx_element), + JSXAttrValue::JSXFragment(jsx_fragment) => self.store_jsx_fragment(jsx_fragment), + } + } + + pub(crate) fn convert_jsx_element_child(&mut self, jsx_element_child: &JSXElementChild) { + match jsx_element_child { + JSXElementChild::JSXText(jsx_text) => { + self.store_jsx_text(jsx_text); + } + JSXElementChild::JSXExprContainer(jsx_expr_container) => { + self.store_jsx_expression_container(jsx_expr_container); + } + JSXElementChild::JSXSpreadChild(jsx_spread_child) => { + self.store_jsx_spread_child(jsx_spread_child); + } + JSXElementChild::JSXFragment(jsx_fragment) => { + self.store_jsx_fragment(jsx_fragment); + } + JSXElementChild::JSXElement(jsx_element) => { + self.store_jsx_element(jsx_element); + } + } + } + + pub(crate) fn convert_jsx_element_name(&mut self, jsx_element_name: &JSXElementName) { + match jsx_element_name { + JSXElementName::Ident(identifier) => { + self.store_jsx_identifier(&identifier.span, &identifier.sym) + } + JSXElementName::JSXMemberExpr(jsx_member_expression) => { + self.store_jsx_member_expression(jsx_member_expression); + } + JSXElementName::JSXNamespacedName(_jsx_namespaced_name) => { + unimplemented!("JSXElementName::JSXNamespacedName") + } + } + } + + pub(crate) fn convert_jsx_object(&mut self, jsx_object: &JSXObject) { + match jsx_object { + JSXObject::JSXMemberExpr(jsx_member_expression) => { + self.store_jsx_member_expression(jsx_member_expression); + } + JSXObject::Ident(identifier) => { + self.store_jsx_identifier(&identifier.span, &identifier.sym); + } + } + } + + fn convert_literal(&mut self, literal: &Lit) { + match literal { + Lit::BigInt(bigint_literal) => self.store_literal_bigint(bigint_literal), + Lit::Bool(boolean_literal) => { + self.store_literal_boolean(boolean_literal); + } + Lit::Null(null_literal) => { + self.store_literal_null(null_literal); + } + Lit::Num(number_literal) => { + self.store_literal_number(number_literal); + } + Lit::Regex(regex_literal) => { + self.store_literal_regex(regex_literal); + } + Lit::Str(string_literal) => { + self.store_literal_string(string_literal); + } + Lit::JSXText(_) => unimplemented!("Lit::JsxText"), + } + } + + fn convert_module_declaration( + &mut self, + module_declaration: &ModuleDecl, + module_item_insert_position: &mut u32, + ) { + match module_declaration { + ModuleDecl::ExportDecl(export_declaration) => { + self.convert_export_declaration(export_declaration, module_item_insert_position) + } + ModuleDecl::ExportNamed(export_named) => { + self.convert_export_named_declaration(export_named, module_item_insert_position) + } + ModuleDecl::Import(import_declaration) => self.store_import_declaration(import_declaration), + ModuleDecl::ExportDefaultExpr(export_default_expression) => self + .convert_export_default_expression(export_default_expression, module_item_insert_position), + ModuleDecl::ExportAll(export_all) => self.convert_export_all(export_all), + ModuleDecl::ExportDefaultDecl(export_default_declaration) => self + .convert_export_default_declaration( + export_default_declaration, + module_item_insert_position, + ), + ModuleDecl::TsImportEquals(_) => unimplemented!("Cannot convert ModuleDecl::TsImportEquals"), + ModuleDecl::TsExportAssignment(_) => { + unimplemented!("Cannot convert ModuleDecl::TsExportAssignment") + } + ModuleDecl::TsNamespaceExport(_) => { + unimplemented!("Cannot convert ModuleDecl::TsNamespaceExport") + } + } + } + + pub(crate) fn convert_module_export_name(&mut self, module_export_name: &ModuleExportName) { + match module_export_name { + ModuleExportName::Ident(identifier) => self.convert_identifier(identifier), + ModuleExportName::Str(string_literal) => self.store_literal_string(string_literal), + } + } + + pub(crate) fn convert_module_item( + &mut self, + module_item: &ModuleItem, + module_item_insert_position: &mut u32, + ) { + match module_item { + ModuleItem::Stmt(statement) => self.convert_statement(statement), + ModuleItem::ModuleDecl(module_declaration) => { + self.convert_module_declaration(module_declaration, module_item_insert_position); + } + } + } + + pub(crate) fn convert_object_pattern_property( + &mut self, + object_pattern_property: &ObjectPatProp, + ) { + match object_pattern_property { + ObjectPatProp::Assign(assignment_pattern_property) => { + self.convert_assignment_pattern_property(assignment_pattern_property) + } + ObjectPatProp::KeyValue(key_value_pattern_property) => { + self.convert_key_value_pattern_property(key_value_pattern_property) + } + ObjectPatProp::Rest(rest_pattern) => self.store_rest_element(rest_pattern), + } + } + + pub(crate) fn convert_optional_chain_base( + &mut self, + optional_chain_base: &OptChainBase, + is_optional: bool, + ) { + match optional_chain_base { + OptChainBase::Member(member_expression) => { + self.convert_member_expression(member_expression, is_optional, true) + } + OptChainBase::Call(optional_call) => { + self.convert_optional_call(optional_call, is_optional, true) + } + } + } + + fn convert_parenthesized_expression(&mut self, parenthesized_expression: &ParenExpr) { + // We are doing this for the side effect of keeping annotations for call expressions + self.index_converter.convert( + parenthesized_expression.span.lo.0 - 1, + matches!( + &*parenthesized_expression.expr, + Expr::Call(_) | Expr::New(_) | Expr::Paren(_) + ), + ); + self.convert_expression(&parenthesized_expression.expr); + } + + pub(crate) fn convert_pattern(&mut self, pattern: &Pat) { + match pattern { + Pat::Array(array_pattern) => { + self.store_array_pattern(array_pattern); + } + Pat::Assign(assignment_pattern) => { + self.convert_assignment_pattern(assignment_pattern); + } + Pat::Expr(expression) => self.convert_expression(expression), + Pat::Ident(binding_identifier) => { + self.convert_binding_identifier(binding_identifier); + } + Pat::Object(object) => { + self.store_object_pattern(object); + } + Pat::Rest(rest_pattern) => { + self.store_rest_element(rest_pattern); + } + Pat::Invalid(_) => unimplemented!("Cannot convert Pat::Invalid"), + } + } + + pub(crate) fn convert_pattern_or_expression(&mut self, pattern_or_expression: &AssignTarget) { + match pattern_or_expression { + AssignTarget::Pat(assignment_target_pattern) => { + self.convert_assignment_target_pattern(assignment_target_pattern); + } + AssignTarget::Simple(simple_assigment_target) => { + self.convert_simple_assignment_target(simple_assigment_target); + } + } + } + + fn convert_assignment_target_pattern(&mut self, assignment_target_pattern: &AssignTargetPat) { + match assignment_target_pattern { + AssignTargetPat::Array(array_pattern) => self.store_array_pattern(array_pattern), + AssignTargetPat::Object(object_pattern) => self.store_object_pattern(object_pattern), + AssignTargetPat::Invalid(_) => unimplemented!("Cannot convert AssignTargetPat::Invalid"), + } + } + + fn convert_simple_assignment_target(&mut self, simple_assignment_target: &SimpleAssignTarget) { + match simple_assignment_target { + SimpleAssignTarget::Ident(binding_identifier) => { + self.convert_binding_identifier(binding_identifier) + } + SimpleAssignTarget::Member(member_expression) => { + self.convert_member_expression(member_expression, false, false) + } + SimpleAssignTarget::SuperProp(super_property) => self.convert_super_property(super_property), + SimpleAssignTarget::Paren(parenthesized_expression) => { + self.convert_parenthesized_expression(parenthesized_expression); + } + SimpleAssignTarget::OptChain(optional_chain_expression) => { + self.store_chain_expression(optional_chain_expression, false) + } + SimpleAssignTarget::TsAs(_) => unimplemented!("Cannot convert SimpleAssignTarget::TsAs"), + SimpleAssignTarget::TsSatisfies(_) => { + unimplemented!("Cannot convert SimpleAssignTarget::TsSatisfies") + } + SimpleAssignTarget::TsNonNull(_) => { + unimplemented!("Cannot convert SimpleAssignTarget::TsNonNull") + } + SimpleAssignTarget::TsTypeAssertion(_) => { + unimplemented!("Cannot convert SimpleAssignTarget::TsTypeAssertion") + } + SimpleAssignTarget::TsInstantiation(_) => { + unimplemented!("Cannot convert SimpleAssignTarget::TsInstantiation") + } + SimpleAssignTarget::Invalid(_) => { + unimplemented!("Cannot convert SimpleAssignTarget::Invalid") + } + } + } + + pub(crate) fn convert_property_name(&mut self, property_name: &PropName) { + match property_name { + PropName::Computed(computed_property_name) => { + self.convert_expression(computed_property_name.expr.as_ref()) + } + PropName::Ident(identifier_name) => { + self.convert_identifier_name(identifier_name); + } + PropName::Str(string) => { + self.store_literal_string(string); + } + PropName::Num(number) => { + self.store_literal_number(number); + } + PropName::BigInt(bigint) => { + self.store_literal_bigint(bigint); + } + } + } + + pub(crate) fn convert_property_or_spread(&mut self, property_or_spread: &PropOrSpread) { + match property_or_spread { + PropOrSpread::Prop(property) => self.convert_property(property), + PropOrSpread::Spread(spread_element) => self.convert_spread_element(spread_element), + } + } + + pub(crate) fn convert_statement(&mut self, statement: &Stmt) { + match statement { + Stmt::Break(break_statement) => self.store_break_statement(break_statement), + Stmt::Block(block_statement) => self.store_block_statement(block_statement, false), + Stmt::Continue(continue_statement) => self.store_continue_statement(continue_statement), + Stmt::Decl(declaration) => self.convert_declaration(declaration, None), + Stmt::Debugger(debugger_statement) => self.store_debugger_statement(debugger_statement), + Stmt::DoWhile(do_while_statement) => self.store_do_while_statement(do_while_statement), + Stmt::Empty(empty_statement) => self.store_empty_statement(empty_statement), + Stmt::Expr(expression_statement) => self.store_expression_statement(expression_statement), + Stmt::For(for_statement) => self.store_for_statement(for_statement), + Stmt::ForIn(for_in_statement) => self.store_for_in_statement(for_in_statement), + Stmt::ForOf(for_of_statement) => self.store_for_of_statement(for_of_statement), + Stmt::If(if_statement) => self.store_if_statement(if_statement), + Stmt::Labeled(labeled_statement) => self.store_labeled_statement(labeled_statement), + Stmt::Return(return_statement) => self.store_return_statement(return_statement), + Stmt::Switch(switch_statement) => self.store_switch_statement(switch_statement), + Stmt::Throw(throw_statement) => self.store_throw_statement(throw_statement), + Stmt::Try(try_statement) => self.store_try_statement(try_statement), + Stmt::While(while_statement) => self.store_while_statement(while_statement), + Stmt::With(_) => unimplemented!("Cannot convert Stmt::With"), + } + } + + pub(crate) fn convert_variable_declaration_or_expression( + &mut self, + variable_declaration_or_expression: &VarDeclOrExpr, + ) { + match variable_declaration_or_expression { + VarDeclOrExpr::VarDecl(variable_declaration) => { + self.store_variable_declaration(&VariableDeclaration::Var(variable_declaration)); + } + VarDeclOrExpr::Expr(expression) => { + self.convert_expression(expression); + } + } + } + + pub(crate) fn move_to_specific_index(&mut self, index: u32) { + self.index_converter.convert(index, false); + } +} + +pub(crate) fn convert_annotation(buffer: &mut Vec, annotation: &ConvertedAnnotation) { + // start + buffer.extend_from_slice(&annotation.start.to_ne_bytes()); + // end + buffer.extend_from_slice(&annotation.end.to_ne_bytes()); + // kind + buffer.extend_from_slice(match annotation.kind { + AnnotationKind::Pure => &STRING_PURE, + AnnotationKind::NoSideEffects => &STRING_NOSIDEEFFECTS, + AnnotationKind::SourceMappingUrl => &STRING_SOURCEMAP, + }); +} + +pub(crate) fn convert_string(buffer: &mut Vec, string: &str) { + let length = string.len(); + let additional_length = ((length + 3) & !3) - length; + buffer.extend_from_slice(&(length as u32).to_ne_bytes()); + buffer.extend_from_slice(string.as_bytes()); + buffer.resize(buffer.len() + additional_length, 0); +} + +pub(crate) fn update_reference_position(buffer: &mut [u8], reference_position: usize) { + let insert_position = (buffer.len() as u32) >> 2; + buffer[reference_position..reference_position + 4] + .copy_from_slice(&insert_position.to_ne_bytes()); +} + +pub(crate) fn get_outside_class_span_decorators_info<'a>( + span: &Span, + class: Option<&'a Class>, +) -> (Option, bool, bool, Option<&'a Vec>) { + let mut are_decorators_before_export = false; + let mut are_decorators_after_export = false; + let mut outside_class_span_decorators = None; + + if let Some(class) = class { + if !class.decorators.is_empty() { + let decorator_start_boundary = class.decorators[0].span.lo.0 - 1; + if decorator_start_boundary < span.lo.0 - 1 { + are_decorators_before_export = true; + outside_class_span_decorators = Some(&class.decorators); + } else if decorator_start_boundary < class.span.lo.0 - 1 { + are_decorators_after_export = true; + outside_class_span_decorators = Some(&class.decorators); + } + } + } + + ( + None, + are_decorators_before_export, + are_decorators_after_export, + outside_class_span_decorators, + ) +} diff --git a/rust/parse_ast/src/convert_ast/converter/analyze_code.rs b/rust/parse_ast/src/convert_ast/converter/analyze_code.rs new file mode 100644 index 00000000000..2aa770a98d9 --- /dev/null +++ b/rust/parse_ast/src/convert_ast/converter/analyze_code.rs @@ -0,0 +1,44 @@ +pub(crate) fn find_first_occurrence_outside_comment( + code: &[u8], + search_byte: u8, + start: u32, +) -> u32 { + let mut search_pos = start as usize; + let mut comment_type = CommentType::None; + loop { + match comment_type { + CommentType::SingleLine => { + if code[search_pos] == b'\n' { + comment_type = CommentType::None; + } + } + CommentType::MultiLine => { + if code[search_pos] == b'*' && code[search_pos + 1] == b'/' { + comment_type = CommentType::None; + search_pos += 1; + } + } + CommentType::None => { + if code[search_pos] == b'/' && code[search_pos + 1] == b'/' { + comment_type = CommentType::SingleLine; + search_pos += 1; + } else if code[search_pos] == b'/' && code[search_pos + 1] == b'*' { + comment_type = CommentType::MultiLine; + search_pos += 1; + } else if code[search_pos] == search_byte { + return search_pos as u32; + } + } + } + search_pos += 1; + if search_pos >= code.len() { + return code.len().try_into().unwrap(); + } + } +} + +enum CommentType { + SingleLine, + MultiLine, + None, +} diff --git a/rust/parse_ast/src/convert_ast/converter/ast_constants.rs b/rust/parse_ast/src/convert_ast/converter/ast_constants.rs new file mode 100644 index 00000000000..add6ddf81e8 --- /dev/null +++ b/rust/parse_ast/src/convert_ast/converter/ast_constants.rs @@ -0,0 +1,208 @@ +// This file is generated by scripts/generate-rust-constants.js. +// Do not edit this file directly. + +pub const TYPE_PANIC_ERROR: [u8; 4] = 0u32.to_ne_bytes(); +pub const TYPE_PARSE_ERROR: [u8; 4] = 1u32.to_ne_bytes(); +pub const TYPE_ARRAY_EXPRESSION: [u8; 4] = 2u32.to_ne_bytes(); +pub const TYPE_ARRAY_PATTERN: [u8; 4] = 3u32.to_ne_bytes(); +pub const TYPE_ARROW_FUNCTION_EXPRESSION: [u8; 4] = 4u32.to_ne_bytes(); +pub const TYPE_ASSIGNMENT_PATTERN: [u8; 4] = 6u32.to_ne_bytes(); +pub const TYPE_BINARY_EXPRESSION: [u8; 4] = 8u32.to_ne_bytes(); +pub const TYPE_BLOCK_STATEMENT: [u8; 4] = 9u32.to_ne_bytes(); +pub const TYPE_CALL_EXPRESSION: [u8; 4] = 11u32.to_ne_bytes(); +pub const TYPE_CATCH_CLAUSE: [u8; 4] = 12u32.to_ne_bytes(); +pub const TYPE_CHAIN_EXPRESSION: [u8; 4] = 13u32.to_ne_bytes(); +pub const TYPE_CLASS_BODY: [u8; 4] = 14u32.to_ne_bytes(); +pub const TYPE_CLASS_DECLARATION: [u8; 4] = 15u32.to_ne_bytes(); +pub const TYPE_CLASS_EXPRESSION: [u8; 4] = 16u32.to_ne_bytes(); +pub const TYPE_EXPORT_ALL_DECLARATION: [u8; 4] = 24u32.to_ne_bytes(); +pub const TYPE_EXPORT_DEFAULT_DECLARATION: [u8; 4] = 25u32.to_ne_bytes(); +pub const TYPE_EXPORT_NAMED_DECLARATION: [u8; 4] = 26u32.to_ne_bytes(); +pub const TYPE_FUNCTION_DECLARATION: [u8; 4] = 32u32.to_ne_bytes(); +pub const TYPE_FUNCTION_EXPRESSION: [u8; 4] = 33u32.to_ne_bytes(); +pub const TYPE_IDENTIFIER: [u8; 4] = 34u32.to_ne_bytes(); +pub const TYPE_IMPORT_ATTRIBUTE: [u8; 4] = 36u32.to_ne_bytes(); +pub const TYPE_IMPORT_DECLARATION: [u8; 4] = 37u32.to_ne_bytes(); +pub const TYPE_IMPORT_EXPRESSION: [u8; 4] = 39u32.to_ne_bytes(); +pub const TYPE_JSX_EMPTY_EXPRESSION: [u8; 4] = 46u32.to_ne_bytes(); +pub const TYPE_JSX_EXPRESSION_CONTAINER: [u8; 4] = 47u32.to_ne_bytes(); +pub const TYPE_JSX_MEMBER_EXPRESSION: [u8; 4] = 50u32.to_ne_bytes(); +pub const TYPE_JSX_NAMESPACED_NAME: [u8; 4] = 51u32.to_ne_bytes(); +pub const TYPE_JSX_OPENING_ELEMENT: [u8; 4] = 52u32.to_ne_bytes(); +pub const TYPE_JSX_SPREAD_ATTRIBUTE: [u8; 4] = 54u32.to_ne_bytes(); +pub const TYPE_LOGICAL_EXPRESSION: [u8; 4] = 64u32.to_ne_bytes(); +pub const TYPE_MEMBER_EXPRESSION: [u8; 4] = 65u32.to_ne_bytes(); +pub const TYPE_META_PROPERTY: [u8; 4] = 66u32.to_ne_bytes(); +pub const TYPE_METHOD_DEFINITION: [u8; 4] = 67u32.to_ne_bytes(); +pub const TYPE_NEW_EXPRESSION: [u8; 4] = 68u32.to_ne_bytes(); +pub const TYPE_PROGRAM: [u8; 4] = 72u32.to_ne_bytes(); +pub const TYPE_PROPERTY: [u8; 4] = 73u32.to_ne_bytes(); +pub const TYPE_PROPERTY_DEFINITION: [u8; 4] = 74u32.to_ne_bytes(); +pub const TYPE_REST_ELEMENT: [u8; 4] = 75u32.to_ne_bytes(); +pub const TYPE_SPREAD_ELEMENT: [u8; 4] = 78u32.to_ne_bytes(); +pub const TYPE_TEMPLATE_LITERAL: [u8; 4] = 85u32.to_ne_bytes(); +pub const TYPE_TRY_STATEMENT: [u8; 4] = 88u32.to_ne_bytes(); +pub const TYPE_VARIABLE_DECLARATION: [u8; 4] = 91u32.to_ne_bytes(); +pub const TYPE_VARIABLE_DECLARATOR: [u8; 4] = 92u32.to_ne_bytes(); + +pub const PANIC_ERROR_RESERVED_BYTES: usize = 8; +pub const PANIC_ERROR_MESSAGE_OFFSET: usize = 4; + +pub const PARSE_ERROR_RESERVED_BYTES: usize = 8; +pub const PARSE_ERROR_MESSAGE_OFFSET: usize = 4; + +pub const ARRAY_EXPRESSION_RESERVED_BYTES: usize = 8; +pub const ARRAY_EXPRESSION_ELEMENTS_OFFSET: usize = 4; + +pub const ARRAY_PATTERN_RESERVED_BYTES: usize = 8; +pub const ARRAY_PATTERN_ELEMENTS_OFFSET: usize = 4; + +pub const ARROW_FUNCTION_EXPRESSION_RESERVED_BYTES: usize = 20; +pub const ARROW_FUNCTION_EXPRESSION_ANNOTATIONS_OFFSET: usize = 8; +pub const ARROW_FUNCTION_EXPRESSION_PARAMS_OFFSET: usize = 12; +pub const ARROW_FUNCTION_EXPRESSION_BODY_OFFSET: usize = 16; + +pub const ASSIGNMENT_PATTERN_RESERVED_BYTES: usize = 12; +pub const ASSIGNMENT_PATTERN_LEFT_OFFSET: usize = 4; +pub const ASSIGNMENT_PATTERN_RIGHT_OFFSET: usize = 8; + +pub const BINARY_EXPRESSION_RESERVED_BYTES: usize = 16; +pub const BINARY_EXPRESSION_OPERATOR_OFFSET: usize = 4; +pub const BINARY_EXPRESSION_LEFT_OFFSET: usize = 8; +pub const BINARY_EXPRESSION_RIGHT_OFFSET: usize = 12; + +pub const BLOCK_STATEMENT_RESERVED_BYTES: usize = 8; +pub const BLOCK_STATEMENT_BODY_OFFSET: usize = 4; + +pub const CALL_EXPRESSION_RESERVED_BYTES: usize = 20; +pub const CALL_EXPRESSION_ANNOTATIONS_OFFSET: usize = 8; +pub const CALL_EXPRESSION_CALLEE_OFFSET: usize = 12; +pub const CALL_EXPRESSION_ARGUMENTS_OFFSET: usize = 16; + +pub const CATCH_CLAUSE_RESERVED_BYTES: usize = 12; +pub const CATCH_CLAUSE_PARAM_OFFSET: usize = 4; +pub const CATCH_CLAUSE_BODY_OFFSET: usize = 8; + +pub const CHAIN_EXPRESSION_RESERVED_BYTES: usize = 8; +pub const CHAIN_EXPRESSION_EXPRESSION_OFFSET: usize = 4; + +pub const CLASS_BODY_RESERVED_BYTES: usize = 8; +pub const CLASS_BODY_BODY_OFFSET: usize = 4; + +pub const CLASS_DECLARATION_RESERVED_BYTES: usize = 20; +pub const CLASS_DECLARATION_DECORATORS_OFFSET: usize = 4; +pub const CLASS_DECLARATION_ID_OFFSET: usize = 8; +pub const CLASS_DECLARATION_SUPER_CLASS_OFFSET: usize = 12; +pub const CLASS_DECLARATION_BODY_OFFSET: usize = 16; + +pub const EXPORT_ALL_DECLARATION_RESERVED_BYTES: usize = 16; +pub const EXPORT_ALL_DECLARATION_EXPORTED_OFFSET: usize = 4; +pub const EXPORT_ALL_DECLARATION_SOURCE_OFFSET: usize = 8; +pub const EXPORT_ALL_DECLARATION_ATTRIBUTES_OFFSET: usize = 12; + +pub const EXPORT_DEFAULT_DECLARATION_RESERVED_BYTES: usize = 8; +pub const EXPORT_DEFAULT_DECLARATION_DECLARATION_OFFSET: usize = 4; + +pub const EXPORT_NAMED_DECLARATION_RESERVED_BYTES: usize = 20; +pub const EXPORT_NAMED_DECLARATION_SPECIFIERS_OFFSET: usize = 4; +pub const EXPORT_NAMED_DECLARATION_SOURCE_OFFSET: usize = 8; +pub const EXPORT_NAMED_DECLARATION_ATTRIBUTES_OFFSET: usize = 12; +pub const EXPORT_NAMED_DECLARATION_DECLARATION_OFFSET: usize = 16; + +pub const FUNCTION_DECLARATION_RESERVED_BYTES: usize = 24; +pub const FUNCTION_DECLARATION_ANNOTATIONS_OFFSET: usize = 8; +pub const FUNCTION_DECLARATION_ID_OFFSET: usize = 12; +pub const FUNCTION_DECLARATION_PARAMS_OFFSET: usize = 16; +pub const FUNCTION_DECLARATION_BODY_OFFSET: usize = 20; + +pub const IDENTIFIER_RESERVED_BYTES: usize = 8; +pub const IDENTIFIER_NAME_OFFSET: usize = 4; + +pub const IMPORT_ATTRIBUTE_RESERVED_BYTES: usize = 12; +pub const IMPORT_ATTRIBUTE_KEY_OFFSET: usize = 4; +pub const IMPORT_ATTRIBUTE_VALUE_OFFSET: usize = 8; + +pub const IMPORT_DECLARATION_RESERVED_BYTES: usize = 16; +pub const IMPORT_DECLARATION_SPECIFIERS_OFFSET: usize = 4; +pub const IMPORT_DECLARATION_SOURCE_OFFSET: usize = 8; +pub const IMPORT_DECLARATION_ATTRIBUTES_OFFSET: usize = 12; + +pub const IMPORT_EXPRESSION_RESERVED_BYTES: usize = 12; +pub const IMPORT_EXPRESSION_SOURCE_OFFSET: usize = 4; +pub const IMPORT_EXPRESSION_OPTIONS_OFFSET: usize = 8; + +pub const JSX_EMPTY_EXPRESSION_RESERVED_BYTES: usize = 4; + +pub const JSX_EXPRESSION_CONTAINER_RESERVED_BYTES: usize = 8; +pub const JSX_EXPRESSION_CONTAINER_EXPRESSION_OFFSET: usize = 4; + +pub const JSX_MEMBER_EXPRESSION_RESERVED_BYTES: usize = 12; +pub const JSX_MEMBER_EXPRESSION_OBJECT_OFFSET: usize = 4; +pub const JSX_MEMBER_EXPRESSION_PROPERTY_OFFSET: usize = 8; + +pub const JSX_NAMESPACED_NAME_RESERVED_BYTES: usize = 12; +pub const JSX_NAMESPACED_NAME_NAMESPACE_OFFSET: usize = 4; +pub const JSX_NAMESPACED_NAME_NAME_OFFSET: usize = 8; + +pub const JSX_OPENING_ELEMENT_RESERVED_BYTES: usize = 16; +pub const JSX_OPENING_ELEMENT_NAME_OFFSET: usize = 8; +pub const JSX_OPENING_ELEMENT_ATTRIBUTES_OFFSET: usize = 12; + +pub const JSX_SPREAD_ATTRIBUTE_RESERVED_BYTES: usize = 8; +pub const JSX_SPREAD_ATTRIBUTE_ARGUMENT_OFFSET: usize = 4; + +pub const MEMBER_EXPRESSION_RESERVED_BYTES: usize = 16; +pub const MEMBER_EXPRESSION_OBJECT_OFFSET: usize = 8; +pub const MEMBER_EXPRESSION_PROPERTY_OFFSET: usize = 12; + +pub const META_PROPERTY_RESERVED_BYTES: usize = 12; +pub const META_PROPERTY_META_OFFSET: usize = 4; +pub const META_PROPERTY_PROPERTY_OFFSET: usize = 8; + +pub const METHOD_DEFINITION_RESERVED_BYTES: usize = 24; +pub const METHOD_DEFINITION_DECORATORS_OFFSET: usize = 8; +pub const METHOD_DEFINITION_KEY_OFFSET: usize = 12; +pub const METHOD_DEFINITION_VALUE_OFFSET: usize = 16; +pub const METHOD_DEFINITION_KIND_OFFSET: usize = 20; + +pub const NEW_EXPRESSION_RESERVED_BYTES: usize = 16; +pub const NEW_EXPRESSION_ANNOTATIONS_OFFSET: usize = 4; +pub const NEW_EXPRESSION_CALLEE_OFFSET: usize = 8; +pub const NEW_EXPRESSION_ARGUMENTS_OFFSET: usize = 12; + +pub const PROGRAM_RESERVED_BYTES: usize = 12; +pub const PROGRAM_BODY_OFFSET: usize = 4; +pub const PROGRAM_INVALID_ANNOTATIONS_OFFSET: usize = 8; + +pub const PROPERTY_RESERVED_BYTES: usize = 20; +pub const PROPERTY_KEY_OFFSET: usize = 8; +pub const PROPERTY_VALUE_OFFSET: usize = 12; +pub const PROPERTY_KIND_OFFSET: usize = 16; + +pub const PROPERTY_DEFINITION_RESERVED_BYTES: usize = 20; +pub const PROPERTY_DEFINITION_DECORATORS_OFFSET: usize = 8; +pub const PROPERTY_DEFINITION_KEY_OFFSET: usize = 12; +pub const PROPERTY_DEFINITION_VALUE_OFFSET: usize = 16; + +pub const REST_ELEMENT_RESERVED_BYTES: usize = 8; +pub const REST_ELEMENT_ARGUMENT_OFFSET: usize = 4; + +pub const SPREAD_ELEMENT_RESERVED_BYTES: usize = 8; +pub const SPREAD_ELEMENT_ARGUMENT_OFFSET: usize = 4; + +pub const TEMPLATE_LITERAL_RESERVED_BYTES: usize = 12; +pub const TEMPLATE_LITERAL_QUASIS_OFFSET: usize = 4; +pub const TEMPLATE_LITERAL_EXPRESSIONS_OFFSET: usize = 8; + +pub const TRY_STATEMENT_RESERVED_BYTES: usize = 16; +pub const TRY_STATEMENT_BLOCK_OFFSET: usize = 4; +pub const TRY_STATEMENT_HANDLER_OFFSET: usize = 8; +pub const TRY_STATEMENT_FINALIZER_OFFSET: usize = 12; + +pub const VARIABLE_DECLARATION_RESERVED_BYTES: usize = 12; +pub const VARIABLE_DECLARATION_KIND_OFFSET: usize = 4; +pub const VARIABLE_DECLARATION_DECLARATIONS_OFFSET: usize = 8; + +pub const VARIABLE_DECLARATOR_RESERVED_BYTES: usize = 12; +pub const VARIABLE_DECLARATOR_ID_OFFSET: usize = 4; +pub const VARIABLE_DECLARATOR_INIT_OFFSET: usize = 8; diff --git a/rust/parse_ast/src/convert_ast/converter/ast_macros.rs b/rust/parse_ast/src/convert_ast/converter/ast_macros.rs new file mode 100644 index 00000000000..84fff18bf9a --- /dev/null +++ b/rust/parse_ast/src/convert_ast/converter/ast_macros.rs @@ -0,0 +1,1050 @@ +// This file is generated by scripts/generate-ast-macros.js. +// Do not edit this file directly. + +#[macro_export] +macro_rules! store_assignment_expression { + ($self:expr, span => $span:expr, operator => $operator_value:expr, left => [$left_value:expr, $left_converter:ident], right => [$right_value:expr, $right_converter:ident]) => { + let _: &mut AstConverter = $self; + let end_position = $self.add_type_and_start(&5u32.to_ne_bytes(), &$span, 16, false); + // operator + let operator_position = end_position + 4; + $self.buffer[operator_position..operator_position + 4].copy_from_slice($operator_value); + // left + $self.update_reference_position(end_position + 8); + $self.$left_converter(&$left_value); + // right + $self.update_reference_position(end_position + 12); + $self.$right_converter(&$right_value); + // end + $self.add_end(end_position, &$span); + }; +} + +#[macro_export] +macro_rules! store_await_expression { + ($self:expr, span => $span:expr, argument => [$argument_value:expr, $argument_converter:ident]) => { + let _: &mut AstConverter = $self; + let end_position = $self.add_type_and_start(&7u32.to_ne_bytes(), &$span, 8, false); + // argument + $self.update_reference_position(end_position + 4); + $self.$argument_converter(&$argument_value); + // end + $self.add_end(end_position, &$span); + }; +} + +#[macro_export] +macro_rules! store_break_statement { + ($self:expr, span => $span:expr, label => [$label_value:expr, $label_converter:ident]) => { + let _: &mut AstConverter = $self; + let end_position = $self.add_type_and_start(&10u32.to_ne_bytes(), &$span, 8, false); + // label + if let Some(value) = $label_value.as_ref() { + $self.update_reference_position(end_position + 4); + $self.$label_converter(value); + } + // end + $self.add_end(end_position, &$span); + }; +} + +#[macro_export] +macro_rules! store_conditional_expression { + ($self:expr, span => $span:expr, test => [$test_value:expr, $test_converter:ident], consequent => [$consequent_value:expr, $consequent_converter:ident], alternate => [$alternate_value:expr, $alternate_converter:ident]) => { + let _: &mut AstConverter = $self; + let end_position = $self.add_type_and_start(&17u32.to_ne_bytes(), &$span, 16, false); + // test + $self.update_reference_position(end_position + 4); + $self.$test_converter(&$test_value); + // consequent + $self.update_reference_position(end_position + 8); + $self.$consequent_converter(&$consequent_value); + // alternate + $self.update_reference_position(end_position + 12); + $self.$alternate_converter(&$alternate_value); + // end + $self.add_end(end_position, &$span); + }; +} + +#[macro_export] +macro_rules! store_continue_statement { + ($self:expr, span => $span:expr, label => [$label_value:expr, $label_converter:ident]) => { + let _: &mut AstConverter = $self; + let end_position = $self.add_type_and_start(&18u32.to_ne_bytes(), &$span, 8, false); + // label + if let Some(value) = $label_value.as_ref() { + $self.update_reference_position(end_position + 4); + $self.$label_converter(value); + } + // end + $self.add_end(end_position, &$span); + }; +} + +#[macro_export] +macro_rules! store_debugger_statement { + ($self:expr, span => $span:expr) => { + let _: &mut AstConverter = $self; + let end_position = $self.add_type_and_start(&19u32.to_ne_bytes(), &$span, 4, false); + // end + $self.add_end(end_position, &$span); + }; +} + +#[macro_export] +macro_rules! store_decorator { + ($self:expr, span => $span:expr, expression => [$expression_value:expr, $expression_converter:ident]) => { + let _: &mut AstConverter = $self; + let end_position = $self.add_type_and_start(&20u32.to_ne_bytes(), &$span, 8, false); + // expression + $self.update_reference_position(end_position + 4); + $self.$expression_converter(&$expression_value); + // end + $self.add_end(end_position, &$span); + }; +} + +#[macro_export] +macro_rules! store_directive { + ($self:expr, span => $span:expr, directive => $directive_value:expr, expression => [$expression_value:expr, $expression_converter:ident]) => { + let _: &mut AstConverter = $self; + let end_position = $self.add_type_and_start(&21u32.to_ne_bytes(), &$span, 12, false); + // directive + $self.convert_string($directive_value, end_position + 4); + // expression + $self.update_reference_position(end_position + 8); + $self.$expression_converter(&$expression_value); + // end + $self.add_end(end_position, &$span); + }; +} + +#[macro_export] +macro_rules! store_do_while_statement { + ($self:expr, span => $span:expr, body => [$body_value:expr, $body_converter:ident], test => [$test_value:expr, $test_converter:ident]) => { + let _: &mut AstConverter = $self; + let end_position = $self.add_type_and_start(&22u32.to_ne_bytes(), &$span, 12, false); + // body + $self.update_reference_position(end_position + 4); + $self.$body_converter(&$body_value); + // test + $self.update_reference_position(end_position + 8); + $self.$test_converter(&$test_value); + // end + $self.add_end(end_position, &$span); + }; +} + +#[macro_export] +macro_rules! store_empty_statement { + ($self:expr, span => $span:expr) => { + let _: &mut AstConverter = $self; + let end_position = $self.add_type_and_start(&23u32.to_ne_bytes(), &$span, 4, false); + // end + $self.add_end(end_position, &$span); + }; +} + +#[macro_export] +macro_rules! store_export_specifier { + ($self:expr, span => $span:expr, local => [$local_value:expr, $local_converter:ident], exported => [$exported_value:expr, $exported_converter:ident]) => { + let _: &mut AstConverter = $self; + let end_position = $self.add_type_and_start(&27u32.to_ne_bytes(), &$span, 12, false); + // local + $self.update_reference_position(end_position + 4); + $self.$local_converter(&$local_value); + // exported + if let Some(value) = $exported_value.as_ref() { + $self.update_reference_position(end_position + 8); + $self.$exported_converter(value); + } + // end + $self.add_end(end_position, &$span); + }; +} + +#[macro_export] +macro_rules! store_expression_statement { + ($self:expr, span => $span:expr, expression => [$expression_value:expr, $expression_converter:ident]) => { + let _: &mut AstConverter = $self; + let end_position = $self.add_type_and_start(&28u32.to_ne_bytes(), &$span, 8, false); + // expression + $self.update_reference_position(end_position + 4); + $self.$expression_converter(&$expression_value); + // end + $self.add_end(end_position, &$span); + }; +} + +#[macro_export] +macro_rules! store_for_in_statement { + ($self:expr, span => $span:expr, left => [$left_value:expr, $left_converter:ident], right => [$right_value:expr, $right_converter:ident], body => [$body_value:expr, $body_converter:ident]) => { + let _: &mut AstConverter = $self; + let end_position = $self.add_type_and_start(&29u32.to_ne_bytes(), &$span, 16, false); + // left + $self.update_reference_position(end_position + 4); + $self.$left_converter(&$left_value); + // right + $self.update_reference_position(end_position + 8); + $self.$right_converter(&$right_value); + // body + $self.update_reference_position(end_position + 12); + $self.$body_converter(&$body_value); + // end + $self.add_end(end_position, &$span); + }; +} + +#[macro_export] +macro_rules! store_for_of_statement { + ($self:expr, span => $span:expr, await => $await_value:expr, left => [$left_value:expr, $left_converter:ident], right => [$right_value:expr, $right_converter:ident], body => [$body_value:expr, $body_converter:ident]) => { + let _: &mut AstConverter = $self; + let end_position = $self.add_type_and_start( + &30u32.to_ne_bytes(), + &$span, + 20, + false, + ); + // flags + store_for_of_statement_flags!($self, end_position, await => $await_value); + // left + $self.update_reference_position(end_position + 8); + $self.$left_converter(&$left_value); + // right + $self.update_reference_position(end_position + 12); + $self.$right_converter(&$right_value); + // body + $self.update_reference_position(end_position + 16); + $self.$body_converter(&$body_value); + // end + $self.add_end(end_position, &$span); + }; +} + +#[macro_export] +macro_rules! store_for_statement { + ($self:expr, span => $span:expr, init => [$init_value:expr, $init_converter:ident], test => [$test_value:expr, $test_converter:ident], update => [$update_value:expr, $update_converter:ident], body => [$body_value:expr, $body_converter:ident]) => { + let _: &mut AstConverter = $self; + let end_position = $self.add_type_and_start(&31u32.to_ne_bytes(), &$span, 20, false); + // init + if let Some(value) = $init_value.as_ref() { + $self.update_reference_position(end_position + 4); + $self.$init_converter(value); + } + // test + if let Some(value) = $test_value.as_ref() { + $self.update_reference_position(end_position + 8); + $self.$test_converter(value); + } + // update + if let Some(value) = $update_value.as_ref() { + $self.update_reference_position(end_position + 12); + $self.$update_converter(value); + } + // body + $self.update_reference_position(end_position + 16); + $self.$body_converter(&$body_value); + // end + $self.add_end(end_position, &$span); + }; +} + +#[macro_export] +macro_rules! store_if_statement { + ($self:expr, span => $span:expr, test => [$test_value:expr, $test_converter:ident], consequent => [$consequent_value:expr, $consequent_converter:ident], alternate => [$alternate_value:expr, $alternate_converter:ident]) => { + let _: &mut AstConverter = $self; + let end_position = $self.add_type_and_start(&35u32.to_ne_bytes(), &$span, 16, false); + // test + $self.update_reference_position(end_position + 4); + $self.$test_converter(&$test_value); + // consequent + $self.update_reference_position(end_position + 8); + $self.$consequent_converter(&$consequent_value); + // alternate + if let Some(value) = $alternate_value.as_ref() { + $self.update_reference_position(end_position + 12); + $self.$alternate_converter(value); + } + // end + $self.add_end(end_position, &$span); + }; +} + +#[macro_export] +macro_rules! store_import_default_specifier { + ($self:expr, span => $span:expr, local => [$local_value:expr, $local_converter:ident]) => { + let _: &mut AstConverter = $self; + let end_position = $self.add_type_and_start(&38u32.to_ne_bytes(), &$span, 8, false); + // local + $self.update_reference_position(end_position + 4); + $self.$local_converter(&$local_value); + // end + $self.add_end(end_position, &$span); + }; +} + +#[macro_export] +macro_rules! store_import_namespace_specifier { + ($self:expr, span => $span:expr, local => [$local_value:expr, $local_converter:ident]) => { + let _: &mut AstConverter = $self; + let end_position = $self.add_type_and_start(&40u32.to_ne_bytes(), &$span, 8, false); + // local + $self.update_reference_position(end_position + 4); + $self.$local_converter(&$local_value); + // end + $self.add_end(end_position, &$span); + }; +} + +#[macro_export] +macro_rules! store_import_specifier { + ($self:expr, span => $span:expr, imported => [$imported_value:expr, $imported_converter:ident], local => [$local_value:expr, $local_converter:ident]) => { + let _: &mut AstConverter = $self; + let end_position = $self.add_type_and_start(&41u32.to_ne_bytes(), &$span, 12, false); + // imported + if let Some(value) = $imported_value.as_ref() { + $self.update_reference_position(end_position + 4); + $self.$imported_converter(value); + } + // local + $self.update_reference_position(end_position + 8); + $self.$local_converter(&$local_value); + // end + $self.add_end(end_position, &$span); + }; +} + +#[macro_export] +macro_rules! store_jsx_attribute { + ($self:expr, span => $span:expr, name => [$name_value:expr, $name_converter:ident], value => [$value_value:expr, $value_converter:ident]) => { + let _: &mut AstConverter = $self; + let end_position = $self.add_type_and_start(&42u32.to_ne_bytes(), &$span, 12, false); + // name + $self.update_reference_position(end_position + 4); + $self.$name_converter(&$name_value); + // value + if let Some(value) = $value_value.as_ref() { + $self.update_reference_position(end_position + 8); + $self.$value_converter(value); + } + // end + $self.add_end(end_position, &$span); + }; +} + +#[macro_export] +macro_rules! store_jsx_closing_element { + ($self:expr, span => $span:expr, name => [$name_value:expr, $name_converter:ident]) => { + let _: &mut AstConverter = $self; + let end_position = $self.add_type_and_start(&43u32.to_ne_bytes(), &$span, 8, false); + // name + $self.update_reference_position(end_position + 4); + $self.$name_converter(&$name_value); + // end + $self.add_end(end_position, &$span); + }; +} + +#[macro_export] +macro_rules! store_jsx_closing_fragment { + ($self:expr, span => $span:expr) => { + let _: &mut AstConverter = $self; + let end_position = $self.add_type_and_start(&44u32.to_ne_bytes(), &$span, 4, false); + // end + $self.add_end(end_position, &$span); + }; +} + +#[macro_export] +macro_rules! store_jsx_element { + ($self:expr, span => $span:expr, openingElement => [$openingElement_value:expr, $openingElement_converter:ident], children => [$children_value:expr, $children_converter:ident], closingElement => [$closingElement_value:expr, $closingElement_converter:ident]) => { + let _: &mut AstConverter = $self; + let end_position = $self.add_type_and_start(&45u32.to_ne_bytes(), &$span, 16, false); + // openingElement + $self.update_reference_position(end_position + 4); + $self.$openingElement_converter(&$openingElement_value); + // children + $self.convert_item_list(&$children_value, end_position + 8, |ast_converter, node| { + ast_converter.$children_converter(node); + true + }); + // closingElement + if let Some(value) = $closingElement_value.as_ref() { + $self.update_reference_position(end_position + 12); + $self.$closingElement_converter(value); + } + // end + $self.add_end(end_position, &$span); + }; +} + +#[macro_export] +macro_rules! store_jsx_fragment { + ($self:expr, span => $span:expr, openingFragment => [$openingFragment_value:expr, $openingFragment_converter:ident], children => [$children_value:expr, $children_converter:ident], closingFragment => [$closingFragment_value:expr, $closingFragment_converter:ident]) => { + let _: &mut AstConverter = $self; + let end_position = $self.add_type_and_start(&48u32.to_ne_bytes(), &$span, 16, false); + // openingFragment + $self.update_reference_position(end_position + 4); + $self.$openingFragment_converter(&$openingFragment_value); + // children + $self.convert_item_list(&$children_value, end_position + 8, |ast_converter, node| { + ast_converter.$children_converter(node); + true + }); + // closingFragment + $self.update_reference_position(end_position + 12); + $self.$closingFragment_converter(&$closingFragment_value); + // end + $self.add_end(end_position, &$span); + }; +} + +#[macro_export] +macro_rules! store_jsx_identifier { + ($self:expr, span => $span:expr, name => $name_value:expr) => { + let _: &mut AstConverter = $self; + let end_position = $self.add_type_and_start(&49u32.to_ne_bytes(), &$span, 8, false); + // name + $self.convert_string($name_value, end_position + 4); + // end + $self.add_end(end_position, &$span); + }; +} + +#[macro_export] +macro_rules! store_jsx_opening_fragment { + ($self:expr, span => $span:expr) => { + let _: &mut AstConverter = $self; + let end_position = $self.add_type_and_start(&53u32.to_ne_bytes(), &$span, 4, false); + // end + $self.add_end(end_position, &$span); + }; +} + +#[macro_export] +macro_rules! store_jsx_spread_child { + ($self:expr, span => $span:expr, expression => [$expression_value:expr, $expression_converter:ident]) => { + let _: &mut AstConverter = $self; + let end_position = $self.add_type_and_start(&55u32.to_ne_bytes(), &$span, 8, false); + // expression + $self.update_reference_position(end_position + 4); + $self.$expression_converter(&$expression_value); + // end + $self.add_end(end_position, &$span); + }; +} + +#[macro_export] +macro_rules! store_jsx_text { + ($self:expr, span => $span:expr, value => $value_value:expr, raw => $raw_value:expr) => { + let _: &mut AstConverter = $self; + let end_position = $self.add_type_and_start(&56u32.to_ne_bytes(), &$span, 12, false); + // value + $self.convert_string($value_value, end_position + 4); + // raw + $self.convert_string($raw_value, end_position + 8); + // end + $self.add_end(end_position, &$span); + }; +} + +#[macro_export] +macro_rules! store_labeled_statement { + ($self:expr, span => $span:expr, label => [$label_value:expr, $label_converter:ident], body => [$body_value:expr, $body_converter:ident]) => { + let _: &mut AstConverter = $self; + let end_position = $self.add_type_and_start(&57u32.to_ne_bytes(), &$span, 12, false); + // label + $self.update_reference_position(end_position + 4); + $self.$label_converter(&$label_value); + // body + $self.update_reference_position(end_position + 8); + $self.$body_converter(&$body_value); + // end + $self.add_end(end_position, &$span); + }; +} + +#[macro_export] +macro_rules! store_literal_big_int { + ($self:expr, span => $span:expr, bigint => $bigint_value:expr, raw => $raw_value:expr) => { + let _: &mut AstConverter = $self; + let end_position = $self.add_type_and_start(&58u32.to_ne_bytes(), &$span, 12, false); + // bigint + $self.convert_string($bigint_value, end_position + 4); + // raw + $self.convert_string($raw_value, end_position + 8); + // end + $self.add_end(end_position, &$span); + }; +} + +#[macro_export] +macro_rules! store_literal_boolean { + ($self:expr, span => $span:expr, value => $value_value:expr) => { + let _: &mut AstConverter = $self; + let end_position = $self.add_type_and_start( + &59u32.to_ne_bytes(), + &$span, + 8, + false, + ); + // flags + store_literal_boolean_flags!($self, end_position, value => $value_value); + // end + $self.add_end(end_position, &$span); + }; +} + +#[macro_export] +macro_rules! store_literal_null { + ($self:expr, span => $span:expr) => { + let _: &mut AstConverter = $self; + let end_position = $self.add_type_and_start(&60u32.to_ne_bytes(), &$span, 4, false); + // end + $self.add_end(end_position, &$span); + }; +} + +#[macro_export] +macro_rules! store_literal_number { + ($self:expr, span => $span:expr, raw => $raw_value:expr, value => $value_value:expr) => { + let _: &mut AstConverter = $self; + let end_position = $self.add_type_and_start(&61u32.to_ne_bytes(), &$span, 16, false); + // raw + if let Some(value) = $raw_value.as_ref() { + $self.convert_string(value, end_position + 4); + } + // value + let value_position = end_position + 8; + $self.buffer[value_position..value_position + 8].copy_from_slice(&$value_value.to_le_bytes()); + // end + $self.add_end(end_position, &$span); + }; +} + +#[macro_export] +macro_rules! store_literal_reg_exp { + ($self:expr, span => $span:expr, flags => $flags_value:expr, pattern => $pattern_value:expr) => { + let _: &mut AstConverter = $self; + let end_position = $self.add_type_and_start(&62u32.to_ne_bytes(), &$span, 12, false); + // flags + $self.convert_string($flags_value, end_position + 4); + // pattern + $self.convert_string($pattern_value, end_position + 8); + // end + $self.add_end(end_position, &$span); + }; +} + +#[macro_export] +macro_rules! store_literal_string { + ($self:expr, span => $span:expr, value => $value_value:expr, raw => $raw_value:expr) => { + let _: &mut AstConverter = $self; + let end_position = $self.add_type_and_start(&63u32.to_ne_bytes(), &$span, 12, false); + // value + $self.convert_string($value_value, end_position + 4); + // raw + if let Some(value) = $raw_value.as_ref() { + $self.convert_string(value, end_position + 8); + } + // end + $self.add_end(end_position, &$span); + }; +} + +#[macro_export] +macro_rules! store_object_expression { + ($self:expr, span => $span:expr, properties => [$properties_value:expr, $properties_converter:ident]) => { + let _: &mut AstConverter = $self; + let end_position = $self.add_type_and_start(&69u32.to_ne_bytes(), &$span, 8, false); + // properties + $self.convert_item_list( + &$properties_value, + end_position + 4, + |ast_converter, node| { + ast_converter.$properties_converter(node); + true + }, + ); + // end + $self.add_end(end_position, &$span); + }; +} + +#[macro_export] +macro_rules! store_object_pattern { + ($self:expr, span => $span:expr, properties => [$properties_value:expr, $properties_converter:ident]) => { + let _: &mut AstConverter = $self; + let end_position = $self.add_type_and_start(&70u32.to_ne_bytes(), &$span, 8, false); + // properties + $self.convert_item_list( + &$properties_value, + end_position + 4, + |ast_converter, node| { + ast_converter.$properties_converter(node); + true + }, + ); + // end + $self.add_end(end_position, &$span); + }; +} + +#[macro_export] +macro_rules! store_private_identifier { + ($self:expr, span => $span:expr, name => $name_value:expr) => { + let _: &mut AstConverter = $self; + let end_position = $self.add_type_and_start(&71u32.to_ne_bytes(), &$span, 8, false); + // name + $self.convert_string($name_value, end_position + 4); + // end + $self.add_end(end_position, &$span); + }; +} + +#[macro_export] +macro_rules! store_return_statement { + ($self:expr, span => $span:expr, argument => [$argument_value:expr, $argument_converter:ident]) => { + let _: &mut AstConverter = $self; + let end_position = $self.add_type_and_start(&76u32.to_ne_bytes(), &$span, 8, false); + // argument + if let Some(value) = $argument_value.as_ref() { + $self.update_reference_position(end_position + 4); + $self.$argument_converter(value); + } + // end + $self.add_end(end_position, &$span); + }; +} + +#[macro_export] +macro_rules! store_sequence_expression { + ($self:expr, span => $span:expr, expressions => [$expressions_value:expr, $expressions_converter:ident]) => { + let _: &mut AstConverter = $self; + let end_position = $self.add_type_and_start(&77u32.to_ne_bytes(), &$span, 8, false); + // expressions + $self.convert_item_list( + &$expressions_value, + end_position + 4, + |ast_converter, node| { + ast_converter.$expressions_converter(node); + true + }, + ); + // end + $self.add_end(end_position, &$span); + }; +} + +#[macro_export] +macro_rules! store_static_block { + ($self:expr, span => $span:expr, body => [$body_value:expr, $body_converter:ident]) => { + let _: &mut AstConverter = $self; + let end_position = $self.add_type_and_start(&79u32.to_ne_bytes(), &$span, 8, false); + // body + $self.convert_item_list(&$body_value, end_position + 4, |ast_converter, node| { + ast_converter.$body_converter(node); + true + }); + // end + $self.add_end(end_position, &$span); + }; +} + +#[macro_export] +macro_rules! store_super_element { + ($self:expr, span => $span:expr) => { + let _: &mut AstConverter = $self; + let end_position = $self.add_type_and_start(&80u32.to_ne_bytes(), &$span, 4, false); + // end + $self.add_end(end_position, &$span); + }; +} + +#[macro_export] +macro_rules! store_switch_case { + ($self:expr, span => $span:expr, test => [$test_value:expr, $test_converter:ident], consequent => [$consequent_value:expr, $consequent_converter:ident]) => { + let _: &mut AstConverter = $self; + let end_position = $self.add_type_and_start(&81u32.to_ne_bytes(), &$span, 12, false); + // test + if let Some(value) = $test_value.as_ref() { + $self.update_reference_position(end_position + 4); + $self.$test_converter(value); + } + // consequent + $self.convert_item_list( + &$consequent_value, + end_position + 8, + |ast_converter, node| { + ast_converter.$consequent_converter(node); + true + }, + ); + // end + $self.add_end(end_position, &$span); + }; +} + +#[macro_export] +macro_rules! store_switch_statement { + ($self:expr, span => $span:expr, discriminant => [$discriminant_value:expr, $discriminant_converter:ident], cases => [$cases_value:expr, $cases_converter:ident]) => { + let _: &mut AstConverter = $self; + let end_position = $self.add_type_and_start(&82u32.to_ne_bytes(), &$span, 12, false); + // discriminant + $self.update_reference_position(end_position + 4); + $self.$discriminant_converter(&$discriminant_value); + // cases + $self.convert_item_list(&$cases_value, end_position + 8, |ast_converter, node| { + ast_converter.$cases_converter(node); + true + }); + // end + $self.add_end(end_position, &$span); + }; +} + +#[macro_export] +macro_rules! store_tagged_template_expression { + ($self:expr, span => $span:expr, tag => [$tag_value:expr, $tag_converter:ident], quasi => [$quasi_value:expr, $quasi_converter:ident]) => { + let _: &mut AstConverter = $self; + let end_position = $self.add_type_and_start(&83u32.to_ne_bytes(), &$span, 12, false); + // tag + $self.update_reference_position(end_position + 4); + $self.$tag_converter(&$tag_value); + // quasi + $self.update_reference_position(end_position + 8); + $self.$quasi_converter(&$quasi_value); + // end + $self.add_end(end_position, &$span); + }; +} + +#[macro_export] +macro_rules! store_template_element { + ($self:expr, span => $span:expr, tail => $tail_value:expr, cooked => $cooked_value:expr, raw => $raw_value:expr) => { + let _: &mut AstConverter = $self; + let end_position = $self.add_type_and_start( + &84u32.to_ne_bytes(), + &$span, + 16, + false, + ); + // flags + store_template_element_flags!($self, end_position, tail => $tail_value); + // cooked + if let Some(value) = $cooked_value.as_ref() { + $self.convert_string(value, end_position + 8); + } + // raw + $self.convert_string($raw_value, end_position + 12); + // end + $self.add_end(end_position, &$span); + }; +} + +#[macro_export] +macro_rules! store_this_expression { + ($self:expr, span => $span:expr) => { + let _: &mut AstConverter = $self; + let end_position = $self.add_type_and_start(&86u32.to_ne_bytes(), &$span, 4, false); + // end + $self.add_end(end_position, &$span); + }; +} + +#[macro_export] +macro_rules! store_throw_statement { + ($self:expr, span => $span:expr, argument => [$argument_value:expr, $argument_converter:ident]) => { + let _: &mut AstConverter = $self; + let end_position = $self.add_type_and_start(&87u32.to_ne_bytes(), &$span, 8, false); + // argument + $self.update_reference_position(end_position + 4); + $self.$argument_converter(&$argument_value); + // end + $self.add_end(end_position, &$span); + }; +} + +#[macro_export] +macro_rules! store_unary_expression { + ($self:expr, span => $span:expr, operator => $operator_value:expr, argument => [$argument_value:expr, $argument_converter:ident]) => { + let _: &mut AstConverter = $self; + let end_position = $self.add_type_and_start(&89u32.to_ne_bytes(), &$span, 12, false); + // operator + let operator_position = end_position + 4; + $self.buffer[operator_position..operator_position + 4].copy_from_slice($operator_value); + // argument + $self.update_reference_position(end_position + 8); + $self.$argument_converter(&$argument_value); + // end + $self.add_end(end_position, &$span); + }; +} + +#[macro_export] +macro_rules! store_update_expression { + ($self:expr, span => $span:expr, prefix => $prefix_value:expr, operator => $operator_value:expr, argument => [$argument_value:expr, $argument_converter:ident]) => { + let _: &mut AstConverter = $self; + let end_position = $self.add_type_and_start( + &90u32.to_ne_bytes(), + &$span, + 16, + false, + ); + // flags + store_update_expression_flags!($self, end_position, prefix => $prefix_value); + // operator + let operator_position = end_position + 8; + $self.buffer[operator_position..operator_position + 4].copy_from_slice($operator_value); + // argument + $self.update_reference_position(end_position + 12); + $self.$argument_converter(&$argument_value); + // end + $self.add_end(end_position, &$span); + }; +} + +#[macro_export] +macro_rules! store_while_statement { + ($self:expr, span => $span:expr, test => [$test_value:expr, $test_converter:ident], body => [$body_value:expr, $body_converter:ident]) => { + let _: &mut AstConverter = $self; + let end_position = $self.add_type_and_start(&93u32.to_ne_bytes(), &$span, 12, false); + // test + $self.update_reference_position(end_position + 4); + $self.$test_converter(&$test_value); + // body + $self.update_reference_position(end_position + 8); + $self.$body_converter(&$body_value); + // end + $self.add_end(end_position, &$span); + }; +} + +#[macro_export] +macro_rules! store_yield_expression { + ($self:expr, span => $span:expr, delegate => $delegate_value:expr, argument => [$argument_value:expr, $argument_converter:ident]) => { + let _: &mut AstConverter = $self; + let end_position = $self.add_type_and_start( + &94u32.to_ne_bytes(), + &$span, + 12, + false, + ); + // flags + store_yield_expression_flags!($self, end_position, delegate => $delegate_value); + // argument + if let Some(value) = $argument_value.as_ref() { + $self.update_reference_position(end_position + 8); + $self.$argument_converter(value); + } + // end + $self.add_end(end_position, &$span); + }; +} + +#[macro_export] +macro_rules! store_arrow_function_expression_flags { + ($self:expr, $end_position:expr, async => $async_value:expr, expression => $expression_value:expr, generator => $generator_value:expr) => { + let _: &mut AstConverter = $self; + let _: usize = $end_position; + let mut flags = 0u32; + if $async_value { + flags |= 1; + } + if $expression_value { + flags |= 2; + } + if $generator_value { + flags |= 4; + } + let flags_position = $end_position + 4; + $self.buffer[flags_position..flags_position + 4].copy_from_slice(&flags.to_ne_bytes()); + }; +} + +#[macro_export] +macro_rules! store_call_expression_flags { + ($self:expr, $end_position:expr, optional => $optional_value:expr) => { + let _: &mut AstConverter = $self; + let _: usize = $end_position; + let mut flags = 0u32; + if $optional_value { + flags |= 1; + } + let flags_position = $end_position + 4; + $self.buffer[flags_position..flags_position + 4].copy_from_slice(&flags.to_ne_bytes()); + }; +} + +#[macro_export] +macro_rules! store_for_of_statement_flags { + ($self:expr, $end_position:expr, await => $await_value:expr) => { + let _: &mut AstConverter = $self; + let _: usize = $end_position; + let mut flags = 0u32; + if $await_value { + flags |= 1; + } + let flags_position = $end_position + 4; + $self.buffer[flags_position..flags_position + 4].copy_from_slice(&flags.to_ne_bytes()); + }; +} + +#[macro_export] +macro_rules! store_function_declaration_flags { + ($self:expr, $end_position:expr, async => $async_value:expr, generator => $generator_value:expr) => { + let _: &mut AstConverter = $self; + let _: usize = $end_position; + let mut flags = 0u32; + if $async_value { + flags |= 1; + } + if $generator_value { + flags |= 2; + } + let flags_position = $end_position + 4; + $self.buffer[flags_position..flags_position + 4].copy_from_slice(&flags.to_ne_bytes()); + }; +} + +#[macro_export] +macro_rules! store_jsx_opening_element_flags { + ($self:expr, $end_position:expr, selfClosing => $selfClosing_value:expr) => { + let _: &mut AstConverter = $self; + let _: usize = $end_position; + let mut flags = 0u32; + if $selfClosing_value { + flags |= 1; + } + let flags_position = $end_position + 4; + $self.buffer[flags_position..flags_position + 4].copy_from_slice(&flags.to_ne_bytes()); + }; +} + +#[macro_export] +macro_rules! store_literal_boolean_flags { + ($self:expr, $end_position:expr, value => $value_value:expr) => { + let _: &mut AstConverter = $self; + let _: usize = $end_position; + let mut flags = 0u32; + if $value_value { + flags |= 1; + } + let flags_position = $end_position + 4; + $self.buffer[flags_position..flags_position + 4].copy_from_slice(&flags.to_ne_bytes()); + }; +} + +#[macro_export] +macro_rules! store_member_expression_flags { + ($self:expr, $end_position:expr, computed => $computed_value:expr, optional => $optional_value:expr) => { + let _: &mut AstConverter = $self; + let _: usize = $end_position; + let mut flags = 0u32; + if $computed_value { + flags |= 1; + } + if $optional_value { + flags |= 2; + } + let flags_position = $end_position + 4; + $self.buffer[flags_position..flags_position + 4].copy_from_slice(&flags.to_ne_bytes()); + }; +} + +#[macro_export] +macro_rules! store_method_definition_flags { + ($self:expr, $end_position:expr, static => $static_value:expr, computed => $computed_value:expr) => { + let _: &mut AstConverter = $self; + let _: usize = $end_position; + let mut flags = 0u32; + if $static_value { + flags |= 1; + } + if $computed_value { + flags |= 2; + } + let flags_position = $end_position + 4; + $self.buffer[flags_position..flags_position + 4].copy_from_slice(&flags.to_ne_bytes()); + }; +} + +#[macro_export] +macro_rules! store_property_flags { + ($self:expr, $end_position:expr, method => $method_value:expr, shorthand => $shorthand_value:expr, computed => $computed_value:expr) => { + let _: &mut AstConverter = $self; + let _: usize = $end_position; + let mut flags = 0u32; + if $method_value { + flags |= 1; + } + if $shorthand_value { + flags |= 2; + } + if $computed_value { + flags |= 4; + } + let flags_position = $end_position + 4; + $self.buffer[flags_position..flags_position + 4].copy_from_slice(&flags.to_ne_bytes()); + }; +} + +#[macro_export] +macro_rules! store_property_definition_flags { + ($self:expr, $end_position:expr, static => $static_value:expr, computed => $computed_value:expr) => { + let _: &mut AstConverter = $self; + let _: usize = $end_position; + let mut flags = 0u32; + if $static_value { + flags |= 1; + } + if $computed_value { + flags |= 2; + } + let flags_position = $end_position + 4; + $self.buffer[flags_position..flags_position + 4].copy_from_slice(&flags.to_ne_bytes()); + }; +} + +#[macro_export] +macro_rules! store_template_element_flags { + ($self:expr, $end_position:expr, tail => $tail_value:expr) => { + let _: &mut AstConverter = $self; + let _: usize = $end_position; + let mut flags = 0u32; + if $tail_value { + flags |= 1; + } + let flags_position = $end_position + 4; + $self.buffer[flags_position..flags_position + 4].copy_from_slice(&flags.to_ne_bytes()); + }; +} + +#[macro_export] +macro_rules! store_update_expression_flags { + ($self:expr, $end_position:expr, prefix => $prefix_value:expr) => { + let _: &mut AstConverter = $self; + let _: usize = $end_position; + let mut flags = 0u32; + if $prefix_value { + flags |= 1; + } + let flags_position = $end_position + 4; + $self.buffer[flags_position..flags_position + 4].copy_from_slice(&flags.to_ne_bytes()); + }; +} + +#[macro_export] +macro_rules! store_yield_expression_flags { + ($self:expr, $end_position:expr, delegate => $delegate_value:expr) => { + let _: &mut AstConverter = $self; + let _: usize = $end_position; + let mut flags = 0u32; + if $delegate_value { + flags |= 1; + } + let flags_position = $end_position + 4; + $self.buffer[flags_position..flags_position + 4].copy_from_slice(&flags.to_ne_bytes()); + }; +} diff --git a/rust/parse_ast/src/convert_ast/converter/string_constants.rs b/rust/parse_ast/src/convert_ast/converter/string_constants.rs new file mode 100644 index 00000000000..b5955be0eab --- /dev/null +++ b/rust/parse_ast/src/convert_ast/converter/string_constants.rs @@ -0,0 +1,66 @@ +// This file is generated by scripts/generate-string-constants.js. +// Do not edit this file directly. + +pub const STRING_VAR: [u8; 4] = 0u32.to_ne_bytes(); // var +pub const STRING_LET: [u8; 4] = 1u32.to_ne_bytes(); // let +pub const STRING_CONST: [u8; 4] = 2u32.to_ne_bytes(); // const +pub const STRING_INIT: [u8; 4] = 3u32.to_ne_bytes(); // init +pub const STRING_GET: [u8; 4] = 4u32.to_ne_bytes(); // get +pub const STRING_SET: [u8; 4] = 5u32.to_ne_bytes(); // set +pub const STRING_CONSTRUCTOR: [u8; 4] = 6u32.to_ne_bytes(); // constructor +pub const STRING_METHOD: [u8; 4] = 7u32.to_ne_bytes(); // method +pub const STRING_MINUS: [u8; 4] = 8u32.to_ne_bytes(); // - +pub const STRING_PLUS: [u8; 4] = 9u32.to_ne_bytes(); // + +pub const STRING_BANG: [u8; 4] = 10u32.to_ne_bytes(); // ! +pub const STRING_TILDE: [u8; 4] = 11u32.to_ne_bytes(); // ~ +pub const STRING_TYPEOF: [u8; 4] = 12u32.to_ne_bytes(); // typeof +pub const STRING_VOID: [u8; 4] = 13u32.to_ne_bytes(); // void +pub const STRING_DELETE: [u8; 4] = 14u32.to_ne_bytes(); // delete +pub const STRING_PLUSPLUS: [u8; 4] = 15u32.to_ne_bytes(); // ++ +pub const STRING_MINUSMINUS: [u8; 4] = 16u32.to_ne_bytes(); // -- +pub const STRING_EQEQ: [u8; 4] = 17u32.to_ne_bytes(); // == +pub const STRING_NOTEQ: [u8; 4] = 18u32.to_ne_bytes(); // != +pub const STRING_EQEQEQ: [u8; 4] = 19u32.to_ne_bytes(); // === +pub const STRING_NOTEQEQ: [u8; 4] = 20u32.to_ne_bytes(); // !== +pub const STRING_LT: [u8; 4] = 21u32.to_ne_bytes(); // < +pub const STRING_LTEQ: [u8; 4] = 22u32.to_ne_bytes(); // <= +pub const STRING_GT: [u8; 4] = 23u32.to_ne_bytes(); // > +pub const STRING_GTEQ: [u8; 4] = 24u32.to_ne_bytes(); // >= +pub const STRING_LSHIFT: [u8; 4] = 25u32.to_ne_bytes(); // << +pub const STRING_RSHIFT: [u8; 4] = 26u32.to_ne_bytes(); // >> +pub const STRING_ZEROFILLRSHIFT: [u8; 4] = 27u32.to_ne_bytes(); // >>> +pub const STRING_ADD: [u8; 4] = 28u32.to_ne_bytes(); // + +pub const STRING_SUB: [u8; 4] = 29u32.to_ne_bytes(); // - +pub const STRING_MUL: [u8; 4] = 30u32.to_ne_bytes(); // * +pub const STRING_DIV: [u8; 4] = 31u32.to_ne_bytes(); // / +pub const STRING_MOD: [u8; 4] = 32u32.to_ne_bytes(); // % +pub const STRING_BITOR: [u8; 4] = 33u32.to_ne_bytes(); // | +pub const STRING_BITXOR: [u8; 4] = 34u32.to_ne_bytes(); // ^ +pub const STRING_BITAND: [u8; 4] = 35u32.to_ne_bytes(); // & +pub const STRING_LOGICALOR: [u8; 4] = 36u32.to_ne_bytes(); // || +pub const STRING_LOGICALAND: [u8; 4] = 37u32.to_ne_bytes(); // && +pub const STRING_IN: [u8; 4] = 38u32.to_ne_bytes(); // in +pub const STRING_INSTANCEOF: [u8; 4] = 39u32.to_ne_bytes(); // instanceof +pub const STRING_EXP: [u8; 4] = 40u32.to_ne_bytes(); // ** +pub const STRING_NULLISHCOALESCING: [u8; 4] = 41u32.to_ne_bytes(); // ?? +pub const STRING_ASSIGN: [u8; 4] = 42u32.to_ne_bytes(); // = +pub const STRING_ADDASSIGN: [u8; 4] = 43u32.to_ne_bytes(); // += +pub const STRING_SUBASSIGN: [u8; 4] = 44u32.to_ne_bytes(); // -= +pub const STRING_MULASSIGN: [u8; 4] = 45u32.to_ne_bytes(); // *= +pub const STRING_DIVASSIGN: [u8; 4] = 46u32.to_ne_bytes(); // /= +pub const STRING_MODASSIGN: [u8; 4] = 47u32.to_ne_bytes(); // %= +pub const STRING_LSHIFTASSIGN: [u8; 4] = 48u32.to_ne_bytes(); // <<= +pub const STRING_RSHIFTASSIGN: [u8; 4] = 49u32.to_ne_bytes(); // >>= +pub const STRING_ZEROFILLRSHIFTASSIGN: [u8; 4] = 50u32.to_ne_bytes(); // >>>= +pub const STRING_BITORASSIGN: [u8; 4] = 51u32.to_ne_bytes(); // |= +pub const STRING_BITXORASSIGN: [u8; 4] = 52u32.to_ne_bytes(); // ^= +pub const STRING_BITANDASSIGN: [u8; 4] = 53u32.to_ne_bytes(); // &= +pub const STRING_EXPASSIGN: [u8; 4] = 54u32.to_ne_bytes(); // **= +pub const STRING_ANDASSIGN: [u8; 4] = 55u32.to_ne_bytes(); // &&= +pub const STRING_ORASSIGN: [u8; 4] = 56u32.to_ne_bytes(); // ||= +pub const STRING_NULLISHASSIGN: [u8; 4] = 57u32.to_ne_bytes(); // ??= +pub const STRING_PURE: [u8; 4] = 58u32.to_ne_bytes(); // pure +pub const STRING_NOSIDEEFFECTS: [u8; 4] = 59u32.to_ne_bytes(); // noSideEffects +pub const STRING_SOURCEMAP: [u8; 4] = 60u32.to_ne_bytes(); // sourcemap +pub const STRING_USING: [u8; 4] = 61u32.to_ne_bytes(); // using +pub const STRING_AWAIT_USING: [u8; 4] = 62u32.to_ne_bytes(); // await using diff --git a/rust/parse_ast/src/convert_ast/converter/utf16_positions.rs b/rust/parse_ast/src/convert_ast/converter/utf16_positions.rs new file mode 100644 index 00000000000..7dccfe05e52 --- /dev/null +++ b/rust/parse_ast/src/convert_ast/converter/utf16_positions.rs @@ -0,0 +1,146 @@ +use std::slice::Iter; +use std::str::Chars; + +use crate::convert_ast::annotations::CommentKind::Annotation; +use crate::convert_ast::annotations::{AnnotationKind, AnnotationWithType}; + +pub(crate) struct Utf8ToUtf16ByteIndexConverterAndAnnotationHandler<'a> { + current_utf8_index: u32, + current_utf16_index: u32, + character_iterator: Chars<'a>, + next_annotation: Option<&'a AnnotationWithType>, + next_annotation_start: u32, + annotation_iterator: Iter<'a, AnnotationWithType>, + collected_annotations: Vec, + invalid_annotations: Vec, + keep_annotations: bool, +} + +#[derive(Debug)] +pub(crate) struct ConvertedAnnotation { + pub(crate) start: u32, + pub(crate) end: u32, + pub(crate) kind: AnnotationKind, +} + +impl<'a> Utf8ToUtf16ByteIndexConverterAndAnnotationHandler<'a> { + pub(crate) fn new(code: &'a str, annotations: &'a [AnnotationWithType]) -> Self { + let mut annotation_iterator = annotations.iter(); + let current_annotation = annotation_iterator.next(); + Self { + current_utf8_index: 0, + current_utf16_index: 0, + character_iterator: code.chars(), + next_annotation: current_annotation, + next_annotation_start: get_annotation_start(current_annotation), + annotation_iterator, + collected_annotations: Vec::new(), + invalid_annotations: Vec::with_capacity(annotations.len()), + keep_annotations: false, + } + } + + /// Converts the given UTF-8 byte index to a UTF-16 byte index. + /// + /// To be performant, this method assumes that the given index is not smaller + /// than the previous index. Additionally, it handles "annotations" like + /// `@__PURE__` comments in the process. + /// + /// The logic for those comments is as follows: + /// - If the current index is at the start of an annotation, the annotation + /// is collected and the index is advanced to the end of the annotation. + /// - Otherwise, we check if the next character is a white-space character. + /// If not, we invalidate all collected annotations. + /// This is to ensure that we only collect annotations that directly precede + /// an expression and are not e.g. separated by a comma. + /// - If annotations are relevant for an expression, it can "take" the + /// collected annotations by calling `take_collected_annotations`. This + /// clears the internal buffer and returns the collected annotations. + /// - Invalidated annotations are attached to the Program node so that they + /// can all be removed from the source code later. + /// - If an annotation can influence a child that is separated by some + /// non-whitespace from the annotation, `keep_annotations_for_next` will + /// prevent annotations from being invalidated when the next position is + /// converted. + pub(crate) fn convert(&mut self, utf8_index: u32, keep_annotations_for_next: bool) -> u32 { + if self.current_utf8_index > utf8_index { + panic!( + "Cannot convert positions backwards: {} < {}", + utf8_index, self.current_utf8_index + ); + } + while self.current_utf8_index < utf8_index { + if self.current_utf8_index == self.next_annotation_start { + let start = self.current_utf16_index; + let (next_comment_end, next_comment_kind) = self + .next_annotation + .map(|a| (a.comment.span.hi.0 - 1, a.kind.clone())) + .unwrap(); + while self.current_utf8_index < next_comment_end { + let character = self.character_iterator.next().unwrap(); + self.current_utf8_index += character.len_utf8() as u32; + self.current_utf16_index += character.len_utf16() as u32; + } + if let Annotation(kind) = next_comment_kind { + self.collected_annotations.push(ConvertedAnnotation { + start, + end: self.current_utf16_index, + kind, + }); + } + self.next_annotation = self.annotation_iterator.next(); + self.next_annotation_start = get_annotation_start(self.next_annotation); + } else { + let character = self.character_iterator.next().unwrap(); + if !(self.keep_annotations || self.collected_annotations.is_empty()) { + match character { + ' ' | '\t' | '\r' | '\n' => {} + _ => { + self.invalidate_collected_annotations(); + } + } + } + self.current_utf8_index += character.len_utf8() as u32; + self.current_utf16_index += character.len_utf16() as u32; + } + } + self.keep_annotations = keep_annotations_for_next; + self.current_utf16_index + } + + pub(crate) fn take_collected_annotations( + &mut self, + kind: AnnotationKind, + ) -> Vec { + let mut relevant_annotations = Vec::new(); + for annotation in self.collected_annotations.drain(..) { + if annotation.kind == kind { + relevant_annotations.push(annotation); + } else { + self.invalid_annotations.push(annotation); + } + } + relevant_annotations + } + + pub(crate) fn add_collected_annotations(&mut self, annotations: Vec) { + self.collected_annotations.extend(annotations); + self.keep_annotations = true; + } + + pub(crate) fn invalidate_collected_annotations(&mut self) { + self + .invalid_annotations + .append(&mut self.collected_annotations); + } + + pub(crate) fn take_invalid_annotations(&mut self) -> Vec { + std::mem::take(&mut self.invalid_annotations) + } +} + +fn get_annotation_start(annotation: Option<&AnnotationWithType>) -> u32 { + annotation + .map(|a| a.comment.span.lo.0 - 1) + .unwrap_or(u32::MAX) +} diff --git a/rust/parse_ast/src/error_emit.rs b/rust/parse_ast/src/error_emit.rs new file mode 100644 index 00000000000..aac4dde8bc1 --- /dev/null +++ b/rust/parse_ast/src/error_emit.rs @@ -0,0 +1,81 @@ +use std::{io::Write, mem::take, sync::Arc}; + +use anyhow::Error; +use parking_lot::Mutex; +use swc_common::errors::{DiagnosticBuilder, Emitter, Handler, Level, HANDLER}; +use swc_ecma_ast::Program; + +use crate::ast_nodes::parse_error::get_parse_error_buffer; +use crate::convert_ast::converter::convert_string; + +#[derive(Clone, Default)] +struct Writer(Arc>>); + +impl Write for Writer { + fn write(&mut self, buf: &[u8]) -> std::io::Result { + let mut lock = self.0.lock(); + + lock.extend_from_slice(buf); + + Ok(buf.len()) + } + fn flush(&mut self) -> std::io::Result<()> { + Ok(()) + } +} + +pub(crate) struct ErrorEmitter { + wr: Box, +} + +impl Emitter for ErrorEmitter { + fn emit(&mut self, db: &mut DiagnosticBuilder<'_>) { + if db.level == Level::Error { + let mut buffer = Vec::new(); + let mut pos: u32 = 0; + if let Some(span) = db.span.primary_span() { + pos = span.lo.0 - 1; + }; + let message = &db.message[0].0; + buffer.extend_from_slice(&pos.to_ne_bytes()); + convert_string(&mut buffer, message); + let _ = self.wr.write(&buffer); + } + } +} + +pub(crate) fn try_with_handler(code: &str, op: F) -> Result> +where + F: FnOnce(&Handler) -> Result, +{ + let wr = Box::::default(); + + let emitter = ErrorEmitter { wr: wr.clone() }; + + let handler = Handler::with_emitter(true, false, Box::new(emitter)); + + let result = HANDLER.set(&handler, || op(&handler)); + + result.map_err(|_| { + if handler.has_errors() { + create_error_buffer(&wr, code) + } else { + panic!("Unexpected error in parse") + } + }) +} + +fn create_error_buffer(wr: &Writer, code: &str) -> Vec { + let mut lock = wr.0.lock(); + let error_buffer = take(&mut *lock); + let pos = u32::from_ne_bytes(error_buffer[0..4].try_into().unwrap()); + let mut utf_16_pos: u32 = 0; + // convert utf-8 to utf-16 inline + for (utf_8_pos, char) in code.char_indices() { + if (utf_8_pos as u32) == pos { + break; + } + utf_16_pos += char.len_utf16() as u32; + } + get_parse_error_buffer(&error_buffer, &utf_16_pos) +} diff --git a/rust/parse_ast/src/lib.rs b/rust/parse_ast/src/lib.rs new file mode 100644 index 00000000000..c1ecc70d254 --- /dev/null +++ b/rust/parse_ast/src/lib.rs @@ -0,0 +1,70 @@ +use std::panic::{catch_unwind, AssertUnwindSafe}; + +use swc_common::sync::Lrc; +use swc_common::{FileName, FilePathMapping, Globals, SourceMap, GLOBALS}; +use swc_compiler_base::parse_js; +use swc_config::is_module::IsModule; +use swc_ecma_ast::EsVersion; +use swc_ecma_parser::{EsSyntax, Syntax}; + +use convert_ast::converter::AstConverter; +use error_emit::try_with_handler; + +use crate::ast_nodes::panic_error::get_panic_error_buffer; +use crate::convert_ast::annotations::SequentialComments; + +mod ast_nodes; +mod convert_ast; +mod error_emit; + +pub fn parse_ast(code: String, allow_return_outside_function: bool, jsx: bool) -> Vec { + let cm = Lrc::new(SourceMap::new(FilePathMapping::empty())); + let target = EsVersion::EsNext; + let syntax = Syntax::Es(EsSyntax { + allow_return_outside_function, + import_attributes: true, + explicit_resource_management: true, + decorators: true, + decorators_before_export: true, + jsx, + ..Default::default() + }); + + let filename = FileName::Anon; + let file = cm.new_source_file(filename.into(), code); + let code_reference = file.src.clone(); + let comments = SequentialComments::default(); + GLOBALS.set(&Globals::default(), || { + let result = catch_unwind(AssertUnwindSafe(|| { + let result = try_with_handler(&code_reference, |handler| { + parse_js( + cm, + file, + handler, + target, + syntax, + IsModule::Unknown, + Some(&comments), + ) + }); + match result { + Err(buffer) => buffer, + Ok(program) => { + let annotations = comments.take_annotations(); + let converter = AstConverter::new(&code_reference, &annotations); + converter.convert_ast_to_buffer(&program) + } + } + })); + result.unwrap_or_else(|err| { + let msg = if let Some(msg) = err.downcast_ref::<&str>() { + msg + } else if let Some(msg) = err.downcast_ref::() { + msg + } else { + "Unknown rust panic message" + }; + get_panic_error_buffer(msg) + }) + }) +} diff --git a/rust/rustfmt.toml b/rust/rustfmt.toml new file mode 100644 index 00000000000..cab5731edaf --- /dev/null +++ b/rust/rustfmt.toml @@ -0,0 +1,2 @@ +tab_spaces = 2 +edition = "2021" diff --git a/rust/xxhash/Cargo.toml b/rust/xxhash/Cargo.toml new file mode 100644 index 00000000000..14decc64ec5 --- /dev/null +++ b/rust/xxhash/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "xxhash" +version = "0.0.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +base-encode = "0.3.1" +xxhash-rust = { version = "0.8.15", features = ["xxh3"] } diff --git a/rust/xxhash/src/lib.rs b/rust/xxhash/src/lib.rs new file mode 100644 index 00000000000..88d1dd8b2fb --- /dev/null +++ b/rust/xxhash/src/lib.rs @@ -0,0 +1,24 @@ +use base_encode::to_string; +use xxhash_rust::xxh3::xxh3_128; + +const CHARACTERS_BASE64: &[u8; 64] = + b"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"; + +const CHARACTERS_BASE36: &[u8; 36] = b"abcdefghijklmnopqrstuvwxyz0123456789"; + +pub fn xxhash_base64_url(input: &[u8]) -> String { + to_string(&xxh3_128(input).to_le_bytes(), 64, CHARACTERS_BASE64).unwrap() +} + +pub fn xxhash_base36(input: &[u8]) -> String { + to_string(&xxh3_128(input).to_le_bytes(), 36, CHARACTERS_BASE36).unwrap() +} + +pub fn xxhash_base16(input: &[u8]) -> String { + // Format each byte as 2 hex digits, preserving leading zeros to always return a 32 digits string. + xxh3_128(input) + .to_le_bytes() + .iter() + .map(|b| format!("{b:02x}")) + .collect::() +} diff --git a/scripts/ast-types.js b/scripts/ast-types.js new file mode 100644 index 00000000000..f36d1719d54 --- /dev/null +++ b/scripts/ast-types.js @@ -0,0 +1,773 @@ +/** + * This file contains the AST node descriptions for the ESTree AST. + * From this file, "npm run build:ast-converters" will generate + * - /rust/parse_ast/src/convert_ast/converter/ast_constants.rs: + * Constants that describe how the AST nodes are encoded in Rust. + * - /src/utils/bufferToAst.ts: + * Helper functions that are used by this.parse in plugins to convert a buffer + * to a JSON AST. + * - /src/ast/bufferParsers.ts + * Helper functions that are used by Module.ts to convert a buffer to an + * internal Rollup AST. While this uses roughly the same AST format, it + * instantiates the classes in /src/ast/nodes instead. + * - /src/ast/childNodeKeys.ts + * A list of which AST nodes keys represent child nodes. This is used by the + * legacy parser to instantiate a Rollup AST from a JSON AST. + * + * JavaScript AST nodes follow the ESTree format specified here + * https://github.com/estree/estree. While the binary buffer format could + * theoretically deviate from this, it should be either a one-to-one or a + * many-to-one mapping (Example: All Literal* nodes in the buffer are encoded + * as "type: Literal" in the JSON AST). + * + * For encoded non-JavaScript AST nodes like TypeScript or JSX, we try to follow + * the format of typescript-eslint, which can be derived from their playground + * https://typescript-eslint.io/play/#showAST=es&fileType=.tsx + * For JSX, see also https://github.com/facebook/jsx/blob/main/AST.md + */ + +/** @typedef {"Node"|"OptionalNode"|"NodeList"|"Annotations"|"InvalidAnnotations"|"String"|"FixedString"|"OptionalString"|"NullableString"|"Float"} FieldType */ + +/** @typedef {[name:string, type:FieldType]} FieldWithType */ + +/** @typedef {{ + * astType?: string; // If several converters produce the same type, specify the actual type here + * estreeType?: string, // If the extended ESTree type is different from the AST type + * hasSameFieldsAs?: string, // If this node uses the same Rust converter as another one, specify the name here. This will skip Rust field constant generation. + * fields?: FieldWithType[], // The non-boolean fields of the node, sorted by parse order + * flags?: string[], // The boolean fields of the node + * fixed?: Record, // Any fields with fixed values + * fieldTypes?: Record, // Add a type cast to a field + * additionalFields?: Record, // Derived fields can be specified as arbitrary strings here + * baseForAdditionalFields?: string[], // Fields needed to define additional fields + * hiddenFields?: string[], // Fields that are added in Rust but are not part of the AST, usually together with additionalFields + * optionalFallback?: Record // If an optional variable should not have "null" as fallback, but the value of another field, + * postProcessFields?: Record, // If this is specified, the field will be extracted into a variable and this code is injected after the field is assigned + * scopes?: Record // If the field gets a parent scope other than node.scope + * scriptedFields?: Record // If fields are parsed via custom logic, $position references the node position. $typeFoo is replaced with the numeric code for Foo + * useMacro?: boolean // Generate a Rust macro instead of separate constants + * }} NodeDescription */ + +/** @type {Record} */ +export const AST_NODES = { + PanicError: { + estreeType: "{ type: 'PanicError', message: string }", + fields: [['message', 'String']], + useMacro: false + }, + ParseError: { + estreeType: "{ type: 'ParseError', message: string }", + fields: [['message', 'String']], + useMacro: false + }, + // eslint-disable-next-line sort-keys + ArrayExpression: { + fields: [['elements', 'NodeList']], + useMacro: false + }, + ArrayPattern: { + fields: [['elements', 'NodeList']], + useMacro: false + }, + ArrowFunctionExpression: { + fields: [ + ['annotations', 'Annotations'], + ['params', 'NodeList'], + ['body', 'Node'] + ], + fixed: { + id: null + }, + flags: ['async', 'expression', 'generator'], + postProcessFields: { + annotations: [ + 'annotations', + "node.annotationNoSideEffects = annotations.some(comment => comment.type === 'noSideEffects')" + ], + params: [ + 'parameters', + `scope.addParameterVariables( + parameters.map( + parameter => parameter.declare('parameter', EMPTY_PATH, UNKNOWN_EXPRESSION) as ParameterVariable[] + ), + parameters[parameters.length - 1] instanceof RestElement + );` + ] + }, + scopes: { + body: 'scope.bodyScope' + }, + useMacro: false + }, + AssignmentExpression: { + fields: [ + ['operator', 'FixedString'], + ['left', 'Node'], + ['right', 'Node'] + ], + fieldTypes: { + operator: 'estree.AssignmentOperator' + } + }, + AssignmentPattern: { + fields: [ + ['left', 'Node'], + ['right', 'Node'] + ], + useMacro: false + }, + AwaitExpression: { + fields: [['argument', 'Node']] + }, + BinaryExpression: { + fields: [ + ['operator', 'FixedString'], + ['left', 'Node'], + ['right', 'Node'] + ], + fieldTypes: { + operator: 'estree.BinaryOperator' + }, + useMacro: false + }, + BlockStatement: { + fields: [['body', 'NodeList']], + useMacro: false + }, + BreakStatement: { + fields: [['label', 'OptionalNode']] + }, + CallExpression: { + estreeType: 'estree.SimpleCallExpression', + fields: [ + ['annotations', 'Annotations'], + ['callee', 'Node'], + ['arguments', 'NodeList'] + ], + flags: ['optional'], + useMacro: false + }, + CatchClause: { + fields: [ + ['param', 'OptionalNode'], + ['body', 'Node'] + ], + postProcessFields: { + param: ['parameter', "parameter?.declare('parameter', EMPTY_PATH, UNKNOWN_EXPRESSION)"] + }, + scopes: { + body: 'scope.bodyScope' + }, + useMacro: false + }, + ChainExpression: { + fields: [['expression', 'Node']], + useMacro: false + }, + ClassBody: { + fields: [['body', 'NodeList']], + scriptedFields: { + body: ` const bodyPosition = $position; + if (bodyPosition) { + const length = buffer[bodyPosition]; + const body: (MethodDefinition | PropertyDefinition | StaticBlock)[] = (node.body = new Array(length)); + for (let index = 0; index < length; index++) { + const nodePosition = buffer[bodyPosition + 1 + index]; + body[index] = convertNode( + node, + buffer[nodePosition] !== $typeStaticBlock && (buffer[nodePosition + 3] & /* the static flag is always first */ 1) === 0 ? scope.instanceScope : scope, + nodePosition, + buffer + ); + } + } else { + node.body = []; + }` + }, + useMacro: false + }, + ClassDeclaration: { + fields: [ + ['decorators', 'NodeList'], + ['id', 'OptionalNode'], + ['superClass', 'OptionalNode'], + ['body', 'Node'] + ], + scopes: { + id: 'scope.parent as ChildScope' + }, + useMacro: false + }, + ClassExpression: { + hasSameFieldsAs: 'ClassDeclaration', + scopes: { + id: 'scope' + }, + useMacro: false + }, + ConditionalExpression: { + fields: [ + ['test', 'Node'], + ['consequent', 'Node'], + ['alternate', 'Node'] + ] + }, + ContinueStatement: { + fields: [['label', 'OptionalNode']] + }, + DebuggerStatement: {}, + Decorator: { fields: [['expression', 'Node']] }, + Directive: { + astType: 'ExpressionStatement', + estreeType: 'estree.Directive', + fields: [ + ['directive', 'String'], + ['expression', 'Node'] + ] + }, + DoWhileStatement: { + fields: [ + ['body', 'Node'], + ['test', 'Node'] + ] + }, + EmptyStatement: {}, + ExportAllDeclaration: { + estreeType: 'estree.ExportAllDeclaration & { attributes: ImportAttributeNode[] }', + fields: [ + ['exported', 'OptionalNode'], + ['source', 'Node'], + ['attributes', 'NodeList'] + ], + useMacro: false + }, + ExportDefaultDeclaration: { + fields: [['declaration', 'Node']], + useMacro: false + }, + ExportNamedDeclaration: { + estreeType: 'estree.ExportNamedDeclaration & { attributes: ImportAttributeNode[] }', + fields: [ + ['specifiers', 'NodeList'], + ['source', 'OptionalNode'], + ['attributes', 'NodeList'], + ['declaration', 'OptionalNode'] + ], + useMacro: false + }, + ExportSpecifier: { + fields: [ + ['local', 'Node'], + ['exported', 'OptionalNode'] + ], + optionalFallback: { + exported: 'local' + } + }, + ExpressionStatement: { + fields: [['expression', 'Node']] + }, + ForInStatement: { + fields: [ + ['left', 'Node'], + ['right', 'Node'], + ['body', 'Node'] + ] + }, + ForOfStatement: { + fields: [ + ['left', 'Node'], + ['right', 'Node'], + ['body', 'Node'] + ], + flags: ['await'] + }, + ForStatement: { + fields: [ + ['init', 'OptionalNode'], + ['test', 'OptionalNode'], + ['update', 'OptionalNode'], + ['body', 'Node'] + ] + }, + FunctionDeclaration: { + fields: [ + ['annotations', 'Annotations'], + ['id', 'OptionalNode'], + ['params', 'NodeList'], + ['body', 'Node'] + ], + fixed: { + expression: false + }, + flags: ['async', 'generator'], + postProcessFields: { + annotations: [ + 'annotations', + "node.annotationNoSideEffects = annotations.some(comment => comment.type === 'noSideEffects')" + ], + params: [ + 'parameters', + `scope.addParameterVariables( + parameters.map( + parameter => parameter.declare('parameter', EMPTY_PATH, UNKNOWN_EXPRESSION) as ParameterVariable[] + ), + parameters[parameters.length - 1] instanceof RestElement + );` + ] + }, + scopes: { + body: 'scope.bodyScope', + id: 'scope.parent as ChildScope' + }, + useMacro: false + }, + FunctionExpression: { + hasSameFieldsAs: 'FunctionDeclaration', + scopes: { + id: 'node.idScope' + }, + useMacro: false + }, + Identifier: { + fields: [['name', 'String']], + useMacro: false + }, + IfStatement: { + fields: [ + ['test', 'Node'], + ['consequent', 'Node'], + ['alternate', 'OptionalNode'] + ], + scopes: { + alternate: '(node.alternateScope = new TrackingScope(scope))', + consequent: '(node.consequentScope = new TrackingScope(scope))' + } + }, + ImportAttribute: { + estreeType: + "{ key: estree.Identifier | estree.Literal; type: 'ImportAttribute'; value: estree.Literal; }", + fields: [ + ['key', 'Node'], + ['value', 'Node'] + ], + useMacro: false + }, + ImportDeclaration: { + estreeType: 'estree.ImportDeclaration & { attributes: ImportAttributeNode[] }', + fields: [ + ['specifiers', 'NodeList'], + ['source', 'Node'], + ['attributes', 'NodeList'] + ], + useMacro: false + }, + ImportDefaultSpecifier: { + fields: [['local', 'Node']] + }, + ImportExpression: { + estreeType: 'estree.ImportExpression & { options: estree.Expression | null }', + fields: [ + ['source', 'Node'], + ['options', 'OptionalNode'] + ], + scriptedFields: { + source: `node.source = convertNode(node, scope, $position, buffer); + node.sourceAstNode = convertJsonNode($position, buffer);` + }, + useMacro: false + }, + ImportNamespaceSpecifier: { + fields: [['local', 'Node']] + }, + ImportSpecifier: { + fields: [ + ['imported', 'OptionalNode'], + ['local', 'Node'] + ], + optionalFallback: { + imported: 'local' + } + }, + JSXAttribute: { + estreeType: 'any', + fields: [ + ['name', 'Node'], + ['value', 'OptionalNode'] + ] + }, + JSXClosingElement: { + estreeType: 'any', + fields: [['name', 'Node']] + }, + JSXClosingFragment: { + estreeType: 'any', + fields: [] + }, + JSXElement: { + estreeType: 'any', + fields: [ + ['openingElement', 'Node'], + ['children', 'NodeList'], + ['closingElement', 'OptionalNode'] + ] + }, + JSXEmptyExpression: { + estreeType: 'any', + useMacro: false + }, + JSXExpressionContainer: { + estreeType: 'any', + fields: [['expression', 'Node']], + useMacro: false + }, + JSXFragment: { + estreeType: 'any', + fields: [ + ['openingFragment', 'Node'], + ['children', 'NodeList'], + ['closingFragment', 'Node'] + ] + }, + JSXIdentifier: { + estreeType: 'any', + fields: [['name', 'String']] + }, + JSXMemberExpression: { + estreeType: 'any', + fields: [ + ['object', 'Node'], + ['property', 'Node'] + ], + useMacro: false + }, + JSXNamespacedName: { + estreeType: 'any', + fields: [ + ['namespace', 'Node'], + ['name', 'Node'] + ], + useMacro: false + }, + JSXOpeningElement: { + estreeType: 'any', + fields: [ + ['name', 'Node'], + ['attributes', 'NodeList'] + ], + flags: ['selfClosing'], + useMacro: false + }, + JSXOpeningFragment: { + additionalFields: { + attributes: '[]', + selfClosing: 'false' + }, + estreeType: 'any' + }, + JSXSpreadAttribute: { + estreeType: 'any', + fields: [['argument', 'Node']], + useMacro: false + }, + JSXSpreadChild: { + estreeType: 'any', + fields: [['expression', 'Node']] + }, + JSXText: { + estreeType: 'any', + fields: [ + ['value', 'String'], + ['raw', 'String'] + ] + }, + LabeledStatement: { + fields: [ + ['label', 'Node'], + ['body', 'Node'] + ] + }, + LiteralBigInt: { + additionalFields: { + value: 'BigInt(bigint)' + }, + astType: 'Literal', + baseForAdditionalFields: ['bigint'], + estreeType: 'estree.BigIntLiteral', + fields: [ + ['bigint', 'String'], + ['raw', 'String'] + ] + }, + LiteralBoolean: { + additionalFields: { + raw: 'value ? "true" : "false"' + }, + astType: 'Literal', + baseForAdditionalFields: ['value'], + estreeType: 'estree.SimpleLiteral & {value: boolean}', + flags: ['value'] + }, + LiteralNull: { + additionalFields: { + value: 'null' + }, + astType: 'Literal', + estreeType: 'estree.SimpleLiteral & {value: null}', + fixed: { + raw: 'null' + } + }, + LiteralNumber: { + astType: 'Literal', + estreeType: 'estree.SimpleLiteral & {value: number}', + fields: [ + ['raw', 'OptionalString'], + ['value', 'Float'] + ] + }, + LiteralRegExp: { + additionalFields: { + raw: '`/${pattern}/${flags}`', + regex: '{ flags, pattern }', + value: 'new RegExp(pattern, flags)' + }, + astType: 'Literal', + baseForAdditionalFields: ['flags', 'pattern'], + estreeType: 'estree.RegExpLiteral', + fields: [ + ['flags', 'String'], + ['pattern', 'String'] + ], + hiddenFields: ['flags', 'pattern'] + }, + LiteralString: { + astType: 'Literal', + estreeType: 'estree.SimpleLiteral & {value: string}', + fields: [ + ['value', 'String'], + ['raw', 'OptionalString'] + ] + }, + LogicalExpression: { + fieldTypes: { + operator: 'estree.LogicalOperator' + }, + hasSameFieldsAs: 'BinaryExpression', + useMacro: false + }, + MemberExpression: { + fields: [ + ['object', 'Node'], + ['property', 'Node'] + ], + flags: ['computed', 'optional'], + useMacro: false + }, + MetaProperty: { + fields: [ + ['meta', 'Node'], + ['property', 'Node'] + ], + useMacro: false + }, + MethodDefinition: { + fields: [ + ['decorators', 'NodeList'], + ['key', 'Node'], + ['value', 'Node'], + ['kind', 'FixedString'] + ], + fieldTypes: { + kind: "estree.MethodDefinition['kind']" + }, + // "static" needs to come first as ClassBody depends on it + flags: ['static', 'computed'], + useMacro: false + }, + NewExpression: { + fields: [ + ['annotations', 'Annotations'], + ['callee', 'Node'], + ['arguments', 'NodeList'] + ], + useMacro: false + }, + ObjectExpression: { + fields: [['properties', 'NodeList']] + }, + ObjectPattern: { + fields: [['properties', 'NodeList']] + }, + PrivateIdentifier: { + fields: [['name', 'String']] + }, + Program: { + fields: [ + ['body', 'NodeList'], + ['invalidAnnotations', 'InvalidAnnotations'] + ], + fixed: { + sourceType: 'module' + }, + useMacro: false + }, + Property: { + fields: [ + ['key', 'OptionalNode'], + ['value', 'Node'], + ['kind', 'FixedString'] + ], + fieldTypes: { kind: "estree.Property['kind']" }, + flags: ['method', 'shorthand', 'computed'], + optionalFallback: { + key: 'value' + }, + useMacro: false + }, + PropertyDefinition: { + fields: [ + ['decorators', 'NodeList'], + ['key', 'Node'], + ['value', 'OptionalNode'] + ], + // "static" needs to come first as ClassBody depends on it + flags: ['static', 'computed'], + useMacro: false + }, + RestElement: { + fields: [['argument', 'Node']], + useMacro: false + }, + ReturnStatement: { + fields: [['argument', 'OptionalNode']] + }, + SequenceExpression: { + fields: [['expressions', 'NodeList']] + }, + SpreadElement: { + fields: [['argument', 'Node']], + useMacro: false + }, + StaticBlock: { + fields: [['body', 'NodeList']] + }, + SuperElement: { + astType: 'Super', + estreeType: 'estree.Super' + }, + SwitchCase: { + fields: [ + ['test', 'OptionalNode'], + ['consequent', 'NodeList'] + ] + }, + SwitchStatement: { + fields: [ + ['discriminant', 'Node'], + ['cases', 'NodeList'] + ], + scopes: { + discriminant: 'node.parentScope' + } + }, + TaggedTemplateExpression: { + fields: [ + ['tag', 'Node'], + ['quasi', 'Node'] + ] + }, + TemplateElement: { + additionalFields: { + value: '{ cooked, raw}' + }, + baseForAdditionalFields: ['cooked', 'raw'], + fields: [ + ['cooked', 'NullableString'], + ['raw', 'String'] + ], + flags: ['tail'], + hiddenFields: ['cooked', 'raw'] + }, + TemplateLiteral: { + fields: [ + ['quasis', 'NodeList'], + ['expressions', 'NodeList'] + ], + useMacro: false + }, + ThisExpression: {}, + ThrowStatement: { + fields: [['argument', 'Node']] + }, + TryStatement: { + fields: [ + ['block', 'Node'], + ['handler', 'OptionalNode'], + ['finalizer', 'OptionalNode'] + ], + useMacro: false + }, + UnaryExpression: { + fields: [ + ['operator', 'FixedString'], + ['argument', 'Node'] + ], + fieldTypes: { + operator: 'estree.UnaryOperator' + }, + fixed: { + prefix: true + } + }, + UpdateExpression: { + fields: [ + ['operator', 'FixedString'], + ['argument', 'Node'] + ], + fieldTypes: { + operator: 'estree.UpdateOperator' + }, + flags: ['prefix'] + }, + VariableDeclaration: { + fields: [ + ['kind', 'FixedString'], + ['declarations', 'NodeList'] + ], + fieldTypes: { + kind: "estree.VariableDeclaration['kind']" + }, + useMacro: false + }, + VariableDeclarator: { + fields: [ + ['id', 'Node'], + ['init', 'OptionalNode'] + ], + useMacro: false + }, + WhileStatement: { + fields: [ + ['test', 'Node'], + ['body', 'Node'] + ] + }, + YieldExpression: { + fields: [['argument', 'OptionalNode']], + flags: ['delegate'] + } +}; + +/** @type { {name: string; fields: FieldWithType[]; node: NodeDescription; originalNode: NodeDescription;}[] } */ +export const astNodeNamesWithFieldOrder = Object.entries(AST_NODES).map(([name, originalNode]) => { + const node = originalNode.hasSameFieldsAs + ? AST_NODES[originalNode.hasSameFieldsAs] + : originalNode; + return { + fields: node.fields || [], + name, + node, + originalNode + }; +}); diff --git a/scripts/check-release.js b/scripts/check-release.js new file mode 100755 index 00000000000..bd32b6b86fd --- /dev/null +++ b/scripts/check-release.js @@ -0,0 +1,8 @@ +#!/usr/bin/env node + +import { env, exit } from 'node:process'; + +if (env.ROLLUP_RELEASE !== 'releasing') { + console.error('Currently not in release mode.'); + exit(1); +} diff --git a/scripts/colors.js b/scripts/colors.js new file mode 100644 index 00000000000..c82022c23a3 --- /dev/null +++ b/scripts/colors.js @@ -0,0 +1,8 @@ +import { env } from 'node:process'; +import pc from 'picocolors'; + +// @see https://no-color.org +// @see https://www.npmjs.com/package/chalk +export const { bold, cyan, green, red, yellow, blue, magenta } = pc.createColors( + env.FORCE_COLOR !== '0' && !env.NO_COLOR +); diff --git a/scripts/declarations.d.ts b/scripts/declarations.d.ts new file mode 100644 index 00000000000..7860e8e3d04 --- /dev/null +++ b/scripts/declarations.d.ts @@ -0,0 +1,27 @@ +declare module 'github-api' { + export interface Repo { + listPullRequests(filter: { state: string }): Promise<{ + data: { number: number; title: string; head: { sha: string } }[]; + }>; + + listCommitsOnPR(pr: number): Promise<{ + data: { author: { login: string } | null; commit: { author: { name: string } } }[]; + }>; + + getPullRequest(pr: number): Promise<{ data: { body: string; user: { login: string } } }>; + + createRelease(release: { body: string; name: string; tag_name: string }): Promise; + } + + export interface Issues { + createIssueComment(issueNumber: number, text: string): Promise; + } + + export default class GitHub { + constructor(options: { token: string }); + + getRepo(organization: string, repository: string): Repo; + + getIssues(organization: string, repository: string): Issues; + } +} diff --git a/scripts/generate-ast-converters.js b/scripts/generate-ast-converters.js new file mode 100644 index 00000000000..f5f3d56c714 --- /dev/null +++ b/scripts/generate-ast-converters.js @@ -0,0 +1,10 @@ +#!/usr/bin/env node + +import './generate-ast-macros.js'; +import './generate-buffer-parsers.js'; +import './generate-buffer-to-ast.js'; +import './generate-child-node-keys.js'; +import './generate-node-index.js'; +import './generate-node-types.js'; +import './generate-rust-constants.js'; +import './generate-string-constants.js'; diff --git a/scripts/generate-ast-macros.js b/scripts/generate-ast-macros.js new file mode 100644 index 00000000000..5252348ae93 --- /dev/null +++ b/scripts/generate-ast-macros.js @@ -0,0 +1,152 @@ +import { writeFile } from 'node:fs/promises'; +import { astNodeNamesWithFieldOrder } from './ast-types.js'; +import { generateNotEditFilesComment, lintRustFile, toSnakeCase } from './helpers.js'; + +const BYTES_PER_U32 = 4; + +const notEditFilesComment = generateNotEditFilesComment(import.meta.url); + +const astMacrosFile = new URL( + '../rust/parse_ast/src/convert_ast/converter/ast_macros.rs', + import.meta.url +); + +const astMacros = astNodeNamesWithFieldOrder + .map(({ name, fields, node: { flags, useMacro } }, nodeIndex) => { + if (useMacro === false) { + return ''; + } + let reservedBytes = BYTES_PER_U32; + let valuesInput = ''; + let flagConverter = ''; + if (flags?.length) { + reservedBytes += BYTES_PER_U32; + let flagsInput = ''; + for (const flag of flags) { + valuesInput += `, ${flag} => $${flag}_value:expr`; + flagsInput += `, ${flag} => $${flag}_value`; + } + flagConverter = ` + // flags + store_${toSnakeCase(name)}_flags!($self, end_position${flagsInput});`; + } + let fieldConverters = ''; + for (const [fieldName, fieldType] of fields) { + fieldConverters += ` + // ${fieldName}`; + switch (fieldType) { + case 'FixedString': { + valuesInput += `, ${fieldName} => $${fieldName}_value:expr`; + fieldConverters += ` + let ${fieldName}_position = end_position + ${reservedBytes}; + $self.buffer[${fieldName}_position..${fieldName}_position + ${BYTES_PER_U32}].copy_from_slice($${fieldName}_value);`; + break; + } + case 'Float': { + valuesInput += `, ${fieldName} => $${fieldName}_value:expr`; + fieldConverters += ` + let ${fieldName}_position = end_position + ${reservedBytes}; + $self.buffer[${fieldName}_position..${fieldName}_position + ${2 * BYTES_PER_U32}].copy_from_slice(&$${fieldName}_value.to_le_bytes());`; + reservedBytes += BYTES_PER_U32; + break; + } + case 'Node': { + valuesInput += `, ${fieldName} => [$${fieldName}_value:expr, $${fieldName}_converter:ident]`; + fieldConverters += ` + $self.update_reference_position(end_position + ${reservedBytes}); + $self.$${fieldName}_converter(&$${fieldName}_value);`; + break; + } + case 'NodeList': { + valuesInput += `, ${fieldName} => [$${fieldName}_value:expr, $${fieldName}_converter:ident]`; + fieldConverters += ` + $self.convert_item_list( + &$${fieldName}_value, + end_position + ${reservedBytes}, + |ast_converter, node| { + ast_converter.$${fieldName}_converter(node); + true + } + );`; + break; + } + case 'OptionalNode': { + valuesInput += `, ${fieldName} => [$${fieldName}_value:expr, $${fieldName}_converter:ident]`; + fieldConverters += ` + if let Some(value) = $${fieldName}_value.as_ref() { + $self.update_reference_position(end_position + ${reservedBytes}); + $self.$${fieldName}_converter(value); + }`; + break; + } + case 'OptionalString': + case 'NullableString': { + valuesInput += `, ${fieldName} => $${fieldName}_value:expr`; + fieldConverters += ` + if let Some(value) = $${fieldName}_value.as_ref() { + $self.convert_string(value, end_position + ${reservedBytes}); + }`; + break; + } + case 'String': { + valuesInput += `, ${fieldName} => $${fieldName}_value:expr`; + fieldConverters += ` + $self.convert_string($${fieldName}_value, end_position + ${reservedBytes});`; + break; + } + default: { + throw new Error(`Unhandled field type ${fieldType}`); + } + } + reservedBytes += BYTES_PER_U32; + } + return `#[macro_export] +macro_rules! store_${toSnakeCase(name)} { + ($self:expr, span => $span:expr${valuesInput}) => { + let _: &mut AstConverter = $self; + let end_position = $self.add_type_and_start( + &${nodeIndex}u32.to_ne_bytes(), + &$span, + ${reservedBytes}, + false, + );${flagConverter}${fieldConverters} + // end + $self.add_end(end_position, &$span); + }; +} + +`; + }) + .join(''); + +const flagMacros = astNodeNamesWithFieldOrder + .map(({ name, originalNode: { flags, hasSameFieldsAs } }) => { + if (hasSameFieldsAs || !flags?.length) { + return ''; + } + const valuesInput = flags.map(flag => `${flag} => $${flag}_value:expr`).join(', '); + const setFlags = flags + .map((flag, index) => `if $${flag}_value { flags |= ${1 << index}; }`) + .join('\n'); + return `#[macro_export] +macro_rules! store_${toSnakeCase(name)}_flags { + ($self:expr, $end_position:expr, ${valuesInput}) => { + let _: &mut AstConverter = $self; + let _: usize = $end_position; + let mut flags = 0u32; + ${setFlags} + let flags_position = $end_position + ${BYTES_PER_U32}; + $self.buffer[flags_position..flags_position + ${BYTES_PER_U32}].copy_from_slice(&flags.to_ne_bytes()); + }; +} + +`; + }) + .join(''); + +const astConstants = `${notEditFilesComment} +${astMacros} +${flagMacros}`; + +await writeFile(astMacrosFile, astConstants); +await lintRustFile(astMacrosFile); diff --git a/scripts/generate-buffer-parsers.js b/scripts/generate-buffer-parsers.js new file mode 100644 index 00000000000..09362946e92 --- /dev/null +++ b/scripts/generate-buffer-parsers.js @@ -0,0 +1,251 @@ +import { writeFile } from 'node:fs/promises'; +import { astNodeNamesWithFieldOrder } from './ast-types.js'; +import { firstLettersLowercase, generateNotEditFilesComment, lintTsFile } from './helpers.js'; + +const notEditFilesComment = generateNotEditFilesComment(import.meta.url); + +const bufferParsersFile = new URL('../src/ast/bufferParsers.ts', import.meta.url); + +const nodeTypes = astNodeNamesWithFieldOrder.map(({ name, node }) => node.astType || name); + +const nodeTypeImports = nodeTypes.map(name => `import ${name} from './nodes/${name}';`); +const nodeTypeStrings = nodeTypes.map(name => `\t'${name}'`); + +const jsConverters = astNodeNamesWithFieldOrder.map(({ name, fields, node, originalNode }) => { + /** @type {string[]} */ + const definitions = []; + let offset = 0; + let needsBuffer = false; + let needsScope = false; + if (node.flags) { + offset++; + needsBuffer = true; + definitions.push( + 'const flags = buffer[position];\n', + ...node.flags.map((flagName, index) => { + let assignmentLeftHand = node.baseForAdditionalFields?.includes(flagName) + ? `const ${flagName} = ` + : ''; + if (!node.hiddenFields?.includes(flagName)) { + assignmentLeftHand += `node.${flagName} = `; + } + return `${assignmentLeftHand}(flags & ${1 << index}) === ${1 << index};`; + }) + ); + } + for (const [index, field] of fields.entries()) { + const fieldDefinition = getFieldDefinition(field, node, originalNode, offset + index); + needsBuffer = true; + needsScope ||= fieldDefinition.needsScope; + definitions.push(`${fieldDefinition.definition}\n`); + } + offset += fields.length; + for (const [fieldName, fieldValue] of Object.entries(node.additionalFields || {})) { + definitions.push(`node.${fieldName} = ${fieldValue};\n`); + } + for (const [fieldName, fallbackName] of Object.entries(node.optionalFallback || {})) { + needsScope = true; + definitions.push( + `node.${fieldName} = ${fieldName}Position === 0 ? node.${fallbackName} : convertNode(node, scope, ${fieldName}Position, buffer);\n` + ); + } + if (needsScope) { + definitions.unshift('const {scope} = node;'); + } + /** @type {string[]} */ + const parameters = []; + if (definitions.length > 0) { + parameters.push(`node: ${node.astType || name}`); + if (needsBuffer) { + parameters.push('position, buffer'); + } + } + return `function ${firstLettersLowercase(name)} (${parameters.join(', ')}) { + ${definitions.join('')}}`; +}); + +/** + * @param {import("./ast-types.js").FieldWithType} field + * @param {import("./ast-types.js").NodeDescription} node + * @param {import("./ast-types.js").NodeDescription} originalNode + * @param {number} offset + * @returns {{definition: string, needsScope: boolean}} + */ +function getFieldDefinition([fieldName, fieldType], node, originalNode, offset) { + const getPosition = offset > 0 ? `position + ${offset}` : 'position'; + const dataStart = `buffer[${getPosition}]`; + if (node.scriptedFields?.[fieldName]) { + return { + definition: node.scriptedFields?.[fieldName] + .replace(/\$position/g, dataStart) + .replace( + /\$type([A-Z]\w+)\b/g, + (_, typeName) => + `${astNodeNamesWithFieldOrder.findIndex(astNode => astNode.name === typeName)}` + ), + needsScope: true + }; + } + const typeCast = originalNode.fieldTypes?.[fieldName] || node.fieldTypes?.[fieldName]; + const typeCastString = typeCast ? ` as ${typeCast}` : ''; + let assignmentLeftHand = node.baseForAdditionalFields?.includes(fieldName) + ? `const ${fieldName} = ` + : ''; + if (!node.hiddenFields?.includes(fieldName)) { + assignmentLeftHand += `node.${fieldName} = `; + } + const scope = originalNode?.scopes?.[fieldName] || node?.scopes?.[fieldName] || 'scope'; + switch (fieldType) { + case 'Node': { + return { + definition: `${assignmentLeftHand}convertNode(node, ${scope}, ${dataStart}, buffer)${typeCastString};`, + needsScope: true + }; + } + case 'OptionalNode': { + let definition = `const ${fieldName}Position = ${dataStart};`; + let needsScope = false; + if (!node.optionalFallback?.[fieldName]) { + needsScope = true; + let additionalDefinition = `\n${assignmentLeftHand}${fieldName}Position === 0 ? null : convertNode(node, ${scope}, ${fieldName}Position, buffer)${typeCastString}`; + if (node.postProcessFields?.[fieldName]) { + const [variableName, postProcess] = node.postProcessFields[fieldName]; + additionalDefinition = `const ${variableName} = (${additionalDefinition});\n${postProcess}`; + } + definition += additionalDefinition; + } + return { definition, needsScope }; + } + case 'NodeList': { + let definition = `${assignmentLeftHand}convertNodeList(node, ${scope}, ${dataStart}, buffer)${typeCastString}`; + if (node.postProcessFields?.[fieldName]) { + const [variableName, postProcess] = node.postProcessFields[fieldName]; + definition = `const ${variableName} = (${definition});\n${postProcess}`; + } + return { + definition, + needsScope: true + }; + } + case 'Annotations': + case 'InvalidAnnotations': { + let definition = `${assignmentLeftHand}convertAnnotations(${dataStart}, buffer)${typeCastString}`; + if (node.postProcessFields?.[fieldName]) { + const [variableName, postProcess] = node.postProcessFields[fieldName]; + definition = `const ${variableName} = (${definition});\n${postProcess}`; + } + return { + definition, + needsScope: false + }; + } + case 'String': { + return { + definition: `${assignmentLeftHand}buffer.convertString(${dataStart})${typeCastString};`, + needsScope: false + }; + } + case 'OptionalString': + case 'NullableString': { + return { + definition: `const ${fieldName}Position = ${dataStart};\n${assignmentLeftHand}${fieldName}Position === 0 ? ${fieldType === 'OptionalString' ? 'undefined' : 'null'} : buffer.convertString(${fieldName}Position)${typeCastString};`, + needsScope: false + }; + } + case 'FixedString': { + return { + definition: `${assignmentLeftHand}FIXED_STRINGS[${dataStart}]${typeCastString};`, + needsScope: false + }; + } + case 'Float': { + return { + definition: `${assignmentLeftHand}new DataView(buffer.buffer).getFloat64((${getPosition}) << 2, true);`, + needsScope: false + }; + } + default: { + throw new Error(`Unknown field type: ${fieldType}`); + } + } +} + +const bufferParsers = `${notEditFilesComment} +import type * as estree from 'estree'; +import type { AstContext } from '../Module'; +import { convertAnnotations } from '../utils/astConverterHelpers'; +import { EMPTY_ARRAY } from '../utils/blank'; +import { convertNode as convertJsonNode } from '../utils/bufferToAst'; +import FIXED_STRINGS from '../utils/convert-ast-strings'; +import type { AstBuffer } from '../utils/getAstBuffer'; +import { getAstBuffer } from '../utils/getAstBuffer'; +${nodeTypeImports.join('\n')} +import { UNKNOWN_EXPRESSION } from './nodes/shared/Expression'; +import type { Node, NodeBase } from './nodes/shared/Node'; +import type ChildScope from './scopes/ChildScope'; +import type ModuleScope from './scopes/ModuleScope'; +import TrackingScope from './scopes/TrackingScope'; +import { EMPTY_PATH } from './utils/PathTracker'; +import type ParameterVariable from './variables/ParameterVariable'; + +export function convertProgram( + buffer: Buffer | Uint8Array, + parent: Node | { context: AstContext; type: string }, + parentScope: ModuleScope +): Program { + return convertNode(parent, parentScope, 0, getAstBuffer(buffer)); +} + +const nodeTypeStrings = [ + ${nodeTypeStrings.join(',\n')} +] as const; + +const nodeConstructors: (typeof NodeBase)[] = [ + ${nodeTypes.join(',\n')} +]; + +const bufferParsers: ((node: any, position: number, buffer: AstBuffer) => void)[] = [ + ${jsConverters.join(',\n')} +]; + +function convertNode( + parent: Node | { context: AstContext; type: string }, + parentScope: ChildScope, + position: number, + buffer: AstBuffer +): any { + const nodeType = buffer[position]; + const NodeConstructor = nodeConstructors[nodeType]; + /* istanbul ignore if: This should never be executed but is a safeguard against faulty buffers */ + if (!NodeConstructor) { + console.trace(); + throw new Error(\`Unknown node type: $\{nodeType}\`); + } + const node = new NodeConstructor(parent, parentScope); + node.type = nodeTypeStrings[nodeType]; + node.start = buffer[position + 1]; + node.end = buffer[position + 2]; + bufferParsers[nodeType](node, position + 3, buffer); + node.initialise(); + return node; +} + +function convertNodeList( + parent: Node | { context: AstContext; type: string }, + parentScope: ChildScope, + position: number, + buffer: AstBuffer +): any[] { + if (position === 0) return EMPTY_ARRAY as never[]; + const length = buffer[position++]; + const list: any[] = new Array(length); + for (let index = 0; index < length; index++) { + const nodePosition = buffer[position++]; + list[index] = nodePosition ? convertNode(parent, parentScope, nodePosition, buffer) : null; + } + return list; +} +`; + +await writeFile(bufferParsersFile, bufferParsers); +await lintTsFile(bufferParsersFile); diff --git a/scripts/generate-buffer-to-ast.js b/scripts/generate-buffer-to-ast.js new file mode 100644 index 00000000000..648b0d2e8bd --- /dev/null +++ b/scripts/generate-buffer-to-ast.js @@ -0,0 +1,254 @@ +import { writeFile } from 'node:fs/promises'; +import { astNodeNamesWithFieldOrder } from './ast-types.js'; +import { firstLettersLowercase, generateNotEditFilesComment, lintTsFile } from './helpers.js'; + +const notEditFilesComment = generateNotEditFilesComment(import.meta.url); + +const bufferToJsAstFile = new URL('../src/utils/bufferToAst.ts', import.meta.url); + +const jsConverters = astNodeNamesWithFieldOrder.map(({ name, fields, node, originalNode }) => { + /** @type {string[]} */ + const definitions = []; + let offset = 2; + if (node.flags) { + offset++; + definitions.push('const flags = buffer[position + 2];\n'); + for (const [index, flag] of node.flags.entries()) { + if (isHoistedField(flag, node)) { + definitions.push(`const ${flag} = (flags & ${1 << index}) === ${1 << index};`); + } + } + } + for (const [index, field] of fields.entries()) { + definitions.push(getFieldDefinition(field, node, originalNode, index + offset)); + if (isHoistedField(field[0], node)) { + definitions.push( + `const ${field[0]} = ${getFieldPropertyBase(field, node, originalNode, index + offset)};` + ); + } + } + /** @type {string[]} */ + const properties = [ + ...(node.flags || []).map((name, index) => + isHoistedField(name, node) ? name : `${name}: (flags & ${1 << index}) === ${1 << index}` + ), + ...fields + .map((field, index) => getFieldProperty(field, node, originalNode, index + offset)) + .filter(Boolean), + ...getFixedProperties(node), + ...Object.entries(node.additionalFields || []).map(([key, value]) => `${key}: ${value}`) + ]; + return `function ${firstLettersLowercase(name)} (position, buffer): ${name}Node { + ${definitions.join('')}return { + type: '${node.astType || name}', + start: buffer[position], + end: buffer[position + 1], + ${properties.join(',\n')} + }; + }`; +}); + +/** + * @param {string} name + * @param {import("./ast-types.js").NodeDescription} node + * @returns {boolean|undefined} + */ +function isHoistedField(name, node) { + return ( + node.baseForAdditionalFields?.includes(name) || + (node.optionalFallback && Object.values(node.optionalFallback).includes(name)) + ); +} + +/** + * @param {import("./ast-types.js").FieldWithType} field + * @param {import("./ast-types.js").NodeDescription} node + * @param {import("./ast-types.js").NodeDescription} originalNode + * @param {number} offset + * @returns {string} + */ +function getFieldDefinition([fieldName, fieldType], node, originalNode, offset) { + const typeCast = originalNode.fieldTypes?.[fieldName] || node.fieldTypes?.[fieldName]; + const typeCastString = typeCast ? ` as ${typeCast}` : ''; + const position = `position + ${offset}`; + const dataStart = `buffer[${position}]`; + switch (fieldType) { + case 'Node': + case 'NodeList': + case 'String': + case 'FixedString': + case 'Float': { + return ''; + } + case 'OptionalNode': { + return `const ${fieldName}Position = ${dataStart};\n`; + } + case 'Annotations': + case 'InvalidAnnotations': { + return `const ${fieldName} = convertAnnotations(${dataStart}, buffer)${typeCastString};\n`; + } + case 'OptionalString': + case 'NullableString': { + return `const ${fieldName}Position = ${dataStart};\n`; + } + default: { + throw new Error(`Unknown field type: ${fieldType}`); + } + } +} + +/** + * @param {import("./ast-types.js").FieldWithType} field + * @param {import("./ast-types.js").NodeDescription} node + * @param {import("./ast-types.js").NodeDescription} originalNode + * @param {number} offset + * @returns {string} + */ +function getFieldProperty([fieldName, fieldType], node, originalNode, offset) { + if (node.hiddenFields?.includes(fieldName)) { + return ''; + } + if (isHoistedField(fieldName, node)) { + return fieldName; + } + switch (fieldType) { + case 'Annotations': { + return `...(${fieldName}.length > 0 ? { [ANNOTATION_KEY]: ${fieldName} } : {})`; + } + case 'InvalidAnnotations': { + return `...(${fieldName}.length > 0 ? { [INVALID_ANNOTATION_KEY]: ${fieldName} } : {})`; + } + default: { + return `${fieldName}: ${getFieldPropertyBase([fieldName, fieldType], node, originalNode, offset)}`; + } + } +} + +/** + * @param {import("./ast-types.js").FieldWithType} field + * @param {import("./ast-types.js").NodeDescription} node + * @param {import("./ast-types.js").NodeDescription} originalNode + * @param {number} offset + * @returns {string} + */ +function getFieldPropertyBase([fieldName, fieldType], node, originalNode, offset) { + const typeCast = originalNode.fieldTypes?.[fieldName] || node.fieldTypes?.[fieldName]; + const typeCastString = typeCast ? ` as ${typeCast}` : ''; + const position = `position + ${offset}`; + const dataStart = `buffer[${position}]`; + switch (fieldType) { + case 'Node': { + return `convertNode(${dataStart}, buffer)${typeCastString}`; + } + case 'OptionalNode': { + const fallback = node.optionalFallback?.[fieldName]; + return `${fieldName}Position === 0 ? ${fallback ? `{ ...${fallback} }` : null} : convertNode(${fieldName}Position, buffer)${typeCastString}`; + } + case 'NodeList': { + return `convertNodeList(${dataStart}, buffer)${typeCastString}`; + } + case 'String': { + return `buffer.convertString(${dataStart})${typeCastString}`; + } + case 'OptionalString': + case 'NullableString': { + return `${fieldName}Position === 0 ? ${fieldType === 'OptionalString' ? 'undefined' : 'null'} : buffer.convertString(${fieldName}Position)${typeCastString}`; + } + case 'FixedString': { + return `FIXED_STRINGS[${dataStart}]${typeCastString}`; + } + case 'Float': { + return `new DataView(buffer.buffer).getFloat64(${position} << 2, true)`; + } + default: { + throw new Error(`Cannot get field property base for: ${fieldType}`); + } + } +} + +/** + * @param {import("./ast-types.js").NodeDescription} node + * @return {string[]} + */ +function getFixedProperties(node) { + return Object.entries(node.fixed || {}).map(([key, value]) => `${key}: ${JSON.stringify(value)}`); +} + +const types = astNodeNamesWithFieldOrder.map(({ name, node }) => { + let typeDefinition = `export type ${name}Node = RollupAstNode<${node.estreeType || `estree.${name}`}>`; + /** @type {string[]} */ + const additionalFieldTypes = []; + if ((node.fields || []).some(([, fieldType]) => fieldType === 'Annotations')) { + additionalFieldTypes.push('[ANNOTATION_KEY]?: readonly RollupAnnotation[]'); + } + if ((node.fields || []).some(([, fieldType]) => fieldType === 'InvalidAnnotations')) { + additionalFieldTypes.push('[INVALID_ANNOTATION_KEY]?: readonly RollupAnnotation[]'); + } + const fixedProperties = getFixedProperties(node); + if (fixedProperties.length > 0) { + additionalFieldTypes.push(...getFixedProperties(node)); + } + if (additionalFieldTypes.length > 0) { + typeDefinition += ` & { ${additionalFieldTypes.join('; ')} }`; + } + typeDefinition += ';'; + return typeDefinition; +}); + +const bufferToJsAst = `${notEditFilesComment} +import type * as estree from 'estree'; +import { PanicError, ParseError } from '../ast/nodes/NodeType';import type { RollupAstNode } from '../rollup/types'; +import type { RollupAnnotation } from './astConverterHelpers'; +import { ANNOTATION_KEY, convertAnnotations, INVALID_ANNOTATION_KEY } from './astConverterHelpers'; +import { EMPTY_ARRAY } from './blank'; +import FIXED_STRINGS from './convert-ast-strings'; +import type { AstBuffer } from './getAstBuffer'; +import { error, getRollupError, logParseError } from './logs'; + +export function convertProgram(buffer: AstBuffer): ProgramNode { + const node = convertNode(0, buffer); + switch (node.type) { + case PanicError: { + return error(getRollupError(logParseError(node.message))); + } + case ParseError: { + return error(getRollupError(logParseError(node.message, node.start))); + } + default: { + return node; + } + } +} + +/* eslint-disable sort-keys */ +const nodeConverters: ((position: number, buffer: AstBuffer) => any)[] = [ + ${jsConverters.join(',\n')} +]; + +${types.join('\n')} + +export function convertNode(position: number, buffer: AstBuffer): any { + const nodeType = buffer[position]; + const converter = nodeConverters[nodeType]; + /* istanbul ignore if: This should never be executed but is a safeguard against faulty buffers */ + if (!converter) { + console.trace(); + throw new Error(\`Unknown node type: \${nodeType}\`); + } + return converter(position + 1, buffer); +} + +function convertNodeList(position: number, buffer: AstBuffer): any[] { + if (position === 0) return EMPTY_ARRAY as never[]; + const length = buffer[position++]; + const list: any[] = new Array(length); + for (let index = 0; index < length; index++) { + const nodePosition = buffer[position++]; + list[index] = nodePosition ? convertNode(nodePosition, buffer) : null; + } + return list; +} +`; + +await writeFile(bufferToJsAstFile, bufferToJsAst); +await lintTsFile(bufferToJsAstFile); diff --git a/scripts/generate-child-node-keys.js b/scripts/generate-child-node-keys.js new file mode 100644 index 00000000000..6bc080bca24 --- /dev/null +++ b/scripts/generate-child-node-keys.js @@ -0,0 +1,33 @@ +import { writeFile } from 'node:fs/promises'; +import { AST_NODES } from './ast-types.js'; +import { generateNotEditFilesComment, lintTsFile } from './helpers.js'; + +const notEditFilesComment = generateNotEditFilesComment(import.meta.url); + +const childNodeKeysFile = new URL('../src/ast/childNodeKeys.ts', import.meta.url); + +/** @type {Record>} */ +const childNodeKeysByAstType = {}; +for (const [name, node] of Object.entries(AST_NODES)) { + const astType = node.astType || name; + const keySet = (childNodeKeysByAstType[astType] ||= new Set()); + for (const [fieldName, fieldType] of (node.hasSameFieldsAs + ? AST_NODES[node.hasSameFieldsAs].fields + : node.fields) || []) { + if (['NodeList', 'Node', 'OptionalNode'].includes(fieldType)) { + keySet.add(fieldName); + } + } +} + +const childNodeKeys = `${notEditFilesComment} +export const childNodeKeys: Record = { + ${Object.entries(childNodeKeysByAstType) + .sort(([astType1], [astType2]) => astType1.localeCompare(astType2)) + .map(([astType, keys]) => `${astType}: [${[...keys].map(key => `'${key}'`).join(', ')}]`) + .join(',\n ')} +}; +`; + +await writeFile(childNodeKeysFile, childNodeKeys); +await lintTsFile(childNodeKeysFile); diff --git a/scripts/generate-node-index.js b/scripts/generate-node-index.js new file mode 100644 index 00000000000..3dc4f59bf9c --- /dev/null +++ b/scripts/generate-node-index.js @@ -0,0 +1,27 @@ +import { writeFile } from 'node:fs/promises'; +import { AST_NODES } from './ast-types.js'; +import { generateNotEditFilesComment, lintTsFile } from './helpers.js'; + +const notEditFilesComment = generateNotEditFilesComment(import.meta.url); + +const nodeIndexFile = new URL('../src/ast/nodes/index.ts', import.meta.url); + +/** @type string[] */ +const astTypes = [ + ...new Set(Object.entries(AST_NODES).map(([name, node]) => node.astType || name)), + 'UnknownNode' +].sort(); + +const nodeIndex = `${notEditFilesComment} +${astTypes.map(astType => `import ${astType} from './${astType}';`).join('\n')} +import type { NodeBase } from './shared/Node'; + +export const nodeConstructors: { + [name: string]: typeof NodeBase; +} = { + ${astTypes.join(',\n\t')} +}; +`; + +await writeFile(nodeIndexFile, nodeIndex); +await lintTsFile(nodeIndexFile); diff --git a/scripts/generate-node-types.js b/scripts/generate-node-types.js new file mode 100644 index 00000000000..b9637b1213d --- /dev/null +++ b/scripts/generate-node-types.js @@ -0,0 +1,21 @@ +import { writeFile } from 'node:fs/promises'; +import { AST_NODES } from './ast-types.js'; +import { generateNotEditFilesComment, lintTsFile } from './helpers.js'; + +const notEditFilesComment = generateNotEditFilesComment(import.meta.url); + +const nodeTypesFile = new URL('../src/ast/nodes/NodeType.ts', import.meta.url); + +/** @type string[] */ +const astTypes = [ + ...new Set(Object.entries(AST_NODES).map(([name, node]) => node.astType || name)) +].sort(); + +const nodeIndex = `${notEditFilesComment} +${astTypes.map(astType => `export type t${astType} = '${astType}';`).join('\n')} + +${astTypes.map(astType => `export const ${astType}: t${astType} = '${astType}';`).join('\n')} +`; + +await writeFile(nodeTypesFile, nodeIndex); +await lintTsFile(nodeTypesFile); diff --git a/scripts/generate-rust-constants.js b/scripts/generate-rust-constants.js new file mode 100644 index 00000000000..5c99fffe6a1 --- /dev/null +++ b/scripts/generate-rust-constants.js @@ -0,0 +1,68 @@ +import { writeFile } from 'node:fs/promises'; +import { AST_NODES, astNodeNamesWithFieldOrder } from './ast-types.js'; +import { generateNotEditFilesComment, lintRustFile, toScreamingSnakeCase } from './helpers.js'; + +const BYTES_PER_U32 = 4; + +const notEditFilesComment = generateNotEditFilesComment(import.meta.url); + +const astConstantsFile = new URL( + '../rust/parse_ast/src/convert_ast/converter/ast_constants.rs', + import.meta.url +); + +const nodeTypes = astNodeNamesWithFieldOrder + .map(({ name, node: { useMacro } }, index) => + useMacro === false + ? `pub const TYPE_${toScreamingSnakeCase(name)}: [u8; 4] = ${index}u32.to_ne_bytes();\n` + : '' + ) + .join(''); + +const reservedBytesAndOffsets = astNodeNamesWithFieldOrder + .map(({ name, fields, node: { useMacro } }) => { + const { flags, hasSameFieldsAs } = AST_NODES[name]; + if (hasSameFieldsAs || useMacro !== false) { + return ''; + } + /** @type {string[]} */ + const lines = []; + // reservedBytes is the number of bytes reserved for + // - end position + // - flags if present + // - non-inlined fields + let reservedBytes = BYTES_PER_U32; + if (flags) { + reservedBytes += BYTES_PER_U32; + } + for (const [fieldName, fieldType] of fields) { + lines.push( + `pub const ${toScreamingSnakeCase(name)}_${toScreamingSnakeCase( + fieldName + )}_OFFSET: usize = ${reservedBytes};` + ); + switch (fieldType) { + case 'Float': { + reservedBytes += 8; + break; + } + default: { + reservedBytes += BYTES_PER_U32; + } + } + } + lines.unshift( + `pub const ${toScreamingSnakeCase(name)}_RESERVED_BYTES: usize = ${reservedBytes};` + ); + return `${lines.join('\n')}\n`; + }) + .join('\n'); + +const astConstants = `${notEditFilesComment} +${nodeTypes} + +${reservedBytesAndOffsets} +`; + +await writeFile(astConstantsFile, astConstants); +await lintRustFile(astConstantsFile); diff --git a/scripts/generate-string-constants.js b/scripts/generate-string-constants.js new file mode 100644 index 00000000000..120c2a6c958 --- /dev/null +++ b/scripts/generate-string-constants.js @@ -0,0 +1,100 @@ +import { writeFile } from 'node:fs/promises'; +import { generateNotEditFilesComment, lintRustFile, lintTsFile } from './helpers.js'; + +const notEditFilesComment = generateNotEditFilesComment(import.meta.url); + +const targetRustFile = new URL( + '../rust/parse_ast/src/convert_ast/converter/string_constants.rs', + import.meta.url +); +const targetTsFile = new URL('../src/utils/convert-ast-strings.ts', import.meta.url); + +const stringConstantsTemplate = [ + ['STRING_VAR', 'var'], + ['STRING_LET', 'let'], + ['STRING_CONST', 'const'], + ['STRING_INIT', 'init'], + ['STRING_GET', 'get'], + ['STRING_SET', 'set'], + ['STRING_CONSTRUCTOR', 'constructor'], + ['STRING_METHOD', 'method'], + ['STRING_MINUS', '-'], + ['STRING_PLUS', '+'], + ['STRING_BANG', '!'], + ['STRING_TILDE', '~'], + ['STRING_TYPEOF', 'typeof'], + ['STRING_VOID', 'void'], + ['STRING_DELETE', 'delete'], + ['STRING_PLUSPLUS', '++'], + ['STRING_MINUSMINUS', '--'], + ['STRING_EQEQ', '=='], + ['STRING_NOTEQ', '!='], + ['STRING_EQEQEQ', '==='], + ['STRING_NOTEQEQ', '!=='], + ['STRING_LT', '<'], + ['STRING_LTEQ', '<='], + ['STRING_GT', '>'], + ['STRING_GTEQ', '>='], + ['STRING_LSHIFT', '<<'], + ['STRING_RSHIFT', '>>'], + ['STRING_ZEROFILLRSHIFT', '>>>'], + ['STRING_ADD', '+'], + ['STRING_SUB', '-'], + ['STRING_MUL', '*'], + ['STRING_DIV', '/'], + ['STRING_MOD', '%'], + ['STRING_BITOR', '|'], + ['STRING_BITXOR', '^'], + ['STRING_BITAND', '&'], + ['STRING_LOGICALOR', '||'], + ['STRING_LOGICALAND', '&&'], + ['STRING_IN', 'in'], + ['STRING_INSTANCEOF', 'instanceof'], + ['STRING_EXP', '**'], + ['STRING_NULLISHCOALESCING', '??'], + ['STRING_ASSIGN', '='], + ['STRING_ADDASSIGN', '+='], + ['STRING_SUBASSIGN', '-='], + ['STRING_MULASSIGN', '*='], + ['STRING_DIVASSIGN', '/='], + ['STRING_MODASSIGN', '%='], + ['STRING_LSHIFTASSIGN', '<<='], + ['STRING_RSHIFTASSIGN', '>>='], + ['STRING_ZEROFILLRSHIFTASSIGN', '>>>='], + ['STRING_BITORASSIGN', '|='], + ['STRING_BITXORASSIGN', '^='], + ['STRING_BITANDASSIGN', '&='], + ['STRING_EXPASSIGN', '**='], + ['STRING_ANDASSIGN', '&&='], + ['STRING_ORASSIGN', '||='], + ['STRING_NULLISHASSIGN', '??='], + ['STRING_PURE', 'pure'], + ['STRING_NOSIDEEFFECTS', 'noSideEffects'], + ['STRING_SOURCEMAP', 'sourcemap'], + ['STRING_USING', 'using'], + ['STRING_AWAIT_USING', 'await using'] +]; + +const rustCode = + notEditFilesComment + + stringConstantsTemplate + .map( + ([variableName, value], index) => + `pub const ${variableName}: [u8; 4] = ${index}u32.to_ne_bytes(); // ${value}` + ) + .join('\n'); + +const tsCode = + notEditFilesComment + + `export default ` + + JSON.stringify( + stringConstantsTemplate.map(([, value]) => value), + undefined, + 2 + ) + + `;\n`; + +await Promise.all([ + writeFile(targetTsFile, tsCode).then(() => lintTsFile(targetTsFile)), + writeFile(targetRustFile, rustCode).then(() => lintRustFile(targetRustFile)) +]); diff --git a/scripts/helpers.js b/scripts/helpers.js new file mode 100644 index 00000000000..b3f0329c7d7 --- /dev/null +++ b/scripts/helpers.js @@ -0,0 +1,135 @@ +import { ESLint } from 'eslint'; +import { spawn } from 'node:child_process'; +import { readFile } from 'node:fs/promises'; +import path from 'node:path'; +import { fileURLToPath } from 'node:url'; +import { blue, bold, cyan, green, magenta, red, yellow } from './colors.js'; + +const colors = [cyan, yellow, blue, red, green, magenta]; +let nextColorIndex = 0; + +/** + * @param {string} command + * @param {string[]} parameters + * @param {Parameters[2]=} options + * @return {Promise} + */ +export function runWithEcho(command, parameters, options) { + const color = colors[nextColorIndex]; + nextColorIndex = (nextColorIndex + 1) % colors.length; + return /** @type {Promise} */ ( + new Promise((resolve, reject) => { + const cmdString = formatCommand(command, parameters); + console.error(bold(`\n${color('Run>')} ${cmdString}`)); + + const childProcess = spawn(command, parameters, { stdio: 'inherit', ...options }); + + childProcess.on('close', code => { + if (code) { + reject(new Error(`"${cmdString}" exited with code ${code}.`)); + } else { + console.error(bold(`${color('Finished>')} ${cmdString}\n`)); + resolve(); + } + }); + }) + ); +} + +/** + * @param {string} command + * @param {string[]} parameters + * @return {Promise} + */ +export function runAndGetStdout(command, parameters) { + return new Promise((resolve, reject) => { + const childProcess = spawn(command, parameters); + let stdout = ''; + + childProcess.stderr.pipe(process.stderr); + childProcess.stdout.on('data', data => (stdout += String(data))); + + childProcess.on('close', code => { + if (code) { + reject(new Error(`"${formatCommand(command, parameters)}" exited with code ${code}.`)); + } else { + resolve(stdout.trim()); + } + }); + }); +} + +/** + * @param {string} command + * @param {string[]} parameters + * @return {string} + */ +function formatCommand(command, parameters) { + return [command, ...parameters].join(' '); +} + +/** + * @param {string} file + * @returns {Promise>} + */ +export async function readJson(file) { + const content = await readFile(file, 'utf8'); + return JSON.parse(content); +} + +/** + * @param {URL} file + * @return {Promise} + */ +export async function lintTsFile(file) { + const eslint = new ESLint({ fix: true }); + const results = await eslint.lintFiles([fileURLToPath(file)]); + await ESLint.outputFixes(results); + const formatter = await eslint.loadFormatter('stylish'); + const resultText = formatter.format(results); + console.log(resultText); +} + +/** + * @param {URL} file + * @return {Promise} + */ +export function lintRustFile(file) { + return runWithEcho('rustfmt', [fileURLToPath(file)]); +} + +/** + * Replace the first letters with lowercase while maintaining camel casing + * @param {string} string + * @returns {string} + */ +export function firstLettersLowercase(string) { + return string.replace(/^[A-Z]+/, match => + match.length === 1 ? match.toLowerCase() : match.slice(0, -1).toLowerCase() + match.slice(-1) + ); +} + +/** + * @param {string} string + * @returns {string} + */ +export function toSnakeCase(string) { + return string.replace(/(? 0) { + throw new Error( + `${JSON.stringify( + notFoundExports.join(',') + )} was exported from native.js but not exported from native.wasm.js.` + ); +} diff --git a/scripts/load-perf-config.js b/scripts/load-perf-config.js deleted file mode 100644 index 8784f9c5071..00000000000 --- a/scripts/load-perf-config.js +++ /dev/null @@ -1,39 +0,0 @@ -const path = require('path'); -const fs = require('fs'); -const rollup = require('../dist/rollup.js'); - -exports.targetDir = path.resolve(__dirname, '..', 'perf'); -const configFile = path.resolve(exports.targetDir, 'rollup.config.js'); - -try { - fs.accessSync(configFile, fs.constants.R_OK); -} catch (e) { - console.error( - `No valid "rollup.config.js" in ${exports.targetDir}. Did you "npm run perf:init"?` - ); - process.exit(1); -} - -exports.loadPerfConfig = async () => { - const bundle = await rollup.rollup({ - input: configFile, - external: id => (id[0] !== '.' && !path.isAbsolute(id)) || id.slice(-5, id.length) === '.json', - onwarn: warning => console.error(warning.message) - }); - let config = loadConfigFromCode((await bundle.generate({ format: 'cjs' })).output[0].code); - config = typeof config === 'function' ? config({}) : config; - return Array.isArray(config) ? config[0] : config; -}; - -function loadConfigFromCode(code) { - const defaultLoader = require.extensions['.js']; - require.extensions['.js'] = (module, filename) => { - if (filename === configFile) { - module._compile(code, filename); - } else { - defaultLoader(module, filename); - } - }; - delete require.cache[configFile]; - return require(configFile); -} diff --git a/scripts/package.json b/scripts/package.json new file mode 100644 index 00000000000..3dbc1ca591c --- /dev/null +++ b/scripts/package.json @@ -0,0 +1,3 @@ +{ + "type": "module" +} diff --git a/scripts/perf-debug.js b/scripts/perf-debug.js deleted file mode 100644 index 2173118fc3d..00000000000 --- a/scripts/perf-debug.js +++ /dev/null @@ -1,8 +0,0 @@ -const rollup = require('../dist/rollup.js'); -const loadConfig = require('./load-perf-config').loadPerfConfig; - -loadConfig().then(async config => - (await rollup.rollup(config)).generate( - Array.isArray(config.output) ? config.output[0] : config.output - ) -); diff --git a/scripts/perf-init.js b/scripts/perf-init.js deleted file mode 100644 index fa3930f76f8..00000000000 --- a/scripts/perf-init.js +++ /dev/null @@ -1,52 +0,0 @@ -/* eslint-disable no-console */ - -const execa = require('execa'); -const path = require('path'); -const fs = require('fs'); -const sander = require('sander'); -const repoWithBranch = process.argv[2]; - -const TARGET_DIR = path.resolve(__dirname, '..', 'perf'); -const VALID_REPO = /^([^/\s#]+\/[^/\s#]+)(#([^/\s#]+))?$/; - -if (process.argv.length !== 3 || !VALID_REPO.test(repoWithBranch)) { - console.error( - 'You need to provide a GitHub repo in the form / or /#branch, e.g. ' + - '"npm run perf:init rollup/rollup"' - ); - process.exit(1); -} -console.error(`Cleaning up '${TARGET_DIR}'...`); -sander.rimrafSync(TARGET_DIR); - -const [, repo, , branch] = VALID_REPO.exec(repoWithBranch); - -setupNewRepo(repo, branch).catch(error => { - console.error(error.message); - process.exit(1); -}); - -function execWithOutput(command, args) { - const call = execa(command, args); - call.stderr.pipe(process.stderr); - return call; -} - -async function setupNewRepo(repo, branch) { - const gitArgs = ['clone', '--depth', 1, '--progress']; - if (branch) { - console.error(`Cloning branch "${branch}" of "${repo}"...`); - gitArgs.push('--branch', branch); - } else { - console.error(`Cloning "${repo}"...`); - } - gitArgs.push(`https://github.com/${repo}.git`, TARGET_DIR); - await execWithOutput('git', gitArgs); - try { - fs.accessSync(path.resolve(TARGET_DIR, 'rollup.config.js'), fs.constants.R_OK); - } catch (e) { - throw new Error('The repository needs to have a file "rollup.config.js" at the top level.'); - } - process.chdir(TARGET_DIR); - await execWithOutput('npm', ['install']); -} diff --git a/scripts/perf-report/index.js b/scripts/perf-report/index.js new file mode 100644 index 00000000000..0ce225a4b1f --- /dev/null +++ b/scripts/perf-report/index.js @@ -0,0 +1,318 @@ +/* global gc */ + +import { mkdir, symlink, writeFile } from 'node:fs/promises'; +import { chdir } from 'node:process'; +import { fileURLToPath } from 'node:url'; +import pc from 'picocolors'; +import prettyBytes from 'pretty-bytes'; +import { runWithEcho } from '../helpers.js'; +import reportCollector from './report-collector.js'; +import { newRollup, previousRollup, previousVersion } from './rollup-artefacts.js'; + +/** + * @typedef {Record} CollectedTimings + */ + +/** + * @typedef {Record} AccumulatedTimings + */ + +const PERF_DIRECTORY = new URL('../../perf/', import.meta.url); +const ENTRY = new URL('entry.js', PERF_DIRECTORY); +const THREEJS_COPIES = 10; +const { bold, underline, cyan, red, green } = pc.createColors(); +const MIN_ABSOLUTE_TIME_DEVIATION = 10; +const MIN_RELATIVE_DEVIATION_PERCENT = 2; +const RELATIVE_DEVIATION_PERCENT_FOR_COLORING = 5; +const RUNS_TO_AVERAGE = 7; +const DISCARDED_LARGE_RESULTS = 2; +const DISCARDED_SMALL_RESULTS = 1; + +await ensureBenchmarkExists(); +await calculatePrintAndPersistTimings(); + +async function ensureBenchmarkExists() { + const THREE_DIRECTORY = new URL('threejs1/', PERF_DIRECTORY); + // mkdir only returns undefined if the directory already exists, in which case + // we do not need to prepare anything + if (await mkdir(THREE_DIRECTORY, { recursive: true })) { + console.info(bold(`Creating a benchmark to bundle ${cyan(THREEJS_COPIES)} copies of ThreeJS.`)); + const promises = [ + runWithEcho('git', [ + 'clone', + '--depth', + '1', + '--branch', + 'r108', + 'https://github.com/mrdoob/three.js.git', + fileURLToPath(THREE_DIRECTORY) + ]) + ]; + for (let index = 2; index <= THREEJS_COPIES; index++) { + promises.push(symlink(THREE_DIRECTORY, new URL(`threejs${index}`, PERF_DIRECTORY))); + } + let entry = ''; + for (let index = 1; index <= THREEJS_COPIES; index++) { + entry += `export * as threejs${index} from './threejs${index}/src/Three.js';\n`; + } + promises.push(writeFile(ENTRY, entry)); + await Promise.all(promises); + } +} + +async function calculatePrintAndPersistTimings() { + console.info( + bold( + `Comparing against rollup@${previousVersion}.\nCalculating the average of ${cyan(RUNS_TO_AVERAGE)} runs discarding the ${cyan( + DISCARDED_LARGE_RESULTS + )} largest and the ${cyan(DISCARDED_SMALL_RESULTS)}s smallest results.` + ) + ); + chdir(fileURLToPath(PERF_DIRECTORY)); + /** @type {AccumulatedTimings} */ + const accumulatedPreviousTimings = {}; + await buildAndGetTimings(previousRollup, accumulatedPreviousTimings); + /** @type {AccumulatedTimings} */ + const accumulatedNewTimings = {}; + await buildAndGetTimings( + /** @type{typeof import('rollup').rollup} */ (newRollup), + accumulatedNewTimings + ); + for (let currentRun = 1; currentRun < RUNS_TO_AVERAGE; currentRun++) { + const numberOfLinesToClear = printMeasurements( + getAverage(accumulatedNewTimings, currentRun), + getAverage(accumulatedPreviousTimings, currentRun), + /^#/ + ); + console.info(`Completed run ${currentRun}.`); + await buildAndGetTimings(previousRollup, accumulatedPreviousTimings); + await buildAndGetTimings( + /** @type{typeof import('rollup').rollup} */ (newRollup), + accumulatedNewTimings + ); + clearLines(numberOfLinesToClear); + } + reportCollector.startRecord(); + printMeasurements( + getAverage(accumulatedNewTimings, RUNS_TO_AVERAGE), + getAverage(accumulatedPreviousTimings, RUNS_TO_AVERAGE) + ); + await reportCollector.outputMsg(); +} + +/** + * @param {typeof import('rollup').rollup} rollup + * @param {AccumulatedTimings} accumulatedTimings + */ +async function buildAndGetTimings(rollup, accumulatedTimings) { + if (typeof gc === 'undefined') { + throw new TypeError('Garbage collection is not enabled'); + } + gc(); + const bundle = await rollup({ + input: fileURLToPath(ENTRY), + onLog() {}, + perf: true + }); + await bundle.generate({ format: 'es' }); + if (!bundle.getTimings) { + throw new Error('Timings not found in the bundle.'); + } + for (const [label, timings] of Object.entries(bundle.getTimings())) { + (accumulatedTimings[label] ||= []).push(timings); + } +} + +/** + * @param {AccumulatedTimings} accumulatedMeasurements + * @param {number} runs + * @return {CollectedTimings} + */ +function getAverage(accumulatedMeasurements, runs) { + /** + * @type {CollectedTimings} + */ + const average = {}; + for (const label of Object.keys(accumulatedMeasurements)) { + average[label] = { + memory: getSingleAverage( + accumulatedMeasurements[label].map(timing => timing[2]), + runs, + DISCARDED_LARGE_RESULTS, + DISCARDED_SMALL_RESULTS + ), + time: getSingleAverage( + accumulatedMeasurements[label].map(timing => timing[0]), + runs, + DISCARDED_LARGE_RESULTS, + DISCARDED_SMALL_RESULTS + ) + }; + } + return average; +} + +/** + * @param {number[]} times + * @param {number} runs + * @param {number} discardedLarge + * @param {number} discardedSmall + * @return {number} + */ +function getSingleAverage(times, runs, discardedLarge, discardedSmall) { + const actualDiscarded = Math.min(discardedLarge + discardedSmall, runs - 1); + const actualDiscardedSmall = Math.max(actualDiscarded - discardedLarge, 0); + const actualDiscardedLarge = actualDiscarded - actualDiscardedSmall; + return ( + times + .sort() + .reverse() + .slice(actualDiscardedLarge, runs - actualDiscardedSmall) + .reduce((sum, time) => sum + time, 0) / + (runs - actualDiscarded) + ); +} + +/** + * @param {CollectedTimings} newAverage + * @param {CollectedTimings} previousAverage + * @param {RegExp} filter + * @return {number} + */ +function printMeasurements(newAverage, previousAverage, filter = /.*/) { + const newPrintedLabels = Object.keys(newAverage).filter(predicateLabel); + const previousPrintedLabels = Object.keys(previousAverage).filter(predicateLabel); + + const newTreeShakings = newPrintedLabels.filter(isTreeShakingLabel); + const oldTreeShakings = previousPrintedLabels.filter(isTreeShakingLabel); + + const addedTreeShaking = newTreeShakings.length - oldTreeShakings.length; + let treeShakingCount = 0; + + for (const label of newPrintedLabels) { + /** + * @type {function(string): string} + */ + let color = identity; + if (label[0] === '#') { + color = bold; + if (label[1] !== '#') { + color = underline; + } + } + const texts = []; + if (isTreeShakingLabel(label)) { + treeShakingCount++; + if (addedTreeShaking < 0 && treeShakingCount === newTreeShakings.length) { + texts.push(generateSingleReport(label)); + for (const label of oldTreeShakings.slice(addedTreeShaking)) { + const { time, memory } = previousAverage[label]; + texts.push(`${label}: ${time.toFixed(0)}ms, ${prettyBytes(memory)}, removed stage`); + } + } else if (addedTreeShaking > 0 && treeShakingCount > oldTreeShakings.length) { + texts.push(generateSingleReport(label, ', new stage')); + } else { + texts.push(generateSingleReport(label)); + } + } else { + texts.push(generateSingleReport(label)); + } + for (const text of texts) { + reportCollector.push(text); + console.info(color(text)); + } + } + return Math.max(newPrintedLabels.length, previousPrintedLabels.length) + 2; + + /** + * @param {string} label + */ + function predicateLabel(label) { + return filter.test(label); + } + + /** + * @param {string} label + * @param {string} addon + */ + function generateSingleReport(label, addon = '') { + return `${label}: ${getFormattedTime( + newAverage[label].time, + previousAverage[label]?.time + )}, ${getFormattedMemory(newAverage[label].memory, previousAverage[label]?.memory)}${addon}`; + } +} + +/** + * @param {string} label + */ +function isTreeShakingLabel(label) { + return label.startsWith('treeshaking pass'); +} + +/** + * @param {number} measuredTime + * @param {number} baseTime + * @return {string} + */ +function getFormattedTime(measuredTime, baseTime = measuredTime) { + /** + * @type {function(string): string} + */ + let color = identity, + formattedTime = `${measuredTime.toFixed(0)}ms`; + const absoluteDeviation = Math.abs(measuredTime - baseTime); + const relativeDeviation = 100 * (absoluteDeviation / baseTime); + if ( + absoluteDeviation > MIN_ABSOLUTE_TIME_DEVIATION && + relativeDeviation > MIN_RELATIVE_DEVIATION_PERCENT + ) { + const sign = measuredTime >= baseTime ? '+' : '-'; + formattedTime += ` (${sign}${absoluteDeviation.toFixed( + 0 + )}ms, ${sign}${relativeDeviation.toFixed(1)}%)`; + if (relativeDeviation > RELATIVE_DEVIATION_PERCENT_FOR_COLORING) { + color = measuredTime >= baseTime ? red : green; + } + } + return color(formattedTime); +} + +/** + * @param {number} currentMemory + * @param {number} persistedMemory + * @return {string} + */ +function getFormattedMemory(currentMemory, persistedMemory = currentMemory) { + /** + * @type {function(string): string} + */ + let color = identity, + formattedMemory = prettyBytes(currentMemory); + const absoluteDeviation = Math.abs(currentMemory - persistedMemory); + const relativeDeviation = 100 * (absoluteDeviation / persistedMemory); + if (relativeDeviation > MIN_RELATIVE_DEVIATION_PERCENT) { + const sign = currentMemory >= persistedMemory ? '+' : '-'; + formattedMemory += ` (${sign}${relativeDeviation.toFixed(0)}%)`; + if (relativeDeviation > RELATIVE_DEVIATION_PERCENT_FOR_COLORING) { + color = currentMemory >= persistedMemory ? red : green; + } + } + return color(formattedMemory); +} + +/** + * @param {number} numberOfLines + */ +function clearLines(numberOfLines) { + console.info('\u001B[A' + '\u001B[2K\u001B[A'.repeat(numberOfLines)); +} + +/** + * @template T + * @param {T} x + * @returns {T} + */ +function identity(x) { + return x; +} diff --git a/scripts/perf-report/report-collector.js b/scripts/perf-report/report-collector.js new file mode 100644 index 00000000000..d9eb7eadc66 --- /dev/null +++ b/scripts/perf-report/report-collector.js @@ -0,0 +1,55 @@ +import { appendFile, writeFile } from 'node:fs/promises'; +import { fileURLToPath } from 'node:url'; + +export default new (class ReportCollector { + /** + * @type {string[]} + */ + #messageList = []; + #isRecording = false; + startRecord() { + this.#isRecording = true; + } + /** + * @param {string} message + */ + push(message) { + if (!this.#isRecording) return; + if (message.startsWith('# ')) { + message = message.replace(/^# /, '- '); + } else if (message.startsWith('## ')) { + message = message.replace(/^## /, ' - '); + } else if (message.startsWith('- ')) { + message = ' ' + message; + } else { + message = ' - ' + message; + } + this.#messageList.push(message); + } + outputMsg() { + if (process.env.CI) { + const result = `# Performance report +${removeAnsiStyles(this.#messageList.join('\n'))}`; + return Promise.all([ + writeFile(fileURLToPath(new URL('../../_benchmark/result.md', import.meta.url)), result), + process.env.GITHUB_STEP_SUMMARY && appendFile(process.env.GITHUB_STEP_SUMMARY, result) + ]); + } + } +})(); + +/** + * @param {string} text + * @returns {string} + */ +function removeAnsiStyles(text) { + const ansiRegex = new RegExp( + [ + '[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[a-zA-Z\\d]*)*)?\\u0007)', + '(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PRZcf-ntqry=><~]))' + ].join('|'), + 'g' + ); + + return text.replace(ansiRegex, ''); +} diff --git a/scripts/perf-report/rollup-artefacts.js b/scripts/perf-report/rollup-artefacts.js new file mode 100644 index 00000000000..5f3da1ddd84 --- /dev/null +++ b/scripts/perf-report/rollup-artefacts.js @@ -0,0 +1,2 @@ +export { rollup as previousRollup, VERSION as previousVersion } from 'rollup'; +export { rollup as newRollup } from '../../dist/rollup.js'; diff --git a/scripts/perf.js b/scripts/perf.js deleted file mode 100644 index 828c5f12b62..00000000000 --- a/scripts/perf.js +++ /dev/null @@ -1,195 +0,0 @@ -const path = require('path'); -const fs = require('fs'); -const rollup = require('../dist/rollup.js'); -const tc = require('turbocolor'); -const { loadPerfConfig, targetDir } = require('./load-perf-config'); -const prettyBytes = require('pretty-bytes'); - -const initialDir = process.cwd(); -const perfFile = path.resolve(targetDir, 'rollup.perf.json'); - -let numberOfRunsToAverage = 6; -let numberOfDiscardedResults = 3; -if (process.argv.length >= 3) { - numberOfRunsToAverage = Number.parseInt(process.argv[2]); - if (process.argv.length >= 4) { - numberOfDiscardedResults = Number.parseInt(process.argv[3]); - } -} -if (!(numberOfDiscardedResults >= 0) || !(numberOfDiscardedResults < numberOfRunsToAverage)) { - console.error( - `Invalid parameters: runs = ${numberOfRunsToAverage}, discarded = ${numberOfDiscardedResults}.\n` + - 'Usage: "npm run perf [ []]"\n' + - 'where 0 <= < ' - ); - process.exit(1); -} -console.info( - tc.bold( - `Calculating the average of ${tc.cyan(numberOfRunsToAverage)} runs discarding the ${tc.cyan( - numberOfDiscardedResults - )} largest results.\n` - ) + 'Run "npm run perf " to change that.' -); - -function getSingleAverage(times, runs, discarded) { - const actualDiscarded = Math.min(discarded, runs - 1); - return ( - times - .sort() - .reverse() - .slice(actualDiscarded) - .reduce((sum, time) => sum + time, 0) / - (runs - actualDiscarded) - ); -} - -function getAverage(accumulatedMeasurements, runs, discarded) { - const average = {}; - Object.keys(accumulatedMeasurements).forEach(label => { - average[label] = { - time: getSingleAverage( - accumulatedMeasurements[label].map(timing => timing[0]), - runs, - discarded - ), - memory: getSingleAverage( - accumulatedMeasurements[label].map(timing => timing[2]), - runs, - discarded - ) - }; - }); - return average; -} - -async function calculatePrintAndPersistTimings(config, existingTimings) { - const timings = await buildAndGetTimings(config); - Object.keys(timings).forEach(label => { - timings[label] = [timings[label]]; - }); - for (let currentRun = 1; currentRun < numberOfRunsToAverage; currentRun++) { - const numberOfLinesToClear = printMeasurements( - getAverage(timings, currentRun, numberOfDiscardedResults), - existingTimings, - /^#/ - ); - console.info(`Completed run ${currentRun}.`); - const currentTimings = await buildAndGetTimings(config); - clearLines(numberOfLinesToClear); - Object.keys(timings).forEach(label => { - if (!currentTimings.hasOwnProperty(label)) { - delete timings[label]; - } else { - timings[label].push(currentTimings[label]); - } - }); - } - const averageTimings = getAverage(timings, numberOfRunsToAverage, numberOfDiscardedResults); - printMeasurements(averageTimings, existingTimings); - if (Object.keys(existingTimings).length === 0) persistTimings(averageTimings); -} - -async function buildAndGetTimings(config) { - config.perf = true; - if (Array.isArray(config.output)) { - config.output = config.output[0]; - } - gc(); - process.chdir(targetDir); - const bundle = await rollup.rollup(config); - process.chdir(initialDir); - await bundle.generate(config.output); - return bundle.getTimings(); -} - -function printMeasurements(average, existingAverage, filter = /.*/) { - const printedLabels = Object.keys(average).filter(label => filter.test(label)); - console.info(''); - printedLabels.forEach(label => { - let color = text => text; - if (label[0] === '#') { - color = tc.bold; - if (label[1] !== '#') { - color = tc.underline; - } - } - console.info( - color( - `${label}: ${getFormattedTime( - average[label].time, - existingAverage[label] && existingAverage[label].time - )}, ${getFormattedMemory( - average[label].memory, - existingAverage[label] && existingAverage[label].memory - )}` - ) - ); - }); - return printedLabels.length + 2; -} - -function clearLines(numberOfLines) { - console.info('\33[A' + '\33[2K\33[A'.repeat(numberOfLines)); -} - -function getExistingTimings() { - try { - const timings = JSON.parse(fs.readFileSync(perfFile, 'utf8')); - console.info( - tc.bold(`Comparing with ${tc.cyan(perfFile)}. Delete this file to create a new base line.`) - ); - return timings; - } catch (e) { - return {}; - } -} - -function persistTimings(timings) { - try { - fs.writeFileSync(perfFile, JSON.stringify(timings, null, 2), 'utf8'); - console.info( - tc.bold(`Saving performance information to new reference file ${tc.cyan(perfFile)}.`) - ); - } catch (e) { - console.error(tc.bold(`Could not persist performance information in ${tc.cyan(perfFile)}.`)); - system.exit(1); - } -} - -const MIN_ABSOLUTE_TIME_DEVIATION = 10; -const RELATIVE_DEVIATION_FOR_COLORING = 5; - -function getFormattedTime(currentTime, persistedTime = currentTime) { - let color = text => text, - formattedTime = `${currentTime.toFixed(0)}ms`; - const absoluteDeviation = Math.abs(currentTime - persistedTime); - if (absoluteDeviation > MIN_ABSOLUTE_TIME_DEVIATION) { - const sign = currentTime >= persistedTime ? '+' : '-'; - const relativeDeviation = 100 * (absoluteDeviation / persistedTime); - formattedTime += ` (${sign}${absoluteDeviation.toFixed( - 0 - )}ms, ${sign}${relativeDeviation.toFixed(1)}%)`; - if (relativeDeviation > RELATIVE_DEVIATION_FOR_COLORING) { - color = currentTime >= persistedTime ? tc.red : tc.green; - } - } - return color(formattedTime); -} - -function getFormattedMemory(currentMemory, persistedMemory = currentMemory) { - let color = text => text, - formattedMemory = prettyBytes(currentMemory); - const absoluteDeviation = Math.abs(currentMemory - persistedMemory); - const sign = currentMemory >= persistedMemory ? '+' : '-'; - const relativeDeviation = 100 * (absoluteDeviation / persistedMemory); - if (relativeDeviation > RELATIVE_DEVIATION_FOR_COLORING) { - formattedMemory += ` (${sign}${relativeDeviation.toFixed(0)}%)`; - color = currentMemory >= persistedMemory ? tc.red : tc.green; - } - return color(formattedMemory); -} - -loadPerfConfig().then(async config => - calculatePrintAndPersistTimings(config, await getExistingTimings()) -); diff --git a/scripts/postpublish.js b/scripts/postpublish.js new file mode 100644 index 00000000000..ba817fbf2d4 --- /dev/null +++ b/scripts/postpublish.js @@ -0,0 +1,119 @@ +import GitHub from 'github-api'; +import { readFile } from 'node:fs/promises'; +import { env } from 'node:process'; +import semverPreRelease from 'semver/functions/prerelease.js'; +import { cyan } from './colors.js'; +import { runWithEcho } from './helpers.js'; +import { CHANGELOG, DOCUMENTATION_BRANCH } from './release-constants.js'; +import { + getCurrentCommitMessage, + getFirstChangelogEntry, + getGitTag, + getIncludedPRs +} from './release-helpers.js'; + +console.log( + `------------------------------------------------------------------------------- +This script will create the release in GitHub and post comments to all released +PRs and resolved issues. It is only run from CI. +-------------------------------------------------------------------------------` +); + +if (!(env.CI && env.ROLLUP_RELEASE && env.GITHUB_TOKEN)) { + throw new Error('This script is only intended to be run from CI.'); +} + +const gh = new GitHub({ token: env.GITHUB_TOKEN }); +const [newVersion, changelog, repo, issues] = await Promise.all([ + getCurrentCommitMessage(), + readFile(CHANGELOG, 'utf8'), + gh.getRepo('rollup', 'rollup'), + gh.getIssues('rollup', 'rollup') +]); + +const matched = /^\d+\.\d+\.\d+(-\d+)?$/.exec(newVersion); +if (!matched) { + throw new Error(`The last commit message "${newVersion}" does not contain a version.`); +} + +const isPreRelease = !!matched[1]; + +const firstEntry = getFirstChangelogEntry(changelog); +const [previousVersion, changelogEntry] = + firstEntry.currentVersion === newVersion + ? [firstEntry.previousVersion, firstEntry.text] + : [firstEntry.currentVersion, null]; +const includedPRs = await getIncludedPRs( + `v${previousVersion}`, + `v${newVersion}`, + repo, + null, + isPreRelease +); + +const gitTag = getGitTag(newVersion); +if (changelogEntry) { + await createReleaseNotes(changelogEntry, gitTag); +} +await postReleaseComments(includedPRs, issues, newVersion); + +if (!isPreRelease) { + await runWithEcho('git', ['branch', DOCUMENTATION_BRANCH, '--force', gitTag]); + await runWithEcho('git', ['push', '--force', 'origin', DOCUMENTATION_BRANCH]); +} + +/** + * @param {string} changelog + * @param {string} tag + * @return {Promise} + */ +function createReleaseNotes(changelog, tag) { + return repo.createRelease({ + body: changelog, + name: tag, + tag_name: tag + }); +} + +/** + * @param {import('./release-helpers.js').IncludedPR[]} includedPRs + * @param {import('github-api').Issues} issues + * @param {string} version + * @return {Promise} + */ +async function postReleaseComments(includedPRs, issues, version) { + const installNote = semverPreRelease(version) + ? `Note that this is a pre-release, so to test it, you need to install Rollup via \`npm install rollup@${version}\` or \`npm install rollup@beta\`. It will likely become part of a regular release later.` + : 'You can test it via `npm install rollup`.'; + + let caughtError = null; + + /** + * @param {number} issueNumber + * @param {string} comment + * @return {Promise} + */ + const addComment = (issueNumber, comment) => + // Add a small timeout to avoid rate limiting issues + new Promise(resolve => setTimeout(resolve, 500)).then(() => + issues + .createIssueComment(issueNumber, `${comment} as part of rollup@${version}. ${installNote}`) + .catch(error => { + console.error(error); + caughtError ||= error; + }) + ); + + for (const { pr, closed } of includedPRs) { + await addComment(pr, 'This PR has been released'); + console.log(cyan(`Added release comment to #${pr}.`)); + + for (const closedIssue of closed) { + await addComment(closedIssue, `This issue has been resolved via #${pr}`); + console.log(cyan(`Added fix comment to #${closedIssue} via #${pr}.`)); + } + } + if (caughtError) { + throw caughtError; + } +} diff --git a/scripts/prepare-release.js b/scripts/prepare-release.js new file mode 100755 index 00000000000..d3e1fa71b21 --- /dev/null +++ b/scripts/prepare-release.js @@ -0,0 +1,296 @@ +#!/usr/bin/env node + +import { select } from '@inquirer/prompts'; +import { readFile, writeFile } from 'node:fs/promises'; +import { chdir, exit } from 'node:process'; +import { fileURLToPath } from 'node:url'; +import semverInc from 'semver/functions/inc.js'; +import semverParse from 'semver/functions/parse.js'; +import semverPreRelease from 'semver/functions/prerelease.js'; +import { bold, cyan } from './colors.js'; +import { readJson, runAndGetStdout, runWithEcho } from './helpers.js'; +import { + BROWSER_PACKAGE, + CHANGELOG, + MAIN_BRANCH, + MAIN_LOCKFILE, + MAIN_PACKAGE +} from './release-constants.js'; +import { + getFirstChangelogEntry, + getGithubApi, + getGitTag, + getIncludedPRs +} from './release-helpers.js'; + +console.log( + `----------------------------------------------------------------------------- +This script will create a release tag for you and guide you through writing a +CHANGELOG entry for non-beta releases. The actual release will be performed +by GitHub Actions once this script completes successfully. +-----------------------------------------------------------------------------` +); + +// We execute everything from the main directory +chdir(fileURLToPath(new URL('..', import.meta.url))); + +const [gh, currentBranch] = await Promise.all([ + getGithubApi(), + runAndGetStdout('git', ['branch', '--show-current']), + runWithEcho('git', ['pull', '--ff-only']) +]); +const [mainPackage, mainLockFile, browserPackage, repo, changelog] = await Promise.all([ + readJson(MAIN_PACKAGE), + readJson(MAIN_LOCKFILE), + readJson(BROWSER_PACKAGE), + gh.getRepo('rollup', 'rollup'), + readFile(CHANGELOG, 'utf8') +]); +const isMainBranch = currentBranch === MAIN_BRANCH; +const includedPRs = await getIncludedPRs( + `v${getFirstChangelogEntry(changelog).currentVersion}`, + 'HEAD', + repo, + currentBranch, + !isMainBranch +); + +console.log(bold(`\nPreparing release for "${currentBranch}". Included PRs:`)); +console.log( + includedPRs + .map( + ({ text, pr, authors }) => + `https://github.com/rollup/rollup/pull/${pr}: ${text} (${authors.map(author => `@${author}`).join(', ')})` + ) + .join('\n') +); +console.log(); + +const newVersion = await getNewVersion(mainPackage, isMainBranch); + +const gitTag = getGitTag(newVersion); +try { + if (isMainBranch) { + await addStubChangelogEntry(newVersion, changelog, includedPRs); + } + await updatePackages(mainPackage, mainLockFile, browserPackage, newVersion); + await installDependenciesAndLint(); + if (isMainBranch) { + await waitForChangelogUpdate(newVersion); + } + await commitChanges(newVersion, gitTag, isMainBranch); +} catch (error) { + console.error( + `Error during release, rolling back changes: ${error instanceof Error ? error.message : error}` + ); + console.error('Run `git reset --hard` to roll back changes.'); + throw error; +} + +await pushChanges(gitTag); + +/** + * @param {Record} mainPackage + * @param {boolean} isMainBranch + * @return {Promise} + */ +async function getNewVersion(mainPackage, isMainBranch) { + const { version } = mainPackage; + /** + * @type {import('semver').ReleaseType[]} + */ + const availableIncrements = isMainBranch + ? ['patch', 'minor'] + : semverPreRelease(version) + ? ['prerelease'] + : ['premajor', 'preminor', 'prepatch']; + + return await select({ + choices: availableIncrements.map(increment => { + const value = /** @type {string} */ (semverInc(version, increment)); + return { + name: `${increment} (${value})`, + short: increment, + value + }; + }), + message: `Select type of release (currently "${version}" on branch "${currentBranch}"):` + }); +} + +/** + * @param {string} version + * @param {string} changelog + * @param {import('./release-helpers.js').IncludedPR[]} includedPRs + * @return {Promise} + */ +async function addStubChangelogEntry(version, changelog, includedPRs) { + const { currentVersion, index } = getFirstChangelogEntry(changelog); + if (currentVersion === version) { + console.error( + `Changelog entry for version "${version}" already exists. Please remove the entry and commit the change before trying again.` + ); + exit(1); + } + + await writeFile( + CHANGELOG, + changelog.slice(0, index) + + getNewLogEntry(version, includedPRs) + + '\n\n' + + changelog.slice(index) + ); + + console.log( + cyan(`A stub for the release notes was added to the beginning of "${CHANGELOG}". +Please edit this file to add useful information about bug fixes, features and +breaking changes in the release while the tests are running.`) + ); +} + +/** + * @param {string} version + * @param {import('./release-helpers.js').IncludedPR[]} prs + * @return {string} + */ +function getNewLogEntry(version, prs) { + if (prs.length === 0) { + throw new Error(`Release does not contain any PRs`); + } + const firstPr = prs[0].pr; + const date = new Date().toISOString().slice(0, 10); + const parsedVersion = semverParse(version); + if (!parsedVersion) { + throw new Error(`Could not parse version ${version}.`); + } + const { minor, patch } = parsedVersion; + let sections = getDummyLogSection('Bug Fixes', firstPr); + if (patch === 0) { + sections = getDummyLogSection('Features', firstPr) + sections; + if (minor === 0) { + sections = getDummyLogSection('Breaking Changes', firstPr) + sections; + } + } + return `## ${version} + +_${date}_ + +${sections}### Pull Requests + +${prs + .map( + ({ text, pr, authors }) => + `- [#${pr}](https://github.com/rollup/rollup/pull/${pr}): ${text} (${authors.map(author => `@${author}`).join(', ')})` + ) + .join('\n')}`; +} + +/** + * @param {string} headline + * @param {number} pr + * @return {string} + */ +function getDummyLogSection(headline, pr) { + return `### ${headline} + +- [replace me] (#${pr}) + +`; +} + +/** + * @return {Promise} + */ +async function installDependenciesAndLint() { + await runWithEcho('npm', ['ci', '--ignore-scripts']); + await runWithEcho('npm', ['run', 'check-audit']); + await runWithEcho('npm', ['run', 'ci:lint']); +} + +/** + * @param {string} version + * @return {Promise} + */ +async function waitForChangelogUpdate(version) { + let changelogEntry = ''; + while (true) { + await runWithEcho('npx', ['prettier', '--write', CHANGELOG]); + const changelog = await readFile(CHANGELOG, 'utf8'); + const { text: newEntry } = getFirstChangelogEntry(changelog); + if (newEntry === changelogEntry) { + console.log(cyan('No further changes, continuing release.')); + break; + } + changelogEntry = newEntry; + console.log(cyan('You generated the following changelog entry:\n') + changelogEntry); + await select({ + choices: ['ok'], + message: `Please edit the changelog or confirm the changelog is acceptable to continue to release "${version}".` + }); + } +} + +/** + * @param {Record} mainPackage + * @param {Record} mainLockFile + * @param {Record} browserPackage + * @param {string} newVersion + * @return {Promise[]>} + */ +function updatePackages(mainPackage, mainLockFile, browserPackage, newVersion) { + return Promise.all([ + writeFile(MAIN_PACKAGE, updatePackageVersionAndGetString(mainPackage, newVersion)), + writeFile(MAIN_LOCKFILE, updateLockFileVersionAndGetString(mainLockFile, newVersion)), + writeFile(BROWSER_PACKAGE, updatePackageVersionAndGetString(browserPackage, newVersion)) + ]); +} + +/** + * @param {Record} packageContent + * @param {string} version + * @return {string} + */ +function updatePackageVersionAndGetString(packageContent, version) { + packageContent.version = version; + return JSON.stringify(packageContent, null, 2) + '\n'; +} + +/** + * @param {Record} lockfileContent + * @param {string} version + * @return {string} + */ +function updateLockFileVersionAndGetString(lockfileContent, version) { + lockfileContent.version = version; + lockfileContent.packages[''].version = version; + return JSON.stringify(lockfileContent, null, 2) + '\n'; +} + +/** + * @param {string} newVersion + * @param {string} gitTag + * @param {boolean} isMainBranch + * @return {Promise} + */ +async function commitChanges(newVersion, gitTag, isMainBranch) { + await runWithEcho('git', [ + 'add', + MAIN_PACKAGE, + MAIN_LOCKFILE, + BROWSER_PACKAGE, + ...(isMainBranch ? [CHANGELOG] : []) + ]); + await runWithEcho('git', ['commit', '-m', newVersion]); + await runWithEcho('git', ['tag', gitTag]); +} + +/** + * @param {string} gitTag + * @return {Promise} + */ +function pushChanges(gitTag) { + return Promise.all([ + runWithEcho('git', ['push', 'origin', 'HEAD']), + runWithEcho('git', ['push', 'origin', gitTag]) + ]); +} diff --git a/scripts/prepublish.js b/scripts/prepublish.js new file mode 100755 index 00000000000..ef95f741f3c --- /dev/null +++ b/scripts/prepublish.js @@ -0,0 +1,65 @@ +#!/usr/bin/env node + +import { readFile, writeFile } from 'node:fs/promises'; +import path from 'node:path'; +import { chdir } from 'node:process'; +import { fileURLToPath } from 'node:url'; +import { readJson, runWithEcho } from './helpers.js'; +import publishWasmNodePackage from './publish-wasm-node-package.js'; +import { CHANGELOG, MAIN_PACKAGE } from './release-constants.js'; +import { getCurrentCommitMessage, getFirstChangelogEntry } from './release-helpers.js'; + +// We execute everything from the main directory +chdir(fileURLToPath(new URL('..', import.meta.url))); + +const version = await getCurrentCommitMessage(); +const matched = /^\d+\.\d+\.\d+(-\d+)?$/.exec(version); + +if (!matched) { + throw new Error( + `The commit message "${version}" does not satisfy the patterns 0.0.0 or 0.0.0-0.` + ); +} +const isPreRelease = !!matched[1]; +await verifyChangelog(isPreRelease); + +await runWithEcho('npm', ['publish'], { cwd: path.resolve('browser') }); +await publishWasmNodePackage(); + +const { optionalDependencies } = await readJson(MAIN_PACKAGE); +await runWithEcho('npm', ['run', 'prepublish:napi']); +const mainPackage = await readJson(MAIN_PACKAGE); +await writeFile( + MAIN_PACKAGE, + JSON.stringify( + { + ...mainPackage, + optionalDependencies: { ...optionalDependencies, ...mainPackage.optionalDependencies } + }, + null, + 2 + ) +); + +/** + * @param {boolean} isPreRelease + * @return {Promise} + */ +async function verifyChangelog(isPreRelease) { + const changelog = await readFile(CHANGELOG, 'utf8'); + const { currentVersion, text } = getFirstChangelogEntry(changelog); + if (currentVersion !== version) { + if (isPreRelease) { + console.log( + `There is no changelog entry for version "${version}", the last entry is for version "${currentVersion}". This is OK for a pre-release.` + ); + return; + } + throw new Error( + `There is no changelog entry for version "${version}", the last entry is for version "${currentVersion}".` + ); + } + if (text.includes('[replace me]')) { + throw new Error(`The changelog entry must not contain placeholders. The text was:\n${text}`); + } +} diff --git a/scripts/publish-wasm-node-package.js b/scripts/publish-wasm-node-package.js new file mode 100644 index 00000000000..a2af6433188 --- /dev/null +++ b/scripts/publish-wasm-node-package.js @@ -0,0 +1,55 @@ +import { cp, mkdir, readFile, writeFile } from 'node:fs/promises'; +import path from 'node:path'; +import { fileURLToPath } from 'node:url'; +import { readJson, runWithEcho } from './helpers.js'; +import { MAIN_PACKAGE } from './release-constants.js'; + +const WASM_NODE_PACKAGE_INFO = { + description: 'Next-generation ES module bundler with Node wasm', + name: '@rollup/wasm-node' +}; +const COPIED_FILES_OR_DIRS = ['LICENSE.md', 'dist']; +const PACKAGE_DIR = fileURLToPath(new URL('../wasm-node-package', import.meta.url)); + +/** + * @param {string[]} pathSegments + * @return {string} + */ +function getOutputPath(...pathSegments) { + return path.resolve(PACKAGE_DIR, ...pathSegments); +} + +export default async function publishWasmNodePackage() { + await mkdir(PACKAGE_DIR); + + const mainPackage = await readJson(MAIN_PACKAGE); + mainPackage.files.unshift('dist/wasm-node/*.wasm'); + delete mainPackage.napi; + delete mainPackage.scripts; + + await Promise.all([ + ...COPIED_FILES_OR_DIRS.map(file => cp(file, getOutputPath(file), { recursive: true })), + writeFile( + getOutputPath('package.json'), + JSON.stringify( + { + ...mainPackage, + ...WASM_NODE_PACKAGE_INFO + }, + undefined, + 2 + ) + ) + ]); + + const nativeJsContent = await readFile(new URL('../native.wasm.js', import.meta.url), 'utf8'); + + await Promise.all([ + writeFile(getOutputPath('dist', 'native.js'), nativeJsContent.trimStart()), + cp('artifacts/bindings-wasm-node/wasm-node', getOutputPath('dist', 'wasm-node'), { + recursive: true + }) + ]); + + await runWithEcho('npm', ['publish'], { cwd: path.resolve(PACKAGE_DIR) }); +} diff --git a/scripts/release-constants.js b/scripts/release-constants.js new file mode 100644 index 00000000000..869fbf965a6 --- /dev/null +++ b/scripts/release-constants.js @@ -0,0 +1,6 @@ +export const MAIN_BRANCH = 'master'; +export const MAIN_PACKAGE = 'package.json'; +export const MAIN_LOCKFILE = 'package-lock.json'; +export const BROWSER_PACKAGE = 'browser/package.json'; +export const CHANGELOG = 'CHANGELOG.md'; +export const DOCUMENTATION_BRANCH = 'documentation-published'; diff --git a/scripts/release-helpers.js b/scripts/release-helpers.js new file mode 100644 index 00000000000..d4636a3504a --- /dev/null +++ b/scripts/release-helpers.js @@ -0,0 +1,134 @@ +import GitHub from 'github-api'; +import { readFile } from 'node:fs/promises'; +import { exit } from 'node:process'; +import { runAndGetStdout } from './helpers.js'; + +/** + * @param {string} changelog + * @returns {{ currentVersion: string, index: number, previousVersion: string, text: string }} + */ +export function getFirstChangelogEntry(changelog) { + const match = changelog.match( + /(?## (?\d+\.\d+\.\d+(-\d+)?)[\S\s]*?)\n+## (?\d+\.\d+\.\d+)/ + ); + if (!match || !match.groups || typeof match.index !== 'number') { + throw new Error('Could not detect any changelog entry.'); + } + const { + groups: { text, currentVersion, previousVersion }, + index + } = match; + return { currentVersion, index, previousVersion, text }; +} + +/** + * @typedef {object} IncludedPR + * @property {string[]} authors + * @property {number[]} closed - which PRs are closed by this + * @property {number} pr + * @property {string} text + */ + +/** + * @param {string} fromVersion + * @param {string} toVersion + * @param {import('github-api').Repo} repo + * @param {string|null} currentBranch We only have a branch when locally prepare a release, otherwise we use the sha to find the PR + * @param {boolean} isPreRelease + * @returns {Promise} + */ +export async function getIncludedPRs(fromVersion, toVersion, repo, currentBranch, isPreRelease) { + const [commits, commitSha] = await Promise.all([ + runAndGetStdout('git', [ + '--no-pager', + 'log', + `${fromVersion}..${toVersion}`, + '--pretty=tformat:%s' + ]), + runAndGetStdout('git', ['rev-parse', toVersion]) + ]); + const getPrRegExp = /^(.+)\s\(#(\d+)\)$/gm; + const prs = []; + let match; + while ((match = getPrRegExp.exec(commits))) { + prs.push({ pr: Number(match[2]), text: match[1].split('\n')[0] }); + } + + if (isPreRelease) { + const { data: basePrs } = await repo.listPullRequests({ + state: 'open', + ...(currentBranch ? { head: `rollup:${currentBranch}` } : {}) + }); + for (const { + number, + title, + head: { sha } + } of basePrs) { + if (currentBranch || sha === commitSha) { + prs.push({ pr: number, text: title }); + } + } + } + prs.sort((a, b) => (a.pr > b.pr ? 1 : -1)); + return Promise.all( + prs.map(async ({ pr, text }) => { + const [{ data: pullRequest }, { data: commits }] = await Promise.all([ + repo.getPullRequest(pr), + repo.listCommitsOnPR(pr) + ]); + const mainAuthor = pullRequest.user.login; + const otherAuthors = new Set( + commits.map(({ author, commit }) => author?.login || commit.author.name) + ); + otherAuthors.delete(mainAuthor); + const bodyWithoutComments = pullRequest.body.replace(//g, ''); + const closedIssuesRegexp = /([Ff]ix(es|ed)?|([Cc]lose|[Rr]esolve)[ds]?) #(\d+)/g; + const closed = []; + while ((match = closedIssuesRegexp.exec(bodyWithoutComments))) { + closed.push(Number(match[4])); + } + return { + authors: [mainAuthor, ...otherAuthors], + closed, + pr, + text + }; + }) + ); +} + +/** + * @return {Promise} + */ +export async function getGithubApi() { + const GITHUB_TOKEN = '.github_token'; + try { + const token = (await readFile(GITHUB_TOKEN, 'utf8')).trim(); + return new GitHub({ token }); + } catch (error) { + if (error instanceof Error && 'code' in error && error.code === 'ENOENT') { + console.error( + `Could not find GitHub token file. Please create "${GITHUB_TOKEN}" containing a token with the following permissions: +- public_repo` + ); + exit(1); + } else { + throw error; + } + } +} + +/** + * @param {string} version + * @return {string} + */ +export function getGitTag(version) { + return `v${version}`; +} + +/** + * @return {Promise} + */ +export function getCurrentCommitMessage() { + return runAndGetStdout('git', ['--no-pager', 'log', '-1', '--pretty=%B']); +} diff --git a/scripts/test-options.js b/scripts/test-options.js new file mode 100644 index 00000000000..f4fe9e1a591 --- /dev/null +++ b/scripts/test-options.js @@ -0,0 +1,73 @@ +import { readFile } from 'node:fs/promises'; +import { exit } from 'node:process'; + +const [optionsText, helpText] = await Promise.all([ + readFile(new URL('../docs/configuration-options/index.md', import.meta.url), 'utf8'), + readFile(new URL('../cli/help.md', import.meta.url), 'utf8') +]); + +const optionSections = optionsText.split('\n## '); +let searchedOptions = ''; +for (const section of optionSections.slice(1)) { + if (!(section.startsWith('Experimental') || section.startsWith('Deprecated'))) { + searchedOptions += section; + } +} + +const findCliOptionRegExp = /CLI: (`(-(\w)[^`]*)`\/)?`(--([\w.]+)[^`]*)`/g; + +const allCliOptions = []; +let match; + +while ((match = findCliOptionRegExp.exec(searchedOptions)) !== null) { + allCliOptions.push({ long: match[5], short: match[3] }); +} + +const findOptionInHelpRegExp = /^(-(\w), )?--(no-)?([\w.]+)/gm; + +const cliOptionsInHelp = new Map(); + +while ((match = findOptionInHelpRegExp.exec(helpText)) !== null) { + cliOptionsInHelp.set(match[4], match[2]); +} + +let failed = false; + +for (const { long, short } of allCliOptions) { + if (!cliOptionsInHelp.has(long)) { + failed = true; + console.error(`Could find neither --${long} nor --no-${long} in help.md.`); + } + const optionInHelp = cliOptionsInHelp.get(long); + if (short !== optionInHelp) { + failed = true; + console.error( + `Inconsistent option with shortcut. Expected -${short}/--${long}, got -${optionInHelp.short}/--${optionInHelp.long}.` + ); + } +} + +if (failed) { + exit(1); +} + +let current = null; +for (const [long, short] of cliOptionsInHelp) { + if (!short) { + if (current && long < current) { + console.error( + `Options in help.md are not sorted properly. "${long}" should occur before "${current}".` + ); + exit(1); + } + current = long; + } +} + +const splitHelpText = helpText.split('\n'); +for (const line of splitHelpText) { + if (line.length > 80) { + console.error(`The following line in help.md exceeds the limit of 80 characters:\n${line}`); + exit(1); + } +} diff --git a/scripts/test-package.js b/scripts/test-package.js index 4368d20ad8e..afb6adc6102 100644 --- a/scripts/test-package.js +++ b/scripts/test-package.js @@ -1,16 +1,14 @@ -const pkg = require('../package.json'); +import { readFile } from 'node:fs/promises'; -function checkChokidar() { - const chokidarPkg = require('../node_modules/chokidar/package.json'); - const chokidarFsevents = - chokidarPkg.dependencies.fsevents || chokidarPkg.optionalDependencies.fsevents; - if (!chokidarFsevents) return; - const pkgFsevents = pkg.optionalDependencies.fsevents; - if (chokidarFsevents !== pkgFsevents) { - throw new Error( - `The dependency "fsevents" should exist with the same version range "${chokidarFsevents}" as it has for chokidar but it has "${pkgFsevents}".` - ); - } +const package_ = JSON.parse(await readFile(new URL('../package.json', import.meta.url), 'utf8')); +const chokidarPackage = JSON.parse( + await readFile(new URL('../node_modules/chokidar/package.json', import.meta.url), 'utf8') +); +const chokidarFsevents = + chokidarPackage.dependencies.fsevents || chokidarPackage.optionalDependencies.fsevents; +const packageFsevents = package_.optionalDependencies.fsevents; +if (chokidarFsevents !== packageFsevents) { + throw new Error( + `The dependency "fsevents" should exist with the same version range "${chokidarFsevents}" as it has for chokidar but it has "${packageFsevents}".` + ); } - -checkChokidar(); diff --git a/scripts/tsconfig.json b/scripts/tsconfig.json new file mode 100644 index 00000000000..efa9d3882e6 --- /dev/null +++ b/scripts/tsconfig.json @@ -0,0 +1,15 @@ +{ + "compilerOptions": { + "checkJs": true, + "allowJs": true, + "forceConsistentCasingInFileNames": true, + "module": "NodeNext", + "moduleResolution": "NodeNext", + "noEmit": true, + "noUnusedParameters": true, + "lib": ["ESNext"], + "strict": true, + "target": "ESNext", + "types": ["node"] + } +} diff --git a/scripts/update-snapshots.js b/scripts/update-snapshots.js index 9e7ac2571ee..a12180914f3 100755 --- a/scripts/update-snapshots.js +++ b/scripts/update-snapshots.js @@ -1,39 +1,41 @@ #!/usr/bin/env node -const { readdirSync, copydirSync, copyFileSync, rimrafSync } = require('sander'); -const { resolve, join } = require('path'); +import fs from 'fs-extra'; +import { readdirSync } from 'node:fs'; +import path from 'node:path'; +import { fileURLToPath } from 'node:url'; -const basePath = resolve(__dirname, '../test'); +const basePath = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../test'); -const formPath = join(basePath, 'form/samples'); -const formDirsToHandle = readdirSync(formPath); -for (const dir of formDirsToHandle) { - const testPath = join(formPath, dir); +const formPath = path.join(basePath, 'form/samples'); +const formDirectoriesToHandle = readdirSync(formPath); +for (const directory of formDirectoriesToHandle) { + const testPath = path.join(formPath, directory); const testFiles = readdirSync(testPath); if (!testFiles.includes('_config.js')) { - formDirsToHandle.push(...testFiles.map(filename => join(dir, filename))); + formDirectoriesToHandle.push(...testFiles.map(filename => path.join(directory, filename))); } else if (testFiles.includes('_actual')) { - const expectedPath = join(testPath, '_expected'); - rimrafSync(expectedPath); - copydirSync(join(testPath, '_actual')).to(expectedPath); + const expectedPath = path.join(testPath, '_expected'); + fs.removeSync(expectedPath); + fs.copySync(path.join(testPath, '_actual'), expectedPath); } else if (testFiles.includes('_actual.js')) { - copyFileSync(join(testPath, '_actual.js')).to(join(testPath, '_expected.js')); + fs.copySync(path.join(testPath, '_actual.js'), path.join(testPath, '_expected.js')); } else { throw new Error(`Could not find test output in ${testPath}`); } } -const chunkingPath = join(basePath, 'chunking-form/samples'); -const chunkingDirsToHandle = readdirSync(chunkingPath); -for (const dir of chunkingDirsToHandle) { - const testPath = join(chunkingPath, dir); +const chunkingPath = path.join(basePath, 'chunking-form/samples'); +const chunkingDirectoriesToHandle = readdirSync(chunkingPath); +for (const directory of chunkingDirectoriesToHandle) { + const testPath = path.join(chunkingPath, directory); const testFiles = readdirSync(testPath); if (!testFiles.includes('_config.js')) { - chunkingDirsToHandle.push(...testFiles.map(filename => join(dir, filename))); + chunkingDirectoriesToHandle.push(...testFiles.map(filename => path.join(directory, filename))); } else if (testFiles.includes('_actual')) { - const expectedPath = join(testPath, '_expected'); - rimrafSync(expectedPath); - copydirSync(join(testPath, '_actual')).to(expectedPath); + const expectedPath = path.join(testPath, '_expected'); + fs.removeSync(expectedPath); + fs.copySync(path.join(testPath, '_actual'), expectedPath); } else { throw new Error(`Could not find test output in ${testPath}`); } diff --git a/src/Bundle.ts b/src/Bundle.ts index 65f97532c52..64f8245443f 100644 --- a/src/Bundle.ts +++ b/src/Bundle.ts @@ -1,38 +1,50 @@ import Chunk from './Chunk'; +import ExternalChunk from './ExternalChunk'; import ExternalModule from './ExternalModule'; -import Graph from './Graph'; +import type Graph from './Graph'; import Module from './Module'; -import { +import type { GetManualChunk, + LogHandler, NormalizedInputOptions, NormalizedOutputOptions, - OutputBundle, - OutputBundleWithPlaceholders, - OutputChunk, - WarningHandler + OutputBundle } from './rollup/types'; -import { Addons, createAddons } from './utils/addons'; import { getChunkAssignments } from './utils/chunkAssignment'; import commondir from './utils/commondir'; +import { sortByExecutionOrder } from './utils/executionOrder'; +import { getGenerateCodeSnippets } from './utils/generateCodeSnippets'; +import type { HashPlaceholderGenerator } from './utils/hashPlaceholders'; +import { getHashPlaceholderGenerator } from './utils/hashPlaceholders'; +import { LOGLEVEL_WARN } from './utils/logging'; import { - errCannotAssignModuleToChunk, - errChunkInvalid, error, - warnDeprecation -} from './utils/error'; -import { sortByExecutionOrder } from './utils/executionOrder'; -import { FILE_PLACEHOLDER } from './utils/FileEmitter'; -import { basename, isAbsolute } from './utils/path'; -import { PluginDriver } from './utils/PluginDriver'; + logCannotAssignModuleToChunk, + logChunkInvalid, + logCircularChunk, + logInvalidOption +} from './utils/logs'; +import type { OutputBundleWithPlaceholders } from './utils/outputBundle'; +import { getOutputBundle, removeUnreferencedAssets } from './utils/outputBundle'; +import { parseAst } from './utils/parseAst'; +import { isAbsolute } from './utils/path'; +import type { PluginDriver } from './utils/PluginDriver'; +import { renderChunks } from './utils/renderChunks'; import { timeEnd, timeStart } from './utils/timers'; +import { + URL_OUTPUT_AMD_ID, + URL_OUTPUT_DIR, + URL_OUTPUT_FORMAT, + URL_OUTPUT_SOURCEMAPFILE +} from './utils/urls'; export default class Bundle { - private facadeChunkByModule = new Map(); - private includedNamespaces = new Set(); + private readonly facadeChunkByModule = new Map(); + private readonly includedNamespaces = new Set(); constructor( private readonly outputOptions: NormalizedOutputOptions, - private readonly unsetOptions: Set, + private readonly unsetOptions: ReadonlySet, private readonly inputOptions: NormalizedInputOptions, private readonly pluginDriver: PluginDriver, private readonly graph: Graph @@ -40,36 +52,47 @@ export default class Bundle { async generate(isWrite: boolean): Promise { timeStart('GENERATE', 1); - const outputBundle: OutputBundleWithPlaceholders = Object.create(null); - this.pluginDriver.setOutputBundle( - outputBundle, - this.outputOptions.assetFileNames, - this.facadeChunkByModule - ); + const outputBundleBase: OutputBundle = Object.create(null); + const outputBundle = getOutputBundle(outputBundleBase); + this.pluginDriver.setOutputBundle(outputBundle, this.outputOptions); + try { + timeStart('initialize render', 2); + await this.pluginDriver.hookParallel('renderStart', [this.outputOptions, this.inputOptions]); + timeEnd('initialize render', 2); timeStart('generate chunks', 2); - const chunks = await this.generateChunks(); + + const getHashPlaceholder = getHashPlaceholderGenerator(); + const chunks = await this.generateChunks(outputBundle, getHashPlaceholder); if (chunks.length > 1) { - validateOptionsForMultiChunkOutput(this.outputOptions, this.inputOptions.onwarn); + validateOptionsForMultiChunkOutput(this.outputOptions, this.inputOptions.onLog); + } + this.pluginDriver.setChunkInformation(this.facadeChunkByModule); + for (const chunk of chunks) { + chunk.generateExports(); + chunk.inlineTransitiveImports(); } - const inputBase = commondir(getAbsoluteEntryModulePaths(chunks)); + timeEnd('generate chunks', 2); - timeStart('render modules', 2); + await renderChunks( + chunks, + outputBundle, + this.pluginDriver, + this.outputOptions, + this.inputOptions.onLog + ); + } catch (error_: any) { + await this.pluginDriver.hookParallel('renderError', [error_]); + throw error_; + } - // We need to create addons before prerender because at the moment, there - // can be no async code between prerender and render due to internal state - const addons = await createAddons(this.outputOptions, this.pluginDriver); - this.prerenderChunks(chunks, inputBase); - timeEnd('render modules', 2); + removeUnreferencedAssets(outputBundle); + + timeStart('generate bundle', 2); - await this.addFinalizedChunksToBundle(chunks, inputBase, addons, outputBundle); - } catch (error) { - await this.pluginDriver.hookParallel('renderError', [error]); - throw error; - } await this.pluginDriver.hookSeq('generateBundle', [ this.outputOptions, outputBundle as OutputBundle, @@ -77,36 +100,19 @@ export default class Bundle { ]); this.finaliseAssets(outputBundle); + timeEnd('generate bundle', 2); timeEnd('GENERATE', 1); - return outputBundle as OutputBundle; - } - - private async addFinalizedChunksToBundle( - chunks: Chunk[], - inputBase: string, - addons: Addons, - outputBundle: OutputBundleWithPlaceholders - ): Promise { - this.assignChunkIds(chunks, inputBase, addons, outputBundle); - for (const chunk of chunks) { - outputBundle[chunk.id!] = chunk.getChunkInfoWithFileNames() as OutputChunk; - } - await Promise.all( - chunks.map(async chunk => { - const outputChunk = outputBundle[chunk.id!] as OutputChunk; - Object.assign(outputChunk, await chunk.render(this.outputOptions, addons, outputChunk)); - }) - ); + return outputBundleBase; } private async addManualChunks( - manualChunks: Record + manualChunks: Record ): Promise> { const manualChunkAliasByEntry = new Map(); const chunkEntries = await Promise.all( - Object.keys(manualChunks).map(async alias => ({ + Object.entries(manualChunks).map(async ([alias, files]) => ({ alias, - entries: await this.graph.moduleLoader.addAdditionalModules(manualChunks[alias]) + entries: await this.graph.moduleLoader.addAdditionalModules(files, true) })) ); for (const { alias, entries } of chunkEntries) { @@ -117,40 +123,6 @@ export default class Bundle { return manualChunkAliasByEntry; } - private assignChunkIds( - chunks: Chunk[], - inputBase: string, - addons: Addons, - bundle: OutputBundleWithPlaceholders - ) { - const entryChunks: Chunk[] = []; - const otherChunks: Chunk[] = []; - for (const chunk of chunks) { - (chunk.facadeModule && chunk.facadeModule.isUserDefinedEntryPoint - ? entryChunks - : otherChunks - ).push(chunk); - } - - // make sure entry chunk names take precedence with regard to deconflicting - const chunksForNaming: Chunk[] = entryChunks.concat(otherChunks); - for (const chunk of chunksForNaming) { - if (this.outputOptions.file) { - chunk.id = basename(this.outputOptions.file); - } else if (this.outputOptions.preserveModules) { - chunk.id = chunk.generateIdPreserveModules( - inputBase, - this.outputOptions, - bundle, - this.unsetOptions - ); - } else { - chunk.id = chunk.generateId(addons, this.outputOptions, bundle, true); - } - bundle[chunk.id] = FILE_PLACEHOLDER; - } - } - private assignManualChunks(getManualChunk: GetManualChunk): Map { const manualChunkAliasByEntry = new Map(); const manualChunksApi = { @@ -168,47 +140,60 @@ export default class Bundle { return manualChunkAliasByEntry; } - private finaliseAssets(outputBundle: OutputBundleWithPlaceholders): void { - for (const key of Object.keys(outputBundle)) { - const file = outputBundle[key] as any; - if (!file.type) { - warnDeprecation( - 'A plugin is directly adding properties to the bundle object in the "generateBundle" hook. This is deprecated and will be removed in a future Rollup version, please use "this.emitFile" instead.', - true, - this.inputOptions - ); - file.type = 'asset'; - } - if (this.outputOptions.validate && typeof file.code == 'string') { - try { - this.graph.contextParse(file.code, { - allowHashBang: true, - ecmaVersion: 'latest' - }); - } catch (exception) { - this.inputOptions.onwarn(errChunkInvalid(file, exception)); + private finaliseAssets(bundle: OutputBundleWithPlaceholders): void { + if (this.outputOptions.validate) { + for (const file of Object.values(bundle)) { + if ('code' in file) { + try { + parseAst(file.code, { jsx: this.inputOptions.jsx !== false }); + } catch (error_: any) { + this.inputOptions.onLog(LOGLEVEL_WARN, logChunkInvalid(file, error_)); + } } } } this.pluginDriver.finaliseAssets(); } - private async generateChunks(): Promise { - const { manualChunks } = this.outputOptions; + private async generateChunks( + bundle: OutputBundleWithPlaceholders, + getHashPlaceholder: HashPlaceholderGenerator + ): Promise { + const { + experimentalMinChunkSize, + inlineDynamicImports, + manualChunks, + preserveModules, + onlyExplicitManualChunks + } = this.outputOptions; const manualChunkAliasByEntry = typeof manualChunks === 'object' ? await this.addManualChunks(manualChunks) : this.assignManualChunks(manualChunks); - const chunks: Chunk[] = []; + const snippets = getGenerateCodeSnippets(this.outputOptions); + const includedModules = getIncludedModules(this.graph.modulesById); + const inputBase = commondir(getAbsoluteEntryModulePaths(includedModules, preserveModules)); + const externalChunkByModule = getExternalChunkByModule( + this.graph.modulesById, + this.outputOptions, + inputBase + ); + const executableModule = inlineDynamicImports + ? [{ alias: null, modules: includedModules }] + : preserveModules + ? includedModules.map(module => ({ alias: null, modules: [module] })) + : getChunkAssignments( + this.graph.entryModules, + manualChunkAliasByEntry, + experimentalMinChunkSize, + this.inputOptions.onLog, + typeof manualChunks === 'function', + onlyExplicitManualChunks + ); + const chunks: Chunk[] = new Array(executableModule.length); const chunkByModule = new Map(); - for (const { alias, modules } of this.outputOptions.inlineDynamicImports - ? [{ alias: null, modules: getIncludedModules(this.graph.modulesById) }] - : this.outputOptions.preserveModules - ? getIncludedModules(this.graph.modulesById).map(module => ({ - alias: null, - modules: [module] - })) - : getChunkAssignments(this.graph.entryModules, manualChunkAliasByEntry)) { + let index = 0; + for (const { alias, modules } of executableModule) { sortByExecutionOrder(modules); const chunk = new Chunk( modules, @@ -218,18 +203,25 @@ export default class Bundle { this.pluginDriver, this.graph.modulesById, chunkByModule, + externalChunkByModule, this.facadeChunkByModule, this.includedNamespaces, - alias + alias, + getHashPlaceholder, + bundle, + inputBase, + snippets ); - chunks.push(chunk); - for (const module of modules) { - chunkByModule.set(module, chunk); - } + chunks[index++] = chunk; } for (const chunk of chunks) { chunk.link(); } + + if (!inlineDynamicImports && !preserveModules) { + this.checkCircularChunks(chunks); + } + const facades: Chunk[] = []; for (const chunk of chunks) { facades.push(...chunk.generateFacades()); @@ -237,73 +229,136 @@ export default class Bundle { return [...chunks, ...facades]; } - private prerenderChunks(chunks: Chunk[], inputBase: string): void { - for (const chunk of chunks) { - chunk.generateExports(); - } - for (const chunk of chunks) { - chunk.preRender(this.outputOptions, inputBase); - } - } -} + private checkCircularChunks(chunks: Chunk[]): void { + const visited = new Set(); + const parents = new Map(); -function getAbsoluteEntryModulePaths(chunks: Chunk[]): string[] { - const absoluteEntryModulePaths: string[] = []; - for (const chunk of chunks) { - for (const entryModule of chunk.entryModules) { - if (isAbsolute(entryModule.id)) { - absoluteEntryModulePaths.push(entryModule.id); + const handleDependency = (chunk: Chunk, parent: Chunk): void => { + if (parents.has(chunk)) { + if (!visited.has(chunk)) { + const path = [chunk.getChunkName()]; + let isManualChunkConflict = chunk.isManualChunk; + let nextChunk: Chunk | undefined = parent; + while (nextChunk !== chunk && nextChunk) { + path.push(nextChunk.getChunkName()); + isManualChunkConflict &&= nextChunk.isManualChunk; + nextChunk = parents.get(nextChunk); + } + path.push(path[0]); + path.reverse(); + this.inputOptions.onLog(LOGLEVEL_WARN, logCircularChunk(path, isManualChunkConflict)); + } + return; + } + parents.set(chunk, parent); + analyseChunk(chunk); + }; + + const analyseChunk = (chunk: Chunk): void => { + for (const dependency of chunk.dependencies) { + if (dependency instanceof Chunk) { + handleDependency(dependency, chunk); + } + } + visited.add(chunk); + }; + + for (const chunk of chunks) { + if (!parents.has(chunk)) { + analyseChunk(chunk); } } } - return absoluteEntryModulePaths; } function validateOptionsForMultiChunkOutput( outputOptions: NormalizedOutputOptions, - onWarn: WarningHandler + log: LogHandler ) { if (outputOptions.format === 'umd' || outputOptions.format === 'iife') - return error({ - code: 'INVALID_OPTION', - message: 'UMD and IIFE output formats are not supported for code-splitting builds.' - }); + return error( + logInvalidOption( + 'output.format', + URL_OUTPUT_FORMAT, + 'UMD and IIFE output formats are not supported for code-splitting builds', + outputOptions.format + ) + ); if (typeof outputOptions.file === 'string') - return error({ - code: 'INVALID_OPTION', - message: - 'When building multiple chunks, the "output.dir" option must be used, not "output.file". ' + - 'To inline dynamic imports, set the "inlineDynamicImports" option.' - }); + return error( + logInvalidOption( + 'output.file', + URL_OUTPUT_DIR, + 'when building multiple chunks, the "output.dir" option must be used, not "output.file". To inline dynamic imports, set the "inlineDynamicImports" option' + ) + ); if (outputOptions.sourcemapFile) - return error({ - code: 'INVALID_OPTION', - message: '"output.sourcemapFile" is only supported for single-file builds.' - }); + return error( + logInvalidOption( + 'output.sourcemapFile', + URL_OUTPUT_SOURCEMAPFILE, + '"output.sourcemapFile" is only supported for single-file builds' + ) + ); if (!outputOptions.amd.autoId && outputOptions.amd.id) - onWarn({ - code: 'INVALID_OPTION', - message: - '"output.amd.id" is only properly supported for single-file builds. Use "output.amd.autoId" and "output.amd.basePath".' - }); + log( + LOGLEVEL_WARN, + logInvalidOption( + 'output.amd.id', + URL_OUTPUT_AMD_ID, + 'this option is only properly supported for single-file builds. Use "output.amd.autoId" and "output.amd.basePath" instead' + ) + ); } -function getIncludedModules(modulesById: Map): Module[] { - return [...modulesById.values()].filter( - module => +function getIncludedModules(modulesById: ReadonlyMap): Module[] { + const includedModules: Module[] = []; + for (const module of modulesById.values()) { + if ( module instanceof Module && (module.isIncluded() || module.info.isEntry || module.includedDynamicImporters.length > 0) - ) as Module[]; + ) { + includedModules.push(module); + } + } + return includedModules; +} + +function getAbsoluteEntryModulePaths( + includedModules: readonly Module[], + preserveModules: boolean +): string[] { + const absoluteEntryModulePaths: string[] = []; + for (const module of includedModules) { + if ((module.info.isEntry || preserveModules) && isAbsolute(module.id)) { + absoluteEntryModulePaths.push(module.id); + } + } + return absoluteEntryModulePaths; +} + +function getExternalChunkByModule( + modulesById: ReadonlyMap, + outputOptions: NormalizedOutputOptions, + inputBase: string +): Map { + const externalChunkByModule = new Map(); + for (const module of modulesById.values()) { + if (module instanceof ExternalModule) { + externalChunkByModule.set(module, new ExternalChunk(module, outputOptions, inputBase)); + } + } + return externalChunkByModule; } function addModuleToManualChunk( alias: string, module: Module, manualChunkAliasByEntry: Map -) { +): void { const existingAlias = manualChunkAliasByEntry.get(module); if (typeof existingAlias === 'string' && existingAlias !== alias) { - return error(errCannotAssignModuleToChunk(module.id, alias, existingAlias)); + return error(logCannotAssignModuleToChunk(module.id, alias, existingAlias)); } manualChunkAliasByEntry.set(module, alias); } diff --git a/src/Chunk.ts b/src/Chunk.ts index 0d79ffb1811..f1899a25b7e 100644 --- a/src/Chunk.ts +++ b/src/Chunk.ts @@ -1,74 +1,106 @@ -import MagicString, { Bundle as MagicStringBundle, SourceMap } from 'magic-string'; -import { relative } from '../browser/path'; +import MagicString, { Bundle as MagicStringBundle, type SourceMap } from 'magic-string'; +import { relative } from '../browser/src/path'; import ExportDefaultDeclaration from './ast/nodes/ExportDefaultDeclaration'; import FunctionDeclaration from './ast/nodes/FunctionDeclaration'; -import ChildScope from './ast/scopes/ChildScope'; -import { UNDEFINED_EXPRESSION } from './ast/values'; +import type ImportExpression from './ast/nodes/ImportExpression'; +import { formatsMaybeAccessDocumentCurrentScript } from './ast/nodes/MetaProperty'; +import type ChildScope from './ast/scopes/ChildScope'; import ExportDefaultVariable from './ast/variables/ExportDefaultVariable'; -import ExportShimVariable from './ast/variables/ExportShimVariable'; import LocalVariable from './ast/variables/LocalVariable'; import NamespaceVariable from './ast/variables/NamespaceVariable'; import SyntheticNamedExportVariable from './ast/variables/SyntheticNamedExportVariable'; -import Variable from './ast/variables/Variable'; +import type Variable from './ast/variables/Variable'; +import ExternalChunk, { formatAttributes } from './ExternalChunk'; import ExternalModule from './ExternalModule'; import finalisers from './finalisers/index'; import Module from './Module'; -import { - DecodedSourceMapOrMissing, +import type { GetInterop, GlobalsOption, InternalModuleFormat, + LogHandler, NormalizedInputOptions, NormalizedOutputOptions, + OutputChunk, PreRenderedChunk, RenderedChunk, - RenderedModule, - WarningHandler + RenderedModule } from './rollup/types'; -import { Addons } from './utils/addons'; -import { collapseSourcemaps } from './utils/collapseSourcemaps'; -import { createHash } from './utils/crypto'; -import { deconflictChunk, DependenciesToBeDeconflicted } from './utils/deconflictChunk'; -import { - errCyclicCrossChunkReexport, - errFailedValidation, - error, - errUnexpectedNamedImport, - errUnexpectedNamespaceReexport -} from './utils/error'; +import { createAddons } from './utils/addons'; +import { EMPTY_OBJECT } from './utils/blank'; +import { deconflictChunk, type DependenciesToBeDeconflicted } from './utils/deconflictChunk'; import { escapeId } from './utils/escapeId'; import { assignExportsToMangledNames, assignExportsToNames } from './utils/exportNames'; +import type { GenerateCodeSnippets } from './utils/generateCodeSnippets'; import getExportMode from './utils/getExportMode'; -import { getId } from './utils/getId'; import getIndentString from './utils/getIndentString'; -import { getOrCreate } from './utils/getOrCreate'; +import { getNewArray, getOrCreate } from './utils/getOrCreate'; import { getStaticDependencies } from './utils/getStaticDependencies'; +import type { HashPlaceholderGenerator } from './utils/hashPlaceholders'; +import { DEFAULT_HASH_SIZE, replacePlaceholders } from './utils/hashPlaceholders'; import { makeLegal } from './utils/identifierHelpers'; import { defaultInteropHelpersByInteropType, + DOCUMENT_CURRENT_SCRIPT, HELPER_NAMES, isDefaultAProperty, namespaceInteropHelpersByInteropType } from './utils/interopHelpers'; -import { basename, dirname, extname, isAbsolute, normalize, resolve } from './utils/path'; -import { PluginDriver } from './utils/PluginDriver'; -import relativeId, { getAliasName } from './utils/relativeId'; -import renderChunk from './utils/renderChunk'; -import { RenderOptions } from './utils/renderHelpers'; +import { LOGLEVEL_WARN } from './utils/logging'; +import { + error, + logCyclicCrossChunkReexport, + logEmptyChunk, + logMissingGlobalName, + logUnexpectedNamedImport, + logUnexpectedNamespaceReexport +} from './utils/logs'; +import type { OutputBundleWithPlaceholders } from './utils/outputBundle'; +import { FILE_PLACEHOLDER } from './utils/outputBundle'; +import { getAttributesFromImportExpression } from './utils/parseImportAttributes'; +import { basename, extname, isAbsolute, normalize, resolve } from './utils/path'; +import type { PluginDriver } from './utils/PluginDriver'; +import { getAliasName, getImportPath } from './utils/relativeId'; +import type { RenderOptions } from './utils/renderHelpers'; import { makeUnique, renderNamePattern } from './utils/renderNamePattern'; -import { sanitizeFileName } from './utils/sanitizeFileName'; -import { timeEnd, timeStart } from './utils/timers'; import { MISSING_EXPORT_SHIM_VARIABLE } from './utils/variableNames'; export interface ModuleDeclarations { - dependencies: ModuleDeclarationDependency[]; + dependencies: ChunkDependency[]; exports: ChunkExports; } -export interface ModuleDeclarationDependency { +type PreliminaryFileName = PreliminaryFileNameWithPlaceholder | FixedPreliminaryFileName; + +export interface ChunkRenderResult { + chunk: Chunk; + magicString: MagicStringBundle; + preliminaryFileName: PreliminaryFileName; + preliminarySourcemapFileName: PreliminaryFileName | null; + usedModules: Module[]; +} + +interface PreliminaryFileNameWithPlaceholder { + fileName: string; + hashPlaceholder: string; +} + +interface FixedPreliminaryFileName { + fileName: string; + hashPlaceholder: null; +} + +export type ResolvedDynamicImport = ( + | { chunk: Chunk; externalChunk: null; facadeChunk: Chunk | undefined; resolution: Module } + | { chunk: null; externalChunk: ExternalChunk; facadeChunk: null; resolution: ExternalModule } + | { chunk: null; externalChunk: null; facadeChunk: null; resolution: string | null } +) & { node: ImportExpression }; + +export interface ChunkDependency { + attributes: string | null; defaultVariableName: string | undefined; - globalName: string; - id: string; + globalName: string | false | undefined; + importPath: string; imports: ImportSpecifier[] | null; isChunk: boolean; name: string; @@ -77,14 +109,11 @@ export interface ModuleDeclarationDependency { reexports: ReexportSpecifier[] | null; } -export type ChunkDependencies = ModuleDeclarationDependency[]; - export type ChunkExports = { exported: string; expression: string | null; hoisted: boolean; local: string; - uninitialized: boolean; }[]; export interface ReexportSpecifier { @@ -103,134 +132,109 @@ interface FacadeName { name?: string; } -const NON_ASSET_EXTENSIONS = ['.js', '.jsx', '.ts', '.tsx']; +type RenderedDependencies = Map; + +const RESERVED_USED_NAMES = [ + 'Object', + 'Promise', + 'module', + 'exports', + 'require', + '__filename', + '__dirname', + ...HELPER_NAMES +]; +const NON_ASSET_EXTENSIONS = new Set([ + '.js', + '.jsx', + '.ts', + '.tsx', + '.mjs', + '.mts', + '.cjs', + '.cts' +]); function getGlobalName( - module: ExternalModule, + chunk: ExternalChunk, globals: GlobalsOption, hasExports: boolean, - warn: WarningHandler -) { - const globalName = typeof globals === 'function' ? globals(module.id) : globals[module.id]; + log: LogHandler +): string | undefined { + const globalName = typeof globals === 'function' ? globals(chunk.id) : globals[chunk.id]; if (globalName) { return globalName; } if (hasExports) { - warn({ - code: 'MISSING_GLOBAL_NAME', - guess: module.variableName, - message: `No name was provided for external module '${module.id}' in output.globals – guessing '${module.variableName}'`, - source: module.id - }); - return module.variableName; + log(LOGLEVEL_WARN, logMissingGlobalName(chunk.id, chunk.variableName)); + return chunk.variableName; } } export default class Chunk { - private static generateFacade( - inputOptions: NormalizedInputOptions, - outputOptions: NormalizedOutputOptions, - unsetOptions: Set, - pluginDriver: PluginDriver, - modulesById: Map, - chunkByModule: Map, - facadeChunkByModule: Map, - includedNamespaces: Set, - facadedModule: Module, - facadeName: FacadeName - ): Chunk { - const chunk = new Chunk( - [], - inputOptions, - outputOptions, - unsetOptions, - pluginDriver, - modulesById, - chunkByModule, - facadeChunkByModule, - includedNamespaces, - null - ); - chunk.assignFacadeName(facadeName, facadedModule); - if (!facadeChunkByModule.has(facadedModule)) { - facadeChunkByModule.set(facadedModule, chunk); - } - for (const dependency of facadedModule.getDependenciesToBeIncluded()) { - chunk.dependencies.add( - dependency instanceof Module ? chunkByModule.get(dependency)! : dependency - ); - } - if ( - !chunk.dependencies.has(chunkByModule.get(facadedModule)!) && - facadedModule.info.hasModuleSideEffects && - facadedModule.hasEffects() - ) { - chunk.dependencies.add(chunkByModule.get(facadedModule)!); - } - chunk.ensureReexportsAreAvailableForModule(facadedModule); - chunk.facadeModule = facadedModule; - chunk.strictFacade = true; - return chunk; - } - - entryModules: Module[] = []; + // placeholder declaration, only relevant for ExternalChunk + defaultVariableName?: undefined; + dependencies = new Set(); + readonly entryModules: Module[] = []; execIndex: number; exportMode: 'none' | 'named' | 'default' = 'named'; facadeModule: Module | null = null; - id: string | null = null; namespaceVariableName = ''; suggestedVariableName: string; variableName = ''; + isManualChunk = false; - private accessedGlobalsByScope = new Map>(); - private dependencies = new Set(); - private dynamicDependencies = new Set(); - private dynamicEntryModules: Module[] = []; + private readonly accessedGlobalsByScope = new Map>(); + private readonly dynamicEntryModules: Module[] = []; private dynamicName: string | null = null; - private exportNamesByVariable = new Map(); - private exports = new Set(); - private exportsByName: Record = Object.create(null); + private readonly exportNamesByVariable = new Map(); + private readonly exports = new Set(); + private readonly exportsByName = new Map(); private fileName: string | null = null; private implicitEntryModules: Module[] = []; - private implicitlyLoadedBefore = new Set(); - private imports = new Set(); - private indentString: string = undefined as any; + private readonly implicitlyLoadedBefore = new Set(); + private readonly imports = new Set(); + private includedDynamicImports: ResolvedDynamicImport[] | null = null; + private readonly includedReexportsByModule = new Map(); + // This may be updated in the constructor private readonly isEmpty: boolean = true; private name: string | null = null; private needsExportsShim = false; - private renderedDependencies: Map< - ExternalModule | Chunk, - ModuleDeclarationDependency - > | null = null; - private renderedExports: ChunkExports | null = null; - private renderedHash: string = undefined as any; - private renderedModules: { - [moduleId: string]: RenderedModule; - } = Object.create(null); - private renderedModuleSources = new Map(); - private renderedSource: MagicStringBundle | null = null; + private preRenderedChunkInfo: PreRenderedChunk | null = null; + private preliminaryFileName: PreliminaryFileName | null = null; + private preliminarySourcemapFileName: PreliminaryFileName | null = null; + private renderedChunkInfo: RenderedChunk | null = null; + private renderedDependencies: Map | null = null; + private readonly renderedModules: Record = Object.create(null); private sortedExportNames: string[] | null = null; private strictFacade = false; - private usedModules: Module[] = undefined as any; + /** Modules with 'allow-extension' that should have preserved exports within the chunk */ + private allowExtensionModules = new Set(); constructor( - private readonly orderedModules: Module[], + private readonly orderedModules: readonly Module[], private readonly inputOptions: NormalizedInputOptions, private readonly outputOptions: NormalizedOutputOptions, - private readonly unsetOptions: Set, + private readonly unsetOptions: ReadonlySet, private readonly pluginDriver: PluginDriver, - private readonly modulesById: Map, + private readonly modulesById: ReadonlyMap, private readonly chunkByModule: Map, + private readonly externalChunkByModule: ReadonlyMap, private readonly facadeChunkByModule: Map, private readonly includedNamespaces: Set, - private readonly manualChunkAlias: string | null + private readonly manualChunkAlias: string | null, + private readonly getPlaceholder: HashPlaceholderGenerator, + private readonly bundle: OutputBundleWithPlaceholders, + private readonly inputBase: string, + private readonly snippets: GenerateCodeSnippets ) { this.execIndex = orderedModules.length > 0 ? orderedModules[0].execIndex : Infinity; const chunkModules = new Set(orderedModules); for (const module of orderedModules) { - if (module.namespace.included) { + chunkByModule.set(module, this); + if (module.namespace.included && !outputOptions.preserveModules) { includedNamespaces.add(module); } if (this.isEmpty && module.isIncluded()) { @@ -243,10 +247,12 @@ export default class Chunk { if (!chunkModules.has(importer)) { this.dynamicEntryModules.push(module); // Modules with synthetic exports need an artificial namespace for dynamic imports - if (module.info.syntheticNamedExports && !outputOptions.preserveModules) { + if (module.info.syntheticNamedExports) { includedNamespaces.add(module); this.exports.add(module.namespace); } + // This only needs to run once + break; } } if (module.implicitlyLoadedAfter.size > 0) { @@ -254,33 +260,84 @@ export default class Chunk { } } this.suggestedVariableName = makeLegal(this.generateVariableName()); + this.isManualChunk = manualChunkAlias !== null; + } + + private static generateFacade( + inputOptions: NormalizedInputOptions, + outputOptions: NormalizedOutputOptions, + unsetOptions: ReadonlySet, + pluginDriver: PluginDriver, + modulesById: ReadonlyMap, + chunkByModule: Map, + externalChunkByModule: ReadonlyMap, + facadeChunkByModule: Map, + includedNamespaces: Set, + facadedModule: Module, + facadeName: FacadeName, + getPlaceholder: HashPlaceholderGenerator, + bundle: OutputBundleWithPlaceholders, + inputBase: string, + snippets: GenerateCodeSnippets + ): Chunk { + const chunk = new Chunk( + [], + inputOptions, + outputOptions, + unsetOptions, + pluginDriver, + modulesById, + chunkByModule, + externalChunkByModule, + facadeChunkByModule, + includedNamespaces, + null, + getPlaceholder, + bundle, + inputBase, + snippets + ); + chunk.assignFacadeName(facadeName, facadedModule); + if (!facadeChunkByModule.has(facadedModule)) { + facadeChunkByModule.set(facadedModule, chunk); + } + for (const dependency of facadedModule.getDependenciesToBeIncluded()) { + chunk.dependencies.add( + dependency instanceof Module + ? chunkByModule.get(dependency)! + : externalChunkByModule.get(dependency)! + ); + } + if ( + !chunk.dependencies.has(chunkByModule.get(facadedModule)!) && + facadedModule.info.moduleSideEffects && + facadedModule.hasEffects() + ) { + chunk.dependencies.add(chunkByModule.get(facadedModule)!); + } + chunk.ensureReexportsAreAvailableForModule(facadedModule); + chunk.facadeModule = facadedModule; + chunk.strictFacade = true; + return chunk; } - canModuleBeFacade(module: Module, exposedVariables: Set): boolean { + canModuleBeFacade(module: Module, exposedVariables: ReadonlySet): boolean { const moduleExportNamesByVariable = module.getExportNamesByVariable(); + // All exports of this chunk need to be exposed by the candidate module for (const exposedVariable of this.exports) { if (!moduleExportNamesByVariable.has(exposedVariable)) { - if ( - moduleExportNamesByVariable.size === 0 && - module.isUserDefinedEntryPoint && - module.preserveSignature === 'strict' && - this.unsetOptions.has('preserveEntrySignatures') - ) { - this.inputOptions.onwarn({ - code: 'EMPTY_FACADE', - id: module.id, - message: `To preserve the export signature of the entry module "${relativeId( - module.id - )}", an empty facade chunk was created. This often happens when creating a bundle for a web app where chunks are placed in script tags and exports are ignored. In this case it is recommended to set "preserveEntrySignatures: false" to avoid this and reduce the number of chunks. Otherwise if this is intentional, set "preserveEntrySignatures: 'strict'" explicitly to silence this warning.`, - url: 'https://rollupjs.org/guide/en/#preserveentrysignatures' - }); - } return false; } } + // Additionally, we need to expose namespaces of dynamic entries that are not the facade module and exports from other entry modules for (const exposedVariable of exposedVariables) { if ( - !(moduleExportNamesByVariable.has(exposedVariable) || exposedVariable.module === module) + !( + exposedVariable.module === module || + moduleExportNamesByVariable.has(exposedVariable) || + (exposedVariable instanceof SyntheticNamedExportVariable && + moduleExportNamesByVariable.has(exposedVariable.getBaseVariable())) + ) ) { return false; } @@ -288,7 +345,37 @@ export default class Chunk { return true; } - generateExports() { + finalizeChunk( + code: string, + map: SourceMap | null, + sourcemapFileName: string | null, + hashesByPlaceholder: Map + ): OutputChunk { + const renderedChunkInfo = this.getRenderedChunkInfo(); + const finalize = (code: string) => replacePlaceholders(code, hashesByPlaceholder); + const preliminaryFileName = renderedChunkInfo.fileName; + const fileName = (this.fileName = finalize(preliminaryFileName)); + return { + ...renderedChunkInfo, + code, + dynamicImports: renderedChunkInfo.dynamicImports.map(finalize), + fileName, + implicitlyLoadedBefore: renderedChunkInfo.implicitlyLoadedBefore.map(finalize), + importedBindings: Object.fromEntries( + Object.entries(renderedChunkInfo.importedBindings).map(([fileName, bindings]) => [ + finalize(fileName), + bindings + ]) + ), + imports: renderedChunkInfo.imports.map(finalize), + map, + preliminaryFileName, + referencedFiles: renderedChunkInfo.referencedFiles.map(finalize), + sourcemapFileName + }; + } + + generateExports(): void { this.sortedExportNames = null; const remainingExports = new Set(this.exports); if ( @@ -299,11 +386,23 @@ export default class Chunk { for (const [variable, exportNames] of exportNamesByVariable) { this.exportNamesByVariable.set(variable, [...exportNames]); for (const exportName of exportNames) { - this.exportsByName[exportName] = variable; + this.exportsByName.set(exportName, variable); } remainingExports.delete(variable); } } + + for (const module of this.allowExtensionModules) { + const exportNamesByVariable = module.getExportNamesByVariable(); + for (const [variable, exportNames] of exportNamesByVariable) { + this.exportNamesByVariable.set(variable, [...exportNames]); + for (const exportName of exportNames) { + this.exportsByName.set(exportName, variable); + } + remainingExports.delete(variable); + } + } + if (this.outputOptions.minifyInternalExports) { assignExportsToMangledNames(remainingExports, this.exportsByName, this.exportNamesByVariable); } else { @@ -313,9 +412,8 @@ export default class Chunk { this.exportMode = getExportMode( this, this.outputOptions, - this.unsetOptions, this.facadeModule!.id, - this.inputOptions.onwarn + this.inputOptions.onLog ); } @@ -323,42 +421,65 @@ export default class Chunk { const facades: Chunk[] = []; const entryModules = new Set([...this.entryModules, ...this.implicitEntryModules]); const exposedVariables = new Set( - this.dynamicEntryModules.map(module => module.namespace) + this.dynamicEntryModules.map(({ namespace }) => namespace) ); + for (const module of entryModules) { - if (module.preserveSignature) { - for (const exportedVariable of module.getExportNamesByVariable().keys()) { - exposedVariables.add(exportedVariable); + if (module.preserveSignature === 'allow-extension') { + const canPreserveExports = this.canPreserveModuleExports(module); + + if ( + canPreserveExports && + !module.chunkFileNames.size && + module.chunkNames.every(({ isUserDefined }) => !isUserDefined) + ) { + this.allowExtensionModules.add(module); + + if (!this.facadeModule) { + this.facadeModule = module; + this.strictFacade = false; + this.assignFacadeName({}, module, this.outputOptions.preserveModules); + } + this.facadeChunkByModule.set(module, this); + + continue; } } - } - for (const module of entryModules) { - const requiredFacades: FacadeName[] = Array.from(module.userChunkNames, name => ({ - name - })); + + const requiredFacades: FacadeName[] = Array.from( + new Set( + module.chunkNames.filter(({ isUserDefined }) => isUserDefined).map(({ name }) => name) + ), + // mapping must run after Set 'name' dedupe + name => ({ + name + }) + ); if (requiredFacades.length === 0 && module.isUserDefinedEntryPoint) { requiredFacades.push({}); } + requiredFacades.push(...Array.from(module.chunkFileNames, fileName => ({ fileName }))); if (requiredFacades.length === 0) { requiredFacades.push({}); } if (!this.facadeModule) { const needsStrictFacade = - module.preserveSignature === 'strict' || - (module.preserveSignature === 'exports-only' && - module.getExportNamesByVariable().size !== 0); - if ( - !needsStrictFacade || - this.outputOptions.preserveModules || - this.canModuleBeFacade(module, exposedVariables) - ) { + !this.outputOptions.preserveModules && + (module.preserveSignature === 'strict' || + (module.preserveSignature === 'exports-only' && + module.getExportNamesByVariable().size > 0)); + if (!needsStrictFacade || this.canModuleBeFacade(module, exposedVariables)) { this.facadeModule = module; this.facadeChunkByModule.set(module, this); if (module.preserveSignature) { this.strictFacade = needsStrictFacade; } - this.assignFacadeName(requiredFacades.shift()!, module); + this.assignFacadeName( + requiredFacades.shift()!, + module, + this.outputOptions.preserveModules + ); } } @@ -371,10 +492,15 @@ export default class Chunk { this.pluginDriver, this.modulesById, this.chunkByModule, + this.externalChunkByModule, this.facadeChunkByModule, this.includedNamespaces, module, - facadeName + facadeName, + this.getPlaceholder, + this.bundle, + this.inputBase, + this.snippets ) ); } @@ -397,148 +523,150 @@ export default class Chunk { this.exports.add(module.namespace); } } + if (!this.outputOptions.preserveModules) { + this.addNecessaryImportsForFacades(); + } + return facades; } - generateId( - addons: Addons, - options: NormalizedOutputOptions, - existingNames: Record, - includeHash: boolean - ): string { - if (this.fileName !== null) { - return this.fileName; - } - const [pattern, patternName] = - this.facadeModule && this.facadeModule.isUserDefinedEntryPoint - ? [options.entryFileNames, 'output.entryFileNames'] - : [options.chunkFileNames, 'output.chunkFileNames']; - return makeUnique( - renderNamePattern( - typeof pattern === 'function' ? pattern(this.getChunkInfo()) : pattern, + private canPreserveModuleExports(module: Module): boolean { + const exportNamesByVariable = module.getExportNamesByVariable(); + + // Check for conflicts - an export name is a conflict if it points to a different module or definition + for (const [variable, exportNames] of exportNamesByVariable) { + for (const exportName of exportNames) { + const existingVariable = this.exportsByName.get(exportName); + // It's ok if the same export name in two modules references the exact same variable + if (existingVariable && existingVariable !== variable) { + return false; + } + } + } + + // No actual conflicts found, add export names for future conflict checks + for (const [variable, exportNames] of exportNamesByVariable) { + for (const exportName of exportNames) { + this.exportsByName.set(exportName, variable); + } + } + + return true; + } + + getChunkName(): string { + return (this.name ??= this.outputOptions.sanitizeFileName(this.getFallbackChunkName())); + } + + getExportNames(): string[] { + return (this.sortedExportNames ??= [...this.exportsByName.keys()].sort()); + } + + getFileName(): string { + return this.fileName || this.getPreliminaryFileName().fileName; + } + + getImportPath(importer: string): string { + return escapeId( + getImportPath( + importer, + this.getFileName(), + this.outputOptions.format === 'amd' && !this.outputOptions.amd.forceJsExtensionForImports, + true + ) + ); + } + + getPreliminaryFileName(): PreliminaryFileName { + if (this.preliminaryFileName) { + return this.preliminaryFileName; + } + let fileName: string; + let hashPlaceholder: string | null = null; + const { chunkFileNames, entryFileNames, file, format, preserveModules } = this.outputOptions; + if (file) { + fileName = basename(file); + } else if (this.fileName === null) { + const [pattern, patternName] = + preserveModules || this.facadeModule?.isUserDefinedEntryPoint + ? [entryFileNames, 'output.entryFileNames'] + : [chunkFileNames, 'output.chunkFileNames']; + fileName = renderNamePattern( + typeof pattern === 'function' ? pattern(this.getPreRenderedChunkInfo()) : pattern, patternName, { - format: () => options.format, - hash: () => - includeHash - ? this.computeContentHashWithDependencies(addons, options, existingNames) - : '[hash]', + format: () => format, + hash: size => + hashPlaceholder || + (hashPlaceholder = this.getPlaceholder(patternName, size || DEFAULT_HASH_SIZE)), name: () => this.getChunkName() } - ), - existingNames - ); + ); + if (!hashPlaceholder) { + fileName = makeUnique(fileName, this.bundle); + } + } else { + fileName = this.fileName; + } + if (!hashPlaceholder) { + this.bundle[fileName] = FILE_PLACEHOLDER; + } + // Caching is essential to not conflict with the file name reservation above + return (this.preliminaryFileName = { fileName, hashPlaceholder }); } - generateIdPreserveModules( - preserveModulesRelativeDir: string, - options: NormalizedOutputOptions, - existingNames: Record, - unsetOptions: Set - ): string { - const id = this.orderedModules[0].id; - const sanitizedId = sanitizeFileName(id); - let path: string; - if (isAbsolute(id)) { - const extension = extname(id); - const pattern = unsetOptions.has('entryFileNames') - ? NON_ASSET_EXTENSIONS.includes(extension) - ? '[name].js' - : '[name][extname].js' - : options.entryFileNames; - const currentDir = dirname(sanitizedId); - const fileName = renderNamePattern( - typeof pattern === 'function' ? pattern(this.getChunkInfo()) : pattern, - 'output.entryFileNames', + getPreliminarySourcemapFileName(): PreliminaryFileName | null { + if (this.preliminarySourcemapFileName) { + return this.preliminarySourcemapFileName; + } + let sourcemapFileName: string | null = null; + let hashPlaceholder: string | null = null; + const { sourcemapFileNames, format } = this.outputOptions; + if (sourcemapFileNames) { + const [pattern, patternName] = [sourcemapFileNames, 'output.sourcemapFileNames']; + sourcemapFileName = renderNamePattern( + typeof pattern === 'function' ? pattern(this.getPreRenderedChunkInfo()) : pattern, + patternName, { - ext: () => extension.substr(1), - extname: () => extension, - format: () => options.format as string, + chunkhash: () => this.getPreliminaryFileName().hashPlaceholder || '', + format: () => format, + hash: size => + hashPlaceholder || + (hashPlaceholder = this.getPlaceholder(patternName, size || DEFAULT_HASH_SIZE)), name: () => this.getChunkName() } ); - const currentPath = `${currentDir}/${fileName}`; - const { preserveModulesRoot } = options; - if (preserveModulesRoot && currentPath.startsWith(preserveModulesRoot)) { - path = currentPath.slice(preserveModulesRoot.length).replace(/^[\\/]/, ''); - } else { - path = relative(preserveModulesRelativeDir, currentPath); + if (!hashPlaceholder) { + sourcemapFileName = makeUnique(sourcemapFileName, this.bundle); } } else { - path = `_virtual/${basename(sanitizedId)}`; + return null; } - return makeUnique(normalize(path), existingNames); - } - getChunkInfo(): PreRenderedChunk { - const facadeModule = this.facadeModule; - const getChunkName = this.getChunkName.bind(this); - return { - exports: this.getExportNames(), - facadeModuleId: facadeModule && facadeModule.id, - isDynamicEntry: this.dynamicEntryModules.length > 0, - isEntry: facadeModule !== null && facadeModule.info.isEntry, - isImplicitEntry: this.implicitEntryModules.length > 0, - modules: this.renderedModules, - get name() { - return getChunkName(); - }, - type: 'chunk' - }; + return (this.preliminarySourcemapFileName = { fileName: sourcemapFileName, hashPlaceholder }); } - getChunkInfoWithFileNames(): RenderedChunk { - return Object.assign(this.getChunkInfo(), { - code: undefined, - dynamicImports: Array.from(this.dynamicDependencies, getId), - fileName: this.id!, - implicitlyLoadedBefore: Array.from(this.implicitlyLoadedBefore, getId), - importedBindings: this.getImportedBindingsPerDependency(), - imports: Array.from(this.dependencies, getId), - map: undefined, + public getRenderedChunkInfo(): RenderedChunk { + if (this.renderedChunkInfo) { + return this.renderedChunkInfo; + } + return (this.renderedChunkInfo = { + ...this.getPreRenderedChunkInfo(), + dynamicImports: this.getDynamicDependencies().map(resolveFileName), + fileName: this.getFileName(), + + implicitlyLoadedBefore: Array.from(this.implicitlyLoadedBefore, resolveFileName), + importedBindings: getImportedBindingsPerDependency( + this.getRenderedDependencies(), + resolveFileName + ), + + imports: Array.from(this.dependencies, resolveFileName), + modules: this.renderedModules, referencedFiles: this.getReferencedFiles() }); } - getChunkName(): string { - return this.name || (this.name = sanitizeFileName(this.getFallbackChunkName())); - } - - getExportNames(): string[] { - return ( - this.sortedExportNames || (this.sortedExportNames = Object.keys(this.exportsByName).sort()) - ); - } - - getRenderedHash(): string { - if (this.renderedHash) return this.renderedHash; - const hash = createHash(); - const hashAugmentation = this.pluginDriver.hookReduceValueSync( - 'augmentChunkHash', - '', - [this.getChunkInfo()], - (augmentation, pluginHash) => { - if (pluginHash) { - augmentation += pluginHash; - } - return augmentation; - } - ); - hash.update(hashAugmentation); - hash.update(this.renderedSource!.toString()); - hash.update( - this.getExportNames() - .map(exportName => { - const variable = this.exportsByName[exportName]; - return `${relativeId((variable.module as Module).id).replace(/\\/g, '/')}:${ - variable.name - }:${exportName}`; - }) - .join(',') - ); - return (this.renderedHash = hash.digest('hex')); - } - getVariableExportName(variable: Variable): string { if (this.outputOptions.preserveModules && variable instanceof NamespaceVariable) { return '*'; @@ -546,281 +674,157 @@ export default class Chunk { return this.exportNamesByVariable.get(variable)![0]; } - link() { - this.dependencies = getStaticDependencies(this, this.orderedModules, this.chunkByModule); + link(): void { + this.dependencies = getStaticDependencies( + this, + this.orderedModules, + this.chunkByModule, + this.externalChunkByModule + ); for (const module of this.orderedModules) { - this.addDependenciesToChunk(module.dynamicDependencies, this.dynamicDependencies); - this.addDependenciesToChunk(module.implicitlyLoadedBefore, this.implicitlyLoadedBefore); + this.addImplicitlyLoadedBeforeFromModule(module); this.setUpChunkImportsAndExportsForModule(module); } } - // prerender allows chunk hashes and names to be generated before finalizing - preRender(options: NormalizedOutputOptions, inputBase: string) { - const magicString = new MagicStringBundle({ separator: options.compact ? '' : '\n\n' }); - this.usedModules = []; - this.indentString = getIndentString(this.orderedModules, options); - - const n = options.compact ? '' : '\n'; - const _ = options.compact ? '' : ' '; + inlineTransitiveImports(): void { + const { facadeModule, dependencies, outputOptions } = this; + const { hoistTransitiveImports, preserveModules } = outputOptions; - const renderOptions: RenderOptions = { - compact: options.compact, - dynamicImportFunction: options.dynamicImportFunction, - exportNamesByVariable: this.exportNamesByVariable, - format: options.format, - freeze: options.freeze, - indent: this.indentString, - namespaceToStringTag: options.namespaceToStringTag, - outputPluginDriver: this.pluginDriver, - varOrConst: options.preferConst ? 'const' : 'var' - }; - - // for static and dynamic entry points, inline the execution list to avoid loading latency - if ( - options.hoistTransitiveImports && - !this.outputOptions.preserveModules && - this.facadeModule !== null - ) { - for (const dep of this.dependencies) { + // for static and dynamic entry points, add transitive dependencies to this + // chunk's dependencies to avoid loading latency + if (hoistTransitiveImports && !preserveModules && facadeModule !== null) { + for (const dep of dependencies) { if (dep instanceof Chunk) this.inlineChunkDependencies(dep); } } + } - this.prepareDynamicImportsAndImportMetas(); - this.setIdentifierRenderResolutions(options); - - let hoistedSource = ''; - const renderedModules = this.renderedModules; - - for (const module of this.orderedModules) { - let renderedLength = 0; - if (module.isIncluded() || this.includedNamespaces.has(module)) { - const source = module.render(renderOptions).trim(); - renderedLength = source.length(); - if (renderedLength) { - if (options.compact && source.lastLine().indexOf('//') !== -1) source.append('\n'); - this.renderedModuleSources.set(module, source); - magicString.addSource(source); - this.usedModules.push(module); + async render(): Promise { + const { + exportMode, + facadeModule, + inputOptions: { onLog }, + outputOptions, + pluginDriver, + snippets + } = this; + const { format, preserveModules } = outputOptions; + + const preliminaryFileName = this.getPreliminaryFileName(); + const preliminarySourcemapFileName = this.getPreliminarySourcemapFileName(); + const { accessedGlobals, indent, magicString, renderedSource, usedModules, usesTopLevelAwait } = + this.renderModules(preliminaryFileName.fileName); + + const renderedDependencies = [...this.getRenderedDependencies().values()]; + const renderedExports = exportMode === 'none' ? [] : this.getChunkExportDeclarations(format); + let hasExports = renderedExports.length > 0; + let hasDefaultExport = false; + for (const renderedDependency of renderedDependencies) { + const { reexports } = renderedDependency; + if (reexports?.length) { + hasExports = true; + if (!hasDefaultExport && reexports.some(reexport => reexport.reexported === 'default')) { + hasDefaultExport = true; } - const namespace = module.namespace; - if (this.includedNamespaces.has(module) && !this.outputOptions.preserveModules) { - const rendered = namespace.renderBlock(renderOptions); - if (namespace.renderFirst()) hoistedSource += n + rendered; - else magicString.addSource(new MagicString(rendered)); + if (format === 'es') { + renderedDependency.reexports = reexports.filter( + ({ reexported }) => !renderedExports.find(({ exported }) => exported === reexported) + ); } } - const { renderedExports, removedExports } = module.getRenderedExports(); - const chunk = this; - renderedModules[module.id] = { - originalLength: module.originalCode.length, - removedExports, - renderedExports, - renderedLength, - get code() { - return chunk.renderedModuleSources.get(module)?.toString() ?? null; - } - }; - } - - if (hoistedSource) magicString.prepend(hoistedSource + n + n); - - if (this.needsExportsShim) { - magicString.prepend( - `${n}${renderOptions.varOrConst} ${MISSING_EXPORT_SHIM_VARIABLE}${_}=${_}void 0;${n}${n}` - ); - } - if (options.compact) { - this.renderedSource = magicString; - } else { - this.renderedSource = magicString.trim(); - } - - this.renderedHash = undefined as any; - - if (this.isEmpty && this.getExportNames().length === 0 && this.dependencies.size === 0) { - const chunkName = this.getChunkName(); - this.inputOptions.onwarn({ - chunkName, - code: 'EMPTY_BUNDLE', - message: `Generated an empty chunk: "${chunkName}"` - }); - } - - this.setExternalRenderPaths(options, inputBase); - - this.renderedDependencies = this.getChunkDependencyDeclarations(options); - this.renderedExports = - this.exportMode === 'none' ? [] : this.getChunkExportDeclarations(options.format); - } - - async render(options: NormalizedOutputOptions, addons: Addons, outputChunk: RenderedChunk) { - timeStart('render format', 2); - - const format = options.format; - const finalise = finalisers[format]; - if (options.dynamicImportFunction && format !== 'es') { - this.inputOptions.onwarn({ - code: 'INVALID_OPTION', - message: '"output.dynamicImportFunction" is ignored for formats other than "es".' - }); - } - - // populate ids in the rendered declarations only here - // as chunk ids known only after prerender - for (const dependency of this.dependencies) { - const renderedDependency = this.renderedDependencies!.get(dependency)!; - if (dependency instanceof ExternalModule) { - const originalId = dependency.renderPath; - renderedDependency.id = escapeId( - dependency.renormalizeRenderPath ? this.getRelativePath(originalId, false) : originalId - ); - } else { - renderedDependency.namedExportsMode = dependency.exportMode !== 'default'; - renderedDependency.id = escapeId(this.getRelativePath(dependency.id!, false)); - } } - - this.finaliseDynamicImports(options); - this.finaliseImportMetas(format); - - const hasExports = - this.renderedExports!.length !== 0 || - [...this.renderedDependencies!.values()].some( - dep => (dep.reexports && dep.reexports.length !== 0)! - ); - - let usesTopLevelAwait = false; - const accessedGlobals = new Set(); - for (const module of this.orderedModules) { - if (module.usesTopLevelAwait) { - usesTopLevelAwait = true; - } - const accessedGlobalVariables = this.accessedGlobalsByScope.get(module.scope); - if (accessedGlobalVariables) { - for (const name of accessedGlobalVariables) { - accessedGlobals.add(name); + if (!hasDefaultExport) { + for (const { exported } of renderedExports) { + if (exported === 'default') { + hasDefaultExport = true; + break; } } } - if (usesTopLevelAwait && format !== 'es' && format !== 'system') { - return error({ - code: 'INVALID_TLA_FORMAT', - message: `Module format ${format} does not support top-level await. Use the "es" or "system" output formats rather.` - }); - } - - /* istanbul ignore next */ - if (!this.id) { - throw new Error('Internal Error: expecting chunk id'); - } - - const magicString = finalise( - this.renderedSource!, + const { intro, outro, banner, footer } = await createAddons( + outputOptions, + pluginDriver, + this.getRenderedChunkInfo() + ); + finalisers[format]( + renderedSource, { accessedGlobals, - dependencies: [...this.renderedDependencies!.values()], - exports: this.renderedExports!, + dependencies: renderedDependencies, + exports: renderedExports, + hasDefaultExport, hasExports, - id: this.id, - indentString: this.indentString, - intro: addons.intro!, - isEntryFacade: - this.outputOptions.preserveModules || - (this.facadeModule !== null && this.facadeModule.info.isEntry), - isModuleFacade: this.facadeModule !== null, - namedExportsMode: this.exportMode !== 'default', - outro: addons.outro!, - usesTopLevelAwait, - varOrConst: options.preferConst ? 'const' : 'var', - warn: this.inputOptions.onwarn + id: preliminaryFileName.fileName, + indent, + intro, + isEntryFacade: preserveModules || (facadeModule !== null && facadeModule.info.isEntry), + isModuleFacade: facadeModule !== null, + log: onLog, + namedExportsMode: exportMode !== 'default', + outro, + snippets, + usesTopLevelAwait }, - options + outputOptions ); - if (addons.banner) magicString.prepend(addons.banner); - if (addons.footer) magicString.append(addons.footer); - const prevCode = magicString.toString(); - - timeEnd('render format', 2); - - let map: SourceMap = null as any; - const chunkSourcemapChain: DecodedSourceMapOrMissing[] = []; - - let code = await renderChunk({ - code: prevCode, - options, - outputPluginDriver: this.pluginDriver, - renderChunk: outputChunk, - sourcemapChain: chunkSourcemapChain - }); - if (options.sourcemap) { - timeStart('sourcemap', 2); - - let file: string; - if (options.file) file = resolve(options.sourcemapFile || options.file); - else if (options.dir) file = resolve(options.dir, this.id); - else file = resolve(this.id); - - const decodedMap = magicString.generateDecodedMap({}); - map = collapseSourcemaps( - file, - decodedMap, - this.usedModules, - chunkSourcemapChain, - options.sourcemapExcludeSources, - this.inputOptions.onwarn - ); - map.sources = map.sources - .map(sourcePath => { - const { sourcemapPathTransform } = options; - - if (sourcemapPathTransform) { - const newSourcePath = sourcemapPathTransform(sourcePath, `${file}.map`) as unknown; - - if (typeof newSourcePath !== 'string') { - error(errFailedValidation(`sourcemapPathTransform function must return a string.`)); - } - - return newSourcePath; - } + if (banner) magicString.prepend(banner); + if (format === 'es' || format === 'cjs') { + const shebang = facadeModule !== null && facadeModule.info.isEntry && facadeModule.shebang; + if (shebang) { + magicString.prepend(`#!${shebang}\n`); + } + } + if (footer) magicString.append(footer); - return sourcePath; - }) - .map(normalize); + return { + chunk: this, + magicString, + preliminaryFileName, + preliminarySourcemapFileName, + usedModules + }; + } - timeEnd('sourcemap', 2); + private addImplicitlyLoadedBeforeFromModule(baseModule: Module): void { + const { chunkByModule, implicitlyLoadedBefore } = this; + for (const module of baseModule.implicitlyLoadedBefore) { + const chunk = chunkByModule.get(module); + if (chunk && chunk !== this) { + implicitlyLoadedBefore.add(chunk); + } } - if (!options.compact && code[code.length - 1] !== '\n') code += '\n'; - return { code, map }; } - private addDependenciesToChunk( - moduleDependencies: Set, - chunkDependencies: Set - ) { - for (const module of moduleDependencies) { - if (module instanceof Module) { - const chunk = this.chunkByModule.get(module); - if (chunk && chunk !== this) { - chunkDependencies.add(chunk); + private addNecessaryImportsForFacades() { + for (const [module, variables] of this.includedReexportsByModule) { + if (this.includedNamespaces.has(module)) { + for (const variable of variables) { + this.imports.add(variable); } - } else { - chunkDependencies.add(module); } } } - private assignFacadeName({ fileName, name }: FacadeName, facadedModule: Module) { + private assignFacadeName( + { fileName, name }: FacadeName, + facadedModule: Module, + preservePath?: boolean + ): void { if (fileName) { this.fileName = fileName; } else { - this.name = sanitizeFileName(name || getChunkNameFromModule(facadedModule)); + this.name = this.outputOptions.sanitizeFileName( + name || + (preservePath + ? this.getPreserveModulesChunkNameFromModule(facadedModule) + : getChunkNameFromModule(facadedModule)) + ); } } - private checkCircularDependencyImport(variable: Variable, importingModule: Module) { + private checkCircularDependencyImport(variable: Variable, importingModule: Module): void { const variableModule = variable.module; if (variableModule instanceof Module) { const exportChunk = this.chunkByModule.get(variableModule); @@ -829,13 +833,16 @@ export default class Chunk { alternativeReexportModule = importingModule.alternativeReexportModules.get(variable); if (alternativeReexportModule) { const exportingChunk = this.chunkByModule.get(alternativeReexportModule); - if (exportingChunk && exportingChunk !== exportChunk) { - this.inputOptions.onwarn( - errCyclicCrossChunkReexport( - variableModule.getExportNamesByVariable().get(variable)![0], + if (exportingChunk !== exportChunk) { + this.inputOptions.onLog( + LOGLEVEL_WARN, + logCyclicCrossChunkReexport( + // Namespaces do not have an export name + variableModule.getExportNamesByVariable().get(variable)?.[0] || '*', variableModule.id, alternativeReexportModule.id, - importingModule.id + importingModule.id, + this.outputOptions.preserveModules ) ); } @@ -845,46 +852,22 @@ export default class Chunk { } } - private computeContentHashWithDependencies( - addons: Addons, - options: NormalizedOutputOptions, - existingNames: Record - ): string { - const hash = createHash(); - hash.update( - [addons.intro, addons.outro, addons.banner, addons.footer].map(addon => addon || '').join(':') - ); - hash.update(options.format as string); - const dependenciesForHashing = new Set([this]); - for (const current of dependenciesForHashing) { - if (current instanceof ExternalModule) { - hash.update(':' + current.renderPath); - } else { - hash.update(current.getRenderedHash()); - hash.update(current.generateId(addons, options, existingNames, false)); - } - if (current instanceof ExternalModule) continue; - for (const dependency of [...current.dependencies, ...current.dynamicDependencies]) { - dependenciesForHashing.add(dependency); - } - } - return hash.digest('hex').substr(0, 8); - } - - private ensureReexportsAreAvailableForModule(module: Module) { + private ensureReexportsAreAvailableForModule(module: Module): void { + const includedReexports: Variable[] = []; const map = module.getExportNamesByVariable(); for (const exportedVariable of map.keys()) { const isSynthetic = exportedVariable instanceof SyntheticNamedExportVariable; - const importedVariable = isSynthetic - ? (exportedVariable as SyntheticNamedExportVariable).getBaseVariable() - : exportedVariable; + const importedVariable = isSynthetic ? exportedVariable.getBaseVariable() : exportedVariable; + this.checkCircularDependencyImport(importedVariable, module); + // When preserving modules, we do not create namespace objects but directly + // use the actual namespaces, which would be broken by this logic. if (!(importedVariable instanceof NamespaceVariable && this.outputOptions.preserveModules)) { - this.checkCircularDependencyImport(importedVariable, module); const exportingModule = importedVariable.module; if (exportingModule instanceof Module) { const chunk = this.chunkByModule.get(exportingModule); if (chunk && chunk !== this) { chunk.exports.add(importedVariable); + includedReexports.push(importedVariable); if (isSynthetic) { this.imports.add(importedVariable); } @@ -892,44 +875,8 @@ export default class Chunk { } } } - } - - private finaliseDynamicImports(options: NormalizedOutputOptions) { - const stripKnownJsExtensions = options.format === 'amd'; - for (const [module, code] of this.renderedModuleSources) { - for (const { node, resolution } of module.dynamicImports) { - const chunk = this.chunkByModule.get(resolution as Module); - const facadeChunk = this.facadeChunkByModule.get(resolution as Module); - if (!resolution || !node.included || chunk === this) { - continue; - } - const renderedResolution = - resolution instanceof Module - ? `'${this.getRelativePath((facadeChunk || chunk!).id!, stripKnownJsExtensions)}'` - : resolution instanceof ExternalModule - ? `'${ - resolution.renormalizeRenderPath - ? this.getRelativePath(resolution.renderPath, stripKnownJsExtensions) - : resolution.renderPath - }'` - : resolution; - node.renderFinalResolution( - code, - renderedResolution, - resolution instanceof Module && - !facadeChunk?.strictFacade && - chunk!.exportNamesByVariable.get(resolution.namespace)![0], - options - ); - } - } - } - - private finaliseImportMetas(format: InternalModuleFormat): void { - for (const [module, code] of this.renderedModuleSources) { - for (const importMeta of module.importMetas) { - importMeta.renderFinalMechanism(code, this.id!, format, this.pluginDriver); - } + if (includedReexports.length > 0) { + this.includedReexportsByModule.set(module, includedReexports); } } @@ -943,63 +890,46 @@ export default class Chunk { this.dynamicEntryModules[0] || this.orderedModules[this.orderedModules.length - 1]; if (moduleForNaming) { - return moduleForNaming.chunkName || getAliasName(moduleForNaming.id); + return getChunkNameFromModule(moduleForNaming); } return 'chunk'; } - private getChunkDependencyDeclarations( - options: NormalizedOutputOptions - ): Map { - const importSpecifiers = this.getImportSpecifiers(); - const reexportSpecifiers = this.getReexportSpecifiers(); - const dependencyDeclaration = new Map(); - for (const dep of this.dependencies) { - const imports = importSpecifiers.get(dep) || null; - const reexports = reexportSpecifiers.get(dep) || null; - const namedExportsMode = dep instanceof ExternalModule || dep.exportMode !== 'default'; - - dependencyDeclaration.set(dep, { - defaultVariableName: (dep as ExternalModule).defaultVariableName, - globalName: (dep instanceof ExternalModule && - (options.format === 'umd' || options.format === 'iife') && - getGlobalName( - dep, - options.globals, - (imports || reexports) !== null, - this.inputOptions.onwarn - )) as string, - id: undefined as any, // chunk id updated on render - imports, - isChunk: dep instanceof Chunk, - name: dep.variableName, - namedExportsMode, - namespaceVariableName: (dep as ExternalModule).namespaceVariableName, - reexports - }); - } - - return dependencyDeclaration; - } - private getChunkExportDeclarations(format: InternalModuleFormat): ChunkExports { const exports: ChunkExports = []; for (const exportName of this.getExportNames()) { if (exportName[0] === '*') continue; - const variable = this.exportsByName[exportName]; + const variable = this.exportsByName.get(exportName)!; if (!(variable instanceof SyntheticNamedExportVariable)) { const module = variable.module; - if (module && this.chunkByModule.get(module as Module) !== this) continue; + if (module) { + const chunk = this.chunkByModule.get(module as Module); + if (chunk !== this) { + if (!chunk || format !== 'es') { + continue; + } + const chunkDep = this.renderedDependencies!.get(chunk)!; + if (!chunkDep) { + continue; + } + const { imports, reexports } = chunkDep; + const importedByReexported = reexports?.find( + ({ reexported }) => reexported === exportName + ); + const isImported = imports?.find( + ({ imported }) => imported === importedByReexported?.imported + ); + if (!isImported) { + continue; + } + } + } } let expression = null; let hoisted = false; - let uninitialized = false; - let local = variable.getName(); + let local = variable.getName(this.snippets.getPropertyAccess); if (variable instanceof LocalVariable) { - if (variable.init === UNDEFINED_EXPRESSION) { - uninitialized = true; - } for (const declaration of variable.declarations) { if ( declaration.parent instanceof FunctionDeclaration || @@ -1012,7 +942,7 @@ export default class Chunk { } } else if (variable instanceof SyntheticNamedExportVariable) { expression = local; - if (format === 'es' && exportName !== 'default') { + if (format === 'es') { local = variable.renderName!; } } @@ -1021,8 +951,7 @@ export default class Chunk { exported: exportName, expression, hoisted, - local, - uninitialized + local }); } return exports; @@ -1033,23 +962,30 @@ export default class Chunk { addDependenciesWithoutBindings: boolean, interop: GetInterop ): DependenciesToBeDeconflicted { - const dependencies = new Set(); - const deconflictedDefault = new Set(); - const deconflictedNamespace = new Set(); + const dependencies = new Set(); + const deconflictedDefault = new Set(); + const deconflictedNamespace = new Set(); for (const variable of [...this.exportNamesByVariable.keys(), ...this.imports]) { if (addNonNamespacesAndInteropHelpers || variable.isNamespace) { const module = variable.module!; if (module instanceof ExternalModule) { - dependencies.add(module); + const chunk = this.externalChunkByModule.get(module)!; + dependencies.add(chunk); if (addNonNamespacesAndInteropHelpers) { if (variable.name === 'default') { - if (defaultInteropHelpersByInteropType[String(interop(module.id))]) { - deconflictedDefault.add(module); - } - } else if (variable.name === '*') { - if (namespaceInteropHelpersByInteropType[String(interop(module.id))]) { - deconflictedNamespace.add(module); + if (defaultInteropHelpersByInteropType[interop(module.id)]) { + deconflictedDefault.add(chunk); } + } else if ( + variable.isNamespace && + namespaceInteropHelpersByInteropType[interop(module.id)] && + (this.imports.has(variable) || + !this.exportNamesByVariable.get(variable)?.every(name => name[0] === '*')) + ) { + // We only need to deconflict it if the namespace is actually + // created as a variable, i.e. because it is used internally or + // because it is reexported as an object + deconflictedNamespace.add(chunk); } } } else { @@ -1075,6 +1011,49 @@ export default class Chunk { return { deconflictedDefault, deconflictedNamespace, dependencies }; } + private getDynamicDependencies(): (Chunk | ExternalChunk)[] { + return this.getIncludedDynamicImports() + .map( + resolvedDynamicImport => + resolvedDynamicImport.facadeChunk || + resolvedDynamicImport.chunk || + resolvedDynamicImport.externalChunk || + resolvedDynamicImport.resolution + ) + .filter( + (resolution): resolution is Chunk | ExternalChunk => + resolution !== this && + (resolution instanceof Chunk || resolution instanceof ExternalChunk) + ); + } + + private getDynamicImportStringAndAttributes( + resolution: ExternalModule | string | null, + fileName: string, + node: ImportExpression + ): [importPath: string, attributes: string | null | true] { + const { externalImportAttributes } = this.outputOptions; + const keepExternalImportAttributes = + ['es', 'cjs'].includes(this.outputOptions.format) && externalImportAttributes; + if (resolution instanceof ExternalModule) { + const chunk = this.externalChunkByModule.get(resolution)!; + const dynamicAttributes = chunk.getImportAttributes(this.snippets); + return [ + `'${chunk.getImportPath(fileName)}'`, + dynamicAttributes || (keepExternalImportAttributes ? true : null) + ]; + } + let attributes: string | true | null = null; + if (keepExternalImportAttributes) { + const attributesFromImportAttributes = getAttributesFromImportExpression(node); + attributes = + attributesFromImportAttributes === EMPTY_OBJECT + ? true + : formatAttributes(attributesFromImportAttributes, this.snippets); + } + return [resolution || '', attributes]; + } + private getFallbackChunkName(): string { if (this.manualChunkAlias) { return this.manualChunkAlias; @@ -1088,67 +1067,126 @@ export default class Chunk { return getAliasName(this.orderedModules[this.orderedModules.length - 1].id); } - private getImportedBindingsPerDependency(): { [imported: string]: string[] } { - const importSpecifiers: { [imported: string]: string[] } = {}; - for (const [dependency, declaration] of this.renderedDependencies!) { - const specifiers = new Set(); - if (declaration.imports) { - for (const { imported } of declaration.imports) { - specifiers.add(imported); - } - } - if (declaration.reexports) { - for (const { imported } of declaration.reexports) { - specifiers.add(imported); - } - } - importSpecifiers[dependency.id!] = [...specifiers]; - } - return importSpecifiers; - } - - private getImportSpecifiers(): Map { + private getImportSpecifiers(): Map { const { interop } = this.outputOptions; - const importsByDependency = new Map(); + const importsByDependency = new Map(); for (const variable of this.imports) { const module = variable.module!; - let dependency: Chunk | ExternalModule; + let dependency: Chunk | ExternalChunk; let imported: string; if (module instanceof ExternalModule) { - dependency = module; + dependency = this.externalChunkByModule.get(module)!; imported = variable.name; if (imported !== 'default' && imported !== '*' && interop(module.id) === 'defaultOnly') { - return error(errUnexpectedNamedImport(module.id, imported, false)); + return error(logUnexpectedNamedImport(module.id, imported, false)); } } else { dependency = this.chunkByModule.get(module)!; imported = dependency.getVariableExportName(variable); } - getOrCreate(importsByDependency, dependency, () => []).push({ + getOrCreate(importsByDependency, dependency, getNewArray).push({ imported, - local: variable.getName() + local: variable.getName(this.snippets.getPropertyAccess) }); } return importsByDependency; } - private getReexportSpecifiers(): Map { + private getIncludedDynamicImports(): ResolvedDynamicImport[] { + if (this.includedDynamicImports) { + return this.includedDynamicImports; + } + const includedDynamicImports: ResolvedDynamicImport[] = []; + for (const module of this.orderedModules) { + for (const { node } of module.dynamicImports) { + if (!node.included) { + continue; + } + const { resolution } = node; + includedDynamicImports.push( + resolution instanceof Module + ? { + chunk: this.chunkByModule.get(resolution)!, + externalChunk: null, + facadeChunk: this.facadeChunkByModule.get(resolution), + node, + resolution + } + : resolution instanceof ExternalModule + ? { + chunk: null, + externalChunk: this.externalChunkByModule.get(resolution)!, + facadeChunk: null, + node, + resolution + } + : { chunk: null, externalChunk: null, facadeChunk: null, node, resolution } + ); + } + } + return (this.includedDynamicImports = includedDynamicImports); + } + + getPreRenderedChunkInfo(): PreRenderedChunk { + if (this.preRenderedChunkInfo) { + return this.preRenderedChunkInfo; + } + const { dynamicEntryModules, facadeModule, implicitEntryModules, orderedModules } = this; + return (this.preRenderedChunkInfo = { + exports: this.getExportNames(), + facadeModuleId: facadeModule && facadeModule.id, + isDynamicEntry: dynamicEntryModules.length > 0, + isEntry: !!facadeModule?.info.isEntry, + isImplicitEntry: implicitEntryModules.length > 0, + moduleIds: orderedModules.map(({ id }) => id), + name: this.getChunkName(), + type: 'chunk' + }); + } + + private getPreserveModulesChunkNameFromModule(module: Module): string { + const predefinedChunkName = getPredefinedChunkNameFromModule(module); + if (predefinedChunkName) return predefinedChunkName; + const { preserveModulesRoot, sanitizeFileName } = this.outputOptions; + const sanitizedId = sanitizeFileName(normalize(module.id.split(QUERY_HASH_REGEX, 1)[0])); + const extensionName = extname(sanitizedId); + const idWithoutExtension = NON_ASSET_EXTENSIONS.has(extensionName) + ? sanitizedId.slice(0, -extensionName.length) + : sanitizedId; + if (isAbsolute(idWithoutExtension)) { + if (preserveModulesRoot && resolve(idWithoutExtension).startsWith(preserveModulesRoot)) { + return idWithoutExtension.slice(preserveModulesRoot.length).replace(/^[/\\]/, ''); + } else { + // handle edge case in Windows + if (this.inputBase === '/' && idWithoutExtension[0] !== '/') { + return relative(this.inputBase, idWithoutExtension.replace(/^[a-zA-Z]:[/\\]/, '/')); + } + return relative(this.inputBase, idWithoutExtension); + } + } else { + return ( + this.outputOptions.virtualDirname.replace(/\/$/, '') + '/' + basename(idWithoutExtension) + ); + } + } + + private getReexportSpecifiers(): Map { const { externalLiveBindings, interop } = this.outputOptions; - const reexportSpecifiers = new Map(); + const reexportSpecifiers = new Map(); for (let exportName of this.getExportNames()) { - let dependency: Chunk | ExternalModule; + let dependency: Chunk | ExternalChunk; let imported: string; let needsLiveBinding = false; if (exportName[0] === '*') { - const id = exportName.substr(1); + const id = exportName.slice(1); if (interop(id) === 'defaultOnly') { - this.inputOptions.onwarn(errUnexpectedNamespaceReexport(id)); + this.inputOptions.onLog(LOGLEVEL_WARN, logUnexpectedNamespaceReexport(id)); } needsLiveBinding = externalLiveBindings; - dependency = this.modulesById.get(id) as ExternalModule; + dependency = this.externalChunkByModule.get(this.modulesById.get(id) as ExternalModule)!; imported = exportName = '*'; } else { - const variable = this.exportsByName[exportName]; + const variable = this.exportsByName.get(exportName)!; if (variable instanceof SyntheticNamedExportVariable) continue; const module = variable.module!; if (module instanceof Module) { @@ -1157,17 +1195,17 @@ export default class Chunk { imported = dependency.getVariableExportName(variable); needsLiveBinding = variable.isReassigned; } else { - dependency = module; + dependency = this.externalChunkByModule.get(module)!; imported = variable.name; if (imported !== 'default' && imported !== '*' && interop(module.id) === 'defaultOnly') { - return error(errUnexpectedNamedImport(module.id, imported, true)); + return error(logUnexpectedNamedImport(module.id, imported, true)); } needsLiveBinding = externalLiveBindings && - (imported !== 'default' || isDefaultAProperty(String(interop(module.id)), true)); + (imported !== 'default' || isDefaultAProperty(interop(module.id), true)); } } - getOrCreate(reexportSpecifiers, dependency, () => []).push({ + getOrCreate(reexportSpecifiers, dependency, getNewArray).push({ imported, needsLiveBinding, reexported: exportName @@ -1177,29 +1215,62 @@ export default class Chunk { } private getReferencedFiles(): string[] { - const referencedFiles: string[] = []; + const referencedFiles = new Set(); for (const module of this.orderedModules) { for (const meta of module.importMetas) { const fileName = meta.getReferencedFileName(this.pluginDriver); if (fileName) { - referencedFiles.push(fileName); + referencedFiles.add(fileName); } } } - return referencedFiles; + return [...referencedFiles]; } - private getRelativePath(targetPath: string, stripJsExtension: boolean): string { - let relativePath = normalize(relative(dirname(this.id!), targetPath)); - if (stripJsExtension && relativePath.endsWith('.js')) { - relativePath = relativePath.slice(0, -3); + private getRenderedDependencies(): RenderedDependencies { + if (this.renderedDependencies) { + return this.renderedDependencies; } - if (relativePath === '..') return '../../' + basename(targetPath); - if (relativePath === '') return '../' + basename(targetPath); - return relativePath.startsWith('../') ? relativePath : './' + relativePath; + const importSpecifiers = this.getImportSpecifiers(); + const reexportSpecifiers = this.getReexportSpecifiers(); + const renderedDependencies = new Map(); + const fileName = this.getFileName(); + for (const dependency of this.dependencies) { + const imports = importSpecifiers.get(dependency) || null; + const reexports = reexportSpecifiers.get(dependency) || null; + const namedExportsMode = + dependency instanceof ExternalChunk || dependency.exportMode !== 'default'; + const importPath = dependency.getImportPath(fileName); + + renderedDependencies.set(dependency, { + attributes: + dependency instanceof ExternalChunk + ? dependency.getImportAttributes(this.snippets) + : null, + defaultVariableName: dependency.defaultVariableName, + globalName: + dependency instanceof ExternalChunk && + (this.outputOptions.format === 'umd' || this.outputOptions.format === 'iife') && + getGlobalName( + dependency, + this.outputOptions.globals, + (imports || reexports) !== null, + this.inputOptions.onLog + ), + importPath, + imports, + isChunk: dependency instanceof Chunk, + name: dependency.variableName, + namedExportsMode, + namespaceVariableName: dependency.namespaceVariableName, + reexports + }); + } + + return (this.renderedDependencies = renderedDependencies); } - private inlineChunkDependencies(chunk: Chunk) { + private inlineChunkDependencies(chunk: Chunk): void { for (const dep of chunk.dependencies) { if (this.dependencies.has(dep)) continue; this.dependencies.add(dep); @@ -1209,60 +1280,168 @@ export default class Chunk { } } - private prepareDynamicImportsAndImportMetas() { - const accessedGlobalsByScope = this.accessedGlobalsByScope; - for (const module of this.orderedModules) { - for (const { node, resolution } of module.dynamicImports) { - if (node.included) { - if (resolution instanceof Module) { - const chunk = this.chunkByModule.get(resolution); - if (chunk === this) { - node.setInternalResolution(resolution.namespace); - } else { - node.setExternalResolution( - this.facadeChunkByModule.get(resolution)?.exportMode || chunk!.exportMode, - resolution, - this.outputOptions, - this.pluginDriver, - accessedGlobalsByScope - ); - } - } else { - node.setExternalResolution( - 'external', - resolution, - this.outputOptions, - this.pluginDriver, - accessedGlobalsByScope - ); + // This method changes properties on the AST before rendering and must not be async + private renderModules(fileName: string) { + const { + accessedGlobalsByScope, + dependencies, + exportNamesByVariable, + includedNamespaces, + inputOptions: { onLog }, + isEmpty, + orderedModules, + outputOptions, + pluginDriver, + renderedModules, + snippets + } = this; + const { + compact, + format, + freeze, + generatedCode: { symbols }, + importAttributesKey + } = outputOptions; + const { _, cnst, n } = snippets; + this.setDynamicImportResolutions(fileName); + this.setImportMetaResolutions(fileName); + this.setIdentifierRenderResolutions(); + + const magicString = new MagicStringBundle({ separator: `${n}${n}` }); + const indent = getIndentString(orderedModules, outputOptions); + const usedModules: Module[] = []; + let hoistedSource = ''; + const accessedGlobals = new Set(); + const renderedModuleSources = new Map(); + + const renderOptions: RenderOptions = { + accessedDocumentCurrentScript: false, + exportNamesByVariable, + format, + freeze, + importAttributesKey, + indent, + pluginDriver, + snippets, + symbols, + useOriginalName: null + }; + + let usesTopLevelAwait = false; + for (const module of orderedModules) { + let renderedLength = 0; + let source: MagicString | undefined; + if (module.isIncluded() || includedNamespaces.has(module)) { + const rendered = module.render(renderOptions); + if ( + !renderOptions.accessedDocumentCurrentScript && + formatsMaybeAccessDocumentCurrentScript.includes(format) + ) { + this.accessedGlobalsByScope.get(module.scope)?.delete(DOCUMENT_CURRENT_SCRIPT); + } + renderOptions.accessedDocumentCurrentScript = false; + ({ source } = rendered); + usesTopLevelAwait ||= rendered.usesTopLevelAwait; + renderedLength = source.length(); + if (renderedLength) { + if (compact && source.lastLine().includes('//')) source.append('\n'); + renderedModuleSources.set(module, source); + magicString.addSource(source); + usedModules.push(module); + } + const namespace = module.namespace; + if (includedNamespaces.has(module)) { + const rendered = namespace.renderBlock(renderOptions); + if (namespace.renderFirst()) hoistedSource += n + rendered; + else magicString.addSource(new MagicString(rendered)); + } + const accessedGlobalVariables = accessedGlobalsByScope.get(module.scope); + if (accessedGlobalVariables) { + for (const name of accessedGlobalVariables) { + accessedGlobals.add(name); } } } - for (const importMeta of module.importMetas) { - importMeta.addAccessedGlobals(this.outputOptions.format, accessedGlobalsByScope); - } + const { renderedExports, removedExports } = module.getRenderedExports(); + renderedModules[module.id] = { + get code() { + return source?.toString() ?? null; + }, + originalLength: module.originalCode.length, + removedExports, + renderedExports, + renderedLength + }; + } + + if (hoistedSource) magicString.prepend(hoistedSource + n + n); + + if (this.needsExportsShim) { + magicString.prepend(`${n}${cnst} ${MISSING_EXPORT_SHIM_VARIABLE}${_}=${_}void 0;${n}${n}`); + } + const renderedSource = compact ? magicString : magicString.trim(); + + if (isEmpty && this.getExportNames().length === 0 && dependencies.size === 0) { + onLog(LOGLEVEL_WARN, logEmptyChunk(this.getChunkName())); } + return { accessedGlobals, indent, magicString, renderedSource, usedModules, usesTopLevelAwait }; } - private setExternalRenderPaths(options: NormalizedOutputOptions, inputBase: string) { - for (const dependency of [...this.dependencies, ...this.dynamicDependencies]) { - if (dependency instanceof ExternalModule) { - dependency.setRenderPath(options, inputBase); + private setDynamicImportResolutions(fileName: string) { + const { accessedGlobalsByScope, outputOptions, pluginDriver, snippets } = this; + for (const resolvedDynamicImport of this.getIncludedDynamicImports()) { + if (resolvedDynamicImport.chunk) { + const { chunk, facadeChunk, node, resolution } = resolvedDynamicImport; + if (chunk === this) { + node.setInternalResolution(resolution.namespace); + } else { + node.setExternalResolution( + (facadeChunk || chunk).exportMode, + outputOptions, + snippets, + pluginDriver, + accessedGlobalsByScope, + `'${(facadeChunk || chunk).getImportPath(fileName)}'`, + !facadeChunk?.strictFacade && chunk.exportNamesByVariable.get(resolution.namespace)![0], + null, + this, + facadeChunk || chunk + ); + } + } else { + const { node, resolution } = resolvedDynamicImport; + const [resolutionString, attributes] = this.getDynamicImportStringAndAttributes( + resolution, + fileName, + node + ); + node.setExternalResolution( + 'external', + outputOptions, + snippets, + pluginDriver, + accessedGlobalsByScope, + resolutionString, + false, + attributes, + this, + null + ); } } } - private setIdentifierRenderResolutions({ - format, - interop, - namespaceToStringTag - }: NormalizedOutputOptions) { + private setIdentifierRenderResolutions() { + const { + format, + generatedCode: { symbols }, + interop, + preserveModules, + externalLiveBindings + } = this.outputOptions; const syntheticExports = new Set(); for (const exportName of this.getExportNames()) { - const exportVariable = this.exportsByName[exportName]; - if (exportVariable instanceof ExportShimVariable) { - this.needsExportsShim = true; - } + const exportVariable = this.exportsByName.get(exportName)!; if ( format !== 'es' && format !== 'system' && @@ -1276,29 +1455,19 @@ export default class Chunk { exportVariable.setRenderNames(null, null); } } - - const usedNames = new Set(['Object', 'Promise']); + for (const module of this.orderedModules) { + if (module.needsExportShim) { + this.needsExportsShim = true; + break; + } + } + const usedNames = new Set(RESERVED_USED_NAMES); if (this.needsExportsShim) { usedNames.add(MISSING_EXPORT_SHIM_VARIABLE); } - if (namespaceToStringTag) { + if (symbols) { usedNames.add('Symbol'); } - switch (format) { - case 'system': - usedNames.add('module').add('exports'); - break; - case 'es': - break; - case 'cjs': - usedNames.add('module').add('require').add('__filename').add('__dirname'); - // fallthrough - default: - usedNames.add('exports'); - for (const helper of HELPER_NAMES) { - usedNames.add(helper); - } - } deconflictChunk( this.orderedModules, @@ -1311,9 +1480,10 @@ export default class Chunk { usedNames, format, interop, - this.outputOptions.preserveModules, - this.outputOptions.externalLiveBindings, + preserveModules, + externalLiveBindings, this.chunkByModule, + this.externalChunkByModule, syntheticExports, this.exportNamesByVariable, this.accessedGlobalsByScope, @@ -1321,15 +1491,31 @@ export default class Chunk { ); } - private setUpChunkImportsAndExportsForModule(module: Module) { - const moduleImports = new Set(module.imports); + private setImportMetaResolutions(fileName: string) { + const { + accessedGlobalsByScope, + includedNamespaces, + orderedModules, + outputOptions: { format } + } = this; + for (const module of orderedModules) { + for (const importMeta of module.importMetas) { + importMeta.setResolution(format, accessedGlobalsByScope, fileName); + } + if (includedNamespaces.has(module)) { + module.namespace.prepare(accessedGlobalsByScope); + } + } + } + + private setUpChunkImportsAndExportsForModule(module: Module): void { + const moduleImports = new Set(module.includedImports); // when we are not preserving modules, we need to make all namespace variables available for // rendering the namespace object - if (!this.outputOptions.preserveModules) { - if (this.includedNamespaces.has(module)) { - const memberVariables = module.namespace.getMemberVariables(); - for (const name of Object.keys(memberVariables)) { - moduleImports.add(memberVariables[name]); + if (!this.outputOptions.preserveModules && this.includedNamespaces.has(module)) { + for (const variable of module.getExportedVariablesByName().values()) { + if (variable.included) { + moduleImports.add(variable); } } } @@ -1343,12 +1529,13 @@ export default class Chunk { const chunk = this.chunkByModule.get(variable.module as Module); if (chunk !== this) { this.imports.add(variable); - if ( - !(variable instanceof NamespaceVariable && this.outputOptions.preserveModules) && - variable.module instanceof Module - ) { - chunk!.exports.add(variable); + if (variable.module instanceof Module) { this.checkCircularDependencyImport(variable, module); + // When preserving modules, we do not create namespace objects but directly + // use the actual namespaces, which would be broken by this logic. + if (!(variable instanceof NamespaceVariable && this.outputOptions.preserveModules)) { + chunk!.exports.add(variable); + } } } } @@ -1359,9 +1546,11 @@ export default class Chunk { ) { this.ensureReexportsAreAvailableForModule(module); } - for (const { node, resolution } of module.dynamicImports) { + for (const { + node: { included, resolution } + } of module.dynamicImports) { if ( - node.included && + included && resolution instanceof Module && this.chunkByModule.get(resolution) === this && !this.includedNamespaces.has(resolution) @@ -1374,5 +1563,37 @@ export default class Chunk { } function getChunkNameFromModule(module: Module): string { - return module.chunkName || getAliasName(module.id); + return getPredefinedChunkNameFromModule(module) ?? getAliasName(module.id); +} + +function getPredefinedChunkNameFromModule(module: Module): string { + return ( + module.chunkNames.find(({ isUserDefined }) => isUserDefined)?.name ?? module.chunkNames[0]?.name + ); +} + +function getImportedBindingsPerDependency( + renderedDependencies: RenderedDependencies, + resolveFileName: (dependency: Chunk | ExternalChunk) => string +): Record { + const importedBindingsPerDependency: Record = {}; + for (const [dependency, declaration] of renderedDependencies) { + const specifiers = new Set(); + if (declaration.imports) { + for (const { imported } of declaration.imports) { + specifiers.add(imported); + } + } + if (declaration.reexports) { + for (const { imported } of declaration.reexports) { + specifiers.add(imported); + } + } + importedBindingsPerDependency[resolveFileName(dependency)] = [...specifiers]; + } + return importedBindingsPerDependency; } + +const QUERY_HASH_REGEX = /[#?]/; + +const resolveFileName = (dependency: Chunk | ExternalChunk): string => dependency.getFileName(); diff --git a/src/ExternalChunk.ts b/src/ExternalChunk.ts new file mode 100644 index 00000000000..24583fdffae --- /dev/null +++ b/src/ExternalChunk.ts @@ -0,0 +1,73 @@ +import type ExternalModule from './ExternalModule'; +import type { ModuleInfo, NormalizedOutputOptions } from './rollup/types'; +import { escapeId } from './utils/escapeId'; +import type { GenerateCodeSnippets } from './utils/generateCodeSnippets'; +import { normalize, relative } from './utils/path'; +import { getImportPath } from './utils/relativeId'; + +export default class ExternalChunk { + defaultVariableName = ''; + id: string; + namespaceVariableName = ''; + suggestedVariableName: string; + variableName = ''; + + private fileName: string | null = null; + private importAttributes: string | null = null; + private moduleInfo: ModuleInfo; + private renormalizeRenderPath: boolean; + + constructor( + module: ExternalModule, + private options: NormalizedOutputOptions, + private inputBase: string + ) { + this.id = module.id; + this.moduleInfo = module.info; + this.renormalizeRenderPath = module.renormalizeRenderPath; + this.suggestedVariableName = module.suggestedVariableName; + } + + getFileName(): string { + if (this.fileName) { + return this.fileName; + } + const { paths } = this.options; + return (this.fileName = + (typeof paths === 'function' ? paths(this.id) : paths[this.id]) || + (this.renormalizeRenderPath ? normalize(relative(this.inputBase, this.id)) : this.id)); + } + + getImportAttributes(snippets: GenerateCodeSnippets): string | null { + return (this.importAttributes ||= formatAttributes( + ['es', 'cjs'].includes(this.options.format) && + this.options.externalImportAttributes && + this.moduleInfo.attributes, + snippets + )); + } + + getImportPath(importer: string): string { + return escapeId( + this.renormalizeRenderPath + ? getImportPath(importer, this.getFileName(), this.options.format === 'amd', false) + : this.getFileName() + ); + } +} + +export function formatAttributes( + attributes: Record | null | void | false, + { getObject }: GenerateCodeSnippets +): string | null { + if (!attributes) { + return null; + } + const assertionEntries: [key: string, value: string][] = Object.entries(attributes).map( + ([key, value]) => [key, `'${value}'`] + ); + if (assertionEntries.length > 0) { + return getObject(assertionEntries, { lineBreakIndent: null }); + } + return null; +} diff --git a/src/ExternalModule.ts b/src/ExternalModule.ts index 0b81685625a..edee69e61a1 100644 --- a/src/ExternalModule.ts +++ b/src/ExternalModule.ts @@ -1,120 +1,117 @@ import ExternalVariable from './ast/variables/ExternalVariable'; -import { - CustomPluginOptions, - ModuleInfo, - NormalizedInputOptions, - NormalizedOutputOptions -} from './rollup/types'; +import type { CustomPluginOptions, ModuleInfo, NormalizedInputOptions } from './rollup/types'; import { EMPTY_ARRAY } from './utils/blank'; +import { getNewSet, getOrCreate } from './utils/getOrCreate'; +import { cacheObjectGetters } from './utils/getter'; import { makeLegal } from './utils/identifierHelpers'; -import { normalize, relative } from './utils/path'; +import { LOGLEVEL_WARN } from './utils/logging'; +import { logUnusedExternalImports } from './utils/logs'; export default class ExternalModule { - chunk: void; - declarations: { [name: string]: ExternalVariable }; - defaultVariableName = ''; - dynamicImporters: string[] = []; - execIndex: number; - exportedVariables: Map; - importers: string[] = []; - info: ModuleInfo; - mostCommonSuggestion = 0; - namespaceVariableName = ''; - nameSuggestions: { [name: string]: number }; + readonly dynamicImporters: string[] = []; + execIndex = Infinity; + readonly exportedVariables = new Map(); + readonly importers: string[] = []; + readonly info: ModuleInfo; reexported = false; - renderPath: string = undefined as any; suggestedVariableName: string; used = false; - variableName = ''; + + private readonly declarations = new Map(); + private readonly importersByExportedName = new Map>(); + private mostCommonSuggestion = 0; + private readonly nameSuggestions = new Map(); constructor( private readonly options: NormalizedInputOptions, public readonly id: string, - hasModuleSideEffects: boolean | 'no-treeshake', + moduleSideEffects: boolean | 'no-treeshake', meta: CustomPluginOptions, - public renormalizeRenderPath: boolean + public readonly renormalizeRenderPath: boolean, + attributes: Record ) { - this.execIndex = Infinity; - this.suggestedVariableName = makeLegal(id.split(/[\\/]/).pop()!); - this.nameSuggestions = Object.create(null); - this.declarations = Object.create(null); - this.exportedVariables = new Map(); + this.suggestedVariableName = makeLegal(id.split(/[/\\]/).pop()!); - const module = this; + const { importers, dynamicImporters } = this; this.info = { ast: null, + attributes, code: null, + dynamicallyImportedIdResolutions: EMPTY_ARRAY, dynamicallyImportedIds: EMPTY_ARRAY, get dynamicImporters() { - return module.dynamicImporters.sort(); + return dynamicImporters.sort(); }, - hasModuleSideEffects, + exportedBindings: null, + exports: null, + hasDefaultExport: null, id, implicitlyLoadedAfterOneOf: EMPTY_ARRAY, implicitlyLoadedBefore: EMPTY_ARRAY, + importedIdResolutions: EMPTY_ARRAY, importedIds: EMPTY_ARRAY, get importers() { - return module.importers.sort(); + return importers.sort(); }, isEntry: false, isExternal: true, + isIncluded: null, meta, + moduleSideEffects, + safeVariableNames: null, syntheticNamedExports: false }; } - getVariableForExportName(name: string): ExternalVariable { - let declaration = this.declarations[name]; - if (declaration) return declaration; - - this.declarations[name] = declaration = new ExternalVariable(this, name); - this.exportedVariables.set(declaration, name); - return declaration; + cacheInfoGetters(): void { + cacheObjectGetters(this.info, ['dynamicImporters', 'importers']); } - setRenderPath(options: NormalizedOutputOptions, inputBase: string) { - this.renderPath = - typeof options.paths === 'function' ? options.paths(this.id) : options.paths[this.id]; - if (!this.renderPath) { - this.renderPath = this.renormalizeRenderPath - ? normalize(relative(inputBase, this.id)) - : this.id; + getVariableForExportName( + name: string, + { importChain }: { importChain: string[] } + ): [variable: ExternalVariable] { + const declaration = this.declarations.get(name); + for (const module of importChain) { + getOrCreate(this.importersByExportedName, name, getNewSet).add(module); } - return this.renderPath; + if (declaration) return [declaration]; + const externalVariable = new ExternalVariable(this, name); + + this.declarations.set(name, externalVariable); + this.exportedVariables.set(externalVariable, name); + return [externalVariable]; } - suggestName(name: string) { - if (!this.nameSuggestions[name]) this.nameSuggestions[name] = 0; - this.nameSuggestions[name] += 1; + suggestName(name: string): void { + const value = (this.nameSuggestions.get(name) ?? 0) + 1; + this.nameSuggestions.set(name, value); - if (this.nameSuggestions[name] > this.mostCommonSuggestion) { - this.mostCommonSuggestion = this.nameSuggestions[name]; + if (value > this.mostCommonSuggestion) { + this.mostCommonSuggestion = value; this.suggestedVariableName = name; } } - warnUnusedImports() { - const unused = Object.keys(this.declarations).filter(name => { - if (name === '*') return false; - const declaration = this.declarations[name]; - return !declaration.included && !this.reexported && !declaration.referenced; - }); + warnUnusedImports(): void { + const unused = [...this.declarations] + .filter( + ([name, declaration]) => + name !== '*' && !declaration.included && !this.reexported && !declaration.referenced + ) + .map(([name]) => name); if (unused.length === 0) return; - const names = - unused.length === 1 - ? `'${unused[0]}' is` - : `${unused - .slice(0, -1) - .map(name => `'${name}'`) - .join(', ')} and '${unused.slice(-1)}' are`; - - this.options.onwarn({ - code: 'UNUSED_EXTERNAL_IMPORT', - message: `${names} imported from external module '${this.id}' but never used`, - names: unused, - source: this.id - }); + const importersSet = new Set(); + for (const name of unused) { + const importersOfName = this.importersByExportedName.get(name); + for (const importer of this.importers) { + if (!importersOfName?.has(importer)) continue; + importersSet.add(importer); + } + } + const importersArray = [...importersSet]; + this.options.onLog(LOGLEVEL_WARN, logUnusedExternalImports(this.id, unused, importersArray)); } } diff --git a/src/Graph.ts b/src/Graph.ts index 847b9b67d70..58ca3418d29 100644 --- a/src/Graph.ts +++ b/src/Graph.ts @@ -1,29 +1,39 @@ -import * as acorn from 'acorn'; +import flru from 'flru'; +import { createInclusionContext } from './ast/ExecutionContext'; +import type { ExpressionEntity } from './ast/nodes/shared/Expression'; import GlobalScope from './ast/scopes/GlobalScope'; -import { PathTracker } from './ast/utils/PathTracker'; -import ExternalModule from './ExternalModule'; +import { EntityPathTracker } from './ast/utils/PathTracker'; +import type ExternalModule from './ExternalModule'; import Module from './Module'; -import { ModuleLoader, UnresolvedModule } from './ModuleLoader'; -import { +import { ModuleLoader, type UnresolvedModule } from './ModuleLoader'; +import type { ModuleInfo, ModuleJSON, NormalizedInputOptions, + ProgramNode, RollupCache, RollupWatcher, SerializablePluginCache, WatchChangeHook } from './rollup/types'; import { BuildPhase } from './utils/buildPhase'; -import { errImplicitDependantIsNotIncluded, error } from './utils/error'; import { analyseModuleExecution } from './utils/executionOrder'; +import { LOGLEVEL_WARN } from './utils/logging'; +import { + error, + logCircularDependency, + logImplicitDependantIsNotIncluded, + logMissingExport +} from './utils/logs'; import { PluginDriver } from './utils/PluginDriver'; -import { markPureCallExpressions } from './utils/pureComments'; -import relativeId from './utils/relativeId'; +import type { PureFunctions } from './utils/pureFunctions'; +import { getPureFunctions } from './utils/pureFunctions'; +import Queue from './utils/Queue'; import { timeEnd, timeStart } from './utils/timers'; import { markModuleAndImpureDependenciesAsExecuted } from './utils/traverseStaticDependencies'; function normalizeEntryModules( - entryModules: string[] | Record + entryModules: readonly string[] | Record ): UnresolvedModule[] { if (Array.isArray(entryModules)) { return entryModules.map(id => ({ @@ -34,9 +44,9 @@ function normalizeEntryModules( name: null })); } - return Object.keys(entryModules).map(name => ({ + return Object.entries(entryModules).map(([name, id]) => ({ fileName: null, - id: entryModules[name], + id, implicitlyLoadedAfter: [], importer: undefined, name @@ -44,27 +54,31 @@ function normalizeEntryModules( } export default class Graph { - acornParser: typeof acorn.Parser; - cachedModules: Map; - deoptimizationTracker: PathTracker; + readonly astLru = flru(5); + readonly cachedModules = new Map(); + readonly deoptimizationTracker = new EntityPathTracker(); entryModules: Module[] = []; - moduleLoader: ModuleLoader; - modulesById = new Map(); + readonly fileOperationQueue: Queue; + readonly moduleLoader: ModuleLoader; + readonly modulesById = new Map(); needsTreeshakingPass = false; + readonly newlyIncludedVariableInits = new Set(); phase: BuildPhase = BuildPhase.LOAD_AND_PARSE; - pluginDriver: PluginDriver; - scope: GlobalScope; - watchFiles: Record = Object.create(null); + readonly pluginDriver: PluginDriver; + readonly pureFunctions: PureFunctions; + readonly scope = new GlobalScope(); + readonly watchFiles: Record = Object.create(null); watchMode = false; - private externalModules: ExternalModule[] = []; + private readonly externalModules: ExternalModule[] = []; private implicitEntryModules: Module[] = []; private modules: Module[] = []; - private pluginCache?: Record; + declare private pluginCache?: Record; - constructor(private readonly options: NormalizedInputOptions, watcher: RollupWatcher | null) { - this.deoptimizationTracker = new PathTracker(); - this.cachedModules = new Map(); + constructor( + private readonly options: NormalizedInputOptions, + watcher: RollupWatcher | null + ) { if (options.cache !== false) { if (options.cache?.modules) { for (const module of options.cache.modules) this.cachedModules.set(module.id, module); @@ -74,25 +88,22 @@ export default class Graph { // increment access counter for (const name in this.pluginCache) { const cache = this.pluginCache[name]; - for (const key of Object.keys(cache)) cache[key][0]++; + for (const value of Object.values(cache)) value[0]++; } } if (watcher) { this.watchMode = true; - const handleChange: WatchChangeHook = (...args) => this.pluginDriver.hookSeqSync('watchChange', args); - const handleClose = () => this.pluginDriver.hookSeqSync('closeWatcher', []); - watcher.on('change', handleChange); - watcher.on('close', handleClose); - watcher.once('restart', () => { - watcher.removeListener('change', handleChange); - watcher.removeListener('close', handleClose); - }); + const handleChange = (...parameters: Parameters) => + this.pluginDriver.hookParallel('watchChange', parameters); + const handleClose = () => this.pluginDriver.hookParallel('closeWatcher', []); + watcher.onCurrentRun('change', handleChange); + watcher.onCurrentRun('close', handleClose); } this.pluginDriver = new PluginDriver(this, options, options.plugins, this.pluginCache); - this.scope = new GlobalScope(); - this.acornParser = acorn.Parser.extend(...(options.acornInjectPlugins as any)); this.moduleLoader = new ModuleLoader(this, this.modulesById, this.options, this.pluginDriver); + this.fileOperationQueue = new Queue(options.maxParallelFileOps); + this.pureFunctions = getPureFunctions(options); } async build(): Promise { @@ -100,10 +111,10 @@ export default class Graph { await this.generateModuleGraph(); timeEnd('generate module graph', 2); - timeStart('sort modules', 2); + timeStart('sort and bind modules', 2); this.phase = BuildPhase.ANALYSE; - this.sortModules(); - timeEnd('sort modules', 2); + this.sortAndBindModules(); + timeEnd('sort and bind modules', 2); timeStart('mark included statements', 2); this.includeStatements(); @@ -112,42 +123,13 @@ export default class Graph { this.phase = BuildPhase.GENERATE; } - contextParse(code: string, options: Partial = {}) { - const onCommentOrig = options.onComment; - const comments: acorn.Comment[] = []; - - if (onCommentOrig && typeof onCommentOrig == 'function') { - options.onComment = (block, text, start, end, ...args) => { - comments.push({type: block ? "Block" : "Line", value: text, start, end}); - return onCommentOrig.call(options, block, text, start, end, ...args); - } - } else { - options.onComment = comments; - } - - const ast = this.acornParser.parse(code, { - ...(this.options.acorn as acorn.Options), - ...options - }); - - if (typeof onCommentOrig == 'object') { - onCommentOrig.push(...comments); - } - - options.onComment = onCommentOrig; - - markPureCallExpressions(comments, ast); - - return ast; - } - getCache(): RollupCache { // handle plugin cache eviction for (const name in this.pluginCache) { const cache = this.pluginCache[name]; let allDeleted = true; - for (const key of Object.keys(cache)) { - if (cache[key][0] >= this.options.experimentalCacheExpiry) delete cache[key]; + for (const [key, value] of Object.entries(cache)) { + if (value[0] >= this.options.experimentalCacheExpiry) delete cache[key]; else allDeleted = false; } if (allDeleted) delete this.pluginCache[name]; @@ -166,14 +148,13 @@ export default class Graph { }; private async generateModuleGraph(): Promise { - ({ - entryModules: this.entryModules, - implicitEntryModules: this.implicitEntryModules - } = await this.moduleLoader.addEntryModules(normalizeEntryModules(this.options.input), true)); + ({ entryModules: this.entryModules, implicitEntryModules: this.implicitEntryModules } = + await this.moduleLoader.addEntryModules(normalizeEntryModules(this.options.input), true)); if (this.entryModules.length === 0) { throw new Error('You must supply options.input to rollup'); } for (const module of this.modulesById.values()) { + module.cacheInfoGetters(); if (module instanceof Module) { this.modules.push(module); } else { @@ -182,26 +163,39 @@ export default class Graph { } } - private includeStatements() { - for (const module of [...this.entryModules, ...this.implicitEntryModules]) { - if (module.preserveSignature !== false) { - module.includeAllExports(false); - } else { - markModuleAndImpureDependenciesAsExecuted(module); - } + private includeStatements(): void { + const entryModules = [...this.entryModules, ...this.implicitEntryModules]; + for (const module of entryModules) { + markModuleAndImpureDependenciesAsExecuted(module); } if (this.options.treeshake) { let treeshakingPass = 1; + this.newlyIncludedVariableInits.clear(); do { timeStart(`treeshaking pass ${treeshakingPass}`, 3); this.needsTreeshakingPass = false; for (const module of this.modules) { if (module.isExecuted) { - if (module.info.hasModuleSideEffects === 'no-treeshake') { + module.hasTreeShakingPassStarted = true; + if (module.info.moduleSideEffects === 'no-treeshake') { module.includeAllInBundle(); } else { module.include(); } + for (const entity of this.newlyIncludedVariableInits) { + this.newlyIncludedVariableInits.delete(entity); + entity.include(createInclusionContext(), false); + } + } + } + if (treeshakingPass === 1) { + // We only include exports after the first pass to avoid issues with + // the TDZ detection logic + for (const module of entryModules) { + if (module.preserveSignature !== false) { + module.includeAllExports(); + this.needsTreeshakingPass = true; + } } } timeEnd(`treeshaking pass ${treeshakingPass++}`, 3); @@ -213,21 +207,16 @@ export default class Graph { for (const module of this.implicitEntryModules) { for (const dependant of module.implicitlyLoadedAfter) { if (!(dependant.info.isEntry || dependant.isIncluded())) { - error(errImplicitDependantIsNotIncluded(dependant)); + error(logImplicitDependantIsNotIncluded(dependant)); } } } } - private sortModules() { + private sortAndBindModules(): void { const { orderedModules, cyclePaths } = analyseModuleExecution(this.entryModules); for (const cyclePath of cyclePaths) { - this.options.onwarn({ - code: 'CIRCULAR_DEPENDENCY', - cycle: cyclePath, - importer: cyclePath[0], - message: `Circular dependency: ${cyclePath.join(' -> ')}` - }); + this.options.onLog(LOGLEVEL_WARN, logCircularDependency(cyclePath)); } this.modules = orderedModules; for (const module of this.modules) { @@ -236,25 +225,26 @@ export default class Graph { this.warnForMissingExports(); } - private warnForMissingExports() { + private warnForMissingExports(): void { for (const module of this.modules) { - for (const importName of Object.keys(module.importDescriptions)) { - const importDescription = module.importDescriptions[importName]; - if ( - importDescription.name !== '*' && - !(importDescription.module as Module).getVariableForExportName(importDescription.name) - ) { - module.warn( - { - code: 'NON_EXISTENT_EXPORT', - message: `Non-existent export '${ - importDescription.name - }' is imported from ${relativeId((importDescription.module as Module).id)}`, - name: importDescription.name, - source: (importDescription.module as Module).id - }, - importDescription.start + for (const importDescription of module.importDescriptions.values()) { + if (importDescription.name !== '*') { + const [variable, options] = importDescription.module.getVariableForExportName( + importDescription.name, + { importChain: [module.id] } ); + if (!variable) { + module.log( + LOGLEVEL_WARN, + logMissingExport( + importDescription.name, + module.id, + importDescription.module.id, + !!options?.missingButExportExists + ), + importDescription.start + ); + } } } } diff --git a/src/Module.ts b/src/Module.ts index 328202c6488..13aba84a761 100644 --- a/src/Module.ts +++ b/src/Module.ts @@ -1,71 +1,97 @@ -import * as acorn from 'acorn'; +import { extractAssignedNames } from '@rollup/pluginutils'; import { locate } from 'locate-character'; import MagicString from 'magic-string'; -import extractAssignedNames from 'rollup-pluginutils/src/extractAssignedNames'; -import { createHasEffectsContext, createInclusionContext } from './ast/ExecutionContext'; +import { parseAsync } from '../native'; +import { convertProgram } from './ast/bufferParsers'; +import type { InclusionContext } from './ast/ExecutionContext'; +import { createInclusionContext } from './ast/ExecutionContext'; +import { nodeConstructors } from './ast/nodes'; import ExportAllDeclaration from './ast/nodes/ExportAllDeclaration'; import ExportDefaultDeclaration from './ast/nodes/ExportDefaultDeclaration'; -import ExportNamedDeclaration from './ast/nodes/ExportNamedDeclaration'; +import type ExportNamedDeclaration from './ast/nodes/ExportNamedDeclaration'; import Identifier from './ast/nodes/Identifier'; -import ImportDeclaration from './ast/nodes/ImportDeclaration'; -import ImportExpression from './ast/nodes/ImportExpression'; -import ImportSpecifier from './ast/nodes/ImportSpecifier'; -import { nodeConstructors } from './ast/nodes/index'; +import type ImportDeclaration from './ast/nodes/ImportDeclaration'; +import ImportDefaultSpecifier from './ast/nodes/ImportDefaultSpecifier'; +import type ImportExpression from './ast/nodes/ImportExpression'; +import ImportNamespaceSpecifier from './ast/nodes/ImportNamespaceSpecifier'; import Literal from './ast/nodes/Literal'; -import MetaProperty from './ast/nodes/MetaProperty'; +import type MetaProperty from './ast/nodes/MetaProperty'; import * as NodeType from './ast/nodes/NodeType'; -import Program from './ast/nodes/Program'; -import { ExpressionNode, GenericEsTreeNode, NodeBase } from './ast/nodes/shared/Node'; -import TemplateLiteral from './ast/nodes/TemplateLiteral'; +import type Program from './ast/nodes/Program'; +import type { ExpressionEntity } from './ast/nodes/shared/Expression'; +import type { NodeBase } from './ast/nodes/shared/Node'; import VariableDeclaration from './ast/nodes/VariableDeclaration'; import ModuleScope from './ast/scopes/ModuleScope'; -import { PathTracker, UNKNOWN_PATH } from './ast/utils/PathTracker'; +import type { ObjectPath } from './ast/utils/PathTracker'; +import { type EntityPathTracker, UNKNOWN_PATH } from './ast/utils/PathTracker'; import ExportDefaultVariable from './ast/variables/ExportDefaultVariable'; import ExportShimVariable from './ast/variables/ExportShimVariable'; import ExternalVariable from './ast/variables/ExternalVariable'; import NamespaceVariable from './ast/variables/NamespaceVariable'; import SyntheticNamedExportVariable from './ast/variables/SyntheticNamedExportVariable'; -import Variable from './ast/variables/Variable'; +import type Variable from './ast/variables/Variable'; import ExternalModule from './ExternalModule'; -import Graph from './Graph'; -import { +import type Graph from './Graph'; +import type { + AstNode, CustomPluginOptions, DecodedSourceMapOrMissing, EmittedFile, ExistingDecodedSourceMap, + LogLevel, ModuleInfo, ModuleJSON, ModuleOptions, NormalizedInputOptions, PartialNull, PreserveEntrySignaturesOption, + ResolvedId, ResolvedIdMap, RollupError, - RollupLogProps, - RollupWarning, + RollupLog, TransformModuleJSON } from './rollup/types'; -import { - augmentCodeLocation, - errCircularReexport, - errMissingExport, - errNamespaceConflict, - error, - errSyntheticNamedExportsNeedNamespaceExport -} from './utils/error'; +import { EMPTY_OBJECT } from './utils/blank'; +import type { LiteralStringNode, TemplateLiteralNode } from './utils/bufferToAst'; +import { BuildPhase } from './utils/buildPhase'; +import { decodedSourcemap, resetSourcemapCache } from './utils/decodedSourcemap'; import { getId } from './utils/getId'; -import { getOrCreate } from './utils/getOrCreate'; +import { getNewSet, getOrCreate } from './utils/getOrCreate'; import { getOriginalLocation } from './utils/getOriginalLocation'; +import { cacheObjectGetters } from './utils/getter'; import { makeLegal } from './utils/identifierHelpers'; +import { LOGLEVEL_WARN } from './utils/logging'; +import { + augmentCodeLocation, + error, + logAmbiguousExternalNamespaces, + logCircularReexport, + logDuplicateExportError, + logInconsistentImportAttributes, + logInvalidFormatForTopLevelAwait, + logInvalidSourcemapForError, + logMissingEntryExport, + logMissingExport, + logMissingJsxExport, + logModuleParseError, + logNamespaceConflict, + logRedeclarationError, + logShimmedExport, + logSyntheticNamedExportsNeedNamespaceExport +} from './utils/logs'; +import { parseAst } from './utils/parseAst'; +import { + doAttributesDiffer, + getAttributesFromImportExportDeclaration +} from './utils/parseImportAttributes'; import { basename, extname } from './utils/path'; -import relativeId from './utils/relativeId'; -import { RenderOptions } from './utils/renderHelpers'; -import { SOURCEMAPPING_URL_COMMENT_RE } from './utils/sourceMappingURL'; +import type { PureFunctions } from './utils/pureFunctions'; +import type { RenderOptions } from './utils/renderHelpers'; import { timeEnd, timeStart } from './utils/timers'; import { markModuleAndImpureDependenciesAsExecuted } from './utils/traverseStaticDependencies'; import { MISSING_EXPORT_SHIM_VARIABLE } from './utils/variableNames'; -interface ImportDescription { +export interface ImportDescription { module: Module | ExternalModule; name: string; source: string; @@ -91,27 +117,39 @@ export interface AstContext { ) => void; addImport: (node: ImportDeclaration) => void; addImportMeta: (node: MetaProperty) => void; + addImportSource: (importSource: string) => void; code: string; - deoptimizationTracker: PathTracker; - error: (props: RollupError, pos: number) => never; + deoptimizationTracker: EntityPathTracker; + error: (properties: RollupLog, pos: number) => never; fileName: string; - getExports: () => string[]; + getImportedJsxFactoryVariable: (baseName: string, pos: number, importSource: string) => Variable; getModuleExecIndex: () => number; getModuleName: () => string; - getReexports: () => string[]; - importDescriptions: { [name: string]: ImportDescription }; - includeAllExports: () => void; + getNodeConstructor: (name: string) => typeof NodeBase; + importDescriptions: Map; includeDynamicImport: (node: ImportExpression) => void; - includeVariableInModule: (variable: Variable) => void; + includeVariableInModule: ( + variable: Variable, + path: ObjectPath, + context: InclusionContext + ) => void; + log: (level: LogLevel, properties: RollupLog, pos: number) => void; magicString: MagicString; + manualPureFunctions: PureFunctions; module: Module; // not to be used for tree-shaking moduleContext: string; - nodeConstructors: { [name: string]: typeof NodeBase }; + newlyIncludedVariableInits: Set; options: NormalizedInputOptions; - traceExport: (name: string) => Variable | null; + requestTreeshakingPass: () => void; + traceExport: (name: string) => [variable: Variable | null, options?: VariableOptions]; traceVariable: (name: string) => Variable | null; usesTopLevelAwait: boolean; - warn: (warning: RollupWarning, pos: number) => void; +} + +export interface DynamicImport { + argument: string | AstNode; + id: string | null; + node: ImportExpression; } const MISSING_EXPORT_SHIM_DESCRIPTION: ExportDescription = { @@ -119,60 +157,36 @@ const MISSING_EXPORT_SHIM_DESCRIPTION: ExportDescription = { localName: MISSING_EXPORT_SHIM_VARIABLE }; -function findSourceMappingURLComments(ast: acorn.Node, code: string): [number, number][] { - const ret: [number, number][] = []; - - const addCommentsPos = (start: number, end: number): void => { - if (start == end) { - return; - } - - let sourcemappingUrlMatch; - const interStatmentCode = code.slice(start, end); - while (sourcemappingUrlMatch = SOURCEMAPPING_URL_COMMENT_RE.exec(interStatmentCode)) { - ret.push([start + sourcemappingUrlMatch.index, start + SOURCEMAPPING_URL_COMMENT_RE.lastIndex]); - } - }; - - let prevStmtEnd = 0; - for (const stmt of (ast as GenericEsTreeNode).body) { - addCommentsPos(prevStmtEnd, stmt.start); - prevStmtEnd = stmt.end; - } - addCommentsPos(prevStmtEnd, code.length); - - return ret; -} - function getVariableForExportNameRecursive( target: Module | ExternalModule, name: string, importerForSideEffects: Module | undefined, - isExportAllSearch: boolean, - searchedNamesAndModules = new Map>() -): Variable | null { + isExportAllSearch: boolean | undefined, + searchedNamesAndModules = new Map>(), + importChain: string[] +): [variable: Variable | null, options?: VariableOptions] { const searchedModules = searchedNamesAndModules.get(name); if (searchedModules) { if (searchedModules.has(target)) { - return isExportAllSearch ? null : error(errCircularReexport(name, target.id)); + return isExportAllSearch ? [null] : error(logCircularReexport(name, target.id)); } searchedModules.add(target); } else { searchedNamesAndModules.set(name, new Set([target])); } - return target.getVariableForExportName( - name, + return target.getVariableForExportName(name, { + importChain, importerForSideEffects, isExportAllSearch, searchedNamesAndModules - ); + }); } function getAndExtendSideEffectModules(variable: Variable, module: Module): Set { const sideEffectModules = getOrCreate( module.sideEffectDependenciesByVariable, variable, - () => new Set() + getNewSet ); let currentVariable: Variable | null = variable; const referencedVariables = new Set([currentVariable]); @@ -182,16 +196,15 @@ function getAndExtendSideEffectModules(variable: Variable, module: Module): Set< currentVariable instanceof ExportDefaultVariable ? currentVariable.getDirectOriginalVariable() : currentVariable instanceof SyntheticNamedExportVariable - ? currentVariable.syntheticNamespace - : null; + ? currentVariable.syntheticNamespace + : null; if (!currentVariable || referencedVariables.has(currentVariable)) { break; } referencedVariables.add(currentVariable); sideEffectModules.add(importingModule); - const originalSideEffects = importingModule.sideEffectDependenciesByVariable.get( - currentVariable - ); + const originalSideEffects = + importingModule.sideEffectDependenciesByVariable.get(currentVariable); if (originalSideEffects) { for (const module of originalSideEffects) { sideEffectModules.add(module); @@ -202,169 +215,243 @@ function getAndExtendSideEffectModules(variable: Variable, module: Module): Set< } export default class Module { - alternativeReexportModules = new Map(); - ast: Program | null = null; - chunkFileNames = new Set(); - chunkName: string | null = null; - cycles = new Set(); - dependencies = new Set(); - dynamicDependencies = new Set(); - dynamicImporters: string[] = []; - dynamicImports: { - argument: string | ExpressionNode; - node: ImportExpression; - resolution: Module | ExternalModule | string | null; + readonly alternativeReexportModules = new Map(); + readonly chunkFileNames = new Set(); + chunkNames: { + isUserDefined: boolean; + name: string; + priority: number; }[] = []; + readonly cycles = new Set(); + readonly dependencies = new Set(); + readonly dynamicDependencies = new Set(); + readonly dynamicImporters: string[] = []; + readonly dynamicImports: DynamicImport[] = []; excludeFromSourcemap: boolean; execIndex = Infinity; - exportAllSources = new Set(); - exports: { [name: string]: ExportDescription } = Object.create(null); - exportsAll: { [name: string]: string } = Object.create(null); - implicitlyLoadedAfter = new Set(); - implicitlyLoadedBefore = new Set(); - importDescriptions: { [name: string]: ImportDescription } = Object.create(null); - importers: string[] = []; - importMetas: MetaProperty[] = []; - imports = new Set(); - includedDynamicImporters: Module[] = []; - info: ModuleInfo; + hasTreeShakingPassStarted = false; + readonly implicitlyLoadedAfter = new Set(); + readonly implicitlyLoadedBefore = new Set(); + readonly importDescriptions = new Map(); + readonly importMetas: MetaProperty[] = []; + importedFromNotTreeshaken = false; + shebang: undefined | string; + readonly importers: string[] = []; + readonly includedDynamicImporters: Module[] = []; + readonly includedTopLevelAwaitingDynamicImporters = new Set(); + readonly includedImports = new Set(); + readonly info: ModuleInfo; isExecuted = false; isUserDefinedEntryPoint = false; - namespace!: NamespaceVariable; - originalCode!: string; - originalSourcemap!: ExistingDecodedSourceMap | null; - preserveSignature: PreserveEntrySignaturesOption = this.options.preserveEntrySignatures; - reexportDescriptions: { [name: string]: ReexportDescription } = Object.create(null); - resolvedIds!: ResolvedIdMap; - scope!: ModuleScope; - sideEffectDependenciesByVariable = new Map>(); - sourcemapChain!: DecodedSourceMapOrMissing[]; - sources = new Set(); - transformFiles?: EmittedFile[]; - userChunkNames = new Set(); - usesTopLevelAwait = false; - - private allExportNames: Set | null = null; - private alwaysRemovedCode!: [number, number][]; - private astContext!: AstContext; + declare magicString: MagicString; + declare namespace: NamespaceVariable; + needsExportShim = false; + declare originalCode: string; + declare originalSourcemap: ExistingDecodedSourceMap | null; + preserveSignature: PreserveEntrySignaturesOption; + declare resolvedIds: ResolvedIdMap; + declare scope: ModuleScope; + readonly sideEffectDependenciesByVariable = new Map>(); + declare sourcemapChain: DecodedSourceMapOrMissing[]; + readonly sourcesWithAttributes = new Map>(); + declare transformFiles?: EmittedFile[]; + + private allExportsIncluded = false; + private ast: Program | null = null; + declare private astContext: AstContext; private readonly context: string; - private customTransformCache!: boolean; - private exportAllModules: (Module | ExternalModule)[] = []; + declare private customTransformCache: boolean; + private readonly exportAllModules: (Module | ExternalModule)[] = []; + private readonly exportAllSources = new Set(); + private readonly exportDescriptions = new Map(); + private exportedVariablesByName: Map | null = null; private exportNamesByVariable: Map | null = null; - private exportShimVariable: ExportShimVariable = new ExportShimVariable(this); - private magicString!: MagicString; + private readonly exportShimVariable = new ExportShimVariable(this); + private readonly namespaceReexportsByName = new Map< + string, + [variable: Variable | null, options?: VariableOptions] + >(); + private readonly reexportDescriptions = new Map(); private relevantDependencies: Set | null = null; - private syntheticExports = new Map(); + private readonly syntheticExports = new Map(); private syntheticNamespace: Variable | null | undefined = null; private transformDependencies: string[] = []; - private transitiveReexports: string[] | null = null; constructor( private readonly graph: Graph, public readonly id: string, private readonly options: NormalizedInputOptions, isEntry: boolean, - hasModuleSideEffects: boolean | 'no-treeshake', + moduleSideEffects: boolean | 'no-treeshake', syntheticNamedExports: boolean | string, - meta: CustomPluginOptions + meta: CustomPluginOptions, + attributes: Record ) { this.excludeFromSourcemap = /\0/.test(id); this.context = options.moduleContext(id); + this.preserveSignature = this.options.preserveEntrySignatures; + // eslint-disable-next-line @typescript-eslint/no-this-alias const module = this; + const { + dynamicImports, + dynamicImporters, + exportAllSources, + exportDescriptions, + implicitlyLoadedAfter, + implicitlyLoadedBefore, + importers, + reexportDescriptions, + sourcesWithAttributes + } = this; + this.info = { ast: null, + attributes, code: null, + get dynamicallyImportedIdResolutions() { + return dynamicImports + .map(({ argument }) => typeof argument === 'string' && module.resolvedIds[argument]) + .filter(Boolean) as ResolvedId[]; + }, get dynamicallyImportedIds() { - const dynamicallyImportedIds: string[] = []; - for (const { resolution } of module.dynamicImports) { - if (resolution instanceof Module || resolution instanceof ExternalModule) { - dynamicallyImportedIds.push(resolution.id); - } - } - return dynamicallyImportedIds; + // We cannot use this.dynamicDependencies because this is needed before + // dynamicDependencies are populated + return dynamicImports.map(({ id }) => id).filter((id): id is string => id != null); }, get dynamicImporters() { - return module.dynamicImporters.sort(); + return dynamicImporters.sort(); + }, + get exportedBindings() { + const exportBindings: Record = { '.': [...exportDescriptions.keys()] }; + + for (const [name, { source }] of reexportDescriptions) { + (exportBindings[source] ??= []).push(name); + } + + for (const source of exportAllSources) { + (exportBindings[source] ??= []).push('*'); + } + + return exportBindings; + }, + get exports() { + return [ + ...exportDescriptions.keys(), + ...reexportDescriptions.keys(), + ...[...exportAllSources].map(() => '*') + ]; + }, + get hasDefaultExport() { + // This information is only valid after parsing + if (!module.ast) { + return null; + } + return module.exportDescriptions.has('default') || reexportDescriptions.has('default'); }, - hasModuleSideEffects, id, get implicitlyLoadedAfterOneOf() { - return Array.from(module.implicitlyLoadedAfter, getId); + return Array.from(implicitlyLoadedAfter, getId).sort(); }, get implicitlyLoadedBefore() { - return Array.from(module.implicitlyLoadedBefore, getId); + return Array.from(implicitlyLoadedBefore, getId).sort(); + }, + get importedIdResolutions() { + return Array.from( + sourcesWithAttributes.keys(), + source => module.resolvedIds[source] + ).filter(Boolean); }, get importedIds() { - return Array.from(module.sources, source => module.resolvedIds[source].id); + // We cannot use this.dependencies because this is needed before + // dependencies are populated + + return Array.from( + sourcesWithAttributes.keys(), + source => module.resolvedIds[source]?.id + ).filter(Boolean); }, get importers() { - return module.importers.sort(); + return importers.sort(); }, isEntry, isExternal: false, - meta, + get isIncluded() { + if (graph.phase !== BuildPhase.GENERATE) { + return null; + } + return module.isIncluded(); + }, + meta: { ...meta }, + moduleSideEffects, + safeVariableNames: null, syntheticNamedExports }; } - basename() { + basename(): string { const base = basename(this.id); - const ext = extname(this.id); + const extension = extname(this.id); - return makeLegal(ext ? base.slice(0, -ext.length) : base); + return makeLegal(extension ? base.slice(0, -extension.length) : base); } - bindReferences() { + bindReferences(): void { this.ast!.bind(); } - error(props: RollupError, pos: number): never { - this.addLocationToLogProps(props, pos); - return error(props); + cacheInfoGetters(): void { + cacheObjectGetters(this.info, [ + 'dynamicallyImportedIdResolutions', + 'dynamicallyImportedIds', + 'dynamicImporters', + 'exportedBindings', + 'exports', + 'hasDefaultExport', + 'implicitlyLoadedAfterOneOf', + 'implicitlyLoadedBefore', + 'importedIdResolutions', + 'importedIds', + 'importers' + ]); } - getAllExportNames(): Set { - if (this.allExportNames) { - return this.allExportNames; + error(properties: RollupError, pos: number | undefined): never { + if (pos !== undefined) { + this.addLocationToLogProps(properties, pos); } - const allExportNames = (this.allExportNames = new Set()); - for (const name of Object.keys(this.exports)) { - allExportNames.add(name); - } - for (const name of Object.keys(this.reexportDescriptions)) { - allExportNames.add(name); - } - for (const module of this.exportAllModules) { - if (module instanceof ExternalModule) { - allExportNames.add(`*${module.id}`); - continue; - } + return error(properties); + } - for (const name of module.getAllExportNames()) { - if (name !== 'default') allExportNames.add(name); + // sum up the length of all ast nodes that are included + estimateSize(): number { + let size = 0; + for (const node of this.ast!.body) { + if (node.included) { + size += node.end - node.start; } } - - return allExportNames; + return size; } getDependenciesToBeIncluded(): Set { if (this.relevantDependencies) return this.relevantDependencies; - const relevantDependencies = new Set(); + + this.relevantDependencies = new Set(); const necessaryDependencies = new Set(); const alwaysCheckedDependencies = new Set(); + const dependencyVariables = new Set(this.includedImports); - let dependencyVariables: Set | IterableIterator = this.imports.keys(); if ( this.info.isEntry || this.includedDynamicImporters.length > 0 || this.namespace.included || this.implicitlyLoadedAfter.size > 0 ) { - dependencyVariables = new Set(dependencyVariables); - for (const exportName of [...this.getReexports(), ...this.getExports()]) { - dependencyVariables.add(this.getVariableForExportName(exportName)!); + for (const variable of this.getExportedVariablesByName().values()) { + if (variable.included) { + dependencyVariables.add(variable); + } } } for (let variable of dependencyVariables) { @@ -381,38 +468,81 @@ export default class Module { } necessaryDependencies.add(variable.module!); } - if (this.options.treeshake && this.info.hasModuleSideEffects !== 'no-treeshake') { + if (!this.options.treeshake || this.info.moduleSideEffects === 'no-treeshake') { + for (const dependency of this.dependencies) { + this.relevantDependencies.add(dependency); + } + } else { this.addRelevantSideEffectDependencies( - relevantDependencies, + this.relevantDependencies, necessaryDependencies, alwaysCheckedDependencies ); - } else { - for (const dependency of this.dependencies) { - relevantDependencies.add(dependency); - } } for (const dependency of necessaryDependencies) { - relevantDependencies.add(dependency); + this.relevantDependencies.add(dependency); + } + return this.relevantDependencies; + } + + getExportedVariablesByName(): Map { + if (this.exportedVariablesByName) { + return this.exportedVariablesByName; + } + const exportedVariablesByName = (this.exportedVariablesByName = new Map()); + for (const name of this.exportDescriptions.keys()) { + // We do not count the synthetic namespace as a regular export to hide it + // from entry signatures and namespace objects + if (name !== this.info.syntheticNamedExports) { + const [exportedVariable] = this.getVariableForExportName(name); + if (exportedVariable) { + exportedVariablesByName.set(name, exportedVariable); + } else { + return error(logMissingEntryExport(name, this.id)); + } + } } - return (this.relevantDependencies = relevantDependencies); + for (const name of this.reexportDescriptions.keys()) { + const [exportedVariable] = this.getVariableForExportName(name); + if (exportedVariable) { + exportedVariablesByName.set(name, exportedVariable); + } + } + for (const module of this.exportAllModules) { + if (module instanceof ExternalModule) { + exportedVariablesByName.set( + `*${module.id}`, + module.getVariableForExportName('*', { + importChain: [this.id] + })[0] + ); + continue; + } + + for (const name of module.getExportedVariablesByName().keys()) { + if (name !== 'default' && !exportedVariablesByName.has(name)) { + const [exportedVariable] = this.getVariableForExportName(name); + if (exportedVariable) { + exportedVariablesByName.set(name, exportedVariable); + } + } + } + } + + return (this.exportedVariablesByName = new Map( + [...exportedVariablesByName].sort(sortExportedVariables) + )); } getExportNamesByVariable(): Map { if (this.exportNamesByVariable) { return this.exportNamesByVariable; } - const exportNamesByVariable: Map = new Map(); - for (const exportName of this.getAllExportNames()) { - if (exportName === this.info.syntheticNamedExports) continue; - let tracedVariable = this.getVariableForExportName(exportName); - if (tracedVariable instanceof ExportDefaultVariable) { - tracedVariable = tracedVariable.getOriginalVariable(); - } - if ( - !tracedVariable || - !(tracedVariable.included || tracedVariable instanceof ExternalVariable) - ) { + const exportNamesByVariable = new Map(); + for (const [exportName, variable] of this.getExportedVariablesByName().entries()) { + const tracedVariable = + variable instanceof ExportDefaultVariable ? variable.getOriginalVariable() : variable; + if (!variable || !(variable.included || variable instanceof ExternalVariable)) { continue; } const existingExportNames = exportNamesByVariable.get(tracedVariable); @@ -425,56 +555,32 @@ export default class Module { return (this.exportNamesByVariable = exportNamesByVariable); } - getExports() { - return Object.keys(this.exports); - } - - getReexports(): string[] { - if (this.transitiveReexports) { - return this.transitiveReexports; - } - // to avoid infinite recursion when using circular `export * from X` - this.transitiveReexports = []; - - const reexports = new Set(); - for (const name in this.reexportDescriptions) { - reexports.add(name); - } - for (const module of this.exportAllModules) { - if (module instanceof ExternalModule) { - reexports.add(`*${module.id}`); - } else { - for (const name of [...module.getReexports(), ...module.getExports()]) { - if (name !== 'default') reexports.add(name); - } - } - } - return (this.transitiveReexports = [...reexports]); - } - - getRenderedExports() { + getRenderedExports(): { removedExports: string[]; renderedExports: string[] } { // only direct exports are counted here, not reexports at all const renderedExports: string[] = []; const removedExports: string[] = []; - for (const exportName in this.exports) { - const variable = this.getVariableForExportName(exportName); - (variable && variable.included ? renderedExports : removedExports).push(exportName); + for (const exportName of this.exportDescriptions.keys()) { + (this.getExportedVariablesByName().get(exportName)?.included + ? renderedExports + : removedExports + ).push(exportName); } - return { renderedExports, removedExports }; + return { removedExports, renderedExports }; } - getSyntheticNamespace() { + getSyntheticNamespace(): Variable { if (this.syntheticNamespace === null) { this.syntheticNamespace = undefined; - this.syntheticNamespace = this.getVariableForExportName( + [this.syntheticNamespace] = this.getVariableForExportName( typeof this.info.syntheticNamedExports === 'string' ? this.info.syntheticNamedExports - : 'default' + : 'default', + { onlyExplicit: true } ); } if (!this.syntheticNamespace) { return error( - errSyntheticNamedExportsNeedNamespaceExport(this.id, this.info.syntheticNamedExports) + logSyntheticNamedExportsNeedNamespaceExport(this.id, this.info.syntheticNamedExports) ); } return this.syntheticNamespace; @@ -482,118 +588,132 @@ export default class Module { getVariableForExportName( name: string, - importerForSideEffects?: Module, - isExportAllSearch?: boolean, - searchedNamesAndModules?: Map> - ): Variable | null { + { + importerForSideEffects, + importChain = [], + isExportAllSearch, + onlyExplicit, + searchedNamesAndModules + }: { + importerForSideEffects?: Module; + importChain?: string[]; + isExportAllSearch?: boolean; + onlyExplicit?: boolean; + searchedNamesAndModules?: Map>; + } = EMPTY_OBJECT + ): [variable: Variable | null, options?: VariableOptions] { if (name[0] === '*') { if (name.length === 1) { // export * from './other' - return this.namespace; - } else { - // export * from 'external' - const module = this.graph.modulesById.get(name.slice(1)) as ExternalModule; - return module.getVariableForExportName('*'); + return [this.namespace]; } + // export * from 'external' + const module = this.graph.modulesById.get(name.slice(1)) as ExternalModule; + return module.getVariableForExportName('*', { + importChain: [...importChain, this.id] + }); } // export { foo } from './other' - const reexportDeclaration = this.reexportDescriptions[name]; + const reexportDeclaration = this.reexportDescriptions.get(name); if (reexportDeclaration) { - const variable = getVariableForExportNameRecursive( + const [variable, options] = getVariableForExportNameRecursive( reexportDeclaration.module, reexportDeclaration.localName, importerForSideEffects, false, - searchedNamesAndModules + searchedNamesAndModules, + [...importChain, this.id] ); - if (!variable) { return this.error( - errMissingExport(reexportDeclaration.localName, this.id, reexportDeclaration.module.id), + logMissingExport( + reexportDeclaration.localName, + this.id, + reexportDeclaration.module.id, + !!options?.missingButExportExists + ), reexportDeclaration.start ); } if (importerForSideEffects) { setAlternativeExporterIfCyclic(variable, importerForSideEffects, this); + if (this.info.moduleSideEffects) { + getOrCreate( + importerForSideEffects.sideEffectDependenciesByVariable, + variable, + getNewSet + ).add(this); + } } - return variable; + return [variable]; } - const exportDeclaration = this.exports[name]; + const exportDeclaration = this.exportDescriptions.get(name); if (exportDeclaration) { if (exportDeclaration === MISSING_EXPORT_SHIM_DESCRIPTION) { - return this.exportShimVariable; + return [this.exportShimVariable]; } const name = exportDeclaration.localName; - const variable = this.traceVariable(name, importerForSideEffects)!; + const variable = this.traceVariable(name, { + importerForSideEffects, + searchedNamesAndModules + }); + if (!variable) { + return [null, { missingButExportExists: true }]; + } if (importerForSideEffects) { + setAlternativeExporterIfCyclic(variable, importerForSideEffects, this); getOrCreate( importerForSideEffects.sideEffectDependenciesByVariable, variable, - () => new Set() + getNewSet ).add(this); - setAlternativeExporterIfCyclic(variable, importerForSideEffects, this); } - return variable; + return [variable]; + } + + if (onlyExplicit) { + return [null]; } if (name !== 'default') { - let foundSyntheticDeclaration: SyntheticNamedExportVariable | null = null; - for (const module of this.exportAllModules) { - const declaration = getVariableForExportNameRecursive( - module, + const foundNamespaceReexport = + this.namespaceReexportsByName.get(name) ?? + this.getVariableFromNamespaceReexports( name, importerForSideEffects, - true, - searchedNamesAndModules + searchedNamesAndModules, + [...importChain, this.id] ); - - if (declaration) { - if (!(declaration instanceof SyntheticNamedExportVariable)) { - return declaration; - } - if (!foundSyntheticDeclaration) { - foundSyntheticDeclaration = declaration; - } - } - } - if (foundSyntheticDeclaration) { - return foundSyntheticDeclaration; + this.namespaceReexportsByName.set(name, foundNamespaceReexport); + if (foundNamespaceReexport[0]) { + return foundNamespaceReexport; } } if (this.info.syntheticNamedExports) { - let syntheticExport = this.syntheticExports.get(name); - if (!syntheticExport) { - const syntheticNamespace = this.getSyntheticNamespace(); - syntheticExport = new SyntheticNamedExportVariable( - this.astContext, + return [ + getOrCreate( + this.syntheticExports, name, - syntheticNamespace - ); - this.syntheticExports.set(name, syntheticExport); - return syntheticExport; - } - return syntheticExport; + () => + new SyntheticNamedExportVariable(this.astContext, name, this.getSyntheticNamespace()) + ) + ]; } // we don't want to create shims when we are just // probing export * modules for exports - if (!isExportAllSearch) { - if (this.options.shimMissingExports) { - this.shimMissingExport(name); - return this.exportShimVariable; - } + if (!isExportAllSearch && this.options.shimMissingExports) { + this.shimMissingExport(name); + return [this.exportShimVariable]; } - return null; + return [null]; } - hasEffects() { - return ( - this.info.hasModuleSideEffects === 'no-treeshake' || - (this.ast!.included && this.ast!.hasEffects(createHasEffectsContext())) - ); + hasEffects(): boolean { + return this.info.moduleSideEffects === 'no-treeshake' || this.ast!.hasCachedEffects(); } include(): void { @@ -601,54 +721,47 @@ export default class Module { if (this.ast!.shouldBeIncluded(context)) this.ast!.include(context, false); } - includeAllExports(includeNamespaceMembers: boolean) { - if (!this.isExecuted) { - this.graph.needsTreeshakingPass = true; - markModuleAndImpureDependenciesAsExecuted(this); - } - - for (const exportName of this.getExports()) { - if (includeNamespaceMembers || exportName !== this.info.syntheticNamedExports) { - const variable = this.getVariableForExportName(exportName)!; - variable.deoptimizePath(UNKNOWN_PATH); - if (!variable.included) { - this.includeVariable(variable); - } - } - } - - for (const name of this.getReexports()) { - const variable = this.getVariableForExportName(name)!; + includeAllExports(): void { + if (this.allExportsIncluded) return; + this.allExportsIncluded = true; + this.includeModuleInExecution(); + const inclusionContext = createInclusionContext(); + for (const variable of this.getExportedVariablesByName().values()) { + this.includeVariable(variable, UNKNOWN_PATH, inclusionContext); variable.deoptimizePath(UNKNOWN_PATH); - if (!variable.included) { - this.includeVariable(variable); - } if (variable instanceof ExternalVariable) { variable.module.reexported = true; } } - - if (includeNamespaceMembers) { - this.namespace.prepareNamespace(this.includeAndGetAdditionalMergedNamespaces()); - } } - includeAllInBundle() { + includeAllInBundle(): void { this.ast!.include(createInclusionContext(), true); + this.includeAllExports(); + } + + includeModuleInExecution(): void { + if (!this.isExecuted) { + markModuleAndImpureDependenciesAsExecuted(this); + this.graph.needsTreeshakingPass = true; + } } - isIncluded() { - return this.ast!.included || this.namespace.included; + isIncluded(): boolean | null { + // Modules where this.ast is missing have been loaded via this.load and are + // not yet fully processed, hence they cannot be included. + return ( + this.ast && + (this.ast.included || + this.namespace.included || + this.importedFromNotTreeshaken || + this.exportShimVariable.included) + ); } - linkImports() { + linkImports(): void { this.addModulesToImportDescriptions(this.importDescriptions); this.addModulesToImportDescriptions(this.reexportDescriptions); - for (const name in this.exports) { - if (name !== 'default' && name !== this.info.syntheticNamedExports) { - this.exportsAll[name] = this.id; - } - } const externalExportAllModules: ExternalModule[] = []; for (const source of this.exportAllSources) { const module = this.graph.modulesById.get(this.resolvedIds[source].id)!; @@ -657,26 +770,27 @@ export default class Module { continue; } this.exportAllModules.push(module); - for (const name in module.exportsAll) { - if (name in this.exportsAll) { - this.options.onwarn(errNamespaceConflict(name, this, module)); - } else { - this.exportsAll[name] = module.exportsAll[name]; - } - } } this.exportAllModules.push(...externalExportAllModules); } - render(options: RenderOptions): MagicString { - const magicString = this.magicString.clone(); - this.ast!.render(magicString, options); - this.usesTopLevelAwait = this.astContext.usesTopLevelAwait; - return magicString; + log(level: LogLevel, properties: RollupLog, pos: number): void { + this.addLocationToLogProps(properties, pos); + this.options.onLog(level, properties); + } + + render(options: RenderOptions): { source: MagicString; usesTopLevelAwait: boolean } { + const source = this.magicString.clone(); + this.ast!.render(source, options); + source.trim(); + const { usesTopLevelAwait } = this.astContext; + if (usesTopLevelAwait && options.format !== 'es' && options.format !== 'system') { + return error(logInvalidFormatForTopLevelAwait(this.id, options.format)); + } + return { source, usesTopLevelAwait }; } - setSource({ - alwaysRemovedCode, + async setSource({ ast, code, customTransformCache, @@ -686,15 +800,33 @@ export default class Module { sourcemapChain, transformDependencies, transformFiles, + safeVariableNames, ...moduleOptions }: TransformModuleJSON & { - alwaysRemovedCode?: [number, number][]; + resolvedIds?: ResolvedIdMap; transformFiles?: EmittedFile[] | undefined; - }) { + }): Promise { + timeStart('generate ast', 3); + if (code.startsWith('#!')) { + const shebangEndPosition = code.indexOf('\n'); + this.shebang = code.slice(2, shebangEndPosition); + } + this.info.code = code; + this.info.safeVariableNames = safeVariableNames; this.originalCode = originalCode; - this.originalSourcemap = originalSourcemap; - this.sourcemapChain = sourcemapChain; + + // We need to call decodedSourcemap on the input in case they were hydrated from json in the cache and don't + // have the lazy evaluation cache configured. Right now this isn't enforced by the type system because the + // RollupCache stores `ExistingDecodedSourcemap` instead of `ExistingRawSourcemap` + this.originalSourcemap = decodedSourcemap(originalSourcemap); + this.sourcemapChain = sourcemapChain.map(mapOrMissing => + mapOrMissing.missing ? mapOrMissing : decodedSourcemap(mapOrMissing) + ); + + // If coming from cache and this value is already fully decoded, we want to re-encode here to save memory. + resetSourcemapCache(this.originalSourcemap, this.sourcemapChain); + if (transformFiles) { this.transformFiles = transformFiles; } @@ -702,17 +834,7 @@ export default class Module { this.customTransformCache = customTransformCache; this.updateOptions(moduleOptions); - timeStart('generate ast', 3); - - this.alwaysRemovedCode = alwaysRemovedCode || []; - if (!ast) { - ast = this.tryParse(); - } - this.alwaysRemovedCode.push(...findSourceMappingURLComments(ast, this.info.code)); - - timeEnd('generate ast', 3); - - this.resolvedIds = resolvedIds || Object.create(null); + this.resolvedIds = resolvedIds ?? Object.create(null); // By default, `id` is the file name. Custom resolvers and loaders // can change that, but it makes sense to use it for the source file name @@ -722,61 +844,93 @@ export default class Module { filename: (this.excludeFromSourcemap ? null : fileName)!, // don't include plugin helpers in sourcemap indentExclusionRanges: [] }); - for (const [start, end] of this.alwaysRemovedCode) { - this.magicString.remove(start, end); - } - - timeStart('analyse ast', 3); this.astContext = { addDynamicImport: this.addDynamicImport.bind(this), addExport: this.addExport.bind(this), addImport: this.addImport.bind(this), addImportMeta: this.addImportMeta.bind(this), + addImportSource: this.addImportSource.bind(this), code, // Only needed for debugging deoptimizationTracker: this.graph.deoptimizationTracker, error: this.error.bind(this), fileName, // Needed for warnings - getExports: this.getExports.bind(this), + getImportedJsxFactoryVariable: this.getImportedJsxFactoryVariable.bind(this), getModuleExecIndex: () => this.execIndex, getModuleName: this.basename.bind(this), - getReexports: this.getReexports.bind(this), + getNodeConstructor: (name: string) => nodeConstructors[name] || nodeConstructors.UnknownNode, importDescriptions: this.importDescriptions, - includeAllExports: () => this.includeAllExports(true), includeDynamicImport: this.includeDynamicImport.bind(this), includeVariableInModule: this.includeVariableInModule.bind(this), + log: this.log.bind(this), magicString: this.magicString, + manualPureFunctions: this.graph.pureFunctions, module: this, moduleContext: this.context, - nodeConstructors, + newlyIncludedVariableInits: this.graph.newlyIncludedVariableInits, options: this.options, - traceExport: this.getVariableForExportName.bind(this), + requestTreeshakingPass: () => (this.graph.needsTreeshakingPass = true), + traceExport: (name: string) => this.getVariableForExportName(name), traceVariable: this.traceVariable.bind(this), - usesTopLevelAwait: false, - warn: this.warn.bind(this) + usesTopLevelAwait: false }; - this.scope = new ModuleScope(this.graph.scope, this.astContext); - this.namespace = new NamespaceVariable(this.astContext, this.info.syntheticNamedExports); - this.ast = new Program(ast, { type: 'Module', context: this.astContext }, this.scope); - this.info.ast = ast; + this.scope = new ModuleScope(this.graph.scope, this.astContext, this.importDescriptions); + this.namespace = new NamespaceVariable(this.astContext); + const programParent = { context: this.astContext, type: 'Module' }; + + if (ast) { + this.ast = new nodeConstructors[ast.type](programParent, this.scope).parseNode( + ast + ) as Program; + this.info.ast = ast; + } else { + // Measuring asynchronous code does not provide reasonable results + timeEnd('generate ast', 3); + const astBuffer = await parseAsync(code, false, this.options.jsx !== false); + timeStart('generate ast', 3); + this.ast = convertProgram(astBuffer, programParent, this.scope); + // Make lazy and apply LRU cache to not hog the memory + Object.defineProperty(this.info, 'ast', { + get: () => { + if (this.graph.astLru.has(fileName)) { + return this.graph.astLru.get(fileName)!; + } else { + const parsedAst = this.tryParse(); + // If the cache is not disabled, we need to keep the AST in memory + // until the end when the cache is generated + if (this.options.cache !== false) { + Object.defineProperty(this.info, 'ast', { + value: parsedAst + }); + return parsedAst; + } + // Otherwise, we keep it in a small LRU cache to not hog too much + // memory but allow the same AST to be requested several times. + this.graph.astLru.set(fileName, parsedAst); + return parsedAst; + } + } + }); + } - timeEnd('analyse ast', 3); + timeEnd('generate ast', 3); } toJSON(): ModuleJSON { return { - alwaysRemovedCode: this.alwaysRemovedCode, - ast: this.ast!.esTreeNode, + ast: this.info.ast!, + attributes: this.info.attributes, code: this.info.code!, customTransformCache: this.customTransformCache, dependencies: Array.from(this.dependencies, getId), id: this.id, meta: this.info.meta, - moduleSideEffects: this.info.hasModuleSideEffects, + moduleSideEffects: this.info.moduleSideEffects, originalCode: this.originalCode, originalSourcemap: this.originalSourcemap, resolvedIds: this.resolvedIds, + safeVariableNames: this.info.safeVariableNames, sourcemapChain: this.sourcemapChain, syntheticNamedExports: this.info.syntheticNamedExports, transformDependencies: this.transformDependencies, @@ -784,29 +938,49 @@ export default class Module { }; } - traceVariable(name: string, importerForSideEffects?: Module): Variable | null { + traceVariable( + name: string, + { + importerForSideEffects, + isExportAllSearch, + searchedNamesAndModules + }: { + importerForSideEffects?: Module; + isExportAllSearch?: boolean; + searchedNamesAndModules?: Map>; + } = EMPTY_OBJECT + ): Variable | null { const localVariable = this.scope.variables.get(name); if (localVariable) { return localVariable; } - if (name in this.importDescriptions) { - const importDeclaration = this.importDescriptions[name]; - const otherModule = importDeclaration.module; + const importDescription = this.importDescriptions.get(name); + if (importDescription) { + const otherModule = importDescription.module; - if (otherModule instanceof Module && importDeclaration.name === '*') { + if (otherModule instanceof Module && importDescription.name === '*') { return otherModule.namespace; } - const declaration = otherModule.getVariableForExportName( - importDeclaration.name, - importerForSideEffects || this + const [declaration, options] = getVariableForExportNameRecursive( + otherModule, + importDescription.name, + importerForSideEffects || this, + isExportAllSearch, + searchedNamesAndModules, + [this.id] ); if (!declaration) { return this.error( - errMissingExport(importDeclaration.name, this.id, otherModule.id), - importDeclaration.start + logMissingExport( + importDescription.name, + this.id, + otherModule.id, + !!options?.missingButExportExists + ), + importDescription.start ); } @@ -816,84 +990,71 @@ export default class Module { return null; } - tryParse(): acorn.Node { - try { - return this.graph.contextParse(this.info.code!); - } catch (err) { - let message = err.message.replace(/ \(\d+:\d+\)$/, ''); - if (this.id.endsWith('.json')) { - message += ' (Note that you need @rollup/plugin-json to import JSON files)'; - } else if (!this.id.endsWith('.js')) { - message += ' (Note that you need plugins to import files that are not JavaScript)'; - } - return this.error( - { - code: 'PARSE_ERROR', - message, - parserError: err - }, - err.pos - ); - } - } - - updateOptions({ meta, moduleSideEffects, syntheticNamedExports - }: Partial>) { + }: Partial>): void { if (moduleSideEffects != null) { - this.info.hasModuleSideEffects = moduleSideEffects; + this.info.moduleSideEffects = moduleSideEffects; } if (syntheticNamedExports != null) { this.info.syntheticNamedExports = syntheticNamedExports; } if (meta != null) { - this.info.meta = { ...this.info.meta, ...meta }; + Object.assign(this.info.meta, meta); } } - warn(props: RollupWarning, pos: number) { - this.addLocationToLogProps(props, pos); - this.options.onwarn(props); - } - private addDynamicImport(node: ImportExpression) { - let argument: ExpressionNode | string = node.source; - if (argument instanceof TemplateLiteral) { - if (argument.quasis.length === 1 && argument.quasis[0].value.cooked) { - argument = argument.quasis[0].value.cooked; + let argument: AstNode | string = node.sourceAstNode; + if (argument.type === NodeType.TemplateLiteral) { + if ( + (argument as TemplateLiteralNode).quasis.length === 1 && + typeof (argument as TemplateLiteralNode).quasis[0].value.cooked === 'string' + ) { + argument = (argument as TemplateLiteralNode).quasis[0].value.cooked!; } - } else if (argument instanceof Literal && typeof argument.value === 'string') { - argument = argument.value; + } else if ( + argument.type === NodeType.Literal && + typeof (argument as LiteralStringNode).value === 'string' + ) { + argument = (argument as LiteralStringNode).value!; + } + this.dynamicImports.push({ argument, id: null, node }); + } + + private assertUniqueExportName(name: string, nodeStart: number) { + if (this.exportDescriptions.has(name) || this.reexportDescriptions.has(name)) { + this.error(logDuplicateExportError(name), nodeStart); } - this.dynamicImports.push({ node, resolution: null, argument }); } private addExport( node: ExportAllDeclaration | ExportNamedDeclaration | ExportDefaultDeclaration - ) { + ): void { if (node instanceof ExportDefaultDeclaration) { // export default foo; - this.exports.default = { + this.assertUniqueExportName('default', node.start); + this.exportDescriptions.set('default', { identifier: node.variable.getAssignedVariableName(), localName: 'default' - }; + }); } else if (node instanceof ExportAllDeclaration) { const source = node.source.value; - this.sources.add(source); + this.addSource(source, node); if (node.exported) { // export * as name from './other' - const name = node.exported.name; - this.reexportDescriptions[name] = { + const name = node.exported instanceof Literal ? node.exported.value : node.exported.name; + this.assertUniqueExportName(name, node.exported.start); + this.reexportDescriptions.set(name, { localName: '*', - module: null as any, // filled in later, + module: null as never, // filled in later, source, start: node.start - }; + }); } else { // export * from './other' @@ -903,15 +1064,16 @@ export default class Module { // export { name } from './other' const source = node.source.value; - this.sources.add(source); - for (const specifier of node.specifiers) { - const name = specifier.exported.name; - this.reexportDescriptions[name] = { - localName: specifier.local.name, - module: null as any, // filled in later, + this.addSource(source, node); + for (const { exported, local, start } of node.specifiers) { + const name = exported instanceof Literal ? exported.value : exported.name; + this.assertUniqueExportName(name, start); + this.reexportDescriptions.set(name, { + localName: local instanceof Literal ? local.value : local.name, + module: null as never, // filled in later, source, - start: specifier.start - }; + start + }); } } else if (node.declaration) { const declaration = node.declaration; @@ -921,93 +1083,106 @@ export default class Module { for (const declarator of declaration.declarations) { for (const localName of extractAssignedNames(declarator.id)) { - this.exports[localName] = { identifier: null, localName }; + this.assertUniqueExportName(localName, declarator.id.start); + this.exportDescriptions.set(localName, { identifier: null, localName }); } } } else { // export function foo () {} const localName = (declaration.id as Identifier).name; - this.exports[localName] = { identifier: null, localName }; + this.assertUniqueExportName(localName, declaration.id!.start); + this.exportDescriptions.set(localName, { identifier: null, localName }); } } else { // export { foo, bar, baz } - for (const specifier of node.specifiers) { - const localName = specifier.local.name; - const exportedName = specifier.exported.name; - this.exports[exportedName] = { identifier: null, localName }; + for (const { local, exported } of node.specifiers) { + // except for reexports, local must be an Identifier + const localName = (local as Identifier).name; + const exportedName = exported instanceof Identifier ? exported.name : exported.value; + this.assertUniqueExportName(exportedName, exported.start); + this.exportDescriptions.set(exportedName, { identifier: null, localName }); } } } - private addImport(node: ImportDeclaration) { + private addImport(node: ImportDeclaration): void { const source = node.source.value; - this.sources.add(source); + this.addSource(source, node); + for (const specifier of node.specifiers) { - const isDefault = specifier.type === NodeType.ImportDefaultSpecifier; - const isNamespace = specifier.type === NodeType.ImportNamespaceSpecifier; - - const name = isDefault - ? 'default' - : isNamespace - ? '*' - : (specifier as ImportSpecifier).imported.name; - this.importDescriptions[specifier.local.name] = { - module: null as any, // filled in later + const localName = specifier.local.name; + if (this.scope.variables.has(localName) || this.importDescriptions.has(localName)) { + this.error(logRedeclarationError(localName), specifier.local.start); + } + + const name = + specifier instanceof ImportDefaultSpecifier + ? 'default' + : specifier instanceof ImportNamespaceSpecifier + ? '*' + : specifier.imported instanceof Identifier + ? specifier.imported.name + : specifier.imported.value; + this.importDescriptions.set(localName, { + module: null as never, // filled in later name, source, start: specifier.start - }; + }); } } - private addImportMeta(node: MetaProperty) { + private addImportSource(importSource: string): void { + if (importSource && !this.sourcesWithAttributes.has(importSource)) { + this.sourcesWithAttributes.set(importSource, EMPTY_OBJECT); + } + } + + private addImportMeta(node: MetaProperty): void { this.importMetas.push(node); } - private addLocationToLogProps(props: RollupLogProps, pos: number): void { - props.id = this.id; - props.pos = pos; + private addLocationToLogProps(properties: RollupLog, pos: number): void { + properties.id = this.id; + properties.pos = pos; let code = this.info.code; - let { column, line } = locate(code!, pos, { offsetLine: 1 }); - try { - ({ column, line } = getOriginalLocation(this.sourcemapChain, { column, line })); - code = this.originalCode; - } catch (e) { - this.options.onwarn({ - code: 'SOURCEMAP_ERROR', - id: this.id, - loc: { - column, - file: this.id, - line - }, - message: `Error when using sourcemap for reporting an error: ${e.message}`, - pos - }); + const location = locate(code!, pos, { offsetLine: 1 }); + if (location) { + let { column, line } = location; + try { + ({ column, line } = getOriginalLocation(this.sourcemapChain, { column, line })); + code = this.originalCode; + } catch (error_: any) { + this.options.onLog( + LOGLEVEL_WARN, + logInvalidSourcemapForError(error_, this.id, column, line, pos) + ); + } + augmentCodeLocation(properties, { column, line }, code!, this.id); } - augmentCodeLocation(props, { column, line }, code!, this.id); } - private addModulesToImportDescriptions(importDescription: { - [name: string]: ImportDescription | ReexportDescription; - }) { - for (const name of Object.keys(importDescription)) { - const specifier = importDescription[name]; - const id = this.resolvedIds[specifier.source].id; + private addModulesToImportDescriptions( + importDescription: ReadonlyMap + ): void { + for (const specifier of importDescription.values()) { + const { id } = this.resolvedIds[specifier.source]; specifier.module = this.graph.modulesById.get(id)!; } } private addRelevantSideEffectDependencies( relevantDependencies: Set, - necessaryDependencies: Set, - alwaysCheckedDependencies: Set - ) { + necessaryDependencies: ReadonlySet, + alwaysCheckedDependencies: ReadonlySet + ): void { const handledDependencies = new Set(); - const addSideEffectDependencies = (possibleDependencies: Set) => { + const addSideEffectDependencies = ( + possibleDependencies: ReadonlySet + ) => { for (const dependency of possibleDependencies) { if (handledDependencies.has(dependency)) { continue; @@ -1017,7 +1192,7 @@ export default class Module { relevantDependencies.add(dependency); continue; } - if (!(dependency.info.hasModuleSideEffects || alwaysCheckedDependencies.has(dependency))) { + if (!(dependency.info.moduleSideEffects || alwaysCheckedDependencies.has(dependency))) { continue; } if (dependency instanceof ExternalModule || dependency.hasEffects()) { @@ -1032,78 +1207,204 @@ export default class Module { addSideEffectDependencies(alwaysCheckedDependencies); } - private includeAndGetAdditionalMergedNamespaces(): Variable[] { - const mergedNamespaces: Variable[] = []; + private addSource( + source: string, + declaration: ImportDeclaration | ExportNamedDeclaration | ExportAllDeclaration + ) { + const parsedAttributes = getAttributesFromImportExportDeclaration(declaration.attributes); + const existingAttributes = this.sourcesWithAttributes.get(source); + if (existingAttributes) { + if (doAttributesDiffer(existingAttributes, parsedAttributes)) { + this.log( + LOGLEVEL_WARN, + logInconsistentImportAttributes(existingAttributes, parsedAttributes, source, this.id), + declaration.start + ); + } + } else { + this.sourcesWithAttributes.set(source, parsedAttributes); + } + } + + private getImportedJsxFactoryVariable( + baseName: string, + nodeStart: number, + importSource: string + ): Variable { + const { id } = this.resolvedIds[importSource!]; + const module = this.graph.modulesById.get(id)!; + const [variable] = module.getVariableForExportName(baseName, { importChain: [this.id] }); + if (!variable) { + return this.error(logMissingJsxExport(baseName, id, this.id), nodeStart); + } + return variable; + } + + private getVariableFromNamespaceReexports( + name: string, + importerForSideEffects: Module | undefined, + searchedNamesAndModules: Map> | undefined, + importChain: string[] + ): [variable: Variable | null, options?: VariableOptions] { + let foundSyntheticDeclaration: SyntheticNamedExportVariable | null = null; + const foundInternalDeclarations = new Map(); + const foundExternalDeclarations = new Set(); for (const module of this.exportAllModules) { + // Synthetic namespaces should not hide "regular" exports of the same name + if (module.info.syntheticNamedExports === name) { + continue; + } + const [variable, options] = getVariableForExportNameRecursive( + module, + name, + importerForSideEffects, + true, + // We are creating a copy to handle the case where the same binding is + // imported through different namespace reexports gracefully + copyNameToModulesMap(searchedNamesAndModules), + importChain + ); + + if (module instanceof ExternalModule || options?.indirectExternal) { + foundExternalDeclarations.add(variable as ExternalVariable); + } else if (variable instanceof SyntheticNamedExportVariable) { + if (!foundSyntheticDeclaration) { + foundSyntheticDeclaration = variable; + } + } else if (variable) { + foundInternalDeclarations.set(variable, module); + } + } + if (foundInternalDeclarations.size > 0) { + const foundDeclarationList = [...foundInternalDeclarations]; + const usedDeclaration = foundDeclarationList[0][0]; + if (foundDeclarationList.length === 1) { + return [usedDeclaration]; + } + this.options.onLog( + LOGLEVEL_WARN, + logNamespaceConflict( + name, + this.id, + foundDeclarationList.map(([, module]) => module.id) + ) + ); + // TODO we are pretending it was not found while it should behave like "undefined" + return [null]; + } + if (foundExternalDeclarations.size > 0) { + const foundDeclarationList = [...foundExternalDeclarations]; + const usedDeclaration = foundDeclarationList[0]; + if (foundDeclarationList.length > 1) { + this.options.onLog( + LOGLEVEL_WARN, + logAmbiguousExternalNamespaces( + name, + this.id, + usedDeclaration.module.id, + foundDeclarationList.map(declaration => declaration.module.id) + ) + ); + } + return [usedDeclaration, { indirectExternal: true }]; + } + if (foundSyntheticDeclaration) { + return [foundSyntheticDeclaration]; + } + return [null]; + } + + includeAndGetAdditionalMergedNamespaces(): Variable[] { + const externalNamespaces = new Set(); + const syntheticNamespaces = new Set(); + for (const module of [this, ...this.exportAllModules]) { if (module instanceof ExternalModule) { - const externalVariable = module.getVariableForExportName('*'); - externalVariable.include(); - this.imports.add(externalVariable); - mergedNamespaces.push(externalVariable); + const [externalVariable] = module.getVariableForExportName('*', { + importChain: [this.id] + }); + externalVariable.includePath(UNKNOWN_PATH, createInclusionContext()); + this.includedImports.add(externalVariable); + externalNamespaces.add(externalVariable); } else if (module.info.syntheticNamedExports) { const syntheticNamespace = module.getSyntheticNamespace(); - syntheticNamespace.include(); - this.imports.add(syntheticNamespace); - mergedNamespaces.push(syntheticNamespace); + syntheticNamespace.includePath(UNKNOWN_PATH, createInclusionContext()); + this.includedImports.add(syntheticNamespace); + syntheticNamespaces.add(syntheticNamespace); } } - return mergedNamespaces; + return [...syntheticNamespaces, ...externalNamespaces]; } - private includeDynamicImport(node: ImportExpression) { - const resolution = (this.dynamicImports.find(dynamicImport => dynamicImport.node === node) as { - resolution: string | Module | ExternalModule | undefined; - }).resolution; + private includeDynamicImport(node: ImportExpression): void { + const { resolution } = node; if (resolution instanceof Module) { - resolution.includedDynamicImporters.push(this); - resolution.includeAllExports(true); + if (!resolution.includedDynamicImporters.includes(this)) { + resolution.includedDynamicImporters.push(this); + // If a module has a top-level await, removing this entry can create + // deadlocks. + if (this.astContext.usesTopLevelAwait) { + resolution.includedTopLevelAwaitingDynamicImporters.add(this); + } + } } } - private includeVariable(variable: Variable) { - if (!variable.included) { - variable.include(); - this.graph.needsTreeshakingPass = true; - const variableModule = variable.module; - if (variableModule && variableModule instanceof Module) { - if (!variableModule.isExecuted) { - markModuleAndImpureDependenciesAsExecuted(variableModule); - } - if (variableModule !== this) { - const sideEffectModules = getAndExtendSideEffectModules(variable, this); - for (const module of sideEffectModules) { - if (!module.isExecuted) { - markModuleAndImpureDependenciesAsExecuted(module); - } - } - } + private includeVariable(variable: Variable, path: ObjectPath, context: InclusionContext): void { + const { included, module: variableModule } = variable; + variable.includePath(path, context); + if (included) { + if (variableModule instanceof Module && variableModule !== this) { + getAndExtendSideEffectModules(variable, this); + } + return; + } + this.graph.needsTreeshakingPass = true; + if (!(variableModule instanceof Module)) { + return; + } + variableModule.includeModuleInExecution(); + if (variableModule !== this) { + const sideEffectModules = getAndExtendSideEffectModules(variable, this); + for (const module of sideEffectModules) { + module.includeModuleInExecution(); } } } - private includeVariableInModule(variable: Variable) { - this.includeVariable(variable); + private includeVariableInModule( + variable: Variable, + path: ObjectPath, + context: InclusionContext + ): void { + this.includeVariable(variable, path, context); const variableModule = variable.module; if (variableModule && variableModule !== this) { - this.imports.add(variable); + this.includedImports.add(variable); } } private shimMissingExport(name: string): void { - this.options.onwarn({ - code: 'SHIMMED_EXPORT', - exporter: relativeId(this.id), - exportName: name, - message: `Missing export "${name}" has been shimmed in module ${relativeId(this.id)}.` - }); - this.exports[name] = MISSING_EXPORT_SHIM_DESCRIPTION; + this.options.onLog(LOGLEVEL_WARN, logShimmedExport(this.id, name)); + this.exportDescriptions.set(name, MISSING_EXPORT_SHIM_DESCRIPTION); + } + + private tryParse() { + try { + return parseAst(this.info.code!, { jsx: this.options.jsx !== false }); + } catch (error_: any) { + return this.error(logModuleParseError(error_, this.id), error_.pos); + } } } // if there is a cyclic import in the reexport chain, we should not // import from the original module but from the cyclic module to not // mess up execution order. -function setAlternativeExporterIfCyclic(variable: Variable, importer: Module, reexporter: Module) { +function setAlternativeExporterIfCyclic( + variable: Variable, + importer: Module, + reexporter: Module +): void { if (variable.module instanceof Module && variable.module !== reexporter) { const exporterCycles = variable.module.cycles; if (exporterCycles.size > 0) { @@ -1117,3 +1418,17 @@ function setAlternativeExporterIfCyclic(variable: Variable, importer: Module, re } } } + +const copyNameToModulesMap = ( + searchedNamesAndModules?: Map> +): Map> | undefined => + searchedNamesAndModules && + new Map(Array.from(searchedNamesAndModules, ([name, modules]) => [name, new Set(modules)])); + +interface VariableOptions { + indirectExternal?: boolean; + missingButExportExists?: boolean; +} + +const sortExportedVariables = ([a]: [string, Variable], [b]: [string, Variable]) => + a < b ? -1 : a > b ? 1 : 0; diff --git a/src/ModuleLoader.ts b/src/ModuleLoader.ts index cad73ea8473..907407d75ce 100644 --- a/src/ModuleLoader.ts +++ b/src/ModuleLoader.ts @@ -1,38 +1,46 @@ -import * as acorn from 'acorn'; import ExternalModule from './ExternalModule'; -import Graph from './Graph'; -import Module from './Module'; -import { +import type Graph from './Graph'; +import Module, { type DynamicImport } from './Module'; +import type { + AstNode, CustomPluginOptions, EmittedChunk, HasModuleSideEffects, + LoadResult, + ModuleInfo, ModuleOptions, NormalizedInputOptions, PartialNull, Plugin, ResolvedId, - ResolveIdResult, - SourceDescription + ResolveIdResult } from './rollup/types'; import { EMPTY_OBJECT } from './utils/blank'; +import { LOGLEVEL_WARN } from './utils/logging'; import { - errBadLoader, - errEntryCannotBeExternal, - errExternalSyntheticExports, - errImplicitDependantCannotBeExternal, - errInternalIdCannotBeExternal, error, - errUnresolvedEntry, - errUnresolvedImplicitDependant, - errUnresolvedImport, - errUnresolvedImportTreatedAsExternal -} from './utils/error'; -import { readFile } from './utils/fs'; + logBadLoader, + logEntryCannotBeExternal, + logExternalModulesCannotBeIncludedInManualChunks, + logExternalModulesCannotBeTransformedToModules, + logExternalSyntheticExports, + logImplicitDependantCannotBeExternal, + logInconsistentImportAttributes, + logInternalIdCannotBeExternal, + logUnresolvedEntry, + logUnresolvedImplicitDependant, + logUnresolvedImport, + logUnresolvedImportTreatedAsExternal +} from './utils/logs'; +import { + doAttributesDiffer, + getAttributesFromImportExpression +} from './utils/parseImportAttributes'; import { isAbsolute, isRelative, resolve } from './utils/path'; -import { PluginDriver } from './utils/PluginDriver'; +import type { PluginDriver } from './utils/PluginDriver'; import relativeId from './utils/relativeId'; import { resolveId } from './utils/resolveId'; -import { timeEnd, timeStart } from './utils/timers'; +import stripBom from './utils/stripBom'; import transform from './utils/transform'; export interface UnresolvedModule { @@ -42,16 +50,43 @@ export interface UnresolvedModule { name: string | null; } +export type ModuleLoaderResolveId = ( + source: string, + importer: string | undefined, + customOptions: CustomPluginOptions | undefined, + isEntry: boolean | undefined, + attributes: Record, + skip?: readonly { importer: string | undefined; plugin: Plugin; source: string }[] | null +) => Promise; + type NormalizedResolveIdWithoutDefaults = Partial> & { external?: boolean | 'absolute'; id: string; + resolvedBy?: string; }; +type ResolveStaticDependencyPromise = Promise; +type ResolveDynamicDependencyPromise = Promise< + readonly [dynamicImport: DynamicImport, resolvedId: ResolvedId | string | null] +>; +type LoadModulePromise = Promise< + [ + resolveStaticDependencies: ResolveStaticDependencyPromise[], + resolveDynamicDependencies: ResolveDynamicDependencyPromise[], + loadAndResolveDependencies: Promise + ] +>; +type PreloadType = boolean | 'resolveDependencies'; +const RESOLVE_DEPENDENCIES: PreloadType = 'resolveDependencies'; + export class ModuleLoader { private readonly hasModuleSideEffects: HasModuleSideEffects; private readonly implicitEntryModules = new Set(); private readonly indexedEntryModules: { index: number; module: Module }[] = []; - private latestLoadModulesPromise: Promise = Promise.resolve(); + private latestLoadModulesPromise: Promise = Promise.resolve(); + private readonly moduleLoadPromises = new Map(); + private readonly modulesWithLoadedDependencies = new Set(); + private nextChunkNamePriority = 0; private nextEntryModuleIndex = 0; constructor( @@ -65,16 +100,23 @@ export class ModuleLoader { : () => true; } - async addAdditionalModules(unresolvedModules: string[]): Promise { + async addAdditionalModules( + unresolvedModules: readonly string[], + isAddForManualChunks: boolean + ): Promise { const result = this.extendLoadModulesPromise( - Promise.all(unresolvedModules.map(id => this.loadEntryModule(id, false, undefined, null))) + Promise.all( + unresolvedModules.map(id => + this.loadEntryModule(id, false, undefined, null, isAddForManualChunks) + ) + ) ); await this.awaitLoadModulesPromise(); return result; } async addEntryModules( - unresolvedEntryModules: UnresolvedModule[], + unresolvedEntryModules: readonly UnresolvedModule[], isUserDefined: boolean ): Promise<{ entryModules: Module[]; @@ -83,27 +125,37 @@ export class ModuleLoader { }> { const firstEntryModuleIndex = this.nextEntryModuleIndex; this.nextEntryModuleIndex += unresolvedEntryModules.length; + const firstChunkNamePriority = this.nextChunkNamePriority; + this.nextChunkNamePriority += unresolvedEntryModules.length; const newEntryModules = await this.extendLoadModulesPromise( Promise.all( - unresolvedEntryModules.map( - ({ id, importer }): Promise => this.loadEntryModule(id, true, importer, null) + unresolvedEntryModules.map(({ id, importer }) => + this.loadEntryModule(id, true, importer, null) ) ).then(entryModules => { - let moduleIndex = firstEntryModuleIndex; - for (let index = 0; index < entryModules.length; index++) { - const entryModule = entryModules[index]; + for (const [index, entryModule] of entryModules.entries()) { entryModule.isUserDefinedEntryPoint = entryModule.isUserDefinedEntryPoint || isUserDefined; - addChunkNamesToModule(entryModule, unresolvedEntryModules[index], isUserDefined); + addChunkNamesToModule( + entryModule, + unresolvedEntryModules[index], + isUserDefined, + firstChunkNamePriority + index + ); const existingIndexedModule = this.indexedEntryModules.find( indexedModule => indexedModule.module === entryModule ); - if (!existingIndexedModule) { - this.indexedEntryModules.push({ module: entryModule, index: moduleIndex }); + if (existingIndexedModule) { + existingIndexedModule.index = Math.min( + existingIndexedModule.index, + firstEntryModuleIndex + index + ); } else { - existingIndexedModule.index = Math.min(existingIndexedModule.index, moduleIndex); + this.indexedEntryModules.push({ + index: firstEntryModuleIndex + index, + module: entryModule + }); } - moduleIndex++; } this.indexedEntryModules.sort(({ index: indexA }, { index: indexB }) => indexA > indexB ? 1 : -1 @@ -142,13 +194,27 @@ export class ModuleLoader { return module; } - resolveId = async ( - source: string, - importer: string | undefined, - customOptions: CustomPluginOptions | undefined, - skip: { importer: string | undefined; plugin: Plugin; source: string }[] | null = null - ): Promise => { - return this.addDefaultsToResolvedId( + public async preloadModule( + resolvedId: { id: string; resolveDependencies?: boolean } & Partial> + ): Promise { + const module = await this.fetchModule( + this.getResolvedIdWithDefaults(resolvedId, EMPTY_OBJECT)!, + undefined, + false, + resolvedId.resolveDependencies ? RESOLVE_DEPENDENCIES : true + ); + return module.info; + } + + resolveId: ModuleLoaderResolveId = async ( + source, + importer, + customOptions, + isEntry, + attributes, + skip = null + ) => + this.getResolvedIdWithDefaults( this.getNormalizedResolvedIdWithoutDefaults( this.options.external(source, importer, false) ? false @@ -159,52 +225,44 @@ export class ModuleLoader { this.pluginDriver, this.resolveId, skip, - customOptions - ), - + customOptions, + typeof isEntry === 'boolean' ? isEntry : !importer, + attributes, + this.options.fs + ), importer, source - ) + ), + attributes ); - }; - - private addDefaultsToResolvedId( - resolvedId: NormalizedResolveIdWithoutDefaults | null - ): ResolvedId | null { - if (!resolvedId) { - return null; - } - const external = resolvedId.external || false; - return { - external, - id: resolvedId.id, - meta: resolvedId.meta || EMPTY_OBJECT, - moduleSideEffects: - resolvedId.moduleSideEffects ?? this.hasModuleSideEffects(resolvedId.id, !!external), - syntheticNamedExports: resolvedId.syntheticNamedExports ?? false - }; - } private addEntryWithImplicitDependants( unresolvedModule: UnresolvedModule, - implicitlyLoadedAfter: string[] + implicitlyLoadedAfter: readonly string[] ): Promise { + const chunkNamePriority = this.nextChunkNamePriority++; return this.extendLoadModulesPromise( this.loadEntryModule(unresolvedModule.id, false, unresolvedModule.importer, null).then( async entryModule => { - addChunkNamesToModule(entryModule, unresolvedModule, false); + addChunkNamesToModule(entryModule, unresolvedModule, false, chunkNamePriority); if (!entryModule.info.isEntry) { - this.implicitEntryModules.add(entryModule); const implicitlyLoadedAfterModules = await Promise.all( implicitlyLoadedAfter.map(id => this.loadEntryModule(id, false, unresolvedModule.importer, entryModule.id) ) ); - for (const module of implicitlyLoadedAfterModules) { - entryModule.implicitlyLoadedAfter.add(module); - } - for (const dependant of entryModule.implicitlyLoadedAfter) { - dependant.implicitlyLoadedBefore.add(entryModule); + // We need to check again if this is still an entry module as these + // changes need to be performed atomically to avoid race conditions + // if the same module is re-emitted as an entry module. + // The inverse changes happen in "handleExistingModule" + if (!entryModule.info.isEntry) { + this.implicitEntryModules.add(entryModule); + for (const module of implicitlyLoadedAfterModules) { + entryModule.implicitlyLoadedAfter.add(module); + } + for (const dependant of entryModule.implicitlyLoadedAfter) { + dependant.implicitlyLoadedBefore.add(entryModule); + } } } return entryModule; @@ -213,41 +271,59 @@ export class ModuleLoader { ); } - private async addModuleSource(id: string, importer: string | undefined, module: Module) { - timeStart('load modules', 3); - let source: string | SourceDescription; + private async addModuleSource( + id: string, + importer: string | undefined, + module: Module + ): Promise { + let source: LoadResult; try { - source = (await this.pluginDriver.hookFirst('load', [id])) ?? (await readFile(id)); - } catch (err) { - timeEnd('load modules', 3); - let msg = `Could not load ${id}`; - if (importer) msg += ` (imported by ${relativeId(importer)})`; - msg += `: ${err.message}`; - err.message = msg; - throw err; + source = await this.graph.fileOperationQueue.run(async () => { + const content = await this.pluginDriver.hookFirst('load', [id]); + if (content !== null) return content; + this.graph.watchFiles[id] = true; + return (await this.options.fs.readFile(id, { encoding: 'utf8' })) as string; + }); + } catch (error_: any) { + let message = `Could not load ${id}`; + if (importer) message += ` (imported by ${relativeId(importer)})`; + message += `: ${error_.message}`; + error_.message = message; + throw error_; } - timeEnd('load modules', 3); const sourceDescription = typeof source === 'string' ? { code: source } - : typeof source === 'object' && typeof source.code === 'string' - ? source - : error(errBadLoader(id)); + : source != null && typeof source === 'object' && typeof source.code === 'string' + ? source + : error(logBadLoader(id)); + sourceDescription.code = stripBom(sourceDescription.code); const cachedModule = this.graph.cachedModules.get(id); if ( cachedModule && !cachedModule.customTransformCache && - cachedModule.originalCode === sourceDescription.code + cachedModule.originalCode === sourceDescription.code && + !(await this.pluginDriver.hookFirst('shouldTransformCachedModule', [ + { + ast: cachedModule.ast, + code: cachedModule.code, + id: cachedModule.id, + meta: cachedModule.meta, + moduleSideEffects: cachedModule.moduleSideEffects, + resolvedSources: cachedModule.resolvedIds, + syntheticNamedExports: cachedModule.syntheticNamedExports + } + ])) ) { if (cachedModule.transformFiles) { for (const emittedFile of cachedModule.transformFiles) this.pluginDriver.emitFile(emittedFile); } - module.setSource(cachedModule); + await module.setSource(cachedModule); } else { module.updateOptions(sourceDescription); - module.setSource( - await transform(sourceDescription, module, this.pluginDriver, this.options.onwarn) + await module.setSource( + await transform(sourceDescription, module, this.pluginDriver, this.options.onLog) ); } } @@ -271,27 +347,25 @@ export class ModuleLoader { return loadNewModulesPromise; } - private async fetchDynamicDependencies(module: Module): Promise { + private async fetchDynamicDependencies( + module: Module, + resolveDynamicImportPromises: readonly ResolveDynamicDependencyPromise[] + ): Promise { const dependencies = await Promise.all( - module.dynamicImports.map(async dynamicImport => { - const resolvedId = await this.resolveDynamicImport( - module, - typeof dynamicImport.argument === 'string' - ? dynamicImport.argument - : dynamicImport.argument.esTreeNode, - module.id - ); - if (resolvedId === null) return null; - if (typeof resolvedId === 'string') { - dynamicImport.resolution = resolvedId; - return null; - } - return (dynamicImport.resolution = await this.fetchResolvedDependency( - relativeId(resolvedId.id), - module.id, - resolvedId - )); - }) + resolveDynamicImportPromises.map(resolveDynamicImportPromise => + resolveDynamicImportPromise.then(async ([{ node }, resolvedId]) => { + if (resolvedId === null) return null; + if (typeof resolvedId === 'string') { + node.resolution = resolvedId; + return null; + } + return (node.resolution = await this.fetchResolvedDependency( + relativeId(resolvedId.id), + module.id, + resolvedId + )); + }) + ) ); for (const dependency of dependencies) { if (dependency) { @@ -301,43 +375,82 @@ export class ModuleLoader { } } + // If this is a preload, then this method always waits for the dependencies of + // the module to be resolved. + // Otherwise, if the module does not exist, it waits for the module and all + // its dependencies to be loaded. + // Otherwise, it returns immediately. private async fetchModule( - { id, meta, moduleSideEffects, syntheticNamedExports }: ResolvedId, + { attributes, id, meta, moduleSideEffects, syntheticNamedExports }: ResolvedId, importer: string | undefined, - isEntry: boolean + isEntry: boolean, + isPreload: PreloadType ): Promise { const existingModule = this.modulesById.get(id); if (existingModule instanceof Module) { - if (isEntry) { - existingModule.info.isEntry = true; - this.implicitEntryModules.delete(existingModule); - for (const dependant of existingModule.implicitlyLoadedAfter) { - dependant.implicitlyLoadedBefore.delete(existingModule); - } - existingModule.implicitlyLoadedAfter.clear(); + if (importer && doAttributesDiffer(attributes, existingModule.info.attributes)) { + this.options.onLog( + LOGLEVEL_WARN, + logInconsistentImportAttributes(existingModule.info.attributes, attributes, id, importer) + ); } + await this.handleExistingModule(existingModule, isEntry, isPreload); return existingModule; } - const module: Module = new Module( + if (existingModule instanceof ExternalModule) { + return error(logExternalModulesCannotBeTransformedToModules(existingModule.id)); + } + + const module = new Module( this.graph, id, this.options, isEntry, moduleSideEffects, syntheticNamedExports, - meta + meta, + attributes ); this.modulesById.set(id, module); - this.graph.watchFiles[id] = true; - await this.addModuleSource(id, importer, module); - await this.pluginDriver.hookParallel('moduleParsed', [module.info]); + const loadPromise: LoadModulePromise = this.addModuleSource(id, importer, module).then(() => [ + this.getResolveStaticDependencyPromises(module), + this.getResolveDynamicImportPromises(module), + loadAndResolveDependenciesPromise + ]); + const loadAndResolveDependenciesPromise = waitForDependencyResolution(loadPromise).then(() => + this.pluginDriver.hookParallel('moduleParsed', [module.info]) + ); + loadAndResolveDependenciesPromise.catch(() => { + /* avoid unhandled promise rejections */ + }); + this.moduleLoadPromises.set(module, loadPromise); + const resolveDependencyPromises = await loadPromise; + if (!isPreload) { + await this.fetchModuleDependencies(module, ...resolveDependencyPromises); + } else if (isPreload === RESOLVE_DEPENDENCIES) { + await loadAndResolveDependenciesPromise; + } + return module; + } + + private async fetchModuleDependencies( + module: Module, + resolveStaticDependencyPromises: readonly ResolveStaticDependencyPromise[], + resolveDynamicDependencyPromises: readonly ResolveDynamicDependencyPromise[], + loadAndResolveDependenciesPromise: Promise + ): Promise { + if (this.modulesWithLoadedDependencies.has(module)) { + return; + } + this.modulesWithLoadedDependencies.add(module); await Promise.all([ - this.fetchStaticDependencies(module), - this.fetchDynamicDependencies(module) + this.fetchStaticDependencies(module, resolveStaticDependencyPromises), + this.fetchDynamicDependencies(module, resolveDynamicDependencyPromises) ]); module.linkImports(); - return module; + // To handle errors when resolving dependencies or in moduleParsed + await loadAndResolveDependenciesPromise; } private fetchResolvedDependency( @@ -346,49 +459,57 @@ export class ModuleLoader { resolvedId: ResolvedId ): Promise { if (resolvedId.external) { - const { external, id, moduleSideEffects, meta } = resolvedId; - if (!this.modulesById.has(id)) { - this.modulesById.set( + const { attributes, external, id, moduleSideEffects, meta } = resolvedId; + let externalModule = this.modulesById.get(id); + if (!externalModule) { + externalModule = new ExternalModule( + this.options, id, - new ExternalModule( - this.options, - id, - moduleSideEffects, - meta, - external !== 'absolute' && isAbsolute(id) + moduleSideEffects, + meta, + external !== 'absolute' && isAbsolute(id), + attributes + ); + this.modulesById.set(id, externalModule); + } else if (!(externalModule instanceof ExternalModule)) { + return error(logInternalIdCannotBeExternal(source, importer)); + } else if (doAttributesDiffer(externalModule.info.attributes, attributes)) { + this.options.onLog( + LOGLEVEL_WARN, + logInconsistentImportAttributes( + externalModule.info.attributes, + attributes, + source, + importer ) ); } - - const externalModule = this.modulesById.get(id); - if (!(externalModule instanceof ExternalModule)) { - return error(errInternalIdCannotBeExternal(source, importer)); - } return Promise.resolve(externalModule); - } else { - return this.fetchModule(resolvedId, importer, false); } + return this.fetchModule(resolvedId, importer, false, false); } - private async fetchStaticDependencies(module: Module): Promise { + private async fetchStaticDependencies( + module: Module, + resolveStaticDependencyPromises: readonly ResolveStaticDependencyPromise[] + ): Promise { for (const dependency of await Promise.all( - Array.from(module.sources, async source => - this.fetchResolvedDependency( - source, - module.id, - (module.resolvedIds[source] = - module.resolvedIds[source] || - this.handleResolveId( - await this.resolveId(source, module.id, EMPTY_OBJECT), - source, - module.id - )) + resolveStaticDependencyPromises.map(resolveStaticDependencyPromise => + resolveStaticDependencyPromise.then(([source, resolvedId]) => + this.fetchResolvedDependency(source, module.id, resolvedId) ) ) )) { module.dependencies.add(dependency); dependency.importers.push(module.id); } + if (!this.options.treeshake || module.info.moduleSideEffects === 'no-treeshake') { + for (const dependency of module.dependencies) { + if (dependency instanceof Module) { + dependency.importedFromNotTreeshaken = true; + } + } + } } private getNormalizedResolvedIdWithoutDefaults( @@ -438,27 +559,104 @@ export class ModuleLoader { }; } - private handleResolveId( + private getResolveDynamicImportPromises(module: Module): ResolveDynamicDependencyPromise[] { + return module.dynamicImports.map(async dynamicImport => { + const resolvedId = await this.resolveDynamicImport( + module, + dynamicImport.argument, + module.id, + getAttributesFromImportExpression(dynamicImport.node) + ); + if (!resolvedId || typeof resolvedId === 'string') { + dynamicImport.node.shouldIncludeDynamicAttributes = true; + } else { + dynamicImport.node.shouldIncludeDynamicAttributes = !!resolvedId.external; + dynamicImport.id = resolvedId.id; + } + return [dynamicImport, resolvedId] as const; + }); + } + + private getResolveStaticDependencyPromises(module: Module): ResolveStaticDependencyPromise[] { + return Array.from( + module.sourcesWithAttributes, + async ([source, attributes]) => + [ + source, + (module.resolvedIds[source] = + module.resolvedIds[source] || + this.handleInvalidResolvedId( + await this.resolveId(source, module.id, EMPTY_OBJECT, false, attributes), + source, + module.id, + attributes + )) + ] as const + ); + } + + private getResolvedIdWithDefaults( + resolvedId: NormalizedResolveIdWithoutDefaults | null, + attributes: Record + ): ResolvedId | null { + if (!resolvedId) { + return null; + } + const external = resolvedId.external || false; + return { + attributes: resolvedId.attributes || attributes, + external, + id: resolvedId.id, + meta: resolvedId.meta || {}, + moduleSideEffects: + resolvedId.moduleSideEffects ?? this.hasModuleSideEffects(resolvedId.id, !!external), + resolvedBy: resolvedId.resolvedBy ?? 'rollup', + syntheticNamedExports: resolvedId.syntheticNamedExports ?? false + }; + } + + private async handleExistingModule(module: Module, isEntry: boolean, isPreload: PreloadType) { + const loadPromise = this.moduleLoadPromises.get(module)!; + if (isPreload) { + return isPreload === RESOLVE_DEPENDENCIES + ? waitForDependencyResolution(loadPromise) + : loadPromise; + } + if (isEntry) { + // This reverts the changes in addEntryWithImplicitDependants and needs to + // be performed atomically + module.info.isEntry = true; + this.implicitEntryModules.delete(module); + for (const dependant of module.implicitlyLoadedAfter) { + dependant.implicitlyLoadedBefore.delete(module); + } + module.implicitlyLoadedAfter.clear(); + } + return this.fetchModuleDependencies(module, ...(await loadPromise)); + } + + private handleInvalidResolvedId( resolvedId: ResolvedId | null, source: string, - importer: string + importer: string, + attributes: Record ): ResolvedId { if (resolvedId === null) { if (isRelative(source)) { - return error(errUnresolvedImport(source, importer)); + return error(logUnresolvedImport(source, importer)); } - this.options.onwarn(errUnresolvedImportTreatedAsExternal(source, importer)); + this.options.onLog(LOGLEVEL_WARN, logUnresolvedImportTreatedAsExternal(source, importer)); return { + attributes, external: true, id: source, - meta: EMPTY_OBJECT, + meta: {}, moduleSideEffects: this.hasModuleSideEffects(source, true), + resolvedBy: 'rollup', syntheticNamedExports: false }; - } else { - if (resolvedId.external && resolvedId.syntheticNamedExports) { - this.options.onwarn(errExternalSyntheticExports(source, importer)); - } + } else if (resolvedId.external && resolvedId.syntheticNamedExports) { + this.options.onLog(LOGLEVEL_WARN, logExternalSyntheticExports(source, importer)); } return resolvedId; } @@ -467,7 +665,8 @@ export class ModuleLoader { unresolvedId: string, isEntry: boolean, importer: string | undefined, - implicitlyLoadedBefore: string | null + implicitlyLoadedBefore: string | null, + isLoadForManualChunks = false ): Promise { const resolveIdResult = await resolveId( unresolvedId, @@ -476,44 +675,51 @@ export class ModuleLoader { this.pluginDriver, this.resolveId, null, - EMPTY_OBJECT + EMPTY_OBJECT, + true, + EMPTY_OBJECT, + this.options.fs ); if (resolveIdResult == null) { return error( implicitlyLoadedBefore === null - ? errUnresolvedEntry(unresolvedId) - : errUnresolvedImplicitDependant(unresolvedId, implicitlyLoadedBefore) + ? logUnresolvedEntry(unresolvedId) + : logUnresolvedImplicitDependant(unresolvedId, implicitlyLoadedBefore) ); } - if ( - resolveIdResult === false || - (typeof resolveIdResult === 'object' && resolveIdResult.external) - ) { + const isExternalModules = typeof resolveIdResult === 'object' && resolveIdResult.external; + if (resolveIdResult === false || isExternalModules) { return error( implicitlyLoadedBefore === null - ? errEntryCannotBeExternal(unresolvedId) - : errImplicitDependantCannotBeExternal(unresolvedId, implicitlyLoadedBefore) + ? isExternalModules && isLoadForManualChunks + ? logExternalModulesCannotBeIncludedInManualChunks(unresolvedId) + : logEntryCannotBeExternal(unresolvedId) + : logImplicitDependantCannotBeExternal(unresolvedId, implicitlyLoadedBefore) ); } return this.fetchModule( - this.addDefaultsToResolvedId( + this.getResolvedIdWithDefaults( typeof resolveIdResult === 'object' ? (resolveIdResult as NormalizedResolveIdWithoutDefaults) - : { id: resolveIdResult } + : { id: resolveIdResult }, + EMPTY_OBJECT )!, undefined, - isEntry + isEntry, + false ); } private async resolveDynamicImport( module: Module, - specifier: string | acorn.Node, - importer: string + specifier: string | AstNode, + importer: string, + attributes: Record ): Promise { const resolution = await this.pluginDriver.hookFirst('resolveDynamicImport', [ specifier, - importer + importer, + { attributes } ]); if (typeof specifier !== 'string') { if (typeof resolution === 'string') { @@ -522,27 +728,42 @@ export class ModuleLoader { if (!resolution) { return null; } - return { - external: false, - moduleSideEffects: true, - ...resolution - } as ResolvedId; + return this.getResolvedIdWithDefaults( + resolution as NormalizedResolveIdWithoutDefaults, + attributes + ); } if (resolution == null) { - return (module.resolvedIds[specifier] = - module.resolvedIds[specifier] || - this.handleResolveId( - await this.resolveId(specifier, module.id, EMPTY_OBJECT), - specifier, - module.id - )); + const existingResolution = module.resolvedIds[specifier]; + if (existingResolution) { + if (doAttributesDiffer(existingResolution.attributes, attributes)) { + this.options.onLog( + LOGLEVEL_WARN, + logInconsistentImportAttributes( + existingResolution.attributes, + attributes, + specifier, + importer + ) + ); + } + return existingResolution; + } + return (module.resolvedIds[specifier] = this.handleInvalidResolvedId( + await this.resolveId(specifier, module.id, EMPTY_OBJECT, false, attributes), + specifier, + module.id, + attributes + )); } - return this.handleResolveId( - this.addDefaultsToResolvedId( - this.getNormalizedResolvedIdWithoutDefaults(resolution, importer, specifier) + return this.handleInvalidResolvedId( + this.getResolvedIdWithDefaults( + this.getNormalizedResolvedIdWithoutDefaults(resolution, importer, specifier), + attributes ), specifier, - importer + importer, + attributes ); } } @@ -558,17 +779,16 @@ function normalizeRelativeExternalId(source: string, importer: string | undefine function addChunkNamesToModule( module: Module, { fileName, name }: UnresolvedModule, - isUserDefined: boolean -) { + isUserDefined: boolean, + priority: number +): void { if (fileName !== null) { module.chunkFileNames.add(fileName); } else if (name !== null) { - if (module.chunkName === null) { - module.chunkName = name; - } - if (isUserDefined) { - module.userChunkNames.add(name); - } + // Always keep chunkNames sorted by priority + let namePosition = 0; + while (module.chunkNames[namePosition]?.priority < priority) namePosition++; + module.chunkNames.splice(namePosition, 0, { isUserDefined, name, priority }); } } @@ -576,10 +796,15 @@ function isNotAbsoluteExternal( id: string, source: string, makeAbsoluteExternalsRelative: boolean | 'ifRelativeSource' -) { +): boolean { return ( makeAbsoluteExternalsRelative === true || (makeAbsoluteExternalsRelative === 'ifRelativeSource' && isRelative(source)) || !isAbsolute(id) ); } + +async function waitForDependencyResolution(loadPromise: LoadModulePromise) { + const [resolveStaticDependencyPromises, resolveDynamicImportPromises] = await loadPromise; + return Promise.all([...resolveStaticDependencyPromises, ...resolveDynamicImportPromises]); +} diff --git a/src/ast/CallOptions.ts b/src/ast/CallOptions.ts deleted file mode 100644 index ad368d69951..00000000000 --- a/src/ast/CallOptions.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { ExpressionEntity } from './nodes/shared/Expression'; -import SpreadElement from './nodes/SpreadElement'; - -export const NO_ARGS = []; - -export interface CallOptions { - args: (ExpressionEntity | SpreadElement)[]; - withNew: boolean; -} diff --git a/src/ast/Entity.ts b/src/ast/Entity.ts index f67667c74c4..86397d60786 100644 --- a/src/ast/Entity.ts +++ b/src/ast/Entity.ts @@ -1,9 +1,9 @@ -import { HasEffectsContext } from './ExecutionContext'; -import { ObjectPath } from './utils/PathTracker'; +import type { HasEffectsContext } from './ExecutionContext'; +import type { NodeInteractionAssigned } from './NodeInteractions'; +import type { ObjectPath } from './utils/PathTracker'; -export interface Entity { - toString: () => string; -} +// eslint-disable-next-line @typescript-eslint/no-empty-object-type +export interface Entity {} export interface WritableEntity extends Entity { /** @@ -13,5 +13,10 @@ export interface WritableEntity extends Entity { * expression of this node is reassigned as well. */ deoptimizePath(path: ObjectPath): void; - hasEffectsWhenAssignedAtPath(path: ObjectPath, execution: HasEffectsContext): boolean; + + hasEffectsOnInteractionAtPath( + path: ObjectPath, + interaction: NodeInteractionAssigned, + context: HasEffectsContext + ): boolean; } diff --git a/src/ast/ExecutionContext.ts b/src/ast/ExecutionContext.ts index 09d6d313fc0..df7bb363769 100644 --- a/src/ast/ExecutionContext.ts +++ b/src/ast/ExecutionContext.ts @@ -1,21 +1,20 @@ -import { Entity } from './Entity'; -import { ExpressionEntity } from './nodes/shared/Expression'; -import { DiscriminatedPathTracker, PathTracker } from './utils/PathTracker'; -import ThisVariable from './variables/ThisVariable'; +import type { Entity } from './Entity'; +import type { ExpressionEntity } from './nodes/shared/Expression'; +import { DiscriminatedPathTracker, EntityPathTracker } from './utils/PathTracker'; +import type ThisVariable from './variables/ThisVariable'; interface ExecutionContextIgnore { breaks: boolean; continues: boolean; labels: Set; - returnAwaitYield: boolean; + returnYield: boolean; + this: boolean; } -export const BROKEN_FLOW_NONE = 0; -export const BROKEN_FLOW_BREAK_CONTINUE = 1; -export const BROKEN_FLOW_ERROR_RETURN_LABEL = 2; - interface ControlFlowContext { - brokenFlow: number; + brokenFlow: boolean; + hasBreak: boolean; + hasContinue: boolean; includedLabels: Set; } @@ -24,9 +23,9 @@ export interface InclusionContext extends ControlFlowContext { } export interface HasEffectsContext extends ControlFlowContext { - accessed: PathTracker; - assigned: PathTracker; - brokenFlow: number; + accessed: EntityPathTracker; + assigned: EntityPathTracker; + brokenFlow: boolean; called: DiscriminatedPathTracker; ignore: ExecutionContextIgnore; instantiated: DiscriminatedPathTracker; @@ -35,7 +34,9 @@ export interface HasEffectsContext extends ControlFlowContext { export function createInclusionContext(): InclusionContext { return { - brokenFlow: BROKEN_FLOW_NONE, + brokenFlow: false, + hasBreak: false, + hasContinue: false, includedCallArguments: new Set(), includedLabels: new Set() }; @@ -43,15 +44,18 @@ export function createInclusionContext(): InclusionContext { export function createHasEffectsContext(): HasEffectsContext { return { - accessed: new PathTracker(), - assigned: new PathTracker(), - brokenFlow: BROKEN_FLOW_NONE, + accessed: new EntityPathTracker(), + assigned: new EntityPathTracker(), + brokenFlow: false, called: new DiscriminatedPathTracker(), + hasBreak: false, + hasContinue: false, ignore: { breaks: false, continues: false, labels: new Set(), - returnAwaitYield: false + returnYield: false, + this: false }, includedLabels: new Set(), instantiated: new DiscriminatedPathTracker(), diff --git a/src/ast/NodeInteractions.ts b/src/ast/NodeInteractions.ts new file mode 100644 index 00000000000..012da794330 --- /dev/null +++ b/src/ast/NodeInteractions.ts @@ -0,0 +1,51 @@ +import type SpreadElement from './nodes/SpreadElement'; +import type { ExpressionEntity } from './nodes/shared/Expression'; +import { UNKNOWN_EXPRESSION } from './nodes/shared/Expression'; + +export const INTERACTION_ACCESSED = 0; +export const INTERACTION_ASSIGNED = 1; +export const INTERACTION_CALLED = 2; + +// The first argument is the "this" context +export interface NodeInteractionAccessed { + args: readonly [ExpressionEntity | null]; + type: typeof INTERACTION_ACCESSED; +} + +export const NODE_INTERACTION_UNKNOWN_ACCESS: NodeInteractionAccessed = { + args: [null], + type: INTERACTION_ACCESSED +}; + +// The first argument is the "this" context, the second argument the assigned expression +export interface NodeInteractionAssigned { + args: readonly [ExpressionEntity | null, ExpressionEntity]; + type: typeof INTERACTION_ASSIGNED; +} + +export const NODE_INTERACTION_UNKNOWN_ASSIGNMENT: NodeInteractionAssigned = { + args: [null, UNKNOWN_EXPRESSION], + type: INTERACTION_ASSIGNED +}; + +// The first argument is the "this" context, the other arguments are the actual arguments +export interface NodeInteractionCalled { + args: readonly [ExpressionEntity | null, ...(ExpressionEntity | SpreadElement)[]]; + type: typeof INTERACTION_CALLED; + withNew: boolean; +} + +// While this is technically a call without arguments, we can compare against +// this reference in places where precise values or this argument would make a +// difference +export const NODE_INTERACTION_UNKNOWN_CALL: NodeInteractionCalled = { + args: [null], + type: INTERACTION_CALLED, + withNew: false +}; + +// For tracking, interactions are uniquely determined by their .args +export type NodeInteraction = + | NodeInteractionAccessed + | NodeInteractionAssigned + | NodeInteractionCalled; diff --git a/src/ast/bufferParsers.ts b/src/ast/bufferParsers.ts new file mode 100644 index 00000000000..826f12b3c09 --- /dev/null +++ b/src/ast/bufferParsers.ts @@ -0,0 +1,935 @@ +// This file is generated by scripts/generate-buffer-parsers.js. +// Do not edit this file directly. + +import type * as estree from 'estree'; +import type { AstContext } from '../Module'; +import { convertAnnotations } from '../utils/astConverterHelpers'; +import { EMPTY_ARRAY } from '../utils/blank'; +import { convertNode as convertJsonNode } from '../utils/bufferToAst'; +import FIXED_STRINGS from '../utils/convert-ast-strings'; +import type { AstBuffer } from '../utils/getAstBuffer'; +import { getAstBuffer } from '../utils/getAstBuffer'; +import ArrayExpression from './nodes/ArrayExpression'; +import ArrayPattern from './nodes/ArrayPattern'; +import ArrowFunctionExpression from './nodes/ArrowFunctionExpression'; +import AssignmentExpression from './nodes/AssignmentExpression'; +import AssignmentPattern from './nodes/AssignmentPattern'; +import AwaitExpression from './nodes/AwaitExpression'; +import BinaryExpression from './nodes/BinaryExpression'; +import BlockStatement from './nodes/BlockStatement'; +import BreakStatement from './nodes/BreakStatement'; +import CallExpression from './nodes/CallExpression'; +import CatchClause from './nodes/CatchClause'; +import ChainExpression from './nodes/ChainExpression'; +import ClassBody from './nodes/ClassBody'; +import ClassDeclaration from './nodes/ClassDeclaration'; +import ClassExpression from './nodes/ClassExpression'; +import ConditionalExpression from './nodes/ConditionalExpression'; +import ContinueStatement from './nodes/ContinueStatement'; +import DebuggerStatement from './nodes/DebuggerStatement'; +import Decorator from './nodes/Decorator'; +import DoWhileStatement from './nodes/DoWhileStatement'; +import EmptyStatement from './nodes/EmptyStatement'; +import ExportAllDeclaration from './nodes/ExportAllDeclaration'; +import ExportDefaultDeclaration from './nodes/ExportDefaultDeclaration'; +import ExportNamedDeclaration from './nodes/ExportNamedDeclaration'; +import ExportSpecifier from './nodes/ExportSpecifier'; +import ExpressionStatement from './nodes/ExpressionStatement'; +import ForInStatement from './nodes/ForInStatement'; +import ForOfStatement from './nodes/ForOfStatement'; +import ForStatement from './nodes/ForStatement'; +import FunctionDeclaration from './nodes/FunctionDeclaration'; +import FunctionExpression from './nodes/FunctionExpression'; +import Identifier from './nodes/Identifier'; +import IfStatement from './nodes/IfStatement'; +import ImportAttribute from './nodes/ImportAttribute'; +import ImportDeclaration from './nodes/ImportDeclaration'; +import ImportDefaultSpecifier from './nodes/ImportDefaultSpecifier'; +import ImportExpression from './nodes/ImportExpression'; +import ImportNamespaceSpecifier from './nodes/ImportNamespaceSpecifier'; +import ImportSpecifier from './nodes/ImportSpecifier'; +import JSXAttribute from './nodes/JSXAttribute'; +import JSXClosingElement from './nodes/JSXClosingElement'; +import JSXClosingFragment from './nodes/JSXClosingFragment'; +import JSXElement from './nodes/JSXElement'; +import JSXEmptyExpression from './nodes/JSXEmptyExpression'; +import JSXExpressionContainer from './nodes/JSXExpressionContainer'; +import JSXFragment from './nodes/JSXFragment'; +import JSXIdentifier from './nodes/JSXIdentifier'; +import JSXMemberExpression from './nodes/JSXMemberExpression'; +import JSXNamespacedName from './nodes/JSXNamespacedName'; +import JSXOpeningElement from './nodes/JSXOpeningElement'; +import JSXOpeningFragment from './nodes/JSXOpeningFragment'; +import JSXSpreadAttribute from './nodes/JSXSpreadAttribute'; +import JSXSpreadChild from './nodes/JSXSpreadChild'; +import JSXText from './nodes/JSXText'; +import LabeledStatement from './nodes/LabeledStatement'; +import Literal from './nodes/Literal'; +import LogicalExpression from './nodes/LogicalExpression'; +import MemberExpression from './nodes/MemberExpression'; +import MetaProperty from './nodes/MetaProperty'; +import MethodDefinition from './nodes/MethodDefinition'; +import NewExpression from './nodes/NewExpression'; +import ObjectExpression from './nodes/ObjectExpression'; +import ObjectPattern from './nodes/ObjectPattern'; +import PanicError from './nodes/PanicError'; +import ParseError from './nodes/ParseError'; +import PrivateIdentifier from './nodes/PrivateIdentifier'; +import Program from './nodes/Program'; +import Property from './nodes/Property'; +import PropertyDefinition from './nodes/PropertyDefinition'; +import RestElement from './nodes/RestElement'; +import ReturnStatement from './nodes/ReturnStatement'; +import SequenceExpression from './nodes/SequenceExpression'; +import SpreadElement from './nodes/SpreadElement'; +import StaticBlock from './nodes/StaticBlock'; +import Super from './nodes/Super'; +import SwitchCase from './nodes/SwitchCase'; +import SwitchStatement from './nodes/SwitchStatement'; +import TaggedTemplateExpression from './nodes/TaggedTemplateExpression'; +import TemplateElement from './nodes/TemplateElement'; +import TemplateLiteral from './nodes/TemplateLiteral'; +import ThisExpression from './nodes/ThisExpression'; +import ThrowStatement from './nodes/ThrowStatement'; +import TryStatement from './nodes/TryStatement'; +import UnaryExpression from './nodes/UnaryExpression'; +import UpdateExpression from './nodes/UpdateExpression'; +import VariableDeclaration from './nodes/VariableDeclaration'; +import VariableDeclarator from './nodes/VariableDeclarator'; +import WhileStatement from './nodes/WhileStatement'; +import YieldExpression from './nodes/YieldExpression'; +import { UNKNOWN_EXPRESSION } from './nodes/shared/Expression'; +import type { Node, NodeBase } from './nodes/shared/Node'; +import type ChildScope from './scopes/ChildScope'; +import type ModuleScope from './scopes/ModuleScope'; +import TrackingScope from './scopes/TrackingScope'; +import { EMPTY_PATH } from './utils/PathTracker'; +import type ParameterVariable from './variables/ParameterVariable'; + +export function convertProgram( + buffer: Buffer | Uint8Array, + parent: Node | { context: AstContext; type: string }, + parentScope: ModuleScope +): Program { + return convertNode(parent, parentScope, 0, getAstBuffer(buffer)); +} + +const nodeTypeStrings = [ + 'PanicError', + 'ParseError', + 'ArrayExpression', + 'ArrayPattern', + 'ArrowFunctionExpression', + 'AssignmentExpression', + 'AssignmentPattern', + 'AwaitExpression', + 'BinaryExpression', + 'BlockStatement', + 'BreakStatement', + 'CallExpression', + 'CatchClause', + 'ChainExpression', + 'ClassBody', + 'ClassDeclaration', + 'ClassExpression', + 'ConditionalExpression', + 'ContinueStatement', + 'DebuggerStatement', + 'Decorator', + 'ExpressionStatement', + 'DoWhileStatement', + 'EmptyStatement', + 'ExportAllDeclaration', + 'ExportDefaultDeclaration', + 'ExportNamedDeclaration', + 'ExportSpecifier', + 'ExpressionStatement', + 'ForInStatement', + 'ForOfStatement', + 'ForStatement', + 'FunctionDeclaration', + 'FunctionExpression', + 'Identifier', + 'IfStatement', + 'ImportAttribute', + 'ImportDeclaration', + 'ImportDefaultSpecifier', + 'ImportExpression', + 'ImportNamespaceSpecifier', + 'ImportSpecifier', + 'JSXAttribute', + 'JSXClosingElement', + 'JSXClosingFragment', + 'JSXElement', + 'JSXEmptyExpression', + 'JSXExpressionContainer', + 'JSXFragment', + 'JSXIdentifier', + 'JSXMemberExpression', + 'JSXNamespacedName', + 'JSXOpeningElement', + 'JSXOpeningFragment', + 'JSXSpreadAttribute', + 'JSXSpreadChild', + 'JSXText', + 'LabeledStatement', + 'Literal', + 'Literal', + 'Literal', + 'Literal', + 'Literal', + 'Literal', + 'LogicalExpression', + 'MemberExpression', + 'MetaProperty', + 'MethodDefinition', + 'NewExpression', + 'ObjectExpression', + 'ObjectPattern', + 'PrivateIdentifier', + 'Program', + 'Property', + 'PropertyDefinition', + 'RestElement', + 'ReturnStatement', + 'SequenceExpression', + 'SpreadElement', + 'StaticBlock', + 'Super', + 'SwitchCase', + 'SwitchStatement', + 'TaggedTemplateExpression', + 'TemplateElement', + 'TemplateLiteral', + 'ThisExpression', + 'ThrowStatement', + 'TryStatement', + 'UnaryExpression', + 'UpdateExpression', + 'VariableDeclaration', + 'VariableDeclarator', + 'WhileStatement', + 'YieldExpression' +] as const; + +const nodeConstructors: (typeof NodeBase)[] = [ + PanicError, + ParseError, + ArrayExpression, + ArrayPattern, + ArrowFunctionExpression, + AssignmentExpression, + AssignmentPattern, + AwaitExpression, + BinaryExpression, + BlockStatement, + BreakStatement, + CallExpression, + CatchClause, + ChainExpression, + ClassBody, + ClassDeclaration, + ClassExpression, + ConditionalExpression, + ContinueStatement, + DebuggerStatement, + Decorator, + ExpressionStatement, + DoWhileStatement, + EmptyStatement, + ExportAllDeclaration, + ExportDefaultDeclaration, + ExportNamedDeclaration, + ExportSpecifier, + ExpressionStatement, + ForInStatement, + ForOfStatement, + ForStatement, + FunctionDeclaration, + FunctionExpression, + Identifier, + IfStatement, + ImportAttribute, + ImportDeclaration, + ImportDefaultSpecifier, + ImportExpression, + ImportNamespaceSpecifier, + ImportSpecifier, + JSXAttribute, + JSXClosingElement, + JSXClosingFragment, + JSXElement, + JSXEmptyExpression, + JSXExpressionContainer, + JSXFragment, + JSXIdentifier, + JSXMemberExpression, + JSXNamespacedName, + JSXOpeningElement, + JSXOpeningFragment, + JSXSpreadAttribute, + JSXSpreadChild, + JSXText, + LabeledStatement, + Literal, + Literal, + Literal, + Literal, + Literal, + Literal, + LogicalExpression, + MemberExpression, + MetaProperty, + MethodDefinition, + NewExpression, + ObjectExpression, + ObjectPattern, + PrivateIdentifier, + Program, + Property, + PropertyDefinition, + RestElement, + ReturnStatement, + SequenceExpression, + SpreadElement, + StaticBlock, + Super, + SwitchCase, + SwitchStatement, + TaggedTemplateExpression, + TemplateElement, + TemplateLiteral, + ThisExpression, + ThrowStatement, + TryStatement, + UnaryExpression, + UpdateExpression, + VariableDeclaration, + VariableDeclarator, + WhileStatement, + YieldExpression +]; + +const bufferParsers: ((node: any, position: number, buffer: AstBuffer) => void)[] = [ + function panicError(node: PanicError, position, buffer) { + node.message = buffer.convertString(buffer[position]); + }, + function parseError(node: ParseError, position, buffer) { + node.message = buffer.convertString(buffer[position]); + }, + function arrayExpression(node: ArrayExpression, position, buffer) { + const { scope } = node; + node.elements = convertNodeList(node, scope, buffer[position], buffer); + }, + function arrayPattern(node: ArrayPattern, position, buffer) { + const { scope } = node; + node.elements = convertNodeList(node, scope, buffer[position], buffer); + }, + function arrowFunctionExpression(node: ArrowFunctionExpression, position, buffer) { + const { scope } = node; + const flags = buffer[position]; + node.async = (flags & 1) === 1; + node.expression = (flags & 2) === 2; + node.generator = (flags & 4) === 4; + const annotations = (node.annotations = convertAnnotations(buffer[position + 1], buffer)); + node.annotationNoSideEffects = annotations.some(comment => comment.type === 'noSideEffects'); + const parameters = (node.params = convertNodeList(node, scope, buffer[position + 2], buffer)); + scope.addParameterVariables( + parameters.map( + parameter => + parameter.declare('parameter', EMPTY_PATH, UNKNOWN_EXPRESSION) as ParameterVariable[] + ), + parameters[parameters.length - 1] instanceof RestElement + ); + node.body = convertNode(node, scope.bodyScope, buffer[position + 3], buffer); + }, + function assignmentExpression(node: AssignmentExpression, position, buffer) { + const { scope } = node; + node.operator = FIXED_STRINGS[buffer[position]] as estree.AssignmentOperator; + node.left = convertNode(node, scope, buffer[position + 1], buffer); + node.right = convertNode(node, scope, buffer[position + 2], buffer); + }, + function assignmentPattern(node: AssignmentPattern, position, buffer) { + const { scope } = node; + node.left = convertNode(node, scope, buffer[position], buffer); + node.right = convertNode(node, scope, buffer[position + 1], buffer); + }, + function awaitExpression(node: AwaitExpression, position, buffer) { + const { scope } = node; + node.argument = convertNode(node, scope, buffer[position], buffer); + }, + function binaryExpression(node: BinaryExpression, position, buffer) { + const { scope } = node; + node.operator = FIXED_STRINGS[buffer[position]] as estree.BinaryOperator; + node.left = convertNode(node, scope, buffer[position + 1], buffer); + node.right = convertNode(node, scope, buffer[position + 2], buffer); + }, + function blockStatement(node: BlockStatement, position, buffer) { + const { scope } = node; + node.body = convertNodeList(node, scope, buffer[position], buffer); + }, + function breakStatement(node: BreakStatement, position, buffer) { + const { scope } = node; + const labelPosition = buffer[position]; + node.label = labelPosition === 0 ? null : convertNode(node, scope, labelPosition, buffer); + }, + function callExpression(node: CallExpression, position, buffer) { + const { scope } = node; + const flags = buffer[position]; + node.optional = (flags & 1) === 1; + node.annotations = convertAnnotations(buffer[position + 1], buffer); + node.callee = convertNode(node, scope, buffer[position + 2], buffer); + node.arguments = convertNodeList(node, scope, buffer[position + 3], buffer); + }, + function catchClause(node: CatchClause, position, buffer) { + const { scope } = node; + const parameterPosition = buffer[position]; + const parameter = (node.param = + parameterPosition === 0 ? null : convertNode(node, scope, parameterPosition, buffer)); + parameter?.declare('parameter', EMPTY_PATH, UNKNOWN_EXPRESSION); + node.body = convertNode(node, scope.bodyScope, buffer[position + 1], buffer); + }, + function chainExpression(node: ChainExpression, position, buffer) { + const { scope } = node; + node.expression = convertNode(node, scope, buffer[position], buffer); + }, + function classBody(node: ClassBody, position, buffer) { + const { scope } = node; + const bodyPosition = buffer[position]; + if (bodyPosition) { + const length = buffer[bodyPosition]; + const body: (MethodDefinition | PropertyDefinition | StaticBlock)[] = (node.body = new Array( + length + )); + for (let index = 0; index < length; index++) { + const nodePosition = buffer[bodyPosition + 1 + index]; + body[index] = convertNode( + node, + buffer[nodePosition] !== 79 && + (buffer[nodePosition + 3] & /* the static flag is always first */ 1) === 0 + ? scope.instanceScope + : scope, + nodePosition, + buffer + ); + } + } else { + node.body = []; + } + }, + function classDeclaration(node: ClassDeclaration, position, buffer) { + const { scope } = node; + node.decorators = convertNodeList(node, scope, buffer[position], buffer); + const idPosition = buffer[position + 1]; + node.id = + idPosition === 0 ? null : convertNode(node, scope.parent as ChildScope, idPosition, buffer); + const superClassPosition = buffer[position + 2]; + node.superClass = + superClassPosition === 0 ? null : convertNode(node, scope, superClassPosition, buffer); + node.body = convertNode(node, scope, buffer[position + 3], buffer); + }, + function classExpression(node: ClassExpression, position, buffer) { + const { scope } = node; + node.decorators = convertNodeList(node, scope, buffer[position], buffer); + const idPosition = buffer[position + 1]; + node.id = idPosition === 0 ? null : convertNode(node, scope, idPosition, buffer); + const superClassPosition = buffer[position + 2]; + node.superClass = + superClassPosition === 0 ? null : convertNode(node, scope, superClassPosition, buffer); + node.body = convertNode(node, scope, buffer[position + 3], buffer); + }, + function conditionalExpression(node: ConditionalExpression, position, buffer) { + const { scope } = node; + node.test = convertNode(node, scope, buffer[position], buffer); + node.consequent = convertNode(node, scope, buffer[position + 1], buffer); + node.alternate = convertNode(node, scope, buffer[position + 2], buffer); + }, + function continueStatement(node: ContinueStatement, position, buffer) { + const { scope } = node; + const labelPosition = buffer[position]; + node.label = labelPosition === 0 ? null : convertNode(node, scope, labelPosition, buffer); + }, + function debuggerStatement() {}, + function decorator(node: Decorator, position, buffer) { + const { scope } = node; + node.expression = convertNode(node, scope, buffer[position], buffer); + }, + function directive(node: ExpressionStatement, position, buffer) { + const { scope } = node; + node.directive = buffer.convertString(buffer[position]); + node.expression = convertNode(node, scope, buffer[position + 1], buffer); + }, + function doWhileStatement(node: DoWhileStatement, position, buffer) { + const { scope } = node; + node.body = convertNode(node, scope, buffer[position], buffer); + node.test = convertNode(node, scope, buffer[position + 1], buffer); + }, + function emptyStatement() {}, + function exportAllDeclaration(node: ExportAllDeclaration, position, buffer) { + const { scope } = node; + const exportedPosition = buffer[position]; + node.exported = + exportedPosition === 0 ? null : convertNode(node, scope, exportedPosition, buffer); + node.source = convertNode(node, scope, buffer[position + 1], buffer); + node.attributes = convertNodeList(node, scope, buffer[position + 2], buffer); + }, + function exportDefaultDeclaration(node: ExportDefaultDeclaration, position, buffer) { + const { scope } = node; + node.declaration = convertNode(node, scope, buffer[position], buffer); + }, + function exportNamedDeclaration(node: ExportNamedDeclaration, position, buffer) { + const { scope } = node; + node.specifiers = convertNodeList(node, scope, buffer[position], buffer); + const sourcePosition = buffer[position + 1]; + node.source = sourcePosition === 0 ? null : convertNode(node, scope, sourcePosition, buffer); + node.attributes = convertNodeList(node, scope, buffer[position + 2], buffer); + const declarationPosition = buffer[position + 3]; + node.declaration = + declarationPosition === 0 ? null : convertNode(node, scope, declarationPosition, buffer); + }, + function exportSpecifier(node: ExportSpecifier, position, buffer) { + const { scope } = node; + node.local = convertNode(node, scope, buffer[position], buffer); + const exportedPosition = buffer[position + 1]; + node.exported = + exportedPosition === 0 ? node.local : convertNode(node, scope, exportedPosition, buffer); + }, + function expressionStatement(node: ExpressionStatement, position, buffer) { + const { scope } = node; + node.expression = convertNode(node, scope, buffer[position], buffer); + }, + function forInStatement(node: ForInStatement, position, buffer) { + const { scope } = node; + node.left = convertNode(node, scope, buffer[position], buffer); + node.right = convertNode(node, scope, buffer[position + 1], buffer); + node.body = convertNode(node, scope, buffer[position + 2], buffer); + }, + function forOfStatement(node: ForOfStatement, position, buffer) { + const { scope } = node; + const flags = buffer[position]; + node.await = (flags & 1) === 1; + node.left = convertNode(node, scope, buffer[position + 1], buffer); + node.right = convertNode(node, scope, buffer[position + 2], buffer); + node.body = convertNode(node, scope, buffer[position + 3], buffer); + }, + function forStatement(node: ForStatement, position, buffer) { + const { scope } = node; + const initPosition = buffer[position]; + node.init = initPosition === 0 ? null : convertNode(node, scope, initPosition, buffer); + const testPosition = buffer[position + 1]; + node.test = testPosition === 0 ? null : convertNode(node, scope, testPosition, buffer); + const updatePosition = buffer[position + 2]; + node.update = updatePosition === 0 ? null : convertNode(node, scope, updatePosition, buffer); + node.body = convertNode(node, scope, buffer[position + 3], buffer); + }, + function functionDeclaration(node: FunctionDeclaration, position, buffer) { + const { scope } = node; + const flags = buffer[position]; + node.async = (flags & 1) === 1; + node.generator = (flags & 2) === 2; + const annotations = (node.annotations = convertAnnotations(buffer[position + 1], buffer)); + node.annotationNoSideEffects = annotations.some(comment => comment.type === 'noSideEffects'); + const idPosition = buffer[position + 2]; + node.id = + idPosition === 0 ? null : convertNode(node, scope.parent as ChildScope, idPosition, buffer); + const parameters = (node.params = convertNodeList(node, scope, buffer[position + 3], buffer)); + scope.addParameterVariables( + parameters.map( + parameter => + parameter.declare('parameter', EMPTY_PATH, UNKNOWN_EXPRESSION) as ParameterVariable[] + ), + parameters[parameters.length - 1] instanceof RestElement + ); + node.body = convertNode(node, scope.bodyScope, buffer[position + 4], buffer); + }, + function functionExpression(node: FunctionExpression, position, buffer) { + const { scope } = node; + const flags = buffer[position]; + node.async = (flags & 1) === 1; + node.generator = (flags & 2) === 2; + const annotations = (node.annotations = convertAnnotations(buffer[position + 1], buffer)); + node.annotationNoSideEffects = annotations.some(comment => comment.type === 'noSideEffects'); + const idPosition = buffer[position + 2]; + node.id = idPosition === 0 ? null : convertNode(node, node.idScope, idPosition, buffer); + const parameters = (node.params = convertNodeList(node, scope, buffer[position + 3], buffer)); + scope.addParameterVariables( + parameters.map( + parameter => + parameter.declare('parameter', EMPTY_PATH, UNKNOWN_EXPRESSION) as ParameterVariable[] + ), + parameters[parameters.length - 1] instanceof RestElement + ); + node.body = convertNode(node, scope.bodyScope, buffer[position + 4], buffer); + }, + function identifier(node: Identifier, position, buffer) { + node.name = buffer.convertString(buffer[position]); + }, + function ifStatement(node: IfStatement, position, buffer) { + const { scope } = node; + node.test = convertNode(node, scope, buffer[position], buffer); + node.consequent = convertNode( + node, + (node.consequentScope = new TrackingScope(scope)), + buffer[position + 1], + buffer + ); + const alternatePosition = buffer[position + 2]; + node.alternate = + alternatePosition === 0 + ? null + : convertNode( + node, + (node.alternateScope = new TrackingScope(scope)), + alternatePosition, + buffer + ); + }, + function importAttribute(node: ImportAttribute, position, buffer) { + const { scope } = node; + node.key = convertNode(node, scope, buffer[position], buffer); + node.value = convertNode(node, scope, buffer[position + 1], buffer); + }, + function importDeclaration(node: ImportDeclaration, position, buffer) { + const { scope } = node; + node.specifiers = convertNodeList(node, scope, buffer[position], buffer); + node.source = convertNode(node, scope, buffer[position + 1], buffer); + node.attributes = convertNodeList(node, scope, buffer[position + 2], buffer); + }, + function importDefaultSpecifier(node: ImportDefaultSpecifier, position, buffer) { + const { scope } = node; + node.local = convertNode(node, scope, buffer[position], buffer); + }, + function importExpression(node: ImportExpression, position, buffer) { + const { scope } = node; + node.source = convertNode(node, scope, buffer[position], buffer); + node.sourceAstNode = convertJsonNode(buffer[position], buffer); + const optionsPosition = buffer[position + 1]; + node.options = optionsPosition === 0 ? null : convertNode(node, scope, optionsPosition, buffer); + }, + function importNamespaceSpecifier(node: ImportNamespaceSpecifier, position, buffer) { + const { scope } = node; + node.local = convertNode(node, scope, buffer[position], buffer); + }, + function importSpecifier(node: ImportSpecifier, position, buffer) { + const { scope } = node; + const importedPosition = buffer[position]; + node.local = convertNode(node, scope, buffer[position + 1], buffer); + node.imported = + importedPosition === 0 ? node.local : convertNode(node, scope, importedPosition, buffer); + }, + function jsxAttribute(node: JSXAttribute, position, buffer) { + const { scope } = node; + node.name = convertNode(node, scope, buffer[position], buffer); + const valuePosition = buffer[position + 1]; + node.value = valuePosition === 0 ? null : convertNode(node, scope, valuePosition, buffer); + }, + function jsxClosingElement(node: JSXClosingElement, position, buffer) { + const { scope } = node; + node.name = convertNode(node, scope, buffer[position], buffer); + }, + function jsxClosingFragment() {}, + function jsxElement(node: JSXElement, position, buffer) { + const { scope } = node; + node.openingElement = convertNode(node, scope, buffer[position], buffer); + node.children = convertNodeList(node, scope, buffer[position + 1], buffer); + const closingElementPosition = buffer[position + 2]; + node.closingElement = + closingElementPosition === 0 + ? null + : convertNode(node, scope, closingElementPosition, buffer); + }, + function jsxEmptyExpression() {}, + function jsxExpressionContainer(node: JSXExpressionContainer, position, buffer) { + const { scope } = node; + node.expression = convertNode(node, scope, buffer[position], buffer); + }, + function jsxFragment(node: JSXFragment, position, buffer) { + const { scope } = node; + node.openingFragment = convertNode(node, scope, buffer[position], buffer); + node.children = convertNodeList(node, scope, buffer[position + 1], buffer); + node.closingFragment = convertNode(node, scope, buffer[position + 2], buffer); + }, + function jsxIdentifier(node: JSXIdentifier, position, buffer) { + node.name = buffer.convertString(buffer[position]); + }, + function jsxMemberExpression(node: JSXMemberExpression, position, buffer) { + const { scope } = node; + node.object = convertNode(node, scope, buffer[position], buffer); + node.property = convertNode(node, scope, buffer[position + 1], buffer); + }, + function jsxNamespacedName(node: JSXNamespacedName, position, buffer) { + const { scope } = node; + node.namespace = convertNode(node, scope, buffer[position], buffer); + node.name = convertNode(node, scope, buffer[position + 1], buffer); + }, + function jsxOpeningElement(node: JSXOpeningElement, position, buffer) { + const { scope } = node; + const flags = buffer[position]; + node.selfClosing = (flags & 1) === 1; + node.name = convertNode(node, scope, buffer[position + 1], buffer); + node.attributes = convertNodeList(node, scope, buffer[position + 2], buffer); + }, + function jsxOpeningFragment(node: JSXOpeningFragment) { + node.attributes = []; + node.selfClosing = false; + }, + function jsxSpreadAttribute(node: JSXSpreadAttribute, position, buffer) { + const { scope } = node; + node.argument = convertNode(node, scope, buffer[position], buffer); + }, + function jsxSpreadChild(node: JSXSpreadChild, position, buffer) { + const { scope } = node; + node.expression = convertNode(node, scope, buffer[position], buffer); + }, + function jsxText(node: JSXText, position, buffer) { + node.value = buffer.convertString(buffer[position]); + node.raw = buffer.convertString(buffer[position + 1]); + }, + function labeledStatement(node: LabeledStatement, position, buffer) { + const { scope } = node; + node.label = convertNode(node, scope, buffer[position], buffer); + node.body = convertNode(node, scope, buffer[position + 1], buffer); + }, + function literalBigInt(node: Literal, position, buffer) { + const bigint = (node.bigint = buffer.convertString(buffer[position])); + node.raw = buffer.convertString(buffer[position + 1]); + node.value = BigInt(bigint); + }, + function literalBoolean(node: Literal, position, buffer) { + const flags = buffer[position]; + const value = (node.value = (flags & 1) === 1); + node.raw = value ? 'true' : 'false'; + }, + function literalNull(node: Literal) { + node.value = null; + }, + function literalNumber(node: Literal, position, buffer) { + const rawPosition = buffer[position]; + node.raw = rawPosition === 0 ? undefined : buffer.convertString(rawPosition); + node.value = new DataView(buffer.buffer).getFloat64((position + 1) << 2, true); + }, + function literalRegExp(node: Literal, position, buffer) { + const flags = buffer.convertString(buffer[position]); + const pattern = buffer.convertString(buffer[position + 1]); + node.raw = `/${pattern}/${flags}`; + node.regex = { flags, pattern }; + node.value = new RegExp(pattern, flags); + }, + function literalString(node: Literal, position, buffer) { + node.value = buffer.convertString(buffer[position]); + const rawPosition = buffer[position + 1]; + node.raw = rawPosition === 0 ? undefined : buffer.convertString(rawPosition); + }, + function logicalExpression(node: LogicalExpression, position, buffer) { + const { scope } = node; + node.operator = FIXED_STRINGS[buffer[position]] as estree.LogicalOperator; + node.left = convertNode(node, scope, buffer[position + 1], buffer); + node.right = convertNode(node, scope, buffer[position + 2], buffer); + }, + function memberExpression(node: MemberExpression, position, buffer) { + const { scope } = node; + const flags = buffer[position]; + node.computed = (flags & 1) === 1; + node.optional = (flags & 2) === 2; + node.object = convertNode(node, scope, buffer[position + 1], buffer); + node.property = convertNode(node, scope, buffer[position + 2], buffer); + }, + function metaProperty(node: MetaProperty, position, buffer) { + const { scope } = node; + node.meta = convertNode(node, scope, buffer[position], buffer); + node.property = convertNode(node, scope, buffer[position + 1], buffer); + }, + function methodDefinition(node: MethodDefinition, position, buffer) { + const { scope } = node; + const flags = buffer[position]; + node.static = (flags & 1) === 1; + node.computed = (flags & 2) === 2; + node.decorators = convertNodeList(node, scope, buffer[position + 1], buffer); + node.key = convertNode(node, scope, buffer[position + 2], buffer); + node.value = convertNode(node, scope, buffer[position + 3], buffer); + node.kind = FIXED_STRINGS[buffer[position + 4]] as estree.MethodDefinition['kind']; + }, + function newExpression(node: NewExpression, position, buffer) { + const { scope } = node; + node.annotations = convertAnnotations(buffer[position], buffer); + node.callee = convertNode(node, scope, buffer[position + 1], buffer); + node.arguments = convertNodeList(node, scope, buffer[position + 2], buffer); + }, + function objectExpression(node: ObjectExpression, position, buffer) { + const { scope } = node; + node.properties = convertNodeList(node, scope, buffer[position], buffer); + }, + function objectPattern(node: ObjectPattern, position, buffer) { + const { scope } = node; + node.properties = convertNodeList(node, scope, buffer[position], buffer); + }, + function privateIdentifier(node: PrivateIdentifier, position, buffer) { + node.name = buffer.convertString(buffer[position]); + }, + function program(node: Program, position, buffer) { + const { scope } = node; + node.body = convertNodeList(node, scope, buffer[position], buffer); + node.invalidAnnotations = convertAnnotations(buffer[position + 1], buffer); + }, + function property(node: Property, position, buffer) { + const { scope } = node; + const flags = buffer[position]; + node.method = (flags & 1) === 1; + node.shorthand = (flags & 2) === 2; + node.computed = (flags & 4) === 4; + const keyPosition = buffer[position + 1]; + node.value = convertNode(node, scope, buffer[position + 2], buffer); + node.kind = FIXED_STRINGS[buffer[position + 3]] as estree.Property['kind']; + node.key = keyPosition === 0 ? node.value : convertNode(node, scope, keyPosition, buffer); + }, + function propertyDefinition(node: PropertyDefinition, position, buffer) { + const { scope } = node; + const flags = buffer[position]; + node.static = (flags & 1) === 1; + node.computed = (flags & 2) === 2; + node.decorators = convertNodeList(node, scope, buffer[position + 1], buffer); + node.key = convertNode(node, scope, buffer[position + 2], buffer); + const valuePosition = buffer[position + 3]; + node.value = valuePosition === 0 ? null : convertNode(node, scope, valuePosition, buffer); + }, + function restElement(node: RestElement, position, buffer) { + const { scope } = node; + node.argument = convertNode(node, scope, buffer[position], buffer); + }, + function returnStatement(node: ReturnStatement, position, buffer) { + const { scope } = node; + const argumentPosition = buffer[position]; + node.argument = + argumentPosition === 0 ? null : convertNode(node, scope, argumentPosition, buffer); + }, + function sequenceExpression(node: SequenceExpression, position, buffer) { + const { scope } = node; + node.expressions = convertNodeList(node, scope, buffer[position], buffer); + }, + function spreadElement(node: SpreadElement, position, buffer) { + const { scope } = node; + node.argument = convertNode(node, scope, buffer[position], buffer); + }, + function staticBlock(node: StaticBlock, position, buffer) { + const { scope } = node; + node.body = convertNodeList(node, scope, buffer[position], buffer); + }, + function superElement() {}, + function switchCase(node: SwitchCase, position, buffer) { + const { scope } = node; + const testPosition = buffer[position]; + node.test = testPosition === 0 ? null : convertNode(node, scope, testPosition, buffer); + node.consequent = convertNodeList(node, scope, buffer[position + 1], buffer); + }, + function switchStatement(node: SwitchStatement, position, buffer) { + const { scope } = node; + node.discriminant = convertNode(node, node.parentScope, buffer[position], buffer); + node.cases = convertNodeList(node, scope, buffer[position + 1], buffer); + }, + function taggedTemplateExpression(node: TaggedTemplateExpression, position, buffer) { + const { scope } = node; + node.tag = convertNode(node, scope, buffer[position], buffer); + node.quasi = convertNode(node, scope, buffer[position + 1], buffer); + }, + function templateElement(node: TemplateElement, position, buffer) { + const flags = buffer[position]; + node.tail = (flags & 1) === 1; + const cookedPosition = buffer[position + 1]; + const cooked = cookedPosition === 0 ? null : buffer.convertString(cookedPosition); + const raw = buffer.convertString(buffer[position + 2]); + node.value = { cooked, raw }; + }, + function templateLiteral(node: TemplateLiteral, position, buffer) { + const { scope } = node; + node.quasis = convertNodeList(node, scope, buffer[position], buffer); + node.expressions = convertNodeList(node, scope, buffer[position + 1], buffer); + }, + function thisExpression() {}, + function throwStatement(node: ThrowStatement, position, buffer) { + const { scope } = node; + node.argument = convertNode(node, scope, buffer[position], buffer); + }, + function tryStatement(node: TryStatement, position, buffer) { + const { scope } = node; + node.block = convertNode(node, scope, buffer[position], buffer); + const handlerPosition = buffer[position + 1]; + node.handler = handlerPosition === 0 ? null : convertNode(node, scope, handlerPosition, buffer); + const finalizerPosition = buffer[position + 2]; + node.finalizer = + finalizerPosition === 0 ? null : convertNode(node, scope, finalizerPosition, buffer); + }, + function unaryExpression(node: UnaryExpression, position, buffer) { + const { scope } = node; + node.operator = FIXED_STRINGS[buffer[position]] as estree.UnaryOperator; + node.argument = convertNode(node, scope, buffer[position + 1], buffer); + }, + function updateExpression(node: UpdateExpression, position, buffer) { + const { scope } = node; + const flags = buffer[position]; + node.prefix = (flags & 1) === 1; + node.operator = FIXED_STRINGS[buffer[position + 1]] as estree.UpdateOperator; + node.argument = convertNode(node, scope, buffer[position + 2], buffer); + }, + function variableDeclaration(node: VariableDeclaration, position, buffer) { + const { scope } = node; + node.kind = FIXED_STRINGS[buffer[position]] as estree.VariableDeclaration['kind']; + node.declarations = convertNodeList(node, scope, buffer[position + 1], buffer); + }, + function variableDeclarator(node: VariableDeclarator, position, buffer) { + const { scope } = node; + node.id = convertNode(node, scope, buffer[position], buffer); + const initPosition = buffer[position + 1]; + node.init = initPosition === 0 ? null : convertNode(node, scope, initPosition, buffer); + }, + function whileStatement(node: WhileStatement, position, buffer) { + const { scope } = node; + node.test = convertNode(node, scope, buffer[position], buffer); + node.body = convertNode(node, scope, buffer[position + 1], buffer); + }, + function yieldExpression(node: YieldExpression, position, buffer) { + const { scope } = node; + const flags = buffer[position]; + node.delegate = (flags & 1) === 1; + const argumentPosition = buffer[position + 1]; + node.argument = + argumentPosition === 0 ? null : convertNode(node, scope, argumentPosition, buffer); + } +]; + +function convertNode( + parent: Node | { context: AstContext; type: string }, + parentScope: ChildScope, + position: number, + buffer: AstBuffer +): any { + const nodeType = buffer[position]; + const NodeConstructor = nodeConstructors[nodeType]; + /* istanbul ignore if: This should never be executed but is a safeguard against faulty buffers */ + if (!NodeConstructor) { + console.trace(); + throw new Error(`Unknown node type: ${nodeType}`); + } + const node = new NodeConstructor(parent, parentScope); + node.type = nodeTypeStrings[nodeType]; + node.start = buffer[position + 1]; + node.end = buffer[position + 2]; + bufferParsers[nodeType](node, position + 3, buffer); + node.initialise(); + return node; +} + +function convertNodeList( + parent: Node | { context: AstContext; type: string }, + parentScope: ChildScope, + position: number, + buffer: AstBuffer +): any[] { + if (position === 0) return EMPTY_ARRAY as never[]; + const length = buffer[position++]; + const list: any[] = new Array(length); + for (let index = 0; index < length; index++) { + const nodePosition = buffer[position++]; + list[index] = nodePosition ? convertNode(parent, parentScope, nodePosition, buffer) : null; + } + return list; +} diff --git a/src/ast/childNodeKeys.ts b/src/ast/childNodeKeys.ts new file mode 100644 index 00000000000..2658d723d42 --- /dev/null +++ b/src/ast/childNodeKeys.ts @@ -0,0 +1,94 @@ +// This file is generated by scripts/generate-child-node-keys.js. +// Do not edit this file directly. + +export const childNodeKeys: Record = { + ArrayExpression: ['elements'], + ArrayPattern: ['elements'], + ArrowFunctionExpression: ['params', 'body'], + AssignmentExpression: ['left', 'right'], + AssignmentPattern: ['left', 'right'], + AwaitExpression: ['argument'], + BinaryExpression: ['left', 'right'], + BlockStatement: ['body'], + BreakStatement: ['label'], + CallExpression: ['callee', 'arguments'], + CatchClause: ['param', 'body'], + ChainExpression: ['expression'], + ClassBody: ['body'], + ClassDeclaration: ['decorators', 'id', 'superClass', 'body'], + ClassExpression: ['decorators', 'id', 'superClass', 'body'], + ConditionalExpression: ['test', 'consequent', 'alternate'], + ContinueStatement: ['label'], + DebuggerStatement: [], + Decorator: ['expression'], + DoWhileStatement: ['body', 'test'], + EmptyStatement: [], + ExportAllDeclaration: ['exported', 'source', 'attributes'], + ExportDefaultDeclaration: ['declaration'], + ExportNamedDeclaration: ['specifiers', 'source', 'attributes', 'declaration'], + ExportSpecifier: ['local', 'exported'], + ExpressionStatement: ['expression'], + ForInStatement: ['left', 'right', 'body'], + ForOfStatement: ['left', 'right', 'body'], + ForStatement: ['init', 'test', 'update', 'body'], + FunctionDeclaration: ['id', 'params', 'body'], + FunctionExpression: ['id', 'params', 'body'], + Identifier: [], + IfStatement: ['test', 'consequent', 'alternate'], + ImportAttribute: ['key', 'value'], + ImportDeclaration: ['specifiers', 'source', 'attributes'], + ImportDefaultSpecifier: ['local'], + ImportExpression: ['source', 'options'], + ImportNamespaceSpecifier: ['local'], + ImportSpecifier: ['imported', 'local'], + JSXAttribute: ['name', 'value'], + JSXClosingElement: ['name'], + JSXClosingFragment: [], + JSXElement: ['openingElement', 'children', 'closingElement'], + JSXEmptyExpression: [], + JSXExpressionContainer: ['expression'], + JSXFragment: ['openingFragment', 'children', 'closingFragment'], + JSXIdentifier: [], + JSXMemberExpression: ['object', 'property'], + JSXNamespacedName: ['namespace', 'name'], + JSXOpeningElement: ['name', 'attributes'], + JSXOpeningFragment: [], + JSXSpreadAttribute: ['argument'], + JSXSpreadChild: ['expression'], + JSXText: [], + LabeledStatement: ['label', 'body'], + Literal: [], + LogicalExpression: ['left', 'right'], + MemberExpression: ['object', 'property'], + MetaProperty: ['meta', 'property'], + MethodDefinition: ['decorators', 'key', 'value'], + NewExpression: ['callee', 'arguments'], + ObjectExpression: ['properties'], + ObjectPattern: ['properties'], + PanicError: [], + ParseError: [], + PrivateIdentifier: [], + Program: ['body'], + Property: ['key', 'value'], + PropertyDefinition: ['decorators', 'key', 'value'], + RestElement: ['argument'], + ReturnStatement: ['argument'], + SequenceExpression: ['expressions'], + SpreadElement: ['argument'], + StaticBlock: ['body'], + Super: [], + SwitchCase: ['test', 'consequent'], + SwitchStatement: ['discriminant', 'cases'], + TaggedTemplateExpression: ['tag', 'quasi'], + TemplateElement: [], + TemplateLiteral: ['quasis', 'expressions'], + ThisExpression: [], + ThrowStatement: ['argument'], + TryStatement: ['block', 'handler', 'finalizer'], + UnaryExpression: ['argument'], + UpdateExpression: ['argument'], + VariableDeclaration: ['declarations'], + VariableDeclarator: ['id', 'init'], + WhileStatement: ['test', 'body'], + YieldExpression: ['argument'] +}; diff --git a/src/ast/keys.ts b/src/ast/keys.ts deleted file mode 100644 index 9434d9aae03..00000000000 --- a/src/ast/keys.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { GenericEsTreeNode } from './nodes/shared/Node'; - -export const keys: { - [name: string]: string[]; -} = { - Literal: [], - Program: ['body'] -}; - -export function getAndCreateKeys(esTreeNode: GenericEsTreeNode) { - keys[esTreeNode.type] = Object.keys(esTreeNode).filter( - key => key !== '_rollupAnnotations' && typeof esTreeNode[key] === 'object' - ); - return keys[esTreeNode.type]; -} diff --git a/src/ast/nodes/ArrayExpression.ts b/src/ast/nodes/ArrayExpression.ts index f37b81dbbc5..87897b87c92 100644 --- a/src/ast/nodes/ArrayExpression.ts +++ b/src/ast/nodes/ArrayExpression.ts @@ -1,44 +1,115 @@ -import { CallOptions } from '../CallOptions'; -import { HasEffectsContext } from '../ExecutionContext'; -import { ObjectPath, UNKNOWN_PATH } from '../utils/PathTracker'; +import type { DeoptimizableEntity } from '../DeoptimizableEntity'; +import type { HasEffectsContext, InclusionContext } from '../ExecutionContext'; +import type { NodeInteraction, NodeInteractionCalled } from '../NodeInteractions'; import { - arrayMembers, - getMemberReturnExpressionWhenCalled, - hasMemberEffectWhenCalled, - UNKNOWN_EXPRESSION -} from '../values'; -import * as NodeType from './NodeType'; -import { ExpressionNode, NodeBase } from './shared/Node'; + type EntityPathTracker, + type ObjectPath, + UNKNOWN_PATH, + UnknownInteger +} from '../utils/PathTracker'; +import { UNDEFINED_EXPRESSION, UNKNOWN_LITERAL_NUMBER } from '../values'; +import type * as NodeType from './NodeType'; +import { ARRAY_PROTOTYPE } from './shared/ArrayPrototype'; +import type { ExpressionEntity, LiteralValueOrUnknown } from './shared/Expression'; +import { type ExpressionNode, NodeBase } from './shared/Node'; +import { ObjectEntity, type ObjectProperty } from './shared/ObjectEntity'; import SpreadElement from './SpreadElement'; export default class ArrayExpression extends NodeBase { - elements!: (ExpressionNode | SpreadElement | null)[]; - type!: NodeType.tArrayExpression; + declare elements: readonly (ExpressionNode | SpreadElement | null)[]; + declare type: NodeType.tArrayExpression; + private objectEntity: ObjectEntity | null = null; - bind() { - super.bind(); - for (const element of this.elements) { - if (element !== null) element.deoptimizePath(UNKNOWN_PATH); - } + deoptimizeArgumentsOnInteractionAtPath( + interaction: NodeInteraction, + path: ObjectPath, + recursionTracker: EntityPathTracker + ): void { + this.getObjectEntity().deoptimizeArgumentsOnInteractionAtPath( + interaction, + path, + recursionTracker + ); } - getReturnExpressionWhenCalledAtPath(path: ObjectPath) { - if (path.length !== 1) return UNKNOWN_EXPRESSION; - return getMemberReturnExpressionWhenCalled(arrayMembers, path[0]); + deoptimizePath(path: ObjectPath): void { + this.getObjectEntity().deoptimizePath(path); } - hasEffectsWhenAccessedAtPath(path: ObjectPath) { - return path.length > 1; + getLiteralValueAtPath( + path: ObjectPath, + recursionTracker: EntityPathTracker, + origin: DeoptimizableEntity + ): LiteralValueOrUnknown { + return this.getObjectEntity().getLiteralValueAtPath(path, recursionTracker, origin); } - hasEffectsWhenCalledAtPath( + getReturnExpressionWhenCalledAtPath( path: ObjectPath, - callOptions: CallOptions, + interaction: NodeInteractionCalled, + recursionTracker: EntityPathTracker, + origin: DeoptimizableEntity + ): [expression: ExpressionEntity, isPure: boolean] { + return this.getObjectEntity().getReturnExpressionWhenCalledAtPath( + path, + interaction, + recursionTracker, + origin + ); + } + + hasEffectsOnInteractionAtPath( + path: ObjectPath, + interaction: NodeInteraction, context: HasEffectsContext ): boolean { - if (path.length === 1) { - return hasMemberEffectWhenCalled(arrayMembers, path[0], this.included, callOptions, context); + return this.getObjectEntity().hasEffectsOnInteractionAtPath(path, interaction, context); + } + + includeNode(context: InclusionContext) { + this.included = true; + if (!this.deoptimized) this.applyDeoptimizations(); + for (const element of this.elements) { + if (element) { + element?.includePath(UNKNOWN_PATH, context); + } + } + } + + applyDeoptimizations() { + this.deoptimized = true; + let hasSpread = false; + for (let index = 0; index < this.elements.length; index++) { + const element = this.elements[index]; + if (element && (hasSpread || element instanceof SpreadElement)) { + hasSpread = true; + element.deoptimizePath(UNKNOWN_PATH); + } + } + this.scope.context.requestTreeshakingPass(); + } + + private getObjectEntity(): ObjectEntity { + if (this.objectEntity !== null) { + return this.objectEntity; + } + const properties: ObjectProperty[] = [ + { key: 'length', kind: 'init', property: UNKNOWN_LITERAL_NUMBER } + ]; + let hasSpread = false; + for (let index = 0; index < this.elements.length; index++) { + const element = this.elements[index]; + if (hasSpread || element instanceof SpreadElement) { + if (element) { + hasSpread = true; + properties.unshift({ key: UnknownInteger, kind: 'init', property: element }); + } + } else if (element) { + properties.push({ key: String(index), kind: 'init', property: element }); + } else { + properties.push({ key: String(index), kind: 'init', property: UNDEFINED_EXPRESSION }); + } } - return true; + return (this.objectEntity = new ObjectEntity(properties, ARRAY_PROTOTYPE)); } } diff --git a/src/ast/nodes/ArrayPattern.ts b/src/ast/nodes/ArrayPattern.ts index e73f591fd7b..9736271bf04 100644 --- a/src/ast/nodes/ArrayPattern.ts +++ b/src/ast/nodes/ArrayPattern.ts @@ -1,52 +1,132 @@ -import { HasEffectsContext } from '../ExecutionContext'; -import { EMPTY_PATH, ObjectPath } from '../utils/PathTracker'; -import { UNKNOWN_EXPRESSION } from '../values'; -import Variable from '../variables/Variable'; -import * as NodeType from './NodeType'; -import { NodeBase } from './shared/Node'; -import { PatternNode } from './shared/Pattern'; - -export default class ArrayPattern extends NodeBase implements PatternNode { - elements!: (PatternNode | null)[]; - type!: NodeType.tArrayPattern; +import type MagicString from 'magic-string'; +import type { RenderOptions } from '../../utils/renderHelpers'; +import type { HasEffectsContext, InclusionContext } from '../ExecutionContext'; +import type { NodeInteractionAssigned } from '../NodeInteractions'; +import { EMPTY_PATH, type ObjectPath, UnknownInteger, UnknownKey } from '../utils/PathTracker'; +import type LocalVariable from '../variables/LocalVariable'; +import type Variable from '../variables/Variable'; +import type * as NodeType from './NodeType'; +import type { ExpressionEntity } from './shared/Expression'; +import { NodeBase, onlyIncludeSelf } from './shared/Node'; +import type { DeclarationPatternNode, PatternNode } from './shared/Pattern'; +import type { VariableKind } from './shared/VariableKinds'; + +export default class ArrayPattern extends NodeBase implements DeclarationPatternNode { + declare elements: (PatternNode | null)[]; + declare type: NodeType.tArrayPattern; addExportedVariables( - variables: Variable[], - exportNamesByVariable: Map + variables: readonly Variable[], + exportNamesByVariable: ReadonlyMap ): void { for (const element of this.elements) { - if (element !== null) { - element.addExportedVariables(variables, exportNamesByVariable); - } + element?.addExportedVariables(variables, exportNamesByVariable); } } - declare(kind: string) { - const variables = []; + declare( + kind: VariableKind, + destructuredInitPath: ObjectPath, + init: ExpressionEntity + ): LocalVariable[] { + const variables: LocalVariable[] = []; + const includedPatternPath = getIncludedPatternPath(destructuredInitPath); for (const element of this.elements) { if (element !== null) { - variables.push(...element.declare(kind, UNKNOWN_EXPRESSION)); + variables.push( + ...(element as DeclarationPatternNode).declare(kind, includedPatternPath, init) + ); } } return variables; } - deoptimizePath(path: ObjectPath) { - if (path.length === 0) { - for (const element of this.elements) { - if (element !== null) { - element.deoptimizePath(path); - } - } + deoptimizeAssignment(destructuredInitPath: ObjectPath, init: ExpressionEntity): void { + const includedPatternPath = getIncludedPatternPath(destructuredInitPath); + for (const element of this.elements) { + element?.deoptimizeAssignment(includedPatternPath, init); } } - hasEffectsWhenAssignedAtPath(path: ObjectPath, context: HasEffectsContext) { - if (path.length > 0) return true; + // Patterns can only be deoptimized at the empty path at the moment + deoptimizePath(): void { for (const element of this.elements) { - if (element !== null && element.hasEffectsWhenAssignedAtPath(EMPTY_PATH, context)) + element?.deoptimizePath(EMPTY_PATH); + } + } + + hasEffectsWhenDestructuring( + context: HasEffectsContext, + destructuredInitPath: ObjectPath, + init: ExpressionEntity + ): boolean { + const includedPatternPath = getIncludedPatternPath(destructuredInitPath); + for (const element of this.elements) { + if (element?.hasEffectsWhenDestructuring(context, includedPatternPath, init)) { return true; + } + } + return false; + } + + // Patterns are only checked at the empty path at the moment + hasEffectsOnInteractionAtPath( + _path: ObjectPath, + interaction: NodeInteractionAssigned, + context: HasEffectsContext + ): boolean { + for (const element of this.elements) { + if (element?.hasEffectsOnInteractionAtPath(EMPTY_PATH, interaction, context)) return true; } return false; } + + includeDestructuredIfNecessary( + context: InclusionContext, + destructuredInitPath: ObjectPath, + init: ExpressionEntity + ): boolean { + let included = false; + const includedPatternPath = getIncludedPatternPath(destructuredInitPath); + for (const element of [...this.elements].reverse()) { + if (element) { + if (included && !element.included) { + element.includeNode(context); + } + included = + element.includeDestructuredIfNecessary(context, includedPatternPath, init) || included; + } + } + if (!this.included && included) { + this.includeNode(context); + } + return this.included; + } + + render(code: MagicString, options: RenderOptions): void { + let removedStart = this.start + 1; + for (const element of this.elements) { + if (!element) continue; + if (element.included) { + element.render(code, options); + removedStart = element.end; + } else { + code.remove(removedStart, this.end - 1); + break; + } + } + } + + markDeclarationReached(): void { + for (const element of this.elements) { + (element as DeclarationPatternNode)?.markDeclarationReached(); + } + } } + +ArrayPattern.prototype.includeNode = onlyIncludeSelf; + +const getIncludedPatternPath = (destructuredInitPath: ObjectPath): ObjectPath => + destructuredInitPath.at(-1) === UnknownKey + ? destructuredInitPath + : [...destructuredInitPath, UnknownInteger]; diff --git a/src/ast/nodes/ArrowFunctionExpression.ts b/src/ast/nodes/ArrowFunctionExpression.ts index 52c08376857..55ddffe42ee 100644 --- a/src/ast/nodes/ArrowFunctionExpression.ts +++ b/src/ast/nodes/ArrowFunctionExpression.ts @@ -1,117 +1,105 @@ -import { CallOptions } from '../CallOptions'; -import { BROKEN_FLOW_NONE, HasEffectsContext, InclusionContext } from '../ExecutionContext'; +import type { HasEffectsContext, InclusionContext } from '../ExecutionContext'; +import type { NodeInteraction } from '../NodeInteractions'; +import { INTERACTION_CALLED } from '../NodeInteractions'; +import type ChildScope from '../scopes/ChildScope'; import ReturnValueScope from '../scopes/ReturnValueScope'; -import Scope from '../scopes/Scope'; -import { ObjectPath, UnknownKey, UNKNOWN_PATH } from '../utils/PathTracker'; -import { UNKNOWN_EXPRESSION } from '../values'; -import BlockStatement from './BlockStatement'; +import { type ObjectPath, UNKNOWN_PATH } from '../utils/PathTracker'; +import type BlockStatement from './BlockStatement'; +import type CallExpression from './CallExpression'; import Identifier from './Identifier'; import * as NodeType from './NodeType'; -import RestElement from './RestElement'; -import { ExpressionNode, GenericEsTreeNode, IncludeChildren, NodeBase } from './shared/Node'; -import { PatternNode } from './shared/Pattern'; -import SpreadElement from './SpreadElement'; +import { Flag, isFlagSet, setFlag } from './shared/BitFlags'; +import FunctionBase from './shared/FunctionBase'; +import type { ExpressionNode, IncludeChildren } from './shared/Node'; +import { ObjectEntity } from './shared/ObjectEntity'; +import { OBJECT_PROTOTYPE } from './shared/ObjectPrototype'; +import type { DeclarationPatternNode } from './shared/Pattern'; -export default class ArrowFunctionExpression extends NodeBase { - body!: BlockStatement | ExpressionNode; - params!: PatternNode[]; - preventChildBlockScope!: true; - scope!: ReturnValueScope; - type!: NodeType.tArrowFunctionExpression; +export default class ArrowFunctionExpression extends FunctionBase { + declare body: BlockStatement | ExpressionNode; + declare params: DeclarationPatternNode[]; + declare preventChildBlockScope: true; + declare scope: ReturnValueScope; + declare type: NodeType.tArrowFunctionExpression; + protected objectEntity: ObjectEntity | null = null; - createScope(parentScope: Scope) { - this.scope = new ReturnValueScope(parentScope, this.context); + get expression(): boolean { + return isFlagSet(this.flags, Flag.expression); } - - deoptimizePath(path: ObjectPath) { - // A reassignment of UNKNOWN_PATH is considered equivalent to having lost track - // which means the return expression needs to be reassigned - if (path.length === 1 && path[0] === UnknownKey) { - this.scope.getReturnExpression().deoptimizePath(UNKNOWN_PATH); - } + set expression(value: boolean) { + this.flags = setFlag(this.flags, Flag.expression, value); } - getReturnExpressionWhenCalledAtPath(path: ObjectPath) { - return path.length === 0 ? this.scope.getReturnExpression() : UNKNOWN_EXPRESSION; + createScope(parentScope: ChildScope): void { + this.scope = new ReturnValueScope(parentScope, false); } - hasEffects() { + hasEffects(): boolean { return false; } - hasEffectsWhenAccessedAtPath(path: ObjectPath) { - return path.length > 1; - } - - hasEffectsWhenAssignedAtPath(path: ObjectPath) { - return path.length > 1; - } - - hasEffectsWhenCalledAtPath( + hasEffectsOnInteractionAtPath( path: ObjectPath, - _callOptions: CallOptions, + interaction: NodeInteraction, context: HasEffectsContext ): boolean { - if (path.length > 0) return true; - for (const param of this.params) { - if (param.hasEffects(context)) return true; + if ( + this.annotationNoSideEffects && + path.length === 0 && + interaction.type === INTERACTION_CALLED + ) { + return false; + } + if (super.hasEffectsOnInteractionAtPath(path, interaction, context)) { + return true; } - const { ignore, brokenFlow } = context; - context.ignore = { - breaks: false, - continues: false, - labels: new Set(), - returnAwaitYield: true - }; - if (this.body.hasEffects(context)) return true; - context.ignore = ignore; - context.brokenFlow = brokenFlow; - return false; - } - include(context: InclusionContext, includeChildrenRecursively: IncludeChildren) { - this.included = true; - for (const param of this.params) { - if (!(param instanceof Identifier)) { - param.include(context, includeChildrenRecursively); - } + if (interaction.type === INTERACTION_CALLED) { + const { ignore, brokenFlow } = context; + context.ignore = { + breaks: false, + continues: false, + labels: new Set(), + returnYield: true, + this: false + }; + if (this.body.hasEffects(context)) return true; + context.ignore = ignore; + context.brokenFlow = brokenFlow; } - const { brokenFlow } = context; - context.brokenFlow = BROKEN_FLOW_NONE; - this.body.include(context, includeChildrenRecursively); - context.brokenFlow = brokenFlow; + return false; } - includeCallArguments(context: InclusionContext, args: (ExpressionNode | SpreadElement)[]): void { - this.scope.includeCallArguments(context, args); + protected onlyFunctionCallUsed(): boolean { + const isIIFE = + this.parent.type === NodeType.CallExpression && + (this.parent as CallExpression).callee === this; + return isIIFE || super.onlyFunctionCallUsed(); } - initialise() { - this.scope.addParameterVariables( - this.params.map(param => param.declare('parameter', UNKNOWN_EXPRESSION)), - this.params[this.params.length - 1] instanceof RestElement - ); - if (this.body instanceof BlockStatement) { - this.body.addImplicitReturnExpressionToScope(); - } else { - this.scope.addReturnExpression(this.body); + include(context: InclusionContext, includeChildrenRecursively: IncludeChildren): void { + super.include(context, includeChildrenRecursively); + for (const parameter of this.params) { + if (!(parameter instanceof Identifier)) { + parameter.include(context, includeChildrenRecursively); + } } } - mayModifyThisWhenCalledAtPath() { - return false; + includeNode(context: InclusionContext) { + this.included = true; + this.body.includePath(UNKNOWN_PATH, context); + for (const parameter of this.params) { + if (!(parameter instanceof Identifier)) { + parameter.includePath(UNKNOWN_PATH, context); + } + } } - parseNode(esTreeNode: GenericEsTreeNode) { - if (esTreeNode.body.type === NodeType.BlockStatement) { - this.body = new this.context.nodeConstructors.BlockStatement( - esTreeNode.body, - this, - this.scope.hoistedBodyVarScope - ); + protected getObjectEntity(): ObjectEntity { + if (this.objectEntity !== null) { + return this.objectEntity; } - super.parseNode(esTreeNode); + return (this.objectEntity = new ObjectEntity([], OBJECT_PROTOTYPE)); } } - -ArrowFunctionExpression.prototype.preventChildBlockScope = true; diff --git a/src/ast/nodes/AssignmentExpression.ts b/src/ast/nodes/AssignmentExpression.ts index f982147be34..626a1f7297f 100644 --- a/src/ast/nodes/AssignmentExpression.ts +++ b/src/ast/nodes/AssignmentExpression.ts @@ -1,23 +1,37 @@ -import MagicString from 'magic-string'; +import type MagicString from 'magic-string'; import { BLANK } from '../../utils/blank'; +import { LOGLEVEL_WARN } from '../../utils/logging'; +import { logConstVariableReassignError } from '../../utils/logs'; import { findFirstOccurrenceOutsideComment, findNonWhiteSpace, - NodeRenderOptions, + type NodeRenderOptions, removeLineBreaks, - RenderOptions + type RenderOptions } from '../../utils/renderHelpers'; -import { getSystemExportFunctionLeft } from '../../utils/systemJsRendering'; -import { createHasEffectsContext, HasEffectsContext, InclusionContext } from '../ExecutionContext'; -import { EMPTY_PATH, ObjectPath, UNKNOWN_PATH } from '../utils/PathTracker'; -import Variable from '../variables/Variable'; +import { + renderSystemExportExpression, + renderSystemExportFunction, + renderSystemExportSequenceAfterExpression +} from '../../utils/systemJsRendering'; +import { + createHasEffectsContext, + type HasEffectsContext, + type InclusionContext +} from '../ExecutionContext'; +import type { NodeInteraction } from '../NodeInteractions'; +import { INTERACTION_ASSIGNED } from '../NodeInteractions'; +import { EMPTY_PATH, type ObjectPath, UNKNOWN_PATH } from '../utils/PathTracker'; +import type Variable from '../variables/Variable'; +import Identifier from './Identifier'; import * as NodeType from './NodeType'; -import { ExpressionNode, IncludeChildren, NodeBase } from './shared/Node'; -import { PatternNode } from './shared/Pattern'; +import ObjectPattern from './ObjectPattern'; +import { type ExpressionNode, type IncludeChildren, NodeBase } from './shared/Node'; +import type { PatternNode } from './shared/Pattern'; export default class AssignmentExpression extends NodeBase { - left!: ExpressionNode | PatternNode; - operator!: + declare left: PatternNode; + declare operator: | '=' | '+=' | '-=' @@ -30,101 +44,146 @@ export default class AssignmentExpression extends NodeBase { | '|=' | '^=' | '&=' - | '**='; - right!: ExpressionNode; - type!: NodeType.tAssignmentExpression; - private deoptimized = false; + | '**=' + | '&&=' + | '||=' + | '??='; + declare right: ExpressionNode; + declare type: NodeType.tAssignmentExpression; + private isConstReassignment = false; hasEffects(context: HasEffectsContext): boolean { - if (!this.deoptimized) this.applyDeoptimizations(); + const { deoptimized, isConstReassignment, left, operator, right } = this; + if (!deoptimized) this.applyDeoptimizations(); + // MemberExpressions do not access the property before assignments if the + // operator is '='. return ( - this.right.hasEffects(context) || - this.left.hasEffects(context) || - this.left.hasEffectsWhenAssignedAtPath(EMPTY_PATH, context) + isConstReassignment || + right.hasEffects(context) || + left.hasEffectsAsAssignmentTarget(context, operator !== '=') || + this.left.hasEffectsWhenDestructuring?.(context, EMPTY_PATH, right) ); } - hasEffectsWhenAccessedAtPath(path: ObjectPath, context: HasEffectsContext): boolean { - return path.length > 0 && this.right.hasEffectsWhenAccessedAtPath(path, context); + hasEffectsOnInteractionAtPath( + path: ObjectPath, + interaction: NodeInteraction, + context: HasEffectsContext + ): boolean { + return ( + (interaction.type === INTERACTION_ASSIGNED && this.left.included) || + this.right.hasEffectsOnInteractionAtPath(path, interaction, context) + ); } include(context: InclusionContext, includeChildrenRecursively: IncludeChildren): void { - if (!this.deoptimized) this.applyDeoptimizations(); - this.included = true; - let hasEffectsContext; + const { deoptimized, isConstReassignment, left, right, operator } = this; + if (!deoptimized) this.applyDeoptimizations(); + if (!this.included) this.includeNode(context); + const hasEffectsContext = createHasEffectsContext(); if ( includeChildrenRecursively || - this.operator !== '=' || - this.left.included || - ((hasEffectsContext = createHasEffectsContext()), - this.left.hasEffects(hasEffectsContext) || - this.left.hasEffectsWhenAssignedAtPath(EMPTY_PATH, hasEffectsContext)) + isConstReassignment || + operator !== '=' || + left.included || + left.hasEffectsAsAssignmentTarget(hasEffectsContext, false) || + left.hasEffectsWhenDestructuring?.(hasEffectsContext, EMPTY_PATH, right) ) { - this.left.include(context, includeChildrenRecursively); + left.includeAsAssignmentTarget(context, includeChildrenRecursively, operator !== '='); } - this.right.include(context, includeChildrenRecursively); + right.include(context, includeChildrenRecursively); + } + + includeNode(context: InclusionContext) { + this.included = true; + if (!this.deoptimized) this.applyDeoptimizations(); + this.right.includePath(UNKNOWN_PATH, context); + } + + initialise(): void { + super.initialise(); + if (this.left instanceof Identifier) { + const variable = this.scope.variables.get(this.left.name); + if (variable?.kind === 'const') { + this.isConstReassignment = true; + this.scope.context.log(LOGLEVEL_WARN, logConstVariableReassignError(), this.left.start); + } + } + this.left.setAssignedValue(this.right); } render( code: MagicString, options: RenderOptions, - { preventASI, renderedParentType }: NodeRenderOptions = BLANK - ) { - if (this.left.included) { - this.left.render(code, options); - this.right.render(code, options); + { preventASI, renderedParentType, renderedSurroundingElement }: NodeRenderOptions = BLANK + ): void { + const { left, right, start, end, parent } = this; + if (left.included) { + left.render(code, options); + right.render(code, options); } else { const inclusionStart = findNonWhiteSpace( code.original, - findFirstOccurrenceOutsideComment(code.original, '=', this.left.end) + 1 + findFirstOccurrenceOutsideComment(code.original, '=', left.end) + 1 ); - code.remove(this.start, inclusionStart); + code.remove(start, inclusionStart); if (preventASI) { - removeLineBreaks(code, inclusionStart, this.right.start); + removeLineBreaks(code, inclusionStart, right.start); } - this.right.render(code, options, { - renderedParentType: renderedParentType || this.parent.type + right.render(code, options, { + renderedParentType: renderedParentType || parent.type, + renderedSurroundingElement: renderedSurroundingElement || parent.type }); } if (options.format === 'system') { - const exportNames = - this.left.variable && options.exportNamesByVariable.get(this.left.variable); - if (this.left.type === 'Identifier' && exportNames) { - const _ = options.compact ? '' : ' '; - const operatorPos = findFirstOccurrenceOutsideComment( - code.original, - this.operator, - this.left.end - ); - const operation = - this.operator.length > 1 ? `${exportNames[0]}${_}${this.operator.slice(0, -1)}${_}` : ''; - code.overwrite( - operatorPos, - findNonWhiteSpace(code.original, operatorPos + this.operator.length), - `=${_}${ - exportNames.length === 1 - ? `exports('${exportNames[0]}',${_}` - : getSystemExportFunctionLeft([this.left.variable!], false, options) - }${operation}` - ); - code.appendLeft(this.right.end, ')'); + if (left instanceof Identifier) { + const variable = left.variable!; + const exportNames = options.exportNamesByVariable.get(variable); + if (exportNames) { + if (exportNames.length === 1) { + renderSystemExportExpression(variable, start, end, code, options); + } else { + renderSystemExportSequenceAfterExpression( + variable, + start, + end, + parent.type !== NodeType.ExpressionStatement, + code, + options + ); + } + return; + } } else { const systemPatternExports: Variable[] = []; - this.left.addExportedVariables(systemPatternExports, options.exportNamesByVariable); + left.addExportedVariables(systemPatternExports, options.exportNamesByVariable); if (systemPatternExports.length > 0) { - code.prependRight( - this.start, - `(${getSystemExportFunctionLeft(systemPatternExports, true, options)}` + renderSystemExportFunction( + systemPatternExports, + start, + end, + renderedSurroundingElement === NodeType.ExpressionStatement, + code, + options ); - code.appendLeft(this.end, '))'); + return; } } } + if ( + left.included && + left instanceof ObjectPattern && + (renderedSurroundingElement === NodeType.ExpressionStatement || + renderedSurroundingElement === NodeType.ArrowFunctionExpression) + ) { + code.appendRight(start, '('); + code.prependLeft(end, ')'); + } } - private applyDeoptimizations() { + applyDeoptimizations() { this.deoptimized = true; - this.left.deoptimizePath(EMPTY_PATH); - this.right.deoptimizePath(UNKNOWN_PATH); + this.left.deoptimizeAssignment(EMPTY_PATH, this.right); + this.scope.context.requestTreeshakingPass(); } } diff --git a/src/ast/nodes/AssignmentPattern.ts b/src/ast/nodes/AssignmentPattern.ts index 06d6ea3268b..56c59ae5307 100644 --- a/src/ast/nodes/AssignmentPattern.ts +++ b/src/ast/nodes/AssignmentPattern.ts @@ -1,50 +1,111 @@ -import MagicString from 'magic-string'; +import type MagicString from 'magic-string'; import { BLANK } from '../../utils/blank'; -import { NodeRenderOptions, RenderOptions } from '../../utils/renderHelpers'; -import { HasEffectsContext } from '../ExecutionContext'; -import { EMPTY_PATH, ObjectPath, UNKNOWN_PATH } from '../utils/PathTracker'; -import Variable from '../variables/Variable'; -import * as NodeType from './NodeType'; -import { ExpressionEntity } from './shared/Expression'; -import { ExpressionNode, NodeBase } from './shared/Node'; -import { PatternNode } from './shared/Pattern'; - -export default class AssignmentPattern extends NodeBase implements PatternNode { - left!: PatternNode; - right!: ExpressionNode; - type!: NodeType.tAssignmentPattern; +import type { NodeRenderOptions, RenderOptions } from '../../utils/renderHelpers'; +import type { HasEffectsContext, InclusionContext } from '../ExecutionContext'; +import type { NodeInteractionAssigned } from '../NodeInteractions'; +import { EMPTY_PATH, type ObjectPath, UNKNOWN_PATH } from '../utils/PathTracker'; +import type LocalVariable from '../variables/LocalVariable'; +import type Variable from '../variables/Variable'; +import type * as NodeType from './NodeType'; +import type { ExpressionEntity } from './shared/Expression'; +import { type ExpressionNode, NodeBase } from './shared/Node'; +import type { DeclarationPatternNode, PatternNode } from './shared/Pattern'; +import type { VariableKind } from './shared/VariableKinds'; + +export default class AssignmentPattern extends NodeBase implements DeclarationPatternNode { + declare left: PatternNode; + declare right: ExpressionNode; + declare type: NodeType.tAssignmentPattern; addExportedVariables( - variables: Variable[], - exportNamesByVariable: Map + variables: readonly Variable[], + exportNamesByVariable: ReadonlyMap ): void { this.left.addExportedVariables(variables, exportNamesByVariable); } - bind() { - super.bind(); - this.left.deoptimizePath(EMPTY_PATH); - this.right.deoptimizePath(UNKNOWN_PATH); + declare( + kind: VariableKind, + destructuredInitPath: ObjectPath, + init: ExpressionEntity + ): LocalVariable[] { + return (this.left as DeclarationPatternNode).declare(kind, destructuredInitPath, init); + } + + deoptimizeAssignment(destructuredInitPath: ObjectPath, init: ExpressionEntity): void { + this.left.deoptimizeAssignment(destructuredInitPath, init); + } + + deoptimizePath(path: ObjectPath): void { + if (path.length === 0) { + this.left.deoptimizePath(path); + } + } + + hasEffectsOnInteractionAtPath( + path: ObjectPath, + interaction: NodeInteractionAssigned, + context: HasEffectsContext + ): boolean { + return ( + path.length > 0 || this.left.hasEffectsOnInteractionAtPath(EMPTY_PATH, interaction, context) + ); + } + + hasEffectsWhenDestructuring( + context: HasEffectsContext, + destructuredInitPath: ObjectPath, + init: ExpressionEntity + ): boolean { + return this.left.hasEffectsWhenDestructuring(context, destructuredInitPath, init); } - declare(kind: string, init: ExpressionEntity) { - return this.left.declare(kind, init); + includeDestructuredIfNecessary( + context: InclusionContext, + destructuredInitPath: ObjectPath, + init: ExpressionEntity + ): boolean { + let included = + this.left.includeDestructuredIfNecessary(context, destructuredInitPath, init) || + this.included; + if ((included ||= this.right.shouldBeIncluded(context))) { + this.right.include(context, false); + if (!this.left.included) { + this.left.includeNode(context); + // Unfortunately, we need to include the left side again now, so that + // any declared variables are properly included. + this.left.includeDestructuredIfNecessary(context, destructuredInitPath, init); + } + } + if (!this.included && included) { + this.includeNode(context); + } + return this.included; } - deoptimizePath(path: ObjectPath) { - path.length === 0 && this.left.deoptimizePath(path); + includeNode(context: InclusionContext) { + this.included = true; + if (!this.deoptimized) this.applyDeoptimizations(); + this.right.includePath(UNKNOWN_PATH, context); } - hasEffectsWhenAssignedAtPath(path: ObjectPath, context: HasEffectsContext): boolean { - return path.length > 0 || this.left.hasEffectsWhenAssignedAtPath(EMPTY_PATH, context); + markDeclarationReached(): void { + (this.left as DeclarationPatternNode).markDeclarationReached(); } render( code: MagicString, options: RenderOptions, { isShorthandProperty }: NodeRenderOptions = BLANK - ) { + ): void { this.left.render(code, options, { isShorthandProperty }); this.right.render(code, options); } + + applyDeoptimizations() { + this.deoptimized = true; + this.left.deoptimizePath(EMPTY_PATH); + this.right.deoptimizePath(UNKNOWN_PATH); + this.scope.context.requestTreeshakingPass(); + } } diff --git a/src/ast/nodes/AwaitExpression.ts b/src/ast/nodes/AwaitExpression.ts index efa95f74f86..0523aed55d7 100644 --- a/src/ast/nodes/AwaitExpression.ts +++ b/src/ast/nodes/AwaitExpression.ts @@ -1,29 +1,49 @@ -import { HasEffectsContext, InclusionContext } from '../ExecutionContext'; +import type { InclusionContext } from '../ExecutionContext'; +import type { ObjectPath } from '../utils/PathTracker'; import ArrowFunctionExpression from './ArrowFunctionExpression'; -import * as NodeType from './NodeType'; +import type * as NodeType from './NodeType'; import FunctionNode from './shared/FunctionNode'; -import { ExpressionNode, IncludeChildren, Node, NodeBase } from './shared/Node'; +import { type ExpressionNode, type IncludeChildren, type Node, NodeBase } from './shared/Node'; export default class AwaitExpression extends NodeBase { - argument!: ExpressionNode; - type!: NodeType.tAwaitExpression; + declare argument: ExpressionNode; + declare type: NodeType.tAwaitExpression; - hasEffects(context: HasEffectsContext) { - return !context.ignore.returnAwaitYield || this.argument.hasEffects(context); + deoptimizePath(path: ObjectPath) { + this.argument.deoptimizePath(path); } - include(context: InclusionContext, includeChildrenRecursively: IncludeChildren) { - if (!this.included) { - this.included = true; - checkTopLevelAwait: if (!this.context.usesTopLevelAwait) { - let parent = this.parent; - do { - if (parent instanceof FunctionNode || parent instanceof ArrowFunctionExpression) - break checkTopLevelAwait; - } while ((parent = (parent as Node).parent as Node)); - this.context.usesTopLevelAwait = true; - } - } + hasEffects(): boolean { + if (!this.deoptimized) this.applyDeoptimizations(); + return true; + } + + initialise(): void { + super.initialise(); + let parent = this.parent; + do { + if (parent instanceof FunctionNode || parent instanceof ArrowFunctionExpression) return; + } while ((parent = (parent as Node).parent as Node)); + this.scope.context.usesTopLevelAwait = true; + } + + include(context: InclusionContext, includeChildrenRecursively: IncludeChildren): void { + if (!this.included) this.includeNode(context); this.argument.include(context, includeChildrenRecursively); } + + includeNode(context: InclusionContext) { + this.included = true; + if (!this.deoptimized) this.applyDeoptimizations(); + // Thenables need to be included + this.argument.includePath(THEN_PATH, context); + } + + includePath(path: ObjectPath, context: InclusionContext): void { + if (!this.deoptimized) this.applyDeoptimizations(); + if (!this.included) this.includeNode(context); + this.argument.includePath(path, context); + } } + +const THEN_PATH = ['then']; diff --git a/src/ast/nodes/BinaryExpression.ts b/src/ast/nodes/BinaryExpression.ts index eb85497e630..bdd960b9fe5 100644 --- a/src/ast/nodes/BinaryExpression.ts +++ b/src/ast/nodes/BinaryExpression.ts @@ -1,20 +1,64 @@ -import { DeoptimizableEntity } from '../DeoptimizableEntity'; -import { HasEffectsContext } from '../ExecutionContext'; +import type MagicString from 'magic-string'; +import { BLANK } from '../../utils/blank'; +import type { NodeRenderOptions, RenderOptions } from '../../utils/renderHelpers'; +import type { DeoptimizableEntity } from '../DeoptimizableEntity'; +import type { HasEffectsContext, InclusionContext } from '../ExecutionContext'; +import type { NodeInteraction } from '../NodeInteractions'; +import { INTERACTION_ACCESSED } from '../NodeInteractions'; import { EMPTY_PATH, - ObjectPath, - PathTracker, - SHARED_RECURSION_TRACKER + type EntityPathTracker, + INSTANCEOF_PATH, + type ObjectPath, + SHARED_RECURSION_TRACKER, + UNKNOWN_PATH } from '../utils/PathTracker'; -import { LiteralValueOrUnknown, UnknownValue } from '../values'; +import { getRenderedLiteralValue } from '../utils/renderLiteralValue'; +import ExternalVariable from '../variables/ExternalVariable'; +import NamespaceVariable from '../variables/NamespaceVariable'; +import SyntheticNamedExportVariable from '../variables/SyntheticNamedExportVariable'; import ExpressionStatement from './ExpressionStatement'; -import { LiteralValue } from './Literal'; -import * as NodeType from './NodeType'; -import { ExpressionNode, NodeBase } from './shared/Node'; +import type { LiteralValue } from './Literal'; +import type * as NodeType from './NodeType'; +import { + type InclusionOptions, + type LiteralValueOrUnknown, + UnknownValue +} from './shared/Expression'; +import { + doNotDeoptimize, + type ExpressionNode, + type IncludeChildren, + NodeBase +} from './shared/Node'; + +type Operator = + | '!=' + | '!==' + | '%' + | '&' + | '*' + | '**' + | '+' + | '-' + | '/' + | '<' + | '<<' + | '<=' + | '==' + | '===' + | '>' + | '>=' + | '>>' + | '>>>' + | '^' + | '|' + | 'in' + | 'instanceof'; -const binaryOperators: { - [operator: string]: (left: LiteralValue, right: LiteralValue) => LiteralValueOrUnknown; -} = { +const binaryOperators: Partial< + Record LiteralValueOrUnknown> +> = { '!=': (left, right) => left != right, '!==': (left, right) => left !== right, '%': (left: any, right: any) => left % right, @@ -25,47 +69,71 @@ const binaryOperators: { '+': (left: any, right: any) => left + right, '-': (left: any, right: any) => left - right, '/': (left: any, right: any) => left / right, - '<': (left, right) => (left as NonNullable) < (right as NonNullable), + '<': (left, right) => left! < right!, '<<': (left: any, right: any) => left << right, - '<=': (left, right) => - (left as NonNullable) <= (right as NonNullable), + '<=': (left, right) => left! <= right!, '==': (left, right) => left == right, '===': (left, right) => left === right, - '>': (left, right) => (left as NonNullable) > (right as NonNullable), - '>=': (left, right) => - (left as NonNullable) >= (right as NonNullable), + '>': (left, right) => left! > right!, + '>=': (left, right) => left! >= right!, '>>': (left: any, right: any) => left >> right, '>>>': (left: any, right: any) => left >>> right, '^': (left: any, right: any) => left ^ right, - in: () => UnknownValue, - instanceof: () => UnknownValue, '|': (left: any, right: any) => left | right + // We use the fallback for cases where we return something unknown + // in: () => UnknownValue, + // instanceof: () => UnknownValue, }; +const UNASSIGNED = Symbol('Unassigned'); + export default class BinaryExpression extends NodeBase implements DeoptimizableEntity { - left!: ExpressionNode; - operator!: keyof typeof binaryOperators; - right!: ExpressionNode; - type!: NodeType.tBinaryExpression; + declare left: ExpressionNode; + declare operator: keyof typeof binaryOperators; + declare right: ExpressionNode; + declare type: NodeType.tBinaryExpression; + renderedLiteralValue: string | typeof UnknownValue | typeof UNASSIGNED = UNASSIGNED; - deoptimizeCache(): void {} + deoptimizeCache(): void { + this.renderedLiteralValue = UnknownValue; + } getLiteralValueAtPath( path: ObjectPath, - recursionTracker: PathTracker, + recursionTracker: EntityPathTracker, origin: DeoptimizableEntity ): LiteralValueOrUnknown { if (path.length > 0) return UnknownValue; const leftValue = this.left.getLiteralValueAtPath(EMPTY_PATH, recursionTracker, origin); - if (leftValue === UnknownValue) return UnknownValue; + if (typeof leftValue === 'symbol') return UnknownValue; + + // Optimize `'export' in namespace` + if (this.operator === 'in' && this.right.variable instanceof NamespaceVariable) { + const [variable] = this.right.variable.context.traceExport(String(leftValue)); + if (variable instanceof ExternalVariable) return UnknownValue; + if (variable instanceof SyntheticNamedExportVariable) return UnknownValue; + return !!variable; + } const rightValue = this.right.getLiteralValueAtPath(EMPTY_PATH, recursionTracker, origin); - if (rightValue === UnknownValue) return UnknownValue; + if (typeof rightValue === 'symbol') return UnknownValue; - const operatorFn = binaryOperators[this.operator]; - if (!operatorFn) return UnknownValue; + const operatorFunction = binaryOperators[this.operator]; + if (!operatorFunction) return UnknownValue; - return operatorFn(leftValue, rightValue); + return operatorFunction(leftValue, rightValue); + } + + getRenderedLiteralValue() { + // Only optimize `'export' in ns` + if (this.operator !== 'in' || !(this.right.variable instanceof NamespaceVariable)) { + return UnknownValue; + } + + if (this.renderedLiteralValue !== UNASSIGNED) return this.renderedLiteralValue; + return (this.renderedLiteralValue = getRenderedLiteralValue( + this.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, this) + )); } hasEffects(context: HasEffectsContext): boolean { @@ -74,12 +142,55 @@ export default class BinaryExpression extends NodeBase implements DeoptimizableE this.operator === '+' && this.parent instanceof ExpressionStatement && this.left.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, this) === '' - ) + ) { return true; + } return super.hasEffects(context); } - hasEffectsWhenAccessedAtPath(path: ObjectPath) { - return path.length > 1; + hasEffectsOnInteractionAtPath(path: ObjectPath, { type }: NodeInteraction): boolean { + return type !== INTERACTION_ACCESSED || path.length > 1; + } + + include( + context: InclusionContext, + includeChildrenRecursively: IncludeChildren, + options?: InclusionOptions + ) { + if (!this.included) this.includeNode(context); + if (typeof this.getRenderedLiteralValue() === 'symbol') { + this.left.include(context, includeChildrenRecursively, options); + this.right.include(context, includeChildrenRecursively, options); + + // `instanceof` will attempt to call RHS's `Symbol.hasInstance` if it exists. + if (this.operator === 'instanceof') this.right.includePath(INSTANCEOF_PATH, context); + } + } + + includeNode(context: InclusionContext) { + this.included = true; + if (this.operator === 'in' && typeof this.getRenderedLiteralValue() === 'symbol') { + this.right.includePath(UNKNOWN_PATH, context); + } + } + + removeAnnotations(code: MagicString) { + this.left.removeAnnotations(code); + } + + render( + code: MagicString, + options: RenderOptions, + { renderedSurroundingElement }: NodeRenderOptions = BLANK + ): void { + const renderedLiteralValue = this.getRenderedLiteralValue(); + if (typeof renderedLiteralValue !== 'symbol') { + code.overwrite(this.start, this.end, renderedLiteralValue); + } else { + this.left.render(code, options, { renderedSurroundingElement }); + this.right.render(code, options); + } } } + +BinaryExpression.prototype.applyDeoptimizations = doNotDeoptimize; diff --git a/src/ast/nodes/BlockStatement.ts b/src/ast/nodes/BlockStatement.ts index f60c30ee830..8194867ab23 100644 --- a/src/ast/nodes/BlockStatement.ts +++ b/src/ast/nodes/BlockStatement.ts @@ -1,45 +1,63 @@ -import MagicString from 'magic-string'; -import { RenderOptions, renderStatementList } from '../../utils/renderHelpers'; -import { HasEffectsContext, InclusionContext } from '../ExecutionContext'; +import type MagicString from 'magic-string'; +import { type RenderOptions, renderStatementList } from '../../utils/renderHelpers'; +import type { HasEffectsContext, InclusionContext } from '../ExecutionContext'; import BlockScope from '../scopes/BlockScope'; -import ChildScope from '../scopes/ChildScope'; -import Scope from '../scopes/Scope'; -import { UNKNOWN_EXPRESSION } from '../values'; +import type ChildScope from '../scopes/ChildScope'; import ExpressionStatement from './ExpressionStatement'; import * as NodeType from './NodeType'; -import { IncludeChildren, Node, StatementBase, StatementNode } from './shared/Node'; +import { Flag, isFlagSet, setFlag } from './shared/BitFlags'; +import { UNKNOWN_EXPRESSION } from './shared/Expression'; +import { + doNotDeoptimize, + type IncludeChildren, + type Node, + onlyIncludeSelfNoDeoptimize, + StatementBase, + type StatementNode +} from './shared/Node'; export default class BlockStatement extends StatementBase { - body!: StatementNode[]; - type!: NodeType.tBlockStatement; + declare body: readonly StatementNode[]; + declare type: NodeType.tBlockStatement; - private deoptimizeBody!: boolean; - private directlyIncluded = false; + private get deoptimizeBody(): boolean { + return isFlagSet(this.flags, Flag.deoptimizeBody); + } + private set deoptimizeBody(value: boolean) { + this.flags = setFlag(this.flags, Flag.deoptimizeBody, value); + } + + private get directlyIncluded(): boolean { + return isFlagSet(this.flags, Flag.directlyIncluded); + } + private set directlyIncluded(value: boolean) { + this.flags = setFlag(this.flags, Flag.directlyIncluded, value); + } - addImplicitReturnExpressionToScope() { + addImplicitReturnExpressionToScope(): void { const lastStatement = this.body[this.body.length - 1]; if (!lastStatement || lastStatement.type !== NodeType.ReturnStatement) { this.scope.addReturnExpression(UNKNOWN_EXPRESSION); } } - createScope(parentScope: Scope) { + createScope(parentScope: ChildScope): void { this.scope = (this.parent as Node).preventChildBlockScope ? (parentScope as ChildScope) : new BlockScope(parentScope); } - hasEffects(context: HasEffectsContext) { + hasEffects(context: HasEffectsContext): boolean { if (this.deoptimizeBody) return true; for (const node of this.body) { - if (node.hasEffects(context)) return true; if (context.brokenFlow) break; + if (node.hasEffects(context)) return true; } return false; } - include(context: InclusionContext, includeChildrenRecursively: IncludeChildren) { - if (!this.deoptimizeBody || !this.directlyIncluded) { + include(context: InclusionContext, includeChildrenRecursively: IncludeChildren): void { + if (!(this.deoptimizeBody && this.directlyIncluded)) { this.included = true; this.directlyIncluded = true; if (this.deoptimizeBody) includeChildrenRecursively = true; @@ -50,18 +68,23 @@ export default class BlockStatement extends StatementBase { } } - initialise() { + initialise(): void { + super.initialise(); + this.scope.context.magicString.addSourcemapLocation(this.end - 1); const firstBodyStatement = this.body[0]; this.deoptimizeBody = firstBodyStatement instanceof ExpressionStatement && firstBodyStatement.directive === 'use asm'; } - render(code: MagicString, options: RenderOptions) { - if (this.body.length) { + render(code: MagicString, options: RenderOptions): void { + if (this.body.length > 0) { renderStatementList(this.body, code, this.start + 1, this.end - 1, options); } else { super.render(code, options); } } } + +BlockStatement.prototype.includeNode = onlyIncludeSelfNoDeoptimize; +BlockStatement.prototype.applyDeoptimizations = doNotDeoptimize; diff --git a/src/ast/nodes/BreakStatement.ts b/src/ast/nodes/BreakStatement.ts index e596c7e4298..7507f20b2fb 100644 --- a/src/ast/nodes/BreakStatement.ts +++ b/src/ast/nodes/BreakStatement.ts @@ -1,35 +1,40 @@ +import { type HasEffectsContext, type InclusionContext } from '../ExecutionContext'; +import type Identifier from './Identifier'; +import type * as NodeType from './NodeType'; import { - BROKEN_FLOW_BREAK_CONTINUE, - BROKEN_FLOW_ERROR_RETURN_LABEL, - HasEffectsContext, - InclusionContext -} from '../ExecutionContext'; -import Identifier from './Identifier'; -import * as NodeType from './NodeType'; -import { StatementBase } from './shared/Node'; + doNotDeoptimize, + type IncludeChildren, + onlyIncludeSelfNoDeoptimize, + StatementBase +} from './shared/Node'; export default class BreakStatement extends StatementBase { - label!: Identifier | null; - type!: NodeType.tBreakStatement; + declare label: Identifier | null; + declare type: NodeType.tBreakStatement; - hasEffects(context: HasEffectsContext) { + hasEffects(context: HasEffectsContext): boolean { if (this.label) { if (!context.ignore.labels.has(this.label.name)) return true; context.includedLabels.add(this.label.name); - context.brokenFlow = BROKEN_FLOW_ERROR_RETURN_LABEL; } else { if (!context.ignore.breaks) return true; - context.brokenFlow = BROKEN_FLOW_BREAK_CONTINUE; + context.hasBreak = true; } + context.brokenFlow = true; return false; } - include(context: InclusionContext) { + include(context: InclusionContext, includeChildrenRecursively: IncludeChildren): void { this.included = true; if (this.label) { - this.label.include(); + this.label.include(context, includeChildrenRecursively); context.includedLabels.add(this.label.name); + } else { + context.hasBreak = true; } - context.brokenFlow = this.label ? BROKEN_FLOW_ERROR_RETURN_LABEL : BROKEN_FLOW_BREAK_CONTINUE; + context.brokenFlow = true; } } + +BreakStatement.prototype.includeNode = onlyIncludeSelfNoDeoptimize; +BreakStatement.prototype.applyDeoptimizations = doNotDeoptimize; diff --git a/src/ast/nodes/CallExpression.ts b/src/ast/nodes/CallExpression.ts index 4478a272612..12fbca9ba78 100644 --- a/src/ast/nodes/CallExpression.ts +++ b/src/ast/nodes/CallExpression.ts @@ -1,213 +1,116 @@ -import MagicString from 'magic-string'; -import { NormalizedTreeshakingOptions } from '../../rollup/types'; +import type MagicString from 'magic-string'; +import type { NormalizedTreeshakingOptions } from '../../rollup/types'; import { BLANK } from '../../utils/blank'; -import { - findFirstOccurrenceOutsideComment, - NodeRenderOptions, - RenderOptions -} from '../../utils/renderHelpers'; -import { CallOptions } from '../CallOptions'; -import { DeoptimizableEntity } from '../DeoptimizableEntity'; -import { HasEffectsContext, InclusionContext } from '../ExecutionContext'; -import { - EMPTY_PATH, - ObjectPath, - PathTracker, - SHARED_RECURSION_TRACKER, - UNKNOWN_PATH -} from '../utils/PathTracker'; -import { LiteralValueOrUnknown, UnknownValue, UNKNOWN_EXPRESSION } from '../values'; +import { LOGLEVEL_WARN } from '../../utils/logging'; +import { logCannotCallNamespace, logEval } from '../../utils/logs'; +import { renderCallArguments } from '../../utils/renderCallArguments'; +import { type NodeRenderOptions, type RenderOptions } from '../../utils/renderHelpers'; +import type { DeoptimizableEntity } from '../DeoptimizableEntity'; +import type { HasEffectsContext, InclusionContext } from '../ExecutionContext'; +import { INTERACTION_CALLED } from '../NodeInteractions'; +import type { EntityPathTracker, ObjectPath } from '../utils/PathTracker'; +import { EMPTY_PATH, SHARED_RECURSION_TRACKER } from '../utils/PathTracker'; import Identifier from './Identifier'; import MemberExpression from './MemberExpression'; -import * as NodeType from './NodeType'; -import { ExpressionEntity } from './shared/Expression'; -import { - Annotation, - ExpressionNode, - IncludeChildren, - INCLUDE_PARAMETERS, - NodeBase -} from './shared/Node'; -import SpreadElement from './SpreadElement'; -import Super from './Super'; - -export default class CallExpression extends NodeBase implements DeoptimizableEntity { - arguments!: (ExpressionNode | SpreadElement)[]; - callee!: ExpressionNode | Super; - optional!: boolean; - type!: NodeType.tCallExpression; - - private callOptions!: CallOptions; - private expressionsToBeDeoptimized: DeoptimizableEntity[] = []; - private returnExpression: ExpressionEntity | null = null; - private wasPathDeoptmizedWhileOptimized = false; - - bind() { - super.bind(); - if (this.callee instanceof Identifier) { - const variable = this.scope.findVariable(this.callee.name); - - if (variable.isNamespace) { - this.context.warn( - { - code: 'CANNOT_CALL_NAMESPACE', - message: `Cannot call a namespace ('${this.callee.name}')` - }, - this.start - ); - } - - if (this.callee.name === 'eval') { - this.context.warn( - { - code: 'EVAL', - message: `Use of eval is strongly discouraged, as it poses security risks and may cause issues with minification`, - url: 'https://rollupjs.org/guide/en/#avoiding-eval' - }, - this.start - ); - } - } - // ensure the returnExpression is set for the tree-shaking passes - this.getReturnExpression(SHARED_RECURSION_TRACKER); - // This deoptimizes "this" for non-namespace calls until we have a better solution - if ( - this.callee instanceof MemberExpression && - !this.callee.variable && - this.callee.mayModifyThisWhenCalledAtPath([], SHARED_RECURSION_TRACKER) - ) { - this.callee.object.deoptimizePath(UNKNOWN_PATH); - } - for (const argument of this.arguments) { - // This will make sure all properties of parameters behave as "unknown" - argument.deoptimizePath(UNKNOWN_PATH); - } +import type * as NodeType from './NodeType'; +import { Flag, isFlagSet, setFlag } from './shared/BitFlags'; +import CallExpressionBase from './shared/CallExpressionBase'; +import { getChainElementLiteralValueAtPath } from './shared/chainElements'; +import type { ExpressionEntity, LiteralValueOrUnknown } from './shared/Expression'; +import { UNKNOWN_RETURN_EXPRESSION } from './shared/Expression'; +import type { ChainElement, ExpressionNode, IncludeChildren, SkippedChain } from './shared/Node'; +import { INCLUDE_PARAMETERS, IS_SKIPPED_CHAIN } from './shared/Node'; +import type SpreadElement from './SpreadElement'; +import type Super from './Super'; + +export default class CallExpression + extends CallExpressionBase + implements DeoptimizableEntity, ChainElement +{ + declare arguments: (ExpressionNode | SpreadElement)[]; + declare callee: ExpressionNode | Super; + declare type: NodeType.tCallExpression; + /** Marked with #__PURE__ annotation */ + declare annotationPure?: boolean; + + private get hasCheckedForWarnings(): boolean { + return isFlagSet(this.flags, Flag.checkedForWarnings); } - - deoptimizeCache() { - if (this.returnExpression !== UNKNOWN_EXPRESSION) { - this.returnExpression = null; - const returnExpression = this.getReturnExpression(SHARED_RECURSION_TRACKER); - const expressionsToBeDeoptimized = this.expressionsToBeDeoptimized; - if (returnExpression !== UNKNOWN_EXPRESSION) { - // We need to replace here because is possible new expressions are added - // while we are deoptimizing the old ones - this.expressionsToBeDeoptimized = []; - if (this.wasPathDeoptmizedWhileOptimized) { - returnExpression.deoptimizePath(UNKNOWN_PATH); - this.wasPathDeoptmizedWhileOptimized = false; - } - } - for (const expression of expressionsToBeDeoptimized) { - expression.deoptimizeCache(); - } - } + private set hasCheckedForWarnings(value: boolean) { + this.flags = setFlag(this.flags, Flag.checkedForWarnings, value); } - deoptimizePath(path: ObjectPath) { - if (path.length === 0) return; - const trackedEntities = this.context.deoptimizationTracker.getEntities(path); - if (trackedEntities.has(this)) return; - trackedEntities.add(this); - const returnExpression = this.getReturnExpression(SHARED_RECURSION_TRACKER); - if (returnExpression !== UNKNOWN_EXPRESSION) { - this.wasPathDeoptmizedWhileOptimized = true; - returnExpression.deoptimizePath(path); - } + get optional(): boolean { + return isFlagSet(this.flags, Flag.optional); + } + set optional(value: boolean) { + this.flags = setFlag(this.flags, Flag.optional, value); } - getLiteralValueAtPath( - path: ObjectPath, - recursionTracker: PathTracker, - origin: DeoptimizableEntity - ): LiteralValueOrUnknown { - const returnExpression = this.getReturnExpression(recursionTracker); - if (returnExpression === UNKNOWN_EXPRESSION) { - return UnknownValue; - } - const trackedEntities = recursionTracker.getEntities(path); - if (trackedEntities.has(returnExpression)) { - return UnknownValue; - } - this.expressionsToBeDeoptimized.push(origin); - trackedEntities.add(returnExpression); - const value = returnExpression.getLiteralValueAtPath(path, recursionTracker, origin); - trackedEntities.delete(returnExpression); - return value; + bind(): void { + super.bind(); + this.interaction = { + args: [ + this.callee instanceof MemberExpression && !this.callee.variable + ? this.callee.object + : null, + ...this.arguments + ], + type: INTERACTION_CALLED, + withNew: false + }; } - getReturnExpressionWhenCalledAtPath( + getLiteralValueAtPathAsChainElement( path: ObjectPath, - recursionTracker: PathTracker, + recursionTracker: EntityPathTracker, origin: DeoptimizableEntity - ) { - const returnExpression = this.getReturnExpression(recursionTracker); - if (this.returnExpression === UNKNOWN_EXPRESSION) { - return UNKNOWN_EXPRESSION; - } - const trackedEntities = recursionTracker.getEntities(path); - if (trackedEntities.has(returnExpression)) { - return UNKNOWN_EXPRESSION; - } - this.expressionsToBeDeoptimized.push(origin); - trackedEntities.add(returnExpression); - const value = returnExpression.getReturnExpressionWhenCalledAtPath( - path, - recursionTracker, - origin - ); - trackedEntities.delete(returnExpression); - return value; + ): LiteralValueOrUnknown | SkippedChain { + return getChainElementLiteralValueAtPath(this, this.callee, path, recursionTracker, origin); } hasEffects(context: HasEffectsContext): boolean { + if (!this.deoptimized) this.applyDeoptimizations(); for (const argument of this.arguments) { if (argument.hasEffects(context)) return true; } - if ( - (this.context.options.treeshake as NormalizedTreeshakingOptions).annotations && - this.annotations?.some((a: Annotation) => a.pure) - ) + if (this.annotationPure) { return false; + } return ( this.callee.hasEffects(context) || - this.callee.hasEffectsWhenCalledAtPath(EMPTY_PATH, this.callOptions, context) + this.callee.hasEffectsOnInteractionAtPath(EMPTY_PATH, this.interaction, context) ); } - hasEffectsWhenAccessedAtPath(path: ObjectPath, context: HasEffectsContext): boolean { - if (path.length === 0) return false; - const trackedExpressions = context.accessed.getEntities(path); - if (trackedExpressions.has(this)) return false; - trackedExpressions.add(this); - return this.returnExpression!.hasEffectsWhenAccessedAtPath(path, context); - } - - hasEffectsWhenAssignedAtPath(path: ObjectPath, context: HasEffectsContext): boolean { - if (path.length === 0) return true; - const trackedExpressions = context.assigned.getEntities(path); - if (trackedExpressions.has(this)) return false; - trackedExpressions.add(this); - return this.returnExpression!.hasEffectsWhenAssignedAtPath(path, context); - } - - hasEffectsWhenCalledAtPath( - path: ObjectPath, - callOptions: CallOptions, - context: HasEffectsContext - ): boolean { - const trackedExpressions = (callOptions.withNew - ? context.instantiated - : context.called - ).getEntities(path, callOptions); - if (trackedExpressions.has(this)) return false; - trackedExpressions.add(this); - return this.returnExpression!.hasEffectsWhenCalledAtPath(path, callOptions, context); + hasEffectsAsChainElement(context: HasEffectsContext): boolean | SkippedChain { + const calleeHasEffects = + 'hasEffectsAsChainElement' in this.callee + ? (this.callee as ChainElement).hasEffectsAsChainElement(context) + : this.callee.hasEffects(context); + if (calleeHasEffects === IS_SKIPPED_CHAIN) return IS_SKIPPED_CHAIN; + if ( + this.optional && + this.callee.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, this) == null + ) { + return (!this.annotationPure && calleeHasEffects) || IS_SKIPPED_CHAIN; + } + // We only apply deoptimizations lazily once we know we are not skipping + if (!this.deoptimized) this.applyDeoptimizations(); + for (const argument of this.arguments) { + if (argument.hasEffects(context)) return true; + } + return ( + !this.annotationPure && + (calleeHasEffects || + this.callee.hasEffectsOnInteractionAtPath(EMPTY_PATH, this.interaction, context)) + ); } - include(context: InclusionContext, includeChildrenRecursively: IncludeChildren) { + include(context: InclusionContext, includeChildrenRecursively: IncludeChildren): void { + if (!this.included) this.includeNode(context); if (includeChildrenRecursively) { - super.include(context, includeChildrenRecursively); + super.include(context, true); if ( includeChildrenRecursively === INCLUDE_PARAMETERS && this.callee instanceof Identifier && @@ -216,70 +119,67 @@ export default class CallExpression extends NodeBase implements DeoptimizableEnt this.callee.variable.markCalledFromTryStatement(); } } else { - this.included = true; this.callee.include(context, false); + this.callee.includeCallArguments(this.interaction, context); } - this.callee.includeCallArguments(context, this.arguments); - if (!this.returnExpression!.included) { - this.returnExpression!.include(context, false); - } + } + + includeNode(_context: InclusionContext) { + this.included = true; + if (!this.deoptimized) this.applyDeoptimizations(); } initialise() { - this.callOptions = { - args: this.arguments, - withNew: false - }; + super.initialise(); + if ( + this.annotations && + (this.scope.context.options.treeshake as NormalizedTreeshakingOptions).annotations + ) { + this.annotationPure = this.annotations.some(comment => comment.type === 'pure'); + } } render( code: MagicString, options: RenderOptions, - { renderedParentType, renderedSurroundingElement }: NodeRenderOptions = BLANK - ) { - const surroundingELement = renderedParentType || renderedSurroundingElement; - this.callee.render( - code, - options, - surroundingELement ? { renderedSurroundingElement: surroundingELement } : BLANK - ); - if (this.arguments.length > 0) { - if (this.arguments[this.arguments.length - 1].included) { - for (const arg of this.arguments) { - arg.render(code, options); - } - } else { - let lastIncludedIndex = this.arguments.length - 2; - while (lastIncludedIndex >= 0 && !this.arguments[lastIncludedIndex].included) { - lastIncludedIndex--; - } - if (lastIncludedIndex >= 0) { - for (let index = 0; index <= lastIncludedIndex; index++) { - this.arguments[index].render(code, options); - } - code.remove( - findFirstOccurrenceOutsideComment( - code.original, - ',', - this.arguments[lastIncludedIndex].end - ), - this.end - 1 - ); - } else { - code.remove( - findFirstOccurrenceOutsideComment(code.original, '(', this.callee.end) + 1, - this.end - 1 - ); - } + { renderedSurroundingElement }: NodeRenderOptions = BLANK + ): void { + this.callee.render(code, options, { + isCalleeOfRenderedParent: true, + renderedSurroundingElement + }); + renderCallArguments(code, options, this); + + if (this.callee instanceof Identifier && !this.hasCheckedForWarnings) { + this.hasCheckedForWarnings = true; + const variable = this.scope.findVariable(this.callee.name); + if (variable.isNamespace) { + this.scope.context.log(LOGLEVEL_WARN, logCannotCallNamespace(this.callee.name), this.start); + } + if (this.callee.name === 'eval') { + this.scope.context.log(LOGLEVEL_WARN, logEval(this.scope.context.module.id), this.start); } } } - private getReturnExpression(recursionTracker: PathTracker): ExpressionEntity { + applyDeoptimizations() { + this.deoptimized = true; + this.callee.deoptimizeArgumentsOnInteractionAtPath( + this.interaction, + EMPTY_PATH, + SHARED_RECURSION_TRACKER + ); + this.scope.context.requestTreeshakingPass(); + } + + protected getReturnExpression( + recursionTracker: EntityPathTracker = SHARED_RECURSION_TRACKER + ): [expression: ExpressionEntity, isPure: boolean] { if (this.returnExpression === null) { - this.returnExpression = UNKNOWN_EXPRESSION; + this.returnExpression = UNKNOWN_RETURN_EXPRESSION; return (this.returnExpression = this.callee.getReturnExpressionWhenCalledAtPath( EMPTY_PATH, + this.interaction, recursionTracker, this )); diff --git a/src/ast/nodes/CatchClause.ts b/src/ast/nodes/CatchClause.ts index c7885e8ab80..7224a9a8be2 100644 --- a/src/ast/nodes/CatchClause.ts +++ b/src/ast/nodes/CatchClause.ts @@ -1,36 +1,37 @@ -import CatchScope from '../scopes/CatchScope'; -import Scope from '../scopes/Scope'; -import { UNKNOWN_EXPRESSION } from '../values'; +import type ChildScope from '../scopes/ChildScope'; +import ParameterScope from '../scopes/ParameterScope'; +import { EMPTY_PATH } from '../utils/PathTracker'; import BlockStatement from './BlockStatement'; -import * as NodeType from './NodeType'; -import { GenericEsTreeNode, NodeBase } from './shared/Node'; -import { PatternNode } from './shared/Pattern'; +import type * as NodeType from './NodeType'; +import { UNKNOWN_EXPRESSION } from './shared/Expression'; +import { type GenericEsTreeNode, NodeBase, onlyIncludeSelf } from './shared/Node'; +import type { DeclarationPatternNode } from './shared/Pattern'; export default class CatchClause extends NodeBase { - body!: BlockStatement; - param!: PatternNode | null; - preventChildBlockScope!: true; - scope!: CatchScope; - type!: NodeType.tCatchClause; + declare body: BlockStatement; + declare param: DeclarationPatternNode | null; + declare preventChildBlockScope: true; + declare scope: ParameterScope; + declare type: NodeType.tCatchClause; - createScope(parentScope: Scope) { - this.scope = new CatchScope(parentScope, this.context); + createScope(parentScope: ChildScope): void { + this.scope = new ParameterScope(parentScope, true); } - initialise() { - if (this.param) { - this.param.declare('parameter', UNKNOWN_EXPRESSION); + parseNode(esTreeNode: GenericEsTreeNode): this { + const { body, param, type } = esTreeNode; + this.type = type as NodeType.tCatchClause; + if (param) { + this.param = new (this.scope.context.getNodeConstructor(param.type))( + this, + this.scope + ).parseNode(param) as unknown as DeclarationPatternNode; + this.param!.declare('parameter', EMPTY_PATH, UNKNOWN_EXPRESSION); } - } - - parseNode(esTreeNode: GenericEsTreeNode) { - this.body = new this.context.nodeConstructors.BlockStatement( - esTreeNode.body, - this, - this.scope - ) as BlockStatement; - super.parseNode(esTreeNode); + this.body = new BlockStatement(this, this.scope.bodyScope).parseNode(body); + return super.parseNode(esTreeNode); } } CatchClause.prototype.preventChildBlockScope = true; +CatchClause.prototype.includeNode = onlyIncludeSelf; diff --git a/src/ast/nodes/ChainExpression.ts b/src/ast/nodes/ChainExpression.ts index 77c8a021819..e4c02e15ee2 100644 --- a/src/ast/nodes/ChainExpression.ts +++ b/src/ast/nodes/ChainExpression.ts @@ -1,9 +1,51 @@ -import CallExpression from './CallExpression'; -import MemberExpression from './MemberExpression'; -import * as NodeType from './NodeType'; -import { NodeBase } from './shared/Node'; - -export default class ChainExpression extends NodeBase { - expression!: CallExpression | MemberExpression; - type!: NodeType.tChainExpression; +import type MagicString from 'magic-string'; +import type { DeoptimizableEntity } from '../DeoptimizableEntity'; +import type { HasEffectsContext, InclusionContext } from '../ExecutionContext'; +import type { EntityPathTracker, ObjectPath } from '../utils/PathTracker'; +import type CallExpression from './CallExpression'; +import type MemberExpression from './MemberExpression'; +import type * as NodeType from './NodeType'; +import type { LiteralValueOrUnknown } from './shared/Expression'; +import { + doNotDeoptimize, + IS_SKIPPED_CHAIN, + NodeBase, + onlyIncludeSelfNoDeoptimize +} from './shared/Node'; + +export default class ChainExpression extends NodeBase implements DeoptimizableEntity { + declare expression: CallExpression | MemberExpression; + declare type: NodeType.tChainExpression; + + // deoptimizations are not relevant as we are not caching values + deoptimizeCache(): void {} + + getLiteralValueAtPath( + path: ObjectPath, + recursionTracker: EntityPathTracker, + origin: DeoptimizableEntity + ): LiteralValueOrUnknown { + const literalValue = this.expression.getLiteralValueAtPathAsChainElement( + path, + recursionTracker, + origin + ); + return literalValue === IS_SKIPPED_CHAIN ? undefined : literalValue; + } + + hasEffects(context: HasEffectsContext): boolean { + return this.expression.hasEffectsAsChainElement(context) === true; + } + + includePath(path: ObjectPath, context: InclusionContext) { + this.included = true; + this.expression.includePath(path, context); + } + + removeAnnotations(code: MagicString) { + this.expression.removeAnnotations(code); + } } + +ChainExpression.prototype.includeNode = onlyIncludeSelfNoDeoptimize; +ChainExpression.prototype.applyDeoptimizations = doNotDeoptimize; diff --git a/src/ast/nodes/ClassBody.ts b/src/ast/nodes/ClassBody.ts index 0dc6efa32a5..900e5bca9bf 100644 --- a/src/ast/nodes/ClassBody.ts +++ b/src/ast/nodes/ClassBody.ts @@ -1,42 +1,50 @@ -import { CallOptions } from '../CallOptions'; -import { HasEffectsContext } from '../ExecutionContext'; +import type { InclusionContext } from '../ExecutionContext'; +import type ChildScope from '../scopes/ChildScope'; import ClassBodyScope from '../scopes/ClassBodyScope'; -import Scope from '../scopes/Scope'; -import { EMPTY_PATH, ObjectPath } from '../utils/PathTracker'; -import MethodDefinition from './MethodDefinition'; -import * as NodeType from './NodeType'; -import PropertyDefinition from './PropertyDefinition'; -import { NodeBase } from './shared/Node'; +import { UNKNOWN_PATH } from '../utils/PathTracker'; -export default class ClassBody extends NodeBase { - body!: (MethodDefinition | PropertyDefinition)[]; - type!: NodeType.tClassBody; +import type MethodDefinition from './MethodDefinition'; +import type * as NodeType from './NodeType'; +import type PropertyDefinition from './PropertyDefinition'; +import type ClassNode from './shared/ClassNode'; +import { + doNotDeoptimize, + type GenericEsTreeNode, + type IncludeChildren, + NodeBase, + onlyIncludeSelfNoDeoptimize +} from './shared/Node'; +import type StaticBlock from './StaticBlock'; - private classConstructor!: MethodDefinition | null; +export default class ClassBody extends NodeBase { + declare body: (MethodDefinition | PropertyDefinition | StaticBlock)[]; + declare scope: ClassBodyScope; + declare type: NodeType.tClassBody; - createScope(parentScope: Scope) { - this.scope = new ClassBodyScope(parentScope); + createScope(parentScope: ChildScope): void { + this.scope = new ClassBodyScope(parentScope, this.parent as ClassNode); } - hasEffectsWhenCalledAtPath( - path: ObjectPath, - callOptions: CallOptions, - context: HasEffectsContext - ) { - if (path.length > 0) return true; - return ( - this.classConstructor !== null && - this.classConstructor.hasEffectsWhenCalledAtPath(EMPTY_PATH, callOptions, context) - ); + include(context: InclusionContext, includeChildrenRecursively: IncludeChildren): void { + this.included = true; + this.scope.context.includeVariableInModule(this.scope.thisVariable, UNKNOWN_PATH, context); + for (const definition of this.body) { + definition.include(context, includeChildrenRecursively); + } } - initialise() { - for (const method of this.body) { - if (method instanceof MethodDefinition && method.kind === 'constructor') { - this.classConstructor = method; - return; - } + parseNode(esTreeNode: GenericEsTreeNode): this { + const body: NodeBase[] = (this.body = new Array(esTreeNode.body.length)); + let index = 0; + for (const definition of esTreeNode.body) { + body[index++] = new (this.scope.context.getNodeConstructor(definition.type))( + this, + definition.static ? this.scope : this.scope.instanceScope + ).parseNode(definition); } - this.classConstructor = null; + return super.parseNode(esTreeNode); } } + +ClassBody.prototype.includeNode = onlyIncludeSelfNoDeoptimize; +ClassBody.prototype.applyDeoptimizations = doNotDeoptimize; diff --git a/src/ast/nodes/ClassDeclaration.ts b/src/ast/nodes/ClassDeclaration.ts index 65e18330be1..fdb0bd576d6 100644 --- a/src/ast/nodes/ClassDeclaration.ts +++ b/src/ast/nodes/ClassDeclaration.ts @@ -1,42 +1,70 @@ -import MagicString from 'magic-string'; -import { RenderOptions } from '../../utils/renderHelpers'; +import type MagicString from 'magic-string'; +import type { RenderOptions } from '../../utils/renderHelpers'; import { getSystemExportStatement } from '../../utils/systemJsRendering'; -import ChildScope from '../scopes/ChildScope'; -import { IdentifierWithVariable } from './Identifier'; -import * as NodeType from './NodeType'; +import type ChildScope from '../scopes/ChildScope'; +import type Variable from '../variables/Variable'; +import Identifier, { type IdentifierWithVariable } from './Identifier'; +import type * as NodeType from './NodeType'; import ClassNode from './shared/ClassNode'; -import { GenericEsTreeNode } from './shared/Node'; +import type { GenericEsTreeNode } from './shared/Node'; export default class ClassDeclaration extends ClassNode { - id!: IdentifierWithVariable | null; - type!: NodeType.tClassDeclaration; + declare id: IdentifierWithVariable | null; + declare type: NodeType.tClassDeclaration; - initialise() { + initialise(): void { super.initialise(); if (this.id !== null) { this.id.variable.isId = true; } } - parseNode(esTreeNode: GenericEsTreeNode) { + parseNode(esTreeNode: GenericEsTreeNode): this { if (esTreeNode.id !== null) { - this.id = new this.context.nodeConstructors.Identifier( - esTreeNode.id, - this, - this.scope.parent as ChildScope + this.id = new Identifier(this, this.scope.parent as ChildScope).parseNode( + esTreeNode.id ) as IdentifierWithVariable; } - super.parseNode(esTreeNode); + return super.parseNode(esTreeNode); } - render(code: MagicString, options: RenderOptions) { - if ( - options.format === 'system' && - this.id && - options.exportNamesByVariable.has(this.id.variable) - ) { - code.appendLeft(this.end, `${options.compact ? '' : ' '}${getSystemExportStatement([this.id.variable], options)};`); + render(code: MagicString, options: RenderOptions): void { + const { + exportNamesByVariable, + format, + snippets: { _, getPropertyAccess } + } = options; + if (this.id) { + const { variable, name } = this.id; + if (format === 'system' && exportNamesByVariable.has(variable)) { + code.appendLeft(this.end, `${_}${getSystemExportStatement([variable], options)};`); + } + const renderedVariable = variable.getName(getPropertyAccess); + if (renderedVariable !== name) { + this.decorators.map(decorator => decorator.render(code, options)); + this.superClass?.render(code, options); + this.body.render(code, { + ...options, + useOriginalName: (_variable: Variable) => _variable === variable + }); + code.prependRight(this.start, `let ${renderedVariable}${_}=${_}`); + code.prependLeft(this.end, ';'); + return; + } } super.render(code, options); } + + applyDeoptimizations() { + super.applyDeoptimizations(); + const { id, scope } = this; + if (id) { + const { name, variable } = id; + for (const accessedVariable of scope.accessedOutsideVariables.values()) { + if (accessedVariable !== variable) { + accessedVariable.forbidName(name); + } + } + } + } } diff --git a/src/ast/nodes/ClassExpression.ts b/src/ast/nodes/ClassExpression.ts index ceea4803202..35b429cc0d7 100644 --- a/src/ast/nodes/ClassExpression.ts +++ b/src/ast/nodes/ClassExpression.ts @@ -1,20 +1,19 @@ -import MagicString from 'magic-string'; +import type MagicString from 'magic-string'; import { BLANK } from '../../utils/blank'; -import { NodeRenderOptions, RenderOptions } from '../../utils/renderHelpers'; +import type { NodeRenderOptions, RenderOptions } from '../../utils/renderHelpers'; import * as NodeType from './NodeType'; import ClassNode from './shared/ClassNode'; export default class ClassExpression extends ClassNode { - type!: NodeType.tClassExpression; + declare type: NodeType.tClassExpression; render( code: MagicString, options: RenderOptions, - { renderedParentType, renderedSurroundingElement }: NodeRenderOptions = BLANK - ) { + { renderedSurroundingElement }: NodeRenderOptions = BLANK + ): void { super.render(code, options); - const surroundingElement = renderedParentType || renderedSurroundingElement; - if (surroundingElement === NodeType.ExpressionStatement) { + if (renderedSurroundingElement === NodeType.ExpressionStatement) { code.appendRight(this.start, '('); code.prependLeft(this.end, ')'); } diff --git a/src/ast/nodes/ConditionalExpression.ts b/src/ast/nodes/ConditionalExpression.ts index 2b1dfea88a3..0400ac21ae3 100644 --- a/src/ast/nodes/ConditionalExpression.ts +++ b/src/ast/nodes/ConditionalExpression.ts @@ -1,176 +1,222 @@ -import MagicString from 'magic-string'; -import { BLANK } from '../../utils/blank'; +import type MagicString from 'magic-string'; +import { BLANK, EMPTY_ARRAY } from '../../utils/blank'; +import type { NodeRenderOptions, RenderOptions } from '../../utils/renderHelpers'; import { findFirstOccurrenceOutsideComment, findNonWhiteSpace, - NodeRenderOptions, - removeLineBreaks, - RenderOptions + removeLineBreaks } from '../../utils/renderHelpers'; -import { removeAnnotations } from '../../utils/treeshakeNode'; -import { CallOptions } from '../CallOptions'; -import { DeoptimizableEntity } from '../DeoptimizableEntity'; -import { HasEffectsContext, InclusionContext } from '../ExecutionContext'; -import { - EMPTY_PATH, - ObjectPath, - PathTracker, - SHARED_RECURSION_TRACKER, - UNKNOWN_PATH -} from '../utils/PathTracker'; -import { LiteralValueOrUnknown, UnknownValue } from '../values'; -import CallExpression from './CallExpression'; -import * as NodeType from './NodeType'; -import { ExpressionEntity } from './shared/Expression'; +import type { DeoptimizableEntity } from '../DeoptimizableEntity'; +import type { HasEffectsContext, InclusionContext } from '../ExecutionContext'; +import { createInclusionContext } from '../ExecutionContext'; +import type { NodeInteraction, NodeInteractionCalled } from '../NodeInteractions'; +import type { EntityPathTracker, ObjectPath } from '../utils/PathTracker'; +import { EMPTY_PATH, SHARED_RECURSION_TRACKER, UNKNOWN_PATH } from '../utils/PathTracker'; +import { tryCastLiteralValueToBoolean } from '../utils/tryCastLiteralValueToBoolean'; +import type * as NodeType from './NodeType'; +import { Flag, isFlagSet, setFlag } from './shared/BitFlags'; +import type { ExpressionEntity, LiteralValueOrUnknown } from './shared/Expression'; +import { UnknownFalsyValue, UnknownTruthyValue, UnknownValue } from './shared/Expression'; import { MultiExpression } from './shared/MultiExpression'; -import { ExpressionNode, IncludeChildren, NodeBase } from './shared/Node'; -import SpreadElement from './SpreadElement'; +import type { ExpressionNode, IncludeChildren } from './shared/Node'; +import { doNotDeoptimize, NodeBase, onlyIncludeSelfNoDeoptimize } from './shared/Node'; export default class ConditionalExpression extends NodeBase implements DeoptimizableEntity { - alternate!: ExpressionNode; - consequent!: ExpressionNode; - test!: ExpressionNode; - type!: NodeType.tConditionalExpression; + declare alternate: ExpressionNode; + declare consequent: ExpressionNode; + declare test: ExpressionNode; + declare type: NodeType.tConditionalExpression; + + get isBranchResolutionAnalysed(): boolean { + return isFlagSet(this.flags, Flag.isBranchResolutionAnalysed); + } + set isBranchResolutionAnalysed(value: boolean) { + this.flags = setFlag(this.flags, Flag.isBranchResolutionAnalysed, value); + } + + private get hasDeoptimizedCache(): boolean { + return isFlagSet(this.flags, Flag.hasDeoptimizedCache); + } + private set hasDeoptimizedCache(value: boolean) { + this.flags = setFlag(this.flags, Flag.hasDeoptimizedCache, value); + } private expressionsToBeDeoptimized: DeoptimizableEntity[] = []; - private isBranchResolutionAnalysed = false; private usedBranch: ExpressionNode | null = null; - private wasPathDeoptimizedWhileOptimized = false; - bind() { - super.bind(); - // ensure the usedBranch is set for the tree-shaking passes - this.getUsedBranch(); + deoptimizeArgumentsOnInteractionAtPath( + interaction: NodeInteraction, + path: ObjectPath, + recursionTracker: EntityPathTracker + ): void { + this.consequent.deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker); + this.alternate.deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker); } - deoptimizeCache() { + deoptimizeCache(): void { + if (this.hasDeoptimizedCache) return; + this.hasDeoptimizedCache = true; if (this.usedBranch !== null) { const unusedBranch = this.usedBranch === this.consequent ? this.alternate : this.consequent; this.usedBranch = null; - const expressionsToBeDeoptimized = this.expressionsToBeDeoptimized; - this.expressionsToBeDeoptimized = []; - if (this.wasPathDeoptimizedWhileOptimized) { - unusedBranch.deoptimizePath(UNKNOWN_PATH); + unusedBranch.deoptimizePath(UNKNOWN_PATH); + if (this.included) { + unusedBranch.includePath(UNKNOWN_PATH, createInclusionContext()); } + const { expressionsToBeDeoptimized } = this; + this.expressionsToBeDeoptimized = EMPTY_ARRAY as unknown as DeoptimizableEntity[]; for (const expression of expressionsToBeDeoptimized) { expression.deoptimizeCache(); } } } - deoptimizePath(path: ObjectPath) { - if (path.length > 0) { - const usedBranch = this.getUsedBranch(); - if (usedBranch === null) { - this.consequent.deoptimizePath(path); - this.alternate.deoptimizePath(path); - } else { - this.wasPathDeoptimizedWhileOptimized = true; - usedBranch.deoptimizePath(path); - } + deoptimizePath(path: ObjectPath): void { + const usedBranch = this.getUsedBranch(); + if (usedBranch) { + usedBranch.deoptimizePath(path); + } else { + this.consequent.deoptimizePath(path); + this.alternate.deoptimizePath(path); } } getLiteralValueAtPath( path: ObjectPath, - recursionTracker: PathTracker, + recursionTracker: EntityPathTracker, origin: DeoptimizableEntity ): LiteralValueOrUnknown { const usedBranch = this.getUsedBranch(); - if (usedBranch === null) return UnknownValue; + if (!usedBranch) { + if (this.hasDeoptimizedCache) { + return UnknownValue; + } + const consequentValue = this.consequent.getLiteralValueAtPath(path, recursionTracker, origin); + const castedConsequentValue = tryCastLiteralValueToBoolean(consequentValue); + if (castedConsequentValue === UnknownValue) return UnknownValue; + const alternateValue = this.alternate.getLiteralValueAtPath(path, recursionTracker, origin); + const castedAlternateValue = tryCastLiteralValueToBoolean(alternateValue); + if (castedConsequentValue !== castedAlternateValue) return UnknownValue; + this.expressionsToBeDeoptimized.push(origin); + if (consequentValue !== alternateValue) + return castedConsequentValue ? UnknownTruthyValue : UnknownFalsyValue; + return consequentValue; + } this.expressionsToBeDeoptimized.push(origin); return usedBranch.getLiteralValueAtPath(path, recursionTracker, origin); } getReturnExpressionWhenCalledAtPath( path: ObjectPath, - recursionTracker: PathTracker, + interaction: NodeInteractionCalled, + recursionTracker: EntityPathTracker, origin: DeoptimizableEntity - ): ExpressionEntity { + ): [expression: ExpressionEntity, isPure: boolean] { const usedBranch = this.getUsedBranch(); - if (usedBranch === null) - return new MultiExpression([ - this.consequent.getReturnExpressionWhenCalledAtPath(path, recursionTracker, origin), - this.alternate.getReturnExpressionWhenCalledAtPath(path, recursionTracker, origin) - ]); + if (!usedBranch) + return [ + new MultiExpression([ + this.consequent.getReturnExpressionWhenCalledAtPath( + path, + interaction, + recursionTracker, + origin + )[0], + this.alternate.getReturnExpressionWhenCalledAtPath( + path, + interaction, + recursionTracker, + origin + )[0] + ]), + false + ]; this.expressionsToBeDeoptimized.push(origin); - return usedBranch.getReturnExpressionWhenCalledAtPath(path, recursionTracker, origin); + return usedBranch.getReturnExpressionWhenCalledAtPath( + path, + interaction, + recursionTracker, + origin + ); } hasEffects(context: HasEffectsContext): boolean { if (this.test.hasEffects(context)) return true; - if (this.usedBranch === null) { + const usedBranch = this.getUsedBranch(); + if (!usedBranch) { return this.consequent.hasEffects(context) || this.alternate.hasEffects(context); } - return this.usedBranch.hasEffects(context); - } - - hasEffectsWhenAccessedAtPath(path: ObjectPath, context: HasEffectsContext): boolean { - if (path.length === 0) return false; - if (this.usedBranch === null) { - return ( - this.consequent.hasEffectsWhenAccessedAtPath(path, context) || - this.alternate.hasEffectsWhenAccessedAtPath(path, context) - ); - } - return this.usedBranch.hasEffectsWhenAccessedAtPath(path, context); + return usedBranch.hasEffects(context); } - hasEffectsWhenAssignedAtPath(path: ObjectPath, context: HasEffectsContext): boolean { - if (path.length === 0) return true; - if (this.usedBranch === null) { - return ( - this.consequent.hasEffectsWhenAssignedAtPath(path, context) || - this.alternate.hasEffectsWhenAssignedAtPath(path, context) - ); - } - return this.usedBranch.hasEffectsWhenAssignedAtPath(path, context); - } - - hasEffectsWhenCalledAtPath( + hasEffectsOnInteractionAtPath( path: ObjectPath, - callOptions: CallOptions, + interaction: NodeInteraction, context: HasEffectsContext ): boolean { - if (this.usedBranch === null) { + const usedBranch = this.getUsedBranch(); + if (!usedBranch) { return ( - this.consequent.hasEffectsWhenCalledAtPath(path, callOptions, context) || - this.alternate.hasEffectsWhenCalledAtPath(path, callOptions, context) + this.consequent.hasEffectsOnInteractionAtPath(path, interaction, context) || + this.alternate.hasEffectsOnInteractionAtPath(path, interaction, context) ); } - return this.usedBranch.hasEffectsWhenCalledAtPath(path, callOptions, context); + return usedBranch.hasEffectsOnInteractionAtPath(path, interaction, context); } - include(context: InclusionContext, includeChildrenRecursively: IncludeChildren) { + include(context: InclusionContext, includeChildrenRecursively: IncludeChildren): void { this.included = true; - if ( - includeChildrenRecursively || - this.test.shouldBeIncluded(context) || - this.usedBranch === null - ) { + const usedBranch = this.getUsedBranch(); + if (usedBranch === null || includeChildrenRecursively || this.test.shouldBeIncluded(context)) { this.test.include(context, includeChildrenRecursively); this.consequent.include(context, includeChildrenRecursively); this.alternate.include(context, includeChildrenRecursively); } else { - this.usedBranch.include(context, includeChildrenRecursively); + usedBranch.include(context, includeChildrenRecursively); + } + } + + includePath(path: ObjectPath, context: InclusionContext): void { + this.included = true; + const usedBranch = this.getUsedBranch(); + if (usedBranch === null || this.test.shouldBeIncluded(context)) { + this.consequent.includePath(path, context); + this.alternate.includePath(path, context); + } else { + usedBranch.includePath(path, context); } } - includeCallArguments(context: InclusionContext, args: (ExpressionNode | SpreadElement)[]): void { - if (this.usedBranch === null) { - this.consequent.includeCallArguments(context, args); - this.alternate.includeCallArguments(context, args); + includeCallArguments(interaction: NodeInteractionCalled, context: InclusionContext): void { + const usedBranch = this.getUsedBranch(); + if (usedBranch) { + usedBranch.includeCallArguments(interaction, context); } else { - this.usedBranch.includeCallArguments(context, args); + this.consequent.includeCallArguments(interaction, context); + this.alternate.includeCallArguments(interaction, context); } } + removeAnnotations(code: MagicString) { + this.test.removeAnnotations(code); + } + render( code: MagicString, options: RenderOptions, - { renderedParentType, isCalleeOfRenderedParent, preventASI }: NodeRenderOptions = BLANK - ) { - if (!this.test.included) { + { + isCalleeOfRenderedParent, + preventASI, + renderedParentType, + renderedSurroundingElement + }: NodeRenderOptions = BLANK + ): void { + if (this.test.included) { + this.test.render(code, options, { renderedSurroundingElement }); + this.consequent.render(code, options); + this.alternate.render(code, options); + } else { + const usedBranch = this.getUsedBranch(); const colonPos = findFirstOccurrenceOutsideComment(code.original, ':', this.consequent.end); const inclusionStart = findNonWhiteSpace( code.original, @@ -179,22 +225,19 @@ export default class ConditionalExpression extends NodeBase implements Deoptimiz : colonPos) + 1 ); if (preventASI) { - removeLineBreaks(code, inclusionStart, this.usedBranch!.start); + removeLineBreaks(code, inclusionStart, usedBranch!.start); } code.remove(this.start, inclusionStart); if (this.consequent.included) { code.remove(colonPos, this.end); } - removeAnnotations(this, code); - this.usedBranch!.render(code, options, { - isCalleeOfRenderedParent: renderedParentType - ? isCalleeOfRenderedParent - : (this.parent as CallExpression).callee === this, + this.test.removeAnnotations(code); + usedBranch!.render(code, options, { + isCalleeOfRenderedParent, preventASI: true, - renderedParentType: renderedParentType || this.parent.type + renderedParentType: renderedParentType || this.parent.type, + renderedSurroundingElement: renderedSurroundingElement || this.parent.type }); - } else { - super.render(code, options); } } @@ -203,9 +246,14 @@ export default class ConditionalExpression extends NodeBase implements Deoptimiz return this.usedBranch; } this.isBranchResolutionAnalysed = true; - const testValue = this.test.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, this); - return testValue === UnknownValue + const testValue = tryCastLiteralValueToBoolean( + this.test.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, this) + ); + return typeof testValue === 'symbol' ? null : (this.usedBranch = testValue ? this.consequent : this.alternate); } } + +ConditionalExpression.prototype.includeNode = onlyIncludeSelfNoDeoptimize; +ConditionalExpression.prototype.applyDeoptimizations = doNotDeoptimize; diff --git a/src/ast/nodes/ContinueStatement.ts b/src/ast/nodes/ContinueStatement.ts index 5f1f1a35863..af526a9cca4 100644 --- a/src/ast/nodes/ContinueStatement.ts +++ b/src/ast/nodes/ContinueStatement.ts @@ -1,35 +1,40 @@ +import { type HasEffectsContext, type InclusionContext } from '../ExecutionContext'; +import type Identifier from './Identifier'; +import type * as NodeType from './NodeType'; import { - BROKEN_FLOW_BREAK_CONTINUE, - BROKEN_FLOW_ERROR_RETURN_LABEL, - HasEffectsContext, - InclusionContext -} from '../ExecutionContext'; -import Identifier from './Identifier'; -import * as NodeType from './NodeType'; -import { StatementBase } from './shared/Node'; + doNotDeoptimize, + type IncludeChildren, + onlyIncludeSelfNoDeoptimize, + StatementBase +} from './shared/Node'; export default class ContinueStatement extends StatementBase { - label!: Identifier | null; - type!: NodeType.tContinueStatement; + declare label: Identifier | null; + declare type: NodeType.tContinueStatement; - hasEffects(context: HasEffectsContext) { + hasEffects(context: HasEffectsContext): boolean { if (this.label) { if (!context.ignore.labels.has(this.label.name)) return true; context.includedLabels.add(this.label.name); - context.brokenFlow = BROKEN_FLOW_ERROR_RETURN_LABEL; } else { if (!context.ignore.continues) return true; - context.brokenFlow = BROKEN_FLOW_BREAK_CONTINUE; + context.hasContinue = true; } + context.brokenFlow = true; return false; } - include(context: InclusionContext) { + include(context: InclusionContext, includeChildrenRecursively: IncludeChildren): void { this.included = true; if (this.label) { - this.label.include(); + this.label.include(context, includeChildrenRecursively); context.includedLabels.add(this.label.name); + } else { + context.hasContinue = true; } - context.brokenFlow = this.label ? BROKEN_FLOW_ERROR_RETURN_LABEL : BROKEN_FLOW_BREAK_CONTINUE; + context.brokenFlow = true; } } + +ContinueStatement.prototype.includeNode = onlyIncludeSelfNoDeoptimize; +ContinueStatement.prototype.applyDeoptimizations = doNotDeoptimize; diff --git a/src/ast/nodes/DebuggerStatement.ts b/src/ast/nodes/DebuggerStatement.ts new file mode 100644 index 00000000000..cffa2943647 --- /dev/null +++ b/src/ast/nodes/DebuggerStatement.ts @@ -0,0 +1,12 @@ +import type * as NodeType from './NodeType'; +import { onlyIncludeSelf, StatementBase } from './shared/Node'; + +export default class DebuggerStatement extends StatementBase { + declare type: NodeType.tDebuggerStatement; + + hasEffects(): boolean { + return true; + } +} + +DebuggerStatement.prototype.includeNode = onlyIncludeSelf; diff --git a/src/ast/nodes/Decorator.ts b/src/ast/nodes/Decorator.ts new file mode 100644 index 00000000000..c6cf5329dce --- /dev/null +++ b/src/ast/nodes/Decorator.ts @@ -0,0 +1,22 @@ +import type { HasEffectsContext } from '../ExecutionContext'; +import { NODE_INTERACTION_UNKNOWN_CALL } from '../NodeInteractions'; +import { EMPTY_PATH } from '../utils/PathTracker'; +import type * as NodeType from './NodeType'; +import { type ExpressionNode, NodeBase, onlyIncludeSelf } from './shared/Node'; + +export default class Decorator extends NodeBase { + declare type: NodeType.tDecorator; + declare expression: ExpressionNode; + hasEffects(context: HasEffectsContext): boolean { + return ( + this.expression.hasEffects(context) || + this.expression.hasEffectsOnInteractionAtPath( + EMPTY_PATH, + NODE_INTERACTION_UNKNOWN_CALL, + context + ) + ); + } +} + +Decorator.prototype.includeNode = onlyIncludeSelf; diff --git a/src/ast/nodes/DoWhileStatement.ts b/src/ast/nodes/DoWhileStatement.ts index baa5f0dc3b5..1878ca42a65 100644 --- a/src/ast/nodes/DoWhileStatement.ts +++ b/src/ast/nodes/DoWhileStatement.ts @@ -1,32 +1,31 @@ -import { HasEffectsContext, InclusionContext } from '../ExecutionContext'; -import * as NodeType from './NodeType'; -import { ExpressionNode, IncludeChildren, StatementBase, StatementNode } from './shared/Node'; +import type { HasEffectsContext, InclusionContext } from '../ExecutionContext'; +import type * as NodeType from './NodeType'; +import { hasLoopBodyEffects, includeLoopBody } from './shared/loops'; +import { + doNotDeoptimize, + type ExpressionNode, + type IncludeChildren, + onlyIncludeSelfNoDeoptimize, + StatementBase, + type StatementNode +} from './shared/Node'; export default class DoWhileStatement extends StatementBase { - body!: StatementNode; - test!: ExpressionNode; - type!: NodeType.tDoWhileStatement; + declare body: StatementNode; + declare test: ExpressionNode; + declare type: NodeType.tDoWhileStatement; hasEffects(context: HasEffectsContext): boolean { if (this.test.hasEffects(context)) return true; - const { - brokenFlow, - ignore: { breaks, continues } - } = context; - context.ignore.breaks = true; - context.ignore.continues = true; - if (this.body.hasEffects(context)) return true; - context.ignore.breaks = breaks; - context.ignore.continues = continues; - context.brokenFlow = brokenFlow; - return false; + return hasLoopBodyEffects(context, this.body); } - include(context: InclusionContext, includeChildrenRecursively: IncludeChildren) { + include(context: InclusionContext, includeChildrenRecursively: IncludeChildren): void { this.included = true; this.test.include(context, includeChildrenRecursively); - const { brokenFlow } = context; - this.body.includeAsSingleStatement(context, includeChildrenRecursively); - context.brokenFlow = brokenFlow; + includeLoopBody(context, this.body, includeChildrenRecursively); } } + +DoWhileStatement.prototype.includeNode = onlyIncludeSelfNoDeoptimize; +DoWhileStatement.prototype.applyDeoptimizations = doNotDeoptimize; diff --git a/src/ast/nodes/EmptyStatement.ts b/src/ast/nodes/EmptyStatement.ts index 7021b32d7ab..bfe36c3680c 100644 --- a/src/ast/nodes/EmptyStatement.ts +++ b/src/ast/nodes/EmptyStatement.ts @@ -1,10 +1,12 @@ -import * as NodeType from './NodeType'; -import { StatementBase } from './shared/Node'; +import type * as NodeType from './NodeType'; +import { onlyIncludeSelf, StatementBase } from './shared/Node'; export default class EmptyStatement extends StatementBase { - type!: NodeType.tEmptyStatement; + declare type: NodeType.tEmptyStatement; hasEffects(): boolean { return false; } } + +EmptyStatement.prototype.includeNode = onlyIncludeSelf; diff --git a/src/ast/nodes/ExportAllDeclaration.ts b/src/ast/nodes/ExportAllDeclaration.ts index cef3b99d172..19b97ec269b 100644 --- a/src/ast/nodes/ExportAllDeclaration.ts +++ b/src/ast/nodes/ExportAllDeclaration.ts @@ -1,27 +1,32 @@ -import MagicString from 'magic-string'; -import { NodeRenderOptions, RenderOptions } from '../../utils/renderHelpers'; -import Identifier from './Identifier'; -import Literal from './Literal'; -import * as NodeType from './NodeType'; -import { NodeBase } from './shared/Node'; +import type MagicString from 'magic-string'; +import type { NodeRenderOptions, RenderOptions } from '../../utils/renderHelpers'; +import type Identifier from './Identifier'; +import type ImportAttribute from './ImportAttribute'; +import type Literal from './Literal'; +import type * as NodeType from './NodeType'; +import { doNotDeoptimize, NodeBase, onlyIncludeSelfNoDeoptimize } from './shared/Node'; export default class ExportAllDeclaration extends NodeBase { - exported!: Identifier | null; - needsBoundaries!: true; - source!: Literal; - type!: NodeType.tExportAllDeclaration; + declare attributes: ImportAttribute[]; + declare exported: Identifier | Literal | null; + declare needsBoundaries: true; + declare source: Literal; + declare type: NodeType.tExportAllDeclaration; - hasEffects() { + hasEffects(): boolean { return false; } - initialise() { - this.context.addExport(this); + initialise(): void { + super.initialise(); + this.scope.context.addExport(this); } - render(code: MagicString, _options: RenderOptions, nodeRenderOptions?: NodeRenderOptions) { + render(code: MagicString, _options: RenderOptions, nodeRenderOptions?: NodeRenderOptions): void { code.remove(nodeRenderOptions!.start!, nodeRenderOptions!.end!); } } ExportAllDeclaration.prototype.needsBoundaries = true; +ExportAllDeclaration.prototype.includeNode = onlyIncludeSelfNoDeoptimize; +ExportAllDeclaration.prototype.applyDeoptimizations = doNotDeoptimize; diff --git a/src/ast/nodes/ExportDefaultDeclaration.ts b/src/ast/nodes/ExportDefaultDeclaration.ts index a2e365848a5..8a9e5f715e8 100644 --- a/src/ast/nodes/ExportDefaultDeclaration.ts +++ b/src/ast/nodes/ExportDefaultDeclaration.ts @@ -1,38 +1,38 @@ -import MagicString from 'magic-string'; +import type MagicString from 'magic-string'; import { findFirstOccurrenceOutsideComment, findNonWhiteSpace, - NodeRenderOptions, - RenderOptions + type NodeRenderOptions, + type RenderOptions } from '../../utils/renderHelpers'; import { getSystemExportStatement } from '../../utils/systemJsRendering'; import { treeshakeNode } from '../../utils/treeshakeNode'; -import { InclusionContext } from '../ExecutionContext'; -import ModuleScope from '../scopes/ModuleScope'; -import ExportDefaultVariable from '../variables/ExportDefaultVariable'; +import type { InclusionContext } from '../ExecutionContext'; +import type ModuleScope from '../scopes/ModuleScope'; +import type { ObjectPath } from '../utils/PathTracker'; +import { UNKNOWN_PATH } from '../utils/PathTracker'; +import type ExportDefaultVariable from '../variables/ExportDefaultVariable'; import ClassDeclaration from './ClassDeclaration'; import FunctionDeclaration from './FunctionDeclaration'; -import Identifier from './Identifier'; +import type Identifier from './Identifier'; import * as NodeType from './NodeType'; -import { ExpressionNode, IncludeChildren, NodeBase } from './shared/Node'; +import { + doNotDeoptimize, + type ExpressionNode, + type IncludeChildren, + NodeBase, + onlyIncludeSelfNoDeoptimize +} from './shared/Node'; // The header ends at the first non-white-space after "default" -function getDeclarationStart(code: string, start: number) { +function getDeclarationStart(code: string, start: number): number { return findNonWhiteSpace(code, findFirstOccurrenceOutsideComment(code, 'default', start) + 7); } -function getIdInsertPosition( - code: string, - declarationKeyword: string, - endMarker: string, - start: number -) { +function getFunctionIdInsertPosition(code: string, start: number): number { const declarationEnd = - findFirstOccurrenceOutsideComment(code, declarationKeyword, start) + declarationKeyword.length; - code = code.slice( - declarationEnd, - findFirstOccurrenceOutsideComment(code, endMarker, declarationEnd) - ); + findFirstOccurrenceOutsideComment(code, 'function', start) + 'function'.length; + code = code.slice(declarationEnd, findFirstOccurrenceOutsideComment(code, '(', declarationEnd)); const generatorStarPos = findFirstOccurrenceOutsideComment(code, '*'); if (generatorStarPos === -1) { return declarationEnd; @@ -41,34 +41,49 @@ function getIdInsertPosition( } export default class ExportDefaultDeclaration extends NodeBase { - declaration!: FunctionDeclaration | ClassDeclaration | ExpressionNode; - needsBoundaries!: true; - scope!: ModuleScope; - type!: NodeType.tExportDefaultDeclaration; - variable!: ExportDefaultVariable; + declare declaration: FunctionDeclaration | ClassDeclaration | ExpressionNode; + declare needsBoundaries: true; + declare scope: ModuleScope; + declare type: NodeType.tExportDefaultDeclaration; + declare variable: ExportDefaultVariable; + + declare private declarationName: string | undefined; - private declarationName: string | undefined; + bind(): void { + super.bind(); + const name = this.declarationName || this.scope.context.getModuleName(); + // Check if there's already a variable with the same name in the scope. This + // can cause inconsistencies when using the cache. + this.variable.name = this.scope.variables.get(name) ? `${name}_default` : name; + } - include(context: InclusionContext, includeChildrenRecursively: IncludeChildren) { - super.include(context, includeChildrenRecursively); + include(context: InclusionContext, includeChildrenRecursively: IncludeChildren): void { + this.included = true; + this.declaration.include(context, includeChildrenRecursively); if (includeChildrenRecursively) { - this.context.includeVariableInModule(this.variable); + this.scope.context.includeVariableInModule(this.variable, UNKNOWN_PATH, context); } } - initialise() { + includePath(path: ObjectPath, context: InclusionContext): void { + this.included = true; + this.declaration.includePath(path, context); + } + + initialise(): void { + super.initialise(); const declaration = this.declaration as FunctionDeclaration | ClassDeclaration; this.declarationName = (declaration.id && declaration.id.name) || (this.declaration as Identifier).name; - this.variable = this.scope.addExportDefaultDeclaration( - this.declarationName || this.context.getModuleName(), - this, - this.context - ); - this.context.addExport(this); + this.variable = this.scope.addExportDefaultDeclaration(this, this.scope.context); + this.scope.context.addExport(this); } - render(code: MagicString, options: RenderOptions, nodeRenderOptions?: NodeRenderOptions) { + removeAnnotations(code: MagicString) { + this.declaration.removeAnnotations(code); + } + + render(code: MagicString, options: RenderOptions, nodeRenderOptions?: NodeRenderOptions): void { const { start, end } = nodeRenderOptions as { end: number; start: number }; const declarationStart = getDeclarationStart(code.original, this.start); @@ -76,18 +91,18 @@ export default class ExportDefaultDeclaration extends NodeBase { this.renderNamedDeclaration( code, declarationStart, - 'function', - '(', - this.declaration.id === null, + this.declaration.id === null + ? getFunctionIdInsertPosition(code.original, declarationStart) + : null, options ); } else if (this.declaration instanceof ClassDeclaration) { this.renderNamedDeclaration( code, declarationStart, - 'class', - '{', - this.declaration.id === null, + this.declaration.id === null + ? findFirstOccurrenceOutsideComment(code.original, 'class', start) + 'class'.length + : null, options ); } else if (this.variable.getOriginalVariable() !== this.variable) { @@ -99,8 +114,7 @@ export default class ExportDefaultDeclaration extends NodeBase { } else { code.remove(this.start, declarationStart); this.declaration.render(code, options, { - isCalleeOfRenderedParent: false, - renderedParentType: NodeType.ExpressionStatement + renderedSurroundingElement: NodeType.ExpressionStatement }); if (code.original[this.end - 1] !== ';') { code.appendLeft(this.end, ';'); @@ -113,25 +127,25 @@ export default class ExportDefaultDeclaration extends NodeBase { private renderNamedDeclaration( code: MagicString, declarationStart: number, - declarationKeyword: string, - endMarker: string, - needsId: boolean, + idInsertPosition: number | null, options: RenderOptions - ) { - const name = this.variable.getName(); + ): void { + const { + exportNamesByVariable, + format, + snippets: { getPropertyAccess } + } = options; + const name = this.variable.getName(getPropertyAccess); // Remove `export default` code.remove(this.start, declarationStart); - if (needsId) { - code.appendLeft( - getIdInsertPosition(code.original, declarationKeyword, endMarker, declarationStart), - ` ${name}` - ); + if (idInsertPosition !== null) { + code.appendLeft(idInsertPosition, ` ${name}`); } if ( - options.format === 'system' && + format === 'system' && this.declaration instanceof ClassDeclaration && - options.exportNamesByVariable.has(this.variable) + exportNamesByVariable.has(this.variable) ) { code.appendLeft(this.end, ` ${getSystemExportStatement([this.variable], options)};`); } @@ -140,17 +154,18 @@ export default class ExportDefaultDeclaration extends NodeBase { private renderVariableDeclaration( code: MagicString, declarationStart: number, - options: RenderOptions - ) { + { format, exportNamesByVariable, snippets: { cnst, getPropertyAccess } }: RenderOptions + ): void { const hasTrailingSemicolon = code.original.charCodeAt(this.end - 1) === 59; /*";"*/ - const systemExportNames = - options.format === 'system' && options.exportNamesByVariable.get(this.variable); + const systemExportNames = format === 'system' && exportNamesByVariable.get(this.variable); if (systemExportNames) { code.overwrite( this.start, declarationStart, - `${options.varOrConst} ${this.variable.getName()} = exports('${systemExportNames[0]}', ` + `${cnst} ${this.variable.getName(getPropertyAccess)} = exports(${JSON.stringify( + systemExportNames[0] + )}, ` ); code.appendRight( hasTrailingSemicolon ? this.end - 1 : this.end, @@ -160,7 +175,7 @@ export default class ExportDefaultDeclaration extends NodeBase { code.overwrite( this.start, declarationStart, - `${options.varOrConst} ${this.variable.getName()} = ` + `${cnst} ${this.variable.getName(getPropertyAccess)} = ` ); if (!hasTrailingSemicolon) { code.appendLeft(this.end, ';'); @@ -170,3 +185,5 @@ export default class ExportDefaultDeclaration extends NodeBase { } ExportDefaultDeclaration.prototype.needsBoundaries = true; +ExportDefaultDeclaration.prototype.includeNode = onlyIncludeSelfNoDeoptimize; +ExportDefaultDeclaration.prototype.applyDeoptimizations = doNotDeoptimize; diff --git a/src/ast/nodes/ExportNamedDeclaration.ts b/src/ast/nodes/ExportNamedDeclaration.ts index 8d4db57f850..fa87d2e348c 100644 --- a/src/ast/nodes/ExportNamedDeclaration.ts +++ b/src/ast/nodes/ExportNamedDeclaration.ts @@ -1,43 +1,63 @@ -import MagicString from 'magic-string'; -import { NodeRenderOptions, RenderOptions } from '../../utils/renderHelpers'; -import { HasEffectsContext } from '../ExecutionContext'; +import type MagicString from 'magic-string'; +import type { NodeRenderOptions, RenderOptions } from '../../utils/renderHelpers'; +import type { HasEffectsContext } from '../ExecutionContext'; import ClassDeclaration from './ClassDeclaration'; -import ExportSpecifier from './ExportSpecifier'; -import FunctionDeclaration from './FunctionDeclaration'; -import Literal from './Literal'; -import * as NodeType from './NodeType'; -import { Node, NodeBase } from './shared/Node'; -import VariableDeclaration from './VariableDeclaration'; +import type ExportSpecifier from './ExportSpecifier'; +import type FunctionDeclaration from './FunctionDeclaration'; +import type ImportAttribute from './ImportAttribute'; +import type Literal from './Literal'; +import type * as NodeType from './NodeType'; +import { doNotDeoptimize, type Node, NodeBase, onlyIncludeSelfNoDeoptimize } from './shared/Node'; +import type VariableDeclaration from './VariableDeclaration'; export default class ExportNamedDeclaration extends NodeBase { - declaration!: FunctionDeclaration | ClassDeclaration | VariableDeclaration | null; - needsBoundaries!: true; - source!: Literal | null; - specifiers!: ExportSpecifier[]; - type!: NodeType.tExportNamedDeclaration; + declare attributes: ImportAttribute[]; + declare declaration: FunctionDeclaration | ClassDeclaration | VariableDeclaration | null; + declare needsBoundaries: true; + declare source: Literal | null; + declare specifiers: readonly ExportSpecifier[]; + declare type: NodeType.tExportNamedDeclaration; - bind() { + bind(): void { // Do not bind specifiers - if (this.declaration !== null) this.declaration.bind(); + this.declaration?.bind(); } - hasEffects(context: HasEffectsContext) { - return this.declaration !== null && this.declaration.hasEffects(context); + hasEffects(context: HasEffectsContext): boolean { + return !!this.declaration?.hasEffects(context); } - initialise() { - this.context.addExport(this); + initialise(): void { + super.initialise(); + this.scope.context.addExport(this); } - render(code: MagicString, options: RenderOptions, nodeRenderOptions?: NodeRenderOptions) { + removeAnnotations(code: MagicString) { + this.declaration?.removeAnnotations(code); + } + + render(code: MagicString, options: RenderOptions, nodeRenderOptions?: NodeRenderOptions): void { const { start, end } = nodeRenderOptions as { end: number; start: number }; if (this.declaration === null) { code.remove(start, end); } else { - code.remove(this.start, this.declaration.start); - (this.declaration as Node).render(code, options, { start, end }); + let endBoundary = this.declaration.start; + // the start of the decorator may be before the start of the class declaration + if (this.declaration instanceof ClassDeclaration) { + const decorators = this.declaration.decorators; + for (const decorator of decorators) { + endBoundary = Math.min(endBoundary, decorator.start); + } + if (endBoundary <= this.start) { + endBoundary = this.declaration.start; + } + } + code.remove(this.start, endBoundary); + (this.declaration as Node).render(code, options, { end, start }); } } } ExportNamedDeclaration.prototype.needsBoundaries = true; +ExportNamedDeclaration.prototype.includeNode = onlyIncludeSelfNoDeoptimize; +ExportNamedDeclaration.prototype.applyDeoptimizations = doNotDeoptimize; diff --git a/src/ast/nodes/ExportSpecifier.ts b/src/ast/nodes/ExportSpecifier.ts index 1772b4da009..7937561329f 100644 --- a/src/ast/nodes/ExportSpecifier.ts +++ b/src/ast/nodes/ExportSpecifier.ts @@ -1,9 +1,13 @@ -import Identifier from './Identifier'; -import * as NodeType from './NodeType'; -import { NodeBase } from './shared/Node'; +import type Identifier from './Identifier'; +import type Literal from './Literal'; +import type * as NodeType from './NodeType'; +import { doNotDeoptimize, NodeBase, onlyIncludeSelfNoDeoptimize } from './shared/Node'; export default class ExportSpecifier extends NodeBase { - exported!: Identifier; - local!: Identifier; - type!: NodeType.tExportSpecifier; + declare exported: Identifier | Literal; + declare local: Identifier | Literal; + declare type: NodeType.tExportSpecifier; } + +ExportSpecifier.prototype.includeNode = onlyIncludeSelfNoDeoptimize; +ExportSpecifier.prototype.applyDeoptimizations = doNotDeoptimize; diff --git a/src/ast/nodes/ExpressionStatement.ts b/src/ast/nodes/ExpressionStatement.ts index 163954231d8..2aecbf6f433 100644 --- a/src/ast/nodes/ExpressionStatement.ts +++ b/src/ast/nodes/ExpressionStatement.ts @@ -1,39 +1,54 @@ -import MagicString from 'magic-string'; -import { RenderOptions } from '../../utils/renderHelpers'; -import { InclusionContext } from '../ExecutionContext'; +import type MagicString from 'magic-string'; +import { LOGLEVEL_WARN } from '../../utils/logging'; +import { logModuleLevelDirective } from '../../utils/logs'; +import type { RenderOptions } from '../../utils/renderHelpers'; +import type { InclusionContext } from '../ExecutionContext'; import * as NodeType from './NodeType'; -import { ExpressionNode, StatementBase } from './shared/Node'; +import { + doNotDeoptimize, + type ExpressionNode, + onlyIncludeSelfNoDeoptimize, + StatementBase +} from './shared/Node'; export default class ExpressionStatement extends StatementBase { - directive?: string; - expression!: ExpressionNode; + declare directive?: string; + declare expression: ExpressionNode; - initialise() { + initialise(): void { + super.initialise(); if ( this.directive && this.directive !== 'use strict' && this.parent.type === NodeType.Program ) { - this.context.warn( + this.scope.context.log( + LOGLEVEL_WARN, // This is necessary, because either way (deleting or not) can lead to errors. - { - code: 'MODULE_LEVEL_DIRECTIVE', - message: `Module level directives cause errors when bundled, '${this.directive}' was ignored.` - }, + logModuleLevelDirective(this.directive, this.scope.context.module.id), this.start ); } } - render(code: MagicString, options: RenderOptions) { + removeAnnotations(code: MagicString) { + this.expression.removeAnnotations(code); + } + + render(code: MagicString, options: RenderOptions): void { super.render(code, options); - if (this.included) this.insertSemicolon(code); + if (code.original[this.end - 1] !== ';') { + code.appendLeft(this.end, ';'); + } } - shouldBeIncluded(context: InclusionContext) { + shouldBeIncluded(context: InclusionContext): boolean { if (this.directive && this.directive !== 'use strict') return this.parent.type !== NodeType.Program; return super.shouldBeIncluded(context); } } + +ExpressionStatement.prototype.includeNode = onlyIncludeSelfNoDeoptimize; +ExpressionStatement.prototype.applyDeoptimizations = doNotDeoptimize; diff --git a/src/ast/nodes/ForInStatement.ts b/src/ast/nodes/ForInStatement.ts index 609f0d022c2..8cd8e453859 100644 --- a/src/ast/nodes/ForInStatement.ts +++ b/src/ast/nodes/ForInStatement.ts @@ -1,63 +1,59 @@ -import MagicString from 'magic-string'; -import { NO_SEMICOLON, RenderOptions } from '../../utils/renderHelpers'; -import { HasEffectsContext, InclusionContext } from '../ExecutionContext'; +import type MagicString from 'magic-string'; +import { NO_SEMICOLON, type RenderOptions } from '../../utils/renderHelpers'; +import type { HasEffectsContext, InclusionContext } from '../ExecutionContext'; import BlockScope from '../scopes/BlockScope'; -import Scope from '../scopes/Scope'; -import { EMPTY_PATH } from '../utils/PathTracker'; -import * as NodeType from './NodeType'; -import { ExpressionNode, IncludeChildren, StatementBase, StatementNode } from './shared/Node'; -import { PatternNode } from './shared/Pattern'; -import VariableDeclaration from './VariableDeclaration'; +import type ChildScope from '../scopes/ChildScope'; +import { EMPTY_PATH, UNKNOWN_PATH } from '../utils/PathTracker'; +import type * as NodeType from './NodeType'; +import { UNKNOWN_EXPRESSION } from './shared/Expression'; +import { hasLoopBodyEffects, includeLoopBody } from './shared/loops'; +import { + type ExpressionNode, + type IncludeChildren, + StatementBase, + type StatementNode +} from './shared/Node'; +import type { PatternNode } from './shared/Pattern'; +import type VariableDeclaration from './VariableDeclaration'; export default class ForInStatement extends StatementBase { - body!: StatementNode; - left!: VariableDeclaration | PatternNode; - right!: ExpressionNode; - type!: NodeType.tForInStatement; + declare body: StatementNode; + declare left: VariableDeclaration | PatternNode; + declare right: ExpressionNode; + declare type: NodeType.tForInStatement; - bind() { - this.left.bind(); - this.left.deoptimizePath(EMPTY_PATH); - this.right.bind(); - this.body.bind(); - } - - createScope(parentScope: Scope) { + createScope(parentScope: ChildScope): void { this.scope = new BlockScope(parentScope); } hasEffects(context: HasEffectsContext): boolean { - if ( - (this.left && - (this.left.hasEffects(context) || - this.left.hasEffectsWhenAssignedAtPath(EMPTY_PATH, context))) || - (this.right && this.right.hasEffects(context)) - ) - return true; - const { - brokenFlow, - ignore: { breaks, continues } - } = context; - context.ignore.breaks = true; - context.ignore.continues = true; - if (this.body.hasEffects(context)) return true; - context.ignore.breaks = breaks; - context.ignore.continues = continues; - context.brokenFlow = brokenFlow; - return false; + const { body, deoptimized, left, right } = this; + if (!deoptimized) this.applyDeoptimizations(); + if (left.hasEffectsAsAssignmentTarget(context, false) || right.hasEffects(context)) return true; + return hasLoopBodyEffects(context, body); } - include(context: InclusionContext, includeChildrenRecursively: IncludeChildren) { + include(context: InclusionContext, includeChildrenRecursively: IncludeChildren): void { + const { body, deoptimized, left, right } = this; + if (!deoptimized) this.applyDeoptimizations(); + if (!this.included) this.includeNode(context); + left.includeAsAssignmentTarget(context, includeChildrenRecursively || true, false); + right.include(context, includeChildrenRecursively); + includeLoopBody(context, body, includeChildrenRecursively); + } + + includeNode(context: InclusionContext) { this.included = true; - this.left.include(context, includeChildrenRecursively || true); - this.left.deoptimizePath(EMPTY_PATH); - this.right.include(context, includeChildrenRecursively); - const { brokenFlow } = context; - this.body.includeAsSingleStatement(context, includeChildrenRecursively); - context.brokenFlow = brokenFlow; + if (!this.deoptimized) this.applyDeoptimizations(); + this.right.includePath(UNKNOWN_PATH, context); } - render(code: MagicString, options: RenderOptions) { + initialise() { + super.initialise(); + this.left.setAssignedValue(UNKNOWN_EXPRESSION); + } + + render(code: MagicString, options: RenderOptions): void { this.left.render(code, options, NO_SEMICOLON); this.right.render(code, options, NO_SEMICOLON); // handle no space between "in" and the right side @@ -66,4 +62,10 @@ export default class ForInStatement extends StatementBase { } this.body.render(code, options); } + + applyDeoptimizations() { + this.deoptimized = true; + this.left.deoptimizePath(EMPTY_PATH); + this.scope.context.requestTreeshakingPass(); + } } diff --git a/src/ast/nodes/ForOfStatement.ts b/src/ast/nodes/ForOfStatement.ts index 65527662fc0..100f3742add 100644 --- a/src/ast/nodes/ForOfStatement.ts +++ b/src/ast/nodes/ForOfStatement.ts @@ -1,48 +1,66 @@ -import MagicString from 'magic-string'; -import { NO_SEMICOLON, RenderOptions } from '../../utils/renderHelpers'; -import { InclusionContext } from '../ExecutionContext'; +import type MagicString from 'magic-string'; +import { NO_SEMICOLON, type RenderOptions } from '../../utils/renderHelpers'; +import type { InclusionContext } from '../ExecutionContext'; import BlockScope from '../scopes/BlockScope'; -import Scope from '../scopes/Scope'; -import { EMPTY_PATH } from '../utils/PathTracker'; -import * as NodeType from './NodeType'; -import { ExpressionNode, IncludeChildren, StatementBase, StatementNode } from './shared/Node'; -import { PatternNode } from './shared/Pattern'; -import VariableDeclaration from './VariableDeclaration'; +import type ChildScope from '../scopes/ChildScope'; +import { EMPTY_PATH, UNKNOWN_PATH } from '../utils/PathTracker'; +import type * as NodeType from './NodeType'; +import { Flag, isFlagSet, setFlag } from './shared/BitFlags'; +import { UNKNOWN_EXPRESSION } from './shared/Expression'; +import { includeLoopBody } from './shared/loops'; +import { + type ExpressionNode, + type IncludeChildren, + StatementBase, + type StatementNode +} from './shared/Node'; +import type { PatternNode } from './shared/Pattern'; +import type VariableDeclaration from './VariableDeclaration'; export default class ForOfStatement extends StatementBase { - await!: boolean; - body!: StatementNode; - left!: VariableDeclaration | PatternNode; - right!: ExpressionNode; - type!: NodeType.tForOfStatement; - - bind() { - this.left.bind(); - this.left.deoptimizePath(EMPTY_PATH); - this.right.bind(); - this.body.bind(); + declare body: StatementNode; + declare left: VariableDeclaration | PatternNode; + declare right: ExpressionNode; + declare type: NodeType.tForOfStatement; + + get await(): boolean { + return isFlagSet(this.flags, Flag.await); + } + set await(value: boolean) { + this.flags = setFlag(this.flags, Flag.await, value); } - createScope(parentScope: Scope) { + createScope(parentScope: ChildScope): void { this.scope = new BlockScope(parentScope); } hasEffects(): boolean { + if (!this.deoptimized) this.applyDeoptimizations(); // Placeholder until proper Symbol.Iterator support return true; } - include(context: InclusionContext, includeChildrenRecursively: IncludeChildren) { + include(context: InclusionContext, includeChildrenRecursively: IncludeChildren): void { + const { body, deoptimized, left, right } = this; + if (!deoptimized) this.applyDeoptimizations(); + if (!this.included) this.includeNode(context); + left.includeAsAssignmentTarget(context, includeChildrenRecursively || true, false); + right.include(context, includeChildrenRecursively); + includeLoopBody(context, body, includeChildrenRecursively); + } + + includeNode(context: InclusionContext) { this.included = true; - this.left.include(context, includeChildrenRecursively || true); - this.left.deoptimizePath(EMPTY_PATH); - this.right.include(context, includeChildrenRecursively); - const { brokenFlow } = context; - this.body.includeAsSingleStatement(context, includeChildrenRecursively); - context.brokenFlow = brokenFlow; + if (!this.deoptimized) this.applyDeoptimizations(); + this.right.includePath(UNKNOWN_PATH, context); } - render(code: MagicString, options: RenderOptions) { + initialise() { + super.initialise(); + this.left.setAssignedValue(UNKNOWN_EXPRESSION); + } + + render(code: MagicString, options: RenderOptions): void { this.left.render(code, options, NO_SEMICOLON); this.right.render(code, options, NO_SEMICOLON); // handle no space between "of" and the right side @@ -51,4 +69,11 @@ export default class ForOfStatement extends StatementBase { } this.body.render(code, options); } + + applyDeoptimizations() { + this.deoptimized = true; + this.left.deoptimizePath(EMPTY_PATH); + this.right.deoptimizePath(UNKNOWN_PATH); + this.scope.context.requestTreeshakingPass(); + } } diff --git a/src/ast/nodes/ForStatement.ts b/src/ast/nodes/ForStatement.ts index 0ef166ee424..748ec5a602a 100644 --- a/src/ast/nodes/ForStatement.ts +++ b/src/ast/nodes/ForStatement.ts @@ -1,57 +1,59 @@ -import MagicString from 'magic-string'; -import { NO_SEMICOLON, RenderOptions } from '../../utils/renderHelpers'; -import { HasEffectsContext, InclusionContext } from '../ExecutionContext'; +import type MagicString from 'magic-string'; +import { NO_SEMICOLON, type RenderOptions } from '../../utils/renderHelpers'; +import type { HasEffectsContext, InclusionContext } from '../ExecutionContext'; import BlockScope from '../scopes/BlockScope'; -import Scope from '../scopes/Scope'; -import * as NodeType from './NodeType'; -import { ExpressionNode, IncludeChildren, StatementBase, StatementNode } from './shared/Node'; -import VariableDeclaration from './VariableDeclaration'; +import type ChildScope from '../scopes/ChildScope'; +import type * as NodeType from './NodeType'; +import { hasLoopBodyEffects, includeLoopBody } from './shared/loops'; +import { + doNotDeoptimize, + type ExpressionNode, + type IncludeChildren, + onlyIncludeSelfNoDeoptimize, + StatementBase, + type StatementNode +} from './shared/Node'; +import type VariableDeclaration from './VariableDeclaration'; export default class ForStatement extends StatementBase { - body!: StatementNode; - init!: VariableDeclaration | ExpressionNode | null; - test!: ExpressionNode | null; - type!: NodeType.tForStatement; - update!: ExpressionNode | null; + declare body: StatementNode; + declare init: VariableDeclaration | ExpressionNode | null; + declare test: ExpressionNode | null; + declare type: NodeType.tForStatement; + declare update: ExpressionNode | null; - createScope(parentScope: Scope) { + createScope(parentScope: ChildScope): void { this.scope = new BlockScope(parentScope); } hasEffects(context: HasEffectsContext): boolean { if ( - (this.init && this.init.hasEffects(context)) || - (this.test && this.test.hasEffects(context)) || - (this.update && this.update.hasEffects(context)) - ) + this.init?.hasEffects(context) || + this.test?.hasEffects(context) || + this.update?.hasEffects(context) + ) { return true; - const { - brokenFlow, - ignore: { breaks, continues } - } = context; - context.ignore.breaks = true; - context.ignore.continues = true; - if (this.body.hasEffects(context)) return true; - context.ignore.breaks = breaks; - context.ignore.continues = continues; - context.brokenFlow = brokenFlow; - return false; + } + return hasLoopBodyEffects(context, this.body); } - include(context: InclusionContext, includeChildrenRecursively: IncludeChildren) { + include(context: InclusionContext, includeChildrenRecursively: IncludeChildren): void { this.included = true; - if (this.init) this.init.includeAsSingleStatement(context, includeChildrenRecursively); - if (this.test) this.test.include(context, includeChildrenRecursively); - const { brokenFlow } = context; - if (this.update) this.update.include(context, includeChildrenRecursively); - this.body.includeAsSingleStatement(context, includeChildrenRecursively); - context.brokenFlow = brokenFlow; + this.init?.include(context, includeChildrenRecursively, { + asSingleStatement: true + }); + this.test?.include(context, includeChildrenRecursively); + this.update?.include(context, includeChildrenRecursively); + includeLoopBody(context, this.body, includeChildrenRecursively); } - render(code: MagicString, options: RenderOptions) { - if (this.init) this.init.render(code, options, NO_SEMICOLON); - if (this.test) this.test.render(code, options, NO_SEMICOLON); - if (this.update) this.update.render(code, options, NO_SEMICOLON); + render(code: MagicString, options: RenderOptions): void { + this.init?.render(code, options, NO_SEMICOLON); + this.test?.render(code, options, NO_SEMICOLON); + this.update?.render(code, options, NO_SEMICOLON); this.body.render(code, options); } } + +ForStatement.prototype.includeNode = onlyIncludeSelfNoDeoptimize; +ForStatement.prototype.applyDeoptimizations = doNotDeoptimize; diff --git a/src/ast/nodes/FunctionDeclaration.ts b/src/ast/nodes/FunctionDeclaration.ts index a02561dc7c7..9cfa8b21bd5 100644 --- a/src/ast/nodes/FunctionDeclaration.ts +++ b/src/ast/nodes/FunctionDeclaration.ts @@ -1,24 +1,30 @@ -import ChildScope from '../scopes/ChildScope'; -import { IdentifierWithVariable } from './Identifier'; -import * as NodeType from './NodeType'; +import type ChildScope from '../scopes/ChildScope'; +import Identifier, { type IdentifierWithVariable } from './Identifier'; +import type * as NodeType from './NodeType'; import FunctionNode from './shared/FunctionNode'; -import { GenericEsTreeNode } from './shared/Node'; +import type { GenericEsTreeNode } from './shared/Node'; export default class FunctionDeclaration extends FunctionNode { - type!: NodeType.tFunctionDeclaration; + declare type: NodeType.tFunctionDeclaration; - initialise() { + initialise(): void { super.initialise(); if (this.id !== null) { this.id.variable.isId = true; } } - parseNode(esTreeNode: GenericEsTreeNode) { + protected onlyFunctionCallUsed(): boolean { + // call super.onlyFunctionCallUsed for export default anonymous function + return this.id?.variable.getOnlyFunctionCallUsed() ?? super.onlyFunctionCallUsed(); + } + + parseNode(esTreeNode: GenericEsTreeNode): this { if (esTreeNode.id !== null) { - this.id = new this.context.nodeConstructors.Identifier(esTreeNode.id, this, this.scope - .parent as ChildScope) as IdentifierWithVariable; + this.id = new Identifier(this, this.scope.parent as ChildScope).parseNode( + esTreeNode.id + ) as IdentifierWithVariable; } - super.parseNode(esTreeNode); + return super.parseNode(esTreeNode); } } diff --git a/src/ast/nodes/FunctionExpression.ts b/src/ast/nodes/FunctionExpression.ts index 77e44b70111..85b2b5cb45f 100644 --- a/src/ast/nodes/FunctionExpression.ts +++ b/src/ast/nodes/FunctionExpression.ts @@ -1,20 +1,46 @@ -import MagicString from 'magic-string'; +import type MagicString from 'magic-string'; import { BLANK } from '../../utils/blank'; -import { NodeRenderOptions, RenderOptions } from '../../utils/renderHelpers'; +import type { NodeRenderOptions, RenderOptions } from '../../utils/renderHelpers'; +import ChildScope from '../scopes/ChildScope'; +import type CallExpression from './CallExpression'; +import type { IdentifierWithVariable } from './Identifier'; +import Identifier from './Identifier'; import * as NodeType from './NodeType'; import FunctionNode from './shared/FunctionNode'; +import type { GenericEsTreeNode } from './shared/Node'; export default class FunctionExpression extends FunctionNode { - type!: NodeType.tFunctionExpression; + declare type: NodeType.tFunctionExpression; + declare idScope: ChildScope; + + createScope(parentScope: ChildScope) { + super.createScope((this.idScope = new ChildScope(parentScope, parentScope.context))); + } + + parseNode(esTreeNode: GenericEsTreeNode): this { + if (esTreeNode.id !== null) { + this.id = new Identifier(this, this.idScope).parseNode( + esTreeNode.id + ) as IdentifierWithVariable; + } + return super.parseNode(esTreeNode); + } + + protected onlyFunctionCallUsed(): boolean { + const isIIFE = + this.parent.type === NodeType.CallExpression && + (this.parent as CallExpression).callee === this && + (this.id === null || this.id.variable.getOnlyFunctionCallUsed()); + return isIIFE || super.onlyFunctionCallUsed(); + } render( code: MagicString, options: RenderOptions, - { renderedParentType, renderedSurroundingElement }: NodeRenderOptions = BLANK - ) { + { renderedSurroundingElement }: NodeRenderOptions = BLANK + ): void { super.render(code, options); - const surroundingElement = renderedParentType || renderedSurroundingElement; - if (surroundingElement === NodeType.ExpressionStatement) { + if (renderedSurroundingElement === NodeType.ExpressionStatement) { code.appendRight(this.start, '('); code.prependLeft(this.end, ')'); } diff --git a/src/ast/nodes/Identifier.ts b/src/ast/nodes/Identifier.ts index 0c1394198ef..e8f8794bcae 100644 --- a/src/ast/nodes/Identifier.ts +++ b/src/ast/nodes/Identifier.ts @@ -1,159 +1,155 @@ -import isReference from 'is-reference'; -import MagicString from 'magic-string'; -import { NormalizedTreeshakingOptions } from '../../rollup/types'; +import isReference, { type NodeWithFieldDefinition } from 'is-reference'; +import type MagicString from 'magic-string'; +import '../../../typings/declarations'; +import type { NormalizedTreeshakingOptions } from '../../rollup/types'; import { BLANK } from '../../utils/blank'; -import { NodeRenderOptions, RenderOptions } from '../../utils/renderHelpers'; -import { CallOptions } from '../CallOptions'; -import { DeoptimizableEntity } from '../DeoptimizableEntity'; -import { HasEffectsContext, InclusionContext } from '../ExecutionContext'; -import FunctionScope from '../scopes/FunctionScope'; -import { EMPTY_PATH, ObjectPath, PathTracker } from '../utils/PathTracker'; -import { LiteralValueOrUnknown } from '../values'; -import GlobalVariable from '../variables/GlobalVariable'; -import LocalVariable from '../variables/LocalVariable'; -import Variable from '../variables/Variable'; +import type { NodeRenderOptions, RenderOptions } from '../../utils/renderHelpers'; +import type { HasEffectsContext, InclusionContext } from '../ExecutionContext'; +import { createHasEffectsContext } from '../ExecutionContext'; +import { INTERACTION_ACCESSED, NODE_INTERACTION_UNKNOWN_ACCESS } from '../NodeInteractions'; +import type FunctionScope from '../scopes/FunctionScope'; +import type { ObjectPath } from '../utils/PathTracker'; +import { EMPTY_PATH, SHARED_RECURSION_TRACKER, UnknownKey } from '../utils/PathTracker'; +import type LocalVariable from '../variables/LocalVariable'; +import type Variable from '../variables/Variable'; import * as NodeType from './NodeType'; -import { ExpressionEntity } from './shared/Expression'; -import { ExpressionNode, NodeBase } from './shared/Node'; -import { PatternNode } from './shared/Pattern'; -import SpreadElement from './SpreadElement'; +import { Flag, isFlagSet, setFlag } from './shared/BitFlags'; +import { type ExpressionEntity } from './shared/Expression'; +import IdentifierBase from './shared/IdentifierBase'; +import { ObjectMember } from './shared/ObjectMember'; +import type { DeclarationPatternNode } from './shared/Pattern'; +import type { VariableKind } from './shared/VariableKinds'; export type IdentifierWithVariable = Identifier & { variable: Variable }; -export default class Identifier extends NodeBase implements PatternNode { +export default class Identifier extends IdentifierBase implements DeclarationPatternNode { name!: string; type!: NodeType.tIdentifier; - variable: Variable | null = null; - private bound = false; + + private get isDestructuringDeoptimized(): boolean { + return isFlagSet(this.flags, Flag.destructuringDeoptimized); + } + + private set isDestructuringDeoptimized(value: boolean) { + this.flags = setFlag(this.flags, Flag.destructuringDeoptimized, value); + } addExportedVariables( variables: Variable[], - exportNamesByVariable: Map + exportNamesByVariable: ReadonlyMap ): void { - if (this.variable !== null && exportNamesByVariable.has(this.variable)) { - variables.push(this.variable); + if (exportNamesByVariable.has(this.variable!)) { + variables.push(this.variable!); } } - bind() { - if (this.bound) return; - this.bound = true; - if (this.variable === null && isReference(this, this.parent as any)) { + bind(): void { + if (!this.variable && isReference(this, this.parent as NodeWithFieldDefinition)) { this.variable = this.scope.findVariable(this.name); this.variable.addReference(this); - } - if ( - this.variable !== null && - this.variable instanceof LocalVariable && - this.variable.additionalInitializers !== null - ) { - this.variable.consolidateInitializers(); + this.isVariableReference = true; } } - declare(kind: string, init: ExpressionEntity) { + declare( + kind: VariableKind, + destructuredInitPath: ObjectPath, + init: ExpressionEntity + ): LocalVariable[] { let variable: LocalVariable; - switch (kind) { - case 'var': - variable = this.scope.addDeclaration(this, this.context, init, true); - break; - case 'function': - // in strict mode, functions are only hoisted within a scope but not across block scopes - variable = this.scope.addDeclaration(this, this.context, init, false); - break; - case 'let': - case 'const': - case 'class': - variable = this.scope.addDeclaration(this, this.context, init, false); - break; - case 'parameter': - variable = (this.scope as FunctionScope).addParameterDeclaration(this); - break; - /* istanbul ignore next */ - default: - /* istanbul ignore next */ - throw new Error(`Internal Error: Unexpected identifier kind ${kind}.`); + const { treeshake } = this.scope.context.options; + if (kind === 'parameter') { + variable = (this.scope as FunctionScope).addParameterDeclaration(this, destructuredInitPath); + } else { + variable = this.scope.addDeclaration( + this, + this.scope.context, + init, + destructuredInitPath, + kind + ); + if (kind === 'var' && treeshake && treeshake.correctVarValueBeforeDeclaration) { + // Necessary to make sure the init is deoptimized. We cannot call deoptimizePath here. + variable.markInitializersForDeoptimization(); + } } return [(this.variable = variable)]; } - deoptimizePath(path: ObjectPath) { - if (!this.bound) this.bind(); - if (path.length === 0 && !this.scope.contains(this.name)) { - this.disallowImportReassignment(); - } - this.variable!.deoptimizePath(path); - } - - getLiteralValueAtPath( - path: ObjectPath, - recursionTracker: PathTracker, - origin: DeoptimizableEntity - ): LiteralValueOrUnknown { - if (!this.bound) this.bind(); - return this.variable!.getLiteralValueAtPath(path, recursionTracker, origin); + deoptimizeAssignment(destructuredInitPath: ObjectPath, init: ExpressionEntity) { + this.deoptimizePath(EMPTY_PATH); + init.deoptimizePath([...destructuredInitPath, UnknownKey]); } - getReturnExpressionWhenCalledAtPath( - path: ObjectPath, - recursionTracker: PathTracker, - origin: DeoptimizableEntity - ) { - if (!this.bound) this.bind(); - return this.variable!.getReturnExpressionWhenCalledAtPath(path, recursionTracker, origin); - } - - hasEffects(): boolean { + hasEffectsWhenDestructuring( + context: HasEffectsContext, + destructuredInitPath: ObjectPath, + init: ExpressionEntity + ): boolean { return ( - (this.context.options.treeshake as NormalizedTreeshakingOptions).unknownGlobalSideEffects && - this.variable instanceof GlobalVariable && - this.variable.hasEffectsWhenAccessedAtPath(EMPTY_PATH) + destructuredInitPath.length > 0 && + init.hasEffectsOnInteractionAtPath( + destructuredInitPath, + NODE_INTERACTION_UNKNOWN_ACCESS, + context + ) ); } - hasEffectsWhenAccessedAtPath(path: ObjectPath, context: HasEffectsContext): boolean { - return this.variable !== null && this.variable.hasEffectsWhenAccessedAtPath(path, context); - } - - hasEffectsWhenAssignedAtPath(path: ObjectPath, context: HasEffectsContext): boolean { - return !this.variable || this.variable.hasEffectsWhenAssignedAtPath(path, context); - } - - hasEffectsWhenCalledAtPath( - path: ObjectPath, - callOptions: CallOptions, - context: HasEffectsContext - ) { - return !this.variable || this.variable.hasEffectsWhenCalledAtPath(path, callOptions, context); - } - - include() { - if (!this.included) { - this.included = true; - if (this.variable !== null) { - this.context.includeVariableInModule(this.variable); + includeDestructuredIfNecessary( + context: InclusionContext, + destructuredInitPath: ObjectPath, + init: ExpressionEntity + ): boolean { + if (destructuredInitPath.length > 0 && !this.isDestructuringDeoptimized) { + this.isDestructuringDeoptimized = true; + init.deoptimizeArgumentsOnInteractionAtPath( + { + args: [new ObjectMember(init, destructuredInitPath.slice(0, -1))], + type: INTERACTION_ACCESSED + }, + destructuredInitPath, + SHARED_RECURSION_TRACKER + ); + } + const { propertyReadSideEffects } = this.scope.context.options + .treeshake as NormalizedTreeshakingOptions; + let included = this.included; + if ( + (included ||= + destructuredInitPath.length > 0 && + !context.brokenFlow && + propertyReadSideEffects && + (propertyReadSideEffects === 'always' || + init.hasEffectsOnInteractionAtPath( + destructuredInitPath, + NODE_INTERACTION_UNKNOWN_ACCESS, + createHasEffectsContext() + ))) + ) { + if (this.variable && !this.variable.included) { + this.scope.context.includeVariableInModule(this.variable, EMPTY_PATH, context); } + init.includePath(destructuredInitPath, context); } + if (!this.included && included) { + this.includeNode(context); + } + return this.included; } - includeCallArguments(context: InclusionContext, args: (ExpressionNode | SpreadElement)[]): void { - this.variable!.includeCallArguments(context, args); - } - - mayModifyThisWhenCalledAtPath(path: ObjectPath, recursionTracker: PathTracker) { - return this.variable - ? this.variable.mayModifyThisWhenCalledAtPath(path, recursionTracker) - : true; + markDeclarationReached(): void { + this.variable!.initReached = true; } render( code: MagicString, - _options: RenderOptions, + { snippets: { getPropertyAccess }, useOriginalName }: RenderOptions, { renderedParentType, isCalleeOfRenderedParent, isShorthandProperty }: NodeRenderOptions = BLANK - ) { + ): void { if (this.variable) { - const name = this.variable.getName(); + const name = this.variable.getName(getPropertyAccess, useOriginalName); if (name !== this.name) { code.overwrite(this.start, this.end, name, { @@ -174,14 +170,4 @@ export default class Identifier extends NodeBase implements PatternNode { } } } - - private disallowImportReassignment() { - return this.context.error( - { - code: 'ILLEGAL_REASSIGNMENT', - message: `Illegal reassignment to import '${this.name}'` - }, - this.start - ); - } } diff --git a/src/ast/nodes/IfStatement.ts b/src/ast/nodes/IfStatement.ts index 23667804428..931d0d37261 100644 --- a/src/ast/nodes/IfStatement.ts +++ b/src/ast/nodes/IfStatement.ts @@ -1,35 +1,37 @@ -import MagicString from 'magic-string'; -import { RenderOptions } from '../../utils/renderHelpers'; -import { removeAnnotations } from '../../utils/treeshakeNode'; -import { DeoptimizableEntity } from '../DeoptimizableEntity'; -import { BROKEN_FLOW_NONE, HasEffectsContext, InclusionContext } from '../ExecutionContext'; +import type MagicString from 'magic-string'; +import type { RenderOptions } from '../../utils/renderHelpers'; +import type { DeoptimizableEntity } from '../DeoptimizableEntity'; +import { type HasEffectsContext, type InclusionContext } from '../ExecutionContext'; import TrackingScope from '../scopes/TrackingScope'; import { EMPTY_PATH, SHARED_RECURSION_TRACKER } from '../utils/PathTracker'; -import { LiteralValueOrUnknown, UnknownValue } from '../values'; +import { tryCastLiteralValueToBoolean } from '../utils/tryCastLiteralValueToBoolean'; import BlockStatement from './BlockStatement'; -import Identifier from './Identifier'; +import type Identifier from './Identifier'; import * as NodeType from './NodeType'; +import { type LiteralValueOrUnknown, UnknownValue } from './shared/Expression'; import { - ExpressionNode, - GenericEsTreeNode, - IncludeChildren, + doNotDeoptimize, + type ExpressionNode, + type GenericEsTreeNode, + type IncludeChildren, + onlyIncludeSelfNoDeoptimize, StatementBase, - StatementNode + type StatementNode } from './shared/Node'; const unset = Symbol('unset'); export default class IfStatement extends StatementBase implements DeoptimizableEntity { - alternate!: StatementNode | null; - consequent!: StatementNode; - test!: ExpressionNode; - type!: NodeType.tIfStatement; + declare alternate: StatementNode | null; + declare consequent: StatementNode; + declare test: ExpressionNode; + declare type: NodeType.tIfStatement; - private alternateScope?: TrackingScope; - private consequentScope!: TrackingScope; + declare alternateScope?: TrackingScope; + declare consequentScope: TrackingScope; private testValue: LiteralValueOrUnknown | typeof unset = unset; - deoptimizeCache() { + deoptimizeCache(): void { this.testValue = UnknownValue; } @@ -38,29 +40,26 @@ export default class IfStatement extends StatementBase implements DeoptimizableE return true; } const testValue = this.getTestValue(); - if (testValue === UnknownValue) { + if (typeof testValue === 'symbol') { const { brokenFlow } = context; if (this.consequent.hasEffects(context)) return true; const consequentBrokenFlow = context.brokenFlow; context.brokenFlow = brokenFlow; if (this.alternate === null) return false; if (this.alternate.hasEffects(context)) return true; - context.brokenFlow = - context.brokenFlow < consequentBrokenFlow ? context.brokenFlow : consequentBrokenFlow; + context.brokenFlow = context.brokenFlow && consequentBrokenFlow; return false; } - return testValue - ? this.consequent.hasEffects(context) - : this.alternate !== null && this.alternate.hasEffects(context); + return testValue ? this.consequent.hasEffects(context) : !!this.alternate?.hasEffects(context); } - include(context: InclusionContext, includeChildrenRecursively: IncludeChildren) { + include(context: InclusionContext, includeChildrenRecursively: IncludeChildren): void { this.included = true; if (includeChildrenRecursively) { this.includeRecursively(includeChildrenRecursively, context); } else { const testValue = this.getTestValue(); - if (testValue === UnknownValue) { + if (typeof testValue === 'symbol') { this.includeUnknownTest(context); } else { this.includeKnownTest(context, testValue); @@ -68,38 +67,42 @@ export default class IfStatement extends StatementBase implements DeoptimizableE } } - parseNode(esTreeNode: GenericEsTreeNode) { - this.consequentScope = new TrackingScope(this.scope); - this.consequent = new (this.context.nodeConstructors[esTreeNode.consequent.type] || - this.context.nodeConstructors.UnknownNode)(esTreeNode.consequent, this, this.consequentScope); + parseNode(esTreeNode: GenericEsTreeNode): this { + this.consequent = new (this.scope.context.getNodeConstructor(esTreeNode.consequent.type))( + this, + (this.consequentScope = new TrackingScope(this.scope)) + ).parseNode(esTreeNode.consequent); if (esTreeNode.alternate) { - this.alternateScope = new TrackingScope(this.scope); - this.alternate = new (this.context.nodeConstructors[esTreeNode.alternate.type] || - this.context.nodeConstructors.UnknownNode)(esTreeNode.alternate, this, this.alternateScope); + this.alternate = new (this.scope.context.getNodeConstructor(esTreeNode.alternate.type))( + this, + (this.alternateScope = new TrackingScope(this.scope)) + ).parseNode(esTreeNode.alternate); } - super.parseNode(esTreeNode); + return super.parseNode(esTreeNode); } - render(code: MagicString, options: RenderOptions) { + render(code: MagicString, options: RenderOptions): void { + const { + snippets: { getPropertyAccess } + } = options; // Note that unknown test values are always included const testValue = this.getTestValue(); const hoistedDeclarations: Identifier[] = []; const includesIfElse = this.test.included; - const noTreeshake = !this.context.options.treeshake; + const noTreeshake = !this.scope.context.options.treeshake; if (includesIfElse) { this.test.render(code, options); } else { - removeAnnotations(this, code); code.remove(this.start, this.consequent.start); } - if (this.consequent.included && (noTreeshake || testValue === UnknownValue || testValue)) { + if (this.consequent.included && (noTreeshake || typeof testValue === 'symbol' || testValue)) { this.consequent.render(code, options); } else { code.overwrite(this.consequent.start, this.consequent.end, includesIfElse ? ';' : ''); hoistedDeclarations.push(...this.consequentScope.hoistedDeclarations); } if (this.alternate) { - if (this.alternate.included && (noTreeshake || testValue === UnknownValue || !testValue)) { + if (this.alternate.included && (noTreeshake || typeof testValue === 'symbol' || !testValue)) { if (includesIfElse) { if (code.original.charCodeAt(this.alternate.start - 1) === 101) { code.prependLeft(this.alternate.start, ' '); @@ -117,15 +120,13 @@ export default class IfStatement extends StatementBase implements DeoptimizableE hoistedDeclarations.push(...this.alternateScope!.hoistedDeclarations); } } - this.renderHoistedDeclarations(hoistedDeclarations, code); + this.renderHoistedDeclarations(hoistedDeclarations, code, getPropertyAccess); } private getTestValue(): LiteralValueOrUnknown { if (this.testValue === unset) { - return (this.testValue = this.test.getLiteralValueAtPath( - EMPTY_PATH, - SHARED_RECURSION_TRACKER, - this + return (this.testValue = tryCastLiteralValueToBoolean( + this.test.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, this) )); } return this.testValue; @@ -136,10 +137,10 @@ export default class IfStatement extends StatementBase implements DeoptimizableE this.test.include(context, false); } if (testValue && this.consequent.shouldBeIncluded(context)) { - this.consequent.includeAsSingleStatement(context, false); + this.consequent.include(context, false, { asSingleStatement: true }); } - if (this.alternate !== null && !testValue && this.alternate.shouldBeIncluded(context)) { - this.alternate.includeAsSingleStatement(context, false); + if (!testValue && this.alternate?.shouldBeIncluded(context)) { + this.alternate.include(context, false, { asSingleStatement: true }); } } @@ -149,42 +150,43 @@ export default class IfStatement extends StatementBase implements DeoptimizableE ) { this.test.include(context, includeChildrenRecursively); this.consequent.include(context, includeChildrenRecursively); - if (this.alternate !== null) { - this.alternate.include(context, includeChildrenRecursively); - } + this.alternate?.include(context, includeChildrenRecursively); } private includeUnknownTest(context: InclusionContext) { this.test.include(context, false); const { brokenFlow } = context; - let consequentBrokenFlow = BROKEN_FLOW_NONE; + let consequentBrokenFlow = false; if (this.consequent.shouldBeIncluded(context)) { - this.consequent.includeAsSingleStatement(context, false); + this.consequent.include(context, false, { asSingleStatement: true }); consequentBrokenFlow = context.brokenFlow; context.brokenFlow = brokenFlow; } - if (this.alternate !== null && this.alternate.shouldBeIncluded(context)) { - this.alternate.includeAsSingleStatement(context, false); - context.brokenFlow = - context.brokenFlow < consequentBrokenFlow ? context.brokenFlow : consequentBrokenFlow; + if (this.alternate?.shouldBeIncluded(context)) { + this.alternate.include(context, false, { asSingleStatement: true }); + context.brokenFlow = context.brokenFlow && consequentBrokenFlow; } } - private renderHoistedDeclarations(hoistedDeclarations: Identifier[], code: MagicString) { - const hoistedVars = [ + private renderHoistedDeclarations( + hoistedDeclarations: readonly Identifier[], + code: MagicString, + getPropertyAccess: (name: string) => string + ) { + const hoistedVariables = [ ...new Set( hoistedDeclarations.map(identifier => { const variable = identifier.variable!; - return variable.included ? variable.getName() : ''; + return variable.included ? variable.getName(getPropertyAccess) : ''; }) ) ] .filter(Boolean) .join(', '); - if (hoistedVars) { + if (hoistedVariables) { const parentType = this.parent.type; const needsBraces = parentType !== NodeType.Program && parentType !== NodeType.BlockStatement; - code.prependRight(this.start, `${needsBraces ? '{ ' : ''}var ${hoistedVars}; `); + code.prependRight(this.start, `${needsBraces ? '{ ' : ''}var ${hoistedVariables}; `); if (needsBraces) { code.appendLeft(this.end, ` }`); } @@ -205,3 +207,6 @@ export default class IfStatement extends StatementBase implements DeoptimizableE return false; } } + +IfStatement.prototype.includeNode = onlyIncludeSelfNoDeoptimize; +IfStatement.prototype.applyDeoptimizations = doNotDeoptimize; diff --git a/src/ast/nodes/ImportAttribute.ts b/src/ast/nodes/ImportAttribute.ts new file mode 100644 index 00000000000..b9a6771b85c --- /dev/null +++ b/src/ast/nodes/ImportAttribute.ts @@ -0,0 +1,10 @@ +import type Identifier from './Identifier'; +import type Literal from './Literal'; +import type * as NodeType from './NodeType'; +import { NodeBase } from './shared/Node'; + +export default class ImportAttribute extends NodeBase { + declare key: Identifier | Literal; + declare type: NodeType.tImportAttribute; + declare value: Literal; +} diff --git a/src/ast/nodes/ImportDeclaration.ts b/src/ast/nodes/ImportDeclaration.ts index 450381bad86..d279d26b237 100644 --- a/src/ast/nodes/ImportDeclaration.ts +++ b/src/ast/nodes/ImportDeclaration.ts @@ -1,31 +1,37 @@ -import MagicString from 'magic-string'; -import { NodeRenderOptions, RenderOptions } from '../../utils/renderHelpers'; -import ImportDefaultSpecifier from './ImportDefaultSpecifier'; -import ImportNamespaceSpecifier from './ImportNamespaceSpecifier'; -import ImportSpecifier from './ImportSpecifier'; -import Literal from './Literal'; -import * as NodeType from './NodeType'; -import { NodeBase } from './shared/Node'; +import type MagicString from 'magic-string'; +import type { NodeRenderOptions, RenderOptions } from '../../utils/renderHelpers'; +import type ImportAttribute from './ImportAttribute'; +import type ImportDefaultSpecifier from './ImportDefaultSpecifier'; +import type ImportNamespaceSpecifier from './ImportNamespaceSpecifier'; +import type ImportSpecifier from './ImportSpecifier'; +import type Literal from './Literal'; +import type * as NodeType from './NodeType'; +import { doNotDeoptimize, NodeBase, onlyIncludeSelfNoDeoptimize } from './shared/Node'; export default class ImportDeclaration extends NodeBase { - needsBoundaries!: true; - source!: Literal; - specifiers!: (ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier)[]; - type!: NodeType.tImportDeclaration; + declare attributes: ImportAttribute[]; + declare needsBoundaries: true; + declare source: Literal; + declare specifiers: (ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier)[]; + declare type: NodeType.tImportDeclaration; - bind() {} + // Do not bind specifiers or attributes + bind(): void {} - hasEffects() { + hasEffects(): boolean { return false; } - initialise() { - this.context.addImport(this); + initialise(): void { + super.initialise(); + this.scope.context.addImport(this); } - render(code: MagicString, _options: RenderOptions, nodeRenderOptions?: NodeRenderOptions) { + render(code: MagicString, _options: RenderOptions, nodeRenderOptions?: NodeRenderOptions): void { code.remove(nodeRenderOptions!.start!, nodeRenderOptions!.end!); } } ImportDeclaration.prototype.needsBoundaries = true; +ImportDeclaration.prototype.includeNode = onlyIncludeSelfNoDeoptimize; +ImportDeclaration.prototype.applyDeoptimizations = doNotDeoptimize; diff --git a/src/ast/nodes/ImportDefaultSpecifier.ts b/src/ast/nodes/ImportDefaultSpecifier.ts index f55eab1d4e2..e355254a564 100644 --- a/src/ast/nodes/ImportDefaultSpecifier.ts +++ b/src/ast/nodes/ImportDefaultSpecifier.ts @@ -1,8 +1,11 @@ -import Identifier from './Identifier'; -import * as NodeType from './NodeType'; -import { NodeBase } from './shared/Node'; +import type Identifier from './Identifier'; +import type * as NodeType from './NodeType'; +import { doNotDeoptimize, NodeBase, onlyIncludeSelfNoDeoptimize } from './shared/Node'; export default class ImportDefaultSpecifier extends NodeBase { - local!: Identifier; - type!: NodeType.tImportDefaultSpecifier; + declare local: Identifier; + declare type: NodeType.tImportDefaultSpecifier; } + +ImportDefaultSpecifier.prototype.includeNode = onlyIncludeSelfNoDeoptimize; +ImportDefaultSpecifier.prototype.applyDeoptimizations = doNotDeoptimize; diff --git a/src/ast/nodes/ImportExpression.ts b/src/ast/nodes/ImportExpression.ts index dff594a4864..bc2df215da9 100644 --- a/src/ast/nodes/ImportExpression.ts +++ b/src/ast/nodes/ImportExpression.ts @@ -1,61 +1,213 @@ -import MagicString from 'magic-string'; +import type MagicString from 'magic-string'; +import type Chunk from '../../Chunk'; +import ExternalChunk from '../../ExternalChunk'; import ExternalModule from '../../ExternalModule'; -import Module from '../../Module'; -import { GetInterop, NormalizedOutputOptions } from '../../rollup/types'; +import type Module from '../../Module'; +import type { + AstNode, + DynamicImportTargetChunk, + GetInterop, + NormalizedOutputOptions, + PreRenderedChunkWithFileName +} from '../../rollup/types'; +import type { GenerateCodeSnippets } from '../../utils/generateCodeSnippets'; import { - getDefaultOnlyHelper, + INTEROP_NAMESPACE_DEFAULT_ONLY_VARIABLE, namespaceInteropHelpersByInteropType } from '../../utils/interopHelpers'; -import { PluginDriver } from '../../utils/PluginDriver'; -import { findFirstOccurrenceOutsideComment, RenderOptions } from '../../utils/renderHelpers'; -import { InclusionContext } from '../ExecutionContext'; -import ChildScope from '../scopes/ChildScope'; -import NamespaceVariable from '../variables/NamespaceVariable'; -import * as NodeType from './NodeType'; -import { ExpressionNode, IncludeChildren, NodeBase } from './shared/Node'; +import type { PluginDriver } from '../../utils/PluginDriver'; +import { findFirstOccurrenceOutsideComment, type RenderOptions } from '../../utils/renderHelpers'; +import type { InclusionContext } from '../ExecutionContext'; +import type ChildScope from '../scopes/ChildScope'; +import { + isArrowFunctionExpressionNode, + isAwaitExpressionNode, + isCallExpressionNode, + isExpressionStatementNode, + isFunctionExpressionNode, + isIdentifierNode, + isMemberExpressionNode +} from '../utils/identifyNode'; +import type { ObjectPath } from '../utils/PathTracker'; +import { UNKNOWN_PATH } from '../utils/PathTracker'; +import type NamespaceVariable from '../variables/NamespaceVariable'; +import { getDynamicNamespaceVariable } from '../variables/NamespaceVariable'; +import { EmptyPromiseHandler, ObjectPromiseHandler } from '../variables/PromiseHandler'; +import type CallExpression from './CallExpression'; +import type * as NodeType from './NodeType'; +import { Flag, isFlagSet, setFlag } from './shared/BitFlags'; +import { + doNotDeoptimize, + type ExpressionNode, + type GenericEsTreeNode, + type IncludeChildren, + NodeBase +} from './shared/Node'; interface DynamicImportMechanism { left: string; right: string; } +function getChunkInfoWithPath(chunk: Chunk): PreRenderedChunkWithFileName { + return { fileName: chunk.getFileName(), ...chunk.getPreRenderedChunkInfo() }; +} + export default class ImportExpression extends NodeBase { + declare options: ExpressionNode | null; inlineNamespace: NamespaceVariable | null = null; - source!: ExpressionNode; - type!: NodeType.tImportExpression; + declare source: ExpressionNode; + declare type: NodeType.tImportExpression; + declare sourceAstNode: AstNode; + resolution: Module | ExternalModule | string | null = null; + private attributes: string | null | true = null; private mechanism: DynamicImportMechanism | null = null; - private resolution: Module | ExternalModule | string | null = null; + private namespaceExportName: string | false | undefined = undefined; + private localResolution: + | null + | { resolution: Module; tracked: false } + | { resolution: Module; tracked: true } = null; + private resolutionString: string | null = null; + + get shouldIncludeDynamicAttributes() { + return isFlagSet(this.flags, Flag.shouldIncludeDynamicAttributes); + } + + set shouldIncludeDynamicAttributes(value: boolean) { + this.flags = setFlag(this.flags, Flag.shouldIncludeDynamicAttributes, value); + } + + bind(): void { + const { options, parent, resolution, source } = this; + source.bind(); + options?.bind(); + // Check if we resolved to a Module without using instanceof + if (typeof resolution !== 'object' || !resolution || !('namespace' in resolution)) { + return; + } + // In these cases, we can track exactly what is included or deoptimized: + // * import('foo'); // as statement + // * await import('foo') // use as awaited expression in any way + // * import('foo').then(n => {...}) // only if .then is called directly on the import() + if (isExpressionStatementNode(parent) || isAwaitExpressionNode(parent)) { + this.localResolution = { resolution, tracked: true }; + return; + } + if (!isMemberExpressionNode(parent)) { + this.localResolution = { resolution, tracked: false }; + return; + } + let currentParent = parent; + // eslint-disable-next-line @typescript-eslint/no-this-alias + let callExpression: ImportExpression | CallExpression = this; + while (true) { + if ( + currentParent.computed || + currentParent.object !== callExpression || + !isIdentifierNode(currentParent.property) || + !isCallExpressionNode(currentParent.parent) + ) { + break; + } + const propertyName = currentParent.property.name; + callExpression = currentParent.parent; + if (propertyName === 'then') { + const firstArgument = callExpression.arguments[0]; + if ( + firstArgument === undefined || + isFunctionExpressionNode(firstArgument) || + isArrowFunctionExpressionNode(firstArgument) + ) { + currentParent.promiseHandler = new ObjectPromiseHandler( + getDynamicNamespaceVariable(resolution.namespace) + ); + this.localResolution = { resolution, tracked: true }; + return; + } + } else if (propertyName === 'catch' || propertyName === 'finally') { + if (isMemberExpressionNode(callExpression.parent)) { + currentParent.promiseHandler = new EmptyPromiseHandler(); + currentParent = callExpression.parent; + continue; + } + if (isExpressionStatementNode(callExpression.parent)) { + currentParent.promiseHandler = new EmptyPromiseHandler(); + this.localResolution = { resolution, tracked: true }; + return; + } + } + break; + } + this.localResolution = { resolution, tracked: false }; + } + + deoptimizePath(path: ObjectPath): void { + this.localResolution?.resolution?.namespace.deoptimizePath(path); + } hasEffects(): boolean { return true; } - include(context: InclusionContext, includeChildrenRecursively: IncludeChildren) { - if (!this.included) { - this.included = true; - this.context.includeDynamicImport(this); - this.scope.addAccessedDynamicImport(this); - } + include(context: InclusionContext, includeChildrenRecursively: IncludeChildren): void { + if (!this.included) this.includeNode(context); this.source.include(context, includeChildrenRecursively); + if (this.shouldIncludeDynamicAttributes) { + this.options?.include(context, includeChildrenRecursively); + } + } + + includeNode(context: InclusionContext) { + this.included = true; + const { localResolution, scope, shouldIncludeDynamicAttributes } = this; + if (shouldIncludeDynamicAttributes) { + this.options?.includePath(UNKNOWN_PATH, context); + } + scope.context.includeDynamicImport(this); + scope.addAccessedDynamicImport(this); + if (localResolution) { + if (localResolution.tracked) { + localResolution.resolution.includeModuleInExecution(); + } else { + localResolution.resolution.includeAllExports(); + } + } } - initialise() { - this.context.addDynamicImport(this); + includePath(path: ObjectPath, context: InclusionContext): void { + if (!this.included) this.includeNode(context); + this.localResolution?.resolution?.namespace.includeMemberPath(path, context); } - render(code: MagicString, options: RenderOptions) { + initialise(): void { + super.initialise(); + this.scope.context.addDynamicImport(this); + } + + parseNode(esTreeNode: GenericEsTreeNode): this { + this.sourceAstNode = esTreeNode.source; + return super.parseNode(esTreeNode); + } + + render(code: MagicString, options: RenderOptions): void { + const { + snippets: { _, getDirectReturnFunction, getObject, getPropertyAccess }, + importAttributesKey + } = options; if (this.inlineNamespace) { - const _ = options.compact ? '' : ' '; - const s = options.compact ? '' : ';'; + const [left, right] = getDirectReturnFunction([], { + functionReturn: true, + lineBreakIndent: null, + name: null + }); code.overwrite( this.start, this.end, - `Promise.resolve().then(function${_}()${_}{${_}return ${this.inlineNamespace.getName()}${s}${_}})` + `Promise.resolve().then(${left}${this.inlineNamespace.getName(getPropertyAccess)}${right})` ); return; } - if (this.mechanism) { code.overwrite( this.start, @@ -64,41 +216,60 @@ export default class ImportExpression extends NodeBase { ); code.overwrite(this.end - 1, this.end, this.mechanism.right); } - this.source.render(code, options); - } - - renderFinalResolution( - code: MagicString, - resolution: string, - namespaceExportName: string | false | undefined, - options: NormalizedOutputOptions - ) { - code.overwrite(this.source.start, this.source.end, resolution); - if (namespaceExportName) { - const _ = options.compact ? '' : ' '; - const s = options.compact ? '' : ';'; - code.prependLeft( - this.end, - `.then(function${_}(n)${_}{${_}return n.${namespaceExportName}${s}${_}})` - ); + if (this.resolutionString) { + code.overwrite(this.source.start, this.source.end, this.resolutionString); + if (this.namespaceExportName) { + const [left, right] = getDirectReturnFunction(['n'], { + functionReturn: true, + lineBreakIndent: null, + name: null + }); + code.prependLeft(this.end, `.then(${left}n.${this.namespaceExportName}${right})`); + } + } else { + this.source.render(code, options); + } + if (this.attributes !== true) { + if (this.options) { + code.overwrite(this.source.end, this.end - 1, '', { contentOnly: true }); + } + if (this.attributes) { + code.appendLeft( + this.end - 1, + `,${_}${getObject([[importAttributesKey, this.attributes]], { + lineBreakIndent: null + })}` + ); + } } } setExternalResolution( exportMode: 'none' | 'named' | 'default' | 'external', - resolution: Module | ExternalModule | string | null, options: NormalizedOutputOptions, + snippets: GenerateCodeSnippets, pluginDriver: PluginDriver, - accessedGlobalsByScope: Map> + accessedGlobalsByScope: Map>, + resolutionString: string, + namespaceExportName: string | false | undefined, + attributes: string | true | null, + ownChunk: Chunk, + targetChunk: Chunk | null ): void { - this.resolution = resolution; - const accessedGlobals = [...(accessedImportGlobals[options.format] || [])]; + const { format } = options; + this.inlineNamespace = null; + this.resolutionString = resolutionString; + this.namespaceExportName = namespaceExportName; + this.attributes = attributes; + const accessedGlobals = [...(accessedImportGlobals[format] || [])]; let helper: string | null; ({ helper, mechanism: this.mechanism } = this.getDynamicImportMechanismAndHelper( - resolution, exportMode, options, - pluginDriver + snippets, + pluginDriver, + ownChunk, + targetChunk )); if (helper) { accessedGlobals.push(helper); @@ -108,64 +279,128 @@ export default class ImportExpression extends NodeBase { } } - setInternalResolution(inlineNamespace: NamespaceVariable) { + setInternalResolution(inlineNamespace: NamespaceVariable): void { this.inlineNamespace = inlineNamespace; } private getDynamicImportMechanismAndHelper( - resolution: Module | ExternalModule | string | null, exportMode: 'none' | 'named' | 'default' | 'external', - options: NormalizedOutputOptions, - pluginDriver: PluginDriver + { + compact, + dynamicImportInCjs, + format, + generatedCode: { arrowFunctions }, + interop + }: NormalizedOutputOptions, + { _, getDirectReturnFunction, getDirectReturnIifeLeft }: GenerateCodeSnippets, + pluginDriver: PluginDriver, + ownChunk: Chunk, + targetChunk: Chunk | null ): { helper: string | null; mechanism: DynamicImportMechanism | null } { + const { resolution, scope } = this; const mechanism = pluginDriver.hookFirstSync('renderDynamicImport', [ { - customResolution: typeof this.resolution === 'string' ? this.resolution : null, - format: options.format, - moduleId: this.context.module.id, - targetModuleId: - this.resolution && typeof this.resolution !== 'string' ? this.resolution.id : null + chunk: getChunkInfoWithPath(ownChunk), + customResolution: typeof resolution === 'string' ? resolution : null, + format, + getTargetChunkImports(): DynamicImportTargetChunk[] | null { + if (targetChunk === null) return null; + const chunkInfos: DynamicImportTargetChunk[] = []; + const importerPath = ownChunk.getFileName(); + for (const dep of targetChunk.dependencies) { + const resolvedImportPath = `'${dep.getImportPath(importerPath)}'`; + if (dep instanceof ExternalChunk) { + chunkInfos.push({ + fileName: dep.getFileName(), + resolvedImportPath, + type: 'external' + }); + } else { + chunkInfos.push({ + chunk: dep.getPreRenderedChunkInfo(), + fileName: dep.getFileName(), + resolvedImportPath, + type: 'internal' + }); + } + } + return chunkInfos; + }, + moduleId: scope.context.module.id, + targetChunk: targetChunk ? getChunkInfoWithPath(targetChunk) : null, + targetModuleId: resolution && typeof resolution !== 'string' ? resolution.id : null } ]); if (mechanism) { return { helper: null, mechanism }; } - switch (options.format) { + const hasDynamicTarget = !resolution || typeof resolution === 'string'; + switch (format) { case 'cjs': { - const _ = options.compact ? '' : ' '; - const s = options.compact ? '' : ';'; - const leftStart = `Promise.resolve().then(function${_}()${_}{${_}return`; - const helper = this.getInteropHelper(resolution, exportMode, options.interop); + if ( + dynamicImportInCjs && + (!resolution || typeof resolution === 'string' || resolution instanceof ExternalModule) + ) { + return { helper: null, mechanism: null }; + } + const helper = getInteropHelper(resolution, exportMode, interop); + let left = `require(`; + let right = `)`; + if (helper) { + left = `/*#__PURE__*/${helper}(${left}`; + right += ')'; + } + const [functionLeft, functionRight] = getDirectReturnFunction([], { + functionReturn: true, + lineBreakIndent: null, + name: null + }); + left = `Promise.resolve().then(${functionLeft}${left}`; + right += `${functionRight})`; + if (!arrowFunctions && hasDynamicTarget) { + left = getDirectReturnIifeLeft(['t'], `${left}t${right}`, { + needsArrowReturnParens: false, + needsWrappedFunction: true + }); + right = ')'; + } return { helper, - mechanism: helper - ? { - left: `${leftStart} /*#__PURE__*/${helper}(require(`, - right: `))${s}${_}})` - } - : { - left: `${leftStart} require(`, - right: `)${s}${_}})` - } + mechanism: { left, right } }; } case 'amd': { - const _ = options.compact ? '' : ' '; - const resolve = options.compact ? 'c' : 'resolve'; - const reject = options.compact ? 'e' : 'reject'; - const helper = this.getInteropHelper(resolution, exportMode, options.interop); + const resolve = compact ? 'c' : 'resolve'; + const reject = compact ? 'e' : 'reject'; + const helper = getInteropHelper(resolution, exportMode, interop); + const [resolveLeft, resolveRight] = getDirectReturnFunction(['m'], { + functionReturn: false, + lineBreakIndent: null, + name: null + }); const resolveNamespace = helper - ? `function${_}(m)${_}{${_}${resolve}(/*#__PURE__*/${helper}(m));${_}}` + ? `${resolveLeft}${resolve}(/*#__PURE__*/${helper}(m))${resolveRight}` : resolve; + const [handlerLeft, handlerRight] = getDirectReturnFunction([resolve, reject], { + functionReturn: false, + lineBreakIndent: null, + name: null + }); + let left = `new Promise(${handlerLeft}require([`; + let right = `],${_}${resolveNamespace},${_}${reject})${handlerRight})`; + if (!arrowFunctions && hasDynamicTarget) { + left = getDirectReturnIifeLeft(['t'], `${left}t${right}`, { + needsArrowReturnParens: false, + needsWrappedFunction: true + }); + right = ')'; + } return { helper, - mechanism: { - left: `new Promise(function${_}(${resolve},${_}${reject})${_}{${_}require([`, - right: `],${_}${resolveNamespace},${_}${reject})${_}})` - } + mechanism: { left, right } }; } - case 'system': + case 'system': { return { helper: null, mechanism: { @@ -173,33 +408,26 @@ export default class ImportExpression extends NodeBase { right: ')' } }; - case 'es': - if (options.dynamicImportFunction) { - return { - helper: null, - mechanism: { - left: `${options.dynamicImportFunction}(`, - right: ')' - } - }; - } + } } return { helper: null, mechanism: null }; } +} - private getInteropHelper( - resolution: Module | ExternalModule | string | null, - exportMode: 'none' | 'named' | 'default' | 'external', - interop: GetInterop - ): string | null { - return exportMode === 'external' - ? namespaceInteropHelpersByInteropType[ - String(interop(resolution instanceof ExternalModule ? resolution.id : null)) - ] - : exportMode === 'default' - ? getDefaultOnlyHelper() +ImportExpression.prototype.applyDeoptimizations = doNotDeoptimize; + +function getInteropHelper( + resolution: Module | ExternalModule | string | null, + exportMode: 'none' | 'named' | 'default' | 'external', + interop: GetInterop +): string | null { + return exportMode === 'external' + ? namespaceInteropHelpersByInteropType[ + interop(resolution instanceof ExternalModule ? resolution.id : null) + ] + : exportMode === 'default' + ? INTEROP_NAMESPACE_DEFAULT_ONLY_VARIABLE : null; - } } const accessedImportGlobals: Record = { diff --git a/src/ast/nodes/ImportNamespaceSpecifier.ts b/src/ast/nodes/ImportNamespaceSpecifier.ts index 4a4d7f17c18..7fa92cf9638 100644 --- a/src/ast/nodes/ImportNamespaceSpecifier.ts +++ b/src/ast/nodes/ImportNamespaceSpecifier.ts @@ -1,8 +1,11 @@ -import Identifier from './Identifier'; -import * as NodeType from './NodeType'; -import { NodeBase } from './shared/Node'; +import type Identifier from './Identifier'; +import type * as NodeType from './NodeType'; +import { doNotDeoptimize, NodeBase, onlyIncludeSelfNoDeoptimize } from './shared/Node'; export default class ImportNamespaceSpecifier extends NodeBase { - local!: Identifier; - type!: NodeType.tImportNamespaceSpecifier; + declare local: Identifier; + declare type: NodeType.tImportNamespaceSpecifier; } + +ImportNamespaceSpecifier.prototype.includeNode = onlyIncludeSelfNoDeoptimize; +ImportNamespaceSpecifier.prototype.applyDeoptimizations = doNotDeoptimize; diff --git a/src/ast/nodes/ImportSpecifier.ts b/src/ast/nodes/ImportSpecifier.ts index 1852bcb4e97..1cde4f4ac81 100644 --- a/src/ast/nodes/ImportSpecifier.ts +++ b/src/ast/nodes/ImportSpecifier.ts @@ -1,9 +1,13 @@ -import Identifier from './Identifier'; -import * as NodeType from './NodeType'; -import { NodeBase } from './shared/Node'; +import type Identifier from './Identifier'; +import type Literal from './Literal'; +import type * as NodeType from './NodeType'; +import { doNotDeoptimize, NodeBase, onlyIncludeSelfNoDeoptimize } from './shared/Node'; export default class ImportSpecifier extends NodeBase { - imported!: Identifier; - local!: Identifier; - type!: NodeType.tImportSpecifier; + declare imported: Identifier | Literal; + declare local: Identifier; + declare type: NodeType.tImportSpecifier; } + +ImportSpecifier.prototype.includeNode = onlyIncludeSelfNoDeoptimize; +ImportSpecifier.prototype.applyDeoptimizations = doNotDeoptimize; diff --git a/src/ast/nodes/JSXAttribute.ts b/src/ast/nodes/JSXAttribute.ts new file mode 100644 index 00000000000..a2ad6325ed4 --- /dev/null +++ b/src/ast/nodes/JSXAttribute.ts @@ -0,0 +1,50 @@ +import type MagicString from 'magic-string'; +import { BLANK } from '../../utils/blank'; +import { stringifyObjectKeyIfNeeded } from '../../utils/identifierHelpers'; +import type { NodeRenderOptions, RenderOptions } from '../../utils/renderHelpers'; +import type JSXElement from './JSXElement'; +import type JSXExpressionContainer from './JSXExpressionContainer'; +import type JSXFragment from './JSXFragment'; +import JSXIdentifier from './JSXIdentifier'; +import type JSXNamespacedName from './JSXNamespacedName'; +import Literal from './Literal'; +import type * as NodeType from './NodeType'; +import { NodeBase, onlyIncludeSelf } from './shared/Node'; + +export default class JSXAttribute extends NodeBase { + type!: NodeType.tJSXAttribute; + name!: JSXIdentifier | JSXNamespacedName; + value!: Literal | JSXExpressionContainer | JSXElement | JSXFragment | null; + + render(code: MagicString, options: RenderOptions, { jsxMode }: NodeRenderOptions = BLANK): void { + super.render(code, options); + if ((['classic', 'automatic'] as (string | undefined)[]).includes(jsxMode)) { + const { name, value } = this; + const key = + name instanceof JSXIdentifier ? name.name : `${name.namespace.name}:${name.name.name}`; + if (!(jsxMode === 'automatic' && key === 'key')) { + const safeKey = stringifyObjectKeyIfNeeded(key); + if (key !== safeKey) { + code.overwrite(name.start, name.end, safeKey, { contentOnly: true }); + } + if (value) { + code.overwrite(name.end, value.start, ': ', { contentOnly: true }); + // foo="aa \n aa" + if ( + value instanceof Literal && + typeof value.value === 'string' && + value.value.includes('\n') + ) { + code.overwrite(value.start, value.end, JSON.stringify(value.value), { + contentOnly: true + }); + } + } else { + code.appendLeft(name.end, ': true'); + } + } + } + } +} + +JSXAttribute.prototype.includeNode = onlyIncludeSelf; diff --git a/src/ast/nodes/JSXClosingElement.ts b/src/ast/nodes/JSXClosingElement.ts new file mode 100644 index 00000000000..8fdd4500943 --- /dev/null +++ b/src/ast/nodes/JSXClosingElement.ts @@ -0,0 +1,10 @@ +import type JSXIdentifier from './JSXIdentifier'; +import type JSXMemberExpression from './JSXMemberExpression'; +import type JSXNamespacedName from './JSXNamespacedName'; +import type * as NodeType from './NodeType'; +import JSXClosingBase from './shared/JSXClosingBase'; + +export default class JSXClosingElement extends JSXClosingBase { + type!: NodeType.tJSXClosingElement; + name!: JSXIdentifier | JSXMemberExpression | JSXNamespacedName; +} diff --git a/src/ast/nodes/JSXClosingFragment.ts b/src/ast/nodes/JSXClosingFragment.ts new file mode 100644 index 00000000000..a562f09de0b --- /dev/null +++ b/src/ast/nodes/JSXClosingFragment.ts @@ -0,0 +1,6 @@ +import type * as NodeType from './NodeType'; +import JSXClosingBase from './shared/JSXClosingBase'; + +export default class JSXClosingFragment extends JSXClosingBase { + type!: NodeType.tJSXClosingFragment; +} diff --git a/src/ast/nodes/JSXElement.ts b/src/ast/nodes/JSXElement.ts new file mode 100644 index 00000000000..92a66cb5c15 --- /dev/null +++ b/src/ast/nodes/JSXElement.ts @@ -0,0 +1,260 @@ +import type MagicString from 'magic-string'; +import type { NormalizedJsxOptions } from '../../rollup/types'; +import type { RenderOptions } from '../../utils/renderHelpers'; +import type { InclusionContext } from '../ExecutionContext'; +import JSXAttribute from './JSXAttribute'; +import type JSXClosingElement from './JSXClosingElement'; +import type JSXOpeningElement from './JSXOpeningElement'; +import JSXSpreadAttribute from './JSXSpreadAttribute'; +import type * as NodeType from './NodeType'; +import JSXElementBase from './shared/JSXElementBase'; +import type { JSXChild, JsxMode } from './shared/jsxHelpers'; +import type { IncludeChildren } from './shared/Node'; + +export default class JSXElement extends JSXElementBase { + type!: NodeType.tJSXElement; + openingElement!: JSXOpeningElement; + closingElement!: JSXClosingElement | null; + children!: JSXChild[]; + + include(context: InclusionContext, includeChildrenRecursively: IncludeChildren) { + super.include(context, includeChildrenRecursively); + this.openingElement.include(context, includeChildrenRecursively); + this.closingElement?.include(context, includeChildrenRecursively); + } + + render(code: MagicString, options: RenderOptions): void { + switch (this.jsxMode.mode) { + case 'classic': { + this.renderClassicMode(code, options); + break; + } + case 'automatic': { + this.renderAutomaticMode(code, options); + break; + } + default: { + super.render(code, options); + } + } + } + + protected getRenderingMode(): JsxMode { + const jsx = this.scope.context.options.jsx as NormalizedJsxOptions; + const { mode, factory, importSource } = jsx; + if (mode === 'automatic') { + // In the case there is a key after a spread attribute, we fall back to + // classic mode, see https://github.com/facebook/react/issues/20031#issuecomment-710346866 + // for reasoning. + let hasSpread = false; + for (const attribute of this.openingElement.attributes) { + if (attribute instanceof JSXSpreadAttribute) { + hasSpread = true; + } else if (hasSpread && attribute.name.name === 'key') { + return { factory, importSource, mode: 'classic' }; + } + } + } + return super.getRenderingMode(); + } + + private renderClassicMode(code: MagicString, options: RenderOptions) { + const { + snippets: { getPropertyAccess }, + useOriginalName + } = options; + const { + closingElement, + end, + factory, + factoryVariable, + openingElement: { end: openingEnd, selfClosing } + } = this; + const [, ...nestedName] = factory!.split('.'); + const { firstAttribute, hasAttributes, hasSpread, inObject, previousEnd } = + this.renderAttributes( + code, + options, + [factoryVariable!.getName(getPropertyAccess, useOriginalName), ...nestedName].join('.'), + false + ); + + this.wrapAttributes( + code, + inObject, + hasAttributes, + hasSpread, + firstAttribute, + 'null', + previousEnd + ); + + this.renderChildren(code, options, openingEnd); + + if (selfClosing) { + code.appendLeft(end, ')'); + } else { + closingElement!.render(code, options); + } + } + + private renderAutomaticMode(code: MagicString, options: RenderOptions) { + const { + snippets: { getPropertyAccess }, + useOriginalName + } = options; + const { + closingElement, + end, + factoryVariable, + openingElement: { end: openingEnd, selfClosing } + } = this; + let { firstAttribute, hasAttributes, hasSpread, inObject, keyAttribute, previousEnd } = + this.renderAttributes( + code, + options, + factoryVariable!.getName(getPropertyAccess, useOriginalName), + true + ); + + const { firstChild, hasMultipleChildren, childrenEnd } = this.renderChildren( + code, + options, + openingEnd + ); + + if (firstChild) { + code.prependRight(firstChild.start, `children: ${hasMultipleChildren ? '[' : ''}`); + if (!inObject) { + code.prependRight(firstChild.start, '{ '); + inObject = true; + } + previousEnd = closingElement!.start; + if (hasMultipleChildren) { + code.appendLeft(previousEnd, ']'); + } + } + + // This ensures that attributesEnd never corresponds to this.end. This is + // important because we must never use code.move with this.end as target. + // Otherwise, this would interfere with parent elements that try to append + // code to this.end, which would appear BEFORE the moved code. + const attributesEnd = firstChild ? childrenEnd : previousEnd; + this.wrapAttributes( + code, + inObject, + hasAttributes || !!firstChild, + hasSpread, + firstAttribute || firstChild, + '{}', + attributesEnd + ); + + if (keyAttribute) { + const { value } = keyAttribute; + // This will appear to the left of the moved code... + code.appendLeft(attributesEnd, ', '); + if (value) { + code.move(value.start, value.end, attributesEnd); + } else { + code.appendLeft(attributesEnd, 'true'); + } + } + + if (selfClosing) { + // Moving the key attribute will also move the parenthesis to the right position + code.appendLeft(keyAttribute?.value?.end || end, ')'); + } else { + closingElement!.render(code, options); + } + } + + private renderAttributes( + code: MagicString, + options: RenderOptions, + factoryName: string, + extractKeyAttribute: boolean + ): { + firstAttribute: JSXAttribute | JSXSpreadAttribute | JSXChild | null; + hasAttributes: boolean; + hasSpread: boolean; + inObject: boolean; + keyAttribute: JSXAttribute | null; + previousEnd: number; + } { + const { + jsxMode: { mode }, + openingElement + } = this; + const { + attributes, + end: openingEnd, + start: openingStart, + name: { start: nameStart, end: nameEnd } + } = openingElement; + code.update(openingStart, nameStart, `/*#__PURE__*/${factoryName}(`); + openingElement.render(code, options, { jsxMode: mode }); + let keyAttribute: JSXAttribute | null = null; + let hasSpread = false; + let inObject = false; + let previousEnd = nameEnd; + let hasAttributes = false; + let firstAttribute: JSXAttribute | JSXSpreadAttribute | null = null; + for (const attribute of attributes) { + if (attribute instanceof JSXAttribute) { + if (extractKeyAttribute && attribute.name.name === 'key') { + keyAttribute = attribute; + code.remove(previousEnd, attribute.value?.start || attribute.end); + continue; + } + code.appendLeft(previousEnd, ','); + if (!inObject) { + code.prependRight(attribute.start, '{ '); + inObject = true; + } + hasAttributes = true; + } else { + if (inObject) { + if (hasAttributes) { + code.appendLeft(previousEnd, ' '); + } + code.appendLeft(previousEnd, '},'); + inObject = false; + } else { + code.appendLeft(previousEnd, ','); + } + hasSpread = true; + } + previousEnd = attribute.end; + firstAttribute ??= attribute; + } + code.remove(attributes.at(-1)?.end || previousEnd, openingEnd); + return { firstAttribute, hasAttributes, hasSpread, inObject, keyAttribute, previousEnd }; + } + + private wrapAttributes( + code: MagicString, + inObject: boolean, + hasAttributes: boolean, + hasSpread: boolean, + firstAttribute: JSXAttribute | JSXSpreadAttribute | JSXChild | null, + missingAttributesFallback: string, + attributesEnd: number + ) { + if (inObject) { + code.appendLeft(attributesEnd, ' }'); + } + if (hasSpread) { + if (hasAttributes) { + const { start } = firstAttribute!; + if (firstAttribute instanceof JSXSpreadAttribute) { + code.prependRight(start, '{}, '); + } + code.prependRight(start, 'Object.assign('); + code.appendLeft(attributesEnd, ')'); + } + } else if (!hasAttributes) { + code.appendLeft(attributesEnd, `, ${missingAttributesFallback}`); + } + } +} diff --git a/src/ast/nodes/JSXEmptyExpression.ts b/src/ast/nodes/JSXEmptyExpression.ts new file mode 100644 index 00000000000..8ae56517c37 --- /dev/null +++ b/src/ast/nodes/JSXEmptyExpression.ts @@ -0,0 +1,8 @@ +import type * as NodeType from './NodeType'; +import { NodeBase, onlyIncludeSelf } from './shared/Node'; + +export default class JSXEmptyExpression extends NodeBase { + type!: NodeType.tJSXEmptyExpression; +} + +JSXEmptyExpression.prototype.includeNode = onlyIncludeSelf; diff --git a/src/ast/nodes/JSXExpressionContainer.ts b/src/ast/nodes/JSXExpressionContainer.ts new file mode 100644 index 00000000000..4d71c3891d3 --- /dev/null +++ b/src/ast/nodes/JSXExpressionContainer.ts @@ -0,0 +1,29 @@ +import type MagicString from 'magic-string'; +import type { NormalizedJsxOptions } from '../../rollup/types'; +import type { RenderOptions } from '../../utils/renderHelpers'; +import type { InclusionContext } from '../ExecutionContext'; +import { UNKNOWN_PATH } from '../utils/PathTracker'; +import type JSXEmptyExpression from './JSXEmptyExpression'; +import type * as NodeType from './NodeType'; +import type { ExpressionNode } from './shared/Node'; +import { NodeBase } from './shared/Node'; + +export default class JSXExpressionContainer extends NodeBase { + type!: NodeType.tJSXExpressionContainer; + expression!: ExpressionNode | JSXEmptyExpression; + + includeNode(context: InclusionContext) { + this.included = true; + if (!this.deoptimized) this.applyDeoptimizations(); + this.expression.includePath(UNKNOWN_PATH, context); + } + + render(code: MagicString, options: RenderOptions): void { + const { mode } = this.scope.context.options.jsx as NormalizedJsxOptions; + if (mode !== 'preserve') { + code.remove(this.start, this.expression.start); + code.remove(this.expression.end, this.end); + } + this.expression.render(code, options); + } +} diff --git a/src/ast/nodes/JSXFragment.ts b/src/ast/nodes/JSXFragment.ts new file mode 100644 index 00000000000..1f04e9f7522 --- /dev/null +++ b/src/ast/nodes/JSXFragment.ts @@ -0,0 +1,91 @@ +import type MagicString from 'magic-string'; +import type { RenderOptions } from '../../utils/renderHelpers'; +import type { InclusionContext } from '../ExecutionContext'; +import type JSXClosingFragment from './JSXClosingFragment'; +import type JSXOpeningFragment from './JSXOpeningFragment'; +import type * as NodeType from './NodeType'; +import JSXElementBase from './shared/JSXElementBase'; +import type { JSXChild } from './shared/jsxHelpers'; +import type { IncludeChildren } from './shared/Node'; + +export default class JSXFragment extends JSXElementBase { + type!: NodeType.tJSXElement; + openingFragment!: JSXOpeningFragment; + children!: JSXChild[]; + closingFragment!: JSXClosingFragment; + + include(context: InclusionContext, includeChildrenRecursively: IncludeChildren) { + super.include(context, includeChildrenRecursively); + this.openingFragment.include(context, includeChildrenRecursively); + this.closingFragment.include(context, includeChildrenRecursively); + } + + render(code: MagicString, options: RenderOptions): void { + switch (this.jsxMode.mode) { + case 'classic': { + this.renderClassicMode(code, options); + break; + } + case 'automatic': { + this.renderAutomaticMode(code, options); + break; + } + default: { + super.render(code, options); + } + } + } + + private renderClassicMode(code: MagicString, options: RenderOptions) { + const { + snippets: { getPropertyAccess }, + useOriginalName + } = options; + const { closingFragment, factory, factoryVariable, openingFragment, start } = this; + const [, ...nestedName] = factory!.split('.'); + openingFragment.render(code, options); + code.prependRight( + start, + `/*#__PURE__*/${[ + factoryVariable!.getName(getPropertyAccess, useOriginalName), + ...nestedName + ].join('.')}(` + ); + code.appendLeft(openingFragment.end, ', null'); + + this.renderChildren(code, options, openingFragment.end); + + closingFragment.render(code, options); + } + + private renderAutomaticMode(code: MagicString, options: RenderOptions) { + const { + snippets: { getPropertyAccess }, + useOriginalName + } = options; + const { closingFragment, factoryVariable, openingFragment, start } = this; + openingFragment.render(code, options); + code.prependRight( + start, + `/*#__PURE__*/${factoryVariable!.getName(getPropertyAccess, useOriginalName)}(` + ); + + const { firstChild, hasMultipleChildren, childrenEnd } = this.renderChildren( + code, + options, + openingFragment.end + ); + + if (firstChild) { + code.prependRight(firstChild.start, `{ children: ${hasMultipleChildren ? '[' : ''}`); + if (hasMultipleChildren) { + code.appendLeft(closingFragment.start, ']'); + } + code.appendLeft(childrenEnd, ' }'); + } else { + code.appendLeft(openingFragment.end, ', {}'); + } + + closingFragment.render(code, options); + } +} diff --git a/src/ast/nodes/JSXIdentifier.ts b/src/ast/nodes/JSXIdentifier.ts new file mode 100644 index 00000000000..89847c43321 --- /dev/null +++ b/src/ast/nodes/JSXIdentifier.ts @@ -0,0 +1,100 @@ +import type MagicString from 'magic-string'; +import type { NormalizedJsxOptions } from '../../rollup/types'; +import type { RenderOptions } from '../../utils/renderHelpers'; +import type { InclusionContext } from '../ExecutionContext'; +import type { ObjectPath } from '../utils/PathTracker'; +import { EMPTY_PATH } from '../utils/PathTracker'; +import type JSXMemberExpression from './JSXMemberExpression'; +import type * as NodeType from './NodeType'; +import IdentifierBase from './shared/IdentifierBase'; + +const enum IdentifierType { + Reference, + NativeElementName, + Other +} + +export default class JSXIdentifier extends IdentifierBase { + type!: NodeType.tJSXIdentifier; + name!: string; + + private isNativeElement = false; + + bind(): void { + const type = this.getType(); + if (type === IdentifierType.Reference) { + this.variable = this.scope.findVariable(this.name); + this.variable.addReference(this); + } else if (type === IdentifierType.NativeElementName) { + this.isNativeElement = true; + } + } + + include(context: InclusionContext): void { + if (!this.included) this.includeNode(context); + } + + includeNode(context: InclusionContext) { + this.included = true; + if (!this.deoptimized) this.applyDeoptimizations(); + if (this.variable !== null) { + this.scope.context.includeVariableInModule(this.variable, EMPTY_PATH, context); + } + } + + includePath(path: ObjectPath, context: InclusionContext): void { + if (!this.included) { + this.included = true; + if (this.variable !== null) { + this.scope.context.includeVariableInModule(this.variable, path, context); + } + } else if (path.length > 0) { + this.variable?.includePath(path, context); + } + } + + render( + code: MagicString, + { snippets: { getPropertyAccess }, useOriginalName }: RenderOptions + ): void { + if (this.variable) { + const name = this.variable.getName(getPropertyAccess, useOriginalName); + + if (name !== this.name) { + code.overwrite(this.start, this.end, name, { + contentOnly: true, + storeName: true + }); + } + } else if ( + this.isNativeElement && + (this.scope.context.options.jsx as NormalizedJsxOptions).mode !== 'preserve' + ) { + code.update(this.start, this.end, JSON.stringify(this.name)); + } + } + + private getType(): IdentifierType { + switch (this.parent.type) { + case 'JSXOpeningElement': + case 'JSXClosingElement': { + return this.name.startsWith(this.name.charAt(0).toUpperCase()) + ? IdentifierType.Reference + : IdentifierType.NativeElementName; + } + case 'JSXMemberExpression': { + return (this.parent as JSXMemberExpression).object === this + ? IdentifierType.Reference + : IdentifierType.Other; + } + case 'JSXAttribute': + case 'JSXNamespacedName': { + return IdentifierType.Other; + } + default: { + /* istanbul ignore next */ + throw new Error(`Unexpected parent node type for JSXIdentifier: ${this.parent.type}`); + } + } + } +} diff --git a/src/ast/nodes/JSXMemberExpression.ts b/src/ast/nodes/JSXMemberExpression.ts new file mode 100644 index 00000000000..f20963163f1 --- /dev/null +++ b/src/ast/nodes/JSXMemberExpression.ts @@ -0,0 +1,22 @@ +import type { InclusionContext } from '../ExecutionContext'; +import type { ObjectPath } from '../utils/PathTracker'; +import type JSXIdentifier from './JSXIdentifier'; +import type * as NodeType from './NodeType'; +import { NodeBase } from './shared/Node'; + +export default class JSXMemberExpression extends NodeBase { + type!: NodeType.tJSXMemberExpression; + object!: JSXMemberExpression | JSXIdentifier; + property!: JSXIdentifier; + + includeNode(context: InclusionContext) { + this.included = true; + if (!this.deoptimized) this.applyDeoptimizations(); + this.object.includePath([this.property.name], context); + } + + includePath(path: ObjectPath, context: InclusionContext) { + if (!this.included) this.includeNode(context); + this.object.includePath([this.property.name, ...path], context); + } +} diff --git a/src/ast/nodes/JSXNamespacedName.ts b/src/ast/nodes/JSXNamespacedName.ts new file mode 100644 index 00000000000..086568a3d68 --- /dev/null +++ b/src/ast/nodes/JSXNamespacedName.ts @@ -0,0 +1,11 @@ +import type JSXIdentifier from './JSXIdentifier'; +import type * as NodeType from './NodeType'; +import { NodeBase, onlyIncludeSelf } from './shared/Node'; + +export default class JSXNamespacedName extends NodeBase { + type!: NodeType.tJSXNamespacedName; + name!: JSXIdentifier; + namespace!: JSXIdentifier; +} + +JSXNamespacedName.prototype.includeNode = onlyIncludeSelf; diff --git a/src/ast/nodes/JSXOpeningElement.ts b/src/ast/nodes/JSXOpeningElement.ts new file mode 100644 index 00000000000..30261a9556d --- /dev/null +++ b/src/ast/nodes/JSXOpeningElement.ts @@ -0,0 +1,32 @@ +import type MagicString from 'magic-string'; +import type { NormalizedJsxOptions } from '../../rollup/types'; +import type { NodeRenderOptions, RenderOptions } from '../../utils/renderHelpers'; +import type JSXAttribute from './JSXAttribute'; +import type JSXIdentifier from './JSXIdentifier'; +import type JSXMemberExpression from './JSXMemberExpression'; +import type JSXNamespacedName from './JSXNamespacedName'; +import type JSXSpreadAttribute from './JSXSpreadAttribute'; +import type * as NodeType from './NodeType'; +import { NodeBase, onlyIncludeSelf } from './shared/Node'; + +export default class JSXOpeningElement extends NodeBase { + type!: NodeType.tJSXOpeningElement; + name!: JSXIdentifier | JSXMemberExpression | JSXNamespacedName; + attributes!: (JSXAttribute | JSXSpreadAttribute)[]; + selfClosing!: boolean; + + render( + code: MagicString, + options: RenderOptions, + { + jsxMode = (this.scope.context.options.jsx as NormalizedJsxOptions).mode + }: NodeRenderOptions = {} + ): void { + this.name.render(code, options); + for (const attribute of this.attributes) { + attribute.render(code, options, { jsxMode }); + } + } +} + +JSXOpeningElement.prototype.includeNode = onlyIncludeSelf; diff --git a/src/ast/nodes/JSXOpeningFragment.ts b/src/ast/nodes/JSXOpeningFragment.ts new file mode 100644 index 00000000000..15d67eac143 --- /dev/null +++ b/src/ast/nodes/JSXOpeningFragment.ts @@ -0,0 +1,61 @@ +import type MagicString from 'magic-string'; +import type { NormalizedJsxOptions } from '../../rollup/types'; +import type { RenderOptions } from '../../utils/renderHelpers'; +import type { InclusionContext } from '../ExecutionContext'; +import type Variable from '../variables/Variable'; +import type * as NodeType from './NodeType'; +import { getAndIncludeFactoryVariable } from './shared/jsxHelpers'; +import { NodeBase } from './shared/Node'; + +export default class JSXOpeningFragment extends NodeBase { + type!: NodeType.tJSXOpeningElement; + attributes!: never[]; + selfClosing!: false; + + private fragment: string | null = null; + private fragmentVariable: Variable | null = null; + + includeNode(context: InclusionContext) { + this.included = true; + if (!this.deoptimized) this.applyDeoptimizations(); + const jsx = this.scope.context.options.jsx as NormalizedJsxOptions; + if (jsx.mode === 'automatic') { + this.fragment = 'Fragment'; + this.fragmentVariable = getAndIncludeFactoryVariable( + 'Fragment', + false, + jsx.jsxImportSource, + this, + context + ); + } else { + const { fragment, importSource, mode } = jsx; + if (fragment != null) { + this.fragment = fragment; + this.fragmentVariable = getAndIncludeFactoryVariable( + fragment, + mode === 'preserve', + importSource, + this, + context + ); + } + } + } + + render(code: MagicString, options: RenderOptions): void { + const { mode } = this.scope.context.options.jsx as NormalizedJsxOptions; + if (mode !== 'preserve') { + const { + snippets: { getPropertyAccess }, + useOriginalName + } = options; + const [, ...nestedFragment] = this.fragment!.split('.'); + const fragment = [ + this.fragmentVariable!.getName(getPropertyAccess, useOriginalName), + ...nestedFragment + ].join('.'); + code.update(this.start, this.end, fragment); + } + } +} diff --git a/src/ast/nodes/JSXSpreadAttribute.ts b/src/ast/nodes/JSXSpreadAttribute.ts new file mode 100644 index 00000000000..96f846a6c6c --- /dev/null +++ b/src/ast/nodes/JSXSpreadAttribute.ts @@ -0,0 +1,20 @@ +import type MagicString from 'magic-string'; +import type { NormalizedJsxOptions } from '../../rollup/types'; +import type { RenderOptions } from '../../utils/renderHelpers'; +import type * as NodeType from './NodeType'; +import type { ExpressionNode } from './shared/Node'; +import { NodeBase } from './shared/Node'; + +export default class JSXSpreadAttribute extends NodeBase { + type!: NodeType.tJSXSpreadAttribute; + argument!: ExpressionNode; + + render(code: MagicString, options: RenderOptions): void { + this.argument.render(code, options); + const { mode } = this.scope.context.options.jsx as NormalizedJsxOptions; + if (mode !== 'preserve') { + code.overwrite(this.start, this.argument.start, '', { contentOnly: true }); + code.overwrite(this.argument.end, this.end, '', { contentOnly: true }); + } + } +} diff --git a/src/ast/nodes/JSXSpreadChild.ts b/src/ast/nodes/JSXSpreadChild.ts new file mode 100644 index 00000000000..f831e582692 --- /dev/null +++ b/src/ast/nodes/JSXSpreadChild.ts @@ -0,0 +1,20 @@ +import type MagicString from 'magic-string'; +import type { NormalizedJsxOptions } from '../../rollup/types'; +import type { RenderOptions } from '../../utils/renderHelpers'; +import type * as NodeType from './NodeType'; +import type { ExpressionNode } from './shared/Node'; +import { NodeBase } from './shared/Node'; + +export default class JSXSpreadChild extends NodeBase { + type!: NodeType.tJSXSpreadChild; + expression!: ExpressionNode; + + render(code: MagicString, options: RenderOptions): void { + super.render(code, options); + const { mode } = this.scope.context.options.jsx as NormalizedJsxOptions; + if (mode !== 'preserve') { + code.overwrite(this.start, this.expression.start, '...', { contentOnly: true }); + code.overwrite(this.expression.end, this.end, '', { contentOnly: true }); + } + } +} diff --git a/src/ast/nodes/JSXText.ts b/src/ast/nodes/JSXText.ts new file mode 100644 index 00000000000..29436377ff0 --- /dev/null +++ b/src/ast/nodes/JSXText.ts @@ -0,0 +1,38 @@ +import type MagicString from 'magic-string'; +import type { NormalizedJsxOptions } from '../../rollup/types'; +import type * as NodeType from './NodeType'; +import { NodeBase, onlyIncludeSelf } from './shared/Node'; + +const RE_WHITESPACE_TRIM = /^[ \t]*\r?\n[ \t\r\n]*|[ \t]*\r?\n[ \t\r\n]*$/g; +const RE_WHITESPACE_MERGE = /[ \t]*\r?\n[ \t\r\n]*/g; + +export default class JSXText extends NodeBase { + type!: NodeType.tJSXText; + value!: string; + raw!: string; + + private renderedText: string | undefined; + + shouldRender() { + return !!this.getRenderedText(); + } + + render(code: MagicString) { + const { mode } = this.scope.context.options.jsx as NormalizedJsxOptions; + if (mode !== 'preserve') { + code.overwrite(this.start, this.end, JSON.stringify(this.getRenderedText()), { + contentOnly: true + }); + } + } + + private getRenderedText() { + if (this.renderedText === undefined) + this.renderedText = this.value + .replace(RE_WHITESPACE_TRIM, '') + .replace(RE_WHITESPACE_MERGE, ' '); + return this.renderedText; + } +} + +JSXText.prototype.includeNode = onlyIncludeSelf; diff --git a/src/ast/nodes/LabeledStatement.ts b/src/ast/nodes/LabeledStatement.ts index a8aab9dcf98..27d9847df96 100644 --- a/src/ast/nodes/LabeledStatement.ts +++ b/src/ast/nodes/LabeledStatement.ts @@ -1,43 +1,62 @@ -import MagicString from 'magic-string'; +import type MagicString from 'magic-string'; import { findFirstOccurrenceOutsideComment, findNonWhiteSpace, - RenderOptions + type RenderOptions } from '../../utils/renderHelpers'; -import { HasEffectsContext, InclusionContext } from '../ExecutionContext'; -import Identifier from './Identifier'; -import * as NodeType from './NodeType'; -import { IncludeChildren, StatementBase, StatementNode } from './shared/Node'; +import { type HasEffectsContext, type InclusionContext } from '../ExecutionContext'; +import { UNKNOWN_PATH } from '../utils/PathTracker'; +import type Identifier from './Identifier'; +import type * as NodeType from './NodeType'; +import { + doNotDeoptimize, + type IncludeChildren, + StatementBase, + type StatementNode +} from './shared/Node'; export default class LabeledStatement extends StatementBase { - body!: StatementNode; - label!: Identifier; - type!: NodeType.tLabeledStatement; + declare body: StatementNode; + declare label: Identifier; + declare type: NodeType.tLabeledStatement; - hasEffects(context: HasEffectsContext) { - const brokenFlow = context.brokenFlow; + hasEffects(context: HasEffectsContext): boolean { + const { brokenFlow, includedLabels } = context; context.ignore.labels.add(this.label.name); - if (this.body.hasEffects(context)) return true; - context.ignore.labels.delete(this.label.name); - if (context.includedLabels.has(this.label.name)) { - context.includedLabels.delete(this.label.name); - context.brokenFlow = brokenFlow; + context.includedLabels = new Set(); + let bodyHasEffects = false; + if (this.body.hasEffects(context)) { + bodyHasEffects = true; + } else { + context.ignore.labels.delete(this.label.name); + if (context.includedLabels.has(this.label.name)) { + context.includedLabels.delete(this.label.name); + context.brokenFlow = brokenFlow; + } } - return false; + context.includedLabels = new Set([...includedLabels, ...context.includedLabels]); + return bodyHasEffects; } - include(context: InclusionContext, includeChildrenRecursively: IncludeChildren) { - this.included = true; - const brokenFlow = context.brokenFlow; + include(context: InclusionContext, includeChildrenRecursively: IncludeChildren): void { + if (!this.included) this.includeNode(context); + const { brokenFlow, includedLabels } = context; + context.includedLabels = new Set(); this.body.include(context, includeChildrenRecursively); if (includeChildrenRecursively || context.includedLabels.has(this.label.name)) { - this.label.include(); + this.label.include(context, includeChildrenRecursively); context.includedLabels.delete(this.label.name); context.brokenFlow = brokenFlow; } + context.includedLabels = new Set([...includedLabels, ...context.includedLabels]); } - render(code: MagicString, options: RenderOptions) { + includeNode(context: InclusionContext) { + this.included = true; + this.body.includePath(UNKNOWN_PATH, context); + } + + render(code: MagicString, options: RenderOptions): void { if (this.label.included) { this.label.render(code, options); } else { @@ -52,3 +71,5 @@ export default class LabeledStatement extends StatementBase { this.body.render(code, options); } } + +LabeledStatement.prototype.applyDeoptimizations = doNotDeoptimize; diff --git a/src/ast/nodes/Literal.ts b/src/ast/nodes/Literal.ts index fc55458ea11..9ac887b537d 100644 --- a/src/ast/nodes/Literal.ts +++ b/src/ast/nodes/Literal.ts @@ -1,85 +1,111 @@ -import MagicString from 'magic-string'; -import { CallOptions } from '../CallOptions'; -import { HasEffectsContext } from '../ExecutionContext'; -import { ObjectPath } from '../utils/PathTracker'; +import type MagicString from 'magic-string'; +import type { HasEffectsContext } from '../ExecutionContext'; +import type { NodeInteraction } from '../NodeInteractions'; +import { + INTERACTION_ACCESSED, + INTERACTION_ASSIGNED, + INTERACTION_CALLED +} from '../NodeInteractions'; +import type { ObjectPath } from '../utils/PathTracker'; import { getLiteralMembersForValue, getMemberReturnExpressionWhenCalled, hasMemberEffectWhenCalled, - LiteralValueOrUnknown, - MemberDescription, - UnknownValue, - UNKNOWN_EXPRESSION + type MemberDescription } from '../values'; -import * as NodeType from './NodeType'; -import { GenericEsTreeNode, NodeBase } from './shared/Node'; +import type * as NodeType from './NodeType'; +import { + type ExpressionEntity, + type LiteralValueOrUnknown, + UNKNOWN_RETURN_EXPRESSION, + UnknownValue +} from './shared/Expression'; +import { type GenericEsTreeNode, NodeBase, onlyIncludeSelf } from './shared/Node'; export type LiteralValue = string | boolean | null | number | RegExp | undefined; +export type LiteralValueOrBigInt = LiteralValue | bigint; -export default class Literal extends NodeBase { - regex?: { +export default class Literal< + T extends LiteralValueOrBigInt = LiteralValueOrBigInt +> extends NodeBase { + declare bigint?: string; + declare raw?: string; + declare regex?: { flags: string; pattern: string; }; - type!: NodeType.tLiteral; - value!: T; + declare type: NodeType.tLiteral; + declare value: T; + + declare private members: Record; - private members!: { [key: string]: MemberDescription }; + deoptimizeArgumentsOnInteractionAtPath(): void {} getLiteralValueAtPath(path: ObjectPath): LiteralValueOrUnknown { if ( path.length > 0 || // unknown literals can also be null but do not start with an "n" - (this.value === null && this.context.code.charCodeAt(this.start) !== 110) || + (this.value === null && this.scope.context.code.charCodeAt(this.start) !== 110) || typeof this.value === 'bigint' || // to support shims for regular expressions - this.context.code.charCodeAt(this.start) === 47 + this.scope.context.code.charCodeAt(this.start) === 47 ) { return UnknownValue; } return this.value; } - getReturnExpressionWhenCalledAtPath(path: ObjectPath) { - if (path.length !== 1) return UNKNOWN_EXPRESSION; + getReturnExpressionWhenCalledAtPath( + path: ObjectPath + ): [expression: ExpressionEntity, isPure: boolean] { + if (path.length !== 1) return UNKNOWN_RETURN_EXPRESSION; return getMemberReturnExpressionWhenCalled(this.members, path[0]); } - hasEffectsWhenAccessedAtPath(path: ObjectPath) { - if (this.value === null) { - return path.length > 0; - } - return path.length > 1; - } - - hasEffectsWhenAssignedAtPath(path: ObjectPath) { - return path.length > 0; - } - - hasEffectsWhenCalledAtPath( + hasEffectsOnInteractionAtPath( path: ObjectPath, - callOptions: CallOptions, + interaction: NodeInteraction, context: HasEffectsContext ): boolean { - if (path.length === 1) { - return hasMemberEffectWhenCalled(this.members, path[0], this.included, callOptions, context); + switch (interaction.type) { + case INTERACTION_ACCESSED: { + return path.length > (this.value === null ? 0 : 1); + } + case INTERACTION_ASSIGNED: { + return true; + } + case INTERACTION_CALLED: { + if ( + this.included && + this.value instanceof RegExp && + (this.value.global || this.value.sticky) + ) { + return true; + } + return ( + path.length !== 1 || + hasMemberEffectWhenCalled(this.members, path[0], interaction, context) + ); + } } - return true; } - initialise() { + initialise(): void { + super.initialise(); this.members = getLiteralMembersForValue(this.value); } - parseNode(esTreeNode: GenericEsTreeNode) { + parseNode(esTreeNode: GenericEsTreeNode): this { this.value = esTreeNode.value; this.regex = esTreeNode.regex; - super.parseNode(esTreeNode); + return super.parseNode(esTreeNode); } - render(code: MagicString) { + render(code: MagicString): void { if (typeof this.value === 'string') { (code.indentExclusionRanges as [number, number][]).push([this.start + 1, this.end - 1]); } } } + +Literal.prototype.includeNode = onlyIncludeSelf; diff --git a/src/ast/nodes/LogicalExpression.ts b/src/ast/nodes/LogicalExpression.ts index e19ba265c9e..2473132d8a5 100644 --- a/src/ast/nodes/LogicalExpression.ts +++ b/src/ast/nodes/LogicalExpression.ts @@ -1,167 +1,241 @@ -import MagicString from 'magic-string'; -import { BLANK } from '../../utils/blank'; +import type MagicString from 'magic-string'; +import { BLANK, EMPTY_ARRAY } from '../../utils/blank'; import { findFirstOccurrenceOutsideComment, + findLastWhiteSpaceReverse, findNonWhiteSpace, - NodeRenderOptions, + type NodeRenderOptions, removeLineBreaks, - RenderOptions + type RenderOptions } from '../../utils/renderHelpers'; -import { removeAnnotations } from '../../utils/treeshakeNode'; -import { CallOptions } from '../CallOptions'; -import { DeoptimizableEntity } from '../DeoptimizableEntity'; -import { HasEffectsContext, InclusionContext } from '../ExecutionContext'; +import type { DeoptimizableEntity } from '../DeoptimizableEntity'; +import type { HasEffectsContext, InclusionContext } from '../ExecutionContext'; +import { createInclusionContext } from '../ExecutionContext'; +import type { NodeInteraction, NodeInteractionCalled } from '../NodeInteractions'; import { EMPTY_PATH, - ObjectPath, - PathTracker, + type EntityPathTracker, + type ObjectPath, SHARED_RECURSION_TRACKER, UNKNOWN_PATH } from '../utils/PathTracker'; -import { LiteralValueOrUnknown, UnknownValue } from '../values'; -import CallExpression from './CallExpression'; -import * as NodeType from './NodeType'; -import { ExpressionEntity } from './shared/Expression'; +import { tryCastLiteralValueToBoolean } from '../utils/tryCastLiteralValueToBoolean'; +import type * as NodeType from './NodeType'; +import { Flag, isFlagSet, setFlag } from './shared/BitFlags'; +import { + type ExpressionEntity, + type LiteralValueOrUnknown, + UnknownFalsyValue, + UnknownTruthyValue, + UnknownValue +} from './shared/Expression'; import { MultiExpression } from './shared/MultiExpression'; -import { ExpressionNode, IncludeChildren, NodeBase } from './shared/Node'; +import { + doNotDeoptimize, + type ExpressionNode, + type IncludeChildren, + NodeBase, + onlyIncludeSelfNoDeoptimize +} from './shared/Node'; export type LogicalOperator = '||' | '&&' | '??'; export default class LogicalExpression extends NodeBase implements DeoptimizableEntity { - left!: ExpressionNode; - operator!: LogicalOperator; - right!: ExpressionNode; - type!: NodeType.tLogicalExpression; + declare left: ExpressionNode; + declare operator: LogicalOperator; + declare right: ExpressionNode; + declare type: NodeType.tLogicalExpression; + + //private isBranchResolutionAnalysed = false; + private get isBranchResolutionAnalysed(): boolean { + return isFlagSet(this.flags, Flag.isBranchResolutionAnalysed); + } + private set isBranchResolutionAnalysed(value: boolean) { + this.flags = setFlag(this.flags, Flag.isBranchResolutionAnalysed, value); + } // We collect deoptimization information if usedBranch !== null private expressionsToBeDeoptimized: DeoptimizableEntity[] = []; - private isBranchResolutionAnalysed = false; - private unusedBranch: ExpressionNode | null = null; private usedBranch: ExpressionNode | null = null; - private wasPathDeoptimizedWhileOptimized = false; - bind() { - super.bind(); - // ensure the usedBranch is set for the tree-shaking passes - this.getUsedBranch(); + private get hasDeoptimizedCache(): boolean { + return isFlagSet(this.flags, Flag.hasDeoptimizedCache); + } + private set hasDeoptimizedCache(value: boolean) { + this.flags = setFlag(this.flags, Flag.hasDeoptimizedCache, value); } - deoptimizeCache() { - if (this.usedBranch !== null) { + deoptimizeArgumentsOnInteractionAtPath( + interaction: NodeInteraction, + path: ObjectPath, + recursionTracker: EntityPathTracker + ): void { + this.left.deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker); + this.right.deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker); + } + + deoptimizeCache(): void { + if (this.hasDeoptimizedCache) return; + this.hasDeoptimizedCache = true; + if (this.usedBranch) { + const unusedBranch = this.usedBranch === this.left ? this.right : this.left; this.usedBranch = null; - const expressionsToBeDeoptimized = this.expressionsToBeDeoptimized; - this.expressionsToBeDeoptimized = []; - if (this.wasPathDeoptimizedWhileOptimized) { - this.unusedBranch!.deoptimizePath(UNKNOWN_PATH); - } - for (const expression of expressionsToBeDeoptimized) { - expression.deoptimizeCache(); + unusedBranch.deoptimizePath(UNKNOWN_PATH); + if (this.included) { + // As we are not tracking inclusions, we just include everything + unusedBranch.includePath(UNKNOWN_PATH, createInclusionContext()); } } + const { + scope: { context }, + expressionsToBeDeoptimized + } = this; + this.expressionsToBeDeoptimized = EMPTY_ARRAY as unknown as DeoptimizableEntity[]; + for (const expression of expressionsToBeDeoptimized) { + expression.deoptimizeCache(); + } + // Request another pass because we need to ensure "include" runs again if + // it is rendered + context.requestTreeshakingPass(); } - deoptimizePath(path: ObjectPath) { + deoptimizePath(path: ObjectPath): void { const usedBranch = this.getUsedBranch(); - if (usedBranch === null) { + if (usedBranch) { + usedBranch.deoptimizePath(path); + } else { this.left.deoptimizePath(path); this.right.deoptimizePath(path); - } else { - this.wasPathDeoptimizedWhileOptimized = true; - usedBranch.deoptimizePath(path); } } getLiteralValueAtPath( path: ObjectPath, - recursionTracker: PathTracker, + recursionTracker: EntityPathTracker, origin: DeoptimizableEntity ): LiteralValueOrUnknown { + if (origin === this) return UnknownValue; const usedBranch = this.getUsedBranch(); - if (usedBranch === null) return UnknownValue; - this.expressionsToBeDeoptimized.push(origin); - return usedBranch.getLiteralValueAtPath(path, recursionTracker, origin); + if (usedBranch) { + this.expressionsToBeDeoptimized.push(origin); + return usedBranch.getLiteralValueAtPath(path, recursionTracker, origin); + } else if (!this.hasDeoptimizedCache && !path.length) { + const rightValue = this.right.getLiteralValueAtPath(path, recursionTracker, origin); + const booleanOrUnknown = tryCastLiteralValueToBoolean(rightValue); + if (typeof booleanOrUnknown !== 'symbol') { + if (!booleanOrUnknown && this.operator === '&&') { + this.expressionsToBeDeoptimized.push(origin); + return UnknownFalsyValue; + } + if (booleanOrUnknown && this.operator === '||') { + this.expressionsToBeDeoptimized.push(origin); + return UnknownTruthyValue; + } + } + } + return UnknownValue; } getReturnExpressionWhenCalledAtPath( path: ObjectPath, - recursionTracker: PathTracker, + interaction: NodeInteractionCalled, + recursionTracker: EntityPathTracker, origin: DeoptimizableEntity - ): ExpressionEntity { + ): [expression: ExpressionEntity, isPure: boolean] { const usedBranch = this.getUsedBranch(); - if (usedBranch === null) - return new MultiExpression([ - this.left.getReturnExpressionWhenCalledAtPath(path, recursionTracker, origin), - this.right.getReturnExpressionWhenCalledAtPath(path, recursionTracker, origin) - ]); - this.expressionsToBeDeoptimized.push(origin); - return usedBranch.getReturnExpressionWhenCalledAtPath(path, recursionTracker, origin); + if (usedBranch) { + this.expressionsToBeDeoptimized.push(origin); + return usedBranch.getReturnExpressionWhenCalledAtPath( + path, + interaction, + recursionTracker, + origin + ); + } + return [ + new MultiExpression([ + this.left.getReturnExpressionWhenCalledAtPath( + path, + interaction, + recursionTracker, + origin + )[0], + this.right.getReturnExpressionWhenCalledAtPath( + path, + interaction, + recursionTracker, + origin + )[0] + ]), + false + ]; } hasEffects(context: HasEffectsContext): boolean { if (this.left.hasEffects(context)) { return true; } - if (this.usedBranch !== this.left) { + if (this.getUsedBranch() !== this.left) { return this.right.hasEffects(context); } return false; } - hasEffectsWhenAccessedAtPath(path: ObjectPath, context: HasEffectsContext): boolean { - if (path.length === 0) return false; - if (this.usedBranch === null) { - return ( - this.left.hasEffectsWhenAccessedAtPath(path, context) || - this.right.hasEffectsWhenAccessedAtPath(path, context) - ); - } - return this.usedBranch.hasEffectsWhenAccessedAtPath(path, context); - } - - hasEffectsWhenAssignedAtPath(path: ObjectPath, context: HasEffectsContext): boolean { - if (path.length === 0) return true; - if (this.usedBranch === null) { - return ( - this.left.hasEffectsWhenAssignedAtPath(path, context) || - this.right.hasEffectsWhenAssignedAtPath(path, context) - ); - } - return this.usedBranch.hasEffectsWhenAssignedAtPath(path, context); - } - - hasEffectsWhenCalledAtPath( + hasEffectsOnInteractionAtPath( path: ObjectPath, - callOptions: CallOptions, + interaction: NodeInteraction, context: HasEffectsContext ): boolean { - if (this.usedBranch === null) { - return ( - this.left.hasEffectsWhenCalledAtPath(path, callOptions, context) || - this.right.hasEffectsWhenCalledAtPath(path, callOptions, context) - ); + const usedBranch = this.getUsedBranch(); + if (usedBranch) { + return usedBranch.hasEffectsOnInteractionAtPath(path, interaction, context); } - return this.usedBranch.hasEffectsWhenCalledAtPath(path, callOptions, context); + return ( + this.left.hasEffectsOnInteractionAtPath(path, interaction, context) || + this.right.hasEffectsOnInteractionAtPath(path, interaction, context) + ); } - include(context: InclusionContext, includeChildrenRecursively: IncludeChildren) { + include(context: InclusionContext, includeChildrenRecursively: IncludeChildren): void { this.included = true; + const usedBranch = this.getUsedBranch(); if ( includeChildrenRecursively || - (this.usedBranch === this.right && this.left.shouldBeIncluded(context)) || - this.usedBranch === null + !usedBranch || + (usedBranch === this.right && this.left.shouldBeIncluded(context)) ) { this.left.include(context, includeChildrenRecursively); this.right.include(context, includeChildrenRecursively); } else { - this.usedBranch.include(context, includeChildrenRecursively); + usedBranch.include(context, includeChildrenRecursively); + } + } + + includePath(path: ObjectPath, context: InclusionContext): void { + this.included = true; + const usedBranch = this.getUsedBranch(); + if (!usedBranch || (usedBranch === this.right && this.left.shouldBeIncluded(context))) { + this.left.includePath(path, context); + this.right.includePath(path, context); + } else { + usedBranch.includePath(path, context); } } + removeAnnotations(code: MagicString) { + this.left.removeAnnotations(code); + } + render( code: MagicString, options: RenderOptions, - { renderedParentType, isCalleeOfRenderedParent, preventASI }: NodeRenderOptions = BLANK - ) { + { + isCalleeOfRenderedParent, + preventASI, + renderedParentType, + renderedSurroundingElement + }: NodeRenderOptions = BLANK + ): void { if (!this.left.included || !this.right.included) { const operatorPos = findFirstOccurrenceOutsideComment( code.original, @@ -174,19 +248,21 @@ export default class LogicalExpression extends NodeBase implements Deoptimizable if (preventASI) { removeLineBreaks(code, removePos, this.right.start); } + this.left.removeAnnotations(code); } else { - code.remove(operatorPos, this.end); + code.remove(findLastWhiteSpaceReverse(code.original, this.left.end, operatorPos), this.end); } - removeAnnotations(this, code); - this.usedBranch!.render(code, options, { - isCalleeOfRenderedParent: renderedParentType - ? isCalleeOfRenderedParent - : (this.parent as CallExpression).callee === this, + this.getUsedBranch()!.render(code, options, { + isCalleeOfRenderedParent, preventASI, - renderedParentType: renderedParentType || this.parent.type + renderedParentType: renderedParentType || this.parent.type, + renderedSurroundingElement: renderedSurroundingElement || this.parent.type }); } else { - this.left.render(code, options, { preventASI }); + this.left.render(code, options, { + preventASI, + renderedSurroundingElement + }); this.right.render(code, options); } } @@ -195,22 +271,24 @@ export default class LogicalExpression extends NodeBase implements Deoptimizable if (!this.isBranchResolutionAnalysed) { this.isBranchResolutionAnalysed = true; const leftValue = this.left.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, this); - if (leftValue === UnknownValue) { + const booleanOrUnknown = tryCastLiteralValueToBoolean(leftValue); + if ( + typeof booleanOrUnknown === 'symbol' || + (this.operator === '??' && typeof leftValue === 'symbol') + ) { return null; } else { - if ( - (this.operator === '||' && leftValue) || - (this.operator === '&&' && !leftValue) || + this.usedBranch = + (this.operator === '||' && booleanOrUnknown) || + (this.operator === '&&' && !booleanOrUnknown) || (this.operator === '??' && leftValue != null) - ) { - this.usedBranch = this.left; - this.unusedBranch = this.right; - } else { - this.usedBranch = this.right; - this.unusedBranch = this.left; - } + ? this.left + : this.right; } } return this.usedBranch; } } + +LogicalExpression.prototype.includeNode = onlyIncludeSelfNoDeoptimize; +LogicalExpression.prototype.applyDeoptimizations = doNotDeoptimize; diff --git a/src/ast/nodes/MemberExpression.ts b/src/ast/nodes/MemberExpression.ts index 90ecfb4453a..80a52580bed 100644 --- a/src/ast/nodes/MemberExpression.ts +++ b/src/ast/nodes/MemberExpression.ts @@ -1,31 +1,59 @@ -import MagicString from 'magic-string'; -import { NormalizedTreeshakingOptions } from '../../rollup/types'; -import { BLANK } from '../../utils/blank'; -import relativeId from '../../utils/relativeId'; -import { NodeRenderOptions, RenderOptions } from '../../utils/renderHelpers'; -import { CallOptions } from '../CallOptions'; -import { DeoptimizableEntity } from '../DeoptimizableEntity'; -import { HasEffectsContext, InclusionContext } from '../ExecutionContext'; +import type MagicString from 'magic-string'; +import type { AstContext } from '../../Module'; +import type { NormalizedTreeshakingOptions } from '../../rollup/types'; +import { BLANK, EMPTY_ARRAY } from '../../utils/blank'; +import { LOGLEVEL_WARN } from '../../utils/logging'; +import { logIllegalImportReassignment, logMissingExport } from '../../utils/logs'; +import type { NodeRenderOptions, RenderOptions } from '../../utils/renderHelpers'; +import type { DeoptimizableEntity } from '../DeoptimizableEntity'; +import type { HasEffectsContext, InclusionContext } from '../ExecutionContext'; +import { createInclusionContext } from '../ExecutionContext'; +import type { + NodeInteraction, + NodeInteractionAccessed, + NodeInteractionAssigned, + NodeInteractionCalled +} from '../NodeInteractions'; +import { + INTERACTION_ACCESSED, + INTERACTION_ASSIGNED, + NODE_INTERACTION_UNKNOWN_ACCESS +} from '../NodeInteractions'; +import { MAX_PATH_DEPTH } from '../utils/limitPathLength'; import { EMPTY_PATH, - ObjectPath, - ObjectPathKey, - PathTracker, + type EntityPathTracker, + type ObjectPath, + type ObjectPathKey, SHARED_RECURSION_TRACKER, + UNKNOWN_PATH, UnknownKey, - UNKNOWN_PATH + UnknownNonAccessorKey, + WELL_KNOWN_SYMBOLS } from '../utils/PathTracker'; -import { LiteralValueOrUnknown, UnknownValue } from '../values'; +import { UNDEFINED_EXPRESSION } from '../values'; import ExternalVariable from '../variables/ExternalVariable'; -import NamespaceVariable from '../variables/NamespaceVariable'; -import Variable from '../variables/Variable'; +import type NamespaceVariable from '../variables/NamespaceVariable'; +import type { PromiseHandler } from '../variables/PromiseHandler'; +import type Variable from '../variables/Variable'; import Identifier from './Identifier'; import Literal from './Literal'; -import * as NodeType from './NodeType'; -import PrivateIdentifier from './PrivateIdentifier'; -import { ExpressionNode, IncludeChildren, NodeBase } from './shared/Node'; -import SpreadElement from './SpreadElement'; -import Super from './Super'; +import type * as NodeType from './NodeType'; +import type PrivateIdentifier from './PrivateIdentifier'; +import { Flag, isFlagSet, setFlag } from './shared/BitFlags'; +import { getChainElementLiteralValueAtPath } from './shared/chainElements'; +import { + deoptimizeInteraction, + type ExpressionEntity, + includeInteraction, + type LiteralValueOrUnknown, + UNKNOWN_RETURN_EXPRESSION, + UnknownValue +} from './shared/Expression'; +import type { ChainElement, ExpressionNode, IncludeChildren, SkippedChain } from './shared/Node'; +import { IS_SKIPPED_CHAIN, NodeBase } from './shared/Node'; +import type { PatternNode } from './shared/Pattern'; +import type Super from './Super'; function getResolvablePropertyKey(memberExpression: MemberExpression): string | null { return memberExpression.computed @@ -70,179 +98,360 @@ function getStringFromPath(path: PathWithPositions): string { return pathString; } -export default class MemberExpression extends NodeBase implements DeoptimizableEntity { - computed!: boolean; - object!: ExpressionNode | Super; - optional!: boolean; - property!: ExpressionNode | PrivateIdentifier; - propertyKey!: ObjectPathKey | null; - type!: NodeType.tMemberExpression; +export default class MemberExpression + extends NodeBase + implements DeoptimizableEntity, ChainElement, PatternNode +{ + declare object: ExpressionNode | Super; + declare property: ExpressionNode | PrivateIdentifier; + declare propertyKey: ObjectPathKey; + declare type: NodeType.tMemberExpression; + promiseHandler: PromiseHandler | null = null; variable: Variable | null = null; - - private bound = false; + declare protected assignmentInteraction: NodeInteractionAssigned; + declare private accessInteraction: NodeInteractionAccessed; private expressionsToBeDeoptimized: DeoptimizableEntity[] = []; - private replacement: string | null = null; - private wasPathDeoptimizedWhileOptimized = false; + declare private dynamicPropertyKey: ObjectPathKey | null; + + get computed(): boolean { + return isFlagSet(this.flags, Flag.computed); + } + set computed(value: boolean) { + this.flags = setFlag(this.flags, Flag.computed, value); + } + + get optional(): boolean { + return isFlagSet(this.flags, Flag.optional); + } + set optional(value: boolean) { + this.flags = setFlag(this.flags, Flag.optional, value); + } + + private get assignmentDeoptimized(): boolean { + return isFlagSet(this.flags, Flag.assignmentDeoptimized); + } + private set assignmentDeoptimized(value: boolean) { + this.flags = setFlag(this.flags, Flag.assignmentDeoptimized, value); + } + + private get bound(): boolean { + return isFlagSet(this.flags, Flag.bound); + } + private set bound(value: boolean) { + this.flags = setFlag(this.flags, Flag.bound, value); + } - bind() { - if (this.bound) return; + private get isUndefined(): boolean { + return isFlagSet(this.flags, Flag.isUndefined); + } + private set isUndefined(value: boolean) { + this.flags = setFlag(this.flags, Flag.isUndefined, value); + } + + bind(): void { this.bound = true; const path = getPathIfNotComputed(this); const baseVariable = path && this.scope.findVariable(path[0].key); - if (baseVariable && baseVariable.isNamespace) { - const resolvedVariable = this.resolveNamespaceVariables(baseVariable, path!.slice(1)); + if (baseVariable?.isNamespace) { + const resolvedVariable = resolveNamespaceVariables( + baseVariable, + path!.slice(1), + this.scope.context + ); if (!resolvedVariable) { super.bind(); - } else if (typeof resolvedVariable === 'string') { - this.replacement = resolvedVariable; + } else if (resolvedVariable === 'undefined') { + this.isUndefined = true; } else { this.variable = resolvedVariable; this.scope.addNamespaceMemberAccess(getStringFromPath(path!), resolvedVariable); } } else { super.bind(); - // ensure the propertyKey is set for the tree-shaking passes - this.getPropertyKey(); } } - deoptimizeCache() { - const expressionsToBeDeoptimized = this.expressionsToBeDeoptimized; - this.expressionsToBeDeoptimized = []; - this.propertyKey = UnknownKey; - if (this.wasPathDeoptimizedWhileOptimized) { - this.object.deoptimizePath(UNKNOWN_PATH); + deoptimizeArgumentsOnInteractionAtPath( + interaction: NodeInteraction, + path: ObjectPath, + recursionTracker: EntityPathTracker + ): void { + if (this.promiseHandler) { + this.promiseHandler.deoptimizeArgumentsOnInteractionAtPath( + interaction, + path, + recursionTracker + ); + } else if (this.variable) { + this.variable.deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker); + } else if (!this.isUndefined) { + if (path.length < MAX_PATH_DEPTH) { + this.object.deoptimizeArgumentsOnInteractionAtPath( + interaction, + this.propertyKey === UnknownKey ? UNKNOWN_PATH : [this.propertyKey, ...path], + recursionTracker + ); + } else { + deoptimizeInteraction(interaction); + } + } + } + + deoptimizeAssignment(destructuredInitPath: ObjectPath, init: ExpressionEntity) { + this.deoptimizePath(EMPTY_PATH); + init.deoptimizePath([...destructuredInitPath, UnknownKey]); + } + + deoptimizeCache(): void { + if (this.propertyKey === this.dynamicPropertyKey) return; + const { expressionsToBeDeoptimized, object } = this; + this.expressionsToBeDeoptimized = EMPTY_ARRAY as unknown as DeoptimizableEntity[]; + this.dynamicPropertyKey = this.propertyKey; + object.deoptimizePath(UNKNOWN_PATH); + if (this.included) { + object.includePath(UNKNOWN_PATH, createInclusionContext()); } for (const expression of expressionsToBeDeoptimized) { expression.deoptimizeCache(); } } - deoptimizePath(path: ObjectPath) { - if (!this.bound) this.bind(); + deoptimizePath(path: ObjectPath): void { if (path.length === 0) this.disallowNamespaceReassignment(); if (this.variable) { this.variable.deoptimizePath(path); - } else { - const propertyKey = this.getPropertyKey(); - if (propertyKey === UnknownKey) { - this.object.deoptimizePath(UNKNOWN_PATH); - } else { - this.wasPathDeoptimizedWhileOptimized = true; - this.object.deoptimizePath([propertyKey, ...path]); - } + } else if (!this.isUndefined) { + const { propertyKey } = this; + this.object.deoptimizePath([ + propertyKey === UnknownKey ? UnknownNonAccessorKey : propertyKey, + ...(path.length < MAX_PATH_DEPTH + ? path + : [...path.slice(0, MAX_PATH_DEPTH), UnknownKey as ObjectPathKey]) + ]); } } getLiteralValueAtPath( path: ObjectPath, - recursionTracker: PathTracker, + recursionTracker: EntityPathTracker, origin: DeoptimizableEntity ): LiteralValueOrUnknown { - if (!this.bound) this.bind(); - if (this.variable !== null) { + if (this.variable) { return this.variable.getLiteralValueAtPath(path, recursionTracker, origin); } - this.expressionsToBeDeoptimized.push(origin); - return this.object.getLiteralValueAtPath( - [this.getPropertyKey(), ...path], - recursionTracker, - origin - ); + if (this.isUndefined) { + return undefined; + } + const propertyKey = this.getDynamicPropertyKey(); + if (propertyKey !== UnknownKey && path.length < MAX_PATH_DEPTH) { + if (propertyKey !== this.propertyKey) this.expressionsToBeDeoptimized.push(origin); + return this.object.getLiteralValueAtPath([propertyKey, ...path], recursionTracker, origin); + } + return UnknownValue; + } + + getLiteralValueAtPathAsChainElement( + path: ObjectPath, + recursionTracker: EntityPathTracker, + origin: DeoptimizableEntity + ): LiteralValueOrUnknown | SkippedChain { + if (this.variable) { + return this.variable.getLiteralValueAtPath(path, recursionTracker, origin); + } + if (this.isUndefined) { + return undefined; + } + return getChainElementLiteralValueAtPath(this, this.object, path, recursionTracker, origin); } getReturnExpressionWhenCalledAtPath( path: ObjectPath, - recursionTracker: PathTracker, + interaction: NodeInteractionCalled, + recursionTracker: EntityPathTracker, origin: DeoptimizableEntity - ) { - if (!this.bound) this.bind(); - if (this.variable !== null) { - return this.variable.getReturnExpressionWhenCalledAtPath(path, recursionTracker, origin); + ): [expression: ExpressionEntity, isPure: boolean] { + if (this.variable) { + return this.variable.getReturnExpressionWhenCalledAtPath( + path, + interaction, + recursionTracker, + origin + ); } - this.expressionsToBeDeoptimized.push(origin); - return this.object.getReturnExpressionWhenCalledAtPath( - [this.getPropertyKey(), ...path], - recursionTracker, - origin - ); + if (this.isUndefined) { + return [UNDEFINED_EXPRESSION, false]; + } + const propertyKey = this.getDynamicPropertyKey(); + if (propertyKey !== UnknownKey && path.length < MAX_PATH_DEPTH) { + if (propertyKey !== this.propertyKey) this.expressionsToBeDeoptimized.push(origin); + return this.object.getReturnExpressionWhenCalledAtPath( + [propertyKey, ...path], + interaction, + recursionTracker, + origin + ); + } + return UNKNOWN_RETURN_EXPRESSION; } hasEffects(context: HasEffectsContext): boolean { - const propertyReadSideEffects = (this.context.options.treeshake as NormalizedTreeshakingOptions) - .propertyReadSideEffects; + if (!this.deoptimized) this.applyDeoptimizations(); return ( - propertyReadSideEffects === 'always' || this.property.hasEffects(context) || this.object.hasEffects(context) || - (propertyReadSideEffects && - this.object.hasEffectsWhenAccessedAtPath([this.propertyKey!], context)) + this.hasAccessEffect(context) ); } - hasEffectsWhenAccessedAtPath(path: ObjectPath, context: HasEffectsContext): boolean { - if (path.length === 0) return false; - if (this.variable !== null) { - return this.variable.hasEffectsWhenAccessedAtPath(path, context); + hasEffectsAsChainElement(context: HasEffectsContext): boolean | SkippedChain { + if (this.variable || this.isUndefined) return this.hasEffects(context); + const objectHasEffects = + 'hasEffectsAsChainElement' in this.object + ? (this.object as ChainElement).hasEffectsAsChainElement(context) + : this.object.hasEffects(context); + if (objectHasEffects === IS_SKIPPED_CHAIN) return IS_SKIPPED_CHAIN; + if ( + this.optional && + this.object.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, this) == null + ) { + return objectHasEffects || IS_SKIPPED_CHAIN; } - return this.object.hasEffectsWhenAccessedAtPath([this.propertyKey!, ...path], context); + // We only apply deoptimizations lazily once we know we are not skipping + if (!this.deoptimized) this.applyDeoptimizations(); + return objectHasEffects || this.property.hasEffects(context) || this.hasAccessEffect(context); } - hasEffectsWhenAssignedAtPath(path: ObjectPath, context: HasEffectsContext): boolean { - if (this.variable !== null) { - return this.variable.hasEffectsWhenAssignedAtPath(path, context); - } - return this.object.hasEffectsWhenAssignedAtPath([this.propertyKey!, ...path], context); + hasEffectsAsAssignmentTarget(context: HasEffectsContext, checkAccess: boolean): boolean { + if (checkAccess && !this.deoptimized) this.applyDeoptimizations(); + if (!this.assignmentDeoptimized) this.applyAssignmentDeoptimization(); + return ( + this.property.hasEffects(context) || + this.object.hasEffects(context) || + (checkAccess && this.hasAccessEffect(context)) || + this.hasEffectsOnInteractionAtPath(EMPTY_PATH, this.assignmentInteraction, context) + ); } - hasEffectsWhenCalledAtPath( + hasEffectsOnInteractionAtPath( path: ObjectPath, - callOptions: CallOptions, + interaction: NodeInteraction, context: HasEffectsContext ): boolean { - if (this.variable !== null) { - return this.variable.hasEffectsWhenCalledAtPath(path, callOptions, context); + if (this.variable) { + return this.variable.hasEffectsOnInteractionAtPath(path, interaction, context); + } + if (this.isUndefined) { + return true; } - return this.object.hasEffectsWhenCalledAtPath( - [this.propertyKey!, ...path], - callOptions, - context + if (path.length < MAX_PATH_DEPTH) { + return this.object.hasEffectsOnInteractionAtPath( + [this.getDynamicPropertyKey(), ...path], + interaction, + context + ); + } + return true; + } + + hasEffectsWhenDestructuring( + context: HasEffectsContext, + destructuredInitPath: ObjectPath, + init: ExpressionEntity + ): boolean { + return ( + destructuredInitPath.length > 0 && + init.hasEffectsOnInteractionAtPath( + destructuredInitPath, + NODE_INTERACTION_UNKNOWN_ACCESS, + context + ) ); } - include(context: InclusionContext, includeChildrenRecursively: IncludeChildren) { - if (!this.included) { - this.included = true; - if (this.variable !== null) { - this.context.includeVariableInModule(this.variable); - } - } + include(context: InclusionContext, includeChildrenRecursively: IncludeChildren): void { + if (!this.included) this.includeNode(context); this.object.include(context, includeChildrenRecursively); this.property.include(context, includeChildrenRecursively); + if (includeChildrenRecursively) { + this.variable?.includePath(UNKNOWN_PATH, context); + } } - includeCallArguments(context: InclusionContext, args: (ExpressionNode | SpreadElement)[]): void { + includeNode(context: InclusionContext) { + this.included = true; + if (!this.deoptimized) this.applyDeoptimizations(); if (this.variable) { - this.variable.includeCallArguments(context, args); - } else { - super.includeCallArguments(context, args); + this.scope.context.includeVariableInModule(this.variable, EMPTY_PATH, context); + } else if (!this.isUndefined) { + this.object.includePath([this.propertyKey], context); } } - initialise() { - this.propertyKey = getResolvablePropertyKey(this); + includeNodeAsAssignmentTarget(context: InclusionContext) { + this.included = true; + if (!this.assignmentDeoptimized) this.applyAssignmentDeoptimization(); + if (this.variable) { + this.scope.context.includeVariableInModule(this.variable, EMPTY_PATH, context); + } else if (!this.isUndefined) { + this.object.includePath([this.propertyKey], context); + } } - mayModifyThisWhenCalledAtPath(path: ObjectPath, recursionTracker: PathTracker) { + includePath(path: ObjectPath, context: InclusionContext): void { + if (!this.included) this.includeNode(context); if (this.variable) { - return this.variable.mayModifyThisWhenCalledAtPath(path, recursionTracker); + this.variable?.includePath(path, context); + } else if (!this.isUndefined) { + this.object.includePath( + [ + this.propertyKey, + ...(path.length < MAX_PATH_DEPTH + ? path + : [...path.slice(0, MAX_PATH_DEPTH), UnknownKey as ObjectPathKey]) + ], + context + ); } - return this.object.mayModifyThisWhenCalledAtPath( - [this.propertyKey as ObjectPathKey].concat(path), - recursionTracker + } + + includeAsAssignmentTarget( + context: InclusionContext, + includeChildrenRecursively: IncludeChildren, + deoptimizeAccess: boolean + ): void { + if (!this.included) this.includeNodeAsAssignmentTarget(context); + if (deoptimizeAccess && !this.deoptimized) this.applyDeoptimizations(); + this.object.include(context, includeChildrenRecursively); + this.property.include(context, includeChildrenRecursively); + } + + includeCallArguments(interaction: NodeInteractionCalled, context: InclusionContext): void { + if (this.promiseHandler) { + this.promiseHandler.includeCallArguments(interaction, context); + } else if (this.variable) { + this.variable.includeCallArguments(interaction, context); + } else { + includeInteraction(interaction, context); + } + } + + includeDestructuredIfNecessary(): boolean { + /* istanbul ignore next */ + this.scope.context.error( + { + message: 'includeDestructuredIfNecessary is currently not supported for MemberExpressions' + }, + this.start ); } + initialise(): void { + super.initialise(); + this.dynamicPropertyKey = getResolvablePropertyKey(this); + this.propertyKey = this.dynamicPropertyKey === null ? UnknownKey : this.dynamicPropertyKey; + this.accessInteraction = { args: [this.object], type: INTERACTION_ACCESSED }; + } + render( code: MagicString, options: RenderOptions, @@ -251,80 +460,150 @@ export default class MemberExpression extends NodeBase implements DeoptimizableE isCalleeOfRenderedParent, renderedSurroundingElement }: NodeRenderOptions = BLANK - ) { - const isCalleeOfDifferentParent = - renderedParentType === NodeType.CallExpression && isCalleeOfRenderedParent; - if (this.variable || this.replacement) { - let replacement = this.variable ? this.variable.getName() : this.replacement; - if (isCalleeOfDifferentParent) replacement = '0, ' + replacement; + ): void { + if (this.variable || this.isUndefined) { + const { + snippets: { getPropertyAccess } + } = options; + let replacement = this.variable ? this.variable.getName(getPropertyAccess) : 'undefined'; + if (renderedParentType && isCalleeOfRenderedParent) replacement = '0, ' + replacement; code.overwrite(this.start, this.end, replacement!, { contentOnly: true, storeName: true }); } else { - if (isCalleeOfDifferentParent) { + if (renderedParentType && isCalleeOfRenderedParent) { code.appendRight(this.start, '0, '); } - const surroundingElement = renderedParentType || renderedSurroundingElement; - this.object.render( - code, - options, - surroundingElement ? { renderedSurroundingElement: surroundingElement } : BLANK - ); + this.object.render(code, options, { renderedSurroundingElement }); this.property.render(code, options); } } + setAssignedValue(value: ExpressionEntity) { + this.assignmentInteraction = { + args: [this.object, value], + type: INTERACTION_ASSIGNED + }; + } + + applyDeoptimizations() { + this.deoptimized = true; + const { propertyReadSideEffects } = this.scope.context.options + .treeshake as NormalizedTreeshakingOptions; + if ( + // Namespaces are not bound and should not be deoptimized + this.bound && + propertyReadSideEffects && + !(this.variable || this.isUndefined || this.promiseHandler) + ) { + this.object.deoptimizeArgumentsOnInteractionAtPath( + this.accessInteraction, + [this.propertyKey], + SHARED_RECURSION_TRACKER + ); + this.scope.context.requestTreeshakingPass(); + } + if (this.variable) { + this.variable.addUsedPlace(this); + this.scope.context.requestTreeshakingPass(); + } + } + + private applyAssignmentDeoptimization(): void { + this.assignmentDeoptimized = true; + const { propertyReadSideEffects } = this.scope.context.options + .treeshake as NormalizedTreeshakingOptions; + if ( + // Namespaces are not bound and should not be deoptimized + this.bound && + propertyReadSideEffects && + !(this.variable || this.isUndefined) + ) { + this.object.deoptimizeArgumentsOnInteractionAtPath( + this.assignmentInteraction, + [this.propertyKey], + SHARED_RECURSION_TRACKER + ); + this.scope.context.requestTreeshakingPass(); + } + } + private disallowNamespaceReassignment() { if (this.object instanceof Identifier) { const variable = this.scope.findVariable(this.object.name); if (variable.isNamespace) { if (this.variable) { - this.context.includeVariableInModule(this.variable); + this.scope.context.includeVariableInModule( + this.variable, + UNKNOWN_PATH, + createInclusionContext() + ); } - this.context.warn( - { - code: 'ILLEGAL_NAMESPACE_REASSIGNMENT', - message: `Illegal reassignment to import '${this.object.name}'` - }, + this.scope.context.log( + LOGLEVEL_WARN, + logIllegalImportReassignment(this.object.name, this.scope.context.module.id), this.start ); } } } - private getPropertyKey(): ObjectPathKey { - if (this.propertyKey === null) { - this.propertyKey = UnknownKey; + private getDynamicPropertyKey(): ObjectPathKey { + if (this.dynamicPropertyKey === null) { + this.dynamicPropertyKey = this.propertyKey; const value = this.property.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, this); - return (this.propertyKey = value === UnknownValue ? UnknownKey : String(value)); + return (this.dynamicPropertyKey = + typeof value === 'symbol' + ? WELL_KNOWN_SYMBOLS.has(value) + ? value + : UnknownKey + : String(value)); } - return this.propertyKey; - } - - private resolveNamespaceVariables( - baseVariable: Variable, - path: PathWithPositions - ): Variable | string | null { - if (path.length === 0) return baseVariable; - if (!baseVariable.isNamespace || baseVariable instanceof ExternalVariable) return null; - const exportName = path[0].key; - const variable = (baseVariable as NamespaceVariable).context.traceExport(exportName); - if (!variable) { + return this.dynamicPropertyKey; + } + + private hasAccessEffect(context: HasEffectsContext) { + const { propertyReadSideEffects } = this.scope.context.options + .treeshake as NormalizedTreeshakingOptions; + return ( + !(this.variable || this.isUndefined) && + propertyReadSideEffects && + (propertyReadSideEffects === 'always' || + this.object.hasEffectsOnInteractionAtPath( + [this.getDynamicPropertyKey()], + this.accessInteraction, + context + )) + ); + } +} + +function resolveNamespaceVariables( + baseVariable: Variable, + path: PathWithPositions, + astContext: AstContext +): Variable | 'undefined' | null { + if (path.length === 0) return baseVariable; + if (!baseVariable.isNamespace || baseVariable instanceof ExternalVariable) return null; + const exportName = path[0].key; + const [variable, options] = (baseVariable as NamespaceVariable).context.traceExport(exportName); + if (!variable) { + if (path.length === 1) { const fileName = (baseVariable as NamespaceVariable).context.fileName; - this.context.warn( - { - code: 'MISSING_EXPORT', - exporter: relativeId(fileName), - importer: relativeId(this.context.fileName), - message: `'${exportName}' is not exported by '${relativeId(fileName)}'`, - missing: exportName, - url: `https://rollupjs.org/guide/en/#error-name-is-not-exported-by-module` - }, + astContext.log( + LOGLEVEL_WARN, + logMissingExport( + exportName, + astContext.module.id, + fileName, + !!options?.missingButExportExists + ), path[0].pos ); return 'undefined'; } - return this.resolveNamespaceVariables(variable, path.slice(1)); + return null; } + return resolveNamespaceVariables(variable, path.slice(1), astContext); } diff --git a/src/ast/nodes/MetaProperty.ts b/src/ast/nodes/MetaProperty.ts index faadbeb06e1..5a4672e83c9 100644 --- a/src/ast/nodes/MetaProperty.ts +++ b/src/ast/nodes/MetaProperty.ts @@ -1,46 +1,44 @@ -import MagicString from 'magic-string'; -import { InternalModuleFormat } from '../../rollup/types'; -import { warnDeprecation } from '../../utils/error'; +import type MagicString from 'magic-string'; +import type { InternalModuleFormat } from '../../rollup/types'; +import { escapeId } from '../../utils/escapeId'; +import type { GenerateCodeSnippets } from '../../utils/generateCodeSnippets'; +import { DOCUMENT_CURRENT_SCRIPT } from '../../utils/interopHelpers'; import { dirname, normalize, relative } from '../../utils/path'; -import { PluginDriver } from '../../utils/PluginDriver'; -import ChildScope from '../scopes/ChildScope'; -import { ObjectPathKey } from '../utils/PathTracker'; -import Identifier from './Identifier'; +import type { PluginDriver } from '../../utils/PluginDriver'; +import type { RenderOptions } from '../../utils/renderHelpers'; +import type { NodeInteraction } from '../NodeInteractions'; +import { INTERACTION_ACCESSED } from '../NodeInteractions'; +import type ChildScope from '../scopes/ChildScope'; +import type { ObjectPath } from '../utils/PathTracker'; +import type Identifier from './Identifier'; import MemberExpression from './MemberExpression'; -import * as NodeType from './NodeType'; +import type * as NodeType from './NodeType'; import { NodeBase } from './shared/Node'; -const ASSET_PREFIX = 'ROLLUP_ASSET_URL_'; -const CHUNK_PREFIX = 'ROLLUP_CHUNK_URL_'; const FILE_PREFIX = 'ROLLUP_FILE_URL_'; +const FILE_OBJ_PREFIX = 'ROLLUP_FILE_URL_OBJ_'; +const IMPORT = 'import'; export default class MetaProperty extends NodeBase { - meta!: Identifier; - property!: Identifier; - type!: NodeType.tMetaProperty; + declare meta: Identifier; + declare property: Identifier; + declare type: NodeType.tMetaProperty; - private metaProperty?: string | null; - - addAccessedGlobals( - format: InternalModuleFormat, - accessedGlobalsByScope: Map> - ) { - const metaProperty = this.metaProperty; - const accessedGlobals = (metaProperty && - (metaProperty.startsWith(FILE_PREFIX) || - metaProperty.startsWith(ASSET_PREFIX) || - metaProperty.startsWith(CHUNK_PREFIX)) - ? accessedFileUrlGlobals - : accessedMetaUrlGlobals)[format]; - if (accessedGlobals.length > 0) { - this.scope.addAccessedGlobals(accessedGlobals, accessedGlobalsByScope); - } - } + private metaProperty: string | null = null; + private preliminaryChunkId: string | null = null; + private referenceId: string | null = null; getReferencedFileName(outputPluginDriver: PluginDriver): string | null { - const metaProperty = this.metaProperty as string | null; - if (metaProperty && metaProperty.startsWith(FILE_PREFIX)) { - return outputPluginDriver.getFileName(metaProperty.substr(FILE_PREFIX.length)); + const { + meta: { name }, + metaProperty + } = this; + if (name === IMPORT) { + if (metaProperty?.startsWith(FILE_OBJ_PREFIX)) { + return outputPluginDriver.getFileName(metaProperty.slice(FILE_OBJ_PREFIX.length)); + } else if (metaProperty?.startsWith(FILE_PREFIX)) { + return outputPluginDriver.getFileName(metaProperty.slice(FILE_PREFIX.length)); + } } return null; } @@ -49,91 +47,58 @@ export default class MetaProperty extends NodeBase { return false; } - hasEffectsWhenAccessedAtPath(path: ObjectPathKey[]): boolean { - return path.length > 1; + hasEffectsOnInteractionAtPath(path: ObjectPath, { type }: NodeInteraction): boolean { + return path.length > 1 || type !== INTERACTION_ACCESSED; } - include() { - if (!this.included) { - this.included = true; - if (this.meta.name === 'import') { - this.context.addImportMeta(this); - const parent = this.parent; - this.metaProperty = - parent instanceof MemberExpression && typeof parent.propertyKey === 'string' - ? parent.propertyKey - : null; + include(): void { + if (!this.included) this.includeNode(); + } + + includeNode() { + this.included = true; + if (this.meta.name === IMPORT) { + this.scope.context.addImportMeta(this); + const parent = this.parent; + const metaProperty = (this.metaProperty = + parent instanceof MemberExpression && typeof parent.propertyKey === 'string' + ? parent.propertyKey + : null); + if (metaProperty?.startsWith(FILE_OBJ_PREFIX)) { + this.referenceId = metaProperty.slice(FILE_OBJ_PREFIX.length); + } else if (metaProperty?.startsWith(FILE_PREFIX)) { + this.referenceId = metaProperty.slice(FILE_PREFIX.length); } } } - renderFinalMechanism( - code: MagicString, - chunkId: string, - format: InternalModuleFormat, - outputPluginDriver: PluginDriver - ): void { - const parent = this.parent; - const metaProperty = this.metaProperty as string | null; - - if ( - metaProperty && - (metaProperty.startsWith(FILE_PREFIX) || - metaProperty.startsWith(ASSET_PREFIX) || - metaProperty.startsWith(CHUNK_PREFIX)) - ) { - let referenceId: string | null = null; - let assetReferenceId: string | null = null; - let chunkReferenceId: string | null = null; - let fileName: string; - if (metaProperty.startsWith(FILE_PREFIX)) { - referenceId = metaProperty.substr(FILE_PREFIX.length); - fileName = outputPluginDriver.getFileName(referenceId); - } else if (metaProperty.startsWith(ASSET_PREFIX)) { - warnDeprecation( - `Using the "${ASSET_PREFIX}" prefix to reference files is deprecated. Use the "${FILE_PREFIX}" prefix instead.`, - true, - this.context.options - ); - assetReferenceId = metaProperty.substr(ASSET_PREFIX.length); - fileName = outputPluginDriver.getFileName(assetReferenceId); - } else { - warnDeprecation( - `Using the "${CHUNK_PREFIX}" prefix to reference files is deprecated. Use the "${FILE_PREFIX}" prefix instead.`, - true, - this.context.options - ); - chunkReferenceId = metaProperty.substr(CHUNK_PREFIX.length); - fileName = outputPluginDriver.getFileName(chunkReferenceId); - } + render(code: MagicString, renderOptions: RenderOptions): void { + const { format, pluginDriver, snippets } = renderOptions; + const { + scope: { + context: { module } + }, + meta: { name }, + metaProperty, + parent, + preliminaryChunkId, + referenceId, + start, + end + } = this; + const { id: moduleId } = module; + + if (name !== IMPORT) return; + const chunkId = preliminaryChunkId!; + + if (referenceId) { + const fileName = pluginDriver.getFileName(referenceId); const relativePath = normalize(relative(dirname(chunkId), fileName)); - let replacement; - if (assetReferenceId !== null) { - replacement = outputPluginDriver.hookFirstSync('resolveAssetUrl', [ - { - assetFileName: fileName, - chunkId, - format, - moduleId: this.context.module.id, - relativeAssetPath: relativePath - } - ]); - } - if (!replacement) { - replacement = - outputPluginDriver.hookFirstSync('resolveFileUrl', [ - { - assetReferenceId, - chunkId, - chunkReferenceId, - fileName, - format, - moduleId: this.context.module.id, - referenceId: referenceId || assetReferenceId || chunkReferenceId!, - relativePath - } - ]) || relativeUrlMechanisms[format](relativePath); - } + const isUrlObject = !!metaProperty?.startsWith(FILE_OBJ_PREFIX); + const replacement = + pluginDriver.hookFirstSync('resolveFileUrl', [ + { chunkId, fileName, format, moduleId, referenceId, relativePath } + ]) || relativeUrlMechanisms[format](relativePath, isUrlObject); code.overwrite( (parent as MemberExpression).start, @@ -144,32 +109,50 @@ export default class MetaProperty extends NodeBase { return; } - const replacement = - outputPluginDriver.hookFirstSync('resolveImportMeta', [ - metaProperty, - { - chunkId, - format, - moduleId: this.context.module.id - } - ]) || importMetaMechanisms[format]?.(metaProperty, chunkId); + let replacement = pluginDriver.hookFirstSync('resolveImportMeta', [ + metaProperty, + { chunkId, format, moduleId } + ]); + if (!replacement) { + replacement = importMetaMechanisms[format]?.(metaProperty, { chunkId, snippets }); + renderOptions.accessedDocumentCurrentScript ||= + formatsMaybeAccessDocumentCurrentScript.includes(format) && replacement !== 'undefined'; + } if (typeof replacement === 'string') { if (parent instanceof MemberExpression) { code.overwrite(parent.start, parent.end, replacement, { contentOnly: true }); } else { - code.overwrite(this.start, this.end, replacement, { contentOnly: true }); + code.overwrite(start, end, replacement, { contentOnly: true }); } } } + + setResolution( + format: InternalModuleFormat, + accessedGlobalsByScope: Map>, + preliminaryChunkId: string + ): void { + this.preliminaryChunkId = preliminaryChunkId; + const accessedGlobals = ( + this.metaProperty?.startsWith(FILE_PREFIX) || this.metaProperty?.startsWith(FILE_OBJ_PREFIX) + ? accessedFileUrlGlobals + : accessedMetaUrlGlobals + )[format]; + if (accessedGlobals.length > 0) { + this.scope.addAccessedGlobals(accessedGlobals, accessedGlobalsByScope); + } + } } +export const formatsMaybeAccessDocumentCurrentScript = ['cjs', 'iife', 'umd']; + const accessedMetaUrlGlobals = { amd: ['document', 'module', 'URL'], - cjs: ['document', 'require', 'URL'], + cjs: ['document', 'require', 'URL', DOCUMENT_CURRENT_SCRIPT], es: [], - iife: ['document', 'URL'], + iife: ['document', 'URL', DOCUMENT_CURRENT_SCRIPT], system: ['module'], - umd: ['document', 'require', 'URL'] + umd: ['document', 'require', 'URL', DOCUMENT_CURRENT_SCRIPT] }; const accessedFileUrlGlobals = { @@ -181,60 +164,74 @@ const accessedFileUrlGlobals = { umd: ['document', 'require', 'URL'] }; -const getResolveUrl = (path: string, URL = 'URL') => `new ${URL}(${path}).href`; +const getResolveUrl = (path: string, asObject: boolean, URL = 'URL') => + `new ${URL}(${path})${asObject ? '' : '.href'}`; -const getRelativeUrlFromDocument = (relativePath: string) => +const getRelativeUrlFromDocument = (relativePath: string, asObject: boolean, umd = false) => getResolveUrl( - `'${relativePath}', document.currentScript && document.currentScript.src || document.baseURI` + `'${escapeId(relativePath)}', ${ + umd ? `typeof document === 'undefined' ? location.href : ` : '' + }document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT' && document.currentScript.src || document.baseURI`, + asObject ); -const getGenericImportMetaMechanism = (getUrl: (chunkId: string) => string) => ( - prop: string | null, - chunkId: string -) => { - const urlMechanism = getUrl(chunkId); - return prop === null ? `({ url: ${urlMechanism} })` : prop === 'url' ? urlMechanism : 'undefined'; -}; - -const getUrlFromDocument = (chunkId: string) => - `(document.currentScript && document.currentScript.src || new URL('${chunkId}', document.baseURI).href)`; - -const relativeUrlMechanisms: Record string> = { - amd: relativePath => { +const getGenericImportMetaMechanism = + (getUrl: (chunkId: string) => string) => + (property: string | null, { chunkId }: { chunkId: string }) => { + const urlMechanism = getUrl(chunkId); + return property === null + ? `({ url: ${urlMechanism} })` + : property === 'url' + ? urlMechanism + : 'undefined'; + }; + +const getFileUrlFromFullPath = (path: string, asObject: boolean) => + `require('u' + 'rl').pathToFileURL(${path})${asObject ? '' : '.href'}`; + +const getFileUrlFromRelativePath = (path: string, asObject: boolean) => + getFileUrlFromFullPath(`__dirname + '/${escapeId(path)}'`, asObject); + +const getUrlFromDocument = (chunkId: string, umd = false) => + `${ + umd ? `typeof document === 'undefined' ? location.href : ` : '' + }(${DOCUMENT_CURRENT_SCRIPT} && ${DOCUMENT_CURRENT_SCRIPT}.tagName.toUpperCase() === 'SCRIPT' && ${DOCUMENT_CURRENT_SCRIPT}.src || new URL('${escapeId( + chunkId + )}', document.baseURI).href)`; + +const relativeUrlMechanisms: Record< + InternalModuleFormat, + (relativePath: string, asObject: boolean) => string +> = { + amd: (relativePath, asObject: boolean) => { if (relativePath[0] !== '.') relativePath = './' + relativePath; - return getResolveUrl(`require.toUrl('${relativePath}'), document.baseURI`); + return getResolveUrl(`require.toUrl('${escapeId(relativePath)}'), document.baseURI`, asObject); }, - cjs: relativePath => - `(typeof document === 'undefined' ? ${getResolveUrl( - `'file:' + __dirname + '/${relativePath}'`, - `(require('u' + 'rl').URL)` - )} : ${getRelativeUrlFromDocument(relativePath)})`, - es: relativePath => getResolveUrl(`'${relativePath}', import.meta.url`), - iife: relativePath => getRelativeUrlFromDocument(relativePath), - system: relativePath => getResolveUrl(`'${relativePath}', module.meta.url`), - umd: relativePath => - `(typeof document === 'undefined' ? ${getResolveUrl( - `'file:' + __dirname + '/${relativePath}'`, - `(require('u' + 'rl').URL)` - )} : ${getRelativeUrlFromDocument(relativePath)})` + cjs: (relativePath, asObject: boolean) => + `(typeof document === 'undefined' ? ${getFileUrlFromRelativePath(relativePath, asObject)} : ${getRelativeUrlFromDocument(relativePath, asObject)})`, + es: (relativePath, asObject: boolean) => + getResolveUrl(`'${escapeId(relativePath)}', import.meta.url`, asObject), + iife: (relativePath, asObject: boolean) => getRelativeUrlFromDocument(relativePath, asObject), + system: (relativePath, asObject: boolean) => + getResolveUrl(`'${escapeId(relativePath)}', module.meta.url`, asObject), + umd: (relativePath, asObject: boolean) => + `(typeof document === 'undefined' && typeof location === 'undefined' ? ${getFileUrlFromRelativePath(relativePath, asObject)} : ${getRelativeUrlFromDocument(relativePath, asObject, true)})` }; -const importMetaMechanisms: Record string> = { - amd: getGenericImportMetaMechanism(() => getResolveUrl(`module.uri, document.baseURI`)), +const importMetaMechanisms: Record< + string, + (property: string | null, options: { chunkId: string; snippets: GenerateCodeSnippets }) => string +> = { + amd: getGenericImportMetaMechanism(() => getResolveUrl(`module.uri, document.baseURI`, false)), cjs: getGenericImportMetaMechanism( chunkId => - `(typeof document === 'undefined' ? ${getResolveUrl( - `'file:' + __filename`, - `(require('u' + 'rl').URL)` - )} : ${getUrlFromDocument(chunkId)})` + `(typeof document === 'undefined' ? ${getFileUrlFromFullPath('__filename', false)} : ${getUrlFromDocument(chunkId)})` ), iife: getGenericImportMetaMechanism(chunkId => getUrlFromDocument(chunkId)), - system: prop => (prop === null ? `module.meta` : `module.meta.${prop}`), + system: (property, { snippets: { getPropertyAccess } }) => + property === null ? `module.meta` : `module.meta${getPropertyAccess(property)}`, umd: getGenericImportMetaMechanism( chunkId => - `(typeof document === 'undefined' ? ${getResolveUrl( - `'file:' + __filename`, - `(require('u' + 'rl').URL)` - )} : ${getUrlFromDocument(chunkId)})` + `(typeof document === 'undefined' && typeof location === 'undefined' ? ${getFileUrlFromFullPath('__filename', false)} : ${getUrlFromDocument(chunkId, true)})` ) }; diff --git a/src/ast/nodes/MethodDefinition.ts b/src/ast/nodes/MethodDefinition.ts index 7ce5195cc2a..41dc6762ecd 100644 --- a/src/ast/nodes/MethodDefinition.ts +++ b/src/ast/nodes/MethodDefinition.ts @@ -1,30 +1,21 @@ -import { CallOptions } from '../CallOptions'; -import { HasEffectsContext } from '../ExecutionContext'; -import { EMPTY_PATH, ObjectPath } from '../utils/PathTracker'; -import FunctionExpression from './FunctionExpression'; -import * as NodeType from './NodeType'; -import PrivateIdentifier from './PrivateIdentifier'; -import { ExpressionNode, NodeBase } from './shared/Node'; +import type { HasEffectsContext } from '../ExecutionContext'; +import { checkEffectForNodes } from '../utils/checkEffectForNodes'; +import type Decorator from './Decorator'; +import type FunctionExpression from './FunctionExpression'; +import type * as NodeType from './NodeType'; +import type PrivateIdentifier from './PrivateIdentifier'; +import MethodBase from './shared/MethodBase'; +import type { ExpressionNode } from './shared/Node'; -export default class MethodDefinition extends NodeBase { - computed!: boolean; - key!: ExpressionNode | PrivateIdentifier; - kind!: 'constructor' | 'method' | 'get' | 'set'; - static!: boolean; - type!: NodeType.tMethodDefinition; - value!: FunctionExpression; +export default class MethodDefinition extends MethodBase { + declare key: ExpressionNode | PrivateIdentifier; + declare kind: 'constructor' | 'method' | 'get' | 'set'; + declare static: boolean; + declare type: NodeType.tMethodDefinition; + declare value: FunctionExpression; + declare decorators: Decorator[]; - hasEffects(context: HasEffectsContext) { - return this.key.hasEffects(context); - } - - hasEffectsWhenCalledAtPath( - path: ObjectPath, - callOptions: CallOptions, - context: HasEffectsContext - ) { - return ( - path.length > 0 || this.value.hasEffectsWhenCalledAtPath(EMPTY_PATH, callOptions, context) - ); + hasEffects(context: HasEffectsContext): boolean { + return super.hasEffects(context) || checkEffectForNodes(this.decorators, context); } } diff --git a/src/ast/nodes/NewExpression.ts b/src/ast/nodes/NewExpression.ts index 79633447566..ee00c5e82b4 100644 --- a/src/ast/nodes/NewExpression.ts +++ b/src/ast/nodes/NewExpression.ts @@ -1,48 +1,89 @@ -import { NormalizedTreeshakingOptions } from '../../rollup/types'; -import { CallOptions } from '../CallOptions'; -import { HasEffectsContext } from '../ExecutionContext'; -import { EMPTY_PATH, ObjectPath, UNKNOWN_PATH } from '../utils/PathTracker'; -import * as NodeType from './NodeType'; -import { Annotation, ExpressionNode, NodeBase } from './shared/Node'; +import type MagicString from 'magic-string'; +import type { NormalizedTreeshakingOptions } from '../../rollup/types'; +import { renderCallArguments } from '../../utils/renderCallArguments'; +import type { RenderOptions } from '../../utils/renderHelpers'; +import type { HasEffectsContext, InclusionContext } from '../ExecutionContext'; +import type { NodeInteraction, NodeInteractionCalled } from '../NodeInteractions'; +import { INTERACTION_ACCESSED, INTERACTION_CALLED } from '../NodeInteractions'; +import { + EMPTY_PATH, + type ObjectPath, + SHARED_RECURSION_TRACKER, + UNKNOWN_PATH +} from '../utils/PathTracker'; +import type * as NodeType from './NodeType'; +import type { ExpressionNode, IncludeChildren } from './shared/Node'; +import { NodeBase } from './shared/Node'; export default class NewExpression extends NodeBase { - arguments!: ExpressionNode[]; - callee!: ExpressionNode; - type!: NodeType.tNewExpression; - - private callOptions!: CallOptions; - - bind() { - super.bind(); - for (const argument of this.arguments) { - // This will make sure all properties of parameters behave as "unknown" - argument.deoptimizePath(UNKNOWN_PATH); - } - } + declare arguments: ExpressionNode[]; + declare callee: ExpressionNode; + declare type: NodeType.tNewExpression; + declare private interaction: NodeInteractionCalled; + /** Marked with #__PURE__ annotation */ + declare annotationPure?: boolean; hasEffects(context: HasEffectsContext): boolean { + if (!this.deoptimized) this.applyDeoptimizations(); for (const argument of this.arguments) { if (argument.hasEffects(context)) return true; } - if ( - (this.context.options.treeshake as NormalizedTreeshakingOptions).annotations && - this.annotations?.some((a: Annotation) => a.pure) - ) + if (this.annotationPure) { return false; + } return ( this.callee.hasEffects(context) || - this.callee.hasEffectsWhenCalledAtPath(EMPTY_PATH, this.callOptions, context) + this.callee.hasEffectsOnInteractionAtPath(EMPTY_PATH, this.interaction, context) ); } - hasEffectsWhenAccessedAtPath(path: ObjectPath) { - return path.length > 1; + hasEffectsOnInteractionAtPath(path: ObjectPath, { type }: NodeInteraction): boolean { + return path.length > 0 || type !== INTERACTION_ACCESSED; + } + + include(context: InclusionContext, includeChildrenRecursively: IncludeChildren): void { + if (!this.included) this.includeNode(context); + if (includeChildrenRecursively) { + super.include(context, true); + } else { + this.callee.include(context, false); + this.callee.includeCallArguments(this.interaction, context); + } } - initialise() { - this.callOptions = { - args: this.arguments, + includeNode(context: InclusionContext) { + this.included = true; + if (!this.deoptimized) this.applyDeoptimizations(); + this.callee.includePath(UNKNOWN_PATH, context); + } + + initialise(): void { + super.initialise(); + this.interaction = { + args: [null, ...this.arguments], + type: INTERACTION_CALLED, withNew: true }; + if ( + this.annotations && + (this.scope.context.options.treeshake as NormalizedTreeshakingOptions).annotations + ) { + this.annotationPure = this.annotations.some(comment => comment.type === 'pure'); + } + } + + render(code: MagicString, options: RenderOptions) { + this.callee.render(code, options); + renderCallArguments(code, options, this); + } + + applyDeoptimizations() { + this.deoptimized = true; + this.callee.deoptimizeArgumentsOnInteractionAtPath( + this.interaction, + EMPTY_PATH, + SHARED_RECURSION_TRACKER + ); + this.scope.context.requestTreeshakingPass(); } } diff --git a/src/ast/nodes/NodeType.ts b/src/ast/nodes/NodeType.ts index 159aec8cdea..65ef0e1a16d 100644 --- a/src/ast/nodes/NodeType.ts +++ b/src/ast/nodes/NodeType.ts @@ -1,3 +1,6 @@ +// This file is generated by scripts/generate-node-types.js. +// Do not edit this file directly. + export type tArrayExpression = 'ArrayExpression'; export type tArrayPattern = 'ArrayPattern'; export type tArrowFunctionExpression = 'ArrowFunctionExpression'; @@ -15,6 +18,8 @@ export type tClassDeclaration = 'ClassDeclaration'; export type tClassExpression = 'ClassExpression'; export type tConditionalExpression = 'ConditionalExpression'; export type tContinueStatement = 'ContinueStatement'; +export type tDebuggerStatement = 'DebuggerStatement'; +export type tDecorator = 'Decorator'; export type tDoWhileStatement = 'DoWhileStatement'; export type tEmptyStatement = 'EmptyStatement'; export type tExportAllDeclaration = 'ExportAllDeclaration'; @@ -22,19 +27,34 @@ export type tExportDefaultDeclaration = 'ExportDefaultDeclaration'; export type tExportNamedDeclaration = 'ExportNamedDeclaration'; export type tExportSpecifier = 'ExportSpecifier'; export type tExpressionStatement = 'ExpressionStatement'; -export type tForStatement = 'ForStatement'; export type tForInStatement = 'ForInStatement'; export type tForOfStatement = 'ForOfStatement'; +export type tForStatement = 'ForStatement'; export type tFunctionDeclaration = 'FunctionDeclaration'; export type tFunctionExpression = 'FunctionExpression'; export type tIdentifier = 'Identifier'; export type tIfStatement = 'IfStatement'; -export type tImport = 'Import'; +export type tImportAttribute = 'ImportAttribute'; export type tImportDeclaration = 'ImportDeclaration'; -export type tImportExpression = 'ImportExpression'; export type tImportDefaultSpecifier = 'ImportDefaultSpecifier'; +export type tImportExpression = 'ImportExpression'; export type tImportNamespaceSpecifier = 'ImportNamespaceSpecifier'; export type tImportSpecifier = 'ImportSpecifier'; +export type tJSXAttribute = 'JSXAttribute'; +export type tJSXClosingElement = 'JSXClosingElement'; +export type tJSXClosingFragment = 'JSXClosingFragment'; +export type tJSXElement = 'JSXElement'; +export type tJSXEmptyExpression = 'JSXEmptyExpression'; +export type tJSXExpressionContainer = 'JSXExpressionContainer'; +export type tJSXFragment = 'JSXFragment'; +export type tJSXIdentifier = 'JSXIdentifier'; +export type tJSXMemberExpression = 'JSXMemberExpression'; +export type tJSXNamespacedName = 'JSXNamespacedName'; +export type tJSXOpeningElement = 'JSXOpeningElement'; +export type tJSXOpeningFragment = 'JSXOpeningFragment'; +export type tJSXSpreadAttribute = 'JSXSpreadAttribute'; +export type tJSXSpreadChild = 'JSXSpreadChild'; +export type tJSXText = 'JSXText'; export type tLabeledStatement = 'LabeledStatement'; export type tLiteral = 'Literal'; export type tLogicalExpression = 'LogicalExpression'; @@ -44,6 +64,8 @@ export type tMethodDefinition = 'MethodDefinition'; export type tNewExpression = 'NewExpression'; export type tObjectExpression = 'ObjectExpression'; export type tObjectPattern = 'ObjectPattern'; +export type tPanicError = 'PanicError'; +export type tParseError = 'ParseError'; export type tPrivateIdentifier = 'PrivateIdentifier'; export type tProgram = 'Program'; export type tProperty = 'Property'; @@ -52,6 +74,7 @@ export type tRestElement = 'RestElement'; export type tReturnStatement = 'ReturnStatement'; export type tSequenceExpression = 'SequenceExpression'; export type tSpreadElement = 'SpreadElement'; +export type tStaticBlock = 'StaticBlock'; export type tSuper = 'Super'; export type tSwitchCase = 'SwitchCase'; export type tSwitchStatement = 'SwitchStatement'; @@ -63,8 +86,8 @@ export type tThrowStatement = 'ThrowStatement'; export type tTryStatement = 'TryStatement'; export type tUnaryExpression = 'UnaryExpression'; export type tUpdateExpression = 'UpdateExpression'; -export type tVariableDeclarator = 'VariableDeclarator'; export type tVariableDeclaration = 'VariableDeclaration'; +export type tVariableDeclarator = 'VariableDeclarator'; export type tWhileStatement = 'WhileStatement'; export type tYieldExpression = 'YieldExpression'; @@ -85,6 +108,8 @@ export const ClassDeclaration: tClassDeclaration = 'ClassDeclaration'; export const ClassExpression: tClassExpression = 'ClassExpression'; export const ConditionalExpression: tConditionalExpression = 'ConditionalExpression'; export const ContinueStatement: tContinueStatement = 'ContinueStatement'; +export const DebuggerStatement: tDebuggerStatement = 'DebuggerStatement'; +export const Decorator: tDecorator = 'Decorator'; export const DoWhileStatement: tDoWhileStatement = 'DoWhileStatement'; export const EmptyStatement: tEmptyStatement = 'EmptyStatement'; export const ExportAllDeclaration: tExportAllDeclaration = 'ExportAllDeclaration'; @@ -92,19 +117,34 @@ export const ExportDefaultDeclaration: tExportDefaultDeclaration = 'ExportDefaul export const ExportNamedDeclaration: tExportNamedDeclaration = 'ExportNamedDeclaration'; export const ExportSpecifier: tExportSpecifier = 'ExportSpecifier'; export const ExpressionStatement: tExpressionStatement = 'ExpressionStatement'; -export const ForStatement: tForStatement = 'ForStatement'; export const ForInStatement: tForInStatement = 'ForInStatement'; export const ForOfStatement: tForOfStatement = 'ForOfStatement'; +export const ForStatement: tForStatement = 'ForStatement'; export const FunctionDeclaration: tFunctionDeclaration = 'FunctionDeclaration'; export const FunctionExpression: tFunctionExpression = 'FunctionExpression'; export const Identifier: tIdentifier = 'Identifier'; export const IfStatement: tIfStatement = 'IfStatement'; -export const Import: tImport = 'Import'; +export const ImportAttribute: tImportAttribute = 'ImportAttribute'; export const ImportDeclaration: tImportDeclaration = 'ImportDeclaration'; -export const ImportExpression: tImportExpression = 'ImportExpression'; export const ImportDefaultSpecifier: tImportDefaultSpecifier = 'ImportDefaultSpecifier'; +export const ImportExpression: tImportExpression = 'ImportExpression'; export const ImportNamespaceSpecifier: tImportNamespaceSpecifier = 'ImportNamespaceSpecifier'; export const ImportSpecifier: tImportSpecifier = 'ImportSpecifier'; +export const JSXAttribute: tJSXAttribute = 'JSXAttribute'; +export const JSXClosingElement: tJSXClosingElement = 'JSXClosingElement'; +export const JSXClosingFragment: tJSXClosingFragment = 'JSXClosingFragment'; +export const JSXElement: tJSXElement = 'JSXElement'; +export const JSXEmptyExpression: tJSXEmptyExpression = 'JSXEmptyExpression'; +export const JSXExpressionContainer: tJSXExpressionContainer = 'JSXExpressionContainer'; +export const JSXFragment: tJSXFragment = 'JSXFragment'; +export const JSXIdentifier: tJSXIdentifier = 'JSXIdentifier'; +export const JSXMemberExpression: tJSXMemberExpression = 'JSXMemberExpression'; +export const JSXNamespacedName: tJSXNamespacedName = 'JSXNamespacedName'; +export const JSXOpeningElement: tJSXOpeningElement = 'JSXOpeningElement'; +export const JSXOpeningFragment: tJSXOpeningFragment = 'JSXOpeningFragment'; +export const JSXSpreadAttribute: tJSXSpreadAttribute = 'JSXSpreadAttribute'; +export const JSXSpreadChild: tJSXSpreadChild = 'JSXSpreadChild'; +export const JSXText: tJSXText = 'JSXText'; export const LabeledStatement: tLabeledStatement = 'LabeledStatement'; export const Literal: tLiteral = 'Literal'; export const LogicalExpression: tLogicalExpression = 'LogicalExpression'; @@ -114,6 +154,8 @@ export const MethodDefinition: tMethodDefinition = 'MethodDefinition'; export const NewExpression: tNewExpression = 'NewExpression'; export const ObjectExpression: tObjectExpression = 'ObjectExpression'; export const ObjectPattern: tObjectPattern = 'ObjectPattern'; +export const PanicError: tPanicError = 'PanicError'; +export const ParseError: tParseError = 'ParseError'; export const PrivateIdentifier: tPrivateIdentifier = 'PrivateIdentifier'; export const Program: tProgram = 'Program'; export const Property: tProperty = 'Property'; @@ -122,6 +164,7 @@ export const RestElement: tRestElement = 'RestElement'; export const ReturnStatement: tReturnStatement = 'ReturnStatement'; export const SequenceExpression: tSequenceExpression = 'SequenceExpression'; export const SpreadElement: tSpreadElement = 'SpreadElement'; +export const StaticBlock: tStaticBlock = 'StaticBlock'; export const Super: tSuper = 'Super'; export const SwitchCase: tSwitchCase = 'SwitchCase'; export const SwitchStatement: tSwitchStatement = 'SwitchStatement'; @@ -133,7 +176,7 @@ export const ThrowStatement: tThrowStatement = 'ThrowStatement'; export const TryStatement: tTryStatement = 'TryStatement'; export const UnaryExpression: tUnaryExpression = 'UnaryExpression'; export const UpdateExpression: tUpdateExpression = 'UpdateExpression'; -export const VariableDeclarator: tVariableDeclarator = 'VariableDeclarator'; export const VariableDeclaration: tVariableDeclaration = 'VariableDeclaration'; +export const VariableDeclarator: tVariableDeclarator = 'VariableDeclarator'; export const WhileStatement: tWhileStatement = 'WhileStatement'; export const YieldExpression: tYieldExpression = 'YieldExpression'; diff --git a/src/ast/nodes/ObjectExpression.ts b/src/ast/nodes/ObjectExpression.ts index d4190a3d4d0..d4989be1cde 100644 --- a/src/ast/nodes/ObjectExpression.ts +++ b/src/ast/nodes/ObjectExpression.ts @@ -1,354 +1,183 @@ -import MagicString from 'magic-string'; +import type MagicString from 'magic-string'; import { BLANK } from '../../utils/blank'; -import { getOrCreate } from '../../utils/getOrCreate'; -import { NodeRenderOptions, RenderOptions } from '../../utils/renderHelpers'; -import { CallOptions } from '../CallOptions'; -import { DeoptimizableEntity } from '../DeoptimizableEntity'; -import { HasEffectsContext } from '../ExecutionContext'; +import type { NodeRenderOptions, RenderOptions } from '../../utils/renderHelpers'; +import { getCommaSeparatedNodesWithBoundaries } from '../../utils/renderHelpers'; +import { treeshakeNode } from '../../utils/treeshakeNode'; +import type { DeoptimizableEntity } from '../DeoptimizableEntity'; +import type { HasEffectsContext, InclusionContext } from '../ExecutionContext'; +import type { NodeInteraction, NodeInteractionCalled } from '../NodeInteractions'; import { EMPTY_PATH, - ObjectPath, - PathTracker, + type EntityPathTracker, + isAnyWellKnown, + type ObjectPath, SHARED_RECURSION_TRACKER, - UNKNOWN_PATH + UNKNOWN_PATH, + UnknownKey } from '../utils/PathTracker'; -import { - getMemberReturnExpressionWhenCalled, - hasMemberEffectWhenCalled, - LiteralValueOrUnknown, - objectMembers, - UnknownValue, - UNKNOWN_EXPRESSION -} from '../values'; import Identifier from './Identifier'; import Literal from './Literal'; import * as NodeType from './NodeType'; -import Property from './Property'; -import { ExpressionEntity } from './shared/Expression'; -import { NodeBase } from './shared/Node'; +import type Property from './Property'; +import type { ExpressionEntity, LiteralValueOrUnknown } from './shared/Expression'; +import type { IncludeChildren } from './shared/Node'; +import { doNotDeoptimize, NodeBase } from './shared/Node'; +import { ObjectEntity, type ObjectProperty } from './shared/ObjectEntity'; +import { OBJECT_PROTOTYPE } from './shared/ObjectPrototype'; import SpreadElement from './SpreadElement'; -interface PropertyMap { - [key: string]: { - exactMatchRead: Property | null; - exactMatchWrite: Property | null; - propertiesRead: (Property | SpreadElement)[]; - propertiesWrite: Property[]; - }; -} - export default class ObjectExpression extends NodeBase implements DeoptimizableEntity { - properties!: (Property | SpreadElement)[]; - type!: NodeType.tObjectExpression; - - private deoptimizedPaths = new Set(); - - // We collect deoptimization information if we can resolve a computed property access - private expressionsToBeDeoptimized = new Map(); - private hasUnknownDeoptimizedProperty = false; - private propertyMap: PropertyMap | null = null; - private unmatchablePropertiesRead: (Property | SpreadElement)[] = []; - private unmatchablePropertiesWrite: Property[] = []; + declare properties: readonly (Property | SpreadElement)[]; + declare type: NodeType.tObjectExpression; + private objectEntity: ObjectEntity | null = null; + private protoProp: Property | null = null; - bind() { - super.bind(); - // ensure the propertyMap is set for the tree-shaking passes - this.getPropertyMap(); + deoptimizeArgumentsOnInteractionAtPath( + interaction: NodeInteraction, + path: ObjectPath, + recursionTracker: EntityPathTracker + ): void { + this.getObjectEntity().deoptimizeArgumentsOnInteractionAtPath( + interaction, + path, + recursionTracker + ); } - // We could also track this per-property but this would quickly become much more complex - deoptimizeCache() { - if (!this.hasUnknownDeoptimizedProperty) this.deoptimizeAllProperties(); + deoptimizeCache(): void { + this.getObjectEntity().deoptimizeAllProperties(); } - deoptimizePath(path: ObjectPath) { - if (this.hasUnknownDeoptimizedProperty) return; - const propertyMap = this.getPropertyMap(); - const key = path[0]; - if (path.length === 1) { - if (typeof key !== 'string') { - this.deoptimizeAllProperties(); - return; - } - if (!this.deoptimizedPaths.has(key)) { - this.deoptimizedPaths.add(key); - - // we only deoptimizeCache exact matches as in all other cases, - // we do not return a literal value or return expression - const expressionsToBeDeoptimized = this.expressionsToBeDeoptimized.get(key); - if (expressionsToBeDeoptimized) { - for (const expression of expressionsToBeDeoptimized) { - expression.deoptimizeCache(); - } - } - } - } - const subPath = path.length === 1 ? UNKNOWN_PATH : path.slice(1); - for (const property of typeof key === 'string' - ? propertyMap[key] - ? propertyMap[key].propertiesRead - : [] - : this.properties) { - property.deoptimizePath(subPath); - } + deoptimizePath(path: ObjectPath): void { + this.getObjectEntity().deoptimizePath(path); } getLiteralValueAtPath( path: ObjectPath, - recursionTracker: PathTracker, + recursionTracker: EntityPathTracker, origin: DeoptimizableEntity ): LiteralValueOrUnknown { - const propertyMap = this.getPropertyMap(); - const key = path[0]; - - if ( - path.length === 0 || - this.hasUnknownDeoptimizedProperty || - typeof key !== 'string' || - this.deoptimizedPaths.has(key) - ) { - return UnknownValue; - } - - if ( - path.length === 1 && - !propertyMap[key] && - !objectMembers[key] && - this.unmatchablePropertiesRead.length === 0 - ) { - getOrCreate(this.expressionsToBeDeoptimized, key, () => []).push(origin); - return undefined; - } - - if ( - !propertyMap[key] || - propertyMap[key].exactMatchRead === null || - propertyMap[key].propertiesRead.length > 1 - ) { - return UnknownValue; - } - - getOrCreate(this.expressionsToBeDeoptimized, key, () => []).push(origin); - return propertyMap[key].exactMatchRead!.getLiteralValueAtPath( - path.slice(1), - recursionTracker, - origin - ); + return this.getObjectEntity().getLiteralValueAtPath(path, recursionTracker, origin); } getReturnExpressionWhenCalledAtPath( path: ObjectPath, - recursionTracker: PathTracker, + interaction: NodeInteractionCalled, + recursionTracker: EntityPathTracker, origin: DeoptimizableEntity - ): ExpressionEntity { - const propertyMap = this.getPropertyMap(); - const key = path[0]; - - if ( - path.length === 0 || - this.hasUnknownDeoptimizedProperty || - typeof key !== 'string' || - this.deoptimizedPaths.has(key) - ) { - return UNKNOWN_EXPRESSION; - } - - if ( - path.length === 1 && - objectMembers[key] && - this.unmatchablePropertiesRead.length === 0 && - (!propertyMap[key] || propertyMap[key].exactMatchRead === null) - ) { - return getMemberReturnExpressionWhenCalled(objectMembers, key); - } - - if ( - !propertyMap[key] || - propertyMap[key].exactMatchRead === null || - propertyMap[key].propertiesRead.length > 1 - ) { - return UNKNOWN_EXPRESSION; - } - - getOrCreate(this.expressionsToBeDeoptimized, key, () => []).push(origin); - return propertyMap[key].exactMatchRead!.getReturnExpressionWhenCalledAtPath( - path.slice(1), + ): [expression: ExpressionEntity, isPure: boolean] { + return this.getObjectEntity().getReturnExpressionWhenCalledAtPath( + path, + interaction, recursionTracker, origin ); } - hasEffectsWhenAccessedAtPath(path: ObjectPath, context: HasEffectsContext) { - if (path.length === 0) return false; - const key = path[0]; - const propertyMap = this.propertyMap!; - if ( - path.length > 1 && - (this.hasUnknownDeoptimizedProperty || - typeof key !== 'string' || - this.deoptimizedPaths.has(key) || - !propertyMap[key] || - propertyMap[key].exactMatchRead === null) - ) - return true; - - const subPath = path.slice(1); - for (const property of typeof key !== 'string' - ? this.properties - : propertyMap[key] - ? propertyMap[key].propertiesRead - : []) { - if (property.hasEffectsWhenAccessedAtPath(subPath, context)) return true; - } - return false; + hasEffectsOnInteractionAtPath( + path: ObjectPath, + interaction: NodeInteraction, + context: HasEffectsContext + ): boolean { + return this.getObjectEntity().hasEffectsOnInteractionAtPath(path, interaction, context); } - hasEffectsWhenAssignedAtPath(path: ObjectPath, context: HasEffectsContext) { - const key = path[0]; - const propertyMap = this.propertyMap!; - if ( - path.length > 1 && - (this.hasUnknownDeoptimizedProperty || - this.deoptimizedPaths.has(key as string) || - !propertyMap[key as string] || - propertyMap[key as string].exactMatchRead === null) - ) { - return true; - } - - const subPath = path.slice(1); - for (const property of typeof key !== 'string' - ? this.properties - : path.length > 1 - ? propertyMap[key].propertiesRead - : propertyMap[key] - ? propertyMap[key].propertiesWrite - : []) { - if (property.hasEffectsWhenAssignedAtPath(subPath, context)) return true; - } - return false; + include(context: InclusionContext, includeChildrenRecursively: IncludeChildren) { + if (!this.included) this.includeNode(context); + this.getObjectEntity().include(context, includeChildrenRecursively); + this.protoProp?.include(context, includeChildrenRecursively); } - hasEffectsWhenCalledAtPath( - path: ObjectPath, - callOptions: CallOptions, - context: HasEffectsContext - ): boolean { - const key = path[0]; - if ( - typeof key !== 'string' || - this.hasUnknownDeoptimizedProperty || - this.deoptimizedPaths.has(key) || - (this.propertyMap![key] - ? !this.propertyMap![key].exactMatchRead - : path.length > 1 || !objectMembers[key]) - ) { - return true; - } - const subPath = path.slice(1); - if (this.propertyMap![key]) { - for (const property of this.propertyMap![key].propertiesRead) { - if (property.hasEffectsWhenCalledAtPath(subPath, callOptions, context)) return true; - } - } - if (path.length === 1 && objectMembers[key]) - return hasMemberEffectWhenCalled(objectMembers, key, this.included, callOptions, context); - return false; + includeNode(context: InclusionContext) { + this.included = true; + this.protoProp?.includePath(UNKNOWN_PATH, context); } - mayModifyThisWhenCalledAtPath(path: ObjectPath, recursionTracker: PathTracker) { - if (!path.length || typeof path[0] !== 'string') { - return true; - } - const property = this.getPropertyMap()[path[0]]?.exactMatchRead; - return property - ? property.value.mayModifyThisWhenCalledAtPath(path.slice(1), recursionTracker) - : true; + includePath(path: ObjectPath, context: InclusionContext) { + if (!this.included) this.includeNode(context); + this.getObjectEntity().includePath(path, context); } render( code: MagicString, options: RenderOptions, - { renderedParentType, renderedSurroundingElement }: NodeRenderOptions = BLANK - ) { - super.render(code, options); - const surroundingElement = renderedParentType || renderedSurroundingElement; + { renderedSurroundingElement }: NodeRenderOptions = BLANK + ): void { if ( - surroundingElement === NodeType.ExpressionStatement || - surroundingElement === NodeType.ArrowFunctionExpression + renderedSurroundingElement === NodeType.ExpressionStatement || + renderedSurroundingElement === NodeType.ArrowFunctionExpression ) { code.appendRight(this.start, '('); code.prependLeft(this.end, ')'); } - } - - private deoptimizeAllProperties() { - this.hasUnknownDeoptimizedProperty = true; - for (const property of this.properties) { - property.deoptimizePath(UNKNOWN_PATH); - } - for (const expressionsToBeDeoptimized of this.expressionsToBeDeoptimized.values()) { - for (const expression of expressionsToBeDeoptimized) { - expression.deoptimizeCache(); + if (this.properties.length > 0) { + const separatedNodes = getCommaSeparatedNodesWithBoundaries( + this.properties, + code, + this.start + 1, + this.end - 1 + ); + let lastSeparatorPos: number | null = null; + for (const { node, separator, start, end } of separatedNodes) { + if (!node.included) { + treeshakeNode(node, code, start, end); + continue; + } + lastSeparatorPos = separator; + node.render(code, options); + } + if (lastSeparatorPos) { + code.remove(lastSeparatorPos, this.end - 1); } } } - private getPropertyMap(): PropertyMap { - if (this.propertyMap !== null) { - return this.propertyMap; + private getObjectEntity(): ObjectEntity { + if (this.objectEntity !== null) { + return this.objectEntity; } - const propertyMap = (this.propertyMap = Object.create(null)); - for (let index = this.properties.length - 1; index >= 0; index--) { - const property = this.properties[index]; + let prototype: ExpressionEntity | null = OBJECT_PROTOTYPE; + const properties: ObjectProperty[] = []; + for (const property of this.properties) { if (property instanceof SpreadElement) { - this.unmatchablePropertiesRead.push(property); + properties.push({ key: UnknownKey, kind: 'init', property }); continue; } - const isWrite = property.kind !== 'get'; - const isRead = property.kind !== 'set'; let key: string; - let unmatchable = false; if (property.computed) { const keyValue = property.key.getLiteralValueAtPath( EMPTY_PATH, SHARED_RECURSION_TRACKER, this ); - if (keyValue === UnknownValue) unmatchable = true; - key = String(keyValue); - } else if (property.key instanceof Identifier) { - key = property.key.name; - } else { - key = String((property.key as Literal).value); - } - if (unmatchable || (key === '__proto__' && !property.computed)) { - if (isRead) { - this.unmatchablePropertiesRead.push(property); + if (typeof keyValue === 'symbol') { + properties.push({ + key: isAnyWellKnown(keyValue) ? keyValue : UnknownKey, + kind: property.kind, + property + }); + continue; } else { - this.unmatchablePropertiesWrite.push(property); + key = String(keyValue); + } + } else { + key = + property.key instanceof Identifier + ? property.key.name + : String((property.key as Literal).value); + if (key === '__proto__' && property.kind === 'init') { + this.protoProp = property; + prototype = + property.value instanceof Literal && property.value.value === null + ? null + : property.value; + continue; } - continue; - } - const propertyMapProperty = propertyMap[key]; - if (!propertyMapProperty) { - propertyMap[key] = { - exactMatchRead: isRead ? property : null, - exactMatchWrite: isWrite ? property : null, - propertiesRead: isRead ? [property, ...this.unmatchablePropertiesRead] : [], - propertiesWrite: isWrite && !isRead ? [property, ...this.unmatchablePropertiesWrite] : [] - }; - continue; - } - if (isRead && propertyMapProperty.exactMatchRead === null) { - propertyMapProperty.exactMatchRead = property; - propertyMapProperty.propertiesRead.push(property, ...this.unmatchablePropertiesRead); - } - if (isWrite && !isRead && propertyMapProperty.exactMatchWrite === null) { - propertyMapProperty.exactMatchWrite = property; - propertyMapProperty.propertiesWrite.push(property, ...this.unmatchablePropertiesWrite); } + properties.push({ key, kind: property.kind, property }); } - return propertyMap; + return (this.objectEntity = new ObjectEntity(properties, prototype)); } } + +ObjectExpression.prototype.applyDeoptimizations = doNotDeoptimize; diff --git a/src/ast/nodes/ObjectPattern.ts b/src/ast/nodes/ObjectPattern.ts index dd0ad9f1b32..91a93901ce8 100644 --- a/src/ast/nodes/ObjectPattern.ts +++ b/src/ast/nodes/ObjectPattern.ts @@ -1,42 +1,56 @@ -import { HasEffectsContext } from '../ExecutionContext'; -import { EMPTY_PATH, ObjectPath } from '../utils/PathTracker'; -import Variable from '../variables/Variable'; +import type MagicString from 'magic-string'; +import type { RenderOptions } from '../../utils/renderHelpers'; +import { getCommaSeparatedNodesWithBoundaries } from '../../utils/renderHelpers'; +import { treeshakeNode } from '../../utils/treeshakeNode'; +import type { HasEffectsContext, InclusionContext } from '../ExecutionContext'; +import type { NodeInteractionAssigned } from '../NodeInteractions'; +import { EMPTY_PATH, type ObjectPath } from '../utils/PathTracker'; +import type LocalVariable from '../variables/LocalVariable'; +import type Variable from '../variables/Variable'; import * as NodeType from './NodeType'; -import Property from './Property'; -import RestElement from './RestElement'; -import { ExpressionEntity } from './shared/Expression'; -import { NodeBase } from './shared/Node'; -import { PatternNode } from './shared/Pattern'; +import type Property from './Property'; +import type RestElement from './RestElement'; +import type { ExpressionEntity } from './shared/Expression'; +import { doNotDeoptimize, NodeBase, onlyIncludeSelfNoDeoptimize } from './shared/Node'; +import type { DeclarationPatternNode } from './shared/Pattern'; +import type { VariableKind } from './shared/VariableKinds'; -export default class ObjectPattern extends NodeBase implements PatternNode { - properties!: (Property | RestElement)[]; - type!: NodeType.tObjectPattern; +export default class ObjectPattern extends NodeBase implements DeclarationPatternNode { + declare properties: readonly (Property | RestElement)[]; + declare type: NodeType.tObjectPattern; addExportedVariables( - variables: Variable[], - exportNamesByVariable: Map + variables: readonly Variable[], + exportNamesByVariable: ReadonlyMap ): void { for (const property of this.properties) { if (property.type === NodeType.Property) { - ((property.value as unknown) as PatternNode).addExportedVariables( - variables, - exportNamesByVariable - ); + property.value.addExportedVariables(variables, exportNamesByVariable); } else { property.argument.addExportedVariables(variables, exportNamesByVariable); } } } - declare(kind: string, init: ExpressionEntity) { - const variables = []; + declare( + kind: VariableKind, + destructuredInitPath: ObjectPath, + init: ExpressionEntity + ): LocalVariable[] { + const variables: LocalVariable[] = []; for (const property of this.properties) { - variables.push(...property.declare(kind, init)); + variables.push(...property.declare(kind, destructuredInitPath, init)); } return variables; } - deoptimizePath(path: ObjectPath) { + deoptimizeAssignment(destructuredInitPath: ObjectPath, init: ExpressionEntity): void { + for (const property of this.properties) { + property.deoptimizeAssignment(destructuredInitPath, init); + } + } + + deoptimizePath(path: ObjectPath): void { if (path.length === 0) { for (const property of this.properties) { property.deoptimizePath(path); @@ -44,11 +58,83 @@ export default class ObjectPattern extends NodeBase implements PatternNode { } } - hasEffectsWhenAssignedAtPath(path: ObjectPath, context: HasEffectsContext) { - if (path.length > 0) return true; + hasEffectsOnInteractionAtPath( + // At the moment, this is only triggered for assignment left-hand sides, + // where the path is empty + _path: ObjectPath, + interaction: NodeInteractionAssigned, + context: HasEffectsContext + ): boolean { for (const property of this.properties) { - if (property.hasEffectsWhenAssignedAtPath(EMPTY_PATH, context)) return true; + if (property.hasEffectsOnInteractionAtPath(EMPTY_PATH, interaction, context)) return true; } return false; } + + hasEffectsWhenDestructuring( + context: HasEffectsContext, + destructuredInitPath: ObjectPath, + init: ExpressionEntity + ): boolean { + for (const property of this.properties) { + if (property.hasEffectsWhenDestructuring(context, destructuredInitPath, init)) return true; + } + return false; + } + + includeDestructuredIfNecessary( + context: InclusionContext, + destructuredInitPath: ObjectPath, + init: ExpressionEntity + ): boolean { + if (!this.properties.length) return this.included; + + const lastProperty = this.properties.at(-1)!; + let included = lastProperty.includeDestructuredIfNecessary(context, destructuredInitPath, init); + const lastPropertyIsRestElement = lastProperty.type === NodeType.RestElement; + + for (const property of this.properties.slice(0, -1)) { + if (lastPropertyIsRestElement && included && !property.included) { + property.includeNode(context); + } + included = + property.includeDestructuredIfNecessary(context, destructuredInitPath, init) || included; + } + if (!this.included && included) { + this.includeNode(context); + } + return this.included; + } + + markDeclarationReached(): void { + for (const property of this.properties) { + property.markDeclarationReached(); + } + } + + render(code: MagicString, options: RenderOptions): void { + if (this.properties.length > 0) { + const separatedNodes = getCommaSeparatedNodesWithBoundaries( + this.properties, + code, + this.start + 1, + this.end - 1 + ); + let lastSeparatorPos: number | null = null; + for (const { node, separator, start, end } of separatedNodes) { + if (!node.included) { + treeshakeNode(node, code, start, end); + continue; + } + lastSeparatorPos = separator; + node.render(code, options); + } + if (lastSeparatorPos) { + code.remove(lastSeparatorPos, this.end - 1); + } + } + } } + +ObjectPattern.prototype.includeNode = onlyIncludeSelfNoDeoptimize; +ObjectPattern.prototype.applyDeoptimizations = doNotDeoptimize; diff --git a/src/ast/nodes/PanicError.ts b/src/ast/nodes/PanicError.ts new file mode 100644 index 00000000000..29ce7ba679a --- /dev/null +++ b/src/ast/nodes/PanicError.ts @@ -0,0 +1,17 @@ +import { error, getRollupError, logModuleParseError, logParseError } from '../../utils/logs'; +import type * as NodeType from './NodeType'; +import { NodeBase } from './shared/Node'; + +export default class PanicError extends NodeBase { + declare type: NodeType.tPanicError; + declare message: string; + + initialise() { + const { id } = this.scope.context.module; + // This simulates the current nested error structure. We could also just + // replace it with a flat error. + const parseError = getRollupError(logParseError(this.message)); + const moduleParseError = logModuleParseError(parseError, id); + return error(moduleParseError); + } +} diff --git a/src/ast/nodes/ParseError.ts b/src/ast/nodes/ParseError.ts new file mode 100644 index 00000000000..e0ad7a2b768 --- /dev/null +++ b/src/ast/nodes/ParseError.ts @@ -0,0 +1,18 @@ +import { getRollupError, logModuleParseError, logParseError } from '../../utils/logs'; +import type * as NodeType from './NodeType'; +import { NodeBase } from './shared/Node'; + +export default class ParseError extends NodeBase { + declare type: NodeType.tParseError; + declare message: string; + + initialise() { + const pos = this.start; + const { id } = this.scope.context.module; + // This simulates the current nested error structure. We could also just + // replace it with a flat error. + const parseError = getRollupError(logParseError(this.message, pos)); + const moduleParseError = logModuleParseError(parseError, id); + this.scope.context.error(moduleParseError, pos); + } +} diff --git a/src/ast/nodes/PrivateIdentifier.ts b/src/ast/nodes/PrivateIdentifier.ts index 1846762730f..47a51070bbc 100644 --- a/src/ast/nodes/PrivateIdentifier.ts +++ b/src/ast/nodes/PrivateIdentifier.ts @@ -1,7 +1,9 @@ -import * as NodeType from './NodeType'; -import { NodeBase } from './shared/Node'; +import type * as NodeType from './NodeType'; +import { NodeBase, onlyIncludeSelf } from './shared/Node'; export default class PrivateIdentifier extends NodeBase { - name!: string; - type!: NodeType.tPrivateIdentifier; + declare name: string; + declare type: NodeType.tPrivateIdentifier; } + +PrivateIdentifier.prototype.includeNode = onlyIncludeSelf; diff --git a/src/ast/nodes/Program.ts b/src/ast/nodes/Program.ts index 287722c9332..6e9a4b5204f 100644 --- a/src/ast/nodes/Program.ts +++ b/src/ast/nodes/Program.ts @@ -1,28 +1,61 @@ -import MagicString from 'magic-string'; -import { RenderOptions, renderStatementList } from '../../utils/renderHelpers'; -import { HasEffectsContext, InclusionContext } from '../ExecutionContext'; -import * as NodeType from './NodeType'; -import { IncludeChildren, NodeBase, StatementNode } from './shared/Node'; +import { locate } from 'locate-character'; +import type MagicString from 'magic-string'; +import type { RollupAnnotation } from '../../utils/astConverterHelpers'; +import { LOGLEVEL_INFO, LOGLEVEL_WARN } from '../../utils/logging'; +import { logFirstSideEffect, logInvalidAnnotation } from '../../utils/logs'; +import { + findFirstLineBreakOutsideComment, + type RenderOptions, + renderStatementList +} from '../../utils/renderHelpers'; +import type { HasEffectsContext, InclusionContext } from '../ExecutionContext'; +import { createHasEffectsContext } from '../ExecutionContext'; +import type * as NodeType from './NodeType'; +import { + doNotDeoptimize, + type IncludeChildren, + NodeBase, + onlyIncludeSelfNoDeoptimize, + type StatementNode +} from './shared/Node'; export default class Program extends NodeBase { - body!: StatementNode[]; - sourceType!: 'module'; - type!: NodeType.tProgram; + declare body: readonly StatementNode[]; + declare sourceType: 'module'; + declare type: NodeType.tProgram; + declare invalidAnnotations?: readonly RollupAnnotation[]; - private hasCachedEffect = false; + private hasCachedEffect: boolean | null = null; + private hasLoggedEffect = false; - hasEffects(context: HasEffectsContext) { - // We are caching here to later more efficiently identify side-effect-free modules - if (this.hasCachedEffect) return true; + hasCachedEffects(): boolean { + if (!this.included) { + return false; + } + return this.hasCachedEffect === null + ? (this.hasCachedEffect = this.hasEffects(createHasEffectsContext())) + : this.hasCachedEffect; + } + + hasEffects(context: HasEffectsContext): boolean { for (const node of this.body) { if (node.hasEffects(context)) { + if (this.scope.context.options.experimentalLogSideEffects && !this.hasLoggedEffect) { + this.hasLoggedEffect = true; + const { code, log, module } = this.scope.context; + log( + LOGLEVEL_INFO, + logFirstSideEffect(code, module.id, locate(code, node.start, { offsetLine: 1 })!), + node.start + ); + } return (this.hasCachedEffect = true); } } return false; } - include(context: InclusionContext, includeChildrenRecursively: IncludeChildren) { + include(context: InclusionContext, includeChildrenRecursively: IncludeChildren): void { this.included = true; for (const node of this.body) { if (includeChildrenRecursively || node.shouldBeIncluded(context)) { @@ -31,11 +64,48 @@ export default class Program extends NodeBase { } } - render(code: MagicString, options: RenderOptions) { - if (this.body.length) { - renderStatementList(this.body, code, this.start, this.end, options); + initialise() { + super.initialise(); + if (this.invalidAnnotations) + for (const { start, end, type } of this.invalidAnnotations) { + this.scope.context.magicString.remove(start, end); + if (type === 'pure' || type === 'noSideEffects') { + this.scope.context.log( + LOGLEVEL_WARN, + logInvalidAnnotation( + this.scope.context.code.slice(start, end), + this.scope.context.module.id, + type + ), + start + ); + } + } + } + + render(code: MagicString, options: RenderOptions): void { + let start = this.start; + if (code.original.startsWith('#!')) { + start = Math.min(code.original.indexOf('\n') + 1, this.end); + code.remove(0, start); + } + if (this.body.length > 0) { + // Keep all consecutive lines that start with a comment + while (code.original[start] === '/' && /[*/]/.test(code.original[start + 1])) { + const firstLineBreak = findFirstLineBreakOutsideComment( + code.original.slice(start, this.body[0].start) + ); + if (firstLineBreak[0] === -1) { + break; + } + start += firstLineBreak[1]; + } + renderStatementList(this.body, code, start, this.end, options); } else { super.render(code, options); } } } + +Program.prototype.includeNode = onlyIncludeSelfNoDeoptimize; +Program.prototype.applyDeoptimizations = doNotDeoptimize; diff --git a/src/ast/nodes/Property.ts b/src/ast/nodes/Property.ts index 1cfb12233e1..a3c1b71a5a8 100644 --- a/src/ast/nodes/Property.ts +++ b/src/ast/nodes/Property.ts @@ -1,165 +1,135 @@ -import MagicString from 'magic-string'; -import { NormalizedTreeshakingOptions } from '../../rollup/types'; -import { RenderOptions } from '../../utils/renderHelpers'; -import { CallOptions, NO_ARGS } from '../CallOptions'; -import { DeoptimizableEntity } from '../DeoptimizableEntity'; -import { HasEffectsContext } from '../ExecutionContext'; -import { - EMPTY_PATH, - ObjectPath, - PathTracker, - SHARED_RECURSION_TRACKER, - UnknownKey -} from '../utils/PathTracker'; -import { LiteralValueOrUnknown, UNKNOWN_EXPRESSION } from '../values'; -import * as NodeType from './NodeType'; -import { ExpressionEntity } from './shared/Expression'; -import { ExpressionNode, NodeBase } from './shared/Node'; -import { PatternNode } from './shared/Pattern'; +import type MagicString from 'magic-string'; +import type { RenderOptions } from '../../utils/renderHelpers'; +import type { HasEffectsContext, InclusionContext } from '../ExecutionContext'; +import { createHasEffectsContext } from '../ExecutionContext'; +import type { ObjectPath } from '../utils/PathTracker'; +import { UnknownKey } from '../utils/PathTracker'; +import type LocalVariable from '../variables/LocalVariable'; +import Identifier from './Identifier'; +import type Literal from './Literal'; +import type * as NodeType from './NodeType'; +import { Flag, isFlagSet, setFlag } from './shared/BitFlags'; +import { type ExpressionEntity } from './shared/Expression'; +import MethodBase from './shared/MethodBase'; +import type { ExpressionNode, IncludeChildren } from './shared/Node'; +import { doNotDeoptimize, onlyIncludeSelfNoDeoptimize } from './shared/Node'; +import type { DeclarationPatternNode, PatternNode } from './shared/Pattern'; +import type { VariableKind } from './shared/VariableKinds'; -export default class Property extends NodeBase implements DeoptimizableEntity, PatternNode { - computed!: boolean; - key!: ExpressionNode; - kind!: 'init' | 'get' | 'set'; - method!: boolean; - shorthand!: boolean; - type!: NodeType.tProperty; - value!: ExpressionNode | (ExpressionNode & PatternNode); +export default class Property extends MethodBase implements DeclarationPatternNode { + declare key: ExpressionNode; + declare kind: 'init' | 'get' | 'set'; + declare type: NodeType.tProperty; - private accessorCallOptions!: CallOptions; - private declarationInit: ExpressionEntity | null = null; - private returnExpression: ExpressionEntity | null = null; - - bind() { - super.bind(); - if (this.kind === 'get') { - // ensure the returnExpression is set for the tree-shaking passes - this.getReturnExpression(); - } - if (this.declarationInit !== null) { - this.declarationInit.deoptimizePath([UnknownKey, UnknownKey]); - } + //declare method: boolean; + get method(): boolean { + return isFlagSet(this.flags, Flag.method); } - - declare(kind: string, init: ExpressionEntity) { - this.declarationInit = init; - return (this.value as PatternNode).declare(kind, UNKNOWN_EXPRESSION); + set method(value: boolean) { + this.flags = setFlag(this.flags, Flag.method, value); } - // As getter properties directly receive their values from function expressions that always - // have a fixed return value, there is no known situation where a getter is deoptimized. - deoptimizeCache(): void {} - - deoptimizePath(path: ObjectPath) { - if (this.kind === 'get') { - this.getReturnExpression().deoptimizePath(path); - } else { - this.value.deoptimizePath(path); - } + //declare shorthand: boolean; + get shorthand(): boolean { + return isFlagSet(this.flags, Flag.shorthand); + } + set shorthand(value: boolean) { + this.flags = setFlag(this.flags, Flag.shorthand, value); } - getLiteralValueAtPath( - path: ObjectPath, - recursionTracker: PathTracker, - origin: DeoptimizableEntity - ): LiteralValueOrUnknown { - if (this.kind === 'get') { - return this.getReturnExpression().getLiteralValueAtPath(path, recursionTracker, origin); - } - return this.value.getLiteralValueAtPath(path, recursionTracker, origin); + declare( + kind: VariableKind, + destructuredInitPath: ObjectPath, + init: ExpressionEntity + ): LocalVariable[] { + return (this.value as DeclarationPatternNode).declare( + kind, + this.getPathInProperty(destructuredInitPath), + init + ); } - getReturnExpressionWhenCalledAtPath( - path: ObjectPath, - recursionTracker: PathTracker, - origin: DeoptimizableEntity - ): ExpressionEntity { - if (this.kind === 'get') { - return this.getReturnExpression().getReturnExpressionWhenCalledAtPath( - path, - recursionTracker, - origin - ); - } - return this.value.getReturnExpressionWhenCalledAtPath(path, recursionTracker, origin); + deoptimizeAssignment(destructuredInitPath: ObjectPath, init: ExpressionEntity): void { + (this.value as PatternNode).deoptimizeAssignment?.( + this.getPathInProperty(destructuredInitPath), + init + ); } hasEffects(context: HasEffectsContext): boolean { - const propertyReadSideEffects = (this.context.options.treeshake as NormalizedTreeshakingOptions).propertyReadSideEffects; - return this.parent.type === 'ObjectPattern' && propertyReadSideEffects === 'always' || - this.key.hasEffects(context) || - this.value.hasEffects(context); + return this.key.hasEffects(context) || this.value.hasEffects(context); } - hasEffectsWhenAccessedAtPath(path: ObjectPath, context: HasEffectsContext): boolean { - if (this.kind === 'get') { - const trackedExpressions = context.accessed.getEntities(path); - if (trackedExpressions.has(this)) return false; - trackedExpressions.add(this); - return ( - this.value.hasEffectsWhenCalledAtPath(EMPTY_PATH, this.accessorCallOptions, context) || - (path.length > 0 && this.returnExpression!.hasEffectsWhenAccessedAtPath(path, context)) - ); - } - return this.value.hasEffectsWhenAccessedAtPath(path, context); + hasEffectsWhenDestructuring( + context: HasEffectsContext, + destructuredInitPath: ObjectPath, + init: ExpressionEntity + ): boolean { + return (this.value as PatternNode).hasEffectsWhenDestructuring?.( + context, + this.getPathInProperty(destructuredInitPath), + init + ); } - hasEffectsWhenAssignedAtPath(path: ObjectPath, context: HasEffectsContext): boolean { - if (this.kind === 'get') { - const trackedExpressions = context.assigned.getEntities(path); - if (trackedExpressions.has(this)) return false; - trackedExpressions.add(this); - return this.returnExpression!.hasEffectsWhenAssignedAtPath(path, context); + includeDestructuredIfNecessary( + context: InclusionContext, + destructuredInitPath: ObjectPath, + init: ExpressionEntity + ): boolean { + const path = this.getPathInProperty(destructuredInitPath); + let included = + (this.value as PatternNode).includeDestructuredIfNecessary(context, path, init) || + this.included; + if ((included ||= this.key.hasEffects(createHasEffectsContext()))) { + this.key.include(context, false); + if (!this.value.included) { + this.value.includeNode(context); + // Unfortunately, we need to include the value again now, so that any + // declared variables are properly included. + (this.value as PatternNode).includeDestructuredIfNecessary(context, path, init); + } } - if (this.kind === 'set') { - const trackedExpressions = context.assigned.getEntities(path); - if (trackedExpressions.has(this)) return false; - trackedExpressions.add(this); - return this.value.hasEffectsWhenCalledAtPath(EMPTY_PATH, this.accessorCallOptions, context); + if (!this.included && included) { + this.includeNode(context); } - return this.value.hasEffectsWhenAssignedAtPath(path, context); + return this.included; } - hasEffectsWhenCalledAtPath( - path: ObjectPath, - callOptions: CallOptions, - context: HasEffectsContext - ) { - if (this.kind === 'get') { - const trackedExpressions = (callOptions.withNew - ? context.instantiated - : context.called - ).getEntities(path, callOptions); - if (trackedExpressions.has(this)) return false; - trackedExpressions.add(this); - return this.returnExpression!.hasEffectsWhenCalledAtPath(path, callOptions, context); - } - return this.value.hasEffectsWhenCalledAtPath(path, callOptions, context); + include(context: InclusionContext, includeChildrenRecursively: IncludeChildren) { + this.included = true; + this.key.include(context, includeChildrenRecursively); + this.value.include(context, includeChildrenRecursively); } - initialise() { - this.accessorCallOptions = { - args: NO_ARGS, - withNew: false - }; + includePath(path: ObjectPath, context: InclusionContext) { + this.included = true; + this.value.includePath(path, context); } - render(code: MagicString, options: RenderOptions) { + markDeclarationReached(): void { + (this.value as DeclarationPatternNode).markDeclarationReached(); + } + + render(code: MagicString, options: RenderOptions): void { if (!this.shorthand) { this.key.render(code, options); } this.value.render(code, options, { isShorthandProperty: this.shorthand }); } - private getReturnExpression(): ExpressionEntity { - if (this.returnExpression === null) { - this.returnExpression = UNKNOWN_EXPRESSION; - return (this.returnExpression = this.value.getReturnExpressionWhenCalledAtPath( - EMPTY_PATH, - SHARED_RECURSION_TRACKER, - this - )); - } - return this.returnExpression; + private getPathInProperty(destructuredInitPath: ObjectPath): ObjectPath { + return destructuredInitPath.at(-1) === UnknownKey + ? destructuredInitPath + : // For now, we only consider static paths as we do not know how to + // deoptimize the path in the dynamic case. + this.computed + ? [...destructuredInitPath, UnknownKey] + : this.key instanceof Identifier + ? [...destructuredInitPath, this.key.name] + : [...destructuredInitPath, String((this.key as Literal).value)]; } } + +Property.prototype.includeNode = onlyIncludeSelfNoDeoptimize; +Property.prototype.applyDeoptimizations = doNotDeoptimize; diff --git a/src/ast/nodes/PropertyDefinition.ts b/src/ast/nodes/PropertyDefinition.ts index 0b0b02e3643..1e8d9edca69 100644 --- a/src/ast/nodes/PropertyDefinition.ts +++ b/src/ast/nodes/PropertyDefinition.ts @@ -1,19 +1,91 @@ -import { HasEffectsContext } from '../ExecutionContext'; -import * as NodeType from './NodeType'; -import PrivateIdentifier from './PrivateIdentifier'; -import { ExpressionNode, NodeBase } from './shared/Node'; +import type { DeoptimizableEntity } from '../DeoptimizableEntity'; +import type { HasEffectsContext, InclusionContext } from '../ExecutionContext'; +import type { NodeInteraction, NodeInteractionCalled } from '../NodeInteractions'; +import { checkEffectForNodes } from '../utils/checkEffectForNodes'; +import type { EntityPathTracker, ObjectPath } from '../utils/PathTracker'; +import { UNKNOWN_PATH } from '../utils/PathTracker'; +import type Decorator from './Decorator'; +import type * as NodeType from './NodeType'; +import type PrivateIdentifier from './PrivateIdentifier'; +import { Flag, isFlagSet, setFlag } from './shared/BitFlags'; +import { + type ExpressionEntity, + type LiteralValueOrUnknown, + UNKNOWN_RETURN_EXPRESSION, + UnknownValue +} from './shared/Expression'; +import { doNotDeoptimize, type ExpressionNode, NodeBase } from './shared/Node'; export default class PropertyDefinition extends NodeBase { - computed!: boolean; - key!: ExpressionNode | PrivateIdentifier; - static!: boolean; - type!: NodeType.tPropertyDefinition; - value!: ExpressionNode | null; + declare key: ExpressionNode | PrivateIdentifier; + declare static: boolean; + declare type: NodeType.tPropertyDefinition; + declare value: ExpressionNode | null; + declare decorators: Decorator[]; + + get computed(): boolean { + return isFlagSet(this.flags, Flag.computed); + } + set computed(value: boolean) { + this.flags = setFlag(this.flags, Flag.computed, value); + } + + deoptimizeArgumentsOnInteractionAtPath( + interaction: NodeInteraction, + path: ObjectPath, + recursionTracker: EntityPathTracker + ): void { + this.value?.deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker); + } + + deoptimizePath(path: ObjectPath): void { + this.value?.deoptimizePath(path); + } + + getLiteralValueAtPath( + path: ObjectPath, + recursionTracker: EntityPathTracker, + origin: DeoptimizableEntity + ): LiteralValueOrUnknown { + return this.value + ? this.value.getLiteralValueAtPath(path, recursionTracker, origin) + : UnknownValue; + } + + getReturnExpressionWhenCalledAtPath( + path: ObjectPath, + interaction: NodeInteractionCalled, + recursionTracker: EntityPathTracker, + origin: DeoptimizableEntity + ): [expression: ExpressionEntity, isPure: boolean] { + return this.value + ? this.value.getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) + : UNKNOWN_RETURN_EXPRESSION; + } hasEffects(context: HasEffectsContext): boolean { return ( this.key.hasEffects(context) || - (this.static && this.value !== null && this.value.hasEffects(context)) + (this.static && !!this.value?.hasEffects(context)) || + checkEffectForNodes(this.decorators, context) ); } + + hasEffectsOnInteractionAtPath( + path: ObjectPath, + interaction: NodeInteraction, + context: HasEffectsContext + ): boolean { + return !this.value || this.value.hasEffectsOnInteractionAtPath(path, interaction, context); + } + + includeNode(context: InclusionContext) { + this.included = true; + this.value?.includePath(UNKNOWN_PATH, context); + for (const decorator of this.decorators) { + decorator.includePath(UNKNOWN_PATH, context); + } + } } + +PropertyDefinition.prototype.applyDeoptimizations = doNotDeoptimize; diff --git a/src/ast/nodes/RestElement.ts b/src/ast/nodes/RestElement.ts index 1ea98754e47..a443be49400 100644 --- a/src/ast/nodes/RestElement.ts +++ b/src/ast/nodes/RestElement.ts @@ -1,42 +1,112 @@ -import { HasEffectsContext } from '../ExecutionContext'; -import { EMPTY_PATH, ObjectPath, UnknownKey } from '../utils/PathTracker'; -import { UNKNOWN_EXPRESSION } from '../values'; -import Variable from '../variables/Variable'; -import * as NodeType from './NodeType'; -import { ExpressionEntity } from './shared/Expression'; -import { NodeBase } from './shared/Node'; -import { PatternNode } from './shared/Pattern'; - -export default class RestElement extends NodeBase implements PatternNode { - argument!: PatternNode; - type!: NodeType.tRestElement; +import type { HasEffectsContext, InclusionContext } from '../ExecutionContext'; +import type { NodeInteractionAssigned } from '../NodeInteractions'; +import { EMPTY_PATH, type ObjectPath, UnknownKey } from '../utils/PathTracker'; +import type LocalVariable from '../variables/LocalVariable'; +import type Variable from '../variables/Variable'; +import type * as NodeType from './NodeType'; +import { type ExpressionEntity } from './shared/Expression'; +import type { IncludeChildren } from './shared/Node'; +import { NodeBase, onlyIncludeSelf } from './shared/Node'; +import type { DeclarationPatternNode, PatternNode } from './shared/Pattern'; +import type { VariableKind } from './shared/VariableKinds'; +export default class RestElement extends NodeBase implements DeclarationPatternNode { + declare argument: PatternNode; + declare type: NodeType.tRestElement; private declarationInit: ExpressionEntity | null = null; addExportedVariables( - variables: Variable[], - exportNamesByVariable: Map + variables: readonly Variable[], + exportNamesByVariable: ReadonlyMap ): void { this.argument.addExportedVariables(variables, exportNamesByVariable); } - bind() { - super.bind(); - if (this.declarationInit !== null) { - this.declarationInit.deoptimizePath([UnknownKey, UnknownKey]); + declare( + kind: VariableKind, + destructuredInitPath: ObjectPath, + init: ExpressionEntity + ): LocalVariable[] { + this.declarationInit = init; + return (this.argument as DeclarationPatternNode).declare( + kind, + getIncludedPatternPath(destructuredInitPath), + init + ); + } + + deoptimizeAssignment(destructuredInitPath: ObjectPath, init: ExpressionEntity): void { + this.argument.deoptimizeAssignment(getIncludedPatternPath(destructuredInitPath), init); + } + + deoptimizePath(path: ObjectPath): void { + if (path.length === 0) { + this.argument.deoptimizePath(EMPTY_PATH); } } - declare(kind: string, init: ExpressionEntity) { - this.declarationInit = init; - return this.argument.declare(kind, UNKNOWN_EXPRESSION); + hasEffectsOnInteractionAtPath( + path: ObjectPath, + interaction: NodeInteractionAssigned, + context: HasEffectsContext + ): boolean { + return ( + path.length > 0 || + this.argument.hasEffectsOnInteractionAtPath(EMPTY_PATH, interaction, context) + ); + } + + hasEffectsWhenDestructuring( + context: HasEffectsContext, + destructuredInitPath: ObjectPath, + init: ExpressionEntity + ): boolean { + return this.argument.hasEffectsWhenDestructuring( + context, + getIncludedPatternPath(destructuredInitPath), + init + ); } - deoptimizePath(path: ObjectPath) { - path.length === 0 && this.argument.deoptimizePath(EMPTY_PATH); + includeDestructuredIfNecessary( + context: InclusionContext, + destructuredInitPath: ObjectPath, + init: ExpressionEntity + ): boolean { + const included = this.argument.includeDestructuredIfNecessary( + context, + getIncludedPatternPath(destructuredInitPath), + init + ); + if (!this.included && included) { + this.includeNode(context); + } + return this.included; + } + + include(context: InclusionContext, includeChildrenRecursively: IncludeChildren) { + if (!this.included) this.includeNode(context); + // This should just include the identifier, its properties should be + // included where the variable is used. + this.argument.include(context, includeChildrenRecursively); + } + + markDeclarationReached(): void { + (this.argument as DeclarationPatternNode).markDeclarationReached(); } - hasEffectsWhenAssignedAtPath(path: ObjectPath, context: HasEffectsContext): boolean { - return path.length > 0 || this.argument.hasEffectsWhenAssignedAtPath(EMPTY_PATH, context); + applyDeoptimizations() { + this.deoptimized = true; + if (this.declarationInit !== null) { + this.declarationInit.deoptimizePath([UnknownKey, UnknownKey]); + this.scope.context.requestTreeshakingPass(); + } } } + +RestElement.prototype.includeNode = onlyIncludeSelf; + +const getIncludedPatternPath = (destructuredInitPath: ObjectPath): ObjectPath => + destructuredInitPath.at(-1) === UnknownKey + ? destructuredInitPath + : [...destructuredInitPath, UnknownKey]; diff --git a/src/ast/nodes/ReturnStatement.ts b/src/ast/nodes/ReturnStatement.ts index 87bec1a78c2..695019cd3f4 100644 --- a/src/ast/nodes/ReturnStatement.ts +++ b/src/ast/nodes/ReturnStatement.ts @@ -1,41 +1,43 @@ -import MagicString from 'magic-string'; -import { RenderOptions } from '../../utils/renderHelpers'; +import type MagicString from 'magic-string'; +import type { RenderOptions } from '../../utils/renderHelpers'; +import { type HasEffectsContext, type InclusionContext } from '../ExecutionContext'; +import { UNKNOWN_PATH } from '../utils/PathTracker'; +import type * as NodeType from './NodeType'; +import { UNKNOWN_EXPRESSION } from './shared/Expression'; import { - BROKEN_FLOW_ERROR_RETURN_LABEL, - HasEffectsContext, - InclusionContext -} from '../ExecutionContext'; -import { UNKNOWN_EXPRESSION } from '../values'; -import * as NodeType from './NodeType'; -import { ExpressionNode, IncludeChildren, StatementBase } from './shared/Node'; + doNotDeoptimize, + type ExpressionNode, + type IncludeChildren, + StatementBase +} from './shared/Node'; export default class ReturnStatement extends StatementBase { - argument!: ExpressionNode | null; - type!: NodeType.tReturnStatement; + declare argument: ExpressionNode | null; + declare type: NodeType.tReturnStatement; - hasEffects(context: HasEffectsContext) { - if ( - !context.ignore.returnAwaitYield || - (this.argument !== null && this.argument.hasEffects(context)) - ) - return true; - context.brokenFlow = BROKEN_FLOW_ERROR_RETURN_LABEL; + hasEffects(context: HasEffectsContext): boolean { + if (!context.ignore.returnYield || this.argument?.hasEffects(context)) return true; + context.brokenFlow = true; return false; } - include(context: InclusionContext, includeChildrenRecursively: IncludeChildren) { + include(context: InclusionContext, includeChildrenRecursively: IncludeChildren): void { + if (!this.included) this.includeNode(context); + this.argument?.include(context, includeChildrenRecursively); + context.brokenFlow = true; + } + + includeNode(context: InclusionContext) { this.included = true; - if (this.argument) { - this.argument.include(context, includeChildrenRecursively); - } - context.brokenFlow = BROKEN_FLOW_ERROR_RETURN_LABEL; + this.argument?.includePath(UNKNOWN_PATH, context); } - initialise() { + initialise(): void { + super.initialise(); this.scope.addReturnExpression(this.argument || UNKNOWN_EXPRESSION); } - render(code: MagicString, options: RenderOptions) { + render(code: MagicString, options: RenderOptions): void { if (this.argument) { this.argument.render(code, options, { preventASI: true }); if (this.argument.start === this.start + 6 /* 'return'.length */) { @@ -44,3 +46,5 @@ export default class ReturnStatement extends StatementBase { } } } + +ReturnStatement.prototype.applyDeoptimizations = doNotDeoptimize; diff --git a/src/ast/nodes/SequenceExpression.ts b/src/ast/nodes/SequenceExpression.ts index 13930c336f7..0d3fc7e17dd 100644 --- a/src/ast/nodes/SequenceExpression.ts +++ b/src/ast/nodes/SequenceExpression.ts @@ -1,32 +1,50 @@ -import MagicString from 'magic-string'; +import type MagicString from 'magic-string'; import { BLANK } from '../../utils/blank'; import { getCommaSeparatedNodesWithBoundaries, - NodeRenderOptions, + type NodeRenderOptions, removeLineBreaks, - RenderOptions + type RenderOptions } from '../../utils/renderHelpers'; import { treeshakeNode } from '../../utils/treeshakeNode'; -import { CallOptions } from '../CallOptions'; -import { DeoptimizableEntity } from '../DeoptimizableEntity'; -import { HasEffectsContext, InclusionContext } from '../ExecutionContext'; -import { ObjectPath, PathTracker } from '../utils/PathTracker'; -import { LiteralValueOrUnknown } from '../values'; -import CallExpression from './CallExpression'; -import * as NodeType from './NodeType'; -import { ExpressionNode, IncludeChildren, NodeBase } from './shared/Node'; +import type { DeoptimizableEntity } from '../DeoptimizableEntity'; +import type { HasEffectsContext, InclusionContext } from '../ExecutionContext'; +import type { NodeInteraction } from '../NodeInteractions'; +import { type EntityPathTracker, type ObjectPath } from '../utils/PathTracker'; +import ExpressionStatement from './ExpressionStatement'; +import type * as NodeType from './NodeType'; +import type { LiteralValueOrUnknown } from './shared/Expression'; +import { + doNotDeoptimize, + type ExpressionNode, + type IncludeChildren, + NodeBase, + onlyIncludeSelfNoDeoptimize +} from './shared/Node'; export default class SequenceExpression extends NodeBase { - expressions!: ExpressionNode[]; - type!: NodeType.tSequenceExpression; + declare expressions: ExpressionNode[]; + declare type: NodeType.tSequenceExpression; + + deoptimizeArgumentsOnInteractionAtPath( + interaction: NodeInteraction, + path: ObjectPath, + recursionTracker: EntityPathTracker + ): void { + this.expressions[this.expressions.length - 1].deoptimizeArgumentsOnInteractionAtPath( + interaction, + path, + recursionTracker + ); + } - deoptimizePath(path: ObjectPath) { - if (path.length > 0) this.expressions[this.expressions.length - 1].deoptimizePath(path); + deoptimizePath(path: ObjectPath): void { + this.expressions[this.expressions.length - 1].deoptimizePath(path); } getLiteralValueAtPath( path: ObjectPath, - recursionTracker: PathTracker, + recursionTracker: EntityPathTracker, origin: DeoptimizableEntity ): LiteralValueOrUnknown { return this.expressions[this.expressions.length - 1].getLiteralValueAtPath( @@ -43,49 +61,50 @@ export default class SequenceExpression extends NodeBase { return false; } - hasEffectsWhenAccessedAtPath(path: ObjectPath, context: HasEffectsContext): boolean { - return ( - path.length > 0 && - this.expressions[this.expressions.length - 1].hasEffectsWhenAccessedAtPath(path, context) - ); - } - - hasEffectsWhenAssignedAtPath(path: ObjectPath, context: HasEffectsContext): boolean { - return ( - path.length === 0 || - this.expressions[this.expressions.length - 1].hasEffectsWhenAssignedAtPath(path, context) - ); - } - - hasEffectsWhenCalledAtPath( + hasEffectsOnInteractionAtPath( path: ObjectPath, - callOptions: CallOptions, + interaction: NodeInteraction, context: HasEffectsContext ): boolean { - return this.expressions[this.expressions.length - 1].hasEffectsWhenCalledAtPath( + return this.expressions[this.expressions.length - 1].hasEffectsOnInteractionAtPath( path, - callOptions, + interaction, context ); } - include(context: InclusionContext, includeChildrenRecursively: IncludeChildren) { + include(context: InclusionContext, includeChildrenRecursively: IncludeChildren): void { this.included = true; - for (let i = 0; i < this.expressions.length - 1; i++) { - const node = this.expressions[i]; - if (includeChildrenRecursively || node.shouldBeIncluded(context)) - node.include(context, includeChildrenRecursively); + const lastExpression = this.expressions[this.expressions.length - 1]; + for (const expression of this.expressions) { + if ( + includeChildrenRecursively || + (expression === lastExpression && !(this.parent instanceof ExpressionStatement)) || + expression.shouldBeIncluded(context) + ) { + expression.include(context, includeChildrenRecursively); + } } - this.expressions[this.expressions.length - 1].include(context, includeChildrenRecursively); + } + + includePath(path: ObjectPath, context: InclusionContext): void { + this.included = true; + this.expressions[this.expressions.length - 1].includePath(path, context); + } + + removeAnnotations(code: MagicString) { + this.expressions[0].removeAnnotations(code); } render( code: MagicString, options: RenderOptions, { renderedParentType, isCalleeOfRenderedParent, preventASI }: NodeRenderOptions = BLANK - ) { + ): void { let includedNodes = 0; - for (const { node, start, end } of getCommaSeparatedNodesWithBoundaries( + let lastSeparatorPos: number | null = null; + const lastNode = this.expressions[this.expressions.length - 1]; + for (const { node, separator, start, end } of getCommaSeparatedNodesWithBoundaries( this.expressions, code, this.start, @@ -96,19 +115,26 @@ export default class SequenceExpression extends NodeBase { continue; } includedNodes++; + lastSeparatorPos = separator; if (includedNodes === 1 && preventASI) { removeLineBreaks(code, start, node.start); } - if (node === this.expressions[this.expressions.length - 1] && includedNodes === 1) { + if (includedNodes === 1) { + const parentType = renderedParentType || this.parent.type; node.render(code, options, { - isCalleeOfRenderedParent: renderedParentType - ? isCalleeOfRenderedParent - : (this.parent as CallExpression).callee === this, - renderedParentType: renderedParentType || this.parent.type + isCalleeOfRenderedParent: isCalleeOfRenderedParent && node === lastNode, + renderedParentType: parentType, + renderedSurroundingElement: parentType }); } else { node.render(code, options); } } + if (lastSeparatorPos) { + code.remove(lastSeparatorPos, this.end); + } } } + +SequenceExpression.prototype.includeNode = onlyIncludeSelfNoDeoptimize; +SequenceExpression.prototype.applyDeoptimizations = doNotDeoptimize; diff --git a/src/ast/nodes/SpreadElement.ts b/src/ast/nodes/SpreadElement.ts index cc0807079c4..a6f0a99c5db 100644 --- a/src/ast/nodes/SpreadElement.ts +++ b/src/ast/nodes/SpreadElement.ts @@ -1,15 +1,61 @@ -import { UnknownKey } from '../utils/PathTracker'; -import * as NodeType from './NodeType'; -import { ExpressionNode, NodeBase } from './shared/Node'; +import type { NormalizedTreeshakingOptions } from '../../rollup/types'; +import type { HasEffectsContext, InclusionContext } from '../ExecutionContext'; +import type { NodeInteraction } from '../NodeInteractions'; +import { NODE_INTERACTION_UNKNOWN_ACCESS } from '../NodeInteractions'; +import { + type EntityPathTracker, + type ObjectPath, + UNKNOWN_PATH, + UnknownKey +} from '../utils/PathTracker'; +import type * as NodeType from './NodeType'; +import { type ExpressionNode, NodeBase } from './shared/Node'; export default class SpreadElement extends NodeBase { - argument!: ExpressionNode; - type!: NodeType.tSpreadElement; + declare argument: ExpressionNode; + declare type: NodeType.tSpreadElement; - bind() { - super.bind(); + deoptimizeArgumentsOnInteractionAtPath( + interaction: NodeInteraction, + path: ObjectPath, + recursionTracker: EntityPathTracker + ): void { + if (path.length > 0) { + this.argument.deoptimizeArgumentsOnInteractionAtPath( + interaction, + UNKNOWN_PATH, + recursionTracker + ); + } + } + + hasEffects(context: HasEffectsContext): boolean { + if (!this.deoptimized) this.applyDeoptimizations(); + const { propertyReadSideEffects } = this.scope.context.options + .treeshake as NormalizedTreeshakingOptions; + return ( + this.argument.hasEffects(context) || + (propertyReadSideEffects && + (propertyReadSideEffects === 'always' || + this.argument.hasEffectsOnInteractionAtPath( + UNKNOWN_PATH, + NODE_INTERACTION_UNKNOWN_ACCESS, + context + ))) + ); + } + + includeNode(context: InclusionContext) { + this.included = true; + if (!this.deoptimized) this.applyDeoptimizations(); + this.argument.includePath(UNKNOWN_PATH, context); + } + + applyDeoptimizations() { + this.deoptimized = true; // Only properties of properties of the argument could become subject to reassignment // This will also reassign the return values of iterators this.argument.deoptimizePath([UnknownKey, UnknownKey]); + this.scope.context.requestTreeshakingPass(); } } diff --git a/src/ast/nodes/StaticBlock.ts b/src/ast/nodes/StaticBlock.ts new file mode 100644 index 00000000000..385737cf231 --- /dev/null +++ b/src/ast/nodes/StaticBlock.ts @@ -0,0 +1,58 @@ +import type MagicString from 'magic-string'; +import { + findFirstOccurrenceOutsideComment, + type RenderOptions, + renderStatementList +} from '../../utils/renderHelpers'; +import type { HasEffectsContext, InclusionContext } from '../ExecutionContext'; +import BlockScope from '../scopes/BlockScope'; +import type ChildScope from '../scopes/ChildScope'; +import * as NodeType from './NodeType'; +import { + doNotDeoptimize, + type IncludeChildren, + onlyIncludeSelfNoDeoptimize, + StatementBase, + type StatementNode +} from './shared/Node'; + +export default class StaticBlock extends StatementBase { + declare body: readonly StatementNode[]; + declare type: NodeType.tStaticBlock; + + createScope(parentScope: ChildScope): void { + this.scope = new BlockScope(parentScope); + } + + hasEffects(context: HasEffectsContext): boolean { + for (const node of this.body) { + if (node.hasEffects(context)) return true; + } + return false; + } + + include(context: InclusionContext, includeChildrenRecursively: IncludeChildren): void { + this.included = true; + for (const node of this.body) { + if (includeChildrenRecursively || node.shouldBeIncluded(context)) + node.include(context, includeChildrenRecursively); + } + } + + render(code: MagicString, options: RenderOptions): void { + if (this.body.length > 0) { + const bodyStartPos = + findFirstOccurrenceOutsideComment(code.original.slice(this.start, this.end), '{') + 1; + renderStatementList(this.body, code, this.start + bodyStartPos, this.end - 1, options); + } else { + super.render(code, options); + } + } +} + +StaticBlock.prototype.includeNode = onlyIncludeSelfNoDeoptimize; +StaticBlock.prototype.applyDeoptimizations = doNotDeoptimize; + +export function isStaticBlock(statement: StatementNode): statement is StaticBlock { + return statement.type === NodeType.StaticBlock; +} diff --git a/src/ast/nodes/Super.ts b/src/ast/nodes/Super.ts index d09554da7bc..f91ed0e709d 100644 --- a/src/ast/nodes/Super.ts +++ b/src/ast/nodes/Super.ts @@ -1,6 +1,38 @@ -import * as NodeType from './NodeType'; +import type { InclusionContext } from '../ExecutionContext'; +import type { NodeInteraction } from '../NodeInteractions'; +import type { EntityPathTracker, ObjectPath } from '../utils/PathTracker'; +import { EMPTY_PATH } from '../utils/PathTracker'; +import type Variable from '../variables/Variable'; +import type * as NodeType from './NodeType'; import { NodeBase } from './shared/Node'; export default class Super extends NodeBase { - type!: NodeType.tSuper; + declare type: NodeType.tSuper; + declare variable: Variable; + + bind(): void { + this.variable = this.scope.findVariable('this'); + } + + deoptimizeArgumentsOnInteractionAtPath( + interaction: NodeInteraction, + path: ObjectPath, + recursionTracker: EntityPathTracker + ) { + this.variable.deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker); + } + + deoptimizePath(path: ObjectPath): void { + this.variable.deoptimizePath(path); + } + + include(context: InclusionContext): void { + if (!this.included) this.includeNode(context); + } + + includeNode(context: InclusionContext) { + this.included = true; + if (!this.deoptimized) this.applyDeoptimizations(); + this.scope.context.includeVariableInModule(this.variable, EMPTY_PATH, context); + } } diff --git a/src/ast/nodes/SwitchCase.ts b/src/ast/nodes/SwitchCase.ts index 8baef42daeb..4f441300276 100644 --- a/src/ast/nodes/SwitchCase.ts +++ b/src/ast/nodes/SwitchCase.ts @@ -1,22 +1,29 @@ -import MagicString from 'magic-string'; +import type MagicString from 'magic-string'; import { findFirstOccurrenceOutsideComment, - NodeRenderOptions, - RenderOptions, + type NodeRenderOptions, + type RenderOptions, renderStatementList } from '../../utils/renderHelpers'; -import { HasEffectsContext, InclusionContext } from '../ExecutionContext'; -import * as NodeType from './NodeType'; -import { ExpressionNode, IncludeChildren, NodeBase, StatementNode } from './shared/Node'; +import type { HasEffectsContext, InclusionContext } from '../ExecutionContext'; +import type * as NodeType from './NodeType'; +import { + doNotDeoptimize, + type ExpressionNode, + type IncludeChildren, + NodeBase, + onlyIncludeSelfNoDeoptimize, + type StatementNode +} from './shared/Node'; export default class SwitchCase extends NodeBase { - consequent!: StatementNode[]; - needsBoundaries!: true; - test!: ExpressionNode | null; - type!: NodeType.tSwitchCase; + declare consequent: readonly StatementNode[]; + declare needsBoundaries: true; + declare test: ExpressionNode | null; + declare type: NodeType.tSwitchCase; hasEffects(context: HasEffectsContext): boolean { - if (this.test && this.test.hasEffects(context)) return true; + if (this.test?.hasEffects(context)) return true; for (const node of this.consequent) { if (context.brokenFlow) break; if (node.hasEffects(context)) return true; @@ -24,27 +31,32 @@ export default class SwitchCase extends NodeBase { return false; } - include(context: InclusionContext, includeChildrenRecursively: IncludeChildren) { + include(context: InclusionContext, includeChildrenRecursively: IncludeChildren): void { this.included = true; - if (this.test) this.test.include(context, includeChildrenRecursively); + this.test?.include(context, includeChildrenRecursively); for (const node of this.consequent) { if (includeChildrenRecursively || node.shouldBeIncluded(context)) node.include(context, includeChildrenRecursively); } } - render(code: MagicString, options: RenderOptions, nodeRenderOptions?: NodeRenderOptions) { - if (this.consequent.length) { - this.test && this.test.render(code, options); + render(code: MagicString, options: RenderOptions, nodeRenderOptions?: NodeRenderOptions): void { + if (this.test) { + this.test.render(code, options); + if (this.test.start === this.start + 4) { + code.prependLeft(this.test.start, ' '); + } + } + if (this.consequent.length > 0) { const testEnd = this.test ? this.test.end : findFirstOccurrenceOutsideComment(code.original, 'default', this.start) + 7; const consequentStart = findFirstOccurrenceOutsideComment(code.original, ':', testEnd) + 1; renderStatementList(this.consequent, code, consequentStart, nodeRenderOptions!.end!, options); - } else { - super.render(code, options); } } } SwitchCase.prototype.needsBoundaries = true; +SwitchCase.prototype.includeNode = onlyIncludeSelfNoDeoptimize; +SwitchCase.prototype.applyDeoptimizations = doNotDeoptimize; diff --git a/src/ast/nodes/SwitchStatement.ts b/src/ast/nodes/SwitchStatement.ts index 2850b18f122..97e83e77109 100644 --- a/src/ast/nodes/SwitchStatement.ts +++ b/src/ast/nodes/SwitchStatement.ts @@ -1,53 +1,57 @@ -import MagicString from 'magic-string'; -import { RenderOptions, renderStatementList } from '../../utils/renderHelpers'; +import type MagicString from 'magic-string'; +import { type RenderOptions, renderStatementList } from '../../utils/renderHelpers'; import { - BROKEN_FLOW_BREAK_CONTINUE, createHasEffectsContext, - HasEffectsContext, - InclusionContext + type HasEffectsContext, + type InclusionContext } from '../ExecutionContext'; import BlockScope from '../scopes/BlockScope'; -import Scope from '../scopes/Scope'; -import * as NodeType from './NodeType'; -import { ExpressionNode, IncludeChildren, StatementBase } from './shared/Node'; -import SwitchCase from './SwitchCase'; +import type ChildScope from '../scopes/ChildScope'; +import type * as NodeType from './NodeType'; +import type { ExpressionNode, GenericEsTreeNode, IncludeChildren } from './shared/Node'; +import { doNotDeoptimize, onlyIncludeSelfNoDeoptimize, StatementBase } from './shared/Node'; +import type SwitchCase from './SwitchCase'; export default class SwitchStatement extends StatementBase { - cases!: SwitchCase[]; - discriminant!: ExpressionNode; - type!: NodeType.tSwitchStatement; + declare cases: readonly SwitchCase[]; + declare discriminant: ExpressionNode; + declare type: NodeType.tSwitchStatement; - private defaultCase!: number | null; + declare parentScope: ChildScope; + declare private defaultCase: number | null; - createScope(parentScope: Scope) { + createScope(parentScope: ChildScope): void { + this.parentScope = parentScope; this.scope = new BlockScope(parentScope); } - hasEffects(context: HasEffectsContext) { + hasEffects(context: HasEffectsContext): boolean { if (this.discriminant.hasEffects(context)) return true; - const { - brokenFlow, - ignore: { breaks } - } = context; - let minBrokenFlow = Infinity; - context.ignore.breaks = true; + const { brokenFlow, hasBreak, ignore } = context; + const { breaks } = ignore; + ignore.breaks = true; + context.hasBreak = false; + let onlyHasBrokenFlow = true; for (const switchCase of this.cases) { if (switchCase.hasEffects(context)) return true; - minBrokenFlow = context.brokenFlow < minBrokenFlow ? context.brokenFlow : minBrokenFlow; + onlyHasBrokenFlow &&= context.brokenFlow && !context.hasBreak; + context.hasBreak = false; context.brokenFlow = brokenFlow; } - if (this.defaultCase !== null && !(minBrokenFlow === BROKEN_FLOW_BREAK_CONTINUE)) { - context.brokenFlow = minBrokenFlow; + if (this.defaultCase !== null) { + context.brokenFlow = onlyHasBrokenFlow; } - context.ignore.breaks = breaks; + ignore.breaks = breaks; + context.hasBreak = hasBreak; return false; } - include(context: InclusionContext, includeChildrenRecursively: IncludeChildren) { + include(context: InclusionContext, includeChildrenRecursively: IncludeChildren): void { this.included = true; this.discriminant.include(context, includeChildrenRecursively); - const { brokenFlow } = context; - let minBrokenFlow = Infinity; + const { brokenFlow, hasBreak } = context; + context.hasBreak = false; + let onlyHasBrokenFlow = true; let isCaseIncluded = includeChildrenRecursively || (this.defaultCase !== null && this.defaultCase < this.cases.length - 1); @@ -63,22 +67,21 @@ export default class SwitchStatement extends StatementBase { } if (isCaseIncluded) { switchCase.include(context, includeChildrenRecursively); - minBrokenFlow = minBrokenFlow < context.brokenFlow ? minBrokenFlow : context.brokenFlow; + onlyHasBrokenFlow &&= context.brokenFlow && !context.hasBreak; + context.hasBreak = false; context.brokenFlow = brokenFlow; } else { - minBrokenFlow = brokenFlow; + onlyHasBrokenFlow = brokenFlow; } } - if ( - isCaseIncluded && - this.defaultCase !== null && - !(minBrokenFlow === BROKEN_FLOW_BREAK_CONTINUE) - ) { - context.brokenFlow = minBrokenFlow; + if (isCaseIncluded && this.defaultCase !== null) { + context.brokenFlow = onlyHasBrokenFlow; } + context.hasBreak = hasBreak; } - initialise() { + initialise(): void { + super.initialise(); for (let caseIndex = 0; caseIndex < this.cases.length; caseIndex++) { if (this.cases[caseIndex].test === null) { this.defaultCase = caseIndex; @@ -88,10 +91,21 @@ export default class SwitchStatement extends StatementBase { this.defaultCase = null; } - render(code: MagicString, options: RenderOptions) { + parseNode(esTreeNode: GenericEsTreeNode): this { + this.discriminant = new (this.scope.context.getNodeConstructor(esTreeNode.discriminant.type))( + this, + this.parentScope + ).parseNode(esTreeNode.discriminant); + return super.parseNode(esTreeNode); + } + + render(code: MagicString, options: RenderOptions): void { this.discriminant.render(code, options); if (this.cases.length > 0) { renderStatementList(this.cases, code, this.cases[0].start, this.end - 1, options); } } } + +SwitchStatement.prototype.includeNode = onlyIncludeSelfNoDeoptimize; +SwitchStatement.prototype.applyDeoptimizations = doNotDeoptimize; diff --git a/src/ast/nodes/TaggedTemplateExpression.ts b/src/ast/nodes/TaggedTemplateExpression.ts index 84e9dffc3fe..2b64d3b713a 100644 --- a/src/ast/nodes/TaggedTemplateExpression.ts +++ b/src/ast/nodes/TaggedTemplateExpression.ts @@ -1,58 +1,110 @@ -import { CallOptions, NO_ARGS } from '../CallOptions'; -import { HasEffectsContext } from '../ExecutionContext'; -import { EMPTY_PATH } from '../utils/PathTracker'; -import Identifier from './Identifier'; +import type MagicString from 'magic-string'; +import { LOGLEVEL_WARN } from '../../utils/logging'; +import { logCannotCallNamespace } from '../../utils/logs'; +import { type RenderOptions } from '../../utils/renderHelpers'; +import type { HasEffectsContext, InclusionContext } from '../ExecutionContext'; +import { INTERACTION_CALLED } from '../NodeInteractions'; +import type { EntityPathTracker } from '../utils/PathTracker'; +import { EMPTY_PATH, SHARED_RECURSION_TRACKER } from '../utils/PathTracker'; +import type Identifier from './Identifier'; +import MemberExpression from './MemberExpression'; import * as NodeType from './NodeType'; -import { ExpressionNode, NodeBase } from './shared/Node'; -import TemplateLiteral from './TemplateLiteral'; +import { Flag, isFlagSet, setFlag } from './shared/BitFlags'; +import CallExpressionBase from './shared/CallExpressionBase'; +import type { ExpressionEntity } from './shared/Expression'; +import { UNKNOWN_EXPRESSION, UNKNOWN_RETURN_EXPRESSION } from './shared/Expression'; +import type { ExpressionNode, IncludeChildren } from './shared/Node'; +import { onlyIncludeSelf } from './shared/Node'; +import type TemplateLiteral from './TemplateLiteral'; -export default class TaggedTemplateExpression extends NodeBase { - quasi!: TemplateLiteral; - tag!: ExpressionNode; - type!: NodeType.tTaggedTemplateExpression; +export default class TaggedTemplateExpression extends CallExpressionBase { + declare quasi: TemplateLiteral; + declare tag: ExpressionNode; + declare type: NodeType.tTaggedTemplateExpression; + declare private args: ExpressionEntity[]; - private callOptions!: CallOptions; + private get hasCheckedForWarnings(): boolean { + return isFlagSet(this.flags, Flag.checkedForWarnings); + } + private set hasCheckedForWarnings(value: boolean) { + this.flags = setFlag(this.flags, Flag.checkedForWarnings, value); + } + + hasEffects(context: HasEffectsContext): boolean { + if (!this.deoptimized) this.applyDeoptimizations(); + for (const argument of this.quasi.expressions) { + if (argument.hasEffects(context)) return true; + } + return ( + this.tag.hasEffects(context) || + this.tag.hasEffectsOnInteractionAtPath(EMPTY_PATH, this.interaction, context) + ); + } + + include(context: InclusionContext, includeChildrenRecursively: IncludeChildren): void { + if (!this.included) this.includeNode(context); + if (includeChildrenRecursively) { + super.include(context, true); + } else { + this.quasi.include(context, false); + this.tag.include(context, false); + this.tag.includeCallArguments(this.interaction, context); + } + } + + initialise(): void { + super.initialise(); + this.args = [UNKNOWN_EXPRESSION, ...this.quasi.expressions]; + this.interaction = { + args: [ + this.tag instanceof MemberExpression && !this.tag.variable ? this.tag.object : null, + ...this.args + ], + type: INTERACTION_CALLED, + withNew: false + }; + } + + render(code: MagicString, options: RenderOptions): void { + this.tag.render(code, options, { isCalleeOfRenderedParent: true }); + this.quasi.render(code, options); + + if (!this.hasCheckedForWarnings && this.tag.type === NodeType.Identifier) { + this.hasCheckedForWarnings = true; - bind() { - super.bind(); - if (this.tag.type === NodeType.Identifier) { const name = (this.tag as Identifier).name; const variable = this.scope.findVariable(name); if (variable.isNamespace) { - this.context.warn( - { - code: 'CANNOT_CALL_NAMESPACE', - message: `Cannot call a namespace ('${name}')`, - }, - this.start - ); - } - - if (name === 'eval') { - this.context.warn( - { - code: 'EVAL', - message: `Use of eval is strongly discouraged, as it poses security risks and may cause issues with minification`, - url: 'https://rollupjs.org/guide/en/#avoiding-eval', - }, - this.start - ); + this.scope.context.log(LOGLEVEL_WARN, logCannotCallNamespace(name), this.start); } } } - hasEffects(context: HasEffectsContext) { - return ( - super.hasEffects(context) || - this.tag.hasEffectsWhenCalledAtPath(EMPTY_PATH, this.callOptions, context) + applyDeoptimizations() { + this.deoptimized = true; + this.tag.deoptimizeArgumentsOnInteractionAtPath( + this.interaction, + EMPTY_PATH, + SHARED_RECURSION_TRACKER ); + this.scope.context.requestTreeshakingPass(); } - initialise() { - this.callOptions = { - args: NO_ARGS, - withNew: false, - }; + protected getReturnExpression( + recursionTracker: EntityPathTracker = SHARED_RECURSION_TRACKER + ): [expression: ExpressionEntity, isPure: boolean] { + if (this.returnExpression === null) { + this.returnExpression = UNKNOWN_RETURN_EXPRESSION; + return (this.returnExpression = this.tag.getReturnExpressionWhenCalledAtPath( + EMPTY_PATH, + this.interaction, + recursionTracker, + this + )); + } + return this.returnExpression; } } + +TaggedTemplateExpression.prototype.includeNode = onlyIncludeSelf; diff --git a/src/ast/nodes/TemplateElement.ts b/src/ast/nodes/TemplateElement.ts index e5cc466fc3a..3bafb0f14db 100644 --- a/src/ast/nodes/TemplateElement.ts +++ b/src/ast/nodes/TemplateElement.ts @@ -1,28 +1,34 @@ -import * as NodeType from './NodeType'; -import { GenericEsTreeNode, NodeBase } from './shared/Node'; +import type * as NodeType from './NodeType'; +import { Flag, isFlagSet, setFlag } from './shared/BitFlags'; +import { type GenericEsTreeNode, NodeBase, onlyIncludeSelf } from './shared/Node'; export default class TemplateElement extends NodeBase { - tail!: boolean; - type!: NodeType.tTemplateElement; - value!: { + declare type: NodeType.tTemplateElement; + declare value: { cooked: string | null; raw: string; }; - bind() {} - - hasEffects() { - return false; + get tail(): boolean { + return isFlagSet(this.flags, Flag.tail); + } + set tail(value: boolean) { + this.flags = setFlag(this.flags, Flag.tail, value); } - include() { - this.included = true; + // Do not try to bind value + bind(): void {} + + hasEffects(): boolean { + return false; } - parseNode(esTreeNode: GenericEsTreeNode) { + parseNode(esTreeNode: GenericEsTreeNode): this { this.value = esTreeNode.value; - super.parseNode(esTreeNode); + return super.parseNode(esTreeNode); } - render() {} + render(): void {} } + +TemplateElement.prototype.includeNode = onlyIncludeSelf; diff --git a/src/ast/nodes/TemplateLiteral.ts b/src/ast/nodes/TemplateLiteral.ts index fbc02c708ee..ee0279a55e0 100644 --- a/src/ast/nodes/TemplateLiteral.ts +++ b/src/ast/nodes/TemplateLiteral.ts @@ -1,15 +1,27 @@ -import MagicString from 'magic-string'; -import { RenderOptions } from '../../utils/renderHelpers'; -import { ObjectPath } from '../utils/PathTracker'; -import { LiteralValueOrUnknown, UnknownValue } from '../values'; -import * as NodeType from './NodeType'; -import { ExpressionNode, NodeBase } from './shared/Node'; -import TemplateElement from './TemplateElement'; +import type MagicString from 'magic-string'; +import type { RenderOptions } from '../../utils/renderHelpers'; +import type { HasEffectsContext, InclusionContext } from '../ExecutionContext'; +import type { NodeInteraction } from '../NodeInteractions'; +import { INTERACTION_ACCESSED, INTERACTION_CALLED } from '../NodeInteractions'; +import type { ObjectPath } from '../utils/PathTracker'; +import { UNKNOWN_PATH } from '../utils/PathTracker'; +import { + getMemberReturnExpressionWhenCalled, + hasMemberEffectWhenCalled, + literalStringMembers +} from '../values'; +import type * as NodeType from './NodeType'; +import type { ExpressionEntity, LiteralValueOrUnknown } from './shared/Expression'; +import { UNKNOWN_RETURN_EXPRESSION, UnknownValue } from './shared/Expression'; +import { type ExpressionNode, NodeBase } from './shared/Node'; +import type TemplateElement from './TemplateElement'; export default class TemplateLiteral extends NodeBase { - expressions!: ExpressionNode[]; - quasis!: TemplateElement[]; - type!: NodeType.tTemplateLiteral; + declare expressions: ExpressionNode[]; + declare quasis: TemplateElement[]; + declare type: NodeType.tTemplateLiteral; + + deoptimizeArgumentsOnInteractionAtPath(): void {} getLiteralValueAtPath(path: ObjectPath): LiteralValueOrUnknown { if (path.length > 0 || this.quasis.length !== 1) { @@ -18,11 +30,39 @@ export default class TemplateLiteral extends NodeBase { return this.quasis[0].value.cooked; } - render(code: MagicString, options: RenderOptions) { - (code.indentExclusionRanges as [number, number][]).push([this.start, this.end] as [ - number, - number - ]); + getReturnExpressionWhenCalledAtPath( + path: ObjectPath + ): [expression: ExpressionEntity, isPure: boolean] { + if (path.length !== 1) { + return UNKNOWN_RETURN_EXPRESSION; + } + return getMemberReturnExpressionWhenCalled(literalStringMembers, path[0]); + } + + hasEffectsOnInteractionAtPath( + path: ObjectPath, + interaction: NodeInteraction, + context: HasEffectsContext + ): boolean { + if (interaction.type === INTERACTION_ACCESSED) { + return path.length > 1; + } + if (interaction.type === INTERACTION_CALLED && path.length === 1) { + return hasMemberEffectWhenCalled(literalStringMembers, path[0], interaction, context); + } + return true; + } + + includeNode(context: InclusionContext) { + this.included = true; + if (!this.deoptimized) this.applyDeoptimizations(); + for (const node of this.expressions) { + node.includePath(UNKNOWN_PATH, context); + } + } + + render(code: MagicString, options: RenderOptions): void { + (code.indentExclusionRanges as [number, number][]).push([this.start, this.end]); super.render(code, options); } } diff --git a/src/ast/nodes/ThisExpression.ts b/src/ast/nodes/ThisExpression.ts index f68631adae6..f9e5e79541c 100644 --- a/src/ast/nodes/ThisExpression.ts +++ b/src/ast/nodes/ThisExpression.ts @@ -1,53 +1,92 @@ -import MagicString from 'magic-string'; -import { HasEffectsContext } from '../ExecutionContext'; +import type MagicString from 'magic-string'; +import { LOGLEVEL_WARN } from '../../utils/logging'; +import { logThisIsUndefined } from '../../utils/logs'; +import type { HasEffectsContext, InclusionContext } from '../ExecutionContext'; +import type { NodeInteraction } from '../NodeInteractions'; +import { INTERACTION_ACCESSED } from '../NodeInteractions'; +import ChildScope from '../scopes/ChildScope'; +import FunctionScope from '../scopes/FunctionScope'; import ModuleScope from '../scopes/ModuleScope'; -import { ObjectPath } from '../utils/PathTracker'; -import ThisVariable from '../variables/ThisVariable'; -import * as NodeType from './NodeType'; -import FunctionNode from './shared/FunctionNode'; +import type Scope from '../scopes/Scope'; +import type { EntityPathTracker, ObjectPath } from '../utils/PathTracker'; +import { EMPTY_PATH } from '../utils/PathTracker'; +import type Variable from '../variables/Variable'; +import type * as NodeType from './NodeType'; +import ObjectExpression from './ObjectExpression'; +import Property from './Property'; import { NodeBase } from './shared/Node'; export default class ThisExpression extends NodeBase { - type!: NodeType.tThisExpression; + declare type: NodeType.tThisExpression; + declare variable: Variable; + declare private alias: string | null; - variable!: ThisVariable; - private alias!: string | null; + bind(): void { + this.variable = this.scope.findVariable('this'); + } + + deoptimizeArgumentsOnInteractionAtPath( + interaction: NodeInteraction, + path: ObjectPath, + recursionTracker: EntityPathTracker + ): void { + this.variable.deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker); + } + + deoptimizePath(path: ObjectPath): void { + this.variable.deoptimizePath(path); + } - bind() { - super.bind(); - this.variable = this.scope.findVariable('this') as ThisVariable; + hasEffectsOnInteractionAtPath( + path: ObjectPath, + interaction: NodeInteraction, + context: HasEffectsContext + ): boolean { + if (path.length === 0) { + return interaction.type !== INTERACTION_ACCESSED; + } + return this.variable.hasEffectsOnInteractionAtPath(path, interaction, context); } - hasEffectsWhenAccessedAtPath(path: ObjectPath, context: HasEffectsContext): boolean { - return path.length > 0 && this.variable.hasEffectsWhenAccessedAtPath(path, context); + include(context: InclusionContext): void { + if (!this.included) this.includeNode(context); } - hasEffectsWhenAssignedAtPath(path: ObjectPath, context: HasEffectsContext): boolean { - return this.variable.hasEffectsWhenAssignedAtPath(path, context); + includeNode(context: InclusionContext) { + this.included = true; + if (!this.deoptimized) this.applyDeoptimizations(); + this.scope.context.includeVariableInModule(this.variable, EMPTY_PATH, context); } - initialise() { + includePath(path: ObjectPath, context: InclusionContext): void { + if (!this.included) { + this.included = true; + this.scope.context.includeVariableInModule(this.variable, path, context); + } else if (path.length > 0) { + this.variable.includePath(path, context); + } + const functionScope = findFunctionScope(this.scope, this.variable); + if ( + functionScope && + functionScope.functionNode.parent instanceof Property && + functionScope.functionNode.parent.parent instanceof ObjectExpression + ) { + functionScope.functionNode.parent.parent.includePath(path, context); + } + } + + initialise(): void { + super.initialise(); this.alias = - this.scope.findLexicalBoundary() instanceof ModuleScope ? this.context.moduleContext : null; + this.scope.findLexicalBoundary() instanceof ModuleScope + ? this.scope.context.moduleContext + : null; if (this.alias === 'undefined') { - this.context.warn( - { - code: 'THIS_IS_UNDEFINED', - message: `The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten`, - url: `https://rollupjs.org/guide/en/#error-this-is-undefined` - }, - this.start - ); - } - for (let parent = this.parent; parent instanceof NodeBase; parent = parent.parent) { - if (parent instanceof FunctionNode) { - parent.referencesThis = true; - break; - } + this.scope.context.log(LOGLEVEL_WARN, logThisIsUndefined(), this.start); } } - render(code: MagicString) { + render(code: MagicString): void { if (this.alias !== null) { code.overwrite(this.start, this.end, this.alias, { contentOnly: false, @@ -56,3 +95,13 @@ export default class ThisExpression extends NodeBase { } } } + +function findFunctionScope(scope: Scope | ChildScope, thisVariable: Variable) { + while (!(scope instanceof FunctionScope && scope.thisVariable === thisVariable)) { + if (!(scope instanceof ChildScope)) { + return null; + } + scope = scope.parent; + } + return scope; +} diff --git a/src/ast/nodes/ThrowStatement.ts b/src/ast/nodes/ThrowStatement.ts index bd52675707c..fab4b3e3fe5 100644 --- a/src/ast/nodes/ThrowStatement.ts +++ b/src/ast/nodes/ThrowStatement.ts @@ -1,24 +1,32 @@ -import MagicString from 'magic-string'; -import { RenderOptions } from '../../utils/renderHelpers'; -import { BROKEN_FLOW_ERROR_RETURN_LABEL, InclusionContext } from '../ExecutionContext'; -import * as NodeType from './NodeType'; -import { ExpressionNode, IncludeChildren, StatementBase } from './shared/Node'; +import type MagicString from 'magic-string'; +import type { RenderOptions } from '../../utils/renderHelpers'; +import { type InclusionContext } from '../ExecutionContext'; +import { UNKNOWN_PATH } from '../utils/PathTracker'; +import type * as NodeType from './NodeType'; +import { type ExpressionNode, type IncludeChildren, StatementBase } from './shared/Node'; export default class ThrowStatement extends StatementBase { - argument!: ExpressionNode; - type!: NodeType.tThrowStatement; + declare argument: ExpressionNode; + declare type: NodeType.tThrowStatement; - hasEffects() { + hasEffects(): boolean { return true; } - include(context: InclusionContext, includeChildrenRecursively: IncludeChildren) { - this.included = true; + include(context: InclusionContext, includeChildrenRecursively: IncludeChildren): void { + if (!this.included) this.includeNode(context); this.argument.include(context, includeChildrenRecursively); - context.brokenFlow = BROKEN_FLOW_ERROR_RETURN_LABEL; + context.brokenFlow = true; } - render(code: MagicString, options: RenderOptions) { + includeNode(context: InclusionContext) { + if (!this.included) { + this.included = true; + this.argument.includePath(UNKNOWN_PATH, context); + } + } + + render(code: MagicString, options: RenderOptions): void { this.argument.render(code, options, { preventASI: true }); if (this.argument.start === this.start + 5 /* 'throw'.length */) { code.prependLeft(this.start + 5, ' '); diff --git a/src/ast/nodes/TryStatement.ts b/src/ast/nodes/TryStatement.ts index 3a9483d1d26..5ec6fff814b 100644 --- a/src/ast/nodes/TryStatement.ts +++ b/src/ast/nodes/TryStatement.ts @@ -1,32 +1,38 @@ -import { NormalizedTreeshakingOptions } from '../../rollup/types'; -import { HasEffectsContext, InclusionContext } from '../ExecutionContext'; -import BlockStatement from './BlockStatement'; -import CatchClause from './CatchClause'; -import * as NodeType from './NodeType'; -import { IncludeChildren, INCLUDE_PARAMETERS, StatementBase } from './shared/Node'; +import type { NormalizedTreeshakingOptions } from '../../rollup/types'; +import type { HasEffectsContext, InclusionContext } from '../ExecutionContext'; +import type BlockStatement from './BlockStatement'; +import type CatchClause from './CatchClause'; +import type * as NodeType from './NodeType'; +import { + doNotDeoptimize, + INCLUDE_PARAMETERS, + type IncludeChildren, + onlyIncludeSelfNoDeoptimize, + StatementBase +} from './shared/Node'; export default class TryStatement extends StatementBase { - block!: BlockStatement; - finalizer!: BlockStatement | null; - handler!: CatchClause | null; - type!: NodeType.tTryStatement; + declare block: BlockStatement; + declare finalizer: BlockStatement | null; + declare handler: CatchClause | null; + declare type: NodeType.tTryStatement; private directlyIncluded = false; private includedLabelsAfterBlock: string[] | null = null; hasEffects(context: HasEffectsContext): boolean { return ( - ((this.context.options.treeshake as NormalizedTreeshakingOptions).tryCatchDeoptimization + ((this.scope.context.options.treeshake as NormalizedTreeshakingOptions).tryCatchDeoptimization ? this.block.body.length > 0 - : this.block.hasEffects(context)) || - (this.finalizer !== null && this.finalizer.hasEffects(context)) + : this.block.hasEffects(context)) || !!this.finalizer?.hasEffects(context) ); } - include(context: InclusionContext, includeChildrenRecursively: IncludeChildren) { - const tryCatchDeoptimization = (this.context.options.treeshake as NormalizedTreeshakingOptions) - ?.tryCatchDeoptimization; - const { brokenFlow } = context; + include(context: InclusionContext, includeChildrenRecursively: IncludeChildren): void { + const tryCatchDeoptimization = ( + this.scope.context.options.treeshake as NormalizedTreeshakingOptions + )?.tryCatchDeoptimization; + const { brokenFlow, includedLabels } = context; if (!this.directlyIncluded || !tryCatchDeoptimization) { this.included = true; this.directlyIncluded = true; @@ -34,21 +40,22 @@ export default class TryStatement extends StatementBase { context, tryCatchDeoptimization ? INCLUDE_PARAMETERS : includeChildrenRecursively ); - if (context.includedLabels.size > 0) { - this.includedLabelsAfterBlock = [...context.includedLabels]; + if (includedLabels.size > 0) { + this.includedLabelsAfterBlock = [...includedLabels]; } context.brokenFlow = brokenFlow; } else if (this.includedLabelsAfterBlock) { for (const label of this.includedLabelsAfterBlock) { - context.includedLabels.add(label); + includedLabels.add(label); } } if (this.handler !== null) { this.handler.include(context, includeChildrenRecursively); context.brokenFlow = brokenFlow; } - if (this.finalizer !== null) { - this.finalizer.include(context, includeChildrenRecursively); - } + this.finalizer?.include(context, includeChildrenRecursively); } } + +TryStatement.prototype.includeNode = onlyIncludeSelfNoDeoptimize; +TryStatement.prototype.applyDeoptimizations = doNotDeoptimize; diff --git a/src/ast/nodes/UnaryExpression.ts b/src/ast/nodes/UnaryExpression.ts index b80b70474ea..15973cf724d 100644 --- a/src/ast/nodes/UnaryExpression.ts +++ b/src/ast/nodes/UnaryExpression.ts @@ -1,15 +1,31 @@ -import { DeoptimizableEntity } from '../DeoptimizableEntity'; -import { HasEffectsContext } from '../ExecutionContext'; -import { EMPTY_PATH, ObjectPath, PathTracker } from '../utils/PathTracker'; -import { LiteralValueOrUnknown, UnknownValue } from '../values'; +import type MagicString from 'magic-string'; +import type { RenderOptions } from '../../utils/renderHelpers'; +import type { DeoptimizableEntity } from '../DeoptimizableEntity'; +import type { HasEffectsContext, InclusionContext } from '../ExecutionContext'; +import type { NodeInteraction } from '../NodeInteractions'; +import { INTERACTION_ACCESSED, NODE_INTERACTION_UNKNOWN_ASSIGNMENT } from '../NodeInteractions'; +import { + EMPTY_PATH, + type EntityPathTracker, + type ObjectPath, + SHARED_RECURSION_TRACKER +} from '../utils/PathTracker'; +import { getRenderedLiteralValue } from '../utils/renderLiteralValue'; import Identifier from './Identifier'; -import { LiteralValue } from './Literal'; -import * as NodeType from './NodeType'; -import { ExpressionNode, NodeBase } from './shared/Node'; +import type { LiteralValue } from './Literal'; +import type * as NodeType from './NodeType'; +import { Flag, isFlagSet, setFlag } from './shared/BitFlags'; +import type { InclusionOptions } from './shared/Expression'; +import { + type LiteralValueOrUnknown, + UnknownFalsyValue, + UnknownTruthyValue, + UnknownValue +} from './shared/Expression'; +import type { IncludeChildren } from './shared/Node'; +import { type ExpressionNode, NodeBase, onlyIncludeSelf } from './shared/Node'; -const unaryOperators: { - [operator: string]: (value: LiteralValue) => LiteralValueOrUnknown; -} = { +const unaryOperators: Record LiteralValueOrUnknown> = { '!': value => !value, '+': value => +(value as NonNullable), '-': value => -(value as NonNullable), @@ -19,44 +35,112 @@ const unaryOperators: { '~': value => ~(value as NonNullable) }; +const UNASSIGNED = Symbol('Unassigned'); + export default class UnaryExpression extends NodeBase { - argument!: ExpressionNode; - operator!: '!' | '+' | '-' | 'delete' | 'typeof' | 'void' | '~'; - prefix!: boolean; - type!: NodeType.tUnaryExpression; + declare argument: ExpressionNode; + declare operator: '!' | '+' | '-' | 'delete' | 'typeof' | 'void' | '~'; + declare type: NodeType.tUnaryExpression; + renderedLiteralValue: string | typeof UnknownValue | typeof UNASSIGNED = UNASSIGNED; - bind() { - super.bind(); - if (this.operator === 'delete') { - this.argument.deoptimizePath(EMPTY_PATH); - } + get prefix(): boolean { + return isFlagSet(this.flags, Flag.prefix); + } + set prefix(value: boolean) { + this.flags = setFlag(this.flags, Flag.prefix, value); + } + + deoptimizeCache(): void { + this.renderedLiteralValue = UnknownValue; } getLiteralValueAtPath( path: ObjectPath, - recursionTracker: PathTracker, + recursionTracker: EntityPathTracker, origin: DeoptimizableEntity ): LiteralValueOrUnknown { if (path.length > 0) return UnknownValue; const argumentValue = this.argument.getLiteralValueAtPath(EMPTY_PATH, recursionTracker, origin); - if (argumentValue === UnknownValue) return UnknownValue; + if (typeof argumentValue === 'symbol') { + if (this.operator === 'void') return undefined; + if (this.operator === '!') { + if (argumentValue === UnknownFalsyValue) return true; + if (argumentValue === UnknownTruthyValue) return false; + } + return UnknownValue; + } return unaryOperators[this.operator](argumentValue); } hasEffects(context: HasEffectsContext): boolean { + if (!this.deoptimized) this.applyDeoptimizations(); if (this.operator === 'typeof' && this.argument instanceof Identifier) return false; return ( this.argument.hasEffects(context) || (this.operator === 'delete' && - this.argument.hasEffectsWhenAssignedAtPath(EMPTY_PATH, context)) + this.argument.hasEffectsOnInteractionAtPath( + EMPTY_PATH, + NODE_INTERACTION_UNKNOWN_ASSIGNMENT, + context + )) ); } - hasEffectsWhenAccessedAtPath(path: ObjectPath) { - if (this.operator === 'void') { - return path.length > 0; + hasEffectsOnInteractionAtPath(path: ObjectPath, { type }: NodeInteraction): boolean { + return type !== INTERACTION_ACCESSED || path.length > (this.operator === 'void' ? 0 : 1); + } + + applyDeoptimizations() { + this.deoptimized = true; + if (this.operator === 'delete') { + this.argument.deoptimizePath(EMPTY_PATH); + this.scope.context.requestTreeshakingPass(); + } + } + + getRenderedLiteralValue(includeChildrenRecursively: IncludeChildren) { + if (this.renderedLiteralValue !== UNASSIGNED) return this.renderedLiteralValue; + return (this.renderedLiteralValue = includeChildrenRecursively + ? UnknownValue + : getRenderedLiteralValue( + this.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, this) + )); + } + + include( + context: InclusionContext, + includeChildrenRecursively: IncludeChildren, + _options?: InclusionOptions + ): void { + if (!this.deoptimized) this.applyDeoptimizations(); + this.included = true; + // Check if the argument is an identifier that should be preserved as a reference for readability + const shouldPreserveArgument = + this.argument instanceof Identifier && this.argument.variable?.included; + if ( + typeof this.getRenderedLiteralValue(includeChildrenRecursively) === 'symbol' || + this.argument.shouldBeIncluded(context) || + shouldPreserveArgument + ) { + this.argument.include(context, includeChildrenRecursively); + this.renderedLiteralValue = UnknownValue; + } + } + + render(code: MagicString, options: RenderOptions) { + if (typeof this.renderedLiteralValue === 'symbol') { + super.render(code, options); + } else { + let value = this.renderedLiteralValue; + if (!CHARACTERS_THAT_DO_NOT_REQUIRE_SPACE.test(code.original[this.start - 1])) { + value = ` ${value}`; + } + code.overwrite(this.start, this.end, value); } - return path.length > 1; } } + +const CHARACTERS_THAT_DO_NOT_REQUIRE_SPACE = /[\s([=%&*+-/<>^|,?:;]/; + +UnaryExpression.prototype.includeNode = onlyIncludeSelf; diff --git a/src/ast/nodes/UnknownNode.ts b/src/ast/nodes/UnknownNode.ts index cdbd09ef538..60ebf1360f4 100644 --- a/src/ast/nodes/UnknownNode.ts +++ b/src/ast/nodes/UnknownNode.ts @@ -1,12 +1,12 @@ -import { InclusionContext } from '../ExecutionContext'; +import type { InclusionContext } from '../ExecutionContext'; import { NodeBase } from './shared/Node'; export default class UnknownNode extends NodeBase { - hasEffects() { + hasEffects(): boolean { return true; } - include(context: InclusionContext) { + include(context: InclusionContext): void { super.include(context, true); } } diff --git a/src/ast/nodes/UpdateExpression.ts b/src/ast/nodes/UpdateExpression.ts index 2d2a60f621d..eaa3a7db893 100644 --- a/src/ast/nodes/UpdateExpression.ts +++ b/src/ast/nodes/UpdateExpression.ts @@ -1,86 +1,95 @@ -import MagicString from 'magic-string'; -import { RenderOptions } from '../../utils/renderHelpers'; -import { getSystemExportFunctionLeft, getSystemExportStatement } from '../../utils/systemJsRendering'; -import { HasEffectsContext } from '../ExecutionContext'; -import { EMPTY_PATH, ObjectPath } from '../utils/PathTracker'; +import type MagicString from 'magic-string'; +import type { RenderOptions } from '../../utils/renderHelpers'; +import { + renderSystemExportExpression, + renderSystemExportSequenceAfterExpression, + renderSystemExportSequenceBeforeExpression +} from '../../utils/systemJsRendering'; +import type { HasEffectsContext, InclusionContext } from '../ExecutionContext'; +import type { NodeInteraction, NodeInteractionAssigned } from '../NodeInteractions'; +import { INTERACTION_ACCESSED } from '../NodeInteractions'; +import { EMPTY_PATH, type ObjectPath } from '../utils/PathTracker'; import Identifier from './Identifier'; import * as NodeType from './NodeType'; -import { ExpressionNode, NodeBase } from './shared/Node'; +import { UNKNOWN_EXPRESSION } from './shared/Expression'; +import type { ExpressionNode, IncludeChildren } from './shared/Node'; +import { NodeBase, onlyIncludeSelf } from './shared/Node'; export default class UpdateExpression extends NodeBase { - argument!: ExpressionNode; - operator!: '++' | '--'; - prefix!: boolean; - type!: NodeType.tUpdateExpression; + declare argument: ExpressionNode; + declare operator: '++' | '--'; + declare prefix: boolean; + declare type: NodeType.tUpdateExpression; + declare private interaction: NodeInteractionAssigned; - bind() { - super.bind(); - this.argument.deoptimizePath(EMPTY_PATH); - if (this.argument instanceof Identifier) { - const variable = this.scope.findVariable(this.argument.name); - variable.isReassigned = true; - } + hasEffects(context: HasEffectsContext): boolean { + if (!this.deoptimized) this.applyDeoptimizations(); + return this.argument.hasEffectsAsAssignmentTarget(context, true); } - hasEffects(context: HasEffectsContext): boolean { - return ( - this.argument.hasEffects(context) || - this.argument.hasEffectsWhenAssignedAtPath(EMPTY_PATH, context) - ); + hasEffectsOnInteractionAtPath(path: ObjectPath, { type }: NodeInteraction): boolean { + return path.length > 1 || type !== INTERACTION_ACCESSED; } - hasEffectsWhenAccessedAtPath(path: ObjectPath) { - return path.length > 1; + include(context: InclusionContext, includeChildrenRecursively: IncludeChildren) { + if (!this.included) this.includeNode(context); + this.argument.includeAsAssignmentTarget(context, includeChildrenRecursively, true); } - render(code: MagicString, options: RenderOptions) { + initialise() { + super.initialise(); + this.argument.setAssignedValue(UNKNOWN_EXPRESSION); + } + + render(code: MagicString, options: RenderOptions): void { + const { + exportNamesByVariable, + format, + snippets: { _ } + } = options; this.argument.render(code, options); - if (options.format === 'system') { - const variable = this.argument.variable; - const exportNames = options.exportNamesByVariable.get(variable!); - if (exportNames && exportNames.length) { - const _ = options.compact ? '' : ' '; - const name = variable!.getName(); + if (format === 'system') { + const variable = this.argument.variable!; + const exportNames = exportNamesByVariable.get(variable); + if (exportNames) { if (this.prefix) { if (exportNames.length === 1) { - code.overwrite( - this.start, - this.end, - `exports('${exportNames[0]}',${_}${this.operator}${name})` - ); + renderSystemExportExpression(variable, this.start, this.end, code, options); } else { - code.overwrite( + renderSystemExportSequenceAfterExpression( + variable, this.start, this.end, - `(${this.operator}${name},${_}${getSystemExportStatement( - [variable!], - options - )},${_}${name})` + this.parent.type !== NodeType.ExpressionStatement, + code, + options ); } - } else if (exportNames.length > 1) { - code.overwrite( - this.start, - this.end, - `(${getSystemExportFunctionLeft([variable!], false, options)}${this.operator}${name}))` - ); } else { - let op; - switch (this.operator) { - case '++': - op = `${name}${_}+${_}1`; - break; - case '--': - op = `${name}${_}-${_}1`; - break; - } - code.overwrite( + const operator = this.operator[0]; + renderSystemExportSequenceBeforeExpression( + variable, this.start, this.end, - `(exports('${exportNames[0]}',${_}${op}),${_}${name}${this.operator})` + this.parent.type !== NodeType.ExpressionStatement, + code, + options, + `${_}${operator}${_}1` ); } } } } + + applyDeoptimizations() { + this.deoptimized = true; + this.argument.deoptimizePath(EMPTY_PATH); + if (this.argument instanceof Identifier) { + const variable = this.scope.findVariable(this.argument.name); + variable.markReassigned(); + } + this.scope.context.requestTreeshakingPass(); + } } + +UpdateExpression.prototype.includeNode = onlyIncludeSelf; diff --git a/src/ast/nodes/VariableDeclaration.ts b/src/ast/nodes/VariableDeclaration.ts index 2058dc667b1..5d55fd9a268 100644 --- a/src/ast/nodes/VariableDeclaration.ts +++ b/src/ast/nodes/VariableDeclaration.ts @@ -1,85 +1,92 @@ -import MagicString from 'magic-string'; +import type MagicString from 'magic-string'; import { BLANK } from '../../utils/blank'; import { isReassignedExportsMember } from '../../utils/reassignedExportsMember'; import { findFirstOccurrenceOutsideComment, findNonWhiteSpace, getCommaSeparatedNodesWithBoundaries, - NodeRenderOptions, - RenderOptions + type NodeRenderOptions, + type RenderOptions } from '../../utils/renderHelpers'; import { - getSystemExportFunctionLeft, - getSystemExportStatement + getSystemExportStatement, + renderSystemExportExpression } from '../../utils/systemJsRendering'; -import { InclusionContext } from '../ExecutionContext'; +import { treeshakeNode } from '../../utils/treeshakeNode'; +import type { InclusionContext } from '../ExecutionContext'; import { EMPTY_PATH } from '../utils/PathTracker'; -import Variable from '../variables/Variable'; -import Identifier, { IdentifierWithVariable } from './Identifier'; +import type Variable from '../variables/Variable'; +import ArrayPattern from './ArrayPattern'; +import Identifier, { type IdentifierWithVariable } from './Identifier'; import * as NodeType from './NodeType'; -import { IncludeChildren, NodeBase } from './shared/Node'; -import VariableDeclarator from './VariableDeclarator'; - -function areAllDeclarationsIncludedAndNotExported( - declarations: VariableDeclarator[], - exportNamesByVariable: Map -): boolean { - for (const declarator of declarations) { - if (!declarator.id.included) return false; - if (declarator.id.type === NodeType.Identifier) { - if (exportNamesByVariable.has(declarator.id.variable!)) return false; - } else { - const exportedVariables: Variable[] = []; - declarator.id.addExportedVariables(exportedVariables, exportNamesByVariable); - if (exportedVariables.length > 0) return false; - } - } - return true; -} +import ObjectPattern from './ObjectPattern'; +import type { InclusionOptions } from './shared/Expression'; +import { + doNotDeoptimize, + type IncludeChildren, + NodeBase, + onlyIncludeSelfNoDeoptimize +} from './shared/Node'; +import type { VariableDeclarationKind } from './shared/VariableKinds'; +import type VariableDeclarator from './VariableDeclarator'; export default class VariableDeclaration extends NodeBase { - declarations!: VariableDeclarator[]; - kind!: 'var' | 'let' | 'const'; - type!: NodeType.tVariableDeclaration; + declare declarations: readonly VariableDeclarator[]; + declare kind: VariableDeclarationKind; + declare type: NodeType.tVariableDeclaration; - deoptimizePath() { + deoptimizePath(): void { for (const declarator of this.declarations) { declarator.deoptimizePath(EMPTY_PATH); } } - hasEffectsWhenAssignedAtPath() { + hasEffectsOnInteractionAtPath(): boolean { return false; } - include(context: InclusionContext, includeChildrenRecursively: IncludeChildren) { - this.included = true; - for (const declarator of this.declarations) { - if (includeChildrenRecursively || declarator.shouldBeIncluded(context)) - declarator.include(context, includeChildrenRecursively); - } - } - - includeAsSingleStatement(context: InclusionContext, includeChildrenRecursively: IncludeChildren) { + include( + context: InclusionContext, + includeChildrenRecursively: IncludeChildren, + { asSingleStatement }: InclusionOptions = BLANK + ): void { this.included = true; for (const declarator of this.declarations) { if (includeChildrenRecursively || declarator.shouldBeIncluded(context)) { declarator.include(context, includeChildrenRecursively); - declarator.id.include(context, includeChildrenRecursively); + } + const { id, init } = declarator; + if (asSingleStatement) { + id.include(context, includeChildrenRecursively); + } + if ( + init && + id.included && + !init.included && + (id instanceof ObjectPattern || id instanceof ArrayPattern) + ) { + init.include(context, includeChildrenRecursively); } } } - initialise() { + initialise(): void { + super.initialise(); for (const declarator of this.declarations) { declarator.declareDeclarator(this.kind); } } - render(code: MagicString, options: RenderOptions, nodeRenderOptions: NodeRenderOptions = BLANK) { - if ( - areAllDeclarationsIncludedAndNotExported(this.declarations, options.exportNamesByVariable) - ) { + removeAnnotations(code: MagicString) { + this.declarations[0].removeAnnotations(code); + } + + render( + code: MagicString, + options: RenderOptions, + nodeRenderOptions: NodeRenderOptions = BLANK + ): void { + if (this.areAllDeclarationsIncludedAndNotExported(options.exportNamesByVariable)) { for (const declarator of this.declarations) { declarator.render(code, options); } @@ -90,7 +97,7 @@ export default class VariableDeclaration extends NodeBase { code.appendLeft(this.end, ';'); } } else { - this.renderReplacedDeclarations(code, options, nodeRenderOptions); + this.renderReplacedDeclarations(code, options); } } @@ -100,17 +107,16 @@ export default class VariableDeclaration extends NodeBase { lastSeparatorPos: number | null, actualContentEnd: number, renderedContentEnd: number, - systemPatternExports: Variable[], - options: RenderOptions, - isNoStatement: boolean | undefined + systemPatternExports: readonly Variable[], + options: RenderOptions ): void { if (code.original.charCodeAt(this.end - 1) === 59 /*";"*/) { code.remove(this.end - 1, this.end); } - if (!isNoStatement) { - separatorString += ';'; - } - if (lastSeparatorPos !== null) { + separatorString += ';'; + if (lastSeparatorPos === null) { + code.appendLeft(renderedContentEnd, separatorString); + } else { if ( code.original.charCodeAt(actualContentEnd - 1) === 10 /*"\n"*/ && (code.original.charCodeAt(this.end) === 10 /*"\n"*/ || @@ -127,8 +133,6 @@ export default class VariableDeclaration extends NodeBase { code.overwrite(lastSeparatorPos, lastSeparatorPos + 1, separatorString); code.remove(actualContentEnd, renderedContentEnd); } - } else { - code.appendLeft(renderedContentEnd, separatorString); } if (systemPatternExports.length > 0) { code.appendLeft( @@ -138,11 +142,7 @@ export default class VariableDeclaration extends NodeBase { } } - private renderReplacedDeclarations( - code: MagicString, - options: RenderOptions, - { isNoStatement }: NodeRenderOptions - ): void { + private renderReplacedDeclarations(code: MagicString, options: RenderOptions): void { const separatedNodes = getCommaSeparatedNodesWithBoundaries( this.declarations, code, @@ -158,12 +158,18 @@ export default class VariableDeclaration extends NodeBase { let separatorString = '', leadingString, nextSeparatorString; - const systemPatternExports: Variable[] = []; + const aggregatedSystemExports: Variable[] = []; + const singleSystemExport = gatherSystemExportsAndGetSingleExport( + separatedNodes, + options, + aggregatedSystemExports + ); for (const { node, start, separator, contentEnd, end } of separatedNodes) { if (!node.included) { - code.remove(start, end); + treeshakeNode(node, code, start, end); continue; } + node.render(code, options); leadingString = ''; nextSeparatorString = ''; if ( @@ -179,27 +185,15 @@ export default class VariableDeclaration extends NodeBase { } isInDeclaration = false; } else { - if (options.format === 'system' && node.init !== null) { - if (node.id.type !== NodeType.Identifier) { - node.id.addExportedVariables(systemPatternExports, options.exportNamesByVariable); - } else { - const exportNames = options.exportNamesByVariable.get(node.id.variable!); - if (exportNames) { - const _ = options.compact ? '' : ' '; - const operatorPos = findFirstOccurrenceOutsideComment( - code.original, - '=', - node.id.end - ); - code.prependLeft( - findNonWhiteSpace(code.original, operatorPos + 1), - exportNames.length === 1 - ? `exports('${exportNames[0]}',${_}` - : getSystemExportFunctionLeft([node.id.variable!], false, options) - ); - nextSeparatorString += ')'; - } - } + if (singleSystemExport && singleSystemExport === node.id.variable) { + const operatorPos = findFirstOccurrenceOutsideComment(code.original, '=', node.id.end); + renderSystemExportExpression( + singleSystemExport, + findNonWhiteSpace(code.original, operatorPos + 1), + separator === null ? contentEnd : separator, + code, + options + ); } if (isInDeclaration) { separatorString += ','; @@ -217,7 +211,6 @@ export default class VariableDeclaration extends NodeBase { code.overwrite(lastSeparatorPos, lastSeparatorPos + 1, separatorString); code.appendLeft(renderedContentEnd, leadingString); } - node.render(code, options); actualContentEnd = contentEnd; renderedContentEnd = end; hasRenderedContent = true; @@ -230,9 +223,61 @@ export default class VariableDeclaration extends NodeBase { lastSeparatorPos, actualContentEnd!, renderedContentEnd, - systemPatternExports, - options, - isNoStatement + aggregatedSystemExports, + options ); } + + private areAllDeclarationsIncludedAndNotExported( + exportNamesByVariable: ReadonlyMap + ): boolean { + if (this.kind === 'await using' || this.kind === 'using') { + return true; + } + for (const declarator of this.declarations) { + if (!declarator.id.included) return false; + if (declarator.id.type === NodeType.Identifier) { + if (exportNamesByVariable.has(declarator.id.variable!)) return false; + } else { + const exportedVariables: Variable[] = []; + declarator.id.addExportedVariables(exportedVariables, exportNamesByVariable); + if (exportedVariables.length > 0) return false; + } + } + return true; + } } + +function gatherSystemExportsAndGetSingleExport( + separatedNodes: readonly { + node: VariableDeclarator; + }[], + options: RenderOptions, + aggregatedSystemExports: Variable[] +): Variable | null { + let singleSystemExport: Variable | null = null; + if (options.format === 'system') { + for (const { node } of separatedNodes) { + if ( + node.id instanceof Identifier && + node.init && + aggregatedSystemExports.length === 0 && + options.exportNamesByVariable.get(node.id.variable!)?.length === 1 + ) { + singleSystemExport = node.id.variable!; + aggregatedSystemExports.push(singleSystemExport); + } else { + node.id.addExportedVariables(aggregatedSystemExports, options.exportNamesByVariable); + } + } + if (aggregatedSystemExports.length > 1) { + singleSystemExport = null; + } else if (singleSystemExport) { + aggregatedSystemExports.length = 0; + } + } + return singleSystemExport; +} + +VariableDeclaration.prototype.includeNode = onlyIncludeSelfNoDeoptimize; +VariableDeclaration.prototype.applyDeoptimizations = doNotDeoptimize; diff --git a/src/ast/nodes/VariableDeclarator.ts b/src/ast/nodes/VariableDeclarator.ts index 40cd81a57db..fc8ecca477c 100644 --- a/src/ast/nodes/VariableDeclarator.ts +++ b/src/ast/nodes/VariableDeclarator.ts @@ -1,66 +1,134 @@ -import MagicString from 'magic-string'; +import type MagicString from 'magic-string'; +import type { NormalizedTreeshakingOptions } from '../../rollup/types'; import { BLANK } from '../../utils/blank'; import { isReassignedExportsMember } from '../../utils/reassignedExportsMember'; import { findFirstOccurrenceOutsideComment, findNonWhiteSpace, - RenderOptions + type RenderOptions } from '../../utils/renderHelpers'; -import { HasEffectsContext, InclusionContext } from '../ExecutionContext'; -import { ObjectPath } from '../utils/PathTracker'; +import type { HasEffectsContext, InclusionContext } from '../ExecutionContext'; +import { + EMPTY_PATH, + type ObjectPath, + SymbolAsyncDispose, + SymbolDispose +} from '../utils/PathTracker'; import { UNDEFINED_EXPRESSION } from '../values'; +import ClassExpression from './ClassExpression'; import Identifier from './Identifier'; import * as NodeType from './NodeType'; -import { ExpressionNode, IncludeChildren, NodeBase } from './shared/Node'; -import { PatternNode } from './shared/Pattern'; +import { + doNotDeoptimize, + type ExpressionNode, + type IncludeChildren, + NodeBase +} from './shared/Node'; +import type { DeclarationPatternNode } from './shared/Pattern'; +import type { VariableKind } from './shared/VariableKinds'; export default class VariableDeclarator extends NodeBase { - id!: PatternNode; - init!: ExpressionNode | null; - type!: NodeType.tVariableDeclarator; + declare id: DeclarationPatternNode; + declare init: ExpressionNode | null; + declare type: NodeType.tVariableDeclarator; + declare isUsingDeclaration: boolean; + declare isAsyncUsingDeclaration: boolean; - declareDeclarator(kind: string) { - this.id.declare(kind, this.init || UNDEFINED_EXPRESSION); + declareDeclarator(kind: VariableKind): void { + this.isUsingDeclaration = kind === 'using'; + this.isAsyncUsingDeclaration = kind === 'await using'; + this.id.declare(kind, EMPTY_PATH, this.init || UNDEFINED_EXPRESSION); } - deoptimizePath(path: ObjectPath) { + deoptimizePath(path: ObjectPath): void { this.id.deoptimizePath(path); } hasEffects(context: HasEffectsContext): boolean { - return this.id.hasEffects(context) || (this.init !== null && this.init.hasEffects(context)); + const initEffect = this.init?.hasEffects(context); + this.id.markDeclarationReached(); + return ( + initEffect || + this.isUsingDeclaration || + this.isAsyncUsingDeclaration || + this.id.hasEffects(context) || + ((this.scope.context.options.treeshake as NormalizedTreeshakingOptions) + .propertyReadSideEffects && + this.id.hasEffectsWhenDestructuring(context, EMPTY_PATH, this.init || UNDEFINED_EXPRESSION)) + ); } - include(context: InclusionContext, includeChildrenRecursively: IncludeChildren) { - this.included = true; - if (includeChildrenRecursively || this.id.shouldBeIncluded(context)) { - this.id.include(context, includeChildrenRecursively); - } - if (this.init) { - this.init.include(context, includeChildrenRecursively); + include(context: InclusionContext, includeChildrenRecursively: IncludeChildren): void { + const { id, init } = this; + if (!this.included) this.includeNode(context); + init?.include(context, includeChildrenRecursively); + id.markDeclarationReached(); + if (includeChildrenRecursively) { + id.include(context, includeChildrenRecursively); + } else { + id.includeDestructuredIfNecessary(context, EMPTY_PATH, init || UNDEFINED_EXPRESSION); } } - render(code: MagicString, options: RenderOptions) { - const renderId = this.id.included; + removeAnnotations(code: MagicString) { + this.init?.removeAnnotations(code); + } + + render(code: MagicString, options: RenderOptions): void { + const { + exportNamesByVariable, + snippets: { _, getPropertyAccess } + } = options; + const { end, id, init, start } = this; + const renderId = id.included || this.isUsingDeclaration || this.isAsyncUsingDeclaration; if (renderId) { - this.id.render(code, options); + id.render(code, options); } else { - const operatorPos = findFirstOccurrenceOutsideComment(code.original, '=', this.id.end); - code.remove(this.start, findNonWhiteSpace(code.original, operatorPos + 1)); + const operatorPos = findFirstOccurrenceOutsideComment(code.original, '=', id.end); + code.remove(start, findNonWhiteSpace(code.original, operatorPos + 1)); } - if (this.init) { - this.init.render( + if (init) { + if (id instanceof Identifier && init instanceof ClassExpression && !init.id) { + const renderedVariable = id.variable!.getName(getPropertyAccess); + if (renderedVariable !== id.name) { + code.appendLeft(init.start + 5, ` ${id.name}`); + } + } + init.render( code, options, - renderId ? BLANK : { renderedParentType: NodeType.ExpressionStatement } + renderId ? BLANK : { renderedSurroundingElement: NodeType.ExpressionStatement } ); } else if ( - this.id instanceof Identifier && - isReassignedExportsMember(this.id.variable!, options.exportNamesByVariable) + id instanceof Identifier && + isReassignedExportsMember(id.variable!, exportNamesByVariable) ) { - const _ = options.compact ? '' : ' '; - code.appendLeft(this.end, `${_}=${_}void 0`); + code.appendLeft(end, `${_}=${_}void 0`); + } + } + + includeNode(context: InclusionContext): void { + this.included = true; + const { id, init } = this; + if (init) { + if (this.isUsingDeclaration) { + init.includePath(SYMBOL_DISPOSE_PATH, context); + } else if (this.isAsyncUsingDeclaration) { + init.includePath(SYMBOL_ASYNC_DISPOSE_PATH, context); + } + if (id instanceof Identifier && init instanceof ClassExpression && !init.id) { + const { name, variable } = id; + for (const accessedVariable of init.scope.accessedOutsideVariables.values()) { + if (accessedVariable !== variable) { + accessedVariable.forbidName(name); + } + } + } } } } + +VariableDeclarator.prototype.applyDeoptimizations = doNotDeoptimize; + +const SYMBOL_DISPOSE_PATH: ObjectPath = [SymbolDispose]; +const SYMBOL_ASYNC_DISPOSE_PATH: ObjectPath = [SymbolAsyncDispose]; diff --git a/src/ast/nodes/WhileStatement.ts b/src/ast/nodes/WhileStatement.ts index 6cc8120640c..88eab40862b 100644 --- a/src/ast/nodes/WhileStatement.ts +++ b/src/ast/nodes/WhileStatement.ts @@ -1,32 +1,31 @@ -import { HasEffectsContext, InclusionContext } from '../ExecutionContext'; -import * as NodeType from './NodeType'; -import { ExpressionNode, IncludeChildren, StatementBase, StatementNode } from './shared/Node'; +import type { HasEffectsContext, InclusionContext } from '../ExecutionContext'; +import type * as NodeType from './NodeType'; +import { hasLoopBodyEffects, includeLoopBody } from './shared/loops'; +import { + doNotDeoptimize, + type ExpressionNode, + type IncludeChildren, + onlyIncludeSelfNoDeoptimize, + StatementBase, + type StatementNode +} from './shared/Node'; export default class WhileStatement extends StatementBase { - body!: StatementNode; - test!: ExpressionNode; - type!: NodeType.tWhileStatement; + declare body: StatementNode; + declare test: ExpressionNode; + declare type: NodeType.tWhileStatement; hasEffects(context: HasEffectsContext): boolean { if (this.test.hasEffects(context)) return true; - const { - brokenFlow, - ignore: { breaks, continues } - } = context; - context.ignore.breaks = true; - context.ignore.continues = true; - if (this.body.hasEffects(context)) return true; - context.ignore.breaks = breaks; - context.ignore.continues = continues; - context.brokenFlow = brokenFlow; - return false; + return hasLoopBodyEffects(context, this.body); } - include(context: InclusionContext, includeChildrenRecursively: IncludeChildren) { + include(context: InclusionContext, includeChildrenRecursively: IncludeChildren): void { this.included = true; this.test.include(context, includeChildrenRecursively); - const { brokenFlow } = context; - this.body.includeAsSingleStatement(context, includeChildrenRecursively); - context.brokenFlow = brokenFlow; + includeLoopBody(context, this.body, includeChildrenRecursively); } } + +WhileStatement.prototype.includeNode = onlyIncludeSelfNoDeoptimize; +WhileStatement.prototype.applyDeoptimizations = doNotDeoptimize; diff --git a/src/ast/nodes/YieldExpression.ts b/src/ast/nodes/YieldExpression.ts index d322951c8fd..e342f6a6446 100644 --- a/src/ast/nodes/YieldExpression.ts +++ b/src/ast/nodes/YieldExpression.ts @@ -1,30 +1,32 @@ -import MagicString from 'magic-string'; -import { RenderOptions } from '../../utils/renderHelpers'; -import { HasEffectsContext } from '../ExecutionContext'; +import type MagicString from 'magic-string'; +import type { RenderOptions } from '../../utils/renderHelpers'; +import type { HasEffectsContext, InclusionContext } from '../ExecutionContext'; import { UNKNOWN_PATH } from '../utils/PathTracker'; -import * as NodeType from './NodeType'; -import { ExpressionNode, NodeBase } from './shared/Node'; +import type * as NodeType from './NodeType'; +import { type ExpressionNode, NodeBase } from './shared/Node'; export default class YieldExpression extends NodeBase { - argument!: ExpressionNode | null; - delegate!: boolean; - type!: NodeType.tYieldExpression; + declare argument: ExpressionNode | null; + declare delegate: boolean; + declare type: NodeType.tYieldExpression; - bind() { - super.bind(); - if (this.argument !== null) { - this.argument.deoptimizePath(UNKNOWN_PATH); - } + applyDeoptimizations() { + this.deoptimized = true; + this.argument?.deoptimizePath(UNKNOWN_PATH); + } + + hasEffects(context: HasEffectsContext): boolean { + if (!this.deoptimized) this.applyDeoptimizations(); + return !(context.ignore.returnYield && !this.argument?.hasEffects(context)); } - hasEffects(context: HasEffectsContext) { - return ( - !context.ignore.returnAwaitYield || - (this.argument !== null && this.argument.hasEffects(context)) - ); + includeNode(context: InclusionContext) { + this.included = true; + if (!this.deoptimized) this.applyDeoptimizations(); + this.argument?.includePath(UNKNOWN_PATH, context); } - render(code: MagicString, options: RenderOptions) { + render(code: MagicString, options: RenderOptions): void { if (this.argument) { this.argument.render(code, options, { preventASI: true }); if (this.argument.start === this.start + 5 /* 'yield'.length */) { diff --git a/src/ast/nodes/index.ts b/src/ast/nodes/index.ts index 9773e26d05e..2ef83573c6c 100644 --- a/src/ast/nodes/index.ts +++ b/src/ast/nodes/index.ts @@ -1,3 +1,6 @@ +// This file is generated by scripts/generate-node-index.js. +// Do not edit this file directly. + import ArrayExpression from './ArrayExpression'; import ArrayPattern from './ArrayPattern'; import ArrowFunctionExpression from './ArrowFunctionExpression'; @@ -15,6 +18,8 @@ import ClassDeclaration from './ClassDeclaration'; import ClassExpression from './ClassExpression'; import ConditionalExpression from './ConditionalExpression'; import ContinueStatement from './ContinueStatement'; +import DebuggerStatement from './DebuggerStatement'; +import Decorator from './Decorator'; import DoWhileStatement from './DoWhileStatement'; import EmptyStatement from './EmptyStatement'; import ExportAllDeclaration from './ExportAllDeclaration'; @@ -29,11 +34,27 @@ import FunctionDeclaration from './FunctionDeclaration'; import FunctionExpression from './FunctionExpression'; import Identifier from './Identifier'; import IfStatement from './IfStatement'; +import ImportAttribute from './ImportAttribute'; import ImportDeclaration from './ImportDeclaration'; import ImportDefaultSpecifier from './ImportDefaultSpecifier'; import ImportExpression from './ImportExpression'; import ImportNamespaceSpecifier from './ImportNamespaceSpecifier'; import ImportSpecifier from './ImportSpecifier'; +import JSXAttribute from './JSXAttribute'; +import JSXClosingElement from './JSXClosingElement'; +import JSXClosingFragment from './JSXClosingFragment'; +import JSXElement from './JSXElement'; +import JSXEmptyExpression from './JSXEmptyExpression'; +import JSXExpressionContainer from './JSXExpressionContainer'; +import JSXFragment from './JSXFragment'; +import JSXIdentifier from './JSXIdentifier'; +import JSXMemberExpression from './JSXMemberExpression'; +import JSXNamespacedName from './JSXNamespacedName'; +import JSXOpeningElement from './JSXOpeningElement'; +import JSXOpeningFragment from './JSXOpeningFragment'; +import JSXSpreadAttribute from './JSXSpreadAttribute'; +import JSXSpreadChild from './JSXSpreadChild'; +import JSXText from './JSXText'; import LabeledStatement from './LabeledStatement'; import Literal from './Literal'; import LogicalExpression from './LogicalExpression'; @@ -43,6 +64,8 @@ import MethodDefinition from './MethodDefinition'; import NewExpression from './NewExpression'; import ObjectExpression from './ObjectExpression'; import ObjectPattern from './ObjectPattern'; +import PanicError from './PanicError'; +import ParseError from './ParseError'; import PrivateIdentifier from './PrivateIdentifier'; import Program from './Program'; import Property from './Property'; @@ -50,8 +73,8 @@ import PropertyDefinition from './PropertyDefinition'; import RestElement from './RestElement'; import ReturnStatement from './ReturnStatement'; import SequenceExpression from './SequenceExpression'; -import { NodeBase } from './shared/Node'; import SpreadElement from './SpreadElement'; +import StaticBlock from './StaticBlock'; import Super from './Super'; import SwitchCase from './SwitchCase'; import SwitchStatement from './SwitchStatement'; @@ -68,10 +91,9 @@ import VariableDeclaration from './VariableDeclaration'; import VariableDeclarator from './VariableDeclarator'; import WhileStatement from './WhileStatement'; import YieldExpression from './YieldExpression'; +import type { NodeBase } from './shared/Node'; -export const nodeConstructors: { - [name: string]: typeof NodeBase; -} = { +export const nodeConstructors: Record = { ArrayExpression, ArrayPattern, ArrowFunctionExpression, @@ -89,6 +111,8 @@ export const nodeConstructors: { ClassExpression, ConditionalExpression, ContinueStatement, + DebuggerStatement, + Decorator, DoWhileStatement, EmptyStatement, ExportAllDeclaration, @@ -103,11 +127,27 @@ export const nodeConstructors: { FunctionExpression, Identifier, IfStatement, + ImportAttribute, ImportDeclaration, ImportDefaultSpecifier, ImportExpression, ImportNamespaceSpecifier, ImportSpecifier, + JSXAttribute, + JSXClosingElement, + JSXClosingFragment, + JSXElement, + JSXEmptyExpression, + JSXExpressionContainer, + JSXFragment, + JSXIdentifier, + JSXMemberExpression, + JSXNamespacedName, + JSXOpeningElement, + JSXOpeningFragment, + JSXSpreadAttribute, + JSXSpreadChild, + JSXText, LabeledStatement, Literal, LogicalExpression, @@ -117,6 +157,8 @@ export const nodeConstructors: { NewExpression, ObjectExpression, ObjectPattern, + PanicError, + ParseError, PrivateIdentifier, Program, Property, @@ -125,6 +167,7 @@ export const nodeConstructors: { ReturnStatement, SequenceExpression, SpreadElement, + StaticBlock, Super, SwitchCase, SwitchStatement, diff --git a/src/ast/nodes/shared/ArrayPrototype.ts b/src/ast/nodes/shared/ArrayPrototype.ts new file mode 100644 index 00000000000..deb5fb45ced --- /dev/null +++ b/src/ast/nodes/shared/ArrayPrototype.ts @@ -0,0 +1,169 @@ +import { UnknownInteger } from '../../utils/PathTracker'; +import { UNKNOWN_LITERAL_BOOLEAN, UNKNOWN_LITERAL_NUMBER } from '../../values'; +import { type ExpressionEntity, UNKNOWN_EXPRESSION } from './Expression'; +import { + Method, + METHOD_RETURNS_BOOLEAN, + METHOD_RETURNS_NUMBER, + METHOD_RETURNS_STRING, + METHOD_RETURNS_UNKNOWN +} from './MethodTypes'; +import { ObjectEntity, type ObjectProperty } from './ObjectEntity'; +import { OBJECT_PROTOTYPE } from './ObjectPrototype'; + +const NEW_ARRAY_PROPERTIES: ObjectProperty[] = [ + { key: UnknownInteger, kind: 'init', property: UNKNOWN_EXPRESSION }, + { key: 'length', kind: 'init', property: UNKNOWN_LITERAL_NUMBER } +]; + +const METHOD_CALLS_ARG_DEOPTS_SELF_RETURNS_BOOLEAN: [ExpressionEntity] = [ + new Method({ + callsArgs: [0], + mutatesArgs: false, + mutatesSelfAsArray: 'deopt-only', + returns: null, + returnsPrimitive: UNKNOWN_LITERAL_BOOLEAN + }) +]; + +const METHOD_CALLS_ARG_DEOPTS_SELF_RETURNS_NUMBER: [ExpressionEntity] = [ + new Method({ + callsArgs: [0], + mutatesArgs: false, + mutatesSelfAsArray: 'deopt-only', + returns: null, + returnsPrimitive: UNKNOWN_LITERAL_NUMBER + }) +]; + +const METHOD_MUTATES_SELF_RETURNS_NEW_ARRAY: [ExpressionEntity] = [ + new Method({ + callsArgs: null, + mutatesArgs: false, + mutatesSelfAsArray: true, + returns: () => new ObjectEntity(NEW_ARRAY_PROPERTIES, ARRAY_PROTOTYPE), + returnsPrimitive: null + }) +]; + +const METHOD_DEOPTS_SELF_RETURNS_NEW_ARRAY: [ExpressionEntity] = [ + new Method({ + callsArgs: null, + mutatesArgs: false, + mutatesSelfAsArray: 'deopt-only', + returns: () => new ObjectEntity(NEW_ARRAY_PROPERTIES, ARRAY_PROTOTYPE), + returnsPrimitive: null + }) +]; + +const METHOD_CALLS_ARG_DEOPTS_SELF_RETURNS_NEW_ARRAY: [ExpressionEntity] = [ + new Method({ + callsArgs: [0], + mutatesArgs: false, + mutatesSelfAsArray: 'deopt-only', + returns: () => new ObjectEntity(NEW_ARRAY_PROPERTIES, ARRAY_PROTOTYPE), + returnsPrimitive: null + }) +]; + +const METHOD_MUTATES_SELF_AND_ARGS_RETURNS_NUMBER: [ExpressionEntity] = [ + new Method({ + callsArgs: null, + mutatesArgs: true, + mutatesSelfAsArray: true, + returns: null, + returnsPrimitive: UNKNOWN_LITERAL_NUMBER + }) +]; + +const METHOD_MUTATES_SELF_RETURNS_UNKNOWN: [ExpressionEntity] = [ + new Method({ + callsArgs: null, + mutatesArgs: false, + mutatesSelfAsArray: true, + returns: null, + returnsPrimitive: UNKNOWN_EXPRESSION + }) +]; + +const METHOD_DEOPTS_SELF_RETURNS_UNKNOWN: [ExpressionEntity] = [ + new Method({ + callsArgs: null, + mutatesArgs: false, + mutatesSelfAsArray: 'deopt-only', + returns: null, + returnsPrimitive: UNKNOWN_EXPRESSION + }) +]; + +const METHOD_CALLS_ARG_DEOPTS_SELF_RETURNS_UNKNOWN: [ExpressionEntity] = [ + new Method({ + callsArgs: [0], + mutatesArgs: false, + mutatesSelfAsArray: 'deopt-only', + returns: null, + returnsPrimitive: UNKNOWN_EXPRESSION + }) +]; + +const METHOD_MUTATES_SELF_RETURNS_SELF: [ExpressionEntity] = [ + new Method({ + callsArgs: null, + mutatesArgs: false, + mutatesSelfAsArray: true, + returns: 'self', + returnsPrimitive: null + }) +]; + +const METHOD_CALLS_ARG_MUTATES_SELF_RETURNS_SELF: [ExpressionEntity] = [ + new Method({ + callsArgs: [0], + mutatesArgs: false, + mutatesSelfAsArray: true, + returns: 'self', + returnsPrimitive: null + }) +]; + +export const ARRAY_PROTOTYPE = new ObjectEntity( + new Map([ + // We assume that accessors have effects as we do not track the accessed value afterwards + ['at', METHOD_DEOPTS_SELF_RETURNS_UNKNOWN], + ['concat', METHOD_DEOPTS_SELF_RETURNS_NEW_ARRAY], + ['copyWithin', METHOD_MUTATES_SELF_RETURNS_SELF], + ['entries', METHOD_DEOPTS_SELF_RETURNS_NEW_ARRAY], + ['every', METHOD_CALLS_ARG_DEOPTS_SELF_RETURNS_BOOLEAN], + ['fill', METHOD_MUTATES_SELF_RETURNS_SELF], + ['filter', METHOD_CALLS_ARG_DEOPTS_SELF_RETURNS_NEW_ARRAY], + ['find', METHOD_CALLS_ARG_DEOPTS_SELF_RETURNS_UNKNOWN], + ['findIndex', METHOD_CALLS_ARG_DEOPTS_SELF_RETURNS_NUMBER], + ['findLast', METHOD_CALLS_ARG_DEOPTS_SELF_RETURNS_UNKNOWN], + ['findLastIndex', METHOD_CALLS_ARG_DEOPTS_SELF_RETURNS_NUMBER], + ['flat', METHOD_DEOPTS_SELF_RETURNS_NEW_ARRAY], + ['flatMap', METHOD_CALLS_ARG_DEOPTS_SELF_RETURNS_NEW_ARRAY], + ['forEach', METHOD_CALLS_ARG_DEOPTS_SELF_RETURNS_UNKNOWN], + ['includes', METHOD_RETURNS_BOOLEAN], + ['indexOf', METHOD_RETURNS_NUMBER], + ['join', METHOD_RETURNS_STRING], + ['keys', METHOD_RETURNS_UNKNOWN], + ['lastIndexOf', METHOD_RETURNS_NUMBER], + ['map', METHOD_CALLS_ARG_DEOPTS_SELF_RETURNS_NEW_ARRAY], + ['pop', METHOD_MUTATES_SELF_RETURNS_UNKNOWN], + ['push', METHOD_MUTATES_SELF_AND_ARGS_RETURNS_NUMBER], + ['reduce', METHOD_CALLS_ARG_DEOPTS_SELF_RETURNS_UNKNOWN], + ['reduceRight', METHOD_CALLS_ARG_DEOPTS_SELF_RETURNS_UNKNOWN], + ['reverse', METHOD_MUTATES_SELF_RETURNS_SELF], + ['shift', METHOD_MUTATES_SELF_RETURNS_UNKNOWN], + ['slice', METHOD_DEOPTS_SELF_RETURNS_NEW_ARRAY], + ['some', METHOD_CALLS_ARG_DEOPTS_SELF_RETURNS_BOOLEAN], + ['sort', METHOD_CALLS_ARG_MUTATES_SELF_RETURNS_SELF], + ['splice', METHOD_MUTATES_SELF_RETURNS_NEW_ARRAY], + ['toLocaleString', METHOD_RETURNS_STRING], + ['toString', METHOD_RETURNS_STRING], + ['unshift', METHOD_MUTATES_SELF_AND_ARGS_RETURNS_NUMBER], + ['values', METHOD_DEOPTS_SELF_RETURNS_UNKNOWN] + ]), + OBJECT_PROTOTYPE, + true +); diff --git a/src/ast/nodes/shared/BitFlags.ts b/src/ast/nodes/shared/BitFlags.ts new file mode 100644 index 00000000000..eab09fddffd --- /dev/null +++ b/src/ast/nodes/shared/BitFlags.ts @@ -0,0 +1,39 @@ +export const enum Flag { + included = 1 << 0, + deoptimized = 1 << 1, + tdzAccessDefined = 1 << 2, + tdzAccess = 1 << 3, + assignmentDeoptimized = 1 << 4, + bound = 1 << 5, + isUndefined = 1 << 6, + optional = 1 << 7, + async = 1 << 8, + deoptimizedReturn = 1 << 9, + computed = 1 << 10, + hasLostTrack = 1 << 11, + hasUnknownDeoptimizedInteger = 1 << 12, + hasUnknownDeoptimizedProperty = 1 << 13, + directlyIncluded = 1 << 14, + deoptimizeBody = 1 << 15, + isBranchResolutionAnalysed = 1 << 16, + await = 1 << 17, + method = 1 << 18, + shorthand = 1 << 19, + tail = 1 << 20, + prefix = 1 << 21, + generator = 1 << 22, + expression = 1 << 23, + destructuringDeoptimized = 1 << 24, + hasDeoptimizedCache = 1 << 25, + hasEffects = 1 << 26, + checkedForWarnings = 1 << 27, + shouldIncludeDynamicAttributes = 1 << 28 +} + +export function isFlagSet(flags: number, flag: Flag): boolean { + return (flags & flag) !== 0; +} + +export function setFlag(flags: number, flag: Flag, value: boolean): number { + return (flags & ~flag) | (-value & flag); +} diff --git a/src/ast/nodes/shared/CallExpressionBase.ts b/src/ast/nodes/shared/CallExpressionBase.ts new file mode 100644 index 00000000000..c63a0d314c0 --- /dev/null +++ b/src/ast/nodes/shared/CallExpressionBase.ts @@ -0,0 +1,167 @@ +import { EMPTY_ARRAY, EMPTY_SET } from '../../../utils/blank'; +import type { DeoptimizableEntity } from '../../DeoptimizableEntity'; +import type { HasEffectsContext } from '../../ExecutionContext'; +import type { NodeInteraction, NodeInteractionCalled } from '../../NodeInteractions'; +import { INTERACTION_ASSIGNED, INTERACTION_CALLED } from '../../NodeInteractions'; +import { type EntityPathTracker, type ObjectPath, UNKNOWN_PATH } from '../../utils/PathTracker'; +import { + type ExpressionEntity, + type LiteralValueOrUnknown, + UNKNOWN_EXPRESSION, + UNKNOWN_RETURN_EXPRESSION, + UnknownValue +} from './Expression'; +import { NodeBase } from './Node'; + +export default abstract class CallExpressionBase extends NodeBase implements DeoptimizableEntity { + declare protected interaction: NodeInteractionCalled; + protected returnExpression: [expression: ExpressionEntity, isPure: boolean] | null = null; + private deoptimizableDependentExpressions: DeoptimizableEntity[] = []; + private expressionsToBeDeoptimized = new Set(); + + deoptimizeArgumentsOnInteractionAtPath( + interaction: NodeInteraction, + path: ObjectPath, + recursionTracker: EntityPathTracker + ): void { + const { args } = interaction; + const [returnExpression, isPure] = this.getReturnExpression(recursionTracker); + if (isPure) return; + const deoptimizedExpressions = args.filter( + expression => !!expression && expression !== UNKNOWN_EXPRESSION + ) as ExpressionEntity[]; + if (deoptimizedExpressions.length === 0) return; + if (returnExpression === UNKNOWN_EXPRESSION) { + for (const expression of deoptimizedExpressions) { + expression.deoptimizePath(UNKNOWN_PATH); + } + } else { + recursionTracker.withTrackedEntityAtPath( + path, + returnExpression, + () => { + for (const expression of deoptimizedExpressions) { + this.expressionsToBeDeoptimized.add(expression); + } + returnExpression.deoptimizeArgumentsOnInteractionAtPath( + interaction, + path, + recursionTracker + ); + }, + null + ); + } + } + + deoptimizeCache(): void { + if (this.returnExpression?.[0] !== UNKNOWN_EXPRESSION) { + this.returnExpression = UNKNOWN_RETURN_EXPRESSION; + const { deoptimizableDependentExpressions, expressionsToBeDeoptimized } = this; + this.expressionsToBeDeoptimized = EMPTY_SET; + this.deoptimizableDependentExpressions = EMPTY_ARRAY as unknown as DeoptimizableEntity[]; + for (const expression of deoptimizableDependentExpressions) { + expression.deoptimizeCache(); + } + for (const expression of expressionsToBeDeoptimized) { + expression.deoptimizePath(UNKNOWN_PATH); + } + } + } + + deoptimizePath(path: ObjectPath): void { + if ( + path.length === 0 || + this.scope.context.deoptimizationTracker.trackEntityAtPathAndGetIfTracked(path, this) + ) { + return; + } + const [returnExpression] = this.getReturnExpression(); + if (returnExpression !== UNKNOWN_EXPRESSION) { + returnExpression.deoptimizePath(path); + } + } + + getLiteralValueAtPath( + path: ObjectPath, + recursionTracker: EntityPathTracker, + origin: DeoptimizableEntity + ): LiteralValueOrUnknown { + const [returnExpression] = this.getReturnExpression(recursionTracker); + if (returnExpression === UNKNOWN_EXPRESSION) { + return UnknownValue; + } + return recursionTracker.withTrackedEntityAtPath( + path, + returnExpression, + () => { + this.deoptimizableDependentExpressions.push(origin); + return returnExpression.getLiteralValueAtPath(path, recursionTracker, origin); + }, + UnknownValue + ); + } + + getReturnExpressionWhenCalledAtPath( + path: ObjectPath, + interaction: NodeInteractionCalled, + recursionTracker: EntityPathTracker, + origin: DeoptimizableEntity + ): [expression: ExpressionEntity, isPure: boolean] { + const returnExpression = this.getReturnExpression(recursionTracker); + if (returnExpression[0] === UNKNOWN_EXPRESSION) { + return returnExpression; + } + return recursionTracker.withTrackedEntityAtPath( + path, + returnExpression, + () => { + this.deoptimizableDependentExpressions.push(origin); + const [expression, isPure] = returnExpression[0].getReturnExpressionWhenCalledAtPath( + path, + interaction, + recursionTracker, + origin + ); + return [expression, isPure || returnExpression[1]]; + }, + UNKNOWN_RETURN_EXPRESSION + ); + } + + hasEffectsOnInteractionAtPath( + path: ObjectPath, + interaction: NodeInteraction, + context: HasEffectsContext + ): boolean { + const { type } = interaction; + if (type === INTERACTION_CALLED) { + const { args, withNew } = interaction; + if ( + (withNew ? context.instantiated : context.called).trackEntityAtPathAndGetIfTracked( + path, + args, + this + ) + ) { + return false; + } + } else if ( + (type === INTERACTION_ASSIGNED + ? context.assigned + : context.accessed + ).trackEntityAtPathAndGetIfTracked(path, this) + ) { + return false; + } + const [returnExpression, isPure] = this.getReturnExpression(); + return ( + (type === INTERACTION_ASSIGNED || !isPure) && + returnExpression.hasEffectsOnInteractionAtPath(path, interaction, context) + ); + } + + protected abstract getReturnExpression( + recursionTracker?: EntityPathTracker + ): [expression: ExpressionEntity, isPure: boolean]; +} diff --git a/src/ast/nodes/shared/ClassNode.ts b/src/ast/nodes/shared/ClassNode.ts index 4323d8c789f..7d8f948ae10 100644 --- a/src/ast/nodes/shared/ClassNode.ts +++ b/src/ast/nodes/shared/ClassNode.ts @@ -1,47 +1,196 @@ -import { CallOptions } from '../../CallOptions'; -import { HasEffectsContext } from '../../ExecutionContext'; +import type { DeoptimizableEntity } from '../../DeoptimizableEntity'; +import { type HasEffectsContext, type InclusionContext } from '../../ExecutionContext'; +import type { NodeInteraction, NodeInteractionCalled } from '../../NodeInteractions'; +import { INTERACTION_CALLED } from '../../NodeInteractions'; import ChildScope from '../../scopes/ChildScope'; -import Scope from '../../scopes/Scope'; -import { ObjectPath } from '../../utils/PathTracker'; -import ClassBody from '../ClassBody'; +import { checkEffectForNodes } from '../../utils/checkEffectForNodes'; +import { + EMPTY_PATH, + type EntityPathTracker, + isAnyWellKnown, + type ObjectPath, + SHARED_RECURSION_TRACKER, + UNKNOWN_PATH, + UnknownKey +} from '../../utils/PathTracker'; +import type ClassBody from '../ClassBody'; +import type Decorator from '../Decorator'; import Identifier from '../Identifier'; -import { ExpressionNode, NodeBase } from './Node'; +import type Literal from '../Literal'; +import MethodDefinition from '../MethodDefinition'; +import { isStaticBlock } from '../StaticBlock'; +import { type ExpressionEntity, type LiteralValueOrUnknown } from './Expression'; +import { type ExpressionNode, type IncludeChildren, NodeBase, onlyIncludeSelf } from './Node'; +import { ObjectEntity, type ObjectProperty } from './ObjectEntity'; +import { ObjectMember } from './ObjectMember'; +import { OBJECT_PROTOTYPE } from './ObjectPrototype'; -export default class ClassNode extends NodeBase { - body!: ClassBody; - id!: Identifier | null; - superClass!: ExpressionNode | null; +export default class ClassNode extends NodeBase implements DeoptimizableEntity { + declare body: ClassBody; + declare id: Identifier | null; + declare superClass: ExpressionNode | null; + declare decorators: Decorator[]; + declare private classConstructor: MethodDefinition | null; + private objectEntity: ObjectEntity | null = null; - createScope(parentScope: Scope) { - this.scope = new ChildScope(parentScope); + createScope(parentScope: ChildScope): void { + this.scope = new ChildScope(parentScope, parentScope.context); } - hasEffectsWhenAccessedAtPath(path: ObjectPath) { - if (path.length <= 1) return false; - return path.length > 2 || path[0] !== 'prototype'; + deoptimizeArgumentsOnInteractionAtPath( + interaction: NodeInteraction, + path: ObjectPath, + recursionTracker: EntityPathTracker + ): void { + this.getObjectEntity().deoptimizeArgumentsOnInteractionAtPath( + interaction, + path, + recursionTracker + ); + } + + deoptimizeCache(): void { + this.getObjectEntity().deoptimizeAllProperties(); } - hasEffectsWhenAssignedAtPath(path: ObjectPath) { - if (path.length <= 1) return false; - return path.length > 2 || path[0] !== 'prototype'; + deoptimizePath(path: ObjectPath): void { + this.getObjectEntity().deoptimizePath(path); } - hasEffectsWhenCalledAtPath( + getLiteralValueAtPath( path: ObjectPath, - callOptions: CallOptions, - context: HasEffectsContext - ) { - if (!callOptions.withNew) return true; - return ( - this.body.hasEffectsWhenCalledAtPath(path, callOptions, context) || - (this.superClass !== null && - this.superClass.hasEffectsWhenCalledAtPath(path, callOptions, context)) + recursionTracker: EntityPathTracker, + origin: DeoptimizableEntity + ): LiteralValueOrUnknown { + return this.getObjectEntity().getLiteralValueAtPath(path, recursionTracker, origin); + } + + getReturnExpressionWhenCalledAtPath( + path: ObjectPath, + interaction: NodeInteractionCalled, + recursionTracker: EntityPathTracker, + origin: DeoptimizableEntity + ): [expression: ExpressionEntity, isPure: boolean] { + return this.getObjectEntity().getReturnExpressionWhenCalledAtPath( + path, + interaction, + recursionTracker, + origin ); } - initialise() { - if (this.id !== null) { - this.id.declare('class', this); + hasEffects(context: HasEffectsContext): boolean { + if (!this.deoptimized) this.applyDeoptimizations(); + const initEffect = this.superClass?.hasEffects(context) || this.body.hasEffects(context); + this.id?.markDeclarationReached(); + return initEffect || super.hasEffects(context) || checkEffectForNodes(this.decorators, context); + } + + hasEffectsOnInteractionAtPath( + path: ObjectPath, + interaction: NodeInteraction, + context: HasEffectsContext + ): boolean { + return interaction.type === INTERACTION_CALLED && path.length === 0 + ? !interaction.withNew || + (this.classConstructor === null + ? this.superClass?.hasEffectsOnInteractionAtPath(path, interaction, context) + : this.classConstructor.hasEffectsOnInteractionAtPath(path, interaction, context)) || + false + : this.getObjectEntity().hasEffectsOnInteractionAtPath(path, interaction, context); + } + + include(context: InclusionContext, includeChildrenRecursively: IncludeChildren): void { + if (!this.included) this.includeNode(context); + this.superClass?.include(context, includeChildrenRecursively); + this.body.include(context, includeChildrenRecursively); + for (const decorator of this.decorators) decorator.include(context, includeChildrenRecursively); + if (this.id) { + this.id.markDeclarationReached(); + this.id.include(context, includeChildrenRecursively); + } + } + + initialise(): void { + super.initialise(); + this.id?.declare('class', EMPTY_PATH, this); + for (const method of this.body.body) { + if (method instanceof MethodDefinition && method.kind === 'constructor') { + this.classConstructor = method; + return; + } + } + this.classConstructor = null; + } + + applyDeoptimizations() { + this.deoptimized = true; + for (const definition of this.body.body) { + if ( + !isStaticBlock(definition) && + !( + definition.static || + (definition instanceof MethodDefinition && definition.kind === 'constructor') + ) + ) { + // Calls to methods are not tracked, ensure that the return value is deoptimized + definition.deoptimizePath(UNKNOWN_PATH); + } + } + this.scope.context.requestTreeshakingPass(); + } + + private getObjectEntity(): ObjectEntity { + if (this.objectEntity !== null) { + return this.objectEntity; + } + const staticProperties: ObjectProperty[] = []; + const dynamicMethods: ObjectProperty[] = []; + for (const definition of this.body.body) { + if (isStaticBlock(definition)) continue; + const properties = definition.static ? staticProperties : dynamicMethods; + const definitionKind = (definition as MethodDefinition | { kind: undefined }).kind; + // Note that class fields do not end up on the prototype + if (properties === dynamicMethods && !definitionKind) continue; + const kind = definitionKind === 'set' || definitionKind === 'get' ? definitionKind : 'init'; + let key: string; + if (definition.computed) { + const keyValue = definition.key.getLiteralValueAtPath( + EMPTY_PATH, + SHARED_RECURSION_TRACKER, + this + ); + if (typeof keyValue === 'symbol') { + properties.push({ + key: isAnyWellKnown(keyValue) ? keyValue : UnknownKey, + kind, + property: definition + }); + continue; + } else { + key = String(keyValue); + } + } else { + key = + definition.key instanceof Identifier + ? definition.key.name + : String((definition.key as Literal).value); + } + properties.push({ key, kind, property: definition }); } + staticProperties.unshift({ + key: 'prototype', + kind: 'init', + property: new ObjectEntity( + dynamicMethods, + this.superClass ? new ObjectMember(this.superClass, ['prototype']) : OBJECT_PROTOTYPE + ) + }); + return (this.objectEntity = new ObjectEntity( + staticProperties, + this.superClass || OBJECT_PROTOTYPE + )); } } + +ClassNode.prototype.includeNode = onlyIncludeSelf; diff --git a/src/ast/nodes/shared/Expression.ts b/src/ast/nodes/shared/Expression.ts index eba5367420b..eeb204acf61 100644 --- a/src/ast/nodes/shared/Expression.ts +++ b/src/ast/nodes/shared/Expression.ts @@ -1,37 +1,147 @@ -import { CallOptions } from '../../CallOptions'; -import { DeoptimizableEntity } from '../../DeoptimizableEntity'; -import { WritableEntity } from '../../Entity'; -import { HasEffectsContext, InclusionContext } from '../../ExecutionContext'; -import { ObjectPath, PathTracker } from '../../utils/PathTracker'; -import { LiteralValueOrUnknown } from '../../values'; -import SpreadElement from '../SpreadElement'; -import { ExpressionNode, IncludeChildren } from './Node'; - -export interface ExpressionEntity extends WritableEntity { - included: boolean; +import type { DeoptimizableEntity } from '../../DeoptimizableEntity'; +import type { WritableEntity } from '../../Entity'; +import type { HasEffectsContext, InclusionContext } from '../../ExecutionContext'; +import type { NodeInteraction, NodeInteractionCalled } from '../../NodeInteractions'; +import type { + EntityPathTracker, + ObjectPath, + UnknownWellKnown, + WellKnownSymbol +} from '../../utils/PathTracker'; +import { UNKNOWN_PATH } from '../../utils/PathTracker'; +import type { LiteralValue } from '../Literal'; +import { Flag, isFlagSet, setFlag } from './BitFlags'; +import type { IncludeChildren } from './Node'; +export const UnknownValue = Symbol('Unknown Value'); +export const UnknownTruthyValue = Symbol('Unknown Truthy Value'); +export const UnknownFalsyValue = Symbol('Unknown Falsy Value'); + +export type LiteralValueOrUnknown = + | LiteralValue + | typeof UnknownValue + | typeof UnknownWellKnown + | typeof UnknownTruthyValue + | typeof UnknownFalsyValue + | WellKnownSymbol; + +export interface InclusionOptions { /** - * If possible it returns a stringifyable literal value for this node that can be used - * for inlining or comparing values. - * Otherwise it should return UnknownValue. + * Include the id of a declarator even if unused to ensure it is a valid + * statement. + */ + asSingleStatement?: boolean; +} + +export class ExpressionEntity implements WritableEntity { + protected flags = 0; + + get included(): boolean { + return isFlagSet(this.flags, Flag.included); + } + set included(value: boolean) { + this.flags = setFlag(this.flags, Flag.included, value); + } + + deoptimizeArgumentsOnInteractionAtPath( + interaction: NodeInteraction, + _path: ObjectPath, + _recursionTracker: EntityPathTracker + ): void { + deoptimizeInteraction(interaction); + } + + deoptimizePath(_path: ObjectPath): void {} + + /** + * If possible it returns a stringifyable literal value for this node that + * can be used for inlining or comparing values. Otherwise, it should return + * UnknownValue. */ getLiteralValueAtPath( - path: ObjectPath, - recursionTracker: PathTracker, - origin: DeoptimizableEntity - ): LiteralValueOrUnknown; + _path: ObjectPath, + _recursionTracker: EntityPathTracker, + _origin: DeoptimizableEntity + ): LiteralValueOrUnknown { + return UnknownValue; + } + getReturnExpressionWhenCalledAtPath( - path: ObjectPath, - recursionTracker: PathTracker, - origin: DeoptimizableEntity - ): ExpressionEntity; - hasEffectsWhenAccessedAtPath(path: ObjectPath, context: HasEffectsContext): boolean; - hasEffectsWhenCalledAtPath( - path: ObjectPath, - callOptions: CallOptions, - context: HasEffectsContext - ): boolean; - include(context: InclusionContext, includeChildrenRecursively: IncludeChildren): void; - includeCallArguments(context: InclusionContext, args: (ExpressionNode | SpreadElement)[]): void; - mayModifyThisWhenCalledAtPath(path: ObjectPath, recursionTracker: PathTracker): boolean; + _path: ObjectPath, + _interaction: NodeInteractionCalled, + _recursionTracker: EntityPathTracker, + _origin: DeoptimizableEntity + ): [expression: ExpressionEntity, isPure: boolean] { + return UNKNOWN_RETURN_EXPRESSION; + } + + hasEffectsOnInteractionAtPath( + _path: ObjectPath, + _interaction: NodeInteraction, + _context: HasEffectsContext + ): boolean { + return true; + } + + include( + context: InclusionContext, + _includeChildrenRecursively: IncludeChildren, + _options?: InclusionOptions + ): void { + if (!this.included) this.includeNode(context); + } + + includeNode(_context: InclusionContext): void { + this.included = true; + } + + includePath(_path: ObjectPath, context: InclusionContext): void { + if (!this.included) this.includeNode(context); + } + /* We are both including and including an unknown path here as the former + * ensures that nested nodes are included while the latter ensures that all + * paths of the expression are included. + * */ + + includeCallArguments(interaction: NodeInteractionCalled, context: InclusionContext): void { + includeInteraction(interaction, context); + } + + shouldBeIncluded(_context: InclusionContext): boolean { + return true; + } } + +export const UNKNOWN_EXPRESSION: ExpressionEntity = + new (class UnknownExpression extends ExpressionEntity {})(); + +export const UNKNOWN_RETURN_EXPRESSION: [expression: ExpressionEntity, isPure: boolean] = [ + UNKNOWN_EXPRESSION, + false +]; + +export const deoptimizeInteraction = (interaction: NodeInteraction) => { + for (const argument of interaction.args) { + argument?.deoptimizePath(UNKNOWN_PATH); + } +}; + +export const includeInteraction = (interaction: NodeInteraction, context: InclusionContext) => { + // We do not re-include the "this" argument as we expect this is already + // re-included at the call site + interaction.args[0]?.includePath(UNKNOWN_PATH, context); + includeInteractionWithoutThis(interaction, context); +}; + +export const includeInteractionWithoutThis = ( + { args }: NodeInteraction, + context: InclusionContext +) => { + for (let argumentIndex = 1; argumentIndex < args.length; argumentIndex++) { + const argument = args[argumentIndex]; + if (argument) { + argument.includePath(UNKNOWN_PATH, context); + argument.include(context, false); + } + } +}; diff --git a/src/ast/nodes/shared/FunctionBase.ts b/src/ast/nodes/shared/FunctionBase.ts new file mode 100644 index 00000000000..a3da5e27aa4 --- /dev/null +++ b/src/ast/nodes/shared/FunctionBase.ts @@ -0,0 +1,261 @@ +import type { NormalizedTreeshakingOptions } from '../../../rollup/types'; +import type { DeoptimizableEntity } from '../../DeoptimizableEntity'; +import { type HasEffectsContext, type InclusionContext } from '../../ExecutionContext'; +import type { NodeInteraction, NodeInteractionCalled } from '../../NodeInteractions'; +import { + INTERACTION_CALLED, + NODE_INTERACTION_UNKNOWN_ACCESS, + NODE_INTERACTION_UNKNOWN_CALL +} from '../../NodeInteractions'; +import type ReturnValueScope from '../../scopes/ReturnValueScope'; +import type { EntityPathTracker, ObjectPath } from '../../utils/PathTracker'; +import { EMPTY_PATH, UNKNOWN_PATH, UnknownKey } from '../../utils/PathTracker'; +import { UNDEFINED_EXPRESSION } from '../../values'; +import type ParameterVariable from '../../variables/ParameterVariable'; +import type Variable from '../../variables/Variable'; +import BlockStatement from '../BlockStatement'; +import type ExportDefaultDeclaration from '../ExportDefaultDeclaration'; +import * as NodeType from '../NodeType'; +import RestElement from '../RestElement'; +import type VariableDeclarator from '../VariableDeclarator'; +import { Flag, isFlagSet, setFlag } from './BitFlags'; +import type { ExpressionEntity, LiteralValueOrUnknown } from './Expression'; +import { UNKNOWN_EXPRESSION, UNKNOWN_RETURN_EXPRESSION } from './Expression'; +import { + doNotDeoptimize, + type ExpressionNode, + type GenericEsTreeNode, + type IncludeChildren, + NodeBase, + onlyIncludeSelfNoDeoptimize +} from './Node'; +import type { ObjectEntity } from './ObjectEntity'; +import type { DeclarationPatternNode } from './Pattern'; + +export default abstract class FunctionBase extends NodeBase { + declare body: BlockStatement | ExpressionNode; + declare params: DeclarationPatternNode[]; + declare preventChildBlockScope: true; + declare scope: ReturnValueScope; + + /** Marked with #__NO_SIDE_EFFECTS__ annotation */ + declare annotationNoSideEffects?: boolean; + + get async(): boolean { + return isFlagSet(this.flags, Flag.async); + } + set async(value: boolean) { + this.flags = setFlag(this.flags, Flag.async, value); + } + + get deoptimizedReturn(): boolean { + return isFlagSet(this.flags, Flag.deoptimizedReturn); + } + set deoptimizedReturn(value: boolean) { + this.flags = setFlag(this.flags, Flag.deoptimizedReturn, value); + } + + get generator(): boolean { + return isFlagSet(this.flags, Flag.generator); + } + set generator(value: boolean) { + this.flags = setFlag(this.flags, Flag.generator, value); + } + + protected get hasCachedEffects(): boolean { + return isFlagSet(this.flags, Flag.hasEffects); + } + protected set hasCachedEffects(value: boolean) { + this.flags = setFlag(this.flags, Flag.hasEffects, value); + } + + deoptimizeArgumentsOnInteractionAtPath( + interaction: NodeInteraction, + path: ObjectPath, + recursionTracker: EntityPathTracker + ): void { + if (interaction.type === INTERACTION_CALLED && path.length === 0) { + this.scope.deoptimizeArgumentsOnCall(interaction); + } else { + this.getObjectEntity().deoptimizeArgumentsOnInteractionAtPath( + interaction, + path, + recursionTracker + ); + } + } + + deoptimizePath(path: ObjectPath): void { + this.getObjectEntity().deoptimizePath(path); + if (path.length === 1 && path[0] === UnknownKey) { + // A reassignment of UNKNOWN_PATH is considered equivalent to having lost track + // which means the return expression and parameters need to be reassigned + this.scope.getReturnExpression().deoptimizePath(UNKNOWN_PATH); + this.scope.deoptimizeAllParameters(); + } + } + + getLiteralValueAtPath( + path: ObjectPath, + recursionTracker: EntityPathTracker, + origin: DeoptimizableEntity + ): LiteralValueOrUnknown { + return this.getObjectEntity().getLiteralValueAtPath(path, recursionTracker, origin); + } + + getReturnExpressionWhenCalledAtPath( + path: ObjectPath, + interaction: NodeInteractionCalled, + recursionTracker: EntityPathTracker, + origin: DeoptimizableEntity + ): [expression: ExpressionEntity, isPure: boolean] { + if (path.length > 0) { + return this.getObjectEntity().getReturnExpressionWhenCalledAtPath( + path, + interaction, + recursionTracker, + origin + ); + } + if (this.async) { + if (!this.deoptimizedReturn) { + this.deoptimizedReturn = true; + this.scope.getReturnExpression().deoptimizePath(UNKNOWN_PATH); + this.scope.context.requestTreeshakingPass(); + } + return UNKNOWN_RETURN_EXPRESSION; + } + return [this.scope.getReturnExpression(), false]; + } + + hasEffectsOnInteractionAtPath( + path: ObjectPath, + interaction: NodeInteraction, + context: HasEffectsContext + ): boolean { + if (path.length > 0 || interaction.type !== INTERACTION_CALLED) { + return this.getObjectEntity().hasEffectsOnInteractionAtPath(path, interaction, context); + } + if (this.hasCachedEffects) { + return true; + } + + if (this.async) { + const { propertyReadSideEffects } = this.scope.context.options + .treeshake as NormalizedTreeshakingOptions; + const returnExpression = this.scope.getReturnExpression(); + if ( + returnExpression.hasEffectsOnInteractionAtPath( + ['then'], + NODE_INTERACTION_UNKNOWN_CALL, + context + ) || + (propertyReadSideEffects && + (propertyReadSideEffects === 'always' || + returnExpression.hasEffectsOnInteractionAtPath( + ['then'], + NODE_INTERACTION_UNKNOWN_ACCESS, + context + ))) + ) { + this.hasCachedEffects = true; + return true; + } + } + const { propertyReadSideEffects } = this.scope.context.options + .treeshake as NormalizedTreeshakingOptions; + for (let index = 0; index < this.params.length; index++) { + const parameter = this.params[index]; + if ( + parameter.hasEffects(context) || + (propertyReadSideEffects && + parameter.hasEffectsWhenDestructuring( + context, + EMPTY_PATH, + interaction.args[index + 1] || UNDEFINED_EXPRESSION + )) + ) { + this.hasCachedEffects = true; + return true; + } + } + return false; + } + + /** + * If the function (expression or declaration) is only used as function calls + */ + protected onlyFunctionCallUsed(): boolean { + let variable: Variable | null = null; + if (this.parent.type === NodeType.VariableDeclarator) { + variable = (this.parent as VariableDeclarator).id.variable ?? null; + } + if (this.parent.type === NodeType.ExportDefaultDeclaration) { + variable = (this.parent as ExportDefaultDeclaration).variable; + } + return variable?.getOnlyFunctionCallUsed() ?? false; + } + + private parameterVariableValuesDeoptimized = false; + + include(context: InclusionContext, includeChildrenRecursively: IncludeChildren): void { + if (!this.included) this.includeNode(context); + if (!(this.parameterVariableValuesDeoptimized || this.onlyFunctionCallUsed())) { + this.parameterVariableValuesDeoptimized = true; + this.scope.reassignAllParameters(); + } + const { brokenFlow } = context; + context.brokenFlow = false; + this.body.include(context, includeChildrenRecursively); + context.brokenFlow = brokenFlow; + } + + includeCallArguments = this.scope.includeCallArguments.bind(this.scope); + + initialise(): void { + super.initialise(); + if (this.body instanceof BlockStatement) { + this.body.addImplicitReturnExpressionToScope(); + } else { + this.scope.addReturnExpression(this.body); + } + if ( + this.annotations && + (this.scope.context.options.treeshake as NormalizedTreeshakingOptions).annotations + ) { + this.annotationNoSideEffects = this.annotations.some( + comment => comment.type === 'noSideEffects' + ); + } + } + + parseNode(esTreeNode: GenericEsTreeNode): this { + const { body, params } = esTreeNode; + const { scope } = this; + const { bodyScope, context } = scope; + // We need to ensure that parameters are declared before the body is parsed + // so that the scope already knows all parameters and can detect conflicts + // when parsing the body. + const parameters: typeof this.params = (this.params = params.map( + (parameter: GenericEsTreeNode) => + new (context.getNodeConstructor(parameter.type))(this, scope).parseNode( + parameter + ) as unknown as DeclarationPatternNode + )); + scope.addParameterVariables( + parameters.map( + parameter => + parameter.declare('parameter', EMPTY_PATH, UNKNOWN_EXPRESSION) as ParameterVariable[] + ), + parameters[parameters.length - 1] instanceof RestElement + ); + this.body = new (context.getNodeConstructor(body.type))(this, bodyScope).parseNode(body); + return super.parseNode(esTreeNode); + } + + protected abstract getObjectEntity(): ObjectEntity; +} + +FunctionBase.prototype.preventChildBlockScope = true; +FunctionBase.prototype.includeNode = onlyIncludeSelfNoDeoptimize; +FunctionBase.prototype.applyDeoptimizations = doNotDeoptimize; diff --git a/src/ast/nodes/shared/FunctionNode.ts b/src/ast/nodes/shared/FunctionNode.ts index 65e81bed072..4d1b1932d9b 100644 --- a/src/ast/nodes/shared/FunctionNode.ts +++ b/src/ast/nodes/shared/FunctionNode.ts @@ -1,141 +1,144 @@ -import { CallOptions } from '../../CallOptions'; -import { BROKEN_FLOW_NONE, HasEffectsContext, InclusionContext } from '../../ExecutionContext'; +import { type HasEffectsContext, type InclusionContext } from '../../ExecutionContext'; +import type { NodeInteraction } from '../../NodeInteractions'; +import { INTERACTION_CALLED } from '../../NodeInteractions'; +import type ChildScope from '../../scopes/ChildScope'; import FunctionScope from '../../scopes/FunctionScope'; -import { ObjectPath, UnknownKey, UNKNOWN_PATH } from '../../utils/PathTracker'; -import { UnknownObjectExpression, UNKNOWN_EXPRESSION } from '../../values'; -import BlockStatement from '../BlockStatement'; -import Identifier, { IdentifierWithVariable } from '../Identifier'; -import RestElement from '../RestElement'; -import SpreadElement from '../SpreadElement'; -import { ExpressionNode, GenericEsTreeNode, IncludeChildren, NodeBase } from './Node'; -import { PatternNode } from './Pattern'; - -export default class FunctionNode extends NodeBase { - async!: boolean; - body!: BlockStatement; - id!: IdentifierWithVariable | null; - params!: PatternNode[]; - preventChildBlockScope!: true; - referencesThis!: boolean; - scope!: FunctionScope; - - private isPrototypeDeoptimized = false; - - createScope(parentScope: FunctionScope) { - this.scope = new FunctionScope(parentScope, this.context); +import { + EMPTY_PATH, + type EntityPathTracker, + type ObjectPath, + UNKNOWN_PATH +} from '../../utils/PathTracker'; +import type BlockStatement from '../BlockStatement'; +import Identifier, { type IdentifierWithVariable } from '../Identifier'; +import { UNKNOWN_EXPRESSION } from './Expression'; +import FunctionBase from './FunctionBase'; +import { type IncludeChildren } from './Node'; +import { ObjectEntity } from './ObjectEntity'; +import { OBJECT_PROTOTYPE } from './ObjectPrototype'; +import type { DeclarationPatternNode } from './Pattern'; + +export default class FunctionNode extends FunctionBase { + declare body: BlockStatement; + declare id: IdentifierWithVariable | null; + declare params: DeclarationPatternNode[]; + declare preventChildBlockScope: true; + declare scope: FunctionScope; + protected objectEntity: ObjectEntity | null = null; + declare private constructedEntity: ObjectEntity; + + createScope(parentScope: ChildScope): void { + this.scope = new FunctionScope(parentScope, this); + this.constructedEntity = new ObjectEntity(new Map(), OBJECT_PROTOTYPE); + // This makes sure that all deoptimizations of "this" are applied to the + // constructed entity. + this.scope.thisVariable.addArgumentForDeoptimization(this.constructedEntity); } - deoptimizePath(path: ObjectPath) { - if (path.length === 1) { - if (path[0] === 'prototype') { - this.isPrototypeDeoptimized = true; - } else if (path[0] === UnknownKey) { - this.isPrototypeDeoptimized = true; - - // A reassignment of UNKNOWN_PATH is considered equivalent to having lost track - // which means the return expression needs to be reassigned as well - this.scope.getReturnExpression().deoptimizePath(UNKNOWN_PATH); - } + deoptimizeArgumentsOnInteractionAtPath( + interaction: NodeInteraction, + path: ObjectPath, + recursionTracker: EntityPathTracker + ): void { + super.deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker); + if (interaction.type === INTERACTION_CALLED && path.length === 0 && interaction.args[0]) { + // args[0] is the "this" argument + this.scope.thisVariable.addArgumentForDeoptimization(interaction.args[0]); } } - getReturnExpressionWhenCalledAtPath(path: ObjectPath) { - return path.length === 0 ? this.scope.getReturnExpression() : UNKNOWN_EXPRESSION; - } - - hasEffects() { - return this.id !== null && this.id.hasEffects(); - } - - hasEffectsWhenAccessedAtPath(path: ObjectPath) { - if (path.length <= 1) return false; - return path.length > 2 || path[0] !== 'prototype' || this.isPrototypeDeoptimized; - } - - hasEffectsWhenAssignedAtPath(path: ObjectPath) { - if (path.length <= 1) { + hasEffects(context: HasEffectsContext): boolean { + if (this.annotationNoSideEffects) { return false; } - return path.length > 2 || path[0] !== 'prototype' || this.isPrototypeDeoptimized; + + return !!this.id?.hasEffects(context); } - hasEffectsWhenCalledAtPath( + hasEffectsOnInteractionAtPath( path: ObjectPath, - callOptions: CallOptions, + interaction: NodeInteraction, context: HasEffectsContext - ) { - if (path.length > 0) return true; - for (const param of this.params) { - if (param.hasEffects(context)) return true; + ): boolean { + if ( + this.annotationNoSideEffects && + path.length === 0 && + interaction.type === INTERACTION_CALLED + ) { + return false; } - const thisInit = context.replacedVariableInits.get(this.scope.thisVariable); - context.replacedVariableInits.set( - this.scope.thisVariable, - callOptions.withNew ? new UnknownObjectExpression() : UNKNOWN_EXPRESSION - ); - const { brokenFlow, ignore } = context; - context.ignore = { - breaks: false, - continues: false, - labels: new Set(), - returnAwaitYield: true - }; - if (this.body.hasEffects(context)) return true; - context.brokenFlow = brokenFlow; - if (thisInit) { - context.replacedVariableInits.set(this.scope.thisVariable, thisInit); - } else { - context.replacedVariableInits.delete(this.scope.thisVariable); + if (super.hasEffectsOnInteractionAtPath(path, interaction, context)) { + return true; + } + + if (path.length === 0 && interaction.type === INTERACTION_CALLED) { + const thisInit = context.replacedVariableInits.get(this.scope.thisVariable); + context.replacedVariableInits.set( + this.scope.thisVariable, + interaction.withNew ? this.constructedEntity : UNKNOWN_EXPRESSION + ); + const { brokenFlow, ignore, replacedVariableInits } = context; + context.ignore = { + breaks: false, + continues: false, + labels: new Set(), + returnYield: true, + this: interaction.withNew + }; + if (this.body.hasEffects(context)) { + this.hasCachedEffects = true; + return true; + } + context.brokenFlow = brokenFlow; + if (thisInit) { + replacedVariableInits.set(this.scope.thisVariable, thisInit); + } else { + replacedVariableInits.delete(this.scope.thisVariable); + } + context.ignore = ignore; } - context.ignore = ignore; return false; } - include(context: InclusionContext, includeChildrenRecursively: IncludeChildren) { - this.included = true; - if (this.id) this.id.include(); + include(context: InclusionContext, includeChildrenRecursively: IncludeChildren): void { + super.include(context, includeChildrenRecursively); + this.id?.include(context, includeChildrenRecursively); const hasArguments = this.scope.argumentsVariable.included; - for (const param of this.params) { - if (!(param instanceof Identifier) || hasArguments) { - param.include(context, includeChildrenRecursively); + for (const parameter of this.params) { + if (!(parameter instanceof Identifier) || hasArguments) { + parameter.include(context, includeChildrenRecursively); } } - const { brokenFlow } = context; - context.brokenFlow = BROKEN_FLOW_NONE; - this.body.include(context, includeChildrenRecursively); - context.brokenFlow = brokenFlow; } - includeCallArguments(context: InclusionContext, args: (ExpressionNode | SpreadElement)[]): void { - this.scope.includeCallArguments(context, args); - } - - initialise() { - if (this.id !== null) { - this.id.declare('function', this); + includeNode(context: InclusionContext) { + this.included = true; + const hasArguments = this.scope.argumentsVariable.included; + for (const parameter of this.params) { + if (!(parameter instanceof Identifier) || hasArguments) { + parameter.includePath(UNKNOWN_PATH, context); + } } - this.scope.addParameterVariables( - this.params.map(param => param.declare('parameter', UNKNOWN_EXPRESSION)), - this.params[this.params.length - 1] instanceof RestElement - ); - this.body.addImplicitReturnExpressionToScope(); } - mayModifyThisWhenCalledAtPath( - path: ObjectPath - ) { - return path.length ? true : this.referencesThis + initialise(): void { + super.initialise(); + this.id?.declare('function', EMPTY_PATH, this); } - parseNode(esTreeNode: GenericEsTreeNode) { - this.referencesThis = false; - this.body = new this.context.nodeConstructors.BlockStatement( - esTreeNode.body, - this, - this.scope.hoistedBodyVarScope - ) as BlockStatement; - super.parseNode(esTreeNode); + protected getObjectEntity(): ObjectEntity { + if (this.objectEntity !== null) { + return this.objectEntity; + } + return (this.objectEntity = new ObjectEntity( + [ + { + key: 'prototype', + kind: 'init', + property: new ObjectEntity([], OBJECT_PROTOTYPE) + } + ], + OBJECT_PROTOTYPE + )); } } - -FunctionNode.prototype.preventChildBlockScope = true; diff --git a/src/ast/nodes/shared/IdentifierBase.ts b/src/ast/nodes/shared/IdentifierBase.ts new file mode 100644 index 00000000000..688ee03bc76 --- /dev/null +++ b/src/ast/nodes/shared/IdentifierBase.ts @@ -0,0 +1,256 @@ +import type { NormalizedTreeshakingOptions } from '../../../rollup/types'; +import { logIllegalImportReassignment } from '../../../utils/logs'; +import { PureFunctionKey } from '../../../utils/pureFunctions'; +import { markModuleAndImpureDependenciesAsExecuted } from '../../../utils/traverseStaticDependencies'; +import type { DeoptimizableEntity } from '../../DeoptimizableEntity'; +import type { HasEffectsContext, InclusionContext } from '../../ExecutionContext'; +import type { NodeInteraction, NodeInteractionCalled } from '../../NodeInteractions'; +import { + INTERACTION_ACCESSED, + INTERACTION_ASSIGNED, + INTERACTION_CALLED, + NODE_INTERACTION_UNKNOWN_ACCESS +} from '../../NodeInteractions'; +import type { EntityPathTracker, ObjectPath } from '../../utils/PathTracker'; +import { EMPTY_PATH, UNKNOWN_PATH } from '../../utils/PathTracker'; +import GlobalVariable from '../../variables/GlobalVariable'; +import LocalVariable from '../../variables/LocalVariable'; +import type Variable from '../../variables/Variable'; +import { Flag, isFlagSet, setFlag } from './BitFlags'; +import type { ExpressionEntity, LiteralValueOrUnknown } from './Expression'; +import { UNKNOWN_EXPRESSION } from './Expression'; +import { type IncludeChildren, NodeBase } from './Node'; + +const tdzVariableKinds = new Set(['class', 'const', 'let', 'var', 'using', 'await using']); + +export default class IdentifierBase extends NodeBase { + name!: string; + variable: Variable | null = null; + + protected isVariableReference = false; + + private get isTDZAccess(): boolean | null { + if (!isFlagSet(this.flags, Flag.tdzAccessDefined)) { + return null; + } + return isFlagSet(this.flags, Flag.tdzAccess); + } + + private set isTDZAccess(value: boolean) { + this.flags = setFlag(this.flags, Flag.tdzAccessDefined, true); + this.flags = setFlag(this.flags, Flag.tdzAccess, value); + } + + deoptimizeArgumentsOnInteractionAtPath( + interaction: NodeInteraction, + path: ObjectPath, + recursionTracker: EntityPathTracker + ): void { + this.variable!.deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker); + } + + deoptimizePath(path: ObjectPath): void { + if (path.length === 0 && !this.scope.contains(this.name)) { + this.disallowImportReassignment(); + } + // We keep conditional chaining because an unknown Node could have an + // Identifier as property that might be deoptimized by default + this.variable?.deoptimizePath(path); + } + + getLiteralValueAtPath( + path: ObjectPath, + recursionTracker: EntityPathTracker, + origin: DeoptimizableEntity + ): LiteralValueOrUnknown { + return this.getVariableRespectingTDZ()!.getLiteralValueAtPath(path, recursionTracker, origin); + } + + getReturnExpressionWhenCalledAtPath( + path: ObjectPath, + interaction: NodeInteractionCalled, + recursionTracker: EntityPathTracker, + origin: DeoptimizableEntity + ): [expression: ExpressionEntity, isPure: boolean] { + const [expression, isPure] = + this.getVariableRespectingTDZ()!.getReturnExpressionWhenCalledAtPath( + path, + interaction, + recursionTracker, + origin + ); + return [expression, isPure || this.isPureFunction(path)]; + } + + hasEffects(context: HasEffectsContext): boolean { + if (!this.deoptimized) this.applyDeoptimizations(); + if (this.isPossibleTDZ() && this.variable!.kind !== 'var') { + return true; + } + return ( + (this.scope.context.options.treeshake as NormalizedTreeshakingOptions) + .unknownGlobalSideEffects && + this.variable instanceof GlobalVariable && + !this.isPureFunction(EMPTY_PATH) && + this.variable.hasEffectsOnInteractionAtPath( + EMPTY_PATH, + NODE_INTERACTION_UNKNOWN_ACCESS, + context + ) + ); + } + + hasEffectsOnInteractionAtPath( + path: ObjectPath, + interaction: NodeInteraction, + context: HasEffectsContext + ): boolean { + switch (interaction.type) { + case INTERACTION_ACCESSED: { + return ( + this.variable !== null && + !this.isPureFunction(path) && + this.getVariableRespectingTDZ()!.hasEffectsOnInteractionAtPath(path, interaction, context) + ); + } + case INTERACTION_ASSIGNED: { + return ( + path.length > 0 ? this.getVariableRespectingTDZ() : this.variable + )!.hasEffectsOnInteractionAtPath(path, interaction, context); + } + case INTERACTION_CALLED: { + return ( + !this.isPureFunction(path) && + this.getVariableRespectingTDZ()!.hasEffectsOnInteractionAtPath(path, interaction, context) + ); + } + } + } + + include(context: InclusionContext, includeChildrenRecursively: IncludeChildren): void { + if (!this.included) this.includeNode(context); + if (includeChildrenRecursively) { + this.variable?.includePath(UNKNOWN_PATH, context); + } + } + + includeNode(context: InclusionContext) { + this.included = true; + if (!this.deoptimized) this.applyDeoptimizations(); + if (this.variable !== null) { + this.scope.context.includeVariableInModule(this.variable, EMPTY_PATH, context); + } + } + + includePath(path: ObjectPath, context: InclusionContext): void { + if (!this.included) { + this.included = true; + if (!this.deoptimized) this.applyDeoptimizations(); + if (this.variable !== null) { + this.scope.context.includeVariableInModule(this.variable, path, context); + } + } else if (path.length > 0) { + this.variable?.includePath(path, context); + } + } + + includeCallArguments(interaction: NodeInteractionCalled, context: InclusionContext): void { + this.variable!.includeCallArguments(interaction, context); + } + + isPossibleTDZ(): boolean { + // return cached value to avoid issues with the next tree-shaking pass + const cachedTdzAccess = this.isTDZAccess; + if (cachedTdzAccess !== null) return cachedTdzAccess; + + if ( + !( + this.variable instanceof LocalVariable && + this.variable.kind && + tdzVariableKinds.has(this.variable.kind) && + // We ignore modules that did not receive a treeshaking pass yet as that + // causes many false positives due to circular dependencies or disabled + // moduleSideEffects. + this.variable.module.hasTreeShakingPassStarted + ) + ) { + return (this.isTDZAccess = false); + } + + let decl_id; + if ( + this.variable.declarations && + this.variable.declarations.length === 1 && + (decl_id = this.variable.declarations[0] as any) && + this.start < decl_id.start && + closestParentFunctionOrProgram(this) === closestParentFunctionOrProgram(decl_id) + ) { + // a variable accessed before its declaration + // in the same function or at top level of module + return (this.isTDZAccess = true); + } + + if (!this.variable.initReached) { + // Either a const/let TDZ violation or + // var use before declaration was encountered. + return (this.isTDZAccess = true); + } + + return (this.isTDZAccess = false); + } + + applyDeoptimizations() { + this.deoptimized = true; + if (this.variable instanceof LocalVariable) { + // When accessing a variable from a module without side effects, this + // means we use an export of that module and therefore need to potentially + // include it in the bundle. + if (!this.variable.module.isExecuted) { + markModuleAndImpureDependenciesAsExecuted(this.variable.module); + } + this.variable.consolidateInitializers(); + this.scope.context.requestTreeshakingPass(); + } + if (this.isVariableReference) { + this.variable!.addUsedPlace(this); + this.scope.context.requestTreeshakingPass(); + } + } + + private disallowImportReassignment(): never { + return this.scope.context.error( + logIllegalImportReassignment(this.name, this.scope.context.module.id), + this.start + ); + } + + private getVariableRespectingTDZ(): ExpressionEntity | null { + if (this.isPossibleTDZ()) { + return UNKNOWN_EXPRESSION; + } + return this.variable; + } + + private isPureFunction(path: ObjectPath) { + let currentPureFunction = this.scope.context.manualPureFunctions[this.name]; + for (const segment of path) { + if (currentPureFunction) { + if (currentPureFunction[PureFunctionKey]) { + return true; + } + currentPureFunction = currentPureFunction[segment as string]; + } else { + return false; + } + } + return currentPureFunction?.[PureFunctionKey] as boolean; + } +} + +function closestParentFunctionOrProgram(node: any): any { + while (node && !/^Program|Function/.test(node.type)) { + node = node.parent; + } + // one of: ArrowFunctionExpression, FunctionDeclaration, FunctionExpression or Program + return node; +} diff --git a/src/ast/nodes/shared/JSXClosingBase.ts b/src/ast/nodes/shared/JSXClosingBase.ts new file mode 100644 index 00000000000..19d672888df --- /dev/null +++ b/src/ast/nodes/shared/JSXClosingBase.ts @@ -0,0 +1,17 @@ +import type MagicString from 'magic-string'; +import type { NormalizedJsxOptions } from '../../../rollup/types'; +import type { RenderOptions } from '../../../utils/renderHelpers'; +import { NodeBase, onlyIncludeSelf } from './Node'; + +export default class JSXClosingBase extends NodeBase { + render(code: MagicString, options: RenderOptions): void { + const { mode } = this.scope.context.options.jsx as NormalizedJsxOptions; + if (mode !== 'preserve') { + code.overwrite(this.start, this.end, ')', { contentOnly: true }); + } else { + super.render(code, options); + } + } +} + +JSXClosingBase.prototype.includeNode = onlyIncludeSelf; diff --git a/src/ast/nodes/shared/JSXElementBase.ts b/src/ast/nodes/shared/JSXElementBase.ts new file mode 100644 index 00000000000..40c53646fda --- /dev/null +++ b/src/ast/nodes/shared/JSXElementBase.ts @@ -0,0 +1,92 @@ +import type MagicString from 'magic-string'; +import type { NormalizedJsxOptions } from '../../../rollup/types'; +import { getRenderedJsxChildren } from '../../../utils/jsx'; +import type { RenderOptions } from '../../../utils/renderHelpers'; +import type { InclusionContext } from '../../ExecutionContext'; +import type Variable from '../../variables/Variable'; +import JSXEmptyExpression from '../JSXEmptyExpression'; +import JSXExpressionContainer from '../JSXExpressionContainer'; +import JSXText from '../JSXText'; +import type { JSXChild, JsxMode } from './jsxHelpers'; +import { getAndIncludeFactoryVariable } from './jsxHelpers'; +import type { IncludeChildren } from './Node'; +import { doNotDeoptimize, NodeBase } from './Node'; + +export default class JSXElementBase extends NodeBase { + children!: JSXChild[]; + + protected factoryVariable: Variable | null = null; + protected factory: string | null = null; + declare protected jsxMode: JsxMode; + + initialise() { + super.initialise(); + const { importSource } = (this.jsxMode = this.getRenderingMode()); + if (importSource) { + this.scope.context.addImportSource(importSource); + } + } + + include(context: InclusionContext, includeChildrenRecursively: IncludeChildren) { + if (!this.included) this.includeNode(context); + for (const child of this.children) { + child.include(context, includeChildrenRecursively); + } + } + + includeNode(context: InclusionContext) { + this.included = true; + const { factory, importSource, mode } = this.jsxMode; + if (factory) { + this.factory = factory; + this.factoryVariable = getAndIncludeFactoryVariable( + factory, + mode === 'preserve', + importSource, + this, + context + ); + } + } + + protected getRenderingMode(): JsxMode { + const jsx = this.scope.context.options.jsx as NormalizedJsxOptions; + const { mode, factory, importSource } = jsx; + if (mode === 'automatic') { + return { + factory: getRenderedJsxChildren(this.children) > 1 ? 'jsxs' : 'jsx', + importSource: jsx.jsxImportSource, + mode + }; + } + return { factory, importSource, mode }; + } + + protected renderChildren(code: MagicString, options: RenderOptions, openingEnd: number) { + const { children } = this; + let hasMultipleChildren = false; + let childrenEnd = openingEnd; + let firstChild: JSXChild | null = null; + for (const child of children) { + if ( + (child instanceof JSXExpressionContainer && + child.expression instanceof JSXEmptyExpression) || + (child instanceof JSXText && !child.shouldRender()) + ) { + code.remove(childrenEnd, child.end); + } else { + code.appendLeft(childrenEnd, ', '); + child.render(code, options); + if (firstChild) { + hasMultipleChildren = true; + } else { + firstChild = child; + } + } + childrenEnd = child.end; + } + return { childrenEnd, firstChild, hasMultipleChildren }; + } +} + +JSXElementBase.prototype.applyDeoptimizations = doNotDeoptimize; diff --git a/src/ast/nodes/shared/MethodBase.ts b/src/ast/nodes/shared/MethodBase.ts new file mode 100644 index 00000000000..6bd71da55de --- /dev/null +++ b/src/ast/nodes/shared/MethodBase.ts @@ -0,0 +1,163 @@ +import type { DeoptimizableEntity } from '../../DeoptimizableEntity'; +import type { HasEffectsContext } from '../../ExecutionContext'; +import type { NodeInteraction, NodeInteractionCalled } from '../../NodeInteractions'; +import { + INTERACTION_ACCESSED, + INTERACTION_ASSIGNED, + INTERACTION_CALLED, + NODE_INTERACTION_UNKNOWN_CALL +} from '../../NodeInteractions'; +import { + EMPTY_PATH, + type EntityPathTracker, + type ObjectPath, + SHARED_RECURSION_TRACKER +} from '../../utils/PathTracker'; +import type PrivateIdentifier from '../PrivateIdentifier'; +import { Flag, isFlagSet, setFlag } from './BitFlags'; +import { + type ExpressionEntity, + type LiteralValueOrUnknown, + UNKNOWN_RETURN_EXPRESSION +} from './Expression'; +import { + doNotDeoptimize, + type ExpressionNode, + NodeBase, + onlyIncludeSelfNoDeoptimize +} from './Node'; +import type { DeclarationPatternNode } from './Pattern'; + +export default class MethodBase extends NodeBase implements DeoptimizableEntity { + declare key: ExpressionNode | PrivateIdentifier; + declare kind: 'constructor' | 'method' | 'init' | 'get' | 'set'; + declare value: ExpressionNode | (ExpressionNode & DeclarationPatternNode); + + get computed(): boolean { + return isFlagSet(this.flags, Flag.computed); + } + set computed(value: boolean) { + this.flags = setFlag(this.flags, Flag.computed, value); + } + + private accessedValue: [expression: ExpressionEntity, isPure: boolean] | null = null; + + deoptimizeArgumentsOnInteractionAtPath( + interaction: NodeInteraction, + path: ObjectPath, + recursionTracker: EntityPathTracker + ): void { + if (interaction.type === INTERACTION_ACCESSED && this.kind === 'get' && path.length === 0) { + return this.value.deoptimizeArgumentsOnInteractionAtPath( + { + args: interaction.args, + type: INTERACTION_CALLED, + withNew: false + }, + EMPTY_PATH, + recursionTracker + ); + } + if (interaction.type === INTERACTION_ASSIGNED && this.kind === 'set' && path.length === 0) { + return this.value.deoptimizeArgumentsOnInteractionAtPath( + { + args: interaction.args, + type: INTERACTION_CALLED, + withNew: false + }, + EMPTY_PATH, + recursionTracker + ); + } + this.getAccessedValue()[0].deoptimizeArgumentsOnInteractionAtPath( + interaction, + path, + recursionTracker + ); + } + + // As getter properties directly receive their values from fixed function + // expressions, there is no known situation where a getter is deoptimized. + deoptimizeCache(): void {} + + deoptimizePath(path: ObjectPath): void { + this.getAccessedValue()[0].deoptimizePath(path); + } + + getLiteralValueAtPath( + path: ObjectPath, + recursionTracker: EntityPathTracker, + origin: DeoptimizableEntity + ): LiteralValueOrUnknown { + return this.getAccessedValue()[0].getLiteralValueAtPath(path, recursionTracker, origin); + } + + getReturnExpressionWhenCalledAtPath( + path: ObjectPath, + interaction: NodeInteractionCalled, + recursionTracker: EntityPathTracker, + origin: DeoptimizableEntity + ): [expression: ExpressionEntity, isPure: boolean] { + return this.getAccessedValue()[0].getReturnExpressionWhenCalledAtPath( + path, + interaction, + recursionTracker, + origin + ); + } + + hasEffects(context: HasEffectsContext): boolean { + return this.key.hasEffects(context); + } + + hasEffectsOnInteractionAtPath( + path: ObjectPath, + interaction: NodeInteraction, + context: HasEffectsContext + ): boolean { + if (this.kind === 'get' && interaction.type === INTERACTION_ACCESSED && path.length === 0) { + return this.value.hasEffectsOnInteractionAtPath( + EMPTY_PATH, + { + args: interaction.args, + type: INTERACTION_CALLED, + withNew: false + }, + context + ); + } + // setters are only called for empty paths + if (this.kind === 'set' && interaction.type === INTERACTION_ASSIGNED) { + return this.value.hasEffectsOnInteractionAtPath( + EMPTY_PATH, + { + args: interaction.args, + type: INTERACTION_CALLED, + withNew: false + }, + context + ); + } + return this.getAccessedValue()[0].hasEffectsOnInteractionAtPath(path, interaction, context); + } + + protected getAccessedValue(): [expression: ExpressionEntity, isPure: boolean] { + if (this.accessedValue === null) { + if (this.kind === 'get') { + this.accessedValue = UNKNOWN_RETURN_EXPRESSION; + return (this.accessedValue = this.value.getReturnExpressionWhenCalledAtPath( + EMPTY_PATH, + NODE_INTERACTION_UNKNOWN_CALL, + SHARED_RECURSION_TRACKER, + this + )); + } else { + return (this.accessedValue = [this.value, false]); + } + } + return this.accessedValue; + } +} + +MethodBase.prototype.includeNode = onlyIncludeSelfNoDeoptimize; +MethodBase.prototype.applyDeoptimizations = doNotDeoptimize; diff --git a/src/ast/nodes/shared/MethodTypes.ts b/src/ast/nodes/shared/MethodTypes.ts new file mode 100644 index 00000000000..727154bcbd4 --- /dev/null +++ b/src/ast/nodes/shared/MethodTypes.ts @@ -0,0 +1,146 @@ +import type { HasEffectsContext } from '../../ExecutionContext'; +import type { NodeInteraction, NodeInteractionCalled } from '../../NodeInteractions'; +import { + INTERACTION_ACCESSED, + INTERACTION_CALLED, + NODE_INTERACTION_UNKNOWN_ASSIGNMENT, + NODE_INTERACTION_UNKNOWN_CALL +} from '../../NodeInteractions'; +import { + EMPTY_PATH, + type ObjectPath, + UNKNOWN_INTEGER_PATH, + UNKNOWN_PATH +} from '../../utils/PathTracker'; +import { + UNKNOWN_LITERAL_BOOLEAN, + UNKNOWN_LITERAL_NUMBER, + UNKNOWN_LITERAL_STRING +} from '../../values'; +import { ExpressionEntity, UNKNOWN_EXPRESSION, UNKNOWN_RETURN_EXPRESSION } from './Expression'; + +type MethodDescription = { + callsArgs: number[] | null; + mutatesSelfAsArray: boolean | 'deopt-only'; + mutatesArgs: boolean; +} & ( + | { + returns: 'self' | (() => ExpressionEntity); + returnsPrimitive: null; + } + | { + returns: null; + returnsPrimitive: ExpressionEntity; + } +); + +export class Method extends ExpressionEntity { + constructor(private readonly description: MethodDescription) { + super(); + } + + deoptimizeArgumentsOnInteractionAtPath({ args, type }: NodeInteraction, path: ObjectPath): void { + if (type === INTERACTION_CALLED && path.length === 0) { + if (this.description.mutatesSelfAsArray) { + args[0]?.deoptimizePath(UNKNOWN_INTEGER_PATH); + } + if (this.description.mutatesArgs) { + for (let index = 1; index < args.length; index++) { + args[index]!.deoptimizePath(UNKNOWN_PATH); + } + } + } + } + + getReturnExpressionWhenCalledAtPath( + path: ObjectPath, + { args }: NodeInteractionCalled + ): [expression: ExpressionEntity, isPure: boolean] { + if (path.length > 0) { + return UNKNOWN_RETURN_EXPRESSION; + } + return [ + this.description.returnsPrimitive || + (this.description.returns === 'self' + ? args[0] || UNKNOWN_EXPRESSION + : this.description.returns()), + false + ]; + } + + hasEffectsOnInteractionAtPath( + path: ObjectPath, + { args, type }: NodeInteraction, + context: HasEffectsContext + ): boolean { + if (path.length > (type === INTERACTION_ACCESSED ? 1 : 0)) { + return true; + } + if (type === INTERACTION_CALLED) { + if ( + this.description.mutatesSelfAsArray === true && + args[0]?.hasEffectsOnInteractionAtPath( + UNKNOWN_INTEGER_PATH, + NODE_INTERACTION_UNKNOWN_ASSIGNMENT, + context + ) + ) { + return true; + } + if (this.description.callsArgs) { + for (const argumentIndex of this.description.callsArgs) { + if ( + args[argumentIndex + 1]?.hasEffectsOnInteractionAtPath( + EMPTY_PATH, + NODE_INTERACTION_UNKNOWN_CALL, + context + ) + ) { + return true; + } + } + } + } + return false; + } +} + +export const METHOD_RETURNS_BOOLEAN = [ + new Method({ + callsArgs: null, + mutatesArgs: false, + mutatesSelfAsArray: false, + returns: null, + returnsPrimitive: UNKNOWN_LITERAL_BOOLEAN + }) +]; + +export const METHOD_RETURNS_STRING = [ + new Method({ + callsArgs: null, + mutatesArgs: false, + mutatesSelfAsArray: false, + returns: null, + returnsPrimitive: UNKNOWN_LITERAL_STRING + }) +]; + +export const METHOD_RETURNS_NUMBER = [ + new Method({ + callsArgs: null, + mutatesArgs: false, + mutatesSelfAsArray: false, + returns: null, + returnsPrimitive: UNKNOWN_LITERAL_NUMBER + }) +]; + +export const METHOD_RETURNS_UNKNOWN = [ + new Method({ + callsArgs: null, + mutatesArgs: false, + mutatesSelfAsArray: false, + returns: null, + returnsPrimitive: UNKNOWN_EXPRESSION + }) +]; diff --git a/src/ast/nodes/shared/MultiExpression.ts b/src/ast/nodes/shared/MultiExpression.ts index f657c7e3454..5b1279355c0 100644 --- a/src/ast/nodes/shared/MultiExpression.ts +++ b/src/ast/nodes/shared/MultiExpression.ts @@ -1,18 +1,12 @@ -import { CallOptions } from '../../CallOptions'; -import { DeoptimizableEntity } from '../../DeoptimizableEntity'; -import { HasEffectsContext, InclusionContext } from '../../ExecutionContext'; -import { ObjectPath, PathTracker } from '../../utils/PathTracker'; -import { LiteralValueOrUnknown, UnknownValue } from '../../values'; +import type { DeoptimizableEntity } from '../../DeoptimizableEntity'; +import type { HasEffectsContext } from '../../ExecutionContext'; +import type { NodeInteraction, NodeInteractionCalled } from '../../NodeInteractions'; +import type { EntityPathTracker, ObjectPath } from '../../utils/PathTracker'; import { ExpressionEntity } from './Expression'; -import { IncludeChildren } from './Node'; -export class MultiExpression implements ExpressionEntity { - included = false; - - private expressions: ExpressionEntity[]; - - constructor(expressions: ExpressionEntity[]) { - this.expressions = expressions; +export class MultiExpression extends ExpressionEntity { + constructor(private expressions: readonly ExpressionEntity[]) { + super(); } deoptimizePath(path: ObjectPath): void { @@ -21,60 +15,36 @@ export class MultiExpression implements ExpressionEntity { } } - getLiteralValueAtPath(): LiteralValueOrUnknown { - return UnknownValue; - } - getReturnExpressionWhenCalledAtPath( path: ObjectPath, - recursionTracker: PathTracker, + interaction: NodeInteractionCalled, + recursionTracker: EntityPathTracker, origin: DeoptimizableEntity - ): ExpressionEntity { - return new MultiExpression( - this.expressions.map(expression => - expression.getReturnExpressionWhenCalledAtPath(path, recursionTracker, origin) - ) - ); - } - - hasEffectsWhenAccessedAtPath(path: ObjectPath, context: HasEffectsContext): boolean { - for (const expression of this.expressions) { - if (expression.hasEffectsWhenAccessedAtPath(path, context)) return true; - } - return false; - } - - hasEffectsWhenAssignedAtPath(path: ObjectPath, context: HasEffectsContext): boolean { - for (const expression of this.expressions) { - if (expression.hasEffectsWhenAssignedAtPath(path, context)) return true; - } - return false; - } - - hasEffectsWhenCalledAtPath( + ): [expression: ExpressionEntity, isPure: boolean] { + return [ + new MultiExpression( + this.expressions.map( + expression => + expression.getReturnExpressionWhenCalledAtPath( + path, + interaction, + recursionTracker, + origin + )[0] + ) + ), + false + ]; + } + + hasEffectsOnInteractionAtPath( path: ObjectPath, - callOptions: CallOptions, + interaction: NodeInteraction, context: HasEffectsContext ): boolean { for (const expression of this.expressions) { - if (expression.hasEffectsWhenCalledAtPath(path, callOptions, context)) return true; + if (expression.hasEffectsOnInteractionAtPath(path, interaction, context)) return true; } return false; } - - include(context: InclusionContext, includeChildrenRecursively: IncludeChildren): void { - // This is only relevant to include values that do not have an AST representation, - // such as UnknownArrayExpression. Thus we only need to include them once. - for (const expression of this.expressions) { - if (!expression.included) { - expression.include(context, includeChildrenRecursively); - } - } - } - - includeCallArguments(): void {} - - mayModifyThisWhenCalledAtPath(path: ObjectPath, recursionTracker: PathTracker) { - return this.expressions.some(e => e.mayModifyThisWhenCalledAtPath(path, recursionTracker)); - } } diff --git a/src/ast/nodes/shared/Node.ts b/src/ast/nodes/shared/Node.ts index 26fa04daf55..a56512f0b70 100644 --- a/src/ast/nodes/shared/Node.ts +++ b/src/ast/nodes/shared/Node.ts @@ -1,274 +1,346 @@ -import * as acorn from 'acorn'; -import { locate } from 'locate-character'; -import MagicString from 'magic-string'; -import { AstContext } from '../../../Module'; -import { NodeRenderOptions, RenderOptions } from '../../../utils/renderHelpers'; -import { CallOptions } from '../../CallOptions'; -import { DeoptimizableEntity } from '../../DeoptimizableEntity'; -import { Entity } from '../../Entity'; +import { locate, type Location } from 'locate-character'; +import type MagicString from 'magic-string'; +import type { AstContext } from '../../../Module'; +import type { AstNode } from '../../../rollup/types'; +import type { RollupAnnotation } from '../../../utils/astConverterHelpers'; +import { ANNOTATION_KEY, INVALID_ANNOTATION_KEY } from '../../../utils/astConverterHelpers'; +import type { NodeRenderOptions, RenderOptions } from '../../../utils/renderHelpers'; +import { childNodeKeys } from '../../childNodeKeys'; +import type { DeoptimizableEntity } from '../../DeoptimizableEntity'; +import type { Entity } from '../../Entity'; import { createHasEffectsContext, - HasEffectsContext, - InclusionContext + type HasEffectsContext, + type InclusionContext } from '../../ExecutionContext'; -import { getAndCreateKeys, keys } from '../../keys'; -import ChildScope from '../../scopes/ChildScope'; -import { ObjectPath, PathTracker } from '../../utils/PathTracker'; -import { LiteralValueOrUnknown, UnknownValue, UNKNOWN_EXPRESSION } from '../../values'; -import Variable from '../../variables/Variable'; -import * as NodeType from '../NodeType'; -import SpreadElement from '../SpreadElement'; +import type { NodeInteractionAssigned } from '../../NodeInteractions'; +import { INTERACTION_ASSIGNED } from '../../NodeInteractions'; +import type ChildScope from '../../scopes/ChildScope'; +import { + EMPTY_PATH, + type EntityPathTracker, + type ObjectPath, + UNKNOWN_PATH +} from '../../utils/PathTracker'; +import type Variable from '../../variables/Variable'; +import type * as NodeType from '../NodeType'; +import type Program from '../Program'; +import { Flag, isFlagSet, setFlag } from './BitFlags'; +import type { InclusionOptions, LiteralValueOrUnknown } from './Expression'; import { ExpressionEntity } from './Expression'; -export interface GenericEsTreeNode extends acorn.Node { +// eslint-disable-next-line @typescript-eslint/consistent-indexed-object-style +export interface GenericEsTreeNode extends AstNode { [key: string]: any; } -export const INCLUDE_PARAMETERS: 'variables' = 'variables'; +export const INCLUDE_PARAMETERS = 'variables' as const; export type IncludeChildren = boolean | typeof INCLUDE_PARAMETERS; -export interface Annotation { - comment?: acorn.Comment; - pure?: boolean; -} export interface Node extends Entity { - annotations?: Annotation[]; - context: AstContext; + annotations?: readonly RollupAnnotation[]; end: number; - esTreeNode: GenericEsTreeNode; included: boolean; - keys: string[]; needsBoundaries?: boolean; parent: Node | { type?: string }; + scope: ChildScope; preventChildBlockScope?: boolean; start: number; type: string; variable?: Variable | null; - addExportedVariables(variables: Variable[], exportNamesByVariable: Map): void; + addExportedVariables( + variables: readonly Variable[], + exportNamesByVariable: ReadonlyMap + ): void; /** - * Called once all nodes have been initialised and the scopes have been populated. + * Called once all nodes have been initialised and the scopes have been + * populated. */ bind(): void; /** - * Determine if this Node would have an effect on the bundle. - * This is usually true for already included nodes. Exceptions are e.g. break statements - * which only have an effect if their surrounding loop or switch statement is included. + * Determine if this Node would have an effect on the bundle. This is usually + * true for already included nodes. Exceptions are e.g. break statements which + * only have an effect if their surrounding loop or switch statement is + * included. * The options pass on information like this about the current execution path. */ hasEffects(context: HasEffectsContext): boolean; /** - * Includes the node in the bundle. If the flag is not set, children are usually included - * if they are necessary for this node (e.g. a function body) or if they have effects. - * Necessary variables need to be included as well. + * Special version of hasEffects for assignment left-hand sides which ensures + * that accessor effects are checked as well. This is necessary to do from the + * child so that member expressions can use the correct this value. + * setAssignedValue needs to be called during initialise to use this. + */ + hasEffectsAsAssignmentTarget(context: HasEffectsContext, checkAccess: boolean): boolean; + + /** + * Includes the node in the bundle. If the flag is not set, children are + * usually included if they are necessary for this node (e.g. a function body) + * or if they have effects. Necessary variables need to be included as well. + * This is called repeatedly for each tree-shaking pass. + */ + include( + context: InclusionContext, + includeChildrenRecursively: IncludeChildren, + options?: InclusionOptions + ): void; + + /** + * Includes this node for the first time in the bundle and ensures that all + * paths that this node relies on are included as well. Does not include + * child nodes by default, though. */ - include(context: InclusionContext, includeChildrenRecursively: IncludeChildren): void; + includeNode(context: InclusionContext): void; /** - * Alternative version of include to override the default behaviour of - * declarations to not include the id by default if the declarator has an effect. + * Explicitly include a path of this Node. */ - includeAsSingleStatement( + includePath(path: ObjectPath, context: InclusionContext): void; + + /** + * Special version of include for assignment left-hand sides which ensures + * that accessors are handled correctly. This is necessary to do from the + * child so that member expressions can use the correct this value. + * setAssignedValue needs to be called during initialise to use this. + */ + includeAsAssignmentTarget( context: InclusionContext, - includeChildrenRecursively: IncludeChildren + includeChildrenRecursively: IncludeChildren, + deoptimizeAccess: boolean ): void; + removeAnnotations(code: MagicString): void; + render(code: MagicString, options: RenderOptions, nodeRenderOptions?: NodeRenderOptions): void; /** - * Start a new execution path to determine if this node has an effect on the bundle and - * should therefore be included. Included nodes should always be included again in subsequent - * visits as the inclusion of additional variables may require the inclusion of more child - * nodes in e.g. block statements. + * Sets the assigned value e.g. for assignment expression left. This must be + * called during initialise in case hasEffects/includeAsAssignmentTarget are + * used. + */ + setAssignedValue(value: ExpressionEntity): void; + + /** + * Start a new execution path to determine if this node has an effect on the + * bundle and should therefore be included. Included nodes should always be + * included again in subsequent visits as the inclusion of additional + * variables may require the inclusion of more child nodes in e.g. block + * statements. */ shouldBeIncluded(context: InclusionContext): boolean; } -export interface StatementNode extends Node {} +export type StatementNode = Node; + +export const IS_SKIPPED_CHAIN = Symbol('IS_SKIPPED_CHAIN'); +export type SkippedChain = typeof IS_SKIPPED_CHAIN; + +export interface ExpressionNode extends ExpressionEntity, Node, Partial {} -export interface ExpressionNode extends ExpressionEntity, Node {} +export interface ChainElement { + getLiteralValueAtPathAsChainElement( + path: ObjectPath, + recursionTracker: EntityPathTracker, + origin: DeoptimizableEntity + ): LiteralValueOrUnknown | SkippedChain; + hasEffectsAsChainElement(context: HasEffectsContext): boolean | SkippedChain; +} -export class NodeBase implements ExpressionNode { - annotations?: Annotation[]; - context: AstContext; - end!: number; - esTreeNode: acorn.Node; - included = false; - keys: string[]; +export class NodeBase extends ExpressionEntity implements ExpressionNode { + declare annotations?: readonly RollupAnnotation[]; + declare end: number; parent: Node | { context: AstContext; type: string }; - scope!: ChildScope; - start!: number; - type!: keyof typeof NodeType; - - constructor( - esTreeNode: GenericEsTreeNode, - parent: Node | { context: AstContext; type: string }, - parentScope: ChildScope - ) { - this.esTreeNode = esTreeNode; - this.keys = keys[esTreeNode.type] || getAndCreateKeys(esTreeNode); + declare scope: ChildScope; + declare start: number; + declare type: keyof typeof NodeType; + /** + * This will be populated during initialise if setAssignedValue is called. + */ + declare protected assignmentInteraction: NodeInteractionAssigned; + + /** + * Nodes can apply custom deoptimizations once they become part of the + * executed code. To do this, they must initialize this as false, implement + * applyDeoptimizations and call this from include and hasEffects if they have + * custom handlers + */ + protected get deoptimized(): boolean { + return isFlagSet(this.flags, Flag.deoptimized); + } + + protected set deoptimized(value: boolean) { + this.flags = setFlag(this.flags, Flag.deoptimized, value); + } + + constructor(parent: Node | { context: AstContext; type: string }, parentScope: ChildScope) { + super(); this.parent = parent; - this.context = parent.context; + this.scope = parentScope; this.createScope(parentScope); - this.parseNode(esTreeNode); - this.initialise(); - this.context.magicString.addSourcemapLocation(this.start); - this.context.magicString.addSourcemapLocation(this.end); } addExportedVariables( - _variables: Variable[], - _exportNamesByVariable: Map + _variables: readonly Variable[], + _exportNamesByVariable: ReadonlyMap ): void {} /** - * Override this to bind assignments to variables and do any initialisations that - * require the scopes to be populated with variables. + * Override this to bind assignments to variables and do any initialisations + * that require the scopes to be populated with variables. */ - bind() { - for (const key of this.keys) { + bind(): void { + for (const key of childNodeKeys[this.type]) { const value = (this as GenericEsTreeNode)[key]; - if (value === null) continue; if (Array.isArray(value)) { for (const child of value) { - if (child !== null) child.bind(); + child?.bind(); } - } else { + } else if (value) { value.bind(); } } } /** - * Override if this node should receive a different scope than the parent scope. + * Override if this node should receive a different scope than the parent + * scope. */ - createScope(parentScope: ChildScope) { + createScope(parentScope: ChildScope): void { this.scope = parentScope; } - deoptimizePath(_path: ObjectPath) {} - - getLiteralValueAtPath( - _path: ObjectPath, - _recursionTracker: PathTracker, - _origin: DeoptimizableEntity - ): LiteralValueOrUnknown { - return UnknownValue; - } - - getReturnExpressionWhenCalledAtPath( - _path: ObjectPath, - _recursionTracker: PathTracker, - _origin: DeoptimizableEntity - ): ExpressionEntity { - return UNKNOWN_EXPRESSION; - } - hasEffects(context: HasEffectsContext): boolean { - for (const key of this.keys) { + if (!this.deoptimized) this.applyDeoptimizations(); + for (const key of childNodeKeys[this.type]) { const value = (this as GenericEsTreeNode)[key]; if (value === null) continue; if (Array.isArray(value)) { for (const child of value) { - if (child !== null && child.hasEffects(context)) return true; + if (child?.hasEffects(context)) return true; } } else if (value.hasEffects(context)) return true; } return false; } - hasEffectsWhenAccessedAtPath(path: ObjectPath, _context: HasEffectsContext) { - return path.length > 0; - } - - hasEffectsWhenAssignedAtPath(_path: ObjectPath, _context: HasEffectsContext) { - return true; + hasEffectsAsAssignmentTarget(context: HasEffectsContext, _checkAccess: boolean): boolean { + return ( + this.hasEffects(context) || + this.hasEffectsOnInteractionAtPath(EMPTY_PATH, this.assignmentInteraction, context) + ); } - hasEffectsWhenCalledAtPath( - _path: ObjectPath, - _callOptions: CallOptions, - _context: HasEffectsContext - ) { - return true; + include( + context: InclusionContext, + includeChildrenRecursively: IncludeChildren, + _options?: InclusionOptions + ): void { + if (!this.included) this.includeNode(context); + for (const key of childNodeKeys[this.type]) { + const value = (this as GenericEsTreeNode)[key]; + if (value === null) continue; + if (Array.isArray(value)) { + for (const child of value) { + child?.include(context, includeChildrenRecursively); + } + } else { + value.include(context, includeChildrenRecursively); + } + } } - include(context: InclusionContext, includeChildrenRecursively: IncludeChildren) { + includeNode(context: InclusionContext) { this.included = true; - for (const key of this.keys) { + if (!this.deoptimized) this.applyDeoptimizations(); + for (const key of childNodeKeys[this.type]) { const value = (this as GenericEsTreeNode)[key]; if (value === null) continue; if (Array.isArray(value)) { for (const child of value) { - if (child !== null) child.include(context, includeChildrenRecursively); + child?.includePath(UNKNOWN_PATH, context); } } else { - value.include(context, includeChildrenRecursively); + value.includePath(UNKNOWN_PATH, context); } } } - includeAsSingleStatement(context: InclusionContext, includeChildrenRecursively: IncludeChildren) { + includeAsAssignmentTarget( + context: InclusionContext, + includeChildrenRecursively: IncludeChildren, + _deoptimizeAccess: boolean + ) { this.include(context, includeChildrenRecursively); } - includeCallArguments(context: InclusionContext, args: (ExpressionNode | SpreadElement)[]): void { - for (const arg of args) { - arg.include(context, false); - } - } - /** - * Override to perform special initialisation steps after the scope is initialised + * Override to perform special initialisation steps after the scope is + * initialised */ - initialise() {} - - insertSemicolon(code: MagicString) { - if (code.original[this.end - 1] !== ';') { - code.appendLeft(this.end, ';'); - } - } - - mayModifyThisWhenCalledAtPath(_path: ObjectPath, _recursionTracker: PathTracker) { - return true; + initialise(): void { + this.scope.context.magicString.addSourcemapLocation(this.start); + this.scope.context.magicString.addSourcemapLocation(this.end); } - parseNode(esTreeNode: GenericEsTreeNode) { - for (const key of Object.keys(esTreeNode)) { - // That way, we can override this function to add custom initialisation and then call super.parseNode + parseNode(esTreeNode: GenericEsTreeNode): this { + for (const [key, value] of Object.entries(esTreeNode)) { + // Skip properties defined on the class already. + // This way, we can override this function to add custom initialisation and then call super.parseNode + // Note: this doesn't skip properties with defined getters/setters which we use to pack wrap booleans + // in bitfields. Those are still assigned from the value in the esTreeNode. if (this.hasOwnProperty(key)) continue; - const value = esTreeNode[key]; - if (key === '_rollupAnnotations') { - this.annotations = value; + + if (key.charCodeAt(0) === 95 /* _ */) { + if (key === ANNOTATION_KEY) { + this.annotations = value as RollupAnnotation[]; + } else if (key === INVALID_ANNOTATION_KEY) { + (this as unknown as Program).invalidAnnotations = value as RollupAnnotation[]; + } } else if (typeof value !== 'object' || value === null) { (this as GenericEsTreeNode)[key] = value; } else if (Array.isArray(value)) { - (this as GenericEsTreeNode)[key] = []; + (this as GenericEsTreeNode)[key] = new Array(value.length); + let index = 0; for (const child of value) { - (this as GenericEsTreeNode)[key].push( + (this as GenericEsTreeNode)[key][index++] = child === null ? null - : new (this.context.nodeConstructors[child.type] || - this.context.nodeConstructors.UnknownNode)(child, this, this.scope) - ); + : new (this.scope.context.getNodeConstructor(child.type))(this, this.scope).parseNode( + child + ); } } else { - (this as GenericEsTreeNode)[key] = new (this.context.nodeConstructors[value.type] || - this.context.nodeConstructors.UnknownNode)(value, this, this.scope); + (this as GenericEsTreeNode)[key] = new (this.scope.context.getNodeConstructor(value.type))( + this, + this.scope + ).parseNode(value); + } + } + // extend child keys for unknown node types + childNodeKeys[esTreeNode.type] ||= createChildNodeKeysForNode(esTreeNode); + this.initialise(); + return this; + } + + removeAnnotations(code: MagicString): void { + if (this.annotations) { + for (const annotation of this.annotations) { + code.remove(annotation.start, annotation.end); } } } - render(code: MagicString, options: RenderOptions) { - for (const key of this.keys) { + render(code: MagicString, options: RenderOptions): void { + for (const key of childNodeKeys[this.type]) { const value = (this as GenericEsTreeNode)[key]; if (value === null) continue; if (Array.isArray(value)) { for (const child of value) { - if (child !== null) child.render(code, options); + child?.render(code, options); } } else { value.render(code, options); @@ -276,22 +348,76 @@ export class NodeBase implements ExpressionNode { } } + setAssignedValue(value: ExpressionEntity): void { + this.assignmentInteraction = { args: [null, value], type: INTERACTION_ASSIGNED }; + } + shouldBeIncluded(context: InclusionContext): boolean { return this.included || (!context.brokenFlow && this.hasEffects(createHasEffectsContext())); } + + /** + * Just deoptimize everything by default so that when e.g. we do not track + * something properly, it is deoptimized. + * @protected + */ + applyDeoptimizations() { + this.deoptimized = true; + for (const key of childNodeKeys[this.type]) { + const value = (this as GenericEsTreeNode)[key]; + if (value === null) continue; + if (Array.isArray(value)) { + for (const child of value) { + child?.deoptimizePath(UNKNOWN_PATH); + } + } else { + value.deoptimizePath(UNKNOWN_PATH); + } + } + this.scope.context.requestTreeshakingPass(); + } } export { NodeBase as StatementBase }; -// useful for debugging -export function locateNode(node: Node) { - const location = locate(node.context.code, node.start, { offsetLine: 1 }); - (location as any).file = node.context.fileName; +function createChildNodeKeysForNode(esTreeNode: GenericEsTreeNode): string[] { + return Object.keys(esTreeNode).filter( + key => typeof esTreeNode[key] === 'object' && key.charCodeAt(0) !== 95 /* _ */ + ); +} + +export function locateNode(node: Node): Location & { file: string } { + const { + start, + scope: { + context: { code, fileName } + } + } = node; + const location = locate(code, start, { offsetLine: 1 }) as Location & { + file: string; + }; + location.file = fileName; location.toString = () => JSON.stringify(location); return location; } -export function logNode(node: Node) { - return node.context.code.slice(node.start, node.end); +export function logNode(node: Node | ExpressionEntity): string { + if ('scope' in node) { + return node.scope.context.code.slice(node.start, node.end); + } + return node.constructor.name; +} + +export function onlyIncludeSelf(this: NodeBase) { + this.included = true; + if (!this.deoptimized) this.applyDeoptimizations(); +} + +export function onlyIncludeSelfNoDeoptimize(this: NodeBase) { + this.included = true; +} + +export function doNotDeoptimize(this: NodeBase) { + this.deoptimized = true; } diff --git a/src/ast/nodes/shared/ObjectEntity.ts b/src/ast/nodes/shared/ObjectEntity.ts new file mode 100644 index 00000000000..24d06bc1298 --- /dev/null +++ b/src/ast/nodes/shared/ObjectEntity.ts @@ -0,0 +1,529 @@ +import type { DeoptimizableEntity } from '../../DeoptimizableEntity'; +import type { HasEffectsContext, InclusionContext } from '../../ExecutionContext'; +import type { NodeInteraction, NodeInteractionCalled } from '../../NodeInteractions'; +import { INTERACTION_ACCESSED, INTERACTION_CALLED } from '../../NodeInteractions'; +import type { + ConcreteKey, + EntityPathTracker, + ObjectPath, + ObjectPathKey +} from '../../utils/PathTracker'; +import { + isAnyWellKnown, + isConcreteKey, + TREE_SHAKEABLE_SYMBOLS, + UNKNOWN_INTEGER_PATH, + UNKNOWN_PATH, + UnknownInteger, + UnknownKey, + UnknownNonAccessorKey, + UnknownWellKnown +} from '../../utils/PathTracker'; +import { Flag, isFlagSet, setFlag } from './BitFlags'; +import type { LiteralValueOrUnknown } from './Expression'; +import { + deoptimizeInteraction, + ExpressionEntity, + UNKNOWN_EXPRESSION, + UNKNOWN_RETURN_EXPRESSION, + UnknownValue +} from './Expression'; +import type { IncludeChildren } from './Node'; + +export interface ObjectProperty { + key: ObjectPathKey; + kind: 'init' | 'set' | 'get'; + property: ExpressionEntity; +} + +export type PropertyMap = Map; +const INTEGER_REG_EXP = /^\d+$/; + +export class ObjectEntity extends ExpressionEntity { + private get hasLostTrack(): boolean { + return isFlagSet(this.flags, Flag.hasLostTrack); + } + private set hasLostTrack(value: boolean) { + this.flags = setFlag(this.flags, Flag.hasLostTrack, value); + } + + private get hasUnknownDeoptimizedInteger(): boolean { + return isFlagSet(this.flags, Flag.hasUnknownDeoptimizedInteger); + } + private set hasUnknownDeoptimizedInteger(value: boolean) { + this.flags = setFlag(this.flags, Flag.hasUnknownDeoptimizedInteger, value); + } + + private get hasUnknownDeoptimizedProperty(): boolean { + return isFlagSet(this.flags, Flag.hasUnknownDeoptimizedProperty); + } + private set hasUnknownDeoptimizedProperty(value: boolean) { + this.flags = setFlag(this.flags, Flag.hasUnknownDeoptimizedProperty, value); + } + + private readonly additionalExpressionsToBeDeoptimized = new Set(); + private readonly allProperties: ExpressionEntity[] = []; + private readonly alwaysIncludedProperties = new Set(); + private readonly deoptimizedPaths = new Map(); + private readonly expressionsToBeDeoptimizedByKey = new Map(); + private readonly gettersByKey: PropertyMap = new Map(); + + private readonly propertiesAndGettersByKey: PropertyMap = new Map(); + private readonly propertiesAndSettersByKey: PropertyMap = new Map(); + private readonly settersByKey: PropertyMap = new Map(); + private readonly unknownIntegerProps: ExpressionEntity[] = []; + private readonly unmatchableGetters: ExpressionEntity[] = []; + private readonly unmatchablePropertiesAndGetters: ExpressionEntity[] = []; + private readonly unmatchablePropertiesAndSetters: ExpressionEntity[] = []; + private readonly unmatchableSetters: ExpressionEntity[] = []; + + // If a PropertyMap is used, this will be taken as propertiesAndGettersByKey + // and we assume there are no setters or getters + constructor( + properties: ObjectProperty[] | PropertyMap, + private prototypeExpression: ExpressionEntity | null, + private immutable = false + ) { + super(); + if (Array.isArray(properties)) { + this.buildPropertyMaps(properties); + } else { + this.propertiesAndGettersByKey = this.propertiesAndSettersByKey = properties; + for (const propertiesForKey of properties.values()) { + this.allProperties.push(...propertiesForKey); + } + } + } + + deoptimizeAllProperties(noAccessors?: boolean): void { + const isDeoptimized = this.hasLostTrack || this.hasUnknownDeoptimizedProperty; + if (noAccessors) { + this.hasUnknownDeoptimizedProperty = true; + } else { + this.hasLostTrack = true; + } + if (isDeoptimized) { + return; + } + for (const properties of [ + ...this.propertiesAndGettersByKey.values(), + ...this.settersByKey.values() + ]) { + for (const property of properties) { + property.deoptimizePath(UNKNOWN_PATH); + } + } + // While the prototype itself cannot be mutated, each property can + this.prototypeExpression?.deoptimizePath([UnknownKey, UnknownKey]); + this.deoptimizeCachedEntities(); + } + + deoptimizeArgumentsOnInteractionAtPath( + interaction: NodeInteraction, + path: ObjectPath, + recursionTracker: EntityPathTracker + ): void { + const [key, ...subPath] = path; + const { args, type } = interaction; + + if ( + this.hasLostTrack || + // single paths that are deoptimized will not become getters or setters + ((type === INTERACTION_CALLED || path.length > 1) && + (this.hasUnknownDeoptimizedProperty || + (isConcreteKey(key) && this.deoptimizedPaths.get(key)))) + ) { + deoptimizeInteraction(interaction); + return; + } + + const [propertiesForExactMatchByKey, relevantPropertiesByKey, relevantUnmatchableProperties] = + type === INTERACTION_CALLED || path.length > 1 + ? [ + this.propertiesAndGettersByKey, + this.propertiesAndGettersByKey, + this.unmatchablePropertiesAndGetters + ] + : type === INTERACTION_ACCESSED + ? [this.propertiesAndGettersByKey, this.gettersByKey, this.unmatchableGetters] + : [this.propertiesAndSettersByKey, this.settersByKey, this.unmatchableSetters]; + + if (isConcreteKey(key)) { + if (propertiesForExactMatchByKey.get(key)) { + const properties = relevantPropertiesByKey.get(key); + if (properties) { + for (const property of properties) { + property.deoptimizeArgumentsOnInteractionAtPath(interaction, subPath, recursionTracker); + } + } + if (!this.immutable) { + for (const argument of args) { + if (argument) { + this.additionalExpressionsToBeDeoptimized.add(argument); + } + } + } + return; + } + for (const property of relevantUnmatchableProperties) { + property.deoptimizeArgumentsOnInteractionAtPath(interaction, subPath, recursionTracker); + } + if (typeof key === 'string' && INTEGER_REG_EXP.test(key)) { + for (const property of this.unknownIntegerProps) { + property.deoptimizeArgumentsOnInteractionAtPath(interaction, subPath, recursionTracker); + } + } + } else { + for (const properties of [ + ...relevantPropertiesByKey.values(), + relevantUnmatchableProperties + ]) { + for (const property of properties) { + property.deoptimizeArgumentsOnInteractionAtPath(interaction, subPath, recursionTracker); + } + } + for (const property of this.unknownIntegerProps) { + property.deoptimizeArgumentsOnInteractionAtPath(interaction, subPath, recursionTracker); + } + } + if (!this.immutable) { + for (const argument of args) { + if (argument) { + this.additionalExpressionsToBeDeoptimized.add(argument); + } + } + } + this.prototypeExpression?.deoptimizeArgumentsOnInteractionAtPath( + interaction, + path, + recursionTracker + ); + } + + deoptimizeIntegerProperties(): void { + if ( + this.hasLostTrack || + this.hasUnknownDeoptimizedProperty || + this.hasUnknownDeoptimizedInteger + ) { + return; + } + this.hasUnknownDeoptimizedInteger = true; + // Omits symbol keys but that's unimportant here + for (const [key, propertiesAndGetters] of this.propertiesAndGettersByKey.entries()) { + if (typeof key === 'string' && INTEGER_REG_EXP.test(key)) { + for (const property of propertiesAndGetters) { + property.deoptimizePath(UNKNOWN_PATH); + } + } + } + this.deoptimizeCachedIntegerEntities(); + } + + // Assumption: If only a specific path is deoptimized, no accessors are created + deoptimizePath(path: ObjectPath): void { + if (this.hasLostTrack || this.immutable) { + return; + } + const key = path[0]; + if (path.length === 1) { + if (key === UnknownInteger) { + return this.deoptimizeIntegerProperties(); + } else if (!isConcreteKey(key)) { + return this.deoptimizeAllProperties(key === UnknownNonAccessorKey); + } + if (!this.deoptimizedPaths.get(key)) { + this.deoptimizedPaths.set(key, true); + + // we only deoptimizeCache exact matches as in all other cases, + // we do not return a literal value or return expression + const expressionsToBeDeoptimized = this.expressionsToBeDeoptimizedByKey.get(key); + if (expressionsToBeDeoptimized) { + for (const expression of expressionsToBeDeoptimized) { + expression.deoptimizeCache(); + } + } + } + } + + const subPath = path.length === 1 ? UNKNOWN_PATH : path.slice(1); + for (const property of isConcreteKey(key) + ? [ + ...(this.propertiesAndGettersByKey.get(key) || this.unmatchablePropertiesAndGetters), + ...(this.settersByKey.get(key) || this.unmatchableSetters) + ] + : this.allProperties) { + property.deoptimizePath(subPath); + } + this.prototypeExpression?.deoptimizePath(path.length === 1 ? [path[0], UnknownKey] : path); + } + + getLiteralValueAtPath( + path: ObjectPath, + recursionTracker: EntityPathTracker, + origin: DeoptimizableEntity + ): LiteralValueOrUnknown { + if (path.length === 0) { + // This should actually be "UnknownTruthyValue". However, this currently + // causes an issue with TypeScript enums in files with moduleSideEffects: + // false because we cannot properly track whether a "var" has been + // initialized. This should be reverted once we can properly track this. + // return UnknownTruthyValue; + return UnknownValue; + } + const key = path[0]; + const expressionAtPath = this.getMemberExpressionAndTrackDeopt(key, origin); + if (expressionAtPath) { + return expressionAtPath.getLiteralValueAtPath(path.slice(1), recursionTracker, origin); + } + if (this.prototypeExpression) { + return this.prototypeExpression.getLiteralValueAtPath(path, recursionTracker, origin); + } + if (path.length === 1) { + return undefined; + } + return UnknownValue; + } + + getReturnExpressionWhenCalledAtPath( + path: ObjectPath, + interaction: NodeInteractionCalled, + recursionTracker: EntityPathTracker, + origin: DeoptimizableEntity + ): [expression: ExpressionEntity, isPure: boolean] { + if (path.length === 0) { + return UNKNOWN_RETURN_EXPRESSION; + } + const [key, ...subPath] = path; + const expressionAtPath = this.getMemberExpressionAndTrackDeopt(key, origin); + if (expressionAtPath) { + return expressionAtPath.getReturnExpressionWhenCalledAtPath( + subPath, + interaction, + recursionTracker, + origin + ); + } + if (this.prototypeExpression) { + return this.prototypeExpression.getReturnExpressionWhenCalledAtPath( + path, + interaction, + recursionTracker, + origin + ); + } + return UNKNOWN_RETURN_EXPRESSION; + } + + hasEffectsOnInteractionAtPath( + path: ObjectPath, + interaction: NodeInteraction, + context: HasEffectsContext + ): boolean { + const [key, ...subPath] = path; + if (subPath.length > 0 || interaction.type === INTERACTION_CALLED) { + const expressionAtPath = this.getMemberExpression(key); + if (expressionAtPath) { + return expressionAtPath.hasEffectsOnInteractionAtPath(subPath, interaction, context); + } + if (this.prototypeExpression) { + return this.prototypeExpression.hasEffectsOnInteractionAtPath(path, interaction, context); + } + return true; + } + if (key === UnknownNonAccessorKey) return false; + if (this.hasLostTrack) return true; + const [propertiesAndAccessorsByKey, accessorsByKey, unmatchableAccessors] = + interaction.type === INTERACTION_ACCESSED + ? [this.propertiesAndGettersByKey, this.gettersByKey, this.unmatchableGetters] + : [this.propertiesAndSettersByKey, this.settersByKey, this.unmatchableSetters]; + if (isConcreteKey(key)) { + if (propertiesAndAccessorsByKey.get(key)) { + const accessors = accessorsByKey.get(key); + if (accessors) { + for (const accessor of accessors) { + if (accessor.hasEffectsOnInteractionAtPath(subPath, interaction, context)) return true; + } + } + return false; + } + for (const accessor of unmatchableAccessors) { + if (accessor.hasEffectsOnInteractionAtPath(subPath, interaction, context)) { + return true; + } + } + } else { + for (const accessors of [...accessorsByKey.values(), unmatchableAccessors]) { + for (const accessor of accessors) { + if (accessor.hasEffectsOnInteractionAtPath(subPath, interaction, context)) return true; + } + } + } + if (this.prototypeExpression) { + return this.prototypeExpression.hasEffectsOnInteractionAtPath(path, interaction, context); + } + return false; + } + + include(context: InclusionContext, includeChildrenRecursively: IncludeChildren) { + this.included = true; + for (const property of this.allProperties) { + if ( + includeChildrenRecursively || + property.shouldBeIncluded(context) || + this.alwaysIncludedProperties.has(property) + ) { + property.include(context, includeChildrenRecursively); + } + } + this.prototypeExpression?.include(context, includeChildrenRecursively); + } + + includePath(path: ObjectPath, context: InclusionContext) { + this.included = true; + for (const property of this.alwaysIncludedProperties) { + property.includePath(UNKNOWN_PATH, context); + } + + if (path.length === 0) return; + const [key, ...subPath] = path; + const [includedMembers, includedPath] = isConcreteKey(key) + ? [ + new Set([ + ...(this.propertiesAndGettersByKey.get(key) || this.unmatchablePropertiesAndGetters), + ...(this.propertiesAndSettersByKey.get(key) || this.unmatchablePropertiesAndSetters) + ]), + subPath + ] + : [this.allProperties, UNKNOWN_PATH]; + for (const property of includedMembers) { + property.includePath(includedPath, context); + } + this.prototypeExpression?.includePath(path, context); + } + + private buildPropertyMaps(properties: readonly ObjectProperty[]): void { + const { + allProperties, + alwaysIncludedProperties, + propertiesAndGettersByKey, + propertiesAndSettersByKey, + settersByKey, + gettersByKey, + unknownIntegerProps, + unmatchablePropertiesAndGetters, + unmatchablePropertiesAndSetters, + unmatchableGetters, + unmatchableSetters + } = this; + for (let index = properties.length - 1; index >= 0; index--) { + const { key, kind, property } = properties[index]; + allProperties.push(property); + if (isAnyWellKnown(key) && !TREE_SHAKEABLE_SYMBOLS.has(key)) { + // Never treeshake well-known symbols (unless Rollup can optimize them) + // They are most likely called implicitly by language semantics, don't get rid of them + alwaysIncludedProperties.add(property); + if (key === UnknownWellKnown) continue; + } + + if (isConcreteKey(key)) { + if (kind === 'set') { + if (!propertiesAndSettersByKey.has(key)) { + propertiesAndSettersByKey.set(key, [property, ...unmatchablePropertiesAndSetters]); + settersByKey.set(key, [property, ...unmatchableSetters]); + } + } else if (kind === 'get') { + if (!propertiesAndGettersByKey.has(key)) { + propertiesAndGettersByKey.set(key, [property, ...unmatchablePropertiesAndGetters]); + gettersByKey.set(key, [property, ...unmatchableGetters]); + } + } else { + if (!propertiesAndSettersByKey.has(key)) { + propertiesAndSettersByKey.set(key, [property, ...unmatchablePropertiesAndSetters]); + } + if (!propertiesAndGettersByKey.has(key)) { + propertiesAndGettersByKey.set(key, [property, ...unmatchablePropertiesAndGetters]); + } + } + } else { + if (key === UnknownInteger) { + unknownIntegerProps.push(property); + continue; + } + if (kind === 'set') unmatchableSetters.push(property); + if (kind === 'get') unmatchableGetters.push(property); + if (kind !== 'get') unmatchablePropertiesAndSetters.push(property); + if (kind !== 'set') unmatchablePropertiesAndGetters.push(property); + } + } + } + + private deoptimizeCachedEntities() { + for (const expressionsToBeDeoptimized of this.expressionsToBeDeoptimizedByKey.values()) { + for (const expression of expressionsToBeDeoptimized) { + expression.deoptimizeCache(); + } + } + for (const expression of this.additionalExpressionsToBeDeoptimized) { + expression.deoptimizePath(UNKNOWN_PATH); + } + } + + private deoptimizeCachedIntegerEntities() { + for (const [ + key, + expressionsToBeDeoptimized + ] of this.expressionsToBeDeoptimizedByKey.entries()) { + if (typeof key === 'string' && INTEGER_REG_EXP.test(key)) { + for (const expression of expressionsToBeDeoptimized) { + expression.deoptimizeCache(); + } + } + } + for (const expression of this.additionalExpressionsToBeDeoptimized) { + expression.deoptimizePath(UNKNOWN_INTEGER_PATH); + } + } + + private getMemberExpression(key: ObjectPathKey): ExpressionEntity | null { + if ( + this.hasLostTrack || + this.hasUnknownDeoptimizedProperty || + !isConcreteKey(key) || + (this.hasUnknownDeoptimizedInteger && typeof key === 'string' && INTEGER_REG_EXP.test(key)) || + this.deoptimizedPaths.get(key) + ) { + return UNKNOWN_EXPRESSION; + } + const properties = this.propertiesAndGettersByKey.get(key); + if (properties?.length === 1) { + return properties[0]; + } + if ( + properties || + this.unmatchablePropertiesAndGetters.length > 0 || + (this.unknownIntegerProps.length > 0 && typeof key === 'string' && INTEGER_REG_EXP.test(key)) + ) { + return UNKNOWN_EXPRESSION; + } + return null; + } + + private getMemberExpressionAndTrackDeopt( + key: ObjectPathKey, + origin: DeoptimizableEntity + ): ExpressionEntity | null { + if (!isConcreteKey(key)) { + return UNKNOWN_EXPRESSION; + } + const expression = this.getMemberExpression(key); + if (!(expression === UNKNOWN_EXPRESSION || this.immutable)) { + let expressionsToBeDeoptimized = this.expressionsToBeDeoptimizedByKey.get(key); + if (!expressionsToBeDeoptimized) { + this.expressionsToBeDeoptimizedByKey.set(key, (expressionsToBeDeoptimized = [])); + } + expressionsToBeDeoptimized.push(origin); + } + return expression; + } +} diff --git a/src/ast/nodes/shared/ObjectMember.ts b/src/ast/nodes/shared/ObjectMember.ts new file mode 100644 index 00000000000..8bda71fbc9e --- /dev/null +++ b/src/ast/nodes/shared/ObjectMember.ts @@ -0,0 +1,60 @@ +import type { DeoptimizableEntity } from '../../DeoptimizableEntity'; +import type { HasEffectsContext } from '../../ExecutionContext'; +import type { NodeInteraction, NodeInteractionCalled } from '../../NodeInteractions'; +import type { EntityPathTracker, ObjectPath } from '../../utils/PathTracker'; +import { ExpressionEntity, type LiteralValueOrUnknown } from './Expression'; + +export class ObjectMember extends ExpressionEntity { + constructor( + private readonly object: ExpressionEntity, + private readonly path: ObjectPath + ) { + super(); + } + + deoptimizeArgumentsOnInteractionAtPath( + interaction: NodeInteraction, + path: ObjectPath, + recursionTracker: EntityPathTracker + ): void { + this.object.deoptimizeArgumentsOnInteractionAtPath( + interaction, + [...this.path, ...path], + recursionTracker + ); + } + + deoptimizePath(path: ObjectPath): void { + this.object.deoptimizePath([...this.path, ...path]); + } + + getLiteralValueAtPath( + path: ObjectPath, + recursionTracker: EntityPathTracker, + origin: DeoptimizableEntity + ): LiteralValueOrUnknown { + return this.object.getLiteralValueAtPath([...this.path, ...path], recursionTracker, origin); + } + + getReturnExpressionWhenCalledAtPath( + path: ObjectPath, + interaction: NodeInteractionCalled, + recursionTracker: EntityPathTracker, + origin: DeoptimizableEntity + ): [expression: ExpressionEntity, isPure: boolean] { + return this.object.getReturnExpressionWhenCalledAtPath( + [...this.path, ...path], + interaction, + recursionTracker, + origin + ); + } + + hasEffectsOnInteractionAtPath( + path: ObjectPath, + interaction: NodeInteraction, + context: HasEffectsContext + ): boolean { + return this.object.hasEffectsOnInteractionAtPath([...this.path, ...path], interaction, context); + } +} diff --git a/src/ast/nodes/shared/ObjectPrototype.ts b/src/ast/nodes/shared/ObjectPrototype.ts new file mode 100644 index 00000000000..5f1d3474f1a --- /dev/null +++ b/src/ast/nodes/shared/ObjectPrototype.ts @@ -0,0 +1,51 @@ +import type { NodeInteraction } from '../../NodeInteractions'; +import { INTERACTION_CALLED } from '../../NodeInteractions'; +import type { ObjectPath, ObjectPathKey } from '../../utils/PathTracker'; +import type { LiteralValueOrUnknown } from './Expression'; +import { deoptimizeInteraction, ExpressionEntity, UnknownValue } from './Expression'; +import { + METHOD_RETURNS_BOOLEAN, + METHOD_RETURNS_STRING, + METHOD_RETURNS_UNKNOWN +} from './MethodTypes'; +import { ObjectEntity } from './ObjectEntity'; + +const isInteger = (property: ObjectPathKey): boolean => + typeof property === 'string' && /^\d+$/.test(property); + +// This makes sure unknown properties are not handled as "undefined" but as +// "unknown" but without access side effects. An exception is done for numeric +// properties as we do not expect new builtin properties to be numbers, this +// will improve tree-shaking for out-of-bounds array properties +const OBJECT_PROTOTYPE_FALLBACK: ExpressionEntity = + new (class ObjectPrototypeFallbackExpression extends ExpressionEntity { + deoptimizeArgumentsOnInteractionAtPath(interaction: NodeInteraction, path: ObjectPath): void { + if (interaction.type === INTERACTION_CALLED && path.length === 1 && !isInteger(path[0])) { + deoptimizeInteraction(interaction); + } + } + + getLiteralValueAtPath(path: ObjectPath): LiteralValueOrUnknown { + // We ignore number properties as we do not expect new properties to be + // numbers and also want to keep handling out-of-bound array elements as + // "undefined" + return path.length === 1 && isInteger(path[0]) ? undefined : UnknownValue; + } + + hasEffectsOnInteractionAtPath(path: ObjectPath, { type }: NodeInteraction): boolean { + return path.length > 1 || type === INTERACTION_CALLED; + } + })(); + +export const OBJECT_PROTOTYPE = new ObjectEntity( + new Map([ + ['hasOwnProperty', METHOD_RETURNS_BOOLEAN], + ['isPrototypeOf', METHOD_RETURNS_BOOLEAN], + ['propertyIsEnumerable', METHOD_RETURNS_BOOLEAN], + ['toLocaleString', METHOD_RETURNS_STRING], + ['toString', METHOD_RETURNS_STRING], + ['valueOf', METHOD_RETURNS_UNKNOWN] + ]), + OBJECT_PROTOTYPE_FALLBACK, + true +); diff --git a/src/ast/nodes/shared/Pattern.ts b/src/ast/nodes/shared/Pattern.ts index ccca00c9e01..040f5403fe7 100644 --- a/src/ast/nodes/shared/Pattern.ts +++ b/src/ast/nodes/shared/Pattern.ts @@ -1,8 +1,36 @@ -import { WritableEntity } from '../../Entity'; -import LocalVariable from '../../variables/LocalVariable'; -import { ExpressionEntity } from './Expression'; -import { Node } from './Node'; +import type { WritableEntity } from '../../Entity'; +import type { HasEffectsContext, InclusionContext } from '../../ExecutionContext'; +import type { ObjectPath } from '../../utils/PathTracker'; +import type LocalVariable from '../../variables/LocalVariable'; +import type { ExpressionEntity } from './Expression'; +import type { Node } from './Node'; +import type { VariableKind } from './VariableKinds'; export interface PatternNode extends WritableEntity, Node { - declare(kind: string, init: ExpressionEntity | null): LocalVariable[]; + // This should deoptimize both the left-hand and right-hand side + deoptimizeAssignment(destructuredInitPath: ObjectPath, init: ExpressionEntity): void; + + hasEffectsWhenDestructuring( + context: HasEffectsContext, + destructuredInitPath: ObjectPath, + init: ExpressionEntity + ): boolean; + + includeDestructuredIfNecessary( + context: InclusionContext, + destructuredInitPath: ObjectPath, + init: ExpressionEntity + ): boolean; + + includePath(path: ObjectPath, context: InclusionContext): void; +} + +export interface DeclarationPatternNode extends PatternNode { + declare( + kind: VariableKind, + destructuredInitPath: ObjectPath, + init: ExpressionEntity + ): LocalVariable[]; + + markDeclarationReached(): void; } diff --git a/src/ast/nodes/shared/VariableKinds.ts b/src/ast/nodes/shared/VariableKinds.ts new file mode 100644 index 00000000000..e62e171541c --- /dev/null +++ b/src/ast/nodes/shared/VariableKinds.ts @@ -0,0 +1,2 @@ +export type VariableDeclarationKind = 'var' | 'let' | 'const' | 'using' | 'await using'; +export type VariableKind = VariableDeclarationKind | 'function' | 'class' | 'parameter' | 'other'; diff --git a/src/ast/nodes/shared/chainElements.ts b/src/ast/nodes/shared/chainElements.ts new file mode 100644 index 00000000000..390e4029a9f --- /dev/null +++ b/src/ast/nodes/shared/chainElements.ts @@ -0,0 +1,33 @@ +import type { DeoptimizableEntity } from '../../DeoptimizableEntity'; +import type { EntityPathTracker, ObjectPath } from '../../utils/PathTracker'; +import { EMPTY_PATH, SHARED_RECURSION_TRACKER } from '../../utils/PathTracker'; +import type CallExpression from '../CallExpression'; +import type MemberExpression from '../MemberExpression'; +import type { LiteralValueOrUnknown } from './Expression'; +import type { ChainElement, ExpressionNode, SkippedChain } from './Node'; +import { IS_SKIPPED_CHAIN } from './Node'; + +export function getChainElementLiteralValueAtPath( + element: CallExpression | MemberExpression, + object: ExpressionNode, + path: ObjectPath, + recursionTracker: EntityPathTracker, + origin: DeoptimizableEntity +): LiteralValueOrUnknown | SkippedChain { + if ('getLiteralValueAtPathAsChainElement' in object) { + const calleeValue = (object as ChainElement).getLiteralValueAtPathAsChainElement( + EMPTY_PATH, + SHARED_RECURSION_TRACKER, + origin + ); + if (calleeValue === IS_SKIPPED_CHAIN || (element.optional && calleeValue == null)) { + return IS_SKIPPED_CHAIN; + } + } else if ( + element.optional && + object.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, origin) == null + ) { + return IS_SKIPPED_CHAIN; + } + return element.getLiteralValueAtPath(path, recursionTracker, origin); +} diff --git a/src/ast/nodes/shared/jsxHelpers.ts b/src/ast/nodes/shared/jsxHelpers.ts new file mode 100644 index 00000000000..5a840d22d43 --- /dev/null +++ b/src/ast/nodes/shared/jsxHelpers.ts @@ -0,0 +1,55 @@ +import type { InclusionContext } from '../../ExecutionContext'; +import { UNKNOWN_PATH } from '../../utils/PathTracker'; +import LocalVariable from '../../variables/LocalVariable'; +import type Variable from '../../variables/Variable'; +import type JSXElement from '../JSXElement'; +import type JSXExpressionContainer from '../JSXExpressionContainer'; +import type JSXFragment from '../JSXFragment'; +import type JSXOpeningElement from '../JSXOpeningElement'; +import type JSXOpeningFragment from '../JSXOpeningFragment'; +import type JSXSpreadChild from '../JSXSpreadChild'; +import type JSXText from '../JSXText'; +import type JSXElementBase from './JSXElementBase'; + +export type JsxMode = + | { + mode: 'preserve' | 'classic'; + factory: string | null; + importSource: string | null; + } + | { mode: 'automatic'; factory: string; importSource: string }; +export type JSXChild = JSXText | JSXExpressionContainer | JSXElement | JSXFragment | JSXSpreadChild; + +export function getAndIncludeFactoryVariable( + factory: string, + preserve: boolean, + importSource: string | null, + node: JSXElementBase | JSXOpeningElement | JSXOpeningFragment, + context: InclusionContext +): Variable { + const [baseName, nestedName] = factory.split('.'); + let factoryVariable: Variable; + if (importSource) { + factoryVariable = node.scope.context.getImportedJsxFactoryVariable( + nestedName ? 'default' : baseName, + node.start, + importSource + ); + if (preserve) { + // This pretends we are accessing an included global variable of the same name + const globalVariable = node.scope.findGlobal(baseName); + globalVariable.includePath(UNKNOWN_PATH, context); + // This excludes this variable from renaming + factoryVariable.globalName = baseName; + } + } else { + factoryVariable = node.scope.findGlobal(baseName); + } + node.scope.context.includeVariableInModule(factoryVariable, UNKNOWN_PATH, context); + if (factoryVariable instanceof LocalVariable) { + factoryVariable.consolidateInitializers(); + factoryVariable.addUsedPlace(node); + node.scope.context.requestTreeshakingPass(); + } + return factoryVariable; +} diff --git a/src/ast/nodes/shared/knownGlobals.ts b/src/ast/nodes/shared/knownGlobals.ts index be47374f08d..7fe522eaa36 100644 --- a/src/ast/nodes/shared/knownGlobals.ts +++ b/src/ast/nodes/shared/knownGlobals.ts @@ -1,37 +1,135 @@ -import { ObjectPath } from '../../utils/PathTracker'; +/* eslint sort-keys: "off" */ + +import { doNothing } from '../../../utils/doNothing'; +import type { HasEffectsContext } from '../../ExecutionContext'; +import type { NodeInteractionCalled } from '../../NodeInteractions'; +import { + INTERACTION_CALLED, + NODE_INTERACTION_UNKNOWN_ACCESS, + NODE_INTERACTION_UNKNOWN_ASSIGNMENT +} from '../../NodeInteractions'; +import { isObjectExpressionNode, isPropertyNode } from '../../utils/identifyNode'; +import type { ObjectPath, WellKnownSymbol } from '../../utils/PathTracker'; +import { + EMPTY_PATH, + SHARED_RECURSION_TRACKER, + SymbolAsyncDispose, + SymbolDispose, + SymbolHasInstance, + SymbolToStringTag, + UNKNOWN_NON_ACCESSOR_PATH, + UNKNOWN_PATH, + UnknownWellKnown +} from '../../utils/PathTracker'; +import ArrayExpression from '../ArrayExpression'; +import type { LiteralValueOrUnknown } from './Expression'; +import { ExpressionEntity, UnknownValue } from './Expression'; const ValueProperties = Symbol('Value Properties'); interface ValueDescription { - pure: boolean; + deoptimizeArgumentsOnCall(interaction: NodeInteractionCalled): void; + getLiteralValue(): LiteralValueOrUnknown; + hasEffectsWhenCalled(interaction: NodeInteractionCalled, context: HasEffectsContext): boolean; } interface GlobalDescription { + [pathKey: string]: GlobalDescription | null; [ValueProperties]: ValueDescription; - [pathKey: string]: GlobalDescription; + __proto__: null; } -const PURE: ValueDescription = { pure: true }; -const IMPURE: ValueDescription = { pure: false }; +const getUnknownValue = (): LiteralValueOrUnknown => UnknownValue; +const returnFalse = () => false; +const returnTrue = () => true; + +const getWellKnownSymbol = (symbol: WellKnownSymbol) => ({ + __proto__: null, + [ValueProperties]: { + deoptimizeArgumentsOnCall: doNothing, + getLiteralValue: () => symbol, + hasEffectsWhenCalled: returnTrue + } +}); + +const PURE: ValueDescription = { + deoptimizeArgumentsOnCall: doNothing, + getLiteralValue: getUnknownValue, + hasEffectsWhenCalled: returnFalse +}; + +const IMPURE: ValueDescription = { + deoptimizeArgumentsOnCall: doNothing, + getLiteralValue: getUnknownValue, + hasEffectsWhenCalled: returnTrue +}; + +const PURE_WITH_ARRAY: ValueDescription = { + deoptimizeArgumentsOnCall: doNothing, + getLiteralValue: getUnknownValue, + hasEffectsWhenCalled({ args }) { + return args.length > 1 && !(args[1] instanceof ArrayExpression); + } +}; + +const GETTER_ACCESS: ValueDescription = { + deoptimizeArgumentsOnCall: doNothing, + getLiteralValue: getUnknownValue, + hasEffectsWhenCalled({ args }, context) { + const [_thisArgument, firstArgument] = args; + return ( + !(firstArgument instanceof ExpressionEntity) || + firstArgument.hasEffectsOnInteractionAtPath( + UNKNOWN_PATH, + NODE_INTERACTION_UNKNOWN_ACCESS, + context + ) + ); + } +}; // We use shortened variables to reduce file size here /* OBJECT */ const O: GlobalDescription = { - // @ts-ignore __proto__: null, [ValueProperties]: IMPURE }; /* PURE FUNCTION */ const PF: GlobalDescription = { - // @ts-ignore __proto__: null, [ValueProperties]: PURE }; +/* PURE FUNCTION IF FIRST ARG DOES NOT CONTAIN A GETTER */ +const PF_NO_GETTER: GlobalDescription = { + __proto__: null, + [ValueProperties]: GETTER_ACCESS +}; + +/* FUNCTION THAT MUTATES FIRST ARG WITHOUT TRIGGERING ACCESSORS */ +const MUTATES_ARG_WITHOUT_ACCESSOR: GlobalDescription = { + __proto__: null, + [ValueProperties]: { + deoptimizeArgumentsOnCall({ args: [, firstArgument] }: NodeInteractionCalled) { + firstArgument?.deoptimizePath(UNKNOWN_PATH); + }, + getLiteralValue: getUnknownValue, + hasEffectsWhenCalled({ args }, context) { + return ( + args.length <= 1 || + args[1].hasEffectsOnInteractionAtPath( + UNKNOWN_NON_ACCESSOR_PATH, + NODE_INTERACTION_UNKNOWN_ASSIGNMENT, + context + ) + ); + } + } +}; + /* CONSTRUCTOR */ const C: GlobalDescription = { - // @ts-ignore __proto__: null, [ValueProperties]: IMPURE, prototype: O @@ -39,28 +137,37 @@ const C: GlobalDescription = { /* PURE CONSTRUCTOR */ const PC: GlobalDescription = { - // @ts-ignore __proto__: null, [ValueProperties]: PURE, prototype: O }; +const PC_WITH_ARRAY = { + __proto__: null, + [ValueProperties]: PURE_WITH_ARRAY, + prototype: O +}; + const ARRAY_TYPE: GlobalDescription = { - // @ts-ignore __proto__: null, [ValueProperties]: PURE, - from: PF, + from: O, of: PF, prototype: O }; const INTL_MEMBER: GlobalDescription = { - // @ts-ignore __proto__: null, [ValueProperties]: PURE, supportedLocalesOf: PC }; +const UNKNOWN_WELL_KNOWN: ValueDescription = { + deoptimizeArgumentsOnCall: doNothing, + getLiteralValue: () => UnknownWellKnown, + hasEffectsWhenCalled: returnTrue +}; + const knownGlobals: GlobalDescription = { // Placeholders for global objects to avoid shape mutations global: O, @@ -69,11 +176,9 @@ const knownGlobals: GlobalDescription = { window: O, // Common globals - // @ts-ignore __proto__: null, [ValueProperties]: IMPURE, Array: { - // @ts-ignore __proto__: null, [ValueProperties]: IMPURE, from: O, @@ -82,22 +187,20 @@ const knownGlobals: GlobalDescription = { prototype: O }, ArrayBuffer: { - // @ts-ignore __proto__: null, [ValueProperties]: PURE, isView: PF, prototype: O }, + AggregateError: PC_WITH_ARRAY, Atomics: O, BigInt: C, BigInt64Array: C, BigUint64Array: C, Boolean: PC, - // @ts-ignore constructor: C, DataView: PC, Date: { - // @ts-ignore __proto__: null, [ValueProperties]: PURE, now: PF, @@ -113,10 +216,10 @@ const knownGlobals: GlobalDescription = { escape: PF, eval: O, EvalError: PC, + FinalizationRegistry: C, Float32Array: ARRAY_TYPE, Float64Array: ARRAY_TYPE, Function: C, - // @ts-ignore hasOwnProperty: O, Infinity: O, Int16Array: ARRAY_TYPE, @@ -124,12 +227,10 @@ const knownGlobals: GlobalDescription = { Int8Array: ARRAY_TYPE, isFinite: PF, isNaN: PF, - // @ts-ignore isPrototypeOf: O, JSON: O, - Map: PC, + Map: PC_WITH_ARRAY, Math: { - // @ts-ignore __proto__: null, [ValueProperties]: IMPURE, abs: PF, @@ -170,7 +271,6 @@ const knownGlobals: GlobalDescription = { }, NaN: O, Number: { - // @ts-ignore __proto__: null, [ValueProperties]: PURE, isFinite: PF, @@ -182,45 +282,79 @@ const knownGlobals: GlobalDescription = { prototype: O }, Object: { - // @ts-ignore __proto__: null, [ValueProperties]: PURE, create: PF, - getNotifier: PF, - getOwn: PF, + // Technically those can throw in certain situations, but we ignore this as + // code that relies on this will hopefully wrap this in a try-catch, which + // deoptimizes everything anyway + defineProperty: MUTATES_ARG_WITHOUT_ACCESSOR, + defineProperties: MUTATES_ARG_WITHOUT_ACCESSOR, + freeze: MUTATES_ARG_WITHOUT_ACCESSOR, getOwnPropertyDescriptor: PF, + getOwnPropertyDescriptors: PF, getOwnPropertyNames: PF, getOwnPropertySymbols: PF, getPrototypeOf: PF, + hasOwn: PF, is: PF, isExtensible: PF, isFrozen: PF, isSealed: PF, keys: PF, + fromEntries: O, + entries: PF_NO_GETTER, + values: PF_NO_GETTER, prototype: O }, parseFloat: PF, parseInt: PF, Promise: { - // @ts-ignore __proto__: null, [ValueProperties]: IMPURE, - all: PF, + all: O, + allSettled: O, + any: O, prototype: O, - race: PF, - resolve: PF + race: O, + reject: O, + resolve: O }, - // @ts-ignore propertyIsEnumerable: O, - Proxy: O, + Proxy: { + __proto__: null, + [ValueProperties]: { + deoptimizeArgumentsOnCall: ({ args: [, target, parameter] }) => { + if (isObjectExpressionNode(parameter)) { + const hasSpreadElement = parameter.properties.some(property => !isPropertyNode(property)); + if (!hasSpreadElement) { + for (const property of parameter.properties) { + property.deoptimizeArgumentsOnInteractionAtPath( + { + args: [null, target], + type: INTERACTION_CALLED, + withNew: false + }, + EMPTY_PATH, + SHARED_RECURSION_TRACKER + ); + } + return; + } + } + target.deoptimizePath(UNKNOWN_PATH); + }, + getLiteralValue: getUnknownValue, + hasEffectsWhenCalled: returnTrue + } + }, RangeError: PC, ReferenceError: PC, Reflect: O, RegExp: PC, - Set: PC, + Set: PC_WITH_ARRAY, SharedArrayBuffer: C, String: { - // @ts-ignore __proto__: null, [ValueProperties]: PURE, fromCharCode: PF, @@ -229,17 +363,18 @@ const knownGlobals: GlobalDescription = { raw: PF }, Symbol: { - // @ts-ignore __proto__: null, [ValueProperties]: PURE, for: PF, keyFor: PF, - prototype: O + prototype: O, + asyncDispose: getWellKnownSymbol(SymbolAsyncDispose), + dispose: getWellKnownSymbol(SymbolDispose), + hasInstance: getWellKnownSymbol(SymbolHasInstance), + toStringTag: getWellKnownSymbol(SymbolToStringTag) }, SyntaxError: PC, - // @ts-ignore toLocaleString: O, - // @ts-ignore toString: O, TypeError: PC, Uint16Array: ARRAY_TYPE, @@ -250,31 +385,61 @@ const knownGlobals: GlobalDescription = { // undefined: ?, unescape: PF, URIError: PC, - // @ts-ignore valueOf: O, - WeakMap: PC, - WeakSet: PC, + WeakMap: PC_WITH_ARRAY, + WeakRef: C, + WeakSet: PC_WITH_ARRAY, // Additional globals shared by Node and Browser that are not strictly part of the language clearInterval: C, clearTimeout: C, - console: O, + console: { + __proto__: null, + [ValueProperties]: IMPURE, + assert: C, + clear: C, + count: C, + countReset: C, + debug: C, + dir: C, + dirxml: C, + error: C, + exception: C, + group: C, + groupCollapsed: C, + groupEnd: C, + info: C, + log: C, + table: C, + time: C, + timeEnd: C, + timeLog: C, + trace: C, + warn: C + }, Intl: { - // @ts-ignore __proto__: null, [ValueProperties]: IMPURE, Collator: INTL_MEMBER, DateTimeFormat: INTL_MEMBER, + DisplayNames: INTL_MEMBER, ListFormat: INTL_MEMBER, + Locale: INTL_MEMBER, NumberFormat: INTL_MEMBER, PluralRules: INTL_MEMBER, - RelativeTimeFormat: INTL_MEMBER + RelativeTimeFormat: INTL_MEMBER, + Segmenter: INTL_MEMBER }, setInterval: C, setTimeout: C, TextDecoder: C, TextEncoder: C, - URL: C, + URL: { + __proto__: null, + [ValueProperties]: IMPURE, + prototype: O, + canParse: PF + }, URLSearchParams: C, // Browser specific globals @@ -359,7 +524,17 @@ const knownGlobals: GlobalDescription = { CSSSupportsRule: C, CustomElementRegistry: C, customElements: O, - CustomEvent: C, + CustomEvent: { + __proto__: null, + [ValueProperties]: { + deoptimizeArgumentsOnCall({ args }: NodeInteractionCalled) { + args[2]?.deoptimizePath(['detail']); + }, + getLiteralValue: getUnknownValue, + hasEffectsWhenCalled: returnFalse + }, + prototype: O + }, DataTransfer: C, DataTransferItem: C, DataTransferItemList: C, @@ -866,28 +1041,18 @@ for (const global of ['window', 'global', 'self', 'globalThis']) { knownGlobals[global] = knownGlobals; } -function getGlobalAtPath(path: ObjectPath): ValueDescription | null { - let currentGlobal = knownGlobals; +export function getGlobalAtPath(path: ObjectPath): ValueDescription | null { + let currentGlobal: GlobalDescription | null = knownGlobals; for (const pathSegment of path) { if (typeof pathSegment !== 'string') { return null; } currentGlobal = currentGlobal[pathSegment]; if (!currentGlobal) { - return null; + // Well-known symbols very often have a complex meaning and are invoked implicitly by the language. + // Resolve them to a special value so they can be distinguished and excluded from treeshaking. + return path[0] === 'Symbol' && path.length === 2 ? UNKNOWN_WELL_KNOWN : null; } } return currentGlobal[ValueProperties]; } - -export function isPureGlobal(path: ObjectPath): boolean { - const globalAtPath = getGlobalAtPath(path); - return globalAtPath !== null && globalAtPath.pure; -} - -export function isGlobalMember(path: ObjectPath): boolean { - if (path.length === 1) { - return path[0] === 'undefined' || getGlobalAtPath(path) !== null; - } - return getGlobalAtPath(path.slice(0, -1)) !== null; -} diff --git a/src/ast/nodes/shared/loops.ts b/src/ast/nodes/shared/loops.ts new file mode 100644 index 00000000000..dcc2dc6b41d --- /dev/null +++ b/src/ast/nodes/shared/loops.ts @@ -0,0 +1,32 @@ +import type { HasEffectsContext, InclusionContext } from '../../ExecutionContext'; +import type { StatementNode } from './Node'; + +export function hasLoopBodyEffects(context: HasEffectsContext, body: StatementNode): boolean { + const { brokenFlow, hasBreak, hasContinue, ignore } = context; + const { breaks, continues } = ignore; + ignore.breaks = true; + ignore.continues = true; + context.hasBreak = false; + context.hasContinue = false; + if (body.hasEffects(context)) return true; + ignore.breaks = breaks; + ignore.continues = continues; + context.hasBreak = hasBreak; + context.hasContinue = hasContinue; + context.brokenFlow = brokenFlow; + return false; +} + +export function includeLoopBody( + context: InclusionContext, + body: StatementNode, + includeChildrenRecursively: boolean | 'variables' +) { + const { brokenFlow, hasBreak, hasContinue } = context; + context.hasBreak = false; + context.hasContinue = false; + body.include(context, includeChildrenRecursively, { asSingleStatement: true }); + context.hasBreak = hasBreak; + context.hasContinue = hasContinue; + context.brokenFlow = brokenFlow; +} diff --git a/src/ast/scopes/BlockScope.ts b/src/ast/scopes/BlockScope.ts index b72bcc3a19e..278e4096ca6 100644 --- a/src/ast/scopes/BlockScope.ts +++ b/src/ast/scopes/BlockScope.ts @@ -1,21 +1,52 @@ -import { AstContext } from '../../Module'; -import Identifier from '../nodes/Identifier'; -import { ExpressionEntity } from '../nodes/shared/Expression'; -import { UNKNOWN_EXPRESSION } from '../values'; -import LocalVariable from '../variables/LocalVariable'; +import type { AstContext } from '../../Module'; +import { logRedeclarationError } from '../../utils/logs'; +import type Identifier from '../nodes/Identifier'; +import type { ExpressionEntity } from '../nodes/shared/Expression'; +import type { VariableKind } from '../nodes/shared/VariableKinds'; +import type { ObjectPath } from '../utils/PathTracker'; +import type LocalVariable from '../variables/LocalVariable'; import ChildScope from './ChildScope'; export default class BlockScope extends ChildScope { + constructor(parent: ChildScope) { + super(parent, parent.context); + } + addDeclaration( identifier: Identifier, context: AstContext, - init: ExpressionEntity | null, - isHoisted: boolean + init: ExpressionEntity, + destructuredInitPath: ObjectPath, + kind: VariableKind ): LocalVariable { - if (isHoisted) { - return this.parent.addDeclaration(identifier, context, UNKNOWN_EXPRESSION, isHoisted); - } else { - return super.addDeclaration(identifier, context, init, false); + if (kind === 'var') { + const name = identifier.name; + const existingVariable = + this.hoistedVariables?.get(name) || (this.variables.get(name) as LocalVariable | undefined); + if (existingVariable) { + if ( + existingVariable.kind === 'var' || + (kind === 'var' && existingVariable.kind === 'parameter') + ) { + existingVariable.addDeclaration(identifier, init); + return existingVariable; + } + return context.error(logRedeclarationError(name), identifier.start); + } + const declaredVariable = this.parent.addDeclaration( + identifier, + context, + init, + destructuredInitPath, + kind + ); + // Necessary to make sure the init is deoptimized for conditional declarations. + // We cannot call deoptimizePath here. + declaredVariable.markInitializersForDeoptimization(); + // We add the variable to this and all parent scopes to reliably detect conflicts + this.addHoistedVariable(name, declaredVariable); + return declaredVariable; } + return super.addDeclaration(identifier, context, init, destructuredInitPath, kind); } } diff --git a/src/ast/scopes/CatchBodyScope.ts b/src/ast/scopes/CatchBodyScope.ts new file mode 100644 index 00000000000..46cc32b6894 --- /dev/null +++ b/src/ast/scopes/CatchBodyScope.ts @@ -0,0 +1,81 @@ +import type { AstContext } from '../../Module'; +import { logRedeclarationError } from '../../utils/logs'; +import type Identifier from '../nodes/Identifier'; +import * as NodeType from '../nodes/NodeType'; +import type { ExpressionEntity } from '../nodes/shared/Expression'; +import type { VariableKind } from '../nodes/shared/VariableKinds'; +import type { ObjectPath } from '../utils/PathTracker'; +import { UNDEFINED_EXPRESSION } from '../values'; +import type LocalVariable from '../variables/LocalVariable'; +import ChildScope from './ChildScope'; +import type ParameterScope from './ParameterScope'; + +export default class CatchBodyScope extends ChildScope { + constructor(readonly parent: ParameterScope) { + super(parent, parent.context); + } + + addDeclaration( + identifier: Identifier, + context: AstContext, + init: ExpressionEntity, + destructuredInitPath: ObjectPath, + kind: VariableKind + ): LocalVariable { + if (kind === 'var') { + const name = identifier.name; + const existingVariable = + this.hoistedVariables?.get(name) || (this.variables.get(name) as LocalVariable | undefined); + if (existingVariable) { + const existingKind = existingVariable.kind; + if ( + existingKind === 'parameter' && + // If this is a destructured parameter, it is forbidden to redeclare + existingVariable.declarations[0].parent.type === NodeType.CatchClause + ) { + // If this is a var with the same name as the catch scope parameter, + // the assignment actually goes to the parameter and the var is + // hoisted without assignment. Locally, it is shadowed by the + // parameter + const declaredVariable = this.parent.parent.addDeclaration( + identifier, + context, + UNDEFINED_EXPRESSION, + destructuredInitPath, + kind + ); + // To avoid the need to rewrite the declaration, we link the variable + // names. If we ever implement a logic that splits initialization and + // assignment for hoisted vars, the "renderLikeHoisted" logic can be + // removed again. + // We do not need to check whether there already is a linked + // variable because then declaredVariable would be that linked + // variable. + existingVariable.renderLikeHoisted(declaredVariable); + this.addHoistedVariable(name, declaredVariable); + return declaredVariable; + } + if (existingKind === 'var') { + existingVariable.addDeclaration(identifier, init); + return existingVariable; + } + return context.error(logRedeclarationError(name), identifier.start); + } + // We only add parameters to parameter scopes + const declaredVariable = this.parent.parent.addDeclaration( + identifier, + context, + init, + destructuredInitPath, + kind + ); + // Necessary to make sure the init is deoptimized for conditional declarations. + // We cannot call deoptimizePath here. + declaredVariable.markInitializersForDeoptimization(); + // We add the variable to this and all parent scopes to reliably detect conflicts + this.addHoistedVariable(name, declaredVariable); + return declaredVariable; + } + return super.addDeclaration(identifier, context, init, destructuredInitPath, kind); + } +} diff --git a/src/ast/scopes/CatchScope.ts b/src/ast/scopes/CatchScope.ts deleted file mode 100644 index 4b59fbfe1ed..00000000000 --- a/src/ast/scopes/CatchScope.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { AstContext } from '../../Module'; -import Identifier from '../nodes/Identifier'; -import { ExpressionEntity } from '../nodes/shared/Expression'; -import LocalVariable from '../variables/LocalVariable'; -import ParameterScope from './ParameterScope'; - -export default class CatchScope extends ParameterScope { - addDeclaration( - identifier: Identifier, - context: AstContext, - init: ExpressionEntity | null, - isHoisted: boolean - ): LocalVariable { - if (isHoisted) { - return this.parent.addDeclaration(identifier, context, init, isHoisted); - } else { - return super.addDeclaration(identifier, context, init, false); - } - } -} diff --git a/src/ast/scopes/ChildScope.ts b/src/ast/scopes/ChildScope.ts index e6122317aee..9435e7517c2 100644 --- a/src/ast/scopes/ChildScope.ts +++ b/src/ast/scopes/ChildScope.ts @@ -1,22 +1,24 @@ -import { InternalModuleFormat } from '../../rollup/types'; +import type { AstContext } from '../../Module'; +import type { InternalModuleFormat } from '../../rollup/types'; import { getSafeName } from '../../utils/safeName'; -import ImportExpression from '../nodes/ImportExpression'; -import { ExpressionEntity } from '../nodes/shared/Expression'; -import Variable from '../variables/Variable'; +import type ImportExpression from '../nodes/ImportExpression'; +import type { ExpressionEntity } from '../nodes/shared/Expression'; +import type Variable from '../variables/Variable'; import Scope from './Scope'; export default class ChildScope extends Scope { - accessedOutsideVariables = new Map(); - parent: Scope; - private accessedDynamicImports?: Set; + readonly accessedOutsideVariables = new Map(); + declare private accessedDynamicImports?: Set; - constructor(parent: Scope) { + constructor( + readonly parent: Scope, + readonly context: AstContext + ) { super(); - this.parent = parent; parent.children.push(this); } - addAccessedDynamicImport(importExpression: ImportExpression) { + addAccessedDynamicImport(importExpression: ImportExpression): void { (this.accessedDynamicImports || (this.accessedDynamicImports = new Set())).add( importExpression ); @@ -25,7 +27,10 @@ export default class ChildScope extends Scope { } } - addAccessedGlobals(globals: string[], accessedGlobalsByScope: Map>) { + addAccessedGlobals( + globals: readonly string[], + accessedGlobalsByScope: Map> + ): void { const accessedGlobals = accessedGlobalsByScope.get(this) || new Set(); for (const name of globals) { accessedGlobals.add(name); @@ -36,27 +41,24 @@ export default class ChildScope extends Scope { } } - addNamespaceMemberAccess(name: string, variable: Variable) { + addNamespaceMemberAccess(name: string, variable: Variable): void { this.accessedOutsideVariables.set(name, variable); (this.parent as ChildScope).addNamespaceMemberAccess(name, variable); } - addReturnExpression(expression: ExpressionEntity) { - this.parent instanceof ChildScope && this.parent.addReturnExpression(expression); + addReturnExpression(expression: ExpressionEntity): void { + if (this.parent instanceof ChildScope) { + this.parent.addReturnExpression(expression); + } } addUsedOutsideNames( usedNames: Set, - format: InternalModuleFormat, - exportNamesByVariable: Map, - accessedGlobalsByScope: Map> + accessedGlobalsByScope: ReadonlyMap> ): void { for (const variable of this.accessedOutsideVariables.values()) { if (variable.included) { usedNames.add(variable.getBaseVariableName()); - if (format === 'system' && exportNamesByVariable.has(variable)) { - usedNames.add('exports'); - } } } const accessedGlobals = accessedGlobalsByScope.get(this); @@ -73,11 +75,11 @@ export default class ChildScope extends Scope { deconflict( format: InternalModuleFormat, - exportNamesByVariable: Map, - accessedGlobalsByScope: Map> - ) { + exportNamesByVariable: ReadonlyMap, + accessedGlobalsByScope: ReadonlyMap> + ): void { const usedNames = new Set(); - this.addUsedOutsideNames(usedNames, format, exportNamesByVariable, accessedGlobalsByScope); + this.addUsedOutsideNames(usedNames, accessedGlobalsByScope); if (this.accessedDynamicImports) { for (const importExpression of this.accessedDynamicImports) { if (importExpression.inlineNamespace) { @@ -87,7 +89,7 @@ export default class ChildScope extends Scope { } for (const [name, variable] of this.variables) { if (variable.included || variable.alwaysRendered) { - variable.setRenderNames(null, getSafeName(name, usedNames)); + variable.setRenderNames(null, getSafeName(name, usedNames, variable.forbiddenNames)); } } for (const scope of this.children) { @@ -99,6 +101,12 @@ export default class ChildScope extends Scope { return (this.parent as ChildScope).findLexicalBoundary(); } + findGlobal(name: string): Variable { + const variable = this.parent.findVariable(name); + this.accessedOutsideVariables.set(name, variable); + return variable; + } + findVariable(name: string): Variable { const knownVariable = this.variables.get(name) || this.accessedOutsideVariables.get(name); if (knownVariable) { diff --git a/src/ast/scopes/ClassBodyScope.ts b/src/ast/scopes/ClassBodyScope.ts index ebda392188a..a9c086444ba 100644 --- a/src/ast/scopes/ClassBodyScope.ts +++ b/src/ast/scopes/ClassBodyScope.ts @@ -1,7 +1,25 @@ +import type ClassNode from '../nodes/shared/ClassNode'; +import { EMPTY_PATH } from '../utils/PathTracker'; +import LocalVariable from '../variables/LocalVariable'; +import ThisVariable from '../variables/ThisVariable'; import ChildScope from './ChildScope'; export default class ClassBodyScope extends ChildScope { - findLexicalBoundary() { + readonly instanceScope: ChildScope; + readonly thisVariable: LocalVariable; + + constructor(parent: ChildScope, classNode: ClassNode) { + const { context } = parent; + super(parent, context); + this.variables.set( + 'this', + (this.thisVariable = new LocalVariable('this', null, classNode, EMPTY_PATH, context, 'other')) + ); + this.instanceScope = new ChildScope(this, context); + this.instanceScope.variables.set('this', new ThisVariable(context)); + } + + findLexicalBoundary(): ChildScope { return this; } } diff --git a/src/ast/scopes/FunctionBodyScope.ts b/src/ast/scopes/FunctionBodyScope.ts new file mode 100644 index 00000000000..6edab0c0ba5 --- /dev/null +++ b/src/ast/scopes/FunctionBodyScope.ts @@ -0,0 +1,50 @@ +import type { AstContext } from '../../Module'; +import { logRedeclarationError } from '../../utils/logs'; +import type Identifier from '../nodes/Identifier'; +import type { ExpressionEntity } from '../nodes/shared/Expression'; +import type { VariableKind } from '../nodes/shared/VariableKinds'; +import type { ObjectPath } from '../utils/PathTracker'; +import LocalVariable from '../variables/LocalVariable'; +import ChildScope from './ChildScope'; +import type ParameterScope from './ParameterScope'; + +export default class FunctionBodyScope extends ChildScope { + constructor(parent: ParameterScope) { + super(parent, parent.context); + } + + // There is stuff that is only allowed in function scopes, i.e. functions can + // be redeclared, functions and var can redeclare each other + addDeclaration( + identifier: Identifier, + context: AstContext, + init: ExpressionEntity, + destructuredInitPath: ObjectPath, + kind: VariableKind + ): LocalVariable { + const name = identifier.name; + const existingVariable = + this.hoistedVariables?.get(name) || (this.variables.get(name) as LocalVariable); + if (existingVariable) { + const existingKind = existingVariable.kind; + if ( + (kind === 'var' || kind === 'function') && + (existingKind === 'var' || existingKind === 'function' || existingKind === 'parameter') + ) { + existingVariable.addDeclaration(identifier, init); + return existingVariable; + } + context.error(logRedeclarationError(name), identifier.start); + } + const newVariable = new LocalVariable( + identifier.name, + identifier, + init, + destructuredInitPath, + context, + kind + ); + this.variables.set(name, newVariable); + return newVariable; + } +} diff --git a/src/ast/scopes/FunctionScope.ts b/src/ast/scopes/FunctionScope.ts index 7519f8036ff..f1aa7eb2cf0 100644 --- a/src/ast/scopes/FunctionScope.ts +++ b/src/ast/scopes/FunctionScope.ts @@ -1,34 +1,46 @@ -import { AstContext } from '../../Module'; -import { InclusionContext } from '../ExecutionContext'; -import { ExpressionNode } from '../nodes/shared/Node'; -import SpreadElement from '../nodes/SpreadElement'; +import type { InclusionContext } from '../ExecutionContext'; +import type { NodeInteractionCalled } from '../NodeInteractions'; +import type { ExpressionEntity } from '../nodes/shared/Expression'; +import type { NodeBase } from '../nodes/shared/Node'; +import { UNKNOWN_PATH } from '../utils/PathTracker'; import ArgumentsVariable from '../variables/ArgumentsVariable'; import ThisVariable from '../variables/ThisVariable'; -import ChildScope from './ChildScope'; +import type ChildScope from './ChildScope'; import ReturnValueScope from './ReturnValueScope'; export default class FunctionScope extends ReturnValueScope { - argumentsVariable: ArgumentsVariable; - thisVariable: ThisVariable; + readonly argumentsVariable: ArgumentsVariable; + readonly thisVariable: ThisVariable; - constructor(parent: ChildScope, context: AstContext) { - super(parent, context); + constructor( + parent: ChildScope, + readonly functionNode: NodeBase + ) { + super(parent, false); + const { context } = parent; this.variables.set('arguments', (this.argumentsVariable = new ArgumentsVariable(context))); this.variables.set('this', (this.thisVariable = new ThisVariable(context))); } - findLexicalBoundary() { + findLexicalBoundary(): ChildScope { return this; } - includeCallArguments(context: InclusionContext, args: (ExpressionNode | SpreadElement)[]): void { - super.includeCallArguments(context, args); + includeCallArguments(interaction: NodeInteractionCalled, context: InclusionContext): void { + super.includeCallArguments(interaction, context); if (this.argumentsVariable.included) { - for (const arg of args) { - if (!arg.included) { - arg.include(context, false); + const { args } = interaction; + for (let argumentIndex = 1; argumentIndex < args.length; argumentIndex++) { + const argument = args[argumentIndex]; + if (argument) { + argument.includePath(UNKNOWN_PATH, context); + argument.include(context, false); } } } } + + protected addArgumentToBeDeoptimized(argument: ExpressionEntity) { + this.argumentsVariable.addArgumentToBeDeoptimized(argument); + } } diff --git a/src/ast/scopes/GlobalScope.ts b/src/ast/scopes/GlobalScope.ts index d5c96644d7f..08c94f0f879 100644 --- a/src/ast/scopes/GlobalScope.ts +++ b/src/ast/scopes/GlobalScope.ts @@ -1,10 +1,10 @@ import GlobalVariable from '../variables/GlobalVariable'; import UndefinedVariable from '../variables/UndefinedVariable'; -import Variable from '../variables/Variable'; +import type Variable from '../variables/Variable'; import Scope from './Scope'; export default class GlobalScope extends Scope { - parent: null; + parent = null; constructor() { super(); diff --git a/src/ast/scopes/ModuleScope.ts b/src/ast/scopes/ModuleScope.ts index 372839a7dd0..3fc0a9ea0e2 100644 --- a/src/ast/scopes/ModuleScope.ts +++ b/src/ast/scopes/ModuleScope.ts @@ -1,51 +1,74 @@ -import { AstContext } from '../../Module'; -import { InternalModuleFormat } from '../../rollup/types'; -import ExportDefaultDeclaration from '../nodes/ExportDefaultDeclaration'; +import type { AstContext, ImportDescription } from '../../Module'; +import type { InternalModuleFormat } from '../../rollup/types'; +import { logRedeclarationError } from '../../utils/logs'; +import type ExportDefaultDeclaration from '../nodes/ExportDefaultDeclaration'; +import type Identifier from '../nodes/Identifier'; +import type { ExpressionEntity } from '../nodes/shared/Expression'; +import type { VariableKind } from '../nodes/shared/VariableKinds'; +import type { ObjectPath } from '../utils/PathTracker'; +import { EMPTY_PATH } from '../utils/PathTracker'; import { UNDEFINED_EXPRESSION } from '../values'; import ExportDefaultVariable from '../variables/ExportDefaultVariable'; import GlobalVariable from '../variables/GlobalVariable'; import LocalVariable from '../variables/LocalVariable'; -import Variable from '../variables/Variable'; +import type Variable from '../variables/Variable'; import ChildScope from './ChildScope'; -import GlobalScope from './GlobalScope'; +import type GlobalScope from './GlobalScope'; export default class ModuleScope extends ChildScope { - context: AstContext; - parent!: GlobalScope; + declare parent: GlobalScope; - constructor(parent: GlobalScope, context: AstContext) { - super(parent); - this.context = context; - this.variables.set('this', new LocalVariable('this', null, UNDEFINED_EXPRESSION, context)); + constructor( + parent: GlobalScope, + context: AstContext, + private readonly importDescriptions: Map + ) { + super(parent, context); + this.variables.set( + 'this', + new LocalVariable('this', null, UNDEFINED_EXPRESSION, EMPTY_PATH, context, 'other') + ); + } + + addDeclaration( + identifier: Identifier, + context: AstContext, + init: ExpressionEntity, + destructuredInitPath: ObjectPath, + kind: VariableKind + ): LocalVariable { + if (this.importDescriptions.has(identifier.name)) { + context.error(logRedeclarationError(identifier.name), identifier.start); + } + return super.addDeclaration(identifier, context, init, destructuredInitPath, kind); } addExportDefaultDeclaration( - name: string, exportDefaultDeclaration: ExportDefaultDeclaration, context: AstContext ): ExportDefaultVariable { - const variable = new ExportDefaultVariable(name, exportDefaultDeclaration, context); + const variable = new ExportDefaultVariable(exportDefaultDeclaration, context); this.variables.set('default', variable); return variable; } - addNamespaceMemberAccess() {} + addNamespaceMemberAccess(): void {} deconflict( format: InternalModuleFormat, - exportNamesByVariable: Map, - accessedGlobalsByScope: Map> - ) { + exportNamesByVariable: ReadonlyMap, + accessedGlobalsByScope: ReadonlyMap> + ): void { // all module level variables are already deconflicted when deconflicting the chunk for (const scope of this.children) scope.deconflict(format, exportNamesByVariable, accessedGlobalsByScope); } - findLexicalBoundary() { + findLexicalBoundary(): this { return this; } - findVariable(name: string) { + findVariable(name: string): Variable { const knownVariable = this.variables.get(name) || this.accessedOutsideVariables.get(name); if (knownVariable) { return knownVariable; diff --git a/src/ast/scopes/ParameterScope.ts b/src/ast/scopes/ParameterScope.ts index 8aafd8d4e09..ce80b3f4e20 100644 --- a/src/ast/scopes/ParameterScope.ts +++ b/src/ast/scopes/ParameterScope.ts @@ -1,43 +1,47 @@ -import { AstContext } from '../../Module'; -import { InclusionContext } from '../ExecutionContext'; -import Identifier from '../nodes/Identifier'; -import { ExpressionNode } from '../nodes/shared/Node'; +import { logDuplicateArgumentNameError } from '../../utils/logs'; +import type { InclusionContext } from '../ExecutionContext'; +import type { NodeInteractionCalled } from '../NodeInteractions'; +import type Identifier from '../nodes/Identifier'; import SpreadElement from '../nodes/SpreadElement'; -import { UNKNOWN_EXPRESSION } from '../values'; -import LocalVariable from '../variables/LocalVariable'; +import type { ObjectPath } from '../utils/PathTracker'; +import { UNKNOWN_PATH } from '../utils/PathTracker'; +import ParameterVariable from '../variables/ParameterVariable'; +import CatchBodyScope from './CatchBodyScope'; import ChildScope from './ChildScope'; -import Scope from './Scope'; +import FunctionBodyScope from './FunctionBodyScope'; export default class ParameterScope extends ChildScope { - hoistedBodyVarScope: ChildScope; + readonly bodyScope: ChildScope; - protected parameters: LocalVariable[][] = []; - private context: AstContext; - private hasRest = false; + protected hasRest = false; + protected parameters: readonly ParameterVariable[][] = []; - constructor(parent: Scope, context: AstContext) { - super(parent); - this.context = context; - this.hoistedBodyVarScope = new ChildScope(this); + constructor(parent: ChildScope, isCatchScope: boolean) { + super(parent, parent.context); + this.bodyScope = isCatchScope ? new CatchBodyScope(this) : new FunctionBodyScope(this); } /** * Adds a parameter to this scope. Parameters must be added in the correct - * order, e.g. from left to right. + * order, i.e. from left to right. */ - addParameterDeclaration(identifier: Identifier) { - const name = identifier.name; - let variable = this.hoistedBodyVarScope.variables.get(name) as LocalVariable; - if (variable) { - variable.addDeclaration(identifier, null); - } else { - variable = new LocalVariable(name, identifier, UNKNOWN_EXPRESSION, this.context); + addParameterDeclaration(identifier: Identifier, argumentPath: ObjectPath): ParameterVariable { + const { name, start } = identifier; + const existingParameter = this.variables.get(name); + if (existingParameter) { + return this.context.error(logDuplicateArgumentNameError(name), start); } + const variable = new ParameterVariable(name, identifier, argumentPath, this.context); this.variables.set(name, variable); + // We also add it to the body scope to detect name conflicts with local + // variables. We still need the intermediate scope, though, as parameter + // defaults are NOT taken from the body scope but from the parameters or + // outside scope. + this.bodyScope.addHoistedVariable(name, variable); return variable; } - addParameterVariables(parameters: LocalVariable[][], hasRest: boolean) { + addParameterVariables(parameters: ParameterVariable[][], hasRest: boolean): void { this.parameters = parameters; for (const parameterList of parameters) { for (const parameter of parameterList) { @@ -47,42 +51,54 @@ export default class ParameterScope extends ChildScope { this.hasRest = hasRest; } - includeCallArguments(context: InclusionContext, args: (ExpressionNode | SpreadElement)[]): void { + includeCallArguments({ args }: NodeInteractionCalled, context: InclusionContext): void { let calledFromTryStatement = false; - let argIncluded = false; - const restParam = this.hasRest && this.parameters[this.parameters.length - 1]; - for (const checkedArg of args) { - if (checkedArg instanceof SpreadElement) { - for (const arg of args) { - arg.include(context, false); - } - break; + let argumentIncluded = false; + const restParameter = this.hasRest && this.parameters[this.parameters.length - 1]; + let lastExplicitlyIncludedIndex = args.length - 1; + // If there is a SpreadElement, we need to include all arguments after it + // because we no longer know which argument corresponds to which parameter. + for (let argumentIndex = 1; argumentIndex < args.length; argumentIndex++) { + const argument = args[argumentIndex]; + if (argument instanceof SpreadElement && !argumentIncluded) { + argumentIncluded = true; + lastExplicitlyIncludedIndex = argumentIndex - 1; + } + if (argumentIncluded) { + argument!.includePath(UNKNOWN_PATH, context); + argument!.include(context, false); } } - for (let index = args.length - 1; index >= 0; index--) { - const paramVars = this.parameters[index] || restParam; - const arg = args[index]; - if (paramVars) { + // Now we go backwards either starting from the last argument or before the + // first SpreadElement to ensure all arguments before are included as needed + for (let index = lastExplicitlyIncludedIndex; index >= 1; index--) { + const parameterVariables = this.parameters[index - 1] || restParameter; + const argument = args[index]!; + if (parameterVariables) { calledFromTryStatement = false; - if (paramVars.length === 0) { - // handle empty destructuring - argIncluded = true; + if (parameterVariables.length === 0) { + // handle empty destructuring to avoid destructuring undefined + argumentIncluded = true; } else { - for (const variable of paramVars) { - if (variable.included) { - argIncluded = true; - } - if (variable.calledFromTryStatement) { + for (const parameterVariable of parameterVariables) { + if (parameterVariable.calledFromTryStatement) { calledFromTryStatement = true; } + if (parameterVariable.included) { + argumentIncluded = true; + if (calledFromTryStatement) { + argument.include(context, true); + } else { + parameterVariable.includeArgumentPaths(argument, context); + argument.include(context, false); + } + } } } } - if (!argIncluded && arg.shouldBeIncluded(context)) { - argIncluded = true; - } - if (argIncluded) { - arg.include(context, calledFromTryStatement); + if (argumentIncluded || argument.shouldBeIncluded(context)) { + argumentIncluded = true; + argument.include(context, calledFromTryStatement); } } } diff --git a/src/ast/scopes/ReturnValueScope.ts b/src/ast/scopes/ReturnValueScope.ts index 8647cd299ba..9e446c4056a 100644 --- a/src/ast/scopes/ReturnValueScope.ts +++ b/src/ast/scopes/ReturnValueScope.ts @@ -1,21 +1,78 @@ -import { ExpressionEntity } from '../nodes/shared/Expression'; +import type { NodeInteractionCalled } from '../NodeInteractions'; +import { type ExpressionEntity, UNKNOWN_EXPRESSION } from '../nodes/shared/Expression'; +import SpreadElement from '../nodes/SpreadElement'; import { UNKNOWN_PATH } from '../utils/PathTracker'; -import { UNKNOWN_EXPRESSION } from '../values'; +import { UNDEFINED_EXPRESSION } from '../values'; import ParameterScope from './ParameterScope'; export default class ReturnValueScope extends ParameterScope { private returnExpression: ExpressionEntity | null = null; - private returnExpressions: ExpressionEntity[] = []; + private readonly returnExpressions: ExpressionEntity[] = []; - addReturnExpression(expression: ExpressionEntity) { + addReturnExpression(expression: ExpressionEntity): void { this.returnExpressions.push(expression); } + deoptimizeArgumentsOnCall({ args }: NodeInteractionCalled): void { + const { parameters } = this; + let position = 0; + for (; position < args.length - 1; position++) { + // Only the "this" argument arg[0] can be null + const argument = args[position + 1]!; + if (argument instanceof SpreadElement) { + // This deoptimizes the current and remaining parameters and arguments + for (; position < parameters.length; position++) { + args[position + 1]?.deoptimizePath(UNKNOWN_PATH); + for (const variable of parameters[position]) { + variable.markReassigned(); + } + } + break; + } + if (this.hasRest && position >= parameters.length - 1) { + argument.deoptimizePath(UNKNOWN_PATH); + } else { + const variables = parameters[position]; + if (variables) { + for (const variable of variables) { + variable.addArgumentForDeoptimization(argument); + } + } + this.addArgumentToBeDeoptimized(argument); + } + } + const nonRestParameterLength = this.hasRest ? parameters.length - 1 : parameters.length; + for (; position < nonRestParameterLength; position++) { + for (const variable of parameters[position]) { + variable.addArgumentForDeoptimization(UNDEFINED_EXPRESSION); + } + } + } + getReturnExpression(): ExpressionEntity { if (this.returnExpression === null) this.updateReturnExpression(); return this.returnExpression!; } + deoptimizeAllParameters() { + for (const parameter of this.parameters) { + for (const variable of parameter) { + variable.deoptimizePath(UNKNOWN_PATH); + variable.markReassigned(); + } + } + } + + reassignAllParameters() { + for (const parameter of this.parameters) { + for (const variable of parameter) { + variable.markReassigned(); + } + } + } + + protected addArgumentToBeDeoptimized(_argument: ExpressionEntity) {} + private updateReturnExpression() { if (this.returnExpressions.length === 1) { this.returnExpression = this.returnExpressions[0]; diff --git a/src/ast/scopes/Scope.ts b/src/ast/scopes/Scope.ts index 32a46d31719..3be6b64292c 100644 --- a/src/ast/scopes/Scope.ts +++ b/src/ast/scopes/Scope.ts @@ -1,35 +1,61 @@ -import { AstContext } from '../../Module'; -import Identifier from '../nodes/Identifier'; -import { ExpressionEntity } from '../nodes/shared/Expression'; -import { UNDEFINED_EXPRESSION } from '../values'; +import type { AstContext } from '../../Module'; +import { logRedeclarationError } from '../../utils/logs'; +import type Identifier from '../nodes/Identifier'; +import type { ExpressionEntity } from '../nodes/shared/Expression'; +import type { VariableKind } from '../nodes/shared/VariableKinds'; +import type { ObjectPath } from '../utils/PathTracker'; import LocalVariable from '../variables/LocalVariable'; -import Variable from '../variables/Variable'; -import ChildScope from './ChildScope'; +import type Variable from '../variables/Variable'; +import type ChildScope from './ChildScope'; export default class Scope { - children: ChildScope[] = []; - variables = new Map(); + readonly children: ChildScope[] = []; + readonly variables = new Map(); + hoistedVariables?: Map; + /* + Redeclaration rules: + - var can redeclare var + - in function scopes, function and var can redeclare function and var + - var is hoisted across scopes, function remains in the scope it is declared + - var and function can redeclare function parameters, but parameters cannot redeclare parameters + - function cannot redeclare catch scope parameters + - var can redeclare catch scope parameters in a way + - if the parameter is an identifier and not a pattern + - then the variable is still declared in the hoisted outer scope, but the initializer is assigned to the parameter + - const, let, class, and function except in the cases above cannot redeclare anything + */ addDeclaration( identifier: Identifier, context: AstContext, - init: ExpressionEntity | null, - _isHoisted: boolean - ) { + init: ExpressionEntity, + destructuredInitPath: ObjectPath, + kind: VariableKind + ): LocalVariable { const name = identifier.name; - let variable = this.variables.get(name) as LocalVariable; - if (variable) { - variable.addDeclaration(identifier, init); - } else { - variable = new LocalVariable( - identifier.name, - identifier, - init || UNDEFINED_EXPRESSION, - context - ); - this.variables.set(name, variable); + const existingVariable = + this.hoistedVariables?.get(name) || (this.variables.get(name) as LocalVariable); + if (existingVariable) { + if (kind === 'var' && existingVariable.kind === 'var') { + existingVariable.addDeclaration(identifier, init); + return existingVariable; + } + context.error(logRedeclarationError(name), identifier.start); } - return variable; + const newVariable = new LocalVariable( + identifier.name, + identifier, + init, + destructuredInitPath, + context, + kind + ); + this.variables.set(name, newVariable); + return newVariable; + } + + addHoistedVariable(name: string, variable: LocalVariable) { + (this.hoistedVariables ||= new Map()).set(name, variable); } contains(name: string): boolean { @@ -37,6 +63,7 @@ export default class Scope { } findVariable(_name: string): Variable { + /* istanbul ignore next */ throw new Error('Internal Error: findVariable needs to be implemented by a subclass'); } } diff --git a/src/ast/scopes/TrackingScope.ts b/src/ast/scopes/TrackingScope.ts index 41bf1dd98eb..616fcafafa8 100644 --- a/src/ast/scopes/TrackingScope.ts +++ b/src/ast/scopes/TrackingScope.ts @@ -1,19 +1,22 @@ -import { AstContext } from '../../Module'; -import Identifier from '../nodes/Identifier'; -import { ExpressionEntity } from '../nodes/shared/Expression'; -import LocalVariable from '../variables/LocalVariable'; +import type { AstContext } from '../../Module'; +import type Identifier from '../nodes/Identifier'; +import type { ExpressionEntity } from '../nodes/shared/Expression'; +import type { VariableKind } from '../nodes/shared/VariableKinds'; +import type { ObjectPath } from '../utils/PathTracker'; +import type LocalVariable from '../variables/LocalVariable'; import BlockScope from './BlockScope'; export default class TrackingScope extends BlockScope { - public hoistedDeclarations: Identifier[] = []; + readonly hoistedDeclarations: Identifier[] = []; addDeclaration( identifier: Identifier, context: AstContext, - init: ExpressionEntity | null, - isHoisted: boolean + init: ExpressionEntity, + destructuredInitPath: ObjectPath, + kind: VariableKind ): LocalVariable { this.hoistedDeclarations.push(identifier); - return this.parent.addDeclaration(identifier, context, init, isHoisted); + return super.addDeclaration(identifier, context, init, destructuredInitPath, kind); } } diff --git a/src/ast/utils/PathTracker.ts b/src/ast/utils/PathTracker.ts index 74e10553744..a91590b5816 100644 --- a/src/ast/utils/PathTracker.ts +++ b/src/ast/utils/PathTracker.ts @@ -1,54 +1,254 @@ -import { getOrCreate } from '../../utils/getOrCreate'; -import { Entity } from '../Entity'; +import { EMPTY_OBJECT } from '../../utils/blank'; +import { getNewSet, getOrCreate } from '../../utils/getOrCreate'; +import type { Entity } from '../Entity'; +import type { InclusionContext } from '../ExecutionContext'; +import type { ExpressionEntity } from '../nodes/shared/Expression'; export const UnknownKey = Symbol('Unknown Key'); -export type ObjectPathKey = string | typeof UnknownKey; +export const UnknownNonAccessorKey = Symbol('Unknown Non-Accessor Key'); +export const UnknownInteger = Symbol('Unknown Integer'); +export const UnknownWellKnown = Symbol('Unknown Well-Known'); +export const SymbolToStringTag = Symbol('Symbol.toStringTag'); +export const SymbolDispose = Symbol('Symbol.asyncDispose'); +export const SymbolAsyncDispose = Symbol('Symbol.dispose'); +export const SymbolHasInstance = Symbol('Symbol.hasInstance'); -export type ObjectPath = ObjectPathKey[]; +interface SymbolSet extends Set { + has(symbol: symbol): symbol is T; +} + +const WELL_KNOWN_SYMBOLS_LIST = [ + SymbolToStringTag, + SymbolDispose, + SymbolAsyncDispose, + SymbolHasInstance +] as const; +export type WellKnownSymbol = (typeof WELL_KNOWN_SYMBOLS_LIST)[number]; +export const WELL_KNOWN_SYMBOLS = new Set(WELL_KNOWN_SYMBOLS_LIST) as SymbolSet; + +type AnyWellKnownSymbol = WellKnownSymbol | typeof UnknownWellKnown; +export const isAnyWellKnown = (v: any): v is AnyWellKnownSymbol => + WELL_KNOWN_SYMBOLS.has(v) || v === UnknownWellKnown; + +const TREE_SHAKEABLE_SYMBOLS_LIST = [SymbolHasInstance, SymbolDispose, SymbolAsyncDispose] as const; +type TreeShakeableSymbol = (typeof TREE_SHAKEABLE_SYMBOLS_LIST)[number]; +export const TREE_SHAKEABLE_SYMBOLS = new Set( + TREE_SHAKEABLE_SYMBOLS_LIST +) as SymbolSet; + +export type ConcreteKey = string | WellKnownSymbol; +export type ObjectPathKey = + | ConcreteKey + | typeof UnknownKey + | typeof UnknownWellKnown + | typeof UnknownNonAccessorKey + | typeof UnknownInteger; + +export const isConcreteKey = (v: ObjectPathKey): v is ConcreteKey => + typeof v === 'string' || WELL_KNOWN_SYMBOLS.has(v); + +export type ObjectPath = readonly ObjectPathKey[]; export const EMPTY_PATH: ObjectPath = []; export const UNKNOWN_PATH: ObjectPath = [UnknownKey]; +// For deoptimizations, this means we are modifying an unknown property but did +// not lose track of the object or are creating a setter/getter; +// For assignment effects it means we do not check for setter/getter effects +// but only if something is mutated that is included, which is relevant for +// Object.defineProperty +export const UNKNOWN_NON_ACCESSOR_PATH: ObjectPath = [UnknownNonAccessorKey]; +export const UNKNOWN_INTEGER_PATH: ObjectPath = [UnknownInteger]; +export const INSTANCEOF_PATH: ObjectPath = [SymbolHasInstance]; const EntitiesKey = Symbol('Entities'); interface EntityPaths { + [pathSegment: string]: EntityPaths; [EntitiesKey]: Set; + [SymbolToStringTag]?: EntityPaths; + [SymbolHasInstance]?: EntityPaths; + [SymbolDispose]?: EntityPaths; + [SymbolAsyncDispose]?: EntityPaths; + [UnknownInteger]?: EntityPaths; [UnknownKey]?: EntityPaths; - [pathSegment: string]: EntityPaths; + [UnknownWellKnown]?: EntityPaths; + [UnknownNonAccessorKey]?: EntityPaths; } -export class PathTracker { - entityPaths: EntityPaths = Object.create(null, { [EntitiesKey]: { value: new Set() } }); +export class EntityPathTracker { + private readonly entityPaths: EntityPaths = Object.create(null, { + [EntitiesKey]: { value: new Set() } + }); + + trackEntityAtPathAndGetIfTracked(path: ObjectPath, entity: Entity): boolean { + const trackedEntities = this.getEntities(path); + if (trackedEntities.has(entity)) return true; + trackedEntities.add(entity); + return false; + } - getEntities(path: ObjectPath): Set { + withTrackedEntityAtPath( + path: ObjectPath, + entity: Entity, + onUntracked: () => T, + returnIfTracked: T + ): T { + const trackedEntities = this.getEntities(path); + if (trackedEntities.has(entity)) return returnIfTracked; + trackedEntities.add(entity); + const result = onUntracked(); + trackedEntities.delete(entity); + return result; + } + + private getEntities(path: ObjectPath): Set { let currentPaths = this.entityPaths; for (const pathSegment of path) { - currentPaths = currentPaths[pathSegment] = - currentPaths[pathSegment] || - Object.create(null, { [EntitiesKey]: { value: new Set() } }); + currentPaths = currentPaths[pathSegment] ||= Object.create(null, { + [EntitiesKey]: { value: new Set() } + }); } return currentPaths[EntitiesKey]; } } -export const SHARED_RECURSION_TRACKER = new PathTracker(); +export const SHARED_RECURSION_TRACKER = new EntityPathTracker(); interface DiscriminatedEntityPaths { - [EntitiesKey]: Map>; - [UnknownKey]?: DiscriminatedEntityPaths; [pathSegment: string]: DiscriminatedEntityPaths; + [EntitiesKey]: Map>; + [SymbolToStringTag]?: DiscriminatedEntityPaths; + [SymbolHasInstance]?: DiscriminatedEntityPaths; + [SymbolDispose]?: DiscriminatedEntityPaths; + [SymbolAsyncDispose]?: DiscriminatedEntityPaths; + [UnknownInteger]?: DiscriminatedEntityPaths; + [UnknownKey]?: DiscriminatedEntityPaths; + [UnknownWellKnown]?: DiscriminatedEntityPaths; + [UnknownNonAccessorKey]?: DiscriminatedEntityPaths; } export class DiscriminatedPathTracker { - entityPaths: DiscriminatedEntityPaths = Object.create(null, { - [EntitiesKey]: { value: new Map>() } + private readonly entityPaths: DiscriminatedEntityPaths = Object.create(null, { + [EntitiesKey]: { value: new Map>() } }); - getEntities(path: ObjectPath, discriminator: object): Set { + trackEntityAtPathAndGetIfTracked( + path: ObjectPath, + discriminator: unknown, + entity: unknown + ): boolean { let currentPaths = this.entityPaths; for (const pathSegment of path) { - currentPaths = currentPaths[pathSegment] = - currentPaths[pathSegment] || - Object.create(null, { [EntitiesKey]: { value: new Map>() } }); + currentPaths = currentPaths[pathSegment] ||= Object.create(null, { + [EntitiesKey]: { value: new Map>() } + }); + } + const trackedEntities = getOrCreate( + currentPaths[EntitiesKey], + discriminator, + getNewSet + ); + if (trackedEntities.has(entity)) return true; + trackedEntities.add(entity); + return false; + } +} + +export interface IncludedPathTracker { + includePathAndGetIfIncluded(path: ObjectPath): boolean; +} + +type IncludedPaths = { [K in ConcreteKey]?: IncludedPaths } & { [UnknownKey]?: IncludedPaths }; + +const UNKNOWN_INCLUDED_PATH: IncludedPaths = Object.freeze({ [UnknownKey]: EMPTY_OBJECT }); + +export class IncludedFullPathTracker implements IncludedPathTracker { + private includedPaths: IncludedPaths | null = null; + + includePathAndGetIfIncluded(path: ObjectPath): boolean { + let included = true; + let parent = this as unknown as IncludedPaths; + let parentSegment: ConcreteKey = 'includedPaths'; + let currentPaths: IncludedPaths = (this.includedPaths ||= + ((included = false), Object.create(null))); + for (const pathSegment of path) { + // This means from here, all paths are included + if (currentPaths[UnknownKey]) { + return true; + } + // Including UnknownKey automatically includes all nested paths. + // From above, we know that UnknownKey is not included yet. + if (!isConcreteKey(pathSegment)) { + // Hopefully, this saves some memory over just setting + // currentPaths[UnknownKey] = EMPTY_OBJECT + parent[parentSegment] = UNKNOWN_INCLUDED_PATH; + return false; + } + parent = currentPaths; + parentSegment = pathSegment; + currentPaths = currentPaths[pathSegment] ||= ((included = false), Object.create(null)); + } + return included; + } +} + +// "true" means not sub-paths are included, "UnknownKey" means at least some sub-paths are included +type IncludedTopLevelPaths = Partial> & { + [UnknownKey]?: true; +}; + +const UNKNOWN_INCLUDED_TOP_LEVEL_PATH: Readonly = Object.freeze({ + [UnknownKey]: true as const +}); + +export class IncludedTopLevelPathTracker implements IncludedPathTracker { + private includedPaths: IncludedTopLevelPaths | null = null; + + includePathAndGetIfIncluded(path: ObjectPath): boolean { + let included = true; + const includedPaths: IncludedTopLevelPaths = (this.includedPaths ||= + ((included = false), Object.create(null))); + if (includedPaths[UnknownKey]) { + return true; + } + const [firstPathSegment, secondPathSegment] = path; + if (!firstPathSegment) { + return included; + } + if (!isConcreteKey(firstPathSegment)) { + this.includedPaths = UNKNOWN_INCLUDED_TOP_LEVEL_PATH; + return false; + } + if (secondPathSegment) { + if (includedPaths[firstPathSegment] === UnknownKey) { + return true; + } + includedPaths[firstPathSegment] = UnknownKey; + return false; + } + if (includedPaths[firstPathSegment]) { + return true; + } + includedPaths[firstPathSegment] = true; + return false; + } + + includeAllPaths(entity: ExpressionEntity, context: InclusionContext, basePath: ObjectPath) { + const { includedPaths } = this; + if (includedPaths) { + if (includedPaths[UnknownKey]) { + entity.includePath([...basePath, UnknownKey], context); + } else { + const inclusionEntries = Object.entries(includedPaths); + if (inclusionEntries.length === 0) { + entity.includePath(basePath, context); + } else { + for (const [key, value] of inclusionEntries) { + entity.includePath( + value === UnknownKey ? [...basePath, key, UnknownKey] : [...basePath, key], + context + ); + } + } + } } - return getOrCreate(currentPaths[EntitiesKey], discriminator, () => new Set()); } } diff --git a/src/ast/utils/checkEffectForNodes.ts b/src/ast/utils/checkEffectForNodes.ts new file mode 100644 index 00000000000..d3bb34d059c --- /dev/null +++ b/src/ast/utils/checkEffectForNodes.ts @@ -0,0 +1,11 @@ +import type { HasEffectsContext } from '../ExecutionContext'; +import type { NodeBase } from '../nodes/shared/Node'; + +export function checkEffectForNodes(nodes: NodeBase[], context: HasEffectsContext): boolean { + for (const node of nodes) { + if (node.hasEffects(context)) { + return true; + } + } + return false; +} diff --git a/src/ast/utils/identifyNode.ts b/src/ast/utils/identifyNode.ts new file mode 100644 index 00000000000..882a3dc4256 --- /dev/null +++ b/src/ast/utils/identifyNode.ts @@ -0,0 +1,53 @@ +import type ArrowFunctionExpression from '../nodes/ArrowFunctionExpression'; +import type AwaitExpression from '../nodes/AwaitExpression'; +import type CallExpression from '../nodes/CallExpression'; +import type ExpressionStatement from '../nodes/ExpressionStatement'; +import type FunctionExpression from '../nodes/FunctionExpression'; +import type Identifier from '../nodes/Identifier'; +import type ImportExpression from '../nodes/ImportExpression'; +import type MemberExpression from '../nodes/MemberExpression'; +import * as nodeType from '../nodes/NodeType'; +import type ObjectExpression from '../nodes/ObjectExpression'; +import type Property from '../nodes/Property'; +import type { ExpressionEntity } from '../nodes/shared/Expression'; +import { NodeBase } from '../nodes/shared/Node'; + +export function isObjectExpressionNode(node: ExpressionEntity): node is ObjectExpression { + return node instanceof NodeBase && node.type === nodeType.ObjectExpression; +} + +export function isPropertyNode(node: unknown): node is Property { + return node instanceof NodeBase && node.type === nodeType.Property; +} + +export function isArrowFunctionExpressionNode(node: unknown): node is ArrowFunctionExpression { + return node instanceof NodeBase && node.type === nodeType.ArrowFunctionExpression; +} + +export function isFunctionExpressionNode(node: unknown): node is FunctionExpression { + return node instanceof NodeBase && node.type === nodeType.FunctionExpression; +} + +export function isCallExpressionNode(node: unknown): node is CallExpression { + return node instanceof NodeBase && node.type === nodeType.CallExpression; +} + +export function isMemberExpressionNode(node: unknown): node is MemberExpression { + return node instanceof NodeBase && node.type === nodeType.MemberExpression; +} + +export function isImportExpressionNode(node: unknown): node is ImportExpression { + return node instanceof NodeBase && node.type === nodeType.ImportExpression; +} + +export function isAwaitExpressionNode(node: unknown): node is AwaitExpression { + return node instanceof NodeBase && node.type === nodeType.AwaitExpression; +} + +export function isIdentifierNode(node: unknown): node is Identifier { + return node instanceof NodeBase && node.type === nodeType.Identifier; +} + +export function isExpressionStatementNode(node: unknown): node is ExpressionStatement { + return node instanceof NodeBase && node.type === nodeType.ExpressionStatement; +} diff --git a/src/ast/utils/limitPathLength.ts b/src/ast/utils/limitPathLength.ts new file mode 100644 index 00000000000..d1fe8871b09 --- /dev/null +++ b/src/ast/utils/limitPathLength.ts @@ -0,0 +1,23 @@ +import type { ObjectPath } from './PathTracker'; + +// To avoid infinite recursions +export const MAX_PATH_DEPTH = 6; + +// If a path is longer than MAX_PATH_DEPTH, it is truncated so that it is at +// most MAX_PATH_DEPTH long. The last element is always UnknownKey +export const limitPathDepth = (path: ObjectPath): ObjectPath => + path.length > MAX_PATH_DEPTH ? [...path.slice(0, MAX_PATH_DEPTH - 1), 'UnknownKey'] : path; + +// If a path is longer than MAX_PATH_DEPTH, it is truncated so that it is at +// most MAX_PATH_DEPTH long. The last element is always UnknownKey +export const limitConcatenatedPathDepth = (path1: ObjectPath, path2: ObjectPath): ObjectPath => { + const { length: length1 } = path1; + const { length: length2 } = path2; + return length1 === 0 + ? path2 + : length2 === 0 + ? path1 + : length1 + length2 > MAX_PATH_DEPTH + ? [...path1, ...path2.slice(0, MAX_PATH_DEPTH - 1 - path1.length), 'UnknownKey'] + : [...path1, ...path2]; +}; diff --git a/src/ast/utils/renderLiteralValue.ts b/src/ast/utils/renderLiteralValue.ts new file mode 100644 index 00000000000..b2eb3607c0e --- /dev/null +++ b/src/ast/utils/renderLiteralValue.ts @@ -0,0 +1,29 @@ +import { UnknownValue } from '../nodes/shared/Expression'; + +export function getRenderedLiteralValue(value: unknown) { + if (value === undefined) { + return 'void 0'; + } + if (typeof value === 'boolean') { + return String(value); + } + if (typeof value === 'string') { + return JSON.stringify(value); + } + if (typeof value === 'number') { + return getSimplifiedNumber(value); + } + return UnknownValue; +} + +function getSimplifiedNumber(value: number) { + if (Object.is(-0, value)) { + return '-0'; + } + const exp = value.toExponential(); + const [base, exponent] = exp.split('e'); + const floatLength = base.split('.')[1]?.length || 0; + const finalizedExp = `${base.replace('.', '')}e${parseInt(exponent) - floatLength}`; + const stringifiedValue = String(value).replace('+', ''); + return finalizedExp.length < stringifiedValue.length ? finalizedExp : stringifiedValue; +} diff --git a/src/ast/utils/tryCastLiteralValueToBoolean.ts b/src/ast/utils/tryCastLiteralValueToBoolean.ts new file mode 100644 index 00000000000..bfcc6016185 --- /dev/null +++ b/src/ast/utils/tryCastLiteralValueToBoolean.ts @@ -0,0 +1,17 @@ +import type { LiteralValueOrUnknown } from '../nodes/shared/Expression'; +import { UnknownFalsyValue, UnknownTruthyValue, UnknownValue } from '../nodes/shared/Expression'; + +export function tryCastLiteralValueToBoolean( + literalValue: LiteralValueOrUnknown +): boolean | typeof UnknownValue { + if (typeof literalValue === 'symbol') { + if (literalValue === UnknownFalsyValue) { + return false; + } + if (literalValue === UnknownTruthyValue) { + return true; + } + return UnknownValue; + } + return !!literalValue; +} diff --git a/src/ast/values.ts b/src/ast/values.ts index 0d7ea2ca50f..9c85be79723 100644 --- a/src/ast/values.ts +++ b/src/ast/values.ts @@ -1,334 +1,179 @@ -import { CallOptions, NO_ARGS } from './CallOptions'; -import { HasEffectsContext, InclusionContext } from './ExecutionContext'; -import { LiteralValue } from './nodes/Literal'; -import { ExpressionEntity } from './nodes/shared/Expression'; -import { ExpressionNode } from './nodes/shared/Node'; -import SpreadElement from './nodes/SpreadElement'; -import { EMPTY_PATH, ObjectPath, ObjectPathKey } from './utils/PathTracker'; +import type { HasEffectsContext } from './ExecutionContext'; +import type { NodeInteraction, NodeInteractionCalled } from './NodeInteractions'; +import { + INTERACTION_ACCESSED, + INTERACTION_CALLED, + NODE_INTERACTION_UNKNOWN_CALL +} from './NodeInteractions'; +import type { LiteralValueOrBigInt } from './nodes/Literal'; +import type { LiteralValueOrUnknown } from './nodes/shared/Expression'; +import { + ExpressionEntity, + UNKNOWN_EXPRESSION, + UNKNOWN_RETURN_EXPRESSION, + UnknownValue +} from './nodes/shared/Expression'; +import { + EMPTY_PATH, + type ObjectPath, + type ObjectPathKey, + SHARED_RECURSION_TRACKER +} from './utils/PathTracker'; export interface MemberDescription { - callsArgs: number[] | null; - mutatesSelf: boolean; - returns: { new (): ExpressionEntity } | null; - returnsPrimitive: ExpressionEntity | null; + hasEffectsWhenCalled: + | ((interaction: NodeInteractionCalled, context: HasEffectsContext) => boolean) + | null; + returns: ExpressionEntity; } -export interface MemberDescriptions { - [key: string]: MemberDescription; -} +export type MemberDescriptions = Record; interface RawMemberDescription { value: MemberDescription; } function assembleMemberDescriptions( - memberDescriptions: { [key: string]: RawMemberDescription }, + memberDescriptions: Record, inheritedDescriptions: MemberDescriptions | null = null ): MemberDescriptions { return Object.create(inheritedDescriptions, memberDescriptions); } -export const UnknownValue = Symbol('Unknown Value'); -export type LiteralValueOrUnknown = LiteralValue | typeof UnknownValue; - -abstract class ValueBase implements ExpressionEntity { - included = true; - - deoptimizePath() {} - - getLiteralValueAtPath(): LiteralValueOrUnknown { - return UnknownValue; - } - - getReturnExpressionWhenCalledAtPath(_path: ObjectPath) { - return UNKNOWN_EXPRESSION; - } - - hasEffectsWhenAccessedAtPath( - path: ObjectPath, - _context: HasEffectsContext - ) { - return path.length > 0 - } - - hasEffectsWhenAssignedAtPath(path: ObjectPath) { - return path.length > 0 - } - - hasEffectsWhenCalledAtPath( - _path: ObjectPath, - _callOptions: CallOptions, - _context: HasEffectsContext - ) { - return true; - } - - include() {} - - includeCallArguments(_context: InclusionContext, _args: (ExpressionNode | SpreadElement)[]) {} - - mayModifyThisWhenCalledAtPath() { return true; } -} - -function includeAll(context: InclusionContext, args: (ExpressionNode | SpreadElement)[]) { - for (const arg of args) { - arg.include(context, false); - } -} - -export const UNKNOWN_EXPRESSION: ExpressionEntity = new class extends ValueBase { - includeCallArguments(context: InclusionContext, args: (ExpressionNode | SpreadElement)[]): void { - includeAll(context, args); - } -}; - -export const UNDEFINED_EXPRESSION: ExpressionEntity = new class extends ValueBase { - getLiteralValueAtPath() { - return undefined; - } -}; +export const UNDEFINED_EXPRESSION: ExpressionEntity = + new (class UndefinedExpression extends ExpressionEntity { + getLiteralValueAtPath(path: ObjectPath): LiteralValueOrUnknown { + return path.length > 0 ? UnknownValue : undefined; + } + })(); const returnsUnknown: RawMemberDescription = { value: { - callsArgs: null, - mutatesSelf: false, - returns: null, - returnsPrimitive: UNKNOWN_EXPRESSION + hasEffectsWhenCalled: null, + returns: UNKNOWN_EXPRESSION } }; -const mutatesSelfReturnsUnknown: RawMemberDescription = { - value: { returns: null, returnsPrimitive: UNKNOWN_EXPRESSION, callsArgs: null, mutatesSelf: true } -}; -const callsArgReturnsUnknown: RawMemberDescription = { - value: { returns: null, returnsPrimitive: UNKNOWN_EXPRESSION, callsArgs: [0], mutatesSelf: false } -}; - -export class UnknownArrayExpression extends ValueBase { - included = false; - getReturnExpressionWhenCalledAtPath(path: ObjectPath) { - if (path.length === 1) { - return getMemberReturnExpressionWhenCalled(arrayMembers, path[0]); - } - return UNKNOWN_EXPRESSION; - } - - hasEffectsWhenAccessedAtPath(path: ObjectPath) { - return path.length > 1; - } - - hasEffectsWhenAssignedAtPath(path: ObjectPath) { - return path.length > 1; - } - - hasEffectsWhenCalledAtPath( - path: ObjectPath, - callOptions: CallOptions, - context: HasEffectsContext - ) { - if (path.length === 1) { - return hasMemberEffectWhenCalled(arrayMembers, path[0], this.included, callOptions, context); +export const UNKNOWN_LITERAL_BOOLEAN: ExpressionEntity = + new (class UnknownBoolean extends ExpressionEntity { + getReturnExpressionWhenCalledAtPath( + path: ObjectPath + ): [expression: ExpressionEntity, isPure: boolean] { + if (path.length === 1) { + return getMemberReturnExpressionWhenCalled(literalBooleanMembers, path[0]); + } + return UNKNOWN_RETURN_EXPRESSION; } - return true; - } - - include() { - this.included = true; - } - - includeCallArguments(context: InclusionContext, args: (ExpressionNode | SpreadElement)[]): void { - includeAll(context, args); - } -} - -const returnsArray: RawMemberDescription = { - value: { - callsArgs: null, - mutatesSelf: false, - returns: UnknownArrayExpression, - returnsPrimitive: null - } -}; -const mutatesSelfReturnsArray: RawMemberDescription = { - value: { - callsArgs: null, - mutatesSelf: true, - returns: UnknownArrayExpression, - returnsPrimitive: null - } -}; -const callsArgReturnsArray: RawMemberDescription = { - value: { - callsArgs: [0], - mutatesSelf: false, - returns: UnknownArrayExpression, - returnsPrimitive: null - } -}; -const callsArgMutatesSelfReturnsArray: RawMemberDescription = { - value: { - callsArgs: [0], - mutatesSelf: true, - returns: UnknownArrayExpression, - returnsPrimitive: null - } -}; -const UNKNOWN_LITERAL_BOOLEAN: ExpressionEntity = new class extends ValueBase { - getReturnExpressionWhenCalledAtPath(path: ObjectPath) { - if (path.length === 1) { - return getMemberReturnExpressionWhenCalled(literalBooleanMembers, path[0]); - } - return UNKNOWN_EXPRESSION; - } - hasEffectsWhenAccessedAtPath(path: ObjectPath) { - return path.length > 1 - } - hasEffectsWhenCalledAtPath(path: ObjectPath) { - if (path.length === 1) { - const subPath = path[0]; - return typeof subPath !== 'string' || !literalBooleanMembers[subPath]; + hasEffectsOnInteractionAtPath( + path: ObjectPath, + interaction: NodeInteraction, + context: HasEffectsContext + ): boolean { + if (interaction.type === INTERACTION_ACCESSED) { + return path.length > 1; + } + if (interaction.type === INTERACTION_CALLED && path.length === 1) { + return hasMemberEffectWhenCalled(literalBooleanMembers, path[0], interaction, context); + } + return true; } - return true; - } - includeCallArguments(context: InclusionContext, args: (ExpressionNode | SpreadElement)[]): void { - includeAll(context, args); - } -}; + })(); const returnsBoolean: RawMemberDescription = { value: { - callsArgs: null, - mutatesSelf: false, - returns: null, - returnsPrimitive: UNKNOWN_LITERAL_BOOLEAN - } -}; -const callsArgReturnsBoolean: RawMemberDescription = { - value: { - callsArgs: [0], - mutatesSelf: false, - returns: null, - returnsPrimitive: UNKNOWN_LITERAL_BOOLEAN + hasEffectsWhenCalled: null, + returns: UNKNOWN_LITERAL_BOOLEAN } }; -const UNKNOWN_LITERAL_NUMBER: ExpressionEntity = new class extends ValueBase { - getReturnExpressionWhenCalledAtPath(path: ObjectPath) { - if (path.length === 1) { - return getMemberReturnExpressionWhenCalled(literalNumberMembers, path[0]); +export const UNKNOWN_LITERAL_NUMBER: ExpressionEntity = + new (class UnknownNumber extends ExpressionEntity { + getReturnExpressionWhenCalledAtPath( + path: ObjectPath + ): [expression: ExpressionEntity, isPure: boolean] { + if (path.length === 1) { + return getMemberReturnExpressionWhenCalled(literalNumberMembers, path[0]); + } + return UNKNOWN_RETURN_EXPRESSION; } - return UNKNOWN_EXPRESSION; - } - hasEffectsWhenAccessedAtPath(path: ObjectPath) { return path.length > 1; } - hasEffectsWhenCalledAtPath(path: ObjectPath) { - if (path.length === 1) { - const subPath = path[0]; - return typeof subPath !== 'string' || !literalNumberMembers[subPath]; + + hasEffectsOnInteractionAtPath( + path: ObjectPath, + interaction: NodeInteraction, + context: HasEffectsContext + ): boolean { + if (interaction.type === INTERACTION_ACCESSED) { + return path.length > 1; + } + if (interaction.type === INTERACTION_CALLED && path.length === 1) { + return hasMemberEffectWhenCalled(literalNumberMembers, path[0], interaction, context); + } + return true; } - return true; - } - includeCallArguments(context: InclusionContext, args: (ExpressionNode | SpreadElement)[]): void { - includeAll(context, args); - } -}; + })(); const returnsNumber: RawMemberDescription = { value: { - callsArgs: null, - mutatesSelf: false, - returns: null, - returnsPrimitive: UNKNOWN_LITERAL_NUMBER - } -}; -const mutatesSelfReturnsNumber: RawMemberDescription = { - value: { - callsArgs: null, - mutatesSelf: true, - returns: null, - returnsPrimitive: UNKNOWN_LITERAL_NUMBER - } -}; -const callsArgReturnsNumber: RawMemberDescription = { - value: { - callsArgs: [0], - mutatesSelf: false, - returns: null, - returnsPrimitive: UNKNOWN_LITERAL_NUMBER + hasEffectsWhenCalled: null, + returns: UNKNOWN_LITERAL_NUMBER } }; -const UNKNOWN_LITERAL_STRING: ExpressionEntity = new class extends ValueBase { - getReturnExpressionWhenCalledAtPath(path: ObjectPath) { - if (path.length === 1) { - return getMemberReturnExpressionWhenCalled(literalStringMembers, path[0]); +export const UNKNOWN_LITERAL_STRING: ExpressionEntity = + new (class UnknownString extends ExpressionEntity { + getReturnExpressionWhenCalledAtPath( + path: ObjectPath + ): [expression: ExpressionEntity, isPure: boolean] { + if (path.length === 1) { + return getMemberReturnExpressionWhenCalled(literalStringMembers, path[0]); + } + return UNKNOWN_RETURN_EXPRESSION; } - return UNKNOWN_EXPRESSION; - } - hasEffectsWhenAccessedAtPath(path: ObjectPath) { return path.length > 1 } - hasEffectsWhenCalledAtPath( - path: ObjectPath, - callOptions: CallOptions, - context: HasEffectsContext - ) { - if (path.length === 1) { - return hasMemberEffectWhenCalled(literalStringMembers, path[0], true, callOptions, context); + + hasEffectsOnInteractionAtPath( + path: ObjectPath, + interaction: NodeInteraction, + context: HasEffectsContext + ): boolean { + if (interaction.type === INTERACTION_ACCESSED) { + return path.length > 1; + } + if (interaction.type === INTERACTION_CALLED && path.length === 1) { + return hasMemberEffectWhenCalled(literalStringMembers, path[0], interaction, context); + } + return true; } - return true; - } - includeCallArguments(context: InclusionContext, args: (ExpressionNode | SpreadElement)[]): void { - includeAll(context, args); - } -}; + })(); const returnsString: RawMemberDescription = { value: { - callsArgs: null, - mutatesSelf: false, - returns: null, - returnsPrimitive: UNKNOWN_LITERAL_STRING + hasEffectsWhenCalled: null, + returns: UNKNOWN_LITERAL_STRING } }; -export class UnknownObjectExpression extends ValueBase { - included = false; - - getReturnExpressionWhenCalledAtPath(path: ObjectPath) { - if (path.length === 1) { - return getMemberReturnExpressionWhenCalled(objectMembers, path[0]); - } - return UNKNOWN_EXPRESSION; - } - - hasEffectsWhenAccessedAtPath(path: ObjectPath) { - return path.length > 1; - } - - hasEffectsWhenAssignedAtPath(path: ObjectPath) { - return path.length > 1; - } - - hasEffectsWhenCalledAtPath( - path: ObjectPath, - callOptions: CallOptions, - context: HasEffectsContext - ) { - if (path.length === 1) { - return hasMemberEffectWhenCalled(objectMembers, path[0], this.included, callOptions, context); - } - return true; - } - - include() { - this.included = true; - } - - includeCallArguments(context: InclusionContext, args: (ExpressionNode | SpreadElement)[]): void { - includeAll(context, args); +const stringReplace: RawMemberDescription = { + value: { + hasEffectsWhenCalled({ args }, context) { + const argument1 = args[2]; + return ( + args.length < 3 || + (typeof argument1.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, { + deoptimizeCache() {} + }) === 'symbol' && + argument1.hasEffectsOnInteractionAtPath( + EMPTY_PATH, + NODE_INTERACTION_UNKNOWN_CALL, + context + )) + ); + }, + returns: UNKNOWN_LITERAL_STRING } -} +}; -export const objectMembers: MemberDescriptions = assembleMemberDescriptions({ +const objectMembers: MemberDescriptions = assembleMemberDescriptions({ hasOwnProperty: returnsBoolean, isPrototypeOf: returnsBoolean, propertyIsEnumerable: returnsBoolean, @@ -337,36 +182,6 @@ export const objectMembers: MemberDescriptions = assembleMemberDescriptions({ valueOf: returnsUnknown }); -export const arrayMembers: MemberDescriptions = assembleMemberDescriptions( - { - concat: returnsArray, - copyWithin: mutatesSelfReturnsArray, - every: callsArgReturnsBoolean, - fill: mutatesSelfReturnsArray, - filter: callsArgReturnsArray, - find: callsArgReturnsUnknown, - findIndex: callsArgReturnsNumber, - forEach: callsArgReturnsUnknown, - includes: returnsBoolean, - indexOf: returnsNumber, - join: returnsString, - lastIndexOf: returnsNumber, - map: callsArgReturnsArray, - pop: mutatesSelfReturnsUnknown, - push: mutatesSelfReturnsNumber, - reduce: callsArgReturnsUnknown, - reduceRight: callsArgReturnsUnknown, - reverse: mutatesSelfReturnsArray, - shift: mutatesSelfReturnsUnknown, - slice: returnsArray, - some: callsArgReturnsBoolean, - sort: callsArgMutatesSelfReturnsArray, - splice: mutatesSelfReturnsArray, - unshift: mutatesSelfReturnsNumber - }, - objectMembers -); - const literalBooleanMembers: MemberDescriptions = assembleMemberDescriptions( { valueOf: returnsBoolean @@ -385,96 +200,110 @@ const literalNumberMembers: MemberDescriptions = assembleMemberDescriptions( objectMembers ); -const literalStringMembers: MemberDescriptions = assembleMemberDescriptions( +/** + * RegExp are stateful when they have the global or sticky flags set. + * But if we actually don't use them, the side effect does not matter. + * the check logic in `hasEffectsOnInteractionAtPath`. + */ +const literalRegExpMembers: MemberDescriptions = assembleMemberDescriptions( { + exec: returnsUnknown, + test: returnsBoolean + }, + objectMembers +); + +export const literalStringMembers: MemberDescriptions = assembleMemberDescriptions( + { + anchor: returnsString, + + at: returnsUnknown, + big: returnsString, + blink: returnsString, + bold: returnsString, charAt: returnsString, charCodeAt: returnsNumber, - codePointAt: returnsNumber, + codePointAt: returnsUnknown, concat: returnsString, endsWith: returnsBoolean, + fixed: returnsString, + fontcolor: returnsString, + fontsize: returnsString, includes: returnsBoolean, indexOf: returnsNumber, + italics: returnsString, lastIndexOf: returnsNumber, + link: returnsString, localeCompare: returnsNumber, - match: returnsBoolean, + match: returnsUnknown, + matchAll: returnsUnknown, normalize: returnsString, padEnd: returnsString, padStart: returnsString, repeat: returnsString, - replace: { - value: { - callsArgs: [1], - mutatesSelf: false, - returns: null, - returnsPrimitive: UNKNOWN_LITERAL_STRING - } - }, + replace: stringReplace, + replaceAll: stringReplace, search: returnsNumber, slice: returnsString, - split: returnsArray, + small: returnsString, + split: returnsUnknown, startsWith: returnsBoolean, + strike: returnsString, + sub: returnsString, substr: returnsString, substring: returnsString, + sup: returnsString, toLocaleLowerCase: returnsString, toLocaleUpperCase: returnsString, toLowerCase: returnsString, + toString: returnsString, // overrides the toString() method of the Object object; it does not inherit Object.prototype.toString() toUpperCase: returnsString, trim: returnsString, + trimEnd: returnsString, + trimLeft: returnsString, + trimRight: returnsString, + trimStart: returnsString, valueOf: returnsString }, objectMembers ); -export function getLiteralMembersForValue(value: T) { +export function getLiteralMembersForValue( + value: T +): MemberDescriptions { + if (value instanceof RegExp) { + return literalRegExpMembers; + } switch (typeof value) { - case 'boolean': + case 'boolean': { return literalBooleanMembers; - case 'number': + } + case 'number': { return literalNumberMembers; - case 'string': + } + case 'string': { return literalStringMembers; - default: - return Object.create(null); + } } + return Object.create(null); } export function hasMemberEffectWhenCalled( members: MemberDescriptions, memberName: ObjectPathKey, - parentIncluded: boolean, - callOptions: CallOptions, + interaction: NodeInteractionCalled, context: HasEffectsContext -) { - if ( - typeof memberName !== 'string' || - !members[memberName] || - (members[memberName].mutatesSelf && parentIncluded) - ) +): boolean { + if (typeof memberName !== 'string' || !members[memberName]) { return true; - if (!members[memberName].callsArgs) return false; - for (const argIndex of members[memberName].callsArgs!) { - if ( - callOptions.args[argIndex] && - callOptions.args[argIndex].hasEffectsWhenCalledAtPath( - EMPTY_PATH, - { - args: NO_ARGS, - withNew: false - }, - context - ) - ) - return true; } - return false; + return members[memberName].hasEffectsWhenCalled?.(interaction, context) || false; } export function getMemberReturnExpressionWhenCalled( members: MemberDescriptions, memberName: ObjectPathKey -): ExpressionEntity { - if (typeof memberName !== 'string' || !members[memberName]) return UNKNOWN_EXPRESSION; - return members[memberName].returnsPrimitive !== null - ? members[memberName].returnsPrimitive! - : new members[memberName].returns!(); +): [expression: ExpressionEntity, isPure: boolean] { + if (typeof memberName !== 'string' || !members[memberName]) return UNKNOWN_RETURN_EXPRESSION; + return [members[memberName].returns, false]; } diff --git a/src/ast/variables/ArgumentsVariable.ts b/src/ast/variables/ArgumentsVariable.ts index b67ff2f0de4..7201572c60e 100644 --- a/src/ast/variables/ArgumentsVariable.ts +++ b/src/ast/variables/ArgumentsVariable.ts @@ -1,22 +1,46 @@ -import { AstContext } from '../../Module'; -import { ObjectPath } from '../utils/PathTracker'; -import { UNKNOWN_EXPRESSION } from '../values'; +import type { AstContext } from '../../Module'; +import type { InclusionContext } from '../ExecutionContext'; +import type { NodeInteraction } from '../NodeInteractions'; +import { INTERACTION_ACCESSED } from '../NodeInteractions'; +import type { ExpressionEntity } from '../nodes/shared/Expression'; +import { UNKNOWN_EXPRESSION } from '../nodes/shared/Expression'; +import type { ObjectPath } from '../utils/PathTracker'; +import { EMPTY_PATH, UNKNOWN_PATH } from '../utils/PathTracker'; import LocalVariable from './LocalVariable'; export default class ArgumentsVariable extends LocalVariable { + deoptimizedArguments?: ExpressionEntity[]; + constructor(context: AstContext) { - super('arguments', null, UNKNOWN_EXPRESSION, context); + super('arguments', null, UNKNOWN_EXPRESSION, EMPTY_PATH, context, 'other'); } - hasEffectsWhenAccessedAtPath(path: ObjectPath) { - return path.length > 1; + addArgumentToBeDeoptimized(_argument: ExpressionEntity) {} + + // Only If there is at least one reference, then we need to track all + // arguments in order to be able to deoptimize them. + addReference() { + this.deoptimizedArguments = []; + this.addArgumentToBeDeoptimized = addArgumentToBeDeoptimized; } - hasEffectsWhenAssignedAtPath() { - return true; + hasEffectsOnInteractionAtPath(path: ObjectPath, { type }: NodeInteraction): boolean { + return type !== INTERACTION_ACCESSED || path.length > 1; } - hasEffectsWhenCalledAtPath(): boolean { - return true; + includePath(path: ObjectPath, context: InclusionContext) { + super.includePath(path, context); + for (const argument of this.deoptimizedArguments!) { + argument.deoptimizePath(UNKNOWN_PATH); + } + this.deoptimizedArguments!.length = 0; + } +} + +function addArgumentToBeDeoptimized(this: ArgumentsVariable, argument: ExpressionEntity) { + if (this.included) { + argument.deoptimizePath(UNKNOWN_PATH); + } else { + this.deoptimizedArguments?.push(argument); } } diff --git a/src/ast/variables/ExportDefaultVariable.ts b/src/ast/variables/ExportDefaultVariable.ts index c6abe791886..41baa6617c0 100644 --- a/src/ast/variables/ExportDefaultVariable.ts +++ b/src/ast/variables/ExportDefaultVariable.ts @@ -1,24 +1,30 @@ -import { AstContext } from '../../Module'; +import type { AstContext } from '../../Module'; import ClassDeclaration from '../nodes/ClassDeclaration'; -import ExportDefaultDeclaration from '../nodes/ExportDefaultDeclaration'; +import type ExportDefaultDeclaration from '../nodes/ExportDefaultDeclaration'; import FunctionDeclaration from '../nodes/FunctionDeclaration'; -import Identifier, { IdentifierWithVariable } from '../nodes/Identifier'; +import Identifier, { type IdentifierWithVariable } from '../nodes/Identifier'; +import type IdentifierBase from '../nodes/shared/IdentifierBase'; +import type { NodeBase } from '../nodes/shared/Node'; +import { EMPTY_PATH } from '../utils/PathTracker'; import LocalVariable from './LocalVariable'; import UndefinedVariable from './UndefinedVariable'; -import Variable from './Variable'; +import type Variable from './Variable'; export default class ExportDefaultVariable extends LocalVariable { hasId = false; - private originalId: IdentifierWithVariable | null = null; + private readonly originalId: IdentifierWithVariable | null = null; private originalVariable: Variable | null = null; - constructor( - name: string, - exportDefaultDeclaration: ExportDefaultDeclaration, - context: AstContext - ) { - super(name, exportDefaultDeclaration, exportDefaultDeclaration.declaration, context); + constructor(exportDefaultDeclaration: ExportDefaultDeclaration, context: AstContext) { + super( + 'default', + exportDefaultDeclaration, + exportDefaultDeclaration.declaration, + EMPTY_PATH, + context, + 'other' + ); const declaration = exportDefaultDeclaration.declaration; if ( (declaration instanceof FunctionDeclaration || declaration instanceof ClassDeclaration) && @@ -31,29 +37,44 @@ export default class ExportDefaultVariable extends LocalVariable { } } - addReference(identifier: Identifier) { + addReference(identifier: IdentifierBase): void { if (!this.hasId) { this.name = identifier.name; } } - getAssignedVariableName(): string | null { - return (this.originalId && this.originalId.name) || null; + addUsedPlace(usedPlace: NodeBase): void { + const original = this.getOriginalVariable(); + if (original === this) { + super.addUsedPlace(usedPlace); + } else { + original.addUsedPlace(usedPlace); + } } - getBaseVariableName(): string { + forbidName(name: string) { const original = this.getOriginalVariable(); if (original === this) { - return super.getBaseVariableName(); + super.forbidName(name); } else { - return original.getBaseVariableName(); + original.forbidName(name); } } + getAssignedVariableName(): string | null { + return (this.originalId && this.originalId.name) || null; + } + + getBaseVariableName(): string { + const original = this.getOriginalVariable(); + return original === this ? super.getBaseVariableName() : original.getBaseVariableName(); + } + getDirectOriginalVariable(): Variable | null { return this.originalId && (this.hasId || !( + this.originalId.isPossibleTDZ() || this.originalId.variable.isReassigned || this.originalId.variable instanceof UndefinedVariable || // this avoids a circular dependency @@ -63,17 +84,16 @@ export default class ExportDefaultVariable extends LocalVariable { : null; } - getName() { + getName(getPropertyAccess: (name: string) => string): string { const original = this.getOriginalVariable(); - if (original === this) { - return super.getName(); - } else { - return original.getName(); - } + return original === this + ? super.getName(getPropertyAccess) + : original.getName(getPropertyAccess); } getOriginalVariable(): Variable { if (this.originalVariable) return this.originalVariable; + // eslint-disable-next-line @typescript-eslint/no-this-alias let original: Variable | null = this; let currentVariable: Variable; const checkedVariables = new Set(); diff --git a/src/ast/variables/ExportShimVariable.ts b/src/ast/variables/ExportShimVariable.ts index f790182325a..f936e32c3bb 100644 --- a/src/ast/variables/ExportShimVariable.ts +++ b/src/ast/variables/ExportShimVariable.ts @@ -1,10 +1,19 @@ -import Module from '../../Module'; +import type Module from '../../Module'; import { MISSING_EXPORT_SHIM_VARIABLE } from '../../utils/variableNames'; +import type { InclusionContext } from '../ExecutionContext'; +import type { ObjectPath } from '../utils/PathTracker'; import Variable from './Variable'; export default class ExportShimVariable extends Variable { + readonly module: Module; + constructor(module: Module) { super(MISSING_EXPORT_SHIM_VARIABLE); this.module = module; } + + includePath(path: ObjectPath, context: InclusionContext): void { + super.includePath(path, context); + this.module.needsExportShim = true; + } } diff --git a/src/ast/variables/ExternalVariable.ts b/src/ast/variables/ExternalVariable.ts index b0f2ce6a416..ceda7380bd1 100644 --- a/src/ast/variables/ExternalVariable.ts +++ b/src/ast/variables/ExternalVariable.ts @@ -1,35 +1,35 @@ -import ExternalModule from '../../ExternalModule'; -import Identifier from '../nodes/Identifier'; -import { ObjectPath } from '../utils/PathTracker'; +import type ExternalModule from '../../ExternalModule'; +import type { InclusionContext } from '../ExecutionContext'; +import type { NodeInteraction } from '../NodeInteractions'; +import { INTERACTION_ACCESSED } from '../NodeInteractions'; +import type IdentifierBase from '../nodes/shared/IdentifierBase'; +import { type ObjectPath } from '../utils/PathTracker'; import Variable from './Variable'; export default class ExternalVariable extends Variable { - isNamespace: boolean; - module: ExternalModule; - referenced: boolean; + readonly isNamespace: boolean; + readonly module: ExternalModule; + referenced = false; constructor(module: ExternalModule, name: string) { super(name); this.module = module; this.isNamespace = name === '*'; - this.referenced = false; } - addReference(identifier: Identifier) { + addReference(identifier: IdentifierBase): void { this.referenced = true; if (this.name === 'default' || this.name === '*') { this.module.suggestName(identifier.name); } } - hasEffectsWhenAccessedAtPath(path: ObjectPath) { - return path.length > (this.isNamespace ? 1 : 0); + hasEffectsOnInteractionAtPath(path: ObjectPath, { type }: NodeInteraction): boolean { + return type !== INTERACTION_ACCESSED || path.length > (this.isNamespace ? 1 : 0); } - include() { - if (!this.included) { - this.included = true; - this.module.used = true; - } + includePath(path: ObjectPath, context: InclusionContext): void { + super.includePath(path, context); + this.module.used = true; } } diff --git a/src/ast/variables/GlobalVariable.ts b/src/ast/variables/GlobalVariable.ts index ed462df2d08..d6be0ebab4d 100644 --- a/src/ast/variables/GlobalVariable.ts +++ b/src/ast/variables/GlobalVariable.ts @@ -1,15 +1,81 @@ -import { isGlobalMember, isPureGlobal } from '../nodes/shared/knownGlobals'; -import { ObjectPath } from '../utils/PathTracker'; +import type { DeoptimizableEntity } from '../DeoptimizableEntity'; +import type { HasEffectsContext } from '../ExecutionContext'; +import type { NodeInteraction } from '../NodeInteractions'; +import { + INTERACTION_ACCESSED, + INTERACTION_ASSIGNED, + INTERACTION_CALLED +} from '../NodeInteractions'; +import type { LiteralValueOrUnknown } from '../nodes/shared/Expression'; +import { UnknownValue } from '../nodes/shared/Expression'; +import { getGlobalAtPath } from '../nodes/shared/knownGlobals'; +import { type EntityPathTracker, type ObjectPath } from '../utils/PathTracker'; import Variable from './Variable'; export default class GlobalVariable extends Variable { - isReassigned = true; + constructor(name: string) { + super(name); + // Ensure we use live-bindings for globals as we do not know if they have + // been reassigned + this.markReassigned(); + } + + deoptimizeArgumentsOnInteractionAtPath( + interaction: NodeInteraction, + path: ObjectPath, + recursionTracker: EntityPathTracker + ) { + switch (interaction.type) { + // While there is no point in testing these cases as at the moment, they + // are also covered via other means, we keep them for completeness + case INTERACTION_ACCESSED: + case INTERACTION_ASSIGNED: { + if (!getGlobalAtPath([this.name, ...path].slice(0, -1))) { + super.deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker); + } + return; + } + case INTERACTION_CALLED: { + const globalAtPath = getGlobalAtPath([this.name, ...path]); + if (globalAtPath) { + globalAtPath.deoptimizeArgumentsOnCall(interaction); + } else { + super.deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker); + } + return; + } + } + } - hasEffectsWhenAccessedAtPath(path: ObjectPath) { - return !isGlobalMember([this.name, ...path]); + getLiteralValueAtPath( + path: ObjectPath, + _recursionTracker: EntityPathTracker, + _origin: DeoptimizableEntity + ): LiteralValueOrUnknown { + const globalAtPath = getGlobalAtPath([this.name, ...path]); + return globalAtPath ? globalAtPath.getLiteralValue() : UnknownValue; } - hasEffectsWhenCalledAtPath(path: ObjectPath) { - return !isPureGlobal([this.name, ...path]); + hasEffectsOnInteractionAtPath( + path: ObjectPath, + interaction: NodeInteraction, + context: HasEffectsContext + ): boolean { + switch (interaction.type) { + case INTERACTION_ACCESSED: { + if (path.length === 0) { + // Technically, "undefined" is a global variable of sorts + return this.name !== 'undefined' && !getGlobalAtPath([this.name]); + } + return !getGlobalAtPath([this.name, ...path].slice(0, -1)); + } + case INTERACTION_ASSIGNED: { + return true; + } + case INTERACTION_CALLED: { + const globalAtPath = getGlobalAtPath([this.name, ...path]); + return !globalAtPath || globalAtPath.hasEffectsWhenCalled(interaction, context); + } + } } } diff --git a/src/ast/variables/LocalVariable.ts b/src/ast/variables/LocalVariable.ts index 6c3ec83133d..2d2047cce44 100644 --- a/src/ast/variables/LocalVariable.ts +++ b/src/ast/variables/LocalVariable.ts @@ -1,205 +1,266 @@ -import Module, { AstContext } from '../../Module'; -import { CallOptions } from '../CallOptions'; -import { DeoptimizableEntity } from '../DeoptimizableEntity'; -import { createInclusionContext, HasEffectsContext, InclusionContext } from '../ExecutionContext'; -import ExportDefaultDeclaration from '../nodes/ExportDefaultDeclaration'; -import Identifier from '../nodes/Identifier'; +import type { AstContext, default as Module } from '../../Module'; +import { EMPTY_ARRAY } from '../../utils/blank'; +import type { DeoptimizableEntity } from '../DeoptimizableEntity'; +import type { HasEffectsContext, InclusionContext } from '../ExecutionContext'; +import type { NodeInteraction, NodeInteractionCalled } from '../NodeInteractions'; +import { + INTERACTION_ACCESSED, + INTERACTION_ASSIGNED, + INTERACTION_CALLED +} from '../NodeInteractions'; +import type ExportDefaultDeclaration from '../nodes/ExportDefaultDeclaration'; +import type Identifier from '../nodes/Identifier'; import * as NodeType from '../nodes/NodeType'; -import { ExpressionEntity } from '../nodes/shared/Expression'; -import { ExpressionNode, Node } from '../nodes/shared/Node'; -import SpreadElement from '../nodes/SpreadElement'; -import { ObjectPath, PathTracker, UNKNOWN_PATH } from '../utils/PathTracker'; -import { LiteralValueOrUnknown, UnknownValue, UNKNOWN_EXPRESSION } from '../values'; +import { + deoptimizeInteraction, + type ExpressionEntity, + includeInteraction, + type LiteralValueOrUnknown, + UNKNOWN_EXPRESSION, + UNKNOWN_RETURN_EXPRESSION, + UnknownValue +} from '../nodes/shared/Expression'; +import type { Node } from '../nodes/shared/Node'; +import type { VariableKind } from '../nodes/shared/VariableKinds'; +import { limitConcatenatedPathDepth, MAX_PATH_DEPTH } from '../utils/limitPathLength'; +import type { IncludedPathTracker } from '../utils/PathTracker'; +import { + type EntityPathTracker, + IncludedFullPathTracker, + type ObjectPath, + UNKNOWN_PATH, + UnknownKey +} from '../utils/PathTracker'; import Variable from './Variable'; -// To avoid infinite recursions -const MAX_PATH_DEPTH = 7; - export default class LocalVariable extends Variable { - additionalInitializers: ExpressionEntity[] | null = null; calledFromTryStatement = false; - declarations: (Identifier | ExportDefaultDeclaration)[]; - init: ExpressionEntity | null; - module: Module; + readonly declarations: (Identifier | ExportDefaultDeclaration)[]; + readonly module: Module; + + protected additionalInitializers: ExpressionEntity[] | null = null; // Caching and deoptimization: // We track deoptimization when we do not return something unknown - private deoptimizationTracker: PathTracker; + protected deoptimizationTracker: EntityPathTracker; + protected includedPathTracker: IncludedPathTracker = new IncludedFullPathTracker(); private expressionsToBeDeoptimized: DeoptimizableEntity[] = []; constructor( name: string, declarator: Identifier | ExportDefaultDeclaration | null, - init: ExpressionEntity | null, - context: AstContext + public init: ExpressionEntity, + /** if this is non-empty, the actual init is this path of this.init */ + protected initPath: ObjectPath, + context: AstContext, + readonly kind: VariableKind ) { super(name); this.declarations = declarator ? [declarator] : []; - this.init = init; this.deoptimizationTracker = context.deoptimizationTracker; this.module = context.module; } - addDeclaration(identifier: Identifier, init: ExpressionEntity | null) { + addDeclaration(identifier: Identifier, init: ExpressionEntity): void { this.declarations.push(identifier); - if (this.additionalInitializers === null) { - this.additionalInitializers = this.init === null ? [] : [this.init]; - this.init = UNKNOWN_EXPRESSION; - this.isReassigned = true; - } - if (init !== null) { - this.additionalInitializers.push(init); - } + this.markInitializersForDeoptimization().push(init); } - consolidateInitializers() { - if (this.additionalInitializers !== null) { + consolidateInitializers(): void { + if (this.additionalInitializers) { for (const initializer of this.additionalInitializers) { initializer.deoptimizePath(UNKNOWN_PATH); } - this.additionalInitializers = null; } } - deoptimizePath(path: ObjectPath) { - if (path.length > MAX_PATH_DEPTH || this.isReassigned) return; - const trackedEntities = this.deoptimizationTracker.getEntities(path); - if (trackedEntities.has(this)) return; - trackedEntities.add(this); + deoptimizeArgumentsOnInteractionAtPath( + interaction: NodeInteraction, + path: ObjectPath, + recursionTracker: EntityPathTracker + ): void { + if (this.isReassigned || path.length + this.initPath.length > MAX_PATH_DEPTH) { + deoptimizeInteraction(interaction); + return; + } + recursionTracker.withTrackedEntityAtPath( + path, + this.init, + () => { + this.init.deoptimizeArgumentsOnInteractionAtPath( + interaction, + [...this.initPath, ...path], + recursionTracker + ); + }, + undefined + ); + } + + deoptimizePath(path: ObjectPath): void { + if ( + this.isReassigned || + this.deoptimizationTracker.trackEntityAtPathAndGetIfTracked(path, this) + ) { + return; + } if (path.length === 0) { - if (!this.isReassigned) { - this.isReassigned = true; - const expressionsToBeDeoptimized = this.expressionsToBeDeoptimized; - this.expressionsToBeDeoptimized = []; - for (const expression of expressionsToBeDeoptimized) { - expression.deoptimizeCache(); - } - if (this.init) { - this.init.deoptimizePath(UNKNOWN_PATH); - } + this.markReassigned(); + const expressionsToBeDeoptimized = this.expressionsToBeDeoptimized; + this.expressionsToBeDeoptimized = EMPTY_ARRAY as unknown as DeoptimizableEntity[]; + for (const expression of expressionsToBeDeoptimized) { + expression.deoptimizeCache(); } - } else if (this.init) { - this.init.deoptimizePath(path); + this.init.deoptimizePath([...this.initPath, UnknownKey]); + } else { + this.init.deoptimizePath(limitConcatenatedPathDepth(this.initPath, path)); } } getLiteralValueAtPath( path: ObjectPath, - recursionTracker: PathTracker, + recursionTracker: EntityPathTracker, origin: DeoptimizableEntity ): LiteralValueOrUnknown { - if (this.isReassigned || !this.init || path.length > MAX_PATH_DEPTH) { + if (this.isReassigned || path.length + this.initPath.length > MAX_PATH_DEPTH) { return UnknownValue; } - const trackedEntities = recursionTracker.getEntities(path); - if (trackedEntities.has(this.init)) { - return UnknownValue; - } - this.expressionsToBeDeoptimized.push(origin); - trackedEntities.add(this.init); - const value = this.init.getLiteralValueAtPath(path, recursionTracker, origin); - trackedEntities.delete(this.init); - return value; + return recursionTracker.withTrackedEntityAtPath( + path, + this.init, + () => { + this.expressionsToBeDeoptimized.push(origin); + return this.init.getLiteralValueAtPath( + [...this.initPath, ...path], + recursionTracker, + origin + ); + }, + UnknownValue + ); } getReturnExpressionWhenCalledAtPath( path: ObjectPath, - recursionTracker: PathTracker, + interaction: NodeInteractionCalled, + recursionTracker: EntityPathTracker, origin: DeoptimizableEntity - ): ExpressionEntity { - if (this.isReassigned || !this.init || path.length > MAX_PATH_DEPTH) { - return UNKNOWN_EXPRESSION; - } - const trackedEntities = recursionTracker.getEntities(path); - if (trackedEntities.has(this.init)) { - return UNKNOWN_EXPRESSION; + ): [expression: ExpressionEntity, isPure: boolean] { + if (this.isReassigned || path.length + this.initPath.length > MAX_PATH_DEPTH) { + return UNKNOWN_RETURN_EXPRESSION; } - this.expressionsToBeDeoptimized.push(origin); - trackedEntities.add(this.init); - const value = this.init.getReturnExpressionWhenCalledAtPath(path, recursionTracker, origin); - trackedEntities.delete(this.init); - return value; - } - - hasEffectsWhenAccessedAtPath(path: ObjectPath, context: HasEffectsContext) { - if (path.length === 0) return false; - if (this.isReassigned || path.length > MAX_PATH_DEPTH) return true; - const trackedExpressions = context.accessed.getEntities(path); - if (trackedExpressions.has(this)) return false; - trackedExpressions.add(this); - return (this.init && this.init.hasEffectsWhenAccessedAtPath(path, context))!; + return recursionTracker.withTrackedEntityAtPath( + path, + this.init, + () => { + this.expressionsToBeDeoptimized.push(origin); + return this.init.getReturnExpressionWhenCalledAtPath( + [...this.initPath, ...path], + interaction, + recursionTracker, + origin + ); + }, + UNKNOWN_RETURN_EXPRESSION + ); } - hasEffectsWhenAssignedAtPath(path: ObjectPath, context: HasEffectsContext) { - if (this.included || path.length > MAX_PATH_DEPTH) return true; - if (path.length === 0) return false; - if (this.isReassigned) return true; - const trackedExpressions = context.assigned.getEntities(path); - if (trackedExpressions.has(this)) return false; - trackedExpressions.add(this); - return (this.init && this.init.hasEffectsWhenAssignedAtPath(path, context))!; - } - - hasEffectsWhenCalledAtPath( + hasEffectsOnInteractionAtPath( path: ObjectPath, - callOptions: CallOptions, + interaction: NodeInteraction, context: HasEffectsContext - ) { - if (path.length > MAX_PATH_DEPTH || this.isReassigned) return true; - const trackedExpressions = (callOptions.withNew - ? context.instantiated - : context.called - ).getEntities(path, callOptions); - if (trackedExpressions.has(this)) return false; - trackedExpressions.add(this); - return (this.init && this.init.hasEffectsWhenCalledAtPath(path, callOptions, context))!; + ): boolean { + if (path.length + this.initPath.length > MAX_PATH_DEPTH) { + return true; + } + switch (interaction.type) { + case INTERACTION_ACCESSED: { + if (this.isReassigned) return true; + return ( + !context.accessed.trackEntityAtPathAndGetIfTracked(path, this) && + this.init.hasEffectsOnInteractionAtPath([...this.initPath, ...path], interaction, context) + ); + } + case INTERACTION_ASSIGNED: { + if (this.included) return true; + if (path.length === 0) return false; + // if (this.isReassigned || this.init.included) return true; + if (this.isReassigned) return true; + return ( + !context.assigned.trackEntityAtPathAndGetIfTracked(path, this) && + this.init.hasEffectsOnInteractionAtPath([...this.initPath, ...path], interaction, context) + ); + } + case INTERACTION_CALLED: { + if (this.isReassigned) return true; + return ( + !( + interaction.withNew ? context.instantiated : context.called + ).trackEntityAtPathAndGetIfTracked(path, interaction.args, this) && + this.init.hasEffectsOnInteractionAtPath([...this.initPath, ...path], interaction, context) + ); + } + } } - include() { - if (!this.included) { - this.included = true; + includePath(path: ObjectPath, context: InclusionContext): void { + if (!this.includedPathTracker.includePathAndGetIfIncluded(path)) { + this.module.scope.context.requestTreeshakingPass(); + if (!this.included) { + // This will reduce the number of tree-shaking passes by eagerly + // including inits. By pushing this here instead of directly including + // we avoid deep call stacks. + this.module.scope.context.newlyIncludedVariableInits.add(this.init); + } + super.includePath(path, context); for (const declaration of this.declarations) { // If node is a default export, it can save a tree-shaking run to include the full declaration now - if (!declaration.included) declaration.include(createInclusionContext(), false); + if (!declaration.included) declaration.include(context, false); let node = declaration.parent as Node; while (!node.included) { // We do not want to properly include parents in case they are part of a dead branch // in which case .include() might pull in more dead code - node.included = true; + node.includeNode(context); if (node.type === NodeType.Program) break; node = node.parent as Node; } } + // We need to make sure we include the correct path of the init + if (path.length > 0) { + this.init.includePath(limitConcatenatedPathDepth(this.initPath, path), context); + this.additionalInitializers?.forEach(initializer => + initializer.includePath(UNKNOWN_PATH, context) + ); + } } } - includeCallArguments(context: InclusionContext, args: (ExpressionNode | SpreadElement)[]): void { - if (this.isReassigned || (this.init && context.includedCallArguments.has(this.init))) { - for (const arg of args) { - arg.include(context, false); - } - } else if (this.init) { + includeCallArguments(interaction: NodeInteractionCalled, context: InclusionContext): void { + if ( + this.isReassigned || + context.includedCallArguments.has(this.init) || + // This can be removed again once we can include arguments when called at + // a specific path + this.initPath.length > 0 + ) { + includeInteraction(interaction, context); + } else { context.includedCallArguments.add(this.init); - this.init.includeCallArguments(context, args); + this.init.includeCallArguments(interaction, context); context.includedCallArguments.delete(this.init); } } - markCalledFromTryStatement() { + markCalledFromTryStatement(): void { this.calledFromTryStatement = true; } - mayModifyThisWhenCalledAtPath(path: ObjectPath, recursionTracker: PathTracker) { - if (this.isReassigned || !this.init || path.length > MAX_PATH_DEPTH) { - return true; - } - const trackedEntities = recursionTracker.getEntities(path); - if (trackedEntities.has(this.init)) { - return true; + markInitializersForDeoptimization(): ExpressionEntity[] { + if (this.additionalInitializers === null) { + this.additionalInitializers = [this.init]; + this.init = UNKNOWN_EXPRESSION; + this.markReassigned(); } - trackedEntities.add(this.init); - const result = this.init.mayModifyThisWhenCalledAtPath(path, recursionTracker); - trackedEntities.delete(this.init); - return result; + return this.additionalInitializers; } } diff --git a/src/ast/variables/NamespaceVariable.ts b/src/ast/variables/NamespaceVariable.ts index 5312518e013..8367b4cb4a9 100644 --- a/src/ast/variables/NamespaceVariable.ts +++ b/src/ast/variables/NamespaceVariable.ts @@ -1,132 +1,220 @@ -import Module, { AstContext } from '../../Module'; -import { RenderOptions } from '../../utils/renderHelpers'; -import { RESERVED_NAMES } from '../../utils/reservedNames'; +import type { AstContext, default as Module } from '../../Module'; +import { stringifyObjectKeyIfNeeded } from '../../utils/identifierHelpers'; +import { getToStringTagValue, MERGE_NAMESPACES_VARIABLE } from '../../utils/interopHelpers'; +import type { RenderOptions } from '../../utils/renderHelpers'; import { getSystemExportStatement } from '../../utils/systemJsRendering'; -import Identifier from '../nodes/Identifier'; -import { UNKNOWN_PATH } from '../utils/PathTracker'; +import type { HasEffectsContext, InclusionContext } from '../ExecutionContext'; +import type { NodeInteraction } from '../NodeInteractions'; +import { INTERACTION_ASSIGNED, INTERACTION_CALLED } from '../NodeInteractions'; +import type { LiteralValueOrUnknown } from '../nodes/shared/Expression'; +import { deoptimizeInteraction, UnknownValue } from '../nodes/shared/Expression'; +import type IdentifierBase from '../nodes/shared/IdentifierBase'; +import type ChildScope from '../scopes/ChildScope'; +import type { EntityPathTracker, ObjectPath } from '../utils/PathTracker'; +import { SymbolToStringTag, UNKNOWN_PATH } from '../utils/PathTracker'; import Variable from './Variable'; export default class NamespaceVariable extends Variable { - context: AstContext; - isNamespace!: true; - module: Module; + readonly context: AstContext; + declare isNamespace: true; + readonly module: Module; - private memberVariables: { [name: string]: Variable } | null = null; - private mergedNamespaces: Variable[] = []; + private areAllMembersDeoptimized = false; + private mergedNamespaces: readonly Variable[] = []; + private nonExplicitNamespacesIncluded = false; private referencedEarly = false; - private references: Identifier[] = []; - private syntheticNamedExports: boolean | string; + private readonly references: IdentifierBase[] = []; - constructor(context: AstContext, syntheticNamedExports: boolean | string) { + constructor(context: AstContext) { super(context.getModuleName()); this.context = context; this.module = context.module; - this.syntheticNamedExports = syntheticNamedExports; } - addReference(identifier: Identifier) { + addReference(identifier: IdentifierBase): void { this.references.push(identifier); this.name = identifier.name; } - // This is only called if "UNKNOWN_PATH" is reassigned as in all other situations, either the - // build fails due to an illegal namespace reassignment or MemberExpression already forwards - // the reassignment to the right variable. This means we lost track of this variable and thus - // need to reassign all exports. - deoptimizePath() { - const memberVariables = this.getMemberVariables(); - for (const key of Object.keys(memberVariables)) { - memberVariables[key].deoptimizePath(UNKNOWN_PATH); + deoptimizeArgumentsOnInteractionAtPath( + interaction: NodeInteraction, + path: ObjectPath, + recursionTracker: EntityPathTracker + ) { + if (path.length > 1 || (path.length === 1 && interaction.type === INTERACTION_CALLED)) { + const key = path[0]; + if (typeof key === 'string') { + this.module + .getExportedVariablesByName() + .get(key) + ?.deoptimizeArgumentsOnInteractionAtPath(interaction, path.slice(1), recursionTracker); + } else { + deoptimizeInteraction(interaction); + } } } - getMemberVariables(): { [name: string]: Variable } { - if (this.memberVariables) { - return this.memberVariables; - } - const memberVariables = Object.create(null); - for (const name of this.context.getExports().concat(this.context.getReexports())) { - if (name[0] !== '*' && name !== this.module.info.syntheticNamedExports) { - memberVariables[name] = this.context.traceExport(name); + deoptimizePath(path: ObjectPath) { + if (path.length > 1) { + const key = path[0]; + if (typeof key === 'string') { + this.module.getExportedVariablesByName().get(key)?.deoptimizePath(path.slice(1)); + } else if (!this.areAllMembersDeoptimized) { + this.areAllMembersDeoptimized = true; + for (const variable of this.module.getExportedVariablesByName().values()) { + variable.deoptimizePath(UNKNOWN_PATH); + } } } - return (this.memberVariables = memberVariables); } - include() { - this.included = true; - this.context.includeAllExports(); + getLiteralValueAtPath(path: ObjectPath): LiteralValueOrUnknown { + if (path[0] === SymbolToStringTag) { + return 'Module'; + } + return UnknownValue; } - prepareNamespace(mergedNamespaces: Variable[]) { - this.mergedNamespaces = mergedNamespaces; - const moduleExecIndex = this.context.getModuleExecIndex(); - for (const identifier of this.references) { - if (identifier.context.getModuleExecIndex() <= moduleExecIndex) { - this.referencedEarly = true; - break; - } + hasEffectsOnInteractionAtPath( + path: ObjectPath, + interaction: NodeInteraction, + context: HasEffectsContext + ): boolean { + const { type } = interaction; + if (path.length === 0) { + // This can only be a call anyway + return true; } + if (path.length === 1 && type !== INTERACTION_CALLED) { + return type === INTERACTION_ASSIGNED; + } + const key = path[0]; + if (typeof key !== 'string') { + return true; + } + const memberVariable = this.module.getExportedVariablesByName().get(key); + return ( + !memberVariable || + memberVariable.hasEffectsOnInteractionAtPath(path.slice(1), interaction, context) + ); } - renderBlock(options: RenderOptions) { - const _ = options.compact ? '' : ' '; - const n = options.compact ? '' : '\n'; - const t = options.indent; - - const memberVariables = this.getMemberVariables(); - const members = Object.keys(memberVariables).map(name => { - const original = memberVariables[name]; + includePath(path: ObjectPath, context: InclusionContext): void { + super.includePath(path, context); + this.includeMemberPath(path, context); + } - if (this.referencedEarly || original.isReassigned) { - return `${t}get ${name}${_}()${_}{${_}return ${original.getName()}${ - options.compact ? '' : ';' - }${_}}`; + includeMemberPath(path: ObjectPath, context: InclusionContext): void { + if (path.length > 0) { + const [name, ...remainingPath] = path; + if (typeof name === 'string') { + const variable = this.module.getExportedVariablesByName().get(name); + if (variable) { + this.context.includeVariableInModule(variable, remainingPath, context); + } else { + this.includeNonExplicitNamespaces(); + } + } else if (name) { + this.module.includeAllExports(); + this.includeNonExplicitNamespaces(); } - - const safeName = RESERVED_NAMES[name] ? `'${name}'` : name; - - return `${t}${safeName}: ${original.getName()}`; - }); - - if (options.namespaceToStringTag) { - members.unshift(`${t}[Symbol.toStringTag]:${_}'Module'`); } + } - const needsObjectAssign = this.mergedNamespaces.length > 0 || this.syntheticNamedExports; - if (!needsObjectAssign) members.unshift(`${t}__proto__:${_}null`); + prepare(accessedGlobalsByScope: Map>): void { + if (this.mergedNamespaces.length > 0) { + this.module.scope.addAccessedGlobals([MERGE_NAMESPACES_VARIABLE], accessedGlobalsByScope); + } + } - let output = `{${n}${members.join(`,${n}`)}${n}}`; - if (needsObjectAssign) { - const assignmentArgs: string[] = ['/*#__PURE__*/Object.create(null)']; - if (this.mergedNamespaces.length > 0) { - assignmentArgs.push(...this.mergedNamespaces.map(variable => variable.getName())); - } - if (this.syntheticNamedExports) { - assignmentArgs.push(this.module.getSyntheticNamespace().getName()); + renderBlock(options: RenderOptions): string { + const { + exportNamesByVariable, + format, + freeze, + indent: t, + symbols, + snippets: { _, cnst, getObject, getPropertyAccess, n, s } + } = options; + const memberVariables = this.module.getExportedVariablesByName(); + const members: [key: string | null, value: string][] = [...memberVariables.entries()] + .filter(([name, variable]) => !name.startsWith('*') && variable.included) + .map(([name, variable]) => { + if (this.referencedEarly || variable.isReassigned || variable === this) { + return [ + null, + `get ${stringifyObjectKeyIfNeeded(name)}${_}()${_}{${_}return ${variable.getName( + getPropertyAccess + )}${s}${_}}` + ]; + } + + return [name, variable.getName(getPropertyAccess)]; + }); + members.unshift([null, `__proto__:${_}null`]); + + let output = getObject(members, { lineBreakIndent: { base: '', t } }); + if (this.mergedNamespaces.length > 0) { + const assignmentArguments = this.mergedNamespaces.map(variable => + variable.getName(getPropertyAccess) + ); + output = `/*#__PURE__*/${MERGE_NAMESPACES_VARIABLE}(${output},${_}[${assignmentArguments.join( + `,${_}` + )}])`; + } else { + // The helper to merge namespaces will also take care of freezing and toStringTag + if (symbols) { + output = `/*#__PURE__*/Object.defineProperty(${output},${_}Symbol.toStringTag,${_}${getToStringTagValue( + getObject + )})`; } - if (members.length > 0) { - assignmentArgs.push(output); + if (freeze) { + output = `/*#__PURE__*/Object.freeze(${output})`; } - output = `/*#__PURE__*/Object.assign(${assignmentArgs.join(`,${_}`)})`; - } - if (options.freeze) { - output = `/*#__PURE__*/Object.freeze(${output})`; } - const name = this.getName(); - output = `${options.varOrConst} ${name}${_}=${_}${output};`; + const name = this.getName(getPropertyAccess); + output = `${cnst} ${name}${_}=${_}${output};`; - if (options.format === 'system' && options.exportNamesByVariable.has(this)) { + if (format === 'system' && exportNamesByVariable.has(this)) { output += `${n}${getSystemExportStatement([this], options)};`; } return output; } - renderFirst() { + renderFirst(): boolean { return this.referencedEarly; } + + setMergedNamespaces(mergedNamespaces: readonly Variable[]): void { + this.mergedNamespaces = mergedNamespaces; + const moduleExecIndex = this.context.getModuleExecIndex(); + for (const identifier of this.references) { + const { context } = identifier.scope; + if (context.getModuleExecIndex() <= moduleExecIndex) { + this.referencedEarly = true; + break; + } + } + } + + private includeNonExplicitNamespaces(): void { + if (!this.nonExplicitNamespacesIncluded) { + this.nonExplicitNamespacesIncluded = true; + this.setMergedNamespaces(this.module.includeAndGetAdditionalMergedNamespaces()); + } + } } NamespaceVariable.prototype.isNamespace = true; + +// This is a proxy that does not include the namespace object when a path is included +export const getDynamicNamespaceVariable = (namespace: NamespaceVariable): NamespaceVariable => + Object.create(namespace, { + includePath: { + value(path: ObjectPath, context: InclusionContext): void { + namespace.includeMemberPath(path, context); + } + } + }); diff --git a/src/ast/variables/ParameterVariable.ts b/src/ast/variables/ParameterVariable.ts new file mode 100644 index 00000000000..73109f4869d --- /dev/null +++ b/src/ast/variables/ParameterVariable.ts @@ -0,0 +1,280 @@ +import type { AstContext } from '../../Module'; +import { EMPTY_ARRAY } from '../../utils/blank'; +import type { DeoptimizableEntity } from '../DeoptimizableEntity'; +import type { InclusionContext } from '../ExecutionContext'; +import { type HasEffectsContext } from '../ExecutionContext'; +import type { NodeInteraction } from '../NodeInteractions'; +import { INTERACTION_ASSIGNED, INTERACTION_CALLED } from '../NodeInteractions'; +import type ExportDefaultDeclaration from '../nodes/ExportDefaultDeclaration'; +import Identifier from '../nodes/Identifier'; +import type { ExpressionEntity, LiteralValueOrUnknown } from '../nodes/shared/Expression'; +import { + deoptimizeInteraction, + UNKNOWN_EXPRESSION, + UNKNOWN_RETURN_EXPRESSION, + UnknownValue +} from '../nodes/shared/Expression'; +import { MAX_PATH_DEPTH } from '../utils/limitPathLength'; +import type { ObjectPath, ObjectPathKey } from '../utils/PathTracker'; +import { + EntityPathTracker, + IncludedTopLevelPathTracker, + SHARED_RECURSION_TRACKER, + UNKNOWN_PATH, + UnknownKey +} from '../utils/PathTracker'; +import LocalVariable from './LocalVariable'; + +interface TrackedInteraction { + interaction: NodeInteraction; + path: ObjectPath; +} + +const MAX_TRACKED_INTERACTIONS = 20; +const NO_INTERACTIONS = EMPTY_ARRAY as unknown as TrackedInteraction[]; +const UNKNOWN_DEOPTIMIZED_FIELD = new Set([UnknownKey]); +const EMPTY_PATH_TRACKER = new EntityPathTracker(); +const UNKNOWN_DEOPTIMIZED_ENTITY = new Set([UNKNOWN_EXPRESSION]); + +export default class ParameterVariable extends LocalVariable { + protected includedPathTracker = new IncludedTopLevelPathTracker(); + private argumentsToBeDeoptimized = new Set(); + private deoptimizationInteractions: TrackedInteraction[] = []; + private deoptimizations = new EntityPathTracker(); + private deoptimizedFields = new Set(); + private expressionsDependingOnKnownValue: DeoptimizableEntity[] = []; + private knownValue: ExpressionEntity | null = null; + private knownValueLiteral: LiteralValueOrUnknown = UnknownValue; + + constructor( + name: string, + declarator: Identifier | ExportDefaultDeclaration | null, + argumentPath: ObjectPath, + context: AstContext + ) { + super(name, declarator, UNKNOWN_EXPRESSION, argumentPath, context, 'parameter'); + } + + addArgumentForDeoptimization(entity: ExpressionEntity): void { + this.updateKnownValue(entity); + if (entity === UNKNOWN_EXPRESSION) { + // As unknown expressions fully deoptimize all interactions, we can clear + // the interaction cache at this point provided we keep this optimization + // in mind when adding new interactions + if (!this.argumentsToBeDeoptimized.has(UNKNOWN_EXPRESSION)) { + this.argumentsToBeDeoptimized.add(UNKNOWN_EXPRESSION); + for (const { interaction } of this.deoptimizationInteractions) { + deoptimizeInteraction(interaction); + } + this.deoptimizationInteractions = NO_INTERACTIONS; + } + } else if (this.deoptimizedFields.has(UnknownKey)) { + // This means that we already deoptimized all interactions and no longer + // track them + entity.deoptimizePath([...this.initPath, UnknownKey]); + } else if (!this.argumentsToBeDeoptimized.has(entity)) { + this.argumentsToBeDeoptimized.add(entity); + for (const field of this.deoptimizedFields) { + entity.deoptimizePath([...this.initPath, field]); + } + for (const { interaction, path } of this.deoptimizationInteractions) { + entity.deoptimizeArgumentsOnInteractionAtPath( + interaction, + [...this.initPath, ...path], + SHARED_RECURSION_TRACKER + ); + } + } + } + + /** This says we should not make assumptions about the value of the parameter. + * This is different from deoptimization that will also cause argument values + * to be deoptimized. */ + markReassigned(): void { + if (this.isReassigned) { + return; + } + super.markReassigned(); + for (const expression of this.expressionsDependingOnKnownValue) { + expression.deoptimizeCache(); + } + this.expressionsDependingOnKnownValue = EMPTY_ARRAY as unknown as DeoptimizableEntity[]; + } + + deoptimizeCache(): void { + this.markReassigned(); + } + + /** + * Update the known value of the parameter variable. + * Must be called for every function call, so it can track all the arguments, + * and deoptimizeCache itself to mark reassigned if the argument is changed. + * @param argument The argument of the function call + */ + private updateKnownValue(argument: ExpressionEntity) { + if (this.isReassigned) { + return; + } + + if (this.knownValue === null) { + this.knownValue = argument; + this.knownValueLiteral = argument.getLiteralValueAtPath( + this.initPath, + SHARED_RECURSION_TRACKER, + this + ); + return; + } + + // the same literal or identifier, do nothing + if ( + this.knownValue === argument || + (this.knownValue instanceof Identifier && + argument instanceof Identifier && + this.knownValue.variable === argument.variable) + ) { + return; + } + + const { knownValueLiteral } = this; + if ( + typeof knownValueLiteral === 'symbol' || + argument.getLiteralValueAtPath(this.initPath, SHARED_RECURSION_TRACKER, this) !== + knownValueLiteral + ) { + this.markReassigned(); + } + } + + /** + * This function freezes the known value of the parameter variable, + * so the optimization starts with a certain ExpressionEntity. + * The optimization can be undone by calling `markReassigned`. + * @returns the frozen value + */ + private getKnownValue(): ExpressionEntity { + return this.knownValue || UNKNOWN_EXPRESSION; + } + + getLiteralValueAtPath( + path: ObjectPath, + recursionTracker: EntityPathTracker, + origin: DeoptimizableEntity + ): LiteralValueOrUnknown { + if (this.isReassigned || path.length + this.initPath.length > MAX_PATH_DEPTH) { + return UnknownValue; + } + const knownValue = this.getKnownValue(); + this.expressionsDependingOnKnownValue.push(origin); + return recursionTracker.withTrackedEntityAtPath( + path, + knownValue, + () => knownValue.getLiteralValueAtPath([...this.initPath, ...path], recursionTracker, origin), + UnknownValue + ); + } + + hasEffectsOnInteractionAtPath( + path: ObjectPath, + interaction: NodeInteraction, + context: HasEffectsContext + ): boolean { + const { type } = interaction; + if ( + this.isReassigned || + type === INTERACTION_ASSIGNED || + path.length + this.initPath.length > MAX_PATH_DEPTH + ) { + return super.hasEffectsOnInteractionAtPath(path, interaction, context); + } + return ( + !(type === INTERACTION_CALLED + ? (interaction.withNew + ? context.instantiated + : context.called + ).trackEntityAtPathAndGetIfTracked(path, interaction.args, this) + : context.accessed.trackEntityAtPathAndGetIfTracked(path, this)) && + this.getKnownValue().hasEffectsOnInteractionAtPath( + [...this.initPath, ...path], + interaction, + context + ) + ); + } + + deoptimizeArgumentsOnInteractionAtPath(interaction: NodeInteraction, path: ObjectPath): void { + // For performance reasons, we fully deoptimize all deeper interactions + if ( + path.length >= 2 || + this.argumentsToBeDeoptimized.has(UNKNOWN_EXPRESSION) || + this.deoptimizationInteractions.length >= MAX_TRACKED_INTERACTIONS || + (path.length === 1 && + (this.deoptimizedFields.has(UnknownKey) || + (interaction.type === INTERACTION_CALLED && this.deoptimizedFields.has(path[0])))) || + this.initPath.length + path.length > MAX_PATH_DEPTH + ) { + deoptimizeInteraction(interaction); + return; + } + if (!this.deoptimizations.trackEntityAtPathAndGetIfTracked(path, interaction.args)) { + for (const entity of this.argumentsToBeDeoptimized) { + entity.deoptimizeArgumentsOnInteractionAtPath( + interaction, + [...this.initPath, ...path], + SHARED_RECURSION_TRACKER + ); + } + if (!this.argumentsToBeDeoptimized.has(UNKNOWN_EXPRESSION)) { + this.deoptimizationInteractions.push({ + interaction, + path + }); + } + } + } + + deoptimizePath(path: ObjectPath): void { + if (path.length === 0) { + this.markReassigned(); + return; + } + if (this.deoptimizedFields.has(UnknownKey)) { + return; + } + const key = path[0]; + if (this.deoptimizedFields.has(key)) { + return; + } + this.deoptimizedFields.add(key); + for (const entity of this.argumentsToBeDeoptimized) { + // We do not need a recursion tracker here as we already track whether + // this field is deoptimized + entity.deoptimizePath([...this.initPath, key]); + } + if (key === UnknownKey) { + // save some memory + this.deoptimizationInteractions = NO_INTERACTIONS; + this.deoptimizations = EMPTY_PATH_TRACKER; + this.deoptimizedFields = UNKNOWN_DEOPTIMIZED_FIELD; + this.argumentsToBeDeoptimized = UNKNOWN_DEOPTIMIZED_ENTITY; + } + } + + getReturnExpressionWhenCalledAtPath( + path: ObjectPath + ): [expression: ExpressionEntity, isPure: boolean] { + // We deoptimize everything that is called as that will trivially deoptimize + // the corresponding return expressions as well and avoid badly performing + // and complicated alternatives + if (path.length === 0) { + this.deoptimizePath(UNKNOWN_PATH); + } else if (!this.deoptimizedFields.has(path[0])) { + this.deoptimizePath([path[0]]); + } + return UNKNOWN_RETURN_EXPRESSION; + } + + includeArgumentPaths(entity: ExpressionEntity, context: InclusionContext) { + this.includedPathTracker.includeAllPaths(entity, context, this.initPath); + } +} diff --git a/src/ast/variables/PromiseHandler.ts b/src/ast/variables/PromiseHandler.ts new file mode 100644 index 00000000000..f17e67f12cc --- /dev/null +++ b/src/ast/variables/PromiseHandler.ts @@ -0,0 +1,71 @@ +import type { InclusionContext } from '../ExecutionContext'; +import type { NodeInteraction, NodeInteractionCalled } from '../NodeInteractions'; +import { INTERACTION_CALLED } from '../NodeInteractions'; +import { deoptimizeInteraction, includeInteractionWithoutThis } from '../nodes/shared/Expression'; +import { isArrowFunctionExpressionNode, isFunctionExpressionNode } from '../utils/identifyNode'; +import type { EntityPathTracker, ObjectPath } from '../utils/PathTracker'; +import type Variable from './Variable'; + +export interface PromiseHandler { + deoptimizeArgumentsOnInteractionAtPath( + interaction: NodeInteraction, + path: ObjectPath, + recursionTracker: EntityPathTracker + ): void; + + includeCallArguments(interaction: NodeInteractionCalled, context: InclusionContext): void; +} + +export class ObjectPromiseHandler implements PromiseHandler { + private readonly interaction: NodeInteractionCalled; + + constructor(resolvedVariable: Variable) { + this.interaction = { + args: [null, resolvedVariable], + type: INTERACTION_CALLED, + withNew: false + }; + } + + deoptimizeArgumentsOnInteractionAtPath( + interaction: NodeInteraction, + path: ObjectPath, + recursionTracker: EntityPathTracker + ) { + deoptimizeInteraction(interaction); + if ( + interaction.type === INTERACTION_CALLED && + path.length === 0 && + (isFunctionExpressionNode(interaction.args[1]) || + isArrowFunctionExpressionNode(interaction.args[1])) + ) { + interaction.args[1].deoptimizeArgumentsOnInteractionAtPath( + this.interaction, + [], + recursionTracker + ); + } + } + + includeCallArguments(interaction: NodeInteractionCalled, context: InclusionContext) { + // This includes the function call itself + includeInteractionWithoutThis(interaction, context); + if ( + interaction.type === INTERACTION_CALLED && + (isFunctionExpressionNode(interaction.args[1]) || + isArrowFunctionExpressionNode(interaction.args[1])) + ) { + interaction.args[1].includeCallArguments(this.interaction, context); + } + } +} + +export class EmptyPromiseHandler implements PromiseHandler { + deoptimizeArgumentsOnInteractionAtPath(interaction: NodeInteraction) { + deoptimizeInteraction(interaction); + } + + includeCallArguments(interaction: NodeInteractionCalled, context: InclusionContext) { + includeInteractionWithoutThis(interaction, context); + } +} diff --git a/src/ast/variables/SyntheticNamedExportVariable.ts b/src/ast/variables/SyntheticNamedExportVariable.ts index 61ab764ee8b..f6be3573ee1 100644 --- a/src/ast/variables/SyntheticNamedExportVariable.ts +++ b/src/ast/variables/SyntheticNamedExportVariable.ts @@ -1,12 +1,14 @@ -import Module, { AstContext } from '../../Module'; -import { RESERVED_NAMES } from '../../utils/reservedNames'; +import type Module from '../../Module'; +import type { AstContext } from '../../Module'; +import type { InclusionContext } from '../ExecutionContext'; +import { type ObjectPath } from '../utils/PathTracker'; import ExportDefaultVariable from './ExportDefaultVariable'; import Variable from './Variable'; export default class SyntheticNamedExportVariable extends Variable { - context: AstContext; - module: Module; - syntheticNamespace: Variable; + readonly context: AstContext; + readonly module: Module; + readonly syntheticNamespace: Variable; private baseVariable: Variable | null = null; @@ -40,25 +42,16 @@ export default class SyntheticNamedExportVariable extends Variable { return this.syntheticNamespace.getBaseVariableName(); } - getName(): string { - const name = this.name; - return `${this.syntheticNamespace.getName()}${getPropertyAccess(name)}`; + getName(getPropertyAccess: (name: string) => string): string { + return `${this.syntheticNamespace.getName(getPropertyAccess)}${getPropertyAccess(this.name)}`; } - include() { - if (!this.included) { - this.included = true; - this.context.includeVariableInModule(this.syntheticNamespace); - } + includePath(path: ObjectPath, context: InclusionContext): void { + super.includePath(path, context); + this.context.includeVariableInModule(this.syntheticNamespace, [this.name, ...path], context); } - setRenderNames(baseName: string | null, name: string | null) { + setRenderNames(baseName: string | null, name: string | null): void { super.setRenderNames(baseName, name); } } - -const getPropertyAccess = (name: string) => { - return !RESERVED_NAMES[name] && /^(?!\d)[\w$]+$/.test(name) - ? `.${name}` - : `[${JSON.stringify(name)}]`; -}; diff --git a/src/ast/variables/ThisVariable.ts b/src/ast/variables/ThisVariable.ts index b0fbe27e39a..b55b2c1f4b1 100644 --- a/src/ast/variables/ThisVariable.ts +++ b/src/ast/variables/ThisVariable.ts @@ -1,46 +1,22 @@ -import { AstContext } from '../../Module'; -import { CallOptions } from '../CallOptions'; -import { HasEffectsContext } from '../ExecutionContext'; -import { ExpressionEntity } from '../nodes/shared/Expression'; -import { ObjectPath } from '../utils/PathTracker'; -import { LiteralValueOrUnknown, UnknownValue, UNKNOWN_EXPRESSION } from '../values'; -import LocalVariable from './LocalVariable'; +import type { AstContext } from '../../Module'; +import type { HasEffectsContext } from '../ExecutionContext'; +import type { NodeInteraction } from '../NodeInteractions'; +import { UNKNOWN_EXPRESSION } from '../nodes/shared/Expression'; +import { EMPTY_PATH, type ObjectPath } from '../utils/PathTracker'; +import ParameterVariable from './ParameterVariable'; -export default class ThisVariable extends LocalVariable { +export default class ThisVariable extends ParameterVariable { constructor(context: AstContext) { - super('this', null, null, context); + super('this', null, EMPTY_PATH, context); } - getLiteralValueAtPath(): LiteralValueOrUnknown { - return UnknownValue; - } - - hasEffectsWhenAccessedAtPath(path: ObjectPath, context: HasEffectsContext) { - return ( - this.getInit(context).hasEffectsWhenAccessedAtPath(path, context) || - super.hasEffectsWhenAccessedAtPath(path, context) - ); - } - - hasEffectsWhenAssignedAtPath(path: ObjectPath, context: HasEffectsContext) { - return ( - this.getInit(context).hasEffectsWhenAssignedAtPath(path, context) || - super.hasEffectsWhenAssignedAtPath(path, context) - ); - } - - hasEffectsWhenCalledAtPath( + hasEffectsOnInteractionAtPath( path: ObjectPath, - callOptions: CallOptions, + interaction: NodeInteraction, context: HasEffectsContext - ) { + ): boolean { return ( - this.getInit(context).hasEffectsWhenCalledAtPath(path, callOptions, context) || - super.hasEffectsWhenCalledAtPath(path, callOptions, context) - ); - } - - private getInit(context: HasEffectsContext): ExpressionEntity { - return context.replacedVariableInits.get(this) || UNKNOWN_EXPRESSION; + context.replacedVariableInits.get(this) || UNKNOWN_EXPRESSION + ).hasEffectsOnInteractionAtPath(path, interaction, context); } } diff --git a/src/ast/variables/UndefinedVariable.ts b/src/ast/variables/UndefinedVariable.ts index 32e45285abd..85d256321d4 100644 --- a/src/ast/variables/UndefinedVariable.ts +++ b/src/ast/variables/UndefinedVariable.ts @@ -1,4 +1,4 @@ -import { LiteralValueOrUnknown } from '../values'; +import type { LiteralValueOrUnknown } from '../nodes/shared/Expression'; import Variable from './Variable'; export default class UndefinedVariable extends Variable { diff --git a/src/ast/variables/Variable.ts b/src/ast/variables/Variable.ts index 9a3564ff4d7..319608171dc 100644 --- a/src/ast/variables/Variable.ts +++ b/src/ast/variables/Variable.ts @@ -1,106 +1,133 @@ -import ExternalModule from '../../ExternalModule'; -import Module from '../../Module'; -import { RESERVED_NAMES } from '../../utils/reservedNames'; -import { CallOptions } from '../CallOptions'; -import { DeoptimizableEntity } from '../DeoptimizableEntity'; -import { HasEffectsContext, InclusionContext } from '../ExecutionContext'; -import Identifier from '../nodes/Identifier'; +import type ExternalModule from '../../ExternalModule'; +import type Module from '../../Module'; +import type { RenderOptions } from '../../utils/renderHelpers'; +import type { HasEffectsContext, InclusionContext } from '../ExecutionContext'; +import type { NodeInteraction } from '../NodeInteractions'; +import { INTERACTION_ACCESSED } from '../NodeInteractions'; +import type CallExpression from '../nodes/CallExpression'; +import * as NodeType from '../nodes/NodeType'; import { ExpressionEntity } from '../nodes/shared/Expression'; -import { ExpressionNode } from '../nodes/shared/Node'; -import SpreadElement from '../nodes/SpreadElement'; -import { ObjectPath, PathTracker } from '../utils/PathTracker'; -import { LiteralValueOrUnknown, UnknownValue, UNKNOWN_EXPRESSION } from '../values'; +import type IdentifierBase from '../nodes/shared/IdentifierBase'; +import type { NodeBase } from '../nodes/shared/Node'; +import type { VariableKind } from '../nodes/shared/VariableKinds'; +import type { ObjectPath } from '../utils/PathTracker'; -export default class Variable implements ExpressionEntity { +export default class Variable extends ExpressionEntity { alwaysRendered = false; - included = false; + forbiddenNames: Set | null = null; + globalName: string | null = null; + initReached = false; isId = false; // both NamespaceVariable and ExternalVariable can be namespaces - isNamespace?: boolean; - isReassigned = false; - module?: Module | ExternalModule; - name: string; + declare isNamespace?: boolean; + kind: VariableKind | null = null; + declare module?: Module | ExternalModule; renderBaseName: string | null = null; renderName: string | null = null; - constructor(name: string) { - this.name = name; + private renderedLikeHoisted?: Variable; + + readonly isReassigned = false; + markReassigned() { + (this as { isReassigned: boolean }).isReassigned = true; + } + + constructor(public name: string) { + super(); } /** * Binds identifiers that reference this variable to this variable. * Necessary to be able to change variable names. */ - addReference(_identifier: Identifier) {} - - deoptimizePath(_path: ObjectPath) {} - - getBaseVariableName(): string { - return this.renderBaseName || this.renderName || this.name; - } + addReference(_identifier: IdentifierBase): void {} - getLiteralValueAtPath( - _path: ObjectPath, - _recursionTracker: PathTracker, - _origin: DeoptimizableEntity - ): LiteralValueOrUnknown { - return UnknownValue; + private onlyFunctionCallUsed = true; + /** + * Check if the identifier variable is only used as function call + * @returns true if the variable is only used as function call + */ + getOnlyFunctionCallUsed(): boolean { + return this.onlyFunctionCallUsed; } - getName(): string { - const name = this.renderName || this.name; - return this.renderBaseName - ? `${this.renderBaseName}${RESERVED_NAMES[name] ? `['${name}']` : `.${name}`}` - : name; + /** + * Collect the places where the identifier variable is used + * @param usedPlace Where the variable is used + */ + addUsedPlace(usedPlace: NodeBase): void { + const isFunctionCall = + usedPlace.parent.type === NodeType.CallExpression && + (usedPlace.parent as CallExpression).callee === usedPlace; + if (!isFunctionCall && usedPlace.parent.type !== NodeType.ExportDefaultDeclaration) { + this.onlyFunctionCallUsed = false; + } } - getReturnExpressionWhenCalledAtPath( - _path: ObjectPath, - _recursionTracker: PathTracker, - _origin: DeoptimizableEntity - ): ExpressionEntity { - return UNKNOWN_EXPRESSION; + /** + * Prevent this variable from being renamed to this name to avoid name + * collisions + */ + forbidName(name: string) { + (this.forbiddenNames ||= new Set()).add(name); } - hasEffectsWhenAccessedAtPath(path: ObjectPath, _context: HasEffectsContext) { - return path.length > 0; + getBaseVariableName(): string { + return ( + this.renderedLikeHoisted?.getBaseVariableName() || + this.renderBaseName || + this.renderName || + this.name + ); } - hasEffectsWhenAssignedAtPath(_path: ObjectPath, _context: HasEffectsContext) { - return true; + getName( + getPropertyAccess: (name: string) => string, + useOriginalName?: RenderOptions['useOriginalName'] + ): string { + if (this.globalName) { + return this.globalName; + } + if (useOriginalName?.(this)) { + return this.name; + } + if (this.renderedLikeHoisted) { + return this.renderedLikeHoisted.getName(getPropertyAccess, useOriginalName); + } + const name = this.renderName || this.name; + return this.renderBaseName ? `${this.renderBaseName}${getPropertyAccess(name)}` : name; } - hasEffectsWhenCalledAtPath( - _path: ObjectPath, - _callOptions: CallOptions, + hasEffectsOnInteractionAtPath( + path: ObjectPath, + { type }: NodeInteraction, _context: HasEffectsContext - ) { - return true; + ): boolean { + return type !== INTERACTION_ACCESSED || path.length > 0; } /** - * Marks this variable as being part of the bundle, which is usually the case when one of - * its identifiers becomes part of the bundle. Returns true if it has not been included - * previously. - * Once a variable is included, it should take care all its declarations are included. + * Marks this variable as being part of the bundle, which is usually the case + * when one of its identifiers becomes part of the bundle. Returns true if it + * has not been included previously. Once a variable is included, it should + * take care all its declarations are included. */ - include() { + includePath(path: ObjectPath, context: InclusionContext): void { this.included = true; + this.renderedLikeHoisted?.includePath(path, context); } - includeCallArguments(context: InclusionContext, args: (ExpressionNode | SpreadElement)[]): void { - for (const arg of args) { - arg.include(context, false); - } + /** + * Links the rendered name of this variable to another variable and includes + * this variable if the other variable is included. + */ + renderLikeHoisted(variable: Variable): void { + this.renderedLikeHoisted = variable; } - markCalledFromTryStatement() {} - - mayModifyThisWhenCalledAtPath(_path: ObjectPath, _recursionTracker: PathTracker) { - return true; - } + markCalledFromTryStatement(): void {} - setRenderNames(baseName: string | null, name: string | null) { + setRenderNames(baseName: string | null, name: string | null): void { this.renderBaseName = baseName; this.renderName = name; } diff --git a/src/browser-entry.ts b/src/browser-entry.ts index 228d6517e81..0691094e6f2 100644 --- a/src/browser-entry.ts +++ b/src/browser-entry.ts @@ -1,2 +1,4 @@ -export { default as rollup } from './rollup/rollup'; +import '../typings/package.json'; + export { version as VERSION } from 'package.json'; +export { defineConfig, default as rollup } from './rollup/rollup'; diff --git a/src/finalisers/amd.ts b/src/finalisers/amd.ts index 54130894f1b..923bc0f8af6 100644 --- a/src/finalisers/amd.ts +++ b/src/finalisers/amd.ts @@ -1,10 +1,10 @@ -import { Bundle as MagicStringBundle } from 'magic-string'; -import { NormalizedOutputOptions } from '../rollup/types'; -import { FinaliserOptions } from './index'; +import type { Bundle as MagicStringBundle } from 'magic-string'; +import type { NormalizedOutputOptions } from '../rollup/types'; +import type { FinaliserOptions } from './index'; import getCompleteAmdId from './shared/getCompleteAmdId'; import { getExportBlock, getNamespaceMarkers } from './shared/getExportBlock'; import getInteropBlock from './shared/getInteropBlock'; -import removeExtensionFromRelativeAmdId from './shared/removeExtensionFromRelativeAmdId'; +import updateExtensionForRelativeAmdId from './shared/updateExtensionForRelativeAmdId'; import warnOnBuiltins from './shared/warnOnBuiltins'; export default function amd( @@ -13,69 +13,67 @@ export default function amd( accessedGlobals, dependencies, exports, + hasDefaultExport, hasExports, id, - indentString: t, + indent: t, intro, isEntryFacade, isModuleFacade, namedExportsMode, + log, outro, - varOrConst, - warn + snippets }: FinaliserOptions, { amd, - compact, esModule, externalLiveBindings, freeze, + generatedCode: { symbols }, interop, - namespaceToStringTag, + reexportProtoFromExternal, strict }: NormalizedOutputOptions -) { - warnOnBuiltins(warn, dependencies); - const deps = dependencies.map(m => `'${removeExtensionFromRelativeAmdId(m.id)}'`); - const args = dependencies.map(m => m.name); - const n = compact ? '' : '\n'; - const s = compact ? '' : ';'; - const _ = compact ? '' : ' '; +): void { + warnOnBuiltins(log, dependencies); + const deps = dependencies.map( + m => `'${updateExtensionForRelativeAmdId(m.importPath, amd.forceJsExtensionForImports)}'` + ); + const parameters = dependencies.map(m => m.name); + const { n, getNonArrowFunctionIntro, _ } = snippets; - if (namedExportsMode && hasExports) { - args.unshift(`exports`); + if (hasExports && (namedExportsMode || exports[0]?.local === 'exports.default')) { + parameters.unshift(`exports`); deps.unshift(`'exports'`); } if (accessedGlobals.has('require')) { - args.unshift('require'); + parameters.unshift('require'); deps.unshift(`'require'`); } if (accessedGlobals.has('module')) { - args.unshift('module'); + parameters.unshift('module'); deps.unshift(`'module'`); } const completeAmdId = getCompleteAmdId(amd, id); - const params = + const defineParameters = (completeAmdId ? `'${completeAmdId}',${_}` : ``) + - (deps.length ? `[${deps.join(`,${_}`)}],${_}` : ``); + (deps.length > 0 ? `[${deps.join(`,${_}`)}],${_}` : ``); const useStrict = strict ? `${_}'use strict';` : ''; magicString.prepend( `${intro}${getInteropBlock( dependencies, - varOrConst, interop, externalLiveBindings, freeze, - namespaceToStringTag, + symbols, accessedGlobals, - _, - n, - s, - t + t, + snippets )}` ); @@ -84,23 +82,30 @@ export default function amd( dependencies, namedExportsMode, interop, - compact, + snippets, t, - externalLiveBindings + externalLiveBindings, + reexportProtoFromExternal ); let namespaceMarkers = getNamespaceMarkers( namedExportsMode && hasExports, - isEntryFacade && esModule, - isModuleFacade && namespaceToStringTag, - _, - n + isEntryFacade && (esModule === true || (esModule === 'if-default-prop' && hasDefaultExport)), + isModuleFacade && symbols, + snippets ); if (namespaceMarkers) { namespaceMarkers = n + n + namespaceMarkers; } - magicString.append(`${exportBlock}${namespaceMarkers}${outro}`); - return magicString + magicString + .append(`${exportBlock}${namespaceMarkers}${outro}`) .indent(t) - .prepend(`${amd.define}(${params}function${_}(${args.join(`,${_}`)})${_}{${useStrict}${n}${n}`) - .append(`${n}${n}});`); + // factory function should be wrapped by parentheses to avoid lazy parsing, + // cf. https://v8.dev/blog/preparser#pife + .prepend( + `${amd.define}(${defineParameters}(${getNonArrowFunctionIntro(parameters, { + isAsync: false, + name: null + })}{${useStrict}${n}${n}` + ) + .append(`${n}${n}}));`); } diff --git a/src/finalisers/cjs.ts b/src/finalisers/cjs.ts index 9d341426a85..7660867c573 100644 --- a/src/finalisers/cjs.ts +++ b/src/finalisers/cjs.ts @@ -1,7 +1,8 @@ -import { Bundle as MagicStringBundle } from 'magic-string'; -import { ChunkDependencies } from '../Chunk'; -import { NormalizedOutputOptions } from '../rollup/types'; -import { FinaliserOptions } from './index'; +import type { Bundle as MagicStringBundle } from 'magic-string'; +import type { ChunkDependency } from '../Chunk'; +import type { NormalizedOutputOptions } from '../rollup/types'; +import type { GenerateCodeSnippets } from '../utils/generateCodeSnippets'; +import type { FinaliserOptions } from './index'; import { getExportBlock, getNamespaceMarkers } from './shared/getExportBlock'; import getInteropBlock from './shared/getInteropBlock'; @@ -11,14 +12,15 @@ export default function cjs( accessedGlobals, dependencies, exports, + hasDefaultExport, hasExports, - indentString: t, + indent: t, intro, isEntryFacade, isModuleFacade, namedExportsMode, outro, - varOrConst + snippets }: FinaliserOptions, { compact, @@ -26,38 +28,33 @@ export default function cjs( externalLiveBindings, freeze, interop, - namespaceToStringTag, + generatedCode: { symbols }, + reexportProtoFromExternal, strict }: NormalizedOutputOptions -) { - const n = compact ? '' : '\n'; - const s = compact ? '' : ';'; - const _ = compact ? '' : ' '; +): void { + const { _, n } = snippets; const useStrict = strict ? `'use strict';${n}${n}` : ''; let namespaceMarkers = getNamespaceMarkers( namedExportsMode && hasExports, - isEntryFacade && esModule, - isModuleFacade && namespaceToStringTag, - _, - n + isEntryFacade && (esModule === true || (esModule === 'if-default-prop' && hasDefaultExport)), + isModuleFacade && symbols, + snippets ); if (namespaceMarkers) { namespaceMarkers += n + n; } - const importBlock = getImportBlock(dependencies, compact, varOrConst, n, _); + const importBlock = getImportBlock(dependencies, snippets, compact); const interopBlock = getInteropBlock( dependencies, - varOrConst, interop, externalLiveBindings, freeze, - namespaceToStringTag, + symbols, accessedGlobals, - _, - n, - s, - t + t, + snippets ); magicString.prepend(`${useStrict}${intro}${namespaceMarkers}${importBlock}${interopBlock}`); @@ -67,36 +64,34 @@ export default function cjs( dependencies, namedExportsMode, interop, - compact, + snippets, t, externalLiveBindings, + reexportProtoFromExternal, `module.exports${_}=${_}` ); - return magicString.append(`${exportBlock}${outro}`); + magicString.append(`${exportBlock}${outro}`); } function getImportBlock( - dependencies: ChunkDependencies, - compact: boolean, - varOrConst: string, - n: string, - _: string + dependencies: readonly ChunkDependency[], + { _, cnst, n }: GenerateCodeSnippets, + compact: boolean ): string { let importBlock = ''; let definingVariable = false; - for (const { id, name, reexports, imports } of dependencies) { + for (const { importPath, name, reexports, imports } of dependencies) { if (!reexports && !imports) { if (importBlock) { - importBlock += !compact || definingVariable ? `;${n}` : ','; + importBlock += compact && !definingVariable ? ',' : `;${n}`; } definingVariable = false; - importBlock += `require('${id}')`; + importBlock += `require('${importPath}')`; } else { - importBlock += - compact && definingVariable ? ',' : `${importBlock ? `;${n}` : ''}${varOrConst} `; + importBlock += compact && definingVariable ? ',' : `${importBlock ? `;${n}` : ''}${cnst} `; definingVariable = true; - importBlock += `${name}${_}=${_}require('${id}')`; + importBlock += `${name}${_}=${_}require('${importPath}')`; } } if (importBlock) { diff --git a/src/finalisers/es.ts b/src/finalisers/es.ts index fea9e2a5cdc..960f8ea7bdf 100644 --- a/src/finalisers/es.ts +++ b/src/finalisers/es.ts @@ -1,32 +1,54 @@ -import { Bundle as MagicStringBundle } from 'magic-string'; -import { ChunkDependencies, ChunkExports, ImportSpecifier, ReexportSpecifier } from '../Chunk'; -import { NormalizedOutputOptions } from '../rollup/types'; -import { FinaliserOptions } from './index'; +import type { Bundle as MagicStringBundle } from 'magic-string'; +import type { ChunkDependency, ChunkExports, ImportSpecifier, ReexportSpecifier } from '../Chunk'; +import type { ImportAttributesKey, NormalizedOutputOptions } from '../rollup/types'; +import type { GenerateCodeSnippets } from '../utils/generateCodeSnippets'; +import { stringifyIdentifierIfNeeded } from '../utils/identifierHelpers'; +import { getHelpersBlock } from '../utils/interopHelpers'; +import type { FinaliserOptions } from './index'; export default function es( magicString: MagicStringBundle, - { intro, outro, dependencies, exports, varOrConst }: FinaliserOptions, - { compact }: NormalizedOutputOptions -) { - const _ = compact ? '' : ' '; - const n = compact ? '' : '\n'; + { accessedGlobals, indent: t, intro, outro, dependencies, exports, snippets }: FinaliserOptions, + { + externalLiveBindings, + freeze, + generatedCode: { symbols }, + importAttributesKey + }: NormalizedOutputOptions +): void { + const { n } = snippets; - const importBlock = getImportBlock(dependencies, _); + const importBlock = getImportBlock(dependencies, importAttributesKey, snippets); if (importBlock.length > 0) intro += importBlock.join(n) + n + n; + intro += getHelpersBlock( + null, + accessedGlobals, + t, + snippets, + externalLiveBindings, + freeze, + symbols + ); if (intro) magicString.prepend(intro); - const exportBlock = getExportBlock(exports, _, varOrConst); - if (exportBlock.length) magicString.append(n + n + exportBlock.join(n).trim()); + const exportBlock = getExportBlock(exports, snippets); + if (exportBlock.length > 0) magicString.append(n + n + exportBlock.join(n).trim()); if (outro) magicString.append(outro); - return magicString.trim(); + magicString.trim(); } -function getImportBlock(dependencies: ChunkDependencies, _: string): string[] { +function getImportBlock( + dependencies: readonly ChunkDependency[], + importAttributesKey: ImportAttributesKey, + { _ }: GenerateCodeSnippets +): string[] { const importBlock: string[] = []; - for (const { id, reexports, imports, name } of dependencies) { + for (const { importPath, reexports, imports, name, attributes } of dependencies) { + const assertion = attributes ? `${_}${importAttributesKey}${_}${attributes}` : ''; + const pathWithAssertion = `'${importPath}'${assertion};`; if (!reexports && !imports) { - importBlock.push(`import${_}'${id}';`); + importBlock.push(`import${_}${pathWithAssertion}`); continue; } if (imports) { @@ -43,21 +65,19 @@ function getImportBlock(dependencies: ChunkDependencies, _: string): string[] { } } if (starImport) { - importBlock.push(`import${_}*${_}as ${starImport.local} from${_}'${id}';`); + importBlock.push(`import${_}*${_}as ${starImport.local} from${_}${pathWithAssertion}`); } if (defaultImport && importedNames.length === 0) { - importBlock.push(`import ${defaultImport.local} from${_}'${id}';`); + importBlock.push(`import ${defaultImport.local} from${_}${pathWithAssertion}`); } else if (importedNames.length > 0) { importBlock.push( `import ${defaultImport ? `${defaultImport.local},${_}` : ''}{${_}${importedNames - .map(specifier => { - if (specifier.imported === specifier.local) { - return specifier.imported; - } else { - return `${specifier.imported} as ${specifier.local}`; - } - }) - .join(`,${_}`)}${_}}${_}from${_}'${id}';` + .map(specifier => + specifier.imported === specifier.local + ? specifier.imported + : `${stringifyIdentifierIfNeeded(specifier.imported)} as ${specifier.local}` + ) + .join(`,${_}`)}${_}}${_}from${_}${pathWithAssertion}` ); } } @@ -75,19 +95,21 @@ function getImportBlock(dependencies: ChunkDependencies, _: string): string[] { } } if (starExport) { - importBlock.push(`export${_}*${_}from${_}'${id}';`); + importBlock.push(`export${_}*${_}from${_}${pathWithAssertion}`); } if (namespaceReexports.length > 0) { if ( !imports || !imports.some(specifier => specifier.imported === '*' && specifier.local === name) ) { - importBlock.push(`import${_}*${_}as ${name} from${_}'${id}';`); + importBlock.push(`import${_}*${_}as ${name} from${_}${pathWithAssertion}`); } for (const specifier of namespaceReexports) { importBlock.push( `export${_}{${_}${ - name === specifier.reexported ? name : `${name} as ${specifier.reexported}` + name === specifier.reexported + ? name + : `${name} as ${stringifyIdentifierIfNeeded(specifier.reexported)}` } };` ); } @@ -95,14 +117,14 @@ function getImportBlock(dependencies: ChunkDependencies, _: string): string[] { if (namedReexports.length > 0) { importBlock.push( `export${_}{${_}${namedReexports - .map(specifier => { - if (specifier.imported === specifier.reexported) { - return specifier.imported; - } else { - return `${specifier.imported} as ${specifier.reexported}`; - } - }) - .join(`,${_}`)}${_}}${_}from${_}'${id}';` + .map(specifier => + specifier.imported === specifier.reexported + ? stringifyIdentifierIfNeeded(specifier.imported) + : `${stringifyIdentifierIfNeeded( + specifier.imported + )} as ${stringifyIdentifierIfNeeded(specifier.reexported)}` + ) + .join(`,${_}`)}${_}}${_}from${_}${pathWithAssertion}` ); } } @@ -110,24 +132,20 @@ function getImportBlock(dependencies: ChunkDependencies, _: string): string[] { return importBlock; } -function getExportBlock(exports: ChunkExports, _: string, varOrConst: string): string[] { +function getExportBlock(exports: ChunkExports, { _, cnst }: GenerateCodeSnippets): string[] { const exportBlock: string[] = []; - const exportDeclaration: string[] = []; + const exportDeclaration: string[] = new Array(exports.length); + let index = 0; for (const specifier of exports) { - if (specifier.exported === 'default') { - exportBlock.push(`export default ${specifier.local};`); - } else { - if (specifier.expression) { - exportBlock.push(`${varOrConst} ${specifier.local}${_}=${_}${specifier.expression};`); - } - exportDeclaration.push( - specifier.exported === specifier.local - ? specifier.local - : `${specifier.local} as ${specifier.exported}` - ); + if (specifier.expression) { + exportBlock.push(`${cnst} ${specifier.local}${_}=${_}${specifier.expression};`); } + exportDeclaration[index++] = + specifier.exported === specifier.local + ? specifier.local + : `${specifier.local} as ${stringifyIdentifierIfNeeded(specifier.exported)}`; } - if (exportDeclaration.length) { + if (exportDeclaration.length > 0) { exportBlock.push(`export${_}{${_}${exportDeclaration.join(`,${_}`)}${_}};`); } return exportBlock; diff --git a/src/finalisers/iife.ts b/src/finalisers/iife.ts index 75910845073..93a206511c0 100644 --- a/src/finalisers/iife.ts +++ b/src/finalisers/iife.ts @@ -1,8 +1,13 @@ -import { Bundle as MagicStringBundle } from 'magic-string'; -import { NormalizedOutputOptions } from '../rollup/types'; -import { error } from '../utils/error'; +import type { Bundle as MagicStringBundle } from 'magic-string'; +import type { NormalizedOutputOptions } from '../rollup/types'; import { isLegal } from '../utils/identifierHelpers'; -import { FinaliserOptions } from './index'; +import { LOGLEVEL_WARN } from '../utils/logging'; +import { + error, + logIllegalIdentifierAsName, + logMissingNameOptionForIifeExport +} from '../utils/logs'; +import type { FinaliserOptions } from './index'; import { getExportBlock, getNamespaceMarkers } from './shared/getExportBlock'; import getInteropBlock from './shared/getInteropBlock'; import { keypath } from './shared/sanitize'; @@ -10,21 +15,20 @@ import setupNamespace from './shared/setupNamespace'; import trimEmptyImports from './shared/trimEmptyImports'; import warnOnBuiltins from './shared/warnOnBuiltins'; -const thisProp = (name: string) => `this${keypath(name)}`; - export default function iife( magicString: MagicStringBundle, { accessedGlobals, dependencies, exports, + hasDefaultExport, hasExports, - indentString: t, + indent: t, intro, namedExportsMode, + log, outro, - varOrConst, - warn + snippets }: FinaliserOptions, { compact, @@ -32,79 +36,76 @@ export default function iife( extend, freeze, externalLiveBindings, + reexportProtoFromExternal, globals, interop, name, - namespaceToStringTag, + generatedCode: { symbols }, strict }: NormalizedOutputOptions -) { - const _ = compact ? '' : ' '; - const s = compact ? '' : ';'; - const n = compact ? '' : '\n'; - - const isNamespaced = name && name.indexOf('.') !== -1; +): void { + const { _, getNonArrowFunctionIntro, getPropertyAccess, n } = snippets; + const isNamespaced = name && name.includes('.'); const useVariableAssignment = !extend && !isNamespaced; if (name && useVariableAssignment && !isLegal(name)) { - return error({ - code: 'ILLEGAL_IDENTIFIER_AS_NAME', - message: `Given name "${name}" is not a legal JS identifier. If you need this, you can try "output.extend: true".` - }); + return error(logIllegalIdentifierAsName(name)); } - warnOnBuiltins(warn, dependencies); + warnOnBuiltins(log, dependencies); const external = trimEmptyImports(dependencies); const deps = external.map(dep => dep.globalName || 'null'); - const args = external.map(m => m.name); + const parameters = external.map(m => m.name); if (hasExports && !name) { - warn({ - code: 'MISSING_NAME_OPTION_FOR_IIFE_EXPORT', - message: `If you do not supply "output.name", you may not be able to access the exports of an IIFE bundle.` - }); + log(LOGLEVEL_WARN, logMissingNameOptionForIifeExport()); } - if (namedExportsMode && hasExports) { + if (hasExports && (namedExportsMode || exports[0]?.local === 'exports.default')) { if (extend) { - deps.unshift(`${thisProp(name!)}${_}=${_}${thisProp(name!)}${_}||${_}{}`); - args.unshift('exports'); + deps.unshift( + `this${keypath(name!, getPropertyAccess)}${_}=${_}this${keypath( + name!, + getPropertyAccess + )}${_}||${_}{}` + ); + parameters.unshift('exports'); } else { deps.unshift('{}'); - args.unshift('exports'); + parameters.unshift('exports'); } } const useStrict = strict ? `${t}'use strict';${n}` : ''; const interopBlock = getInteropBlock( dependencies, - varOrConst, interop, externalLiveBindings, freeze, - namespaceToStringTag, + symbols, accessedGlobals, - _, - n, - s, - t + t, + snippets ); magicString.prepend(`${intro}${interopBlock}`); - let wrapperIntro = `(function${_}(${args.join(`,${_}`)})${_}{${n}${useStrict}${n}`; + let wrapperIntro = `(${getNonArrowFunctionIntro(parameters, { + isAsync: false, + name: null + })}{${n}${useStrict}${n}`; if (hasExports) { if (name && !(extend && namedExportsMode)) { wrapperIntro = - (useVariableAssignment ? `${varOrConst} ${name}` : thisProp(name)) + + (useVariableAssignment ? `var ${name}` : `this${keypath(name, getPropertyAccess)}`) + `${_}=${_}${wrapperIntro}`; } if (isNamespaced) { - wrapperIntro = setupNamespace(name!, 'this', globals, compact) + wrapperIntro; + wrapperIntro = setupNamespace(name!, 'this', globals, snippets, compact, log) + wrapperIntro; } } - let wrapperOutro = `${n}${n}}(${deps.join(`,${_}`)}));`; + let wrapperOutro = `${n}${n}})(${deps.join(`,${_}`)});`; if (hasExports && !extend && namedExportsMode) { wrapperOutro = `${n}${n}${t}return exports;${wrapperOutro}`; } @@ -114,20 +115,23 @@ export default function iife( dependencies, namedExportsMode, interop, - compact, + snippets, t, - externalLiveBindings + externalLiveBindings, + reexportProtoFromExternal ); let namespaceMarkers = getNamespaceMarkers( namedExportsMode && hasExports, - esModule, - namespaceToStringTag, - _, - n + esModule === true || (esModule === 'if-default-prop' && hasDefaultExport), + symbols, + snippets ); if (namespaceMarkers) { namespaceMarkers = n + n + namespaceMarkers; } - magicString.append(`${exportBlock}${namespaceMarkers}${outro}`); - return magicString.indent(t).prepend(wrapperIntro).append(wrapperOutro); + magicString + .append(`${exportBlock}${namespaceMarkers}${outro}`) + .indent(t) + .prepend(wrapperIntro) + .append(wrapperOutro); } diff --git a/src/finalisers/index.ts b/src/finalisers/index.ts index 2ef9f66fff2..f27e8213d67 100644 --- a/src/finalisers/index.ts +++ b/src/finalisers/index.ts @@ -1,6 +1,7 @@ -import { Bundle as MagicStringBundle } from 'magic-string'; -import { ChunkDependencies, ChunkExports } from '../Chunk'; -import { NormalizedOutputOptions, RollupWarning } from '../rollup/types'; +import type { Bundle as MagicStringBundle } from 'magic-string'; +import type { ChunkDependency, ChunkExports } from '../Chunk'; +import type { LogHandler, NormalizedOutputOptions } from '../rollup/types'; +import type { GenerateCodeSnippets } from '../utils/generateCodeSnippets'; import amd from './amd'; import cjs from './cjs'; import es from './es'; @@ -10,27 +11,26 @@ import umd from './umd'; export interface FinaliserOptions { accessedGlobals: Set; - dependencies: ChunkDependencies; + dependencies: ChunkDependency[]; exports: ChunkExports; + hasDefaultExport: boolean; hasExports: boolean; id: string; - indentString: string; + indent: string; intro: string; isEntryFacade: boolean; isModuleFacade: boolean; + log: LogHandler; namedExportsMode: boolean; outro: string; + snippets: GenerateCodeSnippets; usesTopLevelAwait: boolean; - varOrConst: 'var' | 'const'; - warn(warning: RollupWarning): void; } export type Finaliser = ( magicString: MagicStringBundle, finaliserOptions: FinaliserOptions, options: NormalizedOutputOptions -) => MagicStringBundle; +) => void; -export default { system, amd, cjs, es, iife, umd } as { - [format: string]: Finaliser; -}; +export default { amd, cjs, es, iife, system, umd } as Record; diff --git a/src/finalisers/shared/addJsExtension.ts b/src/finalisers/shared/addJsExtension.ts new file mode 100644 index 00000000000..4c483d935ee --- /dev/null +++ b/src/finalisers/shared/addJsExtension.ts @@ -0,0 +1,3 @@ +export default function addJsExtension(name: string): string { + return name.endsWith('.js') ? name : name + '.js'; +} diff --git a/src/finalisers/shared/getCompleteAmdId.ts b/src/finalisers/shared/getCompleteAmdId.ts index 5143afa8ce2..c6fb4d0074e 100644 --- a/src/finalisers/shared/getCompleteAmdId.ts +++ b/src/finalisers/shared/getCompleteAmdId.ts @@ -1,13 +1,13 @@ -import { NormalizedOutputOptions } from '../../rollup/types'; +import type { NormalizedOutputOptions } from '../../rollup/types'; import removeJsExtension from './removeJsExtension'; export default function getCompleteAmdId( options: NormalizedOutputOptions['amd'], chunkId: string ): string { - if (!options.autoId) { - return options.id || ''; - } else { + if (options.autoId) { return `${options.basePath ? options.basePath + '/' : ''}${removeJsExtension(chunkId)}`; } + + return options.id ?? ''; } diff --git a/src/finalisers/shared/getExportBlock.ts b/src/finalisers/shared/getExportBlock.ts index 48021fab475..ace7046c257 100644 --- a/src/finalisers/shared/getExportBlock.ts +++ b/src/finalisers/shared/getExportBlock.ts @@ -1,44 +1,51 @@ -import { ChunkDependencies, ChunkExports } from '../../Chunk'; -import { GetInterop } from '../../rollup/types'; +import type { ChunkDependency, ChunkExports } from '../../Chunk'; +import type { GetInterop } from '../../rollup/types'; +import type { GenerateCodeSnippets } from '../../utils/generateCodeSnippets'; import { defaultInteropHelpersByInteropType, + getToStringTagValue, isDefaultAProperty, namespaceInteropHelpersByInteropType } from '../../utils/interopHelpers'; export function getExportBlock( exports: ChunkExports, - dependencies: ChunkDependencies, + dependencies: readonly ChunkDependency[], namedExportsMode: boolean, interop: GetInterop, - compact: boolean | undefined, + snippets: GenerateCodeSnippets, t: string, externalLiveBindings: boolean, + reexportProtoFromExternal: boolean, mechanism = 'return ' -) { - const _ = compact ? '' : ' '; - const n = compact ? '' : '\n'; +): string { + const { _, getDirectReturnFunction, getFunctionIntro, getPropertyAccess, n, s } = snippets; if (!namedExportsMode) { return `${n}${n}${mechanism}${getSingleDefaultExport( exports, dependencies, interop, - externalLiveBindings + externalLiveBindings, + getPropertyAccess )};`; } let exportBlock = ''; - for (const { - defaultVariableName, - id, - isChunk, - name, - namedExportsMode: depNamedExportsMode, - namespaceVariableName, - reexports - } of dependencies) { - if (reexports && namedExportsMode) { + if (namedExportsMode) { + for (const { + defaultVariableName, + importPath, + isChunk, + name, + namedExportsMode: depNamedExportsMode, + namespaceVariableName, + reexports + } of dependencies) { + if (!reexports) { + continue; + } + for (const specifier of reexports) { if (specifier.reexported !== '*') { const importName = getReexportedImportName( @@ -49,49 +56,80 @@ export function getExportBlock( defaultVariableName!, namespaceVariableName!, interop, - id, - externalLiveBindings + importPath, + externalLiveBindings, + getPropertyAccess ); if (exportBlock) exportBlock += n; - exportBlock += - specifier.imported !== '*' && specifier.needsLiveBinding - ? `Object.defineProperty(exports,${_}'${specifier.reexported}',${_}{${n}` + - `${t}enumerable:${_}true,${n}` + - `${t}get:${_}function${_}()${_}{${n}` + - `${t}${t}return ${importName};${n}${t}}${n}});` - : `exports.${specifier.reexported}${_}=${_}${importName};`; + if (specifier.imported !== '*' && specifier.needsLiveBinding) { + const [left, right] = getDirectReturnFunction([], { + functionReturn: true, + lineBreakIndent: null, + name: null + }); + exportBlock += + `Object.defineProperty(exports,${_}${JSON.stringify( + specifier.reexported + )},${_}{${n}` + + `${t}enumerable:${_}true,${n}` + + `${t}get:${_}${left}${importName}${right}${n}});`; + } else if (specifier.reexported === '__proto__') { + exportBlock += + `Object.defineProperty(exports,${_}"__proto__",${_}{${n}` + + `${t}enumerable:${_}true,${n}` + + `${t}value:${_}${importName}${n}});`; + } else { + exportBlock += `exports${getPropertyAccess( + specifier.reexported + )}${_}=${_}${importName};`; + } } } } } - for (const chunkExport of exports) { - const lhs = `exports.${chunkExport.exported}`; - const rhs = chunkExport.local; + for (const { exported, local } of exports) { + const lhs = `exports${getPropertyAccess(exported)}`; + const rhs = local; if (lhs !== rhs) { if (exportBlock) exportBlock += n; - exportBlock += `${lhs}${_}=${_}${rhs};`; + exportBlock += + exported === '__proto__' + ? `Object.defineProperty(exports,${_}"__proto__",${_}{${n}` + + `${t}enumerable:${_}true,${n}` + + `${t}value:${_}${rhs}${n}});` + : `${lhs}${_}=${_}${rhs};`; } } - for (const { name, reexports } of dependencies) { - if (reexports && namedExportsMode) { + if (namedExportsMode) { + for (const { name, reexports } of dependencies) { + if (!reexports) { + continue; + } for (const specifier of reexports) { if (specifier.reexported === '*') { if (exportBlock) exportBlock += n; - if (specifier.needsLiveBinding) { + if (!specifier.needsLiveBinding && reexportProtoFromExternal) { + const protoString = "'__proto__'"; exportBlock += - `Object.keys(${name}).forEach(function${_}(k)${_}{${n}` + - `${t}if${_}(k${_}!==${_}'default'${_}&&${_}!exports.hasOwnProperty(k))${_}Object.defineProperty(exports,${_}k,${_}{${n}` + + `Object.prototype.hasOwnProperty.call(${name},${_}${protoString})${_}&&${n}` + + `${t}!Object.prototype.hasOwnProperty.call(exports,${_}${protoString})${_}&&${n}` + + `${t}Object.defineProperty(exports,${_}${protoString},${_}{${n}` + `${t}${t}enumerable:${_}true,${n}` + - `${t}${t}get:${_}function${_}()${_}{${n}` + - `${t}${t}${t}return ${name}[k];${n}` + - `${t}${t}}${n}${t}});${n}});`; - } else { - exportBlock += - `Object.keys(${name}).forEach(function${_}(k)${_}{${n}` + - `${t}if${_}(k${_}!==${_}'default'${_}&&${_}!exports.hasOwnProperty(k))${_}exports[k]${_}=${_}${name}[k];${n}});`; + `${t}${t}value:${_}${name}[${protoString}]${n}` + + `${t}});${n}${n}`; } + const copyPropertyIfNecessary = `{${n}${t}if${_}(k${_}!==${_}'default'${_}&&${_}!Object.prototype.hasOwnProperty.call(exports,${_}k))${_}${getDefineProperty( + name, + specifier.needsLiveBinding, + t, + snippets + )}${s}${n}}`; + exportBlock += `Object.keys(${name}).forEach(${getFunctionIntro(['k'], { + isAsync: false, + name: null + })}${copyPropertyIfNecessary});`; } } } @@ -106,16 +144,17 @@ export function getExportBlock( function getSingleDefaultExport( exports: ChunkExports, - dependencies: ChunkDependencies, + dependencies: readonly ChunkDependency[], interop: GetInterop, - externalLiveBindings: boolean + externalLiveBindings: boolean, + getPropertyAccess: (name: string) => string ) { if (exports.length > 0) { return exports[0].local; } else { for (const { defaultVariableName, - id, + importPath, isChunk, name, namedExportsMode: depNamedExportsMode, @@ -131,8 +170,9 @@ function getSingleDefaultExport( defaultVariableName!, namespaceVariableName!, interop, - id, - externalLiveBindings + importPath, + externalLiveBindings, + getPropertyAccess ); } } @@ -148,58 +188,86 @@ function getReexportedImportName( namespaceVariableName: string, interop: GetInterop, moduleId: string, - externalLiveBindings: boolean + externalLiveBindings: boolean, + getPropertyAccess: (name: string) => string ) { if (imported === 'default') { if (!isChunk) { - const moduleInterop = String(interop(moduleId)); + const moduleInterop = interop(moduleId); const variableName = defaultInteropHelpersByInteropType[moduleInterop] ? defaultVariableName : moduleVariableName; return isDefaultAProperty(moduleInterop, externalLiveBindings) - ? `${variableName}['default']` + ? `${variableName}${getPropertyAccess('default')}` : variableName; } - return depNamedExportsMode ? `${moduleVariableName}['default']` : moduleVariableName; + return depNamedExportsMode + ? `${moduleVariableName}${getPropertyAccess('default')}` + : moduleVariableName; } if (imported === '*') { return ( - isChunk - ? !depNamedExportsMode - : namespaceInteropHelpersByInteropType[String(interop(moduleId))] + isChunk ? !depNamedExportsMode : namespaceInteropHelpersByInteropType[interop(moduleId)] ) ? namespaceVariableName : moduleVariableName; } - return `${moduleVariableName}.${imported}`; -} - -function getEsModuleExport(_: string): string { - return `Object.defineProperty(exports,${_}'__esModule',${_}{${_}value:${_}true${_}});`; + return `${moduleVariableName}${getPropertyAccess(imported)}`; } -function getNamespaceToStringExport(_: string): string { - return `exports[Symbol.toStringTag]${_}=${_}'Module';`; +function getEsModuleValue(getObject: GenerateCodeSnippets['getObject']) { + return getObject([['value', 'true']], { + lineBreakIndent: null + }); } export function getNamespaceMarkers( hasNamedExports: boolean, addEsModule: boolean, addNamespaceToStringTag: boolean, - _: string, - n: string + { _, getObject }: GenerateCodeSnippets ): string { - let namespaceMarkers = ''; if (hasNamedExports) { if (addEsModule) { - namespaceMarkers += getEsModuleExport(_); + if (addNamespaceToStringTag) { + return `Object.defineProperties(exports,${_}${getObject( + [ + ['__esModule', getEsModuleValue(getObject)], + [null, `[Symbol.toStringTag]:${_}${getToStringTagValue(getObject)}`] + ], + { + lineBreakIndent: null + } + )});`; + } + return `Object.defineProperty(exports,${_}'__esModule',${_}${getEsModuleValue(getObject)});`; } if (addNamespaceToStringTag) { - if (namespaceMarkers) { - namespaceMarkers += n; - } - namespaceMarkers += getNamespaceToStringExport(_); + return `Object.defineProperty(exports,${_}Symbol.toStringTag,${_}${getToStringTagValue( + getObject + )});`; } } - return namespaceMarkers; + return ''; } + +const getDefineProperty = ( + name: string, + needsLiveBinding: boolean, + t: string, + { _, getDirectReturnFunction, n }: GenerateCodeSnippets +) => { + if (needsLiveBinding) { + const [left, right] = getDirectReturnFunction([], { + functionReturn: true, + lineBreakIndent: null, + name: null + }); + return ( + `Object.defineProperty(exports,${_}k,${_}{${n}` + + `${t}${t}enumerable:${_}true,${n}` + + `${t}${t}get:${_}${left}${name}[k]${right}${n}${t}})` + ); + } + return `exports[k]${_}=${_}${name}[k]`; +}; diff --git a/src/finalisers/shared/getInteropBlock.ts b/src/finalisers/shared/getInteropBlock.ts index 0231eb1c682..374f89746db 100644 --- a/src/finalisers/shared/getInteropBlock.ts +++ b/src/finalisers/shared/getInteropBlock.ts @@ -1,25 +1,24 @@ -import { ModuleDeclarationDependency, ReexportSpecifier } from '../../Chunk'; -import { GetInterop } from '../../rollup/types'; +import type { ChunkDependency, ReexportSpecifier } from '../../Chunk'; +import type { GetInterop } from '../../rollup/types'; +import type { GenerateCodeSnippets } from '../../utils/generateCodeSnippets'; import { defaultInteropHelpersByInteropType, - getDefaultOnlyHelper, getHelpersBlock, + INTEROP_NAMESPACE_DEFAULT_ONLY_VARIABLE, namespaceInteropHelpersByInteropType } from '../../utils/interopHelpers'; export default function getInteropBlock( - dependencies: ModuleDeclarationDependency[], - varOrConst: string, + dependencies: readonly ChunkDependency[], interop: GetInterop, externalLiveBindings: boolean, freeze: boolean, - namespaceToStringTag: boolean, + symbols: boolean, accessedGlobals: Set, - _: string, - n: string, - s: string, - t: string + indent: string, + snippets: GenerateCodeSnippets ): string { + const { _, cnst, n } = snippets; const neededInteropHelpers = new Set(); const interopStatements: string[] = []; const addInteropStatement = ( @@ -29,13 +28,13 @@ export default function getInteropBlock( ): void => { neededInteropHelpers.add(helper); interopStatements.push( - `${varOrConst} ${helperVariableName}${_}=${_}/*#__PURE__*/${helper}(${dependencyVariableName});` + `${cnst} ${helperVariableName}${_}=${_}/*#__PURE__*/${helper}(${dependencyVariableName});` ); }; for (const { defaultVariableName, imports, - id, + importPath, isChunk, name, namedExportsMode, @@ -49,13 +48,17 @@ export default function getInteropBlock( ] as ReexportSpecifier[]) { if (imported === '*' && reexported !== '*') { if (!namedExportsMode) { - addInteropStatement(namespaceVariableName!, getDefaultOnlyHelper(), name); + addInteropStatement( + namespaceVariableName!, + INTEROP_NAMESPACE_DEFAULT_ONLY_VARIABLE, + name + ); } break; } } } else { - const moduleInterop = String(interop(id)); + const moduleInterop = interop(importPath); let hasDefault = false; let hasNamespace = false; for (const { imported, reexported } of [ @@ -72,12 +75,10 @@ export default function getInteropBlock( helper = defaultInteropHelpersByInteropType[moduleInterop]; } } - } else if (imported === '*' && reexported !== '*') { - if (!hasNamespace) { - hasNamespace = true; - helper = namespaceInteropHelpersByInteropType[moduleInterop]; - variableName = namespaceVariableName!; - } + } else if (imported === '*' && reexported !== '*' && !hasNamespace) { + hasNamespace = true; + helper = namespaceInteropHelpersByInteropType[moduleInterop]; + variableName = namespaceVariableName!; } if (helper) { addInteropStatement(variableName!, helper, name); @@ -88,12 +89,10 @@ export default function getInteropBlock( return `${getHelpersBlock( neededInteropHelpers, accessedGlobals, - _, - n, - s, - t, + indent, + snippets, externalLiveBindings, freeze, - namespaceToStringTag + symbols )}${interopStatements.length > 0 ? `${interopStatements.join(n)}${n}${n}` : ''}`; } diff --git a/src/finalisers/shared/removeExtensionFromRelativeAmdId.ts b/src/finalisers/shared/removeExtensionFromRelativeAmdId.ts deleted file mode 100644 index 61d40a28588..00000000000 --- a/src/finalisers/shared/removeExtensionFromRelativeAmdId.ts +++ /dev/null @@ -1,8 +0,0 @@ -import removeJsExtension from './removeJsExtension'; - -// AMD resolution will only respect the AMD baseUrl if the .js extension is omitted. -// The assumption is that this makes sense for all relative ids: -// https://requirejs.org/docs/api.html#jsfiles -export default function removeExtensionFromRelativeAmdId(id: string) { - return id[0] === '.' ? removeJsExtension(id) : id; -} diff --git a/src/finalisers/shared/removeJsExtension.ts b/src/finalisers/shared/removeJsExtension.ts index f7a707f4a6d..016ad95c4d2 100644 --- a/src/finalisers/shared/removeJsExtension.ts +++ b/src/finalisers/shared/removeJsExtension.ts @@ -1,3 +1,3 @@ -export default function removeJsExtension(name: string) { +export default function removeJsExtension(name: string): string { return name.endsWith('.js') ? name.slice(0, -3) : name; } diff --git a/src/finalisers/shared/sanitize.ts b/src/finalisers/shared/sanitize.ts index 07cad7a37c4..ca361487084 100644 --- a/src/finalisers/shared/sanitize.ts +++ b/src/finalisers/shared/sanitize.ts @@ -1,14 +1,2 @@ -// Generate strings which dereference dotted properties, but use array notation `['prop-deref']` -// if the property name isn't trivial -const shouldUseDot = /^[a-zA-Z$_][a-zA-Z0-9$_]*$/; - -export function property(prop: string) { - return shouldUseDot.test(prop) ? `.${prop}` : `['${prop}']`; -} - -export function keypath(keypath: string) { - return keypath - .split('.') - .map(property) - .join(''); -} +export const keypath = (keypath: string, getPropertyAccess: (name: string) => string): string => + keypath.split('.').map(getPropertyAccess).join(''); diff --git a/src/finalisers/shared/setupNamespace.ts b/src/finalisers/shared/setupNamespace.ts index a2c3e03e8c3..5d33e1e0b8e 100644 --- a/src/finalisers/shared/setupNamespace.ts +++ b/src/finalisers/shared/setupNamespace.ts @@ -1,24 +1,40 @@ -import { GlobalsOption } from '../../rollup/types'; -import { property } from './sanitize'; +import type { LogHandler } from 'rollup'; +import type { GlobalsOption } from '../../rollup/types'; +import type { GenerateCodeSnippets } from '../../utils/generateCodeSnippets'; +import { LOGLEVEL_WARN } from '../../utils/logging'; +import { logReservedNamespace } from '../../utils/logs'; export default function setupNamespace( name: string, root: string, globals: GlobalsOption, - compact: boolean | undefined -) { - const _ = compact ? '' : ' '; + { _, getPropertyAccess, s }: GenerateCodeSnippets, + compact: boolean | undefined, + log?: LogHandler +): string { const parts = name.split('.'); - parts[0] = (typeof globals === 'function' ? globals(parts[0]) : globals[parts[0]]) || parts[0]; + // Check if the key exists in the object's prototype. + const isReserved = parts[0] in Object.prototype; + if (log && isReserved) { + log(LOGLEVEL_WARN, logReservedNamespace(parts[0])); + } + parts[0] = + (typeof globals === 'function' + ? globals(parts[0]) + : isReserved + ? parts[0] + : globals[parts[0]]) || parts[0]; + parts.pop(); - let acc = root; + let propertyPath = root; return ( parts - .map( - part => ((acc += property(part)), `${acc}${_}=${_}${acc}${_}||${_}{}${compact ? '' : ';'}`) - ) - .join(compact ? ',' : '\n') + (compact && parts.length ? ';' : '\n') + .map(part => { + propertyPath += getPropertyAccess(part); + return `${propertyPath}${_}=${_}${propertyPath}${_}||${_}{}${s}`; + }) + .join(compact ? ',' : '\n') + (compact && parts.length > 0 ? ';' : '\n') ); } @@ -26,20 +42,34 @@ export function assignToDeepVariable( deepName: string, root: string, globals: GlobalsOption, - compact: boolean | undefined, - assignment: string + assignment: string, + { _, getPropertyAccess }: GenerateCodeSnippets, + log?: LogHandler ): string { - const _ = compact ? '' : ' '; const parts = deepName.split('.'); - parts[0] = (typeof globals === 'function' ? globals(parts[0]) : globals[parts[0]]) || parts[0]; - const last = parts.pop(); + // Check if the key exists in the object's prototype. + const isReserved = parts[0] in Object.prototype; + if (log && isReserved) { + log(LOGLEVEL_WARN, logReservedNamespace(parts[0])); + } + parts[0] = + (typeof globals === 'function' + ? globals(parts[0]) + : isReserved + ? parts[0] + : globals[parts[0]]) || parts[0]; + + const last = parts.pop()!; - let acc = root; - let deepAssignment = parts - .map(part => ((acc += property(part)), `${acc}${_}=${_}${acc}${_}||${_}{}`)) - .concat(`${acc}${property(last!)}`) - .join(`,${_}`) - .concat(`${_}=${_}${assignment}`); + let propertyPath = root; + let deepAssignment = + [ + ...parts.map(part => { + propertyPath += getPropertyAccess(part); + return `${propertyPath}${_}=${_}${propertyPath}${_}||${_}{}`; + }), + `${propertyPath}${getPropertyAccess(last)}` + ].join(`,${_}`) + `${_}=${_}${assignment}`; if (parts.length > 0) { deepAssignment = `(${deepAssignment})`; } diff --git a/src/finalisers/shared/trimEmptyImports.ts b/src/finalisers/shared/trimEmptyImports.ts index dfb189fe573..99d7f32d253 100644 --- a/src/finalisers/shared/trimEmptyImports.ts +++ b/src/finalisers/shared/trimEmptyImports.ts @@ -1,12 +1,14 @@ -import { ModuleDeclarationDependency } from '../../Chunk'; +import type { ChunkDependency } from '../../Chunk'; -export default function trimEmptyImports(dependencies: ModuleDeclarationDependency[]) { - let i = dependencies.length; +export default function trimEmptyImports( + dependencies: readonly ChunkDependency[] +): ChunkDependency[] { + let index = dependencies.length; - while (i--) { - const { imports, reexports } = dependencies[i]; + while (index--) { + const { imports, reexports } = dependencies[index]; if (imports || reexports) { - return dependencies.slice(0, i + 1); + return dependencies.slice(0, index + 1); } } diff --git a/src/finalisers/shared/updateExtensionForRelativeAmdId.ts b/src/finalisers/shared/updateExtensionForRelativeAmdId.ts new file mode 100644 index 00000000000..2baf20f444b --- /dev/null +++ b/src/finalisers/shared/updateExtensionForRelativeAmdId.ts @@ -0,0 +1,16 @@ +import addJsExtension from './addJsExtension'; +import removeJsExtension from './removeJsExtension'; + +// AMD resolution will only respect the AMD baseUrl if the .js extension is omitted. +// The assumption is that this makes sense for all relative ids: +// https://requirejs.org/docs/api.html#jsfiles +export default function updateExtensionForRelativeAmdId( + id: string, + forceJsExtensionForImports: boolean +): string { + if (id[0] !== '.') { + return id; + } + + return forceJsExtensionForImports ? addJsExtension(id) : removeJsExtension(id); +} diff --git a/src/finalisers/shared/warnOnBuiltins.ts b/src/finalisers/shared/warnOnBuiltins.ts index 2fe1c8015e8..a165bc311e8 100644 --- a/src/finalisers/shared/warnOnBuiltins.ts +++ b/src/finalisers/shared/warnOnBuiltins.ts @@ -1,49 +1,20 @@ -import { ChunkDependencies } from '../../Chunk'; -import { RollupWarning } from '../../rollup/types'; +import builtinModules from 'builtin-modules'; +import type { ChunkDependency } from '../../Chunk'; +import type { LogHandler } from '../../rollup/types'; +import { LOGLEVEL_WARN } from '../../utils/logging'; +import { logMissingNodeBuiltins } from '../../utils/logs'; -const builtins = { - assert: true, - buffer: true, - console: true, - constants: true, - domain: true, - events: true, - http: true, - https: true, - os: true, - path: true, - process: true, - punycode: true, - querystring: true, - stream: true, - string_decoder: true, - timers: true, - tty: true, - url: true, - util: true, - vm: true, - zlib: true -}; +const nodeBuiltins: ReadonlySet = new Set(builtinModules); export default function warnOnBuiltins( - warn: (warning: RollupWarning) => void, - dependencies: ChunkDependencies -) { - const externalBuiltins = dependencies.map(({ id }) => id).filter(id => id in builtins); + log: LogHandler, + dependencies: readonly ChunkDependency[] +): void { + const externalBuiltins = dependencies + .map(({ importPath }) => importPath) + .filter(importPath => nodeBuiltins.has(importPath) || importPath.startsWith('node:')); - if (!externalBuiltins.length) return; + if (externalBuiltins.length === 0) return; - const detail = - externalBuiltins.length === 1 - ? `module ('${externalBuiltins[0]}')` - : `modules (${externalBuiltins - .slice(0, -1) - .map(name => `'${name}'`) - .join(', ')} and '${externalBuiltins.slice(-1)}')`; - - warn({ - code: 'MISSING_NODE_BUILTINS', - message: `Creating a browser bundle that depends on Node.js built-in ${detail}. You might need to include https://github.com/ionic-team/rollup-plugin-node-polyfills`, - modules: externalBuiltins - }); + log(LOGLEVEL_WARN, logMissingNodeBuiltins(externalBuiltins)); } diff --git a/src/finalisers/system.ts b/src/finalisers/system.ts index 0a0653cdb2d..ad926028c7e 100644 --- a/src/finalisers/system.ts +++ b/src/finalisers/system.ts @@ -1,92 +1,11 @@ -import { Bundle as MagicStringBundle } from 'magic-string'; -import { ChunkExports, ModuleDeclarations } from '../Chunk'; -import { NormalizedOutputOptions } from '../rollup/types'; +import type { Bundle as MagicStringBundle } from 'magic-string'; +import type { ChunkDependency, ChunkExports, ModuleDeclarations } from '../Chunk'; +import type { NormalizedOutputOptions } from '../rollup/types'; +import type { GenerateCodeSnippets } from '../utils/generateCodeSnippets'; +import { stringifyObjectKeyIfNeeded } from '../utils/identifierHelpers'; +import { getHelpersBlock } from '../utils/interopHelpers'; import { MISSING_EXPORT_SHIM_VARIABLE } from '../utils/variableNames'; -import { FinaliserOptions } from './index'; - -function getStarExcludes({ dependencies, exports }: ModuleDeclarations): Set { - const starExcludes = new Set(exports.map(expt => expt.exported)); - if (!starExcludes.has('default')) starExcludes.add('default'); - // also include reexport names - for (const { reexports } of dependencies) { - if (reexports) { - for (const reexport of reexports) { - if (reexport.imported !== '*' && !starExcludes.has(reexport.reexported)) - starExcludes.add(reexport.reexported); - } - } - } - return starExcludes; -} - -const getStarExcludesBlock = ( - starExcludes: Set | undefined, - varOrConst: string, - _: string, - t: string, - n: string -): string => - starExcludes - ? `${n}${t}${varOrConst} _starExcludes${_}=${_}{${_}${[...starExcludes] - .map(prop => `${prop}:${_}1`) - .join(`,${_}`)}${_}};` - : ''; - -const getImportBindingsBlock = ( - importBindings: string[], - _: string, - t: string, - n: string -): string => (importBindings.length ? `${n}${t}var ${importBindings.join(`,${_}`)};` : ''); - -function getExportsBlock( - exports: { name: string; value: string }[], - _: string, - t: string, - n: string -): string { - if (exports.length === 0) { - return ''; - } - if (exports.length === 1) { - return `${t}${t}${t}exports('${exports[0].name}',${_}${exports[0].value});${n}${n}`; - } - return ( - `${t}${t}${t}exports({${n}` + - exports.map(({ name, value }) => `${t}${t}${t}${t}${name}:${_}${value}`).join(`,${n}`) + - `${n}${t}${t}${t}});${n}${n}` - ); -} - -const getHoistedExportsBlock = (exports: ChunkExports, _: string, t: string, n: string): string => - getExportsBlock( - exports - .filter(expt => expt.hoisted || expt.uninitialized) - .map(expt => ({ name: expt.exported, value: expt.uninitialized ? 'void 0' : expt.local })), - _, - t, - n - ); - -const getMissingExportsBlock = (exports: ChunkExports, _: string, t: string, n: string): string => - getExportsBlock( - exports - .filter(expt => expt.local === MISSING_EXPORT_SHIM_VARIABLE) - .map(expt => ({ name: expt.exported, value: MISSING_EXPORT_SHIM_VARIABLE })), - _, - t, - n - ); - -const getSyntheticExportsBlock = (exports: ChunkExports, _: string, t: string, n: string): string => - getExportsBlock( - exports - .filter(expt => expt.expression) - .map(expt => ({ name: expt.exported, value: expt.local })), - _, - t, - n - ); +import type { FinaliserOptions } from './index'; export default function system( magicString: MagicStringBundle, @@ -95,22 +14,94 @@ export default function system( dependencies, exports, hasExports, - indentString: t, + indent: t, intro, + snippets, outro, - usesTopLevelAwait, - varOrConst + usesTopLevelAwait }: FinaliserOptions, - options: NormalizedOutputOptions -) { - const n = options.compact ? '' : '\n'; - const _ = options.compact ? '' : ' '; + { + externalLiveBindings, + freeze, + name, + generatedCode: { symbols }, + strict, + systemNullSetters + }: NormalizedOutputOptions +): void { + const { _, getFunctionIntro, getNonArrowFunctionIntro, n, s } = snippets; + const { importBindings, setters, starExcludes } = analyzeDependencies( + dependencies, + exports, + t, + snippets + ); + const registeredName = name ? `'${name}',${_}` : ''; + const wrapperParameters = accessedGlobals.has('module') + ? ['exports', 'module'] + : hasExports + ? ['exports'] + : []; + + // factory function should be wrapped by parentheses to avoid lazy parsing, + // cf. https://v8.dev/blog/preparser#pife + let wrapperStart = + `System.register(${registeredName}[` + + dependencies.map(({ importPath }) => `'${importPath}'`).join(`,${_}`) + + `],${_}(${getNonArrowFunctionIntro(wrapperParameters, { + isAsync: false, + name: null + })}{${n}${t}${strict ? "'use strict';" : ''}` + + getStarExcludesBlock(starExcludes, t, snippets) + + getImportBindingsBlock(importBindings, t, snippets) + + `${n}${t}return${_}{${ + setters.length > 0 + ? `${n}${t}${t}setters:${_}[${setters + .map(setter => + setter + ? `${getFunctionIntro(['module'], { + isAsync: false, + name: null + })}{${n}${t}${t}${t}${setter}${n}${t}${t}}` + : systemNullSetters + ? `null` + : `${getFunctionIntro([], { isAsync: false, name: null })}{}` + ) + .join(`,${_}`)}],` + : '' + }${n}`; + wrapperStart += `${t}${t}execute:${_}(${getNonArrowFunctionIntro([], { + isAsync: usesTopLevelAwait, + name: null + })}{${n}${n}`; - const dependencyIds = dependencies.map(m => `'${m.id}'`); + const wrapperEnd = `${t}${t}})${n}${t}}${s}${n}}));`; + magicString + .prepend( + intro + + getHelpersBlock(null, accessedGlobals, t, snippets, externalLiveBindings, freeze, symbols) + + getHoistedExportsBlock(exports, t, snippets) + ) + .append( + `${outro}${n}${n}` + + getSyntheticExportsBlock(exports, t, snippets) + + getMissingExportsBlock(exports, t, snippets) + ) + .indent(`${t}${t}${t}`) + .append(wrapperEnd) + .prepend(wrapperStart); +} + +function analyzeDependencies( + dependencies: ChunkDependency[], + exports: ChunkExports, + t: string, + { _, cnst, getObject, getPropertyAccess, n }: GenerateCodeSnippets +): { importBindings: string[]; setters: string[]; starExcludes: Set | null } { const importBindings: string[] = []; - let starExcludes: Set | undefined; const setters: string[] = []; + let starExcludes: Set | null = null; for (const { imports, reexports } of dependencies) { const setter: string[] = []; @@ -120,97 +111,141 @@ export default function system( if (specifier.imported === '*') { setter.push(`${specifier.local}${_}=${_}module;`); } else { - setter.push(`${specifier.local}${_}=${_}module.${specifier.imported};`); + setter.push(`${specifier.local}${_}=${_}module${getPropertyAccess(specifier.imported)};`); } } } if (reexports) { - let createdSetter = false; - // bulk-reexport form - if ( - reexports.length > 1 || - (reexports.length === 1 && - (reexports[0].reexported === '*' || reexports[0].imported === '*')) - ) { - // star reexports - for (const specifier of reexports) { - if (specifier.reexported !== '*') continue; - // need own exports list for deduping in star export case + const reexportedNames: [key: string | null, value: string][] = []; + let hasStarReexport = false; + for (const { imported, reexported } of reexports) { + if (reexported === '*') { + hasStarReexport = true; + } else { + reexportedNames.push([ + reexported, + imported === '*' ? 'module' : `module${getPropertyAccess(imported)}` + ]); + } + } + if (reexportedNames.length > 1 || hasStarReexport) { + if (hasStarReexport) { if (!starExcludes) { starExcludes = getStarExcludes({ dependencies, exports }); } - if (!createdSetter) { - setter.push(`${varOrConst} _setter${_}=${_}{};`); - createdSetter = true; - } - setter.push(`for${_}(var _$p${_}in${_}module)${_}{`); - setter.push(`${t}if${_}(!_starExcludes[_$p])${_}_setter[_$p]${_}=${_}module[_$p];`); - setter.push('}'); - } - // star import reexport - for (const specifier of reexports) { - if (specifier.imported !== '*' || specifier.reexported === '*') continue; - setter.push(`exports('${specifier.reexported}',${_}module);`); - } - // reexports - for (const specifier of reexports) { - if (specifier.reexported === '*' || specifier.imported === '*') continue; - if (!createdSetter) { - setter.push(`${varOrConst} _setter${_}=${_}{};`); - createdSetter = true; - } - setter.push(`_setter.${specifier.reexported}${_}=${_}module.${specifier.imported};`); - } - if (createdSetter) { - setter.push('exports(_setter);'); + reexportedNames.unshift([null, `__proto__:${_}null`]); + const exportMapping = getObject(reexportedNames, { lineBreakIndent: null }); + setter.push( + `${cnst} setter${_}=${_}${exportMapping};`, + `for${_}(${cnst} name in module)${_}{`, + `${t}if${_}(!_starExcludes[name])${_}setter[name]${_}=${_}module[name];`, + '}', + 'exports(setter);' + ); + } else { + const exportMapping = getObject(reexportedNames, { lineBreakIndent: null }); + setter.push(`exports(${exportMapping});`); } } else { - // single reexport - for (const specifier of reexports) { - setter.push(`exports('${specifier.reexported}',${_}module.${specifier.imported});`); - } + const [key, value] = reexportedNames[0]; + setter.push(`exports(${JSON.stringify(key)},${_}${value});`); } } setters.push(setter.join(`${n}${t}${t}${t}`)); } + return { importBindings, setters, starExcludes }; +} - const registeredName = options.name ? `'${options.name}',${_}` : ''; - const wrapperParams = accessedGlobals.has('module') - ? `exports,${_}module` - : hasExports - ? 'exports' - : ''; +const getStarExcludes = ({ dependencies, exports }: ModuleDeclarations): Set => { + const starExcludes = new Set(exports.map(expt => expt.exported)); + starExcludes.add('default'); + for (const { reexports } of dependencies) { + if (reexports) { + for (const reexport of reexports) { + if (reexport.reexported !== '*') starExcludes.add(reexport.reexported); + } + } + } + return starExcludes; +}; - let wrapperStart = - `System.register(${registeredName}[` + - dependencyIds.join(`,${_}`) + - `],${_}function${_}(${wrapperParams})${_}{${n}${t}${options.strict ? "'use strict';" : ''}` + - getStarExcludesBlock(starExcludes, varOrConst, _, t, n) + - getImportBindingsBlock(importBindings, _, t, n) + - `${n}${t}return${_}{${ - setters.length - ? `${n}${t}${t}setters:${_}[${setters - .map(s => - s - ? `function${_}(module)${_}{${n}${t}${t}${t}${s}${n}${t}${t}}` - : options.systemNullSetters - ? `null` - : `function${_}()${_}{}` - ) - .join(`,${_}`)}],` - : '' - }${n}`; - wrapperStart += - `${t}${t}execute:${_}${usesTopLevelAwait ? `async${_}` : ''}function${_}()${_}{${n}${n}` + - getHoistedExportsBlock(exports, _, t, n); +const getStarExcludesBlock = ( + starExcludes: ReadonlySet | null, + t: string, + { _, cnst, getObject, n }: GenerateCodeSnippets +): string => { + if (starExcludes) { + const fields: [key: string | null, value: string][] = [...starExcludes].map(property => [ + property, + '1' + ]); + fields.unshift([null, `__proto__:${_}null`]); + return `${n}${t}${cnst} _starExcludes${_}=${_}${getObject(fields, { + lineBreakIndent: { base: t, t } + })};`; + } + return ''; +}; - const wrapperEnd = - `${n}${n}` + - getSyntheticExportsBlock(exports, _, t, n) + - getMissingExportsBlock(exports, _, t, n) + - `${t}${t}}${n}${t}}${options.compact ? '' : ';'}${n}});`; +const getImportBindingsBlock = ( + importBindings: readonly string[], + t: string, + { _, n }: GenerateCodeSnippets +): string => (importBindings.length > 0 ? `${n}${t}var ${importBindings.join(`,${_}`)};` : ''); - if (intro) magicString.prepend(intro); - if (outro) magicString.append(outro); - return magicString.indent(`${t}${t}${t}`).append(wrapperEnd).prepend(wrapperStart); +const getHoistedExportsBlock = ( + exports: ChunkExports, + t: string, + snippets: GenerateCodeSnippets +): string => + getExportsBlock( + exports.filter(expt => expt.hoisted).map(expt => ({ name: expt.exported, value: expt.local })), + t, + snippets + ); + +function getExportsBlock( + exports: readonly { name: string; value: string }[], + t: string, + { _, n }: GenerateCodeSnippets +): string { + if (exports.length === 0) { + return ''; + } + if (exports.length === 1) { + return `exports(${JSON.stringify(exports[0].name)},${_}${exports[0].value});${n}${n}`; + } + return ( + `exports({${n}` + + exports + .map(({ name, value }) => `${t}${stringifyObjectKeyIfNeeded(name)}:${_}${value}`) + .join(`,${n}`) + + `${n}});${n}${n}` + ); } + +const getSyntheticExportsBlock = ( + exports: ChunkExports, + t: string, + snippets: GenerateCodeSnippets +): string => + getExportsBlock( + exports + .filter(expt => expt.expression) + .map(expt => ({ name: expt.exported, value: expt.local })), + t, + snippets + ); + +const getMissingExportsBlock = ( + exports: ChunkExports, + t: string, + snippets: GenerateCodeSnippets +): string => + getExportsBlock( + exports + .filter(expt => expt.local === MISSING_EXPORT_SHIM_VARIABLE) + .map(expt => ({ name: expt.exported, value: MISSING_EXPORT_SHIM_VARIABLE })), + t, + snippets + ); diff --git a/src/finalisers/umd.ts b/src/finalisers/umd.ts index 8ad8ee0eb89..16be02c3758 100644 --- a/src/finalisers/umd.ts +++ b/src/finalisers/umd.ts @@ -1,26 +1,36 @@ -import { Bundle as MagicStringBundle } from 'magic-string'; -import { NormalizedOutputOptions } from '../rollup/types'; -import { error } from '../utils/error'; -import { FinaliserOptions } from './index'; +import type { Bundle as MagicStringBundle } from 'magic-string'; +import type { NormalizedOutputOptions } from '../rollup/types'; +import type { GenerateCodeSnippets } from '../utils/generateCodeSnippets'; +import { error, logMissingNameOptionForUmdExport } from '../utils/logs'; +import type { FinaliserOptions } from './index'; import getCompleteAmdId from './shared/getCompleteAmdId'; import { getExportBlock, getNamespaceMarkers } from './shared/getExportBlock'; import getInteropBlock from './shared/getInteropBlock'; -import removeExtensionFromRelativeAmdId from './shared/removeExtensionFromRelativeAmdId'; -import { keypath, property } from './shared/sanitize'; +import { keypath } from './shared/sanitize'; import { assignToDeepVariable } from './shared/setupNamespace'; import trimEmptyImports from './shared/trimEmptyImports'; +import updateExtensionForRelativeAmdId from './shared/updateExtensionForRelativeAmdId'; import warnOnBuiltins from './shared/warnOnBuiltins'; -function globalProp(name: string, globalVar: string) { +function globalProperty( + name: string | false | undefined, + globalVariable: string, + getPropertyAccess: (name: string) => string +) { if (!name) return 'null'; - return `${globalVar}${keypath(name)}`; + return `${globalVariable}${keypath(name, getPropertyAccess)}`; } -function safeAccess(name: string, globalVar: string, _: string) { - const parts = name.split('.'); - - let acc = globalVar; - return parts.map(part => (acc += property(part))).join(`${_}&&${_}`); +function safeAccess( + name: string, + globalVariable: string, + { _, getPropertyAccess }: GenerateCodeSnippets +) { + let propertyPath = globalVariable; + return name + .split('.') + .map(part => (propertyPath += getPropertyAccess(part))) + .join(`${_}&&${_}`); } export default function umd( @@ -29,14 +39,15 @@ export default function umd( accessedGlobals, dependencies, exports, + hasDefaultExport, hasExports, id, - indentString: t, + indent: t, intro, namedExportsMode, + log, outro, - varOrConst, - warn + snippets }: FinaliserOptions, { amd, @@ -47,55 +58,60 @@ export default function umd( freeze, interop, name, - namespaceToStringTag, + generatedCode: { symbols }, globals, noConflict, + reexportProtoFromExternal, strict }: NormalizedOutputOptions -) { - const _ = compact ? '' : ' '; - const n = compact ? '' : '\n'; - const s = compact ? '' : ';'; - const factoryVar = compact ? 'f' : 'factory'; - const globalVar = compact ? 'g' : 'global'; +): void { + const { _, cnst, getFunctionIntro, getNonArrowFunctionIntro, getPropertyAccess, n, s } = snippets; + const factoryVariable = compact ? 'f' : 'factory'; + const globalVariable = compact ? 'g' : 'global'; if (hasExports && !name) { - return error({ - code: 'MISSING_NAME_OPTION_FOR_IIFE_EXPORT', - message: - 'You must supply "output.name" for UMD bundles that have exports so that the exports are accessible in environments without a module loader.' - }); + return error(logMissingNameOptionForUmdExport()); } - warnOnBuiltins(warn, dependencies); + warnOnBuiltins(log, dependencies); - const amdDeps = dependencies.map(m => `'${removeExtensionFromRelativeAmdId(m.id)}'`); - const cjsDeps = dependencies.map(m => `require('${m.id}')`); + const amdDeps = dependencies.map( + m => `'${updateExtensionForRelativeAmdId(m.importPath, amd.forceJsExtensionForImports)}'` + ); + const cjsDeps = dependencies.map(m => `require('${m.importPath}')`); const trimmedImports = trimEmptyImports(dependencies); - const globalDeps = trimmedImports.map(module => globalProp(module.globalName, globalVar)); - const factoryArgs = trimmedImports.map(m => m.name); + const globalDeps = trimmedImports.map(module => + globalProperty(module.globalName, globalVariable, getPropertyAccess) + ); + const factoryParameters = trimmedImports.map(m => m.name); - if (namedExportsMode && (hasExports || noConflict)) { + if ( + (hasExports || noConflict) && + (namedExportsMode || (hasExports && exports[0]?.local === 'exports.default')) + ) { amdDeps.unshift(`'exports'`); cjsDeps.unshift(`exports`); globalDeps.unshift( assignToDeepVariable( name!, - globalVar, + globalVariable, globals, - compact, - `${extend ? `${globalProp(name!, globalVar)}${_}||${_}` : ''}{}` + `${ + extend ? `${globalProperty(name!, globalVariable, getPropertyAccess)}${_}||${_}` : '' + }{}`, + snippets, + log ) ); - factoryArgs.unshift('exports'); + factoryParameters.unshift('exports'); } const completeAmdId = getCompleteAmdId(amd, id); - const amdParams = + const amdParameters = (completeAmdId ? `'${completeAmdId}',${_}` : ``) + - (amdDeps.length ? `[${amdDeps.join(`,${_}`)}],${_}` : ``); + (amdDeps.length > 0 ? `[${amdDeps.join(`,${_}`)}],${_}` : ``); const define = amd.define; const cjsExport = !namedExportsMode && hasExports ? `module.exports${_}=${_}` : ``; @@ -104,74 +120,84 @@ export default function umd( let iifeExport; if (noConflict) { - const noConflictExportsVar = compact ? 'e' : 'exports'; + const noConflictExportsVariable = compact ? 'e' : 'exports'; let factory; if (!namedExportsMode && hasExports) { - factory = `var ${noConflictExportsVar}${_}=${_}${assignToDeepVariable( + factory = `${cnst} ${noConflictExportsVariable}${_}=${_}${assignToDeepVariable( name!, - globalVar, + globalVariable, globals, - compact, - `${factoryVar}(${globalDeps.join(`,${_}`)})` + `${factoryVariable}(${globalDeps.join(`,${_}`)})`, + snippets, + log )};`; } else { const module = globalDeps.shift(); factory = - `var ${noConflictExportsVar}${_}=${_}${module};${n}` + - `${t}${t}${factoryVar}(${[noConflictExportsVar].concat(globalDeps).join(`,${_}`)});`; + `${cnst} ${noConflictExportsVariable}${_}=${_}${module};${n}` + + `${t}${t}${factoryVariable}(${[noConflictExportsVariable, ...globalDeps].join(`,${_}`)});`; } iifeExport = - `(function${_}()${_}{${n}` + - `${t}${t}var current${_}=${_}${safeAccess(name!, globalVar, _)};${n}` + + `(${getFunctionIntro([], { isAsync: false, name: null })}{${n}` + + `${t}${t}${cnst} current${_}=${_}${safeAccess(name!, globalVariable, snippets)};${n}` + `${t}${t}${factory}${n}` + - `${t}${t}${noConflictExportsVar}.noConflict${_}=${_}function${_}()${_}{${_}` + - `${globalProp(name!, globalVar)}${_}=${_}current;${_}return ${noConflictExportsVar}${ - compact ? '' : '; ' - }};${n}` + - `${t}}())`; + `${t}${t}${noConflictExportsVariable}.noConflict${_}=${_}${getFunctionIntro([], { + isAsync: false, + name: null + })}{${_}` + + `${globalProperty( + name!, + globalVariable, + getPropertyAccess + )}${_}=${_}current;${_}return ${noConflictExportsVariable}${s}${_}};${n}` + + `${t}})()`; } else { - iifeExport = `${factoryVar}(${globalDeps.join(`,${_}`)})`; + iifeExport = `${factoryVariable}(${globalDeps.join(`,${_}`)})`; if (!namedExportsMode && hasExports) { - iifeExport = assignToDeepVariable(name!, globalVar, globals, compact, iifeExport); + iifeExport = assignToDeepVariable(name!, globalVariable, globals, iifeExport, snippets, log); } } const iifeNeedsGlobal = hasExports || (noConflict && namedExportsMode) || globalDeps.length > 0; - const globalParam = iifeNeedsGlobal ? `${globalVar},${_}` : ''; - const globalArg = iifeNeedsGlobal ? `this,${_}` : ''; + const wrapperParameters: string[] = [factoryVariable]; + if (iifeNeedsGlobal) { + wrapperParameters.unshift(globalVariable); + } + const globalArgument = iifeNeedsGlobal ? `this,${_}` : ''; const iifeStart = iifeNeedsGlobal - ? `(${globalVar}${_}=${_}typeof globalThis${_}!==${_}'undefined'${_}?${_}globalThis${_}:${_}${globalVar}${_}||${_}self,${_}` + ? `(${globalVariable}${_}=${_}typeof globalThis${_}!==${_}'undefined'${_}?${_}globalThis${_}:${_}${globalVariable}${_}||${_}self,${_}` : ''; const iifeEnd = iifeNeedsGlobal ? ')' : ''; const cjsIntro = iifeNeedsGlobal ? `${t}typeof exports${_}===${_}'object'${_}&&${_}typeof module${_}!==${_}'undefined'${_}?` + - `${_}${cjsExport}${factoryVar}(${cjsDeps.join(`,${_}`)})${_}:${n}` + `${_}${cjsExport}${factoryVariable}(${cjsDeps.join(`,${_}`)})${_}:${n}` : ''; - // factory function should be wrapped by parentheses to avoid lazy parsing const wrapperIntro = - `(function${_}(${globalParam}${factoryVar})${_}{${n}` + + `(${getNonArrowFunctionIntro(wrapperParameters, { isAsync: false, name: null })}{${n}` + cjsIntro + - `${t}typeof ${define}${_}===${_}'function'${_}&&${_}${define}.amd${_}?${_}${define}(${amdParams}${factoryVar})${_}:${n}` + + `${t}typeof ${define}${_}===${_}'function'${_}&&${_}${define}.amd${_}?${_}${define}(${amdParameters}${factoryVariable})${_}:${n}` + `${t}${iifeStart}${iifeExport}${iifeEnd};${n}` + - `}(${globalArg}(function${_}(${factoryArgs.join(', ')})${_}{${useStrict}${n}`; + // factory function should be wrapped by parentheses to avoid lazy parsing, + // cf. https://v8.dev/blog/preparser#pife + `})(${globalArgument}(${getNonArrowFunctionIntro(factoryParameters, { + isAsync: false, + name: null + })}{${useStrict}${n}`; - const wrapperOutro = n + n + '})));'; + const wrapperOutro = n + n + '}));'; magicString.prepend( `${intro}${getInteropBlock( dependencies, - varOrConst, interop, externalLiveBindings, freeze, - namespaceToStringTag, + symbols, accessedGlobals, - _, - n, - s, - t + t, + snippets )}` ); @@ -180,20 +206,24 @@ export default function umd( dependencies, namedExportsMode, interop, - compact, + snippets, t, - externalLiveBindings + externalLiveBindings, + reexportProtoFromExternal ); let namespaceMarkers = getNamespaceMarkers( namedExportsMode && hasExports, - esModule, - namespaceToStringTag, - _, - n + esModule === true || (esModule === 'if-default-prop' && hasDefaultExport), + symbols, + snippets ); if (namespaceMarkers) { namespaceMarkers = n + n + namespaceMarkers; } - magicString.append(`${exportBlock}${namespaceMarkers}${outro}`); - return magicString.trim().indent(t).append(wrapperOutro).prepend(wrapperIntro); + magicString + .append(`${exportBlock}${namespaceMarkers}${outro}`) + .trim() + .indent(t) + .append(wrapperOutro) + .prepend(wrapperIntro); } diff --git a/src/node-entry.ts b/src/node-entry.ts index a488fb584ac..865f5445b03 100644 --- a/src/node-entry.ts +++ b/src/node-entry.ts @@ -1,3 +1,3 @@ -export { default as rollup } from './rollup/rollup'; -export { default as watch } from './watch/watch-proxy'; export { version as VERSION } from 'package.json'; +export { defineConfig, default as rollup } from './rollup/rollup'; +export { default as watch } from './watch/watch-proxy'; diff --git a/src/rollup/rollup.ts b/src/rollup/rollup.ts index 86519eb5439..824cba4f367 100644 --- a/src/rollup/rollup.ts +++ b/src/rollup/rollup.ts @@ -1,35 +1,52 @@ import { version as rollupVersion } from 'package.json'; import Bundle from '../Bundle'; import Graph from '../Graph'; -import { ensureArray } from '../utils/ensureArray'; -import { errAlreadyClosed, errCannotEmitFromOptionsHook, error } from '../utils/error'; -import { writeFile } from '../utils/fs'; +import { catchUnfinishedHookActions } from '../utils/hookActions'; +import initWasm from '../utils/initWasm'; +import { getLogger } from '../utils/logger'; +import { LOGLEVEL_DEBUG, LOGLEVEL_INFO, LOGLEVEL_WARN } from '../utils/logging'; +import { getLogHandler } from '../utils/logHandler'; +import { + error, + getRollupError, + logAlreadyClosed, + logCannotEmitFromOptionsHook, + logMissingFileOrDirOption, + logPluginError +} from '../utils/logs'; import { normalizeInputOptions } from '../utils/options/normalizeInputOptions'; import { normalizeOutputOptions } from '../utils/options/normalizeOutputOptions'; -import { GenericConfigObject } from '../utils/options/options'; -import { basename, dirname, resolve } from '../utils/path'; -import { PluginDriver } from '../utils/PluginDriver'; -import { ANONYMOUS_OUTPUT_PLUGIN_PREFIX, ANONYMOUS_PLUGIN_PREFIX } from '../utils/pluginUtils'; -import { SOURCEMAPPING_URL } from '../utils/sourceMappingURL'; +import { getOnLog, normalizeLog, normalizePluginOption } from '../utils/options/options'; +import { dirname, resolve } from '../utils/path'; +import type { PluginDriver } from '../utils/PluginDriver'; +import { getSortedValidatedPlugins } from '../utils/PluginDriver'; +import { ANONYMOUS_OUTPUT_PLUGIN_PREFIX, ANONYMOUS_PLUGIN_PREFIX } from '../utils/pluginNames'; import { getTimings, initialiseTimers, timeEnd, timeStart } from '../utils/timers'; -import { +import type { + InputOptions, NormalizedInputOptions, NormalizedOutputOptions, OutputAsset, + OutputBundle, OutputChunk, OutputOptions, Plugin, RollupBuild, + RollupOptions, + RollupOptionsFunction, RollupOutput, RollupWatcher } from './types'; -export default function rollup(rawInputOptions: GenericConfigObject): Promise { +// @ts-expect-error TS2540: the polyfill of `asyncDispose`. +Symbol.asyncDispose ??= Symbol('Symbol.asyncDispose'); + +export default function rollup(rawInputOptions: RollupOptions): Promise { return rollupInternal(rawInputOptions, null); } export async function rollupInternal( - rawInputOptions: GenericConfigObject, + rawInputOptions: RollupOptions, watcher: RollupWatcher | null ): Promise { const { options: inputOptions, unsetOptions: unsetInputOptions } = await getInputOptions( @@ -38,35 +55,58 @@ export async function rollupInternal( ); initialiseTimers(inputOptions); + await initWasm(); + const graph = new Graph(inputOptions, watcher); - // remove the cache option from the memory after graph creation (cache is not used anymore) + // remove the cache object from the memory after graph creation (cache is not used anymore) const useCache = rawInputOptions.cache !== false; - delete inputOptions.cache; - delete rawInputOptions.cache; + if (rawInputOptions.cache) { + inputOptions.cache = undefined; + rawInputOptions.cache = undefined; + } timeStart('BUILD', 1); - try { - await graph.pluginDriver.hookParallel('buildStart', [inputOptions]); - await graph.build(); - } catch (err) { - const watchFiles = Object.keys(graph.watchFiles); - if (watchFiles.length > 0) { - err.watchFiles = watchFiles; + await catchUnfinishedHookActions(graph.pluginDriver, async () => { + try { + timeStart('initialize', 2); + await graph.pluginDriver.hookParallel('buildStart', [inputOptions]); + timeEnd('initialize', 2); + await graph.build(); + } catch (error_: any) { + const watchFiles = Object.keys(graph.watchFiles); + if (watchFiles.length > 0) { + error_.watchFiles = watchFiles; + } + try { + await graph.pluginDriver.hookParallel('buildEnd', [error_]); + } catch (buildEndError: any) { + // Create a compound error object to include both errors, based on the original error + const compoundError = getRollupError({ + ...error_, + message: `There was an error during the build:\n ${error_.message}\nAdditionally, handling the error in the 'buildEnd' hook caused the following error:\n ${buildEndError.message}` + }); + await graph.pluginDriver.hookParallel('closeBundle', [compoundError]); + throw compoundError; + } + await graph.pluginDriver.hookParallel('closeBundle', [error_]); + throw error_; } - await graph.pluginDriver.hookParallel('buildEnd', [err]); - await graph.pluginDriver.hookParallel('closeBundle', []); - throw err; - } - - await graph.pluginDriver.hookParallel('buildEnd', []); + try { + await graph.pluginDriver.hookParallel('buildEnd', []); + } catch (buildEndError: any) { + await graph.pluginDriver.hookParallel('closeBundle', [buildEndError]); + throw buildEndError; + } + }); timeEnd('BUILD', 1); const result: RollupBuild = { - cache: useCache ? graph.getCache() : undefined, - closed: false, + get cache() { + return useCache ? graph.getCache() : undefined; + }, async close() { if (result.closed) return; @@ -74,28 +114,22 @@ export async function rollupInternal( await graph.pluginDriver.hookParallel('closeBundle', []); }, + closed: false, + async [Symbol.asyncDispose]() { + await this.close(); + }, async generate(rawOutputOptions: OutputOptions) { - if (result.closed) return error(errAlreadyClosed()); + if (result.closed) return error(logAlreadyClosed()); - return handleGenerateWrite( - false, - inputOptions, - unsetInputOptions, - rawOutputOptions as GenericConfigObject, - graph - ); + return handleGenerateWrite(false, inputOptions, unsetInputOptions, rawOutputOptions, graph); + }, + get watchFiles() { + return Object.keys(graph.watchFiles); }, - watchFiles: Object.keys(graph.watchFiles), async write(rawOutputOptions: OutputOptions) { - if (result.closed) return error(errAlreadyClosed()); + if (result.closed) return error(logAlreadyClosed()); - return handleGenerateWrite( - true, - inputOptions, - unsetInputOptions, - rawOutputOptions as GenericConfigObject, - graph - ); + return handleGenerateWrite(true, inputOptions, unsetInputOptions, rawOutputOptions, graph); } }; if (inputOptions.perf) result.getTimings = getTimings; @@ -103,43 +137,54 @@ export async function rollupInternal( } async function getInputOptions( - rawInputOptions: GenericConfigObject, + initialInputOptions: InputOptions, watchMode: boolean ): Promise<{ options: NormalizedInputOptions; unsetOptions: Set }> { - if (!rawInputOptions) { + if (!initialInputOptions) { throw new Error('You must supply an options object to rollup'); } - const rawPlugins = ensureArray(rawInputOptions.plugins) as Plugin[]; - const { options, unsetOptions } = normalizeInputOptions( - await rawPlugins.reduce(applyOptionHook(watchMode), Promise.resolve(rawInputOptions)) - ); + const processedInputOptions = await getProcessedInputOptions(initialInputOptions, watchMode); + const { options, unsetOptions } = await normalizeInputOptions(processedInputOptions, watchMode); normalizePlugins(options.plugins, ANONYMOUS_PLUGIN_PREFIX); return { options, unsetOptions }; } -function applyOptionHook(watchMode: boolean) { - return async ( - inputOptions: Promise, - plugin: Plugin - ): Promise => { - if (plugin.options) { - return ( - ((await plugin.options.call( - { meta: { rollupVersion, watchMode } }, - await inputOptions - )) as GenericConfigObject) || inputOptions - ); - } +async function getProcessedInputOptions( + inputOptions: InputOptions, + watchMode: boolean +): Promise { + const plugins = getSortedValidatedPlugins( + 'options', + await normalizePluginOption(inputOptions.plugins) + ); + const logLevel = inputOptions.logLevel || LOGLEVEL_INFO; + const logger = getLogger(plugins, getOnLog(inputOptions, logLevel), watchMode, logLevel); - return inputOptions; - }; + for (const plugin of plugins) { + const { name, options } = plugin; + const handler = 'handler' in options! ? options.handler : options!; + const processedOptions = await handler.call( + { + debug: getLogHandler(LOGLEVEL_DEBUG, 'PLUGIN_LOG', logger, name, logLevel), + error: (error_): never => + error(logPluginError(normalizeLog(error_), name, { hook: 'onLog' })), + info: getLogHandler(LOGLEVEL_INFO, 'PLUGIN_LOG', logger, name, logLevel), + meta: { rollupVersion, watchMode }, + warn: getLogHandler(LOGLEVEL_WARN, 'PLUGIN_WARNING', logger, name, logLevel) + }, + inputOptions + ); + if (processedOptions) { + inputOptions = processedOptions; + } + } + return inputOptions; } -function normalizePlugins(plugins: Plugin[], anonymousPrefix: string): void { - for (let pluginIndex = 0; pluginIndex < plugins.length; pluginIndex++) { - const plugin = plugins[pluginIndex]; +function normalizePlugins(plugins: readonly Plugin[], anonymousPrefix: string): void { + for (const [index, plugin] of plugins.entries()) { if (!plugin.name) { - plugin.name = `${anonymousPrefix}${pluginIndex + 1}`; + plugin.name = `${anonymousPrefix}${index + 1}`; } } } @@ -147,98 +192,104 @@ function normalizePlugins(plugins: Plugin[], anonymousPrefix: string): void { async function handleGenerateWrite( isWrite: boolean, inputOptions: NormalizedInputOptions, - unsetInputOptions: Set, - rawOutputOptions: GenericConfigObject, + unsetInputOptions: ReadonlySet, + rawOutputOptions: OutputOptions, graph: Graph ): Promise { const { options: outputOptions, outputPluginDriver, unsetOptions - } = getOutputOptionsAndPluginDriver( + } = await getOutputOptionsAndPluginDriver( rawOutputOptions, graph.pluginDriver, inputOptions, unsetInputOptions ); - const bundle = new Bundle(outputOptions, unsetOptions, inputOptions, outputPluginDriver, graph); - const generated = await bundle.generate(isWrite); - if (isWrite) { - if (!outputOptions.dir && !outputOptions.file) { - return error({ - code: 'MISSING_OPTION', - message: 'You must specify "output.file" or "output.dir" for the build.' - }); + return catchUnfinishedHookActions(outputPluginDriver, async () => { + const bundle = new Bundle(outputOptions, unsetOptions, inputOptions, outputPluginDriver, graph); + const generated = await bundle.generate(isWrite); + if (isWrite) { + timeStart('WRITE', 1); + if (!outputOptions.dir && !outputOptions.file) { + return error(logMissingFileOrDirOption()); + } + await Promise.all( + Object.values(generated).map(chunk => + graph.fileOperationQueue.run(() => writeOutputFile(chunk, outputOptions, inputOptions)) + ) + ); + await outputPluginDriver.hookParallel('writeBundle', [outputOptions, generated]); + timeEnd('WRITE', 1); } - await Promise.all( - Object.keys(generated).map(chunkId => writeOutputFile(generated[chunkId], outputOptions)) - ); - await outputPluginDriver.hookParallel('writeBundle', [outputOptions, generated]); - } - return createOutput(generated); + return createOutput(generated); + }); } -function getOutputOptionsAndPluginDriver( - rawOutputOptions: GenericConfigObject, +async function getOutputOptionsAndPluginDriver( + rawOutputOptions: OutputOptions, inputPluginDriver: PluginDriver, inputOptions: NormalizedInputOptions, - unsetInputOptions: Set -): { + unsetInputOptions: ReadonlySet +): Promise<{ options: NormalizedOutputOptions; outputPluginDriver: PluginDriver; unsetOptions: Set; -} { +}> { if (!rawOutputOptions) { throw new Error('You must supply an options object'); } - const rawPlugins = ensureArray(rawOutputOptions.plugins) as Plugin[]; + const rawPlugins = await normalizePluginOption(rawOutputOptions.plugins); normalizePlugins(rawPlugins, ANONYMOUS_OUTPUT_PLUGIN_PREFIX); const outputPluginDriver = inputPluginDriver.createOutputPluginDriver(rawPlugins); return { - ...getOutputOptions(inputOptions, unsetInputOptions, rawOutputOptions, outputPluginDriver), + ...(await getOutputOptions( + inputOptions, + unsetInputOptions, + rawOutputOptions, + outputPluginDriver + )), outputPluginDriver }; } function getOutputOptions( inputOptions: NormalizedInputOptions, - unsetInputOptions: Set, - rawOutputOptions: GenericConfigObject, + unsetInputOptions: ReadonlySet, + rawOutputOptions: OutputOptions, outputPluginDriver: PluginDriver -): { options: NormalizedOutputOptions; unsetOptions: Set } { +): Promise<{ options: NormalizedOutputOptions; unsetOptions: Set }> { return normalizeOutputOptions( outputPluginDriver.hookReduceArg0Sync( 'outputOptions', - [rawOutputOptions.output || rawOutputOptions] as [OutputOptions], + [rawOutputOptions], (outputOptions, result) => result || outputOptions, pluginContext => { - const emitError = () => pluginContext.error(errCannotEmitFromOptionsHook()); + const emitError = () => pluginContext.error(logCannotEmitFromOptionsHook()); return { ...pluginContext, emitFile: emitError, setAssetSource: emitError }; } - ) as GenericConfigObject, + ), inputOptions, unsetInputOptions ); } -function createOutput(outputBundle: Record): RollupOutput { +function createOutput(outputBundle: OutputBundle): RollupOutput { return { - output: (Object.keys(outputBundle) - .map(fileName => outputBundle[fileName]) - .filter(outputFile => Object.keys(outputFile).length > 0) as ( - | OutputChunk - | OutputAsset - )[]).sort((outputFileA, outputFileB) => { - const fileTypeA = getSortingFileType(outputFileA); - const fileTypeB = getSortingFileType(outputFileB); - if (fileTypeA === fileTypeB) return 0; - return fileTypeA < fileTypeB ? -1 : 1; - }) as [OutputChunk, ...(OutputChunk | OutputAsset)[]] + output: ( + Object.values(outputBundle).filter(outputFile => Object.keys(outputFile).length > 0) as ( + | OutputChunk + | OutputAsset + )[] + ).sort( + (outputFileA, outputFileB) => + getSortingFileType(outputFileA) - getSortingFileType(outputFileB) + ) as [OutputChunk, ...(OutputChunk | OutputAsset)[]] }; } @@ -258,30 +309,27 @@ function getSortingFileType(file: OutputAsset | OutputChunk): SortingFileType { return SortingFileType.SECONDARY_CHUNK; } -function writeOutputFile( +async function writeOutputFile( outputFile: OutputAsset | OutputChunk, - outputOptions: NormalizedOutputOptions + outputOptions: NormalizedOutputOptions, + { fs: { mkdir, writeFile } }: NormalizedInputOptions ): Promise { const fileName = resolve(outputOptions.dir || dirname(outputOptions.file!), outputFile.fileName); - let writeSourceMapPromise: Promise | undefined; - let source: string | Uint8Array; - if (outputFile.type === 'asset') { - source = outputFile.source; - } else { - source = outputFile.code; - if (outputOptions.sourcemap && outputFile.map) { - let url: string; - if (outputOptions.sourcemap === 'inline') { - url = outputFile.map.toUrl(); - } else { - url = `${basename(outputFile.fileName)}.map`; - writeSourceMapPromise = writeFile(`${fileName}.map`, outputFile.map.toString()); - } - if (outputOptions.sourcemap !== 'hidden') { - source += `//# ${SOURCEMAPPING_URL}=${url}\n`; - } - } - } - return Promise.all([writeFile(fileName, source), writeSourceMapPromise]); + // 'recursive: true' does not throw if the folder structure, or parts of it, already exist + await mkdir(dirname(fileName), { recursive: true }); + + return writeFile(fileName, outputFile.type === 'asset' ? outputFile.source : outputFile.code); +} + +/** + * Auxiliary function for defining rollup configuration + * Mainly to facilitate IDE code prompts, after all, export default does not + * prompt, even if you add @type annotations, it is not accurate + * @param options + */ +export function defineConfig( + options: T +): T { + return options; } diff --git a/src/rollup/types.d.ts b/src/rollup/types.d.ts index b9dda715aa8..e3c305f76b4 100644 --- a/src/rollup/types.d.ts +++ b/src/rollup/types.d.ts @@ -1,123 +1,145 @@ +import type * as estree from 'estree'; + +declare module 'estree' { + export interface Decorator extends estree.BaseNode { + type: 'Decorator'; + expression: estree.Expression; + } + interface PropertyDefinition { + decorators: estree.Decorator[]; + } + interface MethodDefinition { + decorators: estree.Decorator[]; + } + interface BaseClass { + decorators: estree.Decorator[]; + } +} + export const VERSION: string; -export interface RollupError extends RollupLogProps { - parserError?: Error; - stack?: string; - watchFiles?: string[]; -} - -export interface RollupWarning extends RollupLogProps { - chunkName?: string; - cycle?: string[]; - exporter?: string; - exportName?: string; - guess?: string; - importer?: string; - missing?: string; - modules?: string[]; - names?: string[]; - reexporter?: string; - source?: string; - sources?: string[]; -} - -export interface RollupLogProps { - code?: string; - frame?: string; - hook?: string; - id?: string; +// utils +type NullValue = null | undefined | void; +type MaybeArray = T | T[]; +type MaybePromise = T | Promise; + +type PartialNull = { + [P in keyof T]: T[P] | null; +}; + +export interface RollupError extends RollupLog { + name?: string | undefined; + stack?: string | undefined; + watchFiles?: string[] | undefined; +} + +export interface RollupLog { + binding?: string | undefined; + cause?: unknown | undefined; + code?: string | undefined; + exporter?: string | undefined; + frame?: string | undefined; + hook?: string | undefined; + id?: string | undefined; + ids?: string[] | undefined; loc?: { column: number; - file?: string; + file?: string | undefined; line: number; }; message: string; - name?: string; - plugin?: string; - pluginCode?: string; - pos?: number; - url?: string; + meta?: any | undefined; + names?: string[] | undefined; + plugin?: string | undefined; + pluginCode?: unknown | undefined; + pos?: number | undefined; + reexporter?: string | undefined; + stack?: string | undefined; + url?: string | undefined; } +export type LogLevel = 'warn' | 'info' | 'debug'; +export type LogLevelOption = LogLevel | 'silent'; + export type SourceMapSegment = | [number] | [number, number, number, number] | [number, number, number, number, number]; export interface ExistingDecodedSourceMap { - file?: string; - mappings: SourceMapSegment[][]; + file?: string | undefined; + readonly mappings: SourceMapSegment[][]; names: string[]; - sourceRoot?: string; + sourceRoot?: string | undefined; sources: string[]; - sourcesContent?: string[]; + sourcesContent?: string[] | undefined; version: number; + x_google_ignoreList?: number[] | undefined; } export interface ExistingRawSourceMap { - file?: string; + file?: string | undefined; mappings: string; names: string[]; - sourceRoot?: string; + sourceRoot?: string | undefined; sources: string[]; - sourcesContent?: string[]; + sourcesContent?: string[] | undefined; version: number; + x_google_ignoreList?: number[] | undefined; } export type DecodedSourceMapOrMissing = | { - mappings?: never; missing: true; plugin: string; } - | ExistingDecodedSourceMap; + | (ExistingDecodedSourceMap & { missing?: false | undefined }); export interface SourceMap { file: string; mappings: string; names: string[]; sources: string[]; - sourcesContent: string[]; + sourcesContent?: string[] | undefined; version: number; + debugId?: string | undefined; toString(): string; toUrl(): string; } export type SourceMapInput = ExistingRawSourceMap | string | null | { mappings: '' }; -type PartialNull = { - [P in keyof T]: T[P] | null; -}; - interface ModuleOptions { + attributes: Record; meta: CustomPluginOptions; moduleSideEffects: boolean | 'no-treeshake'; syntheticNamedExports: boolean | string; } export interface SourceDescription extends Partial> { - ast?: AcornNode; + ast?: ProgramNode | undefined; code: string; - map?: SourceMapInput; + map?: SourceMapInput | undefined; } -export interface TransformModuleJSON extends Partial> { - ast?: AcornNode; +export interface TransformModuleJSON { + ast?: ProgramNode | undefined; code: string; + safeVariableNames: Record | null; // note if plugins use new this.cache to opt-out auto transform cache customTransformCache: boolean; originalCode: string; originalSourcemap: ExistingDecodedSourceMap | null; - resolvedIds?: ResolvedIdMap; sourcemapChain: DecodedSourceMapOrMissing[]; transformDependencies: string[]; } -export interface ModuleJSON extends TransformModuleJSON { - alwaysRemovedCode: [number, number][]; - ast: AcornNode; +export interface ModuleJSON extends TransformModuleJSON, ModuleOptions { + safeVariableNames: Record | null; + ast: ProgramNode; dependencies: string[]; id: string; + resolvedIds: ResolvedIdMap; transformFiles: EmittedFile[] | undefined; } @@ -128,89 +150,125 @@ export interface PluginCache { set(id: string, value: T): void; } +export type LoggingFunction = (log: RollupLog | string | (() => RollupLog | string)) => void; + export interface MinimalPluginContext { + debug: LoggingFunction; + error: (error: RollupError | string) => never; + info: LoggingFunction; meta: PluginContextMeta; + warn: LoggingFunction; } export interface EmittedAsset { - fileName?: string; - name?: string; - source?: string | Uint8Array; + fileName?: string | undefined; + name?: string | undefined; + needsCodeReference?: boolean | undefined; + originalFileName?: string | null | undefined; + source?: string | Uint8Array | undefined; type: 'asset'; } export interface EmittedChunk { - fileName?: string; + fileName?: string | undefined; id: string; - implicitlyLoadedAfterOneOf?: string[]; - importer?: string; - name?: string; - preserveSignature?: PreserveEntrySignaturesOption; + implicitlyLoadedAfterOneOf?: string[] | undefined; + importer?: string | undefined; + name?: string | undefined; + preserveSignature?: PreserveEntrySignaturesOption | undefined; type: 'chunk'; } -export type EmittedFile = EmittedAsset | EmittedChunk; - -export type EmitAsset = (name: string, source?: string | Uint8Array) => string; +export interface EmittedPrebuiltChunk { + code: string; + exports?: string[] | undefined; + fileName: string; + map?: SourceMap | undefined; + sourcemapFileName?: string | undefined; + type: 'prebuilt-chunk'; +} -export type EmitChunk = (id: string, options?: { name?: string }) => string; +export type EmittedFile = EmittedAsset | EmittedChunk | EmittedPrebuiltChunk; export type EmitFile = (emittedFile: EmittedFile) => string; -interface ModuleInfo { - ast: AcornNode | null; +export interface ModuleInfo extends ModuleOptions { + ast: ProgramNode | null; code: string | null; - dynamicallyImportedIds: readonly string[]; dynamicImporters: readonly string[]; - hasModuleSideEffects: boolean | 'no-treeshake'; + dynamicallyImportedIdResolutions: readonly ResolvedId[]; + dynamicallyImportedIds: readonly string[]; + exportedBindings: Record | null; + exports: string[] | null; + safeVariableNames: Record | null; + hasDefaultExport: boolean | null; id: string; implicitlyLoadedAfterOneOf: readonly string[]; implicitlyLoadedBefore: readonly string[]; + importedIdResolutions: readonly ResolvedId[]; importedIds: readonly string[]; importers: readonly string[]; isEntry: boolean; isExternal: boolean; - meta: CustomPluginOptions; - syntheticNamedExports: boolean | string; + isIncluded: boolean | null; } export type GetModuleInfo = (moduleId: string) => ModuleInfo | null; +// eslint-disable-next-line @typescript-eslint/consistent-indexed-object-style -- this is an interface so that it can be extended by plugins export interface CustomPluginOptions { [plugin: string]: any; } +type LoggingFunctionWithPosition = ( + log: RollupLog | string | (() => RollupLog | string), + pos?: number | { column: number; line: number } +) => void; + +export type ParseAst = ( + input: string, + options?: { allowReturnOutsideFunction?: boolean; jsx?: boolean } +) => ProgramNode; + +// declare AbortSignal here for environments without DOM lib or @types/node +declare global { + // eslint-disable-next-line @typescript-eslint/no-empty-object-type + interface AbortSignal {} +} + +export type ParseAstAsync = ( + input: string, + options?: { allowReturnOutsideFunction?: boolean; jsx?: boolean; signal?: AbortSignal } +) => Promise; + export interface PluginContext extends MinimalPluginContext { addWatchFile: (id: string) => void; cache: PluginCache; - /** @deprecated Use `this.emitFile` instead */ - emitAsset: EmitAsset; - /** @deprecated Use `this.emitFile` instead */ - emitChunk: EmitChunk; + debug: LoggingFunction; emitFile: EmitFile; - error: (err: RollupError | string, pos?: number | { column: number; line: number }) => never; - /** @deprecated Use `this.getFileName` instead */ - getAssetFileName: (assetReferenceId: string) => string; - /** @deprecated Use `this.getFileName` instead */ - getChunkFileName: (chunkReferenceId: string) => string; + error: (error: RollupError | string) => never; + fs: RollupFsModule; getFileName: (fileReferenceId: string) => string; getModuleIds: () => IterableIterator; getModuleInfo: GetModuleInfo; getWatchFiles: () => string[]; - /** @deprecated Use `this.resolve` instead */ - isExternal: IsExternal; - /** @deprecated Use `this.getModuleIds` instead */ - moduleIds: IterableIterator; - parse: (input: string, options?: any) => AcornNode; + info: LoggingFunction; + load: ( + options: { id: string; resolveDependencies?: boolean } & Partial> + ) => Promise; + parse: ParseAst; resolve: ( source: string, importer?: string, - options?: { custom?: CustomPluginOptions; skipSelf?: boolean } + options?: { + attributes?: Record; + custom?: CustomPluginOptions; + isEntry?: boolean; + skipSelf?: boolean; + } ) => Promise; - /** @deprecated Use `this.resolve` instead */ - resolveId: (source: string, importer?: string) => Promise; setAssetSource: (assetReferenceId: string, source: string | Uint8Array) => void; - warn: (warning: RollupWarning | string, pos?: number | { column: number; line: number }) => void; + warn: LoggingFunction; } export interface PluginContextMeta { @@ -218,28 +276,57 @@ export interface PluginContextMeta { watchMode: boolean; } +export type StringOrRegExp = string | RegExp; + +export type StringFilter = + | MaybeArray + | { + include?: MaybeArray | undefined; + exclude?: MaybeArray | undefined; + }; + +export interface HookFilter { + id?: StringFilter | undefined; + code?: StringFilter | undefined; +} + export interface ResolvedId extends ModuleOptions { external: boolean | 'absolute'; id: string; + resolvedBy: string; } -export interface ResolvedIdMap { - [key: string]: ResolvedId; -} +export type ResolvedIdMap = Record; -interface PartialResolvedId extends Partial> { - external?: boolean | 'absolute' | 'relative'; +export interface PartialResolvedId extends Partial> { + external?: boolean | 'absolute' | 'relative' | undefined; id: string; + resolvedBy?: string | undefined; } -export type ResolveIdResult = string | false | null | undefined | PartialResolvedId; +export type ResolveIdResult = string | NullValue | false | PartialResolvedId; + +export type ResolveIdResultWithoutNullValue = string | false | PartialResolvedId; export type ResolveIdHook = ( this: PluginContext, source: string, importer: string | undefined, - options: { custom?: CustomPluginOptions } -) => Promise | ResolveIdResult; + options: { attributes: Record; custom?: CustomPluginOptions; isEntry: boolean } +) => ResolveIdResult; + +export type ShouldTransformCachedModuleHook = ( + this: PluginContext, + options: { + ast: ProgramNode; + code: string; + id: string; + meta: CustomPluginOptions; + moduleSideEffects: boolean | 'no-treeshake'; + resolvedSources: ResolvedIdMap; + syntheticNamedExports: boolean | string; + } +) => boolean | NullValue; export type IsExternal = ( source: string, @@ -247,77 +334,67 @@ export type IsExternal = ( isResolved: boolean ) => boolean; -export type IsPureModule = (id: string) => boolean | null | undefined; - export type HasModuleSideEffects = (id: string, external: boolean) => boolean; -type LoadResult = SourceDescription | string | null | undefined; +export type LoadResult = SourceDescription | string | NullValue; -export type LoadHook = (this: PluginContext, id: string) => Promise | LoadResult; +export type LoadHook = (this: PluginContext, id: string) => LoadResult; export interface TransformPluginContext extends PluginContext { + debug: LoggingFunctionWithPosition; + error: (error: RollupError | string, pos?: number | { column: number; line: number }) => never; getCombinedSourcemap: () => SourceMap; + info: LoggingFunctionWithPosition; + warn: LoggingFunctionWithPosition; } -export type TransformResult = string | null | undefined | Partial; +export type TransformResult = string | NullValue | Partial; export type TransformHook = ( this: TransformPluginContext, code: string, id: string -) => Promise | TransformResult; +) => TransformResult; -export type ModuleParsedHook = (this: PluginContext, info: ModuleInfo) => Promise | void; +export type ModuleParsedHook = (this: PluginContext, info: ModuleInfo) => void; export type RenderChunkHook = ( this: PluginContext, code: string, chunk: RenderedChunk, - options: NormalizedOutputOptions -) => - | Promise<{ code: string; map?: SourceMapInput } | null> - | { code: string; map?: SourceMapInput } - | string - | null; + options: NormalizedOutputOptions, + meta: { chunks: Record } +) => { code: string; map?: SourceMapInput } | string | NullValue; export type ResolveDynamicImportHook = ( this: PluginContext, - specifier: string | AcornNode, - importer: string -) => Promise | ResolveIdResult; + specifier: string | AstNode, + importer: string, + options: { attributes: Record } +) => ResolveIdResult; export type ResolveImportMetaHook = ( this: PluginContext, - prop: string | null, + property: string | null, options: { chunkId: string; format: InternalModuleFormat; moduleId: string } -) => string | null | undefined; - -export type ResolveAssetUrlHook = ( - this: PluginContext, - options: { - assetFileName: string; - chunkId: string; - format: InternalModuleFormat; - moduleId: string; - relativeAssetPath: string; - } -) => string | null | undefined; +) => string | NullValue; export type ResolveFileUrlHook = ( this: PluginContext, options: { - assetReferenceId: string | null; chunkId: string; - chunkReferenceId: string | null; fileName: string; format: InternalModuleFormat; moduleId: string; referenceId: string; relativePath: string; } -) => string | null | undefined; +) => string | NullValue; -export type AddonHookFunction = (this: PluginContext) => string | Promise; +export type AddonHookFunction = ( + this: PluginContext, + chunk: RenderedChunk +) => string | Promise; export type AddonHook = string | AddonHookFunction; export type ChangeEvent = 'create' | 'update' | 'delete'; @@ -337,46 +414,44 @@ export type WatchChangeHook = ( * const myPlugin: PluginImpl = (options = {}) => { ... } * ``` */ -export type PluginImpl = (options?: O) => Plugin; +export type PluginImpl = (options?: O) => Plugin; -export interface OutputBundle { - [fileName: string]: OutputAsset | OutputChunk; -} +export type OutputBundle = Record; -export interface FilePlaceholder { - type: 'placeholder'; -} +export type PreRenderedChunkWithFileName = PreRenderedChunk & { fileName: string }; -export interface OutputBundleWithPlaceholders { - [fileName: string]: OutputAsset | OutputChunk | FilePlaceholder; +export interface ImportedInternalChunk { + type: 'internal'; + fileName: string; + resolvedImportPath: string; + chunk: PreRenderedChunk; } -export interface PluginHooks extends OutputPluginHooks { - buildEnd: (this: PluginContext, err?: Error) => Promise | void; - buildStart: (this: PluginContext, options: NormalizedInputOptions) => Promise | void; - closeBundle: (this: PluginContext) => Promise | void; - closeWatcher: (this: PluginContext) => void; - load: LoadHook; - moduleParsed: ModuleParsedHook; - options: ( - this: MinimalPluginContext, - options: InputOptions - ) => Promise | InputOptions | null | undefined; - resolveDynamicImport: ResolveDynamicImportHook; - resolveId: ResolveIdHook; - transform: TransformHook; - watchChange: WatchChangeHook; +export interface ImportedExternalChunk { + type: 'external'; + fileName: string; + resolvedImportPath: string; } -interface OutputPluginHooks { - augmentChunkHash: (this: PluginContext, chunk: PreRenderedChunk) => string | void; +export type DynamicImportTargetChunk = ImportedInternalChunk | ImportedExternalChunk; + +export interface FunctionPluginHooks { + augmentChunkHash: (this: PluginContext, chunk: RenderedChunk) => string | void; + buildEnd: (this: PluginContext, error?: Error) => void; + buildStart: (this: PluginContext, options: NormalizedInputOptions) => void; + closeBundle: (this: PluginContext, error?: Error) => void; + closeWatcher: (this: PluginContext) => void; generateBundle: ( this: PluginContext, options: NormalizedOutputOptions, bundle: OutputBundle, isWrite: boolean - ) => void | Promise; - outputOptions: (this: PluginContext, options: OutputOptions) => OutputOptions | null | undefined; + ) => void; + load: LoadHook; + moduleParsed: ModuleParsedHook; + onLog: (this: MinimalPluginContext, level: LogLevel, log: RollupLog) => boolean | NullValue; + options: (this: MinimalPluginContext, options: InputOptions) => InputOptions | NullValue; + outputOptions: (this: PluginContext, options: OutputOptions) => OutputOptions | NullValue; renderChunk: RenderChunkHook; renderDynamicImport: ( this: PluginContext, @@ -385,186 +460,263 @@ interface OutputPluginHooks { format: InternalModuleFormat; moduleId: string; targetModuleId: string | null; + chunk: PreRenderedChunkWithFileName; + targetChunk: PreRenderedChunkWithFileName | null; + getTargetChunkImports: () => DynamicImportTargetChunk[] | null; } - ) => { left: string; right: string } | null | undefined; - renderError: (this: PluginContext, err?: Error) => Promise | void; + ) => { left: string; right: string } | NullValue; + renderError: (this: PluginContext, error?: Error) => void; renderStart: ( this: PluginContext, outputOptions: NormalizedOutputOptions, inputOptions: NormalizedInputOptions - ) => Promise | void; - /** @deprecated Use `resolveFileUrl` instead */ - resolveAssetUrl: ResolveAssetUrlHook; + ) => void; + resolveDynamicImport: ResolveDynamicImportHook; resolveFileUrl: ResolveFileUrlHook; + resolveId: ResolveIdHook; resolveImportMeta: ResolveImportMetaHook; + shouldTransformCachedModule: ShouldTransformCachedModuleHook; + transform: TransformHook; + watchChange: WatchChangeHook; writeBundle: ( this: PluginContext, options: NormalizedOutputOptions, bundle: OutputBundle - ) => void | Promise; + ) => void; } -export type AsyncPluginHooks = - | 'options' - | 'buildEnd' - | 'buildStart' +export type OutputPluginHooks = + | 'augmentChunkHash' | 'generateBundle' - | 'load' - | 'moduleParsed' + | 'outputOptions' | 'renderChunk' + | 'renderDynamicImport' | 'renderError' | 'renderStart' - | 'resolveDynamicImport' - | 'resolveId' - | 'transform' - | 'writeBundle' - | 'closeBundle'; + | 'resolveFileUrl' + | 'resolveImportMeta' + | 'writeBundle'; -export type PluginValueHooks = 'banner' | 'footer' | 'intro' | 'outro'; +export type InputPluginHooks = Exclude; -export type SyncPluginHooks = Exclude; +export type SyncPluginHooks = + | 'augmentChunkHash' + | 'onLog' + | 'outputOptions' + | 'renderDynamicImport' + | 'resolveFileUrl' + | 'resolveImportMeta'; + +export type AsyncPluginHooks = Exclude; export type FirstPluginHooks = | 'load' | 'renderDynamicImport' - | 'resolveAssetUrl' | 'resolveDynamicImport' | 'resolveFileUrl' | 'resolveId' - | 'resolveImportMeta'; + | 'resolveImportMeta' + | 'shouldTransformCachedModule'; export type SequentialPluginHooks = | 'augmentChunkHash' - | 'closeWatcher' | 'generateBundle' + | 'onLog' | 'options' | 'outputOptions' | 'renderChunk' - | 'transform' - | 'watchChange'; - -export type ParallelPluginHooks = - | 'banner' - | 'buildEnd' - | 'buildStart' - | 'footer' - | 'intro' - | 'moduleParsed' - | 'outro' - | 'renderError' - | 'renderStart' - | 'writeBundle' - | 'closeBundle'; + | 'transform'; + +export type ParallelPluginHooks = Exclude< + keyof FunctionPluginHooks | AddonHooks, + FirstPluginHooks | SequentialPluginHooks +>; + +export type AddonHooks = 'banner' | 'footer' | 'intro' | 'outro'; + +type MakeAsync = Function_ extends ( + this: infer This, + ...parameters: infer Arguments +) => infer Return + ? (this: This, ...parameters: Arguments) => Return | Promise + : never; + +// eslint-disable-next-line @typescript-eslint/no-empty-object-type +export type ObjectHook = T | ({ handler: T; order?: 'pre' | 'post' | null } & O); + +export type HookFilterExtension = K extends 'transform' + ? { filter?: HookFilter | undefined } + : K extends 'load' + ? { filter?: Pick | undefined } + : K extends 'resolveId' + ? { filter?: { id?: StringFilter | undefined } } | undefined + : // eslint-disable-next-line @typescript-eslint/no-empty-object-type + {}; + +export type PluginHooks = { + [K in keyof FunctionPluginHooks]: ObjectHook< + K extends AsyncPluginHooks ? MakeAsync : FunctionPluginHooks[K], + // eslint-disable-next-line @typescript-eslint/no-empty-object-type + HookFilterExtension & (K extends ParallelPluginHooks ? { sequential?: boolean } : {}) + >; +}; -interface OutputPluginValueHooks { - banner: AddonHook; - cacheKey: string; - footer: AddonHook; - intro: AddonHook; - outro: AddonHook; +export interface OutputPlugin + extends + Partial<{ [K in OutputPluginHooks]: PluginHooks[K] }>, + Partial>> { + cacheKey?: string | undefined; + name: string; + version?: string | undefined; } -export interface Plugin extends Partial, Partial { +export interface Plugin extends OutputPlugin, Partial { // for inter-plugin communication - api?: any; - name: string; + api?: A | undefined; } -export interface OutputPlugin extends Partial, Partial { - name: string; +export type JsxPreset = 'react' | 'react-jsx' | 'preserve' | 'preserve-react'; + +export type NormalizedJsxOptions = + | NormalizedJsxPreserveOptions + | NormalizedJsxClassicOptions + | NormalizedJsxAutomaticOptions; + +interface NormalizedJsxPreserveOptions { + factory: string | null; + fragment: string | null; + importSource: string | null; + mode: 'preserve'; +} + +interface NormalizedJsxClassicOptions { + factory: string; + fragment: string; + importSource: string | null; + mode: 'classic'; } -export interface TreeshakingOptions { - annotations?: boolean; - moduleSideEffects?: ModuleSideEffectsOption; - propertyReadSideEffects?: boolean | 'always'; - /** @deprecated Use `moduleSideEffects` instead */ - pureExternalModules?: PureModulesOption; - tryCatchDeoptimization?: boolean; - unknownGlobalSideEffects?: boolean; +interface NormalizedJsxAutomaticOptions { + factory: string; + importSource: string | null; + jsxImportSource: string; + mode: 'automatic'; } +export type JsxOptions = Partial & { + preset?: JsxPreset | undefined; +}; + +export type TreeshakingPreset = 'smallest' | 'safest' | 'recommended'; + export interface NormalizedTreeshakingOptions { annotations: boolean; + correctVarValueBeforeDeclaration: boolean; + manualPureFunctions: readonly string[]; moduleSideEffects: HasModuleSideEffects; propertyReadSideEffects: boolean | 'always'; tryCatchDeoptimization: boolean; unknownGlobalSideEffects: boolean; } -interface GetManualChunkApi { +export interface TreeshakingOptions extends Partial< + Omit +> { + moduleSideEffects?: ModuleSideEffectsOption | undefined; + preset?: TreeshakingPreset | undefined; +} + +interface ManualChunkMeta { getModuleIds: () => IterableIterator; getModuleInfo: GetModuleInfo; } -export type GetManualChunk = (id: string, api: GetManualChunkApi) => string | null | undefined; + +export type GetManualChunk = (id: string, meta: ManualChunkMeta) => string | NullValue; export type ExternalOption = | (string | RegExp)[] | string | RegExp - | (( - source: string, - importer: string | undefined, - isResolved: boolean - ) => boolean | null | undefined); -export type PureModulesOption = boolean | string[] | IsPureModule; -export type GlobalsOption = { [name: string]: string } | ((name: string) => string); -export type InputOption = string | string[] | { [entryAlias: string]: string }; -export type ManualChunksOption = { [chunkAlias: string]: string[] } | GetManualChunk; + | ((source: string, importer: string | undefined, isResolved: boolean) => boolean | NullValue); + +export type GlobalsOption = Record | ((name: string) => string); + +export type InputOption = string | string[] | Record; + +export type ManualChunksOption = Record | GetManualChunk; + +export type LogHandlerWithDefault = ( + level: LogLevel, + log: RollupLog, + defaultHandler: LogOrStringHandler +) => void; + +export type LogOrStringHandler = (level: LogLevel | 'error', log: RollupLog | string) => void; + +export type LogHandler = (level: LogLevel, log: RollupLog) => void; + export type ModuleSideEffectsOption = boolean | 'no-external' | string[] | HasModuleSideEffects; + export type PreserveEntrySignaturesOption = false | 'strict' | 'allow-extension' | 'exports-only'; + export type SourcemapPathTransformOption = ( relativeSourcePath: string, sourcemapPath: string ) => string; +export type SourcemapIgnoreListOption = ( + relativeSourcePath: string, + sourcemapPath: string +) => boolean; + +export type InputPluginOption = MaybePromise; + export interface InputOptions { - acorn?: Object; - acornInjectPlugins?: Function | Function[]; - cache?: false | RollupCache; - context?: string; - experimentalCacheExpiry?: number; - external?: ExternalOption; - /** @deprecated Use the "inlineDynamicImports" output option instead. */ - inlineDynamicImports?: boolean; - input?: InputOption; - makeAbsoluteExternalsRelative?: boolean | 'ifRelativeSource'; - /** @deprecated Use the "manualChunks" output option instead. */ - manualChunks?: ManualChunksOption; - moduleContext?: ((id: string) => string | null | undefined) | { [id: string]: string }; - onwarn?: WarningHandlerWithDefault; - perf?: boolean; - plugins?: Plugin[]; - preserveEntrySignatures?: PreserveEntrySignaturesOption; - /** @deprecated Use the "preserveModules" output option instead. */ - preserveModules?: boolean; - preserveSymlinks?: boolean; - shimMissingExports?: boolean; - strictDeprecations?: boolean; - treeshake?: boolean | TreeshakingOptions; - watch?: WatcherOptions | false; + cache?: boolean | RollupCache | undefined; + context?: string | undefined; + experimentalCacheExpiry?: number | undefined; + experimentalLogSideEffects?: boolean | undefined; + external?: ExternalOption | undefined; + fs?: RollupFsModule | undefined; + input?: InputOption | undefined; + jsx?: false | JsxPreset | JsxOptions | undefined; + logLevel?: LogLevelOption | undefined; + makeAbsoluteExternalsRelative?: boolean | 'ifRelativeSource' | undefined; + maxParallelFileOps?: number | undefined; + moduleContext?: ((id: string) => string | NullValue) | Record | undefined; + onLog?: LogHandlerWithDefault | undefined; + onwarn?: WarningHandlerWithDefault | undefined; + perf?: boolean | undefined; + plugins?: InputPluginOption | undefined; + preserveEntrySignatures?: PreserveEntrySignaturesOption | undefined; + preserveSymlinks?: boolean | undefined; + shimMissingExports?: boolean | undefined; + strictDeprecations?: boolean | undefined; + treeshake?: boolean | TreeshakingPreset | TreeshakingOptions | undefined; + watch?: WatcherOptions | false | undefined; +} + +export interface InputOptionsWithPlugins extends InputOptions { + plugins: Plugin[]; } export interface NormalizedInputOptions { - acorn: Object; - acornInjectPlugins: Function[]; cache: false | undefined | RollupCache; context: string; experimentalCacheExpiry: number; + experimentalLogSideEffects: boolean; external: IsExternal; - /** @deprecated Use the "inlineDynamicImports" output option instead. */ - inlineDynamicImports: boolean | undefined; - input: string[] | { [entryAlias: string]: string }; + fs: RollupFsModule; + input: string[] | Record; + jsx: false | NormalizedJsxOptions; + logLevel: LogLevelOption; makeAbsoluteExternalsRelative: boolean | 'ifRelativeSource'; - /** @deprecated Use the "manualChunks" output option instead. */ - manualChunks: ManualChunksOption | undefined; + maxParallelFileOps: number; moduleContext: (id: string) => string; - onwarn: WarningHandler; + onLog: LogHandler; perf: boolean; plugins: Plugin[]; preserveEntrySignatures: PreserveEntrySignaturesOption; - /** @deprecated Use the "preserveModules" output option instead. */ - preserveModules: boolean | undefined; preserveSymlinks: boolean; shimMissingExports: boolean; strictDeprecations: boolean; @@ -572,37 +724,53 @@ export interface NormalizedInputOptions { } export type InternalModuleFormat = 'amd' | 'cjs' | 'es' | 'iife' | 'system' | 'umd'; +export type ImportAttributesKey = 'with' | 'assert'; export type ModuleFormat = InternalModuleFormat | 'commonjs' | 'esm' | 'module' | 'systemjs'; +type GeneratedCodePreset = 'es5' | 'es2015'; + +interface NormalizedGeneratedCodeOptions { + arrowFunctions: boolean; + constBindings: boolean; + objectShorthand: boolean; + reservedNamesAsProps: boolean; + symbols: boolean; +} + +interface GeneratedCodeOptions extends Partial { + preset?: GeneratedCodePreset | undefined; +} + export type OptionsPaths = Record | ((id: string) => string); -export type InteropType = boolean | 'auto' | 'esModule' | 'default' | 'defaultOnly'; +export type InteropType = 'compat' | 'auto' | 'esModule' | 'default' | 'defaultOnly'; export type GetInterop = (id: string | null) => InteropType; export type AmdOptions = ( | { - autoId?: false; + autoId?: false | undefined; id: string; } | { autoId: true; - basePath?: string; - id?: undefined; + basePath?: string | undefined; + id?: undefined | undefined; } | { - autoId?: false; - id?: undefined; + autoId?: false | undefined; + id?: undefined | undefined; } ) & { - define?: string; + define?: string | undefined; + forceJsExtensionForImports?: boolean | undefined; }; export type NormalizedAmdOptions = ( | { autoId: false; - id?: string; + id?: string | undefined; } | { autoId: true; @@ -610,126 +778,159 @@ export type NormalizedAmdOptions = ( } ) & { define: string; + forceJsExtensionForImports: boolean; }; +type AddonFunction = (chunk: RenderedChunk) => string | Promise; + +type OutputPluginOption = MaybePromise; + +type HashCharacters = 'base64' | 'base36' | 'hex'; + export interface OutputOptions { - amd?: AmdOptions; - assetFileNames?: string | ((chunkInfo: PreRenderedAsset) => string); - banner?: string | (() => string | Promise); - chunkFileNames?: string | ((chunkInfo: PreRenderedChunk) => string); - compact?: boolean; + amd?: AmdOptions | undefined; + assetFileNames?: string | ((chunkInfo: PreRenderedAsset) => string) | undefined; + banner?: string | AddonFunction | undefined; + chunkFileNames?: string | ((chunkInfo: PreRenderedChunk) => string) | undefined; + compact?: boolean | undefined; // only required for bundle.write - dir?: string; - /** @deprecated Use the "renderDynamicImport" plugin hook instead. */ - dynamicImportFunction?: string; - entryFileNames?: string | ((chunkInfo: PreRenderedChunk) => string); - esModule?: boolean; - exports?: 'default' | 'named' | 'none' | 'auto'; - extend?: boolean; - externalLiveBindings?: boolean; + dir?: string | undefined; + dynamicImportInCjs?: boolean | undefined; + entryFileNames?: string | ((chunkInfo: PreRenderedChunk) => string) | undefined; + esModule?: boolean | 'if-default-prop' | undefined; + experimentalMinChunkSize?: number | undefined; + exports?: 'default' | 'named' | 'none' | 'auto' | undefined; + extend?: boolean | undefined; + /** @deprecated Use "externalImportAttributes" instead. */ + externalImportAssertions?: boolean | undefined; + externalImportAttributes?: boolean | undefined; + externalLiveBindings?: boolean | undefined; // only required for bundle.write - file?: string; - footer?: string | (() => string | Promise); - format?: ModuleFormat; - freeze?: boolean; - globals?: GlobalsOption; - hoistTransitiveImports?: boolean; - indent?: string | boolean; - inlineDynamicImports?: boolean; - interop?: InteropType | GetInterop; - intro?: string | (() => string | Promise); - manualChunks?: ManualChunksOption; - minifyInternalExports?: boolean; - name?: string; - namespaceToStringTag?: boolean; - noConflict?: boolean; - outro?: string | (() => string | Promise); - paths?: OptionsPaths; - plugins?: OutputPlugin[]; - preferConst?: boolean; - preserveModules?: boolean; - preserveModulesRoot?: string; - sourcemap?: boolean | 'inline' | 'hidden'; - sourcemapExcludeSources?: boolean; - sourcemapFile?: string; - sourcemapPathTransform?: SourcemapPathTransformOption; - strict?: boolean; - systemNullSetters?: boolean; - validate?: boolean; + file?: string | undefined; + footer?: string | AddonFunction | undefined; + format?: ModuleFormat | undefined; + freeze?: boolean | undefined; + generatedCode?: GeneratedCodePreset | GeneratedCodeOptions | undefined; + globals?: GlobalsOption | undefined; + hashCharacters?: HashCharacters | undefined; + hoistTransitiveImports?: boolean | undefined; + importAttributesKey?: ImportAttributesKey | undefined; + indent?: string | boolean | undefined; + inlineDynamicImports?: boolean | undefined; + interop?: InteropType | GetInterop | undefined; + intro?: string | AddonFunction | undefined; + manualChunks?: ManualChunksOption | undefined; + minifyInternalExports?: boolean | undefined; + name?: string | undefined; + noConflict?: boolean | undefined; + /** @deprecated This will be the new default in Rollup 5. */ + onlyExplicitManualChunks?: boolean | undefined; + outro?: string | AddonFunction | undefined; + paths?: OptionsPaths | undefined; + plugins?: OutputPluginOption | undefined; + preserveModules?: boolean | undefined; + preserveModulesRoot?: string | undefined; + reexportProtoFromExternal?: boolean | undefined; + sanitizeFileName?: boolean | ((fileName: string) => string) | undefined; + sourcemap?: boolean | 'inline' | 'hidden' | undefined; + sourcemapBaseUrl?: string | undefined; + sourcemapExcludeSources?: boolean | undefined; + sourcemapFile?: string | undefined; + sourcemapFileNames?: string | ((chunkInfo: PreRenderedChunk) => string) | undefined; + sourcemapIgnoreList?: boolean | SourcemapIgnoreListOption | undefined; + sourcemapPathTransform?: SourcemapPathTransformOption | undefined; + sourcemapDebugIds?: boolean | undefined; + strict?: boolean | undefined; + systemNullSetters?: boolean | undefined; + validate?: boolean | undefined; + virtualDirname?: string | undefined; } export interface NormalizedOutputOptions { amd: NormalizedAmdOptions; assetFileNames: string | ((chunkInfo: PreRenderedAsset) => string); - banner: () => string | Promise; + banner: AddonFunction; chunkFileNames: string | ((chunkInfo: PreRenderedChunk) => string); compact: boolean; dir: string | undefined; - /** @deprecated Use the "renderDynamicImport" plugin hook instead. */ - dynamicImportFunction: string | undefined; + dynamicImportInCjs: boolean; entryFileNames: string | ((chunkInfo: PreRenderedChunk) => string); - esModule: boolean; + esModule: boolean | 'if-default-prop'; + experimentalMinChunkSize: number; exports: 'default' | 'named' | 'none' | 'auto'; extend: boolean; + /** @deprecated Use "externalImportAttributes" instead. */ + externalImportAssertions: boolean; + externalImportAttributes: boolean; externalLiveBindings: boolean; file: string | undefined; - footer: () => string | Promise; + footer: AddonFunction; format: InternalModuleFormat; freeze: boolean; + generatedCode: NormalizedGeneratedCodeOptions; globals: GlobalsOption; + hashCharacters: HashCharacters; hoistTransitiveImports: boolean; + importAttributesKey: ImportAttributesKey; indent: true | string; inlineDynamicImports: boolean; interop: GetInterop; - intro: () => string | Promise; + intro: AddonFunction; manualChunks: ManualChunksOption; minifyInternalExports: boolean; name: string | undefined; - namespaceToStringTag: boolean; noConflict: boolean; - outro: () => string | Promise; + onlyExplicitManualChunks: boolean; + outro: AddonFunction; paths: OptionsPaths; plugins: OutputPlugin[]; - preferConst: boolean; preserveModules: boolean; preserveModulesRoot: string | undefined; + reexportProtoFromExternal: boolean; + sanitizeFileName: (fileName: string) => string; sourcemap: boolean | 'inline' | 'hidden'; + sourcemapBaseUrl: string | undefined; sourcemapExcludeSources: boolean; sourcemapFile: string | undefined; + sourcemapFileNames: string | ((chunkInfo: PreRenderedChunk) => string) | undefined; + sourcemapIgnoreList: SourcemapIgnoreListOption; sourcemapPathTransform: SourcemapPathTransformOption | undefined; + sourcemapDebugIds: boolean; strict: boolean; systemNullSetters: boolean; validate: boolean; + virtualDirname: string; } export type WarningHandlerWithDefault = ( - warning: RollupWarning, - defaultHandler: WarningHandler + warning: RollupLog, + defaultHandler: LoggingFunction ) => void; -export type WarningHandler = (warning: RollupWarning) => void; -export interface SerializedTimings { - [label: string]: [number, number, number]; -} +export type SerializedTimings = Record; export interface PreRenderedAsset { + /** @deprecated Use "names" instead. */ name: string | undefined; + names: string[]; + /** @deprecated Use "originalFileNames" instead. */ + originalFileName: string | null; + originalFileNames: string[]; source: string | Uint8Array; type: 'asset'; } export interface OutputAsset extends PreRenderedAsset { fileName: string; - /** @deprecated Accessing "isAsset" on files in the bundle is deprecated, please use "type === \'asset\'" instead */ - isAsset: true; + needsCodeReference: boolean; } export interface RenderedModule { + readonly code: string | null; originalLength: number; removedExports: string[]; renderedExports: string[]; renderedLength: number; - code: string | null; } export interface PreRenderedChunk { @@ -738,33 +939,29 @@ export interface PreRenderedChunk { isDynamicEntry: boolean; isEntry: boolean; isImplicitEntry: boolean; - modules: { - [id: string]: RenderedModule; - }; + moduleIds: string[]; name: string; type: 'chunk'; } export interface RenderedChunk extends PreRenderedChunk { - code?: string; dynamicImports: string[]; fileName: string; implicitlyLoadedBefore: string[]; - importedBindings: { - [imported: string]: string[]; - }; + importedBindings: Record; imports: string[]; - map?: SourceMap; + modules: Record; referencedFiles: string[]; } export interface OutputChunk extends RenderedChunk { code: string; + map: SourceMap | null; + sourcemapFileName: string | null; + preliminaryFileName: string; } -export interface SerializablePluginCache { - [key: string]: [number, any]; -} +export type SerializablePluginCache = Record; export interface RollupCache { modules: ModuleJSON[]; @@ -779,105 +976,215 @@ export interface RollupBuild { cache: RollupCache | undefined; close: () => Promise; closed: boolean; + [Symbol.asyncDispose](): Promise; generate: (outputOptions: OutputOptions) => Promise; - getTimings?: () => SerializedTimings; + getTimings?: (() => SerializedTimings) | undefined; watchFiles: string[]; write: (options: OutputOptions) => Promise; } export interface RollupOptions extends InputOptions { // This is included for compatibility with config files but ignored by rollup.rollup - output?: OutputOptions | OutputOptions[]; + output?: OutputOptions | OutputOptions[] | undefined; } -export interface MergedRollupOptions extends InputOptions { +export interface MergedRollupOptions extends InputOptionsWithPlugins { output: OutputOptions[]; } export function rollup(options: RollupOptions): Promise; export interface ChokidarOptions { - alwaysStat?: boolean; - atomic?: boolean | number; + alwaysStat?: boolean | undefined; + atomic?: boolean | number | undefined; awaitWriteFinish?: | { - pollInterval?: number; - stabilityThreshold?: number; + pollInterval?: number | undefined; + stabilityThreshold?: number | undefined; } - | boolean; - binaryInterval?: number; - cwd?: string; - depth?: number; - disableGlobbing?: boolean; - followSymlinks?: boolean; - ignored?: any; - ignoreInitial?: boolean; - ignorePermissionErrors?: boolean; - interval?: number; - persistent?: boolean; - useFsEvents?: boolean; - usePolling?: boolean; + | boolean + | undefined; + binaryInterval?: number | undefined; + cwd?: string | undefined; + depth?: number | undefined; + disableGlobbing?: boolean | undefined; + followSymlinks?: boolean | undefined; + ignoreInitial?: boolean | undefined; + ignorePermissionErrors?: boolean | undefined; + ignored?: any | undefined; + interval?: number | undefined; + persistent?: boolean | undefined; + useFsEvents?: boolean | undefined; + usePolling?: boolean | undefined; } +export type RollupWatchHooks = 'onError' | 'onStart' | 'onBundleStart' | 'onBundleEnd' | 'onEnd'; + export interface WatcherOptions { - buildDelay?: number; - chokidar?: ChokidarOptions; - clearScreen?: boolean; - exclude?: string | RegExp | (string | RegExp)[]; - include?: string | RegExp | (string | RegExp)[]; - skipWrite?: boolean; + allowInputInsideOutputPath?: boolean | undefined; + buildDelay?: number | undefined; + chokidar?: ChokidarOptions | undefined; + clearScreen?: boolean | undefined; + exclude?: string | RegExp | (string | RegExp)[] | undefined; + include?: string | RegExp | (string | RegExp)[] | undefined; + skipWrite?: boolean | undefined; + onInvalidate?: ((id: string) => void) | undefined; } export interface RollupWatchOptions extends InputOptions { - output?: OutputOptions | OutputOptions[]; - watch?: WatcherOptions | false; -} - -interface TypedEventEmitter any }> { - addListener(event: K, listener: T[K]): this; - emit(event: K, ...args: Parameters): boolean; - eventNames(): Array; - getMaxListeners(): number; - listenerCount(type: keyof T): number; - listeners(event: K): Array; - off(event: K, listener: T[K]): this; - on(event: K, listener: T[K]): this; - once(event: K, listener: T[K]): this; - prependListener(event: K, listener: T[K]): this; - prependOnceListener(event: K, listener: T[K]): this; - rawListeners(event: K): Array; - removeAllListeners(event?: K): this; - removeListener(event: K, listener: T[K]): this; - setMaxListeners(n: number): this; + output?: OutputOptions | OutputOptions[] | undefined; + watch?: WatcherOptions | false | undefined; +} + +export type AwaitedEventListener< + T extends Record any>, + K extends keyof T +> = (...parameters: Parameters) => void | Promise; + +export interface AwaitingEventEmitter any>> { + close(): Promise; + emit(event: K, ...parameters: Parameters): Promise; + /** + * Removes an event listener. + */ + off(event: K, listener: AwaitedEventListener): this; + /** + * Registers an event listener that will be awaited before Rollup continues. + * All listeners will be awaited in parallel while rejections are tracked via + * Promise.all. + */ + on(event: K, listener: AwaitedEventListener): this; + /** + * Registers an event listener that will be awaited before Rollup continues. + * All listeners will be awaited in parallel while rejections are tracked via + * Promise.all. + * Listeners are removed automatically when removeListenersForCurrentRun is + * called, which happens automatically after each run. + */ + onCurrentRun( + event: K, + listener: (...parameters: Parameters) => Promise> + ): this; + removeAllListeners(): this; + removeListenersForCurrentRun(): this; } export type RollupWatcherEvent = | { code: 'START' } - | { code: 'BUNDLE_START'; input?: InputOption; output: readonly string[] } + | { code: 'BUNDLE_START'; input?: InputOption | undefined; output: readonly string[] } | { code: 'BUNDLE_END'; duration: number; - input?: InputOption; + input?: InputOption | undefined; output: readonly string[]; result: RollupBuild; } | { code: 'END' } | { code: 'ERROR'; error: RollupError; result: RollupBuild | null }; -export interface RollupWatcher - extends TypedEventEmitter<{ - change: (id: string, change: { event: ChangeEvent }) => void; - close: () => void; - event: (event: RollupWatcherEvent) => void; - restart: () => void; - }> { - close(): void; -} +export type RollupWatcher = AwaitingEventEmitter<{ + change: (id: string, change: { event: ChangeEvent }) => void; + close: () => void; + event: (event: RollupWatcherEvent) => void; + restart: () => void; +}>; export function watch(config: RollupWatchOptions | RollupWatchOptions[]): RollupWatcher; -interface AcornNode { +interface AstNodeLocation { end: number; start: number; - type: string; +} + +type OmittedEstreeKeys = + | 'loc' + | 'range' + | 'leadingComments' + | 'trailingComments' + | 'innerComments' + | 'comments'; +type RollupAstNode = Omit & AstNodeLocation; + +type ProgramNode = RollupAstNode; +export type AstNode = RollupAstNode; + +export function defineConfig(options: RollupOptions): RollupOptions; +export function defineConfig(options: RollupOptions[]): RollupOptions[]; +export function defineConfig(optionsFunction: RollupOptionsFunction): RollupOptionsFunction; + +export type RollupOptionsFunction = ( + commandLineArguments: Record +) => MaybePromise; + +export interface RollupFsModule { + appendFile( + path: string, + data: string | Uint8Array, + options?: { encoding?: BufferEncoding | null; mode?: string | number; flag?: string | number } + ): Promise; + + copyFile(source: string, destination: string, mode?: string | number): Promise; + + mkdir(path: string, options?: { recursive?: boolean; mode?: string | number }): Promise; + + mkdtemp(prefix: string): Promise; + + readdir(path: string, options?: { withFileTypes?: false }): Promise; + readdir(path: string, options?: { withFileTypes: true }): Promise; + + readFile( + path: string, + options?: { encoding?: null; flag?: string | number; signal?: AbortSignal } + ): Promise; + readFile( + path: string, + options?: { encoding: BufferEncoding; flag?: string | number; signal?: AbortSignal } + ): Promise; + + realpath(path: string): Promise; + + rename(oldPath: string, newPath: string): Promise; + + rmdir(path: string, options?: { recursive?: boolean }): Promise; + + stat(path: string): Promise; + + lstat(path: string): Promise; + + unlink(path: string): Promise; + + writeFile( + path: string, + data: string | Uint8Array, + options?: { encoding?: BufferEncoding | null; mode?: string | number; flag?: string | number } + ): Promise; +} + +export type BufferEncoding = + | 'ascii' + | 'utf8' + | 'utf16le' + | 'ucs2' + | 'base64' + | 'base64url' + | 'latin1' + | 'binary' + | 'hex'; + +export interface RollupDirectoryEntry { + isFile(): boolean; + isDirectory(): boolean; + isSymbolicLink(): boolean; + name: string; +} + +export interface RollupFileStats { + isFile(): boolean; + isDirectory(): boolean; + isSymbolicLink(): boolean; + size: number; + mtime: Date; + ctime: Date; + atime: Date; + birthtime: Date; } diff --git a/src/utils/FileEmitter.ts b/src/utils/FileEmitter.ts index 2c63cbd79f5..e506c77b1a4 100644 --- a/src/utils/FileEmitter.ts +++ b/src/utils/FileEmitter.ts @@ -1,123 +1,151 @@ -import Chunk from '../Chunk'; -import Graph from '../Graph'; -import Module from '../Module'; -import { +import type Chunk from '../Chunk'; +import type Graph from '../Graph'; +import type Module from '../Module'; +import type { + EmittedAsset, EmittedChunk, - FilePlaceholder, + EmittedPrebuiltChunk, + LogHandler, NormalizedInputOptions, - OutputBundleWithPlaceholders, - PreRenderedAsset, - WarningHandler + NormalizedOutputOptions, + OutputChunk } from '../rollup/types'; import { BuildPhase } from './buildPhase'; -import { createHash } from './crypto'; +import type { GetHash } from './crypto'; +import { getHash64, hasherByType } from './crypto'; +import { getNewArray, getOrCreate } from './getOrCreate'; +import { DEFAULT_HASH_SIZE, MAX_HASH_SIZE } from './hashPlaceholders'; +import { LOGLEVEL_WARN } from './logging'; import { - errAssetNotFinalisedForFileName, - errAssetReferenceIdNotFoundForSetSource, - errAssetSourceAlreadySet, - errChunkNotGeneratedForFileName, - errFailedValidation, - errFileNameConflict, - errFileReferenceIdNotFoundForFilename, - errInvalidRollupPhaseForChunkEmission, - errNoAssetSourceSet, error, + logAssetNotFinalisedForFileName, + logAssetReferenceIdNotFoundForSetSource, + logAssetSourceAlreadySet, + logChunkNotGeneratedForFileName, + logFailedValidation, + logFileNameConflict, + logFileReferenceIdNotFoundForFilename, + logInvalidRollupPhaseForChunkEmission, + logNoAssetSourceSet, warnDeprecation -} from './error'; +} from './logs'; +import type { OutputBundleWithPlaceholders } from './outputBundle'; +import { FILE_PLACEHOLDER, lowercaseBundleKeys } from './outputBundle'; import { extname } from './path'; -import { isPlainPathFragment } from './relativeId'; +import { isPathFragment } from './relativeId'; import { makeUnique, renderNamePattern } from './renderNamePattern'; - -interface OutputSpecificFileData { - assetFileNames: string | ((assetInfo: PreRenderedAsset) => string); - bundle: OutputBundleWithPlaceholders; -} +import { URL_GENERATEBUNDLE } from './urls'; function generateAssetFileName( name: string | undefined, + names: string[], source: string | Uint8Array, - output: OutputSpecificFileData + originalFileName: string | null, + originalFileNames: string[], + sourceHash: string, + outputOptions: NormalizedOutputOptions, + bundle: OutputBundleWithPlaceholders, + inputOptions: NormalizedInputOptions ): string { - const emittedName = name || 'asset'; + const emittedName = outputOptions.sanitizeFileName(name || 'asset'); return makeUnique( renderNamePattern( - typeof output.assetFileNames === 'function' - ? output.assetFileNames({ name, source, type: 'asset' }) - : output.assetFileNames, + typeof outputOptions.assetFileNames === 'function' + ? outputOptions.assetFileNames({ + // Additionally, this should be non-enumerable in the next major + get name() { + warnDeprecation( + 'Accessing the "name" property of emitted assets when generating the file name is deprecated. Use the "names" property instead.', + URL_GENERATEBUNDLE, + false, + inputOptions + ); + return name; + }, + names, + // Additionally, this should be non-enumerable in the next major + get originalFileName() { + warnDeprecation( + 'Accessing the "originalFileName" property of emitted assets when generating the file name is deprecated. Use the "originalFileNames" property instead.', + URL_GENERATEBUNDLE, + false, + inputOptions + ); + return originalFileName; + }, + originalFileNames, + source, + type: 'asset' + }) + : outputOptions.assetFileNames, 'output.assetFileNames', { - hash() { - const hash = createHash(); - hash.update(emittedName); - hash.update(':'); - hash.update(source); - return hash.digest('hex').substr(0, 8); - }, - ext: () => extname(emittedName).substr(1), + ext: () => extname(emittedName).slice(1), extname: () => extname(emittedName), - name: () => emittedName.substr(0, emittedName.length - extname(emittedName).length) + hash: size => + sourceHash.slice(0, Math.min(Math.max(0, size || DEFAULT_HASH_SIZE), MAX_HASH_SIZE)), + name: () => + emittedName.slice(0, Math.max(0, emittedName.length - extname(emittedName).length)) } ), - output.bundle + bundle ); } -function reserveFileNameInBundle( - fileName: string, - bundle: OutputBundleWithPlaceholders, - warn: WarningHandler -) { - if (fileName in bundle) { - warn(errFileNameConflict(fileName)); +function reserveFileNameInBundle(fileName: string, { bundle }: FileEmitterOutput, log: LogHandler) { + if (bundle[lowercaseBundleKeys].has(fileName.toLowerCase())) { + log(LOGLEVEL_WARN, logFileNameConflict(fileName)); + } else { + bundle[fileName] = FILE_PLACEHOLDER; } - bundle[fileName] = FILE_PLACEHOLDER; } -interface ConsumedChunk { - fileName: string | undefined; +type ConsumedChunk = Pick & { module: null | Module; name: string; - type: 'chunk'; -} + referenceId: string; +}; -interface ConsumedAsset { - fileName: string | undefined; - name: string | undefined; - source: string | Uint8Array | undefined; - type: 'asset'; -} +type ConsumedPrebuiltChunk = EmittedPrebuiltChunk & { + referenceId: string; +}; + +type ConsumedAsset = EmittedAsset & { + needsCodeReference: boolean; + originalFileName: string | null; + referenceId: string; +}; + +type ConsumedFile = ConsumedChunk | ConsumedAsset | ConsumedPrebuiltChunk; + +type EmittedFileType = ConsumedFile['type']; interface EmittedFile { + [key: string]: unknown; fileName?: string; name?: string; - type: 'chunk' | 'asset'; - [key: string]: unknown; + originalFileName?: string | null; + type: EmittedFileType; } -type ConsumedFile = ConsumedChunk | ConsumedAsset; - -export const FILE_PLACEHOLDER: FilePlaceholder = { - type: 'placeholder' -}; +const emittedFileTypes = new Set(['chunk', 'asset', 'prebuilt-chunk']); -function hasValidType( - emittedFile: unknown -): emittedFile is { type: 'asset' | 'chunk'; [key: string]: unknown } { +function hasValidType(emittedFile: unknown): emittedFile is { + [key: string]: unknown; + type: EmittedFileType; +} { return Boolean( emittedFile && - ((emittedFile as { [key: string]: unknown }).type === 'asset' || - (emittedFile as { [key: string]: unknown }).type === 'chunk') + emittedFileTypes.has((emittedFile as { [key: string]: unknown; type: EmittedFileType }).type) ); } function hasValidName(emittedFile: { - type: 'asset' | 'chunk'; [key: string]: unknown; + type: EmittedFileType; }): emittedFile is EmittedFile { const validatedName = emittedFile.fileName || emittedFile.name; - return ( - !validatedName || (typeof validatedName === 'string' && isPlainPathFragment(validatedName)) - ); + return !validatedName || (typeof validatedName === 'string' && !isPathFragment(validatedName)); } function getValidSource( @@ -128,7 +156,7 @@ function getValidSource( if (!(typeof source === 'string' || source instanceof Uint8Array)) { const assetName = emittedFile.fileName || emittedFile.name || fileReferenceId; return error( - errFailedValidation( + logFailedValidation( `Could not set source for ${ typeof assetName === 'string' ? `asset "${assetName}"` : 'unnamed asset' }, asset source needs to be a string, Uint8Array or Buffer.` @@ -140,24 +168,37 @@ function getValidSource( function getAssetFileName(file: ConsumedAsset, referenceId: string): string { if (typeof file.fileName !== 'string') { - return error(errAssetNotFinalisedForFileName(file.name || referenceId)); + return error(logAssetNotFinalisedForFileName(file.name || referenceId)); } return file.fileName; } function getChunkFileName( file: ConsumedChunk, - facadeChunkByModule: Map | null + facadeChunkByModule: ReadonlyMap | null ): string { - const fileName = file.fileName || (file.module && facadeChunkByModule?.get(file.module)?.id); - if (!fileName) return error(errChunkNotGeneratedForFileName(file.fileName || file.name)); - return fileName; + if (file.fileName) { + return file.fileName; + } + if (facadeChunkByModule) { + return facadeChunkByModule.get(file.module!)!.getFileName(); + } + return error(logChunkNotGeneratedForFileName(file.fileName || file.name)); +} + +interface FileEmitterOutput { + bundle: OutputBundleWithPlaceholders; + fileNamesBySourceHash: Map; + outputOptions: NormalizedOutputOptions; + getHash: GetHash; } export class FileEmitter { - private facadeChunkByModule: Map | null = null; - private filesByReferenceId: Map; - private output: OutputSpecificFileData | null = null; + private facadeChunkByModule: ReadonlyMap | null = null; + private readonly filesByReferenceId: Map; + private nextIdBase = 1; + private output: FileEmitterOutput | null = null; + private outputFileEmitters: FileEmitter[] = []; constructor( private readonly graph: Graph, @@ -167,29 +208,26 @@ export class FileEmitter { this.filesByReferenceId = baseFileEmitter ? new Map(baseFileEmitter.filesByReferenceId) : new Map(); + baseFileEmitter?.addOutputFileEmitter(this); } - public assertAssetsFinalized = (): void => { - for (const [referenceId, emittedFile] of this.filesByReferenceId.entries()) { - if (emittedFile.type === 'asset' && typeof emittedFile.fileName !== 'string') - return error(errNoAssetSourceSet(emittedFile.name || referenceId)); - } - }; - public emitFile = (emittedFile: unknown): string => { if (!hasValidType(emittedFile)) { return error( - errFailedValidation( - `Emitted files must be of type "asset" or "chunk", received "${ + logFailedValidation( + `Emitted files must be of type "asset", "chunk" or "prebuilt-chunk", received "${ emittedFile && (emittedFile as any).type }".` ) ); } + if (emittedFile.type === 'prebuilt-chunk') { + return this.emitPrebuiltChunk(emittedFile); + } if (!hasValidName(emittedFile)) { return error( - errFailedValidation( - `The "fileName" or "name" properties of emitted files must be strings that are neither absolute nor relative paths and do not contain invalid characters, received "${ + logFailedValidation( + `The "fileName" or "name" properties of emitted chunks and assets must be strings that are neither absolute nor relative paths, received "${ emittedFile.fileName || emittedFile.name }".` ) @@ -197,112 +235,188 @@ export class FileEmitter { } if (emittedFile.type === 'chunk') { return this.emitChunk(emittedFile); - } else { - return this.emitAsset(emittedFile); + } + return this.emitAsset(emittedFile); + }; + + public finaliseAssets = (): void => { + for (const [referenceId, emittedFile] of this.filesByReferenceId) { + if (emittedFile.type === 'asset' && typeof emittedFile.fileName !== 'string') + return error(logNoAssetSourceSet(emittedFile.name || referenceId)); } }; public getFileName = (fileReferenceId: string): string => { const emittedFile = this.filesByReferenceId.get(fileReferenceId); - if (!emittedFile) return error(errFileReferenceIdNotFoundForFilename(fileReferenceId)); + if (!emittedFile) return error(logFileReferenceIdNotFoundForFilename(fileReferenceId)); if (emittedFile.type === 'chunk') { return getChunkFileName(emittedFile, this.facadeChunkByModule); - } else { - return getAssetFileName(emittedFile, fileReferenceId); } + if (emittedFile.type === 'prebuilt-chunk') { + return emittedFile.fileName; + } + return getAssetFileName(emittedFile, fileReferenceId); }; public setAssetSource = (referenceId: string, requestedSource: unknown): void => { const consumedFile = this.filesByReferenceId.get(referenceId); - if (!consumedFile) return error(errAssetReferenceIdNotFoundForSetSource(referenceId)); + if (!consumedFile) return error(logAssetReferenceIdNotFoundForSetSource(referenceId)); if (consumedFile.type !== 'asset') { return error( - errFailedValidation( + logFailedValidation( `Asset sources can only be set for emitted assets but "${referenceId}" is an emitted chunk.` ) ); } if (consumedFile.source !== undefined) { - return error(errAssetSourceAlreadySet(consumedFile.name || referenceId)); + return error(logAssetSourceAlreadySet(consumedFile.name || referenceId)); } const source = getValidSource(requestedSource, consumedFile, referenceId); if (this.output) { - this.finalizeAsset(consumedFile, source, referenceId, this.output); + this.finalizeAdditionalAsset(consumedFile, source, this.output); } else { consumedFile.source = source; + for (const emitter of this.outputFileEmitters) { + emitter.finalizeAdditionalAsset(consumedFile, source, emitter.output!); + } } }; + public setChunkInformation = (facadeChunkByModule: ReadonlyMap): void => { + this.facadeChunkByModule = facadeChunkByModule; + }; + public setOutputBundle = ( - outputBundle: OutputBundleWithPlaceholders, - assetFileNames: string | ((assetInfo: PreRenderedAsset) => string), - facadeChunkByModule: Map + bundle: OutputBundleWithPlaceholders, + outputOptions: NormalizedOutputOptions ): void => { - this.output = { - assetFileNames, - bundle: outputBundle - }; - this.facadeChunkByModule = facadeChunkByModule; + const getHash = hasherByType[outputOptions.hashCharacters]; + const output = (this.output = { + bundle, + fileNamesBySourceHash: new Map(), + getHash, + outputOptions + }); for (const emittedFile of this.filesByReferenceId.values()) { if (emittedFile.fileName) { - reserveFileNameInBundle(emittedFile.fileName, this.output.bundle, this.options.onwarn); + reserveFileNameInBundle(emittedFile.fileName, output, this.options.onLog); } } - for (const [referenceId, consumedFile] of this.filesByReferenceId.entries()) { + const consumedAssetsByHash = new Map(); + for (const consumedFile of this.filesByReferenceId.values()) { if (consumedFile.type === 'asset' && consumedFile.source !== undefined) { - this.finalizeAsset(consumedFile, consumedFile.source, referenceId, this.output); + if (consumedFile.fileName) { + this.finalizeAdditionalAsset(consumedFile, consumedFile.source, output); + } else { + const sourceHash = getHash(consumedFile.source); + getOrCreate(consumedAssetsByHash, sourceHash, getNewArray).push(consumedFile); + } + } else if (consumedFile.type === 'prebuilt-chunk') { + this.output.bundle[consumedFile.fileName] = this.createPrebuiltChunk(consumedFile); } } + for (const [sourceHash, consumedFiles] of consumedAssetsByHash) { + this.finalizeAssetsWithSameSource(consumedFiles, sourceHash, output); + } }; + private addOutputFileEmitter(outputFileEmitter: FileEmitter) { + this.outputFileEmitters.push(outputFileEmitter); + } + private assignReferenceId(file: ConsumedFile, idBase: string): string { - let referenceId: string | undefined; + let referenceId = idBase; + do { - const hash = createHash(); - if (referenceId) { - hash.update(referenceId); - } else { - hash.update(idBase); - } - referenceId = hash.digest('hex').substr(0, 8); - } while (this.filesByReferenceId.has(referenceId)); + referenceId = getHash64(referenceId).slice(0, 8).replaceAll('-', '$'); + } while ( + this.filesByReferenceId.has(referenceId) || + this.outputFileEmitters.some(({ filesByReferenceId }) => filesByReferenceId.has(referenceId)) + ); + file.referenceId = referenceId; this.filesByReferenceId.set(referenceId, file); + for (const { filesByReferenceId } of this.outputFileEmitters) { + filesByReferenceId.set(referenceId, file); + } return referenceId; } + private createPrebuiltChunk(prebuiltChunk: ConsumedPrebuiltChunk): OutputChunk { + return { + code: prebuiltChunk.code, + dynamicImports: [], + exports: prebuiltChunk.exports || [], + facadeModuleId: null, + fileName: prebuiltChunk.fileName, + implicitlyLoadedBefore: [], + importedBindings: {}, + imports: [], + isDynamicEntry: false, + isEntry: false, + isImplicitEntry: false, + map: prebuiltChunk.map || null, + moduleIds: [], + modules: {}, + name: prebuiltChunk.fileName, + preliminaryFileName: prebuiltChunk.fileName, + referencedFiles: [], + sourcemapFileName: prebuiltChunk.sourcemapFileName || null, + type: 'chunk' + }; + } + private emitAsset(emittedAsset: EmittedFile): string { const source = - typeof emittedAsset.source !== 'undefined' - ? getValidSource(emittedAsset.source, emittedAsset, null) - : undefined; + emittedAsset.source === undefined + ? undefined + : getValidSource(emittedAsset.source, emittedAsset, null); + const originalFileName = emittedAsset.originalFileName || null; + if (typeof originalFileName === 'string') { + this.graph.watchFiles[originalFileName] = true; + } const consumedAsset: ConsumedAsset = { fileName: emittedAsset.fileName, name: emittedAsset.name, + needsCodeReference: !!emittedAsset.needsCodeReference, + originalFileName, + referenceId: '', source, type: 'asset' }; const referenceId = this.assignReferenceId( consumedAsset, - emittedAsset.fileName || emittedAsset.name || emittedAsset.type + emittedAsset.fileName || emittedAsset.name || String(this.nextIdBase++) ); if (this.output) { - if (emittedAsset.fileName) { - reserveFileNameInBundle(emittedAsset.fileName, this.output.bundle, this.options.onwarn); - } - if (source !== undefined) { - this.finalizeAsset(consumedAsset, source, referenceId, this.output); + this.emitAssetWithReferenceId(consumedAsset, this.output); + } else { + for (const fileEmitter of this.outputFileEmitters) { + fileEmitter.emitAssetWithReferenceId(consumedAsset, fileEmitter.output!); } } return referenceId; } + private emitAssetWithReferenceId( + consumedAsset: Readonly, + output: FileEmitterOutput + ) { + const { fileName, source } = consumedAsset; + if (fileName) { + reserveFileNameInBundle(fileName, output, this.options.onLog); + } + if (source !== undefined) { + this.finalizeAdditionalAsset(consumedAsset, source, output); + } + } + private emitChunk(emittedChunk: EmittedFile): string { if (this.graph.phase > BuildPhase.LOAD_AND_PARSE) { - return error(errInvalidRollupPhaseForChunkEmission()); + return error(logInvalidRollupPhaseForChunkEmission()); } if (typeof emittedChunk.id !== 'string') { return error( - errFailedValidation( + logFailedValidation( `Emitted chunks need to have a valid string id, received "${emittedChunk.id}"` ) ); @@ -311,10 +425,11 @@ export class FileEmitter { fileName: emittedChunk.fileName, module: null, name: emittedChunk.name || emittedChunk.id, + referenceId: '', type: 'chunk' }; this.graph.moduleLoader - .emitChunk((emittedChunk as unknown) as EmittedChunk) + .emitChunk(emittedChunk as unknown as EmittedChunk) .then(module => (consumedChunk.module = module)) .catch(() => { // Avoid unhandled Promise rejection as the error will be thrown later @@ -324,70 +439,207 @@ export class FileEmitter { return this.assignReferenceId(consumedChunk, emittedChunk.id); } - private finalizeAsset( - consumedFile: ConsumedFile, + private emitPrebuiltChunk( + emitPrebuiltChunk: Omit & + Pick + ): string { + if (typeof emitPrebuiltChunk.code !== 'string') { + return error( + logFailedValidation( + `Emitted prebuilt chunks need to have a valid string code, received "${emitPrebuiltChunk.code}".` + ) + ); + } + if ( + typeof emitPrebuiltChunk.fileName !== 'string' || + isPathFragment(emitPrebuiltChunk.fileName) + ) { + return error( + logFailedValidation( + `The "fileName" property of emitted prebuilt chunks must be strings that are neither absolute nor relative paths, received "${emitPrebuiltChunk.fileName}".` + ) + ); + } + const consumedPrebuiltChunk: ConsumedPrebuiltChunk = { + code: emitPrebuiltChunk.code, + exports: emitPrebuiltChunk.exports, + fileName: emitPrebuiltChunk.fileName, + map: emitPrebuiltChunk.map, + referenceId: '', + type: 'prebuilt-chunk' + }; + const referenceId = this.assignReferenceId( + consumedPrebuiltChunk, + consumedPrebuiltChunk.fileName + ); + if (this.output) { + this.output.bundle[consumedPrebuiltChunk.fileName] = + this.createPrebuiltChunk(consumedPrebuiltChunk); + } + return referenceId; + } + + private finalizeAdditionalAsset( + consumedFile: Readonly, source: string | Uint8Array, - referenceId: string, - output: OutputSpecificFileData + { bundle, fileNamesBySourceHash, getHash, outputOptions }: FileEmitterOutput ): void { - const fileName = - consumedFile.fileName || - findExistingAssetFileNameWithSource(output.bundle, source) || - generateAssetFileName(consumedFile.name, source, output); + let { fileName, name, needsCodeReference, originalFileName, referenceId } = consumedFile; + + // Deduplicate assets if an explicit fileName is not provided + if (!fileName) { + const sourceHash = getHash(source); + fileName = fileNamesBySourceHash.get(sourceHash); + if (!fileName) { + fileName = generateAssetFileName( + name, + name ? [name] : [], + source, + originalFileName, + originalFileName ? [originalFileName] : [], + sourceHash, + outputOptions, + bundle, + this.options + ); + fileNamesBySourceHash.set(sourceHash, fileName); + } + } // We must not modify the original assets to avoid interaction between outputs - const assetWithFileName = { ...consumedFile, source, fileName }; + const assetWithFileName = { ...consumedFile, fileName, source }; this.filesByReferenceId.set(referenceId, assetWithFileName); - const options = this.options; - output.bundle[fileName] = { + + const existingAsset = bundle[fileName]; + if (existingAsset?.type === 'asset') { + existingAsset.needsCodeReference &&= needsCodeReference; + if (name) { + existingAsset.names.push(name); + } + if (originalFileName) { + existingAsset.originalFileNames.push(originalFileName); + } + } else { + const { options } = this; + bundle[fileName] = { + fileName, + get name() { + // Additionally, this should be non-enumerable in the next major + warnDeprecation( + 'Accessing the "name" property of emitted assets in the bundle is deprecated. Use the "names" property instead.', + URL_GENERATEBUNDLE, + false, + options + ); + return name; + }, + names: name ? [name] : [], + needsCodeReference, + get originalFileName() { + // Additionally, this should be non-enumerable in the next major + warnDeprecation( + 'Accessing the "originalFileName" property of emitted assets in the bundle is deprecated. Use the "originalFileNames" property instead.', + URL_GENERATEBUNDLE, + false, + options + ); + return originalFileName; + }, + originalFileNames: originalFileName ? [originalFileName] : [], + source, + type: 'asset' + }; + } + } + + private finalizeAssetsWithSameSource( + consumedFiles: readonly ConsumedAsset[], + sourceHash: string, + { bundle, fileNamesBySourceHash, outputOptions }: FileEmitterOutput + ): void { + const { names, originalFileNames } = getNamesFromAssets(consumedFiles); + let fileName = ''; + let usedConsumedFile: ConsumedAsset; + let needsCodeReference = true; + for (const consumedFile of consumedFiles) { + needsCodeReference &&= consumedFile.needsCodeReference; + const assetFileName = generateAssetFileName( + consumedFile.name, + names, + consumedFile.source!, + consumedFile.originalFileName, + originalFileNames, + sourceHash, + outputOptions, + bundle, + this.options + ); + if ( + !fileName || + assetFileName.length < fileName.length || + (assetFileName.length === fileName.length && assetFileName < fileName) + ) { + fileName = assetFileName; + usedConsumedFile = consumedFile; + } + } + fileNamesBySourceHash.set(sourceHash, fileName); + + for (const consumedFile of consumedFiles) { + // We must not modify the original assets to avoid interaction between outputs + const assetWithFileName = { ...consumedFile, fileName }; + this.filesByReferenceId.set(consumedFile.referenceId, assetWithFileName); + } + + const { options } = this; + bundle[fileName] = { fileName, - name: consumedFile.name, - get isAsset(): true { + get name() { + // Additionally, this should be non-enumerable in the next major warnDeprecation( - 'Accessing "isAsset" on files in the bundle is deprecated, please use "type === \'asset\'" instead', - true, + 'Accessing the "name" property of emitted assets in the bundle is deprecated. Use the "names" property instead.', + URL_GENERATEBUNDLE, + false, options ); - - return true; + return usedConsumedFile!.name; }, - source, + names, + needsCodeReference, + get originalFileName() { + // Additionally, this should be non-enumerable in the next major + warnDeprecation( + 'Accessing the "originalFileName" property of emitted assets in the bundle is deprecated. Use the "originalFileNames" property instead.', + URL_GENERATEBUNDLE, + false, + options + ); + return usedConsumedFile!.originalFileName; + }, + originalFileNames, + source: usedConsumedFile!.source!, type: 'asset' }; } } -function findExistingAssetFileNameWithSource( - bundle: OutputBundleWithPlaceholders, - source: string | Uint8Array -): string | null { - for (const fileName of Object.keys(bundle)) { - const outputFile = bundle[fileName]; - if (outputFile.type === 'asset' && areSourcesEqual(source, outputFile.source)) return fileName; - } - return null; -} - -function areSourcesEqual( - sourceA: string | Uint8Array | Buffer, - sourceB: string | Uint8Array | Buffer -): boolean { - if (typeof sourceA === 'string') { - return sourceA === sourceB; - } - if (typeof sourceB === 'string') { - return false; - } - if ('equals' in sourceA) { - return sourceA.equals(sourceB); - } - if (sourceA.length !== sourceB.length) { - return false; - } - for (let index = 0; index < sourceA.length; index++) { - if (sourceA[index] !== sourceB[index]) { - return false; +function getNamesFromAssets(consumedFiles: readonly ConsumedAsset[]): { + names: string[]; + originalFileNames: string[]; +} { + const names: string[] = []; + const originalFileNames: string[] = []; + for (const { name, originalFileName } of consumedFiles) { + if (typeof name === 'string') { + names.push(name); + } + if (originalFileName) { + originalFileNames.push(originalFileName); } } - return true; + originalFileNames.sort(); + // Sort by length first and then alphabetically so that the order is stable + // and the shortest names come first + names.sort((a, b) => a.length - b.length || (a > b ? 1 : a === b ? 0 : -1)); + return { names, originalFileNames }; } diff --git a/src/utils/PluginCache.ts b/src/utils/PluginCache.ts index ecd51148847..558a9e5ba37 100644 --- a/src/utils/PluginCache.ts +++ b/src/utils/PluginCache.ts @@ -1,62 +1,62 @@ -import { PluginCache, SerializablePluginCache } from '../rollup/types'; -import { error } from './error'; -import { ANONYMOUS_OUTPUT_PLUGIN_PREFIX, ANONYMOUS_PLUGIN_PREFIX } from './pluginUtils'; +import type { PluginCache, SerializablePluginCache } from '../rollup/types'; +import { error, logAnonymousPluginCache, logDuplicatePluginName } from './logs'; +import { ANONYMOUS_OUTPUT_PLUGIN_PREFIX, ANONYMOUS_PLUGIN_PREFIX } from './pluginNames'; export function createPluginCache(cache: SerializablePluginCache): PluginCache { return { - has(id: string) { - const item = cache[id]; - if (!item) return false; - item[0] = 0; - return true; + delete(id: string) { + return delete cache[id]; }, get(id: string) { const item = cache[id]; - if (!item) return undefined; + if (!item) return; item[0] = 0; return item[1]; }, + has(id: string) { + const item = cache[id]; + if (!item) return false; + item[0] = 0; + return true; + }, set(id: string, value: any) { cache[id] = [0, value]; - }, - delete(id: string) { - return delete cache[id]; } }; } export function getTrackedPluginCache(pluginCache: PluginCache, onUse: () => void): PluginCache { return { - has(id: string) { + delete(id: string) { onUse(); - return pluginCache.has(id); + return pluginCache.delete(id); }, get(id: string) { onUse(); return pluginCache.get(id); }, - set(id: string, value: any) { + has(id: string) { onUse(); - return pluginCache.set(id, value); + return pluginCache.has(id); }, - delete(id: string) { + set(id: string, value: any) { onUse(); - return pluginCache.delete(id); + return pluginCache.set(id, value); } }; } export const NO_CACHE: PluginCache = { - has() { + delete() { return false; }, get() { return undefined as any; }, - set() {}, - delete() { + has() { return false; - } + }, + set() {} }; function uncacheablePluginError(pluginName: string): never { @@ -64,30 +64,23 @@ function uncacheablePluginError(pluginName: string): never { pluginName.startsWith(ANONYMOUS_PLUGIN_PREFIX) || pluginName.startsWith(ANONYMOUS_OUTPUT_PLUGIN_PREFIX) ) { - return error({ - code: 'ANONYMOUS_PLUGIN_CACHE', - message: - 'A plugin is trying to use the Rollup cache but is not declaring a plugin name or cacheKey.' - }); + return error(logAnonymousPluginCache()); } - return error({ - code: 'DUPLICATE_PLUGIN_NAME', - message: `The plugin name ${pluginName} is being used twice in the same build. Plugin names must be distinct or provide a cacheKey (please post an issue to the plugin if you are a plugin user).` - }); + return error(logDuplicatePluginName(pluginName)); } export function getCacheForUncacheablePlugin(pluginName: string): PluginCache { return { - has() { + delete() { return uncacheablePluginError(pluginName); }, get() { return uncacheablePluginError(pluginName); }, - set() { + has() { return uncacheablePluginError(pluginName); }, - delete() { + set() { return uncacheablePluginError(pluginName); } }; diff --git a/src/utils/PluginContext.ts b/src/utils/PluginContext.ts index 70ca86d58c3..7590b89bf5a 100644 --- a/src/utils/PluginContext.ts +++ b/src/utils/PluginContext.ts @@ -1,48 +1,21 @@ import { version as rollupVersion } from 'package.json'; -import Graph from '../Graph'; -import { +import type Graph from '../Graph'; +import type { NormalizedInputOptions, Plugin, PluginCache, PluginContext, - RollupWarning, SerializablePluginCache } from '../rollup/types'; -import { BLANK } from './blank'; -import { BuildPhase } from './buildPhase'; -import { errInvalidRollupPhaseForAddWatchFile, warnDeprecation } from './error'; -import { FileEmitter } from './FileEmitter'; +import { BLANK, EMPTY_OBJECT } from './blank'; +import type { FileEmitter } from './FileEmitter'; +import { LOGLEVEL_DEBUG, LOGLEVEL_INFO, LOGLEVEL_WARN } from './logging'; +import { getLogHandler } from './logHandler'; +import { error, logPluginError } from './logs'; +import { normalizeLog } from './options/options'; +import { parseAst } from './parseAst'; import { createPluginCache, getCacheForUncacheablePlugin, NO_CACHE } from './PluginCache'; -import { - ANONYMOUS_OUTPUT_PLUGIN_PREFIX, - ANONYMOUS_PLUGIN_PREFIX, - throwPluginError -} from './pluginUtils'; - -function getDeprecatedContextHandler( - handler: H, - handlerName: string, - newHandlerName: string, - pluginName: string, - activeDeprecation: boolean, - options: NormalizedInputOptions -): H { - let deprecationWarningShown = false; - return (((...args: any[]) => { - if (!deprecationWarningShown) { - deprecationWarningShown = true; - warnDeprecation( - { - message: `The "this.${handlerName}" plugin context function used by plugin ${pluginName} is deprecated. The "this.${newHandlerName}" plugin context function should be used instead.`, - plugin: pluginName - }, - activeDeprecation, - options - ); - } - return handler(...args); - }) as unknown) as H; -} +import { ANONYMOUS_OUTPUT_PLUGIN_PREFIX, ANONYMOUS_PLUGIN_PREFIX } from './pluginNames'; export function getPluginContext( plugin: Plugin, @@ -52,6 +25,7 @@ export function getPluginContext( fileEmitter: FileEmitter, existingPluginNames: Set ): PluginContext { + const { logLevel, onLog } = options; let cacheable = true; if (typeof plugin.cacheKey !== 'string') { if ( @@ -77,113 +51,42 @@ export function getPluginContext( cacheInstance = getCacheForUncacheablePlugin(plugin.name); } - const context: PluginContext = { + return { addWatchFile(id) { - if (graph.phase >= BuildPhase.GENERATE) { - return this.error(errInvalidRollupPhaseForAddWatchFile()); - } graph.watchFiles[id] = true; }, cache: cacheInstance, - emitAsset: getDeprecatedContextHandler( - (name: string, source?: string | Uint8Array) => - fileEmitter.emitFile({ type: 'asset', name, source }), - 'emitAsset', - 'emitFile', - plugin.name, - true, - options - ), - emitChunk: getDeprecatedContextHandler( - (id: string, options?: { name?: string }) => - fileEmitter.emitFile({ type: 'chunk', id, name: options && options.name }), - 'emitChunk', - 'emitFile', - plugin.name, - true, - options - ), - emitFile: fileEmitter.emitFile, - error(err): never { - return throwPluginError(err, plugin.name); + debug: getLogHandler(LOGLEVEL_DEBUG, 'PLUGIN_LOG', onLog, plugin.name, logLevel), + emitFile: fileEmitter.emitFile.bind(fileEmitter), + error(error_): never { + return error(logPluginError(normalizeLog(error_), plugin.name)); }, - getAssetFileName: getDeprecatedContextHandler( - fileEmitter.getFileName, - 'getAssetFileName', - 'getFileName', - plugin.name, - true, - options - ), - getChunkFileName: getDeprecatedContextHandler( - fileEmitter.getFileName, - 'getChunkFileName', - 'getFileName', - plugin.name, - true, - options - ), + fs: options.fs, getFileName: fileEmitter.getFileName, getModuleIds: () => graph.modulesById.keys(), getModuleInfo: graph.getModuleInfo, getWatchFiles: () => Object.keys(graph.watchFiles), - isExternal: getDeprecatedContextHandler( - (id: string, parentId: string | undefined, isResolved = false) => - options.external(id, parentId, isResolved), - 'isExternal', - 'resolve', - plugin.name, - true, - options - ), + info: getLogHandler(LOGLEVEL_INFO, 'PLUGIN_LOG', onLog, plugin.name, logLevel), + load(resolvedId) { + return graph.moduleLoader.preloadModule(resolvedId); + }, meta: { rollupVersion, watchMode: graph.watchMode }, - get moduleIds() { - function* wrappedModuleIds() { - warnDeprecation( - { - message: `Accessing "this.moduleIds" on the plugin context by plugin ${plugin.name} is deprecated. The "this.getModuleIds" plugin context function should be used instead.`, - plugin: plugin.name - }, - false, - options - ); - yield* moduleIds; - } - - const moduleIds = graph.modulesById.keys(); - return wrappedModuleIds(); - }, - parse: graph.contextParse.bind(graph), - resolve(source, importer, { custom, skipSelf } = BLANK) { - return graph.moduleLoader.resolveId( - source, - importer, - custom, - skipSelf ? [{ importer, plugin, source }] : null - ); - }, - resolveId: getDeprecatedContextHandler( - (source: string, importer: string | undefined) => - graph.moduleLoader - .resolveId(source, importer, BLANK) - .then(resolveId => resolveId && resolveId.id), - 'resolveId', - 'resolve', - plugin.name, - true, - options - ), - setAssetSource: fileEmitter.setAssetSource, - warn(warning) { - if (typeof warning === 'string') warning = { message: warning } as RollupWarning; - if (warning.code) warning.pluginCode = warning.code; - warning.code = 'PLUGIN_WARNING'; - warning.plugin = plugin.name; - options.onwarn(warning); - } - }; - return context; + parse: parseAst, + resolve(source, importer, { attributes, custom, isEntry, skipSelf } = BLANK) { + skipSelf ??= true; + return graph.moduleLoader.resolveId( + source, + importer, + custom, + isEntry, + attributes || EMPTY_OBJECT, + skipSelf ? [{ importer, plugin, source }] : null + ); + }, + setAssetSource: fileEmitter.setAssetSource, + warn: getLogHandler(LOGLEVEL_WARN, 'PLUGIN_WARNING', onLog, plugin.name, logLevel) + }; } diff --git a/src/utils/PluginDriver.ts b/src/utils/PluginDriver.ts index 61dfce57095..ef33dcf29f6 100644 --- a/src/utils/PluginDriver.ts +++ b/src/utils/PluginDriver.ts @@ -1,59 +1,67 @@ -import Chunk from '../Chunk'; -import Graph from '../Graph'; -import Module from '../Module'; -import { +import type Chunk from '../Chunk'; +import type Graph from '../Graph'; +import type Module from '../Module'; +import type { AddonHookFunction, + AddonHooks, AsyncPluginHooks, EmitFile, FirstPluginHooks, + FunctionPluginHooks, + HookFilter, + InputPluginHooks, NormalizedInputOptions, - OutputBundleWithPlaceholders, - OutputPluginHooks, + NormalizedOutputOptions, ParallelPluginHooks, Plugin, PluginContext, - PluginHooks, - PluginValueHooks, - PreRenderedAsset, SequentialPluginHooks, SerializablePluginCache, SyncPluginHooks } from '../rollup/types'; -import { errInputHookInOutputPlugin, error } from './error'; import { FileEmitter } from './FileEmitter'; import { getPluginContext } from './PluginContext'; -import { throwPluginError, warnDeprecatedHooks } from './pluginUtils'; +import { getOrCreate } from './getOrCreate'; +import { LOGLEVEL_WARN } from './logging'; +import { + error, + logInputHookInOutputPlugin, + logInvalidAddonPluginHook, + logInvalidFunctionPluginHook, + logPluginError +} from './logs'; +import type { OutputBundleWithPlaceholders } from './outputBundle'; +import { + createFilterForId, + createFilterForTransform, + type PluginFilter, + type TransformHookFilter +} from './pluginFilter'; -/** - * Get the inner type from a promise - * @example ResolveValue> -> string - */ -type ResolveValue = T extends Promise ? K : T; /** * Coerce a promise union to always be a promise. * @example EnsurePromise> -> Promise */ -type EnsurePromise = Promise>; +type EnsurePromise = Promise>; /** * Get the type of the first argument in a function. * @example Arg0<(a: string, b: number) => void> -> string */ -type Arg0 = Parameters[0]; +type Argument0 = Parameters[0]; // This will make sure no input hook is omitted -type Subtract = T extends U ? never : T; -const inputHookNames: { - [P in Subtract]: 1; -} = { +const inputHookNames: Record = { buildEnd: 1, buildStart: 1, closeBundle: 1, closeWatcher: 1, load: 1, moduleParsed: 1, + onLog: 1, options: 1, resolveDynamicImport: 1, resolveId: 1, + shouldTransformCachedModule: 1, transform: 1, watchChange: 1 }; @@ -61,136 +69,154 @@ const inputHooks = Object.keys(inputHookNames); export type ReplaceContext = (context: PluginContext, plugin: Plugin) => PluginContext; -function throwInvalidHookError(hookName: string, pluginName: string) { - return error({ - code: 'INVALID_PLUGIN_HOOK', - message: `Error running plugin hook ${hookName} for ${pluginName}, expected a function hook.` - }); -} +export type HookAction = [plugin: string, hook: string, args: unknown[]]; export class PluginDriver { - public emitFile: EmitFile; + public readonly emitFile: EmitFile; public finaliseAssets: () => void; public getFileName: (fileReferenceId: string) => string; - public setOutputBundle: ( - outputBundle: OutputBundleWithPlaceholders, - assetFileNames: string | ((assetInfo: PreRenderedAsset) => string), - facadeChunkByModule: Map + public readonly setChunkInformation: (facadeChunkByModule: ReadonlyMap) => void; + public readonly setOutputBundle: ( + bundle: OutputBundleWithPlaceholders, + outputOptions: NormalizedOutputOptions ) => void; - private fileEmitter: FileEmitter; - private pluginCache: Record | undefined; - private pluginContexts = new Map(); - private plugins: Plugin[]; + private readonly fileEmitter: FileEmitter; + private readonly pluginContexts: ReadonlyMap; + private readonly plugins: readonly Plugin[]; + private readonly sortedPlugins = new Map(); + private readonly unfulfilledActions = new Set(); + private readonly compiledPluginFilters = { + idOnlyFilter: new WeakMap, PluginFilter | undefined>(), + transformFilter: new WeakMap() + }; constructor( private readonly graph: Graph, private readonly options: NormalizedInputOptions, - userPlugins: Plugin[], - pluginCache: Record | undefined, + userPlugins: readonly Plugin[], + private readonly pluginCache: Record | undefined, basePluginDriver?: PluginDriver ) { - warnDeprecatedHooks(userPlugins, options); - this.pluginCache = pluginCache; this.fileEmitter = new FileEmitter( graph, options, basePluginDriver && basePluginDriver.fileEmitter ); - this.emitFile = this.fileEmitter.emitFile; - this.getFileName = this.fileEmitter.getFileName; - this.finaliseAssets = this.fileEmitter.assertAssetsFinalized; - this.setOutputBundle = this.fileEmitter.setOutputBundle; - this.plugins = userPlugins.concat(basePluginDriver ? basePluginDriver.plugins : []); + this.emitFile = this.fileEmitter.emitFile.bind(this.fileEmitter); + this.getFileName = this.fileEmitter.getFileName.bind(this.fileEmitter); + this.finaliseAssets = this.fileEmitter.finaliseAssets.bind(this.fileEmitter); + this.setChunkInformation = this.fileEmitter.setChunkInformation.bind(this.fileEmitter); + this.setOutputBundle = this.fileEmitter.setOutputBundle.bind(this.fileEmitter); + this.plugins = [...(basePluginDriver ? basePluginDriver.plugins : []), ...userPlugins]; const existingPluginNames = new Set(); - for (const plugin of this.plugins) { - this.pluginContexts.set( + + this.pluginContexts = new Map( + this.plugins.map(plugin => [ plugin, getPluginContext(plugin, pluginCache, graph, options, this.fileEmitter, existingPluginNames) - ); - } + ]) + ); + if (basePluginDriver) { for (const plugin of userPlugins) { for (const hook of inputHooks) { if (hook in plugin) { - options.onwarn(errInputHookInOutputPlugin(plugin.name, hook)); + options.onLog(LOGLEVEL_WARN, logInputHookInOutputPlugin(plugin.name, hook)); } } } } } - public createOutputPluginDriver(plugins: Plugin[]): PluginDriver { + public createOutputPluginDriver(plugins: readonly Plugin[]): PluginDriver { return new PluginDriver(this.graph, this.options, plugins, this.pluginCache, this); } + getUnfulfilledHookActions(): Set { + return this.unfulfilledActions; + } + // chains, first non-null result stops and returns hookFirst( hookName: H, - args: Parameters, + parameters: Parameters, replaceContext?: ReplaceContext | null, - skipped?: Set | null - ): EnsurePromise> { - let promise: EnsurePromise> = Promise.resolve(undefined as any); - for (const plugin of this.plugins) { - if (skipped && skipped.has(plugin)) continue; - promise = promise.then(result => { - if (result != null) return result; - return this.runHook(hookName, args, plugin, false, replaceContext); - }); + skipped?: ReadonlySet | null + ): Promise | null> { + return this.hookFirstAndGetPlugin(hookName, parameters, replaceContext, skipped).then( + result => result && result[0] + ); + } + + // chains, first non-null result stops and returns result and last plugin + async hookFirstAndGetPlugin( + hookName: H, + parameters: Parameters, + replaceContext?: ReplaceContext | null, + skipped?: ReadonlySet | null + ): Promise<[NonNullable>, Plugin] | null> { + for (const plugin of this.getSortedPlugins(hookName)) { + if (skipped?.has(plugin)) continue; + const result = await this.runHook(hookName, parameters, plugin, replaceContext); + if (result != null) return [result, plugin]; } - return promise; + return null; } // chains synchronously, first non-null result stops and returns hookFirstSync( hookName: H, - args: Parameters, + parameters: Parameters, replaceContext?: ReplaceContext - ): ReturnType { - for (const plugin of this.plugins) { - const result = this.runHookSync(hookName, args, plugin, replaceContext); + ): ReturnType | null { + for (const plugin of this.getSortedPlugins(hookName)) { + const result = this.runHookSync(hookName, parameters, plugin, replaceContext); if (result != null) return result; } - return null as any; + return null; } // parallel, ignores returns - hookParallel( + async hookParallel( hookName: H, - args: Parameters, + parameters: Parameters, replaceContext?: ReplaceContext ): Promise { - const promises: Promise[] = []; - for (const plugin of this.plugins) { - const hookPromise = this.runHook(hookName, args, plugin, false, replaceContext); - if (!hookPromise) continue; - promises.push(hookPromise); + const parallelPromises: Promise[] = []; + for (const plugin of this.getSortedPlugins(hookName)) { + if ((plugin[hookName] as { sequential?: boolean }).sequential) { + await Promise.all(parallelPromises); + parallelPromises.length = 0; + await this.runHook(hookName, parameters, plugin, replaceContext); + } else { + parallelPromises.push(this.runHook(hookName, parameters, plugin, replaceContext)); + } } - return Promise.all(promises).then(() => {}); + await Promise.all(parallelPromises); } // chains, reduces returned value, handling the reduced value as the first hook argument hookReduceArg0( hookName: H, - [arg0, ...rest]: Parameters, + [argument0, ...rest]: Parameters, reduce: ( - reduction: Arg0, - result: ResolveValue>, + reduction: Argument0, + result: ReturnType, plugin: Plugin - ) => Arg0, + ) => Argument0, replaceContext?: ReplaceContext - ): Promise> { - let promise = Promise.resolve(arg0); - for (const plugin of this.plugins) { - promise = promise.then(arg0 => { - const args = [arg0, ...rest] as Parameters; - const hookPromise = this.runHook(hookName, args, plugin, false, replaceContext); - if (!hookPromise) return arg0; - return hookPromise.then(result => - reduce.call(this.pluginContexts.get(plugin), arg0, result, plugin) - ); - }); + ): Promise> { + let promise = Promise.resolve(argument0); + for (const plugin of this.getSortedPlugins(hookName)) { + promise = promise.then(argument0 => + this.runHook( + hookName, + [argument0, ...rest] as Parameters, + plugin, + replaceContext + ).then(result => reduce.call(this.pluginContexts.get(plugin), argument0, result, plugin)) + ); } return promise; } @@ -198,132 +224,177 @@ export class PluginDriver { // chains synchronously, reduces returned value, handling the reduced value as the first hook argument hookReduceArg0Sync( hookName: H, - [arg0, ...rest]: Parameters, - reduce: (reduction: Arg0, result: ReturnType, plugin: Plugin) => Arg0, + [argument0, ...rest]: Parameters, + reduce: ( + reduction: Argument0, + result: ReturnType, + plugin: Plugin + ) => Argument0, replaceContext?: ReplaceContext - ): Arg0 { - for (const plugin of this.plugins) { - const args = [arg0, ...rest] as Parameters; - const result = this.runHookSync(hookName, args, plugin, replaceContext); - arg0 = reduce.call(this.pluginContexts.get(plugin), arg0, result, plugin); + ): Argument0 { + for (const plugin of this.getSortedPlugins(hookName)) { + const parameters = [argument0, ...rest] as Parameters; + const result = this.runHookSync(hookName, parameters, plugin, replaceContext); + argument0 = reduce.call(this.pluginContexts.get(plugin), argument0, result, plugin); } - return arg0; + return argument0; } - // chains, reduces returned value to type T, handling the reduced value separately. permits hooks as values. - hookReduceValue( + // chains, reduces returned value to type string, handling the reduced value separately. permits hooks as values. + async hookReduceValue( hookName: H, - initialValue: T | Promise, - args: Parameters, - reduce: ( - reduction: T, - result: ResolveValue>, - plugin: Plugin - ) => T, - replaceContext?: ReplaceContext - ): Promise { - let promise = Promise.resolve(initialValue); - for (const plugin of this.plugins) { - promise = promise.then(value => { - const hookPromise = this.runHook(hookName, args, plugin, true, replaceContext); - if (!hookPromise) return value; - return hookPromise.then(result => - reduce.call(this.pluginContexts.get(plugin), value, result, plugin) - ); - }); + initialValue: string | Promise, + parameters: Parameters, + reducer: (result: string, next: string) => string + ): Promise { + const results: string[] = []; + const parallelResults: (string | Promise)[] = []; + for (const plugin of this.getSortedPlugins(hookName, validateAddonPluginHandler)) { + if ((plugin[hookName] as { sequential?: boolean }).sequential) { + results.push(...(await Promise.all(parallelResults))); + parallelResults.length = 0; + results.push(await this.runHook(hookName, parameters, plugin)); + } else { + parallelResults.push(this.runHook(hookName, parameters, plugin)); + } } - return promise; + results.push(...(await Promise.all(parallelResults))); + return results.reduce(reducer, await initialValue); } // chains synchronously, reduces returned value to type T, handling the reduced value separately. permits hooks as values. hookReduceValueSync( hookName: H, initialValue: T, - args: Parameters, - reduce: (reduction: T, result: ReturnType, plugin: Plugin) => T, + parameters: Parameters, + reduce: (reduction: T, result: ReturnType, plugin: Plugin) => T, replaceContext?: ReplaceContext ): T { - let acc = initialValue; - for (const plugin of this.plugins) { - const result = this.runHookSync(hookName, args, plugin, replaceContext); - acc = reduce.call(this.pluginContexts.get(plugin), acc, result, plugin); + let accumulator = initialValue; + for (const plugin of this.getSortedPlugins(hookName)) { + const result = this.runHookSync(hookName, parameters, plugin, replaceContext); + accumulator = reduce.call(this.pluginContexts.get(plugin), accumulator, result, plugin); } - return acc; + return accumulator; } // chains, ignores returns hookSeq( hookName: H, - args: Parameters, + parameters: Parameters, replaceContext?: ReplaceContext ): Promise { - let promise = Promise.resolve(); - for (const plugin of this.plugins) { - promise = promise.then( - () => this.runHook(hookName, args, plugin, false, replaceContext) as Promise - ); + let promise: Promise = Promise.resolve(); + for (const plugin of this.getSortedPlugins(hookName)) { + promise = promise.then(() => this.runHook(hookName, parameters, plugin, replaceContext)); } - return promise; + return promise.then(noReturn); } - // chains synchronously, ignores returns - hookSeqSync( - hookName: H, - args: Parameters, - replaceContext?: ReplaceContext - ): void { - for (const plugin of this.plugins) { - this.runHookSync(hookName, args, plugin, replaceContext); - } + private getSortedPlugins( + hookName: keyof FunctionPluginHooks | AddonHooks, + validateHandler?: (handler: unknown, hookName: string, plugin: Plugin) => void + ): Plugin[] { + return getOrCreate(this.sortedPlugins, hookName, () => + getSortedValidatedPlugins(hookName, this.plugins, validateHandler) + ); } /** * Run an async plugin hook and return the result. - * @param hookName Name of the plugin hook. Must be either in `PluginHooks` or `OutputPluginValueHooks`. + * @param hookName Name of the plugin hook. Must be either in `PluginHooks` + * or `OutputPluginValueHooks`. * @param args Arguments passed to the plugin hook. * @param plugin The actual pluginObject to run. - * @param permitValues If true, values can be passed instead of functions for the plugin hook. - * @param hookContext When passed, the plugin context can be overridden. + * @param replaceContext When passed, the plugin context can be overridden. */ - private runHook( + private runHook( hookName: H, - args: Parameters, - plugin: Plugin, - permitValues: true, - hookContext?: ReplaceContext | null + parameters: Parameters, + plugin: Plugin ): EnsurePromise>; private runHook( hookName: H, - args: Parameters, + parameters: Parameters, plugin: Plugin, - permitValues: false, - hookContext?: ReplaceContext | null - ): EnsurePromise>; - private runHook( + replaceContext?: ReplaceContext | null + ): Promise>; + // Implementation signature + private runHook( hookName: H, - args: Parameters, + parameters: unknown[], plugin: Plugin, - permitValues: boolean, - hookContext?: ReplaceContext | null - ): EnsurePromise> { + replaceContext?: ReplaceContext | null + ): Promise { + // We always filter for plugins that support the hook before running it const hook = plugin[hookName]; - if (!hook) return undefined as any; + const handler = typeof hook === 'object' ? hook.handler : hook; + + if (typeof hook === 'object' && 'filter' in hook && hook.filter) { + if (hookName === 'transform') { + const filter = hook.filter as HookFilter; + const hookParameters = parameters as Parameters; + const compiledFilter = getOrCreate(this.compiledPluginFilters.transformFilter, filter, () => + createFilterForTransform(filter.id, filter.code) + ); + if (compiledFilter && !compiledFilter(hookParameters[1], hookParameters[0])) { + return Promise.resolve(); + } + } else if (hookName === 'resolveId' || hookName === 'load') { + const filter = hook.filter; + const hookParameters = parameters as Parameters; + const compiledFilter = getOrCreate(this.compiledPluginFilters.idOnlyFilter, filter, () => + createFilterForId(filter.id) + ); + if (compiledFilter && !compiledFilter(hookParameters[0])) { + return Promise.resolve(); + } + } + } let context = this.pluginContexts.get(plugin)!; - if (hookContext) { - context = hookContext(context, plugin); + if (replaceContext) { + context = replaceContext(context, plugin); } + let action: [string, string, Parameters] | null = null; return Promise.resolve() .then(() => { - // permit values allows values to be returned instead of a functional hook - if (typeof hook !== 'function') { - if (permitValues) return hook; - return throwInvalidHookError(hookName, plugin.name); + if (typeof handler !== 'function') { + return handler; } - return (hook as Function).apply(context, args); + // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type + const hookResult = (handler as Function).apply(context, parameters); + + if (!hookResult?.then) { + // short circuit for non-thenables and non-Promises + return hookResult; + } + + // Track pending hook actions to properly error out when + // unfulfilled promises cause rollup to abruptly and confusingly + // exit with a successful 0 return code but without producing any + // output, errors or warnings. + action = [plugin.name, hookName, parameters]; + this.unfulfilledActions.add(action); + + // Although it would be more elegant to just return hookResult here + // and put the .then() handler just above the .catch() handler below, + // doing so would subtly change the defacto async event dispatch order + // which at least one test and some plugins in the wild may depend on. + return Promise.resolve(hookResult).then(result => { + // action was fulfilled + this.unfulfilledActions.delete(action!); + return result; + }); }) - .catch(err => throwPluginError(err, plugin.name, { hook: hookName })); + .catch(error_ => { + if (action !== null) { + // action considered to be fulfilled since error being handled + this.unfulfilledActions.delete(action); + } + return error(logPluginError(error_, plugin.name, { hook: hookName })); + }); } /** @@ -331,30 +402,71 @@ export class PluginDriver { * @param hookName Name of the plugin hook. Must be in `PluginHooks`. * @param args Arguments passed to the plugin hook. * @param plugin The acutal plugin - * @param hookContext When passed, the plugin context can be overridden. + * @param replaceContext When passed, the plugin context can be overridden. */ private runHookSync( hookName: H, - args: Parameters, + parameters: Parameters, plugin: Plugin, - hookContext?: ReplaceContext - ): ReturnType { - const hook = plugin[hookName]; - if (!hook) return undefined as any; + replaceContext?: ReplaceContext + ): ReturnType { + const hook = plugin[hookName]!; + const handler = typeof hook === 'object' ? hook.handler : hook; let context = this.pluginContexts.get(plugin)!; - if (hookContext) { - context = hookContext(context, plugin); + if (replaceContext) { + context = replaceContext(context, plugin); } try { - // permit values allows values to be returned instead of a functional hook - if (typeof hook !== 'function') { - return throwInvalidHookError(hookName, plugin.name); + // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type + return (handler as Function).apply(context, parameters); + } catch (error_: any) { + return error(logPluginError(error_, plugin.name, { hook: hookName })); + } + } +} + +export function getSortedValidatedPlugins( + hookName: keyof FunctionPluginHooks | AddonHooks, + plugins: readonly Plugin[], + validateHandler = validateFunctionPluginHandler +): Plugin[] { + const pre: Plugin[] = []; + const normal: Plugin[] = []; + const post: Plugin[] = []; + for (const plugin of plugins) { + const hook = plugin[hookName]; + if (hook) { + if (typeof hook === 'object') { + validateHandler(hook.handler, hookName, plugin); + if (hook.order === 'pre') { + pre.push(plugin); + continue; + } + if (hook.order === 'post') { + post.push(plugin); + continue; + } + } else { + validateHandler(hook, hookName, plugin); } - return (hook as Function).apply(context, args); - } catch (err) { - return throwPluginError(err, plugin.name, { hook: hookName }); + normal.push(plugin); } } + return [...pre, ...normal, ...post]; +} + +function validateFunctionPluginHandler(handler: unknown, hookName: string, plugin: Plugin) { + if (typeof handler !== 'function') { + error(logInvalidFunctionPluginHook(hookName, plugin.name)); + } } + +function validateAddonPluginHandler(handler: unknown, hookName: string, plugin: Plugin) { + if (typeof handler !== 'string' && typeof handler !== 'function') { + return error(logInvalidAddonPluginHook(hookName, plugin.name)); + } +} + +function noReturn() {} diff --git a/src/utils/Queue.ts b/src/utils/Queue.ts new file mode 100644 index 00000000000..2b673386ac9 --- /dev/null +++ b/src/utils/Queue.ts @@ -0,0 +1,40 @@ +type Task = () => Promise; + +interface QueueItem { + reject: (reason?: unknown) => void; + resolve: (value: any) => void; + task: Task; +} + +export default class Queue { + private readonly queue: QueueItem[] = []; + private workerCount = 0; + + constructor(private maxParallel: number) {} + + run(task: Task): Promise { + return new Promise((resolve, reject) => { + this.queue.push({ reject, resolve, task }); + this.work(); + }); + } + + private async work(): Promise { + if (this.workerCount >= this.maxParallel) return; + this.workerCount++; + + let entry: QueueItem | undefined; + while ((entry = this.queue.shift())) { + const { reject, resolve, task } = entry; + + try { + const result = await task(); + resolve(result); + } catch (error) { + reject(error); + } + } + + this.workerCount--; + } +} diff --git a/src/utils/RESERVED_NAMES.ts b/src/utils/RESERVED_NAMES.ts new file mode 100644 index 00000000000..3617670bf7b --- /dev/null +++ b/src/utils/RESERVED_NAMES.ts @@ -0,0 +1,54 @@ +const RESERVED_NAMES: ReadonlySet = new Set([ + 'await', + 'break', + 'case', + 'catch', + 'class', + 'const', + 'continue', + 'debugger', + 'default', + 'delete', + 'do', + 'else', + 'enum', + 'eval', + 'export', + 'exports', + 'extends', + 'false', + 'finally', + 'for', + 'function', + 'if', + 'implements', + 'import', + 'in', + 'instanceof', + 'interface', + 'let', + 'NaN', + 'new', + 'null', + 'package', + 'private', + 'protected', + 'public', + 'return', + 'static', + 'super', + 'switch', + 'this', + 'throw', + 'true', + 'try', + 'typeof', + 'undefined', + 'var', + 'void', + 'while', + 'with', + 'yield' +]); + +export default RESERVED_NAMES; diff --git a/src/utils/addons.ts b/src/utils/addons.ts index a3ef4ab37eb..5c539fee460 100644 --- a/src/utils/addons.ts +++ b/src/utils/addons.ts @@ -1,39 +1,41 @@ -import { NormalizedOutputOptions } from '../rollup/types'; -import { error } from './error'; -import { PluginDriver } from './PluginDriver'; +import type { NormalizedOutputOptions, RenderedChunk } from '../rollup/types'; +import type { PluginDriver } from './PluginDriver'; +import { error, logAddonNotGenerated } from './logs'; export interface Addons { - banner?: string; - footer?: string; - intro?: string; - outro?: string; + banner: string; + footer: string; + intro: string; + outro: string; } -const concatSep = (out: string, next: string) => (next ? `${out}\n${next}` : out); -const concatDblSep = (out: string, next: string) => (next ? `${out}\n\n${next}` : out); +const concatSeparator = (out: string, next: string) => (next ? `${out}\n${next}` : out); +const concatDblSeparator = (out: string, next: string) => (next ? `${out}\n\n${next}` : out); export async function createAddons( options: NormalizedOutputOptions, - outputPluginDriver: PluginDriver + outputPluginDriver: PluginDriver, + chunk: RenderedChunk ): Promise { try { let [banner, footer, intro, outro] = await Promise.all([ - outputPluginDriver.hookReduceValue('banner', options.banner(), [], concatSep), - outputPluginDriver.hookReduceValue('footer', options.footer(), [], concatSep), - outputPluginDriver.hookReduceValue('intro', options.intro(), [], concatDblSep), - outputPluginDriver.hookReduceValue('outro', options.outro(), [], concatDblSep) + outputPluginDriver.hookReduceValue('banner', options.banner(chunk), [chunk], concatSeparator), + outputPluginDriver.hookReduceValue('footer', options.footer(chunk), [chunk], concatSeparator), + outputPluginDriver.hookReduceValue( + 'intro', + options.intro(chunk), + [chunk], + concatDblSeparator + ), + outputPluginDriver.hookReduceValue('outro', options.outro(chunk), [chunk], concatDblSeparator) ]); if (intro) intro += '\n\n'; if (outro) outro = `\n\n${outro}`; - if (banner.length) banner += '\n'; - if (footer.length) footer = '\n' + footer; + if (banner) banner += '\n'; + if (footer) footer = '\n' + footer; - return { intro, outro, banner, footer }; - } catch (err) { - return error({ - code: 'ADDON_ERROR', - message: `Could not retrieve ${err.hook}. Check configuration of plugin ${err.plugin}. -\tError Message: ${err.message}` - }); + return { banner, footer, intro, outro }; + } catch (error_: any) { + return error(logAddonNotGenerated(error_.message, error_.hook, error_.plugin)); } } diff --git a/src/utils/astConverterHelpers.ts b/src/utils/astConverterHelpers.ts new file mode 100644 index 00000000000..44358a323d5 --- /dev/null +++ b/src/utils/astConverterHelpers.ts @@ -0,0 +1,33 @@ +import { EMPTY_ARRAY } from './blank'; +import FIXED_STRINGS from './convert-ast-strings'; + +export const ANNOTATION_KEY = '_rollupAnnotations'; +export const INVALID_ANNOTATION_KEY = '_rollupRemoved'; + +export type AnnotationType = 'pure' | 'noSideEffects'; + +export interface RollupAnnotation { + start: number; + end: number; + type: AnnotationType; +} + +export const convertAnnotations = ( + position: number, + buffer: Uint32Array +): readonly RollupAnnotation[] => { + if (position === 0) return EMPTY_ARRAY; + const length = buffer[position++]; + const list: any[] = new Array(length); + for (let index = 0; index < length; index++) { + list[index] = convertAnnotation(buffer[position++], buffer); + } + return list; +}; + +const convertAnnotation = (position: number, buffer: Uint32Array): RollupAnnotation => { + const start = buffer[position++]; + const end = buffer[position++]; + const type = FIXED_STRINGS[buffer[position]] as AnnotationType; + return { end, start, type }; +}; diff --git a/src/utils/asyncFlatten.ts b/src/utils/asyncFlatten.ts new file mode 100644 index 00000000000..06e58e3ed67 --- /dev/null +++ b/src/utils/asyncFlatten.ts @@ -0,0 +1,6 @@ +export async function asyncFlatten(array: T[]): Promise { + do { + array = (await Promise.all(array)).flat(Infinity) as any; + } while (array.some((v: any) => v?.then)); + return array; +} diff --git a/src/utils/base64.ts b/src/utils/base64.ts index 6a8ec75c66f..5fd6ed79581 100644 --- a/src/utils/base64.ts +++ b/src/utils/base64.ts @@ -1,12 +1,12 @@ const chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_$'; const base = 64; -export function toBase64(num: number): string { - let outStr = ''; +export function toBase64(value: number): string { + let outString = ''; do { - const curDigit = num % base; - num = Math.floor(num / base); - outStr = chars[curDigit] + outStr; - } while (num !== 0); - return outStr; + const currentDigit = value % base; + value = (value / base) | 0; + outString = chars[currentDigit] + outString; + } while (value !== 0); + return outString; } diff --git a/src/utils/blank.ts b/src/utils/blank.ts index b0715d324b9..01c6bd60c74 100644 --- a/src/utils/blank.ts +++ b/src/utils/blank.ts @@ -1,3 +1,10 @@ -export const BLANK: Record = Object.freeze(Object.create(null)); +export const BLANK: Record = Object.freeze(Object.create(null)); export const EMPTY_OBJECT = Object.freeze({}); export const EMPTY_ARRAY = Object.freeze([]); +export const EMPTY_SET = Object.freeze( + new (class extends Set { + add(): never { + throw new Error('Cannot add to empty set'); + } + })() +); diff --git a/src/utils/bufferToAst.ts b/src/utils/bufferToAst.ts new file mode 100644 index 00000000000..a7789d4ac70 --- /dev/null +++ b/src/utils/bufferToAst.ts @@ -0,0 +1,1112 @@ +// This file is generated by scripts/generate-buffer-to-ast.js. +// Do not edit this file directly. + +import type * as estree from 'estree'; +import { PanicError, ParseError } from '../ast/nodes/NodeType'; +import type { RollupAstNode } from '../rollup/types'; +import type { RollupAnnotation } from './astConverterHelpers'; +import { ANNOTATION_KEY, convertAnnotations, INVALID_ANNOTATION_KEY } from './astConverterHelpers'; +import { EMPTY_ARRAY } from './blank'; +import FIXED_STRINGS from './convert-ast-strings'; +import type { AstBuffer } from './getAstBuffer'; +import { error, getRollupError, logParseError } from './logs'; + +export function convertProgram(buffer: AstBuffer): ProgramNode { + const node = convertNode(0, buffer); + switch (node.type) { + case PanicError: { + return error(getRollupError(logParseError(node.message))); + } + case ParseError: { + return error(getRollupError(logParseError(node.message, node.start))); + } + default: { + return node; + } + } +} + +/* eslint-disable sort-keys */ +const nodeConverters: ((position: number, buffer: AstBuffer) => any)[] = [ + function panicError(position, buffer): PanicErrorNode { + return { + type: 'PanicError', + start: buffer[position], + end: buffer[position + 1], + message: buffer.convertString(buffer[position + 2]) + }; + }, + function parseError(position, buffer): ParseErrorNode { + return { + type: 'ParseError', + start: buffer[position], + end: buffer[position + 1], + message: buffer.convertString(buffer[position + 2]) + }; + }, + function arrayExpression(position, buffer): ArrayExpressionNode { + return { + type: 'ArrayExpression', + start: buffer[position], + end: buffer[position + 1], + elements: convertNodeList(buffer[position + 2], buffer) + }; + }, + function arrayPattern(position, buffer): ArrayPatternNode { + return { + type: 'ArrayPattern', + start: buffer[position], + end: buffer[position + 1], + elements: convertNodeList(buffer[position + 2], buffer) + }; + }, + function arrowFunctionExpression(position, buffer): ArrowFunctionExpressionNode { + const flags = buffer[position + 2]; + const annotations = convertAnnotations(buffer[position + 3], buffer); + return { + type: 'ArrowFunctionExpression', + start: buffer[position], + end: buffer[position + 1], + async: (flags & 1) === 1, + expression: (flags & 2) === 2, + generator: (flags & 4) === 4, + ...(annotations.length > 0 ? { [ANNOTATION_KEY]: annotations } : {}), + params: convertNodeList(buffer[position + 4], buffer), + body: convertNode(buffer[position + 5], buffer), + id: null + }; + }, + function assignmentExpression(position, buffer): AssignmentExpressionNode { + return { + type: 'AssignmentExpression', + start: buffer[position], + end: buffer[position + 1], + operator: FIXED_STRINGS[buffer[position + 2]] as estree.AssignmentOperator, + left: convertNode(buffer[position + 3], buffer), + right: convertNode(buffer[position + 4], buffer) + }; + }, + function assignmentPattern(position, buffer): AssignmentPatternNode { + return { + type: 'AssignmentPattern', + start: buffer[position], + end: buffer[position + 1], + left: convertNode(buffer[position + 2], buffer), + right: convertNode(buffer[position + 3], buffer) + }; + }, + function awaitExpression(position, buffer): AwaitExpressionNode { + return { + type: 'AwaitExpression', + start: buffer[position], + end: buffer[position + 1], + argument: convertNode(buffer[position + 2], buffer) + }; + }, + function binaryExpression(position, buffer): BinaryExpressionNode { + return { + type: 'BinaryExpression', + start: buffer[position], + end: buffer[position + 1], + operator: FIXED_STRINGS[buffer[position + 2]] as estree.BinaryOperator, + left: convertNode(buffer[position + 3], buffer), + right: convertNode(buffer[position + 4], buffer) + }; + }, + function blockStatement(position, buffer): BlockStatementNode { + return { + type: 'BlockStatement', + start: buffer[position], + end: buffer[position + 1], + body: convertNodeList(buffer[position + 2], buffer) + }; + }, + function breakStatement(position, buffer): BreakStatementNode { + const labelPosition = buffer[position + 2]; + return { + type: 'BreakStatement', + start: buffer[position], + end: buffer[position + 1], + label: labelPosition === 0 ? null : convertNode(labelPosition, buffer) + }; + }, + function callExpression(position, buffer): CallExpressionNode { + const flags = buffer[position + 2]; + const annotations = convertAnnotations(buffer[position + 3], buffer); + return { + type: 'CallExpression', + start: buffer[position], + end: buffer[position + 1], + optional: (flags & 1) === 1, + ...(annotations.length > 0 ? { [ANNOTATION_KEY]: annotations } : {}), + callee: convertNode(buffer[position + 4], buffer), + arguments: convertNodeList(buffer[position + 5], buffer) + }; + }, + function catchClause(position, buffer): CatchClauseNode { + const parameterPosition = buffer[position + 2]; + return { + type: 'CatchClause', + start: buffer[position], + end: buffer[position + 1], + param: parameterPosition === 0 ? null : convertNode(parameterPosition, buffer), + body: convertNode(buffer[position + 3], buffer) + }; + }, + function chainExpression(position, buffer): ChainExpressionNode { + return { + type: 'ChainExpression', + start: buffer[position], + end: buffer[position + 1], + expression: convertNode(buffer[position + 2], buffer) + }; + }, + function classBody(position, buffer): ClassBodyNode { + return { + type: 'ClassBody', + start: buffer[position], + end: buffer[position + 1], + body: convertNodeList(buffer[position + 2], buffer) + }; + }, + function classDeclaration(position, buffer): ClassDeclarationNode { + const idPosition = buffer[position + 3]; + const superClassPosition = buffer[position + 4]; + return { + type: 'ClassDeclaration', + start: buffer[position], + end: buffer[position + 1], + decorators: convertNodeList(buffer[position + 2], buffer), + id: idPosition === 0 ? null : convertNode(idPosition, buffer), + superClass: superClassPosition === 0 ? null : convertNode(superClassPosition, buffer), + body: convertNode(buffer[position + 5], buffer) + }; + }, + function classExpression(position, buffer): ClassExpressionNode { + const idPosition = buffer[position + 3]; + const superClassPosition = buffer[position + 4]; + return { + type: 'ClassExpression', + start: buffer[position], + end: buffer[position + 1], + decorators: convertNodeList(buffer[position + 2], buffer), + id: idPosition === 0 ? null : convertNode(idPosition, buffer), + superClass: superClassPosition === 0 ? null : convertNode(superClassPosition, buffer), + body: convertNode(buffer[position + 5], buffer) + }; + }, + function conditionalExpression(position, buffer): ConditionalExpressionNode { + return { + type: 'ConditionalExpression', + start: buffer[position], + end: buffer[position + 1], + test: convertNode(buffer[position + 2], buffer), + consequent: convertNode(buffer[position + 3], buffer), + alternate: convertNode(buffer[position + 4], buffer) + }; + }, + function continueStatement(position, buffer): ContinueStatementNode { + const labelPosition = buffer[position + 2]; + return { + type: 'ContinueStatement', + start: buffer[position], + end: buffer[position + 1], + label: labelPosition === 0 ? null : convertNode(labelPosition, buffer) + }; + }, + function debuggerStatement(position, buffer): DebuggerStatementNode { + return { + type: 'DebuggerStatement', + start: buffer[position], + end: buffer[position + 1] + }; + }, + function decorator(position, buffer): DecoratorNode { + return { + type: 'Decorator', + start: buffer[position], + end: buffer[position + 1], + expression: convertNode(buffer[position + 2], buffer) + }; + }, + function directive(position, buffer): DirectiveNode { + return { + type: 'ExpressionStatement', + start: buffer[position], + end: buffer[position + 1], + directive: buffer.convertString(buffer[position + 2]), + expression: convertNode(buffer[position + 3], buffer) + }; + }, + function doWhileStatement(position, buffer): DoWhileStatementNode { + return { + type: 'DoWhileStatement', + start: buffer[position], + end: buffer[position + 1], + body: convertNode(buffer[position + 2], buffer), + test: convertNode(buffer[position + 3], buffer) + }; + }, + function emptyStatement(position, buffer): EmptyStatementNode { + return { + type: 'EmptyStatement', + start: buffer[position], + end: buffer[position + 1] + }; + }, + function exportAllDeclaration(position, buffer): ExportAllDeclarationNode { + const exportedPosition = buffer[position + 2]; + return { + type: 'ExportAllDeclaration', + start: buffer[position], + end: buffer[position + 1], + exported: exportedPosition === 0 ? null : convertNode(exportedPosition, buffer), + source: convertNode(buffer[position + 3], buffer), + attributes: convertNodeList(buffer[position + 4], buffer) + }; + }, + function exportDefaultDeclaration(position, buffer): ExportDefaultDeclarationNode { + return { + type: 'ExportDefaultDeclaration', + start: buffer[position], + end: buffer[position + 1], + declaration: convertNode(buffer[position + 2], buffer) + }; + }, + function exportNamedDeclaration(position, buffer): ExportNamedDeclarationNode { + const sourcePosition = buffer[position + 3]; + const declarationPosition = buffer[position + 5]; + return { + type: 'ExportNamedDeclaration', + start: buffer[position], + end: buffer[position + 1], + specifiers: convertNodeList(buffer[position + 2], buffer), + source: sourcePosition === 0 ? null : convertNode(sourcePosition, buffer), + attributes: convertNodeList(buffer[position + 4], buffer), + declaration: declarationPosition === 0 ? null : convertNode(declarationPosition, buffer) + }; + }, + function exportSpecifier(position, buffer): ExportSpecifierNode { + const local = convertNode(buffer[position + 2], buffer); + const exportedPosition = buffer[position + 3]; + return { + type: 'ExportSpecifier', + start: buffer[position], + end: buffer[position + 1], + local, + exported: exportedPosition === 0 ? { ...local } : convertNode(exportedPosition, buffer) + }; + }, + function expressionStatement(position, buffer): ExpressionStatementNode { + return { + type: 'ExpressionStatement', + start: buffer[position], + end: buffer[position + 1], + expression: convertNode(buffer[position + 2], buffer) + }; + }, + function forInStatement(position, buffer): ForInStatementNode { + return { + type: 'ForInStatement', + start: buffer[position], + end: buffer[position + 1], + left: convertNode(buffer[position + 2], buffer), + right: convertNode(buffer[position + 3], buffer), + body: convertNode(buffer[position + 4], buffer) + }; + }, + function forOfStatement(position, buffer): ForOfStatementNode { + const flags = buffer[position + 2]; + return { + type: 'ForOfStatement', + start: buffer[position], + end: buffer[position + 1], + await: (flags & 1) === 1, + left: convertNode(buffer[position + 3], buffer), + right: convertNode(buffer[position + 4], buffer), + body: convertNode(buffer[position + 5], buffer) + }; + }, + function forStatement(position, buffer): ForStatementNode { + const initPosition = buffer[position + 2]; + const testPosition = buffer[position + 3]; + const updatePosition = buffer[position + 4]; + return { + type: 'ForStatement', + start: buffer[position], + end: buffer[position + 1], + init: initPosition === 0 ? null : convertNode(initPosition, buffer), + test: testPosition === 0 ? null : convertNode(testPosition, buffer), + update: updatePosition === 0 ? null : convertNode(updatePosition, buffer), + body: convertNode(buffer[position + 5], buffer) + }; + }, + function functionDeclaration(position, buffer): FunctionDeclarationNode { + const flags = buffer[position + 2]; + const annotations = convertAnnotations(buffer[position + 3], buffer); + const idPosition = buffer[position + 4]; + return { + type: 'FunctionDeclaration', + start: buffer[position], + end: buffer[position + 1], + async: (flags & 1) === 1, + generator: (flags & 2) === 2, + ...(annotations.length > 0 ? { [ANNOTATION_KEY]: annotations } : {}), + id: idPosition === 0 ? null : convertNode(idPosition, buffer), + params: convertNodeList(buffer[position + 5], buffer), + body: convertNode(buffer[position + 6], buffer), + expression: false + }; + }, + function functionExpression(position, buffer): FunctionExpressionNode { + const flags = buffer[position + 2]; + const annotations = convertAnnotations(buffer[position + 3], buffer); + const idPosition = buffer[position + 4]; + return { + type: 'FunctionExpression', + start: buffer[position], + end: buffer[position + 1], + async: (flags & 1) === 1, + generator: (flags & 2) === 2, + ...(annotations.length > 0 ? { [ANNOTATION_KEY]: annotations } : {}), + id: idPosition === 0 ? null : convertNode(idPosition, buffer), + params: convertNodeList(buffer[position + 5], buffer), + body: convertNode(buffer[position + 6], buffer), + expression: false + }; + }, + function identifier(position, buffer): IdentifierNode { + return { + type: 'Identifier', + start: buffer[position], + end: buffer[position + 1], + name: buffer.convertString(buffer[position + 2]) + }; + }, + function ifStatement(position, buffer): IfStatementNode { + const alternatePosition = buffer[position + 4]; + return { + type: 'IfStatement', + start: buffer[position], + end: buffer[position + 1], + test: convertNode(buffer[position + 2], buffer), + consequent: convertNode(buffer[position + 3], buffer), + alternate: alternatePosition === 0 ? null : convertNode(alternatePosition, buffer) + }; + }, + function importAttribute(position, buffer): ImportAttributeNode { + return { + type: 'ImportAttribute', + start: buffer[position], + end: buffer[position + 1], + key: convertNode(buffer[position + 2], buffer), + value: convertNode(buffer[position + 3], buffer) + }; + }, + function importDeclaration(position, buffer): ImportDeclarationNode { + return { + type: 'ImportDeclaration', + start: buffer[position], + end: buffer[position + 1], + specifiers: convertNodeList(buffer[position + 2], buffer), + source: convertNode(buffer[position + 3], buffer), + attributes: convertNodeList(buffer[position + 4], buffer) + }; + }, + function importDefaultSpecifier(position, buffer): ImportDefaultSpecifierNode { + return { + type: 'ImportDefaultSpecifier', + start: buffer[position], + end: buffer[position + 1], + local: convertNode(buffer[position + 2], buffer) + }; + }, + function importExpression(position, buffer): ImportExpressionNode { + const optionsPosition = buffer[position + 3]; + return { + type: 'ImportExpression', + start: buffer[position], + end: buffer[position + 1], + source: convertNode(buffer[position + 2], buffer), + options: optionsPosition === 0 ? null : convertNode(optionsPosition, buffer) + }; + }, + function importNamespaceSpecifier(position, buffer): ImportNamespaceSpecifierNode { + return { + type: 'ImportNamespaceSpecifier', + start: buffer[position], + end: buffer[position + 1], + local: convertNode(buffer[position + 2], buffer) + }; + }, + function importSpecifier(position, buffer): ImportSpecifierNode { + const importedPosition = buffer[position + 2]; + const local = convertNode(buffer[position + 3], buffer); + return { + type: 'ImportSpecifier', + start: buffer[position], + end: buffer[position + 1], + imported: importedPosition === 0 ? { ...local } : convertNode(importedPosition, buffer), + local + }; + }, + function jsxAttribute(position, buffer): JSXAttributeNode { + const valuePosition = buffer[position + 3]; + return { + type: 'JSXAttribute', + start: buffer[position], + end: buffer[position + 1], + name: convertNode(buffer[position + 2], buffer), + value: valuePosition === 0 ? null : convertNode(valuePosition, buffer) + }; + }, + function jsxClosingElement(position, buffer): JSXClosingElementNode { + return { + type: 'JSXClosingElement', + start: buffer[position], + end: buffer[position + 1], + name: convertNode(buffer[position + 2], buffer) + }; + }, + function jsxClosingFragment(position, buffer): JSXClosingFragmentNode { + return { + type: 'JSXClosingFragment', + start: buffer[position], + end: buffer[position + 1] + }; + }, + function jsxElement(position, buffer): JSXElementNode { + const closingElementPosition = buffer[position + 4]; + return { + type: 'JSXElement', + start: buffer[position], + end: buffer[position + 1], + openingElement: convertNode(buffer[position + 2], buffer), + children: convertNodeList(buffer[position + 3], buffer), + closingElement: + closingElementPosition === 0 ? null : convertNode(closingElementPosition, buffer) + }; + }, + function jsxEmptyExpression(position, buffer): JSXEmptyExpressionNode { + return { + type: 'JSXEmptyExpression', + start: buffer[position], + end: buffer[position + 1] + }; + }, + function jsxExpressionContainer(position, buffer): JSXExpressionContainerNode { + return { + type: 'JSXExpressionContainer', + start: buffer[position], + end: buffer[position + 1], + expression: convertNode(buffer[position + 2], buffer) + }; + }, + function jsxFragment(position, buffer): JSXFragmentNode { + return { + type: 'JSXFragment', + start: buffer[position], + end: buffer[position + 1], + openingFragment: convertNode(buffer[position + 2], buffer), + children: convertNodeList(buffer[position + 3], buffer), + closingFragment: convertNode(buffer[position + 4], buffer) + }; + }, + function jsxIdentifier(position, buffer): JSXIdentifierNode { + return { + type: 'JSXIdentifier', + start: buffer[position], + end: buffer[position + 1], + name: buffer.convertString(buffer[position + 2]) + }; + }, + function jsxMemberExpression(position, buffer): JSXMemberExpressionNode { + return { + type: 'JSXMemberExpression', + start: buffer[position], + end: buffer[position + 1], + object: convertNode(buffer[position + 2], buffer), + property: convertNode(buffer[position + 3], buffer) + }; + }, + function jsxNamespacedName(position, buffer): JSXNamespacedNameNode { + return { + type: 'JSXNamespacedName', + start: buffer[position], + end: buffer[position + 1], + namespace: convertNode(buffer[position + 2], buffer), + name: convertNode(buffer[position + 3], buffer) + }; + }, + function jsxOpeningElement(position, buffer): JSXOpeningElementNode { + const flags = buffer[position + 2]; + return { + type: 'JSXOpeningElement', + start: buffer[position], + end: buffer[position + 1], + selfClosing: (flags & 1) === 1, + name: convertNode(buffer[position + 3], buffer), + attributes: convertNodeList(buffer[position + 4], buffer) + }; + }, + function jsxOpeningFragment(position, buffer): JSXOpeningFragmentNode { + return { + type: 'JSXOpeningFragment', + start: buffer[position], + end: buffer[position + 1], + attributes: [], + selfClosing: false + }; + }, + function jsxSpreadAttribute(position, buffer): JSXSpreadAttributeNode { + return { + type: 'JSXSpreadAttribute', + start: buffer[position], + end: buffer[position + 1], + argument: convertNode(buffer[position + 2], buffer) + }; + }, + function jsxSpreadChild(position, buffer): JSXSpreadChildNode { + return { + type: 'JSXSpreadChild', + start: buffer[position], + end: buffer[position + 1], + expression: convertNode(buffer[position + 2], buffer) + }; + }, + function jsxText(position, buffer): JSXTextNode { + return { + type: 'JSXText', + start: buffer[position], + end: buffer[position + 1], + value: buffer.convertString(buffer[position + 2]), + raw: buffer.convertString(buffer[position + 3]) + }; + }, + function labeledStatement(position, buffer): LabeledStatementNode { + return { + type: 'LabeledStatement', + start: buffer[position], + end: buffer[position + 1], + label: convertNode(buffer[position + 2], buffer), + body: convertNode(buffer[position + 3], buffer) + }; + }, + function literalBigInt(position, buffer): LiteralBigIntNode { + const bigint = buffer.convertString(buffer[position + 2]); + return { + type: 'Literal', + start: buffer[position], + end: buffer[position + 1], + bigint, + raw: buffer.convertString(buffer[position + 3]), + value: BigInt(bigint) + }; + }, + function literalBoolean(position, buffer): LiteralBooleanNode { + const flags = buffer[position + 2]; + const value = (flags & 1) === 1; + return { + type: 'Literal', + start: buffer[position], + end: buffer[position + 1], + value, + raw: value ? 'true' : 'false' + }; + }, + function literalNull(position, buffer): LiteralNullNode { + return { + type: 'Literal', + start: buffer[position], + end: buffer[position + 1], + raw: 'null', + value: null + }; + }, + function literalNumber(position, buffer): LiteralNumberNode { + const rawPosition = buffer[position + 2]; + return { + type: 'Literal', + start: buffer[position], + end: buffer[position + 1], + raw: rawPosition === 0 ? undefined : buffer.convertString(rawPosition), + value: new DataView(buffer.buffer).getFloat64((position + 3) << 2, true) + }; + }, + function literalRegExp(position, buffer): LiteralRegExpNode { + const flags = buffer.convertString(buffer[position + 2]); + const pattern = buffer.convertString(buffer[position + 3]); + return { + type: 'Literal', + start: buffer[position], + end: buffer[position + 1], + raw: `/${pattern}/${flags}`, + regex: { flags, pattern }, + value: new RegExp(pattern, flags) + }; + }, + function literalString(position, buffer): LiteralStringNode { + const rawPosition = buffer[position + 3]; + return { + type: 'Literal', + start: buffer[position], + end: buffer[position + 1], + value: buffer.convertString(buffer[position + 2]), + raw: rawPosition === 0 ? undefined : buffer.convertString(rawPosition) + }; + }, + function logicalExpression(position, buffer): LogicalExpressionNode { + return { + type: 'LogicalExpression', + start: buffer[position], + end: buffer[position + 1], + operator: FIXED_STRINGS[buffer[position + 2]] as estree.LogicalOperator, + left: convertNode(buffer[position + 3], buffer), + right: convertNode(buffer[position + 4], buffer) + }; + }, + function memberExpression(position, buffer): MemberExpressionNode { + const flags = buffer[position + 2]; + return { + type: 'MemberExpression', + start: buffer[position], + end: buffer[position + 1], + computed: (flags & 1) === 1, + optional: (flags & 2) === 2, + object: convertNode(buffer[position + 3], buffer), + property: convertNode(buffer[position + 4], buffer) + }; + }, + function metaProperty(position, buffer): MetaPropertyNode { + return { + type: 'MetaProperty', + start: buffer[position], + end: buffer[position + 1], + meta: convertNode(buffer[position + 2], buffer), + property: convertNode(buffer[position + 3], buffer) + }; + }, + function methodDefinition(position, buffer): MethodDefinitionNode { + const flags = buffer[position + 2]; + return { + type: 'MethodDefinition', + start: buffer[position], + end: buffer[position + 1], + static: (flags & 1) === 1, + computed: (flags & 2) === 2, + decorators: convertNodeList(buffer[position + 3], buffer), + key: convertNode(buffer[position + 4], buffer), + value: convertNode(buffer[position + 5], buffer), + kind: FIXED_STRINGS[buffer[position + 6]] as estree.MethodDefinition['kind'] + }; + }, + function newExpression(position, buffer): NewExpressionNode { + const annotations = convertAnnotations(buffer[position + 2], buffer); + return { + type: 'NewExpression', + start: buffer[position], + end: buffer[position + 1], + ...(annotations.length > 0 ? { [ANNOTATION_KEY]: annotations } : {}), + callee: convertNode(buffer[position + 3], buffer), + arguments: convertNodeList(buffer[position + 4], buffer) + }; + }, + function objectExpression(position, buffer): ObjectExpressionNode { + return { + type: 'ObjectExpression', + start: buffer[position], + end: buffer[position + 1], + properties: convertNodeList(buffer[position + 2], buffer) + }; + }, + function objectPattern(position, buffer): ObjectPatternNode { + return { + type: 'ObjectPattern', + start: buffer[position], + end: buffer[position + 1], + properties: convertNodeList(buffer[position + 2], buffer) + }; + }, + function privateIdentifier(position, buffer): PrivateIdentifierNode { + return { + type: 'PrivateIdentifier', + start: buffer[position], + end: buffer[position + 1], + name: buffer.convertString(buffer[position + 2]) + }; + }, + function program(position, buffer): ProgramNode { + const invalidAnnotations = convertAnnotations(buffer[position + 3], buffer); + return { + type: 'Program', + start: buffer[position], + end: buffer[position + 1], + body: convertNodeList(buffer[position + 2], buffer), + ...(invalidAnnotations.length > 0 ? { [INVALID_ANNOTATION_KEY]: invalidAnnotations } : {}), + sourceType: 'module' + }; + }, + function property(position, buffer): PropertyNode { + const flags = buffer[position + 2]; + const keyPosition = buffer[position + 3]; + const value = convertNode(buffer[position + 4], buffer); + return { + type: 'Property', + start: buffer[position], + end: buffer[position + 1], + method: (flags & 1) === 1, + shorthand: (flags & 2) === 2, + computed: (flags & 4) === 4, + key: keyPosition === 0 ? { ...value } : convertNode(keyPosition, buffer), + value, + kind: FIXED_STRINGS[buffer[position + 5]] as estree.Property['kind'] + }; + }, + function propertyDefinition(position, buffer): PropertyDefinitionNode { + const flags = buffer[position + 2]; + const valuePosition = buffer[position + 5]; + return { + type: 'PropertyDefinition', + start: buffer[position], + end: buffer[position + 1], + static: (flags & 1) === 1, + computed: (flags & 2) === 2, + decorators: convertNodeList(buffer[position + 3], buffer), + key: convertNode(buffer[position + 4], buffer), + value: valuePosition === 0 ? null : convertNode(valuePosition, buffer) + }; + }, + function restElement(position, buffer): RestElementNode { + return { + type: 'RestElement', + start: buffer[position], + end: buffer[position + 1], + argument: convertNode(buffer[position + 2], buffer) + }; + }, + function returnStatement(position, buffer): ReturnStatementNode { + const argumentPosition = buffer[position + 2]; + return { + type: 'ReturnStatement', + start: buffer[position], + end: buffer[position + 1], + argument: argumentPosition === 0 ? null : convertNode(argumentPosition, buffer) + }; + }, + function sequenceExpression(position, buffer): SequenceExpressionNode { + return { + type: 'SequenceExpression', + start: buffer[position], + end: buffer[position + 1], + expressions: convertNodeList(buffer[position + 2], buffer) + }; + }, + function spreadElement(position, buffer): SpreadElementNode { + return { + type: 'SpreadElement', + start: buffer[position], + end: buffer[position + 1], + argument: convertNode(buffer[position + 2], buffer) + }; + }, + function staticBlock(position, buffer): StaticBlockNode { + return { + type: 'StaticBlock', + start: buffer[position], + end: buffer[position + 1], + body: convertNodeList(buffer[position + 2], buffer) + }; + }, + function superElement(position, buffer): SuperElementNode { + return { + type: 'Super', + start: buffer[position], + end: buffer[position + 1] + }; + }, + function switchCase(position, buffer): SwitchCaseNode { + const testPosition = buffer[position + 2]; + return { + type: 'SwitchCase', + start: buffer[position], + end: buffer[position + 1], + test: testPosition === 0 ? null : convertNode(testPosition, buffer), + consequent: convertNodeList(buffer[position + 3], buffer) + }; + }, + function switchStatement(position, buffer): SwitchStatementNode { + return { + type: 'SwitchStatement', + start: buffer[position], + end: buffer[position + 1], + discriminant: convertNode(buffer[position + 2], buffer), + cases: convertNodeList(buffer[position + 3], buffer) + }; + }, + function taggedTemplateExpression(position, buffer): TaggedTemplateExpressionNode { + return { + type: 'TaggedTemplateExpression', + start: buffer[position], + end: buffer[position + 1], + tag: convertNode(buffer[position + 2], buffer), + quasi: convertNode(buffer[position + 3], buffer) + }; + }, + function templateElement(position, buffer): TemplateElementNode { + const flags = buffer[position + 2]; + const cookedPosition = buffer[position + 3]; + const cooked = cookedPosition === 0 ? null : buffer.convertString(cookedPosition); + const raw = buffer.convertString(buffer[position + 4]); + return { + type: 'TemplateElement', + start: buffer[position], + end: buffer[position + 1], + tail: (flags & 1) === 1, + value: { cooked, raw } + }; + }, + function templateLiteral(position, buffer): TemplateLiteralNode { + return { + type: 'TemplateLiteral', + start: buffer[position], + end: buffer[position + 1], + quasis: convertNodeList(buffer[position + 2], buffer), + expressions: convertNodeList(buffer[position + 3], buffer) + }; + }, + function thisExpression(position, buffer): ThisExpressionNode { + return { + type: 'ThisExpression', + start: buffer[position], + end: buffer[position + 1] + }; + }, + function throwStatement(position, buffer): ThrowStatementNode { + return { + type: 'ThrowStatement', + start: buffer[position], + end: buffer[position + 1], + argument: convertNode(buffer[position + 2], buffer) + }; + }, + function tryStatement(position, buffer): TryStatementNode { + const handlerPosition = buffer[position + 3]; + const finalizerPosition = buffer[position + 4]; + return { + type: 'TryStatement', + start: buffer[position], + end: buffer[position + 1], + block: convertNode(buffer[position + 2], buffer), + handler: handlerPosition === 0 ? null : convertNode(handlerPosition, buffer), + finalizer: finalizerPosition === 0 ? null : convertNode(finalizerPosition, buffer) + }; + }, + function unaryExpression(position, buffer): UnaryExpressionNode { + return { + type: 'UnaryExpression', + start: buffer[position], + end: buffer[position + 1], + operator: FIXED_STRINGS[buffer[position + 2]] as estree.UnaryOperator, + argument: convertNode(buffer[position + 3], buffer), + prefix: true + }; + }, + function updateExpression(position, buffer): UpdateExpressionNode { + const flags = buffer[position + 2]; + return { + type: 'UpdateExpression', + start: buffer[position], + end: buffer[position + 1], + prefix: (flags & 1) === 1, + operator: FIXED_STRINGS[buffer[position + 3]] as estree.UpdateOperator, + argument: convertNode(buffer[position + 4], buffer) + }; + }, + function variableDeclaration(position, buffer): VariableDeclarationNode { + return { + type: 'VariableDeclaration', + start: buffer[position], + end: buffer[position + 1], + kind: FIXED_STRINGS[buffer[position + 2]] as estree.VariableDeclaration['kind'], + declarations: convertNodeList(buffer[position + 3], buffer) + }; + }, + function variableDeclarator(position, buffer): VariableDeclaratorNode { + const initPosition = buffer[position + 3]; + return { + type: 'VariableDeclarator', + start: buffer[position], + end: buffer[position + 1], + id: convertNode(buffer[position + 2], buffer), + init: initPosition === 0 ? null : convertNode(initPosition, buffer) + }; + }, + function whileStatement(position, buffer): WhileStatementNode { + return { + type: 'WhileStatement', + start: buffer[position], + end: buffer[position + 1], + test: convertNode(buffer[position + 2], buffer), + body: convertNode(buffer[position + 3], buffer) + }; + }, + function yieldExpression(position, buffer): YieldExpressionNode { + const flags = buffer[position + 2]; + const argumentPosition = buffer[position + 3]; + return { + type: 'YieldExpression', + start: buffer[position], + end: buffer[position + 1], + delegate: (flags & 1) === 1, + argument: argumentPosition === 0 ? null : convertNode(argumentPosition, buffer) + }; + } +]; + +export type PanicErrorNode = RollupAstNode<{ type: 'PanicError'; message: string }>; +export type ParseErrorNode = RollupAstNode<{ type: 'ParseError'; message: string }>; +export type ArrayExpressionNode = RollupAstNode; +export type ArrayPatternNode = RollupAstNode; +export type ArrowFunctionExpressionNode = RollupAstNode & { + [ANNOTATION_KEY]?: readonly RollupAnnotation[]; + id: null; +}; +export type AssignmentExpressionNode = RollupAstNode; +export type AssignmentPatternNode = RollupAstNode; +export type AwaitExpressionNode = RollupAstNode; +export type BinaryExpressionNode = RollupAstNode; +export type BlockStatementNode = RollupAstNode; +export type BreakStatementNode = RollupAstNode; +export type CallExpressionNode = RollupAstNode & { + [ANNOTATION_KEY]?: readonly RollupAnnotation[]; +}; +export type CatchClauseNode = RollupAstNode; +export type ChainExpressionNode = RollupAstNode; +export type ClassBodyNode = RollupAstNode; +export type ClassDeclarationNode = RollupAstNode; +export type ClassExpressionNode = RollupAstNode; +export type ConditionalExpressionNode = RollupAstNode; +export type ContinueStatementNode = RollupAstNode; +export type DebuggerStatementNode = RollupAstNode; +export type DecoratorNode = RollupAstNode; +export type DirectiveNode = RollupAstNode; +export type DoWhileStatementNode = RollupAstNode; +export type EmptyStatementNode = RollupAstNode; +export type ExportAllDeclarationNode = RollupAstNode< + estree.ExportAllDeclaration & { attributes: ImportAttributeNode[] } +>; +export type ExportDefaultDeclarationNode = RollupAstNode; +export type ExportNamedDeclarationNode = RollupAstNode< + estree.ExportNamedDeclaration & { attributes: ImportAttributeNode[] } +>; +export type ExportSpecifierNode = RollupAstNode; +export type ExpressionStatementNode = RollupAstNode; +export type ForInStatementNode = RollupAstNode; +export type ForOfStatementNode = RollupAstNode; +export type ForStatementNode = RollupAstNode; +export type FunctionDeclarationNode = RollupAstNode & { + [ANNOTATION_KEY]?: readonly RollupAnnotation[]; + expression: false; +}; +export type FunctionExpressionNode = RollupAstNode & { + [ANNOTATION_KEY]?: readonly RollupAnnotation[]; + expression: false; +}; +export type IdentifierNode = RollupAstNode; +export type IfStatementNode = RollupAstNode; +export type ImportAttributeNode = RollupAstNode<{ + key: estree.Identifier | estree.Literal; + type: 'ImportAttribute'; + value: estree.Literal; +}>; +export type ImportDeclarationNode = RollupAstNode< + estree.ImportDeclaration & { attributes: ImportAttributeNode[] } +>; +export type ImportDefaultSpecifierNode = RollupAstNode; +export type ImportExpressionNode = RollupAstNode< + estree.ImportExpression & { options: estree.Expression | null } +>; +export type ImportNamespaceSpecifierNode = RollupAstNode; +export type ImportSpecifierNode = RollupAstNode; +export type JSXAttributeNode = RollupAstNode; +export type JSXClosingElementNode = RollupAstNode; +export type JSXClosingFragmentNode = RollupAstNode; +export type JSXElementNode = RollupAstNode; +export type JSXEmptyExpressionNode = RollupAstNode; +export type JSXExpressionContainerNode = RollupAstNode; +export type JSXFragmentNode = RollupAstNode; +export type JSXIdentifierNode = RollupAstNode; +export type JSXMemberExpressionNode = RollupAstNode; +export type JSXNamespacedNameNode = RollupAstNode; +export type JSXOpeningElementNode = RollupAstNode; +export type JSXOpeningFragmentNode = RollupAstNode; +export type JSXSpreadAttributeNode = RollupAstNode; +export type JSXSpreadChildNode = RollupAstNode; +export type JSXTextNode = RollupAstNode; +export type LabeledStatementNode = RollupAstNode; +export type LiteralBigIntNode = RollupAstNode; +export type LiteralBooleanNode = RollupAstNode; +export type LiteralNullNode = RollupAstNode & { + raw: 'null'; +}; +export type LiteralNumberNode = RollupAstNode; +export type LiteralRegExpNode = RollupAstNode; +export type LiteralStringNode = RollupAstNode; +export type LogicalExpressionNode = RollupAstNode; +export type MemberExpressionNode = RollupAstNode; +export type MetaPropertyNode = RollupAstNode; +export type MethodDefinitionNode = RollupAstNode; +export type NewExpressionNode = RollupAstNode & { + [ANNOTATION_KEY]?: readonly RollupAnnotation[]; +}; +export type ObjectExpressionNode = RollupAstNode; +export type ObjectPatternNode = RollupAstNode; +export type PrivateIdentifierNode = RollupAstNode; +export type ProgramNode = RollupAstNode & { + [INVALID_ANNOTATION_KEY]?: readonly RollupAnnotation[]; + sourceType: 'module'; +}; +export type PropertyNode = RollupAstNode; +export type PropertyDefinitionNode = RollupAstNode; +export type RestElementNode = RollupAstNode; +export type ReturnStatementNode = RollupAstNode; +export type SequenceExpressionNode = RollupAstNode; +export type SpreadElementNode = RollupAstNode; +export type StaticBlockNode = RollupAstNode; +export type SuperElementNode = RollupAstNode; +export type SwitchCaseNode = RollupAstNode; +export type SwitchStatementNode = RollupAstNode; +export type TaggedTemplateExpressionNode = RollupAstNode; +export type TemplateElementNode = RollupAstNode; +export type TemplateLiteralNode = RollupAstNode; +export type ThisExpressionNode = RollupAstNode; +export type ThrowStatementNode = RollupAstNode; +export type TryStatementNode = RollupAstNode; +export type UnaryExpressionNode = RollupAstNode & { prefix: true }; +export type UpdateExpressionNode = RollupAstNode; +export type VariableDeclarationNode = RollupAstNode; +export type VariableDeclaratorNode = RollupAstNode; +export type WhileStatementNode = RollupAstNode; +export type YieldExpressionNode = RollupAstNode; + +export function convertNode(position: number, buffer: AstBuffer): any { + const nodeType = buffer[position]; + const converter = nodeConverters[nodeType]; + /* istanbul ignore if: This should never be executed but is a safeguard against faulty buffers */ + if (!converter) { + console.trace(); + throw new Error(`Unknown node type: ${nodeType}`); + } + return converter(position + 1, buffer); +} + +function convertNodeList(position: number, buffer: AstBuffer): any[] { + if (position === 0) return EMPTY_ARRAY as never[]; + const length = buffer[position++]; + const list: any[] = new Array(length); + for (let index = 0; index < length; index++) { + const nodePosition = buffer[position++]; + list[index] = nodePosition ? convertNode(nodePosition, buffer) : null; + } + return list; +} diff --git a/src/utils/chunkAssignment.ts b/src/utils/chunkAssignment.ts index b4fb355377c..46f570365fc 100644 --- a/src/utils/chunkAssignment.ts +++ b/src/utils/chunkAssignment.ts @@ -1,105 +1,259 @@ import ExternalModule from '../ExternalModule'; import Module from '../Module'; -import { getOrCreate } from './getOrCreate'; +import type { LogHandler } from '../rollup/types'; +import { getNewSet, getOrCreate } from './getOrCreate'; +import { concatLazy } from './iterators'; +import { logOptimizeChunkStatus } from './logs'; +import { timeEnd, timeStart } from './timers'; -type DependentModuleMap = Map>; type ChunkDefinitions = { alias: string | null; modules: Module[] }[]; +interface ModulesWithDependentEntries { + /** + * The indices of the entries depending on this chunk + */ + dependentEntries: Set; + modules: Module[]; +} + +interface ChunkDescription extends ModulesWithDependentEntries { + /** + * These are the atoms (=initial chunks) that are contained in this chunk + */ + containedAtoms: bigint; + /** + * The signatures of all atoms that are included in or loaded with this + * chunk. This is the intersection of all dependent entry modules. As chunks + * are merged, these sets are intersected. + */ + correlatedAtoms: bigint; + dependencies: Set; + dependentChunks: Set; + pure: boolean; + size: number; +} + +interface ChunkPartition { + big: Set; + small: Set; +} + +/** + * At its core, the algorithm first starts from each static or dynamic entry + * point and then assigns that entry point to all modules than can be reached + * via static imports. We call this the *dependent entry points* of that + * module. + * + * Then we group all modules with the same dependent entry points into chunks + * as those modules will always be loaded together. + * + * One non-trivial optimization we can apply is that dynamic entries are + * different from static entries in so far as when a dynamic import occurs, + * some modules are already in memory. If some of these modules are also + * dependencies of the dynamic entry, then it does not make sense to create a + * separate chunk for them. Instead, the dynamic import target can load them + * from the importing chunk. + * + * With regard to chunking, if B is implicitly loaded after A, then this can be + * handled the same way as if there was a dynamic import A => B. + * + * Example: + * Assume A -> B (A imports B), A => C (A dynamically imports C) and C -> B. + * Then the initial algorithm would assign A into the A chunk, C into the C + * chunk and B into the AC chunk, i.e. the chunk with the dependent entry + * points A and C. + * However we know that C can only be loaded from A, so A and its dependency B + * must already be in memory when C is loaded. So it is enough to create only + * two chunks A containing [AB] and C containing [C]. + * + * So we do not assign the dynamic entry C as dependent entry point to modules + * that are already loaded. + * + * In a more complex example, let us assume that we have entry points X and Y. + * Further, let us assume + * X -> A, X -> B, X -> C, + * Y -> A, Y -> B, + * A => D, + * D -> B, D -> C + * So without dynamic import optimization, the dependent entry points are + * A: XY, B: DXY, C: DX, D: D, X: X, Y: Y, so we would for now create six + * chunks. + * + * Now D is loaded only after A is loaded. But A is loaded if either X is + * loaded or Y is loaded. So the modules that are already in memory when D is + * loaded are the intersection of all modules that X depends on with all + * modules that Y depends on, which in this case are the modules A and B. + * We could also say they are all modules that have both X and Y as dependent + * entry points. + * + * So we can remove D as dependent entry point from A and B, which means they + * both now have only XY as dependent entry points and can be merged into the + * same chunk. + * + * Now let us extend this to the most general case where we have several + * dynamic importers for one dynamic entry point. + * + * In the most general form, it works like this: + * For each dynamic entry point, we have a number of dynamic importers, which + * are the modules importing it. Using the previous ideas, we can determine + * the modules already in memory for each dynamic importer by looking for all + * modules that have all the dependent entry points of the dynamic importer as + * dependent entry points. + * So the modules that are guaranteed to be in memory when the dynamic entry + * point is loaded are the intersection of the modules already in memory for + * each dynamic importer. + * + * Assuming that A => D and B => D and A has dependent entry points XY and B + * has dependent entry points YZ, then the modules guaranteed to be in memory + * are all modules that have at least XYZ as dependent entry points. + * We call XYZ the *dynamically dependent entry points* of D. + * + * Now there is one last case to consider: If one of the dynamically dependent + * entries is itself a dynamic entry, then any module is in memory that either + * is a dependency of that dynamic entry or again has the dynamic dependent + * entries of that dynamic entry as dependent entry points. + * + * A naive algorithm for this proved to be costly as it contained an O(n^3) + * complexity with regard to dynamic entries that blew up for very large + * projects. + * + * If we have an efficient way to do Set operations, an alternative approach + * would be to instead collect already loaded modules per dynamic entry. And as + * all chunks from the initial grouping would behave the same, we can instead + * collect already loaded chunks for a performance improvement. + * + * To do that efficiently, need + * - a Map of dynamic imports per dynamic entry, which contains all dynamic + * imports that can be triggered by a dynamic entry + * - a Map of static dependencies per entry + * - a Map of already loaded chunks per entry that we initially populate with + * empty Sets for static entries and Sets containing all entries for dynamic + * entries + * + * For efficient operations, we assign each entry a numerical index and + * represent Sets of Chunks as BigInt values where each chunk corresponds to a + * bit index. Then the last two maps can be represented as arrays of BigInt + * values. + * + * Then we iterate through each dynamic entry. We set the already loaded modules + * to the intersection of the previously already loaded modules with the union + * of the already loaded modules of that chunk with its static dependencies. + * + * If the already loaded modules changed, then we use the Map of dynamic imports + * per dynamic entry to marks all dynamic entry dependencies as "dirty" and put + * them back into the iteration. As an additional optimization, we note for + * each dynamic entry which dynamic dependent entries have changed and only + * intersect those entries again on subsequent interations. + * + * Then we remove the dynamic entries from the list of dependent entries for + * those chunks that are already loaded for that dynamic entry and create + * another round of chunks. + */ export function getChunkAssignments( - entryModules: Module[], - manualChunkAliasByEntry: Map + entries: readonly Module[], + manualChunkAliasByEntry: ReadonlyMap, + minChunkSize: number, + log: LogHandler, + isManualChunksFunctionForm: boolean, + onlyExplicitManualChunks: boolean ): ChunkDefinitions { - const chunkDefinitions: ChunkDefinitions = []; - const modulesInManualChunks = new Set(manualChunkAliasByEntry.keys()); - const manualChunkModulesByAlias: Record = Object.create(null); - for (const [entry, alias] of manualChunkAliasByEntry) { - const chunkModules = (manualChunkModulesByAlias[alias] = - manualChunkModulesByAlias[alias] || []); - addStaticDependenciesToManualChunk(entry, chunkModules, modulesInManualChunks); - } - for (const [alias, modules] of Object.entries(manualChunkModulesByAlias)) { - chunkDefinitions.push({ alias, modules }); - } - - const assignedEntryPointsByModule: DependentModuleMap = new Map(); - const { dependentEntryPointsByModule, dynamicEntryModules } = analyzeModuleGraph(entryModules); - const dynamicallyDependentEntryPointsByDynamicEntry: DependentModuleMap = getDynamicDependentEntryPoints( - dependentEntryPointsByModule, - dynamicEntryModules + const { chunkDefinitions, modulesInManualChunks } = getChunkDefinitionsFromManualChunks( + manualChunkAliasByEntry, + isManualChunksFunctionForm, + onlyExplicitManualChunks ); - const staticEntries = new Set(entryModules); - - function assignEntryToStaticDependencies( - entry: Module, - dynamicDependentEntryPoints: Set | null - ) { - const modulesToHandle = new Set([entry]); - for (const module of modulesToHandle) { - const assignedEntryPoints = getOrCreate(assignedEntryPointsByModule, module, () => new Set()); - if ( - dynamicDependentEntryPoints && - areEntryPointsContainedOrDynamicallyDependent( - dynamicDependentEntryPoints, - dependentEntryPointsByModule.get(module)! - ) - ) { - continue; - } else { - assignedEntryPoints.add(entry); - } - for (const dependency of module.getDependenciesToBeIncluded()) { - if (!(dependency instanceof ExternalModule || modulesInManualChunks.has(dependency))) { - modulesToHandle.add(dependency); - } - } - } - } + const { + allEntries, + dependentEntriesByModule, + dynamicallyDependentEntriesByDynamicEntry, + dynamicImportsByEntry, + dynamicallyDependentEntriesByAwaitedDynamicEntry, + awaitedDynamicImportsByEntry + } = analyzeModuleGraph(entries); - function areEntryPointsContainedOrDynamicallyDependent( - entryPoints: Set, - containedIn: Set - ): boolean { - const entriesToCheck = new Set(entryPoints); - for (const entry of entriesToCheck) { - if (!containedIn.has(entry)) { - if (staticEntries.has(entry)) return false; - const dynamicallyDependentEntryPoints = dynamicallyDependentEntryPointsByDynamicEntry.get( - entry - )!; - for (const dependentEntry of dynamicallyDependentEntryPoints) { - entriesToCheck.add(dependentEntry); - } - } - } - return true; - } + // Each chunk is identified by its position in this array + const chunkAtoms = getChunksWithSameDependentEntries( + getModulesWithDependentEntriesAndHandleTLACycles( + dependentEntriesByModule, + modulesInManualChunks, + chunkDefinitions + ) + ); + const staticDependencyAtomsByEntry = getStaticDependencyAtomsByEntry(allEntries, chunkAtoms); + // Warning: This will consume dynamicallyDependentEntriesByDynamicEntry. + // If we no longer want this, we should make a copy here. + const alreadyLoadedAtomsByEntry = getAlreadyLoadedAtomsByEntry( + staticDependencyAtomsByEntry, + dynamicallyDependentEntriesByDynamicEntry, + dynamicImportsByEntry, + allEntries + ); + const awaitedAlreadyLoadedAtomsByEntry = getAlreadyLoadedAtomsByEntry( + staticDependencyAtomsByEntry, + dynamicallyDependentEntriesByAwaitedDynamicEntry, + awaitedDynamicImportsByEntry, + allEntries + ); + // This mutates the dependentEntries in chunkAtoms + removeUnnecessaryDependentEntries( + chunkAtoms, + alreadyLoadedAtomsByEntry, + awaitedAlreadyLoadedAtomsByEntry + ); + const { chunks, sideEffectAtoms, sizeByAtom } = + getChunksWithSameDependentEntriesAndCorrelatedAtoms( + chunkAtoms, + staticDependencyAtomsByEntry, + alreadyLoadedAtomsByEntry, + minChunkSize + ); - for (const entry of entryModules) { - if (!modulesInManualChunks.has(entry)) { - assignEntryToStaticDependencies(entry, null); - } - } + chunkDefinitions.push( + ...getOptimizedChunks(chunks, minChunkSize, sideEffectAtoms, sizeByAtom, log).map( + ({ modules }) => ({ + alias: null, + modules + }) + ) + ); + return chunkDefinitions; +} - for (const entry of dynamicEntryModules) { - if (!modulesInManualChunks.has(entry)) { - assignEntryToStaticDependencies( +function getChunkDefinitionsFromManualChunks( + manualChunkAliasByEntry: ReadonlyMap, + isManualChunksFunctionForm: boolean, + onlyExplicitManualChunks: boolean +): { chunkDefinitions: ChunkDefinitions; modulesInManualChunks: Set } { + const modulesInManualChunks = new Set(manualChunkAliasByEntry.keys()); + const manualChunkModulesByAlias: Record = Object.create(null); + const sortedEntriesWithAlias = [...manualChunkAliasByEntry].sort( + ([entryA], [entryB]) => entryA.execIndex - entryB.execIndex + ); + for (const [entry, alias] of sortedEntriesWithAlias) { + if (isManualChunksFunctionForm && onlyExplicitManualChunks) { + (manualChunkModulesByAlias[alias] ||= []).push(entry); + } else { + addStaticDependenciesToManualChunk( entry, - dynamicallyDependentEntryPointsByDynamicEntry.get(entry)! + (manualChunkModulesByAlias[alias] ||= []), + modulesInManualChunks ); } } - - chunkDefinitions.push( - ...createChunks([...entryModules, ...dynamicEntryModules], assignedEntryPointsByModule) - ); - return chunkDefinitions; + const manualChunks = Object.entries(manualChunkModulesByAlias); + const chunkDefinitions: ChunkDefinitions = new Array(manualChunks.length); + let index = 0; + for (const [alias, modules] of manualChunks) { + chunkDefinitions[index++] = { alias, modules }; + } + return { chunkDefinitions, modulesInManualChunks }; } function addStaticDependenciesToManualChunk( entry: Module, manualChunkModules: Module[], modulesInManualChunks: Set -) { +): void { const modulesToHandle = new Set([entry]); for (const module of modulesToHandle) { modulesInManualChunks.add(module); @@ -112,81 +266,703 @@ function addStaticDependenciesToManualChunk( } } -function analyzeModuleGraph( - entryModules: Module[] -): { - dependentEntryPointsByModule: DependentModuleMap; - dynamicEntryModules: Set; +function analyzeModuleGraph(entries: Iterable): { + allEntries: readonly Module[]; + dependentEntriesByModule: Map>; + dynamicImportsByEntry: readonly ReadonlySet[]; + dynamicallyDependentEntriesByDynamicEntry: Map>; + awaitedDynamicImportsByEntry: readonly ReadonlySet[]; + dynamicallyDependentEntriesByAwaitedDynamicEntry: Map>; } { const dynamicEntryModules = new Set(); - const dependentEntryPointsByModule: DependentModuleMap = new Map(); - const entriesToHandle = new Set(entryModules); - for (const currentEntry of entriesToHandle) { - const modulesToHandle = new Set([currentEntry]); - for (const module of modulesToHandle) { - getOrCreate(dependentEntryPointsByModule, module, () => new Set()).add(currentEntry); + const awaitedDynamicEntryModules = new Set(); + const dependentEntriesByModule = new Map>(); + const allEntriesSet = new Set(entries); + const dynamicImportModulesByEntry: Set[] = new Array(allEntriesSet.size); + const awaitedDynamicImportModulesByEntry: Set[] = new Array(allEntriesSet.size); + let entryIndex = 0; + for (const currentEntry of allEntriesSet) { + const dynamicImportsForCurrentEntry = new Set(); + const awaitedDynamicImportsForCurrentEntry = new Set(); + dynamicImportModulesByEntry[entryIndex] = dynamicImportsForCurrentEntry; + awaitedDynamicImportModulesByEntry[entryIndex] = awaitedDynamicImportsForCurrentEntry; + const staticDependencies = new Set([currentEntry]); + for (const module of staticDependencies) { + getOrCreate(dependentEntriesByModule, module, getNewSet).add(entryIndex); for (const dependency of module.getDependenciesToBeIncluded()) { if (!(dependency instanceof ExternalModule)) { - modulesToHandle.add(dependency); + staticDependencies.add(dependency); } } - for (const { resolution } of module.dynamicImports) { - if (resolution instanceof Module && resolution.includedDynamicImporters.length > 0) { + for (const { + node: { resolution } + } of module.dynamicImports) { + if ( + resolution instanceof Module && + resolution.includedDynamicImporters.length > 0 && + !allEntriesSet.has(resolution) + ) { dynamicEntryModules.add(resolution); - entriesToHandle.add(resolution); + allEntriesSet.add(resolution); + dynamicImportsForCurrentEntry.add(resolution); + for (const includedTopLevelAwaitingDynamicImporter of resolution.includedTopLevelAwaitingDynamicImporters) { + if (staticDependencies.has(includedTopLevelAwaitingDynamicImporter)) { + awaitedDynamicEntryModules.add(resolution); + awaitedDynamicImportsForCurrentEntry.add(resolution); + break; + } + } } } for (const dependency of module.implicitlyLoadedBefore) { - dynamicEntryModules.add(dependency); - entriesToHandle.add(dependency); + if (!allEntriesSet.has(dependency)) { + dynamicEntryModules.add(dependency); + allEntriesSet.add(dependency); + } } } + entryIndex++; + } + const allEntries = [...allEntriesSet]; + const { + awaitedDynamicEntries, + awaitedDynamicImportsByEntry, + dynamicEntries, + dynamicImportsByEntry + } = getDynamicEntries( + allEntries, + dynamicEntryModules, + dynamicImportModulesByEntry, + awaitedDynamicEntryModules, + awaitedDynamicImportModulesByEntry + ); + return { + allEntries, + awaitedDynamicImportsByEntry, + dependentEntriesByModule, + dynamicallyDependentEntriesByAwaitedDynamicEntry: getDynamicallyDependentEntriesByDynamicEntry( + dependentEntriesByModule, + awaitedDynamicEntries, + allEntries, + dynamicEntry => dynamicEntry.includedTopLevelAwaitingDynamicImporters + ), + dynamicallyDependentEntriesByDynamicEntry: getDynamicallyDependentEntriesByDynamicEntry( + dependentEntriesByModule, + dynamicEntries, + allEntries, + dynamicEntry => dynamicEntry.includedDynamicImporters + ), + dynamicImportsByEntry + }; +} + +function getDynamicEntries( + allEntries: Module[], + dynamicEntryModules: Set, + dynamicImportModulesByEntry: Set[], + awaitedDynamicEntryModules: Set, + awaitedDynamicImportModulesByEntry: Set[] +) { + const entryIndexByModule = new Map(); + const dynamicEntries = new Set(); + const awaitedDynamicEntries = new Set(); + for (const [entryIndex, entry] of allEntries.entries()) { + entryIndexByModule.set(entry, entryIndex); + if (dynamicEntryModules.has(entry)) { + dynamicEntries.add(entryIndex); + } + if (awaitedDynamicEntryModules.has(entry)) { + awaitedDynamicEntries.add(entryIndex); + } + } + const dynamicImportsByEntry = getDynamicImportsByEntry( + dynamicImportModulesByEntry, + entryIndexByModule + ); + const awaitedDynamicImportsByEntry = getDynamicImportsByEntry( + awaitedDynamicImportModulesByEntry, + entryIndexByModule + ); + return { + awaitedDynamicEntries, + awaitedDynamicImportsByEntry, + dynamicEntries, + dynamicImportsByEntry + }; +} + +function getDynamicImportsByEntry( + dynamicImportModulesByEntry: Set[], + entryIndexByModule: Map +): Set[] { + const dynamicImportsByEntry: Set[] = new Array(dynamicImportModulesByEntry.length); + let index = 0; + for (const dynamicImportModules of dynamicImportModulesByEntry) { + const dynamicImports = new Set(); + for (const dynamicEntry of dynamicImportModules) { + dynamicImports.add(entryIndexByModule.get(dynamicEntry)!); + } + dynamicImportsByEntry[index++] = dynamicImports; } - return { dependentEntryPointsByModule, dynamicEntryModules }; + return dynamicImportsByEntry; } -function getDynamicDependentEntryPoints( - dependentEntryPointsByModule: DependentModuleMap, - dynamicEntryModules: Set -): DependentModuleMap { - const dynamicallyDependentEntryPointsByDynamicEntry: DependentModuleMap = new Map(); - for (const dynamicEntry of dynamicEntryModules) { - const dynamicDependentEntryPoints = getOrCreate( - dynamicallyDependentEntryPointsByDynamicEntry, - dynamicEntry, - () => new Set() +function getDynamicallyDependentEntriesByDynamicEntry( + dependentEntriesByModule: ReadonlyMap>, + dynamicEntries: ReadonlySet, + allEntries: readonly Module[], + getDynamicImporters: (entry: Module) => Iterable +): Map> { + const dynamicallyDependentEntriesByDynamicEntry = new Map>(); + for (const dynamicEntryIndex of dynamicEntries) { + const dynamicallyDependentEntries = getOrCreate( + dynamicallyDependentEntriesByDynamicEntry, + dynamicEntryIndex, + getNewSet ); - for (const importer of [ - ...dynamicEntry.includedDynamicImporters, - ...dynamicEntry.implicitlyLoadedAfter - ]) { - for (const entryPoint of dependentEntryPointsByModule.get(importer)!) { - dynamicDependentEntryPoints.add(entryPoint); + const dynamicEntry = allEntries[dynamicEntryIndex]; + for (const importer of concatLazy([ + getDynamicImporters(dynamicEntry), + dynamicEntry.implicitlyLoadedAfter + ])) { + for (const entry of dependentEntriesByModule.get(importer)!) { + dynamicallyDependentEntries.add(entry); } } } - return dynamicallyDependentEntryPointsByDynamicEntry; + return dynamicallyDependentEntriesByDynamicEntry; } -function createChunks( - allEntryPoints: Module[], - assignedEntryPointsByModule: DependentModuleMap -): ChunkDefinitions { - const chunkModules: { [chunkSignature: string]: Module[] } = Object.create(null); - for (const [module, assignedEntryPoints] of assignedEntryPointsByModule) { - let chunkSignature = ''; - for (const entry of allEntryPoints) { - chunkSignature += assignedEntryPoints.has(entry) ? 'X' : '_'; - } - const chunk = chunkModules[chunkSignature]; - if (chunk) { - chunk.push(module); - } else { - chunkModules[chunkSignature] = [module]; +function getChunksWithSameDependentEntries( + modulesWithDependentEntries: Iterable +): ModulesWithDependentEntries[] { + const chunkModules: Record = Object.create(null); + for (const { dependentEntries, modules } of modulesWithDependentEntries) { + let chunkSignature = 0n; + for (const entryIndex of dependentEntries) { + chunkSignature |= 1n << BigInt(entryIndex); + } + (chunkModules[String(chunkSignature)] ||= { + dependentEntries: new Set(dependentEntries), + modules: [] + }).modules.push(...modules); + } + return Object.values(chunkModules); +} + +function* getModulesWithDependentEntriesAndHandleTLACycles( + dependentEntriesByModule: Map>, + modulesInManualChunks: Set, + chunkDefinitions: ChunkDefinitions +) { + for (const [module, dependentEntries] of dependentEntriesByModule) { + if (!modulesInManualChunks.has(module)) { + if (module.cycles.size > 0 && module.includedTopLevelAwaitingDynamicImporters.size > 0) { + chunkDefinitions.push({ + alias: null, + modules: [module] + }); + continue; + } + yield { dependentEntries, modules: [module] }; + } + } +} + +function getStaticDependencyAtomsByEntry( + allEntries: readonly Module[], + chunkAtoms: ModulesWithDependentEntries[] +) { + // The indices correspond to the indices in allEntries. The atoms correspond + // to bits in the bigint values where chunk 0 is the lowest bit. + const staticDependencyAtomsByEntry: bigint[] = allEntries.map(() => 0n); + + // This toggles the bits for each atom that is a dependency of an entry + let atomMask = 1n; + for (const { dependentEntries } of chunkAtoms) { + for (const entryIndex of dependentEntries) { + staticDependencyAtomsByEntry[entryIndex] |= atomMask; + } + atomMask <<= 1n; + } + return staticDependencyAtomsByEntry; +} + +// Warning: This will consume dynamicallyDependentEntriesByDynamicEntry. +function getAlreadyLoadedAtomsByEntry( + staticDependencyAtomsByEntry: bigint[], + dynamicallyDependentEntriesByDynamicEntry: Map>, + dynamicImportsByEntry: readonly ReadonlySet[], + allEntries: readonly Module[] +) { + // Dynamic entries have all atoms as already loaded initially because we then + // intersect with the static dependency atoms of all dynamic importers. + // Static entries cannot have already loaded atoms. + const alreadyLoadedAtomsByEntry: bigint[] = allEntries.map((_entry, entryIndex) => + dynamicallyDependentEntriesByDynamicEntry.has(entryIndex) ? -1n : 0n + ); + for (const [ + dynamicEntryIndex, + dynamicallyDependentEntries + ] of dynamicallyDependentEntriesByDynamicEntry) { + // We delete here so that they can be added again if necessary to be handled + // again by the loop + dynamicallyDependentEntriesByDynamicEntry.delete(dynamicEntryIndex); + const knownLoadedAtoms = alreadyLoadedAtomsByEntry[dynamicEntryIndex]; + let updatedLoadedAtoms = knownLoadedAtoms; + for (const entryIndex of dynamicallyDependentEntries) { + updatedLoadedAtoms &= + staticDependencyAtomsByEntry[entryIndex] | alreadyLoadedAtomsByEntry[entryIndex]; + } + // If the knownLoadedAtoms changed, all dependent dynamic entries need to be + // updated again + if (updatedLoadedAtoms !== knownLoadedAtoms) { + alreadyLoadedAtomsByEntry[dynamicEntryIndex] = updatedLoadedAtoms; + for (const dynamicImport of dynamicImportsByEntry[dynamicEntryIndex]) { + // If this adds an entry that was deleted before, it will be handled + // again. This is the reason why we delete every entry from this map + // that we processed. + getOrCreate( + dynamicallyDependentEntriesByDynamicEntry, + dynamicImport, + getNewSet + ).add(dynamicEntryIndex); + } + } + } + return alreadyLoadedAtomsByEntry; +} + +/** + * This removes all unnecessary dynamic entries from the dependentEntries in its + * first argument if a chunk is already loaded without that entry. + */ +function removeUnnecessaryDependentEntries( + chunkAtoms: ModulesWithDependentEntries[], + alreadyLoadedAtomsByEntry: bigint[], + awaitedAlreadyLoadedAtomsByEntry: bigint[] +) { + // Remove entries from dependent entries if a chunk is already loaded without + // that entry. Do not remove already loaded atoms where some dynamic imports + // are awaited to avoid cycles in the output. + let chunkMask = 1n; + for (const { dependentEntries } of chunkAtoms) { + for (const entryIndex of dependentEntries) { + if ( + (alreadyLoadedAtomsByEntry[entryIndex] & chunkMask) === chunkMask && + (awaitedAlreadyLoadedAtomsByEntry[entryIndex] & chunkMask) === 0n + ) { + dependentEntries.delete(entryIndex); + } + } + chunkMask <<= 1n; + } +} + +function getChunksWithSameDependentEntriesAndCorrelatedAtoms( + chunkAtoms: ModulesWithDependentEntries[], + staticDependencyAtomsByEntry: bigint[], + alreadyLoadedAtomsByEntry: bigint[], + minChunkSize: number +) { + const chunksBySignature: Record = Object.create(null); + const chunkByModule = new Map(); + const sizeByAtom: number[] = new Array(chunkAtoms.length); + let sideEffectAtoms = 0n; + let atomMask = 1n; + let index = 0; + for (const { dependentEntries, modules } of chunkAtoms) { + let chunkSignature = 0n; + let correlatedAtoms = -1n; + for (const entryIndex of dependentEntries) { + chunkSignature |= 1n << BigInt(entryIndex); + // Correlated atoms are the atoms that are guaranteed to be loaded as + // well when a given atom is loaded. It is the intersection of the already + // loaded modules of each chunk merged with its static dependencies. + correlatedAtoms &= + staticDependencyAtomsByEntry[entryIndex] | alreadyLoadedAtomsByEntry[entryIndex]; + } + const chunk = (chunksBySignature[String(chunkSignature)] ||= { + containedAtoms: 0n, + correlatedAtoms, + dependencies: new Set(), + dependentChunks: new Set(), + dependentEntries: new Set(dependentEntries), + modules: [], + pure: true, + size: 0 + }); + + let atomSize = 0; + let pure = true; + for (const module of modules) { + chunkByModule.set(module, chunk); + // Unfortunately, we cannot take tree-shaking into account here because + // rendering did not happen yet, but we can detect empty modules + if (module.isIncluded()) { + pure &&= !module.hasEffects(); + // we use a trivial size for the default minChunkSize to improve + // performance + atomSize += minChunkSize > 1 ? module.estimateSize() : 1; + } + } + if (!pure) { + sideEffectAtoms |= atomMask; + } + sizeByAtom[index++] = atomSize; + + chunk.containedAtoms |= atomMask; + chunk.modules.push(...modules); + chunk.pure &&= pure; + chunk.size += atomSize; + atomMask <<= 1n; + } + const chunks = Object.values(chunksBySignature); + sideEffectAtoms |= addChunkDependenciesAndGetExternalSideEffectAtoms( + chunks, + chunkByModule, + atomMask + ); + return { chunks, sideEffectAtoms, sizeByAtom }; +} + +function addChunkDependenciesAndGetExternalSideEffectAtoms( + chunks: ChunkDescription[], + chunkByModule: Map, + nextAvailableAtomMask: bigint +): bigint { + const signatureByExternalModule = new Map(); + let externalSideEffectAtoms = 0n; + for (const chunk of chunks) { + const { dependencies, modules } = chunk; + for (const module of modules) { + for (const dependency of module.getDependenciesToBeIncluded()) { + if (dependency instanceof ExternalModule) { + if (dependency.info.moduleSideEffects) { + const signature = getOrCreate(signatureByExternalModule, dependency, () => { + const signature = nextAvailableAtomMask; + nextAvailableAtomMask <<= 1n; + externalSideEffectAtoms |= signature; + return signature; + }); + chunk.containedAtoms |= signature; + chunk.correlatedAtoms |= signature; + } + } else { + const dependencyChunk = chunkByModule.get(dependency); + if (dependencyChunk && dependencyChunk !== chunk) { + dependencies.add(dependencyChunk); + dependencyChunk.dependentChunks.add(chunk); + } + } + } + } + } + return externalSideEffectAtoms; +} + +/** + * This function tries to get rid of small chunks by merging them with other + * chunks. + * + * We can only merge chunks safely if after the merge, loading any entry point + * in any allowed order will not trigger side effects that should not have been + * triggered. While side effects are usually things like global function calls, + * global variable mutations or potentially thrown errors, details do not + * matter here, and we just discern chunks without side effects (pure chunks) + * from other chunks. + * + * As a first step, we assign each pre-generated chunk with side effects a + * label. I.e. we have side effect "A" if the non-pure chunk "A" is loaded. + * + * Now to determine the side effects of loading a chunk, one also has to take + * the side effects of its dependencies into account. So if A depends on B + * (A -> B) and both have side effects, loading A triggers effects AB. + * + * Now from the previous step we know that each chunk is uniquely determine by + * the entry points that depend on it and cause it to load, which we will call + * its dependent entry points. + * + * E.g. if X -> A and Y -> A, then the dependent entry points of A are XY. + * Starting from that idea, we can determine a set of chunks—and thus a set + * of side effects—that must have been triggered if a certain chunk has been + * loaded. Basically, it is the intersection of all chunks loaded by the + * dependent entry points of a given chunk. We call the corresponding side + * effects the correlated side effects of that chunk. + * + * Example: + * X -> ABC, Y -> ADE, A-> F, B -> D + * Then taking dependencies into account, X -> ABCDF, Y -> ADEF + * The intersection is ADF. So we know that when A is loaded, D and F must also + * be in memory even though neither D nor A is a dependency of the other. + * If all have side effects, we call ADF the correlated side effects of A. The + * correlated side effects need to remain constant when merging chunks. + * + * In contrast, we have the dependency side effects of A, which represents + * the side effects we trigger if we directly load A. In this example, the + * dependency side effects are AF. + * For entry chunks, dependency and correlated side effects are the same. + * + * With these concepts, merging chunks is allowed if the correlated side + * effects of each entry do not change. Thus, we are allowed to merge two + * chunks if + * + * a) the dependency side effects of each chunk are a subset of the correlated + * side effects of the other chunk, so no additional side effects are + * triggered for any entry, or + * b) The dependent entry points of chunk A are a subset of the dependent entry + * points of chunk B while the dependency side effects of A are a subset of + * the correlated side effects of B. Because in that scenario, whenever A is + * loaded, B is loaded as well. But there are cases when B is loaded where A + * is not loaded. So if we merge the chunks, all dependency side effects of + * A will be added to the correlated side effects of B, and as the latter is + * not allowed to change, the former need to be a subset of the latter. + * + * Another consideration when merging small chunks into other chunks is to + * avoid + * that too much additional code is loaded. This is achieved when the dependent + * entries of the small chunk are a subset of the dependent entries of the + * other + * chunk. Because then when the small chunk is loaded, the other chunk was + * loaded/in memory anyway, so at most when the other chunk is loaded, the + * additional size of the small chunk is loaded unnecessarily. + * + * So the algorithm performs merges in two passes: + * + * 1. First we try to merge small chunks A only into other chunks B if the + * dependent entries of A are a subset of the dependent entries of B and the + * dependency side effects of A are a subset of the correlated side effects + * of B. + * 2. Only then for all remaining small chunks, we look for arbitrary merges + * following the rule (a), starting with the smallest chunks to look for + * possible merge targets. + */ +function getOptimizedChunks( + chunks: ChunkDescription[], + minChunkSize: number, + sideEffectAtoms: bigint, + sizeByAtom: number[], + log: LogHandler +): { modules: Module[] }[] { + timeStart('optimize chunks', 3); + const chunkPartition = getPartitionedChunks(chunks, minChunkSize); + if (!chunkPartition) { + timeEnd('optimize chunks', 3); + return chunks; // the actual modules + } + if (minChunkSize > 1) { + log('info', logOptimizeChunkStatus(chunks.length, chunkPartition.small.size, 'Initially')); + } + mergeChunks(chunkPartition, minChunkSize, sideEffectAtoms, sizeByAtom); + if (minChunkSize > 1) { + log( + 'info', + logOptimizeChunkStatus( + chunkPartition.small.size + chunkPartition.big.size, + chunkPartition.small.size, + 'After merging chunks' + ) + ); + } + timeEnd('optimize chunks', 3); + return [...chunkPartition.small, ...chunkPartition.big]; +} + +function getPartitionedChunks( + chunks: ChunkDescription[], + minChunkSize: number +): ChunkPartition | null { + const smallChunks: ChunkDescription[] = []; + const bigChunks: ChunkDescription[] = []; + for (const chunk of chunks) { + (chunk.size < minChunkSize ? smallChunks : bigChunks).push(chunk); + } + if (smallChunks.length === 0) { + return null; + } + smallChunks.sort(compareChunkSize); + bigChunks.sort(compareChunkSize); + return { + big: new Set(bigChunks), + small: new Set(smallChunks) + }; +} + +function compareChunkSize( + { size: sizeA }: ChunkDescription, + { size: sizeB }: ChunkDescription +): number { + return sizeA - sizeB; +} + +function mergeChunks( + chunkPartition: ChunkPartition, + minChunkSize: number, + sideEffectAtoms: bigint, + sizeByAtom: number[] +) { + const { small } = chunkPartition; + for (const mergedChunk of small) { + const bestTargetChunk = findBestMergeTarget( + mergedChunk, + chunkPartition, + sideEffectAtoms, + sizeByAtom, + // In the default case, we do not accept size increases + minChunkSize <= 1 ? 1 : Infinity + ); + if (bestTargetChunk) { + const { containedAtoms, correlatedAtoms, modules, pure, size } = mergedChunk; + small.delete(mergedChunk); + getChunksInPartition(bestTargetChunk, minChunkSize, chunkPartition).delete(bestTargetChunk); + bestTargetChunk.modules.push(...modules); + bestTargetChunk.size += size; + bestTargetChunk.pure &&= pure; + const { dependencies, dependentChunks, dependentEntries } = bestTargetChunk; + bestTargetChunk.correlatedAtoms &= correlatedAtoms; + bestTargetChunk.containedAtoms |= containedAtoms; + for (const entry of mergedChunk.dependentEntries) { + dependentEntries.add(entry); + } + for (const dependency of mergedChunk.dependencies) { + dependencies.add(dependency); + dependency.dependentChunks.delete(mergedChunk); + dependency.dependentChunks.add(bestTargetChunk); + } + for (const dependentChunk of mergedChunk.dependentChunks) { + dependentChunks.add(dependentChunk); + dependentChunk.dependencies.delete(mergedChunk); + dependentChunk.dependencies.add(bestTargetChunk); + } + dependencies.delete(bestTargetChunk); + dependentChunks.delete(bestTargetChunk); + getChunksInPartition(bestTargetChunk, minChunkSize, chunkPartition).add(bestTargetChunk); + } + } +} + +function findBestMergeTarget( + mergedChunk: ChunkDescription, + { big, small }: ChunkPartition, + sideEffectAtoms: bigint, + sizeByAtom: number[], + smallestAdditionalSize: number +): ChunkDescription | null { + let bestTargetChunk: ChunkDescription | null = null; + // In the default case, we do not accept size increases + for (const targetChunk of concatLazy([small, big])) { + if (mergedChunk === targetChunk) continue; + const additionalSizeAfterMerge = getAdditionalSizeAfterMerge( + mergedChunk, + targetChunk, + smallestAdditionalSize, + sideEffectAtoms, + sizeByAtom + ); + if (additionalSizeAfterMerge < smallestAdditionalSize) { + bestTargetChunk = targetChunk; + if (additionalSizeAfterMerge === 0) break; + smallestAdditionalSize = additionalSizeAfterMerge; } } - return Object.keys(chunkModules).map(chunkSignature => ({ - alias: null, - modules: chunkModules[chunkSignature] - })); + return bestTargetChunk; +} + +/** + * Determine the additional unused code size that would be added by merging the + * two chunks. This is not an exact measurement but rather an upper bound. If + * the merge produces cycles or adds non-correlated side effects, `Infinity` + * is returned. + * Merging will not produce cycles if none of the direct non-merged + * dependencies of a chunk have the other chunk as a transitive dependency. + */ +function getAdditionalSizeAfterMerge( + mergedChunk: ChunkDescription, + targetChunk: ChunkDescription, + // The maximum additional unused code size allowed to be added by the merge, + // taking dependencies into account, needs to be below this number + currentAdditionalSize: number, + sideEffectAtoms: bigint, + sizeByAtom: number[] +): number { + const firstSize = getAdditionalSizeIfNoTransitiveDependencyOrNonCorrelatedSideEffect( + mergedChunk, + targetChunk, + currentAdditionalSize, + sideEffectAtoms, + sizeByAtom + ); + return firstSize < currentAdditionalSize + ? firstSize + + getAdditionalSizeIfNoTransitiveDependencyOrNonCorrelatedSideEffect( + targetChunk, + mergedChunk, + currentAdditionalSize - firstSize, + sideEffectAtoms, + sizeByAtom + ) + : Infinity; +} + +function getAdditionalSizeIfNoTransitiveDependencyOrNonCorrelatedSideEffect( + dependentChunk: ChunkDescription, + dependencyChunk: ChunkDescription, + currentAdditionalSize: number, + sideEffectAtoms: bigint, + sizeByAtom: number[] +): number { + const { correlatedAtoms } = dependencyChunk; + let dependencyAtoms = dependentChunk.containedAtoms; + const dependentContainedSideEffects = dependencyAtoms & sideEffectAtoms; + if ((correlatedAtoms & dependentContainedSideEffects) !== dependentContainedSideEffects) { + return Infinity; + } + const chunksToCheck = new Set(dependentChunk.dependencies); + for (const { dependencies, containedAtoms } of chunksToCheck) { + dependencyAtoms |= containedAtoms; + const containedSideEffects = containedAtoms & sideEffectAtoms; + if ((correlatedAtoms & containedSideEffects) !== containedSideEffects) { + return Infinity; + } + for (const dependency of dependencies) { + if (dependency === dependencyChunk) { + return Infinity; + } + chunksToCheck.add(dependency); + } + } + return getAtomsSizeIfBelowLimit( + dependencyAtoms & ~correlatedAtoms, + currentAdditionalSize, + sizeByAtom + ); +} + +function getAtomsSizeIfBelowLimit( + atoms: bigint, + currentAdditionalSize: number, + sizeByAtom: number[] +): number { + let size = 0; + let atomIndex = 0; + let atomSignature = 1n; + const { length } = sizeByAtom; + for (; atomIndex < length; atomIndex++) { + if ((atoms & atomSignature) === atomSignature) { + size += sizeByAtom[atomIndex]; + } + atomSignature <<= 1n; + if (size >= currentAdditionalSize) { + return Infinity; + } + } + return size; +} + +function getChunksInPartition( + chunk: ChunkDescription, + minChunkSize: number, + chunkPartition: ChunkPartition +): Set { + return chunk.size < minChunkSize ? chunkPartition.small : chunkPartition.big; } diff --git a/src/utils/collapseSourcemaps.ts b/src/utils/collapseSourcemaps.ts index 8ae6238f61c..21cd18f6e34 100644 --- a/src/utils/collapseSourcemaps.ts +++ b/src/utils/collapseSourcemaps.ts @@ -1,27 +1,28 @@ -import { DecodedSourceMap, SourceMap } from 'magic-string'; -import Module from '../Module'; -import { +import { type DecodedSourceMap, SourceMap } from 'magic-string'; +import type Module from '../Module'; +import type { DecodedSourceMapOrMissing, ExistingDecodedSourceMap, - SourceMapSegment, - WarningHandler + LogHandler, + SourceMapSegment } from '../rollup/types'; -import { error } from './error'; +import { decodedSourcemap, resetSourcemapCache } from './decodedSourcemap'; +import { LOGLEVEL_WARN } from './logging'; +import { error, logConflictingSourcemapSources, logSourcemapBroken } from './logs'; import { basename, dirname, relative, resolve } from './path'; class Source { - content: string; - filename: string; - isOriginal: boolean; + readonly content: string; + readonly filename: string; + isOriginal = true; constructor(filename: string, content: string) { - this.isOriginal = true; this.filename = filename; this.content = content; } traceSegment(line: number, column: number, name: string): SourceMapSegmentObject { - return { line, column, name, source: this }; + return { column, line, name, source: this }; } } @@ -33,12 +34,12 @@ interface SourceMapSegmentObject { } class Link { - mappings: SourceMapSegment[][]; - names: string[]; - sources: (Source | Link)[]; + readonly mappings: readonly SourceMapSegment[][]; + readonly names: readonly string[]; + readonly sources: (Source | Link)[]; constructor( - map: { mappings: SourceMapSegment[][]; names: string[] }, + map: { mappings: readonly SourceMapSegment[][]; names: readonly string[] }, sources: (Source | Link)[] ) { this.sources = sources; @@ -48,8 +49,10 @@ class Link { traceMappings() { const sources: string[] = []; + const sourceIndexMap = new Map(); const sourcesContent: string[] = []; const names: string[] = []; + const nameIndexMap = new Map(); const mappings = []; @@ -57,7 +60,7 @@ class Link { const tracedLine: SourceMapSegment[] = []; for (const segment of line) { - if (segment.length == 1) continue; + if (segment.length === 1) continue; const source = this.sources[segment[1]]; if (!source) continue; @@ -68,35 +71,32 @@ class Link { ); if (traced) { - // newer sources are more likely to be used, so search backwards. - let sourceIndex = sources.lastIndexOf(traced.source.filename); - if (sourceIndex === -1) { + const { + column, + line, + name, + source: { content, filename } + } = traced; + let sourceIndex = sourceIndexMap.get(filename); + if (sourceIndex === undefined) { sourceIndex = sources.length; - sources.push(traced.source.filename); - sourcesContent[sourceIndex] = traced.source.content; + sources.push(filename); + sourceIndexMap.set(filename, sourceIndex); + sourcesContent[sourceIndex] = content; } else if (sourcesContent[sourceIndex] == null) { - sourcesContent[sourceIndex] = traced.source.content; - } else if ( - traced.source.content != null && - sourcesContent[sourceIndex] !== traced.source.content - ) { - return error({ - message: `Multiple conflicting contents for sourcemap source ${traced.source.filename}` - }); + sourcesContent[sourceIndex] = content; + } else if (content != null && sourcesContent[sourceIndex] !== content) { + return error(logConflictingSourcemapSources(filename)); } - const tracedSegment: SourceMapSegment = [ - segment[0], - sourceIndex, - traced.line, - traced.column - ]; + const tracedSegment: SourceMapSegment = [segment[0], sourceIndex, line, column]; - if (traced.name) { - let nameIndex = names.indexOf(traced.name); - if (nameIndex === -1) { + if (name) { + let nameIndex = nameIndexMap.get(name); + if (nameIndex === undefined) { nameIndex = names.length; - names.push(traced.name); + names.push(name); + nameIndexMap.set(name, nameIndex); } (tracedSegment as SourceMapSegment)[4] = nameIndex; @@ -109,7 +109,7 @@ class Link { mappings.push(tracedLine); } - return { sources, sourcesContent, names, mappings }; + return { mappings, names, sources, sourcesContent }; } traceSegment(line: number, column: number, name: string): SourceMapSegmentObject | null { @@ -117,13 +117,24 @@ class Link { if (!segments) return null; // binary search through segments for the given column - let i = 0; - let j = segments.length - 1; - - while (i <= j) { - const m = (i + j) >> 1; - const segment = segments[m]; - if (segment[0] === column) { + let searchStart = 0; + const lastSegmentIndex = segments.length - 1; + let searchEnd = lastSegmentIndex; + + while (searchStart <= searchEnd) { + const m = (searchStart + searchEnd) >> 1; + let segment = segments[m]; + + // If a sourcemap does not have sufficient resolution to contain a + // necessary mapping, e.g. because it only contains line information or + // the column is not precise (e.g. the sourcemap is generated by esbuild, segment[0] may be shorter than the location of the first letter), + // we approximate by finding the closest segment whose segment[0] is less than the given column + if (segment[0] !== column && searchStart === searchEnd) { + const approximatedSegmentIndex = + segments[searchStart][0] > column ? Math.max(0, searchStart - 1) : searchStart; + segment = segments[approximatedSegmentIndex]; + } + if (segment[0] === column || searchStart === searchEnd) { if (segment.length == 1) return null; const source = this.sources[segment[1]]; if (!source) return null; @@ -135,9 +146,9 @@ class Link { ); } if (segment[0] > column) { - j = m - 1; + searchEnd = m - 1; } else { - i = m + 1; + searchStart = m + 1; } } @@ -145,21 +156,13 @@ class Link { } } -function getLinkMap(warn: WarningHandler) { - return function linkMap(source: Source | Link, map: DecodedSourceMapOrMissing) { - if (map.mappings) { +function getLinkMap(log: LogHandler) { + return function linkMap(source: Source | Link, map: DecodedSourceMapOrMissing): Link { + if (!map.missing) { return new Link(map, [source]); } - warn({ - code: 'SOURCEMAP_BROKEN', - message: - `Sourcemap is likely to be incorrect: a plugin (${map.plugin}) was used to transform ` + - "files, but didn't generate a sourcemap for the transformation. Consult the plugin " + - 'documentation for help', - plugin: map.plugin, - url: `https://rollupjs.org/guide/en/#warning-sourcemap-is-likely-to-be-incorrect` - }); + log(LOGLEVEL_WARN, logSourcemapBroken(map.plugin)); return new Link( { @@ -175,36 +178,36 @@ function getCollapsedSourcemap( id: string, originalCode: string, originalSourcemap: ExistingDecodedSourceMap | null, - sourcemapChain: DecodedSourceMapOrMissing[], + sourcemapChain: readonly DecodedSourceMapOrMissing[], linkMap: (source: Source | Link, map: DecodedSourceMapOrMissing) => Link ): Source | Link { let source: Source | Link; - if (!originalSourcemap) { - source = new Source(id, originalCode); - } else { + if (originalSourcemap) { const sources = originalSourcemap.sources; const sourcesContent = originalSourcemap.sourcesContent || []; const directory = dirname(id) || '.'; const sourceRoot = originalSourcemap.sourceRoot || '.'; const baseSources = sources.map( - (source, i) => new Source(resolve(directory, sourceRoot, source), sourcesContent[i]) + (source, index) => new Source(resolve(directory, sourceRoot, source), sourcesContent[index]) ); source = new Link(originalSourcemap, baseSources); + } else { + source = new Source(id, originalCode); } return sourcemapChain.reduce(linkMap, source); } export function collapseSourcemaps( file: string, - map: DecodedSourceMap, - modules: Module[], - bundleSourcemapChain: DecodedSourceMapOrMissing[], + map: Omit & { sourcesContent: (string | null)[] }, + modules: readonly Module[], + bundleSourcemapChain: readonly DecodedSourceMapOrMissing[], excludeContent: boolean | undefined, - warn: WarningHandler -) { - const linkMap = getLinkMap(warn); + log: LogHandler +): SourceMap { + const linkMap = getLinkMap(log); const moduleSources = modules .filter(module => !module.excludeFromSourcemap) .map(module => @@ -217,12 +220,8 @@ export function collapseSourcemaps( ) ); - // DecodedSourceMap (from magic-string) uses a number[] instead of the more - // correct SourceMapSegment tuples. Cast it here to gain type safety. - let source = new Link(map as ExistingDecodedSourceMap, moduleSources); - - source = bundleSourcemapChain.reduce(linkMap, source); - + const link = new Link(map, moduleSources); + const source = bundleSourcemapChain.reduce(linkMap, link); let { sources, sourcesContent, names, mappings } = source.traceMappings(); if (file) { @@ -231,19 +230,27 @@ export function collapseSourcemaps( file = basename(file); } - sourcesContent = (excludeContent ? null : sourcesContent) as string[]; + for (const module of modules) { + resetSourcemapCache(module.originalSourcemap, module.sourcemapChain); + } - return new SourceMap({ file, sources, sourcesContent, names, mappings }); + return new SourceMap({ + file, + mappings, + names, + sources, + sourcesContent: excludeContent ? undefined : sourcesContent + }); } export function collapseSourcemap( id: string, originalCode: string, originalSourcemap: ExistingDecodedSourceMap | null, - sourcemapChain: DecodedSourceMapOrMissing[], - warn: WarningHandler + sourcemapChain: readonly DecodedSourceMapOrMissing[], + log: LogHandler ): ExistingDecodedSourceMap | null { - if (!sourcemapChain.length) { + if (sourcemapChain.length === 0) { return originalSourcemap; } @@ -252,8 +259,8 @@ export function collapseSourcemap( originalCode, originalSourcemap, sourcemapChain, - getLinkMap(warn) + getLinkMap(log) ) as Link; const map = source.traceMappings(); - return { version: 3, ...map }; + return decodedSourcemap({ version: 3, ...map }); } diff --git a/src/utils/colors.ts b/src/utils/colors.ts new file mode 100644 index 00000000000..54413d5ae8a --- /dev/null +++ b/src/utils/colors.ts @@ -0,0 +1,8 @@ +import { env } from 'node:process'; +import pc from 'picocolors'; + +// @see https://no-color.org +// @see https://www.npmjs.com/package/chalk +export const { bold, cyan, dim, gray, green, red, underline, yellow } = pc.createColors( + env.FORCE_COLOR !== '0' && !env.NO_COLOR +); diff --git a/src/utils/commondir.ts b/src/utils/commondir.ts index b4245f8fb00..cb2e30c6855 100644 --- a/src/utils/commondir.ts +++ b/src/utils/commondir.ts @@ -1,20 +1,23 @@ -import * as path from './path'; +import { dirname } from './path'; // ported from https://github.com/substack/node-commondir -export default function commondir(files: string[]) { +export default function commondir(files: readonly string[]): string { if (files.length === 0) return '/'; - if (files.length === 1) return path.dirname(files[0]); - const commonSegments = files.slice(1).reduce((commonSegments, file) => { - const pathSegements = file.split(/\/+|\\+/); - let i; - for ( - i = 0; - commonSegments[i] === pathSegements[i] && - i < Math.min(commonSegments.length, pathSegements.length); - i++ - ); - return commonSegments.slice(0, i); - }, files[0].split(/\/+|\\+/)); + if (files.length === 1) return dirname(files[0]); + const commonSegments = files.slice(1).reduce( + (commonSegments, file) => { + const pathSegments = file.split(/\/+|\\+/); + let index; + for ( + index = 0; + commonSegments[index] === pathSegments[index] && + index < Math.min(commonSegments.length, pathSegments.length); + index++ + ); + return commonSegments.slice(0, index); + }, + files[0].split(/\/+|\\+/) + ); // Windows correctly handles paths with forward-slashes return commonSegments.length > 1 ? commonSegments.join('/') : '/'; diff --git a/src/utils/convert-ast-strings.ts b/src/utils/convert-ast-strings.ts new file mode 100644 index 00000000000..ad2da5d2bb6 --- /dev/null +++ b/src/utils/convert-ast-strings.ts @@ -0,0 +1,68 @@ +// This file is generated by scripts/generate-string-constants.js. +// Do not edit this file directly. + +export default [ + 'var', + 'let', + 'const', + 'init', + 'get', + 'set', + 'constructor', + 'method', + '-', + '+', + '!', + '~', + 'typeof', + 'void', + 'delete', + '++', + '--', + '==', + '!=', + '===', + '!==', + '<', + '<=', + '>', + '>=', + '<<', + '>>', + '>>>', + '+', + '-', + '*', + '/', + '%', + '|', + '^', + '&', + '||', + '&&', + 'in', + 'instanceof', + '**', + '??', + '=', + '+=', + '-=', + '*=', + '/=', + '%=', + '<<=', + '>>=', + '>>>=', + '|=', + '^=', + '&=', + '**=', + '&&=', + '||=', + '??=', + 'pure', + 'noSideEffects', + 'sourcemap', + 'using', + 'await using' +]; diff --git a/src/utils/crypto.ts b/src/utils/crypto.ts index 310c9a9922e..066d0847c77 100644 --- a/src/utils/crypto.ts +++ b/src/utils/crypto.ts @@ -1,3 +1,27 @@ -import { createHash as cryptoCreateHash } from 'crypto'; +import { xxhashBase16, xxhashBase36, xxhashBase64Url } from '../../native'; +import type { HashCharacters } from '../rollup/types'; -export const createHash = () => cryptoCreateHash('sha256'); +let textEncoder: TextEncoder; + +export type GetHash = (input: string | Uint8Array) => string; + +export const getHash64: GetHash = input => xxhashBase64Url(ensureBuffer(input)); +export const getHash36: GetHash = input => xxhashBase36(ensureBuffer(input)); +export const getHash16: GetHash = input => xxhashBase16(ensureBuffer(input)); + +export const hasherByType: Record = { + base36: getHash36, + base64: getHash64, + hex: getHash16 +}; + +function ensureBuffer(input: string | Uint8Array): Uint8Array { + if (typeof input === 'string') { + if (typeof Buffer === 'undefined') { + textEncoder ??= new TextEncoder(); + return textEncoder.encode(input); + } + return Buffer.from(input); + } + return input; +} diff --git a/src/utils/decodedSourcemap.ts b/src/utils/decodedSourcemap.ts index 3b4acfcf6a4..dc4ce9402ec 100644 --- a/src/utils/decodedSourcemap.ts +++ b/src/utils/decodedSourcemap.ts @@ -1,15 +1,71 @@ -import { decode } from 'sourcemap-codec'; -import { ExistingDecodedSourceMap, ExistingRawSourceMap, SourceMapInput } from '../rollup/types'; +import { decode, encode } from '@jridgewell/sourcemap-codec'; +import type { + DecodedSourceMapOrMissing, + ExistingDecodedSourceMap, + ExistingRawSourceMap, + SourceMapInput +} from '../rollup/types'; -type Input = SourceMapInput | ExistingDecodedSourceMap | undefined; +// While the types for SourceMapInput are what we expect to recieve from plugins, there are cases +// in the wild where plugins return `{mappings: null}`, so we want this function to be a little more +// permissive on the input end so that we can normalize the output when creating the decoded sourcemap. +interface UnexpectedInput { + mappings: null | undefined; +} + +type Input = SourceMapInput | UnexpectedInput | ExistingDecodedSourceMap | undefined; + +interface CachedSourcemapData { + encodedMappings: string | undefined; + decodedMappings: ExistingDecodedSourceMap['mappings'] | undefined; +} + +const sourceMapCache = new WeakMap(); + +/** + * This clears the decoded array and falls back to the encoded string form. + * Sourcemap mappings arrays can be very large and holding on to them for longer + * than is necessary leads to poor heap utilization. + */ +function resetCacheToEncoded(cache: CachedSourcemapData) { + if (cache.encodedMappings === undefined && cache.decodedMappings) { + cache.encodedMappings = encode(cache.decodedMappings); + } + cache.decodedMappings = undefined; +} + +export function resetSourcemapCache( + map: ExistingDecodedSourceMap | null, + sourcemapChain?: DecodedSourceMapOrMissing[] +) { + if (map) { + const cache = sourceMapCache.get(map); + if (cache) { + resetCacheToEncoded(cache); + } + } + if (!sourcemapChain) { + return; + } + + for (const map of sourcemapChain) { + if (map.missing) continue; + + resetSourcemapCache(map); + } +} + +export function decodedSourcemap(map: null | undefined): null; +export function decodedSourcemap(map: Exclude): ExistingDecodedSourceMap; +export function decodedSourcemap(map: Input): ExistingDecodedSourceMap | null; export function decodedSourcemap(map: Input): ExistingDecodedSourceMap | null { if (!map) return null; if (typeof map === 'string') { map = JSON.parse(map) as ExistingRawSourceMap; } - if (map.mappings === '') { + if (!map.mappings) { return { mappings: [], names: [], @@ -18,12 +74,33 @@ export function decodedSourcemap(map: Input): ExistingDecodedSourceMap | null { }; } - let mappings; - if (typeof map.mappings === 'string') { - mappings = decode(map.mappings); - } else { - mappings = map.mappings; - } + const originalMappings = map.mappings; + const isAlreadyDecoded = Array.isArray(originalMappings); + const cache: CachedSourcemapData = { + decodedMappings: isAlreadyDecoded ? originalMappings : undefined, + encodedMappings: isAlreadyDecoded ? undefined : originalMappings + }; + + const decodedMap = { + ...(map as ExistingRawSourceMap | ExistingDecodedSourceMap), + // By moving mappings behind an accessor, we can avoid unneeded computation for cases + // where the mappings field is never actually accessed. This appears to greatly reduce + // the overhead of sourcemap decoding in terms of both compute time and memory usage. + get mappings() { + if (cache.decodedMappings) { + return cache.decodedMappings; + } + // If decodedMappings doesn't exist then encodedMappings should. + // The only scenario where cache.encodedMappings should be undefined is if the map + // this was constructed from was already decoded, or if mappings was set to a new + // decoded string. In either case, this line shouldn't get hit. + cache.decodedMappings = cache.encodedMappings ? decode(cache.encodedMappings) : []; + cache.encodedMappings = undefined; + return cache.decodedMappings; + } + }; + + sourceMapCache.set(decodedMap, cache); - return { ...(map as ExistingRawSourceMap | ExistingDecodedSourceMap), mappings }; + return decodedMap; } diff --git a/src/utils/deconflictChunk.ts b/src/utils/deconflictChunk.ts index f25add1e904..9981974f884 100644 --- a/src/utils/deconflictChunk.ts +++ b/src/utils/deconflictChunk.ts @@ -1,11 +1,13 @@ -import ChildScope from '../ast/scopes/ChildScope'; +import type ChildScope from '../ast/scopes/ChildScope'; import ExportDefaultVariable from '../ast/variables/ExportDefaultVariable'; -import SyntheticNamedExportVariable from '../ast/variables/SyntheticNamedExportVariable'; -import Variable from '../ast/variables/Variable'; -import Chunk from '../Chunk'; +import type SyntheticNamedExportVariable from '../ast/variables/SyntheticNamedExportVariable'; +import type Variable from '../ast/variables/Variable'; +import type Chunk from '../Chunk'; +import ExternalChunk from '../ExternalChunk'; import ExternalModule from '../ExternalModule'; -import Module from '../Module'; -import { GetInterop, InternalModuleFormat } from '../rollup/types'; +import type Module from '../Module'; +import type { GetInterop, InternalModuleFormat } from '../rollup/types'; +import { makeLegal } from './identifierHelpers'; import { canDefaultBeTakenFromNamespace, defaultInteropHelpersByInteropType, @@ -15,23 +17,25 @@ import { import { getSafeName } from './safeName'; export interface DependenciesToBeDeconflicted { - deconflictedDefault: Set; - deconflictedNamespace: Set; - dependencies: Set; + deconflictedDefault: ReadonlySet; + deconflictedNamespace: ReadonlySet; + dependencies: ReadonlySet; } -const DECONFLICT_IMPORTED_VARIABLES_BY_FORMAT: { - [format in InternalModuleFormat]: ( +const DECONFLICT_IMPORTED_VARIABLES_BY_FORMAT: Record< + InternalModuleFormat, + ( usedNames: Set, - imports: Set, + imports: ReadonlySet, dependenciesToBeDeconflicted: DependenciesToBeDeconflicted, interop: GetInterop, preserveModules: boolean, externalLiveBindings: boolean, - chunkByModule: Map, - syntheticExports: Set - ) => void; -} = { + chunkByModule: ReadonlyMap, + externalChunkByModule: ReadonlyMap, + syntheticExports: ReadonlySet + ) => void +> = { amd: deconflictImportsOther, cjs: deconflictImportsOther, es: deconflictImportsEsmOrSystem, @@ -41,30 +45,27 @@ const DECONFLICT_IMPORTED_VARIABLES_BY_FORMAT: { }; export function deconflictChunk( - modules: Module[], + modules: readonly Module[], dependenciesToBeDeconflicted: DependenciesToBeDeconflicted, - imports: Set, + imports: ReadonlySet, usedNames: Set, format: InternalModuleFormat, interop: GetInterop, preserveModules: boolean, externalLiveBindings: boolean, - chunkByModule: Map, - syntheticExports: Set, - exportNamesByVariable: Map, - accessedGlobalsByScope: Map>, - includedNamespaces: Set -) { - const reversedModules = modules.slice().reverse(); + chunkByModule: ReadonlyMap, + externalChunkByModule: ReadonlyMap, + syntheticExports: ReadonlySet, + exportNamesByVariable: ReadonlyMap, + accessedGlobalsByScope: ReadonlyMap>, + includedNamespaces: ReadonlySet +): void { + const reversedModules = [...modules].reverse(); for (const module of reversedModules) { - module.scope.addUsedOutsideNames( - usedNames, - format, - exportNamesByVariable, - accessedGlobalsByScope - ); + module.scope.addUsedOutsideNames(usedNames, accessedGlobalsByScope); } deconflictTopLevelVariables(usedNames, reversedModules, includedNamespaces); + DECONFLICT_IMPORTED_VARIABLES_BY_FORMAT[format]( usedNames, imports, @@ -73,6 +74,7 @@ export function deconflictChunk( preserveModules, externalLiveBindings, chunkByModule, + externalChunkByModule, syntheticExports ); @@ -83,18 +85,19 @@ export function deconflictChunk( function deconflictImportsEsmOrSystem( usedNames: Set, - imports: Set, + imports: ReadonlySet, dependenciesToBeDeconflicted: DependenciesToBeDeconflicted, _interop: GetInterop, preserveModules: boolean, _externalLiveBindings: boolean, - chunkByModule: Map, - syntheticExports: Set + chunkByModule: ReadonlyMap, + externalChunkByModule: ReadonlyMap, + syntheticExports: ReadonlySet ) { // This is needed for namespace reexports for (const dependency of dependenciesToBeDeconflicted.dependencies) { - if (preserveModules || dependency instanceof ExternalModule) { - dependency.variableName = getSafeName(dependency.suggestedVariableName, usedNames); + if (preserveModules || dependency instanceof ExternalChunk) { + dependency.variableName = getSafeName(dependency.suggestedVariableName, usedNames, null); } } for (const variable of imports) { @@ -103,7 +106,10 @@ function deconflictImportsEsmOrSystem( if (variable.isNamespace && (preserveModules || module instanceof ExternalModule)) { variable.setRenderNames( null, - (module instanceof ExternalModule ? module : chunkByModule.get(module)!).variableName + (module instanceof ExternalModule + ? externalChunkByModule.get(module)! + : chunkByModule.get(module)! + ).variableName ); } else if (module instanceof ExternalModule && name === 'default') { variable.setRenderNames( @@ -114,61 +120,59 @@ function deconflictImportsEsmOrSystem( ) ? module.suggestedVariableName + '__default' : module.suggestedVariableName, - usedNames + usedNames, + variable.forbiddenNames ) ); } else { - variable.setRenderNames(null, getSafeName(name, usedNames)); + variable.setRenderNames( + null, + getSafeName(makeLegal(name), usedNames, variable.forbiddenNames) + ); } } for (const variable of syntheticExports) { - variable.setRenderNames(null, getSafeName(variable.name, usedNames)); + variable.setRenderNames(null, getSafeName(variable.name, usedNames, variable.forbiddenNames)); } } function deconflictImportsOther( usedNames: Set, - imports: Set, + imports: ReadonlySet, { deconflictedDefault, deconflictedNamespace, dependencies }: DependenciesToBeDeconflicted, interop: GetInterop, preserveModules: boolean, externalLiveBindings: boolean, - chunkByModule: Map -) { - for (const chunkOrExternalModule of dependencies) { - chunkOrExternalModule.variableName = getSafeName( - chunkOrExternalModule.suggestedVariableName, - usedNames - ); + chunkByModule: ReadonlyMap, + externalChunkByModule: ReadonlyMap +): void { + for (const chunk of dependencies) { + chunk.variableName = getSafeName(chunk.suggestedVariableName, usedNames, null); } - for (const externalModuleOrChunk of deconflictedNamespace) { - externalModuleOrChunk.namespaceVariableName = getSafeName( - `${externalModuleOrChunk.suggestedVariableName}__namespace`, - usedNames + for (const chunk of deconflictedNamespace) { + chunk.namespaceVariableName = getSafeName( + `${chunk.suggestedVariableName}__namespace`, + usedNames, + null ); } for (const externalModule of deconflictedDefault) { - if ( + externalModule.defaultVariableName = deconflictedNamespace.has(externalModule) && - canDefaultBeTakenFromNamespace(String(interop(externalModule.id)), externalLiveBindings) - ) { - externalModule.defaultVariableName = externalModule.namespaceVariableName; - } else { - externalModule.defaultVariableName = getSafeName( - `${externalModule.suggestedVariableName}__default`, - usedNames - ); - } + canDefaultBeTakenFromNamespace(interop(externalModule.id), externalLiveBindings) + ? externalModule.namespaceVariableName + : getSafeName(`${externalModule.suggestedVariableName}__default`, usedNames, null); } for (const variable of imports) { const module = variable.module; if (module instanceof ExternalModule) { + const chunk = externalChunkByModule.get(module)!; const name = variable.name; if (name === 'default') { - const moduleInterop = String(interop(module.id)); + const moduleInterop = interop(module.id); const variableName = defaultInteropHelpersByInteropType[moduleInterop] - ? module.defaultVariableName - : module.variableName; + ? chunk.defaultVariableName + : chunk.variableName; if (isDefaultAProperty(moduleInterop, externalLiveBindings)) { variable.setRenderNames(variableName, 'default'); } else { @@ -177,13 +181,13 @@ function deconflictImportsOther( } else if (name === '*') { variable.setRenderNames( null, - namespaceInteropHelpersByInteropType[String(interop(module.id))] - ? module.namespaceVariableName - : module.variableName + namespaceInteropHelpersByInteropType[interop(module.id)] + ? chunk.namespaceVariableName + : chunk.variableName ); } else { // if the second parameter is `null`, it uses its "name" for the property name - variable.setRenderNames(module.variableName, null); + variable.setRenderNames(chunk.variableName, null); } } else { const chunk = chunkByModule.get(module!)!; @@ -206,10 +210,11 @@ function deconflictImportsOther( function deconflictTopLevelVariables( usedNames: Set, - modules: Module[], - includedNamespaces: Set -) { + modules: readonly Module[], + includedNamespaces: ReadonlySet +): void { for (const module of modules) { + module.info.safeVariableNames ||= {}; for (const variable of module.scope.variables.values()) { if ( variable.included && @@ -219,12 +224,32 @@ function deconflictTopLevelVariables( (variable instanceof ExportDefaultVariable && variable.getOriginalVariable() !== variable) ) ) { - variable.setRenderNames(null, getSafeName(variable.name, usedNames)); + // We need to make sure that variables that corresponding to object + // prototype methods are not accidentally matched. + const cachedSafeVariableName = Object.getOwnPropertyDescriptor( + module.info.safeVariableNames, + variable.name + )?.value; + + if (cachedSafeVariableName && !usedNames.has(cachedSafeVariableName)) { + usedNames.add(cachedSafeVariableName); + variable.setRenderNames(null, cachedSafeVariableName); + continue; + } + + variable.setRenderNames( + null, + getSafeName(variable.name, usedNames, variable.forbiddenNames) + ); + module.info.safeVariableNames[variable.name] = variable.renderName!; } } if (includedNamespaces.has(module)) { const namespace = module.namespace; - namespace.setRenderNames(null, getSafeName(namespace.name, usedNames)); + namespace.setRenderNames( + null, + getSafeName(namespace.name, usedNames, namespace.forbiddenNames) + ); } } } diff --git a/src/utils/doNothing.ts b/src/utils/doNothing.ts new file mode 100644 index 00000000000..61661e01706 --- /dev/null +++ b/src/utils/doNothing.ts @@ -0,0 +1 @@ +export const doNothing = () => {}; diff --git a/src/utils/ensureArray.ts b/src/utils/ensureArray.ts index f108c6b3454..080d73ae226 100644 --- a/src/utils/ensureArray.ts +++ b/src/utils/ensureArray.ts @@ -1,4 +1,6 @@ -export function ensureArray(items: (T | null | undefined)[] | T | null | undefined): T[] { +export function ensureArray( + items: (T | false | null | undefined)[] | T | false | null | undefined +): T[] { if (Array.isArray(items)) { return items.filter(Boolean) as T[]; } diff --git a/src/utils/error.ts b/src/utils/error.ts deleted file mode 100644 index 176a8fc3312..00000000000 --- a/src/utils/error.ts +++ /dev/null @@ -1,494 +0,0 @@ -import { locate } from 'locate-character'; -import Module from '../Module'; -import { - NormalizedInputOptions, - RollupError, - RollupLogProps, - RollupWarning, - WarningHandler -} from '../rollup/types'; -import getCodeFrame from './getCodeFrame'; -import relativeId from './relativeId'; - -export function error(base: Error | RollupError): never { - if (!(base instanceof Error)) base = Object.assign(new Error(base.message), base); - throw base; -} - -export function augmentCodeLocation( - props: RollupLogProps, - pos: number | { column: number; line: number }, - source: string, - id: string -): void { - if (typeof pos === 'object') { - const { line, column } = pos; - props.loc = { file: id, line, column }; - } else { - props.pos = pos; - const { line, column } = locate(source, pos, { offsetLine: 1 }); - props.loc = { file: id, line, column }; - } - - if (props.frame === undefined) { - const { line, column } = props.loc; - props.frame = getCodeFrame(source, line, column); - } -} - -export const enum Errors { - ALREADY_CLOSED = 'ALREADY_CLOSED', - ASSET_NOT_FINALISED = 'ASSET_NOT_FINALISED', - ASSET_NOT_FOUND = 'ASSET_NOT_FOUND', - ASSET_SOURCE_ALREADY_SET = 'ASSET_SOURCE_ALREADY_SET', - ASSET_SOURCE_MISSING = 'ASSET_SOURCE_MISSING', - BAD_LOADER = 'BAD_LOADER', - CANNOT_EMIT_FROM_OPTIONS_HOOK = 'CANNOT_EMIT_FROM_OPTIONS_HOOK', - CHUNK_NOT_GENERATED = 'CHUNK_NOT_GENERATED', - CHUNK_INVALID = 'CHUNK_INVALID', - CIRCULAR_REEXPORT = 'CIRCULAR_REEXPORT', - CYCLIC_CROSS_CHUNK_REEXPORT = 'CYCLIC_CROSS_CHUNK_REEXPORT', - DEPRECATED_FEATURE = 'DEPRECATED_FEATURE', - EXTERNAL_SYNTHETIC_EXPORTS = 'EXTERNAL_SYNTHETIC_EXPORTS', - FILE_NAME_CONFLICT = 'FILE_NAME_CONFLICT', - FILE_NOT_FOUND = 'FILE_NOT_FOUND', - INPUT_HOOK_IN_OUTPUT_PLUGIN = 'INPUT_HOOK_IN_OUTPUT_PLUGIN', - INVALID_CHUNK = 'INVALID_CHUNK', - INVALID_EXPORT_OPTION = 'INVALID_EXPORT_OPTION', - INVALID_EXTERNAL_ID = 'INVALID_EXTERNAL_ID', - INVALID_OPTION = 'INVALID_OPTION', - INVALID_PLUGIN_HOOK = 'INVALID_PLUGIN_HOOK', - INVALID_ROLLUP_PHASE = 'INVALID_ROLLUP_PHASE', - MISSING_EXPORT = 'MISSING_EXPORT', - MISSING_IMPLICIT_DEPENDANT = 'MISSING_IMPLICIT_DEPENDANT', - MIXED_EXPORTS = 'MIXED_EXPORTS', - NAMESPACE_CONFLICT = 'NAMESPACE_CONFLICT', - NO_TRANSFORM_MAP_OR_AST_WITHOUT_CODE = 'NO_TRANSFORM_MAP_OR_AST_WITHOUT_CODE', - PLUGIN_ERROR = 'PLUGIN_ERROR', - PREFER_NAMED_EXPORTS = 'PREFER_NAMED_EXPORTS', - SYNTHETIC_NAMED_EXPORTS_NEED_NAMESPACE_EXPORT = 'SYNTHETIC_NAMED_EXPORTS_NEED_NAMESPACE_EXPORT', - UNEXPECTED_NAMED_IMPORT = 'UNEXPECTED_NAMED_IMPORT', - UNRESOLVED_ENTRY = 'UNRESOLVED_ENTRY', - UNRESOLVED_IMPORT = 'UNRESOLVED_IMPORT', - VALIDATION_ERROR = 'VALIDATION_ERROR' -} - -export function errAssetNotFinalisedForFileName(name: string) { - return { - code: Errors.ASSET_NOT_FINALISED, - message: `Plugin error - Unable to get file name for asset "${name}". Ensure that the source is set and that generate is called first.` - }; -} - -export function errCannotEmitFromOptionsHook() { - return { - code: Errors.CANNOT_EMIT_FROM_OPTIONS_HOOK, - message: `Cannot emit files or set asset sources in the "outputOptions" hook, use the "renderStart" hook instead.` - }; -} - -export function errChunkNotGeneratedForFileName(name: string) { - return { - code: Errors.CHUNK_NOT_GENERATED, - message: `Plugin error - Unable to get file name for chunk "${name}". Ensure that generate is called first.` - }; -} - -export function errChunkInvalid( - { fileName, code }: { code: string; fileName: string }, - exception: { loc: { column: number; line: number }; message: string } -) { - const errorProps = { - code: Errors.CHUNK_INVALID, - message: `Chunk "${fileName}" is not valid JavaScript: ${exception.message}.` - }; - augmentCodeLocation(errorProps, exception.loc, code, fileName); - return errorProps; -} - -export function errCircularReexport(exportName: string, importedModule: string) { - return { - code: Errors.CIRCULAR_REEXPORT, - id: importedModule, - message: `"${exportName}" cannot be exported from ${relativeId( - importedModule - )} as it is a reexport that references itself.` - }; -} - -export function errCyclicCrossChunkReexport( - exportName: string, - exporter: string, - reexporter: string, - importer: string -): RollupWarning { - return { - code: Errors.CYCLIC_CROSS_CHUNK_REEXPORT, - exporter, - importer, - message: `Export "${exportName}" of module ${relativeId( - exporter - )} was reexported through module ${relativeId( - reexporter - )} while both modules are dependencies of each other and will end up in different chunks by current Rollup settings. This scenario is not well supported at the moment as it will produce a circular dependency between chunks and will likely lead to broken execution order.\nEither change the import in ${relativeId( - importer - )} to point directly to the exporting module or do not use "preserveModules" to ensure these modules end up in the same chunk.`, - reexporter - }; -} - -export function errAssetReferenceIdNotFoundForSetSource(assetReferenceId: string) { - return { - code: Errors.ASSET_NOT_FOUND, - message: `Plugin error - Unable to set the source for unknown asset "${assetReferenceId}".` - }; -} - -export function errAssetSourceAlreadySet(name: string) { - return { - code: Errors.ASSET_SOURCE_ALREADY_SET, - message: `Unable to set the source for asset "${name}", source already set.` - }; -} - -export function errNoAssetSourceSet(assetName: string) { - return { - code: Errors.ASSET_SOURCE_MISSING, - message: `Plugin error creating asset "${assetName}" - no asset source set.` - }; -} - -export function errBadLoader(id: string) { - return { - code: Errors.BAD_LOADER, - message: `Error loading ${relativeId( - id - )}: plugin load hook should return a string, a { code, map } object, or nothing/null` - }; -} - -export function errDeprecation(deprecation: string | RollupWarning) { - return { - code: Errors.DEPRECATED_FEATURE, - ...(typeof deprecation === 'string' ? { message: deprecation } : deprecation) - }; -} - -export function errFileReferenceIdNotFoundForFilename(assetReferenceId: string) { - return { - code: Errors.FILE_NOT_FOUND, - message: `Plugin error - Unable to get file name for unknown file "${assetReferenceId}".` - }; -} - -export function errFileNameConflict(fileName: string) { - return { - code: Errors.FILE_NAME_CONFLICT, - message: `The emitted file "${fileName}" overwrites a previously emitted file of the same name.` - }; -} - -export function errInputHookInOutputPlugin(pluginName: string, hookName: string) { - return { - code: Errors.INPUT_HOOK_IN_OUTPUT_PLUGIN, - message: `The "${hookName}" hook used by the output plugin ${pluginName} is a build time hook and will not be run for that plugin. Either this plugin cannot be used as an output plugin, or it should have an option to configure it as an output plugin.` - }; -} - -export function errCannotAssignModuleToChunk( - moduleId: string, - assignToAlias: string, - currentAlias: string -) { - return { - code: Errors.INVALID_CHUNK, - message: `Cannot assign ${relativeId( - moduleId - )} to the "${assignToAlias}" chunk as it is already in the "${currentAlias}" chunk.` - }; -} - -export function errInvalidExportOptionValue(optionValue: string) { - return { - code: Errors.INVALID_EXPORT_OPTION, - message: `"output.exports" must be "default", "named", "none", "auto", or left unspecified (defaults to "auto"), received "${optionValue}"`, - url: `https://rollupjs.org/guide/en/#outputexports` - }; -} - -export function errIncompatibleExportOptionValue( - optionValue: string, - keys: string[], - entryModule: string -) { - return { - code: 'INVALID_EXPORT_OPTION', - message: `"${optionValue}" was specified for "output.exports", but entry module "${relativeId( - entryModule - )}" has the following exports: ${keys.join(', ')}` - }; -} - -export function errInternalIdCannotBeExternal(source: string, importer: string) { - return { - code: Errors.INVALID_EXTERNAL_ID, - message: `'${source}' is imported as an external by ${relativeId( - importer - )}, but is already an existing non-external module id.` - }; -} - -export function errInvalidOption(option: string, explanation: string) { - return { - code: Errors.INVALID_OPTION, - message: `Invalid value for option "${option}" - ${explanation}.` - }; -} - -export function errInvalidRollupPhaseForAddWatchFile() { - return { - code: Errors.INVALID_ROLLUP_PHASE, - message: `Cannot call addWatchFile after the build has finished.` - }; -} - -export function errInvalidRollupPhaseForChunkEmission() { - return { - code: Errors.INVALID_ROLLUP_PHASE, - message: `Cannot emit chunks after module loading has finished.` - }; -} - -export function errMissingExport( - exportName: string, - importingModule: string, - importedModule: string -) { - return { - code: Errors.MISSING_EXPORT, - message: `'${exportName}' is not exported by ${relativeId( - importedModule - )}, imported by ${relativeId(importingModule)}`, - url: `https://rollupjs.org/guide/en/#error-name-is-not-exported-by-module` - }; -} - -export function errImplicitDependantCannotBeExternal( - unresolvedId: string, - implicitlyLoadedBefore: string -) { - return { - code: Errors.MISSING_IMPLICIT_DEPENDANT, - message: `Module "${relativeId( - unresolvedId - )}" that should be implicitly loaded before "${relativeId( - implicitlyLoadedBefore - )}" cannot be external.` - }; -} - -export function errUnresolvedImplicitDependant( - unresolvedId: string, - implicitlyLoadedBefore: string -) { - return { - code: Errors.MISSING_IMPLICIT_DEPENDANT, - message: `Module "${relativeId( - unresolvedId - )}" that should be implicitly loaded before "${relativeId( - implicitlyLoadedBefore - )}" could not be resolved.` - }; -} - -export function errImplicitDependantIsNotIncluded(module: Module) { - const implicitDependencies = Array.from(module.implicitlyLoadedBefore, dependency => - relativeId(dependency.id) - ).sort(); - return { - code: Errors.MISSING_IMPLICIT_DEPENDANT, - message: `Module "${relativeId(module.id)}" that should be implicitly loaded before "${ - implicitDependencies.length === 1 - ? implicitDependencies[0] - : `${implicitDependencies.slice(0, -1).join('", "')}" and "${ - implicitDependencies.slice(-1)[0] - }` - }" is not included in the module graph. Either it was not imported by an included module or only via a tree-shaken dynamic import, or no imported bindings were used and it had otherwise no side-effects.` - }; -} - -export function errMixedExport(facadeModuleId: string, name?: string) { - return { - code: Errors.MIXED_EXPORTS, - id: facadeModuleId, - message: `Entry module "${relativeId( - facadeModuleId - )}" is using named and default exports together. Consumers of your bundle will have to use \`${ - name || 'chunk' - }["default"]\` to access the default export, which may not be what you want. Use \`output.exports: "named"\` to disable this warning`, - url: `https://rollupjs.org/guide/en/#outputexports` - }; -} - -export function errNamespaceConflict( - name: string, - reexportingModule: Module, - additionalExportAllModule: Module -) { - return { - code: Errors.NAMESPACE_CONFLICT, - message: `Conflicting namespaces: ${relativeId( - reexportingModule.id - )} re-exports '${name}' from both ${relativeId( - reexportingModule.exportsAll[name] - )} and ${relativeId(additionalExportAllModule.exportsAll[name])} (will be ignored)`, - name, - reexporter: reexportingModule.id, - sources: [reexportingModule.exportsAll[name], additionalExportAllModule.exportsAll[name]] - }; -} - -export function errNoTransformMapOrAstWithoutCode(pluginName: string) { - return { - code: Errors.NO_TRANSFORM_MAP_OR_AST_WITHOUT_CODE, - message: - `The plugin "${pluginName}" returned a "map" or "ast" without returning ` + - 'a "code". This will be ignored.' - }; -} - -export function errPreferNamedExports(facadeModuleId: string) { - const file = relativeId(facadeModuleId); - return { - code: Errors.PREFER_NAMED_EXPORTS, - id: facadeModuleId, - message: `Entry module "${file}" is implicitly using "default" export mode, which means for CommonJS output that its default export is assigned to "module.exports". For many tools, such CommonJS output will not be interchangeable with the original ES module. If this is intended, explicitly set "output.exports" to either "auto" or "default", otherwise you might want to consider changing the signature of "${file}" to use named exports only.`, - url: `https://rollupjs.org/guide/en/#outputexports` - }; -} - -export function errSyntheticNamedExportsNeedNamespaceExport( - id: string, - syntheticNamedExportsOption: boolean | string -) { - return { - code: Errors.SYNTHETIC_NAMED_EXPORTS_NEED_NAMESPACE_EXPORT, - id, - message: `Module "${relativeId( - id - )}" that is marked with 'syntheticNamedExports: ${JSON.stringify( - syntheticNamedExportsOption - )}' needs ${ - typeof syntheticNamedExportsOption === 'string' && syntheticNamedExportsOption !== 'default' - ? `an export named "${syntheticNamedExportsOption}"` - : 'a default export' - } that does not reexport an unresolved named export of the same module.` - }; -} - -export function errUnexpectedNamedImport(id: string, imported: string, isReexport: boolean) { - const importType = isReexport ? 'reexport' : 'import'; - return { - code: Errors.UNEXPECTED_NAMED_IMPORT, - id, - message: `The named export "${imported}" was ${importType}ed from the external module ${relativeId( - id - )} even though its interop type is "defaultOnly". Either remove or change this ${importType} or change the value of the "output.interop" option.`, - url: 'https://rollupjs.org/guide/en/#outputinterop' - }; -} - -export function errUnexpectedNamespaceReexport(id: string) { - return { - code: Errors.UNEXPECTED_NAMED_IMPORT, - id, - message: `There was a namespace "*" reexport from the external module ${relativeId( - id - )} even though its interop type is "defaultOnly". This will be ignored as namespace reexports only reexport named exports. If this is not intended, either remove or change this reexport or change the value of the "output.interop" option.`, - url: 'https://rollupjs.org/guide/en/#outputinterop' - }; -} - -export function errEntryCannotBeExternal(unresolvedId: string) { - return { - code: Errors.UNRESOLVED_ENTRY, - message: `Entry module cannot be external (${relativeId(unresolvedId)}).` - }; -} - -export function errUnresolvedEntry(unresolvedId: string) { - return { - code: Errors.UNRESOLVED_ENTRY, - message: `Could not resolve entry module (${relativeId(unresolvedId)}).` - }; -} - -export function errUnresolvedImport(source: string, importer: string) { - return { - code: Errors.UNRESOLVED_IMPORT, - message: `Could not resolve '${source}' from ${relativeId(importer)}` - }; -} - -export function errUnresolvedImportTreatedAsExternal(source: string, importer: string) { - return { - code: Errors.UNRESOLVED_IMPORT, - importer: relativeId(importer), - message: `'${source}' is imported by ${relativeId( - importer - )}, but could not be resolved – treating it as an external dependency`, - source, - url: 'https://rollupjs.org/guide/en/#warning-treating-module-as-external-dependency' - }; -} - -export function errExternalSyntheticExports(source: string, importer: string) { - return { - code: Errors.EXTERNAL_SYNTHETIC_EXPORTS, - importer: relativeId(importer), - message: `External '${source}' can not have 'syntheticNamedExports' enabled.`, - source - }; -} - -export function errFailedValidation(message: string) { - return { - code: Errors.VALIDATION_ERROR, - message - }; -} - -export function errAlreadyClosed() { - return { - code: Errors.ALREADY_CLOSED, - message: 'Bundle is already closed, no more calls to "generate" or "write" are allowed.' - }; -} - -export function warnDeprecation( - deprecation: string | RollupWarning, - activeDeprecation: boolean, - options: NormalizedInputOptions -): void { - warnDeprecationWithOptions( - deprecation, - activeDeprecation, - options.onwarn, - options.strictDeprecations - ); -} - -export function warnDeprecationWithOptions( - deprecation: string | RollupWarning, - activeDeprecation: boolean, - warn: WarningHandler, - strictDeprecations: boolean -): void { - if (activeDeprecation || strictDeprecations) { - const warning = errDeprecation(deprecation); - if (strictDeprecations) { - return error(warning); - } - warn(warning); - } -} diff --git a/src/utils/escapeId.ts b/src/utils/escapeId.ts index 45384811a9d..fd9047ad089 100644 --- a/src/utils/escapeId.ts +++ b/src/utils/escapeId.ts @@ -1,7 +1,8 @@ -const needsEscapeRegEx = /[\\'\r\n\u2028\u2029]/; -const quoteNewlineRegEx = /(['\r\n\u2028\u2029])/g; +const needsEscapeRegEx = /[\n\r'\\\u2028\u2029]/; +const quoteNewlineRegEx = /([\n\r'\u2028\u2029])/g; const backSlashRegEx = /\\/g; -export function escapeId(id: string) { - if (!id.match(needsEscapeRegEx)) return id; + +export function escapeId(id: string): string { + if (!needsEscapeRegEx.test(id)) return id; return id.replace(backSlashRegEx, '\\\\').replace(quoteNewlineRegEx, '\\$1'); } diff --git a/src/utils/executionOrder.ts b/src/utils/executionOrder.ts index 638971a613f..657b963d788 100644 --- a/src/utils/executionOrder.ts +++ b/src/utils/executionOrder.ts @@ -1,6 +1,5 @@ -import ExternalModule from '../ExternalModule'; +import type ExternalModule from '../ExternalModule'; import Module from '../Module'; -import relativeId from './relativeId'; interface OrderedExecutionUnit { execIndex: number; @@ -9,11 +8,21 @@ interface OrderedExecutionUnit { const compareExecIndex = (unitA: T, unitB: T) => unitA.execIndex > unitB.execIndex ? 1 : -1; -export function sortByExecutionOrder(units: OrderedExecutionUnit[]) { +export function sortByExecutionOrder(units: OrderedExecutionUnit[]): void { units.sort(compareExecIndex); } -export function analyseModuleExecution(entryModules: Module[]) { +// This process is currently faulty in so far as it only takes the first entry +// module into account and assumes that dynamic imports are imported in a +// certain order. +// A better algorithm would follow every possible execution path and mark which +// modules are executed before or after which other modules. THen the chunking +// would need to take care that in each chunk, all modules are always executed +// in the same sequence. +export function analyseModuleExecution(entryModules: readonly Module[]): { + cyclePaths: string[][]; + orderedModules: Module[]; +} { let nextExecIndex = 0; const cyclePaths: string[][] = []; const analysedModules = new Set(); @@ -21,25 +30,35 @@ export function analyseModuleExecution(entryModules: Module[]) { const parents = new Map(); const orderedModules: Module[] = []; + const handleSyncLoadedModule = (module: Module | ExternalModule, parent: Module) => { + if (parents.has(module)) { + if (!analysedModules.has(module)) { + cyclePaths.push(getCyclePath(module as Module, parent, parents)); + } + return; + } + parents.set(module, parent); + analyseModule(module); + }; + const analyseModule = (module: Module | ExternalModule) => { if (module instanceof Module) { for (const dependency of module.dependencies) { - if (parents.has(dependency)) { - if (!analysedModules.has(dependency)) { - cyclePaths.push(getCyclePath(dependency as Module, module, parents)); - } - continue; - } - parents.set(dependency, module); - analyseModule(dependency); + handleSyncLoadedModule(dependency, module); } for (const dependency of module.implicitlyLoadedBefore) { dynamicImports.add(dependency); } - for (const { resolution } of module.dynamicImports) { + for (const { + node: { resolution, scope } + } of module.dynamicImports) { if (resolution instanceof Module) { - dynamicImports.add(resolution); + if (scope.context.usesTopLevelAwait) { + handleSyncLoadedModule(resolution, module); + } else { + dynamicImports.add(resolution); + } } } orderedModules.push(module); @@ -49,34 +68,34 @@ export function analyseModuleExecution(entryModules: Module[]) { analysedModules.add(module); }; - for (const curEntry of entryModules) { - if (!parents.has(curEntry)) { - parents.set(curEntry, null); - analyseModule(curEntry); + for (const currentEntry of entryModules) { + if (!parents.has(currentEntry)) { + parents.set(currentEntry, null); + analyseModule(currentEntry); } } - for (const curEntry of dynamicImports) { - if (!parents.has(curEntry)) { - parents.set(curEntry, null); - analyseModule(curEntry); + for (const currentEntry of dynamicImports) { + if (!parents.has(currentEntry)) { + parents.set(currentEntry, null); + analyseModule(currentEntry); } } - return { orderedModules, cyclePaths }; + return { cyclePaths, orderedModules }; } function getCyclePath( module: Module, parent: Module, - parents: Map -) { + parents: ReadonlyMap +): string[] { const cycleSymbol = Symbol(module.id); - const path = [relativeId(module.id)]; + const path = [module.id]; let nextModule = parent; module.cycles.add(cycleSymbol); while (nextModule !== module) { nextModule.cycles.add(cycleSymbol); - path.push(relativeId(nextModule.id)); + path.push(nextModule.id); nextModule = parents.get(nextModule)!; } path.push(path[0]); diff --git a/src/utils/exportNames.ts b/src/utils/exportNames.ts index 9f3feb3fed7..e24c411555e 100644 --- a/src/utils/exportNames.ts +++ b/src/utils/exportNames.ts @@ -1,16 +1,16 @@ -import Variable from '../ast/variables/Variable'; +import type Variable from '../ast/variables/Variable'; +import RESERVED_NAMES from './RESERVED_NAMES'; import { toBase64 } from './base64'; -import { RESERVED_NAMES } from './reservedNames'; export function assignExportsToMangledNames( - exports: Set, - exportsByName: Record, + exports: ReadonlySet, + exportsByName: Map, exportNamesByVariable: Map -) { +): void { let nameIndex = 0; for (const variable of exports) { - let exportName = variable.name[0]; - if (exportsByName[exportName]) { + let [exportName] = variable.name; + if (exportsByName.has(exportName)) { do { exportName = toBase64(++nameIndex); // skip past leading number identifiers @@ -18,25 +18,25 @@ export function assignExportsToMangledNames( nameIndex += 9 * 64 ** (exportName.length - 1); exportName = toBase64(nameIndex); } - } while (RESERVED_NAMES[exportName] || exportsByName[exportName]); + } while (RESERVED_NAMES.has(exportName) || exportsByName.has(exportName)); } - exportsByName[exportName] = variable; + exportsByName.set(exportName, variable); exportNamesByVariable.set(variable, [exportName]); } } export function assignExportsToNames( - exports: Set, - exportsByName: Record, + exports: ReadonlySet, + exportsByName: Map, exportNamesByVariable: Map -) { +): void { for (const variable of exports) { let nameIndex = 0; let exportName = variable.name; - while (exportsByName[exportName]) { + while (exportsByName.has(exportName)) { exportName = variable.name + '$' + ++nameIndex; } - exportsByName[exportName] = variable; + exportsByName.set(exportName, variable); exportNamesByVariable.set(variable, [exportName]); } } diff --git a/src/utils/fs.ts b/src/utils/fs.ts index 4d58925027f..702f7bcdffb 100644 --- a/src/utils/fs.ts +++ b/src/utils/fs.ts @@ -1,39 +1 @@ -import * as fs from 'fs'; -import { dirname } from './path'; - -export * from 'fs'; - -export const readFile = (file: string) => - new Promise((fulfil, reject) => - fs.readFile(file, 'utf-8', (err, contents) => (err ? reject(err) : fulfil(contents))) - ); - -function mkdirpath(path: string) { - const dir = dirname(path); - try { - fs.readdirSync(dir); - } catch (err) { - mkdirpath(dir); - try { - fs.mkdirSync(dir); - } catch (err2) { - if (err2.code !== 'EEXIST') { - throw err2; - } - } - } -} - -export function writeFile(dest: string, data: string | Uint8Array) { - return new Promise((fulfil, reject) => { - mkdirpath(dest); - - fs.writeFile(dest, data, err => { - if (err) { - reject(err); - } else { - fulfil(); - } - }); - }); -} +export * from 'node:fs/promises'; diff --git a/src/utils/generateCodeSnippets.ts b/src/utils/generateCodeSnippets.ts new file mode 100644 index 00000000000..06cb5da389e --- /dev/null +++ b/src/utils/generateCodeSnippets.ts @@ -0,0 +1,133 @@ +import type { NormalizedOutputOptions } from '../rollup/types'; +import RESERVED_NAMES from './RESERVED_NAMES'; +import { stringifyObjectKeyIfNeeded, VALID_IDENTIFIER_REGEXP } from './identifierHelpers'; + +export interface GenerateCodeSnippets { + _: string; + cnst: string; + n: string; + s: string; + getDirectReturnFunction( + parameters: string[], + options: { + functionReturn: boolean; + lineBreakIndent: { base: string; t: string } | null; + name: string | null; + } + ): [left: string, right: string]; + getDirectReturnIifeLeft( + parameters: string[], + returned: string, + options: { + needsArrowReturnParens: boolean | undefined; + needsWrappedFunction: boolean | undefined; + } + ): string; + getFunctionIntro( + parameters: string[], + options: { isAsync: boolean; name: string | null } + ): string; + getNonArrowFunctionIntro( + parameters: string[], + options: { isAsync: boolean; name: string | null } + ): string; + getObject( + fields: [key: string | null, value: string][], + options: { lineBreakIndent: { base: string; t: string } | null } + ): string; + getPropertyAccess(name: string): string; +} + +export function getGenerateCodeSnippets({ + compact, + generatedCode: { arrowFunctions, constBindings, objectShorthand, reservedNamesAsProps } +}: NormalizedOutputOptions): GenerateCodeSnippets { + const { _, n, s } = compact ? { _: '', n: '', s: '' } : { _: ' ', n: '\n', s: ';' }; + const cnst = constBindings ? 'const' : 'var'; + const getNonArrowFunctionIntro: GenerateCodeSnippets['getNonArrowFunctionIntro'] = ( + parameters, + { isAsync, name } + ) => + `${isAsync ? `async ` : ''}function${name ? ` ${name}` : ''}${_}(${parameters.join( + `,${_}` + )})${_}`; + + const getFunctionIntro: GenerateCodeSnippets['getFunctionIntro'] = arrowFunctions + ? (parameters, { isAsync, name }) => { + const singleParameter = parameters.length === 1; + const asyncString = isAsync ? `async${singleParameter ? ' ' : _}` : ''; + return `${name ? `${cnst} ${name}${_}=${_}` : ''}${asyncString}${ + singleParameter ? parameters[0] : `(${parameters.join(`,${_}`)})` + }${_}=>${_}`; + } + : getNonArrowFunctionIntro; + + const getDirectReturnFunction: GenerateCodeSnippets['getDirectReturnFunction'] = ( + parameters, + { functionReturn, lineBreakIndent, name } + ) => [ + `${getFunctionIntro(parameters, { + isAsync: false, + name + })}${ + arrowFunctions + ? lineBreakIndent + ? `${n}${lineBreakIndent.base}${lineBreakIndent.t}` + : '' + : `{${lineBreakIndent ? `${n}${lineBreakIndent.base}${lineBreakIndent.t}` : _}${ + functionReturn ? 'return ' : '' + }` + }`, + arrowFunctions + ? `${name ? ';' : ''}${lineBreakIndent ? `${n}${lineBreakIndent.base}` : ''}` + : `${s}${lineBreakIndent ? `${n}${lineBreakIndent.base}` : _}}` + ]; + + const isValidPropertyName = reservedNamesAsProps + ? (name: string): boolean => VALID_IDENTIFIER_REGEXP.test(name) + : (name: string): boolean => !RESERVED_NAMES.has(name) && VALID_IDENTIFIER_REGEXP.test(name); + + return { + _, + cnst, + getDirectReturnFunction, + getDirectReturnIifeLeft: ( + parameters, + returned, + { needsArrowReturnParens, needsWrappedFunction } + ) => { + const [left, right] = getDirectReturnFunction(parameters, { + functionReturn: true, + lineBreakIndent: null, + name: null + }); + return `${wrapIfNeeded( + `${left}${wrapIfNeeded(returned, arrowFunctions && needsArrowReturnParens)}${right}`, + arrowFunctions || needsWrappedFunction + )}(`; + }, + getFunctionIntro, + getNonArrowFunctionIntro, + getObject(fields, { lineBreakIndent }) { + const prefix = lineBreakIndent ? `${n}${lineBreakIndent.base}${lineBreakIndent.t}` : _; + return `{${fields + .map(([key, value]) => { + if (key === null) return `${prefix}${value}`; + const keyInObject = stringifyObjectKeyIfNeeded(key); + return key === value && objectShorthand && key === keyInObject + ? prefix + key + : `${prefix}${keyInObject}:${_}${value}`; + }) + .join(`,`)}${ + fields.length === 0 ? '' : lineBreakIndent ? `${n}${lineBreakIndent.base}` : _ + }}`; + }, + getPropertyAccess: (name: string): string => + isValidPropertyName(name) ? `.${name}` : `[${JSON.stringify(name)}]`, + n, + s + }; +} + +const wrapIfNeeded = (code: string, needsParens: boolean | undefined): string => + needsParens ? `(${code})` : code; diff --git a/src/utils/getAstBuffer.ts b/src/utils/getAstBuffer.ts new file mode 100644 index 00000000000..5d49df35179 --- /dev/null +++ b/src/utils/getAstBuffer.ts @@ -0,0 +1,21 @@ +export type AstBuffer = Uint32Array & { convertString: (position: number) => string }; + +export function getAstBuffer(astBuffer: Buffer | Uint8Array): AstBuffer { + const array = new Uint32Array(astBuffer.buffer); + let convertString: (position: number) => string; + if (typeof Buffer !== 'undefined' && astBuffer instanceof Buffer) { + convertString = (position: number) => { + const length = array[position++]; + const bytePosition = position << 2; + return astBuffer.toString('utf8', bytePosition, bytePosition + length); + }; + } else { + const textDecoder = new TextDecoder(); + convertString = (position: number) => { + const length = array[position++]; + const bytePosition = position << 2; + return textDecoder.decode(astBuffer.subarray(bytePosition, bytePosition + length)); + }; + } + return Object.assign(array, { convertString }); +} diff --git a/src/utils/getCodeFrame.ts b/src/utils/getCodeFrame.ts index e99d688259b..5c547c63ba8 100644 --- a/src/utils/getCodeFrame.ts +++ b/src/utils/getCodeFrame.ts @@ -1,15 +1,27 @@ -function spaces(i: number) { +function spaces(index: number): string { let result = ''; - while (i--) result += ' '; + while (index--) result += ' '; return result; } -function tabsToSpaces(str: string) { - return str.replace(/^\t+/, match => match.split('\t').join(' ')); +function tabsToSpaces(value: string): string { + return value.replace(/^\t+/, match => match.split('\t').join(' ')); } -export default function getCodeFrame(source: string, line: number, column: number) { +const LINE_TRUNCATE_LENGTH = 120; +const MIN_CHARACTERS_SHOWN_AFTER_LOCATION = 10; +const ELLIPSIS = '...'; + +export default function getCodeFrame(source: string, line: number, column: number): string { let lines = source.split('\n'); + // Needed if a plugin did not generate correct sourcemaps + if (line > lines.length) return ''; + const maxLineLength = Math.max( + tabsToSpaces(lines[line - 1].slice(0, column)).length + + MIN_CHARACTERS_SHOWN_AFTER_LOCATION + + ELLIPSIS.length, + LINE_TRUNCATE_LENGTH + ); const frameStart = Math.max(0, line - 3); let frameEnd = Math.min(line + 2, lines.length); @@ -23,18 +35,23 @@ export default function getCodeFrame(source: string, line: number, column: numbe const digits = String(frameEnd).length; return lines - .map((str, i) => { - const isErrorLine = frameStart + i + 1 === line; + .map((sourceLine, index) => { + const isErrorLine = frameStart + index + 1 === line; - let lineNum = String(i + frameStart + 1); - while (lineNum.length < digits) lineNum = ` ${lineNum}`; + let lineNumber = String(index + frameStart + 1); + while (lineNumber.length < digits) lineNumber = ` ${lineNumber}`; + let displayedLine = tabsToSpaces(sourceLine); + if (displayedLine.length > maxLineLength) { + displayedLine = `${displayedLine.slice(0, maxLineLength - ELLIPSIS.length)}${ELLIPSIS}`; + } if (isErrorLine) { - const indicator = spaces(digits + 2 + tabsToSpaces(str.slice(0, column)).length) + '^'; - return `${lineNum}: ${tabsToSpaces(str)}\n${indicator}`; + const indicator = + spaces(digits + 2 + tabsToSpaces(sourceLine.slice(0, column)).length) + '^'; + return `${lineNumber}: ${displayedLine}\n${indicator}`; } - return `${lineNum}: ${tabsToSpaces(str)}`; + return `${lineNumber}: ${displayedLine}`; }) .join('\n'); } diff --git a/src/utils/getExportMode.ts b/src/utils/getExportMode.ts index 01e6ac534ea..0b3b389a4d5 100644 --- a/src/utils/getExportMode.ts +++ b/src/utils/getExportMode.ts @@ -1,40 +1,32 @@ -import Chunk from '../Chunk'; -import { NormalizedOutputOptions, WarningHandler } from '../rollup/types'; -import { - errIncompatibleExportOptionValue, - errMixedExport, - error, - errPreferNamedExports -} from './error'; +import type Chunk from '../Chunk'; +import type { LogHandler, NormalizedOutputOptions } from '../rollup/types'; +import { LOGLEVEL_WARN } from './logging'; +import { error, logIncompatibleExportOptionValue, logMixedExport } from './logs'; export default function getExportMode( chunk: Chunk, { exports: exportMode, name, format }: NormalizedOutputOptions, - unsetOptions: Set, facadeModuleId: string, - warn: WarningHandler -) { + log: LogHandler +): 'default' | 'named' | 'none' { const exportKeys = chunk.getExportNames(); if (exportMode === 'default') { if (exportKeys.length !== 1 || exportKeys[0] !== 'default') { - return error(errIncompatibleExportOptionValue('default', exportKeys, facadeModuleId)); + return error(logIncompatibleExportOptionValue('default', exportKeys, facadeModuleId)); } - } else if (exportMode === 'none' && exportKeys.length) { - return error(errIncompatibleExportOptionValue('none', exportKeys, facadeModuleId)); + } else if (exportMode === 'none' && exportKeys.length > 0) { + return error(logIncompatibleExportOptionValue('none', exportKeys, facadeModuleId)); } if (exportMode === 'auto') { if (exportKeys.length === 0) { exportMode = 'none'; } else if (exportKeys.length === 1 && exportKeys[0] === 'default') { - if (format === 'cjs' && unsetOptions.has('exports')) { - warn(errPreferNamedExports(facadeModuleId)); - } exportMode = 'default'; } else { - if (format !== 'es' && exportKeys.indexOf('default') !== -1) { - warn(errMixedExport(facadeModuleId, name)); + if (format !== 'es' && format !== 'system' && exportKeys.includes('default')) { + log(LOGLEVEL_WARN, logMixedExport(facadeModuleId, name)); } exportMode = 'named'; } diff --git a/src/utils/getIndentString.ts b/src/utils/getIndentString.ts index bd2ab3522c4..ad6e97ddfa1 100644 --- a/src/utils/getIndentString.ts +++ b/src/utils/getIndentString.ts @@ -1,6 +1,6 @@ -import Module from '../Module'; +import type Module from '../Module'; -function guessIndentString(code: string) { +function guessIndentString(code: string): string | null { const lines = code.split('\n'); const tabbed = lines.filter(line => /^\t+/.test(line)); @@ -19,18 +19,20 @@ function guessIndentString(code: string) { // Otherwise, we need to guess the multiple const min = spaced.reduce((previous, current) => { - const numSpaces = /^ +/.exec(current)![0].length; - return Math.min(numSpaces, previous); + const numberSpaces = /^ +/.exec(current)![0].length; + return Math.min(numberSpaces, previous); }, Infinity); - return new Array(min + 1).join(' '); + return ' '.repeat(min); } -export default function getIndentString(modules: Module[], options: { indent: true | string }) { +export default function getIndentString( + modules: readonly Module[], + options: { indent: true | string } +): string { if (options.indent !== true) return options.indent; - - for (let i = 0; i < modules.length; i++) { - const indent = guessIndentString(modules[i].originalCode); + for (const module of modules) { + const indent = guessIndentString(module.originalCode); if (indent !== null) return indent; } diff --git a/src/utils/getLogFilter.ts b/src/utils/getLogFilter.ts new file mode 100644 index 00000000000..3c12555a667 --- /dev/null +++ b/src/utils/getLogFilter.ts @@ -0,0 +1,57 @@ +import type { RollupLog } from '../rollup/types'; +import type { GetLogFilter } from './getLogFilterType'; + +export const getLogFilter: GetLogFilter = filters => { + if (filters.length === 0) return () => true; + const normalizedFilters = filters.map(filter => + filter.split('&').map(subFilter => { + const inverted = subFilter[0] === '!'; + if (inverted) subFilter = subFilter.slice(1); + const [key, ...value] = subFilter.split(':'); + return { inverted, key: key.split('.'), parts: value.join(':').split('*') }; + }) + ); + return (log: RollupLog): boolean => { + nextIntersectedFilter: for (const intersectedFilters of normalizedFilters) { + for (const { inverted, key, parts } of intersectedFilters) { + const isFilterSatisfied = testFilter(log, key, parts); + if (inverted ? isFilterSatisfied : !isFilterSatisfied) { + continue nextIntersectedFilter; + } + } + return true; + } + return false; + }; +}; + +const testFilter = (log: RollupLog, key: string[], parts: string[]): boolean => { + let rawValue: any = log; + for (let index = 0; index < key.length; index++) { + if (!rawValue) { + return false; + } + const part = key[index]; + if (!(part in rawValue)) { + return false; + } + rawValue = rawValue[part]; + } + let value = typeof rawValue === 'object' ? JSON.stringify(rawValue) : String(rawValue); + if (parts.length === 1) { + return value === parts[0]; + } + if (!value.startsWith(parts[0])) { + return false; + } + const lastPartIndex = parts.length - 1; + for (let index = 1; index < lastPartIndex; index++) { + const part = parts[index]; + const position = value.indexOf(part); + if (position === -1) { + return false; + } + value = value.slice(position + part.length); + } + return value.endsWith(parts[lastPartIndex]); +}; diff --git a/src/utils/getLogFilterType.d.ts b/src/utils/getLogFilterType.d.ts new file mode 100644 index 00000000000..4e1bedaf89d --- /dev/null +++ b/src/utils/getLogFilterType.d.ts @@ -0,0 +1,5 @@ +import type { RollupLog } from '../rollup/types'; + +export type GetLogFilter = typeof getLogFilter; + +export function getLogFilter(filters: string[]): (log: RollupLog) => boolean; diff --git a/src/utils/getOrCreate.ts b/src/utils/getOrCreate.ts index 8fbf119f4fb..c2bf9cc278c 100644 --- a/src/utils/getOrCreate.ts +++ b/src/utils/getOrCreate.ts @@ -1,9 +1,27 @@ -export function getOrCreate(map: Map, key: K, init: () => V): V { +export function getOrCreate( + map: Map | WeakMap, + key: K, + init: () => V +): V; +export function getOrCreate(map: Map, key: K, init: () => V): V; +export function getOrCreate( + map: Map | WeakMap, + key: K, + init: () => V +): V { const existing = map.get(key); - if (existing) { + if (existing !== undefined) { return existing; } const value = init(); map.set(key, value); return value; } + +export function getNewSet() { + return new Set(); +} + +export function getNewArray(): T[] { + return []; +} diff --git a/src/utils/getOriginalLocation.ts b/src/utils/getOriginalLocation.ts index 1da1d7aa7e5..baeb4425180 100644 --- a/src/utils/getOriginalLocation.ts +++ b/src/utils/getOriginalLocation.ts @@ -1,37 +1,35 @@ -import { DecodedSourceMapOrMissing, ExistingDecodedSourceMap } from '../rollup/types'; +import type { DecodedSourceMapOrMissing, ExistingDecodedSourceMap } from '../rollup/types'; export function getOriginalLocation( - sourcemapChain: DecodedSourceMapOrMissing[], - location: { column: number; line: number; name?: string; source?: string } -) { - // This cast is guaranteed. If it were a missing Map, it wouldn't have a mappings. + sourcemapChain: readonly DecodedSourceMapOrMissing[], + location: { column: number; line: number } +): { column: number; line: number } { const filteredSourcemapChain = sourcemapChain.filter( - sourcemap => sourcemap.mappings - ) as ExistingDecodedSourceMap[]; - - while (filteredSourcemapChain.length > 0) { + (sourcemap): sourcemap is ExistingDecodedSourceMap => !sourcemap.missing + ); + traceSourcemap: while (filteredSourcemapChain.length > 0) { const sourcemap = filteredSourcemapChain.pop()!; const line = sourcemap.mappings[location.line - 1]; - let locationFound = false; - - if (line !== undefined) { - for (const segment of line) { - if (segment[0] >= location.column) { - if (segment.length === 1) break; + if (line) { + const filteredLine = line.filter( + (segment): segment is [number, number, number, number] => segment.length > 1 + ); + const lastSegment = filteredLine[filteredLine.length - 1]; + let previousSegment = filteredLine[0]; + for (let segment of filteredLine) { + if (segment[0] >= location.column || segment === lastSegment) { + const notMatched = segment[0] !== location.column; + segment = notMatched ? previousSegment : segment; location = { column: segment[3], - line: segment[2] + 1, - name: segment.length === 5 ? sourcemap.names[segment[4]] : undefined, - source: sourcemap.sources[segment[1]] + line: segment[2] + 1 }; - locationFound = true; - break; + continue traceSourcemap; } + previousSegment = segment; } } - if (!locationFound) { - throw new Error("Can't resolve original location of error."); - } + throw new Error("Can't resolve original location of error."); } return location; } diff --git a/src/utils/getStaticDependencies.ts b/src/utils/getStaticDependencies.ts index 5d3a447c9f5..4dc93236371 100644 --- a/src/utils/getStaticDependencies.ts +++ b/src/utils/getStaticDependencies.ts @@ -1,23 +1,32 @@ -import Chunk from '../Chunk'; +import type Chunk from '../Chunk'; +import type ExternalChunk from '../ExternalChunk'; import ExternalModule from '../ExternalModule'; -import Module from '../Module'; +import type Module from '../Module'; export function getStaticDependencies( chunk: Chunk, - orderedModules: Module[], - chunkByModule: Map -): Set { - const staticDependencyBlocks: (Chunk | ExternalModule)[][] = []; + orderedModules: readonly Module[], + chunkByModule: ReadonlyMap, + externalChunkByModule: ReadonlyMap +): Set { + const staticDependencyBlocks: (Chunk | ExternalChunk)[][] = []; const handledDependencies = new Set(); for (let modulePos = orderedModules.length - 1; modulePos >= 0; modulePos--) { const module = orderedModules[modulePos]; if (!handledDependencies.has(module)) { - const staticDependencies: (Chunk | ExternalModule)[] = []; - addStaticDependencies(module, staticDependencies, handledDependencies, chunk, chunkByModule); + const staticDependencies: (Chunk | ExternalChunk)[] = []; + addStaticDependencies( + module, + staticDependencies, + handledDependencies, + chunk, + chunkByModule, + externalChunkByModule + ); staticDependencyBlocks.unshift(staticDependencies); } } - const dependencies = new Set(); + const dependencies = new Set(); for (const block of staticDependencyBlocks) { for (const dependency of block) { dependencies.add(dependency); @@ -28,15 +37,16 @@ export function getStaticDependencies( function addStaticDependencies( module: Module, - staticDependencies: (Chunk | ExternalModule)[], + staticDependencies: (Chunk | ExternalChunk)[], handledModules: Set, chunk: Chunk, - chunkByModule: Map + chunkByModule: ReadonlyMap, + externalChunkByModule: ReadonlyMap ): void { const dependencies = module.getDependenciesToBeIncluded(); for (const dependency of dependencies) { if (dependency instanceof ExternalModule) { - staticDependencies.push(dependency); + staticDependencies.push(externalChunkByModule.get(dependency)!); continue; } const dependencyChunk = chunkByModule.get(dependency)!; @@ -46,7 +56,14 @@ function addStaticDependencies( } if (!handledModules.has(dependency)) { handledModules.add(dependency); - addStaticDependencies(dependency, staticDependencies, handledModules, chunk, chunkByModule); + addStaticDependencies( + dependency, + staticDependencies, + handledModules, + chunk, + chunkByModule, + externalChunkByModule + ); } } } diff --git a/src/utils/getter.ts b/src/utils/getter.ts new file mode 100644 index 00000000000..611ed95d899 --- /dev/null +++ b/src/utils/getter.ts @@ -0,0 +1,16 @@ +export function cacheObjectGetters( + object: T, + getterProperties: K[] +) { + for (const property of getterProperties) { + const propertyGetter = Object.getOwnPropertyDescriptor(object, property)!.get!; + Object.defineProperty(object, property, { + get() { + const value = propertyGetter.call(object); + // This replaces the getter with a fixed value for subsequent calls + Object.defineProperty(object, property, { value }); + return value; + } + }); + } +} diff --git a/src/utils/hashPlaceholders.ts b/src/utils/hashPlaceholders.ts new file mode 100644 index 00000000000..91c67b756bd --- /dev/null +++ b/src/utils/hashPlaceholders.ts @@ -0,0 +1,75 @@ +import { toBase64 } from './base64'; +import { error, logFailedValidation } from './logs'; + +// Four random characters from the private use area to minimize risk of +// conflicts +const hashPlaceholderLeft = '!~{'; +const hashPlaceholderRight = '}~'; +const hashPlaceholderOverhead = hashPlaceholderLeft.length + hashPlaceholderRight.length; + +// This is the size of a 128-bits xxhash with base64url encoding +export const MAX_HASH_SIZE = 21; +export const DEFAULT_HASH_SIZE = 8; + +export type HashPlaceholderGenerator = (optionName: string, hashSize: number) => string; + +export const getHashPlaceholderGenerator = (): HashPlaceholderGenerator => { + let nextIndex = 0; + return (optionName, hashSize) => { + if (hashSize > MAX_HASH_SIZE) { + return error( + logFailedValidation( + `Hashes cannot be longer than ${MAX_HASH_SIZE} characters, received ${hashSize}. Check the "${optionName}" option.` + ) + ); + } + const placeholder = `${hashPlaceholderLeft}${toBase64(++nextIndex).padStart( + hashSize - hashPlaceholderOverhead, + '0' + )}${hashPlaceholderRight}`; + if (placeholder.length > hashSize) { + return error( + logFailedValidation( + `To generate hashes for this number of chunks (currently ${nextIndex}), you need a minimum hash size of ${placeholder.length}, received ${hashSize}. Check the "${optionName}" option.` + ) + ); + } + return placeholder; + }; +}; + +const REPLACER_REGEX = new RegExp( + `${hashPlaceholderLeft}[0-9a-zA-Z_$]{1,${ + MAX_HASH_SIZE - hashPlaceholderOverhead + }}${hashPlaceholderRight}`, + 'g' +); + +export const replacePlaceholders = ( + code: string, + hashesByPlaceholder: Map +): string => + code.replace(REPLACER_REGEX, placeholder => hashesByPlaceholder.get(placeholder) || placeholder); + +export const replaceSinglePlaceholder = ( + code: string, + placeholder: string, + value: string +): string => code.replace(REPLACER_REGEX, match => (match === placeholder ? value : match)); + +export const replacePlaceholdersWithDefaultAndGetContainedPlaceholders = ( + code: string, + placeholders: Set +): { containedPlaceholders: Set; transformedCode: string } => { + const containedPlaceholders = new Set(); + const transformedCode = code.replace(REPLACER_REGEX, placeholder => { + if (placeholders.has(placeholder)) { + containedPlaceholders.add(placeholder); + return `${hashPlaceholderLeft}${'0'.repeat( + placeholder.length - hashPlaceholderOverhead + )}${hashPlaceholderRight}`; + } + return placeholder; + }); + return { containedPlaceholders, transformedCode }; +}; diff --git a/src/utils/hookActions.ts b/src/utils/hookActions.ts new file mode 100644 index 00000000000..c2143332a00 --- /dev/null +++ b/src/utils/hookActions.ts @@ -0,0 +1,63 @@ +import process from 'node:process'; +import type { HookAction, PluginDriver } from './PluginDriver'; + +function formatAction([pluginName, hookName, parameters]: HookAction): string { + const action = `(${pluginName}) ${hookName}`; + const s = JSON.stringify; + switch (hookName) { + case 'resolveId': { + return `${action} ${s(parameters[0])} ${s(parameters[1])}`; + } + case 'load': { + return `${action} ${s(parameters[0])}`; + } + case 'transform': { + return `${action} ${s(parameters[1])}`; + } + case 'shouldTransformCachedModule': { + return `${action} ${s((parameters[0] as { id: string }).id)}`; + } + case 'moduleParsed': { + return `${action} ${s((parameters[0] as { id: string }).id)}`; + } + } + return action; +} + +let handleBeforeExit: null | (() => void) = null; +const rejectByPluginDriver = new Map void>(); + +export async function catchUnfinishedHookActions( + pluginDriver: PluginDriver, + callback: () => Promise +): Promise { + const emptyEventLoopPromise = new Promise((_, reject) => { + rejectByPluginDriver.set(pluginDriver, reject); + if (!handleBeforeExit) { + // We only ever create a single event listener to avoid max listener and + // other issues + handleBeforeExit = () => { + for (const [pluginDriver, reject] of rejectByPluginDriver) { + const unfulfilledActions = pluginDriver.getUnfulfilledHookActions(); + reject( + new Error( + `Unexpected early exit. This happens when Promises returned by plugins cannot resolve. Unfinished hook action(s) on exit:\n` + + [...unfulfilledActions].map(formatAction).join('\n') + ) + ); + } + }; + process.once('beforeExit', handleBeforeExit); + } + }); + + try { + return await Promise.race([callback(), emptyEventLoopPromise]); + } finally { + rejectByPluginDriver.delete(pluginDriver); + if (rejectByPluginDriver.size === 0) { + process.off('beforeExit', handleBeforeExit!); + handleBeforeExit = null; + } + } +} diff --git a/src/utils/identifierHelpers.ts b/src/utils/identifierHelpers.ts index b03d78dc606..0150752bb83 100644 --- a/src/utils/identifierHelpers.ts +++ b/src/utils/identifierHelpers.ts @@ -1,27 +1,45 @@ -export const reservedWords = 'break case class catch const continue debugger default delete do else export extends finally for function if import in instanceof let new return super switch this throw try typeof var void while with yield enum await implements package protected static interface private public'.split( - ' ' -); -const builtins = 'Infinity NaN undefined null true false eval uneval isFinite isNaN parseFloat parseInt decodeURI decodeURIComponent encodeURI encodeURIComponent escape unescape Object Function Boolean Symbol Error EvalError InternalError RangeError ReferenceError SyntaxError TypeError URIError Number Math Date String RegExp Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array Map Set WeakMap WeakSet SIMD ArrayBuffer DataView JSON Promise Generator GeneratorFunction Reflect Proxy Intl'.split( - ' ' -); +import RESERVED_NAMES from './RESERVED_NAMES'; -const blacklisted = new Set(reservedWords.concat(builtins)); +const illegalCharacters = /[^\w$]/g; -const illegalCharacters = /[^$_a-zA-Z0-9]/g; +const startsWithDigit = (value: string): boolean => /\d/.test(value[0]); -const startsWithDigit = (str: string) => /\d/.test(str[0]); +const needsEscape = (value: string) => + startsWithDigit(value) || RESERVED_NAMES.has(value) || value === 'arguments'; -export function isLegal(str: string): boolean { - if (startsWithDigit(str) || blacklisted.has(str)) { +export function isLegal(value: string): boolean { + if (needsEscape(value)) { return false; } - return !illegalCharacters.test(str); + return !illegalCharacters.test(value); } -export function makeLegal(str: string): string { - str = str.replace(/-(\w)/g, (_, letter) => letter.toUpperCase()).replace(illegalCharacters, '_'); +export function makeLegal(value: string): string { + value = value + .replace(/-(\w)/g, (_, letter) => letter.toUpperCase()) + .replace(illegalCharacters, '_'); - if (startsWithDigit(str) || blacklisted.has(str)) str = `_${str}`; + if (needsEscape(value)) value = `_${value}`; - return str || '_'; + return value || '_'; +} + +export const VALID_IDENTIFIER_REGEXP = /^[$_\p{ID_Start}][$\u200C\u200D\p{ID_Continue}]*$/u; +const NUMBER_REGEXP = /^(?:0|[1-9]\d*)$/; + +export function stringifyObjectKeyIfNeeded(key: string) { + if (VALID_IDENTIFIER_REGEXP.test(key)) { + return key === '__proto__' ? '["__proto__"]' : key; + } + if (NUMBER_REGEXP.test(key) && +key <= Number.MAX_SAFE_INTEGER) { + return key; + } + return JSON.stringify(key); +} + +export function stringifyIdentifierIfNeeded(key: string) { + if (VALID_IDENTIFIER_REGEXP.test(key)) { + return key; + } + return JSON.stringify(key); } diff --git a/src/utils/initWasm.ts b/src/utils/initWasm.ts new file mode 100644 index 00000000000..9cd42c723ee --- /dev/null +++ b/src/utils/initWasm.ts @@ -0,0 +1 @@ +export default async function initWasm() {} diff --git a/src/utils/interopHelpers.ts b/src/utils/interopHelpers.ts index 77aaacba46a..11626226a3f 100644 --- a/src/utils/interopHelpers.ts +++ b/src/utils/interopHelpers.ts @@ -1,184 +1,358 @@ +import type { InteropType } from '../rollup/types'; +import type { GenerateCodeSnippets } from './generateCodeSnippets'; + const INTEROP_DEFAULT_VARIABLE = '_interopDefault'; -const INTEROP_DEFAULT_LEGACY_VARIABLE = '_interopDefaultLegacy'; +const INTEROP_DEFAULT_COMPAT_VARIABLE = '_interopDefaultCompat'; const INTEROP_NAMESPACE_VARIABLE = '_interopNamespace'; +const INTEROP_NAMESPACE_COMPAT_VARIABLE = '_interopNamespaceCompat'; const INTEROP_NAMESPACE_DEFAULT_VARIABLE = '_interopNamespaceDefault'; -const INTEROP_NAMESPACE_DEFAULT_ONLY_VARIABLE = '_interopNamespaceDefaultOnly'; +export const INTEROP_NAMESPACE_DEFAULT_ONLY_VARIABLE = '_interopNamespaceDefaultOnly'; +export const MERGE_NAMESPACES_VARIABLE = '_mergeNamespaces'; +export const DOCUMENT_CURRENT_SCRIPT = '_documentCurrentScript'; -export const defaultInteropHelpersByInteropType: { [interopType: string]: string | null } = { +export const defaultInteropHelpersByInteropType: Record = { auto: INTEROP_DEFAULT_VARIABLE, + compat: INTEROP_DEFAULT_COMPAT_VARIABLE, default: null, defaultOnly: null, - esModule: null, - false: null, - true: INTEROP_DEFAULT_LEGACY_VARIABLE + esModule: null }; -export function isDefaultAProperty(interopType: string, externalLiveBindings: boolean) { - return ( - interopType === 'esModule' || - (externalLiveBindings && (interopType === 'auto' || interopType === 'true')) - ); -} +export const isDefaultAProperty = ( + interopType: InteropType, + externalLiveBindings: boolean +): boolean => + interopType === 'esModule' || + (externalLiveBindings && (interopType === 'auto' || interopType === 'compat')); -export const namespaceInteropHelpersByInteropType: { [interopType: string]: string | null } = { +export const namespaceInteropHelpersByInteropType: Record = { auto: INTEROP_NAMESPACE_VARIABLE, + compat: INTEROP_NAMESPACE_COMPAT_VARIABLE, default: INTEROP_NAMESPACE_DEFAULT_VARIABLE, defaultOnly: INTEROP_NAMESPACE_DEFAULT_ONLY_VARIABLE, - esModule: null, - false: null, - true: INTEROP_NAMESPACE_VARIABLE + esModule: null }; -export function canDefaultBeTakenFromNamespace(interopType: string, externalLiveBindings: boolean) { - return ( - isDefaultAProperty(interopType, externalLiveBindings) && - defaultInteropHelpersByInteropType[interopType] === INTEROP_DEFAULT_VARIABLE - ); -} - -export function getDefaultOnlyHelper(): string { - return INTEROP_NAMESPACE_DEFAULT_ONLY_VARIABLE; -} +export const canDefaultBeTakenFromNamespace = ( + interopType: InteropType, + externalLiveBindings: boolean +): boolean => interopType !== 'esModule' && isDefaultAProperty(interopType, externalLiveBindings); -export function getHelpersBlock( - usedHelpers: Set, - accessedGlobals: Set, - _: string, - n: string, - s: string, - t: string, +export const getHelpersBlock = ( + additionalHelpers: ReadonlySet | null, + accessedGlobals: ReadonlySet, + indent: string, + snippets: GenerateCodeSnippets, liveBindings: boolean, freeze: boolean, - namespaceToStringTag: boolean -): string { + symbols: boolean +): string => { + const usedHelpers = new Set(additionalHelpers); + for (const variable of HELPER_NAMES) { + if (accessedGlobals.has(variable)) { + usedHelpers.add(variable); + } + } return HELPER_NAMES.map(variable => - usedHelpers.has(variable) || accessedGlobals.has(variable) - ? HELPER_GENERATORS[variable]( - _, - n, - s, - t, - liveBindings, - freeze, - namespaceToStringTag, - usedHelpers - ) + usedHelpers.has(variable) + ? HELPER_GENERATORS[variable](indent, snippets, liveBindings, freeze, symbols, usedHelpers) : '' ).join(''); -} +}; -const HELPER_GENERATORS: { - [variable: string]: ( - _: string, - n: string, - s: string, - t: string, +const HELPER_GENERATORS: Record< + string, + ( + indent: string, + snippets: GenerateCodeSnippets, liveBindings: boolean, freeze: boolean, - namespaceToStringTag: boolean, - usedHelpers: Set - ) => string; -} = { - [INTEROP_DEFAULT_VARIABLE]: (_, n, s, _t, liveBindings) => - `function ${INTEROP_DEFAULT_VARIABLE}${_}(e)${_}{${_}return ` + - `e${_}&&${_}e.__esModule${_}?${_}` + - `${liveBindings ? getDefaultLiveBinding(_) : getDefaultStatic(_)}${s}${_}}${n}${n}`, - [INTEROP_DEFAULT_LEGACY_VARIABLE]: (_, n, s, _t, liveBindings) => - `function ${INTEROP_DEFAULT_LEGACY_VARIABLE}${_}(e)${_}{${_}return ` + - `e${_}&&${_}typeof e${_}===${_}'object'${_}&&${_}'default'${_}in e${_}?${_}` + - `${liveBindings ? getDefaultLiveBinding(_) : getDefaultStatic(_)}${s}${_}}${n}${n}`, - [INTEROP_NAMESPACE_VARIABLE]: ( - _, - n, - s, - t, - liveBindings, - freeze, - namespaceToStringTag, - usedHelpers - ) => - `function ${INTEROP_NAMESPACE_VARIABLE}(e)${_}{${n}` + - (usedHelpers.has(INTEROP_NAMESPACE_DEFAULT_VARIABLE) - ? `${t}return e${_}&&${_}e.__esModule${_}?${_}e${_}:${_}${INTEROP_NAMESPACE_DEFAULT_VARIABLE}(e)${s}${n}` - : `${t}if${_}(e${_}&&${_}e.__esModule)${_}return e;${n}` + - createNamespaceObject(_, n, t, t, liveBindings, freeze, namespaceToStringTag)) + - `}${n}${n}`, - [INTEROP_NAMESPACE_DEFAULT_VARIABLE]: (_, n, _s, t, liveBindings, freeze, namespaceToStringTag) => - `function ${INTEROP_NAMESPACE_DEFAULT_VARIABLE}(e)${_}{${n}` + - createNamespaceObject(_, n, t, t, liveBindings, freeze, namespaceToStringTag) + - `}${n}${n}`, - [INTEROP_NAMESPACE_DEFAULT_ONLY_VARIABLE]: ( - _: string, - n: string, - _s: string, - t: string, + symbols: boolean, + usedHelpers: ReadonlySet + ) => string +> = { + [DOCUMENT_CURRENT_SCRIPT](_t, { _, n }) { + return `var ${DOCUMENT_CURRENT_SCRIPT}${_}=${_}typeof document${_}!==${_}'undefined'${_}?${_}document.currentScript${_}:${_}null;${n}`; + }, + [INTEROP_DEFAULT_COMPAT_VARIABLE](_t, snippets, liveBindings) { + const { _, getDirectReturnFunction, n } = snippets; + const [left, right] = getDirectReturnFunction(['e'], { + functionReturn: true, + lineBreakIndent: null, + name: INTEROP_DEFAULT_COMPAT_VARIABLE + }); + return ( + `${left}${getIsCompatNamespace(snippets)}${_}?${_}` + + `${ + liveBindings ? getDefaultLiveBinding(snippets) : getDefaultStatic(snippets) + }${right}${n}${n}` + ); + }, + [INTEROP_DEFAULT_VARIABLE](_t, snippets, liveBindings) { + const { _, getDirectReturnFunction, n } = snippets; + const [left, right] = getDirectReturnFunction(['e'], { + functionReturn: true, + lineBreakIndent: null, + name: INTEROP_DEFAULT_VARIABLE + }); + return ( + `${left}e${_}&&${_}e.__esModule${_}?${_}` + + `${ + liveBindings ? getDefaultLiveBinding(snippets) : getDefaultStatic(snippets) + }${right}${n}${n}` + ); + }, + [INTEROP_NAMESPACE_COMPAT_VARIABLE](t, snippets, liveBindings, freeze, symbols, usedHelpers) { + const { _, getDirectReturnFunction, n } = snippets; + if (usedHelpers.has(INTEROP_NAMESPACE_DEFAULT_VARIABLE)) { + const [left, right] = getDirectReturnFunction(['e'], { + functionReturn: true, + lineBreakIndent: null, + name: INTEROP_NAMESPACE_COMPAT_VARIABLE + }); + return `${left}${getIsCompatNamespace( + snippets + )}${_}?${_}e${_}:${_}${INTEROP_NAMESPACE_DEFAULT_VARIABLE}(e)${right}${n}${n}`; + } + return ( + `function ${INTEROP_NAMESPACE_COMPAT_VARIABLE}(e)${_}{${n}` + + `${t}if${_}(${getIsCompatNamespace(snippets)})${_}return e;${n}` + + createNamespaceObject(t, t, snippets, liveBindings, freeze, symbols) + + `}${n}${n}` + ); + }, + [INTEROP_NAMESPACE_DEFAULT_ONLY_VARIABLE]( + _t, + snippets, _liveBindings: boolean, freeze: boolean, - namespaceToStringTag: boolean - ) => - `function ${INTEROP_NAMESPACE_DEFAULT_ONLY_VARIABLE}(e)${_}{${n}` + - `${t}return ${getFrozen( - `{__proto__: null,${ - namespaceToStringTag ? `${_}[Symbol.toStringTag]:${_}'Module',` : '' - }${_}'default':${_}e}`, - freeze - )};${n}` + - `}${n}${n}` + symbols: boolean + ) { + const { getDirectReturnFunction, getObject, n, _ } = snippets; + const [left, right] = getDirectReturnFunction(['e'], { + functionReturn: true, + lineBreakIndent: null, + name: INTEROP_NAMESPACE_DEFAULT_ONLY_VARIABLE + }); + return `${left}${getFrozen( + freeze, + getWithToStringTag( + symbols, + getObject( + [ + [null, `__proto__:${_}null`], + ['default', 'e'] + ], + { lineBreakIndent: null } + ), + snippets + ) + )}${right}${n}${n}`; + }, + [INTEROP_NAMESPACE_DEFAULT_VARIABLE](t, snippets, liveBindings, freeze, symbols) { + const { _, n } = snippets; + return ( + `function ${INTEROP_NAMESPACE_DEFAULT_VARIABLE}(e)${_}{${n}` + + createNamespaceObject(t, t, snippets, liveBindings, freeze, symbols) + + `}${n}${n}` + ); + }, + [INTEROP_NAMESPACE_VARIABLE](t, snippets, liveBindings, freeze, symbols, usedHelpers) { + const { _, getDirectReturnFunction, n } = snippets; + if (usedHelpers.has(INTEROP_NAMESPACE_DEFAULT_VARIABLE)) { + const [left, right] = getDirectReturnFunction(['e'], { + functionReturn: true, + lineBreakIndent: null, + name: INTEROP_NAMESPACE_VARIABLE + }); + return `${left}e${_}&&${_}e.__esModule${_}?${_}e${_}:${_}${INTEROP_NAMESPACE_DEFAULT_VARIABLE}(e)${right}${n}${n}`; + } + return ( + `function ${INTEROP_NAMESPACE_VARIABLE}(e)${_}{${n}` + + `${t}if${_}(e${_}&&${_}e.__esModule)${_}return e;${n}` + + createNamespaceObject(t, t, snippets, liveBindings, freeze, symbols) + + `}${n}${n}` + ); + }, + [MERGE_NAMESPACES_VARIABLE](t, snippets, liveBindings, freeze, symbols) { + const { _, cnst, n } = snippets; + const useForEach = cnst === 'var' && liveBindings; + return ( + `function ${MERGE_NAMESPACES_VARIABLE}(n, m)${_}{${n}` + + `${t}${loopOverNamespaces( + `{${n}` + + `${t}${t}${t}if${_}(k${_}!==${_}'default'${_}&&${_}!(k in n))${_}{${n}` + + (liveBindings + ? useForEach + ? copyOwnPropertyLiveBinding + : copyPropertyLiveBinding + : copyPropertyStatic)(t, t + t + t + t, snippets) + + `${t}${t}${t}}${n}` + + `${t}${t}}`, + useForEach, + t, + snippets + )}${n}` + + `${t}return ${getFrozen(freeze, getWithToStringTag(symbols, 'n', snippets))};${n}` + + `}${n}${n}` + ); + } }; -function getDefaultLiveBinding(_: string) { - return `e${_}:${_}{${_}'default':${_}e${_}}`; -} +const getDefaultLiveBinding = ({ _, getObject }: GenerateCodeSnippets) => + `e${_}:${_}${getObject([['default', 'e']], { lineBreakIndent: null })}`; -function getDefaultStatic(_: string) { - return `e['default']${_}:${_}e`; -} +const getDefaultStatic = ({ _, getPropertyAccess }: GenerateCodeSnippets) => + `e${getPropertyAccess('default')}${_}:${_}e`; -function createNamespaceObject( - _: string, - n: string, +const getIsCompatNamespace = ({ _ }: GenerateCodeSnippets) => + `e${_}&&${_}typeof e${_}===${_}'object'${_}&&${_}'default'${_}in e`; + +const createNamespaceObject = ( t: string, - i: string, + index: string, + snippets: GenerateCodeSnippets, liveBindings: boolean, freeze: boolean, - namespaceToStringTag: boolean -) { + symbols: boolean +) => { + const { _, cnst, getObject, getPropertyAccess, n, s } = snippets; + const copyProperty = + `{${n}` + + (liveBindings ? copyNonDefaultOwnPropertyLiveBinding : copyPropertyStatic)( + t, + index + t + t, + snippets + ) + + `${index}${t}}`; return ( - `${i}var n${_}=${_}${ - namespaceToStringTag - ? `{__proto__:${_}null,${_}[Symbol.toStringTag]:${_}'Module'}` - : 'Object.create(null)' - };${n}` + - `${i}if${_}(e)${_}{${n}` + - `${i}${t}Object.keys(e).forEach(function${_}(k)${_}{${n}` + - (liveBindings ? copyPropertyLiveBinding : copyPropertyStatic)(_, n, t, i + t + t) + - `${i}${t}});${n}` + - `${i}}${n}` + - `${i}n['default']${_}=${_}e;${n}` + - `${i}return ${getFrozen('n', freeze)};${n}` + `${index}${cnst} n${_}=${_}Object.create(null${ + symbols ? `,${_}{${_}[Symbol.toStringTag]:${_}${getToStringTagValue(getObject)}${_}}` : '' + });${n}` + + `${index}if${_}(e)${_}{${n}` + + `${index}${t}${loopOverKeys(copyProperty, !liveBindings, snippets)}${n}` + + `${index}}${n}` + + `${index}n${getPropertyAccess('default')}${_}=${_}e;${n}` + + `${index}return ${getFrozen(freeze, 'n')}${s}${n}` ); -} +}; + +const loopOverKeys = ( + body: string, + allowVariableLoopVariable: boolean, + { _, cnst, getFunctionIntro, s }: GenerateCodeSnippets +) => + cnst !== 'var' || allowVariableLoopVariable + ? `for${_}(${cnst} k in e)${_}${body}` + : `Object.keys(e).forEach(${getFunctionIntro(['k'], { + isAsync: false, + name: null + })}${body})${s}`; -function copyPropertyLiveBinding(_: string, n: string, t: string, i: string) { +const loopOverNamespaces = ( + body: string, + useForEach: boolean, + t: string, + { _, cnst, getDirectReturnFunction, getFunctionIntro, n }: GenerateCodeSnippets +) => { + if (useForEach) { + const [left, right] = getDirectReturnFunction(['e'], { + functionReturn: false, + lineBreakIndent: { base: t, t }, + name: null + }); + return ( + `m.forEach(${left}` + + `e${_}&&${_}typeof e${_}!==${_}'string'${_}&&${_}!Array.isArray(e)${_}&&${_}Object.keys(e).forEach(${getFunctionIntro( + ['k'], + { + isAsync: false, + name: null + } + )}${body})${right});` + ); + } return ( - `${i}if${_}(k${_}!==${_}'default')${_}{${n}` + - `${i}${t}var d${_}=${_}Object.getOwnPropertyDescriptor(e,${_}k);${n}` + - `${i}${t}Object.defineProperty(n,${_}k,${_}d.get${_}?${_}d${_}:${_}{${n}` + - `${i}${t}${t}enumerable:${_}true,${n}` + - `${i}${t}${t}get:${_}function${_}()${_}{${n}` + - `${i}${t}${t}${t}return e[k];${n}` + - `${i}${t}${t}}${n}` + - `${i}${t}});${n}` + - `${i}}${n}` + `for${_}(var i${_}=${_}0;${_}i${_}<${_}m.length;${_}i++)${_}{${n}` + + `${t}${t}${cnst} e${_}=${_}m[i];${n}` + + `${t}${t}if${_}(typeof e${_}!==${_}'string'${_}&&${_}!Array.isArray(e))${_}{${_}for${_}(${cnst} k in e)${_}${body}${_}}${n}${t}}` ); -} +}; -function copyPropertyStatic(_: string, n: string, _t: string, i: string) { - return `${i}n[k]${_}=${_}e[k];${n}`; -} +const copyNonDefaultOwnPropertyLiveBinding = ( + t: string, + index: string, + snippets: GenerateCodeSnippets +) => { + const { _, n } = snippets; + return ( + `${index}if${_}(k${_}!==${_}'default')${_}{${n}` + + copyOwnPropertyLiveBinding(t, index + t, snippets) + + `${index}}${n}` + ); +}; -function getFrozen(fragment: string, freeze: boolean) { - return freeze ? `Object.freeze(${fragment})` : fragment; -} +const copyOwnPropertyLiveBinding = ( + t: string, + index: string, + { _, cnst, getDirectReturnFunction, n }: GenerateCodeSnippets +) => { + const [left, right] = getDirectReturnFunction([], { + functionReturn: true, + lineBreakIndent: null, + name: null + }); + return ( + `${index}${cnst} d${_}=${_}Object.getOwnPropertyDescriptor(e,${_}k);${n}` + + `${index}Object.defineProperty(n,${_}k,${_}d.get${_}?${_}d${_}:${_}{${n}` + + `${index}${t}enumerable:${_}true,${n}` + + `${index}${t}get:${_}${left}e[k]${right}${n}` + + `${index}});${n}` + ); +}; + +const copyPropertyLiveBinding = ( + t: string, + index: string, + { _, cnst, getDirectReturnFunction, n }: GenerateCodeSnippets +) => { + const [left, right] = getDirectReturnFunction([], { + functionReturn: true, + lineBreakIndent: null, + name: null + }); + return ( + `${index}${cnst} d${_}=${_}Object.getOwnPropertyDescriptor(e,${_}k);${n}` + + `${index}if${_}(d)${_}{${n}` + + `${index}${t}Object.defineProperty(n,${_}k,${_}d.get${_}?${_}d${_}:${_}{${n}` + + `${index}${t}${t}enumerable:${_}true,${n}` + + `${index}${t}${t}get:${_}${left}e[k]${right}${n}` + + `${index}${t}});${n}` + + `${index}}${n}` + ); +}; + +const copyPropertyStatic = (_t: string, index: string, { _, n }: GenerateCodeSnippets) => + `${index}n[k]${_}=${_}e[k];${n}`; + +const getFrozen = (freeze: boolean, fragment: string) => + freeze ? `Object.freeze(${fragment})` : fragment; + +const getWithToStringTag = ( + symbols: boolean, + fragment: string, + { _, getObject }: GenerateCodeSnippets +) => + symbols + ? `Object.defineProperty(${fragment},${_}Symbol.toStringTag,${_}${getToStringTagValue( + getObject + )})` + : fragment; export const HELPER_NAMES = Object.keys(HELPER_GENERATORS); + +export function getToStringTagValue(getObject: GenerateCodeSnippets['getObject']) { + return getObject([['value', "'Module'"]], { + lineBreakIndent: null + }); +} diff --git a/src/utils/iterators.ts b/src/utils/iterators.ts new file mode 100644 index 00000000000..a18af232222 --- /dev/null +++ b/src/utils/iterators.ts @@ -0,0 +1,10 @@ +/** + * Concatenate a number of iterables to a new iterable without fully evaluating + * their iterators. Useful when e.g. working with large sets or lists and when + * there is a chance that the iterators will not be fully exhausted. + */ +export function* concatLazy(iterables: Iterable[]): Iterable { + for (const iterable of iterables) { + yield* iterable; + } +} diff --git a/src/utils/jsx.ts b/src/utils/jsx.ts new file mode 100644 index 00000000000..e2e2d502fe0 --- /dev/null +++ b/src/utils/jsx.ts @@ -0,0 +1,23 @@ +import type JSXElement from '../ast/nodes/JSXElement'; +import JSXEmptyExpression from '../ast/nodes/JSXEmptyExpression'; +import JSXExpressionContainer from '../ast/nodes/JSXExpressionContainer'; +import type JSXFragment from '../ast/nodes/JSXFragment'; +import type JSXSpreadChild from '../ast/nodes/JSXSpreadChild'; +import JSXText from '../ast/nodes/JSXText'; + +export function getRenderedJsxChildren( + children: (JSXText | JSXExpressionContainer | JSXElement | JSXFragment | JSXSpreadChild)[] +) { + let renderedChildren = 0; + for (const child of children) { + if ( + !( + child instanceof JSXExpressionContainer && child.expression instanceof JSXEmptyExpression + ) && + (!(child instanceof JSXText) || child.shouldRender()) + ) { + renderedChildren++; + } + } + return renderedChildren; +} diff --git a/src/utils/logHandler.ts b/src/utils/logHandler.ts new file mode 100644 index 00000000000..c6be1e63d39 --- /dev/null +++ b/src/utils/logHandler.ts @@ -0,0 +1,34 @@ +import type { + LoggingFunctionWithPosition, + LogHandler, + LogLevel, + LogLevelOption +} from '../rollup/types'; +import { doNothing } from './doNothing'; +import { LOGLEVEL_WARN, logLevelPriority } from './logging'; +import { logInvalidLogPosition } from './logs'; +import { normalizeLog } from './options/options'; + +export function getLogHandler( + level: LogLevel, + code: string, + logger: LogHandler, + pluginName: string, + logLevel: LogLevelOption +): LoggingFunctionWithPosition { + if (logLevelPriority[level] < logLevelPriority[logLevel]) { + return doNothing; + } + return (log, pos) => { + if (pos != null) { + logger(LOGLEVEL_WARN, logInvalidLogPosition(pluginName)); + } + log = normalizeLog(log); + if (log.code && !log.pluginCode) { + log.pluginCode = log.code; + } + log.code = code; + log.plugin = pluginName; + logger(level, log); + }; +} diff --git a/src/utils/logger.ts b/src/utils/logger.ts new file mode 100644 index 00000000000..f03229a8d77 --- /dev/null +++ b/src/utils/logger.ts @@ -0,0 +1,64 @@ +import { version as rollupVersion } from 'package.json'; +import type { + LoggingFunction, + LogHandler, + LogLevel, + LogLevelOption, + Plugin, + RollupLog +} from '../rollup/types'; +import { getSortedValidatedPlugins } from './PluginDriver'; +import { EMPTY_SET } from './blank'; +import { doNothing } from './doNothing'; +import { LOGLEVEL_DEBUG, LOGLEVEL_INFO, LOGLEVEL_WARN, logLevelPriority } from './logging'; +import { augmentLogMessage, error } from './logs'; +import { normalizeLog } from './options/options'; + +export function getLogger( + plugins: Plugin[], + onLog: LogHandler, + watchMode: boolean, + logLevel: LogLevelOption +): LogHandler { + plugins = getSortedValidatedPlugins('onLog', plugins); + const minimalPriority = logLevelPriority[logLevel]; + const logger = (level: LogLevel, log: RollupLog, skipped: ReadonlySet = EMPTY_SET) => { + augmentLogMessage(log); + const logPriority = logLevelPriority[level]; + if (logPriority < minimalPriority) { + return; + } + for (const plugin of plugins) { + if (skipped.has(plugin)) continue; + + const { onLog: pluginOnLog } = plugin; + + const getLogHandler = (level: LogLevel): LoggingFunction => { + if (logLevelPriority[level] < minimalPriority) { + return doNothing; + } + return log => logger(level, normalizeLog(log), new Set(skipped).add(plugin)); + }; + + const handler = 'handler' in pluginOnLog! ? pluginOnLog.handler : pluginOnLog!; + if ( + handler.call( + { + debug: getLogHandler(LOGLEVEL_DEBUG), + error: (log): never => error(normalizeLog(log)), + info: getLogHandler(LOGLEVEL_INFO), + meta: { rollupVersion, watchMode }, + warn: getLogHandler(LOGLEVEL_WARN) + }, + level, + log + ) === false + ) { + return; + } + } + onLog(level, log); + }; + + return logger; +} diff --git a/src/utils/logging.ts b/src/utils/logging.ts new file mode 100644 index 00000000000..cbd48ee20b0 --- /dev/null +++ b/src/utils/logging.ts @@ -0,0 +1,14 @@ +import type { LogLevel, LogLevelOption } from '../rollup/types'; + +export const LOGLEVEL_SILENT: LogLevelOption = 'silent'; +export const LOGLEVEL_ERROR = 'error'; +export const LOGLEVEL_WARN: LogLevel = 'warn'; +export const LOGLEVEL_INFO: LogLevel = 'info'; +export const LOGLEVEL_DEBUG: LogLevel = 'debug'; + +export const logLevelPriority: Record = { + [LOGLEVEL_DEBUG]: 0, + [LOGLEVEL_INFO]: 1, + [LOGLEVEL_SILENT]: 3, + [LOGLEVEL_WARN]: 2 +}; diff --git a/src/utils/logs.ts b/src/utils/logs.ts new file mode 100644 index 00000000000..415537f016b --- /dev/null +++ b/src/utils/logs.ts @@ -0,0 +1,1206 @@ +import { locate } from 'locate-character'; +import type Module from '../Module'; +import type { + InternalModuleFormat, + LogHandler, + NormalizedInputOptions, + RollupLog +} from '../rollup/types'; +import type { AnnotationType } from './astConverterHelpers'; +import getCodeFrame from './getCodeFrame'; +import { LOGLEVEL_WARN } from './logging'; +import { extname } from './path'; +import { printQuotedStringList } from './printStringList'; +import relativeId from './relativeId'; +import { getRollupUrl } from './url'; +import { + URL_A_SIMPLE_EXAMPLE, + URL_AVOIDING_EVAL, + URL_BUNDLE_CONFIG_AS_CJS, + URL_CONFIGURATION_FILES, + URL_JSX, + URL_NAME_IS_NOT_EXPORTED, + URL_OUTPUT_DIR, + URL_OUTPUT_EXPORTS, + URL_OUTPUT_EXTEND, + URL_OUTPUT_GLOBALS, + URL_OUTPUT_INTEROP, + URL_OUTPUT_NAME, + URL_SOURCEMAP_IS_LIKELY_TO_BE_INCORRECT, + URL_THIS_IS_UNDEFINED, + URL_TREATING_MODULE_AS_EXTERNAL_DEPENDENCY, + URL_TREESHAKE_NOSIDEEFFECTS, + URL_TREESHAKE_PURE +} from './urls'; + +export function error(base: Error | RollupLog): never { + throw base instanceof Error ? base : getRollupError(base); +} + +export function getRollupError(base: RollupLog): Error & RollupLog { + augmentLogMessage(base); + const errorInstance = Object.assign(new Error(base.message), base); + Object.defineProperty(errorInstance, 'name', { + value: 'RollupError', + writable: true + }); + return errorInstance; +} + +export function augmentCodeLocation( + properties: RollupLog, + pos: number | { column: number; line: number }, + source: string, + id: string +): void { + if (typeof pos === 'object') { + const { line, column } = pos; + properties.loc = { column, file: id, line }; + } else { + properties.pos = pos; + const location = locate(source, pos, { offsetLine: 1 }); + if (!location) { + return; + } + const { line, column } = location; + properties.loc = { column, file: id, line }; + } + + if (properties.frame === undefined) { + const { line, column } = properties.loc; + properties.frame = getCodeFrame(source, line, column); + } +} + +const symbolAugmented = Symbol('augmented'); + +interface AugmentedRollupLog extends RollupLog { + [symbolAugmented]?: boolean; +} + +export function augmentLogMessage(log: AugmentedRollupLog): void { + // Make sure to only augment the log message once + if (!(log.plugin || log.loc) || log[symbolAugmented]) { + return; + } + log[symbolAugmented] = true; + let prefix = ''; + + if (log.plugin) { + prefix += `[plugin ${log.plugin}] `; + } + const id = log.id || log.loc?.file; + if (id) { + const position = log.loc ? ` (${log.loc.line}:${log.loc.column})` : ''; + prefix += `${relativeId(id)}${position}: `; + } + const oldMessage = log.message; + log.message = prefix + log.message; + tweakStackMessage(log, oldMessage); +} + +// Error codes should be sorted alphabetically while errors should be sorted by +// error code below +const ADDON_ERROR = 'ADDON_ERROR', + ALREADY_CLOSED = 'ALREADY_CLOSED', + AMBIGUOUS_EXTERNAL_NAMESPACES = 'AMBIGUOUS_EXTERNAL_NAMESPACES', + ANONYMOUS_PLUGIN_CACHE = 'ANONYMOUS_PLUGIN_CACHE', + ASSET_NOT_FINALISED = 'ASSET_NOT_FINALISED', + ASSET_NOT_FOUND = 'ASSET_NOT_FOUND', + ASSET_SOURCE_ALREADY_SET = 'ASSET_SOURCE_ALREADY_SET', + ASSET_SOURCE_MISSING = 'ASSET_SOURCE_MISSING', + BAD_LOADER = 'BAD_LOADER', + CANNOT_CALL_NAMESPACE = 'CANNOT_CALL_NAMESPACE', + CANNOT_EMIT_FROM_OPTIONS_HOOK = 'CANNOT_EMIT_FROM_OPTIONS_HOOK', + CHUNK_NOT_GENERATED = 'CHUNK_NOT_GENERATED', + CHUNK_INVALID = 'CHUNK_INVALID', + CIRCULAR_CHUNK = 'CIRCULAR_CHUNK', + CIRCULAR_DEPENDENCY = 'CIRCULAR_DEPENDENCY', + CIRCULAR_REEXPORT = 'CIRCULAR_REEXPORT', + CONST_REASSIGN = 'CONST_REASSIGN', + CYCLIC_CROSS_CHUNK_REEXPORT = 'CYCLIC_CROSS_CHUNK_REEXPORT', + DEPRECATED_FEATURE = 'DEPRECATED_FEATURE', + DUPLICATE_ARGUMENT_NAME = 'DUPLICATE_ARGUMENT_NAME', + DUPLICATE_EXPORT = 'DUPLICATE_EXPORT', + DUPLICATE_IMPORT_OPTIONS = 'DUPLICATE_IMPORT_OPTIONS', + DUPLICATE_PLUGIN_NAME = 'DUPLICATE_PLUGIN_NAME', + EMPTY_BUNDLE = 'EMPTY_BUNDLE', + EVAL = 'EVAL', + EXTERNAL_MODULES_CANNOT_BE_INCLUDED_IN_MANUAL_CHUNKS = + 'EXTERNAL_MODULES_CANNOT_BE_INCLUDED_IN_MANUAL_CHUNKS', + EXTERNAL_MODULES_CANNOT_BE_TRANSFORMED_TO_MODULES = + 'EXTERNAL_MODULES_CANNOT_BE_TRANSFORMED_TO_MODULES', + EXTERNAL_SYNTHETIC_EXPORTS = 'EXTERNAL_SYNTHETIC_EXPORTS', + FAIL_AFTER_WARNINGS = 'FAIL_AFTER_WARNINGS', + FILE_NAME_CONFLICT = 'FILE_NAME_CONFLICT', + FILE_NOT_FOUND = 'FILE_NOT_FOUND', + FIRST_SIDE_EFFECT = 'FIRST_SIDE_EFFECT', + ILLEGAL_IDENTIFIER_AS_NAME = 'ILLEGAL_IDENTIFIER_AS_NAME', + ILLEGAL_REASSIGNMENT = 'ILLEGAL_REASSIGNMENT', + INCONSISTENT_IMPORT_ATTRIBUTES = 'INCONSISTENT_IMPORT_ATTRIBUTES', + INVALID_ANNOTATION = 'INVALID_ANNOTATION', + INPUT_HOOK_IN_OUTPUT_PLUGIN = 'INPUT_HOOK_IN_OUTPUT_PLUGIN', + INVALID_CHUNK = 'INVALID_CHUNK', + INVALID_CONFIG_MODULE_FORMAT = 'INVALID_CONFIG_MODULE_FORMAT', + INVALID_EXPORT_OPTION = 'INVALID_EXPORT_OPTION', + INVALID_EXTERNAL_ID = 'INVALID_EXTERNAL_ID', + INVALID_IMPORT_ATTRIBUTE = 'INVALID_IMPORT_ATTRIBUTE', + INVALID_LOG_POSITION = 'INVALID_LOG_POSITION', + INVALID_OPTION = 'INVALID_OPTION', + INVALID_PLUGIN_HOOK = 'INVALID_PLUGIN_HOOK', + INVALID_ROLLUP_PHASE = 'INVALID_ROLLUP_PHASE', + INVALID_SETASSETSOURCE = 'INVALID_SETASSETSOURCE', + INVALID_TLA_FORMAT = 'INVALID_TLA_FORMAT', + MISSING_CONFIG = 'MISSING_CONFIG', + MISSING_EXPORT = 'MISSING_EXPORT', + MISSING_EXTERNAL_CONFIG = 'MISSING_EXTERNAL_CONFIG', + MISSING_GLOBAL_NAME = 'MISSING_GLOBAL_NAME', + MISSING_IMPLICIT_DEPENDANT = 'MISSING_IMPLICIT_DEPENDANT', + MISSING_JSX_EXPORT = 'MISSING_JSX_EXPORT', + MISSING_NAME_OPTION_FOR_IIFE_EXPORT = 'MISSING_NAME_OPTION_FOR_IIFE_EXPORT', + MISSING_NODE_BUILTINS = 'MISSING_NODE_BUILTINS', + MISSING_OPTION = 'MISSING_OPTION', + MIXED_EXPORTS = 'MIXED_EXPORTS', + MODULE_LEVEL_DIRECTIVE = 'MODULE_LEVEL_DIRECTIVE', + NAMESPACE_CONFLICT = 'NAMESPACE_CONFLICT', + NO_FS_IN_BROWSER = 'NO_FS_IN_BROWSER', + NO_TRANSFORM_MAP_OR_AST_WITHOUT_CODE = 'NO_TRANSFORM_MAP_OR_AST_WITHOUT_CODE', + ONLY_INLINE_SOURCEMAPS = 'ONLY_INLINE_SOURCEMAPS', + OPTIMIZE_CHUNK_STATUS = 'OPTIMIZE_CHUNK_STATUS', + PARSE_ERROR = 'PARSE_ERROR', + PLUGIN_ERROR = 'PLUGIN_ERROR', + REDECLARATION_ERROR = 'REDECLARATION_ERROR', + RESERVED_NAMESPACE = 'RESERVED_NAMESPACE', + SHIMMED_EXPORT = 'SHIMMED_EXPORT', + SOURCEMAP_BROKEN = 'SOURCEMAP_BROKEN', + SOURCEMAP_ERROR = 'SOURCEMAP_ERROR', + SYNTHETIC_NAMED_EXPORTS_NEED_NAMESPACE_EXPORT = 'SYNTHETIC_NAMED_EXPORTS_NEED_NAMESPACE_EXPORT', + THIS_IS_UNDEFINED = 'THIS_IS_UNDEFINED', + UNEXPECTED_NAMED_IMPORT = 'UNEXPECTED_NAMED_IMPORT', + UNKNOWN_OPTION = 'UNKNOWN_OPTION', + UNRESOLVED_ENTRY = 'UNRESOLVED_ENTRY', + UNRESOLVED_IMPORT = 'UNRESOLVED_IMPORT', + UNUSED_EXTERNAL_IMPORT = 'UNUSED_EXTERNAL_IMPORT', + VALIDATION_ERROR = 'VALIDATION_ERROR'; + +export function logAddonNotGenerated(message: string, hook: string, plugin: string): RollupLog { + return { + code: ADDON_ERROR, + message: `Could not retrieve "${hook}". Check configuration of plugin "${plugin}". +\tError Message: ${message}` + }; +} + +export function logAlreadyClosed(): RollupLog { + return { + code: ALREADY_CLOSED, + message: 'Bundle is already closed, no more calls to "generate" or "write" are allowed.' + }; +} + +export function logAmbiguousExternalNamespaces( + binding: string, + reexportingModule: string, + usedModule: string, + sources: string[] +): RollupLog { + return { + binding, + code: AMBIGUOUS_EXTERNAL_NAMESPACES, + ids: sources, + message: `Ambiguous external namespace resolution: "${relativeId( + reexportingModule + )}" re-exports "${binding}" from one of the external modules ${printQuotedStringList( + sources.map(module => relativeId(module)) + )}, guessing "${relativeId(usedModule)}".`, + reexporter: reexportingModule + }; +} + +export function logAnonymousPluginCache(): RollupLog { + return { + code: ANONYMOUS_PLUGIN_CACHE, + message: + 'A plugin is trying to use the Rollup cache but is not declaring a plugin name or cacheKey.' + }; +} + +export function logAssetNotFinalisedForFileName(name: string): RollupLog { + return { + code: ASSET_NOT_FINALISED, + message: `Plugin error - Unable to get file name for asset "${name}". Ensure that the source is set and that generate is called first. If you reference assets via import.meta.ROLLUP_FILE_URL_, you need to either have set their source after "renderStart" or need to provide an explicit "fileName" when emitting them.` + }; +} + +export function logAssetReferenceIdNotFoundForSetSource(assetReferenceId: string): RollupLog { + return { + code: ASSET_NOT_FOUND, + message: `Plugin error - Unable to set the source for unknown asset "${assetReferenceId}".` + }; +} + +export function logAssetSourceAlreadySet(name: string): RollupLog { + return { + code: ASSET_SOURCE_ALREADY_SET, + message: `Unable to set the source for asset "${name}", source already set.` + }; +} + +export function logNoAssetSourceSet(assetName: string): RollupLog { + return { + code: ASSET_SOURCE_MISSING, + message: `Plugin error creating asset "${assetName}" - no asset source set.` + }; +} + +export function logBadLoader(id: string): RollupLog { + return { + code: BAD_LOADER, + message: `Error loading "${relativeId( + id + )}": plugin load hook should return a string, a { code, map } object, or nothing/null.` + }; +} + +export function logCannotCallNamespace(name: string): RollupLog { + return { + code: CANNOT_CALL_NAMESPACE, + message: `Cannot call a namespace ("${name}").` + }; +} + +export function logCannotEmitFromOptionsHook(): RollupLog { + return { + code: CANNOT_EMIT_FROM_OPTIONS_HOOK, + message: `Cannot emit files or set asset sources in the "outputOptions" hook, use the "renderStart" hook instead.` + }; +} + +export function logChunkNotGeneratedForFileName(name: string): RollupLog { + return { + code: CHUNK_NOT_GENERATED, + message: `Plugin error - Unable to get file name for emitted chunk "${name}". You can only get file names once chunks have been generated after the "renderStart" hook.` + }; +} + +export function logChunkInvalid( + { fileName, code }: { code: string; fileName: string }, + { pos, message }: { pos: number; message: string } +): RollupLog { + const errorProperties = { + code: CHUNK_INVALID, + message: `Chunk "${fileName}" is not valid JavaScript: ${message}.` + }; + augmentCodeLocation(errorProperties, pos, code, fileName); + return errorProperties; +} + +export function logCircularDependency(cyclePath: string[]): RollupLog { + return { + code: CIRCULAR_DEPENDENCY, + ids: cyclePath, + message: `Circular dependency: ${cyclePath.map(relativeId).join(' -> ')}` + }; +} + +export function logCircularChunk(cyclePath: string[], isManualChunkConflict: boolean): RollupLog { + return { + code: CIRCULAR_CHUNK, + ids: cyclePath, + message: `Circular chunk: ${cyclePath.join(' -> ')}. ${ + isManualChunkConflict + ? `Please adjust the manual chunk logic for these chunks.` + : `Consider disabling the "output.onlyExplicitManualChunks" option, as enabling it causes the static dependencies of the manual chunk "${cyclePath.at(-2)}" to be bundled into the chunk "${cyclePath.at(-1)}".` + }` + }; +} + +export function logCircularReexport(exportName: string, exporter: string): RollupLog { + return { + code: CIRCULAR_REEXPORT, + exporter, + message: `"${exportName}" cannot be exported from "${relativeId( + exporter + )}" as it is a reexport that references itself.` + }; +} + +export function logCyclicCrossChunkReexport( + exportName: string, + exporter: string, + reexporter: string, + importer: string, + preserveModules: boolean +): RollupLog { + return { + code: CYCLIC_CROSS_CHUNK_REEXPORT, + exporter, + id: importer, + message: `Export "${exportName}" of module "${relativeId( + exporter + )}" was reexported through module "${relativeId( + reexporter + )}" while both modules are dependencies of each other and will end up in different chunks by current Rollup settings. This scenario is not well supported at the moment as it will produce a circular dependency between chunks and will likely lead to broken execution order.\nEither change the import in "${relativeId( + importer + )}" to point directly to the exporting module or ${ + preserveModules ? 'do not use "output.preserveModules"' : 'reconfigure "output.manualChunks"' + } to ensure these modules end up in the same chunk.`, + reexporter + }; +} + +export function logDeprecation( + deprecation: string, + urlSnippet: string, + plugin?: string +): RollupLog { + return { + code: DEPRECATED_FEATURE, + message: deprecation, + url: getRollupUrl(urlSnippet), + ...(plugin ? { plugin } : {}) + }; +} + +export function logConstVariableReassignError() { + return { + code: CONST_REASSIGN, + message: 'Cannot reassign a variable declared with `const`' + }; +} + +export function logDuplicateArgumentNameError(name: string): RollupLog { + return { + code: DUPLICATE_ARGUMENT_NAME, + message: `Duplicate argument name "${name}"` + }; +} + +export function logDuplicateExportError(name: string): RollupLog { + return { code: DUPLICATE_EXPORT, message: `Duplicate export "${name}"` }; +} + +export function logDuplicateImportOptions(): RollupLog { + return { + code: DUPLICATE_IMPORT_OPTIONS, + message: 'Either use --input, or pass input path as argument' + }; +} + +export function logDuplicatePluginName(plugin: string): RollupLog { + return { + code: DUPLICATE_PLUGIN_NAME, + message: `The plugin name ${plugin} is being used twice in the same build. Plugin names must be distinct or provide a cacheKey (please post an issue to the plugin if you are a plugin user).` + }; +} + +export function logEmptyChunk(chunkName: string): RollupLog { + return { + code: EMPTY_BUNDLE, + message: `Generated an empty chunk: "${chunkName}".`, + names: [chunkName] + }; +} + +export function logEval(id: string): RollupLog { + return { + code: EVAL, + id, + message: `Use of eval in "${relativeId( + id + )}" is strongly discouraged as it poses security risks and may cause issues with minification.`, + url: getRollupUrl(URL_AVOIDING_EVAL) + }; +} + +export function logExternalSyntheticExports(id: string, importer: string): RollupLog { + return { + code: EXTERNAL_SYNTHETIC_EXPORTS, + exporter: id, + message: `External "${id}" cannot have "syntheticNamedExports" enabled (imported by "${relativeId( + importer + )}").` + }; +} + +export function logFailAfterWarnings(): RollupLog { + return { + code: FAIL_AFTER_WARNINGS, + message: 'Warnings occurred and --failAfterWarnings flag present.' + }; +} + +export function logFileNameConflict(fileName: string): RollupLog { + return { + code: FILE_NAME_CONFLICT, + message: `The emitted file "${fileName}" overwrites a previously emitted file of the same name.` + }; +} + +export function logFileReferenceIdNotFoundForFilename(assetReferenceId: string): RollupLog { + return { + code: FILE_NOT_FOUND, + message: `Plugin error - Unable to get file name for unknown file "${assetReferenceId}".` + }; +} + +export function logFirstSideEffect( + source: string, + id: string, + { line, column }: { column: number; line: number } +): RollupLog { + return { + code: FIRST_SIDE_EFFECT, + message: `First side effect in ${relativeId(id)} is at (${line}:${column})\n${getCodeFrame( + source, + line, + column + )}` + }; +} + +export function logIllegalIdentifierAsName(name: string): RollupLog { + return { + code: ILLEGAL_IDENTIFIER_AS_NAME, + message: `Given name "${name}" is not a legal JS identifier. If you need this, you can try "output.extend: true".`, + url: getRollupUrl(URL_OUTPUT_EXTEND) + }; +} + +export function logIllegalImportReassignment(name: string, importingId: string): RollupLog { + return { + code: ILLEGAL_REASSIGNMENT, + message: `Illegal reassignment of import "${name}" in "${relativeId(importingId)}".` + }; +} + +export function logInconsistentImportAttributes( + existingAttributes: Record, + newAttributes: Record, + source: string, + importer: string +): RollupLog { + return { + code: INCONSISTENT_IMPORT_ATTRIBUTES, + message: `Module "${relativeId(importer)}" tried to import "${relativeId( + source + )}" with ${formatAttributes( + newAttributes + )} attributes, but it was already imported elsewhere with ${formatAttributes( + existingAttributes + )} attributes. Please ensure that import attributes for the same module are always consistent.` + }; +} + +const formatAttributes = (attributes: Record): string => { + const entries = Object.entries(attributes); + if (entries.length === 0) return 'no'; + return entries.map(([key, value]) => `"${key}": "${value}"`).join(', '); +}; + +export function logInvalidAnnotation(comment: string, id: string, type: AnnotationType): RollupLog { + return { + code: INVALID_ANNOTATION, + id, + message: `A comment\n\n"${comment}"\n\nin "${relativeId( + id + )}" contains an annotation that Rollup cannot interpret due to the position of the comment. The comment will be removed to avoid issues.`, + url: getRollupUrl(type === 'noSideEffects' ? URL_TREESHAKE_NOSIDEEFFECTS : URL_TREESHAKE_PURE) + }; +} + +export function logInputHookInOutputPlugin(pluginName: string, hookName: string): RollupLog { + return { + code: INPUT_HOOK_IN_OUTPUT_PLUGIN, + message: `The "${hookName}" hook used by the output plugin ${pluginName} is a build time hook and will not be run for that plugin. Either this plugin cannot be used as an output plugin, or it should have an option to configure it as an output plugin.` + }; +} + +export function logCannotAssignModuleToChunk( + moduleId: string, + assignToAlias: string, + currentAlias: string +): RollupLog { + return { + code: INVALID_CHUNK, + message: `Cannot assign "${relativeId( + moduleId + )}" to the "${assignToAlias}" chunk as it is already in the "${currentAlias}" chunk.` + }; +} + +function tweakStackMessage(error: RollupLog, oldMessage: string): RollupLog { + if (!error.stack) { + return error; + } + error.stack = error.stack.replace(oldMessage, error.message); + return error; +} + +export function logCannotBundleConfigAsEsm(originalError: Error): RollupLog { + return tweakStackMessage( + { + cause: originalError, + code: INVALID_CONFIG_MODULE_FORMAT, + message: `Rollup transpiled your configuration to an ES module even though it appears to contain CommonJS elements. To resolve this, you can pass the "--bundleConfigAsCjs" flag to Rollup or change your configuration to only contain valid ESM code.\n\nOriginal error: ${originalError.message}`, + stack: originalError.stack, + url: getRollupUrl(URL_BUNDLE_CONFIG_AS_CJS) + }, + originalError.message + ); +} + +export function logCannotLoadConfigAsCjs(originalError: Error): RollupLog { + return tweakStackMessage( + { + cause: originalError, + code: INVALID_CONFIG_MODULE_FORMAT, + message: `Node tried to load your configuration file as CommonJS even though it is likely an ES module. To resolve this, change the extension of your configuration to ".mjs", set "type": "module" in your package.json file or pass the "--bundleConfigAsCjs" flag.\n\nOriginal error: ${originalError.message}`, + stack: originalError.stack, + url: getRollupUrl(URL_BUNDLE_CONFIG_AS_CJS) + }, + originalError.message + ); +} + +export function logCannotLoadConfigAsEsm(originalError: Error): RollupLog { + return tweakStackMessage( + { + cause: originalError, + code: INVALID_CONFIG_MODULE_FORMAT, + message: `Node tried to load your configuration as an ES module even though it is likely CommonJS. To resolve this, change the extension of your configuration to ".cjs" or pass the "--bundleConfigAsCjs" flag.\n\nOriginal error: ${originalError.message}`, + stack: originalError.stack, + url: getRollupUrl(URL_BUNDLE_CONFIG_AS_CJS) + }, + originalError.message + ); +} + +export function logInvalidExportOptionValue(optionValue: string): RollupLog { + return { + code: INVALID_EXPORT_OPTION, + message: `"output.exports" must be "default", "named", "none", "auto", or left unspecified (defaults to "auto"), received "${optionValue}".`, + url: getRollupUrl(URL_OUTPUT_EXPORTS) + }; +} + +export function logIncompatibleExportOptionValue( + optionValue: string, + keys: readonly string[], + entryModule: string +): RollupLog { + return { + code: INVALID_EXPORT_OPTION, + message: `"${optionValue}" was specified for "output.exports", but entry module "${relativeId( + entryModule + )}" has the following exports: ${printQuotedStringList(keys)}`, + url: getRollupUrl(URL_OUTPUT_EXPORTS) + }; +} + +export function logInternalIdCannotBeExternal(source: string, importer: string): RollupLog { + return { + code: INVALID_EXTERNAL_ID, + message: `"${source}" is imported as an external by "${relativeId( + importer + )}", but is already an existing non-external module id.` + }; +} + +export function logImportOptionsAreInvalid(importer: string): RollupLog { + return { + code: INVALID_IMPORT_ATTRIBUTE, + message: `Rollup could not statically analyze the options argument of a dynamic import in "${relativeId( + importer + )}". Dynamic import options need to be an object with a nested attributes object.` + }; +} + +export function logImportAttributeIsInvalid(importer: string): RollupLog { + return { + code: INVALID_IMPORT_ATTRIBUTE, + message: `Rollup could not statically analyze an import attribute of a dynamic import in "${relativeId( + importer + )}". Import attributes need to have string keys and values.` + }; +} + +export function logInvalidLogPosition(plugin: string): RollupLog { + return { + code: INVALID_LOG_POSITION, + message: `Plugin "${plugin}" tried to add a file position to a log or warning. This is only supported in the "transform" hook at the moment and will be ignored.` + }; +} + +export function logInvalidOption( + option: string, + urlSnippet: string, + explanation: string, + value?: string | boolean | null +): RollupLog { + return { + code: INVALID_OPTION, + message: `Invalid value ${ + value === undefined ? '' : `${JSON.stringify(value)} ` + }for option "${option}" - ${explanation}.`, + url: getRollupUrl(urlSnippet) + }; +} + +export function logInvalidAddonPluginHook(hook: string, plugin: string): RollupLog { + return { + code: INVALID_PLUGIN_HOOK, + hook, + message: `Error running plugin hook "${hook}" for plugin "${plugin}", expected a string, a function hook or an object with a "handler" string or function.`, + plugin + }; +} + +export function logInvalidFunctionPluginHook(hook: string, plugin: string): RollupLog { + return { + code: INVALID_PLUGIN_HOOK, + hook, + message: `Error running plugin hook "${hook}" for plugin "${plugin}", expected a function hook or an object with a "handler" function.`, + plugin + }; +} + +export function logInvalidRollupPhaseForChunkEmission(): RollupLog { + return { + code: INVALID_ROLLUP_PHASE, + message: `Cannot emit chunks after module loading has finished.` + }; +} + +export function logInvalidSetAssetSourceCall(): RollupLog { + return { + code: INVALID_SETASSETSOURCE, + message: `setAssetSource cannot be called in transform for caching reasons. Use emitFile with a source, or call setAssetSource in another hook.` + }; +} + +export function logInvalidFormatForTopLevelAwait( + id: string, + format: InternalModuleFormat +): RollupLog { + return { + code: INVALID_TLA_FORMAT, + id, + message: `Module format "${format}" does not support top-level await. Use the "es" or "system" output formats rather.` + }; +} + +export function logMissingConfig(): RollupLog { + return { + code: MISSING_CONFIG, + message: 'Config file must export an options object, or an array of options objects', + url: getRollupUrl(URL_CONFIGURATION_FILES) + }; +} + +export function logMissingEntryExport(binding: string, exporter: string): RollupLog { + return { + binding, + code: MISSING_EXPORT, + exporter, + message: `Exported variable "${binding}" is not defined in "${relativeId(exporter)}".`, + url: getRollupUrl(URL_NAME_IS_NOT_EXPORTED) + }; +} + +export function logMissingExport( + binding: string, + importingModule: string, + exporter: string, + missingButExportExists: boolean +): RollupLog { + const baseLog = { + binding, + code: MISSING_EXPORT, + exporter, + id: importingModule, + url: getRollupUrl(URL_NAME_IS_NOT_EXPORTED) + }; + if (missingButExportExists) { + return { + ...baseLog, + message: `Exported variable "${binding}" is not defined in "${relativeId(exporter)}", but it is imported by "${relativeId( + importingModule + )}".` + }; + } + const isJson = extname(exporter) === '.json'; + return { + ...baseLog, + message: `"${binding}" is not exported by "${relativeId(exporter)}", imported by "${relativeId( + importingModule + )}".${isJson ? ' (Note that you need @rollup/plugin-json to import JSON files)' : ''}` + }; +} + +export function logMissingExternalConfig(file: string): RollupLog { + return { + code: MISSING_EXTERNAL_CONFIG, + message: `Could not resolve config file "${file}"` + }; +} + +export function logMissingGlobalName(externalId: string, guess: string): RollupLog { + return { + code: MISSING_GLOBAL_NAME, + id: externalId, + message: `No name was provided for external module "${externalId}" in "output.globals" – guessing "${guess}".`, + names: [guess], + url: getRollupUrl(URL_OUTPUT_GLOBALS) + }; +} + +export function logImplicitDependantCannotBeExternal( + unresolvedId: string, + implicitlyLoadedBefore: string +): RollupLog { + return { + code: MISSING_IMPLICIT_DEPENDANT, + message: `Module "${relativeId( + unresolvedId + )}" that should be implicitly loaded before "${relativeId( + implicitlyLoadedBefore + )}" cannot be external.` + }; +} + +export function logUnresolvedImplicitDependant( + unresolvedId: string, + implicitlyLoadedBefore: string +): RollupLog { + return { + code: MISSING_IMPLICIT_DEPENDANT, + message: `Module "${relativeId( + unresolvedId + )}" that should be implicitly loaded before "${relativeId( + implicitlyLoadedBefore + )}" could not be resolved.` + }; +} + +export function logImplicitDependantIsNotIncluded(module: Module): RollupLog { + const implicitDependencies = [...module.implicitlyLoadedBefore] + .map(dependency => relativeId(dependency.id)) + .sort(); + return { + code: MISSING_IMPLICIT_DEPENDANT, + message: `Module "${relativeId( + module.id + )}" that should be implicitly loaded before ${printQuotedStringList( + implicitDependencies + )} is not included in the module graph. Either it was not imported by an included module or only via a tree-shaken dynamic import, or no imported bindings were used and it had otherwise no side-effects.` + }; +} + +export function logMissingJsxExport(name: string, exporter: string, importer: string): RollupLog { + return { + code: MISSING_JSX_EXPORT, + exporter, + id: importer, + message: `Export "${name}" is not defined in module "${relativeId(exporter)}" even though it is needed in "${relativeId(importer)}" to provide JSX syntax. Please check your "jsx" option.`, + names: [name], + url: getRollupUrl(URL_JSX) + }; +} + +export function logMissingNameOptionForIifeExport(): RollupLog { + return { + code: MISSING_NAME_OPTION_FOR_IIFE_EXPORT, + message: `If you do not supply "output.name", you may not be able to access the exports of an IIFE bundle.`, + url: getRollupUrl(URL_OUTPUT_NAME) + }; +} + +export function logMissingNameOptionForUmdExport(): RollupLog { + return { + code: MISSING_NAME_OPTION_FOR_IIFE_EXPORT, + message: + 'You must supply "output.name" for UMD bundles that have exports so that the exports are accessible in environments without a module loader.', + url: getRollupUrl(URL_OUTPUT_NAME) + }; +} + +export function logMissingNodeBuiltins(externalBuiltins: string[]): RollupLog { + return { + code: MISSING_NODE_BUILTINS, + ids: externalBuiltins, + message: `Creating a browser bundle that depends on Node.js built-in modules (${printQuotedStringList( + externalBuiltins + )}). You might need to include https://github.com/FredKSchott/rollup-plugin-polyfill-node` + }; +} + +export function logMissingFileOrDirOption(): RollupLog { + return { + code: MISSING_OPTION, + message: 'You must specify "output.file" or "output.dir" for the build.', + url: getRollupUrl(URL_OUTPUT_DIR) + }; +} + +export function logMixedExport(facadeModuleId: string, name?: string): RollupLog { + return { + code: MIXED_EXPORTS, + id: facadeModuleId, + message: `Entry module "${relativeId( + facadeModuleId + )}" is using named and default exports together. Consumers of your bundle will have to use \`${ + name || 'chunk' + }.default\` to access the default export, which may not be what you want. Use \`output.exports: "named"\` to disable this warning.`, + url: getRollupUrl(URL_OUTPUT_EXPORTS) + }; +} + +export function logModuleLevelDirective(directive: string, id: string): RollupLog { + return { + code: MODULE_LEVEL_DIRECTIVE, + id, + message: `Module level directives cause errors when bundled, "${directive}" in "${relativeId( + id + )}" was ignored.` + }; +} + +export function logNamespaceConflict( + binding: string, + reexportingModuleId: string, + sources: string[] +): RollupLog { + return { + binding, + code: NAMESPACE_CONFLICT, + ids: sources, + message: `Conflicting namespaces: "${relativeId( + reexportingModuleId + )}" re-exports "${binding}" from one of the modules ${printQuotedStringList( + sources.map(moduleId => relativeId(moduleId)) + )} (will be ignored).`, + reexporter: reexportingModuleId + }; +} + +export function logNoFileSystemInBrowser(method: string): RollupLog { + return { + code: NO_FS_IN_BROWSER, + message: `Cannot access the file system (via "${method}") when using the browser build of Rollup. Make sure you supply a plugin with custom resolveId and load hooks to Rollup.`, + url: getRollupUrl(URL_A_SIMPLE_EXAMPLE) + }; +} + +export function logNoTransformMapOrAstWithoutCode(pluginName: string): RollupLog { + return { + code: NO_TRANSFORM_MAP_OR_AST_WITHOUT_CODE, + message: + `The plugin "${pluginName}" returned a "map" or "ast" without returning ` + + 'a "code". This will be ignored.' + }; +} + +export function logOnlyInlineSourcemapsForStdout(): RollupLog { + return { + code: ONLY_INLINE_SOURCEMAPS, + message: 'Only inline sourcemaps are supported when bundling to stdout.' + }; +} + +export function logOptimizeChunkStatus( + chunks: number, + smallChunks: number, + pointInTime: string +): RollupLog { + return { + code: OPTIMIZE_CHUNK_STATUS, + message: + `${pointInTime}, there are\n` + + `${chunks} chunks, of which\n` + + `${smallChunks} are below minChunkSize.` + }; +} + +export function logParseError(message: string, pos?: number): RollupLog { + return { code: PARSE_ERROR, message, pos }; +} + +export function logRedeclarationError(name: string): RollupLog { + return { + code: REDECLARATION_ERROR, + message: `Identifier "${name}" has already been declared` + }; +} + +export function logReservedNamespace(namespace: string): RollupLog { + return { + code: RESERVED_NAMESPACE, + message: `You have overridden reserved namespace "${namespace}"` + }; +} + +export function logModuleParseError(error: Error, moduleId: string): RollupLog { + let message = error.message.replace(/ \(\d+:\d+\)$/, ''); + if (moduleId.endsWith('.json')) { + message += ' (Note that you need @rollup/plugin-json to import JSON files)'; + } else if (!moduleId.endsWith('.js')) { + message += ' (Note that you need plugins to import files that are not JavaScript)'; + } + return tweakStackMessage( + { + cause: error, + code: PARSE_ERROR, + id: moduleId, + message, + stack: error.stack + }, + error.message + ); +} + +export function logPluginError( + error: Omit & { code?: unknown }, + plugin: string, + { hook, id }: { hook?: string; id?: string } = {} +) { + const code = error.code; + if ( + !error.pluginCode && + code != null && + (typeof code !== 'string' || !code.startsWith('PLUGIN_')) + ) { + error.pluginCode = code; + } + error.code = PLUGIN_ERROR; + error.plugin = plugin; + if (hook) { + error.hook = hook; + } + if (id) { + error.id = id; + } + return error as RollupLog; +} + +export function logShimmedExport(id: string, binding: string): RollupLog { + return { + binding, + code: SHIMMED_EXPORT, + exporter: id, + message: `Missing export "${binding}" has been shimmed in module "${relativeId(id)}".` + }; +} + +export function logSourcemapBroken(plugin: string): RollupLog { + return { + code: SOURCEMAP_BROKEN, + message: `Sourcemap is likely to be incorrect: a plugin (${plugin}) was used to transform files, but didn't generate a sourcemap for the transformation. Consult the plugin documentation for help`, + plugin, + url: getRollupUrl(URL_SOURCEMAP_IS_LIKELY_TO_BE_INCORRECT) + }; +} + +export function logConflictingSourcemapSources(filename: string): RollupLog { + return { + code: SOURCEMAP_BROKEN, + message: `Multiple conflicting contents for sourcemap source ${filename}` + }; +} + +export function logInvalidSourcemapForError( + error: Error, + id: string, + column: number, + line: number, + pos: number +): RollupLog { + return { + cause: error, + code: SOURCEMAP_ERROR, + id, + loc: { + column, + file: id, + line + }, + message: `Error when using sourcemap for reporting an error: ${error.message}`, + pos + }; +} + +export function logSyntheticNamedExportsNeedNamespaceExport( + id: string, + syntheticNamedExportsOption: boolean | string +): RollupLog { + return { + code: SYNTHETIC_NAMED_EXPORTS_NEED_NAMESPACE_EXPORT, + exporter: id, + message: `Module "${relativeId( + id + )}" that is marked with \`syntheticNamedExports: ${JSON.stringify( + syntheticNamedExportsOption + )}\` needs ${ + typeof syntheticNamedExportsOption === 'string' && syntheticNamedExportsOption !== 'default' + ? `an explicit export named "${syntheticNamedExportsOption}"` + : 'a default export' + } that does not reexport an unresolved named export of the same module.` + }; +} + +export function logThisIsUndefined(): RollupLog { + return { + code: THIS_IS_UNDEFINED, + message: `The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten`, + url: getRollupUrl(URL_THIS_IS_UNDEFINED) + }; +} + +export function logUnexpectedNamedImport( + id: string, + imported: string, + isReexport: boolean +): RollupLog { + const importType = isReexport ? 'reexport' : 'import'; + return { + code: UNEXPECTED_NAMED_IMPORT, + exporter: id, + message: `The named export "${imported}" was ${importType}ed from the external module "${relativeId( + id + )}" even though its interop type is "defaultOnly". Either remove or change this ${importType} or change the value of the "output.interop" option.`, + url: getRollupUrl(URL_OUTPUT_INTEROP) + }; +} + +export function logUnexpectedNamespaceReexport(id: string): RollupLog { + return { + code: UNEXPECTED_NAMED_IMPORT, + exporter: id, + message: `There was a namespace "*" reexport from the external module "${relativeId( + id + )}" even though its interop type is "defaultOnly". This will be ignored as namespace reexports only reexport named exports. If this is not intended, either remove or change this reexport or change the value of the "output.interop" option.`, + url: getRollupUrl(URL_OUTPUT_INTEROP) + }; +} + +export function logUnknownOption( + optionType: string, + unknownOptions: string[], + validOptions: string[] +): RollupLog { + return { + code: UNKNOWN_OPTION, + message: `Unknown ${optionType}: ${unknownOptions.join( + ', ' + )}. Allowed options: ${validOptions.join(', ')}` + }; +} + +export function logEntryCannotBeExternal(unresolvedId: string): RollupLog { + return { + code: UNRESOLVED_ENTRY, + message: `Entry module "${relativeId(unresolvedId)}" cannot be external.` + }; +} + +export function logExternalModulesCannotBeIncludedInManualChunks(source: string): RollupLog { + return { + code: EXTERNAL_MODULES_CANNOT_BE_INCLUDED_IN_MANUAL_CHUNKS, + message: `"${source}" cannot be included in manualChunks because it is resolved as an external module by the "external" option or plugins.` + }; +} + +export function logExternalModulesCannotBeTransformedToModules(source: string): RollupLog { + return { + code: EXTERNAL_MODULES_CANNOT_BE_TRANSFORMED_TO_MODULES, + message: `${source} is resolved as a module now, but it was an external module before. Please check whether there are conflicts in your Rollup options "external" and "manualChunks", manualChunks cannot include external modules.` + }; +} + +export function logUnresolvedEntry(unresolvedId: string): RollupLog { + return { + code: UNRESOLVED_ENTRY, + message: `Could not resolve entry module "${relativeId(unresolvedId)}".` + }; +} + +export function logUnresolvedImport(source: string, importer: string): RollupLog { + return { + code: UNRESOLVED_IMPORT, + exporter: source, + id: importer, + message: `Could not resolve "${source}" from "${relativeId(importer)}"` + }; +} + +export function logUnresolvedImportTreatedAsExternal(source: string, importer: string): RollupLog { + return { + code: UNRESOLVED_IMPORT, + exporter: source, + id: importer, + message: `"${source}" is imported by "${relativeId( + importer + )}", but could not be resolved – treating it as an external dependency.`, + url: getRollupUrl(URL_TREATING_MODULE_AS_EXTERNAL_DEPENDENCY) + }; +} + +export function logUnusedExternalImports( + externalId: string, + names: string[], + importers: string[] +): RollupLog { + return { + code: UNUSED_EXTERNAL_IMPORT, + exporter: externalId, + ids: importers, + message: `${printQuotedStringList(names, [ + 'is', + 'are' + ])} imported from external module "${externalId}" but never used in ${printQuotedStringList( + importers.map(importer => relativeId(importer)) + )}.`, + names + }; +} + +export function logFailedValidation(message: string): RollupLog { + return { + code: VALIDATION_ERROR, + message + }; +} + +export function warnDeprecation( + deprecation: string, + urlSnippet: string, + activeDeprecation: boolean, + options: NormalizedInputOptions, + plugin?: string +): void { + warnDeprecationWithOptions( + deprecation, + urlSnippet, + activeDeprecation, + options.onLog, + options.strictDeprecations, + plugin + ); +} + +export function warnDeprecationWithOptions( + deprecation: string, + urlSnippet: string, + activeDeprecation: boolean, + log: LogHandler, + strictDeprecations: boolean, + plugin?: string +): void { + if (activeDeprecation || strictDeprecations) { + const warning = logDeprecation(deprecation, urlSnippet, plugin); + if (strictDeprecations) { + return error(warning); + } + log(LOGLEVEL_WARN, warning); + } +} diff --git a/src/utils/options/mergeOptions.ts b/src/utils/options/mergeOptions.ts index 822e26c0f8f..7f452c8d537 100644 --- a/src/utils/options/mergeOptions.ts +++ b/src/utils/options/mergeOptions.ts @@ -1,17 +1,31 @@ -import { +import type { ExternalOption, InputOptions, + LogHandler, MergedRollupOptions, OutputOptions, + Plugin, RollupCache, - WarningHandler, - WarningHandlerWithDefault + RollupOptions } from '../../rollup/types'; import { ensureArray } from '../ensureArray'; -import { CommandConfigObject } from './normalizeInputOptions'; -import { defaultOnWarn, GenericConfigObject, warnUnknownOptions } from './options'; +import { getLogger } from '../logger'; +import { LOGLEVEL_INFO } from '../logging'; +import { URL_JSX, URL_OUTPUT_GENERATEDCODE, URL_TREESHAKE } from '../urls'; +import type { CommandConfigObject } from './normalizeInputOptions'; +import { + generatedCodePresets, + type GenericConfigObject, + getOnLog, + jsxPresets, + normalizePluginOption, + objectifyOption, + objectifyOptionWithPresets, + treeshakePresets, + warnUnknownOptions +} from './options'; -export const commandAliases: { [key: string]: string } = { +export const commandAliases: Record = { c: 'config', d: 'dir', e: 'external', @@ -27,38 +41,54 @@ export const commandAliases: { [key: string]: string } = { w: 'watch' }; -export function mergeOptions( - config: GenericConfigObject, - rawCommandOptions: GenericConfigObject = { external: [], globals: undefined }, - defaultOnWarnHandler: WarningHandler = defaultOnWarn -): MergedRollupOptions { +const EMPTY_COMMAND_OPTIONS = { external: [], globals: undefined }; + +export async function mergeOptions( + config: RollupOptions, + watchMode: boolean, + rawCommandOptions: GenericConfigObject = EMPTY_COMMAND_OPTIONS, + printLog?: LogHandler +): Promise { const command = getCommandOptions(rawCommandOptions); - const inputOptions = mergeInputOptions(config, command, defaultOnWarnHandler); - const warn = inputOptions.onwarn as WarningHandler; + const plugins = await normalizePluginOption(config.plugins); + const logLevel = config.logLevel || LOGLEVEL_INFO; + const onLog = getOnLog(config, logLevel, printLog); + const log = getLogger(plugins, onLog, watchMode, logLevel); + const inputOptions = mergeInputOptions(config, command, plugins, log, onLog); if (command.output) { Object.assign(command, command.output); } - const outputOptionsArray = ensureArray(config.output) as GenericConfigObject[]; + const outputOptionsArray = ensureArray(config.output); if (outputOptionsArray.length === 0) outputOptionsArray.push({}); - const outputOptions = outputOptionsArray.map(singleOutputOptions => - mergeOutputOptions(singleOutputOptions, command, warn) + const outputOptions = await Promise.all( + outputOptionsArray.map(singleOutputOptions => + mergeOutputOptions(singleOutputOptions, command, log) + ) ); warnUnknownOptions( command, - Object.keys(inputOptions).concat( - Object.keys(outputOptions[0]).filter(option => option !== 'sourcemapPathTransform'), - Object.keys(commandAliases), + [ + ...Object.keys(inputOptions).filter(option => option !== 'fs'), + ...Object.keys(outputOptions[0]).filter( + option => option !== 'sourcemapIgnoreList' && option !== 'sourcemapPathTransform' + ), + ...Object.keys(commandAliases), + 'bundleConfigAsCjs', 'config', + 'configImportAttributesKey', + 'configPlugin', 'environment', + 'failAfterWarnings', + 'filterLogs', + 'forceExit', 'plugin', 'silent', - 'failAfterWarnings', 'stdin', 'waitForBundleInput' - ), + ], 'CLI flags', - warn, + log, /^_$|output$|config/ ); (inputOptions as MergedRollupOptions).output = outputOptions; @@ -78,11 +108,11 @@ function getCommandOptions(rawCommandOptions: GenericConfigObject): CommandConfi ? rawCommandOptions.globals.split(',').reduce((globals, globalDefinition) => { const [id, variableName] = globalDefinition.split(':'); globals[id] = variableName; - if (external.indexOf(id) === -1) { + if (!external.includes(id)) { external.push(id); } return globals; - }, Object.create(null)) + }, Object.create(null)) : undefined }; } @@ -92,103 +122,113 @@ type CompleteInputOptions = { }; function mergeInputOptions( - config: GenericConfigObject, + config: InputOptions, overrides: CommandConfigObject, - defaultOnWarnHandler: WarningHandler + plugins: Plugin[], + log: LogHandler, + onLog: LogHandler ): InputOptions { - const getOption = (name: string): any => overrides[name] ?? config[name]; + const getOption = (name: keyof InputOptions): any => overrides[name] ?? config[name]; const inputOptions: CompleteInputOptions = { - acorn: getOption('acorn'), - acornInjectPlugins: config.acornInjectPlugins as Function | Function[] | undefined, cache: config.cache as false | RollupCache | undefined, context: getOption('context'), experimentalCacheExpiry: getOption('experimentalCacheExpiry'), + experimentalLogSideEffects: getOption('experimentalLogSideEffects'), external: getExternal(config, overrides), - inlineDynamicImports: getOption('inlineDynamicImports'), + fs: getOption('fs'), input: getOption('input') || [], + jsx: getObjectOption( + config, + overrides, + 'jsx', + objectifyOptionWithPresets(jsxPresets, 'jsx', URL_JSX, 'false, ') + ), + logLevel: getOption('logLevel'), makeAbsoluteExternalsRelative: getOption('makeAbsoluteExternalsRelative'), - manualChunks: getOption('manualChunks'), + maxParallelFileOps: getOption('maxParallelFileOps'), moduleContext: getOption('moduleContext'), - onwarn: getOnWarn(config, defaultOnWarnHandler), + onLog, + onwarn: undefined, perf: getOption('perf'), - plugins: ensureArray(config.plugins) as Plugin[], + plugins, preserveEntrySignatures: getOption('preserveEntrySignatures'), - preserveModules: getOption('preserveModules'), preserveSymlinks: getOption('preserveSymlinks'), shimMissingExports: getOption('shimMissingExports'), strictDeprecations: getOption('strictDeprecations'), - treeshake: getObjectOption(config, overrides, 'treeshake'), - watch: getWatch(config, overrides, 'watch') + treeshake: getObjectOption( + config, + overrides, + 'treeshake', + objectifyOptionWithPresets(treeshakePresets, 'treeshake', URL_TREESHAKE, 'false, true, ') + ), + watch: getWatch(config, overrides) }; - warnUnknownOptions( - config, - Object.keys(inputOptions), - 'input options', - inputOptions.onwarn as WarningHandler, - /^output$/ - ); + warnUnknownOptions(config, Object.keys(inputOptions), 'input options', log, /^output$/); return inputOptions; } -const getExternal = ( - config: GenericConfigObject, - overrides: CommandConfigObject -): ExternalOption => { - const configExternal = config.external as ExternalOption | undefined; +const getExternal = (config: InputOptions, overrides: CommandConfigObject): ExternalOption => { + const configExternal = config.external; return typeof configExternal === 'function' ? (source: string, importer: string | undefined, isResolved: boolean) => - configExternal(source, importer, isResolved) || overrides.external.indexOf(source) !== -1 - : ensureArray(configExternal).concat(overrides.external); + configExternal(source, importer, isResolved) || overrides.external.includes(source) + : [...ensureArray(configExternal), ...overrides.external]; }; -const getOnWarn = ( - config: GenericConfigObject, - defaultOnWarnHandler: WarningHandler -): WarningHandler => - config.onwarn - ? warning => (config.onwarn as WarningHandlerWithDefault)(warning, defaultOnWarnHandler) - : defaultOnWarnHandler; - -const getObjectOption = ( - config: GenericConfigObject, - overrides: GenericConfigObject, - name: string -) => { - const commandOption = normalizeObjectOptionValue(overrides[name]); - const configOption = normalizeObjectOptionValue(config[name]); +const getObjectOption = ( + config: T, + overrides: T, + name: keyof T, + objectifyValue = objectifyOption +): any => { + const commandOption = normalizeObjectOptionValue(overrides[name], objectifyValue); + const configOption = normalizeObjectOptionValue(config[name], objectifyValue); if (commandOption !== undefined) { return commandOption && { ...configOption, ...commandOption }; } return configOption; }; -const getWatch = (config: GenericConfigObject, overrides: GenericConfigObject, name: string) => - config.watch !== false && getObjectOption(config, overrides, name); +export const getWatch = (config: InputOptions, overrides: InputOptions) => + config.watch !== false && getObjectOption(config, overrides, 'watch'); -export const normalizeObjectOptionValue = (optionValue: any) => { +export const isWatchEnabled = (optionValue: unknown): boolean => { + if (Array.isArray(optionValue)) { + return optionValue.reduce( + (result, value) => (typeof value === 'boolean' ? value : result), + false + ); + } + return optionValue === true; +}; + +export const normalizeObjectOptionValue = ( + optionValue: unknown, + objectifyValue: (value: unknown) => Record | undefined +): Record | undefined => { if (!optionValue) { - return optionValue; + return optionValue as undefined; } if (Array.isArray(optionValue)) { - return optionValue.reduce((result, value) => value && result && { ...result, ...value }, {}); + return optionValue.reduce( + (result, value) => value && result && { ...result, ...objectifyValue(value) }, + {} + ); } - if (typeof optionValue !== 'object') { - return {}; - } - return optionValue; + return objectifyValue(optionValue); }; type CompleteOutputOptions = { [K in U]: OutputOptions[K]; }; -function mergeOutputOptions( - config: GenericConfigObject, - overrides: GenericConfigObject, - warn: WarningHandler -): OutputOptions { - const getOption = (name: string): any => overrides[name] ?? config[name]; +async function mergeOutputOptions( + config: OutputOptions, + overrides: OutputOptions, + log: LogHandler +): Promise { + const getOption = (name: keyof OutputOptions): any => overrides[name] ?? config[name]; const outputOptions: CompleteOutputOptions = { amd: getObjectOption(config, overrides, 'amd'), assetFileNames: getOption('assetFileNames'), @@ -196,18 +236,34 @@ function mergeOutputOptions( chunkFileNames: getOption('chunkFileNames'), compact: getOption('compact'), dir: getOption('dir'), - dynamicImportFunction: getOption('dynamicImportFunction'), + dynamicImportInCjs: getOption('dynamicImportInCjs'), entryFileNames: getOption('entryFileNames'), esModule: getOption('esModule'), + experimentalMinChunkSize: getOption('experimentalMinChunkSize'), exports: getOption('exports'), extend: getOption('extend'), + externalImportAssertions: getOption('externalImportAssertions'), + externalImportAttributes: getOption('externalImportAttributes'), externalLiveBindings: getOption('externalLiveBindings'), file: getOption('file'), footer: getOption('footer'), format: getOption('format'), freeze: getOption('freeze'), + generatedCode: getObjectOption( + config, + overrides, + 'generatedCode', + objectifyOptionWithPresets( + generatedCodePresets, + 'output.generatedCode', + URL_OUTPUT_GENERATEDCODE, + '' + ) + ), globals: getOption('globals'), + hashCharacters: getOption('hashCharacters'), hoistTransitiveImports: getOption('hoistTransitiveImports'), + importAttributesKey: getOption('importAttributesKey'), indent: getOption('indent'), inlineDynamicImports: getOption('inlineDynamicImports'), interop: getOption('interop'), @@ -215,23 +271,29 @@ function mergeOutputOptions( manualChunks: getOption('manualChunks'), minifyInternalExports: getOption('minifyInternalExports'), name: getOption('name'), - namespaceToStringTag: getOption('namespaceToStringTag'), noConflict: getOption('noConflict'), + onlyExplicitManualChunks: getOption('onlyExplicitManualChunks'), outro: getOption('outro'), paths: getOption('paths'), - plugins: ensureArray(config.plugins) as Plugin[], - preferConst: getOption('preferConst'), + plugins: await normalizePluginOption(config.plugins), preserveModules: getOption('preserveModules'), preserveModulesRoot: getOption('preserveModulesRoot'), + reexportProtoFromExternal: getOption('reexportProtoFromExternal'), + sanitizeFileName: getOption('sanitizeFileName'), sourcemap: getOption('sourcemap'), + sourcemapBaseUrl: getOption('sourcemapBaseUrl'), + sourcemapDebugIds: getOption('sourcemapDebugIds'), sourcemapExcludeSources: getOption('sourcemapExcludeSources'), sourcemapFile: getOption('sourcemapFile'), + sourcemapFileNames: getOption('sourcemapFileNames'), + sourcemapIgnoreList: getOption('sourcemapIgnoreList'), sourcemapPathTransform: getOption('sourcemapPathTransform'), strict: getOption('strict'), systemNullSetters: getOption('systemNullSetters'), - validate: getOption('validate') + validate: getOption('validate'), + virtualDirname: getOption('virtualDirname') }; - warnUnknownOptions(config, Object.keys(outputOptions), 'output options', warn); + warnUnknownOptions(config, Object.keys(outputOptions), 'output options', log); return outputOptions; } diff --git a/src/utils/options/normalizeInputOptions.ts b/src/utils/options/normalizeInputOptions.ts index 4d707964870..70e466a5695 100644 --- a/src/utils/options/normalizeInputOptions.ts +++ b/src/utils/options/normalizeInputOptions.ts @@ -1,131 +1,103 @@ -import * as acorn from 'acorn'; -import injectClassFields from 'acorn-class-fields'; -import injectPrivateMethods from 'acorn-private-methods'; -import injectStaticClassFeatures from 'acorn-static-class-features'; -import { - ExternalOption, +import type { HasModuleSideEffects, - InputOption, InputOptions, - ManualChunksOption, ModuleSideEffectsOption, NormalizedInputOptions, - PreserveEntrySignaturesOption, - PureModulesOption, RollupBuild, - RollupCache, - TreeshakingOptions, - WarningHandler, - WarningHandlerWithDefault + RollupFsModule } from '../../rollup/types'; +import { EMPTY_ARRAY } from '../blank'; import { ensureArray } from '../ensureArray'; -import { errInvalidOption, warnDeprecationWithOptions } from '../error'; +import * as fs from '../fs'; +import { getLogger } from '../logger'; +import { LOGLEVEL_INFO } from '../logging'; +import { error, logInvalidOption } from '../logs'; import { resolve } from '../path'; -import relativeId from '../relativeId'; -import { defaultOnWarn, GenericConfigObject, warnUnknownOptions } from './options'; +import { URL_JSX, URL_TREESHAKE, URL_TREESHAKE_MODULESIDEEFFECTS } from '../urls'; +import { + getOnLog, + getOptionWithPreset, + jsxPresets, + normalizePluginOption, + treeshakePresets, + warnUnknownOptions +} from './options'; export interface CommandConfigObject { - external: (string | RegExp)[]; - globals: { [id: string]: string } | undefined; - [key: string]: unknown; + external: (string | RegExp)[]; + globals: Record | undefined; } -export function normalizeInputOptions( - config: GenericConfigObject -): { options: NormalizedInputOptions; unsetOptions: Set } { +export async function normalizeInputOptions( + config: InputOptions, + watchMode: boolean +): Promise<{ + options: NormalizedInputOptions; + unsetOptions: Set; +}> { // These are options that may trigger special warnings or behaviour later // if the user did not select an explicit value const unsetOptions = new Set(); - const context = (config.context as string | undefined) ?? 'undefined'; - const onwarn = getOnwarn(config); - const strictDeprecations = (config.strictDeprecations as boolean | undefined) || false; + const context = config.context ?? 'undefined'; + const plugins = await normalizePluginOption(config.plugins); + const logLevel = config.logLevel || LOGLEVEL_INFO; + const onLog = getLogger(plugins, getOnLog(config, logLevel), watchMode, logLevel); + const strictDeprecations = config.strictDeprecations || false; + const maxParallelFileOps = getMaxParallelFileOps(config); const options: NormalizedInputOptions & InputOptions = { - acorn: getAcorn(config), - acornInjectPlugins: getAcornInjectPlugins(config), cache: getCache(config), context, - experimentalCacheExpiry: (config.experimentalCacheExpiry as number | undefined) ?? 10, - external: getIdMatcher(config.external as ExternalOption), - inlineDynamicImports: getInlineDynamicImports(config, onwarn, strictDeprecations), + experimentalCacheExpiry: config.experimentalCacheExpiry ?? 10, + experimentalLogSideEffects: config.experimentalLogSideEffects || false, + external: getIdMatcher(config.external), + fs: config.fs ?? (fs as RollupFsModule), input: getInput(config), - makeAbsoluteExternalsRelative: - (config.makeAbsoluteExternalsRelative as boolean | 'ifRelativeSource' | undefined) ?? true, - manualChunks: getManualChunks(config, onwarn, strictDeprecations), + jsx: getJsx(config), + logLevel, + makeAbsoluteExternalsRelative: config.makeAbsoluteExternalsRelative ?? 'ifRelativeSource', + maxParallelFileOps, moduleContext: getModuleContext(config, context), - onwarn, - perf: (config.perf as boolean | undefined) || false, - plugins: ensureArray(config.plugins) as Plugin[], - preserveEntrySignatures: getPreserveEntrySignatures(config, unsetOptions), - preserveModules: getPreserveModules(config, onwarn, strictDeprecations), - preserveSymlinks: (config.preserveSymlinks as boolean | undefined) || false, - shimMissingExports: (config.shimMissingExports as boolean | undefined) || false, + onLog, + perf: config.perf || false, + plugins, + preserveEntrySignatures: config.preserveEntrySignatures ?? 'exports-only', + preserveSymlinks: config.preserveSymlinks || false, + shimMissingExports: config.shimMissingExports || false, strictDeprecations, - treeshake: getTreeshake(config, onwarn, strictDeprecations) + treeshake: getTreeshake(config) }; warnUnknownOptions( config, - [...Object.keys(options), 'watch'], + [...Object.keys(options), 'onwarn', 'watch'], 'input options', - options.onwarn, + onLog, /^(output)$/ ); return { options, unsetOptions }; } -const getOnwarn = (config: GenericConfigObject): WarningHandler => { - return config.onwarn - ? warning => { - warning.toString = () => { - let str = ''; - - if (warning.plugin) str += `(${warning.plugin} plugin) `; - if (warning.loc) - str += `${relativeId(warning.loc.file!)} (${warning.loc.line}:${warning.loc.column}) `; - str += warning.message; - - return str; - }; - (config.onwarn as WarningHandlerWithDefault)(warning, defaultOnWarn); - } - : defaultOnWarn; -}; - -const getAcorn = (config: GenericConfigObject): acorn.Options => ({ - allowAwaitOutsideFunction: true, - ecmaVersion: 'latest', - preserveParens: false, - sourceType: 'module', - ...(config.acorn as Object) -}); +const getCache = (config: InputOptions): NormalizedInputOptions['cache'] => + config.cache === true // `true` is the default + ? undefined + : (config.cache as unknown as RollupBuild)?.cache || config.cache; -const getAcornInjectPlugins = (config: GenericConfigObject): Function[] => [ - injectClassFields, - injectPrivateMethods, - injectStaticClassFeatures, - ...(ensureArray(config.acornInjectPlugins) as any) -]; - -const getCache = (config: GenericConfigObject): false | undefined | RollupCache => { - return (config.cache as RollupBuild)?.cache || (config.cache as false | undefined | RollupCache); -}; - -const getIdMatcher = >( +const getIdMatcher = ( option: | undefined | boolean | string | RegExp | (string | RegExp)[] - | ((id: string, ...args: T) => boolean | null | undefined) -): ((id: string, ...args: T) => boolean) => { + | ((id: string, ...parameters: T) => boolean | null | void) +): ((id: string, ...parameters: T) => boolean) => { if (option === true) { return () => true; } if (typeof option === 'function') { - return (id, ...args) => (!id.startsWith('\0') && option(id, ...args)) || false; + return (id, ...parameters) => (id[0] !== '\0' && option(id, ...parameters)) || false; } if (option) { const ids = new Set(); @@ -137,154 +109,129 @@ const getIdMatcher = >( ids.add(value); } } - return (id: string, ..._args: T) => ids.has(id) || matchers.some(matcher => matcher.test(id)); + return (id: string, ..._arguments) => ids.has(id) || matchers.some(matcher => matcher.test(id)); } return () => false; }; -const getInlineDynamicImports = ( - config: GenericConfigObject, - warn: WarningHandler, - strictDeprecations: boolean -): boolean | undefined => { - const configInlineDynamicImports = config.inlineDynamicImports as boolean | undefined; - if (configInlineDynamicImports) { - warnDeprecationWithOptions( - 'The "inlineDynamicImports" option is deprecated. Use the "output.inlineDynamicImports" option instead.', - false, - warn, - strictDeprecations - ); - } - return configInlineDynamicImports; +const getInput = (config: InputOptions): NormalizedInputOptions['input'] => { + const configInput = config.input; + return configInput == null ? [] : typeof configInput === 'string' ? [configInput] : configInput; }; -const getInput = (config: GenericConfigObject): string[] | { [entryAlias: string]: string } => { - const configInput = config.input as InputOption | undefined; - return configInput == null ? [] : typeof configInput === 'string' ? [configInput] : configInput; +const getJsx = (config: InputOptions): NormalizedInputOptions['jsx'] => { + const configJsx = config.jsx; + if (!configJsx) return false; + const configWithPreset = getOptionWithPreset(configJsx, jsxPresets, 'jsx', URL_JSX, 'false, '); + const { factory, importSource, mode } = configWithPreset; + switch (mode) { + case 'automatic': { + return { + factory: factory || 'React.createElement', + importSource: importSource || 'react', + jsxImportSource: configWithPreset.jsxImportSource || 'react/jsx-runtime', + mode: 'automatic' + }; + } + case 'preserve': { + if (importSource && !(factory || configWithPreset.fragment)) { + error( + logInvalidOption( + 'jsx', + URL_JSX, + 'when preserving JSX and specifying an importSource, you also need to specify a factory or fragment' + ) + ); + } + return { + factory: factory || null, + fragment: configWithPreset.fragment || null, + importSource: importSource || null, + mode: 'preserve' + }; + } + // case 'classic': + default: { + if (mode && mode !== 'classic') { + error( + logInvalidOption( + 'jsx.mode', + URL_JSX, + 'mode must be "automatic", "classic" or "preserve"', + mode + ) + ); + } + return { + factory: factory || 'React.createElement', + fragment: configWithPreset.fragment || 'React.Fragment', + importSource: importSource || null, + mode: 'classic' + }; + } + } }; -const getManualChunks = ( - config: GenericConfigObject, - warn: WarningHandler, - strictDeprecations: boolean -): ManualChunksOption | undefined => { - const configManualChunks = config.manualChunks as ManualChunksOption | undefined; - if (configManualChunks) { - warnDeprecationWithOptions( - 'The "manualChunks" option is deprecated. Use the "output.manualChunks" option instead.', - false, - warn, - strictDeprecations - ); +const getMaxParallelFileOps = ( + config: InputOptions +): NormalizedInputOptions['maxParallelFileOps'] => { + const maxParallelFileOps = config.maxParallelFileOps; + if (typeof maxParallelFileOps === 'number') { + if (maxParallelFileOps <= 0) return Infinity; + return maxParallelFileOps; } - return configManualChunks; + return 1000; }; const getModuleContext = ( - config: GenericConfigObject, + config: InputOptions, context: string -): ((id: string) => string) => { - const configModuleContext = config.moduleContext as - | ((id: string) => string | null | undefined) - | { [id: string]: string } - | undefined; +): NormalizedInputOptions['moduleContext'] => { + const configModuleContext = config.moduleContext; if (typeof configModuleContext === 'function') { return id => configModuleContext(id) ?? context; } if (configModuleContext) { - const contextByModuleId = Object.create(null); - for (const key of Object.keys(configModuleContext)) { - contextByModuleId[resolve(key)] = configModuleContext[key]; + const contextByModuleId: Record = Object.create(null); + for (const [key, moduleContext] of Object.entries(configModuleContext)) { + contextByModuleId[resolve(key)] = moduleContext; } - return id => contextByModuleId[id] || context; + return id => contextByModuleId[id] ?? context; } return () => context; }; -const getPreserveEntrySignatures = ( - config: GenericConfigObject, - unsetOptions: Set -): PreserveEntrySignaturesOption => { - const configPreserveEntrySignatures = config.preserveEntrySignatures as - | PreserveEntrySignaturesOption - | undefined; - if (configPreserveEntrySignatures == null) { - unsetOptions.add('preserveEntrySignatures'); - } - return configPreserveEntrySignatures ?? 'strict'; -}; - -const getPreserveModules = ( - config: GenericConfigObject, - warn: WarningHandler, - strictDeprecations: boolean -): boolean | undefined => { - const configPreserveModules = config.preserveModules as boolean | undefined; - if (configPreserveModules) { - warnDeprecationWithOptions( - 'The "preserveModules" option is deprecated. Use the "output.preserveModules" option instead.', - false, - warn, - strictDeprecations - ); - } - return configPreserveModules; -}; - -const getTreeshake = ( - config: GenericConfigObject, - warn: WarningHandler, - strictDeprecations: boolean -): - | false - | { - annotations: boolean; - moduleSideEffects: HasModuleSideEffects; - propertyReadSideEffects: boolean | 'always'; - tryCatchDeoptimization: boolean; - unknownGlobalSideEffects: boolean; - } => { - const configTreeshake = config.treeshake as boolean | TreeshakingOptions; +const getTreeshake = (config: InputOptions): NormalizedInputOptions['treeshake'] => { + const configTreeshake = config.treeshake; if (configTreeshake === false) { return false; } - if (configTreeshake && configTreeshake !== true) { - if (typeof configTreeshake.pureExternalModules !== 'undefined') { - warnDeprecationWithOptions( - `The "treeshake.pureExternalModules" option is deprecated. The "treeshake.moduleSideEffects" option should be used instead. "treeshake.pureExternalModules: true" is equivalent to "treeshake.moduleSideEffects: 'no-external'"`, - true, - warn, - strictDeprecations - ); - } - return { - annotations: configTreeshake.annotations !== false, - moduleSideEffects: getHasModuleSideEffects( - configTreeshake.moduleSideEffects, - configTreeshake.pureExternalModules, - warn - ), - propertyReadSideEffects: - (configTreeshake.propertyReadSideEffects === 'always' && 'always') || - configTreeshake.propertyReadSideEffects !== false, - tryCatchDeoptimization: configTreeshake.tryCatchDeoptimization !== false, - unknownGlobalSideEffects: configTreeshake.unknownGlobalSideEffects !== false - }; - } + const configWithPreset = getOptionWithPreset( + config.treeshake, + treeshakePresets, + 'treeshake', + URL_TREESHAKE, + 'false, true, ' + ); return { - annotations: true, - moduleSideEffects: () => true, - propertyReadSideEffects: true, - tryCatchDeoptimization: true, - unknownGlobalSideEffects: true + annotations: configWithPreset.annotations !== false, + correctVarValueBeforeDeclaration: configWithPreset.correctVarValueBeforeDeclaration === true, + manualPureFunctions: + (configWithPreset.manualPureFunctions as readonly string[] | undefined) ?? EMPTY_ARRAY, + moduleSideEffects: getHasModuleSideEffects( + configWithPreset.moduleSideEffects as ModuleSideEffectsOption | undefined + ), + propertyReadSideEffects: + configWithPreset.propertyReadSideEffects === 'always' + ? 'always' + : configWithPreset.propertyReadSideEffects !== false, + tryCatchDeoptimization: configWithPreset.tryCatchDeoptimization !== false, + unknownGlobalSideEffects: configWithPreset.unknownGlobalSideEffects !== false }; }; const getHasModuleSideEffects = ( - moduleSideEffectsOption: ModuleSideEffectsOption | undefined, - pureExternalModules: PureModulesOption | undefined, - warn: WarningHandler + moduleSideEffectsOption: ModuleSideEffectsOption | undefined ): HasModuleSideEffects => { if (typeof moduleSideEffectsOption === 'boolean') { return () => moduleSideEffectsOption; @@ -294,20 +241,20 @@ const getHasModuleSideEffects = ( } if (typeof moduleSideEffectsOption === 'function') { return (id, external) => - !id.startsWith('\0') ? moduleSideEffectsOption(id, external) !== false : true; + id[0] === '\0' ? true : moduleSideEffectsOption(id, external) !== false; } if (Array.isArray(moduleSideEffectsOption)) { const ids = new Set(moduleSideEffectsOption); return id => ids.has(id); } if (moduleSideEffectsOption) { - warn( - errInvalidOption( + error( + logInvalidOption( 'treeshake.moduleSideEffects', + URL_TREESHAKE_MODULESIDEEFFECTS, 'please use one of false, "no-external", a function or an array' ) ); } - const isPureExternalModule = getIdMatcher(pureExternalModules); - return (id, external) => !(external && isPureExternalModule(id)); + return () => true; }; diff --git a/src/utils/options/normalizeOutputOptions.ts b/src/utils/options/normalizeOutputOptions.ts index 5cf14024e29..270f5166f6e 100644 --- a/src/utils/options/normalizeOutputOptions.ts +++ b/src/utils/options/normalizeOutputOptions.ts @@ -1,261 +1,325 @@ -import { - GetInterop, - GlobalsOption, +import type { InternalModuleFormat, InteropType, - ManualChunksOption, - ModuleFormat, NormalizedInputOptions, NormalizedOutputOptions, - OptionsPaths, OutputOptions, SourcemapPathTransformOption } from '../../rollup/types'; -import { ensureArray } from '../ensureArray'; -import { errInvalidExportOptionValue, error, warnDeprecation } from '../error'; +import { error, logInvalidExportOptionValue, logInvalidOption, warnDeprecation } from '../logs'; import { resolve } from '../path'; -import { GenericConfigObject, warnUnknownOptions } from './options'; +import { sanitizeFileName as defaultSanitizeFileName } from '../sanitizeFileName'; +import { addTrailingSlashIfMissed, isValidUrl } from '../url'; +import { + URL_OUTPUT_AMD_BASEPATH, + URL_OUTPUT_AMD_ID, + URL_OUTPUT_DIR, + URL_OUTPUT_EXTERNALIMPORTATTRIBUTES, + URL_OUTPUT_FORMAT, + URL_OUTPUT_GENERATEDCODE, + URL_OUTPUT_INLINEDYNAMICIMPORTS, + URL_OUTPUT_INTEROP, + URL_OUTPUT_MANUALCHUNKS, + URL_OUTPUT_SOURCEMAPBASEURL, + URL_PRESERVEENTRYSIGNATURES +} from '../urls'; +import { + generatedCodePresets, + getOptionWithPreset, + normalizePluginOption, + warnUnknownOptions +} from './options'; -export function normalizeOutputOptions( - config: GenericConfigObject, +export async function normalizeOutputOptions( + config: OutputOptions, inputOptions: NormalizedInputOptions, - unsetInputOptions: Set -): { options: NormalizedOutputOptions; unsetOptions: Set } { + unsetInputOptions: ReadonlySet +): Promise<{ options: NormalizedOutputOptions; unsetOptions: Set }> { // These are options that may trigger special warnings or behaviour later // if the user did not select an explicit value const unsetOptions = new Set(unsetInputOptions); - const compact = (config.compact as boolean | undefined) || false; + const compact = config.compact || false; const format = getFormat(config); const inlineDynamicImports = getInlineDynamicImports(config, inputOptions); const preserveModules = getPreserveModules(config, inlineDynamicImports, inputOptions); const file = getFile(config, preserveModules, inputOptions); + const generatedCode = getGeneratedCode(config); + const externalImportAttributes = getExternalImportAttributes(config, inputOptions); const outputOptions: NormalizedOutputOptions & OutputOptions = { amd: getAmd(config), - assetFileNames: - (config.assetFileNames as string | undefined) ?? 'assets/[name]-[hash][extname]', + assetFileNames: config.assetFileNames ?? 'assets/[name]-[hash][extname]', banner: getAddon(config, 'banner'), - chunkFileNames: (config.chunkFileNames as string | undefined) ?? '[name]-[hash].js', + chunkFileNames: config.chunkFileNames ?? '[name]-[hash].js', compact, dir: getDir(config, file), - dynamicImportFunction: getDynamicImportFunction(config, inputOptions), + dynamicImportInCjs: config.dynamicImportInCjs ?? true, entryFileNames: getEntryFileNames(config, unsetOptions), - esModule: (config.esModule as boolean | undefined) ?? true, + esModule: config.esModule ?? 'if-default-prop', + experimentalMinChunkSize: config.experimentalMinChunkSize ?? 1, exports: getExports(config, unsetOptions), - extend: (config.extend as boolean | undefined) || false, - externalLiveBindings: (config.externalLiveBindings as boolean | undefined) ?? true, + extend: config.extend || false, + externalImportAssertions: externalImportAttributes, + externalImportAttributes, + externalLiveBindings: config.externalLiveBindings ?? true, file, footer: getAddon(config, 'footer'), format, - freeze: (config.freeze as boolean | undefined) ?? true, - globals: (config.globals as GlobalsOption | undefined) || {}, - hoistTransitiveImports: (config.hoistTransitiveImports as boolean | undefined) ?? true, + freeze: config.freeze ?? true, + generatedCode, + globals: config.globals || {}, + hashCharacters: config.hashCharacters ?? 'base64', + hoistTransitiveImports: config.hoistTransitiveImports ?? true, + importAttributesKey: config.importAttributesKey ?? 'assert', indent: getIndent(config, compact), inlineDynamicImports, - interop: getInterop(config, inputOptions), + interop: getInterop(config), intro: getAddon(config, 'intro'), - manualChunks: getManualChunks(config, inlineDynamicImports, preserveModules, inputOptions), + manualChunks: getManualChunks(config, inlineDynamicImports, preserveModules), minifyInternalExports: getMinifyInternalExports(config, format, compact), - name: config.name as string | undefined, - namespaceToStringTag: (config.namespaceToStringTag as boolean | undefined) || false, - noConflict: (config.noConflict as boolean | undefined) || false, + name: config.name, + noConflict: config.noConflict || false, + onlyExplicitManualChunks: config.onlyExplicitManualChunks || false, outro: getAddon(config, 'outro'), - paths: (config.paths as OptionsPaths | undefined) || {}, - plugins: ensureArray(config.plugins) as Plugin[], - preferConst: (config.preferConst as boolean | undefined) || false, + paths: config.paths || {}, + plugins: await normalizePluginOption(config.plugins), preserveModules, preserveModulesRoot: getPreserveModulesRoot(config), - sourcemap: (config.sourcemap as boolean | 'inline' | 'hidden' | undefined) || false, - sourcemapExcludeSources: (config.sourcemapExcludeSources as boolean | undefined) || false, - sourcemapFile: config.sourcemapFile as string | undefined, + reexportProtoFromExternal: config.reexportProtoFromExternal ?? true, + sanitizeFileName: + typeof config.sanitizeFileName === 'function' + ? config.sanitizeFileName + : config.sanitizeFileName === false + ? id => id + : defaultSanitizeFileName, + sourcemap: config.sourcemap || false, + sourcemapBaseUrl: getSourcemapBaseUrl(config), + sourcemapDebugIds: config.sourcemapDebugIds || false, + sourcemapExcludeSources: config.sourcemapExcludeSources || false, + sourcemapFile: config.sourcemapFile, + sourcemapFileNames: getSourcemapFileNames(config, unsetOptions), + sourcemapIgnoreList: + typeof config.sourcemapIgnoreList === 'function' + ? config.sourcemapIgnoreList + : config.sourcemapIgnoreList === false + ? () => false + : relativeSourcePath => relativeSourcePath.includes('node_modules'), sourcemapPathTransform: config.sourcemapPathTransform as | SourcemapPathTransformOption | undefined, - strict: (config.strict as boolean | undefined) ?? true, - systemNullSetters: (config.systemNullSetters as boolean | undefined) || false, - validate: (config.validate as boolean | undefined) || false + strict: config.strict ?? true, + systemNullSetters: config.systemNullSetters ?? true, + validate: config.validate || false, + virtualDirname: config.virtualDirname || '_virtual' }; - warnUnknownOptions(config, Object.keys(outputOptions), 'output options', inputOptions.onwarn); + warnUnknownOptions(config, Object.keys(outputOptions), 'output options', inputOptions.onLog); return { options: outputOptions, unsetOptions }; } const getFile = ( - config: GenericConfigObject, + config: OutputOptions, preserveModules: boolean, inputOptions: NormalizedInputOptions -): string | undefined => { - const file = config.file as string | undefined; +): NormalizedOutputOptions['file'] => { + const { file } = config; if (typeof file === 'string') { if (preserveModules) { - return error({ - code: 'INVALID_OPTION', - message: - 'You must set "output.dir" instead of "output.file" when using the "output.preserveModules" option.' - }); + return error( + logInvalidOption( + 'output.file', + URL_OUTPUT_DIR, + 'you must set "output.dir" instead of "output.file" when using the "output.preserveModules" option' + ) + ); } if (!Array.isArray(inputOptions.input)) - return error({ - code: 'INVALID_OPTION', - message: 'You must set "output.dir" instead of "output.file" when providing named inputs.' - }); + return error( + logInvalidOption( + 'output.file', + URL_OUTPUT_DIR, + 'you must set "output.dir" instead of "output.file" when providing named inputs' + ) + ); } return file; }; -const getFormat = (config: GenericConfigObject): InternalModuleFormat => { - const configFormat = config.format as ModuleFormat | undefined; +const getFormat = (config: OutputOptions): NormalizedOutputOptions['format'] => { + const configFormat = config.format; switch (configFormat) { case undefined: case 'es': case 'esm': - case 'module': + case 'module': { return 'es'; + } case 'cjs': - case 'commonjs': + case 'commonjs': { return 'cjs'; + } case 'system': - case 'systemjs': + case 'systemjs': { return 'system'; + } case 'amd': case 'iife': - case 'umd': + case 'umd': { return configFormat; - default: - return error({ - message: `You must specify "output.format", which can be one of "amd", "cjs", "system", "es", "iife" or "umd".`, - url: `https://rollupjs.org/guide/en/#outputformat` - }); + } + default: { + return error( + logInvalidOption( + 'output.format', + URL_OUTPUT_FORMAT, + `Valid values are "amd", "cjs", "system", "es", "iife" or "umd"`, + configFormat + ) + ); + } } }; const getInlineDynamicImports = ( - config: GenericConfigObject, + config: OutputOptions, inputOptions: NormalizedInputOptions -): boolean => { - const inlineDynamicImports = - ((config.inlineDynamicImports as boolean | undefined) ?? inputOptions.inlineDynamicImports) || - false; +): NormalizedOutputOptions['inlineDynamicImports'] => { + const inlineDynamicImports = config.inlineDynamicImports || false; const { input } = inputOptions; if (inlineDynamicImports && (Array.isArray(input) ? input : Object.keys(input)).length > 1) { - return error({ - code: 'INVALID_OPTION', - message: 'Multiple inputs are not supported for "output.inlineDynamicImports".' - }); + return error( + logInvalidOption( + 'output.inlineDynamicImports', + URL_OUTPUT_INLINEDYNAMICIMPORTS, + 'multiple inputs are not supported when "output.inlineDynamicImports" is true' + ) + ); } return inlineDynamicImports; }; const getPreserveModules = ( - config: GenericConfigObject, + config: OutputOptions, inlineDynamicImports: boolean, inputOptions: NormalizedInputOptions -): boolean => { - const preserveModules = - ((config.preserveModules as boolean | undefined) ?? inputOptions.preserveModules) || false; +): NormalizedOutputOptions['preserveModules'] => { + const preserveModules = config.preserveModules || false; if (preserveModules) { if (inlineDynamicImports) { - return error({ - code: 'INVALID_OPTION', - message: `The "output.inlineDynamicImports" option is not supported for "output.preserveModules".` - }); + return error( + logInvalidOption( + 'output.inlineDynamicImports', + URL_OUTPUT_INLINEDYNAMICIMPORTS, + `this option is not supported for "output.preserveModules"` + ) + ); } if (inputOptions.preserveEntrySignatures === false) { - return error({ - code: 'INVALID_OPTION', - message: - 'Setting "preserveEntrySignatures" to "false" is not supported for "output.preserveModules".' - }); + return error( + logInvalidOption( + 'preserveEntrySignatures', + URL_PRESERVEENTRYSIGNATURES, + 'setting this option to false is not supported for "output.preserveModules"' + ) + ); } } return preserveModules; }; -const getPreserveModulesRoot = (config: GenericConfigObject): string | undefined => { - const preserveModulesRoot = config.preserveModulesRoot as string | null | undefined; +const getPreserveModulesRoot = ( + config: OutputOptions +): NormalizedOutputOptions['preserveModulesRoot'] => { + const { preserveModulesRoot } = config; if (preserveModulesRoot === null || preserveModulesRoot === undefined) { return undefined; } return resolve(preserveModulesRoot); }; -const getAmd = (config: GenericConfigObject): NormalizedOutputOptions['amd'] => { - const collection: { autoId: boolean; basePath: string; define: string; id?: string } = { +const getAmd = (config: OutputOptions): NormalizedOutputOptions['amd'] => { + const mergedOption: { + autoId: boolean; + basePath: string; + define: string; + forceJsExtensionForImports: boolean; + id?: string; + } = { autoId: false, basePath: '', define: 'define', - ...(config.amd as OutputOptions['amd']) + forceJsExtensionForImports: false, + ...config.amd }; - if ((collection.autoId || collection.basePath) && collection.id) { - return error({ - code: 'INVALID_OPTION', - message: - '"output.amd.autoId"/"output.amd.basePath" and "output.amd.id" cannot be used together.' - }); + if ((mergedOption.autoId || mergedOption.basePath) && mergedOption.id) { + return error( + logInvalidOption( + 'output.amd.id', + URL_OUTPUT_AMD_ID, + 'this option cannot be used together with "output.amd.autoId"/"output.amd.basePath"' + ) + ); } - if (collection.basePath && !collection.autoId) { - return error({ - code: 'INVALID_OPTION', - message: '"output.amd.basePath" only works with "output.amd.autoId".' - }); + if (mergedOption.basePath && !mergedOption.autoId) { + return error( + logInvalidOption( + 'output.amd.basePath', + URL_OUTPUT_AMD_BASEPATH, + 'this option only works with "output.amd.autoId"' + ) + ); } - let normalized: NormalizedOutputOptions['amd']; - if (collection.autoId) { - normalized = { - autoId: true, - basePath: collection.basePath, - define: collection.define - }; - } else { - normalized = { - autoId: false, - define: collection.define, - id: collection.id - }; - } - return normalized; + return mergedOption.autoId + ? { + autoId: true, + basePath: mergedOption.basePath, + define: mergedOption.define, + forceJsExtensionForImports: mergedOption.forceJsExtensionForImports + } + : { + autoId: false, + define: mergedOption.define, + forceJsExtensionForImports: mergedOption.forceJsExtensionForImports, + id: mergedOption.id + }; }; -const getAddon = (config: GenericConfigObject, name: string): (() => string | Promise) => { - const configAddon = config[name] as string | (() => string | Promise); +const getAddon = ( + config: OutputOptions, + name: T +): NormalizedOutputOptions[T] => { + const configAddon = config[name]; if (typeof configAddon === 'function') { - return configAddon; + return configAddon as NormalizedOutputOptions[T]; } return () => configAddon || ''; }; -const getDir = (config: GenericConfigObject, file: string | undefined): string | undefined => { - const dir = config.dir as string | undefined; +const getDir = ( + config: OutputOptions, + file: string | undefined +): NormalizedOutputOptions['dir'] => { + const { dir } = config; if (typeof dir === 'string' && typeof file === 'string') { - return error({ - code: 'INVALID_OPTION', - message: - 'You must set either "output.file" for a single-file build or "output.dir" when generating multiple chunks.' - }); - } - return dir; -}; - -const getDynamicImportFunction = ( - config: GenericConfigObject, - inputOptions: NormalizedInputOptions -): string | undefined => { - const configDynamicImportFunction = config.dynamicImportFunction as string | undefined; - if (configDynamicImportFunction) { - warnDeprecation( - `The "output.dynamicImportFunction" option is deprecated. Use the "renderDynamicImport" plugin hook instead.`, - false, - inputOptions + return error( + logInvalidOption( + 'output.dir', + URL_OUTPUT_DIR, + 'you must set either "output.file" for a single-file build or "output.dir" when generating multiple chunks' + ) ); } - return configDynamicImportFunction; + return dir; }; -const getEntryFileNames = (config: GenericConfigObject, unsetOptions: Set): string => { - const configEntryFileNames = config.entryFileNames as string | undefined; +const getEntryFileNames = ( + config: OutputOptions, + unsetOptions: Set +): NormalizedOutputOptions['entryFileNames'] => { + const configEntryFileNames = config.entryFileNames; if (configEntryFileNames == null) { unsetOptions.add('entryFileNames'); } @@ -263,107 +327,159 @@ const getEntryFileNames = (config: GenericConfigObject, unsetOptions: Set -): 'default' | 'named' | 'none' | 'auto' { - const configExports = config.exports as string | undefined; +): NormalizedOutputOptions['exports'] { + const configExports = config.exports; if (configExports == null) { unsetOptions.add('exports'); } else if (!['default', 'named', 'none', 'auto'].includes(configExports)) { - return error(errInvalidExportOptionValue(configExports)); + return error(logInvalidExportOptionValue(configExports)); } - return (configExports as 'default' | 'named' | 'none' | 'auto') || 'auto'; + return configExports || 'auto'; } -const getIndent = (config: GenericConfigObject, compact: boolean): string | true => { +const getExternalImportAttributes = ( + config: OutputOptions, + inputOptions: NormalizedInputOptions +): NormalizedOutputOptions['externalImportAttributes'] => { + if (config.externalImportAssertions != undefined) { + warnDeprecation( + `The "output.externalImportAssertions" option is deprecated. Use the "output.externalImportAttributes" option instead.`, + URL_OUTPUT_EXTERNALIMPORTATTRIBUTES, + true, + inputOptions + ); + } + return config.externalImportAttributes ?? config.externalImportAssertions ?? true; +}; + +const getGeneratedCode = (config: OutputOptions): NormalizedOutputOptions['generatedCode'] => { + const configWithPreset = getOptionWithPreset( + config.generatedCode, + generatedCodePresets, + 'output.generatedCode', + URL_OUTPUT_GENERATEDCODE, + '' + ); + return { + arrowFunctions: configWithPreset.arrowFunctions === true, + constBindings: configWithPreset.constBindings === true, + objectShorthand: configWithPreset.objectShorthand === true, + reservedNamesAsProps: configWithPreset.reservedNamesAsProps !== false, + symbols: configWithPreset.symbols === true + }; +}; + +const getIndent = (config: OutputOptions, compact: boolean): NormalizedOutputOptions['indent'] => { if (compact) { return ''; } - const configIndent = config.indent as string | boolean | undefined; - return configIndent === false ? '' : configIndent ?? true; + const configIndent = config.indent; + return configIndent === false ? '' : (configIndent ?? true); }; -const ALLOWED_INTEROP_TYPES = new Set(['auto', 'esModule', 'default', 'defaultOnly', true, false]); -const getInterop = ( - config: GenericConfigObject, - inputOptions: NormalizedInputOptions -): GetInterop => { - const configInterop = config.interop as InteropType | GetInterop | undefined; - const validatedInteropTypes = new Set(); - const validateInterop = (interop: InteropType): InteropType => { - if (!validatedInteropTypes.has(interop)) { - validatedInteropTypes.add(interop); - if (!ALLOWED_INTEROP_TYPES.has(interop)) { - return error({ - code: 'INVALID_OPTION', - message: `The value ${JSON.stringify( - interop - )} is not supported for "output.interop". Use one of ${Array.from( - ALLOWED_INTEROP_TYPES.values(), - value => JSON.stringify(value) - ).join(', ')} instead.`, - url: 'https://rollupjs.org/guide/en/#outputinterop' - }); - } - if (typeof interop === 'boolean') { - warnDeprecation( - { - message: `The boolean value "${interop}" for the "output.interop" option is deprecated. Use ${ - interop ? '"auto"' : '"esModule", "default" or "defaultOnly"' - } instead.`, - url: 'https://rollupjs.org/guide/en/#outputinterop' - }, - false, - inputOptions - ); - } - } - return interop; - }; +const ALLOWED_INTEROP_TYPES: ReadonlySet = new Set([ + 'compat', + 'auto', + 'esModule', + 'default', + 'defaultOnly' +]); +const getInterop = (config: OutputOptions): NormalizedOutputOptions['interop'] => { + const configInterop = config.interop; if (typeof configInterop === 'function') { - const interopPerId: { [id: string]: InteropType } = Object.create(null); + const interopPerId: Record = Object.create(null); let defaultInterop: InteropType | null = null; return id => id === null ? defaultInterop || validateInterop((defaultInterop = configInterop(id))) : id in interopPerId - ? interopPerId[id] - : validateInterop((interopPerId[id] = configInterop(id))); + ? interopPerId[id] + : validateInterop((interopPerId[id] = configInterop(id))); + } + return configInterop === undefined ? () => 'default' : () => validateInterop(configInterop); +}; + +const validateInterop = (interop: InteropType): InteropType => { + if (!ALLOWED_INTEROP_TYPES.has(interop)) { + return error( + logInvalidOption( + 'output.interop', + URL_OUTPUT_INTEROP, + + `use one of ${Array.from(ALLOWED_INTEROP_TYPES, value => JSON.stringify(value)).join( + ', ' + )}`, + interop + ) + ); } - return configInterop === undefined ? () => true : () => validateInterop(configInterop); + return interop; }; const getManualChunks = ( - config: GenericConfigObject, + config: OutputOptions, inlineDynamicImports: boolean, - preserveModules: boolean, - inputOptions: NormalizedInputOptions -): ManualChunksOption => { - const configManualChunks = - (config.manualChunks as ManualChunksOption | undefined) || inputOptions.manualChunks; + preserveModules: boolean +): NormalizedOutputOptions['manualChunks'] => { + const configManualChunks = config.manualChunks; if (configManualChunks) { if (inlineDynamicImports) { - return error({ - code: 'INVALID_OPTION', - message: - 'The "output.manualChunks" option is not supported for "output.inlineDynamicImports".' - }); + return error( + logInvalidOption( + 'output.manualChunks', + URL_OUTPUT_MANUALCHUNKS, + 'this option is not supported for "output.inlineDynamicImports"' + ) + ); } if (preserveModules) { - return error({ - code: 'INVALID_OPTION', - message: 'The "output.manualChunks" option is not supported for "output.preserveModules".' - }); + return error( + logInvalidOption( + 'output.manualChunks', + URL_OUTPUT_MANUALCHUNKS, + 'this option is not supported for "output.preserveModules"' + ) + ); } } return configManualChunks || {}; }; const getMinifyInternalExports = ( - config: GenericConfigObject, + config: OutputOptions, format: InternalModuleFormat, compact: boolean -): boolean => - (config.minifyInternalExports as boolean | undefined) ?? - (compact || format === 'es' || format === 'system'); +): NormalizedOutputOptions['minifyInternalExports'] => + config.minifyInternalExports ?? (compact || format === 'es' || format === 'system'); + +const getSourcemapFileNames = ( + config: OutputOptions, + unsetOptions: Set +): NormalizedOutputOptions['sourcemapFileNames'] => { + const configSourcemapFileNames = config.sourcemapFileNames; + if (configSourcemapFileNames == null) { + unsetOptions.add('sourcemapFileNames'); + } + return configSourcemapFileNames; +}; + +const getSourcemapBaseUrl = ( + config: OutputOptions +): NormalizedOutputOptions['sourcemapBaseUrl'] => { + const { sourcemapBaseUrl } = config; + if (sourcemapBaseUrl) { + if (isValidUrl(sourcemapBaseUrl)) { + return addTrailingSlashIfMissed(sourcemapBaseUrl); + } + return error( + logInvalidOption( + 'output.sourcemapBaseUrl', + URL_OUTPUT_SOURCEMAPBASEURL, + `must be a valid URL, received ${JSON.stringify(sourcemapBaseUrl)}` + ) + ); + } +}; diff --git a/src/utils/options/options.ts b/src/utils/options/options.ts index a7ddc54f640..d4e91c6f1a4 100644 --- a/src/utils/options/options.ts +++ b/src/utils/options/options.ts @@ -1,30 +1,254 @@ -import { WarningHandler } from '../../rollup/types'; +import type { + InputOptions, + InputPluginOption, + LogHandler, + LogLevelOption, + NormalizedGeneratedCodeOptions, + NormalizedInputOptions, + NormalizedJsxOptions, + NormalizedOutputOptions, + NormalizedTreeshakingOptions, + OutputOptions, + OutputPlugin, + OutputPluginOption, + Plugin, + RollupLog, + WarningHandlerWithDefault +} from '../../rollup/types'; +import { asyncFlatten } from '../asyncFlatten'; +import { EMPTY_ARRAY } from '../blank'; +import { LOGLEVEL_DEBUG, LOGLEVEL_ERROR, LOGLEVEL_WARN, logLevelPriority } from '../logging'; +import { error, logInvalidOption, logUnknownOption } from '../logs'; +import { printQuotedStringList } from '../printStringList'; -export interface GenericConfigObject { - [key: string]: unknown; -} +export type GenericConfigObject = Record; + +export const getOnLog = ( + config: InputOptions, + logLevel: LogLevelOption, + printLog = defaultPrintLog +): NormalizedInputOptions['onLog'] => { + const { onwarn, onLog } = config; + const defaultOnLog = getDefaultOnLog(printLog, onwarn); + if (onLog) { + const minimalPriority = logLevelPriority[logLevel]; + return (level, log) => + onLog(level, addLogToString(log), (level, handledLog) => { + if (level === LOGLEVEL_ERROR) { + return error(normalizeLog(handledLog)); + } + if (logLevelPriority[level] >= minimalPriority) { + defaultOnLog(level, normalizeLog(handledLog)); + } + }); + } + return defaultOnLog; +}; + +const getDefaultOnLog = (printLog: LogHandler, onwarn?: WarningHandlerWithDefault): LogHandler => + onwarn + ? (level, log) => { + if (level === LOGLEVEL_WARN) { + onwarn(addLogToString(log), warning => printLog(LOGLEVEL_WARN, normalizeLog(warning))); + } else { + printLog(level, log); + } + } + : printLog; + +const addLogToString = (log: RollupLog): RollupLog => { + Object.defineProperty(log, 'toString', { + value: () => log.message, + writable: true + }); + return log; +}; -export const defaultOnWarn: WarningHandler = warning => console.warn(warning.message || warning); +export const normalizeLog = (log: RollupLog | string | (() => RollupLog | string)): RollupLog => + typeof log === 'string' + ? { message: log } + : typeof log === 'function' + ? normalizeLog(log()) + : log; + +const defaultPrintLog: LogHandler = (level, { message }) => { + switch (level) { + case LOGLEVEL_WARN: { + return console.warn(message); + } + case LOGLEVEL_DEBUG: { + return console.debug(message); + } + default: { + return console.info(message); + } + } +}; export function warnUnknownOptions( - passedOptions: GenericConfigObject, - validOptions: string[], + passedOptions: object, + validOptions: readonly string[], optionType: string, - warn: WarningHandler, - ignoredKeys: RegExp = /$./ + log: LogHandler, + ignoredKeys = /$./ ): void { const validOptionSet = new Set(validOptions); const unknownOptions = Object.keys(passedOptions).filter( key => !(validOptionSet.has(key) || ignoredKeys.test(key)) ); if (unknownOptions.length > 0) { - warn({ - code: 'UNKNOWN_OPTION', - message: `Unknown ${optionType}: ${unknownOptions.join(', ')}. Allowed options: ${[ - ...validOptionSet - ] - .sort() - .join(', ')}` - }); + log(LOGLEVEL_WARN, logUnknownOption(optionType, unknownOptions, [...validOptionSet].sort())); } } + +type ObjectValue = Base extends Record ? Base : never; + +export const treeshakePresets: Record< + NonNullable['preset']>, + NormalizedTreeshakingOptions +> = { + recommended: { + annotations: true, + correctVarValueBeforeDeclaration: false, + manualPureFunctions: EMPTY_ARRAY, + moduleSideEffects: () => true, + propertyReadSideEffects: true, + tryCatchDeoptimization: true, + unknownGlobalSideEffects: false + }, + safest: { + annotations: true, + correctVarValueBeforeDeclaration: true, + manualPureFunctions: EMPTY_ARRAY, + moduleSideEffects: () => true, + propertyReadSideEffects: true, + tryCatchDeoptimization: true, + unknownGlobalSideEffects: true + }, + smallest: { + annotations: true, + correctVarValueBeforeDeclaration: false, + manualPureFunctions: EMPTY_ARRAY, + moduleSideEffects: () => false, + propertyReadSideEffects: false, + tryCatchDeoptimization: false, + unknownGlobalSideEffects: false + } +}; + +export const jsxPresets: Record< + NonNullable['preset']>, + NormalizedJsxOptions +> = { + preserve: { + factory: null, + fragment: null, + importSource: null, + mode: 'preserve' + }, + 'preserve-react': { + factory: 'React.createElement', + fragment: 'React.Fragment', + importSource: 'react', + mode: 'preserve' + }, + react: { + factory: 'React.createElement', + fragment: 'React.Fragment', + importSource: 'react', + mode: 'classic' + }, + 'react-jsx': { + factory: 'React.createElement', + importSource: 'react', + jsxImportSource: 'react/jsx-runtime', + mode: 'automatic' + } +}; + +export const generatedCodePresets: Record< + NonNullable['preset']>, + NormalizedOutputOptions['generatedCode'] +> = { + es2015: { + arrowFunctions: true, + constBindings: true, + objectShorthand: true, + reservedNamesAsProps: true, + symbols: true + }, + es5: { + arrowFunctions: false, + constBindings: false, + objectShorthand: false, + reservedNamesAsProps: true, + symbols: false + } +}; + +type ObjectOptionWithPresets = + | Partial + | Partial + | Partial; + +export const objectifyOption = (value: unknown): Record => + value && typeof value === 'object' ? (value as Record) : {}; + +export const objectifyOptionWithPresets = + ( + presets: Record, + optionName: string, + urlSnippet: string, + additionalValues: string + ) => + (value: unknown): Record => { + if (typeof value === 'string') { + const preset = presets[value]; + if (preset) { + return preset; + } + error( + logInvalidOption( + optionName, + urlSnippet, + `valid values are ${additionalValues}${printQuotedStringList( + Object.keys(presets) + )}. You can also supply an object for more fine-grained control`, + value + ) + ); + } + return objectifyOption(value); + }; + +export const getOptionWithPreset = ( + value: unknown, + presets: Record, + optionName: string, + urlSnippet: string, + additionalValues: string +): T => { + const presetName: string | undefined = (value as any)?.preset; + if (presetName) { + const preset = presets[presetName]; + if (preset) { + return { ...preset, ...(value as Record) }; + } else { + error( + logInvalidOption( + `${optionName}.preset`, + urlSnippet, + `valid values are ${printQuotedStringList(Object.keys(presets))}`, + presetName + ) + ); + } + } + return objectifyOptionWithPresets(presets, optionName, urlSnippet, additionalValues)(value) as T; +}; + +export const normalizePluginOption: { + (plugins: InputPluginOption): Promise; + (plugins: OutputPluginOption): Promise; + (plugins: unknown): Promise; +} = async (plugins: any) => (await asyncFlatten([plugins])).filter(Boolean); diff --git a/src/utils/outputBundle.ts b/src/utils/outputBundle.ts new file mode 100644 index 00000000000..2be71781acc --- /dev/null +++ b/src/utils/outputBundle.ts @@ -0,0 +1,61 @@ +import type { OutputAsset, OutputBundle, OutputChunk } from '../rollup/types'; + +export const lowercaseBundleKeys = Symbol('bundleKeys'); + +export const FILE_PLACEHOLDER = { + type: 'placeholder' as const +}; + +export interface OutputBundleWithPlaceholders { + [fileName: string]: OutputAsset | OutputChunk | typeof FILE_PLACEHOLDER; + [lowercaseBundleKeys]: Set; +} + +export const getOutputBundle = (outputBundleBase: OutputBundle): OutputBundleWithPlaceholders => { + const reservedLowercaseBundleKeys = new Set(); + return new Proxy(outputBundleBase, { + deleteProperty(target, key) { + if (typeof key === 'string') { + reservedLowercaseBundleKeys.delete(key.toLowerCase()); + } + return Reflect.deleteProperty(target, key); + }, + get(target, key) { + if (key === lowercaseBundleKeys) { + return reservedLowercaseBundleKeys; + } + return Reflect.get(target, key); + }, + set(target, key, value) { + if (typeof key === 'string') { + reservedLowercaseBundleKeys.add(key.toLowerCase()); + } + return Reflect.set(target, key, value); + } + }) as OutputBundleWithPlaceholders; +}; + +export const removeUnreferencedAssets = (outputBundle: OutputBundleWithPlaceholders) => { + const unreferencedAssets = new Set(); + const bundleEntries = Object.values(outputBundle); + + for (const asset of bundleEntries) { + if (asset.type === 'asset' && asset.needsCodeReference) { + unreferencedAssets.add(asset.fileName); + } + } + + for (const chunk of bundleEntries) { + if (chunk.type === 'chunk') { + for (const referencedFile of chunk.referencedFiles) { + if (unreferencedAssets.has(referencedFile)) { + unreferencedAssets.delete(referencedFile); + } + } + } + } + + for (const file of unreferencedAssets) { + delete outputBundle[file]; + } +}; diff --git a/src/utils/parseAst.ts b/src/utils/parseAst.ts new file mode 100644 index 00000000000..4300ad847d3 --- /dev/null +++ b/src/utils/parseAst.ts @@ -0,0 +1,14 @@ +import { parse, parseAsync } from '../../native'; +import type { ParseAst, ParseAstAsync } from '../rollup/types'; +import { convertProgram } from './bufferToAst'; +import { getAstBuffer } from './getAstBuffer'; + +export const parseAst: ParseAst = ( + input, + { allowReturnOutsideFunction = false, jsx = false } = {} +) => convertProgram(getAstBuffer(parse(input, allowReturnOutsideFunction, jsx))); + +export const parseAstAsync: ParseAstAsync = async ( + input, + { allowReturnOutsideFunction = false, jsx = false, signal } = {} +) => convertProgram(getAstBuffer(await parseAsync(input, allowReturnOutsideFunction, jsx, signal))); diff --git a/src/utils/parseAstType.d.ts b/src/utils/parseAstType.d.ts new file mode 100644 index 00000000000..aa706fb3983 --- /dev/null +++ b/src/utils/parseAstType.d.ts @@ -0,0 +1,4 @@ +import type { ParseAst, ParseAstAsync } from '../rollup/types'; + +export const parseAst: ParseAst; +export const parseAstAsync: ParseAstAsync; diff --git a/src/utils/parseImportAttributes.ts b/src/utils/parseImportAttributes.ts new file mode 100644 index 00000000000..0775a8ab02f --- /dev/null +++ b/src/utils/parseImportAttributes.ts @@ -0,0 +1,87 @@ +import type Identifier from '../ast/nodes/Identifier'; +import type ImportAttribute from '../ast/nodes/ImportAttribute'; +import type ImportExpression from '../ast/nodes/ImportExpression'; +import type { default as Literal, LiteralValue } from '../ast/nodes/Literal'; +import ObjectExpression from '../ast/nodes/ObjectExpression'; +import type Property from '../ast/nodes/Property'; +import type SpreadElement from '../ast/nodes/SpreadElement'; +import { EMPTY_OBJECT } from './blank'; +import { LOGLEVEL_WARN } from './logging'; +import { logImportAttributeIsInvalid, logImportOptionsAreInvalid } from './logs'; + +const ATTRIBUTE_KEYWORDS = new Set(['assert', 'with']); + +export function getAttributesFromImportExpression(node: ImportExpression): Record { + const { + scope: { context }, + options, + start + } = node; + if (!(options instanceof ObjectExpression)) { + if (options) { + context.module.log(LOGLEVEL_WARN, logImportAttributeIsInvalid(context.module.id), start); + } + return EMPTY_OBJECT; + } + const assertProperty = options.properties.find((property): property is Property => + ATTRIBUTE_KEYWORDS.has(getPropertyKey(property) as string) + )?.value; + if (!assertProperty) { + return EMPTY_OBJECT; + } + if (!(assertProperty instanceof ObjectExpression)) { + context.module.log(LOGLEVEL_WARN, logImportOptionsAreInvalid(context.module.id), start); + return EMPTY_OBJECT; + } + const assertFields = (assertProperty as ObjectExpression).properties + .map(property => { + const key = getPropertyKey(property); + if ( + typeof key === 'string' && + typeof ((property as Property).value as Literal).value === 'string' + ) { + return [key, ((property as Property).value as Literal).value] as [string, string]; + } + context.module.log( + LOGLEVEL_WARN, + logImportAttributeIsInvalid(context.module.id), + property.start + ); + return null; + }) + .filter((property): property is [string, string] => !!property); + if (assertFields.length > 0) { + return Object.fromEntries(assertFields); + } + return EMPTY_OBJECT; +} + +const getPropertyKey = (property: Property | SpreadElement | ImportAttribute): LiteralValue => { + const key = (property as Property | ImportAttribute).key; + return ( + key && + !(property as Property).computed && + ((key as Identifier).name || (key as Literal).value) + ); +}; + +export function getAttributesFromImportExportDeclaration( + attributes: ImportAttribute[] +): Record { + return attributes?.length + ? Object.fromEntries( + attributes.map(assertion => [getPropertyKey(assertion), assertion.value.value]) + ) + : EMPTY_OBJECT; +} + +export function doAttributesDiffer( + assertionA: Record, + assertionB: Record +): boolean { + const keysA = Object.keys(assertionA); + return ( + keysA.length !== Object.keys(assertionB).length || + keysA.some(key => assertionA[key] !== assertionB[key]) + ); +} diff --git a/src/utils/path.ts b/src/utils/path.ts index d6480fb9819..6b8c61f5334 100644 --- a/src/utils/path.ts +++ b/src/utils/path.ts @@ -1,17 +1,18 @@ -const absolutePath = /^(?:\/|(?:[A-Za-z]:)?[\\|/])/; -const relativePath = /^\.?\.\//; +const ABSOLUTE_PATH_REGEX = /^(?:\/|(?:[A-Za-z]:)?[/\\|])/; +const RELATIVE_PATH_REGEX = /^\.?\.(\/|$)/; -export function isAbsolute(path: string) { - return absolutePath.test(path); +export function isAbsolute(path: string): boolean { + return ABSOLUTE_PATH_REGEX.test(path); } -export function isRelative(path: string) { - return relativePath.test(path); +export function isRelative(path: string): boolean { + return RELATIVE_PATH_REGEX.test(path); } -export function normalize(path: string) { - if (path.indexOf('\\') == -1) return path; - return path.replace(/\\/g, '/'); +const BACKSLASH_REGEX = /\\/g; + +export function normalize(path: string): string { + return path.replace(BACKSLASH_REGEX, '/'); } -export { basename, dirname, extname, relative, resolve } from 'path'; +export { basename, dirname, extname, relative, resolve } from 'node:path'; diff --git a/src/utils/performance.ts b/src/utils/performance.ts new file mode 100644 index 00000000000..baecf98c58e --- /dev/null +++ b/src/utils/performance.ts @@ -0,0 +1 @@ +export { performance as default } from 'node:perf_hooks'; diff --git a/src/utils/pluginFilter.ts b/src/utils/pluginFilter.ts new file mode 100644 index 00000000000..776317d608b --- /dev/null +++ b/src/utils/pluginFilter.ts @@ -0,0 +1,130 @@ +import picomatch from 'picomatch'; +import type { StringFilter, StringOrRegExp } from '../rollup/types'; +import { ensureArray } from './ensureArray'; +import { isAbsolute, normalize, resolve } from './path'; + +export type PluginFilter = (input: string) => boolean; +export type TransformHookFilter = (id: string, code: string) => boolean; + +interface NormalizedStringFilter { + include?: StringOrRegExp[]; + exclude?: StringOrRegExp[]; +} + +function getMatcherString(glob: string, cwd: string) { + if (glob.startsWith('**') || isAbsolute(glob)) { + return normalize(glob); + } + + const resolved = resolve(cwd, glob); + return normalize(resolved); +} + +function patternToIdFilter(pattern: StringOrRegExp): PluginFilter { + if (pattern instanceof RegExp) { + return (id: string) => { + const normalizedId = normalize(id); + const result = pattern.test(normalizedId); + pattern.lastIndex = 0; + return result; + }; + } + const cwd = process.cwd(); + const glob = getMatcherString(pattern, cwd); + const matcher = picomatch(glob, { dot: true }); + return (id: string) => { + const normalizedId = normalize(id); + return matcher(normalizedId); + }; +} + +function patternToCodeFilter(pattern: StringOrRegExp): PluginFilter { + if (pattern instanceof RegExp) { + return (code: string) => { + const result = pattern.test(code); + pattern.lastIndex = 0; + return result; + }; + } + return (code: string) => code.includes(pattern); +} + +function createFilter( + exclude: PluginFilter[] | undefined, + include: PluginFilter[] | undefined +): PluginFilter | undefined { + if (!exclude && !include) { + return; + } + + return input => { + if (exclude?.some(filter => filter(input))) { + return false; + } + if (include?.some(filter => filter(input))) { + return true; + } + return !(include && include.length > 0); + }; +} + +function normalizeFilter(filter: StringFilter): NormalizedStringFilter { + if (typeof filter === 'string' || filter instanceof RegExp) { + return { + include: [filter] + }; + } + if (Array.isArray(filter)) { + return { + include: filter + }; + } + return { + exclude: filter.exclude ? ensureArray(filter.exclude) : undefined, + include: filter.include ? ensureArray(filter.include) : undefined + }; +} + +function createIdFilter(filter: StringFilter | undefined): PluginFilter | undefined { + if (!filter) return; + const { exclude, include } = normalizeFilter(filter); + const excludeFilter = exclude?.map(patternToIdFilter); + const includeFilter = include?.map(patternToIdFilter); + return createFilter(excludeFilter, includeFilter); +} + +function createCodeFilter(filter: StringFilter | undefined): PluginFilter | undefined { + if (!filter) return; + const { exclude, include } = normalizeFilter(filter); + const excludeFilter = exclude?.map(patternToCodeFilter); + const includeFilter = include?.map(patternToCodeFilter); + return createFilter(excludeFilter, includeFilter); +} + +export function createFilterForId(filter: StringFilter | undefined): PluginFilter | undefined { + const filterFunction = createIdFilter(filter); + return filterFunction ? id => !!filterFunction(id) : undefined; +} + +export function createFilterForTransform( + idFilter: StringFilter | undefined, + codeFilter: StringFilter | undefined +): TransformHookFilter | undefined { + if (!idFilter && !codeFilter) return; + const idFilterFunction = createIdFilter(idFilter); + const codeFilterFunction = createCodeFilter(codeFilter); + return (id, code) => { + let fallback = true; + if (idFilterFunction) { + fallback &&= idFilterFunction(id); + } + if (!fallback) { + return false; + } + + if (codeFilterFunction) { + fallback &&= codeFilterFunction(code); + } + return fallback; + }; +} diff --git a/src/utils/pluginNames.ts b/src/utils/pluginNames.ts new file mode 100644 index 00000000000..7ee68f4367a --- /dev/null +++ b/src/utils/pluginNames.ts @@ -0,0 +1,2 @@ +export const ANONYMOUS_PLUGIN_PREFIX = 'at position '; +export const ANONYMOUS_OUTPUT_PLUGIN_PREFIX = 'at output position '; diff --git a/src/utils/pluginUtils.ts b/src/utils/pluginUtils.ts deleted file mode 100644 index 651122cf2dc..00000000000 --- a/src/utils/pluginUtils.ts +++ /dev/null @@ -1,46 +0,0 @@ -import { NormalizedInputOptions, Plugin, RollupError } from '../rollup/types'; -import { error, Errors, warnDeprecation } from './error'; - -export const ANONYMOUS_PLUGIN_PREFIX = 'at position '; -export const ANONYMOUS_OUTPUT_PLUGIN_PREFIX = 'at output position '; - -export function throwPluginError( - err: string | RollupError, - plugin: string, - { hook, id }: { hook?: string; id?: string } = {} -): never { - if (typeof err === 'string') err = { message: err }; - if (err.code && err.code !== Errors.PLUGIN_ERROR) { - err.pluginCode = err.code; - } - err.code = Errors.PLUGIN_ERROR; - err.plugin = plugin; - if (hook) { - err.hook = hook; - } - if (id) { - err.id = id; - } - return error(err); -} - -export const deprecatedHooks: { active: boolean; deprecated: string; replacement: string }[] = [ - { active: true, deprecated: 'resolveAssetUrl', replacement: 'resolveFileUrl' } -]; - -export function warnDeprecatedHooks(plugins: Plugin[], options: NormalizedInputOptions) { - for (const { active, deprecated, replacement } of deprecatedHooks) { - for (const plugin of plugins) { - if (deprecated in plugin) { - warnDeprecation( - { - message: `The "${deprecated}" hook used by plugin ${plugin.name} is deprecated. The "${replacement}" hook should be used instead.`, - plugin: plugin.name - }, - active, - options - ); - } - } - } -} diff --git a/src/utils/printStringList.ts b/src/utils/printStringList.ts new file mode 100644 index 00000000000..80445ebb8fa --- /dev/null +++ b/src/utils/printStringList.ts @@ -0,0 +1,14 @@ +export function printQuotedStringList( + list: readonly string[], + verbs?: readonly [string, string] +): string { + const isSingleItem = list.length <= 1; + const quotedList = list.map(item => `"${item}"`); + let output = isSingleItem + ? quotedList[0] + : `${quotedList.slice(0, -1).join(', ')} and ${quotedList.slice(-1)[0]}`; + if (verbs) { + output += ` ${isSingleItem ? verbs[0] : verbs[1]}`; + } + return output; +} diff --git a/src/utils/process.ts b/src/utils/process.ts new file mode 100644 index 00000000000..f9f55ca5a26 --- /dev/null +++ b/src/utils/process.ts @@ -0,0 +1 @@ +export { default } from 'node:process'; diff --git a/src/utils/pureComments.ts b/src/utils/pureComments.ts deleted file mode 100644 index f6c681d3074..00000000000 --- a/src/utils/pureComments.ts +++ /dev/null @@ -1,70 +0,0 @@ -import * as acorn from 'acorn'; -import { base as basicWalker, BaseWalker } from 'acorn-walk'; -import { - CallExpression, - ChainExpression, - ExpressionStatement, - NewExpression -} from '../ast/nodes/NodeType'; -import { Annotation } from '../ast/nodes/shared/Node'; - -// patch up acorn-walk until class-fields are officially supported -basicWalker.PropertyDefinition = function (node: any, st: any, c: any) { - if (node.computed) { - c(node.key, st, 'Expression'); - } - if (node.value) { - c(node.value, st, 'Expression'); - } -}; - -interface CommentState { - commentIndex: number; - commentNodes: acorn.Comment[]; -} - -function handlePureAnnotationsOfNode( - node: acorn.Node, - state: CommentState, - type: string = node.type -) { - let commentNode = state.commentNodes[state.commentIndex]; - while (commentNode && node.start >= commentNode.end) { - markPureNode(node, commentNode); - commentNode = state.commentNodes[++state.commentIndex]; - } - if (commentNode && commentNode.end <= node.end) { - (basicWalker as BaseWalker)[type](node, state, handlePureAnnotationsOfNode); - } -} - -function markPureNode( - node: acorn.Node & { _rollupAnnotations?: Annotation[] }, - comment: acorn.Comment -) { - if (node._rollupAnnotations) { - node._rollupAnnotations.push({ comment }); - } else { - node._rollupAnnotations = [{ comment }]; - } - while (node.type === ExpressionStatement || node.type === ChainExpression) { - node = (node as any).expression; - } - if (node.type === CallExpression || node.type === NewExpression) { - if (node._rollupAnnotations) { - node._rollupAnnotations.push({ pure: true }); - } else { - node._rollupAnnotations = [{ pure: true }]; - } - } -} - -const pureCommentRegex = /[@#]__PURE__/; -const isPureComment = (comment: acorn.Comment) => pureCommentRegex.test(comment.value); - -export function markPureCallExpressions(comments: acorn.Comment[], esTreeAst: acorn.Node) { - handlePureAnnotationsOfNode(esTreeAst, { - commentIndex: 0, - commentNodes: comments.filter(isPureComment) - }); -} diff --git a/src/utils/pureFunctions.ts b/src/utils/pureFunctions.ts new file mode 100644 index 00000000000..bbae413ecb2 --- /dev/null +++ b/src/utils/pureFunctions.ts @@ -0,0 +1,20 @@ +import type { NormalizedInputOptions } from '../rollup/types'; + +export const PureFunctionKey = Symbol('PureFunction'); + +export interface PureFunctions { + [pathSegment: string]: PureFunctions; + [PureFunctionKey]?: boolean; +} + +export const getPureFunctions = ({ treeshake }: NormalizedInputOptions): PureFunctions => { + const pureFunctions: PureFunctions = Object.create(null); + for (const functionName of treeshake ? treeshake.manualPureFunctions : []) { + let currentFunctions = pureFunctions; + for (const pathSegment of functionName.split('.')) { + currentFunctions = currentFunctions[pathSegment] ||= Object.create(null); + } + currentFunctions[PureFunctionKey] = true; + } + return pureFunctions; +}; diff --git a/src/utils/reassignedExportsMember.ts b/src/utils/reassignedExportsMember.ts index c51081a5bc4..41abd0ad2e3 100644 --- a/src/utils/reassignedExportsMember.ts +++ b/src/utils/reassignedExportsMember.ts @@ -1,8 +1,8 @@ -import Variable from '../ast/variables/Variable'; +import type Variable from '../ast/variables/Variable'; export function isReassignedExportsMember( variable: Variable, - exportNamesByVariable: Map + exportNamesByVariable: ReadonlyMap ): boolean { return ( variable.renderBaseName !== null && exportNamesByVariable.has(variable) && variable.isReassigned diff --git a/src/utils/relativeId.ts b/src/utils/relativeId.ts index e3d3d36475b..0af204a1086 100644 --- a/src/utils/relativeId.ts +++ b/src/utils/relativeId.ts @@ -1,22 +1,44 @@ -import { basename, extname, isAbsolute, relative, resolve } from './path'; -import { sanitizeFileName } from './sanitizeFileName'; +import { relative } from '../../browser/src/path'; +import { basename, dirname, extname, isAbsolute, normalize, resolve } from './path'; -export function getAliasName(id: string) { +export function getAliasName(id: string): string { const base = basename(id); - return base.substr(0, base.length - extname(id).length); + return base.slice(0, Math.max(0, base.length - extname(id).length)); } -export default function relativeId(id: string) { +export default function relativeId(id: string): string { if (!isAbsolute(id)) return id; return relative(resolve(), id); } -export function isPlainPathFragment(name: string) { - // not starting with "/", "./", "../" +export function isPathFragment(name: string): boolean { + // starting with "/", "./", "../", "C:/" return ( - name[0] !== '/' && - !(name[0] === '.' && (name[1] === '/' || name[1] === '.')) && - sanitizeFileName(name) === name && - !isAbsolute(name) + name[0] === '/' || (name[0] === '.' && (name[1] === '/' || name[1] === '.')) || isAbsolute(name) ); } + +const UPPER_DIR_REGEX = /^(\.\.\/)*\.\.$/; + +export function getImportPath( + importerId: string, + targetPath: string, + stripJsExtension: boolean, + ensureFileName: boolean +): string { + while (targetPath.startsWith('../')) { + targetPath = targetPath.slice(3); + importerId = '_/' + importerId; + } + let relativePath = normalize(relative(dirname(importerId), targetPath)); + if (stripJsExtension && relativePath.endsWith('.js')) { + relativePath = relativePath.slice(0, -3); + } + if (ensureFileName) { + if (relativePath === '') return '../' + basename(targetPath); + if (UPPER_DIR_REGEX.test(relativePath)) { + return [...relativePath.split('/'), '..', basename(targetPath)].join('/'); + } + } + return relativePath ? (relativePath.startsWith('..') ? relativePath : './' + relativePath) : '.'; +} diff --git a/src/utils/renderCallArguments.ts b/src/utils/renderCallArguments.ts new file mode 100644 index 00000000000..fdd508ca650 --- /dev/null +++ b/src/utils/renderCallArguments.ts @@ -0,0 +1,42 @@ +import type MagicString from 'magic-string'; +import type CallExpression from '../ast/nodes/CallExpression'; +import type NewExpression from '../ast/nodes/NewExpression'; +import type { RenderOptions } from './renderHelpers'; +import { findFirstOccurrenceOutsideComment } from './renderHelpers'; + +export function renderCallArguments( + code: MagicString, + options: RenderOptions, + node: CallExpression | NewExpression +): void { + if (node.arguments.length > 0) { + if (node.arguments[node.arguments.length - 1].included) { + for (const argument of node.arguments) { + argument.render(code, options); + } + } else { + let lastIncludedIndex = node.arguments.length - 2; + while (lastIncludedIndex >= 0 && !node.arguments[lastIncludedIndex].included) { + lastIncludedIndex--; + } + if (lastIncludedIndex >= 0) { + for (let index = 0; index <= lastIncludedIndex; index++) { + node.arguments[index].render(code, options); + } + code.remove( + findFirstOccurrenceOutsideComment( + code.original, + ',', + node.arguments[lastIncludedIndex].end + ), + node.end - 1 + ); + } else { + code.remove( + findFirstOccurrenceOutsideComment(code.original, '(', node.callee.end) + 1, + node.end - 1 + ); + } + } + } +} diff --git a/src/utils/renderChunk.ts b/src/utils/renderChunk.ts deleted file mode 100644 index 2b85bc0bd53..00000000000 --- a/src/utils/renderChunk.ts +++ /dev/null @@ -1,51 +0,0 @@ -import { - DecodedSourceMapOrMissing, - NormalizedOutputOptions, - Plugin, - RenderedChunk, - SourceMapInput -} from '../rollup/types'; -import { decodedSourcemap } from './decodedSourcemap'; -import { PluginDriver } from './PluginDriver'; - -export default function renderChunk({ - code, - options, - outputPluginDriver, - renderChunk, - sourcemapChain -}: { - code: string; - options: NormalizedOutputOptions; - outputPluginDriver: PluginDriver; - renderChunk: RenderedChunk; - sourcemapChain: DecodedSourceMapOrMissing[]; -}): Promise { - const renderChunkReducer = ( - code: string, - result: { code: string; map?: SourceMapInput } | string | null, - plugin: Plugin - ): string => { - if (result == null) return code; - - if (typeof result === 'string') - result = { - code: result, - map: undefined - }; - - // strict null check allows 'null' maps to not be pushed to the chain, while 'undefined' gets the missing map warning - if (result.map !== null) { - const map = decodedSourcemap(result.map); - sourcemapChain.push(map || { missing: true, plugin: plugin.name }); - } - - return result.code; - }; - - return outputPluginDriver.hookReduceArg0( - 'renderChunk', - [code, renderChunk, options], - renderChunkReducer - ); -} diff --git a/src/utils/renderChunks.ts b/src/utils/renderChunks.ts new file mode 100644 index 00000000000..1b407fa14a8 --- /dev/null +++ b/src/utils/renderChunks.ts @@ -0,0 +1,425 @@ +import type { Bundle as MagicStringBundle, SourceMap } from 'magic-string'; +import type { default as Chunk, ChunkRenderResult } from '../Chunk'; +import type Module from '../Module'; +import type { + DecodedSourceMapOrMissing, + LogHandler, + NormalizedOutputOptions, + RenderedChunk +} from '../rollup/types'; +import { collapseSourcemaps } from './collapseSourcemaps'; +import type { GetHash } from './crypto'; +import { hasherByType } from './crypto'; +import { decodedSourcemap } from './decodedSourcemap'; +import { + replacePlaceholders, + replacePlaceholdersWithDefaultAndGetContainedPlaceholders, + replaceSinglePlaceholder +} from './hashPlaceholders'; +import { error, logFailedValidation } from './logs'; +import type { OutputBundleWithPlaceholders } from './outputBundle'; +import { FILE_PLACEHOLDER, lowercaseBundleKeys } from './outputBundle'; +import { basename, normalize, resolve } from './path'; +import type { PluginDriver } from './PluginDriver'; +import { SOURCEMAPPING_URL } from './sourceMappingURL'; +import { timeEnd, timeStart } from './timers'; + +interface HashResult { + containedPlaceholders: Set; + contentHash: string; +} + +interface RenderedChunkWithPlaceholders { + chunk: Chunk; + code: string; + fileName: string; + sourcemapFileName: string | null; + map: SourceMap | null; +} + +export async function renderChunks( + chunks: Chunk[], + bundle: OutputBundleWithPlaceholders, + pluginDriver: PluginDriver, + outputOptions: NormalizedOutputOptions, + log: LogHandler +) { + timeStart('render chunks', 2); + + reserveEntryChunksInBundle(chunks); + const renderedChunks = await Promise.all(chunks.map(chunk => chunk.render())); + + timeEnd('render chunks', 2); + timeStart('transform chunks', 2); + + const getHash = hasherByType[outputOptions.hashCharacters]; + const chunkGraph = getChunkGraph(chunks); + const { + hashDependenciesByPlaceholder, + initialHashesByPlaceholder, + nonHashedChunksWithPlaceholders, + placeholders, + renderedChunksByPlaceholder + } = await transformChunksAndGenerateContentHashes( + renderedChunks, + chunkGraph, + outputOptions, + pluginDriver, + getHash, + log + ); + const hashesByPlaceholder = generateFinalHashes( + renderedChunksByPlaceholder, + hashDependenciesByPlaceholder, + initialHashesByPlaceholder, + placeholders, + bundle, + getHash + ); + addChunksToBundle( + renderedChunksByPlaceholder, + hashesByPlaceholder, + bundle, + nonHashedChunksWithPlaceholders, + pluginDriver, + outputOptions + ); + + timeEnd('transform chunks', 2); +} + +function reserveEntryChunksInBundle(chunks: Chunk[]) { + for (const chunk of chunks) { + if (chunk.facadeModule && chunk.facadeModule.isUserDefinedEntryPoint) { + // reserves name in bundle as side effect if it does not contain a hash + chunk.getPreliminaryFileName(); + } + } +} + +function getChunkGraph(chunks: Chunk[]) { + return Object.fromEntries( + chunks.map(chunk => { + const renderedChunkInfo = chunk.getRenderedChunkInfo(); + return [renderedChunkInfo.fileName, renderedChunkInfo]; + }) + ); +} + +async function transformChunk( + magicString: MagicStringBundle, + fileName: string, + usedModules: Module[], + chunkGraph: Record, + options: NormalizedOutputOptions, + outputPluginDriver: PluginDriver, + log: LogHandler +) { + let map: SourceMap | null = null; + const sourcemapChain: DecodedSourceMapOrMissing[] = []; + let code = await outputPluginDriver.hookReduceArg0( + 'renderChunk', + [magicString.toString(), chunkGraph[fileName], options, { chunks: chunkGraph }], + (code, result, plugin) => { + if (result == null) return code; + + if (typeof result === 'string') + result = { + code: result, + map: undefined + }; + + // strict null check allows 'null' maps to not be pushed to the chain, while 'undefined' gets the missing map warning + if (result.map !== null) { + const map = decodedSourcemap(result.map); + sourcemapChain.push(map || { missing: true, plugin: plugin.name }); + } + + return result.code; + } + ); + const { + compact, + dir, + file, + sourcemap, + sourcemapExcludeSources, + sourcemapFile, + sourcemapPathTransform, + sourcemapIgnoreList + } = options; + if (!compact && code[code.length - 1] !== '\n') code += '\n'; + + if (sourcemap) { + timeStart('sourcemaps', 3); + + let resultingFile: string; + if (file) resultingFile = resolve(sourcemapFile || file); + else if (dir) resultingFile = resolve(dir, fileName); + else resultingFile = resolve(fileName); + + const decodedMap = magicString.generateDecodedMap({}); + map = collapseSourcemaps( + resultingFile, + decodedMap, + usedModules, + sourcemapChain, + sourcemapExcludeSources, + log + ); + for (let sourcesIndex = 0; sourcesIndex < map.sources.length; ++sourcesIndex) { + let sourcePath = map.sources[sourcesIndex]; + const sourcemapPath = `${resultingFile}.map`; + const ignoreList = sourcemapIgnoreList(sourcePath, sourcemapPath); + if (typeof ignoreList !== 'boolean') { + error(logFailedValidation('sourcemapIgnoreList function must return a boolean.')); + } + if (ignoreList) { + if (map.x_google_ignoreList === undefined) { + map.x_google_ignoreList = []; + } + if (!map.x_google_ignoreList.includes(sourcesIndex)) { + map.x_google_ignoreList.push(sourcesIndex); + } + } + if (sourcemapPathTransform) { + sourcePath = sourcemapPathTransform(sourcePath, sourcemapPath); + if (typeof sourcePath !== 'string') { + error(logFailedValidation(`sourcemapPathTransform function must return a string.`)); + } + } + map.sources[sourcesIndex] = normalize(sourcePath); + } + + timeEnd('sourcemaps', 3); + } + return { + code, + map + }; +} + +async function transformChunksAndGenerateContentHashes( + renderedChunks: ChunkRenderResult[], + chunkGraph: Record, + outputOptions: NormalizedOutputOptions, + pluginDriver: PluginDriver, + getHash: GetHash, + log: LogHandler +) { + const nonHashedChunksWithPlaceholders: RenderedChunkWithPlaceholders[] = []; + const renderedChunksByPlaceholder = new Map(); + const hashDependenciesByPlaceholder = new Map(); + const initialHashesByPlaceholder = new Map(); + const placeholders = new Set(); + for (const { + preliminaryFileName: { hashPlaceholder } + } of renderedChunks) { + if (hashPlaceholder) placeholders.add(hashPlaceholder); + } + await Promise.all( + renderedChunks.map( + async ({ + chunk, + preliminaryFileName: { fileName, hashPlaceholder }, + preliminarySourcemapFileName, + magicString, + usedModules + }) => { + const transformedChunk: RenderedChunkWithPlaceholders = { + chunk, + fileName, + sourcemapFileName: preliminarySourcemapFileName?.fileName ?? null, + ...(await transformChunk( + magicString, + fileName, + usedModules, + chunkGraph, + outputOptions, + pluginDriver, + log + )) + }; + const { code, map } = transformedChunk; + + if (hashPlaceholder) { + // To create a reproducible content-only hash, all placeholders are + // replaced with the same value before hashing + const { containedPlaceholders, transformedCode } = + replacePlaceholdersWithDefaultAndGetContainedPlaceholders(code, placeholders); + let contentToHash = transformedCode; + const hashAugmentation = pluginDriver.hookReduceValueSync( + 'augmentChunkHash', + '', + [chunk.getRenderedChunkInfo()], + (augmentation, pluginHash) => { + if (pluginHash) { + augmentation += pluginHash; + } + return augmentation; + } + ); + if (hashAugmentation) { + contentToHash += hashAugmentation; + } + renderedChunksByPlaceholder.set(hashPlaceholder, transformedChunk); + hashDependenciesByPlaceholder.set(hashPlaceholder, { + containedPlaceholders, + contentHash: getHash(contentToHash) + }); + } else { + nonHashedChunksWithPlaceholders.push(transformedChunk); + } + + const sourcemapHashPlaceholder = preliminarySourcemapFileName?.hashPlaceholder; + if (map && sourcemapHashPlaceholder) { + initialHashesByPlaceholder.set( + preliminarySourcemapFileName.hashPlaceholder, + getHash(map.toString()).slice(0, preliminarySourcemapFileName.hashPlaceholder.length) + ); + } + } + ) + ); + return { + hashDependenciesByPlaceholder, + initialHashesByPlaceholder, + nonHashedChunksWithPlaceholders, + placeholders, + renderedChunksByPlaceholder + }; +} + +function generateFinalHashes( + renderedChunksByPlaceholder: Map, + hashDependenciesByPlaceholder: Map, + initialHashesByPlaceholder: Map, + placeholders: Set, + bundle: OutputBundleWithPlaceholders, + getHash: GetHash +) { + const hashesByPlaceholder = new Map(initialHashesByPlaceholder); + for (const placeholder of placeholders) { + const { fileName } = renderedChunksByPlaceholder.get(placeholder)!; + let contentToHash = ''; + const hashDependencyPlaceholders = new Set([placeholder]); + for (const dependencyPlaceholder of hashDependencyPlaceholders) { + const { containedPlaceholders, contentHash } = + hashDependenciesByPlaceholder.get(dependencyPlaceholder)!; + contentToHash += contentHash; + for (const containedPlaceholder of containedPlaceholders) { + // When looping over a map, setting an entry only causes a new iteration if the key is new + hashDependencyPlaceholders.add(containedPlaceholder); + } + } + let finalFileName: string | undefined; + let finalHash: string | undefined; + do { + // In case of a hash collision, create a hash of the hash + if (finalHash) { + contentToHash = finalHash; + } + finalHash = getHash(contentToHash).slice(0, placeholder.length); + finalFileName = replaceSinglePlaceholder(fileName, placeholder, finalHash); + } while (bundle[lowercaseBundleKeys].has(finalFileName.toLowerCase())); + bundle[finalFileName] = FILE_PLACEHOLDER; + hashesByPlaceholder.set(placeholder, finalHash); + } + return hashesByPlaceholder; +} + +function addChunksToBundle( + renderedChunksByPlaceholder: Map, + hashesByPlaceholder: Map, + bundle: OutputBundleWithPlaceholders, + nonHashedChunksWithPlaceholders: RenderedChunkWithPlaceholders[], + pluginDriver: PluginDriver, + options: NormalizedOutputOptions +) { + for (const { + chunk, + code, + fileName, + sourcemapFileName, + map + } of renderedChunksByPlaceholder.values()) { + let updatedCode = replacePlaceholders(code, hashesByPlaceholder); + const finalFileName = replacePlaceholders(fileName, hashesByPlaceholder); + let finalSourcemapFileName = null; + if (map) { + if (options.sourcemapDebugIds) { + updatedCode += calculateDebugIdAndGetComment(updatedCode, map); + } + finalSourcemapFileName = sourcemapFileName + ? replacePlaceholders(sourcemapFileName, hashesByPlaceholder) + : `${finalFileName}.map`; + map.file = replacePlaceholders(map.file, hashesByPlaceholder); + updatedCode += emitSourceMapAndGetComment(finalSourcemapFileName, map, pluginDriver, options); + } + bundle[finalFileName] = chunk.finalizeChunk( + updatedCode, + map, + finalSourcemapFileName, + hashesByPlaceholder + ); + } + for (const { chunk, code, fileName, sourcemapFileName, map } of nonHashedChunksWithPlaceholders) { + let updatedCode = + hashesByPlaceholder.size > 0 ? replacePlaceholders(code, hashesByPlaceholder) : code; + let finalSourcemapFileName = null; + if (map) { + if (options.sourcemapDebugIds) { + updatedCode += calculateDebugIdAndGetComment(updatedCode, map); + } + finalSourcemapFileName = sourcemapFileName + ? replacePlaceholders(sourcemapFileName, hashesByPlaceholder) + : `${fileName}.map`; + updatedCode += emitSourceMapAndGetComment(finalSourcemapFileName, map, pluginDriver, options); + } + bundle[fileName] = chunk.finalizeChunk( + updatedCode, + map, + finalSourcemapFileName, + hashesByPlaceholder + ); + } +} + +function emitSourceMapAndGetComment( + fileName: string, + map: SourceMap, + pluginDriver: PluginDriver, + { sourcemap, sourcemapBaseUrl }: NormalizedOutputOptions +) { + let url: string; + if (sourcemap === 'inline') { + url = map.toUrl(); + } else { + const sourcemapFileName = basename(fileName); + url = sourcemapBaseUrl + ? new URL(sourcemapFileName, sourcemapBaseUrl).toString() + : sourcemapFileName; + pluginDriver.emitFile({ + fileName, + originalFileName: null, + source: map.toString(), + type: 'asset' + }); + } + return sourcemap === 'hidden' ? '' : `//# ${SOURCEMAPPING_URL}=${url}\n`; +} + +function calculateDebugIdAndGetComment(code: string, map: SourceMap & { debugId?: string }) { + const hash = hasherByType.hex(code); + const debugId = [ + hash.slice(0, 8), + hash.slice(8, 12), + '4' + hash.slice(12, 15), + ((parseInt(hash.slice(15, 16), 16) & 3) | 8).toString(16) + hash.slice(17, 20), + hash.slice(20, 32) + ].join('-'); + + map.debugId = debugId; + + return '//# debugId=' + debugId + '\n'; +} diff --git a/src/utils/renderHelpers.ts b/src/utils/renderHelpers.ts index e2fe09b2e88..0041b43cdfa 100644 --- a/src/utils/renderHelpers.ts +++ b/src/utils/renderHelpers.ts @@ -1,20 +1,22 @@ -import MagicString from 'magic-string'; -import { Node, StatementNode } from '../ast/nodes/shared/Node'; -import Variable from '../ast/variables/Variable'; -import { InternalModuleFormat } from '../rollup/types'; -import { PluginDriver } from './PluginDriver'; +import type MagicString from 'magic-string'; +import type { Node, StatementNode } from '../ast/nodes/shared/Node'; +import type Variable from '../ast/variables/Variable'; +import type { ImportAttributesKey, InternalModuleFormat } from '../rollup/types'; +import type { GenerateCodeSnippets } from './generateCodeSnippets'; +import type { PluginDriver } from './PluginDriver'; import { treeshakeNode } from './treeshakeNode'; export interface RenderOptions { - compact: boolean; - dynamicImportFunction: string | undefined; + accessedDocumentCurrentScript: boolean; exportNamesByVariable: Map; format: InternalModuleFormat; freeze: boolean; indent: string; - namespaceToStringTag: boolean; - outputPluginDriver: PluginDriver; - varOrConst: 'var' | 'const'; + importAttributesKey: ImportAttributesKey; + pluginDriver: PluginDriver; + snippets: GenerateCodeSnippets; + symbols: boolean; + useOriginalName: ((variable: Variable) => boolean) | null; } export interface NodeRenderOptions { @@ -22,17 +24,26 @@ export interface NodeRenderOptions { isCalleeOfRenderedParent?: boolean; isNoStatement?: boolean; isShorthandProperty?: boolean; + jsxMode?: 'preserve' | 'classic' | 'automatic'; preventASI?: boolean; - renderedParentType?: string; // also serves as a flag if the rendered parent is different from the actual parent - renderedSurroundingElement?: string; // same as parent type, but for changed non-direct parents that directly preceed elements + /* Indicates if the direct parent of an element changed. + Necessary for determining the "this" context of callees. */ + renderedParentType?: string; + /* Indicates if the parent or ancestor surrounding an element has changed and what it changed to. + Necessary for adding parentheses. */ + renderedSurroundingElement?: string; start?: number; } export const NO_SEMICOLON: NodeRenderOptions = { isNoStatement: true }; // This assumes there are only white-space and comments between start and the string we are looking for -export function findFirstOccurrenceOutsideComment(code: string, searchString: string, start = 0) { - let searchPos, charCodeAfterSlash; +export function findFirstOccurrenceOutsideComment( + code: string, + searchString: string, + start = 0 +): number { + let searchPos: number, charCodeAfterSlash: number; searchPos = code.indexOf(searchString, start); while (true) { start = code.indexOf('/', start); @@ -53,15 +64,30 @@ export function findFirstOccurrenceOutsideComment(code: string, searchString: st const NON_WHITESPACE = /\S/g; -export function findNonWhiteSpace(code: string, index: number) { +export function findNonWhiteSpace(code: string, index: number): number { NON_WHITESPACE.lastIndex = index; const result = NON_WHITESPACE.exec(code)!; return result.index; } +const WHITESPACE = /\s/; + +export function findLastWhiteSpaceReverse(code: string, start: number, end: number): number { + while (true) { + if (start >= end) { + return end; + } + if (WHITESPACE.test(code[end - 1])) { + end--; + } else { + return end; + } + } +} + // This assumes "code" only contains white-space and comments // Returns position of line-comment if applicable -function findFirstLineBreakOutsideComment(code: string): [number, number] { +export function findFirstLineBreakOutsideComment(code: string): [number, number] { let lineBreakPos, charCodeAfterSlash, start = 0; @@ -73,7 +99,7 @@ function findFirstLineBreakOutsideComment(code: string): [number, number] { // With our assumption, '/' always starts a comment. Determine comment type: charCodeAfterSlash = code.charCodeAt(start + 1); if (charCodeAfterSlash === 47 /*"/"*/) return [start, lineBreakPos + 1]; - start = code.indexOf('*/', start + 3) + 2; + start = code.indexOf('*/', start + 2) + 2; if (start > lineBreakPos) { lineBreakPos = code.indexOf('\n', start); } @@ -81,12 +107,12 @@ function findFirstLineBreakOutsideComment(code: string): [number, number] { } export function renderStatementList( - statements: StatementNode[], + statements: readonly StatementNode[], code: MagicString, start: number, end: number, options: RenderOptions -) { +): void { let currentNode, currentNodeStart, currentNodeNeedsBoundaries, nextNodeStart; let nextNode = statements[0]; let nextNodeNeedsBoundaries = !nextNode.included || nextNode.needsBoundaries; @@ -109,12 +135,14 @@ export function renderStatementList( code.original.slice(currentNode.end, nextNode === undefined ? end : nextNode.start) )[1]; if (currentNode.included) { - currentNodeNeedsBoundaries - ? currentNode.render(code, options, { - end: nextNodeStart, - start: currentNodeStart - }) - : currentNode.render(code, options); + if (currentNodeNeedsBoundaries) { + currentNode.render(code, options, { + end: nextNodeStart, + start: currentNodeStart + }); + } else { + currentNode.render(code, options); + } } else { treeshakeNode(currentNode, code, currentNodeStart!, nextNodeStart); } @@ -126,7 +154,7 @@ export function renderStatementList( // This assumes that the first character is not part of the first node export function getCommaSeparatedNodesWithBoundaries( - nodes: N[], + nodes: readonly N[], code: MagicString, start: number, end: number @@ -138,11 +166,10 @@ export function getCommaSeparatedNodesWithBoundaries( start: number; }[] { const splitUpNodes = []; - let node, nextNode, nextNodeStart, contentEnd, char; + let node, nextNodeStart, contentEnd, char; let separator = start - 1; - for (let nextIndex = 0; nextIndex < nodes.length; nextIndex++) { - nextNode = nodes[nextIndex]; + for (const nextNode of nodes) { if (node !== undefined) { separator = node.end + @@ -180,7 +207,7 @@ export function getCommaSeparatedNodesWithBoundaries( } // This assumes there are only white-space and comments between start and end -export function removeLineBreaks(code: MagicString, start: number, end: number) { +export function removeLineBreaks(code: MagicString, start: number, end: number): void { while (true) { const [removeStart, removeEnd] = findFirstLineBreakOutsideComment( code.original.slice(start, end) diff --git a/src/utils/renderNamePattern.ts b/src/utils/renderNamePattern.ts index 13690decc71..36ecdc42463 100644 --- a/src/utils/renderNamePattern.ts +++ b/src/utils/renderNamePattern.ts @@ -1,43 +1,53 @@ -import { errFailedValidation, error } from './error'; +import { error, logFailedValidation } from './logs'; +import type { OutputBundleWithPlaceholders } from './outputBundle'; +import { lowercaseBundleKeys } from './outputBundle'; import { extname } from './path'; -import { isPlainPathFragment } from './relativeId'; +import { isPathFragment } from './relativeId'; export function renderNamePattern( pattern: string, patternName: string, - replacements: { [name: string]: () => string } -) { - if (!isPlainPathFragment(pattern)) + replacements: Record string> +): string { + if (isPathFragment(pattern)) return error( - errFailedValidation( - `Invalid pattern "${pattern}" for "${patternName}", patterns can be neither absolute nor relative paths and must not contain invalid characters.` + logFailedValidation( + `Invalid pattern "${pattern}" for "${patternName}", patterns can be neither absolute nor relative paths. If you want your files to be stored in a subdirectory, write its name without a leading slash like this: subdirectory/pattern.` ) ); - return pattern.replace(/\[(\w+)\]/g, (_match, type) => { - if (!replacements.hasOwnProperty(type)) { - return error( - errFailedValidation(`"[${type}]" is not a valid placeholder in "${patternName}" pattern.`) - ); + return pattern.replace( + /\[(\w+)(:\d+)?]/g, + (_match, type: string, size: `:${string}` | undefined) => { + if (!replacements.hasOwnProperty(type) || (size && type !== 'hash')) { + return error( + logFailedValidation( + `"[${type}${size || ''}]" is not a valid placeholder in the "${patternName}" pattern.` + ) + ); + } + const replacement = replacements[type](size && Number.parseInt(size.slice(1))); + if (isPathFragment(replacement)) + return error( + logFailedValidation( + `Invalid substitution "${replacement}" for placeholder "[${type}]" in "${patternName}" pattern, can be neither absolute nor relative path.` + ) + ); + return replacement; } - const replacement = replacements[type](); - if (!isPlainPathFragment(replacement)) - return error( - errFailedValidation( - `Invalid substitution "${replacement}" for placeholder "[${type}]" in "${patternName}" pattern, can be neither absolute nor relative path.` - ) - ); - return replacement; - }); + ); } -export function makeUnique(name: string, existingNames: Record) { - const existingNamesLowercase = new Set(Object.keys(existingNames).map(key => key.toLowerCase())); - if (!existingNamesLowercase.has(name.toLocaleLowerCase())) return name; - - const ext = extname(name); - name = name.substr(0, name.length - ext.length); - let uniqueName, +export function makeUnique( + name: string, + { [lowercaseBundleKeys]: reservedLowercaseBundleKeys }: OutputBundleWithPlaceholders +): string { + if (!reservedLowercaseBundleKeys.has(name.toLowerCase())) return name; + const extension = extname(name); + name = name.slice(0, Math.max(0, name.length - extension.length)); + let uniqueName: string, uniqueIndex = 1; - while (existingNamesLowercase.has((uniqueName = name + ++uniqueIndex + ext).toLowerCase())); + while ( + reservedLowercaseBundleKeys.has((uniqueName = name + ++uniqueIndex + extension).toLowerCase()) + ); return uniqueName; } diff --git a/src/utils/reservedNames.ts b/src/utils/reservedNames.ts deleted file mode 100644 index aa2f58cfb4d..00000000000 --- a/src/utils/reservedNames.ts +++ /dev/null @@ -1,56 +0,0 @@ -export interface NameCollection { - [name: string]: true; -} - -export const RESERVED_NAMES: NameCollection = { - // @ts-ignore - __proto__: null, - await: true, - break: true, - case: true, - catch: true, - class: true, - const: true, - continue: true, - debugger: true, - default: true, - delete: true, - do: true, - else: true, - enum: true, - eval: true, - export: true, - extends: true, - false: true, - finally: true, - for: true, - function: true, - if: true, - implements: true, - import: true, - in: true, - instanceof: true, - interface: true, - let: true, - new: true, - null: true, - package: true, - private: true, - protected: true, - public: true, - return: true, - static: true, - super: true, - switch: true, - this: true, - throw: true, - true: true, - try: true, - typeof: true, - undefined: true, - var: true, - void: true, - while: true, - with: true, - yield: true -}; diff --git a/src/utils/resolveId.ts b/src/utils/resolveId.ts index da6d848d58a..766da800c09 100644 --- a/src/utils/resolveId.ts +++ b/src/utils/resolveId.ts @@ -1,7 +1,7 @@ -import { CustomPluginOptions, Plugin, ResolvedId } from '../rollup/types'; -import { lstatSync, readdirSync, realpathSync } from './fs'; +import type { ModuleLoaderResolveId } from '../ModuleLoader'; +import type { CustomPluginOptions, Plugin, ResolveIdResult, RollupFsModule } from '../rollup/types'; import { basename, dirname, isAbsolute, resolve } from './path'; -import { PluginDriver } from './PluginDriver'; +import type { PluginDriver } from './PluginDriver'; import { resolveIdViaPlugins } from './resolveIdViaPlugins'; export async function resolveId( @@ -9,24 +9,40 @@ export async function resolveId( importer: string | undefined, preserveSymlinks: boolean, pluginDriver: PluginDriver, - moduleLoaderResolveId: ( - source: string, - importer: string | undefined, - customOptions: CustomPluginOptions | undefined, - skip: { importer: string | undefined; plugin: Plugin; source: string }[] | null - ) => Promise, - skip: { importer: string | undefined; plugin: Plugin; source: string }[] | null, - customOptions: CustomPluginOptions | undefined -) { + moduleLoaderResolveId: ModuleLoaderResolveId, + skip: readonly { importer: string | undefined; plugin: Plugin; source: string }[] | null, + customOptions: CustomPluginOptions | undefined, + isEntry: boolean, + attributes: Record, + fs: RollupFsModule +): Promise { const pluginResult = await resolveIdViaPlugins( source, importer, pluginDriver, moduleLoaderResolveId, skip, - customOptions + customOptions, + isEntry, + attributes ); - if (pluginResult != null) return pluginResult; + + if (pluginResult != null) { + const [resolveIdResult, plugin] = pluginResult; + if (typeof resolveIdResult === 'object' && !resolveIdResult.resolvedBy) { + return { + ...resolveIdResult, + resolvedBy: plugin.name + }; + } + if (typeof resolveIdResult === 'string') { + return { + id: resolveIdResult, + resolvedBy: plugin.name + }; + } + return resolveIdResult; + } // external modules (non-entry modules that start with neither '.' or '/') // are skipped at this stage. @@ -38,30 +54,38 @@ export async function resolveId( // See https://nodejs.org/api/path.html#path_path_resolve_paths return addJsExtensionIfNecessary( importer ? resolve(dirname(importer), source) : resolve(source), - preserveSymlinks + preserveSymlinks, + fs ); } -function addJsExtensionIfNecessary(file: string, preserveSymlinks: boolean) { - let found = findFile(file, preserveSymlinks); - if (found) return found; - found = findFile(file + '.mjs', preserveSymlinks); - if (found) return found; - found = findFile(file + '.js', preserveSymlinks); - return found; +async function addJsExtensionIfNecessary( + file: string, + preserveSymlinks: boolean, + fs: RollupFsModule +): Promise { + return ( + (await findFile(file, preserveSymlinks, fs)) ?? + (await findFile(file + '.mjs', preserveSymlinks, fs)) ?? + (await findFile(file + '.js', preserveSymlinks, fs)) + ); } -function findFile(file: string, preserveSymlinks: boolean): string | undefined { +async function findFile( + file: string, + preserveSymlinks: boolean, + fs: RollupFsModule +): Promise { try { - const stats = lstatSync(file); + const stats = await fs.lstat(file); if (!preserveSymlinks && stats.isSymbolicLink()) - return findFile(realpathSync(file), preserveSymlinks); + return await findFile(await fs.realpath(file), preserveSymlinks, fs); if ((preserveSymlinks && stats.isSymbolicLink()) || stats.isFile()) { // check case const name = basename(file); - const files = readdirSync(dirname(file)); + const files = await fs.readdir(dirname(file)); - if (files.indexOf(name) !== -1) return file; + if (files.includes(name)) return file; } } catch { // suppress diff --git a/src/utils/resolveIdViaPlugins.ts b/src/utils/resolveIdViaPlugins.ts index 992718efe0e..0473a6a55b8 100644 --- a/src/utils/resolveIdViaPlugins.ts +++ b/src/utils/resolveIdViaPlugins.ts @@ -1,20 +1,18 @@ -import { CustomPluginOptions, Plugin, PluginContext, ResolvedId } from '../rollup/types'; -import { BLANK } from './blank'; -import { PluginDriver, ReplaceContext } from './PluginDriver'; +import type { ModuleLoaderResolveId } from '../ModuleLoader'; +import type { CustomPluginOptions, Plugin, PluginContext, ResolveIdResult } from '../rollup/types'; +import type { PluginDriver, ReplaceContext } from './PluginDriver'; +import { BLANK, EMPTY_OBJECT } from './blank'; export function resolveIdViaPlugins( source: string, importer: string | undefined, pluginDriver: PluginDriver, - moduleLoaderResolveId: ( - source: string, - importer: string | undefined, - customOptions: CustomPluginOptions | undefined, - skip: { importer: string | undefined; plugin: Plugin; source: string }[] | null - ) => Promise, - skip: { importer: string | undefined; plugin: Plugin; source: string }[] | null, - customOptions: CustomPluginOptions | undefined -) { + moduleLoaderResolveId: ModuleLoaderResolveId, + skip: readonly { importer: string | undefined; plugin: Plugin; source: string }[] | null, + customOptions: CustomPluginOptions | undefined, + isEntry: boolean, + attributes: Record +): Promise<[NonNullable, Plugin] | null> { let skipped: Set | null = null; let replaceContext: ReplaceContext | null = null; if (skip) { @@ -26,19 +24,36 @@ export function resolveIdViaPlugins( } replaceContext = (pluginContext, plugin): PluginContext => ({ ...pluginContext, - resolve: (source, importer, { custom, skipSelf } = BLANK) => { + resolve: (source, importer, { attributes, custom, isEntry, skipSelf } = BLANK) => { + skipSelf ??= true; + if ( + skipSelf && + skip.findIndex(skippedCall => { + return ( + skippedCall.plugin === plugin && + skippedCall.source === source && + skippedCall.importer === importer + ); + }) !== -1 + ) { + // This means that the plugin recursively called itself + // Thus returning Promise.resolve(null) in purpose of fallback to default behavior of `resolveId` plugin hook. + return Promise.resolve(null); + } return moduleLoaderResolveId( source, importer, custom, + isEntry, + attributes || EMPTY_OBJECT, skipSelf ? [...skip, { importer, plugin, source }] : skip ); } }); } - return pluginDriver.hookFirst( + return pluginDriver.hookFirstAndGetPlugin( 'resolveId', - [source, importer, { custom: customOptions }], + [source, importer, { attributes, custom: customOptions, isEntry }], replaceContext, skipped ); diff --git a/src/utils/safeName.ts b/src/utils/safeName.ts index 94644da71ae..560d5a10ca8 100644 --- a/src/utils/safeName.ts +++ b/src/utils/safeName.ts @@ -1,10 +1,14 @@ +import RESERVED_NAMES from './RESERVED_NAMES'; import { toBase64 } from './base64'; -import { RESERVED_NAMES } from './reservedNames'; -export function getSafeName(baseName: string, usedNames: Set): string { +export function getSafeName( + baseName: string, + usedNames: Set, + forbiddenNames: Set | null +): string { let safeName = baseName; let count = 1; - while (usedNames.has(safeName) || RESERVED_NAMES[safeName]) { + while (usedNames.has(safeName) || RESERVED_NAMES.has(safeName) || forbiddenNames?.has(safeName)) { safeName = `${baseName}$${toBase64(count++)}`; } usedNames.add(safeName); diff --git a/src/utils/sanitizeFileName.ts b/src/utils/sanitizeFileName.ts index 14ceb33e2d1..c80ab56f7b6 100644 --- a/src/utils/sanitizeFileName.ts +++ b/src/utils/sanitizeFileName.ts @@ -1,8 +1,13 @@ +// https://datatracker.ietf.org/doc/html/rfc2396 +// eslint-disable-next-line no-control-regex +const INVALID_CHAR_REGEX = /[\u0000-\u001F"#$%&*+,:;<=>?[\]^`{|}\u007F]/g; +const DRIVE_LETTER_REGEX = /^[a-z]:/i; + export function sanitizeFileName(name: string): string { - const match = /^[a-z]:/i.exec(name); - const driveLetter = match ? match[0] : ""; + const match = DRIVE_LETTER_REGEX.exec(name); + const driveLetter = match ? match[0] : ''; // A `:` is only allowed as part of a windows drive letter (ex: C:\foo) // Otherwise, avoid them because they can refer to NTFS alternate data streams. - return driveLetter + name.substr(driveLetter.length).replace(/[\0?*:]/g, '_'); + return driveLetter + name.slice(driveLetter.length).replace(INVALID_CHAR_REGEX, '_'); } diff --git a/src/utils/sourceMappingURL.ts b/src/utils/sourceMappingURL.ts index c6b6e4b700e..ef4a35413c1 100644 --- a/src/utils/sourceMappingURL.ts +++ b/src/utils/sourceMappingURL.ts @@ -1,12 +1,9 @@ // this looks ridiculous, but it prevents sourcemap tooling from mistaking // this for an actual sourceMappingURL -let SOURCEMAPPING_URL = 'sourceMa'; +export let SOURCEMAPPING_URL = 'sourceMa'; SOURCEMAPPING_URL += 'ppingURL'; -const whiteSpaceNoNewline = '[ \\f\\r\\t\\v\\u00a0\\u1680\\u2000-\\u200a\\u2028\\u2029\\u202f\\u205f\\u3000\\ufeff]'; -const SOURCEMAPPING_URL_LINE_COMMENT_RE = `//#${whiteSpaceNoNewline}+${SOURCEMAPPING_URL}=.+`; -const SOURCEMAPPING_URL_BLOCK_COMMENT_RE = `/\\*#${whiteSpaceNoNewline}+${SOURCEMAPPING_URL}=.+\\*/`; -const SOURCEMAPPING_URL_COMMENT_RE = new RegExp( - `(${SOURCEMAPPING_URL_LINE_COMMENT_RE})|(${SOURCEMAPPING_URL_BLOCK_COMMENT_RE})`, 'g'); +const whiteSpaceNoNewline = + '[ \\f\\r\\t\\v\\u00a0\\u1680\\u2000-\\u200a\\u2028\\u2029\\u202f\\u205f\\u3000\\ufeff]'; -export { SOURCEMAPPING_URL, SOURCEMAPPING_URL_COMMENT_RE}; +export const SOURCEMAPPING_URL_RE = new RegExp(`^#${whiteSpaceNoNewline}+${SOURCEMAPPING_URL}=.+`); diff --git a/src/utils/stripBom.ts b/src/utils/stripBom.ts new file mode 100644 index 00000000000..e78124d1e27 --- /dev/null +++ b/src/utils/stripBom.ts @@ -0,0 +1,6 @@ +export default function stripBom(content: string): string { + if (content.charCodeAt(0) === 0xfe_ff) { + return stripBom(content.slice(1)); + } + return content; +} diff --git a/src/utils/systemJsRendering.ts b/src/utils/systemJsRendering.ts index 77a867c9254..4d12dc8a9c0 100644 --- a/src/utils/systemJsRendering.ts +++ b/src/utils/systemJsRendering.ts @@ -1,42 +1,103 @@ -import Variable from '../ast/variables/Variable'; -import { RenderOptions } from './renderHelpers'; +import type MagicString from 'magic-string'; +import type Variable from '../ast/variables/Variable'; +import type { RenderOptions } from './renderHelpers'; export function getSystemExportStatement( - exportedVariables: Variable[], - options: RenderOptions + exportedVariables: readonly Variable[], + { exportNamesByVariable, snippets: { _, getObject, getPropertyAccess } }: RenderOptions, + modifier = '' ): string { - const _ = options.compact ? '' : ' '; if ( exportedVariables.length === 1 && - options.exportNamesByVariable.get(exportedVariables[0])!.length === 1 + exportNamesByVariable.get(exportedVariables[0])!.length === 1 ) { const variable = exportedVariables[0]; - return `exports('${options.exportNamesByVariable.get(variable)}',${_}${variable.getName()})`; + return `exports(${JSON.stringify( + exportNamesByVariable.get(variable)![0] + )},${_}${variable.getName(getPropertyAccess)}${modifier})`; } else { - return `exports({${_}${exportedVariables - .map(variable => { - return options.exportNamesByVariable - .get(variable)! - .map(exportName => `${exportName}:${_}${variable.getName()}`) - .join(`,${_}`); - }) - .join(`,${_}`)}${_}})`; + const fields: [key: string, value: string][] = []; + for (const variable of exportedVariables) { + for (const exportName of exportNamesByVariable.get(variable)!) { + fields.push([exportName, variable.getName(getPropertyAccess) + modifier]); + } + } + return `exports(${getObject(fields, { lineBreakIndent: null })})`; } } -export function getSystemExportFunctionLeft( - exportedVariables: Variable[], - setFromExpression: boolean, +// This is only invoked if there is exactly one export name +export function renderSystemExportExpression( + exportedVariable: Variable, + expressionStart: number, + expressionEnd: number, + code: MagicString, + { exportNamesByVariable, snippets: { _ } }: RenderOptions +): void { + code.prependRight( + expressionStart, + `exports(${JSON.stringify(exportNamesByVariable.get(exportedVariable)![0])},${_}` + ); + code.appendLeft(expressionEnd, ')'); +} + +export function renderSystemExportFunction( + exportedVariables: readonly Variable[], + expressionStart: number, + expressionEnd: number, + needsParens: boolean | undefined, + code: MagicString, options: RenderOptions -): string { - const _ = options.compact ? '' : ' '; - const s = options.compact ? '' : ';'; - return `function${_}(v)${_}{${_}return exports({${_}${exportedVariables - .map(variable => { - return options.exportNamesByVariable - .get(variable)! - .map(exportName => `${exportName}:${_}${setFromExpression ? variable.getName() : 'v'}`) - .join(`,${_}`); - }) - .join(`,${_}`)}${_}}),${_}v${s}${_}}(`; +): void { + const { _, getDirectReturnIifeLeft } = options.snippets; + code.prependRight( + expressionStart, + getDirectReturnIifeLeft( + ['v'], + `${getSystemExportStatement(exportedVariables, options)},${_}v`, + { needsArrowReturnParens: true, needsWrappedFunction: needsParens } + ) + ); + code.appendLeft(expressionEnd, ')'); +} + +export function renderSystemExportSequenceAfterExpression( + exportedVariable: Variable, + expressionStart: number, + expressionEnd: number, + needsParens: boolean | undefined, + code: MagicString, + options: RenderOptions +): void { + const { _, getPropertyAccess } = options.snippets; + code.appendLeft( + expressionEnd, + `,${_}${getSystemExportStatement([exportedVariable], options)},${_}${exportedVariable.getName( + getPropertyAccess + )}` + ); + if (needsParens) { + code.prependRight(expressionStart, '('); + code.appendLeft(expressionEnd, ')'); + } +} + +export function renderSystemExportSequenceBeforeExpression( + exportedVariable: Variable, + expressionStart: number, + expressionEnd: number, + needsParens: boolean | undefined, + code: MagicString, + options: RenderOptions, + modifier: string +): void { + const { _ } = options.snippets; + code.prependRight( + expressionStart, + `${getSystemExportStatement([exportedVariable], options, modifier)},${_}` + ); + if (needsParens) { + code.prependRight(expressionStart, '('); + code.appendLeft(expressionEnd, ')'); + } } diff --git a/src/utils/timers.ts b/src/utils/timers.ts index 5f030bbfafb..14f1cab3724 100644 --- a/src/utils/timers.ts +++ b/src/utils/timers.ts @@ -1,136 +1,149 @@ -import { InputOptions, SerializedTimings } from '../rollup/types'; - -type StartTime = [number, number]; +import type { + NormalizedInputOptions, + Plugin, + PluginHooks, + SerializedTimings +} from '../rollup/types'; +import { doNothing } from './doNothing'; +import performance from './performance'; +import process from './process'; interface Timer { memory: number; startMemory: number; - startTime: StartTime; + startTime: number; time: number; totalMemory: number; } -interface Timers { - [label: string]: Timer; -} +let timers = new Map(); -const NOOP = () => {}; -let getStartTime: () => StartTime = () => [0, 0]; -let getElapsedTime: (previous: StartTime) => number = () => 0; -let getMemory: () => number = () => 0; -let timers: Timers = {}; - -const normalizeHrTime = (time: [number, number]) => time[0] * 1e3 + time[1] / 1e6; - -function setTimeHelpers() { - if (typeof process !== 'undefined' && typeof process.hrtime === 'function') { - getStartTime = process.hrtime.bind(process); - getElapsedTime = previous => normalizeHrTime(process.hrtime(previous)); - } else if (typeof performance !== 'undefined' && typeof performance.now === 'function') { - getStartTime = () => [performance.now(), 0]; - getElapsedTime = previous => performance.now() - previous[0]; - } - if (typeof process !== 'undefined' && typeof process.memoryUsage === 'function') { - getMemory = () => process.memoryUsage().heapUsed; - } -} +type LabelLevel = 1 | 2 | 3 | 4; -function getPersistedLabel(label: string, level: number) { +function getPersistedLabel(label: string, level: LabelLevel): string { switch (level) { - case 1: + case 1: { return `# ${label}`; - case 2: + } + case 2: { return `## ${label}`; - case 3: + } + case 3: { return label; - default: - return `${' '.repeat(level - 4)}- ${label}`; + } + default: { + return `- ${label}`; + } } } -function timeStartImpl(label: string, level = 3) { +function timeStartImpl(label: string, level: LabelLevel = 3): void { label = getPersistedLabel(label, level); - if (!timers.hasOwnProperty(label)) { - timers[label] = { + + const startMemory = process.memoryUsage().heapUsed; + const startTime = performance.now(); + + const timer = timers.get(label); + + if (timer === undefined) { + timers.set(label, { memory: 0, - startMemory: undefined as any, - startTime: undefined as any, + startMemory, + startTime, time: 0, totalMemory: 0 - }; + }); + } else { + timer.startMemory = startMemory; + timer.startTime = startTime; } - const currentMemory = getMemory(); - timers[label].startTime = getStartTime(); - timers[label].startMemory = currentMemory; } -function timeEndImpl(label: string, level = 3) { +function timeEndImpl(label: string, level: LabelLevel = 3): void { label = getPersistedLabel(label, level); - if (timers.hasOwnProperty(label)) { - const currentMemory = getMemory(); - timers[label].time += getElapsedTime(timers[label].startTime); - timers[label].totalMemory = Math.max(timers[label].totalMemory, currentMemory); - timers[label].memory += currentMemory - timers[label].startMemory; + + const timer = timers.get(label); + + if (timer !== undefined) { + const currentMemory = process.memoryUsage().heapUsed; + timer.memory += currentMemory - timer.startMemory; + timer.time += performance.now() - timer.startTime; + timer.totalMemory = Math.max(timer.totalMemory, currentMemory); } } export function getTimings(): SerializedTimings { const newTimings: SerializedTimings = {}; - for (const label of Object.keys(timers)) { - newTimings[label] = [timers[label].time, timers[label].memory, timers[label].totalMemory]; + + for (const [label, { memory, time, totalMemory }] of timers) { + newTimings[label] = [time, memory, totalMemory]; } return newTimings; } -export let timeStart: (label: string, level?: number) => void = NOOP, - timeEnd: (label: string, level?: number) => void = NOOP; +export let timeStart: (label: string, level?: LabelLevel) => void = doNothing; +export let timeEnd: (label: string, level?: LabelLevel) => void = doNothing; -const TIMED_PLUGIN_HOOKS: { [hook: string]: boolean } = { - load: true, - resolveDynamicImport: true, - resolveId: true, - transform: true -}; +const TIMED_PLUGIN_HOOKS: readonly (keyof PluginHooks)[] = [ + 'augmentChunkHash', + 'buildEnd', + 'buildStart', + 'generateBundle', + 'load', + 'moduleParsed', + 'options', + 'outputOptions', + 'renderChunk', + 'renderDynamicImport', + 'renderStart', + 'resolveDynamicImport', + 'resolveFileUrl', + 'resolveId', + 'resolveImportMeta', + 'shouldTransformCachedModule', + 'transform', + 'writeBundle' +]; function getPluginWithTimers(plugin: any, index: number): Plugin { - const timedPlugin: { [hook: string]: any } = {}; - - for (const hook of Object.keys(plugin)) { - if (TIMED_PLUGIN_HOOKS[hook] === true) { + if (plugin._hasTimer) return plugin; + plugin._hasTimer = true; + for (const hook of TIMED_PLUGIN_HOOKS) { + if (hook in plugin) { let timerLabel = `plugin ${index}`; if (plugin.name) { timerLabel += ` (${plugin.name})`; } timerLabel += ` - ${hook}`; - timedPlugin[hook] = function() { + + const handler = function (this: any, ...parameters: readonly unknown[]) { timeStart(timerLabel, 4); - let result = plugin[hook].apply(this === timedPlugin ? plugin : this, arguments); + const result = hookFunction.apply(this, parameters); timeEnd(timerLabel, 4); - if (result && typeof result.then === 'function') { - timeStart(`${timerLabel} (async)`, 4); - result = result.then((hookResult: any) => { - timeEnd(`${timerLabel} (async)`, 4); - return hookResult; - }); - } return result; }; - } else { - timedPlugin[hook] = plugin[hook]; + + let hookFunction: any; + if (typeof plugin[hook].handler === 'function') { + hookFunction = plugin[hook].handler; + plugin[hook].handler = handler; + } else { + hookFunction = plugin[hook]; + plugin[hook] = handler; + } } } - return timedPlugin as Plugin; + return plugin; } -export function initialiseTimers(inputOptions: InputOptions) { +export function initialiseTimers(inputOptions: NormalizedInputOptions): void { if (inputOptions.perf) { - timers = {}; - setTimeHelpers(); + timers = new Map(); timeStart = timeStartImpl; timeEnd = timeEndImpl; inputOptions.plugins = inputOptions.plugins!.map(getPluginWithTimers); } else { - timeStart = NOOP; - timeEnd = NOOP; + timeStart = doNothing; + timeEnd = doNothing; } } diff --git a/src/utils/transform.ts b/src/utils/transform.ts index dc26ba75b13..c903a6135de 100644 --- a/src/utils/transform.ts +++ b/src/utils/transform.ts @@ -1,31 +1,38 @@ import MagicString, { SourceMap } from 'magic-string'; -import Module from '../Module'; -import { +import type Module from '../Module'; +import type { DecodedSourceMapOrMissing, EmittedFile, ExistingRawSourceMap, + LoggingFunctionWithPosition, + LogHandler, Plugin, PluginContext, RollupError, - RollupWarning, SourceDescription, TransformModuleJSON, TransformPluginContext, - TransformResult, - WarningHandler + TransformResult } from '../rollup/types'; +import { getTrackedPluginCache } from './PluginCache'; +import type { PluginDriver } from './PluginDriver'; import { collapseSourcemap } from './collapseSourcemaps'; import { decodedSourcemap } from './decodedSourcemap'; -import { augmentCodeLocation, errNoTransformMapOrAstWithoutCode } from './error'; -import { getTrackedPluginCache } from './PluginCache'; -import { PluginDriver } from './PluginDriver'; -import { throwPluginError } from './pluginUtils'; +import { LOGLEVEL_WARN } from './logging'; +import { + augmentCodeLocation, + error, + logInvalidSetAssetSourceCall, + logNoTransformMapOrAstWithoutCode, + logPluginError +} from './logs'; +import { normalizeLog } from './options/options'; -export default function transform( +export default async function transform( source: SourceDescription, module: Module, pluginDriver: PluginDriver, - warn: WarningHandler + log: LogHandler ): Promise { const id = module.id; const sourcemapChain: DecodedSourceMapOrMissing[] = []; @@ -37,8 +44,8 @@ export default function transform( const emittedFiles: EmittedFile[] = []; let customTransformCache = false; const useCustomTransformCache = () => (customTransformCache = true); - let curPlugin: Plugin; - const curSource: string = source.code; + let pluginName = ''; + let currentSource = source.code; function transformReducer( this: PluginContext, @@ -54,7 +61,7 @@ export default function transform( module.updateOptions(result); if (result.code == null) { if (result.map || result.ast) { - warn(errNoTransformMapOrAstWithoutCode(plugin.name)); + log(LOGLEVEL_WARN, logNoTransformMapOrAstWithoutCode(plugin.name)); } return previousCode; } @@ -74,56 +81,53 @@ export default function transform( ); } + currentSource = code; + return code; } - return pluginDriver - .hookReduceArg0( + const getLogHandler = + (handler: LoggingFunctionWithPosition): LoggingFunctionWithPosition => + (log, pos) => { + log = normalizeLog(log); + if (pos) augmentCodeLocation(log, pos, currentSource, id); + log.id = id; + log.hook = 'transform'; + handler(log); + }; + + let code: string; + + try { + code = await pluginDriver.hookReduceArg0( 'transform', - [curSource, id], + [currentSource, id], transformReducer, (pluginContext, plugin): TransformPluginContext => { - curPlugin = plugin; + pluginName = plugin.name; return { ...pluginContext, + addWatchFile(id: string) { + transformDependencies.push(id); + pluginContext.addWatchFile(id); + }, cache: customTransformCache ? pluginContext.cache : getTrackedPluginCache(pluginContext.cache, useCustomTransformCache), - warn(warning: RollupWarning | string, pos?: number | { column: number; line: number }) { - if (typeof warning === 'string') warning = { message: warning } as RollupWarning; - if (pos) augmentCodeLocation(warning, pos, curSource, id); - warning.id = id; - warning.hook = 'transform'; - pluginContext.warn(warning); - }, - error(err: RollupError | string, pos?: number | { column: number; line: number }): never { - if (typeof err === 'string') err = { message: err }; - if (pos) augmentCodeLocation(err, pos, curSource, id); - err.id = id; - err.hook = 'transform'; - return pluginContext.error(err); - }, - emitAsset(name: string, source?: string | Uint8Array) { - emittedFiles.push({ type: 'asset' as const, name, source }); - return pluginContext.emitAsset(name, source); - }, - emitChunk(id, options) { - emittedFiles.push({ type: 'chunk' as const, id, name: options && options.name }); - return pluginContext.emitChunk(id, options); - }, + debug: getLogHandler(pluginContext.debug), emitFile(emittedFile: EmittedFile) { emittedFiles.push(emittedFile); return pluginDriver.emitFile(emittedFile); }, - addWatchFile(id: string) { - transformDependencies.push(id); - pluginContext.addWatchFile(id); - }, - setAssetSource() { - return this.error({ - code: 'INVALID_SETASSETSOURCE', - message: `setAssetSource cannot be called in transform for caching reasons. Use emitFile with a source, or call setAssetSource in another hook.` - }); + error( + error_: RollupError | string, + pos?: number | { column: number; line: number } + ): never { + if (typeof error_ === 'string') error_ = { message: error_ }; + if (pos) augmentCodeLocation(error_, pos, currentSource, id); + error_.id = id; + error_.hook = 'transform'; + return pluginContext.error(error_); }, getCombinedSourcemap() { const combinedMap = collapseSourcemap( @@ -131,11 +135,11 @@ export default function transform( originalCode, originalSourcemap, sourcemapChain, - warn + log ); if (!combinedMap) { const magicString = new MagicString(originalCode); - return magicString.generateMap({ includeContent: true, hires: true, source: id }); + return magicString.generateMap({ hires: true, includeContent: true, source: id }); } if (originalSourcemap !== combinedMap) { originalSourcemap = combinedMap; @@ -143,29 +147,36 @@ export default function transform( } return new SourceMap({ ...combinedMap, - file: null as any, + file: null as never, sourcesContent: combinedMap.sourcesContent! }); - } + }, + info: getLogHandler(pluginContext.info), + setAssetSource() { + return this.error(logInvalidSetAssetSourceCall()); + }, + warn: getLogHandler(pluginContext.warn) }; } - ) - .catch(err => throwPluginError(err, curPlugin.name, { hook: 'transform', id })) - .then(code => { - if (!customTransformCache) { - // files emitted by a transform hook need to be emitted again if the hook is skipped - if (emittedFiles.length) module.transformFiles = emittedFiles; - } + ); + } catch (error_: any) { + return error(logPluginError(error_, pluginName, { hook: 'transform', id })); + } + + if ( + !customTransformCache && // files emitted by a transform hook need to be emitted again if the hook is skipped + emittedFiles.length > 0 + ) + module.transformFiles = emittedFiles; - return { - ast, - code, - customTransformCache, - meta: module.info.meta, - originalCode, - originalSourcemap, - sourcemapChain, - transformDependencies - }; - }); + return { + ast, + code, + customTransformCache, + originalCode, + originalSourcemap, + safeVariableNames: null, + sourcemapChain, + transformDependencies + }; } diff --git a/src/utils/traverseStaticDependencies.ts b/src/utils/traverseStaticDependencies.ts index e2828eb83bf..1f88696a267 100644 --- a/src/utils/traverseStaticDependencies.ts +++ b/src/utils/traverseStaticDependencies.ts @@ -1,7 +1,7 @@ import ExternalModule from '../ExternalModule'; -import Module from '../Module'; +import type Module from '../Module'; -export function markModuleAndImpureDependenciesAsExecuted(baseModule: Module) { +export function markModuleAndImpureDependenciesAsExecuted(baseModule: Module): void { baseModule.isExecuted = true; const modules = [baseModule]; const visitedModules = new Set(); @@ -10,7 +10,7 @@ export function markModuleAndImpureDependenciesAsExecuted(baseModule: Module) { if ( !(dependency instanceof ExternalModule) && !dependency.isExecuted && - (dependency.info.hasModuleSideEffects || module.implicitlyLoadedBefore.has(dependency)) && + (dependency.info.moduleSideEffects || module.implicitlyLoadedBefore.has(dependency)) && !visitedModules.has(dependency.id) ) { dependency.isExecuted = true; diff --git a/src/utils/treeshakeNode.ts b/src/utils/treeshakeNode.ts index 5fafca1d635..4bc767a645e 100644 --- a/src/utils/treeshakeNode.ts +++ b/src/utils/treeshakeNode.ts @@ -1,30 +1,7 @@ -import MagicString from 'magic-string'; -import * as NodeType from '../ast/nodes/NodeType'; -import { Node } from '../ast/nodes/shared/Node'; +import type MagicString from 'magic-string'; +import type { Node } from '../ast/nodes/shared/Node'; -export function treeshakeNode(node: Node, code: MagicString, start: number, end: number) { +export function treeshakeNode(node: Node, code: MagicString, start: number, end: number): void { code.remove(start, end); - if (node.annotations) { - for (const annotation of node.annotations) { - if (!annotation.comment) { - continue; - } - if (annotation.comment.start < start) { - code.remove(annotation.comment.start, annotation.comment.end); - } else { - return; - } - } - } -} - -export function removeAnnotations(node: Node, code: MagicString) { - if (!node.annotations && node.parent.type === NodeType.ExpressionStatement) { - node = node.parent as Node; - } - if (node.annotations) { - for (const annotation of node.annotations.filter((a) => a.comment)) { - code.remove(annotation.comment!.start, annotation.comment!.end); - } - } + node.removeAnnotations(code); } diff --git a/src/utils/url.ts b/src/utils/url.ts new file mode 100644 index 00000000000..b81341e2b5c --- /dev/null +++ b/src/utils/url.ts @@ -0,0 +1,19 @@ +export function isValidUrl(url: string): boolean { + try { + new URL(url); + } catch { + return false; + } + return true; +} + +export function getRollupUrl(snippet: string) { + return `https://rollupjs.org/${snippet}`; +} + +export function addTrailingSlashIfMissed(url: string) { + if (!url.endsWith('/')) { + return url + '/'; + } + return url; +} diff --git a/src/utils/urls.ts b/src/utils/urls.ts new file mode 100644 index 00000000000..3b94e774b83 --- /dev/null +++ b/src/utils/urls.ts @@ -0,0 +1,48 @@ +// troubleshooting +export const URL_AVOIDING_EVAL = 'troubleshooting/#avoiding-eval'; +export const URL_NAME_IS_NOT_EXPORTED = 'troubleshooting/#error-name-is-not-exported-by-module'; +export const URL_THIS_IS_UNDEFINED = 'troubleshooting/#error-this-is-undefined'; +export const URL_TREATING_MODULE_AS_EXTERNAL_DEPENDENCY = + 'troubleshooting/#warning-treating-module-as-external-dependency'; +export const URL_SOURCEMAP_IS_LIKELY_TO_BE_INCORRECT = + 'troubleshooting/#warning-sourcemap-is-likely-to-be-incorrect'; + +// configuration-options +export const URL_JSX = 'configuration-options/#jsx'; +export const URL_MAXPARALLELFILEOPS = 'configuration-options/#maxparallelfileops'; +export const URL_OUTPUT_AMD_ID = 'configuration-options/#output-amd-id'; +export const URL_OUTPUT_AMD_BASEPATH = 'configuration-options/#output-amd-basepath'; +export const URL_OUTPUT_DIR = 'configuration-options/#output-dir'; +export const URL_OUTPUT_EXPORTS = 'configuration-options/#output-exports'; +export const URL_OUTPUT_EXTEND = 'configuration-options/#output-extend'; +export const URL_OUTPUT_EXTERNALIMPORTATTRIBUTES = + 'configuration-options/#output-externalimportattributes'; +export const URL_OUTPUT_FORMAT = 'configuration-options/#output-format'; +export const URL_OUTPUT_GENERATEDCODE = 'configuration-options/#output-generatedcode'; +export const URL_OUTPUT_GENERATEDCODE_SYMBOLS = + 'configuration-options/#output-generatedcode-symbols'; +export const URL_OUTPUT_GLOBALS = 'configuration-options/#output-globals'; +export const URL_OUTPUT_INLINEDYNAMICIMPORTS = 'configuration-options/#output-inlinedynamicimports'; +export const URL_OUTPUT_INTEROP = 'configuration-options/#output-interop'; +export const URL_OUTPUT_MANUALCHUNKS = 'configuration-options/#output-manualchunks'; +export const URL_OUTPUT_NAME = 'configuration-options/#output-name'; +export const URL_OUTPUT_PRESERVEMODULES = 'configuration-options/#output-preservemodules'; +export const URL_OUTPUT_SOURCEMAPBASEURL = 'configuration-options/#output-sourcemapbaseurl'; +export const URL_OUTPUT_SOURCEMAPFILE = 'configuration-options/#output-sourcemapfile'; +export const URL_PRESERVEENTRYSIGNATURES = 'configuration-options/#preserveentrysignatures'; +export const URL_TREESHAKE = 'configuration-options/#treeshake'; +export const URL_TREESHAKE_PURE = 'configuration-options/#pure'; +export const URL_TREESHAKE_NOSIDEEFFECTS = 'configuration-options/#no-side-effects'; +export const URL_TREESHAKE_MODULESIDEEFFECTS = 'configuration-options/#treeshake-modulesideeffects'; +export const URL_WATCH = 'configuration-options/#watch'; + +// command-line-interface +export const URL_BUNDLE_CONFIG_AS_CJS = 'command-line-interface/#bundleconfigascjs'; +export const URL_CONFIGURATION_FILES = 'command-line-interface/#configuration-files'; + +// plugin-development +export const URL_A_SIMPLE_EXAMPLE = 'plugin-development/#a-simple-example'; +export const URL_GENERATEBUNDLE = 'plugin-development/#generatebundle'; +export const URL_RENDERDYNAMICIMPORT = 'plugin-development/#renderdynamicimport'; +export const URL_THIS_GETMODULEIDS = 'plugin-development/#this-getmoduleids'; +export const URL_THIS_GETMODULEINFO = 'plugin-development/#this-getmoduleinfo'; diff --git a/src/watch/WatchEmitter.ts b/src/watch/WatchEmitter.ts new file mode 100644 index 00000000000..278a4599ac9 --- /dev/null +++ b/src/watch/WatchEmitter.ts @@ -0,0 +1,72 @@ +import type { AwaitedEventListener, AwaitingEventEmitter } from '../rollup/types'; + +export class WatchEmitter< + T extends Record any> +> implements AwaitingEventEmitter { + private currentHandlers: { + [K in keyof T]?: AwaitedEventListener[]; + } = Object.create(null); + private persistentHandlers: { + [K in keyof T]?: AwaitedEventListener[]; + } = Object.create(null); + + // Will be overwritten by Rollup + async close(): Promise {} + + emit(event: K, ...parameters: Parameters): Promise { + return Promise.all( + [...this.getCurrentHandlers(event), ...this.getPersistentHandlers(event)].map(handler => + handler(...parameters) + ) + ); + } + + off(event: K, listener: AwaitedEventListener): this { + const listeners = this.persistentHandlers[event]; + if (listeners) { + // A hack stolen from "mitt": ">>> 0" does not change numbers >= 0, but -1 + // (which would remove the last array element if used unchanged) is turned + // into max_int, which is outside the array and does not change anything. + listeners.splice(listeners.indexOf(listener) >>> 0, 1); + } + return this; + } + + on(event: K, listener: AwaitedEventListener): this { + this.getPersistentHandlers(event).push(listener); + return this; + } + + onCurrentRun(event: K, listener: AwaitedEventListener): this { + this.getCurrentHandlers(event).push(listener); + return this; + } + + once(event: K, listener: AwaitedEventListener): this { + const selfRemovingListener: AwaitedEventListener = (...parameters) => { + this.off(event, selfRemovingListener); + return listener(...parameters); + }; + this.on(event, selfRemovingListener); + return this; + } + + removeAllListeners(): this { + this.removeListenersForCurrentRun(); + this.persistentHandlers = Object.create(null); + return this; + } + + removeListenersForCurrentRun(): this { + this.currentHandlers = Object.create(null); + return this; + } + + private getCurrentHandlers(event: K): AwaitedEventListener[] { + return this.currentHandlers[event] || (this.currentHandlers[event] = []); + } + + private getPersistentHandlers(event: K): AwaitedEventListener[] { + return this.persistentHandlers[event] || (this.persistentHandlers[event] = []); + } +} diff --git a/src/watch/fileWatcher.ts b/src/watch/fileWatcher.ts index 02d40ed5bf3..96d53913d69 100644 --- a/src/watch/fileWatcher.ts +++ b/src/watch/fileWatcher.ts @@ -1,13 +1,13 @@ -import chokidar, { FSWatcher } from 'chokidar'; -import { platform } from 'os'; -import { ChangeEvent, ChokidarOptions } from '../rollup/types'; -import { Task } from './watch'; +import chokidar, { type FSWatcher } from 'chokidar'; +import { platform } from 'node:os'; +import type { ChangeEvent, ChokidarOptions } from '../rollup/types'; +import type { Task } from './watch'; export class FileWatcher { - private chokidarOptions: ChokidarOptions; - private task: Task; - private transformWatchers = new Map(); - private watcher: FSWatcher; + private readonly chokidarOptions: ChokidarOptions; + private readonly task: Task; + private readonly transformWatchers = new Map(); + private readonly watcher: FSWatcher; constructor(task: Task, chokidarOptions: ChokidarOptions) { this.chokidarOptions = chokidarOptions; @@ -15,14 +15,14 @@ export class FileWatcher { this.watcher = this.createWatcher(null); } - close() { + close(): void { this.watcher.close(); for (const watcher of this.transformWatchers.values()) { watcher.close(); } } - unwatch(id: string) { + unwatch(id: string): void { this.watcher.unwatch(id); const transformWatcher = this.transformWatchers.get(id); if (transformWatcher) { @@ -31,9 +31,9 @@ export class FileWatcher { } } - watch(id: string, isTransformDependency: boolean) { + watch(id: string, isTransformDependency: boolean): void { if (isTransformDependency) { - const watcher = this.transformWatchers.get(id) || this.createWatcher(id); + const watcher = this.transformWatchers.get(id) ?? this.createWatcher(id); watcher.add(id); this.transformWatchers.set(id, watcher); } else { @@ -44,17 +44,18 @@ export class FileWatcher { private createWatcher(transformWatcherId: string | null): FSWatcher { const task = this.task; const isLinux = platform() === 'linux'; + const isFreeBSD = platform() === 'freebsd'; const isTransformDependency = transformWatcherId !== null; const handleChange = (id: string, event: ChangeEvent) => { const changedId = transformWatcherId || id; - if (isLinux) { + if (isLinux || isFreeBSD) { // unwatching and watching fixes an issue with chokidar where on certain systems, // a file that was unlinked and immediately recreated would create a change event // but then no longer any further events watcher.unwatch(changedId); watcher.add(changedId); } - task.invalidate(changedId, {isTransformDependency, event}); + task.invalidate(changedId, { event, isTransformDependency }); }; const watcher = chokidar .watch([], this.chokidarOptions) diff --git a/src/watch/fsevents-importer.ts b/src/watch/fsevents-importer.ts index d9ee8bc60d4..8a65eff4cc0 100644 --- a/src/watch/fsevents-importer.ts +++ b/src/watch/fsevents-importer.ts @@ -1,18 +1,19 @@ -let fsEvents: any; -let fsEventsImportError: any; +import type FsEvents from 'fsevents'; +import '../../typings/fsevents'; -export function loadFsEvents() { - return import('fsevents') - .then(namespace => { - fsEvents = namespace.default; - }) - .catch(err => { - fsEventsImportError = err; - }); +let fsEvents: typeof FsEvents; +let fsEventsImportError: Error | undefined; + +export async function loadFsEvents(): Promise { + try { + ({ default: fsEvents } = await import('fsevents')); + } catch (error: any) { + fsEventsImportError = error; + } } // A call to this function will be injected into the chokidar code -export function getFsEvents() { +export function getFsEvents(): typeof FsEvents { if (fsEventsImportError) throw fsEventsImportError; return fsEvents; } diff --git a/src/watch/watch-proxy.ts b/src/watch/watch-proxy.ts index b1b006b8aae..f2c0d10a549 100644 --- a/src/watch/watch-proxy.ts +++ b/src/watch/watch-proxy.ts @@ -1,35 +1,80 @@ -import { EventEmitter } from 'events'; -import { RollupWatcher } from '../rollup/types'; +import { handleError } from '../../cli/logging'; +import type { + MaybeArray, + MergedRollupOptions, + RollupOptions, + RollupWatcher +} from '../rollup/types'; import { ensureArray } from '../utils/ensureArray'; -import { errInvalidOption, error } from '../utils/error'; -import { GenericConfigObject } from '../utils/options/options'; +import { error, logInvalidOption } from '../utils/logs'; +import { mergeOptions } from '../utils/options/mergeOptions'; +import { URL_WATCH } from '../utils/urls'; import { loadFsEvents } from './fsevents-importer'; +import { WatchEmitter } from './WatchEmitter'; -class WatchEmitter extends EventEmitter { - constructor() { - super(); - // Allows more than 10 bundles to be watched without - // showing the `MaxListenersExceededWarning` to the user. - this.setMaxListeners(Infinity); +export default function watch(configs: RollupOptions[] | RollupOptions): RollupWatcher { + const emitter = new WatchEmitter() as RollupWatcher; + + watchInternal(configs, emitter).catch(error => { + handleError(error); + }); + + return emitter; +} + +function ensureTrailingSlash(path: string): string { + if (path[path.length - 1] !== '/') { + return `${path}/`; } + return path; +} - close() {} +function checkWatchConfig(config: MergedRollupOptions[]): void { + for (const item of config) { + if (typeof item.watch !== 'boolean' && item.watch?.allowInputInsideOutputPath) { + break; + } + if (item.input && item.output) { + const input = typeof item.input === 'string' ? ensureArray(item.input) : item.input; + const outputs = ensureArray(item.output); + for (const index in input) { + const inputPath = input[index as keyof typeof input]; + if (typeof inputPath !== 'string') { + continue; + } + const outputWithInputAsSubPath = outputs.find( + ({ dir }) => dir && ensureTrailingSlash(inputPath).startsWith(ensureTrailingSlash(dir)) + ); + if (outputWithInputAsSubPath) { + error( + logInvalidOption( + 'watch', + URL_WATCH, + `the input "${inputPath}" is a subpath of the output "${outputWithInputAsSubPath.dir}"` + ) + ); + } + } + } + } } -export default function watch(configs: GenericConfigObject[] | GenericConfigObject): RollupWatcher { - const emitter = new WatchEmitter() as RollupWatcher; - const configArray = ensureArray(configs); - const watchConfigs = configArray.filter(config => config.watch !== false); - if (watchConfigs.length === 0) { - throw error( - errInvalidOption( +async function watchInternal(configs: MaybeArray, emitter: RollupWatcher) { + const optionsList = await Promise.all( + ensureArray(configs).map(config => mergeOptions(config, true)) + ); + const watchOptionsList = optionsList.filter(config => config.watch !== false); + if (watchOptionsList.length === 0) { + return error( + logInvalidOption( 'watch', + URL_WATCH, 'there must be at least one config where "watch" is not set to "false"' ) ); } - loadFsEvents() - .then(() => import('./watch')) - .then(({ Watcher }) => new Watcher(watchConfigs, emitter)); - return emitter; + checkWatchConfig(watchOptionsList); + await loadFsEvents(); + const { Watcher } = await import('./watch'); + new Watcher(watchOptionsList, emitter); } diff --git a/src/watch/watch.ts b/src/watch/watch.ts index b6a1881fdb6..6095e9fd3e1 100644 --- a/src/watch/watch.ts +++ b/src/watch/watch.ts @@ -1,7 +1,8 @@ -import * as path from 'path'; -import createFilter from 'rollup-pluginutils/src/createFilter'; +import { createFilter } from '@rollup/pluginutils'; +import path from 'node:path'; +import process from 'node:process'; import { rollupInternal } from '../rollup/rollup'; -import { +import type { ChangeEvent, MergedRollupOptions, OutputOptions, @@ -10,8 +11,6 @@ import { RollupWatcher, WatcherOptions } from '../rollup/types'; -import { mergeOptions } from '../utils/options/mergeOptions'; -import { GenericConfigObject } from '../utils/options/options'; import { FileWatcher } from './fileWatcher'; const eventsRewrites: Record> = { @@ -33,43 +32,43 @@ const eventsRewrites: Record = new Map(); + private buildTimeout: ReturnType | null = null; + private closed = false; + private readonly invalidatedIds = new Map(); private rerun = false; - private running: boolean; - private tasks: Task[]; + private running = true; + private readonly tasks: Task[]; - constructor(configs: GenericConfigObject[], emitter: RollupWatcher) { + constructor(optionsList: readonly MergedRollupOptions[], emitter: RollupWatcher) { this.emitter = emitter; emitter.close = this.close.bind(this); - this.tasks = configs.map(config => new Task(this, config)); - this.buildDelay = configs.reduce( - (buildDelay, { watch }: any) => - watch && typeof watch.buildDelay === 'number' - ? Math.max(buildDelay, (watch as WatcherOptions).buildDelay!) - : buildDelay, - this.buildDelay - ); - this.running = true; + this.tasks = optionsList.map(options => new Task(this, options)); + for (const { watch } of optionsList) { + if (watch && typeof watch.buildDelay === 'number') { + this.buildDelay = Math.max(this.buildDelay, watch.buildDelay!); + } + } process.nextTick(() => this.run()); } - close() { + async close(): Promise { + if (this.closed) return; + this.closed = true; if (this.buildTimeout) clearTimeout(this.buildTimeout); for (const task of this.tasks) { task.close(); } - this.emitter.emit('close'); + await this.emitter.emit('close'); this.emitter.removeAllListeners(); } - invalidate(file?: { event: ChangeEvent; id: string }) { + invalidate(file?: { event: ChangeEvent; id: string }): void { if (file) { - const prevEvent = this.invalidatedIds.get(file.id); - const event = prevEvent ? eventsRewrites[prevEvent][file.event] : file.event; + const previousEvent = this.invalidatedIds.get(file.id); + const event = previousEvent ? eventsRewrites[previousEvent][file.event] : file.event; if (event === 'buggy') { //TODO: throws or warn? Currently just ignore, uses new event @@ -87,20 +86,33 @@ export class Watcher { if (this.buildTimeout) clearTimeout(this.buildTimeout); - this.buildTimeout = setTimeout(() => { + this.buildTimeout = setTimeout(async () => { this.buildTimeout = null; - for (const [id, event] of this.invalidatedIds.entries()) { - this.emitter.emit('change', id, { event }); + try { + await Promise.all( + [...this.invalidatedIds].map(([id, event]) => this.emitter.emit('change', id, { event })) + ); + this.invalidatedIds.clear(); + await this.emitter.emit('restart'); + this.emitter.removeListenersForCurrentRun(); + this.run(); + } catch (error: any) { + this.invalidatedIds.clear(); + await this.emitter.emit('event', { + code: 'ERROR', + error, + result: null + }); + await this.emitter.emit('event', { + code: 'END' + }); } - this.invalidatedIds.clear(); - this.emitter.emit('restart'); - this.run(); }, this.buildDelay); } - private async run() { + private async run(): Promise { this.running = true; - this.emitter.emit('event', { + await this.emitter.emit('event', { code: 'START' }); @@ -109,7 +121,7 @@ export class Watcher { } this.running = false; - this.emitter.emit('event', { + await this.emitter.emit('event', { code: 'END' }); if (this.rerun) { @@ -123,54 +135,54 @@ export class Task { cache: RollupCache = { modules: [] }; watchFiles: string[] = []; - private closed: boolean; - private fileWatcher: FileWatcher; + private closed = false; + private readonly fileWatcher: FileWatcher; private filter: (id: string) => boolean; private invalidated = true; - private options: MergedRollupOptions; - private outputFiles: string[]; - private outputs: OutputOptions[]; + private readonly options: MergedRollupOptions; + private readonly outputFiles: string[]; + private readonly outputs: OutputOptions[]; private skipWrite: boolean; - private watched: Set; - private watcher: Watcher; + private watched = new Set(); + private readonly watcher: Watcher; + private readonly watchOptions: WatcherOptions; - constructor(watcher: Watcher, config: GenericConfigObject) { + constructor(watcher: Watcher, options: MergedRollupOptions) { this.watcher = watcher; - this.closed = false; - this.watched = new Set(); + this.options = options; - this.skipWrite = Boolean(config.watch && (config.watch as GenericConfigObject).skipWrite); - this.options = mergeOptions(config); + this.skipWrite = Boolean(options.watch && options.watch.skipWrite); this.outputs = this.options.output; this.outputFiles = this.outputs.map(output => { if (output.file || output.dir) return path.resolve(output.file || output.dir!); - return undefined as any; + return undefined as never; }); - const watchOptions: WatcherOptions = this.options.watch || {}; - this.filter = createFilter(watchOptions.include, watchOptions.exclude); + this.watchOptions = this.options.watch || {}; + this.filter = createFilter(this.watchOptions.include, this.watchOptions.exclude); this.fileWatcher = new FileWatcher(this, { - ...watchOptions.chokidar, + ...this.watchOptions.chokidar, disableGlobbing: true, ignoreInitial: true }); } - close() { + close(): void { this.closed = true; this.fileWatcher.close(); } - invalidate(id: string, details: { event: ChangeEvent; isTransformDependency?: boolean }) { + invalidate(id: string, details: { event: ChangeEvent; isTransformDependency?: boolean }): void { this.invalidated = true; if (details.isTransformDependency) { for (const module of this.cache.modules) { - if (module.transformDependencies.indexOf(id) === -1) continue; + if (!module.transformDependencies.includes(id)) continue; // effective invalidation - module.originalCode = null as any; + module.originalCode = null as never; } } - this.watcher.invalidate({ id, event: details.event }); + this.watcher.invalidate({ event: details.event, id }); + this.watchOptions.onInvalidate?.(id); } async run(): Promise { @@ -184,7 +196,7 @@ export class Task { const start = Date.now(); - this.watcher.emitter.emit('event', { + await this.watcher.emitter.emit('event', { code: 'BUNDLE_START', input: this.options.input, output: this.outputFiles @@ -197,15 +209,21 @@ export class Task { return; } this.updateWatchedFiles(result); - this.skipWrite || (await Promise.all(this.outputs.map(output => result!.write(output)))); - this.watcher.emitter.emit('event', { + if (!this.skipWrite) { + await Promise.all(this.outputs.map(output => result!.write(output))); + if (this.closed) { + return; + } + this.updateWatchedFiles(result!); + } + await this.watcher.emitter.emit('event', { code: 'BUNDLE_END', duration: Date.now() - start, input: this.options.input, output: this.outputFiles, result }); - } catch (error) { + } catch (error: any) { if (!this.closed) { if (Array.isArray(error.watchFiles)) { for (const id of error.watchFiles) { @@ -216,7 +234,7 @@ export class Task { this.cache.modules = this.cache.modules.filter(module => module.id !== error.id); } } - this.watcher.emitter.emit('event', { + await this.watcher.emitter.emit('event', { code: 'ERROR', error, result @@ -248,7 +266,7 @@ export class Task { if (!this.filter(id)) return; this.watched.add(id); - if (this.outputFiles.some(file => file === id)) { + if (this.outputFiles.includes(id)) { throw new Error('Cannot import the generated bundle'); } diff --git a/test/.eslintrc b/test/.eslintrc deleted file mode 100644 index e9ea1fc9d8b..00000000000 --- a/test/.eslintrc +++ /dev/null @@ -1,10 +0,0 @@ -{ - "rules": { - "no-console": [ 0 ], - "no-prototype-builtins": [ 0 ], - "no-unused-vars": [ "error", { "vars": "all", "args": "none" } ] - }, - "env": { - "mocha": true - } -} diff --git a/test/browser/define.d.ts b/test/browser/define.d.ts new file mode 100644 index 00000000000..1fde8f77e5e --- /dev/null +++ b/test/browser/define.d.ts @@ -0,0 +1,5 @@ +import type { TestConfigBrowser } from '../types'; + +declare global { + function defineTest(config: TestConfigBrowser): TestConfigBrowser; +} diff --git a/test/browser/index.js b/test/browser/index.js index d77fcc5ac90..b966e0c7900 100644 --- a/test/browser/index.js +++ b/test/browser/index.js @@ -1,76 +1,97 @@ +// since we don't run the browser tests in an actual browser, we need to make `performance` +// globally accessible same as in the browser. this can be removed once `performance` is +// available globally in all supported platforms. [currently global for node.js v16+]. +const { readFile } = require('node:fs/promises'); +const path = require('node:path'); + +global.performance = require('node:perf_hooks').performance; + +global.fetch = url => readFile(url.href.replace('file://', '')); + const fixturify = require('fixturify'); -const { basename, resolve } = require('path'); -const { rollup } = require('../../dist/rollup.browser.js'); -const { assertFilesAreEqual, runTestSuiteWithSamples, compareError } = require('../utils.js'); -runTestSuiteWithSamples('browser', resolve(__dirname, 'samples'), (dir, config) => { - (config.skip ? it.skip : config.solo ? it.only : it)( - basename(dir) + ': ' + config.description, - async () => { - let bundle; - try { - bundle = await rollup({ - input: 'main', - onwarn: warning => { - if (!(config.expectedWarnings && config.expectedWarnings.indexOf(warning.code) >= 0)) { - throw new Error( - `Unexpected warnings (${warning.code}): ${warning.message}\n` + - 'If you expect warnings, list their codes in config.expectedWarnings' - ); - } - }, - strictDeprecations: true, - ...config.options - }); - } catch (error) { +/** + * @type {import('../../src/rollup/types')} Rollup + */ +const { rollup } = require('../../browser/dist/rollup.browser.js'); +const { assertFilesAreEqual, runTestSuiteWithSamples, compareError } = require('../testHelpers.js'); + +runTestSuiteWithSamples( + 'browser', + path.resolve(__dirname, 'samples'), + /** + * @param {import('../types').TestConfigBrowser} config + */ + (directory, config) => { + (config.skip ? it.skip : config.solo ? it.only : it)( + path.basename(directory) + ': ' + config.description, + async () => { + let bundle; + try { + bundle = await rollup({ + input: 'main', + onwarn: warning => { + if (!(config.expectedWarnings && config.expectedWarnings.includes(warning.code))) { + throw new Error( + `Unexpected warnings (${warning.code}): ${warning.message}\n` + + 'If you expect warnings, list their codes in config.expectedWarnings' + ); + } + }, + strictDeprecations: true, + ...config.options + }); + } catch (error) { + if (config.error) { + compareError(error, config.error); + return; + } else { + throw error; + } + } if (config.error) { - compareError(error, config.error); - return; - } else { - throw error; + throw new Error('Expected an error while rolling up'); + } + let output; + try { + ({ output } = await bundle.generate({ + exports: 'auto', + format: 'es', + ...(config.options || {}).output + })); + } catch (error) { + if (config.generateError) { + compareError(error, config.generateError); + return; + } else { + throw error; + } } - } - if (config.error) { - throw new Error('Expected an error while rolling up'); - } - let output; - try { - ({ output } = await bundle.generate({ - exports: 'auto', - format: 'es', - ...(config.options || {}).output - })); - } catch (error) { if (config.generateError) { - compareError(error, config.generateError); - return; - } else { - throw error; + throw new Error('Expected an error while generating output'); } + assertOutputMatches(output, directory); } - if (config.generateError) { - throw new Error('Expected an error while generating output'); - } - assertOutputMatches(output, dir); - } - ); -}); + ).timeout(30_000); + } +); -function assertOutputMatches(output, dir) { +function assertOutputMatches(output, directory) { + /** @type any */ const actual = {}; for (const file of output) { const filePath = file.fileName.split('/'); const fileName = filePath.pop(); - let currentDir = actual; + let currentDirectory = actual; for (const pathElement of filePath) { - if (!currentDir[pathElement]) { - currentDir[pathElement] = {}; + if (!currentDirectory[pathElement]) { + currentDirectory[pathElement] = {}; } - currentDir = currentDir[pathElement] = currentDir[pathElement] || {}; + currentDirectory = currentDirectory[pathElement] = currentDirectory[pathElement] || {}; } - currentDir[fileName] = file.source || file.code; + currentDirectory[fileName] = file.source || file.code; } - fixturify.writeSync(resolve(dir, '_actual'), actual); - const expected = fixturify.readSync(resolve(dir, '_expected')); + fixturify.writeSync(path.resolve(directory, '_actual'), actual); + const expected = fixturify.readSync(path.resolve(directory, '_expected')); assertFilesAreEqual(actual, expected); } diff --git a/test/browser/samples/basic/_config.js b/test/browser/samples/basic/_config.js index a1881638888..865d49b20e3 100644 --- a/test/browser/samples/basic/_config.js +++ b/test/browser/samples/basic/_config.js @@ -1,6 +1,6 @@ -const { loader } = require('../../../utils.js'); +const { loader } = require('../../../testHelpers.js'); -module.exports = { +module.exports = defineTest({ description: 'bundles files for the browser', options: { plugins: loader({ @@ -9,4 +9,4 @@ console.log(foo);`, dep: `export const foo = 42;` }) } -}; +}); diff --git a/test/browser/samples/missing-default-fs/_config.js b/test/browser/samples/missing-default-fs/_config.js new file mode 100644 index 00000000000..2a9277fe0ba --- /dev/null +++ b/test/browser/samples/missing-default-fs/_config.js @@ -0,0 +1,23 @@ +module.exports = defineTest({ + description: 'fails when accessing fs from a browser without supplying it via option', + options: { + plugins: { + name: 'test', + resolveId(source) { + return source; + }, + load(id) { + return this.fs.readFile(id, { encoding: 'utf8' }); + } + } + }, + error: { + code: 'PLUGIN_ERROR', + hook: 'load', + message: + 'Could not load main: Cannot access the file system (via "fs.readFile") when using the browser build of Rollup. Make sure you supply a plugin with custom resolveId and load hooks to Rollup.', + plugin: 'test', + pluginCode: 'NO_FS_IN_BROWSER', + url: 'https://rollupjs.org/plugin-development/#a-simple-example' + } +}); diff --git a/test/browser/samples/missing-dependency-resolution/_config.js b/test/browser/samples/missing-dependency-resolution/_config.js index 123ab0a95e2..671cebb52cd 100644 --- a/test/browser/samples/missing-dependency-resolution/_config.js +++ b/test/browser/samples/missing-dependency-resolution/_config.js @@ -1,16 +1,36 @@ -const { loader } = require('../../../utils.js'); +const { loader } = require('../../../testHelpers.js'); +const assert = require('node:assert/strict'); -module.exports = { - description: 'fails if a dependency cannot be resolved', +const logs = []; + +module.exports = defineTest({ + description: 'warns if a dependency cannot be resolved', options: { - plugins: loader({ - main: `import {foo} from 'dep'; + onLog(level, log) { + logs.push({ level, log }); + }, + plugins: [ + loader({ + main: `import {foo} from 'dep'; console.log(foo);` - }) - }, - error: { - message: - "Unexpected warnings (UNRESOLVED_IMPORT): 'dep' is imported by main, but could not be resolved – treating it as an external dependency\nIf you expect warnings, list their codes in config.expectedWarnings", - watchFiles: ['main'] + }), + { + buildEnd() { + assert.deepEqual(logs, [ + { + level: 'warn', + log: { + code: 'UNRESOLVED_IMPORT', + exporter: 'dep', + id: 'main', + message: + '"dep" is imported by "main", but could not be resolved – treating it as an external dependency.', + url: 'https://rollupjs.org/troubleshooting/#warning-treating-module-as-external-dependency' + } + } + ]); + } + } + ] } -}; +}); diff --git a/test/browser/samples/missing-dependency-resolution/_expected/main.js b/test/browser/samples/missing-dependency-resolution/_expected/main.js new file mode 100644 index 00000000000..37f4a46d1b5 --- /dev/null +++ b/test/browser/samples/missing-dependency-resolution/_expected/main.js @@ -0,0 +1,3 @@ +import { foo } from 'dep'; + +console.log(foo); diff --git a/test/browser/samples/missing-entry-resolution/_config.js b/test/browser/samples/missing-entry-resolution/_config.js index 727dfa793a2..e41dbc2165e 100644 --- a/test/browser/samples/missing-entry-resolution/_config.js +++ b/test/browser/samples/missing-entry-resolution/_config.js @@ -1,7 +1,7 @@ -module.exports = { +module.exports = defineTest({ description: 'fails if an entry cannot be resolved', error: { code: 'UNRESOLVED_ENTRY', - message: 'Could not resolve entry module (main).' + message: 'Could not resolve entry module "main".' } -}; +}); diff --git a/test/browser/samples/missing-load/_config.js b/test/browser/samples/missing-load/_config.js index 3cedcdce298..6cffb4e5c40 100644 --- a/test/browser/samples/missing-load/_config.js +++ b/test/browser/samples/missing-load/_config.js @@ -1,7 +1,8 @@ -module.exports = { +module.exports = defineTest({ description: 'fails if a file cannot be loaded', options: { plugins: { + name: 'test', resolveId(source) { return source; } @@ -11,7 +12,7 @@ module.exports = { code: 'NO_FS_IN_BROWSER', message: 'Could not load main: Cannot access the file system (via "fs.readFile") when using the browser build of Rollup. Make sure you supply a plugin with custom resolveId and load hooks to Rollup.', - url: 'https://rollupjs.org/guide/en/#a-simple-example', + url: 'https://rollupjs.org/plugin-development/#a-simple-example', watchFiles: ['main'] } -}; +}); diff --git a/test/browser/samples/provide-fs/_config.js b/test/browser/samples/provide-fs/_config.js new file mode 100644 index 00000000000..a053d83a8d3 --- /dev/null +++ b/test/browser/samples/provide-fs/_config.js @@ -0,0 +1,12 @@ +const { Volume } = require('memfs'); + +const vol = Volume.fromJSON({ + main: "console.log('Hello, Rollup!');" +}); + +module.exports = defineTest({ + description: 'allows to provide an in-memory fs via option', + options: { + fs: vol.promises + } +}); diff --git a/test/browser/samples/provide-fs/_expected/main.js b/test/browser/samples/provide-fs/_expected/main.js new file mode 100644 index 00000000000..f5d3e627b54 --- /dev/null +++ b/test/browser/samples/provide-fs/_expected/main.js @@ -0,0 +1 @@ +console.log('Hello, Rollup!'); diff --git a/test/browser/samples/renormalizes-external-paths/_config.js b/test/browser/samples/renormalizes-external-paths/_config.js index fae340e6bc8..cc3de31a68f 100644 --- a/test/browser/samples/renormalizes-external-paths/_config.js +++ b/test/browser/samples/renormalizes-external-paths/_config.js @@ -1,6 +1,6 @@ -const { join, dirname } = require('path').posix; +const { join, dirname } = require('node:path').posix; -module.exports = { +module.exports = defineTest({ description: 'renormalizes external paths if possible', options: { input: ['/main.js', '/nested/entry.js'], @@ -8,6 +8,7 @@ module.exports = { return id.endsWith('ext'); }, plugins: { + name: 'test-plugin', resolveId(source, importer) { if (source.endsWith('ext.js')) { return false; @@ -19,24 +20,29 @@ module.exports = { }, load(id) { switch (id) { - case '/main.js': + case '/main.js': { return `import './nested/dep.js'; import './ext.js'; import './nested/nested-ext.js';`; - case '/dep.js': + } + case '/dep.js': { return `import './ext.js'; import './nested/nested-ext.js';`; - case '/nested/dep.js': + } + case '/nested/dep.js': { return `import '../ext.js'; import './nested-ext.js';`; - case '/nested/entry.js': + } + case '/nested/entry.js': { return `import '../dep.js'; import '../ext.js'; import './nested-ext.js';`; - default: + } + default: { throw new Error(`Unexpected id ${id}`); + } } } } } -}; +}); diff --git a/test/browser/samples/supports-hashes/_config.js b/test/browser/samples/supports-hashes/_config.js index 6079c64980d..cf573523ec2 100644 --- a/test/browser/samples/supports-hashes/_config.js +++ b/test/browser/samples/supports-hashes/_config.js @@ -1,7 +1,7 @@ -const { loader } = require('../../../utils.js'); +const { loader } = require('../../../testHelpers.js'); -module.exports = { - description: 'bundles files for the browser', +module.exports = defineTest({ + description: 'supports hashes in the browser build', options: { input: ['main', 'dep'], plugins: loader({ @@ -13,4 +13,4 @@ console.log(foo);`, entryFileNames: '[name]-[hash].js' } } -}; +}); diff --git a/test/browser/samples/supports-hashes/_expected/dep-cf8755fa.js b/test/browser/samples/supports-hashes/_expected/dep-Cd4Qi2HK.js similarity index 100% rename from test/browser/samples/supports-hashes/_expected/dep-cf8755fa.js rename to test/browser/samples/supports-hashes/_expected/dep-Cd4Qi2HK.js diff --git a/test/browser/samples/supports-hashes/_expected/main-53604712.js b/test/browser/samples/supports-hashes/_expected/main-53604712.js deleted file mode 100644 index 347f7a59847..00000000000 --- a/test/browser/samples/supports-hashes/_expected/main-53604712.js +++ /dev/null @@ -1,3 +0,0 @@ -import { foo } from './dep-cf8755fa.js'; - -console.log(foo); diff --git a/test/browser/samples/supports-hashes/_expected/main-DCJ0aYjk.js b/test/browser/samples/supports-hashes/_expected/main-DCJ0aYjk.js new file mode 100644 index 00000000000..5514e33c803 --- /dev/null +++ b/test/browser/samples/supports-hashes/_expected/main-DCJ0aYjk.js @@ -0,0 +1,3 @@ +import { foo } from './dep-Cd4Qi2HK.js'; + +console.log(foo); diff --git a/test/browser/tsconfig.json b/test/browser/tsconfig.json new file mode 100644 index 00000000000..4a26f3ee84c --- /dev/null +++ b/test/browser/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": "../tsconfig.base.json", + "include": [ + "**/_config.js", + "./index.js", + "./define.d.ts" + ] +} diff --git a/test/chunking-form/define.d.ts b/test/chunking-form/define.d.ts new file mode 100644 index 00000000000..00b66beb120 --- /dev/null +++ b/test/chunking-form/define.d.ts @@ -0,0 +1,5 @@ +import type { TestConfigChunkingForm } from '../types'; + +declare global { + function defineTest(config: TestConfigChunkingForm): TestConfigChunkingForm; +} diff --git a/test/chunking-form/index.js b/test/chunking-form/index.js index 509be3cbe44..9bb7d62687b 100644 --- a/test/chunking-form/index.js +++ b/test/chunking-form/index.js @@ -1,64 +1,86 @@ -const path = require('path'); -const rollup = require('../../dist/rollup'); -const { runTestSuiteWithSamples, assertDirectoriesAreEqual } = require('../utils.js'); +const path = require('node:path'); +/** + * @type {import('../../src/rollup/types')} Rollup + */ +// @ts-expect-error not included in types +const { rollup } = require('../../dist/rollup'); +const { compareLogs } = require('../testHelpers'); +const { + runTestSuiteWithSamples, + assertDirectoriesAreEqual, + shuffle +} = require('../testHelpers.js'); const FORMATS = ['es', 'cjs', 'amd', 'system']; -runTestSuiteWithSamples('chunking form', path.resolve(__dirname, 'samples'), (dir, config) => { - (config.skip ? describe.skip : config.solo ? describe.only : describe)( - path.basename(dir) + ': ' + config.description, - () => { - let bundle; +runTestSuiteWithSamples( + 'chunking form', + path.resolve(__dirname, 'samples'), + (directory, config) => { + (config.skip ? describe.skip : config.solo ? describe.only : describe)( + path.basename(directory) + ': ' + config.description, + () => { + let bundle; - for (const format of FORMATS) { - it('generates ' + format, async () => { - process.chdir(dir); - bundle = - bundle || - (await rollup.rollup( - Object.assign( - { - input: [dir + '/main.js'], - onwarn: warning => { - if ( - !( - config.expectedWarnings && - config.expectedWarnings.indexOf(warning.code) >= 0 - ) - ) { - throw new Error( - `Unexpected warnings (${warning.code}): ${warning.message}\n` + - 'If you expect warnings, list their codes in config.expectedWarnings' - ); - } - }, - strictDeprecations: true + if (config.before) { + before(config.before); + } + if (config.after) { + after(config.after); + } + const logs = []; + const warnings = []; + after(() => config.logs && compareLogs(logs, config.logs)); + + for (const format of shuffle(config.formats || FORMATS)) { + it('generates ' + format, async () => { + process.chdir(directory); + bundle = + bundle || + (await rollup({ + input: [directory + '/main.js'], + onLog: (level, log) => { + logs.push({ level, ...log }); + if (level === 'warn' && !config.expectedWarnings?.includes(log.code)) { + warnings.push(log); + } }, - config.options || {} - ) - )); - await generateAndTestBundle( - bundle, - Object.assign( + strictDeprecations: true, + ...config.options + })); + await generateAndTestBundle( + bundle, { - dir: `${dir}/_actual/${format}`, + dir: `${directory}/_actual/${format}`, exports: 'auto', format, chunkFileNames: 'generated-[name].js', - validate: true + validate: true, + ...(config.options || {}).output }, - (config.options || {}).output || {} - ), - `${dir}/_expected/${format}`, - config - ); - }); + `${directory}/_expected/${format}`, + config + ); + if (warnings.length > 0) { + const codes = new Set(); + for (const { code } of warnings) { + codes.add(code); + } + const messages = warnings.map(({ message }) => `${message}\n\n`).join(''); + warnings.length = 0; + throw new Error( + `Unexpected warnings (${[...codes].join(', ')}): \n${messages}` + + 'If you expect warnings, list their codes in config.expectedWarnings' + ); + } + }); + } } - } - ); -}); + ); + } +); -async function generateAndTestBundle(bundle, outputOptions, expectedDir, config) { +async function generateAndTestBundle(bundle, outputOptions, expectedDirectory, config) { await bundle.write({ ...outputOptions, dir: `${outputOptions.dir}${config.nestedDir ? '/' + config.nestedDir : ''}` @@ -66,7 +88,7 @@ async function generateAndTestBundle(bundle, outputOptions, expectedDir, config) if (outputOptions.format === 'amd' && config.runAmd) { try { const exports = await new Promise((resolve, reject) => { - global.assert = require('assert'); + global.assert = require('node:assert'); const requirejs = require('requirejs'); requirejs.config({ baseUrl: outputOptions.dir }); requirejs([config.nestedDir ? `${config.nestedDir}/main` : 'main'], resolve, reject); @@ -80,5 +102,5 @@ async function generateAndTestBundle(bundle, outputOptions, expectedDir, config) delete global.assert; } } - assertDirectoriesAreEqual(outputOptions.dir, expectedDir); + assertDirectoriesAreEqual(outputOptions.dir, expectedDirectory); } diff --git a/test/chunking-form/samples/aliasing-extensions/_config.js b/test/chunking-form/samples/aliasing-extensions/_config.js index aa5a872d5b7..75668bcd7c4 100644 --- a/test/chunking-form/samples/aliasing-extensions/_config.js +++ b/test/chunking-form/samples/aliasing-extensions/_config.js @@ -1,6 +1,6 @@ -module.exports = { +module.exports = defineTest({ description: 'chunk aliasing with extensions', options: { input: ['main1', 'main2', 'main3.ts'] } -}; +}); diff --git a/test/chunking-form/samples/aliasing-extensions/_expected/amd/generated-main4.dynamic.js b/test/chunking-form/samples/aliasing-extensions/_expected/amd/generated-main4.dynamic.js index ed41892cfe1..3e4747014dc 100644 --- a/test/chunking-form/samples/aliasing-extensions/_expected/amd/generated-main4.dynamic.js +++ b/test/chunking-form/samples/aliasing-extensions/_expected/amd/generated-main4.dynamic.js @@ -1,5 +1,5 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; console.log('main4'); -}); +})); diff --git a/test/chunking-form/samples/aliasing-extensions/_expected/amd/generated-main5.js b/test/chunking-form/samples/aliasing-extensions/_expected/amd/generated-main5.js index db3f430c9aa..956126a6484 100644 --- a/test/chunking-form/samples/aliasing-extensions/_expected/amd/generated-main5.js +++ b/test/chunking-form/samples/aliasing-extensions/_expected/amd/generated-main5.js @@ -1,5 +1,5 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; console.log('main5'); -}); +})); diff --git a/test/chunking-form/samples/aliasing-extensions/_expected/amd/main1.js b/test/chunking-form/samples/aliasing-extensions/_expected/amd/main1.js index faa948b5725..0eb4900e413 100644 --- a/test/chunking-form/samples/aliasing-extensions/_expected/amd/main1.js +++ b/test/chunking-form/samples/aliasing-extensions/_expected/amd/main1.js @@ -1,7 +1,7 @@ -define(['require'], function (require) { 'use strict'; +define(['require'], (function (require) { 'use strict'; console.log('main1'); - new Promise(function (resolve, reject) { require(['./generated-main4.dynamic'], resolve, reject) }); - new Promise(function (resolve, reject) { require(['./generated-main5'], resolve, reject) }); + new Promise(function (resolve, reject) { require(['./generated-main4.dynamic'], resolve, reject); }); + new Promise(function (resolve, reject) { require(['./generated-main5'], resolve, reject); }); -}); +})); diff --git a/test/chunking-form/samples/aliasing-extensions/_expected/amd/main2.js b/test/chunking-form/samples/aliasing-extensions/_expected/amd/main2.js index b58286ca58e..50131c97c96 100644 --- a/test/chunking-form/samples/aliasing-extensions/_expected/amd/main2.js +++ b/test/chunking-form/samples/aliasing-extensions/_expected/amd/main2.js @@ -1,5 +1,5 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; console.log('main2'); -}); +})); diff --git a/test/chunking-form/samples/aliasing-extensions/_expected/amd/main3.js b/test/chunking-form/samples/aliasing-extensions/_expected/amd/main3.js index cac48c4d722..03a17efdc4c 100644 --- a/test/chunking-form/samples/aliasing-extensions/_expected/amd/main3.js +++ b/test/chunking-form/samples/aliasing-extensions/_expected/amd/main3.js @@ -1,5 +1,5 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; console.log('main3'); -}); +})); diff --git a/test/chunking-form/samples/aliasing-extensions/_expected/system/generated-main4.dynamic.js b/test/chunking-form/samples/aliasing-extensions/_expected/system/generated-main4.dynamic.js index 1fd85fc4363..27129dd1605 100644 --- a/test/chunking-form/samples/aliasing-extensions/_expected/system/generated-main4.dynamic.js +++ b/test/chunking-form/samples/aliasing-extensions/_expected/system/generated-main4.dynamic.js @@ -1,10 +1,10 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { console.log('main4'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/aliasing-extensions/_expected/system/generated-main5.js b/test/chunking-form/samples/aliasing-extensions/_expected/system/generated-main5.js index e71255e3ef3..0f79cc5318e 100644 --- a/test/chunking-form/samples/aliasing-extensions/_expected/system/generated-main5.js +++ b/test/chunking-form/samples/aliasing-extensions/_expected/system/generated-main5.js @@ -1,10 +1,10 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { console.log('main5'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/aliasing-extensions/_expected/system/main1.js b/test/chunking-form/samples/aliasing-extensions/_expected/system/main1.js index 7ca66f3c42e..bd7b31cda44 100644 --- a/test/chunking-form/samples/aliasing-extensions/_expected/system/main1.js +++ b/test/chunking-form/samples/aliasing-extensions/_expected/system/main1.js @@ -1,12 +1,12 @@ -System.register([], function (exports, module) { +System.register([], (function (exports, module) { 'use strict'; return { - execute: function () { + execute: (function () { console.log('main1'); module.import('./generated-main4.dynamic.js'); module.import('./generated-main5.js'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/aliasing-extensions/_expected/system/main2.js b/test/chunking-form/samples/aliasing-extensions/_expected/system/main2.js index a272843f834..b91e108e596 100644 --- a/test/chunking-form/samples/aliasing-extensions/_expected/system/main2.js +++ b/test/chunking-form/samples/aliasing-extensions/_expected/system/main2.js @@ -1,10 +1,10 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { console.log('main2'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/aliasing-extensions/_expected/system/main3.js b/test/chunking-form/samples/aliasing-extensions/_expected/system/main3.js index ddc6fb10c48..d256a1ac3a4 100644 --- a/test/chunking-form/samples/aliasing-extensions/_expected/system/main3.js +++ b/test/chunking-form/samples/aliasing-extensions/_expected/system/main3.js @@ -1,10 +1,10 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { console.log('main3'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/allow-extension-exports-with-explicat-file-name/_config.js b/test/chunking-form/samples/allow-extension-exports-with-explicat-file-name/_config.js new file mode 100644 index 00000000000..aa82e303304 --- /dev/null +++ b/test/chunking-form/samples/allow-extension-exports-with-explicat-file-name/_config.js @@ -0,0 +1,21 @@ +const preserveSignature = 'allow-extension'; +module.exports = defineTest({ + description: 'generate the separate chunk for the entry module with explicated file name', + options: { + input: 'main', + output: { + manualChunks: { + libs: ['lib1', 'lib2'] + } + }, + plugins: [ + { + name: 'allow-extension-plugin', + buildStart() { + this.emitFile({ type: 'chunk', id: 'lib1', fileName: 'lib1.js', preserveSignature }); + this.emitFile({ type: 'chunk', id: 'lib2', fileName: 'lib2.js', preserveSignature }); + } + } + ] + } +}); diff --git a/test/chunking-form/samples/allow-extension-exports-with-explicat-file-name/_expected/amd/lib1.js b/test/chunking-form/samples/allow-extension-exports-with-explicat-file-name/_expected/amd/lib1.js new file mode 100644 index 00000000000..3abd3e9f2af --- /dev/null +++ b/test/chunking-form/samples/allow-extension-exports-with-explicat-file-name/_expected/amd/lib1.js @@ -0,0 +1,11 @@ +define(['exports'], (function (exports) { 'use strict'; + + const value1 = 'lib1-value'; + + const value2 = 'lib2-value'; + + exports.value1 = value1; + exports.value2 = value2; + exports.value2$1 = value2; + +})); diff --git a/test/chunking-form/samples/allow-extension-exports-with-explicat-file-name/_expected/amd/lib2.js b/test/chunking-form/samples/allow-extension-exports-with-explicat-file-name/_expected/amd/lib2.js new file mode 100644 index 00000000000..7f6977b4689 --- /dev/null +++ b/test/chunking-form/samples/allow-extension-exports-with-explicat-file-name/_expected/amd/lib2.js @@ -0,0 +1,7 @@ +define(['exports', './lib1'], (function (exports, libs) { 'use strict'; + + + + exports.value2 = libs.value2$1; + +})); diff --git a/test/chunking-form/samples/allow-extension-exports-with-explicat-file-name/_expected/amd/main.js b/test/chunking-form/samples/allow-extension-exports-with-explicat-file-name/_expected/amd/main.js new file mode 100644 index 00000000000..5af08acfa30 --- /dev/null +++ b/test/chunking-form/samples/allow-extension-exports-with-explicat-file-name/_expected/amd/main.js @@ -0,0 +1,5 @@ +define(['./lib1'], (function (libs) { 'use strict'; + + console.log(libs.value1, libs.value2$1); + +})); diff --git a/test/chunking-form/samples/allow-extension-exports-with-explicat-file-name/_expected/cjs/lib1.js b/test/chunking-form/samples/allow-extension-exports-with-explicat-file-name/_expected/cjs/lib1.js new file mode 100644 index 00000000000..f659fb2fef5 --- /dev/null +++ b/test/chunking-form/samples/allow-extension-exports-with-explicat-file-name/_expected/cjs/lib1.js @@ -0,0 +1,9 @@ +'use strict'; + +const value1 = 'lib1-value'; + +const value2 = 'lib2-value'; + +exports.value1 = value1; +exports.value2 = value2; +exports.value2$1 = value2; diff --git a/test/chunking-form/samples/allow-extension-exports-with-explicat-file-name/_expected/cjs/lib2.js b/test/chunking-form/samples/allow-extension-exports-with-explicat-file-name/_expected/cjs/lib2.js new file mode 100644 index 00000000000..3576427aecd --- /dev/null +++ b/test/chunking-form/samples/allow-extension-exports-with-explicat-file-name/_expected/cjs/lib2.js @@ -0,0 +1,7 @@ +'use strict'; + +var libs = require('./lib1.js'); + + + +exports.value2 = libs.value2$1; diff --git a/test/chunking-form/samples/allow-extension-exports-with-explicat-file-name/_expected/cjs/main.js b/test/chunking-form/samples/allow-extension-exports-with-explicat-file-name/_expected/cjs/main.js new file mode 100644 index 00000000000..69e27c493ef --- /dev/null +++ b/test/chunking-form/samples/allow-extension-exports-with-explicat-file-name/_expected/cjs/main.js @@ -0,0 +1,5 @@ +'use strict'; + +var libs = require('./lib1.js'); + +console.log(libs.value1, libs.value2$1); diff --git a/test/chunking-form/samples/allow-extension-exports-with-explicat-file-name/_expected/es/lib1.js b/test/chunking-form/samples/allow-extension-exports-with-explicat-file-name/_expected/es/lib1.js new file mode 100644 index 00000000000..408aaa1b749 --- /dev/null +++ b/test/chunking-form/samples/allow-extension-exports-with-explicat-file-name/_expected/es/lib1.js @@ -0,0 +1,5 @@ +const value1 = 'lib1-value'; + +const value2 = 'lib2-value'; + +export { value2 as v, value1, value2 }; diff --git a/test/chunking-form/samples/allow-extension-exports-with-explicat-file-name/_expected/es/lib2.js b/test/chunking-form/samples/allow-extension-exports-with-explicat-file-name/_expected/es/lib2.js new file mode 100644 index 00000000000..91f82db042a --- /dev/null +++ b/test/chunking-form/samples/allow-extension-exports-with-explicat-file-name/_expected/es/lib2.js @@ -0,0 +1 @@ +export { v as value2 } from './lib1.js'; diff --git a/test/chunking-form/samples/allow-extension-exports-with-explicat-file-name/_expected/es/main.js b/test/chunking-form/samples/allow-extension-exports-with-explicat-file-name/_expected/es/main.js new file mode 100644 index 00000000000..4f6129c18b7 --- /dev/null +++ b/test/chunking-form/samples/allow-extension-exports-with-explicat-file-name/_expected/es/main.js @@ -0,0 +1,3 @@ +import { value1, v as value2 } from './lib1.js'; + +console.log(value1, value2); diff --git a/test/chunking-form/samples/allow-extension-exports-with-explicat-file-name/_expected/system/lib1.js b/test/chunking-form/samples/allow-extension-exports-with-explicat-file-name/_expected/system/lib1.js new file mode 100644 index 00000000000..90e55279b8a --- /dev/null +++ b/test/chunking-form/samples/allow-extension-exports-with-explicat-file-name/_expected/system/lib1.js @@ -0,0 +1,12 @@ +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + + const value1 = exports("value1", 'lib1-value'); + + const value2 = exports("v", 'lib2-value'); + + }) + }; +})); diff --git a/test/chunking-form/samples/allow-extension-exports-with-explicat-file-name/_expected/system/lib2.js b/test/chunking-form/samples/allow-extension-exports-with-explicat-file-name/_expected/system/lib2.js new file mode 100644 index 00000000000..1a3313c5f8c --- /dev/null +++ b/test/chunking-form/samples/allow-extension-exports-with-explicat-file-name/_expected/system/lib2.js @@ -0,0 +1,13 @@ +System.register(['./lib1.js'], (function (exports) { + 'use strict'; + return { + setters: [function (module) { + exports("value2", module.v); + }], + execute: (function () { + + + + }) + }; +})); diff --git a/test/chunking-form/samples/allow-extension-exports-with-explicat-file-name/_expected/system/main.js b/test/chunking-form/samples/allow-extension-exports-with-explicat-file-name/_expected/system/main.js new file mode 100644 index 00000000000..265bfeca6a1 --- /dev/null +++ b/test/chunking-form/samples/allow-extension-exports-with-explicat-file-name/_expected/system/main.js @@ -0,0 +1,15 @@ +System.register(['./lib1.js'], (function () { + 'use strict'; + var value1, value2; + return { + setters: [function (module) { + value1 = module.value1; + value2 = module.v; + }], + execute: (function () { + + console.log(value1, value2); + + }) + }; +})); diff --git a/test/chunking-form/samples/allow-extension-exports-with-explicat-file-name/lib1.js b/test/chunking-form/samples/allow-extension-exports-with-explicat-file-name/lib1.js new file mode 100644 index 00000000000..fb5c9197083 --- /dev/null +++ b/test/chunking-form/samples/allow-extension-exports-with-explicat-file-name/lib1.js @@ -0,0 +1 @@ +export const value1 = 'lib1-value'; \ No newline at end of file diff --git a/test/chunking-form/samples/allow-extension-exports-with-explicat-file-name/lib2.js b/test/chunking-form/samples/allow-extension-exports-with-explicat-file-name/lib2.js new file mode 100644 index 00000000000..b6e333890ab --- /dev/null +++ b/test/chunking-form/samples/allow-extension-exports-with-explicat-file-name/lib2.js @@ -0,0 +1 @@ +export const value2 = 'lib2-value'; diff --git a/test/chunking-form/samples/allow-extension-exports-with-explicat-file-name/main.js b/test/chunking-form/samples/allow-extension-exports-with-explicat-file-name/main.js new file mode 100644 index 00000000000..3aa9aea4e9a --- /dev/null +++ b/test/chunking-form/samples/allow-extension-exports-with-explicat-file-name/main.js @@ -0,0 +1,4 @@ +import { value1 } from './lib1.js'; +import { value2 } from './lib2.js'; + +console.log(value1, value2); diff --git a/test/chunking-form/samples/allow-extension-exports-with-explicat-name-In-input-options/_config.js b/test/chunking-form/samples/allow-extension-exports-with-explicat-name-In-input-options/_config.js new file mode 100644 index 00000000000..97006aa2524 --- /dev/null +++ b/test/chunking-form/samples/allow-extension-exports-with-explicat-name-In-input-options/_config.js @@ -0,0 +1,10 @@ +module.exports = defineTest({ + description: 'generate a separate chunk for the entry module with explicit name in input options', + options: { + input: { + main: './main.js', + otherEntry: './otherEntry.js' + }, + preserveEntrySignatures: 'allow-extension' + } +}); diff --git a/test/chunking-form/samples/allow-extension-exports-with-explicat-name-In-input-options/_expected/amd/main.js b/test/chunking-form/samples/allow-extension-exports-with-explicat-name-In-input-options/_expected/amd/main.js new file mode 100644 index 00000000000..ec3923cef36 --- /dev/null +++ b/test/chunking-form/samples/allow-extension-exports-with-explicat-name-In-input-options/_expected/amd/main.js @@ -0,0 +1,7 @@ +define(['exports', './otherEntry'], (function (exports, otherEntry) { 'use strict'; + + + + exports.fooInOtherEntry = otherEntry.fooInOtherEntry; + +})); diff --git a/test/chunking-form/samples/allow-extension-exports-with-explicat-name-In-input-options/_expected/amd/otherEntry.js b/test/chunking-form/samples/allow-extension-exports-with-explicat-name-In-input-options/_expected/amd/otherEntry.js new file mode 100644 index 00000000000..def11b13a46 --- /dev/null +++ b/test/chunking-form/samples/allow-extension-exports-with-explicat-name-In-input-options/_expected/amd/otherEntry.js @@ -0,0 +1,9 @@ +define(['exports'], (function (exports) { 'use strict'; + + function fooInOtherEntry() { + console.log('hello world'); + } + + exports.fooInOtherEntry = fooInOtherEntry; + +})); diff --git a/test/chunking-form/samples/allow-extension-exports-with-explicat-name-In-input-options/_expected/cjs/main.js b/test/chunking-form/samples/allow-extension-exports-with-explicat-name-In-input-options/_expected/cjs/main.js new file mode 100644 index 00000000000..b12d6f0dcb4 --- /dev/null +++ b/test/chunking-form/samples/allow-extension-exports-with-explicat-name-In-input-options/_expected/cjs/main.js @@ -0,0 +1,7 @@ +'use strict'; + +var otherEntry = require('./otherEntry.js'); + + + +exports.fooInOtherEntry = otherEntry.fooInOtherEntry; diff --git a/test/chunking-form/samples/allow-extension-exports-with-explicat-name-In-input-options/_expected/cjs/otherEntry.js b/test/chunking-form/samples/allow-extension-exports-with-explicat-name-In-input-options/_expected/cjs/otherEntry.js new file mode 100644 index 00000000000..5d539880a4c --- /dev/null +++ b/test/chunking-form/samples/allow-extension-exports-with-explicat-name-In-input-options/_expected/cjs/otherEntry.js @@ -0,0 +1,7 @@ +'use strict'; + +function fooInOtherEntry() { + console.log('hello world'); +} + +exports.fooInOtherEntry = fooInOtherEntry; diff --git a/test/chunking-form/samples/allow-extension-exports-with-explicat-name-In-input-options/_expected/es/main.js b/test/chunking-form/samples/allow-extension-exports-with-explicat-name-In-input-options/_expected/es/main.js new file mode 100644 index 00000000000..78cf7bd89cd --- /dev/null +++ b/test/chunking-form/samples/allow-extension-exports-with-explicat-name-In-input-options/_expected/es/main.js @@ -0,0 +1 @@ +export { fooInOtherEntry } from './otherEntry.js'; diff --git a/test/chunking-form/samples/allow-extension-exports-with-explicat-name-In-input-options/_expected/es/otherEntry.js b/test/chunking-form/samples/allow-extension-exports-with-explicat-name-In-input-options/_expected/es/otherEntry.js new file mode 100644 index 00000000000..54283657ca5 --- /dev/null +++ b/test/chunking-form/samples/allow-extension-exports-with-explicat-name-In-input-options/_expected/es/otherEntry.js @@ -0,0 +1,5 @@ +function fooInOtherEntry() { + console.log('hello world'); +} + +export { fooInOtherEntry }; diff --git a/test/chunking-form/samples/allow-extension-exports-with-explicat-name-In-input-options/_expected/system/main.js b/test/chunking-form/samples/allow-extension-exports-with-explicat-name-In-input-options/_expected/system/main.js new file mode 100644 index 00000000000..a4a8ff6ad0c --- /dev/null +++ b/test/chunking-form/samples/allow-extension-exports-with-explicat-name-In-input-options/_expected/system/main.js @@ -0,0 +1,13 @@ +System.register(['./otherEntry.js'], (function (exports) { + 'use strict'; + return { + setters: [function (module) { + exports("fooInOtherEntry", module.fooInOtherEntry); + }], + execute: (function () { + + + + }) + }; +})); diff --git a/test/chunking-form/samples/allow-extension-exports-with-explicat-name-In-input-options/_expected/system/otherEntry.js b/test/chunking-form/samples/allow-extension-exports-with-explicat-name-In-input-options/_expected/system/otherEntry.js new file mode 100644 index 00000000000..02be0f24eec --- /dev/null +++ b/test/chunking-form/samples/allow-extension-exports-with-explicat-name-In-input-options/_expected/system/otherEntry.js @@ -0,0 +1,14 @@ +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + + exports("fooInOtherEntry", fooInOtherEntry); + + function fooInOtherEntry() { + console.log('hello world'); + } + + }) + }; +})); diff --git a/test/chunking-form/samples/allow-extension-exports-with-explicat-name-In-input-options/main.js b/test/chunking-form/samples/allow-extension-exports-with-explicat-name-In-input-options/main.js new file mode 100644 index 00000000000..ad6e369f080 --- /dev/null +++ b/test/chunking-form/samples/allow-extension-exports-with-explicat-name-In-input-options/main.js @@ -0,0 +1 @@ +export { fooInOtherEntry } from './otherEntry'; diff --git a/test/chunking-form/samples/allow-extension-exports-with-explicat-name-In-input-options/otherEntry.js b/test/chunking-form/samples/allow-extension-exports-with-explicat-name-In-input-options/otherEntry.js new file mode 100644 index 00000000000..d68580912e1 --- /dev/null +++ b/test/chunking-form/samples/allow-extension-exports-with-explicat-name-In-input-options/otherEntry.js @@ -0,0 +1,3 @@ +export function fooInOtherEntry() { + console.log('hello world'); +} diff --git a/test/chunking-form/samples/allow-extension-exports/_config.js b/test/chunking-form/samples/allow-extension-exports/_config.js new file mode 100644 index 00000000000..70a6d0df965 --- /dev/null +++ b/test/chunking-form/samples/allow-extension-exports/_config.js @@ -0,0 +1,22 @@ +const preserveSignature = 'allow-extension'; +module.exports = defineTest({ + description: 'preserves exports for modules with allow-extension signature', + options: { + input: 'main', + output: { + manualChunks: { + libs: ['lib1', 'lib2', 'lib3'] + } + }, + plugins: [ + { + name: 'allow-extension-plugin', + buildStart() { + this.emitFile({ type: 'chunk', id: 'lib1', preserveSignature }); + this.emitFile({ type: 'chunk', id: 'lib2', preserveSignature }); + this.emitFile({ type: 'chunk', id: 'lib3', preserveSignature }); + } + } + ] + } +}); diff --git a/test/chunking-form/samples/allow-extension-exports/_expected/amd/generated-lib1.js b/test/chunking-form/samples/allow-extension-exports/_expected/amd/generated-lib1.js new file mode 100644 index 00000000000..70c9921b74d --- /dev/null +++ b/test/chunking-form/samples/allow-extension-exports/_expected/amd/generated-lib1.js @@ -0,0 +1,24 @@ +define(['exports'], (function (exports) { 'use strict'; + + // This should be included directly in the chunk with preserved exports + const value1$1 = 'lib1-value'; + + // This will have conflicting exports and need a facade + const value2 = 'lib2-value'; + const value1 = 'conflict-value'; // Conflicting name + + // This should be included directly in the chunk with preserved exports + const value3 = 'lib3-value'; + + var lib3 = /*#__PURE__*/Object.freeze({ + __proto__: null, + value3: value3 + }); + + exports.lib3 = lib3; + exports.value1 = value1$1; + exports.value1$1 = value1; + exports.value2 = value2; + exports.value3 = value3; + +})); diff --git a/test/chunking-form/samples/allow-extension-exports/_expected/amd/generated-lib2.js b/test/chunking-form/samples/allow-extension-exports/_expected/amd/generated-lib2.js new file mode 100644 index 00000000000..c6351f0c9d1 --- /dev/null +++ b/test/chunking-form/samples/allow-extension-exports/_expected/amd/generated-lib2.js @@ -0,0 +1,8 @@ +define(['exports', './generated-lib1'], (function (exports, libs) { 'use strict'; + + + + exports.value1 = libs.value1$1; + exports.value2 = libs.value2; + +})); diff --git a/test/chunking-form/samples/allow-extension-exports/_expected/amd/main.js b/test/chunking-form/samples/allow-extension-exports/_expected/amd/main.js new file mode 100644 index 00000000000..ca3452ab302 --- /dev/null +++ b/test/chunking-form/samples/allow-extension-exports/_expected/amd/main.js @@ -0,0 +1,8 @@ +define(['require', './generated-lib1'], (function (require, libs) { 'use strict'; + + console.log(libs.value1); + console.log(libs.value1$1); + console.log(libs.value2); + console.log(new Promise(function (resolve, reject) { require(['./generated-lib1'], resolve, reject); }).then(function (n) { return n.lib3; }).then(m => m.value3)); + +})); diff --git a/test/chunking-form/samples/allow-extension-exports/_expected/cjs/generated-lib1.js b/test/chunking-form/samples/allow-extension-exports/_expected/cjs/generated-lib1.js new file mode 100644 index 00000000000..75981f882e8 --- /dev/null +++ b/test/chunking-form/samples/allow-extension-exports/_expected/cjs/generated-lib1.js @@ -0,0 +1,22 @@ +'use strict'; + +// This should be included directly in the chunk with preserved exports +const value1$1 = 'lib1-value'; + +// This will have conflicting exports and need a facade +const value2 = 'lib2-value'; +const value1 = 'conflict-value'; // Conflicting name + +// This should be included directly in the chunk with preserved exports +const value3 = 'lib3-value'; + +var lib3 = /*#__PURE__*/Object.freeze({ + __proto__: null, + value3: value3 +}); + +exports.lib3 = lib3; +exports.value1 = value1$1; +exports.value1$1 = value1; +exports.value2 = value2; +exports.value3 = value3; diff --git a/test/chunking-form/samples/allow-extension-exports/_expected/cjs/generated-lib2.js b/test/chunking-form/samples/allow-extension-exports/_expected/cjs/generated-lib2.js new file mode 100644 index 00000000000..7b5a346c254 --- /dev/null +++ b/test/chunking-form/samples/allow-extension-exports/_expected/cjs/generated-lib2.js @@ -0,0 +1,8 @@ +'use strict'; + +var libs = require('./generated-lib1.js'); + + + +exports.value1 = libs.value1$1; +exports.value2 = libs.value2; diff --git a/test/chunking-form/samples/allow-extension-exports/_expected/cjs/main.js b/test/chunking-form/samples/allow-extension-exports/_expected/cjs/main.js new file mode 100644 index 00000000000..cdf75a0d93e --- /dev/null +++ b/test/chunking-form/samples/allow-extension-exports/_expected/cjs/main.js @@ -0,0 +1,8 @@ +'use strict'; + +var libs = require('./generated-lib1.js'); + +console.log(libs.value1); +console.log(libs.value1$1); +console.log(libs.value2); +console.log(Promise.resolve().then(function () { return require('./generated-lib1.js'); }).then(function (n) { return n.lib3; }).then(m => m.value3)); diff --git a/test/chunking-form/samples/allow-extension-exports/_expected/es/generated-lib1.js b/test/chunking-form/samples/allow-extension-exports/_expected/es/generated-lib1.js new file mode 100644 index 00000000000..e97a5489fb7 --- /dev/null +++ b/test/chunking-form/samples/allow-extension-exports/_expected/es/generated-lib1.js @@ -0,0 +1,16 @@ +// This should be included directly in the chunk with preserved exports +const value1$1 = 'lib1-value'; + +// This will have conflicting exports and need a facade +const value2 = 'lib2-value'; +const value1 = 'conflict-value'; // Conflicting name + +// This should be included directly in the chunk with preserved exports +const value3 = 'lib3-value'; + +var lib3 = /*#__PURE__*/Object.freeze({ + __proto__: null, + value3: value3 +}); + +export { value2 as a, lib3 as l, value1 as v, value1$1 as value1, value3 }; diff --git a/test/chunking-form/samples/allow-extension-exports/_expected/es/generated-lib2.js b/test/chunking-form/samples/allow-extension-exports/_expected/es/generated-lib2.js new file mode 100644 index 00000000000..e9fd4de6241 --- /dev/null +++ b/test/chunking-form/samples/allow-extension-exports/_expected/es/generated-lib2.js @@ -0,0 +1 @@ +export { v as value1, a as value2 } from './generated-lib1.js'; diff --git a/test/chunking-form/samples/allow-extension-exports/_expected/es/main.js b/test/chunking-form/samples/allow-extension-exports/_expected/es/main.js new file mode 100644 index 00000000000..2f7a3c4137a --- /dev/null +++ b/test/chunking-form/samples/allow-extension-exports/_expected/es/main.js @@ -0,0 +1,6 @@ +import { value1, v as value1$1, a as value2 } from './generated-lib1.js'; + +console.log(value1); +console.log(value1$1); +console.log(value2); +console.log(import('./generated-lib1.js').then(function (n) { return n.l; }).then(m => m.value3)); diff --git a/test/chunking-form/samples/allow-extension-exports/_expected/system/generated-lib1.js b/test/chunking-form/samples/allow-extension-exports/_expected/system/generated-lib1.js new file mode 100644 index 00000000000..dbf53fc9106 --- /dev/null +++ b/test/chunking-form/samples/allow-extension-exports/_expected/system/generated-lib1.js @@ -0,0 +1,24 @@ +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + + // This should be included directly in the chunk with preserved exports + const value1$1 = exports("value1", 'lib1-value'); + + // This will have conflicting exports and need a facade + const value2 = exports("a", 'lib2-value'); + const value1 = exports("v", 'conflict-value'); // Conflicting name + + // This should be included directly in the chunk with preserved exports + const value3 = exports("value3", 'lib3-value'); + + var lib3 = /*#__PURE__*/Object.freeze({ + __proto__: null, + value3: value3 + }); + exports("l", lib3); + + }) + }; +})); diff --git a/test/chunking-form/samples/allow-extension-exports/_expected/system/generated-lib2.js b/test/chunking-form/samples/allow-extension-exports/_expected/system/generated-lib2.js new file mode 100644 index 00000000000..abe11b843b3 --- /dev/null +++ b/test/chunking-form/samples/allow-extension-exports/_expected/system/generated-lib2.js @@ -0,0 +1,13 @@ +System.register(['./generated-lib1.js'], (function (exports) { + 'use strict'; + return { + setters: [function (module) { + exports({ value1: module.v, value2: module.a }); + }], + execute: (function () { + + + + }) + }; +})); diff --git a/test/chunking-form/samples/allow-extension-exports/_expected/system/main.js b/test/chunking-form/samples/allow-extension-exports/_expected/system/main.js new file mode 100644 index 00000000000..766e17f008d --- /dev/null +++ b/test/chunking-form/samples/allow-extension-exports/_expected/system/main.js @@ -0,0 +1,19 @@ +System.register(['./generated-lib1.js'], (function (exports, module) { + 'use strict'; + var value1, value1$1, value2; + return { + setters: [function (module) { + value1 = module.value1; + value1$1 = module.v; + value2 = module.a; + }], + execute: (function () { + + console.log(value1); + console.log(value1$1); + console.log(value2); + console.log(module.import('./generated-lib1.js').then(function (n) { return n.l; }).then(m => m.value3)); + + }) + }; +})); diff --git a/test/chunking-form/samples/allow-extension-exports/lib1.js b/test/chunking-form/samples/allow-extension-exports/lib1.js new file mode 100644 index 00000000000..b4dc8825354 --- /dev/null +++ b/test/chunking-form/samples/allow-extension-exports/lib1.js @@ -0,0 +1,2 @@ +// This should be included directly in the chunk with preserved exports +export const value1 = 'lib1-value'; diff --git a/test/chunking-form/samples/allow-extension-exports/lib2.js b/test/chunking-form/samples/allow-extension-exports/lib2.js new file mode 100644 index 00000000000..b258eeac3d1 --- /dev/null +++ b/test/chunking-form/samples/allow-extension-exports/lib2.js @@ -0,0 +1,3 @@ +// This will have conflicting exports and need a facade +export const value2 = 'lib2-value'; +export const value1 = 'conflict-value'; // Conflicting name diff --git a/test/chunking-form/samples/allow-extension-exports/lib3.js b/test/chunking-form/samples/allow-extension-exports/lib3.js new file mode 100644 index 00000000000..4f01971f39b --- /dev/null +++ b/test/chunking-form/samples/allow-extension-exports/lib3.js @@ -0,0 +1,2 @@ +// This should be included directly in the chunk with preserved exports +export const value3 = 'lib3-value'; diff --git a/test/chunking-form/samples/allow-extension-exports/main.js b/test/chunking-form/samples/allow-extension-exports/main.js new file mode 100644 index 00000000000..6fb6193e5c4 --- /dev/null +++ b/test/chunking-form/samples/allow-extension-exports/main.js @@ -0,0 +1,7 @@ +import { value1 } from './lib1.js'; +import { value1 as v1, value2 } from './lib2.js'; + +console.log(value1); +console.log(v1); +console.log(value2); +console.log(import('./lib3.js').then(m => m.value3)); diff --git a/test/chunking-form/samples/allow-extension-merge-same-exports/_config.js b/test/chunking-form/samples/allow-extension-merge-same-exports/_config.js new file mode 100644 index 00000000000..5bf0c6293c3 --- /dev/null +++ b/test/chunking-form/samples/allow-extension-merge-same-exports/_config.js @@ -0,0 +1,21 @@ +const preserveSignature = 'allow-extension'; +module.exports = defineTest({ + description: 'merges same exports for modules with allow-extension signature', + options: { + input: 'main', + output: { + manualChunks: { + libs: ['lib1', 'lib2'] + } + }, + plugins: [ + { + name: 'allow-extension-plugin', + buildStart() { + this.emitFile({ type: 'chunk', id: 'lib1', preserveSignature }); + this.emitFile({ type: 'chunk', id: 'lib2', preserveSignature }); + } + } + ] + } +}); diff --git a/test/chunking-form/samples/allow-extension-merge-same-exports/_expected/amd/generated-lib1.js b/test/chunking-form/samples/allow-extension-merge-same-exports/_expected/amd/generated-lib1.js new file mode 100644 index 00000000000..7471994ab59 --- /dev/null +++ b/test/chunking-form/samples/allow-extension-merge-same-exports/_expected/amd/generated-lib1.js @@ -0,0 +1,13 @@ +define(['exports'], (function (exports) { 'use strict'; + + const bar = 'vendor-bar'; + + const value1 = 'lib1-value'; + + const value2 = 'lib2-value'; + + exports.bar = bar; + exports.value1 = value1; + exports.value2 = value2; + +})); diff --git a/test/chunking-form/samples/allow-extension-merge-same-exports/_expected/amd/main.js b/test/chunking-form/samples/allow-extension-merge-same-exports/_expected/amd/main.js new file mode 100644 index 00000000000..f1431baa915 --- /dev/null +++ b/test/chunking-form/samples/allow-extension-merge-same-exports/_expected/amd/main.js @@ -0,0 +1,8 @@ +define(['./generated-lib1'], (function (libs) { 'use strict'; + + console.log(libs.value1); + console.log(libs.bar); + console.log(libs.value2); + console.log(libs.bar); + +})); diff --git a/test/chunking-form/samples/allow-extension-merge-same-exports/_expected/cjs/generated-lib1.js b/test/chunking-form/samples/allow-extension-merge-same-exports/_expected/cjs/generated-lib1.js new file mode 100644 index 00000000000..bb5e2887a04 --- /dev/null +++ b/test/chunking-form/samples/allow-extension-merge-same-exports/_expected/cjs/generated-lib1.js @@ -0,0 +1,11 @@ +'use strict'; + +const bar = 'vendor-bar'; + +const value1 = 'lib1-value'; + +const value2 = 'lib2-value'; + +exports.bar = bar; +exports.value1 = value1; +exports.value2 = value2; diff --git a/test/chunking-form/samples/allow-extension-merge-same-exports/_expected/cjs/main.js b/test/chunking-form/samples/allow-extension-merge-same-exports/_expected/cjs/main.js new file mode 100644 index 00000000000..979bbc6373d --- /dev/null +++ b/test/chunking-form/samples/allow-extension-merge-same-exports/_expected/cjs/main.js @@ -0,0 +1,8 @@ +'use strict'; + +var libs = require('./generated-lib1.js'); + +console.log(libs.value1); +console.log(libs.bar); +console.log(libs.value2); +console.log(libs.bar); diff --git a/test/chunking-form/samples/allow-extension-merge-same-exports/_expected/es/generated-lib1.js b/test/chunking-form/samples/allow-extension-merge-same-exports/_expected/es/generated-lib1.js new file mode 100644 index 00000000000..3e64bffd74f --- /dev/null +++ b/test/chunking-form/samples/allow-extension-merge-same-exports/_expected/es/generated-lib1.js @@ -0,0 +1,7 @@ +const bar = 'vendor-bar'; + +const value1 = 'lib1-value'; + +const value2 = 'lib2-value'; + +export { bar, value1, value2 }; diff --git a/test/chunking-form/samples/allow-extension-merge-same-exports/_expected/es/main.js b/test/chunking-form/samples/allow-extension-merge-same-exports/_expected/es/main.js new file mode 100644 index 00000000000..be8a98e80da --- /dev/null +++ b/test/chunking-form/samples/allow-extension-merge-same-exports/_expected/es/main.js @@ -0,0 +1,6 @@ +import { value1, bar, value2 } from './generated-lib1.js'; + +console.log(value1); +console.log(bar); +console.log(value2); +console.log(bar); diff --git a/test/chunking-form/samples/allow-extension-merge-same-exports/_expected/system/generated-lib1.js b/test/chunking-form/samples/allow-extension-merge-same-exports/_expected/system/generated-lib1.js new file mode 100644 index 00000000000..e4ec9e5880c --- /dev/null +++ b/test/chunking-form/samples/allow-extension-merge-same-exports/_expected/system/generated-lib1.js @@ -0,0 +1,14 @@ +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + + const bar = exports("bar", 'vendor-bar'); + + const value1 = exports("value1", 'lib1-value'); + + const value2 = exports("value2", 'lib2-value'); + + }) + }; +})); diff --git a/test/chunking-form/samples/allow-extension-merge-same-exports/_expected/system/main.js b/test/chunking-form/samples/allow-extension-merge-same-exports/_expected/system/main.js new file mode 100644 index 00000000000..ca21ed3d27d --- /dev/null +++ b/test/chunking-form/samples/allow-extension-merge-same-exports/_expected/system/main.js @@ -0,0 +1,19 @@ +System.register(['./generated-lib1.js'], (function () { + 'use strict'; + var value1, bar, value2; + return { + setters: [function (module) { + value1 = module.value1; + bar = module.bar; + value2 = module.value2; + }], + execute: (function () { + + console.log(value1); + console.log(bar); + console.log(value2); + console.log(bar); + + }) + }; +})); diff --git a/test/chunking-form/samples/allow-extension-merge-same-exports/lib1.js b/test/chunking-form/samples/allow-extension-merge-same-exports/lib1.js new file mode 100644 index 00000000000..92682195999 --- /dev/null +++ b/test/chunking-form/samples/allow-extension-merge-same-exports/lib1.js @@ -0,0 +1,2 @@ +export const value1 = 'lib1-value'; +export { bar } from './vendor.js'; diff --git a/test/chunking-form/samples/allow-extension-merge-same-exports/lib2.js b/test/chunking-form/samples/allow-extension-merge-same-exports/lib2.js new file mode 100644 index 00000000000..827994c64ca --- /dev/null +++ b/test/chunking-form/samples/allow-extension-merge-same-exports/lib2.js @@ -0,0 +1,2 @@ +export const value2 = 'lib2-value'; +export { bar } from './vendor.js'; diff --git a/test/chunking-form/samples/allow-extension-merge-same-exports/main.js b/test/chunking-form/samples/allow-extension-merge-same-exports/main.js new file mode 100644 index 00000000000..da694c1d544 --- /dev/null +++ b/test/chunking-form/samples/allow-extension-merge-same-exports/main.js @@ -0,0 +1,7 @@ +import { bar as b1, value1 } from './lib1.js'; +import { bar as b2, value2 } from './lib2.js'; + +console.log(value1); +console.log(b1); +console.log(value2); +console.log(b2); diff --git a/test/chunking-form/samples/allow-extension-merge-same-exports/vendor.js b/test/chunking-form/samples/allow-extension-merge-same-exports/vendor.js new file mode 100644 index 00000000000..89c28a3a47c --- /dev/null +++ b/test/chunking-form/samples/allow-extension-merge-same-exports/vendor.js @@ -0,0 +1 @@ +export const bar = 'vendor-bar'; diff --git a/test/chunking-form/samples/amd-id-auto-base-path-concat/_config.js b/test/chunking-form/samples/amd-id-auto-base-path-concat/_config.js index 754ccbcbd10..34581fa6241 100644 --- a/test/chunking-form/samples/amd-id-auto-base-path-concat/_config.js +++ b/test/chunking-form/samples/amd-id-auto-base-path-concat/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: "allows to use amd.autoId with amd.basePath and works when concat'd into one file", options: { input: ['main'], @@ -31,4 +31,4 @@ module.exports = { return exports.getA(); } } -}; +}); diff --git a/test/chunking-form/samples/amd-id-auto-base-path-concat/_expected/amd/some/where/main.js b/test/chunking-form/samples/amd-id-auto-base-path-concat/_expected/amd/some/where/main.js index d885e74cbf4..6aef214406d 100644 --- a/test/chunking-form/samples/amd-id-auto-base-path-concat/_expected/amd/some/where/main.js +++ b/test/chunking-form/samples/amd-id-auto-base-path-concat/_expected/amd/some/where/main.js @@ -1,19 +1,17 @@ -define('some/where/main', ['require', 'exports'], function (require, exports) { 'use strict'; +define('some/where/main', ['require', 'exports'], (function (require, exports) { 'use strict'; function getA() { - return new Promise(function (resolve, reject) { require(['./generated-a'], resolve, reject) }); + return new Promise(function (resolve, reject) { require(['./generated-a'], resolve, reject); }); } exports.getA = getA; - Object.defineProperty(exports, '__esModule', { value: true }); +})); -}); - -define('some/where/generated-a', ['exports'], function (exports) { 'use strict'; +define('some/where/generated-a', ['exports'], (function (exports) { 'use strict'; const something = 42; exports.something = something; -}); +})); diff --git a/test/chunking-form/samples/amd-id-auto-base-path-concat/_expected/cjs/some/where/main.js b/test/chunking-form/samples/amd-id-auto-base-path-concat/_expected/cjs/some/where/main.js index 9fb4e75ab81..90dfebf79be 100644 --- a/test/chunking-form/samples/amd-id-auto-base-path-concat/_expected/cjs/some/where/main.js +++ b/test/chunking-form/samples/amd-id-auto-base-path-concat/_expected/cjs/some/where/main.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - function getA() { return Promise.resolve().then(function () { return require('./generated-a.js'); }); } diff --git a/test/chunking-form/samples/amd-id-auto-base-path-concat/_expected/system/some/where/generated-a.js b/test/chunking-form/samples/amd-id-auto-base-path-concat/_expected/system/some/where/generated-a.js index 88194588de1..4da5e1795b1 100644 --- a/test/chunking-form/samples/amd-id-auto-base-path-concat/_expected/system/some/where/generated-a.js +++ b/test/chunking-form/samples/amd-id-auto-base-path-concat/_expected/system/some/where/generated-a.js @@ -1,10 +1,10 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - const something = exports('something', 42); + const something = exports("something", 42); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/amd-id-auto-base-path-concat/_expected/system/some/where/main.js b/test/chunking-form/samples/amd-id-auto-base-path-concat/_expected/system/some/where/main.js index d3d68f9de5c..4de2af2f3a9 100644 --- a/test/chunking-form/samples/amd-id-auto-base-path-concat/_expected/system/some/where/main.js +++ b/test/chunking-form/samples/amd-id-auto-base-path-concat/_expected/system/some/where/main.js @@ -1,14 +1,14 @@ -System.register([], function (exports, module) { +System.register([], (function (exports, module) { 'use strict'; return { - execute: function () { + execute: (function () { - exports('getA', getA); + exports("getA", getA); function getA() { return module.import('./generated-a.js'); } - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/amd-id-auto-base-path/_config.js b/test/chunking-form/samples/amd-id-auto-base-path/_config.js index f8158e4cd6a..9e49a70026b 100644 --- a/test/chunking-form/samples/amd-id-auto-base-path/_config.js +++ b/test/chunking-form/samples/amd-id-auto-base-path/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'allows to use amd.autoId with amd.basePath, and chunks folder', options: { input: ['main'], @@ -16,4 +16,4 @@ module.exports = { return exports.getA(); } } -}; +}); diff --git a/test/chunking-form/samples/amd-id-auto-base-path/_expected/amd/some/where/chunks/generated-a.js b/test/chunking-form/samples/amd-id-auto-base-path/_expected/amd/some/where/chunks/generated-a.js index 9f558a6da87..b9160771754 100644 --- a/test/chunking-form/samples/amd-id-auto-base-path/_expected/amd/some/where/chunks/generated-a.js +++ b/test/chunking-form/samples/amd-id-auto-base-path/_expected/amd/some/where/chunks/generated-a.js @@ -1,7 +1,7 @@ -define('some/where/chunks/generated-a', ['exports'], function (exports) { 'use strict'; +define('some/where/chunks/generated-a', ['exports'], (function (exports) { 'use strict'; const something = 42; exports.something = something; -}); +})); diff --git a/test/chunking-form/samples/amd-id-auto-base-path/_expected/amd/some/where/main.js b/test/chunking-form/samples/amd-id-auto-base-path/_expected/amd/some/where/main.js index e45e31f7b87..5fa585eca08 100644 --- a/test/chunking-form/samples/amd-id-auto-base-path/_expected/amd/some/where/main.js +++ b/test/chunking-form/samples/amd-id-auto-base-path/_expected/amd/some/where/main.js @@ -1,11 +1,9 @@ -define('some/where/main', ['require', 'exports'], function (require, exports) { 'use strict'; +define('some/where/main', ['require', 'exports'], (function (require, exports) { 'use strict'; function getA() { - return new Promise(function (resolve, reject) { require(['./chunks/generated-a'], resolve, reject) }); + return new Promise(function (resolve, reject) { require(['./chunks/generated-a'], resolve, reject); }); } exports.getA = getA; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/amd-id-auto-base-path/_expected/cjs/some/where/main.js b/test/chunking-form/samples/amd-id-auto-base-path/_expected/cjs/some/where/main.js index ec865e5ed72..a413360c169 100644 --- a/test/chunking-form/samples/amd-id-auto-base-path/_expected/cjs/some/where/main.js +++ b/test/chunking-form/samples/amd-id-auto-base-path/_expected/cjs/some/where/main.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - function getA() { return Promise.resolve().then(function () { return require('./chunks/generated-a.js'); }); } diff --git a/test/chunking-form/samples/amd-id-auto-base-path/_expected/system/some/where/chunks/generated-a.js b/test/chunking-form/samples/amd-id-auto-base-path/_expected/system/some/where/chunks/generated-a.js index 88194588de1..4da5e1795b1 100644 --- a/test/chunking-form/samples/amd-id-auto-base-path/_expected/system/some/where/chunks/generated-a.js +++ b/test/chunking-form/samples/amd-id-auto-base-path/_expected/system/some/where/chunks/generated-a.js @@ -1,10 +1,10 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - const something = exports('something', 42); + const something = exports("something", 42); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/amd-id-auto-base-path/_expected/system/some/where/main.js b/test/chunking-form/samples/amd-id-auto-base-path/_expected/system/some/where/main.js index 4f171309bf6..cf4bdf09f31 100644 --- a/test/chunking-form/samples/amd-id-auto-base-path/_expected/system/some/where/main.js +++ b/test/chunking-form/samples/amd-id-auto-base-path/_expected/system/some/where/main.js @@ -1,14 +1,14 @@ -System.register([], function (exports, module) { +System.register([], (function (exports, module) { 'use strict'; return { - execute: function () { + execute: (function () { - exports('getA', getA); + exports("getA", getA); function getA() { return module.import('./chunks/generated-a.js'); } - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/amd-id-auto/_config.js b/test/chunking-form/samples/amd-id-auto/_config.js index e2ced9f0459..62dce8813f7 100644 --- a/test/chunking-form/samples/amd-id-auto/_config.js +++ b/test/chunking-form/samples/amd-id-auto/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'allows to use amd.autoId', options: { input: ['main'], @@ -13,4 +13,4 @@ module.exports = { return exports.getA(); } } -}; +}); diff --git a/test/chunking-form/samples/amd-id-auto/_expected/amd/generated-a.js b/test/chunking-form/samples/amd-id-auto/_expected/amd/generated-a.js index 0e008ab71bf..69adb865a3a 100644 --- a/test/chunking-form/samples/amd-id-auto/_expected/amd/generated-a.js +++ b/test/chunking-form/samples/amd-id-auto/_expected/amd/generated-a.js @@ -1,7 +1,7 @@ -define('generated-a', ['exports'], function (exports) { 'use strict'; +define('generated-a', ['exports'], (function (exports) { 'use strict'; const something = 42; exports.something = something; -}); +})); diff --git a/test/chunking-form/samples/amd-id-auto/_expected/amd/main.js b/test/chunking-form/samples/amd-id-auto/_expected/amd/main.js index ce58a18fd63..c1e974db3cb 100644 --- a/test/chunking-form/samples/amd-id-auto/_expected/amd/main.js +++ b/test/chunking-form/samples/amd-id-auto/_expected/amd/main.js @@ -1,11 +1,9 @@ -define('main', ['require', 'exports'], function (require, exports) { 'use strict'; +define('main', ['require', 'exports'], (function (require, exports) { 'use strict'; function getA() { - return new Promise(function (resolve, reject) { require(['./generated-a'], resolve, reject) }); + return new Promise(function (resolve, reject) { require(['./generated-a'], resolve, reject); }); } exports.getA = getA; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/amd-id-auto/_expected/cjs/main.js b/test/chunking-form/samples/amd-id-auto/_expected/cjs/main.js index 9fb4e75ab81..90dfebf79be 100644 --- a/test/chunking-form/samples/amd-id-auto/_expected/cjs/main.js +++ b/test/chunking-form/samples/amd-id-auto/_expected/cjs/main.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - function getA() { return Promise.resolve().then(function () { return require('./generated-a.js'); }); } diff --git a/test/chunking-form/samples/amd-id-auto/_expected/system/generated-a.js b/test/chunking-form/samples/amd-id-auto/_expected/system/generated-a.js index 88194588de1..4da5e1795b1 100644 --- a/test/chunking-form/samples/amd-id-auto/_expected/system/generated-a.js +++ b/test/chunking-form/samples/amd-id-auto/_expected/system/generated-a.js @@ -1,10 +1,10 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - const something = exports('something', 42); + const something = exports("something", 42); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/amd-id-auto/_expected/system/main.js b/test/chunking-form/samples/amd-id-auto/_expected/system/main.js index d3d68f9de5c..4de2af2f3a9 100644 --- a/test/chunking-form/samples/amd-id-auto/_expected/system/main.js +++ b/test/chunking-form/samples/amd-id-auto/_expected/system/main.js @@ -1,14 +1,14 @@ -System.register([], function (exports, module) { +System.register([], (function (exports, module) { 'use strict'; return { - execute: function () { + execute: (function () { - exports('getA', getA); + exports("getA", getA); function getA() { return module.import('./generated-a.js'); } - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/asset-needs-code-reference-same-source/_config.js b/test/chunking-form/samples/asset-needs-code-reference-same-source/_config.js new file mode 100644 index 00000000000..932e0a08294 --- /dev/null +++ b/test/chunking-form/samples/asset-needs-code-reference-same-source/_config.js @@ -0,0 +1,98 @@ +const assert = require('node:assert'); + +module.exports = defineTest({ + description: + 'emits unreferenced assets if needsCodeReference is true if they are also emitted without that flag', + options: { + output: { + assetFileNames: '[name][extname]' + }, + plugins: [ + { + name: 'test', + buildStart() { + this.emitFile({ + type: 'asset', + name: 'needs-reference1.txt', + needsCodeReference: true, + source: 'source1' + }); + this.emitFile({ + type: 'asset', + name: 'file1.txt', + source: 'source1' + }); + this.emitFile({ + type: 'asset', + name: 'file2.txt', + source: 'source2' + }); + this.emitFile({ + type: 'asset', + name: 'needs-reference2.txt', + needsCodeReference: true, + source: 'source2' + }); + this.emitFile({ + type: 'asset', + name: 'needs-reference3.txt', + needsCodeReference: true, + source: 'source3' + }); + this.emitFile({ + type: 'asset', + name: 'file4.txt', + source: 'source4' + }); + this.emitFile({ + type: 'asset', + name: 'needs-reference5.txt', + needsCodeReference: true, + source: 'source5' + }); + this.emitFile({ + type: 'asset', + name: 'file6.txt', + source: 'source6' + }); + }, + renderStart() { + this.emitFile({ + type: 'asset', + name: 'file3.txt', + source: 'source3' + }); + this.emitFile({ + type: 'asset', + name: 'needs-reference4.txt', + needsCodeReference: true, + source: 'source4' + }); + }, + generateBundle(_, bundle) { + this.emitFile({ + type: 'asset', + name: 'file5.txt', + source: 'source5' + }); + this.emitFile({ + type: 'asset', + name: 'needs-reference6.txt', + needsCodeReference: true, + source: 'source6' + }); + + assert.deepEqual(Object.keys(bundle).sort(), [ + 'file1.txt', + 'file2.txt', + 'file4.txt', + 'file6.txt', + 'main.js', + 'needs-reference3.txt', + 'needs-reference5.txt' + ]); + } + } + ] + } +}); diff --git a/test/chunking-form/samples/asset-needs-code-reference-same-source/_expected/amd/file1.txt b/test/chunking-form/samples/asset-needs-code-reference-same-source/_expected/amd/file1.txt new file mode 100644 index 00000000000..90607bb217b --- /dev/null +++ b/test/chunking-form/samples/asset-needs-code-reference-same-source/_expected/amd/file1.txt @@ -0,0 +1 @@ +source1 \ No newline at end of file diff --git a/test/chunking-form/samples/asset-needs-code-reference-same-source/_expected/amd/file2.txt b/test/chunking-form/samples/asset-needs-code-reference-same-source/_expected/amd/file2.txt new file mode 100644 index 00000000000..a1d2704e103 --- /dev/null +++ b/test/chunking-form/samples/asset-needs-code-reference-same-source/_expected/amd/file2.txt @@ -0,0 +1 @@ +source2 \ No newline at end of file diff --git a/test/chunking-form/samples/asset-needs-code-reference-same-source/_expected/amd/file4.txt b/test/chunking-form/samples/asset-needs-code-reference-same-source/_expected/amd/file4.txt new file mode 100644 index 00000000000..253dd032578 --- /dev/null +++ b/test/chunking-form/samples/asset-needs-code-reference-same-source/_expected/amd/file4.txt @@ -0,0 +1 @@ +source4 \ No newline at end of file diff --git a/test/chunking-form/samples/asset-needs-code-reference-same-source/_expected/amd/file6.txt b/test/chunking-form/samples/asset-needs-code-reference-same-source/_expected/amd/file6.txt new file mode 100644 index 00000000000..bbc84df5fe1 --- /dev/null +++ b/test/chunking-form/samples/asset-needs-code-reference-same-source/_expected/amd/file6.txt @@ -0,0 +1 @@ +source6 \ No newline at end of file diff --git a/test/chunking-form/samples/asset-needs-code-reference-same-source/_expected/amd/main.js b/test/chunking-form/samples/asset-needs-code-reference-same-source/_expected/amd/main.js new file mode 100644 index 00000000000..49540b44d78 --- /dev/null +++ b/test/chunking-form/samples/asset-needs-code-reference-same-source/_expected/amd/main.js @@ -0,0 +1,5 @@ +define((function () { 'use strict'; + + console.log('main'); + +})); diff --git a/test/chunking-form/samples/asset-needs-code-reference-same-source/_expected/amd/needs-reference3.txt b/test/chunking-form/samples/asset-needs-code-reference-same-source/_expected/amd/needs-reference3.txt new file mode 100644 index 00000000000..ab3070242e6 --- /dev/null +++ b/test/chunking-form/samples/asset-needs-code-reference-same-source/_expected/amd/needs-reference3.txt @@ -0,0 +1 @@ +source3 \ No newline at end of file diff --git a/test/chunking-form/samples/asset-needs-code-reference-same-source/_expected/amd/needs-reference5.txt b/test/chunking-form/samples/asset-needs-code-reference-same-source/_expected/amd/needs-reference5.txt new file mode 100644 index 00000000000..cfd9aaa7945 --- /dev/null +++ b/test/chunking-form/samples/asset-needs-code-reference-same-source/_expected/amd/needs-reference5.txt @@ -0,0 +1 @@ +source5 \ No newline at end of file diff --git a/test/chunking-form/samples/asset-needs-code-reference-same-source/_expected/cjs/file1.txt b/test/chunking-form/samples/asset-needs-code-reference-same-source/_expected/cjs/file1.txt new file mode 100644 index 00000000000..90607bb217b --- /dev/null +++ b/test/chunking-form/samples/asset-needs-code-reference-same-source/_expected/cjs/file1.txt @@ -0,0 +1 @@ +source1 \ No newline at end of file diff --git a/test/chunking-form/samples/asset-needs-code-reference-same-source/_expected/cjs/file2.txt b/test/chunking-form/samples/asset-needs-code-reference-same-source/_expected/cjs/file2.txt new file mode 100644 index 00000000000..a1d2704e103 --- /dev/null +++ b/test/chunking-form/samples/asset-needs-code-reference-same-source/_expected/cjs/file2.txt @@ -0,0 +1 @@ +source2 \ No newline at end of file diff --git a/test/chunking-form/samples/asset-needs-code-reference-same-source/_expected/cjs/file4.txt b/test/chunking-form/samples/asset-needs-code-reference-same-source/_expected/cjs/file4.txt new file mode 100644 index 00000000000..253dd032578 --- /dev/null +++ b/test/chunking-form/samples/asset-needs-code-reference-same-source/_expected/cjs/file4.txt @@ -0,0 +1 @@ +source4 \ No newline at end of file diff --git a/test/chunking-form/samples/asset-needs-code-reference-same-source/_expected/cjs/file6.txt b/test/chunking-form/samples/asset-needs-code-reference-same-source/_expected/cjs/file6.txt new file mode 100644 index 00000000000..bbc84df5fe1 --- /dev/null +++ b/test/chunking-form/samples/asset-needs-code-reference-same-source/_expected/cjs/file6.txt @@ -0,0 +1 @@ +source6 \ No newline at end of file diff --git a/test/form/samples/deprecated/emit-asset-hacky/_expected/cjs.js b/test/chunking-form/samples/asset-needs-code-reference-same-source/_expected/cjs/main.js similarity index 100% rename from test/form/samples/deprecated/emit-asset-hacky/_expected/cjs.js rename to test/chunking-form/samples/asset-needs-code-reference-same-source/_expected/cjs/main.js diff --git a/test/chunking-form/samples/asset-needs-code-reference-same-source/_expected/cjs/needs-reference3.txt b/test/chunking-form/samples/asset-needs-code-reference-same-source/_expected/cjs/needs-reference3.txt new file mode 100644 index 00000000000..ab3070242e6 --- /dev/null +++ b/test/chunking-form/samples/asset-needs-code-reference-same-source/_expected/cjs/needs-reference3.txt @@ -0,0 +1 @@ +source3 \ No newline at end of file diff --git a/test/chunking-form/samples/asset-needs-code-reference-same-source/_expected/cjs/needs-reference5.txt b/test/chunking-form/samples/asset-needs-code-reference-same-source/_expected/cjs/needs-reference5.txt new file mode 100644 index 00000000000..cfd9aaa7945 --- /dev/null +++ b/test/chunking-form/samples/asset-needs-code-reference-same-source/_expected/cjs/needs-reference5.txt @@ -0,0 +1 @@ +source5 \ No newline at end of file diff --git a/test/chunking-form/samples/asset-needs-code-reference-same-source/_expected/es/file1.txt b/test/chunking-form/samples/asset-needs-code-reference-same-source/_expected/es/file1.txt new file mode 100644 index 00000000000..90607bb217b --- /dev/null +++ b/test/chunking-form/samples/asset-needs-code-reference-same-source/_expected/es/file1.txt @@ -0,0 +1 @@ +source1 \ No newline at end of file diff --git a/test/chunking-form/samples/asset-needs-code-reference-same-source/_expected/es/file2.txt b/test/chunking-form/samples/asset-needs-code-reference-same-source/_expected/es/file2.txt new file mode 100644 index 00000000000..a1d2704e103 --- /dev/null +++ b/test/chunking-form/samples/asset-needs-code-reference-same-source/_expected/es/file2.txt @@ -0,0 +1 @@ +source2 \ No newline at end of file diff --git a/test/chunking-form/samples/asset-needs-code-reference-same-source/_expected/es/file4.txt b/test/chunking-form/samples/asset-needs-code-reference-same-source/_expected/es/file4.txt new file mode 100644 index 00000000000..253dd032578 --- /dev/null +++ b/test/chunking-form/samples/asset-needs-code-reference-same-source/_expected/es/file4.txt @@ -0,0 +1 @@ +source4 \ No newline at end of file diff --git a/test/chunking-form/samples/asset-needs-code-reference-same-source/_expected/es/file6.txt b/test/chunking-form/samples/asset-needs-code-reference-same-source/_expected/es/file6.txt new file mode 100644 index 00000000000..bbc84df5fe1 --- /dev/null +++ b/test/chunking-form/samples/asset-needs-code-reference-same-source/_expected/es/file6.txt @@ -0,0 +1 @@ +source6 \ No newline at end of file diff --git a/test/form/samples/deprecated/emit-asset-hacky/main.js b/test/chunking-form/samples/asset-needs-code-reference-same-source/_expected/es/main.js similarity index 100% rename from test/form/samples/deprecated/emit-asset-hacky/main.js rename to test/chunking-form/samples/asset-needs-code-reference-same-source/_expected/es/main.js diff --git a/test/chunking-form/samples/asset-needs-code-reference-same-source/_expected/es/needs-reference3.txt b/test/chunking-form/samples/asset-needs-code-reference-same-source/_expected/es/needs-reference3.txt new file mode 100644 index 00000000000..ab3070242e6 --- /dev/null +++ b/test/chunking-form/samples/asset-needs-code-reference-same-source/_expected/es/needs-reference3.txt @@ -0,0 +1 @@ +source3 \ No newline at end of file diff --git a/test/chunking-form/samples/asset-needs-code-reference-same-source/_expected/es/needs-reference5.txt b/test/chunking-form/samples/asset-needs-code-reference-same-source/_expected/es/needs-reference5.txt new file mode 100644 index 00000000000..cfd9aaa7945 --- /dev/null +++ b/test/chunking-form/samples/asset-needs-code-reference-same-source/_expected/es/needs-reference5.txt @@ -0,0 +1 @@ +source5 \ No newline at end of file diff --git a/test/chunking-form/samples/asset-needs-code-reference-same-source/_expected/system/file1.txt b/test/chunking-form/samples/asset-needs-code-reference-same-source/_expected/system/file1.txt new file mode 100644 index 00000000000..90607bb217b --- /dev/null +++ b/test/chunking-form/samples/asset-needs-code-reference-same-source/_expected/system/file1.txt @@ -0,0 +1 @@ +source1 \ No newline at end of file diff --git a/test/chunking-form/samples/asset-needs-code-reference-same-source/_expected/system/file2.txt b/test/chunking-form/samples/asset-needs-code-reference-same-source/_expected/system/file2.txt new file mode 100644 index 00000000000..a1d2704e103 --- /dev/null +++ b/test/chunking-form/samples/asset-needs-code-reference-same-source/_expected/system/file2.txt @@ -0,0 +1 @@ +source2 \ No newline at end of file diff --git a/test/chunking-form/samples/asset-needs-code-reference-same-source/_expected/system/file4.txt b/test/chunking-form/samples/asset-needs-code-reference-same-source/_expected/system/file4.txt new file mode 100644 index 00000000000..253dd032578 --- /dev/null +++ b/test/chunking-form/samples/asset-needs-code-reference-same-source/_expected/system/file4.txt @@ -0,0 +1 @@ +source4 \ No newline at end of file diff --git a/test/chunking-form/samples/asset-needs-code-reference-same-source/_expected/system/file6.txt b/test/chunking-form/samples/asset-needs-code-reference-same-source/_expected/system/file6.txt new file mode 100644 index 00000000000..bbc84df5fe1 --- /dev/null +++ b/test/chunking-form/samples/asset-needs-code-reference-same-source/_expected/system/file6.txt @@ -0,0 +1 @@ +source6 \ No newline at end of file diff --git a/test/chunking-form/samples/asset-needs-code-reference-same-source/_expected/system/main.js b/test/chunking-form/samples/asset-needs-code-reference-same-source/_expected/system/main.js new file mode 100644 index 00000000000..35e2693371a --- /dev/null +++ b/test/chunking-form/samples/asset-needs-code-reference-same-source/_expected/system/main.js @@ -0,0 +1,10 @@ +System.register([], (function () { + 'use strict'; + return { + execute: (function () { + + console.log('main'); + + }) + }; +})); diff --git a/test/chunking-form/samples/asset-needs-code-reference-same-source/_expected/system/needs-reference3.txt b/test/chunking-form/samples/asset-needs-code-reference-same-source/_expected/system/needs-reference3.txt new file mode 100644 index 00000000000..ab3070242e6 --- /dev/null +++ b/test/chunking-form/samples/asset-needs-code-reference-same-source/_expected/system/needs-reference3.txt @@ -0,0 +1 @@ +source3 \ No newline at end of file diff --git a/test/chunking-form/samples/asset-needs-code-reference-same-source/_expected/system/needs-reference5.txt b/test/chunking-form/samples/asset-needs-code-reference-same-source/_expected/system/needs-reference5.txt new file mode 100644 index 00000000000..cfd9aaa7945 --- /dev/null +++ b/test/chunking-form/samples/asset-needs-code-reference-same-source/_expected/system/needs-reference5.txt @@ -0,0 +1 @@ +source5 \ No newline at end of file diff --git a/test/function/samples/deprecated/emit-chunk/chunk-filename-not-available-render-start/main.js b/test/chunking-form/samples/asset-needs-code-reference-same-source/main.js similarity index 100% rename from test/function/samples/deprecated/emit-chunk/chunk-filename-not-available-render-start/main.js rename to test/chunking-form/samples/asset-needs-code-reference-same-source/main.js diff --git a/test/chunking-form/samples/asset-needs-code-reference/_config.js b/test/chunking-form/samples/asset-needs-code-reference/_config.js new file mode 100644 index 00000000000..d593ffa4d11 --- /dev/null +++ b/test/chunking-form/samples/asset-needs-code-reference/_config.js @@ -0,0 +1,35 @@ +const assert = require('node:assert'); +const fs = require('node:fs'); +const path = require('node:path'); + +module.exports = defineTest({ + description: 'does not emit unreferenced assets if needsCodeReference is true', + options: { + output: { + assetFileNames: '[name][extname]' + }, + plugins: [ + { + resolveId(source, importer) { + if (source.endsWith('.svg')) { + return path.resolve(path.dirname(importer), source); + } + }, + load(id) { + if (id.endsWith('.svg')) { + const referenceId = this.emitFile({ + type: 'asset', + name: path.basename(id), + needsCodeReference: true, + source: fs.readFileSync(id) + }); + return `export default import.meta.ROLLUP_FILE_URL_${referenceId}`; + } + }, + generateBundle(_, bundle) { + assert.deepEqual(Object.keys(bundle), ['logo2.svg', 'main.js']); + } + } + ] + } +}); diff --git a/test/chunking-form/samples/asset-needs-code-reference/_expected/amd/logo2.svg b/test/chunking-form/samples/asset-needs-code-reference/_expected/amd/logo2.svg new file mode 100644 index 00000000000..a936e24b407 --- /dev/null +++ b/test/chunking-form/samples/asset-needs-code-reference/_expected/amd/logo2.svg @@ -0,0 +1,3 @@ + + + diff --git a/test/chunking-form/samples/asset-needs-code-reference/_expected/amd/main.js b/test/chunking-form/samples/asset-needs-code-reference/_expected/amd/main.js new file mode 100644 index 00000000000..7962de7e116 --- /dev/null +++ b/test/chunking-form/samples/asset-needs-code-reference/_expected/amd/main.js @@ -0,0 +1,11 @@ +define(['require'], (function (require) { 'use strict'; + + var asset2 = new URL(require.toUrl('./logo2.svg'), document.baseURI).href; + + { + const image = document.createElement('img'); + image.src = asset2; + document.body.appendChild(image); + } + +})); diff --git a/test/chunking-form/samples/asset-needs-code-reference/_expected/cjs/logo2.svg b/test/chunking-form/samples/asset-needs-code-reference/_expected/cjs/logo2.svg new file mode 100644 index 00000000000..a936e24b407 --- /dev/null +++ b/test/chunking-form/samples/asset-needs-code-reference/_expected/cjs/logo2.svg @@ -0,0 +1,3 @@ + + + diff --git a/test/chunking-form/samples/asset-needs-code-reference/_expected/cjs/main.js b/test/chunking-form/samples/asset-needs-code-reference/_expected/cjs/main.js new file mode 100644 index 00000000000..5fe6927ab20 --- /dev/null +++ b/test/chunking-form/samples/asset-needs-code-reference/_expected/cjs/main.js @@ -0,0 +1,9 @@ +'use strict'; + +var asset2 = (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__dirname + '/logo2.svg').href : new URL('logo2.svg', document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT' && document.currentScript.src || document.baseURI).href); + +{ + const image = document.createElement('img'); + image.src = asset2; + document.body.appendChild(image); +} diff --git a/test/chunking-form/samples/asset-needs-code-reference/_expected/es/logo2.svg b/test/chunking-form/samples/asset-needs-code-reference/_expected/es/logo2.svg new file mode 100644 index 00000000000..a936e24b407 --- /dev/null +++ b/test/chunking-form/samples/asset-needs-code-reference/_expected/es/logo2.svg @@ -0,0 +1,3 @@ + + + diff --git a/test/chunking-form/samples/asset-needs-code-reference/_expected/es/main.js b/test/chunking-form/samples/asset-needs-code-reference/_expected/es/main.js new file mode 100644 index 00000000000..26d98360f79 --- /dev/null +++ b/test/chunking-form/samples/asset-needs-code-reference/_expected/es/main.js @@ -0,0 +1,7 @@ +var asset2 = new URL('logo2.svg', import.meta.url).href; + +{ + const image = document.createElement('img'); + image.src = asset2; + document.body.appendChild(image); +} diff --git a/test/chunking-form/samples/asset-needs-code-reference/_expected/system/logo2.svg b/test/chunking-form/samples/asset-needs-code-reference/_expected/system/logo2.svg new file mode 100644 index 00000000000..a936e24b407 --- /dev/null +++ b/test/chunking-form/samples/asset-needs-code-reference/_expected/system/logo2.svg @@ -0,0 +1,3 @@ + + + diff --git a/test/chunking-form/samples/asset-needs-code-reference/_expected/system/main.js b/test/chunking-form/samples/asset-needs-code-reference/_expected/system/main.js new file mode 100644 index 00000000000..d5c68872301 --- /dev/null +++ b/test/chunking-form/samples/asset-needs-code-reference/_expected/system/main.js @@ -0,0 +1,16 @@ +System.register([], (function (exports, module) { + 'use strict'; + return { + execute: (function () { + + var asset2 = new URL('logo2.svg', module.meta.url).href; + + { + const image = document.createElement('img'); + image.src = asset2; + document.body.appendChild(image); + } + + }) + }; +})); diff --git a/test/chunking-form/samples/deprecated/emit-asset/_expected/amd/assets/logo1-a5ec488b.svg b/test/chunking-form/samples/asset-needs-code-reference/logo.svg similarity index 100% rename from test/chunking-form/samples/deprecated/emit-asset/_expected/amd/assets/logo1-a5ec488b.svg rename to test/chunking-form/samples/asset-needs-code-reference/logo.svg diff --git a/test/chunking-form/samples/asset-needs-code-reference/logo2.svg b/test/chunking-form/samples/asset-needs-code-reference/logo2.svg new file mode 100644 index 00000000000..a936e24b407 --- /dev/null +++ b/test/chunking-form/samples/asset-needs-code-reference/logo2.svg @@ -0,0 +1,3 @@ + + + diff --git a/test/chunking-form/samples/asset-needs-code-reference/main.js b/test/chunking-form/samples/asset-needs-code-reference/main.js new file mode 100644 index 00000000000..ff9e1de4873 --- /dev/null +++ b/test/chunking-form/samples/asset-needs-code-reference/main.js @@ -0,0 +1,13 @@ +import asset from './logo.svg'; +import asset2 from './logo2.svg'; + +if (false) { + const image = document.createElement('img'); + image.src = asset; + document.body.appendChild(image); +} +if (true) { + const image = document.createElement('img'); + image.src = asset2; + document.body.appendChild(image); +} diff --git a/test/chunking-form/samples/avoid-chunk-import-hoisting/_config.js b/test/chunking-form/samples/avoid-chunk-import-hoisting/_config.js index e46fa0fd615..1b0d962ce0c 100644 --- a/test/chunking-form/samples/avoid-chunk-import-hoisting/_config.js +++ b/test/chunking-form/samples/avoid-chunk-import-hoisting/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'avoids hoisting transitive dependencies via flag', options: { input: ['main1.js', 'main2.js'], @@ -7,4 +7,4 @@ module.exports = { hoistTransitiveImports: false } } -}; +}); diff --git a/test/chunking-form/samples/avoid-chunk-import-hoisting/_expected/amd/generated-dep.js b/test/chunking-form/samples/avoid-chunk-import-hoisting/_expected/amd/generated-dep.js index 1d5c0bd5167..5c17fa81a3c 100644 --- a/test/chunking-form/samples/avoid-chunk-import-hoisting/_expected/amd/generated-dep.js +++ b/test/chunking-form/samples/avoid-chunk-import-hoisting/_expected/amd/generated-dep.js @@ -1,11 +1,7 @@ -define(['exports', 'lib'], function (exports, value) { 'use strict'; +define(['exports', 'lib'], (function (exports, value) { 'use strict'; - function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } - - var value__default = /*#__PURE__*/_interopDefaultLegacy(value); - - var dep = 2 * value__default['default']; + var dep = 2 * value; exports.dep = dep; -}); +})); diff --git a/test/chunking-form/samples/avoid-chunk-import-hoisting/_expected/amd/main1.js b/test/chunking-form/samples/avoid-chunk-import-hoisting/_expected/amd/main1.js index 4e7c5c84f74..0cc5c4b5ee9 100644 --- a/test/chunking-form/samples/avoid-chunk-import-hoisting/_expected/amd/main1.js +++ b/test/chunking-form/samples/avoid-chunk-import-hoisting/_expected/amd/main1.js @@ -1,5 +1,5 @@ -define(['./generated-dep'], function (dep) { 'use strict'; +define(['./generated-dep'], (function (dep) { 'use strict'; console.log('main1', dep.dep); -}); +})); diff --git a/test/chunking-form/samples/avoid-chunk-import-hoisting/_expected/amd/main2.js b/test/chunking-form/samples/avoid-chunk-import-hoisting/_expected/amd/main2.js index e5f5685b5a8..7468aba624c 100644 --- a/test/chunking-form/samples/avoid-chunk-import-hoisting/_expected/amd/main2.js +++ b/test/chunking-form/samples/avoid-chunk-import-hoisting/_expected/amd/main2.js @@ -1,5 +1,5 @@ -define(['./generated-dep'], function (dep) { 'use strict'; +define(['./generated-dep'], (function (dep) { 'use strict'; console.log('main2', dep.dep); -}); +})); diff --git a/test/chunking-form/samples/avoid-chunk-import-hoisting/_expected/cjs/generated-dep.js b/test/chunking-form/samples/avoid-chunk-import-hoisting/_expected/cjs/generated-dep.js index 21a7ce2ae84..be61e76d631 100644 --- a/test/chunking-form/samples/avoid-chunk-import-hoisting/_expected/cjs/generated-dep.js +++ b/test/chunking-form/samples/avoid-chunk-import-hoisting/_expected/cjs/generated-dep.js @@ -2,10 +2,6 @@ var value = require('lib'); -function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } - -var value__default = /*#__PURE__*/_interopDefaultLegacy(value); - -var dep = 2 * value__default['default']; +var dep = 2 * value; exports.dep = dep; diff --git a/test/chunking-form/samples/avoid-chunk-import-hoisting/_expected/system/generated-dep.js b/test/chunking-form/samples/avoid-chunk-import-hoisting/_expected/system/generated-dep.js index f570c8632a9..d52c6c07ca6 100644 --- a/test/chunking-form/samples/avoid-chunk-import-hoisting/_expected/system/generated-dep.js +++ b/test/chunking-form/samples/avoid-chunk-import-hoisting/_expected/system/generated-dep.js @@ -1,14 +1,14 @@ -System.register(['lib'], function (exports) { +System.register(['lib'], (function (exports) { 'use strict'; var value; return { setters: [function (module) { value = module.default; }], - execute: function () { + execute: (function () { - var dep = exports('d', 2 * value); + var dep = exports("d", 2 * value); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/avoid-chunk-import-hoisting/_expected/system/main1.js b/test/chunking-form/samples/avoid-chunk-import-hoisting/_expected/system/main1.js index d13859ddc6d..a687f08cdc6 100644 --- a/test/chunking-form/samples/avoid-chunk-import-hoisting/_expected/system/main1.js +++ b/test/chunking-form/samples/avoid-chunk-import-hoisting/_expected/system/main1.js @@ -1,14 +1,14 @@ -System.register(['./generated-dep.js'], function () { +System.register(['./generated-dep.js'], (function () { 'use strict'; var dep; return { setters: [function (module) { dep = module.d; }], - execute: function () { + execute: (function () { console.log('main1', dep); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/avoid-chunk-import-hoisting/_expected/system/main2.js b/test/chunking-form/samples/avoid-chunk-import-hoisting/_expected/system/main2.js index ab882c0f261..7c542187ce1 100644 --- a/test/chunking-form/samples/avoid-chunk-import-hoisting/_expected/system/main2.js +++ b/test/chunking-form/samples/avoid-chunk-import-hoisting/_expected/system/main2.js @@ -1,14 +1,14 @@ -System.register(['./generated-dep.js'], function () { +System.register(['./generated-dep.js'], (function () { 'use strict'; var dep; return { setters: [function (module) { dep = module.d; }], - execute: function () { + execute: (function () { console.log('main2', dep); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/basic-chunking/_config.js b/test/chunking-form/samples/basic-chunking/_config.js index a601862651e..0f55acd1edc 100644 --- a/test/chunking-form/samples/basic-chunking/_config.js +++ b/test/chunking-form/samples/basic-chunking/_config.js @@ -1,6 +1,6 @@ -module.exports = { +module.exports = defineTest({ description: 'simple chunking', options: { input: ['main1.js', 'main2.js'] } -}; +}); diff --git a/test/chunking-form/samples/basic-chunking/_expected/amd/generated-dep2.js b/test/chunking-form/samples/basic-chunking/_expected/amd/generated-dep2.js index f49e0094590..6dfaa8d5698 100644 --- a/test/chunking-form/samples/basic-chunking/_expected/amd/generated-dep2.js +++ b/test/chunking-form/samples/basic-chunking/_expected/amd/generated-dep2.js @@ -1,4 +1,4 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; function fn$1 () { console.log('lib2 fn'); @@ -11,4 +11,4 @@ define(['exports'], function (exports) { 'use strict'; exports.fn = fn; -}); +})); diff --git a/test/chunking-form/samples/basic-chunking/_expected/amd/main1.js b/test/chunking-form/samples/basic-chunking/_expected/amd/main1.js index ab0a692d55b..97cc8e638d1 100644 --- a/test/chunking-form/samples/basic-chunking/_expected/amd/main1.js +++ b/test/chunking-form/samples/basic-chunking/_expected/amd/main1.js @@ -1,4 +1,4 @@ -define(['./generated-dep2'], function (dep2) { 'use strict'; +define(['./generated-dep2'], (function (dep2) { 'use strict'; function fn () { console.log('dep1 fn'); @@ -13,4 +13,4 @@ define(['./generated-dep2'], function (dep2) { 'use strict'; return Main1; -}); +})); diff --git a/test/chunking-form/samples/basic-chunking/_expected/amd/main2.js b/test/chunking-form/samples/basic-chunking/_expected/amd/main2.js index 1a818448c5f..91ef160711c 100644 --- a/test/chunking-form/samples/basic-chunking/_expected/amd/main2.js +++ b/test/chunking-form/samples/basic-chunking/_expected/amd/main2.js @@ -1,4 +1,4 @@ -define(['./generated-dep2'], function (dep2) { 'use strict'; +define(['./generated-dep2'], (function (dep2) { 'use strict'; function fn$1 () { console.log('lib1 fn'); @@ -18,4 +18,4 @@ define(['./generated-dep2'], function (dep2) { 'use strict'; return Main2; -}); +})); diff --git a/test/chunking-form/samples/basic-chunking/_expected/es/main1.js b/test/chunking-form/samples/basic-chunking/_expected/es/main1.js index f2e4ef52928..c5a66ab8a40 100644 --- a/test/chunking-form/samples/basic-chunking/_expected/es/main1.js +++ b/test/chunking-form/samples/basic-chunking/_expected/es/main1.js @@ -11,4 +11,4 @@ class Main1 { } } -export default Main1; +export { Main1 as default }; diff --git a/test/chunking-form/samples/basic-chunking/_expected/es/main2.js b/test/chunking-form/samples/basic-chunking/_expected/es/main2.js index a7a28b48588..995e80e48e8 100644 --- a/test/chunking-form/samples/basic-chunking/_expected/es/main2.js +++ b/test/chunking-form/samples/basic-chunking/_expected/es/main2.js @@ -16,4 +16,4 @@ class Main2 { } } -export default Main2; +export { Main2 as default }; diff --git a/test/chunking-form/samples/basic-chunking/_expected/system/generated-dep2.js b/test/chunking-form/samples/basic-chunking/_expected/system/generated-dep2.js index c86d9b47682..94fa4559204 100644 --- a/test/chunking-form/samples/basic-chunking/_expected/system/generated-dep2.js +++ b/test/chunking-form/samples/basic-chunking/_expected/system/generated-dep2.js @@ -1,9 +1,9 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - exports('f', fn); + exports("f", fn); function fn$1 () { console.log('lib2 fn'); @@ -14,6 +14,6 @@ System.register([], function (exports) { console.log('dep2 fn'); } - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/basic-chunking/_expected/system/main1.js b/test/chunking-form/samples/basic-chunking/_expected/system/main1.js index 287fda7c0e7..c849f2ae044 100644 --- a/test/chunking-form/samples/basic-chunking/_expected/system/main1.js +++ b/test/chunking-form/samples/basic-chunking/_expected/system/main1.js @@ -1,11 +1,11 @@ -System.register(['./generated-dep2.js'], function (exports) { +System.register(['./generated-dep2.js'], (function (exports) { 'use strict'; var fn$1; return { setters: [function (module) { fn$1 = module.f; }], - execute: function () { + execute: (function () { function fn () { console.log('dep1 fn'); @@ -16,8 +16,8 @@ System.register(['./generated-dep2.js'], function (exports) { fn(); fn$1(); } - } exports('default', Main1); + } exports("default", Main1); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/basic-chunking/_expected/system/main2.js b/test/chunking-form/samples/basic-chunking/_expected/system/main2.js index f17ba0bcf33..b9279c92e93 100644 --- a/test/chunking-form/samples/basic-chunking/_expected/system/main2.js +++ b/test/chunking-form/samples/basic-chunking/_expected/system/main2.js @@ -1,11 +1,11 @@ -System.register(['./generated-dep2.js'], function (exports) { +System.register(['./generated-dep2.js'], (function (exports) { 'use strict'; var fn$2; return { setters: [function (module) { fn$2 = module.f; }], - execute: function () { + execute: (function () { function fn$1 () { console.log('lib1 fn'); @@ -21,8 +21,8 @@ System.register(['./generated-dep2.js'], function (exports) { fn(); fn$2(); } - } exports('default', Main2); + } exports("default", Main2); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/chunk-assigment-in-dynamic/_config.js b/test/chunking-form/samples/chunk-assigment-in-dynamic/_config.js new file mode 100644 index 00000000000..51f8ded2009 --- /dev/null +++ b/test/chunking-form/samples/chunk-assigment-in-dynamic/_config.js @@ -0,0 +1,21 @@ +const path = require('node:path'); +const commonjs = require('@rollup/plugin-commonjs'); + +module.exports = defineTest({ + description: 'the content of c.js is complete', + options: { + plugins: [ + commonjs(), + { + resolveId(id) { + if (id === './c.js') { + return { + id: path.resolve('./c.js'), + moduleSideEffects: false + }; + } + } + } + ] + } +}); diff --git a/test/chunking-form/samples/chunk-assigment-in-dynamic/_expected/amd/generated-a.js b/test/chunking-form/samples/chunk-assigment-in-dynamic/_expected/amd/generated-a.js new file mode 100644 index 00000000000..e54bca90766 --- /dev/null +++ b/test/chunking-form/samples/chunk-assigment-in-dynamic/_expected/amd/generated-a.js @@ -0,0 +1,9 @@ +define(['exports', './generated-c'], (function (exports, c) { 'use strict'; + + function A() { + return { icon: c.cExports.faPrint }; + } + + exports.A = A; + +})); diff --git a/test/chunking-form/samples/chunk-assigment-in-dynamic/_expected/amd/generated-b.js b/test/chunking-form/samples/chunk-assigment-in-dynamic/_expected/amd/generated-b.js new file mode 100644 index 00000000000..90a2c5df2a5 --- /dev/null +++ b/test/chunking-form/samples/chunk-assigment-in-dynamic/_expected/amd/generated-b.js @@ -0,0 +1,9 @@ +define(['exports', './generated-c'], (function (exports, c) { 'use strict'; + + function B() { + return { icon: c.cExports.faPrint }; + } + + exports.B = B; + +})); diff --git a/test/chunking-form/samples/chunk-assigment-in-dynamic/_expected/amd/generated-c.js b/test/chunking-form/samples/chunk-assigment-in-dynamic/_expected/amd/generated-c.js new file mode 100644 index 00000000000..9134f1cfd4e --- /dev/null +++ b/test/chunking-form/samples/chunk-assigment-in-dynamic/_expected/amd/generated-c.js @@ -0,0 +1,24 @@ +define(['exports'], (function (exports) { 'use strict'; + + var c = {}; + + var hasRequiredC; + + function requireC () { + if (hasRequiredC) return c; + hasRequiredC = 1; + (function (exports$1) { + exports$1.preFaPrint = { + foo: 1 + }; + + exports$1.faPrint = exports$1.preFaPrint; + } (c)); + return c; + } + + var cExports = /*@__PURE__*/ requireC(); + + exports.cExports = cExports; + +})); diff --git a/test/chunking-form/samples/chunk-assigment-in-dynamic/_expected/amd/main.js b/test/chunking-form/samples/chunk-assigment-in-dynamic/_expected/amd/main.js new file mode 100644 index 00000000000..c7d1bb41894 --- /dev/null +++ b/test/chunking-form/samples/chunk-assigment-in-dynamic/_expected/amd/main.js @@ -0,0 +1,8 @@ +define(['require'], (function (require) { 'use strict'; + + const importA = () => new Promise(function (resolve, reject) { require(['./generated-a'], resolve, reject); }); + const importB = () => new Promise(function (resolve, reject) { require(['./generated-b'], resolve, reject); }); + + console.log(importA, importB); + +})); diff --git a/test/chunking-form/samples/chunk-assigment-in-dynamic/_expected/cjs/generated-a.js b/test/chunking-form/samples/chunk-assigment-in-dynamic/_expected/cjs/generated-a.js new file mode 100644 index 00000000000..d1bdd886676 --- /dev/null +++ b/test/chunking-form/samples/chunk-assigment-in-dynamic/_expected/cjs/generated-a.js @@ -0,0 +1,9 @@ +'use strict'; + +var c = require('./generated-c.js'); + +function A() { + return { icon: c.cExports.faPrint }; +} + +exports.A = A; diff --git a/test/chunking-form/samples/chunk-assigment-in-dynamic/_expected/cjs/generated-b.js b/test/chunking-form/samples/chunk-assigment-in-dynamic/_expected/cjs/generated-b.js new file mode 100644 index 00000000000..22cf5a557d5 --- /dev/null +++ b/test/chunking-form/samples/chunk-assigment-in-dynamic/_expected/cjs/generated-b.js @@ -0,0 +1,9 @@ +'use strict'; + +var c = require('./generated-c.js'); + +function B() { + return { icon: c.cExports.faPrint }; +} + +exports.B = B; diff --git a/test/chunking-form/samples/chunk-assigment-in-dynamic/_expected/cjs/generated-c.js b/test/chunking-form/samples/chunk-assigment-in-dynamic/_expected/cjs/generated-c.js new file mode 100644 index 00000000000..1599bd99094 --- /dev/null +++ b/test/chunking-form/samples/chunk-assigment-in-dynamic/_expected/cjs/generated-c.js @@ -0,0 +1,22 @@ +'use strict'; + +var c = {}; + +var hasRequiredC; + +function requireC () { + if (hasRequiredC) return c; + hasRequiredC = 1; + (function (exports$1) { + exports$1.preFaPrint = { + foo: 1 + }; + + exports$1.faPrint = exports$1.preFaPrint; + } (c)); + return c; +} + +var cExports = /*@__PURE__*/ requireC(); + +exports.cExports = cExports; diff --git a/test/chunking-form/samples/chunk-assigment-in-dynamic/_expected/cjs/main.js b/test/chunking-form/samples/chunk-assigment-in-dynamic/_expected/cjs/main.js new file mode 100644 index 00000000000..90831d35d8a --- /dev/null +++ b/test/chunking-form/samples/chunk-assigment-in-dynamic/_expected/cjs/main.js @@ -0,0 +1,6 @@ +'use strict'; + +const importA = () => Promise.resolve().then(function () { return require('./generated-a.js'); }); +const importB = () => Promise.resolve().then(function () { return require('./generated-b.js'); }); + +console.log(importA, importB); diff --git a/test/chunking-form/samples/chunk-assigment-in-dynamic/_expected/es/generated-a.js b/test/chunking-form/samples/chunk-assigment-in-dynamic/_expected/es/generated-a.js new file mode 100644 index 00000000000..85ecf0aff89 --- /dev/null +++ b/test/chunking-form/samples/chunk-assigment-in-dynamic/_expected/es/generated-a.js @@ -0,0 +1,7 @@ +import { c as cExports } from './generated-c.js'; + +function A() { + return { icon: cExports.faPrint }; +} + +export { A }; diff --git a/test/chunking-form/samples/chunk-assigment-in-dynamic/_expected/es/generated-b.js b/test/chunking-form/samples/chunk-assigment-in-dynamic/_expected/es/generated-b.js new file mode 100644 index 00000000000..22f73d7e3e8 --- /dev/null +++ b/test/chunking-form/samples/chunk-assigment-in-dynamic/_expected/es/generated-b.js @@ -0,0 +1,7 @@ +import { c as cExports } from './generated-c.js'; + +function B() { + return { icon: cExports.faPrint }; +} + +export { B }; diff --git a/test/chunking-form/samples/chunk-assigment-in-dynamic/_expected/es/generated-c.js b/test/chunking-form/samples/chunk-assigment-in-dynamic/_expected/es/generated-c.js new file mode 100644 index 00000000000..bffb077501d --- /dev/null +++ b/test/chunking-form/samples/chunk-assigment-in-dynamic/_expected/es/generated-c.js @@ -0,0 +1,20 @@ +var c = {}; + +var hasRequiredC; + +function requireC () { + if (hasRequiredC) return c; + hasRequiredC = 1; + (function (exports$1) { + exports$1.preFaPrint = { + foo: 1 + }; + + exports$1.faPrint = exports$1.preFaPrint; + } (c)); + return c; +} + +var cExports = /*@__PURE__*/ requireC(); + +export { cExports as c }; diff --git a/test/chunking-form/samples/chunk-assigment-in-dynamic/_expected/es/main.js b/test/chunking-form/samples/chunk-assigment-in-dynamic/_expected/es/main.js new file mode 100644 index 00000000000..c4861967ba3 --- /dev/null +++ b/test/chunking-form/samples/chunk-assigment-in-dynamic/_expected/es/main.js @@ -0,0 +1,4 @@ +const importA = () => import('./generated-a.js'); +const importB = () => import('./generated-b.js'); + +console.log(importA, importB); diff --git a/test/chunking-form/samples/chunk-assigment-in-dynamic/_expected/system/generated-a.js b/test/chunking-form/samples/chunk-assigment-in-dynamic/_expected/system/generated-a.js new file mode 100644 index 00000000000..96d7ec4cacb --- /dev/null +++ b/test/chunking-form/samples/chunk-assigment-in-dynamic/_expected/system/generated-a.js @@ -0,0 +1,18 @@ +System.register(['./generated-c.js'], (function (exports) { + 'use strict'; + var cExports; + return { + setters: [function (module) { + cExports = module.c; + }], + execute: (function () { + + exports("A", A); + + function A() { + return { icon: cExports.faPrint }; + } + + }) + }; +})); diff --git a/test/chunking-form/samples/chunk-assigment-in-dynamic/_expected/system/generated-b.js b/test/chunking-form/samples/chunk-assigment-in-dynamic/_expected/system/generated-b.js new file mode 100644 index 00000000000..5b38afc58e3 --- /dev/null +++ b/test/chunking-form/samples/chunk-assigment-in-dynamic/_expected/system/generated-b.js @@ -0,0 +1,18 @@ +System.register(['./generated-c.js'], (function (exports) { + 'use strict'; + var cExports; + return { + setters: [function (module) { + cExports = module.c; + }], + execute: (function () { + + exports("B", B); + + function B() { + return { icon: cExports.faPrint }; + } + + }) + }; +})); diff --git a/test/chunking-form/samples/chunk-assigment-in-dynamic/_expected/system/generated-c.js b/test/chunking-form/samples/chunk-assigment-in-dynamic/_expected/system/generated-c.js new file mode 100644 index 00000000000..145015f2ed5 --- /dev/null +++ b/test/chunking-form/samples/chunk-assigment-in-dynamic/_expected/system/generated-c.js @@ -0,0 +1,27 @@ +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + + var c = {}; + + var hasRequiredC; + + function requireC () { + if (hasRequiredC) return c; + hasRequiredC = 1; + (function (exports$1) { + exports$1.preFaPrint = { + foo: 1 + }; + + exports$1.faPrint = exports$1.preFaPrint; + } (c)); + return c; + } + + var cExports = exports("c", /*@__PURE__*/ requireC()); + + }) + }; +})); diff --git a/test/chunking-form/samples/chunk-assigment-in-dynamic/_expected/system/main.js b/test/chunking-form/samples/chunk-assigment-in-dynamic/_expected/system/main.js new file mode 100644 index 00000000000..bc199a45949 --- /dev/null +++ b/test/chunking-form/samples/chunk-assigment-in-dynamic/_expected/system/main.js @@ -0,0 +1,13 @@ +System.register([], (function (exports, module) { + 'use strict'; + return { + execute: (function () { + + const importA = () => module.import('./generated-a.js'); + const importB = () => module.import('./generated-b.js'); + + console.log(importA, importB); + + }) + }; +})); diff --git a/test/chunking-form/samples/chunk-assigment-in-dynamic/a.js b/test/chunking-form/samples/chunk-assigment-in-dynamic/a.js new file mode 100644 index 00000000000..aff72490c7e --- /dev/null +++ b/test/chunking-form/samples/chunk-assigment-in-dynamic/a.js @@ -0,0 +1,5 @@ +import { faPrint } from './c.js'; + +export function A() { + return { icon: faPrint }; +} diff --git a/test/chunking-form/samples/chunk-assigment-in-dynamic/b.js b/test/chunking-form/samples/chunk-assigment-in-dynamic/b.js new file mode 100644 index 00000000000..63d37d9cf24 --- /dev/null +++ b/test/chunking-form/samples/chunk-assigment-in-dynamic/b.js @@ -0,0 +1,5 @@ +import { faPrint } from './c.js'; + +export function B() { + return { icon: faPrint }; +} diff --git a/test/chunking-form/samples/chunk-assigment-in-dynamic/c.js b/test/chunking-form/samples/chunk-assigment-in-dynamic/c.js new file mode 100644 index 00000000000..3e801a6fba0 --- /dev/null +++ b/test/chunking-form/samples/chunk-assigment-in-dynamic/c.js @@ -0,0 +1,5 @@ +exports.preFaPrint = { + foo: 1 +}; + +exports.faPrint = exports.preFaPrint; diff --git a/test/chunking-form/samples/chunk-assigment-in-dynamic/main.js b/test/chunking-form/samples/chunk-assigment-in-dynamic/main.js new file mode 100644 index 00000000000..2a9821bbeb7 --- /dev/null +++ b/test/chunking-form/samples/chunk-assigment-in-dynamic/main.js @@ -0,0 +1,4 @@ +const importA = () => import('./a.js'); +const importB = () => import('./b.js'); + +console.log(importA, importB); diff --git a/test/chunking-form/samples/chunk-deshadowing-reassignment/_config.js b/test/chunking-form/samples/chunk-deshadowing-reassignment/_config.js index e0abcec057f..c4a86112011 100644 --- a/test/chunking-form/samples/chunk-deshadowing-reassignment/_config.js +++ b/test/chunking-form/samples/chunk-deshadowing-reassignment/_config.js @@ -1,6 +1,6 @@ -module.exports = { +module.exports = defineTest({ description: 'chunk reassignment import deshadowing', options: { input: ['main1.js', 'main2.js', 'main3.js', 'main4.js'] } -}; +}); diff --git a/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/amd/generated-dep1.js b/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/amd/generated-dep1.js deleted file mode 100644 index 9b17fe9ee5f..00000000000 --- a/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/amd/generated-dep1.js +++ /dev/null @@ -1,8 +0,0 @@ -define(['exports'], function (exports) { 'use strict'; - - var x = 42; - console.log('dep1'); - - exports.x = x; - -}); diff --git a/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/amd/generated-dep2.js b/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/amd/generated-dep2.js deleted file mode 100644 index cb1482e274a..00000000000 --- a/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/amd/generated-dep2.js +++ /dev/null @@ -1,8 +0,0 @@ -define(['exports'], function (exports) { 'use strict'; - - var x = 43; - console.log('dep2'); - - exports.x = x; - -}); diff --git a/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/amd/generated-shared2.js b/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/amd/generated-shared2.js deleted file mode 100644 index e847953e2bd..00000000000 --- a/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/amd/generated-shared2.js +++ /dev/null @@ -1,12 +0,0 @@ -define(['exports', './generated-dep1', './generated-dep2'], function (exports, dep1, dep2) { 'use strict'; - - var x = dep1.x + 1; - console.log('shared1'); - - var y = dep2.x + 1; - console.log('shared2'); - - exports.x = x; - exports.y = y; - -}); diff --git a/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/amd/main1.js b/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/amd/main1.js index 5569e16d827..a594827dc20 100644 --- a/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/amd/main1.js +++ b/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/amd/main1.js @@ -1,5 +1,5 @@ -define(['./generated-shared2', './generated-dep1', './generated-dep2'], function (shared2, dep1, dep2) { 'use strict'; +define(['./main2', './main3', './main4'], (function (main2, main3, main4) { 'use strict'; - console.log(shared2.x + shared2.y); + console.log(main2.x + main2.y); -}); +})); diff --git a/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/amd/main2.js b/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/amd/main2.js index 6820cdc5219..35bb3c8eaf2 100644 --- a/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/amd/main2.js +++ b/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/amd/main2.js @@ -1,5 +1,12 @@ -define(['./generated-shared2', './generated-dep1', './generated-dep2'], function (shared2, dep1, dep2) { 'use strict'; +define(['exports', './main3', './main4'], (function (exports, main3, main4) { 'use strict'; + var x = main3.x + 1; + console.log('shared1'); + var y = main4.x + 1; + console.log('shared2'); -}); + exports.x = x; + exports.y = y; + +})); diff --git a/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/amd/main3.js b/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/amd/main3.js index 02a46daf2cd..262610de8e1 100644 --- a/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/amd/main3.js +++ b/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/amd/main3.js @@ -1,5 +1,8 @@ -define(['./generated-dep1'], function (dep1) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; + var x = 42; + console.log('dep1'); + exports.x = x; -}); +})); diff --git a/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/amd/main4.js b/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/amd/main4.js index 8806f30b198..3c2c6ef8874 100644 --- a/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/amd/main4.js +++ b/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/amd/main4.js @@ -1,5 +1,8 @@ -define(['./generated-dep2'], function (dep2) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; + var x = 43; + console.log('dep2'); + exports.x = x; -}); +})); diff --git a/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/cjs/generated-dep1.js b/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/cjs/generated-dep1.js deleted file mode 100644 index 0832148cd65..00000000000 --- a/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/cjs/generated-dep1.js +++ /dev/null @@ -1,6 +0,0 @@ -'use strict'; - -var x = 42; -console.log('dep1'); - -exports.x = x; diff --git a/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/cjs/generated-dep2.js b/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/cjs/generated-dep2.js deleted file mode 100644 index 2d4b0b3b7e2..00000000000 --- a/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/cjs/generated-dep2.js +++ /dev/null @@ -1,6 +0,0 @@ -'use strict'; - -var x = 43; -console.log('dep2'); - -exports.x = x; diff --git a/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/cjs/generated-shared2.js b/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/cjs/generated-shared2.js deleted file mode 100644 index 6dfe1e7a09f..00000000000 --- a/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/cjs/generated-shared2.js +++ /dev/null @@ -1,13 +0,0 @@ -'use strict'; - -var dep1 = require('./generated-dep1.js'); -var dep2 = require('./generated-dep2.js'); - -var x = dep1.x + 1; -console.log('shared1'); - -var y = dep2.x + 1; -console.log('shared2'); - -exports.x = x; -exports.y = y; diff --git a/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/cjs/main1.js b/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/cjs/main1.js index e7c819ca823..82028036790 100644 --- a/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/cjs/main1.js +++ b/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/cjs/main1.js @@ -1,7 +1,7 @@ 'use strict'; -var shared2 = require('./generated-shared2.js'); -require('./generated-dep1.js'); -require('./generated-dep2.js'); +var main2 = require('./main2.js'); +require('./main3.js'); +require('./main4.js'); -console.log(shared2.x + shared2.y); +console.log(main2.x + main2.y); diff --git a/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/cjs/main2.js b/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/cjs/main2.js index 3a2eedeb32c..de3ae8b1320 100644 --- a/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/cjs/main2.js +++ b/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/cjs/main2.js @@ -1,6 +1,13 @@ 'use strict'; -require('./generated-shared2.js'); -require('./generated-dep1.js'); -require('./generated-dep2.js'); +var main3 = require('./main3.js'); +var main4 = require('./main4.js'); +var x = main3.x + 1; +console.log('shared1'); + +var y = main4.x + 1; +console.log('shared2'); + +exports.x = x; +exports.y = y; diff --git a/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/cjs/main3.js b/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/cjs/main3.js index ccb8d98ce68..0832148cd65 100644 --- a/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/cjs/main3.js +++ b/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/cjs/main3.js @@ -1,4 +1,6 @@ 'use strict'; -require('./generated-dep1.js'); +var x = 42; +console.log('dep1'); +exports.x = x; diff --git a/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/cjs/main4.js b/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/cjs/main4.js index 8bcaed1c530..2d4b0b3b7e2 100644 --- a/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/cjs/main4.js +++ b/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/cjs/main4.js @@ -1,4 +1,6 @@ 'use strict'; -require('./generated-dep2.js'); +var x = 43; +console.log('dep2'); +exports.x = x; diff --git a/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/es/generated-dep1.js b/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/es/generated-dep1.js deleted file mode 100644 index d6d2ae2cb09..00000000000 --- a/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/es/generated-dep1.js +++ /dev/null @@ -1,4 +0,0 @@ -var x = 42; -console.log('dep1'); - -export { x }; diff --git a/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/es/generated-dep2.js b/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/es/generated-dep2.js deleted file mode 100644 index 2ba7d8fc572..00000000000 --- a/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/es/generated-dep2.js +++ /dev/null @@ -1,4 +0,0 @@ -var x = 43; -console.log('dep2'); - -export { x }; diff --git a/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/es/generated-shared2.js b/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/es/generated-shared2.js deleted file mode 100644 index f0db7b88f4a..00000000000 --- a/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/es/generated-shared2.js +++ /dev/null @@ -1,10 +0,0 @@ -import { x as x$1 } from './generated-dep1.js'; -import { x as x$2 } from './generated-dep2.js'; - -var x = x$1 + 1; -console.log('shared1'); - -var y = x$2 + 1; -console.log('shared2'); - -export { x, y }; diff --git a/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/es/main1.js b/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/es/main1.js index 4ecb3793798..ba9b7f1beda 100644 --- a/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/es/main1.js +++ b/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/es/main1.js @@ -1,5 +1,5 @@ -import { x, y } from './generated-shared2.js'; -import './generated-dep1.js'; -import './generated-dep2.js'; +import { x, y } from './main2.js'; +import './main3.js'; +import './main4.js'; console.log(x + y); diff --git a/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/es/main2.js b/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/es/main2.js index ad419134b5a..de6e14112c0 100644 --- a/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/es/main2.js +++ b/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/es/main2.js @@ -1,3 +1,10 @@ -import './generated-shared2.js'; -import './generated-dep1.js'; -import './generated-dep2.js'; +import { x as x$1 } from './main3.js'; +import { x as x$2 } from './main4.js'; + +var x = x$1 + 1; +console.log('shared1'); + +var y = x$2 + 1; +console.log('shared2'); + +export { x, y }; diff --git a/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/es/main3.js b/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/es/main3.js index 934a68ee7f1..d6d2ae2cb09 100644 --- a/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/es/main3.js +++ b/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/es/main3.js @@ -1 +1,4 @@ -import './generated-dep1.js'; +var x = 42; +console.log('dep1'); + +export { x }; diff --git a/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/es/main4.js b/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/es/main4.js index e38989d38f2..2ba7d8fc572 100644 --- a/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/es/main4.js +++ b/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/es/main4.js @@ -1 +1,4 @@ -import './generated-dep2.js'; +var x = 43; +console.log('dep2'); + +export { x }; diff --git a/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/system/generated-dep1.js b/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/system/generated-dep1.js deleted file mode 100644 index 1adbf5d7c5b..00000000000 --- a/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/system/generated-dep1.js +++ /dev/null @@ -1,11 +0,0 @@ -System.register([], function (exports) { - 'use strict'; - return { - execute: function () { - - var x = exports('x', 42); - console.log('dep1'); - - } - }; -}); diff --git a/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/system/generated-dep2.js b/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/system/generated-dep2.js deleted file mode 100644 index 987641ccc10..00000000000 --- a/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/system/generated-dep2.js +++ /dev/null @@ -1,11 +0,0 @@ -System.register([], function (exports) { - 'use strict'; - return { - execute: function () { - - var x = exports('x', 43); - console.log('dep2'); - - } - }; -}); diff --git a/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/system/generated-shared2.js b/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/system/generated-shared2.js deleted file mode 100644 index e3daf5963c5..00000000000 --- a/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/system/generated-shared2.js +++ /dev/null @@ -1,20 +0,0 @@ -System.register(['./generated-dep1.js', './generated-dep2.js'], function (exports) { - 'use strict'; - var x$1, x$2; - return { - setters: [function (module) { - x$1 = module.x; - }, function (module) { - x$2 = module.x; - }], - execute: function () { - - var x = exports('x', x$1 + 1); - console.log('shared1'); - - var y = exports('y', x$2 + 1); - console.log('shared2'); - - } - }; -}); diff --git a/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/system/main1.js b/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/system/main1.js index e0735768bea..ff4b6f14868 100644 --- a/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/system/main1.js +++ b/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/system/main1.js @@ -1,15 +1,15 @@ -System.register(['./generated-shared2.js', './generated-dep1.js', './generated-dep2.js'], function () { +System.register(['./main2.js', './main3.js', './main4.js'], (function () { 'use strict'; var x, y; return { setters: [function (module) { x = module.x; y = module.y; - }, function () {}, function () {}], - execute: function () { + }, null, null], + execute: (function () { console.log(x + y); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/system/main2.js b/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/system/main2.js index b37f5d5a852..7087d2c63a1 100644 --- a/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/system/main2.js +++ b/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/system/main2.js @@ -1,11 +1,20 @@ -System.register(['./generated-shared2.js', './generated-dep1.js', './generated-dep2.js'], function () { +System.register(['./main3.js', './main4.js'], (function (exports) { 'use strict'; + var x$1, x$2; return { - setters: [function () {}, function () {}, function () {}], - execute: function () { + setters: [function (module) { + x$1 = module.x; + }, function (module) { + x$2 = module.x; + }], + execute: (function () { + var x = exports("x", x$1 + 1); + console.log('shared1'); + var y = exports("y", x$2 + 1); + console.log('shared2'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/system/main3.js b/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/system/main3.js index 5668bec5d4f..45cb7ae03fc 100644 --- a/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/system/main3.js +++ b/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/system/main3.js @@ -1,11 +1,11 @@ -System.register(['./generated-dep1.js'], function () { +System.register([], (function (exports) { 'use strict'; return { - setters: [function () {}], - execute: function () { + execute: (function () { + var x = exports("x", 42); + console.log('dep1'); - - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/system/main4.js b/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/system/main4.js index 73473efce7c..d7f5f84e7c3 100644 --- a/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/system/main4.js +++ b/test/chunking-form/samples/chunk-deshadowing-reassignment/_expected/system/main4.js @@ -1,11 +1,11 @@ -System.register(['./generated-dep2.js'], function () { +System.register([], (function (exports) { 'use strict'; return { - setters: [function () {}], - execute: function () { + execute: (function () { + var x = exports("x", 43); + console.log('dep2'); - - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/chunk-execution-order/_config.js b/test/chunking-form/samples/chunk-execution-order/_config.js index 74ee8f5f11c..53b6ecbb3b1 100644 --- a/test/chunking-form/samples/chunk-execution-order/_config.js +++ b/test/chunking-form/samples/chunk-execution-order/_config.js @@ -1,6 +1,6 @@ -module.exports = { +module.exports = defineTest({ description: 'maintains execution order ', options: { input: ['main1.js', 'main2.js', 'main3.js', 'main4.js'] } -}; +}); diff --git a/test/chunking-form/samples/chunk-execution-order/_expected/amd/generated-dep11.js b/test/chunking-form/samples/chunk-execution-order/_expected/amd/generated-dep11.js deleted file mode 100644 index 8a7b5d70482..00000000000 --- a/test/chunking-form/samples/chunk-execution-order/_expected/amd/generated-dep11.js +++ /dev/null @@ -1,5 +0,0 @@ -define(['./generated-dep111', './generated-dep112'], function (dep111, dep112) { 'use strict'; - - console.log('11'); - -}); diff --git a/test/chunking-form/samples/chunk-execution-order/_expected/amd/generated-dep111.js b/test/chunking-form/samples/chunk-execution-order/_expected/amd/generated-dep111.js deleted file mode 100644 index 3e36b05c84b..00000000000 --- a/test/chunking-form/samples/chunk-execution-order/_expected/amd/generated-dep111.js +++ /dev/null @@ -1,5 +0,0 @@ -define(function () { 'use strict'; - - console.log('111'); - -}); diff --git a/test/chunking-form/samples/chunk-execution-order/_expected/amd/generated-dep112.js b/test/chunking-form/samples/chunk-execution-order/_expected/amd/generated-dep112.js deleted file mode 100644 index bd54da136b3..00000000000 --- a/test/chunking-form/samples/chunk-execution-order/_expected/amd/generated-dep112.js +++ /dev/null @@ -1,8 +0,0 @@ -define(['exports'], function (exports) { 'use strict'; - - const x = 0; - console.log('112'); - - exports.x = x; - -}); diff --git a/test/chunking-form/samples/chunk-execution-order/_expected/amd/main1.js b/test/chunking-form/samples/chunk-execution-order/_expected/amd/main1.js index ae3cc192d00..88c2903ff99 100644 --- a/test/chunking-form/samples/chunk-execution-order/_expected/amd/main1.js +++ b/test/chunking-form/samples/chunk-execution-order/_expected/amd/main1.js @@ -1,7 +1,7 @@ -define(['./generated-dep11', './generated-dep112', './generated-dep111'], function (dep11, dep112, dep111) { 'use strict'; +define(['./main2', './main4', './main3'], (function (main2, main4, main3) { 'use strict'; console.log('1'); - console.log(dep112.x); + console.log(main4.x); -}); +})); diff --git a/test/chunking-form/samples/chunk-execution-order/_expected/amd/main2.js b/test/chunking-form/samples/chunk-execution-order/_expected/amd/main2.js index 39a25a82033..e62322fcf97 100644 --- a/test/chunking-form/samples/chunk-execution-order/_expected/amd/main2.js +++ b/test/chunking-form/samples/chunk-execution-order/_expected/amd/main2.js @@ -1,5 +1,5 @@ -define(['./generated-dep11', './generated-dep111', './generated-dep112'], function (dep11, dep111, dep112) { 'use strict'; +define(['./main3', './main4'], (function (main3, main4) { 'use strict'; + console.log('11'); - -}); +})); diff --git a/test/chunking-form/samples/chunk-execution-order/_expected/amd/main3.js b/test/chunking-form/samples/chunk-execution-order/_expected/amd/main3.js index 6b57c04c178..22ac93b635d 100644 --- a/test/chunking-form/samples/chunk-execution-order/_expected/amd/main3.js +++ b/test/chunking-form/samples/chunk-execution-order/_expected/amd/main3.js @@ -1,5 +1,5 @@ -define(['./generated-dep111'], function (dep111) { 'use strict'; +define((function () { 'use strict'; + console.log('111'); - -}); +})); diff --git a/test/chunking-form/samples/chunk-execution-order/_expected/amd/main4.js b/test/chunking-form/samples/chunk-execution-order/_expected/amd/main4.js index bcc4d6bb6d1..8db6250c9f8 100644 --- a/test/chunking-form/samples/chunk-execution-order/_expected/amd/main4.js +++ b/test/chunking-form/samples/chunk-execution-order/_expected/amd/main4.js @@ -1,5 +1,8 @@ -define(['./generated-dep112'], function (dep112) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; + const x = 0; + console.log('112'); + exports.x = x; -}); +})); diff --git a/test/chunking-form/samples/chunk-execution-order/_expected/cjs/generated-dep11.js b/test/chunking-form/samples/chunk-execution-order/_expected/cjs/generated-dep11.js deleted file mode 100644 index d53656de00a..00000000000 --- a/test/chunking-form/samples/chunk-execution-order/_expected/cjs/generated-dep11.js +++ /dev/null @@ -1,6 +0,0 @@ -'use strict'; - -require('./generated-dep111.js'); -require('./generated-dep112.js'); - -console.log('11'); diff --git a/test/chunking-form/samples/chunk-execution-order/_expected/cjs/generated-dep111.js b/test/chunking-form/samples/chunk-execution-order/_expected/cjs/generated-dep111.js deleted file mode 100644 index bf703b5acf3..00000000000 --- a/test/chunking-form/samples/chunk-execution-order/_expected/cjs/generated-dep111.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -console.log('111'); diff --git a/test/chunking-form/samples/chunk-execution-order/_expected/cjs/generated-dep112.js b/test/chunking-form/samples/chunk-execution-order/_expected/cjs/generated-dep112.js deleted file mode 100644 index 8ddf85976dd..00000000000 --- a/test/chunking-form/samples/chunk-execution-order/_expected/cjs/generated-dep112.js +++ /dev/null @@ -1,6 +0,0 @@ -'use strict'; - -const x = 0; -console.log('112'); - -exports.x = x; diff --git a/test/chunking-form/samples/chunk-execution-order/_expected/cjs/main1.js b/test/chunking-form/samples/chunk-execution-order/_expected/cjs/main1.js index e61cfc76ea0..76218bc748e 100644 --- a/test/chunking-form/samples/chunk-execution-order/_expected/cjs/main1.js +++ b/test/chunking-form/samples/chunk-execution-order/_expected/cjs/main1.js @@ -1,9 +1,9 @@ 'use strict'; -require('./generated-dep11.js'); -var dep112 = require('./generated-dep112.js'); -require('./generated-dep111.js'); +require('./main2.js'); +var main4 = require('./main4.js'); +require('./main3.js'); console.log('1'); -console.log(dep112.x); +console.log(main4.x); diff --git a/test/chunking-form/samples/chunk-execution-order/_expected/cjs/main2.js b/test/chunking-form/samples/chunk-execution-order/_expected/cjs/main2.js index 7bcc0f1f5c7..8c6d654f014 100644 --- a/test/chunking-form/samples/chunk-execution-order/_expected/cjs/main2.js +++ b/test/chunking-form/samples/chunk-execution-order/_expected/cjs/main2.js @@ -1,6 +1,6 @@ 'use strict'; -require('./generated-dep11.js'); -require('./generated-dep111.js'); -require('./generated-dep112.js'); +require('./main3.js'); +require('./main4.js'); +console.log('11'); diff --git a/test/chunking-form/samples/chunk-execution-order/_expected/cjs/main3.js b/test/chunking-form/samples/chunk-execution-order/_expected/cjs/main3.js index 03f5bcb4802..bf703b5acf3 100644 --- a/test/chunking-form/samples/chunk-execution-order/_expected/cjs/main3.js +++ b/test/chunking-form/samples/chunk-execution-order/_expected/cjs/main3.js @@ -1,4 +1,3 @@ 'use strict'; -require('./generated-dep111.js'); - +console.log('111'); diff --git a/test/chunking-form/samples/chunk-execution-order/_expected/cjs/main4.js b/test/chunking-form/samples/chunk-execution-order/_expected/cjs/main4.js index 9efc879ddeb..8ddf85976dd 100644 --- a/test/chunking-form/samples/chunk-execution-order/_expected/cjs/main4.js +++ b/test/chunking-form/samples/chunk-execution-order/_expected/cjs/main4.js @@ -1,4 +1,6 @@ 'use strict'; -require('./generated-dep112.js'); +const x = 0; +console.log('112'); +exports.x = x; diff --git a/test/chunking-form/samples/chunk-execution-order/_expected/es/generated-dep11.js b/test/chunking-form/samples/chunk-execution-order/_expected/es/generated-dep11.js deleted file mode 100644 index 113045c45f4..00000000000 --- a/test/chunking-form/samples/chunk-execution-order/_expected/es/generated-dep11.js +++ /dev/null @@ -1,4 +0,0 @@ -import './generated-dep111.js'; -import './generated-dep112.js'; - -console.log('11'); diff --git a/test/chunking-form/samples/chunk-execution-order/_expected/es/generated-dep111.js b/test/chunking-form/samples/chunk-execution-order/_expected/es/generated-dep111.js deleted file mode 100644 index ab8d7e39114..00000000000 --- a/test/chunking-form/samples/chunk-execution-order/_expected/es/generated-dep111.js +++ /dev/null @@ -1 +0,0 @@ -console.log('111'); diff --git a/test/chunking-form/samples/chunk-execution-order/_expected/es/generated-dep112.js b/test/chunking-form/samples/chunk-execution-order/_expected/es/generated-dep112.js deleted file mode 100644 index a72c32b4c0a..00000000000 --- a/test/chunking-form/samples/chunk-execution-order/_expected/es/generated-dep112.js +++ /dev/null @@ -1,4 +0,0 @@ -const x = 0; -console.log('112'); - -export { x }; diff --git a/test/chunking-form/samples/chunk-execution-order/_expected/es/main1.js b/test/chunking-form/samples/chunk-execution-order/_expected/es/main1.js index 8ccac0f4e96..69a2f611dd0 100644 --- a/test/chunking-form/samples/chunk-execution-order/_expected/es/main1.js +++ b/test/chunking-form/samples/chunk-execution-order/_expected/es/main1.js @@ -1,6 +1,6 @@ -import './generated-dep11.js'; -import { x } from './generated-dep112.js'; -import './generated-dep111.js'; +import './main2.js'; +import { x } from './main4.js'; +import './main3.js'; console.log('1'); diff --git a/test/chunking-form/samples/chunk-execution-order/_expected/es/main2.js b/test/chunking-form/samples/chunk-execution-order/_expected/es/main2.js index 85ab1d519aa..805eb879157 100644 --- a/test/chunking-form/samples/chunk-execution-order/_expected/es/main2.js +++ b/test/chunking-form/samples/chunk-execution-order/_expected/es/main2.js @@ -1,3 +1,4 @@ -import './generated-dep11.js'; -import './generated-dep111.js'; -import './generated-dep112.js'; +import './main3.js'; +import './main4.js'; + +console.log('11'); diff --git a/test/chunking-form/samples/chunk-execution-order/_expected/es/main3.js b/test/chunking-form/samples/chunk-execution-order/_expected/es/main3.js index 7fab442816a..ab8d7e39114 100644 --- a/test/chunking-form/samples/chunk-execution-order/_expected/es/main3.js +++ b/test/chunking-form/samples/chunk-execution-order/_expected/es/main3.js @@ -1 +1 @@ -import './generated-dep111.js'; +console.log('111'); diff --git a/test/chunking-form/samples/chunk-execution-order/_expected/es/main4.js b/test/chunking-form/samples/chunk-execution-order/_expected/es/main4.js index 7d06babc396..a72c32b4c0a 100644 --- a/test/chunking-form/samples/chunk-execution-order/_expected/es/main4.js +++ b/test/chunking-form/samples/chunk-execution-order/_expected/es/main4.js @@ -1 +1,4 @@ -import './generated-dep112.js'; +const x = 0; +console.log('112'); + +export { x }; diff --git a/test/chunking-form/samples/chunk-execution-order/_expected/system/generated-dep11.js b/test/chunking-form/samples/chunk-execution-order/_expected/system/generated-dep11.js deleted file mode 100644 index 639ef3bdbab..00000000000 --- a/test/chunking-form/samples/chunk-execution-order/_expected/system/generated-dep11.js +++ /dev/null @@ -1,11 +0,0 @@ -System.register(['./generated-dep111.js', './generated-dep112.js'], function () { - 'use strict'; - return { - setters: [function () {}, function () {}], - execute: function () { - - console.log('11'); - - } - }; -}); diff --git a/test/chunking-form/samples/chunk-execution-order/_expected/system/generated-dep111.js b/test/chunking-form/samples/chunk-execution-order/_expected/system/generated-dep111.js deleted file mode 100644 index 3f7c0ec4cbd..00000000000 --- a/test/chunking-form/samples/chunk-execution-order/_expected/system/generated-dep111.js +++ /dev/null @@ -1,10 +0,0 @@ -System.register([], function () { - 'use strict'; - return { - execute: function () { - - console.log('111'); - - } - }; -}); diff --git a/test/chunking-form/samples/chunk-execution-order/_expected/system/generated-dep112.js b/test/chunking-form/samples/chunk-execution-order/_expected/system/generated-dep112.js deleted file mode 100644 index 9af2689ddec..00000000000 --- a/test/chunking-form/samples/chunk-execution-order/_expected/system/generated-dep112.js +++ /dev/null @@ -1,11 +0,0 @@ -System.register([], function (exports) { - 'use strict'; - return { - execute: function () { - - const x = exports('x', 0); - console.log('112'); - - } - }; -}); diff --git a/test/chunking-form/samples/chunk-execution-order/_expected/system/main1.js b/test/chunking-form/samples/chunk-execution-order/_expected/system/main1.js index faf8082f0c3..797f64371a1 100644 --- a/test/chunking-form/samples/chunk-execution-order/_expected/system/main1.js +++ b/test/chunking-form/samples/chunk-execution-order/_expected/system/main1.js @@ -1,16 +1,16 @@ -System.register(['./generated-dep11.js', './generated-dep112.js', './generated-dep111.js'], function () { +System.register(['./main2.js', './main4.js', './main3.js'], (function () { 'use strict'; var x; return { - setters: [function () {}, function (module) { + setters: [null, function (module) { x = module.x; - }, function () {}], - execute: function () { + }, null], + execute: (function () { console.log('1'); console.log(x); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/chunk-execution-order/_expected/system/main2.js b/test/chunking-form/samples/chunk-execution-order/_expected/system/main2.js index ce4453cda62..f8f44a795ba 100644 --- a/test/chunking-form/samples/chunk-execution-order/_expected/system/main2.js +++ b/test/chunking-form/samples/chunk-execution-order/_expected/system/main2.js @@ -1,11 +1,11 @@ -System.register(['./generated-dep11.js', './generated-dep111.js', './generated-dep112.js'], function () { +System.register(['./main3.js', './main4.js'], (function () { 'use strict'; return { - setters: [function () {}, function () {}, function () {}], - execute: function () { + setters: [null, null], + execute: (function () { + console.log('11'); - - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/chunk-execution-order/_expected/system/main3.js b/test/chunking-form/samples/chunk-execution-order/_expected/system/main3.js index 84a63039a8d..43f080e2c33 100644 --- a/test/chunking-form/samples/chunk-execution-order/_expected/system/main3.js +++ b/test/chunking-form/samples/chunk-execution-order/_expected/system/main3.js @@ -1,11 +1,10 @@ -System.register(['./generated-dep111.js'], function () { +System.register([], (function () { 'use strict'; return { - setters: [function () {}], - execute: function () { + execute: (function () { + console.log('111'); - - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/chunk-execution-order/_expected/system/main4.js b/test/chunking-form/samples/chunk-execution-order/_expected/system/main4.js index 2ce7e7a8ab3..99cab91eddb 100644 --- a/test/chunking-form/samples/chunk-execution-order/_expected/system/main4.js +++ b/test/chunking-form/samples/chunk-execution-order/_expected/system/main4.js @@ -1,11 +1,11 @@ -System.register(['./generated-dep112.js'], function () { +System.register([], (function (exports) { 'use strict'; return { - setters: [function () {}], - execute: function () { + execute: (function () { + const x = exports("x", 0); + console.log('112'); - - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/chunk-export-deshadowing/_config.js b/test/chunking-form/samples/chunk-export-deshadowing/_config.js index 5301c6b729b..5a9970b0b25 100644 --- a/test/chunking-form/samples/chunk-export-deshadowing/_config.js +++ b/test/chunking-form/samples/chunk-export-deshadowing/_config.js @@ -1,7 +1,7 @@ -module.exports = { +module.exports = defineTest({ description: 'chunk export deshadowing', expectedWarnings: ['CIRCULAR_DEPENDENCY'], options: { input: ['main1.js', 'main2.js'] } -}; +}); diff --git a/test/chunking-form/samples/chunk-export-deshadowing/_expected/amd/generated-dep1.js b/test/chunking-form/samples/chunk-export-deshadowing/_expected/amd/generated-dep1.js index cddd2c6bf79..5c310984650 100644 --- a/test/chunking-form/samples/chunk-export-deshadowing/_expected/amd/generated-dep1.js +++ b/test/chunking-form/samples/chunk-export-deshadowing/_expected/amd/generated-dep1.js @@ -1,4 +1,4 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; function fn$2 () { console.log('lib fn'); @@ -20,4 +20,4 @@ define(['exports'], function (exports) { 'use strict'; exports.fn = fn; exports.fn$1 = fn$1; -}); +})); diff --git a/test/chunking-form/samples/chunk-export-deshadowing/_expected/amd/main1.js b/test/chunking-form/samples/chunk-export-deshadowing/_expected/amd/main1.js index 76c150bb232..e6b4a5d3f9e 100644 --- a/test/chunking-form/samples/chunk-export-deshadowing/_expected/amd/main1.js +++ b/test/chunking-form/samples/chunk-export-deshadowing/_expected/amd/main1.js @@ -1,4 +1,4 @@ -define(['./generated-dep1'], function (dep1) { 'use strict'; +define(['./generated-dep1'], (function (dep1) { 'use strict'; class Main1 { constructor () { @@ -8,4 +8,4 @@ define(['./generated-dep1'], function (dep1) { 'use strict'; return Main1; -}); +})); diff --git a/test/chunking-form/samples/chunk-export-deshadowing/_expected/amd/main2.js b/test/chunking-form/samples/chunk-export-deshadowing/_expected/amd/main2.js index 483ff435cb6..eb0d44bef64 100644 --- a/test/chunking-form/samples/chunk-export-deshadowing/_expected/amd/main2.js +++ b/test/chunking-form/samples/chunk-export-deshadowing/_expected/amd/main2.js @@ -1,4 +1,4 @@ -define(['./generated-dep1'], function (dep1) { 'use strict'; +define(['./generated-dep1'], (function (dep1) { 'use strict'; class Main2 { constructor () { @@ -8,4 +8,4 @@ define(['./generated-dep1'], function (dep1) { 'use strict'; return Main2; -}); +})); diff --git a/test/chunking-form/samples/chunk-export-deshadowing/_expected/es/main1.js b/test/chunking-form/samples/chunk-export-deshadowing/_expected/es/main1.js index d08c5b42593..1a95e5325f9 100644 --- a/test/chunking-form/samples/chunk-export-deshadowing/_expected/es/main1.js +++ b/test/chunking-form/samples/chunk-export-deshadowing/_expected/es/main1.js @@ -6,4 +6,4 @@ class Main1 { } } -export default Main1; +export { Main1 as default }; diff --git a/test/chunking-form/samples/chunk-export-deshadowing/_expected/es/main2.js b/test/chunking-form/samples/chunk-export-deshadowing/_expected/es/main2.js index dc15f820234..96dee8313a6 100644 --- a/test/chunking-form/samples/chunk-export-deshadowing/_expected/es/main2.js +++ b/test/chunking-form/samples/chunk-export-deshadowing/_expected/es/main2.js @@ -6,4 +6,4 @@ class Main2 { } } -export default Main2; +export { Main2 as default }; diff --git a/test/chunking-form/samples/chunk-export-deshadowing/_expected/system/generated-dep1.js b/test/chunking-form/samples/chunk-export-deshadowing/_expected/system/generated-dep1.js index 680a3879893..b3755401f9b 100644 --- a/test/chunking-form/samples/chunk-export-deshadowing/_expected/system/generated-dep1.js +++ b/test/chunking-form/samples/chunk-export-deshadowing/_expected/system/generated-dep1.js @@ -1,7 +1,7 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { exports({ a: fn$1, @@ -25,6 +25,6 @@ System.register([], function (exports) { var text = 'dep2 fn'; - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/chunk-export-deshadowing/_expected/system/main1.js b/test/chunking-form/samples/chunk-export-deshadowing/_expected/system/main1.js index 21a22fa46ea..fc87483d9fa 100644 --- a/test/chunking-form/samples/chunk-export-deshadowing/_expected/system/main1.js +++ b/test/chunking-form/samples/chunk-export-deshadowing/_expected/system/main1.js @@ -1,18 +1,18 @@ -System.register(['./generated-dep1.js'], function (exports) { +System.register(['./generated-dep1.js'], (function (exports) { 'use strict'; var fn; return { setters: [function (module) { fn = module.f; }], - execute: function () { + execute: (function () { class Main1 { constructor () { fn(); } - } exports('default', Main1); + } exports("default", Main1); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/chunk-export-deshadowing/_expected/system/main2.js b/test/chunking-form/samples/chunk-export-deshadowing/_expected/system/main2.js index a105cc04181..d4480417b4f 100644 --- a/test/chunking-form/samples/chunk-export-deshadowing/_expected/system/main2.js +++ b/test/chunking-form/samples/chunk-export-deshadowing/_expected/system/main2.js @@ -1,18 +1,18 @@ -System.register(['./generated-dep1.js'], function (exports) { +System.register(['./generated-dep1.js'], (function (exports) { 'use strict'; var fn; return { setters: [function (module) { fn = module.a; }], - execute: function () { + execute: (function () { class Main2 { constructor () { fn(); } - } exports('default', Main2); + } exports("default", Main2); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/chunk-export-renaming/_config.js b/test/chunking-form/samples/chunk-export-renaming/_config.js index e24d7ae8389..e743bcb4fc0 100644 --- a/test/chunking-form/samples/chunk-export-renaming/_config.js +++ b/test/chunking-form/samples/chunk-export-renaming/_config.js @@ -1,6 +1,6 @@ -module.exports = { +module.exports = defineTest({ description: 'chunk export renaming', options: { input: ['main1.js', 'main2.js'] } -}; +}); diff --git a/test/chunking-form/samples/chunk-export-renaming/_expected/amd/generated-main1.js b/test/chunking-form/samples/chunk-export-renaming/_expected/amd/generated-main1.js new file mode 100644 index 00000000000..260a859fc15 --- /dev/null +++ b/test/chunking-form/samples/chunk-export-renaming/_expected/amd/generated-main1.js @@ -0,0 +1,14 @@ +define(['exports'], (function (exports) { 'use strict'; + + class One { + test() { + return ONE_CONSTANT; + } + } + + const ONE_CONSTANT = 'oneconstant'; + + exports.ONE_CONSTANT = ONE_CONSTANT; + exports.One = One; + +})); diff --git a/test/chunking-form/samples/chunk-export-renaming/_expected/amd/generated-one.js b/test/chunking-form/samples/chunk-export-renaming/_expected/amd/generated-one.js deleted file mode 100644 index c0824cee21b..00000000000 --- a/test/chunking-form/samples/chunk-export-renaming/_expected/amd/generated-one.js +++ /dev/null @@ -1,14 +0,0 @@ -define(['exports'], function (exports) { 'use strict'; - - class One { - test() { - return ONE_CONSTANT; - } - } - - const ONE_CONSTANT = 'oneconstant'; - - exports.ONE_CONSTANT = ONE_CONSTANT; - exports.One = One; - -}); diff --git a/test/chunking-form/samples/chunk-export-renaming/_expected/amd/main1.js b/test/chunking-form/samples/chunk-export-renaming/_expected/amd/main1.js index 18a0182c07a..5a17f385180 100644 --- a/test/chunking-form/samples/chunk-export-renaming/_expected/amd/main1.js +++ b/test/chunking-form/samples/chunk-export-renaming/_expected/amd/main1.js @@ -1,9 +1,7 @@ -define(['exports', './generated-one'], function (exports, one) { 'use strict'; +define(['exports', './generated-main1'], (function (exports, main1) { 'use strict'; - exports.ItemOne = one.One; + exports.ItemOne = main1.One; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/chunk-export-renaming/_expected/amd/main2.js b/test/chunking-form/samples/chunk-export-renaming/_expected/amd/main2.js index 781a4cbc0bb..a04d2b3886e 100644 --- a/test/chunking-form/samples/chunk-export-renaming/_expected/amd/main2.js +++ b/test/chunking-form/samples/chunk-export-renaming/_expected/amd/main2.js @@ -1,13 +1,11 @@ -define(['exports', './generated-one'], function (exports, one) { 'use strict'; +define(['exports', './generated-main1'], (function (exports, main1) { 'use strict'; class Two { test() { - return one.ONE_CONSTANT; + return main1.ONE_CONSTANT; } } exports.ItemTwo = Two; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/chunk-export-renaming/_expected/cjs/generated-one.js b/test/chunking-form/samples/chunk-export-renaming/_expected/cjs/generated-main1.js similarity index 100% rename from test/chunking-form/samples/chunk-export-renaming/_expected/cjs/generated-one.js rename to test/chunking-form/samples/chunk-export-renaming/_expected/cjs/generated-main1.js diff --git a/test/chunking-form/samples/chunk-export-renaming/_expected/cjs/main1.js b/test/chunking-form/samples/chunk-export-renaming/_expected/cjs/main1.js index 357f059b4fd..a691df024c1 100644 --- a/test/chunking-form/samples/chunk-export-renaming/_expected/cjs/main1.js +++ b/test/chunking-form/samples/chunk-export-renaming/_expected/cjs/main1.js @@ -1,9 +1,7 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); +var main1 = require('./generated-main1.js'); -var one = require('./generated-one.js'); - -exports.ItemOne = one.One; +exports.ItemOne = main1.One; diff --git a/test/chunking-form/samples/chunk-export-renaming/_expected/cjs/main2.js b/test/chunking-form/samples/chunk-export-renaming/_expected/cjs/main2.js index d990bcc5d17..b06c4d03648 100644 --- a/test/chunking-form/samples/chunk-export-renaming/_expected/cjs/main2.js +++ b/test/chunking-form/samples/chunk-export-renaming/_expected/cjs/main2.js @@ -1,12 +1,10 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - -var one = require('./generated-one.js'); +var main1 = require('./generated-main1.js'); class Two { test() { - return one.ONE_CONSTANT; + return main1.ONE_CONSTANT; } } diff --git a/test/chunking-form/samples/chunk-export-renaming/_expected/es/generated-main1.js b/test/chunking-form/samples/chunk-export-renaming/_expected/es/generated-main1.js new file mode 100644 index 00000000000..f9b0444b3e4 --- /dev/null +++ b/test/chunking-form/samples/chunk-export-renaming/_expected/es/generated-main1.js @@ -0,0 +1,9 @@ +class One { + test() { + return ONE_CONSTANT; + } +} + +const ONE_CONSTANT = 'oneconstant'; + +export { ONE_CONSTANT as O, One as a }; diff --git a/test/chunking-form/samples/chunk-export-renaming/_expected/es/generated-one.js b/test/chunking-form/samples/chunk-export-renaming/_expected/es/generated-one.js deleted file mode 100644 index 34473c119fa..00000000000 --- a/test/chunking-form/samples/chunk-export-renaming/_expected/es/generated-one.js +++ /dev/null @@ -1,9 +0,0 @@ -class One { - test() { - return ONE_CONSTANT; - } -} - -const ONE_CONSTANT = 'oneconstant'; - -export { One as O, ONE_CONSTANT as a }; diff --git a/test/chunking-form/samples/chunk-export-renaming/_expected/es/main1.js b/test/chunking-form/samples/chunk-export-renaming/_expected/es/main1.js index fe75206da7e..7596598026c 100644 --- a/test/chunking-form/samples/chunk-export-renaming/_expected/es/main1.js +++ b/test/chunking-form/samples/chunk-export-renaming/_expected/es/main1.js @@ -1 +1 @@ -export { O as ItemOne } from './generated-one.js'; +export { a as ItemOne } from './generated-main1.js'; diff --git a/test/chunking-form/samples/chunk-export-renaming/_expected/es/main2.js b/test/chunking-form/samples/chunk-export-renaming/_expected/es/main2.js index fccdd26cf28..e2b3239a134 100644 --- a/test/chunking-form/samples/chunk-export-renaming/_expected/es/main2.js +++ b/test/chunking-form/samples/chunk-export-renaming/_expected/es/main2.js @@ -1,4 +1,4 @@ -import { a as ONE_CONSTANT } from './generated-one.js'; +import { O as ONE_CONSTANT } from './generated-main1.js'; class Two { test() { diff --git a/test/chunking-form/samples/chunk-export-renaming/_expected/system/generated-main1.js b/test/chunking-form/samples/chunk-export-renaming/_expected/system/generated-main1.js new file mode 100644 index 00000000000..83c7accc310 --- /dev/null +++ b/test/chunking-form/samples/chunk-export-renaming/_expected/system/generated-main1.js @@ -0,0 +1,16 @@ +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + + class One { + test() { + return ONE_CONSTANT; + } + } exports("a", One); + + const ONE_CONSTANT = exports("O", 'oneconstant'); + + }) + }; +})); diff --git a/test/chunking-form/samples/chunk-export-renaming/_expected/system/generated-one.js b/test/chunking-form/samples/chunk-export-renaming/_expected/system/generated-one.js deleted file mode 100644 index 68c57590ad1..00000000000 --- a/test/chunking-form/samples/chunk-export-renaming/_expected/system/generated-one.js +++ /dev/null @@ -1,16 +0,0 @@ -System.register([], function (exports) { - 'use strict'; - return { - execute: function () { - - class One { - test() { - return ONE_CONSTANT; - } - } exports('O', One); - - const ONE_CONSTANT = exports('a', 'oneconstant'); - - } - }; -}); diff --git a/test/chunking-form/samples/chunk-export-renaming/_expected/system/main1.js b/test/chunking-form/samples/chunk-export-renaming/_expected/system/main1.js index 4ef53c4cb8c..8ab00910eb0 100644 --- a/test/chunking-form/samples/chunk-export-renaming/_expected/system/main1.js +++ b/test/chunking-form/samples/chunk-export-renaming/_expected/system/main1.js @@ -1,13 +1,13 @@ -System.register(['./generated-one.js'], function (exports) { +System.register(['./generated-main1.js'], (function (exports) { 'use strict'; return { setters: [function (module) { - exports('ItemOne', module.O); + exports("ItemOne", module.a); }], - execute: function () { + execute: (function () { - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/chunk-export-renaming/_expected/system/main2.js b/test/chunking-form/samples/chunk-export-renaming/_expected/system/main2.js index 98c75710b26..6a9ba051dc9 100644 --- a/test/chunking-form/samples/chunk-export-renaming/_expected/system/main2.js +++ b/test/chunking-form/samples/chunk-export-renaming/_expected/system/main2.js @@ -1,18 +1,18 @@ -System.register(['./generated-one.js'], function (exports) { +System.register(['./generated-main1.js'], (function (exports) { 'use strict'; var ONE_CONSTANT; return { setters: [function (module) { - ONE_CONSTANT = module.a; + ONE_CONSTANT = module.O; }], - execute: function () { + execute: (function () { class Two { test() { return ONE_CONSTANT; } - } exports('ItemTwo', Two); + } exports("ItemTwo", Two); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/chunk-import-deshadowing/_config.js b/test/chunking-form/samples/chunk-import-deshadowing/_config.js index 4bfe9e670a7..9b0e303d2ae 100644 --- a/test/chunking-form/samples/chunk-import-deshadowing/_config.js +++ b/test/chunking-form/samples/chunk-import-deshadowing/_config.js @@ -1,6 +1,6 @@ -module.exports = { +module.exports = defineTest({ description: 'chunk import deshadowing', options: { input: ['main1.js', 'main2.js'] } -}; +}); diff --git a/test/chunking-form/samples/chunk-import-deshadowing/_expected/amd/generated-lib.js b/test/chunking-form/samples/chunk-import-deshadowing/_expected/amd/generated-lib.js index ef3191944b8..3dde718704c 100644 --- a/test/chunking-form/samples/chunk-import-deshadowing/_expected/amd/generated-lib.js +++ b/test/chunking-form/samples/chunk-import-deshadowing/_expected/amd/generated-lib.js @@ -1,4 +1,4 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; function emptyFunction() {} @@ -6,4 +6,4 @@ define(['exports'], function (exports) { 'use strict'; exports.emptyFunction = emptyFunction; -}); +})); diff --git a/test/chunking-form/samples/chunk-import-deshadowing/_expected/amd/main1.js b/test/chunking-form/samples/chunk-import-deshadowing/_expected/amd/main1.js index 6489c2c14ca..cf2e853c856 100644 --- a/test/chunking-form/samples/chunk-import-deshadowing/_expected/amd/main1.js +++ b/test/chunking-form/samples/chunk-import-deshadowing/_expected/amd/main1.js @@ -1,4 +1,4 @@ -define(['./generated-lib'], function (lib) { 'use strict'; +define(['./generated-lib'], (function (lib) { 'use strict'; function fn() { var emptyFunction = lib.emptyFunction; @@ -9,4 +9,4 @@ define(['./generated-lib'], function (lib) { 'use strict'; fn(); -}); +})); diff --git a/test/chunking-form/samples/chunk-import-deshadowing/_expected/amd/main2.js b/test/chunking-form/samples/chunk-import-deshadowing/_expected/amd/main2.js index 2bc67f0467a..6c803cf1a3f 100644 --- a/test/chunking-form/samples/chunk-import-deshadowing/_expected/amd/main2.js +++ b/test/chunking-form/samples/chunk-import-deshadowing/_expected/amd/main2.js @@ -1,5 +1,5 @@ -define(['./generated-lib'], function (lib) { 'use strict'; +define(['./generated-lib'], (function (lib) { 'use strict'; console.log('dep2'); -}); +})); diff --git a/test/chunking-form/samples/chunk-import-deshadowing/_expected/system/generated-lib.js b/test/chunking-form/samples/chunk-import-deshadowing/_expected/system/generated-lib.js index 41c5389c2f2..08ebd02ede3 100644 --- a/test/chunking-form/samples/chunk-import-deshadowing/_expected/system/generated-lib.js +++ b/test/chunking-form/samples/chunk-import-deshadowing/_expected/system/generated-lib.js @@ -1,14 +1,14 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - exports('e', emptyFunction); + exports("e", emptyFunction); function emptyFunction() {} console.log('lib'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/chunk-import-deshadowing/_expected/system/main1.js b/test/chunking-form/samples/chunk-import-deshadowing/_expected/system/main1.js index bebccb02e6f..7fb718518ca 100644 --- a/test/chunking-form/samples/chunk-import-deshadowing/_expected/system/main1.js +++ b/test/chunking-form/samples/chunk-import-deshadowing/_expected/system/main1.js @@ -1,11 +1,11 @@ -System.register(['./generated-lib.js'], function () { +System.register(['./generated-lib.js'], (function () { 'use strict'; var emptyFunction; return { setters: [function (module) { emptyFunction = module.e; }], - execute: function () { + execute: (function () { function fn() { var emptyFunction$1 = emptyFunction; @@ -16,6 +16,6 @@ System.register(['./generated-lib.js'], function () { fn(); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/chunk-import-deshadowing/_expected/system/main2.js b/test/chunking-form/samples/chunk-import-deshadowing/_expected/system/main2.js index 67ec6dee448..6388df3d006 100644 --- a/test/chunking-form/samples/chunk-import-deshadowing/_expected/system/main2.js +++ b/test/chunking-form/samples/chunk-import-deshadowing/_expected/system/main2.js @@ -1,11 +1,11 @@ -System.register(['./generated-lib.js'], function () { +System.register(['./generated-lib.js'], (function () { 'use strict'; return { - setters: [function () {}], - execute: function () { + setters: [null], + execute: (function () { console.log('dep2'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/chunk-live-bindings/_config.js b/test/chunking-form/samples/chunk-live-bindings/_config.js index 85aeb5f738b..3fc1fb7b7b8 100644 --- a/test/chunking-form/samples/chunk-live-bindings/_config.js +++ b/test/chunking-form/samples/chunk-live-bindings/_config.js @@ -1,7 +1,7 @@ -module.exports = { +module.exports = defineTest({ description: 'ES module live bindings in chunks', expectedWarnings: ['CIRCULAR_DEPENDENCY'], options: { input: ['main1.js', 'main2.js'] } -}; +}); diff --git a/test/chunking-form/samples/chunk-live-bindings/_expected/amd/generated-dep1.js b/test/chunking-form/samples/chunk-live-bindings/_expected/amd/generated-dep1.js index 1bad95594aa..34410fe561a 100644 --- a/test/chunking-form/samples/chunk-live-bindings/_expected/amd/generated-dep1.js +++ b/test/chunking-form/samples/chunk-live-bindings/_expected/amd/generated-dep1.js @@ -1,4 +1,4 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; function fn$2 () { console.log('lib fn'); @@ -22,4 +22,4 @@ define(['exports'], function (exports) { 'use strict'; exports.fn = fn; exports.fn$1 = fn$1; -}); +})); diff --git a/test/chunking-form/samples/chunk-live-bindings/_expected/amd/main1.js b/test/chunking-form/samples/chunk-live-bindings/_expected/amd/main1.js index 7f1158b9f9b..5753381ad51 100644 --- a/test/chunking-form/samples/chunk-live-bindings/_expected/amd/main1.js +++ b/test/chunking-form/samples/chunk-live-bindings/_expected/amd/main1.js @@ -1,4 +1,4 @@ -define(['./generated-dep1'], function (dep1) { 'use strict'; +define(['./generated-dep1'], (function (dep1) { 'use strict'; class Main1 { constructor () { @@ -9,4 +9,4 @@ define(['./generated-dep1'], function (dep1) { 'use strict'; return Main1; -}); +})); diff --git a/test/chunking-form/samples/chunk-live-bindings/_expected/amd/main2.js b/test/chunking-form/samples/chunk-live-bindings/_expected/amd/main2.js index 82f94dbe2f0..550a968abf7 100644 --- a/test/chunking-form/samples/chunk-live-bindings/_expected/amd/main2.js +++ b/test/chunking-form/samples/chunk-live-bindings/_expected/amd/main2.js @@ -1,4 +1,4 @@ -define(['./generated-dep1'], function (dep1) { 'use strict'; +define(['./generated-dep1'], (function (dep1) { 'use strict'; class Main2 { constructor () { @@ -9,4 +9,4 @@ define(['./generated-dep1'], function (dep1) { 'use strict'; return Main2; -}); +})); diff --git a/test/chunking-form/samples/chunk-live-bindings/_expected/es/main1.js b/test/chunking-form/samples/chunk-live-bindings/_expected/es/main1.js index 4ab6a281f36..9359183629d 100644 --- a/test/chunking-form/samples/chunk-live-bindings/_expected/es/main1.js +++ b/test/chunking-form/samples/chunk-live-bindings/_expected/es/main1.js @@ -7,4 +7,4 @@ class Main1 { } } -export default Main1; +export { Main1 as default }; diff --git a/test/chunking-form/samples/chunk-live-bindings/_expected/es/main2.js b/test/chunking-form/samples/chunk-live-bindings/_expected/es/main2.js index 07b5d8e9ba6..5e6b4eb1b81 100644 --- a/test/chunking-form/samples/chunk-live-bindings/_expected/es/main2.js +++ b/test/chunking-form/samples/chunk-live-bindings/_expected/es/main2.js @@ -7,4 +7,4 @@ class Main2 { } } -export default Main2; +export { Main2 as default }; diff --git a/test/chunking-form/samples/chunk-live-bindings/_expected/system/generated-dep1.js b/test/chunking-form/samples/chunk-live-bindings/_expected/system/generated-dep1.js index b7059895ad0..7437a23a134 100644 --- a/test/chunking-form/samples/chunk-live-bindings/_expected/system/generated-dep1.js +++ b/test/chunking-form/samples/chunk-live-bindings/_expected/system/generated-dep1.js @@ -1,7 +1,7 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { exports({ a: fn$1, @@ -15,18 +15,18 @@ System.register([], function (exports) { function fn$1 () { fn$2(); console.log(text); - text$1 = exports('b', 'dep1 fn after dep2'); + exports("b", text$1 = 'dep1 fn after dep2'); } - var text$1 = exports('b', 'dep1 fn'); + var text$1 = exports("b", 'dep1 fn'); function fn () { console.log(text$1); - text = exports('t', 'dep2 fn after dep1'); + exports("t", text = 'dep2 fn after dep1'); } - var text = exports('t', 'dep2 fn'); + var text = exports("t", 'dep2 fn'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/chunk-live-bindings/_expected/system/main1.js b/test/chunking-form/samples/chunk-live-bindings/_expected/system/main1.js index 4082f2bc13a..9acc62da027 100644 --- a/test/chunking-form/samples/chunk-live-bindings/_expected/system/main1.js +++ b/test/chunking-form/samples/chunk-live-bindings/_expected/system/main1.js @@ -1,4 +1,4 @@ -System.register(['./generated-dep1.js'], function (exports) { +System.register(['./generated-dep1.js'], (function (exports) { 'use strict'; var fn, text; return { @@ -6,15 +6,15 @@ System.register(['./generated-dep1.js'], function (exports) { fn = module.f; text = module.t; }], - execute: function () { + execute: (function () { class Main1 { constructor () { fn(); console.log(text); } - } exports('default', Main1); + } exports("default", Main1); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/chunk-live-bindings/_expected/system/main2.js b/test/chunking-form/samples/chunk-live-bindings/_expected/system/main2.js index d7c6ceee584..b92b9c972d2 100644 --- a/test/chunking-form/samples/chunk-live-bindings/_expected/system/main2.js +++ b/test/chunking-form/samples/chunk-live-bindings/_expected/system/main2.js @@ -1,4 +1,4 @@ -System.register(['./generated-dep1.js'], function (exports) { +System.register(['./generated-dep1.js'], (function (exports) { 'use strict'; var fn, text; return { @@ -6,15 +6,15 @@ System.register(['./generated-dep1.js'], function (exports) { fn = module.a; text = module.b; }], - execute: function () { + execute: (function () { class Main2 { constructor () { fn(); console.log(text); } - } exports('default', Main2); + } exports("default", Main2); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/chunk-namespace-boundary/_config.js b/test/chunking-form/samples/chunk-namespace-boundary/_config.js index 0a1af5188f6..87e946f115a 100644 --- a/test/chunking-form/samples/chunk-namespace-boundary/_config.js +++ b/test/chunking-form/samples/chunk-namespace-boundary/_config.js @@ -1,6 +1,6 @@ -module.exports = { +module.exports = defineTest({ description: 'chunk with a namespace boundary', options: { input: ['main1.js', 'main2.js'] } -}; +}); diff --git a/test/chunking-form/samples/chunk-namespace-boundary/_expected/amd/generated-shared.js b/test/chunking-form/samples/chunk-namespace-boundary/_expected/amd/generated-shared.js index 0464582daaa..0c415a736ae 100644 --- a/test/chunking-form/samples/chunk-namespace-boundary/_expected/amd/generated-shared.js +++ b/test/chunking-form/samples/chunk-namespace-boundary/_expected/amd/generated-shared.js @@ -1,4 +1,4 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; @@ -8,4 +8,4 @@ define(['exports'], function (exports) { 'use strict'; exports.commonjsGlobal = commonjsGlobal; exports.shared = shared; -}); +})); diff --git a/test/chunking-form/samples/chunk-namespace-boundary/_expected/amd/main1.js b/test/chunking-form/samples/chunk-namespace-boundary/_expected/amd/main1.js index a908b157552..e03d9525f5f 100644 --- a/test/chunking-form/samples/chunk-namespace-boundary/_expected/amd/main1.js +++ b/test/chunking-form/samples/chunk-namespace-boundary/_expected/amd/main1.js @@ -1,4 +1,4 @@ -define(['./generated-shared'], function (shared) { 'use strict'; +define(['./generated-shared'], (function (shared) { 'use strict'; shared.commonjsGlobal.fn = d => d + 1; var cjs = shared.commonjsGlobal.fn; @@ -7,4 +7,4 @@ define(['./generated-shared'], function (shared) { 'use strict'; return main1; -}); +})); diff --git a/test/chunking-form/samples/chunk-namespace-boundary/_expected/amd/main2.js b/test/chunking-form/samples/chunk-namespace-boundary/_expected/amd/main2.js index 421ca13fd28..f3a28245b03 100644 --- a/test/chunking-form/samples/chunk-namespace-boundary/_expected/amd/main2.js +++ b/test/chunking-form/samples/chunk-namespace-boundary/_expected/amd/main2.js @@ -1,7 +1,7 @@ -define(['./generated-shared'], function (shared) { 'use strict'; +define(['./generated-shared'], (function (shared) { 'use strict'; var main2 = shared.shared.map(d => d + 2); return main2; -}); +})); diff --git a/test/chunking-form/samples/chunk-namespace-boundary/_expected/es/main1.js b/test/chunking-form/samples/chunk-namespace-boundary/_expected/es/main1.js index c1d90952e9d..fac65c8e84a 100644 --- a/test/chunking-form/samples/chunk-namespace-boundary/_expected/es/main1.js +++ b/test/chunking-form/samples/chunk-namespace-boundary/_expected/es/main1.js @@ -5,4 +5,4 @@ var cjs = commonjsGlobal.fn; var main1 = shared.map(cjs); -export default main1; +export { main1 as default }; diff --git a/test/chunking-form/samples/chunk-namespace-boundary/_expected/es/main2.js b/test/chunking-form/samples/chunk-namespace-boundary/_expected/es/main2.js index 13af1f3fb55..85079115460 100644 --- a/test/chunking-form/samples/chunk-namespace-boundary/_expected/es/main2.js +++ b/test/chunking-form/samples/chunk-namespace-boundary/_expected/es/main2.js @@ -2,4 +2,4 @@ import { s as shared } from './generated-shared.js'; var main2 = shared.map(d => d + 2); -export default main2; +export { main2 as default }; diff --git a/test/chunking-form/samples/chunk-namespace-boundary/_expected/system/generated-shared.js b/test/chunking-form/samples/chunk-namespace-boundary/_expected/system/generated-shared.js index 935f823d325..65996afbdeb 100644 --- a/test/chunking-form/samples/chunk-namespace-boundary/_expected/system/generated-shared.js +++ b/test/chunking-form/samples/chunk-namespace-boundary/_expected/system/generated-shared.js @@ -1,13 +1,13 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - var commonjsGlobal = exports('c', typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}); + var commonjsGlobal = exports("c", typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}); commonjsGlobal.data = [4, 5, 6]; - var shared = exports('s', commonjsGlobal.data); + var shared = exports("s", commonjsGlobal.data); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/chunk-namespace-boundary/_expected/system/main1.js b/test/chunking-form/samples/chunk-namespace-boundary/_expected/system/main1.js index 8be27a05c6d..bbfe5b30d63 100644 --- a/test/chunking-form/samples/chunk-namespace-boundary/_expected/system/main1.js +++ b/test/chunking-form/samples/chunk-namespace-boundary/_expected/system/main1.js @@ -1,4 +1,4 @@ -System.register(['./generated-shared.js'], function (exports) { +System.register(['./generated-shared.js'], (function (exports) { 'use strict'; var commonjsGlobal, shared; return { @@ -6,13 +6,13 @@ System.register(['./generated-shared.js'], function (exports) { commonjsGlobal = module.c; shared = module.s; }], - execute: function () { + execute: (function () { commonjsGlobal.fn = d => d + 1; var cjs = commonjsGlobal.fn; - var main1 = exports('default', shared.map(cjs)); + var main1 = exports("default", shared.map(cjs)); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/chunk-namespace-boundary/_expected/system/main2.js b/test/chunking-form/samples/chunk-namespace-boundary/_expected/system/main2.js index 7230e1091cd..54bad1dde61 100644 --- a/test/chunking-form/samples/chunk-namespace-boundary/_expected/system/main2.js +++ b/test/chunking-form/samples/chunk-namespace-boundary/_expected/system/main2.js @@ -1,14 +1,14 @@ -System.register(['./generated-shared.js'], function (exports) { +System.register(['./generated-shared.js'], (function (exports) { 'use strict'; var shared; return { setters: [function (module) { shared = module.s; }], - execute: function () { + execute: (function () { - var main2 = exports('default', shared.map(d => d + 2)); + var main2 = exports("default", shared.map(d => d + 2)); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/chunk-naming/_config.js b/test/chunking-form/samples/chunk-naming/_config.js index 1c4fa182faa..f7f0e219f43 100644 --- a/test/chunking-form/samples/chunk-naming/_config.js +++ b/test/chunking-form/samples/chunk-naming/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'simple chunking', options: { input: { @@ -10,4 +10,4 @@ module.exports = { chunkFileNames: 'chunks/chunk.js' } } -}; +}); diff --git a/test/chunking-form/samples/chunk-naming/_expected/amd/chunks/chunk.js b/test/chunking-form/samples/chunk-naming/_expected/amd/chunks/chunk.js index adcda74465b..972b13ee121 100644 --- a/test/chunking-form/samples/chunk-naming/_expected/amd/chunks/chunk.js +++ b/test/chunking-form/samples/chunk-naming/_expected/amd/chunks/chunk.js @@ -1,7 +1,7 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; var num = 1; exports.num = num; -}); +})); diff --git a/test/chunking-form/samples/chunk-naming/_expected/amd/chunks/chunk2.js b/test/chunking-form/samples/chunk-naming/_expected/amd/chunks/chunk2.js index a1d8833c67a..76b78a38c0a 100644 --- a/test/chunking-form/samples/chunk-naming/_expected/amd/chunks/chunk2.js +++ b/test/chunking-form/samples/chunk-naming/_expected/amd/chunks/chunk2.js @@ -1,7 +1,7 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; var num = 2; exports.num = num; -}); +})); diff --git a/test/chunking-form/samples/chunk-naming/_expected/amd/chunks/chunk3.js b/test/chunking-form/samples/chunk-naming/_expected/amd/chunks/chunk3.js index 301f565bc07..69a887664de 100644 --- a/test/chunking-form/samples/chunk-naming/_expected/amd/chunks/chunk3.js +++ b/test/chunking-form/samples/chunk-naming/_expected/amd/chunks/chunk3.js @@ -1,7 +1,7 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; var num = 3; exports.num = num; -}); +})); diff --git a/test/chunking-form/samples/chunk-naming/_expected/amd/custom/entryC.js b/test/chunking-form/samples/chunk-naming/_expected/amd/custom/entryC.js index dc61fbfae26..e0ccfd7a805 100644 --- a/test/chunking-form/samples/chunk-naming/_expected/amd/custom/entryC.js +++ b/test/chunking-form/samples/chunk-naming/_expected/amd/custom/entryC.js @@ -1,5 +1,5 @@ -define(['../chunks/chunk', '../chunks/chunk3'], function (dep1, dep3) { 'use strict'; +define(['../chunks/chunk', '../chunks/chunk3'], (function (dep1, dep3) { 'use strict'; console.log(dep1.num + dep3.num); -}); +})); diff --git a/test/chunking-form/samples/chunk-naming/_expected/amd/entryA.js b/test/chunking-form/samples/chunk-naming/_expected/amd/entryA.js index 263d4b3c0ed..3b1c578c959 100644 --- a/test/chunking-form/samples/chunk-naming/_expected/amd/entryA.js +++ b/test/chunking-form/samples/chunk-naming/_expected/amd/entryA.js @@ -1,5 +1,5 @@ -define(['./chunks/chunk', './chunks/chunk2'], function (dep1, dep2) { 'use strict'; +define(['./chunks/chunk', './chunks/chunk2'], (function (dep1, dep2) { 'use strict'; console.log(dep1.num + dep2.num); -}); +})); diff --git a/test/chunking-form/samples/chunk-naming/_expected/amd/entryB.js b/test/chunking-form/samples/chunk-naming/_expected/amd/entryB.js index 2b47f5f6800..901e0a6207c 100644 --- a/test/chunking-form/samples/chunk-naming/_expected/amd/entryB.js +++ b/test/chunking-form/samples/chunk-naming/_expected/amd/entryB.js @@ -1,5 +1,5 @@ -define(['./chunks/chunk2', './chunks/chunk3'], function (dep2, dep3) { 'use strict'; +define(['./chunks/chunk2', './chunks/chunk3'], (function (dep2, dep3) { 'use strict'; console.log(dep2.num + dep3.num); -}); +})); diff --git a/test/chunking-form/samples/chunk-naming/_expected/system/chunks/chunk.js b/test/chunking-form/samples/chunk-naming/_expected/system/chunks/chunk.js index 6f90b945280..6766b5b369e 100644 --- a/test/chunking-form/samples/chunk-naming/_expected/system/chunks/chunk.js +++ b/test/chunking-form/samples/chunk-naming/_expected/system/chunks/chunk.js @@ -1,10 +1,10 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - var num = exports('n', 1); + var num = exports("n", 1); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/chunk-naming/_expected/system/chunks/chunk2.js b/test/chunking-form/samples/chunk-naming/_expected/system/chunks/chunk2.js index cb32055bf44..f200dffc1ed 100644 --- a/test/chunking-form/samples/chunk-naming/_expected/system/chunks/chunk2.js +++ b/test/chunking-form/samples/chunk-naming/_expected/system/chunks/chunk2.js @@ -1,10 +1,10 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - var num = exports('n', 2); + var num = exports("n", 2); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/chunk-naming/_expected/system/chunks/chunk3.js b/test/chunking-form/samples/chunk-naming/_expected/system/chunks/chunk3.js index 77b824db0df..b0a345d9b4e 100644 --- a/test/chunking-form/samples/chunk-naming/_expected/system/chunks/chunk3.js +++ b/test/chunking-form/samples/chunk-naming/_expected/system/chunks/chunk3.js @@ -1,10 +1,10 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - var num = exports('n', 3); + var num = exports("n", 3); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/chunk-naming/_expected/system/custom/entryC.js b/test/chunking-form/samples/chunk-naming/_expected/system/custom/entryC.js index 0ae872b28a0..dccd2b13e22 100644 --- a/test/chunking-form/samples/chunk-naming/_expected/system/custom/entryC.js +++ b/test/chunking-form/samples/chunk-naming/_expected/system/custom/entryC.js @@ -1,4 +1,4 @@ -System.register(['../chunks/chunk.js', '../chunks/chunk3.js'], function () { +System.register(['../chunks/chunk.js', '../chunks/chunk3.js'], (function () { 'use strict'; var num, num$1; return { @@ -7,10 +7,10 @@ System.register(['../chunks/chunk.js', '../chunks/chunk3.js'], function () { }, function (module) { num$1 = module.n; }], - execute: function () { + execute: (function () { console.log(num + num$1); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/chunk-naming/_expected/system/entryA.js b/test/chunking-form/samples/chunk-naming/_expected/system/entryA.js index 1f0441bc93e..a95244123c3 100644 --- a/test/chunking-form/samples/chunk-naming/_expected/system/entryA.js +++ b/test/chunking-form/samples/chunk-naming/_expected/system/entryA.js @@ -1,4 +1,4 @@ -System.register(['./chunks/chunk.js', './chunks/chunk2.js'], function () { +System.register(['./chunks/chunk.js', './chunks/chunk2.js'], (function () { 'use strict'; var num, num$1; return { @@ -7,10 +7,10 @@ System.register(['./chunks/chunk.js', './chunks/chunk2.js'], function () { }, function (module) { num$1 = module.n; }], - execute: function () { + execute: (function () { console.log(num + num$1); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/chunk-naming/_expected/system/entryB.js b/test/chunking-form/samples/chunk-naming/_expected/system/entryB.js index dee75a915fc..5d87f3f0fcb 100644 --- a/test/chunking-form/samples/chunk-naming/_expected/system/entryB.js +++ b/test/chunking-form/samples/chunk-naming/_expected/system/entryB.js @@ -1,4 +1,4 @@ -System.register(['./chunks/chunk2.js', './chunks/chunk3.js'], function () { +System.register(['./chunks/chunk2.js', './chunks/chunk3.js'], (function () { 'use strict'; var num, num$1; return { @@ -7,10 +7,10 @@ System.register(['./chunks/chunk2.js', './chunks/chunk3.js'], function () { }, function (module) { num$1 = module.n; }], - execute: function () { + execute: (function () { console.log(num + num$1); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/chunk-variable-name-conflict/_config.js b/test/chunking-form/samples/chunk-variable-name-conflict/_config.js index bded69227e6..2d3898b4196 100644 --- a/test/chunking-form/samples/chunk-variable-name-conflict/_config.js +++ b/test/chunking-form/samples/chunk-variable-name-conflict/_config.js @@ -1,6 +1,6 @@ -module.exports = { +module.exports = defineTest({ description: 'chunk variable name conflict', options: { input: ['main1.js', 'main2.js'] } -}; +}); diff --git a/test/chunking-form/samples/chunk-variable-name-conflict/_expected/amd/generated-dep.js b/test/chunking-form/samples/chunk-variable-name-conflict/_expected/amd/generated-dep.js index 27508b4e569..425c1f65e7b 100644 --- a/test/chunking-form/samples/chunk-variable-name-conflict/_expected/amd/generated-dep.js +++ b/test/chunking-form/samples/chunk-variable-name-conflict/_expected/amd/generated-dep.js @@ -1,4 +1,4 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; var value = 42; const x = 3; @@ -6,4 +6,4 @@ define(['exports'], function (exports) { 'use strict'; exports.value = value; exports.x = x; -}); +})); diff --git a/test/chunking-form/samples/chunk-variable-name-conflict/_expected/amd/main1.js b/test/chunking-form/samples/chunk-variable-name-conflict/_expected/amd/main1.js index b5ec063a056..883f67fcdb4 100644 --- a/test/chunking-form/samples/chunk-variable-name-conflict/_expected/amd/main1.js +++ b/test/chunking-form/samples/chunk-variable-name-conflict/_expected/amd/main1.js @@ -1,5 +1,5 @@ -define(['./generated-dep'], function (dep) { 'use strict'; +define(['./generated-dep'], (function (dep) { 'use strict'; [43].map(dep$1 => console.log(dep$1, dep.value, dep.x)); -}); +})); diff --git a/test/chunking-form/samples/chunk-variable-name-conflict/_expected/amd/main2.js b/test/chunking-form/samples/chunk-variable-name-conflict/_expected/amd/main2.js index dfbe4d1c21e..9fd4f22c21d 100644 --- a/test/chunking-form/samples/chunk-variable-name-conflict/_expected/amd/main2.js +++ b/test/chunking-form/samples/chunk-variable-name-conflict/_expected/amd/main2.js @@ -1,6 +1,6 @@ -define(['./generated-dep'], function (dep$1) { 'use strict'; +define(['./generated-dep'], (function (dep$1) { 'use strict'; var dep = 44; console.log(dep, dep$1.value); -}); +})); diff --git a/test/chunking-form/samples/chunk-variable-name-conflict/_expected/system/generated-dep.js b/test/chunking-form/samples/chunk-variable-name-conflict/_expected/system/generated-dep.js index d48918f6dca..4a1664ee290 100644 --- a/test/chunking-form/samples/chunk-variable-name-conflict/_expected/system/generated-dep.js +++ b/test/chunking-form/samples/chunk-variable-name-conflict/_expected/system/generated-dep.js @@ -1,11 +1,11 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - var value = exports('v', 42); - const x = exports('x', 3); + var value = exports("v", 42); + const x = exports("x", 3); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/chunk-variable-name-conflict/_expected/system/main1.js b/test/chunking-form/samples/chunk-variable-name-conflict/_expected/system/main1.js index c3a57d0d021..91d07818245 100644 --- a/test/chunking-form/samples/chunk-variable-name-conflict/_expected/system/main1.js +++ b/test/chunking-form/samples/chunk-variable-name-conflict/_expected/system/main1.js @@ -1,4 +1,4 @@ -System.register(['./generated-dep.js'], function () { +System.register(['./generated-dep.js'], (function () { 'use strict'; var value, x; return { @@ -6,10 +6,10 @@ System.register(['./generated-dep.js'], function () { value = module.v; x = module.x; }], - execute: function () { + execute: (function () { [43].map(dep => console.log(dep, value, x)); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/chunk-variable-name-conflict/_expected/system/main2.js b/test/chunking-form/samples/chunk-variable-name-conflict/_expected/system/main2.js index ab8d56f3a9a..3322223cc10 100644 --- a/test/chunking-form/samples/chunk-variable-name-conflict/_expected/system/main2.js +++ b/test/chunking-form/samples/chunk-variable-name-conflict/_expected/system/main2.js @@ -1,15 +1,15 @@ -System.register(['./generated-dep.js'], function () { +System.register(['./generated-dep.js'], (function () { 'use strict'; var value; return { setters: [function (module) { value = module.v; }], - execute: function () { + execute: (function () { var dep = 44; console.log(dep, value); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/chunking-compact/_config.js b/test/chunking-form/samples/chunking-compact/_config.js index 341b669ef2f..407e02c1727 100644 --- a/test/chunking-form/samples/chunking-compact/_config.js +++ b/test/chunking-form/samples/chunking-compact/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'chunking compact and mangled output', options: { input: ['main1.js', 'main2.js'], @@ -7,4 +7,4 @@ module.exports = { compact: true } } -}; +}); diff --git a/test/chunking-form/samples/chunking-compact/_expected/amd/generated-dep2.js b/test/chunking-form/samples/chunking-compact/_expected/amd/generated-dep2.js index 306ef4cb391..44642c46678 100644 --- a/test/chunking-form/samples/chunking-compact/_expected/amd/generated-dep2.js +++ b/test/chunking-form/samples/chunking-compact/_expected/amd/generated-dep2.js @@ -1,6 +1,6 @@ -define(['exports'],function(exports){'use strict';function fn$1 () { +define(['exports'],(function(exports){'use strict';function fn$1 () { console.log('lib2 fn'); }function fn () { fn$1(); console.log('dep2 fn'); -}exports.f=fn;}); \ No newline at end of file +}exports.f=fn;})); \ No newline at end of file diff --git a/test/chunking-form/samples/chunking-compact/_expected/amd/main1.js b/test/chunking-form/samples/chunking-compact/_expected/amd/main1.js index 56ee749a02b..18456b174f6 100644 --- a/test/chunking-form/samples/chunking-compact/_expected/amd/main1.js +++ b/test/chunking-form/samples/chunking-compact/_expected/amd/main1.js @@ -1,8 +1,8 @@ -define(['./generated-dep2'],function(dep2){'use strict';function fn () { +define(['./generated-dep2'],(function(dep2){'use strict';function fn () { console.log('dep1 fn'); }class Main1 { constructor () { fn(); dep2.f(); } -}return Main1;}); \ No newline at end of file +}return Main1;})); \ No newline at end of file diff --git a/test/chunking-form/samples/chunking-compact/_expected/amd/main2.js b/test/chunking-form/samples/chunking-compact/_expected/amd/main2.js index 7e213ea3600..692f3c158e2 100644 --- a/test/chunking-form/samples/chunking-compact/_expected/amd/main2.js +++ b/test/chunking-form/samples/chunking-compact/_expected/amd/main2.js @@ -1,4 +1,4 @@ -define(['./generated-dep2','external'],function(dep2,external){'use strict';function fn$1 () { +define(['./generated-dep2','external'],(function(dep2,external){'use strict';function fn$1 () { console.log('lib1 fn'); external.fn(); }function fn () { @@ -9,4 +9,4 @@ define(['./generated-dep2','external'],function(dep2,external){'use strict';func fn(); dep2.f(); } -}return Main2;}); \ No newline at end of file +}return Main2;})); \ No newline at end of file diff --git a/test/chunking-form/samples/chunking-compact/_expected/es/main1.js b/test/chunking-form/samples/chunking-compact/_expected/es/main1.js index b761b539ad2..eb401d6b2ba 100644 --- a/test/chunking-form/samples/chunking-compact/_expected/es/main1.js +++ b/test/chunking-form/samples/chunking-compact/_expected/es/main1.js @@ -5,4 +5,4 @@ import {f as fn$1}from'./generated-dep2.js';function fn () { fn(); fn$1(); } -}export default Main1; \ No newline at end of file +}export{Main1 as default}; \ No newline at end of file diff --git a/test/chunking-form/samples/chunking-compact/_expected/es/main2.js b/test/chunking-form/samples/chunking-compact/_expected/es/main2.js index 2cf11d86262..96f500f0236 100644 --- a/test/chunking-form/samples/chunking-compact/_expected/es/main2.js +++ b/test/chunking-form/samples/chunking-compact/_expected/es/main2.js @@ -9,4 +9,4 @@ import {f as fn$3}from'./generated-dep2.js';import {fn as fn$2}from'external';fu fn(); fn$3(); } -}export default Main2; \ No newline at end of file +}export{Main2 as default}; \ No newline at end of file diff --git a/test/chunking-form/samples/chunking-compact/_expected/system/generated-dep2.js b/test/chunking-form/samples/chunking-compact/_expected/system/generated-dep2.js index 49605653920..028923d158c 100644 --- a/test/chunking-form/samples/chunking-compact/_expected/system/generated-dep2.js +++ b/test/chunking-form/samples/chunking-compact/_expected/system/generated-dep2.js @@ -1,6 +1,6 @@ -System.register([],function(exports){'use strict';return{execute:function(){exports('f',fn);function fn$1 () { +System.register([],(function(exports){'use strict';return{execute:(function(){exports("f",fn);function fn$1 () { console.log('lib2 fn'); }function fn () { fn$1(); console.log('dep2 fn'); -}}}}); \ No newline at end of file +}})}})); \ No newline at end of file diff --git a/test/chunking-form/samples/chunking-compact/_expected/system/main1.js b/test/chunking-form/samples/chunking-compact/_expected/system/main1.js index f4ad7db0404..892d5538e8a 100644 --- a/test/chunking-form/samples/chunking-compact/_expected/system/main1.js +++ b/test/chunking-form/samples/chunking-compact/_expected/system/main1.js @@ -1,8 +1,8 @@ -System.register(['./generated-dep2.js'],function(exports){'use strict';var fn$1;return{setters:[function(module){fn$1=module.f;}],execute:function(){function fn () { +System.register(['./generated-dep2.js'],(function(exports){'use strict';var fn$1;return{setters:[function(module){fn$1=module.f;}],execute:(function(){function fn () { console.log('dep1 fn'); }class Main1 { constructor () { fn(); fn$1(); } -}exports('default',Main1);}}}); \ No newline at end of file +}exports("default",Main1);})}})); \ No newline at end of file diff --git a/test/chunking-form/samples/chunking-compact/_expected/system/main2.js b/test/chunking-form/samples/chunking-compact/_expected/system/main2.js index 082b46ef0af..b63e66fdbf9 100644 --- a/test/chunking-form/samples/chunking-compact/_expected/system/main2.js +++ b/test/chunking-form/samples/chunking-compact/_expected/system/main2.js @@ -1,4 +1,4 @@ -System.register(['./generated-dep2.js','external'],function(exports){'use strict';var fn$3,fn$2;return{setters:[function(module){fn$3=module.f;},function(module){fn$2=module.fn;}],execute:function(){function fn$1 () { +System.register(['./generated-dep2.js','external'],(function(exports){'use strict';var fn$3,fn$2;return{setters:[function(module){fn$3=module.f;},function(module){fn$2=module.fn;}],execute:(function(){function fn$1 () { console.log('lib1 fn'); fn$2(); }function fn () { @@ -9,4 +9,4 @@ System.register(['./generated-dep2.js','external'],function(exports){'use strict fn(); fn$3(); } -}exports('default',Main2);}}}); \ No newline at end of file +}exports("default",Main2);})}})); \ No newline at end of file diff --git a/test/chunking-form/samples/chunking-externals/_config.js b/test/chunking-form/samples/chunking-externals/_config.js index 31a37faf7e6..f2630b5a279 100644 --- a/test/chunking-form/samples/chunking-externals/_config.js +++ b/test/chunking-form/samples/chunking-externals/_config.js @@ -1,7 +1,7 @@ -module.exports = { +module.exports = defineTest({ description: 'chunking external module handling', options: { input: ['main1.js', 'main2.js'], external: ['external'] } -}; +}); diff --git a/test/chunking-form/samples/chunking-externals/_expected/amd/generated-dep2.js b/test/chunking-form/samples/chunking-externals/_expected/amd/generated-dep2.js index f49e0094590..6dfaa8d5698 100644 --- a/test/chunking-form/samples/chunking-externals/_expected/amd/generated-dep2.js +++ b/test/chunking-form/samples/chunking-externals/_expected/amd/generated-dep2.js @@ -1,4 +1,4 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; function fn$1 () { console.log('lib2 fn'); @@ -11,4 +11,4 @@ define(['exports'], function (exports) { 'use strict'; exports.fn = fn; -}); +})); diff --git a/test/chunking-form/samples/chunking-externals/_expected/amd/main1.js b/test/chunking-form/samples/chunking-externals/_expected/amd/main1.js index ab0a692d55b..97cc8e638d1 100644 --- a/test/chunking-form/samples/chunking-externals/_expected/amd/main1.js +++ b/test/chunking-form/samples/chunking-externals/_expected/amd/main1.js @@ -1,4 +1,4 @@ -define(['./generated-dep2'], function (dep2) { 'use strict'; +define(['./generated-dep2'], (function (dep2) { 'use strict'; function fn () { console.log('dep1 fn'); @@ -13,4 +13,4 @@ define(['./generated-dep2'], function (dep2) { 'use strict'; return Main1; -}); +})); diff --git a/test/chunking-form/samples/chunking-externals/_expected/amd/main2.js b/test/chunking-form/samples/chunking-externals/_expected/amd/main2.js index 60066323ee2..6c0cafb0959 100644 --- a/test/chunking-form/samples/chunking-externals/_expected/amd/main2.js +++ b/test/chunking-form/samples/chunking-externals/_expected/amd/main2.js @@ -1,4 +1,4 @@ -define(['./generated-dep2', 'external'], function (dep2, external) { 'use strict'; +define(['./generated-dep2', 'external'], (function (dep2, external) { 'use strict'; function fn$1 () { console.log('lib1 fn'); @@ -19,4 +19,4 @@ define(['./generated-dep2', 'external'], function (dep2, external) { 'use strict return Main2; -}); +})); diff --git a/test/chunking-form/samples/chunking-externals/_expected/es/main1.js b/test/chunking-form/samples/chunking-externals/_expected/es/main1.js index f2e4ef52928..c5a66ab8a40 100644 --- a/test/chunking-form/samples/chunking-externals/_expected/es/main1.js +++ b/test/chunking-form/samples/chunking-externals/_expected/es/main1.js @@ -11,4 +11,4 @@ class Main1 { } } -export default Main1; +export { Main1 as default }; diff --git a/test/chunking-form/samples/chunking-externals/_expected/es/main2.js b/test/chunking-form/samples/chunking-externals/_expected/es/main2.js index 8080906328a..9c840b20316 100644 --- a/test/chunking-form/samples/chunking-externals/_expected/es/main2.js +++ b/test/chunking-form/samples/chunking-externals/_expected/es/main2.js @@ -18,4 +18,4 @@ class Main2 { } } -export default Main2; +export { Main2 as default }; diff --git a/test/chunking-form/samples/chunking-externals/_expected/system/generated-dep2.js b/test/chunking-form/samples/chunking-externals/_expected/system/generated-dep2.js index c86d9b47682..94fa4559204 100644 --- a/test/chunking-form/samples/chunking-externals/_expected/system/generated-dep2.js +++ b/test/chunking-form/samples/chunking-externals/_expected/system/generated-dep2.js @@ -1,9 +1,9 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - exports('f', fn); + exports("f", fn); function fn$1 () { console.log('lib2 fn'); @@ -14,6 +14,6 @@ System.register([], function (exports) { console.log('dep2 fn'); } - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/chunking-externals/_expected/system/main1.js b/test/chunking-form/samples/chunking-externals/_expected/system/main1.js index 287fda7c0e7..c849f2ae044 100644 --- a/test/chunking-form/samples/chunking-externals/_expected/system/main1.js +++ b/test/chunking-form/samples/chunking-externals/_expected/system/main1.js @@ -1,11 +1,11 @@ -System.register(['./generated-dep2.js'], function (exports) { +System.register(['./generated-dep2.js'], (function (exports) { 'use strict'; var fn$1; return { setters: [function (module) { fn$1 = module.f; }], - execute: function () { + execute: (function () { function fn () { console.log('dep1 fn'); @@ -16,8 +16,8 @@ System.register(['./generated-dep2.js'], function (exports) { fn(); fn$1(); } - } exports('default', Main1); + } exports("default", Main1); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/chunking-externals/_expected/system/main2.js b/test/chunking-form/samples/chunking-externals/_expected/system/main2.js index f24c7c8cd43..40892cc3b5d 100644 --- a/test/chunking-form/samples/chunking-externals/_expected/system/main2.js +++ b/test/chunking-form/samples/chunking-externals/_expected/system/main2.js @@ -1,4 +1,4 @@ -System.register(['./generated-dep2.js', 'external'], function (exports) { +System.register(['./generated-dep2.js', 'external'], (function (exports) { 'use strict'; var fn$3, fn$2; return { @@ -7,7 +7,7 @@ System.register(['./generated-dep2.js', 'external'], function (exports) { }, function (module) { fn$2 = module.fn; }], - execute: function () { + execute: (function () { function fn$1 () { console.log('lib1 fn'); @@ -24,8 +24,8 @@ System.register(['./generated-dep2.js', 'external'], function (exports) { fn(); fn$3(); } - } exports('default', Main2); + } exports("default", Main2); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/chunking-reexport/_config.js b/test/chunking-form/samples/chunking-reexport/_config.js index 19248895def..ad213495366 100644 --- a/test/chunking-form/samples/chunking-reexport/_config.js +++ b/test/chunking-form/samples/chunking-reexport/_config.js @@ -1,7 +1,7 @@ -module.exports = { +module.exports = defineTest({ description: 'chunking star external', options: { input: ['main1.js', 'main2.js'], external: ['external'] } -}; +}); diff --git a/test/chunking-form/samples/chunking-reexport/_expected/amd/generated-dep.js b/test/chunking-form/samples/chunking-reexport/_expected/amd/generated-dep.js deleted file mode 100644 index f906bb861ce..00000000000 --- a/test/chunking-form/samples/chunking-reexport/_expected/amd/generated-dep.js +++ /dev/null @@ -1,5 +0,0 @@ -define(['external'], function (external) { 'use strict'; - - console.log('dep'); - -}); diff --git a/test/chunking-form/samples/chunking-reexport/_expected/amd/main1.js b/test/chunking-form/samples/chunking-reexport/_expected/amd/main1.js index 01e41b3d04f..e43349836e4 100644 --- a/test/chunking-form/samples/chunking-reexport/_expected/amd/main1.js +++ b/test/chunking-form/samples/chunking-reexport/_expected/amd/main1.js @@ -1,14 +1,10 @@ -define(['exports', './generated-dep', 'external'], function (exports, dep, external) { 'use strict'; +define(['exports', 'external'], (function (exports, external) { 'use strict'; + console.log('dep'); - - Object.defineProperty(exports, 'dep', { + Object.defineProperty(exports, "dep", { enumerable: true, - get: function () { - return external.asdf; - } + get: function () { return external.asdf; } }); - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/chunking-reexport/_expected/amd/main2.js b/test/chunking-form/samples/chunking-reexport/_expected/amd/main2.js index 01e41b3d04f..578464cd4ba 100644 --- a/test/chunking-form/samples/chunking-reexport/_expected/amd/main2.js +++ b/test/chunking-form/samples/chunking-reexport/_expected/amd/main2.js @@ -1,14 +1,10 @@ -define(['exports', './generated-dep', 'external'], function (exports, dep, external) { 'use strict'; +define(['exports', './main1', 'external'], (function (exports, main1, external) { 'use strict'; - Object.defineProperty(exports, 'dep', { + Object.defineProperty(exports, "dep", { enumerable: true, - get: function () { - return external.asdf; - } + get: function () { return external.asdf; } }); - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/chunking-reexport/_expected/cjs/generated-dep.js b/test/chunking-form/samples/chunking-reexport/_expected/cjs/generated-dep.js deleted file mode 100644 index 0d3516434e6..00000000000 --- a/test/chunking-form/samples/chunking-reexport/_expected/cjs/generated-dep.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -require('external'); - -console.log('dep'); diff --git a/test/chunking-form/samples/chunking-reexport/_expected/cjs/main1.js b/test/chunking-form/samples/chunking-reexport/_expected/cjs/main1.js index c12bad5371c..f12c9787bd9 100644 --- a/test/chunking-form/samples/chunking-reexport/_expected/cjs/main1.js +++ b/test/chunking-form/samples/chunking-reexport/_expected/cjs/main1.js @@ -1,15 +1,10 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - -require('./generated-dep.js'); var external = require('external'); +console.log('dep'); - -Object.defineProperty(exports, 'dep', { +Object.defineProperty(exports, "dep", { enumerable: true, - get: function () { - return external.asdf; - } + get: function () { return external.asdf; } }); diff --git a/test/chunking-form/samples/chunking-reexport/_expected/cjs/main2.js b/test/chunking-form/samples/chunking-reexport/_expected/cjs/main2.js index c12bad5371c..711fd4fedee 100644 --- a/test/chunking-form/samples/chunking-reexport/_expected/cjs/main2.js +++ b/test/chunking-form/samples/chunking-reexport/_expected/cjs/main2.js @@ -1,15 +1,11 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - -require('./generated-dep.js'); +require('./main1.js'); var external = require('external'); -Object.defineProperty(exports, 'dep', { +Object.defineProperty(exports, "dep", { enumerable: true, - get: function () { - return external.asdf; - } + get: function () { return external.asdf; } }); diff --git a/test/chunking-form/samples/chunking-reexport/_expected/es/generated-dep.js b/test/chunking-form/samples/chunking-reexport/_expected/es/generated-dep.js deleted file mode 100644 index 12514a3e503..00000000000 --- a/test/chunking-form/samples/chunking-reexport/_expected/es/generated-dep.js +++ /dev/null @@ -1,3 +0,0 @@ -import 'external'; - -console.log('dep'); diff --git a/test/chunking-form/samples/chunking-reexport/_expected/es/main1.js b/test/chunking-form/samples/chunking-reexport/_expected/es/main1.js index d751b5a173c..9f0b3a911d6 100644 --- a/test/chunking-form/samples/chunking-reexport/_expected/es/main1.js +++ b/test/chunking-form/samples/chunking-reexport/_expected/es/main1.js @@ -1,2 +1,3 @@ -import './generated-dep.js'; export { asdf as dep } from 'external'; + +console.log('dep'); diff --git a/test/chunking-form/samples/chunking-reexport/_expected/es/main2.js b/test/chunking-form/samples/chunking-reexport/_expected/es/main2.js index d751b5a173c..b6b84205109 100644 --- a/test/chunking-form/samples/chunking-reexport/_expected/es/main2.js +++ b/test/chunking-form/samples/chunking-reexport/_expected/es/main2.js @@ -1,2 +1,2 @@ -import './generated-dep.js'; +import './main1.js'; export { asdf as dep } from 'external'; diff --git a/test/chunking-form/samples/chunking-reexport/_expected/system/generated-dep.js b/test/chunking-form/samples/chunking-reexport/_expected/system/generated-dep.js deleted file mode 100644 index fb314b87d49..00000000000 --- a/test/chunking-form/samples/chunking-reexport/_expected/system/generated-dep.js +++ /dev/null @@ -1,11 +0,0 @@ -System.register(['external'], function () { - 'use strict'; - return { - setters: [function () {}], - execute: function () { - - console.log('dep'); - - } - }; -}); diff --git a/test/chunking-form/samples/chunking-reexport/_expected/system/main1.js b/test/chunking-form/samples/chunking-reexport/_expected/system/main1.js index 91fd8399052..ababa43497f 100644 --- a/test/chunking-form/samples/chunking-reexport/_expected/system/main1.js +++ b/test/chunking-form/samples/chunking-reexport/_expected/system/main1.js @@ -1,13 +1,13 @@ -System.register(['./generated-dep.js', 'external'], function (exports) { +System.register(['external'], (function (exports) { 'use strict'; return { - setters: [function () {}, function (module) { - exports('dep', module.asdf); + setters: [function (module) { + exports("dep", module.asdf); }], - execute: function () { + execute: (function () { + console.log('dep'); - - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/chunking-reexport/_expected/system/main2.js b/test/chunking-form/samples/chunking-reexport/_expected/system/main2.js index 91fd8399052..22bde20d0ad 100644 --- a/test/chunking-form/samples/chunking-reexport/_expected/system/main2.js +++ b/test/chunking-form/samples/chunking-reexport/_expected/system/main2.js @@ -1,13 +1,13 @@ -System.register(['./generated-dep.js', 'external'], function (exports) { +System.register(['./main1.js', 'external'], (function (exports) { 'use strict'; return { - setters: [function () {}, function (module) { - exports('dep', module.asdf); + setters: [null, function (module) { + exports("dep", module.asdf); }], - execute: function () { + execute: (function () { - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/chunking-source-maps/_config.js b/test/chunking-form/samples/chunking-source-maps/_config.js index 172d5f652b0..b3272e3c679 100644 --- a/test/chunking-form/samples/chunking-source-maps/_config.js +++ b/test/chunking-form/samples/chunking-source-maps/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'source maps', options: { input: ['main1.js', 'main2.js'], @@ -6,4 +6,4 @@ module.exports = { sourcemap: true } } -}; +}); diff --git a/test/chunking-form/samples/chunking-source-maps/_expected/amd/generated-dep2.js b/test/chunking-form/samples/chunking-source-maps/_expected/amd/generated-dep2.js index e6264bae1bf..aa672d6498e 100644 --- a/test/chunking-form/samples/chunking-source-maps/_expected/amd/generated-dep2.js +++ b/test/chunking-form/samples/chunking-source-maps/_expected/amd/generated-dep2.js @@ -1,4 +1,4 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; function fn$1 () { console.log('lib2 fn'); @@ -11,5 +11,5 @@ define(['exports'], function (exports) { 'use strict'; exports.fn = fn; -}); +})); //# sourceMappingURL=generated-dep2.js.map diff --git a/test/chunking-form/samples/chunking-source-maps/_expected/amd/generated-dep2.js.map b/test/chunking-form/samples/chunking-source-maps/_expected/amd/generated-dep2.js.map index e4aa8e0d8ec..9883dddb764 100644 --- a/test/chunking-form/samples/chunking-source-maps/_expected/amd/generated-dep2.js.map +++ b/test/chunking-form/samples/chunking-source-maps/_expected/amd/generated-dep2.js.map @@ -1 +1 @@ -{"version":3,"file":"generated-dep2.js","sources":["../../lib2.js","../../dep2.js"],"sourcesContent":["export function fn () {\n console.log('lib2 fn');\n}","import { fn as libfn } from './lib2.js';\n\nexport function fn () {\n libfn();\n console.log('dep2 fn');\n}"],"names":["fn","libfn"],"mappings":";;EAAO,SAASA,IAAE,IAAI;EACtB,EAAE,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;EACzB;;ECAO,SAAS,EAAE,IAAI;EACtB,EAAEC,IAAK,EAAE,CAAC;EACV,EAAE,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;EACzB;;;;;;;;"} \ No newline at end of file +{"version":3,"file":"generated-dep2.js","sources":["../../lib2.js","../../dep2.js"],"sourcesContent":["export function fn () {\n console.log('lib2 fn');\n}","import { fn as libfn } from './lib2.js';\n\nexport function fn () {\n libfn();\n console.log('dep2 fn');\n}"],"names":["fn","libfn"],"mappings":";;EAAO,SAASA,IAAE,IAAI;EACtB,EAAE,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC;EACxB;;ECAO,SAAS,EAAE,IAAI;EACtB,EAAEC,IAAK,EAAE;EACT,EAAE,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC;EACxB;;;;;;;;"} \ No newline at end of file diff --git a/test/chunking-form/samples/chunking-source-maps/_expected/amd/main1.js b/test/chunking-form/samples/chunking-source-maps/_expected/amd/main1.js index 81c55bbb6dd..5f7c157a307 100644 --- a/test/chunking-form/samples/chunking-source-maps/_expected/amd/main1.js +++ b/test/chunking-form/samples/chunking-source-maps/_expected/amd/main1.js @@ -1,4 +1,4 @@ -define(['./generated-dep2'], function (dep2) { 'use strict'; +define(['./generated-dep2'], (function (dep2) { 'use strict'; function fn () { console.log('dep1 fn'); @@ -13,5 +13,5 @@ define(['./generated-dep2'], function (dep2) { 'use strict'; return Main1; -}); +})); //# sourceMappingURL=main1.js.map diff --git a/test/chunking-form/samples/chunking-source-maps/_expected/amd/main1.js.map b/test/chunking-form/samples/chunking-source-maps/_expected/amd/main1.js.map index aa0106569e2..f6ef4e680e1 100644 --- a/test/chunking-form/samples/chunking-source-maps/_expected/amd/main1.js.map +++ b/test/chunking-form/samples/chunking-source-maps/_expected/amd/main1.js.map @@ -1 +1 @@ -{"version":3,"file":"main1.js","sources":["../../dep1.js","../../main1.js"],"sourcesContent":["export function fn () {\n console.log('dep1 fn');\n}","import { fn } from './dep1.js';\nimport { fn as fn2 } from './dep2.js';\n\nexport default class Main1 {\n constructor () {\n fn();\n fn2();\n }\n}"],"names":["fn2"],"mappings":";;EAAO,SAAS,EAAE,IAAI;EACtB,EAAE,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;EACzB;;ECCe,MAAM,KAAK,CAAC;EAC3B,EAAE,WAAW,CAAC,GAAG;EACjB,IAAI,EAAE,EAAE,CAAC;EACT,IAAIA,OAAG,EAAE,CAAC;EACV,GAAG;EACH;;;;;;;;"} \ No newline at end of file +{"version":3,"file":"main1.js","sources":["../../dep1.js","../../main1.js"],"sourcesContent":["export function fn () {\n console.log('dep1 fn');\n}","import { fn } from './dep1.js';\nimport { fn as fn2 } from './dep2.js';\n\nexport default class Main1 {\n constructor () {\n fn();\n fn2();\n }\n}"],"names":["fn2"],"mappings":";;EAAO,SAAS,EAAE,IAAI;EACtB,EAAE,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC;EACxB;;ECCe,MAAM,KAAK,CAAC;EAC3B,EAAE,WAAW,CAAC,GAAG;EACjB,IAAI,EAAE,EAAE;EACR,IAAIA,OAAG,EAAE;EACT,EAAE;EACF;;;;;;;;"} \ No newline at end of file diff --git a/test/chunking-form/samples/chunking-source-maps/_expected/amd/main2.js b/test/chunking-form/samples/chunking-source-maps/_expected/amd/main2.js index 301efcfcd46..542db76a7a7 100644 --- a/test/chunking-form/samples/chunking-source-maps/_expected/amd/main2.js +++ b/test/chunking-form/samples/chunking-source-maps/_expected/amd/main2.js @@ -1,4 +1,4 @@ -define(['./generated-dep2'], function (dep2) { 'use strict'; +define(['./generated-dep2'], (function (dep2) { 'use strict'; function fn$1 () { console.log('lib1 fn'); @@ -18,5 +18,5 @@ define(['./generated-dep2'], function (dep2) { 'use strict'; return Main2; -}); +})); //# sourceMappingURL=main2.js.map diff --git a/test/chunking-form/samples/chunking-source-maps/_expected/amd/main2.js.map b/test/chunking-form/samples/chunking-source-maps/_expected/amd/main2.js.map index adc342e7133..9004074f7dc 100644 --- a/test/chunking-form/samples/chunking-source-maps/_expected/amd/main2.js.map +++ b/test/chunking-form/samples/chunking-source-maps/_expected/amd/main2.js.map @@ -1 +1 @@ -{"version":3,"file":"main2.js","sources":["../../lib1.js","../../dep3.js","../../main2.js"],"sourcesContent":["export function fn () {\n console.log('lib1 fn');\n}\n\nexport function treeshaked () {\n console.log('this is tree shaken!');\n}","import { fn as libfn, treeshaked } from './lib1.js';\n\nexport function fn () {\n libfn();\n console.log('dep3 fn');\n}\n\nexport default treeshaked;","import { fn } from './dep2.js';\nimport { fn as fn2, default as treeshaked } from './dep3.js';\n\nif (false) {\n treeshaked();\n}\n\nexport default class Main2 {\n constructor () {\n fn2();\n fn();\n }\n}"],"names":["fn","libfn","fn2"],"mappings":";;EAAO,SAASA,IAAE,IAAI;EACtB,EAAE,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;EACzB;;ECAO,SAAS,EAAE,IAAI;EACtB,EAAEC,IAAK,EAAE,CAAC;EACV,EAAE,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;EACzB;;ECEe,MAAM,KAAK,CAAC;EAC3B,EAAE,WAAW,CAAC,GAAG;EACjB,IAAIC,EAAG,EAAE,CAAC;EACV,IAAIF,OAAE,EAAE,CAAC;EACT,GAAG;EACH;;;;;;;;"} \ No newline at end of file +{"version":3,"file":"main2.js","sources":["../../lib1.js","../../dep3.js","../../main2.js"],"sourcesContent":["export function fn () {\n console.log('lib1 fn');\n}\n\nexport function treeshaked () {\n console.log('this is tree shaken!');\n}","import { fn as libfn, treeshaked } from './lib1.js';\n\nexport function fn () {\n libfn();\n console.log('dep3 fn');\n}\n\nexport default treeshaked;","import { fn } from './dep2.js';\nimport { fn as fn2, default as treeshaked } from './dep3.js';\n\nif (false) {\n treeshaked();\n}\n\nexport default class Main2 {\n constructor () {\n fn2();\n fn();\n }\n}"],"names":["fn","libfn","fn2"],"mappings":";;EAAO,SAASA,IAAE,IAAI;EACtB,EAAE,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC;EACxB;;ECAO,SAAS,EAAE,IAAI;EACtB,EAAEC,IAAK,EAAE;EACT,EAAE,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC;EACxB;;ECEe,MAAM,KAAK,CAAC;EAC3B,EAAE,WAAW,CAAC,GAAG;EACjB,IAAIC,EAAG,EAAE;EACT,IAAIF,OAAE,EAAE;EACR,EAAE;EACF;;;;;;;;"} \ No newline at end of file diff --git a/test/chunking-form/samples/chunking-source-maps/_expected/cjs/generated-dep2.js.map b/test/chunking-form/samples/chunking-source-maps/_expected/cjs/generated-dep2.js.map index 2bbede8ff6a..f44195090e7 100644 --- a/test/chunking-form/samples/chunking-source-maps/_expected/cjs/generated-dep2.js.map +++ b/test/chunking-form/samples/chunking-source-maps/_expected/cjs/generated-dep2.js.map @@ -1 +1 @@ -{"version":3,"file":"generated-dep2.js","sources":["../../lib2.js","../../dep2.js"],"sourcesContent":["export function fn () {\n console.log('lib2 fn');\n}","import { fn as libfn } from './lib2.js';\n\nexport function fn () {\n libfn();\n console.log('dep2 fn');\n}"],"names":["fn","libfn"],"mappings":";;AAAO,SAASA,IAAE,IAAI;AACtB,EAAE,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;AACzB;;ACAO,SAAS,EAAE,IAAI;AACtB,EAAEC,IAAK,EAAE,CAAC;AACV,EAAE,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;AACzB;;;;"} \ No newline at end of file +{"version":3,"file":"generated-dep2.js","sources":["../../lib2.js","../../dep2.js"],"sourcesContent":["export function fn () {\n console.log('lib2 fn');\n}","import { fn as libfn } from './lib2.js';\n\nexport function fn () {\n libfn();\n console.log('dep2 fn');\n}"],"names":["fn","libfn"],"mappings":";;AAAO,SAASA,IAAE,IAAI;AACtB,EAAE,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC;AACxB;;ACAO,SAAS,EAAE,IAAI;AACtB,EAAEC,IAAK,EAAE;AACT,EAAE,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC;AACxB;;;;"} \ No newline at end of file diff --git a/test/chunking-form/samples/chunking-source-maps/_expected/cjs/main1.js.map b/test/chunking-form/samples/chunking-source-maps/_expected/cjs/main1.js.map index 7fa03bb66c0..bde1dac05dc 100644 --- a/test/chunking-form/samples/chunking-source-maps/_expected/cjs/main1.js.map +++ b/test/chunking-form/samples/chunking-source-maps/_expected/cjs/main1.js.map @@ -1 +1 @@ -{"version":3,"file":"main1.js","sources":["../../dep1.js","../../main1.js"],"sourcesContent":["export function fn () {\n console.log('dep1 fn');\n}","import { fn } from './dep1.js';\nimport { fn as fn2 } from './dep2.js';\n\nexport default class Main1 {\n constructor () {\n fn();\n fn2();\n }\n}"],"names":["fn2"],"mappings":";;;;AAAO,SAAS,EAAE,IAAI;AACtB,EAAE,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;AACzB;;ACCe,MAAM,KAAK,CAAC;AAC3B,EAAE,WAAW,CAAC,GAAG;AACjB,IAAI,EAAE,EAAE,CAAC;AACT,IAAIA,OAAG,EAAE,CAAC;AACV,GAAG;AACH;;;;"} \ No newline at end of file +{"version":3,"file":"main1.js","sources":["../../dep1.js","../../main1.js"],"sourcesContent":["export function fn () {\n console.log('dep1 fn');\n}","import { fn } from './dep1.js';\nimport { fn as fn2 } from './dep2.js';\n\nexport default class Main1 {\n constructor () {\n fn();\n fn2();\n }\n}"],"names":["fn2"],"mappings":";;;;AAAO,SAAS,EAAE,IAAI;AACtB,EAAE,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC;AACxB;;ACCe,MAAM,KAAK,CAAC;AAC3B,EAAE,WAAW,CAAC,GAAG;AACjB,IAAI,EAAE,EAAE;AACR,IAAIA,OAAG,EAAE;AACT,EAAE;AACF;;;;"} \ No newline at end of file diff --git a/test/chunking-form/samples/chunking-source-maps/_expected/cjs/main2.js.map b/test/chunking-form/samples/chunking-source-maps/_expected/cjs/main2.js.map index 9593dd0350c..44cd581cbab 100644 --- a/test/chunking-form/samples/chunking-source-maps/_expected/cjs/main2.js.map +++ b/test/chunking-form/samples/chunking-source-maps/_expected/cjs/main2.js.map @@ -1 +1 @@ -{"version":3,"file":"main2.js","sources":["../../lib1.js","../../dep3.js","../../main2.js"],"sourcesContent":["export function fn () {\n console.log('lib1 fn');\n}\n\nexport function treeshaked () {\n console.log('this is tree shaken!');\n}","import { fn as libfn, treeshaked } from './lib1.js';\n\nexport function fn () {\n libfn();\n console.log('dep3 fn');\n}\n\nexport default treeshaked;","import { fn } from './dep2.js';\nimport { fn as fn2, default as treeshaked } from './dep3.js';\n\nif (false) {\n treeshaked();\n}\n\nexport default class Main2 {\n constructor () {\n fn2();\n fn();\n }\n}"],"names":["fn","libfn","fn2"],"mappings":";;;;AAAO,SAASA,IAAE,IAAI;AACtB,EAAE,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;AACzB;;ACAO,SAAS,EAAE,IAAI;AACtB,EAAEC,IAAK,EAAE,CAAC;AACV,EAAE,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;AACzB;;ACEe,MAAM,KAAK,CAAC;AAC3B,EAAE,WAAW,CAAC,GAAG;AACjB,IAAIC,EAAG,EAAE,CAAC;AACV,IAAIF,OAAE,EAAE,CAAC;AACT,GAAG;AACH;;;;"} \ No newline at end of file +{"version":3,"file":"main2.js","sources":["../../lib1.js","../../dep3.js","../../main2.js"],"sourcesContent":["export function fn () {\n console.log('lib1 fn');\n}\n\nexport function treeshaked () {\n console.log('this is tree shaken!');\n}","import { fn as libfn, treeshaked } from './lib1.js';\n\nexport function fn () {\n libfn();\n console.log('dep3 fn');\n}\n\nexport default treeshaked;","import { fn } from './dep2.js';\nimport { fn as fn2, default as treeshaked } from './dep3.js';\n\nif (false) {\n treeshaked();\n}\n\nexport default class Main2 {\n constructor () {\n fn2();\n fn();\n }\n}"],"names":["fn","libfn","fn2"],"mappings":";;;;AAAO,SAASA,IAAE,IAAI;AACtB,EAAE,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC;AACxB;;ACAO,SAAS,EAAE,IAAI;AACtB,EAAEC,IAAK,EAAE;AACT,EAAE,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC;AACxB;;ACEe,MAAM,KAAK,CAAC;AAC3B,EAAE,WAAW,CAAC,GAAG;AACjB,IAAIC,EAAG,EAAE;AACT,IAAIF,OAAE,EAAE;AACR,EAAE;AACF;;;;"} \ No newline at end of file diff --git a/test/chunking-form/samples/chunking-source-maps/_expected/es/generated-dep2.js.map b/test/chunking-form/samples/chunking-source-maps/_expected/es/generated-dep2.js.map index b4aedaaf0d7..7c1efc88c45 100644 --- a/test/chunking-form/samples/chunking-source-maps/_expected/es/generated-dep2.js.map +++ b/test/chunking-form/samples/chunking-source-maps/_expected/es/generated-dep2.js.map @@ -1 +1 @@ -{"version":3,"file":"generated-dep2.js","sources":["../../lib2.js","../../dep2.js"],"sourcesContent":["export function fn () {\n console.log('lib2 fn');\n}","import { fn as libfn } from './lib2.js';\n\nexport function fn () {\n libfn();\n console.log('dep2 fn');\n}"],"names":["fn","libfn"],"mappings":"AAAO,SAASA,IAAE,IAAI;AACtB,EAAE,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;AACzB;;ACAO,SAAS,EAAE,IAAI;AACtB,EAAEC,IAAK,EAAE,CAAC;AACV,EAAE,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;AACzB;;;;"} \ No newline at end of file +{"version":3,"file":"generated-dep2.js","sources":["../../lib2.js","../../dep2.js"],"sourcesContent":["export function fn () {\n console.log('lib2 fn');\n}","import { fn as libfn } from './lib2.js';\n\nexport function fn () {\n libfn();\n console.log('dep2 fn');\n}"],"names":["fn","libfn"],"mappings":"AAAO,SAASA,IAAE,IAAI;AACtB,EAAE,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC;AACxB;;ACAO,SAAS,EAAE,IAAI;AACtB,EAAEC,IAAK,EAAE;AACT,EAAE,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC;AACxB;;;;"} \ No newline at end of file diff --git a/test/chunking-form/samples/chunking-source-maps/_expected/es/main1.js b/test/chunking-form/samples/chunking-source-maps/_expected/es/main1.js index 4075e0cecd4..3b9b307b1ff 100644 --- a/test/chunking-form/samples/chunking-source-maps/_expected/es/main1.js +++ b/test/chunking-form/samples/chunking-source-maps/_expected/es/main1.js @@ -11,5 +11,5 @@ class Main1 { } } -export default Main1; +export { Main1 as default }; //# sourceMappingURL=main1.js.map diff --git a/test/chunking-form/samples/chunking-source-maps/_expected/es/main1.js.map b/test/chunking-form/samples/chunking-source-maps/_expected/es/main1.js.map index ee57867ffc8..2f836369939 100644 --- a/test/chunking-form/samples/chunking-source-maps/_expected/es/main1.js.map +++ b/test/chunking-form/samples/chunking-source-maps/_expected/es/main1.js.map @@ -1 +1 @@ -{"version":3,"file":"main1.js","sources":["../../dep1.js","../../main1.js"],"sourcesContent":["export function fn () {\n console.log('dep1 fn');\n}","import { fn } from './dep1.js';\nimport { fn as fn2 } from './dep2.js';\n\nexport default class Main1 {\n constructor () {\n fn();\n fn2();\n }\n}"],"names":["fn2"],"mappings":";;AAAO,SAAS,EAAE,IAAI;AACtB,EAAE,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;AACzB;;ACCe,MAAM,KAAK,CAAC;AAC3B,EAAE,WAAW,CAAC,GAAG;AACjB,IAAI,EAAE,EAAE,CAAC;AACT,IAAIA,IAAG,EAAE,CAAC;AACV,GAAG;AACH;;;;"} \ No newline at end of file +{"version":3,"file":"main1.js","sources":["../../dep1.js","../../main1.js"],"sourcesContent":["export function fn () {\n console.log('dep1 fn');\n}","import { fn } from './dep1.js';\nimport { fn as fn2 } from './dep2.js';\n\nexport default class Main1 {\n constructor () {\n fn();\n fn2();\n }\n}"],"names":["fn2"],"mappings":";;AAAO,SAAS,EAAE,IAAI;AACtB,EAAE,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC;AACxB;;ACCe,MAAM,KAAK,CAAC;AAC3B,EAAE,WAAW,CAAC,GAAG;AACjB,IAAI,EAAE,EAAE;AACR,IAAIA,IAAG,EAAE;AACT,EAAE;AACF;;;;"} \ No newline at end of file diff --git a/test/chunking-form/samples/chunking-source-maps/_expected/es/main2.js b/test/chunking-form/samples/chunking-source-maps/_expected/es/main2.js index 4165c094c98..4e290139213 100644 --- a/test/chunking-form/samples/chunking-source-maps/_expected/es/main2.js +++ b/test/chunking-form/samples/chunking-source-maps/_expected/es/main2.js @@ -16,5 +16,5 @@ class Main2 { } } -export default Main2; +export { Main2 as default }; //# sourceMappingURL=main2.js.map diff --git a/test/chunking-form/samples/chunking-source-maps/_expected/es/main2.js.map b/test/chunking-form/samples/chunking-source-maps/_expected/es/main2.js.map index 436542418a0..44ac58a32d9 100644 --- a/test/chunking-form/samples/chunking-source-maps/_expected/es/main2.js.map +++ b/test/chunking-form/samples/chunking-source-maps/_expected/es/main2.js.map @@ -1 +1 @@ -{"version":3,"file":"main2.js","sources":["../../lib1.js","../../dep3.js","../../main2.js"],"sourcesContent":["export function fn () {\n console.log('lib1 fn');\n}\n\nexport function treeshaked () {\n console.log('this is tree shaken!');\n}","import { fn as libfn, treeshaked } from './lib1.js';\n\nexport function fn () {\n libfn();\n console.log('dep3 fn');\n}\n\nexport default treeshaked;","import { fn } from './dep2.js';\nimport { fn as fn2, default as treeshaked } from './dep3.js';\n\nif (false) {\n treeshaked();\n}\n\nexport default class Main2 {\n constructor () {\n fn2();\n fn();\n }\n}"],"names":["fn","libfn","fn2"],"mappings":";;AAAO,SAASA,IAAE,IAAI;AACtB,EAAE,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;AACzB;;ACAO,SAAS,EAAE,IAAI;AACtB,EAAEC,IAAK,EAAE,CAAC;AACV,EAAE,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;AACzB;;ACEe,MAAM,KAAK,CAAC;AAC3B,EAAE,WAAW,CAAC,GAAG;AACjB,IAAIC,EAAG,EAAE,CAAC;AACV,IAAIF,IAAE,EAAE,CAAC;AACT,GAAG;AACH;;;;"} \ No newline at end of file +{"version":3,"file":"main2.js","sources":["../../lib1.js","../../dep3.js","../../main2.js"],"sourcesContent":["export function fn () {\n console.log('lib1 fn');\n}\n\nexport function treeshaked () {\n console.log('this is tree shaken!');\n}","import { fn as libfn, treeshaked } from './lib1.js';\n\nexport function fn () {\n libfn();\n console.log('dep3 fn');\n}\n\nexport default treeshaked;","import { fn } from './dep2.js';\nimport { fn as fn2, default as treeshaked } from './dep3.js';\n\nif (false) {\n treeshaked();\n}\n\nexport default class Main2 {\n constructor () {\n fn2();\n fn();\n }\n}"],"names":["fn","libfn","fn2"],"mappings":";;AAAO,SAASA,IAAE,IAAI;AACtB,EAAE,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC;AACxB;;ACAO,SAAS,EAAE,IAAI;AACtB,EAAEC,IAAK,EAAE;AACT,EAAE,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC;AACxB;;ACEe,MAAM,KAAK,CAAC;AAC3B,EAAE,WAAW,CAAC,GAAG;AACjB,IAAIC,EAAG,EAAE;AACT,IAAIF,IAAE,EAAE;AACR,EAAE;AACF;;;;"} \ No newline at end of file diff --git a/test/chunking-form/samples/chunking-source-maps/_expected/system/generated-dep2.js b/test/chunking-form/samples/chunking-source-maps/_expected/system/generated-dep2.js index 54de90db5b7..2437ff95a85 100644 --- a/test/chunking-form/samples/chunking-source-maps/_expected/system/generated-dep2.js +++ b/test/chunking-form/samples/chunking-source-maps/_expected/system/generated-dep2.js @@ -1,9 +1,9 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - exports('f', fn); + exports("f", fn); function fn$1 () { console.log('lib2 fn'); @@ -14,7 +14,7 @@ System.register([], function (exports) { console.log('dep2 fn'); } - } + }) }; -}); +})); //# sourceMappingURL=generated-dep2.js.map diff --git a/test/chunking-form/samples/chunking-source-maps/_expected/system/generated-dep2.js.map b/test/chunking-form/samples/chunking-source-maps/_expected/system/generated-dep2.js.map index a14686ef0a1..579119e5764 100644 --- a/test/chunking-form/samples/chunking-source-maps/_expected/system/generated-dep2.js.map +++ b/test/chunking-form/samples/chunking-source-maps/_expected/system/generated-dep2.js.map @@ -1 +1 @@ -{"version":3,"file":"generated-dep2.js","sources":["../../lib2.js","../../dep2.js"],"sourcesContent":["export function fn () {\n console.log('lib2 fn');\n}","import { fn as libfn } from './lib2.js';\n\nexport function fn () {\n libfn();\n console.log('dep2 fn');\n}"],"names":["fn","libfn"],"mappings":";;;;;;;MAAO,SAASA,IAAE,IAAI;MACtB,EAAE,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;MACzB;;MCAO,SAAS,EAAE,IAAI;MACtB,EAAEC,IAAK,EAAE,CAAC;MACV,EAAE,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;MACzB;;;;;;"} \ No newline at end of file +{"version":3,"file":"generated-dep2.js","sources":["../../lib2.js","../../dep2.js"],"sourcesContent":["export function fn () {\n console.log('lib2 fn');\n}","import { fn as libfn } from './lib2.js';\n\nexport function fn () {\n libfn();\n console.log('dep2 fn');\n}"],"names":["fn","libfn"],"mappings":";;;;;;;MAAO,SAASA,IAAE,IAAI;MACtB,EAAE,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC;MACxB;;MCAO,SAAS,EAAE,IAAI;MACtB,EAAEC,IAAK,EAAE;MACT,EAAE,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC;MACxB;;;;;;;;"} \ No newline at end of file diff --git a/test/chunking-form/samples/chunking-source-maps/_expected/system/main1.js b/test/chunking-form/samples/chunking-source-maps/_expected/system/main1.js index 2ac9cf86864..68785846e50 100644 --- a/test/chunking-form/samples/chunking-source-maps/_expected/system/main1.js +++ b/test/chunking-form/samples/chunking-source-maps/_expected/system/main1.js @@ -1,11 +1,11 @@ -System.register(['./generated-dep2.js'], function (exports) { +System.register(['./generated-dep2.js'], (function (exports) { 'use strict'; var fn$1; return { setters: [function (module) { fn$1 = module.f; }], - execute: function () { + execute: (function () { function fn () { console.log('dep1 fn'); @@ -16,9 +16,9 @@ System.register(['./generated-dep2.js'], function (exports) { fn(); fn$1(); } - } exports('default', Main1); + } exports("default", Main1); - } + }) }; -}); +})); //# sourceMappingURL=main1.js.map diff --git a/test/chunking-form/samples/chunking-source-maps/_expected/system/main1.js.map b/test/chunking-form/samples/chunking-source-maps/_expected/system/main1.js.map index 74b33711151..fd52e882ead 100644 --- a/test/chunking-form/samples/chunking-source-maps/_expected/system/main1.js.map +++ b/test/chunking-form/samples/chunking-source-maps/_expected/system/main1.js.map @@ -1 +1 @@ -{"version":3,"file":"main1.js","sources":["../../dep1.js","../../main1.js"],"sourcesContent":["export function fn () {\n console.log('dep1 fn');\n}","import { fn } from './dep1.js';\nimport { fn as fn2 } from './dep2.js';\n\nexport default class Main1 {\n constructor () {\n fn();\n fn2();\n }\n}"],"names":["fn2"],"mappings":";;;;;;;;;MAAO,SAAS,EAAE,IAAI;MACtB,EAAE,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;MACzB;;MCCe,MAAM,KAAK,CAAC;MAC3B,EAAE,WAAW,CAAC,GAAG;MACjB,IAAI,EAAE,EAAE,CAAC;MACT,IAAIA,IAAG,EAAE,CAAC;MACV,GAAG;MACH;;;;;;"} \ No newline at end of file +{"version":3,"file":"main1.js","sources":["../../dep1.js","../../main1.js"],"sourcesContent":["export function fn () {\n console.log('dep1 fn');\n}","import { fn } from './dep1.js';\nimport { fn as fn2 } from './dep2.js';\n\nexport default class Main1 {\n constructor () {\n fn();\n fn2();\n }\n}"],"names":["fn2"],"mappings":";;;;;;;;;MAAO,SAAS,EAAE,IAAI;MACtB,EAAE,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC;MACxB;;MCCe,MAAM,KAAK,CAAC;MAC3B,EAAE,WAAW,CAAC,GAAG;MACjB,IAAI,EAAE,EAAE;MACR,IAAIA,IAAG,EAAE;MACT,EAAE;MACF;;;;;;;;"} \ No newline at end of file diff --git a/test/chunking-form/samples/chunking-source-maps/_expected/system/main2.js b/test/chunking-form/samples/chunking-source-maps/_expected/system/main2.js index f4b7cb76a18..a5bcb2370d6 100644 --- a/test/chunking-form/samples/chunking-source-maps/_expected/system/main2.js +++ b/test/chunking-form/samples/chunking-source-maps/_expected/system/main2.js @@ -1,11 +1,11 @@ -System.register(['./generated-dep2.js'], function (exports) { +System.register(['./generated-dep2.js'], (function (exports) { 'use strict'; var fn$2; return { setters: [function (module) { fn$2 = module.f; }], - execute: function () { + execute: (function () { function fn$1 () { console.log('lib1 fn'); @@ -21,9 +21,9 @@ System.register(['./generated-dep2.js'], function (exports) { fn(); fn$2(); } - } exports('default', Main2); + } exports("default", Main2); - } + }) }; -}); +})); //# sourceMappingURL=main2.js.map diff --git a/test/chunking-form/samples/chunking-source-maps/_expected/system/main2.js.map b/test/chunking-form/samples/chunking-source-maps/_expected/system/main2.js.map index 52fa30eeb69..99de359cb9c 100644 --- a/test/chunking-form/samples/chunking-source-maps/_expected/system/main2.js.map +++ b/test/chunking-form/samples/chunking-source-maps/_expected/system/main2.js.map @@ -1 +1 @@ -{"version":3,"file":"main2.js","sources":["../../lib1.js","../../dep3.js","../../main2.js"],"sourcesContent":["export function fn () {\n console.log('lib1 fn');\n}\n\nexport function treeshaked () {\n console.log('this is tree shaken!');\n}","import { fn as libfn, treeshaked } from './lib1.js';\n\nexport function fn () {\n libfn();\n console.log('dep3 fn');\n}\n\nexport default treeshaked;","import { fn } from './dep2.js';\nimport { fn as fn2, default as treeshaked } from './dep3.js';\n\nif (false) {\n treeshaked();\n}\n\nexport default class Main2 {\n constructor () {\n fn2();\n fn();\n }\n}"],"names":["fn","libfn","fn2"],"mappings":";;;;;;;;;MAAO,SAASA,IAAE,IAAI;MACtB,EAAE,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;MACzB;;MCAO,SAAS,EAAE,IAAI;MACtB,EAAEC,IAAK,EAAE,CAAC;MACV,EAAE,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;MACzB;;MCEe,MAAM,KAAK,CAAC;MAC3B,EAAE,WAAW,CAAC,GAAG;MACjB,IAAIC,EAAG,EAAE,CAAC;MACV,IAAIF,IAAE,EAAE,CAAC;MACT,GAAG;MACH;;;;;;"} \ No newline at end of file +{"version":3,"file":"main2.js","sources":["../../lib1.js","../../dep3.js","../../main2.js"],"sourcesContent":["export function fn () {\n console.log('lib1 fn');\n}\n\nexport function treeshaked () {\n console.log('this is tree shaken!');\n}","import { fn as libfn, treeshaked } from './lib1.js';\n\nexport function fn () {\n libfn();\n console.log('dep3 fn');\n}\n\nexport default treeshaked;","import { fn } from './dep2.js';\nimport { fn as fn2, default as treeshaked } from './dep3.js';\n\nif (false) {\n treeshaked();\n}\n\nexport default class Main2 {\n constructor () {\n fn2();\n fn();\n }\n}"],"names":["fn","libfn","fn2"],"mappings":";;;;;;;;;MAAO,SAASA,IAAE,IAAI;MACtB,EAAE,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC;MACxB;;MCAO,SAAS,EAAE,IAAI;MACtB,EAAEC,IAAK,EAAE;MACT,EAAE,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC;MACxB;;MCEe,MAAM,KAAK,CAAC;MAC3B,EAAE,WAAW,CAAC,GAAG;MACjB,IAAIC,EAAG,EAAE;MACT,IAAIF,IAAE,EAAE;MACR,EAAE;MACF;;;;;;;;"} \ No newline at end of file diff --git a/test/chunking-form/samples/chunking-star-external/_config.js b/test/chunking-form/samples/chunking-star-external/_config.js index 854a3591362..2ab2aae45cb 100644 --- a/test/chunking-form/samples/chunking-star-external/_config.js +++ b/test/chunking-form/samples/chunking-star-external/_config.js @@ -1,7 +1,7 @@ -module.exports = { +module.exports = defineTest({ description: 'chunking star external', options: { input: ['main1.js', 'main2.js'], external: ['external1', 'external2', 'starexternal1', 'starexternal2'] } -}; +}); diff --git a/test/chunking-form/samples/chunking-star-external/_expected/amd/generated-dep.js b/test/chunking-form/samples/chunking-star-external/_expected/amd/generated-dep.js index f5158b2b3db..4ad294cd745 100644 --- a/test/chunking-form/samples/chunking-star-external/_expected/amd/generated-dep.js +++ b/test/chunking-form/samples/chunking-star-external/_expected/amd/generated-dep.js @@ -1,7 +1,7 @@ -define(['exports', 'starexternal2', 'external2'], function (exports, starexternal2, external2) { 'use strict'; +define(['exports', 'starexternal2', 'external2'], (function (exports, starexternal2, external2) { 'use strict'; var dep = 'dep'; exports.dep = dep; -}); +})); diff --git a/test/chunking-form/samples/chunking-star-external/_expected/amd/main1.js b/test/chunking-form/samples/chunking-star-external/_expected/amd/main1.js index 936dee41172..6f9ccce82cf 100644 --- a/test/chunking-form/samples/chunking-star-external/_expected/amd/main1.js +++ b/test/chunking-form/samples/chunking-star-external/_expected/amd/main1.js @@ -1,24 +1,18 @@ -define(['exports', 'starexternal1', 'external1', './generated-dep', 'starexternal2', 'external2'], function (exports, starexternal1, external1, dep, starexternal2, external2) { 'use strict'; +define(['exports', 'starexternal1', 'external1', './generated-dep', 'starexternal2', 'external2'], (function (exports, starexternal1, external1, dep, starexternal2, external2) { 'use strict'; var main = '1'; - Object.defineProperty(exports, 'e', { + Object.defineProperty(exports, "e", { enumerable: true, - get: function () { - return external1.e; - } + get: function () { return external1.e; } }); exports.dep = dep.dep; exports.main = main; Object.keys(starexternal1).forEach(function (k) { - if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, { + if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, { enumerable: true, - get: function () { - return starexternal1[k]; - } + get: function () { return starexternal1[k]; } }); }); - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/chunking-star-external/_expected/amd/main2.js b/test/chunking-form/samples/chunking-star-external/_expected/amd/main2.js index 6655382d8c6..7416b22989b 100644 --- a/test/chunking-form/samples/chunking-star-external/_expected/amd/main2.js +++ b/test/chunking-form/samples/chunking-star-external/_expected/amd/main2.js @@ -1,24 +1,18 @@ -define(['exports', './generated-dep', 'external2', 'starexternal2'], function (exports, dep, external2, starexternal2) { 'use strict'; +define(['exports', './generated-dep', 'starexternal2', 'external2'], (function (exports, dep, starexternal2, external2) { 'use strict'; var main = '2'; exports.dep = dep.dep; - Object.defineProperty(exports, 'e', { + Object.defineProperty(exports, "e", { enumerable: true, - get: function () { - return external2.e; - } + get: function () { return external2.e; } }); exports.main = main; Object.keys(starexternal2).forEach(function (k) { - if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, { + if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, { enumerable: true, - get: function () { - return starexternal2[k]; - } + get: function () { return starexternal2[k]; } }); }); - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/chunking-star-external/_expected/cjs/main1.js b/test/chunking-form/samples/chunking-star-external/_expected/cjs/main1.js index 620f87b6570..8a43c4fd070 100644 --- a/test/chunking-form/samples/chunking-star-external/_expected/cjs/main1.js +++ b/test/chunking-form/samples/chunking-star-external/_expected/cjs/main1.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - var starexternal1 = require('starexternal1'); var external1 = require('external1'); var dep = require('./generated-dep.js'); @@ -10,19 +8,15 @@ require('external2'); var main = '1'; -Object.defineProperty(exports, 'e', { +Object.defineProperty(exports, "e", { enumerable: true, - get: function () { - return external1.e; - } + get: function () { return external1.e; } }); exports.dep = dep.dep; exports.main = main; Object.keys(starexternal1).forEach(function (k) { - if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, { + if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, { enumerable: true, - get: function () { - return starexternal1[k]; - } + get: function () { return starexternal1[k]; } }); }); diff --git a/test/chunking-form/samples/chunking-star-external/_expected/cjs/main2.js b/test/chunking-form/samples/chunking-star-external/_expected/cjs/main2.js index 79d55867966..e977db3f88a 100644 --- a/test/chunking-form/samples/chunking-star-external/_expected/cjs/main2.js +++ b/test/chunking-form/samples/chunking-star-external/_expected/cjs/main2.js @@ -1,26 +1,20 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - var dep = require('./generated-dep.js'); -var external2 = require('external2'); var starexternal2 = require('starexternal2'); +var external2 = require('external2'); var main = '2'; exports.dep = dep.dep; -Object.defineProperty(exports, 'e', { +Object.defineProperty(exports, "e", { enumerable: true, - get: function () { - return external2.e; - } + get: function () { return external2.e; } }); exports.main = main; Object.keys(starexternal2).forEach(function (k) { - if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, { + if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, { enumerable: true, - get: function () { - return starexternal2[k]; - } + get: function () { return starexternal2[k]; } }); }); diff --git a/test/chunking-form/samples/chunking-star-external/_expected/es/main2.js b/test/chunking-form/samples/chunking-star-external/_expected/es/main2.js index 50f4537ad48..821e9fd776a 100644 --- a/test/chunking-form/samples/chunking-star-external/_expected/es/main2.js +++ b/test/chunking-form/samples/chunking-star-external/_expected/es/main2.js @@ -1,6 +1,6 @@ export { d as dep } from './generated-dep.js'; -export { e } from 'external2'; export * from 'starexternal2'; +export { e } from 'external2'; var main = '2'; diff --git a/test/chunking-form/samples/chunking-star-external/_expected/system/generated-dep.js b/test/chunking-form/samples/chunking-star-external/_expected/system/generated-dep.js index d73c96188d2..10f3df28b05 100644 --- a/test/chunking-form/samples/chunking-star-external/_expected/system/generated-dep.js +++ b/test/chunking-form/samples/chunking-star-external/_expected/system/generated-dep.js @@ -1,11 +1,11 @@ -System.register(['starexternal2', 'external2'], function (exports) { +System.register(['starexternal2', 'external2'], (function (exports) { 'use strict'; return { - setters: [function () {}, function () {}], - execute: function () { + setters: [null, null], + execute: (function () { - var dep = exports('d', 'dep'); + var dep = exports("d", 'dep'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/chunking-star-external/_expected/system/main1.js b/test/chunking-form/samples/chunking-star-external/_expected/system/main1.js index bad9531bb69..92889946436 100644 --- a/test/chunking-form/samples/chunking-star-external/_expected/system/main1.js +++ b/test/chunking-form/samples/chunking-star-external/_expected/system/main1.js @@ -1,22 +1,28 @@ -System.register(['starexternal1', 'external1', './generated-dep.js', 'starexternal2', 'external2'], function (exports) { +System.register(['starexternal1', 'external1', './generated-dep.js', 'starexternal2', 'external2'], (function (exports) { 'use strict'; - var _starExcludes = { main: 1, default: 1, e: 1, dep: 1 }; + var _starExcludes = { + __proto__: null, + main: 1, + default: 1, + e: 1, + dep: 1 + }; return { setters: [function (module) { - var _setter = {}; - for (var _$p in module) { - if (!_starExcludes[_$p]) _setter[_$p] = module[_$p]; + var setter = { __proto__: null }; + for (var name in module) { + if (!_starExcludes[name]) setter[name] = module[name]; } - exports(_setter); + exports(setter); }, function (module) { - exports('e', module.e); + exports("e", module.e); }, function (module) { - exports('dep', module.d); - }, function () {}, function () {}], - execute: function () { + exports("dep", module.d); + }, null, null], + execute: (function () { - var main = exports('main', '1'); + var main = exports("main", '1'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/chunking-star-external/_expected/system/main2.js b/test/chunking-form/samples/chunking-star-external/_expected/system/main2.js index 91b5984d5ea..bfec4ba71e8 100644 --- a/test/chunking-form/samples/chunking-star-external/_expected/system/main2.js +++ b/test/chunking-form/samples/chunking-star-external/_expected/system/main2.js @@ -1,22 +1,28 @@ -System.register(['./generated-dep.js', 'external2', 'starexternal2'], function (exports) { +System.register(['./generated-dep.js', 'starexternal2', 'external2'], (function (exports) { 'use strict'; - var _starExcludes = { main: 1, default: 1, dep: 1, e: 1 }; + var _starExcludes = { + __proto__: null, + main: 1, + default: 1, + dep: 1, + e: 1 + }; return { setters: [function (module) { - exports('dep', module.d); - }, function (module) { - exports('e', module.e); + exports("dep", module.d); }, function (module) { - var _setter = {}; - for (var _$p in module) { - if (!_starExcludes[_$p]) _setter[_$p] = module[_$p]; + var setter = { __proto__: null }; + for (var name in module) { + if (!_starExcludes[name]) setter[name] = module[name]; } - exports(_setter); + exports(setter); + }, function (module) { + exports("e", module.e); }], - execute: function () { + execute: (function () { - var main = exports('main', '2'); + var main = exports("main", '2'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/circular-chunks-warning-caused-by-manual-chunks-conflict/_config.js b/test/chunking-form/samples/circular-chunks-warning-caused-by-manual-chunks-conflict/_config.js new file mode 100644 index 00000000000..a1a97d0a9d4 --- /dev/null +++ b/test/chunking-form/samples/circular-chunks-warning-caused-by-manual-chunks-conflict/_config.js @@ -0,0 +1,18 @@ +module.exports = defineTest({ + description: 'Throw a warning for circular chunks caused by manual chunks conflict', + options: { + output: { + manualChunks(id) { + if (id.endsWith('a.js') || id.endsWith('c.js')) return 'ac'; + if (id.endsWith('b.js')) return 'b'; + } + } + }, + expectedWarnings: ['CIRCULAR_CHUNK'], + logs: new Array(4).fill(null).map(() => ({ + code: 'CIRCULAR_CHUNK', + ids: ['b', 'ac', 'b'], + level: 'warn', + message: 'Circular chunk: b -> ac -> b. Please adjust the manual chunk logic for these chunks.' + })) +}); diff --git a/test/chunking-form/samples/circular-chunks-warning-caused-by-manual-chunks-conflict/_expected/amd/generated-ac.js b/test/chunking-form/samples/circular-chunks-warning-caused-by-manual-chunks-conflict/_expected/amd/generated-ac.js new file mode 100644 index 00000000000..5cc373d201e --- /dev/null +++ b/test/chunking-form/samples/circular-chunks-warning-caused-by-manual-chunks-conflict/_expected/amd/generated-ac.js @@ -0,0 +1,12 @@ +define(['exports', './generated-b'], (function (exports, b) { 'use strict'; + + const c = 'c'; + console.log(c); + + const a = 'a'; + console.log(a + b.b); + + exports.a = a; + exports.c = c; + +})); diff --git a/test/chunking-form/samples/circular-chunks-warning-caused-by-manual-chunks-conflict/_expected/amd/generated-b.js b/test/chunking-form/samples/circular-chunks-warning-caused-by-manual-chunks-conflict/_expected/amd/generated-b.js new file mode 100644 index 00000000000..8a6fce9e0ed --- /dev/null +++ b/test/chunking-form/samples/circular-chunks-warning-caused-by-manual-chunks-conflict/_expected/amd/generated-b.js @@ -0,0 +1,8 @@ +define(['exports', './generated-ac'], (function (exports, ac) { 'use strict'; + + const b = 'b'; + console.log(b + ac.c); + + exports.b = b; + +})); diff --git a/test/chunking-form/samples/circular-chunks-warning-caused-by-manual-chunks-conflict/_expected/amd/main.js b/test/chunking-form/samples/circular-chunks-warning-caused-by-manual-chunks-conflict/_expected/amd/main.js new file mode 100644 index 00000000000..c689dd7bb37 --- /dev/null +++ b/test/chunking-form/samples/circular-chunks-warning-caused-by-manual-chunks-conflict/_expected/amd/main.js @@ -0,0 +1,5 @@ +define(['./generated-ac', './generated-b'], (function (ac, b) { 'use strict'; + + console.log(ac.a); + +})); diff --git a/test/chunking-form/samples/circular-chunks-warning-caused-by-manual-chunks-conflict/_expected/cjs/generated-ac.js b/test/chunking-form/samples/circular-chunks-warning-caused-by-manual-chunks-conflict/_expected/cjs/generated-ac.js new file mode 100644 index 00000000000..28b60a9a1d8 --- /dev/null +++ b/test/chunking-form/samples/circular-chunks-warning-caused-by-manual-chunks-conflict/_expected/cjs/generated-ac.js @@ -0,0 +1,12 @@ +'use strict'; + +var b = require('./generated-b.js'); + +const c = 'c'; +console.log(c); + +const a = 'a'; +console.log(a + b.b); + +exports.a = a; +exports.c = c; diff --git a/test/chunking-form/samples/circular-chunks-warning-caused-by-manual-chunks-conflict/_expected/cjs/generated-b.js b/test/chunking-form/samples/circular-chunks-warning-caused-by-manual-chunks-conflict/_expected/cjs/generated-b.js new file mode 100644 index 00000000000..f2599875b3b --- /dev/null +++ b/test/chunking-form/samples/circular-chunks-warning-caused-by-manual-chunks-conflict/_expected/cjs/generated-b.js @@ -0,0 +1,8 @@ +'use strict'; + +var ac = require('./generated-ac.js'); + +const b = 'b'; +console.log(b + ac.c); + +exports.b = b; diff --git a/test/chunking-form/samples/circular-chunks-warning-caused-by-manual-chunks-conflict/_expected/cjs/main.js b/test/chunking-form/samples/circular-chunks-warning-caused-by-manual-chunks-conflict/_expected/cjs/main.js new file mode 100644 index 00000000000..895b45cf4fa --- /dev/null +++ b/test/chunking-form/samples/circular-chunks-warning-caused-by-manual-chunks-conflict/_expected/cjs/main.js @@ -0,0 +1,6 @@ +'use strict'; + +var ac = require('./generated-ac.js'); +require('./generated-b.js'); + +console.log(ac.a); diff --git a/test/chunking-form/samples/circular-chunks-warning-caused-by-manual-chunks-conflict/_expected/es/generated-ac.js b/test/chunking-form/samples/circular-chunks-warning-caused-by-manual-chunks-conflict/_expected/es/generated-ac.js new file mode 100644 index 00000000000..59e7cc568c0 --- /dev/null +++ b/test/chunking-form/samples/circular-chunks-warning-caused-by-manual-chunks-conflict/_expected/es/generated-ac.js @@ -0,0 +1,9 @@ +import { b } from './generated-b.js'; + +const c = 'c'; +console.log(c); + +const a = 'a'; +console.log(a + b); + +export { a, c }; diff --git a/test/chunking-form/samples/circular-chunks-warning-caused-by-manual-chunks-conflict/_expected/es/generated-b.js b/test/chunking-form/samples/circular-chunks-warning-caused-by-manual-chunks-conflict/_expected/es/generated-b.js new file mode 100644 index 00000000000..c2f84a4695a --- /dev/null +++ b/test/chunking-form/samples/circular-chunks-warning-caused-by-manual-chunks-conflict/_expected/es/generated-b.js @@ -0,0 +1,6 @@ +import { c } from './generated-ac.js'; + +const b = 'b'; +console.log(b + c); + +export { b }; diff --git a/test/chunking-form/samples/circular-chunks-warning-caused-by-manual-chunks-conflict/_expected/es/main.js b/test/chunking-form/samples/circular-chunks-warning-caused-by-manual-chunks-conflict/_expected/es/main.js new file mode 100644 index 00000000000..b8075900379 --- /dev/null +++ b/test/chunking-form/samples/circular-chunks-warning-caused-by-manual-chunks-conflict/_expected/es/main.js @@ -0,0 +1,4 @@ +import { a } from './generated-ac.js'; +import './generated-b.js'; + +console.log(a); diff --git a/test/chunking-form/samples/circular-chunks-warning-caused-by-manual-chunks-conflict/_expected/system/generated-ac.js b/test/chunking-form/samples/circular-chunks-warning-caused-by-manual-chunks-conflict/_expected/system/generated-ac.js new file mode 100644 index 00000000000..7378cfcd490 --- /dev/null +++ b/test/chunking-form/samples/circular-chunks-warning-caused-by-manual-chunks-conflict/_expected/system/generated-ac.js @@ -0,0 +1,18 @@ +System.register(['./generated-b.js'], (function (exports) { + 'use strict'; + var b; + return { + setters: [function (module) { + b = module.b; + }], + execute: (function () { + + const c = exports("c", 'c'); + console.log(c); + + const a = exports("a", 'a'); + console.log(a + b); + + }) + }; +})); diff --git a/test/chunking-form/samples/circular-chunks-warning-caused-by-manual-chunks-conflict/_expected/system/generated-b.js b/test/chunking-form/samples/circular-chunks-warning-caused-by-manual-chunks-conflict/_expected/system/generated-b.js new file mode 100644 index 00000000000..f99ee1e23dc --- /dev/null +++ b/test/chunking-form/samples/circular-chunks-warning-caused-by-manual-chunks-conflict/_expected/system/generated-b.js @@ -0,0 +1,15 @@ +System.register(['./generated-ac.js'], (function (exports) { + 'use strict'; + var c; + return { + setters: [function (module) { + c = module.c; + }], + execute: (function () { + + const b = exports("b", 'b'); + console.log(b + c); + + }) + }; +})); diff --git a/test/chunking-form/samples/circular-chunks-warning-caused-by-manual-chunks-conflict/_expected/system/main.js b/test/chunking-form/samples/circular-chunks-warning-caused-by-manual-chunks-conflict/_expected/system/main.js new file mode 100644 index 00000000000..dfa468f4626 --- /dev/null +++ b/test/chunking-form/samples/circular-chunks-warning-caused-by-manual-chunks-conflict/_expected/system/main.js @@ -0,0 +1,14 @@ +System.register(['./generated-ac.js', './generated-b.js'], (function () { + 'use strict'; + var a; + return { + setters: [function (module) { + a = module.a; + }, null], + execute: (function () { + + console.log(a); + + }) + }; +})); diff --git a/test/chunking-form/samples/circular-chunks-warning-caused-by-manual-chunks-conflict/a.js b/test/chunking-form/samples/circular-chunks-warning-caused-by-manual-chunks-conflict/a.js new file mode 100644 index 00000000000..0d5d8d34122 --- /dev/null +++ b/test/chunking-form/samples/circular-chunks-warning-caused-by-manual-chunks-conflict/a.js @@ -0,0 +1,4 @@ +import { b } from './b.js'; +const a = 'a'; +console.log(a + b); +export { a } diff --git a/test/chunking-form/samples/circular-chunks-warning-caused-by-manual-chunks-conflict/b.js b/test/chunking-form/samples/circular-chunks-warning-caused-by-manual-chunks-conflict/b.js new file mode 100644 index 00000000000..f57d3c3eef2 --- /dev/null +++ b/test/chunking-form/samples/circular-chunks-warning-caused-by-manual-chunks-conflict/b.js @@ -0,0 +1,4 @@ +import { c } from './c.js'; +const b = 'b'; +console.log(b + c); +export { b } diff --git a/test/chunking-form/samples/circular-chunks-warning-caused-by-manual-chunks-conflict/c.js b/test/chunking-form/samples/circular-chunks-warning-caused-by-manual-chunks-conflict/c.js new file mode 100644 index 00000000000..791276a8f6e --- /dev/null +++ b/test/chunking-form/samples/circular-chunks-warning-caused-by-manual-chunks-conflict/c.js @@ -0,0 +1,3 @@ +const c = 'c'; +console.log(c); +export { c } diff --git a/test/chunking-form/samples/circular-chunks-warning-caused-by-manual-chunks-conflict/main.js b/test/chunking-form/samples/circular-chunks-warning-caused-by-manual-chunks-conflict/main.js new file mode 100644 index 00000000000..aeca4539049 --- /dev/null +++ b/test/chunking-form/samples/circular-chunks-warning-caused-by-manual-chunks-conflict/main.js @@ -0,0 +1,2 @@ +import {a} from './a.js'; +console.log(a); diff --git a/test/chunking-form/samples/circular-chunks-warning-caused-by-only-explicit-manual-chunks/_config.js b/test/chunking-form/samples/circular-chunks-warning-caused-by-only-explicit-manual-chunks/_config.js new file mode 100644 index 00000000000..dc0e3a17e0d --- /dev/null +++ b/test/chunking-form/samples/circular-chunks-warning-caused-by-only-explicit-manual-chunks/_config.js @@ -0,0 +1,19 @@ +module.exports = defineTest({ + description: 'Throw a warning for circular chunks caused by onlyExplicitManualChunks', + options: { + output: { + manualChunks(id) { + if (id.endsWith('a.js') || id.endsWith('c.js')) return 'ac'; + }, + onlyExplicitManualChunks: true + } + }, + expectedWarnings: ['CIRCULAR_CHUNK'], + logs: new Array(4).fill(null).map(() => ({ + code: 'CIRCULAR_CHUNK', + ids: ['main', 'ac', 'main'], + level: 'warn', + message: + 'Circular chunk: main -> ac -> main. Consider disabling the "output.onlyExplicitManualChunks" option, as enabling it causes the static dependencies of the manual chunk "ac" to be bundled into the chunk "main".' + })) +}); diff --git a/test/chunking-form/samples/circular-chunks-warning-caused-by-only-explicit-manual-chunks/_expected/amd/generated-ac.js b/test/chunking-form/samples/circular-chunks-warning-caused-by-only-explicit-manual-chunks/_expected/amd/generated-ac.js new file mode 100644 index 00000000000..414454c5374 --- /dev/null +++ b/test/chunking-form/samples/circular-chunks-warning-caused-by-only-explicit-manual-chunks/_expected/amd/generated-ac.js @@ -0,0 +1,12 @@ +define(['exports', './main'], (function (exports, main) { 'use strict'; + + const c = 'c'; + console.log(c); + + const a = 'a'; + console.log(a + main.b); + + exports.a = a; + exports.c = c; + +})); diff --git a/test/chunking-form/samples/circular-chunks-warning-caused-by-only-explicit-manual-chunks/_expected/amd/main.js b/test/chunking-form/samples/circular-chunks-warning-caused-by-only-explicit-manual-chunks/_expected/amd/main.js new file mode 100644 index 00000000000..2974c7d5ae5 --- /dev/null +++ b/test/chunking-form/samples/circular-chunks-warning-caused-by-only-explicit-manual-chunks/_expected/amd/main.js @@ -0,0 +1,10 @@ +define(['exports', './generated-ac', './main'], (function (exports, ac, main) { 'use strict'; + + const b = 'b'; + console.log(b + ac.c); + + console.log(ac.a); + + exports.b = b; + +})); diff --git a/test/chunking-form/samples/circular-chunks-warning-caused-by-only-explicit-manual-chunks/_expected/cjs/generated-ac.js b/test/chunking-form/samples/circular-chunks-warning-caused-by-only-explicit-manual-chunks/_expected/cjs/generated-ac.js new file mode 100644 index 00000000000..ed1bc6eb3a6 --- /dev/null +++ b/test/chunking-form/samples/circular-chunks-warning-caused-by-only-explicit-manual-chunks/_expected/cjs/generated-ac.js @@ -0,0 +1,12 @@ +'use strict'; + +var main = require('./main.js'); + +const c = 'c'; +console.log(c); + +const a = 'a'; +console.log(a + main.b); + +exports.a = a; +exports.c = c; diff --git a/test/chunking-form/samples/circular-chunks-warning-caused-by-only-explicit-manual-chunks/_expected/cjs/main.js b/test/chunking-form/samples/circular-chunks-warning-caused-by-only-explicit-manual-chunks/_expected/cjs/main.js new file mode 100644 index 00000000000..e41db390582 --- /dev/null +++ b/test/chunking-form/samples/circular-chunks-warning-caused-by-only-explicit-manual-chunks/_expected/cjs/main.js @@ -0,0 +1,11 @@ +'use strict'; + +var ac = require('./generated-ac.js'); +require('./main.js'); + +const b = 'b'; +console.log(b + ac.c); + +console.log(ac.a); + +exports.b = b; diff --git a/test/chunking-form/samples/circular-chunks-warning-caused-by-only-explicit-manual-chunks/_expected/es/generated-ac.js b/test/chunking-form/samples/circular-chunks-warning-caused-by-only-explicit-manual-chunks/_expected/es/generated-ac.js new file mode 100644 index 00000000000..62117c43160 --- /dev/null +++ b/test/chunking-form/samples/circular-chunks-warning-caused-by-only-explicit-manual-chunks/_expected/es/generated-ac.js @@ -0,0 +1,9 @@ +import { b } from './main.js'; + +const c = 'c'; +console.log(c); + +const a = 'a'; +console.log(a + b); + +export { a, c }; diff --git a/test/chunking-form/samples/circular-chunks-warning-caused-by-only-explicit-manual-chunks/_expected/es/main.js b/test/chunking-form/samples/circular-chunks-warning-caused-by-only-explicit-manual-chunks/_expected/es/main.js new file mode 100644 index 00000000000..3d419ef4efe --- /dev/null +++ b/test/chunking-form/samples/circular-chunks-warning-caused-by-only-explicit-manual-chunks/_expected/es/main.js @@ -0,0 +1,9 @@ +import { c, a } from './generated-ac.js'; +import './main.js'; + +const b = 'b'; +console.log(b + c); + +console.log(a); + +export { b }; diff --git a/test/chunking-form/samples/circular-chunks-warning-caused-by-only-explicit-manual-chunks/_expected/system/generated-ac.js b/test/chunking-form/samples/circular-chunks-warning-caused-by-only-explicit-manual-chunks/_expected/system/generated-ac.js new file mode 100644 index 00000000000..b9583d60d3e --- /dev/null +++ b/test/chunking-form/samples/circular-chunks-warning-caused-by-only-explicit-manual-chunks/_expected/system/generated-ac.js @@ -0,0 +1,18 @@ +System.register(['./main.js'], (function (exports) { + 'use strict'; + var b; + return { + setters: [function (module) { + b = module.b; + }], + execute: (function () { + + const c = exports("c", 'c'); + console.log(c); + + const a = exports("a", 'a'); + console.log(a + b); + + }) + }; +})); diff --git a/test/chunking-form/samples/circular-chunks-warning-caused-by-only-explicit-manual-chunks/_expected/system/main.js b/test/chunking-form/samples/circular-chunks-warning-caused-by-only-explicit-manual-chunks/_expected/system/main.js new file mode 100644 index 00000000000..f322bfbb2a6 --- /dev/null +++ b/test/chunking-form/samples/circular-chunks-warning-caused-by-only-explicit-manual-chunks/_expected/system/main.js @@ -0,0 +1,18 @@ +System.register(['./generated-ac.js', './main.js'], (function (exports) { + 'use strict'; + var c, a; + return { + setters: [function (module) { + c = module.c; + a = module.a; + }, null], + execute: (function () { + + const b = exports("b", 'b'); + console.log(b + c); + + console.log(a); + + }) + }; +})); diff --git a/test/chunking-form/samples/circular-chunks-warning-caused-by-only-explicit-manual-chunks/a.js b/test/chunking-form/samples/circular-chunks-warning-caused-by-only-explicit-manual-chunks/a.js new file mode 100644 index 00000000000..0d5d8d34122 --- /dev/null +++ b/test/chunking-form/samples/circular-chunks-warning-caused-by-only-explicit-manual-chunks/a.js @@ -0,0 +1,4 @@ +import { b } from './b.js'; +const a = 'a'; +console.log(a + b); +export { a } diff --git a/test/chunking-form/samples/circular-chunks-warning-caused-by-only-explicit-manual-chunks/b.js b/test/chunking-form/samples/circular-chunks-warning-caused-by-only-explicit-manual-chunks/b.js new file mode 100644 index 00000000000..f57d3c3eef2 --- /dev/null +++ b/test/chunking-form/samples/circular-chunks-warning-caused-by-only-explicit-manual-chunks/b.js @@ -0,0 +1,4 @@ +import { c } from './c.js'; +const b = 'b'; +console.log(b + c); +export { b } diff --git a/test/chunking-form/samples/circular-chunks-warning-caused-by-only-explicit-manual-chunks/c.js b/test/chunking-form/samples/circular-chunks-warning-caused-by-only-explicit-manual-chunks/c.js new file mode 100644 index 00000000000..791276a8f6e --- /dev/null +++ b/test/chunking-form/samples/circular-chunks-warning-caused-by-only-explicit-manual-chunks/c.js @@ -0,0 +1,3 @@ +const c = 'c'; +console.log(c); +export { c } diff --git a/test/chunking-form/samples/circular-chunks-warning-caused-by-only-explicit-manual-chunks/main.js b/test/chunking-form/samples/circular-chunks-warning-caused-by-only-explicit-manual-chunks/main.js new file mode 100644 index 00000000000..aeca4539049 --- /dev/null +++ b/test/chunking-form/samples/circular-chunks-warning-caused-by-only-explicit-manual-chunks/main.js @@ -0,0 +1,2 @@ +import {a} from './a.js'; +console.log(a); diff --git a/test/chunking-form/samples/circular-entry-points/_config.js b/test/chunking-form/samples/circular-entry-points/_config.js index c594e1ff53b..b12b129c5df 100644 --- a/test/chunking-form/samples/circular-entry-points/_config.js +++ b/test/chunking-form/samples/circular-entry-points/_config.js @@ -1,7 +1,7 @@ -module.exports = { +module.exports = defineTest({ description: 'chunking circular entry points', expectedWarnings: ['CIRCULAR_DEPENDENCY'], options: { input: ['main1.js', 'main2.js'] } -}; +}); diff --git a/test/chunking-form/samples/circular-entry-points/_expected/amd/generated-main1.js b/test/chunking-form/samples/circular-entry-points/_expected/amd/generated-main1.js deleted file mode 100644 index 7d3b2d0e505..00000000000 --- a/test/chunking-form/samples/circular-entry-points/_expected/amd/generated-main1.js +++ /dev/null @@ -1,26 +0,0 @@ -define(['exports'], function (exports) { 'use strict'; - - class C$1 { - fn (num) { - console.log(num - p); - } - } - - var p$1 = 43; - - new C$1().fn(p$1); - - class C { - fn (num) { - console.log(num - p$1); - } - } - - var p = 42; - - new C().fn(p); - - exports.p = p$1; - exports.p$1 = p; - -}); diff --git a/test/chunking-form/samples/circular-entry-points/_expected/amd/main1.js b/test/chunking-form/samples/circular-entry-points/_expected/amd/main1.js index 0ab330944b0..060fe89af3d 100644 --- a/test/chunking-form/samples/circular-entry-points/_expected/amd/main1.js +++ b/test/chunking-form/samples/circular-entry-points/_expected/amd/main1.js @@ -1,9 +1,7 @@ -define(['exports', './generated-main1'], function (exports, main2) { 'use strict'; +define(['exports', './main2'], (function (exports, main2) { 'use strict'; exports.p = main2.p$1; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/circular-entry-points/_expected/amd/main2.js b/test/chunking-form/samples/circular-entry-points/_expected/amd/main2.js index 31b181d41f3..fd709c6671b 100644 --- a/test/chunking-form/samples/circular-entry-points/_expected/amd/main2.js +++ b/test/chunking-form/samples/circular-entry-points/_expected/amd/main2.js @@ -1,9 +1,26 @@ -define(['exports', './generated-main1'], function (exports, main2) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; + let C$1 = class C { + fn (num) { + console.log(num - p); + } + }; + var p$1 = 43; - exports.p = main2.p; + new C$1().fn(p$1); - Object.defineProperty(exports, '__esModule', { value: true }); + class C { + fn (num) { + console.log(num - p$1); + } + } -}); + var p = 42; + + new C().fn(p); + + exports.p = p$1; + exports.p$1 = p; + +})); diff --git a/test/chunking-form/samples/circular-entry-points/_expected/cjs/generated-main1.js b/test/chunking-form/samples/circular-entry-points/_expected/cjs/generated-main1.js deleted file mode 100644 index a930fd89967..00000000000 --- a/test/chunking-form/samples/circular-entry-points/_expected/cjs/generated-main1.js +++ /dev/null @@ -1,24 +0,0 @@ -'use strict'; - -class C$1 { - fn (num) { - console.log(num - p); - } -} - -var p$1 = 43; - -new C$1().fn(p$1); - -class C { - fn (num) { - console.log(num - p$1); - } -} - -var p = 42; - -new C().fn(p); - -exports.p = p$1; -exports.p$1 = p; diff --git a/test/chunking-form/samples/circular-entry-points/_expected/cjs/main1.js b/test/chunking-form/samples/circular-entry-points/_expected/cjs/main1.js index a5ec2910766..983fb7c9f41 100644 --- a/test/chunking-form/samples/circular-entry-points/_expected/cjs/main1.js +++ b/test/chunking-form/samples/circular-entry-points/_expected/cjs/main1.js @@ -1,8 +1,6 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - -var main2 = require('./generated-main1.js'); +var main2 = require('./main2.js'); diff --git a/test/chunking-form/samples/circular-entry-points/_expected/cjs/main2.js b/test/chunking-form/samples/circular-entry-points/_expected/cjs/main2.js index 0b9366cd0e2..4b6651abf50 100644 --- a/test/chunking-form/samples/circular-entry-points/_expected/cjs/main2.js +++ b/test/chunking-form/samples/circular-entry-points/_expected/cjs/main2.js @@ -1,9 +1,24 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); +let C$1 = class C { + fn (num) { + console.log(num - p); + } +}; -var main2 = require('./generated-main1.js'); +var p$1 = 43; +new C$1().fn(p$1); +class C { + fn (num) { + console.log(num - p$1); + } +} -exports.p = main2.p; +var p = 42; + +new C().fn(p); + +exports.p = p$1; +exports.p$1 = p; diff --git a/test/chunking-form/samples/circular-entry-points/_expected/es/generated-main1.js b/test/chunking-form/samples/circular-entry-points/_expected/es/generated-main1.js deleted file mode 100644 index 27379cf813d..00000000000 --- a/test/chunking-form/samples/circular-entry-points/_expected/es/generated-main1.js +++ /dev/null @@ -1,21 +0,0 @@ -class C$1 { - fn (num) { - console.log(num - p); - } -} - -var p$1 = 43; - -new C$1().fn(p$1); - -class C { - fn (num) { - console.log(num - p$1); - } -} - -var p = 42; - -new C().fn(p); - -export { p as a, p$1 as p }; diff --git a/test/chunking-form/samples/circular-entry-points/_expected/es/main1.js b/test/chunking-form/samples/circular-entry-points/_expected/es/main1.js index 0a83cdd426e..8d3627c9c9d 100644 --- a/test/chunking-form/samples/circular-entry-points/_expected/es/main1.js +++ b/test/chunking-form/samples/circular-entry-points/_expected/es/main1.js @@ -1 +1 @@ -export { a as p } from './generated-main1.js'; +export { a as p } from './main2.js'; diff --git a/test/chunking-form/samples/circular-entry-points/_expected/es/main2.js b/test/chunking-form/samples/circular-entry-points/_expected/es/main2.js index b1a60375e3b..f8011f29482 100644 --- a/test/chunking-form/samples/circular-entry-points/_expected/es/main2.js +++ b/test/chunking-form/samples/circular-entry-points/_expected/es/main2.js @@ -1 +1,21 @@ -export { p } from './generated-main1.js'; +let C$1 = class C { + fn (num) { + console.log(num - p); + } +}; + +var p$1 = 43; + +new C$1().fn(p$1); + +class C { + fn (num) { + console.log(num - p$1); + } +} + +var p = 42; + +new C().fn(p); + +export { p as a, p$1 as p }; diff --git a/test/chunking-form/samples/circular-entry-points/_expected/system/generated-main1.js b/test/chunking-form/samples/circular-entry-points/_expected/system/generated-main1.js deleted file mode 100644 index e77f4ad7ffb..00000000000 --- a/test/chunking-form/samples/circular-entry-points/_expected/system/generated-main1.js +++ /dev/null @@ -1,28 +0,0 @@ -System.register([], function (exports) { - 'use strict'; - return { - execute: function () { - - class C$1 { - fn (num) { - console.log(num - p); - } - } - - var p$1 = exports('p', 43); - - new C$1().fn(p$1); - - class C { - fn (num) { - console.log(num - p$1); - } - } - - var p = exports('a', 42); - - new C().fn(p); - - } - }; -}); diff --git a/test/chunking-form/samples/circular-entry-points/_expected/system/main1.js b/test/chunking-form/samples/circular-entry-points/_expected/system/main1.js index 491c2be1e9f..6313d040e48 100644 --- a/test/chunking-form/samples/circular-entry-points/_expected/system/main1.js +++ b/test/chunking-form/samples/circular-entry-points/_expected/system/main1.js @@ -1,13 +1,13 @@ -System.register(['./generated-main1.js'], function (exports) { +System.register(['./main2.js'], (function (exports) { 'use strict'; return { setters: [function (module) { - exports('p', module.a); + exports("p", module.a); }], - execute: function () { + execute: (function () { - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/circular-entry-points/_expected/system/main2.js b/test/chunking-form/samples/circular-entry-points/_expected/system/main2.js index 21397d608ec..99e0e674e4b 100644 --- a/test/chunking-form/samples/circular-entry-points/_expected/system/main2.js +++ b/test/chunking-form/samples/circular-entry-points/_expected/system/main2.js @@ -1,13 +1,28 @@ -System.register(['./generated-main1.js'], function (exports) { - 'use strict'; - return { - setters: [function (module) { - exports('p', module.p); - }], - execute: function () { +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + let C$1 = class C { + fn (num) { + console.log(num - p); + } + }; + var p$1 = exports("p", 43); - } - }; -}); + new C$1().fn(p$1); + + class C { + fn (num) { + console.log(num - p$1); + } + } + + var p = exports("a", 42); + + new C().fn(p); + + }) + }; +})); diff --git a/test/chunking-form/samples/circular-entry-points2/_config.js b/test/chunking-form/samples/circular-entry-points2/_config.js index 4894b95c53b..b3da7733aff 100644 --- a/test/chunking-form/samples/circular-entry-points2/_config.js +++ b/test/chunking-form/samples/circular-entry-points2/_config.js @@ -1,7 +1,7 @@ -module.exports = { +module.exports = defineTest({ description: 'does not create a facade for one circular entry point if possible', expectedWarnings: ['CIRCULAR_DEPENDENCY'], options: { input: ['main1.js', 'main2.js'] } -}; +}); diff --git a/test/chunking-form/samples/circular-entry-points2/_expected/amd/main1.js b/test/chunking-form/samples/circular-entry-points2/_expected/amd/main1.js index 0c0e9f7352f..dbb53a4ecbc 100644 --- a/test/chunking-form/samples/circular-entry-points2/_expected/amd/main1.js +++ b/test/chunking-form/samples/circular-entry-points2/_expected/amd/main1.js @@ -1,9 +1,7 @@ -define(['exports', './main2'], function (exports, main2) { 'use strict'; +define(['exports', './main2'], (function (exports, main2) { 'use strict'; exports.p = main2.p2; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/circular-entry-points2/_expected/amd/main2.js b/test/chunking-form/samples/circular-entry-points2/_expected/amd/main2.js index 80034ef4326..2abda26ae68 100644 --- a/test/chunking-form/samples/circular-entry-points2/_expected/amd/main2.js +++ b/test/chunking-form/samples/circular-entry-points2/_expected/amd/main2.js @@ -1,10 +1,10 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; - class C$1 { + let C$1 = class C { fn (num) { console.log(num - p); } - } + }; var p$1 = 43; @@ -23,6 +23,4 @@ define(['exports'], function (exports) { 'use strict'; exports.p = p$1; exports.p2 = p; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/circular-entry-points2/_expected/cjs/main1.js b/test/chunking-form/samples/circular-entry-points2/_expected/cjs/main1.js index 3e8554d3bd1..1679b725edb 100644 --- a/test/chunking-form/samples/circular-entry-points2/_expected/cjs/main1.js +++ b/test/chunking-form/samples/circular-entry-points2/_expected/cjs/main1.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - var main2 = require('./main2.js'); diff --git a/test/chunking-form/samples/circular-entry-points2/_expected/cjs/main2.js b/test/chunking-form/samples/circular-entry-points2/_expected/cjs/main2.js index 953be18833a..9b0f760095c 100644 --- a/test/chunking-form/samples/circular-entry-points2/_expected/cjs/main2.js +++ b/test/chunking-form/samples/circular-entry-points2/_expected/cjs/main2.js @@ -1,12 +1,10 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - -class C$1 { +let C$1 = class C { fn (num) { console.log(num - p); } -} +}; var p$1 = 43; diff --git a/test/chunking-form/samples/circular-entry-points2/_expected/es/main2.js b/test/chunking-form/samples/circular-entry-points2/_expected/es/main2.js index e4ea2f61743..ac842dd5d95 100644 --- a/test/chunking-form/samples/circular-entry-points2/_expected/es/main2.js +++ b/test/chunking-form/samples/circular-entry-points2/_expected/es/main2.js @@ -1,8 +1,8 @@ -class C$1 { +let C$1 = class C { fn (num) { console.log(num - p); } -} +}; var p$1 = 43; diff --git a/test/chunking-form/samples/circular-entry-points2/_expected/system/main1.js b/test/chunking-form/samples/circular-entry-points2/_expected/system/main1.js index 2b0dfa618c7..a33996a979f 100644 --- a/test/chunking-form/samples/circular-entry-points2/_expected/system/main1.js +++ b/test/chunking-form/samples/circular-entry-points2/_expected/system/main1.js @@ -1,13 +1,13 @@ -System.register(['./main2.js'], function (exports) { +System.register(['./main2.js'], (function (exports) { 'use strict'; return { setters: [function (module) { - exports('p', module.p2); + exports("p", module.p2); }], - execute: function () { + execute: (function () { - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/circular-entry-points2/_expected/system/main2.js b/test/chunking-form/samples/circular-entry-points2/_expected/system/main2.js index d14ace319de..a29131276cd 100644 --- a/test/chunking-form/samples/circular-entry-points2/_expected/system/main2.js +++ b/test/chunking-form/samples/circular-entry-points2/_expected/system/main2.js @@ -1,15 +1,15 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - class C$1 { + let C$1 = class C { fn (num) { console.log(num - p); } - } + }; - var p$1 = exports('p', 43); + var p$1 = exports("p", 43); new C$1().fn(p$1); @@ -19,10 +19,10 @@ System.register([], function (exports) { } } - var p = exports('p2', 42); + var p = exports("p2", 42); new C().fn(p); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/circular-entry-points3/_config.js b/test/chunking-form/samples/circular-entry-points3/_config.js index 8902b116aef..c73b3d824e6 100644 --- a/test/chunking-form/samples/circular-entry-points3/_config.js +++ b/test/chunking-form/samples/circular-entry-points3/_config.js @@ -1,8 +1,8 @@ -module.exports = { +module.exports = defineTest({ description: 'creates facades for all circular entry points if they become tainted by another entry', expectedWarnings: ['CIRCULAR_DEPENDENCY'], options: { input: ['main1.js', 'main2.js', 'main3.js'] } -}; +}); diff --git a/test/chunking-form/samples/circular-entry-points3/_expected/amd/generated-main1.js b/test/chunking-form/samples/circular-entry-points3/_expected/amd/generated-main1.js deleted file mode 100644 index 2290db65a8b..00000000000 --- a/test/chunking-form/samples/circular-entry-points3/_expected/amd/generated-main1.js +++ /dev/null @@ -1,27 +0,0 @@ -define(['exports'], function (exports) { 'use strict'; - - class C$1 { - fn (num) { - console.log(num - p); - } - } - - var p$1 = 43; - - new C$1().fn(p$1); - - class C { - fn (num) { - console.log(num - p$1); - } - } - - var p = 42; - - new C().fn(p); - - exports.C = C$1; - exports.p = p$1; - exports.p$1 = p; - -}); diff --git a/test/chunking-form/samples/circular-entry-points3/_expected/amd/main1.js b/test/chunking-form/samples/circular-entry-points3/_expected/amd/main1.js index 0ab330944b0..dbb53a4ecbc 100644 --- a/test/chunking-form/samples/circular-entry-points3/_expected/amd/main1.js +++ b/test/chunking-form/samples/circular-entry-points3/_expected/amd/main1.js @@ -1,9 +1,7 @@ -define(['exports', './generated-main1'], function (exports, main2) { 'use strict'; +define(['exports', './main2'], (function (exports, main2) { 'use strict'; - exports.p = main2.p$1; + exports.p = main2.p2; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/circular-entry-points3/_expected/amd/main2.js b/test/chunking-form/samples/circular-entry-points3/_expected/amd/main2.js index 5c35d167805..50d3e726ea4 100644 --- a/test/chunking-form/samples/circular-entry-points3/_expected/amd/main2.js +++ b/test/chunking-form/samples/circular-entry-points3/_expected/amd/main2.js @@ -1,10 +1,27 @@ -define(['exports', './generated-main1'], function (exports, main2) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; + let C$1 = class C { + fn (num) { + console.log(num - p); + } + }; + var p$1 = 43; - exports.p = main2.p; - exports.p2 = main2.p$1; + new C$1().fn(p$1); - Object.defineProperty(exports, '__esModule', { value: true }); + class C { + fn (num) { + console.log(num - p$1); + } + } -}); + var p = 42; + + new C().fn(p); + + exports.C = C$1; + exports.p = p$1; + exports.p2 = p; + +})); diff --git a/test/chunking-form/samples/circular-entry-points3/_expected/amd/main3.js b/test/chunking-form/samples/circular-entry-points3/_expected/amd/main3.js index 18d49d297a1..4205149e63f 100644 --- a/test/chunking-form/samples/circular-entry-points3/_expected/amd/main3.js +++ b/test/chunking-form/samples/circular-entry-points3/_expected/amd/main3.js @@ -1,9 +1,7 @@ -define(['exports', './generated-main1'], function (exports, main2) { 'use strict'; +define(['exports', './main2'], (function (exports, main2) { 'use strict'; exports.C = main2.C; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/circular-entry-points3/_expected/cjs/generated-main1.js b/test/chunking-form/samples/circular-entry-points3/_expected/cjs/generated-main1.js deleted file mode 100644 index e1ec1ce79e3..00000000000 --- a/test/chunking-form/samples/circular-entry-points3/_expected/cjs/generated-main1.js +++ /dev/null @@ -1,25 +0,0 @@ -'use strict'; - -class C$1 { - fn (num) { - console.log(num - p); - } -} - -var p$1 = 43; - -new C$1().fn(p$1); - -class C { - fn (num) { - console.log(num - p$1); - } -} - -var p = 42; - -new C().fn(p); - -exports.C = C$1; -exports.p = p$1; -exports.p$1 = p; diff --git a/test/chunking-form/samples/circular-entry-points3/_expected/cjs/main1.js b/test/chunking-form/samples/circular-entry-points3/_expected/cjs/main1.js index a5ec2910766..1679b725edb 100644 --- a/test/chunking-form/samples/circular-entry-points3/_expected/cjs/main1.js +++ b/test/chunking-form/samples/circular-entry-points3/_expected/cjs/main1.js @@ -1,9 +1,7 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); +var main2 = require('./main2.js'); -var main2 = require('./generated-main1.js'); - -exports.p = main2.p$1; +exports.p = main2.p2; diff --git a/test/chunking-form/samples/circular-entry-points3/_expected/cjs/main2.js b/test/chunking-form/samples/circular-entry-points3/_expected/cjs/main2.js index bc1e103d7c1..5b2b2243d25 100644 --- a/test/chunking-form/samples/circular-entry-points3/_expected/cjs/main2.js +++ b/test/chunking-form/samples/circular-entry-points3/_expected/cjs/main2.js @@ -1,10 +1,25 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); +let C$1 = class C { + fn (num) { + console.log(num - p); + } +}; -var main2 = require('./generated-main1.js'); +var p$1 = 43; +new C$1().fn(p$1); +class C { + fn (num) { + console.log(num - p$1); + } +} -exports.p = main2.p; -exports.p2 = main2.p$1; +var p = 42; + +new C().fn(p); + +exports.C = C$1; +exports.p = p$1; +exports.p2 = p; diff --git a/test/chunking-form/samples/circular-entry-points3/_expected/cjs/main3.js b/test/chunking-form/samples/circular-entry-points3/_expected/cjs/main3.js index e89188ab5e8..c053c9f4717 100644 --- a/test/chunking-form/samples/circular-entry-points3/_expected/cjs/main3.js +++ b/test/chunking-form/samples/circular-entry-points3/_expected/cjs/main3.js @@ -1,8 +1,6 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - -var main2 = require('./generated-main1.js'); +var main2 = require('./main2.js'); diff --git a/test/chunking-form/samples/circular-entry-points3/_expected/es/generated-main1.js b/test/chunking-form/samples/circular-entry-points3/_expected/es/generated-main1.js deleted file mode 100644 index d31e8c0e1f9..00000000000 --- a/test/chunking-form/samples/circular-entry-points3/_expected/es/generated-main1.js +++ /dev/null @@ -1,21 +0,0 @@ -class C$1 { - fn (num) { - console.log(num - p); - } -} - -var p$1 = 43; - -new C$1().fn(p$1); - -class C { - fn (num) { - console.log(num - p$1); - } -} - -var p = 42; - -new C().fn(p); - -export { C$1 as C, p as a, p$1 as p }; diff --git a/test/chunking-form/samples/circular-entry-points3/_expected/es/main1.js b/test/chunking-form/samples/circular-entry-points3/_expected/es/main1.js index 0a83cdd426e..1f1e926d922 100644 --- a/test/chunking-form/samples/circular-entry-points3/_expected/es/main1.js +++ b/test/chunking-form/samples/circular-entry-points3/_expected/es/main1.js @@ -1 +1 @@ -export { a as p } from './generated-main1.js'; +export { p2 as p } from './main2.js'; diff --git a/test/chunking-form/samples/circular-entry-points3/_expected/es/main2.js b/test/chunking-form/samples/circular-entry-points3/_expected/es/main2.js index 422b3e863a5..6e4381bcfc1 100644 --- a/test/chunking-form/samples/circular-entry-points3/_expected/es/main2.js +++ b/test/chunking-form/samples/circular-entry-points3/_expected/es/main2.js @@ -1 +1,21 @@ -export { p, a as p2 } from './generated-main1.js'; +let C$1 = class C { + fn (num) { + console.log(num - p); + } +}; + +var p$1 = 43; + +new C$1().fn(p$1); + +class C { + fn (num) { + console.log(num - p$1); + } +} + +var p = 42; + +new C().fn(p); + +export { C$1 as C, p$1 as p, p as p2 }; diff --git a/test/chunking-form/samples/circular-entry-points3/_expected/es/main3.js b/test/chunking-form/samples/circular-entry-points3/_expected/es/main3.js index 541321f375e..2f61347a388 100644 --- a/test/chunking-form/samples/circular-entry-points3/_expected/es/main3.js +++ b/test/chunking-form/samples/circular-entry-points3/_expected/es/main3.js @@ -1 +1 @@ -export { C } from './generated-main1.js'; +export { C } from './main2.js'; diff --git a/test/chunking-form/samples/circular-entry-points3/_expected/system/generated-main1.js b/test/chunking-form/samples/circular-entry-points3/_expected/system/generated-main1.js deleted file mode 100644 index c39474ed4e3..00000000000 --- a/test/chunking-form/samples/circular-entry-points3/_expected/system/generated-main1.js +++ /dev/null @@ -1,28 +0,0 @@ -System.register([], function (exports) { - 'use strict'; - return { - execute: function () { - - class C$1 { - fn (num) { - console.log(num - p); - } - } exports('C', C$1); - - var p$1 = exports('p', 43); - - new C$1().fn(p$1); - - class C { - fn (num) { - console.log(num - p$1); - } - } - - var p = exports('a', 42); - - new C().fn(p); - - } - }; -}); diff --git a/test/chunking-form/samples/circular-entry-points3/_expected/system/main1.js b/test/chunking-form/samples/circular-entry-points3/_expected/system/main1.js index 491c2be1e9f..a33996a979f 100644 --- a/test/chunking-form/samples/circular-entry-points3/_expected/system/main1.js +++ b/test/chunking-form/samples/circular-entry-points3/_expected/system/main1.js @@ -1,13 +1,13 @@ -System.register(['./generated-main1.js'], function (exports) { +System.register(['./main2.js'], (function (exports) { 'use strict'; return { setters: [function (module) { - exports('p', module.a); + exports("p", module.p2); }], - execute: function () { + execute: (function () { - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/circular-entry-points3/_expected/system/main2.js b/test/chunking-form/samples/circular-entry-points3/_expected/system/main2.js index f3c05e2aa76..378a2711a2f 100644 --- a/test/chunking-form/samples/circular-entry-points3/_expected/system/main2.js +++ b/test/chunking-form/samples/circular-entry-points3/_expected/system/main2.js @@ -1,16 +1,28 @@ -System.register(['./generated-main1.js'], function (exports) { - 'use strict'; - return { - setters: [function (module) { - var _setter = {}; - _setter.p = module.p; - _setter.p2 = module.a; - exports(_setter); - }], - execute: function () { +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + let C$1 = class C { + fn (num) { + console.log(num - p); + } + }; exports("C", C$1); + var p$1 = exports("p", 43); - } - }; -}); + new C$1().fn(p$1); + + class C { + fn (num) { + console.log(num - p$1); + } + } + + var p = exports("p2", 42); + + new C().fn(p); + + }) + }; +})); diff --git a/test/chunking-form/samples/circular-entry-points3/_expected/system/main3.js b/test/chunking-form/samples/circular-entry-points3/_expected/system/main3.js index d4d8510a240..73777e9550e 100644 --- a/test/chunking-form/samples/circular-entry-points3/_expected/system/main3.js +++ b/test/chunking-form/samples/circular-entry-points3/_expected/system/main3.js @@ -1,13 +1,13 @@ -System.register(['./generated-main1.js'], function (exports) { +System.register(['./main2.js'], (function (exports) { 'use strict'; return { setters: [function (module) { - exports('C', module.C); + exports("C", module.C); }], - execute: function () { + execute: (function () { - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/circular-manual-chunks/_config.js b/test/chunking-form/samples/circular-manual-chunks/_config.js index 4a03dcf2c88..53e61d3e65e 100644 --- a/test/chunking-form/samples/circular-manual-chunks/_config.js +++ b/test/chunking-form/samples/circular-manual-chunks/_config.js @@ -1,8 +1,8 @@ -module.exports = { +module.exports = defineTest({ description: 'handles manual chunks with circular dependencies', - expectedWarnings: ['CIRCULAR_DEPENDENCY'], + expectedWarnings: ['CIRCULAR_DEPENDENCY', 'CIRCULAR_CHUNK'], options: { input: 'main', output: { manualChunks: { lib1: ['lib1'], lib2: ['lib2'] } } } -}; +}); diff --git a/test/chunking-form/samples/circular-manual-chunks/_expected/amd/generated-lib1.js b/test/chunking-form/samples/circular-manual-chunks/_expected/amd/generated-lib1.js index 257a2531b61..d53e713d2af 100644 --- a/test/chunking-form/samples/circular-manual-chunks/_expected/amd/generated-lib1.js +++ b/test/chunking-form/samples/circular-manual-chunks/_expected/amd/generated-lib1.js @@ -1,8 +1,8 @@ -define(['exports', './generated-lib2'], function (exports, lib2) { 'use strict'; +define(['exports', './generated-lib2'], (function (exports, lib2) { 'use strict'; const lib1 = 'lib1'; console.log(`${lib1} imports ${lib2.lib2}`); exports.lib1 = lib1; -}); +})); diff --git a/test/chunking-form/samples/circular-manual-chunks/_expected/amd/generated-lib2.js b/test/chunking-form/samples/circular-manual-chunks/_expected/amd/generated-lib2.js index 2d731c52482..4910275ea03 100644 --- a/test/chunking-form/samples/circular-manual-chunks/_expected/amd/generated-lib2.js +++ b/test/chunking-form/samples/circular-manual-chunks/_expected/amd/generated-lib2.js @@ -1,8 +1,8 @@ -define(['exports', './generated-lib1'], function (exports, lib1) { 'use strict'; +define(['exports', './generated-lib1'], (function (exports, lib1) { 'use strict'; const lib2 = 'lib2'; console.log(`${lib2} imports ${lib1.lib1}`); exports.lib2 = lib2; -}); +})); diff --git a/test/chunking-form/samples/circular-manual-chunks/_expected/amd/main.js b/test/chunking-form/samples/circular-manual-chunks/_expected/amd/main.js index bb9152d6ae4..0fbe5aa7e54 100644 --- a/test/chunking-form/samples/circular-manual-chunks/_expected/amd/main.js +++ b/test/chunking-form/samples/circular-manual-chunks/_expected/amd/main.js @@ -1,9 +1,7 @@ -define(['exports', './generated-lib1', './generated-lib2'], function (exports, lib1, lib2) { 'use strict'; +define(['exports', './generated-lib1', './generated-lib2'], (function (exports, lib1, lib2) { 'use strict'; exports.lib1 = lib1.lib1; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/circular-manual-chunks/_expected/cjs/main.js b/test/chunking-form/samples/circular-manual-chunks/_expected/cjs/main.js index 8ca369a5e0b..0a949dc0f1c 100644 --- a/test/chunking-form/samples/circular-manual-chunks/_expected/cjs/main.js +++ b/test/chunking-form/samples/circular-manual-chunks/_expected/cjs/main.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - var lib1 = require('./generated-lib1.js'); require('./generated-lib2.js'); diff --git a/test/chunking-form/samples/circular-manual-chunks/_expected/system/generated-lib1.js b/test/chunking-form/samples/circular-manual-chunks/_expected/system/generated-lib1.js index 482dde2146a..535a199fc1c 100644 --- a/test/chunking-form/samples/circular-manual-chunks/_expected/system/generated-lib1.js +++ b/test/chunking-form/samples/circular-manual-chunks/_expected/system/generated-lib1.js @@ -1,15 +1,15 @@ -System.register(['./generated-lib2.js'], function (exports) { +System.register(['./generated-lib2.js'], (function (exports) { 'use strict'; var lib2; return { setters: [function (module) { lib2 = module.l; }], - execute: function () { + execute: (function () { - const lib1 = exports('l', 'lib1'); + const lib1 = exports("l", 'lib1'); console.log(`${lib1} imports ${lib2}`); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/circular-manual-chunks/_expected/system/generated-lib2.js b/test/chunking-form/samples/circular-manual-chunks/_expected/system/generated-lib2.js index d1beca4b879..0f57c3770d0 100644 --- a/test/chunking-form/samples/circular-manual-chunks/_expected/system/generated-lib2.js +++ b/test/chunking-form/samples/circular-manual-chunks/_expected/system/generated-lib2.js @@ -1,15 +1,15 @@ -System.register(['./generated-lib1.js'], function (exports) { +System.register(['./generated-lib1.js'], (function (exports) { 'use strict'; var lib1; return { setters: [function (module) { lib1 = module.l; }], - execute: function () { + execute: (function () { - const lib2 = exports('l', 'lib2'); + const lib2 = exports("l", 'lib2'); console.log(`${lib2} imports ${lib1}`); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/circular-manual-chunks/_expected/system/main.js b/test/chunking-form/samples/circular-manual-chunks/_expected/system/main.js index 2bbc4fab8c6..bd2f4d32323 100644 --- a/test/chunking-form/samples/circular-manual-chunks/_expected/system/main.js +++ b/test/chunking-form/samples/circular-manual-chunks/_expected/system/main.js @@ -1,13 +1,13 @@ -System.register(['./generated-lib1.js', './generated-lib2.js'], function (exports) { +System.register(['./generated-lib1.js', './generated-lib2.js'], (function (exports) { 'use strict'; return { setters: [function (module) { - exports('lib1', module.l); - }, function () {}], - execute: function () { + exports("lib1", module.l); + }, null], + execute: (function () { - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/combined-namespace-reexport/_config.js b/test/chunking-form/samples/combined-namespace-reexport/_config.js index 7c41d4f14e8..c7ae8738bf7 100644 --- a/test/chunking-form/samples/combined-namespace-reexport/_config.js +++ b/test/chunking-form/samples/combined-namespace-reexport/_config.js @@ -1,6 +1,6 @@ -module.exports = { +module.exports = defineTest({ description: 'correctly handles combined namespace reexports', options: { input: ['main1', 'main2'] } -}; +}); diff --git a/test/chunking-form/samples/combined-namespace-reexport/_expected/amd/generated-geometry.js b/test/chunking-form/samples/combined-namespace-reexport/_expected/amd/generated-geometry.js index 20d78525e45..82863ed5b09 100644 --- a/test/chunking-form/samples/combined-namespace-reexport/_expected/amd/generated-geometry.js +++ b/test/chunking-form/samples/combined-namespace-reexport/_expected/amd/generated-geometry.js @@ -1,4 +1,4 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; const foo = 'foo'; @@ -19,4 +19,4 @@ define(['exports'], function (exports) { 'use strict'; exports.geometry = geometry; exports.volume = volume; -}); +})); diff --git a/test/chunking-form/samples/combined-namespace-reexport/_expected/amd/main1.js b/test/chunking-form/samples/combined-namespace-reexport/_expected/amd/main1.js index b2173934dfc..ac7396d126a 100644 --- a/test/chunking-form/samples/combined-namespace-reexport/_expected/amd/main1.js +++ b/test/chunking-form/samples/combined-namespace-reexport/_expected/amd/main1.js @@ -1,11 +1,11 @@ -define(['./generated-geometry'], function (geometry) { 'use strict'; +define(['./generated-geometry'], (function (geometry) { 'use strict'; var mod = /*#__PURE__*/Object.freeze({ __proto__: null, - volume: geometry.volume, - geometry: geometry.geometry + geometry: geometry.geometry, + volume: geometry.volume }); console.log(mod); -}); +})); diff --git a/test/chunking-form/samples/combined-namespace-reexport/_expected/amd/main2.js b/test/chunking-form/samples/combined-namespace-reexport/_expected/amd/main2.js index 64b26b0e785..2c2d40710a8 100644 --- a/test/chunking-form/samples/combined-namespace-reexport/_expected/amd/main2.js +++ b/test/chunking-form/samples/combined-namespace-reexport/_expected/amd/main2.js @@ -1,5 +1,5 @@ -define(['./generated-geometry'], function (geometry) { 'use strict'; +define(['./generated-geometry'], (function (geometry) { 'use strict'; console.log(geometry.foo, geometry.bar); -}); +})); diff --git a/test/chunking-form/samples/combined-namespace-reexport/_expected/cjs/main1.js b/test/chunking-form/samples/combined-namespace-reexport/_expected/cjs/main1.js index 334caa6cb79..a0ef60ca03e 100644 --- a/test/chunking-form/samples/combined-namespace-reexport/_expected/cjs/main1.js +++ b/test/chunking-form/samples/combined-namespace-reexport/_expected/cjs/main1.js @@ -4,8 +4,8 @@ var geometry = require('./generated-geometry.js'); var mod = /*#__PURE__*/Object.freeze({ __proto__: null, - volume: geometry.volume, - geometry: geometry.geometry + geometry: geometry.geometry, + volume: geometry.volume }); console.log(mod); diff --git a/test/chunking-form/samples/combined-namespace-reexport/_expected/es/main1.js b/test/chunking-form/samples/combined-namespace-reexport/_expected/es/main1.js index 6ac7ceecc36..e15bbf63c7c 100644 --- a/test/chunking-form/samples/combined-namespace-reexport/_expected/es/main1.js +++ b/test/chunking-form/samples/combined-namespace-reexport/_expected/es/main1.js @@ -1,9 +1,9 @@ -import { v as volume, g as geometry } from './generated-geometry.js'; +import { g as geometry, v as volume } from './generated-geometry.js'; var mod = /*#__PURE__*/Object.freeze({ __proto__: null, - volume: volume, - geometry: geometry + geometry: geometry, + volume: volume }); console.log(mod); diff --git a/test/chunking-form/samples/combined-namespace-reexport/_expected/system/generated-geometry.js b/test/chunking-form/samples/combined-namespace-reexport/_expected/system/generated-geometry.js index 8b902d37741..fdd1936cb18 100644 --- a/test/chunking-form/samples/combined-namespace-reexport/_expected/system/generated-geometry.js +++ b/test/chunking-form/samples/combined-namespace-reexport/_expected/system/generated-geometry.js @@ -1,24 +1,24 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - const foo = exports('f', 'foo'); + const foo = exports("f", 'foo'); var volume = /*#__PURE__*/Object.freeze({ __proto__: null, foo: foo }); - exports('v', volume); + exports("v", volume); - const bar = exports('b', 'bar'); + const bar = exports("b", 'bar'); var geometry = /*#__PURE__*/Object.freeze({ __proto__: null, bar: bar }); - exports('g', geometry); + exports("g", geometry); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/combined-namespace-reexport/_expected/system/main1.js b/test/chunking-form/samples/combined-namespace-reexport/_expected/system/main1.js index 5c19a95900c..a9cf9d11c4b 100644 --- a/test/chunking-form/samples/combined-namespace-reexport/_expected/system/main1.js +++ b/test/chunking-form/samples/combined-namespace-reexport/_expected/system/main1.js @@ -1,21 +1,21 @@ -System.register(['./generated-geometry.js'], function () { +System.register(['./generated-geometry.js'], (function () { 'use strict'; - var volume, geometry; + var geometry, volume; return { setters: [function (module) { - volume = module.v; geometry = module.g; + volume = module.v; }], - execute: function () { + execute: (function () { var mod = /*#__PURE__*/Object.freeze({ __proto__: null, - volume: volume, - geometry: geometry + geometry: geometry, + volume: volume }); console.log(mod); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/combined-namespace-reexport/_expected/system/main2.js b/test/chunking-form/samples/combined-namespace-reexport/_expected/system/main2.js index 43bed67a0f7..15f9cf788f6 100644 --- a/test/chunking-form/samples/combined-namespace-reexport/_expected/system/main2.js +++ b/test/chunking-form/samples/combined-namespace-reexport/_expected/system/main2.js @@ -1,4 +1,4 @@ -System.register(['./generated-geometry.js'], function () { +System.register(['./generated-geometry.js'], (function () { 'use strict'; var foo, bar; return { @@ -6,10 +6,10 @@ System.register(['./generated-geometry.js'], function () { foo = module.f; bar = module.b; }], - execute: function () { + execute: (function () { console.log(foo, bar); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/custom-sanitizer/_config.js b/test/chunking-form/samples/custom-sanitizer/_config.js new file mode 100644 index 00000000000..c556c19f323 --- /dev/null +++ b/test/chunking-form/samples/custom-sanitizer/_config.js @@ -0,0 +1,19 @@ +module.exports = defineTest({ + description: 'supports custom file name sanitizer functions', + options: { + plugins: [ + { + name: 'test-plugin', + buildStart() { + this.emitFile({ type: 'asset', name: 'asset.txt', source: 'asset' }); + } + } + ], + output: { + assetFileNames: '[name][extname]', + sanitizeFileName(id) { + return id.replace(/a/g, '_'); + } + } + } +}); diff --git a/test/chunking-form/samples/custom-sanitizer/_expected/amd/_sset.txt b/test/chunking-form/samples/custom-sanitizer/_expected/amd/_sset.txt new file mode 100644 index 00000000000..a95e94f6604 --- /dev/null +++ b/test/chunking-form/samples/custom-sanitizer/_expected/amd/_sset.txt @@ -0,0 +1 @@ +asset \ No newline at end of file diff --git a/test/chunking-form/samples/custom-sanitizer/_expected/amd/m_in.js b/test/chunking-form/samples/custom-sanitizer/_expected/amd/m_in.js new file mode 100644 index 00000000000..7e204c06c9d --- /dev/null +++ b/test/chunking-form/samples/custom-sanitizer/_expected/amd/m_in.js @@ -0,0 +1,5 @@ +define((function () { 'use strict'; + + console.log('ok'); + +})); diff --git a/test/chunking-form/samples/custom-sanitizer/_expected/cjs/_sset.txt b/test/chunking-form/samples/custom-sanitizer/_expected/cjs/_sset.txt new file mode 100644 index 00000000000..a95e94f6604 --- /dev/null +++ b/test/chunking-form/samples/custom-sanitizer/_expected/cjs/_sset.txt @@ -0,0 +1 @@ +asset \ No newline at end of file diff --git a/test/chunking-form/samples/custom-sanitizer/_expected/cjs/m_in.js b/test/chunking-form/samples/custom-sanitizer/_expected/cjs/m_in.js new file mode 100644 index 00000000000..faea9b6d894 --- /dev/null +++ b/test/chunking-form/samples/custom-sanitizer/_expected/cjs/m_in.js @@ -0,0 +1,3 @@ +'use strict'; + +console.log('ok'); diff --git a/test/chunking-form/samples/custom-sanitizer/_expected/es/_sset.txt b/test/chunking-form/samples/custom-sanitizer/_expected/es/_sset.txt new file mode 100644 index 00000000000..a95e94f6604 --- /dev/null +++ b/test/chunking-form/samples/custom-sanitizer/_expected/es/_sset.txt @@ -0,0 +1 @@ +asset \ No newline at end of file diff --git a/test/chunking-form/samples/custom-sanitizer/_expected/es/m_in.js b/test/chunking-form/samples/custom-sanitizer/_expected/es/m_in.js new file mode 100644 index 00000000000..37108886b56 --- /dev/null +++ b/test/chunking-form/samples/custom-sanitizer/_expected/es/m_in.js @@ -0,0 +1 @@ +console.log('ok'); diff --git a/test/chunking-form/samples/custom-sanitizer/_expected/system/_sset.txt b/test/chunking-form/samples/custom-sanitizer/_expected/system/_sset.txt new file mode 100644 index 00000000000..a95e94f6604 --- /dev/null +++ b/test/chunking-form/samples/custom-sanitizer/_expected/system/_sset.txt @@ -0,0 +1 @@ +asset \ No newline at end of file diff --git a/test/chunking-form/samples/custom-sanitizer/_expected/system/m_in.js b/test/chunking-form/samples/custom-sanitizer/_expected/system/m_in.js new file mode 100644 index 00000000000..6138292b599 --- /dev/null +++ b/test/chunking-form/samples/custom-sanitizer/_expected/system/m_in.js @@ -0,0 +1,10 @@ +System.register([], (function () { + 'use strict'; + return { + execute: (function () { + + console.log('ok'); + + }) + }; +})); diff --git a/test/chunking-form/samples/custom-sanitizer/main.js b/test/chunking-form/samples/custom-sanitizer/main.js new file mode 100644 index 00000000000..bb06158e22d --- /dev/null +++ b/test/chunking-form/samples/custom-sanitizer/main.js @@ -0,0 +1,2 @@ +console.log('ok'); + diff --git a/test/chunking-form/samples/deconflict-globals/_config.js b/test/chunking-form/samples/deconflict-globals/_config.js index 9ffbdeef487..cb6c7c55b09 100644 --- a/test/chunking-form/samples/deconflict-globals/_config.js +++ b/test/chunking-form/samples/deconflict-globals/_config.js @@ -1,6 +1,6 @@ -module.exports = { +module.exports = defineTest({ description: 'does not deconflict due to global variables used in other chunks', options: { input: ['main1.js', 'main2.js'] } -}; +}); diff --git a/test/chunking-form/samples/deconflict-globals/_expected/amd/generated-dep.js b/test/chunking-form/samples/deconflict-globals/_expected/amd/generated-dep.js index 86200d0b228..81013c2e722 100644 --- a/test/chunking-form/samples/deconflict-globals/_expected/amd/generated-dep.js +++ b/test/chunking-form/samples/deconflict-globals/_expected/amd/generated-dep.js @@ -1,7 +1,7 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; const x = 42; exports.x = x; -}); +})); diff --git a/test/chunking-form/samples/deconflict-globals/_expected/amd/main1.js b/test/chunking-form/samples/deconflict-globals/_expected/amd/main1.js index ac552c3f721..3998240711c 100644 --- a/test/chunking-form/samples/deconflict-globals/_expected/amd/main1.js +++ b/test/chunking-form/samples/deconflict-globals/_expected/amd/main1.js @@ -1,5 +1,5 @@ -define(['./generated-dep'], function (dep) { 'use strict'; +define(['./generated-dep'], (function (dep) { 'use strict'; console.log(dep.x); -}); +})); diff --git a/test/chunking-form/samples/deconflict-globals/_expected/amd/main2.js b/test/chunking-form/samples/deconflict-globals/_expected/amd/main2.js index d7edef3bc09..0d2f44ab20f 100644 --- a/test/chunking-form/samples/deconflict-globals/_expected/amd/main2.js +++ b/test/chunking-form/samples/deconflict-globals/_expected/amd/main2.js @@ -1,5 +1,5 @@ -define(['./generated-dep'], function (dep) { 'use strict'; +define(['./generated-dep'], (function (dep) { 'use strict'; console.log(x, dep.x); -}); +})); diff --git a/test/chunking-form/samples/deconflict-globals/_expected/system/generated-dep.js b/test/chunking-form/samples/deconflict-globals/_expected/system/generated-dep.js index 51eb3ae7f88..7d67e9780f8 100644 --- a/test/chunking-form/samples/deconflict-globals/_expected/system/generated-dep.js +++ b/test/chunking-form/samples/deconflict-globals/_expected/system/generated-dep.js @@ -1,10 +1,10 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - const x = exports('x', 42); + const x = exports("x", 42); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/deconflict-globals/_expected/system/main1.js b/test/chunking-form/samples/deconflict-globals/_expected/system/main1.js index d1b8162d68e..6e9db33ac7a 100644 --- a/test/chunking-form/samples/deconflict-globals/_expected/system/main1.js +++ b/test/chunking-form/samples/deconflict-globals/_expected/system/main1.js @@ -1,14 +1,14 @@ -System.register(['./generated-dep.js'], function () { +System.register(['./generated-dep.js'], (function () { 'use strict'; var x; return { setters: [function (module) { x = module.x; }], - execute: function () { + execute: (function () { console.log(x); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/deconflict-globals/_expected/system/main2.js b/test/chunking-form/samples/deconflict-globals/_expected/system/main2.js index 66912a652cf..280d07abb4c 100644 --- a/test/chunking-form/samples/deconflict-globals/_expected/system/main2.js +++ b/test/chunking-form/samples/deconflict-globals/_expected/system/main2.js @@ -1,14 +1,14 @@ -System.register(['./generated-dep.js'], function () { +System.register(['./generated-dep.js'], (function () { 'use strict'; var x$1; return { setters: [function (module) { x$1 = module.x; }], - execute: function () { + execute: (function () { console.log(x, x$1); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/deconflict-system-default-export-variable/_config.js b/test/chunking-form/samples/deconflict-system-default-export-variable/_config.js index f0300a3c472..2903a929386 100644 --- a/test/chunking-form/samples/deconflict-system-default-export-variable/_config.js +++ b/test/chunking-form/samples/deconflict-system-default-export-variable/_config.js @@ -1,7 +1,6 @@ -module.exports = { +module.exports = defineTest({ description: 'deconflicts SystemJS default export variable with namespace imports', options: { - external: 'external', output: { preserveModules: true } } -}; +}); diff --git a/test/chunking-form/samples/deconflict-system-default-export-variable/_expected/amd/main.js b/test/chunking-form/samples/deconflict-system-default-export-variable/_expected/amd/main.js index b32a1761b50..5fcd6df652b 100644 --- a/test/chunking-form/samples/deconflict-system-default-export-variable/_expected/amd/main.js +++ b/test/chunking-form/samples/deconflict-system-default-export-variable/_expected/amd/main.js @@ -1,7 +1,7 @@ -define(['./other'], function (other) { 'use strict'; +define(['./other'], (function (other) { 'use strict'; - var main = other + "extended"; + var main = () => other; return main; -}); +})); diff --git a/test/chunking-form/samples/deconflict-system-default-export-variable/_expected/amd/other.js b/test/chunking-form/samples/deconflict-system-default-export-variable/_expected/amd/other.js index a32f525eb6d..414ddb1a550 100644 --- a/test/chunking-form/samples/deconflict-system-default-export-variable/_expected/amd/other.js +++ b/test/chunking-form/samples/deconflict-system-default-export-variable/_expected/amd/other.js @@ -1,9 +1,7 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; - const foo = 'bar'; + const main = 'bar'; - exports.foo = foo; + exports.main = main; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/deconflict-system-default-export-variable/_expected/cjs/main.js b/test/chunking-form/samples/deconflict-system-default-export-variable/_expected/cjs/main.js index 51fb736492a..4ec81065480 100644 --- a/test/chunking-form/samples/deconflict-system-default-export-variable/_expected/cjs/main.js +++ b/test/chunking-form/samples/deconflict-system-default-export-variable/_expected/cjs/main.js @@ -2,6 +2,6 @@ var other = require('./other.js'); -var main = other + "extended"; +var main = () => other; module.exports = main; diff --git a/test/chunking-form/samples/deconflict-system-default-export-variable/_expected/cjs/other.js b/test/chunking-form/samples/deconflict-system-default-export-variable/_expected/cjs/other.js index f2628893cb0..64f38c1ca61 100644 --- a/test/chunking-form/samples/deconflict-system-default-export-variable/_expected/cjs/other.js +++ b/test/chunking-form/samples/deconflict-system-default-export-variable/_expected/cjs/other.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); +const main = 'bar'; -const foo = 'bar'; - -exports.foo = foo; +exports.main = main; diff --git a/test/chunking-form/samples/deconflict-system-default-export-variable/_expected/es/main.js b/test/chunking-form/samples/deconflict-system-default-export-variable/_expected/es/main.js index bceb98a95d2..413f312ea83 100644 --- a/test/chunking-form/samples/deconflict-system-default-export-variable/_expected/es/main.js +++ b/test/chunking-form/samples/deconflict-system-default-export-variable/_expected/es/main.js @@ -1,5 +1,5 @@ import * as other from './other.js'; -var main = other + "extended"; +var main = () => other; -export default main; +export { main as default }; diff --git a/test/chunking-form/samples/deconflict-system-default-export-variable/_expected/es/other.js b/test/chunking-form/samples/deconflict-system-default-export-variable/_expected/es/other.js index 978472167c0..2eb04323557 100644 --- a/test/chunking-form/samples/deconflict-system-default-export-variable/_expected/es/other.js +++ b/test/chunking-form/samples/deconflict-system-default-export-variable/_expected/es/other.js @@ -1,3 +1,3 @@ -const foo = 'bar'; +const main = 'bar'; -export { foo }; +export { main }; diff --git a/test/chunking-form/samples/deconflict-system-default-export-variable/_expected/system/main.js b/test/chunking-form/samples/deconflict-system-default-export-variable/_expected/system/main.js index b5317f1c0a6..20a37a5db57 100644 --- a/test/chunking-form/samples/deconflict-system-default-export-variable/_expected/system/main.js +++ b/test/chunking-form/samples/deconflict-system-default-export-variable/_expected/system/main.js @@ -1,14 +1,14 @@ -System.register(['./other.js'], function (exports) { +System.register(['./other.js'], (function (exports) { 'use strict'; var other; return { setters: [function (module) { other = module; }], - execute: function () { + execute: (function () { - var main = exports('default', other + "extended"); + var main = exports("default", () => other); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/deconflict-system-default-export-variable/_expected/system/other.js b/test/chunking-form/samples/deconflict-system-default-export-variable/_expected/system/other.js index bd30d4938ef..a7386499745 100644 --- a/test/chunking-form/samples/deconflict-system-default-export-variable/_expected/system/other.js +++ b/test/chunking-form/samples/deconflict-system-default-export-variable/_expected/system/other.js @@ -1,10 +1,10 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - const foo = exports('foo', 'bar'); + const main = exports("main", 'bar'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/deconflict-system-default-export-variable/main.js b/test/chunking-form/samples/deconflict-system-default-export-variable/main.js index b47741c0828..26df3f8f791 100644 --- a/test/chunking-form/samples/deconflict-system-default-export-variable/main.js +++ b/test/chunking-form/samples/deconflict-system-default-export-variable/main.js @@ -1,3 +1,3 @@ import * as main from './other.js'; -export default main + "extended"; \ No newline at end of file +export default () => main; diff --git a/test/chunking-form/samples/deconflict-system-default-export-variable/other.js b/test/chunking-form/samples/deconflict-system-default-export-variable/other.js index 7212fb6787a..546a6495e5d 100644 --- a/test/chunking-form/samples/deconflict-system-default-export-variable/other.js +++ b/test/chunking-form/samples/deconflict-system-default-export-variable/other.js @@ -1 +1 @@ -export const foo = 'bar' \ No newline at end of file +export const main = 'bar' diff --git a/test/chunking-form/samples/deduplicate-imports-referencing-originals-2/_config.js b/test/chunking-form/samples/deduplicate-imports-referencing-originals-2/_config.js index a393eccd704..f938b8172b2 100644 --- a/test/chunking-form/samples/deduplicate-imports-referencing-originals-2/_config.js +++ b/test/chunking-form/samples/deduplicate-imports-referencing-originals-2/_config.js @@ -1,7 +1,7 @@ -module.exports = { +module.exports = defineTest({ description: 'do not import variables that reference an original if another variable referencing it is already imported', options: { input: ['main1', 'main2'] } -}; +}); diff --git a/test/chunking-form/samples/deduplicate-imports-referencing-originals-2/_expected/amd/generated-foo.js b/test/chunking-form/samples/deduplicate-imports-referencing-originals-2/_expected/amd/generated-foo.js index d3a2d0d4a15..aeb235dc318 100644 --- a/test/chunking-form/samples/deduplicate-imports-referencing-originals-2/_expected/amd/generated-foo.js +++ b/test/chunking-form/samples/deduplicate-imports-referencing-originals-2/_expected/amd/generated-foo.js @@ -1,7 +1,7 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; const foo = {}; exports.foo = foo; -}); +})); diff --git a/test/chunking-form/samples/deduplicate-imports-referencing-originals-2/_expected/amd/main1.js b/test/chunking-form/samples/deduplicate-imports-referencing-originals-2/_expected/amd/main1.js index b61c591021b..f5ab0bc8435 100644 --- a/test/chunking-form/samples/deduplicate-imports-referencing-originals-2/_expected/amd/main1.js +++ b/test/chunking-form/samples/deduplicate-imports-referencing-originals-2/_expected/amd/main1.js @@ -1,5 +1,5 @@ -define(['./generated-foo'], function (foo) { 'use strict'; +define(['./generated-foo'], (function (foo) { 'use strict'; console.log(foo.foo, foo.foo); -}); +})); diff --git a/test/chunking-form/samples/deduplicate-imports-referencing-originals-2/_expected/amd/main2.js b/test/chunking-form/samples/deduplicate-imports-referencing-originals-2/_expected/amd/main2.js index b61c591021b..f5ab0bc8435 100644 --- a/test/chunking-form/samples/deduplicate-imports-referencing-originals-2/_expected/amd/main2.js +++ b/test/chunking-form/samples/deduplicate-imports-referencing-originals-2/_expected/amd/main2.js @@ -1,5 +1,5 @@ -define(['./generated-foo'], function (foo) { 'use strict'; +define(['./generated-foo'], (function (foo) { 'use strict'; console.log(foo.foo, foo.foo); -}); +})); diff --git a/test/chunking-form/samples/deduplicate-imports-referencing-originals-2/_expected/system/generated-foo.js b/test/chunking-form/samples/deduplicate-imports-referencing-originals-2/_expected/system/generated-foo.js index d8d23d2e461..ddfbf2750bd 100644 --- a/test/chunking-form/samples/deduplicate-imports-referencing-originals-2/_expected/system/generated-foo.js +++ b/test/chunking-form/samples/deduplicate-imports-referencing-originals-2/_expected/system/generated-foo.js @@ -1,10 +1,10 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - const foo = exports('f', {}); + const foo = exports("f", {}); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/deduplicate-imports-referencing-originals-2/_expected/system/main1.js b/test/chunking-form/samples/deduplicate-imports-referencing-originals-2/_expected/system/main1.js index 8f6b0263c35..3868a331e1d 100644 --- a/test/chunking-form/samples/deduplicate-imports-referencing-originals-2/_expected/system/main1.js +++ b/test/chunking-form/samples/deduplicate-imports-referencing-originals-2/_expected/system/main1.js @@ -1,14 +1,14 @@ -System.register(['./generated-foo.js'], function () { +System.register(['./generated-foo.js'], (function () { 'use strict'; var foo; return { setters: [function (module) { foo = module.f; }], - execute: function () { + execute: (function () { console.log(foo, foo); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/deduplicate-imports-referencing-originals-2/_expected/system/main2.js b/test/chunking-form/samples/deduplicate-imports-referencing-originals-2/_expected/system/main2.js index 8f6b0263c35..3868a331e1d 100644 --- a/test/chunking-form/samples/deduplicate-imports-referencing-originals-2/_expected/system/main2.js +++ b/test/chunking-form/samples/deduplicate-imports-referencing-originals-2/_expected/system/main2.js @@ -1,14 +1,14 @@ -System.register(['./generated-foo.js'], function () { +System.register(['./generated-foo.js'], (function () { 'use strict'; var foo; return { setters: [function (module) { foo = module.f; }], - execute: function () { + execute: (function () { console.log(foo, foo); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/deduplicate-imports-referencing-originals/_config.js b/test/chunking-form/samples/deduplicate-imports-referencing-originals/_config.js index 8bf09102383..7053b779517 100644 --- a/test/chunking-form/samples/deduplicate-imports-referencing-originals/_config.js +++ b/test/chunking-form/samples/deduplicate-imports-referencing-originals/_config.js @@ -1,7 +1,7 @@ -module.exports = { +module.exports = defineTest({ description: 'do not import variables that reference an original if the original is already imported', options: { input: ['main1', 'main2'] } -}; +}); diff --git a/test/chunking-form/samples/deduplicate-imports-referencing-originals/_expected/amd/generated-foo.js b/test/chunking-form/samples/deduplicate-imports-referencing-originals/_expected/amd/generated-foo.js index d3a2d0d4a15..aeb235dc318 100644 --- a/test/chunking-form/samples/deduplicate-imports-referencing-originals/_expected/amd/generated-foo.js +++ b/test/chunking-form/samples/deduplicate-imports-referencing-originals/_expected/amd/generated-foo.js @@ -1,7 +1,7 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; const foo = {}; exports.foo = foo; -}); +})); diff --git a/test/chunking-form/samples/deduplicate-imports-referencing-originals/_expected/amd/main1.js b/test/chunking-form/samples/deduplicate-imports-referencing-originals/_expected/amd/main1.js index b61c591021b..f5ab0bc8435 100644 --- a/test/chunking-form/samples/deduplicate-imports-referencing-originals/_expected/amd/main1.js +++ b/test/chunking-form/samples/deduplicate-imports-referencing-originals/_expected/amd/main1.js @@ -1,5 +1,5 @@ -define(['./generated-foo'], function (foo) { 'use strict'; +define(['./generated-foo'], (function (foo) { 'use strict'; console.log(foo.foo, foo.foo); -}); +})); diff --git a/test/chunking-form/samples/deduplicate-imports-referencing-originals/_expected/amd/main2.js b/test/chunking-form/samples/deduplicate-imports-referencing-originals/_expected/amd/main2.js index b61c591021b..f5ab0bc8435 100644 --- a/test/chunking-form/samples/deduplicate-imports-referencing-originals/_expected/amd/main2.js +++ b/test/chunking-form/samples/deduplicate-imports-referencing-originals/_expected/amd/main2.js @@ -1,5 +1,5 @@ -define(['./generated-foo'], function (foo) { 'use strict'; +define(['./generated-foo'], (function (foo) { 'use strict'; console.log(foo.foo, foo.foo); -}); +})); diff --git a/test/chunking-form/samples/deduplicate-imports-referencing-originals/_expected/system/generated-foo.js b/test/chunking-form/samples/deduplicate-imports-referencing-originals/_expected/system/generated-foo.js index d8d23d2e461..ddfbf2750bd 100644 --- a/test/chunking-form/samples/deduplicate-imports-referencing-originals/_expected/system/generated-foo.js +++ b/test/chunking-form/samples/deduplicate-imports-referencing-originals/_expected/system/generated-foo.js @@ -1,10 +1,10 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - const foo = exports('f', {}); + const foo = exports("f", {}); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/deduplicate-imports-referencing-originals/_expected/system/main1.js b/test/chunking-form/samples/deduplicate-imports-referencing-originals/_expected/system/main1.js index 8f6b0263c35..3868a331e1d 100644 --- a/test/chunking-form/samples/deduplicate-imports-referencing-originals/_expected/system/main1.js +++ b/test/chunking-form/samples/deduplicate-imports-referencing-originals/_expected/system/main1.js @@ -1,14 +1,14 @@ -System.register(['./generated-foo.js'], function () { +System.register(['./generated-foo.js'], (function () { 'use strict'; var foo; return { setters: [function (module) { foo = module.f; }], - execute: function () { + execute: (function () { console.log(foo, foo); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/deduplicate-imports-referencing-originals/_expected/system/main2.js b/test/chunking-form/samples/deduplicate-imports-referencing-originals/_expected/system/main2.js index 8f6b0263c35..3868a331e1d 100644 --- a/test/chunking-form/samples/deduplicate-imports-referencing-originals/_expected/system/main2.js +++ b/test/chunking-form/samples/deduplicate-imports-referencing-originals/_expected/system/main2.js @@ -1,14 +1,14 @@ -System.register(['./generated-foo.js'], function () { +System.register(['./generated-foo.js'], (function () { 'use strict'; var foo; return { setters: [function (module) { foo = module.f; }], - execute: function () { + execute: (function () { console.log(foo, foo); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/default-export-name-conflict/_config.js b/test/chunking-form/samples/default-export-name-conflict/_config.js index 958b2db90bb..ff47dc7beb5 100644 --- a/test/chunking-form/samples/default-export-name-conflict/_config.js +++ b/test/chunking-form/samples/default-export-name-conflict/_config.js @@ -1,6 +1,6 @@ -module.exports = { +module.exports = defineTest({ description: 'does not produce name conflicts when reexporting via default exports', options: { input: ['main1', 'main2'] } -}; +}); diff --git a/test/chunking-form/samples/default-export-name-conflict/_expected/amd/generated-module1.js b/test/chunking-form/samples/default-export-name-conflict/_expected/amd/generated-module1.js index 99e5242e82f..6cfa5eb31e1 100644 --- a/test/chunking-form/samples/default-export-name-conflict/_expected/amd/generated-module1.js +++ b/test/chunking-form/samples/default-export-name-conflict/_expected/amd/generated-module1.js @@ -1,7 +1,7 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; const firebase = {}; exports.firebase = firebase; -}); +})); diff --git a/test/chunking-form/samples/default-export-name-conflict/_expected/amd/main1.js b/test/chunking-form/samples/default-export-name-conflict/_expected/amd/main1.js index b1525c2e830..c338555e78e 100644 --- a/test/chunking-form/samples/default-export-name-conflict/_expected/amd/main1.js +++ b/test/chunking-form/samples/default-export-name-conflict/_expected/amd/main1.js @@ -1,5 +1,5 @@ -define(['./generated-module1'], function (module1) { 'use strict'; +define(['./generated-module1'], (function (module1) { 'use strict'; console.log(module1.firebase, module1.firebase); -}); +})); diff --git a/test/chunking-form/samples/default-export-name-conflict/_expected/amd/main2.js b/test/chunking-form/samples/default-export-name-conflict/_expected/amd/main2.js index b1525c2e830..c338555e78e 100644 --- a/test/chunking-form/samples/default-export-name-conflict/_expected/amd/main2.js +++ b/test/chunking-form/samples/default-export-name-conflict/_expected/amd/main2.js @@ -1,5 +1,5 @@ -define(['./generated-module1'], function (module1) { 'use strict'; +define(['./generated-module1'], (function (module1) { 'use strict'; console.log(module1.firebase, module1.firebase); -}); +})); diff --git a/test/chunking-form/samples/default-export-name-conflict/_expected/system/generated-module1.js b/test/chunking-form/samples/default-export-name-conflict/_expected/system/generated-module1.js index 444b218efb0..a468b3956ee 100644 --- a/test/chunking-form/samples/default-export-name-conflict/_expected/system/generated-module1.js +++ b/test/chunking-form/samples/default-export-name-conflict/_expected/system/generated-module1.js @@ -1,10 +1,10 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - const firebase = exports('f', {}); + const firebase = exports("f", {}); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/default-export-name-conflict/_expected/system/main1.js b/test/chunking-form/samples/default-export-name-conflict/_expected/system/main1.js index abf296ea001..a649760a11a 100644 --- a/test/chunking-form/samples/default-export-name-conflict/_expected/system/main1.js +++ b/test/chunking-form/samples/default-export-name-conflict/_expected/system/main1.js @@ -1,14 +1,14 @@ -System.register(['./generated-module1.js'], function () { +System.register(['./generated-module1.js'], (function () { 'use strict'; var firebase; return { setters: [function (module) { firebase = module.f; }], - execute: function () { + execute: (function () { console.log(firebase, firebase); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/default-export-name-conflict/_expected/system/main2.js b/test/chunking-form/samples/default-export-name-conflict/_expected/system/main2.js index abf296ea001..a649760a11a 100644 --- a/test/chunking-form/samples/default-export-name-conflict/_expected/system/main2.js +++ b/test/chunking-form/samples/default-export-name-conflict/_expected/system/main2.js @@ -1,14 +1,14 @@ -System.register(['./generated-module1.js'], function () { +System.register(['./generated-module1.js'], (function () { 'use strict'; var firebase; return { setters: [function (module) { firebase = module.f; }], - execute: function () { + execute: (function () { console.log(firebase, firebase); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/default-identifier-renaming/_config.js b/test/chunking-form/samples/default-identifier-renaming/_config.js index d6e0502667f..56449217213 100644 --- a/test/chunking-form/samples/default-identifier-renaming/_config.js +++ b/test/chunking-form/samples/default-identifier-renaming/_config.js @@ -1,6 +1,6 @@ -module.exports = { +module.exports = defineTest({ description: 'Default export identifier name handling', options: { input: ['main1.js', 'main2.js'] } -}; +}); diff --git a/test/chunking-form/samples/default-identifier-renaming/_expected/amd/generated-shared.js b/test/chunking-form/samples/default-identifier-renaming/_expected/amd/generated-shared.js index 74e45d79f9b..d91f39a8f8b 100644 --- a/test/chunking-form/samples/default-identifier-renaming/_expected/amd/generated-shared.js +++ b/test/chunking-form/samples/default-identifier-renaming/_expected/amd/generated-shared.js @@ -1,7 +1,7 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; const data = [1, 2, 3]; exports.data = data; -}); +})); diff --git a/test/chunking-form/samples/default-identifier-renaming/_expected/amd/main1.js b/test/chunking-form/samples/default-identifier-renaming/_expected/amd/main1.js index 7091cf839ed..1535598fa7a 100644 --- a/test/chunking-form/samples/default-identifier-renaming/_expected/amd/main1.js +++ b/test/chunking-form/samples/default-identifier-renaming/_expected/amd/main1.js @@ -1,7 +1,7 @@ -define(['./generated-shared'], function (shared) { 'use strict'; +define(['./generated-shared'], (function (shared) { 'use strict'; var main1 = shared.data.map(d => d + 1); return main1; -}); +})); diff --git a/test/chunking-form/samples/default-identifier-renaming/_expected/amd/main2.js b/test/chunking-form/samples/default-identifier-renaming/_expected/amd/main2.js index e9e8324c95f..31dec8f35e6 100644 --- a/test/chunking-form/samples/default-identifier-renaming/_expected/amd/main2.js +++ b/test/chunking-form/samples/default-identifier-renaming/_expected/amd/main2.js @@ -1,7 +1,7 @@ -define(['./generated-shared'], function (shared) { 'use strict'; +define(['./generated-shared'], (function (shared) { 'use strict'; var main2 = shared.data.map(d => d + 2); return main2; -}); +})); diff --git a/test/chunking-form/samples/default-identifier-renaming/_expected/es/main1.js b/test/chunking-form/samples/default-identifier-renaming/_expected/es/main1.js index 55f323e9053..6336b9e0b47 100644 --- a/test/chunking-form/samples/default-identifier-renaming/_expected/es/main1.js +++ b/test/chunking-form/samples/default-identifier-renaming/_expected/es/main1.js @@ -2,4 +2,4 @@ import { d as data } from './generated-shared.js'; var main1 = data.map(d => d + 1); -export default main1; +export { main1 as default }; diff --git a/test/chunking-form/samples/default-identifier-renaming/_expected/es/main2.js b/test/chunking-form/samples/default-identifier-renaming/_expected/es/main2.js index 422b5bdc434..e008f3b390b 100644 --- a/test/chunking-form/samples/default-identifier-renaming/_expected/es/main2.js +++ b/test/chunking-form/samples/default-identifier-renaming/_expected/es/main2.js @@ -2,4 +2,4 @@ import { d as data } from './generated-shared.js'; var main2 = data.map(d => d + 2); -export default main2; +export { main2 as default }; diff --git a/test/chunking-form/samples/default-identifier-renaming/_expected/system/generated-shared.js b/test/chunking-form/samples/default-identifier-renaming/_expected/system/generated-shared.js index e28588b540b..f6cf80c57ad 100644 --- a/test/chunking-form/samples/default-identifier-renaming/_expected/system/generated-shared.js +++ b/test/chunking-form/samples/default-identifier-renaming/_expected/system/generated-shared.js @@ -1,10 +1,10 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - const data = exports('d', [1, 2, 3]); + const data = exports("d", [1, 2, 3]); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/default-identifier-renaming/_expected/system/main1.js b/test/chunking-form/samples/default-identifier-renaming/_expected/system/main1.js index 97e63bc06fb..a48dc6f82ba 100644 --- a/test/chunking-form/samples/default-identifier-renaming/_expected/system/main1.js +++ b/test/chunking-form/samples/default-identifier-renaming/_expected/system/main1.js @@ -1,14 +1,14 @@ -System.register(['./generated-shared.js'], function (exports) { +System.register(['./generated-shared.js'], (function (exports) { 'use strict'; var data; return { setters: [function (module) { data = module.d; }], - execute: function () { + execute: (function () { - var main1 = exports('default', data.map(d => d + 1)); + var main1 = exports("default", data.map(d => d + 1)); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/default-identifier-renaming/_expected/system/main2.js b/test/chunking-form/samples/default-identifier-renaming/_expected/system/main2.js index 5e810db15ef..e7c01fb78bf 100644 --- a/test/chunking-form/samples/default-identifier-renaming/_expected/system/main2.js +++ b/test/chunking-form/samples/default-identifier-renaming/_expected/system/main2.js @@ -1,14 +1,14 @@ -System.register(['./generated-shared.js'], function (exports) { +System.register(['./generated-shared.js'], (function (exports) { 'use strict'; var data; return { setters: [function (module) { data = module.d; }], - execute: function () { + execute: (function () { - var main2 = exports('default', data.map(d => d + 2)); + var main2 = exports("default", data.map(d => d + 2)); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/default-reexport-namespace/_config.js b/test/chunking-form/samples/default-reexport-namespace/_config.js index 20ee29986bd..18616527b0c 100644 --- a/test/chunking-form/samples/default-reexport-namespace/_config.js +++ b/test/chunking-form/samples/default-reexport-namespace/_config.js @@ -1,6 +1,6 @@ -module.exports = { +module.exports = defineTest({ description: 'Properly handle adding a default reexport to a namespace (#3583)', options: { input: ['main.js', 'icons/one.js'] } -}; +}); diff --git a/test/chunking-form/samples/default-reexport-namespace/_expected/amd/main.js b/test/chunking-form/samples/default-reexport-namespace/_expected/amd/main.js index c28f6995097..57c5ace9748 100644 --- a/test/chunking-form/samples/default-reexport-namespace/_expected/amd/main.js +++ b/test/chunking-form/samples/default-reexport-namespace/_expected/amd/main.js @@ -1,4 +1,4 @@ -define(['exports', './one'], function (exports, one) { 'use strict'; +define(['exports', './one'], (function (exports, one) { 'use strict'; const __icon__ = {}; @@ -12,6 +12,4 @@ define(['exports', './one'], function (exports, one) { 'use strict'; exports.Component_one = __component__; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/default-reexport-namespace/_expected/amd/one.js b/test/chunking-form/samples/default-reexport-namespace/_expected/amd/one.js index 19ec22efce4..69cfdde2bd8 100644 --- a/test/chunking-form/samples/default-reexport-namespace/_expected/amd/one.js +++ b/test/chunking-form/samples/default-reexport-namespace/_expected/amd/one.js @@ -1,7 +1,7 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; const __icon__ = {}; return __icon__; -}); +})); diff --git a/test/chunking-form/samples/default-reexport-namespace/_expected/cjs/main.js b/test/chunking-form/samples/default-reexport-namespace/_expected/cjs/main.js index 9333ccc880a..2da32d95433 100644 --- a/test/chunking-form/samples/default-reexport-namespace/_expected/cjs/main.js +++ b/test/chunking-form/samples/default-reexport-namespace/_expected/cjs/main.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - var one = require('./one.js'); const __icon__ = {}; diff --git a/test/chunking-form/samples/default-reexport-namespace/_expected/es/one.js b/test/chunking-form/samples/default-reexport-namespace/_expected/es/one.js index db8b271506d..e710d5327c1 100644 --- a/test/chunking-form/samples/default-reexport-namespace/_expected/es/one.js +++ b/test/chunking-form/samples/default-reexport-namespace/_expected/es/one.js @@ -1,3 +1,3 @@ const __icon__ = {}; -export default __icon__; +export { __icon__ as default }; diff --git a/test/chunking-form/samples/default-reexport-namespace/_expected/system/main.js b/test/chunking-form/samples/default-reexport-namespace/_expected/system/main.js index f8bec502907..404a5b2cfad 100644 --- a/test/chunking-form/samples/default-reexport-namespace/_expected/system/main.js +++ b/test/chunking-form/samples/default-reexport-namespace/_expected/system/main.js @@ -1,11 +1,11 @@ -System.register(['./one.js'], function (exports) { +System.register(['./one.js'], (function (exports) { 'use strict'; var __icon__$1; return { setters: [function (module) { __icon__$1 = module.default; }], - execute: function () { + execute: (function () { const __icon__ = {}; @@ -15,8 +15,8 @@ System.register(['./one.js'], function (exports) { two: __icon__ }); - const __component__ = exports('Component_one', { icons }); + const __component__ = exports("Component_one", { icons }); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/default-reexport-namespace/_expected/system/one.js b/test/chunking-form/samples/default-reexport-namespace/_expected/system/one.js index 1db761192aa..4cec8dd59d0 100644 --- a/test/chunking-form/samples/default-reexport-namespace/_expected/system/one.js +++ b/test/chunking-form/samples/default-reexport-namespace/_expected/system/one.js @@ -1,10 +1,10 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - const __icon__ = exports('default', {}); + const __icon__ = exports("default", {}); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/deprecated/avoid-imports-preserve-modules/_config.js b/test/chunking-form/samples/deprecated/avoid-imports-preserve-modules/_config.js deleted file mode 100644 index f1ceddc826f..00000000000 --- a/test/chunking-form/samples/deprecated/avoid-imports-preserve-modules/_config.js +++ /dev/null @@ -1,8 +0,0 @@ -module.exports = { - description: - 'avoids empty imports if they do not have side-effects when preserving modules (#3359)', - options: { - strictDeprecations: false, - preserveModules: true - } -}; diff --git a/test/chunking-form/samples/deprecated/avoid-imports-preserve-modules/_expected/amd/a.js b/test/chunking-form/samples/deprecated/avoid-imports-preserve-modules/_expected/amd/a.js deleted file mode 100644 index a0ee4d5c962..00000000000 --- a/test/chunking-form/samples/deprecated/avoid-imports-preserve-modules/_expected/amd/a.js +++ /dev/null @@ -1,9 +0,0 @@ -define(['exports'], function (exports) { 'use strict'; - - const a = 1; - - exports.a = a; - - Object.defineProperty(exports, '__esModule', { value: true }); - -}); diff --git a/test/chunking-form/samples/deprecated/avoid-imports-preserve-modules/_expected/amd/b.js b/test/chunking-form/samples/deprecated/avoid-imports-preserve-modules/_expected/amd/b.js deleted file mode 100644 index 71d3b650e8d..00000000000 --- a/test/chunking-form/samples/deprecated/avoid-imports-preserve-modules/_expected/amd/b.js +++ /dev/null @@ -1,9 +0,0 @@ -define(['exports'], function (exports) { 'use strict'; - - const b = 2; - - exports.b = b; - - Object.defineProperty(exports, '__esModule', { value: true }); - -}); diff --git a/test/chunking-form/samples/deprecated/avoid-imports-preserve-modules/_expected/amd/main.js b/test/chunking-form/samples/deprecated/avoid-imports-preserve-modules/_expected/amd/main.js deleted file mode 100644 index 854a7e8dca1..00000000000 --- a/test/chunking-form/samples/deprecated/avoid-imports-preserve-modules/_expected/amd/main.js +++ /dev/null @@ -1,5 +0,0 @@ -define(['./a', './one'], function (a, one) { 'use strict'; - - console.log(a.a + one.d); - -}); diff --git a/test/chunking-form/samples/deprecated/avoid-imports-preserve-modules/_expected/amd/one.js b/test/chunking-form/samples/deprecated/avoid-imports-preserve-modules/_expected/amd/one.js deleted file mode 100644 index 2d8ca9bd394..00000000000 --- a/test/chunking-form/samples/deprecated/avoid-imports-preserve-modules/_expected/amd/one.js +++ /dev/null @@ -1,9 +0,0 @@ -define(['exports', './b'], function (exports, b) { 'use strict'; - - const d = b.b + 4; - - exports.d = d; - - Object.defineProperty(exports, '__esModule', { value: true }); - -}); diff --git a/test/chunking-form/samples/deprecated/avoid-imports-preserve-modules/_expected/cjs/a.js b/test/chunking-form/samples/deprecated/avoid-imports-preserve-modules/_expected/cjs/a.js deleted file mode 100644 index 97007408241..00000000000 --- a/test/chunking-form/samples/deprecated/avoid-imports-preserve-modules/_expected/cjs/a.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { value: true }); - -const a = 1; - -exports.a = a; diff --git a/test/chunking-form/samples/deprecated/avoid-imports-preserve-modules/_expected/cjs/b.js b/test/chunking-form/samples/deprecated/avoid-imports-preserve-modules/_expected/cjs/b.js deleted file mode 100644 index 3c417e8458a..00000000000 --- a/test/chunking-form/samples/deprecated/avoid-imports-preserve-modules/_expected/cjs/b.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { value: true }); - -const b = 2; - -exports.b = b; diff --git a/test/chunking-form/samples/deprecated/avoid-imports-preserve-modules/_expected/cjs/main.js b/test/chunking-form/samples/deprecated/avoid-imports-preserve-modules/_expected/cjs/main.js deleted file mode 100644 index c691c0d47e9..00000000000 --- a/test/chunking-form/samples/deprecated/avoid-imports-preserve-modules/_expected/cjs/main.js +++ /dev/null @@ -1,6 +0,0 @@ -'use strict'; - -var a = require('./a.js'); -var one = require('./one.js'); - -console.log(a.a + one.d); diff --git a/test/chunking-form/samples/deprecated/avoid-imports-preserve-modules/_expected/cjs/one.js b/test/chunking-form/samples/deprecated/avoid-imports-preserve-modules/_expected/cjs/one.js deleted file mode 100644 index 9eea4c87a9f..00000000000 --- a/test/chunking-form/samples/deprecated/avoid-imports-preserve-modules/_expected/cjs/one.js +++ /dev/null @@ -1,9 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { value: true }); - -var b = require('./b.js'); - -const d = b.b + 4; - -exports.d = d; diff --git a/test/chunking-form/samples/deprecated/avoid-imports-preserve-modules/_expected/es/a.js b/test/chunking-form/samples/deprecated/avoid-imports-preserve-modules/_expected/es/a.js deleted file mode 100644 index 089815c5bdd..00000000000 --- a/test/chunking-form/samples/deprecated/avoid-imports-preserve-modules/_expected/es/a.js +++ /dev/null @@ -1,3 +0,0 @@ -const a = 1; - -export { a }; diff --git a/test/chunking-form/samples/deprecated/avoid-imports-preserve-modules/_expected/es/b.js b/test/chunking-form/samples/deprecated/avoid-imports-preserve-modules/_expected/es/b.js deleted file mode 100644 index 27b49eddabb..00000000000 --- a/test/chunking-form/samples/deprecated/avoid-imports-preserve-modules/_expected/es/b.js +++ /dev/null @@ -1,3 +0,0 @@ -const b = 2; - -export { b }; diff --git a/test/chunking-form/samples/deprecated/avoid-imports-preserve-modules/_expected/es/main.js b/test/chunking-form/samples/deprecated/avoid-imports-preserve-modules/_expected/es/main.js deleted file mode 100644 index 0b42cf037c6..00000000000 --- a/test/chunking-form/samples/deprecated/avoid-imports-preserve-modules/_expected/es/main.js +++ /dev/null @@ -1,4 +0,0 @@ -import { a } from './a.js'; -import { d } from './one.js'; - -console.log(a + d); diff --git a/test/chunking-form/samples/deprecated/avoid-imports-preserve-modules/_expected/es/one.js b/test/chunking-form/samples/deprecated/avoid-imports-preserve-modules/_expected/es/one.js deleted file mode 100644 index d9291f1bff3..00000000000 --- a/test/chunking-form/samples/deprecated/avoid-imports-preserve-modules/_expected/es/one.js +++ /dev/null @@ -1,5 +0,0 @@ -import { b } from './b.js'; - -const d = b + 4; - -export { d }; diff --git a/test/chunking-form/samples/deprecated/avoid-imports-preserve-modules/_expected/system/a.js b/test/chunking-form/samples/deprecated/avoid-imports-preserve-modules/_expected/system/a.js deleted file mode 100644 index 50f0d7760ca..00000000000 --- a/test/chunking-form/samples/deprecated/avoid-imports-preserve-modules/_expected/system/a.js +++ /dev/null @@ -1,10 +0,0 @@ -System.register([], function (exports) { - 'use strict'; - return { - execute: function () { - - const a = exports('a', 1); - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/avoid-imports-preserve-modules/_expected/system/b.js b/test/chunking-form/samples/deprecated/avoid-imports-preserve-modules/_expected/system/b.js deleted file mode 100644 index baa28369184..00000000000 --- a/test/chunking-form/samples/deprecated/avoid-imports-preserve-modules/_expected/system/b.js +++ /dev/null @@ -1,10 +0,0 @@ -System.register([], function (exports) { - 'use strict'; - return { - execute: function () { - - const b = exports('b', 2); - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/avoid-imports-preserve-modules/_expected/system/main.js b/test/chunking-form/samples/deprecated/avoid-imports-preserve-modules/_expected/system/main.js deleted file mode 100644 index 306aa2895cd..00000000000 --- a/test/chunking-form/samples/deprecated/avoid-imports-preserve-modules/_expected/system/main.js +++ /dev/null @@ -1,16 +0,0 @@ -System.register(['./a.js', './one.js'], function () { - 'use strict'; - var a, d; - return { - setters: [function (module) { - a = module.a; - }, function (module) { - d = module.d; - }], - execute: function () { - - console.log(a + d); - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/avoid-imports-preserve-modules/_expected/system/one.js b/test/chunking-form/samples/deprecated/avoid-imports-preserve-modules/_expected/system/one.js deleted file mode 100644 index dac01a3453c..00000000000 --- a/test/chunking-form/samples/deprecated/avoid-imports-preserve-modules/_expected/system/one.js +++ /dev/null @@ -1,14 +0,0 @@ -System.register(['./b.js'], function (exports) { - 'use strict'; - var b; - return { - setters: [function (module) { - b = module.b; - }], - execute: function () { - - const d = exports('d', b + 4); - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/avoid-imports-preserve-modules/a.js b/test/chunking-form/samples/deprecated/avoid-imports-preserve-modules/a.js deleted file mode 100644 index cc798ff50da..00000000000 --- a/test/chunking-form/samples/deprecated/avoid-imports-preserve-modules/a.js +++ /dev/null @@ -1 +0,0 @@ -export const a = 1; diff --git a/test/chunking-form/samples/deprecated/avoid-imports-preserve-modules/b.js b/test/chunking-form/samples/deprecated/avoid-imports-preserve-modules/b.js deleted file mode 100644 index 202103085ce..00000000000 --- a/test/chunking-form/samples/deprecated/avoid-imports-preserve-modules/b.js +++ /dev/null @@ -1 +0,0 @@ -export const b = 2; diff --git a/test/chunking-form/samples/deprecated/avoid-imports-preserve-modules/c.js b/test/chunking-form/samples/deprecated/avoid-imports-preserve-modules/c.js deleted file mode 100644 index 5f0cabef84f..00000000000 --- a/test/chunking-form/samples/deprecated/avoid-imports-preserve-modules/c.js +++ /dev/null @@ -1 +0,0 @@ -export const c = 3; diff --git a/test/chunking-form/samples/deprecated/avoid-imports-preserve-modules/index.js b/test/chunking-form/samples/deprecated/avoid-imports-preserve-modules/index.js deleted file mode 100644 index c2357812df9..00000000000 --- a/test/chunking-form/samples/deprecated/avoid-imports-preserve-modules/index.js +++ /dev/null @@ -1,3 +0,0 @@ -export { a } from './a'; -export { b } from './b'; -export { c } from './c'; diff --git a/test/chunking-form/samples/deprecated/avoid-imports-preserve-modules/main.js b/test/chunking-form/samples/deprecated/avoid-imports-preserve-modules/main.js deleted file mode 100644 index 6279273d11d..00000000000 --- a/test/chunking-form/samples/deprecated/avoid-imports-preserve-modules/main.js +++ /dev/null @@ -1,3 +0,0 @@ -import { a } from './index'; -import { d } from './one'; -console.log(a + d); diff --git a/test/chunking-form/samples/deprecated/avoid-imports-preserve-modules/one.js b/test/chunking-form/samples/deprecated/avoid-imports-preserve-modules/one.js deleted file mode 100644 index 8a9f8689a62..00000000000 --- a/test/chunking-form/samples/deprecated/avoid-imports-preserve-modules/one.js +++ /dev/null @@ -1,2 +0,0 @@ -import { b } from './index'; -export const d = b + 4; diff --git a/test/chunking-form/samples/deprecated/circular-manual-chunks/_config.js b/test/chunking-form/samples/deprecated/circular-manual-chunks/_config.js deleted file mode 100644 index 1a256a1d458..00000000000 --- a/test/chunking-form/samples/deprecated/circular-manual-chunks/_config.js +++ /dev/null @@ -1,9 +0,0 @@ -module.exports = { - description: 'handles manual chunks with circular dependencies', - expectedWarnings: ['CIRCULAR_DEPENDENCY'], - options: { - strictDeprecations: false, - input: 'main', - manualChunks: { lib1: ['lib1'], lib2: ['lib2'] } - } -}; diff --git a/test/chunking-form/samples/deprecated/circular-manual-chunks/_expected/amd/generated-lib1.js b/test/chunking-form/samples/deprecated/circular-manual-chunks/_expected/amd/generated-lib1.js deleted file mode 100644 index 257a2531b61..00000000000 --- a/test/chunking-form/samples/deprecated/circular-manual-chunks/_expected/amd/generated-lib1.js +++ /dev/null @@ -1,8 +0,0 @@ -define(['exports', './generated-lib2'], function (exports, lib2) { 'use strict'; - - const lib1 = 'lib1'; - console.log(`${lib1} imports ${lib2.lib2}`); - - exports.lib1 = lib1; - -}); diff --git a/test/chunking-form/samples/deprecated/circular-manual-chunks/_expected/amd/generated-lib2.js b/test/chunking-form/samples/deprecated/circular-manual-chunks/_expected/amd/generated-lib2.js deleted file mode 100644 index 2d731c52482..00000000000 --- a/test/chunking-form/samples/deprecated/circular-manual-chunks/_expected/amd/generated-lib2.js +++ /dev/null @@ -1,8 +0,0 @@ -define(['exports', './generated-lib1'], function (exports, lib1) { 'use strict'; - - const lib2 = 'lib2'; - console.log(`${lib2} imports ${lib1.lib1}`); - - exports.lib2 = lib2; - -}); diff --git a/test/chunking-form/samples/deprecated/circular-manual-chunks/_expected/amd/main.js b/test/chunking-form/samples/deprecated/circular-manual-chunks/_expected/amd/main.js deleted file mode 100644 index bb9152d6ae4..00000000000 --- a/test/chunking-form/samples/deprecated/circular-manual-chunks/_expected/amd/main.js +++ /dev/null @@ -1,9 +0,0 @@ -define(['exports', './generated-lib1', './generated-lib2'], function (exports, lib1, lib2) { 'use strict'; - - - - exports.lib1 = lib1.lib1; - - Object.defineProperty(exports, '__esModule', { value: true }); - -}); diff --git a/test/chunking-form/samples/deprecated/circular-manual-chunks/_expected/cjs/generated-lib1.js b/test/chunking-form/samples/deprecated/circular-manual-chunks/_expected/cjs/generated-lib1.js deleted file mode 100644 index 7c6e9861e98..00000000000 --- a/test/chunking-form/samples/deprecated/circular-manual-chunks/_expected/cjs/generated-lib1.js +++ /dev/null @@ -1,8 +0,0 @@ -'use strict'; - -var lib2 = require('./generated-lib2.js'); - -const lib1 = 'lib1'; -console.log(`${lib1} imports ${lib2.lib2}`); - -exports.lib1 = lib1; diff --git a/test/chunking-form/samples/deprecated/circular-manual-chunks/_expected/cjs/generated-lib2.js b/test/chunking-form/samples/deprecated/circular-manual-chunks/_expected/cjs/generated-lib2.js deleted file mode 100644 index b1af239dfea..00000000000 --- a/test/chunking-form/samples/deprecated/circular-manual-chunks/_expected/cjs/generated-lib2.js +++ /dev/null @@ -1,8 +0,0 @@ -'use strict'; - -var lib1 = require('./generated-lib1.js'); - -const lib2 = 'lib2'; -console.log(`${lib2} imports ${lib1.lib1}`); - -exports.lib2 = lib2; diff --git a/test/chunking-form/samples/deprecated/circular-manual-chunks/_expected/cjs/main.js b/test/chunking-form/samples/deprecated/circular-manual-chunks/_expected/cjs/main.js deleted file mode 100644 index 8ca369a5e0b..00000000000 --- a/test/chunking-form/samples/deprecated/circular-manual-chunks/_expected/cjs/main.js +++ /dev/null @@ -1,10 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { value: true }); - -var lib1 = require('./generated-lib1.js'); -require('./generated-lib2.js'); - - - -exports.lib1 = lib1.lib1; diff --git a/test/chunking-form/samples/deprecated/circular-manual-chunks/_expected/es/generated-lib1.js b/test/chunking-form/samples/deprecated/circular-manual-chunks/_expected/es/generated-lib1.js deleted file mode 100644 index f01a233c797..00000000000 --- a/test/chunking-form/samples/deprecated/circular-manual-chunks/_expected/es/generated-lib1.js +++ /dev/null @@ -1,6 +0,0 @@ -import { l as lib2 } from './generated-lib2.js'; - -const lib1 = 'lib1'; -console.log(`${lib1} imports ${lib2}`); - -export { lib1 as l }; diff --git a/test/chunking-form/samples/deprecated/circular-manual-chunks/_expected/es/generated-lib2.js b/test/chunking-form/samples/deprecated/circular-manual-chunks/_expected/es/generated-lib2.js deleted file mode 100644 index d822262aeb0..00000000000 --- a/test/chunking-form/samples/deprecated/circular-manual-chunks/_expected/es/generated-lib2.js +++ /dev/null @@ -1,6 +0,0 @@ -import { l as lib1 } from './generated-lib1.js'; - -const lib2 = 'lib2'; -console.log(`${lib2} imports ${lib1}`); - -export { lib2 as l }; diff --git a/test/chunking-form/samples/deprecated/circular-manual-chunks/_expected/es/main.js b/test/chunking-form/samples/deprecated/circular-manual-chunks/_expected/es/main.js deleted file mode 100644 index 93f53841e6a..00000000000 --- a/test/chunking-form/samples/deprecated/circular-manual-chunks/_expected/es/main.js +++ /dev/null @@ -1,2 +0,0 @@ -export { l as lib1 } from './generated-lib1.js'; -import './generated-lib2.js'; diff --git a/test/chunking-form/samples/deprecated/circular-manual-chunks/_expected/system/generated-lib1.js b/test/chunking-form/samples/deprecated/circular-manual-chunks/_expected/system/generated-lib1.js deleted file mode 100644 index 482dde2146a..00000000000 --- a/test/chunking-form/samples/deprecated/circular-manual-chunks/_expected/system/generated-lib1.js +++ /dev/null @@ -1,15 +0,0 @@ -System.register(['./generated-lib2.js'], function (exports) { - 'use strict'; - var lib2; - return { - setters: [function (module) { - lib2 = module.l; - }], - execute: function () { - - const lib1 = exports('l', 'lib1'); - console.log(`${lib1} imports ${lib2}`); - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/circular-manual-chunks/_expected/system/generated-lib2.js b/test/chunking-form/samples/deprecated/circular-manual-chunks/_expected/system/generated-lib2.js deleted file mode 100644 index d1beca4b879..00000000000 --- a/test/chunking-form/samples/deprecated/circular-manual-chunks/_expected/system/generated-lib2.js +++ /dev/null @@ -1,15 +0,0 @@ -System.register(['./generated-lib1.js'], function (exports) { - 'use strict'; - var lib1; - return { - setters: [function (module) { - lib1 = module.l; - }], - execute: function () { - - const lib2 = exports('l', 'lib2'); - console.log(`${lib2} imports ${lib1}`); - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/circular-manual-chunks/_expected/system/main.js b/test/chunking-form/samples/deprecated/circular-manual-chunks/_expected/system/main.js deleted file mode 100644 index 2bbc4fab8c6..00000000000 --- a/test/chunking-form/samples/deprecated/circular-manual-chunks/_expected/system/main.js +++ /dev/null @@ -1,13 +0,0 @@ -System.register(['./generated-lib1.js', './generated-lib2.js'], function (exports) { - 'use strict'; - return { - setters: [function (module) { - exports('lib1', module.l); - }, function () {}], - execute: function () { - - - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/circular-manual-chunks/lib1.js b/test/chunking-form/samples/deprecated/circular-manual-chunks/lib1.js deleted file mode 100644 index f0e3728c779..00000000000 --- a/test/chunking-form/samples/deprecated/circular-manual-chunks/lib1.js +++ /dev/null @@ -1,3 +0,0 @@ -import { lib2 } from './lib2.js'; -export const lib1 = 'lib1'; -console.log(`${lib1} imports ${lib2}`); diff --git a/test/chunking-form/samples/deprecated/circular-manual-chunks/lib2.js b/test/chunking-form/samples/deprecated/circular-manual-chunks/lib2.js deleted file mode 100644 index cb0f5333f98..00000000000 --- a/test/chunking-form/samples/deprecated/circular-manual-chunks/lib2.js +++ /dev/null @@ -1,3 +0,0 @@ -import { lib1 } from './lib1'; -export const lib2 = 'lib2'; -console.log(`${lib2} imports ${lib1}`); diff --git a/test/chunking-form/samples/deprecated/circular-manual-chunks/main.js b/test/chunking-form/samples/deprecated/circular-manual-chunks/main.js deleted file mode 100644 index 73c902d4bfa..00000000000 --- a/test/chunking-form/samples/deprecated/circular-manual-chunks/main.js +++ /dev/null @@ -1 +0,0 @@ -export { lib1 } from './lib1.js'; diff --git a/test/chunking-form/samples/deprecated/configure-asset-url/_config.js b/test/chunking-form/samples/deprecated/configure-asset-url/_config.js deleted file mode 100644 index c867fee7ed1..00000000000 --- a/test/chunking-form/samples/deprecated/configure-asset-url/_config.js +++ /dev/null @@ -1,43 +0,0 @@ -module.exports = { - description: 'allows to configure asset urls', - expectedWarnings: ['DEPRECATED_FEATURE'], - options: { - strictDeprecations: false, - output: { - chunkFileNames: 'nested/chunk.js' - }, - plugins: [ - { - resolveId(id) { - if (id.endsWith('solved')) { - return id; - } - }, - load(id) { - if (id.endsWith('solved')) { - const assetId = this.emitAsset(`asset-${id}.txt`, `Asset for: ${id}`); - return `export default import.meta.ROLLUP_ASSET_URL_${assetId};`; - } - }, - resolveAssetUrl({ chunkId, moduleId, assetFileName, relativeAssetPath }) { - if (!moduleId.endsWith('resolved')) { - return `'${chunkId}:${moduleId - .replace(/\\/g, '/') - .split('/') - .slice(-2) - .join('/')}:${assetFileName}:${relativeAssetPath}'`; - } - return null; - } - }, - { - resolveAssetUrl({ moduleId }) { - if (moduleId === 'resolved') { - return `'resolved'`; - } - return null; - } - } - ] - } -}; diff --git a/test/chunking-form/samples/deprecated/configure-asset-url/_expected/amd/main.js b/test/chunking-form/samples/deprecated/configure-asset-url/_expected/amd/main.js deleted file mode 100644 index 44faf871ab5..00000000000 --- a/test/chunking-form/samples/deprecated/configure-asset-url/_expected/amd/main.js +++ /dev/null @@ -1,9 +0,0 @@ -define(['require'], function (require) { 'use strict'; - - var asset2 = 'resolved'; - - var asset3 = new URL(require.toUrl('./assets/asset-unresolved-8dcd7fca.txt'), document.baseURI).href; - - new Promise(function (resolve, reject) { require(['./nested/chunk'], resolve, reject) }).then(result => console.log(result, asset2, asset3)); - -}); diff --git a/test/chunking-form/samples/deprecated/configure-asset-url/_expected/amd/nested/chunk.js b/test/chunking-form/samples/deprecated/configure-asset-url/_expected/amd/nested/chunk.js deleted file mode 100644 index c52ce8abedf..00000000000 --- a/test/chunking-form/samples/deprecated/configure-asset-url/_expected/amd/nested/chunk.js +++ /dev/null @@ -1,7 +0,0 @@ -define(['require', 'exports'], function (require, exports) { 'use strict'; - - var solved = 'nested/chunk.js:solved:assets/asset-solved-28a7ac89.txt:../assets/asset-solved-28a7ac89.txt'; - - exports.default = solved; - -}); diff --git a/test/chunking-form/samples/deprecated/configure-asset-url/_expected/cjs/main.js b/test/chunking-form/samples/deprecated/configure-asset-url/_expected/cjs/main.js deleted file mode 100644 index ca36e16ba1d..00000000000 --- a/test/chunking-form/samples/deprecated/configure-asset-url/_expected/cjs/main.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -var asset2 = 'resolved'; - -var asset3 = (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __dirname + '/assets/asset-unresolved-8dcd7fca.txt').href : new URL('assets/asset-unresolved-8dcd7fca.txt', document.currentScript && document.currentScript.src || document.baseURI).href); - -Promise.resolve().then(function () { return require('./nested/chunk.js'); }).then(result => console.log(result, asset2, asset3)); diff --git a/test/chunking-form/samples/deprecated/configure-asset-url/_expected/cjs/nested/chunk.js b/test/chunking-form/samples/deprecated/configure-asset-url/_expected/cjs/nested/chunk.js deleted file mode 100644 index 5ddc0c99e0d..00000000000 --- a/test/chunking-form/samples/deprecated/configure-asset-url/_expected/cjs/nested/chunk.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -var solved = 'nested/chunk.js:solved:assets/asset-solved-28a7ac89.txt:../assets/asset-solved-28a7ac89.txt'; - -exports.default = solved; diff --git a/test/chunking-form/samples/deprecated/configure-asset-url/_expected/es/main.js b/test/chunking-form/samples/deprecated/configure-asset-url/_expected/es/main.js deleted file mode 100644 index c78af2b3768..00000000000 --- a/test/chunking-form/samples/deprecated/configure-asset-url/_expected/es/main.js +++ /dev/null @@ -1,5 +0,0 @@ -var asset2 = 'resolved'; - -var asset3 = new URL('assets/asset-unresolved-8dcd7fca.txt', import.meta.url).href; - -import('./nested/chunk.js').then(result => console.log(result, asset2, asset3)); diff --git a/test/chunking-form/samples/deprecated/configure-asset-url/_expected/es/nested/chunk.js b/test/chunking-form/samples/deprecated/configure-asset-url/_expected/es/nested/chunk.js deleted file mode 100644 index 1af7c01e941..00000000000 --- a/test/chunking-form/samples/deprecated/configure-asset-url/_expected/es/nested/chunk.js +++ /dev/null @@ -1,3 +0,0 @@ -var solved = 'nested/chunk.js:solved:assets/asset-solved-28a7ac89.txt:../assets/asset-solved-28a7ac89.txt'; - -export default solved; diff --git a/test/chunking-form/samples/deprecated/configure-asset-url/_expected/system/main.js b/test/chunking-form/samples/deprecated/configure-asset-url/_expected/system/main.js deleted file mode 100644 index 971fff86b4d..00000000000 --- a/test/chunking-form/samples/deprecated/configure-asset-url/_expected/system/main.js +++ /dev/null @@ -1,14 +0,0 @@ -System.register([], function (exports, module) { - 'use strict'; - return { - execute: function () { - - var asset2 = 'resolved'; - - var asset3 = new URL('assets/asset-unresolved-8dcd7fca.txt', module.meta.url).href; - - module.import('./nested/chunk.js').then(result => console.log(result, asset2, asset3)); - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/configure-asset-url/_expected/system/nested/chunk.js b/test/chunking-form/samples/deprecated/configure-asset-url/_expected/system/nested/chunk.js deleted file mode 100644 index 3bdc2610687..00000000000 --- a/test/chunking-form/samples/deprecated/configure-asset-url/_expected/system/nested/chunk.js +++ /dev/null @@ -1,10 +0,0 @@ -System.register([], function (exports, module) { - 'use strict'; - return { - execute: function () { - - var solved = exports('default', 'nested/chunk.js:solved:assets/asset-solved-28a7ac89.txt:../assets/asset-solved-28a7ac89.txt'); - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/configure-asset-url/main.js b/test/chunking-form/samples/deprecated/configure-asset-url/main.js deleted file mode 100644 index b3f01707026..00000000000 --- a/test/chunking-form/samples/deprecated/configure-asset-url/main.js +++ /dev/null @@ -1,4 +0,0 @@ -import asset2 from 'resolved'; -import asset3 from 'unresolved'; - -import('solved').then(result => console.log(result, asset2, asset3)); diff --git a/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_config.js b/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_config.js deleted file mode 100644 index 187178aed06..00000000000 --- a/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_config.js +++ /dev/null @@ -1,57 +0,0 @@ -module.exports = { - description: 'allows to configure file urls', - expectedWarnings: ['DEPRECATED_FEATURE'], - options: { - strictDeprecations: false, - output: { - chunkFileNames: 'nested/chunk.js' - }, - plugins: [ - { - resolveId(id) { - if (id.endsWith('solved')) { - return id; - } - }, - load(id) { - if (id.endsWith('solved')) { - const assetId = this.emitAsset(`asset-${id}.txt`, `Asset for: ${id}`); - const chunkId = this.emitChunk('chunk.js'); - return ( - `export const asset = import.meta.ROLLUP_ASSET_URL_${assetId};\n` + - `export const chunk = import.meta.ROLLUP_CHUNK_URL_${chunkId};` - ); - } - }, - resolveFileUrl({ - assetReferenceId, - chunkId, - chunkReferenceId, - fileName, - format, - moduleId, - relativePath - }) { - if (!moduleId.endsWith('resolved')) { - return `'chunkId=${chunkId}:moduleId=${moduleId - .replace(/\\/g, '/') - .split('/') - .slice(-2) - .join( - '/' - )}:fileName=${fileName}:format=${format}:relativePath=${relativePath}:assetReferenceId=${assetReferenceId}:chunkReferenceId=${chunkReferenceId}'`; - } - return null; - } - }, - { - resolveFileUrl({ moduleId }) { - if (moduleId === 'resolved') { - return `'resolved'`; - } - return null; - } - } - ] - } -}; diff --git a/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/amd/main.js b/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/amd/main.js deleted file mode 100644 index 5bae0b1bdb6..00000000000 --- a/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/amd/main.js +++ /dev/null @@ -1,11 +0,0 @@ -define(['require'], function (require) { 'use strict'; - - const asset$1 = 'resolved'; - const chunk$1 = 'resolved'; - - const asset = new URL(require.toUrl('./assets/asset-unresolved-8dcd7fca.txt'), document.baseURI).href; - const chunk = new URL(require.toUrl('./nested/chunk.js'), document.baseURI).href; - - new Promise(function (resolve, reject) { require(['./nested/chunk2'], resolve, reject) }).then(result => console.log(result, chunk$1, chunk, asset$1, asset)); - -}); diff --git a/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/amd/nested/chunk.js b/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/amd/nested/chunk.js deleted file mode 100644 index 32f0814a584..00000000000 --- a/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/amd/nested/chunk.js +++ /dev/null @@ -1,5 +0,0 @@ -define(function () { 'use strict'; - - console.log('chunk'); - -}); diff --git a/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/amd/nested/chunk2.js b/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/amd/nested/chunk2.js deleted file mode 100644 index c40e57b7bf5..00000000000 --- a/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/amd/nested/chunk2.js +++ /dev/null @@ -1,9 +0,0 @@ -define(['require', 'exports'], function (require, exports) { 'use strict'; - - const asset = 'chunkId=nested/chunk2.js:moduleId=solved:fileName=assets/asset-solved-28a7ac89.txt:format=amd:relativePath=../assets/asset-solved-28a7ac89.txt:assetReferenceId=6296c678:chunkReferenceId=null'; - const chunk = 'chunkId=nested/chunk2.js:moduleId=solved:fileName=nested/chunk.js:format=amd:relativePath=chunk.js:assetReferenceId=null:chunkReferenceId=f6c25ae7'; - - exports.asset = asset; - exports.chunk = chunk; - -}); diff --git a/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/cjs/assets/asset-resolved-8bd22e6e.txt b/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/cjs/assets/asset-resolved-8bd22e6e.txt deleted file mode 100644 index 31fb300f988..00000000000 --- a/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/cjs/assets/asset-resolved-8bd22e6e.txt +++ /dev/null @@ -1 +0,0 @@ -Asset for: resolved \ No newline at end of file diff --git a/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/cjs/assets/asset-solved-28a7ac89.txt b/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/cjs/assets/asset-solved-28a7ac89.txt deleted file mode 100644 index 07c7a096c7e..00000000000 --- a/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/cjs/assets/asset-solved-28a7ac89.txt +++ /dev/null @@ -1 +0,0 @@ -Asset for: solved \ No newline at end of file diff --git a/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/cjs/assets/asset-unresolved-8dcd7fca.txt b/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/cjs/assets/asset-unresolved-8dcd7fca.txt deleted file mode 100644 index fd3ad6261cc..00000000000 --- a/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/cjs/assets/asset-unresolved-8dcd7fca.txt +++ /dev/null @@ -1 +0,0 @@ -Asset for: unresolved \ No newline at end of file diff --git a/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/cjs/main.js b/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/cjs/main.js deleted file mode 100644 index feea03def6e..00000000000 --- a/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/cjs/main.js +++ /dev/null @@ -1,9 +0,0 @@ -'use strict'; - -const asset$1 = 'resolved'; -const chunk$1 = 'resolved'; - -const asset = (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __dirname + '/assets/asset-unresolved-8dcd7fca.txt').href : new URL('assets/asset-unresolved-8dcd7fca.txt', document.currentScript && document.currentScript.src || document.baseURI).href); -const chunk = (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __dirname + '/nested/chunk.js').href : new URL('nested/chunk.js', document.currentScript && document.currentScript.src || document.baseURI).href); - -Promise.resolve().then(function () { return require('./nested/chunk2.js'); }).then(result => console.log(result, chunk$1, chunk, asset$1, asset)); diff --git a/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/cjs/nested/chunk.js b/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/cjs/nested/chunk.js deleted file mode 100644 index 9bd6f06e964..00000000000 --- a/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/cjs/nested/chunk.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -console.log('chunk'); diff --git a/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/cjs/nested/chunk2.js b/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/cjs/nested/chunk2.js deleted file mode 100644 index 2ea0d2caf6f..00000000000 --- a/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/cjs/nested/chunk2.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -const asset = 'chunkId=nested/chunk2.js:moduleId=solved:fileName=assets/asset-solved-28a7ac89.txt:format=cjs:relativePath=../assets/asset-solved-28a7ac89.txt:assetReferenceId=6296c678:chunkReferenceId=null'; -const chunk = 'chunkId=nested/chunk2.js:moduleId=solved:fileName=nested/chunk.js:format=cjs:relativePath=chunk.js:assetReferenceId=null:chunkReferenceId=f6c25ae7'; - -exports.asset = asset; -exports.chunk = chunk; diff --git a/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/es/assets/asset-resolved-8bd22e6e.txt b/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/es/assets/asset-resolved-8bd22e6e.txt deleted file mode 100644 index 31fb300f988..00000000000 --- a/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/es/assets/asset-resolved-8bd22e6e.txt +++ /dev/null @@ -1 +0,0 @@ -Asset for: resolved \ No newline at end of file diff --git a/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/es/assets/asset-solved-28a7ac89.txt b/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/es/assets/asset-solved-28a7ac89.txt deleted file mode 100644 index 07c7a096c7e..00000000000 --- a/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/es/assets/asset-solved-28a7ac89.txt +++ /dev/null @@ -1 +0,0 @@ -Asset for: solved \ No newline at end of file diff --git a/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/es/assets/asset-unresolved-8dcd7fca.txt b/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/es/assets/asset-unresolved-8dcd7fca.txt deleted file mode 100644 index fd3ad6261cc..00000000000 --- a/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/es/assets/asset-unresolved-8dcd7fca.txt +++ /dev/null @@ -1 +0,0 @@ -Asset for: unresolved \ No newline at end of file diff --git a/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/es/main.js b/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/es/main.js deleted file mode 100644 index 1f84c485bd4..00000000000 --- a/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/es/main.js +++ /dev/null @@ -1,7 +0,0 @@ -const asset$1 = 'resolved'; -const chunk$1 = 'resolved'; - -const asset = new URL('assets/asset-unresolved-8dcd7fca.txt', import.meta.url).href; -const chunk = new URL('nested/chunk.js', import.meta.url).href; - -import('./nested/chunk2.js').then(result => console.log(result, chunk$1, chunk, asset$1, asset)); diff --git a/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/es/nested/chunk.js b/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/es/nested/chunk.js deleted file mode 100644 index 36b1d61dd25..00000000000 --- a/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/es/nested/chunk.js +++ /dev/null @@ -1 +0,0 @@ -console.log('chunk'); diff --git a/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/es/nested/chunk2.js b/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/es/nested/chunk2.js deleted file mode 100644 index 736b09b62c1..00000000000 --- a/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/es/nested/chunk2.js +++ /dev/null @@ -1,4 +0,0 @@ -const asset = 'chunkId=nested/chunk2.js:moduleId=solved:fileName=assets/asset-solved-28a7ac89.txt:format=es:relativePath=../assets/asset-solved-28a7ac89.txt:assetReferenceId=6296c678:chunkReferenceId=null'; -const chunk = 'chunkId=nested/chunk2.js:moduleId=solved:fileName=nested/chunk.js:format=es:relativePath=chunk.js:assetReferenceId=null:chunkReferenceId=f6c25ae7'; - -export { asset, chunk }; diff --git a/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/system/assets/asset-resolved-8bd22e6e.txt b/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/system/assets/asset-resolved-8bd22e6e.txt deleted file mode 100644 index 31fb300f988..00000000000 --- a/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/system/assets/asset-resolved-8bd22e6e.txt +++ /dev/null @@ -1 +0,0 @@ -Asset for: resolved \ No newline at end of file diff --git a/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/system/assets/asset-solved-28a7ac89.txt b/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/system/assets/asset-solved-28a7ac89.txt deleted file mode 100644 index 07c7a096c7e..00000000000 --- a/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/system/assets/asset-solved-28a7ac89.txt +++ /dev/null @@ -1 +0,0 @@ -Asset for: solved \ No newline at end of file diff --git a/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/system/assets/asset-unresolved-8dcd7fca.txt b/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/system/assets/asset-unresolved-8dcd7fca.txt deleted file mode 100644 index fd3ad6261cc..00000000000 --- a/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/system/assets/asset-unresolved-8dcd7fca.txt +++ /dev/null @@ -1 +0,0 @@ -Asset for: unresolved \ No newline at end of file diff --git a/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/system/main.js b/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/system/main.js deleted file mode 100644 index c7f3e654ea4..00000000000 --- a/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/system/main.js +++ /dev/null @@ -1,16 +0,0 @@ -System.register([], function (exports, module) { - 'use strict'; - return { - execute: function () { - - const asset$1 = 'resolved'; - const chunk$1 = 'resolved'; - - const asset = new URL('assets/asset-unresolved-8dcd7fca.txt', module.meta.url).href; - const chunk = new URL('nested/chunk.js', module.meta.url).href; - - module.import('./nested/chunk2.js').then(result => console.log(result, chunk$1, chunk, asset$1, asset)); - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/system/nested/chunk.js b/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/system/nested/chunk.js deleted file mode 100644 index 9d080a80d2d..00000000000 --- a/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/system/nested/chunk.js +++ /dev/null @@ -1,10 +0,0 @@ -System.register([], function () { - 'use strict'; - return { - execute: function () { - - console.log('chunk'); - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/system/nested/chunk2.js b/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/system/nested/chunk2.js deleted file mode 100644 index 0ef79e2e19a..00000000000 --- a/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/system/nested/chunk2.js +++ /dev/null @@ -1,11 +0,0 @@ -System.register([], function (exports, module) { - 'use strict'; - return { - execute: function () { - - const asset = exports('asset', 'chunkId=nested/chunk2.js:moduleId=solved:fileName=assets/asset-solved-28a7ac89.txt:format=system:relativePath=../assets/asset-solved-28a7ac89.txt:assetReferenceId=6296c678:chunkReferenceId=null'); - const chunk = exports('chunk', 'chunkId=nested/chunk2.js:moduleId=solved:fileName=nested/chunk.js:format=system:relativePath=chunk.js:assetReferenceId=null:chunkReferenceId=f6c25ae7'); - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/chunk.js b/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/chunk.js deleted file mode 100644 index 36b1d61dd25..00000000000 --- a/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/chunk.js +++ /dev/null @@ -1 +0,0 @@ -console.log('chunk'); diff --git a/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/main.js b/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/main.js deleted file mode 100644 index c7b101dfc5b..00000000000 --- a/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/main.js +++ /dev/null @@ -1,5 +0,0 @@ -import { asset as asset1, chunk as chunk1 } from 'resolved'; -import { asset as asset2, chunk as chunk2 } from 'unresolved'; - -import('solved').then(result => console.log(result, chunk1, chunk2, asset1, asset2)); - diff --git a/test/chunking-form/samples/deprecated/dynamic-import-comments/_config.js b/test/chunking-form/samples/deprecated/dynamic-import-comments/_config.js deleted file mode 100644 index 2bc7c8df417..00000000000 --- a/test/chunking-form/samples/deprecated/dynamic-import-comments/_config.js +++ /dev/null @@ -1,16 +0,0 @@ -module.exports = { - description: 'should not remove inline comments inside dynamic import', - options: { - strictDeprecations: false, - input: 'main.js', - onwarn() {}, - plugins: { - resolveDynamicImport() { - return false; - } - }, - output: { - dynamicImportFunction: 'foobar' - } - } -}; diff --git a/test/chunking-form/samples/deprecated/dynamic-import-comments/_expected/amd/main.js b/test/chunking-form/samples/deprecated/dynamic-import-comments/_expected/amd/main.js deleted file mode 100644 index 263888b053a..00000000000 --- a/test/chunking-form/samples/deprecated/dynamic-import-comments/_expected/amd/main.js +++ /dev/null @@ -1,27 +0,0 @@ -define(['require'], function (require) { 'use strict'; - - function _interopNamespace(e) { - if (e && e.__esModule) return e; - var n = Object.create(null); - if (e) { - Object.keys(e).forEach(function (k) { - if (k !== 'default') { - var d = Object.getOwnPropertyDescriptor(e, k); - Object.defineProperty(n, k, d.get ? d : { - enumerable: true, - get: function () { - return e[k]; - } - }); - } - }); - } - n['default'] = e; - return Object.freeze(n); - } - - new Promise(function (resolve, reject) { require([ - /* webpackChunkName: "chunk-name" */ - './foo'/*suffix*/], function (m) { resolve(/*#__PURE__*/_interopNamespace(m)); }, reject) }); - -}); diff --git a/test/chunking-form/samples/deprecated/dynamic-import-comments/_expected/cjs/main.js b/test/chunking-form/samples/deprecated/dynamic-import-comments/_expected/cjs/main.js deleted file mode 100644 index 1969a9698a6..00000000000 --- a/test/chunking-form/samples/deprecated/dynamic-import-comments/_expected/cjs/main.js +++ /dev/null @@ -1,25 +0,0 @@ -'use strict'; - -function _interopNamespace(e) { - if (e && e.__esModule) return e; - var n = Object.create(null); - if (e) { - Object.keys(e).forEach(function (k) { - if (k !== 'default') { - var d = Object.getOwnPropertyDescriptor(e, k); - Object.defineProperty(n, k, d.get ? d : { - enumerable: true, - get: function () { - return e[k]; - } - }); - } - }); - } - n['default'] = e; - return Object.freeze(n); -} - -Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require( -/* webpackChunkName: "chunk-name" */ -'./foo.js'/*suffix*/)); }); diff --git a/test/chunking-form/samples/deprecated/dynamic-import-comments/_expected/es/main.js b/test/chunking-form/samples/deprecated/dynamic-import-comments/_expected/es/main.js deleted file mode 100644 index 8f23863149d..00000000000 --- a/test/chunking-form/samples/deprecated/dynamic-import-comments/_expected/es/main.js +++ /dev/null @@ -1,3 +0,0 @@ -foobar( -/* webpackChunkName: "chunk-name" */ -'./foo.js'/*suffix*/); diff --git a/test/chunking-form/samples/deprecated/dynamic-import-comments/_expected/system/main.js b/test/chunking-form/samples/deprecated/dynamic-import-comments/_expected/system/main.js deleted file mode 100644 index 5967f1516fb..00000000000 --- a/test/chunking-form/samples/deprecated/dynamic-import-comments/_expected/system/main.js +++ /dev/null @@ -1,12 +0,0 @@ -System.register([], function (exports, module) { - 'use strict'; - return { - execute: function () { - - module.import( - /* webpackChunkName: "chunk-name" */ - './foo.js'/*suffix*/); - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/dynamic-import-comments/main.js b/test/chunking-form/samples/deprecated/dynamic-import-comments/main.js deleted file mode 100644 index 9519c0a650f..00000000000 --- a/test/chunking-form/samples/deprecated/dynamic-import-comments/main.js +++ /dev/null @@ -1,3 +0,0 @@ -import /* () should not break */ ( -/* webpackChunkName: "chunk-name" */ -'./foo.js'/*suffix*/); diff --git a/test/chunking-form/samples/deprecated/dynamic-import-inlining-object/_config.js b/test/chunking-form/samples/deprecated/dynamic-import-inlining-object/_config.js deleted file mode 100644 index 4ffc9d0f905..00000000000 --- a/test/chunking-form/samples/deprecated/dynamic-import-inlining-object/_config.js +++ /dev/null @@ -1,8 +0,0 @@ -module.exports = { - description: 'supports an object with a single entry when inlining dynamic imports', - options: { - strictDeprecations: false, - inlineDynamicImports: true, - input: { entry: 'main' } - } -}; diff --git a/test/chunking-form/samples/deprecated/dynamic-import-inlining-object/_expected/amd/entry.js b/test/chunking-form/samples/deprecated/dynamic-import-inlining-object/_expected/amd/entry.js deleted file mode 100644 index 87c533f4a08..00000000000 --- a/test/chunking-form/samples/deprecated/dynamic-import-inlining-object/_expected/amd/entry.js +++ /dev/null @@ -1,17 +0,0 @@ -define(['exports'], function (exports) { 'use strict'; - - const bar = 2; - Promise.resolve().then(function () { return foo$1; }); - - const foo = 1; - - var foo$1 = /*#__PURE__*/Object.freeze({ - __proto__: null, - foo: foo - }); - - exports.bar = bar; - - Object.defineProperty(exports, '__esModule', { value: true }); - -}); diff --git a/test/chunking-form/samples/deprecated/dynamic-import-inlining-object/_expected/cjs/entry.js b/test/chunking-form/samples/deprecated/dynamic-import-inlining-object/_expected/cjs/entry.js deleted file mode 100644 index 188ad126796..00000000000 --- a/test/chunking-form/samples/deprecated/dynamic-import-inlining-object/_expected/cjs/entry.js +++ /dev/null @@ -1,15 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { value: true }); - -const bar = 2; -Promise.resolve().then(function () { return foo$1; }); - -const foo = 1; - -var foo$1 = /*#__PURE__*/Object.freeze({ - __proto__: null, - foo: foo -}); - -exports.bar = bar; diff --git a/test/chunking-form/samples/deprecated/dynamic-import-inlining-object/_expected/es/entry.js b/test/chunking-form/samples/deprecated/dynamic-import-inlining-object/_expected/es/entry.js deleted file mode 100644 index ae434046e6c..00000000000 --- a/test/chunking-form/samples/deprecated/dynamic-import-inlining-object/_expected/es/entry.js +++ /dev/null @@ -1,11 +0,0 @@ -const bar = 2; -Promise.resolve().then(function () { return foo$1; }); - -const foo = 1; - -var foo$1 = /*#__PURE__*/Object.freeze({ - __proto__: null, - foo: foo -}); - -export { bar }; diff --git a/test/chunking-form/samples/deprecated/dynamic-import-inlining-object/_expected/system/entry.js b/test/chunking-form/samples/deprecated/dynamic-import-inlining-object/_expected/system/entry.js deleted file mode 100644 index 0ac064e426c..00000000000 --- a/test/chunking-form/samples/deprecated/dynamic-import-inlining-object/_expected/system/entry.js +++ /dev/null @@ -1,18 +0,0 @@ -System.register([], function (exports) { - 'use strict'; - return { - execute: function () { - - const bar = exports('bar', 2); - Promise.resolve().then(function () { return foo$1; }); - - const foo = 1; - - var foo$1 = /*#__PURE__*/Object.freeze({ - __proto__: null, - foo: foo - }); - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/dynamic-import-inlining-object/foo.js b/test/chunking-form/samples/deprecated/dynamic-import-inlining-object/foo.js deleted file mode 100644 index 6a8018af412..00000000000 --- a/test/chunking-form/samples/deprecated/dynamic-import-inlining-object/foo.js +++ /dev/null @@ -1 +0,0 @@ -export const foo = 1; \ No newline at end of file diff --git a/test/chunking-form/samples/deprecated/dynamic-import-inlining-object/main.js b/test/chunking-form/samples/deprecated/dynamic-import-inlining-object/main.js deleted file mode 100644 index ee3e6a770d6..00000000000 --- a/test/chunking-form/samples/deprecated/dynamic-import-inlining-object/main.js +++ /dev/null @@ -1,2 +0,0 @@ -export const bar = 2; -import('./foo.js'); diff --git a/test/chunking-form/samples/deprecated/dynamic-import-name/_config.js b/test/chunking-form/samples/deprecated/dynamic-import-name/_config.js deleted file mode 100644 index 601e3b9d0d7..00000000000 --- a/test/chunking-form/samples/deprecated/dynamic-import-name/_config.js +++ /dev/null @@ -1,16 +0,0 @@ -module.exports = { - description: 'allows specifying a custom importer function', - options: { - strictDeprecations: false, - input: 'main.js', - onwarn() {}, - plugins: { - resolveDynamicImport() { - return false; - } - }, - output: { - dynamicImportFunction: 'foobar' - } - } -}; diff --git a/test/chunking-form/samples/deprecated/dynamic-import-name/_expected/amd/main.js b/test/chunking-form/samples/deprecated/dynamic-import-name/_expected/amd/main.js deleted file mode 100644 index 91e687181a8..00000000000 --- a/test/chunking-form/samples/deprecated/dynamic-import-name/_expected/amd/main.js +++ /dev/null @@ -1,25 +0,0 @@ -define(['require'], function (require) { 'use strict'; - - function _interopNamespace(e) { - if (e && e.__esModule) return e; - var n = Object.create(null); - if (e) { - Object.keys(e).forEach(function (k) { - if (k !== 'default') { - var d = Object.getOwnPropertyDescriptor(e, k); - Object.defineProperty(n, k, d.get ? d : { - enumerable: true, - get: function () { - return e[k]; - } - }); - } - }); - } - n['default'] = e; - return Object.freeze(n); - } - - new Promise(function (resolve, reject) { require(['./foo'], function (m) { resolve(/*#__PURE__*/_interopNamespace(m)); }, reject) }).then(result => console.log(result)); - -}); diff --git a/test/chunking-form/samples/deprecated/dynamic-import-name/_expected/cjs/main.js b/test/chunking-form/samples/deprecated/dynamic-import-name/_expected/cjs/main.js deleted file mode 100644 index c6d45fe81dc..00000000000 --- a/test/chunking-form/samples/deprecated/dynamic-import-name/_expected/cjs/main.js +++ /dev/null @@ -1,23 +0,0 @@ -'use strict'; - -function _interopNamespace(e) { - if (e && e.__esModule) return e; - var n = Object.create(null); - if (e) { - Object.keys(e).forEach(function (k) { - if (k !== 'default') { - var d = Object.getOwnPropertyDescriptor(e, k); - Object.defineProperty(n, k, d.get ? d : { - enumerable: true, - get: function () { - return e[k]; - } - }); - } - }); - } - n['default'] = e; - return Object.freeze(n); -} - -Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('./foo.js')); }).then(result => console.log(result)); diff --git a/test/chunking-form/samples/deprecated/dynamic-import-name/_expected/es/main.js b/test/chunking-form/samples/deprecated/dynamic-import-name/_expected/es/main.js deleted file mode 100644 index 31d9a65e153..00000000000 --- a/test/chunking-form/samples/deprecated/dynamic-import-name/_expected/es/main.js +++ /dev/null @@ -1 +0,0 @@ -foobar('./foo.js').then(result => console.log(result)); diff --git a/test/chunking-form/samples/deprecated/dynamic-import-name/_expected/system/main.js b/test/chunking-form/samples/deprecated/dynamic-import-name/_expected/system/main.js deleted file mode 100644 index ce0e7ba782a..00000000000 --- a/test/chunking-form/samples/deprecated/dynamic-import-name/_expected/system/main.js +++ /dev/null @@ -1,10 +0,0 @@ -System.register([], function (exports, module) { - 'use strict'; - return { - execute: function () { - - module.import('./foo.js').then(result => console.log(result)); - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/dynamic-import-name/main.js b/test/chunking-form/samples/deprecated/dynamic-import-name/main.js deleted file mode 100644 index 56ab47293cd..00000000000 --- a/test/chunking-form/samples/deprecated/dynamic-import-name/main.js +++ /dev/null @@ -1 +0,0 @@ -import('./foo.js').then(result => console.log(result)); diff --git a/test/chunking-form/samples/deprecated/emit-asset/_config.js b/test/chunking-form/samples/deprecated/emit-asset/_config.js deleted file mode 100644 index dad3aeeaf09..00000000000 --- a/test/chunking-form/samples/deprecated/emit-asset/_config.js +++ /dev/null @@ -1,30 +0,0 @@ -const fs = require('fs'); -const path = require('path'); - -module.exports = { - description: 'supports emitting assets from plugin hooks', - expectedWarnings: ['DEPRECATED_FEATURE'], - options: { - strictDeprecations: false, - input: ['main.js'], - preserveEntrySignatures: false, - output: { - chunkFileNames: 'nested/chunk.js' - }, - plugins: { - resolveId(id, importee) { - if (id.endsWith('.svg')) { - return path.resolve(path.dirname(importee), id); - } - }, - load(id) { - if (id.endsWith('.svg')) { - return `export default import.meta.ROLLUP_ASSET_URL_${this.emitAsset( - path.basename(id), - fs.readFileSync(id) - )};`; - } - } - } - } -}; diff --git a/test/chunking-form/samples/deprecated/emit-asset/_expected/amd/main.js b/test/chunking-form/samples/deprecated/emit-asset/_expected/amd/main.js deleted file mode 100644 index d69c2282450..00000000000 --- a/test/chunking-form/samples/deprecated/emit-asset/_expected/amd/main.js +++ /dev/null @@ -1,21 +0,0 @@ -define(['require', 'exports'], function (require, exports) { 'use strict'; - - var logo = new URL(require.toUrl('./assets/logo1-a5ec488b.svg'), document.baseURI).href; - - function showImage(url) { - console.log(url); - if (typeof document !== 'undefined') { - const image = document.createElement('img'); - image.src = url; - document.body.appendChild(image); - } - } - - showImage(logo); - new Promise(function (resolve, reject) { require(['./nested/chunk'], resolve, reject) }); - - exports.showImage = showImage; - - Object.defineProperty(exports, '__esModule', { value: true }); - -}); diff --git a/test/chunking-form/samples/deprecated/emit-asset/_expected/amd/nested/chunk.js b/test/chunking-form/samples/deprecated/emit-asset/_expected/amd/nested/chunk.js deleted file mode 100644 index 58bc60e0179..00000000000 --- a/test/chunking-form/samples/deprecated/emit-asset/_expected/amd/nested/chunk.js +++ /dev/null @@ -1,7 +0,0 @@ -define(['require', '../main'], function (require, main) { 'use strict'; - - var logo = new URL(require.toUrl('../assets/logo2-6d5979e4.svg'), document.baseURI).href; - - main.showImage(logo); - -}); diff --git a/test/chunking-form/samples/deprecated/emit-asset/_expected/cjs/main.js b/test/chunking-form/samples/deprecated/emit-asset/_expected/cjs/main.js deleted file mode 100644 index 5c22a31491d..00000000000 --- a/test/chunking-form/samples/deprecated/emit-asset/_expected/cjs/main.js +++ /dev/null @@ -1,19 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { value: true }); - -var logo = (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __dirname + '/assets/logo1-a5ec488b.svg').href : new URL('assets/logo1-a5ec488b.svg', document.currentScript && document.currentScript.src || document.baseURI).href); - -function showImage(url) { - console.log(url); - if (typeof document !== 'undefined') { - const image = document.createElement('img'); - image.src = url; - document.body.appendChild(image); - } -} - -showImage(logo); -Promise.resolve().then(function () { return require('./nested/chunk.js'); }); - -exports.showImage = showImage; diff --git a/test/chunking-form/samples/deprecated/emit-asset/_expected/cjs/nested/chunk.js b/test/chunking-form/samples/deprecated/emit-asset/_expected/cjs/nested/chunk.js deleted file mode 100644 index 8d9f9558b6d..00000000000 --- a/test/chunking-form/samples/deprecated/emit-asset/_expected/cjs/nested/chunk.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -var main = require('../main.js'); - -var logo = (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __dirname + '/../assets/logo2-6d5979e4.svg').href : new URL('../assets/logo2-6d5979e4.svg', document.currentScript && document.currentScript.src || document.baseURI).href); - -main.showImage(logo); diff --git a/test/chunking-form/samples/deprecated/emit-asset/_expected/es/main.js b/test/chunking-form/samples/deprecated/emit-asset/_expected/es/main.js deleted file mode 100644 index 4d8fd5dd758..00000000000 --- a/test/chunking-form/samples/deprecated/emit-asset/_expected/es/main.js +++ /dev/null @@ -1,15 +0,0 @@ -var logo = new URL('assets/logo1-a5ec488b.svg', import.meta.url).href; - -function showImage(url) { - console.log(url); - if (typeof document !== 'undefined') { - const image = document.createElement('img'); - image.src = url; - document.body.appendChild(image); - } -} - -showImage(logo); -import('./nested/chunk.js'); - -export { showImage as s }; diff --git a/test/chunking-form/samples/deprecated/emit-asset/_expected/es/nested/chunk.js b/test/chunking-form/samples/deprecated/emit-asset/_expected/es/nested/chunk.js deleted file mode 100644 index 4491f94fb7e..00000000000 --- a/test/chunking-form/samples/deprecated/emit-asset/_expected/es/nested/chunk.js +++ /dev/null @@ -1,5 +0,0 @@ -import { s as showImage } from '../main.js'; - -var logo = new URL('../assets/logo2-6d5979e4.svg', import.meta.url).href; - -showImage(logo); diff --git a/test/chunking-form/samples/deprecated/emit-asset/_expected/system/main.js b/test/chunking-form/samples/deprecated/emit-asset/_expected/system/main.js deleted file mode 100644 index c4f3d058bad..00000000000 --- a/test/chunking-form/samples/deprecated/emit-asset/_expected/system/main.js +++ /dev/null @@ -1,24 +0,0 @@ -System.register([], function (exports, module) { - 'use strict'; - return { - execute: function () { - - exports('s', showImage); - - var logo = new URL('assets/logo1-a5ec488b.svg', module.meta.url).href; - - function showImage(url) { - console.log(url); - if (typeof document !== 'undefined') { - const image = document.createElement('img'); - image.src = url; - document.body.appendChild(image); - } - } - - showImage(logo); - module.import('./nested/chunk.js'); - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/emit-asset/_expected/system/nested/chunk.js b/test/chunking-form/samples/deprecated/emit-asset/_expected/system/nested/chunk.js deleted file mode 100644 index 627ee24d913..00000000000 --- a/test/chunking-form/samples/deprecated/emit-asset/_expected/system/nested/chunk.js +++ /dev/null @@ -1,16 +0,0 @@ -System.register(['../main.js'], function (exports, module) { - 'use strict'; - var showImage; - return { - setters: [function (module) { - showImage = module.s; - }], - execute: function () { - - var logo = new URL('../assets/logo2-6d5979e4.svg', module.meta.url).href; - - showImage(logo); - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/emit-asset/index-amd.html b/test/chunking-form/samples/deprecated/emit-asset/index-amd.html deleted file mode 100644 index cd17b62967d..00000000000 --- a/test/chunking-form/samples/deprecated/emit-asset/index-amd.html +++ /dev/null @@ -1,10 +0,0 @@ - - - - - AMD - - - - - diff --git a/test/chunking-form/samples/deprecated/emit-asset/index-es.html b/test/chunking-form/samples/deprecated/emit-asset/index-es.html deleted file mode 100644 index 58ae4a61527..00000000000 --- a/test/chunking-form/samples/deprecated/emit-asset/index-es.html +++ /dev/null @@ -1,10 +0,0 @@ - - - - - Title - - - - - diff --git a/test/chunking-form/samples/deprecated/emit-asset/index-system.html b/test/chunking-form/samples/deprecated/emit-asset/index-system.html deleted file mode 100644 index d4b3890b337..00000000000 --- a/test/chunking-form/samples/deprecated/emit-asset/index-system.html +++ /dev/null @@ -1,11 +0,0 @@ - - - - - SystemJS - - - - - - diff --git a/test/chunking-form/samples/deprecated/emit-asset/logo2.svg b/test/chunking-form/samples/deprecated/emit-asset/logo2.svg deleted file mode 100644 index b446284a4cd..00000000000 --- a/test/chunking-form/samples/deprecated/emit-asset/logo2.svg +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/test/chunking-form/samples/deprecated/emit-asset/main.js b/test/chunking-form/samples/deprecated/emit-asset/main.js deleted file mode 100644 index 5c1787b77b4..00000000000 --- a/test/chunking-form/samples/deprecated/emit-asset/main.js +++ /dev/null @@ -1,5 +0,0 @@ -import logo from './logo1.svg'; -import { showImage } from './show-image'; - -showImage(logo); -import('./nested.js'); diff --git a/test/chunking-form/samples/deprecated/emit-asset/nested.js b/test/chunking-form/samples/deprecated/emit-asset/nested.js deleted file mode 100644 index ceb0a68e6e1..00000000000 --- a/test/chunking-form/samples/deprecated/emit-asset/nested.js +++ /dev/null @@ -1,4 +0,0 @@ -import logo from './logo2.svg'; -import { showImage } from './show-image'; - -showImage(logo); diff --git a/test/chunking-form/samples/deprecated/emit-asset/show-image.js b/test/chunking-form/samples/deprecated/emit-asset/show-image.js deleted file mode 100644 index 28c706ab24b..00000000000 --- a/test/chunking-form/samples/deprecated/emit-asset/show-image.js +++ /dev/null @@ -1,8 +0,0 @@ -export function showImage(url) { - console.log(url); - if (typeof document !== 'undefined') { - const image = document.createElement('img'); - image.src = url; - document.body.appendChild(image); - } -} diff --git a/test/chunking-form/samples/deprecated/emit-chunk-existing/_config.js b/test/chunking-form/samples/deprecated/emit-chunk-existing/_config.js deleted file mode 100644 index a472740a55a..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk-existing/_config.js +++ /dev/null @@ -1,21 +0,0 @@ -module.exports = { - description: 'allows adding modules already in the graph as entry points', - expectedWarnings: ['DEPRECATED_FEATURE'], - options: { - strictDeprecations: false, - input: { - 'first-main': 'main1', - 'second-main': 'main2' - }, - plugins: { - buildStart() { - // it should be possible to add existing entry points while not overriding their alias - this.emitChunk('main1'); - - // if an existing dependency is added, all references should use the new name - this.emitChunk('dep.js'); - this.emitChunk('dep'); - } - } - } -}; diff --git a/test/chunking-form/samples/deprecated/emit-chunk-existing/_expected/amd/first-main.js b/test/chunking-form/samples/deprecated/emit-chunk-existing/_expected/amd/first-main.js deleted file mode 100644 index fd823ca54c7..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk-existing/_expected/amd/first-main.js +++ /dev/null @@ -1,5 +0,0 @@ -define(['./generated-dep'], function (dep) { 'use strict'; - - console.log('main1', dep); - -}); diff --git a/test/chunking-form/samples/deprecated/emit-chunk-existing/_expected/amd/generated-dep.js b/test/chunking-form/samples/deprecated/emit-chunk-existing/_expected/amd/generated-dep.js deleted file mode 100644 index e14fcf80133..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk-existing/_expected/amd/generated-dep.js +++ /dev/null @@ -1,7 +0,0 @@ -define(function () { 'use strict'; - - var value = 42; - - return value; - -}); diff --git a/test/chunking-form/samples/deprecated/emit-chunk-existing/_expected/amd/second-main.js b/test/chunking-form/samples/deprecated/emit-chunk-existing/_expected/amd/second-main.js deleted file mode 100644 index fd823ca54c7..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk-existing/_expected/amd/second-main.js +++ /dev/null @@ -1,5 +0,0 @@ -define(['./generated-dep'], function (dep) { 'use strict'; - - console.log('main1', dep); - -}); diff --git a/test/chunking-form/samples/deprecated/emit-chunk-existing/_expected/cjs/first-main.js b/test/chunking-form/samples/deprecated/emit-chunk-existing/_expected/cjs/first-main.js deleted file mode 100644 index 54bee5af979..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk-existing/_expected/cjs/first-main.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -var dep = require('./generated-dep.js'); - -console.log('main1', dep); diff --git a/test/chunking-form/samples/deprecated/emit-chunk-existing/_expected/cjs/generated-dep.js b/test/chunking-form/samples/deprecated/emit-chunk-existing/_expected/cjs/generated-dep.js deleted file mode 100644 index 07d7bfe2962..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk-existing/_expected/cjs/generated-dep.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -var value = 42; - -module.exports = value; diff --git a/test/chunking-form/samples/deprecated/emit-chunk-existing/_expected/cjs/second-main.js b/test/chunking-form/samples/deprecated/emit-chunk-existing/_expected/cjs/second-main.js deleted file mode 100644 index 54bee5af979..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk-existing/_expected/cjs/second-main.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -var dep = require('./generated-dep.js'); - -console.log('main1', dep); diff --git a/test/chunking-form/samples/deprecated/emit-chunk-existing/_expected/es/first-main.js b/test/chunking-form/samples/deprecated/emit-chunk-existing/_expected/es/first-main.js deleted file mode 100644 index d77500b5810..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk-existing/_expected/es/first-main.js +++ /dev/null @@ -1,3 +0,0 @@ -import value from './generated-dep.js'; - -console.log('main1', value); diff --git a/test/chunking-form/samples/deprecated/emit-chunk-existing/_expected/es/generated-dep.js b/test/chunking-form/samples/deprecated/emit-chunk-existing/_expected/es/generated-dep.js deleted file mode 100644 index 630536069ae..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk-existing/_expected/es/generated-dep.js +++ /dev/null @@ -1,3 +0,0 @@ -var value = 42; - -export default value; diff --git a/test/chunking-form/samples/deprecated/emit-chunk-existing/_expected/es/second-main.js b/test/chunking-form/samples/deprecated/emit-chunk-existing/_expected/es/second-main.js deleted file mode 100644 index d77500b5810..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk-existing/_expected/es/second-main.js +++ /dev/null @@ -1,3 +0,0 @@ -import value from './generated-dep.js'; - -console.log('main1', value); diff --git a/test/chunking-form/samples/deprecated/emit-chunk-existing/_expected/system/first-main.js b/test/chunking-form/samples/deprecated/emit-chunk-existing/_expected/system/first-main.js deleted file mode 100644 index 80f3e6cfee2..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk-existing/_expected/system/first-main.js +++ /dev/null @@ -1,14 +0,0 @@ -System.register(['./generated-dep.js'], function () { - 'use strict'; - var value; - return { - setters: [function (module) { - value = module.default; - }], - execute: function () { - - console.log('main1', value); - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/emit-chunk-existing/_expected/system/generated-dep.js b/test/chunking-form/samples/deprecated/emit-chunk-existing/_expected/system/generated-dep.js deleted file mode 100644 index 9cb117a6246..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk-existing/_expected/system/generated-dep.js +++ /dev/null @@ -1,10 +0,0 @@ -System.register([], function (exports) { - 'use strict'; - return { - execute: function () { - - var value = exports('default', 42); - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/emit-chunk-existing/_expected/system/second-main.js b/test/chunking-form/samples/deprecated/emit-chunk-existing/_expected/system/second-main.js deleted file mode 100644 index 80f3e6cfee2..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk-existing/_expected/system/second-main.js +++ /dev/null @@ -1,14 +0,0 @@ -System.register(['./generated-dep.js'], function () { - 'use strict'; - var value; - return { - setters: [function (module) { - value = module.default; - }], - execute: function () { - - console.log('main1', value); - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/emit-chunk-existing/main1.js b/test/chunking-form/samples/deprecated/emit-chunk-existing/main1.js deleted file mode 100644 index e384824c6f2..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk-existing/main1.js +++ /dev/null @@ -1,3 +0,0 @@ -import value from './dep.js'; - -console.log('main1', value); diff --git a/test/chunking-form/samples/deprecated/emit-chunk-existing/main2.js b/test/chunking-form/samples/deprecated/emit-chunk-existing/main2.js deleted file mode 100644 index e384824c6f2..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk-existing/main2.js +++ /dev/null @@ -1,3 +0,0 @@ -import value from './dep.js'; - -console.log('main1', value); diff --git a/test/chunking-form/samples/deprecated/emit-chunk-facade/_config.js b/test/chunking-form/samples/deprecated/emit-chunk-facade/_config.js deleted file mode 100644 index 780dd15d602..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk-facade/_config.js +++ /dev/null @@ -1,22 +0,0 @@ -const assert = require('assert'); -let referenceId; - -module.exports = { - description: 'retrieves the correct name of an emitted chunk in case a facade is created', - expectedWarnings: ['DEPRECATED_FEATURE'], - options: { - strictDeprecations: false, - input: 'main', - manualChunks: { - 'build-starter': ['buildStart'] - }, - plugins: { - buildStart() { - referenceId = this.emitChunk('buildStart'); - }, - renderChunk() { - assert.strictEqual(this.getChunkFileName(referenceId), 'generated-buildStart.js'); - } - } - } -}; diff --git a/test/chunking-form/samples/deprecated/emit-chunk-facade/_expected/amd/generated-build-starter.js b/test/chunking-form/samples/deprecated/emit-chunk-facade/_expected/amd/generated-build-starter.js deleted file mode 100644 index 4974a348248..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk-facade/_expected/amd/generated-build-starter.js +++ /dev/null @@ -1,11 +0,0 @@ -define(['exports'], function (exports) { 'use strict'; - - const value = 42; - const otherValue = 43; - - console.log('startBuild', value); - - exports.otherValue = otherValue; - exports.value = value; - -}); diff --git a/test/chunking-form/samples/deprecated/emit-chunk-facade/_expected/amd/generated-buildStart.js b/test/chunking-form/samples/deprecated/emit-chunk-facade/_expected/amd/generated-buildStart.js deleted file mode 100644 index 06143748495..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk-facade/_expected/amd/generated-buildStart.js +++ /dev/null @@ -1,9 +0,0 @@ -define(['exports', './generated-build-starter'], function (exports, buildStarter) { 'use strict'; - - - - exports.buildStartValue = buildStarter.value; - - Object.defineProperty(exports, '__esModule', { value: true }); - -}); diff --git a/test/chunking-form/samples/deprecated/emit-chunk-facade/_expected/amd/main.js b/test/chunking-form/samples/deprecated/emit-chunk-facade/_expected/amd/main.js deleted file mode 100644 index f9191ee8ad4..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk-facade/_expected/amd/main.js +++ /dev/null @@ -1,5 +0,0 @@ -define(['./generated-build-starter'], function (buildStarter) { 'use strict'; - - console.log('main', buildStarter.value, buildStarter.otherValue); - -}); diff --git a/test/chunking-form/samples/deprecated/emit-chunk-facade/_expected/cjs/generated-build-starter.js b/test/chunking-form/samples/deprecated/emit-chunk-facade/_expected/cjs/generated-build-starter.js deleted file mode 100644 index fecf7a3cd4c..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk-facade/_expected/cjs/generated-build-starter.js +++ /dev/null @@ -1,9 +0,0 @@ -'use strict'; - -const value = 42; -const otherValue = 43; - -console.log('startBuild', value); - -exports.otherValue = otherValue; -exports.value = value; diff --git a/test/chunking-form/samples/deprecated/emit-chunk-facade/_expected/cjs/generated-buildStart.js b/test/chunking-form/samples/deprecated/emit-chunk-facade/_expected/cjs/generated-buildStart.js deleted file mode 100644 index 66c05cca4ba..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk-facade/_expected/cjs/generated-buildStart.js +++ /dev/null @@ -1,9 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { value: true }); - -var buildStarter = require('./generated-build-starter.js'); - - - -exports.buildStartValue = buildStarter.value; diff --git a/test/chunking-form/samples/deprecated/emit-chunk-facade/_expected/cjs/main.js b/test/chunking-form/samples/deprecated/emit-chunk-facade/_expected/cjs/main.js deleted file mode 100644 index 666c396846a..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk-facade/_expected/cjs/main.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -var buildStarter = require('./generated-build-starter.js'); - -console.log('main', buildStarter.value, buildStarter.otherValue); diff --git a/test/chunking-form/samples/deprecated/emit-chunk-facade/_expected/es/generated-build-starter.js b/test/chunking-form/samples/deprecated/emit-chunk-facade/_expected/es/generated-build-starter.js deleted file mode 100644 index 43deafdd0be..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk-facade/_expected/es/generated-build-starter.js +++ /dev/null @@ -1,6 +0,0 @@ -const value = 42; -const otherValue = 43; - -console.log('startBuild', value); - -export { otherValue as o, value as v }; diff --git a/test/chunking-form/samples/deprecated/emit-chunk-facade/_expected/es/generated-buildStart.js b/test/chunking-form/samples/deprecated/emit-chunk-facade/_expected/es/generated-buildStart.js deleted file mode 100644 index ffb305eac54..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk-facade/_expected/es/generated-buildStart.js +++ /dev/null @@ -1 +0,0 @@ -export { v as buildStartValue } from './generated-build-starter.js'; diff --git a/test/chunking-form/samples/deprecated/emit-chunk-facade/_expected/es/main.js b/test/chunking-form/samples/deprecated/emit-chunk-facade/_expected/es/main.js deleted file mode 100644 index 28caef9429d..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk-facade/_expected/es/main.js +++ /dev/null @@ -1,3 +0,0 @@ -import { v as value, o as otherValue } from './generated-build-starter.js'; - -console.log('main', value, otherValue); diff --git a/test/chunking-form/samples/deprecated/emit-chunk-facade/_expected/system/generated-build-starter.js b/test/chunking-form/samples/deprecated/emit-chunk-facade/_expected/system/generated-build-starter.js deleted file mode 100644 index 75f69e53e87..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk-facade/_expected/system/generated-build-starter.js +++ /dev/null @@ -1,13 +0,0 @@ -System.register([], function (exports) { - 'use strict'; - return { - execute: function () { - - const value = exports('v', 42); - const otherValue = exports('o', 43); - - console.log('startBuild', value); - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/emit-chunk-facade/_expected/system/generated-buildStart.js b/test/chunking-form/samples/deprecated/emit-chunk-facade/_expected/system/generated-buildStart.js deleted file mode 100644 index b82461c98ab..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk-facade/_expected/system/generated-buildStart.js +++ /dev/null @@ -1,13 +0,0 @@ -System.register(['./generated-build-starter.js'], function (exports) { - 'use strict'; - return { - setters: [function (module) { - exports('buildStartValue', module.v); - }], - execute: function () { - - - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/emit-chunk-facade/_expected/system/main.js b/test/chunking-form/samples/deprecated/emit-chunk-facade/_expected/system/main.js deleted file mode 100644 index 4b52f565751..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk-facade/_expected/system/main.js +++ /dev/null @@ -1,15 +0,0 @@ -System.register(['./generated-build-starter.js'], function () { - 'use strict'; - var value, otherValue; - return { - setters: [function (module) { - value = module.v; - otherValue = module.o; - }], - execute: function () { - - console.log('main', value, otherValue); - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/emit-chunk-facade/buildStart.js b/test/chunking-form/samples/deprecated/emit-chunk-facade/buildStart.js deleted file mode 100644 index 49baee4964e..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk-facade/buildStart.js +++ /dev/null @@ -1,5 +0,0 @@ -import {value} from './dep.js'; - -console.log('startBuild', value); - -export { value as buildStartValue }; diff --git a/test/chunking-form/samples/deprecated/emit-chunk-facade/dep.js b/test/chunking-form/samples/deprecated/emit-chunk-facade/dep.js deleted file mode 100644 index a2db6341120..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk-facade/dep.js +++ /dev/null @@ -1,2 +0,0 @@ -export const value = 42; -export const otherValue = 43; diff --git a/test/chunking-form/samples/deprecated/emit-chunk-facade/main.js b/test/chunking-form/samples/deprecated/emit-chunk-facade/main.js deleted file mode 100644 index df41d56376c..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk-facade/main.js +++ /dev/null @@ -1,3 +0,0 @@ -import { value, otherValue } from './dep'; - -console.log('main', value, otherValue); diff --git a/test/chunking-form/samples/deprecated/emit-chunk-named/_config.js b/test/chunking-form/samples/deprecated/emit-chunk-named/_config.js deleted file mode 100644 index ac8a7dbf46c..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk-named/_config.js +++ /dev/null @@ -1,32 +0,0 @@ -const assert = require('assert'); -let referenceIdBuildStart; -let referenceIdTransform; - -module.exports = { - description: 'allows naming emitted chunks', - expectedWarnings: ['DEPRECATED_FEATURE'], - options: { - strictDeprecations: false, - input: 'main', - plugins: { - buildStart() { - referenceIdBuildStart = this.emitChunk('buildStart', { name: 'nested/build-start' }); - }, - transform(code, id) { - if (id.endsWith('main.js')) { - referenceIdTransform = this.emitChunk('transform', { name: 'nested/transform' }); - } - }, - renderChunk() { - assert.strictEqual( - this.getChunkFileName(referenceIdBuildStart), - 'generated-nested/build-start.js' - ); - assert.strictEqual( - this.getChunkFileName(referenceIdTransform), - 'generated-nested/transform.js' - ); - } - } - } -}; diff --git a/test/chunking-form/samples/deprecated/emit-chunk-named/_expected/amd/generated-dep.js b/test/chunking-form/samples/deprecated/emit-chunk-named/_expected/amd/generated-dep.js deleted file mode 100644 index 5e2f9f02968..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk-named/_expected/amd/generated-dep.js +++ /dev/null @@ -1,7 +0,0 @@ -define(['exports'], function (exports) { 'use strict'; - - var value = 42; - - exports.value = value; - -}); diff --git a/test/chunking-form/samples/deprecated/emit-chunk-named/_expected/amd/generated-nested/build-start.js b/test/chunking-form/samples/deprecated/emit-chunk-named/_expected/amd/generated-nested/build-start.js deleted file mode 100644 index 61df7ab5c80..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk-named/_expected/amd/generated-nested/build-start.js +++ /dev/null @@ -1,5 +0,0 @@ -define(['../generated-dep'], function (dep) { 'use strict'; - - console.log('buildStart', dep.value); - -}); diff --git a/test/chunking-form/samples/deprecated/emit-chunk-named/_expected/amd/generated-nested/transform.js b/test/chunking-form/samples/deprecated/emit-chunk-named/_expected/amd/generated-nested/transform.js deleted file mode 100644 index 83439dd054a..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk-named/_expected/amd/generated-nested/transform.js +++ /dev/null @@ -1,5 +0,0 @@ -define(['../generated-dep'], function (dep) { 'use strict'; - - console.log('transform', dep.value); - -}); diff --git a/test/chunking-form/samples/deprecated/emit-chunk-named/_expected/amd/main.js b/test/chunking-form/samples/deprecated/emit-chunk-named/_expected/amd/main.js deleted file mode 100644 index 764805deda3..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk-named/_expected/amd/main.js +++ /dev/null @@ -1,5 +0,0 @@ -define(['./generated-dep'], function (dep) { 'use strict'; - - console.log('main', dep.value); - -}); diff --git a/test/chunking-form/samples/deprecated/emit-chunk-named/_expected/cjs/generated-dep.js b/test/chunking-form/samples/deprecated/emit-chunk-named/_expected/cjs/generated-dep.js deleted file mode 100644 index 6cec42c9a07..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk-named/_expected/cjs/generated-dep.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -var value = 42; - -exports.value = value; diff --git a/test/chunking-form/samples/deprecated/emit-chunk-named/_expected/cjs/generated-nested/build-start.js b/test/chunking-form/samples/deprecated/emit-chunk-named/_expected/cjs/generated-nested/build-start.js deleted file mode 100644 index 734070e78c9..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk-named/_expected/cjs/generated-nested/build-start.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -var dep = require('../generated-dep.js'); - -console.log('buildStart', dep.value); diff --git a/test/chunking-form/samples/deprecated/emit-chunk-named/_expected/cjs/generated-nested/transform.js b/test/chunking-form/samples/deprecated/emit-chunk-named/_expected/cjs/generated-nested/transform.js deleted file mode 100644 index 4b0f9999aa4..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk-named/_expected/cjs/generated-nested/transform.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -var dep = require('../generated-dep.js'); - -console.log('transform', dep.value); diff --git a/test/chunking-form/samples/deprecated/emit-chunk-named/_expected/cjs/main.js b/test/chunking-form/samples/deprecated/emit-chunk-named/_expected/cjs/main.js deleted file mode 100644 index 4c79b32a701..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk-named/_expected/cjs/main.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -var dep = require('./generated-dep.js'); - -console.log('main', dep.value); diff --git a/test/chunking-form/samples/deprecated/emit-chunk-named/_expected/es/generated-dep.js b/test/chunking-form/samples/deprecated/emit-chunk-named/_expected/es/generated-dep.js deleted file mode 100644 index b7cbe038a73..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk-named/_expected/es/generated-dep.js +++ /dev/null @@ -1,3 +0,0 @@ -var value = 42; - -export { value as v }; diff --git a/test/chunking-form/samples/deprecated/emit-chunk-named/_expected/es/generated-nested/build-start.js b/test/chunking-form/samples/deprecated/emit-chunk-named/_expected/es/generated-nested/build-start.js deleted file mode 100644 index 8b7f3766098..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk-named/_expected/es/generated-nested/build-start.js +++ /dev/null @@ -1,3 +0,0 @@ -import { v as value } from '../generated-dep.js'; - -console.log('buildStart', value); diff --git a/test/chunking-form/samples/deprecated/emit-chunk-named/_expected/es/generated-nested/transform.js b/test/chunking-form/samples/deprecated/emit-chunk-named/_expected/es/generated-nested/transform.js deleted file mode 100644 index 61ce66361c3..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk-named/_expected/es/generated-nested/transform.js +++ /dev/null @@ -1,3 +0,0 @@ -import { v as value } from '../generated-dep.js'; - -console.log('transform', value); diff --git a/test/chunking-form/samples/deprecated/emit-chunk-named/_expected/es/main.js b/test/chunking-form/samples/deprecated/emit-chunk-named/_expected/es/main.js deleted file mode 100644 index da4e855f39a..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk-named/_expected/es/main.js +++ /dev/null @@ -1,3 +0,0 @@ -import { v as value } from './generated-dep.js'; - -console.log('main', value); diff --git a/test/chunking-form/samples/deprecated/emit-chunk-named/_expected/system/generated-dep.js b/test/chunking-form/samples/deprecated/emit-chunk-named/_expected/system/generated-dep.js deleted file mode 100644 index e69dcc529da..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk-named/_expected/system/generated-dep.js +++ /dev/null @@ -1,10 +0,0 @@ -System.register([], function (exports) { - 'use strict'; - return { - execute: function () { - - var value = exports('v', 42); - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/emit-chunk-named/_expected/system/generated-nested/build-start.js b/test/chunking-form/samples/deprecated/emit-chunk-named/_expected/system/generated-nested/build-start.js deleted file mode 100644 index a3b2c2eb9be..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk-named/_expected/system/generated-nested/build-start.js +++ /dev/null @@ -1,14 +0,0 @@ -System.register(['../generated-dep.js'], function () { - 'use strict'; - var value; - return { - setters: [function (module) { - value = module.v; - }], - execute: function () { - - console.log('buildStart', value); - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/emit-chunk-named/_expected/system/generated-nested/transform.js b/test/chunking-form/samples/deprecated/emit-chunk-named/_expected/system/generated-nested/transform.js deleted file mode 100644 index 5f803e25ba9..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk-named/_expected/system/generated-nested/transform.js +++ /dev/null @@ -1,14 +0,0 @@ -System.register(['../generated-dep.js'], function () { - 'use strict'; - var value; - return { - setters: [function (module) { - value = module.v; - }], - execute: function () { - - console.log('transform', value); - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/emit-chunk-named/_expected/system/main.js b/test/chunking-form/samples/deprecated/emit-chunk-named/_expected/system/main.js deleted file mode 100644 index 13eec5478ac..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk-named/_expected/system/main.js +++ /dev/null @@ -1,14 +0,0 @@ -System.register(['./generated-dep.js'], function () { - 'use strict'; - var value; - return { - setters: [function (module) { - value = module.v; - }], - execute: function () { - - console.log('main', value); - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/emit-chunk-named/buildStart.js b/test/chunking-form/samples/deprecated/emit-chunk-named/buildStart.js deleted file mode 100644 index 373c51ace53..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk-named/buildStart.js +++ /dev/null @@ -1,3 +0,0 @@ -import value from './dep.js'; - -console.log('buildStart', value); diff --git a/test/chunking-form/samples/deprecated/emit-chunk-named/main.js b/test/chunking-form/samples/deprecated/emit-chunk-named/main.js deleted file mode 100644 index 4a9b3a3f405..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk-named/main.js +++ /dev/null @@ -1,3 +0,0 @@ -import value from './dep.js'; - -console.log('main', value); diff --git a/test/chunking-form/samples/deprecated/emit-chunk-named/transform.js b/test/chunking-form/samples/deprecated/emit-chunk-named/transform.js deleted file mode 100644 index 6eed294c62c..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk-named/transform.js +++ /dev/null @@ -1,3 +0,0 @@ -import value from './dep.js'; - -console.log('transform', value); diff --git a/test/chunking-form/samples/deprecated/emit-chunk-worker/_config.js b/test/chunking-form/samples/deprecated/emit-chunk-worker/_config.js deleted file mode 100644 index 5e1a2ba5b27..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk-worker/_config.js +++ /dev/null @@ -1,56 +0,0 @@ -const path = require('path'); - -let workerId; -let proxyId; - -module.exports = { - description: 'allows adding additional chunks to be used in workers', - expectedWarnings: ['DEPRECATED_FEATURE'], - options: { - strictDeprecations: false, - input: 'main', - output: { - chunkFileNames: 'chunks/[name].js' - }, - plugins: { - load(id) { - if (id === 'merged' || id === 'nested') { - if (!workerId) { - workerId = this.emitChunk('worker'); - proxyId = this.emitChunk('worker-proxy'); - } - return ` -export const getWorkerMessage = () => new Promise(resolve => { - const worker = new Worker(import.meta.ROLLUP_CHUNK_URL_${proxyId}); - worker.onmessage = resolve; -});`; - } - if (id === 'worker-proxy') { - return `PLACEHOLDER(import.meta.ROLLUP_CHUNK_URL_${workerId})`; - } - }, - renderChunk(code, chunk, options) { - if (chunk.facadeModuleId === 'worker-proxy') { - const chunkFileName = `./${path.relative( - path.dirname(chunk.fileName), - this.getChunkFileName(workerId) - )}`; - if (options.format === 'system') { - return `importScripts('../../../../../../../node_modules/systemjs/dist/system.js'); -System.import('${chunkFileName}');`; - } - if (options.format === 'amd') { - return `importScripts('../../../../../../../node_modules/requirejs/require.js'); -requirejs(['${chunkFileName}']);`; - } - } - }, - resolveId(id) { - if (id === 'merged' || id === 'nested' || id === 'worker-proxy') { - return id; - } - return null; - } - } - } -}; diff --git a/test/chunking-form/samples/deprecated/emit-chunk-worker/_expected/amd/chunks/nested.js b/test/chunking-form/samples/deprecated/emit-chunk-worker/_expected/amd/chunks/nested.js deleted file mode 100644 index deefacd2395..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk-worker/_expected/amd/chunks/nested.js +++ /dev/null @@ -1,10 +0,0 @@ -define(['require', 'exports'], function (require, exports) { 'use strict'; - - const getWorkerMessage = () => new Promise(resolve => { - const worker = new Worker(new URL(require.toUrl('./worker-proxy.js'), document.baseURI).href); - worker.onmessage = resolve; - }); - - exports.getWorkerMessage = getWorkerMessage; - -}); diff --git a/test/chunking-form/samples/deprecated/emit-chunk-worker/_expected/amd/chunks/shared.js b/test/chunking-form/samples/deprecated/emit-chunk-worker/_expected/amd/chunks/shared.js deleted file mode 100644 index b188047d8e0..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk-worker/_expected/amd/chunks/shared.js +++ /dev/null @@ -1,7 +0,0 @@ -define(['exports'], function (exports) { 'use strict'; - - const shared = 'shared'; - - exports.shared = shared; - -}); diff --git a/test/chunking-form/samples/deprecated/emit-chunk-worker/_expected/amd/chunks/worker-proxy.js b/test/chunking-form/samples/deprecated/emit-chunk-worker/_expected/amd/chunks/worker-proxy.js deleted file mode 100644 index 4f2962c005b..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk-worker/_expected/amd/chunks/worker-proxy.js +++ /dev/null @@ -1,2 +0,0 @@ -importScripts('../../../../../../../node_modules/requirejs/require.js'); -requirejs(['./worker.js']); diff --git a/test/chunking-form/samples/deprecated/emit-chunk-worker/_expected/amd/chunks/worker.js b/test/chunking-form/samples/deprecated/emit-chunk-worker/_expected/amd/chunks/worker.js deleted file mode 100644 index de59be73c36..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk-worker/_expected/amd/chunks/worker.js +++ /dev/null @@ -1,5 +0,0 @@ -define(['./shared'], function (shared) { 'use strict'; - - postMessage(`from worker: ${shared.shared}`); - -}); diff --git a/test/chunking-form/samples/deprecated/emit-chunk-worker/_expected/amd/main.js b/test/chunking-form/samples/deprecated/emit-chunk-worker/_expected/amd/main.js deleted file mode 100644 index cc2e4dd2ca3..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk-worker/_expected/amd/main.js +++ /dev/null @@ -1,15 +0,0 @@ -define(['require', './chunks/shared'], function (require, shared) { 'use strict'; - - const getWorkerMessage = () => new Promise(resolve => { - const worker = new Worker(new URL(require.toUrl('./chunks/worker-proxy.js'), document.baseURI).href); - worker.onmessage = resolve; - }); - - document.body.innerHTML += `

main: ${shared.shared}

`; - getWorkerMessage().then(message => (document.body.innerHTML += `

1: ${message.data}

`)); - - new Promise(function (resolve, reject) { require(['./chunks/nested'], resolve, reject) }) - .then(result => result.getWorkerMessage()) - .then(message => (document.body.innerHTML += `

2: ${message.data}

`)); - -}); diff --git a/test/chunking-form/samples/deprecated/emit-chunk-worker/_expected/cjs/chunks/nested.js b/test/chunking-form/samples/deprecated/emit-chunk-worker/_expected/cjs/chunks/nested.js deleted file mode 100644 index b1544deca5e..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk-worker/_expected/cjs/chunks/nested.js +++ /dev/null @@ -1,8 +0,0 @@ -'use strict'; - -const getWorkerMessage = () => new Promise(resolve => { - const worker = new Worker((typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __dirname + '/worker-proxy.js').href : new URL('worker-proxy.js', document.currentScript && document.currentScript.src || document.baseURI).href)); - worker.onmessage = resolve; -}); - -exports.getWorkerMessage = getWorkerMessage; diff --git a/test/chunking-form/samples/deprecated/emit-chunk-worker/_expected/cjs/chunks/shared.js b/test/chunking-form/samples/deprecated/emit-chunk-worker/_expected/cjs/chunks/shared.js deleted file mode 100644 index e2dc6ecb8ef..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk-worker/_expected/cjs/chunks/shared.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -const shared = 'shared'; - -exports.shared = shared; diff --git a/test/chunking-form/samples/deprecated/emit-chunk-worker/_expected/cjs/chunks/worker-proxy.js b/test/chunking-form/samples/deprecated/emit-chunk-worker/_expected/cjs/chunks/worker-proxy.js deleted file mode 100644 index 0171ef8895e..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk-worker/_expected/cjs/chunks/worker-proxy.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -PLACEHOLDER((typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __dirname + '/worker.js').href : new URL('worker.js', document.currentScript && document.currentScript.src || document.baseURI).href)); diff --git a/test/chunking-form/samples/deprecated/emit-chunk-worker/_expected/cjs/chunks/worker.js b/test/chunking-form/samples/deprecated/emit-chunk-worker/_expected/cjs/chunks/worker.js deleted file mode 100644 index c12a25e95f5..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk-worker/_expected/cjs/chunks/worker.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -var shared = require('./shared.js'); - -postMessage(`from worker: ${shared.shared}`); diff --git a/test/chunking-form/samples/deprecated/emit-chunk-worker/_expected/cjs/main.js b/test/chunking-form/samples/deprecated/emit-chunk-worker/_expected/cjs/main.js deleted file mode 100644 index 1d9811d9f8b..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk-worker/_expected/cjs/main.js +++ /dev/null @@ -1,15 +0,0 @@ -'use strict'; - -var shared = require('./chunks/shared.js'); - -const getWorkerMessage = () => new Promise(resolve => { - const worker = new Worker((typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __dirname + '/chunks/worker-proxy.js').href : new URL('chunks/worker-proxy.js', document.currentScript && document.currentScript.src || document.baseURI).href)); - worker.onmessage = resolve; -}); - -document.body.innerHTML += `

main: ${shared.shared}

`; -getWorkerMessage().then(message => (document.body.innerHTML += `

1: ${message.data}

`)); - -Promise.resolve().then(function () { return require('./chunks/nested.js'); }) - .then(result => result.getWorkerMessage()) - .then(message => (document.body.innerHTML += `

2: ${message.data}

`)); diff --git a/test/chunking-form/samples/deprecated/emit-chunk-worker/_expected/es/chunks/nested.js b/test/chunking-form/samples/deprecated/emit-chunk-worker/_expected/es/chunks/nested.js deleted file mode 100644 index 13c379e9742..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk-worker/_expected/es/chunks/nested.js +++ /dev/null @@ -1,6 +0,0 @@ -const getWorkerMessage = () => new Promise(resolve => { - const worker = new Worker(new URL('worker-proxy.js', import.meta.url).href); - worker.onmessage = resolve; -}); - -export { getWorkerMessage }; diff --git a/test/chunking-form/samples/deprecated/emit-chunk-worker/_expected/es/chunks/shared.js b/test/chunking-form/samples/deprecated/emit-chunk-worker/_expected/es/chunks/shared.js deleted file mode 100644 index 464379ccc95..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk-worker/_expected/es/chunks/shared.js +++ /dev/null @@ -1,3 +0,0 @@ -const shared = 'shared'; - -export { shared as s }; diff --git a/test/chunking-form/samples/deprecated/emit-chunk-worker/_expected/es/chunks/worker-proxy.js b/test/chunking-form/samples/deprecated/emit-chunk-worker/_expected/es/chunks/worker-proxy.js deleted file mode 100644 index 88e9531a22e..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk-worker/_expected/es/chunks/worker-proxy.js +++ /dev/null @@ -1 +0,0 @@ -PLACEHOLDER(new URL('worker.js', import.meta.url).href); diff --git a/test/chunking-form/samples/deprecated/emit-chunk-worker/_expected/es/chunks/worker.js b/test/chunking-form/samples/deprecated/emit-chunk-worker/_expected/es/chunks/worker.js deleted file mode 100644 index 376c9cd1a99..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk-worker/_expected/es/chunks/worker.js +++ /dev/null @@ -1,3 +0,0 @@ -import { s as shared } from './shared.js'; - -postMessage(`from worker: ${shared}`); diff --git a/test/chunking-form/samples/deprecated/emit-chunk-worker/_expected/es/main.js b/test/chunking-form/samples/deprecated/emit-chunk-worker/_expected/es/main.js deleted file mode 100644 index 19521653160..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk-worker/_expected/es/main.js +++ /dev/null @@ -1,13 +0,0 @@ -import { s as shared } from './chunks/shared.js'; - -const getWorkerMessage = () => new Promise(resolve => { - const worker = new Worker(new URL('chunks/worker-proxy.js', import.meta.url).href); - worker.onmessage = resolve; -}); - -document.body.innerHTML += `

main: ${shared}

`; -getWorkerMessage().then(message => (document.body.innerHTML += `

1: ${message.data}

`)); - -import('./chunks/nested.js') - .then(result => result.getWorkerMessage()) - .then(message => (document.body.innerHTML += `

2: ${message.data}

`)); diff --git a/test/chunking-form/samples/deprecated/emit-chunk-worker/_expected/system/chunks/nested.js b/test/chunking-form/samples/deprecated/emit-chunk-worker/_expected/system/chunks/nested.js deleted file mode 100644 index 1c41e726447..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk-worker/_expected/system/chunks/nested.js +++ /dev/null @@ -1,13 +0,0 @@ -System.register([], function (exports, module) { - 'use strict'; - return { - execute: function () { - - const getWorkerMessage = exports('getWorkerMessage', () => new Promise(resolve => { - const worker = new Worker(new URL('worker-proxy.js', module.meta.url).href); - worker.onmessage = resolve; - })); - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/emit-chunk-worker/_expected/system/chunks/shared.js b/test/chunking-form/samples/deprecated/emit-chunk-worker/_expected/system/chunks/shared.js deleted file mode 100644 index 48be08070fc..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk-worker/_expected/system/chunks/shared.js +++ /dev/null @@ -1,10 +0,0 @@ -System.register([], function (exports) { - 'use strict'; - return { - execute: function () { - - const shared = exports('s', 'shared'); - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/emit-chunk-worker/_expected/system/chunks/worker-proxy.js b/test/chunking-form/samples/deprecated/emit-chunk-worker/_expected/system/chunks/worker-proxy.js deleted file mode 100644 index 44eb3bb9210..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk-worker/_expected/system/chunks/worker-proxy.js +++ /dev/null @@ -1,2 +0,0 @@ -importScripts('../../../../../../../node_modules/systemjs/dist/system.js'); -System.import('./worker.js'); diff --git a/test/chunking-form/samples/deprecated/emit-chunk-worker/_expected/system/chunks/worker.js b/test/chunking-form/samples/deprecated/emit-chunk-worker/_expected/system/chunks/worker.js deleted file mode 100644 index 1013f55b394..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk-worker/_expected/system/chunks/worker.js +++ /dev/null @@ -1,14 +0,0 @@ -System.register(['./shared.js'], function () { - 'use strict'; - var shared; - return { - setters: [function (module) { - shared = module.s; - }], - execute: function () { - - postMessage(`from worker: ${shared}`); - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/emit-chunk-worker/_expected/system/main.js b/test/chunking-form/samples/deprecated/emit-chunk-worker/_expected/system/main.js deleted file mode 100644 index 4ee1bb4ab60..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk-worker/_expected/system/main.js +++ /dev/null @@ -1,24 +0,0 @@ -System.register(['./chunks/shared.js'], function (exports, module) { - 'use strict'; - var shared; - return { - setters: [function (module) { - shared = module.s; - }], - execute: function () { - - const getWorkerMessage = () => new Promise(resolve => { - const worker = new Worker(new URL('chunks/worker-proxy.js', module.meta.url).href); - worker.onmessage = resolve; - }); - - document.body.innerHTML += `

main: ${shared}

`; - getWorkerMessage().then(message => (document.body.innerHTML += `

1: ${message.data}

`)); - - module.import('./chunks/nested.js') - .then(result => result.getWorkerMessage()) - .then(message => (document.body.innerHTML += `

2: ${message.data}

`)); - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/emit-chunk-worker/index-amd.html b/test/chunking-form/samples/deprecated/emit-chunk-worker/index-amd.html deleted file mode 100644 index 476b9ce3df1..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk-worker/index-amd.html +++ /dev/null @@ -1,10 +0,0 @@ - - - - - AMD - - - - - diff --git a/test/chunking-form/samples/deprecated/emit-chunk-worker/index-system.html b/test/chunking-form/samples/deprecated/emit-chunk-worker/index-system.html deleted file mode 100644 index 96c687c1eb7..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk-worker/index-system.html +++ /dev/null @@ -1,11 +0,0 @@ - - - - - SystemJS - - - - - - diff --git a/test/chunking-form/samples/deprecated/emit-chunk-worker/main.js b/test/chunking-form/samples/deprecated/emit-chunk-worker/main.js deleted file mode 100644 index 4c03186f74e..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk-worker/main.js +++ /dev/null @@ -1,9 +0,0 @@ -import { getWorkerMessage } from 'merged'; -import { shared } from './shared'; - -document.body.innerHTML += `

main: ${shared}

`; -getWorkerMessage().then(message => (document.body.innerHTML += `

1: ${message.data}

`)); - -import('nested') - .then(result => result.getWorkerMessage()) - .then(message => (document.body.innerHTML += `

2: ${message.data}

`)); diff --git a/test/chunking-form/samples/deprecated/emit-chunk-worker/shared.js b/test/chunking-form/samples/deprecated/emit-chunk-worker/shared.js deleted file mode 100644 index cd35843de7a..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk-worker/shared.js +++ /dev/null @@ -1 +0,0 @@ -export const shared = 'shared'; diff --git a/test/chunking-form/samples/deprecated/emit-chunk-worker/worker.js b/test/chunking-form/samples/deprecated/emit-chunk-worker/worker.js deleted file mode 100644 index 824aa26d2e0..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk-worker/worker.js +++ /dev/null @@ -1,3 +0,0 @@ -import {shared} from './shared'; - -postMessage(`from worker: ${shared}`); diff --git a/test/chunking-form/samples/deprecated/emit-chunk-worklet/_config.js b/test/chunking-form/samples/deprecated/emit-chunk-worklet/_config.js deleted file mode 100644 index 5c77d304c82..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk-worklet/_config.js +++ /dev/null @@ -1,30 +0,0 @@ -const REGISTER_WORKLET = 'register-paint-worklet:'; - -module.exports = { - description: 'allows adding additional chunks to be used in worklets', - expectedWarnings: ['DEPRECATED_FEATURE'], - options: { - strictDeprecations: false, - input: 'main', - output: { - chunkFileNames: 'chunks/[name].js' - }, - plugins: { - load(id) { - if (id.startsWith(REGISTER_WORKLET)) { - return `CSS.paintWorklet.addModule(import.meta.ROLLUP_CHUNK_URL_${this.emitChunk( - id.slice(REGISTER_WORKLET.length) - )});`; - } - }, - resolveId(id, importee) { - if (id.startsWith(REGISTER_WORKLET)) { - return this.resolve(id.slice(REGISTER_WORKLET.length), importee).then( - resolvedId => REGISTER_WORKLET + resolvedId.id - ); - } - return null; - } - } - } -}; diff --git a/test/chunking-form/samples/deprecated/emit-chunk-worklet/_expected/amd/chunks/shared.js b/test/chunking-form/samples/deprecated/emit-chunk-worklet/_expected/amd/chunks/shared.js deleted file mode 100644 index 931cd5869bc..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk-worklet/_expected/amd/chunks/shared.js +++ /dev/null @@ -1,9 +0,0 @@ -define(['exports'], function (exports) { 'use strict'; - - const color = 'greenyellow'; - const size = 6; - - exports.color = color; - exports.size = size; - -}); diff --git a/test/chunking-form/samples/deprecated/emit-chunk-worklet/_expected/amd/chunks/worklet.js b/test/chunking-form/samples/deprecated/emit-chunk-worklet/_expected/amd/chunks/worklet.js deleted file mode 100644 index f96f283ad52..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk-worklet/_expected/amd/chunks/worklet.js +++ /dev/null @@ -1,17 +0,0 @@ -define(['./shared'], function (shared) { 'use strict'; - - registerPaint( - 'vertical-lines', - class { - paint(ctx, geom) { - for (let x = 0; x < geom.width / shared.size; x++) { - ctx.beginPath(); - ctx.fillStyle = shared.color; - ctx.rect(x * shared.size, 0, 2, geom.height); - ctx.fill(); - } - } - } - ); - -}); diff --git a/test/chunking-form/samples/deprecated/emit-chunk-worklet/_expected/amd/main.js b/test/chunking-form/samples/deprecated/emit-chunk-worklet/_expected/amd/main.js deleted file mode 100644 index bf73a6f1543..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk-worklet/_expected/amd/main.js +++ /dev/null @@ -1,7 +0,0 @@ -define(['require', './chunks/shared'], function (require, shared) { 'use strict'; - - CSS.paintWorklet.addModule(new URL(require.toUrl('./chunks/worklet.js'), document.baseURI).href); - - document.body.innerHTML += `

color: ${shared.color}, size: ${shared.size}

`; - -}); diff --git a/test/chunking-form/samples/deprecated/emit-chunk-worklet/_expected/cjs/chunks/shared.js b/test/chunking-form/samples/deprecated/emit-chunk-worklet/_expected/cjs/chunks/shared.js deleted file mode 100644 index baee02947f7..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk-worklet/_expected/cjs/chunks/shared.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -const color = 'greenyellow'; -const size = 6; - -exports.color = color; -exports.size = size; diff --git a/test/chunking-form/samples/deprecated/emit-chunk-worklet/_expected/cjs/chunks/worklet.js b/test/chunking-form/samples/deprecated/emit-chunk-worklet/_expected/cjs/chunks/worklet.js deleted file mode 100644 index 55c46f65372..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk-worklet/_expected/cjs/chunks/worklet.js +++ /dev/null @@ -1,17 +0,0 @@ -'use strict'; - -var shared = require('./shared.js'); - -registerPaint( - 'vertical-lines', - class { - paint(ctx, geom) { - for (let x = 0; x < geom.width / shared.size; x++) { - ctx.beginPath(); - ctx.fillStyle = shared.color; - ctx.rect(x * shared.size, 0, 2, geom.height); - ctx.fill(); - } - } - } -); diff --git a/test/chunking-form/samples/deprecated/emit-chunk-worklet/_expected/cjs/main.js b/test/chunking-form/samples/deprecated/emit-chunk-worklet/_expected/cjs/main.js deleted file mode 100644 index 6ba79bfb0e6..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk-worklet/_expected/cjs/main.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -var shared = require('./chunks/shared.js'); - -CSS.paintWorklet.addModule((typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __dirname + '/chunks/worklet.js').href : new URL('chunks/worklet.js', document.currentScript && document.currentScript.src || document.baseURI).href)); - -document.body.innerHTML += `

color: ${shared.color}, size: ${shared.size}

`; diff --git a/test/chunking-form/samples/deprecated/emit-chunk-worklet/_expected/es/chunks/shared.js b/test/chunking-form/samples/deprecated/emit-chunk-worklet/_expected/es/chunks/shared.js deleted file mode 100644 index cce16151201..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk-worklet/_expected/es/chunks/shared.js +++ /dev/null @@ -1,4 +0,0 @@ -const color = 'greenyellow'; -const size = 6; - -export { color as c, size as s }; diff --git a/test/chunking-form/samples/deprecated/emit-chunk-worklet/_expected/es/chunks/worklet.js b/test/chunking-form/samples/deprecated/emit-chunk-worklet/_expected/es/chunks/worklet.js deleted file mode 100644 index 7ae737842e0..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk-worklet/_expected/es/chunks/worklet.js +++ /dev/null @@ -1,15 +0,0 @@ -import { s as size, c as color } from './shared.js'; - -registerPaint( - 'vertical-lines', - class { - paint(ctx, geom) { - for (let x = 0; x < geom.width / size; x++) { - ctx.beginPath(); - ctx.fillStyle = color; - ctx.rect(x * size, 0, 2, geom.height); - ctx.fill(); - } - } - } -); diff --git a/test/chunking-form/samples/deprecated/emit-chunk-worklet/_expected/es/main.js b/test/chunking-form/samples/deprecated/emit-chunk-worklet/_expected/es/main.js deleted file mode 100644 index fc0e00f5183..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk-worklet/_expected/es/main.js +++ /dev/null @@ -1,5 +0,0 @@ -import { c as color, s as size } from './chunks/shared.js'; - -CSS.paintWorklet.addModule(new URL('chunks/worklet.js', import.meta.url).href); - -document.body.innerHTML += `

color: ${color}, size: ${size}

`; diff --git a/test/chunking-form/samples/deprecated/emit-chunk-worklet/_expected/system/chunks/shared.js b/test/chunking-form/samples/deprecated/emit-chunk-worklet/_expected/system/chunks/shared.js deleted file mode 100644 index f348ef3f487..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk-worklet/_expected/system/chunks/shared.js +++ /dev/null @@ -1,11 +0,0 @@ -System.register([], function (exports) { - 'use strict'; - return { - execute: function () { - - const color = exports('c', 'greenyellow'); - const size = exports('s', 6); - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/emit-chunk-worklet/_expected/system/chunks/worklet.js b/test/chunking-form/samples/deprecated/emit-chunk-worklet/_expected/system/chunks/worklet.js deleted file mode 100644 index 9cb6055973e..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk-worklet/_expected/system/chunks/worklet.js +++ /dev/null @@ -1,27 +0,0 @@ -System.register(['./shared.js'], function () { - 'use strict'; - var size, color; - return { - setters: [function (module) { - size = module.s; - color = module.c; - }], - execute: function () { - - registerPaint( - 'vertical-lines', - class { - paint(ctx, geom) { - for (let x = 0; x < geom.width / size; x++) { - ctx.beginPath(); - ctx.fillStyle = color; - ctx.rect(x * size, 0, 2, geom.height); - ctx.fill(); - } - } - } - ); - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/emit-chunk-worklet/_expected/system/main.js b/test/chunking-form/samples/deprecated/emit-chunk-worklet/_expected/system/main.js deleted file mode 100644 index 3165374294e..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk-worklet/_expected/system/main.js +++ /dev/null @@ -1,17 +0,0 @@ -System.register(['./chunks/shared.js'], function (exports, module) { - 'use strict'; - var color, size; - return { - setters: [function (module) { - color = module.c; - size = module.s; - }], - execute: function () { - - CSS.paintWorklet.addModule(new URL('chunks/worklet.js', module.meta.url).href); - - document.body.innerHTML += `

color: ${color}, size: ${size}

`; - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/emit-chunk-worklet/index-es.html b/test/chunking-form/samples/deprecated/emit-chunk-worklet/index-es.html deleted file mode 100644 index d458b71c059..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk-worklet/index-es.html +++ /dev/null @@ -1,10 +0,0 @@ - - - - - ES - - - - - diff --git a/test/chunking-form/samples/deprecated/emit-chunk-worklet/main.js b/test/chunking-form/samples/deprecated/emit-chunk-worklet/main.js deleted file mode 100644 index 60bad6751e8..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk-worklet/main.js +++ /dev/null @@ -1,4 +0,0 @@ -import 'register-paint-worklet:./worklet.js'; -import { color, size } from './shared'; - -document.body.innerHTML += `

color: ${color}, size: ${size}

`; diff --git a/test/chunking-form/samples/deprecated/emit-chunk-worklet/shared.js b/test/chunking-form/samples/deprecated/emit-chunk-worklet/shared.js deleted file mode 100644 index 5a94b80cdd8..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk-worklet/shared.js +++ /dev/null @@ -1,2 +0,0 @@ -export const color = 'greenyellow'; -export const size = 6; diff --git a/test/chunking-form/samples/deprecated/emit-chunk-worklet/worklet.js b/test/chunking-form/samples/deprecated/emit-chunk-worklet/worklet.js deleted file mode 100644 index 2274b010e02..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk-worklet/worklet.js +++ /dev/null @@ -1,15 +0,0 @@ -import { color, size } from './shared'; - -registerPaint( - 'vertical-lines', - class { - paint(ctx, geom) { - for (let x = 0; x < geom.width / size; x++) { - ctx.beginPath(); - ctx.fillStyle = color; - ctx.rect(x * size, 0, 2, geom.height); - ctx.fill(); - } - } - } -); diff --git a/test/chunking-form/samples/deprecated/emit-chunk/_config.js b/test/chunking-form/samples/deprecated/emit-chunk/_config.js deleted file mode 100644 index f99cdb68e91..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk/_config.js +++ /dev/null @@ -1,19 +0,0 @@ -const assert = require('assert'); -let referenceId; - -module.exports = { - description: 'allows adding additional chunks and retrieving their file name', - expectedWarnings: ['DEPRECATED_FEATURE'], - options: { - strictDeprecations: false, - input: 'main', - plugins: { - buildStart() { - referenceId = this.emitChunk('buildStart'); - }, - renderChunk() { - assert.strictEqual(this.getChunkFileName(referenceId), 'generated-buildStart.js'); - } - } - } -}; diff --git a/test/chunking-form/samples/deprecated/emit-chunk/_expected/amd/generated-buildStart.js b/test/chunking-form/samples/deprecated/emit-chunk/_expected/amd/generated-buildStart.js deleted file mode 100644 index 05dda0e01f3..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk/_expected/amd/generated-buildStart.js +++ /dev/null @@ -1,5 +0,0 @@ -define(['./generated-dep'], function (dep) { 'use strict'; - - console.log('startBuild', dep.value); - -}); diff --git a/test/chunking-form/samples/deprecated/emit-chunk/_expected/amd/generated-dep.js b/test/chunking-form/samples/deprecated/emit-chunk/_expected/amd/generated-dep.js deleted file mode 100644 index 5e2f9f02968..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk/_expected/amd/generated-dep.js +++ /dev/null @@ -1,7 +0,0 @@ -define(['exports'], function (exports) { 'use strict'; - - var value = 42; - - exports.value = value; - -}); diff --git a/test/chunking-form/samples/deprecated/emit-chunk/_expected/amd/main.js b/test/chunking-form/samples/deprecated/emit-chunk/_expected/amd/main.js deleted file mode 100644 index 764805deda3..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk/_expected/amd/main.js +++ /dev/null @@ -1,5 +0,0 @@ -define(['./generated-dep'], function (dep) { 'use strict'; - - console.log('main', dep.value); - -}); diff --git a/test/chunking-form/samples/deprecated/emit-chunk/_expected/cjs/generated-buildStart.js b/test/chunking-form/samples/deprecated/emit-chunk/_expected/cjs/generated-buildStart.js deleted file mode 100644 index cfa8c788f1d..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk/_expected/cjs/generated-buildStart.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -var dep = require('./generated-dep.js'); - -console.log('startBuild', dep.value); diff --git a/test/chunking-form/samples/deprecated/emit-chunk/_expected/cjs/generated-dep.js b/test/chunking-form/samples/deprecated/emit-chunk/_expected/cjs/generated-dep.js deleted file mode 100644 index 6cec42c9a07..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk/_expected/cjs/generated-dep.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -var value = 42; - -exports.value = value; diff --git a/test/chunking-form/samples/deprecated/emit-chunk/_expected/cjs/main.js b/test/chunking-form/samples/deprecated/emit-chunk/_expected/cjs/main.js deleted file mode 100644 index 4c79b32a701..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk/_expected/cjs/main.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -var dep = require('./generated-dep.js'); - -console.log('main', dep.value); diff --git a/test/chunking-form/samples/deprecated/emit-chunk/_expected/es/generated-buildStart.js b/test/chunking-form/samples/deprecated/emit-chunk/_expected/es/generated-buildStart.js deleted file mode 100644 index fbe237d2ce7..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk/_expected/es/generated-buildStart.js +++ /dev/null @@ -1,3 +0,0 @@ -import { v as value } from './generated-dep.js'; - -console.log('startBuild', value); diff --git a/test/chunking-form/samples/deprecated/emit-chunk/_expected/es/generated-dep.js b/test/chunking-form/samples/deprecated/emit-chunk/_expected/es/generated-dep.js deleted file mode 100644 index b7cbe038a73..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk/_expected/es/generated-dep.js +++ /dev/null @@ -1,3 +0,0 @@ -var value = 42; - -export { value as v }; diff --git a/test/chunking-form/samples/deprecated/emit-chunk/_expected/es/main.js b/test/chunking-form/samples/deprecated/emit-chunk/_expected/es/main.js deleted file mode 100644 index da4e855f39a..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk/_expected/es/main.js +++ /dev/null @@ -1,3 +0,0 @@ -import { v as value } from './generated-dep.js'; - -console.log('main', value); diff --git a/test/chunking-form/samples/deprecated/emit-chunk/_expected/system/generated-buildStart.js b/test/chunking-form/samples/deprecated/emit-chunk/_expected/system/generated-buildStart.js deleted file mode 100644 index 08465151e63..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk/_expected/system/generated-buildStart.js +++ /dev/null @@ -1,14 +0,0 @@ -System.register(['./generated-dep.js'], function () { - 'use strict'; - var value; - return { - setters: [function (module) { - value = module.v; - }], - execute: function () { - - console.log('startBuild', value); - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/emit-chunk/_expected/system/generated-dep.js b/test/chunking-form/samples/deprecated/emit-chunk/_expected/system/generated-dep.js deleted file mode 100644 index e69dcc529da..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk/_expected/system/generated-dep.js +++ /dev/null @@ -1,10 +0,0 @@ -System.register([], function (exports) { - 'use strict'; - return { - execute: function () { - - var value = exports('v', 42); - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/emit-chunk/_expected/system/main.js b/test/chunking-form/samples/deprecated/emit-chunk/_expected/system/main.js deleted file mode 100644 index 13eec5478ac..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk/_expected/system/main.js +++ /dev/null @@ -1,14 +0,0 @@ -System.register(['./generated-dep.js'], function () { - 'use strict'; - var value; - return { - setters: [function (module) { - value = module.v; - }], - execute: function () { - - console.log('main', value); - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/emit-chunk/buildStart.js b/test/chunking-form/samples/deprecated/emit-chunk/buildStart.js deleted file mode 100644 index f9b1b414da5..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk/buildStart.js +++ /dev/null @@ -1,3 +0,0 @@ -import value from './dep.js'; - -console.log('startBuild', value); diff --git a/test/chunking-form/samples/deprecated/emit-chunk/main.js b/test/chunking-form/samples/deprecated/emit-chunk/main.js deleted file mode 100644 index 4a9b3a3f405..00000000000 --- a/test/chunking-form/samples/deprecated/emit-chunk/main.js +++ /dev/null @@ -1,3 +0,0 @@ -import value from './dep.js'; - -console.log('main', value); diff --git a/test/chunking-form/samples/deprecated/emit-file-chunk-facade/_config.js b/test/chunking-form/samples/deprecated/emit-file-chunk-facade/_config.js deleted file mode 100644 index eb5d67acdb8..00000000000 --- a/test/chunking-form/samples/deprecated/emit-file-chunk-facade/_config.js +++ /dev/null @@ -1,21 +0,0 @@ -const assert = require('assert'); -let referenceId; - -module.exports = { - description: 'retrieves the correct name of an emitted chunk in case a facade is created', - options: { - strictDeprecations: false, - input: 'main', - manualChunks: { - 'build-starter': ['buildStart'] - }, - plugins: { - buildStart() { - referenceId = this.emitFile({ type: 'chunk', id: 'buildStart' }); - }, - renderChunk() { - assert.strictEqual(this.getFileName(referenceId), 'generated-buildStart.js'); - } - } - } -}; diff --git a/test/chunking-form/samples/deprecated/emit-file-chunk-facade/_expected/amd/generated-build-starter.js b/test/chunking-form/samples/deprecated/emit-file-chunk-facade/_expected/amd/generated-build-starter.js deleted file mode 100644 index 4974a348248..00000000000 --- a/test/chunking-form/samples/deprecated/emit-file-chunk-facade/_expected/amd/generated-build-starter.js +++ /dev/null @@ -1,11 +0,0 @@ -define(['exports'], function (exports) { 'use strict'; - - const value = 42; - const otherValue = 43; - - console.log('startBuild', value); - - exports.otherValue = otherValue; - exports.value = value; - -}); diff --git a/test/chunking-form/samples/deprecated/emit-file-chunk-facade/_expected/amd/generated-buildStart.js b/test/chunking-form/samples/deprecated/emit-file-chunk-facade/_expected/amd/generated-buildStart.js deleted file mode 100644 index 06143748495..00000000000 --- a/test/chunking-form/samples/deprecated/emit-file-chunk-facade/_expected/amd/generated-buildStart.js +++ /dev/null @@ -1,9 +0,0 @@ -define(['exports', './generated-build-starter'], function (exports, buildStarter) { 'use strict'; - - - - exports.buildStartValue = buildStarter.value; - - Object.defineProperty(exports, '__esModule', { value: true }); - -}); diff --git a/test/chunking-form/samples/deprecated/emit-file-chunk-facade/_expected/amd/main.js b/test/chunking-form/samples/deprecated/emit-file-chunk-facade/_expected/amd/main.js deleted file mode 100644 index f9191ee8ad4..00000000000 --- a/test/chunking-form/samples/deprecated/emit-file-chunk-facade/_expected/amd/main.js +++ /dev/null @@ -1,5 +0,0 @@ -define(['./generated-build-starter'], function (buildStarter) { 'use strict'; - - console.log('main', buildStarter.value, buildStarter.otherValue); - -}); diff --git a/test/chunking-form/samples/deprecated/emit-file-chunk-facade/_expected/cjs/generated-build-starter.js b/test/chunking-form/samples/deprecated/emit-file-chunk-facade/_expected/cjs/generated-build-starter.js deleted file mode 100644 index fecf7a3cd4c..00000000000 --- a/test/chunking-form/samples/deprecated/emit-file-chunk-facade/_expected/cjs/generated-build-starter.js +++ /dev/null @@ -1,9 +0,0 @@ -'use strict'; - -const value = 42; -const otherValue = 43; - -console.log('startBuild', value); - -exports.otherValue = otherValue; -exports.value = value; diff --git a/test/chunking-form/samples/deprecated/emit-file-chunk-facade/_expected/cjs/generated-buildStart.js b/test/chunking-form/samples/deprecated/emit-file-chunk-facade/_expected/cjs/generated-buildStart.js deleted file mode 100644 index 66c05cca4ba..00000000000 --- a/test/chunking-form/samples/deprecated/emit-file-chunk-facade/_expected/cjs/generated-buildStart.js +++ /dev/null @@ -1,9 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { value: true }); - -var buildStarter = require('./generated-build-starter.js'); - - - -exports.buildStartValue = buildStarter.value; diff --git a/test/chunking-form/samples/deprecated/emit-file-chunk-facade/_expected/cjs/main.js b/test/chunking-form/samples/deprecated/emit-file-chunk-facade/_expected/cjs/main.js deleted file mode 100644 index 666c396846a..00000000000 --- a/test/chunking-form/samples/deprecated/emit-file-chunk-facade/_expected/cjs/main.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -var buildStarter = require('./generated-build-starter.js'); - -console.log('main', buildStarter.value, buildStarter.otherValue); diff --git a/test/chunking-form/samples/deprecated/emit-file-chunk-facade/_expected/es/generated-build-starter.js b/test/chunking-form/samples/deprecated/emit-file-chunk-facade/_expected/es/generated-build-starter.js deleted file mode 100644 index 43deafdd0be..00000000000 --- a/test/chunking-form/samples/deprecated/emit-file-chunk-facade/_expected/es/generated-build-starter.js +++ /dev/null @@ -1,6 +0,0 @@ -const value = 42; -const otherValue = 43; - -console.log('startBuild', value); - -export { otherValue as o, value as v }; diff --git a/test/chunking-form/samples/deprecated/emit-file-chunk-facade/_expected/es/generated-buildStart.js b/test/chunking-form/samples/deprecated/emit-file-chunk-facade/_expected/es/generated-buildStart.js deleted file mode 100644 index ffb305eac54..00000000000 --- a/test/chunking-form/samples/deprecated/emit-file-chunk-facade/_expected/es/generated-buildStart.js +++ /dev/null @@ -1 +0,0 @@ -export { v as buildStartValue } from './generated-build-starter.js'; diff --git a/test/chunking-form/samples/deprecated/emit-file-chunk-facade/_expected/es/main.js b/test/chunking-form/samples/deprecated/emit-file-chunk-facade/_expected/es/main.js deleted file mode 100644 index 28caef9429d..00000000000 --- a/test/chunking-form/samples/deprecated/emit-file-chunk-facade/_expected/es/main.js +++ /dev/null @@ -1,3 +0,0 @@ -import { v as value, o as otherValue } from './generated-build-starter.js'; - -console.log('main', value, otherValue); diff --git a/test/chunking-form/samples/deprecated/emit-file-chunk-facade/_expected/system/generated-build-starter.js b/test/chunking-form/samples/deprecated/emit-file-chunk-facade/_expected/system/generated-build-starter.js deleted file mode 100644 index 75f69e53e87..00000000000 --- a/test/chunking-form/samples/deprecated/emit-file-chunk-facade/_expected/system/generated-build-starter.js +++ /dev/null @@ -1,13 +0,0 @@ -System.register([], function (exports) { - 'use strict'; - return { - execute: function () { - - const value = exports('v', 42); - const otherValue = exports('o', 43); - - console.log('startBuild', value); - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/emit-file-chunk-facade/_expected/system/generated-buildStart.js b/test/chunking-form/samples/deprecated/emit-file-chunk-facade/_expected/system/generated-buildStart.js deleted file mode 100644 index b82461c98ab..00000000000 --- a/test/chunking-form/samples/deprecated/emit-file-chunk-facade/_expected/system/generated-buildStart.js +++ /dev/null @@ -1,13 +0,0 @@ -System.register(['./generated-build-starter.js'], function (exports) { - 'use strict'; - return { - setters: [function (module) { - exports('buildStartValue', module.v); - }], - execute: function () { - - - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/emit-file-chunk-facade/_expected/system/main.js b/test/chunking-form/samples/deprecated/emit-file-chunk-facade/_expected/system/main.js deleted file mode 100644 index 4b52f565751..00000000000 --- a/test/chunking-form/samples/deprecated/emit-file-chunk-facade/_expected/system/main.js +++ /dev/null @@ -1,15 +0,0 @@ -System.register(['./generated-build-starter.js'], function () { - 'use strict'; - var value, otherValue; - return { - setters: [function (module) { - value = module.v; - otherValue = module.o; - }], - execute: function () { - - console.log('main', value, otherValue); - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/emit-file-chunk-facade/buildStart.js b/test/chunking-form/samples/deprecated/emit-file-chunk-facade/buildStart.js deleted file mode 100644 index 49baee4964e..00000000000 --- a/test/chunking-form/samples/deprecated/emit-file-chunk-facade/buildStart.js +++ /dev/null @@ -1,5 +0,0 @@ -import {value} from './dep.js'; - -console.log('startBuild', value); - -export { value as buildStartValue }; diff --git a/test/chunking-form/samples/deprecated/emit-file-chunk-facade/dep.js b/test/chunking-form/samples/deprecated/emit-file-chunk-facade/dep.js deleted file mode 100644 index a2db6341120..00000000000 --- a/test/chunking-form/samples/deprecated/emit-file-chunk-facade/dep.js +++ /dev/null @@ -1,2 +0,0 @@ -export const value = 42; -export const otherValue = 43; diff --git a/test/chunking-form/samples/deprecated/emit-file-chunk-facade/main.js b/test/chunking-form/samples/deprecated/emit-file-chunk-facade/main.js deleted file mode 100644 index df41d56376c..00000000000 --- a/test/chunking-form/samples/deprecated/emit-file-chunk-facade/main.js +++ /dev/null @@ -1,3 +0,0 @@ -import { value, otherValue } from './dep'; - -console.log('main', value, otherValue); diff --git a/test/chunking-form/samples/deprecated/emit-file/filenames-function-patterns/_config.js b/test/chunking-form/samples/deprecated/emit-file/filenames-function-patterns/_config.js new file mode 100644 index 00000000000..d35c664d5d4 --- /dev/null +++ b/test/chunking-form/samples/deprecated/emit-file/filenames-function-patterns/_config.js @@ -0,0 +1,80 @@ +const assert = require('node:assert'); +const path = require('node:path'); + +const ID_MAIN = path.join(__dirname, 'main.js'); +const ID_DEB = path.join(__dirname, 'deb.js'); + +module.exports = defineTest({ + description: 'supports using a function that returns a pattern for FileNames', + options: { + strictDeprecations: false, + input: ['main.js'], + plugins: { + name: 'test-plugin', + transform(code, id) { + const baseName = path.basename(id); + this.emitFile({ + type: 'asset', + name: `${baseName}.txt`, + originalFileName: baseName, + source: 'hello world' + }); + return null; + } + }, + output: { + entryFileNames: fileInfo => { + assert.deepStrictEqual( + fileInfo, + { + exports: [], + facadeModuleId: ID_MAIN, + isDynamicEntry: false, + isEntry: true, + isImplicitEntry: false, + name: 'main', + moduleIds: [ID_MAIN], + type: 'chunk' + }, + 'entry info' + ); + return `entry-[name]-[hash]-[format].js`; + }, + assetFileNames: fileInfo => { + const originalFileName = fileInfo.originalFileName; + const originalFileNames = ['deb.js', 'main.js']; + assert.ok(originalFileNames.includes(originalFileName), 'original file name'); + assert.deepStrictEqual( + fileInfo, + { + name: `${originalFileName}.txt`, + names: ['deb.js.txt', 'main.js.txt'], + originalFileName, + originalFileNames, + source: 'hello world', + type: 'asset' + }, + 'asset info' + ); + return '[ext]/[hash]-[name][extname]'; + }, + chunkFileNames: fileInfo => { + assert.deepStrictEqual( + fileInfo, + { + exports: ['default'], + facadeModuleId: ID_DEB, + isDynamicEntry: true, + isEntry: false, + isImplicitEntry: false, + moduleIds: [ID_DEB], + name: 'deb', + type: 'chunk' + }, + 'chunk info' + ); + return 'chunk-[name]-[hash]-[format].js'; + } + } + } +}); diff --git a/test/chunking-form/samples/deprecated/emit-file/filenames-function-patterns/_expected/amd/chunk-deb--Bz6x-oi-amd.js b/test/chunking-form/samples/deprecated/emit-file/filenames-function-patterns/_expected/amd/chunk-deb--Bz6x-oi-amd.js new file mode 100644 index 00000000000..e91c726e884 --- /dev/null +++ b/test/chunking-form/samples/deprecated/emit-file/filenames-function-patterns/_expected/amd/chunk-deb--Bz6x-oi-amd.js @@ -0,0 +1,7 @@ +define(['exports'], (function (exports) { 'use strict'; + + var deb = 'string'; + + exports.default = deb; + +})); diff --git a/test/chunking-form/samples/deprecated/emit-file/filenames-function-patterns/_expected/amd/entry-main-DJVXpS51-amd.js b/test/chunking-form/samples/deprecated/emit-file/filenames-function-patterns/_expected/amd/entry-main-DJVXpS51-amd.js new file mode 100644 index 00000000000..0b5f0ae0032 --- /dev/null +++ b/test/chunking-form/samples/deprecated/emit-file/filenames-function-patterns/_expected/amd/entry-main-DJVXpS51-amd.js @@ -0,0 +1,6 @@ +define(['require'], (function (require) { 'use strict'; + + console.log('main'); + new Promise(function (resolve, reject) { require(['./chunk-deb--Bz6x-oi-amd'], resolve, reject); }).then(console.log); + +})); diff --git a/test/chunking-form/samples/emit-file/asset-file-names/_expected/amd/txt/7468331f-test.txt b/test/chunking-form/samples/deprecated/emit-file/filenames-function-patterns/_expected/amd/txt/DHthXMdY-deb.js.txt similarity index 100% rename from test/chunking-form/samples/emit-file/asset-file-names/_expected/amd/txt/7468331f-test.txt rename to test/chunking-form/samples/deprecated/emit-file/filenames-function-patterns/_expected/amd/txt/DHthXMdY-deb.js.txt diff --git a/test/chunking-form/samples/emit-file/filenames-function-patterns/_expected/cjs/chunk-deb-19c947c3-cjs.js b/test/chunking-form/samples/deprecated/emit-file/filenames-function-patterns/_expected/cjs/chunk-deb-9LJjyiap-cjs.js similarity index 100% rename from test/chunking-form/samples/emit-file/filenames-function-patterns/_expected/cjs/chunk-deb-19c947c3-cjs.js rename to test/chunking-form/samples/deprecated/emit-file/filenames-function-patterns/_expected/cjs/chunk-deb-9LJjyiap-cjs.js diff --git a/test/chunking-form/samples/deprecated/emit-file/filenames-function-patterns/_expected/cjs/entry-main-DFh1DOOW-cjs.js b/test/chunking-form/samples/deprecated/emit-file/filenames-function-patterns/_expected/cjs/entry-main-DFh1DOOW-cjs.js new file mode 100644 index 00000000000..90ccd092b8f --- /dev/null +++ b/test/chunking-form/samples/deprecated/emit-file/filenames-function-patterns/_expected/cjs/entry-main-DFh1DOOW-cjs.js @@ -0,0 +1,4 @@ +'use strict'; + +console.log('main'); +Promise.resolve().then(function () { return require('./chunk-deb-9LJjyiap-cjs.js'); }).then(console.log); diff --git a/test/chunking-form/samples/emit-file/asset-file-names/_expected/cjs/txt/7468331f-test.txt b/test/chunking-form/samples/deprecated/emit-file/filenames-function-patterns/_expected/cjs/txt/DHthXMdY-deb.js.txt similarity index 100% rename from test/chunking-form/samples/emit-file/asset-file-names/_expected/cjs/txt/7468331f-test.txt rename to test/chunking-form/samples/deprecated/emit-file/filenames-function-patterns/_expected/cjs/txt/DHthXMdY-deb.js.txt diff --git a/test/chunking-form/samples/deprecated/emit-file/filenames-function-patterns/_expected/es/chunk-deb-H_8j5Qun-es.js b/test/chunking-form/samples/deprecated/emit-file/filenames-function-patterns/_expected/es/chunk-deb-H_8j5Qun-es.js new file mode 100644 index 00000000000..d3540098970 --- /dev/null +++ b/test/chunking-form/samples/deprecated/emit-file/filenames-function-patterns/_expected/es/chunk-deb-H_8j5Qun-es.js @@ -0,0 +1,3 @@ +var deb = 'string'; + +export { deb as default }; diff --git a/test/chunking-form/samples/deprecated/emit-file/filenames-function-patterns/_expected/es/entry-main-BeWMkjX8-es.js b/test/chunking-form/samples/deprecated/emit-file/filenames-function-patterns/_expected/es/entry-main-BeWMkjX8-es.js new file mode 100644 index 00000000000..379e421b5d8 --- /dev/null +++ b/test/chunking-form/samples/deprecated/emit-file/filenames-function-patterns/_expected/es/entry-main-BeWMkjX8-es.js @@ -0,0 +1,2 @@ +console.log('main'); +import('./chunk-deb-H_8j5Qun-es.js').then(console.log); diff --git a/test/chunking-form/samples/emit-file/asset-file-names/_expected/es/txt/7468331f-test.txt b/test/chunking-form/samples/deprecated/emit-file/filenames-function-patterns/_expected/es/txt/DHthXMdY-deb.js.txt similarity index 100% rename from test/chunking-form/samples/emit-file/asset-file-names/_expected/es/txt/7468331f-test.txt rename to test/chunking-form/samples/deprecated/emit-file/filenames-function-patterns/_expected/es/txt/DHthXMdY-deb.js.txt diff --git a/test/chunking-form/samples/deprecated/emit-file/filenames-function-patterns/_expected/system/chunk-deb-PNqONwrZ-system.js b/test/chunking-form/samples/deprecated/emit-file/filenames-function-patterns/_expected/system/chunk-deb-PNqONwrZ-system.js new file mode 100644 index 00000000000..533f7eb9ca1 --- /dev/null +++ b/test/chunking-form/samples/deprecated/emit-file/filenames-function-patterns/_expected/system/chunk-deb-PNqONwrZ-system.js @@ -0,0 +1,10 @@ +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + + var deb = exports("default", 'string'); + + }) + }; +})); diff --git a/test/chunking-form/samples/deprecated/emit-file/filenames-function-patterns/_expected/system/entry-main-IHNOrI04-system.js b/test/chunking-form/samples/deprecated/emit-file/filenames-function-patterns/_expected/system/entry-main-IHNOrI04-system.js new file mode 100644 index 00000000000..9c91c2d22d9 --- /dev/null +++ b/test/chunking-form/samples/deprecated/emit-file/filenames-function-patterns/_expected/system/entry-main-IHNOrI04-system.js @@ -0,0 +1,11 @@ +System.register([], (function (exports, module) { + 'use strict'; + return { + execute: (function () { + + console.log('main'); + module.import('./chunk-deb-PNqONwrZ-system.js').then(console.log); + + }) + }; +})); diff --git a/test/chunking-form/samples/emit-file/asset-file-names/_expected/system/txt/7468331f-test.txt b/test/chunking-form/samples/deprecated/emit-file/filenames-function-patterns/_expected/system/txt/DHthXMdY-deb.js.txt similarity index 100% rename from test/chunking-form/samples/emit-file/asset-file-names/_expected/system/txt/7468331f-test.txt rename to test/chunking-form/samples/deprecated/emit-file/filenames-function-patterns/_expected/system/txt/DHthXMdY-deb.js.txt diff --git a/test/chunking-form/samples/deprecated/emit-file/filenames-function-patterns/deb.js b/test/chunking-form/samples/deprecated/emit-file/filenames-function-patterns/deb.js new file mode 100644 index 00000000000..25d150df293 --- /dev/null +++ b/test/chunking-form/samples/deprecated/emit-file/filenames-function-patterns/deb.js @@ -0,0 +1 @@ +export default 'string'; diff --git a/test/chunking-form/samples/deprecated/emit-file/filenames-function-patterns/main.js b/test/chunking-form/samples/deprecated/emit-file/filenames-function-patterns/main.js new file mode 100644 index 00000000000..d2ae8405fe6 --- /dev/null +++ b/test/chunking-form/samples/deprecated/emit-file/filenames-function-patterns/main.js @@ -0,0 +1,2 @@ +console.log('main'); +import('./deb').then(console.log); diff --git a/test/chunking-form/samples/deprecated/emit-file/generate-emission-names/_config.js b/test/chunking-form/samples/deprecated/emit-file/generate-emission-names/_config.js new file mode 100644 index 00000000000..8458b6eed36 --- /dev/null +++ b/test/chunking-form/samples/deprecated/emit-file/generate-emission-names/_config.js @@ -0,0 +1,53 @@ +const assert = require('node:assert'); + +let referenceIdWithoutName; +let referenceIdWithName; + +module.exports = defineTest({ + description: 'updates asset names when emitting in generate phase', + options: { + strictDeprecations: false, + output: { assetFileNames: 'generated-[name][extname]' }, + plugins: { + renderChunk() { + referenceIdWithoutName = this.emitFile({ + type: 'asset', + source: 'renderChunk-without-names' + }); + referenceIdWithName = this.emitFile({ + type: 'asset', + name: 'with-names.txt', + originalFileName: 'with-names-original.txt', + source: 'renderChunk-with-names' + }); + }, + generateBundle(options, bundle) { + const fileNameWithoutName = this.getFileName(referenceIdWithoutName); + assert.strictEqual(fileNameWithoutName, 'generated-asset'); + assert.strictEqual(bundle[fileNameWithoutName].name, undefined); + assert.strictEqual(bundle[fileNameWithoutName].originalFileName, null); + this.emitFile({ + type: 'asset', + source: 'renderChunk-without-names', + name: 'new-name.txt', + originalFileName: 'original-new-name.txt' + }); + assert.strictEqual(bundle[fileNameWithoutName].name, undefined); + assert.strictEqual(bundle[fileNameWithoutName].originalFileName, null); + + const fileNameWithName = this.getFileName(referenceIdWithName); + assert.strictEqual(fileNameWithName, 'generated-with-names.txt'); + assert.strictEqual(bundle[fileNameWithName].name, 'with-names.txt'); + assert.strictEqual(bundle[fileNameWithName].originalFileName, 'with-names-original.txt'); + this.emitFile({ + type: 'asset', + name: 'second-name.txt', + originalFileName: 'original-second-name.txt', + source: 'renderChunk-with-names' + }); + assert.strictEqual(bundle[fileNameWithName].name, 'with-names.txt'); + assert.strictEqual(bundle[fileNameWithName].originalFileName, 'with-names-original.txt'); + } + } + } +}); diff --git a/test/chunking-form/samples/deprecated/emit-file/generate-emission-names/_expected/amd/generated-asset b/test/chunking-form/samples/deprecated/emit-file/generate-emission-names/_expected/amd/generated-asset new file mode 100644 index 00000000000..4a5b37433fe --- /dev/null +++ b/test/chunking-form/samples/deprecated/emit-file/generate-emission-names/_expected/amd/generated-asset @@ -0,0 +1 @@ +renderChunk-without-names \ No newline at end of file diff --git a/test/chunking-form/samples/deprecated/emit-file/generate-emission-names/_expected/amd/generated-with-names.txt b/test/chunking-form/samples/deprecated/emit-file/generate-emission-names/_expected/amd/generated-with-names.txt new file mode 100644 index 00000000000..60e4f7f514d --- /dev/null +++ b/test/chunking-form/samples/deprecated/emit-file/generate-emission-names/_expected/amd/generated-with-names.txt @@ -0,0 +1 @@ +renderChunk-with-names \ No newline at end of file diff --git a/test/chunking-form/samples/deprecated/emit-file/generate-emission-names/_expected/amd/main.js b/test/chunking-form/samples/deprecated/emit-file/generate-emission-names/_expected/amd/main.js new file mode 100644 index 00000000000..947ad1cbafd --- /dev/null +++ b/test/chunking-form/samples/deprecated/emit-file/generate-emission-names/_expected/amd/main.js @@ -0,0 +1,7 @@ +define(['exports'], (function (exports) { 'use strict'; + + const value = 42; + + exports.value = value; + +})); diff --git a/test/chunking-form/samples/deprecated/emit-file/generate-emission-names/_expected/cjs/generated-asset b/test/chunking-form/samples/deprecated/emit-file/generate-emission-names/_expected/cjs/generated-asset new file mode 100644 index 00000000000..4a5b37433fe --- /dev/null +++ b/test/chunking-form/samples/deprecated/emit-file/generate-emission-names/_expected/cjs/generated-asset @@ -0,0 +1 @@ +renderChunk-without-names \ No newline at end of file diff --git a/test/chunking-form/samples/deprecated/emit-file/generate-emission-names/_expected/cjs/generated-with-names.txt b/test/chunking-form/samples/deprecated/emit-file/generate-emission-names/_expected/cjs/generated-with-names.txt new file mode 100644 index 00000000000..60e4f7f514d --- /dev/null +++ b/test/chunking-form/samples/deprecated/emit-file/generate-emission-names/_expected/cjs/generated-with-names.txt @@ -0,0 +1 @@ +renderChunk-with-names \ No newline at end of file diff --git a/test/chunking-form/samples/deprecated/emit-file/generate-emission-names/_expected/cjs/main.js b/test/chunking-form/samples/deprecated/emit-file/generate-emission-names/_expected/cjs/main.js new file mode 100644 index 00000000000..9549eb32880 --- /dev/null +++ b/test/chunking-form/samples/deprecated/emit-file/generate-emission-names/_expected/cjs/main.js @@ -0,0 +1,5 @@ +'use strict'; + +const value = 42; + +exports.value = value; diff --git a/test/chunking-form/samples/deprecated/emit-file/generate-emission-names/_expected/es/generated-asset b/test/chunking-form/samples/deprecated/emit-file/generate-emission-names/_expected/es/generated-asset new file mode 100644 index 00000000000..4a5b37433fe --- /dev/null +++ b/test/chunking-form/samples/deprecated/emit-file/generate-emission-names/_expected/es/generated-asset @@ -0,0 +1 @@ +renderChunk-without-names \ No newline at end of file diff --git a/test/chunking-form/samples/deprecated/emit-file/generate-emission-names/_expected/es/generated-with-names.txt b/test/chunking-form/samples/deprecated/emit-file/generate-emission-names/_expected/es/generated-with-names.txt new file mode 100644 index 00000000000..60e4f7f514d --- /dev/null +++ b/test/chunking-form/samples/deprecated/emit-file/generate-emission-names/_expected/es/generated-with-names.txt @@ -0,0 +1 @@ +renderChunk-with-names \ No newline at end of file diff --git a/test/chunking-form/samples/deprecated/emit-file/generate-emission-names/_expected/es/main.js b/test/chunking-form/samples/deprecated/emit-file/generate-emission-names/_expected/es/main.js new file mode 100644 index 00000000000..d897952f7d1 --- /dev/null +++ b/test/chunking-form/samples/deprecated/emit-file/generate-emission-names/_expected/es/main.js @@ -0,0 +1,3 @@ +const value = 42; + +export { value }; diff --git a/test/chunking-form/samples/deprecated/emit-file/generate-emission-names/_expected/system/generated-asset b/test/chunking-form/samples/deprecated/emit-file/generate-emission-names/_expected/system/generated-asset new file mode 100644 index 00000000000..4a5b37433fe --- /dev/null +++ b/test/chunking-form/samples/deprecated/emit-file/generate-emission-names/_expected/system/generated-asset @@ -0,0 +1 @@ +renderChunk-without-names \ No newline at end of file diff --git a/test/chunking-form/samples/deprecated/emit-file/generate-emission-names/_expected/system/generated-with-names.txt b/test/chunking-form/samples/deprecated/emit-file/generate-emission-names/_expected/system/generated-with-names.txt new file mode 100644 index 00000000000..60e4f7f514d --- /dev/null +++ b/test/chunking-form/samples/deprecated/emit-file/generate-emission-names/_expected/system/generated-with-names.txt @@ -0,0 +1 @@ +renderChunk-with-names \ No newline at end of file diff --git a/test/chunking-form/samples/deprecated/emit-file/generate-emission-names/_expected/system/main.js b/test/chunking-form/samples/deprecated/emit-file/generate-emission-names/_expected/system/main.js new file mode 100644 index 00000000000..f80269f9009 --- /dev/null +++ b/test/chunking-form/samples/deprecated/emit-file/generate-emission-names/_expected/system/main.js @@ -0,0 +1,10 @@ +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + + const value = exports("value", 42); + + }) + }; +})); diff --git a/test/function/samples/deprecated/preserveModules/invalid-no-preserve-entry-signatures/main.js b/test/chunking-form/samples/deprecated/emit-file/generate-emission-names/main.js similarity index 100% rename from test/function/samples/deprecated/preserveModules/invalid-no-preserve-entry-signatures/main.js rename to test/chunking-form/samples/deprecated/emit-file/generate-emission-names/main.js diff --git a/test/chunking-form/samples/deprecated/indirect-reexports-preserve-modules/_config.js b/test/chunking-form/samples/deprecated/indirect-reexports-preserve-modules/_config.js deleted file mode 100644 index be01fb9f36e..00000000000 --- a/test/chunking-form/samples/deprecated/indirect-reexports-preserve-modules/_config.js +++ /dev/null @@ -1,9 +0,0 @@ -module.exports = { - description: 'does not drop indirect reexports when preserving modules', - expectedWarnings: ['MIXED_EXPORTS'], - options: { - strictDeprecations: false, - output: { name: 'bundle' }, - preserveModules: true - } -}; diff --git a/test/chunking-form/samples/deprecated/indirect-reexports-preserve-modules/_expected/amd/components/index.js b/test/chunking-form/samples/deprecated/indirect-reexports-preserve-modules/_expected/amd/components/index.js deleted file mode 100644 index db7eff4760a..00000000000 --- a/test/chunking-form/samples/deprecated/indirect-reexports-preserve-modules/_expected/amd/components/index.js +++ /dev/null @@ -1,10 +0,0 @@ -define(['exports', './sub/index'], function (exports, index) { 'use strict'; - - const baz = { bar: index['default'] }; - - exports.foo = index.foo; - exports.baz = baz; - - Object.defineProperty(exports, '__esModule', { value: true }); - -}); diff --git a/test/chunking-form/samples/deprecated/indirect-reexports-preserve-modules/_expected/amd/components/sub/index.js b/test/chunking-form/samples/deprecated/indirect-reexports-preserve-modules/_expected/amd/components/sub/index.js deleted file mode 100644 index 812fe417fb5..00000000000 --- a/test/chunking-form/samples/deprecated/indirect-reexports-preserve-modules/_expected/amd/components/sub/index.js +++ /dev/null @@ -1,11 +0,0 @@ -define(['exports'], function (exports) { 'use strict'; - - const foo = 'bar'; - var bar = () => {}; - - exports.default = bar; - exports.foo = foo; - - Object.defineProperty(exports, '__esModule', { value: true }); - -}); diff --git a/test/chunking-form/samples/deprecated/indirect-reexports-preserve-modules/_expected/amd/main.js b/test/chunking-form/samples/deprecated/indirect-reexports-preserve-modules/_expected/amd/main.js deleted file mode 100644 index 9e02e78d24e..00000000000 --- a/test/chunking-form/samples/deprecated/indirect-reexports-preserve-modules/_expected/amd/main.js +++ /dev/null @@ -1,10 +0,0 @@ -define(['exports', './components/index', './components/sub/index'], function (exports, index, index$1) { 'use strict'; - - - - exports.baz = index.baz; - exports.foo = index$1.foo; - - Object.defineProperty(exports, '__esModule', { value: true }); - -}); diff --git a/test/chunking-form/samples/deprecated/indirect-reexports-preserve-modules/_expected/cjs/components/index.js b/test/chunking-form/samples/deprecated/indirect-reexports-preserve-modules/_expected/cjs/components/index.js deleted file mode 100644 index 848372ab743..00000000000 --- a/test/chunking-form/samples/deprecated/indirect-reexports-preserve-modules/_expected/cjs/components/index.js +++ /dev/null @@ -1,10 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { value: true }); - -var index = require('./sub/index.js'); - -const baz = { bar: index['default'] }; - -exports.foo = index.foo; -exports.baz = baz; diff --git a/test/chunking-form/samples/deprecated/indirect-reexports-preserve-modules/_expected/cjs/components/sub/index.js b/test/chunking-form/samples/deprecated/indirect-reexports-preserve-modules/_expected/cjs/components/sub/index.js deleted file mode 100644 index 8ffc494cbe4..00000000000 --- a/test/chunking-form/samples/deprecated/indirect-reexports-preserve-modules/_expected/cjs/components/sub/index.js +++ /dev/null @@ -1,9 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { value: true }); - -const foo = 'bar'; -var bar = () => {}; - -exports.default = bar; -exports.foo = foo; diff --git a/test/chunking-form/samples/deprecated/indirect-reexports-preserve-modules/_expected/cjs/main.js b/test/chunking-form/samples/deprecated/indirect-reexports-preserve-modules/_expected/cjs/main.js deleted file mode 100644 index e8c88da6582..00000000000 --- a/test/chunking-form/samples/deprecated/indirect-reexports-preserve-modules/_expected/cjs/main.js +++ /dev/null @@ -1,11 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { value: true }); - -var index = require('./components/index.js'); -var index$1 = require('./components/sub/index.js'); - - - -exports.baz = index.baz; -exports.foo = index$1.foo; diff --git a/test/chunking-form/samples/deprecated/indirect-reexports-preserve-modules/_expected/es/components/index.js b/test/chunking-form/samples/deprecated/indirect-reexports-preserve-modules/_expected/es/components/index.js deleted file mode 100644 index baeee792cc9..00000000000 --- a/test/chunking-form/samples/deprecated/indirect-reexports-preserve-modules/_expected/es/components/index.js +++ /dev/null @@ -1,6 +0,0 @@ -import bar from './sub/index.js'; -export { foo } from './sub/index.js'; - -const baz = { bar }; - -export { baz }; diff --git a/test/chunking-form/samples/deprecated/indirect-reexports-preserve-modules/_expected/es/components/sub/index.js b/test/chunking-form/samples/deprecated/indirect-reexports-preserve-modules/_expected/es/components/sub/index.js deleted file mode 100644 index 3b438c25222..00000000000 --- a/test/chunking-form/samples/deprecated/indirect-reexports-preserve-modules/_expected/es/components/sub/index.js +++ /dev/null @@ -1,5 +0,0 @@ -const foo = 'bar'; -var bar = () => {}; - -export default bar; -export { foo }; diff --git a/test/chunking-form/samples/deprecated/indirect-reexports-preserve-modules/_expected/es/main.js b/test/chunking-form/samples/deprecated/indirect-reexports-preserve-modules/_expected/es/main.js deleted file mode 100644 index d3455118d1b..00000000000 --- a/test/chunking-form/samples/deprecated/indirect-reexports-preserve-modules/_expected/es/main.js +++ /dev/null @@ -1,2 +0,0 @@ -export { baz } from './components/index.js'; -export { foo } from './components/sub/index.js'; diff --git a/test/chunking-form/samples/deprecated/indirect-reexports-preserve-modules/_expected/system/components/index.js b/test/chunking-form/samples/deprecated/indirect-reexports-preserve-modules/_expected/system/components/index.js deleted file mode 100644 index 17def0f802d..00000000000 --- a/test/chunking-form/samples/deprecated/indirect-reexports-preserve-modules/_expected/system/components/index.js +++ /dev/null @@ -1,15 +0,0 @@ -System.register('bundle', ['./sub/index.js'], function (exports) { - 'use strict'; - var bar; - return { - setters: [function (module) { - bar = module.default; - exports('foo', module.foo); - }], - execute: function () { - - const baz = exports('baz', { bar }); - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/indirect-reexports-preserve-modules/_expected/system/components/sub/index.js b/test/chunking-form/samples/deprecated/indirect-reexports-preserve-modules/_expected/system/components/sub/index.js deleted file mode 100644 index 2174c193998..00000000000 --- a/test/chunking-form/samples/deprecated/indirect-reexports-preserve-modules/_expected/system/components/sub/index.js +++ /dev/null @@ -1,11 +0,0 @@ -System.register('bundle', [], function (exports) { - 'use strict'; - return { - execute: function () { - - const foo = exports('foo', 'bar'); - var bar = exports('default', () => {}); - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/indirect-reexports-preserve-modules/_expected/system/main.js b/test/chunking-form/samples/deprecated/indirect-reexports-preserve-modules/_expected/system/main.js deleted file mode 100644 index 8aafd8ee3a0..00000000000 --- a/test/chunking-form/samples/deprecated/indirect-reexports-preserve-modules/_expected/system/main.js +++ /dev/null @@ -1,15 +0,0 @@ -System.register('bundle', ['./components/index.js', './components/sub/index.js'], function (exports) { - 'use strict'; - return { - setters: [function (module) { - exports('baz', module.baz); - }, function (module) { - exports('foo', module.foo); - }], - execute: function () { - - - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/indirect-reexports-preserve-modules/components/index.js b/test/chunking-form/samples/deprecated/indirect-reexports-preserve-modules/components/index.js deleted file mode 100644 index 0c5913716d6..00000000000 --- a/test/chunking-form/samples/deprecated/indirect-reexports-preserve-modules/components/index.js +++ /dev/null @@ -1,4 +0,0 @@ -import bar, { foo } from './sub/index'; - -export const baz = { bar }; -export { foo }; diff --git a/test/chunking-form/samples/deprecated/indirect-reexports-preserve-modules/components/sub/index.js b/test/chunking-form/samples/deprecated/indirect-reexports-preserve-modules/components/sub/index.js deleted file mode 100644 index 0bce193fce2..00000000000 --- a/test/chunking-form/samples/deprecated/indirect-reexports-preserve-modules/components/sub/index.js +++ /dev/null @@ -1,4 +0,0 @@ -const foo = 'bar'; - -export { foo }; -export default () => {}; diff --git a/test/chunking-form/samples/deprecated/indirect-reexports-preserve-modules/main.js b/test/chunking-form/samples/deprecated/indirect-reexports-preserve-modules/main.js deleted file mode 100644 index 6dfbc9774ea..00000000000 --- a/test/chunking-form/samples/deprecated/indirect-reexports-preserve-modules/main.js +++ /dev/null @@ -1,3 +0,0 @@ -import { baz, foo } from './components/index'; - -export { baz, foo }; diff --git a/test/chunking-form/samples/deprecated/interop-per-reexported-default-dependency-boolean/_config.js b/test/chunking-form/samples/deprecated/interop-per-reexported-default-dependency-boolean/_config.js deleted file mode 100644 index 4c6d5748f22..00000000000 --- a/test/chunking-form/samples/deprecated/interop-per-reexported-default-dependency-boolean/_config.js +++ /dev/null @@ -1,14 +0,0 @@ -module.exports = { - description: - 'allows to configure the interop type per reexported default from an external dependency for boolean values', - options: { - strictDeprecations: false, - input: ['false', 'true'], - external: id => id.startsWith('external'), - output: { - interop(id) { - return JSON.parse(id.split('-')[1]); - } - } - } -}; diff --git a/test/chunking-form/samples/deprecated/interop-per-reexported-default-dependency-boolean/_expected.js b/test/chunking-form/samples/deprecated/interop-per-reexported-default-dependency-boolean/_expected.js deleted file mode 100644 index 8607119d36b..00000000000 --- a/test/chunking-form/samples/deprecated/interop-per-reexported-default-dependency-boolean/_expected.js +++ /dev/null @@ -1,78 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { value: true }); - -var externalFalse = require('external-false'); -var externalTrue = require('external-true'); -var externalDefault = require('external-default'); -var externalEsModule = require('external-esModule'); - -function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex : { 'default': ex }; } - -function _interopNamespace(e) { - if (e && e.__esModule) { return e; } else { - var n = Object.create(null); - if (e) { - Object.keys(e).forEach(function (k) { - var d = Object.getOwnPropertyDescriptor(e, k); - Object.defineProperty(n, k, d.get ? d : { - enumerable: true, - get: function () { - return e[k]; - } - }); - }); - } - n['default'] = e; - return Object.freeze(n); - } -} - -var externalTrue__namespace = /*#__PURE__*/_interopNamespace(externalTrue); -var externalTrue__default = /*#__PURE__*/_interopDefault(externalTrue); -var externalDefault__namespace = /*#__PURE__*/_interopNamespace(externalDefault); - - - -Object.defineProperty(exports, 'barFalse', { - enumerable: true, - get: function () { - return externalFalse.barFalse; - } -}); -exports.externalFalse = externalFalse; -exports.fooFalse = externalFalse; -Object.defineProperty(exports, 'barTrue', { - enumerable: true, - get: function () { - return externalTrue.barTrue; - } -}); -exports.externalTrue = externalTrue__namespace; -Object.defineProperty(exports, 'fooTrue', { - enumerable: true, - get: function () { - return externalTrue__default['default']; - } -}); -Object.defineProperty(exports, 'barDefault', { - enumerable: true, - get: function () { - return externalDefault.barDefault; - } -}); -exports.externalDefault = externalDefault__namespace; -exports.fooDefault = externalDefault; -Object.defineProperty(exports, 'barEsModule', { - enumerable: true, - get: function () { - return externalEsModule.barEsModule; - } -}); -exports.externalEsModule = externalEsModule; -Object.defineProperty(exports, 'fooEsModule', { - enumerable: true, - get: function () { - return externalEsModule['default']; - } -}); diff --git a/test/chunking-form/samples/deprecated/interop-per-reexported-default-dependency-boolean/_expected/amd/false.js b/test/chunking-form/samples/deprecated/interop-per-reexported-default-dependency-boolean/_expected/amd/false.js deleted file mode 100644 index f88ed67c58f..00000000000 --- a/test/chunking-form/samples/deprecated/interop-per-reexported-default-dependency-boolean/_expected/amd/false.js +++ /dev/null @@ -1,7 +0,0 @@ -define(['external-false'], function (externalFalse) { 'use strict'; - - - - return externalFalse; - -}); diff --git a/test/chunking-form/samples/deprecated/interop-per-reexported-default-dependency-boolean/_expected/amd/true.js b/test/chunking-form/samples/deprecated/interop-per-reexported-default-dependency-boolean/_expected/amd/true.js deleted file mode 100644 index 90c39c2b2a9..00000000000 --- a/test/chunking-form/samples/deprecated/interop-per-reexported-default-dependency-boolean/_expected/amd/true.js +++ /dev/null @@ -1,11 +0,0 @@ -define(['external-true'], function (externalTrue) { 'use strict'; - - function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } - - var externalTrue__default = /*#__PURE__*/_interopDefaultLegacy(externalTrue); - - - - return externalTrue__default['default']; - -}); diff --git a/test/chunking-form/samples/deprecated/interop-per-reexported-default-dependency-boolean/_expected/cjs/false.js b/test/chunking-form/samples/deprecated/interop-per-reexported-default-dependency-boolean/_expected/cjs/false.js deleted file mode 100644 index 0450ae893d0..00000000000 --- a/test/chunking-form/samples/deprecated/interop-per-reexported-default-dependency-boolean/_expected/cjs/false.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -var externalFalse = require('external-false'); - - - -module.exports = externalFalse; diff --git a/test/chunking-form/samples/deprecated/interop-per-reexported-default-dependency-boolean/_expected/cjs/true.js b/test/chunking-form/samples/deprecated/interop-per-reexported-default-dependency-boolean/_expected/cjs/true.js deleted file mode 100644 index 12cdef8623d..00000000000 --- a/test/chunking-form/samples/deprecated/interop-per-reexported-default-dependency-boolean/_expected/cjs/true.js +++ /dev/null @@ -1,11 +0,0 @@ -'use strict'; - -var externalTrue = require('external-true'); - -function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } - -var externalTrue__default = /*#__PURE__*/_interopDefaultLegacy(externalTrue); - - - -module.exports = externalTrue__default['default']; diff --git a/test/chunking-form/samples/deprecated/interop-per-reexported-default-dependency-boolean/_expected/es/false.js b/test/chunking-form/samples/deprecated/interop-per-reexported-default-dependency-boolean/_expected/es/false.js deleted file mode 100644 index f79e708482b..00000000000 --- a/test/chunking-form/samples/deprecated/interop-per-reexported-default-dependency-boolean/_expected/es/false.js +++ /dev/null @@ -1 +0,0 @@ -export { default } from 'external-false'; diff --git a/test/chunking-form/samples/deprecated/interop-per-reexported-default-dependency-boolean/_expected/es/true.js b/test/chunking-form/samples/deprecated/interop-per-reexported-default-dependency-boolean/_expected/es/true.js deleted file mode 100644 index 1cbae04dc52..00000000000 --- a/test/chunking-form/samples/deprecated/interop-per-reexported-default-dependency-boolean/_expected/es/true.js +++ /dev/null @@ -1 +0,0 @@ -export { default } from 'external-true'; diff --git a/test/chunking-form/samples/deprecated/interop-per-reexported-default-dependency-boolean/_expected/system/false.js b/test/chunking-form/samples/deprecated/interop-per-reexported-default-dependency-boolean/_expected/system/false.js deleted file mode 100644 index b75f835072a..00000000000 --- a/test/chunking-form/samples/deprecated/interop-per-reexported-default-dependency-boolean/_expected/system/false.js +++ /dev/null @@ -1,13 +0,0 @@ -System.register(['external-false'], function (exports) { - 'use strict'; - return { - setters: [function (module) { - exports('default', module.default); - }], - execute: function () { - - - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/interop-per-reexported-default-dependency-boolean/_expected/system/true.js b/test/chunking-form/samples/deprecated/interop-per-reexported-default-dependency-boolean/_expected/system/true.js deleted file mode 100644 index a7ecb82b34d..00000000000 --- a/test/chunking-form/samples/deprecated/interop-per-reexported-default-dependency-boolean/_expected/system/true.js +++ /dev/null @@ -1,13 +0,0 @@ -System.register(['external-true'], function (exports) { - 'use strict'; - return { - setters: [function (module) { - exports('default', module.default); - }], - execute: function () { - - - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/interop-per-reexported-default-dependency-boolean/false.js b/test/chunking-form/samples/deprecated/interop-per-reexported-default-dependency-boolean/false.js deleted file mode 100644 index f79e708482b..00000000000 --- a/test/chunking-form/samples/deprecated/interop-per-reexported-default-dependency-boolean/false.js +++ /dev/null @@ -1 +0,0 @@ -export { default } from 'external-false'; diff --git a/test/chunking-form/samples/deprecated/interop-per-reexported-default-dependency-boolean/true.js b/test/chunking-form/samples/deprecated/interop-per-reexported-default-dependency-boolean/true.js deleted file mode 100644 index 1cbae04dc52..00000000000 --- a/test/chunking-form/samples/deprecated/interop-per-reexported-default-dependency-boolean/true.js +++ /dev/null @@ -1 +0,0 @@ -export { default } from 'external-true'; diff --git a/test/chunking-form/samples/deprecated/manual-chunk-avoid-facade/_config.js b/test/chunking-form/samples/deprecated/manual-chunk-avoid-facade/_config.js deleted file mode 100644 index cdbcbdedf88..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunk-avoid-facade/_config.js +++ /dev/null @@ -1,10 +0,0 @@ -module.exports = { - description: 'avoid facades if possible when using manual chunks', - options: { - strictDeprecations: false, - input: ['main1', 'main2'], - manualChunks: { - manual: ['main2'] - } - } -}; diff --git a/test/chunking-form/samples/deprecated/manual-chunk-avoid-facade/_expected/amd/main1.js b/test/chunking-form/samples/deprecated/manual-chunk-avoid-facade/_expected/amd/main1.js deleted file mode 100644 index a973f4d8de7..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunk-avoid-facade/_expected/amd/main1.js +++ /dev/null @@ -1,5 +0,0 @@ -define(['./main2'], function (manual) { 'use strict'; - - console.log('main', manual.reexported); - -}); diff --git a/test/chunking-form/samples/deprecated/manual-chunk-avoid-facade/_expected/amd/main2.js b/test/chunking-form/samples/deprecated/manual-chunk-avoid-facade/_expected/amd/main2.js deleted file mode 100644 index 674f42a401c..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunk-avoid-facade/_expected/amd/main2.js +++ /dev/null @@ -1,11 +0,0 @@ -define(['exports'], function (exports) { 'use strict'; - - const value = 42; - - console.log('main2', value); - - exports.reexported = value; - - Object.defineProperty(exports, '__esModule', { value: true }); - -}); diff --git a/test/chunking-form/samples/deprecated/manual-chunk-avoid-facade/_expected/cjs/main1.js b/test/chunking-form/samples/deprecated/manual-chunk-avoid-facade/_expected/cjs/main1.js deleted file mode 100644 index 81de531a9bb..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunk-avoid-facade/_expected/cjs/main1.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -var manual = require('./main2.js'); - -console.log('main', manual.reexported); diff --git a/test/chunking-form/samples/deprecated/manual-chunk-avoid-facade/_expected/cjs/main2.js b/test/chunking-form/samples/deprecated/manual-chunk-avoid-facade/_expected/cjs/main2.js deleted file mode 100644 index f7d33362bcc..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunk-avoid-facade/_expected/cjs/main2.js +++ /dev/null @@ -1,9 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { value: true }); - -const value = 42; - -console.log('main2', value); - -exports.reexported = value; diff --git a/test/chunking-form/samples/deprecated/manual-chunk-avoid-facade/_expected/es/main1.js b/test/chunking-form/samples/deprecated/manual-chunk-avoid-facade/_expected/es/main1.js deleted file mode 100644 index 6ba22536aa3..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunk-avoid-facade/_expected/es/main1.js +++ /dev/null @@ -1,3 +0,0 @@ -import { reexported as value } from './main2.js'; - -console.log('main', value); diff --git a/test/chunking-form/samples/deprecated/manual-chunk-avoid-facade/_expected/es/main2.js b/test/chunking-form/samples/deprecated/manual-chunk-avoid-facade/_expected/es/main2.js deleted file mode 100644 index 897452bd66e..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunk-avoid-facade/_expected/es/main2.js +++ /dev/null @@ -1,5 +0,0 @@ -const value = 42; - -console.log('main2', value); - -export { value as reexported }; diff --git a/test/chunking-form/samples/deprecated/manual-chunk-avoid-facade/_expected/system/main1.js b/test/chunking-form/samples/deprecated/manual-chunk-avoid-facade/_expected/system/main1.js deleted file mode 100644 index 36f1fb810be..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunk-avoid-facade/_expected/system/main1.js +++ /dev/null @@ -1,14 +0,0 @@ -System.register(['./main2.js'], function () { - 'use strict'; - var value; - return { - setters: [function (module) { - value = module.reexported; - }], - execute: function () { - - console.log('main', value); - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/manual-chunk-avoid-facade/_expected/system/main2.js b/test/chunking-form/samples/deprecated/manual-chunk-avoid-facade/_expected/system/main2.js deleted file mode 100644 index e00ab6a2dca..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunk-avoid-facade/_expected/system/main2.js +++ /dev/null @@ -1,12 +0,0 @@ -System.register([], function (exports) { - 'use strict'; - return { - execute: function () { - - const value = exports('reexported', 42); - - console.log('main2', value); - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/manual-chunk-avoid-facade/main1.js b/test/chunking-form/samples/deprecated/manual-chunk-avoid-facade/main1.js deleted file mode 100644 index 5da97663c3a..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunk-avoid-facade/main1.js +++ /dev/null @@ -1,3 +0,0 @@ -import { value } from './dep'; - -console.log('main', value); diff --git a/test/chunking-form/samples/deprecated/manual-chunk-avoid-facade/main2.js b/test/chunking-form/samples/deprecated/manual-chunk-avoid-facade/main2.js deleted file mode 100644 index 868d23fd0a7..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunk-avoid-facade/main2.js +++ /dev/null @@ -1,5 +0,0 @@ -import {value} from './dep.js'; - -console.log('main2', value); - -export { value as reexported }; diff --git a/test/chunking-form/samples/deprecated/manual-chunk-contains-entry-conflict/_config.js b/test/chunking-form/samples/deprecated/manual-chunk-contains-entry-conflict/_config.js deleted file mode 100644 index eddc0b545b7..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunk-contains-entry-conflict/_config.js +++ /dev/null @@ -1,13 +0,0 @@ -module.exports = { - description: 'Uses entry alias if manual chunks contain entry chunks with different alias', - options: { - strictDeprecations: false, - input: { - main: 'main.js', - main2: 'main2.js' - }, - manualChunks: { - outer: ['outer'] - } - } -}; diff --git a/test/chunking-form/samples/deprecated/manual-chunk-contains-entry-conflict/_expected/amd/main.js b/test/chunking-form/samples/deprecated/manual-chunk-contains-entry-conflict/_expected/amd/main.js deleted file mode 100644 index fc91f027a0e..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunk-contains-entry-conflict/_expected/amd/main.js +++ /dev/null @@ -1,13 +0,0 @@ -define(['exports'], function (exports) { 'use strict'; - - console.log('dep'); - - console.log('main'); - - const value = 42; - - exports.value = value; - - Object.defineProperty(exports, '__esModule', { value: true }); - -}); diff --git a/test/chunking-form/samples/deprecated/manual-chunk-contains-entry-conflict/_expected/amd/main2.js b/test/chunking-form/samples/deprecated/manual-chunk-contains-entry-conflict/_expected/amd/main2.js deleted file mode 100644 index d28c079a312..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunk-contains-entry-conflict/_expected/amd/main2.js +++ /dev/null @@ -1,5 +0,0 @@ -define(['./main'], function (outer) { 'use strict'; - - - -}); diff --git a/test/chunking-form/samples/deprecated/manual-chunk-contains-entry-conflict/_expected/cjs/main.js b/test/chunking-form/samples/deprecated/manual-chunk-contains-entry-conflict/_expected/cjs/main.js deleted file mode 100644 index 5da9ebd5132..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunk-contains-entry-conflict/_expected/cjs/main.js +++ /dev/null @@ -1,11 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { value: true }); - -console.log('dep'); - -console.log('main'); - -const value = 42; - -exports.value = value; diff --git a/test/chunking-form/samples/deprecated/manual-chunk-contains-entry-conflict/_expected/cjs/main2.js b/test/chunking-form/samples/deprecated/manual-chunk-contains-entry-conflict/_expected/cjs/main2.js deleted file mode 100644 index 7ca8a520b06..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunk-contains-entry-conflict/_expected/cjs/main2.js +++ /dev/null @@ -1,4 +0,0 @@ -'use strict'; - -require('./main.js'); - diff --git a/test/chunking-form/samples/deprecated/manual-chunk-contains-entry-conflict/_expected/es/main.js b/test/chunking-form/samples/deprecated/manual-chunk-contains-entry-conflict/_expected/es/main.js deleted file mode 100644 index 132b27a8d7c..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunk-contains-entry-conflict/_expected/es/main.js +++ /dev/null @@ -1,7 +0,0 @@ -console.log('dep'); - -console.log('main'); - -const value = 42; - -export { value }; diff --git a/test/chunking-form/samples/deprecated/manual-chunk-contains-entry-conflict/_expected/es/main2.js b/test/chunking-form/samples/deprecated/manual-chunk-contains-entry-conflict/_expected/es/main2.js deleted file mode 100644 index 859ecc36bb9..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunk-contains-entry-conflict/_expected/es/main2.js +++ /dev/null @@ -1 +0,0 @@ -import './main.js'; diff --git a/test/chunking-form/samples/deprecated/manual-chunk-contains-entry-conflict/_expected/system/main.js b/test/chunking-form/samples/deprecated/manual-chunk-contains-entry-conflict/_expected/system/main.js deleted file mode 100644 index b92309e3bf3..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunk-contains-entry-conflict/_expected/system/main.js +++ /dev/null @@ -1,14 +0,0 @@ -System.register([], function (exports) { - 'use strict'; - return { - execute: function () { - - console.log('dep'); - - console.log('main'); - - const value = exports('value', 42); - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/manual-chunk-contains-entry-conflict/_expected/system/main2.js b/test/chunking-form/samples/deprecated/manual-chunk-contains-entry-conflict/_expected/system/main2.js deleted file mode 100644 index da731958b75..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunk-contains-entry-conflict/_expected/system/main2.js +++ /dev/null @@ -1,11 +0,0 @@ -System.register(['./main.js'], function () { - 'use strict'; - return { - setters: [function () {}], - execute: function () { - - - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/manual-chunk-contains-entry-conflict/main.js b/test/chunking-form/samples/deprecated/manual-chunk-contains-entry-conflict/main.js deleted file mode 100644 index 983ead17e5a..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunk-contains-entry-conflict/main.js +++ /dev/null @@ -1,5 +0,0 @@ -import './dep.js'; - -console.log('main'); - -export const value = 42; diff --git a/test/chunking-form/samples/deprecated/manual-chunk-contains-entry-conflict/main2.js b/test/chunking-form/samples/deprecated/manual-chunk-contains-entry-conflict/main2.js deleted file mode 100644 index d6cf3b02443..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunk-contains-entry-conflict/main2.js +++ /dev/null @@ -1 +0,0 @@ -import './dep.js'; diff --git a/test/chunking-form/samples/deprecated/manual-chunk-contains-entry-conflict/outer.js b/test/chunking-form/samples/deprecated/manual-chunk-contains-entry-conflict/outer.js deleted file mode 100644 index 26385b8a3c3..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunk-contains-entry-conflict/outer.js +++ /dev/null @@ -1,3 +0,0 @@ -import './main'; - -console.log('outer'); diff --git a/test/chunking-form/samples/deprecated/manual-chunk-contains-entry-match/_config.js b/test/chunking-form/samples/deprecated/manual-chunk-contains-entry-match/_config.js deleted file mode 100644 index 0265957b69b..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunk-contains-entry-match/_config.js +++ /dev/null @@ -1,13 +0,0 @@ -module.exports = { - description: - 'Identifies the entry chunk with the manual chunk that contains it if the aliases match', - options: { - strictDeprecations: false, - input: { - main: 'main.js' - }, - manualChunks: { - main: ['outer'] - } - } -}; diff --git a/test/chunking-form/samples/deprecated/manual-chunk-contains-entry-match/_expected/amd/main.js b/test/chunking-form/samples/deprecated/manual-chunk-contains-entry-match/_expected/amd/main.js deleted file mode 100644 index fc91f027a0e..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunk-contains-entry-match/_expected/amd/main.js +++ /dev/null @@ -1,13 +0,0 @@ -define(['exports'], function (exports) { 'use strict'; - - console.log('dep'); - - console.log('main'); - - const value = 42; - - exports.value = value; - - Object.defineProperty(exports, '__esModule', { value: true }); - -}); diff --git a/test/chunking-form/samples/deprecated/manual-chunk-contains-entry-match/_expected/cjs/main.js b/test/chunking-form/samples/deprecated/manual-chunk-contains-entry-match/_expected/cjs/main.js deleted file mode 100644 index 5da9ebd5132..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunk-contains-entry-match/_expected/cjs/main.js +++ /dev/null @@ -1,11 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { value: true }); - -console.log('dep'); - -console.log('main'); - -const value = 42; - -exports.value = value; diff --git a/test/chunking-form/samples/deprecated/manual-chunk-contains-entry-match/_expected/es/main.js b/test/chunking-form/samples/deprecated/manual-chunk-contains-entry-match/_expected/es/main.js deleted file mode 100644 index 132b27a8d7c..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunk-contains-entry-match/_expected/es/main.js +++ /dev/null @@ -1,7 +0,0 @@ -console.log('dep'); - -console.log('main'); - -const value = 42; - -export { value }; diff --git a/test/chunking-form/samples/deprecated/manual-chunk-contains-entry-match/_expected/system/main.js b/test/chunking-form/samples/deprecated/manual-chunk-contains-entry-match/_expected/system/main.js deleted file mode 100644 index b92309e3bf3..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunk-contains-entry-match/_expected/system/main.js +++ /dev/null @@ -1,14 +0,0 @@ -System.register([], function (exports) { - 'use strict'; - return { - execute: function () { - - console.log('dep'); - - console.log('main'); - - const value = exports('value', 42); - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/manual-chunk-contains-entry-match/main.js b/test/chunking-form/samples/deprecated/manual-chunk-contains-entry-match/main.js deleted file mode 100644 index 983ead17e5a..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunk-contains-entry-match/main.js +++ /dev/null @@ -1,5 +0,0 @@ -import './dep.js'; - -console.log('main'); - -export const value = 42; diff --git a/test/chunking-form/samples/deprecated/manual-chunk-contains-entry-match/outer.js b/test/chunking-form/samples/deprecated/manual-chunk-contains-entry-match/outer.js deleted file mode 100644 index 26385b8a3c3..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunk-contains-entry-match/outer.js +++ /dev/null @@ -1,3 +0,0 @@ -import './main'; - -console.log('outer'); diff --git a/test/chunking-form/samples/deprecated/manual-chunk-is-entry-conflict/_config.js b/test/chunking-form/samples/deprecated/manual-chunk-is-entry-conflict/_config.js deleted file mode 100644 index e30afc125c2..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunk-is-entry-conflict/_config.js +++ /dev/null @@ -1,13 +0,0 @@ -module.exports = { - description: 'Uses entry alias if manual chunks are entry chunks with different alias', - options: { - strictDeprecations: false, - input: { - main: 'main.js', - main2: 'main2.js' - }, - manualChunks: { - other: ['main'] - } - } -}; diff --git a/test/chunking-form/samples/deprecated/manual-chunk-is-entry-conflict/_expected/amd/main.js b/test/chunking-form/samples/deprecated/manual-chunk-is-entry-conflict/_expected/amd/main.js deleted file mode 100644 index fc91f027a0e..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunk-is-entry-conflict/_expected/amd/main.js +++ /dev/null @@ -1,13 +0,0 @@ -define(['exports'], function (exports) { 'use strict'; - - console.log('dep'); - - console.log('main'); - - const value = 42; - - exports.value = value; - - Object.defineProperty(exports, '__esModule', { value: true }); - -}); diff --git a/test/chunking-form/samples/deprecated/manual-chunk-is-entry-conflict/_expected/amd/main2.js b/test/chunking-form/samples/deprecated/manual-chunk-is-entry-conflict/_expected/amd/main2.js deleted file mode 100644 index e007f54e5e2..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunk-is-entry-conflict/_expected/amd/main2.js +++ /dev/null @@ -1,5 +0,0 @@ -define(['./main'], function (other) { 'use strict'; - - - -}); diff --git a/test/chunking-form/samples/deprecated/manual-chunk-is-entry-conflict/_expected/cjs/main.js b/test/chunking-form/samples/deprecated/manual-chunk-is-entry-conflict/_expected/cjs/main.js deleted file mode 100644 index 5da9ebd5132..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunk-is-entry-conflict/_expected/cjs/main.js +++ /dev/null @@ -1,11 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { value: true }); - -console.log('dep'); - -console.log('main'); - -const value = 42; - -exports.value = value; diff --git a/test/chunking-form/samples/deprecated/manual-chunk-is-entry-conflict/_expected/cjs/main2.js b/test/chunking-form/samples/deprecated/manual-chunk-is-entry-conflict/_expected/cjs/main2.js deleted file mode 100644 index 7ca8a520b06..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunk-is-entry-conflict/_expected/cjs/main2.js +++ /dev/null @@ -1,4 +0,0 @@ -'use strict'; - -require('./main.js'); - diff --git a/test/chunking-form/samples/deprecated/manual-chunk-is-entry-conflict/_expected/es/main.js b/test/chunking-form/samples/deprecated/manual-chunk-is-entry-conflict/_expected/es/main.js deleted file mode 100644 index 132b27a8d7c..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunk-is-entry-conflict/_expected/es/main.js +++ /dev/null @@ -1,7 +0,0 @@ -console.log('dep'); - -console.log('main'); - -const value = 42; - -export { value }; diff --git a/test/chunking-form/samples/deprecated/manual-chunk-is-entry-conflict/_expected/es/main2.js b/test/chunking-form/samples/deprecated/manual-chunk-is-entry-conflict/_expected/es/main2.js deleted file mode 100644 index 859ecc36bb9..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunk-is-entry-conflict/_expected/es/main2.js +++ /dev/null @@ -1 +0,0 @@ -import './main.js'; diff --git a/test/chunking-form/samples/deprecated/manual-chunk-is-entry-conflict/_expected/system/main.js b/test/chunking-form/samples/deprecated/manual-chunk-is-entry-conflict/_expected/system/main.js deleted file mode 100644 index b92309e3bf3..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunk-is-entry-conflict/_expected/system/main.js +++ /dev/null @@ -1,14 +0,0 @@ -System.register([], function (exports) { - 'use strict'; - return { - execute: function () { - - console.log('dep'); - - console.log('main'); - - const value = exports('value', 42); - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/manual-chunk-is-entry-conflict/_expected/system/main2.js b/test/chunking-form/samples/deprecated/manual-chunk-is-entry-conflict/_expected/system/main2.js deleted file mode 100644 index da731958b75..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunk-is-entry-conflict/_expected/system/main2.js +++ /dev/null @@ -1,11 +0,0 @@ -System.register(['./main.js'], function () { - 'use strict'; - return { - setters: [function () {}], - execute: function () { - - - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/manual-chunk-is-entry-conflict/main.js b/test/chunking-form/samples/deprecated/manual-chunk-is-entry-conflict/main.js deleted file mode 100644 index 983ead17e5a..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunk-is-entry-conflict/main.js +++ /dev/null @@ -1,5 +0,0 @@ -import './dep.js'; - -console.log('main'); - -export const value = 42; diff --git a/test/chunking-form/samples/deprecated/manual-chunk-is-entry-conflict/main2.js b/test/chunking-form/samples/deprecated/manual-chunk-is-entry-conflict/main2.js deleted file mode 100644 index d6cf3b02443..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunk-is-entry-conflict/main2.js +++ /dev/null @@ -1 +0,0 @@ -import './dep.js'; diff --git a/test/chunking-form/samples/deprecated/manual-chunk-is-entry-match/_config.js b/test/chunking-form/samples/deprecated/manual-chunk-is-entry-match/_config.js deleted file mode 100644 index 3207916f4f1..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunk-is-entry-match/_config.js +++ /dev/null @@ -1,13 +0,0 @@ -module.exports = { - description: - 'Identifies the entry chunk with the manual chunk that has the same entry if the aliases match', - options: { - strictDeprecations: false, - input: { - main: 'main.js' - }, - manualChunks: { - main: ['main'] - } - } -}; diff --git a/test/chunking-form/samples/deprecated/manual-chunk-is-entry-match/_expected/amd/main.js b/test/chunking-form/samples/deprecated/manual-chunk-is-entry-match/_expected/amd/main.js deleted file mode 100644 index fc91f027a0e..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunk-is-entry-match/_expected/amd/main.js +++ /dev/null @@ -1,13 +0,0 @@ -define(['exports'], function (exports) { 'use strict'; - - console.log('dep'); - - console.log('main'); - - const value = 42; - - exports.value = value; - - Object.defineProperty(exports, '__esModule', { value: true }); - -}); diff --git a/test/chunking-form/samples/deprecated/manual-chunk-is-entry-match/_expected/cjs/main.js b/test/chunking-form/samples/deprecated/manual-chunk-is-entry-match/_expected/cjs/main.js deleted file mode 100644 index 5da9ebd5132..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunk-is-entry-match/_expected/cjs/main.js +++ /dev/null @@ -1,11 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { value: true }); - -console.log('dep'); - -console.log('main'); - -const value = 42; - -exports.value = value; diff --git a/test/chunking-form/samples/deprecated/manual-chunk-is-entry-match/_expected/es/main.js b/test/chunking-form/samples/deprecated/manual-chunk-is-entry-match/_expected/es/main.js deleted file mode 100644 index 132b27a8d7c..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunk-is-entry-match/_expected/es/main.js +++ /dev/null @@ -1,7 +0,0 @@ -console.log('dep'); - -console.log('main'); - -const value = 42; - -export { value }; diff --git a/test/chunking-form/samples/deprecated/manual-chunk-is-entry-match/_expected/system/main.js b/test/chunking-form/samples/deprecated/manual-chunk-is-entry-match/_expected/system/main.js deleted file mode 100644 index b92309e3bf3..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunk-is-entry-match/_expected/system/main.js +++ /dev/null @@ -1,14 +0,0 @@ -System.register([], function (exports) { - 'use strict'; - return { - execute: function () { - - console.log('dep'); - - console.log('main'); - - const value = exports('value', 42); - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/manual-chunk-is-entry-match/main.js b/test/chunking-form/samples/deprecated/manual-chunk-is-entry-match/main.js deleted file mode 100644 index 983ead17e5a..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunk-is-entry-match/main.js +++ /dev/null @@ -1,5 +0,0 @@ -import './dep.js'; - -console.log('main'); - -export const value = 42; diff --git a/test/chunking-form/samples/deprecated/manual-chunks-different-nested/_config.js b/test/chunking-form/samples/deprecated/manual-chunks-different-nested/_config.js deleted file mode 100644 index 9f46a40f134..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks-different-nested/_config.js +++ /dev/null @@ -1,12 +0,0 @@ -module.exports = { - description: 'manual chunks can have other manual chunks as dependencies', - options: { - strictDeprecations: false, - input: ['main.js'], - manualChunks: { - 'manual-outer': ['outer.js'], - 'manual-inner': ['inner.js'], - 'manual-middle': ['middle.js'] - } - } -}; diff --git a/test/chunking-form/samples/deprecated/manual-chunks-different-nested/_expected/amd/generated-manual-inner.js b/test/chunking-form/samples/deprecated/manual-chunks-different-nested/_expected/amd/generated-manual-inner.js deleted file mode 100644 index 5068b5fd910..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks-different-nested/_expected/amd/generated-manual-inner.js +++ /dev/null @@ -1,5 +0,0 @@ -define(function () { 'use strict'; - - console.log('inner'); - -}); diff --git a/test/chunking-form/samples/deprecated/manual-chunks-different-nested/_expected/amd/generated-manual-middle.js b/test/chunking-form/samples/deprecated/manual-chunks-different-nested/_expected/amd/generated-manual-middle.js deleted file mode 100644 index a12cddc2c4f..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks-different-nested/_expected/amd/generated-manual-middle.js +++ /dev/null @@ -1,5 +0,0 @@ -define(['./generated-manual-inner'], function (manualInner) { 'use strict'; - - console.log('middle'); - -}); diff --git a/test/chunking-form/samples/deprecated/manual-chunks-different-nested/_expected/amd/generated-manual-outer.js b/test/chunking-form/samples/deprecated/manual-chunks-different-nested/_expected/amd/generated-manual-outer.js deleted file mode 100644 index 19b33370089..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks-different-nested/_expected/amd/generated-manual-outer.js +++ /dev/null @@ -1,5 +0,0 @@ -define(['./generated-manual-middle'], function (manualMiddle) { 'use strict'; - - console.log('outer'); - -}); diff --git a/test/chunking-form/samples/deprecated/manual-chunks-different-nested/_expected/amd/main.js b/test/chunking-form/samples/deprecated/manual-chunks-different-nested/_expected/amd/main.js deleted file mode 100644 index 28fbd1e66ae..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks-different-nested/_expected/amd/main.js +++ /dev/null @@ -1,5 +0,0 @@ -define(['./generated-manual-outer', './generated-manual-middle', './generated-manual-inner'], function (manualOuter, manualMiddle, manualInner) { 'use strict'; - - console.log('main'); - -}); diff --git a/test/chunking-form/samples/deprecated/manual-chunks-different-nested/_expected/cjs/generated-manual-inner.js b/test/chunking-form/samples/deprecated/manual-chunks-different-nested/_expected/cjs/generated-manual-inner.js deleted file mode 100644 index 02ef883da4e..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks-different-nested/_expected/cjs/generated-manual-inner.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -console.log('inner'); diff --git a/test/chunking-form/samples/deprecated/manual-chunks-different-nested/_expected/cjs/generated-manual-middle.js b/test/chunking-form/samples/deprecated/manual-chunks-different-nested/_expected/cjs/generated-manual-middle.js deleted file mode 100644 index 77da3dd71c1..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks-different-nested/_expected/cjs/generated-manual-middle.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -require('./generated-manual-inner.js'); - -console.log('middle'); diff --git a/test/chunking-form/samples/deprecated/manual-chunks-different-nested/_expected/cjs/generated-manual-outer.js b/test/chunking-form/samples/deprecated/manual-chunks-different-nested/_expected/cjs/generated-manual-outer.js deleted file mode 100644 index 8a4efba721e..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks-different-nested/_expected/cjs/generated-manual-outer.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -require('./generated-manual-middle.js'); - -console.log('outer'); diff --git a/test/chunking-form/samples/deprecated/manual-chunks-different-nested/_expected/cjs/main.js b/test/chunking-form/samples/deprecated/manual-chunks-different-nested/_expected/cjs/main.js deleted file mode 100644 index 70f46474792..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks-different-nested/_expected/cjs/main.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -require('./generated-manual-outer.js'); -require('./generated-manual-middle.js'); -require('./generated-manual-inner.js'); - -console.log('main'); diff --git a/test/chunking-form/samples/deprecated/manual-chunks-different-nested/_expected/es/generated-manual-inner.js b/test/chunking-form/samples/deprecated/manual-chunks-different-nested/_expected/es/generated-manual-inner.js deleted file mode 100644 index 8e1a29ca97f..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks-different-nested/_expected/es/generated-manual-inner.js +++ /dev/null @@ -1 +0,0 @@ -console.log('inner'); diff --git a/test/chunking-form/samples/deprecated/manual-chunks-different-nested/_expected/es/generated-manual-middle.js b/test/chunking-form/samples/deprecated/manual-chunks-different-nested/_expected/es/generated-manual-middle.js deleted file mode 100644 index 247a57bae80..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks-different-nested/_expected/es/generated-manual-middle.js +++ /dev/null @@ -1,3 +0,0 @@ -import './generated-manual-inner.js'; - -console.log('middle'); diff --git a/test/chunking-form/samples/deprecated/manual-chunks-different-nested/_expected/es/generated-manual-outer.js b/test/chunking-form/samples/deprecated/manual-chunks-different-nested/_expected/es/generated-manual-outer.js deleted file mode 100644 index f348b38752c..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks-different-nested/_expected/es/generated-manual-outer.js +++ /dev/null @@ -1,3 +0,0 @@ -import './generated-manual-middle.js'; - -console.log('outer'); diff --git a/test/chunking-form/samples/deprecated/manual-chunks-different-nested/_expected/es/main.js b/test/chunking-form/samples/deprecated/manual-chunks-different-nested/_expected/es/main.js deleted file mode 100644 index 10b9ca2eb9b..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks-different-nested/_expected/es/main.js +++ /dev/null @@ -1,5 +0,0 @@ -import './generated-manual-outer.js'; -import './generated-manual-middle.js'; -import './generated-manual-inner.js'; - -console.log('main'); diff --git a/test/chunking-form/samples/deprecated/manual-chunks-different-nested/_expected/system/generated-manual-inner.js b/test/chunking-form/samples/deprecated/manual-chunks-different-nested/_expected/system/generated-manual-inner.js deleted file mode 100644 index 7079c6deaf2..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks-different-nested/_expected/system/generated-manual-inner.js +++ /dev/null @@ -1,10 +0,0 @@ -System.register([], function () { - 'use strict'; - return { - execute: function () { - - console.log('inner'); - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/manual-chunks-different-nested/_expected/system/generated-manual-middle.js b/test/chunking-form/samples/deprecated/manual-chunks-different-nested/_expected/system/generated-manual-middle.js deleted file mode 100644 index e972910e58e..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks-different-nested/_expected/system/generated-manual-middle.js +++ /dev/null @@ -1,11 +0,0 @@ -System.register(['./generated-manual-inner.js'], function () { - 'use strict'; - return { - setters: [function () {}], - execute: function () { - - console.log('middle'); - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/manual-chunks-different-nested/_expected/system/generated-manual-outer.js b/test/chunking-form/samples/deprecated/manual-chunks-different-nested/_expected/system/generated-manual-outer.js deleted file mode 100644 index 8657192807b..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks-different-nested/_expected/system/generated-manual-outer.js +++ /dev/null @@ -1,11 +0,0 @@ -System.register(['./generated-manual-middle.js'], function () { - 'use strict'; - return { - setters: [function () {}], - execute: function () { - - console.log('outer'); - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/manual-chunks-different-nested/_expected/system/main.js b/test/chunking-form/samples/deprecated/manual-chunks-different-nested/_expected/system/main.js deleted file mode 100644 index 9719fd4976c..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks-different-nested/_expected/system/main.js +++ /dev/null @@ -1,11 +0,0 @@ -System.register(['./generated-manual-outer.js', './generated-manual-middle.js', './generated-manual-inner.js'], function () { - 'use strict'; - return { - setters: [function () {}, function () {}, function () {}], - execute: function () { - - console.log('main'); - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/manual-chunks-different-nested/inner.js b/test/chunking-form/samples/deprecated/manual-chunks-different-nested/inner.js deleted file mode 100644 index 8e1a29ca97f..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks-different-nested/inner.js +++ /dev/null @@ -1 +0,0 @@ -console.log('inner'); diff --git a/test/chunking-form/samples/deprecated/manual-chunks-different-nested/main.js b/test/chunking-form/samples/deprecated/manual-chunks-different-nested/main.js deleted file mode 100644 index b46ebb222d8..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks-different-nested/main.js +++ /dev/null @@ -1,3 +0,0 @@ -import './outer.js'; - -console.log('main'); diff --git a/test/chunking-form/samples/deprecated/manual-chunks-different-nested/middle.js b/test/chunking-form/samples/deprecated/manual-chunks-different-nested/middle.js deleted file mode 100644 index 0073259087e..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks-different-nested/middle.js +++ /dev/null @@ -1,3 +0,0 @@ -import './inner.js'; - -console.log('middle'); diff --git a/test/chunking-form/samples/deprecated/manual-chunks-different-nested/outer.js b/test/chunking-form/samples/deprecated/manual-chunks-different-nested/outer.js deleted file mode 100644 index c77196cec49..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks-different-nested/outer.js +++ /dev/null @@ -1,3 +0,0 @@ -import './middle.js'; - -console.log('outer'); diff --git a/test/chunking-form/samples/deprecated/manual-chunks-dynamic-facades/_config.js b/test/chunking-form/samples/deprecated/manual-chunks-dynamic-facades/_config.js deleted file mode 100644 index 9666b5675d5..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks-dynamic-facades/_config.js +++ /dev/null @@ -1,10 +0,0 @@ -module.exports = { - description: 'creates facades for dynamic manual chunks if necessary', - options: { - strictDeprecations: false, - input: ['main.js'], - manualChunks: { - dynamic: ['dynamic1.js'] - } - } -}; diff --git a/test/chunking-form/samples/deprecated/manual-chunks-dynamic-facades/_expected/amd/generated-dynamic.js b/test/chunking-form/samples/deprecated/manual-chunks-dynamic-facades/_expected/amd/generated-dynamic.js deleted file mode 100644 index 06d0b979512..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks-dynamic-facades/_expected/amd/generated-dynamic.js +++ /dev/null @@ -1,34 +0,0 @@ -define(['exports'], function (exports) { 'use strict'; - - const DEP = 'DEP'; - - const DYNAMIC_2 = 'DYNAMIC_2'; - - var dynamic2 = /*#__PURE__*/Object.freeze({ - __proto__: null, - DYNAMIC_2: DYNAMIC_2 - }); - - const DYNAMIC_3 = 'DYNAMIC_3'; - - var dynamic3 = /*#__PURE__*/Object.freeze({ - __proto__: null, - DYNAMIC_3: DYNAMIC_3 - }); - - const DYNAMIC_1 = 'DYNAMIC_1'; - - var dynamic1 = /*#__PURE__*/Object.freeze({ - __proto__: null, - DYNAMIC_1: DYNAMIC_1, - DEP: DEP, - DYNAMIC_2: DYNAMIC_2, - DYNAMIC_3: DYNAMIC_3 - }); - - exports.DEP = DEP; - exports.dynamic1 = dynamic1; - exports.dynamic2 = dynamic2; - exports.dynamic3 = dynamic3; - -}); diff --git a/test/chunking-form/samples/deprecated/manual-chunks-dynamic-facades/_expected/amd/main.js b/test/chunking-form/samples/deprecated/manual-chunks-dynamic-facades/_expected/amd/main.js deleted file mode 100644 index dd2114e5c49..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks-dynamic-facades/_expected/amd/main.js +++ /dev/null @@ -1,7 +0,0 @@ -define(['require', './generated-dynamic'], function (require, dynamic) { 'use strict'; - - Promise.all([new Promise(function (resolve, reject) { require(['./generated-dynamic'], resolve, reject) }).then(function (n) { return n.dynamic1; }), new Promise(function (resolve, reject) { require(['./generated-dynamic'], resolve, reject) }).then(function (n) { return n.dynamic2; }), new Promise(function (resolve, reject) { require(['./generated-dynamic'], resolve, reject) }).then(function (n) { return n.dynamic3; })]).then( - results => console.log(results, dynamic.DEP) - ); - -}); diff --git a/test/chunking-form/samples/deprecated/manual-chunks-dynamic-facades/_expected/cjs/generated-dynamic.js b/test/chunking-form/samples/deprecated/manual-chunks-dynamic-facades/_expected/cjs/generated-dynamic.js deleted file mode 100644 index 50c556066d4..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks-dynamic-facades/_expected/cjs/generated-dynamic.js +++ /dev/null @@ -1,32 +0,0 @@ -'use strict'; - -const DEP = 'DEP'; - -const DYNAMIC_2 = 'DYNAMIC_2'; - -var dynamic2 = /*#__PURE__*/Object.freeze({ - __proto__: null, - DYNAMIC_2: DYNAMIC_2 -}); - -const DYNAMIC_3 = 'DYNAMIC_3'; - -var dynamic3 = /*#__PURE__*/Object.freeze({ - __proto__: null, - DYNAMIC_3: DYNAMIC_3 -}); - -const DYNAMIC_1 = 'DYNAMIC_1'; - -var dynamic1 = /*#__PURE__*/Object.freeze({ - __proto__: null, - DYNAMIC_1: DYNAMIC_1, - DEP: DEP, - DYNAMIC_2: DYNAMIC_2, - DYNAMIC_3: DYNAMIC_3 -}); - -exports.DEP = DEP; -exports.dynamic1 = dynamic1; -exports.dynamic2 = dynamic2; -exports.dynamic3 = dynamic3; diff --git a/test/chunking-form/samples/deprecated/manual-chunks-dynamic-facades/_expected/cjs/main.js b/test/chunking-form/samples/deprecated/manual-chunks-dynamic-facades/_expected/cjs/main.js deleted file mode 100644 index 6d822d5ed9f..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks-dynamic-facades/_expected/cjs/main.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -var dynamic = require('./generated-dynamic.js'); - -Promise.all([Promise.resolve().then(function () { return require('./generated-dynamic.js'); }).then(function (n) { return n.dynamic1; }), Promise.resolve().then(function () { return require('./generated-dynamic.js'); }).then(function (n) { return n.dynamic2; }), Promise.resolve().then(function () { return require('./generated-dynamic.js'); }).then(function (n) { return n.dynamic3; })]).then( - results => console.log(results, dynamic.DEP) -); diff --git a/test/chunking-form/samples/deprecated/manual-chunks-dynamic-facades/_expected/es/generated-dynamic.js b/test/chunking-form/samples/deprecated/manual-chunks-dynamic-facades/_expected/es/generated-dynamic.js deleted file mode 100644 index 3f031460abc..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks-dynamic-facades/_expected/es/generated-dynamic.js +++ /dev/null @@ -1,27 +0,0 @@ -const DEP = 'DEP'; - -const DYNAMIC_2 = 'DYNAMIC_2'; - -var dynamic2 = /*#__PURE__*/Object.freeze({ - __proto__: null, - DYNAMIC_2: DYNAMIC_2 -}); - -const DYNAMIC_3 = 'DYNAMIC_3'; - -var dynamic3 = /*#__PURE__*/Object.freeze({ - __proto__: null, - DYNAMIC_3: DYNAMIC_3 -}); - -const DYNAMIC_1 = 'DYNAMIC_1'; - -var dynamic1 = /*#__PURE__*/Object.freeze({ - __proto__: null, - DYNAMIC_1: DYNAMIC_1, - DEP: DEP, - DYNAMIC_2: DYNAMIC_2, - DYNAMIC_3: DYNAMIC_3 -}); - -export { DEP as D, dynamic3 as a, dynamic1 as b, dynamic2 as d }; diff --git a/test/chunking-form/samples/deprecated/manual-chunks-dynamic-facades/_expected/es/main.js b/test/chunking-form/samples/deprecated/manual-chunks-dynamic-facades/_expected/es/main.js deleted file mode 100644 index 0ef6f970d6a..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks-dynamic-facades/_expected/es/main.js +++ /dev/null @@ -1,5 +0,0 @@ -import { D as DEP } from './generated-dynamic.js'; - -Promise.all([import('./generated-dynamic.js').then(function (n) { return n.b; }), import('./generated-dynamic.js').then(function (n) { return n.d; }), import('./generated-dynamic.js').then(function (n) { return n.a; })]).then( - results => console.log(results, DEP) -); diff --git a/test/chunking-form/samples/deprecated/manual-chunks-dynamic-facades/_expected/system/generated-dynamic.js b/test/chunking-form/samples/deprecated/manual-chunks-dynamic-facades/_expected/system/generated-dynamic.js deleted file mode 100644 index 768028d36f0..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks-dynamic-facades/_expected/system/generated-dynamic.js +++ /dev/null @@ -1,37 +0,0 @@ -System.register([], function (exports) { - 'use strict'; - return { - execute: function () { - - const DEP = exports('D', 'DEP'); - - const DYNAMIC_2 = 'DYNAMIC_2'; - - var dynamic2 = /*#__PURE__*/Object.freeze({ - __proto__: null, - DYNAMIC_2: DYNAMIC_2 - }); - exports('d', dynamic2); - - const DYNAMIC_3 = 'DYNAMIC_3'; - - var dynamic3 = /*#__PURE__*/Object.freeze({ - __proto__: null, - DYNAMIC_3: DYNAMIC_3 - }); - exports('a', dynamic3); - - const DYNAMIC_1 = 'DYNAMIC_1'; - - var dynamic1 = /*#__PURE__*/Object.freeze({ - __proto__: null, - DYNAMIC_1: DYNAMIC_1, - DEP: DEP, - DYNAMIC_2: DYNAMIC_2, - DYNAMIC_3: DYNAMIC_3 - }); - exports('b', dynamic1); - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/manual-chunks-dynamic-facades/_expected/system/main.js b/test/chunking-form/samples/deprecated/manual-chunks-dynamic-facades/_expected/system/main.js deleted file mode 100644 index 3d78385bd86..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks-dynamic-facades/_expected/system/main.js +++ /dev/null @@ -1,16 +0,0 @@ -System.register(['./generated-dynamic.js'], function (exports, module) { - 'use strict'; - var DEP; - return { - setters: [function (module) { - DEP = module.D; - }], - execute: function () { - - Promise.all([module.import('./generated-dynamic.js').then(function (n) { return n.b; }), module.import('./generated-dynamic.js').then(function (n) { return n.d; }), module.import('./generated-dynamic.js').then(function (n) { return n.a; })]).then( - results => console.log(results, DEP) - ); - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/manual-chunks-dynamic-facades/dep.js b/test/chunking-form/samples/deprecated/manual-chunks-dynamic-facades/dep.js deleted file mode 100644 index 4be514fd761..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks-dynamic-facades/dep.js +++ /dev/null @@ -1 +0,0 @@ -export const DEP = 'DEP'; diff --git a/test/chunking-form/samples/deprecated/manual-chunks-dynamic-facades/dynamic1.js b/test/chunking-form/samples/deprecated/manual-chunks-dynamic-facades/dynamic1.js deleted file mode 100644 index 1591826eaf0..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks-dynamic-facades/dynamic1.js +++ /dev/null @@ -1,4 +0,0 @@ -export * from './dep.js'; -export * from './dynamic2.js'; -export * from './dynamic3.js'; -export const DYNAMIC_1 = 'DYNAMIC_1'; diff --git a/test/chunking-form/samples/deprecated/manual-chunks-dynamic-facades/dynamic2.js b/test/chunking-form/samples/deprecated/manual-chunks-dynamic-facades/dynamic2.js deleted file mode 100644 index 11eeeb42896..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks-dynamic-facades/dynamic2.js +++ /dev/null @@ -1 +0,0 @@ -export const DYNAMIC_2 = 'DYNAMIC_2'; diff --git a/test/chunking-form/samples/deprecated/manual-chunks-dynamic-facades/dynamic3.js b/test/chunking-form/samples/deprecated/manual-chunks-dynamic-facades/dynamic3.js deleted file mode 100644 index 439fa36aab0..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks-dynamic-facades/dynamic3.js +++ /dev/null @@ -1 +0,0 @@ -export const DYNAMIC_3 = 'DYNAMIC_3'; diff --git a/test/chunking-form/samples/deprecated/manual-chunks-dynamic-facades/main.js b/test/chunking-form/samples/deprecated/manual-chunks-dynamic-facades/main.js deleted file mode 100644 index 317e03b17c5..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks-dynamic-facades/main.js +++ /dev/null @@ -1,5 +0,0 @@ -import { DEP } from './dep'; - -Promise.all([import('./dynamic1.js'), import('./dynamic2.js'), import('./dynamic3.js')]).then( - results => console.log(results, DEP) -); diff --git a/test/chunking-form/samples/deprecated/manual-chunks-dynamic-name-conflict/_config.js b/test/chunking-form/samples/deprecated/manual-chunks-dynamic-name-conflict/_config.js deleted file mode 100644 index 28725aa0585..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks-dynamic-name-conflict/_config.js +++ /dev/null @@ -1,10 +0,0 @@ -module.exports = { - description: 'handles name conflicts in manual chunks', - options: { - strictDeprecations: false, - input: ['main.js'], - manualChunks: { - dynamic: ['dynamic1.js'] - } - } -}; diff --git a/test/chunking-form/samples/deprecated/manual-chunks-dynamic-name-conflict/_expected/amd/generated-dynamic.js b/test/chunking-form/samples/deprecated/manual-chunks-dynamic-name-conflict/_expected/amd/generated-dynamic.js deleted file mode 100644 index 076fa7636d8..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks-dynamic-name-conflict/_expected/amd/generated-dynamic.js +++ /dev/null @@ -1,25 +0,0 @@ -define(['exports'], function (exports) { 'use strict'; - - console.log('dynamic2'); - - const DYNAMIC_A = 'DYNAMIC_A'; - const DYNAMIC_B = 'DYNAMIC_B'; - - var dynamic2 = /*#__PURE__*/Object.freeze({ - __proto__: null, - DYNAMIC_A: DYNAMIC_A, - DYNAMIC_B: DYNAMIC_B - }); - - console.log('dynamic1'); - - var dynamic1 = /*#__PURE__*/Object.freeze({ - __proto__: null, - DYNAMIC_B: DYNAMIC_A, - DYNAMIC_A: DYNAMIC_B - }); - - exports.dynamic1 = dynamic1; - exports.dynamic2 = dynamic2; - -}); diff --git a/test/chunking-form/samples/deprecated/manual-chunks-dynamic-name-conflict/_expected/amd/main.js b/test/chunking-form/samples/deprecated/manual-chunks-dynamic-name-conflict/_expected/amd/main.js deleted file mode 100644 index 134e33a9f75..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks-dynamic-name-conflict/_expected/amd/main.js +++ /dev/null @@ -1,6 +0,0 @@ -define(['require'], function (require) { 'use strict'; - - new Promise(function (resolve, reject) { require(['./generated-dynamic'], resolve, reject) }).then(function (n) { return n.dynamic1; }).then(result => console.log(result)); - new Promise(function (resolve, reject) { require(['./generated-dynamic'], resolve, reject) }).then(function (n) { return n.dynamic2; }).then(result => console.log(result)); - -}); diff --git a/test/chunking-form/samples/deprecated/manual-chunks-dynamic-name-conflict/_expected/cjs/generated-dynamic.js b/test/chunking-form/samples/deprecated/manual-chunks-dynamic-name-conflict/_expected/cjs/generated-dynamic.js deleted file mode 100644 index 6051f8db1b3..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks-dynamic-name-conflict/_expected/cjs/generated-dynamic.js +++ /dev/null @@ -1,23 +0,0 @@ -'use strict'; - -console.log('dynamic2'); - -const DYNAMIC_A = 'DYNAMIC_A'; -const DYNAMIC_B = 'DYNAMIC_B'; - -var dynamic2 = /*#__PURE__*/Object.freeze({ - __proto__: null, - DYNAMIC_A: DYNAMIC_A, - DYNAMIC_B: DYNAMIC_B -}); - -console.log('dynamic1'); - -var dynamic1 = /*#__PURE__*/Object.freeze({ - __proto__: null, - DYNAMIC_B: DYNAMIC_A, - DYNAMIC_A: DYNAMIC_B -}); - -exports.dynamic1 = dynamic1; -exports.dynamic2 = dynamic2; diff --git a/test/chunking-form/samples/deprecated/manual-chunks-dynamic-name-conflict/_expected/cjs/main.js b/test/chunking-form/samples/deprecated/manual-chunks-dynamic-name-conflict/_expected/cjs/main.js deleted file mode 100644 index 436abdbbe3d..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks-dynamic-name-conflict/_expected/cjs/main.js +++ /dev/null @@ -1,4 +0,0 @@ -'use strict'; - -Promise.resolve().then(function () { return require('./generated-dynamic.js'); }).then(function (n) { return n.dynamic1; }).then(result => console.log(result)); -Promise.resolve().then(function () { return require('./generated-dynamic.js'); }).then(function (n) { return n.dynamic2; }).then(result => console.log(result)); diff --git a/test/chunking-form/samples/deprecated/manual-chunks-dynamic-name-conflict/_expected/es/generated-dynamic.js b/test/chunking-form/samples/deprecated/manual-chunks-dynamic-name-conflict/_expected/es/generated-dynamic.js deleted file mode 100644 index 34710d6347c..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks-dynamic-name-conflict/_expected/es/generated-dynamic.js +++ /dev/null @@ -1,20 +0,0 @@ -console.log('dynamic2'); - -const DYNAMIC_A = 'DYNAMIC_A'; -const DYNAMIC_B = 'DYNAMIC_B'; - -var dynamic2 = /*#__PURE__*/Object.freeze({ - __proto__: null, - DYNAMIC_A: DYNAMIC_A, - DYNAMIC_B: DYNAMIC_B -}); - -console.log('dynamic1'); - -var dynamic1 = /*#__PURE__*/Object.freeze({ - __proto__: null, - DYNAMIC_B: DYNAMIC_A, - DYNAMIC_A: DYNAMIC_B -}); - -export { dynamic1 as a, dynamic2 as d }; diff --git a/test/chunking-form/samples/deprecated/manual-chunks-dynamic-name-conflict/_expected/es/main.js b/test/chunking-form/samples/deprecated/manual-chunks-dynamic-name-conflict/_expected/es/main.js deleted file mode 100644 index e6906c3f8a2..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks-dynamic-name-conflict/_expected/es/main.js +++ /dev/null @@ -1,2 +0,0 @@ -import('./generated-dynamic.js').then(function (n) { return n.a; }).then(result => console.log(result)); -import('./generated-dynamic.js').then(function (n) { return n.d; }).then(result => console.log(result)); diff --git a/test/chunking-form/samples/deprecated/manual-chunks-dynamic-name-conflict/_expected/system/generated-dynamic.js b/test/chunking-form/samples/deprecated/manual-chunks-dynamic-name-conflict/_expected/system/generated-dynamic.js deleted file mode 100644 index 7b09ab0ef5b..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks-dynamic-name-conflict/_expected/system/generated-dynamic.js +++ /dev/null @@ -1,29 +0,0 @@ -System.register([], function (exports) { - 'use strict'; - return { - execute: function () { - - console.log('dynamic2'); - - const DYNAMIC_A = 'DYNAMIC_A'; - const DYNAMIC_B = 'DYNAMIC_B'; - - var dynamic2 = /*#__PURE__*/Object.freeze({ - __proto__: null, - DYNAMIC_A: DYNAMIC_A, - DYNAMIC_B: DYNAMIC_B - }); - exports('d', dynamic2); - - console.log('dynamic1'); - - var dynamic1 = /*#__PURE__*/Object.freeze({ - __proto__: null, - DYNAMIC_B: DYNAMIC_A, - DYNAMIC_A: DYNAMIC_B - }); - exports('a', dynamic1); - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/manual-chunks-dynamic-name-conflict/_expected/system/main.js b/test/chunking-form/samples/deprecated/manual-chunks-dynamic-name-conflict/_expected/system/main.js deleted file mode 100644 index a59ec2ff8bb..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks-dynamic-name-conflict/_expected/system/main.js +++ /dev/null @@ -1,11 +0,0 @@ -System.register([], function (exports, module) { - 'use strict'; - return { - execute: function () { - - module.import('./generated-dynamic.js').then(function (n) { return n.a; }).then(result => console.log(result)); - module.import('./generated-dynamic.js').then(function (n) { return n.d; }).then(result => console.log(result)); - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/manual-chunks-dynamic-name-conflict/dynamic1.js b/test/chunking-form/samples/deprecated/manual-chunks-dynamic-name-conflict/dynamic1.js deleted file mode 100644 index ee02308ddb4..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks-dynamic-name-conflict/dynamic1.js +++ /dev/null @@ -1,3 +0,0 @@ -console.log('dynamic1'); - -export { DYNAMIC_A as DYNAMIC_B, DYNAMIC_B as DYNAMIC_A } from './dynamic2'; diff --git a/test/chunking-form/samples/deprecated/manual-chunks-dynamic-name-conflict/dynamic2.js b/test/chunking-form/samples/deprecated/manual-chunks-dynamic-name-conflict/dynamic2.js deleted file mode 100644 index 6d087c59d00..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks-dynamic-name-conflict/dynamic2.js +++ /dev/null @@ -1,4 +0,0 @@ -console.log('dynamic2'); - -export const DYNAMIC_A = 'DYNAMIC_A'; -export const DYNAMIC_B = 'DYNAMIC_B'; diff --git a/test/chunking-form/samples/deprecated/manual-chunks-dynamic-name-conflict/main.js b/test/chunking-form/samples/deprecated/manual-chunks-dynamic-name-conflict/main.js deleted file mode 100644 index 9e2abfea069..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks-dynamic-name-conflict/main.js +++ /dev/null @@ -1,2 +0,0 @@ -import('./dynamic1.js').then(result => console.log(result)); -import('./dynamic2.js').then(result => console.log(result)); diff --git a/test/chunking-form/samples/deprecated/manual-chunks-dynamic/_config.js b/test/chunking-form/samples/deprecated/manual-chunks-dynamic/_config.js deleted file mode 100644 index cfb06c43a96..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks-dynamic/_config.js +++ /dev/null @@ -1,10 +0,0 @@ -module.exports = { - description: 'supports dynamic manual chunks', - options: { - strictDeprecations: false, - input: ['main.js'], - manualChunks: { - dynamic: ['dynamic.js'] - } - } -}; diff --git a/test/chunking-form/samples/deprecated/manual-chunks-dynamic/_expected/amd/generated-dynamic.js b/test/chunking-form/samples/deprecated/manual-chunks-dynamic/_expected/amd/generated-dynamic.js deleted file mode 100644 index 94b0e40c8e0..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks-dynamic/_expected/amd/generated-dynamic.js +++ /dev/null @@ -1,7 +0,0 @@ -define(['exports'], function (exports) { 'use strict'; - - const DYNAMIC_USED_BY_A = 'DYNAMIC_USED_BY_A'; - - exports.DYNAMIC_USED_BY_A = DYNAMIC_USED_BY_A; - -}); diff --git a/test/chunking-form/samples/deprecated/manual-chunks-dynamic/_expected/amd/main.js b/test/chunking-form/samples/deprecated/manual-chunks-dynamic/_expected/amd/main.js deleted file mode 100644 index 7ade37c39c9..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks-dynamic/_expected/amd/main.js +++ /dev/null @@ -1,5 +0,0 @@ -define(['require'], function (require) { 'use strict'; - - new Promise(function (resolve, reject) { require(['./generated-dynamic'], resolve, reject) }).then(({DYNAMIC_USED_BY_A}) => console.log(DYNAMIC_USED_BY_A)); - -}); diff --git a/test/chunking-form/samples/deprecated/manual-chunks-dynamic/_expected/cjs/generated-dynamic.js b/test/chunking-form/samples/deprecated/manual-chunks-dynamic/_expected/cjs/generated-dynamic.js deleted file mode 100644 index 28e15f91379..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks-dynamic/_expected/cjs/generated-dynamic.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -const DYNAMIC_USED_BY_A = 'DYNAMIC_USED_BY_A'; - -exports.DYNAMIC_USED_BY_A = DYNAMIC_USED_BY_A; diff --git a/test/chunking-form/samples/deprecated/manual-chunks-dynamic/_expected/cjs/main.js b/test/chunking-form/samples/deprecated/manual-chunks-dynamic/_expected/cjs/main.js deleted file mode 100644 index 48ed2ac4287..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks-dynamic/_expected/cjs/main.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -Promise.resolve().then(function () { return require('./generated-dynamic.js'); }).then(({DYNAMIC_USED_BY_A}) => console.log(DYNAMIC_USED_BY_A)); diff --git a/test/chunking-form/samples/deprecated/manual-chunks-dynamic/_expected/es/generated-dynamic.js b/test/chunking-form/samples/deprecated/manual-chunks-dynamic/_expected/es/generated-dynamic.js deleted file mode 100644 index 4ccf6321419..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks-dynamic/_expected/es/generated-dynamic.js +++ /dev/null @@ -1,3 +0,0 @@ -const DYNAMIC_USED_BY_A = 'DYNAMIC_USED_BY_A'; - -export { DYNAMIC_USED_BY_A }; diff --git a/test/chunking-form/samples/deprecated/manual-chunks-dynamic/_expected/es/main.js b/test/chunking-form/samples/deprecated/manual-chunks-dynamic/_expected/es/main.js deleted file mode 100644 index aefad148dc7..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks-dynamic/_expected/es/main.js +++ /dev/null @@ -1 +0,0 @@ -import('./generated-dynamic.js').then(({DYNAMIC_USED_BY_A}) => console.log(DYNAMIC_USED_BY_A)); diff --git a/test/chunking-form/samples/deprecated/manual-chunks-dynamic/_expected/system/generated-dynamic.js b/test/chunking-form/samples/deprecated/manual-chunks-dynamic/_expected/system/generated-dynamic.js deleted file mode 100644 index cf05be5bb3b..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks-dynamic/_expected/system/generated-dynamic.js +++ /dev/null @@ -1,10 +0,0 @@ -System.register([], function (exports) { - 'use strict'; - return { - execute: function () { - - const DYNAMIC_USED_BY_A = exports('DYNAMIC_USED_BY_A', 'DYNAMIC_USED_BY_A'); - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/manual-chunks-dynamic/_expected/system/main.js b/test/chunking-form/samples/deprecated/manual-chunks-dynamic/_expected/system/main.js deleted file mode 100644 index 5c1d9db7c1e..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks-dynamic/_expected/system/main.js +++ /dev/null @@ -1,10 +0,0 @@ -System.register([], function (exports, module) { - 'use strict'; - return { - execute: function () { - - module.import('./generated-dynamic.js').then(({DYNAMIC_USED_BY_A}) => console.log(DYNAMIC_USED_BY_A)); - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/manual-chunks-dynamic/dynamic.js b/test/chunking-form/samples/deprecated/manual-chunks-dynamic/dynamic.js deleted file mode 100644 index 38cb5406d06..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks-dynamic/dynamic.js +++ /dev/null @@ -1 +0,0 @@ -export const DYNAMIC_USED_BY_A = 'DYNAMIC_USED_BY_A'; \ No newline at end of file diff --git a/test/chunking-form/samples/deprecated/manual-chunks-dynamic/main.js b/test/chunking-form/samples/deprecated/manual-chunks-dynamic/main.js deleted file mode 100644 index c4c5988813a..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks-dynamic/main.js +++ /dev/null @@ -1 +0,0 @@ -import('./dynamic.js').then(({DYNAMIC_USED_BY_A}) => console.log(DYNAMIC_USED_BY_A)); diff --git a/test/chunking-form/samples/deprecated/manual-chunks-function/_config.js b/test/chunking-form/samples/deprecated/manual-chunks-function/_config.js deleted file mode 100644 index 5b225fe7552..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks-function/_config.js +++ /dev/null @@ -1,12 +0,0 @@ -module.exports = { - description: 'allows to define manual chunks via a function', - options: { - strictDeprecations: false, - input: ['main-a'], - manualChunks(id) { - if (id[id.length - 5] === '-') { - return `chunk-${id[id.length - 4]}`; - } - } - } -}; diff --git a/test/chunking-form/samples/deprecated/manual-chunks-function/_expected/amd/generated-chunk-b.js b/test/chunking-form/samples/deprecated/manual-chunks-function/_expected/amd/generated-chunk-b.js deleted file mode 100644 index 234e6a42b0c..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks-function/_expected/amd/generated-chunk-b.js +++ /dev/null @@ -1,7 +0,0 @@ -define(function () { 'use strict'; - - console.log('dep2'); - - console.log('dep-b'); - -}); diff --git a/test/chunking-form/samples/deprecated/manual-chunks-function/_expected/amd/generated-chunk-c.js b/test/chunking-form/samples/deprecated/manual-chunks-function/_expected/amd/generated-chunk-c.js deleted file mode 100644 index d62075790ea..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks-function/_expected/amd/generated-chunk-c.js +++ /dev/null @@ -1,5 +0,0 @@ -define(['./generated-chunk-b'], function (chunkB) { 'use strict'; - - console.log('dep-c'); - -}); diff --git a/test/chunking-form/samples/deprecated/manual-chunks-function/_expected/amd/main-a.js b/test/chunking-form/samples/deprecated/manual-chunks-function/_expected/amd/main-a.js deleted file mode 100644 index 35ee425f7c8..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks-function/_expected/amd/main-a.js +++ /dev/null @@ -1,9 +0,0 @@ -define(['./generated-chunk-c', './generated-chunk-b'], function (chunkC, chunkB) { 'use strict'; - - console.log('dep1'); - - console.log('dep-a'); - - console.log('main-a'); - -}); diff --git a/test/chunking-form/samples/deprecated/manual-chunks-function/_expected/cjs/generated-chunk-b.js b/test/chunking-form/samples/deprecated/manual-chunks-function/_expected/cjs/generated-chunk-b.js deleted file mode 100644 index 51b3d3e3d98..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks-function/_expected/cjs/generated-chunk-b.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -console.log('dep2'); - -console.log('dep-b'); diff --git a/test/chunking-form/samples/deprecated/manual-chunks-function/_expected/cjs/generated-chunk-c.js b/test/chunking-form/samples/deprecated/manual-chunks-function/_expected/cjs/generated-chunk-c.js deleted file mode 100644 index d8349602bd6..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks-function/_expected/cjs/generated-chunk-c.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -require('./generated-chunk-b.js'); - -console.log('dep-c'); diff --git a/test/chunking-form/samples/deprecated/manual-chunks-function/_expected/cjs/main-a.js b/test/chunking-form/samples/deprecated/manual-chunks-function/_expected/cjs/main-a.js deleted file mode 100644 index 2d8f820fd93..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks-function/_expected/cjs/main-a.js +++ /dev/null @@ -1,10 +0,0 @@ -'use strict'; - -require('./generated-chunk-c.js'); -require('./generated-chunk-b.js'); - -console.log('dep1'); - -console.log('dep-a'); - -console.log('main-a'); diff --git a/test/chunking-form/samples/deprecated/manual-chunks-function/_expected/es/generated-chunk-b.js b/test/chunking-form/samples/deprecated/manual-chunks-function/_expected/es/generated-chunk-b.js deleted file mode 100644 index 16fb2a90267..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks-function/_expected/es/generated-chunk-b.js +++ /dev/null @@ -1,3 +0,0 @@ -console.log('dep2'); - -console.log('dep-b'); diff --git a/test/chunking-form/samples/deprecated/manual-chunks-function/_expected/es/generated-chunk-c.js b/test/chunking-form/samples/deprecated/manual-chunks-function/_expected/es/generated-chunk-c.js deleted file mode 100644 index 78ee7d95de5..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks-function/_expected/es/generated-chunk-c.js +++ /dev/null @@ -1,3 +0,0 @@ -import './generated-chunk-b.js'; - -console.log('dep-c'); diff --git a/test/chunking-form/samples/deprecated/manual-chunks-function/_expected/es/main-a.js b/test/chunking-form/samples/deprecated/manual-chunks-function/_expected/es/main-a.js deleted file mode 100644 index d3864b7146c..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks-function/_expected/es/main-a.js +++ /dev/null @@ -1,8 +0,0 @@ -import './generated-chunk-c.js'; -import './generated-chunk-b.js'; - -console.log('dep1'); - -console.log('dep-a'); - -console.log('main-a'); diff --git a/test/chunking-form/samples/deprecated/manual-chunks-function/_expected/system/generated-chunk-b.js b/test/chunking-form/samples/deprecated/manual-chunks-function/_expected/system/generated-chunk-b.js deleted file mode 100644 index fabf038cbaa..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks-function/_expected/system/generated-chunk-b.js +++ /dev/null @@ -1,12 +0,0 @@ -System.register([], function () { - 'use strict'; - return { - execute: function () { - - console.log('dep2'); - - console.log('dep-b'); - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/manual-chunks-function/_expected/system/generated-chunk-c.js b/test/chunking-form/samples/deprecated/manual-chunks-function/_expected/system/generated-chunk-c.js deleted file mode 100644 index 4cd41ad57b6..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks-function/_expected/system/generated-chunk-c.js +++ /dev/null @@ -1,11 +0,0 @@ -System.register(['./generated-chunk-b.js'], function () { - 'use strict'; - return { - setters: [function () {}], - execute: function () { - - console.log('dep-c'); - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/manual-chunks-function/_expected/system/main-a.js b/test/chunking-form/samples/deprecated/manual-chunks-function/_expected/system/main-a.js deleted file mode 100644 index c897b06437a..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks-function/_expected/system/main-a.js +++ /dev/null @@ -1,15 +0,0 @@ -System.register(['./generated-chunk-c.js', './generated-chunk-b.js'], function () { - 'use strict'; - return { - setters: [function () {}, function () {}], - execute: function () { - - console.log('dep1'); - - console.log('dep-a'); - - console.log('main-a'); - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/manual-chunks-function/dep-a.js b/test/chunking-form/samples/deprecated/manual-chunks-function/dep-a.js deleted file mode 100644 index 5cf180c1404..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks-function/dep-a.js +++ /dev/null @@ -1,4 +0,0 @@ -import './dep-c'; -import './dep1'; - -console.log('dep-a'); diff --git a/test/chunking-form/samples/deprecated/manual-chunks-function/dep-b.js b/test/chunking-form/samples/deprecated/manual-chunks-function/dep-b.js deleted file mode 100644 index 67c590f583e..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks-function/dep-b.js +++ /dev/null @@ -1,3 +0,0 @@ -import './dep2'; - -console.log('dep-b'); diff --git a/test/chunking-form/samples/deprecated/manual-chunks-function/dep-c.js b/test/chunking-form/samples/deprecated/manual-chunks-function/dep-c.js deleted file mode 100644 index 3934b0ad90e..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks-function/dep-c.js +++ /dev/null @@ -1,3 +0,0 @@ -import './dep2'; - -console.log('dep-c'); diff --git a/test/chunking-form/samples/deprecated/manual-chunks-function/dep1.js b/test/chunking-form/samples/deprecated/manual-chunks-function/dep1.js deleted file mode 100644 index 6aa6066cec9..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks-function/dep1.js +++ /dev/null @@ -1 +0,0 @@ -console.log('dep1'); diff --git a/test/chunking-form/samples/deprecated/manual-chunks-function/dep2.js b/test/chunking-form/samples/deprecated/manual-chunks-function/dep2.js deleted file mode 100644 index f5325d80e8a..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks-function/dep2.js +++ /dev/null @@ -1 +0,0 @@ -console.log('dep2'); diff --git a/test/chunking-form/samples/deprecated/manual-chunks-function/main-a.js b/test/chunking-form/samples/deprecated/manual-chunks-function/main-a.js deleted file mode 100644 index cf97f330a79..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks-function/main-a.js +++ /dev/null @@ -1,4 +0,0 @@ -import './dep-a'; -import './dep-b'; - -console.log('main-a'); diff --git a/test/chunking-form/samples/deprecated/manual-chunks-nested/_config.js b/test/chunking-form/samples/deprecated/manual-chunks-nested/_config.js deleted file mode 100644 index 20ea0b64d16..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks-nested/_config.js +++ /dev/null @@ -1,10 +0,0 @@ -module.exports = { - description: 'manual chunks can contain nested modules', - options: { - strictDeprecations: false, - input: ['main.js'], - manualChunks: { - manual: ['middle.js', 'inner.js', 'outer.js'] - } - } -}; diff --git a/test/chunking-form/samples/deprecated/manual-chunks-nested/_expected/amd/generated-manual.js b/test/chunking-form/samples/deprecated/manual-chunks-nested/_expected/amd/generated-manual.js deleted file mode 100644 index e81d58f94e9..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks-nested/_expected/amd/generated-manual.js +++ /dev/null @@ -1,9 +0,0 @@ -define(function () { 'use strict'; - - console.log('inner'); - - console.log('middle'); - - console.log('outer'); - -}); diff --git a/test/chunking-form/samples/deprecated/manual-chunks-nested/_expected/amd/main.js b/test/chunking-form/samples/deprecated/manual-chunks-nested/_expected/amd/main.js deleted file mode 100644 index c9a0d54be11..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks-nested/_expected/amd/main.js +++ /dev/null @@ -1,5 +0,0 @@ -define(['./generated-manual'], function (manual) { 'use strict'; - - console.log('main'); - -}); diff --git a/test/chunking-form/samples/deprecated/manual-chunks-nested/_expected/cjs/generated-manual.js b/test/chunking-form/samples/deprecated/manual-chunks-nested/_expected/cjs/generated-manual.js deleted file mode 100644 index 3ce3b1a69a1..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks-nested/_expected/cjs/generated-manual.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -console.log('inner'); - -console.log('middle'); - -console.log('outer'); diff --git a/test/chunking-form/samples/deprecated/manual-chunks-nested/_expected/es/generated-manual.js b/test/chunking-form/samples/deprecated/manual-chunks-nested/_expected/es/generated-manual.js deleted file mode 100644 index 7abdcd7f151..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks-nested/_expected/es/generated-manual.js +++ /dev/null @@ -1,5 +0,0 @@ -console.log('inner'); - -console.log('middle'); - -console.log('outer'); diff --git a/test/chunking-form/samples/deprecated/manual-chunks-nested/_expected/system/generated-manual.js b/test/chunking-form/samples/deprecated/manual-chunks-nested/_expected/system/generated-manual.js deleted file mode 100644 index b297489bbda..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks-nested/_expected/system/generated-manual.js +++ /dev/null @@ -1,14 +0,0 @@ -System.register([], function () { - 'use strict'; - return { - execute: function () { - - console.log('inner'); - - console.log('middle'); - - console.log('outer'); - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/manual-chunks-nested/_expected/system/main.js b/test/chunking-form/samples/deprecated/manual-chunks-nested/_expected/system/main.js deleted file mode 100644 index a1d452ebaf8..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks-nested/_expected/system/main.js +++ /dev/null @@ -1,11 +0,0 @@ -System.register(['./generated-manual.js'], function () { - 'use strict'; - return { - setters: [function () {}], - execute: function () { - - console.log('main'); - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/manual-chunks-nested/inner.js b/test/chunking-form/samples/deprecated/manual-chunks-nested/inner.js deleted file mode 100644 index 8e1a29ca97f..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks-nested/inner.js +++ /dev/null @@ -1 +0,0 @@ -console.log('inner'); diff --git a/test/chunking-form/samples/deprecated/manual-chunks-nested/main.js b/test/chunking-form/samples/deprecated/manual-chunks-nested/main.js deleted file mode 100644 index b46ebb222d8..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks-nested/main.js +++ /dev/null @@ -1,3 +0,0 @@ -import './outer.js'; - -console.log('main'); diff --git a/test/chunking-form/samples/deprecated/manual-chunks-nested/middle.js b/test/chunking-form/samples/deprecated/manual-chunks-nested/middle.js deleted file mode 100644 index 0073259087e..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks-nested/middle.js +++ /dev/null @@ -1,3 +0,0 @@ -import './inner.js'; - -console.log('middle'); diff --git a/test/chunking-form/samples/deprecated/manual-chunks-nested/outer.js b/test/chunking-form/samples/deprecated/manual-chunks-nested/outer.js deleted file mode 100644 index c77196cec49..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks-nested/outer.js +++ /dev/null @@ -1,3 +0,0 @@ -import './middle.js'; - -console.log('outer'); diff --git a/test/chunking-form/samples/deprecated/manual-chunks/_config.js b/test/chunking-form/samples/deprecated/manual-chunks/_config.js deleted file mode 100644 index 626186e9b89..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks/_config.js +++ /dev/null @@ -1,11 +0,0 @@ -module.exports = { - description: 'manual chunks support', - options: { - strictDeprecations: false, - input: ['main.js'], - manualChunks: { - lib1: ['lib1.js'], - deps2and3: ['dep2.js', 'dep3.js'] - } - } -}; diff --git a/test/chunking-form/samples/deprecated/manual-chunks/_expected/amd/generated-deps2and3.js b/test/chunking-form/samples/deprecated/manual-chunks/_expected/amd/generated-deps2and3.js deleted file mode 100644 index 603811d8ecc..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks/_expected/amd/generated-deps2and3.js +++ /dev/null @@ -1,20 +0,0 @@ -define(['exports', './generated-lib1'], function (exports, lib1) { 'use strict'; - - function fn$2 () { - console.log('lib2 fn'); - } - - function fn$1 () { - fn$2(); - console.log('dep2 fn'); - } - - function fn () { - lib1.fn(); - console.log('dep3 fn'); - } - - exports.fn = fn$1; - exports.fn$1 = fn; - -}); diff --git a/test/chunking-form/samples/deprecated/manual-chunks/_expected/amd/generated-lib1.js b/test/chunking-form/samples/deprecated/manual-chunks/_expected/amd/generated-lib1.js deleted file mode 100644 index 8ee6361f5e4..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks/_expected/amd/generated-lib1.js +++ /dev/null @@ -1,9 +0,0 @@ -define(['exports'], function (exports) { 'use strict'; - - function fn () { - console.log('lib1 fn'); - } - - exports.fn = fn; - -}); diff --git a/test/chunking-form/samples/deprecated/manual-chunks/_expected/amd/main.js b/test/chunking-form/samples/deprecated/manual-chunks/_expected/amd/main.js deleted file mode 100644 index e636d3d3dd1..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks/_expected/amd/main.js +++ /dev/null @@ -1,17 +0,0 @@ -define(['./generated-deps2and3', './generated-lib1'], function (deps2and3, lib1) { 'use strict'; - - function fn () { - console.log('dep1 fn'); - } - - class Main { - constructor () { - fn(); - deps2and3.fn(); - deps2and3.fn$1(); - } - } - - return Main; - -}); diff --git a/test/chunking-form/samples/deprecated/manual-chunks/_expected/cjs/generated-deps2and3.js b/test/chunking-form/samples/deprecated/manual-chunks/_expected/cjs/generated-deps2and3.js deleted file mode 100644 index b9087cf6bb2..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks/_expected/cjs/generated-deps2and3.js +++ /dev/null @@ -1,20 +0,0 @@ -'use strict'; - -var lib1 = require('./generated-lib1.js'); - -function fn$2 () { - console.log('lib2 fn'); -} - -function fn$1 () { - fn$2(); - console.log('dep2 fn'); -} - -function fn () { - lib1.fn(); - console.log('dep3 fn'); -} - -exports.fn = fn$1; -exports.fn$1 = fn; diff --git a/test/chunking-form/samples/deprecated/manual-chunks/_expected/cjs/generated-lib1.js b/test/chunking-form/samples/deprecated/manual-chunks/_expected/cjs/generated-lib1.js deleted file mode 100644 index 6a9d99129d3..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks/_expected/cjs/generated-lib1.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -function fn () { - console.log('lib1 fn'); -} - -exports.fn = fn; diff --git a/test/chunking-form/samples/deprecated/manual-chunks/_expected/cjs/main.js b/test/chunking-form/samples/deprecated/manual-chunks/_expected/cjs/main.js deleted file mode 100644 index 2a68746bab6..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks/_expected/cjs/main.js +++ /dev/null @@ -1,18 +0,0 @@ -'use strict'; - -var deps2and3 = require('./generated-deps2and3.js'); -require('./generated-lib1.js'); - -function fn () { - console.log('dep1 fn'); -} - -class Main { - constructor () { - fn(); - deps2and3.fn(); - deps2and3.fn$1(); - } -} - -module.exports = Main; diff --git a/test/chunking-form/samples/deprecated/manual-chunks/_expected/es/generated-deps2and3.js b/test/chunking-form/samples/deprecated/manual-chunks/_expected/es/generated-deps2and3.js deleted file mode 100644 index 7e3f8acc1e9..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks/_expected/es/generated-deps2and3.js +++ /dev/null @@ -1,17 +0,0 @@ -import { f as fn$3 } from './generated-lib1.js'; - -function fn$2 () { - console.log('lib2 fn'); -} - -function fn$1 () { - fn$2(); - console.log('dep2 fn'); -} - -function fn () { - fn$3(); - console.log('dep3 fn'); -} - -export { fn as a, fn$1 as f }; diff --git a/test/chunking-form/samples/deprecated/manual-chunks/_expected/es/generated-lib1.js b/test/chunking-form/samples/deprecated/manual-chunks/_expected/es/generated-lib1.js deleted file mode 100644 index ae5cdca1483..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks/_expected/es/generated-lib1.js +++ /dev/null @@ -1,5 +0,0 @@ -function fn () { - console.log('lib1 fn'); -} - -export { fn as f }; diff --git a/test/chunking-form/samples/deprecated/manual-chunks/_expected/es/main.js b/test/chunking-form/samples/deprecated/manual-chunks/_expected/es/main.js deleted file mode 100644 index 55591e37b6a..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks/_expected/es/main.js +++ /dev/null @@ -1,16 +0,0 @@ -import { f as fn$1, a as fn$2 } from './generated-deps2and3.js'; -import './generated-lib1.js'; - -function fn () { - console.log('dep1 fn'); -} - -class Main { - constructor () { - fn(); - fn$1(); - fn$2(); - } -} - -export default Main; diff --git a/test/chunking-form/samples/deprecated/manual-chunks/_expected/system/generated-deps2and3.js b/test/chunking-form/samples/deprecated/manual-chunks/_expected/system/generated-deps2and3.js deleted file mode 100644 index f76d52e19be..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks/_expected/system/generated-deps2and3.js +++ /dev/null @@ -1,31 +0,0 @@ -System.register(['./generated-lib1.js'], function (exports) { - 'use strict'; - var fn$3; - return { - setters: [function (module) { - fn$3 = module.f; - }], - execute: function () { - - exports({ - a: fn, - f: fn$1 - }); - - function fn$2 () { - console.log('lib2 fn'); - } - - function fn$1 () { - fn$2(); - console.log('dep2 fn'); - } - - function fn () { - fn$3(); - console.log('dep3 fn'); - } - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/manual-chunks/_expected/system/generated-lib1.js b/test/chunking-form/samples/deprecated/manual-chunks/_expected/system/generated-lib1.js deleted file mode 100644 index 46e60ceba06..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks/_expected/system/generated-lib1.js +++ /dev/null @@ -1,14 +0,0 @@ -System.register([], function (exports) { - 'use strict'; - return { - execute: function () { - - exports('f', fn); - - function fn () { - console.log('lib1 fn'); - } - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/manual-chunks/_expected/system/main.js b/test/chunking-form/samples/deprecated/manual-chunks/_expected/system/main.js deleted file mode 100644 index b9ce4867e2b..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks/_expected/system/main.js +++ /dev/null @@ -1,25 +0,0 @@ -System.register(['./generated-deps2and3.js', './generated-lib1.js'], function (exports) { - 'use strict'; - var fn$1, fn$2; - return { - setters: [function (module) { - fn$1 = module.f; - fn$2 = module.a; - }, function () {}], - execute: function () { - - function fn () { - console.log('dep1 fn'); - } - - class Main { - constructor () { - fn(); - fn$1(); - fn$2(); - } - } exports('default', Main); - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/manual-chunks/dep1.js b/test/chunking-form/samples/deprecated/manual-chunks/dep1.js deleted file mode 100644 index b67d0bbb2c1..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks/dep1.js +++ /dev/null @@ -1,3 +0,0 @@ -export function fn () { - console.log('dep1 fn'); -} \ No newline at end of file diff --git a/test/chunking-form/samples/deprecated/manual-chunks/dep2.js b/test/chunking-form/samples/deprecated/manual-chunks/dep2.js deleted file mode 100644 index 1549fc1644c..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks/dep2.js +++ /dev/null @@ -1,6 +0,0 @@ -import { fn as libfn } from './lib2.js'; - -export function fn () { - libfn(); - console.log('dep2 fn'); -} \ No newline at end of file diff --git a/test/chunking-form/samples/deprecated/manual-chunks/dep3.js b/test/chunking-form/samples/deprecated/manual-chunks/dep3.js deleted file mode 100644 index 4e32222106a..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks/dep3.js +++ /dev/null @@ -1,8 +0,0 @@ -import { fn as libfn, treeshaked } from './lib1.js'; - -export function fn () { - libfn(); - console.log('dep3 fn'); -} - -export default treeshaked; \ No newline at end of file diff --git a/test/chunking-form/samples/deprecated/manual-chunks/lib1.js b/test/chunking-form/samples/deprecated/manual-chunks/lib1.js deleted file mode 100644 index 5ccf83b357e..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks/lib1.js +++ /dev/null @@ -1,7 +0,0 @@ -export function fn () { - console.log('lib1 fn'); -} - -export function treeshaked () { - console.log('this is tree shaken!'); -} \ No newline at end of file diff --git a/test/chunking-form/samples/deprecated/manual-chunks/lib2.js b/test/chunking-form/samples/deprecated/manual-chunks/lib2.js deleted file mode 100644 index 2d6d2cf0852..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks/lib2.js +++ /dev/null @@ -1,3 +0,0 @@ -export function fn () { - console.log('lib2 fn'); -} \ No newline at end of file diff --git a/test/chunking-form/samples/deprecated/manual-chunks/main.js b/test/chunking-form/samples/deprecated/manual-chunks/main.js deleted file mode 100644 index d65cf01a5ff..00000000000 --- a/test/chunking-form/samples/deprecated/manual-chunks/main.js +++ /dev/null @@ -1,15 +0,0 @@ -import { fn } from './dep1.js'; -import { fn as fn2 } from './dep2.js'; -import { fn as fn3, default as treeshaked } from './dep3.js'; - -if (false) { - treeshaked(); -} - -export default class Main { - constructor () { - fn(); - fn2(); - fn3(); - } -} \ No newline at end of file diff --git a/test/chunking-form/samples/deprecated/missing-export-reused-deconflicting/_config.js b/test/chunking-form/samples/deprecated/missing-export-reused-deconflicting/_config.js deleted file mode 100644 index 23bb4b220e9..00000000000 --- a/test/chunking-form/samples/deprecated/missing-export-reused-deconflicting/_config.js +++ /dev/null @@ -1,10 +0,0 @@ -module.exports = { - description: 'handles using dependencies with shimmed missing exports as ', - expectedWarnings: ['SHIMMED_EXPORT'], - options: { - strictDeprecations: false, - input: ['main.js'], - preserveModules: true, - shimMissingExports: true - } -}; diff --git a/test/chunking-form/samples/deprecated/missing-export-reused-deconflicting/_expected/amd/dep1.js b/test/chunking-form/samples/deprecated/missing-export-reused-deconflicting/_expected/amd/dep1.js deleted file mode 100644 index 4e6617810fb..00000000000 --- a/test/chunking-form/samples/deprecated/missing-export-reused-deconflicting/_expected/amd/dep1.js +++ /dev/null @@ -1,19 +0,0 @@ -define(['exports'], function (exports) { 'use strict'; - - var _missingExportShim = void 0; - - console.log('This is the output when a missing export is used internally but not reexported'); - - function almostUseUnused(useIt) { - if (useIt) { - console.log(_missingExportShim); - } - } - - almostUseUnused(false); - - exports.missing1 = _missingExportShim; - - Object.defineProperty(exports, '__esModule', { value: true }); - -}); diff --git a/test/chunking-form/samples/deprecated/missing-export-reused-deconflicting/_expected/amd/dep2.js b/test/chunking-form/samples/deprecated/missing-export-reused-deconflicting/_expected/amd/dep2.js deleted file mode 100644 index c9382183868..00000000000 --- a/test/chunking-form/samples/deprecated/missing-export-reused-deconflicting/_expected/amd/dep2.js +++ /dev/null @@ -1,16 +0,0 @@ -define(['exports'], function (exports) { 'use strict'; - - var _missingExportShim = void 0; - - console.log('This is the output when a missing export is reexported'); - - var _missingExportShim$1 = void 0; - - console.log(_missingExportShim$1); - - exports.missing2 = _missingExportShim; - exports.previousShimmedExport = _missingExportShim$1; - - Object.defineProperty(exports, '__esModule', { value: true }); - -}); diff --git a/test/chunking-form/samples/deprecated/missing-export-reused-deconflicting/_expected/amd/main.js b/test/chunking-form/samples/deprecated/missing-export-reused-deconflicting/_expected/amd/main.js deleted file mode 100644 index ec4beefe55b..00000000000 --- a/test/chunking-form/samples/deprecated/missing-export-reused-deconflicting/_expected/amd/main.js +++ /dev/null @@ -1,5 +0,0 @@ -define(['./dep1', './dep2'], function (dep1, dep2) { 'use strict'; - - console.log(dep1.missing1, dep2.missing2, dep2.previousShimmedExport); - -}); diff --git a/test/chunking-form/samples/deprecated/missing-export-reused-deconflicting/_expected/cjs/dep1.js b/test/chunking-form/samples/deprecated/missing-export-reused-deconflicting/_expected/cjs/dep1.js deleted file mode 100644 index 58c566f2849..00000000000 --- a/test/chunking-form/samples/deprecated/missing-export-reused-deconflicting/_expected/cjs/dep1.js +++ /dev/null @@ -1,17 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { value: true }); - -var _missingExportShim = void 0; - -console.log('This is the output when a missing export is used internally but not reexported'); - -function almostUseUnused(useIt) { - if (useIt) { - console.log(_missingExportShim); - } -} - -almostUseUnused(false); - -exports.missing1 = _missingExportShim; diff --git a/test/chunking-form/samples/deprecated/missing-export-reused-deconflicting/_expected/cjs/dep2.js b/test/chunking-form/samples/deprecated/missing-export-reused-deconflicting/_expected/cjs/dep2.js deleted file mode 100644 index 8a01d991453..00000000000 --- a/test/chunking-form/samples/deprecated/missing-export-reused-deconflicting/_expected/cjs/dep2.js +++ /dev/null @@ -1,14 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { value: true }); - -var _missingExportShim = void 0; - -console.log('This is the output when a missing export is reexported'); - -var _missingExportShim$1 = void 0; - -console.log(_missingExportShim$1); - -exports.missing2 = _missingExportShim; -exports.previousShimmedExport = _missingExportShim$1; diff --git a/test/chunking-form/samples/deprecated/missing-export-reused-deconflicting/_expected/cjs/main.js b/test/chunking-form/samples/deprecated/missing-export-reused-deconflicting/_expected/cjs/main.js deleted file mode 100644 index 0a8ed0c591c..00000000000 --- a/test/chunking-form/samples/deprecated/missing-export-reused-deconflicting/_expected/cjs/main.js +++ /dev/null @@ -1,6 +0,0 @@ -'use strict'; - -var dep1 = require('./dep1.js'); -var dep2 = require('./dep2.js'); - -console.log(dep1.missing1, dep2.missing2, dep2.previousShimmedExport); diff --git a/test/chunking-form/samples/deprecated/missing-export-reused-deconflicting/_expected/es/dep1.js b/test/chunking-form/samples/deprecated/missing-export-reused-deconflicting/_expected/es/dep1.js deleted file mode 100644 index 99f4196bf72..00000000000 --- a/test/chunking-form/samples/deprecated/missing-export-reused-deconflicting/_expected/es/dep1.js +++ /dev/null @@ -1,13 +0,0 @@ -var _missingExportShim = void 0; - -console.log('This is the output when a missing export is used internally but not reexported'); - -function almostUseUnused(useIt) { - if (useIt) { - console.log(_missingExportShim); - } -} - -almostUseUnused(false); - -export { _missingExportShim as missing1 }; diff --git a/test/chunking-form/samples/deprecated/missing-export-reused-deconflicting/_expected/es/dep2.js b/test/chunking-form/samples/deprecated/missing-export-reused-deconflicting/_expected/es/dep2.js deleted file mode 100644 index 1957fef7ba9..00000000000 --- a/test/chunking-form/samples/deprecated/missing-export-reused-deconflicting/_expected/es/dep2.js +++ /dev/null @@ -1,9 +0,0 @@ -var _missingExportShim = void 0; - -console.log('This is the output when a missing export is reexported'); - -var _missingExportShim$1 = void 0; - -console.log(_missingExportShim$1); - -export { _missingExportShim as missing2, _missingExportShim$1 as previousShimmedExport }; diff --git a/test/chunking-form/samples/deprecated/missing-export-reused-deconflicting/_expected/es/main.js b/test/chunking-form/samples/deprecated/missing-export-reused-deconflicting/_expected/es/main.js deleted file mode 100644 index ea2616a1c8c..00000000000 --- a/test/chunking-form/samples/deprecated/missing-export-reused-deconflicting/_expected/es/main.js +++ /dev/null @@ -1,4 +0,0 @@ -import { missing1 as _missingExportShim } from './dep1.js'; -import { missing2 as _missingExportShim$1, previousShimmedExport as _missingExportShim$2 } from './dep2.js'; - -console.log(_missingExportShim, _missingExportShim$1, _missingExportShim$2); diff --git a/test/chunking-form/samples/deprecated/missing-export-reused-deconflicting/_expected/system/dep1.js b/test/chunking-form/samples/deprecated/missing-export-reused-deconflicting/_expected/system/dep1.js deleted file mode 100644 index 292047e5ff6..00000000000 --- a/test/chunking-form/samples/deprecated/missing-export-reused-deconflicting/_expected/system/dep1.js +++ /dev/null @@ -1,22 +0,0 @@ -System.register([], function (exports) { - 'use strict'; - return { - execute: function () { - - var _missingExportShim = void 0; - - console.log('This is the output when a missing export is used internally but not reexported'); - - function almostUseUnused(useIt) { - if (useIt) { - console.log(_missingExportShim); - } - } - - almostUseUnused(false); - - exports('missing1', _missingExportShim); - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/missing-export-reused-deconflicting/_expected/system/dep2.js b/test/chunking-form/samples/deprecated/missing-export-reused-deconflicting/_expected/system/dep2.js deleted file mode 100644 index da8178d1d7f..00000000000 --- a/test/chunking-form/samples/deprecated/missing-export-reused-deconflicting/_expected/system/dep2.js +++ /dev/null @@ -1,18 +0,0 @@ -System.register([], function (exports) { - 'use strict'; - return { - execute: function () { - - var _missingExportShim = void 0; - - console.log('This is the output when a missing export is reexported'); - - var _missingExportShim$1 = exports('previousShimmedExport', void 0); - - console.log(_missingExportShim$1); - - exports('missing2', _missingExportShim); - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/missing-export-reused-deconflicting/_expected/system/main.js b/test/chunking-form/samples/deprecated/missing-export-reused-deconflicting/_expected/system/main.js deleted file mode 100644 index fa94551b2ef..00000000000 --- a/test/chunking-form/samples/deprecated/missing-export-reused-deconflicting/_expected/system/main.js +++ /dev/null @@ -1,17 +0,0 @@ -System.register(['./dep1.js', './dep2.js'], function () { - 'use strict'; - var _missingExportShim, _missingExportShim$1, _missingExportShim$2; - return { - setters: [function (module) { - _missingExportShim = module.missing1; - }, function (module) { - _missingExportShim$1 = module.missing2; - _missingExportShim$2 = module.previousShimmedExport; - }], - execute: function () { - - console.log(_missingExportShim, _missingExportShim$1, _missingExportShim$2); - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/missing-export-reused-deconflicting/dep1.js b/test/chunking-form/samples/deprecated/missing-export-reused-deconflicting/dep1.js deleted file mode 100644 index 84e22e0fe8f..00000000000 --- a/test/chunking-form/samples/deprecated/missing-export-reused-deconflicting/dep1.js +++ /dev/null @@ -1,9 +0,0 @@ -console.log('This is the output when a missing export is used internally but not reexported'); - -function almostUseUnused(useIt) { - if (useIt) { - console.log(_missingExportShim); - } -} - -almostUseUnused(false); diff --git a/test/chunking-form/samples/deprecated/missing-export-reused-deconflicting/dep2.js b/test/chunking-form/samples/deprecated/missing-export-reused-deconflicting/dep2.js deleted file mode 100644 index e49bb16dd04..00000000000 --- a/test/chunking-form/samples/deprecated/missing-export-reused-deconflicting/dep2.js +++ /dev/null @@ -1,7 +0,0 @@ -console.log('This is the output when a missing export is reexported'); - -var _missingExportShim = void 0; - -console.log(_missingExportShim); - -export {_missingExportShim as previousShimmedExport} diff --git a/test/chunking-form/samples/deprecated/missing-export-reused-deconflicting/main.js b/test/chunking-form/samples/deprecated/missing-export-reused-deconflicting/main.js deleted file mode 100644 index 167c08b23fc..00000000000 --- a/test/chunking-form/samples/deprecated/missing-export-reused-deconflicting/main.js +++ /dev/null @@ -1,4 +0,0 @@ -import { missing1 } from './dep1.js'; -import { missing2, previousShimmedExport } from './dep2.js'; - -console.log(missing1, missing2, previousShimmedExport); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-auto-export-mode/_config.js b/test/chunking-form/samples/deprecated/preserve-modules-auto-export-mode/_config.js deleted file mode 100644 index 31219523c90..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-auto-export-mode/_config.js +++ /dev/null @@ -1,8 +0,0 @@ -module.exports = { - description: 'Uses entry point semantics for all files when preserving modules', - options: { - strictDeprecations: false, - input: 'main.js', - preserveModules: true - } -}; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-auto-export-mode/_expected/amd/default.js b/test/chunking-form/samples/deprecated/preserve-modules-auto-export-mode/_expected/amd/default.js deleted file mode 100644 index 9101b3f3d25..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-auto-export-mode/_expected/amd/default.js +++ /dev/null @@ -1,7 +0,0 @@ -define(function () { 'use strict'; - - var foo = 'default'; - - return foo; - -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-auto-export-mode/_expected/amd/main.js b/test/chunking-form/samples/deprecated/preserve-modules-auto-export-mode/_expected/amd/main.js deleted file mode 100644 index e9283e83bd9..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-auto-export-mode/_expected/amd/main.js +++ /dev/null @@ -1,14 +0,0 @@ -define(['require', './default', './named'], function (require, _default, named) { 'use strict'; - - function _interopNamespaceDefaultOnly(e) { - return Object.freeze({__proto__: null, 'default': e}); - } - - console.log(_default, named.value); - - new Promise(function (resolve, reject) { require(['./default'], function (m) { resolve(/*#__PURE__*/_interopNamespaceDefaultOnly(m)); }, reject) }).then(result => console.log(result.default)); - new Promise(function (resolve, reject) { require(['./named'], resolve, reject) }).then(result => console.log(result.value)); - - return _default; - -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-auto-export-mode/_expected/amd/named.js b/test/chunking-form/samples/deprecated/preserve-modules-auto-export-mode/_expected/amd/named.js deleted file mode 100644 index 37e6d25bd85..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-auto-export-mode/_expected/amd/named.js +++ /dev/null @@ -1,9 +0,0 @@ -define(['exports'], function (exports) { 'use strict'; - - const value = 'named'; - - exports.value = value; - - Object.defineProperty(exports, '__esModule', { value: true }); - -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-auto-export-mode/_expected/cjs/default.js b/test/chunking-form/samples/deprecated/preserve-modules-auto-export-mode/_expected/cjs/default.js deleted file mode 100644 index f670b985a61..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-auto-export-mode/_expected/cjs/default.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -var foo = 'default'; - -module.exports = foo; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-auto-export-mode/_expected/cjs/main.js b/test/chunking-form/samples/deprecated/preserve-modules-auto-export-mode/_expected/cjs/main.js deleted file mode 100644 index f1ded2b4a64..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-auto-export-mode/_expected/cjs/main.js +++ /dev/null @@ -1,15 +0,0 @@ -'use strict'; - -var _default = require('./default.js'); -var named = require('./named.js'); - -function _interopNamespaceDefaultOnly(e) { - return Object.freeze({__proto__: null, 'default': e}); -} - -console.log(_default, named.value); - -Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespaceDefaultOnly(require('./default.js')); }).then(result => console.log(result.default)); -Promise.resolve().then(function () { return require('./named.js'); }).then(result => console.log(result.value)); - -module.exports = _default; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-auto-export-mode/_expected/cjs/named.js b/test/chunking-form/samples/deprecated/preserve-modules-auto-export-mode/_expected/cjs/named.js deleted file mode 100644 index 491f8569447..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-auto-export-mode/_expected/cjs/named.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { value: true }); - -const value = 'named'; - -exports.value = value; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-auto-export-mode/_expected/es/default.js b/test/chunking-form/samples/deprecated/preserve-modules-auto-export-mode/_expected/es/default.js deleted file mode 100644 index 97dcda8cdc9..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-auto-export-mode/_expected/es/default.js +++ /dev/null @@ -1,3 +0,0 @@ -var foo = 'default'; - -export default foo; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-auto-export-mode/_expected/es/main.js b/test/chunking-form/samples/deprecated/preserve-modules-auto-export-mode/_expected/es/main.js deleted file mode 100644 index 1db891a835f..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-auto-export-mode/_expected/es/main.js +++ /dev/null @@ -1,8 +0,0 @@ -import foo from './default.js'; -export { default } from './default.js'; -import { value } from './named.js'; - -console.log(foo, value); - -import('./default.js').then(result => console.log(result.default)); -import('./named.js').then(result => console.log(result.value)); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-auto-export-mode/_expected/es/named.js b/test/chunking-form/samples/deprecated/preserve-modules-auto-export-mode/_expected/es/named.js deleted file mode 100644 index f632590076b..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-auto-export-mode/_expected/es/named.js +++ /dev/null @@ -1,3 +0,0 @@ -const value = 'named'; - -export { value }; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-auto-export-mode/_expected/system/default.js b/test/chunking-form/samples/deprecated/preserve-modules-auto-export-mode/_expected/system/default.js deleted file mode 100644 index 0505d3144dd..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-auto-export-mode/_expected/system/default.js +++ /dev/null @@ -1,10 +0,0 @@ -System.register([], function (exports) { - 'use strict'; - return { - execute: function () { - - var foo = exports('default', 'default'); - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-auto-export-mode/_expected/system/main.js b/test/chunking-form/samples/deprecated/preserve-modules-auto-export-mode/_expected/system/main.js deleted file mode 100644 index 12e707aee57..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-auto-export-mode/_expected/system/main.js +++ /dev/null @@ -1,20 +0,0 @@ -System.register(['./default.js', './named.js'], function (exports, module) { - 'use strict'; - var foo, value; - return { - setters: [function (module) { - foo = module.default; - exports('default', module.default); - }, function (module) { - value = module.value; - }], - execute: function () { - - console.log(foo, value); - - module.import('./default.js').then(result => console.log(result.default)); - module.import('./named.js').then(result => console.log(result.value)); - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-auto-export-mode/_expected/system/named.js b/test/chunking-form/samples/deprecated/preserve-modules-auto-export-mode/_expected/system/named.js deleted file mode 100644 index 431654fc285..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-auto-export-mode/_expected/system/named.js +++ /dev/null @@ -1,10 +0,0 @@ -System.register([], function (exports) { - 'use strict'; - return { - execute: function () { - - const value = exports('value', 'named'); - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-auto-export-mode/default.js b/test/chunking-form/samples/deprecated/preserve-modules-auto-export-mode/default.js deleted file mode 100644 index 413f601a377..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-auto-export-mode/default.js +++ /dev/null @@ -1 +0,0 @@ -export default 'default'; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-auto-export-mode/main.js b/test/chunking-form/samples/deprecated/preserve-modules-auto-export-mode/main.js deleted file mode 100644 index 72dc390d821..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-auto-export-mode/main.js +++ /dev/null @@ -1,8 +0,0 @@ -import foo from './default.js'; -import { value } from './named.js'; -console.log(foo, value); - -export { default } from './default.js'; - -import('./default').then(result => console.log(result.default)); -import('./named').then(result => console.log(result.value)); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-auto-export-mode/named.js b/test/chunking-form/samples/deprecated/preserve-modules-auto-export-mode/named.js deleted file mode 100644 index a5c403fef99..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-auto-export-mode/named.js +++ /dev/null @@ -1 +0,0 @@ -export const value = 'named'; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-commonjs/_config.js b/test/chunking-form/samples/deprecated/preserve-modules-commonjs/_config.js deleted file mode 100644 index 21593c6541f..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-commonjs/_config.js +++ /dev/null @@ -1,13 +0,0 @@ -const commonjs = require('@rollup/plugin-commonjs'); - -module.exports = { - description: 'Handles output from @rollup/plugin-commonjs', - expectedWarnings: ['MIXED_EXPORTS'], - options: { - strictDeprecations: false, - input: 'main.js', - preserveModules: true, - external: ['external'], - plugins: [commonjs()] - } -}; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-commonjs/_expected/amd/_virtual/other.js_commonjs-exports b/test/chunking-form/samples/deprecated/preserve-modules-commonjs/_expected/amd/_virtual/other.js_commonjs-exports deleted file mode 100644 index c85e5adb0f9..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-commonjs/_expected/amd/_virtual/other.js_commonjs-exports +++ /dev/null @@ -1,9 +0,0 @@ -define(['exports'], function (exports) { 'use strict'; - - var other = {}; - - exports.__exports = other; - - Object.defineProperty(exports, '__esModule', { value: true }); - -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-commonjs/_expected/amd/commonjs.js b/test/chunking-form/samples/deprecated/preserve-modules-commonjs/_expected/amd/commonjs.js deleted file mode 100644 index 530d96e07be..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-commonjs/_expected/amd/commonjs.js +++ /dev/null @@ -1,16 +0,0 @@ -define(['external', './other', './_virtual/other.js_commonjs-exports'], function (require$$0, other$1, other) { 'use strict'; - - function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } - - var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0); - - const external = require$$0__default['default']; - const { value } = other.__exports; - - console.log(external, value); - - var commonjs = 42; - - return commonjs; - -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-commonjs/_expected/amd/main.js b/test/chunking-form/samples/deprecated/preserve-modules-commonjs/_expected/amd/main.js deleted file mode 100644 index 59ea43e35ad..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-commonjs/_expected/amd/main.js +++ /dev/null @@ -1,9 +0,0 @@ -define(['./commonjs', 'external'], function (commonjs, require$$0) { 'use strict'; - - function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } - - var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0); - - console.log(commonjs, require$$0__default['default']); - -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-commonjs/_expected/amd/other.js b/test/chunking-form/samples/deprecated/preserve-modules-commonjs/_expected/amd/other.js deleted file mode 100644 index 72f196e0562..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-commonjs/_expected/amd/other.js +++ /dev/null @@ -1,7 +0,0 @@ -define(['./_virtual/other.js_commonjs-exports'], function (other) { 'use strict'; - - other.__exports.value = 43; - - return other.__exports; - -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-commonjs/_expected/cjs/_virtual/other.js_commonjs-exports b/test/chunking-form/samples/deprecated/preserve-modules-commonjs/_expected/cjs/_virtual/other.js_commonjs-exports deleted file mode 100644 index bc3ca602c7c..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-commonjs/_expected/cjs/_virtual/other.js_commonjs-exports +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { value: true }); - -var other = {}; - -exports.__exports = other; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-commonjs/_expected/cjs/commonjs.js b/test/chunking-form/samples/deprecated/preserve-modules-commonjs/_expected/cjs/commonjs.js deleted file mode 100644 index 01c49bb95e2..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-commonjs/_expected/cjs/commonjs.js +++ /dev/null @@ -1,18 +0,0 @@ -'use strict'; - -var require$$0 = require('external'); -require('./other.js'); -var other = require('./_virtual/other.js_commonjs-exports'); - -function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } - -var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0); - -const external = require$$0__default['default']; -const { value } = other.__exports; - -console.log(external, value); - -var commonjs = 42; - -module.exports = commonjs; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-commonjs/_expected/cjs/main.js b/test/chunking-form/samples/deprecated/preserve-modules-commonjs/_expected/cjs/main.js deleted file mode 100644 index d7fe0c9c3a7..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-commonjs/_expected/cjs/main.js +++ /dev/null @@ -1,10 +0,0 @@ -'use strict'; - -var commonjs = require('./commonjs.js'); -var require$$0 = require('external'); - -function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } - -var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0); - -console.log(commonjs, require$$0__default['default']); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-commonjs/_expected/cjs/other.js b/test/chunking-form/samples/deprecated/preserve-modules-commonjs/_expected/cjs/other.js deleted file mode 100644 index a514a7d358f..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-commonjs/_expected/cjs/other.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -var other = require('./_virtual/other.js_commonjs-exports'); - -other.__exports.value = 43; - -module.exports = other.__exports; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-commonjs/_expected/es/commonjs.js b/test/chunking-form/samples/deprecated/preserve-modules-commonjs/_expected/es/commonjs.js deleted file mode 100644 index 75c39f48f46..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-commonjs/_expected/es/commonjs.js +++ /dev/null @@ -1,12 +0,0 @@ -import require$$0 from 'external'; -import './other.js'; -import { __exports as other } from './_virtual/other.js_commonjs-exports'; - -const external = require$$0; -const { value } = other; - -console.log(external, value); - -var commonjs = 42; - -export default commonjs; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-commonjs/_expected/es/main.js b/test/chunking-form/samples/deprecated/preserve-modules-commonjs/_expected/es/main.js deleted file mode 100644 index de8bda2bf4c..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-commonjs/_expected/es/main.js +++ /dev/null @@ -1,4 +0,0 @@ -import commonjs from './commonjs.js'; -import require$$0 from 'external'; - -console.log(commonjs, require$$0); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-commonjs/_expected/es/other.js b/test/chunking-form/samples/deprecated/preserve-modules-commonjs/_expected/es/other.js deleted file mode 100644 index f9d6ad0cb3c..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-commonjs/_expected/es/other.js +++ /dev/null @@ -1,4 +0,0 @@ -import { __exports as other } from './_virtual/other.js_commonjs-exports'; -export { __exports as default } from './_virtual/other.js_commonjs-exports'; - -other.value = 43; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-commonjs/_expected/system/_virtual/other.js_commonjs-exports b/test/chunking-form/samples/deprecated/preserve-modules-commonjs/_expected/system/_virtual/other.js_commonjs-exports deleted file mode 100644 index 99e54f7255f..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-commonjs/_expected/system/_virtual/other.js_commonjs-exports +++ /dev/null @@ -1,10 +0,0 @@ -System.register([], function (exports) { - 'use strict'; - return { - execute: function () { - - var other = exports('__exports', {}); - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-commonjs/_expected/system/commonjs.js b/test/chunking-form/samples/deprecated/preserve-modules-commonjs/_expected/system/commonjs.js deleted file mode 100644 index 61194b78720..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-commonjs/_expected/system/commonjs.js +++ /dev/null @@ -1,21 +0,0 @@ -System.register(['external', './other.js', './_virtual/other.js_commonjs-exports'], function (exports) { - 'use strict'; - var require$$0, other; - return { - setters: [function (module) { - require$$0 = module.default; - }, function () {}, function (module) { - other = module.__exports; - }], - execute: function () { - - const external = require$$0; - const { value } = other; - - console.log(external, value); - - var commonjs = exports('default', 42); - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-commonjs/_expected/system/main.js b/test/chunking-form/samples/deprecated/preserve-modules-commonjs/_expected/system/main.js deleted file mode 100644 index 903fc6c4977..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-commonjs/_expected/system/main.js +++ /dev/null @@ -1,16 +0,0 @@ -System.register(['./commonjs.js', 'external'], function () { - 'use strict'; - var commonjs, require$$0; - return { - setters: [function (module) { - commonjs = module.default; - }, function (module) { - require$$0 = module.default; - }], - execute: function () { - - console.log(commonjs, require$$0); - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-commonjs/_expected/system/other.js b/test/chunking-form/samples/deprecated/preserve-modules-commonjs/_expected/system/other.js deleted file mode 100644 index ce56d7889f6..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-commonjs/_expected/system/other.js +++ /dev/null @@ -1,15 +0,0 @@ -System.register(['./_virtual/other.js_commonjs-exports'], function (exports) { - 'use strict'; - var other; - return { - setters: [function (module) { - other = module.__exports; - exports('default', module.__exports); - }], - execute: function () { - - other.value = 43; - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-commonjs/commonjs.js b/test/chunking-form/samples/deprecated/preserve-modules-commonjs/commonjs.js deleted file mode 100644 index b9bf49c3fc5..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-commonjs/commonjs.js +++ /dev/null @@ -1,6 +0,0 @@ -const external = require('external'); -const { value } = require('./other'); - -console.log(external, value); - -module.exports = 42; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-commonjs/main.js b/test/chunking-form/samples/deprecated/preserve-modules-commonjs/main.js deleted file mode 100644 index cfef423da0c..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-commonjs/main.js +++ /dev/null @@ -1,4 +0,0 @@ -import value from './commonjs'; -import external from 'external'; - -console.log(value, external); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-commonjs/other.js b/test/chunking-form/samples/deprecated/preserve-modules-commonjs/other.js deleted file mode 100644 index cd9dcc83b69..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-commonjs/other.js +++ /dev/null @@ -1 +0,0 @@ -exports.value = 43; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-dynamic-imports/_config.js b/test/chunking-form/samples/deprecated/preserve-modules-dynamic-imports/_config.js deleted file mode 100644 index 3ed23338db8..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-dynamic-imports/_config.js +++ /dev/null @@ -1,8 +0,0 @@ -module.exports = { - description: 'dynamic imports are handled correctly when preserving modules', - options: { - strictDeprecations: false, - input: ['main.js'], - preserveModules: true - } -}; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-dynamic-imports/_expected/amd/dynamic-included.js b/test/chunking-form/samples/deprecated/preserve-modules-dynamic-imports/_expected/amd/dynamic-included.js deleted file mode 100644 index afd117130dc..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-dynamic-imports/_expected/amd/dynamic-included.js +++ /dev/null @@ -1,9 +0,0 @@ -define(['exports'], function (exports) { 'use strict'; - - const value = 'included'; - - exports.value = value; - - Object.defineProperty(exports, '__esModule', { value: true }); - -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-dynamic-imports/_expected/amd/main.js b/test/chunking-form/samples/deprecated/preserve-modules-dynamic-imports/_expected/amd/main.js deleted file mode 100644 index 2ec310c64aa..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-dynamic-imports/_expected/amd/main.js +++ /dev/null @@ -1,5 +0,0 @@ -define(['require'], function (require) { 'use strict'; - - new Promise(function (resolve, reject) { require(['./dynamic-included'], resolve, reject) }).then(result => console.log(result)); - -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-dynamic-imports/_expected/cjs/dynamic-included.js b/test/chunking-form/samples/deprecated/preserve-modules-dynamic-imports/_expected/cjs/dynamic-included.js deleted file mode 100644 index 2c8d642e303..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-dynamic-imports/_expected/cjs/dynamic-included.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { value: true }); - -const value = 'included'; - -exports.value = value; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-dynamic-imports/_expected/cjs/main.js b/test/chunking-form/samples/deprecated/preserve-modules-dynamic-imports/_expected/cjs/main.js deleted file mode 100644 index ed78ead193e..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-dynamic-imports/_expected/cjs/main.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -Promise.resolve().then(function () { return require('./dynamic-included.js'); }).then(result => console.log(result)); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-dynamic-imports/_expected/es/dynamic-included.js b/test/chunking-form/samples/deprecated/preserve-modules-dynamic-imports/_expected/es/dynamic-included.js deleted file mode 100644 index 6370bf94358..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-dynamic-imports/_expected/es/dynamic-included.js +++ /dev/null @@ -1,3 +0,0 @@ -const value = 'included'; - -export { value }; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-dynamic-imports/_expected/es/main.js b/test/chunking-form/samples/deprecated/preserve-modules-dynamic-imports/_expected/es/main.js deleted file mode 100644 index 72ed76ddf10..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-dynamic-imports/_expected/es/main.js +++ /dev/null @@ -1 +0,0 @@ -import('./dynamic-included.js').then(result => console.log(result)); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-dynamic-imports/_expected/system/dynamic-included.js b/test/chunking-form/samples/deprecated/preserve-modules-dynamic-imports/_expected/system/dynamic-included.js deleted file mode 100644 index 3a6e756071e..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-dynamic-imports/_expected/system/dynamic-included.js +++ /dev/null @@ -1,10 +0,0 @@ -System.register([], function (exports) { - 'use strict'; - return { - execute: function () { - - const value = exports('value', 'included'); - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-dynamic-imports/_expected/system/main.js b/test/chunking-form/samples/deprecated/preserve-modules-dynamic-imports/_expected/system/main.js deleted file mode 100644 index 26c21dcccb5..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-dynamic-imports/_expected/system/main.js +++ /dev/null @@ -1,10 +0,0 @@ -System.register([], function (exports, module) { - 'use strict'; - return { - execute: function () { - - module.import('./dynamic-included.js').then(result => console.log(result)); - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-dynamic-imports/dynamic-included.js b/test/chunking-form/samples/deprecated/preserve-modules-dynamic-imports/dynamic-included.js deleted file mode 100644 index 287c398f8d6..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-dynamic-imports/dynamic-included.js +++ /dev/null @@ -1 +0,0 @@ -export const value = 'included'; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-dynamic-imports/dynamic-removed.js b/test/chunking-form/samples/deprecated/preserve-modules-dynamic-imports/dynamic-removed.js deleted file mode 100644 index a0203faa48b..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-dynamic-imports/dynamic-removed.js +++ /dev/null @@ -1 +0,0 @@ -export const value = 'removed'; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-dynamic-imports/main.js b/test/chunking-form/samples/deprecated/preserve-modules-dynamic-imports/main.js deleted file mode 100644 index 9449616c8fe..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-dynamic-imports/main.js +++ /dev/null @@ -1,6 +0,0 @@ -import('./dynamic-included').then(result => console.log(result)); - -const include = false; -if (include) { - import('./dynamic-removed').then(result => console.log(result)); -} diff --git a/test/chunking-form/samples/deprecated/preserve-modules-dynamic-namespace/_config.js b/test/chunking-form/samples/deprecated/preserve-modules-dynamic-namespace/_config.js deleted file mode 100644 index c5483693708..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-dynamic-namespace/_config.js +++ /dev/null @@ -1,8 +0,0 @@ -module.exports = { - description: 'Preserve modules properly handles internal namespace imports (#2576)', - options: { - strictDeprecations: false, - input: ['main.js'], - preserveModules: true - } -}; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-dynamic-namespace/_expected/amd/m1.js b/test/chunking-form/samples/deprecated/preserve-modules-dynamic-namespace/_expected/amd/m1.js deleted file mode 100644 index 25f53d93a63..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-dynamic-namespace/_expected/amd/m1.js +++ /dev/null @@ -1,10 +0,0 @@ -define(['exports', './m2', './m3'], function (exports, m2, m3) { 'use strict'; - - - - exports.m2 = m2; - exports.m3 = m3; - - Object.defineProperty(exports, '__esModule', { value: true }); - -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-dynamic-namespace/_expected/amd/m2.js b/test/chunking-form/samples/deprecated/preserve-modules-dynamic-namespace/_expected/amd/m2.js deleted file mode 100644 index 22e08de419f..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-dynamic-namespace/_expected/amd/m2.js +++ /dev/null @@ -1,7 +0,0 @@ -define(function () { 'use strict'; - - var m2 = {a:1}; - - return m2; - -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-dynamic-namespace/_expected/amd/m3.js b/test/chunking-form/samples/deprecated/preserve-modules-dynamic-namespace/_expected/amd/m3.js deleted file mode 100644 index 685448b54a5..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-dynamic-namespace/_expected/amd/m3.js +++ /dev/null @@ -1,7 +0,0 @@ -define(function () { 'use strict'; - - var m3 = {b:2}; - - return m3; - -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-dynamic-namespace/_expected/amd/main.js b/test/chunking-form/samples/deprecated/preserve-modules-dynamic-namespace/_expected/amd/main.js deleted file mode 100644 index b73da45ad1d..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-dynamic-namespace/_expected/amd/main.js +++ /dev/null @@ -1,5 +0,0 @@ -define(['./m1'], function (m1) { 'use strict'; - - console.log(m1); - -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-dynamic-namespace/_expected/cjs/m1.js b/test/chunking-form/samples/deprecated/preserve-modules-dynamic-namespace/_expected/cjs/m1.js deleted file mode 100644 index 2dcf78656c6..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-dynamic-namespace/_expected/cjs/m1.js +++ /dev/null @@ -1,11 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { value: true }); - -var m2 = require('./m2.js'); -var m3 = require('./m3.js'); - - - -exports.m2 = m2; -exports.m3 = m3; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-dynamic-namespace/_expected/cjs/m2.js b/test/chunking-form/samples/deprecated/preserve-modules-dynamic-namespace/_expected/cjs/m2.js deleted file mode 100644 index 4e7045d3fc5..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-dynamic-namespace/_expected/cjs/m2.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -var m2 = {a:1}; - -module.exports = m2; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-dynamic-namespace/_expected/cjs/m3.js b/test/chunking-form/samples/deprecated/preserve-modules-dynamic-namespace/_expected/cjs/m3.js deleted file mode 100644 index 8e984623675..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-dynamic-namespace/_expected/cjs/m3.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -var m3 = {b:2}; - -module.exports = m3; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-dynamic-namespace/_expected/cjs/main.js b/test/chunking-form/samples/deprecated/preserve-modules-dynamic-namespace/_expected/cjs/main.js deleted file mode 100644 index 79afdf39744..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-dynamic-namespace/_expected/cjs/main.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -var m1 = require('./m1.js'); - -console.log(m1); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-dynamic-namespace/_expected/es/m1.js b/test/chunking-form/samples/deprecated/preserve-modules-dynamic-namespace/_expected/es/m1.js deleted file mode 100644 index 86968950d9d..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-dynamic-namespace/_expected/es/m1.js +++ /dev/null @@ -1,2 +0,0 @@ -export { default as m2 } from './m2.js'; -export { default as m3 } from './m3.js'; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-dynamic-namespace/_expected/es/m2.js b/test/chunking-form/samples/deprecated/preserve-modules-dynamic-namespace/_expected/es/m2.js deleted file mode 100644 index 0ee68395af0..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-dynamic-namespace/_expected/es/m2.js +++ /dev/null @@ -1,3 +0,0 @@ -var m2 = {a:1}; - -export default m2; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-dynamic-namespace/_expected/es/m3.js b/test/chunking-form/samples/deprecated/preserve-modules-dynamic-namespace/_expected/es/m3.js deleted file mode 100644 index 0d65aa10bb9..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-dynamic-namespace/_expected/es/m3.js +++ /dev/null @@ -1,3 +0,0 @@ -var m3 = {b:2}; - -export default m3; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-dynamic-namespace/_expected/es/main.js b/test/chunking-form/samples/deprecated/preserve-modules-dynamic-namespace/_expected/es/main.js deleted file mode 100644 index 0240c910272..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-dynamic-namespace/_expected/es/main.js +++ /dev/null @@ -1,3 +0,0 @@ -import * as m1 from './m1.js'; - -console.log(m1); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-dynamic-namespace/_expected/system/m1.js b/test/chunking-form/samples/deprecated/preserve-modules-dynamic-namespace/_expected/system/m1.js deleted file mode 100644 index 9f2d67db2a9..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-dynamic-namespace/_expected/system/m1.js +++ /dev/null @@ -1,15 +0,0 @@ -System.register(['./m2.js', './m3.js'], function (exports) { - 'use strict'; - return { - setters: [function (module) { - exports('m2', module.default); - }, function (module) { - exports('m3', module.default); - }], - execute: function () { - - - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-dynamic-namespace/_expected/system/m2.js b/test/chunking-form/samples/deprecated/preserve-modules-dynamic-namespace/_expected/system/m2.js deleted file mode 100644 index d724fa35251..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-dynamic-namespace/_expected/system/m2.js +++ /dev/null @@ -1,10 +0,0 @@ -System.register([], function (exports) { - 'use strict'; - return { - execute: function () { - - var m2 = exports('default', {a:1}); - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-dynamic-namespace/_expected/system/m3.js b/test/chunking-form/samples/deprecated/preserve-modules-dynamic-namespace/_expected/system/m3.js deleted file mode 100644 index 1181b9a04ec..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-dynamic-namespace/_expected/system/m3.js +++ /dev/null @@ -1,10 +0,0 @@ -System.register([], function (exports) { - 'use strict'; - return { - execute: function () { - - var m3 = exports('default', {b:2}); - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-dynamic-namespace/_expected/system/main.js b/test/chunking-form/samples/deprecated/preserve-modules-dynamic-namespace/_expected/system/main.js deleted file mode 100644 index 8ee4b05a8af..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-dynamic-namespace/_expected/system/main.js +++ /dev/null @@ -1,14 +0,0 @@ -System.register(['./m1.js'], function () { - 'use strict'; - var m1; - return { - setters: [function (module) { - m1 = module; - }], - execute: function () { - - console.log(m1); - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-dynamic-namespace/m1.js b/test/chunking-form/samples/deprecated/preserve-modules-dynamic-namespace/m1.js deleted file mode 100644 index 611f3360f0a..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-dynamic-namespace/m1.js +++ /dev/null @@ -1,5 +0,0 @@ -import m2 from './m2.js'; -import m3 from './m3.js'; - -// console.log('m1'); -export { m2, m3 }; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-dynamic-namespace/m2.js b/test/chunking-form/samples/deprecated/preserve-modules-dynamic-namespace/m2.js deleted file mode 100644 index 040aecae258..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-dynamic-namespace/m2.js +++ /dev/null @@ -1,2 +0,0 @@ -var m2 = {a:1}; -export default m2; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-dynamic-namespace/m3.js b/test/chunking-form/samples/deprecated/preserve-modules-dynamic-namespace/m3.js deleted file mode 100644 index e58c26e98bd..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-dynamic-namespace/m3.js +++ /dev/null @@ -1,2 +0,0 @@ -var m3 = {b:2}; -export default m3; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-dynamic-namespace/main.js b/test/chunking-form/samples/deprecated/preserve-modules-dynamic-namespace/main.js deleted file mode 100644 index c7526ddd8b1..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-dynamic-namespace/main.js +++ /dev/null @@ -1,3 +0,0 @@ -import * as ms from './m1.js'; - -console.log(ms); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-empty/_config.js b/test/chunking-form/samples/deprecated/preserve-modules-empty/_config.js deleted file mode 100644 index 820e4c3cf04..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-empty/_config.js +++ /dev/null @@ -1,8 +0,0 @@ -module.exports = { - description: 'Preserve modules remove empty dependencies', - options: { - strictDeprecations: false, - input: 'main.js', - preserveModules: true - } -}; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-empty/_expected/amd/main.js b/test/chunking-form/samples/deprecated/preserve-modules-empty/_expected/amd/main.js deleted file mode 100644 index 6fd312fad67..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-empty/_expected/amd/main.js +++ /dev/null @@ -1,5 +0,0 @@ -define(['./two'], function (two) { 'use strict'; - - window.APP = { a: two }; - -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-empty/_expected/amd/two.js b/test/chunking-form/samples/deprecated/preserve-modules-empty/_expected/amd/two.js deleted file mode 100644 index 68dcf822ab8..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-empty/_expected/amd/two.js +++ /dev/null @@ -1,7 +0,0 @@ -define(function () { 'use strict'; - - var a = {}; - - return a; - -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-empty/_expected/cjs/main.js b/test/chunking-form/samples/deprecated/preserve-modules-empty/_expected/cjs/main.js deleted file mode 100644 index b882d86f306..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-empty/_expected/cjs/main.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -var two = require('./two.js'); - -window.APP = { a: two }; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-empty/_expected/cjs/two.js b/test/chunking-form/samples/deprecated/preserve-modules-empty/_expected/cjs/two.js deleted file mode 100644 index 62ff33f50af..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-empty/_expected/cjs/two.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -var a = {}; - -module.exports = a; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-empty/_expected/es/main.js b/test/chunking-form/samples/deprecated/preserve-modules-empty/_expected/es/main.js deleted file mode 100644 index c69a3355933..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-empty/_expected/es/main.js +++ /dev/null @@ -1,3 +0,0 @@ -import a from './two.js'; - -window.APP = { a }; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-empty/_expected/es/two.js b/test/chunking-form/samples/deprecated/preserve-modules-empty/_expected/es/two.js deleted file mode 100644 index 0938a073152..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-empty/_expected/es/two.js +++ /dev/null @@ -1,3 +0,0 @@ -var a = {}; - -export default a; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-empty/_expected/system/main.js b/test/chunking-form/samples/deprecated/preserve-modules-empty/_expected/system/main.js deleted file mode 100644 index b0664a8cd59..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-empty/_expected/system/main.js +++ /dev/null @@ -1,14 +0,0 @@ -System.register(['./two.js'], function () { - 'use strict'; - var a; - return { - setters: [function (module) { - a = module.default; - }], - execute: function () { - - window.APP = { a }; - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-empty/_expected/system/two.js b/test/chunking-form/samples/deprecated/preserve-modules-empty/_expected/system/two.js deleted file mode 100644 index 015fc0193bb..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-empty/_expected/system/two.js +++ /dev/null @@ -1,10 +0,0 @@ -System.register([], function (exports) { - 'use strict'; - return { - execute: function () { - - var a = exports('default', {}); - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-empty/main.js b/test/chunking-form/samples/deprecated/preserve-modules-empty/main.js deleted file mode 100644 index 944087cb5c5..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-empty/main.js +++ /dev/null @@ -1,3 +0,0 @@ -import { a } from './one'; - -window.APP = { a }; \ No newline at end of file diff --git a/test/chunking-form/samples/deprecated/preserve-modules-empty/one.js b/test/chunking-form/samples/deprecated/preserve-modules-empty/one.js deleted file mode 100644 index 2fa4a4dfd2b..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-empty/one.js +++ /dev/null @@ -1,2 +0,0 @@ -export { default as a } from './two'; -export { default as b } from './three'; \ No newline at end of file diff --git a/test/chunking-form/samples/deprecated/preserve-modules-empty/three.js b/test/chunking-form/samples/deprecated/preserve-modules-empty/three.js deleted file mode 100644 index 7c645e42fb7..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-empty/three.js +++ /dev/null @@ -1 +0,0 @@ -export default {}; \ No newline at end of file diff --git a/test/chunking-form/samples/deprecated/preserve-modules-empty/two.js b/test/chunking-form/samples/deprecated/preserve-modules-empty/two.js deleted file mode 100644 index 7c645e42fb7..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-empty/two.js +++ /dev/null @@ -1 +0,0 @@ -export default {}; \ No newline at end of file diff --git a/test/chunking-form/samples/deprecated/preserve-modules-export-alias/_config.js b/test/chunking-form/samples/deprecated/preserve-modules-export-alias/_config.js deleted file mode 100644 index 9ca75e06f00..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-export-alias/_config.js +++ /dev/null @@ -1,8 +0,0 @@ -module.exports = { - description: 'confirm export aliases are preserved in modules', - options: { - strictDeprecations: false, - input: ['main1.js', 'main2.js'], - preserveModules: true - } -}; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-export-alias/_expected/amd/dep.js b/test/chunking-form/samples/deprecated/preserve-modules-export-alias/_expected/amd/dep.js deleted file mode 100644 index cab959ad2ca..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-export-alias/_expected/amd/dep.js +++ /dev/null @@ -1,10 +0,0 @@ -define(['exports'], function (exports) { 'use strict'; - - const foo = 1; - - exports.bar = foo; - exports.foo = foo; - - Object.defineProperty(exports, '__esModule', { value: true }); - -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-export-alias/_expected/amd/main1.js b/test/chunking-form/samples/deprecated/preserve-modules-export-alias/_expected/amd/main1.js deleted file mode 100644 index 4c30c2b8f1e..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-export-alias/_expected/amd/main1.js +++ /dev/null @@ -1,10 +0,0 @@ -define(['exports', './dep'], function (exports, dep) { 'use strict'; - - - - exports.bar = dep.foo; - exports.foo = dep.foo; - - Object.defineProperty(exports, '__esModule', { value: true }); - -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-export-alias/_expected/amd/main2.js b/test/chunking-form/samples/deprecated/preserve-modules-export-alias/_expected/amd/main2.js deleted file mode 100644 index 0d4dfce05b3..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-export-alias/_expected/amd/main2.js +++ /dev/null @@ -1,9 +0,0 @@ -define(['exports', './dep'], function (exports, dep) { 'use strict'; - - - - exports.bar = dep.foo; - - Object.defineProperty(exports, '__esModule', { value: true }); - -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-export-alias/_expected/cjs/dep.js b/test/chunking-form/samples/deprecated/preserve-modules-export-alias/_expected/cjs/dep.js deleted file mode 100644 index 7bf4532c451..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-export-alias/_expected/cjs/dep.js +++ /dev/null @@ -1,8 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { value: true }); - -const foo = 1; - -exports.bar = foo; -exports.foo = foo; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-export-alias/_expected/cjs/main1.js b/test/chunking-form/samples/deprecated/preserve-modules-export-alias/_expected/cjs/main1.js deleted file mode 100644 index 801c4e75c53..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-export-alias/_expected/cjs/main1.js +++ /dev/null @@ -1,10 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { value: true }); - -var dep = require('./dep.js'); - - - -exports.bar = dep.foo; -exports.foo = dep.foo; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-export-alias/_expected/cjs/main2.js b/test/chunking-form/samples/deprecated/preserve-modules-export-alias/_expected/cjs/main2.js deleted file mode 100644 index 1c1f62cd337..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-export-alias/_expected/cjs/main2.js +++ /dev/null @@ -1,9 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { value: true }); - -var dep = require('./dep.js'); - - - -exports.bar = dep.foo; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-export-alias/_expected/es/dep.js b/test/chunking-form/samples/deprecated/preserve-modules-export-alias/_expected/es/dep.js deleted file mode 100644 index fd00364ba36..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-export-alias/_expected/es/dep.js +++ /dev/null @@ -1,3 +0,0 @@ -const foo = 1; - -export { foo as bar, foo }; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-export-alias/_expected/es/main1.js b/test/chunking-form/samples/deprecated/preserve-modules-export-alias/_expected/es/main1.js deleted file mode 100644 index ed1ba0cbfbb..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-export-alias/_expected/es/main1.js +++ /dev/null @@ -1 +0,0 @@ -export { foo as bar, foo } from './dep.js'; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-export-alias/_expected/es/main2.js b/test/chunking-form/samples/deprecated/preserve-modules-export-alias/_expected/es/main2.js deleted file mode 100644 index e7cedc5ee48..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-export-alias/_expected/es/main2.js +++ /dev/null @@ -1 +0,0 @@ -export { foo as bar } from './dep.js'; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-export-alias/_expected/system/dep.js b/test/chunking-form/samples/deprecated/preserve-modules-export-alias/_expected/system/dep.js deleted file mode 100644 index 850241b9ad6..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-export-alias/_expected/system/dep.js +++ /dev/null @@ -1,10 +0,0 @@ -System.register([], function (exports) { - 'use strict'; - return { - execute: function () { - - const foo = function (v) { return exports({ foo: v, bar: v }), v; }(1); - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-export-alias/_expected/system/main1.js b/test/chunking-form/samples/deprecated/preserve-modules-export-alias/_expected/system/main1.js deleted file mode 100644 index bfffe939f7a..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-export-alias/_expected/system/main1.js +++ /dev/null @@ -1,16 +0,0 @@ -System.register(['./dep.js'], function (exports) { - 'use strict'; - return { - setters: [function (module) { - var _setter = {}; - _setter.bar = module.foo; - _setter.foo = module.foo; - exports(_setter); - }], - execute: function () { - - - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-export-alias/_expected/system/main2.js b/test/chunking-form/samples/deprecated/preserve-modules-export-alias/_expected/system/main2.js deleted file mode 100644 index d995245e8f6..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-export-alias/_expected/system/main2.js +++ /dev/null @@ -1,13 +0,0 @@ -System.register(['./dep.js'], function (exports) { - 'use strict'; - return { - setters: [function (module) { - exports('bar', module.foo); - }], - execute: function () { - - - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-export-alias/dep.js b/test/chunking-form/samples/deprecated/preserve-modules-export-alias/dep.js deleted file mode 100644 index 6e70164af81..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-export-alias/dep.js +++ /dev/null @@ -1,3 +0,0 @@ -const foo = 1; - -export { foo, foo as bar }; \ No newline at end of file diff --git a/test/chunking-form/samples/deprecated/preserve-modules-export-alias/main1.js b/test/chunking-form/samples/deprecated/preserve-modules-export-alias/main1.js deleted file mode 100644 index d6dbbf4db77..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-export-alias/main1.js +++ /dev/null @@ -1 +0,0 @@ -export { foo, bar } from './dep'; \ No newline at end of file diff --git a/test/chunking-form/samples/deprecated/preserve-modules-export-alias/main2.js b/test/chunking-form/samples/deprecated/preserve-modules-export-alias/main2.js deleted file mode 100644 index a9aa169df94..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-export-alias/main2.js +++ /dev/null @@ -1 +0,0 @@ -export { bar } from './dep'; \ No newline at end of file diff --git a/test/chunking-form/samples/deprecated/preserve-modules-filename-pattern/_config.js b/test/chunking-form/samples/deprecated/preserve-modules-filename-pattern/_config.js deleted file mode 100644 index fd9c3b9b431..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-filename-pattern/_config.js +++ /dev/null @@ -1,11 +0,0 @@ -module.exports = { - description: 'entryFileNames pattern supported in combination with preserveModules', - options: { - strictDeprecations: false, - input: 'src/main.ts', - output: { - entryFileNames: 'entry-[name]-[format]-[ext][extname].js' - }, - preserveModules: true - } -}; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-filename-pattern/_expected/amd/entry-foo-amd-ts.ts.js b/test/chunking-form/samples/deprecated/preserve-modules-filename-pattern/_expected/amd/entry-foo-amd-ts.ts.js deleted file mode 100644 index 2bc02b35588..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-filename-pattern/_expected/amd/entry-foo-amd-ts.ts.js +++ /dev/null @@ -1,7 +0,0 @@ -define(function () { 'use strict'; - - var foo = 42; - - return foo; - -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-filename-pattern/_expected/amd/entry-main-amd-ts.ts.js b/test/chunking-form/samples/deprecated/preserve-modules-filename-pattern/_expected/amd/entry-main-amd-ts.ts.js deleted file mode 100644 index 1018355bd77..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-filename-pattern/_expected/amd/entry-main-amd-ts.ts.js +++ /dev/null @@ -1,12 +0,0 @@ -define(['exports', './entry-foo-amd-ts.ts', './nested/entry-bar-amd-ts.ts', './nested/entry-baz-amd-ts.ts', './entry-no-ext-amd-'], function (exports, foo, bar, baz, noExt) { 'use strict'; - - - - exports.foo = foo; - exports.bar = bar; - exports.baz = baz; - exports.noExt = noExt; - - Object.defineProperty(exports, '__esModule', { value: true }); - -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-filename-pattern/_expected/amd/entry-no-ext-amd-.js b/test/chunking-form/samples/deprecated/preserve-modules-filename-pattern/_expected/amd/entry-no-ext-amd-.js deleted file mode 100644 index 8e2da77223e..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-filename-pattern/_expected/amd/entry-no-ext-amd-.js +++ /dev/null @@ -1,7 +0,0 @@ -define(function () { 'use strict'; - - var noExt = 'no-ext'; - - return noExt; - -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-filename-pattern/_expected/amd/nested/entry-bar-amd-ts.ts.js b/test/chunking-form/samples/deprecated/preserve-modules-filename-pattern/_expected/amd/nested/entry-bar-amd-ts.ts.js deleted file mode 100644 index cb3bfcd5d1d..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-filename-pattern/_expected/amd/nested/entry-bar-amd-ts.ts.js +++ /dev/null @@ -1,7 +0,0 @@ -define(function () { 'use strict'; - - var bar = 'banana'; - - return bar; - -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-filename-pattern/_expected/amd/nested/entry-baz-amd-ts.ts.js b/test/chunking-form/samples/deprecated/preserve-modules-filename-pattern/_expected/amd/nested/entry-baz-amd-ts.ts.js deleted file mode 100644 index 35018f30618..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-filename-pattern/_expected/amd/nested/entry-baz-amd-ts.ts.js +++ /dev/null @@ -1,7 +0,0 @@ -define(function () { 'use strict'; - - var baz = 'whatever'; - - return baz; - -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-filename-pattern/_expected/cjs/entry-foo-cjs-ts.ts.js b/test/chunking-form/samples/deprecated/preserve-modules-filename-pattern/_expected/cjs/entry-foo-cjs-ts.ts.js deleted file mode 100644 index 476c8ac92d3..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-filename-pattern/_expected/cjs/entry-foo-cjs-ts.ts.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -var foo = 42; - -module.exports = foo; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-filename-pattern/_expected/cjs/entry-main-cjs-ts.ts.js b/test/chunking-form/samples/deprecated/preserve-modules-filename-pattern/_expected/cjs/entry-main-cjs-ts.ts.js deleted file mode 100644 index aff83e1b5d2..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-filename-pattern/_expected/cjs/entry-main-cjs-ts.ts.js +++ /dev/null @@ -1,15 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { value: true }); - -var foo = require('./entry-foo-cjs-ts.ts.js'); -var bar = require('./nested/entry-bar-cjs-ts.ts.js'); -var baz = require('./nested/entry-baz-cjs-ts.ts.js'); -var noExt = require('./entry-no-ext-cjs-.js'); - - - -exports.foo = foo; -exports.bar = bar; -exports.baz = baz; -exports.noExt = noExt; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-filename-pattern/_expected/cjs/nested/entry-bar-cjs-ts.ts.js b/test/chunking-form/samples/deprecated/preserve-modules-filename-pattern/_expected/cjs/nested/entry-bar-cjs-ts.ts.js deleted file mode 100644 index f8f56e6fc51..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-filename-pattern/_expected/cjs/nested/entry-bar-cjs-ts.ts.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -var bar = 'banana'; - -module.exports = bar; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-filename-pattern/_expected/cjs/nested/entry-baz-cjs-ts.ts.js b/test/chunking-form/samples/deprecated/preserve-modules-filename-pattern/_expected/cjs/nested/entry-baz-cjs-ts.ts.js deleted file mode 100644 index 0ba506ad3eb..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-filename-pattern/_expected/cjs/nested/entry-baz-cjs-ts.ts.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -var baz = 'whatever'; - -module.exports = baz; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-filename-pattern/_expected/es/entry-foo-es-ts.ts.js b/test/chunking-form/samples/deprecated/preserve-modules-filename-pattern/_expected/es/entry-foo-es-ts.ts.js deleted file mode 100644 index 8ac2b2169a4..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-filename-pattern/_expected/es/entry-foo-es-ts.ts.js +++ /dev/null @@ -1,3 +0,0 @@ -var foo = 42; - -export default foo; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-filename-pattern/_expected/es/entry-main-es-ts.ts.js b/test/chunking-form/samples/deprecated/preserve-modules-filename-pattern/_expected/es/entry-main-es-ts.ts.js deleted file mode 100644 index 341e9d48d9b..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-filename-pattern/_expected/es/entry-main-es-ts.ts.js +++ /dev/null @@ -1,4 +0,0 @@ -export { default as foo } from './entry-foo-es-ts.ts.js'; -export { default as bar } from './nested/entry-bar-es-ts.ts.js'; -export { default as baz } from './nested/entry-baz-es-ts.ts.js'; -export { default as noExt } from './entry-no-ext-es-.js'; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-filename-pattern/_expected/es/entry-no-ext-es-.js b/test/chunking-form/samples/deprecated/preserve-modules-filename-pattern/_expected/es/entry-no-ext-es-.js deleted file mode 100644 index e630b7b5e9d..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-filename-pattern/_expected/es/entry-no-ext-es-.js +++ /dev/null @@ -1,3 +0,0 @@ -var noExt = 'no-ext'; - -export default noExt; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-filename-pattern/_expected/es/nested/entry-bar-es-ts.ts.js b/test/chunking-form/samples/deprecated/preserve-modules-filename-pattern/_expected/es/nested/entry-bar-es-ts.ts.js deleted file mode 100644 index bbf65d4599d..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-filename-pattern/_expected/es/nested/entry-bar-es-ts.ts.js +++ /dev/null @@ -1,3 +0,0 @@ -var bar = 'banana'; - -export default bar; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-filename-pattern/_expected/es/nested/entry-baz-es-ts.ts.js b/test/chunking-form/samples/deprecated/preserve-modules-filename-pattern/_expected/es/nested/entry-baz-es-ts.ts.js deleted file mode 100644 index 03a3023d32b..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-filename-pattern/_expected/es/nested/entry-baz-es-ts.ts.js +++ /dev/null @@ -1,3 +0,0 @@ -var baz = 'whatever'; - -export default baz; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-filename-pattern/_expected/system/entry-foo-system-ts.ts.js b/test/chunking-form/samples/deprecated/preserve-modules-filename-pattern/_expected/system/entry-foo-system-ts.ts.js deleted file mode 100644 index 81b45b772a8..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-filename-pattern/_expected/system/entry-foo-system-ts.ts.js +++ /dev/null @@ -1,10 +0,0 @@ -System.register([], function (exports) { - 'use strict'; - return { - execute: function () { - - var foo = exports('default', 42); - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-filename-pattern/_expected/system/entry-main-system-ts.ts.js b/test/chunking-form/samples/deprecated/preserve-modules-filename-pattern/_expected/system/entry-main-system-ts.ts.js deleted file mode 100644 index 22b35a8d704..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-filename-pattern/_expected/system/entry-main-system-ts.ts.js +++ /dev/null @@ -1,19 +0,0 @@ -System.register(['./entry-foo-system-ts.ts.js', './nested/entry-bar-system-ts.ts.js', './nested/entry-baz-system-ts.ts.js', './entry-no-ext-system-.js'], function (exports) { - 'use strict'; - return { - setters: [function (module) { - exports('foo', module.default); - }, function (module) { - exports('bar', module.default); - }, function (module) { - exports('baz', module.default); - }, function (module) { - exports('noExt', module.default); - }], - execute: function () { - - - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-filename-pattern/_expected/system/entry-no-ext-system-.js b/test/chunking-form/samples/deprecated/preserve-modules-filename-pattern/_expected/system/entry-no-ext-system-.js deleted file mode 100644 index 91546e66d5b..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-filename-pattern/_expected/system/entry-no-ext-system-.js +++ /dev/null @@ -1,10 +0,0 @@ -System.register([], function (exports) { - 'use strict'; - return { - execute: function () { - - var noExt = exports('default', 'no-ext'); - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-filename-pattern/_expected/system/nested/entry-bar-system-ts.ts.js b/test/chunking-form/samples/deprecated/preserve-modules-filename-pattern/_expected/system/nested/entry-bar-system-ts.ts.js deleted file mode 100644 index 5ef23f15879..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-filename-pattern/_expected/system/nested/entry-bar-system-ts.ts.js +++ /dev/null @@ -1,10 +0,0 @@ -System.register([], function (exports) { - 'use strict'; - return { - execute: function () { - - var bar = exports('default', 'banana'); - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-filename-pattern/_expected/system/nested/entry-baz-system-ts.ts.js b/test/chunking-form/samples/deprecated/preserve-modules-filename-pattern/_expected/system/nested/entry-baz-system-ts.ts.js deleted file mode 100644 index a0526b56624..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-filename-pattern/_expected/system/nested/entry-baz-system-ts.ts.js +++ /dev/null @@ -1,10 +0,0 @@ -System.register([], function (exports) { - 'use strict'; - return { - execute: function () { - - var baz = exports('default', 'whatever'); - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-filename-pattern/src/main.ts b/test/chunking-form/samples/deprecated/preserve-modules-filename-pattern/src/main.ts deleted file mode 100644 index 3f169c8f476..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-filename-pattern/src/main.ts +++ /dev/null @@ -1,8 +0,0 @@ -// @ts-ignore -export { default as foo } from './foo.ts'; -// @ts-ignore -export { default as bar } from './nested/bar.ts'; -// @ts-ignore -export { default as baz } from './nested/baz.ts'; -// @ts-ignore -export { default as noExt } from './no-ext'; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-filename-pattern/src/nested/baz.ts b/test/chunking-form/samples/deprecated/preserve-modules-filename-pattern/src/nested/baz.ts deleted file mode 100644 index 6d70feca8ec..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-filename-pattern/src/nested/baz.ts +++ /dev/null @@ -1 +0,0 @@ -export default 'whatever'; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-filename-pattern/src/no-ext b/test/chunking-form/samples/deprecated/preserve-modules-filename-pattern/src/no-ext deleted file mode 100644 index a59381f7298..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-filename-pattern/src/no-ext +++ /dev/null @@ -1 +0,0 @@ -export default 'no-ext' diff --git a/test/chunking-form/samples/deprecated/preserve-modules-id-case-sensitive/_config.js b/test/chunking-form/samples/deprecated/preserve-modules-id-case-sensitive/_config.js deleted file mode 100644 index 6ffd681d55c..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-id-case-sensitive/_config.js +++ /dev/null @@ -1,22 +0,0 @@ -module.exports = { - description: 'Preserve modules id case sensitive', - options: { - strictDeprecations: false, - input: 'main.js', - preserveModules: true, - plugins: [ - { - resolveId(id) { - if (id.toLowerCase().includes('one')) { - return id; - } - }, - load(id) { - if (id.toLowerCase().includes('one')) { - return `export default '${id.replace('\0', '')}'`; - } - } - } - ] - } -}; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-id-case-sensitive/_expected/amd/_virtual/_One1.js b/test/chunking-form/samples/deprecated/preserve-modules-id-case-sensitive/_expected/amd/_virtual/_One1.js deleted file mode 100644 index 0383829b24e..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-id-case-sensitive/_expected/amd/_virtual/_One1.js +++ /dev/null @@ -1,7 +0,0 @@ -define(function () { 'use strict'; - - var c = 'One1.js'; - - return c; - -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-id-case-sensitive/_expected/amd/_virtual/_One2.js b/test/chunking-form/samples/deprecated/preserve-modules-id-case-sensitive/_expected/amd/_virtual/_One2.js deleted file mode 100644 index 1febaba2ef7..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-id-case-sensitive/_expected/amd/_virtual/_One2.js +++ /dev/null @@ -1,7 +0,0 @@ -define(function () { 'use strict'; - - var b = 'One.js'; - - return b; - -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-id-case-sensitive/_expected/amd/_virtual/_one.js b/test/chunking-form/samples/deprecated/preserve-modules-id-case-sensitive/_expected/amd/_virtual/_one.js deleted file mode 100644 index 469b63f9f86..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-id-case-sensitive/_expected/amd/_virtual/_one.js +++ /dev/null @@ -1,7 +0,0 @@ -define(function () { 'use strict'; - - var a = 'one.js'; - - return a; - -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-id-case-sensitive/_expected/amd/main.js b/test/chunking-form/samples/deprecated/preserve-modules-id-case-sensitive/_expected/amd/main.js deleted file mode 100644 index 803eecb1652..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-id-case-sensitive/_expected/amd/main.js +++ /dev/null @@ -1,5 +0,0 @@ -define(['./_virtual/_one', './_virtual/_One2', './_virtual/_One1'], function (_one, _One, _One1) { 'use strict'; - - window.APP = { a: _one, b: _One, c: _One1 }; - -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-id-case-sensitive/_expected/cjs/_virtual/_One1.js b/test/chunking-form/samples/deprecated/preserve-modules-id-case-sensitive/_expected/cjs/_virtual/_One1.js deleted file mode 100644 index 2e2081c7b39..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-id-case-sensitive/_expected/cjs/_virtual/_One1.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -var c = 'One1.js'; - -module.exports = c; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-id-case-sensitive/_expected/cjs/_virtual/_One2.js b/test/chunking-form/samples/deprecated/preserve-modules-id-case-sensitive/_expected/cjs/_virtual/_One2.js deleted file mode 100644 index 94e5e6eebdb..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-id-case-sensitive/_expected/cjs/_virtual/_One2.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -var b = 'One.js'; - -module.exports = b; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-id-case-sensitive/_expected/cjs/_virtual/_one.js b/test/chunking-form/samples/deprecated/preserve-modules-id-case-sensitive/_expected/cjs/_virtual/_one.js deleted file mode 100644 index 04b4a696e73..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-id-case-sensitive/_expected/cjs/_virtual/_one.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -var a = 'one.js'; - -module.exports = a; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-id-case-sensitive/_expected/cjs/main.js b/test/chunking-form/samples/deprecated/preserve-modules-id-case-sensitive/_expected/cjs/main.js deleted file mode 100644 index d113352518b..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-id-case-sensitive/_expected/cjs/main.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -var _one = require('./_virtual/_one.js'); -var _One = require('./_virtual/_One2.js'); -var _One1 = require('./_virtual/_One1.js'); - -window.APP = { a: _one, b: _One, c: _One1 }; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-id-case-sensitive/_expected/es/_virtual/_One1.js b/test/chunking-form/samples/deprecated/preserve-modules-id-case-sensitive/_expected/es/_virtual/_One1.js deleted file mode 100644 index 3ea816df737..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-id-case-sensitive/_expected/es/_virtual/_One1.js +++ /dev/null @@ -1,3 +0,0 @@ -var c = 'One1.js'; - -export default c; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-id-case-sensitive/_expected/es/_virtual/_One2.js b/test/chunking-form/samples/deprecated/preserve-modules-id-case-sensitive/_expected/es/_virtual/_One2.js deleted file mode 100644 index d889775b3d6..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-id-case-sensitive/_expected/es/_virtual/_One2.js +++ /dev/null @@ -1,3 +0,0 @@ -var b = 'One.js'; - -export default b; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-id-case-sensitive/_expected/es/_virtual/_one.js b/test/chunking-form/samples/deprecated/preserve-modules-id-case-sensitive/_expected/es/_virtual/_one.js deleted file mode 100644 index 615c3de0ca9..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-id-case-sensitive/_expected/es/_virtual/_one.js +++ /dev/null @@ -1,3 +0,0 @@ -var a = 'one.js'; - -export default a; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-id-case-sensitive/_expected/es/main.js b/test/chunking-form/samples/deprecated/preserve-modules-id-case-sensitive/_expected/es/main.js deleted file mode 100644 index e7a751f410a..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-id-case-sensitive/_expected/es/main.js +++ /dev/null @@ -1,5 +0,0 @@ -import a from './_virtual/_one.js'; -import b from './_virtual/_One2.js'; -import c from './_virtual/_One1.js'; - -window.APP = { a, b, c }; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-id-case-sensitive/_expected/system/_virtual/_One1.js b/test/chunking-form/samples/deprecated/preserve-modules-id-case-sensitive/_expected/system/_virtual/_One1.js deleted file mode 100644 index eb4e015bab5..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-id-case-sensitive/_expected/system/_virtual/_One1.js +++ /dev/null @@ -1,10 +0,0 @@ -System.register([], function (exports) { - 'use strict'; - return { - execute: function () { - - var c = exports('default', 'One1.js'); - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-id-case-sensitive/_expected/system/_virtual/_One2.js b/test/chunking-form/samples/deprecated/preserve-modules-id-case-sensitive/_expected/system/_virtual/_One2.js deleted file mode 100644 index 04b90908308..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-id-case-sensitive/_expected/system/_virtual/_One2.js +++ /dev/null @@ -1,10 +0,0 @@ -System.register([], function (exports) { - 'use strict'; - return { - execute: function () { - - var b = exports('default', 'One.js'); - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-id-case-sensitive/_expected/system/_virtual/_one.js b/test/chunking-form/samples/deprecated/preserve-modules-id-case-sensitive/_expected/system/_virtual/_one.js deleted file mode 100644 index f6c4ac9f9fd..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-id-case-sensitive/_expected/system/_virtual/_one.js +++ /dev/null @@ -1,10 +0,0 @@ -System.register([], function (exports) { - 'use strict'; - return { - execute: function () { - - var a = exports('default', 'one.js'); - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-id-case-sensitive/_expected/system/main.js b/test/chunking-form/samples/deprecated/preserve-modules-id-case-sensitive/_expected/system/main.js deleted file mode 100644 index 17303445bb0..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-id-case-sensitive/_expected/system/main.js +++ /dev/null @@ -1,18 +0,0 @@ -System.register(['./_virtual/_one.js', './_virtual/_One2.js', './_virtual/_One1.js'], function () { - 'use strict'; - var a, b, c; - return { - setters: [function (module) { - a = module.default; - }, function (module) { - b = module.default; - }, function (module) { - c = module.default; - }], - execute: function () { - - window.APP = { a, b, c }; - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-id-case-sensitive/main.js b/test/chunking-form/samples/deprecated/preserve-modules-id-case-sensitive/main.js deleted file mode 100644 index 49a5f34ffef..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-id-case-sensitive/main.js +++ /dev/null @@ -1,5 +0,0 @@ -import a from '\0one.js'; -import b from '\0One.js'; -import c from '\0One1.js'; - -window.APP = { a, b, c }; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-named-export-mode/_config.js b/test/chunking-form/samples/deprecated/preserve-modules-named-export-mode/_config.js deleted file mode 100644 index b79256cfb0b..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-named-export-mode/_config.js +++ /dev/null @@ -1,11 +0,0 @@ -module.exports = { - description: 'respects "named" export mode in all chunks when preserving modules', - options: { - strictDeprecations: false, - input: 'main.js', - preserveModules: true, - output: { - exports: 'named' - } - } -}; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-named-export-mode/_expected/amd/default.js b/test/chunking-form/samples/deprecated/preserve-modules-named-export-mode/_expected/amd/default.js deleted file mode 100644 index e8359fc2e7b..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-named-export-mode/_expected/amd/default.js +++ /dev/null @@ -1,9 +0,0 @@ -define(['exports'], function (exports) { 'use strict'; - - var foo = 'default'; - - exports.default = foo; - - Object.defineProperty(exports, '__esModule', { value: true }); - -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-named-export-mode/_expected/amd/main.js b/test/chunking-form/samples/deprecated/preserve-modules-named-export-mode/_expected/amd/main.js deleted file mode 100644 index 8d0b41b8c5c..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-named-export-mode/_expected/amd/main.js +++ /dev/null @@ -1,12 +0,0 @@ -define(['require', 'exports', './default', './named'], function (require, exports, _default, named) { 'use strict'; - - console.log(_default['default'], named.value); - - new Promise(function (resolve, reject) { require(['./default'], resolve, reject) }).then(result => console.log(result.default)); - new Promise(function (resolve, reject) { require(['./named'], resolve, reject) }).then(result => console.log(result.value)); - - exports.default = _default['default']; - - Object.defineProperty(exports, '__esModule', { value: true }); - -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-named-export-mode/_expected/amd/named.js b/test/chunking-form/samples/deprecated/preserve-modules-named-export-mode/_expected/amd/named.js deleted file mode 100644 index 37e6d25bd85..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-named-export-mode/_expected/amd/named.js +++ /dev/null @@ -1,9 +0,0 @@ -define(['exports'], function (exports) { 'use strict'; - - const value = 'named'; - - exports.value = value; - - Object.defineProperty(exports, '__esModule', { value: true }); - -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-named-export-mode/_expected/cjs/default.js b/test/chunking-form/samples/deprecated/preserve-modules-named-export-mode/_expected/cjs/default.js deleted file mode 100644 index bc9cb9bdcb9..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-named-export-mode/_expected/cjs/default.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { value: true }); - -var foo = 'default'; - -exports.default = foo; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-named-export-mode/_expected/cjs/main.js b/test/chunking-form/samples/deprecated/preserve-modules-named-export-mode/_expected/cjs/main.js deleted file mode 100644 index 8c9a245414b..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-named-export-mode/_expected/cjs/main.js +++ /dev/null @@ -1,13 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { value: true }); - -var _default = require('./default.js'); -var named = require('./named.js'); - -console.log(_default['default'], named.value); - -Promise.resolve().then(function () { return require('./default.js'); }).then(result => console.log(result.default)); -Promise.resolve().then(function () { return require('./named.js'); }).then(result => console.log(result.value)); - -exports.default = _default['default']; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-named-export-mode/_expected/cjs/named.js b/test/chunking-form/samples/deprecated/preserve-modules-named-export-mode/_expected/cjs/named.js deleted file mode 100644 index 491f8569447..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-named-export-mode/_expected/cjs/named.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { value: true }); - -const value = 'named'; - -exports.value = value; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-named-export-mode/_expected/es/default.js b/test/chunking-form/samples/deprecated/preserve-modules-named-export-mode/_expected/es/default.js deleted file mode 100644 index 97dcda8cdc9..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-named-export-mode/_expected/es/default.js +++ /dev/null @@ -1,3 +0,0 @@ -var foo = 'default'; - -export default foo; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-named-export-mode/_expected/es/main.js b/test/chunking-form/samples/deprecated/preserve-modules-named-export-mode/_expected/es/main.js deleted file mode 100644 index 1db891a835f..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-named-export-mode/_expected/es/main.js +++ /dev/null @@ -1,8 +0,0 @@ -import foo from './default.js'; -export { default } from './default.js'; -import { value } from './named.js'; - -console.log(foo, value); - -import('./default.js').then(result => console.log(result.default)); -import('./named.js').then(result => console.log(result.value)); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-named-export-mode/_expected/es/named.js b/test/chunking-form/samples/deprecated/preserve-modules-named-export-mode/_expected/es/named.js deleted file mode 100644 index f632590076b..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-named-export-mode/_expected/es/named.js +++ /dev/null @@ -1,3 +0,0 @@ -const value = 'named'; - -export { value }; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-named-export-mode/_expected/system/default.js b/test/chunking-form/samples/deprecated/preserve-modules-named-export-mode/_expected/system/default.js deleted file mode 100644 index 0505d3144dd..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-named-export-mode/_expected/system/default.js +++ /dev/null @@ -1,10 +0,0 @@ -System.register([], function (exports) { - 'use strict'; - return { - execute: function () { - - var foo = exports('default', 'default'); - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-named-export-mode/_expected/system/main.js b/test/chunking-form/samples/deprecated/preserve-modules-named-export-mode/_expected/system/main.js deleted file mode 100644 index 12e707aee57..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-named-export-mode/_expected/system/main.js +++ /dev/null @@ -1,20 +0,0 @@ -System.register(['./default.js', './named.js'], function (exports, module) { - 'use strict'; - var foo, value; - return { - setters: [function (module) { - foo = module.default; - exports('default', module.default); - }, function (module) { - value = module.value; - }], - execute: function () { - - console.log(foo, value); - - module.import('./default.js').then(result => console.log(result.default)); - module.import('./named.js').then(result => console.log(result.value)); - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-named-export-mode/_expected/system/named.js b/test/chunking-form/samples/deprecated/preserve-modules-named-export-mode/_expected/system/named.js deleted file mode 100644 index 431654fc285..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-named-export-mode/_expected/system/named.js +++ /dev/null @@ -1,10 +0,0 @@ -System.register([], function (exports) { - 'use strict'; - return { - execute: function () { - - const value = exports('value', 'named'); - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-named-export-mode/default.js b/test/chunking-form/samples/deprecated/preserve-modules-named-export-mode/default.js deleted file mode 100644 index 413f601a377..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-named-export-mode/default.js +++ /dev/null @@ -1 +0,0 @@ -export default 'default'; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-named-export-mode/main.js b/test/chunking-form/samples/deprecated/preserve-modules-named-export-mode/main.js deleted file mode 100644 index 72dc390d821..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-named-export-mode/main.js +++ /dev/null @@ -1,8 +0,0 @@ -import foo from './default.js'; -import { value } from './named.js'; -console.log(foo, value); - -export { default } from './default.js'; - -import('./default').then(result => console.log(result.default)); -import('./named').then(result => console.log(result.value)); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-named-export-mode/named.js b/test/chunking-form/samples/deprecated/preserve-modules-named-export-mode/named.js deleted file mode 100644 index a5c403fef99..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-named-export-mode/named.js +++ /dev/null @@ -1 +0,0 @@ -export const value = 'named'; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-nested-barrel-es-export/_config.js b/test/chunking-form/samples/deprecated/preserve-modules-nested-barrel-es-export/_config.js deleted file mode 100644 index 22ec30f4ec3..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-nested-barrel-es-export/_config.js +++ /dev/null @@ -1,8 +0,0 @@ -module.exports = { - description: 'confirm exports are deconflicted when exporting nested index aliases', - options: { - strictDeprecations: false, - input: 'main.js', - preserveModules: true - } -}; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-nested-barrel-es-export/_expected/amd/main.js b/test/chunking-form/samples/deprecated/preserve-modules-nested-barrel-es-export/_expected/amd/main.js deleted file mode 100644 index 12dccf71f8f..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-nested-barrel-es-export/_expected/amd/main.js +++ /dev/null @@ -1,10 +0,0 @@ -define(['exports', './module-a/v1/index', './module-b/v1/index'], function (exports, index, index$1) { 'use strict'; - - - - exports.ModuleA_V1 = index; - exports.ModuleB_V1 = index$1; - - Object.defineProperty(exports, '__esModule', { value: true }); - -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-nested-barrel-es-export/_expected/amd/module-a/v1/index.js b/test/chunking-form/samples/deprecated/preserve-modules-nested-barrel-es-export/_expected/amd/module-a/v1/index.js deleted file mode 100644 index 2c1cbb5248d..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-nested-barrel-es-export/_expected/amd/module-a/v1/index.js +++ /dev/null @@ -1,9 +0,0 @@ -define(['exports'], function (exports) { 'use strict'; - - const TEST_MODULE_A = 'A'; - - exports.TEST_MODULE_A = TEST_MODULE_A; - - Object.defineProperty(exports, '__esModule', { value: true }); - -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-nested-barrel-es-export/_expected/amd/module-b/v1/index.js b/test/chunking-form/samples/deprecated/preserve-modules-nested-barrel-es-export/_expected/amd/module-b/v1/index.js deleted file mode 100644 index b56f633d9fb..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-nested-barrel-es-export/_expected/amd/module-b/v1/index.js +++ /dev/null @@ -1,9 +0,0 @@ -define(['exports'], function (exports) { 'use strict'; - - const TEST_MODULE_B = 'A'; - - exports.TEST_MODULE_B = TEST_MODULE_B; - - Object.defineProperty(exports, '__esModule', { value: true }); - -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-nested-barrel-es-export/_expected/cjs/main.js b/test/chunking-form/samples/deprecated/preserve-modules-nested-barrel-es-export/_expected/cjs/main.js deleted file mode 100644 index 632ce47b9ae..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-nested-barrel-es-export/_expected/cjs/main.js +++ /dev/null @@ -1,11 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { value: true }); - -var index = require('./module-a/v1/index.js'); -var index$1 = require('./module-b/v1/index.js'); - - - -exports.ModuleA_V1 = index; -exports.ModuleB_V1 = index$1; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-nested-barrel-es-export/_expected/cjs/module-a/v1/index.js b/test/chunking-form/samples/deprecated/preserve-modules-nested-barrel-es-export/_expected/cjs/module-a/v1/index.js deleted file mode 100644 index a8ab4802133..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-nested-barrel-es-export/_expected/cjs/module-a/v1/index.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { value: true }); - -const TEST_MODULE_A = 'A'; - -exports.TEST_MODULE_A = TEST_MODULE_A; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-nested-barrel-es-export/_expected/cjs/module-b/v1/index.js b/test/chunking-form/samples/deprecated/preserve-modules-nested-barrel-es-export/_expected/cjs/module-b/v1/index.js deleted file mode 100644 index 2c2b23c7d63..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-nested-barrel-es-export/_expected/cjs/module-b/v1/index.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { value: true }); - -const TEST_MODULE_B = 'A'; - -exports.TEST_MODULE_B = TEST_MODULE_B; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-nested-barrel-es-export/_expected/es/main.js b/test/chunking-form/samples/deprecated/preserve-modules-nested-barrel-es-export/_expected/es/main.js deleted file mode 100644 index 537dda397a8..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-nested-barrel-es-export/_expected/es/main.js +++ /dev/null @@ -1,4 +0,0 @@ -import * as index from './module-a/v1/index.js'; -export { index as ModuleA_V1 }; -import * as index$1 from './module-b/v1/index.js'; -export { index$1 as ModuleB_V1 }; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-nested-barrel-es-export/_expected/es/module-a/v1/index.js b/test/chunking-form/samples/deprecated/preserve-modules-nested-barrel-es-export/_expected/es/module-a/v1/index.js deleted file mode 100644 index a8158380482..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-nested-barrel-es-export/_expected/es/module-a/v1/index.js +++ /dev/null @@ -1,3 +0,0 @@ -const TEST_MODULE_A = 'A'; - -export { TEST_MODULE_A }; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-nested-barrel-es-export/_expected/es/module-b/v1/index.js b/test/chunking-form/samples/deprecated/preserve-modules-nested-barrel-es-export/_expected/es/module-b/v1/index.js deleted file mode 100644 index 338a266e13c..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-nested-barrel-es-export/_expected/es/module-b/v1/index.js +++ /dev/null @@ -1,3 +0,0 @@ -const TEST_MODULE_B = 'A'; - -export { TEST_MODULE_B }; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-nested-barrel-es-export/_expected/system/main.js b/test/chunking-form/samples/deprecated/preserve-modules-nested-barrel-es-export/_expected/system/main.js deleted file mode 100644 index 69423415aa6..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-nested-barrel-es-export/_expected/system/main.js +++ /dev/null @@ -1,15 +0,0 @@ -System.register(['./module-a/v1/index.js', './module-b/v1/index.js'], function (exports) { - 'use strict'; - return { - setters: [function (module) { - exports('ModuleA_V1', module); - }, function (module) { - exports('ModuleB_V1', module); - }], - execute: function () { - - - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-nested-barrel-es-export/_expected/system/module-a/v1/index.js b/test/chunking-form/samples/deprecated/preserve-modules-nested-barrel-es-export/_expected/system/module-a/v1/index.js deleted file mode 100644 index 400a5460fc9..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-nested-barrel-es-export/_expected/system/module-a/v1/index.js +++ /dev/null @@ -1,10 +0,0 @@ -System.register([], function (exports) { - 'use strict'; - return { - execute: function () { - - const TEST_MODULE_A = exports('TEST_MODULE_A', 'A'); - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-nested-barrel-es-export/_expected/system/module-b/v1/index.js b/test/chunking-form/samples/deprecated/preserve-modules-nested-barrel-es-export/_expected/system/module-b/v1/index.js deleted file mode 100644 index 337b556bb25..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-nested-barrel-es-export/_expected/system/module-b/v1/index.js +++ /dev/null @@ -1,10 +0,0 @@ -System.register([], function (exports) { - 'use strict'; - return { - execute: function () { - - const TEST_MODULE_B = exports('TEST_MODULE_B', 'A'); - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-nested-barrel-es-export/main.js b/test/chunking-form/samples/deprecated/preserve-modules-nested-barrel-es-export/main.js deleted file mode 100644 index 6322b946820..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-nested-barrel-es-export/main.js +++ /dev/null @@ -1,2 +0,0 @@ -export * from './module-a/index' -export * from './module-b/index' \ No newline at end of file diff --git a/test/chunking-form/samples/deprecated/preserve-modules-nested-barrel-es-export/module-a/index.js b/test/chunking-form/samples/deprecated/preserve-modules-nested-barrel-es-export/module-a/index.js deleted file mode 100644 index 6bd359daf1f..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-nested-barrel-es-export/module-a/index.js +++ /dev/null @@ -1,3 +0,0 @@ -import * as ModuleA_V1 from './v1/index' - -export { ModuleA_V1 } \ No newline at end of file diff --git a/test/chunking-form/samples/deprecated/preserve-modules-nested-barrel-es-export/module-a/v1/index.js b/test/chunking-form/samples/deprecated/preserve-modules-nested-barrel-es-export/module-a/v1/index.js deleted file mode 100644 index 8bc392c756a..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-nested-barrel-es-export/module-a/v1/index.js +++ /dev/null @@ -1 +0,0 @@ -export const TEST_MODULE_A = 'A' \ No newline at end of file diff --git a/test/chunking-form/samples/deprecated/preserve-modules-nested-barrel-es-export/module-b/index.js b/test/chunking-form/samples/deprecated/preserve-modules-nested-barrel-es-export/module-b/index.js deleted file mode 100644 index f9b363cdf9f..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-nested-barrel-es-export/module-b/index.js +++ /dev/null @@ -1,3 +0,0 @@ -import * as ModuleB_V1 from './v1/index' - -export { ModuleB_V1 } \ No newline at end of file diff --git a/test/chunking-form/samples/deprecated/preserve-modules-nested-barrel-es-export/module-b/v1/index.js b/test/chunking-form/samples/deprecated/preserve-modules-nested-barrel-es-export/module-b/v1/index.js deleted file mode 100644 index 1d751964f68..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-nested-barrel-es-export/module-b/v1/index.js +++ /dev/null @@ -1 +0,0 @@ -export const TEST_MODULE_B = 'A' \ No newline at end of file diff --git a/test/chunking-form/samples/deprecated/preserve-modules-nested-export/_config.js b/test/chunking-form/samples/deprecated/preserve-modules-nested-export/_config.js deleted file mode 100644 index 291753db080..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-nested-export/_config.js +++ /dev/null @@ -1,8 +0,0 @@ -module.exports = { - description: 'confirm exports are preserved when exporting a module', - options: { - strictDeprecations: false, - input: 'main.js', - preserveModules: true - } -}; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-nested-export/_expected/amd/inner/more_inner/something.js b/test/chunking-form/samples/deprecated/preserve-modules-nested-export/_expected/amd/inner/more_inner/something.js deleted file mode 100644 index 138d9ba9e40..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-nested-export/_expected/amd/inner/more_inner/something.js +++ /dev/null @@ -1,9 +0,0 @@ -define(['exports'], function (exports) { 'use strict'; - - const Something = 'Hello World'; - - exports.Something = Something; - - Object.defineProperty(exports, '__esModule', { value: true }); - -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-nested-export/_expected/amd/inner/some_effect.js b/test/chunking-form/samples/deprecated/preserve-modules-nested-export/_expected/amd/inner/some_effect.js deleted file mode 100644 index 621699a15d1..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-nested-export/_expected/amd/inner/some_effect.js +++ /dev/null @@ -1,5 +0,0 @@ -define(function () { 'use strict'; - - console.log('side-effect'); - -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-nested-export/_expected/amd/main.js b/test/chunking-form/samples/deprecated/preserve-modules-nested-export/_expected/amd/main.js deleted file mode 100644 index c89b17c4c11..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-nested-export/_expected/amd/main.js +++ /dev/null @@ -1,9 +0,0 @@ -define(['exports', './inner/more_inner/something', './inner/some_effect'], function (exports, something, some_effect) { 'use strict'; - - - - exports.Something = something.Something; - - Object.defineProperty(exports, '__esModule', { value: true }); - -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-nested-export/_expected/cjs/inner/more_inner/something.js b/test/chunking-form/samples/deprecated/preserve-modules-nested-export/_expected/cjs/inner/more_inner/something.js deleted file mode 100644 index 32f3040b7c0..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-nested-export/_expected/cjs/inner/more_inner/something.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { value: true }); - -const Something = 'Hello World'; - -exports.Something = Something; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-nested-export/_expected/cjs/inner/some_effect.js b/test/chunking-form/samples/deprecated/preserve-modules-nested-export/_expected/cjs/inner/some_effect.js deleted file mode 100644 index 28e48ebec94..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-nested-export/_expected/cjs/inner/some_effect.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -console.log('side-effect'); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-nested-export/_expected/cjs/main.js b/test/chunking-form/samples/deprecated/preserve-modules-nested-export/_expected/cjs/main.js deleted file mode 100644 index ffa1d0bc5bb..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-nested-export/_expected/cjs/main.js +++ /dev/null @@ -1,10 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { value: true }); - -var something = require('./inner/more_inner/something.js'); -require('./inner/some_effect.js'); - - - -exports.Something = something.Something; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-nested-export/_expected/es/inner/more_inner/something.js b/test/chunking-form/samples/deprecated/preserve-modules-nested-export/_expected/es/inner/more_inner/something.js deleted file mode 100644 index 636a4132444..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-nested-export/_expected/es/inner/more_inner/something.js +++ /dev/null @@ -1,3 +0,0 @@ -const Something = 'Hello World'; - -export { Something }; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-nested-export/_expected/es/inner/some_effect.js b/test/chunking-form/samples/deprecated/preserve-modules-nested-export/_expected/es/inner/some_effect.js deleted file mode 100644 index 4ca9b41c411..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-nested-export/_expected/es/inner/some_effect.js +++ /dev/null @@ -1 +0,0 @@ -console.log('side-effect'); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-nested-export/_expected/es/main.js b/test/chunking-form/samples/deprecated/preserve-modules-nested-export/_expected/es/main.js deleted file mode 100644 index efa908a5a5b..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-nested-export/_expected/es/main.js +++ /dev/null @@ -1,2 +0,0 @@ -export { Something } from './inner/more_inner/something.js'; -import './inner/some_effect.js'; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-nested-export/_expected/system/inner/more_inner/something.js b/test/chunking-form/samples/deprecated/preserve-modules-nested-export/_expected/system/inner/more_inner/something.js deleted file mode 100644 index 1b4bba21314..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-nested-export/_expected/system/inner/more_inner/something.js +++ /dev/null @@ -1,10 +0,0 @@ -System.register([], function (exports) { - 'use strict'; - return { - execute: function () { - - const Something = exports('Something', 'Hello World'); - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-nested-export/_expected/system/inner/some_effect.js b/test/chunking-form/samples/deprecated/preserve-modules-nested-export/_expected/system/inner/some_effect.js deleted file mode 100644 index 19dd3ec79bd..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-nested-export/_expected/system/inner/some_effect.js +++ /dev/null @@ -1,10 +0,0 @@ -System.register([], function () { - 'use strict'; - return { - execute: function () { - - console.log('side-effect'); - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-nested-export/_expected/system/main.js b/test/chunking-form/samples/deprecated/preserve-modules-nested-export/_expected/system/main.js deleted file mode 100644 index 16e27681d9a..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-nested-export/_expected/system/main.js +++ /dev/null @@ -1,13 +0,0 @@ -System.register(['./inner/more_inner/something.js', './inner/some_effect.js'], function (exports) { - 'use strict'; - return { - setters: [function (module) { - exports('Something', module.Something); - }, function () {}], - execute: function () { - - - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-nested-export/inner/index.js b/test/chunking-form/samples/deprecated/preserve-modules-nested-export/inner/index.js deleted file mode 100644 index b46f14091cf..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-nested-export/inner/index.js +++ /dev/null @@ -1,2 +0,0 @@ -export * from './more_inner/index'; -import './some_effect'; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-nested-export/inner/more_inner/index.js b/test/chunking-form/samples/deprecated/preserve-modules-nested-export/inner/more_inner/index.js deleted file mode 100644 index 93e297c24fb..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-nested-export/inner/more_inner/index.js +++ /dev/null @@ -1 +0,0 @@ -export * from './something'; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-nested-export/inner/more_inner/something.js b/test/chunking-form/samples/deprecated/preserve-modules-nested-export/inner/more_inner/something.js deleted file mode 100644 index 60e3455d002..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-nested-export/inner/more_inner/something.js +++ /dev/null @@ -1 +0,0 @@ -export const Something = 'Hello World'; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-nested-export/inner/some_effect.js b/test/chunking-form/samples/deprecated/preserve-modules-nested-export/inner/some_effect.js deleted file mode 100644 index 4ca9b41c411..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-nested-export/inner/some_effect.js +++ /dev/null @@ -1 +0,0 @@ -console.log('side-effect'); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-nested-export/main.js b/test/chunking-form/samples/deprecated/preserve-modules-nested-export/main.js deleted file mode 100644 index ee0c7608365..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-nested-export/main.js +++ /dev/null @@ -1 +0,0 @@ -export * from './inner/index'; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-non-entry-imports/_config.js b/test/chunking-form/samples/deprecated/preserve-modules-non-entry-imports/_config.js deleted file mode 100644 index 157659436ee..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-non-entry-imports/_config.js +++ /dev/null @@ -1,8 +0,0 @@ -module.exports = { - description: 'imports and exports of non-entry points are tracked', - options: { - strictDeprecations: false, - input: 'main.js', - preserveModules: true - } -}; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-non-entry-imports/_expected/amd/dep2.js b/test/chunking-form/samples/deprecated/preserve-modules-non-entry-imports/_expected/amd/dep2.js deleted file mode 100644 index 16210f80f24..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-non-entry-imports/_expected/amd/dep2.js +++ /dev/null @@ -1,7 +0,0 @@ -define(function () { 'use strict'; - - function foo() {} - - return foo; - -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-non-entry-imports/_expected/amd/main.js b/test/chunking-form/samples/deprecated/preserve-modules-non-entry-imports/_expected/amd/main.js deleted file mode 100644 index 085588168a4..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-non-entry-imports/_expected/amd/main.js +++ /dev/null @@ -1,7 +0,0 @@ -define(['./dep2'], function (dep2) { 'use strict'; - - - - return dep2; - -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-non-entry-imports/_expected/cjs/dep2.js b/test/chunking-form/samples/deprecated/preserve-modules-non-entry-imports/_expected/cjs/dep2.js deleted file mode 100644 index d356914dcc3..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-non-entry-imports/_expected/cjs/dep2.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -function foo() {} - -module.exports = foo; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-non-entry-imports/_expected/cjs/main.js b/test/chunking-form/samples/deprecated/preserve-modules-non-entry-imports/_expected/cjs/main.js deleted file mode 100644 index 663b040c9e7..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-non-entry-imports/_expected/cjs/main.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -var dep2 = require('./dep2.js'); - - - -module.exports = dep2; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-non-entry-imports/_expected/es/dep2.js b/test/chunking-form/samples/deprecated/preserve-modules-non-entry-imports/_expected/es/dep2.js deleted file mode 100644 index e39ccfc8db2..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-non-entry-imports/_expected/es/dep2.js +++ /dev/null @@ -1,3 +0,0 @@ -function foo() {} - -export default foo; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-non-entry-imports/_expected/es/main.js b/test/chunking-form/samples/deprecated/preserve-modules-non-entry-imports/_expected/es/main.js deleted file mode 100644 index 845c1582956..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-non-entry-imports/_expected/es/main.js +++ /dev/null @@ -1,2 +0,0 @@ -import foo from './dep2.js'; -export { default } from './dep2.js'; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-non-entry-imports/_expected/system/dep2.js b/test/chunking-form/samples/deprecated/preserve-modules-non-entry-imports/_expected/system/dep2.js deleted file mode 100644 index eb88d79aeda..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-non-entry-imports/_expected/system/dep2.js +++ /dev/null @@ -1,12 +0,0 @@ -System.register([], function (exports) { - 'use strict'; - return { - execute: function () { - - exports('default', foo); - - function foo() {} - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-non-entry-imports/_expected/system/main.js b/test/chunking-form/samples/deprecated/preserve-modules-non-entry-imports/_expected/system/main.js deleted file mode 100644 index 8f2d06a8f51..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-non-entry-imports/_expected/system/main.js +++ /dev/null @@ -1,15 +0,0 @@ -System.register(['./dep2.js'], function (exports) { - 'use strict'; - var foo; - return { - setters: [function (module) { - foo = module.default; - exports('default', module.default); - }], - execute: function () { - - - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-non-entry-imports/dep1.js b/test/chunking-form/samples/deprecated/preserve-modules-non-entry-imports/dep1.js deleted file mode 100644 index 2c5a157d2d8..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-non-entry-imports/dep1.js +++ /dev/null @@ -1 +0,0 @@ -export { default } from './dep2'; \ No newline at end of file diff --git a/test/chunking-form/samples/deprecated/preserve-modules-non-entry-imports/dep2.js b/test/chunking-form/samples/deprecated/preserve-modules-non-entry-imports/dep2.js deleted file mode 100644 index a5e4ff3389d..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-non-entry-imports/dep2.js +++ /dev/null @@ -1 +0,0 @@ -export default function() {}; \ No newline at end of file diff --git a/test/chunking-form/samples/deprecated/preserve-modules-non-entry-imports/main.js b/test/chunking-form/samples/deprecated/preserve-modules-non-entry-imports/main.js deleted file mode 100644 index 24640f29f7f..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-non-entry-imports/main.js +++ /dev/null @@ -1,3 +0,0 @@ -import foo from './dep1'; - -export default foo; \ No newline at end of file diff --git a/test/chunking-form/samples/deprecated/preserve-modules-proxy-import/_config.js b/test/chunking-form/samples/deprecated/preserve-modules-proxy-import/_config.js deleted file mode 100644 index 19e53c11fe1..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-proxy-import/_config.js +++ /dev/null @@ -1,9 +0,0 @@ -module.exports = { - description: - 'correctly resolves imports via a proxy module as direct imports when preserving modules', - options: { - strictDeprecations: false, - preserveModules: true, - external: 'external' - } -}; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-proxy-import/_expected/amd/main.js b/test/chunking-form/samples/deprecated/preserve-modules-proxy-import/_expected/amd/main.js deleted file mode 100644 index 0abc6cfe931..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-proxy-import/_expected/amd/main.js +++ /dev/null @@ -1,10 +0,0 @@ -define(['external'], function (path) { 'use strict'; - - function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } - - var path__default = /*#__PURE__*/_interopDefaultLegacy(path); - - console.log(path__default['default'].normalize('foo\\bar')); - console.log(path__default['default'].normalize('foo\\bar')); - -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-proxy-import/_expected/amd/proxy.js b/test/chunking-form/samples/deprecated/preserve-modules-proxy-import/_expected/amd/proxy.js deleted file mode 100644 index e130c8d6da4..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-proxy-import/_expected/amd/proxy.js +++ /dev/null @@ -1,11 +0,0 @@ -define(['external'], function (path) { 'use strict'; - - function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } - - var path__default = /*#__PURE__*/_interopDefaultLegacy(path); - - - - return path__default['default']; - -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-proxy-import/_expected/cjs/main.js b/test/chunking-form/samples/deprecated/preserve-modules-proxy-import/_expected/cjs/main.js deleted file mode 100644 index b018def073b..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-proxy-import/_expected/cjs/main.js +++ /dev/null @@ -1,10 +0,0 @@ -'use strict'; - -var path = require('external'); - -function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } - -var path__default = /*#__PURE__*/_interopDefaultLegacy(path); - -console.log(path__default['default'].normalize('foo\\bar')); -console.log(path__default['default'].normalize('foo\\bar')); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-proxy-import/_expected/cjs/proxy.js b/test/chunking-form/samples/deprecated/preserve-modules-proxy-import/_expected/cjs/proxy.js deleted file mode 100644 index f536101936d..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-proxy-import/_expected/cjs/proxy.js +++ /dev/null @@ -1,11 +0,0 @@ -'use strict'; - -var path = require('external'); - -function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } - -var path__default = /*#__PURE__*/_interopDefaultLegacy(path); - - - -module.exports = path__default['default']; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-proxy-import/_expected/es/main.js b/test/chunking-form/samples/deprecated/preserve-modules-proxy-import/_expected/es/main.js deleted file mode 100644 index 57a9f2785a9..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-proxy-import/_expected/es/main.js +++ /dev/null @@ -1,4 +0,0 @@ -import path from 'external'; - -console.log(path.normalize('foo\\bar')); -console.log(path.normalize('foo\\bar')); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-proxy-import/_expected/es/proxy.js b/test/chunking-form/samples/deprecated/preserve-modules-proxy-import/_expected/es/proxy.js deleted file mode 100644 index 0b1c97e9bca..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-proxy-import/_expected/es/proxy.js +++ /dev/null @@ -1,2 +0,0 @@ -import path from 'external'; -export { default } from 'external'; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-proxy-import/_expected/system/main.js b/test/chunking-form/samples/deprecated/preserve-modules-proxy-import/_expected/system/main.js deleted file mode 100644 index cdb1f31d2d8..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-proxy-import/_expected/system/main.js +++ /dev/null @@ -1,15 +0,0 @@ -System.register(['external'], function () { - 'use strict'; - var path; - return { - setters: [function (module) { - path = module.default; - }], - execute: function () { - - console.log(path.normalize('foo\\bar')); - console.log(path.normalize('foo\\bar')); - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-proxy-import/_expected/system/proxy.js b/test/chunking-form/samples/deprecated/preserve-modules-proxy-import/_expected/system/proxy.js deleted file mode 100644 index 131f0eac764..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-proxy-import/_expected/system/proxy.js +++ /dev/null @@ -1,15 +0,0 @@ -System.register(['external'], function (exports) { - 'use strict'; - var path; - return { - setters: [function (module) { - path = module.default; - exports('default', module.default); - }], - execute: function () { - - - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-proxy-import/main.js b/test/chunking-form/samples/deprecated/preserve-modules-proxy-import/main.js deleted file mode 100644 index 288bd4a163c..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-proxy-import/main.js +++ /dev/null @@ -1,5 +0,0 @@ -import path from 'external'; -import proxyPath from './proxy'; - -console.log(path.normalize('foo\\bar')); -console.log(proxyPath.normalize('foo\\bar')); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-proxy-import/proxy.js b/test/chunking-form/samples/deprecated/preserve-modules-proxy-import/proxy.js deleted file mode 100644 index 4635dc5b4a2..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-proxy-import/proxy.js +++ /dev/null @@ -1,2 +0,0 @@ -import path from 'external'; -export default path; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-reaching-outside/_config.js b/test/chunking-form/samples/deprecated/preserve-modules-reaching-outside/_config.js deleted file mode 100644 index e71eaf513aa..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-reaching-outside/_config.js +++ /dev/null @@ -1,8 +0,0 @@ -module.exports = { - description: 'change the module destination', - options: { - strictDeprecations: false, - input: 'src/lib/main.js', - preserveModules: true - } -}; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-reaching-outside/_expected/amd/dep.js b/test/chunking-form/samples/deprecated/preserve-modules-reaching-outside/_expected/amd/dep.js deleted file mode 100644 index 93365a06219..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-reaching-outside/_expected/amd/dep.js +++ /dev/null @@ -1,11 +0,0 @@ -define(['exports'], function (exports) { 'use strict'; - - function fn () { - console.log('dep fn'); - } - - exports.fn = fn; - - Object.defineProperty(exports, '__esModule', { value: true }); - -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-reaching-outside/_expected/amd/lib/main.js b/test/chunking-form/samples/deprecated/preserve-modules-reaching-outside/_expected/amd/lib/main.js deleted file mode 100644 index ff8eacced99..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-reaching-outside/_expected/amd/lib/main.js +++ /dev/null @@ -1,11 +0,0 @@ -define(['../dep'], function (dep) { 'use strict'; - - class Main { - constructor () { - dep.fn(); - } - } - - return Main; - -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-reaching-outside/_expected/cjs/dep.js b/test/chunking-form/samples/deprecated/preserve-modules-reaching-outside/_expected/cjs/dep.js deleted file mode 100644 index b67a1e41d97..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-reaching-outside/_expected/cjs/dep.js +++ /dev/null @@ -1,9 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { value: true }); - -function fn () { - console.log('dep fn'); -} - -exports.fn = fn; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-reaching-outside/_expected/cjs/lib/main.js b/test/chunking-form/samples/deprecated/preserve-modules-reaching-outside/_expected/cjs/lib/main.js deleted file mode 100644 index fb6e31f3abc..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-reaching-outside/_expected/cjs/lib/main.js +++ /dev/null @@ -1,11 +0,0 @@ -'use strict'; - -var dep = require('../dep.js'); - -class Main { - constructor () { - dep.fn(); - } -} - -module.exports = Main; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-reaching-outside/_expected/es/dep.js b/test/chunking-form/samples/deprecated/preserve-modules-reaching-outside/_expected/es/dep.js deleted file mode 100644 index bfe925a46ac..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-reaching-outside/_expected/es/dep.js +++ /dev/null @@ -1,5 +0,0 @@ -function fn () { - console.log('dep fn'); -} - -export { fn }; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-reaching-outside/_expected/es/lib/main.js b/test/chunking-form/samples/deprecated/preserve-modules-reaching-outside/_expected/es/lib/main.js deleted file mode 100644 index 6285f240de1..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-reaching-outside/_expected/es/lib/main.js +++ /dev/null @@ -1,9 +0,0 @@ -import { fn } from '../dep.js'; - -class Main { - constructor () { - fn(); - } -} - -export default Main; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-reaching-outside/_expected/system/dep.js b/test/chunking-form/samples/deprecated/preserve-modules-reaching-outside/_expected/system/dep.js deleted file mode 100644 index 3228f5b2991..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-reaching-outside/_expected/system/dep.js +++ /dev/null @@ -1,14 +0,0 @@ -System.register([], function (exports) { - 'use strict'; - return { - execute: function () { - - exports('fn', fn); - - function fn () { - console.log('dep fn'); - } - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-reaching-outside/_expected/system/lib/main.js b/test/chunking-form/samples/deprecated/preserve-modules-reaching-outside/_expected/system/lib/main.js deleted file mode 100644 index 2c8238dca02..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-reaching-outside/_expected/system/lib/main.js +++ /dev/null @@ -1,18 +0,0 @@ -System.register(['../dep.js'], function (exports) { - 'use strict'; - var fn; - return { - setters: [function (module) { - fn = module.fn; - }], - execute: function () { - - class Main { - constructor () { - fn(); - } - } exports('default', Main); - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-reaching-outside/src/dep.js b/test/chunking-form/samples/deprecated/preserve-modules-reaching-outside/src/dep.js deleted file mode 100644 index b725c96e30d..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-reaching-outside/src/dep.js +++ /dev/null @@ -1,3 +0,0 @@ -export function fn () { - console.log('dep fn'); -} \ No newline at end of file diff --git a/test/chunking-form/samples/deprecated/preserve-modules-reaching-outside/src/lib/main.js b/test/chunking-form/samples/deprecated/preserve-modules-reaching-outside/src/lib/main.js deleted file mode 100644 index a8f1f1403a1..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-reaching-outside/src/lib/main.js +++ /dev/null @@ -1,7 +0,0 @@ -import { fn } from '../dep'; - -export default class Main { - constructor () { - fn(); - } -} \ No newline at end of file diff --git a/test/chunking-form/samples/deprecated/preserve-modules-scriptified-assets/_config.js b/test/chunking-form/samples/deprecated/preserve-modules-scriptified-assets/_config.js deleted file mode 100644 index c79966da224..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-scriptified-assets/_config.js +++ /dev/null @@ -1,27 +0,0 @@ -const path = require('path'); - -module.exports = { - description: 'scriptified assets have extension in preserveModules output filename', - options: { - strictDeprecations: false, - input: 'src/main.js', - preserveModules: true, - plugins: [ - { - name: 'str-num-plugin', - transform(code, id) { - switch (path.extname(id)) { - case '.num': - return { code: `export default ${code.trim()}` }; - case '.str': - return { code: `export default "${code.trim()}"` }; - case '': - return { code: 'export default "COULDN\'T TRANSFORM"' }; - default: - return null; - } - } - } - ] - } -}; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-scriptified-assets/_expected/amd/answer.num.js b/test/chunking-form/samples/deprecated/preserve-modules-scriptified-assets/_expected/amd/answer.num.js deleted file mode 100644 index 66a5b0c010f..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-scriptified-assets/_expected/amd/answer.num.js +++ /dev/null @@ -1,7 +0,0 @@ -define(function () { 'use strict'; - - var answer = 42; - - return answer; - -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-scriptified-assets/_expected/amd/lorem.str.js b/test/chunking-form/samples/deprecated/preserve-modules-scriptified-assets/_expected/amd/lorem.str.js deleted file mode 100644 index 8aeeca012a0..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-scriptified-assets/_expected/amd/lorem.str.js +++ /dev/null @@ -1,7 +0,0 @@ -define(function () { 'use strict'; - - var lorem = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."; - - return lorem; - -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-scriptified-assets/_expected/amd/main.js b/test/chunking-form/samples/deprecated/preserve-modules-scriptified-assets/_expected/amd/main.js deleted file mode 100644 index 889e72fdb24..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-scriptified-assets/_expected/amd/main.js +++ /dev/null @@ -1,11 +0,0 @@ -define(['exports', './answer.num', './lorem.str', './no-ext'], function (exports, answer, lorem, noExt) { 'use strict'; - - - - exports.answer = answer; - exports.lorem = lorem; - exports.noExt = noExt; - - Object.defineProperty(exports, '__esModule', { value: true }); - -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-scriptified-assets/_expected/amd/no-ext.js b/test/chunking-form/samples/deprecated/preserve-modules-scriptified-assets/_expected/amd/no-ext.js deleted file mode 100644 index b60c10d9158..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-scriptified-assets/_expected/amd/no-ext.js +++ /dev/null @@ -1,7 +0,0 @@ -define(function () { 'use strict'; - - var noExt = "COULDN'T TRANSFORM"; - - return noExt; - -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-scriptified-assets/_expected/cjs/answer.num.js b/test/chunking-form/samples/deprecated/preserve-modules-scriptified-assets/_expected/cjs/answer.num.js deleted file mode 100644 index afe78ce4015..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-scriptified-assets/_expected/cjs/answer.num.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -var answer = 42; - -module.exports = answer; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-scriptified-assets/_expected/cjs/lorem.str.js b/test/chunking-form/samples/deprecated/preserve-modules-scriptified-assets/_expected/cjs/lorem.str.js deleted file mode 100644 index aa3ea036c2f..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-scriptified-assets/_expected/cjs/lorem.str.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -var lorem = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."; - -module.exports = lorem; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-scriptified-assets/_expected/cjs/main.js b/test/chunking-form/samples/deprecated/preserve-modules-scriptified-assets/_expected/cjs/main.js deleted file mode 100644 index 0c13700934e..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-scriptified-assets/_expected/cjs/main.js +++ /dev/null @@ -1,13 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { value: true }); - -var answer = require('./answer.num.js'); -var lorem = require('./lorem.str.js'); -var noExt = require('./no-ext.js'); - - - -exports.answer = answer; -exports.lorem = lorem; -exports.noExt = noExt; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-scriptified-assets/_expected/cjs/no-ext.js b/test/chunking-form/samples/deprecated/preserve-modules-scriptified-assets/_expected/cjs/no-ext.js deleted file mode 100644 index 912e8df3bfe..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-scriptified-assets/_expected/cjs/no-ext.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -var noExt = "COULDN'T TRANSFORM"; - -module.exports = noExt; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-scriptified-assets/_expected/es/answer.num.js b/test/chunking-form/samples/deprecated/preserve-modules-scriptified-assets/_expected/es/answer.num.js deleted file mode 100644 index b91051d4a13..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-scriptified-assets/_expected/es/answer.num.js +++ /dev/null @@ -1,3 +0,0 @@ -var answer = 42; - -export default answer; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-scriptified-assets/_expected/es/lorem.str.js b/test/chunking-form/samples/deprecated/preserve-modules-scriptified-assets/_expected/es/lorem.str.js deleted file mode 100644 index 64a054f651b..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-scriptified-assets/_expected/es/lorem.str.js +++ /dev/null @@ -1,3 +0,0 @@ -var lorem = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."; - -export default lorem; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-scriptified-assets/_expected/es/main.js b/test/chunking-form/samples/deprecated/preserve-modules-scriptified-assets/_expected/es/main.js deleted file mode 100644 index 76d97e13ffd..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-scriptified-assets/_expected/es/main.js +++ /dev/null @@ -1,3 +0,0 @@ -export { default as answer } from './answer.num.js'; -export { default as lorem } from './lorem.str.js'; -export { default as noExt } from './no-ext.js'; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-scriptified-assets/_expected/es/no-ext.js b/test/chunking-form/samples/deprecated/preserve-modules-scriptified-assets/_expected/es/no-ext.js deleted file mode 100644 index b1b723a7068..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-scriptified-assets/_expected/es/no-ext.js +++ /dev/null @@ -1,3 +0,0 @@ -var noExt = "COULDN'T TRANSFORM"; - -export default noExt; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-scriptified-assets/_expected/system/answer.num.js b/test/chunking-form/samples/deprecated/preserve-modules-scriptified-assets/_expected/system/answer.num.js deleted file mode 100644 index e897f1a3be2..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-scriptified-assets/_expected/system/answer.num.js +++ /dev/null @@ -1,10 +0,0 @@ -System.register([], function (exports) { - 'use strict'; - return { - execute: function () { - - var answer = exports('default', 42); - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-scriptified-assets/_expected/system/lorem.str.js b/test/chunking-form/samples/deprecated/preserve-modules-scriptified-assets/_expected/system/lorem.str.js deleted file mode 100644 index 7ebf110f98b..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-scriptified-assets/_expected/system/lorem.str.js +++ /dev/null @@ -1,10 +0,0 @@ -System.register([], function (exports) { - 'use strict'; - return { - execute: function () { - - var lorem = exports('default', "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."); - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-scriptified-assets/_expected/system/main.js b/test/chunking-form/samples/deprecated/preserve-modules-scriptified-assets/_expected/system/main.js deleted file mode 100644 index 57340411039..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-scriptified-assets/_expected/system/main.js +++ /dev/null @@ -1,17 +0,0 @@ -System.register(['./answer.num.js', './lorem.str.js', './no-ext.js'], function (exports) { - 'use strict'; - return { - setters: [function (module) { - exports('answer', module.default); - }, function (module) { - exports('lorem', module.default); - }, function (module) { - exports('noExt', module.default); - }], - execute: function () { - - - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-scriptified-assets/_expected/system/no-ext.js b/test/chunking-form/samples/deprecated/preserve-modules-scriptified-assets/_expected/system/no-ext.js deleted file mode 100644 index bd0ec5a3c61..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-scriptified-assets/_expected/system/no-ext.js +++ /dev/null @@ -1,10 +0,0 @@ -System.register([], function (exports) { - 'use strict'; - return { - execute: function () { - - var noExt = exports('default', "COULDN'T TRANSFORM"); - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-scriptified-assets/src/answer.num b/test/chunking-form/samples/deprecated/preserve-modules-scriptified-assets/src/answer.num deleted file mode 100644 index d81cc0710eb..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-scriptified-assets/src/answer.num +++ /dev/null @@ -1 +0,0 @@ -42 diff --git a/test/chunking-form/samples/deprecated/preserve-modules-scriptified-assets/src/main.js b/test/chunking-form/samples/deprecated/preserve-modules-scriptified-assets/src/main.js deleted file mode 100644 index 7ebfc9b7c45..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-scriptified-assets/src/main.js +++ /dev/null @@ -1,3 +0,0 @@ -export { default as answer } from './answer.num'; -export { default as lorem } from './lorem.str'; -export { default as noExt } from './no-ext'; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-scriptified-assets/src/no-ext b/test/chunking-form/samples/deprecated/preserve-modules-scriptified-assets/src/no-ext deleted file mode 100644 index ec25b34dbc2..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-scriptified-assets/src/no-ext +++ /dev/null @@ -1 +0,0 @@ -WHATEVER diff --git a/test/chunking-form/samples/deprecated/preserve-modules-single-entry/_config.js b/test/chunking-form/samples/deprecated/preserve-modules-single-entry/_config.js deleted file mode 100644 index 2c68b2aa9fc..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-single-entry/_config.js +++ /dev/null @@ -1,8 +0,0 @@ -module.exports = { - description: 'single entry names file correctly', - options: { - strictDeprecations: false, - input: 'main.js', - preserveModules: true - } -}; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-single-entry/_expected/amd/main.js b/test/chunking-form/samples/deprecated/preserve-modules-single-entry/_expected/amd/main.js deleted file mode 100644 index 799d8161ff5..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-single-entry/_expected/amd/main.js +++ /dev/null @@ -1,5 +0,0 @@ -define(function () { 'use strict'; - - console.log(); - -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-single-entry/_expected/cjs/main.js b/test/chunking-form/samples/deprecated/preserve-modules-single-entry/_expected/cjs/main.js deleted file mode 100644 index 21c7c3af005..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-single-entry/_expected/cjs/main.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -console.log(); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-single-entry/_expected/es/main.js b/test/chunking-form/samples/deprecated/preserve-modules-single-entry/_expected/es/main.js deleted file mode 100644 index b7bd4c88516..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-single-entry/_expected/es/main.js +++ /dev/null @@ -1 +0,0 @@ -console.log(); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-single-entry/_expected/system/main.js b/test/chunking-form/samples/deprecated/preserve-modules-single-entry/_expected/system/main.js deleted file mode 100644 index 9c717dc8ff3..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-single-entry/_expected/system/main.js +++ /dev/null @@ -1,10 +0,0 @@ -System.register([], function () { - 'use strict'; - return { - execute: function () { - - console.log(); - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-single-entry/main.js b/test/chunking-form/samples/deprecated/preserve-modules-single-entry/main.js deleted file mode 100644 index 13ae9bfeec7..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-single-entry/main.js +++ /dev/null @@ -1 +0,0 @@ -console.log() \ No newline at end of file diff --git a/test/chunking-form/samples/deprecated/preserve-modules-virtual-modules/_config.js b/test/chunking-form/samples/deprecated/preserve-modules-virtual-modules/_config.js deleted file mode 100644 index f9785b99872..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-virtual-modules/_config.js +++ /dev/null @@ -1,23 +0,0 @@ -module.exports = { - description: 'Generates actual files for virtual modules when preserving modules', - options: { - strictDeprecations: false, - input: 'main.js', - preserveModules: true, - plugins: [ - { - resolveId(id) { - if (id === '\0virtualModule') return id; - }, - load(id) { - if (id !== '\0virtualModule') return null; - return 'export const virtual = "Virtual!";\n'; - }, - transform(code, id) { - if (id === '\0virtualModule') return null; - return 'import {virtual} from "\0virtualModule";\n' + code; - } - } - ] - } -}; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-virtual-modules/_expected/amd/_virtual/_virtualModule b/test/chunking-form/samples/deprecated/preserve-modules-virtual-modules/_expected/amd/_virtual/_virtualModule deleted file mode 100644 index e847f6c12b8..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-virtual-modules/_expected/amd/_virtual/_virtualModule +++ /dev/null @@ -1,9 +0,0 @@ -define(['exports'], function (exports) { 'use strict'; - - const virtual = "Virtual!"; - - exports.virtual = virtual; - - Object.defineProperty(exports, '__esModule', { value: true }); - -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-virtual-modules/_expected/amd/main.js b/test/chunking-form/samples/deprecated/preserve-modules-virtual-modules/_expected/amd/main.js deleted file mode 100644 index 452f5c4b435..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-virtual-modules/_expected/amd/main.js +++ /dev/null @@ -1,5 +0,0 @@ -define(['./_virtual/_virtualModule'], function (_virtualModule) { 'use strict'; - - assert.equal(_virtualModule.virtual, 'Virtual!'); - -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-virtual-modules/_expected/cjs/_virtual/_virtualModule b/test/chunking-form/samples/deprecated/preserve-modules-virtual-modules/_expected/cjs/_virtual/_virtualModule deleted file mode 100644 index 3b40ebf67c2..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-virtual-modules/_expected/cjs/_virtual/_virtualModule +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { value: true }); - -const virtual = "Virtual!"; - -exports.virtual = virtual; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-virtual-modules/_expected/cjs/main.js b/test/chunking-form/samples/deprecated/preserve-modules-virtual-modules/_expected/cjs/main.js deleted file mode 100644 index c32672f1b85..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-virtual-modules/_expected/cjs/main.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -var _virtualModule = require('./_virtual/_virtualModule'); - -assert.equal(_virtualModule.virtual, 'Virtual!'); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-virtual-modules/_expected/es/main.js b/test/chunking-form/samples/deprecated/preserve-modules-virtual-modules/_expected/es/main.js deleted file mode 100644 index 6bb75abdf27..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-virtual-modules/_expected/es/main.js +++ /dev/null @@ -1,3 +0,0 @@ -import { virtual } from './_virtual/_virtualModule'; - -assert.equal(virtual, 'Virtual!'); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-virtual-modules/_expected/system/_virtual/_virtualModule b/test/chunking-form/samples/deprecated/preserve-modules-virtual-modules/_expected/system/_virtual/_virtualModule deleted file mode 100644 index 2281d70c5a9..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-virtual-modules/_expected/system/_virtual/_virtualModule +++ /dev/null @@ -1,10 +0,0 @@ -System.register([], function (exports) { - 'use strict'; - return { - execute: function () { - - const virtual = exports('virtual', "Virtual!"); - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-virtual-modules/_expected/system/main.js b/test/chunking-form/samples/deprecated/preserve-modules-virtual-modules/_expected/system/main.js deleted file mode 100644 index 7b8b65e237d..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-virtual-modules/_expected/system/main.js +++ /dev/null @@ -1,14 +0,0 @@ -System.register(['./_virtual/_virtualModule'], function () { - 'use strict'; - var virtual; - return { - setters: [function (module) { - virtual = module.virtual; - }], - execute: function () { - - assert.equal(virtual, 'Virtual!'); - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-virtual-modules/main.js b/test/chunking-form/samples/deprecated/preserve-modules-virtual-modules/main.js deleted file mode 100644 index 505982998fa..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules-virtual-modules/main.js +++ /dev/null @@ -1 +0,0 @@ -assert.equal(virtual, 'Virtual!'); diff --git a/test/chunking-form/samples/deprecated/preserve-modules/_config.js b/test/chunking-form/samples/deprecated/preserve-modules/_config.js deleted file mode 100644 index fb89b5a641c..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules/_config.js +++ /dev/null @@ -1,8 +0,0 @@ -module.exports = { - description: 'Rewrite modules in-place', - options: { - strictDeprecations: false, - input: ['main1.js', 'main2.js'], - preserveModules: true - } -}; diff --git a/test/chunking-form/samples/deprecated/preserve-modules/_expected/amd/deps/dep1.js b/test/chunking-form/samples/deprecated/preserve-modules/_expected/amd/deps/dep1.js deleted file mode 100644 index eb1b2814d87..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules/_expected/amd/deps/dep1.js +++ /dev/null @@ -1,11 +0,0 @@ -define(['exports'], function (exports) { 'use strict'; - - function fn () { - console.log('dep1 fn'); - } - - exports.fn = fn; - - Object.defineProperty(exports, '__esModule', { value: true }); - -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules/_expected/amd/deps/dep2.js b/test/chunking-form/samples/deprecated/preserve-modules/_expected/amd/deps/dep2.js deleted file mode 100644 index 2a152d376d9..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules/_expected/amd/deps/dep2.js +++ /dev/null @@ -1,12 +0,0 @@ -define(['exports', '../lib/lib2'], function (exports, lib2) { 'use strict'; - - function fn () { - lib2.fn(); - console.log('dep2 fn'); - } - - exports.fn = fn; - - Object.defineProperty(exports, '__esModule', { value: true }); - -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules/_expected/amd/deps/dep3.js b/test/chunking-form/samples/deprecated/preserve-modules/_expected/amd/deps/dep3.js deleted file mode 100644 index bfc8f877c33..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules/_expected/amd/deps/dep3.js +++ /dev/null @@ -1,12 +0,0 @@ -define(['exports', '../lib/lib1'], function (exports, lib1) { 'use strict'; - - function fn () { - lib1.fn(); - console.log('dep3 fn'); - } - - exports.fn = fn; - - Object.defineProperty(exports, '__esModule', { value: true }); - -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules/_expected/amd/lib/lib1.js b/test/chunking-form/samples/deprecated/preserve-modules/_expected/amd/lib/lib1.js deleted file mode 100644 index 93c0a3a4169..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules/_expected/amd/lib/lib1.js +++ /dev/null @@ -1,11 +0,0 @@ -define(['exports'], function (exports) { 'use strict'; - - function fn () { - console.log('lib1 fn'); - } - - exports.fn = fn; - - Object.defineProperty(exports, '__esModule', { value: true }); - -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules/_expected/amd/lib/lib2.js b/test/chunking-form/samples/deprecated/preserve-modules/_expected/amd/lib/lib2.js deleted file mode 100644 index 8e8e2d17cdc..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules/_expected/amd/lib/lib2.js +++ /dev/null @@ -1,11 +0,0 @@ -define(['exports'], function (exports) { 'use strict'; - - function fn () { - console.log('lib2 fn'); - } - - exports.fn = fn; - - Object.defineProperty(exports, '__esModule', { value: true }); - -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules/_expected/amd/main1.js b/test/chunking-form/samples/deprecated/preserve-modules/_expected/amd/main1.js deleted file mode 100644 index 70e5862bab7..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules/_expected/amd/main1.js +++ /dev/null @@ -1,12 +0,0 @@ -define(['./deps/dep1', './deps/dep2'], function (dep1, dep2) { 'use strict'; - - class Main1 { - constructor () { - dep1.fn(); - dep2.fn(); - } - } - - return Main1; - -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules/_expected/amd/main2.js b/test/chunking-form/samples/deprecated/preserve-modules/_expected/amd/main2.js deleted file mode 100644 index b9dd02ca10c..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules/_expected/amd/main2.js +++ /dev/null @@ -1,12 +0,0 @@ -define(['./deps/dep2', './deps/dep3'], function (dep2, dep3) { 'use strict'; - - class Main2 { - constructor () { - dep3.fn(); - dep2.fn(); - } - } - - return Main2; - -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules/_expected/cjs/deps/dep1.js b/test/chunking-form/samples/deprecated/preserve-modules/_expected/cjs/deps/dep1.js deleted file mode 100644 index 94bfa086430..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules/_expected/cjs/deps/dep1.js +++ /dev/null @@ -1,9 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { value: true }); - -function fn () { - console.log('dep1 fn'); -} - -exports.fn = fn; diff --git a/test/chunking-form/samples/deprecated/preserve-modules/_expected/cjs/deps/dep2.js b/test/chunking-form/samples/deprecated/preserve-modules/_expected/cjs/deps/dep2.js deleted file mode 100644 index a9f8fb62635..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules/_expected/cjs/deps/dep2.js +++ /dev/null @@ -1,12 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { value: true }); - -var lib2 = require('../lib/lib2.js'); - -function fn () { - lib2.fn(); - console.log('dep2 fn'); -} - -exports.fn = fn; diff --git a/test/chunking-form/samples/deprecated/preserve-modules/_expected/cjs/deps/dep3.js b/test/chunking-form/samples/deprecated/preserve-modules/_expected/cjs/deps/dep3.js deleted file mode 100644 index eb901c61adc..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules/_expected/cjs/deps/dep3.js +++ /dev/null @@ -1,12 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { value: true }); - -var lib1 = require('../lib/lib1.js'); - -function fn () { - lib1.fn(); - console.log('dep3 fn'); -} - -exports.fn = fn; diff --git a/test/chunking-form/samples/deprecated/preserve-modules/_expected/cjs/lib/lib1.js b/test/chunking-form/samples/deprecated/preserve-modules/_expected/cjs/lib/lib1.js deleted file mode 100644 index 135c3023fcc..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules/_expected/cjs/lib/lib1.js +++ /dev/null @@ -1,9 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { value: true }); - -function fn () { - console.log('lib1 fn'); -} - -exports.fn = fn; diff --git a/test/chunking-form/samples/deprecated/preserve-modules/_expected/cjs/lib/lib2.js b/test/chunking-form/samples/deprecated/preserve-modules/_expected/cjs/lib/lib2.js deleted file mode 100644 index ee3ad249352..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules/_expected/cjs/lib/lib2.js +++ /dev/null @@ -1,9 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { value: true }); - -function fn () { - console.log('lib2 fn'); -} - -exports.fn = fn; diff --git a/test/chunking-form/samples/deprecated/preserve-modules/_expected/cjs/main1.js b/test/chunking-form/samples/deprecated/preserve-modules/_expected/cjs/main1.js deleted file mode 100644 index 0181b38e214..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules/_expected/cjs/main1.js +++ /dev/null @@ -1,13 +0,0 @@ -'use strict'; - -var dep1 = require('./deps/dep1.js'); -var dep2 = require('./deps/dep2.js'); - -class Main1 { - constructor () { - dep1.fn(); - dep2.fn(); - } -} - -module.exports = Main1; diff --git a/test/chunking-form/samples/deprecated/preserve-modules/_expected/cjs/main2.js b/test/chunking-form/samples/deprecated/preserve-modules/_expected/cjs/main2.js deleted file mode 100644 index 5078fc7854f..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules/_expected/cjs/main2.js +++ /dev/null @@ -1,13 +0,0 @@ -'use strict'; - -var dep2 = require('./deps/dep2.js'); -var dep3 = require('./deps/dep3.js'); - -class Main2 { - constructor () { - dep3.fn(); - dep2.fn(); - } -} - -module.exports = Main2; diff --git a/test/chunking-form/samples/deprecated/preserve-modules/_expected/es/deps/dep1.js b/test/chunking-form/samples/deprecated/preserve-modules/_expected/es/deps/dep1.js deleted file mode 100644 index 34a5e9c11a5..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules/_expected/es/deps/dep1.js +++ /dev/null @@ -1,5 +0,0 @@ -function fn () { - console.log('dep1 fn'); -} - -export { fn }; diff --git a/test/chunking-form/samples/deprecated/preserve-modules/_expected/es/deps/dep2.js b/test/chunking-form/samples/deprecated/preserve-modules/_expected/es/deps/dep2.js deleted file mode 100644 index 233b8235a07..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules/_expected/es/deps/dep2.js +++ /dev/null @@ -1,8 +0,0 @@ -import { fn as fn$1 } from '../lib/lib2.js'; - -function fn () { - fn$1(); - console.log('dep2 fn'); -} - -export { fn }; diff --git a/test/chunking-form/samples/deprecated/preserve-modules/_expected/es/deps/dep3.js b/test/chunking-form/samples/deprecated/preserve-modules/_expected/es/deps/dep3.js deleted file mode 100644 index e01b47ef194..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules/_expected/es/deps/dep3.js +++ /dev/null @@ -1,8 +0,0 @@ -import { fn as fn$1 } from '../lib/lib1.js'; - -function fn () { - fn$1(); - console.log('dep3 fn'); -} - -export { fn }; diff --git a/test/chunking-form/samples/deprecated/preserve-modules/_expected/es/lib/lib1.js b/test/chunking-form/samples/deprecated/preserve-modules/_expected/es/lib/lib1.js deleted file mode 100644 index 0d869dbec7d..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules/_expected/es/lib/lib1.js +++ /dev/null @@ -1,5 +0,0 @@ -function fn () { - console.log('lib1 fn'); -} - -export { fn }; diff --git a/test/chunking-form/samples/deprecated/preserve-modules/_expected/es/lib/lib2.js b/test/chunking-form/samples/deprecated/preserve-modules/_expected/es/lib/lib2.js deleted file mode 100644 index a6f4f0324f1..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules/_expected/es/lib/lib2.js +++ /dev/null @@ -1,5 +0,0 @@ -function fn () { - console.log('lib2 fn'); -} - -export { fn }; diff --git a/test/chunking-form/samples/deprecated/preserve-modules/_expected/es/main1.js b/test/chunking-form/samples/deprecated/preserve-modules/_expected/es/main1.js deleted file mode 100644 index db71b463402..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules/_expected/es/main1.js +++ /dev/null @@ -1,11 +0,0 @@ -import { fn } from './deps/dep1.js'; -import { fn as fn$1 } from './deps/dep2.js'; - -class Main1 { - constructor () { - fn(); - fn$1(); - } -} - -export default Main1; diff --git a/test/chunking-form/samples/deprecated/preserve-modules/_expected/es/main2.js b/test/chunking-form/samples/deprecated/preserve-modules/_expected/es/main2.js deleted file mode 100644 index a3b4ef89ff7..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules/_expected/es/main2.js +++ /dev/null @@ -1,11 +0,0 @@ -import { fn as fn$1 } from './deps/dep2.js'; -import { fn } from './deps/dep3.js'; - -class Main2 { - constructor () { - fn(); - fn$1(); - } -} - -export default Main2; diff --git a/test/chunking-form/samples/deprecated/preserve-modules/_expected/system/deps/dep1.js b/test/chunking-form/samples/deprecated/preserve-modules/_expected/system/deps/dep1.js deleted file mode 100644 index 813157baf2d..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules/_expected/system/deps/dep1.js +++ /dev/null @@ -1,14 +0,0 @@ -System.register([], function (exports) { - 'use strict'; - return { - execute: function () { - - exports('fn', fn); - - function fn () { - console.log('dep1 fn'); - } - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules/_expected/system/deps/dep2.js b/test/chunking-form/samples/deprecated/preserve-modules/_expected/system/deps/dep2.js deleted file mode 100644 index e659b606bfb..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules/_expected/system/deps/dep2.js +++ /dev/null @@ -1,19 +0,0 @@ -System.register(['../lib/lib2.js'], function (exports) { - 'use strict'; - var fn$1; - return { - setters: [function (module) { - fn$1 = module.fn; - }], - execute: function () { - - exports('fn', fn); - - function fn () { - fn$1(); - console.log('dep2 fn'); - } - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules/_expected/system/deps/dep3.js b/test/chunking-form/samples/deprecated/preserve-modules/_expected/system/deps/dep3.js deleted file mode 100644 index bd88b3e2d36..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules/_expected/system/deps/dep3.js +++ /dev/null @@ -1,19 +0,0 @@ -System.register(['../lib/lib1.js'], function (exports) { - 'use strict'; - var fn$1; - return { - setters: [function (module) { - fn$1 = module.fn; - }], - execute: function () { - - exports('fn', fn); - - function fn () { - fn$1(); - console.log('dep3 fn'); - } - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules/_expected/system/lib/lib1.js b/test/chunking-form/samples/deprecated/preserve-modules/_expected/system/lib/lib1.js deleted file mode 100644 index 744d84434d7..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules/_expected/system/lib/lib1.js +++ /dev/null @@ -1,14 +0,0 @@ -System.register([], function (exports) { - 'use strict'; - return { - execute: function () { - - exports('fn', fn); - - function fn () { - console.log('lib1 fn'); - } - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules/_expected/system/lib/lib2.js b/test/chunking-form/samples/deprecated/preserve-modules/_expected/system/lib/lib2.js deleted file mode 100644 index b27f09d18bd..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules/_expected/system/lib/lib2.js +++ /dev/null @@ -1,14 +0,0 @@ -System.register([], function (exports) { - 'use strict'; - return { - execute: function () { - - exports('fn', fn); - - function fn () { - console.log('lib2 fn'); - } - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules/_expected/system/main1.js b/test/chunking-form/samples/deprecated/preserve-modules/_expected/system/main1.js deleted file mode 100644 index 17f7ddb453e..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules/_expected/system/main1.js +++ /dev/null @@ -1,21 +0,0 @@ -System.register(['./deps/dep1.js', './deps/dep2.js'], function (exports) { - 'use strict'; - var fn, fn$1; - return { - setters: [function (module) { - fn = module.fn; - }, function (module) { - fn$1 = module.fn; - }], - execute: function () { - - class Main1 { - constructor () { - fn(); - fn$1(); - } - } exports('default', Main1); - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules/_expected/system/main2.js b/test/chunking-form/samples/deprecated/preserve-modules/_expected/system/main2.js deleted file mode 100644 index 4833f43826d..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules/_expected/system/main2.js +++ /dev/null @@ -1,21 +0,0 @@ -System.register(['./deps/dep2.js', './deps/dep3.js'], function (exports) { - 'use strict'; - var fn$1, fn; - return { - setters: [function (module) { - fn$1 = module.fn; - }, function (module) { - fn = module.fn; - }], - execute: function () { - - class Main2 { - constructor () { - fn(); - fn$1(); - } - } exports('default', Main2); - - } - }; -}); diff --git a/test/chunking-form/samples/deprecated/preserve-modules/deps/dep1.js b/test/chunking-form/samples/deprecated/preserve-modules/deps/dep1.js deleted file mode 100644 index b67d0bbb2c1..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules/deps/dep1.js +++ /dev/null @@ -1,3 +0,0 @@ -export function fn () { - console.log('dep1 fn'); -} \ No newline at end of file diff --git a/test/chunking-form/samples/deprecated/preserve-modules/deps/dep2.js b/test/chunking-form/samples/deprecated/preserve-modules/deps/dep2.js deleted file mode 100644 index 031534c44bb..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules/deps/dep2.js +++ /dev/null @@ -1,6 +0,0 @@ -import { fn as libfn } from '../lib/lib2.js'; - -export function fn () { - libfn(); - console.log('dep2 fn'); -} \ No newline at end of file diff --git a/test/chunking-form/samples/deprecated/preserve-modules/deps/dep3.js b/test/chunking-form/samples/deprecated/preserve-modules/deps/dep3.js deleted file mode 100644 index 0ebd9320bc6..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules/deps/dep3.js +++ /dev/null @@ -1,8 +0,0 @@ -import { fn as libfn, treeshaked } from '../lib/lib1.js'; - -export function fn () { - libfn(); - console.log('dep3 fn'); -} - -export default treeshaked; \ No newline at end of file diff --git a/test/chunking-form/samples/deprecated/preserve-modules/lib/lib1.js b/test/chunking-form/samples/deprecated/preserve-modules/lib/lib1.js deleted file mode 100644 index 5ccf83b357e..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules/lib/lib1.js +++ /dev/null @@ -1,7 +0,0 @@ -export function fn () { - console.log('lib1 fn'); -} - -export function treeshaked () { - console.log('this is tree shaken!'); -} \ No newline at end of file diff --git a/test/chunking-form/samples/deprecated/preserve-modules/lib/lib2.js b/test/chunking-form/samples/deprecated/preserve-modules/lib/lib2.js deleted file mode 100644 index 2d6d2cf0852..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules/lib/lib2.js +++ /dev/null @@ -1,3 +0,0 @@ -export function fn () { - console.log('lib2 fn'); -} \ No newline at end of file diff --git a/test/chunking-form/samples/deprecated/preserve-modules/main1.js b/test/chunking-form/samples/deprecated/preserve-modules/main1.js deleted file mode 100644 index dfbcdf631e5..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules/main1.js +++ /dev/null @@ -1,9 +0,0 @@ -import { fn } from './deps/dep1.js'; -import { fn as fn2 } from './deps/dep2.js'; - -export default class Main1 { - constructor () { - fn(); - fn2(); - } -} \ No newline at end of file diff --git a/test/chunking-form/samples/deprecated/preserve-modules/main2.js b/test/chunking-form/samples/deprecated/preserve-modules/main2.js deleted file mode 100644 index 67202404b6a..00000000000 --- a/test/chunking-form/samples/deprecated/preserve-modules/main2.js +++ /dev/null @@ -1,13 +0,0 @@ -import { fn } from './deps/dep2.js'; -import { fn as fn2, default as treeshaked } from './deps/dep3.js'; - -if (false) { - treeshaked(); -} - -export default class Main2 { - constructor () { - fn2(); - fn(); - } -} \ No newline at end of file diff --git a/test/chunking-form/samples/dynamic-import-chained/_config.js b/test/chunking-form/samples/dynamic-import-chained/_config.js index 31a03c704ee..e6c2c18e41b 100644 --- a/test/chunking-form/samples/dynamic-import-chained/_config.js +++ b/test/chunking-form/samples/dynamic-import-chained/_config.js @@ -1,6 +1,6 @@ -module.exports = { +module.exports = defineTest({ description: 'includes chained dynamic imports', options: { input: 'main.js' } -}; +}); diff --git a/test/chunking-form/samples/dynamic-import-chained/_expected/amd/generated-dep1.js b/test/chunking-form/samples/dynamic-import-chained/_expected/amd/generated-dep1.js index 83e82a16985..a2dff522068 100644 --- a/test/chunking-form/samples/dynamic-import-chained/_expected/amd/generated-dep1.js +++ b/test/chunking-form/samples/dynamic-import-chained/_expected/amd/generated-dep1.js @@ -1,6 +1,6 @@ -define(['require'], function (require) { 'use strict'; +define(['require'], (function (require) { 'use strict'; console.log('dep1'); - new Promise(function (resolve, reject) { require(['./generated-dep2'], resolve, reject) }); + new Promise(function (resolve, reject) { require(['./generated-dep2'], resolve, reject); }); -}); +})); diff --git a/test/chunking-form/samples/dynamic-import-chained/_expected/amd/generated-dep2.js b/test/chunking-form/samples/dynamic-import-chained/_expected/amd/generated-dep2.js index af27f254599..8b19534cf38 100644 --- a/test/chunking-form/samples/dynamic-import-chained/_expected/amd/generated-dep2.js +++ b/test/chunking-form/samples/dynamic-import-chained/_expected/amd/generated-dep2.js @@ -1,5 +1,5 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; console.log('dep2'); -}); +})); diff --git a/test/chunking-form/samples/dynamic-import-chained/_expected/amd/main.js b/test/chunking-form/samples/dynamic-import-chained/_expected/amd/main.js index a337561f677..4b3d6d3e98b 100644 --- a/test/chunking-form/samples/dynamic-import-chained/_expected/amd/main.js +++ b/test/chunking-form/samples/dynamic-import-chained/_expected/amd/main.js @@ -1,6 +1,6 @@ -define(['require'], function (require) { 'use strict'; +define(['require'], (function (require) { 'use strict'; console.log('main'); - new Promise(function (resolve, reject) { require(['./generated-dep1'], resolve, reject) }); + new Promise(function (resolve, reject) { require(['./generated-dep1'], resolve, reject); }); -}); +})); diff --git a/test/chunking-form/samples/dynamic-import-chained/_expected/system/generated-dep1.js b/test/chunking-form/samples/dynamic-import-chained/_expected/system/generated-dep1.js index 40c0c5a289e..96f41c0a1d6 100644 --- a/test/chunking-form/samples/dynamic-import-chained/_expected/system/generated-dep1.js +++ b/test/chunking-form/samples/dynamic-import-chained/_expected/system/generated-dep1.js @@ -1,11 +1,11 @@ -System.register([], function (exports, module) { +System.register([], (function (exports, module) { 'use strict'; return { - execute: function () { + execute: (function () { console.log('dep1'); module.import('./generated-dep2.js'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/dynamic-import-chained/_expected/system/generated-dep2.js b/test/chunking-form/samples/dynamic-import-chained/_expected/system/generated-dep2.js index 535b40f550f..e97665c4ed9 100644 --- a/test/chunking-form/samples/dynamic-import-chained/_expected/system/generated-dep2.js +++ b/test/chunking-form/samples/dynamic-import-chained/_expected/system/generated-dep2.js @@ -1,10 +1,10 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { console.log('dep2'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/dynamic-import-chained/_expected/system/main.js b/test/chunking-form/samples/dynamic-import-chained/_expected/system/main.js index 818a9966643..e19dd8fb464 100644 --- a/test/chunking-form/samples/dynamic-import-chained/_expected/system/main.js +++ b/test/chunking-form/samples/dynamic-import-chained/_expected/system/main.js @@ -1,11 +1,11 @@ -System.register([], function (exports, module) { +System.register([], (function (exports, module) { 'use strict'; return { - execute: function () { + execute: (function () { console.log('main'); module.import('./generated-dep1.js'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/dynamic-import-chunking/_config.js b/test/chunking-form/samples/dynamic-import-chunking/_config.js index b4c10960b3f..d9d17675315 100644 --- a/test/chunking-form/samples/dynamic-import-chunking/_config.js +++ b/test/chunking-form/samples/dynamic-import-chunking/_config.js @@ -1,7 +1,7 @@ -module.exports = { +module.exports = defineTest({ description: 'Code splitting with dynamic import', options: { input: ['main.js'], preserveEntrySignatures: 'strict' } -}; +}); diff --git a/test/chunking-form/samples/dynamic-import-chunking/_expected/amd/generated-dep2.js b/test/chunking-form/samples/dynamic-import-chunking/_expected/amd/generated-dep2.js index 2e2174a2c9b..676f22d7d37 100644 --- a/test/chunking-form/samples/dynamic-import-chunking/_expected/amd/generated-dep2.js +++ b/test/chunking-form/samples/dynamic-import-chunking/_expected/amd/generated-dep2.js @@ -1,4 +1,4 @@ -define(['exports', './generated-main'], function (exports, main) { 'use strict'; +define(['exports', './generated-main'], (function (exports, main) { 'use strict'; function mult (num) { return num + main.multiplier; @@ -6,4 +6,4 @@ define(['exports', './generated-main'], function (exports, main) { 'use strict'; exports.mult = mult; -}); +})); diff --git a/test/chunking-form/samples/dynamic-import-chunking/_expected/amd/generated-main.js b/test/chunking-form/samples/dynamic-import-chunking/_expected/amd/generated-main.js index edcc94c0953..06907a8b1ac 100644 --- a/test/chunking-form/samples/dynamic-import-chunking/_expected/amd/generated-main.js +++ b/test/chunking-form/samples/dynamic-import-chunking/_expected/amd/generated-main.js @@ -1,4 +1,4 @@ -define(['require', 'exports'], function (require, exports) { 'use strict'; +define(['require', 'exports'], (function (require, exports) { 'use strict'; var multiplier = 7; @@ -11,7 +11,7 @@ define(['require', 'exports'], function (require, exports) { 'use strict'; } function dynamic (num) { - return new Promise(function (resolve, reject) { require(['./generated-dep2'], resolve, reject) }) + return new Promise(function (resolve, reject) { require(['./generated-dep2'], resolve, reject); }) .then(dep2 => { return dep2.mult(num); }); @@ -25,4 +25,4 @@ define(['require', 'exports'], function (require, exports) { 'use strict'; exports.multiplier = multiplier; -}); +})); diff --git a/test/chunking-form/samples/dynamic-import-chunking/_expected/amd/main.js b/test/chunking-form/samples/dynamic-import-chunking/_expected/amd/main.js index 4cef940ab88..96e9a66fe24 100644 --- a/test/chunking-form/samples/dynamic-import-chunking/_expected/amd/main.js +++ b/test/chunking-form/samples/dynamic-import-chunking/_expected/amd/main.js @@ -1,5 +1,5 @@ -define(['./generated-main'], function (main) { 'use strict'; +define(['./generated-main'], (function (main) { 'use strict'; -}); +})); diff --git a/test/chunking-form/samples/dynamic-import-chunking/_expected/system/generated-dep2.js b/test/chunking-form/samples/dynamic-import-chunking/_expected/system/generated-dep2.js index 7172491c255..79d4d6a4882 100644 --- a/test/chunking-form/samples/dynamic-import-chunking/_expected/system/generated-dep2.js +++ b/test/chunking-form/samples/dynamic-import-chunking/_expected/system/generated-dep2.js @@ -1,18 +1,18 @@ -System.register(['./generated-main.js'], function (exports) { +System.register(['./generated-main.js'], (function (exports) { 'use strict'; var multiplier; return { setters: [function (module) { multiplier = module.m; }], - execute: function () { + execute: (function () { - exports('mult', mult); + exports("mult", mult); function mult (num) { return num + multiplier; } - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/dynamic-import-chunking/_expected/system/generated-main.js b/test/chunking-form/samples/dynamic-import-chunking/_expected/system/generated-main.js index 73b8ed1255c..8ecfae75a10 100644 --- a/test/chunking-form/samples/dynamic-import-chunking/_expected/system/generated-main.js +++ b/test/chunking-form/samples/dynamic-import-chunking/_expected/system/generated-main.js @@ -1,9 +1,9 @@ -System.register([], function (exports, module) { +System.register([], (function (exports, module) { 'use strict'; return { - execute: function () { + execute: (function () { - var multiplier = exports('m', 7); + var multiplier = exports("m", 7); function calc (num) { return num * multiplier; @@ -26,6 +26,6 @@ System.register([], function (exports, module) { console.log(num); }); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/dynamic-import-chunking/_expected/system/main.js b/test/chunking-form/samples/dynamic-import-chunking/_expected/system/main.js index 1312c7a3bd6..28a39baeced 100644 --- a/test/chunking-form/samples/dynamic-import-chunking/_expected/system/main.js +++ b/test/chunking-form/samples/dynamic-import-chunking/_expected/system/main.js @@ -1,11 +1,11 @@ -System.register(['./generated-main.js'], function () { +System.register(['./generated-main.js'], (function () { 'use strict'; return { - setters: [function () {}], - execute: function () { + setters: [null], + execute: (function () { - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/dynamic-import-comments/_config.js b/test/chunking-form/samples/dynamic-import-comments/_config.js index 9e74bcab779..57d3faa7e5e 100644 --- a/test/chunking-form/samples/dynamic-import-comments/_config.js +++ b/test/chunking-form/samples/dynamic-import-comments/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'does not remove inline comments inside dynamic imports', options: { input: 'main.js', @@ -12,4 +12,4 @@ module.exports = { } } } -}; +}); diff --git a/test/chunking-form/samples/dynamic-import-comments/_expected/amd/main.js b/test/chunking-form/samples/dynamic-import-comments/_expected/amd/main.js index c0b0389a993..fc8a7d4e791 100644 --- a/test/chunking-form/samples/dynamic-import-comments/_expected/amd/main.js +++ b/test/chunking-form/samples/dynamic-import-comments/_expected/amd/main.js @@ -1,7 +1,7 @@ -define(['require'], function (require) { 'use strict'; +define(['require'], (function (require) { 'use strict'; foobar( /* webpackChunkName: "chunk-name" */ './foo'/*suffix*/); -}); +})); diff --git a/test/chunking-form/samples/dynamic-import-comments/_expected/system/main.js b/test/chunking-form/samples/dynamic-import-comments/_expected/system/main.js index 6a642eabfb8..8a9b514fa7c 100644 --- a/test/chunking-form/samples/dynamic-import-comments/_expected/system/main.js +++ b/test/chunking-form/samples/dynamic-import-comments/_expected/system/main.js @@ -1,12 +1,12 @@ -System.register([], function (exports, module) { +System.register([], (function (exports, module) { 'use strict'; return { - execute: function () { + execute: (function () { foobar( /* webpackChunkName: "chunk-name" */ './foo.js'/*suffix*/); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/dynamic-import-dynamic/_config.js b/test/chunking-form/samples/dynamic-import-dynamic/_config.js index 288d17f8111..c1e7e16a5a8 100644 --- a/test/chunking-form/samples/dynamic-import-dynamic/_config.js +++ b/test/chunking-form/samples/dynamic-import-dynamic/_config.js @@ -1,6 +1,6 @@ -module.exports = { +module.exports = defineTest({ description: 'Code splitting with dynamic import', options: { input: ['main.js'] } -}; +}); diff --git a/test/chunking-form/samples/dynamic-import-dynamic/_expected/amd/main.js b/test/chunking-form/samples/dynamic-import-dynamic/_expected/amd/main.js index bc664553fe3..a04b21a401f 100644 --- a/test/chunking-form/samples/dynamic-import-dynamic/_expected/amd/main.js +++ b/test/chunking-form/samples/dynamic-import-dynamic/_expected/amd/main.js @@ -1,7 +1,6 @@ -define(['require'], function (require) { 'use strict'; +define(['require'], (function (require) { 'use strict'; - function _interopNamespace(e) { - if (e && e.__esModule) return e; + function _interopNamespaceDefault(e) { var n = Object.create(null); if (e) { Object.keys(e).forEach(function (k) { @@ -9,19 +8,17 @@ define(['require'], function (require) { 'use strict'; var d = Object.getOwnPropertyDescriptor(e, k); Object.defineProperty(n, k, d.get ? d : { enumerable: true, - get: function () { - return e[k]; - } + get: function () { return e[k]; } }); } }); } - n['default'] = e; + n.default = e; return Object.freeze(n); } var dep = 'dep'; - new Promise(function (resolve, reject) { require([dep], function (m) { resolve(/*#__PURE__*/_interopNamespace(m)); }, reject) }); + (function (t) { return new Promise(function (resolve, reject) { require([t], function (m) { resolve(/*#__PURE__*/_interopNamespaceDefault(m)); }, reject); }); })(dep); -}); +})); diff --git a/test/chunking-form/samples/dynamic-import-dynamic/_expected/cjs/main.js b/test/chunking-form/samples/dynamic-import-dynamic/_expected/cjs/main.js index dd03c613ed4..657ea9f5266 100644 --- a/test/chunking-form/samples/dynamic-import-dynamic/_expected/cjs/main.js +++ b/test/chunking-form/samples/dynamic-import-dynamic/_expected/cjs/main.js @@ -1,25 +1,5 @@ 'use strict'; -function _interopNamespace(e) { - if (e && e.__esModule) return e; - var n = Object.create(null); - if (e) { - Object.keys(e).forEach(function (k) { - if (k !== 'default') { - var d = Object.getOwnPropertyDescriptor(e, k); - Object.defineProperty(n, k, d.get ? d : { - enumerable: true, - get: function () { - return e[k]; - } - }); - } - }); - } - n['default'] = e; - return Object.freeze(n); -} - var dep = 'dep'; -Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(dep)); }); +import(dep); diff --git a/test/chunking-form/samples/dynamic-import-dynamic/_expected/system/main.js b/test/chunking-form/samples/dynamic-import-dynamic/_expected/system/main.js index 5309550bece..c1ffa14a5c6 100644 --- a/test/chunking-form/samples/dynamic-import-dynamic/_expected/system/main.js +++ b/test/chunking-form/samples/dynamic-import-dynamic/_expected/system/main.js @@ -1,12 +1,12 @@ -System.register([], function (exports, module) { +System.register([], (function (exports, module) { 'use strict'; return { - execute: function () { + execute: (function () { var dep = 'dep'; module.import(dep); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/dynamic-import-external/_config.js b/test/chunking-form/samples/dynamic-import-external/_config.js index 2091d371a39..e3b7b971d89 100644 --- a/test/chunking-form/samples/dynamic-import-external/_config.js +++ b/test/chunking-form/samples/dynamic-import-external/_config.js @@ -1,11 +1,11 @@ -module.exports = { +module.exports = defineTest({ description: 'marks dynamic imports as external when resolveDynamicImport returns false', options: { input: 'main.js', plugins: { - resolveDynamicImport(specifier) { + resolveDynamicImport() { return false; } } } -}; +}); diff --git a/test/chunking-form/samples/dynamic-import-external/_expected/amd/main.js b/test/chunking-form/samples/dynamic-import-external/_expected/amd/main.js index 91082d4ea44..e28d7b1e460 100644 --- a/test/chunking-form/samples/dynamic-import-external/_expected/amd/main.js +++ b/test/chunking-form/samples/dynamic-import-external/_expected/amd/main.js @@ -1,7 +1,6 @@ -define(['require'], function (require) { 'use strict'; +define(['require'], (function (require) { 'use strict'; - function _interopNamespace(e) { - if (e && e.__esModule) return e; + function _interopNamespaceDefault(e) { var n = Object.create(null); if (e) { Object.keys(e).forEach(function (k) { @@ -9,17 +8,15 @@ define(['require'], function (require) { 'use strict'; var d = Object.getOwnPropertyDescriptor(e, k); Object.defineProperty(n, k, d.get ? d : { enumerable: true, - get: function () { - return e[k]; - } + get: function () { return e[k]; } }); } }); } - n['default'] = e; + n.default = e; return Object.freeze(n); } - new Promise(function (resolve, reject) { require(['./foo'], function (m) { resolve(/*#__PURE__*/_interopNamespace(m)); }, reject) }); + new Promise(function (resolve, reject) { require(['./foo'], function (m) { resolve(/*#__PURE__*/_interopNamespaceDefault(m)); }, reject); }); -}); +})); diff --git a/test/chunking-form/samples/dynamic-import-external/_expected/cjs/main.js b/test/chunking-form/samples/dynamic-import-external/_expected/cjs/main.js index f37f056f8ed..324e5eef779 100644 --- a/test/chunking-form/samples/dynamic-import-external/_expected/cjs/main.js +++ b/test/chunking-form/samples/dynamic-import-external/_expected/cjs/main.js @@ -1,23 +1,3 @@ 'use strict'; -function _interopNamespace(e) { - if (e && e.__esModule) return e; - var n = Object.create(null); - if (e) { - Object.keys(e).forEach(function (k) { - if (k !== 'default') { - var d = Object.getOwnPropertyDescriptor(e, k); - Object.defineProperty(n, k, d.get ? d : { - enumerable: true, - get: function () { - return e[k]; - } - }); - } - }); - } - n['default'] = e; - return Object.freeze(n); -} - -Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('./foo.js')); }); +import('./foo.js'); diff --git a/test/chunking-form/samples/dynamic-import-external/_expected/system/main.js b/test/chunking-form/samples/dynamic-import-external/_expected/system/main.js index 0824bad8d3f..e8e2518033b 100644 --- a/test/chunking-form/samples/dynamic-import-external/_expected/system/main.js +++ b/test/chunking-form/samples/dynamic-import-external/_expected/system/main.js @@ -1,10 +1,10 @@ -System.register([], function (exports, module) { +System.register([], (function (exports, module) { 'use strict'; return { - execute: function () { + execute: (function () { module.import('./foo.js'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/dynamic-import-facade/_config.js b/test/chunking-form/samples/dynamic-import-facade/_config.js index 62db88c24ef..d95396fa622 100644 --- a/test/chunking-form/samples/dynamic-import-facade/_config.js +++ b/test/chunking-form/samples/dynamic-import-facade/_config.js @@ -1,6 +1,6 @@ -module.exports = { +module.exports = defineTest({ description: 'makes sure dynamic chunks are not tainted', options: { input: ['main1.js', 'main2.js'] } -}; +}); diff --git a/test/chunking-form/samples/dynamic-import-facade/_expected/amd/generated-dynamic.js b/test/chunking-form/samples/dynamic-import-facade/_expected/amd/generated-dynamic.js index f5a33b1a4be..ecb3e1d920f 100644 --- a/test/chunking-form/samples/dynamic-import-facade/_expected/amd/generated-dynamic.js +++ b/test/chunking-form/samples/dynamic-import-facade/_expected/amd/generated-dynamic.js @@ -1,4 +1,4 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; console.log('dep'); @@ -16,4 +16,4 @@ define(['exports'], function (exports) { 'use strict'; exports.dynamic = dynamic; exports.dynamic$1 = dynamic$1; -}); +})); diff --git a/test/chunking-form/samples/dynamic-import-facade/_expected/amd/main1.js b/test/chunking-form/samples/dynamic-import-facade/_expected/amd/main1.js index 1d0494ad94c..7586e2d95bf 100644 --- a/test/chunking-form/samples/dynamic-import-facade/_expected/amd/main1.js +++ b/test/chunking-form/samples/dynamic-import-facade/_expected/amd/main1.js @@ -1,5 +1,5 @@ -define(['require'], function (require) { 'use strict'; +define(['require'], (function (require) { 'use strict'; - new Promise(function (resolve, reject) { require(['./generated-dynamic'], resolve, reject) }).then(function (n) { return n.dynamic$1; }).then(({dynamic}) => console.log('main1', dynamic)); + new Promise(function (resolve, reject) { require(['./generated-dynamic'], resolve, reject); }).then(function (n) { return n.dynamic$1; }).then(({dynamic}) => console.log('main1', dynamic)); -}); +})); diff --git a/test/chunking-form/samples/dynamic-import-facade/_expected/amd/main2.js b/test/chunking-form/samples/dynamic-import-facade/_expected/amd/main2.js index 1974c7d9afd..e60cc1ff2c1 100644 --- a/test/chunking-form/samples/dynamic-import-facade/_expected/amd/main2.js +++ b/test/chunking-form/samples/dynamic-import-facade/_expected/amd/main2.js @@ -1,5 +1,5 @@ -define(['./generated-dynamic'], function (dynamic) { 'use strict'; +define(['./generated-dynamic'], (function (dynamic) { 'use strict'; console.log('main2', dynamic.dynamic, dynamic.dep); -}); +})); diff --git a/test/chunking-form/samples/dynamic-import-facade/_expected/system/generated-dynamic.js b/test/chunking-form/samples/dynamic-import-facade/_expected/system/generated-dynamic.js index 5e725d7bbd0..924e74d403c 100644 --- a/test/chunking-form/samples/dynamic-import-facade/_expected/system/generated-dynamic.js +++ b/test/chunking-form/samples/dynamic-import-facade/_expected/system/generated-dynamic.js @@ -1,21 +1,21 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { console.log('dep'); - const dep = exports('a', 'dep'); + const dep = exports("a", 'dep'); console.log('dynamic', dep); - const dynamic = exports('d', 'dynamic'); + const dynamic = exports("d", 'dynamic'); var dynamic$1 = /*#__PURE__*/Object.freeze({ __proto__: null, dynamic: dynamic }); - exports('b', dynamic$1); + exports("b", dynamic$1); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/dynamic-import-facade/_expected/system/main1.js b/test/chunking-form/samples/dynamic-import-facade/_expected/system/main1.js index 4bc59f3fd76..16157e30d03 100644 --- a/test/chunking-form/samples/dynamic-import-facade/_expected/system/main1.js +++ b/test/chunking-form/samples/dynamic-import-facade/_expected/system/main1.js @@ -1,10 +1,10 @@ -System.register([], function (exports, module) { +System.register([], (function (exports, module) { 'use strict'; return { - execute: function () { + execute: (function () { module.import('./generated-dynamic.js').then(function (n) { return n.b; }).then(({dynamic}) => console.log('main1', dynamic)); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/dynamic-import-facade/_expected/system/main2.js b/test/chunking-form/samples/dynamic-import-facade/_expected/system/main2.js index 48bd74f53c6..d0c0b3934a6 100644 --- a/test/chunking-form/samples/dynamic-import-facade/_expected/system/main2.js +++ b/test/chunking-form/samples/dynamic-import-facade/_expected/system/main2.js @@ -1,4 +1,4 @@ -System.register(['./generated-dynamic.js'], function () { +System.register(['./generated-dynamic.js'], (function () { 'use strict'; var dynamic, dep; return { @@ -6,10 +6,10 @@ System.register(['./generated-dynamic.js'], function () { dynamic = module.d; dep = module.a; }], - execute: function () { + execute: (function () { console.log('main2', dynamic, dep); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/dynamic-import-from-manual-chunk/_config.js b/test/chunking-form/samples/dynamic-import-from-manual-chunk/_config.js new file mode 100644 index 00000000000..10571bfac78 --- /dev/null +++ b/test/chunking-form/samples/dynamic-import-from-manual-chunk/_config.js @@ -0,0 +1,11 @@ +module.exports = defineTest({ + description: 'handles dynamic imports in manual chunks', + options: { + input: 'main.js', + output: { + manualChunks: { + manual: ['manual.js'] + } + } + } +}); diff --git a/test/chunking-form/samples/dynamic-import-from-manual-chunk/_expected/amd/generated-dynamic.js b/test/chunking-form/samples/dynamic-import-from-manual-chunk/_expected/amd/generated-dynamic.js new file mode 100644 index 00000000000..63e4e679402 --- /dev/null +++ b/test/chunking-form/samples/dynamic-import-from-manual-chunk/_expected/amd/generated-dynamic.js @@ -0,0 +1,5 @@ +define(['./main', './generated-manual'], (function (main, manual) { 'use strict'; + + console.log(main.dep1, manual.dep2); + +})); diff --git a/test/chunking-form/samples/dynamic-import-from-manual-chunk/_expected/amd/generated-manual.js b/test/chunking-form/samples/dynamic-import-from-manual-chunk/_expected/amd/generated-manual.js new file mode 100644 index 00000000000..7fa0a8439c9 --- /dev/null +++ b/test/chunking-form/samples/dynamic-import-from-manual-chunk/_expected/amd/generated-manual.js @@ -0,0 +1,10 @@ +define(['require', 'exports'], (function (require, exports) { 'use strict'; + + const dep2 = 'dep2'; + + console.log(dep2); + new Promise(function (resolve, reject) { require(['./generated-dynamic'], resolve, reject); }); + + exports.dep2 = dep2; + +})); diff --git a/test/chunking-form/samples/dynamic-import-from-manual-chunk/_expected/amd/main.js b/test/chunking-form/samples/dynamic-import-from-manual-chunk/_expected/amd/main.js new file mode 100644 index 00000000000..09cf50c903b --- /dev/null +++ b/test/chunking-form/samples/dynamic-import-from-manual-chunk/_expected/amd/main.js @@ -0,0 +1,9 @@ +define(['exports', './generated-manual'], (function (exports, manual) { 'use strict'; + + const dep1 = 'dep1'; + + console.log(dep1); + + exports.dep1 = dep1; + +})); diff --git a/test/chunking-form/samples/dynamic-import-from-manual-chunk/_expected/cjs/generated-dynamic.js b/test/chunking-form/samples/dynamic-import-from-manual-chunk/_expected/cjs/generated-dynamic.js new file mode 100644 index 00000000000..d970e90cf66 --- /dev/null +++ b/test/chunking-form/samples/dynamic-import-from-manual-chunk/_expected/cjs/generated-dynamic.js @@ -0,0 +1,6 @@ +'use strict'; + +var main = require('./main.js'); +var manual = require('./generated-manual.js'); + +console.log(main.dep1, manual.dep2); diff --git a/test/chunking-form/samples/dynamic-import-from-manual-chunk/_expected/cjs/generated-manual.js b/test/chunking-form/samples/dynamic-import-from-manual-chunk/_expected/cjs/generated-manual.js new file mode 100644 index 00000000000..d83487277f5 --- /dev/null +++ b/test/chunking-form/samples/dynamic-import-from-manual-chunk/_expected/cjs/generated-manual.js @@ -0,0 +1,8 @@ +'use strict'; + +const dep2 = 'dep2'; + +console.log(dep2); +Promise.resolve().then(function () { return require('./generated-dynamic.js'); }); + +exports.dep2 = dep2; diff --git a/test/chunking-form/samples/dynamic-import-from-manual-chunk/_expected/cjs/main.js b/test/chunking-form/samples/dynamic-import-from-manual-chunk/_expected/cjs/main.js new file mode 100644 index 00000000000..088a9ff1580 --- /dev/null +++ b/test/chunking-form/samples/dynamic-import-from-manual-chunk/_expected/cjs/main.js @@ -0,0 +1,9 @@ +'use strict'; + +require('./generated-manual.js'); + +const dep1 = 'dep1'; + +console.log(dep1); + +exports.dep1 = dep1; diff --git a/test/chunking-form/samples/dynamic-import-from-manual-chunk/_expected/es/generated-dynamic.js b/test/chunking-form/samples/dynamic-import-from-manual-chunk/_expected/es/generated-dynamic.js new file mode 100644 index 00000000000..282805c4f46 --- /dev/null +++ b/test/chunking-form/samples/dynamic-import-from-manual-chunk/_expected/es/generated-dynamic.js @@ -0,0 +1,4 @@ +import { d as dep1 } from './main.js'; +import { d as dep2 } from './generated-manual.js'; + +console.log(dep1, dep2); diff --git a/test/chunking-form/samples/dynamic-import-from-manual-chunk/_expected/es/generated-manual.js b/test/chunking-form/samples/dynamic-import-from-manual-chunk/_expected/es/generated-manual.js new file mode 100644 index 00000000000..ac6182cee69 --- /dev/null +++ b/test/chunking-form/samples/dynamic-import-from-manual-chunk/_expected/es/generated-manual.js @@ -0,0 +1,6 @@ +const dep2 = 'dep2'; + +console.log(dep2); +import('./generated-dynamic.js'); + +export { dep2 as d }; diff --git a/test/chunking-form/samples/dynamic-import-from-manual-chunk/_expected/es/main.js b/test/chunking-form/samples/dynamic-import-from-manual-chunk/_expected/es/main.js new file mode 100644 index 00000000000..992b22c5ae0 --- /dev/null +++ b/test/chunking-form/samples/dynamic-import-from-manual-chunk/_expected/es/main.js @@ -0,0 +1,7 @@ +import './generated-manual.js'; + +const dep1 = 'dep1'; + +console.log(dep1); + +export { dep1 as d }; diff --git a/test/chunking-form/samples/dynamic-import-from-manual-chunk/_expected/system/generated-dynamic.js b/test/chunking-form/samples/dynamic-import-from-manual-chunk/_expected/system/generated-dynamic.js new file mode 100644 index 00000000000..583457f73b3 --- /dev/null +++ b/test/chunking-form/samples/dynamic-import-from-manual-chunk/_expected/system/generated-dynamic.js @@ -0,0 +1,16 @@ +System.register(['./main.js', './generated-manual.js'], (function () { + 'use strict'; + var dep1, dep2; + return { + setters: [function (module) { + dep1 = module.d; + }, function (module) { + dep2 = module.d; + }], + execute: (function () { + + console.log(dep1, dep2); + + }) + }; +})); diff --git a/test/chunking-form/samples/dynamic-import-from-manual-chunk/_expected/system/generated-manual.js b/test/chunking-form/samples/dynamic-import-from-manual-chunk/_expected/system/generated-manual.js new file mode 100644 index 00000000000..c5166ca0cca --- /dev/null +++ b/test/chunking-form/samples/dynamic-import-from-manual-chunk/_expected/system/generated-manual.js @@ -0,0 +1,13 @@ +System.register([], (function (exports, module) { + 'use strict'; + return { + execute: (function () { + + const dep2 = exports("d", 'dep2'); + + console.log(dep2); + module.import('./generated-dynamic.js'); + + }) + }; +})); diff --git a/test/chunking-form/samples/dynamic-import-from-manual-chunk/_expected/system/main.js b/test/chunking-form/samples/dynamic-import-from-manual-chunk/_expected/system/main.js new file mode 100644 index 00000000000..ef470af1197 --- /dev/null +++ b/test/chunking-form/samples/dynamic-import-from-manual-chunk/_expected/system/main.js @@ -0,0 +1,13 @@ +System.register(['./generated-manual.js'], (function (exports) { + 'use strict'; + return { + setters: [null], + execute: (function () { + + const dep1 = exports("d", 'dep1'); + + console.log(dep1); + + }) + }; +})); diff --git a/test/chunking-form/samples/dynamic-import-from-manual-chunk/dep1.js b/test/chunking-form/samples/dynamic-import-from-manual-chunk/dep1.js new file mode 100644 index 00000000000..58176a6f23f --- /dev/null +++ b/test/chunking-form/samples/dynamic-import-from-manual-chunk/dep1.js @@ -0,0 +1 @@ +export const dep1 = 'dep1'; diff --git a/test/chunking-form/samples/dynamic-import-from-manual-chunk/dep2.js b/test/chunking-form/samples/dynamic-import-from-manual-chunk/dep2.js new file mode 100644 index 00000000000..99b2aff58bd --- /dev/null +++ b/test/chunking-form/samples/dynamic-import-from-manual-chunk/dep2.js @@ -0,0 +1 @@ +export const dep2 = 'dep2'; diff --git a/test/chunking-form/samples/dynamic-import-from-manual-chunk/dynamic.js b/test/chunking-form/samples/dynamic-import-from-manual-chunk/dynamic.js new file mode 100644 index 00000000000..03ac3acefbe --- /dev/null +++ b/test/chunking-form/samples/dynamic-import-from-manual-chunk/dynamic.js @@ -0,0 +1,4 @@ +import { dep1 } from './dep1'; +import { dep2 } from './dep2'; + +console.log(dep1, dep2); diff --git a/test/chunking-form/samples/dynamic-import-from-manual-chunk/main.js b/test/chunking-form/samples/dynamic-import-from-manual-chunk/main.js new file mode 100644 index 00000000000..79951638218 --- /dev/null +++ b/test/chunking-form/samples/dynamic-import-from-manual-chunk/main.js @@ -0,0 +1,4 @@ +import { dep1 } from './dep1'; +import './manual'; + +console.log(dep1); diff --git a/test/chunking-form/samples/dynamic-import-from-manual-chunk/manual.js b/test/chunking-form/samples/dynamic-import-from-manual-chunk/manual.js new file mode 100644 index 00000000000..a99b6dca4a0 --- /dev/null +++ b/test/chunking-form/samples/dynamic-import-from-manual-chunk/manual.js @@ -0,0 +1,4 @@ +import { dep2 } from './dep2'; + +console.log(dep2); +import('./dynamic'); diff --git a/test/chunking-form/samples/dynamic-import-inline-colouring/_config.js b/test/chunking-form/samples/dynamic-import-inline-colouring/_config.js index b5769882caf..c4f59f85519 100644 --- a/test/chunking-form/samples/dynamic-import-inline-colouring/_config.js +++ b/test/chunking-form/samples/dynamic-import-inline-colouring/_config.js @@ -1,6 +1,6 @@ -module.exports = { +module.exports = defineTest({ description: 'Handle dynamic imports that are part of a static graph', options: { input: ['main1.js', 'main2.js'] } -}; +}); diff --git a/test/chunking-form/samples/dynamic-import-inline-colouring/_expected/amd/generated-separate.js b/test/chunking-form/samples/dynamic-import-inline-colouring/_expected/amd/generated-separate.js index 39394a740ad..539da34f71d 100644 --- a/test/chunking-form/samples/dynamic-import-inline-colouring/_expected/amd/generated-separate.js +++ b/test/chunking-form/samples/dynamic-import-inline-colouring/_expected/amd/generated-separate.js @@ -1,4 +1,4 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; var separate = 'separate'; const x = 2; @@ -7,4 +7,4 @@ define(['exports'], function (exports) { 'use strict'; exports.default = separate; exports.x = x; -}); +})); diff --git a/test/chunking-form/samples/dynamic-import-inline-colouring/_expected/amd/main1.js b/test/chunking-form/samples/dynamic-import-inline-colouring/_expected/amd/main1.js index 9cc6804739d..0ca64ff90de 100644 --- a/test/chunking-form/samples/dynamic-import-inline-colouring/_expected/amd/main1.js +++ b/test/chunking-form/samples/dynamic-import-inline-colouring/_expected/amd/main1.js @@ -1,4 +1,4 @@ -define(['require', 'exports', './generated-separate'], function (require, exports, separate$1) { 'use strict'; +define(['require', 'exports', './generated-separate'], (function (require, exports, separate$1) { 'use strict'; var inlined$1 = 'inlined'; const x = 1; @@ -6,16 +6,14 @@ define(['require', 'exports', './generated-separate'], function (require, export var inlined$2 = /*#__PURE__*/Object.freeze({ __proto__: null, - 'default': inlined$1, + default: inlined$1, x: x }); const inlined = Promise.resolve().then(function () { return inlined$2; }); - const separate = new Promise(function (resolve, reject) { require(['./generated-separate'], resolve, reject) }); + const separate = new Promise(function (resolve, reject) { require(['./generated-separate'], resolve, reject); }); exports.inlined = inlined; exports.separate = separate; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/dynamic-import-inline-colouring/_expected/amd/main2.js b/test/chunking-form/samples/dynamic-import-inline-colouring/_expected/amd/main2.js index 0be3fee1ac0..d75901a1ce6 100644 --- a/test/chunking-form/samples/dynamic-import-inline-colouring/_expected/amd/main2.js +++ b/test/chunking-form/samples/dynamic-import-inline-colouring/_expected/amd/main2.js @@ -1,9 +1,7 @@ -define(['require', 'exports'], function (require, exports) { 'use strict'; +define(['require', 'exports'], (function (require, exports) { 'use strict'; - const separate = new Promise(function (resolve, reject) { require(['./generated-separate'], resolve, reject) }); + const separate = new Promise(function (resolve, reject) { require(['./generated-separate'], resolve, reject); }); exports.separate = separate; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/dynamic-import-inline-colouring/_expected/cjs/main1.js b/test/chunking-form/samples/dynamic-import-inline-colouring/_expected/cjs/main1.js index e7468b89e79..29a1c11edd3 100644 --- a/test/chunking-form/samples/dynamic-import-inline-colouring/_expected/cjs/main1.js +++ b/test/chunking-form/samples/dynamic-import-inline-colouring/_expected/cjs/main1.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - require('./generated-separate.js'); var inlined$1 = 'inlined'; @@ -10,7 +8,7 @@ console.log('inlined'); var inlined$2 = /*#__PURE__*/Object.freeze({ __proto__: null, - 'default': inlined$1, + default: inlined$1, x: x }); diff --git a/test/chunking-form/samples/dynamic-import-inline-colouring/_expected/cjs/main2.js b/test/chunking-form/samples/dynamic-import-inline-colouring/_expected/cjs/main2.js index 0978a48dcc1..dc5b3882f18 100644 --- a/test/chunking-form/samples/dynamic-import-inline-colouring/_expected/cjs/main2.js +++ b/test/chunking-form/samples/dynamic-import-inline-colouring/_expected/cjs/main2.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - const separate = Promise.resolve().then(function () { return require('./generated-separate.js'); }); exports.separate = separate; diff --git a/test/chunking-form/samples/dynamic-import-inline-colouring/_expected/es/generated-separate.js b/test/chunking-form/samples/dynamic-import-inline-colouring/_expected/es/generated-separate.js index fd70da9ecd3..19236ddf914 100644 --- a/test/chunking-form/samples/dynamic-import-inline-colouring/_expected/es/generated-separate.js +++ b/test/chunking-form/samples/dynamic-import-inline-colouring/_expected/es/generated-separate.js @@ -2,5 +2,4 @@ var separate = 'separate'; const x = 2; console.log('separate'); -export default separate; -export { x }; +export { separate as default, x }; diff --git a/test/chunking-form/samples/dynamic-import-inline-colouring/_expected/es/main1.js b/test/chunking-form/samples/dynamic-import-inline-colouring/_expected/es/main1.js index 11da8ee1abb..fb298994f6f 100644 --- a/test/chunking-form/samples/dynamic-import-inline-colouring/_expected/es/main1.js +++ b/test/chunking-form/samples/dynamic-import-inline-colouring/_expected/es/main1.js @@ -6,7 +6,7 @@ console.log('inlined'); var inlined$2 = /*#__PURE__*/Object.freeze({ __proto__: null, - 'default': inlined$1, + default: inlined$1, x: x }); diff --git a/test/chunking-form/samples/dynamic-import-inline-colouring/_expected/system/generated-separate.js b/test/chunking-form/samples/dynamic-import-inline-colouring/_expected/system/generated-separate.js index 97c75dde7ae..063e55ea0a8 100644 --- a/test/chunking-form/samples/dynamic-import-inline-colouring/_expected/system/generated-separate.js +++ b/test/chunking-form/samples/dynamic-import-inline-colouring/_expected/system/generated-separate.js @@ -1,12 +1,12 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - var separate = exports('default', 'separate'); - const x = exports('x', 2); + var separate = exports("default", 'separate'); + const x = exports("x", 2); console.log('separate'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/dynamic-import-inline-colouring/_expected/system/main1.js b/test/chunking-form/samples/dynamic-import-inline-colouring/_expected/system/main1.js index f9de49de79a..c7097531e42 100644 --- a/test/chunking-form/samples/dynamic-import-inline-colouring/_expected/system/main1.js +++ b/test/chunking-form/samples/dynamic-import-inline-colouring/_expected/system/main1.js @@ -1,8 +1,8 @@ -System.register(['./generated-separate.js'], function (exports, module) { +System.register(['./generated-separate.js'], (function (exports, module) { 'use strict'; return { - setters: [function () {}], - execute: function () { + setters: [null], + execute: (function () { var inlined$1 = 'inlined'; const x = 1; @@ -10,13 +10,13 @@ System.register(['./generated-separate.js'], function (exports, module) { var inlined$2 = /*#__PURE__*/Object.freeze({ __proto__: null, - 'default': inlined$1, + default: inlined$1, x: x }); - const inlined = exports('inlined', Promise.resolve().then(function () { return inlined$2; })); - const separate = exports('separate', module.import('./generated-separate.js')); + const inlined = exports("inlined", Promise.resolve().then(function () { return inlined$2; })); + const separate = exports("separate", module.import('./generated-separate.js')); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/dynamic-import-inline-colouring/_expected/system/main2.js b/test/chunking-form/samples/dynamic-import-inline-colouring/_expected/system/main2.js index f54417af5a0..06a162172ca 100644 --- a/test/chunking-form/samples/dynamic-import-inline-colouring/_expected/system/main2.js +++ b/test/chunking-form/samples/dynamic-import-inline-colouring/_expected/system/main2.js @@ -1,10 +1,10 @@ -System.register([], function (exports, module) { +System.register([], (function (exports, module) { 'use strict'; return { - execute: function () { + execute: (function () { - const separate = exports('separate', module.import('./generated-separate.js')); + const separate = exports("separate", module.import('./generated-separate.js')); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/dynamic-import-inlining-object/_config.js b/test/chunking-form/samples/dynamic-import-inlining-object/_config.js index 7dec64bfdc0..6a6b04a9f5e 100644 --- a/test/chunking-form/samples/dynamic-import-inlining-object/_config.js +++ b/test/chunking-form/samples/dynamic-import-inlining-object/_config.js @@ -1,7 +1,7 @@ -module.exports = { +module.exports = defineTest({ description: 'supports an object with a single entry when inlining dynamic imports', options: { output: { inlineDynamicImports: true }, input: { entry: 'main' } } -}; +}); diff --git a/test/chunking-form/samples/dynamic-import-inlining-object/_expected/amd/entry.js b/test/chunking-form/samples/dynamic-import-inlining-object/_expected/amd/entry.js index 87c533f4a08..fef3de875f4 100644 --- a/test/chunking-form/samples/dynamic-import-inlining-object/_expected/amd/entry.js +++ b/test/chunking-form/samples/dynamic-import-inlining-object/_expected/amd/entry.js @@ -1,17 +1,12 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; const bar = 2; - Promise.resolve().then(function () { return foo$1; }); + Promise.resolve().then(function () { return foo; }); - const foo = 1; - - var foo$1 = /*#__PURE__*/Object.freeze({ - __proto__: null, - foo: foo + var foo = /*#__PURE__*/Object.freeze({ + __proto__: null }); exports.bar = bar; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/dynamic-import-inlining-object/_expected/cjs/entry.js b/test/chunking-form/samples/dynamic-import-inlining-object/_expected/cjs/entry.js index 188ad126796..218beb76d7d 100644 --- a/test/chunking-form/samples/dynamic-import-inlining-object/_expected/cjs/entry.js +++ b/test/chunking-form/samples/dynamic-import-inlining-object/_expected/cjs/entry.js @@ -1,15 +1,10 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - const bar = 2; -Promise.resolve().then(function () { return foo$1; }); - -const foo = 1; +Promise.resolve().then(function () { return foo; }); -var foo$1 = /*#__PURE__*/Object.freeze({ - __proto__: null, - foo: foo +var foo = /*#__PURE__*/Object.freeze({ + __proto__: null }); exports.bar = bar; diff --git a/test/chunking-form/samples/dynamic-import-inlining-object/_expected/es/entry.js b/test/chunking-form/samples/dynamic-import-inlining-object/_expected/es/entry.js index ae434046e6c..5a35de939db 100644 --- a/test/chunking-form/samples/dynamic-import-inlining-object/_expected/es/entry.js +++ b/test/chunking-form/samples/dynamic-import-inlining-object/_expected/es/entry.js @@ -1,11 +1,8 @@ const bar = 2; -Promise.resolve().then(function () { return foo$1; }); +Promise.resolve().then(function () { return foo; }); -const foo = 1; - -var foo$1 = /*#__PURE__*/Object.freeze({ - __proto__: null, - foo: foo +var foo = /*#__PURE__*/Object.freeze({ + __proto__: null }); export { bar }; diff --git a/test/chunking-form/samples/dynamic-import-inlining-object/_expected/system/entry.js b/test/chunking-form/samples/dynamic-import-inlining-object/_expected/system/entry.js index 0ac064e426c..39f7c0be723 100644 --- a/test/chunking-form/samples/dynamic-import-inlining-object/_expected/system/entry.js +++ b/test/chunking-form/samples/dynamic-import-inlining-object/_expected/system/entry.js @@ -1,18 +1,15 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - const bar = exports('bar', 2); - Promise.resolve().then(function () { return foo$1; }); + const bar = exports("bar", 2); + Promise.resolve().then(function () { return foo; }); - const foo = 1; - - var foo$1 = /*#__PURE__*/Object.freeze({ - __proto__: null, - foo: foo + var foo = /*#__PURE__*/Object.freeze({ + __proto__: null }); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/dynamic-import-object-property-tree-shaking-await/_config.js b/test/chunking-form/samples/dynamic-import-object-property-tree-shaking-await/_config.js new file mode 100644 index 00000000000..6284ffc48e7 --- /dev/null +++ b/test/chunking-form/samples/dynamic-import-object-property-tree-shaking-await/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'Supports tree-shaking for dynamic import object properties when using "await"' +}); diff --git a/test/chunking-form/samples/dynamic-import-object-property-tree-shaking-await/_expected/amd/generated-dep.js b/test/chunking-form/samples/dynamic-import-object-property-tree-shaking-await/_expected/amd/generated-dep.js new file mode 100644 index 00000000000..f40afd75f49 --- /dev/null +++ b/test/chunking-form/samples/dynamic-import-object-property-tree-shaking-await/_expected/amd/generated-dep.js @@ -0,0 +1,7 @@ +define(['exports'], (function (exports) { 'use strict'; + + const obj = { a: { a: { a: 'included'}}}; + + exports.obj = obj; + +})); diff --git a/test/chunking-form/samples/dynamic-import-object-property-tree-shaking-await/_expected/amd/main.js b/test/chunking-form/samples/dynamic-import-object-property-tree-shaking-await/_expected/amd/main.js new file mode 100644 index 00000000000..7be52264ff3 --- /dev/null +++ b/test/chunking-form/samples/dynamic-import-object-property-tree-shaking-await/_expected/amd/main.js @@ -0,0 +1,10 @@ +define(['require'], (function (require) { 'use strict'; + + async function test() { + const dep = await new Promise(function (resolve, reject) { require(['./generated-dep'], resolve, reject); }); + console.log(dep.obj.a.a.a); + } + + test(); + +})); diff --git a/test/chunking-form/samples/dynamic-import-object-property-tree-shaking-await/_expected/cjs/generated-dep.js b/test/chunking-form/samples/dynamic-import-object-property-tree-shaking-await/_expected/cjs/generated-dep.js new file mode 100644 index 00000000000..4f8bc995fbc --- /dev/null +++ b/test/chunking-form/samples/dynamic-import-object-property-tree-shaking-await/_expected/cjs/generated-dep.js @@ -0,0 +1,5 @@ +'use strict'; + +const obj = { a: { a: { a: 'included'}}}; + +exports.obj = obj; diff --git a/test/chunking-form/samples/dynamic-import-object-property-tree-shaking-await/_expected/cjs/main.js b/test/chunking-form/samples/dynamic-import-object-property-tree-shaking-await/_expected/cjs/main.js new file mode 100644 index 00000000000..21b6804de11 --- /dev/null +++ b/test/chunking-form/samples/dynamic-import-object-property-tree-shaking-await/_expected/cjs/main.js @@ -0,0 +1,8 @@ +'use strict'; + +async function test() { + const dep = await Promise.resolve().then(function () { return require('./generated-dep.js'); }); + console.log(dep.obj.a.a.a); +} + +test(); diff --git a/test/chunking-form/samples/dynamic-import-object-property-tree-shaking-await/_expected/es/generated-dep.js b/test/chunking-form/samples/dynamic-import-object-property-tree-shaking-await/_expected/es/generated-dep.js new file mode 100644 index 00000000000..788e59fda90 --- /dev/null +++ b/test/chunking-form/samples/dynamic-import-object-property-tree-shaking-await/_expected/es/generated-dep.js @@ -0,0 +1,3 @@ +const obj = { a: { a: { a: 'included'}}}; + +export { obj }; diff --git a/test/chunking-form/samples/dynamic-import-object-property-tree-shaking-await/_expected/es/main.js b/test/chunking-form/samples/dynamic-import-object-property-tree-shaking-await/_expected/es/main.js new file mode 100644 index 00000000000..32f44e99edd --- /dev/null +++ b/test/chunking-form/samples/dynamic-import-object-property-tree-shaking-await/_expected/es/main.js @@ -0,0 +1,6 @@ +async function test() { + const dep = await import('./generated-dep.js'); + console.log(dep.obj.a.a.a); +} + +test(); diff --git a/test/chunking-form/samples/dynamic-import-object-property-tree-shaking-await/_expected/system/generated-dep.js b/test/chunking-form/samples/dynamic-import-object-property-tree-shaking-await/_expected/system/generated-dep.js new file mode 100644 index 00000000000..6db374f62e3 --- /dev/null +++ b/test/chunking-form/samples/dynamic-import-object-property-tree-shaking-await/_expected/system/generated-dep.js @@ -0,0 +1,10 @@ +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + + const obj = exports("obj", { a: { a: { a: 'included'}}}); + + }) + }; +})); diff --git a/test/chunking-form/samples/dynamic-import-object-property-tree-shaking-await/_expected/system/main.js b/test/chunking-form/samples/dynamic-import-object-property-tree-shaking-await/_expected/system/main.js new file mode 100644 index 00000000000..5dec256a2ee --- /dev/null +++ b/test/chunking-form/samples/dynamic-import-object-property-tree-shaking-await/_expected/system/main.js @@ -0,0 +1,15 @@ +System.register([], (function (exports, module) { + 'use strict'; + return { + execute: (function () { + + async function test() { + const dep = await module.import('./generated-dep.js'); + console.log(dep.obj.a.a.a); + } + + test(); + + }) + }; +})); diff --git a/test/chunking-form/samples/dynamic-import-object-property-tree-shaking-await/dep.js b/test/chunking-form/samples/dynamic-import-object-property-tree-shaking-await/dep.js new file mode 100644 index 00000000000..2d41a5dea57 --- /dev/null +++ b/test/chunking-form/samples/dynamic-import-object-property-tree-shaking-await/dep.js @@ -0,0 +1,2 @@ +export const obj = { a: { a: { a: 'included', b: 'removed' }, b: 'removed' }, b: 'removed' }; +export const unused = 'removed'; diff --git a/test/chunking-form/samples/dynamic-import-object-property-tree-shaking-await/main.js b/test/chunking-form/samples/dynamic-import-object-property-tree-shaking-await/main.js new file mode 100644 index 00000000000..9d8522e2ecf --- /dev/null +++ b/test/chunking-form/samples/dynamic-import-object-property-tree-shaking-await/main.js @@ -0,0 +1,6 @@ +async function test() { + const dep = await import('./dep.js'); + console.log(dep.obj.a.a.a); +} + +test(); diff --git a/test/chunking-form/samples/dynamic-import-object-property-tree-shaking-then/_config.js b/test/chunking-form/samples/dynamic-import-object-property-tree-shaking-then/_config.js new file mode 100644 index 00000000000..507c78087f7 --- /dev/null +++ b/test/chunking-form/samples/dynamic-import-object-property-tree-shaking-then/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'Supports tree-shaking for dynamic import object properties when using "then"' +}); diff --git a/test/chunking-form/samples/dynamic-import-object-property-tree-shaking-then/_expected/amd/generated-dep.js b/test/chunking-form/samples/dynamic-import-object-property-tree-shaking-then/_expected/amd/generated-dep.js new file mode 100644 index 00000000000..f64c93db820 --- /dev/null +++ b/test/chunking-form/samples/dynamic-import-object-property-tree-shaking-then/_expected/amd/generated-dep.js @@ -0,0 +1,7 @@ +define(['exports'], (function (exports) { 'use strict'; + + const obj = { a: 'included'}; + + exports.obj = obj; + +})); diff --git a/test/chunking-form/samples/dynamic-import-object-property-tree-shaking-then/_expected/amd/main.js b/test/chunking-form/samples/dynamic-import-object-property-tree-shaking-then/_expected/amd/main.js new file mode 100644 index 00000000000..b3963c2cd4c --- /dev/null +++ b/test/chunking-form/samples/dynamic-import-object-property-tree-shaking-then/_expected/amd/main.js @@ -0,0 +1,7 @@ +define(['require'], (function (require) { 'use strict'; + + new Promise(function (resolve, reject) { require(['./generated-dep'], resolve, reject); }).then(({ obj }) => { + console.log(obj.a); + }); + +})); diff --git a/test/chunking-form/samples/dynamic-import-object-property-tree-shaking-then/_expected/cjs/generated-dep.js b/test/chunking-form/samples/dynamic-import-object-property-tree-shaking-then/_expected/cjs/generated-dep.js new file mode 100644 index 00000000000..36c7f5ad9c5 --- /dev/null +++ b/test/chunking-form/samples/dynamic-import-object-property-tree-shaking-then/_expected/cjs/generated-dep.js @@ -0,0 +1,5 @@ +'use strict'; + +const obj = { a: 'included'}; + +exports.obj = obj; diff --git a/test/chunking-form/samples/dynamic-import-object-property-tree-shaking-then/_expected/cjs/main.js b/test/chunking-form/samples/dynamic-import-object-property-tree-shaking-then/_expected/cjs/main.js new file mode 100644 index 00000000000..15aefd347c9 --- /dev/null +++ b/test/chunking-form/samples/dynamic-import-object-property-tree-shaking-then/_expected/cjs/main.js @@ -0,0 +1,5 @@ +'use strict'; + +Promise.resolve().then(function () { return require('./generated-dep.js'); }).then(({ obj }) => { + console.log(obj.a); +}); diff --git a/test/chunking-form/samples/dynamic-import-object-property-tree-shaking-then/_expected/es/generated-dep.js b/test/chunking-form/samples/dynamic-import-object-property-tree-shaking-then/_expected/es/generated-dep.js new file mode 100644 index 00000000000..e761bceea79 --- /dev/null +++ b/test/chunking-form/samples/dynamic-import-object-property-tree-shaking-then/_expected/es/generated-dep.js @@ -0,0 +1,3 @@ +const obj = { a: 'included'}; + +export { obj }; diff --git a/test/chunking-form/samples/dynamic-import-object-property-tree-shaking-then/_expected/es/main.js b/test/chunking-form/samples/dynamic-import-object-property-tree-shaking-then/_expected/es/main.js new file mode 100644 index 00000000000..c5552db1780 --- /dev/null +++ b/test/chunking-form/samples/dynamic-import-object-property-tree-shaking-then/_expected/es/main.js @@ -0,0 +1,3 @@ +import('./generated-dep.js').then(({ obj }) => { + console.log(obj.a); +}); diff --git a/test/chunking-form/samples/dynamic-import-object-property-tree-shaking-then/_expected/system/generated-dep.js b/test/chunking-form/samples/dynamic-import-object-property-tree-shaking-then/_expected/system/generated-dep.js new file mode 100644 index 00000000000..1a82a2aac79 --- /dev/null +++ b/test/chunking-form/samples/dynamic-import-object-property-tree-shaking-then/_expected/system/generated-dep.js @@ -0,0 +1,10 @@ +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + + const obj = exports("obj", { a: 'included'}); + + }) + }; +})); diff --git a/test/chunking-form/samples/dynamic-import-object-property-tree-shaking-then/_expected/system/main.js b/test/chunking-form/samples/dynamic-import-object-property-tree-shaking-then/_expected/system/main.js new file mode 100644 index 00000000000..7e1638213ad --- /dev/null +++ b/test/chunking-form/samples/dynamic-import-object-property-tree-shaking-then/_expected/system/main.js @@ -0,0 +1,12 @@ +System.register([], (function (exports, module) { + 'use strict'; + return { + execute: (function () { + + module.import('./generated-dep.js').then(({ obj }) => { + console.log(obj.a); + }); + + }) + }; +})); diff --git a/test/chunking-form/samples/dynamic-import-object-property-tree-shaking-then/dep.js b/test/chunking-form/samples/dynamic-import-object-property-tree-shaking-then/dep.js new file mode 100644 index 00000000000..27d10de6672 --- /dev/null +++ b/test/chunking-form/samples/dynamic-import-object-property-tree-shaking-then/dep.js @@ -0,0 +1,2 @@ +export const obj = { a: 'included', b: 'removed' }; +export const unused = 'removed'; diff --git a/test/chunking-form/samples/dynamic-import-object-property-tree-shaking-then/main.js b/test/chunking-form/samples/dynamic-import-object-property-tree-shaking-then/main.js new file mode 100644 index 00000000000..d6ea8d3f350 --- /dev/null +++ b/test/chunking-form/samples/dynamic-import-object-property-tree-shaking-then/main.js @@ -0,0 +1,3 @@ +import('./dep.js').then(({ obj }) => { + console.log(obj.a) +}); diff --git a/test/chunking-form/samples/dynamic-import-only-default/_config.js b/test/chunking-form/samples/dynamic-import-only-default/_config.js index c96873edaf0..e345872ade5 100644 --- a/test/chunking-form/samples/dynamic-import-only-default/_config.js +++ b/test/chunking-form/samples/dynamic-import-only-default/_config.js @@ -1,7 +1,7 @@ -module.exports = { +module.exports = defineTest({ description: 'correctly imports dynamic namespaces with only a default export from entry- and non-entry-point chunks', options: { input: ['main', 'entry'] } -}; +}); diff --git a/test/chunking-form/samples/dynamic-import-only-default/_expected/amd/entry.js b/test/chunking-form/samples/dynamic-import-only-default/_expected/amd/entry.js index 341fb1ba462..0dc55c85276 100644 --- a/test/chunking-form/samples/dynamic-import-only-default/_expected/amd/entry.js +++ b/test/chunking-form/samples/dynamic-import-only-default/_expected/amd/entry.js @@ -1,7 +1,7 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; var entry = 42; return entry; -}); +})); diff --git a/test/chunking-form/samples/dynamic-import-only-default/_expected/amd/generated-other.js b/test/chunking-form/samples/dynamic-import-only-default/_expected/amd/generated-other.js index 290138d02f8..8dd05fc1e71 100644 --- a/test/chunking-form/samples/dynamic-import-only-default/_expected/amd/generated-other.js +++ b/test/chunking-form/samples/dynamic-import-only-default/_expected/amd/generated-other.js @@ -1,7 +1,7 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; var other = 42; exports.default = other; -}); +})); diff --git a/test/chunking-form/samples/dynamic-import-only-default/_expected/amd/main.js b/test/chunking-form/samples/dynamic-import-only-default/_expected/amd/main.js index 9c42bd53bc9..f90fb21a876 100644 --- a/test/chunking-form/samples/dynamic-import-only-default/_expected/amd/main.js +++ b/test/chunking-form/samples/dynamic-import-only-default/_expected/amd/main.js @@ -1,11 +1,9 @@ -define(['require'], function (require) { 'use strict'; +define(['require'], (function (require) { 'use strict'; - function _interopNamespaceDefaultOnly(e) { - return Object.freeze({__proto__: null, 'default': e}); - } + function _interopNamespaceDefaultOnly (e) { return Object.freeze({ __proto__: null, default: e }); } - var main = Promise.all([new Promise(function (resolve, reject) { require(['./entry'], function (m) { resolve(/*#__PURE__*/_interopNamespaceDefaultOnly(m)); }, reject) }), new Promise(function (resolve, reject) { require(['./generated-other'], resolve, reject) })]); + var main = Promise.all([new Promise(function (resolve, reject) { require(['./entry'], function (m) { resolve(/*#__PURE__*/_interopNamespaceDefaultOnly(m)); }, reject); }), new Promise(function (resolve, reject) { require(['./generated-other'], resolve, reject); })]); return main; -}); +})); diff --git a/test/chunking-form/samples/dynamic-import-only-default/_expected/cjs/main.js b/test/chunking-form/samples/dynamic-import-only-default/_expected/cjs/main.js index 92840d7dce3..34a2e025684 100644 --- a/test/chunking-form/samples/dynamic-import-only-default/_expected/cjs/main.js +++ b/test/chunking-form/samples/dynamic-import-only-default/_expected/cjs/main.js @@ -1,8 +1,6 @@ 'use strict'; -function _interopNamespaceDefaultOnly(e) { - return Object.freeze({__proto__: null, 'default': e}); -} +function _interopNamespaceDefaultOnly (e) { return Object.freeze({ __proto__: null, default: e }); } var main = Promise.all([Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespaceDefaultOnly(require('./entry.js')); }), Promise.resolve().then(function () { return require('./generated-other.js'); })]); diff --git a/test/chunking-form/samples/dynamic-import-only-default/_expected/es/entry.js b/test/chunking-form/samples/dynamic-import-only-default/_expected/es/entry.js index 6071e090095..1b16d549a54 100644 --- a/test/chunking-form/samples/dynamic-import-only-default/_expected/es/entry.js +++ b/test/chunking-form/samples/dynamic-import-only-default/_expected/es/entry.js @@ -1,3 +1,3 @@ var entry = 42; -export default entry; +export { entry as default }; diff --git a/test/chunking-form/samples/dynamic-import-only-default/_expected/es/generated-other.js b/test/chunking-form/samples/dynamic-import-only-default/_expected/es/generated-other.js index fbe3caedc6c..53819e1d13a 100644 --- a/test/chunking-form/samples/dynamic-import-only-default/_expected/es/generated-other.js +++ b/test/chunking-form/samples/dynamic-import-only-default/_expected/es/generated-other.js @@ -1,3 +1,3 @@ var other = 42; -export default other; +export { other as default }; diff --git a/test/chunking-form/samples/dynamic-import-only-default/_expected/es/main.js b/test/chunking-form/samples/dynamic-import-only-default/_expected/es/main.js index fcf4f050e93..7ba00bc9455 100644 --- a/test/chunking-form/samples/dynamic-import-only-default/_expected/es/main.js +++ b/test/chunking-form/samples/dynamic-import-only-default/_expected/es/main.js @@ -1,3 +1,3 @@ var main = Promise.all([import('./entry.js'), import('./generated-other.js')]); -export default main; +export { main as default }; diff --git a/test/chunking-form/samples/dynamic-import-only-default/_expected/system/entry.js b/test/chunking-form/samples/dynamic-import-only-default/_expected/system/entry.js index a7c67730f41..67d537ce021 100644 --- a/test/chunking-form/samples/dynamic-import-only-default/_expected/system/entry.js +++ b/test/chunking-form/samples/dynamic-import-only-default/_expected/system/entry.js @@ -1,10 +1,10 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - var entry = exports('default', 42); + var entry = exports("default", 42); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/dynamic-import-only-default/_expected/system/generated-other.js b/test/chunking-form/samples/dynamic-import-only-default/_expected/system/generated-other.js index 7995c0dba26..26ff17f05ec 100644 --- a/test/chunking-form/samples/dynamic-import-only-default/_expected/system/generated-other.js +++ b/test/chunking-form/samples/dynamic-import-only-default/_expected/system/generated-other.js @@ -1,10 +1,10 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - var other = exports('default', 42); + var other = exports("default", 42); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/dynamic-import-only-default/_expected/system/main.js b/test/chunking-form/samples/dynamic-import-only-default/_expected/system/main.js index 5bf4e8e0719..f06678f4a13 100644 --- a/test/chunking-form/samples/dynamic-import-only-default/_expected/system/main.js +++ b/test/chunking-form/samples/dynamic-import-only-default/_expected/system/main.js @@ -1,10 +1,10 @@ -System.register([], function (exports, module) { +System.register([], (function (exports, module) { 'use strict'; return { - execute: function () { + execute: (function () { - var main = exports('default', Promise.all([module.import('./entry.js'), module.import('./generated-other.js')])); + var main = exports("default", Promise.all([module.import('./entry.js'), module.import('./generated-other.js')])); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/dynamic-import-only-reexports/_config.js b/test/chunking-form/samples/dynamic-import-only-reexports/_config.js index 1848e95f2e8..66aeea5f2f1 100644 --- a/test/chunking-form/samples/dynamic-import-only-reexports/_config.js +++ b/test/chunking-form/samples/dynamic-import-only-reexports/_config.js @@ -1,6 +1,6 @@ -module.exports = { +module.exports = defineTest({ description: 'handles dynamic imports when the imported module only reexports from other modules', options: { input: ['main'] } -}; +}); diff --git a/test/chunking-form/samples/dynamic-import-only-reexports/_expected/amd/generated-dynamic.js b/test/chunking-form/samples/dynamic-import-only-reexports/_expected/amd/generated-dynamic.js index bf7989e606f..947ad1cbafd 100644 --- a/test/chunking-form/samples/dynamic-import-only-reexports/_expected/amd/generated-dynamic.js +++ b/test/chunking-form/samples/dynamic-import-only-reexports/_expected/amd/generated-dynamic.js @@ -1,7 +1,7 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; const value = 42; exports.value = value; -}); +})); diff --git a/test/chunking-form/samples/dynamic-import-only-reexports/_expected/amd/main.js b/test/chunking-form/samples/dynamic-import-only-reexports/_expected/amd/main.js index 86ed8240329..d52ff54d3a8 100644 --- a/test/chunking-form/samples/dynamic-import-only-reexports/_expected/amd/main.js +++ b/test/chunking-form/samples/dynamic-import-only-reexports/_expected/amd/main.js @@ -1,5 +1,5 @@ -define(['require'], function (require) { 'use strict'; +define(['require'], (function (require) { 'use strict'; - new Promise(function (resolve, reject) { require(['./generated-dynamic'], resolve, reject) }).then(({ value }) => console.log(value)); + new Promise(function (resolve, reject) { require(['./generated-dynamic'], resolve, reject); }).then(({ value }) => console.log(value)); -}); +})); diff --git a/test/chunking-form/samples/dynamic-import-only-reexports/_expected/system/generated-dynamic.js b/test/chunking-form/samples/dynamic-import-only-reexports/_expected/system/generated-dynamic.js index 437f1af456e..f80269f9009 100644 --- a/test/chunking-form/samples/dynamic-import-only-reexports/_expected/system/generated-dynamic.js +++ b/test/chunking-form/samples/dynamic-import-only-reexports/_expected/system/generated-dynamic.js @@ -1,10 +1,10 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - const value = exports('value', 42); + const value = exports("value", 42); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/dynamic-import-only-reexports/_expected/system/main.js b/test/chunking-form/samples/dynamic-import-only-reexports/_expected/system/main.js index c9a3d7a8e03..26fc7a5308e 100644 --- a/test/chunking-form/samples/dynamic-import-only-reexports/_expected/system/main.js +++ b/test/chunking-form/samples/dynamic-import-only-reexports/_expected/system/main.js @@ -1,10 +1,10 @@ -System.register([], function (exports, module) { +System.register([], (function (exports, module) { 'use strict'; return { - execute: function () { + execute: (function () { module.import('./generated-dynamic.js').then(({ value }) => console.log(value)); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/dynamic-import-statically-imported-2/_config.js b/test/chunking-form/samples/dynamic-import-statically-imported-2/_config.js index 2da1b771499..29c1025db4a 100644 --- a/test/chunking-form/samples/dynamic-import-statically-imported-2/_config.js +++ b/test/chunking-form/samples/dynamic-import-statically-imported-2/_config.js @@ -1,7 +1,7 @@ -module.exports = { +module.exports = defineTest({ description: 'handles dynamic imports of previously statically imported chunks that are also dynamically imported by other chunks', options: { input: ['main.js', 'main2.js'] } -}; +}); diff --git a/test/chunking-form/samples/dynamic-import-statically-imported-2/_expected/amd/generated-dep1.js b/test/chunking-form/samples/dynamic-import-statically-imported-2/_expected/amd/generated-dep1.js index 79bab8425d4..b468406da6e 100644 --- a/test/chunking-form/samples/dynamic-import-statically-imported-2/_expected/amd/generated-dep1.js +++ b/test/chunking-form/samples/dynamic-import-statically-imported-2/_expected/amd/generated-dep1.js @@ -1,4 +1,4 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; function foo() { return 'dep2'; @@ -19,4 +19,4 @@ define(['exports'], function (exports) { 'use strict'; exports.dep1 = dep1; exports.foo = foo; -}); +})); diff --git a/test/chunking-form/samples/dynamic-import-statically-imported-2/_expected/amd/main.js b/test/chunking-form/samples/dynamic-import-statically-imported-2/_expected/amd/main.js index cac66392a39..1fa255dfde3 100644 --- a/test/chunking-form/samples/dynamic-import-statically-imported-2/_expected/amd/main.js +++ b/test/chunking-form/samples/dynamic-import-statically-imported-2/_expected/amd/main.js @@ -1,5 +1,5 @@ -define(['./generated-dep1'], function (dep1) { 'use strict'; +define(['./generated-dep1'], (function (dep1) { 'use strict'; console.log(dep1.foo(), dep1.bar()); -}); +})); diff --git a/test/chunking-form/samples/dynamic-import-statically-imported-2/_expected/amd/main2.js b/test/chunking-form/samples/dynamic-import-statically-imported-2/_expected/amd/main2.js index e0ac371ff61..1cb1c65df4f 100644 --- a/test/chunking-form/samples/dynamic-import-statically-imported-2/_expected/amd/main2.js +++ b/test/chunking-form/samples/dynamic-import-statically-imported-2/_expected/amd/main2.js @@ -1,5 +1,5 @@ -define(['require'], function (require) { 'use strict'; +define(['require'], (function (require) { 'use strict'; - new Promise(function (resolve, reject) { require(['./generated-dep1'], resolve, reject) }).then(function (n) { return n.dep1; }).then(({ bar }) => console.log(bar())); + new Promise(function (resolve, reject) { require(['./generated-dep1'], resolve, reject); }).then(function (n) { return n.dep1; }).then(({ bar }) => console.log(bar())); -}); +})); diff --git a/test/chunking-form/samples/dynamic-import-statically-imported-2/_expected/system/generated-dep1.js b/test/chunking-form/samples/dynamic-import-statically-imported-2/_expected/system/generated-dep1.js index a3b7e7440bf..90dace5f201 100644 --- a/test/chunking-form/samples/dynamic-import-statically-imported-2/_expected/system/generated-dep1.js +++ b/test/chunking-form/samples/dynamic-import-statically-imported-2/_expected/system/generated-dep1.js @@ -1,7 +1,7 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { exports({ b: bar, @@ -22,8 +22,8 @@ System.register([], function (exports) { __proto__: null, bar: bar }); - exports('d', dep1); + exports("d", dep1); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/dynamic-import-statically-imported-2/_expected/system/main.js b/test/chunking-form/samples/dynamic-import-statically-imported-2/_expected/system/main.js index 1f0c72ea5a1..293f7a4a3c5 100644 --- a/test/chunking-form/samples/dynamic-import-statically-imported-2/_expected/system/main.js +++ b/test/chunking-form/samples/dynamic-import-statically-imported-2/_expected/system/main.js @@ -1,4 +1,4 @@ -System.register(['./generated-dep1.js'], function () { +System.register(['./generated-dep1.js'], (function () { 'use strict'; var foo, bar; return { @@ -6,10 +6,10 @@ System.register(['./generated-dep1.js'], function () { foo = module.f; bar = module.b; }], - execute: function () { + execute: (function () { console.log(foo(), bar()); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/dynamic-import-statically-imported-2/_expected/system/main2.js b/test/chunking-form/samples/dynamic-import-statically-imported-2/_expected/system/main2.js index a03fddab216..1f7b69ce950 100644 --- a/test/chunking-form/samples/dynamic-import-statically-imported-2/_expected/system/main2.js +++ b/test/chunking-form/samples/dynamic-import-statically-imported-2/_expected/system/main2.js @@ -1,10 +1,10 @@ -System.register([], function (exports, module) { +System.register([], (function (exports, module) { 'use strict'; return { - execute: function () { + execute: (function () { module.import('./generated-dep1.js').then(function (n) { return n.d; }).then(({ bar }) => console.log(bar())); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/dynamic-import-statically-imported/_config.js b/test/chunking-form/samples/dynamic-import-statically-imported/_config.js index 4fd6f721ac4..0017ffbb9de 100644 --- a/test/chunking-form/samples/dynamic-import-statically-imported/_config.js +++ b/test/chunking-form/samples/dynamic-import-statically-imported/_config.js @@ -1,6 +1,6 @@ -module.exports = { +module.exports = defineTest({ description: 'handles dynamic imports of previously statically imported chunks', options: { input: ['main.js'] } -}; +}); diff --git a/test/chunking-form/samples/dynamic-import-statically-imported/_expected/amd/main.js b/test/chunking-form/samples/dynamic-import-statically-imported/_expected/amd/main.js index 5a7c901f9d8..f5bf4c22001 100644 --- a/test/chunking-form/samples/dynamic-import-statically-imported/_expected/amd/main.js +++ b/test/chunking-form/samples/dynamic-import-statically-imported/_expected/amd/main.js @@ -1,4 +1,4 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; function foo() { return 'dep2'; @@ -17,4 +17,4 @@ define(function () { 'use strict'; console.log(foo(), bar()); -}); +})); diff --git a/test/chunking-form/samples/dynamic-import-statically-imported/_expected/system/main.js b/test/chunking-form/samples/dynamic-import-statically-imported/_expected/system/main.js index 524ed74f1fd..317d72beaa2 100644 --- a/test/chunking-form/samples/dynamic-import-statically-imported/_expected/system/main.js +++ b/test/chunking-form/samples/dynamic-import-statically-imported/_expected/system/main.js @@ -1,7 +1,7 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { function foo() { return 'dep2'; @@ -20,6 +20,6 @@ System.register([], function () { console.log(foo(), bar()); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/dynamic-import-synthetic-exports-preserve-modules/_config.js b/test/chunking-form/samples/dynamic-import-synthetic-exports-preserve-modules/_config.js index 5355d8b2fee..f8f4fbc41ad 100644 --- a/test/chunking-form/samples/dynamic-import-synthetic-exports-preserve-modules/_config.js +++ b/test/chunking-form/samples/dynamic-import-synthetic-exports-preserve-modules/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'handle dynamically importing a module with synthetic named exports when preserving modules', options: { @@ -12,7 +12,8 @@ module.exports = { } }, output: { + exports: 'named', preserveModules: true } } -}; +}); diff --git a/test/chunking-form/samples/dynamic-import-synthetic-exports-preserve-modules/_expected/amd/lib.js b/test/chunking-form/samples/dynamic-import-synthetic-exports-preserve-modules/_expected/amd/lib.js index 79fb280a443..11b36a0055f 100644 --- a/test/chunking-form/samples/dynamic-import-synthetic-exports-preserve-modules/_expected/amd/lib.js +++ b/test/chunking-form/samples/dynamic-import-synthetic-exports-preserve-modules/_expected/amd/lib.js @@ -1,8 +1,31 @@ -define(function () { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; + + function _mergeNamespaces(n, m) { + m.forEach(function (e) { + e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) { + if (k !== 'default' && !(k in n)) { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + }); + return Object.freeze(n); + } const __moduleExports = { foo: 'bar' }; var lib = 'baz'; - return lib; + var lib$1 = /*#__PURE__*/_mergeNamespaces({ + __proto__: null, + default: lib + }, [__moduleExports]); + + exports.default = lib; + exports.lib = lib$1; + + Object.defineProperty(exports, '__esModule', { value: true }); -}); +})); diff --git a/test/chunking-form/samples/dynamic-import-synthetic-exports-preserve-modules/_expected/amd/main.js b/test/chunking-form/samples/dynamic-import-synthetic-exports-preserve-modules/_expected/amd/main.js index 1cdbe5f6d44..f09ebbbb6c6 100644 --- a/test/chunking-form/samples/dynamic-import-synthetic-exports-preserve-modules/_expected/amd/main.js +++ b/test/chunking-form/samples/dynamic-import-synthetic-exports-preserve-modules/_expected/amd/main.js @@ -1,9 +1,5 @@ -define(['require'], function (require) { 'use strict'; +define(['require'], (function (require) { 'use strict'; - function _interopNamespaceDefaultOnly(e) { - return Object.freeze({__proto__: null, 'default': e}); - } + new Promise(function (resolve, reject) { require(['./lib'], resolve, reject); }).then(function (n) { return n.lib; }).then(console.log); - new Promise(function (resolve, reject) { require(['./lib'], function (m) { resolve(/*#__PURE__*/_interopNamespaceDefaultOnly(m)); }, reject) }).then(console.log); - -}); +})); diff --git a/test/chunking-form/samples/dynamic-import-synthetic-exports-preserve-modules/_expected/cjs/lib.js b/test/chunking-form/samples/dynamic-import-synthetic-exports-preserve-modules/_expected/cjs/lib.js index dd97d1c0b34..613c61a0d21 100644 --- a/test/chunking-form/samples/dynamic-import-synthetic-exports-preserve-modules/_expected/cjs/lib.js +++ b/test/chunking-form/samples/dynamic-import-synthetic-exports-preserve-modules/_expected/cjs/lib.js @@ -1,6 +1,29 @@ 'use strict'; +Object.defineProperty(exports, '__esModule', { value: true }); + +function _mergeNamespaces(n, m) { + m.forEach(function (e) { + e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) { + if (k !== 'default' && !(k in n)) { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + }); + return Object.freeze(n); +} + const __moduleExports = { foo: 'bar' }; var lib = 'baz'; -module.exports = lib; +var lib$1 = /*#__PURE__*/_mergeNamespaces({ + __proto__: null, + default: lib +}, [__moduleExports]); + +exports.default = lib; +exports.lib = lib$1; diff --git a/test/chunking-form/samples/dynamic-import-synthetic-exports-preserve-modules/_expected/cjs/main.js b/test/chunking-form/samples/dynamic-import-synthetic-exports-preserve-modules/_expected/cjs/main.js index 3fdaab993a9..9d3d5a31602 100644 --- a/test/chunking-form/samples/dynamic-import-synthetic-exports-preserve-modules/_expected/cjs/main.js +++ b/test/chunking-form/samples/dynamic-import-synthetic-exports-preserve-modules/_expected/cjs/main.js @@ -1,7 +1,3 @@ 'use strict'; -function _interopNamespaceDefaultOnly(e) { - return Object.freeze({__proto__: null, 'default': e}); -} - -Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespaceDefaultOnly(require('./lib.js')); }).then(console.log); +Promise.resolve().then(function () { return require('./lib.js'); }).then(function (n) { return n.lib; }).then(console.log); diff --git a/test/chunking-form/samples/dynamic-import-synthetic-exports-preserve-modules/_expected/es/lib.js b/test/chunking-form/samples/dynamic-import-synthetic-exports-preserve-modules/_expected/es/lib.js index 27160dc1838..32e7df1d8dd 100644 --- a/test/chunking-form/samples/dynamic-import-synthetic-exports-preserve-modules/_expected/es/lib.js +++ b/test/chunking-form/samples/dynamic-import-synthetic-exports-preserve-modules/_expected/es/lib.js @@ -1,4 +1,24 @@ +function _mergeNamespaces(n, m) { + m.forEach(function (e) { + e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) { + if (k !== 'default' && !(k in n)) { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + }); + return Object.freeze(n); +} + const __moduleExports = { foo: 'bar' }; var lib = 'baz'; -export default lib; +var lib$1 = /*#__PURE__*/_mergeNamespaces({ + __proto__: null, + default: lib +}, [__moduleExports]); + +export { lib as default, lib$1 as l }; diff --git a/test/chunking-form/samples/dynamic-import-synthetic-exports-preserve-modules/_expected/es/main.js b/test/chunking-form/samples/dynamic-import-synthetic-exports-preserve-modules/_expected/es/main.js index 5d8f1be9684..4f7e9b55070 100644 --- a/test/chunking-form/samples/dynamic-import-synthetic-exports-preserve-modules/_expected/es/main.js +++ b/test/chunking-form/samples/dynamic-import-synthetic-exports-preserve-modules/_expected/es/main.js @@ -1 +1 @@ -import('./lib.js').then(console.log); +import('./lib.js').then(function (n) { return n.l; }).then(console.log); diff --git a/test/chunking-form/samples/dynamic-import-synthetic-exports-preserve-modules/_expected/system/lib.js b/test/chunking-form/samples/dynamic-import-synthetic-exports-preserve-modules/_expected/system/lib.js index 61ae96a88fc..7c2d8b89681 100644 --- a/test/chunking-form/samples/dynamic-import-synthetic-exports-preserve-modules/_expected/system/lib.js +++ b/test/chunking-form/samples/dynamic-import-synthetic-exports-preserve-modules/_expected/system/lib.js @@ -1,11 +1,32 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { + + function _mergeNamespaces(n, m) { + m.forEach(function (e) { + e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) { + if (k !== 'default' && !(k in n)) { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + }); + return Object.freeze(n); + } const __moduleExports = { foo: 'bar' }; - var lib = exports('default', 'baz'); + var lib = exports("default", 'baz'); + + var lib$1 = /*#__PURE__*/_mergeNamespaces({ + __proto__: null, + default: lib + }, [__moduleExports]); + exports("l", lib$1); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/dynamic-import-synthetic-exports-preserve-modules/_expected/system/main.js b/test/chunking-form/samples/dynamic-import-synthetic-exports-preserve-modules/_expected/system/main.js index 61c5f4d5d93..9045026411f 100644 --- a/test/chunking-form/samples/dynamic-import-synthetic-exports-preserve-modules/_expected/system/main.js +++ b/test/chunking-form/samples/dynamic-import-synthetic-exports-preserve-modules/_expected/system/main.js @@ -1,10 +1,10 @@ -System.register([], function (exports, module) { +System.register([], (function (exports, module) { 'use strict'; return { - execute: function () { + execute: (function () { - module.import('./lib.js').then(console.log); + module.import('./lib.js').then(function (n) { return n.l; }).then(console.log); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/dynamic-import-tree-shaking-1/_config.js b/test/chunking-form/samples/dynamic-import-tree-shaking-1/_config.js index dcff9ec11b4..d57e7421e52 100644 --- a/test/chunking-form/samples/dynamic-import-tree-shaking-1/_config.js +++ b/test/chunking-form/samples/dynamic-import-tree-shaking-1/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'uses tree-shaking information to improve chunking', options: { input: { @@ -6,4 +6,4 @@ module.exports = { entryB: 'main2.js' } } -}; +}); diff --git a/test/chunking-form/samples/dynamic-import-tree-shaking-1/_expected/amd/entryA.js b/test/chunking-form/samples/dynamic-import-tree-shaking-1/_expected/amd/entryA.js index 0f3a098cf76..b3964ab30ca 100644 --- a/test/chunking-form/samples/dynamic-import-tree-shaking-1/_expected/amd/entryA.js +++ b/test/chunking-form/samples/dynamic-import-tree-shaking-1/_expected/amd/entryA.js @@ -1,4 +1,4 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; console.log('dep'); @@ -6,4 +6,4 @@ define(function () { 'use strict'; console.log('main1', value); -}); +})); diff --git a/test/chunking-form/samples/dynamic-import-tree-shaking-1/_expected/amd/entryB.js b/test/chunking-form/samples/dynamic-import-tree-shaking-1/_expected/amd/entryB.js index b58286ca58e..50131c97c96 100644 --- a/test/chunking-form/samples/dynamic-import-tree-shaking-1/_expected/amd/entryB.js +++ b/test/chunking-form/samples/dynamic-import-tree-shaking-1/_expected/amd/entryB.js @@ -1,5 +1,5 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; console.log('main2'); -}); +})); diff --git a/test/chunking-form/samples/dynamic-import-tree-shaking-1/_expected/system/entryA.js b/test/chunking-form/samples/dynamic-import-tree-shaking-1/_expected/system/entryA.js index 317d75ddb95..d4913331d7e 100644 --- a/test/chunking-form/samples/dynamic-import-tree-shaking-1/_expected/system/entryA.js +++ b/test/chunking-form/samples/dynamic-import-tree-shaking-1/_expected/system/entryA.js @@ -1,7 +1,7 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { console.log('dep'); @@ -9,6 +9,6 @@ System.register([], function () { console.log('main1', value); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/dynamic-import-tree-shaking-1/_expected/system/entryB.js b/test/chunking-form/samples/dynamic-import-tree-shaking-1/_expected/system/entryB.js index a272843f834..b91e108e596 100644 --- a/test/chunking-form/samples/dynamic-import-tree-shaking-1/_expected/system/entryB.js +++ b/test/chunking-form/samples/dynamic-import-tree-shaking-1/_expected/system/entryB.js @@ -1,10 +1,10 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { console.log('main2'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/dynamic-import-tree-shaking-2/_config.js b/test/chunking-form/samples/dynamic-import-tree-shaking-2/_config.js index 6d2783787e6..31e97827097 100644 --- a/test/chunking-form/samples/dynamic-import-tree-shaking-2/_config.js +++ b/test/chunking-form/samples/dynamic-import-tree-shaking-2/_config.js @@ -1,6 +1,6 @@ -module.exports = { +module.exports = defineTest({ description: 'does not expose exports of chunks which were used by tree-shaken dynamic imports', options: { input: ['main1.js', 'main2.js'] } -}; +}); diff --git a/test/chunking-form/samples/dynamic-import-tree-shaking-2/_expected/amd/main1.js b/test/chunking-form/samples/dynamic-import-tree-shaking-2/_expected/amd/main1.js index 34f4f818070..1bdac651f6d 100644 --- a/test/chunking-form/samples/dynamic-import-tree-shaking-2/_expected/amd/main1.js +++ b/test/chunking-form/samples/dynamic-import-tree-shaking-2/_expected/amd/main1.js @@ -1,5 +1,5 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; console.log('main1'); -}); +})); diff --git a/test/chunking-form/samples/dynamic-import-tree-shaking-2/_expected/amd/main2.js b/test/chunking-form/samples/dynamic-import-tree-shaking-2/_expected/amd/main2.js index 25c0aadce80..dca4556bb55 100644 --- a/test/chunking-form/samples/dynamic-import-tree-shaking-2/_expected/amd/main2.js +++ b/test/chunking-form/samples/dynamic-import-tree-shaking-2/_expected/amd/main2.js @@ -1,4 +1,4 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; console.log('dep'); const dep = 'dep'; @@ -7,4 +7,4 @@ define(function () { 'use strict'; console.log('main2', dep); -}); +})); diff --git a/test/chunking-form/samples/dynamic-import-tree-shaking-2/_expected/system/main1.js b/test/chunking-form/samples/dynamic-import-tree-shaking-2/_expected/system/main1.js index 13a22f40e14..fe1696f27e7 100644 --- a/test/chunking-form/samples/dynamic-import-tree-shaking-2/_expected/system/main1.js +++ b/test/chunking-form/samples/dynamic-import-tree-shaking-2/_expected/system/main1.js @@ -1,10 +1,10 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { console.log('main1'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/dynamic-import-tree-shaking-2/_expected/system/main2.js b/test/chunking-form/samples/dynamic-import-tree-shaking-2/_expected/system/main2.js index 85359651b12..5ee8ea1179e 100644 --- a/test/chunking-form/samples/dynamic-import-tree-shaking-2/_expected/system/main2.js +++ b/test/chunking-form/samples/dynamic-import-tree-shaking-2/_expected/system/main2.js @@ -1,7 +1,7 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { console.log('dep'); const dep = 'dep'; @@ -10,6 +10,6 @@ System.register([], function () { console.log('main2', dep); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/dynamic-import-with-namespace/_config.js b/test/chunking-form/samples/dynamic-import-with-namespace/_config.js new file mode 100644 index 00000000000..e2744888c32 --- /dev/null +++ b/test/chunking-form/samples/dynamic-import-with-namespace/_config.js @@ -0,0 +1,22 @@ +const fs = require('node:fs'); +const path = require('node:path'); + +const moduleContent = fs.readFileSync(path.resolve(__dirname, './module.js'), 'utf8'); +let count = 1; +module.exports = defineTest({ + description: 'The all cases of tree-shaking for dynamic import with namespace', + options: { + plugins: [ + { + resolveId(id) { + if (id.startsWith('./module')) return id + count++; + return this.resolve(id); + }, + load(id) { + if (id.endsWith('main.js')) return null; + return moduleContent; + } + } + ] + } +}); diff --git a/test/chunking-form/samples/dynamic-import-with-namespace/_expected/amd/generated-module1.js b/test/chunking-form/samples/dynamic-import-with-namespace/_expected/amd/generated-module1.js new file mode 100644 index 00000000000..0317e08cea9 --- /dev/null +++ b/test/chunking-form/samples/dynamic-import-with-namespace/_expected/amd/generated-module1.js @@ -0,0 +1,13 @@ +define(['exports'], (function (exports) { 'use strict'; + + const foo = () => {}; + const bar = () => {}; + const baz = () => {}; + const qux = () => {}; + + exports.bar = bar; + exports.baz = baz; + exports.foo = foo; + exports.qux = qux; + +})); diff --git a/test/chunking-form/samples/dynamic-import-with-namespace/_expected/amd/generated-module10.js b/test/chunking-form/samples/dynamic-import-with-namespace/_expected/amd/generated-module10.js new file mode 100644 index 00000000000..0317e08cea9 --- /dev/null +++ b/test/chunking-form/samples/dynamic-import-with-namespace/_expected/amd/generated-module10.js @@ -0,0 +1,13 @@ +define(['exports'], (function (exports) { 'use strict'; + + const foo = () => {}; + const bar = () => {}; + const baz = () => {}; + const qux = () => {}; + + exports.bar = bar; + exports.baz = baz; + exports.foo = foo; + exports.qux = qux; + +})); diff --git a/test/chunking-form/samples/dynamic-import-with-namespace/_expected/amd/generated-module2.js b/test/chunking-form/samples/dynamic-import-with-namespace/_expected/amd/generated-module2.js new file mode 100644 index 00000000000..0317e08cea9 --- /dev/null +++ b/test/chunking-form/samples/dynamic-import-with-namespace/_expected/amd/generated-module2.js @@ -0,0 +1,13 @@ +define(['exports'], (function (exports) { 'use strict'; + + const foo = () => {}; + const bar = () => {}; + const baz = () => {}; + const qux = () => {}; + + exports.bar = bar; + exports.baz = baz; + exports.foo = foo; + exports.qux = qux; + +})); diff --git a/test/chunking-form/samples/dynamic-import-with-namespace/_expected/amd/generated-module3.js b/test/chunking-form/samples/dynamic-import-with-namespace/_expected/amd/generated-module3.js new file mode 100644 index 00000000000..3123adef9b9 --- /dev/null +++ b/test/chunking-form/samples/dynamic-import-with-namespace/_expected/amd/generated-module3.js @@ -0,0 +1,7 @@ +define(['exports'], (function (exports) { 'use strict'; + + const foo = () => {}; + + exports.foo = foo; + +})); diff --git a/test/chunking-form/samples/dynamic-import-with-namespace/_expected/amd/generated-module4.js b/test/chunking-form/samples/dynamic-import-with-namespace/_expected/amd/generated-module4.js new file mode 100644 index 00000000000..0317e08cea9 --- /dev/null +++ b/test/chunking-form/samples/dynamic-import-with-namespace/_expected/amd/generated-module4.js @@ -0,0 +1,13 @@ +define(['exports'], (function (exports) { 'use strict'; + + const foo = () => {}; + const bar = () => {}; + const baz = () => {}; + const qux = () => {}; + + exports.bar = bar; + exports.baz = baz; + exports.foo = foo; + exports.qux = qux; + +})); diff --git a/test/chunking-form/samples/dynamic-import-with-namespace/_expected/amd/generated-module5.js b/test/chunking-form/samples/dynamic-import-with-namespace/_expected/amd/generated-module5.js new file mode 100644 index 00000000000..0317e08cea9 --- /dev/null +++ b/test/chunking-form/samples/dynamic-import-with-namespace/_expected/amd/generated-module5.js @@ -0,0 +1,13 @@ +define(['exports'], (function (exports) { 'use strict'; + + const foo = () => {}; + const bar = () => {}; + const baz = () => {}; + const qux = () => {}; + + exports.bar = bar; + exports.baz = baz; + exports.foo = foo; + exports.qux = qux; + +})); diff --git a/test/chunking-form/samples/dynamic-import-with-namespace/_expected/amd/generated-module6.js b/test/chunking-form/samples/dynamic-import-with-namespace/_expected/amd/generated-module6.js new file mode 100644 index 00000000000..3123adef9b9 --- /dev/null +++ b/test/chunking-form/samples/dynamic-import-with-namespace/_expected/amd/generated-module6.js @@ -0,0 +1,7 @@ +define(['exports'], (function (exports) { 'use strict'; + + const foo = () => {}; + + exports.foo = foo; + +})); diff --git a/test/chunking-form/samples/dynamic-import-with-namespace/_expected/amd/generated-module7.js b/test/chunking-form/samples/dynamic-import-with-namespace/_expected/amd/generated-module7.js new file mode 100644 index 00000000000..0317e08cea9 --- /dev/null +++ b/test/chunking-form/samples/dynamic-import-with-namespace/_expected/amd/generated-module7.js @@ -0,0 +1,13 @@ +define(['exports'], (function (exports) { 'use strict'; + + const foo = () => {}; + const bar = () => {}; + const baz = () => {}; + const qux = () => {}; + + exports.bar = bar; + exports.baz = baz; + exports.foo = foo; + exports.qux = qux; + +})); diff --git a/test/chunking-form/samples/dynamic-import-with-namespace/_expected/amd/generated-module8.js b/test/chunking-form/samples/dynamic-import-with-namespace/_expected/amd/generated-module8.js new file mode 100644 index 00000000000..0317e08cea9 --- /dev/null +++ b/test/chunking-form/samples/dynamic-import-with-namespace/_expected/amd/generated-module8.js @@ -0,0 +1,13 @@ +define(['exports'], (function (exports) { 'use strict'; + + const foo = () => {}; + const bar = () => {}; + const baz = () => {}; + const qux = () => {}; + + exports.bar = bar; + exports.baz = baz; + exports.foo = foo; + exports.qux = qux; + +})); diff --git a/test/chunking-form/samples/dynamic-import-with-namespace/_expected/amd/generated-module9.js b/test/chunking-form/samples/dynamic-import-with-namespace/_expected/amd/generated-module9.js new file mode 100644 index 00000000000..3123adef9b9 --- /dev/null +++ b/test/chunking-form/samples/dynamic-import-with-namespace/_expected/amd/generated-module9.js @@ -0,0 +1,7 @@ +define(['exports'], (function (exports) { 'use strict'; + + const foo = () => {}; + + exports.foo = foo; + +})); diff --git a/test/chunking-form/samples/dynamic-import-with-namespace/_expected/amd/main.js b/test/chunking-form/samples/dynamic-import-with-namespace/_expected/amd/main.js new file mode 100644 index 00000000000..012563bd0b4 --- /dev/null +++ b/test/chunking-form/samples/dynamic-import-with-namespace/_expected/amd/main.js @@ -0,0 +1,87 @@ +define(['require'], (function (require) { 'use strict'; + + (async () => { + const module = await new Promise(function (resolve, reject) { require(['./generated-module1'], resolve, reject); }); + module.foo(); + // disabled + module[global.unknown](); + module.baz(); + })(); + + (async () => { + const module = await new Promise(function (resolve, reject) { require(['./generated-module2'], resolve, reject); }); + const module1 = module; + module1.foo(); + })(); + + (async () => { + const module = await new Promise(function (resolve, reject) { require(['./generated-module3'], resolve, reject); }); + const { foo } = module; + foo(); + })(); + + (async () => { + const module = await new Promise(function (resolve, reject) { require(['./generated-module4'], resolve, reject); }); + // disabled + const { foo, ...rest } = module; + foo(); + rest.bar(); + })(); + + (async () => { + const module = await new Promise(function (resolve, reject) { require(['./generated-module5'], resolve, reject); }); + readFoo({ foo: () => {} }); + readFoo(module); + function readFoo(module1) { + module1.foo(); + } + function readBar(module2) { + module2.bar(); + } + readBar(module); + })(); + + (async () => { + const module = await new Promise(function (resolve, reject) { require(['./generated-module6'], resolve, reject); }); + function b({ foo }) { + foo(); + } + b(module); + })(); + + (async () => { + const module = await new Promise(function (resolve, reject) { require(['./generated-module7'], resolve, reject); }); + // disabled + function b({ foo, ...rest }) { + foo(); + assert.ok(rest); + } + b(module); + })(); + + (async () => { + const module = await new Promise(function (resolve, reject) { require(['./generated-module8'], resolve, reject); }); + // disabled + function b(o1, ...rest) { + assert.ok(rest); + } + b(o1, o2, module); + })(); + + (async () => { + const module = await new Promise(function (resolve, reject) { require(['./generated-module9'], resolve, reject); }); + // disabled + function b({ foo = 1 }) { + assert.ok(foo); + } + b(module); + })(); + + (async () => { + const module = await new Promise(function (resolve, reject) { require(['./generated-module10'], resolve, reject); }); + (module).bar(); + (global.unknown && module).foo(); + (global.unknown ? module : 'foo').baz(); + })(); + +})); diff --git a/test/chunking-form/samples/dynamic-import-with-namespace/_expected/cjs/generated-module1.js b/test/chunking-form/samples/dynamic-import-with-namespace/_expected/cjs/generated-module1.js new file mode 100644 index 00000000000..32b8c4cc05f --- /dev/null +++ b/test/chunking-form/samples/dynamic-import-with-namespace/_expected/cjs/generated-module1.js @@ -0,0 +1,11 @@ +'use strict'; + +const foo = () => {}; +const bar = () => {}; +const baz = () => {}; +const qux = () => {}; + +exports.bar = bar; +exports.baz = baz; +exports.foo = foo; +exports.qux = qux; diff --git a/test/chunking-form/samples/dynamic-import-with-namespace/_expected/cjs/generated-module10.js b/test/chunking-form/samples/dynamic-import-with-namespace/_expected/cjs/generated-module10.js new file mode 100644 index 00000000000..32b8c4cc05f --- /dev/null +++ b/test/chunking-form/samples/dynamic-import-with-namespace/_expected/cjs/generated-module10.js @@ -0,0 +1,11 @@ +'use strict'; + +const foo = () => {}; +const bar = () => {}; +const baz = () => {}; +const qux = () => {}; + +exports.bar = bar; +exports.baz = baz; +exports.foo = foo; +exports.qux = qux; diff --git a/test/chunking-form/samples/dynamic-import-with-namespace/_expected/cjs/generated-module2.js b/test/chunking-form/samples/dynamic-import-with-namespace/_expected/cjs/generated-module2.js new file mode 100644 index 00000000000..32b8c4cc05f --- /dev/null +++ b/test/chunking-form/samples/dynamic-import-with-namespace/_expected/cjs/generated-module2.js @@ -0,0 +1,11 @@ +'use strict'; + +const foo = () => {}; +const bar = () => {}; +const baz = () => {}; +const qux = () => {}; + +exports.bar = bar; +exports.baz = baz; +exports.foo = foo; +exports.qux = qux; diff --git a/test/chunking-form/samples/dynamic-import-with-namespace/_expected/cjs/generated-module3.js b/test/chunking-form/samples/dynamic-import-with-namespace/_expected/cjs/generated-module3.js new file mode 100644 index 00000000000..02ce8a98f32 --- /dev/null +++ b/test/chunking-form/samples/dynamic-import-with-namespace/_expected/cjs/generated-module3.js @@ -0,0 +1,5 @@ +'use strict'; + +const foo = () => {}; + +exports.foo = foo; diff --git a/test/chunking-form/samples/dynamic-import-with-namespace/_expected/cjs/generated-module4.js b/test/chunking-form/samples/dynamic-import-with-namespace/_expected/cjs/generated-module4.js new file mode 100644 index 00000000000..32b8c4cc05f --- /dev/null +++ b/test/chunking-form/samples/dynamic-import-with-namespace/_expected/cjs/generated-module4.js @@ -0,0 +1,11 @@ +'use strict'; + +const foo = () => {}; +const bar = () => {}; +const baz = () => {}; +const qux = () => {}; + +exports.bar = bar; +exports.baz = baz; +exports.foo = foo; +exports.qux = qux; diff --git a/test/chunking-form/samples/dynamic-import-with-namespace/_expected/cjs/generated-module5.js b/test/chunking-form/samples/dynamic-import-with-namespace/_expected/cjs/generated-module5.js new file mode 100644 index 00000000000..32b8c4cc05f --- /dev/null +++ b/test/chunking-form/samples/dynamic-import-with-namespace/_expected/cjs/generated-module5.js @@ -0,0 +1,11 @@ +'use strict'; + +const foo = () => {}; +const bar = () => {}; +const baz = () => {}; +const qux = () => {}; + +exports.bar = bar; +exports.baz = baz; +exports.foo = foo; +exports.qux = qux; diff --git a/test/chunking-form/samples/dynamic-import-with-namespace/_expected/cjs/generated-module6.js b/test/chunking-form/samples/dynamic-import-with-namespace/_expected/cjs/generated-module6.js new file mode 100644 index 00000000000..02ce8a98f32 --- /dev/null +++ b/test/chunking-form/samples/dynamic-import-with-namespace/_expected/cjs/generated-module6.js @@ -0,0 +1,5 @@ +'use strict'; + +const foo = () => {}; + +exports.foo = foo; diff --git a/test/chunking-form/samples/dynamic-import-with-namespace/_expected/cjs/generated-module7.js b/test/chunking-form/samples/dynamic-import-with-namespace/_expected/cjs/generated-module7.js new file mode 100644 index 00000000000..32b8c4cc05f --- /dev/null +++ b/test/chunking-form/samples/dynamic-import-with-namespace/_expected/cjs/generated-module7.js @@ -0,0 +1,11 @@ +'use strict'; + +const foo = () => {}; +const bar = () => {}; +const baz = () => {}; +const qux = () => {}; + +exports.bar = bar; +exports.baz = baz; +exports.foo = foo; +exports.qux = qux; diff --git a/test/chunking-form/samples/dynamic-import-with-namespace/_expected/cjs/generated-module8.js b/test/chunking-form/samples/dynamic-import-with-namespace/_expected/cjs/generated-module8.js new file mode 100644 index 00000000000..32b8c4cc05f --- /dev/null +++ b/test/chunking-form/samples/dynamic-import-with-namespace/_expected/cjs/generated-module8.js @@ -0,0 +1,11 @@ +'use strict'; + +const foo = () => {}; +const bar = () => {}; +const baz = () => {}; +const qux = () => {}; + +exports.bar = bar; +exports.baz = baz; +exports.foo = foo; +exports.qux = qux; diff --git a/test/chunking-form/samples/dynamic-import-with-namespace/_expected/cjs/generated-module9.js b/test/chunking-form/samples/dynamic-import-with-namespace/_expected/cjs/generated-module9.js new file mode 100644 index 00000000000..02ce8a98f32 --- /dev/null +++ b/test/chunking-form/samples/dynamic-import-with-namespace/_expected/cjs/generated-module9.js @@ -0,0 +1,5 @@ +'use strict'; + +const foo = () => {}; + +exports.foo = foo; diff --git a/test/chunking-form/samples/dynamic-import-with-namespace/_expected/cjs/main.js b/test/chunking-form/samples/dynamic-import-with-namespace/_expected/cjs/main.js new file mode 100644 index 00000000000..9afab559262 --- /dev/null +++ b/test/chunking-form/samples/dynamic-import-with-namespace/_expected/cjs/main.js @@ -0,0 +1,85 @@ +'use strict'; + +(async () => { + const module = await Promise.resolve().then(function () { return require('./generated-module1.js'); }); + module.foo(); + // disabled + module[global.unknown](); + module.baz(); +})(); + +(async () => { + const module = await Promise.resolve().then(function () { return require('./generated-module2.js'); }); + const module1 = module; + module1.foo(); +})(); + +(async () => { + const module = await Promise.resolve().then(function () { return require('./generated-module3.js'); }); + const { foo } = module; + foo(); +})(); + +(async () => { + const module = await Promise.resolve().then(function () { return require('./generated-module4.js'); }); + // disabled + const { foo, ...rest } = module; + foo(); + rest.bar(); +})(); + +(async () => { + const module = await Promise.resolve().then(function () { return require('./generated-module5.js'); }); + readFoo({ foo: () => {} }); + readFoo(module); + function readFoo(module1) { + module1.foo(); + } + function readBar(module2) { + module2.bar(); + } + readBar(module); +})(); + +(async () => { + const module = await Promise.resolve().then(function () { return require('./generated-module6.js'); }); + function b({ foo }) { + foo(); + } + b(module); +})(); + +(async () => { + const module = await Promise.resolve().then(function () { return require('./generated-module7.js'); }); + // disabled + function b({ foo, ...rest }) { + foo(); + assert.ok(rest); + } + b(module); +})(); + +(async () => { + const module = await Promise.resolve().then(function () { return require('./generated-module8.js'); }); + // disabled + function b(o1, ...rest) { + assert.ok(rest); + } + b(o1, o2, module); +})(); + +(async () => { + const module = await Promise.resolve().then(function () { return require('./generated-module9.js'); }); + // disabled + function b({ foo = 1 }) { + assert.ok(foo); + } + b(module); +})(); + +(async () => { + const module = await Promise.resolve().then(function () { return require('./generated-module10.js'); }); + (module).bar(); + (global.unknown && module).foo(); + (global.unknown ? module : 'foo').baz(); +})(); diff --git a/test/chunking-form/samples/dynamic-import-with-namespace/_expected/es/generated-module1.js b/test/chunking-form/samples/dynamic-import-with-namespace/_expected/es/generated-module1.js new file mode 100644 index 00000000000..79e04081470 --- /dev/null +++ b/test/chunking-form/samples/dynamic-import-with-namespace/_expected/es/generated-module1.js @@ -0,0 +1,6 @@ +const foo = () => {}; +const bar = () => {}; +const baz = () => {}; +const qux = () => {}; + +export { bar, baz, foo, qux }; diff --git a/test/chunking-form/samples/dynamic-import-with-namespace/_expected/es/generated-module10.js b/test/chunking-form/samples/dynamic-import-with-namespace/_expected/es/generated-module10.js new file mode 100644 index 00000000000..79e04081470 --- /dev/null +++ b/test/chunking-form/samples/dynamic-import-with-namespace/_expected/es/generated-module10.js @@ -0,0 +1,6 @@ +const foo = () => {}; +const bar = () => {}; +const baz = () => {}; +const qux = () => {}; + +export { bar, baz, foo, qux }; diff --git a/test/chunking-form/samples/dynamic-import-with-namespace/_expected/es/generated-module2.js b/test/chunking-form/samples/dynamic-import-with-namespace/_expected/es/generated-module2.js new file mode 100644 index 00000000000..79e04081470 --- /dev/null +++ b/test/chunking-form/samples/dynamic-import-with-namespace/_expected/es/generated-module2.js @@ -0,0 +1,6 @@ +const foo = () => {}; +const bar = () => {}; +const baz = () => {}; +const qux = () => {}; + +export { bar, baz, foo, qux }; diff --git a/test/chunking-form/samples/dynamic-import-with-namespace/_expected/es/generated-module3.js b/test/chunking-form/samples/dynamic-import-with-namespace/_expected/es/generated-module3.js new file mode 100644 index 00000000000..4ac31b619b3 --- /dev/null +++ b/test/chunking-form/samples/dynamic-import-with-namespace/_expected/es/generated-module3.js @@ -0,0 +1,3 @@ +const foo = () => {}; + +export { foo }; diff --git a/test/chunking-form/samples/dynamic-import-with-namespace/_expected/es/generated-module4.js b/test/chunking-form/samples/dynamic-import-with-namespace/_expected/es/generated-module4.js new file mode 100644 index 00000000000..79e04081470 --- /dev/null +++ b/test/chunking-form/samples/dynamic-import-with-namespace/_expected/es/generated-module4.js @@ -0,0 +1,6 @@ +const foo = () => {}; +const bar = () => {}; +const baz = () => {}; +const qux = () => {}; + +export { bar, baz, foo, qux }; diff --git a/test/chunking-form/samples/dynamic-import-with-namespace/_expected/es/generated-module5.js b/test/chunking-form/samples/dynamic-import-with-namespace/_expected/es/generated-module5.js new file mode 100644 index 00000000000..79e04081470 --- /dev/null +++ b/test/chunking-form/samples/dynamic-import-with-namespace/_expected/es/generated-module5.js @@ -0,0 +1,6 @@ +const foo = () => {}; +const bar = () => {}; +const baz = () => {}; +const qux = () => {}; + +export { bar, baz, foo, qux }; diff --git a/test/chunking-form/samples/dynamic-import-with-namespace/_expected/es/generated-module6.js b/test/chunking-form/samples/dynamic-import-with-namespace/_expected/es/generated-module6.js new file mode 100644 index 00000000000..4ac31b619b3 --- /dev/null +++ b/test/chunking-form/samples/dynamic-import-with-namespace/_expected/es/generated-module6.js @@ -0,0 +1,3 @@ +const foo = () => {}; + +export { foo }; diff --git a/test/chunking-form/samples/dynamic-import-with-namespace/_expected/es/generated-module7.js b/test/chunking-form/samples/dynamic-import-with-namespace/_expected/es/generated-module7.js new file mode 100644 index 00000000000..79e04081470 --- /dev/null +++ b/test/chunking-form/samples/dynamic-import-with-namespace/_expected/es/generated-module7.js @@ -0,0 +1,6 @@ +const foo = () => {}; +const bar = () => {}; +const baz = () => {}; +const qux = () => {}; + +export { bar, baz, foo, qux }; diff --git a/test/chunking-form/samples/dynamic-import-with-namespace/_expected/es/generated-module8.js b/test/chunking-form/samples/dynamic-import-with-namespace/_expected/es/generated-module8.js new file mode 100644 index 00000000000..79e04081470 --- /dev/null +++ b/test/chunking-form/samples/dynamic-import-with-namespace/_expected/es/generated-module8.js @@ -0,0 +1,6 @@ +const foo = () => {}; +const bar = () => {}; +const baz = () => {}; +const qux = () => {}; + +export { bar, baz, foo, qux }; diff --git a/test/chunking-form/samples/dynamic-import-with-namespace/_expected/es/generated-module9.js b/test/chunking-form/samples/dynamic-import-with-namespace/_expected/es/generated-module9.js new file mode 100644 index 00000000000..4ac31b619b3 --- /dev/null +++ b/test/chunking-form/samples/dynamic-import-with-namespace/_expected/es/generated-module9.js @@ -0,0 +1,3 @@ +const foo = () => {}; + +export { foo }; diff --git a/test/chunking-form/samples/dynamic-import-with-namespace/_expected/es/main.js b/test/chunking-form/samples/dynamic-import-with-namespace/_expected/es/main.js new file mode 100644 index 00000000000..9d78ab9ac03 --- /dev/null +++ b/test/chunking-form/samples/dynamic-import-with-namespace/_expected/es/main.js @@ -0,0 +1,83 @@ +(async () => { + const module = await import('./generated-module1.js'); + module.foo(); + // disabled + module[global.unknown](); + module.baz(); +})(); + +(async () => { + const module = await import('./generated-module2.js'); + const module1 = module; + module1.foo(); +})(); + +(async () => { + const module = await import('./generated-module3.js'); + const { foo } = module; + foo(); +})(); + +(async () => { + const module = await import('./generated-module4.js'); + // disabled + const { foo, ...rest } = module; + foo(); + rest.bar(); +})(); + +(async () => { + const module = await import('./generated-module5.js'); + readFoo({ foo: () => {} }); + readFoo(module); + function readFoo(module1) { + module1.foo(); + } + function readBar(module2) { + module2.bar(); + } + readBar(module); +})(); + +(async () => { + const module = await import('./generated-module6.js'); + function b({ foo }) { + foo(); + } + b(module); +})(); + +(async () => { + const module = await import('./generated-module7.js'); + // disabled + function b({ foo, ...rest }) { + foo(); + assert.ok(rest); + } + b(module); +})(); + +(async () => { + const module = await import('./generated-module8.js'); + // disabled + function b(o1, ...rest) { + assert.ok(rest); + } + b(o1, o2, module); +})(); + +(async () => { + const module = await import('./generated-module9.js'); + // disabled + function b({ foo = 1 }) { + assert.ok(foo); + } + b(module); +})(); + +(async () => { + const module = await import('./generated-module10.js'); + (module).bar(); + (global.unknown && module).foo(); + (global.unknown ? module : 'foo').baz(); +})(); diff --git a/test/chunking-form/samples/dynamic-import-with-namespace/_expected/system/generated-module1.js b/test/chunking-form/samples/dynamic-import-with-namespace/_expected/system/generated-module1.js new file mode 100644 index 00000000000..e683d313eb5 --- /dev/null +++ b/test/chunking-form/samples/dynamic-import-with-namespace/_expected/system/generated-module1.js @@ -0,0 +1,13 @@ +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + + const foo = exports("foo", () => {}); + const bar = exports("bar", () => {}); + const baz = exports("baz", () => {}); + const qux = exports("qux", () => {}); + + }) + }; +})); diff --git a/test/chunking-form/samples/dynamic-import-with-namespace/_expected/system/generated-module10.js b/test/chunking-form/samples/dynamic-import-with-namespace/_expected/system/generated-module10.js new file mode 100644 index 00000000000..e683d313eb5 --- /dev/null +++ b/test/chunking-form/samples/dynamic-import-with-namespace/_expected/system/generated-module10.js @@ -0,0 +1,13 @@ +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + + const foo = exports("foo", () => {}); + const bar = exports("bar", () => {}); + const baz = exports("baz", () => {}); + const qux = exports("qux", () => {}); + + }) + }; +})); diff --git a/test/chunking-form/samples/dynamic-import-with-namespace/_expected/system/generated-module2.js b/test/chunking-form/samples/dynamic-import-with-namespace/_expected/system/generated-module2.js new file mode 100644 index 00000000000..e683d313eb5 --- /dev/null +++ b/test/chunking-form/samples/dynamic-import-with-namespace/_expected/system/generated-module2.js @@ -0,0 +1,13 @@ +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + + const foo = exports("foo", () => {}); + const bar = exports("bar", () => {}); + const baz = exports("baz", () => {}); + const qux = exports("qux", () => {}); + + }) + }; +})); diff --git a/test/chunking-form/samples/dynamic-import-with-namespace/_expected/system/generated-module3.js b/test/chunking-form/samples/dynamic-import-with-namespace/_expected/system/generated-module3.js new file mode 100644 index 00000000000..72f26099c8c --- /dev/null +++ b/test/chunking-form/samples/dynamic-import-with-namespace/_expected/system/generated-module3.js @@ -0,0 +1,10 @@ +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + + const foo = exports("foo", () => {}); + + }) + }; +})); diff --git a/test/chunking-form/samples/dynamic-import-with-namespace/_expected/system/generated-module4.js b/test/chunking-form/samples/dynamic-import-with-namespace/_expected/system/generated-module4.js new file mode 100644 index 00000000000..e683d313eb5 --- /dev/null +++ b/test/chunking-form/samples/dynamic-import-with-namespace/_expected/system/generated-module4.js @@ -0,0 +1,13 @@ +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + + const foo = exports("foo", () => {}); + const bar = exports("bar", () => {}); + const baz = exports("baz", () => {}); + const qux = exports("qux", () => {}); + + }) + }; +})); diff --git a/test/chunking-form/samples/dynamic-import-with-namespace/_expected/system/generated-module5.js b/test/chunking-form/samples/dynamic-import-with-namespace/_expected/system/generated-module5.js new file mode 100644 index 00000000000..e683d313eb5 --- /dev/null +++ b/test/chunking-form/samples/dynamic-import-with-namespace/_expected/system/generated-module5.js @@ -0,0 +1,13 @@ +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + + const foo = exports("foo", () => {}); + const bar = exports("bar", () => {}); + const baz = exports("baz", () => {}); + const qux = exports("qux", () => {}); + + }) + }; +})); diff --git a/test/chunking-form/samples/dynamic-import-with-namespace/_expected/system/generated-module6.js b/test/chunking-form/samples/dynamic-import-with-namespace/_expected/system/generated-module6.js new file mode 100644 index 00000000000..72f26099c8c --- /dev/null +++ b/test/chunking-form/samples/dynamic-import-with-namespace/_expected/system/generated-module6.js @@ -0,0 +1,10 @@ +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + + const foo = exports("foo", () => {}); + + }) + }; +})); diff --git a/test/chunking-form/samples/dynamic-import-with-namespace/_expected/system/generated-module7.js b/test/chunking-form/samples/dynamic-import-with-namespace/_expected/system/generated-module7.js new file mode 100644 index 00000000000..e683d313eb5 --- /dev/null +++ b/test/chunking-form/samples/dynamic-import-with-namespace/_expected/system/generated-module7.js @@ -0,0 +1,13 @@ +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + + const foo = exports("foo", () => {}); + const bar = exports("bar", () => {}); + const baz = exports("baz", () => {}); + const qux = exports("qux", () => {}); + + }) + }; +})); diff --git a/test/chunking-form/samples/dynamic-import-with-namespace/_expected/system/generated-module8.js b/test/chunking-form/samples/dynamic-import-with-namespace/_expected/system/generated-module8.js new file mode 100644 index 00000000000..e683d313eb5 --- /dev/null +++ b/test/chunking-form/samples/dynamic-import-with-namespace/_expected/system/generated-module8.js @@ -0,0 +1,13 @@ +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + + const foo = exports("foo", () => {}); + const bar = exports("bar", () => {}); + const baz = exports("baz", () => {}); + const qux = exports("qux", () => {}); + + }) + }; +})); diff --git a/test/chunking-form/samples/dynamic-import-with-namespace/_expected/system/generated-module9.js b/test/chunking-form/samples/dynamic-import-with-namespace/_expected/system/generated-module9.js new file mode 100644 index 00000000000..72f26099c8c --- /dev/null +++ b/test/chunking-form/samples/dynamic-import-with-namespace/_expected/system/generated-module9.js @@ -0,0 +1,10 @@ +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + + const foo = exports("foo", () => {}); + + }) + }; +})); diff --git a/test/chunking-form/samples/dynamic-import-with-namespace/_expected/system/main.js b/test/chunking-form/samples/dynamic-import-with-namespace/_expected/system/main.js new file mode 100644 index 00000000000..e5eda4d493c --- /dev/null +++ b/test/chunking-form/samples/dynamic-import-with-namespace/_expected/system/main.js @@ -0,0 +1,92 @@ +System.register([], (function (exports, module) { + 'use strict'; + return { + execute: (function () { + + (async () => { + const module$1 = await module.import('./generated-module1.js'); + module$1.foo(); + // disabled + module$1[global.unknown](); + module$1.baz(); + })(); + + (async () => { + const module$1 = await module.import('./generated-module2.js'); + const module1 = module$1; + module1.foo(); + })(); + + (async () => { + const module$1 = await module.import('./generated-module3.js'); + const { foo } = module$1; + foo(); + })(); + + (async () => { + const module$1 = await module.import('./generated-module4.js'); + // disabled + const { foo, ...rest } = module$1; + foo(); + rest.bar(); + })(); + + (async () => { + const module$1 = await module.import('./generated-module5.js'); + readFoo({ foo: () => {} }); + readFoo(module$1); + function readFoo(module1) { + module1.foo(); + } + function readBar(module2) { + module2.bar(); + } + readBar(module$1); + })(); + + (async () => { + const module$1 = await module.import('./generated-module6.js'); + function b({ foo }) { + foo(); + } + b(module$1); + })(); + + (async () => { + const module$1 = await module.import('./generated-module7.js'); + // disabled + function b({ foo, ...rest }) { + foo(); + assert.ok(rest); + } + b(module$1); + })(); + + (async () => { + const module$1 = await module.import('./generated-module8.js'); + // disabled + function b(o1, ...rest) { + assert.ok(rest); + } + b(o1, o2, module$1); + })(); + + (async () => { + const module$1 = await module.import('./generated-module9.js'); + // disabled + function b({ foo = 1 }) { + assert.ok(foo); + } + b(module$1); + })(); + + (async () => { + const module$1 = await module.import('./generated-module10.js'); + (module$1).bar(); + (global.unknown && module$1).foo(); + (global.unknown ? module$1 : 'foo').baz(); + })(); + + }) + }; +})); diff --git a/test/chunking-form/samples/dynamic-import-with-namespace/main.js b/test/chunking-form/samples/dynamic-import-with-namespace/main.js new file mode 100644 index 00000000000..d7ad776d7a9 --- /dev/null +++ b/test/chunking-form/samples/dynamic-import-with-namespace/main.js @@ -0,0 +1,83 @@ +(async () => { + const module = await import('./module'); + module.foo(); + // disabled + module[global.unknown](); + module.baz(); +})(); + +(async () => { + const module = await import('./module'); + const module1 = module; + module1.foo(); +})(); + +(async () => { + const module = await import('./module'); + const { foo } = module; + foo(); +})(); + +(async () => { + const module = await import('./module'); + // disabled + const { foo, ...rest } = module; + foo(); + rest.bar(); +})(); + +(async () => { + const module = await import('./module'); + readFoo({ foo: () => {} }); + readFoo(module); + function readFoo(module1) { + module1.foo(); + } + function readBar(module2) { + module2.bar(); + } + readBar(module); +})(); + +(async () => { + const module = await import('./module'); + function b({ foo }) { + foo(); + } + b(module); +})(); + +(async () => { + const module = await import('./module'); + // disabled + function b({ foo, ...rest }) { + foo(); + assert.ok(rest); + } + b(module); +})(); + +(async () => { + const module = await import('./module'); + // disabled + function b(o1, ...rest) { + assert.ok(rest); + } + b(o1, o2, module); +})(); + +(async () => { + const module = await import('./module'); + // disabled + function b({ foo = 1 }) { + assert.ok(foo); + } + b(module); +})(); + +(async () => { + const module = await import('./module'); + ('foo', module).bar(); + (global.unknown && module).foo(); + (global.unknown ? module : 'foo').baz(); +})(); diff --git a/test/chunking-form/samples/dynamic-import-with-namespace/module.js b/test/chunking-form/samples/dynamic-import-with-namespace/module.js new file mode 100644 index 00000000000..711d5691650 --- /dev/null +++ b/test/chunking-form/samples/dynamic-import-with-namespace/module.js @@ -0,0 +1,4 @@ +export const foo = () => {}; +export const bar = () => {}; +export const baz = () => {}; +export const qux = () => {}; diff --git a/test/chunking-form/samples/dynamic-import/_config.js b/test/chunking-form/samples/dynamic-import/_config.js index c62aae20125..df578ea35a6 100644 --- a/test/chunking-form/samples/dynamic-import/_config.js +++ b/test/chunking-form/samples/dynamic-import/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'handles dynamic imports with a shared dependency', options: { input: ['main'], @@ -11,4 +11,4 @@ module.exports = { return exports.promise; } } -}; +}); diff --git a/test/chunking-form/samples/dynamic-import/_expected/amd/chunks/main.js b/test/chunking-form/samples/dynamic-import/_expected/amd/chunks/main.js index ea3b3d8d9f1..5fec6b82c7b 100644 --- a/test/chunking-form/samples/dynamic-import/_expected/amd/chunks/main.js +++ b/test/chunking-form/samples/dynamic-import/_expected/amd/chunks/main.js @@ -1,14 +1,14 @@ -define(['require', 'exports'], function (require, exports) { 'use strict'; +define(['require', 'exports'], (function (require, exports) { 'use strict'; const sharedValue = 'shared'; assert.equal(sharedValue, 'shared'); - const promise = new Promise(function (resolve, reject) { require(['./other'], resolve, reject) }).then(result => - assert.deepEqual(result, { value: 'shared' }) + const promise = new Promise(function (resolve, reject) { require(['./other'], resolve, reject); }).then(result => + assert.deepEqual(result, { value: 'shared', extra: 'extra' }) ); exports.promise = promise; exports.sharedValue = sharedValue; -}); +})); diff --git a/test/chunking-form/samples/dynamic-import/_expected/amd/chunks/other.js b/test/chunking-form/samples/dynamic-import/_expected/amd/chunks/other.js index c5536e87042..5f776f29d47 100644 --- a/test/chunking-form/samples/dynamic-import/_expected/amd/chunks/other.js +++ b/test/chunking-form/samples/dynamic-import/_expected/amd/chunks/other.js @@ -1,7 +1,8 @@ -define(['exports', './main'], function (exports, main) { 'use strict'; - +define(['exports', './main'], (function (exports, main) { 'use strict'; + const extra = 'extra'; exports.value = main.sharedValue; + exports.extra = extra; -}); +})); diff --git a/test/chunking-form/samples/dynamic-import/_expected/amd/main.js b/test/chunking-form/samples/dynamic-import/_expected/amd/main.js index d7fa3f63973..cfede414f1c 100644 --- a/test/chunking-form/samples/dynamic-import/_expected/amd/main.js +++ b/test/chunking-form/samples/dynamic-import/_expected/amd/main.js @@ -1,9 +1,7 @@ -define(['exports', './chunks/main'], function (exports, main) { 'use strict'; +define(['exports', './chunks/main'], (function (exports, main) { 'use strict'; exports.promise = main.promise; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/dynamic-import/_expected/cjs/chunks/main.js b/test/chunking-form/samples/dynamic-import/_expected/cjs/chunks/main.js index 4158fbcb7de..673ff4e7b66 100644 --- a/test/chunking-form/samples/dynamic-import/_expected/cjs/chunks/main.js +++ b/test/chunking-form/samples/dynamic-import/_expected/cjs/chunks/main.js @@ -5,7 +5,7 @@ const sharedValue = 'shared'; assert.equal(sharedValue, 'shared'); const promise = Promise.resolve().then(function () { return require('./other.js'); }).then(result => - assert.deepEqual(result, { value: 'shared' }) + assert.deepEqual(result, { value: 'shared', extra: 'extra' }) ); exports.promise = promise; diff --git a/test/chunking-form/samples/dynamic-import/_expected/cjs/chunks/other.js b/test/chunking-form/samples/dynamic-import/_expected/cjs/chunks/other.js index 5e903eb86e5..b00d3623127 100644 --- a/test/chunking-form/samples/dynamic-import/_expected/cjs/chunks/other.js +++ b/test/chunking-form/samples/dynamic-import/_expected/cjs/chunks/other.js @@ -2,6 +2,7 @@ var main = require('./main.js'); - +const extra = 'extra'; exports.value = main.sharedValue; +exports.extra = extra; diff --git a/test/chunking-form/samples/dynamic-import/_expected/cjs/main.js b/test/chunking-form/samples/dynamic-import/_expected/cjs/main.js index 4f5cbe2bc72..382cd3044e4 100644 --- a/test/chunking-form/samples/dynamic-import/_expected/cjs/main.js +++ b/test/chunking-form/samples/dynamic-import/_expected/cjs/main.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - var main = require('./chunks/main.js'); diff --git a/test/chunking-form/samples/dynamic-import/_expected/es/chunks/main.js b/test/chunking-form/samples/dynamic-import/_expected/es/chunks/main.js index 1d6d7916ddf..da645a11cf1 100644 --- a/test/chunking-form/samples/dynamic-import/_expected/es/chunks/main.js +++ b/test/chunking-form/samples/dynamic-import/_expected/es/chunks/main.js @@ -3,7 +3,7 @@ const sharedValue = 'shared'; assert.equal(sharedValue, 'shared'); const promise = import('./other.js').then(result => - assert.deepEqual(result, { value: 'shared' }) + assert.deepEqual(result, { value: 'shared', extra: 'extra' }) ); export { promise as p, sharedValue as s }; diff --git a/test/chunking-form/samples/dynamic-import/_expected/es/chunks/other.js b/test/chunking-form/samples/dynamic-import/_expected/es/chunks/other.js index 5750af52a03..ae43d1fb64b 100644 --- a/test/chunking-form/samples/dynamic-import/_expected/es/chunks/other.js +++ b/test/chunking-form/samples/dynamic-import/_expected/es/chunks/other.js @@ -1 +1,5 @@ export { s as value } from './main.js'; + +const extra = 'extra'; + +export { extra }; diff --git a/test/chunking-form/samples/dynamic-import/_expected/system/chunks/main.js b/test/chunking-form/samples/dynamic-import/_expected/system/chunks/main.js index 5a2e6f0e106..b63d4b92182 100644 --- a/test/chunking-form/samples/dynamic-import/_expected/system/chunks/main.js +++ b/test/chunking-form/samples/dynamic-import/_expected/system/chunks/main.js @@ -1,16 +1,16 @@ -System.register([], function (exports, module) { +System.register([], (function (exports, module) { 'use strict'; return { - execute: function () { + execute: (function () { - const sharedValue = exports('s', 'shared'); + const sharedValue = exports("s", 'shared'); assert.equal(sharedValue, 'shared'); - const promise = exports('p', module.import('./other.js').then(result => - assert.deepEqual(result, { value: 'shared' }) + const promise = exports("p", module.import('./other.js').then(result => + assert.deepEqual(result, { value: 'shared', extra: 'extra' }) )); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/dynamic-import/_expected/system/chunks/other.js b/test/chunking-form/samples/dynamic-import/_expected/system/chunks/other.js index 51028be8b37..0deffdfedfa 100644 --- a/test/chunking-form/samples/dynamic-import/_expected/system/chunks/other.js +++ b/test/chunking-form/samples/dynamic-import/_expected/system/chunks/other.js @@ -1,13 +1,13 @@ -System.register(['./main.js'], function (exports) { +System.register(['./main.js'], (function (exports) { 'use strict'; return { setters: [function (module) { - exports('value', module.s); + exports("value", module.s); }], - execute: function () { + execute: (function () { + const extra = exports("extra", 'extra'); - - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/dynamic-import/_expected/system/main.js b/test/chunking-form/samples/dynamic-import/_expected/system/main.js index bbae28dc22e..141a96c6c37 100644 --- a/test/chunking-form/samples/dynamic-import/_expected/system/main.js +++ b/test/chunking-form/samples/dynamic-import/_expected/system/main.js @@ -1,13 +1,13 @@ -System.register(['./chunks/main.js'], function (exports) { +System.register(['./chunks/main.js'], (function (exports) { 'use strict'; return { setters: [function (module) { - exports('promise', module.p); + exports("promise", module.p); }], - execute: function () { + execute: (function () { - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/dynamic-import/main.js b/test/chunking-form/samples/dynamic-import/main.js index cf97619c11b..08e23958d57 100644 --- a/test/chunking-form/samples/dynamic-import/main.js +++ b/test/chunking-form/samples/dynamic-import/main.js @@ -1,6 +1,7 @@ -import { sharedValue } from './shared'; +import { sharedValue } from "./shared"; + assert.equal(sharedValue, 'shared'); export const promise = import('./other').then(result => - assert.deepEqual(result, { value: 'shared' }) + assert.deepEqual(result, { value: 'shared', extra: 'extra' }) ); diff --git a/test/chunking-form/samples/dynamic-import/other.js b/test/chunking-form/samples/dynamic-import/other.js index e662538f8b4..b1cdc9b80af 100644 --- a/test/chunking-form/samples/dynamic-import/other.js +++ b/test/chunking-form/samples/dynamic-import/other.js @@ -1 +1,2 @@ export { sharedValue as value } from './shared'; +export const extra = 'extra'; diff --git a/test/chunking-form/samples/dynamically-import-facaded-entry/_config.js b/test/chunking-form/samples/dynamically-import-facaded-entry/_config.js index 0807ed35e5e..08ba9ac6fc0 100644 --- a/test/chunking-form/samples/dynamically-import-facaded-entry/_config.js +++ b/test/chunking-form/samples/dynamically-import-facaded-entry/_config.js @@ -1,7 +1,7 @@ -module.exports = { +module.exports = defineTest({ description: 'uses existing entry facades for dynamic imports if present', options: { input: ['main.js', 'importer.js'], preserveEntrySignatures: 'strict' } -}; +}); diff --git a/test/chunking-form/samples/dynamically-import-facaded-entry/_expected/amd/generated-dynamic.js b/test/chunking-form/samples/dynamically-import-facaded-entry/_expected/amd/generated-dynamic.js index d8de66484e5..71af3bb73dc 100644 --- a/test/chunking-form/samples/dynamically-import-facaded-entry/_expected/amd/generated-dynamic.js +++ b/test/chunking-form/samples/dynamically-import-facaded-entry/_expected/amd/generated-dynamic.js @@ -1,5 +1,5 @@ -define(['./generated-main'], function (main) { 'use strict'; +define(['./generated-main'], (function (main) { 'use strict'; console.log('dynamic', main.value); -}); +})); diff --git a/test/chunking-form/samples/dynamically-import-facaded-entry/_expected/amd/generated-main.js b/test/chunking-form/samples/dynamically-import-facaded-entry/_expected/amd/generated-main.js index 4a80598db31..7d07295fb6a 100644 --- a/test/chunking-form/samples/dynamically-import-facaded-entry/_expected/amd/generated-main.js +++ b/test/chunking-form/samples/dynamically-import-facaded-entry/_expected/amd/generated-main.js @@ -1,10 +1,10 @@ -define(['require', 'exports'], function (require, exports) { 'use strict'; +define(['require', 'exports'], (function (require, exports) { 'use strict'; var value = 42; - const promise = new Promise(function (resolve, reject) { require(['./generated-dynamic'], resolve, reject) }).then(result => console.log('main', result, value)); + const promise = new Promise(function (resolve, reject) { require(['./generated-dynamic'], resolve, reject); }).then(result => console.log('main', result, value)); exports.promise = promise; exports.value = value; -}); +})); diff --git a/test/chunking-form/samples/dynamically-import-facaded-entry/_expected/amd/importer.js b/test/chunking-form/samples/dynamically-import-facaded-entry/_expected/amd/importer.js index 3ed7fdddfe1..a30e0ce2437 100644 --- a/test/chunking-form/samples/dynamically-import-facaded-entry/_expected/amd/importer.js +++ b/test/chunking-form/samples/dynamically-import-facaded-entry/_expected/amd/importer.js @@ -1,5 +1,5 @@ -define(['require'], function (require) { 'use strict'; +define(['require'], (function (require) { 'use strict'; - new Promise(function (resolve, reject) { require(['./main'], resolve, reject) }).then(result => console.log('importer', result)); + new Promise(function (resolve, reject) { require(['./main'], resolve, reject); }).then(result => console.log('importer', result)); -}); +})); diff --git a/test/chunking-form/samples/dynamically-import-facaded-entry/_expected/amd/main.js b/test/chunking-form/samples/dynamically-import-facaded-entry/_expected/amd/main.js index 25b18934794..def925166fc 100644 --- a/test/chunking-form/samples/dynamically-import-facaded-entry/_expected/amd/main.js +++ b/test/chunking-form/samples/dynamically-import-facaded-entry/_expected/amd/main.js @@ -1,9 +1,7 @@ -define(['exports', './generated-main'], function (exports, main) { 'use strict'; +define(['exports', './generated-main'], (function (exports, main) { 'use strict'; exports.promise = main.promise; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/dynamically-import-facaded-entry/_expected/cjs/main.js b/test/chunking-form/samples/dynamically-import-facaded-entry/_expected/cjs/main.js index 200a21c5ca7..67dac3123bc 100644 --- a/test/chunking-form/samples/dynamically-import-facaded-entry/_expected/cjs/main.js +++ b/test/chunking-form/samples/dynamically-import-facaded-entry/_expected/cjs/main.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - var main = require('./generated-main.js'); diff --git a/test/chunking-form/samples/dynamically-import-facaded-entry/_expected/system/generated-dynamic.js b/test/chunking-form/samples/dynamically-import-facaded-entry/_expected/system/generated-dynamic.js index bdc7508d075..6cf95b846da 100644 --- a/test/chunking-form/samples/dynamically-import-facaded-entry/_expected/system/generated-dynamic.js +++ b/test/chunking-form/samples/dynamically-import-facaded-entry/_expected/system/generated-dynamic.js @@ -1,14 +1,14 @@ -System.register(['./generated-main.js'], function () { +System.register(['./generated-main.js'], (function () { 'use strict'; var value; return { setters: [function (module) { value = module.v; }], - execute: function () { + execute: (function () { console.log('dynamic', value); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/dynamically-import-facaded-entry/_expected/system/generated-main.js b/test/chunking-form/samples/dynamically-import-facaded-entry/_expected/system/generated-main.js index 6275f749c70..8ad3dd47e2b 100644 --- a/test/chunking-form/samples/dynamically-import-facaded-entry/_expected/system/generated-main.js +++ b/test/chunking-form/samples/dynamically-import-facaded-entry/_expected/system/generated-main.js @@ -1,12 +1,12 @@ -System.register([], function (exports, module) { +System.register([], (function (exports, module) { 'use strict'; return { - execute: function () { + execute: (function () { - var value = exports('v', 42); + var value = exports("v", 42); - const promise = exports('p', module.import('./generated-dynamic.js').then(result => console.log('main', result, value))); + const promise = exports("p", module.import('./generated-dynamic.js').then(result => console.log('main', result, value))); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/dynamically-import-facaded-entry/_expected/system/importer.js b/test/chunking-form/samples/dynamically-import-facaded-entry/_expected/system/importer.js index 470b023dd57..53c54d91dbf 100644 --- a/test/chunking-form/samples/dynamically-import-facaded-entry/_expected/system/importer.js +++ b/test/chunking-form/samples/dynamically-import-facaded-entry/_expected/system/importer.js @@ -1,10 +1,10 @@ -System.register([], function (exports, module) { +System.register([], (function (exports, module) { 'use strict'; return { - execute: function () { + execute: (function () { module.import('./main.js').then(result => console.log('importer', result)); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/dynamically-import-facaded-entry/_expected/system/main.js b/test/chunking-form/samples/dynamically-import-facaded-entry/_expected/system/main.js index b662ff2a137..851f92643cf 100644 --- a/test/chunking-form/samples/dynamically-import-facaded-entry/_expected/system/main.js +++ b/test/chunking-form/samples/dynamically-import-facaded-entry/_expected/system/main.js @@ -1,13 +1,13 @@ -System.register(['./generated-main.js'], function (exports) { +System.register(['./generated-main.js'], (function (exports) { 'use strict'; return { setters: [function (module) { - exports('promise', module.p); + exports("promise", module.p); }], - execute: function () { + execute: (function () { - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/dynamically-import-non-preserved-entry/_config.js b/test/chunking-form/samples/dynamically-import-non-preserved-entry/_config.js index 4a2c34eaccc..e79f7985d56 100644 --- a/test/chunking-form/samples/dynamically-import-non-preserved-entry/_config.js +++ b/test/chunking-form/samples/dynamically-import-non-preserved-entry/_config.js @@ -1,7 +1,7 @@ -module.exports = { +module.exports = defineTest({ description: 'supports dynamically importing entries with additional exports', options: { input: ['main.js', 'importer.js'], preserveEntrySignatures: false } -}; +}); diff --git a/test/chunking-form/samples/dynamically-import-non-preserved-entry/_expected/amd/generated-dynamic.js b/test/chunking-form/samples/dynamically-import-non-preserved-entry/_expected/amd/generated-dynamic.js index efc42f06bf6..efd707899a2 100644 --- a/test/chunking-form/samples/dynamically-import-non-preserved-entry/_expected/amd/generated-dynamic.js +++ b/test/chunking-form/samples/dynamically-import-non-preserved-entry/_expected/amd/generated-dynamic.js @@ -1,5 +1,5 @@ -define(['./main'], function (main) { 'use strict'; +define(['./main'], (function (main) { 'use strict'; console.log('dynamic', main.value); -}); +})); diff --git a/test/chunking-form/samples/dynamically-import-non-preserved-entry/_expected/amd/importer.js b/test/chunking-form/samples/dynamically-import-non-preserved-entry/_expected/amd/importer.js index 9c4349cb7d2..4df9229b0d1 100644 --- a/test/chunking-form/samples/dynamically-import-non-preserved-entry/_expected/amd/importer.js +++ b/test/chunking-form/samples/dynamically-import-non-preserved-entry/_expected/amd/importer.js @@ -1,5 +1,5 @@ -define(['require'], function (require) { 'use strict'; +define(['require'], (function (require) { 'use strict'; - new Promise(function (resolve, reject) { require(['./main'], resolve, reject) }).then(function (n) { return n.main; }).then(result => console.log('importer', result)); + new Promise(function (resolve, reject) { require(['./main'], resolve, reject); }).then(function (n) { return n.main; }).then(result => console.log('importer', result)); -}); +})); diff --git a/test/chunking-form/samples/dynamically-import-non-preserved-entry/_expected/amd/main.js b/test/chunking-form/samples/dynamically-import-non-preserved-entry/_expected/amd/main.js index 7b6fed341b9..640a1a11a0d 100644 --- a/test/chunking-form/samples/dynamically-import-non-preserved-entry/_expected/amd/main.js +++ b/test/chunking-form/samples/dynamically-import-non-preserved-entry/_expected/amd/main.js @@ -1,8 +1,8 @@ -define(['require', 'exports'], function (require, exports) { 'use strict'; +define(['require', 'exports'], (function (require, exports) { 'use strict'; var value = 42; - const promise = new Promise(function (resolve, reject) { require(['./generated-dynamic'], resolve, reject) }).then(result => console.log('main', result, value)); + const promise = new Promise(function (resolve, reject) { require(['./generated-dynamic'], resolve, reject); }).then(result => console.log('main', result, value)); var main = /*#__PURE__*/Object.freeze({ __proto__: null, @@ -12,6 +12,4 @@ define(['require', 'exports'], function (require, exports) { 'use strict'; exports.main = main; exports.value = value; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/dynamically-import-non-preserved-entry/_expected/cjs/main.js b/test/chunking-form/samples/dynamically-import-non-preserved-entry/_expected/cjs/main.js index 47b69e30cb8..dd3b86b6851 100644 --- a/test/chunking-form/samples/dynamically-import-non-preserved-entry/_expected/cjs/main.js +++ b/test/chunking-form/samples/dynamically-import-non-preserved-entry/_expected/cjs/main.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - var value = 42; const promise = Promise.resolve().then(function () { return require('./generated-dynamic.js'); }).then(result => console.log('main', result, value)); diff --git a/test/chunking-form/samples/dynamically-import-non-preserved-entry/_expected/system/generated-dynamic.js b/test/chunking-form/samples/dynamically-import-non-preserved-entry/_expected/system/generated-dynamic.js index f35e9b0719f..3b4cbaf6548 100644 --- a/test/chunking-form/samples/dynamically-import-non-preserved-entry/_expected/system/generated-dynamic.js +++ b/test/chunking-form/samples/dynamically-import-non-preserved-entry/_expected/system/generated-dynamic.js @@ -1,14 +1,14 @@ -System.register(['./main.js'], function () { +System.register(['./main.js'], (function () { 'use strict'; var value; return { setters: [function (module) { value = module.v; }], - execute: function () { + execute: (function () { console.log('dynamic', value); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/dynamically-import-non-preserved-entry/_expected/system/importer.js b/test/chunking-form/samples/dynamically-import-non-preserved-entry/_expected/system/importer.js index 20a09445bd5..f8a8fd5150e 100644 --- a/test/chunking-form/samples/dynamically-import-non-preserved-entry/_expected/system/importer.js +++ b/test/chunking-form/samples/dynamically-import-non-preserved-entry/_expected/system/importer.js @@ -1,10 +1,10 @@ -System.register([], function (exports, module) { +System.register([], (function (exports, module) { 'use strict'; return { - execute: function () { + execute: (function () { module.import('./main.js').then(function (n) { return n.m; }).then(result => console.log('importer', result)); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/dynamically-import-non-preserved-entry/_expected/system/main.js b/test/chunking-form/samples/dynamically-import-non-preserved-entry/_expected/system/main.js index 93f986601ec..69876df26d3 100644 --- a/test/chunking-form/samples/dynamically-import-non-preserved-entry/_expected/system/main.js +++ b/test/chunking-form/samples/dynamically-import-non-preserved-entry/_expected/system/main.js @@ -1,9 +1,9 @@ -System.register([], function (exports, module) { +System.register([], (function (exports, module) { 'use strict'; return { - execute: function () { + execute: (function () { - var value = exports('v', 42); + var value = exports("v", 42); const promise = module.import('./generated-dynamic.js').then(result => console.log('main', result, value)); @@ -11,8 +11,8 @@ System.register([], function (exports, module) { __proto__: null, promise: promise }); - exports('m', main); + exports("m", main); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/dynamically-import-tainted-entry/_config.js b/test/chunking-form/samples/dynamically-import-tainted-entry/_config.js index a1585477b41..5a68c82ae86 100644 --- a/test/chunking-form/samples/dynamically-import-tainted-entry/_config.js +++ b/test/chunking-form/samples/dynamically-import-tainted-entry/_config.js @@ -1,7 +1,7 @@ -module.exports = { +module.exports = defineTest({ description: 'supports dynamically importing entries with additional exports', options: { input: ['main.js', 'importer.js'], preserveEntrySignatures: 'allow-extension' } -}; +}); diff --git a/test/chunking-form/samples/dynamically-import-tainted-entry/_expected/amd/generated-dynamic.js b/test/chunking-form/samples/dynamically-import-tainted-entry/_expected/amd/generated-dynamic.js index efc42f06bf6..efd707899a2 100644 --- a/test/chunking-form/samples/dynamically-import-tainted-entry/_expected/amd/generated-dynamic.js +++ b/test/chunking-form/samples/dynamically-import-tainted-entry/_expected/amd/generated-dynamic.js @@ -1,5 +1,5 @@ -define(['./main'], function (main) { 'use strict'; +define(['./main'], (function (main) { 'use strict'; console.log('dynamic', main.value); -}); +})); diff --git a/test/chunking-form/samples/dynamically-import-tainted-entry/_expected/amd/importer.js b/test/chunking-form/samples/dynamically-import-tainted-entry/_expected/amd/importer.js index 9c4349cb7d2..4df9229b0d1 100644 --- a/test/chunking-form/samples/dynamically-import-tainted-entry/_expected/amd/importer.js +++ b/test/chunking-form/samples/dynamically-import-tainted-entry/_expected/amd/importer.js @@ -1,5 +1,5 @@ -define(['require'], function (require) { 'use strict'; +define(['require'], (function (require) { 'use strict'; - new Promise(function (resolve, reject) { require(['./main'], resolve, reject) }).then(function (n) { return n.main; }).then(result => console.log('importer', result)); + new Promise(function (resolve, reject) { require(['./main'], resolve, reject); }).then(function (n) { return n.main; }).then(result => console.log('importer', result)); -}); +})); diff --git a/test/chunking-form/samples/dynamically-import-tainted-entry/_expected/amd/main.js b/test/chunking-form/samples/dynamically-import-tainted-entry/_expected/amd/main.js index 81f3b4e7d0c..1f52e8ff64c 100644 --- a/test/chunking-form/samples/dynamically-import-tainted-entry/_expected/amd/main.js +++ b/test/chunking-form/samples/dynamically-import-tainted-entry/_expected/amd/main.js @@ -1,8 +1,8 @@ -define(['require', 'exports'], function (require, exports) { 'use strict'; +define(['require', 'exports'], (function (require, exports) { 'use strict'; var value = 42; - const promise = new Promise(function (resolve, reject) { require(['./generated-dynamic'], resolve, reject) }).then(result => console.log('main', result, value)); + const promise = new Promise(function (resolve, reject) { require(['./generated-dynamic'], resolve, reject); }).then(result => console.log('main', result, value)); var main = /*#__PURE__*/Object.freeze({ __proto__: null, @@ -13,6 +13,4 @@ define(['require', 'exports'], function (require, exports) { 'use strict'; exports.promise = promise; exports.value = value; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/dynamically-import-tainted-entry/_expected/cjs/main.js b/test/chunking-form/samples/dynamically-import-tainted-entry/_expected/cjs/main.js index 703b184ddd1..17d46d28972 100644 --- a/test/chunking-form/samples/dynamically-import-tainted-entry/_expected/cjs/main.js +++ b/test/chunking-form/samples/dynamically-import-tainted-entry/_expected/cjs/main.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - var value = 42; const promise = Promise.resolve().then(function () { return require('./generated-dynamic.js'); }).then(result => console.log('main', result, value)); diff --git a/test/chunking-form/samples/dynamically-import-tainted-entry/_expected/system/generated-dynamic.js b/test/chunking-form/samples/dynamically-import-tainted-entry/_expected/system/generated-dynamic.js index f35e9b0719f..3b4cbaf6548 100644 --- a/test/chunking-form/samples/dynamically-import-tainted-entry/_expected/system/generated-dynamic.js +++ b/test/chunking-form/samples/dynamically-import-tainted-entry/_expected/system/generated-dynamic.js @@ -1,14 +1,14 @@ -System.register(['./main.js'], function () { +System.register(['./main.js'], (function () { 'use strict'; var value; return { setters: [function (module) { value = module.v; }], - execute: function () { + execute: (function () { console.log('dynamic', value); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/dynamically-import-tainted-entry/_expected/system/importer.js b/test/chunking-form/samples/dynamically-import-tainted-entry/_expected/system/importer.js index 20a09445bd5..f8a8fd5150e 100644 --- a/test/chunking-form/samples/dynamically-import-tainted-entry/_expected/system/importer.js +++ b/test/chunking-form/samples/dynamically-import-tainted-entry/_expected/system/importer.js @@ -1,10 +1,10 @@ -System.register([], function (exports, module) { +System.register([], (function (exports, module) { 'use strict'; return { - execute: function () { + execute: (function () { module.import('./main.js').then(function (n) { return n.m; }).then(result => console.log('importer', result)); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/dynamically-import-tainted-entry/_expected/system/main.js b/test/chunking-form/samples/dynamically-import-tainted-entry/_expected/system/main.js index 5a2f854ef51..984e679d97e 100644 --- a/test/chunking-form/samples/dynamically-import-tainted-entry/_expected/system/main.js +++ b/test/chunking-form/samples/dynamically-import-tainted-entry/_expected/system/main.js @@ -1,18 +1,18 @@ -System.register([], function (exports, module) { +System.register([], (function (exports, module) { 'use strict'; return { - execute: function () { + execute: (function () { - var value = exports('v', 42); + var value = exports("v", 42); - const promise = exports('promise', module.import('./generated-dynamic.js').then(result => console.log('main', result, value))); + const promise = exports("promise", module.import('./generated-dynamic.js').then(result => console.log('main', result, value))); var main = /*#__PURE__*/Object.freeze({ __proto__: null, promise: promise }); - exports('m', main); + exports("m", main); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/dynamically-import-untainted-entry/_config.js b/test/chunking-form/samples/dynamically-import-untainted-entry/_config.js index 423f6c73b4c..05358c08261 100644 --- a/test/chunking-form/samples/dynamically-import-untainted-entry/_config.js +++ b/test/chunking-form/samples/dynamically-import-untainted-entry/_config.js @@ -1,7 +1,7 @@ -module.exports = { +module.exports = defineTest({ description: 'makes existing entries a proper facade if possible when importing dynamically', options: { input: ['main.js', 'importer.js'], preserveEntrySignatures: false } -}; +}); diff --git a/test/chunking-form/samples/dynamically-import-untainted-entry/_expected/amd/importer.js b/test/chunking-form/samples/dynamically-import-untainted-entry/_expected/amd/importer.js index 53f3727c62d..2f143b55842 100644 --- a/test/chunking-form/samples/dynamically-import-untainted-entry/_expected/amd/importer.js +++ b/test/chunking-form/samples/dynamically-import-untainted-entry/_expected/amd/importer.js @@ -1,9 +1,7 @@ -define(['require'], function (require) { 'use strict'; +define(['require'], (function (require) { 'use strict'; - function _interopNamespaceDefaultOnly(e) { - return Object.freeze({__proto__: null, 'default': e}); - } + function _interopNamespaceDefaultOnly (e) { return Object.freeze({ __proto__: null, default: e }); } - new Promise(function (resolve, reject) { require(['./main'], function (m) { resolve(/*#__PURE__*/_interopNamespaceDefaultOnly(m)); }, reject) }).then(result => console.log('importer', result)); + new Promise(function (resolve, reject) { require(['./main'], function (m) { resolve(/*#__PURE__*/_interopNamespaceDefaultOnly(m)); }, reject); }).then(result => console.log('importer', result)); -}); +})); diff --git a/test/chunking-form/samples/dynamically-import-untainted-entry/_expected/amd/main.js b/test/chunking-form/samples/dynamically-import-untainted-entry/_expected/amd/main.js index 37d25711e09..538fc7738a6 100644 --- a/test/chunking-form/samples/dynamically-import-untainted-entry/_expected/amd/main.js +++ b/test/chunking-form/samples/dynamically-import-untainted-entry/_expected/amd/main.js @@ -1,7 +1,7 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; var main = 42; return main; -}); +})); diff --git a/test/chunking-form/samples/dynamically-import-untainted-entry/_expected/cjs/importer.js b/test/chunking-form/samples/dynamically-import-untainted-entry/_expected/cjs/importer.js index 6045a5bafc4..e911d7416ad 100644 --- a/test/chunking-form/samples/dynamically-import-untainted-entry/_expected/cjs/importer.js +++ b/test/chunking-form/samples/dynamically-import-untainted-entry/_expected/cjs/importer.js @@ -1,7 +1,5 @@ 'use strict'; -function _interopNamespaceDefaultOnly(e) { - return Object.freeze({__proto__: null, 'default': e}); -} +function _interopNamespaceDefaultOnly (e) { return Object.freeze({ __proto__: null, default: e }); } Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespaceDefaultOnly(require('./main.js')); }).then(result => console.log('importer', result)); diff --git a/test/chunking-form/samples/dynamically-import-untainted-entry/_expected/es/main.js b/test/chunking-form/samples/dynamically-import-untainted-entry/_expected/es/main.js index d862de816a3..c3e30233192 100644 --- a/test/chunking-form/samples/dynamically-import-untainted-entry/_expected/es/main.js +++ b/test/chunking-form/samples/dynamically-import-untainted-entry/_expected/es/main.js @@ -1,3 +1,3 @@ var main = 42; -export default main; +export { main as default }; diff --git a/test/chunking-form/samples/dynamically-import-untainted-entry/_expected/system/importer.js b/test/chunking-form/samples/dynamically-import-untainted-entry/_expected/system/importer.js index 470b023dd57..53c54d91dbf 100644 --- a/test/chunking-form/samples/dynamically-import-untainted-entry/_expected/system/importer.js +++ b/test/chunking-form/samples/dynamically-import-untainted-entry/_expected/system/importer.js @@ -1,10 +1,10 @@ -System.register([], function (exports, module) { +System.register([], (function (exports, module) { 'use strict'; return { - execute: function () { + execute: (function () { module.import('./main.js').then(result => console.log('importer', result)); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/dynamically-import-untainted-entry/_expected/system/main.js b/test/chunking-form/samples/dynamically-import-untainted-entry/_expected/system/main.js index a5bc7312807..acfe25c0e31 100644 --- a/test/chunking-form/samples/dynamically-import-untainted-entry/_expected/system/main.js +++ b/test/chunking-form/samples/dynamically-import-untainted-entry/_expected/system/main.js @@ -1,10 +1,10 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - var main = exports('default', 42); + var main = exports("default", 42); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/emit-file/asset-file-names/_config.js b/test/chunking-form/samples/emit-file/asset-file-names/_config.js index c1350154cbf..dcdbc1af8cd 100644 --- a/test/chunking-form/samples/emit-file/asset-file-names/_config.js +++ b/test/chunking-form/samples/emit-file/asset-file-names/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'supports custom asset file names', options: { input: ['main.js'], @@ -12,4 +12,4 @@ module.exports = { assetFileNames: '[ext]/[hash]-[name][extname]' } } -}; +}); diff --git a/test/chunking-form/samples/emit-file/asset-file-names/_expected/amd/main.js b/test/chunking-form/samples/emit-file/asset-file-names/_expected/amd/main.js index 126aa22ee83..49540b44d78 100644 --- a/test/chunking-form/samples/emit-file/asset-file-names/_expected/amd/main.js +++ b/test/chunking-form/samples/emit-file/asset-file-names/_expected/amd/main.js @@ -1,5 +1,5 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; console.log('main'); -}); +})); diff --git a/test/chunking-form/samples/emit-file/deduplicate-assets/_expected/amd/assets/string-be268e3d.txt b/test/chunking-form/samples/emit-file/asset-file-names/_expected/amd/txt/DHthXMdY-test.txt similarity index 100% rename from test/chunking-form/samples/emit-file/deduplicate-assets/_expected/amd/assets/string-be268e3d.txt rename to test/chunking-form/samples/emit-file/asset-file-names/_expected/amd/txt/DHthXMdY-test.txt diff --git a/test/chunking-form/samples/emit-file/deduplicate-assets/_expected/cjs/assets/string-be268e3d.txt b/test/chunking-form/samples/emit-file/asset-file-names/_expected/cjs/txt/DHthXMdY-test.txt similarity index 100% rename from test/chunking-form/samples/emit-file/deduplicate-assets/_expected/cjs/assets/string-be268e3d.txt rename to test/chunking-form/samples/emit-file/asset-file-names/_expected/cjs/txt/DHthXMdY-test.txt diff --git a/test/chunking-form/samples/emit-file/deduplicate-assets/_expected/es/assets/string-be268e3d.txt b/test/chunking-form/samples/emit-file/asset-file-names/_expected/es/txt/DHthXMdY-test.txt similarity index 100% rename from test/chunking-form/samples/emit-file/deduplicate-assets/_expected/es/assets/string-be268e3d.txt rename to test/chunking-form/samples/emit-file/asset-file-names/_expected/es/txt/DHthXMdY-test.txt diff --git a/test/chunking-form/samples/emit-file/asset-file-names/_expected/system/main.js b/test/chunking-form/samples/emit-file/asset-file-names/_expected/system/main.js index c83499bc2d4..35e2693371a 100644 --- a/test/chunking-form/samples/emit-file/asset-file-names/_expected/system/main.js +++ b/test/chunking-form/samples/emit-file/asset-file-names/_expected/system/main.js @@ -1,10 +1,10 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { console.log('main'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/emit-file/deduplicate-assets/_expected/system/assets/string-be268e3d.txt b/test/chunking-form/samples/emit-file/asset-file-names/_expected/system/txt/DHthXMdY-test.txt similarity index 100% rename from test/chunking-form/samples/emit-file/deduplicate-assets/_expected/system/assets/string-be268e3d.txt rename to test/chunking-form/samples/emit-file/asset-file-names/_expected/system/txt/DHthXMdY-test.txt diff --git a/test/chunking-form/samples/emit-file/deconflict-against-named-files/_config.js b/test/chunking-form/samples/emit-file/deconflict-against-named-files/_config.js index a3622a8c983..c1dd9b3cf2f 100644 --- a/test/chunking-form/samples/emit-file/deconflict-against-named-files/_config.js +++ b/test/chunking-form/samples/emit-file/deconflict-against-named-files/_config.js @@ -1,6 +1,6 @@ -const { loader } = require('../../../../utils.js'); +const { loader } = require('../../../../testHelpers.js'); -module.exports = { +module.exports = defineTest({ description: 'deconflicts files against named files', options: { input: 'main', @@ -44,4 +44,4 @@ module.exports = { } ] } -}; +}); diff --git a/test/chunking-form/samples/emit-file/deconflict-against-named-files/_expected/amd/main.js b/test/chunking-form/samples/emit-file/deconflict-against-named-files/_expected/amd/main.js index 126aa22ee83..49540b44d78 100644 --- a/test/chunking-form/samples/emit-file/deconflict-against-named-files/_expected/amd/main.js +++ b/test/chunking-form/samples/emit-file/deconflict-against-named-files/_expected/amd/main.js @@ -1,5 +1,5 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; console.log('main'); -}); +})); diff --git a/test/chunking-form/samples/emit-file/deconflict-against-named-files/_expected/amd/myfile.js b/test/chunking-form/samples/emit-file/deconflict-against-named-files/_expected/amd/myfile.js index fe9bf59ea62..a31b5c3c59e 100644 --- a/test/chunking-form/samples/emit-file/deconflict-against-named-files/_expected/amd/myfile.js +++ b/test/chunking-form/samples/emit-file/deconflict-against-named-files/_expected/amd/myfile.js @@ -1,5 +1,5 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; console.log(2); -}); +})); diff --git a/test/chunking-form/samples/emit-file/deconflict-against-named-files/_expected/amd/myfile4.js b/test/chunking-form/samples/emit-file/deconflict-against-named-files/_expected/amd/myfile4.js index 9ff7f9d4680..fb7e4c4b61b 100644 --- a/test/chunking-form/samples/emit-file/deconflict-against-named-files/_expected/amd/myfile4.js +++ b/test/chunking-form/samples/emit-file/deconflict-against-named-files/_expected/amd/myfile4.js @@ -1,5 +1,5 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; console.log(1); -}); +})); diff --git a/test/chunking-form/samples/emit-file/deconflict-against-named-files/_expected/amd/myfile5.js b/test/chunking-form/samples/emit-file/deconflict-against-named-files/_expected/amd/myfile5.js index 9c9de75f28f..bb474b227c1 100644 --- a/test/chunking-form/samples/emit-file/deconflict-against-named-files/_expected/amd/myfile5.js +++ b/test/chunking-form/samples/emit-file/deconflict-against-named-files/_expected/amd/myfile5.js @@ -1,5 +1,5 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; console.log(3); -}); +})); diff --git a/test/chunking-form/samples/emit-file/deconflict-against-named-files/_expected/system/main.js b/test/chunking-form/samples/emit-file/deconflict-against-named-files/_expected/system/main.js index c83499bc2d4..35e2693371a 100644 --- a/test/chunking-form/samples/emit-file/deconflict-against-named-files/_expected/system/main.js +++ b/test/chunking-form/samples/emit-file/deconflict-against-named-files/_expected/system/main.js @@ -1,10 +1,10 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { console.log('main'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/emit-file/deconflict-against-named-files/_expected/system/myfile.js b/test/chunking-form/samples/emit-file/deconflict-against-named-files/_expected/system/myfile.js index 51bbb7b8df1..046bf6cdd6c 100644 --- a/test/chunking-form/samples/emit-file/deconflict-against-named-files/_expected/system/myfile.js +++ b/test/chunking-form/samples/emit-file/deconflict-against-named-files/_expected/system/myfile.js @@ -1,10 +1,10 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { console.log(2); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/emit-file/deconflict-against-named-files/_expected/system/myfile4.js b/test/chunking-form/samples/emit-file/deconflict-against-named-files/_expected/system/myfile4.js index aa5f5177c77..c16543f5370 100644 --- a/test/chunking-form/samples/emit-file/deconflict-against-named-files/_expected/system/myfile4.js +++ b/test/chunking-form/samples/emit-file/deconflict-against-named-files/_expected/system/myfile4.js @@ -1,10 +1,10 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { console.log(1); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/emit-file/deconflict-against-named-files/_expected/system/myfile5.js b/test/chunking-form/samples/emit-file/deconflict-against-named-files/_expected/system/myfile5.js index 71af751777f..e0e41a91a1a 100644 --- a/test/chunking-form/samples/emit-file/deconflict-against-named-files/_expected/system/myfile5.js +++ b/test/chunking-form/samples/emit-file/deconflict-against-named-files/_expected/system/myfile5.js @@ -1,10 +1,10 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { console.log(3); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/emit-file/deduplicate-assets/_config.js b/test/chunking-form/samples/emit-file/deduplicate-assets/_config.js index e9f0e506a81..98e2c0c0d0e 100644 --- a/test/chunking-form/samples/emit-file/deduplicate-assets/_config.js +++ b/test/chunking-form/samples/emit-file/deduplicate-assets/_config.js @@ -1,31 +1,108 @@ -module.exports = { +const assert = require('node:assert'); +let string1Id, + string2Id, + stringSameSourceId, + sameStringAsBufferId, + otherStringId, + bufferId, + bufferSameSourceId, + sameBufferAsStringId, + otherBufferId; + +module.exports = defineTest({ description: 'deduplicates asset that have the same source', options: { input: ['main.js'], plugins: { buildStart() { - this.emitFile({ type: 'asset', name: 'string.txt', source: 'hello world' }); - this.emitFile({ type: 'asset', name: 'otherString.txt', source: 'hello world' }); - this.emitFile({ + // emit 'string' source in a random order + stringSameSourceId = this.emitFile({ + type: 'asset', + name: 'stringSameSource.txt', + source: 'string' + }); + string2Id = this.emitFile({ type: 'asset', name: 'string2.txt', source: 'string' }); + string1Id = this.emitFile({ type: 'asset', name: 'string1.txt', source: 'string' }); + sameStringAsBufferId = this.emitFile({ + type: 'asset', + name: 'sameStringAsBuffer.txt', + source: Buffer.from('string') // Test cross Buffer/string deduplication + }); + + // Different string source + otherStringId = this.emitFile({ + type: 'asset', + name: 'otherString.txt', + source: 'otherString' + }); + + const bufferSource = () => Buffer.from([0x62, 0x75, 0x66, 0x66, 0x65, 0x72]); + bufferId = this.emitFile({ type: 'asset', name: 'buffer.txt', - source: Buffer.from([0x62, 0x75, 0x66, 0x66, 0x65, 0x72]) + source: bufferSource() }); - this.emitFile({ + bufferSameSourceId = this.emitFile({ + type: 'asset', + name: 'bufferSameSource.txt', + source: bufferSource() + }); + sameBufferAsStringId = this.emitFile({ + type: 'asset', + name: 'sameBufferAsString.txt', + source: bufferSource().toString() // Test cross Buffer/string deduplication + }); + // Different buffer source + otherBufferId = this.emitFile({ type: 'asset', name: 'otherBuffer.txt', - source: Buffer.from([0x62, 0x75, 0x66, 0x66, 0x65, 0x72]) + source: Buffer.from('otherBuffer') }); // specific file names will not be deduplicated - this.emitFile({ type: 'asset', fileName: 'named/string.txt', source: 'hello world' }); + this.emitFile({ type: 'asset', fileName: 'named/string.txt', source: 'named' }); this.emitFile({ type: 'asset', fileName: 'named/buffer.txt', - source: Buffer.from([0x62, 0x75, 0x66, 0x66, 0x65, 0x72]) + source: bufferSource() }); return null; + }, + generateBundle() { + assert.strictEqual(this.getFileName(string1Id), 'assets/string1-8AC3h5vx.txt', 'string1'); + assert.strictEqual(this.getFileName(string2Id), 'assets/string1-8AC3h5vx.txt', 'string2'); + assert.strictEqual( + this.getFileName(stringSameSourceId), + 'assets/string1-8AC3h5vx.txt', + 'stringSameSource' + ); + assert.strictEqual( + this.getFileName(sameStringAsBufferId), + 'assets/string1-8AC3h5vx.txt', + 'sameStringAsBuffer' + ); + assert.strictEqual( + this.getFileName(otherStringId), + 'assets/otherString--JPiSXPF.txt', + 'otherString' + ); + assert.strictEqual(this.getFileName(bufferId), 'assets/buffer-B9X0n-yE.txt', 'buffer'); + assert.strictEqual( + this.getFileName(bufferSameSourceId), + 'assets/buffer-B9X0n-yE.txt', + 'bufferSameSource' + ); + assert.strictEqual( + this.getFileName(sameBufferAsStringId), + 'assets/buffer-B9X0n-yE.txt', + 'sameBufferAsString' + ); + assert.strictEqual( + this.getFileName(otherBufferId), + 'assets/otherBuffer-6HvweN2A.txt', + 'otherBuffer' + ); } } } -}; +}); diff --git a/test/chunking-form/samples/emit-file/deduplicate-assets/_expected/amd/assets/buffer-5a245d77.txt b/test/chunking-form/samples/emit-file/deduplicate-assets/_expected/amd/assets/buffer-B9X0n-yE.txt similarity index 100% rename from test/chunking-form/samples/emit-file/deduplicate-assets/_expected/amd/assets/buffer-5a245d77.txt rename to test/chunking-form/samples/emit-file/deduplicate-assets/_expected/amd/assets/buffer-B9X0n-yE.txt diff --git a/test/chunking-form/samples/emit-file/deduplicate-assets/_expected/amd/assets/otherBuffer-6HvweN2A.txt b/test/chunking-form/samples/emit-file/deduplicate-assets/_expected/amd/assets/otherBuffer-6HvweN2A.txt new file mode 100644 index 00000000000..54eb26bae5c --- /dev/null +++ b/test/chunking-form/samples/emit-file/deduplicate-assets/_expected/amd/assets/otherBuffer-6HvweN2A.txt @@ -0,0 +1 @@ +otherBuffer \ No newline at end of file diff --git a/test/chunking-form/samples/emit-file/deduplicate-assets/_expected/amd/assets/otherString--JPiSXPF.txt b/test/chunking-form/samples/emit-file/deduplicate-assets/_expected/amd/assets/otherString--JPiSXPF.txt new file mode 100644 index 00000000000..f0d609c8c8d --- /dev/null +++ b/test/chunking-form/samples/emit-file/deduplicate-assets/_expected/amd/assets/otherString--JPiSXPF.txt @@ -0,0 +1 @@ +otherString \ No newline at end of file diff --git a/test/chunking-form/samples/emit-file/deduplicate-assets/_expected/amd/assets/string1-8AC3h5vx.txt b/test/chunking-form/samples/emit-file/deduplicate-assets/_expected/amd/assets/string1-8AC3h5vx.txt new file mode 100644 index 00000000000..ec186f1f349 --- /dev/null +++ b/test/chunking-form/samples/emit-file/deduplicate-assets/_expected/amd/assets/string1-8AC3h5vx.txt @@ -0,0 +1 @@ +string \ No newline at end of file diff --git a/test/chunking-form/samples/emit-file/deduplicate-assets/_expected/amd/main.js b/test/chunking-form/samples/emit-file/deduplicate-assets/_expected/amd/main.js index 126aa22ee83..49540b44d78 100644 --- a/test/chunking-form/samples/emit-file/deduplicate-assets/_expected/amd/main.js +++ b/test/chunking-form/samples/emit-file/deduplicate-assets/_expected/amd/main.js @@ -1,5 +1,5 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; console.log('main'); -}); +})); diff --git a/test/chunking-form/samples/emit-file/deduplicate-assets/_expected/amd/named/string.txt b/test/chunking-form/samples/emit-file/deduplicate-assets/_expected/amd/named/string.txt index 95d09f2b101..eab15049cea 100644 --- a/test/chunking-form/samples/emit-file/deduplicate-assets/_expected/amd/named/string.txt +++ b/test/chunking-form/samples/emit-file/deduplicate-assets/_expected/amd/named/string.txt @@ -1 +1 @@ -hello world \ No newline at end of file +named \ No newline at end of file diff --git a/test/chunking-form/samples/emit-file/deduplicate-assets/_expected/cjs/assets/buffer-5a245d77.txt b/test/chunking-form/samples/emit-file/deduplicate-assets/_expected/cjs/assets/buffer-B9X0n-yE.txt similarity index 100% rename from test/chunking-form/samples/emit-file/deduplicate-assets/_expected/cjs/assets/buffer-5a245d77.txt rename to test/chunking-form/samples/emit-file/deduplicate-assets/_expected/cjs/assets/buffer-B9X0n-yE.txt diff --git a/test/chunking-form/samples/emit-file/deduplicate-assets/_expected/cjs/assets/otherBuffer-6HvweN2A.txt b/test/chunking-form/samples/emit-file/deduplicate-assets/_expected/cjs/assets/otherBuffer-6HvweN2A.txt new file mode 100644 index 00000000000..54eb26bae5c --- /dev/null +++ b/test/chunking-form/samples/emit-file/deduplicate-assets/_expected/cjs/assets/otherBuffer-6HvweN2A.txt @@ -0,0 +1 @@ +otherBuffer \ No newline at end of file diff --git a/test/chunking-form/samples/emit-file/deduplicate-assets/_expected/cjs/assets/otherString--JPiSXPF.txt b/test/chunking-form/samples/emit-file/deduplicate-assets/_expected/cjs/assets/otherString--JPiSXPF.txt new file mode 100644 index 00000000000..f0d609c8c8d --- /dev/null +++ b/test/chunking-form/samples/emit-file/deduplicate-assets/_expected/cjs/assets/otherString--JPiSXPF.txt @@ -0,0 +1 @@ +otherString \ No newline at end of file diff --git a/test/chunking-form/samples/emit-file/deduplicate-assets/_expected/cjs/assets/string1-8AC3h5vx.txt b/test/chunking-form/samples/emit-file/deduplicate-assets/_expected/cjs/assets/string1-8AC3h5vx.txt new file mode 100644 index 00000000000..ec186f1f349 --- /dev/null +++ b/test/chunking-form/samples/emit-file/deduplicate-assets/_expected/cjs/assets/string1-8AC3h5vx.txt @@ -0,0 +1 @@ +string \ No newline at end of file diff --git a/test/chunking-form/samples/emit-file/deduplicate-assets/_expected/cjs/named/string.txt b/test/chunking-form/samples/emit-file/deduplicate-assets/_expected/cjs/named/string.txt index 95d09f2b101..eab15049cea 100644 --- a/test/chunking-form/samples/emit-file/deduplicate-assets/_expected/cjs/named/string.txt +++ b/test/chunking-form/samples/emit-file/deduplicate-assets/_expected/cjs/named/string.txt @@ -1 +1 @@ -hello world \ No newline at end of file +named \ No newline at end of file diff --git a/test/chunking-form/samples/emit-file/deduplicate-assets/_expected/es/assets/buffer-5a245d77.txt b/test/chunking-form/samples/emit-file/deduplicate-assets/_expected/es/assets/buffer-B9X0n-yE.txt similarity index 100% rename from test/chunking-form/samples/emit-file/deduplicate-assets/_expected/es/assets/buffer-5a245d77.txt rename to test/chunking-form/samples/emit-file/deduplicate-assets/_expected/es/assets/buffer-B9X0n-yE.txt diff --git a/test/chunking-form/samples/emit-file/deduplicate-assets/_expected/es/assets/otherBuffer-6HvweN2A.txt b/test/chunking-form/samples/emit-file/deduplicate-assets/_expected/es/assets/otherBuffer-6HvweN2A.txt new file mode 100644 index 00000000000..54eb26bae5c --- /dev/null +++ b/test/chunking-form/samples/emit-file/deduplicate-assets/_expected/es/assets/otherBuffer-6HvweN2A.txt @@ -0,0 +1 @@ +otherBuffer \ No newline at end of file diff --git a/test/chunking-form/samples/emit-file/deduplicate-assets/_expected/es/assets/otherString--JPiSXPF.txt b/test/chunking-form/samples/emit-file/deduplicate-assets/_expected/es/assets/otherString--JPiSXPF.txt new file mode 100644 index 00000000000..f0d609c8c8d --- /dev/null +++ b/test/chunking-form/samples/emit-file/deduplicate-assets/_expected/es/assets/otherString--JPiSXPF.txt @@ -0,0 +1 @@ +otherString \ No newline at end of file diff --git a/test/chunking-form/samples/emit-file/deduplicate-assets/_expected/es/assets/string1-8AC3h5vx.txt b/test/chunking-form/samples/emit-file/deduplicate-assets/_expected/es/assets/string1-8AC3h5vx.txt new file mode 100644 index 00000000000..ec186f1f349 --- /dev/null +++ b/test/chunking-form/samples/emit-file/deduplicate-assets/_expected/es/assets/string1-8AC3h5vx.txt @@ -0,0 +1 @@ +string \ No newline at end of file diff --git a/test/chunking-form/samples/emit-file/deduplicate-assets/_expected/es/named/string.txt b/test/chunking-form/samples/emit-file/deduplicate-assets/_expected/es/named/string.txt index 95d09f2b101..eab15049cea 100644 --- a/test/chunking-form/samples/emit-file/deduplicate-assets/_expected/es/named/string.txt +++ b/test/chunking-form/samples/emit-file/deduplicate-assets/_expected/es/named/string.txt @@ -1 +1 @@ -hello world \ No newline at end of file +named \ No newline at end of file diff --git a/test/chunking-form/samples/emit-file/deduplicate-assets/_expected/system/assets/buffer-5a245d77.txt b/test/chunking-form/samples/emit-file/deduplicate-assets/_expected/system/assets/buffer-B9X0n-yE.txt similarity index 100% rename from test/chunking-form/samples/emit-file/deduplicate-assets/_expected/system/assets/buffer-5a245d77.txt rename to test/chunking-form/samples/emit-file/deduplicate-assets/_expected/system/assets/buffer-B9X0n-yE.txt diff --git a/test/chunking-form/samples/emit-file/deduplicate-assets/_expected/system/assets/otherBuffer-6HvweN2A.txt b/test/chunking-form/samples/emit-file/deduplicate-assets/_expected/system/assets/otherBuffer-6HvweN2A.txt new file mode 100644 index 00000000000..54eb26bae5c --- /dev/null +++ b/test/chunking-form/samples/emit-file/deduplicate-assets/_expected/system/assets/otherBuffer-6HvweN2A.txt @@ -0,0 +1 @@ +otherBuffer \ No newline at end of file diff --git a/test/chunking-form/samples/emit-file/deduplicate-assets/_expected/system/assets/otherString--JPiSXPF.txt b/test/chunking-form/samples/emit-file/deduplicate-assets/_expected/system/assets/otherString--JPiSXPF.txt new file mode 100644 index 00000000000..f0d609c8c8d --- /dev/null +++ b/test/chunking-form/samples/emit-file/deduplicate-assets/_expected/system/assets/otherString--JPiSXPF.txt @@ -0,0 +1 @@ +otherString \ No newline at end of file diff --git a/test/chunking-form/samples/emit-file/deduplicate-assets/_expected/system/assets/string1-8AC3h5vx.txt b/test/chunking-form/samples/emit-file/deduplicate-assets/_expected/system/assets/string1-8AC3h5vx.txt new file mode 100644 index 00000000000..ec186f1f349 --- /dev/null +++ b/test/chunking-form/samples/emit-file/deduplicate-assets/_expected/system/assets/string1-8AC3h5vx.txt @@ -0,0 +1 @@ +string \ No newline at end of file diff --git a/test/chunking-form/samples/emit-file/deduplicate-assets/_expected/system/main.js b/test/chunking-form/samples/emit-file/deduplicate-assets/_expected/system/main.js index c83499bc2d4..35e2693371a 100644 --- a/test/chunking-form/samples/emit-file/deduplicate-assets/_expected/system/main.js +++ b/test/chunking-form/samples/emit-file/deduplicate-assets/_expected/system/main.js @@ -1,10 +1,10 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { console.log('main'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/emit-file/deduplicate-assets/_expected/system/named/string.txt b/test/chunking-form/samples/emit-file/deduplicate-assets/_expected/system/named/string.txt index 95d09f2b101..eab15049cea 100644 --- a/test/chunking-form/samples/emit-file/deduplicate-assets/_expected/system/named/string.txt +++ b/test/chunking-form/samples/emit-file/deduplicate-assets/_expected/system/named/string.txt @@ -1 +1 @@ -hello world \ No newline at end of file +named \ No newline at end of file diff --git a/test/chunking-form/samples/emit-file/emit-asset-without-name/_config.js b/test/chunking-form/samples/emit-file/emit-asset-without-name/_config.js index 94cd5b89b47..73ac501f733 100644 --- a/test/chunking-form/samples/emit-file/emit-asset-without-name/_config.js +++ b/test/chunking-form/samples/emit-file/emit-asset-without-name/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'supports emitting an asset without a name', options: { input: ['main.js'], @@ -8,4 +8,4 @@ module.exports = { } } } -}; +}); diff --git a/test/chunking-form/samples/emit-file/emit-asset-without-name/_expected/amd/assets/asset-417c0188 b/test/chunking-form/samples/emit-file/emit-asset-without-name/_expected/amd/assets/asset-DHthXMdY similarity index 100% rename from test/chunking-form/samples/emit-file/emit-asset-without-name/_expected/amd/assets/asset-417c0188 rename to test/chunking-form/samples/emit-file/emit-asset-without-name/_expected/amd/assets/asset-DHthXMdY diff --git a/test/chunking-form/samples/emit-file/emit-asset-without-name/_expected/amd/main.js b/test/chunking-form/samples/emit-file/emit-asset-without-name/_expected/amd/main.js index 126aa22ee83..49540b44d78 100644 --- a/test/chunking-form/samples/emit-file/emit-asset-without-name/_expected/amd/main.js +++ b/test/chunking-form/samples/emit-file/emit-asset-without-name/_expected/amd/main.js @@ -1,5 +1,5 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; console.log('main'); -}); +})); diff --git a/test/chunking-form/samples/emit-file/emit-asset-without-name/_expected/cjs/assets/asset-417c0188 b/test/chunking-form/samples/emit-file/emit-asset-without-name/_expected/cjs/assets/asset-DHthXMdY similarity index 100% rename from test/chunking-form/samples/emit-file/emit-asset-without-name/_expected/cjs/assets/asset-417c0188 rename to test/chunking-form/samples/emit-file/emit-asset-without-name/_expected/cjs/assets/asset-DHthXMdY diff --git a/test/chunking-form/samples/emit-file/emit-asset-without-name/_expected/es/assets/asset-417c0188 b/test/chunking-form/samples/emit-file/emit-asset-without-name/_expected/es/assets/asset-DHthXMdY similarity index 100% rename from test/chunking-form/samples/emit-file/emit-asset-without-name/_expected/es/assets/asset-417c0188 rename to test/chunking-form/samples/emit-file/emit-asset-without-name/_expected/es/assets/asset-DHthXMdY diff --git a/test/chunking-form/samples/emit-file/emit-asset-without-name/_expected/system/assets/asset-417c0188 b/test/chunking-form/samples/emit-file/emit-asset-without-name/_expected/system/assets/asset-DHthXMdY similarity index 100% rename from test/chunking-form/samples/emit-file/emit-asset-without-name/_expected/system/assets/asset-417c0188 rename to test/chunking-form/samples/emit-file/emit-asset-without-name/_expected/system/assets/asset-DHthXMdY diff --git a/test/chunking-form/samples/emit-file/emit-asset-without-name/_expected/system/main.js b/test/chunking-form/samples/emit-file/emit-asset-without-name/_expected/system/main.js index c83499bc2d4..35e2693371a 100644 --- a/test/chunking-form/samples/emit-file/emit-asset-without-name/_expected/system/main.js +++ b/test/chunking-form/samples/emit-file/emit-asset-without-name/_expected/system/main.js @@ -1,10 +1,10 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { console.log('main'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/emit-file/emit-chunk-facade/_config.js b/test/chunking-form/samples/emit-file/emit-chunk-facade/_config.js index 2c185dd564d..a6fe75a2f3e 100644 --- a/test/chunking-form/samples/emit-file/emit-chunk-facade/_config.js +++ b/test/chunking-form/samples/emit-file/emit-chunk-facade/_config.js @@ -1,7 +1,7 @@ -const assert = require('assert'); +const assert = require('node:assert'); let referenceId; -module.exports = { +module.exports = defineTest({ description: 'retrieves the correct name of an emitted chunk in case a facade is created', options: { input: 'main', @@ -19,4 +19,4 @@ module.exports = { } } } -}; +}); diff --git a/test/chunking-form/samples/emit-file/emit-chunk-facade/_expected/amd/generated-build-starter.js b/test/chunking-form/samples/emit-file/emit-chunk-facade/_expected/amd/generated-build-starter.js index 4974a348248..8efead70ddb 100644 --- a/test/chunking-form/samples/emit-file/emit-chunk-facade/_expected/amd/generated-build-starter.js +++ b/test/chunking-form/samples/emit-file/emit-chunk-facade/_expected/amd/generated-build-starter.js @@ -1,4 +1,4 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; const value = 42; const otherValue = 43; @@ -8,4 +8,4 @@ define(['exports'], function (exports) { 'use strict'; exports.otherValue = otherValue; exports.value = value; -}); +})); diff --git a/test/chunking-form/samples/emit-file/emit-chunk-facade/_expected/amd/generated-buildStart.js b/test/chunking-form/samples/emit-file/emit-chunk-facade/_expected/amd/generated-buildStart.js index 06143748495..ffe42cfb359 100644 --- a/test/chunking-form/samples/emit-file/emit-chunk-facade/_expected/amd/generated-buildStart.js +++ b/test/chunking-form/samples/emit-file/emit-chunk-facade/_expected/amd/generated-buildStart.js @@ -1,9 +1,7 @@ -define(['exports', './generated-build-starter'], function (exports, buildStarter) { 'use strict'; +define(['exports', './generated-build-starter'], (function (exports, buildStarter) { 'use strict'; exports.buildStartValue = buildStarter.value; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/emit-file/emit-chunk-facade/_expected/amd/main.js b/test/chunking-form/samples/emit-file/emit-chunk-facade/_expected/amd/main.js index f9191ee8ad4..830d2184836 100644 --- a/test/chunking-form/samples/emit-file/emit-chunk-facade/_expected/amd/main.js +++ b/test/chunking-form/samples/emit-file/emit-chunk-facade/_expected/amd/main.js @@ -1,5 +1,5 @@ -define(['./generated-build-starter'], function (buildStarter) { 'use strict'; +define(['./generated-build-starter'], (function (buildStarter) { 'use strict'; console.log('main', buildStarter.value, buildStarter.otherValue); -}); +})); diff --git a/test/chunking-form/samples/emit-file/emit-chunk-facade/_expected/cjs/generated-buildStart.js b/test/chunking-form/samples/emit-file/emit-chunk-facade/_expected/cjs/generated-buildStart.js index 66c05cca4ba..7f8a521cd91 100644 --- a/test/chunking-form/samples/emit-file/emit-chunk-facade/_expected/cjs/generated-buildStart.js +++ b/test/chunking-form/samples/emit-file/emit-chunk-facade/_expected/cjs/generated-buildStart.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - var buildStarter = require('./generated-build-starter.js'); diff --git a/test/chunking-form/samples/emit-file/emit-chunk-facade/_expected/system/generated-build-starter.js b/test/chunking-form/samples/emit-file/emit-chunk-facade/_expected/system/generated-build-starter.js index 75f69e53e87..70c4c4f9fa1 100644 --- a/test/chunking-form/samples/emit-file/emit-chunk-facade/_expected/system/generated-build-starter.js +++ b/test/chunking-form/samples/emit-file/emit-chunk-facade/_expected/system/generated-build-starter.js @@ -1,13 +1,13 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - const value = exports('v', 42); - const otherValue = exports('o', 43); + const value = exports("v", 42); + const otherValue = exports("o", 43); console.log('startBuild', value); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/emit-file/emit-chunk-facade/_expected/system/generated-buildStart.js b/test/chunking-form/samples/emit-file/emit-chunk-facade/_expected/system/generated-buildStart.js index b82461c98ab..6617d8d3d18 100644 --- a/test/chunking-form/samples/emit-file/emit-chunk-facade/_expected/system/generated-buildStart.js +++ b/test/chunking-form/samples/emit-file/emit-chunk-facade/_expected/system/generated-buildStart.js @@ -1,13 +1,13 @@ -System.register(['./generated-build-starter.js'], function (exports) { +System.register(['./generated-build-starter.js'], (function (exports) { 'use strict'; return { setters: [function (module) { - exports('buildStartValue', module.v); + exports("buildStartValue", module.v); }], - execute: function () { + execute: (function () { - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/emit-file/emit-chunk-facade/_expected/system/main.js b/test/chunking-form/samples/emit-file/emit-chunk-facade/_expected/system/main.js index 4b52f565751..55b718e43e0 100644 --- a/test/chunking-form/samples/emit-file/emit-chunk-facade/_expected/system/main.js +++ b/test/chunking-form/samples/emit-file/emit-chunk-facade/_expected/system/main.js @@ -1,4 +1,4 @@ -System.register(['./generated-build-starter.js'], function () { +System.register(['./generated-build-starter.js'], (function () { 'use strict'; var value, otherValue; return { @@ -6,10 +6,10 @@ System.register(['./generated-build-starter.js'], function () { value = module.v; otherValue = module.o; }], - execute: function () { + execute: (function () { console.log('main', value, otherValue); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/emit-file/emit-chunk-filename/_config.js b/test/chunking-form/samples/emit-file/emit-chunk-filename/_config.js index 391c8457fbc..087ea48ce47 100644 --- a/test/chunking-form/samples/emit-file/emit-chunk-filename/_config.js +++ b/test/chunking-form/samples/emit-file/emit-chunk-filename/_config.js @@ -1,7 +1,7 @@ -const assert = require('assert'); +const assert = require('node:assert'); let referenceId; -module.exports = { +module.exports = defineTest({ description: 'supports specifying a file name when emitting a chunk', options: { input: 'main', @@ -24,4 +24,4 @@ module.exports = { } } } -}; +}); diff --git a/test/chunking-form/samples/emit-file/emit-chunk-filename/_expected/amd/custom/build-start-chunk.js b/test/chunking-form/samples/emit-file/emit-chunk-filename/_expected/amd/custom/build-start-chunk.js index 24c734da490..7c5d4d08bf9 100644 --- a/test/chunking-form/samples/emit-file/emit-chunk-filename/_expected/amd/custom/build-start-chunk.js +++ b/test/chunking-form/samples/emit-file/emit-chunk-filename/_expected/amd/custom/build-start-chunk.js @@ -1,9 +1,7 @@ -define(['exports', '../generated-buildStart'], function (exports, buildStart) { 'use strict'; +define(['exports', '../generated-buildStart'], (function (exports, buildStart) { 'use strict'; exports.id = buildStart.id; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/emit-file/emit-chunk-filename/_expected/amd/generated-buildStart.js b/test/chunking-form/samples/emit-file/emit-chunk-filename/_expected/amd/generated-buildStart.js index 7b9e28ac4ab..fa0451a0345 100644 --- a/test/chunking-form/samples/emit-file/emit-chunk-filename/_expected/amd/generated-buildStart.js +++ b/test/chunking-form/samples/emit-file/emit-chunk-filename/_expected/amd/generated-buildStart.js @@ -1,4 +1,4 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; var value = 42; @@ -8,4 +8,4 @@ define(['exports'], function (exports) { 'use strict'; exports.id = id; exports.value = value; -}); +})); diff --git a/test/chunking-form/samples/emit-file/emit-chunk-filename/_expected/amd/main.js b/test/chunking-form/samples/emit-file/emit-chunk-filename/_expected/amd/main.js index 985270c09e1..d8cd06f3083 100644 --- a/test/chunking-form/samples/emit-file/emit-chunk-filename/_expected/amd/main.js +++ b/test/chunking-form/samples/emit-file/emit-chunk-filename/_expected/amd/main.js @@ -1,7 +1,7 @@ -define(['./generated-buildStart'], function (buildStart) { 'use strict'; +define(['./generated-buildStart'], (function (buildStart) { 'use strict'; console.log(buildStart.id); console.log('main', buildStart.value); -}); +})); diff --git a/test/chunking-form/samples/emit-file/emit-chunk-filename/_expected/cjs/custom/build-start-chunk.js b/test/chunking-form/samples/emit-file/emit-chunk-filename/_expected/cjs/custom/build-start-chunk.js index 6aaa72e953f..325b51890ce 100644 --- a/test/chunking-form/samples/emit-file/emit-chunk-filename/_expected/cjs/custom/build-start-chunk.js +++ b/test/chunking-form/samples/emit-file/emit-chunk-filename/_expected/cjs/custom/build-start-chunk.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - var buildStart = require('../generated-buildStart.js'); diff --git a/test/chunking-form/samples/emit-file/emit-chunk-filename/_expected/system/custom/build-start-chunk.js b/test/chunking-form/samples/emit-file/emit-chunk-filename/_expected/system/custom/build-start-chunk.js index e37489b03c5..1fb088d3647 100644 --- a/test/chunking-form/samples/emit-file/emit-chunk-filename/_expected/system/custom/build-start-chunk.js +++ b/test/chunking-form/samples/emit-file/emit-chunk-filename/_expected/system/custom/build-start-chunk.js @@ -1,13 +1,13 @@ -System.register(['../generated-buildStart.js'], function (exports) { +System.register(['../generated-buildStart.js'], (function (exports) { 'use strict'; return { setters: [function (module) { - exports('id', module.i); + exports("id", module.i); }], - execute: function () { + execute: (function () { - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/emit-file/emit-chunk-filename/_expected/system/generated-buildStart.js b/test/chunking-form/samples/emit-file/emit-chunk-filename/_expected/system/generated-buildStart.js index 491bec60fad..58899794dc0 100644 --- a/test/chunking-form/samples/emit-file/emit-chunk-filename/_expected/system/generated-buildStart.js +++ b/test/chunking-form/samples/emit-file/emit-chunk-filename/_expected/system/generated-buildStart.js @@ -1,13 +1,13 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - var value = exports('v', 42); + var value = exports("v", 42); - const id = exports('i', 'startBuild'); + const id = exports("i", 'startBuild'); console.log(id, value); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/emit-file/emit-chunk-filename/_expected/system/main.js b/test/chunking-form/samples/emit-file/emit-chunk-filename/_expected/system/main.js index 55cc8972780..1c51c855e95 100644 --- a/test/chunking-form/samples/emit-file/emit-chunk-filename/_expected/system/main.js +++ b/test/chunking-form/samples/emit-file/emit-chunk-filename/_expected/system/main.js @@ -1,4 +1,4 @@ -System.register(['./generated-buildStart.js'], function () { +System.register(['./generated-buildStart.js'], (function () { 'use strict'; var id, value; return { @@ -6,12 +6,12 @@ System.register(['./generated-buildStart.js'], function () { id = module.i; value = module.v; }], - execute: function () { + execute: (function () { console.log(id); console.log('main', value); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_config.js b/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_config.js index ce14a9334cf..987b2617332 100644 --- a/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_config.js +++ b/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'deduplicates named chunks emitted more than once', options: { // For the second entry, a facade is created @@ -28,4 +28,4 @@ module.exports = { } } } -}; +}); diff --git a/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/amd/generated-firstName.js b/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/amd/generated-firstName.js new file mode 100644 index 00000000000..e3377c4c68b --- /dev/null +++ b/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/amd/generated-firstName.js @@ -0,0 +1,7 @@ +define((function () { 'use strict'; + + var value2 = 43; + + return value2; + +})); diff --git a/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/amd/generated-name.js b/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/amd/generated-name.js index eaec8503060..414eef8e1e6 100644 --- a/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/amd/generated-name.js +++ b/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/amd/generated-name.js @@ -1,7 +1,7 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; var value1 = 42; return value1; -}); +})); diff --git a/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/amd/generated-name2.js b/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/amd/generated-name2.js index 465cffcb633..256b839e26d 100644 --- a/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/amd/generated-name2.js +++ b/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/amd/generated-name2.js @@ -1,7 +1,7 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; var value3 = 44; return value3; -}); +})); diff --git a/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/amd/generated-secondName.js b/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/amd/generated-secondName.js deleted file mode 100644 index e881e9cecbf..00000000000 --- a/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/amd/generated-secondName.js +++ /dev/null @@ -1,7 +0,0 @@ -define(function () { 'use strict'; - - var value2 = 43; - - return value2; - -}); diff --git a/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/amd/mainChunk.js b/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/amd/mainChunk.js index 399be2c932a..8322726fdc0 100644 --- a/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/amd/mainChunk.js +++ b/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/amd/mainChunk.js @@ -1,5 +1,5 @@ -define(['./generated-name', './generated-secondName', './generated-name2'], function (name, secondName, name$1) { 'use strict'; +define(['./generated-name', './generated-firstName', './generated-name2'], (function (name, firstName, name$1) { 'use strict'; - console.log('main', name, secondName, name$1); + console.log('main', name, firstName, name$1); -}); +})); diff --git a/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/amd/other.js b/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/amd/other.js index 9aa3629e5d4..c23d5e088b7 100644 --- a/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/amd/other.js +++ b/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/amd/other.js @@ -1,5 +1,5 @@ -define(['./generated-name', './generated-secondName', './generated-name2', './mainChunk'], function (name, secondName, name$1, mainChunk) { 'use strict'; +define(['./generated-name', './generated-firstName', './generated-name2', './mainChunk'], (function (name, firstName, name$1, mainChunk) { 'use strict'; -}); +})); diff --git a/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/cjs/generated-secondName.js b/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/cjs/generated-firstName.js similarity index 100% rename from test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/cjs/generated-secondName.js rename to test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/cjs/generated-firstName.js diff --git a/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/cjs/mainChunk.js b/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/cjs/mainChunk.js index 5f0a2cff6ec..a6322eefe1c 100644 --- a/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/cjs/mainChunk.js +++ b/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/cjs/mainChunk.js @@ -1,7 +1,7 @@ 'use strict'; var name = require('./generated-name.js'); -var secondName = require('./generated-secondName.js'); +var firstName = require('./generated-firstName.js'); var name$1 = require('./generated-name2.js'); -console.log('main', name, secondName, name$1); +console.log('main', name, firstName, name$1); diff --git a/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/cjs/other.js b/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/cjs/other.js index 5f69e2c8c3a..18822f29013 100644 --- a/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/cjs/other.js +++ b/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/cjs/other.js @@ -1,7 +1,7 @@ 'use strict'; require('./generated-name.js'); -require('./generated-secondName.js'); +require('./generated-firstName.js'); require('./generated-name2.js'); require('./mainChunk.js'); diff --git a/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/es/generated-firstName.js b/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/es/generated-firstName.js new file mode 100644 index 00000000000..3c5f124193e --- /dev/null +++ b/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/es/generated-firstName.js @@ -0,0 +1,3 @@ +var value2 = 43; + +export { value2 as default }; diff --git a/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/es/generated-name.js b/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/es/generated-name.js index 6c5f12c4a68..d626e696e41 100644 --- a/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/es/generated-name.js +++ b/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/es/generated-name.js @@ -1,3 +1,3 @@ var value1 = 42; -export default value1; +export { value1 as default }; diff --git a/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/es/generated-name2.js b/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/es/generated-name2.js index 6409a036d0c..c1bd37a20f9 100644 --- a/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/es/generated-name2.js +++ b/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/es/generated-name2.js @@ -1,3 +1,3 @@ var value3 = 44; -export default value3; +export { value3 as default }; diff --git a/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/es/generated-secondName.js b/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/es/generated-secondName.js deleted file mode 100644 index 04479022dca..00000000000 --- a/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/es/generated-secondName.js +++ /dev/null @@ -1,3 +0,0 @@ -var value2 = 43; - -export default value2; diff --git a/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/es/mainChunk.js b/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/es/mainChunk.js index bae9f17e008..b0afa0148bb 100644 --- a/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/es/mainChunk.js +++ b/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/es/mainChunk.js @@ -1,5 +1,5 @@ import value1 from './generated-name.js'; -import value2 from './generated-secondName.js'; +import value2 from './generated-firstName.js'; import value3 from './generated-name2.js'; console.log('main', value1, value2, value3); diff --git a/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/es/other.js b/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/es/other.js index c236d86e897..fb128693d8a 100644 --- a/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/es/other.js +++ b/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/es/other.js @@ -1,4 +1,4 @@ import './generated-name.js'; -import './generated-secondName.js'; +import './generated-firstName.js'; import './generated-name2.js'; import './mainChunk.js'; diff --git a/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/system/generated-firstName.js b/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/system/generated-firstName.js new file mode 100644 index 00000000000..c572973e649 --- /dev/null +++ b/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/system/generated-firstName.js @@ -0,0 +1,10 @@ +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + + var value2 = exports("default", 43); + + }) + }; +})); diff --git a/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/system/generated-name.js b/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/system/generated-name.js index 58e5c7ddbc3..cd46257f759 100644 --- a/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/system/generated-name.js +++ b/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/system/generated-name.js @@ -1,10 +1,10 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - var value1 = exports('default', 42); + var value1 = exports("default", 42); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/system/generated-name2.js b/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/system/generated-name2.js index 9996739ec74..f1c2a1657e8 100644 --- a/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/system/generated-name2.js +++ b/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/system/generated-name2.js @@ -1,10 +1,10 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - var value3 = exports('default', 44); + var value3 = exports("default", 44); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/system/generated-secondName.js b/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/system/generated-secondName.js deleted file mode 100644 index 1dad12b0b48..00000000000 --- a/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/system/generated-secondName.js +++ /dev/null @@ -1,10 +0,0 @@ -System.register([], function (exports) { - 'use strict'; - return { - execute: function () { - - var value2 = exports('default', 43); - - } - }; -}); diff --git a/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/system/mainChunk.js b/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/system/mainChunk.js index 1d933eddaef..6440614a8de 100644 --- a/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/system/mainChunk.js +++ b/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/system/mainChunk.js @@ -1,4 +1,4 @@ -System.register(['./generated-name.js', './generated-secondName.js', './generated-name2.js'], function () { +System.register(['./generated-name.js', './generated-firstName.js', './generated-name2.js'], (function () { 'use strict'; var value1, value2, value3; return { @@ -9,10 +9,10 @@ System.register(['./generated-name.js', './generated-secondName.js', './generate }, function (module) { value3 = module.default; }], - execute: function () { + execute: (function () { console.log('main', value1, value2, value3); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/system/other.js b/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/system/other.js index b207a067d3a..a9f766b1dd0 100644 --- a/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/system/other.js +++ b/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/system/other.js @@ -1,11 +1,11 @@ -System.register(['./generated-name.js', './generated-secondName.js', './generated-name2.js', './mainChunk.js'], function () { +System.register(['./generated-name.js', './generated-firstName.js', './generated-name2.js', './mainChunk.js'], (function () { 'use strict'; return { - setters: [function () {}, function () {}, function () {}, function () {}], - execute: function () { + setters: [null, null, null, null], + execute: (function () { - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/emit-file/emit-chunk-named/_config.js b/test/chunking-form/samples/emit-file/emit-chunk-named/_config.js index f0c2828ab2e..d4f66160c67 100644 --- a/test/chunking-form/samples/emit-file/emit-chunk-named/_config.js +++ b/test/chunking-form/samples/emit-file/emit-chunk-named/_config.js @@ -1,7 +1,7 @@ -const assert = require('assert'); +const assert = require('node:assert'); let referenceId; -module.exports = { +module.exports = defineTest({ description: 'allows naming emitted chunks', options: { input: 'main', @@ -14,4 +14,4 @@ module.exports = { } } } -}; +}); diff --git a/test/chunking-form/samples/emit-file/emit-chunk-named/_expected/amd/generated-dep.js b/test/chunking-form/samples/emit-file/emit-chunk-named/_expected/amd/generated-dep.js index 5e2f9f02968..d041b1d05f7 100644 --- a/test/chunking-form/samples/emit-file/emit-chunk-named/_expected/amd/generated-dep.js +++ b/test/chunking-form/samples/emit-file/emit-chunk-named/_expected/amd/generated-dep.js @@ -1,7 +1,7 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; var value = 42; exports.value = value; -}); +})); diff --git a/test/chunking-form/samples/emit-file/emit-chunk-named/_expected/amd/generated-nested/my-chunk.js b/test/chunking-form/samples/emit-file/emit-chunk-named/_expected/amd/generated-nested/my-chunk.js index 5b7a3c5e857..2cb336ca13d 100644 --- a/test/chunking-form/samples/emit-file/emit-chunk-named/_expected/amd/generated-nested/my-chunk.js +++ b/test/chunking-form/samples/emit-file/emit-chunk-named/_expected/amd/generated-nested/my-chunk.js @@ -1,5 +1,5 @@ -define(['../generated-dep'], function (dep) { 'use strict'; +define(['../generated-dep'], (function (dep) { 'use strict'; console.log('startBuild', dep.value); -}); +})); diff --git a/test/chunking-form/samples/emit-file/emit-chunk-named/_expected/amd/main.js b/test/chunking-form/samples/emit-file/emit-chunk-named/_expected/amd/main.js index 764805deda3..9e566362545 100644 --- a/test/chunking-form/samples/emit-file/emit-chunk-named/_expected/amd/main.js +++ b/test/chunking-form/samples/emit-file/emit-chunk-named/_expected/amd/main.js @@ -1,5 +1,5 @@ -define(['./generated-dep'], function (dep) { 'use strict'; +define(['./generated-dep'], (function (dep) { 'use strict'; console.log('main', dep.value); -}); +})); diff --git a/test/chunking-form/samples/emit-file/emit-chunk-named/_expected/system/generated-dep.js b/test/chunking-form/samples/emit-file/emit-chunk-named/_expected/system/generated-dep.js index e69dcc529da..cfb9c05fd92 100644 --- a/test/chunking-form/samples/emit-file/emit-chunk-named/_expected/system/generated-dep.js +++ b/test/chunking-form/samples/emit-file/emit-chunk-named/_expected/system/generated-dep.js @@ -1,10 +1,10 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - var value = exports('v', 42); + var value = exports("v", 42); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/emit-file/emit-chunk-named/_expected/system/generated-nested/my-chunk.js b/test/chunking-form/samples/emit-file/emit-chunk-named/_expected/system/generated-nested/my-chunk.js index 2655f9f646f..dbccb2900b9 100644 --- a/test/chunking-form/samples/emit-file/emit-chunk-named/_expected/system/generated-nested/my-chunk.js +++ b/test/chunking-form/samples/emit-file/emit-chunk-named/_expected/system/generated-nested/my-chunk.js @@ -1,14 +1,14 @@ -System.register(['../generated-dep.js'], function () { +System.register(['../generated-dep.js'], (function () { 'use strict'; var value; return { setters: [function (module) { value = module.v; }], - execute: function () { + execute: (function () { console.log('startBuild', value); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/emit-file/emit-chunk-named/_expected/system/main.js b/test/chunking-form/samples/emit-file/emit-chunk-named/_expected/system/main.js index 13eec5478ac..39150aad0de 100644 --- a/test/chunking-form/samples/emit-file/emit-chunk-named/_expected/system/main.js +++ b/test/chunking-form/samples/emit-file/emit-chunk-named/_expected/system/main.js @@ -1,14 +1,14 @@ -System.register(['./generated-dep.js'], function () { +System.register(['./generated-dep.js'], (function () { 'use strict'; var value; return { setters: [function (module) { value = module.v; }], - execute: function () { + execute: (function () { console.log('main', value); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/emit-file/emit-chunk-order1/_config.js b/test/chunking-form/samples/emit-file/emit-chunk-order1/_config.js index b703d91d0bf..9bb20f1b293 100644 --- a/test/chunking-form/samples/emit-file/emit-chunk-order1/_config.js +++ b/test/chunking-form/samples/emit-file/emit-chunk-order1/_config.js @@ -1,6 +1,6 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'creates a consistent chunking order (needs to be consistent with the other test of this kind)', options: { @@ -33,4 +33,4 @@ console.log(id, value); } } } -}; +}); diff --git a/test/chunking-form/samples/emit-file/emit-chunk-order1/_expected/amd/generated-emitted.js b/test/chunking-form/samples/emit-file/emit-chunk-order1/_expected/amd/generated-emitted.js index 17272f4c92f..8b74a03c43e 100644 --- a/test/chunking-form/samples/emit-file/emit-chunk-order1/_expected/amd/generated-emitted.js +++ b/test/chunking-form/samples/emit-file/emit-chunk-order1/_expected/amd/generated-emitted.js @@ -1,4 +1,4 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; var value = 42; @@ -8,4 +8,4 @@ define(['exports'], function (exports) { 'use strict'; exports.id = id; exports.value = value; -}); +})); diff --git a/test/chunking-form/samples/emit-file/emit-chunk-order1/_expected/amd/generated-emitted2.js b/test/chunking-form/samples/emit-file/emit-chunk-order1/_expected/amd/generated-emitted2.js index 12e48a162a9..4dd558a916d 100644 --- a/test/chunking-form/samples/emit-file/emit-chunk-order1/_expected/amd/generated-emitted2.js +++ b/test/chunking-form/samples/emit-file/emit-chunk-order1/_expected/amd/generated-emitted2.js @@ -1,9 +1,7 @@ -define(['exports', './generated-emitted'], function (exports, emitted) { 'use strict'; +define(['exports', './generated-emitted'], (function (exports, emitted) { 'use strict'; exports.id = emitted.id; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/emit-file/emit-chunk-order1/_expected/amd/main.js b/test/chunking-form/samples/emit-file/emit-chunk-order1/_expected/amd/main.js index b2733720024..155a6377282 100644 --- a/test/chunking-form/samples/emit-file/emit-chunk-order1/_expected/amd/main.js +++ b/test/chunking-form/samples/emit-file/emit-chunk-order1/_expected/amd/main.js @@ -1,7 +1,7 @@ -define(['./generated-emitted'], function (emitted) { 'use strict'; +define(['./generated-emitted'], (function (emitted) { 'use strict'; console.log(emitted.id); console.log('main', emitted.value); -}); +})); diff --git a/test/chunking-form/samples/emit-file/emit-chunk-order1/_expected/cjs/generated-emitted2.js b/test/chunking-form/samples/emit-file/emit-chunk-order1/_expected/cjs/generated-emitted2.js index cea7e87b55c..8fcbdb1da0a 100644 --- a/test/chunking-form/samples/emit-file/emit-chunk-order1/_expected/cjs/generated-emitted2.js +++ b/test/chunking-form/samples/emit-file/emit-chunk-order1/_expected/cjs/generated-emitted2.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - var emitted = require('./generated-emitted.js'); diff --git a/test/chunking-form/samples/emit-file/emit-chunk-order1/_expected/system/generated-emitted.js b/test/chunking-form/samples/emit-file/emit-chunk-order1/_expected/system/generated-emitted.js index 8b1783315ca..fa180ffa380 100644 --- a/test/chunking-form/samples/emit-file/emit-chunk-order1/_expected/system/generated-emitted.js +++ b/test/chunking-form/samples/emit-file/emit-chunk-order1/_expected/system/generated-emitted.js @@ -1,13 +1,13 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - var value = exports('v', 42); + var value = exports("v", 42); - const id = exports('i', 'emitted'); + const id = exports("i", 'emitted'); console.log(id, value); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/emit-file/emit-chunk-order1/_expected/system/generated-emitted2.js b/test/chunking-form/samples/emit-file/emit-chunk-order1/_expected/system/generated-emitted2.js index aca4a34d706..b63192f39a1 100644 --- a/test/chunking-form/samples/emit-file/emit-chunk-order1/_expected/system/generated-emitted2.js +++ b/test/chunking-form/samples/emit-file/emit-chunk-order1/_expected/system/generated-emitted2.js @@ -1,13 +1,13 @@ -System.register(['./generated-emitted.js'], function (exports) { +System.register(['./generated-emitted.js'], (function (exports) { 'use strict'; return { setters: [function (module) { - exports('id', module.i); + exports("id", module.i); }], - execute: function () { + execute: (function () { - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/emit-file/emit-chunk-order1/_expected/system/main.js b/test/chunking-form/samples/emit-file/emit-chunk-order1/_expected/system/main.js index b66e323577b..35e03114fd9 100644 --- a/test/chunking-form/samples/emit-file/emit-chunk-order1/_expected/system/main.js +++ b/test/chunking-form/samples/emit-file/emit-chunk-order1/_expected/system/main.js @@ -1,4 +1,4 @@ -System.register(['./generated-emitted.js'], function () { +System.register(['./generated-emitted.js'], (function () { 'use strict'; var id, value; return { @@ -6,12 +6,12 @@ System.register(['./generated-emitted.js'], function () { id = module.i; value = module.v; }], - execute: function () { + execute: (function () { console.log(id); console.log('main', value); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/emit-file/emit-chunk-order2/_config.js b/test/chunking-form/samples/emit-file/emit-chunk-order2/_config.js index 4f5333bb654..0ee9a7a012f 100644 --- a/test/chunking-form/samples/emit-file/emit-chunk-order2/_config.js +++ b/test/chunking-form/samples/emit-file/emit-chunk-order2/_config.js @@ -1,6 +1,6 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'creates a consistent chunking order (needs to be consistent with the other test of this kind)', options: { @@ -39,4 +39,4 @@ console.log(id, value); } } } -}; +}); diff --git a/test/chunking-form/samples/emit-file/emit-chunk-order2/_expected/amd/generated-emitted.js b/test/chunking-form/samples/emit-file/emit-chunk-order2/_expected/amd/generated-emitted.js index 17272f4c92f..8b74a03c43e 100644 --- a/test/chunking-form/samples/emit-file/emit-chunk-order2/_expected/amd/generated-emitted.js +++ b/test/chunking-form/samples/emit-file/emit-chunk-order2/_expected/amd/generated-emitted.js @@ -1,4 +1,4 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; var value = 42; @@ -8,4 +8,4 @@ define(['exports'], function (exports) { 'use strict'; exports.id = id; exports.value = value; -}); +})); diff --git a/test/chunking-form/samples/emit-file/emit-chunk-order2/_expected/amd/generated-emitted2.js b/test/chunking-form/samples/emit-file/emit-chunk-order2/_expected/amd/generated-emitted2.js index 12e48a162a9..4dd558a916d 100644 --- a/test/chunking-form/samples/emit-file/emit-chunk-order2/_expected/amd/generated-emitted2.js +++ b/test/chunking-form/samples/emit-file/emit-chunk-order2/_expected/amd/generated-emitted2.js @@ -1,9 +1,7 @@ -define(['exports', './generated-emitted'], function (exports, emitted) { 'use strict'; +define(['exports', './generated-emitted'], (function (exports, emitted) { 'use strict'; exports.id = emitted.id; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/emit-file/emit-chunk-order2/_expected/amd/main.js b/test/chunking-form/samples/emit-file/emit-chunk-order2/_expected/amd/main.js index b2733720024..155a6377282 100644 --- a/test/chunking-form/samples/emit-file/emit-chunk-order2/_expected/amd/main.js +++ b/test/chunking-form/samples/emit-file/emit-chunk-order2/_expected/amd/main.js @@ -1,7 +1,7 @@ -define(['./generated-emitted'], function (emitted) { 'use strict'; +define(['./generated-emitted'], (function (emitted) { 'use strict'; console.log(emitted.id); console.log('main', emitted.value); -}); +})); diff --git a/test/chunking-form/samples/emit-file/emit-chunk-order2/_expected/cjs/generated-emitted2.js b/test/chunking-form/samples/emit-file/emit-chunk-order2/_expected/cjs/generated-emitted2.js index cea7e87b55c..8fcbdb1da0a 100644 --- a/test/chunking-form/samples/emit-file/emit-chunk-order2/_expected/cjs/generated-emitted2.js +++ b/test/chunking-form/samples/emit-file/emit-chunk-order2/_expected/cjs/generated-emitted2.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - var emitted = require('./generated-emitted.js'); diff --git a/test/chunking-form/samples/emit-file/emit-chunk-order2/_expected/system/generated-emitted.js b/test/chunking-form/samples/emit-file/emit-chunk-order2/_expected/system/generated-emitted.js index 8b1783315ca..fa180ffa380 100644 --- a/test/chunking-form/samples/emit-file/emit-chunk-order2/_expected/system/generated-emitted.js +++ b/test/chunking-form/samples/emit-file/emit-chunk-order2/_expected/system/generated-emitted.js @@ -1,13 +1,13 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - var value = exports('v', 42); + var value = exports("v", 42); - const id = exports('i', 'emitted'); + const id = exports("i", 'emitted'); console.log(id, value); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/emit-file/emit-chunk-order2/_expected/system/generated-emitted2.js b/test/chunking-form/samples/emit-file/emit-chunk-order2/_expected/system/generated-emitted2.js index aca4a34d706..b63192f39a1 100644 --- a/test/chunking-form/samples/emit-file/emit-chunk-order2/_expected/system/generated-emitted2.js +++ b/test/chunking-form/samples/emit-file/emit-chunk-order2/_expected/system/generated-emitted2.js @@ -1,13 +1,13 @@ -System.register(['./generated-emitted.js'], function (exports) { +System.register(['./generated-emitted.js'], (function (exports) { 'use strict'; return { setters: [function (module) { - exports('id', module.i); + exports("id", module.i); }], - execute: function () { + execute: (function () { - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/emit-file/emit-chunk-order2/_expected/system/main.js b/test/chunking-form/samples/emit-file/emit-chunk-order2/_expected/system/main.js index b66e323577b..35e03114fd9 100644 --- a/test/chunking-form/samples/emit-file/emit-chunk-order2/_expected/system/main.js +++ b/test/chunking-form/samples/emit-file/emit-chunk-order2/_expected/system/main.js @@ -1,4 +1,4 @@ -System.register(['./generated-emitted.js'], function () { +System.register(['./generated-emitted.js'], (function () { 'use strict'; var id, value; return { @@ -6,12 +6,12 @@ System.register(['./generated-emitted.js'], function () { id = module.i; value = module.v; }], - execute: function () { + execute: (function () { console.log(id); console.log('main', value); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/emit-file/emit-chunk-with-importer/_config.js b/test/chunking-form/samples/emit-file/emit-chunk-with-importer/_config.js index f8192ec4ea2..a13bfdc3714 100644 --- a/test/chunking-form/samples/emit-file/emit-chunk-with-importer/_config.js +++ b/test/chunking-form/samples/emit-file/emit-chunk-with-importer/_config.js @@ -1,9 +1,9 @@ -const path = require('path'); +const path = require('node:path'); let noImporterReferenceId; let mainReferenceId; let nestedReferenceId; -module.exports = { +module.exports = defineTest({ description: 'allows specifying an importer when resolving ids', options: { input: 'main', @@ -32,4 +32,4 @@ module.exports = { } } } -}; +}); diff --git a/test/chunking-form/samples/emit-file/emit-chunk-with-importer/_expected/amd/generated-lib.js b/test/chunking-form/samples/emit-file/emit-chunk-with-importer/_expected/amd/generated-lib.js index cee6de6e289..f603c15c237 100644 --- a/test/chunking-form/samples/emit-file/emit-chunk-with-importer/_expected/amd/generated-lib.js +++ b/test/chunking-form/samples/emit-file/emit-chunk-with-importer/_expected/amd/generated-lib.js @@ -1,5 +1,5 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; console.log('main lib'); -}); +})); diff --git a/test/chunking-form/samples/emit-file/emit-chunk-with-importer/_expected/amd/generated-lib2.js b/test/chunking-form/samples/emit-file/emit-chunk-with-importer/_expected/amd/generated-lib2.js index f76826176c4..e4989354aca 100644 --- a/test/chunking-form/samples/emit-file/emit-chunk-with-importer/_expected/amd/generated-lib2.js +++ b/test/chunking-form/samples/emit-file/emit-chunk-with-importer/_expected/amd/generated-lib2.js @@ -1,5 +1,5 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; console.log('nested lib'); -}); +})); diff --git a/test/chunking-form/samples/emit-file/emit-chunk-with-importer/_expected/amd/main.js b/test/chunking-form/samples/emit-file/emit-chunk-with-importer/_expected/amd/main.js index 805bcc46e71..651fe4c500f 100644 --- a/test/chunking-form/samples/emit-file/emit-chunk-with-importer/_expected/amd/main.js +++ b/test/chunking-form/samples/emit-file/emit-chunk-with-importer/_expected/amd/main.js @@ -1,7 +1,7 @@ -define(['require'], function (require) { 'use strict'; +define(['require'], (function (require) { 'use strict'; console.log('no importer', new URL(require.toUrl('./generated-lib.js'), document.baseURI).href); console.log('from maim', new URL(require.toUrl('./generated-lib.js'), document.baseURI).href); console.log('from nested', new URL(require.toUrl('./generated-lib2.js'), document.baseURI).href); -}); +})); diff --git a/test/chunking-form/samples/emit-file/emit-chunk-with-importer/_expected/cjs/main.js b/test/chunking-form/samples/emit-file/emit-chunk-with-importer/_expected/cjs/main.js index 6ea003e0663..4f2e3528610 100644 --- a/test/chunking-form/samples/emit-file/emit-chunk-with-importer/_expected/cjs/main.js +++ b/test/chunking-form/samples/emit-file/emit-chunk-with-importer/_expected/cjs/main.js @@ -1,5 +1,5 @@ 'use strict'; -console.log('no importer', (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __dirname + '/generated-lib.js').href : new URL('generated-lib.js', document.currentScript && document.currentScript.src || document.baseURI).href)); -console.log('from maim', (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __dirname + '/generated-lib.js').href : new URL('generated-lib.js', document.currentScript && document.currentScript.src || document.baseURI).href)); -console.log('from nested', (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __dirname + '/generated-lib2.js').href : new URL('generated-lib2.js', document.currentScript && document.currentScript.src || document.baseURI).href)); +console.log('no importer', (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__dirname + '/generated-lib.js').href : new URL('generated-lib.js', document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT' && document.currentScript.src || document.baseURI).href)); +console.log('from maim', (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__dirname + '/generated-lib.js').href : new URL('generated-lib.js', document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT' && document.currentScript.src || document.baseURI).href)); +console.log('from nested', (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__dirname + '/generated-lib2.js').href : new URL('generated-lib2.js', document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT' && document.currentScript.src || document.baseURI).href)); diff --git a/test/chunking-form/samples/emit-file/emit-chunk-with-importer/_expected/system/generated-lib.js b/test/chunking-form/samples/emit-file/emit-chunk-with-importer/_expected/system/generated-lib.js index 507bca5d3ac..a81bd2cb478 100644 --- a/test/chunking-form/samples/emit-file/emit-chunk-with-importer/_expected/system/generated-lib.js +++ b/test/chunking-form/samples/emit-file/emit-chunk-with-importer/_expected/system/generated-lib.js @@ -1,10 +1,10 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { console.log('main lib'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/emit-file/emit-chunk-with-importer/_expected/system/generated-lib2.js b/test/chunking-form/samples/emit-file/emit-chunk-with-importer/_expected/system/generated-lib2.js index 7926ecf0ea3..19b47071987 100644 --- a/test/chunking-form/samples/emit-file/emit-chunk-with-importer/_expected/system/generated-lib2.js +++ b/test/chunking-form/samples/emit-file/emit-chunk-with-importer/_expected/system/generated-lib2.js @@ -1,10 +1,10 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { console.log('nested lib'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/emit-file/emit-chunk-with-importer/_expected/system/main.js b/test/chunking-form/samples/emit-file/emit-chunk-with-importer/_expected/system/main.js index 370c482dbbb..532ce3c9010 100644 --- a/test/chunking-form/samples/emit-file/emit-chunk-with-importer/_expected/system/main.js +++ b/test/chunking-form/samples/emit-file/emit-chunk-with-importer/_expected/system/main.js @@ -1,12 +1,12 @@ -System.register([], function (exports, module) { +System.register([], (function (exports, module) { 'use strict'; return { - execute: function () { + execute: (function () { console.log('no importer', new URL('generated-lib.js', module.meta.url).href); console.log('from maim', new URL('generated-lib.js', module.meta.url).href); console.log('from nested', new URL('generated-lib2.js', module.meta.url).href); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/emit-file/emit-chunk-worker/_config.js b/test/chunking-form/samples/emit-file/emit-chunk-worker/_config.js index 1be938dec5b..eb3489b8333 100644 --- a/test/chunking-form/samples/emit-file/emit-chunk-worker/_config.js +++ b/test/chunking-form/samples/emit-file/emit-chunk-worker/_config.js @@ -1,9 +1,9 @@ -const path = require('path'); +const path = require('node:path'); let workerId; let proxyId; -module.exports = { +module.exports = defineTest({ description: 'allows adding additional chunks to be used in workers', options: { input: 'main', @@ -51,4 +51,4 @@ requirejs(['${chunkFileName}']);`; } } } -}; +}); diff --git a/test/chunking-form/samples/emit-file/emit-chunk-worker/_expected/amd/chunks/nested.js b/test/chunking-form/samples/emit-file/emit-chunk-worker/_expected/amd/chunks/nested.js index deefacd2395..206aefd79b4 100644 --- a/test/chunking-form/samples/emit-file/emit-chunk-worker/_expected/amd/chunks/nested.js +++ b/test/chunking-form/samples/emit-file/emit-chunk-worker/_expected/amd/chunks/nested.js @@ -1,4 +1,4 @@ -define(['require', 'exports'], function (require, exports) { 'use strict'; +define(['require', 'exports'], (function (require, exports) { 'use strict'; const getWorkerMessage = () => new Promise(resolve => { const worker = new Worker(new URL(require.toUrl('./worker-proxy.js'), document.baseURI).href); @@ -7,4 +7,4 @@ define(['require', 'exports'], function (require, exports) { 'use strict'; exports.getWorkerMessage = getWorkerMessage; -}); +})); diff --git a/test/chunking-form/samples/emit-file/emit-chunk-worker/_expected/amd/chunks/shared.js b/test/chunking-form/samples/emit-file/emit-chunk-worker/_expected/amd/chunks/shared.js index b188047d8e0..3f801df74ed 100644 --- a/test/chunking-form/samples/emit-file/emit-chunk-worker/_expected/amd/chunks/shared.js +++ b/test/chunking-form/samples/emit-file/emit-chunk-worker/_expected/amd/chunks/shared.js @@ -1,7 +1,7 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; const shared = 'shared'; exports.shared = shared; -}); +})); diff --git a/test/chunking-form/samples/emit-file/emit-chunk-worker/_expected/amd/chunks/worker.js b/test/chunking-form/samples/emit-file/emit-chunk-worker/_expected/amd/chunks/worker.js index de59be73c36..56158bba992 100644 --- a/test/chunking-form/samples/emit-file/emit-chunk-worker/_expected/amd/chunks/worker.js +++ b/test/chunking-form/samples/emit-file/emit-chunk-worker/_expected/amd/chunks/worker.js @@ -1,5 +1,5 @@ -define(['./shared'], function (shared) { 'use strict'; +define(['./shared'], (function (shared) { 'use strict'; postMessage(`from worker: ${shared.shared}`); -}); +})); diff --git a/test/chunking-form/samples/emit-file/emit-chunk-worker/_expected/amd/main.js b/test/chunking-form/samples/emit-file/emit-chunk-worker/_expected/amd/main.js index cc2e4dd2ca3..8a68fe8635f 100644 --- a/test/chunking-form/samples/emit-file/emit-chunk-worker/_expected/amd/main.js +++ b/test/chunking-form/samples/emit-file/emit-chunk-worker/_expected/amd/main.js @@ -1,4 +1,4 @@ -define(['require', './chunks/shared'], function (require, shared) { 'use strict'; +define(['require', './chunks/shared'], (function (require, shared) { 'use strict'; const getWorkerMessage = () => new Promise(resolve => { const worker = new Worker(new URL(require.toUrl('./chunks/worker-proxy.js'), document.baseURI).href); @@ -8,8 +8,8 @@ define(['require', './chunks/shared'], function (require, shared) { 'use strict' document.body.innerHTML += `

main: ${shared.shared}

`; getWorkerMessage().then(message => (document.body.innerHTML += `

1: ${message.data}

`)); - new Promise(function (resolve, reject) { require(['./chunks/nested'], resolve, reject) }) + new Promise(function (resolve, reject) { require(['./chunks/nested'], resolve, reject); }) .then(result => result.getWorkerMessage()) .then(message => (document.body.innerHTML += `

2: ${message.data}

`)); -}); +})); diff --git a/test/chunking-form/samples/emit-file/emit-chunk-worker/_expected/cjs/chunks/nested.js b/test/chunking-form/samples/emit-file/emit-chunk-worker/_expected/cjs/chunks/nested.js index b1544deca5e..068a048b4c6 100644 --- a/test/chunking-form/samples/emit-file/emit-chunk-worker/_expected/cjs/chunks/nested.js +++ b/test/chunking-form/samples/emit-file/emit-chunk-worker/_expected/cjs/chunks/nested.js @@ -1,7 +1,7 @@ 'use strict'; const getWorkerMessage = () => new Promise(resolve => { - const worker = new Worker((typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __dirname + '/worker-proxy.js').href : new URL('worker-proxy.js', document.currentScript && document.currentScript.src || document.baseURI).href)); + const worker = new Worker((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__dirname + '/worker-proxy.js').href : new URL('worker-proxy.js', document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT' && document.currentScript.src || document.baseURI).href)); worker.onmessage = resolve; }); diff --git a/test/chunking-form/samples/emit-file/emit-chunk-worker/_expected/cjs/chunks/worker-proxy.js b/test/chunking-form/samples/emit-file/emit-chunk-worker/_expected/cjs/chunks/worker-proxy.js index 0171ef8895e..74905837541 100644 --- a/test/chunking-form/samples/emit-file/emit-chunk-worker/_expected/cjs/chunks/worker-proxy.js +++ b/test/chunking-form/samples/emit-file/emit-chunk-worker/_expected/cjs/chunks/worker-proxy.js @@ -1,3 +1,3 @@ 'use strict'; -PLACEHOLDER((typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __dirname + '/worker.js').href : new URL('worker.js', document.currentScript && document.currentScript.src || document.baseURI).href)); +PLACEHOLDER((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__dirname + '/worker.js').href : new URL('worker.js', document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT' && document.currentScript.src || document.baseURI).href)); diff --git a/test/chunking-form/samples/emit-file/emit-chunk-worker/_expected/cjs/main.js b/test/chunking-form/samples/emit-file/emit-chunk-worker/_expected/cjs/main.js index 1d9811d9f8b..a1cd157d074 100644 --- a/test/chunking-form/samples/emit-file/emit-chunk-worker/_expected/cjs/main.js +++ b/test/chunking-form/samples/emit-file/emit-chunk-worker/_expected/cjs/main.js @@ -3,7 +3,7 @@ var shared = require('./chunks/shared.js'); const getWorkerMessage = () => new Promise(resolve => { - const worker = new Worker((typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __dirname + '/chunks/worker-proxy.js').href : new URL('chunks/worker-proxy.js', document.currentScript && document.currentScript.src || document.baseURI).href)); + const worker = new Worker((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__dirname + '/chunks/worker-proxy.js').href : new URL('chunks/worker-proxy.js', document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT' && document.currentScript.src || document.baseURI).href)); worker.onmessage = resolve; }); diff --git a/test/chunking-form/samples/emit-file/emit-chunk-worker/_expected/system/chunks/nested.js b/test/chunking-form/samples/emit-file/emit-chunk-worker/_expected/system/chunks/nested.js index 1c41e726447..6e654474d21 100644 --- a/test/chunking-form/samples/emit-file/emit-chunk-worker/_expected/system/chunks/nested.js +++ b/test/chunking-form/samples/emit-file/emit-chunk-worker/_expected/system/chunks/nested.js @@ -1,13 +1,13 @@ -System.register([], function (exports, module) { +System.register([], (function (exports, module) { 'use strict'; return { - execute: function () { + execute: (function () { - const getWorkerMessage = exports('getWorkerMessage', () => new Promise(resolve => { + const getWorkerMessage = exports("getWorkerMessage", () => new Promise(resolve => { const worker = new Worker(new URL('worker-proxy.js', module.meta.url).href); worker.onmessage = resolve; })); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/emit-file/emit-chunk-worker/_expected/system/chunks/shared.js b/test/chunking-form/samples/emit-file/emit-chunk-worker/_expected/system/chunks/shared.js index 48be08070fc..86710d1127f 100644 --- a/test/chunking-form/samples/emit-file/emit-chunk-worker/_expected/system/chunks/shared.js +++ b/test/chunking-form/samples/emit-file/emit-chunk-worker/_expected/system/chunks/shared.js @@ -1,10 +1,10 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - const shared = exports('s', 'shared'); + const shared = exports("s", 'shared'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/emit-file/emit-chunk-worker/_expected/system/chunks/worker.js b/test/chunking-form/samples/emit-file/emit-chunk-worker/_expected/system/chunks/worker.js index 1013f55b394..c73a318e3e4 100644 --- a/test/chunking-form/samples/emit-file/emit-chunk-worker/_expected/system/chunks/worker.js +++ b/test/chunking-form/samples/emit-file/emit-chunk-worker/_expected/system/chunks/worker.js @@ -1,14 +1,14 @@ -System.register(['./shared.js'], function () { +System.register(['./shared.js'], (function () { 'use strict'; var shared; return { setters: [function (module) { shared = module.s; }], - execute: function () { + execute: (function () { postMessage(`from worker: ${shared}`); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/emit-file/emit-chunk-worker/_expected/system/main.js b/test/chunking-form/samples/emit-file/emit-chunk-worker/_expected/system/main.js index 4ee1bb4ab60..cd37abb081f 100644 --- a/test/chunking-form/samples/emit-file/emit-chunk-worker/_expected/system/main.js +++ b/test/chunking-form/samples/emit-file/emit-chunk-worker/_expected/system/main.js @@ -1,11 +1,11 @@ -System.register(['./chunks/shared.js'], function (exports, module) { +System.register(['./chunks/shared.js'], (function (exports, module) { 'use strict'; var shared; return { setters: [function (module) { shared = module.s; }], - execute: function () { + execute: (function () { const getWorkerMessage = () => new Promise(resolve => { const worker = new Worker(new URL('chunks/worker-proxy.js', module.meta.url).href); @@ -19,6 +19,6 @@ System.register(['./chunks/shared.js'], function (exports, module) { .then(result => result.getWorkerMessage()) .then(message => (document.body.innerHTML += `

2: ${message.data}

`)); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/emit-file/emit-chunk-worklet/_config.js b/test/chunking-form/samples/emit-file/emit-chunk-worklet/_config.js index 70bd5ddb829..fce3461112d 100644 --- a/test/chunking-form/samples/emit-file/emit-chunk-worklet/_config.js +++ b/test/chunking-form/samples/emit-file/emit-chunk-worklet/_config.js @@ -1,6 +1,6 @@ const REGISTER_WORKLET = 'register-paint-worklet:'; -module.exports = { +module.exports = defineTest({ description: 'allows adding additional chunks to be used in worklets', options: { input: 'main', @@ -26,4 +26,4 @@ module.exports = { } } } -}; +}); diff --git a/test/chunking-form/samples/emit-file/emit-chunk-worklet/_expected/amd/chunks/shared.js b/test/chunking-form/samples/emit-file/emit-chunk-worklet/_expected/amd/chunks/shared.js index 931cd5869bc..e5f35a000cb 100644 --- a/test/chunking-form/samples/emit-file/emit-chunk-worklet/_expected/amd/chunks/shared.js +++ b/test/chunking-form/samples/emit-file/emit-chunk-worklet/_expected/amd/chunks/shared.js @@ -1,4 +1,4 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; const color = 'greenyellow'; const size = 6; @@ -6,4 +6,4 @@ define(['exports'], function (exports) { 'use strict'; exports.color = color; exports.size = size; -}); +})); diff --git a/test/chunking-form/samples/emit-file/emit-chunk-worklet/_expected/amd/chunks/worklet.js b/test/chunking-form/samples/emit-file/emit-chunk-worklet/_expected/amd/chunks/worklet.js index f96f283ad52..ea01ac8fb6b 100644 --- a/test/chunking-form/samples/emit-file/emit-chunk-worklet/_expected/amd/chunks/worklet.js +++ b/test/chunking-form/samples/emit-file/emit-chunk-worklet/_expected/amd/chunks/worklet.js @@ -1,4 +1,4 @@ -define(['./shared'], function (shared) { 'use strict'; +define(['./shared'], (function (shared) { 'use strict'; registerPaint( 'vertical-lines', @@ -14,4 +14,4 @@ define(['./shared'], function (shared) { 'use strict'; } ); -}); +})); diff --git a/test/chunking-form/samples/emit-file/emit-chunk-worklet/_expected/amd/main.js b/test/chunking-form/samples/emit-file/emit-chunk-worklet/_expected/amd/main.js index bf73a6f1543..d10bf642861 100644 --- a/test/chunking-form/samples/emit-file/emit-chunk-worklet/_expected/amd/main.js +++ b/test/chunking-form/samples/emit-file/emit-chunk-worklet/_expected/amd/main.js @@ -1,7 +1,7 @@ -define(['require', './chunks/shared'], function (require, shared) { 'use strict'; +define(['require', './chunks/shared'], (function (require, shared) { 'use strict'; CSS.paintWorklet.addModule(new URL(require.toUrl('./chunks/worklet.js'), document.baseURI).href); document.body.innerHTML += `

color: ${shared.color}, size: ${shared.size}

`; -}); +})); diff --git a/test/chunking-form/samples/emit-file/emit-chunk-worklet/_expected/cjs/main.js b/test/chunking-form/samples/emit-file/emit-chunk-worklet/_expected/cjs/main.js index 6ba79bfb0e6..98ae99aa4ca 100644 --- a/test/chunking-form/samples/emit-file/emit-chunk-worklet/_expected/cjs/main.js +++ b/test/chunking-form/samples/emit-file/emit-chunk-worklet/_expected/cjs/main.js @@ -2,6 +2,6 @@ var shared = require('./chunks/shared.js'); -CSS.paintWorklet.addModule((typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __dirname + '/chunks/worklet.js').href : new URL('chunks/worklet.js', document.currentScript && document.currentScript.src || document.baseURI).href)); +CSS.paintWorklet.addModule((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__dirname + '/chunks/worklet.js').href : new URL('chunks/worklet.js', document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT' && document.currentScript.src || document.baseURI).href)); document.body.innerHTML += `

color: ${shared.color}, size: ${shared.size}

`; diff --git a/test/chunking-form/samples/emit-file/emit-chunk-worklet/_expected/system/chunks/shared.js b/test/chunking-form/samples/emit-file/emit-chunk-worklet/_expected/system/chunks/shared.js index f348ef3f487..7060178db25 100644 --- a/test/chunking-form/samples/emit-file/emit-chunk-worklet/_expected/system/chunks/shared.js +++ b/test/chunking-form/samples/emit-file/emit-chunk-worklet/_expected/system/chunks/shared.js @@ -1,11 +1,11 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - const color = exports('c', 'greenyellow'); - const size = exports('s', 6); + const color = exports("c", 'greenyellow'); + const size = exports("s", 6); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/emit-file/emit-chunk-worklet/_expected/system/chunks/worklet.js b/test/chunking-form/samples/emit-file/emit-chunk-worklet/_expected/system/chunks/worklet.js index 9cb6055973e..88e721d4520 100644 --- a/test/chunking-form/samples/emit-file/emit-chunk-worklet/_expected/system/chunks/worklet.js +++ b/test/chunking-form/samples/emit-file/emit-chunk-worklet/_expected/system/chunks/worklet.js @@ -1,4 +1,4 @@ -System.register(['./shared.js'], function () { +System.register(['./shared.js'], (function () { 'use strict'; var size, color; return { @@ -6,7 +6,7 @@ System.register(['./shared.js'], function () { size = module.s; color = module.c; }], - execute: function () { + execute: (function () { registerPaint( 'vertical-lines', @@ -22,6 +22,6 @@ System.register(['./shared.js'], function () { } ); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/emit-file/emit-chunk-worklet/_expected/system/main.js b/test/chunking-form/samples/emit-file/emit-chunk-worklet/_expected/system/main.js index 3165374294e..69c57ed6000 100644 --- a/test/chunking-form/samples/emit-file/emit-chunk-worklet/_expected/system/main.js +++ b/test/chunking-form/samples/emit-file/emit-chunk-worklet/_expected/system/main.js @@ -1,4 +1,4 @@ -System.register(['./chunks/shared.js'], function (exports, module) { +System.register(['./chunks/shared.js'], (function (exports, module) { 'use strict'; var color, size; return { @@ -6,12 +6,12 @@ System.register(['./chunks/shared.js'], function (exports, module) { color = module.c; size = module.s; }], - execute: function () { + execute: (function () { CSS.paintWorklet.addModule(new URL('chunks/worklet.js', module.meta.url).href); document.body.innerHTML += `

color: ${color}, size: ${size}

`; - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/emit-file/emit-chunk/_config.js b/test/chunking-form/samples/emit-file/emit-chunk/_config.js index 2c6897b8235..14dbf9d2615 100644 --- a/test/chunking-form/samples/emit-file/emit-chunk/_config.js +++ b/test/chunking-form/samples/emit-file/emit-chunk/_config.js @@ -1,7 +1,7 @@ -const assert = require('assert'); +const assert = require('node:assert'); let referenceId; -module.exports = { +module.exports = defineTest({ description: 'allows adding additional chunks and retrieving their file name', options: { input: 'main', @@ -9,9 +9,17 @@ module.exports = { buildStart() { referenceId = this.emitFile({ type: 'chunk', id: 'buildStart' }); }, + resolveId(id) { + if (id === 'external') { + return { + id: "./ext'ernal", + external: true + }; + } + }, renderChunk() { assert.strictEqual(this.getFileName(referenceId), 'generated-buildStart.js'); } } } -}; +}); diff --git a/test/chunking-form/samples/emit-file/emit-chunk/_expected/amd/generated-buildStart.js b/test/chunking-form/samples/emit-file/emit-chunk/_expected/amd/generated-buildStart.js index 05dda0e01f3..041249b1410 100644 --- a/test/chunking-form/samples/emit-file/emit-chunk/_expected/amd/generated-buildStart.js +++ b/test/chunking-form/samples/emit-file/emit-chunk/_expected/amd/generated-buildStart.js @@ -1,5 +1,5 @@ -define(['./generated-dep'], function (dep) { 'use strict'; +define(['./generated-dep'], (function (dep) { 'use strict'; console.log('startBuild', dep.value); -}); +})); diff --git a/test/chunking-form/samples/emit-file/emit-chunk/_expected/amd/generated-dep.js b/test/chunking-form/samples/emit-file/emit-chunk/_expected/amd/generated-dep.js index 5e2f9f02968..d041b1d05f7 100644 --- a/test/chunking-form/samples/emit-file/emit-chunk/_expected/amd/generated-dep.js +++ b/test/chunking-form/samples/emit-file/emit-chunk/_expected/amd/generated-dep.js @@ -1,7 +1,7 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; var value = 42; exports.value = value; -}); +})); diff --git a/test/chunking-form/samples/emit-file/emit-chunk/_expected/amd/main.js b/test/chunking-form/samples/emit-file/emit-chunk/_expected/amd/main.js index 764805deda3..2c569ebaf8a 100644 --- a/test/chunking-form/samples/emit-file/emit-chunk/_expected/amd/main.js +++ b/test/chunking-form/samples/emit-file/emit-chunk/_expected/amd/main.js @@ -1,5 +1,24 @@ -define(['./generated-dep'], function (dep) { 'use strict'; +define(['require', './generated-dep'], (function (require, dep) { 'use strict'; + + function _interopNamespaceDefault(e) { + var n = Object.create(null); + if (e) { + Object.keys(e).forEach(function (k) { + if (k !== 'default') { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + } + n.default = e; + return Object.freeze(n); + } + + new Promise(function (resolve, reject) { require(['./ext\'ernal'], function (m) { resolve(/*#__PURE__*/_interopNamespaceDefault(m)); }, reject); }); console.log('main', dep.value); -}); +})); diff --git a/test/chunking-form/samples/emit-file/emit-chunk/_expected/cjs/main.js b/test/chunking-form/samples/emit-file/emit-chunk/_expected/cjs/main.js index 4c79b32a701..b442767c9b7 100644 --- a/test/chunking-form/samples/emit-file/emit-chunk/_expected/cjs/main.js +++ b/test/chunking-form/samples/emit-file/emit-chunk/_expected/cjs/main.js @@ -2,4 +2,6 @@ var dep = require('./generated-dep.js'); +import('./ext\'ernal'); + console.log('main', dep.value); diff --git a/test/chunking-form/samples/emit-file/emit-chunk/_expected/es/main.js b/test/chunking-form/samples/emit-file/emit-chunk/_expected/es/main.js index da4e855f39a..560042f87c6 100644 --- a/test/chunking-form/samples/emit-file/emit-chunk/_expected/es/main.js +++ b/test/chunking-form/samples/emit-file/emit-chunk/_expected/es/main.js @@ -1,3 +1,5 @@ import { v as value } from './generated-dep.js'; +import('./ext\'ernal'); + console.log('main', value); diff --git a/test/chunking-form/samples/emit-file/emit-chunk/_expected/system/generated-buildStart.js b/test/chunking-form/samples/emit-file/emit-chunk/_expected/system/generated-buildStart.js index 08465151e63..12a2c642f50 100644 --- a/test/chunking-form/samples/emit-file/emit-chunk/_expected/system/generated-buildStart.js +++ b/test/chunking-form/samples/emit-file/emit-chunk/_expected/system/generated-buildStart.js @@ -1,14 +1,14 @@ -System.register(['./generated-dep.js'], function () { +System.register(['./generated-dep.js'], (function () { 'use strict'; var value; return { setters: [function (module) { value = module.v; }], - execute: function () { + execute: (function () { console.log('startBuild', value); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/emit-file/emit-chunk/_expected/system/generated-dep.js b/test/chunking-form/samples/emit-file/emit-chunk/_expected/system/generated-dep.js index e69dcc529da..cfb9c05fd92 100644 --- a/test/chunking-form/samples/emit-file/emit-chunk/_expected/system/generated-dep.js +++ b/test/chunking-form/samples/emit-file/emit-chunk/_expected/system/generated-dep.js @@ -1,10 +1,10 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - var value = exports('v', 42); + var value = exports("v", 42); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/emit-file/emit-chunk/_expected/system/main.js b/test/chunking-form/samples/emit-file/emit-chunk/_expected/system/main.js index 13eec5478ac..7793aad0bf1 100644 --- a/test/chunking-form/samples/emit-file/emit-chunk/_expected/system/main.js +++ b/test/chunking-form/samples/emit-file/emit-chunk/_expected/system/main.js @@ -1,14 +1,16 @@ -System.register(['./generated-dep.js'], function () { +System.register(['./generated-dep.js'], (function (exports, module) { 'use strict'; var value; return { setters: [function (module) { value = module.v; }], - execute: function () { + execute: (function () { + + module.import('./ext\'ernal'); console.log('main', value); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/emit-file/emit-chunk/main.js b/test/chunking-form/samples/emit-file/emit-chunk/main.js index 4a9b3a3f405..9f4f49895e2 100644 --- a/test/chunking-form/samples/emit-file/emit-chunk/main.js +++ b/test/chunking-form/samples/emit-file/emit-chunk/main.js @@ -1,3 +1,4 @@ import value from './dep.js'; +import('external'); console.log('main', value); diff --git a/test/chunking-form/samples/emit-file/emits-existing-chunk/_config.js b/test/chunking-form/samples/emit-file/emits-existing-chunk/_config.js index 404461da95e..a7e3a49dc43 100644 --- a/test/chunking-form/samples/emit-file/emits-existing-chunk/_config.js +++ b/test/chunking-form/samples/emit-file/emits-existing-chunk/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'allows adding modules already in the graph as entry points', options: { input: { @@ -16,4 +16,4 @@ module.exports = { } } } -}; +}); diff --git a/test/chunking-form/samples/emit-file/emits-existing-chunk/_expected/amd/first-main.js b/test/chunking-form/samples/emit-file/emits-existing-chunk/_expected/amd/first-main.js index fd823ca54c7..05e4663fb8f 100644 --- a/test/chunking-form/samples/emit-file/emits-existing-chunk/_expected/amd/first-main.js +++ b/test/chunking-form/samples/emit-file/emits-existing-chunk/_expected/amd/first-main.js @@ -1,5 +1,5 @@ -define(['./generated-dep'], function (dep) { 'use strict'; +define(['./generated-dep'], (function (dep) { 'use strict'; console.log('main1', dep); -}); +})); diff --git a/test/chunking-form/samples/emit-file/emits-existing-chunk/_expected/amd/generated-dep.js b/test/chunking-form/samples/emit-file/emits-existing-chunk/_expected/amd/generated-dep.js index e14fcf80133..918ffcbca16 100644 --- a/test/chunking-form/samples/emit-file/emits-existing-chunk/_expected/amd/generated-dep.js +++ b/test/chunking-form/samples/emit-file/emits-existing-chunk/_expected/amd/generated-dep.js @@ -1,7 +1,7 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; var value = 42; return value; -}); +})); diff --git a/test/chunking-form/samples/emit-file/emits-existing-chunk/_expected/amd/second-main.js b/test/chunking-form/samples/emit-file/emits-existing-chunk/_expected/amd/second-main.js index fd823ca54c7..05e4663fb8f 100644 --- a/test/chunking-form/samples/emit-file/emits-existing-chunk/_expected/amd/second-main.js +++ b/test/chunking-form/samples/emit-file/emits-existing-chunk/_expected/amd/second-main.js @@ -1,5 +1,5 @@ -define(['./generated-dep'], function (dep) { 'use strict'; +define(['./generated-dep'], (function (dep) { 'use strict'; console.log('main1', dep); -}); +})); diff --git a/test/chunking-form/samples/emit-file/emits-existing-chunk/_expected/es/generated-dep.js b/test/chunking-form/samples/emit-file/emits-existing-chunk/_expected/es/generated-dep.js index 630536069ae..47d1cc6ec49 100644 --- a/test/chunking-form/samples/emit-file/emits-existing-chunk/_expected/es/generated-dep.js +++ b/test/chunking-form/samples/emit-file/emits-existing-chunk/_expected/es/generated-dep.js @@ -1,3 +1,3 @@ var value = 42; -export default value; +export { value as default }; diff --git a/test/chunking-form/samples/emit-file/emits-existing-chunk/_expected/system/first-main.js b/test/chunking-form/samples/emit-file/emits-existing-chunk/_expected/system/first-main.js index 80f3e6cfee2..960886321bc 100644 --- a/test/chunking-form/samples/emit-file/emits-existing-chunk/_expected/system/first-main.js +++ b/test/chunking-form/samples/emit-file/emits-existing-chunk/_expected/system/first-main.js @@ -1,14 +1,14 @@ -System.register(['./generated-dep.js'], function () { +System.register(['./generated-dep.js'], (function () { 'use strict'; var value; return { setters: [function (module) { value = module.default; }], - execute: function () { + execute: (function () { console.log('main1', value); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/emit-file/emits-existing-chunk/_expected/system/generated-dep.js b/test/chunking-form/samples/emit-file/emits-existing-chunk/_expected/system/generated-dep.js index 9cb117a6246..e717203f3e0 100644 --- a/test/chunking-form/samples/emit-file/emits-existing-chunk/_expected/system/generated-dep.js +++ b/test/chunking-form/samples/emit-file/emits-existing-chunk/_expected/system/generated-dep.js @@ -1,10 +1,10 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - var value = exports('default', 42); + var value = exports("default", 42); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/emit-file/emits-existing-chunk/_expected/system/second-main.js b/test/chunking-form/samples/emit-file/emits-existing-chunk/_expected/system/second-main.js index 80f3e6cfee2..960886321bc 100644 --- a/test/chunking-form/samples/emit-file/emits-existing-chunk/_expected/system/second-main.js +++ b/test/chunking-form/samples/emit-file/emits-existing-chunk/_expected/system/second-main.js @@ -1,14 +1,14 @@ -System.register(['./generated-dep.js'], function () { +System.register(['./generated-dep.js'], (function () { 'use strict'; var value; return { setters: [function (module) { value = module.default; }], - execute: function () { + execute: (function () { console.log('main1', value); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_config.js b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_config.js index 25e3d03dcaa..abd31580334 100644 --- a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_config.js +++ b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_config.js @@ -1,60 +1,84 @@ -module.exports = { +module.exports = defineTest({ description: 'supports emitting assets from plugin hooks', options: { input: ['main.js'], plugins: { buildStart() { this.emitFile({ type: 'asset', name: 'buildStart.txt', source: 'buildStart' }); - this.emitFile({ type: 'asset', fileName: 'custom/buildStart.txt', source: 'buildStart' }); + this.emitFile({ + type: 'asset', + fileName: 'custom/buildStart.txt', + source: 'buildStart-custom' + }); }, resolveId() { this.emitFile({ type: 'asset', name: 'resolveId.txt', source: 'resolveId' }); - this.emitFile({ type: 'asset', fileName: 'custom/resolveId.txt', source: 'resolveId' }); + this.emitFile({ + type: 'asset', + fileName: 'custom/resolveId.txt', + source: 'resolveId-custom' + }); }, load() { this.emitFile({ type: 'asset', name: 'load.txt', source: 'load' }); - this.emitFile({ type: 'asset', fileName: 'custom/load.txt', source: 'load' }); + this.emitFile({ type: 'asset', fileName: 'custom/load.txt', source: 'load-custom' }); }, transform() { this.emitFile({ type: 'asset', name: 'transform.txt', source: 'transform' }); - this.emitFile({ type: 'asset', fileName: 'custom/transform.txt', source: 'transform' }); + this.emitFile({ + type: 'asset', + fileName: 'custom/transform.txt', + source: 'transform-custom' + }); }, buildEnd() { this.emitFile({ type: 'asset', name: 'buildEnd.txt', source: 'buildEnd' }); - this.emitFile({ type: 'asset', fileName: 'custom/buildEnd.txt', source: 'buildEnd' }); + this.emitFile({ + type: 'asset', + fileName: 'custom/buildEnd.txt', + source: 'buildEnd-custom' + }); }, renderStart() { this.emitFile({ type: 'asset', name: 'renderStart.txt', source: 'renderStart' }); - this.emitFile({ type: 'asset', fileName: 'custom/renderStart.txt', source: 'renderStart' }); + this.emitFile({ + type: 'asset', + fileName: 'custom/renderStart.txt', + source: 'renderStart-custom' + }); }, banner() { this.emitFile({ type: 'asset', name: 'banner.txt', source: 'banner' }); - this.emitFile({ type: 'asset', fileName: 'custom/banner.txt', source: 'banner' }); + this.emitFile({ type: 'asset', fileName: 'custom/banner.txt', source: 'banner-custom' }); }, footer() { this.emitFile({ type: 'asset', name: 'footer.txt', source: 'footer' }); - this.emitFile({ type: 'asset', fileName: 'custom/footer.txt', source: 'footer' }); + this.emitFile({ type: 'asset', fileName: 'custom/footer.txt', source: 'footer-custom' }); }, intro() { this.emitFile({ type: 'asset', name: 'intro.txt', source: 'intro' }); - this.emitFile({ type: 'asset', fileName: 'custom/intro.txt', source: 'intro' }); + this.emitFile({ type: 'asset', fileName: 'custom/intro.txt', source: 'intro-custom' }); }, outro() { this.emitFile({ type: 'asset', name: 'outro.txt', source: 'outro' }); - this.emitFile({ type: 'asset', fileName: 'custom/outro.txt', source: 'outro' }); + this.emitFile({ type: 'asset', fileName: 'custom/outro.txt', source: 'outro-custom' }); }, renderChunk() { this.emitFile({ type: 'asset', name: 'renderChunk.txt', source: 'renderChunk' }); - this.emitFile({ type: 'asset', fileName: 'custom/renderChunk.txt', source: 'renderChunk' }); + this.emitFile({ + type: 'asset', + fileName: 'custom/renderChunk.txt', + source: 'renderChunk-custom' + }); }, generateBundle() { this.emitFile({ type: 'asset', name: 'generateBundle.txt', source: 'generateBundle' }); this.emitFile({ type: 'asset', fileName: 'custom/generateBundle.txt', - source: 'generateBundle' + source: 'generateBundle-custom' }); } } } -}; +}); diff --git a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/amd/assets/banner-2b65cc0c.txt b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/amd/assets/banner--qPJuKPL.txt similarity index 100% rename from test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/amd/assets/banner-2b65cc0c.txt rename to test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/amd/assets/banner--qPJuKPL.txt diff --git a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/amd/assets/buildEnd-4678f17a.txt b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/amd/assets/buildEnd-BuNl-RZp.txt similarity index 100% rename from test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/amd/assets/buildEnd-4678f17a.txt rename to test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/amd/assets/buildEnd-BuNl-RZp.txt diff --git a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/amd/assets/buildStart-5b740828.txt b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/amd/assets/buildStart-CNSwBoeG.txt similarity index 100% rename from test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/amd/assets/buildStart-5b740828.txt rename to test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/amd/assets/buildStart-CNSwBoeG.txt diff --git a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/amd/assets/footer-e1d2fccb.txt b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/amd/assets/footer-CV6kYft-.txt similarity index 100% rename from test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/amd/assets/footer-e1d2fccb.txt rename to test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/amd/assets/footer-CV6kYft-.txt diff --git a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/amd/assets/generateBundle-22413744.txt b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/amd/assets/generateBundle-BgLkrkio.txt similarity index 100% rename from test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/amd/assets/generateBundle-22413744.txt rename to test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/amd/assets/generateBundle-BgLkrkio.txt diff --git a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/amd/assets/intro-520a8116.txt b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/amd/assets/intro-1PpQv4h6.txt similarity index 100% rename from test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/amd/assets/intro-520a8116.txt rename to test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/amd/assets/intro-1PpQv4h6.txt diff --git a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/amd/assets/load-a4cc2865.txt b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/amd/assets/load-B_kSChOq.txt similarity index 100% rename from test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/amd/assets/load-a4cc2865.txt rename to test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/amd/assets/load-B_kSChOq.txt diff --git a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/amd/assets/outro-21f77720.txt b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/amd/assets/outro-D8xwWt8B.txt similarity index 100% rename from test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/amd/assets/outro-21f77720.txt rename to test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/amd/assets/outro-D8xwWt8B.txt diff --git a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/amd/assets/renderChunk-a91c7c32.txt b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/amd/assets/renderChunk-MxjJNaqP.txt similarity index 100% rename from test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/amd/assets/renderChunk-a91c7c32.txt rename to test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/amd/assets/renderChunk-MxjJNaqP.txt diff --git a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/amd/assets/renderStart-66600c78.txt b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/amd/assets/renderStart-B4XObdBk.txt similarity index 100% rename from test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/amd/assets/renderStart-66600c78.txt rename to test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/amd/assets/renderStart-B4XObdBk.txt diff --git a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/amd/assets/resolveId-6d8063a5.txt b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/amd/assets/resolveId-CCjw2RsL.txt similarity index 100% rename from test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/amd/assets/resolveId-6d8063a5.txt rename to test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/amd/assets/resolveId-CCjw2RsL.txt diff --git a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/amd/assets/transform-d49df25a.txt b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/amd/assets/transform-9DaiUiOT.txt similarity index 100% rename from test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/amd/assets/transform-d49df25a.txt rename to test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/amd/assets/transform-9DaiUiOT.txt diff --git a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/amd/custom/banner.txt b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/amd/custom/banner.txt index 12577274ecd..b64fd741450 100644 --- a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/amd/custom/banner.txt +++ b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/amd/custom/banner.txt @@ -1 +1 @@ -banner \ No newline at end of file +banner-custom \ No newline at end of file diff --git a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/amd/custom/buildEnd.txt b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/amd/custom/buildEnd.txt index bbb07acb9fc..845ccdb645d 100644 --- a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/amd/custom/buildEnd.txt +++ b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/amd/custom/buildEnd.txt @@ -1 +1 @@ -buildEnd \ No newline at end of file +buildEnd-custom \ No newline at end of file diff --git a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/amd/custom/buildStart.txt b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/amd/custom/buildStart.txt index 0cb77258e0a..e45aee41d15 100644 --- a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/amd/custom/buildStart.txt +++ b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/amd/custom/buildStart.txt @@ -1 +1 @@ -buildStart \ No newline at end of file +buildStart-custom \ No newline at end of file diff --git a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/amd/custom/footer.txt b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/amd/custom/footer.txt index a56ca533272..8c589a50af2 100644 --- a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/amd/custom/footer.txt +++ b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/amd/custom/footer.txt @@ -1 +1 @@ -footer \ No newline at end of file +footer-custom \ No newline at end of file diff --git a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/amd/custom/generateBundle.txt b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/amd/custom/generateBundle.txt index de472563b28..155523bd6b3 100644 --- a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/amd/custom/generateBundle.txt +++ b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/amd/custom/generateBundle.txt @@ -1 +1 @@ -generateBundle \ No newline at end of file +generateBundle-custom \ No newline at end of file diff --git a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/amd/custom/intro.txt b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/amd/custom/intro.txt index 29fbe946bf9..3e663da2b46 100644 --- a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/amd/custom/intro.txt +++ b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/amd/custom/intro.txt @@ -1 +1 @@ -intro \ No newline at end of file +intro-custom \ No newline at end of file diff --git a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/amd/custom/load.txt b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/amd/custom/load.txt index 024e67c1f24..7bac7254119 100644 --- a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/amd/custom/load.txt +++ b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/amd/custom/load.txt @@ -1 +1 @@ -load \ No newline at end of file +load-custom \ No newline at end of file diff --git a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/amd/custom/outro.txt b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/amd/custom/outro.txt index 31035209b9e..77a881ecde8 100644 --- a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/amd/custom/outro.txt +++ b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/amd/custom/outro.txt @@ -1 +1 @@ -outro \ No newline at end of file +outro-custom \ No newline at end of file diff --git a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/amd/custom/renderChunk.txt b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/amd/custom/renderChunk.txt index 22f947650b0..3930812883e 100644 --- a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/amd/custom/renderChunk.txt +++ b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/amd/custom/renderChunk.txt @@ -1 +1 @@ -renderChunk \ No newline at end of file +renderChunk-custom \ No newline at end of file diff --git a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/amd/custom/renderStart.txt b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/amd/custom/renderStart.txt index 3cdc0005056..a3d2c08e3fb 100644 --- a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/amd/custom/renderStart.txt +++ b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/amd/custom/renderStart.txt @@ -1 +1 @@ -renderStart \ No newline at end of file +renderStart-custom \ No newline at end of file diff --git a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/amd/custom/resolveId.txt b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/amd/custom/resolveId.txt index 53029113abd..7286bfbd602 100644 --- a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/amd/custom/resolveId.txt +++ b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/amd/custom/resolveId.txt @@ -1 +1 @@ -resolveId \ No newline at end of file +resolveId-custom \ No newline at end of file diff --git a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/amd/custom/transform.txt b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/amd/custom/transform.txt index 3f001116657..ce2fb1d6c39 100644 --- a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/amd/custom/transform.txt +++ b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/amd/custom/transform.txt @@ -1 +1 @@ -transform \ No newline at end of file +transform-custom \ No newline at end of file diff --git a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/amd/main.js b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/amd/main.js index 126aa22ee83..49540b44d78 100644 --- a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/amd/main.js +++ b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/amd/main.js @@ -1,5 +1,5 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; console.log('main'); -}); +})); diff --git a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/cjs/assets/banner-2b65cc0c.txt b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/cjs/assets/banner--qPJuKPL.txt similarity index 100% rename from test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/cjs/assets/banner-2b65cc0c.txt rename to test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/cjs/assets/banner--qPJuKPL.txt diff --git a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/cjs/assets/buildEnd-4678f17a.txt b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/cjs/assets/buildEnd-BuNl-RZp.txt similarity index 100% rename from test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/cjs/assets/buildEnd-4678f17a.txt rename to test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/cjs/assets/buildEnd-BuNl-RZp.txt diff --git a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/cjs/assets/buildStart-5b740828.txt b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/cjs/assets/buildStart-CNSwBoeG.txt similarity index 100% rename from test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/cjs/assets/buildStart-5b740828.txt rename to test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/cjs/assets/buildStart-CNSwBoeG.txt diff --git a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/cjs/assets/footer-e1d2fccb.txt b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/cjs/assets/footer-CV6kYft-.txt similarity index 100% rename from test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/cjs/assets/footer-e1d2fccb.txt rename to test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/cjs/assets/footer-CV6kYft-.txt diff --git a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/cjs/assets/generateBundle-22413744.txt b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/cjs/assets/generateBundle-BgLkrkio.txt similarity index 100% rename from test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/cjs/assets/generateBundle-22413744.txt rename to test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/cjs/assets/generateBundle-BgLkrkio.txt diff --git a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/cjs/assets/intro-520a8116.txt b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/cjs/assets/intro-1PpQv4h6.txt similarity index 100% rename from test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/cjs/assets/intro-520a8116.txt rename to test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/cjs/assets/intro-1PpQv4h6.txt diff --git a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/cjs/assets/load-a4cc2865.txt b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/cjs/assets/load-B_kSChOq.txt similarity index 100% rename from test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/cjs/assets/load-a4cc2865.txt rename to test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/cjs/assets/load-B_kSChOq.txt diff --git a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/cjs/assets/outro-21f77720.txt b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/cjs/assets/outro-D8xwWt8B.txt similarity index 100% rename from test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/cjs/assets/outro-21f77720.txt rename to test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/cjs/assets/outro-D8xwWt8B.txt diff --git a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/cjs/assets/renderChunk-a91c7c32.txt b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/cjs/assets/renderChunk-MxjJNaqP.txt similarity index 100% rename from test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/cjs/assets/renderChunk-a91c7c32.txt rename to test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/cjs/assets/renderChunk-MxjJNaqP.txt diff --git a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/cjs/assets/renderStart-66600c78.txt b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/cjs/assets/renderStart-B4XObdBk.txt similarity index 100% rename from test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/cjs/assets/renderStart-66600c78.txt rename to test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/cjs/assets/renderStart-B4XObdBk.txt diff --git a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/cjs/assets/resolveId-6d8063a5.txt b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/cjs/assets/resolveId-CCjw2RsL.txt similarity index 100% rename from test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/cjs/assets/resolveId-6d8063a5.txt rename to test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/cjs/assets/resolveId-CCjw2RsL.txt diff --git a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/cjs/assets/transform-d49df25a.txt b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/cjs/assets/transform-9DaiUiOT.txt similarity index 100% rename from test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/cjs/assets/transform-d49df25a.txt rename to test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/cjs/assets/transform-9DaiUiOT.txt diff --git a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/cjs/custom/banner.txt b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/cjs/custom/banner.txt index 12577274ecd..b64fd741450 100644 --- a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/cjs/custom/banner.txt +++ b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/cjs/custom/banner.txt @@ -1 +1 @@ -banner \ No newline at end of file +banner-custom \ No newline at end of file diff --git a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/cjs/custom/buildEnd.txt b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/cjs/custom/buildEnd.txt index bbb07acb9fc..845ccdb645d 100644 --- a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/cjs/custom/buildEnd.txt +++ b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/cjs/custom/buildEnd.txt @@ -1 +1 @@ -buildEnd \ No newline at end of file +buildEnd-custom \ No newline at end of file diff --git a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/cjs/custom/buildStart.txt b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/cjs/custom/buildStart.txt index 0cb77258e0a..e45aee41d15 100644 --- a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/cjs/custom/buildStart.txt +++ b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/cjs/custom/buildStart.txt @@ -1 +1 @@ -buildStart \ No newline at end of file +buildStart-custom \ No newline at end of file diff --git a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/cjs/custom/footer.txt b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/cjs/custom/footer.txt index a56ca533272..8c589a50af2 100644 --- a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/cjs/custom/footer.txt +++ b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/cjs/custom/footer.txt @@ -1 +1 @@ -footer \ No newline at end of file +footer-custom \ No newline at end of file diff --git a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/cjs/custom/generateBundle.txt b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/cjs/custom/generateBundle.txt index de472563b28..155523bd6b3 100644 --- a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/cjs/custom/generateBundle.txt +++ b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/cjs/custom/generateBundle.txt @@ -1 +1 @@ -generateBundle \ No newline at end of file +generateBundle-custom \ No newline at end of file diff --git a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/cjs/custom/intro.txt b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/cjs/custom/intro.txt index 29fbe946bf9..3e663da2b46 100644 --- a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/cjs/custom/intro.txt +++ b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/cjs/custom/intro.txt @@ -1 +1 @@ -intro \ No newline at end of file +intro-custom \ No newline at end of file diff --git a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/cjs/custom/load.txt b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/cjs/custom/load.txt index 024e67c1f24..7bac7254119 100644 --- a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/cjs/custom/load.txt +++ b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/cjs/custom/load.txt @@ -1 +1 @@ -load \ No newline at end of file +load-custom \ No newline at end of file diff --git a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/cjs/custom/outro.txt b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/cjs/custom/outro.txt index 31035209b9e..77a881ecde8 100644 --- a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/cjs/custom/outro.txt +++ b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/cjs/custom/outro.txt @@ -1 +1 @@ -outro \ No newline at end of file +outro-custom \ No newline at end of file diff --git a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/cjs/custom/renderChunk.txt b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/cjs/custom/renderChunk.txt index 22f947650b0..3930812883e 100644 --- a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/cjs/custom/renderChunk.txt +++ b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/cjs/custom/renderChunk.txt @@ -1 +1 @@ -renderChunk \ No newline at end of file +renderChunk-custom \ No newline at end of file diff --git a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/cjs/custom/renderStart.txt b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/cjs/custom/renderStart.txt index 3cdc0005056..a3d2c08e3fb 100644 --- a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/cjs/custom/renderStart.txt +++ b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/cjs/custom/renderStart.txt @@ -1 +1 @@ -renderStart \ No newline at end of file +renderStart-custom \ No newline at end of file diff --git a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/cjs/custom/resolveId.txt b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/cjs/custom/resolveId.txt index 53029113abd..7286bfbd602 100644 --- a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/cjs/custom/resolveId.txt +++ b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/cjs/custom/resolveId.txt @@ -1 +1 @@ -resolveId \ No newline at end of file +resolveId-custom \ No newline at end of file diff --git a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/cjs/custom/transform.txt b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/cjs/custom/transform.txt index 3f001116657..ce2fb1d6c39 100644 --- a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/cjs/custom/transform.txt +++ b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/cjs/custom/transform.txt @@ -1 +1 @@ -transform \ No newline at end of file +transform-custom \ No newline at end of file diff --git a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/es/assets/banner-2b65cc0c.txt b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/es/assets/banner--qPJuKPL.txt similarity index 100% rename from test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/es/assets/banner-2b65cc0c.txt rename to test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/es/assets/banner--qPJuKPL.txt diff --git a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/es/assets/buildEnd-4678f17a.txt b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/es/assets/buildEnd-BuNl-RZp.txt similarity index 100% rename from test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/es/assets/buildEnd-4678f17a.txt rename to test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/es/assets/buildEnd-BuNl-RZp.txt diff --git a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/es/assets/buildStart-5b740828.txt b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/es/assets/buildStart-CNSwBoeG.txt similarity index 100% rename from test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/es/assets/buildStart-5b740828.txt rename to test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/es/assets/buildStart-CNSwBoeG.txt diff --git a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/es/assets/footer-e1d2fccb.txt b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/es/assets/footer-CV6kYft-.txt similarity index 100% rename from test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/es/assets/footer-e1d2fccb.txt rename to test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/es/assets/footer-CV6kYft-.txt diff --git a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/es/assets/generateBundle-22413744.txt b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/es/assets/generateBundle-BgLkrkio.txt similarity index 100% rename from test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/es/assets/generateBundle-22413744.txt rename to test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/es/assets/generateBundle-BgLkrkio.txt diff --git a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/es/assets/intro-520a8116.txt b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/es/assets/intro-1PpQv4h6.txt similarity index 100% rename from test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/es/assets/intro-520a8116.txt rename to test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/es/assets/intro-1PpQv4h6.txt diff --git a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/es/assets/load-a4cc2865.txt b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/es/assets/load-B_kSChOq.txt similarity index 100% rename from test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/es/assets/load-a4cc2865.txt rename to test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/es/assets/load-B_kSChOq.txt diff --git a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/es/assets/outro-21f77720.txt b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/es/assets/outro-D8xwWt8B.txt similarity index 100% rename from test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/es/assets/outro-21f77720.txt rename to test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/es/assets/outro-D8xwWt8B.txt diff --git a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/es/assets/renderChunk-a91c7c32.txt b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/es/assets/renderChunk-MxjJNaqP.txt similarity index 100% rename from test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/es/assets/renderChunk-a91c7c32.txt rename to test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/es/assets/renderChunk-MxjJNaqP.txt diff --git a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/es/assets/renderStart-66600c78.txt b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/es/assets/renderStart-B4XObdBk.txt similarity index 100% rename from test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/es/assets/renderStart-66600c78.txt rename to test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/es/assets/renderStart-B4XObdBk.txt diff --git a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/es/assets/resolveId-6d8063a5.txt b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/es/assets/resolveId-CCjw2RsL.txt similarity index 100% rename from test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/es/assets/resolveId-6d8063a5.txt rename to test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/es/assets/resolveId-CCjw2RsL.txt diff --git a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/es/assets/transform-d49df25a.txt b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/es/assets/transform-9DaiUiOT.txt similarity index 100% rename from test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/es/assets/transform-d49df25a.txt rename to test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/es/assets/transform-9DaiUiOT.txt diff --git a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/es/custom/banner.txt b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/es/custom/banner.txt index 12577274ecd..b64fd741450 100644 --- a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/es/custom/banner.txt +++ b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/es/custom/banner.txt @@ -1 +1 @@ -banner \ No newline at end of file +banner-custom \ No newline at end of file diff --git a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/es/custom/buildEnd.txt b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/es/custom/buildEnd.txt index bbb07acb9fc..845ccdb645d 100644 --- a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/es/custom/buildEnd.txt +++ b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/es/custom/buildEnd.txt @@ -1 +1 @@ -buildEnd \ No newline at end of file +buildEnd-custom \ No newline at end of file diff --git a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/es/custom/buildStart.txt b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/es/custom/buildStart.txt index 0cb77258e0a..e45aee41d15 100644 --- a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/es/custom/buildStart.txt +++ b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/es/custom/buildStart.txt @@ -1 +1 @@ -buildStart \ No newline at end of file +buildStart-custom \ No newline at end of file diff --git a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/es/custom/footer.txt b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/es/custom/footer.txt index a56ca533272..8c589a50af2 100644 --- a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/es/custom/footer.txt +++ b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/es/custom/footer.txt @@ -1 +1 @@ -footer \ No newline at end of file +footer-custom \ No newline at end of file diff --git a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/es/custom/generateBundle.txt b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/es/custom/generateBundle.txt index de472563b28..155523bd6b3 100644 --- a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/es/custom/generateBundle.txt +++ b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/es/custom/generateBundle.txt @@ -1 +1 @@ -generateBundle \ No newline at end of file +generateBundle-custom \ No newline at end of file diff --git a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/es/custom/intro.txt b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/es/custom/intro.txt index 29fbe946bf9..3e663da2b46 100644 --- a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/es/custom/intro.txt +++ b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/es/custom/intro.txt @@ -1 +1 @@ -intro \ No newline at end of file +intro-custom \ No newline at end of file diff --git a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/es/custom/load.txt b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/es/custom/load.txt index 024e67c1f24..7bac7254119 100644 --- a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/es/custom/load.txt +++ b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/es/custom/load.txt @@ -1 +1 @@ -load \ No newline at end of file +load-custom \ No newline at end of file diff --git a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/es/custom/outro.txt b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/es/custom/outro.txt index 31035209b9e..77a881ecde8 100644 --- a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/es/custom/outro.txt +++ b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/es/custom/outro.txt @@ -1 +1 @@ -outro \ No newline at end of file +outro-custom \ No newline at end of file diff --git a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/es/custom/renderChunk.txt b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/es/custom/renderChunk.txt index 22f947650b0..3930812883e 100644 --- a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/es/custom/renderChunk.txt +++ b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/es/custom/renderChunk.txt @@ -1 +1 @@ -renderChunk \ No newline at end of file +renderChunk-custom \ No newline at end of file diff --git a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/es/custom/renderStart.txt b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/es/custom/renderStart.txt index 3cdc0005056..a3d2c08e3fb 100644 --- a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/es/custom/renderStart.txt +++ b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/es/custom/renderStart.txt @@ -1 +1 @@ -renderStart \ No newline at end of file +renderStart-custom \ No newline at end of file diff --git a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/es/custom/resolveId.txt b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/es/custom/resolveId.txt index 53029113abd..7286bfbd602 100644 --- a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/es/custom/resolveId.txt +++ b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/es/custom/resolveId.txt @@ -1 +1 @@ -resolveId \ No newline at end of file +resolveId-custom \ No newline at end of file diff --git a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/es/custom/transform.txt b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/es/custom/transform.txt index 3f001116657..ce2fb1d6c39 100644 --- a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/es/custom/transform.txt +++ b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/es/custom/transform.txt @@ -1 +1 @@ -transform \ No newline at end of file +transform-custom \ No newline at end of file diff --git a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/system/assets/banner-2b65cc0c.txt b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/system/assets/banner--qPJuKPL.txt similarity index 100% rename from test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/system/assets/banner-2b65cc0c.txt rename to test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/system/assets/banner--qPJuKPL.txt diff --git a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/system/assets/buildEnd-4678f17a.txt b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/system/assets/buildEnd-BuNl-RZp.txt similarity index 100% rename from test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/system/assets/buildEnd-4678f17a.txt rename to test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/system/assets/buildEnd-BuNl-RZp.txt diff --git a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/system/assets/buildStart-5b740828.txt b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/system/assets/buildStart-CNSwBoeG.txt similarity index 100% rename from test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/system/assets/buildStart-5b740828.txt rename to test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/system/assets/buildStart-CNSwBoeG.txt diff --git a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/system/assets/footer-e1d2fccb.txt b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/system/assets/footer-CV6kYft-.txt similarity index 100% rename from test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/system/assets/footer-e1d2fccb.txt rename to test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/system/assets/footer-CV6kYft-.txt diff --git a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/system/assets/generateBundle-22413744.txt b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/system/assets/generateBundle-BgLkrkio.txt similarity index 100% rename from test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/system/assets/generateBundle-22413744.txt rename to test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/system/assets/generateBundle-BgLkrkio.txt diff --git a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/system/assets/intro-520a8116.txt b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/system/assets/intro-1PpQv4h6.txt similarity index 100% rename from test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/system/assets/intro-520a8116.txt rename to test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/system/assets/intro-1PpQv4h6.txt diff --git a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/system/assets/load-a4cc2865.txt b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/system/assets/load-B_kSChOq.txt similarity index 100% rename from test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/system/assets/load-a4cc2865.txt rename to test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/system/assets/load-B_kSChOq.txt diff --git a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/system/assets/outro-21f77720.txt b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/system/assets/outro-D8xwWt8B.txt similarity index 100% rename from test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/system/assets/outro-21f77720.txt rename to test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/system/assets/outro-D8xwWt8B.txt diff --git a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/system/assets/renderChunk-a91c7c32.txt b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/system/assets/renderChunk-MxjJNaqP.txt similarity index 100% rename from test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/system/assets/renderChunk-a91c7c32.txt rename to test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/system/assets/renderChunk-MxjJNaqP.txt diff --git a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/system/assets/renderStart-66600c78.txt b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/system/assets/renderStart-B4XObdBk.txt similarity index 100% rename from test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/system/assets/renderStart-66600c78.txt rename to test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/system/assets/renderStart-B4XObdBk.txt diff --git a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/system/assets/resolveId-6d8063a5.txt b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/system/assets/resolveId-CCjw2RsL.txt similarity index 100% rename from test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/system/assets/resolveId-6d8063a5.txt rename to test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/system/assets/resolveId-CCjw2RsL.txt diff --git a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/system/assets/transform-d49df25a.txt b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/system/assets/transform-9DaiUiOT.txt similarity index 100% rename from test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/system/assets/transform-d49df25a.txt rename to test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/system/assets/transform-9DaiUiOT.txt diff --git a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/system/custom/banner.txt b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/system/custom/banner.txt index 12577274ecd..b64fd741450 100644 --- a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/system/custom/banner.txt +++ b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/system/custom/banner.txt @@ -1 +1 @@ -banner \ No newline at end of file +banner-custom \ No newline at end of file diff --git a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/system/custom/buildEnd.txt b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/system/custom/buildEnd.txt index bbb07acb9fc..845ccdb645d 100644 --- a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/system/custom/buildEnd.txt +++ b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/system/custom/buildEnd.txt @@ -1 +1 @@ -buildEnd \ No newline at end of file +buildEnd-custom \ No newline at end of file diff --git a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/system/custom/buildStart.txt b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/system/custom/buildStart.txt index 0cb77258e0a..e45aee41d15 100644 --- a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/system/custom/buildStart.txt +++ b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/system/custom/buildStart.txt @@ -1 +1 @@ -buildStart \ No newline at end of file +buildStart-custom \ No newline at end of file diff --git a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/system/custom/footer.txt b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/system/custom/footer.txt index a56ca533272..8c589a50af2 100644 --- a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/system/custom/footer.txt +++ b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/system/custom/footer.txt @@ -1 +1 @@ -footer \ No newline at end of file +footer-custom \ No newline at end of file diff --git a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/system/custom/generateBundle.txt b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/system/custom/generateBundle.txt index de472563b28..155523bd6b3 100644 --- a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/system/custom/generateBundle.txt +++ b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/system/custom/generateBundle.txt @@ -1 +1 @@ -generateBundle \ No newline at end of file +generateBundle-custom \ No newline at end of file diff --git a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/system/custom/intro.txt b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/system/custom/intro.txt index 29fbe946bf9..3e663da2b46 100644 --- a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/system/custom/intro.txt +++ b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/system/custom/intro.txt @@ -1 +1 @@ -intro \ No newline at end of file +intro-custom \ No newline at end of file diff --git a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/system/custom/load.txt b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/system/custom/load.txt index 024e67c1f24..7bac7254119 100644 --- a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/system/custom/load.txt +++ b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/system/custom/load.txt @@ -1 +1 @@ -load \ No newline at end of file +load-custom \ No newline at end of file diff --git a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/system/custom/outro.txt b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/system/custom/outro.txt index 31035209b9e..77a881ecde8 100644 --- a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/system/custom/outro.txt +++ b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/system/custom/outro.txt @@ -1 +1 @@ -outro \ No newline at end of file +outro-custom \ No newline at end of file diff --git a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/system/custom/renderChunk.txt b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/system/custom/renderChunk.txt index 22f947650b0..3930812883e 100644 --- a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/system/custom/renderChunk.txt +++ b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/system/custom/renderChunk.txt @@ -1 +1 @@ -renderChunk \ No newline at end of file +renderChunk-custom \ No newline at end of file diff --git a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/system/custom/renderStart.txt b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/system/custom/renderStart.txt index 3cdc0005056..a3d2c08e3fb 100644 --- a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/system/custom/renderStart.txt +++ b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/system/custom/renderStart.txt @@ -1 +1 @@ -renderStart \ No newline at end of file +renderStart-custom \ No newline at end of file diff --git a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/system/custom/resolveId.txt b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/system/custom/resolveId.txt index 53029113abd..7286bfbd602 100644 --- a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/system/custom/resolveId.txt +++ b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/system/custom/resolveId.txt @@ -1 +1 @@ -resolveId \ No newline at end of file +resolveId-custom \ No newline at end of file diff --git a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/system/custom/transform.txt b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/system/custom/transform.txt index 3f001116657..ce2fb1d6c39 100644 --- a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/system/custom/transform.txt +++ b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/system/custom/transform.txt @@ -1 +1 @@ -transform \ No newline at end of file +transform-custom \ No newline at end of file diff --git a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/system/main.js b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/system/main.js index c83499bc2d4..35e2693371a 100644 --- a/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/system/main.js +++ b/test/chunking-form/samples/emit-file/emits-files-from-various-hooks/_expected/system/main.js @@ -1,10 +1,10 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { console.log('main'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/emit-file/filenames-function-patterns-preserve-modules/_config.js b/test/chunking-form/samples/emit-file/filenames-function-patterns-preserve-modules/_config.js index b4eb014757f..83a8fda58fe 100644 --- a/test/chunking-form/samples/emit-file/filenames-function-patterns-preserve-modules/_config.js +++ b/test/chunking-form/samples/emit-file/filenames-function-patterns-preserve-modules/_config.js @@ -1,10 +1,10 @@ -const assert = require('assert'); -const path = require('path'); +const assert = require('node:assert'); +const path = require('node:path'); const ID_MAIN = path.join(__dirname, 'main.js'); const ID_DEB = path.join(__dirname, 'deb.js'); -module.exports = { +module.exports = defineTest({ description: 'supports using a function that returns a pattern for entryFileNames, with output.preserveModules option', options: { @@ -18,28 +18,39 @@ module.exports = { output: { preserveModules: true, entryFileNames: fileInfo => { - const isMain = fileInfo.facadeModuleId === ID_MAIN; - - // This is checked separately as deepStrictEqual is having some issues - assert.deepStrictEqual(Object.keys(fileInfo.modules), [isMain ? ID_MAIN : ID_DEB]); - - delete fileInfo.modules; - assert.deepStrictEqual( - fileInfo, - { - exports: isMain ? [] : ['default'], - facadeModuleId: isMain ? ID_MAIN : ID_DEB, - isDynamicEntry: !isMain, - isEntry: isMain, - isImplicitEntry: false, - name: isMain ? 'main' : 'deb', - type: 'chunk' - }, - 'entry info' - ); - + if (fileInfo.facadeModuleId === ID_MAIN) { + assert.deepStrictEqual( + fileInfo, + { + exports: [], + facadeModuleId: ID_MAIN, + isDynamicEntry: false, + isEntry: true, + isImplicitEntry: false, + moduleIds: [ID_MAIN], + name: 'main', + type: 'chunk' + }, + 'entry info' + ); + } else { + assert.deepStrictEqual( + fileInfo, + { + exports: ['default'], + facadeModuleId: ID_DEB, + isDynamicEntry: true, + isEntry: false, + isImplicitEntry: false, + moduleIds: [ID_DEB], + name: 'deb', + type: 'chunk' + }, + 'entry info' + ); + } return `entry-[name]-[format].js`; } } } -}; +}); diff --git a/test/chunking-form/samples/emit-file/filenames-function-patterns-preserve-modules/_expected/amd/assets/test-7468331f.txt b/test/chunking-form/samples/emit-file/filenames-function-patterns-preserve-modules/_expected/amd/assets/test-DHthXMdY.txt similarity index 100% rename from test/chunking-form/samples/emit-file/filenames-function-patterns-preserve-modules/_expected/amd/assets/test-7468331f.txt rename to test/chunking-form/samples/emit-file/filenames-function-patterns-preserve-modules/_expected/amd/assets/test-DHthXMdY.txt diff --git a/test/chunking-form/samples/emit-file/filenames-function-patterns-preserve-modules/_expected/amd/entry-deb-amd.js b/test/chunking-form/samples/emit-file/filenames-function-patterns-preserve-modules/_expected/amd/entry-deb-amd.js index bdc1bb8eda1..8ccd79f41d5 100644 --- a/test/chunking-form/samples/emit-file/filenames-function-patterns-preserve-modules/_expected/amd/entry-deb-amd.js +++ b/test/chunking-form/samples/emit-file/filenames-function-patterns-preserve-modules/_expected/amd/entry-deb-amd.js @@ -1,7 +1,7 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; var deb = 'string'; return deb; -}); +})); diff --git a/test/chunking-form/samples/emit-file/filenames-function-patterns-preserve-modules/_expected/amd/entry-main-amd.js b/test/chunking-form/samples/emit-file/filenames-function-patterns-preserve-modules/_expected/amd/entry-main-amd.js index a5968f4334b..550023508a3 100644 --- a/test/chunking-form/samples/emit-file/filenames-function-patterns-preserve-modules/_expected/amd/entry-main-amd.js +++ b/test/chunking-form/samples/emit-file/filenames-function-patterns-preserve-modules/_expected/amd/entry-main-amd.js @@ -1,10 +1,8 @@ -define(['require'], function (require) { 'use strict'; +define(['require'], (function (require) { 'use strict'; - function _interopNamespaceDefaultOnly(e) { - return Object.freeze({__proto__: null, 'default': e}); - } + function _interopNamespaceDefaultOnly (e) { return Object.freeze({ __proto__: null, default: e }); } console.log('main'); - new Promise(function (resolve, reject) { require(['./entry-deb-amd'], function (m) { resolve(/*#__PURE__*/_interopNamespaceDefaultOnly(m)); }, reject) }).then(console.log); + new Promise(function (resolve, reject) { require(['./entry-deb-amd'], function (m) { resolve(/*#__PURE__*/_interopNamespaceDefaultOnly(m)); }, reject); }).then(console.log); -}); +})); diff --git a/test/chunking-form/samples/emit-file/filenames-function-patterns-preserve-modules/_expected/cjs/assets/test-7468331f.txt b/test/chunking-form/samples/emit-file/filenames-function-patterns-preserve-modules/_expected/cjs/assets/test-DHthXMdY.txt similarity index 100% rename from test/chunking-form/samples/emit-file/filenames-function-patterns-preserve-modules/_expected/cjs/assets/test-7468331f.txt rename to test/chunking-form/samples/emit-file/filenames-function-patterns-preserve-modules/_expected/cjs/assets/test-DHthXMdY.txt diff --git a/test/chunking-form/samples/emit-file/filenames-function-patterns-preserve-modules/_expected/cjs/entry-main-cjs.js b/test/chunking-form/samples/emit-file/filenames-function-patterns-preserve-modules/_expected/cjs/entry-main-cjs.js index 3a2ce3dd52b..04697098909 100644 --- a/test/chunking-form/samples/emit-file/filenames-function-patterns-preserve-modules/_expected/cjs/entry-main-cjs.js +++ b/test/chunking-form/samples/emit-file/filenames-function-patterns-preserve-modules/_expected/cjs/entry-main-cjs.js @@ -1,8 +1,6 @@ 'use strict'; -function _interopNamespaceDefaultOnly(e) { - return Object.freeze({__proto__: null, 'default': e}); -} +function _interopNamespaceDefaultOnly (e) { return Object.freeze({ __proto__: null, default: e }); } console.log('main'); Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespaceDefaultOnly(require('./entry-deb-cjs.js')); }).then(console.log); diff --git a/test/chunking-form/samples/emit-file/filenames-function-patterns-preserve-modules/_expected/es/assets/test-7468331f.txt b/test/chunking-form/samples/emit-file/filenames-function-patterns-preserve-modules/_expected/es/assets/test-DHthXMdY.txt similarity index 100% rename from test/chunking-form/samples/emit-file/filenames-function-patterns-preserve-modules/_expected/es/assets/test-7468331f.txt rename to test/chunking-form/samples/emit-file/filenames-function-patterns-preserve-modules/_expected/es/assets/test-DHthXMdY.txt diff --git a/test/chunking-form/samples/emit-file/filenames-function-patterns-preserve-modules/_expected/es/entry-deb-es.js b/test/chunking-form/samples/emit-file/filenames-function-patterns-preserve-modules/_expected/es/entry-deb-es.js index 77446c947a7..d3540098970 100644 --- a/test/chunking-form/samples/emit-file/filenames-function-patterns-preserve-modules/_expected/es/entry-deb-es.js +++ b/test/chunking-form/samples/emit-file/filenames-function-patterns-preserve-modules/_expected/es/entry-deb-es.js @@ -1,3 +1,3 @@ var deb = 'string'; -export default deb; +export { deb as default }; diff --git a/test/chunking-form/samples/emit-file/filenames-function-patterns-preserve-modules/_expected/system/assets/test-7468331f.txt b/test/chunking-form/samples/emit-file/filenames-function-patterns-preserve-modules/_expected/system/assets/test-DHthXMdY.txt similarity index 100% rename from test/chunking-form/samples/emit-file/filenames-function-patterns-preserve-modules/_expected/system/assets/test-7468331f.txt rename to test/chunking-form/samples/emit-file/filenames-function-patterns-preserve-modules/_expected/system/assets/test-DHthXMdY.txt diff --git a/test/chunking-form/samples/emit-file/filenames-function-patterns-preserve-modules/_expected/system/entry-deb-system.js b/test/chunking-form/samples/emit-file/filenames-function-patterns-preserve-modules/_expected/system/entry-deb-system.js index bf38b53fc6f..533f7eb9ca1 100644 --- a/test/chunking-form/samples/emit-file/filenames-function-patterns-preserve-modules/_expected/system/entry-deb-system.js +++ b/test/chunking-form/samples/emit-file/filenames-function-patterns-preserve-modules/_expected/system/entry-deb-system.js @@ -1,10 +1,10 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - var deb = exports('default', 'string'); + var deb = exports("default", 'string'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/emit-file/filenames-function-patterns-preserve-modules/_expected/system/entry-main-system.js b/test/chunking-form/samples/emit-file/filenames-function-patterns-preserve-modules/_expected/system/entry-main-system.js index 70ec9992fcf..b473ef22753 100644 --- a/test/chunking-form/samples/emit-file/filenames-function-patterns-preserve-modules/_expected/system/entry-main-system.js +++ b/test/chunking-form/samples/emit-file/filenames-function-patterns-preserve-modules/_expected/system/entry-main-system.js @@ -1,11 +1,11 @@ -System.register([], function (exports, module) { +System.register([], (function (exports, module) { 'use strict'; return { - execute: function () { + execute: (function () { console.log('main'); module.import('./entry-deb-system.js').then(console.log); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/emit-file/filenames-function-patterns/_config.js b/test/chunking-form/samples/emit-file/filenames-function-patterns/_config.js index 5fed7481d5a..3df57353f09 100644 --- a/test/chunking-form/samples/emit-file/filenames-function-patterns/_config.js +++ b/test/chunking-form/samples/emit-file/filenames-function-patterns/_config.js @@ -1,24 +1,30 @@ -const assert = require('assert'); -const path = require('path'); +const assert = require('node:assert'); +const path = require('node:path'); const ID_MAIN = path.join(__dirname, 'main.js'); const ID_DEB = path.join(__dirname, 'deb.js'); -module.exports = { +module.exports = defineTest({ description: 'supports using a function that returns a pattern for FileNames', options: { + // TODO should be removed with next major as deprecated properties become non-enumerable + strictDeprecations: false, input: ['main.js'], plugins: { - transform() { - this.emitFile({ type: 'asset', name: 'test.txt', source: 'hello world' }); + name: 'test-plugin', + transform(code, id) { + const baseName = path.basename(id); + this.emitFile({ + type: 'asset', + name: `${baseName}.txt`, + originalFileName: baseName, + source: 'hello world' + }); return null; } }, output: { entryFileNames: fileInfo => { - // This is checked separately as deepStrictEqual is having some issues - assert.deepStrictEqual(Object.keys(fileInfo.modules), [ID_MAIN]); - delete fileInfo.modules; assert.deepStrictEqual( fileInfo, { @@ -28,6 +34,7 @@ module.exports = { isEntry: true, isImplicitEntry: false, name: 'main', + moduleIds: [ID_MAIN], type: 'chunk' }, 'entry info' @@ -35,10 +42,16 @@ module.exports = { return `entry-[name]-[hash]-[format].js`; }, assetFileNames: fileInfo => { + const originalFileName = fileInfo.originalFileName; + const originalFileNames = ['deb.js', 'main.js']; + assert.ok(originalFileNames.includes(originalFileName), 'original file name'); assert.deepStrictEqual( fileInfo, { - name: 'test.txt', + name: `${originalFileName}.txt`, + names: ['deb.js.txt', 'main.js.txt'], + originalFileName, + originalFileNames, source: 'hello world', type: 'asset' }, @@ -47,9 +60,6 @@ module.exports = { return '[ext]/[hash]-[name][extname]'; }, chunkFileNames: fileInfo => { - // This is checked separately as deepStrictEqual is having some issues - assert.deepStrictEqual(Object.keys(fileInfo.modules), [ID_DEB]); - delete fileInfo.modules; assert.deepStrictEqual( fileInfo, { @@ -58,6 +68,7 @@ module.exports = { isDynamicEntry: true, isEntry: false, isImplicitEntry: false, + moduleIds: [ID_DEB], name: 'deb', type: 'chunk' }, @@ -67,4 +78,4 @@ module.exports = { } } } -}; +}); diff --git a/test/chunking-form/samples/emit-file/filenames-function-patterns/_expected/amd/chunk-deb--Bz6x-oi-amd.js b/test/chunking-form/samples/emit-file/filenames-function-patterns/_expected/amd/chunk-deb--Bz6x-oi-amd.js new file mode 100644 index 00000000000..e91c726e884 --- /dev/null +++ b/test/chunking-form/samples/emit-file/filenames-function-patterns/_expected/amd/chunk-deb--Bz6x-oi-amd.js @@ -0,0 +1,7 @@ +define(['exports'], (function (exports) { 'use strict'; + + var deb = 'string'; + + exports.default = deb; + +})); diff --git a/test/chunking-form/samples/emit-file/filenames-function-patterns/_expected/amd/chunk-deb-c542d45b-amd.js b/test/chunking-form/samples/emit-file/filenames-function-patterns/_expected/amd/chunk-deb-c542d45b-amd.js deleted file mode 100644 index 1bc94d104bd..00000000000 --- a/test/chunking-form/samples/emit-file/filenames-function-patterns/_expected/amd/chunk-deb-c542d45b-amd.js +++ /dev/null @@ -1,7 +0,0 @@ -define(['exports'], function (exports) { 'use strict'; - - var deb = 'string'; - - exports.default = deb; - -}); diff --git a/test/chunking-form/samples/emit-file/filenames-function-patterns/_expected/amd/entry-main-DJVXpS51-amd.js b/test/chunking-form/samples/emit-file/filenames-function-patterns/_expected/amd/entry-main-DJVXpS51-amd.js new file mode 100644 index 00000000000..0b5f0ae0032 --- /dev/null +++ b/test/chunking-form/samples/emit-file/filenames-function-patterns/_expected/amd/entry-main-DJVXpS51-amd.js @@ -0,0 +1,6 @@ +define(['require'], (function (require) { 'use strict'; + + console.log('main'); + new Promise(function (resolve, reject) { require(['./chunk-deb--Bz6x-oi-amd'], resolve, reject); }).then(console.log); + +})); diff --git a/test/chunking-form/samples/emit-file/filenames-function-patterns/_expected/amd/entry-main-ed305cc7-amd.js b/test/chunking-form/samples/emit-file/filenames-function-patterns/_expected/amd/entry-main-ed305cc7-amd.js deleted file mode 100644 index 2d7c204addb..00000000000 --- a/test/chunking-form/samples/emit-file/filenames-function-patterns/_expected/amd/entry-main-ed305cc7-amd.js +++ /dev/null @@ -1,6 +0,0 @@ -define(['require'], function (require) { 'use strict'; - - console.log('main'); - new Promise(function (resolve, reject) { require(['./chunk-deb-c542d45b-amd'], resolve, reject) }).then(console.log); - -}); diff --git a/test/chunking-form/samples/emit-file/filenames-function-patterns/_expected/amd/txt/7468331f-test.txt b/test/chunking-form/samples/emit-file/filenames-function-patterns/_expected/amd/txt/DHthXMdY-deb.js.txt similarity index 100% rename from test/chunking-form/samples/emit-file/filenames-function-patterns/_expected/amd/txt/7468331f-test.txt rename to test/chunking-form/samples/emit-file/filenames-function-patterns/_expected/amd/txt/DHthXMdY-deb.js.txt diff --git a/test/chunking-form/samples/emit-file/filenames-function-patterns/_expected/cjs/chunk-deb-9LJjyiap-cjs.js b/test/chunking-form/samples/emit-file/filenames-function-patterns/_expected/cjs/chunk-deb-9LJjyiap-cjs.js new file mode 100644 index 00000000000..f51dbd7a36a --- /dev/null +++ b/test/chunking-form/samples/emit-file/filenames-function-patterns/_expected/cjs/chunk-deb-9LJjyiap-cjs.js @@ -0,0 +1,5 @@ +'use strict'; + +var deb = 'string'; + +exports.default = deb; diff --git a/test/chunking-form/samples/emit-file/filenames-function-patterns/_expected/cjs/entry-main-9f49db65-cjs.js b/test/chunking-form/samples/emit-file/filenames-function-patterns/_expected/cjs/entry-main-9f49db65-cjs.js deleted file mode 100644 index 6363af0ae9e..00000000000 --- a/test/chunking-form/samples/emit-file/filenames-function-patterns/_expected/cjs/entry-main-9f49db65-cjs.js +++ /dev/null @@ -1,4 +0,0 @@ -'use strict'; - -console.log('main'); -Promise.resolve().then(function () { return require('./chunk-deb-19c947c3-cjs.js'); }).then(console.log); diff --git a/test/chunking-form/samples/emit-file/filenames-function-patterns/_expected/cjs/entry-main-DFh1DOOW-cjs.js b/test/chunking-form/samples/emit-file/filenames-function-patterns/_expected/cjs/entry-main-DFh1DOOW-cjs.js new file mode 100644 index 00000000000..90ccd092b8f --- /dev/null +++ b/test/chunking-form/samples/emit-file/filenames-function-patterns/_expected/cjs/entry-main-DFh1DOOW-cjs.js @@ -0,0 +1,4 @@ +'use strict'; + +console.log('main'); +Promise.resolve().then(function () { return require('./chunk-deb-9LJjyiap-cjs.js'); }).then(console.log); diff --git a/test/chunking-form/samples/emit-file/filenames-function-patterns/_expected/cjs/txt/7468331f-test.txt b/test/chunking-form/samples/emit-file/filenames-function-patterns/_expected/cjs/txt/DHthXMdY-deb.js.txt similarity index 100% rename from test/chunking-form/samples/emit-file/filenames-function-patterns/_expected/cjs/txt/7468331f-test.txt rename to test/chunking-form/samples/emit-file/filenames-function-patterns/_expected/cjs/txt/DHthXMdY-deb.js.txt diff --git a/test/chunking-form/samples/emit-file/filenames-function-patterns/_expected/es/chunk-deb-607fe03f-es.js b/test/chunking-form/samples/emit-file/filenames-function-patterns/_expected/es/chunk-deb-607fe03f-es.js deleted file mode 100644 index 77446c947a7..00000000000 --- a/test/chunking-form/samples/emit-file/filenames-function-patterns/_expected/es/chunk-deb-607fe03f-es.js +++ /dev/null @@ -1,3 +0,0 @@ -var deb = 'string'; - -export default deb; diff --git a/test/chunking-form/samples/emit-file/filenames-function-patterns/_expected/es/chunk-deb-H_8j5Qun-es.js b/test/chunking-form/samples/emit-file/filenames-function-patterns/_expected/es/chunk-deb-H_8j5Qun-es.js new file mode 100644 index 00000000000..d3540098970 --- /dev/null +++ b/test/chunking-form/samples/emit-file/filenames-function-patterns/_expected/es/chunk-deb-H_8j5Qun-es.js @@ -0,0 +1,3 @@ +var deb = 'string'; + +export { deb as default }; diff --git a/test/chunking-form/samples/emit-file/filenames-function-patterns/_expected/es/entry-main-137667a0-es.js b/test/chunking-form/samples/emit-file/filenames-function-patterns/_expected/es/entry-main-137667a0-es.js deleted file mode 100644 index 0896042fc2c..00000000000 --- a/test/chunking-form/samples/emit-file/filenames-function-patterns/_expected/es/entry-main-137667a0-es.js +++ /dev/null @@ -1,2 +0,0 @@ -console.log('main'); -import('./chunk-deb-607fe03f-es.js').then(console.log); diff --git a/test/chunking-form/samples/emit-file/filenames-function-patterns/_expected/es/entry-main-BeWMkjX8-es.js b/test/chunking-form/samples/emit-file/filenames-function-patterns/_expected/es/entry-main-BeWMkjX8-es.js new file mode 100644 index 00000000000..379e421b5d8 --- /dev/null +++ b/test/chunking-form/samples/emit-file/filenames-function-patterns/_expected/es/entry-main-BeWMkjX8-es.js @@ -0,0 +1,2 @@ +console.log('main'); +import('./chunk-deb-H_8j5Qun-es.js').then(console.log); diff --git a/test/chunking-form/samples/emit-file/filenames-function-patterns/_expected/es/txt/7468331f-test.txt b/test/chunking-form/samples/emit-file/filenames-function-patterns/_expected/es/txt/DHthXMdY-deb.js.txt similarity index 100% rename from test/chunking-form/samples/emit-file/filenames-function-patterns/_expected/es/txt/7468331f-test.txt rename to test/chunking-form/samples/emit-file/filenames-function-patterns/_expected/es/txt/DHthXMdY-deb.js.txt diff --git a/test/chunking-form/samples/emit-file/filenames-function-patterns/_expected/system/chunk-deb-3a28869f-system.js b/test/chunking-form/samples/emit-file/filenames-function-patterns/_expected/system/chunk-deb-3a28869f-system.js deleted file mode 100644 index bf38b53fc6f..00000000000 --- a/test/chunking-form/samples/emit-file/filenames-function-patterns/_expected/system/chunk-deb-3a28869f-system.js +++ /dev/null @@ -1,10 +0,0 @@ -System.register([], function (exports) { - 'use strict'; - return { - execute: function () { - - var deb = exports('default', 'string'); - - } - }; -}); diff --git a/test/chunking-form/samples/emit-file/filenames-function-patterns/_expected/system/chunk-deb-PNqONwrZ-system.js b/test/chunking-form/samples/emit-file/filenames-function-patterns/_expected/system/chunk-deb-PNqONwrZ-system.js new file mode 100644 index 00000000000..533f7eb9ca1 --- /dev/null +++ b/test/chunking-form/samples/emit-file/filenames-function-patterns/_expected/system/chunk-deb-PNqONwrZ-system.js @@ -0,0 +1,10 @@ +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + + var deb = exports("default", 'string'); + + }) + }; +})); diff --git a/test/chunking-form/samples/emit-file/filenames-function-patterns/_expected/system/entry-main-IHNOrI04-system.js b/test/chunking-form/samples/emit-file/filenames-function-patterns/_expected/system/entry-main-IHNOrI04-system.js new file mode 100644 index 00000000000..9c91c2d22d9 --- /dev/null +++ b/test/chunking-form/samples/emit-file/filenames-function-patterns/_expected/system/entry-main-IHNOrI04-system.js @@ -0,0 +1,11 @@ +System.register([], (function (exports, module) { + 'use strict'; + return { + execute: (function () { + + console.log('main'); + module.import('./chunk-deb-PNqONwrZ-system.js').then(console.log); + + }) + }; +})); diff --git a/test/chunking-form/samples/emit-file/filenames-function-patterns/_expected/system/entry-main-e573b571-system.js b/test/chunking-form/samples/emit-file/filenames-function-patterns/_expected/system/entry-main-e573b571-system.js deleted file mode 100644 index 4d4ad703227..00000000000 --- a/test/chunking-form/samples/emit-file/filenames-function-patterns/_expected/system/entry-main-e573b571-system.js +++ /dev/null @@ -1,11 +0,0 @@ -System.register([], function (exports, module) { - 'use strict'; - return { - execute: function () { - - console.log('main'); - module.import('./chunk-deb-3a28869f-system.js').then(console.log); - - } - }; -}); diff --git a/test/chunking-form/samples/emit-file/filenames-function-patterns/_expected/system/txt/7468331f-test.txt b/test/chunking-form/samples/emit-file/filenames-function-patterns/_expected/system/txt/DHthXMdY-deb.js.txt similarity index 100% rename from test/chunking-form/samples/emit-file/filenames-function-patterns/_expected/system/txt/7468331f-test.txt rename to test/chunking-form/samples/emit-file/filenames-function-patterns/_expected/system/txt/DHthXMdY-deb.js.txt diff --git a/test/chunking-form/samples/emit-file/generate-emission-names/_config.js b/test/chunking-form/samples/emit-file/generate-emission-names/_config.js new file mode 100644 index 00000000000..196e8b4371b --- /dev/null +++ b/test/chunking-form/samples/emit-file/generate-emission-names/_config.js @@ -0,0 +1,85 @@ +const assert = require('node:assert'); + +let referenceIdWithoutName; +let referenceIdWithName; + +module.exports = defineTest({ + description: 'updates asset names when emitting in generate phase', + options: { + strictDeprecations: false, + output: { assetFileNames: 'generated-[name][extname]' }, + plugins: { + renderChunk() { + referenceIdWithoutName = this.emitFile({ + type: 'asset', + source: 'renderChunk-without-names' + }); + referenceIdWithName = this.emitFile({ + type: 'asset', + name: 'with-names.txt', + originalFileName: 'with-names-original.txt', + source: 'renderChunk-with-names' + }); + }, + generateBundle(options, bundle) { + const fileNameWithoutName = this.getFileName(referenceIdWithoutName); + assert.strictEqual(fileNameWithoutName, 'generated-asset'); + assert.deepStrictEqual(bundle[fileNameWithoutName], { + fileName: 'generated-asset', + name: undefined, + names: [], + needsCodeReference: false, + originalFileName: null, + originalFileNames: [], + source: 'renderChunk-without-names', + type: 'asset' + }); + this.emitFile({ + type: 'asset', + source: 'renderChunk-without-names', + name: 'new-name.txt', + originalFileName: 'original-new-name.txt' + }); + assert.deepStrictEqual(bundle[fileNameWithoutName], { + fileName: 'generated-asset', + name: undefined, + names: ['new-name.txt'], + needsCodeReference: false, + originalFileName: null, + originalFileNames: ['original-new-name.txt'], + source: 'renderChunk-without-names', + type: 'asset' + }); + + const fileNameWithName = this.getFileName(referenceIdWithName); + assert.strictEqual(fileNameWithName, 'generated-with-names.txt'); + assert.deepStrictEqual(bundle[fileNameWithName], { + fileName: 'generated-with-names.txt', + name: 'with-names.txt', + names: ['with-names.txt'], + needsCodeReference: false, + originalFileName: 'with-names-original.txt', + originalFileNames: ['with-names-original.txt'], + source: 'renderChunk-with-names', + type: 'asset' + }); + this.emitFile({ + type: 'asset', + name: 'second-name.txt', + originalFileName: 'original-second-name.txt', + source: 'renderChunk-with-names' + }); + assert.deepStrictEqual(bundle[fileNameWithName], { + fileName: 'generated-with-names.txt', + name: 'with-names.txt', + names: ['with-names.txt', 'second-name.txt'], + needsCodeReference: false, + originalFileName: 'with-names-original.txt', + originalFileNames: ['with-names-original.txt', 'original-second-name.txt'], + source: 'renderChunk-with-names', + type: 'asset' + }); + } + } + } +}); diff --git a/test/chunking-form/samples/emit-file/generate-emission-names/_expected/amd/generated-asset b/test/chunking-form/samples/emit-file/generate-emission-names/_expected/amd/generated-asset new file mode 100644 index 00000000000..4a5b37433fe --- /dev/null +++ b/test/chunking-form/samples/emit-file/generate-emission-names/_expected/amd/generated-asset @@ -0,0 +1 @@ +renderChunk-without-names \ No newline at end of file diff --git a/test/chunking-form/samples/emit-file/generate-emission-names/_expected/amd/generated-with-names.txt b/test/chunking-form/samples/emit-file/generate-emission-names/_expected/amd/generated-with-names.txt new file mode 100644 index 00000000000..60e4f7f514d --- /dev/null +++ b/test/chunking-form/samples/emit-file/generate-emission-names/_expected/amd/generated-with-names.txt @@ -0,0 +1 @@ +renderChunk-with-names \ No newline at end of file diff --git a/test/chunking-form/samples/emit-file/generate-emission-names/_expected/amd/main.js b/test/chunking-form/samples/emit-file/generate-emission-names/_expected/amd/main.js new file mode 100644 index 00000000000..947ad1cbafd --- /dev/null +++ b/test/chunking-form/samples/emit-file/generate-emission-names/_expected/amd/main.js @@ -0,0 +1,7 @@ +define(['exports'], (function (exports) { 'use strict'; + + const value = 42; + + exports.value = value; + +})); diff --git a/test/chunking-form/samples/emit-file/generate-emission-names/_expected/cjs/generated-asset b/test/chunking-form/samples/emit-file/generate-emission-names/_expected/cjs/generated-asset new file mode 100644 index 00000000000..4a5b37433fe --- /dev/null +++ b/test/chunking-form/samples/emit-file/generate-emission-names/_expected/cjs/generated-asset @@ -0,0 +1 @@ +renderChunk-without-names \ No newline at end of file diff --git a/test/chunking-form/samples/emit-file/generate-emission-names/_expected/cjs/generated-with-names.txt b/test/chunking-form/samples/emit-file/generate-emission-names/_expected/cjs/generated-with-names.txt new file mode 100644 index 00000000000..60e4f7f514d --- /dev/null +++ b/test/chunking-form/samples/emit-file/generate-emission-names/_expected/cjs/generated-with-names.txt @@ -0,0 +1 @@ +renderChunk-with-names \ No newline at end of file diff --git a/test/chunking-form/samples/emit-file/generate-emission-names/_expected/cjs/main.js b/test/chunking-form/samples/emit-file/generate-emission-names/_expected/cjs/main.js new file mode 100644 index 00000000000..9549eb32880 --- /dev/null +++ b/test/chunking-form/samples/emit-file/generate-emission-names/_expected/cjs/main.js @@ -0,0 +1,5 @@ +'use strict'; + +const value = 42; + +exports.value = value; diff --git a/test/chunking-form/samples/emit-file/generate-emission-names/_expected/es/generated-asset b/test/chunking-form/samples/emit-file/generate-emission-names/_expected/es/generated-asset new file mode 100644 index 00000000000..4a5b37433fe --- /dev/null +++ b/test/chunking-form/samples/emit-file/generate-emission-names/_expected/es/generated-asset @@ -0,0 +1 @@ +renderChunk-without-names \ No newline at end of file diff --git a/test/chunking-form/samples/emit-file/generate-emission-names/_expected/es/generated-with-names.txt b/test/chunking-form/samples/emit-file/generate-emission-names/_expected/es/generated-with-names.txt new file mode 100644 index 00000000000..60e4f7f514d --- /dev/null +++ b/test/chunking-form/samples/emit-file/generate-emission-names/_expected/es/generated-with-names.txt @@ -0,0 +1 @@ +renderChunk-with-names \ No newline at end of file diff --git a/test/chunking-form/samples/emit-file/generate-emission-names/_expected/es/main.js b/test/chunking-form/samples/emit-file/generate-emission-names/_expected/es/main.js new file mode 100644 index 00000000000..d897952f7d1 --- /dev/null +++ b/test/chunking-form/samples/emit-file/generate-emission-names/_expected/es/main.js @@ -0,0 +1,3 @@ +const value = 42; + +export { value }; diff --git a/test/chunking-form/samples/emit-file/generate-emission-names/_expected/system/generated-asset b/test/chunking-form/samples/emit-file/generate-emission-names/_expected/system/generated-asset new file mode 100644 index 00000000000..4a5b37433fe --- /dev/null +++ b/test/chunking-form/samples/emit-file/generate-emission-names/_expected/system/generated-asset @@ -0,0 +1 @@ +renderChunk-without-names \ No newline at end of file diff --git a/test/chunking-form/samples/emit-file/generate-emission-names/_expected/system/generated-with-names.txt b/test/chunking-form/samples/emit-file/generate-emission-names/_expected/system/generated-with-names.txt new file mode 100644 index 00000000000..60e4f7f514d --- /dev/null +++ b/test/chunking-form/samples/emit-file/generate-emission-names/_expected/system/generated-with-names.txt @@ -0,0 +1 @@ +renderChunk-with-names \ No newline at end of file diff --git a/test/chunking-form/samples/emit-file/generate-emission-names/_expected/system/main.js b/test/chunking-form/samples/emit-file/generate-emission-names/_expected/system/main.js new file mode 100644 index 00000000000..f80269f9009 --- /dev/null +++ b/test/chunking-form/samples/emit-file/generate-emission-names/_expected/system/main.js @@ -0,0 +1,10 @@ +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + + const value = exports("value", 42); + + }) + }; +})); diff --git a/test/chunking-form/samples/deprecated/manual-chunk-avoid-facade/dep.js b/test/chunking-form/samples/emit-file/generate-emission-names/main.js similarity index 100% rename from test/chunking-form/samples/deprecated/manual-chunk-avoid-facade/dep.js rename to test/chunking-form/samples/emit-file/generate-emission-names/main.js diff --git a/test/chunking-form/samples/emit-file/named-user-chunks/_config.js b/test/chunking-form/samples/emit-file/named-user-chunks/_config.js index 6807aad6a57..b59bc1f5d1f 100644 --- a/test/chunking-form/samples/emit-file/named-user-chunks/_config.js +++ b/test/chunking-form/samples/emit-file/named-user-chunks/_config.js @@ -1,10 +1,10 @@ -const assert = require('assert'); +const assert = require('node:assert'); let referenceIdName; let referenceIdFileName1; let referenceIdFileName2; -module.exports = { +module.exports = defineTest({ description: 'deduplicates with named chunks defined by the user', options: { input: { mainChunk: 'main', mainChunkFacade: 'main' }, @@ -29,4 +29,4 @@ module.exports = { } } } -}; +}); diff --git a/test/chunking-form/samples/emit-file/named-user-chunks/_expected/amd/explicit-name1.js b/test/chunking-form/samples/emit-file/named-user-chunks/_expected/amd/explicit-name1.js index 993c75f358b..d6a2055d06e 100644 --- a/test/chunking-form/samples/emit-file/named-user-chunks/_expected/amd/explicit-name1.js +++ b/test/chunking-form/samples/emit-file/named-user-chunks/_expected/amd/explicit-name1.js @@ -1,9 +1,7 @@ -define(['exports', './mainChunk'], function (exports, mainChunk) { 'use strict'; +define(['exports', './mainChunk'], (function (exports, mainChunk) { 'use strict'; exports.value = mainChunk.value; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/emit-file/named-user-chunks/_expected/amd/explicit-name2.js b/test/chunking-form/samples/emit-file/named-user-chunks/_expected/amd/explicit-name2.js index 993c75f358b..d6a2055d06e 100644 --- a/test/chunking-form/samples/emit-file/named-user-chunks/_expected/amd/explicit-name2.js +++ b/test/chunking-form/samples/emit-file/named-user-chunks/_expected/amd/explicit-name2.js @@ -1,9 +1,7 @@ -define(['exports', './mainChunk'], function (exports, mainChunk) { 'use strict'; +define(['exports', './mainChunk'], (function (exports, mainChunk) { 'use strict'; exports.value = mainChunk.value; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/emit-file/named-user-chunks/_expected/amd/mainChunk.js b/test/chunking-form/samples/emit-file/named-user-chunks/_expected/amd/mainChunk.js index 876aec76659..947ad1cbafd 100644 --- a/test/chunking-form/samples/emit-file/named-user-chunks/_expected/amd/mainChunk.js +++ b/test/chunking-form/samples/emit-file/named-user-chunks/_expected/amd/mainChunk.js @@ -1,9 +1,7 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; const value = 42; exports.value = value; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/emit-file/named-user-chunks/_expected/amd/mainChunkFacade.js b/test/chunking-form/samples/emit-file/named-user-chunks/_expected/amd/mainChunkFacade.js index 993c75f358b..d6a2055d06e 100644 --- a/test/chunking-form/samples/emit-file/named-user-chunks/_expected/amd/mainChunkFacade.js +++ b/test/chunking-form/samples/emit-file/named-user-chunks/_expected/amd/mainChunkFacade.js @@ -1,9 +1,7 @@ -define(['exports', './mainChunk'], function (exports, mainChunk) { 'use strict'; +define(['exports', './mainChunk'], (function (exports, mainChunk) { 'use strict'; exports.value = mainChunk.value; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/emit-file/named-user-chunks/_expected/cjs/explicit-name1.js b/test/chunking-form/samples/emit-file/named-user-chunks/_expected/cjs/explicit-name1.js index 4353ca57beb..2c1766ca185 100644 --- a/test/chunking-form/samples/emit-file/named-user-chunks/_expected/cjs/explicit-name1.js +++ b/test/chunking-form/samples/emit-file/named-user-chunks/_expected/cjs/explicit-name1.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - var mainChunk = require('./mainChunk.js'); diff --git a/test/chunking-form/samples/emit-file/named-user-chunks/_expected/cjs/explicit-name2.js b/test/chunking-form/samples/emit-file/named-user-chunks/_expected/cjs/explicit-name2.js index 4353ca57beb..2c1766ca185 100644 --- a/test/chunking-form/samples/emit-file/named-user-chunks/_expected/cjs/explicit-name2.js +++ b/test/chunking-form/samples/emit-file/named-user-chunks/_expected/cjs/explicit-name2.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - var mainChunk = require('./mainChunk.js'); diff --git a/test/chunking-form/samples/emit-file/named-user-chunks/_expected/cjs/mainChunk.js b/test/chunking-form/samples/emit-file/named-user-chunks/_expected/cjs/mainChunk.js index 181fa0fd711..9549eb32880 100644 --- a/test/chunking-form/samples/emit-file/named-user-chunks/_expected/cjs/mainChunk.js +++ b/test/chunking-form/samples/emit-file/named-user-chunks/_expected/cjs/mainChunk.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - const value = 42; exports.value = value; diff --git a/test/chunking-form/samples/emit-file/named-user-chunks/_expected/cjs/mainChunkFacade.js b/test/chunking-form/samples/emit-file/named-user-chunks/_expected/cjs/mainChunkFacade.js index 4353ca57beb..2c1766ca185 100644 --- a/test/chunking-form/samples/emit-file/named-user-chunks/_expected/cjs/mainChunkFacade.js +++ b/test/chunking-form/samples/emit-file/named-user-chunks/_expected/cjs/mainChunkFacade.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - var mainChunk = require('./mainChunk.js'); diff --git a/test/chunking-form/samples/emit-file/named-user-chunks/_expected/system/explicit-name1.js b/test/chunking-form/samples/emit-file/named-user-chunks/_expected/system/explicit-name1.js index cb058047eca..e0909a48244 100644 --- a/test/chunking-form/samples/emit-file/named-user-chunks/_expected/system/explicit-name1.js +++ b/test/chunking-form/samples/emit-file/named-user-chunks/_expected/system/explicit-name1.js @@ -1,13 +1,13 @@ -System.register(['./mainChunk.js'], function (exports) { +System.register(['./mainChunk.js'], (function (exports) { 'use strict'; return { setters: [function (module) { - exports('value', module.value); + exports("value", module.value); }], - execute: function () { + execute: (function () { - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/emit-file/named-user-chunks/_expected/system/explicit-name2.js b/test/chunking-form/samples/emit-file/named-user-chunks/_expected/system/explicit-name2.js index cb058047eca..e0909a48244 100644 --- a/test/chunking-form/samples/emit-file/named-user-chunks/_expected/system/explicit-name2.js +++ b/test/chunking-form/samples/emit-file/named-user-chunks/_expected/system/explicit-name2.js @@ -1,13 +1,13 @@ -System.register(['./mainChunk.js'], function (exports) { +System.register(['./mainChunk.js'], (function (exports) { 'use strict'; return { setters: [function (module) { - exports('value', module.value); + exports("value", module.value); }], - execute: function () { + execute: (function () { - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/emit-file/named-user-chunks/_expected/system/mainChunk.js b/test/chunking-form/samples/emit-file/named-user-chunks/_expected/system/mainChunk.js index 437f1af456e..f80269f9009 100644 --- a/test/chunking-form/samples/emit-file/named-user-chunks/_expected/system/mainChunk.js +++ b/test/chunking-form/samples/emit-file/named-user-chunks/_expected/system/mainChunk.js @@ -1,10 +1,10 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - const value = exports('value', 42); + const value = exports("value", 42); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/emit-file/named-user-chunks/_expected/system/mainChunkFacade.js b/test/chunking-form/samples/emit-file/named-user-chunks/_expected/system/mainChunkFacade.js index cb058047eca..e0909a48244 100644 --- a/test/chunking-form/samples/emit-file/named-user-chunks/_expected/system/mainChunkFacade.js +++ b/test/chunking-form/samples/emit-file/named-user-chunks/_expected/system/mainChunkFacade.js @@ -1,13 +1,13 @@ -System.register(['./mainChunk.js'], function (exports) { +System.register(['./mainChunk.js'], (function (exports) { 'use strict'; return { setters: [function (module) { - exports('value', module.value); + exports("value", module.value); }], - execute: function () { + execute: (function () { - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/emit-file/reference-files/_config.js b/test/chunking-form/samples/emit-file/reference-files/_config.js index 57ba1d3de55..7736eceee20 100644 --- a/test/chunking-form/samples/emit-file/reference-files/_config.js +++ b/test/chunking-form/samples/emit-file/reference-files/_config.js @@ -1,7 +1,7 @@ -const fs = require('fs'); -const path = require('path'); +const { readFileSync } = require('node:fs'); +const path = require('node:path'); -module.exports = { +module.exports = defineTest({ description: 'allows referencing emitted files', options: { strictDeprecations: false, @@ -11,8 +11,9 @@ module.exports = { chunkFileNames: 'nested/chunk.js' }, plugins: { + name: 'test-plugin', resolveId(id, importee) { - if (id.endsWith('.svg')) { + if (id.endsWith('.svg') && importee) { return path.resolve(path.dirname(importee), id); } }, @@ -21,10 +22,10 @@ module.exports = { return `export default import.meta.ROLLUP_FILE_URL_${this.emitFile({ type: 'asset', name: path.basename(id), - source: fs.readFileSync(id) + source: readFileSync(id) })};`; } } } } -}; +}); diff --git a/test/chunking-form/samples/deprecated/emit-asset/_expected/cjs/assets/logo1-a5ec488b.svg b/test/chunking-form/samples/emit-file/reference-files/_expected/amd/assets/logo1-FquQRdV3.svg similarity index 100% rename from test/chunking-form/samples/deprecated/emit-asset/_expected/cjs/assets/logo1-a5ec488b.svg rename to test/chunking-form/samples/emit-file/reference-files/_expected/amd/assets/logo1-FquQRdV3.svg diff --git a/test/chunking-form/samples/emit-file/reference-files/_expected/amd/assets/logo1-a5ec488b.svg b/test/chunking-form/samples/emit-file/reference-files/_expected/amd/assets/logo1-a5ec488b.svg deleted file mode 100644 index cb7e52c5130..00000000000 --- a/test/chunking-form/samples/emit-file/reference-files/_expected/amd/assets/logo1-a5ec488b.svg +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/test/chunking-form/samples/emit-file/reference-files/_expected/amd/assets/logo2-6d5979e4.svg b/test/chunking-form/samples/emit-file/reference-files/_expected/amd/assets/logo2-6d5979e4.svg deleted file mode 100644 index b446284a4cd..00000000000 --- a/test/chunking-form/samples/emit-file/reference-files/_expected/amd/assets/logo2-6d5979e4.svg +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/test/chunking-form/samples/deprecated/emit-asset/_expected/amd/assets/logo2-6d5979e4.svg b/test/chunking-form/samples/emit-file/reference-files/_expected/amd/assets/logo2-DJfvToLT.svg similarity index 100% rename from test/chunking-form/samples/deprecated/emit-asset/_expected/amd/assets/logo2-6d5979e4.svg rename to test/chunking-form/samples/emit-file/reference-files/_expected/amd/assets/logo2-DJfvToLT.svg diff --git a/test/chunking-form/samples/emit-file/reference-files/_expected/amd/main.js b/test/chunking-form/samples/emit-file/reference-files/_expected/amd/main.js index d69c2282450..7b2b18dc1a7 100644 --- a/test/chunking-form/samples/emit-file/reference-files/_expected/amd/main.js +++ b/test/chunking-form/samples/emit-file/reference-files/_expected/amd/main.js @@ -1,6 +1,6 @@ -define(['require', 'exports'], function (require, exports) { 'use strict'; +define(['require', 'exports'], (function (require, exports) { 'use strict'; - var logo = new URL(require.toUrl('./assets/logo1-a5ec488b.svg'), document.baseURI).href; + var logo = new URL(require.toUrl('./assets/logo1-FquQRdV3.svg'), document.baseURI).href; function showImage(url) { console.log(url); @@ -12,10 +12,8 @@ define(['require', 'exports'], function (require, exports) { 'use strict'; } showImage(logo); - new Promise(function (resolve, reject) { require(['./nested/chunk'], resolve, reject) }); + new Promise(function (resolve, reject) { require(['./nested/chunk'], resolve, reject); }); exports.showImage = showImage; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/emit-file/reference-files/_expected/amd/nested/chunk.js b/test/chunking-form/samples/emit-file/reference-files/_expected/amd/nested/chunk.js index 58bc60e0179..a6fe9f3274f 100644 --- a/test/chunking-form/samples/emit-file/reference-files/_expected/amd/nested/chunk.js +++ b/test/chunking-form/samples/emit-file/reference-files/_expected/amd/nested/chunk.js @@ -1,7 +1,7 @@ -define(['require', '../main'], function (require, main) { 'use strict'; +define(['require', '../main'], (function (require, main) { 'use strict'; - var logo = new URL(require.toUrl('../assets/logo2-6d5979e4.svg'), document.baseURI).href; + var logo = new URL(require.toUrl('../assets/logo2-DJfvToLT.svg'), document.baseURI).href; main.showImage(logo); -}); +})); diff --git a/test/chunking-form/samples/deprecated/emit-asset/_expected/es/assets/logo1-a5ec488b.svg b/test/chunking-form/samples/emit-file/reference-files/_expected/cjs/assets/logo1-FquQRdV3.svg similarity index 100% rename from test/chunking-form/samples/deprecated/emit-asset/_expected/es/assets/logo1-a5ec488b.svg rename to test/chunking-form/samples/emit-file/reference-files/_expected/cjs/assets/logo1-FquQRdV3.svg diff --git a/test/chunking-form/samples/emit-file/reference-files/_expected/cjs/assets/logo1-a5ec488b.svg b/test/chunking-form/samples/emit-file/reference-files/_expected/cjs/assets/logo1-a5ec488b.svg deleted file mode 100644 index cb7e52c5130..00000000000 --- a/test/chunking-form/samples/emit-file/reference-files/_expected/cjs/assets/logo1-a5ec488b.svg +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/test/chunking-form/samples/emit-file/reference-files/_expected/cjs/assets/logo2-6d5979e4.svg b/test/chunking-form/samples/emit-file/reference-files/_expected/cjs/assets/logo2-6d5979e4.svg deleted file mode 100644 index b446284a4cd..00000000000 --- a/test/chunking-form/samples/emit-file/reference-files/_expected/cjs/assets/logo2-6d5979e4.svg +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/test/chunking-form/samples/deprecated/emit-asset/_expected/cjs/assets/logo2-6d5979e4.svg b/test/chunking-form/samples/emit-file/reference-files/_expected/cjs/assets/logo2-DJfvToLT.svg similarity index 100% rename from test/chunking-form/samples/deprecated/emit-asset/_expected/cjs/assets/logo2-6d5979e4.svg rename to test/chunking-form/samples/emit-file/reference-files/_expected/cjs/assets/logo2-DJfvToLT.svg diff --git a/test/chunking-form/samples/emit-file/reference-files/_expected/cjs/main.js b/test/chunking-form/samples/emit-file/reference-files/_expected/cjs/main.js index 5c22a31491d..ca7980f9082 100644 --- a/test/chunking-form/samples/emit-file/reference-files/_expected/cjs/main.js +++ b/test/chunking-form/samples/emit-file/reference-files/_expected/cjs/main.js @@ -1,8 +1,6 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - -var logo = (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __dirname + '/assets/logo1-a5ec488b.svg').href : new URL('assets/logo1-a5ec488b.svg', document.currentScript && document.currentScript.src || document.baseURI).href); +var logo = (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__dirname + '/assets/logo1-FquQRdV3.svg').href : new URL('assets/logo1-FquQRdV3.svg', document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT' && document.currentScript.src || document.baseURI).href); function showImage(url) { console.log(url); diff --git a/test/chunking-form/samples/emit-file/reference-files/_expected/cjs/nested/chunk.js b/test/chunking-form/samples/emit-file/reference-files/_expected/cjs/nested/chunk.js index 8d9f9558b6d..f5430b1cb4c 100644 --- a/test/chunking-form/samples/emit-file/reference-files/_expected/cjs/nested/chunk.js +++ b/test/chunking-form/samples/emit-file/reference-files/_expected/cjs/nested/chunk.js @@ -2,6 +2,6 @@ var main = require('../main.js'); -var logo = (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __dirname + '/../assets/logo2-6d5979e4.svg').href : new URL('../assets/logo2-6d5979e4.svg', document.currentScript && document.currentScript.src || document.baseURI).href); +var logo = (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__dirname + '/../assets/logo2-DJfvToLT.svg').href : new URL('../assets/logo2-DJfvToLT.svg', document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT' && document.currentScript.src || document.baseURI).href); main.showImage(logo); diff --git a/test/chunking-form/samples/deprecated/emit-asset/_expected/system/assets/logo1-a5ec488b.svg b/test/chunking-form/samples/emit-file/reference-files/_expected/es/assets/logo1-FquQRdV3.svg similarity index 100% rename from test/chunking-form/samples/deprecated/emit-asset/_expected/system/assets/logo1-a5ec488b.svg rename to test/chunking-form/samples/emit-file/reference-files/_expected/es/assets/logo1-FquQRdV3.svg diff --git a/test/chunking-form/samples/emit-file/reference-files/_expected/es/assets/logo1-a5ec488b.svg b/test/chunking-form/samples/emit-file/reference-files/_expected/es/assets/logo1-a5ec488b.svg deleted file mode 100644 index cb7e52c5130..00000000000 --- a/test/chunking-form/samples/emit-file/reference-files/_expected/es/assets/logo1-a5ec488b.svg +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/test/chunking-form/samples/emit-file/reference-files/_expected/es/assets/logo2-6d5979e4.svg b/test/chunking-form/samples/emit-file/reference-files/_expected/es/assets/logo2-6d5979e4.svg deleted file mode 100644 index b446284a4cd..00000000000 --- a/test/chunking-form/samples/emit-file/reference-files/_expected/es/assets/logo2-6d5979e4.svg +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/test/chunking-form/samples/deprecated/emit-asset/_expected/es/assets/logo2-6d5979e4.svg b/test/chunking-form/samples/emit-file/reference-files/_expected/es/assets/logo2-DJfvToLT.svg similarity index 100% rename from test/chunking-form/samples/deprecated/emit-asset/_expected/es/assets/logo2-6d5979e4.svg rename to test/chunking-form/samples/emit-file/reference-files/_expected/es/assets/logo2-DJfvToLT.svg diff --git a/test/chunking-form/samples/emit-file/reference-files/_expected/es/main.js b/test/chunking-form/samples/emit-file/reference-files/_expected/es/main.js index 4d8fd5dd758..dad04758a2f 100644 --- a/test/chunking-form/samples/emit-file/reference-files/_expected/es/main.js +++ b/test/chunking-form/samples/emit-file/reference-files/_expected/es/main.js @@ -1,4 +1,4 @@ -var logo = new URL('assets/logo1-a5ec488b.svg', import.meta.url).href; +var logo = new URL('assets/logo1-FquQRdV3.svg', import.meta.url).href; function showImage(url) { console.log(url); diff --git a/test/chunking-form/samples/emit-file/reference-files/_expected/es/nested/chunk.js b/test/chunking-form/samples/emit-file/reference-files/_expected/es/nested/chunk.js index 4491f94fb7e..c6952accfb6 100644 --- a/test/chunking-form/samples/emit-file/reference-files/_expected/es/nested/chunk.js +++ b/test/chunking-form/samples/emit-file/reference-files/_expected/es/nested/chunk.js @@ -1,5 +1,5 @@ import { s as showImage } from '../main.js'; -var logo = new URL('../assets/logo2-6d5979e4.svg', import.meta.url).href; +var logo = new URL('../assets/logo2-DJfvToLT.svg', import.meta.url).href; showImage(logo); diff --git a/test/chunking-form/samples/deprecated/emit-asset/logo1.svg b/test/chunking-form/samples/emit-file/reference-files/_expected/system/assets/logo1-FquQRdV3.svg similarity index 100% rename from test/chunking-form/samples/deprecated/emit-asset/logo1.svg rename to test/chunking-form/samples/emit-file/reference-files/_expected/system/assets/logo1-FquQRdV3.svg diff --git a/test/chunking-form/samples/emit-file/reference-files/_expected/system/assets/logo1-a5ec488b.svg b/test/chunking-form/samples/emit-file/reference-files/_expected/system/assets/logo1-a5ec488b.svg deleted file mode 100644 index cb7e52c5130..00000000000 --- a/test/chunking-form/samples/emit-file/reference-files/_expected/system/assets/logo1-a5ec488b.svg +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/test/chunking-form/samples/emit-file/reference-files/_expected/system/assets/logo2-6d5979e4.svg b/test/chunking-form/samples/emit-file/reference-files/_expected/system/assets/logo2-6d5979e4.svg deleted file mode 100644 index b446284a4cd..00000000000 --- a/test/chunking-form/samples/emit-file/reference-files/_expected/system/assets/logo2-6d5979e4.svg +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/test/chunking-form/samples/deprecated/emit-asset/_expected/system/assets/logo2-6d5979e4.svg b/test/chunking-form/samples/emit-file/reference-files/_expected/system/assets/logo2-DJfvToLT.svg similarity index 100% rename from test/chunking-form/samples/deprecated/emit-asset/_expected/system/assets/logo2-6d5979e4.svg rename to test/chunking-form/samples/emit-file/reference-files/_expected/system/assets/logo2-DJfvToLT.svg diff --git a/test/chunking-form/samples/emit-file/reference-files/_expected/system/main.js b/test/chunking-form/samples/emit-file/reference-files/_expected/system/main.js index c4f3d058bad..ee8aedd7c15 100644 --- a/test/chunking-form/samples/emit-file/reference-files/_expected/system/main.js +++ b/test/chunking-form/samples/emit-file/reference-files/_expected/system/main.js @@ -1,11 +1,11 @@ -System.register([], function (exports, module) { +System.register([], (function (exports, module) { 'use strict'; return { - execute: function () { + execute: (function () { - exports('s', showImage); + exports("s", showImage); - var logo = new URL('assets/logo1-a5ec488b.svg', module.meta.url).href; + var logo = new URL('assets/logo1-FquQRdV3.svg', module.meta.url).href; function showImage(url) { console.log(url); @@ -19,6 +19,6 @@ System.register([], function (exports, module) { showImage(logo); module.import('./nested/chunk.js'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/emit-file/reference-files/_expected/system/nested/chunk.js b/test/chunking-form/samples/emit-file/reference-files/_expected/system/nested/chunk.js index 627ee24d913..8a5cd4e5611 100644 --- a/test/chunking-form/samples/emit-file/reference-files/_expected/system/nested/chunk.js +++ b/test/chunking-form/samples/emit-file/reference-files/_expected/system/nested/chunk.js @@ -1,16 +1,16 @@ -System.register(['../main.js'], function (exports, module) { +System.register(['../main.js'], (function (exports, module) { 'use strict'; var showImage; return { setters: [function (module) { showImage = module.s; }], - execute: function () { + execute: (function () { - var logo = new URL('../assets/logo2-6d5979e4.svg', module.meta.url).href; + var logo = new URL('../assets/logo2-DJfvToLT.svg', module.meta.url).href; showImage(logo); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/emit-file/sanitize-file-name/_config.js b/test/chunking-form/samples/emit-file/sanitize-file-name/_config.js index 39a76de71d6..0ff640af2f8 100644 --- a/test/chunking-form/samples/emit-file/sanitize-file-name/_config.js +++ b/test/chunking-form/samples/emit-file/sanitize-file-name/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'allows adding additional chunks and retrieving their file name', options: { input: 'main', @@ -18,4 +18,4 @@ module.exports = { } } } -}; +}); diff --git a/test/chunking-form/samples/emit-file/sanitize-file-name/_expected/amd/generated-_virtual.js b/test/chunking-form/samples/emit-file/sanitize-file-name/_expected/amd/generated-_virtual.js index 32246cb68ba..ccc5826554f 100644 --- a/test/chunking-form/samples/emit-file/sanitize-file-name/_expected/amd/generated-_virtual.js +++ b/test/chunking-form/samples/emit-file/sanitize-file-name/_expected/amd/generated-_virtual.js @@ -1,5 +1,5 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; console.log('virtual'); -}); +})); diff --git a/test/chunking-form/samples/emit-file/sanitize-file-name/_expected/amd/main.js b/test/chunking-form/samples/emit-file/sanitize-file-name/_expected/amd/main.js index dcbf09f0392..b764a43bb0b 100644 --- a/test/chunking-form/samples/emit-file/sanitize-file-name/_expected/amd/main.js +++ b/test/chunking-form/samples/emit-file/sanitize-file-name/_expected/amd/main.js @@ -1,7 +1,7 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; var value = 42; console.log('main', value); -}); +})); diff --git a/test/chunking-form/samples/emit-file/sanitize-file-name/_expected/system/generated-_virtual.js b/test/chunking-form/samples/emit-file/sanitize-file-name/_expected/system/generated-_virtual.js index e8682500989..5059379eb6c 100644 --- a/test/chunking-form/samples/emit-file/sanitize-file-name/_expected/system/generated-_virtual.js +++ b/test/chunking-form/samples/emit-file/sanitize-file-name/_expected/system/generated-_virtual.js @@ -1,10 +1,10 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { console.log('virtual'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/emit-file/sanitize-file-name/_expected/system/main.js b/test/chunking-form/samples/emit-file/sanitize-file-name/_expected/system/main.js index a824ae3115d..158865e7667 100644 --- a/test/chunking-form/samples/emit-file/sanitize-file-name/_expected/system/main.js +++ b/test/chunking-form/samples/emit-file/sanitize-file-name/_expected/system/main.js @@ -1,12 +1,12 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { var value = 42; console.log('main', value); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/emit-file/set-asset-source/_config.js b/test/chunking-form/samples/emit-file/set-asset-source/_config.js index c70db0ddc39..aef65a793fe 100644 --- a/test/chunking-form/samples/emit-file/set-asset-source/_config.js +++ b/test/chunking-form/samples/emit-file/set-asset-source/_config.js @@ -13,7 +13,7 @@ let renderChunkNamed; let generateBundle; let generateBundleNamed; -module.exports = { +module.exports = defineTest({ description: 'supports setting the asset source during generate', options: { input: ['main.js'], @@ -37,14 +37,12 @@ module.exports = { `export const renderStart = import.meta.ROLLUP_FILE_URL_${renderStart};\n` + `export const renderStartNamed = import.meta.ROLLUP_FILE_URL_${renderStartNamed};\n` + `export const renderStartNamedImmediately = '${this.getFileName(renderStartNamed)}';\n` + - `export const banner = import.meta.ROLLUP_FILE_URL_${banner};\n` + `export const bannerNamed = import.meta.ROLLUP_FILE_URL_${bannerNamed};\n` + - `export const footer = import.meta.ROLLUP_FILE_URL_${footer};\n` + `export const footerNamed = import.meta.ROLLUP_FILE_URL_${footerNamed};\n` + - `export const intro = import.meta.ROLLUP_FILE_URL_${intro};\n` + `export const introNamed = import.meta.ROLLUP_FILE_URL_${introNamed};\n` + - `export const outro = import.meta.ROLLUP_FILE_URL_${outro};\n` + - `export const outroNamed = import.meta.ROLLUP_FILE_URL_${outroNamed};\n` + `export const outroNamed = import.meta.ROLLUP_FILE_URL_${outroNamed};\n` + + `export const renderChunkNamed = import.meta.ROLLUP_FILE_URL_${renderChunkNamed};\n` + + `export const generateBundleNamed = import.meta.ROLLUP_FILE_URL_${generateBundleNamed};\n` ); }, renderStart() { @@ -90,4 +88,4 @@ module.exports = { } } } -}; +}); diff --git a/test/chunking-form/samples/emit-file/set-asset-source/_expected/amd/assets/banner-2b65cc0c.txt b/test/chunking-form/samples/emit-file/set-asset-source/_expected/amd/assets/banner--qPJuKPL.txt similarity index 100% rename from test/chunking-form/samples/emit-file/set-asset-source/_expected/amd/assets/banner-2b65cc0c.txt rename to test/chunking-form/samples/emit-file/set-asset-source/_expected/amd/assets/banner--qPJuKPL.txt diff --git a/test/chunking-form/samples/emit-file/set-asset-source/_expected/amd/assets/footer-e1d2fccb.txt b/test/chunking-form/samples/emit-file/set-asset-source/_expected/amd/assets/footer-CV6kYft-.txt similarity index 100% rename from test/chunking-form/samples/emit-file/set-asset-source/_expected/amd/assets/footer-e1d2fccb.txt rename to test/chunking-form/samples/emit-file/set-asset-source/_expected/amd/assets/footer-CV6kYft-.txt diff --git a/test/chunking-form/samples/emit-file/set-asset-source/_expected/amd/assets/generateBundle-BBHXGh_d.txt b/test/chunking-form/samples/emit-file/set-asset-source/_expected/amd/assets/generateBundle-BBHXGh_d.txt new file mode 100644 index 00000000000..cfc6ec09513 --- /dev/null +++ b/test/chunking-form/samples/emit-file/set-asset-source/_expected/amd/assets/generateBundle-BBHXGh_d.txt @@ -0,0 +1 @@ +generateBundle amd with assets/generateBundle-format-DmNW-T7b.txt \ No newline at end of file diff --git a/test/chunking-form/samples/emit-file/set-asset-source/_expected/amd/assets/generateBundle-ea61028d.txt b/test/chunking-form/samples/emit-file/set-asset-source/_expected/amd/assets/generateBundle-ea61028d.txt deleted file mode 100644 index a11bda7ebad..00000000000 --- a/test/chunking-form/samples/emit-file/set-asset-source/_expected/amd/assets/generateBundle-ea61028d.txt +++ /dev/null @@ -1 +0,0 @@ -generateBundle amd with assets/generateBundle-format-78d67aa8.txt \ No newline at end of file diff --git a/test/chunking-form/samples/emit-file/set-asset-source/_expected/amd/assets/generateBundle-format-78d67aa8.txt b/test/chunking-form/samples/emit-file/set-asset-source/_expected/amd/assets/generateBundle-format-DmNW-T7b.txt similarity index 100% rename from test/chunking-form/samples/emit-file/set-asset-source/_expected/amd/assets/generateBundle-format-78d67aa8.txt rename to test/chunking-form/samples/emit-file/set-asset-source/_expected/amd/assets/generateBundle-format-DmNW-T7b.txt diff --git a/test/chunking-form/samples/emit-file/set-asset-source/_expected/amd/assets/intro-520a8116.txt b/test/chunking-form/samples/emit-file/set-asset-source/_expected/amd/assets/intro-1PpQv4h6.txt similarity index 100% rename from test/chunking-form/samples/emit-file/set-asset-source/_expected/amd/assets/intro-520a8116.txt rename to test/chunking-form/samples/emit-file/set-asset-source/_expected/amd/assets/intro-1PpQv4h6.txt diff --git a/test/chunking-form/samples/emit-file/set-asset-source/_expected/amd/assets/outro-21f77720.txt b/test/chunking-form/samples/emit-file/set-asset-source/_expected/amd/assets/outro-D8xwWt8B.txt similarity index 100% rename from test/chunking-form/samples/emit-file/set-asset-source/_expected/amd/assets/outro-21f77720.txt rename to test/chunking-form/samples/emit-file/set-asset-source/_expected/amd/assets/outro-D8xwWt8B.txt diff --git a/test/chunking-form/samples/emit-file/set-asset-source/_expected/amd/assets/renderChunk-a91c7c32.txt b/test/chunking-form/samples/emit-file/set-asset-source/_expected/amd/assets/renderChunk-MxjJNaqP.txt similarity index 100% rename from test/chunking-form/samples/emit-file/set-asset-source/_expected/amd/assets/renderChunk-a91c7c32.txt rename to test/chunking-form/samples/emit-file/set-asset-source/_expected/amd/assets/renderChunk-MxjJNaqP.txt diff --git a/test/chunking-form/samples/emit-file/set-asset-source/_expected/amd/assets/renderStart-66600c78.txt b/test/chunking-form/samples/emit-file/set-asset-source/_expected/amd/assets/renderStart-B4XObdBk.txt similarity index 100% rename from test/chunking-form/samples/emit-file/set-asset-source/_expected/amd/assets/renderStart-66600c78.txt rename to test/chunking-form/samples/emit-file/set-asset-source/_expected/amd/assets/renderStart-B4XObdBk.txt diff --git a/test/chunking-form/samples/emit-file/set-asset-source/_expected/amd/generateBundle.txt b/test/chunking-form/samples/emit-file/set-asset-source/_expected/amd/generateBundle.txt index a11bda7ebad..cfc6ec09513 100644 --- a/test/chunking-form/samples/emit-file/set-asset-source/_expected/amd/generateBundle.txt +++ b/test/chunking-form/samples/emit-file/set-asset-source/_expected/amd/generateBundle.txt @@ -1 +1 @@ -generateBundle amd with assets/generateBundle-format-78d67aa8.txt \ No newline at end of file +generateBundle amd with assets/generateBundle-format-DmNW-T7b.txt \ No newline at end of file diff --git a/test/chunking-form/samples/emit-file/set-asset-source/_expected/amd/main.js b/test/chunking-form/samples/emit-file/set-asset-source/_expected/amd/main.js index 6dd36994c0f..b815307122b 100644 --- a/test/chunking-form/samples/emit-file/set-asset-source/_expected/amd/main.js +++ b/test/chunking-form/samples/emit-file/set-asset-source/_expected/amd/main.js @@ -1,29 +1,23 @@ -define(['require', 'exports'], function (require, exports) { 'use strict'; +define(['require', 'exports'], (function (require, exports) { 'use strict'; - const renderStart = new URL(require.toUrl('./assets/renderStart-66600c78.txt'), document.baseURI).href; + const renderStart = new URL(require.toUrl('./assets/renderStart-B4XObdBk.txt'), document.baseURI).href; const renderStartNamed = new URL(require.toUrl('./renderStart.txt'), document.baseURI).href; const renderStartNamedImmediately = 'renderStart.txt'; - const banner = new URL(require.toUrl('./assets/banner-2b65cc0c.txt'), document.baseURI).href; const bannerNamed = new URL(require.toUrl('./banner.txt'), document.baseURI).href; - const footer = new URL(require.toUrl('./assets/footer-e1d2fccb.txt'), document.baseURI).href; const footerNamed = new URL(require.toUrl('./footer.txt'), document.baseURI).href; - const intro = new URL(require.toUrl('./assets/intro-520a8116.txt'), document.baseURI).href; const introNamed = new URL(require.toUrl('./intro.txt'), document.baseURI).href; - const outro = new URL(require.toUrl('./assets/outro-21f77720.txt'), document.baseURI).href; const outroNamed = new URL(require.toUrl('./outro.txt'), document.baseURI).href; + const renderChunkNamed = new URL(require.toUrl('./renderChunk.txt'), document.baseURI).href; + const generateBundleNamed = new URL(require.toUrl('./generateBundle.txt'), document.baseURI).href; - exports.banner = banner; exports.bannerNamed = bannerNamed; - exports.footer = footer; exports.footerNamed = footerNamed; - exports.intro = intro; + exports.generateBundleNamed = generateBundleNamed; exports.introNamed = introNamed; - exports.outro = outro; exports.outroNamed = outroNamed; + exports.renderChunkNamed = renderChunkNamed; exports.renderStart = renderStart; exports.renderStartNamed = renderStartNamed; exports.renderStartNamedImmediately = renderStartNamedImmediately; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/emit-file/set-asset-source/_expected/cjs/assets/banner-2b65cc0c.txt b/test/chunking-form/samples/emit-file/set-asset-source/_expected/cjs/assets/banner--qPJuKPL.txt similarity index 100% rename from test/chunking-form/samples/emit-file/set-asset-source/_expected/cjs/assets/banner-2b65cc0c.txt rename to test/chunking-form/samples/emit-file/set-asset-source/_expected/cjs/assets/banner--qPJuKPL.txt diff --git a/test/chunking-form/samples/emit-file/set-asset-source/_expected/cjs/assets/footer-e1d2fccb.txt b/test/chunking-form/samples/emit-file/set-asset-source/_expected/cjs/assets/footer-CV6kYft-.txt similarity index 100% rename from test/chunking-form/samples/emit-file/set-asset-source/_expected/cjs/assets/footer-e1d2fccb.txt rename to test/chunking-form/samples/emit-file/set-asset-source/_expected/cjs/assets/footer-CV6kYft-.txt diff --git a/test/chunking-form/samples/emit-file/set-asset-source/_expected/cjs/assets/generateBundle-7ba089df.txt b/test/chunking-form/samples/emit-file/set-asset-source/_expected/cjs/assets/generateBundle-7ba089df.txt deleted file mode 100644 index 3f6be650ed5..00000000000 --- a/test/chunking-form/samples/emit-file/set-asset-source/_expected/cjs/assets/generateBundle-7ba089df.txt +++ /dev/null @@ -1 +0,0 @@ -generateBundle cjs with assets/generateBundle-format-ef46b0c8.txt \ No newline at end of file diff --git a/test/chunking-form/samples/emit-file/set-asset-source/_expected/cjs/assets/generateBundle-CtuF2NSi.txt b/test/chunking-form/samples/emit-file/set-asset-source/_expected/cjs/assets/generateBundle-CtuF2NSi.txt new file mode 100644 index 00000000000..9948062f456 --- /dev/null +++ b/test/chunking-form/samples/emit-file/set-asset-source/_expected/cjs/assets/generateBundle-CtuF2NSi.txt @@ -0,0 +1 @@ +generateBundle cjs with assets/generateBundle-format-D1nvefY4.txt \ No newline at end of file diff --git a/test/chunking-form/samples/emit-file/set-asset-source/_expected/cjs/assets/generateBundle-format-ef46b0c8.txt b/test/chunking-form/samples/emit-file/set-asset-source/_expected/cjs/assets/generateBundle-format-D1nvefY4.txt similarity index 100% rename from test/chunking-form/samples/emit-file/set-asset-source/_expected/cjs/assets/generateBundle-format-ef46b0c8.txt rename to test/chunking-form/samples/emit-file/set-asset-source/_expected/cjs/assets/generateBundle-format-D1nvefY4.txt diff --git a/test/chunking-form/samples/emit-file/set-asset-source/_expected/cjs/assets/intro-520a8116.txt b/test/chunking-form/samples/emit-file/set-asset-source/_expected/cjs/assets/intro-1PpQv4h6.txt similarity index 100% rename from test/chunking-form/samples/emit-file/set-asset-source/_expected/cjs/assets/intro-520a8116.txt rename to test/chunking-form/samples/emit-file/set-asset-source/_expected/cjs/assets/intro-1PpQv4h6.txt diff --git a/test/chunking-form/samples/emit-file/set-asset-source/_expected/cjs/assets/outro-21f77720.txt b/test/chunking-form/samples/emit-file/set-asset-source/_expected/cjs/assets/outro-D8xwWt8B.txt similarity index 100% rename from test/chunking-form/samples/emit-file/set-asset-source/_expected/cjs/assets/outro-21f77720.txt rename to test/chunking-form/samples/emit-file/set-asset-source/_expected/cjs/assets/outro-D8xwWt8B.txt diff --git a/test/chunking-form/samples/emit-file/set-asset-source/_expected/cjs/assets/renderChunk-a91c7c32.txt b/test/chunking-form/samples/emit-file/set-asset-source/_expected/cjs/assets/renderChunk-MxjJNaqP.txt similarity index 100% rename from test/chunking-form/samples/emit-file/set-asset-source/_expected/cjs/assets/renderChunk-a91c7c32.txt rename to test/chunking-form/samples/emit-file/set-asset-source/_expected/cjs/assets/renderChunk-MxjJNaqP.txt diff --git a/test/chunking-form/samples/emit-file/set-asset-source/_expected/cjs/assets/renderStart-66600c78.txt b/test/chunking-form/samples/emit-file/set-asset-source/_expected/cjs/assets/renderStart-B4XObdBk.txt similarity index 100% rename from test/chunking-form/samples/emit-file/set-asset-source/_expected/cjs/assets/renderStart-66600c78.txt rename to test/chunking-form/samples/emit-file/set-asset-source/_expected/cjs/assets/renderStart-B4XObdBk.txt diff --git a/test/chunking-form/samples/emit-file/set-asset-source/_expected/cjs/generateBundle.txt b/test/chunking-form/samples/emit-file/set-asset-source/_expected/cjs/generateBundle.txt index 3f6be650ed5..9948062f456 100644 --- a/test/chunking-form/samples/emit-file/set-asset-source/_expected/cjs/generateBundle.txt +++ b/test/chunking-form/samples/emit-file/set-asset-source/_expected/cjs/generateBundle.txt @@ -1 +1 @@ -generateBundle cjs with assets/generateBundle-format-ef46b0c8.txt \ No newline at end of file +generateBundle cjs with assets/generateBundle-format-D1nvefY4.txt \ No newline at end of file diff --git a/test/chunking-form/samples/emit-file/set-asset-source/_expected/cjs/main.js b/test/chunking-form/samples/emit-file/set-asset-source/_expected/cjs/main.js index 51058623000..20a405e4e31 100644 --- a/test/chunking-form/samples/emit-file/set-asset-source/_expected/cjs/main.js +++ b/test/chunking-form/samples/emit-file/set-asset-source/_expected/cjs/main.js @@ -1,27 +1,21 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - -const renderStart = (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __dirname + '/assets/renderStart-66600c78.txt').href : new URL('assets/renderStart-66600c78.txt', document.currentScript && document.currentScript.src || document.baseURI).href); -const renderStartNamed = (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __dirname + '/renderStart.txt').href : new URL('renderStart.txt', document.currentScript && document.currentScript.src || document.baseURI).href); +const renderStart = (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__dirname + '/assets/renderStart-B4XObdBk.txt').href : new URL('assets/renderStart-B4XObdBk.txt', document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT' && document.currentScript.src || document.baseURI).href); +const renderStartNamed = (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__dirname + '/renderStart.txt').href : new URL('renderStart.txt', document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT' && document.currentScript.src || document.baseURI).href); const renderStartNamedImmediately = 'renderStart.txt'; -const banner = (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __dirname + '/assets/banner-2b65cc0c.txt').href : new URL('assets/banner-2b65cc0c.txt', document.currentScript && document.currentScript.src || document.baseURI).href); -const bannerNamed = (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __dirname + '/banner.txt').href : new URL('banner.txt', document.currentScript && document.currentScript.src || document.baseURI).href); -const footer = (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __dirname + '/assets/footer-e1d2fccb.txt').href : new URL('assets/footer-e1d2fccb.txt', document.currentScript && document.currentScript.src || document.baseURI).href); -const footerNamed = (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __dirname + '/footer.txt').href : new URL('footer.txt', document.currentScript && document.currentScript.src || document.baseURI).href); -const intro = (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __dirname + '/assets/intro-520a8116.txt').href : new URL('assets/intro-520a8116.txt', document.currentScript && document.currentScript.src || document.baseURI).href); -const introNamed = (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __dirname + '/intro.txt').href : new URL('intro.txt', document.currentScript && document.currentScript.src || document.baseURI).href); -const outro = (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __dirname + '/assets/outro-21f77720.txt').href : new URL('assets/outro-21f77720.txt', document.currentScript && document.currentScript.src || document.baseURI).href); -const outroNamed = (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __dirname + '/outro.txt').href : new URL('outro.txt', document.currentScript && document.currentScript.src || document.baseURI).href); +const bannerNamed = (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__dirname + '/banner.txt').href : new URL('banner.txt', document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT' && document.currentScript.src || document.baseURI).href); +const footerNamed = (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__dirname + '/footer.txt').href : new URL('footer.txt', document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT' && document.currentScript.src || document.baseURI).href); +const introNamed = (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__dirname + '/intro.txt').href : new URL('intro.txt', document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT' && document.currentScript.src || document.baseURI).href); +const outroNamed = (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__dirname + '/outro.txt').href : new URL('outro.txt', document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT' && document.currentScript.src || document.baseURI).href); +const renderChunkNamed = (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__dirname + '/renderChunk.txt').href : new URL('renderChunk.txt', document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT' && document.currentScript.src || document.baseURI).href); +const generateBundleNamed = (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__dirname + '/generateBundle.txt').href : new URL('generateBundle.txt', document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT' && document.currentScript.src || document.baseURI).href); -exports.banner = banner; exports.bannerNamed = bannerNamed; -exports.footer = footer; exports.footerNamed = footerNamed; -exports.intro = intro; +exports.generateBundleNamed = generateBundleNamed; exports.introNamed = introNamed; -exports.outro = outro; exports.outroNamed = outroNamed; +exports.renderChunkNamed = renderChunkNamed; exports.renderStart = renderStart; exports.renderStartNamed = renderStartNamed; exports.renderStartNamedImmediately = renderStartNamedImmediately; diff --git a/test/chunking-form/samples/emit-file/set-asset-source/_expected/es/assets/banner-2b65cc0c.txt b/test/chunking-form/samples/emit-file/set-asset-source/_expected/es/assets/banner--qPJuKPL.txt similarity index 100% rename from test/chunking-form/samples/emit-file/set-asset-source/_expected/es/assets/banner-2b65cc0c.txt rename to test/chunking-form/samples/emit-file/set-asset-source/_expected/es/assets/banner--qPJuKPL.txt diff --git a/test/chunking-form/samples/emit-file/set-asset-source/_expected/es/assets/footer-e1d2fccb.txt b/test/chunking-form/samples/emit-file/set-asset-source/_expected/es/assets/footer-CV6kYft-.txt similarity index 100% rename from test/chunking-form/samples/emit-file/set-asset-source/_expected/es/assets/footer-e1d2fccb.txt rename to test/chunking-form/samples/emit-file/set-asset-source/_expected/es/assets/footer-CV6kYft-.txt diff --git a/test/chunking-form/samples/emit-file/set-asset-source/_expected/es/assets/generateBundle-7e84678a.txt b/test/chunking-form/samples/emit-file/set-asset-source/_expected/es/assets/generateBundle-7e84678a.txt deleted file mode 100644 index 70119149dc7..00000000000 --- a/test/chunking-form/samples/emit-file/set-asset-source/_expected/es/assets/generateBundle-7e84678a.txt +++ /dev/null @@ -1 +0,0 @@ -generateBundle es with assets/generateBundle-format-8b573c58.txt \ No newline at end of file diff --git a/test/chunking-form/samples/emit-file/set-asset-source/_expected/es/assets/generateBundle-C9HFj0EF.txt b/test/chunking-form/samples/emit-file/set-asset-source/_expected/es/assets/generateBundle-C9HFj0EF.txt new file mode 100644 index 00000000000..c33d5516494 --- /dev/null +++ b/test/chunking-form/samples/emit-file/set-asset-source/_expected/es/assets/generateBundle-C9HFj0EF.txt @@ -0,0 +1 @@ +generateBundle es with assets/generateBundle-format-B6fu0hOK.txt \ No newline at end of file diff --git a/test/chunking-form/samples/emit-file/set-asset-source/_expected/es/assets/generateBundle-format-8b573c58.txt b/test/chunking-form/samples/emit-file/set-asset-source/_expected/es/assets/generateBundle-format-B6fu0hOK.txt similarity index 100% rename from test/chunking-form/samples/emit-file/set-asset-source/_expected/es/assets/generateBundle-format-8b573c58.txt rename to test/chunking-form/samples/emit-file/set-asset-source/_expected/es/assets/generateBundle-format-B6fu0hOK.txt diff --git a/test/chunking-form/samples/emit-file/set-asset-source/_expected/es/assets/intro-520a8116.txt b/test/chunking-form/samples/emit-file/set-asset-source/_expected/es/assets/intro-1PpQv4h6.txt similarity index 100% rename from test/chunking-form/samples/emit-file/set-asset-source/_expected/es/assets/intro-520a8116.txt rename to test/chunking-form/samples/emit-file/set-asset-source/_expected/es/assets/intro-1PpQv4h6.txt diff --git a/test/chunking-form/samples/emit-file/set-asset-source/_expected/es/assets/outro-21f77720.txt b/test/chunking-form/samples/emit-file/set-asset-source/_expected/es/assets/outro-D8xwWt8B.txt similarity index 100% rename from test/chunking-form/samples/emit-file/set-asset-source/_expected/es/assets/outro-21f77720.txt rename to test/chunking-form/samples/emit-file/set-asset-source/_expected/es/assets/outro-D8xwWt8B.txt diff --git a/test/chunking-form/samples/emit-file/set-asset-source/_expected/es/assets/renderChunk-a91c7c32.txt b/test/chunking-form/samples/emit-file/set-asset-source/_expected/es/assets/renderChunk-MxjJNaqP.txt similarity index 100% rename from test/chunking-form/samples/emit-file/set-asset-source/_expected/es/assets/renderChunk-a91c7c32.txt rename to test/chunking-form/samples/emit-file/set-asset-source/_expected/es/assets/renderChunk-MxjJNaqP.txt diff --git a/test/chunking-form/samples/emit-file/set-asset-source/_expected/es/assets/renderStart-66600c78.txt b/test/chunking-form/samples/emit-file/set-asset-source/_expected/es/assets/renderStart-B4XObdBk.txt similarity index 100% rename from test/chunking-form/samples/emit-file/set-asset-source/_expected/es/assets/renderStart-66600c78.txt rename to test/chunking-form/samples/emit-file/set-asset-source/_expected/es/assets/renderStart-B4XObdBk.txt diff --git a/test/chunking-form/samples/emit-file/set-asset-source/_expected/es/generateBundle.txt b/test/chunking-form/samples/emit-file/set-asset-source/_expected/es/generateBundle.txt index 70119149dc7..c33d5516494 100644 --- a/test/chunking-form/samples/emit-file/set-asset-source/_expected/es/generateBundle.txt +++ b/test/chunking-form/samples/emit-file/set-asset-source/_expected/es/generateBundle.txt @@ -1 +1 @@ -generateBundle es with assets/generateBundle-format-8b573c58.txt \ No newline at end of file +generateBundle es with assets/generateBundle-format-B6fu0hOK.txt \ No newline at end of file diff --git a/test/chunking-form/samples/emit-file/set-asset-source/_expected/es/main.js b/test/chunking-form/samples/emit-file/set-asset-source/_expected/es/main.js index 067f0c112fc..bfcf9969caa 100644 --- a/test/chunking-form/samples/emit-file/set-asset-source/_expected/es/main.js +++ b/test/chunking-form/samples/emit-file/set-asset-source/_expected/es/main.js @@ -1,13 +1,11 @@ -const renderStart = new URL('assets/renderStart-66600c78.txt', import.meta.url).href; +const renderStart = new URL('assets/renderStart-B4XObdBk.txt', import.meta.url).href; const renderStartNamed = new URL('renderStart.txt', import.meta.url).href; const renderStartNamedImmediately = 'renderStart.txt'; -const banner = new URL('assets/banner-2b65cc0c.txt', import.meta.url).href; const bannerNamed = new URL('banner.txt', import.meta.url).href; -const footer = new URL('assets/footer-e1d2fccb.txt', import.meta.url).href; const footerNamed = new URL('footer.txt', import.meta.url).href; -const intro = new URL('assets/intro-520a8116.txt', import.meta.url).href; const introNamed = new URL('intro.txt', import.meta.url).href; -const outro = new URL('assets/outro-21f77720.txt', import.meta.url).href; const outroNamed = new URL('outro.txt', import.meta.url).href; +const renderChunkNamed = new URL('renderChunk.txt', import.meta.url).href; +const generateBundleNamed = new URL('generateBundle.txt', import.meta.url).href; -export { banner, bannerNamed, footer, footerNamed, intro, introNamed, outro, outroNamed, renderStart, renderStartNamed, renderStartNamedImmediately }; +export { bannerNamed, footerNamed, generateBundleNamed, introNamed, outroNamed, renderChunkNamed, renderStart, renderStartNamed, renderStartNamedImmediately }; diff --git a/test/chunking-form/samples/emit-file/set-asset-source/_expected/system/assets/banner-2b65cc0c.txt b/test/chunking-form/samples/emit-file/set-asset-source/_expected/system/assets/banner--qPJuKPL.txt similarity index 100% rename from test/chunking-form/samples/emit-file/set-asset-source/_expected/system/assets/banner-2b65cc0c.txt rename to test/chunking-form/samples/emit-file/set-asset-source/_expected/system/assets/banner--qPJuKPL.txt diff --git a/test/chunking-form/samples/emit-file/set-asset-source/_expected/system/assets/footer-e1d2fccb.txt b/test/chunking-form/samples/emit-file/set-asset-source/_expected/system/assets/footer-CV6kYft-.txt similarity index 100% rename from test/chunking-form/samples/emit-file/set-asset-source/_expected/system/assets/footer-e1d2fccb.txt rename to test/chunking-form/samples/emit-file/set-asset-source/_expected/system/assets/footer-CV6kYft-.txt diff --git a/test/chunking-form/samples/emit-file/set-asset-source/_expected/system/assets/generateBundle-dd5a26a4.txt b/test/chunking-form/samples/emit-file/set-asset-source/_expected/system/assets/generateBundle-dd5a26a4.txt deleted file mode 100644 index fdbb98a9d52..00000000000 --- a/test/chunking-form/samples/emit-file/set-asset-source/_expected/system/assets/generateBundle-dd5a26a4.txt +++ /dev/null @@ -1 +0,0 @@ -generateBundle system with assets/generateBundle-format-7df86840.txt \ No newline at end of file diff --git a/test/chunking-form/samples/emit-file/set-asset-source/_expected/system/assets/generateBundle-format-7df86840.txt b/test/chunking-form/samples/emit-file/set-asset-source/_expected/system/assets/generateBundle-format-BcOEo4R3.txt similarity index 100% rename from test/chunking-form/samples/emit-file/set-asset-source/_expected/system/assets/generateBundle-format-7df86840.txt rename to test/chunking-form/samples/emit-file/set-asset-source/_expected/system/assets/generateBundle-format-BcOEo4R3.txt diff --git a/test/chunking-form/samples/emit-file/set-asset-source/_expected/system/assets/generateBundle-oIb15WdK.txt b/test/chunking-form/samples/emit-file/set-asset-source/_expected/system/assets/generateBundle-oIb15WdK.txt new file mode 100644 index 00000000000..c4f8895488a --- /dev/null +++ b/test/chunking-form/samples/emit-file/set-asset-source/_expected/system/assets/generateBundle-oIb15WdK.txt @@ -0,0 +1 @@ +generateBundle system with assets/generateBundle-format-BcOEo4R3.txt \ No newline at end of file diff --git a/test/chunking-form/samples/emit-file/set-asset-source/_expected/system/assets/intro-520a8116.txt b/test/chunking-form/samples/emit-file/set-asset-source/_expected/system/assets/intro-1PpQv4h6.txt similarity index 100% rename from test/chunking-form/samples/emit-file/set-asset-source/_expected/system/assets/intro-520a8116.txt rename to test/chunking-form/samples/emit-file/set-asset-source/_expected/system/assets/intro-1PpQv4h6.txt diff --git a/test/chunking-form/samples/emit-file/set-asset-source/_expected/system/assets/outro-21f77720.txt b/test/chunking-form/samples/emit-file/set-asset-source/_expected/system/assets/outro-D8xwWt8B.txt similarity index 100% rename from test/chunking-form/samples/emit-file/set-asset-source/_expected/system/assets/outro-21f77720.txt rename to test/chunking-form/samples/emit-file/set-asset-source/_expected/system/assets/outro-D8xwWt8B.txt diff --git a/test/chunking-form/samples/emit-file/set-asset-source/_expected/system/assets/renderChunk-a91c7c32.txt b/test/chunking-form/samples/emit-file/set-asset-source/_expected/system/assets/renderChunk-MxjJNaqP.txt similarity index 100% rename from test/chunking-form/samples/emit-file/set-asset-source/_expected/system/assets/renderChunk-a91c7c32.txt rename to test/chunking-form/samples/emit-file/set-asset-source/_expected/system/assets/renderChunk-MxjJNaqP.txt diff --git a/test/chunking-form/samples/emit-file/set-asset-source/_expected/system/assets/renderStart-66600c78.txt b/test/chunking-form/samples/emit-file/set-asset-source/_expected/system/assets/renderStart-B4XObdBk.txt similarity index 100% rename from test/chunking-form/samples/emit-file/set-asset-source/_expected/system/assets/renderStart-66600c78.txt rename to test/chunking-form/samples/emit-file/set-asset-source/_expected/system/assets/renderStart-B4XObdBk.txt diff --git a/test/chunking-form/samples/emit-file/set-asset-source/_expected/system/generateBundle.txt b/test/chunking-form/samples/emit-file/set-asset-source/_expected/system/generateBundle.txt index fdbb98a9d52..c4f8895488a 100644 --- a/test/chunking-form/samples/emit-file/set-asset-source/_expected/system/generateBundle.txt +++ b/test/chunking-form/samples/emit-file/set-asset-source/_expected/system/generateBundle.txt @@ -1 +1 @@ -generateBundle system with assets/generateBundle-format-7df86840.txt \ No newline at end of file +generateBundle system with assets/generateBundle-format-BcOEo4R3.txt \ No newline at end of file diff --git a/test/chunking-form/samples/emit-file/set-asset-source/_expected/system/main.js b/test/chunking-form/samples/emit-file/set-asset-source/_expected/system/main.js index 5910199d4fd..5488e4d39be 100644 --- a/test/chunking-form/samples/emit-file/set-asset-source/_expected/system/main.js +++ b/test/chunking-form/samples/emit-file/set-asset-source/_expected/system/main.js @@ -1,20 +1,18 @@ -System.register([], function (exports, module) { +System.register([], (function (exports, module) { 'use strict'; return { - execute: function () { + execute: (function () { - const renderStart = exports('renderStart', new URL('assets/renderStart-66600c78.txt', module.meta.url).href); - const renderStartNamed = exports('renderStartNamed', new URL('renderStart.txt', module.meta.url).href); - const renderStartNamedImmediately = exports('renderStartNamedImmediately', 'renderStart.txt'); - const banner = exports('banner', new URL('assets/banner-2b65cc0c.txt', module.meta.url).href); - const bannerNamed = exports('bannerNamed', new URL('banner.txt', module.meta.url).href); - const footer = exports('footer', new URL('assets/footer-e1d2fccb.txt', module.meta.url).href); - const footerNamed = exports('footerNamed', new URL('footer.txt', module.meta.url).href); - const intro = exports('intro', new URL('assets/intro-520a8116.txt', module.meta.url).href); - const introNamed = exports('introNamed', new URL('intro.txt', module.meta.url).href); - const outro = exports('outro', new URL('assets/outro-21f77720.txt', module.meta.url).href); - const outroNamed = exports('outroNamed', new URL('outro.txt', module.meta.url).href); + const renderStart = exports("renderStart", new URL('assets/renderStart-B4XObdBk.txt', module.meta.url).href); + const renderStartNamed = exports("renderStartNamed", new URL('renderStart.txt', module.meta.url).href); + const renderStartNamedImmediately = exports("renderStartNamedImmediately", 'renderStart.txt'); + const bannerNamed = exports("bannerNamed", new URL('banner.txt', module.meta.url).href); + const footerNamed = exports("footerNamed", new URL('footer.txt', module.meta.url).href); + const introNamed = exports("introNamed", new URL('intro.txt', module.meta.url).href); + const outroNamed = exports("outroNamed", new URL('outro.txt', module.meta.url).href); + const renderChunkNamed = exports("renderChunkNamed", new URL('renderChunk.txt', module.meta.url).href); + const generateBundleNamed = exports("generateBundleNamed", new URL('generateBundle.txt', module.meta.url).href); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/empty-chunks/_config.js b/test/chunking-form/samples/empty-chunks/_config.js index 4f26f947897..67b27d78bf0 100644 --- a/test/chunking-form/samples/empty-chunks/_config.js +++ b/test/chunking-form/samples/empty-chunks/_config.js @@ -1,7 +1,7 @@ -module.exports = { +module.exports = defineTest({ description: 'empty chunk pruning', expectedWarnings: ['EMPTY_BUNDLE'], options: { input: ['main1.js', 'main2.js'] } -}; +}); diff --git a/test/chunking-form/samples/empty-chunks/_expected/amd/main1.js b/test/chunking-form/samples/empty-chunks/_expected/amd/main1.js index f9f8229aa40..a9e9419e212 100644 --- a/test/chunking-form/samples/empty-chunks/_expected/amd/main1.js +++ b/test/chunking-form/samples/empty-chunks/_expected/amd/main1.js @@ -1,5 +1,5 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; -}); +})); diff --git a/test/chunking-form/samples/empty-chunks/_expected/amd/main2.js b/test/chunking-form/samples/empty-chunks/_expected/amd/main2.js index f9f8229aa40..a9e9419e212 100644 --- a/test/chunking-form/samples/empty-chunks/_expected/amd/main2.js +++ b/test/chunking-form/samples/empty-chunks/_expected/amd/main2.js @@ -1,5 +1,5 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; -}); +})); diff --git a/test/chunking-form/samples/empty-chunks/_expected/system/main1.js b/test/chunking-form/samples/empty-chunks/_expected/system/main1.js index a702f2b06ef..343cc3a5100 100644 --- a/test/chunking-form/samples/empty-chunks/_expected/system/main1.js +++ b/test/chunking-form/samples/empty-chunks/_expected/system/main1.js @@ -1,10 +1,10 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/empty-chunks/_expected/system/main2.js b/test/chunking-form/samples/empty-chunks/_expected/system/main2.js index a702f2b06ef..343cc3a5100 100644 --- a/test/chunking-form/samples/empty-chunks/_expected/system/main2.js +++ b/test/chunking-form/samples/empty-chunks/_expected/system/main2.js @@ -1,10 +1,10 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/empty-module-no-treeshake/_config.js b/test/chunking-form/samples/empty-module-no-treeshake/_config.js index da96284354d..6fbadc4c419 100644 --- a/test/chunking-form/samples/empty-module-no-treeshake/_config.js +++ b/test/chunking-form/samples/empty-module-no-treeshake/_config.js @@ -1,12 +1,13 @@ -const assert = require('assert'); -const path = require('path'); -const { getObject } = require('../../../utils'); +const assert = require('node:assert'); +const path = require('node:path'); +const { getObject } = require('../../../testHelpers'); -module.exports = { +module.exports = defineTest({ description: 'associates empty modules with chunks if tree-shaking is disabled for them', options: { input: ['main1.js', 'main2.js'], plugins: { + name: 'test-plugin', resolveId(id) { if (id.startsWith('empty')) { if (id === 'emptyResolved') { @@ -34,9 +35,9 @@ module.exports = { generateBundle(options, bundle) { assert.deepStrictEqual( getObject( - Array.from(this.getModuleIds(), id => [ + [...this.getModuleIds()].map(id => [ id.startsWith('empty') ? id : path.relative(__dirname, id), - this.getModuleInfo(id).hasModuleSideEffects + this.getModuleInfo(id).moduleSideEffects ]) ), { @@ -64,4 +65,4 @@ module.exports = { } } } -}; +}); diff --git a/test/chunking-form/samples/empty-module-no-treeshake/_expected/amd/generated-emptyTransformed.js b/test/chunking-form/samples/empty-module-no-treeshake/_expected/amd/generated-emptyTransformed.js index f9f8229aa40..a9e9419e212 100644 --- a/test/chunking-form/samples/empty-module-no-treeshake/_expected/amd/generated-emptyTransformed.js +++ b/test/chunking-form/samples/empty-module-no-treeshake/_expected/amd/generated-emptyTransformed.js @@ -1,5 +1,5 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; -}); +})); diff --git a/test/chunking-form/samples/empty-module-no-treeshake/_expected/amd/main1.js b/test/chunking-form/samples/empty-module-no-treeshake/_expected/amd/main1.js index 992c5755630..79b7506c8d3 100644 --- a/test/chunking-form/samples/empty-module-no-treeshake/_expected/amd/main1.js +++ b/test/chunking-form/samples/empty-module-no-treeshake/_expected/amd/main1.js @@ -1,5 +1,5 @@ -define(['./generated-emptyTransformed'], function (emptyTransformed) { 'use strict'; +define(['./generated-emptyTransformed'], (function (emptyTransformed) { 'use strict'; console.log('main1'); -}); +})); diff --git a/test/chunking-form/samples/empty-module-no-treeshake/_expected/amd/main2.js b/test/chunking-form/samples/empty-module-no-treeshake/_expected/amd/main2.js index 5cd23f53804..5637dfe6a34 100644 --- a/test/chunking-form/samples/empty-module-no-treeshake/_expected/amd/main2.js +++ b/test/chunking-form/samples/empty-module-no-treeshake/_expected/amd/main2.js @@ -1,5 +1,5 @@ -define(['./generated-emptyTransformed'], function (emptyTransformed) { 'use strict'; +define(['./generated-emptyTransformed'], (function (emptyTransformed) { 'use strict'; console.log('main2'); -}); +})); diff --git a/test/chunking-form/samples/empty-module-no-treeshake/_expected/system/generated-emptyTransformed.js b/test/chunking-form/samples/empty-module-no-treeshake/_expected/system/generated-emptyTransformed.js index a702f2b06ef..343cc3a5100 100644 --- a/test/chunking-form/samples/empty-module-no-treeshake/_expected/system/generated-emptyTransformed.js +++ b/test/chunking-form/samples/empty-module-no-treeshake/_expected/system/generated-emptyTransformed.js @@ -1,10 +1,10 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/empty-module-no-treeshake/_expected/system/main1.js b/test/chunking-form/samples/empty-module-no-treeshake/_expected/system/main1.js index 42dde523b17..11b0d79c4c8 100644 --- a/test/chunking-form/samples/empty-module-no-treeshake/_expected/system/main1.js +++ b/test/chunking-form/samples/empty-module-no-treeshake/_expected/system/main1.js @@ -1,11 +1,11 @@ -System.register(['./generated-emptyTransformed.js'], function () { +System.register(['./generated-emptyTransformed.js'], (function () { 'use strict'; return { - setters: [function () {}], - execute: function () { + setters: [null], + execute: (function () { console.log('main1'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/empty-module-no-treeshake/_expected/system/main2.js b/test/chunking-form/samples/empty-module-no-treeshake/_expected/system/main2.js index 6c9dc294094..a2b1c4a1ae8 100644 --- a/test/chunking-form/samples/empty-module-no-treeshake/_expected/system/main2.js +++ b/test/chunking-form/samples/empty-module-no-treeshake/_expected/system/main2.js @@ -1,11 +1,11 @@ -System.register(['./generated-emptyTransformed.js'], function () { +System.register(['./generated-emptyTransformed.js'], (function () { 'use strict'; return { - setters: [function () {}], - execute: function () { + setters: [null], + execute: (function () { console.log('main2'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/entry-aliases/_config.js b/test/chunking-form/samples/entry-aliases/_config.js index b34e645a489..b80512b545f 100644 --- a/test/chunking-form/samples/entry-aliases/_config.js +++ b/test/chunking-form/samples/entry-aliases/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'alias module dependency inlining', options: { input: { @@ -10,4 +10,4 @@ module.exports = { entryFileNames: '[name]' } } -}; +}); diff --git a/test/chunking-form/samples/entry-aliases/_expected/amd/generated-dep.js b/test/chunking-form/samples/entry-aliases/_expected/amd/generated-dep.js deleted file mode 100644 index 859f8d05dc5..00000000000 --- a/test/chunking-form/samples/entry-aliases/_expected/amd/generated-dep.js +++ /dev/null @@ -1,7 +0,0 @@ -define(['exports'], function (exports) { 'use strict'; - - var name = 'name'; - - exports.name = name; - -}); diff --git a/test/chunking-form/samples/entry-aliases/_expected/amd/main1-alias.js b/test/chunking-form/samples/entry-aliases/_expected/amd/main1-alias.js index e91de314159..7a1a9208192 100644 --- a/test/chunking-form/samples/entry-aliases/_expected/amd/main1-alias.js +++ b/test/chunking-form/samples/entry-aliases/_expected/amd/main1-alias.js @@ -1,9 +1,7 @@ -define(['exports', './generated-dep'], function (exports, dep) { 'use strict'; +define(['exports', './main1'], (function (exports, main1_js) { 'use strict'; - exports.name = dep.name; + exports.name = main1_js.name; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/entry-aliases/_expected/amd/main1.js b/test/chunking-form/samples/entry-aliases/_expected/amd/main1.js index e91de314159..1828d3a1a3b 100644 --- a/test/chunking-form/samples/entry-aliases/_expected/amd/main1.js +++ b/test/chunking-form/samples/entry-aliases/_expected/amd/main1.js @@ -1,9 +1,7 @@ -define(['exports', './generated-dep'], function (exports, dep) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; + var name = 'name'; + exports.name = name; - exports.name = dep.name; - - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/entry-aliases/_expected/amd/main2.js b/test/chunking-form/samples/entry-aliases/_expected/amd/main2.js index cb9ff3e4b30..921f4ce0eea 100644 --- a/test/chunking-form/samples/entry-aliases/_expected/amd/main2.js +++ b/test/chunking-form/samples/entry-aliases/_expected/amd/main2.js @@ -1,5 +1,5 @@ -define(['./generated-dep'], function (dep) { 'use strict'; +define(['./main1'], (function (main1_js) { 'use strict'; - console.log(dep.name); + console.log(main1_js.name); -}); +})); diff --git a/test/chunking-form/samples/entry-aliases/_expected/cjs/generated-dep.js b/test/chunking-form/samples/entry-aliases/_expected/cjs/generated-dep.js deleted file mode 100644 index fe90666bb92..00000000000 --- a/test/chunking-form/samples/entry-aliases/_expected/cjs/generated-dep.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -var name = 'name'; - -exports.name = name; diff --git a/test/chunking-form/samples/entry-aliases/_expected/cjs/main1-alias.js b/test/chunking-form/samples/entry-aliases/_expected/cjs/main1-alias.js index 50083991d6f..24021e5ec62 100644 --- a/test/chunking-form/samples/entry-aliases/_expected/cjs/main1-alias.js +++ b/test/chunking-form/samples/entry-aliases/_expected/cjs/main1-alias.js @@ -1,9 +1,7 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); +var main1_js = require('./main1.js'); -var dep = require('./generated-dep.js'); - -exports.name = dep.name; +exports.name = main1_js.name; diff --git a/test/chunking-form/samples/entry-aliases/_expected/cjs/main1.js b/test/chunking-form/samples/entry-aliases/_expected/cjs/main1.js index 50083991d6f..fe90666bb92 100644 --- a/test/chunking-form/samples/entry-aliases/_expected/cjs/main1.js +++ b/test/chunking-form/samples/entry-aliases/_expected/cjs/main1.js @@ -1,9 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); +var name = 'name'; -var dep = require('./generated-dep.js'); - - - -exports.name = dep.name; +exports.name = name; diff --git a/test/chunking-form/samples/entry-aliases/_expected/cjs/main2.js b/test/chunking-form/samples/entry-aliases/_expected/cjs/main2.js index 033c5333a49..56a38b41c48 100644 --- a/test/chunking-form/samples/entry-aliases/_expected/cjs/main2.js +++ b/test/chunking-form/samples/entry-aliases/_expected/cjs/main2.js @@ -1,5 +1,5 @@ 'use strict'; -var dep = require('./generated-dep.js'); +var main1_js = require('./main1.js'); -console.log(dep.name); +console.log(main1_js.name); diff --git a/test/chunking-form/samples/entry-aliases/_expected/es/generated-dep.js b/test/chunking-form/samples/entry-aliases/_expected/es/generated-dep.js deleted file mode 100644 index 83809a871df..00000000000 --- a/test/chunking-form/samples/entry-aliases/_expected/es/generated-dep.js +++ /dev/null @@ -1,3 +0,0 @@ -var name = 'name'; - -export { name as n }; diff --git a/test/chunking-form/samples/entry-aliases/_expected/es/main1-alias.js b/test/chunking-form/samples/entry-aliases/_expected/es/main1-alias.js index a9f98d6ab2d..8e995fcd9ee 100644 --- a/test/chunking-form/samples/entry-aliases/_expected/es/main1-alias.js +++ b/test/chunking-form/samples/entry-aliases/_expected/es/main1-alias.js @@ -1 +1 @@ -export { n as name } from './generated-dep.js'; +export { name } from './main1.js'; diff --git a/test/chunking-form/samples/entry-aliases/_expected/es/main1.js b/test/chunking-form/samples/entry-aliases/_expected/es/main1.js index a9f98d6ab2d..6a9667dced1 100644 --- a/test/chunking-form/samples/entry-aliases/_expected/es/main1.js +++ b/test/chunking-form/samples/entry-aliases/_expected/es/main1.js @@ -1 +1,3 @@ -export { n as name } from './generated-dep.js'; +var name = 'name'; + +export { name }; diff --git a/test/chunking-form/samples/entry-aliases/_expected/es/main2.js b/test/chunking-form/samples/entry-aliases/_expected/es/main2.js index fc1b553e541..5cbdc9eed89 100644 --- a/test/chunking-form/samples/entry-aliases/_expected/es/main2.js +++ b/test/chunking-form/samples/entry-aliases/_expected/es/main2.js @@ -1,3 +1,3 @@ -import { n as name } from './generated-dep.js'; +import { name } from './main1.js'; console.log(name); diff --git a/test/chunking-form/samples/entry-aliases/_expected/system/generated-dep.js b/test/chunking-form/samples/entry-aliases/_expected/system/generated-dep.js deleted file mode 100644 index 0efb4ed6cb1..00000000000 --- a/test/chunking-form/samples/entry-aliases/_expected/system/generated-dep.js +++ /dev/null @@ -1,10 +0,0 @@ -System.register([], function (exports) { - 'use strict'; - return { - execute: function () { - - var name = exports('n', 'name'); - - } - }; -}); diff --git a/test/chunking-form/samples/entry-aliases/_expected/system/main1-alias.js b/test/chunking-form/samples/entry-aliases/_expected/system/main1-alias.js index fa0993a1758..5bd6af1062b 100644 --- a/test/chunking-form/samples/entry-aliases/_expected/system/main1-alias.js +++ b/test/chunking-form/samples/entry-aliases/_expected/system/main1-alias.js @@ -1,13 +1,13 @@ -System.register(['./generated-dep.js'], function (exports) { +System.register(['./main1.js'], (function (exports) { 'use strict'; return { setters: [function (module) { - exports('name', module.n); + exports("name", module.name); }], - execute: function () { + execute: (function () { - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/entry-aliases/_expected/system/main1.js b/test/chunking-form/samples/entry-aliases/_expected/system/main1.js index fa0993a1758..5f02b7e4f2b 100644 --- a/test/chunking-form/samples/entry-aliases/_expected/system/main1.js +++ b/test/chunking-form/samples/entry-aliases/_expected/system/main1.js @@ -1,13 +1,10 @@ -System.register(['./generated-dep.js'], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - setters: [function (module) { - exports('name', module.n); - }], - execute: function () { + execute: (function () { + var name = exports("name", 'name'); - - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/entry-aliases/_expected/system/main2.js b/test/chunking-form/samples/entry-aliases/_expected/system/main2.js index eb344d8e3de..2a41336bf24 100644 --- a/test/chunking-form/samples/entry-aliases/_expected/system/main2.js +++ b/test/chunking-form/samples/entry-aliases/_expected/system/main2.js @@ -1,14 +1,14 @@ -System.register(['./generated-dep.js'], function () { +System.register(['./main1.js'], (function () { 'use strict'; var name; return { setters: [function (module) { - name = module.n; + name = module.name; }], - execute: function () { + execute: (function () { console.log(name); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/entry-chunk-export-mode/_config.js b/test/chunking-form/samples/entry-chunk-export-mode/_config.js index e1044841bf5..540e65182cb 100644 --- a/test/chunking-form/samples/entry-chunk-export-mode/_config.js +++ b/test/chunking-form/samples/entry-chunk-export-mode/_config.js @@ -1,6 +1,6 @@ -module.exports = { +module.exports = defineTest({ description: 'entry chunk export mode checks', options: { input: ['main1.js', 'main2.js'] } -}; +}); diff --git a/test/chunking-form/samples/entry-chunk-export-mode/_expected/amd/main1.js b/test/chunking-form/samples/entry-chunk-export-mode/_expected/amd/main1.js index 0d61613c51f..39cbdf15c8c 100644 --- a/test/chunking-form/samples/entry-chunk-export-mode/_expected/amd/main1.js +++ b/test/chunking-form/samples/entry-chunk-export-mode/_expected/amd/main1.js @@ -1,5 +1,5 @@ -define(['./main2'], function (main2) { 'use strict'; +define(['./main2'], (function (main2) { 'use strict'; main2(); -}); +})); diff --git a/test/chunking-form/samples/entry-chunk-export-mode/_expected/amd/main2.js b/test/chunking-form/samples/entry-chunk-export-mode/_expected/amd/main2.js index faf5c00a55b..004b19f4687 100644 --- a/test/chunking-form/samples/entry-chunk-export-mode/_expected/amd/main2.js +++ b/test/chunking-form/samples/entry-chunk-export-mode/_expected/amd/main2.js @@ -1,4 +1,4 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; function fn () { console.log('main fn'); @@ -6,4 +6,4 @@ define(function () { 'use strict'; return fn; -}); +})); diff --git a/test/chunking-form/samples/entry-chunk-export-mode/_expected/es/main2.js b/test/chunking-form/samples/entry-chunk-export-mode/_expected/es/main2.js index 83b8044f5b7..46f993dbcc3 100644 --- a/test/chunking-form/samples/entry-chunk-export-mode/_expected/es/main2.js +++ b/test/chunking-form/samples/entry-chunk-export-mode/_expected/es/main2.js @@ -2,4 +2,4 @@ function fn () { console.log('main fn'); } -export default fn; +export { fn as default }; diff --git a/test/chunking-form/samples/entry-chunk-export-mode/_expected/system/main1.js b/test/chunking-form/samples/entry-chunk-export-mode/_expected/system/main1.js index fe6d9ae5c23..a39bb38ad2d 100644 --- a/test/chunking-form/samples/entry-chunk-export-mode/_expected/system/main1.js +++ b/test/chunking-form/samples/entry-chunk-export-mode/_expected/system/main1.js @@ -1,14 +1,14 @@ -System.register(['./main2.js'], function () { +System.register(['./main2.js'], (function () { 'use strict'; var fn; return { setters: [function (module) { fn = module.default; }], - execute: function () { + execute: (function () { fn(); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/entry-chunk-export-mode/_expected/system/main2.js b/test/chunking-form/samples/entry-chunk-export-mode/_expected/system/main2.js index 94007ef7392..20c10307a38 100644 --- a/test/chunking-form/samples/entry-chunk-export-mode/_expected/system/main2.js +++ b/test/chunking-form/samples/entry-chunk-export-mode/_expected/system/main2.js @@ -1,14 +1,14 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - exports('default', fn); + exports("default", fn); function fn () { console.log('main fn'); } - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/entry-point-without-own-code/_config.js b/test/chunking-form/samples/entry-point-without-own-code/_config.js index cdd3035cbc1..16454926433 100644 --- a/test/chunking-form/samples/entry-point-without-own-code/_config.js +++ b/test/chunking-form/samples/entry-point-without-own-code/_config.js @@ -1,6 +1,6 @@ -module.exports = { +module.exports = defineTest({ description: 'Handles entry points that contain no own code except imports and exports', options: { input: ['main.js', 'm1.js', 'm2.js'] } -}; +}); diff --git a/test/chunking-form/samples/entry-point-without-own-code/_expected/amd/generated-m1.js b/test/chunking-form/samples/entry-point-without-own-code/_expected/amd/generated-m1.js index 6eb70776913..d35d51c5e18 100644 --- a/test/chunking-form/samples/entry-point-without-own-code/_expected/amd/generated-m1.js +++ b/test/chunking-form/samples/entry-point-without-own-code/_expected/amd/generated-m1.js @@ -1,4 +1,4 @@ -define(['exports', './m2'], function (exports, m2) { 'use strict'; +define(['exports', './m2'], (function (exports, m2) { 'use strict'; var ms = /*#__PURE__*/Object.freeze({ __proto__: null, @@ -7,4 +7,4 @@ define(['exports', './m2'], function (exports, m2) { 'use strict'; exports.ms = ms; -}); +})); diff --git a/test/chunking-form/samples/entry-point-without-own-code/_expected/amd/m1.js b/test/chunking-form/samples/entry-point-without-own-code/_expected/amd/m1.js index 8c152a68567..f28945e1828 100644 --- a/test/chunking-form/samples/entry-point-without-own-code/_expected/amd/m1.js +++ b/test/chunking-form/samples/entry-point-without-own-code/_expected/amd/m1.js @@ -1,9 +1,7 @@ -define(['exports', './m2'], function (exports, m2) { 'use strict'; +define(['exports', './m2'], (function (exports, m2) { 'use strict'; exports.m2 = m2; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/entry-point-without-own-code/_expected/amd/m2.js b/test/chunking-form/samples/entry-point-without-own-code/_expected/amd/m2.js index a0c374fb3a3..a57bfdbb677 100644 --- a/test/chunking-form/samples/entry-point-without-own-code/_expected/amd/m2.js +++ b/test/chunking-form/samples/entry-point-without-own-code/_expected/amd/m2.js @@ -1,7 +1,7 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; var m2 = 'm2'; return m2; -}); +})); diff --git a/test/chunking-form/samples/entry-point-without-own-code/_expected/amd/main.js b/test/chunking-form/samples/entry-point-without-own-code/_expected/amd/main.js index 2a34eca4872..bb1a0cb66ba 100644 --- a/test/chunking-form/samples/entry-point-without-own-code/_expected/amd/main.js +++ b/test/chunking-form/samples/entry-point-without-own-code/_expected/amd/main.js @@ -1,5 +1,5 @@ -define(['./generated-m1', './m2'], function (m1, m2) { 'use strict'; +define(['./generated-m1', './m2'], (function (m1, m2) { 'use strict'; console.log(m1.ms); -}); +})); diff --git a/test/chunking-form/samples/entry-point-without-own-code/_expected/cjs/m1.js b/test/chunking-form/samples/entry-point-without-own-code/_expected/cjs/m1.js index f1de24e56e2..5c65692eec7 100644 --- a/test/chunking-form/samples/entry-point-without-own-code/_expected/cjs/m1.js +++ b/test/chunking-form/samples/entry-point-without-own-code/_expected/cjs/m1.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - var m2 = require('./m2.js'); diff --git a/test/chunking-form/samples/entry-point-without-own-code/_expected/es/m2.js b/test/chunking-form/samples/entry-point-without-own-code/_expected/es/m2.js index ba5d9f8731a..2e0ed575641 100644 --- a/test/chunking-form/samples/entry-point-without-own-code/_expected/es/m2.js +++ b/test/chunking-form/samples/entry-point-without-own-code/_expected/es/m2.js @@ -1,3 +1,3 @@ var m2 = 'm2'; -export default m2; +export { m2 as default }; diff --git a/test/chunking-form/samples/entry-point-without-own-code/_expected/system/generated-m1.js b/test/chunking-form/samples/entry-point-without-own-code/_expected/system/generated-m1.js index b34ac383826..dc1cc2f0a3a 100644 --- a/test/chunking-form/samples/entry-point-without-own-code/_expected/system/generated-m1.js +++ b/test/chunking-form/samples/entry-point-without-own-code/_expected/system/generated-m1.js @@ -1,18 +1,18 @@ -System.register(['./m2.js'], function (exports) { +System.register(['./m2.js'], (function (exports) { 'use strict'; var m2; return { setters: [function (module) { m2 = module.default; }], - execute: function () { + execute: (function () { var ms = /*#__PURE__*/Object.freeze({ __proto__: null, m2: m2 }); - exports('m', ms); + exports("m", ms); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/entry-point-without-own-code/_expected/system/m1.js b/test/chunking-form/samples/entry-point-without-own-code/_expected/system/m1.js index f9644287173..742fcc2431e 100644 --- a/test/chunking-form/samples/entry-point-without-own-code/_expected/system/m1.js +++ b/test/chunking-form/samples/entry-point-without-own-code/_expected/system/m1.js @@ -1,13 +1,13 @@ -System.register(['./m2.js'], function (exports) { +System.register(['./m2.js'], (function (exports) { 'use strict'; return { setters: [function (module) { - exports('m2', module.default); + exports("m2", module.default); }], - execute: function () { + execute: (function () { - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/entry-point-without-own-code/_expected/system/m2.js b/test/chunking-form/samples/entry-point-without-own-code/_expected/system/m2.js index 99666912c3f..1eeac225006 100644 --- a/test/chunking-form/samples/entry-point-without-own-code/_expected/system/m2.js +++ b/test/chunking-form/samples/entry-point-without-own-code/_expected/system/m2.js @@ -1,10 +1,10 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - var m2 = exports('default', 'm2'); + var m2 = exports("default", 'm2'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/entry-point-without-own-code/_expected/system/main.js b/test/chunking-form/samples/entry-point-without-own-code/_expected/system/main.js index c2269622e03..070c3d723e0 100644 --- a/test/chunking-form/samples/entry-point-without-own-code/_expected/system/main.js +++ b/test/chunking-form/samples/entry-point-without-own-code/_expected/system/main.js @@ -1,14 +1,14 @@ -System.register(['./generated-m1.js', './m2.js'], function () { +System.register(['./generated-m1.js', './m2.js'], (function () { 'use strict'; var ms; return { setters: [function (module) { ms = module.m; - }, function () {}], - execute: function () { + }, null], + execute: (function () { console.log(ms); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/entry-without-code-dynamic/_config.js b/test/chunking-form/samples/entry-without-code-dynamic/_config.js new file mode 100644 index 00000000000..af2dc8d4560 --- /dev/null +++ b/test/chunking-form/samples/entry-without-code-dynamic/_config.js @@ -0,0 +1,7 @@ +module.exports = defineTest({ + description: + 'optimizes chunks when a dynamic entry point without own code is imported from another entry', + options: { + input: ['main1.js', 'main2.js'] + } +}); diff --git a/test/chunking-form/samples/entry-without-code-dynamic/_expected/amd/generated-dynamic.js b/test/chunking-form/samples/entry-without-code-dynamic/_expected/amd/generated-dynamic.js new file mode 100644 index 00000000000..6fd637014ea --- /dev/null +++ b/test/chunking-form/samples/entry-without-code-dynamic/_expected/amd/generated-dynamic.js @@ -0,0 +1,7 @@ +define(['exports'], (function (exports) { 'use strict'; + + const foo = 'foo'; + + exports.foo = foo; + +})); diff --git a/test/chunking-form/samples/entry-without-code-dynamic/_expected/amd/main1.js b/test/chunking-form/samples/entry-without-code-dynamic/_expected/amd/main1.js new file mode 100644 index 00000000000..0d4971e9c75 --- /dev/null +++ b/test/chunking-form/samples/entry-without-code-dynamic/_expected/amd/main1.js @@ -0,0 +1,5 @@ +define(['./generated-dynamic'], (function (dynamic) { 'use strict'; + + console.log(dynamic.foo); + +})); diff --git a/test/chunking-form/samples/entry-without-code-dynamic/_expected/amd/main2.js b/test/chunking-form/samples/entry-without-code-dynamic/_expected/amd/main2.js new file mode 100644 index 00000000000..f6f80ef24e4 --- /dev/null +++ b/test/chunking-form/samples/entry-without-code-dynamic/_expected/amd/main2.js @@ -0,0 +1,5 @@ +define(['require'], (function (require) { 'use strict'; + + new Promise(function (resolve, reject) { require(['./generated-dynamic'], resolve, reject); }).then(console.log); + +})); diff --git a/test/chunking-form/samples/entry-without-code-dynamic/_expected/cjs/generated-dynamic.js b/test/chunking-form/samples/entry-without-code-dynamic/_expected/cjs/generated-dynamic.js new file mode 100644 index 00000000000..71c76a07cc0 --- /dev/null +++ b/test/chunking-form/samples/entry-without-code-dynamic/_expected/cjs/generated-dynamic.js @@ -0,0 +1,5 @@ +'use strict'; + +const foo = 'foo'; + +exports.foo = foo; diff --git a/test/chunking-form/samples/entry-without-code-dynamic/_expected/cjs/main1.js b/test/chunking-form/samples/entry-without-code-dynamic/_expected/cjs/main1.js new file mode 100644 index 00000000000..df6293c8293 --- /dev/null +++ b/test/chunking-form/samples/entry-without-code-dynamic/_expected/cjs/main1.js @@ -0,0 +1,5 @@ +'use strict'; + +var dynamic = require('./generated-dynamic.js'); + +console.log(dynamic.foo); diff --git a/test/chunking-form/samples/entry-without-code-dynamic/_expected/cjs/main2.js b/test/chunking-form/samples/entry-without-code-dynamic/_expected/cjs/main2.js new file mode 100644 index 00000000000..187995b6f39 --- /dev/null +++ b/test/chunking-form/samples/entry-without-code-dynamic/_expected/cjs/main2.js @@ -0,0 +1,3 @@ +'use strict'; + +Promise.resolve().then(function () { return require('./generated-dynamic.js'); }).then(console.log); diff --git a/test/chunking-form/samples/entry-without-code-dynamic/_expected/es/generated-dynamic.js b/test/chunking-form/samples/entry-without-code-dynamic/_expected/es/generated-dynamic.js new file mode 100644 index 00000000000..d1f660b22f1 --- /dev/null +++ b/test/chunking-form/samples/entry-without-code-dynamic/_expected/es/generated-dynamic.js @@ -0,0 +1,3 @@ +const foo = 'foo'; + +export { foo }; diff --git a/test/chunking-form/samples/entry-without-code-dynamic/_expected/es/main1.js b/test/chunking-form/samples/entry-without-code-dynamic/_expected/es/main1.js new file mode 100644 index 00000000000..9dc76696e25 --- /dev/null +++ b/test/chunking-form/samples/entry-without-code-dynamic/_expected/es/main1.js @@ -0,0 +1,3 @@ +import { foo } from './generated-dynamic.js'; + +console.log(foo); diff --git a/test/chunking-form/samples/entry-without-code-dynamic/_expected/es/main2.js b/test/chunking-form/samples/entry-without-code-dynamic/_expected/es/main2.js new file mode 100644 index 00000000000..57e21c798b1 --- /dev/null +++ b/test/chunking-form/samples/entry-without-code-dynamic/_expected/es/main2.js @@ -0,0 +1 @@ +import('./generated-dynamic.js').then(console.log); diff --git a/test/chunking-form/samples/entry-without-code-dynamic/_expected/system/generated-dynamic.js b/test/chunking-form/samples/entry-without-code-dynamic/_expected/system/generated-dynamic.js new file mode 100644 index 00000000000..99f811f3faa --- /dev/null +++ b/test/chunking-form/samples/entry-without-code-dynamic/_expected/system/generated-dynamic.js @@ -0,0 +1,10 @@ +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + + const foo = exports("foo", 'foo'); + + }) + }; +})); diff --git a/test/chunking-form/samples/entry-without-code-dynamic/_expected/system/main1.js b/test/chunking-form/samples/entry-without-code-dynamic/_expected/system/main1.js new file mode 100644 index 00000000000..e150c52dcf2 --- /dev/null +++ b/test/chunking-form/samples/entry-without-code-dynamic/_expected/system/main1.js @@ -0,0 +1,14 @@ +System.register(['./generated-dynamic.js'], (function () { + 'use strict'; + var foo; + return { + setters: [function (module) { + foo = module.foo; + }], + execute: (function () { + + console.log(foo); + + }) + }; +})); diff --git a/test/chunking-form/samples/entry-without-code-dynamic/_expected/system/main2.js b/test/chunking-form/samples/entry-without-code-dynamic/_expected/system/main2.js new file mode 100644 index 00000000000..7241408dff3 --- /dev/null +++ b/test/chunking-form/samples/entry-without-code-dynamic/_expected/system/main2.js @@ -0,0 +1,10 @@ +System.register([], (function (exports, module) { + 'use strict'; + return { + execute: (function () { + + module.import('./generated-dynamic.js').then(console.log); + + }) + }; +})); diff --git a/test/function/samples/deprecations/plugin-module-ids/main.js b/test/chunking-form/samples/entry-without-code-dynamic/dynamic.js similarity index 100% rename from test/function/samples/deprecations/plugin-module-ids/main.js rename to test/chunking-form/samples/entry-without-code-dynamic/dynamic.js diff --git a/test/chunking-form/samples/entry-without-code-dynamic/foo.js b/test/chunking-form/samples/entry-without-code-dynamic/foo.js new file mode 100644 index 00000000000..3329a7d972f --- /dev/null +++ b/test/chunking-form/samples/entry-without-code-dynamic/foo.js @@ -0,0 +1 @@ +export const foo = 'foo'; diff --git a/test/chunking-form/samples/entry-without-code-dynamic/main1.js b/test/chunking-form/samples/entry-without-code-dynamic/main1.js new file mode 100644 index 00000000000..19ce0a562c7 --- /dev/null +++ b/test/chunking-form/samples/entry-without-code-dynamic/main1.js @@ -0,0 +1,3 @@ +import { foo } from './dynamic.js'; + +console.log(foo); diff --git a/test/chunking-form/samples/entry-without-code-dynamic/main2.js b/test/chunking-form/samples/entry-without-code-dynamic/main2.js new file mode 100644 index 00000000000..b25e0542502 --- /dev/null +++ b/test/chunking-form/samples/entry-without-code-dynamic/main2.js @@ -0,0 +1 @@ +import('./dynamic.js').then(console.log); diff --git a/test/chunking-form/samples/entry-without-code/_config.js b/test/chunking-form/samples/entry-without-code/_config.js new file mode 100644 index 00000000000..5d503fdc17a --- /dev/null +++ b/test/chunking-form/samples/entry-without-code/_config.js @@ -0,0 +1,7 @@ +module.exports = defineTest({ + description: + 'optimizes chunks when an entry point without own code is imported from another entry', + options: { + input: ['main1.js', 'main2.js'] + } +}); diff --git a/test/chunking-form/samples/entry-without-code/_expected/amd/main1.js b/test/chunking-form/samples/entry-without-code/_expected/amd/main1.js new file mode 100644 index 00000000000..079eb43bd23 --- /dev/null +++ b/test/chunking-form/samples/entry-without-code/_expected/amd/main1.js @@ -0,0 +1,5 @@ +define(['./main2'], (function (main2) { 'use strict'; + + console.log(main2.foo); + +})); diff --git a/test/chunking-form/samples/entry-without-code/_expected/amd/main2.js b/test/chunking-form/samples/entry-without-code/_expected/amd/main2.js new file mode 100644 index 00000000000..6fd637014ea --- /dev/null +++ b/test/chunking-form/samples/entry-without-code/_expected/amd/main2.js @@ -0,0 +1,7 @@ +define(['exports'], (function (exports) { 'use strict'; + + const foo = 'foo'; + + exports.foo = foo; + +})); diff --git a/test/chunking-form/samples/entry-without-code/_expected/cjs/main1.js b/test/chunking-form/samples/entry-without-code/_expected/cjs/main1.js new file mode 100644 index 00000000000..38ef54c59ac --- /dev/null +++ b/test/chunking-form/samples/entry-without-code/_expected/cjs/main1.js @@ -0,0 +1,5 @@ +'use strict'; + +var main2 = require('./main2.js'); + +console.log(main2.foo); diff --git a/test/chunking-form/samples/entry-without-code/_expected/cjs/main2.js b/test/chunking-form/samples/entry-without-code/_expected/cjs/main2.js new file mode 100644 index 00000000000..71c76a07cc0 --- /dev/null +++ b/test/chunking-form/samples/entry-without-code/_expected/cjs/main2.js @@ -0,0 +1,5 @@ +'use strict'; + +const foo = 'foo'; + +exports.foo = foo; diff --git a/test/chunking-form/samples/entry-without-code/_expected/es/main1.js b/test/chunking-form/samples/entry-without-code/_expected/es/main1.js new file mode 100644 index 00000000000..cfccb2a5a43 --- /dev/null +++ b/test/chunking-form/samples/entry-without-code/_expected/es/main1.js @@ -0,0 +1,3 @@ +import { foo } from './main2.js'; + +console.log(foo); diff --git a/test/chunking-form/samples/entry-without-code/_expected/es/main2.js b/test/chunking-form/samples/entry-without-code/_expected/es/main2.js new file mode 100644 index 00000000000..d1f660b22f1 --- /dev/null +++ b/test/chunking-form/samples/entry-without-code/_expected/es/main2.js @@ -0,0 +1,3 @@ +const foo = 'foo'; + +export { foo }; diff --git a/test/chunking-form/samples/entry-without-code/_expected/system/main1.js b/test/chunking-form/samples/entry-without-code/_expected/system/main1.js new file mode 100644 index 00000000000..ef625ce147e --- /dev/null +++ b/test/chunking-form/samples/entry-without-code/_expected/system/main1.js @@ -0,0 +1,14 @@ +System.register(['./main2.js'], (function () { + 'use strict'; + var foo; + return { + setters: [function (module) { + foo = module.foo; + }], + execute: (function () { + + console.log(foo); + + }) + }; +})); diff --git a/test/chunking-form/samples/entry-without-code/_expected/system/main2.js b/test/chunking-form/samples/entry-without-code/_expected/system/main2.js new file mode 100644 index 00000000000..99f811f3faa --- /dev/null +++ b/test/chunking-form/samples/entry-without-code/_expected/system/main2.js @@ -0,0 +1,10 @@ +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + + const foo = exports("foo", 'foo'); + + }) + }; +})); diff --git a/test/chunking-form/samples/entry-without-code/foo.js b/test/chunking-form/samples/entry-without-code/foo.js new file mode 100644 index 00000000000..3329a7d972f --- /dev/null +++ b/test/chunking-form/samples/entry-without-code/foo.js @@ -0,0 +1 @@ +export const foo = 'foo'; diff --git a/test/chunking-form/samples/entry-without-code/main1.js b/test/chunking-form/samples/entry-without-code/main1.js new file mode 100644 index 00000000000..cfccb2a5a43 --- /dev/null +++ b/test/chunking-form/samples/entry-without-code/main1.js @@ -0,0 +1,3 @@ +import { foo } from './main2.js'; + +console.log(foo); diff --git a/test/chunking-form/samples/entry-without-code/main2.js b/test/chunking-form/samples/entry-without-code/main2.js new file mode 100644 index 00000000000..4ffe2d41cfe --- /dev/null +++ b/test/chunking-form/samples/entry-without-code/main2.js @@ -0,0 +1 @@ +export { foo } from './foo.js'; diff --git a/test/chunking-form/samples/entrypoint-aliasing/_config.js b/test/chunking-form/samples/entrypoint-aliasing/_config.js index 19a22686336..b75226f6044 100644 --- a/test/chunking-form/samples/entrypoint-aliasing/_config.js +++ b/test/chunking-form/samples/entrypoint-aliasing/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'entry point facade creation', options: { input: { @@ -6,4 +6,4 @@ module.exports = { main2alias: 'main2.js' } } -}; +}); diff --git a/test/chunking-form/samples/entrypoint-aliasing/_expected/amd/generated-main2.js b/test/chunking-form/samples/entrypoint-aliasing/_expected/amd/generated-main2.js index 4a5858c04a1..9643e93c569 100644 --- a/test/chunking-form/samples/entrypoint-aliasing/_expected/amd/generated-main2.js +++ b/test/chunking-form/samples/entrypoint-aliasing/_expected/amd/generated-main2.js @@ -1,4 +1,4 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; var dep = { x: 42 }; @@ -11,4 +11,4 @@ define(['exports'], function (exports) { 'use strict'; exports.dep = dep; exports.log = log; -}); +})); diff --git a/test/chunking-form/samples/entrypoint-aliasing/_expected/amd/main1alias.js b/test/chunking-form/samples/entrypoint-aliasing/_expected/amd/main1alias.js index c58fe8910da..f2c65e8e5a5 100644 --- a/test/chunking-form/samples/entrypoint-aliasing/_expected/amd/main1alias.js +++ b/test/chunking-form/samples/entrypoint-aliasing/_expected/amd/main1alias.js @@ -1,5 +1,5 @@ -define(['./generated-main2'], function (main2alias) { 'use strict'; +define(['./generated-main2'], (function (main2alias) { 'use strict'; main2alias.log(main2alias.dep); -}); +})); diff --git a/test/chunking-form/samples/entrypoint-aliasing/_expected/amd/main2alias.js b/test/chunking-form/samples/entrypoint-aliasing/_expected/amd/main2alias.js index 61ab8e7d7a6..b582fed37f8 100644 --- a/test/chunking-form/samples/entrypoint-aliasing/_expected/amd/main2alias.js +++ b/test/chunking-form/samples/entrypoint-aliasing/_expected/amd/main2alias.js @@ -1,7 +1,7 @@ -define(['./generated-main2'], function (main2alias) { 'use strict'; +define(['./generated-main2'], (function (main2alias) { 'use strict'; return main2alias.log; -}); +})); diff --git a/test/chunking-form/samples/entrypoint-aliasing/_expected/system/generated-main2.js b/test/chunking-form/samples/entrypoint-aliasing/_expected/system/generated-main2.js index 6ef9c75bc0f..b6cc008bb90 100644 --- a/test/chunking-form/samples/entrypoint-aliasing/_expected/system/generated-main2.js +++ b/test/chunking-form/samples/entrypoint-aliasing/_expected/system/generated-main2.js @@ -1,11 +1,11 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - exports('l', log); + exports("l", log); - var dep = exports('d', { x: 42 }); + var dep = exports("d", { x: 42 }); function log (x) { if (dep) { @@ -13,6 +13,6 @@ System.register([], function (exports) { } } - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/entrypoint-aliasing/_expected/system/main1alias.js b/test/chunking-form/samples/entrypoint-aliasing/_expected/system/main1alias.js index 8eddd1df106..413fc99fd3e 100644 --- a/test/chunking-form/samples/entrypoint-aliasing/_expected/system/main1alias.js +++ b/test/chunking-form/samples/entrypoint-aliasing/_expected/system/main1alias.js @@ -1,4 +1,4 @@ -System.register(['./generated-main2.js'], function () { +System.register(['./generated-main2.js'], (function () { 'use strict'; var log, dep; return { @@ -6,10 +6,10 @@ System.register(['./generated-main2.js'], function () { log = module.l; dep = module.d; }], - execute: function () { + execute: (function () { log(dep); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/entrypoint-aliasing/_expected/system/main2alias.js b/test/chunking-form/samples/entrypoint-aliasing/_expected/system/main2alias.js index 94afaca11b1..1750d72b46b 100644 --- a/test/chunking-form/samples/entrypoint-aliasing/_expected/system/main2alias.js +++ b/test/chunking-form/samples/entrypoint-aliasing/_expected/system/main2alias.js @@ -1,13 +1,13 @@ -System.register(['./generated-main2.js'], function (exports) { +System.register(['./generated-main2.js'], (function (exports) { 'use strict'; return { setters: [function (module) { - exports('default', module.l); + exports("default", module.l); }], - execute: function () { + execute: (function () { - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/entrypoint-facade/_config.js b/test/chunking-form/samples/entrypoint-facade/_config.js index c044e70e346..0301e6e748a 100644 --- a/test/chunking-form/samples/entrypoint-facade/_config.js +++ b/test/chunking-form/samples/entrypoint-facade/_config.js @@ -1,6 +1,6 @@ -module.exports = { +module.exports = defineTest({ description: 'entry point facade creation', options: { input: ['main1.js', 'main2.js'] } -}; +}); diff --git a/test/chunking-form/samples/entrypoint-facade/_expected/amd/generated-main2.js b/test/chunking-form/samples/entrypoint-facade/_expected/amd/generated-main2.js index 4a5858c04a1..9643e93c569 100644 --- a/test/chunking-form/samples/entrypoint-facade/_expected/amd/generated-main2.js +++ b/test/chunking-form/samples/entrypoint-facade/_expected/amd/generated-main2.js @@ -1,4 +1,4 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; var dep = { x: 42 }; @@ -11,4 +11,4 @@ define(['exports'], function (exports) { 'use strict'; exports.dep = dep; exports.log = log; -}); +})); diff --git a/test/chunking-form/samples/entrypoint-facade/_expected/amd/main1.js b/test/chunking-form/samples/entrypoint-facade/_expected/amd/main1.js index b319e7ebff9..d23070f5b8a 100644 --- a/test/chunking-form/samples/entrypoint-facade/_expected/amd/main1.js +++ b/test/chunking-form/samples/entrypoint-facade/_expected/amd/main1.js @@ -1,5 +1,5 @@ -define(['./generated-main2'], function (main2) { 'use strict'; +define(['./generated-main2'], (function (main2) { 'use strict'; main2.log(main2.dep); -}); +})); diff --git a/test/chunking-form/samples/entrypoint-facade/_expected/amd/main2.js b/test/chunking-form/samples/entrypoint-facade/_expected/amd/main2.js index e4a115ee883..9356f1aca68 100644 --- a/test/chunking-form/samples/entrypoint-facade/_expected/amd/main2.js +++ b/test/chunking-form/samples/entrypoint-facade/_expected/amd/main2.js @@ -1,7 +1,7 @@ -define(['./generated-main2'], function (main2) { 'use strict'; +define(['./generated-main2'], (function (main2) { 'use strict'; return main2.log; -}); +})); diff --git a/test/chunking-form/samples/entrypoint-facade/_expected/system/generated-main2.js b/test/chunking-form/samples/entrypoint-facade/_expected/system/generated-main2.js index 6ef9c75bc0f..b6cc008bb90 100644 --- a/test/chunking-form/samples/entrypoint-facade/_expected/system/generated-main2.js +++ b/test/chunking-form/samples/entrypoint-facade/_expected/system/generated-main2.js @@ -1,11 +1,11 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - exports('l', log); + exports("l", log); - var dep = exports('d', { x: 42 }); + var dep = exports("d", { x: 42 }); function log (x) { if (dep) { @@ -13,6 +13,6 @@ System.register([], function (exports) { } } - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/entrypoint-facade/_expected/system/main1.js b/test/chunking-form/samples/entrypoint-facade/_expected/system/main1.js index 8eddd1df106..413fc99fd3e 100644 --- a/test/chunking-form/samples/entrypoint-facade/_expected/system/main1.js +++ b/test/chunking-form/samples/entrypoint-facade/_expected/system/main1.js @@ -1,4 +1,4 @@ -System.register(['./generated-main2.js'], function () { +System.register(['./generated-main2.js'], (function () { 'use strict'; var log, dep; return { @@ -6,10 +6,10 @@ System.register(['./generated-main2.js'], function () { log = module.l; dep = module.d; }], - execute: function () { + execute: (function () { log(dep); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/entrypoint-facade/_expected/system/main2.js b/test/chunking-form/samples/entrypoint-facade/_expected/system/main2.js index 94afaca11b1..1750d72b46b 100644 --- a/test/chunking-form/samples/entrypoint-facade/_expected/system/main2.js +++ b/test/chunking-form/samples/entrypoint-facade/_expected/system/main2.js @@ -1,13 +1,13 @@ -System.register(['./generated-main2.js'], function (exports) { +System.register(['./generated-main2.js'], (function (exports) { 'use strict'; return { setters: [function (module) { - exports('default', module.l); + exports("default", module.l); }], - execute: function () { + execute: (function () { - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/export-default-from-entry/_config.js b/test/chunking-form/samples/export-default-from-entry/_config.js index 1fa07bc2cf0..1e07de5c314 100644 --- a/test/chunking-form/samples/export-default-from-entry/_config.js +++ b/test/chunking-form/samples/export-default-from-entry/_config.js @@ -1,6 +1,6 @@ -module.exports = { +module.exports = defineTest({ description: 'correctly imports the default from an entry point', options: { input: ['main', 'dep'] } -}; +}); diff --git a/test/chunking-form/samples/export-default-from-entry/_expected/amd/dep.js b/test/chunking-form/samples/export-default-from-entry/_expected/amd/dep.js index 67abed68a19..2a74cbbf495 100644 --- a/test/chunking-form/samples/export-default-from-entry/_expected/amd/dep.js +++ b/test/chunking-form/samples/export-default-from-entry/_expected/amd/dep.js @@ -1,7 +1,7 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; var dep = 42; return dep; -}); +})); diff --git a/test/chunking-form/samples/export-default-from-entry/_expected/amd/main.js b/test/chunking-form/samples/export-default-from-entry/_expected/amd/main.js index 515a0bbe1cf..ae54c23e6a2 100644 --- a/test/chunking-form/samples/export-default-from-entry/_expected/amd/main.js +++ b/test/chunking-form/samples/export-default-from-entry/_expected/amd/main.js @@ -1,9 +1,7 @@ -define(['exports', './dep'], function (exports, dep) { 'use strict'; +define(['exports', './dep'], (function (exports, dep) { 'use strict'; exports.value = dep; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/export-default-from-entry/_expected/cjs/main.js b/test/chunking-form/samples/export-default-from-entry/_expected/cjs/main.js index d5b48cc5a0a..e855a76e250 100644 --- a/test/chunking-form/samples/export-default-from-entry/_expected/cjs/main.js +++ b/test/chunking-form/samples/export-default-from-entry/_expected/cjs/main.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - var dep = require('./dep.js'); diff --git a/test/chunking-form/samples/export-default-from-entry/_expected/es/dep.js b/test/chunking-form/samples/export-default-from-entry/_expected/es/dep.js index 1df3b791cce..deb0fc0b34a 100644 --- a/test/chunking-form/samples/export-default-from-entry/_expected/es/dep.js +++ b/test/chunking-form/samples/export-default-from-entry/_expected/es/dep.js @@ -1,3 +1,3 @@ var dep = 42; -export default dep; +export { dep as default }; diff --git a/test/chunking-form/samples/export-default-from-entry/_expected/system/dep.js b/test/chunking-form/samples/export-default-from-entry/_expected/system/dep.js index dcce373e5a7..fa68ae3b783 100644 --- a/test/chunking-form/samples/export-default-from-entry/_expected/system/dep.js +++ b/test/chunking-form/samples/export-default-from-entry/_expected/system/dep.js @@ -1,10 +1,10 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - var dep = exports('default', 42); + var dep = exports("default", 42); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/export-default-from-entry/_expected/system/main.js b/test/chunking-form/samples/export-default-from-entry/_expected/system/main.js index 9e3ac3a6ab2..4ffef531bbf 100644 --- a/test/chunking-form/samples/export-default-from-entry/_expected/system/main.js +++ b/test/chunking-form/samples/export-default-from-entry/_expected/system/main.js @@ -1,13 +1,13 @@ -System.register(['./dep.js'], function (exports) { +System.register(['./dep.js'], (function (exports) { 'use strict'; return { setters: [function (module) { - exports('value', module.default); + exports("value", module.default); }], - execute: function () { + execute: (function () { - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/external-imports/_config.js b/test/chunking-form/samples/external-imports/_config.js index faff03e56ea..1271444b037 100644 --- a/test/chunking-form/samples/external-imports/_config.js +++ b/test/chunking-form/samples/external-imports/_config.js @@ -1,7 +1,8 @@ -module.exports = { +module.exports = defineTest({ description: 'uses correct interop per chunk when importing from external modules', options: { external: module => module.includes('external'), - input: ['main-default.js', 'main-named.js', 'main-namespace'] + input: ['main-default.js', 'main-named.js', 'main-namespace'], + output: { interop: 'compat' } } -}; +}); diff --git a/test/chunking-form/samples/external-imports/_expected/amd/main-default.js b/test/chunking-form/samples/external-imports/_expected/amd/main-default.js index 2b6c7688ffa..0465dafdcfe 100644 --- a/test/chunking-form/samples/external-imports/_expected/amd/main-default.js +++ b/test/chunking-form/samples/external-imports/_expected/amd/main-default.js @@ -1,12 +1,12 @@ -define(['external-all', 'external-default', 'external-default-named', 'external-default-namespace'], function (foo, bar, baz, quux) { 'use strict'; +define(['external-all', 'external-default', 'external-default-named', 'external-default-namespace'], (function (foo, bar, baz, quux) { 'use strict'; - function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } + function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; } - var foo__default = /*#__PURE__*/_interopDefaultLegacy(foo); - var bar__default = /*#__PURE__*/_interopDefaultLegacy(bar); - var baz__default = /*#__PURE__*/_interopDefaultLegacy(baz); - var quux__default = /*#__PURE__*/_interopDefaultLegacy(quux); + var foo__default = /*#__PURE__*/_interopDefaultCompat(foo); + var bar__default = /*#__PURE__*/_interopDefaultCompat(bar); + var baz__default = /*#__PURE__*/_interopDefaultCompat(baz); + var quux__default = /*#__PURE__*/_interopDefaultCompat(quux); - console.log(foo__default['default'], bar__default['default'], baz__default['default'], quux__default['default']); + console.log(foo__default.default, bar__default.default, baz__default.default, quux__default.default); -}); +})); diff --git a/test/chunking-form/samples/external-imports/_expected/amd/main-named.js b/test/chunking-form/samples/external-imports/_expected/amd/main-named.js index f5a7f6572d7..cf7f2cb92af 100644 --- a/test/chunking-form/samples/external-imports/_expected/amd/main-named.js +++ b/test/chunking-form/samples/external-imports/_expected/amd/main-named.js @@ -1,5 +1,5 @@ -define(['external-all', 'external-named', 'external-default-named', 'external-named-namespace'], function (foo, externalNamed, baz, quux) { 'use strict'; +define(['external-all', 'external-named', 'external-default-named', 'external-named-namespace'], (function (foo, externalNamed, baz, quux) { 'use strict'; console.log(foo.foo, externalNamed.bar, baz.baz, quux.quux); -}); +})); diff --git a/test/chunking-form/samples/external-imports/_expected/amd/main-namespace.js b/test/chunking-form/samples/external-imports/_expected/amd/main-namespace.js index e038a7abed4..cbe35642050 100644 --- a/test/chunking-form/samples/external-imports/_expected/amd/main-namespace.js +++ b/test/chunking-form/samples/external-imports/_expected/amd/main-namespace.js @@ -1,7 +1,7 @@ -define(['external-all', 'external-namespace', 'external-default-namespace', 'external-named-namespace'], function (foo, bar, quux, quux$1) { 'use strict'; +define(['external-all', 'external-namespace', 'external-default-namespace', 'external-named-namespace'], (function (foo, bar, quux, quux$1) { 'use strict'; - function _interopNamespace(e) { - if (e && e.__esModule) return e; + function _interopNamespaceCompat(e) { + if (e && typeof e === 'object' && 'default' in e) return e; var n = Object.create(null); if (e) { Object.keys(e).forEach(function (k) { @@ -9,22 +9,20 @@ define(['external-all', 'external-namespace', 'external-default-namespace', 'ext var d = Object.getOwnPropertyDescriptor(e, k); Object.defineProperty(n, k, d.get ? d : { enumerable: true, - get: function () { - return e[k]; - } + get: function () { return e[k]; } }); } }); } - n['default'] = e; + n.default = e; return Object.freeze(n); } - var foo__namespace = /*#__PURE__*/_interopNamespace(foo); - var bar__namespace = /*#__PURE__*/_interopNamespace(bar); - var quux__namespace = /*#__PURE__*/_interopNamespace(quux); - var quux__namespace$1 = /*#__PURE__*/_interopNamespace(quux$1); + var foo__namespace = /*#__PURE__*/_interopNamespaceCompat(foo); + var bar__namespace = /*#__PURE__*/_interopNamespaceCompat(bar); + var quux__namespace = /*#__PURE__*/_interopNamespaceCompat(quux); + var quux__namespace$1 = /*#__PURE__*/_interopNamespaceCompat(quux$1); console.log(foo__namespace, bar__namespace, quux__namespace, quux__namespace$1); -}); +})); diff --git a/test/chunking-form/samples/external-imports/_expected/cjs/main-default.js b/test/chunking-form/samples/external-imports/_expected/cjs/main-default.js index e4f08d36ebd..090e9cdf2b7 100644 --- a/test/chunking-form/samples/external-imports/_expected/cjs/main-default.js +++ b/test/chunking-form/samples/external-imports/_expected/cjs/main-default.js @@ -5,11 +5,11 @@ var bar = require('external-default'); var baz = require('external-default-named'); var quux = require('external-default-namespace'); -function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } +function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; } -var foo__default = /*#__PURE__*/_interopDefaultLegacy(foo); -var bar__default = /*#__PURE__*/_interopDefaultLegacy(bar); -var baz__default = /*#__PURE__*/_interopDefaultLegacy(baz); -var quux__default = /*#__PURE__*/_interopDefaultLegacy(quux); +var foo__default = /*#__PURE__*/_interopDefaultCompat(foo); +var bar__default = /*#__PURE__*/_interopDefaultCompat(bar); +var baz__default = /*#__PURE__*/_interopDefaultCompat(baz); +var quux__default = /*#__PURE__*/_interopDefaultCompat(quux); -console.log(foo__default['default'], bar__default['default'], baz__default['default'], quux__default['default']); +console.log(foo__default.default, bar__default.default, baz__default.default, quux__default.default); diff --git a/test/chunking-form/samples/external-imports/_expected/cjs/main-namespace.js b/test/chunking-form/samples/external-imports/_expected/cjs/main-namespace.js index 0417d88a1cc..8624513d356 100644 --- a/test/chunking-form/samples/external-imports/_expected/cjs/main-namespace.js +++ b/test/chunking-form/samples/external-imports/_expected/cjs/main-namespace.js @@ -5,8 +5,8 @@ var bar = require('external-namespace'); var quux = require('external-default-namespace'); var quux$1 = require('external-named-namespace'); -function _interopNamespace(e) { - if (e && e.__esModule) return e; +function _interopNamespaceCompat(e) { + if (e && typeof e === 'object' && 'default' in e) return e; var n = Object.create(null); if (e) { Object.keys(e).forEach(function (k) { @@ -14,20 +14,18 @@ function _interopNamespace(e) { var d = Object.getOwnPropertyDescriptor(e, k); Object.defineProperty(n, k, d.get ? d : { enumerable: true, - get: function () { - return e[k]; - } + get: function () { return e[k]; } }); } }); } - n['default'] = e; + n.default = e; return Object.freeze(n); } -var foo__namespace = /*#__PURE__*/_interopNamespace(foo); -var bar__namespace = /*#__PURE__*/_interopNamespace(bar); -var quux__namespace = /*#__PURE__*/_interopNamespace(quux); -var quux__namespace$1 = /*#__PURE__*/_interopNamespace(quux$1); +var foo__namespace = /*#__PURE__*/_interopNamespaceCompat(foo); +var bar__namespace = /*#__PURE__*/_interopNamespaceCompat(bar); +var quux__namespace = /*#__PURE__*/_interopNamespaceCompat(quux); +var quux__namespace$1 = /*#__PURE__*/_interopNamespaceCompat(quux$1); console.log(foo__namespace, bar__namespace, quux__namespace, quux__namespace$1); diff --git a/test/chunking-form/samples/external-imports/_expected/system/main-default.js b/test/chunking-form/samples/external-imports/_expected/system/main-default.js index b21f670e5d1..df87fcd463f 100644 --- a/test/chunking-form/samples/external-imports/_expected/system/main-default.js +++ b/test/chunking-form/samples/external-imports/_expected/system/main-default.js @@ -1,4 +1,4 @@ -System.register(['external-all', 'external-default', 'external-default-named', 'external-default-namespace'], function () { +System.register(['external-all', 'external-default', 'external-default-named', 'external-default-namespace'], (function () { 'use strict'; var foo__default, bar, baz, quux__default; return { @@ -11,10 +11,10 @@ System.register(['external-all', 'external-default', 'external-default-named', ' }, function (module) { quux__default = module.default; }], - execute: function () { + execute: (function () { console.log(foo__default, bar, baz, quux__default); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/external-imports/_expected/system/main-named.js b/test/chunking-form/samples/external-imports/_expected/system/main-named.js index ae0b8189756..d5deb31fb50 100644 --- a/test/chunking-form/samples/external-imports/_expected/system/main-named.js +++ b/test/chunking-form/samples/external-imports/_expected/system/main-named.js @@ -1,4 +1,4 @@ -System.register(['external-all', 'external-named', 'external-default-named', 'external-named-namespace'], function () { +System.register(['external-all', 'external-named', 'external-default-named', 'external-named-namespace'], (function () { 'use strict'; var foo, bar, baz, quux; return { @@ -11,10 +11,10 @@ System.register(['external-all', 'external-named', 'external-default-named', 'ex }, function (module) { quux = module.quux; }], - execute: function () { + execute: (function () { console.log(foo, bar, baz, quux); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/external-imports/_expected/system/main-namespace.js b/test/chunking-form/samples/external-imports/_expected/system/main-namespace.js index efb58b88879..7386dc73fe5 100644 --- a/test/chunking-form/samples/external-imports/_expected/system/main-namespace.js +++ b/test/chunking-form/samples/external-imports/_expected/system/main-namespace.js @@ -1,4 +1,4 @@ -System.register(['external-all', 'external-namespace', 'external-default-namespace', 'external-named-namespace'], function () { +System.register(['external-all', 'external-namespace', 'external-default-namespace', 'external-named-namespace'], (function () { 'use strict'; var foo, bar, quux, quux$1; return { @@ -11,10 +11,10 @@ System.register(['external-all', 'external-namespace', 'external-default-namespa }, function (module) { quux$1 = module; }], - execute: function () { + execute: (function () { console.log(foo, bar, quux, quux$1); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/external-reexports/_config.js b/test/chunking-form/samples/external-reexports/_config.js index e110d316f0f..f142ecda3f3 100644 --- a/test/chunking-form/samples/external-reexports/_config.js +++ b/test/chunking-form/samples/external-reexports/_config.js @@ -1,7 +1,8 @@ -module.exports = { +module.exports = defineTest({ description: 'uses correct interop per chunk when reexporting from external modules', options: { external: module => module.includes('external'), - input: ['main-default.js', 'main-named.js', 'main-namespace'] + input: ['main-default.js', 'main-named.js', 'main-namespace'], + output: { interop: 'compat' } } -}; +}); diff --git a/test/chunking-form/samples/external-reexports/_expected/amd/main-default.js b/test/chunking-form/samples/external-reexports/_expected/amd/main-default.js index f12fde932ad..df943b94f35 100644 --- a/test/chunking-form/samples/external-reexports/_expected/amd/main-default.js +++ b/test/chunking-form/samples/external-reexports/_expected/amd/main-default.js @@ -1,39 +1,29 @@ -define(['exports', 'external-all', 'external-default', 'external-default-named', 'external-default-namespace'], function (exports, externalAll, externalDefault, externalDefaultNamed, externalDefaultNamespace) { 'use strict'; +define(['exports', 'external-all', 'external-default', 'external-default-named', 'external-default-namespace'], (function (exports, externalAll, externalDefault, externalDefaultNamed, externalDefaultNamespace) { 'use strict'; - function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } + function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; } - var externalAll__default = /*#__PURE__*/_interopDefaultLegacy(externalAll); - var externalDefault__default = /*#__PURE__*/_interopDefaultLegacy(externalDefault); - var externalDefaultNamed__default = /*#__PURE__*/_interopDefaultLegacy(externalDefaultNamed); - var externalDefaultNamespace__default = /*#__PURE__*/_interopDefaultLegacy(externalDefaultNamespace); + var externalAll__default = /*#__PURE__*/_interopDefaultCompat(externalAll); + var externalDefault__default = /*#__PURE__*/_interopDefaultCompat(externalDefault); + var externalDefaultNamed__default = /*#__PURE__*/_interopDefaultCompat(externalDefaultNamed); + var externalDefaultNamespace__default = /*#__PURE__*/_interopDefaultCompat(externalDefaultNamespace); - Object.defineProperty(exports, 'foo', { + Object.defineProperty(exports, "foo", { enumerable: true, - get: function () { - return externalAll__default['default']; - } + get: function () { return externalAll__default.default; } }); - Object.defineProperty(exports, 'bar', { + Object.defineProperty(exports, "bar", { enumerable: true, - get: function () { - return externalDefault__default['default']; - } + get: function () { return externalDefault__default.default; } }); - Object.defineProperty(exports, 'baz', { + Object.defineProperty(exports, "baz", { enumerable: true, - get: function () { - return externalDefaultNamed__default['default']; - } + get: function () { return externalDefaultNamed__default.default; } }); - Object.defineProperty(exports, 'quux', { + Object.defineProperty(exports, "quux", { enumerable: true, - get: function () { - return externalDefaultNamespace__default['default']; - } + get: function () { return externalDefaultNamespace__default.default; } }); - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/external-reexports/_expected/amd/main-named.js b/test/chunking-form/samples/external-reexports/_expected/amd/main-named.js index 28207c22da5..0092b29a7e8 100644 --- a/test/chunking-form/samples/external-reexports/_expected/amd/main-named.js +++ b/test/chunking-form/samples/external-reexports/_expected/amd/main-named.js @@ -1,32 +1,22 @@ -define(['exports', 'external-all', 'external-named', 'external-default-named', 'external-named-namespace'], function (exports, externalAll, externalNamed, externalDefaultNamed, externalNamedNamespace) { 'use strict'; +define(['exports', 'external-all', 'external-named', 'external-default-named', 'external-named-namespace'], (function (exports, externalAll, externalNamed, externalDefaultNamed, externalNamedNamespace) { 'use strict'; - Object.defineProperty(exports, 'foo', { + Object.defineProperty(exports, "foo", { enumerable: true, - get: function () { - return externalAll.foo; - } + get: function () { return externalAll.foo; } }); - Object.defineProperty(exports, 'bar', { + Object.defineProperty(exports, "bar", { enumerable: true, - get: function () { - return externalNamed.bar; - } + get: function () { return externalNamed.bar; } }); - Object.defineProperty(exports, 'baz', { + Object.defineProperty(exports, "baz", { enumerable: true, - get: function () { - return externalDefaultNamed.baz; - } + get: function () { return externalDefaultNamed.baz; } }); - Object.defineProperty(exports, 'quux', { + Object.defineProperty(exports, "quux", { enumerable: true, - get: function () { - return externalNamedNamespace.quux; - } + get: function () { return externalNamedNamespace.quux; } }); - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/external-reexports/_expected/amd/main-namespace.js b/test/chunking-form/samples/external-reexports/_expected/amd/main-namespace.js index 255a9264b36..193ce4b4b72 100644 --- a/test/chunking-form/samples/external-reexports/_expected/amd/main-namespace.js +++ b/test/chunking-form/samples/external-reexports/_expected/amd/main-namespace.js @@ -1,7 +1,7 @@ -define(['exports', 'external-all', 'external-namespace', 'external-default-namespace', 'external-named-namespace'], function (exports, externalAll, externalNamespace$1, externalDefaultNamespace, externalNamedNamespace) { 'use strict'; +define(['exports', 'external-all', 'external-namespace', 'external-default-namespace', 'external-named-namespace'], (function (exports, externalAll, externalNamespace$1, externalDefaultNamespace, externalNamedNamespace) { 'use strict'; - function _interopNamespace(e) { - if (e && e.__esModule) return e; + function _interopNamespaceCompat(e) { + if (e && typeof e === 'object' && 'default' in e) return e; var n = Object.create(null); if (e) { Object.keys(e).forEach(function (k) { @@ -9,21 +9,19 @@ define(['exports', 'external-all', 'external-namespace', 'external-default-names var d = Object.getOwnPropertyDescriptor(e, k); Object.defineProperty(n, k, d.get ? d : { enumerable: true, - get: function () { - return e[k]; - } + get: function () { return e[k]; } }); } }); } - n['default'] = e; + n.default = e; return Object.freeze(n); } - var externalAll__namespace = /*#__PURE__*/_interopNamespace(externalAll); - var externalNamespace__namespace = /*#__PURE__*/_interopNamespace(externalNamespace$1); - var externalDefaultNamespace__namespace = /*#__PURE__*/_interopNamespace(externalDefaultNamespace); - var externalNamedNamespace__namespace = /*#__PURE__*/_interopNamespace(externalNamedNamespace); + var externalAll__namespace = /*#__PURE__*/_interopNamespaceCompat(externalAll); + var externalNamespace__namespace = /*#__PURE__*/_interopNamespaceCompat(externalNamespace$1); + var externalDefaultNamespace__namespace = /*#__PURE__*/_interopNamespaceCompat(externalDefaultNamespace); + var externalNamedNamespace__namespace = /*#__PURE__*/_interopNamespaceCompat(externalNamedNamespace); const externalNamespace = 1; const externalNamespace__ns = 1; @@ -34,6 +32,4 @@ define(['exports', 'external-all', 'external-namespace', 'external-default-names exports.baz = externalDefaultNamespace__namespace; exports.quux = externalNamedNamespace__namespace; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/external-reexports/_expected/cjs/main-default.js b/test/chunking-form/samples/external-reexports/_expected/cjs/main-default.js index 4ebf12cb657..b69e66475ab 100644 --- a/test/chunking-form/samples/external-reexports/_expected/cjs/main-default.js +++ b/test/chunking-form/samples/external-reexports/_expected/cjs/main-default.js @@ -1,42 +1,32 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - var externalAll = require('external-all'); var externalDefault = require('external-default'); var externalDefaultNamed = require('external-default-named'); var externalDefaultNamespace = require('external-default-namespace'); -function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } +function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; } -var externalAll__default = /*#__PURE__*/_interopDefaultLegacy(externalAll); -var externalDefault__default = /*#__PURE__*/_interopDefaultLegacy(externalDefault); -var externalDefaultNamed__default = /*#__PURE__*/_interopDefaultLegacy(externalDefaultNamed); -var externalDefaultNamespace__default = /*#__PURE__*/_interopDefaultLegacy(externalDefaultNamespace); +var externalAll__default = /*#__PURE__*/_interopDefaultCompat(externalAll); +var externalDefault__default = /*#__PURE__*/_interopDefaultCompat(externalDefault); +var externalDefaultNamed__default = /*#__PURE__*/_interopDefaultCompat(externalDefaultNamed); +var externalDefaultNamespace__default = /*#__PURE__*/_interopDefaultCompat(externalDefaultNamespace); -Object.defineProperty(exports, 'foo', { +Object.defineProperty(exports, "foo", { enumerable: true, - get: function () { - return externalAll__default['default']; - } + get: function () { return externalAll__default.default; } }); -Object.defineProperty(exports, 'bar', { +Object.defineProperty(exports, "bar", { enumerable: true, - get: function () { - return externalDefault__default['default']; - } + get: function () { return externalDefault__default.default; } }); -Object.defineProperty(exports, 'baz', { +Object.defineProperty(exports, "baz", { enumerable: true, - get: function () { - return externalDefaultNamed__default['default']; - } + get: function () { return externalDefaultNamed__default.default; } }); -Object.defineProperty(exports, 'quux', { +Object.defineProperty(exports, "quux", { enumerable: true, - get: function () { - return externalDefaultNamespace__default['default']; - } + get: function () { return externalDefaultNamespace__default.default; } }); diff --git a/test/chunking-form/samples/external-reexports/_expected/cjs/main-named.js b/test/chunking-form/samples/external-reexports/_expected/cjs/main-named.js index 15dc96d6de7..e39c413e6f4 100644 --- a/test/chunking-form/samples/external-reexports/_expected/cjs/main-named.js +++ b/test/chunking-form/samples/external-reexports/_expected/cjs/main-named.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - var externalAll = require('external-all'); var externalNamed = require('external-named'); var externalDefaultNamed = require('external-default-named'); @@ -9,27 +7,19 @@ var externalNamedNamespace = require('external-named-namespace'); -Object.defineProperty(exports, 'foo', { +Object.defineProperty(exports, "foo", { enumerable: true, - get: function () { - return externalAll.foo; - } + get: function () { return externalAll.foo; } }); -Object.defineProperty(exports, 'bar', { +Object.defineProperty(exports, "bar", { enumerable: true, - get: function () { - return externalNamed.bar; - } + get: function () { return externalNamed.bar; } }); -Object.defineProperty(exports, 'baz', { +Object.defineProperty(exports, "baz", { enumerable: true, - get: function () { - return externalDefaultNamed.baz; - } + get: function () { return externalDefaultNamed.baz; } }); -Object.defineProperty(exports, 'quux', { +Object.defineProperty(exports, "quux", { enumerable: true, - get: function () { - return externalNamedNamespace.quux; - } + get: function () { return externalNamedNamespace.quux; } }); diff --git a/test/chunking-form/samples/external-reexports/_expected/cjs/main-namespace.js b/test/chunking-form/samples/external-reexports/_expected/cjs/main-namespace.js index 8d3df6ca7ac..03779a6b5a2 100644 --- a/test/chunking-form/samples/external-reexports/_expected/cjs/main-namespace.js +++ b/test/chunking-form/samples/external-reexports/_expected/cjs/main-namespace.js @@ -1,14 +1,12 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - var externalAll = require('external-all'); var externalNamespace$1 = require('external-namespace'); var externalDefaultNamespace = require('external-default-namespace'); var externalNamedNamespace = require('external-named-namespace'); -function _interopNamespace(e) { - if (e && e.__esModule) return e; +function _interopNamespaceCompat(e) { + if (e && typeof e === 'object' && 'default' in e) return e; var n = Object.create(null); if (e) { Object.keys(e).forEach(function (k) { @@ -16,21 +14,19 @@ function _interopNamespace(e) { var d = Object.getOwnPropertyDescriptor(e, k); Object.defineProperty(n, k, d.get ? d : { enumerable: true, - get: function () { - return e[k]; - } + get: function () { return e[k]; } }); } }); } - n['default'] = e; + n.default = e; return Object.freeze(n); } -var externalAll__namespace = /*#__PURE__*/_interopNamespace(externalAll); -var externalNamespace__namespace = /*#__PURE__*/_interopNamespace(externalNamespace$1); -var externalDefaultNamespace__namespace = /*#__PURE__*/_interopNamespace(externalDefaultNamespace); -var externalNamedNamespace__namespace = /*#__PURE__*/_interopNamespace(externalNamedNamespace); +var externalAll__namespace = /*#__PURE__*/_interopNamespaceCompat(externalAll); +var externalNamespace__namespace = /*#__PURE__*/_interopNamespaceCompat(externalNamespace$1); +var externalDefaultNamespace__namespace = /*#__PURE__*/_interopNamespaceCompat(externalDefaultNamespace); +var externalNamedNamespace__namespace = /*#__PURE__*/_interopNamespaceCompat(externalNamedNamespace); const externalNamespace = 1; const externalNamespace__ns = 1; diff --git a/test/chunking-form/samples/external-reexports/_expected/system/main-default.js b/test/chunking-form/samples/external-reexports/_expected/system/main-default.js index 593a7453ec4..ea5c0a83232 100644 --- a/test/chunking-form/samples/external-reexports/_expected/system/main-default.js +++ b/test/chunking-form/samples/external-reexports/_expected/system/main-default.js @@ -1,19 +1,19 @@ -System.register(['external-all', 'external-default', 'external-default-named', 'external-default-namespace'], function (exports) { +System.register(['external-all', 'external-default', 'external-default-named', 'external-default-namespace'], (function (exports) { 'use strict'; return { setters: [function (module) { - exports('foo', module.default); + exports("foo", module.default); }, function (module) { - exports('bar', module.default); + exports("bar", module.default); }, function (module) { - exports('baz', module.default); + exports("baz", module.default); }, function (module) { - exports('quux', module.default); + exports("quux", module.default); }], - execute: function () { + execute: (function () { - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/external-reexports/_expected/system/main-named.js b/test/chunking-form/samples/external-reexports/_expected/system/main-named.js index c0d4f81aab3..d494418041d 100644 --- a/test/chunking-form/samples/external-reexports/_expected/system/main-named.js +++ b/test/chunking-form/samples/external-reexports/_expected/system/main-named.js @@ -1,19 +1,19 @@ -System.register(['external-all', 'external-named', 'external-default-named', 'external-named-namespace'], function (exports) { +System.register(['external-all', 'external-named', 'external-default-named', 'external-named-namespace'], (function (exports) { 'use strict'; return { setters: [function (module) { - exports('foo', module.foo); + exports("foo", module.foo); }, function (module) { - exports('bar', module.bar); + exports("bar", module.bar); }, function (module) { - exports('baz', module.baz); + exports("baz", module.baz); }, function (module) { - exports('quux', module.quux); + exports("quux", module.quux); }], - execute: function () { + execute: (function () { - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/external-reexports/_expected/system/main-namespace.js b/test/chunking-form/samples/external-reexports/_expected/system/main-namespace.js index 0116bef7af3..5464fe190f3 100644 --- a/test/chunking-form/samples/external-reexports/_expected/system/main-namespace.js +++ b/test/chunking-form/samples/external-reexports/_expected/system/main-namespace.js @@ -1,21 +1,21 @@ -System.register(['external-all', 'external-namespace', 'external-default-namespace', 'external-named-namespace'], function (exports) { +System.register(['external-all', 'external-namespace', 'external-default-namespace', 'external-named-namespace'], (function (exports) { 'use strict'; return { setters: [function (module) { - exports('foo', module); + exports("foo", module); }, function (module) { - exports('bar', module); + exports("bar", module); }, function (module) { - exports('baz', module); + exports("baz", module); }, function (module) { - exports('quux', module); + exports("quux", module); }], - execute: function () { + execute: (function () { const externalNamespace = 1; const externalNamespace__ns = 1; console.log(externalNamespace, externalNamespace__ns); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/facades-with-external-reexports/_config.js b/test/chunking-form/samples/facades-with-external-reexports/_config.js new file mode 100644 index 00000000000..4293de04426 --- /dev/null +++ b/test/chunking-form/samples/facades-with-external-reexports/_config.js @@ -0,0 +1,8 @@ +module.exports = defineTest({ + description: 'ignores external reexports of other entries when finding facades', + options: { + external: ['external'], + input: ['main.js', 'other.js'] + }, + expectedWarnings: ['CIRCULAR_DEPENDENCY'] +}); diff --git a/test/chunking-form/samples/facades-with-external-reexports/_expected/amd/main.js b/test/chunking-form/samples/facades-with-external-reexports/_expected/amd/main.js new file mode 100644 index 00000000000..9230eb57d54 --- /dev/null +++ b/test/chunking-form/samples/facades-with-external-reexports/_expected/amd/main.js @@ -0,0 +1,10 @@ +define(['exports', './other', 'external'], (function (exports, other, external) { 'use strict'; + + + + Object.defineProperty(exports, "foo", { + enumerable: true, + get: function () { return external.foo; } + }); + +})); diff --git a/test/chunking-form/samples/facades-with-external-reexports/_expected/amd/other.js b/test/chunking-form/samples/facades-with-external-reexports/_expected/amd/other.js new file mode 100644 index 00000000000..20813e36a56 --- /dev/null +++ b/test/chunking-form/samples/facades-with-external-reexports/_expected/amd/other.js @@ -0,0 +1,12 @@ +define(['exports', 'external'], (function (exports, external) { 'use strict'; + + console.log('other'); + + console.log('main'); + + Object.defineProperty(exports, "bar", { + enumerable: true, + get: function () { return external.bar; } + }); + +})); diff --git a/test/chunking-form/samples/facades-with-external-reexports/_expected/cjs/main.js b/test/chunking-form/samples/facades-with-external-reexports/_expected/cjs/main.js new file mode 100644 index 00000000000..c97a13dc1db --- /dev/null +++ b/test/chunking-form/samples/facades-with-external-reexports/_expected/cjs/main.js @@ -0,0 +1,11 @@ +'use strict'; + +require('./other.js'); +var external = require('external'); + + + +Object.defineProperty(exports, "foo", { + enumerable: true, + get: function () { return external.foo; } +}); diff --git a/test/chunking-form/samples/facades-with-external-reexports/_expected/cjs/other.js b/test/chunking-form/samples/facades-with-external-reexports/_expected/cjs/other.js new file mode 100644 index 00000000000..977bde89775 --- /dev/null +++ b/test/chunking-form/samples/facades-with-external-reexports/_expected/cjs/other.js @@ -0,0 +1,12 @@ +'use strict'; + +var external = require('external'); + +console.log('other'); + +console.log('main'); + +Object.defineProperty(exports, "bar", { + enumerable: true, + get: function () { return external.bar; } +}); diff --git a/test/chunking-form/samples/facades-with-external-reexports/_expected/es/main.js b/test/chunking-form/samples/facades-with-external-reexports/_expected/es/main.js new file mode 100644 index 00000000000..95e22a3dc89 --- /dev/null +++ b/test/chunking-form/samples/facades-with-external-reexports/_expected/es/main.js @@ -0,0 +1,2 @@ +import './other.js'; +export { foo } from 'external'; diff --git a/test/chunking-form/samples/facades-with-external-reexports/_expected/es/other.js b/test/chunking-form/samples/facades-with-external-reexports/_expected/es/other.js new file mode 100644 index 00000000000..e298f01b36e --- /dev/null +++ b/test/chunking-form/samples/facades-with-external-reexports/_expected/es/other.js @@ -0,0 +1,5 @@ +export { bar } from 'external'; + +console.log('other'); + +console.log('main'); diff --git a/test/chunking-form/samples/facades-with-external-reexports/_expected/system/main.js b/test/chunking-form/samples/facades-with-external-reexports/_expected/system/main.js new file mode 100644 index 00000000000..0ac3b7bf306 --- /dev/null +++ b/test/chunking-form/samples/facades-with-external-reexports/_expected/system/main.js @@ -0,0 +1,13 @@ +System.register(['./other.js', 'external'], (function (exports) { + 'use strict'; + return { + setters: [null, function (module) { + exports("foo", module.foo); + }], + execute: (function () { + + + + }) + }; +})); diff --git a/test/chunking-form/samples/facades-with-external-reexports/_expected/system/other.js b/test/chunking-form/samples/facades-with-external-reexports/_expected/system/other.js new file mode 100644 index 00000000000..55107fd4297 --- /dev/null +++ b/test/chunking-form/samples/facades-with-external-reexports/_expected/system/other.js @@ -0,0 +1,15 @@ +System.register(['external'], (function (exports) { + 'use strict'; + return { + setters: [function (module) { + exports("bar", module.bar); + }], + execute: (function () { + + console.log('other'); + + console.log('main'); + + }) + }; +})); diff --git a/test/chunking-form/samples/facades-with-external-reexports/main.js b/test/chunking-form/samples/facades-with-external-reexports/main.js new file mode 100644 index 00000000000..7bd82763f1c --- /dev/null +++ b/test/chunking-form/samples/facades-with-external-reexports/main.js @@ -0,0 +1,3 @@ +import './other'; +console.log('main'); +export { foo } from 'external'; diff --git a/test/chunking-form/samples/facades-with-external-reexports/other.js b/test/chunking-form/samples/facades-with-external-reexports/other.js new file mode 100644 index 00000000000..5d3e9ea0bbf --- /dev/null +++ b/test/chunking-form/samples/facades-with-external-reexports/other.js @@ -0,0 +1,3 @@ +import './main'; +console.log('other'); +export { bar } from 'external'; diff --git a/test/chunking-form/samples/facades-with-reexports/_config.js b/test/chunking-form/samples/facades-with-reexports/_config.js new file mode 100644 index 00000000000..18a42efb9ad --- /dev/null +++ b/test/chunking-form/samples/facades-with-reexports/_config.js @@ -0,0 +1,7 @@ +module.exports = defineTest({ + description: 'ignores reexports of other entries when finding facades', + options: { + input: ['main.js', 'other.js', 'third.js'] + }, + expectedWarnings: ['CIRCULAR_DEPENDENCY'] +}); diff --git a/test/chunking-form/samples/facades-with-reexports/_expected/amd/main.js b/test/chunking-form/samples/facades-with-reexports/_expected/amd/main.js new file mode 100644 index 00000000000..e4ffeffbc4a --- /dev/null +++ b/test/chunking-form/samples/facades-with-reexports/_expected/amd/main.js @@ -0,0 +1,7 @@ +define(['exports', './other', './third'], (function (exports, other, third) { 'use strict'; + + + + exports.foo = third.foo; + +})); diff --git a/test/chunking-form/samples/facades-with-reexports/_expected/amd/other.js b/test/chunking-form/samples/facades-with-reexports/_expected/amd/other.js new file mode 100644 index 00000000000..d8eb63aec2d --- /dev/null +++ b/test/chunking-form/samples/facades-with-reexports/_expected/amd/other.js @@ -0,0 +1,9 @@ +define(['exports', './third'], (function (exports, third) { 'use strict'; + + console.log('other'); + + console.log('main'); + + exports.bar = third.bar; + +})); diff --git a/test/chunking-form/samples/facades-with-reexports/_expected/amd/third.js b/test/chunking-form/samples/facades-with-reexports/_expected/amd/third.js new file mode 100644 index 00000000000..63963eb303b --- /dev/null +++ b/test/chunking-form/samples/facades-with-reexports/_expected/amd/third.js @@ -0,0 +1,10 @@ +define(['exports'], (function (exports) { 'use strict'; + + console.log('third'); + const foo = 'foo'; + const bar = 'bar'; + + exports.bar = bar; + exports.foo = foo; + +})); diff --git a/test/chunking-form/samples/facades-with-reexports/_expected/cjs/main.js b/test/chunking-form/samples/facades-with-reexports/_expected/cjs/main.js new file mode 100644 index 00000000000..2f109781de0 --- /dev/null +++ b/test/chunking-form/samples/facades-with-reexports/_expected/cjs/main.js @@ -0,0 +1,8 @@ +'use strict'; + +require('./other.js'); +var third = require('./third.js'); + + + +exports.foo = third.foo; diff --git a/test/chunking-form/samples/facades-with-reexports/_expected/cjs/other.js b/test/chunking-form/samples/facades-with-reexports/_expected/cjs/other.js new file mode 100644 index 00000000000..ad769d264ae --- /dev/null +++ b/test/chunking-form/samples/facades-with-reexports/_expected/cjs/other.js @@ -0,0 +1,9 @@ +'use strict'; + +var third = require('./third.js'); + +console.log('other'); + +console.log('main'); + +exports.bar = third.bar; diff --git a/test/chunking-form/samples/facades-with-reexports/_expected/cjs/third.js b/test/chunking-form/samples/facades-with-reexports/_expected/cjs/third.js new file mode 100644 index 00000000000..8f0e3640b2f --- /dev/null +++ b/test/chunking-form/samples/facades-with-reexports/_expected/cjs/third.js @@ -0,0 +1,8 @@ +'use strict'; + +console.log('third'); +const foo = 'foo'; +const bar = 'bar'; + +exports.bar = bar; +exports.foo = foo; diff --git a/test/chunking-form/samples/facades-with-reexports/_expected/es/main.js b/test/chunking-form/samples/facades-with-reexports/_expected/es/main.js new file mode 100644 index 00000000000..7c4f4ccc4be --- /dev/null +++ b/test/chunking-form/samples/facades-with-reexports/_expected/es/main.js @@ -0,0 +1,2 @@ +import './other.js'; +export { foo } from './third.js'; diff --git a/test/chunking-form/samples/facades-with-reexports/_expected/es/other.js b/test/chunking-form/samples/facades-with-reexports/_expected/es/other.js new file mode 100644 index 00000000000..4b227bf9b4f --- /dev/null +++ b/test/chunking-form/samples/facades-with-reexports/_expected/es/other.js @@ -0,0 +1,5 @@ +export { bar } from './third.js'; + +console.log('other'); + +console.log('main'); diff --git a/test/chunking-form/samples/facades-with-reexports/_expected/es/third.js b/test/chunking-form/samples/facades-with-reexports/_expected/es/third.js new file mode 100644 index 00000000000..c7bb3ce0c34 --- /dev/null +++ b/test/chunking-form/samples/facades-with-reexports/_expected/es/third.js @@ -0,0 +1,5 @@ +console.log('third'); +const foo = 'foo'; +const bar = 'bar'; + +export { bar, foo }; diff --git a/test/chunking-form/samples/facades-with-reexports/_expected/system/main.js b/test/chunking-form/samples/facades-with-reexports/_expected/system/main.js new file mode 100644 index 00000000000..960f3d55aa2 --- /dev/null +++ b/test/chunking-form/samples/facades-with-reexports/_expected/system/main.js @@ -0,0 +1,13 @@ +System.register(['./other.js', './third.js'], (function (exports) { + 'use strict'; + return { + setters: [null, function (module) { + exports("foo", module.foo); + }], + execute: (function () { + + + + }) + }; +})); diff --git a/test/chunking-form/samples/facades-with-reexports/_expected/system/other.js b/test/chunking-form/samples/facades-with-reexports/_expected/system/other.js new file mode 100644 index 00000000000..f731359e040 --- /dev/null +++ b/test/chunking-form/samples/facades-with-reexports/_expected/system/other.js @@ -0,0 +1,15 @@ +System.register(['./third.js'], (function (exports) { + 'use strict'; + return { + setters: [function (module) { + exports("bar", module.bar); + }], + execute: (function () { + + console.log('other'); + + console.log('main'); + + }) + }; +})); diff --git a/test/chunking-form/samples/facades-with-reexports/_expected/system/third.js b/test/chunking-form/samples/facades-with-reexports/_expected/system/third.js new file mode 100644 index 00000000000..14d27f81ce2 --- /dev/null +++ b/test/chunking-form/samples/facades-with-reexports/_expected/system/third.js @@ -0,0 +1,12 @@ +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + + console.log('third'); + const foo = exports("foo", 'foo'); + const bar = exports("bar", 'bar'); + + }) + }; +})); diff --git a/test/chunking-form/samples/facades-with-reexports/main.js b/test/chunking-form/samples/facades-with-reexports/main.js new file mode 100644 index 00000000000..7322abb42a9 --- /dev/null +++ b/test/chunking-form/samples/facades-with-reexports/main.js @@ -0,0 +1,3 @@ +import './other'; +console.log('main'); +export { foo } from './third'; diff --git a/test/chunking-form/samples/facades-with-reexports/other.js b/test/chunking-form/samples/facades-with-reexports/other.js new file mode 100644 index 00000000000..e7c70e8cfe1 --- /dev/null +++ b/test/chunking-form/samples/facades-with-reexports/other.js @@ -0,0 +1,3 @@ +import './main'; +console.log('other'); +export { bar } from './third'; diff --git a/test/chunking-form/samples/facades-with-reexports/third.js b/test/chunking-form/samples/facades-with-reexports/third.js new file mode 100644 index 00000000000..ff311c81d58 --- /dev/null +++ b/test/chunking-form/samples/facades-with-reexports/third.js @@ -0,0 +1,3 @@ +console.log('third'); +export const foo = 'foo'; +export const bar = 'bar'; diff --git a/test/chunking-form/samples/filenames-patterns/_config.js b/test/chunking-form/samples/filenames-patterns/_config.js index a9ebf6560d0..fee15a8638c 100644 --- a/test/chunking-form/samples/filenames-patterns/_config.js +++ b/test/chunking-form/samples/filenames-patterns/_config.js @@ -1,10 +1,10 @@ -module.exports = { +module.exports = defineTest({ description: 'filenames custom pattern', options: { input: ['main1.js', 'main2.js'], output: { entryFileNames: 'entry-[name]-[hash]-[format].js', - chunkFileNames: 'chunk-[name]-[hash]-[format].js', - }, - }, -}; + chunkFileNames: 'chunk-[name]-[hash]-[format].js' + } + } +}); diff --git a/test/chunking-form/samples/filenames-patterns/_expected/amd/chunk-main2-6a714ad3-amd.js b/test/chunking-form/samples/filenames-patterns/_expected/amd/chunk-main2-6a714ad3-amd.js deleted file mode 100644 index 4a5858c04a1..00000000000 --- a/test/chunking-form/samples/filenames-patterns/_expected/amd/chunk-main2-6a714ad3-amd.js +++ /dev/null @@ -1,14 +0,0 @@ -define(['exports'], function (exports) { 'use strict'; - - var dep = { x: 42 }; - - function log (x) { - if (dep) { - console.log(x); - } - } - - exports.dep = dep; - exports.log = log; - -}); diff --git a/test/chunking-form/samples/filenames-patterns/_expected/amd/chunk-main2-BeN-_z3e-amd.js b/test/chunking-form/samples/filenames-patterns/_expected/amd/chunk-main2-BeN-_z3e-amd.js new file mode 100644 index 00000000000..9643e93c569 --- /dev/null +++ b/test/chunking-form/samples/filenames-patterns/_expected/amd/chunk-main2-BeN-_z3e-amd.js @@ -0,0 +1,14 @@ +define(['exports'], (function (exports) { 'use strict'; + + var dep = { x: 42 }; + + function log (x) { + if (dep) { + console.log(x); + } + } + + exports.dep = dep; + exports.log = log; + +})); diff --git a/test/chunking-form/samples/filenames-patterns/_expected/amd/entry-main1-DMJ9vLw5-amd.js b/test/chunking-form/samples/filenames-patterns/_expected/amd/entry-main1-DMJ9vLw5-amd.js new file mode 100644 index 00000000000..bf19b5fca96 --- /dev/null +++ b/test/chunking-form/samples/filenames-patterns/_expected/amd/entry-main1-DMJ9vLw5-amd.js @@ -0,0 +1,5 @@ +define(['./chunk-main2-BeN-_z3e-amd'], (function (main2) { 'use strict'; + + main2.log(main2.dep); + +})); diff --git a/test/chunking-form/samples/filenames-patterns/_expected/amd/entry-main1-f47d0370-amd.js b/test/chunking-form/samples/filenames-patterns/_expected/amd/entry-main1-f47d0370-amd.js deleted file mode 100644 index 2c10541ae90..00000000000 --- a/test/chunking-form/samples/filenames-patterns/_expected/amd/entry-main1-f47d0370-amd.js +++ /dev/null @@ -1,5 +0,0 @@ -define(['./chunk-main2-6a714ad3-amd'], function (main2) { 'use strict'; - - main2.log(main2.dep); - -}); diff --git a/test/chunking-form/samples/filenames-patterns/_expected/amd/entry-main2-4db8cd0c-amd.js b/test/chunking-form/samples/filenames-patterns/_expected/amd/entry-main2-4db8cd0c-amd.js deleted file mode 100644 index 34d0dd28197..00000000000 --- a/test/chunking-form/samples/filenames-patterns/_expected/amd/entry-main2-4db8cd0c-amd.js +++ /dev/null @@ -1,7 +0,0 @@ -define(['./chunk-main2-6a714ad3-amd'], function (main2) { 'use strict'; - - - - return main2.log; - -}); diff --git a/test/chunking-form/samples/filenames-patterns/_expected/amd/entry-main2-SEc5gjvu-amd.js b/test/chunking-form/samples/filenames-patterns/_expected/amd/entry-main2-SEc5gjvu-amd.js new file mode 100644 index 00000000000..e814188dec4 --- /dev/null +++ b/test/chunking-form/samples/filenames-patterns/_expected/amd/entry-main2-SEc5gjvu-amd.js @@ -0,0 +1,7 @@ +define(['./chunk-main2-BeN-_z3e-amd'], (function (main2) { 'use strict'; + + + + return main2.log; + +})); diff --git a/test/chunking-form/samples/filenames-patterns/_expected/cjs/chunk-main2-397efa8f-cjs.js b/test/chunking-form/samples/filenames-patterns/_expected/cjs/chunk-main2-DB987Lh4-cjs.js similarity index 100% rename from test/chunking-form/samples/filenames-patterns/_expected/cjs/chunk-main2-397efa8f-cjs.js rename to test/chunking-form/samples/filenames-patterns/_expected/cjs/chunk-main2-DB987Lh4-cjs.js diff --git a/test/chunking-form/samples/filenames-patterns/_expected/cjs/entry-main1-5358eeba-cjs.js b/test/chunking-form/samples/filenames-patterns/_expected/cjs/entry-main1-5358eeba-cjs.js deleted file mode 100644 index 5528fde39bd..00000000000 --- a/test/chunking-form/samples/filenames-patterns/_expected/cjs/entry-main1-5358eeba-cjs.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -var main2 = require('./chunk-main2-397efa8f-cjs.js'); - -main2.log(main2.dep); diff --git a/test/chunking-form/samples/filenames-patterns/_expected/cjs/entry-main1-m802XraR-cjs.js b/test/chunking-form/samples/filenames-patterns/_expected/cjs/entry-main1-m802XraR-cjs.js new file mode 100644 index 00000000000..ff2abb6f258 --- /dev/null +++ b/test/chunking-form/samples/filenames-patterns/_expected/cjs/entry-main1-m802XraR-cjs.js @@ -0,0 +1,5 @@ +'use strict'; + +var main2 = require('./chunk-main2-DB987Lh4-cjs.js'); + +main2.log(main2.dep); diff --git a/test/chunking-form/samples/filenames-patterns/_expected/cjs/entry-main2-6a001c26-cjs.js b/test/chunking-form/samples/filenames-patterns/_expected/cjs/entry-main2-6a001c26-cjs.js deleted file mode 100644 index 3479ebb3f9c..00000000000 --- a/test/chunking-form/samples/filenames-patterns/_expected/cjs/entry-main2-6a001c26-cjs.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -var main2 = require('./chunk-main2-397efa8f-cjs.js'); - - - -module.exports = main2.log; diff --git a/test/chunking-form/samples/filenames-patterns/_expected/cjs/entry-main2-CDyYOEPK-cjs.js b/test/chunking-form/samples/filenames-patterns/_expected/cjs/entry-main2-CDyYOEPK-cjs.js new file mode 100644 index 00000000000..a8c1d498e19 --- /dev/null +++ b/test/chunking-form/samples/filenames-patterns/_expected/cjs/entry-main2-CDyYOEPK-cjs.js @@ -0,0 +1,7 @@ +'use strict'; + +var main2 = require('./chunk-main2-DB987Lh4-cjs.js'); + + + +module.exports = main2.log; diff --git a/test/chunking-form/samples/filenames-patterns/_expected/es/chunk-main2-bb2aced4-es.js b/test/chunking-form/samples/filenames-patterns/_expected/es/chunk-main2-CPMnlUsH-es.js similarity index 100% rename from test/chunking-form/samples/filenames-patterns/_expected/es/chunk-main2-bb2aced4-es.js rename to test/chunking-form/samples/filenames-patterns/_expected/es/chunk-main2-CPMnlUsH-es.js diff --git a/test/chunking-form/samples/filenames-patterns/_expected/es/entry-main1-352fcfce-es.js b/test/chunking-form/samples/filenames-patterns/_expected/es/entry-main1-352fcfce-es.js deleted file mode 100644 index 989bb35ec89..00000000000 --- a/test/chunking-form/samples/filenames-patterns/_expected/es/entry-main1-352fcfce-es.js +++ /dev/null @@ -1,3 +0,0 @@ -import { l as log, d as dep } from './chunk-main2-bb2aced4-es.js'; - -log(dep); diff --git a/test/chunking-form/samples/filenames-patterns/_expected/es/entry-main1-DCmtsuTI-es.js b/test/chunking-form/samples/filenames-patterns/_expected/es/entry-main1-DCmtsuTI-es.js new file mode 100644 index 00000000000..2e9c7317e25 --- /dev/null +++ b/test/chunking-form/samples/filenames-patterns/_expected/es/entry-main1-DCmtsuTI-es.js @@ -0,0 +1,3 @@ +import { l as log, d as dep } from './chunk-main2-CPMnlUsH-es.js'; + +log(dep); diff --git a/test/chunking-form/samples/filenames-patterns/_expected/es/entry-main2-8ebb5d84-es.js b/test/chunking-form/samples/filenames-patterns/_expected/es/entry-main2-8ebb5d84-es.js deleted file mode 100644 index eee53e0b1e0..00000000000 --- a/test/chunking-form/samples/filenames-patterns/_expected/es/entry-main2-8ebb5d84-es.js +++ /dev/null @@ -1 +0,0 @@ -export { l as default } from './chunk-main2-bb2aced4-es.js'; diff --git a/test/chunking-form/samples/filenames-patterns/_expected/es/entry-main2-CO3mT8jT-es.js b/test/chunking-form/samples/filenames-patterns/_expected/es/entry-main2-CO3mT8jT-es.js new file mode 100644 index 00000000000..83eddb16c42 --- /dev/null +++ b/test/chunking-form/samples/filenames-patterns/_expected/es/entry-main2-CO3mT8jT-es.js @@ -0,0 +1 @@ +export { l as default } from './chunk-main2-CPMnlUsH-es.js'; diff --git a/test/chunking-form/samples/filenames-patterns/_expected/system/chunk-main2-97f5caac-system.js b/test/chunking-form/samples/filenames-patterns/_expected/system/chunk-main2-97f5caac-system.js deleted file mode 100644 index 6ef9c75bc0f..00000000000 --- a/test/chunking-form/samples/filenames-patterns/_expected/system/chunk-main2-97f5caac-system.js +++ /dev/null @@ -1,18 +0,0 @@ -System.register([], function (exports) { - 'use strict'; - return { - execute: function () { - - exports('l', log); - - var dep = exports('d', { x: 42 }); - - function log (x) { - if (dep) { - console.log(x); - } - } - - } - }; -}); diff --git a/test/chunking-form/samples/filenames-patterns/_expected/system/chunk-main2-BRXsWtDg-system.js b/test/chunking-form/samples/filenames-patterns/_expected/system/chunk-main2-BRXsWtDg-system.js new file mode 100644 index 00000000000..b6cc008bb90 --- /dev/null +++ b/test/chunking-form/samples/filenames-patterns/_expected/system/chunk-main2-BRXsWtDg-system.js @@ -0,0 +1,18 @@ +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + + exports("l", log); + + var dep = exports("d", { x: 42 }); + + function log (x) { + if (dep) { + console.log(x); + } + } + + }) + }; +})); diff --git a/test/chunking-form/samples/filenames-patterns/_expected/system/entry-main1-Biq2O0X--system.js b/test/chunking-form/samples/filenames-patterns/_expected/system/entry-main1-Biq2O0X--system.js new file mode 100644 index 00000000000..173ac94ddf4 --- /dev/null +++ b/test/chunking-form/samples/filenames-patterns/_expected/system/entry-main1-Biq2O0X--system.js @@ -0,0 +1,15 @@ +System.register(['./chunk-main2-BRXsWtDg-system.js'], (function () { + 'use strict'; + var log, dep; + return { + setters: [function (module) { + log = module.l; + dep = module.d; + }], + execute: (function () { + + log(dep); + + }) + }; +})); diff --git a/test/chunking-form/samples/filenames-patterns/_expected/system/entry-main1-e6585a3e-system.js b/test/chunking-form/samples/filenames-patterns/_expected/system/entry-main1-e6585a3e-system.js deleted file mode 100644 index 63ae6a96879..00000000000 --- a/test/chunking-form/samples/filenames-patterns/_expected/system/entry-main1-e6585a3e-system.js +++ /dev/null @@ -1,15 +0,0 @@ -System.register(['./chunk-main2-97f5caac-system.js'], function () { - 'use strict'; - var log, dep; - return { - setters: [function (module) { - log = module.l; - dep = module.d; - }], - execute: function () { - - log(dep); - - } - }; -}); diff --git a/test/chunking-form/samples/filenames-patterns/_expected/system/entry-main2-2e964c97-system.js b/test/chunking-form/samples/filenames-patterns/_expected/system/entry-main2-2e964c97-system.js deleted file mode 100644 index e36c442c5f5..00000000000 --- a/test/chunking-form/samples/filenames-patterns/_expected/system/entry-main2-2e964c97-system.js +++ /dev/null @@ -1,13 +0,0 @@ -System.register(['./chunk-main2-97f5caac-system.js'], function (exports) { - 'use strict'; - return { - setters: [function (module) { - exports('default', module.l); - }], - execute: function () { - - - - } - }; -}); diff --git a/test/chunking-form/samples/filenames-patterns/_expected/system/entry-main2-D_RLirM0-system.js b/test/chunking-form/samples/filenames-patterns/_expected/system/entry-main2-D_RLirM0-system.js new file mode 100644 index 00000000000..417076cf1e2 --- /dev/null +++ b/test/chunking-form/samples/filenames-patterns/_expected/system/entry-main2-D_RLirM0-system.js @@ -0,0 +1,13 @@ +System.register(['./chunk-main2-BRXsWtDg-system.js'], (function (exports) { + 'use strict'; + return { + setters: [function (module) { + exports("default", module.l); + }], + execute: (function () { + + + + }) + }; +})); diff --git a/test/chunking-form/samples/generated-code/arrow-functions-false/_config.js b/test/chunking-form/samples/generated-code/arrow-functions-false/_config.js new file mode 100644 index 00000000000..a9b14376de9 --- /dev/null +++ b/test/chunking-form/samples/generated-code/arrow-functions-false/_config.js @@ -0,0 +1,9 @@ +module.exports = defineTest({ + description: 'does not use arrow functions', + options: { + input: ['main', 'main2'], + output: { + generatedCode: { arrowFunctions: false } + } + } +}); diff --git a/test/chunking-form/samples/generated-code/arrow-functions-false/_expected/amd/generated-dep1.js b/test/chunking-form/samples/generated-code/arrow-functions-false/_expected/amd/generated-dep1.js new file mode 100644 index 00000000000..12280c586bf --- /dev/null +++ b/test/chunking-form/samples/generated-code/arrow-functions-false/_expected/amd/generated-dep1.js @@ -0,0 +1,17 @@ +define(['exports'], (function (exports) { 'use strict'; + + const foo = 'dep2'; + Promise.resolve().then(function () { return dep1; }).then(console.log); + + const bar = 'dep1' + foo; + + var dep1 = /*#__PURE__*/Object.freeze({ + __proto__: null, + bar: bar + }); + + exports.bar = bar; + exports.dep1 = dep1; + exports.foo = foo; + +})); diff --git a/test/chunking-form/samples/generated-code/arrow-functions-false/_expected/amd/main.js b/test/chunking-form/samples/generated-code/arrow-functions-false/_expected/amd/main.js new file mode 100644 index 00000000000..020c82b8402 --- /dev/null +++ b/test/chunking-form/samples/generated-code/arrow-functions-false/_expected/amd/main.js @@ -0,0 +1,5 @@ +define(['./generated-dep1'], (function (dep1) { 'use strict'; + + console.log(dep1.foo, dep1.bar); + +})); diff --git a/test/chunking-form/samples/generated-code/arrow-functions-false/_expected/amd/main2.js b/test/chunking-form/samples/generated-code/arrow-functions-false/_expected/amd/main2.js new file mode 100644 index 00000000000..9d28ca7ea12 --- /dev/null +++ b/test/chunking-form/samples/generated-code/arrow-functions-false/_expected/amd/main2.js @@ -0,0 +1,5 @@ +define(['require'], (function (require) { 'use strict'; + + new Promise(function (resolve, reject) { require(['./generated-dep1'], resolve, reject); }).then(function (n) { return n.dep1; }).then(console.log); + +})); diff --git a/test/chunking-form/samples/generated-code/arrow-functions-false/_expected/cjs/generated-dep1.js b/test/chunking-form/samples/generated-code/arrow-functions-false/_expected/cjs/generated-dep1.js new file mode 100644 index 00000000000..8f3d5eb15ff --- /dev/null +++ b/test/chunking-form/samples/generated-code/arrow-functions-false/_expected/cjs/generated-dep1.js @@ -0,0 +1,15 @@ +'use strict'; + +const foo = 'dep2'; +Promise.resolve().then(function () { return dep1; }).then(console.log); + +const bar = 'dep1' + foo; + +var dep1 = /*#__PURE__*/Object.freeze({ + __proto__: null, + bar: bar +}); + +exports.bar = bar; +exports.dep1 = dep1; +exports.foo = foo; diff --git a/test/chunking-form/samples/generated-code/arrow-functions-false/_expected/cjs/main.js b/test/chunking-form/samples/generated-code/arrow-functions-false/_expected/cjs/main.js new file mode 100644 index 00000000000..f83f3d29ad9 --- /dev/null +++ b/test/chunking-form/samples/generated-code/arrow-functions-false/_expected/cjs/main.js @@ -0,0 +1,5 @@ +'use strict'; + +var dep1 = require('./generated-dep1.js'); + +console.log(dep1.foo, dep1.bar); diff --git a/test/chunking-form/samples/generated-code/arrow-functions-false/_expected/cjs/main2.js b/test/chunking-form/samples/generated-code/arrow-functions-false/_expected/cjs/main2.js new file mode 100644 index 00000000000..0d5634c4bdf --- /dev/null +++ b/test/chunking-form/samples/generated-code/arrow-functions-false/_expected/cjs/main2.js @@ -0,0 +1,3 @@ +'use strict'; + +Promise.resolve().then(function () { return require('./generated-dep1.js'); }).then(function (n) { return n.dep1; }).then(console.log); diff --git a/test/chunking-form/samples/generated-code/arrow-functions-false/_expected/es/generated-dep1.js b/test/chunking-form/samples/generated-code/arrow-functions-false/_expected/es/generated-dep1.js new file mode 100644 index 00000000000..77708921062 --- /dev/null +++ b/test/chunking-form/samples/generated-code/arrow-functions-false/_expected/es/generated-dep1.js @@ -0,0 +1,11 @@ +const foo = 'dep2'; +Promise.resolve().then(function () { return dep1; }).then(console.log); + +const bar = 'dep1' + foo; + +var dep1 = /*#__PURE__*/Object.freeze({ + __proto__: null, + bar: bar +}); + +export { bar as b, dep1 as d, foo as f }; diff --git a/test/chunking-form/samples/generated-code/arrow-functions-false/_expected/es/main.js b/test/chunking-form/samples/generated-code/arrow-functions-false/_expected/es/main.js new file mode 100644 index 00000000000..d4995f06fc5 --- /dev/null +++ b/test/chunking-form/samples/generated-code/arrow-functions-false/_expected/es/main.js @@ -0,0 +1,3 @@ +import { f as foo, b as bar } from './generated-dep1.js'; + +console.log(foo, bar); diff --git a/test/chunking-form/samples/generated-code/arrow-functions-false/_expected/es/main2.js b/test/chunking-form/samples/generated-code/arrow-functions-false/_expected/es/main2.js new file mode 100644 index 00000000000..c40c03697a6 --- /dev/null +++ b/test/chunking-form/samples/generated-code/arrow-functions-false/_expected/es/main2.js @@ -0,0 +1 @@ +import('./generated-dep1.js').then(function (n) { return n.d; }).then(console.log); diff --git a/test/chunking-form/samples/generated-code/arrow-functions-false/_expected/system/generated-dep1.js b/test/chunking-form/samples/generated-code/arrow-functions-false/_expected/system/generated-dep1.js new file mode 100644 index 00000000000..8ad60737d4a --- /dev/null +++ b/test/chunking-form/samples/generated-code/arrow-functions-false/_expected/system/generated-dep1.js @@ -0,0 +1,19 @@ +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + + const foo = exports("f", 'dep2'); + Promise.resolve().then(function () { return dep1; }).then(console.log); + + const bar = exports("b", 'dep1' + foo); + + var dep1 = /*#__PURE__*/Object.freeze({ + __proto__: null, + bar: bar + }); + exports("d", dep1); + + }) + }; +})); diff --git a/test/chunking-form/samples/generated-code/arrow-functions-false/_expected/system/main.js b/test/chunking-form/samples/generated-code/arrow-functions-false/_expected/system/main.js new file mode 100644 index 00000000000..0d25b49f41d --- /dev/null +++ b/test/chunking-form/samples/generated-code/arrow-functions-false/_expected/system/main.js @@ -0,0 +1,15 @@ +System.register(['./generated-dep1.js'], (function () { + 'use strict'; + var foo, bar; + return { + setters: [function (module) { + foo = module.f; + bar = module.b; + }], + execute: (function () { + + console.log(foo, bar); + + }) + }; +})); diff --git a/test/chunking-form/samples/generated-code/arrow-functions-false/_expected/system/main2.js b/test/chunking-form/samples/generated-code/arrow-functions-false/_expected/system/main2.js new file mode 100644 index 00000000000..0c3776f68ab --- /dev/null +++ b/test/chunking-form/samples/generated-code/arrow-functions-false/_expected/system/main2.js @@ -0,0 +1,10 @@ +System.register([], (function (exports, module) { + 'use strict'; + return { + execute: (function () { + + module.import('./generated-dep1.js').then(function (n) { return n.d; }).then(console.log); + + }) + }; +})); diff --git a/test/chunking-form/samples/generated-code/arrow-functions-false/dep1.js b/test/chunking-form/samples/generated-code/arrow-functions-false/dep1.js new file mode 100644 index 00000000000..a21ddc4eff6 --- /dev/null +++ b/test/chunking-form/samples/generated-code/arrow-functions-false/dep1.js @@ -0,0 +1,2 @@ +import { foo } from './dep2.js'; +export const bar = 'dep1' + foo; diff --git a/test/chunking-form/samples/generated-code/arrow-functions-false/dep2.js b/test/chunking-form/samples/generated-code/arrow-functions-false/dep2.js new file mode 100644 index 00000000000..0afb618e52e --- /dev/null +++ b/test/chunking-form/samples/generated-code/arrow-functions-false/dep2.js @@ -0,0 +1,2 @@ +export const foo = 'dep2'; +import('./dep1.js').then(console.log); diff --git a/test/chunking-form/samples/generated-code/arrow-functions-false/main.js b/test/chunking-form/samples/generated-code/arrow-functions-false/main.js new file mode 100644 index 00000000000..46ce2673857 --- /dev/null +++ b/test/chunking-form/samples/generated-code/arrow-functions-false/main.js @@ -0,0 +1,4 @@ +import { bar } from './dep1.js'; +import { foo } from './dep2.js'; + +console.log(foo, bar); diff --git a/test/chunking-form/samples/generated-code/arrow-functions-false/main2.js b/test/chunking-form/samples/generated-code/arrow-functions-false/main2.js new file mode 100644 index 00000000000..5fe43355db1 --- /dev/null +++ b/test/chunking-form/samples/generated-code/arrow-functions-false/main2.js @@ -0,0 +1 @@ +import('./dep1.js').then(console.log); diff --git a/test/chunking-form/samples/generated-code/arrow-functions-true/_config.js b/test/chunking-form/samples/generated-code/arrow-functions-true/_config.js new file mode 100644 index 00000000000..c02ebd7077b --- /dev/null +++ b/test/chunking-form/samples/generated-code/arrow-functions-true/_config.js @@ -0,0 +1,9 @@ +module.exports = defineTest({ + description: 'uses arrow functions', + options: { + input: ['main', 'main2'], + output: { + generatedCode: { arrowFunctions: true } + } + } +}); diff --git a/test/chunking-form/samples/generated-code/arrow-functions-true/_expected/amd/generated-dep1.js b/test/chunking-form/samples/generated-code/arrow-functions-true/_expected/amd/generated-dep1.js new file mode 100644 index 00000000000..df06ecfa8a6 --- /dev/null +++ b/test/chunking-form/samples/generated-code/arrow-functions-true/_expected/amd/generated-dep1.js @@ -0,0 +1,17 @@ +define(['exports'], (function (exports) { 'use strict'; + + const foo = 'dep2'; + Promise.resolve().then(() => dep1).then(console.log); + + const bar = 'dep1' + foo; + + var dep1 = /*#__PURE__*/Object.freeze({ + __proto__: null, + bar: bar + }); + + exports.bar = bar; + exports.dep1 = dep1; + exports.foo = foo; + +})); diff --git a/test/chunking-form/samples/generated-code/arrow-functions-true/_expected/amd/main.js b/test/chunking-form/samples/generated-code/arrow-functions-true/_expected/amd/main.js new file mode 100644 index 00000000000..020c82b8402 --- /dev/null +++ b/test/chunking-form/samples/generated-code/arrow-functions-true/_expected/amd/main.js @@ -0,0 +1,5 @@ +define(['./generated-dep1'], (function (dep1) { 'use strict'; + + console.log(dep1.foo, dep1.bar); + +})); diff --git a/test/chunking-form/samples/generated-code/arrow-functions-true/_expected/amd/main2.js b/test/chunking-form/samples/generated-code/arrow-functions-true/_expected/amd/main2.js new file mode 100644 index 00000000000..8d1097019eb --- /dev/null +++ b/test/chunking-form/samples/generated-code/arrow-functions-true/_expected/amd/main2.js @@ -0,0 +1,5 @@ +define(['require'], (function (require) { 'use strict'; + + new Promise((resolve, reject) => require(['./generated-dep1'], resolve, reject)).then(n => n.dep1).then(console.log); + +})); diff --git a/test/chunking-form/samples/generated-code/arrow-functions-true/_expected/cjs/generated-dep1.js b/test/chunking-form/samples/generated-code/arrow-functions-true/_expected/cjs/generated-dep1.js new file mode 100644 index 00000000000..86631565e69 --- /dev/null +++ b/test/chunking-form/samples/generated-code/arrow-functions-true/_expected/cjs/generated-dep1.js @@ -0,0 +1,15 @@ +'use strict'; + +const foo = 'dep2'; +Promise.resolve().then(() => dep1).then(console.log); + +const bar = 'dep1' + foo; + +var dep1 = /*#__PURE__*/Object.freeze({ + __proto__: null, + bar: bar +}); + +exports.bar = bar; +exports.dep1 = dep1; +exports.foo = foo; diff --git a/test/chunking-form/samples/generated-code/arrow-functions-true/_expected/cjs/main.js b/test/chunking-form/samples/generated-code/arrow-functions-true/_expected/cjs/main.js new file mode 100644 index 00000000000..f83f3d29ad9 --- /dev/null +++ b/test/chunking-form/samples/generated-code/arrow-functions-true/_expected/cjs/main.js @@ -0,0 +1,5 @@ +'use strict'; + +var dep1 = require('./generated-dep1.js'); + +console.log(dep1.foo, dep1.bar); diff --git a/test/chunking-form/samples/generated-code/arrow-functions-true/_expected/cjs/main2.js b/test/chunking-form/samples/generated-code/arrow-functions-true/_expected/cjs/main2.js new file mode 100644 index 00000000000..c1864a84c5f --- /dev/null +++ b/test/chunking-form/samples/generated-code/arrow-functions-true/_expected/cjs/main2.js @@ -0,0 +1,3 @@ +'use strict'; + +Promise.resolve().then(() => require('./generated-dep1.js')).then(n => n.dep1).then(console.log); diff --git a/test/chunking-form/samples/generated-code/arrow-functions-true/_expected/es/generated-dep1.js b/test/chunking-form/samples/generated-code/arrow-functions-true/_expected/es/generated-dep1.js new file mode 100644 index 00000000000..455a57ee3b1 --- /dev/null +++ b/test/chunking-form/samples/generated-code/arrow-functions-true/_expected/es/generated-dep1.js @@ -0,0 +1,11 @@ +const foo = 'dep2'; +Promise.resolve().then(() => dep1).then(console.log); + +const bar = 'dep1' + foo; + +var dep1 = /*#__PURE__*/Object.freeze({ + __proto__: null, + bar: bar +}); + +export { bar as b, dep1 as d, foo as f }; diff --git a/test/chunking-form/samples/generated-code/arrow-functions-true/_expected/es/main.js b/test/chunking-form/samples/generated-code/arrow-functions-true/_expected/es/main.js new file mode 100644 index 00000000000..d4995f06fc5 --- /dev/null +++ b/test/chunking-form/samples/generated-code/arrow-functions-true/_expected/es/main.js @@ -0,0 +1,3 @@ +import { f as foo, b as bar } from './generated-dep1.js'; + +console.log(foo, bar); diff --git a/test/chunking-form/samples/generated-code/arrow-functions-true/_expected/es/main2.js b/test/chunking-form/samples/generated-code/arrow-functions-true/_expected/es/main2.js new file mode 100644 index 00000000000..dcba6f64946 --- /dev/null +++ b/test/chunking-form/samples/generated-code/arrow-functions-true/_expected/es/main2.js @@ -0,0 +1 @@ +import('./generated-dep1.js').then(n => n.d).then(console.log); diff --git a/test/chunking-form/samples/generated-code/arrow-functions-true/_expected/system/generated-dep1.js b/test/chunking-form/samples/generated-code/arrow-functions-true/_expected/system/generated-dep1.js new file mode 100644 index 00000000000..7e6602e007d --- /dev/null +++ b/test/chunking-form/samples/generated-code/arrow-functions-true/_expected/system/generated-dep1.js @@ -0,0 +1,19 @@ +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + + const foo = exports("f", 'dep2'); + Promise.resolve().then(() => dep1).then(console.log); + + const bar = exports("b", 'dep1' + foo); + + var dep1 = /*#__PURE__*/Object.freeze({ + __proto__: null, + bar: bar + }); + exports("d", dep1); + + }) + }; +})); diff --git a/test/chunking-form/samples/generated-code/arrow-functions-true/_expected/system/main.js b/test/chunking-form/samples/generated-code/arrow-functions-true/_expected/system/main.js new file mode 100644 index 00000000000..e3ababbe349 --- /dev/null +++ b/test/chunking-form/samples/generated-code/arrow-functions-true/_expected/system/main.js @@ -0,0 +1,15 @@ +System.register(['./generated-dep1.js'], (function () { + 'use strict'; + var foo, bar; + return { + setters: [module => { + foo = module.f; + bar = module.b; + }], + execute: (function () { + + console.log(foo, bar); + + }) + }; +})); diff --git a/test/chunking-form/samples/generated-code/arrow-functions-true/_expected/system/main2.js b/test/chunking-form/samples/generated-code/arrow-functions-true/_expected/system/main2.js new file mode 100644 index 00000000000..bfe7a6c93ed --- /dev/null +++ b/test/chunking-form/samples/generated-code/arrow-functions-true/_expected/system/main2.js @@ -0,0 +1,10 @@ +System.register([], (function (exports, module) { + 'use strict'; + return { + execute: (function () { + + module.import('./generated-dep1.js').then(n => n.d).then(console.log); + + }) + }; +})); diff --git a/test/chunking-form/samples/generated-code/arrow-functions-true/dep1.js b/test/chunking-form/samples/generated-code/arrow-functions-true/dep1.js new file mode 100644 index 00000000000..a21ddc4eff6 --- /dev/null +++ b/test/chunking-form/samples/generated-code/arrow-functions-true/dep1.js @@ -0,0 +1,2 @@ +import { foo } from './dep2.js'; +export const bar = 'dep1' + foo; diff --git a/test/chunking-form/samples/generated-code/arrow-functions-true/dep2.js b/test/chunking-form/samples/generated-code/arrow-functions-true/dep2.js new file mode 100644 index 00000000000..0afb618e52e --- /dev/null +++ b/test/chunking-form/samples/generated-code/arrow-functions-true/dep2.js @@ -0,0 +1,2 @@ +export const foo = 'dep2'; +import('./dep1.js').then(console.log); diff --git a/test/chunking-form/samples/generated-code/arrow-functions-true/main.js b/test/chunking-form/samples/generated-code/arrow-functions-true/main.js new file mode 100644 index 00000000000..46ce2673857 --- /dev/null +++ b/test/chunking-form/samples/generated-code/arrow-functions-true/main.js @@ -0,0 +1,4 @@ +import { bar } from './dep1.js'; +import { foo } from './dep2.js'; + +console.log(foo, bar); diff --git a/test/chunking-form/samples/generated-code/arrow-functions-true/main2.js b/test/chunking-form/samples/generated-code/arrow-functions-true/main2.js new file mode 100644 index 00000000000..5fe43355db1 --- /dev/null +++ b/test/chunking-form/samples/generated-code/arrow-functions-true/main2.js @@ -0,0 +1 @@ +import('./dep1.js').then(console.log); diff --git a/test/chunking-form/samples/generated-code/reserved-names-as-props-false/_config.js b/test/chunking-form/samples/generated-code/reserved-names-as-props-false/_config.js new file mode 100644 index 00000000000..47b2ec162d3 --- /dev/null +++ b/test/chunking-form/samples/generated-code/reserved-names-as-props-false/_config.js @@ -0,0 +1,12 @@ +module.exports = defineTest({ + description: 'escapes reserved names used as props', + options: { + input: ['main', 'main2'], + external: ['external'], + output: { + exports: 'named', + generatedCode: { reservedNamesAsProps: false }, + name: 'bundle' + } + } +}); diff --git a/test/chunking-form/samples/generated-code/reserved-names-as-props-false/_expected/amd/main.js b/test/chunking-form/samples/generated-code/reserved-names-as-props-false/_expected/amd/main.js new file mode 100644 index 00000000000..25748951123 --- /dev/null +++ b/test/chunking-form/samples/generated-code/reserved-names-as-props-false/_expected/amd/main.js @@ -0,0 +1,7 @@ +define(['exports', './main2'], (function (exports, main2) { 'use strict'; + + + + exports.foo = main2["default"]; + +})); diff --git a/test/chunking-form/samples/generated-code/reserved-names-as-props-false/_expected/amd/main2.js b/test/chunking-form/samples/generated-code/reserved-names-as-props-false/_expected/amd/main2.js new file mode 100644 index 00000000000..f72ff95d4f9 --- /dev/null +++ b/test/chunking-form/samples/generated-code/reserved-names-as-props-false/_expected/amd/main2.js @@ -0,0 +1,9 @@ +define(['exports'], (function (exports) { 'use strict'; + + var main2 = 42; + + exports["default"] = main2; + + Object.defineProperty(exports, '__esModule', { value: true }); + +})); diff --git a/test/chunking-form/samples/generated-code/reserved-names-as-props-false/_expected/cjs/main.js b/test/chunking-form/samples/generated-code/reserved-names-as-props-false/_expected/cjs/main.js new file mode 100644 index 00000000000..92ccdef0867 --- /dev/null +++ b/test/chunking-form/samples/generated-code/reserved-names-as-props-false/_expected/cjs/main.js @@ -0,0 +1,7 @@ +'use strict'; + +var main2 = require('./main2.js'); + + + +exports.foo = main2["default"]; diff --git a/test/chunking-form/samples/generated-code/reserved-names-as-props-false/_expected/cjs/main2.js b/test/chunking-form/samples/generated-code/reserved-names-as-props-false/_expected/cjs/main2.js new file mode 100644 index 00000000000..0b290f6585e --- /dev/null +++ b/test/chunking-form/samples/generated-code/reserved-names-as-props-false/_expected/cjs/main2.js @@ -0,0 +1,7 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { value: true }); + +var main2 = 42; + +exports["default"] = main2; diff --git a/test/chunking-form/samples/generated-code/reserved-names-as-props-false/_expected/es/main.js b/test/chunking-form/samples/generated-code/reserved-names-as-props-false/_expected/es/main.js new file mode 100644 index 00000000000..5e54d802c29 --- /dev/null +++ b/test/chunking-form/samples/generated-code/reserved-names-as-props-false/_expected/es/main.js @@ -0,0 +1 @@ +export { default as foo } from './main2.js'; diff --git a/test/chunking-form/samples/generated-code/reserved-names-as-props-false/_expected/es/main2.js b/test/chunking-form/samples/generated-code/reserved-names-as-props-false/_expected/es/main2.js new file mode 100644 index 00000000000..51f64f011b3 --- /dev/null +++ b/test/chunking-form/samples/generated-code/reserved-names-as-props-false/_expected/es/main2.js @@ -0,0 +1,3 @@ +var main2 = 42; + +export { main2 as default }; diff --git a/test/chunking-form/samples/generated-code/reserved-names-as-props-false/_expected/system/main.js b/test/chunking-form/samples/generated-code/reserved-names-as-props-false/_expected/system/main.js new file mode 100644 index 00000000000..eae57be70fd --- /dev/null +++ b/test/chunking-form/samples/generated-code/reserved-names-as-props-false/_expected/system/main.js @@ -0,0 +1,13 @@ +System.register('bundle', ['./main2.js'], (function (exports) { + 'use strict'; + return { + setters: [function (module) { + exports("foo", module["default"]); + }], + execute: (function () { + + + + }) + }; +})); diff --git a/test/chunking-form/samples/generated-code/reserved-names-as-props-false/_expected/system/main2.js b/test/chunking-form/samples/generated-code/reserved-names-as-props-false/_expected/system/main2.js new file mode 100644 index 00000000000..ed15e026d93 --- /dev/null +++ b/test/chunking-form/samples/generated-code/reserved-names-as-props-false/_expected/system/main2.js @@ -0,0 +1,10 @@ +System.register('bundle', [], (function (exports) { + 'use strict'; + return { + execute: (function () { + + var main2 = exports("default", 42); + + }) + }; +})); diff --git a/test/chunking-form/samples/generated-code/reserved-names-as-props-false/main.js b/test/chunking-form/samples/generated-code/reserved-names-as-props-false/main.js new file mode 100644 index 00000000000..5e54d802c29 --- /dev/null +++ b/test/chunking-form/samples/generated-code/reserved-names-as-props-false/main.js @@ -0,0 +1 @@ +export { default as foo } from './main2.js'; diff --git a/test/chunking-form/samples/deprecated/emit-chunk-existing/dep.js b/test/chunking-form/samples/generated-code/reserved-names-as-props-false/main2.js similarity index 100% rename from test/chunking-form/samples/deprecated/emit-chunk-existing/dep.js rename to test/chunking-form/samples/generated-code/reserved-names-as-props-false/main2.js diff --git a/test/chunking-form/samples/generated-code/reserved-names-as-props-true/_config.js b/test/chunking-form/samples/generated-code/reserved-names-as-props-true/_config.js new file mode 100644 index 00000000000..b82804a1274 --- /dev/null +++ b/test/chunking-form/samples/generated-code/reserved-names-as-props-true/_config.js @@ -0,0 +1,12 @@ +module.exports = defineTest({ + description: 'escapes reserved names used as props', + options: { + input: ['main', 'main2'], + external: ['external'], + output: { + exports: 'named', + generatedCode: { reservedNamesAsProps: true }, + name: 'bundle' + } + } +}); diff --git a/test/chunking-form/samples/generated-code/reserved-names-as-props-true/_expected/amd/main.js b/test/chunking-form/samples/generated-code/reserved-names-as-props-true/_expected/amd/main.js new file mode 100644 index 00000000000..22ced0f4756 --- /dev/null +++ b/test/chunking-form/samples/generated-code/reserved-names-as-props-true/_expected/amd/main.js @@ -0,0 +1,7 @@ +define(['exports', './main2'], (function (exports, main2) { 'use strict'; + + + + exports.foo = main2.default; + +})); diff --git a/test/chunking-form/samples/generated-code/reserved-names-as-props-true/_expected/amd/main2.js b/test/chunking-form/samples/generated-code/reserved-names-as-props-true/_expected/amd/main2.js new file mode 100644 index 00000000000..f1de07c9368 --- /dev/null +++ b/test/chunking-form/samples/generated-code/reserved-names-as-props-true/_expected/amd/main2.js @@ -0,0 +1,9 @@ +define(['exports'], (function (exports) { 'use strict'; + + var main2 = 42; + + exports.default = main2; + + Object.defineProperty(exports, '__esModule', { value: true }); + +})); diff --git a/test/chunking-form/samples/generated-code/reserved-names-as-props-true/_expected/cjs/main.js b/test/chunking-form/samples/generated-code/reserved-names-as-props-true/_expected/cjs/main.js new file mode 100644 index 00000000000..4bf51892080 --- /dev/null +++ b/test/chunking-form/samples/generated-code/reserved-names-as-props-true/_expected/cjs/main.js @@ -0,0 +1,7 @@ +'use strict'; + +var main2 = require('./main2.js'); + + + +exports.foo = main2.default; diff --git a/test/chunking-form/samples/generated-code/reserved-names-as-props-true/_expected/cjs/main2.js b/test/chunking-form/samples/generated-code/reserved-names-as-props-true/_expected/cjs/main2.js new file mode 100644 index 00000000000..28c25bb8325 --- /dev/null +++ b/test/chunking-form/samples/generated-code/reserved-names-as-props-true/_expected/cjs/main2.js @@ -0,0 +1,7 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { value: true }); + +var main2 = 42; + +exports.default = main2; diff --git a/test/chunking-form/samples/generated-code/reserved-names-as-props-true/_expected/es/main.js b/test/chunking-form/samples/generated-code/reserved-names-as-props-true/_expected/es/main.js new file mode 100644 index 00000000000..5e54d802c29 --- /dev/null +++ b/test/chunking-form/samples/generated-code/reserved-names-as-props-true/_expected/es/main.js @@ -0,0 +1 @@ +export { default as foo } from './main2.js'; diff --git a/test/chunking-form/samples/generated-code/reserved-names-as-props-true/_expected/es/main2.js b/test/chunking-form/samples/generated-code/reserved-names-as-props-true/_expected/es/main2.js new file mode 100644 index 00000000000..51f64f011b3 --- /dev/null +++ b/test/chunking-form/samples/generated-code/reserved-names-as-props-true/_expected/es/main2.js @@ -0,0 +1,3 @@ +var main2 = 42; + +export { main2 as default }; diff --git a/test/chunking-form/samples/generated-code/reserved-names-as-props-true/_expected/system/main.js b/test/chunking-form/samples/generated-code/reserved-names-as-props-true/_expected/system/main.js new file mode 100644 index 00000000000..6fac144e585 --- /dev/null +++ b/test/chunking-form/samples/generated-code/reserved-names-as-props-true/_expected/system/main.js @@ -0,0 +1,13 @@ +System.register('bundle', ['./main2.js'], (function (exports) { + 'use strict'; + return { + setters: [function (module) { + exports("foo", module.default); + }], + execute: (function () { + + + + }) + }; +})); diff --git a/test/chunking-form/samples/generated-code/reserved-names-as-props-true/_expected/system/main2.js b/test/chunking-form/samples/generated-code/reserved-names-as-props-true/_expected/system/main2.js new file mode 100644 index 00000000000..ed15e026d93 --- /dev/null +++ b/test/chunking-form/samples/generated-code/reserved-names-as-props-true/_expected/system/main2.js @@ -0,0 +1,10 @@ +System.register('bundle', [], (function (exports) { + 'use strict'; + return { + execute: (function () { + + var main2 = exports("default", 42); + + }) + }; +})); diff --git a/test/chunking-form/samples/generated-code/reserved-names-as-props-true/main.js b/test/chunking-form/samples/generated-code/reserved-names-as-props-true/main.js new file mode 100644 index 00000000000..5e54d802c29 --- /dev/null +++ b/test/chunking-form/samples/generated-code/reserved-names-as-props-true/main.js @@ -0,0 +1 @@ +export { default as foo } from './main2.js'; diff --git a/test/chunking-form/samples/deprecated/emit-chunk-named/dep.js b/test/chunking-form/samples/generated-code/reserved-names-as-props-true/main2.js similarity index 100% rename from test/chunking-form/samples/deprecated/emit-chunk-named/dep.js rename to test/chunking-form/samples/generated-code/reserved-names-as-props-true/main2.js diff --git a/test/chunking-form/samples/hashing/base-16/_config.js b/test/chunking-form/samples/hashing/base-16/_config.js new file mode 100644 index 00000000000..c5e360e7520 --- /dev/null +++ b/test/chunking-form/samples/hashing/base-16/_config.js @@ -0,0 +1,20 @@ +module.exports = defineTest({ + description: 'supports hex hashes', + options: { + input: ['main1.js', 'main2.js'], + plugins: [ + { + name: 'test', + buildStart() { + this.emitFile({ type: 'asset', name: 'test.txt', source: 'test' }); + } + } + ], + output: { + entryFileNames: ({ name }) => (name === 'main1' ? '[name]-[hash:8].js' : '[name]-[hash].js'), + chunkFileNames: '[name]-[hash:14].js', + assetFileNames: '[name]-[hash:18][extname]', + hashCharacters: 'hex' + } + } +}); diff --git a/test/chunking-form/samples/hashing/base-16/_expected/amd/dep-9748f597e7f841.js b/test/chunking-form/samples/hashing/base-16/_expected/amd/dep-9748f597e7f841.js new file mode 100644 index 00000000000..f94a3d9d9f9 --- /dev/null +++ b/test/chunking-form/samples/hashing/base-16/_expected/amd/dep-9748f597e7f841.js @@ -0,0 +1,5 @@ +define((function () { 'use strict'; + + console.log('dep'); + +})); diff --git a/test/chunking-form/samples/hashing/base-16/_expected/amd/main1-32c81258.js b/test/chunking-form/samples/hashing/base-16/_expected/amd/main1-32c81258.js new file mode 100644 index 00000000000..374fe944661 --- /dev/null +++ b/test/chunking-form/samples/hashing/base-16/_expected/amd/main1-32c81258.js @@ -0,0 +1,5 @@ +define(['./dep-9748f597e7f841'], (function (dep) { 'use strict'; + + console.log('main1'); + +})); diff --git a/test/chunking-form/samples/hashing/base-16/_expected/amd/main2-a297141a.js b/test/chunking-form/samples/hashing/base-16/_expected/amd/main2-a297141a.js new file mode 100644 index 00000000000..bf78a4dec63 --- /dev/null +++ b/test/chunking-form/samples/hashing/base-16/_expected/amd/main2-a297141a.js @@ -0,0 +1,5 @@ +define(['./dep-9748f597e7f841'], (function (dep) { 'use strict'; + + console.log('main2'); + +})); diff --git a/test/chunking-form/samples/hashing/base-16/_expected/amd/test-b85fb84286751ed058.txt b/test/chunking-form/samples/hashing/base-16/_expected/amd/test-b85fb84286751ed058.txt new file mode 100644 index 00000000000..30d74d25844 --- /dev/null +++ b/test/chunking-form/samples/hashing/base-16/_expected/amd/test-b85fb84286751ed058.txt @@ -0,0 +1 @@ +test \ No newline at end of file diff --git a/test/chunking-form/samples/hashing/base-16/_expected/cjs/dep-8e72f6a548dc1a.js b/test/chunking-form/samples/hashing/base-16/_expected/cjs/dep-8e72f6a548dc1a.js new file mode 100644 index 00000000000..f97cbb47032 --- /dev/null +++ b/test/chunking-form/samples/hashing/base-16/_expected/cjs/dep-8e72f6a548dc1a.js @@ -0,0 +1,3 @@ +'use strict'; + +console.log('dep'); diff --git a/test/chunking-form/samples/hashing/base-16/_expected/cjs/main1-10ba0f88.js b/test/chunking-form/samples/hashing/base-16/_expected/cjs/main1-10ba0f88.js new file mode 100644 index 00000000000..46a720ce4f7 --- /dev/null +++ b/test/chunking-form/samples/hashing/base-16/_expected/cjs/main1-10ba0f88.js @@ -0,0 +1,5 @@ +'use strict'; + +require('./dep-8e72f6a548dc1a.js'); + +console.log('main1'); diff --git a/test/chunking-form/samples/hashing/base-16/_expected/cjs/main2-e8d99f43.js b/test/chunking-form/samples/hashing/base-16/_expected/cjs/main2-e8d99f43.js new file mode 100644 index 00000000000..ac7092b32a5 --- /dev/null +++ b/test/chunking-form/samples/hashing/base-16/_expected/cjs/main2-e8d99f43.js @@ -0,0 +1,5 @@ +'use strict'; + +require('./dep-8e72f6a548dc1a.js'); + +console.log('main2'); diff --git a/test/chunking-form/samples/hashing/base-16/_expected/cjs/test-b85fb84286751ed058.txt b/test/chunking-form/samples/hashing/base-16/_expected/cjs/test-b85fb84286751ed058.txt new file mode 100644 index 00000000000..30d74d25844 --- /dev/null +++ b/test/chunking-form/samples/hashing/base-16/_expected/cjs/test-b85fb84286751ed058.txt @@ -0,0 +1 @@ +test \ No newline at end of file diff --git a/test/chunking-form/samples/deprecated/manual-chunk-contains-entry-conflict/dep.js b/test/chunking-form/samples/hashing/base-16/_expected/es/dep-ea4271148a0859.js similarity index 100% rename from test/chunking-form/samples/deprecated/manual-chunk-contains-entry-conflict/dep.js rename to test/chunking-form/samples/hashing/base-16/_expected/es/dep-ea4271148a0859.js diff --git a/test/chunking-form/samples/hashing/base-16/_expected/es/main1-e88c4e75.js b/test/chunking-form/samples/hashing/base-16/_expected/es/main1-e88c4e75.js new file mode 100644 index 00000000000..f1f2c901ac8 --- /dev/null +++ b/test/chunking-form/samples/hashing/base-16/_expected/es/main1-e88c4e75.js @@ -0,0 +1,3 @@ +import './dep-ea4271148a0859.js'; + +console.log('main1'); diff --git a/test/chunking-form/samples/hashing/base-16/_expected/es/main2-11f6fea7.js b/test/chunking-form/samples/hashing/base-16/_expected/es/main2-11f6fea7.js new file mode 100644 index 00000000000..f479817a7b2 --- /dev/null +++ b/test/chunking-form/samples/hashing/base-16/_expected/es/main2-11f6fea7.js @@ -0,0 +1,3 @@ +import './dep-ea4271148a0859.js'; + +console.log('main2'); diff --git a/test/chunking-form/samples/hashing/base-16/_expected/es/test-b85fb84286751ed058.txt b/test/chunking-form/samples/hashing/base-16/_expected/es/test-b85fb84286751ed058.txt new file mode 100644 index 00000000000..30d74d25844 --- /dev/null +++ b/test/chunking-form/samples/hashing/base-16/_expected/es/test-b85fb84286751ed058.txt @@ -0,0 +1 @@ +test \ No newline at end of file diff --git a/test/chunking-form/samples/hashing/base-16/_expected/system/dep-fc1ce55215e47e.js b/test/chunking-form/samples/hashing/base-16/_expected/system/dep-fc1ce55215e47e.js new file mode 100644 index 00000000000..963f20ddf9c --- /dev/null +++ b/test/chunking-form/samples/hashing/base-16/_expected/system/dep-fc1ce55215e47e.js @@ -0,0 +1,10 @@ +System.register([], (function () { + 'use strict'; + return { + execute: (function () { + + console.log('dep'); + + }) + }; +})); diff --git a/test/chunking-form/samples/hashing/base-16/_expected/system/main1-9428b54c.js b/test/chunking-form/samples/hashing/base-16/_expected/system/main1-9428b54c.js new file mode 100644 index 00000000000..1f213fefbb7 --- /dev/null +++ b/test/chunking-form/samples/hashing/base-16/_expected/system/main1-9428b54c.js @@ -0,0 +1,11 @@ +System.register(['./dep-fc1ce55215e47e.js'], (function () { + 'use strict'; + return { + setters: [null], + execute: (function () { + + console.log('main1'); + + }) + }; +})); diff --git a/test/chunking-form/samples/hashing/base-16/_expected/system/main2-bae4f47a.js b/test/chunking-form/samples/hashing/base-16/_expected/system/main2-bae4f47a.js new file mode 100644 index 00000000000..72d74115361 --- /dev/null +++ b/test/chunking-form/samples/hashing/base-16/_expected/system/main2-bae4f47a.js @@ -0,0 +1,11 @@ +System.register(['./dep-fc1ce55215e47e.js'], (function () { + 'use strict'; + return { + setters: [null], + execute: (function () { + + console.log('main2'); + + }) + }; +})); diff --git a/test/chunking-form/samples/hashing/base-16/_expected/system/test-b85fb84286751ed058.txt b/test/chunking-form/samples/hashing/base-16/_expected/system/test-b85fb84286751ed058.txt new file mode 100644 index 00000000000..30d74d25844 --- /dev/null +++ b/test/chunking-form/samples/hashing/base-16/_expected/system/test-b85fb84286751ed058.txt @@ -0,0 +1 @@ +test \ No newline at end of file diff --git a/test/chunking-form/samples/deprecated/manual-chunk-contains-entry-match/dep.js b/test/chunking-form/samples/hashing/base-16/dep.js similarity index 100% rename from test/chunking-form/samples/deprecated/manual-chunk-contains-entry-match/dep.js rename to test/chunking-form/samples/hashing/base-16/dep.js diff --git a/test/chunking-form/samples/hashing/base-16/main1.js b/test/chunking-form/samples/hashing/base-16/main1.js new file mode 100644 index 00000000000..a739b1e23d4 --- /dev/null +++ b/test/chunking-form/samples/hashing/base-16/main1.js @@ -0,0 +1,3 @@ +import "./dep.js"; + +console.log('main1'); diff --git a/test/chunking-form/samples/hashing/base-16/main2.js b/test/chunking-form/samples/hashing/base-16/main2.js new file mode 100644 index 00000000000..03ed51465f8 --- /dev/null +++ b/test/chunking-form/samples/hashing/base-16/main2.js @@ -0,0 +1,3 @@ +import "./dep.js"; + +console.log('main2'); diff --git a/test/chunking-form/samples/hashing/base-36/_config.js b/test/chunking-form/samples/hashing/base-36/_config.js new file mode 100644 index 00000000000..87f4424f07f --- /dev/null +++ b/test/chunking-form/samples/hashing/base-36/_config.js @@ -0,0 +1,20 @@ +module.exports = defineTest({ + description: 'supports base-36 hashes', + options: { + input: ['main1.js', 'main2.js'], + plugins: [ + { + name: 'test', + buildStart() { + this.emitFile({ type: 'asset', name: 'test.txt', source: 'test' }); + } + } + ], + output: { + entryFileNames: ({ name }) => (name === 'main1' ? '[name]-[hash:8].js' : '[name]-[hash].js'), + chunkFileNames: '[name]-[hash:14].js', + assetFileNames: '[name]-[hash:18][extname]', + hashCharacters: 'base36' + } + } +}); diff --git a/test/chunking-form/samples/hashing/base-36/_expected/amd/dep-bmptxkz04onep5.js b/test/chunking-form/samples/hashing/base-36/_expected/amd/dep-bmptxkz04onep5.js new file mode 100644 index 00000000000..f94a3d9d9f9 --- /dev/null +++ b/test/chunking-form/samples/hashing/base-36/_expected/amd/dep-bmptxkz04onep5.js @@ -0,0 +1,5 @@ +define((function () { 'use strict'; + + console.log('dep'); + +})); diff --git a/test/chunking-form/samples/hashing/base-36/_expected/amd/main1-eq1xfkwk.js b/test/chunking-form/samples/hashing/base-36/_expected/amd/main1-eq1xfkwk.js new file mode 100644 index 00000000000..d899df32652 --- /dev/null +++ b/test/chunking-form/samples/hashing/base-36/_expected/amd/main1-eq1xfkwk.js @@ -0,0 +1,5 @@ +define(['./dep-bmptxkz04onep5'], (function (dep) { 'use strict'; + + console.log('main1'); + +})); diff --git a/test/chunking-form/samples/hashing/base-36/_expected/amd/main2-ghsu9bcu.js b/test/chunking-form/samples/hashing/base-36/_expected/amd/main2-ghsu9bcu.js new file mode 100644 index 00000000000..b2d52ed3117 --- /dev/null +++ b/test/chunking-form/samples/hashing/base-36/_expected/amd/main2-ghsu9bcu.js @@ -0,0 +1,5 @@ +define(['./dep-bmptxkz04onep5'], (function (dep) { 'use strict'; + + console.log('main2'); + +})); diff --git a/test/chunking-form/samples/hashing/base-36/_expected/amd/test-k68mbkgbkbej7p9txd.txt b/test/chunking-form/samples/hashing/base-36/_expected/amd/test-k68mbkgbkbej7p9txd.txt new file mode 100644 index 00000000000..30d74d25844 --- /dev/null +++ b/test/chunking-form/samples/hashing/base-36/_expected/amd/test-k68mbkgbkbej7p9txd.txt @@ -0,0 +1 @@ +test \ No newline at end of file diff --git a/test/chunking-form/samples/hashing/base-36/_expected/cjs/dep-ovzp2ykm52qk5e.js b/test/chunking-form/samples/hashing/base-36/_expected/cjs/dep-ovzp2ykm52qk5e.js new file mode 100644 index 00000000000..f97cbb47032 --- /dev/null +++ b/test/chunking-form/samples/hashing/base-36/_expected/cjs/dep-ovzp2ykm52qk5e.js @@ -0,0 +1,3 @@ +'use strict'; + +console.log('dep'); diff --git a/test/chunking-form/samples/hashing/base-36/_expected/cjs/main1-j953dn8u.js b/test/chunking-form/samples/hashing/base-36/_expected/cjs/main1-j953dn8u.js new file mode 100644 index 00000000000..46c9bbec206 --- /dev/null +++ b/test/chunking-form/samples/hashing/base-36/_expected/cjs/main1-j953dn8u.js @@ -0,0 +1,5 @@ +'use strict'; + +require('./dep-ovzp2ykm52qk5e.js'); + +console.log('main1'); diff --git a/test/chunking-form/samples/hashing/base-36/_expected/cjs/main2-m5d1jqhr.js b/test/chunking-form/samples/hashing/base-36/_expected/cjs/main2-m5d1jqhr.js new file mode 100644 index 00000000000..d28a19b76cf --- /dev/null +++ b/test/chunking-form/samples/hashing/base-36/_expected/cjs/main2-m5d1jqhr.js @@ -0,0 +1,5 @@ +'use strict'; + +require('./dep-ovzp2ykm52qk5e.js'); + +console.log('main2'); diff --git a/test/chunking-form/samples/hashing/base-36/_expected/cjs/test-k68mbkgbkbej7p9txd.txt b/test/chunking-form/samples/hashing/base-36/_expected/cjs/test-k68mbkgbkbej7p9txd.txt new file mode 100644 index 00000000000..30d74d25844 --- /dev/null +++ b/test/chunking-form/samples/hashing/base-36/_expected/cjs/test-k68mbkgbkbej7p9txd.txt @@ -0,0 +1 @@ +test \ No newline at end of file diff --git a/test/chunking-form/samples/deprecated/manual-chunk-is-entry-conflict/dep.js b/test/chunking-form/samples/hashing/base-36/_expected/es/dep-fjef7fnh2ag8g7.js similarity index 100% rename from test/chunking-form/samples/deprecated/manual-chunk-is-entry-conflict/dep.js rename to test/chunking-form/samples/hashing/base-36/_expected/es/dep-fjef7fnh2ag8g7.js diff --git a/test/chunking-form/samples/hashing/base-36/_expected/es/main1-mw1pkh6b.js b/test/chunking-form/samples/hashing/base-36/_expected/es/main1-mw1pkh6b.js new file mode 100644 index 00000000000..403e76b13fc --- /dev/null +++ b/test/chunking-form/samples/hashing/base-36/_expected/es/main1-mw1pkh6b.js @@ -0,0 +1,3 @@ +import './dep-fjef7fnh2ag8g7.js'; + +console.log('main1'); diff --git a/test/chunking-form/samples/hashing/base-36/_expected/es/main2-kiy506nw.js b/test/chunking-form/samples/hashing/base-36/_expected/es/main2-kiy506nw.js new file mode 100644 index 00000000000..4fd9a65472f --- /dev/null +++ b/test/chunking-form/samples/hashing/base-36/_expected/es/main2-kiy506nw.js @@ -0,0 +1,3 @@ +import './dep-fjef7fnh2ag8g7.js'; + +console.log('main2'); diff --git a/test/chunking-form/samples/hashing/base-36/_expected/es/test-k68mbkgbkbej7p9txd.txt b/test/chunking-form/samples/hashing/base-36/_expected/es/test-k68mbkgbkbej7p9txd.txt new file mode 100644 index 00000000000..30d74d25844 --- /dev/null +++ b/test/chunking-form/samples/hashing/base-36/_expected/es/test-k68mbkgbkbej7p9txd.txt @@ -0,0 +1 @@ +test \ No newline at end of file diff --git a/test/chunking-form/samples/hashing/base-36/_expected/system/dep-jg0ebpli0vt21p.js b/test/chunking-form/samples/hashing/base-36/_expected/system/dep-jg0ebpli0vt21p.js new file mode 100644 index 00000000000..963f20ddf9c --- /dev/null +++ b/test/chunking-form/samples/hashing/base-36/_expected/system/dep-jg0ebpli0vt21p.js @@ -0,0 +1,10 @@ +System.register([], (function () { + 'use strict'; + return { + execute: (function () { + + console.log('dep'); + + }) + }; +})); diff --git a/test/chunking-form/samples/hashing/base-36/_expected/system/main1-mrx14iyi.js b/test/chunking-form/samples/hashing/base-36/_expected/system/main1-mrx14iyi.js new file mode 100644 index 00000000000..a31beba92d6 --- /dev/null +++ b/test/chunking-form/samples/hashing/base-36/_expected/system/main1-mrx14iyi.js @@ -0,0 +1,11 @@ +System.register(['./dep-jg0ebpli0vt21p.js'], (function () { + 'use strict'; + return { + setters: [null], + execute: (function () { + + console.log('main1'); + + }) + }; +})); diff --git a/test/chunking-form/samples/hashing/base-36/_expected/system/main2-mqk8gped.js b/test/chunking-form/samples/hashing/base-36/_expected/system/main2-mqk8gped.js new file mode 100644 index 00000000000..9673e24f1b5 --- /dev/null +++ b/test/chunking-form/samples/hashing/base-36/_expected/system/main2-mqk8gped.js @@ -0,0 +1,11 @@ +System.register(['./dep-jg0ebpli0vt21p.js'], (function () { + 'use strict'; + return { + setters: [null], + execute: (function () { + + console.log('main2'); + + }) + }; +})); diff --git a/test/chunking-form/samples/hashing/base-36/_expected/system/test-k68mbkgbkbej7p9txd.txt b/test/chunking-form/samples/hashing/base-36/_expected/system/test-k68mbkgbkbej7p9txd.txt new file mode 100644 index 00000000000..30d74d25844 --- /dev/null +++ b/test/chunking-form/samples/hashing/base-36/_expected/system/test-k68mbkgbkbej7p9txd.txt @@ -0,0 +1 @@ +test \ No newline at end of file diff --git a/test/chunking-form/samples/deprecated/manual-chunk-is-entry-match/dep.js b/test/chunking-form/samples/hashing/base-36/dep.js similarity index 100% rename from test/chunking-form/samples/deprecated/manual-chunk-is-entry-match/dep.js rename to test/chunking-form/samples/hashing/base-36/dep.js diff --git a/test/chunking-form/samples/hashing/base-36/main1.js b/test/chunking-form/samples/hashing/base-36/main1.js new file mode 100644 index 00000000000..a739b1e23d4 --- /dev/null +++ b/test/chunking-form/samples/hashing/base-36/main1.js @@ -0,0 +1,3 @@ +import "./dep.js"; + +console.log('main1'); diff --git a/test/chunking-form/samples/hashing/base-36/main2.js b/test/chunking-form/samples/hashing/base-36/main2.js new file mode 100644 index 00000000000..03ed51465f8 --- /dev/null +++ b/test/chunking-form/samples/hashing/base-36/main2.js @@ -0,0 +1,3 @@ +import "./dep.js"; + +console.log('main2'); diff --git a/test/chunking-form/samples/hashing/base-64/_config.js b/test/chunking-form/samples/hashing/base-64/_config.js new file mode 100644 index 00000000000..42855288946 --- /dev/null +++ b/test/chunking-form/samples/hashing/base-64/_config.js @@ -0,0 +1,20 @@ +module.exports = defineTest({ + description: 'supports base-64 hashes', + options: { + input: ['main1.js', 'main2.js'], + plugins: [ + { + name: 'test', + buildStart() { + this.emitFile({ type: 'asset', name: 'test.txt', source: 'test' }); + } + } + ], + output: { + entryFileNames: ({ name }) => (name === 'main1' ? '[name]-[hash:8].js' : '[name]-[hash].js'), + chunkFileNames: '[name]-[hash:14].js', + assetFileNames: '[name]-[hash:18][extname]', + hashCharacters: 'base64' + } + } +}); diff --git a/test/chunking-form/samples/hashing/base-64/_expected/amd/dep-CQnwizGk7iiKyM.js b/test/chunking-form/samples/hashing/base-64/_expected/amd/dep-CQnwizGk7iiKyM.js new file mode 100644 index 00000000000..f94a3d9d9f9 --- /dev/null +++ b/test/chunking-form/samples/hashing/base-64/_expected/amd/dep-CQnwizGk7iiKyM.js @@ -0,0 +1,5 @@ +define((function () { 'use strict'; + + console.log('dep'); + +})); diff --git a/test/chunking-form/samples/hashing/base-64/_expected/amd/main1-DmCo11bz.js b/test/chunking-form/samples/hashing/base-64/_expected/amd/main1-DmCo11bz.js new file mode 100644 index 00000000000..9ec489eda38 --- /dev/null +++ b/test/chunking-form/samples/hashing/base-64/_expected/amd/main1-DmCo11bz.js @@ -0,0 +1,5 @@ +define(['./dep-CQnwizGk7iiKyM'], (function (dep) { 'use strict'; + + console.log('main1'); + +})); diff --git a/test/chunking-form/samples/hashing/base-64/_expected/amd/main2-plMRg5wo.js b/test/chunking-form/samples/hashing/base-64/_expected/amd/main2-plMRg5wo.js new file mode 100644 index 00000000000..682a4f9fcf7 --- /dev/null +++ b/test/chunking-form/samples/hashing/base-64/_expected/amd/main2-plMRg5wo.js @@ -0,0 +1,5 @@ +define(['./dep-CQnwizGk7iiKyM'], (function (dep) { 'use strict'; + + console.log('main2'); + +})); diff --git a/test/chunking-form/samples/hashing/base-64/_expected/amd/test-C4X7hChnUe0FjTUb3j.txt b/test/chunking-form/samples/hashing/base-64/_expected/amd/test-C4X7hChnUe0FjTUb3j.txt new file mode 100644 index 00000000000..30d74d25844 --- /dev/null +++ b/test/chunking-form/samples/hashing/base-64/_expected/amd/test-C4X7hChnUe0FjTUb3j.txt @@ -0,0 +1 @@ +test \ No newline at end of file diff --git a/test/chunking-form/samples/hashing/base-64/_expected/cjs/dep-DP3g5uf-_SXPa0.js b/test/chunking-form/samples/hashing/base-64/_expected/cjs/dep-DP3g5uf-_SXPa0.js new file mode 100644 index 00000000000..f97cbb47032 --- /dev/null +++ b/test/chunking-form/samples/hashing/base-64/_expected/cjs/dep-DP3g5uf-_SXPa0.js @@ -0,0 +1,3 @@ +'use strict'; + +console.log('dep'); diff --git a/test/chunking-form/samples/hashing/base-64/_expected/cjs/main1-DnXXnXwB.js b/test/chunking-form/samples/hashing/base-64/_expected/cjs/main1-DnXXnXwB.js new file mode 100644 index 00000000000..b2cd34a4bf1 --- /dev/null +++ b/test/chunking-form/samples/hashing/base-64/_expected/cjs/main1-DnXXnXwB.js @@ -0,0 +1,5 @@ +'use strict'; + +require('./dep-DP3g5uf-_SXPa0.js'); + +console.log('main1'); diff --git a/test/chunking-form/samples/hashing/base-64/_expected/cjs/main2-gxHln_2b.js b/test/chunking-form/samples/hashing/base-64/_expected/cjs/main2-gxHln_2b.js new file mode 100644 index 00000000000..fb9aceedd15 --- /dev/null +++ b/test/chunking-form/samples/hashing/base-64/_expected/cjs/main2-gxHln_2b.js @@ -0,0 +1,5 @@ +'use strict'; + +require('./dep-DP3g5uf-_SXPa0.js'); + +console.log('main2'); diff --git a/test/chunking-form/samples/hashing/base-64/_expected/cjs/test-C4X7hChnUe0FjTUb3j.txt b/test/chunking-form/samples/hashing/base-64/_expected/cjs/test-C4X7hChnUe0FjTUb3j.txt new file mode 100644 index 00000000000..30d74d25844 --- /dev/null +++ b/test/chunking-form/samples/hashing/base-64/_expected/cjs/test-C4X7hChnUe0FjTUb3j.txt @@ -0,0 +1 @@ +test \ No newline at end of file diff --git a/test/function/samples/deprecated/manual-chunks-conflict/dep.js b/test/chunking-form/samples/hashing/base-64/_expected/es/dep-Bjk1mBEz6TLC2O.js similarity index 100% rename from test/function/samples/deprecated/manual-chunks-conflict/dep.js rename to test/chunking-form/samples/hashing/base-64/_expected/es/dep-Bjk1mBEz6TLC2O.js diff --git a/test/chunking-form/samples/hashing/base-64/_expected/es/main1-CFYv4LMw.js b/test/chunking-form/samples/hashing/base-64/_expected/es/main1-CFYv4LMw.js new file mode 100644 index 00000000000..04e05fdcdf0 --- /dev/null +++ b/test/chunking-form/samples/hashing/base-64/_expected/es/main1-CFYv4LMw.js @@ -0,0 +1,3 @@ +import './dep-Bjk1mBEz6TLC2O.js'; + +console.log('main1'); diff --git a/test/chunking-form/samples/hashing/base-64/_expected/es/main2-DZLiRzpS.js b/test/chunking-form/samples/hashing/base-64/_expected/es/main2-DZLiRzpS.js new file mode 100644 index 00000000000..9c7b5a2ee4a --- /dev/null +++ b/test/chunking-form/samples/hashing/base-64/_expected/es/main2-DZLiRzpS.js @@ -0,0 +1,3 @@ +import './dep-Bjk1mBEz6TLC2O.js'; + +console.log('main2'); diff --git a/test/chunking-form/samples/hashing/base-64/_expected/es/test-C4X7hChnUe0FjTUb3j.txt b/test/chunking-form/samples/hashing/base-64/_expected/es/test-C4X7hChnUe0FjTUb3j.txt new file mode 100644 index 00000000000..30d74d25844 --- /dev/null +++ b/test/chunking-form/samples/hashing/base-64/_expected/es/test-C4X7hChnUe0FjTUb3j.txt @@ -0,0 +1 @@ +test \ No newline at end of file diff --git a/test/chunking-form/samples/hashing/base-64/_expected/system/dep-58OVQdrHioalt3.js b/test/chunking-form/samples/hashing/base-64/_expected/system/dep-58OVQdrHioalt3.js new file mode 100644 index 00000000000..963f20ddf9c --- /dev/null +++ b/test/chunking-form/samples/hashing/base-64/_expected/system/dep-58OVQdrHioalt3.js @@ -0,0 +1,10 @@ +System.register([], (function () { + 'use strict'; + return { + execute: (function () { + + console.log('dep'); + + }) + }; +})); diff --git a/test/chunking-form/samples/hashing/base-64/_expected/system/main1-D6XIOQ-3.js b/test/chunking-form/samples/hashing/base-64/_expected/system/main1-D6XIOQ-3.js new file mode 100644 index 00000000000..21217f80b41 --- /dev/null +++ b/test/chunking-form/samples/hashing/base-64/_expected/system/main1-D6XIOQ-3.js @@ -0,0 +1,11 @@ +System.register(['./dep-58OVQdrHioalt3.js'], (function () { + 'use strict'; + return { + setters: [null], + execute: (function () { + + console.log('main1'); + + }) + }; +})); diff --git a/test/chunking-form/samples/hashing/base-64/_expected/system/main2-DvH4my1X.js b/test/chunking-form/samples/hashing/base-64/_expected/system/main2-DvH4my1X.js new file mode 100644 index 00000000000..b785b3cac45 --- /dev/null +++ b/test/chunking-form/samples/hashing/base-64/_expected/system/main2-DvH4my1X.js @@ -0,0 +1,11 @@ +System.register(['./dep-58OVQdrHioalt3.js'], (function () { + 'use strict'; + return { + setters: [null], + execute: (function () { + + console.log('main2'); + + }) + }; +})); diff --git a/test/chunking-form/samples/hashing/base-64/_expected/system/test-C4X7hChnUe0FjTUb3j.txt b/test/chunking-form/samples/hashing/base-64/_expected/system/test-C4X7hChnUe0FjTUb3j.txt new file mode 100644 index 00000000000..30d74d25844 --- /dev/null +++ b/test/chunking-form/samples/hashing/base-64/_expected/system/test-C4X7hChnUe0FjTUb3j.txt @@ -0,0 +1 @@ +test \ No newline at end of file diff --git a/test/chunking-form/samples/hashing/base-64/dep.js b/test/chunking-form/samples/hashing/base-64/dep.js new file mode 100644 index 00000000000..b74a9837c07 --- /dev/null +++ b/test/chunking-form/samples/hashing/base-64/dep.js @@ -0,0 +1 @@ +console.log('dep'); diff --git a/test/chunking-form/samples/hashing/base-64/main1.js b/test/chunking-form/samples/hashing/base-64/main1.js new file mode 100644 index 00000000000..a739b1e23d4 --- /dev/null +++ b/test/chunking-form/samples/hashing/base-64/main1.js @@ -0,0 +1,3 @@ +import "./dep.js"; + +console.log('main1'); diff --git a/test/chunking-form/samples/hashing/base-64/main2.js b/test/chunking-form/samples/hashing/base-64/main2.js new file mode 100644 index 00000000000..03ed51465f8 --- /dev/null +++ b/test/chunking-form/samples/hashing/base-64/main2.js @@ -0,0 +1,3 @@ +import "./dep.js"; + +console.log('main2'); diff --git a/test/chunking-form/samples/hashing/deconflict-hashes/_config.js b/test/chunking-form/samples/hashing/deconflict-hashes/_config.js new file mode 100644 index 00000000000..3cd6ea4cd3a --- /dev/null +++ b/test/chunking-form/samples/hashing/deconflict-hashes/_config.js @@ -0,0 +1,7 @@ +module.exports = defineTest({ + description: 'deduplicates hashes for identical files', + options: { + input: ['main1', 'main2'], + output: { entryFileNames: 'entry-[hash].js' } + } +}); diff --git a/test/chunking-form/samples/hashing/deconflict-hashes/_expected/amd/entry-DKQbg3Wf.js b/test/chunking-form/samples/hashing/deconflict-hashes/_expected/amd/entry-DKQbg3Wf.js new file mode 100644 index 00000000000..49540b44d78 --- /dev/null +++ b/test/chunking-form/samples/hashing/deconflict-hashes/_expected/amd/entry-DKQbg3Wf.js @@ -0,0 +1,5 @@ +define((function () { 'use strict'; + + console.log('main'); + +})); diff --git a/test/chunking-form/samples/hashing/deconflict-hashes/_expected/amd/entry-GCBTgmAv.js b/test/chunking-form/samples/hashing/deconflict-hashes/_expected/amd/entry-GCBTgmAv.js new file mode 100644 index 00000000000..49540b44d78 --- /dev/null +++ b/test/chunking-form/samples/hashing/deconflict-hashes/_expected/amd/entry-GCBTgmAv.js @@ -0,0 +1,5 @@ +define((function () { 'use strict'; + + console.log('main'); + +})); diff --git a/test/form/samples/deprecated/inlined-treeshaken-dynamic-import/_expected/cjs.js b/test/chunking-form/samples/hashing/deconflict-hashes/_expected/cjs/entry-CfHQ99Wd.js similarity index 100% rename from test/form/samples/deprecated/inlined-treeshaken-dynamic-import/_expected/cjs.js rename to test/chunking-form/samples/hashing/deconflict-hashes/_expected/cjs/entry-CfHQ99Wd.js diff --git a/test/chunking-form/samples/hashing/deconflict-hashes/_expected/cjs/entry-DCMVlR3X.js b/test/chunking-form/samples/hashing/deconflict-hashes/_expected/cjs/entry-DCMVlR3X.js new file mode 100644 index 00000000000..d0ed06d8c90 --- /dev/null +++ b/test/chunking-form/samples/hashing/deconflict-hashes/_expected/cjs/entry-DCMVlR3X.js @@ -0,0 +1,3 @@ +'use strict'; + +console.log('main'); diff --git a/test/form/samples/deprecated/emit-asset-hacky/_expected/es.js b/test/chunking-form/samples/hashing/deconflict-hashes/_expected/es/entry-BIjZ-t_L.js similarity index 100% rename from test/form/samples/deprecated/emit-asset-hacky/_expected/es.js rename to test/chunking-form/samples/hashing/deconflict-hashes/_expected/es/entry-BIjZ-t_L.js diff --git a/test/form/samples/deprecated/inlined-treeshaken-dynamic-import/_expected/es.js b/test/chunking-form/samples/hashing/deconflict-hashes/_expected/es/entry-BbWhrgmr.js similarity index 100% rename from test/form/samples/deprecated/inlined-treeshaken-dynamic-import/_expected/es.js rename to test/chunking-form/samples/hashing/deconflict-hashes/_expected/es/entry-BbWhrgmr.js diff --git a/test/chunking-form/samples/hashing/deconflict-hashes/_expected/system/entry-5NcCWKKj.js b/test/chunking-form/samples/hashing/deconflict-hashes/_expected/system/entry-5NcCWKKj.js new file mode 100644 index 00000000000..35e2693371a --- /dev/null +++ b/test/chunking-form/samples/hashing/deconflict-hashes/_expected/system/entry-5NcCWKKj.js @@ -0,0 +1,10 @@ +System.register([], (function () { + 'use strict'; + return { + execute: (function () { + + console.log('main'); + + }) + }; +})); diff --git a/test/chunking-form/samples/hashing/deconflict-hashes/_expected/system/entry-Co4GckLL.js b/test/chunking-form/samples/hashing/deconflict-hashes/_expected/system/entry-Co4GckLL.js new file mode 100644 index 00000000000..35e2693371a --- /dev/null +++ b/test/chunking-form/samples/hashing/deconflict-hashes/_expected/system/entry-Co4GckLL.js @@ -0,0 +1,10 @@ +System.register([], (function () { + 'use strict'; + return { + execute: (function () { + + console.log('main'); + + }) + }; +})); diff --git a/test/function/samples/deprecated/emit-chunk/chunk-filename-not-available/main.js b/test/chunking-form/samples/hashing/deconflict-hashes/main1.js similarity index 100% rename from test/function/samples/deprecated/emit-chunk/chunk-filename-not-available/main.js rename to test/chunking-form/samples/hashing/deconflict-hashes/main1.js diff --git a/test/function/samples/deprecated/emit-chunk/chunk-not-found/main.js b/test/chunking-form/samples/hashing/deconflict-hashes/main2.js similarity index 100% rename from test/function/samples/deprecated/emit-chunk/chunk-not-found/main.js rename to test/chunking-form/samples/hashing/deconflict-hashes/main2.js diff --git a/test/chunking-form/samples/hashing/double-hash/_config.js b/test/chunking-form/samples/hashing/double-hash/_config.js new file mode 100644 index 00000000000..a024fbf94eb --- /dev/null +++ b/test/chunking-form/samples/hashing/double-hash/_config.js @@ -0,0 +1,6 @@ +module.exports = defineTest({ + description: 'supports double hashes in patterns', + options: { + output: { entryFileNames: '[hash]/entry-[hash].js' } + } +}); diff --git a/test/chunking-form/samples/hashing/double-hash/_expected/amd/GCBTgmAv/entry-GCBTgmAv.js b/test/chunking-form/samples/hashing/double-hash/_expected/amd/GCBTgmAv/entry-GCBTgmAv.js new file mode 100644 index 00000000000..49540b44d78 --- /dev/null +++ b/test/chunking-form/samples/hashing/double-hash/_expected/amd/GCBTgmAv/entry-GCBTgmAv.js @@ -0,0 +1,5 @@ +define((function () { 'use strict'; + + console.log('main'); + +})); diff --git a/test/chunking-form/samples/hashing/double-hash/_expected/cjs/DCMVlR3X/entry-DCMVlR3X.js b/test/chunking-form/samples/hashing/double-hash/_expected/cjs/DCMVlR3X/entry-DCMVlR3X.js new file mode 100644 index 00000000000..d0ed06d8c90 --- /dev/null +++ b/test/chunking-form/samples/hashing/double-hash/_expected/cjs/DCMVlR3X/entry-DCMVlR3X.js @@ -0,0 +1,3 @@ +'use strict'; + +console.log('main'); diff --git a/test/function/samples/deprecated/emit-chunk/modules-loaded/main.js b/test/chunking-form/samples/hashing/double-hash/_expected/es/BIjZ-t_L/entry-BIjZ-t_L.js similarity index 100% rename from test/function/samples/deprecated/emit-chunk/modules-loaded/main.js rename to test/chunking-form/samples/hashing/double-hash/_expected/es/BIjZ-t_L/entry-BIjZ-t_L.js diff --git a/test/chunking-form/samples/hashing/double-hash/_expected/system/Co4GckLL/entry-Co4GckLL.js b/test/chunking-form/samples/hashing/double-hash/_expected/system/Co4GckLL/entry-Co4GckLL.js new file mode 100644 index 00000000000..35e2693371a --- /dev/null +++ b/test/chunking-form/samples/hashing/double-hash/_expected/system/Co4GckLL/entry-Co4GckLL.js @@ -0,0 +1,10 @@ +System.register([], (function () { + 'use strict'; + return { + execute: (function () { + + console.log('main'); + + }) + }; +})); diff --git a/test/chunking-form/samples/hashing/double-hash/main.js b/test/chunking-form/samples/hashing/double-hash/main.js new file mode 100644 index 00000000000..c0b933d7b56 --- /dev/null +++ b/test/chunking-form/samples/hashing/double-hash/main.js @@ -0,0 +1 @@ +console.log('main'); diff --git a/test/chunking-form/samples/hashing/hash-size/_config.js b/test/chunking-form/samples/hashing/hash-size/_config.js new file mode 100644 index 00000000000..0986b663bc4 --- /dev/null +++ b/test/chunking-form/samples/hashing/hash-size/_config.js @@ -0,0 +1,20 @@ +module.exports = defineTest({ + description: 'allows configurable hash size', + options: { + input: ['main1.js', 'main2.js'], + plugins: [ + { + name: 'test', + buildStart() { + this.emitFile({ type: 'asset', name: 'test.txt', source: 'test' }); + } + } + ], + output: { + entryFileNames: ({ name }) => + name === 'main1' ? '[name]-[hash:8].js' : '[name]-[hash:10].js', + chunkFileNames: '[name]-[hash:14].js', + assetFileNames: '[name]-[hash:22][extname]' + } + } +}); diff --git a/test/chunking-form/samples/hashing/hash-size/_expected/amd/dep-CQnwizGk7iiKyM.js b/test/chunking-form/samples/hashing/hash-size/_expected/amd/dep-CQnwizGk7iiKyM.js new file mode 100644 index 00000000000..f94a3d9d9f9 --- /dev/null +++ b/test/chunking-form/samples/hashing/hash-size/_expected/amd/dep-CQnwizGk7iiKyM.js @@ -0,0 +1,5 @@ +define((function () { 'use strict'; + + console.log('dep'); + +})); diff --git a/test/chunking-form/samples/hashing/hash-size/_expected/amd/main1-DmCo11bz.js b/test/chunking-form/samples/hashing/hash-size/_expected/amd/main1-DmCo11bz.js new file mode 100644 index 00000000000..9ec489eda38 --- /dev/null +++ b/test/chunking-form/samples/hashing/hash-size/_expected/amd/main1-DmCo11bz.js @@ -0,0 +1,5 @@ +define(['./dep-CQnwizGk7iiKyM'], (function (dep) { 'use strict'; + + console.log('main1'); + +})); diff --git a/test/chunking-form/samples/hashing/hash-size/_expected/amd/main2-plMRg5woLM.js b/test/chunking-form/samples/hashing/hash-size/_expected/amd/main2-plMRg5woLM.js new file mode 100644 index 00000000000..682a4f9fcf7 --- /dev/null +++ b/test/chunking-form/samples/hashing/hash-size/_expected/amd/main2-plMRg5woLM.js @@ -0,0 +1,5 @@ +define(['./dep-CQnwizGk7iiKyM'], (function (dep) { 'use strict'; + + console.log('main2'); + +})); diff --git a/test/chunking-form/samples/hashing/hash-size/_expected/amd/test-C4X7hChnUe0FjTUb3j4Hh.txt b/test/chunking-form/samples/hashing/hash-size/_expected/amd/test-C4X7hChnUe0FjTUb3j4Hh.txt new file mode 100644 index 00000000000..30d74d25844 --- /dev/null +++ b/test/chunking-form/samples/hashing/hash-size/_expected/amd/test-C4X7hChnUe0FjTUb3j4Hh.txt @@ -0,0 +1 @@ +test \ No newline at end of file diff --git a/test/chunking-form/samples/hashing/hash-size/_expected/cjs/dep-DP3g5uf-_SXPa0.js b/test/chunking-form/samples/hashing/hash-size/_expected/cjs/dep-DP3g5uf-_SXPa0.js new file mode 100644 index 00000000000..f97cbb47032 --- /dev/null +++ b/test/chunking-form/samples/hashing/hash-size/_expected/cjs/dep-DP3g5uf-_SXPa0.js @@ -0,0 +1,3 @@ +'use strict'; + +console.log('dep'); diff --git a/test/chunking-form/samples/hashing/hash-size/_expected/cjs/main1-DnXXnXwB.js b/test/chunking-form/samples/hashing/hash-size/_expected/cjs/main1-DnXXnXwB.js new file mode 100644 index 00000000000..b2cd34a4bf1 --- /dev/null +++ b/test/chunking-form/samples/hashing/hash-size/_expected/cjs/main1-DnXXnXwB.js @@ -0,0 +1,5 @@ +'use strict'; + +require('./dep-DP3g5uf-_SXPa0.js'); + +console.log('main1'); diff --git a/test/chunking-form/samples/hashing/hash-size/_expected/cjs/main2-gxHln_2big.js b/test/chunking-form/samples/hashing/hash-size/_expected/cjs/main2-gxHln_2big.js new file mode 100644 index 00000000000..fb9aceedd15 --- /dev/null +++ b/test/chunking-form/samples/hashing/hash-size/_expected/cjs/main2-gxHln_2big.js @@ -0,0 +1,5 @@ +'use strict'; + +require('./dep-DP3g5uf-_SXPa0.js'); + +console.log('main2'); diff --git a/test/chunking-form/samples/hashing/hash-size/_expected/cjs/test-C4X7hChnUe0FjTUb3j4Hh.txt b/test/chunking-form/samples/hashing/hash-size/_expected/cjs/test-C4X7hChnUe0FjTUb3j4Hh.txt new file mode 100644 index 00000000000..30d74d25844 --- /dev/null +++ b/test/chunking-form/samples/hashing/hash-size/_expected/cjs/test-C4X7hChnUe0FjTUb3j4Hh.txt @@ -0,0 +1 @@ +test \ No newline at end of file diff --git a/test/chunking-form/samples/hashing/hash-size/_expected/es/dep-Bjk1mBEz6TLC2O.js b/test/chunking-form/samples/hashing/hash-size/_expected/es/dep-Bjk1mBEz6TLC2O.js new file mode 100644 index 00000000000..b74a9837c07 --- /dev/null +++ b/test/chunking-form/samples/hashing/hash-size/_expected/es/dep-Bjk1mBEz6TLC2O.js @@ -0,0 +1 @@ +console.log('dep'); diff --git a/test/chunking-form/samples/hashing/hash-size/_expected/es/main1-CFYv4LMw.js b/test/chunking-form/samples/hashing/hash-size/_expected/es/main1-CFYv4LMw.js new file mode 100644 index 00000000000..04e05fdcdf0 --- /dev/null +++ b/test/chunking-form/samples/hashing/hash-size/_expected/es/main1-CFYv4LMw.js @@ -0,0 +1,3 @@ +import './dep-Bjk1mBEz6TLC2O.js'; + +console.log('main1'); diff --git a/test/chunking-form/samples/hashing/hash-size/_expected/es/main2-DZLiRzpSAF.js b/test/chunking-form/samples/hashing/hash-size/_expected/es/main2-DZLiRzpSAF.js new file mode 100644 index 00000000000..9c7b5a2ee4a --- /dev/null +++ b/test/chunking-form/samples/hashing/hash-size/_expected/es/main2-DZLiRzpSAF.js @@ -0,0 +1,3 @@ +import './dep-Bjk1mBEz6TLC2O.js'; + +console.log('main2'); diff --git a/test/chunking-form/samples/hashing/hash-size/_expected/es/test-C4X7hChnUe0FjTUb3j4Hh.txt b/test/chunking-form/samples/hashing/hash-size/_expected/es/test-C4X7hChnUe0FjTUb3j4Hh.txt new file mode 100644 index 00000000000..30d74d25844 --- /dev/null +++ b/test/chunking-form/samples/hashing/hash-size/_expected/es/test-C4X7hChnUe0FjTUb3j4Hh.txt @@ -0,0 +1 @@ +test \ No newline at end of file diff --git a/test/chunking-form/samples/hashing/hash-size/_expected/system/dep-58OVQdrHioalt3.js b/test/chunking-form/samples/hashing/hash-size/_expected/system/dep-58OVQdrHioalt3.js new file mode 100644 index 00000000000..963f20ddf9c --- /dev/null +++ b/test/chunking-form/samples/hashing/hash-size/_expected/system/dep-58OVQdrHioalt3.js @@ -0,0 +1,10 @@ +System.register([], (function () { + 'use strict'; + return { + execute: (function () { + + console.log('dep'); + + }) + }; +})); diff --git a/test/chunking-form/samples/hashing/hash-size/_expected/system/main1-D6XIOQ-3.js b/test/chunking-form/samples/hashing/hash-size/_expected/system/main1-D6XIOQ-3.js new file mode 100644 index 00000000000..21217f80b41 --- /dev/null +++ b/test/chunking-form/samples/hashing/hash-size/_expected/system/main1-D6XIOQ-3.js @@ -0,0 +1,11 @@ +System.register(['./dep-58OVQdrHioalt3.js'], (function () { + 'use strict'; + return { + setters: [null], + execute: (function () { + + console.log('main1'); + + }) + }; +})); diff --git a/test/chunking-form/samples/hashing/hash-size/_expected/system/main2-DvH4my1XU3.js b/test/chunking-form/samples/hashing/hash-size/_expected/system/main2-DvH4my1XU3.js new file mode 100644 index 00000000000..b785b3cac45 --- /dev/null +++ b/test/chunking-form/samples/hashing/hash-size/_expected/system/main2-DvH4my1XU3.js @@ -0,0 +1,11 @@ +System.register(['./dep-58OVQdrHioalt3.js'], (function () { + 'use strict'; + return { + setters: [null], + execute: (function () { + + console.log('main2'); + + }) + }; +})); diff --git a/test/chunking-form/samples/hashing/hash-size/_expected/system/test-C4X7hChnUe0FjTUb3j4Hh.txt b/test/chunking-form/samples/hashing/hash-size/_expected/system/test-C4X7hChnUe0FjTUb3j4Hh.txt new file mode 100644 index 00000000000..30d74d25844 --- /dev/null +++ b/test/chunking-form/samples/hashing/hash-size/_expected/system/test-C4X7hChnUe0FjTUb3j4Hh.txt @@ -0,0 +1 @@ +test \ No newline at end of file diff --git a/test/chunking-form/samples/hashing/hash-size/dep.js b/test/chunking-form/samples/hashing/hash-size/dep.js new file mode 100644 index 00000000000..b74a9837c07 --- /dev/null +++ b/test/chunking-form/samples/hashing/hash-size/dep.js @@ -0,0 +1 @@ +console.log('dep'); diff --git a/test/chunking-form/samples/hashing/hash-size/main1.js b/test/chunking-form/samples/hashing/hash-size/main1.js new file mode 100644 index 00000000000..a739b1e23d4 --- /dev/null +++ b/test/chunking-form/samples/hashing/hash-size/main1.js @@ -0,0 +1,3 @@ +import "./dep.js"; + +console.log('main1'); diff --git a/test/chunking-form/samples/hashing/hash-size/main2.js b/test/chunking-form/samples/hashing/hash-size/main2.js new file mode 100644 index 00000000000..03ed51465f8 --- /dev/null +++ b/test/chunking-form/samples/hashing/hash-size/main2.js @@ -0,0 +1,3 @@ +import "./dep.js"; + +console.log('main2'); diff --git a/test/chunking-form/samples/hashing/random-match/_config.js b/test/chunking-form/samples/hashing/random-match/_config.js new file mode 100644 index 00000000000..e17d7df99e0 --- /dev/null +++ b/test/chunking-form/samples/hashing/random-match/_config.js @@ -0,0 +1,8 @@ +module.exports = defineTest({ + description: 'leaves random hash matches untransformed', + options: { + output: { + entryFileNames: 'entry-[hash]-!~{001}~-!~{123}~.js' + } + } +}); diff --git a/test/chunking-form/samples/hashing/random-match/_expected/amd/entry-sQD11LPz-sQD11LPz-!~{123}~.js b/test/chunking-form/samples/hashing/random-match/_expected/amd/entry-sQD11LPz-sQD11LPz-!~{123}~.js new file mode 100644 index 00000000000..675b5e87805 --- /dev/null +++ b/test/chunking-form/samples/hashing/random-match/_expected/amd/entry-sQD11LPz-sQD11LPz-!~{123}~.js @@ -0,0 +1,6 @@ +define((function () { 'use strict'; + + console.log('replaced: sQD11LPz'); + console.log('not replaced: !~{123}~'); + +})); diff --git a/test/chunking-form/samples/hashing/random-match/_expected/cjs/entry-BZIkp09S-BZIkp09S-!~{123}~.js b/test/chunking-form/samples/hashing/random-match/_expected/cjs/entry-BZIkp09S-BZIkp09S-!~{123}~.js new file mode 100644 index 00000000000..93865c6bb2b --- /dev/null +++ b/test/chunking-form/samples/hashing/random-match/_expected/cjs/entry-BZIkp09S-BZIkp09S-!~{123}~.js @@ -0,0 +1,4 @@ +'use strict'; + +console.log('replaced: BZIkp09S'); +console.log('not replaced: !~{123}~'); diff --git a/test/chunking-form/samples/hashing/random-match/_expected/es/entry-BVS-XKSP-BVS-XKSP-!~{123}~.js b/test/chunking-form/samples/hashing/random-match/_expected/es/entry-BVS-XKSP-BVS-XKSP-!~{123}~.js new file mode 100644 index 00000000000..e66804aeaa1 --- /dev/null +++ b/test/chunking-form/samples/hashing/random-match/_expected/es/entry-BVS-XKSP-BVS-XKSP-!~{123}~.js @@ -0,0 +1,2 @@ +console.log('replaced: BVS-XKSP'); +console.log('not replaced: !~{123}~'); diff --git a/test/chunking-form/samples/hashing/random-match/_expected/system/entry-BIeoZmJB-BIeoZmJB-!~{123}~.js b/test/chunking-form/samples/hashing/random-match/_expected/system/entry-BIeoZmJB-BIeoZmJB-!~{123}~.js new file mode 100644 index 00000000000..8e640e24e9c --- /dev/null +++ b/test/chunking-form/samples/hashing/random-match/_expected/system/entry-BIeoZmJB-BIeoZmJB-!~{123}~.js @@ -0,0 +1,11 @@ +System.register([], (function () { + 'use strict'; + return { + execute: (function () { + + console.log('replaced: BIeoZmJB'); + console.log('not replaced: !~{123}~'); + + }) + }; +})); diff --git a/test/chunking-form/samples/hashing/random-match/main.js b/test/chunking-form/samples/hashing/random-match/main.js new file mode 100644 index 00000000000..21de10d404e --- /dev/null +++ b/test/chunking-form/samples/hashing/random-match/main.js @@ -0,0 +1,2 @@ +console.log('replaced: !~{001}~'); +console.log('not replaced: !~{123}~'); diff --git a/test/chunking-form/samples/hashing/tree-shaken-dynamic-hash/_config.js b/test/chunking-form/samples/hashing/tree-shaken-dynamic-hash/_config.js new file mode 100644 index 00000000000..6a90c90a03a --- /dev/null +++ b/test/chunking-form/samples/hashing/tree-shaken-dynamic-hash/_config.js @@ -0,0 +1,10 @@ +module.exports = defineTest({ + description: + 'Does not fail when calculating the hash of a file containing a tree-shaken dynamic import', + options: { + input: ['main.js'], + output: { + entryFileNames: '[hash].js' + } + } +}); diff --git a/test/chunking-form/samples/hashing/tree-shaken-dynamic-hash/_expected/amd/B0TueUNf.js b/test/chunking-form/samples/hashing/tree-shaken-dynamic-hash/_expected/amd/B0TueUNf.js new file mode 100644 index 00000000000..45e664bea46 --- /dev/null +++ b/test/chunking-form/samples/hashing/tree-shaken-dynamic-hash/_expected/amd/B0TueUNf.js @@ -0,0 +1,7 @@ +define((function () { 'use strict'; + + var main = null; + + return main; + +})); diff --git a/test/chunking-form/samples/tree-shaken-dynamic-hash/_expected/cjs/05ff8838.js b/test/chunking-form/samples/hashing/tree-shaken-dynamic-hash/_expected/cjs/CZGiCtun.js similarity index 100% rename from test/chunking-form/samples/tree-shaken-dynamic-hash/_expected/cjs/05ff8838.js rename to test/chunking-form/samples/hashing/tree-shaken-dynamic-hash/_expected/cjs/CZGiCtun.js diff --git a/test/chunking-form/samples/hashing/tree-shaken-dynamic-hash/_expected/es/i0JfRnA6.js b/test/chunking-form/samples/hashing/tree-shaken-dynamic-hash/_expected/es/i0JfRnA6.js new file mode 100644 index 00000000000..d23b07b5840 --- /dev/null +++ b/test/chunking-form/samples/hashing/tree-shaken-dynamic-hash/_expected/es/i0JfRnA6.js @@ -0,0 +1,3 @@ +var main = null; + +export { main as default }; diff --git a/test/chunking-form/samples/hashing/tree-shaken-dynamic-hash/_expected/system/DZcpXEg4.js b/test/chunking-form/samples/hashing/tree-shaken-dynamic-hash/_expected/system/DZcpXEg4.js new file mode 100644 index 00000000000..f4b08cd6d9c --- /dev/null +++ b/test/chunking-form/samples/hashing/tree-shaken-dynamic-hash/_expected/system/DZcpXEg4.js @@ -0,0 +1,10 @@ +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + + var main = exports("default", null); + + }) + }; +})); diff --git a/test/chunking-form/samples/tree-shaken-dynamic-hash/foo.js b/test/chunking-form/samples/hashing/tree-shaken-dynamic-hash/foo.js similarity index 100% rename from test/chunking-form/samples/tree-shaken-dynamic-hash/foo.js rename to test/chunking-form/samples/hashing/tree-shaken-dynamic-hash/foo.js diff --git a/test/chunking-form/samples/tree-shaken-dynamic-hash/main.js b/test/chunking-form/samples/hashing/tree-shaken-dynamic-hash/main.js similarity index 100% rename from test/chunking-form/samples/tree-shaken-dynamic-hash/main.js rename to test/chunking-form/samples/hashing/tree-shaken-dynamic-hash/main.js diff --git a/test/chunking-form/samples/ignore-chunk-name-query/_config.js b/test/chunking-form/samples/ignore-chunk-name-query/_config.js new file mode 100644 index 00000000000..17cf7f74b0e --- /dev/null +++ b/test/chunking-form/samples/ignore-chunk-name-query/_config.js @@ -0,0 +1,15 @@ +const { loader } = require('../../../testHelpers.js'); + +module.exports = defineTest({ + description: 'ignores queries and hashes for chunk names when preserving modules', + options: { + input: ['a.js?query', 'b.js#hash'], + output: { preserveModules: true }, + plugins: [ + loader({ + 'a.js?query': "console.log('a');", + 'b.js#hash': "console.log('b');" + }) + ] + } +}); diff --git a/test/chunking-form/samples/ignore-chunk-name-query/_expected/amd/_virtual/a.js b/test/chunking-form/samples/ignore-chunk-name-query/_expected/amd/_virtual/a.js new file mode 100644 index 00000000000..6d0638c63e4 --- /dev/null +++ b/test/chunking-form/samples/ignore-chunk-name-query/_expected/amd/_virtual/a.js @@ -0,0 +1,5 @@ +define((function () { 'use strict'; + + console.log('a'); + +})); diff --git a/test/chunking-form/samples/ignore-chunk-name-query/_expected/amd/_virtual/b.js b/test/chunking-form/samples/ignore-chunk-name-query/_expected/amd/_virtual/b.js new file mode 100644 index 00000000000..b8ffc59b2da --- /dev/null +++ b/test/chunking-form/samples/ignore-chunk-name-query/_expected/amd/_virtual/b.js @@ -0,0 +1,5 @@ +define((function () { 'use strict'; + + console.log('b'); + +})); diff --git a/test/chunking-form/samples/ignore-chunk-name-query/_expected/cjs/_virtual/a.js b/test/chunking-form/samples/ignore-chunk-name-query/_expected/cjs/_virtual/a.js new file mode 100644 index 00000000000..4151e09bdbf --- /dev/null +++ b/test/chunking-form/samples/ignore-chunk-name-query/_expected/cjs/_virtual/a.js @@ -0,0 +1,3 @@ +'use strict'; + +console.log('a'); diff --git a/test/chunking-form/samples/ignore-chunk-name-query/_expected/cjs/_virtual/b.js b/test/chunking-form/samples/ignore-chunk-name-query/_expected/cjs/_virtual/b.js new file mode 100644 index 00000000000..099afa3ff4c --- /dev/null +++ b/test/chunking-form/samples/ignore-chunk-name-query/_expected/cjs/_virtual/b.js @@ -0,0 +1,3 @@ +'use strict'; + +console.log('b'); diff --git a/test/chunking-form/samples/ignore-chunk-name-query/_expected/es/_virtual/a.js b/test/chunking-form/samples/ignore-chunk-name-query/_expected/es/_virtual/a.js new file mode 100644 index 00000000000..8609d075540 --- /dev/null +++ b/test/chunking-form/samples/ignore-chunk-name-query/_expected/es/_virtual/a.js @@ -0,0 +1 @@ +console.log('a'); diff --git a/test/chunking-form/samples/ignore-chunk-name-query/_expected/es/_virtual/b.js b/test/chunking-form/samples/ignore-chunk-name-query/_expected/es/_virtual/b.js new file mode 100644 index 00000000000..eeb313a0347 --- /dev/null +++ b/test/chunking-form/samples/ignore-chunk-name-query/_expected/es/_virtual/b.js @@ -0,0 +1 @@ +console.log('b'); diff --git a/test/chunking-form/samples/ignore-chunk-name-query/_expected/system/_virtual/a.js b/test/chunking-form/samples/ignore-chunk-name-query/_expected/system/_virtual/a.js new file mode 100644 index 00000000000..2859a1e855c --- /dev/null +++ b/test/chunking-form/samples/ignore-chunk-name-query/_expected/system/_virtual/a.js @@ -0,0 +1,10 @@ +System.register([], (function () { + 'use strict'; + return { + execute: (function () { + + console.log('a'); + + }) + }; +})); diff --git a/test/chunking-form/samples/ignore-chunk-name-query/_expected/system/_virtual/b.js b/test/chunking-form/samples/ignore-chunk-name-query/_expected/system/_virtual/b.js new file mode 100644 index 00000000000..17b43387a91 --- /dev/null +++ b/test/chunking-form/samples/ignore-chunk-name-query/_expected/system/_virtual/b.js @@ -0,0 +1,10 @@ +System.register([], (function () { + 'use strict'; + return { + execute: (function () { + + console.log('b'); + + }) + }; +})); diff --git a/test/chunking-form/samples/implicit-dependencies/dependant-entry-no-effects/_config.js b/test/chunking-form/samples/implicit-dependencies/dependant-entry-no-effects/_config.js index ab57ea9f387..556a8139cf9 100644 --- a/test/chunking-form/samples/implicit-dependencies/dependant-entry-no-effects/_config.js +++ b/test/chunking-form/samples/implicit-dependencies/dependant-entry-no-effects/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'properly emits a chunk when it is implicitly loaded after an empty entry module', expectedWarnings: ['EMPTY_BUNDLE'], options: { @@ -13,4 +13,4 @@ module.exports = { } } } -}; +}); diff --git a/test/chunking-form/samples/implicit-dependencies/dependant-entry-no-effects/_expected/amd/generated-dep.js b/test/chunking-form/samples/implicit-dependencies/dependant-entry-no-effects/_expected/amd/generated-dep.js index c2f17b2a5dd..f94a3d9d9f9 100644 --- a/test/chunking-form/samples/implicit-dependencies/dependant-entry-no-effects/_expected/amd/generated-dep.js +++ b/test/chunking-form/samples/implicit-dependencies/dependant-entry-no-effects/_expected/amd/generated-dep.js @@ -1,5 +1,5 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; console.log('dep'); -}); +})); diff --git a/test/chunking-form/samples/implicit-dependencies/dependant-entry-no-effects/_expected/amd/main.js b/test/chunking-form/samples/implicit-dependencies/dependant-entry-no-effects/_expected/amd/main.js index f9f8229aa40..a9e9419e212 100644 --- a/test/chunking-form/samples/implicit-dependencies/dependant-entry-no-effects/_expected/amd/main.js +++ b/test/chunking-form/samples/implicit-dependencies/dependant-entry-no-effects/_expected/amd/main.js @@ -1,5 +1,5 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; -}); +})); diff --git a/test/chunking-form/samples/implicit-dependencies/dependant-entry-no-effects/_expected/system/generated-dep.js b/test/chunking-form/samples/implicit-dependencies/dependant-entry-no-effects/_expected/system/generated-dep.js index 106b124d6be..963f20ddf9c 100644 --- a/test/chunking-form/samples/implicit-dependencies/dependant-entry-no-effects/_expected/system/generated-dep.js +++ b/test/chunking-form/samples/implicit-dependencies/dependant-entry-no-effects/_expected/system/generated-dep.js @@ -1,10 +1,10 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { console.log('dep'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/implicit-dependencies/dependant-entry-no-effects/_expected/system/main.js b/test/chunking-form/samples/implicit-dependencies/dependant-entry-no-effects/_expected/system/main.js index a702f2b06ef..343cc3a5100 100644 --- a/test/chunking-form/samples/implicit-dependencies/dependant-entry-no-effects/_expected/system/main.js +++ b/test/chunking-form/samples/implicit-dependencies/dependant-entry-no-effects/_expected/system/main.js @@ -1,10 +1,10 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-emitted-entry/_config.js b/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-emitted-entry/_config.js index 6564522f9b9..999f77d3505 100644 --- a/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-emitted-entry/_config.js +++ b/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-emitted-entry/_config.js @@ -1,11 +1,11 @@ -const path = require('path'); -const assert = require('assert'); +const assert = require('node:assert'); +const path = require('node:path'); const ID_MAIN = path.join(__dirname, 'main.js'); const ID_LIB = path.join(__dirname, 'lib.js'); const ID_DEP = path.join(__dirname, 'dep.js'); -module.exports = { +module.exports = defineTest({ description: 'makes sure emitted entry points are never implicit dependencies', options: { preserveEntrySignatures: 'allow-extension', @@ -25,6 +25,8 @@ module.exports = { }, buildEnd() { assert.deepStrictEqual(JSON.parse(JSON.stringify(this.getModuleInfo(ID_MAIN))), { + id: ID_MAIN, + attributes: {}, ast: { type: 'Program', start: 0, @@ -34,6 +36,7 @@ module.exports = { type: 'ImportDeclaration', start: 0, end: 30, + source: { type: 'Literal', start: 22, end: 29, raw: "'./lib'", value: './lib' }, specifiers: [ { type: 'ImportSpecifier', @@ -43,7 +46,7 @@ module.exports = { local: { type: 'Identifier', start: 9, end: 14, name: 'value' } } ], - source: { type: 'Literal', start: 22, end: 29, value: './lib', raw: "'./lib'" } + attributes: [] }, { type: 'ExpressionStatement', @@ -53,16 +56,16 @@ module.exports = { type: 'CallExpression', start: 31, end: 49, + arguments: [{ type: 'Identifier', start: 43, end: 48, name: 'value' }], callee: { type: 'MemberExpression', start: 31, end: 42, - object: { type: 'Identifier', start: 31, end: 38, name: 'console' }, - property: { type: 'Identifier', start: 39, end: 42, name: 'log' }, computed: false, - optional: false + object: { type: 'Identifier', start: 31, end: 38, name: 'console' }, + optional: false, + property: { type: 'Identifier', start: 39, end: 42, name: 'log' } }, - arguments: [{ type: 'Identifier', start: 43, end: 48, name: 'value' }], optional: false } } @@ -70,20 +73,40 @@ module.exports = { sourceType: 'module' }, code: "import { value } from './lib';\nconsole.log(value);\n", + dynamicallyImportedIdResolutions: [], dynamicallyImportedIds: [], dynamicImporters: [], - hasModuleSideEffects: true, - id: ID_MAIN, + exportedBindings: { + '.': [] + }, + exports: [], + hasDefaultExport: false, + moduleSideEffects: true, implicitlyLoadedAfterOneOf: [], implicitlyLoadedBefore: [], + importedIdResolutions: [ + { + attributes: {}, + external: false, + id: ID_LIB, + meta: {}, + moduleSideEffects: true, + resolvedBy: 'rollup', + syntheticNamedExports: false + } + ], importedIds: [ID_LIB], importers: [], isEntry: true, isExternal: false, + isIncluded: true, meta: {}, + safeVariableNames: null, syntheticNamedExports: false }); assert.deepStrictEqual(JSON.parse(JSON.stringify(this.getModuleInfo(ID_DEP))), { + id: ID_DEP, + attributes: {}, ast: { type: 'Program', start: 0, @@ -93,6 +116,7 @@ module.exports = { type: 'ImportDeclaration', start: 0, end: 30, + source: { type: 'Literal', start: 22, end: 29, raw: "'./lib'", value: './lib' }, specifiers: [ { type: 'ImportSpecifier', @@ -102,7 +126,7 @@ module.exports = { local: { type: 'Identifier', start: 9, end: 14, name: 'value' } } ], - source: { type: 'Literal', start: 22, end: 29, value: './lib', raw: "'./lib'" } + attributes: [] }, { type: 'ExpressionStatement', @@ -112,16 +136,16 @@ module.exports = { type: 'CallExpression', start: 31, end: 49, + arguments: [{ type: 'Identifier', start: 43, end: 48, name: 'value' }], callee: { type: 'MemberExpression', start: 31, end: 42, - object: { type: 'Identifier', start: 31, end: 38, name: 'console' }, - property: { type: 'Identifier', start: 39, end: 42, name: 'log' }, computed: false, - optional: false + object: { type: 'Identifier', start: 31, end: 38, name: 'console' }, + optional: false, + property: { type: 'Identifier', start: 39, end: 42, name: 'log' } }, - arguments: [{ type: 'Identifier', start: 43, end: 48, name: 'value' }], optional: false } } @@ -129,17 +153,35 @@ module.exports = { sourceType: 'module' }, code: "import { value } from './lib';\nconsole.log(value);\n", + dynamicallyImportedIdResolutions: [], dynamicallyImportedIds: [], dynamicImporters: [], - hasModuleSideEffects: true, - id: ID_DEP, + exportedBindings: { + '.': [] + }, + exports: [], + hasDefaultExport: false, + moduleSideEffects: true, implicitlyLoadedAfterOneOf: [], implicitlyLoadedBefore: [], + importedIdResolutions: [ + { + attributes: {}, + external: false, + id: ID_LIB, + meta: {}, + moduleSideEffects: true, + resolvedBy: 'rollup', + syntheticNamedExports: false + } + ], importedIds: [ID_LIB], importers: [], isEntry: true, isExternal: false, + isIncluded: true, meta: {}, + safeVariableNames: null, syntheticNamedExports: false }); }, @@ -154,7 +196,13 @@ module.exports = { assert.strictEqual(dep.isEntry, true, 'dep.isEntry'); assert.strictEqual(dep.isDynamicEntry, false, 'dep.isDynamicEntry'); assert.strictEqual(dep.isImplicitEntry, false, 'dep.isImplicitEntry'); + }, + async transform(code, id) { + if (id.endsWith('main.js')) { + // This delay used to cause a race condition + await new Promise(resolve => setTimeout(resolve, 200)); + } } } } -}; +}); diff --git a/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-emitted-entry/_expected/amd/generated-dep.js b/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-emitted-entry/_expected/amd/generated-dep.js index 0390847a204..b2d6432da4c 100644 --- a/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-emitted-entry/_expected/amd/generated-dep.js +++ b/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-emitted-entry/_expected/amd/generated-dep.js @@ -1,5 +1,5 @@ -define(['./generated-lib'], function (lib) { 'use strict'; +define(['./generated-lib'], (function (lib) { 'use strict'; console.log(lib.value); -}); +})); diff --git a/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-emitted-entry/_expected/amd/generated-lib.js b/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-emitted-entry/_expected/amd/generated-lib.js index bf7989e606f..947ad1cbafd 100644 --- a/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-emitted-entry/_expected/amd/generated-lib.js +++ b/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-emitted-entry/_expected/amd/generated-lib.js @@ -1,7 +1,7 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; const value = 42; exports.value = value; -}); +})); diff --git a/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-emitted-entry/_expected/amd/main.js b/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-emitted-entry/_expected/amd/main.js index 0390847a204..b2d6432da4c 100644 --- a/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-emitted-entry/_expected/amd/main.js +++ b/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-emitted-entry/_expected/amd/main.js @@ -1,5 +1,5 @@ -define(['./generated-lib'], function (lib) { 'use strict'; +define(['./generated-lib'], (function (lib) { 'use strict'; console.log(lib.value); -}); +})); diff --git a/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-emitted-entry/_expected/system/generated-dep.js b/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-emitted-entry/_expected/system/generated-dep.js index fe619e7ec3d..42acb18c54c 100644 --- a/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-emitted-entry/_expected/system/generated-dep.js +++ b/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-emitted-entry/_expected/system/generated-dep.js @@ -1,14 +1,14 @@ -System.register(['./generated-lib.js'], function () { +System.register(['./generated-lib.js'], (function () { 'use strict'; var value; return { setters: [function (module) { value = module.v; }], - execute: function () { + execute: (function () { console.log(value); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-emitted-entry/_expected/system/generated-lib.js b/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-emitted-entry/_expected/system/generated-lib.js index 1fc955eb247..6ca617cd0d2 100644 --- a/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-emitted-entry/_expected/system/generated-lib.js +++ b/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-emitted-entry/_expected/system/generated-lib.js @@ -1,10 +1,10 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - const value = exports('v', 42); + const value = exports("v", 42); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-emitted-entry/_expected/system/main.js b/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-emitted-entry/_expected/system/main.js index fe619e7ec3d..42acb18c54c 100644 --- a/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-emitted-entry/_expected/system/main.js +++ b/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-emitted-entry/_expected/system/main.js @@ -1,14 +1,14 @@ -System.register(['./generated-lib.js'], function () { +System.register(['./generated-lib.js'], (function () { 'use strict'; var value; return { setters: [function (module) { value = module.v; }], - execute: function () { + execute: (function () { console.log(value); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-emitted-entry2/_config.js b/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-emitted-entry2/_config.js new file mode 100644 index 00000000000..abfcd332fc2 --- /dev/null +++ b/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-emitted-entry2/_config.js @@ -0,0 +1,202 @@ +const assert = require('node:assert'); +const path = require('node:path'); + +const ID_MAIN = path.join(__dirname, 'main.js'); +const ID_LIB = path.join(__dirname, 'lib.js'); +const ID_DEP = path.join(__dirname, 'dep.js'); + +module.exports = defineTest({ + description: 'makes sure emitted entry points are never implicit dependencies', + options: { + preserveEntrySignatures: 'allow-extension', + plugins: { + name: 'test-plugin', + async buildStart() { + this.emitFile({ + type: 'chunk', + id: 'dep.js', + implicitlyLoadedAfterOneOf: [ID_MAIN] + }); + await new Promise(resolve => setTimeout(resolve, 200)); + this.emitFile({ + type: 'chunk', + id: 'dep.js' + }); + }, + buildEnd() { + assert.deepStrictEqual(JSON.parse(JSON.stringify(this.getModuleInfo(ID_MAIN))), { + id: ID_MAIN, + attributes: {}, + ast: { + type: 'Program', + start: 0, + end: 51, + body: [ + { + type: 'ImportDeclaration', + start: 0, + end: 30, + source: { type: 'Literal', start: 22, end: 29, raw: "'./lib'", value: './lib' }, + specifiers: [ + { + type: 'ImportSpecifier', + start: 9, + end: 14, + imported: { type: 'Identifier', start: 9, end: 14, name: 'value' }, + local: { type: 'Identifier', start: 9, end: 14, name: 'value' } + } + ], + attributes: [] + }, + { + type: 'ExpressionStatement', + start: 31, + end: 50, + expression: { + type: 'CallExpression', + start: 31, + end: 49, + arguments: [{ type: 'Identifier', start: 43, end: 48, name: 'value' }], + callee: { + type: 'MemberExpression', + start: 31, + end: 42, + computed: false, + object: { type: 'Identifier', start: 31, end: 38, name: 'console' }, + optional: false, + property: { type: 'Identifier', start: 39, end: 42, name: 'log' } + }, + optional: false + } + } + ], + sourceType: 'module' + }, + code: "import { value } from './lib';\nconsole.log(value);\n", + dynamicallyImportedIdResolutions: [], + dynamicallyImportedIds: [], + dynamicImporters: [], + exportedBindings: { + '.': [] + }, + exports: [], + hasDefaultExport: false, + moduleSideEffects: true, + safeVariableNames: null, + implicitlyLoadedAfterOneOf: [], + implicitlyLoadedBefore: [], + importedIdResolutions: [ + { + attributes: {}, + external: false, + id: ID_LIB, + meta: {}, + moduleSideEffects: true, + resolvedBy: 'rollup', + syntheticNamedExports: false + } + ], + importedIds: [ID_LIB], + importers: [], + isEntry: true, + isExternal: false, + isIncluded: true, + meta: {}, + syntheticNamedExports: false + }); + assert.deepStrictEqual(JSON.parse(JSON.stringify(this.getModuleInfo(ID_DEP))), { + id: ID_DEP, + attributes: {}, + ast: { + type: 'Program', + start: 0, + end: 51, + body: [ + { + type: 'ImportDeclaration', + start: 0, + end: 30, + source: { type: 'Literal', start: 22, end: 29, raw: "'./lib'", value: './lib' }, + specifiers: [ + { + type: 'ImportSpecifier', + start: 9, + end: 14, + imported: { type: 'Identifier', start: 9, end: 14, name: 'value' }, + local: { type: 'Identifier', start: 9, end: 14, name: 'value' } + } + ], + attributes: [] + }, + { + type: 'ExpressionStatement', + start: 31, + end: 50, + expression: { + type: 'CallExpression', + start: 31, + end: 49, + arguments: [{ type: 'Identifier', start: 43, end: 48, name: 'value' }], + callee: { + type: 'MemberExpression', + start: 31, + end: 42, + computed: false, + object: { type: 'Identifier', start: 31, end: 38, name: 'console' }, + optional: false, + property: { type: 'Identifier', start: 39, end: 42, name: 'log' } + }, + optional: false + } + } + ], + sourceType: 'module' + }, + code: "import { value } from './lib';\nconsole.log(value);\n", + dynamicallyImportedIdResolutions: [], + dynamicallyImportedIds: [], + dynamicImporters: [], + exportedBindings: { + '.': [] + }, + exports: [], + hasDefaultExport: false, + moduleSideEffects: true, + safeVariableNames: null, + implicitlyLoadedAfterOneOf: [], + implicitlyLoadedBefore: [], + importedIdResolutions: [ + { + attributes: {}, + external: false, + id: ID_LIB, + meta: {}, + moduleSideEffects: true, + resolvedBy: 'rollup', + syntheticNamedExports: false + } + ], + importedIds: [ID_LIB], + importers: [], + isEntry: true, + isExternal: false, + isIncluded: true, + meta: {}, + syntheticNamedExports: false + }); + }, + generateBundle(options, bundle) { + const main = bundle['main.js']; + assert.deepStrictEqual(main.implicitlyLoadedBefore, [], 'main.implicitlyLoadedBefore'); + assert.strictEqual(main.isEntry, true, 'main.isEntry'); + assert.strictEqual(main.isDynamicEntry, false, 'main.isDynamicEntry'); + assert.strictEqual(main.isImplicitEntry, false, 'main.isImplicitEntry'); + const dep = bundle['generated-dep.js']; + assert.deepStrictEqual(dep.implicitlyLoadedBefore, [], 'dep.implicitlyLoadedBefore'); + assert.strictEqual(dep.isEntry, true, 'dep.isEntry'); + assert.strictEqual(dep.isDynamicEntry, false, 'dep.isDynamicEntry'); + assert.strictEqual(dep.isImplicitEntry, false, 'dep.isImplicitEntry'); + } + } + } +}); diff --git a/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-emitted-entry2/_expected/amd/generated-dep.js b/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-emitted-entry2/_expected/amd/generated-dep.js new file mode 100644 index 00000000000..b2d6432da4c --- /dev/null +++ b/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-emitted-entry2/_expected/amd/generated-dep.js @@ -0,0 +1,5 @@ +define(['./generated-lib'], (function (lib) { 'use strict'; + + console.log(lib.value); + +})); diff --git a/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-emitted-entry2/_expected/amd/generated-lib.js b/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-emitted-entry2/_expected/amd/generated-lib.js new file mode 100644 index 00000000000..947ad1cbafd --- /dev/null +++ b/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-emitted-entry2/_expected/amd/generated-lib.js @@ -0,0 +1,7 @@ +define(['exports'], (function (exports) { 'use strict'; + + const value = 42; + + exports.value = value; + +})); diff --git a/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-emitted-entry2/_expected/amd/main.js b/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-emitted-entry2/_expected/amd/main.js new file mode 100644 index 00000000000..b2d6432da4c --- /dev/null +++ b/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-emitted-entry2/_expected/amd/main.js @@ -0,0 +1,5 @@ +define(['./generated-lib'], (function (lib) { 'use strict'; + + console.log(lib.value); + +})); diff --git a/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-emitted-entry2/_expected/cjs/generated-dep.js b/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-emitted-entry2/_expected/cjs/generated-dep.js new file mode 100644 index 00000000000..cbb66f4c7a2 --- /dev/null +++ b/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-emitted-entry2/_expected/cjs/generated-dep.js @@ -0,0 +1,5 @@ +'use strict'; + +var lib = require('./generated-lib.js'); + +console.log(lib.value); diff --git a/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-emitted-entry2/_expected/cjs/generated-lib.js b/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-emitted-entry2/_expected/cjs/generated-lib.js new file mode 100644 index 00000000000..9549eb32880 --- /dev/null +++ b/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-emitted-entry2/_expected/cjs/generated-lib.js @@ -0,0 +1,5 @@ +'use strict'; + +const value = 42; + +exports.value = value; diff --git a/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-emitted-entry2/_expected/cjs/main.js b/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-emitted-entry2/_expected/cjs/main.js new file mode 100644 index 00000000000..cbb66f4c7a2 --- /dev/null +++ b/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-emitted-entry2/_expected/cjs/main.js @@ -0,0 +1,5 @@ +'use strict'; + +var lib = require('./generated-lib.js'); + +console.log(lib.value); diff --git a/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-emitted-entry2/_expected/es/generated-dep.js b/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-emitted-entry2/_expected/es/generated-dep.js new file mode 100644 index 00000000000..010878f5f45 --- /dev/null +++ b/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-emitted-entry2/_expected/es/generated-dep.js @@ -0,0 +1,3 @@ +import { v as value } from './generated-lib.js'; + +console.log(value); diff --git a/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-emitted-entry2/_expected/es/generated-lib.js b/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-emitted-entry2/_expected/es/generated-lib.js new file mode 100644 index 00000000000..eede3bf82d2 --- /dev/null +++ b/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-emitted-entry2/_expected/es/generated-lib.js @@ -0,0 +1,3 @@ +const value = 42; + +export { value as v }; diff --git a/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-emitted-entry2/_expected/es/main.js b/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-emitted-entry2/_expected/es/main.js new file mode 100644 index 00000000000..010878f5f45 --- /dev/null +++ b/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-emitted-entry2/_expected/es/main.js @@ -0,0 +1,3 @@ +import { v as value } from './generated-lib.js'; + +console.log(value); diff --git a/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-emitted-entry2/_expected/system/generated-dep.js b/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-emitted-entry2/_expected/system/generated-dep.js new file mode 100644 index 00000000000..42acb18c54c --- /dev/null +++ b/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-emitted-entry2/_expected/system/generated-dep.js @@ -0,0 +1,14 @@ +System.register(['./generated-lib.js'], (function () { + 'use strict'; + var value; + return { + setters: [function (module) { + value = module.v; + }], + execute: (function () { + + console.log(value); + + }) + }; +})); diff --git a/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-emitted-entry2/_expected/system/generated-lib.js b/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-emitted-entry2/_expected/system/generated-lib.js new file mode 100644 index 00000000000..6ca617cd0d2 --- /dev/null +++ b/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-emitted-entry2/_expected/system/generated-lib.js @@ -0,0 +1,10 @@ +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + + const value = exports("v", 42); + + }) + }; +})); diff --git a/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-emitted-entry2/_expected/system/main.js b/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-emitted-entry2/_expected/system/main.js new file mode 100644 index 00000000000..42acb18c54c --- /dev/null +++ b/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-emitted-entry2/_expected/system/main.js @@ -0,0 +1,14 @@ +System.register(['./generated-lib.js'], (function () { + 'use strict'; + var value; + return { + setters: [function (module) { + value = module.v; + }], + execute: (function () { + + console.log(value); + + }) + }; +})); diff --git a/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-emitted-entry2/dep.js b/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-emitted-entry2/dep.js new file mode 100644 index 00000000000..48f78898604 --- /dev/null +++ b/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-emitted-entry2/dep.js @@ -0,0 +1,2 @@ +import { value } from './lib'; +console.log(value); diff --git a/test/function/samples/deprecated/inline-imports-with-manual/lib.js b/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-emitted-entry2/lib.js similarity index 100% rename from test/function/samples/deprecated/inline-imports-with-manual/lib.js rename to test/chunking-form/samples/implicit-dependencies/implicitly-dependent-emitted-entry2/lib.js diff --git a/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-emitted-entry2/main.js b/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-emitted-entry2/main.js new file mode 100644 index 00000000000..48f78898604 --- /dev/null +++ b/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-emitted-entry2/main.js @@ -0,0 +1,2 @@ +import { value } from './lib'; +console.log(value); diff --git a/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-entry/_config.js b/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-entry/_config.js index 1a44bf6a0bf..d636b38915c 100644 --- a/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-entry/_config.js +++ b/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-entry/_config.js @@ -1,11 +1,11 @@ -const path = require('path'); -const assert = require('assert'); +const assert = require('node:assert'); +const path = require('node:path'); const ID_MAIN = path.join(__dirname, 'main.js'); const ID_LIB = path.join(__dirname, 'lib.js'); const ID_DEP = path.join(__dirname, 'dep.js'); -module.exports = { +module.exports = defineTest({ description: 'makes sure actual entry points are never implicit dependencies', options: { input: ['main', 'dep'], @@ -21,6 +21,8 @@ module.exports = { }, buildEnd() { assert.deepStrictEqual(JSON.parse(JSON.stringify(this.getModuleInfo(ID_MAIN))), { + id: ID_MAIN, + attributes: {}, ast: { type: 'Program', start: 0, @@ -30,6 +32,7 @@ module.exports = { type: 'ImportDeclaration', start: 0, end: 30, + source: { type: 'Literal', start: 22, end: 29, raw: "'./lib'", value: './lib' }, specifiers: [ { type: 'ImportSpecifier', @@ -39,7 +42,7 @@ module.exports = { local: { type: 'Identifier', start: 9, end: 14, name: 'value' } } ], - source: { type: 'Literal', start: 22, end: 29, value: './lib', raw: "'./lib'" } + attributes: [] }, { type: 'ExpressionStatement', @@ -49,16 +52,16 @@ module.exports = { type: 'CallExpression', start: 31, end: 49, + arguments: [{ type: 'Identifier', start: 43, end: 48, name: 'value' }], callee: { type: 'MemberExpression', start: 31, end: 42, - object: { type: 'Identifier', start: 31, end: 38, name: 'console' }, - property: { type: 'Identifier', start: 39, end: 42, name: 'log' }, computed: false, - optional: false + object: { type: 'Identifier', start: 31, end: 38, name: 'console' }, + optional: false, + property: { type: 'Identifier', start: 39, end: 42, name: 'log' } }, - arguments: [{ type: 'Identifier', start: 43, end: 48, name: 'value' }], optional: false } } @@ -66,20 +69,40 @@ module.exports = { sourceType: 'module' }, code: "import { value } from './lib';\nconsole.log(value);\n", + dynamicallyImportedIdResolutions: [], dynamicallyImportedIds: [], dynamicImporters: [], - hasModuleSideEffects: true, - id: ID_MAIN, + exportedBindings: { + '.': [] + }, + exports: [], + hasDefaultExport: false, + moduleSideEffects: true, + safeVariableNames: null, implicitlyLoadedAfterOneOf: [], implicitlyLoadedBefore: [], + importedIdResolutions: [ + { + attributes: {}, + external: false, + id: ID_LIB, + meta: {}, + moduleSideEffects: true, + resolvedBy: 'rollup', + syntheticNamedExports: false + } + ], importedIds: [ID_LIB], importers: [], isEntry: true, isExternal: false, + isIncluded: true, meta: {}, syntheticNamedExports: false }); assert.deepStrictEqual(JSON.parse(JSON.stringify(this.getModuleInfo(ID_DEP))), { + id: ID_DEP, + attributes: {}, ast: { type: 'Program', start: 0, @@ -89,6 +112,7 @@ module.exports = { type: 'ImportDeclaration', start: 0, end: 30, + source: { type: 'Literal', start: 22, end: 29, raw: "'./lib'", value: './lib' }, specifiers: [ { type: 'ImportSpecifier', @@ -98,7 +122,7 @@ module.exports = { local: { type: 'Identifier', start: 9, end: 14, name: 'value' } } ], - source: { type: 'Literal', start: 22, end: 29, value: './lib', raw: "'./lib'" } + attributes: [] }, { type: 'ExpressionStatement', @@ -108,16 +132,16 @@ module.exports = { type: 'CallExpression', start: 31, end: 49, + arguments: [{ type: 'Identifier', start: 43, end: 48, name: 'value' }], callee: { type: 'MemberExpression', start: 31, end: 42, - object: { type: 'Identifier', start: 31, end: 38, name: 'console' }, - property: { type: 'Identifier', start: 39, end: 42, name: 'log' }, computed: false, - optional: false + object: { type: 'Identifier', start: 31, end: 38, name: 'console' }, + optional: false, + property: { type: 'Identifier', start: 39, end: 42, name: 'log' } }, - arguments: [{ type: 'Identifier', start: 43, end: 48, name: 'value' }], optional: false } } @@ -125,16 +149,34 @@ module.exports = { sourceType: 'module' }, code: "import { value } from './lib';\nconsole.log(value);\n", + dynamicallyImportedIdResolutions: [], dynamicallyImportedIds: [], dynamicImporters: [], - hasModuleSideEffects: true, - id: ID_DEP, + exports: [], + exportedBindings: { + '.': [] + }, + hasDefaultExport: false, + moduleSideEffects: true, + safeVariableNames: null, implicitlyLoadedAfterOneOf: [], implicitlyLoadedBefore: [], + importedIdResolutions: [ + { + attributes: {}, + external: false, + id: ID_LIB, + meta: {}, + moduleSideEffects: true, + resolvedBy: 'rollup', + syntheticNamedExports: false + } + ], importedIds: [ID_LIB], importers: [], isEntry: true, isExternal: false, + isIncluded: true, meta: {}, syntheticNamedExports: false }); @@ -153,4 +195,4 @@ module.exports = { } } } -}; +}); diff --git a/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-entry/_expected/amd/dep.js b/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-entry/_expected/amd/dep.js index 0390847a204..b2d6432da4c 100644 --- a/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-entry/_expected/amd/dep.js +++ b/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-entry/_expected/amd/dep.js @@ -1,5 +1,5 @@ -define(['./generated-lib'], function (lib) { 'use strict'; +define(['./generated-lib'], (function (lib) { 'use strict'; console.log(lib.value); -}); +})); diff --git a/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-entry/_expected/amd/generated-lib.js b/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-entry/_expected/amd/generated-lib.js index bf7989e606f..947ad1cbafd 100644 --- a/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-entry/_expected/amd/generated-lib.js +++ b/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-entry/_expected/amd/generated-lib.js @@ -1,7 +1,7 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; const value = 42; exports.value = value; -}); +})); diff --git a/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-entry/_expected/amd/main.js b/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-entry/_expected/amd/main.js index 0390847a204..b2d6432da4c 100644 --- a/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-entry/_expected/amd/main.js +++ b/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-entry/_expected/amd/main.js @@ -1,5 +1,5 @@ -define(['./generated-lib'], function (lib) { 'use strict'; +define(['./generated-lib'], (function (lib) { 'use strict'; console.log(lib.value); -}); +})); diff --git a/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-entry/_expected/system/dep.js b/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-entry/_expected/system/dep.js index fe619e7ec3d..42acb18c54c 100644 --- a/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-entry/_expected/system/dep.js +++ b/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-entry/_expected/system/dep.js @@ -1,14 +1,14 @@ -System.register(['./generated-lib.js'], function () { +System.register(['./generated-lib.js'], (function () { 'use strict'; var value; return { setters: [function (module) { value = module.v; }], - execute: function () { + execute: (function () { console.log(value); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-entry/_expected/system/generated-lib.js b/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-entry/_expected/system/generated-lib.js index 1fc955eb247..6ca617cd0d2 100644 --- a/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-entry/_expected/system/generated-lib.js +++ b/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-entry/_expected/system/generated-lib.js @@ -1,10 +1,10 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - const value = exports('v', 42); + const value = exports("v", 42); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-entry/_expected/system/main.js b/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-entry/_expected/system/main.js index fe619e7ec3d..42acb18c54c 100644 --- a/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-entry/_expected/system/main.js +++ b/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-entry/_expected/system/main.js @@ -1,14 +1,14 @@ -System.register(['./generated-lib.js'], function () { +System.register(['./generated-lib.js'], (function () { 'use strict'; var value; return { setters: [function (module) { value = module.v; }], - execute: function () { + execute: (function () { console.log(value); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/implicit-dependencies/multiple-dependencies/_config.js b/test/chunking-form/samples/implicit-dependencies/multiple-dependencies/_config.js index 8ae1e81d181..9dc2ee5c6ce 100644 --- a/test/chunking-form/samples/implicit-dependencies/multiple-dependencies/_config.js +++ b/test/chunking-form/samples/implicit-dependencies/multiple-dependencies/_config.js @@ -1,5 +1,5 @@ -const path = require('path'); -const assert = require('assert'); +const assert = require('node:assert'); +const path = require('node:path'); const ID_MAIN1 = path.join(__dirname, 'main1.js'); const ID_MAIN2 = path.join(__dirname, 'main2.js'); @@ -9,7 +9,7 @@ const ID_LIB2 = path.join(__dirname, 'lib2.js'); const ID_LIB3 = path.join(__dirname, 'lib3.js'); const ID_DEP = path.join(__dirname, 'dep.js'); -module.exports = { +module.exports = defineTest({ description: 'supports emitting the same chunk with different and multiple dependencies', options: { input: ['main1', 'main2'], @@ -34,6 +34,8 @@ module.exports = { }, buildEnd() { assert.deepStrictEqual(JSON.parse(JSON.stringify(this.getModuleInfo(ID_MAIN1))), { + id: ID_MAIN1, + attributes: {}, ast: { type: 'Program', start: 0, @@ -43,6 +45,7 @@ module.exports = { type: 'ImportDeclaration', start: 0, end: 30, + source: { type: 'Literal', start: 21, end: 29, raw: "'./lib1'", value: './lib1' }, specifiers: [ { type: 'ImportSpecifier', @@ -52,12 +55,13 @@ module.exports = { local: { type: 'Identifier', start: 9, end: 13, name: 'lib1' } } ], - source: { type: 'Literal', start: 21, end: 29, value: './lib1', raw: "'./lib1'" } + attributes: [] }, { type: 'ImportDeclaration', start: 31, end: 63, + source: { type: 'Literal', start: 53, end: 62, raw: "'./lib1b'", value: './lib1b' }, specifiers: [ { type: 'ImportSpecifier', @@ -67,12 +71,13 @@ module.exports = { local: { type: 'Identifier', start: 40, end: 45, name: 'lib1b' } } ], - source: { type: 'Literal', start: 53, end: 62, value: './lib1b', raw: "'./lib1b'" } + attributes: [] }, { type: 'ImportDeclaration', start: 64, end: 94, + source: { type: 'Literal', start: 85, end: 93, raw: "'./lib2'", value: './lib2' }, specifiers: [ { type: 'ImportSpecifier', @@ -82,7 +87,7 @@ module.exports = { local: { type: 'Identifier', start: 73, end: 77, name: 'lib2' } } ], - source: { type: 'Literal', start: 85, end: 93, value: './lib2', raw: "'./lib2'" } + attributes: [] }, { type: 'ExpressionStatement', @@ -92,43 +97,80 @@ module.exports = { type: 'CallExpression', start: 95, end: 135, + arguments: [ + { type: 'Literal', start: 107, end: 114, raw: "'main1'", value: 'main1' }, + { type: 'Identifier', start: 116, end: 120, name: 'lib1' }, + { type: 'Identifier', start: 123, end: 128, name: 'lib1b' }, + { type: 'Identifier', start: 130, end: 134, name: 'lib2' } + ], callee: { type: 'MemberExpression', start: 95, end: 106, - object: { type: 'Identifier', start: 95, end: 102, name: 'console' }, - property: { type: 'Identifier', start: 103, end: 106, name: 'log' }, computed: false, - optional: false + object: { type: 'Identifier', start: 95, end: 102, name: 'console' }, + optional: false, + property: { type: 'Identifier', start: 103, end: 106, name: 'log' } }, - arguments: [ - { type: 'Literal', start: 107, end: 114, value: 'main1', raw: "'main1'" }, - { type: 'Identifier', start: 116, end: 120, name: 'lib1' }, - { type: 'Identifier', start: 123, end: 128, name: 'lib1b' }, - { type: 'Identifier', start: 130, end: 134, name: 'lib2' } - ], optional: false } } ], sourceType: 'module' }, - code: - "import { lib1 } from './lib1';\nimport { lib1b } from './lib1b';\nimport { lib2 } from './lib2';\nconsole.log('main1', lib1, lib1b, lib2);\n", + code: "import { lib1 } from './lib1';\nimport { lib1b } from './lib1b';\nimport { lib2 } from './lib2';\nconsole.log('main1', lib1, lib1b, lib2);\n", + dynamicallyImportedIdResolutions: [], dynamicallyImportedIds: [], dynamicImporters: [], - hasModuleSideEffects: true, - id: ID_MAIN1, + exportedBindings: { + '.': [] + }, + exports: [], + hasDefaultExport: false, + moduleSideEffects: true, + safeVariableNames: null, implicitlyLoadedAfterOneOf: [], implicitlyLoadedBefore: [ID_DEP], + importedIdResolutions: [ + { + attributes: {}, + external: false, + id: ID_LIB1, + meta: {}, + moduleSideEffects: true, + resolvedBy: 'rollup', + syntheticNamedExports: false + }, + { + attributes: {}, + external: false, + id: ID_LIB1B, + meta: {}, + moduleSideEffects: true, + resolvedBy: 'rollup', + syntheticNamedExports: false + }, + { + attributes: {}, + external: false, + id: ID_LIB2, + meta: {}, + moduleSideEffects: true, + resolvedBy: 'rollup', + syntheticNamedExports: false + } + ], importedIds: [ID_LIB1, ID_LIB1B, ID_LIB2], importers: [], isEntry: true, isExternal: false, + isIncluded: true, meta: {}, syntheticNamedExports: false }); assert.deepStrictEqual(JSON.parse(JSON.stringify(this.getModuleInfo(ID_MAIN2))), { + id: ID_MAIN2, + attributes: {}, ast: { type: 'Program', start: 0, @@ -138,6 +180,7 @@ module.exports = { type: 'ImportDeclaration', start: 0, end: 30, + source: { type: 'Literal', start: 21, end: 29, raw: "'./lib1'", value: './lib1' }, specifiers: [ { type: 'ImportSpecifier', @@ -147,12 +190,13 @@ module.exports = { local: { type: 'Identifier', start: 9, end: 13, name: 'lib1' } } ], - source: { type: 'Literal', start: 21, end: 29, value: './lib1', raw: "'./lib1'" } + attributes: [] }, { type: 'ImportDeclaration', start: 31, end: 63, + source: { type: 'Literal', start: 53, end: 62, raw: "'./lib1b'", value: './lib1b' }, specifiers: [ { type: 'ImportSpecifier', @@ -162,12 +206,13 @@ module.exports = { local: { type: 'Identifier', start: 40, end: 45, name: 'lib1b' } } ], - source: { type: 'Literal', start: 53, end: 62, value: './lib1b', raw: "'./lib1b'" } + attributes: [] }, { type: 'ImportDeclaration', start: 64, end: 94, + source: { type: 'Literal', start: 85, end: 93, raw: "'./lib3'", value: './lib3' }, specifiers: [ { type: 'ImportSpecifier', @@ -177,7 +222,7 @@ module.exports = { local: { type: 'Identifier', start: 73, end: 77, name: 'lib3' } } ], - source: { type: 'Literal', start: 85, end: 93, value: './lib3', raw: "'./lib3'" } + attributes: [] }, { type: 'ExpressionStatement', @@ -187,43 +232,80 @@ module.exports = { type: 'CallExpression', start: 95, end: 134, + arguments: [ + { type: 'Literal', start: 107, end: 114, raw: "'main2'", value: 'main2' }, + { type: 'Identifier', start: 116, end: 120, name: 'lib1' }, + { type: 'Identifier', start: 122, end: 127, name: 'lib1b' }, + { type: 'Identifier', start: 129, end: 133, name: 'lib3' } + ], callee: { type: 'MemberExpression', start: 95, end: 106, - object: { type: 'Identifier', start: 95, end: 102, name: 'console' }, - property: { type: 'Identifier', start: 103, end: 106, name: 'log' }, computed: false, - optional: false + object: { type: 'Identifier', start: 95, end: 102, name: 'console' }, + optional: false, + property: { type: 'Identifier', start: 103, end: 106, name: 'log' } }, - arguments: [ - { type: 'Literal', start: 107, end: 114, value: 'main2', raw: "'main2'" }, - { type: 'Identifier', start: 116, end: 120, name: 'lib1' }, - { type: 'Identifier', start: 122, end: 127, name: 'lib1b' }, - { type: 'Identifier', start: 129, end: 133, name: 'lib3' } - ], optional: false } } ], sourceType: 'module' }, - code: - "import { lib1 } from './lib1';\nimport { lib1b } from './lib1b';\nimport { lib3 } from './lib3';\nconsole.log('main2', lib1, lib1b, lib3);\n", + code: "import { lib1 } from './lib1';\nimport { lib1b } from './lib1b';\nimport { lib3 } from './lib3';\nconsole.log('main2', lib1, lib1b, lib3);\n", + dynamicallyImportedIdResolutions: [], dynamicallyImportedIds: [], dynamicImporters: [], - hasModuleSideEffects: true, - id: ID_MAIN2, + exportedBindings: { + '.': [] + }, + exports: [], + hasDefaultExport: false, + moduleSideEffects: true, + safeVariableNames: null, implicitlyLoadedAfterOneOf: [], implicitlyLoadedBefore: [ID_DEP], + importedIdResolutions: [ + { + attributes: {}, + external: false, + id: ID_LIB1, + meta: {}, + moduleSideEffects: true, + resolvedBy: 'rollup', + syntheticNamedExports: false + }, + { + attributes: {}, + external: false, + id: ID_LIB1B, + meta: {}, + moduleSideEffects: true, + resolvedBy: 'rollup', + syntheticNamedExports: false + }, + { + attributes: {}, + external: false, + id: ID_LIB3, + meta: {}, + moduleSideEffects: true, + resolvedBy: 'rollup', + syntheticNamedExports: false + } + ], importedIds: [ID_LIB1, ID_LIB1B, ID_LIB3], importers: [], isEntry: true, isExternal: false, + isIncluded: true, meta: {}, syntheticNamedExports: false }); assert.deepStrictEqual(JSON.parse(JSON.stringify(this.getModuleInfo(ID_DEP))), { + id: ID_DEP, + attributes: {}, ast: { type: 'Program', start: 0, @@ -233,6 +315,7 @@ module.exports = { type: 'ImportDeclaration', start: 0, end: 30, + source: { type: 'Literal', start: 21, end: 29, raw: "'./lib1'", value: './lib1' }, specifiers: [ { type: 'ImportSpecifier', @@ -242,12 +325,13 @@ module.exports = { local: { type: 'Identifier', start: 9, end: 13, name: 'lib1' } } ], - source: { type: 'Literal', start: 21, end: 29, value: './lib1', raw: "'./lib1'" } + attributes: [] }, { type: 'ImportDeclaration', start: 31, end: 61, + source: { type: 'Literal', start: 52, end: 60, raw: "'./lib2'", value: './lib2' }, specifiers: [ { type: 'ImportSpecifier', @@ -257,12 +341,13 @@ module.exports = { local: { type: 'Identifier', start: 40, end: 44, name: 'lib2' } } ], - source: { type: 'Literal', start: 52, end: 60, value: './lib2', raw: "'./lib2'" } + attributes: [] }, { type: 'ImportDeclaration', start: 62, end: 92, + source: { type: 'Literal', start: 83, end: 91, raw: "'./lib3'", value: './lib3' }, specifiers: [ { type: 'ImportSpecifier', @@ -272,7 +357,7 @@ module.exports = { local: { type: 'Identifier', start: 71, end: 75, name: 'lib3' } } ], - source: { type: 'Literal', start: 83, end: 91, value: './lib3', raw: "'./lib3'" } + attributes: [] }, { type: 'ExpressionStatement', @@ -282,42 +367,77 @@ module.exports = { type: 'CallExpression', start: 93, end: 122, + arguments: [ + { type: 'Identifier', start: 105, end: 109, name: 'lib1' }, + { type: 'Identifier', start: 111, end: 115, name: 'lib2' }, + { type: 'Identifier', start: 117, end: 121, name: 'lib3' } + ], callee: { type: 'MemberExpression', start: 93, end: 104, - object: { type: 'Identifier', start: 93, end: 100, name: 'console' }, - property: { type: 'Identifier', start: 101, end: 104, name: 'log' }, computed: false, - optional: false + object: { type: 'Identifier', start: 93, end: 100, name: 'console' }, + optional: false, + property: { type: 'Identifier', start: 101, end: 104, name: 'log' } }, - arguments: [ - { type: 'Identifier', start: 105, end: 109, name: 'lib1' }, - { type: 'Identifier', start: 111, end: 115, name: 'lib2' }, - { type: 'Identifier', start: 117, end: 121, name: 'lib3' } - ], optional: false } } ], sourceType: 'module' }, - code: - "import { lib1 } from './lib1';\nimport { lib2 } from './lib2';\nimport { lib3 } from './lib3';\nconsole.log(lib1, lib2, lib3);\n", + code: "import { lib1 } from './lib1';\nimport { lib2 } from './lib2';\nimport { lib3 } from './lib3';\nconsole.log(lib1, lib2, lib3);\n", + dynamicallyImportedIdResolutions: [], dynamicallyImportedIds: [], dynamicImporters: [], - hasModuleSideEffects: true, - id: ID_DEP, + exportedBindings: { + '.': [] + }, + exports: [], + hasDefaultExport: false, + moduleSideEffects: true, + safeVariableNames: null, implicitlyLoadedAfterOneOf: [ID_MAIN1, ID_MAIN2], implicitlyLoadedBefore: [], + importedIdResolutions: [ + { + attributes: {}, + external: false, + id: ID_LIB1, + meta: {}, + moduleSideEffects: true, + resolvedBy: 'rollup', + syntheticNamedExports: false + }, + { + attributes: {}, + external: false, + id: ID_LIB2, + meta: {}, + moduleSideEffects: true, + resolvedBy: 'rollup', + syntheticNamedExports: false + }, + { + attributes: {}, + external: false, + id: ID_LIB3, + meta: {}, + moduleSideEffects: true, + resolvedBy: 'rollup', + syntheticNamedExports: false + } + ], importedIds: [ID_LIB1, ID_LIB2, ID_LIB3], importers: [], isEntry: false, isExternal: false, + isIncluded: true, meta: {}, syntheticNamedExports: false }); } } } -}; +}); diff --git a/test/chunking-form/samples/implicit-dependencies/multiple-dependencies/_expected/amd/generated-dep.js b/test/chunking-form/samples/implicit-dependencies/multiple-dependencies/_expected/amd/generated-dep.js index ea1b99d8646..f24a5f092a1 100644 --- a/test/chunking-form/samples/implicit-dependencies/multiple-dependencies/_expected/amd/generated-dep.js +++ b/test/chunking-form/samples/implicit-dependencies/multiple-dependencies/_expected/amd/generated-dep.js @@ -1,5 +1,5 @@ -define(['./generated-lib1b', './generated-lib2', './generated-lib3'], function (lib1b, lib2, lib3) { 'use strict'; +define(['./generated-lib1b', './generated-lib2', './generated-lib3'], (function (lib1b, lib2, lib3) { 'use strict'; console.log(lib1b.lib1, lib2.lib2, lib3.lib3); -}); +})); diff --git a/test/chunking-form/samples/implicit-dependencies/multiple-dependencies/_expected/amd/generated-lib1b.js b/test/chunking-form/samples/implicit-dependencies/multiple-dependencies/_expected/amd/generated-lib1b.js index 1e746aa36ce..b1c96340d53 100644 --- a/test/chunking-form/samples/implicit-dependencies/multiple-dependencies/_expected/amd/generated-lib1b.js +++ b/test/chunking-form/samples/implicit-dependencies/multiple-dependencies/_expected/amd/generated-lib1b.js @@ -1,4 +1,4 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; const lib1 = 'lib1'; @@ -7,4 +7,4 @@ define(['exports'], function (exports) { 'use strict'; exports.lib1 = lib1; exports.lib1b = lib1b; -}); +})); diff --git a/test/chunking-form/samples/implicit-dependencies/multiple-dependencies/_expected/amd/generated-lib2.js b/test/chunking-form/samples/implicit-dependencies/multiple-dependencies/_expected/amd/generated-lib2.js index 3a91d26585d..9ec4a107787 100644 --- a/test/chunking-form/samples/implicit-dependencies/multiple-dependencies/_expected/amd/generated-lib2.js +++ b/test/chunking-form/samples/implicit-dependencies/multiple-dependencies/_expected/amd/generated-lib2.js @@ -1,7 +1,7 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; const lib2 = 'lib2'; exports.lib2 = lib2; -}); +})); diff --git a/test/chunking-form/samples/implicit-dependencies/multiple-dependencies/_expected/amd/generated-lib3.js b/test/chunking-form/samples/implicit-dependencies/multiple-dependencies/_expected/amd/generated-lib3.js index 8e34d12ddf6..c9ca063d22a 100644 --- a/test/chunking-form/samples/implicit-dependencies/multiple-dependencies/_expected/amd/generated-lib3.js +++ b/test/chunking-form/samples/implicit-dependencies/multiple-dependencies/_expected/amd/generated-lib3.js @@ -1,7 +1,7 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; const lib3 = 'lib3'; exports.lib3 = lib3; -}); +})); diff --git a/test/chunking-form/samples/implicit-dependencies/multiple-dependencies/_expected/amd/main1.js b/test/chunking-form/samples/implicit-dependencies/multiple-dependencies/_expected/amd/main1.js index d8a1bed3777..b2925a0b0c7 100644 --- a/test/chunking-form/samples/implicit-dependencies/multiple-dependencies/_expected/amd/main1.js +++ b/test/chunking-form/samples/implicit-dependencies/multiple-dependencies/_expected/amd/main1.js @@ -1,5 +1,5 @@ -define(['./generated-lib1b', './generated-lib2'], function (lib1b, lib2) { 'use strict'; +define(['./generated-lib1b', './generated-lib2'], (function (lib1b, lib2) { 'use strict'; console.log('main1', lib1b.lib1, lib1b.lib1b, lib2.lib2); -}); +})); diff --git a/test/chunking-form/samples/implicit-dependencies/multiple-dependencies/_expected/amd/main2.js b/test/chunking-form/samples/implicit-dependencies/multiple-dependencies/_expected/amd/main2.js index 857eb5c0e37..f4a43aed67d 100644 --- a/test/chunking-form/samples/implicit-dependencies/multiple-dependencies/_expected/amd/main2.js +++ b/test/chunking-form/samples/implicit-dependencies/multiple-dependencies/_expected/amd/main2.js @@ -1,5 +1,5 @@ -define(['./generated-lib1b', './generated-lib3'], function (lib1b, lib3) { 'use strict'; +define(['./generated-lib1b', './generated-lib3'], (function (lib1b, lib3) { 'use strict'; console.log('main2', lib1b.lib1, lib1b.lib1b, lib3.lib3); -}); +})); diff --git a/test/chunking-form/samples/implicit-dependencies/multiple-dependencies/_expected/system/generated-dep.js b/test/chunking-form/samples/implicit-dependencies/multiple-dependencies/_expected/system/generated-dep.js index c06dd7e3890..01adc30a10a 100644 --- a/test/chunking-form/samples/implicit-dependencies/multiple-dependencies/_expected/system/generated-dep.js +++ b/test/chunking-form/samples/implicit-dependencies/multiple-dependencies/_expected/system/generated-dep.js @@ -1,4 +1,4 @@ -System.register(['./generated-lib1b.js', './generated-lib2.js', './generated-lib3.js'], function () { +System.register(['./generated-lib1b.js', './generated-lib2.js', './generated-lib3.js'], (function () { 'use strict'; var lib1, lib2, lib3; return { @@ -9,10 +9,10 @@ System.register(['./generated-lib1b.js', './generated-lib2.js', './generated-lib }, function (module) { lib3 = module.l; }], - execute: function () { + execute: (function () { console.log(lib1, lib2, lib3); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/implicit-dependencies/multiple-dependencies/_expected/system/generated-lib1b.js b/test/chunking-form/samples/implicit-dependencies/multiple-dependencies/_expected/system/generated-lib1b.js index c17dd22efe8..9fe7577f0ba 100644 --- a/test/chunking-form/samples/implicit-dependencies/multiple-dependencies/_expected/system/generated-lib1b.js +++ b/test/chunking-form/samples/implicit-dependencies/multiple-dependencies/_expected/system/generated-lib1b.js @@ -1,12 +1,12 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - const lib1 = exports('l', 'lib1'); + const lib1 = exports("l", 'lib1'); - const lib1b = exports('a', 'lib1b'); + const lib1b = exports("a", 'lib1b'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/implicit-dependencies/multiple-dependencies/_expected/system/generated-lib2.js b/test/chunking-form/samples/implicit-dependencies/multiple-dependencies/_expected/system/generated-lib2.js index 5e7dfbff411..ddb0c51daf4 100644 --- a/test/chunking-form/samples/implicit-dependencies/multiple-dependencies/_expected/system/generated-lib2.js +++ b/test/chunking-form/samples/implicit-dependencies/multiple-dependencies/_expected/system/generated-lib2.js @@ -1,10 +1,10 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - const lib2 = exports('l', 'lib2'); + const lib2 = exports("l", 'lib2'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/implicit-dependencies/multiple-dependencies/_expected/system/generated-lib3.js b/test/chunking-form/samples/implicit-dependencies/multiple-dependencies/_expected/system/generated-lib3.js index becc1e4d277..622d676762a 100644 --- a/test/chunking-form/samples/implicit-dependencies/multiple-dependencies/_expected/system/generated-lib3.js +++ b/test/chunking-form/samples/implicit-dependencies/multiple-dependencies/_expected/system/generated-lib3.js @@ -1,10 +1,10 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - const lib3 = exports('l', 'lib3'); + const lib3 = exports("l", 'lib3'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/implicit-dependencies/multiple-dependencies/_expected/system/main1.js b/test/chunking-form/samples/implicit-dependencies/multiple-dependencies/_expected/system/main1.js index 01673be260e..12f48ccd77d 100644 --- a/test/chunking-form/samples/implicit-dependencies/multiple-dependencies/_expected/system/main1.js +++ b/test/chunking-form/samples/implicit-dependencies/multiple-dependencies/_expected/system/main1.js @@ -1,4 +1,4 @@ -System.register(['./generated-lib1b.js', './generated-lib2.js'], function () { +System.register(['./generated-lib1b.js', './generated-lib2.js'], (function () { 'use strict'; var lib1, lib1b, lib2; return { @@ -8,10 +8,10 @@ System.register(['./generated-lib1b.js', './generated-lib2.js'], function () { }, function (module) { lib2 = module.l; }], - execute: function () { + execute: (function () { console.log('main1', lib1, lib1b, lib2); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/implicit-dependencies/multiple-dependencies/_expected/system/main2.js b/test/chunking-form/samples/implicit-dependencies/multiple-dependencies/_expected/system/main2.js index b6d8e2483b8..bb2381df817 100644 --- a/test/chunking-form/samples/implicit-dependencies/multiple-dependencies/_expected/system/main2.js +++ b/test/chunking-form/samples/implicit-dependencies/multiple-dependencies/_expected/system/main2.js @@ -1,4 +1,4 @@ -System.register(['./generated-lib1b.js', './generated-lib3.js'], function () { +System.register(['./generated-lib1b.js', './generated-lib3.js'], (function () { 'use strict'; var lib1, lib1b, lib3; return { @@ -8,10 +8,10 @@ System.register(['./generated-lib1b.js', './generated-lib3.js'], function () { }, function (module) { lib3 = module.l; }], - execute: function () { + execute: (function () { console.log('main2', lib1, lib1b, lib3); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/implicit-dependencies/preserve-signature-allow-extension/_config.js b/test/chunking-form/samples/implicit-dependencies/preserve-signature-allow-extension/_config.js index 63dd296f16e..ff9e2797ae9 100644 --- a/test/chunking-form/samples/implicit-dependencies/preserve-signature-allow-extension/_config.js +++ b/test/chunking-form/samples/implicit-dependencies/preserve-signature-allow-extension/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'supports implicit dependencies when emitting files', options: { plugins: { @@ -13,4 +13,4 @@ module.exports = { } } } -}; +}); diff --git a/test/chunking-form/samples/implicit-dependencies/preserve-signature-allow-extension/_expected/amd/generated-dep.js b/test/chunking-form/samples/implicit-dependencies/preserve-signature-allow-extension/_expected/amd/generated-dep.js index ace79e44c1f..72757b08553 100644 --- a/test/chunking-form/samples/implicit-dependencies/preserve-signature-allow-extension/_expected/amd/generated-dep.js +++ b/test/chunking-form/samples/implicit-dependencies/preserve-signature-allow-extension/_expected/amd/generated-dep.js @@ -1,12 +1,12 @@ -define(['require', 'exports'], function (require, exports) { 'use strict'; +define(['require', 'exports'], (function (require, exports) { 'use strict'; const value = 42; console.log(value); - new Promise(function (resolve, reject) { require(['./generated-dynamicDep'], resolve, reject) }); + new Promise(function (resolve, reject) { require(['./generated-dynamicDep'], resolve, reject); }); const dep = 'dep'; exports.dep = dep; exports.value = value; -}); +})); diff --git a/test/chunking-form/samples/implicit-dependencies/preserve-signature-allow-extension/_expected/amd/generated-dynamicDep.js b/test/chunking-form/samples/implicit-dependencies/preserve-signature-allow-extension/_expected/amd/generated-dynamicDep.js index 893ebdbd125..29be163ef89 100644 --- a/test/chunking-form/samples/implicit-dependencies/preserve-signature-allow-extension/_expected/amd/generated-dynamicDep.js +++ b/test/chunking-form/samples/implicit-dependencies/preserve-signature-allow-extension/_expected/amd/generated-dynamicDep.js @@ -1,5 +1,5 @@ -define(['./generated-dep'], function (dep) { 'use strict'; +define(['./generated-dep'], (function (dep) { 'use strict'; console.log(dep.value); -}); +})); diff --git a/test/chunking-form/samples/implicit-dependencies/preserve-signature-allow-extension/_expected/amd/main.js b/test/chunking-form/samples/implicit-dependencies/preserve-signature-allow-extension/_expected/amd/main.js index 126aa22ee83..49540b44d78 100644 --- a/test/chunking-form/samples/implicit-dependencies/preserve-signature-allow-extension/_expected/amd/main.js +++ b/test/chunking-form/samples/implicit-dependencies/preserve-signature-allow-extension/_expected/amd/main.js @@ -1,5 +1,5 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; console.log('main'); -}); +})); diff --git a/test/chunking-form/samples/implicit-dependencies/preserve-signature-allow-extension/_expected/system/generated-dep.js b/test/chunking-form/samples/implicit-dependencies/preserve-signature-allow-extension/_expected/system/generated-dep.js index 7839cea8005..9ce9f360603 100644 --- a/test/chunking-form/samples/implicit-dependencies/preserve-signature-allow-extension/_expected/system/generated-dep.js +++ b/test/chunking-form/samples/implicit-dependencies/preserve-signature-allow-extension/_expected/system/generated-dep.js @@ -1,14 +1,14 @@ -System.register([], function (exports, module) { +System.register([], (function (exports, module) { 'use strict'; return { - execute: function () { + execute: (function () { - const value = exports('v', 42); + const value = exports("v", 42); console.log(value); module.import('./generated-dynamicDep.js'); - const dep = exports('dep', 'dep'); + const dep = exports("dep", 'dep'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/implicit-dependencies/preserve-signature-allow-extension/_expected/system/generated-dynamicDep.js b/test/chunking-form/samples/implicit-dependencies/preserve-signature-allow-extension/_expected/system/generated-dynamicDep.js index b6f1df26e00..f7e6e21a538 100644 --- a/test/chunking-form/samples/implicit-dependencies/preserve-signature-allow-extension/_expected/system/generated-dynamicDep.js +++ b/test/chunking-form/samples/implicit-dependencies/preserve-signature-allow-extension/_expected/system/generated-dynamicDep.js @@ -1,14 +1,14 @@ -System.register(['./generated-dep.js'], function () { +System.register(['./generated-dep.js'], (function () { 'use strict'; var value; return { setters: [function (module) { value = module.v; }], - execute: function () { + execute: (function () { console.log(value); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/implicit-dependencies/preserve-signature-allow-extension/_expected/system/main.js b/test/chunking-form/samples/implicit-dependencies/preserve-signature-allow-extension/_expected/system/main.js index c83499bc2d4..35e2693371a 100644 --- a/test/chunking-form/samples/implicit-dependencies/preserve-signature-allow-extension/_expected/system/main.js +++ b/test/chunking-form/samples/implicit-dependencies/preserve-signature-allow-extension/_expected/system/main.js @@ -1,10 +1,10 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { console.log('main'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/implicit-dependencies/preserve-signature-false/_config.js b/test/chunking-form/samples/implicit-dependencies/preserve-signature-false/_config.js index e55905d0227..8e53b933b32 100644 --- a/test/chunking-form/samples/implicit-dependencies/preserve-signature-false/_config.js +++ b/test/chunking-form/samples/implicit-dependencies/preserve-signature-false/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'supports implicit dependencies when emitting files', options: { plugins: { @@ -13,4 +13,4 @@ module.exports = { } } } -}; +}); diff --git a/test/chunking-form/samples/implicit-dependencies/preserve-signature-false/_expected/amd/generated-dep.js b/test/chunking-form/samples/implicit-dependencies/preserve-signature-false/_expected/amd/generated-dep.js index e56c2be819e..530dd19cfef 100644 --- a/test/chunking-form/samples/implicit-dependencies/preserve-signature-false/_expected/amd/generated-dep.js +++ b/test/chunking-form/samples/implicit-dependencies/preserve-signature-false/_expected/amd/generated-dep.js @@ -1,10 +1,10 @@ -define(['require', 'exports'], function (require, exports) { 'use strict'; +define(['require', 'exports'], (function (require, exports) { 'use strict'; const value = 42; console.log(value); - new Promise(function (resolve, reject) { require(['./generated-dynamicDep'], resolve, reject) }); + new Promise(function (resolve, reject) { require(['./generated-dynamicDep'], resolve, reject); }); exports.value = value; -}); +})); diff --git a/test/chunking-form/samples/implicit-dependencies/preserve-signature-false/_expected/amd/generated-dynamicDep.js b/test/chunking-form/samples/implicit-dependencies/preserve-signature-false/_expected/amd/generated-dynamicDep.js index 893ebdbd125..29be163ef89 100644 --- a/test/chunking-form/samples/implicit-dependencies/preserve-signature-false/_expected/amd/generated-dynamicDep.js +++ b/test/chunking-form/samples/implicit-dependencies/preserve-signature-false/_expected/amd/generated-dynamicDep.js @@ -1,5 +1,5 @@ -define(['./generated-dep'], function (dep) { 'use strict'; +define(['./generated-dep'], (function (dep) { 'use strict'; console.log(dep.value); -}); +})); diff --git a/test/chunking-form/samples/implicit-dependencies/preserve-signature-false/_expected/amd/main.js b/test/chunking-form/samples/implicit-dependencies/preserve-signature-false/_expected/amd/main.js index 126aa22ee83..49540b44d78 100644 --- a/test/chunking-form/samples/implicit-dependencies/preserve-signature-false/_expected/amd/main.js +++ b/test/chunking-form/samples/implicit-dependencies/preserve-signature-false/_expected/amd/main.js @@ -1,5 +1,5 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; console.log('main'); -}); +})); diff --git a/test/chunking-form/samples/implicit-dependencies/preserve-signature-false/_expected/system/generated-dep.js b/test/chunking-form/samples/implicit-dependencies/preserve-signature-false/_expected/system/generated-dep.js index e896163f238..f0508890589 100644 --- a/test/chunking-form/samples/implicit-dependencies/preserve-signature-false/_expected/system/generated-dep.js +++ b/test/chunking-form/samples/implicit-dependencies/preserve-signature-false/_expected/system/generated-dep.js @@ -1,13 +1,13 @@ -System.register([], function (exports, module) { +System.register([], (function (exports, module) { 'use strict'; return { - execute: function () { + execute: (function () { - const value = exports('v', 42); + const value = exports("v", 42); console.log(value); module.import('./generated-dynamicDep.js'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/implicit-dependencies/preserve-signature-false/_expected/system/generated-dynamicDep.js b/test/chunking-form/samples/implicit-dependencies/preserve-signature-false/_expected/system/generated-dynamicDep.js index b6f1df26e00..f7e6e21a538 100644 --- a/test/chunking-form/samples/implicit-dependencies/preserve-signature-false/_expected/system/generated-dynamicDep.js +++ b/test/chunking-form/samples/implicit-dependencies/preserve-signature-false/_expected/system/generated-dynamicDep.js @@ -1,14 +1,14 @@ -System.register(['./generated-dep.js'], function () { +System.register(['./generated-dep.js'], (function () { 'use strict'; var value; return { setters: [function (module) { value = module.v; }], - execute: function () { + execute: (function () { console.log(value); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/implicit-dependencies/preserve-signature-false/_expected/system/main.js b/test/chunking-form/samples/implicit-dependencies/preserve-signature-false/_expected/system/main.js index c83499bc2d4..35e2693371a 100644 --- a/test/chunking-form/samples/implicit-dependencies/preserve-signature-false/_expected/system/main.js +++ b/test/chunking-form/samples/implicit-dependencies/preserve-signature-false/_expected/system/main.js @@ -1,10 +1,10 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { console.log('main'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/implicit-dependencies/preserve-signature-strict/_config.js b/test/chunking-form/samples/implicit-dependencies/preserve-signature-strict/_config.js index e86db665836..043608e0981 100644 --- a/test/chunking-form/samples/implicit-dependencies/preserve-signature-strict/_config.js +++ b/test/chunking-form/samples/implicit-dependencies/preserve-signature-strict/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'supports implicit dependencies when emitting files', options: { plugins: { @@ -13,4 +13,4 @@ module.exports = { } } } -}; +}); diff --git a/test/chunking-form/samples/implicit-dependencies/preserve-signature-strict/_expected/amd/generated-dep.js b/test/chunking-form/samples/implicit-dependencies/preserve-signature-strict/_expected/amd/generated-dep.js index ace79e44c1f..72757b08553 100644 --- a/test/chunking-form/samples/implicit-dependencies/preserve-signature-strict/_expected/amd/generated-dep.js +++ b/test/chunking-form/samples/implicit-dependencies/preserve-signature-strict/_expected/amd/generated-dep.js @@ -1,12 +1,12 @@ -define(['require', 'exports'], function (require, exports) { 'use strict'; +define(['require', 'exports'], (function (require, exports) { 'use strict'; const value = 42; console.log(value); - new Promise(function (resolve, reject) { require(['./generated-dynamicDep'], resolve, reject) }); + new Promise(function (resolve, reject) { require(['./generated-dynamicDep'], resolve, reject); }); const dep = 'dep'; exports.dep = dep; exports.value = value; -}); +})); diff --git a/test/chunking-form/samples/implicit-dependencies/preserve-signature-strict/_expected/amd/generated-dep2.js b/test/chunking-form/samples/implicit-dependencies/preserve-signature-strict/_expected/amd/generated-dep2.js index 86c7cf798d5..db82d89d61e 100644 --- a/test/chunking-form/samples/implicit-dependencies/preserve-signature-strict/_expected/amd/generated-dep2.js +++ b/test/chunking-form/samples/implicit-dependencies/preserve-signature-strict/_expected/amd/generated-dep2.js @@ -1,7 +1,7 @@ -define(['exports', './generated-dep'], function (exports, dep) { 'use strict'; +define(['exports', './generated-dep'], (function (exports, dep) { 'use strict'; exports.dep = dep.dep; -}); +})); diff --git a/test/chunking-form/samples/implicit-dependencies/preserve-signature-strict/_expected/amd/generated-dynamicDep.js b/test/chunking-form/samples/implicit-dependencies/preserve-signature-strict/_expected/amd/generated-dynamicDep.js index 893ebdbd125..29be163ef89 100644 --- a/test/chunking-form/samples/implicit-dependencies/preserve-signature-strict/_expected/amd/generated-dynamicDep.js +++ b/test/chunking-form/samples/implicit-dependencies/preserve-signature-strict/_expected/amd/generated-dynamicDep.js @@ -1,5 +1,5 @@ -define(['./generated-dep'], function (dep) { 'use strict'; +define(['./generated-dep'], (function (dep) { 'use strict'; console.log(dep.value); -}); +})); diff --git a/test/chunking-form/samples/implicit-dependencies/preserve-signature-strict/_expected/amd/main.js b/test/chunking-form/samples/implicit-dependencies/preserve-signature-strict/_expected/amd/main.js index 126aa22ee83..49540b44d78 100644 --- a/test/chunking-form/samples/implicit-dependencies/preserve-signature-strict/_expected/amd/main.js +++ b/test/chunking-form/samples/implicit-dependencies/preserve-signature-strict/_expected/amd/main.js @@ -1,5 +1,5 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; console.log('main'); -}); +})); diff --git a/test/chunking-form/samples/implicit-dependencies/preserve-signature-strict/_expected/system/generated-dep.js b/test/chunking-form/samples/implicit-dependencies/preserve-signature-strict/_expected/system/generated-dep.js index d59f5cecfbc..bb9d9ed8539 100644 --- a/test/chunking-form/samples/implicit-dependencies/preserve-signature-strict/_expected/system/generated-dep.js +++ b/test/chunking-form/samples/implicit-dependencies/preserve-signature-strict/_expected/system/generated-dep.js @@ -1,14 +1,14 @@ -System.register([], function (exports, module) { +System.register([], (function (exports, module) { 'use strict'; return { - execute: function () { + execute: (function () { - const value = exports('v', 42); + const value = exports("v", 42); console.log(value); module.import('./generated-dynamicDep.js'); - const dep = exports('d', 'dep'); + const dep = exports("d", 'dep'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/implicit-dependencies/preserve-signature-strict/_expected/system/generated-dep2.js b/test/chunking-form/samples/implicit-dependencies/preserve-signature-strict/_expected/system/generated-dep2.js index f2b92ab1de9..5931abe6b64 100644 --- a/test/chunking-form/samples/implicit-dependencies/preserve-signature-strict/_expected/system/generated-dep2.js +++ b/test/chunking-form/samples/implicit-dependencies/preserve-signature-strict/_expected/system/generated-dep2.js @@ -1,13 +1,13 @@ -System.register(['./generated-dep.js'], function (exports) { +System.register(['./generated-dep.js'], (function (exports) { 'use strict'; return { setters: [function (module) { - exports('dep', module.d); + exports("dep", module.d); }], - execute: function () { + execute: (function () { - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/implicit-dependencies/preserve-signature-strict/_expected/system/generated-dynamicDep.js b/test/chunking-form/samples/implicit-dependencies/preserve-signature-strict/_expected/system/generated-dynamicDep.js index b6f1df26e00..f7e6e21a538 100644 --- a/test/chunking-form/samples/implicit-dependencies/preserve-signature-strict/_expected/system/generated-dynamicDep.js +++ b/test/chunking-form/samples/implicit-dependencies/preserve-signature-strict/_expected/system/generated-dynamicDep.js @@ -1,14 +1,14 @@ -System.register(['./generated-dep.js'], function () { +System.register(['./generated-dep.js'], (function () { 'use strict'; var value; return { setters: [function (module) { value = module.v; }], - execute: function () { + execute: (function () { console.log(value); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/implicit-dependencies/preserve-signature-strict/_expected/system/main.js b/test/chunking-form/samples/implicit-dependencies/preserve-signature-strict/_expected/system/main.js index c83499bc2d4..35e2693371a 100644 --- a/test/chunking-form/samples/implicit-dependencies/preserve-signature-strict/_expected/system/main.js +++ b/test/chunking-form/samples/implicit-dependencies/preserve-signature-strict/_expected/system/main.js @@ -1,10 +1,10 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { console.log('main'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/implicit-dependencies/same-chunk-dependency/_config.js b/test/chunking-form/samples/implicit-dependencies/same-chunk-dependency/_config.js index 7a8a24e60f4..16f322ebcc5 100644 --- a/test/chunking-form/samples/implicit-dependencies/same-chunk-dependency/_config.js +++ b/test/chunking-form/samples/implicit-dependencies/same-chunk-dependency/_config.js @@ -1,8 +1,8 @@ -const assert = require('assert'); +const assert = require('node:assert'); let referenceId; -module.exports = { +module.exports = defineTest({ description: 'handles implicit dependencies where the dependant is inlined into the same chunk', expectedWarnings: ['CIRCULAR_DEPENDENCY'], options: { @@ -20,4 +20,4 @@ module.exports = { } } } -}; +}); diff --git a/test/chunking-form/samples/implicit-dependencies/same-chunk-dependency/_expected/amd/generated-dep.js b/test/chunking-form/samples/implicit-dependencies/same-chunk-dependency/_expected/amd/generated-dep.js index 450a2f3156d..64b2b078d0e 100644 --- a/test/chunking-form/samples/implicit-dependencies/same-chunk-dependency/_expected/amd/generated-dep.js +++ b/test/chunking-form/samples/implicit-dependencies/same-chunk-dependency/_expected/amd/generated-dep.js @@ -1,7 +1,7 @@ -define(['exports', './generated-lib'], function (exports, dep) { 'use strict'; +define(['exports', './generated-lib'], (function (exports, dep) { 'use strict'; exports.dep = dep.dep; -}); +})); diff --git a/test/chunking-form/samples/implicit-dependencies/same-chunk-dependency/_expected/amd/generated-lib.js b/test/chunking-form/samples/implicit-dependencies/same-chunk-dependency/_expected/amd/generated-lib.js index 3f7dd30a55b..b37d0f74a71 100644 --- a/test/chunking-form/samples/implicit-dependencies/same-chunk-dependency/_expected/amd/generated-lib.js +++ b/test/chunking-form/samples/implicit-dependencies/same-chunk-dependency/_expected/amd/generated-lib.js @@ -1,4 +1,4 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; const dep = 'dep'; @@ -11,4 +11,4 @@ define(['exports'], function (exports) { 'use strict'; exports.dep = dep; exports.lib = lib; -}); +})); diff --git a/test/chunking-form/samples/implicit-dependencies/same-chunk-dependency/_expected/amd/main.js b/test/chunking-form/samples/implicit-dependencies/same-chunk-dependency/_expected/amd/main.js index 54b624a33e0..90aeaea3795 100644 --- a/test/chunking-form/samples/implicit-dependencies/same-chunk-dependency/_expected/amd/main.js +++ b/test/chunking-form/samples/implicit-dependencies/same-chunk-dependency/_expected/amd/main.js @@ -1,5 +1,5 @@ -define(['require'], function (require) { 'use strict'; +define(['require'], (function (require) { 'use strict'; - new Promise(function (resolve, reject) { require(['./generated-lib'], resolve, reject) }).then(function (n) { return n.lib; }); + new Promise(function (resolve, reject) { require(['./generated-lib'], resolve, reject); }).then(function (n) { return n.lib; }); -}); +})); diff --git a/test/chunking-form/samples/implicit-dependencies/same-chunk-dependency/_expected/system/generated-dep.js b/test/chunking-form/samples/implicit-dependencies/same-chunk-dependency/_expected/system/generated-dep.js index 8730939120a..348d9baaf46 100644 --- a/test/chunking-form/samples/implicit-dependencies/same-chunk-dependency/_expected/system/generated-dep.js +++ b/test/chunking-form/samples/implicit-dependencies/same-chunk-dependency/_expected/system/generated-dep.js @@ -1,13 +1,13 @@ -System.register(['./generated-lib.js'], function (exports) { +System.register(['./generated-lib.js'], (function (exports) { 'use strict'; return { setters: [function (module) { - exports('dep', module.d); + exports("dep", module.d); }], - execute: function () { + execute: (function () { - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/implicit-dependencies/same-chunk-dependency/_expected/system/generated-lib.js b/test/chunking-form/samples/implicit-dependencies/same-chunk-dependency/_expected/system/generated-lib.js index 6c4233b1634..1e8df0a997b 100644 --- a/test/chunking-form/samples/implicit-dependencies/same-chunk-dependency/_expected/system/generated-lib.js +++ b/test/chunking-form/samples/implicit-dependencies/same-chunk-dependency/_expected/system/generated-lib.js @@ -1,17 +1,17 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - const dep = exports('d', 'dep'); + const dep = exports("d", 'dep'); console.log('lib', dep); var lib = /*#__PURE__*/Object.freeze({ __proto__: null }); - exports('l', lib); + exports("l", lib); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/implicit-dependencies/same-chunk-dependency/_expected/system/main.js b/test/chunking-form/samples/implicit-dependencies/same-chunk-dependency/_expected/system/main.js index 82ee3811fec..921b536b5a1 100644 --- a/test/chunking-form/samples/implicit-dependencies/same-chunk-dependency/_expected/system/main.js +++ b/test/chunking-form/samples/implicit-dependencies/same-chunk-dependency/_expected/system/main.js @@ -1,10 +1,10 @@ -System.register([], function (exports, module) { +System.register([], (function (exports, module) { 'use strict'; return { - execute: function () { + execute: (function () { module.import('./generated-lib.js').then(function (n) { return n.l; }); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/implicit-dependencies/shared-dependency-no-side-effect/_config.js b/test/chunking-form/samples/implicit-dependencies/shared-dependency-no-side-effect/_config.js index 564795d4540..fc4638d4966 100644 --- a/test/chunking-form/samples/implicit-dependencies/shared-dependency-no-side-effect/_config.js +++ b/test/chunking-form/samples/implicit-dependencies/shared-dependency-no-side-effect/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'handles shared dependencies between implicit chunks without side-effects', options: { plugins: { @@ -17,4 +17,4 @@ module.exports = { } } } -}; +}); diff --git a/test/chunking-form/samples/implicit-dependencies/shared-dependency-no-side-effect/_expected/amd/generated-button.js b/test/chunking-form/samples/implicit-dependencies/shared-dependency-no-side-effect/_expected/amd/generated-button.js index dcdda160dd4..c27633ed2d9 100644 --- a/test/chunking-form/samples/implicit-dependencies/shared-dependency-no-side-effect/_expected/amd/generated-button.js +++ b/test/chunking-form/samples/implicit-dependencies/shared-dependency-no-side-effect/_expected/amd/generated-button.js @@ -1,7 +1,7 @@ -define(['exports', './main'], function (exports, main) { 'use strict'; +define(['exports', './main'], (function (exports, main) { 'use strict'; const bar = main.foo + 'bar'; exports.bar = bar; -}); +})); diff --git a/test/chunking-form/samples/implicit-dependencies/shared-dependency-no-side-effect/_expected/amd/generated-core.js b/test/chunking-form/samples/implicit-dependencies/shared-dependency-no-side-effect/_expected/amd/generated-core.js index 3bfac6f7283..0a2932d5d9f 100644 --- a/test/chunking-form/samples/implicit-dependencies/shared-dependency-no-side-effect/_expected/amd/generated-core.js +++ b/test/chunking-form/samples/implicit-dependencies/shared-dependency-no-side-effect/_expected/amd/generated-core.js @@ -1,7 +1,7 @@ -define(['exports', './main'], function (exports, main) { 'use strict'; +define(['exports', './main'], (function (exports, main) { 'use strict'; exports.foo = main.foo; -}); +})); diff --git a/test/chunking-form/samples/implicit-dependencies/shared-dependency-no-side-effect/_expected/amd/main.js b/test/chunking-form/samples/implicit-dependencies/shared-dependency-no-side-effect/_expected/amd/main.js index f29cbae64fc..6fd637014ea 100644 --- a/test/chunking-form/samples/implicit-dependencies/shared-dependency-no-side-effect/_expected/amd/main.js +++ b/test/chunking-form/samples/implicit-dependencies/shared-dependency-no-side-effect/_expected/amd/main.js @@ -1,9 +1,7 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; const foo = 'foo'; exports.foo = foo; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/implicit-dependencies/shared-dependency-no-side-effect/_expected/cjs/main.js b/test/chunking-form/samples/implicit-dependencies/shared-dependency-no-side-effect/_expected/cjs/main.js index de59b01ec34..71c76a07cc0 100644 --- a/test/chunking-form/samples/implicit-dependencies/shared-dependency-no-side-effect/_expected/cjs/main.js +++ b/test/chunking-form/samples/implicit-dependencies/shared-dependency-no-side-effect/_expected/cjs/main.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - const foo = 'foo'; exports.foo = foo; diff --git a/test/chunking-form/samples/implicit-dependencies/shared-dependency-no-side-effect/_expected/system/generated-button.js b/test/chunking-form/samples/implicit-dependencies/shared-dependency-no-side-effect/_expected/system/generated-button.js index 20fca3e203f..5e9f54f6ebc 100644 --- a/test/chunking-form/samples/implicit-dependencies/shared-dependency-no-side-effect/_expected/system/generated-button.js +++ b/test/chunking-form/samples/implicit-dependencies/shared-dependency-no-side-effect/_expected/system/generated-button.js @@ -1,14 +1,14 @@ -System.register(['./main.js'], function (exports) { +System.register(['./main.js'], (function (exports) { 'use strict'; var foo; return { setters: [function (module) { foo = module.foo; }], - execute: function () { + execute: (function () { - const bar = exports('bar', foo + 'bar'); + const bar = exports("bar", foo + 'bar'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/implicit-dependencies/shared-dependency-no-side-effect/_expected/system/generated-core.js b/test/chunking-form/samples/implicit-dependencies/shared-dependency-no-side-effect/_expected/system/generated-core.js index e5c120e06a1..ddb9a4180ee 100644 --- a/test/chunking-form/samples/implicit-dependencies/shared-dependency-no-side-effect/_expected/system/generated-core.js +++ b/test/chunking-form/samples/implicit-dependencies/shared-dependency-no-side-effect/_expected/system/generated-core.js @@ -1,13 +1,13 @@ -System.register(['./main.js'], function (exports) { +System.register(['./main.js'], (function (exports) { 'use strict'; return { setters: [function (module) { - exports('foo', module.foo); + exports("foo", module.foo); }], - execute: function () { + execute: (function () { - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/implicit-dependencies/shared-dependency-no-side-effect/_expected/system/main.js b/test/chunking-form/samples/implicit-dependencies/shared-dependency-no-side-effect/_expected/system/main.js index 245b6107a44..99f811f3faa 100644 --- a/test/chunking-form/samples/implicit-dependencies/shared-dependency-no-side-effect/_expected/system/main.js +++ b/test/chunking-form/samples/implicit-dependencies/shared-dependency-no-side-effect/_expected/system/main.js @@ -1,10 +1,10 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - const foo = exports('foo', 'foo'); + const foo = exports("foo", 'foo'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/implicit-dependencies/shared-dependency-reexport/_config.js b/test/chunking-form/samples/implicit-dependencies/shared-dependency-reexport/_config.js index c3fa81549a0..5d10f4c5a8c 100644 --- a/test/chunking-form/samples/implicit-dependencies/shared-dependency-reexport/_config.js +++ b/test/chunking-form/samples/implicit-dependencies/shared-dependency-reexport/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'handles shared dependencies when there are only reexports', options: { plugins: { @@ -12,4 +12,4 @@ module.exports = { } } } -}; +}); diff --git a/test/chunking-form/samples/implicit-dependencies/shared-dependency-reexport/_expected/amd/generated-implicit.js b/test/chunking-form/samples/implicit-dependencies/shared-dependency-reexport/_expected/amd/generated-implicit.js index 3bfac6f7283..0a2932d5d9f 100644 --- a/test/chunking-form/samples/implicit-dependencies/shared-dependency-reexport/_expected/amd/generated-implicit.js +++ b/test/chunking-form/samples/implicit-dependencies/shared-dependency-reexport/_expected/amd/generated-implicit.js @@ -1,7 +1,7 @@ -define(['exports', './main'], function (exports, main) { 'use strict'; +define(['exports', './main'], (function (exports, main) { 'use strict'; exports.foo = main.foo; -}); +})); diff --git a/test/chunking-form/samples/implicit-dependencies/shared-dependency-reexport/_expected/amd/main.js b/test/chunking-form/samples/implicit-dependencies/shared-dependency-reexport/_expected/amd/main.js index d352033857d..069c69d1b48 100644 --- a/test/chunking-form/samples/implicit-dependencies/shared-dependency-reexport/_expected/amd/main.js +++ b/test/chunking-form/samples/implicit-dependencies/shared-dependency-reexport/_expected/amd/main.js @@ -1,9 +1,7 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; const foo = 'shared'; exports.foo = foo; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/implicit-dependencies/shared-dependency-reexport/_expected/cjs/main.js b/test/chunking-form/samples/implicit-dependencies/shared-dependency-reexport/_expected/cjs/main.js index 686f63da865..5c12b1c2f79 100644 --- a/test/chunking-form/samples/implicit-dependencies/shared-dependency-reexport/_expected/cjs/main.js +++ b/test/chunking-form/samples/implicit-dependencies/shared-dependency-reexport/_expected/cjs/main.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - const foo = 'shared'; exports.foo = foo; diff --git a/test/chunking-form/samples/implicit-dependencies/shared-dependency-reexport/_expected/system/generated-implicit.js b/test/chunking-form/samples/implicit-dependencies/shared-dependency-reexport/_expected/system/generated-implicit.js index e5c120e06a1..ddb9a4180ee 100644 --- a/test/chunking-form/samples/implicit-dependencies/shared-dependency-reexport/_expected/system/generated-implicit.js +++ b/test/chunking-form/samples/implicit-dependencies/shared-dependency-reexport/_expected/system/generated-implicit.js @@ -1,13 +1,13 @@ -System.register(['./main.js'], function (exports) { +System.register(['./main.js'], (function (exports) { 'use strict'; return { setters: [function (module) { - exports('foo', module.foo); + exports("foo", module.foo); }], - execute: function () { + execute: (function () { - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/implicit-dependencies/shared-dependency-reexport/_expected/system/main.js b/test/chunking-form/samples/implicit-dependencies/shared-dependency-reexport/_expected/system/main.js index bef2b3726fe..3a61bacb1f3 100644 --- a/test/chunking-form/samples/implicit-dependencies/shared-dependency-reexport/_expected/system/main.js +++ b/test/chunking-form/samples/implicit-dependencies/shared-dependency-reexport/_expected/system/main.js @@ -1,10 +1,10 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - const foo = exports('foo', 'shared'); + const foo = exports("foo", 'shared'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/implicit-dependencies/single-dependency/_config.js b/test/chunking-form/samples/implicit-dependencies/single-dependency/_config.js index 1ef3f4bf156..4724ecd3e52 100644 --- a/test/chunking-form/samples/implicit-dependencies/single-dependency/_config.js +++ b/test/chunking-form/samples/implicit-dependencies/single-dependency/_config.js @@ -1,11 +1,11 @@ -const path = require('path'); -const assert = require('assert'); +const assert = require('node:assert'); +const path = require('node:path'); const ID_MAIN = path.join(__dirname, 'main.js'); const ID_LIB = path.join(__dirname, 'lib.js'); const ID_DEP = path.join(__dirname, 'dep.js'); -module.exports = { +module.exports = defineTest({ description: 'supports implicit dependencies when emitting files', options: { preserveEntrySignatures: 'allow-extension', @@ -20,6 +20,8 @@ module.exports = { }, buildEnd() { assert.deepStrictEqual(JSON.parse(JSON.stringify(this.getModuleInfo(ID_MAIN))), { + id: ID_MAIN, + attributes: {}, ast: { type: 'Program', start: 0, @@ -29,6 +31,7 @@ module.exports = { type: 'ImportDeclaration', start: 0, end: 30, + source: { type: 'Literal', start: 22, end: 29, raw: "'./lib'", value: './lib' }, specifiers: [ { type: 'ImportSpecifier', @@ -38,7 +41,7 @@ module.exports = { local: { type: 'Identifier', start: 9, end: 14, name: 'value' } } ], - source: { type: 'Literal', start: 22, end: 29, value: './lib', raw: "'./lib'" } + attributes: [] }, { type: 'ExpressionStatement', @@ -48,16 +51,16 @@ module.exports = { type: 'CallExpression', start: 31, end: 49, + arguments: [{ type: 'Identifier', start: 43, end: 48, name: 'value' }], callee: { type: 'MemberExpression', start: 31, end: 42, - object: { type: 'Identifier', start: 31, end: 38, name: 'console' }, - property: { type: 'Identifier', start: 39, end: 42, name: 'log' }, computed: false, - optional: false + object: { type: 'Identifier', start: 31, end: 38, name: 'console' }, + optional: false, + property: { type: 'Identifier', start: 39, end: 42, name: 'log' } }, - arguments: [{ type: 'Identifier', start: 43, end: 48, name: 'value' }], optional: false } } @@ -65,20 +68,40 @@ module.exports = { sourceType: 'module' }, code: "import { value } from './lib';\nconsole.log(value);\n", + dynamicallyImportedIdResolutions: [], dynamicallyImportedIds: [], dynamicImporters: [], - hasModuleSideEffects: true, - id: ID_MAIN, + exportedBindings: { + '.': [] + }, + exports: [], + hasDefaultExport: false, + moduleSideEffects: true, implicitlyLoadedAfterOneOf: [], implicitlyLoadedBefore: [ID_DEP], + importedIdResolutions: [ + { + attributes: {}, + external: false, + id: ID_LIB, + meta: {}, + moduleSideEffects: true, + resolvedBy: 'rollup', + syntheticNamedExports: false + } + ], importedIds: [ID_LIB], importers: [], isEntry: true, isExternal: false, + isIncluded: true, meta: {}, + safeVariableNames: null, syntheticNamedExports: false }); assert.deepStrictEqual(JSON.parse(JSON.stringify(this.getModuleInfo(ID_DEP))), { + id: ID_DEP, + attributes: {}, ast: { type: 'Program', start: 0, @@ -88,6 +111,7 @@ module.exports = { type: 'ImportDeclaration', start: 0, end: 30, + source: { type: 'Literal', start: 22, end: 29, raw: "'./lib'", value: './lib' }, specifiers: [ { type: 'ImportSpecifier', @@ -97,7 +121,7 @@ module.exports = { local: { type: 'Identifier', start: 9, end: 14, name: 'value' } } ], - source: { type: 'Literal', start: 22, end: 29, value: './lib', raw: "'./lib'" } + attributes: [] }, { type: 'ExpressionStatement', @@ -107,16 +131,16 @@ module.exports = { type: 'CallExpression', start: 31, end: 49, + arguments: [{ type: 'Identifier', start: 43, end: 48, name: 'value' }], callee: { type: 'MemberExpression', start: 31, end: 42, - object: { type: 'Identifier', start: 31, end: 38, name: 'console' }, - property: { type: 'Identifier', start: 39, end: 42, name: 'log' }, computed: false, - optional: false + object: { type: 'Identifier', start: 31, end: 38, name: 'console' }, + optional: false, + property: { type: 'Identifier', start: 39, end: 42, name: 'log' } }, - arguments: [{ type: 'Identifier', start: 43, end: 48, name: 'value' }], optional: false } } @@ -124,17 +148,35 @@ module.exports = { sourceType: 'module' }, code: "import { value } from './lib';\nconsole.log(value);\n", + dynamicallyImportedIdResolutions: [], dynamicallyImportedIds: [], dynamicImporters: [], - hasModuleSideEffects: true, - id: ID_DEP, + exportedBindings: { + '.': [] + }, + exports: [], + hasDefaultExport: false, + moduleSideEffects: true, implicitlyLoadedAfterOneOf: [ID_MAIN], implicitlyLoadedBefore: [], + importedIdResolutions: [ + { + attributes: {}, + external: false, + id: ID_LIB, + meta: {}, + moduleSideEffects: true, + resolvedBy: 'rollup', + syntheticNamedExports: false + } + ], importedIds: [ID_LIB], importers: [], isEntry: false, isExternal: false, + isIncluded: true, meta: {}, + safeVariableNames: null, syntheticNamedExports: false }); }, @@ -156,4 +198,4 @@ module.exports = { } } } -}; +}); diff --git a/test/chunking-form/samples/implicit-dependencies/single-dependency/_expected/amd/generated-dep.js b/test/chunking-form/samples/implicit-dependencies/single-dependency/_expected/amd/generated-dep.js index 162f76d7b67..3f902234397 100644 --- a/test/chunking-form/samples/implicit-dependencies/single-dependency/_expected/amd/generated-dep.js +++ b/test/chunking-form/samples/implicit-dependencies/single-dependency/_expected/amd/generated-dep.js @@ -1,5 +1,5 @@ -define(['./main'], function (main) { 'use strict'; +define(['./main'], (function (main) { 'use strict'; console.log(main.value); -}); +})); diff --git a/test/chunking-form/samples/implicit-dependencies/single-dependency/_expected/amd/main.js b/test/chunking-form/samples/implicit-dependencies/single-dependency/_expected/amd/main.js index c9a3a6e48b1..609c853c574 100644 --- a/test/chunking-form/samples/implicit-dependencies/single-dependency/_expected/amd/main.js +++ b/test/chunking-form/samples/implicit-dependencies/single-dependency/_expected/amd/main.js @@ -1,4 +1,4 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; const value = 42; @@ -6,6 +6,4 @@ define(['exports'], function (exports) { 'use strict'; exports.value = value; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/implicit-dependencies/single-dependency/_expected/cjs/main.js b/test/chunking-form/samples/implicit-dependencies/single-dependency/_expected/cjs/main.js index 4677b07af09..a8d51732214 100644 --- a/test/chunking-form/samples/implicit-dependencies/single-dependency/_expected/cjs/main.js +++ b/test/chunking-form/samples/implicit-dependencies/single-dependency/_expected/cjs/main.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - const value = 42; console.log(value); diff --git a/test/chunking-form/samples/implicit-dependencies/single-dependency/_expected/system/generated-dep.js b/test/chunking-form/samples/implicit-dependencies/single-dependency/_expected/system/generated-dep.js index 478948525f1..5c111e397a1 100644 --- a/test/chunking-form/samples/implicit-dependencies/single-dependency/_expected/system/generated-dep.js +++ b/test/chunking-form/samples/implicit-dependencies/single-dependency/_expected/system/generated-dep.js @@ -1,14 +1,14 @@ -System.register(['./main.js'], function () { +System.register(['./main.js'], (function () { 'use strict'; var value; return { setters: [function (module) { value = module.v; }], - execute: function () { + execute: (function () { console.log(value); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/implicit-dependencies/single-dependency/_expected/system/main.js b/test/chunking-form/samples/implicit-dependencies/single-dependency/_expected/system/main.js index dbbc960c503..a554aa797c5 100644 --- a/test/chunking-form/samples/implicit-dependencies/single-dependency/_expected/system/main.js +++ b/test/chunking-form/samples/implicit-dependencies/single-dependency/_expected/system/main.js @@ -1,12 +1,12 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - const value = exports('v', 42); + const value = exports("v", 42); console.log(value); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/import-meta-numeric-paths/0/1/nested.js b/test/chunking-form/samples/import-meta-numeric-paths/0/1/nested.js new file mode 100644 index 00000000000..bdeb009362b --- /dev/null +++ b/test/chunking-form/samples/import-meta-numeric-paths/0/1/nested.js @@ -0,0 +1 @@ +export const url = import.meta.url; diff --git a/test/chunking-form/samples/import-meta-numeric-paths/_config.js b/test/chunking-form/samples/import-meta-numeric-paths/_config.js new file mode 100644 index 00000000000..9d622265857 --- /dev/null +++ b/test/chunking-form/samples/import-meta-numeric-paths/_config.js @@ -0,0 +1,16 @@ +const assert = require('node:assert'); + +module.exports = defineTest({ + description: 'supports nested numeric paths without issues on Windows', + options: { + output: { preserveModules: true }, + plugins: [ + { + name: 'test', + generateBundle(options, bundle) { + assert.deepStrictEqual(Object.keys(bundle), ['main.js', '0/1/nested.js']); + } + } + ] + } +}); diff --git a/test/chunking-form/samples/import-meta-numeric-paths/_expected/amd/0/1/nested.js b/test/chunking-form/samples/import-meta-numeric-paths/_expected/amd/0/1/nested.js new file mode 100644 index 00000000000..69562cb0eb6 --- /dev/null +++ b/test/chunking-form/samples/import-meta-numeric-paths/_expected/amd/0/1/nested.js @@ -0,0 +1,7 @@ +define(['module', 'exports'], (function (module, exports) { 'use strict'; + + const url = new URL(module.uri, document.baseURI).href; + + exports.url = url; + +})); diff --git a/test/chunking-form/samples/import-meta-numeric-paths/_expected/amd/main.js b/test/chunking-form/samples/import-meta-numeric-paths/_expected/amd/main.js new file mode 100644 index 00000000000..386d534b366 --- /dev/null +++ b/test/chunking-form/samples/import-meta-numeric-paths/_expected/amd/main.js @@ -0,0 +1,7 @@ +define(['exports', './0/1/nested'], (function (exports, nested) { 'use strict'; + + + + exports.url = nested.url; + +})); diff --git a/test/chunking-form/samples/import-meta-numeric-paths/_expected/cjs/0/1/nested.js b/test/chunking-form/samples/import-meta-numeric-paths/_expected/cjs/0/1/nested.js new file mode 100644 index 00000000000..554aa8e8546 --- /dev/null +++ b/test/chunking-form/samples/import-meta-numeric-paths/_expected/cjs/0/1/nested.js @@ -0,0 +1,6 @@ +'use strict'; + +var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null; +const url = (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('0/1/nested.js', document.baseURI).href)); + +exports.url = url; diff --git a/test/chunking-form/samples/import-meta-numeric-paths/_expected/cjs/main.js b/test/chunking-form/samples/import-meta-numeric-paths/_expected/cjs/main.js new file mode 100644 index 00000000000..7b739791d3d --- /dev/null +++ b/test/chunking-form/samples/import-meta-numeric-paths/_expected/cjs/main.js @@ -0,0 +1,7 @@ +'use strict'; + +var nested = require('./0/1/nested.js'); + + + +exports.url = nested.url; diff --git a/test/chunking-form/samples/import-meta-numeric-paths/_expected/es/0/1/nested.js b/test/chunking-form/samples/import-meta-numeric-paths/_expected/es/0/1/nested.js new file mode 100644 index 00000000000..ee0310bf234 --- /dev/null +++ b/test/chunking-form/samples/import-meta-numeric-paths/_expected/es/0/1/nested.js @@ -0,0 +1,3 @@ +const url = import.meta.url; + +export { url }; diff --git a/test/chunking-form/samples/import-meta-numeric-paths/_expected/es/main.js b/test/chunking-form/samples/import-meta-numeric-paths/_expected/es/main.js new file mode 100644 index 00000000000..0b111561502 --- /dev/null +++ b/test/chunking-form/samples/import-meta-numeric-paths/_expected/es/main.js @@ -0,0 +1 @@ +export { url } from './0/1/nested.js'; diff --git a/test/chunking-form/samples/import-meta-numeric-paths/_expected/system/0/1/nested.js b/test/chunking-form/samples/import-meta-numeric-paths/_expected/system/0/1/nested.js new file mode 100644 index 00000000000..eea27aecb48 --- /dev/null +++ b/test/chunking-form/samples/import-meta-numeric-paths/_expected/system/0/1/nested.js @@ -0,0 +1,10 @@ +System.register([], (function (exports, module) { + 'use strict'; + return { + execute: (function () { + + const url = exports("url", module.meta.url); + + }) + }; +})); diff --git a/test/chunking-form/samples/import-meta-numeric-paths/_expected/system/main.js b/test/chunking-form/samples/import-meta-numeric-paths/_expected/system/main.js new file mode 100644 index 00000000000..945f03a112c --- /dev/null +++ b/test/chunking-form/samples/import-meta-numeric-paths/_expected/system/main.js @@ -0,0 +1,13 @@ +System.register(['./0/1/nested.js'], (function (exports) { + 'use strict'; + return { + setters: [function (module) { + exports("url", module.url); + }], + execute: (function () { + + + + }) + }; +})); diff --git a/test/chunking-form/samples/import-meta-numeric-paths/main.js b/test/chunking-form/samples/import-meta-numeric-paths/main.js new file mode 100644 index 00000000000..0b111561502 --- /dev/null +++ b/test/chunking-form/samples/import-meta-numeric-paths/main.js @@ -0,0 +1 @@ +export { url } from './0/1/nested.js'; diff --git a/test/chunking-form/samples/import-meta-url/_config.js b/test/chunking-form/samples/import-meta-url/_config.js index e6560873bb7..827ffc9580f 100644 --- a/test/chunking-form/samples/import-meta-url/_config.js +++ b/test/chunking-form/samples/import-meta-url/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'supports import.meta.url', options: { preserveEntrySignatures: false, @@ -6,4 +6,4 @@ module.exports = { chunkFileNames: 'nested/chunk.js' } } -}; +}); diff --git a/test/chunking-form/samples/import-meta-url/_expected/amd/main.js b/test/chunking-form/samples/import-meta-url/_expected/amd/main.js index bd9df854fba..97856a276bc 100644 --- a/test/chunking-form/samples/import-meta-url/_expected/amd/main.js +++ b/test/chunking-form/samples/import-meta-url/_expected/amd/main.js @@ -1,4 +1,4 @@ -define(['module', 'require', 'exports'], function (module, require, exports) { 'use strict'; +define(['module', 'require', 'exports'], (function (module, require, exports) { 'use strict'; function log(url) { if (typeof document === 'undefined') { @@ -9,10 +9,8 @@ define(['module', 'require', 'exports'], function (module, require, exports) { ' } log('main: ' + new URL(module.uri, document.baseURI).href); - new Promise(function (resolve, reject) { require(['./nested/chunk'], resolve, reject) }); + new Promise(function (resolve, reject) { require(['./nested/chunk'], resolve, reject); }); exports.log = log; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/import-meta-url/_expected/amd/nested/chunk.js b/test/chunking-form/samples/import-meta-url/_expected/amd/nested/chunk.js index 38e3c7579e3..e45f6185159 100644 --- a/test/chunking-form/samples/import-meta-url/_expected/amd/nested/chunk.js +++ b/test/chunking-form/samples/import-meta-url/_expected/amd/nested/chunk.js @@ -1,5 +1,5 @@ -define(['module', '../main'], function (module, main) { 'use strict'; +define(['module', '../main'], (function (module, main) { 'use strict'; main.log('nested: ' + new URL(module.uri, document.baseURI).href); -}); +})); diff --git a/test/chunking-form/samples/import-meta-url/_expected/cjs/main.js b/test/chunking-form/samples/import-meta-url/_expected/cjs/main.js index 0713b95c0b4..bb2e40a89fa 100644 --- a/test/chunking-form/samples/import-meta-url/_expected/cjs/main.js +++ b/test/chunking-form/samples/import-meta-url/_expected/cjs/main.js @@ -1,7 +1,6 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - +var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null; function log(url) { if (typeof document === 'undefined') { console.log(url); @@ -10,7 +9,7 @@ function log(url) { } } -log('main: ' + (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('main.js', document.baseURI).href))); +log('main: ' + (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('main.js', document.baseURI).href))); Promise.resolve().then(function () { return require('./nested/chunk.js'); }); exports.log = log; diff --git a/test/chunking-form/samples/import-meta-url/_expected/cjs/nested/chunk.js b/test/chunking-form/samples/import-meta-url/_expected/cjs/nested/chunk.js index e3b4db6f94d..43c3320e686 100644 --- a/test/chunking-form/samples/import-meta-url/_expected/cjs/nested/chunk.js +++ b/test/chunking-form/samples/import-meta-url/_expected/cjs/nested/chunk.js @@ -2,4 +2,5 @@ var main = require('../main.js'); -main.log('nested: ' + (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('nested/chunk.js', document.baseURI).href))); +var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null; +main.log('nested: ' + (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('nested/chunk.js', document.baseURI).href))); diff --git a/test/chunking-form/samples/import-meta-url/_expected/system/main.js b/test/chunking-form/samples/import-meta-url/_expected/system/main.js index 36b1dd3268a..f75a0d6f7be 100644 --- a/test/chunking-form/samples/import-meta-url/_expected/system/main.js +++ b/test/chunking-form/samples/import-meta-url/_expected/system/main.js @@ -1,9 +1,9 @@ -System.register([], function (exports, module) { +System.register([], (function (exports, module) { 'use strict'; return { - execute: function () { + execute: (function () { - exports('l', log); + exports("l", log); function log(url) { if (typeof document === 'undefined') { @@ -16,6 +16,6 @@ System.register([], function (exports, module) { log('main: ' + module.meta.url); module.import('./nested/chunk.js'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/import-meta-url/_expected/system/nested/chunk.js b/test/chunking-form/samples/import-meta-url/_expected/system/nested/chunk.js index 3009915c4e5..6a31d73cd18 100644 --- a/test/chunking-form/samples/import-meta-url/_expected/system/nested/chunk.js +++ b/test/chunking-form/samples/import-meta-url/_expected/system/nested/chunk.js @@ -1,14 +1,14 @@ -System.register(['../main.js'], function (exports, module) { +System.register(['../main.js'], (function (exports, module) { 'use strict'; var log; return { setters: [function (module) { log = module.l; }], - execute: function () { + execute: (function () { log('nested: ' + module.meta.url); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/import-variable-duplicates/_config.js b/test/chunking-form/samples/import-variable-duplicates/_config.js index 950b01a7535..2d85bf61f09 100644 --- a/test/chunking-form/samples/import-variable-duplicates/_config.js +++ b/test/chunking-form/samples/import-variable-duplicates/_config.js @@ -1,6 +1,6 @@ -module.exports = { +module.exports = defineTest({ description: 'chunk duplicate import deshadowing', options: { input: ['main1.js', 'main2.js', 'first.js', 'head.js'] } -}; +}); diff --git a/test/chunking-form/samples/import-variable-duplicates/_expected/amd/first.js b/test/chunking-form/samples/import-variable-duplicates/_expected/amd/first.js index 60adeb468ed..2a1a73bafa5 100644 --- a/test/chunking-form/samples/import-variable-duplicates/_expected/amd/first.js +++ b/test/chunking-form/samples/import-variable-duplicates/_expected/amd/first.js @@ -1,7 +1,7 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; var head2 = 'first'; return head2; -}); +})); diff --git a/test/chunking-form/samples/import-variable-duplicates/_expected/amd/head.js b/test/chunking-form/samples/import-variable-duplicates/_expected/amd/head.js index 4fee7a37979..11e841c2338 100644 --- a/test/chunking-form/samples/import-variable-duplicates/_expected/amd/head.js +++ b/test/chunking-form/samples/import-variable-duplicates/_expected/amd/head.js @@ -1,7 +1,7 @@ -define(['./first'], function (first) { 'use strict'; +define(['./first'], (function (first) { 'use strict'; return first; -}); +})); diff --git a/test/chunking-form/samples/import-variable-duplicates/_expected/amd/main1.js b/test/chunking-form/samples/import-variable-duplicates/_expected/amd/main1.js index c1fbad76dd0..ab8f6130cdd 100644 --- a/test/chunking-form/samples/import-variable-duplicates/_expected/amd/main1.js +++ b/test/chunking-form/samples/import-variable-duplicates/_expected/amd/main1.js @@ -1,6 +1,6 @@ -define(['./first'], function (first) { 'use strict'; +define(['./first'], (function (first) { 'use strict'; console.log(first); console.log(first); -}); +})); diff --git a/test/chunking-form/samples/import-variable-duplicates/_expected/amd/main2.js b/test/chunking-form/samples/import-variable-duplicates/_expected/amd/main2.js index c1fbad76dd0..ab8f6130cdd 100644 --- a/test/chunking-form/samples/import-variable-duplicates/_expected/amd/main2.js +++ b/test/chunking-form/samples/import-variable-duplicates/_expected/amd/main2.js @@ -1,6 +1,6 @@ -define(['./first'], function (first) { 'use strict'; +define(['./first'], (function (first) { 'use strict'; console.log(first); console.log(first); -}); +})); diff --git a/test/chunking-form/samples/import-variable-duplicates/_expected/es/first.js b/test/chunking-form/samples/import-variable-duplicates/_expected/es/first.js index 7a022e55d7c..af30557f465 100644 --- a/test/chunking-form/samples/import-variable-duplicates/_expected/es/first.js +++ b/test/chunking-form/samples/import-variable-duplicates/_expected/es/first.js @@ -1,3 +1,3 @@ var head2 = 'first'; -export default head2; +export { head2 as default }; diff --git a/test/chunking-form/samples/import-variable-duplicates/_expected/system/first.js b/test/chunking-form/samples/import-variable-duplicates/_expected/system/first.js index f6906bebd92..042decabc75 100644 --- a/test/chunking-form/samples/import-variable-duplicates/_expected/system/first.js +++ b/test/chunking-form/samples/import-variable-duplicates/_expected/system/first.js @@ -1,10 +1,10 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - var head2 = exports('default', 'first'); + var head2 = exports("default", 'first'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/import-variable-duplicates/_expected/system/head.js b/test/chunking-form/samples/import-variable-duplicates/_expected/system/head.js index 9f7b4572ac6..73b98d9be51 100644 --- a/test/chunking-form/samples/import-variable-duplicates/_expected/system/head.js +++ b/test/chunking-form/samples/import-variable-duplicates/_expected/system/head.js @@ -1,13 +1,13 @@ -System.register(['./first.js'], function (exports) { +System.register(['./first.js'], (function (exports) { 'use strict'; return { setters: [function (module) { - exports('default', module.default); + exports("default", module.default); }], - execute: function () { + execute: (function () { - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/import-variable-duplicates/_expected/system/main1.js b/test/chunking-form/samples/import-variable-duplicates/_expected/system/main1.js index 7fc36d77ff9..b3a7f4bd2dc 100644 --- a/test/chunking-form/samples/import-variable-duplicates/_expected/system/main1.js +++ b/test/chunking-form/samples/import-variable-duplicates/_expected/system/main1.js @@ -1,15 +1,15 @@ -System.register(['./first.js'], function () { +System.register(['./first.js'], (function () { 'use strict'; var head2; return { setters: [function (module) { head2 = module.default; }], - execute: function () { + execute: (function () { console.log(head2); console.log(head2); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/import-variable-duplicates/_expected/system/main2.js b/test/chunking-form/samples/import-variable-duplicates/_expected/system/main2.js index 7fc36d77ff9..b3a7f4bd2dc 100644 --- a/test/chunking-form/samples/import-variable-duplicates/_expected/system/main2.js +++ b/test/chunking-form/samples/import-variable-duplicates/_expected/system/main2.js @@ -1,15 +1,15 @@ -System.register(['./first.js'], function () { +System.register(['./first.js'], (function () { 'use strict'; var head2; return { setters: [function (module) { head2 = module.default; }], - execute: function () { + execute: (function () { console.log(head2); console.log(head2); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/chained-dynamic-with-shared/_config.js b/test/chunking-form/samples/improved-dynamic-chunks/chained-dynamic-with-shared/_config.js index ba9c4c3c981..0a19b3b0fd4 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/chained-dynamic-with-shared/_config.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/chained-dynamic-with-shared/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'chained dynamic import that imports something already loaded' -}; +}); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/chained-dynamic-with-shared/_expected/amd/generated-dynamic1.js b/test/chunking-form/samples/improved-dynamic-chunks/chained-dynamic-with-shared/_expected/amd/generated-dynamic1.js index be41dd73ba2..6858aea4bb0 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/chained-dynamic-with-shared/_expected/amd/generated-dynamic1.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/chained-dynamic-with-shared/_expected/amd/generated-dynamic1.js @@ -1,6 +1,11 @@ -define(['require'], function (require) { 'use strict'; +define(['./main'], (function (main) { 'use strict'; - new Promise(function (resolve, reject) { require(['./generated-dynamic2'], resolve, reject) }); + Promise.resolve().then(function () { return dynamic2; }); console.log('dynamic1'); -}); + var dynamic2 = /*#__PURE__*/Object.freeze({ + __proto__: null, + shared: main.shared + }); + +})); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/chained-dynamic-with-shared/_expected/amd/generated-dynamic2.js b/test/chunking-form/samples/improved-dynamic-chunks/chained-dynamic-with-shared/_expected/amd/generated-dynamic2.js deleted file mode 100644 index 54e4f19ff6d..00000000000 --- a/test/chunking-form/samples/improved-dynamic-chunks/chained-dynamic-with-shared/_expected/amd/generated-dynamic2.js +++ /dev/null @@ -1,7 +0,0 @@ -define(['exports', './main'], function (exports, main) { 'use strict'; - - - - exports.shared = main.shared; - -}); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/chained-dynamic-with-shared/_expected/amd/main.js b/test/chunking-form/samples/improved-dynamic-chunks/chained-dynamic-with-shared/_expected/amd/main.js index c5be5c70fbb..08a469fe7a0 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/chained-dynamic-with-shared/_expected/amd/main.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/chained-dynamic-with-shared/_expected/amd/main.js @@ -1,11 +1,9 @@ -define(['require', 'exports'], function (require, exports) { 'use strict'; +define(['require', 'exports'], (function (require, exports) { 'use strict'; const shared = 'shared'; - new Promise(function (resolve, reject) { require(['./generated-dynamic1'], resolve, reject) }); + new Promise(function (resolve, reject) { require(['./generated-dynamic1'], resolve, reject); }); exports.shared = shared; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/chained-dynamic-with-shared/_expected/cjs/generated-dynamic1.js b/test/chunking-form/samples/improved-dynamic-chunks/chained-dynamic-with-shared/_expected/cjs/generated-dynamic1.js index a2c5fbe22b9..c7e5aa129c6 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/chained-dynamic-with-shared/_expected/cjs/generated-dynamic1.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/chained-dynamic-with-shared/_expected/cjs/generated-dynamic1.js @@ -1,4 +1,11 @@ 'use strict'; -Promise.resolve().then(function () { return require('./generated-dynamic2.js'); }); +var main = require('./main.js'); + +Promise.resolve().then(function () { return dynamic2; }); console.log('dynamic1'); + +var dynamic2 = /*#__PURE__*/Object.freeze({ + __proto__: null, + shared: main.shared +}); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/chained-dynamic-with-shared/_expected/cjs/generated-dynamic2.js b/test/chunking-form/samples/improved-dynamic-chunks/chained-dynamic-with-shared/_expected/cjs/generated-dynamic2.js deleted file mode 100644 index 9393c62e477..00000000000 --- a/test/chunking-form/samples/improved-dynamic-chunks/chained-dynamic-with-shared/_expected/cjs/generated-dynamic2.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -var main = require('./main.js'); - - - -exports.shared = main.shared; diff --git a/test/chunking-form/samples/improved-dynamic-chunks/chained-dynamic-with-shared/_expected/cjs/main.js b/test/chunking-form/samples/improved-dynamic-chunks/chained-dynamic-with-shared/_expected/cjs/main.js index d90a9e09166..1526f9dd5a0 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/chained-dynamic-with-shared/_expected/cjs/main.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/chained-dynamic-with-shared/_expected/cjs/main.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - const shared = 'shared'; Promise.resolve().then(function () { return require('./generated-dynamic1.js'); }); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/chained-dynamic-with-shared/_expected/es/generated-dynamic1.js b/test/chunking-form/samples/improved-dynamic-chunks/chained-dynamic-with-shared/_expected/es/generated-dynamic1.js index 2db19197d94..c8e96932bb2 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/chained-dynamic-with-shared/_expected/es/generated-dynamic1.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/chained-dynamic-with-shared/_expected/es/generated-dynamic1.js @@ -1,2 +1,9 @@ -import('./generated-dynamic2.js'); +import { shared } from './main.js'; + +Promise.resolve().then(function () { return dynamic2; }); console.log('dynamic1'); + +var dynamic2 = /*#__PURE__*/Object.freeze({ + __proto__: null, + shared: shared +}); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/chained-dynamic-with-shared/_expected/es/generated-dynamic2.js b/test/chunking-form/samples/improved-dynamic-chunks/chained-dynamic-with-shared/_expected/es/generated-dynamic2.js deleted file mode 100644 index f33a9bfc313..00000000000 --- a/test/chunking-form/samples/improved-dynamic-chunks/chained-dynamic-with-shared/_expected/es/generated-dynamic2.js +++ /dev/null @@ -1 +0,0 @@ -export { shared } from './main.js'; diff --git a/test/chunking-form/samples/improved-dynamic-chunks/chained-dynamic-with-shared/_expected/system/generated-dynamic1.js b/test/chunking-form/samples/improved-dynamic-chunks/chained-dynamic-with-shared/_expected/system/generated-dynamic1.js index 4885888ccf8..8a956053e49 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/chained-dynamic-with-shared/_expected/system/generated-dynamic1.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/chained-dynamic-with-shared/_expected/system/generated-dynamic1.js @@ -1,11 +1,20 @@ -System.register([], function (exports, module) { +System.register(['./main.js'], (function () { 'use strict'; + var shared; return { - execute: function () { + setters: [function (module) { + shared = module.shared; + }], + execute: (function () { - module.import('./generated-dynamic2.js'); + Promise.resolve().then(function () { return dynamic2; }); console.log('dynamic1'); - } + var dynamic2 = /*#__PURE__*/Object.freeze({ + __proto__: null, + shared: shared + }); + + }) }; -}); +})); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/chained-dynamic-with-shared/_expected/system/generated-dynamic2.js b/test/chunking-form/samples/improved-dynamic-chunks/chained-dynamic-with-shared/_expected/system/generated-dynamic2.js deleted file mode 100644 index 583c430ed19..00000000000 --- a/test/chunking-form/samples/improved-dynamic-chunks/chained-dynamic-with-shared/_expected/system/generated-dynamic2.js +++ /dev/null @@ -1,13 +0,0 @@ -System.register(['./main.js'], function (exports) { - 'use strict'; - return { - setters: [function (module) { - exports('shared', module.shared); - }], - execute: function () { - - - - } - }; -}); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/chained-dynamic-with-shared/_expected/system/main.js b/test/chunking-form/samples/improved-dynamic-chunks/chained-dynamic-with-shared/_expected/system/main.js index 68b287fdff0..280a3fa9286 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/chained-dynamic-with-shared/_expected/system/main.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/chained-dynamic-with-shared/_expected/system/main.js @@ -1,12 +1,12 @@ -System.register([], function (exports, module) { +System.register([], (function (exports, module) { 'use strict'; return { - execute: function () { + execute: (function () { - const shared = exports('shared', 'shared'); + const shared = exports("shared", 'shared'); module.import('./generated-dynamic1.js'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/circular-dynamic-imports/_config.js b/test/chunking-form/samples/improved-dynamic-chunks/circular-dynamic-imports/_config.js index 86aea7fe346..c0b010a8a2c 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/circular-dynamic-imports/_config.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/circular-dynamic-imports/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'handles circular dynamic imports' -}; +}); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/circular-dynamic-imports/_expected/amd/generated-dynamic1.js b/test/chunking-form/samples/improved-dynamic-chunks/circular-dynamic-imports/_expected/amd/generated-dynamic1.js index be41dd73ba2..b6491460a46 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/circular-dynamic-imports/_expected/amd/generated-dynamic1.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/circular-dynamic-imports/_expected/amd/generated-dynamic1.js @@ -1,6 +1,6 @@ -define(['require'], function (require) { 'use strict'; +define(['require'], (function (require) { 'use strict'; - new Promise(function (resolve, reject) { require(['./generated-dynamic2'], resolve, reject) }); + new Promise(function (resolve, reject) { require(['./generated-dynamic2'], resolve, reject); }); console.log('dynamic1'); -}); +})); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/circular-dynamic-imports/_expected/amd/generated-dynamic2.js b/test/chunking-form/samples/improved-dynamic-chunks/circular-dynamic-imports/_expected/amd/generated-dynamic2.js index f7f9fa681f2..7088a002291 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/circular-dynamic-imports/_expected/amd/generated-dynamic2.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/circular-dynamic-imports/_expected/amd/generated-dynamic2.js @@ -1,6 +1,6 @@ -define(['require'], function (require) { 'use strict'; +define(['require'], (function (require) { 'use strict'; - new Promise(function (resolve, reject) { require(['./main'], resolve, reject) }); + new Promise(function (resolve, reject) { require(['./main'], resolve, reject); }); console.log('dynamic2'); -}); +})); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/circular-dynamic-imports/_expected/amd/main.js b/test/chunking-form/samples/improved-dynamic-chunks/circular-dynamic-imports/_expected/amd/main.js index 8960a94b11a..6ae3a3b3786 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/circular-dynamic-imports/_expected/amd/main.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/circular-dynamic-imports/_expected/amd/main.js @@ -1,7 +1,7 @@ -define(['require'], function (require) { 'use strict'; +define(['require'], (function (require) { 'use strict'; - new Promise(function (resolve, reject) { require(['./generated-dynamic2'], resolve, reject) }); - new Promise(function (resolve, reject) { require(['./generated-dynamic1'], resolve, reject) }); + new Promise(function (resolve, reject) { require(['./generated-dynamic2'], resolve, reject); }); + new Promise(function (resolve, reject) { require(['./generated-dynamic1'], resolve, reject); }); console.log('main'); -}); +})); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/circular-dynamic-imports/_expected/system/generated-dynamic1.js b/test/chunking-form/samples/improved-dynamic-chunks/circular-dynamic-imports/_expected/system/generated-dynamic1.js index 4885888ccf8..3dd67ec612b 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/circular-dynamic-imports/_expected/system/generated-dynamic1.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/circular-dynamic-imports/_expected/system/generated-dynamic1.js @@ -1,11 +1,11 @@ -System.register([], function (exports, module) { +System.register([], (function (exports, module) { 'use strict'; return { - execute: function () { + execute: (function () { module.import('./generated-dynamic2.js'); console.log('dynamic1'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/circular-dynamic-imports/_expected/system/generated-dynamic2.js b/test/chunking-form/samples/improved-dynamic-chunks/circular-dynamic-imports/_expected/system/generated-dynamic2.js index e54de5996a6..0d16f84b0d3 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/circular-dynamic-imports/_expected/system/generated-dynamic2.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/circular-dynamic-imports/_expected/system/generated-dynamic2.js @@ -1,11 +1,11 @@ -System.register([], function (exports, module) { +System.register([], (function (exports, module) { 'use strict'; return { - execute: function () { + execute: (function () { module.import('./main.js'); console.log('dynamic2'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/circular-dynamic-imports/_expected/system/main.js b/test/chunking-form/samples/improved-dynamic-chunks/circular-dynamic-imports/_expected/system/main.js index 6a23dc688df..2f6de3adf11 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/circular-dynamic-imports/_expected/system/main.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/circular-dynamic-imports/_expected/system/main.js @@ -1,12 +1,12 @@ -System.register([], function (exports, module) { +System.register([], (function (exports, module) { 'use strict'; return { - execute: function () { + execute: (function () { module.import('./generated-dynamic2.js'); module.import('./generated-dynamic1.js'); console.log('main'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/cut-off/_config.js b/test/chunking-form/samples/improved-dynamic-chunks/cut-off/_config.js new file mode 100644 index 00000000000..5893fd7a651 --- /dev/null +++ b/test/chunking-form/samples/improved-dynamic-chunks/cut-off/_config.js @@ -0,0 +1,7 @@ +module.exports = defineTest({ + description: + 'does not avoid separate chunks if too many modules dynamically import the same chunk', + options: { + input: ['main1', 'main2', 'main3', 'main4'] + } +}); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/cut-off/_expected/amd/generated-dep.js b/test/chunking-form/samples/improved-dynamic-chunks/cut-off/_expected/amd/generated-dep.js new file mode 100644 index 00000000000..2338648d763 --- /dev/null +++ b/test/chunking-form/samples/improved-dynamic-chunks/cut-off/_expected/amd/generated-dep.js @@ -0,0 +1,7 @@ +define(['exports'], (function (exports) { 'use strict'; + + const value = 'shared'; + + exports.value = value; + +})); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/cut-off/_expected/amd/generated-dynamic1.js b/test/chunking-form/samples/improved-dynamic-chunks/cut-off/_expected/amd/generated-dynamic1.js new file mode 100644 index 00000000000..0521001fece --- /dev/null +++ b/test/chunking-form/samples/improved-dynamic-chunks/cut-off/_expected/amd/generated-dynamic1.js @@ -0,0 +1,6 @@ +define(['require', './generated-dep'], (function (require, dep) { 'use strict'; + + console.log('dynamic1', dep.value); + new Promise(function (resolve, reject) { require(['./generated-dynamic2'], resolve, reject); }); + +})); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/cut-off/_expected/amd/generated-dynamic2.js b/test/chunking-form/samples/improved-dynamic-chunks/cut-off/_expected/amd/generated-dynamic2.js new file mode 100644 index 00000000000..7e1d9ca3c22 --- /dev/null +++ b/test/chunking-form/samples/improved-dynamic-chunks/cut-off/_expected/amd/generated-dynamic2.js @@ -0,0 +1,5 @@ +define(['./generated-dep'], (function (dep) { 'use strict'; + + console.log('dynamic2', dep.value); + +})); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/cut-off/_expected/amd/main1.js b/test/chunking-form/samples/improved-dynamic-chunks/cut-off/_expected/amd/main1.js new file mode 100644 index 00000000000..eed65cfcb79 --- /dev/null +++ b/test/chunking-form/samples/improved-dynamic-chunks/cut-off/_expected/amd/main1.js @@ -0,0 +1,6 @@ +define(['require', './generated-dep'], (function (require, dep) { 'use strict'; + + console.log('main1', dep.value); + new Promise(function (resolve, reject) { require(['./generated-dynamic1'], resolve, reject); }); + +})); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/cut-off/_expected/amd/main2.js b/test/chunking-form/samples/improved-dynamic-chunks/cut-off/_expected/amd/main2.js new file mode 100644 index 00000000000..eed65cfcb79 --- /dev/null +++ b/test/chunking-form/samples/improved-dynamic-chunks/cut-off/_expected/amd/main2.js @@ -0,0 +1,6 @@ +define(['require', './generated-dep'], (function (require, dep) { 'use strict'; + + console.log('main1', dep.value); + new Promise(function (resolve, reject) { require(['./generated-dynamic1'], resolve, reject); }); + +})); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/cut-off/_expected/amd/main3.js b/test/chunking-form/samples/improved-dynamic-chunks/cut-off/_expected/amd/main3.js new file mode 100644 index 00000000000..eed65cfcb79 --- /dev/null +++ b/test/chunking-form/samples/improved-dynamic-chunks/cut-off/_expected/amd/main3.js @@ -0,0 +1,6 @@ +define(['require', './generated-dep'], (function (require, dep) { 'use strict'; + + console.log('main1', dep.value); + new Promise(function (resolve, reject) { require(['./generated-dynamic1'], resolve, reject); }); + +})); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/cut-off/_expected/amd/main4.js b/test/chunking-form/samples/improved-dynamic-chunks/cut-off/_expected/amd/main4.js new file mode 100644 index 00000000000..eed65cfcb79 --- /dev/null +++ b/test/chunking-form/samples/improved-dynamic-chunks/cut-off/_expected/amd/main4.js @@ -0,0 +1,6 @@ +define(['require', './generated-dep'], (function (require, dep) { 'use strict'; + + console.log('main1', dep.value); + new Promise(function (resolve, reject) { require(['./generated-dynamic1'], resolve, reject); }); + +})); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/cut-off/_expected/cjs/generated-dep.js b/test/chunking-form/samples/improved-dynamic-chunks/cut-off/_expected/cjs/generated-dep.js new file mode 100644 index 00000000000..31a412b6dc4 --- /dev/null +++ b/test/chunking-form/samples/improved-dynamic-chunks/cut-off/_expected/cjs/generated-dep.js @@ -0,0 +1,5 @@ +'use strict'; + +const value = 'shared'; + +exports.value = value; diff --git a/test/chunking-form/samples/improved-dynamic-chunks/cut-off/_expected/cjs/generated-dynamic1.js b/test/chunking-form/samples/improved-dynamic-chunks/cut-off/_expected/cjs/generated-dynamic1.js new file mode 100644 index 00000000000..bc0ad9f1c2a --- /dev/null +++ b/test/chunking-form/samples/improved-dynamic-chunks/cut-off/_expected/cjs/generated-dynamic1.js @@ -0,0 +1,6 @@ +'use strict'; + +var dep = require('./generated-dep.js'); + +console.log('dynamic1', dep.value); +Promise.resolve().then(function () { return require('./generated-dynamic2.js'); }); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/cut-off/_expected/cjs/generated-dynamic2.js b/test/chunking-form/samples/improved-dynamic-chunks/cut-off/_expected/cjs/generated-dynamic2.js new file mode 100644 index 00000000000..af07a8e556a --- /dev/null +++ b/test/chunking-form/samples/improved-dynamic-chunks/cut-off/_expected/cjs/generated-dynamic2.js @@ -0,0 +1,5 @@ +'use strict'; + +var dep = require('./generated-dep.js'); + +console.log('dynamic2', dep.value); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/cut-off/_expected/cjs/main1.js b/test/chunking-form/samples/improved-dynamic-chunks/cut-off/_expected/cjs/main1.js new file mode 100644 index 00000000000..5d139ba4b8d --- /dev/null +++ b/test/chunking-form/samples/improved-dynamic-chunks/cut-off/_expected/cjs/main1.js @@ -0,0 +1,6 @@ +'use strict'; + +var dep = require('./generated-dep.js'); + +console.log('main1', dep.value); +Promise.resolve().then(function () { return require('./generated-dynamic1.js'); }); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/cut-off/_expected/cjs/main2.js b/test/chunking-form/samples/improved-dynamic-chunks/cut-off/_expected/cjs/main2.js new file mode 100644 index 00000000000..5d139ba4b8d --- /dev/null +++ b/test/chunking-form/samples/improved-dynamic-chunks/cut-off/_expected/cjs/main2.js @@ -0,0 +1,6 @@ +'use strict'; + +var dep = require('./generated-dep.js'); + +console.log('main1', dep.value); +Promise.resolve().then(function () { return require('./generated-dynamic1.js'); }); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/cut-off/_expected/cjs/main3.js b/test/chunking-form/samples/improved-dynamic-chunks/cut-off/_expected/cjs/main3.js new file mode 100644 index 00000000000..5d139ba4b8d --- /dev/null +++ b/test/chunking-form/samples/improved-dynamic-chunks/cut-off/_expected/cjs/main3.js @@ -0,0 +1,6 @@ +'use strict'; + +var dep = require('./generated-dep.js'); + +console.log('main1', dep.value); +Promise.resolve().then(function () { return require('./generated-dynamic1.js'); }); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/cut-off/_expected/cjs/main4.js b/test/chunking-form/samples/improved-dynamic-chunks/cut-off/_expected/cjs/main4.js new file mode 100644 index 00000000000..5d139ba4b8d --- /dev/null +++ b/test/chunking-form/samples/improved-dynamic-chunks/cut-off/_expected/cjs/main4.js @@ -0,0 +1,6 @@ +'use strict'; + +var dep = require('./generated-dep.js'); + +console.log('main1', dep.value); +Promise.resolve().then(function () { return require('./generated-dynamic1.js'); }); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/cut-off/_expected/es/generated-dep.js b/test/chunking-form/samples/improved-dynamic-chunks/cut-off/_expected/es/generated-dep.js new file mode 100644 index 00000000000..27b7b7de159 --- /dev/null +++ b/test/chunking-form/samples/improved-dynamic-chunks/cut-off/_expected/es/generated-dep.js @@ -0,0 +1,3 @@ +const value = 'shared'; + +export { value as v }; diff --git a/test/chunking-form/samples/improved-dynamic-chunks/cut-off/_expected/es/generated-dynamic1.js b/test/chunking-form/samples/improved-dynamic-chunks/cut-off/_expected/es/generated-dynamic1.js new file mode 100644 index 00000000000..67428789ad0 --- /dev/null +++ b/test/chunking-form/samples/improved-dynamic-chunks/cut-off/_expected/es/generated-dynamic1.js @@ -0,0 +1,4 @@ +import { v as value } from './generated-dep.js'; + +console.log('dynamic1', value); +import('./generated-dynamic2.js'); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/cut-off/_expected/es/generated-dynamic2.js b/test/chunking-form/samples/improved-dynamic-chunks/cut-off/_expected/es/generated-dynamic2.js new file mode 100644 index 00000000000..0c2d81a045a --- /dev/null +++ b/test/chunking-form/samples/improved-dynamic-chunks/cut-off/_expected/es/generated-dynamic2.js @@ -0,0 +1,3 @@ +import { v as value } from './generated-dep.js'; + +console.log('dynamic2', value); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/cut-off/_expected/es/main1.js b/test/chunking-form/samples/improved-dynamic-chunks/cut-off/_expected/es/main1.js new file mode 100644 index 00000000000..40e11af6e3d --- /dev/null +++ b/test/chunking-form/samples/improved-dynamic-chunks/cut-off/_expected/es/main1.js @@ -0,0 +1,4 @@ +import { v as value } from './generated-dep.js'; + +console.log('main1', value); +import('./generated-dynamic1.js'); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/cut-off/_expected/es/main2.js b/test/chunking-form/samples/improved-dynamic-chunks/cut-off/_expected/es/main2.js new file mode 100644 index 00000000000..40e11af6e3d --- /dev/null +++ b/test/chunking-form/samples/improved-dynamic-chunks/cut-off/_expected/es/main2.js @@ -0,0 +1,4 @@ +import { v as value } from './generated-dep.js'; + +console.log('main1', value); +import('./generated-dynamic1.js'); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/cut-off/_expected/es/main3.js b/test/chunking-form/samples/improved-dynamic-chunks/cut-off/_expected/es/main3.js new file mode 100644 index 00000000000..40e11af6e3d --- /dev/null +++ b/test/chunking-form/samples/improved-dynamic-chunks/cut-off/_expected/es/main3.js @@ -0,0 +1,4 @@ +import { v as value } from './generated-dep.js'; + +console.log('main1', value); +import('./generated-dynamic1.js'); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/cut-off/_expected/es/main4.js b/test/chunking-form/samples/improved-dynamic-chunks/cut-off/_expected/es/main4.js new file mode 100644 index 00000000000..40e11af6e3d --- /dev/null +++ b/test/chunking-form/samples/improved-dynamic-chunks/cut-off/_expected/es/main4.js @@ -0,0 +1,4 @@ +import { v as value } from './generated-dep.js'; + +console.log('main1', value); +import('./generated-dynamic1.js'); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/cut-off/_expected/system/generated-dep.js b/test/chunking-form/samples/improved-dynamic-chunks/cut-off/_expected/system/generated-dep.js new file mode 100644 index 00000000000..42ee1c20534 --- /dev/null +++ b/test/chunking-form/samples/improved-dynamic-chunks/cut-off/_expected/system/generated-dep.js @@ -0,0 +1,10 @@ +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + + const value = exports("v", 'shared'); + + }) + }; +})); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/cut-off/_expected/system/generated-dynamic1.js b/test/chunking-form/samples/improved-dynamic-chunks/cut-off/_expected/system/generated-dynamic1.js new file mode 100644 index 00000000000..57cef271845 --- /dev/null +++ b/test/chunking-form/samples/improved-dynamic-chunks/cut-off/_expected/system/generated-dynamic1.js @@ -0,0 +1,15 @@ +System.register(['./generated-dep.js'], (function (exports, module) { + 'use strict'; + var value; + return { + setters: [function (module) { + value = module.v; + }], + execute: (function () { + + console.log('dynamic1', value); + module.import('./generated-dynamic2.js'); + + }) + }; +})); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/cut-off/_expected/system/generated-dynamic2.js b/test/chunking-form/samples/improved-dynamic-chunks/cut-off/_expected/system/generated-dynamic2.js new file mode 100644 index 00000000000..ba93f808068 --- /dev/null +++ b/test/chunking-form/samples/improved-dynamic-chunks/cut-off/_expected/system/generated-dynamic2.js @@ -0,0 +1,14 @@ +System.register(['./generated-dep.js'], (function () { + 'use strict'; + var value; + return { + setters: [function (module) { + value = module.v; + }], + execute: (function () { + + console.log('dynamic2', value); + + }) + }; +})); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/cut-off/_expected/system/main1.js b/test/chunking-form/samples/improved-dynamic-chunks/cut-off/_expected/system/main1.js new file mode 100644 index 00000000000..a469eaf5724 --- /dev/null +++ b/test/chunking-form/samples/improved-dynamic-chunks/cut-off/_expected/system/main1.js @@ -0,0 +1,15 @@ +System.register(['./generated-dep.js'], (function (exports, module) { + 'use strict'; + var value; + return { + setters: [function (module) { + value = module.v; + }], + execute: (function () { + + console.log('main1', value); + module.import('./generated-dynamic1.js'); + + }) + }; +})); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/cut-off/_expected/system/main2.js b/test/chunking-form/samples/improved-dynamic-chunks/cut-off/_expected/system/main2.js new file mode 100644 index 00000000000..a469eaf5724 --- /dev/null +++ b/test/chunking-form/samples/improved-dynamic-chunks/cut-off/_expected/system/main2.js @@ -0,0 +1,15 @@ +System.register(['./generated-dep.js'], (function (exports, module) { + 'use strict'; + var value; + return { + setters: [function (module) { + value = module.v; + }], + execute: (function () { + + console.log('main1', value); + module.import('./generated-dynamic1.js'); + + }) + }; +})); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/cut-off/_expected/system/main3.js b/test/chunking-form/samples/improved-dynamic-chunks/cut-off/_expected/system/main3.js new file mode 100644 index 00000000000..a469eaf5724 --- /dev/null +++ b/test/chunking-form/samples/improved-dynamic-chunks/cut-off/_expected/system/main3.js @@ -0,0 +1,15 @@ +System.register(['./generated-dep.js'], (function (exports, module) { + 'use strict'; + var value; + return { + setters: [function (module) { + value = module.v; + }], + execute: (function () { + + console.log('main1', value); + module.import('./generated-dynamic1.js'); + + }) + }; +})); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/cut-off/_expected/system/main4.js b/test/chunking-form/samples/improved-dynamic-chunks/cut-off/_expected/system/main4.js new file mode 100644 index 00000000000..a469eaf5724 --- /dev/null +++ b/test/chunking-form/samples/improved-dynamic-chunks/cut-off/_expected/system/main4.js @@ -0,0 +1,15 @@ +System.register(['./generated-dep.js'], (function (exports, module) { + 'use strict'; + var value; + return { + setters: [function (module) { + value = module.v; + }], + execute: (function () { + + console.log('main1', value); + module.import('./generated-dynamic1.js'); + + }) + }; +})); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/cut-off/dep.js b/test/chunking-form/samples/improved-dynamic-chunks/cut-off/dep.js new file mode 100644 index 00000000000..1d4be9c15d0 --- /dev/null +++ b/test/chunking-form/samples/improved-dynamic-chunks/cut-off/dep.js @@ -0,0 +1 @@ +export const value = 'shared'; diff --git a/test/chunking-form/samples/improved-dynamic-chunks/cut-off/dynamic1.js b/test/chunking-form/samples/improved-dynamic-chunks/cut-off/dynamic1.js new file mode 100644 index 00000000000..58d0327fc60 --- /dev/null +++ b/test/chunking-form/samples/improved-dynamic-chunks/cut-off/dynamic1.js @@ -0,0 +1,4 @@ +import { value } from './dep.js'; +console.log('dynamic1', value); +import('./dynamic2.js'); + diff --git a/test/chunking-form/samples/improved-dynamic-chunks/cut-off/dynamic2.js b/test/chunking-form/samples/improved-dynamic-chunks/cut-off/dynamic2.js new file mode 100644 index 00000000000..daf24d9c4d3 --- /dev/null +++ b/test/chunking-form/samples/improved-dynamic-chunks/cut-off/dynamic2.js @@ -0,0 +1,2 @@ +import { value } from './dep.js'; +console.log('dynamic2', value); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/cut-off/main1.js b/test/chunking-form/samples/improved-dynamic-chunks/cut-off/main1.js new file mode 100644 index 00000000000..170c4e5d89a --- /dev/null +++ b/test/chunking-form/samples/improved-dynamic-chunks/cut-off/main1.js @@ -0,0 +1,3 @@ +import { value } from './dep.js'; +console.log('main1', value); +import('./dynamic1.js'); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/cut-off/main2.js b/test/chunking-form/samples/improved-dynamic-chunks/cut-off/main2.js new file mode 100644 index 00000000000..170c4e5d89a --- /dev/null +++ b/test/chunking-form/samples/improved-dynamic-chunks/cut-off/main2.js @@ -0,0 +1,3 @@ +import { value } from './dep.js'; +console.log('main1', value); +import('./dynamic1.js'); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/cut-off/main3.js b/test/chunking-form/samples/improved-dynamic-chunks/cut-off/main3.js new file mode 100644 index 00000000000..170c4e5d89a --- /dev/null +++ b/test/chunking-form/samples/improved-dynamic-chunks/cut-off/main3.js @@ -0,0 +1,3 @@ +import { value } from './dep.js'; +console.log('main1', value); +import('./dynamic1.js'); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/cut-off/main4.js b/test/chunking-form/samples/improved-dynamic-chunks/cut-off/main4.js new file mode 100644 index 00000000000..170c4e5d89a --- /dev/null +++ b/test/chunking-form/samples/improved-dynamic-chunks/cut-off/main4.js @@ -0,0 +1,3 @@ +import { value } from './dep.js'; +console.log('main1', value); +import('./dynamic1.js'); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/dynamic-import-already-contained-1/_config.js b/test/chunking-form/samples/improved-dynamic-chunks/dynamic-import-already-contained-1/_config.js index f475a15a739..32d32893c38 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/dynamic-import-already-contained-1/_config.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/dynamic-import-already-contained-1/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'inlines dynamic imports that are already statically imported' -}; +}); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/dynamic-import-already-contained-1/_expected/amd/main.js b/test/chunking-form/samples/improved-dynamic-chunks/dynamic-import-already-contained-1/_expected/amd/main.js index 3fab3918be6..e6637b66148 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/dynamic-import-already-contained-1/_expected/amd/main.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/dynamic-import-already-contained-1/_expected/amd/main.js @@ -1,4 +1,4 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; Promise.resolve().then(function () { return main; }).then(console.log); console.log('dep1'); @@ -24,6 +24,4 @@ define(['exports'], function (exports) { 'use strict'; exports.value = value; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/dynamic-import-already-contained-1/_expected/cjs/main.js b/test/chunking-form/samples/improved-dynamic-chunks/dynamic-import-already-contained-1/_expected/cjs/main.js index cb766ee459d..4cc450416cd 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/dynamic-import-already-contained-1/_expected/cjs/main.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/dynamic-import-already-contained-1/_expected/cjs/main.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - Promise.resolve().then(function () { return main; }).then(console.log); console.log('dep1'); const value1 = 'dep1'; diff --git a/test/chunking-form/samples/improved-dynamic-chunks/dynamic-import-already-contained-1/_expected/system/main.js b/test/chunking-form/samples/improved-dynamic-chunks/dynamic-import-already-contained-1/_expected/system/main.js index 30ad2f5698f..9b960811ee2 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/dynamic-import-already-contained-1/_expected/system/main.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/dynamic-import-already-contained-1/_expected/system/main.js @@ -1,7 +1,7 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { Promise.resolve().then(function () { return main; }).then(console.log); console.log('dep1'); @@ -18,13 +18,13 @@ System.register([], function (exports) { Promise.resolve().then(function () { return main; }).then(console.log); console.log('main', value1, value2); - const value = exports('value', 'main'); + const value = exports("value", 'main'); var main = /*#__PURE__*/Object.freeze({ __proto__: null, value: value }); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/dynamic-import-already-contained-2/_config.js b/test/chunking-form/samples/improved-dynamic-chunks/dynamic-import-already-contained-2/_config.js index 8fb4c32176c..af17537fdee 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/dynamic-import-already-contained-2/_config.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/dynamic-import-already-contained-2/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'inlines dynamic imports that are already statically imported by their importers' -}; +}); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/dynamic-import-already-contained-2/_expected/amd/main.js b/test/chunking-form/samples/improved-dynamic-chunks/dynamic-import-already-contained-2/_expected/amd/main.js index 466b0dabc88..54414984515 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/dynamic-import-already-contained-2/_expected/amd/main.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/dynamic-import-already-contained-2/_expected/amd/main.js @@ -1,4 +1,4 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; Promise.resolve().then(function () { return dynamic2; }).then(console.log); console.log('dynamic1'); @@ -20,4 +20,4 @@ define(function () { 'use strict'; Promise.resolve().then(function () { return dynamic1; }).then(console.log); console.log('main', value1, value2); -}); +})); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/dynamic-import-already-contained-2/_expected/system/main.js b/test/chunking-form/samples/improved-dynamic-chunks/dynamic-import-already-contained-2/_expected/system/main.js index 35382e9f21f..fa925a8d123 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/dynamic-import-already-contained-2/_expected/system/main.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/dynamic-import-already-contained-2/_expected/system/main.js @@ -1,7 +1,7 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { Promise.resolve().then(function () { return dynamic2; }).then(console.log); console.log('dynamic1'); @@ -23,6 +23,6 @@ System.register([], function () { Promise.resolve().then(function () { return dynamic1; }).then(console.log); console.log('main', value1, value2); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/dynamic-import-dynamic-multi-stage/_config.js b/test/chunking-form/samples/improved-dynamic-chunks/dynamic-import-dynamic-multi-stage/_config.js index d8b7a769273..7e113af09c4 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/dynamic-import-dynamic-multi-stage/_config.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/dynamic-import-dynamic-multi-stage/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'handles if a dynamically imported module imports another module dynamically' -}; +}); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/dynamic-import-dynamic-multi-stage/_expected/amd/generated-dynamic1.js b/test/chunking-form/samples/improved-dynamic-chunks/dynamic-import-dynamic-multi-stage/_expected/amd/generated-dynamic1.js index 41b95d106c9..e5ffc917706 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/dynamic-import-dynamic-multi-stage/_expected/amd/generated-dynamic1.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/dynamic-import-dynamic-multi-stage/_expected/amd/generated-dynamic1.js @@ -1,5 +1,5 @@ -define(['require'], function (require) { 'use strict'; +define(['require'], (function (require) { 'use strict'; - new Promise(function (resolve, reject) { require(['./generated-dynamic2'], resolve, reject) }); + new Promise(function (resolve, reject) { require(['./generated-dynamic2'], resolve, reject); }); -}); +})); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/dynamic-import-dynamic-multi-stage/_expected/amd/generated-dynamic2.js b/test/chunking-form/samples/improved-dynamic-chunks/dynamic-import-dynamic-multi-stage/_expected/amd/generated-dynamic2.js index b30754a60e8..162cba33808 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/dynamic-import-dynamic-multi-stage/_expected/amd/generated-dynamic2.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/dynamic-import-dynamic-multi-stage/_expected/amd/generated-dynamic2.js @@ -1,7 +1,7 @@ -define(['exports', './main'], function (exports, main) { 'use strict'; +define(['exports', './main'], (function (exports, main) { 'use strict'; console.log('dynamic2', main.value); exports.value = main.value; -}); +})); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/dynamic-import-dynamic-multi-stage/_expected/amd/main.js b/test/chunking-form/samples/improved-dynamic-chunks/dynamic-import-dynamic-multi-stage/_expected/amd/main.js index 1cc193e37b7..90307101cfa 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/dynamic-import-dynamic-multi-stage/_expected/amd/main.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/dynamic-import-dynamic-multi-stage/_expected/amd/main.js @@ -1,12 +1,10 @@ -define(['require', 'exports'], function (require, exports) { 'use strict'; +define(['require', 'exports'], (function (require, exports) { 'use strict'; const value = 'shared'; console.log('dynamic1', value); - new Promise(function (resolve, reject) { require(['./generated-dynamic1'], resolve, reject) }); + new Promise(function (resolve, reject) { require(['./generated-dynamic1'], resolve, reject); }); exports.value = value; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/dynamic-import-dynamic-multi-stage/_expected/cjs/main.js b/test/chunking-form/samples/improved-dynamic-chunks/dynamic-import-dynamic-multi-stage/_expected/cjs/main.js index eed79993ff0..e547a8b0a6d 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/dynamic-import-dynamic-multi-stage/_expected/cjs/main.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/dynamic-import-dynamic-multi-stage/_expected/cjs/main.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - const value = 'shared'; console.log('dynamic1', value); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/dynamic-import-dynamic-multi-stage/_expected/es/generated-dynamic2.js b/test/chunking-form/samples/improved-dynamic-chunks/dynamic-import-dynamic-multi-stage/_expected/es/generated-dynamic2.js index a092412cc30..982e0f809e7 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/dynamic-import-dynamic-multi-stage/_expected/es/generated-dynamic2.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/dynamic-import-dynamic-multi-stage/_expected/es/generated-dynamic2.js @@ -1,4 +1,5 @@ import { value } from './main.js'; -export { value } from './main.js'; console.log('dynamic2', value); + +export { value }; diff --git a/test/chunking-form/samples/improved-dynamic-chunks/dynamic-import-dynamic-multi-stage/_expected/system/generated-dynamic1.js b/test/chunking-form/samples/improved-dynamic-chunks/dynamic-import-dynamic-multi-stage/_expected/system/generated-dynamic1.js index 0d19e5aa49b..768bccdf553 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/dynamic-import-dynamic-multi-stage/_expected/system/generated-dynamic1.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/dynamic-import-dynamic-multi-stage/_expected/system/generated-dynamic1.js @@ -1,10 +1,10 @@ -System.register([], function (exports, module) { +System.register([], (function (exports, module) { 'use strict'; return { - execute: function () { + execute: (function () { module.import('./generated-dynamic2.js'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/dynamic-import-dynamic-multi-stage/_expected/system/generated-dynamic2.js b/test/chunking-form/samples/improved-dynamic-chunks/dynamic-import-dynamic-multi-stage/_expected/system/generated-dynamic2.js index 5bb722682d3..180fb65ff19 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/dynamic-import-dynamic-multi-stage/_expected/system/generated-dynamic2.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/dynamic-import-dynamic-multi-stage/_expected/system/generated-dynamic2.js @@ -1,15 +1,15 @@ -System.register(['./main.js'], function (exports) { +System.register(['./main.js'], (function (exports) { 'use strict'; var value; return { setters: [function (module) { value = module.value; - exports('value', module.value); + exports("value", module.value); }], - execute: function () { + execute: (function () { console.log('dynamic2', value); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/dynamic-import-dynamic-multi-stage/_expected/system/main.js b/test/chunking-form/samples/improved-dynamic-chunks/dynamic-import-dynamic-multi-stage/_expected/system/main.js index fa1f161107b..044d38262a8 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/dynamic-import-dynamic-multi-stage/_expected/system/main.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/dynamic-import-dynamic-multi-stage/_expected/system/main.js @@ -1,13 +1,13 @@ -System.register([], function (exports, module) { +System.register([], (function (exports, module) { 'use strict'; return { - execute: function () { + execute: (function () { - const value = exports('value', 'shared'); + const value = exports("value", 'shared'); console.log('dynamic1', value); module.import('./generated-dynamic1.js'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/dynamic-import-dynamic/_config.js b/test/chunking-form/samples/improved-dynamic-chunks/dynamic-import-dynamic/_config.js index d8b7a769273..7e113af09c4 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/dynamic-import-dynamic/_config.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/dynamic-import-dynamic/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'handles if a dynamically imported module imports another module dynamically' -}; +}); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/dynamic-import-dynamic/_expected/amd/generated-dynamic1.js b/test/chunking-form/samples/improved-dynamic-chunks/dynamic-import-dynamic/_expected/amd/generated-dynamic1.js index 50a4863d1b2..dcde8c31edf 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/dynamic-import-dynamic/_expected/amd/generated-dynamic1.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/dynamic-import-dynamic/_expected/amd/generated-dynamic1.js @@ -1,10 +1,10 @@ -define(['require', 'exports'], function (require, exports) { 'use strict'; +define(['require', 'exports'], (function (require, exports) { 'use strict'; const value = 'shared'; console.log('dynamic1', value); - new Promise(function (resolve, reject) { require(['./generated-dynamic2'], resolve, reject) }); + new Promise(function (resolve, reject) { require(['./generated-dynamic2'], resolve, reject); }); exports.value = value; -}); +})); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/dynamic-import-dynamic/_expected/amd/generated-dynamic2.js b/test/chunking-form/samples/improved-dynamic-chunks/dynamic-import-dynamic/_expected/amd/generated-dynamic2.js index b43d0ad04a5..ab85dd0d062 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/dynamic-import-dynamic/_expected/amd/generated-dynamic2.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/dynamic-import-dynamic/_expected/amd/generated-dynamic2.js @@ -1,7 +1,7 @@ -define(['exports', './generated-dynamic1'], function (exports, dynamic1) { 'use strict'; +define(['exports', './generated-dynamic1'], (function (exports, dynamic1) { 'use strict'; console.log('dynamic2', dynamic1.value); exports.value = dynamic1.value; -}); +})); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/dynamic-import-dynamic/_expected/amd/main.js b/test/chunking-form/samples/improved-dynamic-chunks/dynamic-import-dynamic/_expected/amd/main.js index 935d1692f83..044e0729999 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/dynamic-import-dynamic/_expected/amd/main.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/dynamic-import-dynamic/_expected/amd/main.js @@ -1,5 +1,5 @@ -define(['require'], function (require) { 'use strict'; +define(['require'], (function (require) { 'use strict'; - new Promise(function (resolve, reject) { require(['./generated-dynamic1'], resolve, reject) }); + new Promise(function (resolve, reject) { require(['./generated-dynamic1'], resolve, reject); }); -}); +})); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/dynamic-import-dynamic/_expected/es/generated-dynamic2.js b/test/chunking-form/samples/improved-dynamic-chunks/dynamic-import-dynamic/_expected/es/generated-dynamic2.js index 83da591c684..9e77312b6b4 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/dynamic-import-dynamic/_expected/es/generated-dynamic2.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/dynamic-import-dynamic/_expected/es/generated-dynamic2.js @@ -1,4 +1,5 @@ import { value } from './generated-dynamic1.js'; -export { value } from './generated-dynamic1.js'; console.log('dynamic2', value); + +export { value }; diff --git a/test/chunking-form/samples/improved-dynamic-chunks/dynamic-import-dynamic/_expected/system/generated-dynamic1.js b/test/chunking-form/samples/improved-dynamic-chunks/dynamic-import-dynamic/_expected/system/generated-dynamic1.js index 2730357cfe2..b55968365ff 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/dynamic-import-dynamic/_expected/system/generated-dynamic1.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/dynamic-import-dynamic/_expected/system/generated-dynamic1.js @@ -1,13 +1,13 @@ -System.register([], function (exports, module) { +System.register([], (function (exports, module) { 'use strict'; return { - execute: function () { + execute: (function () { - const value = exports('value', 'shared'); + const value = exports("value", 'shared'); console.log('dynamic1', value); module.import('./generated-dynamic2.js'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/dynamic-import-dynamic/_expected/system/generated-dynamic2.js b/test/chunking-form/samples/improved-dynamic-chunks/dynamic-import-dynamic/_expected/system/generated-dynamic2.js index 934231e63ce..4500adc948c 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/dynamic-import-dynamic/_expected/system/generated-dynamic2.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/dynamic-import-dynamic/_expected/system/generated-dynamic2.js @@ -1,15 +1,15 @@ -System.register(['./generated-dynamic1.js'], function (exports) { +System.register(['./generated-dynamic1.js'], (function (exports) { 'use strict'; var value; return { setters: [function (module) { value = module.value; - exports('value', module.value); + exports("value", module.value); }], - execute: function () { + execute: (function () { console.log('dynamic2', value); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/dynamic-import-dynamic/_expected/system/main.js b/test/chunking-form/samples/improved-dynamic-chunks/dynamic-import-dynamic/_expected/system/main.js index 6bf031d4fed..2f046fa0b2b 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/dynamic-import-dynamic/_expected/system/main.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/dynamic-import-dynamic/_expected/system/main.js @@ -1,10 +1,10 @@ -System.register([], function (exports, module) { +System.register([], (function (exports, module) { 'use strict'; return { - execute: function () { + execute: (function () { module.import('./generated-dynamic1.js'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/dynamic-not-in-memory/_config.js b/test/chunking-form/samples/improved-dynamic-chunks/dynamic-not-in-memory/_config.js index 8d679763598..92b07dee16d 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/dynamic-not-in-memory/_config.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/dynamic-not-in-memory/_config.js @@ -1,6 +1,6 @@ -module.exports = { +module.exports = defineTest({ description: 'keeps chunks separate when not in memory for all dynamic imports', options: { input: ['main1', 'main2', 'main3'] } -}; +}); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/dynamic-not-in-memory/_expected/amd/generated-dep.js b/test/chunking-form/samples/improved-dynamic-chunks/dynamic-not-in-memory/_expected/amd/generated-dep.js index 397a3e627a5..fa57429bdbb 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/dynamic-not-in-memory/_expected/amd/generated-dep.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/dynamic-not-in-memory/_expected/amd/generated-dep.js @@ -1,7 +1,7 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; const value1 = 'dep'; exports.value1 = value1; -}); +})); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/dynamic-not-in-memory/_expected/amd/generated-dynamic.js b/test/chunking-form/samples/improved-dynamic-chunks/dynamic-not-in-memory/_expected/amd/generated-dynamic.js index ddd658c3ee7..f96c3217957 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/dynamic-not-in-memory/_expected/amd/generated-dynamic.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/dynamic-not-in-memory/_expected/amd/generated-dynamic.js @@ -1,5 +1,5 @@ -define(['./generated-dep'], function (dep) { 'use strict'; +define(['./generated-dep'], (function (dep) { 'use strict'; console.log('dynamic', dep.value1); -}); +})); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/dynamic-not-in-memory/_expected/amd/generated-shared.js b/test/chunking-form/samples/improved-dynamic-chunks/dynamic-not-in-memory/_expected/amd/generated-shared.js index f2465789fc3..41d21e9ad6a 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/dynamic-not-in-memory/_expected/amd/generated-shared.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/dynamic-not-in-memory/_expected/amd/generated-shared.js @@ -1,6 +1,6 @@ -define(['require', './generated-dep'], function (require, dep) { 'use strict'; +define(['require', './generated-dep'], (function (require, dep) { 'use strict'; - new Promise(function (resolve, reject) { require(['./generated-dynamic'], resolve, reject) }); + new Promise(function (resolve, reject) { require(['./generated-dynamic'], resolve, reject); }); console.log('shared', dep.value1); -}); +})); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/dynamic-not-in-memory/_expected/amd/main1.js b/test/chunking-form/samples/improved-dynamic-chunks/dynamic-not-in-memory/_expected/amd/main1.js index b8530d391f5..09d673380b6 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/dynamic-not-in-memory/_expected/amd/main1.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/dynamic-not-in-memory/_expected/amd/main1.js @@ -1,5 +1,5 @@ -define(['./generated-shared', './generated-dep'], function (shared, dep) { 'use strict'; +define(['./generated-shared', './generated-dep'], (function (shared, dep) { 'use strict'; console.log('main1'); -}); +})); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/dynamic-not-in-memory/_expected/amd/main2.js b/test/chunking-form/samples/improved-dynamic-chunks/dynamic-not-in-memory/_expected/amd/main2.js index be30778a331..53c7a8e57ac 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/dynamic-not-in-memory/_expected/amd/main2.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/dynamic-not-in-memory/_expected/amd/main2.js @@ -1,5 +1,5 @@ -define(['./generated-shared', './generated-dep'], function (shared, dep) { 'use strict'; +define(['./generated-shared', './generated-dep'], (function (shared, dep) { 'use strict'; console.log('main2'); -}); +})); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/dynamic-not-in-memory/_expected/amd/main3.js b/test/chunking-form/samples/improved-dynamic-chunks/dynamic-not-in-memory/_expected/amd/main3.js index 19f4b8f4188..9b6df58b82f 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/dynamic-not-in-memory/_expected/amd/main3.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/dynamic-not-in-memory/_expected/amd/main3.js @@ -1,7 +1,7 @@ -define(['require'], function (require) { 'use strict'; +define(['require'], (function (require) { 'use strict'; - new Promise(function (resolve, reject) { require(['./generated-dynamic'], resolve, reject) }); + new Promise(function (resolve, reject) { require(['./generated-dynamic'], resolve, reject); }); console.log('main3'); -}); +})); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/dynamic-not-in-memory/_expected/system/generated-dep.js b/test/chunking-form/samples/improved-dynamic-chunks/dynamic-not-in-memory/_expected/system/generated-dep.js index a0da80f9923..bdf09b8e6a8 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/dynamic-not-in-memory/_expected/system/generated-dep.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/dynamic-not-in-memory/_expected/system/generated-dep.js @@ -1,10 +1,10 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - const value1 = exports('v', 'dep'); + const value1 = exports("v", 'dep'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/dynamic-not-in-memory/_expected/system/generated-dynamic.js b/test/chunking-form/samples/improved-dynamic-chunks/dynamic-not-in-memory/_expected/system/generated-dynamic.js index 6a9c0e632e5..d28a89fd88f 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/dynamic-not-in-memory/_expected/system/generated-dynamic.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/dynamic-not-in-memory/_expected/system/generated-dynamic.js @@ -1,14 +1,14 @@ -System.register(['./generated-dep.js'], function () { +System.register(['./generated-dep.js'], (function () { 'use strict'; var value1; return { setters: [function (module) { value1 = module.v; }], - execute: function () { + execute: (function () { console.log('dynamic', value1); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/dynamic-not-in-memory/_expected/system/generated-shared.js b/test/chunking-form/samples/improved-dynamic-chunks/dynamic-not-in-memory/_expected/system/generated-shared.js index 5ca1f03bd70..51cb622d8e1 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/dynamic-not-in-memory/_expected/system/generated-shared.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/dynamic-not-in-memory/_expected/system/generated-shared.js @@ -1,15 +1,15 @@ -System.register(['./generated-dep.js'], function (exports, module) { +System.register(['./generated-dep.js'], (function (exports, module) { 'use strict'; var value1; return { setters: [function (module) { value1 = module.v; }], - execute: function () { + execute: (function () { module.import('./generated-dynamic.js'); console.log('shared', value1); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/dynamic-not-in-memory/_expected/system/main1.js b/test/chunking-form/samples/improved-dynamic-chunks/dynamic-not-in-memory/_expected/system/main1.js index 2e44d944de9..81a14baade8 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/dynamic-not-in-memory/_expected/system/main1.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/dynamic-not-in-memory/_expected/system/main1.js @@ -1,11 +1,11 @@ -System.register(['./generated-shared.js', './generated-dep.js'], function () { +System.register(['./generated-shared.js', './generated-dep.js'], (function () { 'use strict'; return { - setters: [function () {}, function () {}], - execute: function () { + setters: [null, null], + execute: (function () { console.log('main1'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/dynamic-not-in-memory/_expected/system/main2.js b/test/chunking-form/samples/improved-dynamic-chunks/dynamic-not-in-memory/_expected/system/main2.js index 569ffa4f137..5adf7bbffac 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/dynamic-not-in-memory/_expected/system/main2.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/dynamic-not-in-memory/_expected/system/main2.js @@ -1,11 +1,11 @@ -System.register(['./generated-shared.js', './generated-dep.js'], function () { +System.register(['./generated-shared.js', './generated-dep.js'], (function () { 'use strict'; return { - setters: [function () {}, function () {}], - execute: function () { + setters: [null, null], + execute: (function () { console.log('main2'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/dynamic-not-in-memory/_expected/system/main3.js b/test/chunking-form/samples/improved-dynamic-chunks/dynamic-not-in-memory/_expected/system/main3.js index 168b997d8da..24c653f1a20 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/dynamic-not-in-memory/_expected/system/main3.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/dynamic-not-in-memory/_expected/system/main3.js @@ -1,12 +1,12 @@ -System.register([], function (exports, module) { +System.register([], (function (exports, module) { 'use strict'; return { - execute: function () { + execute: (function () { module.import('./generated-dynamic.js'); console.log('main3'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-and-shared-dependencies/_config.js b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-and-shared-dependencies/_config.js index fd9e687a29a..8493c52ad2f 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-and-shared-dependencies/_config.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-and-shared-dependencies/_config.js @@ -1,7 +1,7 @@ -module.exports = { +module.exports = defineTest({ description: 'avoids chunks for always loaded dependencies if multiple entry points with different dependencies have dynamic imports', options: { input: ['main1', 'main2'] } -}; +}); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-and-shared-dependencies/_expected/amd/generated-dynamic.js b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-and-shared-dependencies/_expected/amd/generated-dynamic.js index 10daf999052..05a6422d40f 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-and-shared-dependencies/_expected/amd/generated-dynamic.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-and-shared-dependencies/_expected/amd/generated-dynamic.js @@ -1,8 +1,8 @@ -define(['exports', './generated-from-main-1-and-dynamic', './generated-from-main-1-and-2'], function (exports, fromMain1AndDynamic, fromMain1And2) { 'use strict'; +define(['exports', './generated-from-main-1-and-dynamic', './generated-from-main-1-and-2'], (function (exports, fromMain1AndDynamic, fromMain1And2) { 'use strict'; console.log('dynamic1', fromMain1AndDynamic.value1, fromMain1And2.value2); exports.value1 = fromMain1AndDynamic.value1; exports.value2 = fromMain1And2.value2; -}); +})); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-and-shared-dependencies/_expected/amd/generated-from-main-1-and-2.js b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-and-shared-dependencies/_expected/amd/generated-from-main-1-and-2.js index bd61814cfd4..634a4859ac5 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-and-shared-dependencies/_expected/amd/generated-from-main-1-and-2.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-and-shared-dependencies/_expected/amd/generated-from-main-1-and-2.js @@ -1,4 +1,4 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; const value2 = 'all'; @@ -7,4 +7,4 @@ define(['exports'], function (exports) { 'use strict'; exports.value2 = value2; exports.value3 = value3; -}); +})); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-and-shared-dependencies/_expected/amd/generated-from-main-1-and-dynamic.js b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-and-shared-dependencies/_expected/amd/generated-from-main-1-and-dynamic.js index 003c64a967f..4cc52f8fd03 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-and-shared-dependencies/_expected/amd/generated-from-main-1-and-dynamic.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-and-shared-dependencies/_expected/amd/generated-from-main-1-and-dynamic.js @@ -1,7 +1,7 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; const value1 = 'main1 and dynamic'; exports.value1 = value1; -}); +})); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-and-shared-dependencies/_expected/amd/main1.js b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-and-shared-dependencies/_expected/amd/main1.js index eac3239623d..6332d864ba6 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-and-shared-dependencies/_expected/amd/main1.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-and-shared-dependencies/_expected/amd/main1.js @@ -1,12 +1,10 @@ -define(['require', 'exports', './generated-from-main-1-and-dynamic', './generated-from-main-1-and-2'], function (require, exports, fromMain1AndDynamic, fromMain1And2) { 'use strict'; +define(['require', 'exports', './generated-from-main-1-and-dynamic', './generated-from-main-1-and-2'], (function (require, exports, fromMain1AndDynamic, fromMain1And2) { 'use strict'; console.log('main1', fromMain1AndDynamic.value1, fromMain1And2.value2, fromMain1And2.value3); - new Promise(function (resolve, reject) { require(['./generated-dynamic'], resolve, reject) }); + new Promise(function (resolve, reject) { require(['./generated-dynamic'], resolve, reject); }); exports.value1 = fromMain1AndDynamic.value1; exports.value2 = fromMain1And2.value2; exports.value3 = fromMain1And2.value3; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-and-shared-dependencies/_expected/amd/main2.js b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-and-shared-dependencies/_expected/amd/main2.js index 5a746a349a7..7ac0888d98d 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-and-shared-dependencies/_expected/amd/main2.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-and-shared-dependencies/_expected/amd/main2.js @@ -1,11 +1,9 @@ -define(['require', 'exports', './generated-from-main-1-and-2'], function (require, exports, fromMain1And2) { 'use strict'; +define(['require', 'exports', './generated-from-main-1-and-2'], (function (require, exports, fromMain1And2) { 'use strict'; console.log('main2', fromMain1And2.value2, fromMain1And2.value3); - new Promise(function (resolve, reject) { require(['./generated-dynamic'], resolve, reject) }); + new Promise(function (resolve, reject) { require(['./generated-dynamic'], resolve, reject); }); exports.value2 = fromMain1And2.value2; exports.value3 = fromMain1And2.value3; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-and-shared-dependencies/_expected/cjs/main1.js b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-and-shared-dependencies/_expected/cjs/main1.js index 4d2113add8e..649a253a15e 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-and-shared-dependencies/_expected/cjs/main1.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-and-shared-dependencies/_expected/cjs/main1.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - var fromMain1AndDynamic = require('./generated-from-main-1-and-dynamic.js'); var fromMain1And2 = require('./generated-from-main-1-and-2.js'); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-and-shared-dependencies/_expected/cjs/main2.js b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-and-shared-dependencies/_expected/cjs/main2.js index af0a1590d26..fde80335cbe 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-and-shared-dependencies/_expected/cjs/main2.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-and-shared-dependencies/_expected/cjs/main2.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - var fromMain1And2 = require('./generated-from-main-1-and-2.js'); console.log('main2', fromMain1And2.value2, fromMain1And2.value3); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-and-shared-dependencies/_expected/es/generated-dynamic.js b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-and-shared-dependencies/_expected/es/generated-dynamic.js index 27e2a2c6636..6380c9bf25f 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-and-shared-dependencies/_expected/es/generated-dynamic.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-and-shared-dependencies/_expected/es/generated-dynamic.js @@ -1,6 +1,6 @@ import { v as value1 } from './generated-from-main-1-and-dynamic.js'; -export { v as value1 } from './generated-from-main-1-and-dynamic.js'; import { v as value2 } from './generated-from-main-1-and-2.js'; -export { v as value2 } from './generated-from-main-1-and-2.js'; console.log('dynamic1', value1, value2); + +export { value1, value2 }; diff --git a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-and-shared-dependencies/_expected/es/main1.js b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-and-shared-dependencies/_expected/es/main1.js index 8762e90e0e4..3b3b3151a91 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-and-shared-dependencies/_expected/es/main1.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-and-shared-dependencies/_expected/es/main1.js @@ -1,7 +1,7 @@ import { v as value1 } from './generated-from-main-1-and-dynamic.js'; -export { v as value1 } from './generated-from-main-1-and-dynamic.js'; import { v as value2, a as value3 } from './generated-from-main-1-and-2.js'; -export { v as value2, a as value3 } from './generated-from-main-1-and-2.js'; console.log('main1', value1, value2, value3); import('./generated-dynamic.js'); + +export { value1, value2, value3 }; diff --git a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-and-shared-dependencies/_expected/es/main2.js b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-and-shared-dependencies/_expected/es/main2.js index 0967a06d772..69ec00b4439 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-and-shared-dependencies/_expected/es/main2.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-and-shared-dependencies/_expected/es/main2.js @@ -1,5 +1,6 @@ import { v as value2, a as value3 } from './generated-from-main-1-and-2.js'; -export { v as value2, a as value3 } from './generated-from-main-1-and-2.js'; console.log('main2', value2, value3); import('./generated-dynamic.js'); + +export { value2, value3 }; diff --git a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-and-shared-dependencies/_expected/system/generated-dynamic.js b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-and-shared-dependencies/_expected/system/generated-dynamic.js index 348735eeb2c..827b171fc8a 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-and-shared-dependencies/_expected/system/generated-dynamic.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-and-shared-dependencies/_expected/system/generated-dynamic.js @@ -1,18 +1,18 @@ -System.register(['./generated-from-main-1-and-dynamic.js', './generated-from-main-1-and-2.js'], function (exports) { +System.register(['./generated-from-main-1-and-dynamic.js', './generated-from-main-1-and-2.js'], (function (exports) { 'use strict'; var value1, value2; return { setters: [function (module) { value1 = module.v; - exports('value1', module.v); + exports("value1", module.v); }, function (module) { value2 = module.v; - exports('value2', module.v); + exports("value2", module.v); }], - execute: function () { + execute: (function () { console.log('dynamic1', value1, value2); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-and-shared-dependencies/_expected/system/generated-from-main-1-and-2.js b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-and-shared-dependencies/_expected/system/generated-from-main-1-and-2.js index 31fbb093f29..066246a4091 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-and-shared-dependencies/_expected/system/generated-from-main-1-and-2.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-and-shared-dependencies/_expected/system/generated-from-main-1-and-2.js @@ -1,12 +1,12 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - const value2 = exports('v', 'all'); + const value2 = exports("v", 'all'); - const value3 = exports('a', 'main1 and main2'); + const value3 = exports("a", 'main1 and main2'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-and-shared-dependencies/_expected/system/generated-from-main-1-and-dynamic.js b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-and-shared-dependencies/_expected/system/generated-from-main-1-and-dynamic.js index 0e97c43984d..c8d1ed2c10b 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-and-shared-dependencies/_expected/system/generated-from-main-1-and-dynamic.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-and-shared-dependencies/_expected/system/generated-from-main-1-and-dynamic.js @@ -1,10 +1,10 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - const value1 = exports('v', 'main1 and dynamic'); + const value1 = exports("v", 'main1 and dynamic'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-and-shared-dependencies/_expected/system/main1.js b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-and-shared-dependencies/_expected/system/main1.js index b736d7a05fa..292d7a74595 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-and-shared-dependencies/_expected/system/main1.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-and-shared-dependencies/_expected/system/main1.js @@ -1,23 +1,20 @@ -System.register(['./generated-from-main-1-and-dynamic.js', './generated-from-main-1-and-2.js'], function (exports, module) { +System.register(['./generated-from-main-1-and-dynamic.js', './generated-from-main-1-and-2.js'], (function (exports, module) { 'use strict'; var value1, value2, value3; return { setters: [function (module) { value1 = module.v; - exports('value1', module.v); + exports("value1", module.v); }, function (module) { value2 = module.v; value3 = module.a; - var _setter = {}; - _setter.value2 = module.v; - _setter.value3 = module.a; - exports(_setter); + exports({ value2: module.v, value3: module.a }); }], - execute: function () { + execute: (function () { console.log('main1', value1, value2, value3); module.import('./generated-dynamic.js'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-and-shared-dependencies/_expected/system/main2.js b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-and-shared-dependencies/_expected/system/main2.js index 1aca888b896..a899ec2add7 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-and-shared-dependencies/_expected/system/main2.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-and-shared-dependencies/_expected/system/main2.js @@ -1,20 +1,17 @@ -System.register(['./generated-from-main-1-and-2.js'], function (exports, module) { +System.register(['./generated-from-main-1-and-2.js'], (function (exports, module) { 'use strict'; var value2, value3; return { setters: [function (module) { value2 = module.v; value3 = module.a; - var _setter = {}; - _setter.value2 = module.v; - _setter.value3 = module.a; - exports(_setter); + exports({ value2: module.v, value3: module.a }); }], - execute: function () { + execute: (function () { console.log('main2', value2, value3); module.import('./generated-dynamic.js'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-dependencies/_config.js b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-dependencies/_config.js index fd9e687a29a..8493c52ad2f 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-dependencies/_config.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-dependencies/_config.js @@ -1,7 +1,7 @@ -module.exports = { +module.exports = defineTest({ description: 'avoids chunks for always loaded dependencies if multiple entry points with different dependencies have dynamic imports', options: { input: ['main1', 'main2'] } -}; +}); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-dependencies/_expected/amd/generated-dep1.js b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-dependencies/_expected/amd/generated-dep1.js index aa83bc12cab..eba0de549fd 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-dependencies/_expected/amd/generated-dep1.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-dependencies/_expected/amd/generated-dep1.js @@ -1,7 +1,7 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; const value1 = 'shared1'; exports.value1 = value1; -}); +})); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-dependencies/_expected/amd/generated-dep2.js b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-dependencies/_expected/amd/generated-dep2.js index b728fc2ba24..09036e72084 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-dependencies/_expected/amd/generated-dep2.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-dependencies/_expected/amd/generated-dep2.js @@ -1,7 +1,7 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; const value2 = 'shared2'; exports.value2 = value2; -}); +})); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-dependencies/_expected/amd/generated-dynamic.js b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-dependencies/_expected/amd/generated-dynamic.js index 35442e34c36..e7672b63949 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-dependencies/_expected/amd/generated-dynamic.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-dependencies/_expected/amd/generated-dynamic.js @@ -1,8 +1,8 @@ -define(['exports', './generated-dep1', './generated-dep2'], function (exports, dep1, dep2) { 'use strict'; +define(['exports', './generated-dep1', './generated-dep2'], (function (exports, dep1, dep2) { 'use strict'; console.log('dynamic1', dep1.value1, dep2.value2); exports.value1 = dep1.value1; exports.value2 = dep2.value2; -}); +})); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-dependencies/_expected/amd/main1.js b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-dependencies/_expected/amd/main1.js index 67e14ca6faa..208aca62975 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-dependencies/_expected/amd/main1.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-dependencies/_expected/amd/main1.js @@ -1,13 +1,11 @@ -define(['require', 'exports', './generated-dep1', './generated-dep2'], function (require, exports, dep1, dep2) { 'use strict'; +define(['require', 'exports', './generated-dep1', './generated-dep2'], (function (require, exports, dep1, dep2) { 'use strict'; const something = 'something'; console.log('main1', dep1.value1, dep2.value2, something); - new Promise(function (resolve, reject) { require(['./generated-dynamic'], resolve, reject) }); + new Promise(function (resolve, reject) { require(['./generated-dynamic'], resolve, reject); }); exports.value1 = dep1.value1; exports.value2 = dep2.value2; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-dependencies/_expected/amd/main2.js b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-dependencies/_expected/amd/main2.js index 5411a5236e1..27a36093db2 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-dependencies/_expected/amd/main2.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-dependencies/_expected/amd/main2.js @@ -1,10 +1,8 @@ -define(['require', 'exports', './generated-dep2'], function (require, exports, dep2) { 'use strict'; +define(['require', 'exports', './generated-dep2'], (function (require, exports, dep2) { 'use strict'; console.log('main2', dep2.value2); - new Promise(function (resolve, reject) { require(['./generated-dynamic'], resolve, reject) }); + new Promise(function (resolve, reject) { require(['./generated-dynamic'], resolve, reject); }); exports.value2 = dep2.value2; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-dependencies/_expected/cjs/main1.js b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-dependencies/_expected/cjs/main1.js index 3134e2d98eb..4d238a7c135 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-dependencies/_expected/cjs/main1.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-dependencies/_expected/cjs/main1.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - var dep1 = require('./generated-dep1.js'); var dep2 = require('./generated-dep2.js'); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-dependencies/_expected/cjs/main2.js b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-dependencies/_expected/cjs/main2.js index 782db267adf..ff0bde842e1 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-dependencies/_expected/cjs/main2.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-dependencies/_expected/cjs/main2.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - var dep2 = require('./generated-dep2.js'); console.log('main2', dep2.value2); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-dependencies/_expected/es/generated-dynamic.js b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-dependencies/_expected/es/generated-dynamic.js index f4548c7c3ac..048134a8fb1 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-dependencies/_expected/es/generated-dynamic.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-dependencies/_expected/es/generated-dynamic.js @@ -1,6 +1,6 @@ import { v as value1 } from './generated-dep1.js'; -export { v as value1 } from './generated-dep1.js'; import { v as value2 } from './generated-dep2.js'; -export { v as value2 } from './generated-dep2.js'; console.log('dynamic1', value1, value2); + +export { value1, value2 }; diff --git a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-dependencies/_expected/es/main1.js b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-dependencies/_expected/es/main1.js index fa5963a970a..a6e38954434 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-dependencies/_expected/es/main1.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-dependencies/_expected/es/main1.js @@ -1,9 +1,9 @@ import { v as value1 } from './generated-dep1.js'; -export { v as value1 } from './generated-dep1.js'; import { v as value2 } from './generated-dep2.js'; -export { v as value2 } from './generated-dep2.js'; const something = 'something'; console.log('main1', value1, value2, something); import('./generated-dynamic.js'); + +export { value1, value2 }; diff --git a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-dependencies/_expected/es/main2.js b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-dependencies/_expected/es/main2.js index eac967da533..9c7e4462b03 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-dependencies/_expected/es/main2.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-dependencies/_expected/es/main2.js @@ -1,5 +1,6 @@ import { v as value2 } from './generated-dep2.js'; -export { v as value2 } from './generated-dep2.js'; console.log('main2', value2); import('./generated-dynamic.js'); + +export { value2 }; diff --git a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-dependencies/_expected/system/generated-dep1.js b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-dependencies/_expected/system/generated-dep1.js index 65ef243d0ae..c883b92bc4d 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-dependencies/_expected/system/generated-dep1.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-dependencies/_expected/system/generated-dep1.js @@ -1,10 +1,10 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - const value1 = exports('v', 'shared1'); + const value1 = exports("v", 'shared1'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-dependencies/_expected/system/generated-dep2.js b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-dependencies/_expected/system/generated-dep2.js index af5ad2b9e6d..35c7c89f7f2 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-dependencies/_expected/system/generated-dep2.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-dependencies/_expected/system/generated-dep2.js @@ -1,10 +1,10 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - const value2 = exports('v', 'shared2'); + const value2 = exports("v", 'shared2'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-dependencies/_expected/system/generated-dynamic.js b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-dependencies/_expected/system/generated-dynamic.js index 6db6e1afcbd..46886cae883 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-dependencies/_expected/system/generated-dynamic.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-dependencies/_expected/system/generated-dynamic.js @@ -1,18 +1,18 @@ -System.register(['./generated-dep1.js', './generated-dep2.js'], function (exports) { +System.register(['./generated-dep1.js', './generated-dep2.js'], (function (exports) { 'use strict'; var value1, value2; return { setters: [function (module) { value1 = module.v; - exports('value1', module.v); + exports("value1", module.v); }, function (module) { value2 = module.v; - exports('value2', module.v); + exports("value2", module.v); }], - execute: function () { + execute: (function () { console.log('dynamic1', value1, value2); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-dependencies/_expected/system/main1.js b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-dependencies/_expected/system/main1.js index a9473f8ab02..b46f3803574 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-dependencies/_expected/system/main1.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-dependencies/_expected/system/main1.js @@ -1,21 +1,21 @@ -System.register(['./generated-dep1.js', './generated-dep2.js'], function (exports, module) { +System.register(['./generated-dep1.js', './generated-dep2.js'], (function (exports, module) { 'use strict'; var value1, value2; return { setters: [function (module) { value1 = module.v; - exports('value1', module.v); + exports("value1", module.v); }, function (module) { value2 = module.v; - exports('value2', module.v); + exports("value2", module.v); }], - execute: function () { + execute: (function () { const something = 'something'; console.log('main1', value1, value2, something); module.import('./generated-dynamic.js'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-dependencies/_expected/system/main2.js b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-dependencies/_expected/system/main2.js index 528d214357c..0e0f2ceb9d7 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-dependencies/_expected/system/main2.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-different-dependencies/_expected/system/main2.js @@ -1,16 +1,16 @@ -System.register(['./generated-dep2.js'], function (exports, module) { +System.register(['./generated-dep2.js'], (function (exports, module) { 'use strict'; var value2; return { setters: [function (module) { value2 = module.v; - exports('value2', module.v); + exports("value2", module.v); }], - execute: function () { + execute: (function () { console.log('main2', value2); module.import('./generated-dynamic.js'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-partly-already-loaded-dynamic/_config.js b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-partly-already-loaded-dynamic/_config.js index fd9e687a29a..8493c52ad2f 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-partly-already-loaded-dynamic/_config.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-partly-already-loaded-dynamic/_config.js @@ -1,7 +1,7 @@ -module.exports = { +module.exports = defineTest({ description: 'avoids chunks for always loaded dependencies if multiple entry points with different dependencies have dynamic imports', options: { input: ['main1', 'main2'] } -}; +}); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-partly-already-loaded-dynamic/_expected/amd/generated-dep2.js b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-partly-already-loaded-dynamic/_expected/amd/generated-dep2.js index b728fc2ba24..09036e72084 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-partly-already-loaded-dynamic/_expected/amd/generated-dep2.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-partly-already-loaded-dynamic/_expected/amd/generated-dep2.js @@ -1,7 +1,7 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; const value2 = 'shared2'; exports.value2 = value2; -}); +})); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-partly-already-loaded-dynamic/_expected/amd/generated-dynamic1.js b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-partly-already-loaded-dynamic/_expected/amd/generated-dynamic1.js index 42096a32cee..d86ea0561b6 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-partly-already-loaded-dynamic/_expected/amd/generated-dynamic1.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-partly-already-loaded-dynamic/_expected/amd/generated-dynamic1.js @@ -1,7 +1,7 @@ -define(['exports', './main1', './generated-dep2'], function (exports, main1, dep2) { 'use strict'; +define(['exports', './main1', './generated-dep2'], (function (exports, main1, dep2) { 'use strict'; console.log('dynamic1', main1.value1); exports.value1 = main1.value1; -}); +})); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-partly-already-loaded-dynamic/_expected/amd/generated-dynamic2.js b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-partly-already-loaded-dynamic/_expected/amd/generated-dynamic2.js index 42269ebe1c5..642ac1f8c9a 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-partly-already-loaded-dynamic/_expected/amd/generated-dynamic2.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-partly-already-loaded-dynamic/_expected/amd/generated-dynamic2.js @@ -1,7 +1,7 @@ -define(['exports', './generated-dep2'], function (exports, dep2) { 'use strict'; +define(['exports', './generated-dep2'], (function (exports, dep2) { 'use strict'; console.log('dynamic2', dep2.value2); exports.value2 = dep2.value2; -}); +})); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-partly-already-loaded-dynamic/_expected/amd/main1.js b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-partly-already-loaded-dynamic/_expected/amd/main1.js index 05e7ad09749..cb1d05e77eb 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-partly-already-loaded-dynamic/_expected/amd/main1.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-partly-already-loaded-dynamic/_expected/amd/main1.js @@ -1,13 +1,11 @@ -define(['require', 'exports', './generated-dep2'], function (require, exports, dep2) { 'use strict'; +define(['require', 'exports', './generated-dep2'], (function (require, exports, dep2) { 'use strict'; const value1 = 'shared1'; console.log('main1', value1, dep2.value2); - new Promise(function (resolve, reject) { require(['./generated-dynamic1'], resolve, reject) }); + new Promise(function (resolve, reject) { require(['./generated-dynamic1'], resolve, reject); }); exports.value2 = dep2.value2; exports.value1 = value1; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-partly-already-loaded-dynamic/_expected/amd/main2.js b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-partly-already-loaded-dynamic/_expected/amd/main2.js index 9f9a3f577e1..fb1681eb43e 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-partly-already-loaded-dynamic/_expected/amd/main2.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-partly-already-loaded-dynamic/_expected/amd/main2.js @@ -1,10 +1,8 @@ -define(['require', 'exports', './generated-dep2'], function (require, exports, dep2) { 'use strict'; +define(['require', 'exports', './generated-dep2'], (function (require, exports, dep2) { 'use strict'; console.log('main2', dep2.value2); - new Promise(function (resolve, reject) { require(['./generated-dynamic2'], resolve, reject) }); + new Promise(function (resolve, reject) { require(['./generated-dynamic2'], resolve, reject); }); exports.value2 = dep2.value2; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-partly-already-loaded-dynamic/_expected/cjs/main1.js b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-partly-already-loaded-dynamic/_expected/cjs/main1.js index 77a24bd8173..204a4307432 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-partly-already-loaded-dynamic/_expected/cjs/main1.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-partly-already-loaded-dynamic/_expected/cjs/main1.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - var dep2 = require('./generated-dep2.js'); const value1 = 'shared1'; diff --git a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-partly-already-loaded-dynamic/_expected/cjs/main2.js b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-partly-already-loaded-dynamic/_expected/cjs/main2.js index 86e101c64c8..2b88a744f0b 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-partly-already-loaded-dynamic/_expected/cjs/main2.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-partly-already-loaded-dynamic/_expected/cjs/main2.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - var dep2 = require('./generated-dep2.js'); console.log('main2', dep2.value2); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-partly-already-loaded-dynamic/_expected/es/generated-dynamic1.js b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-partly-already-loaded-dynamic/_expected/es/generated-dynamic1.js index eec2d5323f1..76961847004 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-partly-already-loaded-dynamic/_expected/es/generated-dynamic1.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-partly-already-loaded-dynamic/_expected/es/generated-dynamic1.js @@ -1,5 +1,6 @@ import { value1 } from './main1.js'; -export { value1 } from './main1.js'; import './generated-dep2.js'; console.log('dynamic1', value1); + +export { value1 }; diff --git a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-partly-already-loaded-dynamic/_expected/es/generated-dynamic2.js b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-partly-already-loaded-dynamic/_expected/es/generated-dynamic2.js index ce16c9af379..027cb6f031e 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-partly-already-loaded-dynamic/_expected/es/generated-dynamic2.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-partly-already-loaded-dynamic/_expected/es/generated-dynamic2.js @@ -1,4 +1,5 @@ import { v as value2 } from './generated-dep2.js'; -export { v as value2 } from './generated-dep2.js'; console.log('dynamic2', value2); + +export { value2 }; diff --git a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-partly-already-loaded-dynamic/_expected/es/main1.js b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-partly-already-loaded-dynamic/_expected/es/main1.js index 090f16af526..d32767617a2 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-partly-already-loaded-dynamic/_expected/es/main1.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-partly-already-loaded-dynamic/_expected/es/main1.js @@ -1,9 +1,8 @@ import { v as value2 } from './generated-dep2.js'; -export { v as value2 } from './generated-dep2.js'; const value1 = 'shared1'; console.log('main1', value1, value2); import('./generated-dynamic1.js'); -export { value1 }; +export { value1, value2 }; diff --git a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-partly-already-loaded-dynamic/_expected/es/main2.js b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-partly-already-loaded-dynamic/_expected/es/main2.js index 7837ea7eca3..4217394441d 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-partly-already-loaded-dynamic/_expected/es/main2.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-partly-already-loaded-dynamic/_expected/es/main2.js @@ -1,5 +1,6 @@ import { v as value2 } from './generated-dep2.js'; -export { v as value2 } from './generated-dep2.js'; console.log('main2', value2); import('./generated-dynamic2.js'); + +export { value2 }; diff --git a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-partly-already-loaded-dynamic/_expected/system/generated-dep2.js b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-partly-already-loaded-dynamic/_expected/system/generated-dep2.js index af5ad2b9e6d..35c7c89f7f2 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-partly-already-loaded-dynamic/_expected/system/generated-dep2.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-partly-already-loaded-dynamic/_expected/system/generated-dep2.js @@ -1,10 +1,10 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - const value2 = exports('v', 'shared2'); + const value2 = exports("v", 'shared2'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-partly-already-loaded-dynamic/_expected/system/generated-dynamic1.js b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-partly-already-loaded-dynamic/_expected/system/generated-dynamic1.js index 7ec987e9404..908048004d8 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-partly-already-loaded-dynamic/_expected/system/generated-dynamic1.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-partly-already-loaded-dynamic/_expected/system/generated-dynamic1.js @@ -1,15 +1,15 @@ -System.register(['./main1.js', './generated-dep2.js'], function (exports) { +System.register(['./main1.js', './generated-dep2.js'], (function (exports) { 'use strict'; var value1; return { setters: [function (module) { value1 = module.value1; - exports('value1', module.value1); - }, function () {}], - execute: function () { + exports("value1", module.value1); + }, null], + execute: (function () { console.log('dynamic1', value1); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-partly-already-loaded-dynamic/_expected/system/generated-dynamic2.js b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-partly-already-loaded-dynamic/_expected/system/generated-dynamic2.js index 6a4117a6e7a..2cf55c00c89 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-partly-already-loaded-dynamic/_expected/system/generated-dynamic2.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-partly-already-loaded-dynamic/_expected/system/generated-dynamic2.js @@ -1,15 +1,15 @@ -System.register(['./generated-dep2.js'], function (exports) { +System.register(['./generated-dep2.js'], (function (exports) { 'use strict'; var value2; return { setters: [function (module) { value2 = module.v; - exports('value2', module.v); + exports("value2", module.v); }], - execute: function () { + execute: (function () { console.log('dynamic2', value2); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-partly-already-loaded-dynamic/_expected/system/main1.js b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-partly-already-loaded-dynamic/_expected/system/main1.js index 470b5052df5..6cd2f1d5dd9 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-partly-already-loaded-dynamic/_expected/system/main1.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-partly-already-loaded-dynamic/_expected/system/main1.js @@ -1,18 +1,18 @@ -System.register(['./generated-dep2.js'], function (exports, module) { +System.register(['./generated-dep2.js'], (function (exports, module) { 'use strict'; var value2; return { setters: [function (module) { value2 = module.v; - exports('value2', module.v); + exports("value2", module.v); }], - execute: function () { + execute: (function () { - const value1 = exports('value1', 'shared1'); + const value1 = exports("value1", 'shared1'); console.log('main1', value1, value2); module.import('./generated-dynamic1.js'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-partly-already-loaded-dynamic/_expected/system/main2.js b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-partly-already-loaded-dynamic/_expected/system/main2.js index 295aa292840..ba819c24ade 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-partly-already-loaded-dynamic/_expected/system/main2.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-partly-already-loaded-dynamic/_expected/system/main2.js @@ -1,16 +1,16 @@ -System.register(['./generated-dep2.js'], function (exports, module) { +System.register(['./generated-dep2.js'], (function (exports, module) { 'use strict'; var value2; return { setters: [function (module) { value2 = module.v; - exports('value2', module.v); + exports("value2", module.v); }], - execute: function () { + execute: (function () { console.log('main2', value2); module.import('./generated-dynamic2.js'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-shared-static-with-dynamic-import/_config.js b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-shared-static-with-dynamic-import/_config.js index fd9e687a29a..8493c52ad2f 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-shared-static-with-dynamic-import/_config.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-shared-static-with-dynamic-import/_config.js @@ -1,7 +1,7 @@ -module.exports = { +module.exports = defineTest({ description: 'avoids chunks for always loaded dependencies if multiple entry points with different dependencies have dynamic imports', options: { input: ['main1', 'main2'] } -}; +}); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-shared-static-with-dynamic-import/_expected/amd/generated-dynamic.js b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-shared-static-with-dynamic-import/_expected/amd/generated-dynamic.js index 12c490a65d7..57440e418b3 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-shared-static-with-dynamic-import/_expected/amd/generated-dynamic.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-shared-static-with-dynamic-import/_expected/amd/generated-dynamic.js @@ -1,5 +1,5 @@ -define(['./generated-shared'], function (shared) { 'use strict'; +define(['./generated-shared'], (function (shared) { 'use strict'; console.log('dynamic', shared.value1); -}); +})); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-shared-static-with-dynamic-import/_expected/amd/generated-shared.js b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-shared-static-with-dynamic-import/_expected/amd/generated-shared.js index 01bb5903aa3..9098968ce25 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-shared-static-with-dynamic-import/_expected/amd/generated-shared.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-shared-static-with-dynamic-import/_expected/amd/generated-shared.js @@ -1,10 +1,10 @@ -define(['require', 'exports'], function (require, exports) { 'use strict'; +define(['require', 'exports'], (function (require, exports) { 'use strict'; const value1 = 'dep'; - new Promise(function (resolve, reject) { require(['./generated-dynamic'], resolve, reject) }); + new Promise(function (resolve, reject) { require(['./generated-dynamic'], resolve, reject); }); console.log('shared', value1); exports.value1 = value1; -}); +})); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-shared-static-with-dynamic-import/_expected/amd/main1.js b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-shared-static-with-dynamic-import/_expected/amd/main1.js index c018fae72c1..5d3c33a18aa 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-shared-static-with-dynamic-import/_expected/amd/main1.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-shared-static-with-dynamic-import/_expected/amd/main1.js @@ -1,5 +1,5 @@ -define(['./generated-shared'], function (shared) { 'use strict'; +define(['./generated-shared'], (function (shared) { 'use strict'; console.log('main1'); -}); +})); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-shared-static-with-dynamic-import/_expected/amd/main2.js b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-shared-static-with-dynamic-import/_expected/amd/main2.js index dd385452003..ed3debceeb5 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-shared-static-with-dynamic-import/_expected/amd/main2.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-shared-static-with-dynamic-import/_expected/amd/main2.js @@ -1,5 +1,5 @@ -define(['./generated-shared'], function (shared) { 'use strict'; +define(['./generated-shared'], (function (shared) { 'use strict'; console.log('main2'); -}); +})); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-shared-static-with-dynamic-import/_expected/system/generated-dynamic.js b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-shared-static-with-dynamic-import/_expected/system/generated-dynamic.js index 659a4e37473..53e95abfe53 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-shared-static-with-dynamic-import/_expected/system/generated-dynamic.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-shared-static-with-dynamic-import/_expected/system/generated-dynamic.js @@ -1,14 +1,14 @@ -System.register(['./generated-shared.js'], function () { +System.register(['./generated-shared.js'], (function () { 'use strict'; var value1; return { setters: [function (module) { value1 = module.v; }], - execute: function () { + execute: (function () { console.log('dynamic', value1); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-shared-static-with-dynamic-import/_expected/system/generated-shared.js b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-shared-static-with-dynamic-import/_expected/system/generated-shared.js index 03771769b9e..cd649c42f5e 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-shared-static-with-dynamic-import/_expected/system/generated-shared.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-shared-static-with-dynamic-import/_expected/system/generated-shared.js @@ -1,13 +1,13 @@ -System.register([], function (exports, module) { +System.register([], (function (exports, module) { 'use strict'; return { - execute: function () { + execute: (function () { - const value1 = exports('v', 'dep'); + const value1 = exports("v", 'dep'); module.import('./generated-dynamic.js'); console.log('shared', value1); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-shared-static-with-dynamic-import/_expected/system/main1.js b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-shared-static-with-dynamic-import/_expected/system/main1.js index 494e5e24557..f4992f47347 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-shared-static-with-dynamic-import/_expected/system/main1.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-shared-static-with-dynamic-import/_expected/system/main1.js @@ -1,11 +1,11 @@ -System.register(['./generated-shared.js'], function () { +System.register(['./generated-shared.js'], (function () { 'use strict'; return { - setters: [function () {}], - execute: function () { + setters: [null], + execute: (function () { console.log('main1'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-shared-static-with-dynamic-import/_expected/system/main2.js b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-shared-static-with-dynamic-import/_expected/system/main2.js index da2aaca8f06..a85cddd61c7 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-shared-static-with-dynamic-import/_expected/system/main2.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/multi-entry-shared-static-with-dynamic-import/_expected/system/main2.js @@ -1,11 +1,11 @@ -System.register(['./generated-shared.js'], function () { +System.register(['./generated-shared.js'], (function () { 'use strict'; return { - setters: [function () {}], - execute: function () { + setters: [null], + execute: (function () { console.log('main2'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/single-dynamic-multiple-imports/_config.js b/test/chunking-form/samples/improved-dynamic-chunks/single-dynamic-multiple-imports/_config.js index 03f32f46185..9f42c784a4b 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/single-dynamic-multiple-imports/_config.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/single-dynamic-multiple-imports/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'does not create a separate chunk if a dynamically imported chunk shares a dependency with its importer, and dynamic chunk imported from multiple places' -}; +}); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/single-dynamic-multiple-imports/_expected/amd/generated-dynamic.js b/test/chunking-form/samples/improved-dynamic-chunks/single-dynamic-multiple-imports/_expected/amd/generated-dynamic.js index 1b7cd9e3d6d..862b9d645a0 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/single-dynamic-multiple-imports/_expected/amd/generated-dynamic.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/single-dynamic-multiple-imports/_expected/amd/generated-dynamic.js @@ -1,7 +1,7 @@ -define(['exports', './main'], function (exports, main) { 'use strict'; +define(['exports', './main'], (function (exports, main) { 'use strict'; console.log('dynamic', main.value); exports.value = main.value; -}); +})); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/single-dynamic-multiple-imports/_expected/amd/main.js b/test/chunking-form/samples/improved-dynamic-chunks/single-dynamic-multiple-imports/_expected/amd/main.js index 3f72fe8575e..7bcf0392fbe 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/single-dynamic-multiple-imports/_expected/amd/main.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/single-dynamic-multiple-imports/_expected/amd/main.js @@ -1,15 +1,13 @@ -define(['require', 'exports'], function (require, exports) { 'use strict'; +define(['require', 'exports'], (function (require, exports) { 'use strict'; const value = 'shared'; console.log('a', value); - new Promise(function (resolve, reject) { require(['./generated-dynamic'], resolve, reject) }); + new Promise(function (resolve, reject) { require(['./generated-dynamic'], resolve, reject); }); console.log('main', value); - new Promise(function (resolve, reject) { require(['./generated-dynamic'], resolve, reject) }); + new Promise(function (resolve, reject) { require(['./generated-dynamic'], resolve, reject); }); exports.value = value; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/single-dynamic-multiple-imports/_expected/cjs/main.js b/test/chunking-form/samples/improved-dynamic-chunks/single-dynamic-multiple-imports/_expected/cjs/main.js index 70c72b3bb02..ca520ae599f 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/single-dynamic-multiple-imports/_expected/cjs/main.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/single-dynamic-multiple-imports/_expected/cjs/main.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - const value = 'shared'; console.log('a', value); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/single-dynamic-multiple-imports/_expected/es/generated-dynamic.js b/test/chunking-form/samples/improved-dynamic-chunks/single-dynamic-multiple-imports/_expected/es/generated-dynamic.js index 5726f3b9c9f..dc895901989 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/single-dynamic-multiple-imports/_expected/es/generated-dynamic.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/single-dynamic-multiple-imports/_expected/es/generated-dynamic.js @@ -1,4 +1,5 @@ import { value } from './main.js'; -export { value } from './main.js'; console.log('dynamic', value); + +export { value }; diff --git a/test/chunking-form/samples/improved-dynamic-chunks/single-dynamic-multiple-imports/_expected/system/generated-dynamic.js b/test/chunking-form/samples/improved-dynamic-chunks/single-dynamic-multiple-imports/_expected/system/generated-dynamic.js index d709dd7477a..d7b0c456898 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/single-dynamic-multiple-imports/_expected/system/generated-dynamic.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/single-dynamic-multiple-imports/_expected/system/generated-dynamic.js @@ -1,15 +1,15 @@ -System.register(['./main.js'], function (exports) { +System.register(['./main.js'], (function (exports) { 'use strict'; var value; return { setters: [function (module) { value = module.value; - exports('value', module.value); + exports("value", module.value); }], - execute: function () { + execute: (function () { console.log('dynamic', value); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/single-dynamic-multiple-imports/_expected/system/main.js b/test/chunking-form/samples/improved-dynamic-chunks/single-dynamic-multiple-imports/_expected/system/main.js index 0b98d98ec9e..4ad3f8f0fe3 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/single-dynamic-multiple-imports/_expected/system/main.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/single-dynamic-multiple-imports/_expected/system/main.js @@ -1,9 +1,9 @@ -System.register([], function (exports, module) { +System.register([], (function (exports, module) { 'use strict'; return { - execute: function () { + execute: (function () { - const value = exports('value', 'shared'); + const value = exports("value", 'shared'); console.log('a', value); module.import('./generated-dynamic.js'); @@ -11,6 +11,6 @@ System.register([], function (exports, module) { console.log('main', value); module.import('./generated-dynamic.js'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/single-dynamic/_config.js b/test/chunking-form/samples/improved-dynamic-chunks/single-dynamic/_config.js index 4ca923a9bb0..ceca06a61a8 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/single-dynamic/_config.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/single-dynamic/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'does not create a separate chunk if a dynamically imported chunk shares a dependency with its importer' -}; +}); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/single-dynamic/_expected/amd/generated-dynamic.js b/test/chunking-form/samples/improved-dynamic-chunks/single-dynamic/_expected/amd/generated-dynamic.js index 1b7cd9e3d6d..862b9d645a0 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/single-dynamic/_expected/amd/generated-dynamic.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/single-dynamic/_expected/amd/generated-dynamic.js @@ -1,7 +1,7 @@ -define(['exports', './main'], function (exports, main) { 'use strict'; +define(['exports', './main'], (function (exports, main) { 'use strict'; console.log('dynamic', main.value); exports.value = main.value; -}); +})); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/single-dynamic/_expected/amd/main.js b/test/chunking-form/samples/improved-dynamic-chunks/single-dynamic/_expected/amd/main.js index 714a305c85f..f279110b6b4 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/single-dynamic/_expected/amd/main.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/single-dynamic/_expected/amd/main.js @@ -1,12 +1,10 @@ -define(['require', 'exports'], function (require, exports) { 'use strict'; +define(['require', 'exports'], (function (require, exports) { 'use strict'; const value = 'shared'; console.log('main', value); - new Promise(function (resolve, reject) { require(['./generated-dynamic'], resolve, reject) }); + new Promise(function (resolve, reject) { require(['./generated-dynamic'], resolve, reject); }); exports.value = value; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/single-dynamic/_expected/cjs/main.js b/test/chunking-form/samples/improved-dynamic-chunks/single-dynamic/_expected/cjs/main.js index 7d1b02e1eea..2f20576f18a 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/single-dynamic/_expected/cjs/main.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/single-dynamic/_expected/cjs/main.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - const value = 'shared'; console.log('main', value); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/single-dynamic/_expected/es/generated-dynamic.js b/test/chunking-form/samples/improved-dynamic-chunks/single-dynamic/_expected/es/generated-dynamic.js index 5726f3b9c9f..dc895901989 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/single-dynamic/_expected/es/generated-dynamic.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/single-dynamic/_expected/es/generated-dynamic.js @@ -1,4 +1,5 @@ import { value } from './main.js'; -export { value } from './main.js'; console.log('dynamic', value); + +export { value }; diff --git a/test/chunking-form/samples/improved-dynamic-chunks/single-dynamic/_expected/system/generated-dynamic.js b/test/chunking-form/samples/improved-dynamic-chunks/single-dynamic/_expected/system/generated-dynamic.js index d709dd7477a..d7b0c456898 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/single-dynamic/_expected/system/generated-dynamic.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/single-dynamic/_expected/system/generated-dynamic.js @@ -1,15 +1,15 @@ -System.register(['./main.js'], function (exports) { +System.register(['./main.js'], (function (exports) { 'use strict'; var value; return { setters: [function (module) { value = module.value; - exports('value', module.value); + exports("value", module.value); }], - execute: function () { + execute: (function () { console.log('dynamic', value); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/improved-dynamic-chunks/single-dynamic/_expected/system/main.js b/test/chunking-form/samples/improved-dynamic-chunks/single-dynamic/_expected/system/main.js index b49c63ff160..f0840feb622 100644 --- a/test/chunking-form/samples/improved-dynamic-chunks/single-dynamic/_expected/system/main.js +++ b/test/chunking-form/samples/improved-dynamic-chunks/single-dynamic/_expected/system/main.js @@ -1,13 +1,13 @@ -System.register([], function (exports, module) { +System.register([], (function (exports, module) { 'use strict'; return { - execute: function () { + execute: (function () { - const value = exports('value', 'shared'); + const value = exports("value", 'shared'); console.log('main', value); module.import('./generated-dynamic.js'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/indirect-reexports-preserve-modules/_config.js b/test/chunking-form/samples/indirect-reexports-preserve-modules/_config.js index e2616fe4ab7..63434c3b164 100644 --- a/test/chunking-form/samples/indirect-reexports-preserve-modules/_config.js +++ b/test/chunking-form/samples/indirect-reexports-preserve-modules/_config.js @@ -1,7 +1,7 @@ -module.exports = { +module.exports = defineTest({ description: 'does not drop indirect reexports when preserving modules', expectedWarnings: ['MIXED_EXPORTS'], options: { output: { name: 'bundle', preserveModules: true } } -}; +}); diff --git a/test/chunking-form/samples/indirect-reexports-preserve-modules/_expected/amd/components/index.js b/test/chunking-form/samples/indirect-reexports-preserve-modules/_expected/amd/components/index.js index db7eff4760a..a03efcb5e7a 100644 --- a/test/chunking-form/samples/indirect-reexports-preserve-modules/_expected/amd/components/index.js +++ b/test/chunking-form/samples/indirect-reexports-preserve-modules/_expected/amd/components/index.js @@ -1,10 +1,8 @@ -define(['exports', './sub/index'], function (exports, index) { 'use strict'; +define(['exports', './sub/index'], (function (exports, index) { 'use strict'; - const baz = { bar: index['default'] }; + const baz = { bar: index.default }; exports.foo = index.foo; exports.baz = baz; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/indirect-reexports-preserve-modules/_expected/amd/components/sub/index.js b/test/chunking-form/samples/indirect-reexports-preserve-modules/_expected/amd/components/sub/index.js index 812fe417fb5..9da33feb210 100644 --- a/test/chunking-form/samples/indirect-reexports-preserve-modules/_expected/amd/components/sub/index.js +++ b/test/chunking-form/samples/indirect-reexports-preserve-modules/_expected/amd/components/sub/index.js @@ -1,4 +1,4 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; const foo = 'bar'; var bar = () => {}; @@ -8,4 +8,4 @@ define(['exports'], function (exports) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); -}); +})); diff --git a/test/chunking-form/samples/indirect-reexports-preserve-modules/_expected/amd/main.js b/test/chunking-form/samples/indirect-reexports-preserve-modules/_expected/amd/main.js index 9e02e78d24e..c17dc35d934 100644 --- a/test/chunking-form/samples/indirect-reexports-preserve-modules/_expected/amd/main.js +++ b/test/chunking-form/samples/indirect-reexports-preserve-modules/_expected/amd/main.js @@ -1,10 +1,8 @@ -define(['exports', './components/index', './components/sub/index'], function (exports, index, index$1) { 'use strict'; +define(['exports', './components/index', './components/sub/index'], (function (exports, index, index$1) { 'use strict'; exports.baz = index.baz; exports.foo = index$1.foo; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/indirect-reexports-preserve-modules/_expected/cjs/components/index.js b/test/chunking-form/samples/indirect-reexports-preserve-modules/_expected/cjs/components/index.js index 848372ab743..c6e74030a5f 100644 --- a/test/chunking-form/samples/indirect-reexports-preserve-modules/_expected/cjs/components/index.js +++ b/test/chunking-form/samples/indirect-reexports-preserve-modules/_expected/cjs/components/index.js @@ -1,10 +1,8 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - var index = require('./sub/index.js'); -const baz = { bar: index['default'] }; +const baz = { bar: index.default }; exports.foo = index.foo; exports.baz = baz; diff --git a/test/chunking-form/samples/indirect-reexports-preserve-modules/_expected/cjs/main.js b/test/chunking-form/samples/indirect-reexports-preserve-modules/_expected/cjs/main.js index e8c88da6582..6bcd93609e4 100644 --- a/test/chunking-form/samples/indirect-reexports-preserve-modules/_expected/cjs/main.js +++ b/test/chunking-form/samples/indirect-reexports-preserve-modules/_expected/cjs/main.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - var index = require('./components/index.js'); var index$1 = require('./components/sub/index.js'); diff --git a/test/chunking-form/samples/indirect-reexports-preserve-modules/_expected/es/components/sub/index.js b/test/chunking-form/samples/indirect-reexports-preserve-modules/_expected/es/components/sub/index.js index 3b438c25222..1ee02cde7d7 100644 --- a/test/chunking-form/samples/indirect-reexports-preserve-modules/_expected/es/components/sub/index.js +++ b/test/chunking-form/samples/indirect-reexports-preserve-modules/_expected/es/components/sub/index.js @@ -1,5 +1,4 @@ const foo = 'bar'; var bar = () => {}; -export default bar; -export { foo }; +export { bar as default, foo }; diff --git a/test/chunking-form/samples/indirect-reexports-preserve-modules/_expected/system/components/index.js b/test/chunking-form/samples/indirect-reexports-preserve-modules/_expected/system/components/index.js index 17def0f802d..5319f6d2a12 100644 --- a/test/chunking-form/samples/indirect-reexports-preserve-modules/_expected/system/components/index.js +++ b/test/chunking-form/samples/indirect-reexports-preserve-modules/_expected/system/components/index.js @@ -1,15 +1,15 @@ -System.register('bundle', ['./sub/index.js'], function (exports) { +System.register('bundle', ['./sub/index.js'], (function (exports) { 'use strict'; var bar; return { setters: [function (module) { bar = module.default; - exports('foo', module.foo); + exports("foo", module.foo); }], - execute: function () { + execute: (function () { - const baz = exports('baz', { bar }); + const baz = exports("baz", { bar }); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/indirect-reexports-preserve-modules/_expected/system/components/sub/index.js b/test/chunking-form/samples/indirect-reexports-preserve-modules/_expected/system/components/sub/index.js index 2174c193998..d3f5dc5017f 100644 --- a/test/chunking-form/samples/indirect-reexports-preserve-modules/_expected/system/components/sub/index.js +++ b/test/chunking-form/samples/indirect-reexports-preserve-modules/_expected/system/components/sub/index.js @@ -1,11 +1,11 @@ -System.register('bundle', [], function (exports) { +System.register('bundle', [], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - const foo = exports('foo', 'bar'); - var bar = exports('default', () => {}); + const foo = exports("foo", 'bar'); + var bar = exports("default", () => {}); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/indirect-reexports-preserve-modules/_expected/system/main.js b/test/chunking-form/samples/indirect-reexports-preserve-modules/_expected/system/main.js index 8aafd8ee3a0..d62a266f72e 100644 --- a/test/chunking-form/samples/indirect-reexports-preserve-modules/_expected/system/main.js +++ b/test/chunking-form/samples/indirect-reexports-preserve-modules/_expected/system/main.js @@ -1,15 +1,15 @@ -System.register('bundle', ['./components/index.js', './components/sub/index.js'], function (exports) { +System.register('bundle', ['./components/index.js', './components/sub/index.js'], (function (exports) { 'use strict'; return { setters: [function (module) { - exports('baz', module.baz); + exports("baz", module.baz); }, function (module) { - exports('foo', module.foo); + exports("foo", module.foo); }], - execute: function () { + execute: (function () { - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/interop-per-reexported-default-dependency/_config.js b/test/chunking-form/samples/interop-per-reexported-default-dependency/_config.js index 128dc1e4400..a780bdd05c2 100644 --- a/test/chunking-form/samples/interop-per-reexported-default-dependency/_config.js +++ b/test/chunking-form/samples/interop-per-reexported-default-dependency/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'allows to configure the interop type per reexported default from an external dependency', options: { @@ -10,4 +10,4 @@ module.exports = { } } } -}; +}); diff --git a/test/chunking-form/samples/interop-per-reexported-default-dependency/_expected.js b/test/chunking-form/samples/interop-per-reexported-default-dependency/_expected.js deleted file mode 100644 index 8607119d36b..00000000000 --- a/test/chunking-form/samples/interop-per-reexported-default-dependency/_expected.js +++ /dev/null @@ -1,78 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { value: true }); - -var externalFalse = require('external-false'); -var externalTrue = require('external-true'); -var externalDefault = require('external-default'); -var externalEsModule = require('external-esModule'); - -function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex : { 'default': ex }; } - -function _interopNamespace(e) { - if (e && e.__esModule) { return e; } else { - var n = Object.create(null); - if (e) { - Object.keys(e).forEach(function (k) { - var d = Object.getOwnPropertyDescriptor(e, k); - Object.defineProperty(n, k, d.get ? d : { - enumerable: true, - get: function () { - return e[k]; - } - }); - }); - } - n['default'] = e; - return Object.freeze(n); - } -} - -var externalTrue__namespace = /*#__PURE__*/_interopNamespace(externalTrue); -var externalTrue__default = /*#__PURE__*/_interopDefault(externalTrue); -var externalDefault__namespace = /*#__PURE__*/_interopNamespace(externalDefault); - - - -Object.defineProperty(exports, 'barFalse', { - enumerable: true, - get: function () { - return externalFalse.barFalse; - } -}); -exports.externalFalse = externalFalse; -exports.fooFalse = externalFalse; -Object.defineProperty(exports, 'barTrue', { - enumerable: true, - get: function () { - return externalTrue.barTrue; - } -}); -exports.externalTrue = externalTrue__namespace; -Object.defineProperty(exports, 'fooTrue', { - enumerable: true, - get: function () { - return externalTrue__default['default']; - } -}); -Object.defineProperty(exports, 'barDefault', { - enumerable: true, - get: function () { - return externalDefault.barDefault; - } -}); -exports.externalDefault = externalDefault__namespace; -exports.fooDefault = externalDefault; -Object.defineProperty(exports, 'barEsModule', { - enumerable: true, - get: function () { - return externalEsModule.barEsModule; - } -}); -exports.externalEsModule = externalEsModule; -Object.defineProperty(exports, 'fooEsModule', { - enumerable: true, - get: function () { - return externalEsModule['default']; - } -}); diff --git a/test/chunking-form/samples/interop-per-reexported-default-dependency/_expected/amd/auto.js b/test/chunking-form/samples/interop-per-reexported-default-dependency/_expected/amd/auto.js index 3a34ca9e242..66631128466 100644 --- a/test/chunking-form/samples/interop-per-reexported-default-dependency/_expected/amd/auto.js +++ b/test/chunking-form/samples/interop-per-reexported-default-dependency/_expected/amd/auto.js @@ -1,11 +1,11 @@ -define(['external-auto'], function (externalAuto) { 'use strict'; +define(['external-auto'], (function (externalAuto) { 'use strict'; - function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; } + function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; } var externalAuto__default = /*#__PURE__*/_interopDefault(externalAuto); - return externalAuto__default['default']; + return externalAuto__default.default; -}); +})); diff --git a/test/chunking-form/samples/interop-per-reexported-default-dependency/_expected/amd/default.js b/test/chunking-form/samples/interop-per-reexported-default-dependency/_expected/amd/default.js index c936d8f5207..c721a6d3ef7 100644 --- a/test/chunking-form/samples/interop-per-reexported-default-dependency/_expected/amd/default.js +++ b/test/chunking-form/samples/interop-per-reexported-default-dependency/_expected/amd/default.js @@ -1,7 +1,7 @@ -define(['external-default'], function (externalDefault) { 'use strict'; +define(['external-default'], (function (externalDefault) { 'use strict'; return externalDefault; -}); +})); diff --git a/test/chunking-form/samples/interop-per-reexported-default-dependency/_expected/amd/defaultOnly.js b/test/chunking-form/samples/interop-per-reexported-default-dependency/_expected/amd/defaultOnly.js index c936d8f5207..c721a6d3ef7 100644 --- a/test/chunking-form/samples/interop-per-reexported-default-dependency/_expected/amd/defaultOnly.js +++ b/test/chunking-form/samples/interop-per-reexported-default-dependency/_expected/amd/defaultOnly.js @@ -1,7 +1,7 @@ -define(['external-default'], function (externalDefault) { 'use strict'; +define(['external-default'], (function (externalDefault) { 'use strict'; return externalDefault; -}); +})); diff --git a/test/chunking-form/samples/interop-per-reexported-default-dependency/_expected/amd/esModule.js b/test/chunking-form/samples/interop-per-reexported-default-dependency/_expected/amd/esModule.js index a26140cc715..72f65424542 100644 --- a/test/chunking-form/samples/interop-per-reexported-default-dependency/_expected/amd/esModule.js +++ b/test/chunking-form/samples/interop-per-reexported-default-dependency/_expected/amd/esModule.js @@ -1,7 +1,7 @@ -define(['external-esModule'], function (externalEsModule) { 'use strict'; +define(['external-esModule'], (function (externalEsModule) { 'use strict'; - return externalEsModule['default']; + return externalEsModule.default; -}); +})); diff --git a/test/chunking-form/samples/interop-per-reexported-default-dependency/_expected/cjs/auto.js b/test/chunking-form/samples/interop-per-reexported-default-dependency/_expected/cjs/auto.js index ebee47076ab..77f4d9ad384 100644 --- a/test/chunking-form/samples/interop-per-reexported-default-dependency/_expected/cjs/auto.js +++ b/test/chunking-form/samples/interop-per-reexported-default-dependency/_expected/cjs/auto.js @@ -2,10 +2,10 @@ var externalAuto = require('external-auto'); -function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; } +function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; } var externalAuto__default = /*#__PURE__*/_interopDefault(externalAuto); -module.exports = externalAuto__default['default']; +module.exports = externalAuto__default.default; diff --git a/test/chunking-form/samples/interop-per-reexported-default-dependency/_expected/cjs/esModule.js b/test/chunking-form/samples/interop-per-reexported-default-dependency/_expected/cjs/esModule.js index 0dcb175c714..6dc4181b44c 100644 --- a/test/chunking-form/samples/interop-per-reexported-default-dependency/_expected/cjs/esModule.js +++ b/test/chunking-form/samples/interop-per-reexported-default-dependency/_expected/cjs/esModule.js @@ -4,4 +4,4 @@ var externalEsModule = require('external-esModule'); -module.exports = externalEsModule['default']; +module.exports = externalEsModule.default; diff --git a/test/chunking-form/samples/interop-per-reexported-default-dependency/_expected/system/auto.js b/test/chunking-form/samples/interop-per-reexported-default-dependency/_expected/system/auto.js index 767082a71d6..b1ace3a6e74 100644 --- a/test/chunking-form/samples/interop-per-reexported-default-dependency/_expected/system/auto.js +++ b/test/chunking-form/samples/interop-per-reexported-default-dependency/_expected/system/auto.js @@ -1,13 +1,13 @@ -System.register(['external-auto'], function (exports) { +System.register(['external-auto'], (function (exports) { 'use strict'; return { setters: [function (module) { - exports('default', module.default); + exports("default", module.default); }], - execute: function () { + execute: (function () { - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/interop-per-reexported-default-dependency/_expected/system/default.js b/test/chunking-form/samples/interop-per-reexported-default-dependency/_expected/system/default.js index 88b0186a0dc..e9410a0f77c 100644 --- a/test/chunking-form/samples/interop-per-reexported-default-dependency/_expected/system/default.js +++ b/test/chunking-form/samples/interop-per-reexported-default-dependency/_expected/system/default.js @@ -1,13 +1,13 @@ -System.register(['external-default'], function (exports) { +System.register(['external-default'], (function (exports) { 'use strict'; return { setters: [function (module) { - exports('default', module.default); + exports("default", module.default); }], - execute: function () { + execute: (function () { - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/interop-per-reexported-default-dependency/_expected/system/defaultOnly.js b/test/chunking-form/samples/interop-per-reexported-default-dependency/_expected/system/defaultOnly.js index 88b0186a0dc..e9410a0f77c 100644 --- a/test/chunking-form/samples/interop-per-reexported-default-dependency/_expected/system/defaultOnly.js +++ b/test/chunking-form/samples/interop-per-reexported-default-dependency/_expected/system/defaultOnly.js @@ -1,13 +1,13 @@ -System.register(['external-default'], function (exports) { +System.register(['external-default'], (function (exports) { 'use strict'; return { setters: [function (module) { - exports('default', module.default); + exports("default", module.default); }], - execute: function () { + execute: (function () { - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/interop-per-reexported-default-dependency/_expected/system/esModule.js b/test/chunking-form/samples/interop-per-reexported-default-dependency/_expected/system/esModule.js index e2f6478073b..c15015a6ecc 100644 --- a/test/chunking-form/samples/interop-per-reexported-default-dependency/_expected/system/esModule.js +++ b/test/chunking-form/samples/interop-per-reexported-default-dependency/_expected/system/esModule.js @@ -1,13 +1,13 @@ -System.register(['external-esModule'], function (exports) { +System.register(['external-esModule'], (function (exports) { 'use strict'; return { setters: [function (module) { - exports('default', module.default); + exports("default", module.default); }], - execute: function () { + execute: (function () { - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/manual-chunk-avoid-facade/_config.js b/test/chunking-form/samples/manual-chunk-avoid-facade/_config.js index b3f1783fee8..7a1847a0e8a 100644 --- a/test/chunking-form/samples/manual-chunk-avoid-facade/_config.js +++ b/test/chunking-form/samples/manual-chunk-avoid-facade/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'avoid facades if possible when using manual chunks', options: { input: ['main1', 'main2'], @@ -8,4 +8,4 @@ module.exports = { } } } -}; +}); diff --git a/test/chunking-form/samples/manual-chunk-avoid-facade/_expected/amd/main1.js b/test/chunking-form/samples/manual-chunk-avoid-facade/_expected/amd/main1.js index a973f4d8de7..56e0171e999 100644 --- a/test/chunking-form/samples/manual-chunk-avoid-facade/_expected/amd/main1.js +++ b/test/chunking-form/samples/manual-chunk-avoid-facade/_expected/amd/main1.js @@ -1,5 +1,5 @@ -define(['./main2'], function (manual) { 'use strict'; +define(['./main2'], (function (manual) { 'use strict'; console.log('main', manual.reexported); -}); +})); diff --git a/test/chunking-form/samples/manual-chunk-avoid-facade/_expected/amd/main2.js b/test/chunking-form/samples/manual-chunk-avoid-facade/_expected/amd/main2.js index 674f42a401c..0c42189302d 100644 --- a/test/chunking-form/samples/manual-chunk-avoid-facade/_expected/amd/main2.js +++ b/test/chunking-form/samples/manual-chunk-avoid-facade/_expected/amd/main2.js @@ -1,4 +1,4 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; const value = 42; @@ -6,6 +6,4 @@ define(['exports'], function (exports) { 'use strict'; exports.reexported = value; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/manual-chunk-avoid-facade/_expected/cjs/main2.js b/test/chunking-form/samples/manual-chunk-avoid-facade/_expected/cjs/main2.js index f7d33362bcc..58617370ca4 100644 --- a/test/chunking-form/samples/manual-chunk-avoid-facade/_expected/cjs/main2.js +++ b/test/chunking-form/samples/manual-chunk-avoid-facade/_expected/cjs/main2.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - const value = 42; console.log('main2', value); diff --git a/test/chunking-form/samples/manual-chunk-avoid-facade/_expected/system/main1.js b/test/chunking-form/samples/manual-chunk-avoid-facade/_expected/system/main1.js index 36f1fb810be..f189fb530a6 100644 --- a/test/chunking-form/samples/manual-chunk-avoid-facade/_expected/system/main1.js +++ b/test/chunking-form/samples/manual-chunk-avoid-facade/_expected/system/main1.js @@ -1,14 +1,14 @@ -System.register(['./main2.js'], function () { +System.register(['./main2.js'], (function () { 'use strict'; var value; return { setters: [function (module) { value = module.reexported; }], - execute: function () { + execute: (function () { console.log('main', value); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/manual-chunk-avoid-facade/_expected/system/main2.js b/test/chunking-form/samples/manual-chunk-avoid-facade/_expected/system/main2.js index e00ab6a2dca..6eabcbeb662 100644 --- a/test/chunking-form/samples/manual-chunk-avoid-facade/_expected/system/main2.js +++ b/test/chunking-form/samples/manual-chunk-avoid-facade/_expected/system/main2.js @@ -1,12 +1,12 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - const value = exports('reexported', 42); + const value = exports("reexported", 42); console.log('main2', value); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/manual-chunk-contains-entry-conflict/_config.js b/test/chunking-form/samples/manual-chunk-contains-entry-conflict/_config.js index a37dc57a3b7..2c522de8b4a 100644 --- a/test/chunking-form/samples/manual-chunk-contains-entry-conflict/_config.js +++ b/test/chunking-form/samples/manual-chunk-contains-entry-conflict/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ expectedWarnings: ['EMPTY_BUNDLE'], description: 'Uses entry alias if manual chunks contain entry chunks with different alias', options: { @@ -12,4 +12,4 @@ module.exports = { } } } -}; +}); diff --git a/test/chunking-form/samples/manual-chunk-contains-entry-conflict/_expected/amd/main.js b/test/chunking-form/samples/manual-chunk-contains-entry-conflict/_expected/amd/main.js index fc91f027a0e..0dce9285fd6 100644 --- a/test/chunking-form/samples/manual-chunk-contains-entry-conflict/_expected/amd/main.js +++ b/test/chunking-form/samples/manual-chunk-contains-entry-conflict/_expected/amd/main.js @@ -1,4 +1,4 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; console.log('dep'); @@ -8,6 +8,4 @@ define(['exports'], function (exports) { 'use strict'; exports.value = value; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/manual-chunk-contains-entry-conflict/_expected/amd/main2.js b/test/chunking-form/samples/manual-chunk-contains-entry-conflict/_expected/amd/main2.js index d28c079a312..a8c2660dcf0 100644 --- a/test/chunking-form/samples/manual-chunk-contains-entry-conflict/_expected/amd/main2.js +++ b/test/chunking-form/samples/manual-chunk-contains-entry-conflict/_expected/amd/main2.js @@ -1,5 +1,5 @@ -define(['./main'], function (outer) { 'use strict'; +define(['./main'], (function (outer) { 'use strict'; -}); +})); diff --git a/test/chunking-form/samples/manual-chunk-contains-entry-conflict/_expected/cjs/main.js b/test/chunking-form/samples/manual-chunk-contains-entry-conflict/_expected/cjs/main.js index 5da9ebd5132..fe59aaab6b9 100644 --- a/test/chunking-form/samples/manual-chunk-contains-entry-conflict/_expected/cjs/main.js +++ b/test/chunking-form/samples/manual-chunk-contains-entry-conflict/_expected/cjs/main.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - console.log('dep'); console.log('main'); diff --git a/test/chunking-form/samples/manual-chunk-contains-entry-conflict/_expected/system/main.js b/test/chunking-form/samples/manual-chunk-contains-entry-conflict/_expected/system/main.js index b92309e3bf3..e58f3c8376f 100644 --- a/test/chunking-form/samples/manual-chunk-contains-entry-conflict/_expected/system/main.js +++ b/test/chunking-form/samples/manual-chunk-contains-entry-conflict/_expected/system/main.js @@ -1,14 +1,14 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { console.log('dep'); console.log('main'); - const value = exports('value', 42); + const value = exports("value", 42); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/manual-chunk-contains-entry-conflict/_expected/system/main2.js b/test/chunking-form/samples/manual-chunk-contains-entry-conflict/_expected/system/main2.js index da731958b75..e2a9d26523e 100644 --- a/test/chunking-form/samples/manual-chunk-contains-entry-conflict/_expected/system/main2.js +++ b/test/chunking-form/samples/manual-chunk-contains-entry-conflict/_expected/system/main2.js @@ -1,11 +1,11 @@ -System.register(['./main.js'], function () { +System.register(['./main.js'], (function () { 'use strict'; return { - setters: [function () {}], - execute: function () { + setters: [null], + execute: (function () { - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/manual-chunk-contains-entry-match/_config.js b/test/chunking-form/samples/manual-chunk-contains-entry-match/_config.js index 886f2483469..c4ddc6655d4 100644 --- a/test/chunking-form/samples/manual-chunk-contains-entry-match/_config.js +++ b/test/chunking-form/samples/manual-chunk-contains-entry-match/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'Identifies the entry chunk with the manual chunk that contains it if the aliases match', options: { @@ -11,4 +11,4 @@ module.exports = { } } } -}; +}); diff --git a/test/chunking-form/samples/manual-chunk-contains-entry-match/_expected/amd/main.js b/test/chunking-form/samples/manual-chunk-contains-entry-match/_expected/amd/main.js index fc91f027a0e..0dce9285fd6 100644 --- a/test/chunking-form/samples/manual-chunk-contains-entry-match/_expected/amd/main.js +++ b/test/chunking-form/samples/manual-chunk-contains-entry-match/_expected/amd/main.js @@ -1,4 +1,4 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; console.log('dep'); @@ -8,6 +8,4 @@ define(['exports'], function (exports) { 'use strict'; exports.value = value; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/manual-chunk-contains-entry-match/_expected/cjs/main.js b/test/chunking-form/samples/manual-chunk-contains-entry-match/_expected/cjs/main.js index 5da9ebd5132..fe59aaab6b9 100644 --- a/test/chunking-form/samples/manual-chunk-contains-entry-match/_expected/cjs/main.js +++ b/test/chunking-form/samples/manual-chunk-contains-entry-match/_expected/cjs/main.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - console.log('dep'); console.log('main'); diff --git a/test/chunking-form/samples/manual-chunk-contains-entry-match/_expected/system/main.js b/test/chunking-form/samples/manual-chunk-contains-entry-match/_expected/system/main.js index b92309e3bf3..e58f3c8376f 100644 --- a/test/chunking-form/samples/manual-chunk-contains-entry-match/_expected/system/main.js +++ b/test/chunking-form/samples/manual-chunk-contains-entry-match/_expected/system/main.js @@ -1,14 +1,14 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { console.log('dep'); console.log('main'); - const value = exports('value', 42); + const value = exports("value", 42); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/manual-chunk-is-entry-conflict/_config.js b/test/chunking-form/samples/manual-chunk-is-entry-conflict/_config.js index ff3ff114277..375bfd9fdde 100644 --- a/test/chunking-form/samples/manual-chunk-is-entry-conflict/_config.js +++ b/test/chunking-form/samples/manual-chunk-is-entry-conflict/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'Uses entry alias if manual chunks are entry chunks with different alias', options: { input: { @@ -11,4 +11,4 @@ module.exports = { } } } -}; +}); diff --git a/test/chunking-form/samples/manual-chunk-is-entry-conflict/_expected/amd/main.js b/test/chunking-form/samples/manual-chunk-is-entry-conflict/_expected/amd/main.js index fc91f027a0e..0dce9285fd6 100644 --- a/test/chunking-form/samples/manual-chunk-is-entry-conflict/_expected/amd/main.js +++ b/test/chunking-form/samples/manual-chunk-is-entry-conflict/_expected/amd/main.js @@ -1,4 +1,4 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; console.log('dep'); @@ -8,6 +8,4 @@ define(['exports'], function (exports) { 'use strict'; exports.value = value; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/manual-chunk-is-entry-conflict/_expected/amd/main2.js b/test/chunking-form/samples/manual-chunk-is-entry-conflict/_expected/amd/main2.js index e007f54e5e2..e5e4e1a17ef 100644 --- a/test/chunking-form/samples/manual-chunk-is-entry-conflict/_expected/amd/main2.js +++ b/test/chunking-form/samples/manual-chunk-is-entry-conflict/_expected/amd/main2.js @@ -1,5 +1,5 @@ -define(['./main'], function (other) { 'use strict'; +define(['./main'], (function (other) { 'use strict'; -}); +})); diff --git a/test/chunking-form/samples/manual-chunk-is-entry-conflict/_expected/cjs/main.js b/test/chunking-form/samples/manual-chunk-is-entry-conflict/_expected/cjs/main.js index 5da9ebd5132..fe59aaab6b9 100644 --- a/test/chunking-form/samples/manual-chunk-is-entry-conflict/_expected/cjs/main.js +++ b/test/chunking-form/samples/manual-chunk-is-entry-conflict/_expected/cjs/main.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - console.log('dep'); console.log('main'); diff --git a/test/chunking-form/samples/manual-chunk-is-entry-conflict/_expected/system/main.js b/test/chunking-form/samples/manual-chunk-is-entry-conflict/_expected/system/main.js index b92309e3bf3..e58f3c8376f 100644 --- a/test/chunking-form/samples/manual-chunk-is-entry-conflict/_expected/system/main.js +++ b/test/chunking-form/samples/manual-chunk-is-entry-conflict/_expected/system/main.js @@ -1,14 +1,14 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { console.log('dep'); console.log('main'); - const value = exports('value', 42); + const value = exports("value", 42); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/manual-chunk-is-entry-conflict/_expected/system/main2.js b/test/chunking-form/samples/manual-chunk-is-entry-conflict/_expected/system/main2.js index da731958b75..e2a9d26523e 100644 --- a/test/chunking-form/samples/manual-chunk-is-entry-conflict/_expected/system/main2.js +++ b/test/chunking-form/samples/manual-chunk-is-entry-conflict/_expected/system/main2.js @@ -1,11 +1,11 @@ -System.register(['./main.js'], function () { +System.register(['./main.js'], (function () { 'use strict'; return { - setters: [function () {}], - execute: function () { + setters: [null], + execute: (function () { - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/manual-chunk-is-entry-match/_config.js b/test/chunking-form/samples/manual-chunk-is-entry-match/_config.js index e48ab6e5c57..6851f393376 100644 --- a/test/chunking-form/samples/manual-chunk-is-entry-match/_config.js +++ b/test/chunking-form/samples/manual-chunk-is-entry-match/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'Identifies the entry chunk with the manual chunk that has the same entry if the aliases match', options: { @@ -11,4 +11,4 @@ module.exports = { } } } -}; +}); diff --git a/test/chunking-form/samples/manual-chunk-is-entry-match/_expected/amd/main.js b/test/chunking-form/samples/manual-chunk-is-entry-match/_expected/amd/main.js index fc91f027a0e..0dce9285fd6 100644 --- a/test/chunking-form/samples/manual-chunk-is-entry-match/_expected/amd/main.js +++ b/test/chunking-form/samples/manual-chunk-is-entry-match/_expected/amd/main.js @@ -1,4 +1,4 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; console.log('dep'); @@ -8,6 +8,4 @@ define(['exports'], function (exports) { 'use strict'; exports.value = value; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/manual-chunk-is-entry-match/_expected/cjs/main.js b/test/chunking-form/samples/manual-chunk-is-entry-match/_expected/cjs/main.js index 5da9ebd5132..fe59aaab6b9 100644 --- a/test/chunking-form/samples/manual-chunk-is-entry-match/_expected/cjs/main.js +++ b/test/chunking-form/samples/manual-chunk-is-entry-match/_expected/cjs/main.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - console.log('dep'); console.log('main'); diff --git a/test/chunking-form/samples/manual-chunk-is-entry-match/_expected/system/main.js b/test/chunking-form/samples/manual-chunk-is-entry-match/_expected/system/main.js index b92309e3bf3..e58f3c8376f 100644 --- a/test/chunking-form/samples/manual-chunk-is-entry-match/_expected/system/main.js +++ b/test/chunking-form/samples/manual-chunk-is-entry-match/_expected/system/main.js @@ -1,14 +1,14 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { console.log('dep'); console.log('main'); - const value = exports('value', 42); + const value = exports("value", 42); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/manual-chunk-not-included/_config.js b/test/chunking-form/samples/manual-chunk-not-included/_config.js new file mode 100644 index 00000000000..38b02eb3641 --- /dev/null +++ b/test/chunking-form/samples/manual-chunk-not-included/_config.js @@ -0,0 +1,11 @@ +module.exports = defineTest({ + description: 'handles manual chunks where the root is not part of the module graph', + options: { + input: ['main.js'], + output: { + manualChunks: { + manual: ['manual-entry.js'] + } + } + } +}); diff --git a/test/chunking-form/samples/manual-chunk-not-included/_expected/amd/generated-manual.js b/test/chunking-form/samples/manual-chunk-not-included/_expected/amd/generated-manual.js new file mode 100644 index 00000000000..f9e8bf57b21 --- /dev/null +++ b/test/chunking-form/samples/manual-chunk-not-included/_expected/amd/generated-manual.js @@ -0,0 +1,5 @@ +define((function () { 'use strict'; + + console.log('included'); + +})); diff --git a/test/chunking-form/samples/manual-chunk-not-included/_expected/amd/main.js b/test/chunking-form/samples/manual-chunk-not-included/_expected/amd/main.js new file mode 100644 index 00000000000..b9a9d643047 --- /dev/null +++ b/test/chunking-form/samples/manual-chunk-not-included/_expected/amd/main.js @@ -0,0 +1,5 @@ +define(['./generated-manual'], (function (manual) { 'use strict'; + + console.log('main'); + +})); diff --git a/test/chunking-form/samples/manual-chunk-not-included/_expected/cjs/generated-manual.js b/test/chunking-form/samples/manual-chunk-not-included/_expected/cjs/generated-manual.js new file mode 100644 index 00000000000..46970f369e4 --- /dev/null +++ b/test/chunking-form/samples/manual-chunk-not-included/_expected/cjs/generated-manual.js @@ -0,0 +1,3 @@ +'use strict'; + +console.log('included'); diff --git a/test/chunking-form/samples/deprecated/manual-chunks-nested/_expected/cjs/main.js b/test/chunking-form/samples/manual-chunk-not-included/_expected/cjs/main.js similarity index 100% rename from test/chunking-form/samples/deprecated/manual-chunks-nested/_expected/cjs/main.js rename to test/chunking-form/samples/manual-chunk-not-included/_expected/cjs/main.js diff --git a/test/chunking-form/samples/manual-chunk-not-included/_expected/es/generated-manual.js b/test/chunking-form/samples/manual-chunk-not-included/_expected/es/generated-manual.js new file mode 100644 index 00000000000..452029d8355 --- /dev/null +++ b/test/chunking-form/samples/manual-chunk-not-included/_expected/es/generated-manual.js @@ -0,0 +1 @@ +console.log('included'); diff --git a/test/chunking-form/samples/deprecated/manual-chunks-nested/_expected/es/main.js b/test/chunking-form/samples/manual-chunk-not-included/_expected/es/main.js similarity index 100% rename from test/chunking-form/samples/deprecated/manual-chunks-nested/_expected/es/main.js rename to test/chunking-form/samples/manual-chunk-not-included/_expected/es/main.js diff --git a/test/chunking-form/samples/manual-chunk-not-included/_expected/system/generated-manual.js b/test/chunking-form/samples/manual-chunk-not-included/_expected/system/generated-manual.js new file mode 100644 index 00000000000..f147b38fa45 --- /dev/null +++ b/test/chunking-form/samples/manual-chunk-not-included/_expected/system/generated-manual.js @@ -0,0 +1,10 @@ +System.register([], (function () { + 'use strict'; + return { + execute: (function () { + + console.log('included'); + + }) + }; +})); diff --git a/test/chunking-form/samples/manual-chunk-not-included/_expected/system/main.js b/test/chunking-form/samples/manual-chunk-not-included/_expected/system/main.js new file mode 100644 index 00000000000..3e762e61fd8 --- /dev/null +++ b/test/chunking-form/samples/manual-chunk-not-included/_expected/system/main.js @@ -0,0 +1,11 @@ +System.register(['./generated-manual.js'], (function () { + 'use strict'; + return { + setters: [null], + execute: (function () { + + console.log('main'); + + }) + }; +})); diff --git a/test/chunking-form/samples/manual-chunk-not-included/main.js b/test/chunking-form/samples/manual-chunk-not-included/main.js new file mode 100644 index 00000000000..8e6e9e0b963 --- /dev/null +++ b/test/chunking-form/samples/manual-chunk-not-included/main.js @@ -0,0 +1,2 @@ +import './manual-included'; +console.log('main'); diff --git a/test/chunking-form/samples/manual-chunk-not-included/manual-entry.js b/test/chunking-form/samples/manual-chunk-not-included/manual-entry.js new file mode 100644 index 00000000000..9947c39b198 --- /dev/null +++ b/test/chunking-form/samples/manual-chunk-not-included/manual-entry.js @@ -0,0 +1,5 @@ +import './manual-included'; + +function test() {} + +test(); diff --git a/test/chunking-form/samples/manual-chunk-not-included/manual-included.js b/test/chunking-form/samples/manual-chunk-not-included/manual-included.js new file mode 100644 index 00000000000..452029d8355 --- /dev/null +++ b/test/chunking-form/samples/manual-chunk-not-included/manual-included.js @@ -0,0 +1 @@ +console.log('included'); diff --git a/test/chunking-form/samples/manual-chunks-different-nested/_config.js b/test/chunking-form/samples/manual-chunks-different-nested/_config.js index b3cb648c6ce..4a9ba21f564 100644 --- a/test/chunking-form/samples/manual-chunks-different-nested/_config.js +++ b/test/chunking-form/samples/manual-chunks-different-nested/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'manual chunks can have other manual chunks as dependencies', options: { input: ['main.js'], @@ -10,4 +10,4 @@ module.exports = { } } } -}; +}); diff --git a/test/chunking-form/samples/manual-chunks-different-nested/_expected/amd/generated-manual-inner.js b/test/chunking-form/samples/manual-chunks-different-nested/_expected/amd/generated-manual-inner.js index 5068b5fd910..a0d11c04e68 100644 --- a/test/chunking-form/samples/manual-chunks-different-nested/_expected/amd/generated-manual-inner.js +++ b/test/chunking-form/samples/manual-chunks-different-nested/_expected/amd/generated-manual-inner.js @@ -1,5 +1,5 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; console.log('inner'); -}); +})); diff --git a/test/chunking-form/samples/manual-chunks-different-nested/_expected/amd/generated-manual-middle.js b/test/chunking-form/samples/manual-chunks-different-nested/_expected/amd/generated-manual-middle.js index a12cddc2c4f..15b8a8171f9 100644 --- a/test/chunking-form/samples/manual-chunks-different-nested/_expected/amd/generated-manual-middle.js +++ b/test/chunking-form/samples/manual-chunks-different-nested/_expected/amd/generated-manual-middle.js @@ -1,5 +1,5 @@ -define(['./generated-manual-inner'], function (manualInner) { 'use strict'; +define(['./generated-manual-inner'], (function (manualInner) { 'use strict'; console.log('middle'); -}); +})); diff --git a/test/chunking-form/samples/manual-chunks-different-nested/_expected/amd/generated-manual-outer.js b/test/chunking-form/samples/manual-chunks-different-nested/_expected/amd/generated-manual-outer.js index 19b33370089..e40914a91d6 100644 --- a/test/chunking-form/samples/manual-chunks-different-nested/_expected/amd/generated-manual-outer.js +++ b/test/chunking-form/samples/manual-chunks-different-nested/_expected/amd/generated-manual-outer.js @@ -1,5 +1,5 @@ -define(['./generated-manual-middle'], function (manualMiddle) { 'use strict'; +define(['./generated-manual-middle'], (function (manualMiddle) { 'use strict'; console.log('outer'); -}); +})); diff --git a/test/chunking-form/samples/manual-chunks-different-nested/_expected/amd/main.js b/test/chunking-form/samples/manual-chunks-different-nested/_expected/amd/main.js index 28fbd1e66ae..bab51c5ba21 100644 --- a/test/chunking-form/samples/manual-chunks-different-nested/_expected/amd/main.js +++ b/test/chunking-form/samples/manual-chunks-different-nested/_expected/amd/main.js @@ -1,5 +1,5 @@ -define(['./generated-manual-outer', './generated-manual-middle', './generated-manual-inner'], function (manualOuter, manualMiddle, manualInner) { 'use strict'; +define(['./generated-manual-outer', './generated-manual-middle', './generated-manual-inner'], (function (manualOuter, manualMiddle, manualInner) { 'use strict'; console.log('main'); -}); +})); diff --git a/test/chunking-form/samples/manual-chunks-different-nested/_expected/system/generated-manual-inner.js b/test/chunking-form/samples/manual-chunks-different-nested/_expected/system/generated-manual-inner.js index 7079c6deaf2..402e3d2df8d 100644 --- a/test/chunking-form/samples/manual-chunks-different-nested/_expected/system/generated-manual-inner.js +++ b/test/chunking-form/samples/manual-chunks-different-nested/_expected/system/generated-manual-inner.js @@ -1,10 +1,10 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { console.log('inner'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/manual-chunks-different-nested/_expected/system/generated-manual-middle.js b/test/chunking-form/samples/manual-chunks-different-nested/_expected/system/generated-manual-middle.js index e972910e58e..f36fecb955c 100644 --- a/test/chunking-form/samples/manual-chunks-different-nested/_expected/system/generated-manual-middle.js +++ b/test/chunking-form/samples/manual-chunks-different-nested/_expected/system/generated-manual-middle.js @@ -1,11 +1,11 @@ -System.register(['./generated-manual-inner.js'], function () { +System.register(['./generated-manual-inner.js'], (function () { 'use strict'; return { - setters: [function () {}], - execute: function () { + setters: [null], + execute: (function () { console.log('middle'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/manual-chunks-different-nested/_expected/system/generated-manual-outer.js b/test/chunking-form/samples/manual-chunks-different-nested/_expected/system/generated-manual-outer.js index 8657192807b..b44b4b9deec 100644 --- a/test/chunking-form/samples/manual-chunks-different-nested/_expected/system/generated-manual-outer.js +++ b/test/chunking-form/samples/manual-chunks-different-nested/_expected/system/generated-manual-outer.js @@ -1,11 +1,11 @@ -System.register(['./generated-manual-middle.js'], function () { +System.register(['./generated-manual-middle.js'], (function () { 'use strict'; return { - setters: [function () {}], - execute: function () { + setters: [null], + execute: (function () { console.log('outer'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/manual-chunks-different-nested/_expected/system/main.js b/test/chunking-form/samples/manual-chunks-different-nested/_expected/system/main.js index 9719fd4976c..875b0a42886 100644 --- a/test/chunking-form/samples/manual-chunks-different-nested/_expected/system/main.js +++ b/test/chunking-form/samples/manual-chunks-different-nested/_expected/system/main.js @@ -1,11 +1,11 @@ -System.register(['./generated-manual-outer.js', './generated-manual-middle.js', './generated-manual-inner.js'], function () { +System.register(['./generated-manual-outer.js', './generated-manual-middle.js', './generated-manual-inner.js'], (function () { 'use strict'; return { - setters: [function () {}, function () {}, function () {}], - execute: function () { + setters: [null, null, null], + execute: (function () { console.log('main'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/manual-chunks-dynamic-facades/_config.js b/test/chunking-form/samples/manual-chunks-dynamic-facades/_config.js index 4b561f0ff92..91bf1733452 100644 --- a/test/chunking-form/samples/manual-chunks-dynamic-facades/_config.js +++ b/test/chunking-form/samples/manual-chunks-dynamic-facades/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'creates facades for dynamic manual chunks if necessary', options: { input: ['main.js'], @@ -8,4 +8,4 @@ module.exports = { } } } -}; +}); diff --git a/test/chunking-form/samples/manual-chunks-dynamic-facades/_expected/amd/generated-dynamic.js b/test/chunking-form/samples/manual-chunks-dynamic-facades/_expected/amd/generated-dynamic.js index 06d0b979512..8568aedda86 100644 --- a/test/chunking-form/samples/manual-chunks-dynamic-facades/_expected/amd/generated-dynamic.js +++ b/test/chunking-form/samples/manual-chunks-dynamic-facades/_expected/amd/generated-dynamic.js @@ -1,4 +1,4 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; const DEP = 'DEP'; @@ -20,8 +20,8 @@ define(['exports'], function (exports) { 'use strict'; var dynamic1 = /*#__PURE__*/Object.freeze({ __proto__: null, - DYNAMIC_1: DYNAMIC_1, DEP: DEP, + DYNAMIC_1: DYNAMIC_1, DYNAMIC_2: DYNAMIC_2, DYNAMIC_3: DYNAMIC_3 }); @@ -31,4 +31,4 @@ define(['exports'], function (exports) { 'use strict'; exports.dynamic2 = dynamic2; exports.dynamic3 = dynamic3; -}); +})); diff --git a/test/chunking-form/samples/manual-chunks-dynamic-facades/_expected/amd/main.js b/test/chunking-form/samples/manual-chunks-dynamic-facades/_expected/amd/main.js index dd2114e5c49..7326ba1aa79 100644 --- a/test/chunking-form/samples/manual-chunks-dynamic-facades/_expected/amd/main.js +++ b/test/chunking-form/samples/manual-chunks-dynamic-facades/_expected/amd/main.js @@ -1,7 +1,7 @@ -define(['require', './generated-dynamic'], function (require, dynamic) { 'use strict'; +define(['require', './generated-dynamic'], (function (require, dynamic) { 'use strict'; - Promise.all([new Promise(function (resolve, reject) { require(['./generated-dynamic'], resolve, reject) }).then(function (n) { return n.dynamic1; }), new Promise(function (resolve, reject) { require(['./generated-dynamic'], resolve, reject) }).then(function (n) { return n.dynamic2; }), new Promise(function (resolve, reject) { require(['./generated-dynamic'], resolve, reject) }).then(function (n) { return n.dynamic3; })]).then( + Promise.all([new Promise(function (resolve, reject) { require(['./generated-dynamic'], resolve, reject); }).then(function (n) { return n.dynamic1; }), new Promise(function (resolve, reject) { require(['./generated-dynamic'], resolve, reject); }).then(function (n) { return n.dynamic2; }), new Promise(function (resolve, reject) { require(['./generated-dynamic'], resolve, reject); }).then(function (n) { return n.dynamic3; })]).then( results => console.log(results, dynamic.DEP) ); -}); +})); diff --git a/test/chunking-form/samples/manual-chunks-dynamic-facades/_expected/cjs/generated-dynamic.js b/test/chunking-form/samples/manual-chunks-dynamic-facades/_expected/cjs/generated-dynamic.js index 50c556066d4..d4f21ff8133 100644 --- a/test/chunking-form/samples/manual-chunks-dynamic-facades/_expected/cjs/generated-dynamic.js +++ b/test/chunking-form/samples/manual-chunks-dynamic-facades/_expected/cjs/generated-dynamic.js @@ -20,8 +20,8 @@ const DYNAMIC_1 = 'DYNAMIC_1'; var dynamic1 = /*#__PURE__*/Object.freeze({ __proto__: null, - DYNAMIC_1: DYNAMIC_1, DEP: DEP, + DYNAMIC_1: DYNAMIC_1, DYNAMIC_2: DYNAMIC_2, DYNAMIC_3: DYNAMIC_3 }); diff --git a/test/chunking-form/samples/manual-chunks-dynamic-facades/_expected/es/generated-dynamic.js b/test/chunking-form/samples/manual-chunks-dynamic-facades/_expected/es/generated-dynamic.js index 3f031460abc..cff71eaf144 100644 --- a/test/chunking-form/samples/manual-chunks-dynamic-facades/_expected/es/generated-dynamic.js +++ b/test/chunking-form/samples/manual-chunks-dynamic-facades/_expected/es/generated-dynamic.js @@ -18,8 +18,8 @@ const DYNAMIC_1 = 'DYNAMIC_1'; var dynamic1 = /*#__PURE__*/Object.freeze({ __proto__: null, - DYNAMIC_1: DYNAMIC_1, DEP: DEP, + DYNAMIC_1: DYNAMIC_1, DYNAMIC_2: DYNAMIC_2, DYNAMIC_3: DYNAMIC_3 }); diff --git a/test/chunking-form/samples/manual-chunks-dynamic-facades/_expected/system/generated-dynamic.js b/test/chunking-form/samples/manual-chunks-dynamic-facades/_expected/system/generated-dynamic.js index 768028d36f0..9c03aa1de03 100644 --- a/test/chunking-form/samples/manual-chunks-dynamic-facades/_expected/system/generated-dynamic.js +++ b/test/chunking-form/samples/manual-chunks-dynamic-facades/_expected/system/generated-dynamic.js @@ -1,9 +1,9 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - const DEP = exports('D', 'DEP'); + const DEP = exports("D", 'DEP'); const DYNAMIC_2 = 'DYNAMIC_2'; @@ -11,7 +11,7 @@ System.register([], function (exports) { __proto__: null, DYNAMIC_2: DYNAMIC_2 }); - exports('d', dynamic2); + exports("d", dynamic2); const DYNAMIC_3 = 'DYNAMIC_3'; @@ -19,19 +19,19 @@ System.register([], function (exports) { __proto__: null, DYNAMIC_3: DYNAMIC_3 }); - exports('a', dynamic3); + exports("a", dynamic3); const DYNAMIC_1 = 'DYNAMIC_1'; var dynamic1 = /*#__PURE__*/Object.freeze({ __proto__: null, - DYNAMIC_1: DYNAMIC_1, DEP: DEP, + DYNAMIC_1: DYNAMIC_1, DYNAMIC_2: DYNAMIC_2, DYNAMIC_3: DYNAMIC_3 }); - exports('b', dynamic1); + exports("b", dynamic1); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/manual-chunks-dynamic-facades/_expected/system/main.js b/test/chunking-form/samples/manual-chunks-dynamic-facades/_expected/system/main.js index 3d78385bd86..f8bb41b07d8 100644 --- a/test/chunking-form/samples/manual-chunks-dynamic-facades/_expected/system/main.js +++ b/test/chunking-form/samples/manual-chunks-dynamic-facades/_expected/system/main.js @@ -1,16 +1,16 @@ -System.register(['./generated-dynamic.js'], function (exports, module) { +System.register(['./generated-dynamic.js'], (function (exports, module) { 'use strict'; var DEP; return { setters: [function (module) { DEP = module.D; }], - execute: function () { + execute: (function () { Promise.all([module.import('./generated-dynamic.js').then(function (n) { return n.b; }), module.import('./generated-dynamic.js').then(function (n) { return n.d; }), module.import('./generated-dynamic.js').then(function (n) { return n.a; })]).then( results => console.log(results, DEP) ); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/manual-chunks-dynamic-name-conflict/_config.js b/test/chunking-form/samples/manual-chunks-dynamic-name-conflict/_config.js index 05c5ee743cf..e970a1f3446 100644 --- a/test/chunking-form/samples/manual-chunks-dynamic-name-conflict/_config.js +++ b/test/chunking-form/samples/manual-chunks-dynamic-name-conflict/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'handles name conflicts in manual chunks', options: { input: ['main.js'], @@ -8,4 +8,4 @@ module.exports = { } } } -}; +}); diff --git a/test/chunking-form/samples/manual-chunks-dynamic-name-conflict/_expected/amd/generated-dynamic.js b/test/chunking-form/samples/manual-chunks-dynamic-name-conflict/_expected/amd/generated-dynamic.js index 076fa7636d8..166f39a68df 100644 --- a/test/chunking-form/samples/manual-chunks-dynamic-name-conflict/_expected/amd/generated-dynamic.js +++ b/test/chunking-form/samples/manual-chunks-dynamic-name-conflict/_expected/amd/generated-dynamic.js @@ -1,4 +1,4 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; console.log('dynamic2'); @@ -15,11 +15,11 @@ define(['exports'], function (exports) { 'use strict'; var dynamic1 = /*#__PURE__*/Object.freeze({ __proto__: null, - DYNAMIC_B: DYNAMIC_A, - DYNAMIC_A: DYNAMIC_B + DYNAMIC_A: DYNAMIC_B, + DYNAMIC_B: DYNAMIC_A }); exports.dynamic1 = dynamic1; exports.dynamic2 = dynamic2; -}); +})); diff --git a/test/chunking-form/samples/manual-chunks-dynamic-name-conflict/_expected/amd/main.js b/test/chunking-form/samples/manual-chunks-dynamic-name-conflict/_expected/amd/main.js index 134e33a9f75..ac3701e1181 100644 --- a/test/chunking-form/samples/manual-chunks-dynamic-name-conflict/_expected/amd/main.js +++ b/test/chunking-form/samples/manual-chunks-dynamic-name-conflict/_expected/amd/main.js @@ -1,6 +1,6 @@ -define(['require'], function (require) { 'use strict'; +define(['require'], (function (require) { 'use strict'; - new Promise(function (resolve, reject) { require(['./generated-dynamic'], resolve, reject) }).then(function (n) { return n.dynamic1; }).then(result => console.log(result)); - new Promise(function (resolve, reject) { require(['./generated-dynamic'], resolve, reject) }).then(function (n) { return n.dynamic2; }).then(result => console.log(result)); + new Promise(function (resolve, reject) { require(['./generated-dynamic'], resolve, reject); }).then(function (n) { return n.dynamic1; }).then(result => console.log(result)); + new Promise(function (resolve, reject) { require(['./generated-dynamic'], resolve, reject); }).then(function (n) { return n.dynamic2; }).then(result => console.log(result)); -}); +})); diff --git a/test/chunking-form/samples/manual-chunks-dynamic-name-conflict/_expected/cjs/generated-dynamic.js b/test/chunking-form/samples/manual-chunks-dynamic-name-conflict/_expected/cjs/generated-dynamic.js index 6051f8db1b3..fd2a4ea6093 100644 --- a/test/chunking-form/samples/manual-chunks-dynamic-name-conflict/_expected/cjs/generated-dynamic.js +++ b/test/chunking-form/samples/manual-chunks-dynamic-name-conflict/_expected/cjs/generated-dynamic.js @@ -15,8 +15,8 @@ console.log('dynamic1'); var dynamic1 = /*#__PURE__*/Object.freeze({ __proto__: null, - DYNAMIC_B: DYNAMIC_A, - DYNAMIC_A: DYNAMIC_B + DYNAMIC_A: DYNAMIC_B, + DYNAMIC_B: DYNAMIC_A }); exports.dynamic1 = dynamic1; diff --git a/test/chunking-form/samples/manual-chunks-dynamic-name-conflict/_expected/es/generated-dynamic.js b/test/chunking-form/samples/manual-chunks-dynamic-name-conflict/_expected/es/generated-dynamic.js index 34710d6347c..9f46b61f9b2 100644 --- a/test/chunking-form/samples/manual-chunks-dynamic-name-conflict/_expected/es/generated-dynamic.js +++ b/test/chunking-form/samples/manual-chunks-dynamic-name-conflict/_expected/es/generated-dynamic.js @@ -13,8 +13,8 @@ console.log('dynamic1'); var dynamic1 = /*#__PURE__*/Object.freeze({ __proto__: null, - DYNAMIC_B: DYNAMIC_A, - DYNAMIC_A: DYNAMIC_B + DYNAMIC_A: DYNAMIC_B, + DYNAMIC_B: DYNAMIC_A }); export { dynamic1 as a, dynamic2 as d }; diff --git a/test/chunking-form/samples/manual-chunks-dynamic-name-conflict/_expected/system/generated-dynamic.js b/test/chunking-form/samples/manual-chunks-dynamic-name-conflict/_expected/system/generated-dynamic.js index 7b09ab0ef5b..96ec9422e7e 100644 --- a/test/chunking-form/samples/manual-chunks-dynamic-name-conflict/_expected/system/generated-dynamic.js +++ b/test/chunking-form/samples/manual-chunks-dynamic-name-conflict/_expected/system/generated-dynamic.js @@ -1,7 +1,7 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { console.log('dynamic2'); @@ -13,17 +13,17 @@ System.register([], function (exports) { DYNAMIC_A: DYNAMIC_A, DYNAMIC_B: DYNAMIC_B }); - exports('d', dynamic2); + exports("d", dynamic2); console.log('dynamic1'); var dynamic1 = /*#__PURE__*/Object.freeze({ __proto__: null, - DYNAMIC_B: DYNAMIC_A, - DYNAMIC_A: DYNAMIC_B + DYNAMIC_A: DYNAMIC_B, + DYNAMIC_B: DYNAMIC_A }); - exports('a', dynamic1); + exports("a", dynamic1); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/manual-chunks-dynamic-name-conflict/_expected/system/main.js b/test/chunking-form/samples/manual-chunks-dynamic-name-conflict/_expected/system/main.js index a59ec2ff8bb..ac232010313 100644 --- a/test/chunking-form/samples/manual-chunks-dynamic-name-conflict/_expected/system/main.js +++ b/test/chunking-form/samples/manual-chunks-dynamic-name-conflict/_expected/system/main.js @@ -1,11 +1,11 @@ -System.register([], function (exports, module) { +System.register([], (function (exports, module) { 'use strict'; return { - execute: function () { + execute: (function () { module.import('./generated-dynamic.js').then(function (n) { return n.a; }).then(result => console.log(result)); module.import('./generated-dynamic.js').then(function (n) { return n.d; }).then(result => console.log(result)); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/manual-chunks-dynamic/_config.js b/test/chunking-form/samples/manual-chunks-dynamic/_config.js index e41c6eed7a7..97dba71179e 100644 --- a/test/chunking-form/samples/manual-chunks-dynamic/_config.js +++ b/test/chunking-form/samples/manual-chunks-dynamic/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'supports dynamic manual chunks', options: { input: ['main.js'], @@ -8,4 +8,4 @@ module.exports = { } } } -}; +}); diff --git a/test/chunking-form/samples/manual-chunks-dynamic/_expected/amd/generated-dynamic.js b/test/chunking-form/samples/manual-chunks-dynamic/_expected/amd/generated-dynamic.js index 94b0e40c8e0..49c2415e4ad 100644 --- a/test/chunking-form/samples/manual-chunks-dynamic/_expected/amd/generated-dynamic.js +++ b/test/chunking-form/samples/manual-chunks-dynamic/_expected/amd/generated-dynamic.js @@ -1,7 +1,7 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; const DYNAMIC_USED_BY_A = 'DYNAMIC_USED_BY_A'; exports.DYNAMIC_USED_BY_A = DYNAMIC_USED_BY_A; -}); +})); diff --git a/test/chunking-form/samples/manual-chunks-dynamic/_expected/amd/main.js b/test/chunking-form/samples/manual-chunks-dynamic/_expected/amd/main.js index 7ade37c39c9..9dd81f18740 100644 --- a/test/chunking-form/samples/manual-chunks-dynamic/_expected/amd/main.js +++ b/test/chunking-form/samples/manual-chunks-dynamic/_expected/amd/main.js @@ -1,5 +1,5 @@ -define(['require'], function (require) { 'use strict'; +define(['require'], (function (require) { 'use strict'; - new Promise(function (resolve, reject) { require(['./generated-dynamic'], resolve, reject) }).then(({DYNAMIC_USED_BY_A}) => console.log(DYNAMIC_USED_BY_A)); + new Promise(function (resolve, reject) { require(['./generated-dynamic'], resolve, reject); }).then(({DYNAMIC_USED_BY_A}) => console.log(DYNAMIC_USED_BY_A)); -}); +})); diff --git a/test/chunking-form/samples/manual-chunks-dynamic/_expected/system/generated-dynamic.js b/test/chunking-form/samples/manual-chunks-dynamic/_expected/system/generated-dynamic.js index cf05be5bb3b..35469f810fd 100644 --- a/test/chunking-form/samples/manual-chunks-dynamic/_expected/system/generated-dynamic.js +++ b/test/chunking-form/samples/manual-chunks-dynamic/_expected/system/generated-dynamic.js @@ -1,10 +1,10 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - const DYNAMIC_USED_BY_A = exports('DYNAMIC_USED_BY_A', 'DYNAMIC_USED_BY_A'); + const DYNAMIC_USED_BY_A = exports("DYNAMIC_USED_BY_A", 'DYNAMIC_USED_BY_A'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/manual-chunks-dynamic/_expected/system/main.js b/test/chunking-form/samples/manual-chunks-dynamic/_expected/system/main.js index 5c1d9db7c1e..df0f0195b01 100644 --- a/test/chunking-form/samples/manual-chunks-dynamic/_expected/system/main.js +++ b/test/chunking-form/samples/manual-chunks-dynamic/_expected/system/main.js @@ -1,10 +1,10 @@ -System.register([], function (exports, module) { +System.register([], (function (exports, module) { 'use strict'; return { - execute: function () { + execute: (function () { module.import('./generated-dynamic.js').then(({DYNAMIC_USED_BY_A}) => console.log(DYNAMIC_USED_BY_A)); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/manual-chunks-function/_config.js b/test/chunking-form/samples/manual-chunks-function/_config.js index 1c3e6daf708..cb91ed2b095 100644 --- a/test/chunking-form/samples/manual-chunks-function/_config.js +++ b/test/chunking-form/samples/manual-chunks-function/_config.js @@ -1,4 +1,6 @@ -module.exports = { +const assert = require('node:assert'); + +module.exports = defineTest({ description: 'allows to define manual chunks via a function', options: { input: ['main-a'], @@ -8,6 +10,19 @@ module.exports = { return `chunk-${id[id.length - 4]}`; } } - } + }, + plugins: [ + { + generateBundle(options, bundle) { + // This also asserts the sorting order, which should be alphabetical + // between the manual chunks + assert.deepStrictEqual(Object.keys(bundle), [ + 'main-a.js', + 'generated-chunk-c.js', + 'generated-chunk-b.js' + ]); + } + } + ] } -}; +}); diff --git a/test/chunking-form/samples/manual-chunks-function/_expected/amd/generated-chunk-b.js b/test/chunking-form/samples/manual-chunks-function/_expected/amd/generated-chunk-b.js index 234e6a42b0c..6daed26df97 100644 --- a/test/chunking-form/samples/manual-chunks-function/_expected/amd/generated-chunk-b.js +++ b/test/chunking-form/samples/manual-chunks-function/_expected/amd/generated-chunk-b.js @@ -1,7 +1,9 @@ -define(function () { 'use strict'; - - console.log('dep2'); +define(['./generated-chunk-c'], (function (chunkC) { 'use strict'; console.log('dep-b'); -}); + console.log('dep2-b'); + + console.log('dep3-b'); + +})); diff --git a/test/chunking-form/samples/manual-chunks-function/_expected/amd/generated-chunk-c.js b/test/chunking-form/samples/manual-chunks-function/_expected/amd/generated-chunk-c.js index d62075790ea..d144cc03b0f 100644 --- a/test/chunking-form/samples/manual-chunks-function/_expected/amd/generated-chunk-c.js +++ b/test/chunking-form/samples/manual-chunks-function/_expected/amd/generated-chunk-c.js @@ -1,5 +1,7 @@ -define(['./generated-chunk-b'], function (chunkB) { 'use strict'; +define((function () { 'use strict'; + + console.log('dep2'); console.log('dep-c'); -}); +})); diff --git a/test/chunking-form/samples/manual-chunks-function/_expected/amd/main-a.js b/test/chunking-form/samples/manual-chunks-function/_expected/amd/main-a.js index 35ee425f7c8..072c08147ab 100644 --- a/test/chunking-form/samples/manual-chunks-function/_expected/amd/main-a.js +++ b/test/chunking-form/samples/manual-chunks-function/_expected/amd/main-a.js @@ -1,9 +1,13 @@ -define(['./generated-chunk-c', './generated-chunk-b'], function (chunkC, chunkB) { 'use strict'; +define(['./generated-chunk-c', './generated-chunk-b'], (function (chunkC, chunkB) { 'use strict'; console.log('dep1'); console.log('dep-a'); + console.log('dep2-a'); + + console.log('dep3-a'); + console.log('main-a'); -}); +})); diff --git a/test/chunking-form/samples/manual-chunks-function/_expected/cjs/generated-chunk-b.js b/test/chunking-form/samples/manual-chunks-function/_expected/cjs/generated-chunk-b.js index 51b3d3e3d98..9765e6b8ded 100644 --- a/test/chunking-form/samples/manual-chunks-function/_expected/cjs/generated-chunk-b.js +++ b/test/chunking-form/samples/manual-chunks-function/_expected/cjs/generated-chunk-b.js @@ -1,5 +1,9 @@ 'use strict'; -console.log('dep2'); +require('./generated-chunk-c.js'); console.log('dep-b'); + +console.log('dep2-b'); + +console.log('dep3-b'); diff --git a/test/chunking-form/samples/manual-chunks-function/_expected/cjs/generated-chunk-c.js b/test/chunking-form/samples/manual-chunks-function/_expected/cjs/generated-chunk-c.js index d8349602bd6..4fe62a18981 100644 --- a/test/chunking-form/samples/manual-chunks-function/_expected/cjs/generated-chunk-c.js +++ b/test/chunking-form/samples/manual-chunks-function/_expected/cjs/generated-chunk-c.js @@ -1,5 +1,5 @@ 'use strict'; -require('./generated-chunk-b.js'); +console.log('dep2'); console.log('dep-c'); diff --git a/test/chunking-form/samples/manual-chunks-function/_expected/cjs/main-a.js b/test/chunking-form/samples/manual-chunks-function/_expected/cjs/main-a.js index 2d8f820fd93..6f6c77f9901 100644 --- a/test/chunking-form/samples/manual-chunks-function/_expected/cjs/main-a.js +++ b/test/chunking-form/samples/manual-chunks-function/_expected/cjs/main-a.js @@ -7,4 +7,8 @@ console.log('dep1'); console.log('dep-a'); +console.log('dep2-a'); + +console.log('dep3-a'); + console.log('main-a'); diff --git a/test/chunking-form/samples/manual-chunks-function/_expected/es/generated-chunk-b.js b/test/chunking-form/samples/manual-chunks-function/_expected/es/generated-chunk-b.js index 16fb2a90267..5ef8bab1cb7 100644 --- a/test/chunking-form/samples/manual-chunks-function/_expected/es/generated-chunk-b.js +++ b/test/chunking-form/samples/manual-chunks-function/_expected/es/generated-chunk-b.js @@ -1,3 +1,7 @@ -console.log('dep2'); +import './generated-chunk-c.js'; console.log('dep-b'); + +console.log('dep2-b'); + +console.log('dep3-b'); diff --git a/test/chunking-form/samples/manual-chunks-function/_expected/es/generated-chunk-c.js b/test/chunking-form/samples/manual-chunks-function/_expected/es/generated-chunk-c.js index 78ee7d95de5..d0c3403c8a6 100644 --- a/test/chunking-form/samples/manual-chunks-function/_expected/es/generated-chunk-c.js +++ b/test/chunking-form/samples/manual-chunks-function/_expected/es/generated-chunk-c.js @@ -1,3 +1,3 @@ -import './generated-chunk-b.js'; +console.log('dep2'); console.log('dep-c'); diff --git a/test/chunking-form/samples/manual-chunks-function/_expected/es/main-a.js b/test/chunking-form/samples/manual-chunks-function/_expected/es/main-a.js index d3864b7146c..64402f5149a 100644 --- a/test/chunking-form/samples/manual-chunks-function/_expected/es/main-a.js +++ b/test/chunking-form/samples/manual-chunks-function/_expected/es/main-a.js @@ -5,4 +5,8 @@ console.log('dep1'); console.log('dep-a'); +console.log('dep2-a'); + +console.log('dep3-a'); + console.log('main-a'); diff --git a/test/chunking-form/samples/manual-chunks-function/_expected/system/generated-chunk-b.js b/test/chunking-form/samples/manual-chunks-function/_expected/system/generated-chunk-b.js index fabf038cbaa..ec5f24d6636 100644 --- a/test/chunking-form/samples/manual-chunks-function/_expected/system/generated-chunk-b.js +++ b/test/chunking-form/samples/manual-chunks-function/_expected/system/generated-chunk-b.js @@ -1,12 +1,15 @@ -System.register([], function () { +System.register(['./generated-chunk-c.js'], (function () { 'use strict'; return { - execute: function () { - - console.log('dep2'); + setters: [null], + execute: (function () { console.log('dep-b'); - } + console.log('dep2-b'); + + console.log('dep3-b'); + + }) }; -}); +})); diff --git a/test/chunking-form/samples/manual-chunks-function/_expected/system/generated-chunk-c.js b/test/chunking-form/samples/manual-chunks-function/_expected/system/generated-chunk-c.js index 4cd41ad57b6..8a615729325 100644 --- a/test/chunking-form/samples/manual-chunks-function/_expected/system/generated-chunk-c.js +++ b/test/chunking-form/samples/manual-chunks-function/_expected/system/generated-chunk-c.js @@ -1,11 +1,12 @@ -System.register(['./generated-chunk-b.js'], function () { +System.register([], (function () { 'use strict'; return { - setters: [function () {}], - execute: function () { + execute: (function () { + + console.log('dep2'); console.log('dep-c'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/manual-chunks-function/_expected/system/main-a.js b/test/chunking-form/samples/manual-chunks-function/_expected/system/main-a.js index c897b06437a..3ff03fcbe34 100644 --- a/test/chunking-form/samples/manual-chunks-function/_expected/system/main-a.js +++ b/test/chunking-form/samples/manual-chunks-function/_expected/system/main-a.js @@ -1,15 +1,19 @@ -System.register(['./generated-chunk-c.js', './generated-chunk-b.js'], function () { +System.register(['./generated-chunk-c.js', './generated-chunk-b.js'], (function () { 'use strict'; return { - setters: [function () {}, function () {}], - execute: function () { + setters: [null, null], + execute: (function () { console.log('dep1'); console.log('dep-a'); + console.log('dep2-a'); + + console.log('dep3-a'); + console.log('main-a'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/manual-chunks-function/dep2-a.js b/test/chunking-form/samples/manual-chunks-function/dep2-a.js new file mode 100644 index 00000000000..a36794d741a --- /dev/null +++ b/test/chunking-form/samples/manual-chunks-function/dep2-a.js @@ -0,0 +1 @@ +console.log('dep2-a'); diff --git a/test/chunking-form/samples/manual-chunks-function/dep2-b.js b/test/chunking-form/samples/manual-chunks-function/dep2-b.js new file mode 100644 index 00000000000..0497bb3e651 --- /dev/null +++ b/test/chunking-form/samples/manual-chunks-function/dep2-b.js @@ -0,0 +1 @@ +console.log('dep2-b'); diff --git a/test/chunking-form/samples/manual-chunks-function/dep3-a.js b/test/chunking-form/samples/manual-chunks-function/dep3-a.js new file mode 100644 index 00000000000..4a39d2d9a27 --- /dev/null +++ b/test/chunking-form/samples/manual-chunks-function/dep3-a.js @@ -0,0 +1 @@ +console.log('dep3-a'); diff --git a/test/chunking-form/samples/manual-chunks-function/dep3-b.js b/test/chunking-form/samples/manual-chunks-function/dep3-b.js new file mode 100644 index 00000000000..63138d71943 --- /dev/null +++ b/test/chunking-form/samples/manual-chunks-function/dep3-b.js @@ -0,0 +1 @@ +console.log('dep3-b'); diff --git a/test/chunking-form/samples/manual-chunks-function/main-a.js b/test/chunking-form/samples/manual-chunks-function/main-a.js index cf97f330a79..5357d3deb1c 100644 --- a/test/chunking-form/samples/manual-chunks-function/main-a.js +++ b/test/chunking-form/samples/manual-chunks-function/main-a.js @@ -1,4 +1,9 @@ +import './dep-c'; import './dep-a'; +import './dep2-a' +import './dep3-a' import './dep-b'; +import './dep2-b' +import './dep3-b' console.log('main-a'); diff --git a/test/chunking-form/samples/manual-chunks-nested/_config.js b/test/chunking-form/samples/manual-chunks-nested/_config.js index 8214e629eaf..f39bf727dfb 100644 --- a/test/chunking-form/samples/manual-chunks-nested/_config.js +++ b/test/chunking-form/samples/manual-chunks-nested/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'manual chunks can contain nested modules', options: { input: ['main.js'], @@ -8,4 +8,4 @@ module.exports = { } } } -}; +}); diff --git a/test/chunking-form/samples/manual-chunks-nested/_expected/amd/generated-manual.js b/test/chunking-form/samples/manual-chunks-nested/_expected/amd/generated-manual.js index e81d58f94e9..3c9aa92fa80 100644 --- a/test/chunking-form/samples/manual-chunks-nested/_expected/amd/generated-manual.js +++ b/test/chunking-form/samples/manual-chunks-nested/_expected/amd/generated-manual.js @@ -1,4 +1,4 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; console.log('inner'); @@ -6,4 +6,4 @@ define(function () { 'use strict'; console.log('outer'); -}); +})); diff --git a/test/chunking-form/samples/manual-chunks-nested/_expected/amd/main.js b/test/chunking-form/samples/manual-chunks-nested/_expected/amd/main.js index c9a0d54be11..b9a9d643047 100644 --- a/test/chunking-form/samples/manual-chunks-nested/_expected/amd/main.js +++ b/test/chunking-form/samples/manual-chunks-nested/_expected/amd/main.js @@ -1,5 +1,5 @@ -define(['./generated-manual'], function (manual) { 'use strict'; +define(['./generated-manual'], (function (manual) { 'use strict'; console.log('main'); -}); +})); diff --git a/test/chunking-form/samples/manual-chunks-nested/_expected/system/generated-manual.js b/test/chunking-form/samples/manual-chunks-nested/_expected/system/generated-manual.js index b297489bbda..4596d906ee4 100644 --- a/test/chunking-form/samples/manual-chunks-nested/_expected/system/generated-manual.js +++ b/test/chunking-form/samples/manual-chunks-nested/_expected/system/generated-manual.js @@ -1,7 +1,7 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { console.log('inner'); @@ -9,6 +9,6 @@ System.register([], function () { console.log('outer'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/manual-chunks-nested/_expected/system/main.js b/test/chunking-form/samples/manual-chunks-nested/_expected/system/main.js index a1d452ebaf8..3e762e61fd8 100644 --- a/test/chunking-form/samples/manual-chunks-nested/_expected/system/main.js +++ b/test/chunking-form/samples/manual-chunks-nested/_expected/system/main.js @@ -1,11 +1,11 @@ -System.register(['./generated-manual.js'], function () { +System.register(['./generated-manual.js'], (function () { 'use strict'; return { - setters: [function () {}], - execute: function () { + setters: [null], + execute: (function () { console.log('main'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/manual-chunks-only-explicit-dependencies/function-form/_config.js b/test/chunking-form/samples/manual-chunks-only-explicit-dependencies/function-form/_config.js new file mode 100644 index 00000000000..b8af45eff05 --- /dev/null +++ b/test/chunking-form/samples/manual-chunks-only-explicit-dependencies/function-form/_config.js @@ -0,0 +1,15 @@ +module.exports = defineTest({ + description: + 'manual chunks function form with onlyExplicitManualChunks does not merge non specified dependencies into the output chunk. Instead it lets Rollup normal chunking logic output them separately.', + options: { + input: 'main', + output: { + manualChunks: id => { + if (id.endsWith('manual1.js') || id.endsWith('manual2.js')) { + return 'manual'; + } + }, + onlyExplicitManualChunks: true + } + } +}); diff --git a/test/chunking-form/samples/manual-chunks-only-explicit-dependencies/function-form/_expected/amd/generated-dep.js b/test/chunking-form/samples/manual-chunks-only-explicit-dependencies/function-form/_expected/amd/generated-dep.js new file mode 100644 index 00000000000..f94a3d9d9f9 --- /dev/null +++ b/test/chunking-form/samples/manual-chunks-only-explicit-dependencies/function-form/_expected/amd/generated-dep.js @@ -0,0 +1,5 @@ +define((function () { 'use strict'; + + console.log('dep'); + +})); diff --git a/test/chunking-form/samples/manual-chunks-only-explicit-dependencies/function-form/_expected/amd/generated-manual.js b/test/chunking-form/samples/manual-chunks-only-explicit-dependencies/function-form/_expected/amd/generated-manual.js new file mode 100644 index 00000000000..23e6f34f8b9 --- /dev/null +++ b/test/chunking-form/samples/manual-chunks-only-explicit-dependencies/function-form/_expected/amd/generated-manual.js @@ -0,0 +1,18 @@ +define(['exports', './generated-dep'], (function (exports, dep) { 'use strict'; + + console.log('manual1'); + + var manual1 = /*#__PURE__*/Object.freeze({ + __proto__: null + }); + + console.log('manual2'); + + var manual2 = /*#__PURE__*/Object.freeze({ + __proto__: null + }); + + exports.manual1 = manual1; + exports.manual2 = manual2; + +})); diff --git a/test/chunking-form/samples/manual-chunks-only-explicit-dependencies/function-form/_expected/amd/main.js b/test/chunking-form/samples/manual-chunks-only-explicit-dependencies/function-form/_expected/amd/main.js new file mode 100644 index 00000000000..793ac6d3fd2 --- /dev/null +++ b/test/chunking-form/samples/manual-chunks-only-explicit-dependencies/function-form/_expected/amd/main.js @@ -0,0 +1,14 @@ +define(['require'], (function (require) { 'use strict'; + + // Using dynamic imports for clearer expected output + const load = async () => { + console.log( + await new Promise(function (resolve, reject) { require(['./generated-manual'], resolve, reject); }).then(function (n) { return n.manual1; }).then((m) => m.manual1), + await new Promise(function (resolve, reject) { require(['./generated-manual'], resolve, reject); }).then(function (n) { return n.manual2; }).then((m) => m.manual2), + ); + }; + load(); + + console.log('main'); + +})); diff --git a/test/chunking-form/samples/manual-chunks-only-explicit-dependencies/function-form/_expected/cjs/generated-dep.js b/test/chunking-form/samples/manual-chunks-only-explicit-dependencies/function-form/_expected/cjs/generated-dep.js new file mode 100644 index 00000000000..f97cbb47032 --- /dev/null +++ b/test/chunking-form/samples/manual-chunks-only-explicit-dependencies/function-form/_expected/cjs/generated-dep.js @@ -0,0 +1,3 @@ +'use strict'; + +console.log('dep'); diff --git a/test/chunking-form/samples/manual-chunks-only-explicit-dependencies/function-form/_expected/cjs/generated-manual.js b/test/chunking-form/samples/manual-chunks-only-explicit-dependencies/function-form/_expected/cjs/generated-manual.js new file mode 100644 index 00000000000..81025971bb6 --- /dev/null +++ b/test/chunking-form/samples/manual-chunks-only-explicit-dependencies/function-form/_expected/cjs/generated-manual.js @@ -0,0 +1,18 @@ +'use strict'; + +require('./generated-dep.js'); + +console.log('manual1'); + +var manual1 = /*#__PURE__*/Object.freeze({ + __proto__: null +}); + +console.log('manual2'); + +var manual2 = /*#__PURE__*/Object.freeze({ + __proto__: null +}); + +exports.manual1 = manual1; +exports.manual2 = manual2; diff --git a/test/chunking-form/samples/manual-chunks-only-explicit-dependencies/function-form/_expected/cjs/main.js b/test/chunking-form/samples/manual-chunks-only-explicit-dependencies/function-form/_expected/cjs/main.js new file mode 100644 index 00000000000..59cff03dd81 --- /dev/null +++ b/test/chunking-form/samples/manual-chunks-only-explicit-dependencies/function-form/_expected/cjs/main.js @@ -0,0 +1,12 @@ +'use strict'; + +// Using dynamic imports for clearer expected output +const load = async () => { + console.log( + await Promise.resolve().then(function () { return require('./generated-manual.js'); }).then(function (n) { return n.manual1; }).then((m) => m.manual1), + await Promise.resolve().then(function () { return require('./generated-manual.js'); }).then(function (n) { return n.manual2; }).then((m) => m.manual2), + ); +}; +load(); + +console.log('main'); diff --git a/test/chunking-form/samples/manual-chunks-only-explicit-dependencies/function-form/_expected/es/generated-dep.js b/test/chunking-form/samples/manual-chunks-only-explicit-dependencies/function-form/_expected/es/generated-dep.js new file mode 100644 index 00000000000..b74a9837c07 --- /dev/null +++ b/test/chunking-form/samples/manual-chunks-only-explicit-dependencies/function-form/_expected/es/generated-dep.js @@ -0,0 +1 @@ +console.log('dep'); diff --git a/test/chunking-form/samples/manual-chunks-only-explicit-dependencies/function-form/_expected/es/generated-manual.js b/test/chunking-form/samples/manual-chunks-only-explicit-dependencies/function-form/_expected/es/generated-manual.js new file mode 100644 index 00000000000..50a3b0eb239 --- /dev/null +++ b/test/chunking-form/samples/manual-chunks-only-explicit-dependencies/function-form/_expected/es/generated-manual.js @@ -0,0 +1,15 @@ +import './generated-dep.js'; + +console.log('manual1'); + +var manual1 = /*#__PURE__*/Object.freeze({ + __proto__: null +}); + +console.log('manual2'); + +var manual2 = /*#__PURE__*/Object.freeze({ + __proto__: null +}); + +export { manual2 as a, manual1 as m }; diff --git a/test/chunking-form/samples/manual-chunks-only-explicit-dependencies/function-form/_expected/es/main.js b/test/chunking-form/samples/manual-chunks-only-explicit-dependencies/function-form/_expected/es/main.js new file mode 100644 index 00000000000..3b1ebec0851 --- /dev/null +++ b/test/chunking-form/samples/manual-chunks-only-explicit-dependencies/function-form/_expected/es/main.js @@ -0,0 +1,10 @@ +// Using dynamic imports for clearer expected output +const load = async () => { + console.log( + await import('./generated-manual.js').then(function (n) { return n.m; }).then((m) => m.manual1), + await import('./generated-manual.js').then(function (n) { return n.a; }).then((m) => m.manual2), + ); +}; +load(); + +console.log('main'); diff --git a/test/chunking-form/samples/manual-chunks-only-explicit-dependencies/function-form/_expected/system/generated-dep.js b/test/chunking-form/samples/manual-chunks-only-explicit-dependencies/function-form/_expected/system/generated-dep.js new file mode 100644 index 00000000000..963f20ddf9c --- /dev/null +++ b/test/chunking-form/samples/manual-chunks-only-explicit-dependencies/function-form/_expected/system/generated-dep.js @@ -0,0 +1,10 @@ +System.register([], (function () { + 'use strict'; + return { + execute: (function () { + + console.log('dep'); + + }) + }; +})); diff --git a/test/chunking-form/samples/manual-chunks-only-explicit-dependencies/function-form/_expected/system/generated-manual.js b/test/chunking-form/samples/manual-chunks-only-explicit-dependencies/function-form/_expected/system/generated-manual.js new file mode 100644 index 00000000000..2e810431ff8 --- /dev/null +++ b/test/chunking-form/samples/manual-chunks-only-explicit-dependencies/function-form/_expected/system/generated-manual.js @@ -0,0 +1,23 @@ +System.register(['./generated-dep.js'], (function (exports) { + 'use strict'; + return { + setters: [null], + execute: (function () { + + console.log('manual1'); + + var manual1 = /*#__PURE__*/Object.freeze({ + __proto__: null + }); + exports("m", manual1); + + console.log('manual2'); + + var manual2 = /*#__PURE__*/Object.freeze({ + __proto__: null + }); + exports("a", manual2); + + }) + }; +})); diff --git a/test/chunking-form/samples/manual-chunks-only-explicit-dependencies/function-form/_expected/system/main.js b/test/chunking-form/samples/manual-chunks-only-explicit-dependencies/function-form/_expected/system/main.js new file mode 100644 index 00000000000..44608d8b191 --- /dev/null +++ b/test/chunking-form/samples/manual-chunks-only-explicit-dependencies/function-form/_expected/system/main.js @@ -0,0 +1,19 @@ +System.register([], (function (exports, module) { + 'use strict'; + return { + execute: (function () { + + // Using dynamic imports for clearer expected output + const load = async () => { + console.log( + await module.import('./generated-manual.js').then(function (n) { return n.m; }).then((m) => m.manual1), + await module.import('./generated-manual.js').then(function (n) { return n.a; }).then((m) => m.manual2), + ); + }; + load(); + + console.log('main'); + + }) + }; +})); diff --git a/test/chunking-form/samples/manual-chunks-only-explicit-dependencies/function-form/dep.js b/test/chunking-form/samples/manual-chunks-only-explicit-dependencies/function-form/dep.js new file mode 100644 index 00000000000..9d1f6e2d94b --- /dev/null +++ b/test/chunking-form/samples/manual-chunks-only-explicit-dependencies/function-form/dep.js @@ -0,0 +1 @@ +console.log('dep'); \ No newline at end of file diff --git a/test/chunking-form/samples/manual-chunks-only-explicit-dependencies/function-form/main.js b/test/chunking-form/samples/manual-chunks-only-explicit-dependencies/function-form/main.js new file mode 100644 index 00000000000..d5192f392f4 --- /dev/null +++ b/test/chunking-form/samples/manual-chunks-only-explicit-dependencies/function-form/main.js @@ -0,0 +1,10 @@ +// Using dynamic imports for clearer expected output +const load = async () => { + console.log( + await import('./manual1').then((m) => m.manual1), + await import('./manual2').then((m) => m.manual2), + ); +}; +load(); + +console.log('main'); \ No newline at end of file diff --git a/test/chunking-form/samples/manual-chunks-only-explicit-dependencies/function-form/manual1.js b/test/chunking-form/samples/manual-chunks-only-explicit-dependencies/function-form/manual1.js new file mode 100644 index 00000000000..15fd878b5af --- /dev/null +++ b/test/chunking-form/samples/manual-chunks-only-explicit-dependencies/function-form/manual1.js @@ -0,0 +1,3 @@ +import './dep.js'; + +console.log('manual1'); \ No newline at end of file diff --git a/test/chunking-form/samples/manual-chunks-only-explicit-dependencies/function-form/manual2.js b/test/chunking-form/samples/manual-chunks-only-explicit-dependencies/function-form/manual2.js new file mode 100644 index 00000000000..053423837a0 --- /dev/null +++ b/test/chunking-form/samples/manual-chunks-only-explicit-dependencies/function-form/manual2.js @@ -0,0 +1,3 @@ +import './dep.js'; + +console.log('manual2'); \ No newline at end of file diff --git a/test/chunking-form/samples/manual-chunks-only-explicit-dependencies/object-form/_config.js b/test/chunking-form/samples/manual-chunks-only-explicit-dependencies/object-form/_config.js new file mode 100644 index 00000000000..b4c667a702c --- /dev/null +++ b/test/chunking-form/samples/manual-chunks-only-explicit-dependencies/object-form/_config.js @@ -0,0 +1,13 @@ +module.exports = defineTest({ + description: + "manual chunks object form merges the specified modules' dependencies into the output chunk", + options: { + input: 'main', + output: { + manualChunks: { + manual: ['manual1', 'manual2'] + }, + onlyExplicitManualChunks: true + } + } +}); diff --git a/test/chunking-form/samples/manual-chunks-only-explicit-dependencies/object-form/_expected/amd/generated-manual.js b/test/chunking-form/samples/manual-chunks-only-explicit-dependencies/object-form/_expected/amd/generated-manual.js new file mode 100644 index 00000000000..c6338afbf33 --- /dev/null +++ b/test/chunking-form/samples/manual-chunks-only-explicit-dependencies/object-form/_expected/amd/generated-manual.js @@ -0,0 +1,20 @@ +define(['exports'], (function (exports) { 'use strict'; + + console.log('dep'); + + console.log('manual1'); + + var manual1 = /*#__PURE__*/Object.freeze({ + __proto__: null + }); + + console.log('manual2'); + + var manual2 = /*#__PURE__*/Object.freeze({ + __proto__: null + }); + + exports.manual1 = manual1; + exports.manual2 = manual2; + +})); diff --git a/test/chunking-form/samples/manual-chunks-only-explicit-dependencies/object-form/_expected/amd/main.js b/test/chunking-form/samples/manual-chunks-only-explicit-dependencies/object-form/_expected/amd/main.js new file mode 100644 index 00000000000..793ac6d3fd2 --- /dev/null +++ b/test/chunking-form/samples/manual-chunks-only-explicit-dependencies/object-form/_expected/amd/main.js @@ -0,0 +1,14 @@ +define(['require'], (function (require) { 'use strict'; + + // Using dynamic imports for clearer expected output + const load = async () => { + console.log( + await new Promise(function (resolve, reject) { require(['./generated-manual'], resolve, reject); }).then(function (n) { return n.manual1; }).then((m) => m.manual1), + await new Promise(function (resolve, reject) { require(['./generated-manual'], resolve, reject); }).then(function (n) { return n.manual2; }).then((m) => m.manual2), + ); + }; + load(); + + console.log('main'); + +})); diff --git a/test/chunking-form/samples/manual-chunks-only-explicit-dependencies/object-form/_expected/cjs/generated-manual.js b/test/chunking-form/samples/manual-chunks-only-explicit-dependencies/object-form/_expected/cjs/generated-manual.js new file mode 100644 index 00000000000..56407d94510 --- /dev/null +++ b/test/chunking-form/samples/manual-chunks-only-explicit-dependencies/object-form/_expected/cjs/generated-manual.js @@ -0,0 +1,18 @@ +'use strict'; + +console.log('dep'); + +console.log('manual1'); + +var manual1 = /*#__PURE__*/Object.freeze({ + __proto__: null +}); + +console.log('manual2'); + +var manual2 = /*#__PURE__*/Object.freeze({ + __proto__: null +}); + +exports.manual1 = manual1; +exports.manual2 = manual2; diff --git a/test/chunking-form/samples/manual-chunks-only-explicit-dependencies/object-form/_expected/cjs/main.js b/test/chunking-form/samples/manual-chunks-only-explicit-dependencies/object-form/_expected/cjs/main.js new file mode 100644 index 00000000000..59cff03dd81 --- /dev/null +++ b/test/chunking-form/samples/manual-chunks-only-explicit-dependencies/object-form/_expected/cjs/main.js @@ -0,0 +1,12 @@ +'use strict'; + +// Using dynamic imports for clearer expected output +const load = async () => { + console.log( + await Promise.resolve().then(function () { return require('./generated-manual.js'); }).then(function (n) { return n.manual1; }).then((m) => m.manual1), + await Promise.resolve().then(function () { return require('./generated-manual.js'); }).then(function (n) { return n.manual2; }).then((m) => m.manual2), + ); +}; +load(); + +console.log('main'); diff --git a/test/chunking-form/samples/manual-chunks-only-explicit-dependencies/object-form/_expected/es/generated-manual.js b/test/chunking-form/samples/manual-chunks-only-explicit-dependencies/object-form/_expected/es/generated-manual.js new file mode 100644 index 00000000000..a4d2ebc1b46 --- /dev/null +++ b/test/chunking-form/samples/manual-chunks-only-explicit-dependencies/object-form/_expected/es/generated-manual.js @@ -0,0 +1,15 @@ +console.log('dep'); + +console.log('manual1'); + +var manual1 = /*#__PURE__*/Object.freeze({ + __proto__: null +}); + +console.log('manual2'); + +var manual2 = /*#__PURE__*/Object.freeze({ + __proto__: null +}); + +export { manual2 as a, manual1 as m }; diff --git a/test/chunking-form/samples/manual-chunks-only-explicit-dependencies/object-form/_expected/es/main.js b/test/chunking-form/samples/manual-chunks-only-explicit-dependencies/object-form/_expected/es/main.js new file mode 100644 index 00000000000..3b1ebec0851 --- /dev/null +++ b/test/chunking-form/samples/manual-chunks-only-explicit-dependencies/object-form/_expected/es/main.js @@ -0,0 +1,10 @@ +// Using dynamic imports for clearer expected output +const load = async () => { + console.log( + await import('./generated-manual.js').then(function (n) { return n.m; }).then((m) => m.manual1), + await import('./generated-manual.js').then(function (n) { return n.a; }).then((m) => m.manual2), + ); +}; +load(); + +console.log('main'); diff --git a/test/chunking-form/samples/manual-chunks-only-explicit-dependencies/object-form/_expected/system/generated-manual.js b/test/chunking-form/samples/manual-chunks-only-explicit-dependencies/object-form/_expected/system/generated-manual.js new file mode 100644 index 00000000000..f5ceaf67413 --- /dev/null +++ b/test/chunking-form/samples/manual-chunks-only-explicit-dependencies/object-form/_expected/system/generated-manual.js @@ -0,0 +1,24 @@ +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + + console.log('dep'); + + console.log('manual1'); + + var manual1 = /*#__PURE__*/Object.freeze({ + __proto__: null + }); + exports("m", manual1); + + console.log('manual2'); + + var manual2 = /*#__PURE__*/Object.freeze({ + __proto__: null + }); + exports("a", manual2); + + }) + }; +})); diff --git a/test/chunking-form/samples/manual-chunks-only-explicit-dependencies/object-form/_expected/system/main.js b/test/chunking-form/samples/manual-chunks-only-explicit-dependencies/object-form/_expected/system/main.js new file mode 100644 index 00000000000..44608d8b191 --- /dev/null +++ b/test/chunking-form/samples/manual-chunks-only-explicit-dependencies/object-form/_expected/system/main.js @@ -0,0 +1,19 @@ +System.register([], (function (exports, module) { + 'use strict'; + return { + execute: (function () { + + // Using dynamic imports for clearer expected output + const load = async () => { + console.log( + await module.import('./generated-manual.js').then(function (n) { return n.m; }).then((m) => m.manual1), + await module.import('./generated-manual.js').then(function (n) { return n.a; }).then((m) => m.manual2), + ); + }; + load(); + + console.log('main'); + + }) + }; +})); diff --git a/test/chunking-form/samples/manual-chunks-only-explicit-dependencies/object-form/dep.js b/test/chunking-form/samples/manual-chunks-only-explicit-dependencies/object-form/dep.js new file mode 100644 index 00000000000..9d1f6e2d94b --- /dev/null +++ b/test/chunking-form/samples/manual-chunks-only-explicit-dependencies/object-form/dep.js @@ -0,0 +1 @@ +console.log('dep'); \ No newline at end of file diff --git a/test/chunking-form/samples/manual-chunks-only-explicit-dependencies/object-form/main.js b/test/chunking-form/samples/manual-chunks-only-explicit-dependencies/object-form/main.js new file mode 100644 index 00000000000..d5192f392f4 --- /dev/null +++ b/test/chunking-form/samples/manual-chunks-only-explicit-dependencies/object-form/main.js @@ -0,0 +1,10 @@ +// Using dynamic imports for clearer expected output +const load = async () => { + console.log( + await import('./manual1').then((m) => m.manual1), + await import('./manual2').then((m) => m.manual2), + ); +}; +load(); + +console.log('main'); \ No newline at end of file diff --git a/test/chunking-form/samples/manual-chunks-only-explicit-dependencies/object-form/manual1.js b/test/chunking-form/samples/manual-chunks-only-explicit-dependencies/object-form/manual1.js new file mode 100644 index 00000000000..15fd878b5af --- /dev/null +++ b/test/chunking-form/samples/manual-chunks-only-explicit-dependencies/object-form/manual1.js @@ -0,0 +1,3 @@ +import './dep.js'; + +console.log('manual1'); \ No newline at end of file diff --git a/test/chunking-form/samples/manual-chunks-only-explicit-dependencies/object-form/manual2.js b/test/chunking-form/samples/manual-chunks-only-explicit-dependencies/object-form/manual2.js new file mode 100644 index 00000000000..053423837a0 --- /dev/null +++ b/test/chunking-form/samples/manual-chunks-only-explicit-dependencies/object-form/manual2.js @@ -0,0 +1,3 @@ +import './dep.js'; + +console.log('manual2'); \ No newline at end of file diff --git a/test/chunking-form/samples/manual-chunks/_config.js b/test/chunking-form/samples/manual-chunks/_config.js index 2589e95d79a..2b424e1b73e 100644 --- a/test/chunking-form/samples/manual-chunks/_config.js +++ b/test/chunking-form/samples/manual-chunks/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'manual chunks support', options: { input: ['main.js'], @@ -9,4 +9,4 @@ module.exports = { } } } -}; +}); diff --git a/test/chunking-form/samples/manual-chunks/_expected/amd/generated-deps2and3.js b/test/chunking-form/samples/manual-chunks/_expected/amd/generated-deps2and3.js index 603811d8ecc..2321db64293 100644 --- a/test/chunking-form/samples/manual-chunks/_expected/amd/generated-deps2and3.js +++ b/test/chunking-form/samples/manual-chunks/_expected/amd/generated-deps2and3.js @@ -1,4 +1,4 @@ -define(['exports', './generated-lib1'], function (exports, lib1) { 'use strict'; +define(['exports', './generated-lib1'], (function (exports, lib1) { 'use strict'; function fn$2 () { console.log('lib2 fn'); @@ -17,4 +17,4 @@ define(['exports', './generated-lib1'], function (exports, lib1) { 'use strict'; exports.fn = fn$1; exports.fn$1 = fn; -}); +})); diff --git a/test/chunking-form/samples/manual-chunks/_expected/amd/generated-lib1.js b/test/chunking-form/samples/manual-chunks/_expected/amd/generated-lib1.js index 8ee6361f5e4..6d846653cf3 100644 --- a/test/chunking-form/samples/manual-chunks/_expected/amd/generated-lib1.js +++ b/test/chunking-form/samples/manual-chunks/_expected/amd/generated-lib1.js @@ -1,4 +1,4 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; function fn () { console.log('lib1 fn'); @@ -6,4 +6,4 @@ define(['exports'], function (exports) { 'use strict'; exports.fn = fn; -}); +})); diff --git a/test/chunking-form/samples/manual-chunks/_expected/amd/main.js b/test/chunking-form/samples/manual-chunks/_expected/amd/main.js index e636d3d3dd1..89925cb1116 100644 --- a/test/chunking-form/samples/manual-chunks/_expected/amd/main.js +++ b/test/chunking-form/samples/manual-chunks/_expected/amd/main.js @@ -1,4 +1,4 @@ -define(['./generated-deps2and3', './generated-lib1'], function (deps2and3, lib1) { 'use strict'; +define(['./generated-deps2and3', './generated-lib1'], (function (deps2and3, lib1) { 'use strict'; function fn () { console.log('dep1 fn'); @@ -14,4 +14,4 @@ define(['./generated-deps2and3', './generated-lib1'], function (deps2and3, lib1) return Main; -}); +})); diff --git a/test/chunking-form/samples/manual-chunks/_expected/es/main.js b/test/chunking-form/samples/manual-chunks/_expected/es/main.js index 55591e37b6a..6982299f90d 100644 --- a/test/chunking-form/samples/manual-chunks/_expected/es/main.js +++ b/test/chunking-form/samples/manual-chunks/_expected/es/main.js @@ -13,4 +13,4 @@ class Main { } } -export default Main; +export { Main as default }; diff --git a/test/chunking-form/samples/manual-chunks/_expected/system/generated-deps2and3.js b/test/chunking-form/samples/manual-chunks/_expected/system/generated-deps2and3.js index f76d52e19be..a0867bcd984 100644 --- a/test/chunking-form/samples/manual-chunks/_expected/system/generated-deps2and3.js +++ b/test/chunking-form/samples/manual-chunks/_expected/system/generated-deps2and3.js @@ -1,11 +1,11 @@ -System.register(['./generated-lib1.js'], function (exports) { +System.register(['./generated-lib1.js'], (function (exports) { 'use strict'; var fn$3; return { setters: [function (module) { fn$3 = module.f; }], - execute: function () { + execute: (function () { exports({ a: fn, @@ -26,6 +26,6 @@ System.register(['./generated-lib1.js'], function (exports) { console.log('dep3 fn'); } - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/manual-chunks/_expected/system/generated-lib1.js b/test/chunking-form/samples/manual-chunks/_expected/system/generated-lib1.js index 46e60ceba06..e740d158df6 100644 --- a/test/chunking-form/samples/manual-chunks/_expected/system/generated-lib1.js +++ b/test/chunking-form/samples/manual-chunks/_expected/system/generated-lib1.js @@ -1,14 +1,14 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - exports('f', fn); + exports("f", fn); function fn () { console.log('lib1 fn'); } - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/manual-chunks/_expected/system/main.js b/test/chunking-form/samples/manual-chunks/_expected/system/main.js index b9ce4867e2b..fe98d70f88b 100644 --- a/test/chunking-form/samples/manual-chunks/_expected/system/main.js +++ b/test/chunking-form/samples/manual-chunks/_expected/system/main.js @@ -1,12 +1,12 @@ -System.register(['./generated-deps2and3.js', './generated-lib1.js'], function (exports) { +System.register(['./generated-deps2and3.js', './generated-lib1.js'], (function (exports) { 'use strict'; var fn$1, fn$2; return { setters: [function (module) { fn$1 = module.f; fn$2 = module.a; - }, function () {}], - execute: function () { + }, null], + execute: (function () { function fn () { console.log('dep1 fn'); @@ -18,8 +18,8 @@ System.register(['./generated-deps2and3.js', './generated-lib1.js'], function (e fn$1(); fn$2(); } - } exports('default', Main); + } exports("default", Main); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/max-parallel-file-operations/1.js b/test/chunking-form/samples/max-parallel-file-operations/1.js new file mode 100644 index 00000000000..877dd1fbb70 --- /dev/null +++ b/test/chunking-form/samples/max-parallel-file-operations/1.js @@ -0,0 +1 @@ +export const x1 = 1; diff --git a/test/chunking-form/samples/max-parallel-file-operations/2.js b/test/chunking-form/samples/max-parallel-file-operations/2.js new file mode 100644 index 00000000000..c269ae0d246 --- /dev/null +++ b/test/chunking-form/samples/max-parallel-file-operations/2.js @@ -0,0 +1 @@ +export const x2 = 2; diff --git a/test/chunking-form/samples/max-parallel-file-operations/3.js b/test/chunking-form/samples/max-parallel-file-operations/3.js new file mode 100644 index 00000000000..1c323539956 --- /dev/null +++ b/test/chunking-form/samples/max-parallel-file-operations/3.js @@ -0,0 +1 @@ +export const x3 = 3; diff --git a/test/chunking-form/samples/max-parallel-file-operations/4.js b/test/chunking-form/samples/max-parallel-file-operations/4.js new file mode 100644 index 00000000000..1b01b419ace --- /dev/null +++ b/test/chunking-form/samples/max-parallel-file-operations/4.js @@ -0,0 +1 @@ +export const x4 = 4; diff --git a/test/chunking-form/samples/max-parallel-file-operations/5.js b/test/chunking-form/samples/max-parallel-file-operations/5.js new file mode 100644 index 00000000000..734bf3f6f04 --- /dev/null +++ b/test/chunking-form/samples/max-parallel-file-operations/5.js @@ -0,0 +1 @@ +export const x5 = 5; diff --git a/test/chunking-form/samples/max-parallel-file-operations/_config.js b/test/chunking-form/samples/max-parallel-file-operations/_config.js new file mode 100644 index 00000000000..f2cc3f55711 --- /dev/null +++ b/test/chunking-form/samples/max-parallel-file-operations/_config.js @@ -0,0 +1,29 @@ +const assert = require('node:assert'); +const { promises: fs } = require('node:fs'); +const { wait } = require('../../../testHelpers'); + +const fsWriteFile = fs.writeFile; +let currentWrites = 0; +let maxWrites = 0; + +module.exports = defineTest({ + description: 'maxParallelFileOps limits write operations', + options: { + maxParallelFileOps: 3, + output: { preserveModules: true }, + fs + }, + before() { + fs.writeFile = async (path, content) => { + currentWrites++; + maxWrites = Math.max(maxWrites, currentWrites); + await fsWriteFile(path, content); + await wait(50); + currentWrites--; + }; + }, + after() { + fs.writeFile = fsWriteFile; + assert.strictEqual(maxWrites, 3, 'Wrong number of parallel file writes: ' + maxWrites); + } +}); diff --git a/test/chunking-form/samples/max-parallel-file-operations/_expected/amd/1.js b/test/chunking-form/samples/max-parallel-file-operations/_expected/amd/1.js new file mode 100644 index 00000000000..d17df8438e0 --- /dev/null +++ b/test/chunking-form/samples/max-parallel-file-operations/_expected/amd/1.js @@ -0,0 +1,7 @@ +define(['exports'], (function (exports) { 'use strict'; + + const x1 = 1; + + exports.x1 = x1; + +})); diff --git a/test/chunking-form/samples/max-parallel-file-operations/_expected/amd/2.js b/test/chunking-form/samples/max-parallel-file-operations/_expected/amd/2.js new file mode 100644 index 00000000000..12aef8ef5da --- /dev/null +++ b/test/chunking-form/samples/max-parallel-file-operations/_expected/amd/2.js @@ -0,0 +1,7 @@ +define(['exports'], (function (exports) { 'use strict'; + + const x2 = 2; + + exports.x2 = x2; + +})); diff --git a/test/chunking-form/samples/max-parallel-file-operations/_expected/amd/3.js b/test/chunking-form/samples/max-parallel-file-operations/_expected/amd/3.js new file mode 100644 index 00000000000..79e3ea0bf2a --- /dev/null +++ b/test/chunking-form/samples/max-parallel-file-operations/_expected/amd/3.js @@ -0,0 +1,7 @@ +define(['exports'], (function (exports) { 'use strict'; + + const x3 = 3; + + exports.x3 = x3; + +})); diff --git a/test/chunking-form/samples/max-parallel-file-operations/_expected/amd/4.js b/test/chunking-form/samples/max-parallel-file-operations/_expected/amd/4.js new file mode 100644 index 00000000000..d81dcbbc35a --- /dev/null +++ b/test/chunking-form/samples/max-parallel-file-operations/_expected/amd/4.js @@ -0,0 +1,7 @@ +define(['exports'], (function (exports) { 'use strict'; + + const x4 = 4; + + exports.x4 = x4; + +})); diff --git a/test/chunking-form/samples/max-parallel-file-operations/_expected/amd/5.js b/test/chunking-form/samples/max-parallel-file-operations/_expected/amd/5.js new file mode 100644 index 00000000000..5578006da1f --- /dev/null +++ b/test/chunking-form/samples/max-parallel-file-operations/_expected/amd/5.js @@ -0,0 +1,7 @@ +define(['exports'], (function (exports) { 'use strict'; + + const x5 = 5; + + exports.x5 = x5; + +})); diff --git a/test/chunking-form/samples/max-parallel-file-operations/_expected/amd/main.js b/test/chunking-form/samples/max-parallel-file-operations/_expected/amd/main.js new file mode 100644 index 00000000000..958c6a79b82 --- /dev/null +++ b/test/chunking-form/samples/max-parallel-file-operations/_expected/amd/main.js @@ -0,0 +1,11 @@ +define(['exports', './1', './2', './3', './4', './5'], (function (exports, _1, _2, _3, _4, _5) { 'use strict'; + + + + exports.x1 = _1.x1; + exports.x2 = _2.x2; + exports.x3 = _3.x3; + exports.x4 = _4.x4; + exports.x5 = _5.x5; + +})); diff --git a/test/chunking-form/samples/max-parallel-file-operations/_expected/cjs/1.js b/test/chunking-form/samples/max-parallel-file-operations/_expected/cjs/1.js new file mode 100644 index 00000000000..5e709389809 --- /dev/null +++ b/test/chunking-form/samples/max-parallel-file-operations/_expected/cjs/1.js @@ -0,0 +1,5 @@ +'use strict'; + +const x1 = 1; + +exports.x1 = x1; diff --git a/test/chunking-form/samples/max-parallel-file-operations/_expected/cjs/2.js b/test/chunking-form/samples/max-parallel-file-operations/_expected/cjs/2.js new file mode 100644 index 00000000000..0bff1b9044e --- /dev/null +++ b/test/chunking-form/samples/max-parallel-file-operations/_expected/cjs/2.js @@ -0,0 +1,5 @@ +'use strict'; + +const x2 = 2; + +exports.x2 = x2; diff --git a/test/chunking-form/samples/max-parallel-file-operations/_expected/cjs/3.js b/test/chunking-form/samples/max-parallel-file-operations/_expected/cjs/3.js new file mode 100644 index 00000000000..cc7401957bb --- /dev/null +++ b/test/chunking-form/samples/max-parallel-file-operations/_expected/cjs/3.js @@ -0,0 +1,5 @@ +'use strict'; + +const x3 = 3; + +exports.x3 = x3; diff --git a/test/chunking-form/samples/max-parallel-file-operations/_expected/cjs/4.js b/test/chunking-form/samples/max-parallel-file-operations/_expected/cjs/4.js new file mode 100644 index 00000000000..b0a26d49675 --- /dev/null +++ b/test/chunking-form/samples/max-parallel-file-operations/_expected/cjs/4.js @@ -0,0 +1,5 @@ +'use strict'; + +const x4 = 4; + +exports.x4 = x4; diff --git a/test/chunking-form/samples/max-parallel-file-operations/_expected/cjs/5.js b/test/chunking-form/samples/max-parallel-file-operations/_expected/cjs/5.js new file mode 100644 index 00000000000..b2a5c8b24ea --- /dev/null +++ b/test/chunking-form/samples/max-parallel-file-operations/_expected/cjs/5.js @@ -0,0 +1,5 @@ +'use strict'; + +const x5 = 5; + +exports.x5 = x5; diff --git a/test/chunking-form/samples/max-parallel-file-operations/_expected/cjs/main.js b/test/chunking-form/samples/max-parallel-file-operations/_expected/cjs/main.js new file mode 100644 index 00000000000..f3acc7bcdbf --- /dev/null +++ b/test/chunking-form/samples/max-parallel-file-operations/_expected/cjs/main.js @@ -0,0 +1,15 @@ +'use strict'; + +var _1 = require('./1.js'); +var _2 = require('./2.js'); +var _3 = require('./3.js'); +var _4 = require('./4.js'); +var _5 = require('./5.js'); + + + +exports.x1 = _1.x1; +exports.x2 = _2.x2; +exports.x3 = _3.x3; +exports.x4 = _4.x4; +exports.x5 = _5.x5; diff --git a/test/chunking-form/samples/max-parallel-file-operations/_expected/es/1.js b/test/chunking-form/samples/max-parallel-file-operations/_expected/es/1.js new file mode 100644 index 00000000000..12510eaeff9 --- /dev/null +++ b/test/chunking-form/samples/max-parallel-file-operations/_expected/es/1.js @@ -0,0 +1,3 @@ +const x1 = 1; + +export { x1 }; diff --git a/test/chunking-form/samples/max-parallel-file-operations/_expected/es/2.js b/test/chunking-form/samples/max-parallel-file-operations/_expected/es/2.js new file mode 100644 index 00000000000..07506bd43c2 --- /dev/null +++ b/test/chunking-form/samples/max-parallel-file-operations/_expected/es/2.js @@ -0,0 +1,3 @@ +const x2 = 2; + +export { x2 }; diff --git a/test/chunking-form/samples/max-parallel-file-operations/_expected/es/3.js b/test/chunking-form/samples/max-parallel-file-operations/_expected/es/3.js new file mode 100644 index 00000000000..b8d139147c2 --- /dev/null +++ b/test/chunking-form/samples/max-parallel-file-operations/_expected/es/3.js @@ -0,0 +1,3 @@ +const x3 = 3; + +export { x3 }; diff --git a/test/chunking-form/samples/max-parallel-file-operations/_expected/es/4.js b/test/chunking-form/samples/max-parallel-file-operations/_expected/es/4.js new file mode 100644 index 00000000000..a5ad0e2c3ab --- /dev/null +++ b/test/chunking-form/samples/max-parallel-file-operations/_expected/es/4.js @@ -0,0 +1,3 @@ +const x4 = 4; + +export { x4 }; diff --git a/test/chunking-form/samples/max-parallel-file-operations/_expected/es/5.js b/test/chunking-form/samples/max-parallel-file-operations/_expected/es/5.js new file mode 100644 index 00000000000..7d8ab15e38a --- /dev/null +++ b/test/chunking-form/samples/max-parallel-file-operations/_expected/es/5.js @@ -0,0 +1,3 @@ +const x5 = 5; + +export { x5 }; diff --git a/test/chunking-form/samples/max-parallel-file-operations/_expected/es/main.js b/test/chunking-form/samples/max-parallel-file-operations/_expected/es/main.js new file mode 100644 index 00000000000..f09011e5458 --- /dev/null +++ b/test/chunking-form/samples/max-parallel-file-operations/_expected/es/main.js @@ -0,0 +1,5 @@ +export { x1 } from './1.js'; +export { x2 } from './2.js'; +export { x3 } from './3.js'; +export { x4 } from './4.js'; +export { x5 } from './5.js'; diff --git a/test/chunking-form/samples/max-parallel-file-operations/_expected/system/1.js b/test/chunking-form/samples/max-parallel-file-operations/_expected/system/1.js new file mode 100644 index 00000000000..518e6de98fc --- /dev/null +++ b/test/chunking-form/samples/max-parallel-file-operations/_expected/system/1.js @@ -0,0 +1,10 @@ +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + + const x1 = exports("x1", 1); + + }) + }; +})); diff --git a/test/chunking-form/samples/max-parallel-file-operations/_expected/system/2.js b/test/chunking-form/samples/max-parallel-file-operations/_expected/system/2.js new file mode 100644 index 00000000000..c7dccffc04b --- /dev/null +++ b/test/chunking-form/samples/max-parallel-file-operations/_expected/system/2.js @@ -0,0 +1,10 @@ +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + + const x2 = exports("x2", 2); + + }) + }; +})); diff --git a/test/chunking-form/samples/max-parallel-file-operations/_expected/system/3.js b/test/chunking-form/samples/max-parallel-file-operations/_expected/system/3.js new file mode 100644 index 00000000000..595107c5901 --- /dev/null +++ b/test/chunking-form/samples/max-parallel-file-operations/_expected/system/3.js @@ -0,0 +1,10 @@ +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + + const x3 = exports("x3", 3); + + }) + }; +})); diff --git a/test/chunking-form/samples/max-parallel-file-operations/_expected/system/4.js b/test/chunking-form/samples/max-parallel-file-operations/_expected/system/4.js new file mode 100644 index 00000000000..1ca4467a2f9 --- /dev/null +++ b/test/chunking-form/samples/max-parallel-file-operations/_expected/system/4.js @@ -0,0 +1,10 @@ +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + + const x4 = exports("x4", 4); + + }) + }; +})); diff --git a/test/chunking-form/samples/max-parallel-file-operations/_expected/system/5.js b/test/chunking-form/samples/max-parallel-file-operations/_expected/system/5.js new file mode 100644 index 00000000000..9a9e6d6def5 --- /dev/null +++ b/test/chunking-form/samples/max-parallel-file-operations/_expected/system/5.js @@ -0,0 +1,10 @@ +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + + const x5 = exports("x5", 5); + + }) + }; +})); diff --git a/test/chunking-form/samples/max-parallel-file-operations/_expected/system/main.js b/test/chunking-form/samples/max-parallel-file-operations/_expected/system/main.js new file mode 100644 index 00000000000..9fc1578222c --- /dev/null +++ b/test/chunking-form/samples/max-parallel-file-operations/_expected/system/main.js @@ -0,0 +1,21 @@ +System.register(['./1.js', './2.js', './3.js', './4.js', './5.js'], (function (exports) { + 'use strict'; + return { + setters: [function (module) { + exports("x1", module.x1); + }, function (module) { + exports("x2", module.x2); + }, function (module) { + exports("x3", module.x3); + }, function (module) { + exports("x4", module.x4); + }, function (module) { + exports("x5", module.x5); + }], + execute: (function () { + + + + }) + }; +})); diff --git a/test/chunking-form/samples/max-parallel-file-operations/main.js b/test/chunking-form/samples/max-parallel-file-operations/main.js new file mode 100644 index 00000000000..5f0a705e464 --- /dev/null +++ b/test/chunking-form/samples/max-parallel-file-operations/main.js @@ -0,0 +1,5 @@ +export * from './1'; +export * from './2'; +export * from './3'; +export * from './4'; +export * from './5'; diff --git a/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies/_config.js b/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies/_config.js new file mode 100644 index 00000000000..801623fc162 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies/_config.js @@ -0,0 +1,9 @@ +module.exports = defineTest({ + description: 'avoids circular dependencies when merging chunks', + options: { + input: ['main1.js', 'main2.js', 'main3.js'], + output: { + experimentalMinChunkSize: 100 + } + } +}); diff --git a/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies/_expected/amd/generated-main1.js b/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies/_expected/amd/generated-main1.js new file mode 100644 index 00000000000..9ea2ba09a08 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies/_expected/amd/generated-main1.js @@ -0,0 +1,11 @@ +define(['exports', './generated-small'], (function (exports, small) { 'use strict'; + + const result = small.small + '0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789'; + console.log(result); + + const generated = 'generated' + result; + + exports.generated = generated; + exports.result = result; + +})); diff --git a/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies/_expected/amd/generated-small.js b/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies/_expected/amd/generated-small.js new file mode 100644 index 00000000000..ee89ef5bdf5 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies/_expected/amd/generated-small.js @@ -0,0 +1,7 @@ +define(['exports'], (function (exports) { 'use strict'; + + const small = '1'; + + exports.small = small; + +})); diff --git a/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies/_expected/amd/main1.js b/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies/_expected/amd/main1.js new file mode 100644 index 00000000000..afd7520ad1f --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies/_expected/amd/main1.js @@ -0,0 +1,7 @@ +define(['exports', './generated-main1', './generated-small'], (function (exports, main1, small) { 'use strict'; + + + + exports.generated = main1.generated; + +})); diff --git a/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies/_expected/amd/main2.js b/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies/_expected/amd/main2.js new file mode 100644 index 00000000000..e115cfe6d16 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies/_expected/amd/main2.js @@ -0,0 +1,5 @@ +define(['./generated-main1', './generated-small'], (function (main1, small) { 'use strict'; + + console.log(main1.result); + +})); diff --git a/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies/_expected/amd/main3.js b/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies/_expected/amd/main3.js new file mode 100644 index 00000000000..87b6a754d97 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies/_expected/amd/main3.js @@ -0,0 +1,5 @@ +define(['./generated-small'], (function (small) { 'use strict'; + + console.log(small.small); + +})); diff --git a/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies/_expected/cjs/generated-main1.js b/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies/_expected/cjs/generated-main1.js new file mode 100644 index 00000000000..360c4b247f7 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies/_expected/cjs/generated-main1.js @@ -0,0 +1,11 @@ +'use strict'; + +var small = require('./generated-small.js'); + +const result = small.small + '0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789'; +console.log(result); + +const generated = 'generated' + result; + +exports.generated = generated; +exports.result = result; diff --git a/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies/_expected/cjs/generated-small.js b/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies/_expected/cjs/generated-small.js new file mode 100644 index 00000000000..c7bcc6a74b7 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies/_expected/cjs/generated-small.js @@ -0,0 +1,5 @@ +'use strict'; + +const small = '1'; + +exports.small = small; diff --git a/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies/_expected/cjs/main1.js b/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies/_expected/cjs/main1.js new file mode 100644 index 00000000000..72ce95d1746 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies/_expected/cjs/main1.js @@ -0,0 +1,8 @@ +'use strict'; + +var main1 = require('./generated-main1.js'); +require('./generated-small.js'); + + + +exports.generated = main1.generated; diff --git a/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies/_expected/cjs/main2.js b/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies/_expected/cjs/main2.js new file mode 100644 index 00000000000..3f2f5fef72a --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies/_expected/cjs/main2.js @@ -0,0 +1,6 @@ +'use strict'; + +var main1 = require('./generated-main1.js'); +require('./generated-small.js'); + +console.log(main1.result); diff --git a/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies/_expected/cjs/main3.js b/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies/_expected/cjs/main3.js new file mode 100644 index 00000000000..e9f5c811d62 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies/_expected/cjs/main3.js @@ -0,0 +1,5 @@ +'use strict'; + +var small = require('./generated-small.js'); + +console.log(small.small); diff --git a/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies/_expected/es/generated-main1.js b/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies/_expected/es/generated-main1.js new file mode 100644 index 00000000000..a63b577e8b6 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies/_expected/es/generated-main1.js @@ -0,0 +1,8 @@ +import { s as small } from './generated-small.js'; + +const result = small + '0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789'; +console.log(result); + +const generated = 'generated' + result; + +export { generated as g, result as r }; diff --git a/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies/_expected/es/generated-small.js b/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies/_expected/es/generated-small.js new file mode 100644 index 00000000000..7b56a806f80 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies/_expected/es/generated-small.js @@ -0,0 +1,3 @@ +const small = '1'; + +export { small as s }; diff --git a/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies/_expected/es/main1.js b/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies/_expected/es/main1.js new file mode 100644 index 00000000000..a344e995ca1 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies/_expected/es/main1.js @@ -0,0 +1,2 @@ +export { g as generated } from './generated-main1.js'; +import './generated-small.js'; diff --git a/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies/_expected/es/main2.js b/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies/_expected/es/main2.js new file mode 100644 index 00000000000..bd0359ebf59 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies/_expected/es/main2.js @@ -0,0 +1,4 @@ +import { r as result } from './generated-main1.js'; +import './generated-small.js'; + +console.log(result); diff --git a/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies/_expected/es/main3.js b/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies/_expected/es/main3.js new file mode 100644 index 00000000000..3f8fefa28aa --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies/_expected/es/main3.js @@ -0,0 +1,3 @@ +import { s as small } from './generated-small.js'; + +console.log(small); diff --git a/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies/_expected/system/generated-main1.js b/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies/_expected/system/generated-main1.js new file mode 100644 index 00000000000..03d1c8b3f84 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies/_expected/system/generated-main1.js @@ -0,0 +1,17 @@ +System.register(['./generated-small.js'], (function (exports) { + 'use strict'; + var small; + return { + setters: [function (module) { + small = module.s; + }], + execute: (function () { + + const result = exports("r", small + '0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789'); + console.log(result); + + const generated = exports("g", 'generated' + result); + + }) + }; +})); diff --git a/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies/_expected/system/generated-small.js b/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies/_expected/system/generated-small.js new file mode 100644 index 00000000000..b8f4c6b63ef --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies/_expected/system/generated-small.js @@ -0,0 +1,10 @@ +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + + const small = exports("s", '1'); + + }) + }; +})); diff --git a/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies/_expected/system/main1.js b/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies/_expected/system/main1.js new file mode 100644 index 00000000000..1e49e98b041 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies/_expected/system/main1.js @@ -0,0 +1,13 @@ +System.register(['./generated-main1.js', './generated-small.js'], (function (exports) { + 'use strict'; + return { + setters: [function (module) { + exports("generated", module.g); + }, null], + execute: (function () { + + + + }) + }; +})); diff --git a/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies/_expected/system/main2.js b/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies/_expected/system/main2.js new file mode 100644 index 00000000000..1d1f2c5805d --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies/_expected/system/main2.js @@ -0,0 +1,14 @@ +System.register(['./generated-main1.js', './generated-small.js'], (function () { + 'use strict'; + var result; + return { + setters: [function (module) { + result = module.r; + }, null], + execute: (function () { + + console.log(result); + + }) + }; +})); diff --git a/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies/_expected/system/main3.js b/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies/_expected/system/main3.js new file mode 100644 index 00000000000..6e93391fab8 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies/_expected/system/main3.js @@ -0,0 +1,14 @@ +System.register(['./generated-small.js'], (function () { + 'use strict'; + var small; + return { + setters: [function (module) { + small = module.s; + }], + execute: (function () { + + console.log(small); + + }) + }; +})); diff --git a/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies/main1.js b/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies/main1.js new file mode 100644 index 00000000000..2a2fee9a294 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies/main1.js @@ -0,0 +1,2 @@ +import { result } from './side-effect'; +export const generated = 'generated' + result; diff --git a/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies/main2.js b/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies/main2.js new file mode 100644 index 00000000000..db149930ab0 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies/main2.js @@ -0,0 +1,3 @@ +import { result } from './side-effect'; + +console.log(result); diff --git a/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies/main3.js b/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies/main3.js new file mode 100644 index 00000000000..445919e6d15 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies/main3.js @@ -0,0 +1,3 @@ +import { small } from './small'; + +console.log(small); diff --git a/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies/side-effect.js b/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies/side-effect.js new file mode 100644 index 00000000000..5debd1231bc --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies/side-effect.js @@ -0,0 +1,3 @@ +import { small } from './small'; +export const result = small + '0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789'; +console.log(result); diff --git a/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies/small.js b/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies/small.js new file mode 100644 index 00000000000..64e15634102 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies/small.js @@ -0,0 +1 @@ +export const small = '1'; diff --git a/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies2/_config.js b/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies2/_config.js new file mode 100644 index 00000000000..801623fc162 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies2/_config.js @@ -0,0 +1,9 @@ +module.exports = defineTest({ + description: 'avoids circular dependencies when merging chunks', + options: { + input: ['main1.js', 'main2.js', 'main3.js'], + output: { + experimentalMinChunkSize: 100 + } + } +}); diff --git a/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies2/_expected/amd/main1.js b/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies2/_expected/amd/main1.js new file mode 100644 index 00000000000..2148994ec8b --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies2/_expected/amd/main1.js @@ -0,0 +1,19 @@ +define(['exports'], (function (exports) { 'use strict'; + + const second = 1; + + const shared = second + 'shared'; + + const main1 = 1; + + const main2 = 2; + + const main3 = 3; + + exports.main1 = main1; + exports.main2 = main2; + exports.main3 = main3; + exports.second = second; + exports.shared = shared; + +})); diff --git a/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies2/_expected/amd/main2.js b/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies2/_expected/amd/main2.js new file mode 100644 index 00000000000..3c5be2bd22c --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies2/_expected/amd/main2.js @@ -0,0 +1,8 @@ +define(['exports', './main1'], (function (exports, main1) { 'use strict'; + + + + exports.main2 = main1.main2; + exports.shared = main1.shared; + +})); diff --git a/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies2/_expected/amd/main3.js b/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies2/_expected/amd/main3.js new file mode 100644 index 00000000000..f67dfc706ac --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies2/_expected/amd/main3.js @@ -0,0 +1,8 @@ +define(['exports', './main1'], (function (exports, main1) { 'use strict'; + + + + exports.main3 = main1.main3; + exports.second = main1.second; + +})); diff --git a/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies2/_expected/cjs/main1.js b/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies2/_expected/cjs/main1.js new file mode 100644 index 00000000000..e2d0f24ec93 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies2/_expected/cjs/main1.js @@ -0,0 +1,17 @@ +'use strict'; + +const second = 1; + +const shared = second + 'shared'; + +const main1 = 1; + +const main2 = 2; + +const main3 = 3; + +exports.main1 = main1; +exports.main2 = main2; +exports.main3 = main3; +exports.second = second; +exports.shared = shared; diff --git a/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies2/_expected/cjs/main2.js b/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies2/_expected/cjs/main2.js new file mode 100644 index 00000000000..f305cdb4a6f --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies2/_expected/cjs/main2.js @@ -0,0 +1,8 @@ +'use strict'; + +var main1 = require('./main1.js'); + + + +exports.main2 = main1.main2; +exports.shared = main1.shared; diff --git a/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies2/_expected/cjs/main3.js b/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies2/_expected/cjs/main3.js new file mode 100644 index 00000000000..1b3614dc8d3 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies2/_expected/cjs/main3.js @@ -0,0 +1,8 @@ +'use strict'; + +var main1 = require('./main1.js'); + + + +exports.main3 = main1.main3; +exports.second = main1.second; diff --git a/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies2/_expected/es/main1.js b/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies2/_expected/es/main1.js new file mode 100644 index 00000000000..278236a96cf --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies2/_expected/es/main1.js @@ -0,0 +1,11 @@ +const second = 1; + +const shared = second + 'shared'; + +const main1 = 1; + +const main2 = 2; + +const main3 = 3; + +export { main3 as a, main2 as m, main1, second, shared }; diff --git a/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies2/_expected/es/main2.js b/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies2/_expected/es/main2.js new file mode 100644 index 00000000000..ddf5213b8b7 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies2/_expected/es/main2.js @@ -0,0 +1 @@ +export { m as main2, shared } from './main1.js'; diff --git a/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies2/_expected/es/main3.js b/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies2/_expected/es/main3.js new file mode 100644 index 00000000000..39683d36408 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies2/_expected/es/main3.js @@ -0,0 +1 @@ +export { a as main3, second } from './main1.js'; diff --git a/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies2/_expected/system/main1.js b/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies2/_expected/system/main1.js new file mode 100644 index 00000000000..f1771506c0d --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies2/_expected/system/main1.js @@ -0,0 +1,18 @@ +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + + const second = exports("second", 1); + + const shared = exports("shared", second + 'shared'); + + const main1 = exports("main1", 1); + + const main2 = exports("m", 2); + + const main3 = exports("a", 3); + + }) + }; +})); diff --git a/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies2/_expected/system/main2.js b/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies2/_expected/system/main2.js new file mode 100644 index 00000000000..2f09a9929d8 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies2/_expected/system/main2.js @@ -0,0 +1,13 @@ +System.register(['./main1.js'], (function (exports) { + 'use strict'; + return { + setters: [function (module) { + exports({ main2: module.m, shared: module.shared }); + }], + execute: (function () { + + + + }) + }; +})); diff --git a/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies2/_expected/system/main3.js b/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies2/_expected/system/main3.js new file mode 100644 index 00000000000..178a8b4b2ea --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies2/_expected/system/main3.js @@ -0,0 +1,13 @@ +System.register(['./main1.js'], (function (exports) { + 'use strict'; + return { + setters: [function (module) { + exports({ main3: module.a, second: module.second }); + }], + execute: (function () { + + + + }) + }; +})); diff --git a/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies2/main1.js b/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies2/main1.js new file mode 100644 index 00000000000..4c1436ba1d8 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies2/main1.js @@ -0,0 +1,3 @@ +export { shared } from './shared'; +export { second } from './second'; +export const main1 = 1; diff --git a/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies2/main2.js b/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies2/main2.js new file mode 100644 index 00000000000..7480a1b6abf --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies2/main2.js @@ -0,0 +1,2 @@ +export { shared } from './shared'; +export const main2 = 2; diff --git a/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies2/main3.js b/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies2/main3.js new file mode 100644 index 00000000000..f6e676e5b5d --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies2/main3.js @@ -0,0 +1,2 @@ +export { second } from './second'; +export const main3 = 3; diff --git a/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies2/second.js b/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies2/second.js new file mode 100644 index 00000000000..aca216a37b9 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies2/second.js @@ -0,0 +1 @@ +export const second = 1; diff --git a/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies2/shared.js b/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies2/shared.js new file mode 100644 index 00000000000..0d10caaea19 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/avoid-circular-dependencies2/shared.js @@ -0,0 +1,2 @@ +import { second } from './second'; +export const shared = second + 'shared'; diff --git a/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/_config.js b/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/_config.js new file mode 100644 index 00000000000..51c86dd250e --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/_config.js @@ -0,0 +1,9 @@ +module.exports = defineTest({ + description: 'does not merge chunks if a dependency would introduce a new side effect', + options: { + input: ['main1.js', 'main2.js', 'main3.js', 'main4.js'], + output: { + experimentalMinChunkSize: 100 + } + } +}); diff --git a/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/_expected/amd/generated-chunk.js b/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/_expected/amd/generated-chunk.js new file mode 100644 index 00000000000..806ea76e38d --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/_expected/amd/generated-chunk.js @@ -0,0 +1,8 @@ +define(['exports', './generated-effect'], (function (exports, effect) { 'use strict'; + + const big = + '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'; + + exports.big = big; + +})); diff --git a/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/_expected/amd/generated-effect.js b/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/_expected/amd/generated-effect.js new file mode 100644 index 00000000000..3913c6bd594 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/_expected/amd/generated-effect.js @@ -0,0 +1,5 @@ +define((function () { 'use strict'; + + console.log('effect 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'); + +})); diff --git a/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/_expected/amd/generated-small.js b/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/_expected/amd/generated-small.js new file mode 100644 index 00000000000..59507568055 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/_expected/amd/generated-small.js @@ -0,0 +1,7 @@ +define(['exports'], (function (exports) { 'use strict'; + + const small = '0'; + + exports.small = small; + +})); diff --git a/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/_expected/amd/main1.js b/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/_expected/amd/main1.js new file mode 100644 index 00000000000..87b6a754d97 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/_expected/amd/main1.js @@ -0,0 +1,5 @@ +define(['./generated-small'], (function (small) { 'use strict'; + + console.log(small.small); + +})); diff --git a/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/_expected/amd/main2.js b/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/_expected/amd/main2.js new file mode 100644 index 00000000000..dd21d02d99b --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/_expected/amd/main2.js @@ -0,0 +1,5 @@ +define(['./generated-chunk', './generated-effect'], (function (chunk, effect) { 'use strict'; + + console.log(chunk.big); + +})); diff --git a/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/_expected/amd/main3.js b/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/_expected/amd/main3.js new file mode 100644 index 00000000000..a247bb649bb --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/_expected/amd/main3.js @@ -0,0 +1,5 @@ +define(['./generated-effect'], (function (effect) { 'use strict'; + + console.log(); + +})); diff --git a/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/_expected/amd/main4.js b/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/_expected/amd/main4.js new file mode 100644 index 00000000000..40f93b1a7d1 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/_expected/amd/main4.js @@ -0,0 +1,5 @@ +define(['./generated-small', './generated-chunk', './generated-effect'], (function (small, chunk, effect) { 'use strict'; + + console.log(small.small, chunk.big); + +})); diff --git a/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/_expected/cjs/generated-chunk.js b/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/_expected/cjs/generated-chunk.js new file mode 100644 index 00000000000..ff74cf0517a --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/_expected/cjs/generated-chunk.js @@ -0,0 +1,8 @@ +'use strict'; + +require('./generated-effect.js'); + +const big = + '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'; + +exports.big = big; diff --git a/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/_expected/cjs/generated-effect.js b/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/_expected/cjs/generated-effect.js new file mode 100644 index 00000000000..bc25944b1d4 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/_expected/cjs/generated-effect.js @@ -0,0 +1,3 @@ +'use strict'; + +console.log('effect 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'); diff --git a/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/_expected/cjs/generated-small.js b/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/_expected/cjs/generated-small.js new file mode 100644 index 00000000000..c72613c4229 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/_expected/cjs/generated-small.js @@ -0,0 +1,5 @@ +'use strict'; + +const small = '0'; + +exports.small = small; diff --git a/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/_expected/cjs/main1.js b/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/_expected/cjs/main1.js new file mode 100644 index 00000000000..e9f5c811d62 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/_expected/cjs/main1.js @@ -0,0 +1,5 @@ +'use strict'; + +var small = require('./generated-small.js'); + +console.log(small.small); diff --git a/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/_expected/cjs/main2.js b/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/_expected/cjs/main2.js new file mode 100644 index 00000000000..f382afa6e55 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/_expected/cjs/main2.js @@ -0,0 +1,6 @@ +'use strict'; + +var chunk = require('./generated-chunk.js'); +require('./generated-effect.js'); + +console.log(chunk.big); diff --git a/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/_expected/cjs/main3.js b/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/_expected/cjs/main3.js new file mode 100644 index 00000000000..4ef9083aba8 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/_expected/cjs/main3.js @@ -0,0 +1,5 @@ +'use strict'; + +require('./generated-effect.js'); + +console.log(); diff --git a/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/_expected/cjs/main4.js b/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/_expected/cjs/main4.js new file mode 100644 index 00000000000..a559c4e25b2 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/_expected/cjs/main4.js @@ -0,0 +1,7 @@ +'use strict'; + +var small = require('./generated-small.js'); +var chunk = require('./generated-chunk.js'); +require('./generated-effect.js'); + +console.log(small.small, chunk.big); diff --git a/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/_expected/es/generated-chunk.js b/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/_expected/es/generated-chunk.js new file mode 100644 index 00000000000..fd5a50c0dfd --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/_expected/es/generated-chunk.js @@ -0,0 +1,6 @@ +import './generated-effect.js'; + +const big = + '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'; + +export { big as b }; diff --git a/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/_expected/es/generated-effect.js b/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/_expected/es/generated-effect.js new file mode 100644 index 00000000000..419200c2133 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/_expected/es/generated-effect.js @@ -0,0 +1 @@ +console.log('effect 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'); diff --git a/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/_expected/es/generated-small.js b/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/_expected/es/generated-small.js new file mode 100644 index 00000000000..0b35eebd22a --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/_expected/es/generated-small.js @@ -0,0 +1,3 @@ +const small = '0'; + +export { small as s }; diff --git a/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/_expected/es/main1.js b/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/_expected/es/main1.js new file mode 100644 index 00000000000..3f8fefa28aa --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/_expected/es/main1.js @@ -0,0 +1,3 @@ +import { s as small } from './generated-small.js'; + +console.log(small); diff --git a/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/_expected/es/main2.js b/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/_expected/es/main2.js new file mode 100644 index 00000000000..8747b2a4529 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/_expected/es/main2.js @@ -0,0 +1,4 @@ +import { b as big } from './generated-chunk.js'; +import './generated-effect.js'; + +console.log(big); diff --git a/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/_expected/es/main3.js b/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/_expected/es/main3.js new file mode 100644 index 00000000000..4d870c2fbd0 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/_expected/es/main3.js @@ -0,0 +1,3 @@ +import './generated-effect.js'; + +console.log(); diff --git a/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/_expected/es/main4.js b/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/_expected/es/main4.js new file mode 100644 index 00000000000..3cd8b45ab14 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/_expected/es/main4.js @@ -0,0 +1,5 @@ +import { s as small } from './generated-small.js'; +import { b as big } from './generated-chunk.js'; +import './generated-effect.js'; + +console.log(small, big); diff --git a/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/_expected/system/generated-chunk.js b/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/_expected/system/generated-chunk.js new file mode 100644 index 00000000000..f778c0b3911 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/_expected/system/generated-chunk.js @@ -0,0 +1,12 @@ +System.register(['./generated-effect.js'], (function (exports) { + 'use strict'; + return { + setters: [null], + execute: (function () { + + const big = + exports("b", '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'); + + }) + }; +})); diff --git a/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/_expected/system/generated-effect.js b/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/_expected/system/generated-effect.js new file mode 100644 index 00000000000..dd75e356285 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/_expected/system/generated-effect.js @@ -0,0 +1,10 @@ +System.register([], (function () { + 'use strict'; + return { + execute: (function () { + + console.log('effect 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'); + + }) + }; +})); diff --git a/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/_expected/system/generated-small.js b/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/_expected/system/generated-small.js new file mode 100644 index 00000000000..47d00c02115 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/_expected/system/generated-small.js @@ -0,0 +1,10 @@ +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + + const small = exports("s", '0'); + + }) + }; +})); diff --git a/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/_expected/system/main1.js b/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/_expected/system/main1.js new file mode 100644 index 00000000000..6e93391fab8 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/_expected/system/main1.js @@ -0,0 +1,14 @@ +System.register(['./generated-small.js'], (function () { + 'use strict'; + var small; + return { + setters: [function (module) { + small = module.s; + }], + execute: (function () { + + console.log(small); + + }) + }; +})); diff --git a/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/_expected/system/main2.js b/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/_expected/system/main2.js new file mode 100644 index 00000000000..aeeaa3b8473 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/_expected/system/main2.js @@ -0,0 +1,14 @@ +System.register(['./generated-chunk.js', './generated-effect.js'], (function () { + 'use strict'; + var big; + return { + setters: [function (module) { + big = module.b; + }, null], + execute: (function () { + + console.log(big); + + }) + }; +})); diff --git a/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/_expected/system/main3.js b/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/_expected/system/main3.js new file mode 100644 index 00000000000..711e5f70c7e --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/_expected/system/main3.js @@ -0,0 +1,11 @@ +System.register(['./generated-effect.js'], (function () { + 'use strict'; + return { + setters: [null], + execute: (function () { + + console.log(); + + }) + }; +})); diff --git a/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/_expected/system/main4.js b/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/_expected/system/main4.js new file mode 100644 index 00000000000..f51da7fdbe0 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/_expected/system/main4.js @@ -0,0 +1,16 @@ +System.register(['./generated-small.js', './generated-chunk.js', './generated-effect.js'], (function () { + 'use strict'; + var small, big; + return { + setters: [function (module) { + small = module.s; + }, function (module) { + big = module.b; + }, null], + execute: (function () { + + console.log(small, big); + + }) + }; +})); diff --git a/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/chunk.js b/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/chunk.js new file mode 100644 index 00000000000..340a5f0d282 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/chunk.js @@ -0,0 +1,3 @@ +import './effect'; +export const big = + '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'; diff --git a/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/effect.js b/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/effect.js new file mode 100644 index 00000000000..419200c2133 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/effect.js @@ -0,0 +1 @@ +console.log('effect 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'); diff --git a/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/main1.js b/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/main1.js new file mode 100644 index 00000000000..445919e6d15 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/main1.js @@ -0,0 +1,3 @@ +import { small } from './small'; + +console.log(small); diff --git a/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/main2.js b/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/main2.js new file mode 100644 index 00000000000..8283096a8c2 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/main2.js @@ -0,0 +1,3 @@ +import { big } from './chunk'; + +console.log(big); diff --git a/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/main3.js b/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/main3.js new file mode 100644 index 00000000000..0342c37e626 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/main3.js @@ -0,0 +1,3 @@ +import './effect'; + +console.log(); diff --git a/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/main4.js b/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/main4.js new file mode 100644 index 00000000000..ae65c061caf --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/main4.js @@ -0,0 +1,5 @@ +import { small } from './small'; +import { big } from './chunk'; +import './effect'; + +console.log(small, big); diff --git a/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/small.js b/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/small.js new file mode 100644 index 00000000000..1f81fbc27dd --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/avoid-transitive-side-effects/small.js @@ -0,0 +1 @@ +export const small = '0'; diff --git a/test/chunking-form/samples/min-chunk-size/best-merge-target/_config.js b/test/chunking-form/samples/min-chunk-size/best-merge-target/_config.js new file mode 100644 index 00000000000..d18589d13f0 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/best-merge-target/_config.js @@ -0,0 +1,19 @@ +module.exports = defineTest({ + description: 'uses the merge target that is closest', + options: { + input: [ + 'main1.js', + 'main2.js', + 'main3.js', + 'main4.js', + 'main5.js', + 'main6.js', + 'main7.js', + 'main8.js', + 'main9.js' + ], + output: { + experimentalMinChunkSize: 100 + } + } +}); diff --git a/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/amd/generated-small2.js b/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/amd/generated-small2.js new file mode 100644 index 00000000000..2f2c139dfb3 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/amd/generated-small2.js @@ -0,0 +1,10 @@ +define(['exports'], (function (exports) { 'use strict'; + + const small1 = '12345678901234567890123456789012345678901234567890'; + + const small2 = '12345678901234567890123456789012345678901234567890'; + + exports.small1 = small1; + exports.small2 = small2; + +})); diff --git a/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/amd/generated-small4.js b/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/amd/generated-small4.js new file mode 100644 index 00000000000..464d28c8342 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/amd/generated-small4.js @@ -0,0 +1,10 @@ +define(['exports'], (function (exports) { 'use strict'; + + const small3 = '12345678901234567890123456789012345678901234567890'; + + const small4 = '12345678901234567890123456789012345678901234567890'; + + exports.small3 = small3; + exports.small4 = small4; + +})); diff --git a/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/amd/main1.js b/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/amd/main1.js new file mode 100644 index 00000000000..8aeed219f97 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/amd/main1.js @@ -0,0 +1,5 @@ +define(['./generated-small2', './generated-small4'], (function (small2, small4) { 'use strict'; + + console.log(small2.small1, small4.small3); + +})); diff --git a/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/amd/main2.js b/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/amd/main2.js new file mode 100644 index 00000000000..6c9f8b5b3df --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/amd/main2.js @@ -0,0 +1,5 @@ +define(['./generated-small2', './generated-small4'], (function (small2, small4) { 'use strict'; + + console.log(small2.small2, small4.small4); + +})); diff --git a/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/amd/main3.js b/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/amd/main3.js new file mode 100644 index 00000000000..5bee3857601 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/amd/main3.js @@ -0,0 +1,5 @@ +define(['./generated-small2', './generated-small4'], (function (small2, small4) { 'use strict'; + + console.log(small2.small1, small2.small2, small4.small3); + +})); diff --git a/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/amd/main4.js b/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/amd/main4.js new file mode 100644 index 00000000000..fe4c60808ad --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/amd/main4.js @@ -0,0 +1,5 @@ +define(['./generated-small2', './generated-small4'], (function (small2, small4) { 'use strict'; + + console.log(small2.small2, small4.small3, small4.small4); + +})); diff --git a/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/amd/main5.js b/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/amd/main5.js new file mode 100644 index 00000000000..d00402ce32c --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/amd/main5.js @@ -0,0 +1,5 @@ +define(['./generated-small2', './generated-small4'], (function (small2, small4) { 'use strict'; + + console.log(small2.small1, small2.small2, small4.small3, small4.small4); + +})); diff --git a/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/amd/main6.js b/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/amd/main6.js new file mode 100644 index 00000000000..933e6f8fc01 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/amd/main6.js @@ -0,0 +1,5 @@ +define(['./generated-small2'], (function (small2) { 'use strict'; + + console.log(small2.small1); + +})); diff --git a/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/amd/main7.js b/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/amd/main7.js new file mode 100644 index 00000000000..f7a8bc388f2 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/amd/main7.js @@ -0,0 +1,5 @@ +define(['./generated-small2'], (function (small2) { 'use strict'; + + console.log(small2.small2); + +})); diff --git a/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/amd/main8.js b/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/amd/main8.js new file mode 100644 index 00000000000..47005228fc4 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/amd/main8.js @@ -0,0 +1,5 @@ +define(['./generated-small4'], (function (small4) { 'use strict'; + + console.log(small4.small3); + +})); diff --git a/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/amd/main9.js b/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/amd/main9.js new file mode 100644 index 00000000000..6b8c31423f9 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/amd/main9.js @@ -0,0 +1,5 @@ +define(['./generated-small4'], (function (small4) { 'use strict'; + + console.log(small4.small4); + +})); diff --git a/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/cjs/generated-small2.js b/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/cjs/generated-small2.js new file mode 100644 index 00000000000..2de161519be --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/cjs/generated-small2.js @@ -0,0 +1,8 @@ +'use strict'; + +const small1 = '12345678901234567890123456789012345678901234567890'; + +const small2 = '12345678901234567890123456789012345678901234567890'; + +exports.small1 = small1; +exports.small2 = small2; diff --git a/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/cjs/generated-small4.js b/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/cjs/generated-small4.js new file mode 100644 index 00000000000..b921b0d1dba --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/cjs/generated-small4.js @@ -0,0 +1,8 @@ +'use strict'; + +const small3 = '12345678901234567890123456789012345678901234567890'; + +const small4 = '12345678901234567890123456789012345678901234567890'; + +exports.small3 = small3; +exports.small4 = small4; diff --git a/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/cjs/main1.js b/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/cjs/main1.js new file mode 100644 index 00000000000..63177e7591a --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/cjs/main1.js @@ -0,0 +1,6 @@ +'use strict'; + +var small2 = require('./generated-small2.js'); +var small4 = require('./generated-small4.js'); + +console.log(small2.small1, small4.small3); diff --git a/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/cjs/main2.js b/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/cjs/main2.js new file mode 100644 index 00000000000..9d6e898c9f9 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/cjs/main2.js @@ -0,0 +1,6 @@ +'use strict'; + +var small2 = require('./generated-small2.js'); +var small4 = require('./generated-small4.js'); + +console.log(small2.small2, small4.small4); diff --git a/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/cjs/main3.js b/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/cjs/main3.js new file mode 100644 index 00000000000..f7d8b5a1c19 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/cjs/main3.js @@ -0,0 +1,6 @@ +'use strict'; + +var small2 = require('./generated-small2.js'); +var small4 = require('./generated-small4.js'); + +console.log(small2.small1, small2.small2, small4.small3); diff --git a/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/cjs/main4.js b/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/cjs/main4.js new file mode 100644 index 00000000000..6f2dcaadff0 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/cjs/main4.js @@ -0,0 +1,6 @@ +'use strict'; + +var small2 = require('./generated-small2.js'); +var small4 = require('./generated-small4.js'); + +console.log(small2.small2, small4.small3, small4.small4); diff --git a/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/cjs/main5.js b/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/cjs/main5.js new file mode 100644 index 00000000000..9b3c1acfc6e --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/cjs/main5.js @@ -0,0 +1,6 @@ +'use strict'; + +var small2 = require('./generated-small2.js'); +var small4 = require('./generated-small4.js'); + +console.log(small2.small1, small2.small2, small4.small3, small4.small4); diff --git a/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/cjs/main6.js b/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/cjs/main6.js new file mode 100644 index 00000000000..680aff2ffe1 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/cjs/main6.js @@ -0,0 +1,5 @@ +'use strict'; + +var small2 = require('./generated-small2.js'); + +console.log(small2.small1); diff --git a/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/cjs/main7.js b/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/cjs/main7.js new file mode 100644 index 00000000000..cfd5e278dbd --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/cjs/main7.js @@ -0,0 +1,5 @@ +'use strict'; + +var small2 = require('./generated-small2.js'); + +console.log(small2.small2); diff --git a/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/cjs/main8.js b/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/cjs/main8.js new file mode 100644 index 00000000000..baa335b65b7 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/cjs/main8.js @@ -0,0 +1,5 @@ +'use strict'; + +var small4 = require('./generated-small4.js'); + +console.log(small4.small3); diff --git a/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/cjs/main9.js b/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/cjs/main9.js new file mode 100644 index 00000000000..ca6f97d273b --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/cjs/main9.js @@ -0,0 +1,5 @@ +'use strict'; + +var small4 = require('./generated-small4.js'); + +console.log(small4.small4); diff --git a/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/es/generated-small2.js b/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/es/generated-small2.js new file mode 100644 index 00000000000..f553b8cf7b9 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/es/generated-small2.js @@ -0,0 +1,5 @@ +const small1 = '12345678901234567890123456789012345678901234567890'; + +const small2 = '12345678901234567890123456789012345678901234567890'; + +export { small2 as a, small1 as s }; diff --git a/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/es/generated-small4.js b/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/es/generated-small4.js new file mode 100644 index 00000000000..6de396475b6 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/es/generated-small4.js @@ -0,0 +1,5 @@ +const small3 = '12345678901234567890123456789012345678901234567890'; + +const small4 = '12345678901234567890123456789012345678901234567890'; + +export { small4 as a, small3 as s }; diff --git a/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/es/main1.js b/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/es/main1.js new file mode 100644 index 00000000000..be812db83f0 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/es/main1.js @@ -0,0 +1,4 @@ +import { s as small1 } from './generated-small2.js'; +import { s as small3 } from './generated-small4.js'; + +console.log(small1, small3); diff --git a/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/es/main2.js b/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/es/main2.js new file mode 100644 index 00000000000..c7ee3b5d3b0 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/es/main2.js @@ -0,0 +1,4 @@ +import { a as small2 } from './generated-small2.js'; +import { a as small4 } from './generated-small4.js'; + +console.log(small2, small4); diff --git a/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/es/main3.js b/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/es/main3.js new file mode 100644 index 00000000000..a5de45be16e --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/es/main3.js @@ -0,0 +1,4 @@ +import { s as small1, a as small2 } from './generated-small2.js'; +import { s as small3 } from './generated-small4.js'; + +console.log(small1, small2, small3); diff --git a/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/es/main4.js b/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/es/main4.js new file mode 100644 index 00000000000..108fa0a0165 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/es/main4.js @@ -0,0 +1,4 @@ +import { a as small2 } from './generated-small2.js'; +import { s as small3, a as small4 } from './generated-small4.js'; + +console.log(small2, small3, small4); diff --git a/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/es/main5.js b/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/es/main5.js new file mode 100644 index 00000000000..1eca8b64e08 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/es/main5.js @@ -0,0 +1,4 @@ +import { s as small1, a as small2 } from './generated-small2.js'; +import { s as small3, a as small4 } from './generated-small4.js'; + +console.log(small1, small2, small3, small4); diff --git a/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/es/main6.js b/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/es/main6.js new file mode 100644 index 00000000000..e30e3ce1ca9 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/es/main6.js @@ -0,0 +1,3 @@ +import { s as small1 } from './generated-small2.js'; + +console.log(small1); diff --git a/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/es/main7.js b/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/es/main7.js new file mode 100644 index 00000000000..edc8ae8b0c0 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/es/main7.js @@ -0,0 +1,3 @@ +import { a as small2 } from './generated-small2.js'; + +console.log(small2); diff --git a/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/es/main8.js b/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/es/main8.js new file mode 100644 index 00000000000..b83d5c810f4 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/es/main8.js @@ -0,0 +1,3 @@ +import { s as small3 } from './generated-small4.js'; + +console.log(small3); diff --git a/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/es/main9.js b/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/es/main9.js new file mode 100644 index 00000000000..2d15dc3b226 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/es/main9.js @@ -0,0 +1,3 @@ +import { a as small4 } from './generated-small4.js'; + +console.log(small4); diff --git a/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/system/generated-small2.js b/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/system/generated-small2.js new file mode 100644 index 00000000000..d06fd48f6c4 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/system/generated-small2.js @@ -0,0 +1,12 @@ +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + + const small1 = exports("s", '12345678901234567890123456789012345678901234567890'); + + const small2 = exports("a", '12345678901234567890123456789012345678901234567890'); + + }) + }; +})); diff --git a/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/system/generated-small4.js b/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/system/generated-small4.js new file mode 100644 index 00000000000..59d1a76822e --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/system/generated-small4.js @@ -0,0 +1,12 @@ +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + + const small3 = exports("s", '12345678901234567890123456789012345678901234567890'); + + const small4 = exports("a", '12345678901234567890123456789012345678901234567890'); + + }) + }; +})); diff --git a/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/system/main1.js b/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/system/main1.js new file mode 100644 index 00000000000..7b539f9d37d --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/system/main1.js @@ -0,0 +1,16 @@ +System.register(['./generated-small2.js', './generated-small4.js'], (function () { + 'use strict'; + var small1, small3; + return { + setters: [function (module) { + small1 = module.s; + }, function (module) { + small3 = module.s; + }], + execute: (function () { + + console.log(small1, small3); + + }) + }; +})); diff --git a/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/system/main2.js b/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/system/main2.js new file mode 100644 index 00000000000..f3c7bf18579 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/system/main2.js @@ -0,0 +1,16 @@ +System.register(['./generated-small2.js', './generated-small4.js'], (function () { + 'use strict'; + var small2, small4; + return { + setters: [function (module) { + small2 = module.a; + }, function (module) { + small4 = module.a; + }], + execute: (function () { + + console.log(small2, small4); + + }) + }; +})); diff --git a/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/system/main3.js b/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/system/main3.js new file mode 100644 index 00000000000..fbe7a65cd87 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/system/main3.js @@ -0,0 +1,17 @@ +System.register(['./generated-small2.js', './generated-small4.js'], (function () { + 'use strict'; + var small1, small2, small3; + return { + setters: [function (module) { + small1 = module.s; + small2 = module.a; + }, function (module) { + small3 = module.s; + }], + execute: (function () { + + console.log(small1, small2, small3); + + }) + }; +})); diff --git a/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/system/main4.js b/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/system/main4.js new file mode 100644 index 00000000000..f86d6370878 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/system/main4.js @@ -0,0 +1,17 @@ +System.register(['./generated-small2.js', './generated-small4.js'], (function () { + 'use strict'; + var small2, small3, small4; + return { + setters: [function (module) { + small2 = module.a; + }, function (module) { + small3 = module.s; + small4 = module.a; + }], + execute: (function () { + + console.log(small2, small3, small4); + + }) + }; +})); diff --git a/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/system/main5.js b/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/system/main5.js new file mode 100644 index 00000000000..272bf31ad03 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/system/main5.js @@ -0,0 +1,18 @@ +System.register(['./generated-small2.js', './generated-small4.js'], (function () { + 'use strict'; + var small1, small2, small3, small4; + return { + setters: [function (module) { + small1 = module.s; + small2 = module.a; + }, function (module) { + small3 = module.s; + small4 = module.a; + }], + execute: (function () { + + console.log(small1, small2, small3, small4); + + }) + }; +})); diff --git a/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/system/main6.js b/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/system/main6.js new file mode 100644 index 00000000000..a9fde34525d --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/system/main6.js @@ -0,0 +1,14 @@ +System.register(['./generated-small2.js'], (function () { + 'use strict'; + var small1; + return { + setters: [function (module) { + small1 = module.s; + }], + execute: (function () { + + console.log(small1); + + }) + }; +})); diff --git a/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/system/main7.js b/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/system/main7.js new file mode 100644 index 00000000000..114aa710b39 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/system/main7.js @@ -0,0 +1,14 @@ +System.register(['./generated-small2.js'], (function () { + 'use strict'; + var small2; + return { + setters: [function (module) { + small2 = module.a; + }], + execute: (function () { + + console.log(small2); + + }) + }; +})); diff --git a/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/system/main8.js b/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/system/main8.js new file mode 100644 index 00000000000..3f3ffcc0261 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/system/main8.js @@ -0,0 +1,14 @@ +System.register(['./generated-small4.js'], (function () { + 'use strict'; + var small3; + return { + setters: [function (module) { + small3 = module.s; + }], + execute: (function () { + + console.log(small3); + + }) + }; +})); diff --git a/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/system/main9.js b/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/system/main9.js new file mode 100644 index 00000000000..918f32f15a3 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/best-merge-target/_expected/system/main9.js @@ -0,0 +1,14 @@ +System.register(['./generated-small4.js'], (function () { + 'use strict'; + var small4; + return { + setters: [function (module) { + small4 = module.a; + }], + execute: (function () { + + console.log(small4); + + }) + }; +})); diff --git a/test/chunking-form/samples/min-chunk-size/best-merge-target/main1.js b/test/chunking-form/samples/min-chunk-size/best-merge-target/main1.js new file mode 100644 index 00000000000..ff00ad482a2 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/best-merge-target/main1.js @@ -0,0 +1,4 @@ +import { small1 } from './small1'; +import { small3 } from './small3'; + +console.log(small1, small3); diff --git a/test/chunking-form/samples/min-chunk-size/best-merge-target/main2.js b/test/chunking-form/samples/min-chunk-size/best-merge-target/main2.js new file mode 100644 index 00000000000..b25ce08596e --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/best-merge-target/main2.js @@ -0,0 +1,4 @@ +import { small2 } from './small2'; +import { small4 } from './small4'; + +console.log(small2, small4); diff --git a/test/chunking-form/samples/min-chunk-size/best-merge-target/main3.js b/test/chunking-form/samples/min-chunk-size/best-merge-target/main3.js new file mode 100644 index 00000000000..8b799fc2a7b --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/best-merge-target/main3.js @@ -0,0 +1,5 @@ +import { small1 } from './small1'; +import { small2 } from './small2'; +import { small3 } from './small3'; + +console.log(small1, small2, small3); diff --git a/test/chunking-form/samples/min-chunk-size/best-merge-target/main4.js b/test/chunking-form/samples/min-chunk-size/best-merge-target/main4.js new file mode 100644 index 00000000000..8a49a8ebc7b --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/best-merge-target/main4.js @@ -0,0 +1,5 @@ +import { small2 } from './small2'; +import { small3 } from './small3'; +import { small4 } from './small4'; + +console.log(small2, small3, small4); diff --git a/test/chunking-form/samples/min-chunk-size/best-merge-target/main5.js b/test/chunking-form/samples/min-chunk-size/best-merge-target/main5.js new file mode 100644 index 00000000000..8f8fc42d6c6 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/best-merge-target/main5.js @@ -0,0 +1,6 @@ +import { small1 } from './small1'; +import { small2 } from './small2'; +import { small3 } from './small3'; +import { small4 } from './small4'; + +console.log(small1, small2, small3, small4); diff --git a/test/chunking-form/samples/min-chunk-size/best-merge-target/main6.js b/test/chunking-form/samples/min-chunk-size/best-merge-target/main6.js new file mode 100644 index 00000000000..e7180b14932 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/best-merge-target/main6.js @@ -0,0 +1,3 @@ +import { small1 } from './small1'; + +console.log(small1); diff --git a/test/chunking-form/samples/min-chunk-size/best-merge-target/main7.js b/test/chunking-form/samples/min-chunk-size/best-merge-target/main7.js new file mode 100644 index 00000000000..5104c70fc70 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/best-merge-target/main7.js @@ -0,0 +1,3 @@ +import { small2 } from './small2'; + +console.log(small2); diff --git a/test/chunking-form/samples/min-chunk-size/best-merge-target/main8.js b/test/chunking-form/samples/min-chunk-size/best-merge-target/main8.js new file mode 100644 index 00000000000..9b3e32cd341 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/best-merge-target/main8.js @@ -0,0 +1,3 @@ +import { small3 } from './small3'; + +console.log(small3); diff --git a/test/chunking-form/samples/min-chunk-size/best-merge-target/main9.js b/test/chunking-form/samples/min-chunk-size/best-merge-target/main9.js new file mode 100644 index 00000000000..87d1370ae33 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/best-merge-target/main9.js @@ -0,0 +1,3 @@ +import { small4 } from './small4'; + +console.log(small4); diff --git a/test/chunking-form/samples/min-chunk-size/best-merge-target/small1.js b/test/chunking-form/samples/min-chunk-size/best-merge-target/small1.js new file mode 100644 index 00000000000..076d519a29d --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/best-merge-target/small1.js @@ -0,0 +1 @@ +export const small1 = '12345678901234567890123456789012345678901234567890'; diff --git a/test/chunking-form/samples/min-chunk-size/best-merge-target/small2.js b/test/chunking-form/samples/min-chunk-size/best-merge-target/small2.js new file mode 100644 index 00000000000..1baf7456bcb --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/best-merge-target/small2.js @@ -0,0 +1 @@ +export const small2 = '12345678901234567890123456789012345678901234567890'; diff --git a/test/chunking-form/samples/min-chunk-size/best-merge-target/small3.js b/test/chunking-form/samples/min-chunk-size/best-merge-target/small3.js new file mode 100644 index 00000000000..ca3abd77d3e --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/best-merge-target/small3.js @@ -0,0 +1 @@ +export const small3 = '12345678901234567890123456789012345678901234567890'; diff --git a/test/chunking-form/samples/min-chunk-size/best-merge-target/small4.js b/test/chunking-form/samples/min-chunk-size/best-merge-target/small4.js new file mode 100644 index 00000000000..98e02ed47e9 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/best-merge-target/small4.js @@ -0,0 +1 @@ +export const small4 = '12345678901234567890123456789012345678901234567890'; diff --git a/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/_config.js b/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/_config.js new file mode 100644 index 00000000000..760704c72af --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/_config.js @@ -0,0 +1,9 @@ +module.exports = defineTest({ + description: 'ignores correlated side effects if they cannot be merged', + options: { + input: ['main1.js', 'main2.js', 'main3.js', 'main4.js', 'main5.js'], + output: { + experimentalMinChunkSize: 100 + } + } +}); diff --git a/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/_expected/amd/generated-small1.js b/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/_expected/amd/generated-small1.js new file mode 100644 index 00000000000..25cd135ccde --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/_expected/amd/generated-small1.js @@ -0,0 +1,9 @@ +define(['exports'], (function (exports) { 'use strict'; + + console.log('effect 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'); + + const small1 = '1'; + + exports.small1 = small1; + +})); diff --git a/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/_expected/amd/generated-small2.js b/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/_expected/amd/generated-small2.js new file mode 100644 index 00000000000..852f389a5d5 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/_expected/amd/generated-small2.js @@ -0,0 +1,9 @@ +define(['exports'], (function (exports) { 'use strict'; + + console.log('other effect 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'); + + const small2 = '2'; + + exports.small2 = small2; + +})); diff --git a/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/_expected/amd/main1.js b/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/_expected/amd/main1.js new file mode 100644 index 00000000000..77a2db52fd4 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/_expected/amd/main1.js @@ -0,0 +1,5 @@ +define(['./generated-small1', './generated-small2'], (function (small1, small2) { 'use strict'; + + console.log(small1.small1, small2.small2); + +})); diff --git a/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/_expected/amd/main2.js b/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/_expected/amd/main2.js new file mode 100644 index 00000000000..9873e8c4cdb --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/_expected/amd/main2.js @@ -0,0 +1,5 @@ +define(['./generated-small1'], (function (small1) { 'use strict'; + + console.log(small1.small1); + +})); diff --git a/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/_expected/amd/main3.js b/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/_expected/amd/main3.js new file mode 100644 index 00000000000..f7a8bc388f2 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/_expected/amd/main3.js @@ -0,0 +1,5 @@ +define(['./generated-small2'], (function (small2) { 'use strict'; + + console.log(small2.small2); + +})); diff --git a/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/_expected/amd/main4.js b/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/_expected/amd/main4.js new file mode 100644 index 00000000000..cff4625d39d --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/_expected/amd/main4.js @@ -0,0 +1,5 @@ +define(['./generated-small1', './generated-small2'], (function (small1, small2) { 'use strict'; + + console.log('main 4'); + +})); diff --git a/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/_expected/amd/main5.js b/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/_expected/amd/main5.js new file mode 100644 index 00000000000..8fd03f46cea --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/_expected/amd/main5.js @@ -0,0 +1,5 @@ +define(['./generated-small1', './generated-small2'], (function (small1, small2) { 'use strict'; + + console.log('main 5'); + +})); diff --git a/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/_expected/cjs/generated-small1.js b/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/_expected/cjs/generated-small1.js new file mode 100644 index 00000000000..ca741958a36 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/_expected/cjs/generated-small1.js @@ -0,0 +1,7 @@ +'use strict'; + +console.log('effect 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'); + +const small1 = '1'; + +exports.small1 = small1; diff --git a/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/_expected/cjs/generated-small2.js b/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/_expected/cjs/generated-small2.js new file mode 100644 index 00000000000..d3fb59432cd --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/_expected/cjs/generated-small2.js @@ -0,0 +1,7 @@ +'use strict'; + +console.log('other effect 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'); + +const small2 = '2'; + +exports.small2 = small2; diff --git a/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/_expected/cjs/main1.js b/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/_expected/cjs/main1.js new file mode 100644 index 00000000000..cbcec9c4b43 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/_expected/cjs/main1.js @@ -0,0 +1,6 @@ +'use strict'; + +var small1 = require('./generated-small1.js'); +var small2 = require('./generated-small2.js'); + +console.log(small1.small1, small2.small2); diff --git a/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/_expected/cjs/main2.js b/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/_expected/cjs/main2.js new file mode 100644 index 00000000000..481138de8db --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/_expected/cjs/main2.js @@ -0,0 +1,5 @@ +'use strict'; + +var small1 = require('./generated-small1.js'); + +console.log(small1.small1); diff --git a/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/_expected/cjs/main3.js b/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/_expected/cjs/main3.js new file mode 100644 index 00000000000..cfd5e278dbd --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/_expected/cjs/main3.js @@ -0,0 +1,5 @@ +'use strict'; + +var small2 = require('./generated-small2.js'); + +console.log(small2.small2); diff --git a/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/_expected/cjs/main4.js b/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/_expected/cjs/main4.js new file mode 100644 index 00000000000..16ddc46d562 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/_expected/cjs/main4.js @@ -0,0 +1,6 @@ +'use strict'; + +require('./generated-small1.js'); +require('./generated-small2.js'); + +console.log('main 4'); diff --git a/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/_expected/cjs/main5.js b/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/_expected/cjs/main5.js new file mode 100644 index 00000000000..d7f10f57f55 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/_expected/cjs/main5.js @@ -0,0 +1,6 @@ +'use strict'; + +require('./generated-small1.js'); +require('./generated-small2.js'); + +console.log('main 5'); diff --git a/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/_expected/es/generated-small1.js b/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/_expected/es/generated-small1.js new file mode 100644 index 00000000000..ffcc9833c5b --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/_expected/es/generated-small1.js @@ -0,0 +1,5 @@ +console.log('effect 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'); + +const small1 = '1'; + +export { small1 as s }; diff --git a/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/_expected/es/generated-small2.js b/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/_expected/es/generated-small2.js new file mode 100644 index 00000000000..e7010a77bbd --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/_expected/es/generated-small2.js @@ -0,0 +1,5 @@ +console.log('other effect 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'); + +const small2 = '2'; + +export { small2 as s }; diff --git a/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/_expected/es/main1.js b/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/_expected/es/main1.js new file mode 100644 index 00000000000..82171309c6a --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/_expected/es/main1.js @@ -0,0 +1,4 @@ +import { s as small1 } from './generated-small1.js'; +import { s as small2 } from './generated-small2.js'; + +console.log(small1, small2); diff --git a/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/_expected/es/main2.js b/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/_expected/es/main2.js new file mode 100644 index 00000000000..ebac230bc5b --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/_expected/es/main2.js @@ -0,0 +1,3 @@ +import { s as small1 } from './generated-small1.js'; + +console.log(small1); diff --git a/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/_expected/es/main3.js b/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/_expected/es/main3.js new file mode 100644 index 00000000000..3c70cd4f78a --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/_expected/es/main3.js @@ -0,0 +1,3 @@ +import { s as small2 } from './generated-small2.js'; + +console.log(small2); diff --git a/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/_expected/es/main4.js b/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/_expected/es/main4.js new file mode 100644 index 00000000000..080c95f1668 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/_expected/es/main4.js @@ -0,0 +1,4 @@ +import './generated-small1.js'; +import './generated-small2.js'; + +console.log('main 4'); diff --git a/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/_expected/es/main5.js b/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/_expected/es/main5.js new file mode 100644 index 00000000000..601cd735ba7 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/_expected/es/main5.js @@ -0,0 +1,4 @@ +import './generated-small1.js'; +import './generated-small2.js'; + +console.log('main 5'); diff --git a/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/_expected/system/generated-small1.js b/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/_expected/system/generated-small1.js new file mode 100644 index 00000000000..f807546609b --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/_expected/system/generated-small1.js @@ -0,0 +1,12 @@ +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + + console.log('effect 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'); + + const small1 = exports("s", '1'); + + }) + }; +})); diff --git a/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/_expected/system/generated-small2.js b/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/_expected/system/generated-small2.js new file mode 100644 index 00000000000..12b1135e4b3 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/_expected/system/generated-small2.js @@ -0,0 +1,12 @@ +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + + console.log('other effect 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'); + + const small2 = exports("s", '2'); + + }) + }; +})); diff --git a/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/_expected/system/main1.js b/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/_expected/system/main1.js new file mode 100644 index 00000000000..46f4276e987 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/_expected/system/main1.js @@ -0,0 +1,16 @@ +System.register(['./generated-small1.js', './generated-small2.js'], (function () { + 'use strict'; + var small1, small2; + return { + setters: [function (module) { + small1 = module.s; + }, function (module) { + small2 = module.s; + }], + execute: (function () { + + console.log(small1, small2); + + }) + }; +})); diff --git a/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/_expected/system/main2.js b/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/_expected/system/main2.js new file mode 100644 index 00000000000..a3f5c0e8eda --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/_expected/system/main2.js @@ -0,0 +1,14 @@ +System.register(['./generated-small1.js'], (function () { + 'use strict'; + var small1; + return { + setters: [function (module) { + small1 = module.s; + }], + execute: (function () { + + console.log(small1); + + }) + }; +})); diff --git a/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/_expected/system/main3.js b/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/_expected/system/main3.js new file mode 100644 index 00000000000..7eeca1a47a6 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/_expected/system/main3.js @@ -0,0 +1,14 @@ +System.register(['./generated-small2.js'], (function () { + 'use strict'; + var small2; + return { + setters: [function (module) { + small2 = module.s; + }], + execute: (function () { + + console.log(small2); + + }) + }; +})); diff --git a/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/_expected/system/main4.js b/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/_expected/system/main4.js new file mode 100644 index 00000000000..48fec908bc1 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/_expected/system/main4.js @@ -0,0 +1,11 @@ +System.register(['./generated-small1.js', './generated-small2.js'], (function () { + 'use strict'; + return { + setters: [null, null], + execute: (function () { + + console.log('main 4'); + + }) + }; +})); diff --git a/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/_expected/system/main5.js b/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/_expected/system/main5.js new file mode 100644 index 00000000000..d16e4d57209 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/_expected/system/main5.js @@ -0,0 +1,11 @@ +System.register(['./generated-small1.js', './generated-small2.js'], (function () { + 'use strict'; + return { + setters: [null, null], + execute: (function () { + + console.log('main 5'); + + }) + }; +})); diff --git a/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/effect.js b/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/effect.js new file mode 100644 index 00000000000..419200c2133 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/effect.js @@ -0,0 +1 @@ +console.log('effect 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'); diff --git a/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/main1.js b/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/main1.js new file mode 100644 index 00000000000..a9b9698fd4f --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/main1.js @@ -0,0 +1,6 @@ +import './effect'; +import './other-effect'; +import { small1 } from './small1'; +import { small2 } from './small2'; + +console.log(small1, small2); diff --git a/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/main2.js b/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/main2.js new file mode 100644 index 00000000000..0ac776a8282 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/main2.js @@ -0,0 +1,4 @@ +import './effect'; +import { small1 } from './small1'; + +console.log(small1); diff --git a/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/main3.js b/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/main3.js new file mode 100644 index 00000000000..400c857cc30 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/main3.js @@ -0,0 +1,4 @@ +import './other-effect'; +import { small2 } from './small2'; + +console.log(small2); diff --git a/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/main4.js b/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/main4.js new file mode 100644 index 00000000000..d8e12e40b57 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/main4.js @@ -0,0 +1,4 @@ +import './effect'; +import './other-effect'; + +console.log('main 4'); diff --git a/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/main5.js b/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/main5.js new file mode 100644 index 00000000000..d070f78168a --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/main5.js @@ -0,0 +1,4 @@ +import './effect'; +import './other-effect'; + +console.log('main 5'); diff --git a/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/other-effect.js b/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/other-effect.js new file mode 100644 index 00000000000..c6763f0c208 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/other-effect.js @@ -0,0 +1 @@ +console.log('other effect 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'); diff --git a/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/small1.js b/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/small1.js new file mode 100644 index 00000000000..7d722b9f6d7 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/small1.js @@ -0,0 +1 @@ +export const small1 = '1'; diff --git a/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/small2.js b/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/small2.js new file mode 100644 index 00000000000..ce9a3ce233f --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/ignore-correlated-side-effects/small2.js @@ -0,0 +1 @@ +export const small2 = '2'; diff --git a/test/chunking-form/samples/min-chunk-size/merge-chunk-into-distant-shared/_config.js b/test/chunking-form/samples/min-chunk-size/merge-chunk-into-distant-shared/_config.js new file mode 100644 index 00000000000..f9f8b583282 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-chunk-into-distant-shared/_config.js @@ -0,0 +1,10 @@ +module.exports = defineTest({ + description: + 'merges small chunks into shared chunks that are loaded by a non-close super-set of entry points', + options: { + input: ['main1.js', 'main2.js', 'main3.js', 'main4.js'], + output: { + experimentalMinChunkSize: 100 + } + } +}); diff --git a/test/chunking-form/samples/min-chunk-size/merge-chunk-into-distant-shared/_expected/amd/generated-shared.js b/test/chunking-form/samples/min-chunk-size/merge-chunk-into-distant-shared/_expected/amd/generated-shared.js new file mode 100644 index 00000000000..14143b2a6af --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-chunk-into-distant-shared/_expected/amd/generated-shared.js @@ -0,0 +1,11 @@ +define(['exports'], (function (exports) { 'use strict'; + + const small = '1'; + + const shared = '1'; + console.log('effect'); + + exports.shared = shared; + exports.small = small; + +})); diff --git a/test/chunking-form/samples/min-chunk-size/merge-chunk-into-distant-shared/_expected/amd/main1.js b/test/chunking-form/samples/min-chunk-size/merge-chunk-into-distant-shared/_expected/amd/main1.js new file mode 100644 index 00000000000..da13f87a714 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-chunk-into-distant-shared/_expected/amd/main1.js @@ -0,0 +1,5 @@ +define(['./generated-shared'], (function (shared) { 'use strict'; + + console.log(shared.shared, shared.small); + +})); diff --git a/test/chunking-form/samples/min-chunk-size/merge-chunk-into-distant-shared/_expected/amd/main2.js b/test/chunking-form/samples/min-chunk-size/merge-chunk-into-distant-shared/_expected/amd/main2.js new file mode 100644 index 00000000000..da13f87a714 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-chunk-into-distant-shared/_expected/amd/main2.js @@ -0,0 +1,5 @@ +define(['./generated-shared'], (function (shared) { 'use strict'; + + console.log(shared.shared, shared.small); + +})); diff --git a/test/chunking-form/samples/min-chunk-size/merge-chunk-into-distant-shared/_expected/amd/main3.js b/test/chunking-form/samples/min-chunk-size/merge-chunk-into-distant-shared/_expected/amd/main3.js new file mode 100644 index 00000000000..4402ec2e891 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-chunk-into-distant-shared/_expected/amd/main3.js @@ -0,0 +1,5 @@ +define(['./generated-shared'], (function (shared) { 'use strict'; + + console.log(shared.shared); + +})); diff --git a/test/chunking-form/samples/min-chunk-size/merge-chunk-into-distant-shared/_expected/amd/main4.js b/test/chunking-form/samples/min-chunk-size/merge-chunk-into-distant-shared/_expected/amd/main4.js new file mode 100644 index 00000000000..4402ec2e891 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-chunk-into-distant-shared/_expected/amd/main4.js @@ -0,0 +1,5 @@ +define(['./generated-shared'], (function (shared) { 'use strict'; + + console.log(shared.shared); + +})); diff --git a/test/chunking-form/samples/min-chunk-size/merge-chunk-into-distant-shared/_expected/cjs/generated-shared.js b/test/chunking-form/samples/min-chunk-size/merge-chunk-into-distant-shared/_expected/cjs/generated-shared.js new file mode 100644 index 00000000000..2de6f6481e3 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-chunk-into-distant-shared/_expected/cjs/generated-shared.js @@ -0,0 +1,9 @@ +'use strict'; + +const small = '1'; + +const shared = '1'; +console.log('effect'); + +exports.shared = shared; +exports.small = small; diff --git a/test/chunking-form/samples/min-chunk-size/merge-chunk-into-distant-shared/_expected/cjs/main1.js b/test/chunking-form/samples/min-chunk-size/merge-chunk-into-distant-shared/_expected/cjs/main1.js new file mode 100644 index 00000000000..d789523b554 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-chunk-into-distant-shared/_expected/cjs/main1.js @@ -0,0 +1,5 @@ +'use strict'; + +var shared = require('./generated-shared.js'); + +console.log(shared.shared, shared.small); diff --git a/test/chunking-form/samples/min-chunk-size/merge-chunk-into-distant-shared/_expected/cjs/main2.js b/test/chunking-form/samples/min-chunk-size/merge-chunk-into-distant-shared/_expected/cjs/main2.js new file mode 100644 index 00000000000..d789523b554 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-chunk-into-distant-shared/_expected/cjs/main2.js @@ -0,0 +1,5 @@ +'use strict'; + +var shared = require('./generated-shared.js'); + +console.log(shared.shared, shared.small); diff --git a/test/chunking-form/samples/min-chunk-size/merge-chunk-into-distant-shared/_expected/cjs/main3.js b/test/chunking-form/samples/min-chunk-size/merge-chunk-into-distant-shared/_expected/cjs/main3.js new file mode 100644 index 00000000000..ca2995738b8 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-chunk-into-distant-shared/_expected/cjs/main3.js @@ -0,0 +1,5 @@ +'use strict'; + +var shared = require('./generated-shared.js'); + +console.log(shared.shared); diff --git a/test/chunking-form/samples/min-chunk-size/merge-chunk-into-distant-shared/_expected/cjs/main4.js b/test/chunking-form/samples/min-chunk-size/merge-chunk-into-distant-shared/_expected/cjs/main4.js new file mode 100644 index 00000000000..ca2995738b8 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-chunk-into-distant-shared/_expected/cjs/main4.js @@ -0,0 +1,5 @@ +'use strict'; + +var shared = require('./generated-shared.js'); + +console.log(shared.shared); diff --git a/test/chunking-form/samples/min-chunk-size/merge-chunk-into-distant-shared/_expected/es/generated-shared.js b/test/chunking-form/samples/min-chunk-size/merge-chunk-into-distant-shared/_expected/es/generated-shared.js new file mode 100644 index 00000000000..5f64665d615 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-chunk-into-distant-shared/_expected/es/generated-shared.js @@ -0,0 +1,6 @@ +const small = '1'; + +const shared = '1'; +console.log('effect'); + +export { small as a, shared as s }; diff --git a/test/chunking-form/samples/min-chunk-size/merge-chunk-into-distant-shared/_expected/es/main1.js b/test/chunking-form/samples/min-chunk-size/merge-chunk-into-distant-shared/_expected/es/main1.js new file mode 100644 index 00000000000..7632ccbb92d --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-chunk-into-distant-shared/_expected/es/main1.js @@ -0,0 +1,3 @@ +import { s as shared, a as small } from './generated-shared.js'; + +console.log(shared, small); diff --git a/test/chunking-form/samples/min-chunk-size/merge-chunk-into-distant-shared/_expected/es/main2.js b/test/chunking-form/samples/min-chunk-size/merge-chunk-into-distant-shared/_expected/es/main2.js new file mode 100644 index 00000000000..7632ccbb92d --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-chunk-into-distant-shared/_expected/es/main2.js @@ -0,0 +1,3 @@ +import { s as shared, a as small } from './generated-shared.js'; + +console.log(shared, small); diff --git a/test/chunking-form/samples/min-chunk-size/merge-chunk-into-distant-shared/_expected/es/main3.js b/test/chunking-form/samples/min-chunk-size/merge-chunk-into-distant-shared/_expected/es/main3.js new file mode 100644 index 00000000000..5fa03d326a0 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-chunk-into-distant-shared/_expected/es/main3.js @@ -0,0 +1,3 @@ +import { s as shared } from './generated-shared.js'; + +console.log(shared); diff --git a/test/chunking-form/samples/min-chunk-size/merge-chunk-into-distant-shared/_expected/es/main4.js b/test/chunking-form/samples/min-chunk-size/merge-chunk-into-distant-shared/_expected/es/main4.js new file mode 100644 index 00000000000..5fa03d326a0 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-chunk-into-distant-shared/_expected/es/main4.js @@ -0,0 +1,3 @@ +import { s as shared } from './generated-shared.js'; + +console.log(shared); diff --git a/test/chunking-form/samples/min-chunk-size/merge-chunk-into-distant-shared/_expected/system/generated-shared.js b/test/chunking-form/samples/min-chunk-size/merge-chunk-into-distant-shared/_expected/system/generated-shared.js new file mode 100644 index 00000000000..a62447258a1 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-chunk-into-distant-shared/_expected/system/generated-shared.js @@ -0,0 +1,13 @@ +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + + const small = exports("a", '1'); + + const shared = exports("s", '1'); + console.log('effect'); + + }) + }; +})); diff --git a/test/chunking-form/samples/min-chunk-size/merge-chunk-into-distant-shared/_expected/system/main1.js b/test/chunking-form/samples/min-chunk-size/merge-chunk-into-distant-shared/_expected/system/main1.js new file mode 100644 index 00000000000..46b5be2e994 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-chunk-into-distant-shared/_expected/system/main1.js @@ -0,0 +1,15 @@ +System.register(['./generated-shared.js'], (function () { + 'use strict'; + var shared, small; + return { + setters: [function (module) { + shared = module.s; + small = module.a; + }], + execute: (function () { + + console.log(shared, small); + + }) + }; +})); diff --git a/test/chunking-form/samples/min-chunk-size/merge-chunk-into-distant-shared/_expected/system/main2.js b/test/chunking-form/samples/min-chunk-size/merge-chunk-into-distant-shared/_expected/system/main2.js new file mode 100644 index 00000000000..46b5be2e994 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-chunk-into-distant-shared/_expected/system/main2.js @@ -0,0 +1,15 @@ +System.register(['./generated-shared.js'], (function () { + 'use strict'; + var shared, small; + return { + setters: [function (module) { + shared = module.s; + small = module.a; + }], + execute: (function () { + + console.log(shared, small); + + }) + }; +})); diff --git a/test/chunking-form/samples/min-chunk-size/merge-chunk-into-distant-shared/_expected/system/main3.js b/test/chunking-form/samples/min-chunk-size/merge-chunk-into-distant-shared/_expected/system/main3.js new file mode 100644 index 00000000000..f926486d97e --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-chunk-into-distant-shared/_expected/system/main3.js @@ -0,0 +1,14 @@ +System.register(['./generated-shared.js'], (function () { + 'use strict'; + var shared; + return { + setters: [function (module) { + shared = module.s; + }], + execute: (function () { + + console.log(shared); + + }) + }; +})); diff --git a/test/chunking-form/samples/min-chunk-size/merge-chunk-into-distant-shared/_expected/system/main4.js b/test/chunking-form/samples/min-chunk-size/merge-chunk-into-distant-shared/_expected/system/main4.js new file mode 100644 index 00000000000..f926486d97e --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-chunk-into-distant-shared/_expected/system/main4.js @@ -0,0 +1,14 @@ +System.register(['./generated-shared.js'], (function () { + 'use strict'; + var shared; + return { + setters: [function (module) { + shared = module.s; + }], + execute: (function () { + + console.log(shared); + + }) + }; +})); diff --git a/test/chunking-form/samples/min-chunk-size/merge-chunk-into-distant-shared/main1.js b/test/chunking-form/samples/min-chunk-size/merge-chunk-into-distant-shared/main1.js new file mode 100644 index 00000000000..93f92a531bb --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-chunk-into-distant-shared/main1.js @@ -0,0 +1,4 @@ +import { small } from './small'; +import { shared } from './shared'; + +console.log(shared, small); diff --git a/test/chunking-form/samples/min-chunk-size/merge-chunk-into-distant-shared/main2.js b/test/chunking-form/samples/min-chunk-size/merge-chunk-into-distant-shared/main2.js new file mode 100644 index 00000000000..93f92a531bb --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-chunk-into-distant-shared/main2.js @@ -0,0 +1,4 @@ +import { small } from './small'; +import { shared } from './shared'; + +console.log(shared, small); diff --git a/test/chunking-form/samples/min-chunk-size/merge-chunk-into-distant-shared/main3.js b/test/chunking-form/samples/min-chunk-size/merge-chunk-into-distant-shared/main3.js new file mode 100644 index 00000000000..72cff2a340b --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-chunk-into-distant-shared/main3.js @@ -0,0 +1,3 @@ +import { shared } from './shared'; + +console.log(shared); diff --git a/test/chunking-form/samples/min-chunk-size/merge-chunk-into-distant-shared/main4.js b/test/chunking-form/samples/min-chunk-size/merge-chunk-into-distant-shared/main4.js new file mode 100644 index 00000000000..72cff2a340b --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-chunk-into-distant-shared/main4.js @@ -0,0 +1,3 @@ +import { shared } from './shared'; + +console.log(shared); diff --git a/test/chunking-form/samples/min-chunk-size/merge-chunk-into-distant-shared/shared.js b/test/chunking-form/samples/min-chunk-size/merge-chunk-into-distant-shared/shared.js new file mode 100644 index 00000000000..fda6d079f86 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-chunk-into-distant-shared/shared.js @@ -0,0 +1,2 @@ +export const shared = '1'; +console.log('effect'); diff --git a/test/chunking-form/samples/min-chunk-size/merge-chunk-into-distant-shared/small.js b/test/chunking-form/samples/min-chunk-size/merge-chunk-into-distant-shared/small.js new file mode 100644 index 00000000000..64e15634102 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-chunk-into-distant-shared/small.js @@ -0,0 +1 @@ +export const small = '1'; diff --git a/test/chunking-form/samples/min-chunk-size/merge-chunk-into-shared/_config.js b/test/chunking-form/samples/min-chunk-size/merge-chunk-into-shared/_config.js new file mode 100644 index 00000000000..b05e85da0e3 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-chunk-into-shared/_config.js @@ -0,0 +1,52 @@ +module.exports = defineTest({ + description: + 'merges small chunks into shared chunks that are loaded by a super-set of entry points', + options: { + input: ['main1.js', 'main2.js', 'main3.js'], + output: { + experimentalMinChunkSize: 100 + } + }, + logs: [ + { + level: 'info', + code: 'OPTIMIZE_CHUNK_STATUS', + message: 'After merging chunks, there are\n4 chunks, of which\n3 are below minChunkSize.' + }, + { + level: 'info', + code: 'OPTIMIZE_CHUNK_STATUS', + message: 'After merging chunks, there are\n4 chunks, of which\n3 are below minChunkSize.' + }, + { + level: 'info', + code: 'OPTIMIZE_CHUNK_STATUS', + message: 'After merging chunks, there are\n4 chunks, of which\n3 are below minChunkSize.' + }, + { + level: 'info', + code: 'OPTIMIZE_CHUNK_STATUS', + message: 'After merging chunks, there are\n4 chunks, of which\n3 are below minChunkSize.' + }, + { + level: 'info', + code: 'OPTIMIZE_CHUNK_STATUS', + message: 'Initially, there are\n5 chunks, of which\n4 are below minChunkSize.' + }, + { + level: 'info', + code: 'OPTIMIZE_CHUNK_STATUS', + message: 'Initially, there are\n5 chunks, of which\n4 are below minChunkSize.' + }, + { + level: 'info', + code: 'OPTIMIZE_CHUNK_STATUS', + message: 'Initially, there are\n5 chunks, of which\n4 are below minChunkSize.' + }, + { + level: 'info', + code: 'OPTIMIZE_CHUNK_STATUS', + message: 'Initially, there are\n5 chunks, of which\n4 are below minChunkSize.' + } + ] +}); diff --git a/test/chunking-form/samples/min-chunk-size/merge-chunk-into-shared/_expected/amd/generated-small.js b/test/chunking-form/samples/min-chunk-size/merge-chunk-into-shared/_expected/amd/generated-small.js new file mode 100644 index 00000000000..1353d019769 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-chunk-into-shared/_expected/amd/generated-small.js @@ -0,0 +1,10 @@ +define(['exports'], (function (exports) { 'use strict'; + + const big = '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'; + + const small = '1'; + + exports.big = big; + exports.small = small; + +})); diff --git a/test/chunking-form/samples/min-chunk-size/merge-chunk-into-shared/_expected/amd/main1.js b/test/chunking-form/samples/min-chunk-size/merge-chunk-into-shared/_expected/amd/main1.js new file mode 100644 index 00000000000..ec8f5125645 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-chunk-into-shared/_expected/amd/main1.js @@ -0,0 +1,5 @@ +define(['./generated-small'], (function (small) { 'use strict'; + + console.log(small.big, small.small); + +})); diff --git a/test/chunking-form/samples/min-chunk-size/merge-chunk-into-shared/_expected/amd/main2.js b/test/chunking-form/samples/min-chunk-size/merge-chunk-into-shared/_expected/amd/main2.js new file mode 100644 index 00000000000..ec8f5125645 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-chunk-into-shared/_expected/amd/main2.js @@ -0,0 +1,5 @@ +define(['./generated-small'], (function (small) { 'use strict'; + + console.log(small.big, small.small); + +})); diff --git a/test/chunking-form/samples/min-chunk-size/merge-chunk-into-shared/_expected/amd/main3.js b/test/chunking-form/samples/min-chunk-size/merge-chunk-into-shared/_expected/amd/main3.js new file mode 100644 index 00000000000..7691effe419 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-chunk-into-shared/_expected/amd/main3.js @@ -0,0 +1,5 @@ +define(['./generated-small'], (function (small) { 'use strict'; + + console.log(small.big); + +})); diff --git a/test/chunking-form/samples/min-chunk-size/merge-chunk-into-shared/_expected/cjs/generated-small.js b/test/chunking-form/samples/min-chunk-size/merge-chunk-into-shared/_expected/cjs/generated-small.js new file mode 100644 index 00000000000..9834f833d9c --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-chunk-into-shared/_expected/cjs/generated-small.js @@ -0,0 +1,8 @@ +'use strict'; + +const big = '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'; + +const small = '1'; + +exports.big = big; +exports.small = small; diff --git a/test/chunking-form/samples/min-chunk-size/merge-chunk-into-shared/_expected/cjs/main1.js b/test/chunking-form/samples/min-chunk-size/merge-chunk-into-shared/_expected/cjs/main1.js new file mode 100644 index 00000000000..8d1efac502d --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-chunk-into-shared/_expected/cjs/main1.js @@ -0,0 +1,5 @@ +'use strict'; + +var small = require('./generated-small.js'); + +console.log(small.big, small.small); diff --git a/test/chunking-form/samples/min-chunk-size/merge-chunk-into-shared/_expected/cjs/main2.js b/test/chunking-form/samples/min-chunk-size/merge-chunk-into-shared/_expected/cjs/main2.js new file mode 100644 index 00000000000..8d1efac502d --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-chunk-into-shared/_expected/cjs/main2.js @@ -0,0 +1,5 @@ +'use strict'; + +var small = require('./generated-small.js'); + +console.log(small.big, small.small); diff --git a/test/chunking-form/samples/min-chunk-size/merge-chunk-into-shared/_expected/cjs/main3.js b/test/chunking-form/samples/min-chunk-size/merge-chunk-into-shared/_expected/cjs/main3.js new file mode 100644 index 00000000000..168bfc47fb1 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-chunk-into-shared/_expected/cjs/main3.js @@ -0,0 +1,5 @@ +'use strict'; + +var small = require('./generated-small.js'); + +console.log(small.big); diff --git a/test/chunking-form/samples/min-chunk-size/merge-chunk-into-shared/_expected/es/generated-small.js b/test/chunking-form/samples/min-chunk-size/merge-chunk-into-shared/_expected/es/generated-small.js new file mode 100644 index 00000000000..3a60fcf90de --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-chunk-into-shared/_expected/es/generated-small.js @@ -0,0 +1,5 @@ +const big = '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'; + +const small = '1'; + +export { big as b, small as s }; diff --git a/test/chunking-form/samples/min-chunk-size/merge-chunk-into-shared/_expected/es/main1.js b/test/chunking-form/samples/min-chunk-size/merge-chunk-into-shared/_expected/es/main1.js new file mode 100644 index 00000000000..f72ae2e2c0b --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-chunk-into-shared/_expected/es/main1.js @@ -0,0 +1,3 @@ +import { b as big, s as small } from './generated-small.js'; + +console.log(big, small); diff --git a/test/chunking-form/samples/min-chunk-size/merge-chunk-into-shared/_expected/es/main2.js b/test/chunking-form/samples/min-chunk-size/merge-chunk-into-shared/_expected/es/main2.js new file mode 100644 index 00000000000..f72ae2e2c0b --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-chunk-into-shared/_expected/es/main2.js @@ -0,0 +1,3 @@ +import { b as big, s as small } from './generated-small.js'; + +console.log(big, small); diff --git a/test/chunking-form/samples/min-chunk-size/merge-chunk-into-shared/_expected/es/main3.js b/test/chunking-form/samples/min-chunk-size/merge-chunk-into-shared/_expected/es/main3.js new file mode 100644 index 00000000000..68f15d2638c --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-chunk-into-shared/_expected/es/main3.js @@ -0,0 +1,3 @@ +import { b as big } from './generated-small.js'; + +console.log(big); diff --git a/test/chunking-form/samples/min-chunk-size/merge-chunk-into-shared/_expected/system/generated-small.js b/test/chunking-form/samples/min-chunk-size/merge-chunk-into-shared/_expected/system/generated-small.js new file mode 100644 index 00000000000..8c290bc9ff8 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-chunk-into-shared/_expected/system/generated-small.js @@ -0,0 +1,12 @@ +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + + const big = exports("b", '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'); + + const small = exports("s", '1'); + + }) + }; +})); diff --git a/test/chunking-form/samples/min-chunk-size/merge-chunk-into-shared/_expected/system/main1.js b/test/chunking-form/samples/min-chunk-size/merge-chunk-into-shared/_expected/system/main1.js new file mode 100644 index 00000000000..d9c93667327 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-chunk-into-shared/_expected/system/main1.js @@ -0,0 +1,15 @@ +System.register(['./generated-small.js'], (function () { + 'use strict'; + var big, small; + return { + setters: [function (module) { + big = module.b; + small = module.s; + }], + execute: (function () { + + console.log(big, small); + + }) + }; +})); diff --git a/test/chunking-form/samples/min-chunk-size/merge-chunk-into-shared/_expected/system/main2.js b/test/chunking-form/samples/min-chunk-size/merge-chunk-into-shared/_expected/system/main2.js new file mode 100644 index 00000000000..d9c93667327 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-chunk-into-shared/_expected/system/main2.js @@ -0,0 +1,15 @@ +System.register(['./generated-small.js'], (function () { + 'use strict'; + var big, small; + return { + setters: [function (module) { + big = module.b; + small = module.s; + }], + execute: (function () { + + console.log(big, small); + + }) + }; +})); diff --git a/test/chunking-form/samples/min-chunk-size/merge-chunk-into-shared/_expected/system/main3.js b/test/chunking-form/samples/min-chunk-size/merge-chunk-into-shared/_expected/system/main3.js new file mode 100644 index 00000000000..90ebf97d750 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-chunk-into-shared/_expected/system/main3.js @@ -0,0 +1,14 @@ +System.register(['./generated-small.js'], (function () { + 'use strict'; + var big; + return { + setters: [function (module) { + big = module.b; + }], + execute: (function () { + + console.log(big); + + }) + }; +})); diff --git a/test/chunking-form/samples/min-chunk-size/merge-chunk-into-shared/big.js b/test/chunking-form/samples/min-chunk-size/merge-chunk-into-shared/big.js new file mode 100644 index 00000000000..aa804924cba --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-chunk-into-shared/big.js @@ -0,0 +1 @@ +export const big = '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'; diff --git a/test/chunking-form/samples/min-chunk-size/merge-chunk-into-shared/main1.js b/test/chunking-form/samples/min-chunk-size/merge-chunk-into-shared/main1.js new file mode 100644 index 00000000000..ca84399ef67 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-chunk-into-shared/main1.js @@ -0,0 +1,4 @@ +import { big } from './big'; +import { small } from './small'; + +console.log(big, small); diff --git a/test/chunking-form/samples/min-chunk-size/merge-chunk-into-shared/main2.js b/test/chunking-form/samples/min-chunk-size/merge-chunk-into-shared/main2.js new file mode 100644 index 00000000000..ca84399ef67 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-chunk-into-shared/main2.js @@ -0,0 +1,4 @@ +import { big } from './big'; +import { small } from './small'; + +console.log(big, small); diff --git a/test/chunking-form/samples/min-chunk-size/merge-chunk-into-shared/main3.js b/test/chunking-form/samples/min-chunk-size/merge-chunk-into-shared/main3.js new file mode 100644 index 00000000000..99752c1c3b4 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-chunk-into-shared/main3.js @@ -0,0 +1,3 @@ +import { big } from './big'; + +console.log(big); diff --git a/test/chunking-form/samples/min-chunk-size/merge-chunk-into-shared/small.js b/test/chunking-form/samples/min-chunk-size/merge-chunk-into-shared/small.js new file mode 100644 index 00000000000..64e15634102 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-chunk-into-shared/small.js @@ -0,0 +1 @@ +export const small = '1'; diff --git a/test/chunking-form/samples/min-chunk-size/merge-correlated-side-effects/_config.js b/test/chunking-form/samples/min-chunk-size/merge-correlated-side-effects/_config.js new file mode 100644 index 00000000000..a53c27cb97f --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-correlated-side-effects/_config.js @@ -0,0 +1,9 @@ +module.exports = defineTest({ + description: 'merges correlated side effects with pure chunks', + options: { + input: ['main1.js', 'main2.js', 'main3.js'], + output: { + experimentalMinChunkSize: 100 + } + } +}); diff --git a/test/chunking-form/samples/min-chunk-size/merge-correlated-side-effects/_expected/amd/generated-small1.js b/test/chunking-form/samples/min-chunk-size/merge-correlated-side-effects/_expected/amd/generated-small1.js new file mode 100644 index 00000000000..fc317547352 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-correlated-side-effects/_expected/amd/generated-small1.js @@ -0,0 +1,9 @@ +define(['exports'], (function (exports) { 'use strict'; + + console.log('effect'); + + const small1 = '1'; + + exports.small1 = small1; + +})); diff --git a/test/chunking-form/samples/min-chunk-size/merge-correlated-side-effects/_expected/amd/generated-small2.js b/test/chunking-form/samples/min-chunk-size/merge-correlated-side-effects/_expected/amd/generated-small2.js new file mode 100644 index 00000000000..1b4781a0b56 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-correlated-side-effects/_expected/amd/generated-small2.js @@ -0,0 +1,9 @@ +define(['exports'], (function (exports) { 'use strict'; + + console.log('other effect'); + + const small2 = '2'; + + exports.small2 = small2; + +})); diff --git a/test/chunking-form/samples/min-chunk-size/merge-correlated-side-effects/_expected/amd/main1.js b/test/chunking-form/samples/min-chunk-size/merge-correlated-side-effects/_expected/amd/main1.js new file mode 100644 index 00000000000..77a2db52fd4 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-correlated-side-effects/_expected/amd/main1.js @@ -0,0 +1,5 @@ +define(['./generated-small1', './generated-small2'], (function (small1, small2) { 'use strict'; + + console.log(small1.small1, small2.small2); + +})); diff --git a/test/chunking-form/samples/min-chunk-size/merge-correlated-side-effects/_expected/amd/main2.js b/test/chunking-form/samples/min-chunk-size/merge-correlated-side-effects/_expected/amd/main2.js new file mode 100644 index 00000000000..9873e8c4cdb --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-correlated-side-effects/_expected/amd/main2.js @@ -0,0 +1,5 @@ +define(['./generated-small1'], (function (small1) { 'use strict'; + + console.log(small1.small1); + +})); diff --git a/test/chunking-form/samples/min-chunk-size/merge-correlated-side-effects/_expected/amd/main3.js b/test/chunking-form/samples/min-chunk-size/merge-correlated-side-effects/_expected/amd/main3.js new file mode 100644 index 00000000000..f7a8bc388f2 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-correlated-side-effects/_expected/amd/main3.js @@ -0,0 +1,5 @@ +define(['./generated-small2'], (function (small2) { 'use strict'; + + console.log(small2.small2); + +})); diff --git a/test/chunking-form/samples/min-chunk-size/merge-correlated-side-effects/_expected/cjs/generated-small1.js b/test/chunking-form/samples/min-chunk-size/merge-correlated-side-effects/_expected/cjs/generated-small1.js new file mode 100644 index 00000000000..357633bf37a --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-correlated-side-effects/_expected/cjs/generated-small1.js @@ -0,0 +1,7 @@ +'use strict'; + +console.log('effect'); + +const small1 = '1'; + +exports.small1 = small1; diff --git a/test/chunking-form/samples/min-chunk-size/merge-correlated-side-effects/_expected/cjs/generated-small2.js b/test/chunking-form/samples/min-chunk-size/merge-correlated-side-effects/_expected/cjs/generated-small2.js new file mode 100644 index 00000000000..fea266b7fef --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-correlated-side-effects/_expected/cjs/generated-small2.js @@ -0,0 +1,7 @@ +'use strict'; + +console.log('other effect'); + +const small2 = '2'; + +exports.small2 = small2; diff --git a/test/chunking-form/samples/min-chunk-size/merge-correlated-side-effects/_expected/cjs/main1.js b/test/chunking-form/samples/min-chunk-size/merge-correlated-side-effects/_expected/cjs/main1.js new file mode 100644 index 00000000000..cbcec9c4b43 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-correlated-side-effects/_expected/cjs/main1.js @@ -0,0 +1,6 @@ +'use strict'; + +var small1 = require('./generated-small1.js'); +var small2 = require('./generated-small2.js'); + +console.log(small1.small1, small2.small2); diff --git a/test/chunking-form/samples/min-chunk-size/merge-correlated-side-effects/_expected/cjs/main2.js b/test/chunking-form/samples/min-chunk-size/merge-correlated-side-effects/_expected/cjs/main2.js new file mode 100644 index 00000000000..481138de8db --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-correlated-side-effects/_expected/cjs/main2.js @@ -0,0 +1,5 @@ +'use strict'; + +var small1 = require('./generated-small1.js'); + +console.log(small1.small1); diff --git a/test/chunking-form/samples/min-chunk-size/merge-correlated-side-effects/_expected/cjs/main3.js b/test/chunking-form/samples/min-chunk-size/merge-correlated-side-effects/_expected/cjs/main3.js new file mode 100644 index 00000000000..cfd5e278dbd --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-correlated-side-effects/_expected/cjs/main3.js @@ -0,0 +1,5 @@ +'use strict'; + +var small2 = require('./generated-small2.js'); + +console.log(small2.small2); diff --git a/test/chunking-form/samples/min-chunk-size/merge-correlated-side-effects/_expected/es/generated-small1.js b/test/chunking-form/samples/min-chunk-size/merge-correlated-side-effects/_expected/es/generated-small1.js new file mode 100644 index 00000000000..13899a0acab --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-correlated-side-effects/_expected/es/generated-small1.js @@ -0,0 +1,5 @@ +console.log('effect'); + +const small1 = '1'; + +export { small1 as s }; diff --git a/test/chunking-form/samples/min-chunk-size/merge-correlated-side-effects/_expected/es/generated-small2.js b/test/chunking-form/samples/min-chunk-size/merge-correlated-side-effects/_expected/es/generated-small2.js new file mode 100644 index 00000000000..583720d6354 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-correlated-side-effects/_expected/es/generated-small2.js @@ -0,0 +1,5 @@ +console.log('other effect'); + +const small2 = '2'; + +export { small2 as s }; diff --git a/test/chunking-form/samples/min-chunk-size/merge-correlated-side-effects/_expected/es/main1.js b/test/chunking-form/samples/min-chunk-size/merge-correlated-side-effects/_expected/es/main1.js new file mode 100644 index 00000000000..82171309c6a --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-correlated-side-effects/_expected/es/main1.js @@ -0,0 +1,4 @@ +import { s as small1 } from './generated-small1.js'; +import { s as small2 } from './generated-small2.js'; + +console.log(small1, small2); diff --git a/test/chunking-form/samples/min-chunk-size/merge-correlated-side-effects/_expected/es/main2.js b/test/chunking-form/samples/min-chunk-size/merge-correlated-side-effects/_expected/es/main2.js new file mode 100644 index 00000000000..ebac230bc5b --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-correlated-side-effects/_expected/es/main2.js @@ -0,0 +1,3 @@ +import { s as small1 } from './generated-small1.js'; + +console.log(small1); diff --git a/test/chunking-form/samples/min-chunk-size/merge-correlated-side-effects/_expected/es/main3.js b/test/chunking-form/samples/min-chunk-size/merge-correlated-side-effects/_expected/es/main3.js new file mode 100644 index 00000000000..3c70cd4f78a --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-correlated-side-effects/_expected/es/main3.js @@ -0,0 +1,3 @@ +import { s as small2 } from './generated-small2.js'; + +console.log(small2); diff --git a/test/chunking-form/samples/min-chunk-size/merge-correlated-side-effects/_expected/system/generated-small1.js b/test/chunking-form/samples/min-chunk-size/merge-correlated-side-effects/_expected/system/generated-small1.js new file mode 100644 index 00000000000..c6d72dea502 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-correlated-side-effects/_expected/system/generated-small1.js @@ -0,0 +1,12 @@ +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + + console.log('effect'); + + const small1 = exports("s", '1'); + + }) + }; +})); diff --git a/test/chunking-form/samples/min-chunk-size/merge-correlated-side-effects/_expected/system/generated-small2.js b/test/chunking-form/samples/min-chunk-size/merge-correlated-side-effects/_expected/system/generated-small2.js new file mode 100644 index 00000000000..07ca1e12553 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-correlated-side-effects/_expected/system/generated-small2.js @@ -0,0 +1,12 @@ +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + + console.log('other effect'); + + const small2 = exports("s", '2'); + + }) + }; +})); diff --git a/test/chunking-form/samples/min-chunk-size/merge-correlated-side-effects/_expected/system/main1.js b/test/chunking-form/samples/min-chunk-size/merge-correlated-side-effects/_expected/system/main1.js new file mode 100644 index 00000000000..46f4276e987 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-correlated-side-effects/_expected/system/main1.js @@ -0,0 +1,16 @@ +System.register(['./generated-small1.js', './generated-small2.js'], (function () { + 'use strict'; + var small1, small2; + return { + setters: [function (module) { + small1 = module.s; + }, function (module) { + small2 = module.s; + }], + execute: (function () { + + console.log(small1, small2); + + }) + }; +})); diff --git a/test/chunking-form/samples/min-chunk-size/merge-correlated-side-effects/_expected/system/main2.js b/test/chunking-form/samples/min-chunk-size/merge-correlated-side-effects/_expected/system/main2.js new file mode 100644 index 00000000000..a3f5c0e8eda --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-correlated-side-effects/_expected/system/main2.js @@ -0,0 +1,14 @@ +System.register(['./generated-small1.js'], (function () { + 'use strict'; + var small1; + return { + setters: [function (module) { + small1 = module.s; + }], + execute: (function () { + + console.log(small1); + + }) + }; +})); diff --git a/test/chunking-form/samples/min-chunk-size/merge-correlated-side-effects/_expected/system/main3.js b/test/chunking-form/samples/min-chunk-size/merge-correlated-side-effects/_expected/system/main3.js new file mode 100644 index 00000000000..7eeca1a47a6 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-correlated-side-effects/_expected/system/main3.js @@ -0,0 +1,14 @@ +System.register(['./generated-small2.js'], (function () { + 'use strict'; + var small2; + return { + setters: [function (module) { + small2 = module.s; + }], + execute: (function () { + + console.log(small2); + + }) + }; +})); diff --git a/test/chunking-form/samples/min-chunk-size/merge-correlated-side-effects/effect.js b/test/chunking-form/samples/min-chunk-size/merge-correlated-side-effects/effect.js new file mode 100644 index 00000000000..074feba739d --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-correlated-side-effects/effect.js @@ -0,0 +1 @@ +console.log('effect'); diff --git a/test/chunking-form/samples/min-chunk-size/merge-correlated-side-effects/main1.js b/test/chunking-form/samples/min-chunk-size/merge-correlated-side-effects/main1.js new file mode 100644 index 00000000000..a9b9698fd4f --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-correlated-side-effects/main1.js @@ -0,0 +1,6 @@ +import './effect'; +import './other-effect'; +import { small1 } from './small1'; +import { small2 } from './small2'; + +console.log(small1, small2); diff --git a/test/chunking-form/samples/min-chunk-size/merge-correlated-side-effects/main2.js b/test/chunking-form/samples/min-chunk-size/merge-correlated-side-effects/main2.js new file mode 100644 index 00000000000..0ac776a8282 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-correlated-side-effects/main2.js @@ -0,0 +1,4 @@ +import './effect'; +import { small1 } from './small1'; + +console.log(small1); diff --git a/test/chunking-form/samples/min-chunk-size/merge-correlated-side-effects/main3.js b/test/chunking-form/samples/min-chunk-size/merge-correlated-side-effects/main3.js new file mode 100644 index 00000000000..400c857cc30 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-correlated-side-effects/main3.js @@ -0,0 +1,4 @@ +import './other-effect'; +import { small2 } from './small2'; + +console.log(small2); diff --git a/test/chunking-form/samples/min-chunk-size/merge-correlated-side-effects/other-effect.js b/test/chunking-form/samples/min-chunk-size/merge-correlated-side-effects/other-effect.js new file mode 100644 index 00000000000..d3fdab38ad4 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-correlated-side-effects/other-effect.js @@ -0,0 +1 @@ +console.log('other effect'); diff --git a/test/chunking-form/samples/min-chunk-size/merge-correlated-side-effects/small1.js b/test/chunking-form/samples/min-chunk-size/merge-correlated-side-effects/small1.js new file mode 100644 index 00000000000..9216599f281 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-correlated-side-effects/small1.js @@ -0,0 +1,2 @@ + +export const small1 = '1'; diff --git a/test/chunking-form/samples/min-chunk-size/merge-correlated-side-effects/small2.js b/test/chunking-form/samples/min-chunk-size/merge-correlated-side-effects/small2.js new file mode 100644 index 00000000000..4112cdf0926 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-correlated-side-effects/small2.js @@ -0,0 +1,2 @@ + +export const small2 = '2'; diff --git a/test/chunking-form/samples/min-chunk-size/merge-dependency-side-effects/_config.js b/test/chunking-form/samples/min-chunk-size/merge-dependency-side-effects/_config.js new file mode 100644 index 00000000000..bd8600b4a71 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-dependency-side-effects/_config.js @@ -0,0 +1,9 @@ +module.exports = defineTest({ + description: 'merges chunks if their dependency side effects are the same', + options: { + input: ['main1.js', 'main2.js', 'main3.js'], + output: { + experimentalMinChunkSize: 100 + } + } +}); diff --git a/test/chunking-form/samples/min-chunk-size/merge-dependency-side-effects/_expected/amd/generated-small.js b/test/chunking-form/samples/min-chunk-size/merge-dependency-side-effects/_expected/amd/generated-small.js new file mode 100644 index 00000000000..3630af83674 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-dependency-side-effects/_expected/amd/generated-small.js @@ -0,0 +1,12 @@ +define(['exports'], (function (exports) { 'use strict'; + + console.log('effect'); + + const big = '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'; + + const small = '0'; + + exports.big = big; + exports.small = small; + +})); diff --git a/test/chunking-form/samples/min-chunk-size/merge-dependency-side-effects/_expected/amd/main1.js b/test/chunking-form/samples/min-chunk-size/merge-dependency-side-effects/_expected/amd/main1.js new file mode 100644 index 00000000000..ec8f5125645 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-dependency-side-effects/_expected/amd/main1.js @@ -0,0 +1,5 @@ +define(['./generated-small'], (function (small) { 'use strict'; + + console.log(small.big, small.small); + +})); diff --git a/test/chunking-form/samples/min-chunk-size/merge-dependency-side-effects/_expected/amd/main2.js b/test/chunking-form/samples/min-chunk-size/merge-dependency-side-effects/_expected/amd/main2.js new file mode 100644 index 00000000000..ec8f5125645 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-dependency-side-effects/_expected/amd/main2.js @@ -0,0 +1,5 @@ +define(['./generated-small'], (function (small) { 'use strict'; + + console.log(small.big, small.small); + +})); diff --git a/test/chunking-form/samples/min-chunk-size/merge-dependency-side-effects/_expected/amd/main3.js b/test/chunking-form/samples/min-chunk-size/merge-dependency-side-effects/_expected/amd/main3.js new file mode 100644 index 00000000000..7691effe419 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-dependency-side-effects/_expected/amd/main3.js @@ -0,0 +1,5 @@ +define(['./generated-small'], (function (small) { 'use strict'; + + console.log(small.big); + +})); diff --git a/test/chunking-form/samples/min-chunk-size/merge-dependency-side-effects/_expected/cjs/generated-small.js b/test/chunking-form/samples/min-chunk-size/merge-dependency-side-effects/_expected/cjs/generated-small.js new file mode 100644 index 00000000000..3d64fde9d15 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-dependency-side-effects/_expected/cjs/generated-small.js @@ -0,0 +1,10 @@ +'use strict'; + +console.log('effect'); + +const big = '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'; + +const small = '0'; + +exports.big = big; +exports.small = small; diff --git a/test/chunking-form/samples/min-chunk-size/merge-dependency-side-effects/_expected/cjs/main1.js b/test/chunking-form/samples/min-chunk-size/merge-dependency-side-effects/_expected/cjs/main1.js new file mode 100644 index 00000000000..8d1efac502d --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-dependency-side-effects/_expected/cjs/main1.js @@ -0,0 +1,5 @@ +'use strict'; + +var small = require('./generated-small.js'); + +console.log(small.big, small.small); diff --git a/test/chunking-form/samples/min-chunk-size/merge-dependency-side-effects/_expected/cjs/main2.js b/test/chunking-form/samples/min-chunk-size/merge-dependency-side-effects/_expected/cjs/main2.js new file mode 100644 index 00000000000..8d1efac502d --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-dependency-side-effects/_expected/cjs/main2.js @@ -0,0 +1,5 @@ +'use strict'; + +var small = require('./generated-small.js'); + +console.log(small.big, small.small); diff --git a/test/chunking-form/samples/min-chunk-size/merge-dependency-side-effects/_expected/cjs/main3.js b/test/chunking-form/samples/min-chunk-size/merge-dependency-side-effects/_expected/cjs/main3.js new file mode 100644 index 00000000000..168bfc47fb1 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-dependency-side-effects/_expected/cjs/main3.js @@ -0,0 +1,5 @@ +'use strict'; + +var small = require('./generated-small.js'); + +console.log(small.big); diff --git a/test/chunking-form/samples/min-chunk-size/merge-dependency-side-effects/_expected/es/generated-small.js b/test/chunking-form/samples/min-chunk-size/merge-dependency-side-effects/_expected/es/generated-small.js new file mode 100644 index 00000000000..04023812a13 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-dependency-side-effects/_expected/es/generated-small.js @@ -0,0 +1,7 @@ +console.log('effect'); + +const big = '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'; + +const small = '0'; + +export { big as b, small as s }; diff --git a/test/chunking-form/samples/min-chunk-size/merge-dependency-side-effects/_expected/es/main1.js b/test/chunking-form/samples/min-chunk-size/merge-dependency-side-effects/_expected/es/main1.js new file mode 100644 index 00000000000..f72ae2e2c0b --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-dependency-side-effects/_expected/es/main1.js @@ -0,0 +1,3 @@ +import { b as big, s as small } from './generated-small.js'; + +console.log(big, small); diff --git a/test/chunking-form/samples/min-chunk-size/merge-dependency-side-effects/_expected/es/main2.js b/test/chunking-form/samples/min-chunk-size/merge-dependency-side-effects/_expected/es/main2.js new file mode 100644 index 00000000000..f72ae2e2c0b --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-dependency-side-effects/_expected/es/main2.js @@ -0,0 +1,3 @@ +import { b as big, s as small } from './generated-small.js'; + +console.log(big, small); diff --git a/test/chunking-form/samples/min-chunk-size/merge-dependency-side-effects/_expected/es/main3.js b/test/chunking-form/samples/min-chunk-size/merge-dependency-side-effects/_expected/es/main3.js new file mode 100644 index 00000000000..68f15d2638c --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-dependency-side-effects/_expected/es/main3.js @@ -0,0 +1,3 @@ +import { b as big } from './generated-small.js'; + +console.log(big); diff --git a/test/chunking-form/samples/min-chunk-size/merge-dependency-side-effects/_expected/system/generated-small.js b/test/chunking-form/samples/min-chunk-size/merge-dependency-side-effects/_expected/system/generated-small.js new file mode 100644 index 00000000000..12dfbd2ec3d --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-dependency-side-effects/_expected/system/generated-small.js @@ -0,0 +1,14 @@ +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + + console.log('effect'); + + const big = exports("b", '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'); + + const small = exports("s", '0'); + + }) + }; +})); diff --git a/test/chunking-form/samples/min-chunk-size/merge-dependency-side-effects/_expected/system/main1.js b/test/chunking-form/samples/min-chunk-size/merge-dependency-side-effects/_expected/system/main1.js new file mode 100644 index 00000000000..d9c93667327 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-dependency-side-effects/_expected/system/main1.js @@ -0,0 +1,15 @@ +System.register(['./generated-small.js'], (function () { + 'use strict'; + var big, small; + return { + setters: [function (module) { + big = module.b; + small = module.s; + }], + execute: (function () { + + console.log(big, small); + + }) + }; +})); diff --git a/test/chunking-form/samples/min-chunk-size/merge-dependency-side-effects/_expected/system/main2.js b/test/chunking-form/samples/min-chunk-size/merge-dependency-side-effects/_expected/system/main2.js new file mode 100644 index 00000000000..d9c93667327 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-dependency-side-effects/_expected/system/main2.js @@ -0,0 +1,15 @@ +System.register(['./generated-small.js'], (function () { + 'use strict'; + var big, small; + return { + setters: [function (module) { + big = module.b; + small = module.s; + }], + execute: (function () { + + console.log(big, small); + + }) + }; +})); diff --git a/test/chunking-form/samples/min-chunk-size/merge-dependency-side-effects/_expected/system/main3.js b/test/chunking-form/samples/min-chunk-size/merge-dependency-side-effects/_expected/system/main3.js new file mode 100644 index 00000000000..90ebf97d750 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-dependency-side-effects/_expected/system/main3.js @@ -0,0 +1,14 @@ +System.register(['./generated-small.js'], (function () { + 'use strict'; + var big; + return { + setters: [function (module) { + big = module.b; + }], + execute: (function () { + + console.log(big); + + }) + }; +})); diff --git a/test/chunking-form/samples/min-chunk-size/merge-dependency-side-effects/big.js b/test/chunking-form/samples/min-chunk-size/merge-dependency-side-effects/big.js new file mode 100644 index 00000000000..6d49a202f60 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-dependency-side-effects/big.js @@ -0,0 +1,3 @@ +import './effect'; + +export const big = '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'; diff --git a/test/chunking-form/samples/min-chunk-size/merge-dependency-side-effects/effect.js b/test/chunking-form/samples/min-chunk-size/merge-dependency-side-effects/effect.js new file mode 100644 index 00000000000..074feba739d --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-dependency-side-effects/effect.js @@ -0,0 +1 @@ +console.log('effect'); diff --git a/test/chunking-form/samples/min-chunk-size/merge-dependency-side-effects/main1.js b/test/chunking-form/samples/min-chunk-size/merge-dependency-side-effects/main1.js new file mode 100644 index 00000000000..ca84399ef67 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-dependency-side-effects/main1.js @@ -0,0 +1,4 @@ +import { big } from './big'; +import { small } from './small'; + +console.log(big, small); diff --git a/test/chunking-form/samples/min-chunk-size/merge-dependency-side-effects/main2.js b/test/chunking-form/samples/min-chunk-size/merge-dependency-side-effects/main2.js new file mode 100644 index 00000000000..ca84399ef67 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-dependency-side-effects/main2.js @@ -0,0 +1,4 @@ +import { big } from './big'; +import { small } from './small'; + +console.log(big, small); diff --git a/test/chunking-form/samples/min-chunk-size/merge-dependency-side-effects/main3.js b/test/chunking-form/samples/min-chunk-size/merge-dependency-side-effects/main3.js new file mode 100644 index 00000000000..99752c1c3b4 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-dependency-side-effects/main3.js @@ -0,0 +1,3 @@ +import { big } from './big'; + +console.log(big); diff --git a/test/chunking-form/samples/min-chunk-size/merge-dependency-side-effects/small.js b/test/chunking-form/samples/min-chunk-size/merge-dependency-side-effects/small.js new file mode 100644 index 00000000000..6ca369caab8 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-dependency-side-effects/small.js @@ -0,0 +1,3 @@ +import './effect'; + +export const small = '0'; diff --git a/test/chunking-form/samples/min-chunk-size/merge-despite-correlated-side-effects/_config.js b/test/chunking-form/samples/min-chunk-size/merge-despite-correlated-side-effects/_config.js new file mode 100644 index 00000000000..858c318d993 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-despite-correlated-side-effects/_config.js @@ -0,0 +1,10 @@ +module.exports = defineTest({ + description: + "merges chunks if their dependency side effects are a subset of the other's correlated side effects", + options: { + input: ['main1.js', 'main2.js', 'main3.js'], + output: { + experimentalMinChunkSize: 100 + } + } +}); diff --git a/test/chunking-form/samples/min-chunk-size/merge-despite-correlated-side-effects/_expected/amd/generated-small.js b/test/chunking-form/samples/min-chunk-size/merge-despite-correlated-side-effects/_expected/amd/generated-small.js new file mode 100644 index 00000000000..3630af83674 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-despite-correlated-side-effects/_expected/amd/generated-small.js @@ -0,0 +1,12 @@ +define(['exports'], (function (exports) { 'use strict'; + + console.log('effect'); + + const big = '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'; + + const small = '0'; + + exports.big = big; + exports.small = small; + +})); diff --git a/test/chunking-form/samples/min-chunk-size/merge-despite-correlated-side-effects/_expected/amd/main1.js b/test/chunking-form/samples/min-chunk-size/merge-despite-correlated-side-effects/_expected/amd/main1.js new file mode 100644 index 00000000000..ec8f5125645 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-despite-correlated-side-effects/_expected/amd/main1.js @@ -0,0 +1,5 @@ +define(['./generated-small'], (function (small) { 'use strict'; + + console.log(small.big, small.small); + +})); diff --git a/test/chunking-form/samples/min-chunk-size/merge-despite-correlated-side-effects/_expected/amd/main2.js b/test/chunking-form/samples/min-chunk-size/merge-despite-correlated-side-effects/_expected/amd/main2.js new file mode 100644 index 00000000000..13b257c70d1 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-despite-correlated-side-effects/_expected/amd/main2.js @@ -0,0 +1,5 @@ +define(['./generated-small'], (function (small$1) { 'use strict'; + + console.log(small$1.big, small); + +})); diff --git a/test/chunking-form/samples/min-chunk-size/merge-despite-correlated-side-effects/_expected/amd/main3.js b/test/chunking-form/samples/min-chunk-size/merge-despite-correlated-side-effects/_expected/amd/main3.js new file mode 100644 index 00000000000..87b6a754d97 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-despite-correlated-side-effects/_expected/amd/main3.js @@ -0,0 +1,5 @@ +define(['./generated-small'], (function (small) { 'use strict'; + + console.log(small.small); + +})); diff --git a/test/chunking-form/samples/min-chunk-size/merge-despite-correlated-side-effects/_expected/cjs/generated-small.js b/test/chunking-form/samples/min-chunk-size/merge-despite-correlated-side-effects/_expected/cjs/generated-small.js new file mode 100644 index 00000000000..3d64fde9d15 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-despite-correlated-side-effects/_expected/cjs/generated-small.js @@ -0,0 +1,10 @@ +'use strict'; + +console.log('effect'); + +const big = '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'; + +const small = '0'; + +exports.big = big; +exports.small = small; diff --git a/test/chunking-form/samples/min-chunk-size/merge-despite-correlated-side-effects/_expected/cjs/main1.js b/test/chunking-form/samples/min-chunk-size/merge-despite-correlated-side-effects/_expected/cjs/main1.js new file mode 100644 index 00000000000..8d1efac502d --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-despite-correlated-side-effects/_expected/cjs/main1.js @@ -0,0 +1,5 @@ +'use strict'; + +var small = require('./generated-small.js'); + +console.log(small.big, small.small); diff --git a/test/chunking-form/samples/min-chunk-size/merge-despite-correlated-side-effects/_expected/cjs/main2.js b/test/chunking-form/samples/min-chunk-size/merge-despite-correlated-side-effects/_expected/cjs/main2.js new file mode 100644 index 00000000000..fb370c5606f --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-despite-correlated-side-effects/_expected/cjs/main2.js @@ -0,0 +1,5 @@ +'use strict'; + +var small$1 = require('./generated-small.js'); + +console.log(small$1.big, small); diff --git a/test/chunking-form/samples/min-chunk-size/merge-despite-correlated-side-effects/_expected/cjs/main3.js b/test/chunking-form/samples/min-chunk-size/merge-despite-correlated-side-effects/_expected/cjs/main3.js new file mode 100644 index 00000000000..e9f5c811d62 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-despite-correlated-side-effects/_expected/cjs/main3.js @@ -0,0 +1,5 @@ +'use strict'; + +var small = require('./generated-small.js'); + +console.log(small.small); diff --git a/test/chunking-form/samples/min-chunk-size/merge-despite-correlated-side-effects/_expected/es/generated-small.js b/test/chunking-form/samples/min-chunk-size/merge-despite-correlated-side-effects/_expected/es/generated-small.js new file mode 100644 index 00000000000..04023812a13 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-despite-correlated-side-effects/_expected/es/generated-small.js @@ -0,0 +1,7 @@ +console.log('effect'); + +const big = '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'; + +const small = '0'; + +export { big as b, small as s }; diff --git a/test/chunking-form/samples/min-chunk-size/merge-despite-correlated-side-effects/_expected/es/main1.js b/test/chunking-form/samples/min-chunk-size/merge-despite-correlated-side-effects/_expected/es/main1.js new file mode 100644 index 00000000000..f72ae2e2c0b --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-despite-correlated-side-effects/_expected/es/main1.js @@ -0,0 +1,3 @@ +import { b as big, s as small } from './generated-small.js'; + +console.log(big, small); diff --git a/test/chunking-form/samples/min-chunk-size/merge-despite-correlated-side-effects/_expected/es/main2.js b/test/chunking-form/samples/min-chunk-size/merge-despite-correlated-side-effects/_expected/es/main2.js new file mode 100644 index 00000000000..3f6998eb87b --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-despite-correlated-side-effects/_expected/es/main2.js @@ -0,0 +1,3 @@ +import { b as big } from './generated-small.js'; + +console.log(big, small); diff --git a/test/chunking-form/samples/min-chunk-size/merge-despite-correlated-side-effects/_expected/es/main3.js b/test/chunking-form/samples/min-chunk-size/merge-despite-correlated-side-effects/_expected/es/main3.js new file mode 100644 index 00000000000..3f8fefa28aa --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-despite-correlated-side-effects/_expected/es/main3.js @@ -0,0 +1,3 @@ +import { s as small } from './generated-small.js'; + +console.log(small); diff --git a/test/chunking-form/samples/min-chunk-size/merge-despite-correlated-side-effects/_expected/system/generated-small.js b/test/chunking-form/samples/min-chunk-size/merge-despite-correlated-side-effects/_expected/system/generated-small.js new file mode 100644 index 00000000000..12dfbd2ec3d --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-despite-correlated-side-effects/_expected/system/generated-small.js @@ -0,0 +1,14 @@ +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + + console.log('effect'); + + const big = exports("b", '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'); + + const small = exports("s", '0'); + + }) + }; +})); diff --git a/test/chunking-form/samples/min-chunk-size/merge-despite-correlated-side-effects/_expected/system/main1.js b/test/chunking-form/samples/min-chunk-size/merge-despite-correlated-side-effects/_expected/system/main1.js new file mode 100644 index 00000000000..d9c93667327 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-despite-correlated-side-effects/_expected/system/main1.js @@ -0,0 +1,15 @@ +System.register(['./generated-small.js'], (function () { + 'use strict'; + var big, small; + return { + setters: [function (module) { + big = module.b; + small = module.s; + }], + execute: (function () { + + console.log(big, small); + + }) + }; +})); diff --git a/test/chunking-form/samples/min-chunk-size/merge-despite-correlated-side-effects/_expected/system/main2.js b/test/chunking-form/samples/min-chunk-size/merge-despite-correlated-side-effects/_expected/system/main2.js new file mode 100644 index 00000000000..d58dee177b9 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-despite-correlated-side-effects/_expected/system/main2.js @@ -0,0 +1,14 @@ +System.register(['./generated-small.js'], (function () { + 'use strict'; + var big; + return { + setters: [function (module) { + big = module.b; + }], + execute: (function () { + + console.log(big, small); + + }) + }; +})); diff --git a/test/chunking-form/samples/min-chunk-size/merge-despite-correlated-side-effects/_expected/system/main3.js b/test/chunking-form/samples/min-chunk-size/merge-despite-correlated-side-effects/_expected/system/main3.js new file mode 100644 index 00000000000..6e93391fab8 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-despite-correlated-side-effects/_expected/system/main3.js @@ -0,0 +1,14 @@ +System.register(['./generated-small.js'], (function () { + 'use strict'; + var small; + return { + setters: [function (module) { + small = module.s; + }], + execute: (function () { + + console.log(small); + + }) + }; +})); diff --git a/test/chunking-form/samples/min-chunk-size/merge-despite-correlated-side-effects/big.js b/test/chunking-form/samples/min-chunk-size/merge-despite-correlated-side-effects/big.js new file mode 100644 index 00000000000..aa804924cba --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-despite-correlated-side-effects/big.js @@ -0,0 +1 @@ +export const big = '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'; diff --git a/test/chunking-form/samples/min-chunk-size/merge-despite-correlated-side-effects/effect.js b/test/chunking-form/samples/min-chunk-size/merge-despite-correlated-side-effects/effect.js new file mode 100644 index 00000000000..074feba739d --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-despite-correlated-side-effects/effect.js @@ -0,0 +1 @@ +console.log('effect'); diff --git a/test/chunking-form/samples/min-chunk-size/merge-despite-correlated-side-effects/main1.js b/test/chunking-form/samples/min-chunk-size/merge-despite-correlated-side-effects/main1.js new file mode 100644 index 00000000000..dbcea351551 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-despite-correlated-side-effects/main1.js @@ -0,0 +1,5 @@ +import './effect'; +import { big } from './big'; +import { small } from './small'; + +console.log(big, small); diff --git a/test/chunking-form/samples/min-chunk-size/merge-despite-correlated-side-effects/main2.js b/test/chunking-form/samples/min-chunk-size/merge-despite-correlated-side-effects/main2.js new file mode 100644 index 00000000000..68f7b2d0449 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-despite-correlated-side-effects/main2.js @@ -0,0 +1,4 @@ +import './effect'; +import { big } from './big'; + +console.log(big, small); diff --git a/test/chunking-form/samples/min-chunk-size/merge-despite-correlated-side-effects/main3.js b/test/chunking-form/samples/min-chunk-size/merge-despite-correlated-side-effects/main3.js new file mode 100644 index 00000000000..445919e6d15 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-despite-correlated-side-effects/main3.js @@ -0,0 +1,3 @@ +import { small } from './small'; + +console.log(small); diff --git a/test/chunking-form/samples/min-chunk-size/merge-despite-correlated-side-effects/small.js b/test/chunking-form/samples/min-chunk-size/merge-despite-correlated-side-effects/small.js new file mode 100644 index 00000000000..6ca369caab8 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-despite-correlated-side-effects/small.js @@ -0,0 +1,3 @@ +import './effect'; + +export const small = '0'; diff --git a/test/chunking-form/samples/min-chunk-size/merge-dynamic-imports/_config.js b/test/chunking-form/samples/min-chunk-size/merge-dynamic-imports/_config.js new file mode 100644 index 00000000000..f136a8cb39c --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-dynamic-imports/_config.js @@ -0,0 +1,8 @@ +module.exports = defineTest({ + description: 'merges small chunks without side effects into suitable chunks', + options: { + output: { + experimentalMinChunkSize: 100 + } + } +}); diff --git a/test/chunking-form/samples/min-chunk-size/merge-dynamic-imports/_expected/amd/main.js b/test/chunking-form/samples/min-chunk-size/merge-dynamic-imports/_expected/amd/main.js new file mode 100644 index 00000000000..82fc5568e13 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-dynamic-imports/_expected/amd/main.js @@ -0,0 +1,27 @@ +define(['exports'], (function (exports) { 'use strict'; + + const big = + '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'; + + const small1$2 = Promise.resolve().then(function () { return small1$1; }); + const small2$2 = Promise.resolve().then(function () { return small2$1; }); + + const small1 = 'small1'; + + var small1$1 = /*#__PURE__*/Object.freeze({ + __proto__: null, + small1: small1 + }); + + const small2 = 'small2'; + + var small2$1 = /*#__PURE__*/Object.freeze({ + __proto__: null, + small2: small2 + }); + + exports.big = big; + exports.small1 = small1$2; + exports.small2 = small2$2; + +})); diff --git a/test/chunking-form/samples/min-chunk-size/merge-dynamic-imports/_expected/cjs/main.js b/test/chunking-form/samples/min-chunk-size/merge-dynamic-imports/_expected/cjs/main.js new file mode 100644 index 00000000000..e4b7621df92 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-dynamic-imports/_expected/cjs/main.js @@ -0,0 +1,25 @@ +'use strict'; + +const big = + '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'; + +const small1$2 = Promise.resolve().then(function () { return small1$1; }); +const small2$2 = Promise.resolve().then(function () { return small2$1; }); + +const small1 = 'small1'; + +var small1$1 = /*#__PURE__*/Object.freeze({ + __proto__: null, + small1: small1 +}); + +const small2 = 'small2'; + +var small2$1 = /*#__PURE__*/Object.freeze({ + __proto__: null, + small2: small2 +}); + +exports.big = big; +exports.small1 = small1$2; +exports.small2 = small2$2; diff --git a/test/chunking-form/samples/min-chunk-size/merge-dynamic-imports/_expected/es/main.js b/test/chunking-form/samples/min-chunk-size/merge-dynamic-imports/_expected/es/main.js new file mode 100644 index 00000000000..7492732289a --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-dynamic-imports/_expected/es/main.js @@ -0,0 +1,21 @@ +const big = + '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'; + +const small1$2 = Promise.resolve().then(function () { return small1$1; }); +const small2$2 = Promise.resolve().then(function () { return small2$1; }); + +const small1 = 'small1'; + +var small1$1 = /*#__PURE__*/Object.freeze({ + __proto__: null, + small1: small1 +}); + +const small2 = 'small2'; + +var small2$1 = /*#__PURE__*/Object.freeze({ + __proto__: null, + small2: small2 +}); + +export { big, small1$2 as small1, small2$2 as small2 }; diff --git a/test/chunking-form/samples/min-chunk-size/merge-dynamic-imports/_expected/system/main.js b/test/chunking-form/samples/min-chunk-size/merge-dynamic-imports/_expected/system/main.js new file mode 100644 index 00000000000..caec9a3ad4c --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-dynamic-imports/_expected/system/main.js @@ -0,0 +1,28 @@ +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + + const big = + exports("big", '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'); + + const small1$2 = exports("small1", Promise.resolve().then(function () { return small1$1; })); + const small2$2 = exports("small2", Promise.resolve().then(function () { return small2$1; })); + + const small1 = 'small1'; + + var small1$1 = /*#__PURE__*/Object.freeze({ + __proto__: null, + small1: small1 + }); + + const small2 = 'small2'; + + var small2$1 = /*#__PURE__*/Object.freeze({ + __proto__: null, + small2: small2 + }); + + }) + }; +})); diff --git a/test/chunking-form/samples/min-chunk-size/merge-dynamic-imports/main.js b/test/chunking-form/samples/min-chunk-size/merge-dynamic-imports/main.js new file mode 100644 index 00000000000..2551904441a --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-dynamic-imports/main.js @@ -0,0 +1,5 @@ +export const big = + '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'; + +export const small1 = import('./small1'); +export const small2 = import('./small2'); diff --git a/test/chunking-form/samples/min-chunk-size/merge-dynamic-imports/small1.js b/test/chunking-form/samples/min-chunk-size/merge-dynamic-imports/small1.js new file mode 100644 index 00000000000..e5130ed7792 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-dynamic-imports/small1.js @@ -0,0 +1 @@ +export const small1 = 'small1'; diff --git a/test/chunking-form/samples/min-chunk-size/merge-dynamic-imports/small2.js b/test/chunking-form/samples/min-chunk-size/merge-dynamic-imports/small2.js new file mode 100644 index 00000000000..b31afab30aa --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-dynamic-imports/small2.js @@ -0,0 +1 @@ +export const small2 = 'small2'; diff --git a/test/chunking-form/samples/min-chunk-size/merge-small-side-effect-chunks/_config.js b/test/chunking-form/samples/min-chunk-size/merge-small-side-effect-chunks/_config.js new file mode 100644 index 00000000000..7e23f3230e0 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-small-side-effect-chunks/_config.js @@ -0,0 +1,9 @@ +module.exports = defineTest({ + description: 'merges small chunks with side effects into suitable pure chunks', + options: { + input: ['main1.js', 'main2.js'], + output: { + experimentalMinChunkSize: 100 + } + } +}); diff --git a/test/chunking-form/samples/min-chunk-size/merge-small-side-effect-chunks/_expected/amd/main1.js b/test/chunking-form/samples/min-chunk-size/merge-small-side-effect-chunks/_expected/amd/main1.js new file mode 100644 index 00000000000..3477c56bb66 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-small-side-effect-chunks/_expected/amd/main1.js @@ -0,0 +1,8 @@ +define(['exports'], (function (exports) { 'use strict'; + + const small = '12345678901234567890123456789012345678901234567890'; + console.log('effect'); + + exports.small = small; + +})); diff --git a/test/chunking-form/samples/min-chunk-size/merge-small-side-effect-chunks/_expected/amd/main2.js b/test/chunking-form/samples/min-chunk-size/merge-small-side-effect-chunks/_expected/amd/main2.js new file mode 100644 index 00000000000..75d29312f44 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-small-side-effect-chunks/_expected/amd/main2.js @@ -0,0 +1,7 @@ +define(['exports', './main1'], (function (exports, main1) { 'use strict'; + + + + exports.small = main1.small; + +})); diff --git a/test/chunking-form/samples/min-chunk-size/merge-small-side-effect-chunks/_expected/cjs/main1.js b/test/chunking-form/samples/min-chunk-size/merge-small-side-effect-chunks/_expected/cjs/main1.js new file mode 100644 index 00000000000..c83f3b00640 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-small-side-effect-chunks/_expected/cjs/main1.js @@ -0,0 +1,6 @@ +'use strict'; + +const small = '12345678901234567890123456789012345678901234567890'; +console.log('effect'); + +exports.small = small; diff --git a/test/chunking-form/samples/min-chunk-size/merge-small-side-effect-chunks/_expected/cjs/main2.js b/test/chunking-form/samples/min-chunk-size/merge-small-side-effect-chunks/_expected/cjs/main2.js new file mode 100644 index 00000000000..719cb13d037 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-small-side-effect-chunks/_expected/cjs/main2.js @@ -0,0 +1,7 @@ +'use strict'; + +var main1 = require('./main1.js'); + + + +exports.small = main1.small; diff --git a/test/chunking-form/samples/min-chunk-size/merge-small-side-effect-chunks/_expected/es/main1.js b/test/chunking-form/samples/min-chunk-size/merge-small-side-effect-chunks/_expected/es/main1.js new file mode 100644 index 00000000000..9cfdcd426b8 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-small-side-effect-chunks/_expected/es/main1.js @@ -0,0 +1,4 @@ +const small = '12345678901234567890123456789012345678901234567890'; +console.log('effect'); + +export { small }; diff --git a/test/chunking-form/samples/min-chunk-size/merge-small-side-effect-chunks/_expected/es/main2.js b/test/chunking-form/samples/min-chunk-size/merge-small-side-effect-chunks/_expected/es/main2.js new file mode 100644 index 00000000000..e2bdb207da6 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-small-side-effect-chunks/_expected/es/main2.js @@ -0,0 +1 @@ +export { small } from './main1.js'; diff --git a/test/chunking-form/samples/min-chunk-size/merge-small-side-effect-chunks/_expected/system/main1.js b/test/chunking-form/samples/min-chunk-size/merge-small-side-effect-chunks/_expected/system/main1.js new file mode 100644 index 00000000000..8438bdca4fd --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-small-side-effect-chunks/_expected/system/main1.js @@ -0,0 +1,11 @@ +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + + const small = exports("small", '12345678901234567890123456789012345678901234567890'); + console.log('effect'); + + }) + }; +})); diff --git a/test/chunking-form/samples/min-chunk-size/merge-small-side-effect-chunks/_expected/system/main2.js b/test/chunking-form/samples/min-chunk-size/merge-small-side-effect-chunks/_expected/system/main2.js new file mode 100644 index 00000000000..9a35b1cd4d2 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-small-side-effect-chunks/_expected/system/main2.js @@ -0,0 +1,13 @@ +System.register(['./main1.js'], (function (exports) { + 'use strict'; + return { + setters: [function (module) { + exports("small", module.small); + }], + execute: (function () { + + + + }) + }; +})); diff --git a/test/chunking-form/samples/min-chunk-size/merge-small-side-effect-chunks/big.js b/test/chunking-form/samples/min-chunk-size/merge-small-side-effect-chunks/big.js new file mode 100644 index 00000000000..aa804924cba --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-small-side-effect-chunks/big.js @@ -0,0 +1 @@ +export const big = '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'; diff --git a/test/chunking-form/samples/min-chunk-size/merge-small-side-effect-chunks/main1.js b/test/chunking-form/samples/min-chunk-size/merge-small-side-effect-chunks/main1.js new file mode 100644 index 00000000000..985a5976f8e --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-small-side-effect-chunks/main1.js @@ -0,0 +1 @@ +export { small } from './small'; diff --git a/test/chunking-form/samples/min-chunk-size/merge-small-side-effect-chunks/main2.js b/test/chunking-form/samples/min-chunk-size/merge-small-side-effect-chunks/main2.js new file mode 100644 index 00000000000..985a5976f8e --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-small-side-effect-chunks/main2.js @@ -0,0 +1 @@ +export { small } from './small'; diff --git a/test/chunking-form/samples/min-chunk-size/merge-small-side-effect-chunks/small.js b/test/chunking-form/samples/min-chunk-size/merge-small-side-effect-chunks/small.js new file mode 100644 index 00000000000..15cd7b80445 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-small-side-effect-chunks/small.js @@ -0,0 +1,2 @@ +export const small = '12345678901234567890123456789012345678901234567890'; +console.log('effect'); diff --git a/test/chunking-form/samples/min-chunk-size/merge-unrelated/_config.js b/test/chunking-form/samples/min-chunk-size/merge-unrelated/_config.js new file mode 100644 index 00000000000..5fabd4dea86 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-unrelated/_config.js @@ -0,0 +1,9 @@ +module.exports = defineTest({ + description: 'merges unrelated small chunks if there is no better alternative', + options: { + input: ['main1.js', 'main2.js', 'main3.js'], + output: { + experimentalMinChunkSize: 100 + } + } +}); diff --git a/test/chunking-form/samples/min-chunk-size/merge-unrelated/_expected/amd/generated-small2.js b/test/chunking-form/samples/min-chunk-size/merge-unrelated/_expected/amd/generated-small2.js new file mode 100644 index 00000000000..0329d284b07 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-unrelated/_expected/amd/generated-small2.js @@ -0,0 +1,10 @@ +define(['exports'], (function (exports) { 'use strict'; + + const small1 = '1'; + + const small2 = '1'; + + exports.small1 = small1; + exports.small2 = small2; + +})); diff --git a/test/chunking-form/samples/min-chunk-size/merge-unrelated/_expected/amd/main1.js b/test/chunking-form/samples/min-chunk-size/merge-unrelated/_expected/amd/main1.js new file mode 100644 index 00000000000..189d163ea42 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-unrelated/_expected/amd/main1.js @@ -0,0 +1,5 @@ +define(['./generated-small2'], (function (small2) { 'use strict'; + + console.log(small2.small1, small2.small2); + +})); diff --git a/test/chunking-form/samples/min-chunk-size/merge-unrelated/_expected/amd/main2.js b/test/chunking-form/samples/min-chunk-size/merge-unrelated/_expected/amd/main2.js new file mode 100644 index 00000000000..933e6f8fc01 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-unrelated/_expected/amd/main2.js @@ -0,0 +1,5 @@ +define(['./generated-small2'], (function (small2) { 'use strict'; + + console.log(small2.small1); + +})); diff --git a/test/chunking-form/samples/min-chunk-size/merge-unrelated/_expected/amd/main3.js b/test/chunking-form/samples/min-chunk-size/merge-unrelated/_expected/amd/main3.js new file mode 100644 index 00000000000..f7a8bc388f2 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-unrelated/_expected/amd/main3.js @@ -0,0 +1,5 @@ +define(['./generated-small2'], (function (small2) { 'use strict'; + + console.log(small2.small2); + +})); diff --git a/test/chunking-form/samples/min-chunk-size/merge-unrelated/_expected/cjs/generated-small2.js b/test/chunking-form/samples/min-chunk-size/merge-unrelated/_expected/cjs/generated-small2.js new file mode 100644 index 00000000000..73ed4392701 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-unrelated/_expected/cjs/generated-small2.js @@ -0,0 +1,8 @@ +'use strict'; + +const small1 = '1'; + +const small2 = '1'; + +exports.small1 = small1; +exports.small2 = small2; diff --git a/test/chunking-form/samples/min-chunk-size/merge-unrelated/_expected/cjs/main1.js b/test/chunking-form/samples/min-chunk-size/merge-unrelated/_expected/cjs/main1.js new file mode 100644 index 00000000000..dd3c763d78a --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-unrelated/_expected/cjs/main1.js @@ -0,0 +1,5 @@ +'use strict'; + +var small2 = require('./generated-small2.js'); + +console.log(small2.small1, small2.small2); diff --git a/test/chunking-form/samples/min-chunk-size/merge-unrelated/_expected/cjs/main2.js b/test/chunking-form/samples/min-chunk-size/merge-unrelated/_expected/cjs/main2.js new file mode 100644 index 00000000000..680aff2ffe1 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-unrelated/_expected/cjs/main2.js @@ -0,0 +1,5 @@ +'use strict'; + +var small2 = require('./generated-small2.js'); + +console.log(small2.small1); diff --git a/test/chunking-form/samples/min-chunk-size/merge-unrelated/_expected/cjs/main3.js b/test/chunking-form/samples/min-chunk-size/merge-unrelated/_expected/cjs/main3.js new file mode 100644 index 00000000000..cfd5e278dbd --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-unrelated/_expected/cjs/main3.js @@ -0,0 +1,5 @@ +'use strict'; + +var small2 = require('./generated-small2.js'); + +console.log(small2.small2); diff --git a/test/chunking-form/samples/min-chunk-size/merge-unrelated/_expected/es/generated-small2.js b/test/chunking-form/samples/min-chunk-size/merge-unrelated/_expected/es/generated-small2.js new file mode 100644 index 00000000000..2f0c5c65af4 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-unrelated/_expected/es/generated-small2.js @@ -0,0 +1,5 @@ +const small1 = '1'; + +const small2 = '1'; + +export { small2 as a, small1 as s }; diff --git a/test/chunking-form/samples/min-chunk-size/merge-unrelated/_expected/es/main1.js b/test/chunking-form/samples/min-chunk-size/merge-unrelated/_expected/es/main1.js new file mode 100644 index 00000000000..c0544864943 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-unrelated/_expected/es/main1.js @@ -0,0 +1,3 @@ +import { s as small1, a as small2 } from './generated-small2.js'; + +console.log(small1, small2); diff --git a/test/chunking-form/samples/min-chunk-size/merge-unrelated/_expected/es/main2.js b/test/chunking-form/samples/min-chunk-size/merge-unrelated/_expected/es/main2.js new file mode 100644 index 00000000000..e30e3ce1ca9 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-unrelated/_expected/es/main2.js @@ -0,0 +1,3 @@ +import { s as small1 } from './generated-small2.js'; + +console.log(small1); diff --git a/test/chunking-form/samples/min-chunk-size/merge-unrelated/_expected/es/main3.js b/test/chunking-form/samples/min-chunk-size/merge-unrelated/_expected/es/main3.js new file mode 100644 index 00000000000..edc8ae8b0c0 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-unrelated/_expected/es/main3.js @@ -0,0 +1,3 @@ +import { a as small2 } from './generated-small2.js'; + +console.log(small2); diff --git a/test/chunking-form/samples/min-chunk-size/merge-unrelated/_expected/system/generated-small2.js b/test/chunking-form/samples/min-chunk-size/merge-unrelated/_expected/system/generated-small2.js new file mode 100644 index 00000000000..a7fb732434f --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-unrelated/_expected/system/generated-small2.js @@ -0,0 +1,12 @@ +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + + const small1 = exports("s", '1'); + + const small2 = exports("a", '1'); + + }) + }; +})); diff --git a/test/chunking-form/samples/min-chunk-size/merge-unrelated/_expected/system/main1.js b/test/chunking-form/samples/min-chunk-size/merge-unrelated/_expected/system/main1.js new file mode 100644 index 00000000000..cfb4b5a9ceb --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-unrelated/_expected/system/main1.js @@ -0,0 +1,15 @@ +System.register(['./generated-small2.js'], (function () { + 'use strict'; + var small1, small2; + return { + setters: [function (module) { + small1 = module.s; + small2 = module.a; + }], + execute: (function () { + + console.log(small1, small2); + + }) + }; +})); diff --git a/test/chunking-form/samples/min-chunk-size/merge-unrelated/_expected/system/main2.js b/test/chunking-form/samples/min-chunk-size/merge-unrelated/_expected/system/main2.js new file mode 100644 index 00000000000..a9fde34525d --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-unrelated/_expected/system/main2.js @@ -0,0 +1,14 @@ +System.register(['./generated-small2.js'], (function () { + 'use strict'; + var small1; + return { + setters: [function (module) { + small1 = module.s; + }], + execute: (function () { + + console.log(small1); + + }) + }; +})); diff --git a/test/chunking-form/samples/min-chunk-size/merge-unrelated/_expected/system/main3.js b/test/chunking-form/samples/min-chunk-size/merge-unrelated/_expected/system/main3.js new file mode 100644 index 00000000000..114aa710b39 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-unrelated/_expected/system/main3.js @@ -0,0 +1,14 @@ +System.register(['./generated-small2.js'], (function () { + 'use strict'; + var small2; + return { + setters: [function (module) { + small2 = module.a; + }], + execute: (function () { + + console.log(small2); + + }) + }; +})); diff --git a/test/chunking-form/samples/min-chunk-size/merge-unrelated/main1.js b/test/chunking-form/samples/min-chunk-size/merge-unrelated/main1.js new file mode 100644 index 00000000000..b8159efe933 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-unrelated/main1.js @@ -0,0 +1,4 @@ +import { small1 } from './small1'; +import { small2 } from './small2'; + +console.log(small1, small2); diff --git a/test/chunking-form/samples/min-chunk-size/merge-unrelated/main2.js b/test/chunking-form/samples/min-chunk-size/merge-unrelated/main2.js new file mode 100644 index 00000000000..e7180b14932 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-unrelated/main2.js @@ -0,0 +1,3 @@ +import { small1 } from './small1'; + +console.log(small1); diff --git a/test/chunking-form/samples/min-chunk-size/merge-unrelated/main3.js b/test/chunking-form/samples/min-chunk-size/merge-unrelated/main3.js new file mode 100644 index 00000000000..5104c70fc70 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-unrelated/main3.js @@ -0,0 +1,3 @@ +import { small2 } from './small2'; + +console.log(small2); diff --git a/test/chunking-form/samples/min-chunk-size/merge-unrelated/small1.js b/test/chunking-form/samples/min-chunk-size/merge-unrelated/small1.js new file mode 100644 index 00000000000..7d722b9f6d7 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-unrelated/small1.js @@ -0,0 +1 @@ +export const small1 = '1'; diff --git a/test/chunking-form/samples/min-chunk-size/merge-unrelated/small2.js b/test/chunking-form/samples/min-chunk-size/merge-unrelated/small2.js new file mode 100644 index 00000000000..53ce25e7164 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-unrelated/small2.js @@ -0,0 +1 @@ +export const small2 = '1'; diff --git a/test/chunking-form/samples/min-chunk-size/merge-with-entry-side-effect/_config.js b/test/chunking-form/samples/min-chunk-size/merge-with-entry-side-effect/_config.js new file mode 100644 index 00000000000..2898b6db739 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-with-entry-side-effect/_config.js @@ -0,0 +1,9 @@ +module.exports = defineTest({ + description: 'merges dynamic imports even when the entry has side effects', + options: { + input: ['main.js'], + output: { + experimentalMinChunkSize: 100 + } + } +}); diff --git a/test/chunking-form/samples/min-chunk-size/merge-with-entry-side-effect/_expected/amd/main.js b/test/chunking-form/samples/min-chunk-size/merge-with-entry-side-effect/_expected/amd/main.js new file mode 100644 index 00000000000..eea30a3255e --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-with-entry-side-effect/_expected/amd/main.js @@ -0,0 +1,26 @@ +define((function () { 'use strict'; + + const s1 = x => x; + + const { d1: d1$1 } = Promise.resolve().then(function () { return dynamic1; }); + const { d2: d2$1 } = Promise.resolve().then(function () { return dynamic2; }); + + console.log(s1, d1$1, d2$1); + + const s2 = x => x; + + const d1 = x => s1(s2(x)); + + var dynamic1 = /*#__PURE__*/Object.freeze({ + __proto__: null, + d1: d1 + }); + + const d2 = x => s1(s2(x)); + + var dynamic2 = /*#__PURE__*/Object.freeze({ + __proto__: null, + d2: d2 + }); + +})); diff --git a/test/chunking-form/samples/min-chunk-size/merge-with-entry-side-effect/_expected/cjs/main.js b/test/chunking-form/samples/min-chunk-size/merge-with-entry-side-effect/_expected/cjs/main.js new file mode 100644 index 00000000000..a79cdc8e851 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-with-entry-side-effect/_expected/cjs/main.js @@ -0,0 +1,24 @@ +'use strict'; + +const s1 = x => x; + +const { d1: d1$1 } = Promise.resolve().then(function () { return dynamic1; }); +const { d2: d2$1 } = Promise.resolve().then(function () { return dynamic2; }); + +console.log(s1, d1$1, d2$1); + +const s2 = x => x; + +const d1 = x => s1(s2(x)); + +var dynamic1 = /*#__PURE__*/Object.freeze({ + __proto__: null, + d1: d1 +}); + +const d2 = x => s1(s2(x)); + +var dynamic2 = /*#__PURE__*/Object.freeze({ + __proto__: null, + d2: d2 +}); diff --git a/test/chunking-form/samples/min-chunk-size/merge-with-entry-side-effect/_expected/es/main.js b/test/chunking-form/samples/min-chunk-size/merge-with-entry-side-effect/_expected/es/main.js new file mode 100644 index 00000000000..538fbf2226e --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-with-entry-side-effect/_expected/es/main.js @@ -0,0 +1,22 @@ +const s1 = x => x; + +const { d1: d1$1 } = Promise.resolve().then(function () { return dynamic1; }); +const { d2: d2$1 } = Promise.resolve().then(function () { return dynamic2; }); + +console.log(s1, d1$1, d2$1); + +const s2 = x => x; + +const d1 = x => s1(s2(x)); + +var dynamic1 = /*#__PURE__*/Object.freeze({ + __proto__: null, + d1: d1 +}); + +const d2 = x => s1(s2(x)); + +var dynamic2 = /*#__PURE__*/Object.freeze({ + __proto__: null, + d2: d2 +}); diff --git a/test/chunking-form/samples/min-chunk-size/merge-with-entry-side-effect/_expected/system/main.js b/test/chunking-form/samples/min-chunk-size/merge-with-entry-side-effect/_expected/system/main.js new file mode 100644 index 00000000000..59f4c8471f0 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-with-entry-side-effect/_expected/system/main.js @@ -0,0 +1,31 @@ +System.register([], (function () { + 'use strict'; + return { + execute: (function () { + + const s1 = x => x; + + const { d1: d1$1 } = Promise.resolve().then(function () { return dynamic1; }); + const { d2: d2$1 } = Promise.resolve().then(function () { return dynamic2; }); + + console.log(s1, d1$1, d2$1); + + const s2 = x => x; + + const d1 = x => s1(s2(x)); + + var dynamic1 = /*#__PURE__*/Object.freeze({ + __proto__: null, + d1: d1 + }); + + const d2 = x => s1(s2(x)); + + var dynamic2 = /*#__PURE__*/Object.freeze({ + __proto__: null, + d2: d2 + }); + + }) + }; +})); diff --git a/test/chunking-form/samples/min-chunk-size/merge-with-entry-side-effect/dynamic-1.js b/test/chunking-form/samples/min-chunk-size/merge-with-entry-side-effect/dynamic-1.js new file mode 100644 index 00000000000..bd33c035dd2 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-with-entry-side-effect/dynamic-1.js @@ -0,0 +1,4 @@ +import { s1 } from "./shared-1.js"; +import { s2 } from "./shared-2.js"; + +export const d1 = x => s1(s2(x)); diff --git a/test/chunking-form/samples/min-chunk-size/merge-with-entry-side-effect/dynamic-2.js b/test/chunking-form/samples/min-chunk-size/merge-with-entry-side-effect/dynamic-2.js new file mode 100644 index 00000000000..14f82112081 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-with-entry-side-effect/dynamic-2.js @@ -0,0 +1,4 @@ +import { s1 } from './shared-1.js'; +import { s2 } from './shared-2.js'; + +export const d2 = x => s1(s2(x)); diff --git a/test/chunking-form/samples/min-chunk-size/merge-with-entry-side-effect/main.js b/test/chunking-form/samples/min-chunk-size/merge-with-entry-side-effect/main.js new file mode 100644 index 00000000000..4b8de68899d --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-with-entry-side-effect/main.js @@ -0,0 +1,6 @@ +import { s1 } from "./shared-1.js"; + +const { d1 } = import('./dynamic-1.js'); +const { d2 } = import('./dynamic-2.js'); + +console.log(s1, d1, d2); diff --git a/test/chunking-form/samples/min-chunk-size/merge-with-entry-side-effect/shared-1.js b/test/chunking-form/samples/min-chunk-size/merge-with-entry-side-effect/shared-1.js new file mode 100644 index 00000000000..3d5d72780ff --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-with-entry-side-effect/shared-1.js @@ -0,0 +1 @@ +export const s1 = x => x; diff --git a/test/chunking-form/samples/min-chunk-size/merge-with-entry-side-effect/shared-2.js b/test/chunking-form/samples/min-chunk-size/merge-with-entry-side-effect/shared-2.js new file mode 100644 index 00000000000..48fba687d1a --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/merge-with-entry-side-effect/shared-2.js @@ -0,0 +1 @@ +export const s2 = x => x; diff --git a/test/chunking-form/samples/min-chunk-size/no-merge-for-big-chunks/_config.js b/test/chunking-form/samples/min-chunk-size/no-merge-for-big-chunks/_config.js new file mode 100644 index 00000000000..0a5af5cbeb6 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/no-merge-for-big-chunks/_config.js @@ -0,0 +1,9 @@ +module.exports = defineTest({ + description: 'does not merge chunks if all chunks are below the size limit', + options: { + input: ['main1.js', 'main2.js', 'main3.js'], + output: { + experimentalMinChunkSize: 1 + } + } +}); diff --git a/test/chunking-form/samples/min-chunk-size/no-merge-for-big-chunks/_expected/amd/generated-big.js b/test/chunking-form/samples/min-chunk-size/no-merge-for-big-chunks/_expected/amd/generated-big.js new file mode 100644 index 00000000000..1c86c5f3245 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/no-merge-for-big-chunks/_expected/amd/generated-big.js @@ -0,0 +1,7 @@ +define(['exports'], (function (exports) { 'use strict'; + + const big = '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'; + + exports.big = big; + +})); diff --git a/test/chunking-form/samples/min-chunk-size/no-merge-for-big-chunks/_expected/amd/generated-small.js b/test/chunking-form/samples/min-chunk-size/no-merge-for-big-chunks/_expected/amd/generated-small.js new file mode 100644 index 00000000000..ee89ef5bdf5 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/no-merge-for-big-chunks/_expected/amd/generated-small.js @@ -0,0 +1,7 @@ +define(['exports'], (function (exports) { 'use strict'; + + const small = '1'; + + exports.small = small; + +})); diff --git a/test/chunking-form/samples/min-chunk-size/no-merge-for-big-chunks/_expected/amd/main1.js b/test/chunking-form/samples/min-chunk-size/no-merge-for-big-chunks/_expected/amd/main1.js new file mode 100644 index 00000000000..9f1e89308c2 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/no-merge-for-big-chunks/_expected/amd/main1.js @@ -0,0 +1,5 @@ +define(['./generated-big', './generated-small'], (function (big, small) { 'use strict'; + + console.log(big.big, small.small); + +})); diff --git a/test/chunking-form/samples/min-chunk-size/no-merge-for-big-chunks/_expected/amd/main2.js b/test/chunking-form/samples/min-chunk-size/no-merge-for-big-chunks/_expected/amd/main2.js new file mode 100644 index 00000000000..9f1e89308c2 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/no-merge-for-big-chunks/_expected/amd/main2.js @@ -0,0 +1,5 @@ +define(['./generated-big', './generated-small'], (function (big, small) { 'use strict'; + + console.log(big.big, small.small); + +})); diff --git a/test/chunking-form/samples/min-chunk-size/no-merge-for-big-chunks/_expected/amd/main3.js b/test/chunking-form/samples/min-chunk-size/no-merge-for-big-chunks/_expected/amd/main3.js new file mode 100644 index 00000000000..1bddbc92f18 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/no-merge-for-big-chunks/_expected/amd/main3.js @@ -0,0 +1,5 @@ +define(['./generated-big'], (function (big) { 'use strict'; + + console.log(big.big); + +})); diff --git a/test/chunking-form/samples/min-chunk-size/no-merge-for-big-chunks/_expected/cjs/generated-big.js b/test/chunking-form/samples/min-chunk-size/no-merge-for-big-chunks/_expected/cjs/generated-big.js new file mode 100644 index 00000000000..02f83e81fc3 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/no-merge-for-big-chunks/_expected/cjs/generated-big.js @@ -0,0 +1,5 @@ +'use strict'; + +const big = '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'; + +exports.big = big; diff --git a/test/chunking-form/samples/min-chunk-size/no-merge-for-big-chunks/_expected/cjs/generated-small.js b/test/chunking-form/samples/min-chunk-size/no-merge-for-big-chunks/_expected/cjs/generated-small.js new file mode 100644 index 00000000000..c7bcc6a74b7 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/no-merge-for-big-chunks/_expected/cjs/generated-small.js @@ -0,0 +1,5 @@ +'use strict'; + +const small = '1'; + +exports.small = small; diff --git a/test/chunking-form/samples/min-chunk-size/no-merge-for-big-chunks/_expected/cjs/main1.js b/test/chunking-form/samples/min-chunk-size/no-merge-for-big-chunks/_expected/cjs/main1.js new file mode 100644 index 00000000000..b3a7679c4a0 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/no-merge-for-big-chunks/_expected/cjs/main1.js @@ -0,0 +1,6 @@ +'use strict'; + +var big = require('./generated-big.js'); +var small = require('./generated-small.js'); + +console.log(big.big, small.small); diff --git a/test/chunking-form/samples/min-chunk-size/no-merge-for-big-chunks/_expected/cjs/main2.js b/test/chunking-form/samples/min-chunk-size/no-merge-for-big-chunks/_expected/cjs/main2.js new file mode 100644 index 00000000000..b3a7679c4a0 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/no-merge-for-big-chunks/_expected/cjs/main2.js @@ -0,0 +1,6 @@ +'use strict'; + +var big = require('./generated-big.js'); +var small = require('./generated-small.js'); + +console.log(big.big, small.small); diff --git a/test/chunking-form/samples/min-chunk-size/no-merge-for-big-chunks/_expected/cjs/main3.js b/test/chunking-form/samples/min-chunk-size/no-merge-for-big-chunks/_expected/cjs/main3.js new file mode 100644 index 00000000000..5a574b96fe4 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/no-merge-for-big-chunks/_expected/cjs/main3.js @@ -0,0 +1,5 @@ +'use strict'; + +var big = require('./generated-big.js'); + +console.log(big.big); diff --git a/test/chunking-form/samples/min-chunk-size/no-merge-for-big-chunks/_expected/es/generated-big.js b/test/chunking-form/samples/min-chunk-size/no-merge-for-big-chunks/_expected/es/generated-big.js new file mode 100644 index 00000000000..f26e52dae36 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/no-merge-for-big-chunks/_expected/es/generated-big.js @@ -0,0 +1,3 @@ +const big = '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'; + +export { big as b }; diff --git a/test/chunking-form/samples/min-chunk-size/no-merge-for-big-chunks/_expected/es/generated-small.js b/test/chunking-form/samples/min-chunk-size/no-merge-for-big-chunks/_expected/es/generated-small.js new file mode 100644 index 00000000000..7b56a806f80 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/no-merge-for-big-chunks/_expected/es/generated-small.js @@ -0,0 +1,3 @@ +const small = '1'; + +export { small as s }; diff --git a/test/chunking-form/samples/min-chunk-size/no-merge-for-big-chunks/_expected/es/main1.js b/test/chunking-form/samples/min-chunk-size/no-merge-for-big-chunks/_expected/es/main1.js new file mode 100644 index 00000000000..003370663b0 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/no-merge-for-big-chunks/_expected/es/main1.js @@ -0,0 +1,4 @@ +import { b as big } from './generated-big.js'; +import { s as small } from './generated-small.js'; + +console.log(big, small); diff --git a/test/chunking-form/samples/min-chunk-size/no-merge-for-big-chunks/_expected/es/main2.js b/test/chunking-form/samples/min-chunk-size/no-merge-for-big-chunks/_expected/es/main2.js new file mode 100644 index 00000000000..003370663b0 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/no-merge-for-big-chunks/_expected/es/main2.js @@ -0,0 +1,4 @@ +import { b as big } from './generated-big.js'; +import { s as small } from './generated-small.js'; + +console.log(big, small); diff --git a/test/chunking-form/samples/min-chunk-size/no-merge-for-big-chunks/_expected/es/main3.js b/test/chunking-form/samples/min-chunk-size/no-merge-for-big-chunks/_expected/es/main3.js new file mode 100644 index 00000000000..00748695997 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/no-merge-for-big-chunks/_expected/es/main3.js @@ -0,0 +1,3 @@ +import { b as big } from './generated-big.js'; + +console.log(big); diff --git a/test/chunking-form/samples/min-chunk-size/no-merge-for-big-chunks/_expected/system/generated-big.js b/test/chunking-form/samples/min-chunk-size/no-merge-for-big-chunks/_expected/system/generated-big.js new file mode 100644 index 00000000000..ee6fe80459b --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/no-merge-for-big-chunks/_expected/system/generated-big.js @@ -0,0 +1,10 @@ +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + + const big = exports("b", '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'); + + }) + }; +})); diff --git a/test/chunking-form/samples/min-chunk-size/no-merge-for-big-chunks/_expected/system/generated-small.js b/test/chunking-form/samples/min-chunk-size/no-merge-for-big-chunks/_expected/system/generated-small.js new file mode 100644 index 00000000000..b8f4c6b63ef --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/no-merge-for-big-chunks/_expected/system/generated-small.js @@ -0,0 +1,10 @@ +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + + const small = exports("s", '1'); + + }) + }; +})); diff --git a/test/chunking-form/samples/min-chunk-size/no-merge-for-big-chunks/_expected/system/main1.js b/test/chunking-form/samples/min-chunk-size/no-merge-for-big-chunks/_expected/system/main1.js new file mode 100644 index 00000000000..1b80803b9e5 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/no-merge-for-big-chunks/_expected/system/main1.js @@ -0,0 +1,16 @@ +System.register(['./generated-big.js', './generated-small.js'], (function () { + 'use strict'; + var big, small; + return { + setters: [function (module) { + big = module.b; + }, function (module) { + small = module.s; + }], + execute: (function () { + + console.log(big, small); + + }) + }; +})); diff --git a/test/chunking-form/samples/min-chunk-size/no-merge-for-big-chunks/_expected/system/main2.js b/test/chunking-form/samples/min-chunk-size/no-merge-for-big-chunks/_expected/system/main2.js new file mode 100644 index 00000000000..1b80803b9e5 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/no-merge-for-big-chunks/_expected/system/main2.js @@ -0,0 +1,16 @@ +System.register(['./generated-big.js', './generated-small.js'], (function () { + 'use strict'; + var big, small; + return { + setters: [function (module) { + big = module.b; + }, function (module) { + small = module.s; + }], + execute: (function () { + + console.log(big, small); + + }) + }; +})); diff --git a/test/chunking-form/samples/min-chunk-size/no-merge-for-big-chunks/_expected/system/main3.js b/test/chunking-form/samples/min-chunk-size/no-merge-for-big-chunks/_expected/system/main3.js new file mode 100644 index 00000000000..9d92d0a9972 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/no-merge-for-big-chunks/_expected/system/main3.js @@ -0,0 +1,14 @@ +System.register(['./generated-big.js'], (function () { + 'use strict'; + var big; + return { + setters: [function (module) { + big = module.b; + }], + execute: (function () { + + console.log(big); + + }) + }; +})); diff --git a/test/chunking-form/samples/min-chunk-size/no-merge-for-big-chunks/big.js b/test/chunking-form/samples/min-chunk-size/no-merge-for-big-chunks/big.js new file mode 100644 index 00000000000..aa804924cba --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/no-merge-for-big-chunks/big.js @@ -0,0 +1 @@ +export const big = '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'; diff --git a/test/chunking-form/samples/min-chunk-size/no-merge-for-big-chunks/main1.js b/test/chunking-form/samples/min-chunk-size/no-merge-for-big-chunks/main1.js new file mode 100644 index 00000000000..ca84399ef67 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/no-merge-for-big-chunks/main1.js @@ -0,0 +1,4 @@ +import { big } from './big'; +import { small } from './small'; + +console.log(big, small); diff --git a/test/chunking-form/samples/min-chunk-size/no-merge-for-big-chunks/main2.js b/test/chunking-form/samples/min-chunk-size/no-merge-for-big-chunks/main2.js new file mode 100644 index 00000000000..ca84399ef67 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/no-merge-for-big-chunks/main2.js @@ -0,0 +1,4 @@ +import { big } from './big'; +import { small } from './small'; + +console.log(big, small); diff --git a/test/chunking-form/samples/min-chunk-size/no-merge-for-big-chunks/main3.js b/test/chunking-form/samples/min-chunk-size/no-merge-for-big-chunks/main3.js new file mode 100644 index 00000000000..99752c1c3b4 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/no-merge-for-big-chunks/main3.js @@ -0,0 +1,3 @@ +import { big } from './big'; + +console.log(big); diff --git a/test/chunking-form/samples/min-chunk-size/no-merge-for-big-chunks/small.js b/test/chunking-form/samples/min-chunk-size/no-merge-for-big-chunks/small.js new file mode 100644 index 00000000000..64e15634102 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/no-merge-for-big-chunks/small.js @@ -0,0 +1 @@ +export const small = '1'; diff --git a/test/chunking-form/samples/min-chunk-size/no-merge-side-effects/_config.js b/test/chunking-form/samples/min-chunk-size/no-merge-side-effects/_config.js new file mode 100644 index 00000000000..f45f896c20c --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/no-merge-side-effects/_config.js @@ -0,0 +1,9 @@ +module.exports = defineTest({ + description: 'does not merge small chunks that have side effects', + options: { + input: ['main1.js', 'main2.js', 'main3.js'], + output: { + experimentalMinChunkSize: 100 + } + } +}); diff --git a/test/chunking-form/samples/min-chunk-size/no-merge-side-effects/_expected/amd/generated-big.js b/test/chunking-form/samples/min-chunk-size/no-merge-side-effects/_expected/amd/generated-big.js new file mode 100644 index 00000000000..1c86c5f3245 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/no-merge-side-effects/_expected/amd/generated-big.js @@ -0,0 +1,7 @@ +define(['exports'], (function (exports) { 'use strict'; + + const big = '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'; + + exports.big = big; + +})); diff --git a/test/chunking-form/samples/min-chunk-size/no-merge-side-effects/_expected/amd/generated-small.js b/test/chunking-form/samples/min-chunk-size/no-merge-side-effects/_expected/amd/generated-small.js new file mode 100644 index 00000000000..60ddec3c69f --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/no-merge-side-effects/_expected/amd/generated-small.js @@ -0,0 +1,8 @@ +define(['exports'], (function (exports) { 'use strict'; + + console.log('effect'); + const small = '1'; + + exports.small = small; + +})); diff --git a/test/chunking-form/samples/min-chunk-size/no-merge-side-effects/_expected/amd/main1.js b/test/chunking-form/samples/min-chunk-size/no-merge-side-effects/_expected/amd/main1.js new file mode 100644 index 00000000000..9f1e89308c2 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/no-merge-side-effects/_expected/amd/main1.js @@ -0,0 +1,5 @@ +define(['./generated-big', './generated-small'], (function (big, small) { 'use strict'; + + console.log(big.big, small.small); + +})); diff --git a/test/chunking-form/samples/min-chunk-size/no-merge-side-effects/_expected/amd/main2.js b/test/chunking-form/samples/min-chunk-size/no-merge-side-effects/_expected/amd/main2.js new file mode 100644 index 00000000000..9f1e89308c2 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/no-merge-side-effects/_expected/amd/main2.js @@ -0,0 +1,5 @@ +define(['./generated-big', './generated-small'], (function (big, small) { 'use strict'; + + console.log(big.big, small.small); + +})); diff --git a/test/chunking-form/samples/min-chunk-size/no-merge-side-effects/_expected/amd/main3.js b/test/chunking-form/samples/min-chunk-size/no-merge-side-effects/_expected/amd/main3.js new file mode 100644 index 00000000000..1bddbc92f18 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/no-merge-side-effects/_expected/amd/main3.js @@ -0,0 +1,5 @@ +define(['./generated-big'], (function (big) { 'use strict'; + + console.log(big.big); + +})); diff --git a/test/chunking-form/samples/min-chunk-size/no-merge-side-effects/_expected/cjs/generated-big.js b/test/chunking-form/samples/min-chunk-size/no-merge-side-effects/_expected/cjs/generated-big.js new file mode 100644 index 00000000000..02f83e81fc3 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/no-merge-side-effects/_expected/cjs/generated-big.js @@ -0,0 +1,5 @@ +'use strict'; + +const big = '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'; + +exports.big = big; diff --git a/test/chunking-form/samples/min-chunk-size/no-merge-side-effects/_expected/cjs/generated-small.js b/test/chunking-form/samples/min-chunk-size/no-merge-side-effects/_expected/cjs/generated-small.js new file mode 100644 index 00000000000..f28ad7e891d --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/no-merge-side-effects/_expected/cjs/generated-small.js @@ -0,0 +1,6 @@ +'use strict'; + +console.log('effect'); +const small = '1'; + +exports.small = small; diff --git a/test/chunking-form/samples/min-chunk-size/no-merge-side-effects/_expected/cjs/main1.js b/test/chunking-form/samples/min-chunk-size/no-merge-side-effects/_expected/cjs/main1.js new file mode 100644 index 00000000000..b3a7679c4a0 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/no-merge-side-effects/_expected/cjs/main1.js @@ -0,0 +1,6 @@ +'use strict'; + +var big = require('./generated-big.js'); +var small = require('./generated-small.js'); + +console.log(big.big, small.small); diff --git a/test/chunking-form/samples/min-chunk-size/no-merge-side-effects/_expected/cjs/main2.js b/test/chunking-form/samples/min-chunk-size/no-merge-side-effects/_expected/cjs/main2.js new file mode 100644 index 00000000000..b3a7679c4a0 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/no-merge-side-effects/_expected/cjs/main2.js @@ -0,0 +1,6 @@ +'use strict'; + +var big = require('./generated-big.js'); +var small = require('./generated-small.js'); + +console.log(big.big, small.small); diff --git a/test/chunking-form/samples/min-chunk-size/no-merge-side-effects/_expected/cjs/main3.js b/test/chunking-form/samples/min-chunk-size/no-merge-side-effects/_expected/cjs/main3.js new file mode 100644 index 00000000000..5a574b96fe4 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/no-merge-side-effects/_expected/cjs/main3.js @@ -0,0 +1,5 @@ +'use strict'; + +var big = require('./generated-big.js'); + +console.log(big.big); diff --git a/test/chunking-form/samples/min-chunk-size/no-merge-side-effects/_expected/es/generated-big.js b/test/chunking-form/samples/min-chunk-size/no-merge-side-effects/_expected/es/generated-big.js new file mode 100644 index 00000000000..f26e52dae36 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/no-merge-side-effects/_expected/es/generated-big.js @@ -0,0 +1,3 @@ +const big = '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'; + +export { big as b }; diff --git a/test/chunking-form/samples/min-chunk-size/no-merge-side-effects/_expected/es/generated-small.js b/test/chunking-form/samples/min-chunk-size/no-merge-side-effects/_expected/es/generated-small.js new file mode 100644 index 00000000000..71d7aa578ee --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/no-merge-side-effects/_expected/es/generated-small.js @@ -0,0 +1,4 @@ +console.log('effect'); +const small = '1'; + +export { small as s }; diff --git a/test/chunking-form/samples/min-chunk-size/no-merge-side-effects/_expected/es/main1.js b/test/chunking-form/samples/min-chunk-size/no-merge-side-effects/_expected/es/main1.js new file mode 100644 index 00000000000..003370663b0 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/no-merge-side-effects/_expected/es/main1.js @@ -0,0 +1,4 @@ +import { b as big } from './generated-big.js'; +import { s as small } from './generated-small.js'; + +console.log(big, small); diff --git a/test/chunking-form/samples/min-chunk-size/no-merge-side-effects/_expected/es/main2.js b/test/chunking-form/samples/min-chunk-size/no-merge-side-effects/_expected/es/main2.js new file mode 100644 index 00000000000..003370663b0 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/no-merge-side-effects/_expected/es/main2.js @@ -0,0 +1,4 @@ +import { b as big } from './generated-big.js'; +import { s as small } from './generated-small.js'; + +console.log(big, small); diff --git a/test/chunking-form/samples/min-chunk-size/no-merge-side-effects/_expected/es/main3.js b/test/chunking-form/samples/min-chunk-size/no-merge-side-effects/_expected/es/main3.js new file mode 100644 index 00000000000..00748695997 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/no-merge-side-effects/_expected/es/main3.js @@ -0,0 +1,3 @@ +import { b as big } from './generated-big.js'; + +console.log(big); diff --git a/test/chunking-form/samples/min-chunk-size/no-merge-side-effects/_expected/system/generated-big.js b/test/chunking-form/samples/min-chunk-size/no-merge-side-effects/_expected/system/generated-big.js new file mode 100644 index 00000000000..ee6fe80459b --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/no-merge-side-effects/_expected/system/generated-big.js @@ -0,0 +1,10 @@ +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + + const big = exports("b", '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'); + + }) + }; +})); diff --git a/test/chunking-form/samples/min-chunk-size/no-merge-side-effects/_expected/system/generated-small.js b/test/chunking-form/samples/min-chunk-size/no-merge-side-effects/_expected/system/generated-small.js new file mode 100644 index 00000000000..2cf3453b356 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/no-merge-side-effects/_expected/system/generated-small.js @@ -0,0 +1,11 @@ +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + + console.log('effect'); + const small = exports("s", '1'); + + }) + }; +})); diff --git a/test/chunking-form/samples/min-chunk-size/no-merge-side-effects/_expected/system/main1.js b/test/chunking-form/samples/min-chunk-size/no-merge-side-effects/_expected/system/main1.js new file mode 100644 index 00000000000..1b80803b9e5 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/no-merge-side-effects/_expected/system/main1.js @@ -0,0 +1,16 @@ +System.register(['./generated-big.js', './generated-small.js'], (function () { + 'use strict'; + var big, small; + return { + setters: [function (module) { + big = module.b; + }, function (module) { + small = module.s; + }], + execute: (function () { + + console.log(big, small); + + }) + }; +})); diff --git a/test/chunking-form/samples/min-chunk-size/no-merge-side-effects/_expected/system/main2.js b/test/chunking-form/samples/min-chunk-size/no-merge-side-effects/_expected/system/main2.js new file mode 100644 index 00000000000..1b80803b9e5 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/no-merge-side-effects/_expected/system/main2.js @@ -0,0 +1,16 @@ +System.register(['./generated-big.js', './generated-small.js'], (function () { + 'use strict'; + var big, small; + return { + setters: [function (module) { + big = module.b; + }, function (module) { + small = module.s; + }], + execute: (function () { + + console.log(big, small); + + }) + }; +})); diff --git a/test/chunking-form/samples/min-chunk-size/no-merge-side-effects/_expected/system/main3.js b/test/chunking-form/samples/min-chunk-size/no-merge-side-effects/_expected/system/main3.js new file mode 100644 index 00000000000..9d92d0a9972 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/no-merge-side-effects/_expected/system/main3.js @@ -0,0 +1,14 @@ +System.register(['./generated-big.js'], (function () { + 'use strict'; + var big; + return { + setters: [function (module) { + big = module.b; + }], + execute: (function () { + + console.log(big); + + }) + }; +})); diff --git a/test/chunking-form/samples/min-chunk-size/no-merge-side-effects/big.js b/test/chunking-form/samples/min-chunk-size/no-merge-side-effects/big.js new file mode 100644 index 00000000000..aa804924cba --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/no-merge-side-effects/big.js @@ -0,0 +1 @@ +export const big = '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'; diff --git a/test/chunking-form/samples/min-chunk-size/no-merge-side-effects/main1.js b/test/chunking-form/samples/min-chunk-size/no-merge-side-effects/main1.js new file mode 100644 index 00000000000..ca84399ef67 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/no-merge-side-effects/main1.js @@ -0,0 +1,4 @@ +import { big } from './big'; +import { small } from './small'; + +console.log(big, small); diff --git a/test/chunking-form/samples/min-chunk-size/no-merge-side-effects/main2.js b/test/chunking-form/samples/min-chunk-size/no-merge-side-effects/main2.js new file mode 100644 index 00000000000..ca84399ef67 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/no-merge-side-effects/main2.js @@ -0,0 +1,4 @@ +import { big } from './big'; +import { small } from './small'; + +console.log(big, small); diff --git a/test/chunking-form/samples/min-chunk-size/no-merge-side-effects/main3.js b/test/chunking-form/samples/min-chunk-size/no-merge-side-effects/main3.js new file mode 100644 index 00000000000..99752c1c3b4 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/no-merge-side-effects/main3.js @@ -0,0 +1,3 @@ +import { big } from './big'; + +console.log(big); diff --git a/test/chunking-form/samples/min-chunk-size/no-merge-side-effects/small.js b/test/chunking-form/samples/min-chunk-size/no-merge-side-effects/small.js new file mode 100644 index 00000000000..d41bd10033c --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/no-merge-side-effects/small.js @@ -0,0 +1,2 @@ +console.log('effect'); +export const small = '1'; diff --git a/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-a/_config.js b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-a/_config.js new file mode 100644 index 00000000000..18809bd51c7 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-a/_config.js @@ -0,0 +1,10 @@ +module.exports = defineTest({ + description: + 'when there are two valid merge targets, the one that is loaded under more similar conditions is preferred', + options: { + input: ['main1.js', 'main2.js', 'main3.js', 'main4.js'], + output: { + experimentalMinChunkSize: 100 + } + } +}); diff --git a/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-a/_expected/amd/generated-chunk1.js b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-a/_expected/amd/generated-chunk1.js new file mode 100644 index 00000000000..e8220dca082 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-a/_expected/amd/generated-chunk1.js @@ -0,0 +1,11 @@ +define(['exports'], (function (exports) { 'use strict'; + + const small = '0'; + + const big1 = + '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'; + + exports.big1 = big1; + exports.small = small; + +})); diff --git a/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-a/_expected/amd/generated-chunk2.js b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-a/_expected/amd/generated-chunk2.js new file mode 100644 index 00000000000..dd86f0a8619 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-a/_expected/amd/generated-chunk2.js @@ -0,0 +1,8 @@ +define(['exports'], (function (exports) { 'use strict'; + + const big2 = + '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'; + + exports.big2 = big2; + +})); diff --git a/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-a/_expected/amd/main1.js b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-a/_expected/amd/main1.js new file mode 100644 index 00000000000..cc2340c2087 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-a/_expected/amd/main1.js @@ -0,0 +1,5 @@ +define(['./generated-chunk1', './generated-chunk2'], (function (chunk1, chunk2) { 'use strict'; + + console.log(chunk1.small, chunk1.big1, chunk2.big2); + +})); diff --git a/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-a/_expected/amd/main2.js b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-a/_expected/amd/main2.js new file mode 100644 index 00000000000..cc2340c2087 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-a/_expected/amd/main2.js @@ -0,0 +1,5 @@ +define(['./generated-chunk1', './generated-chunk2'], (function (chunk1, chunk2) { 'use strict'; + + console.log(chunk1.small, chunk1.big1, chunk2.big2); + +})); diff --git a/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-a/_expected/amd/main3.js b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-a/_expected/amd/main3.js new file mode 100644 index 00000000000..07d3c184a7a --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-a/_expected/amd/main3.js @@ -0,0 +1,5 @@ +define(['./generated-chunk1', './generated-chunk2'], (function (chunk1, chunk2) { 'use strict'; + + console.log(chunk1.big1, chunk2.big2); + +})); diff --git a/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-a/_expected/amd/main4.js b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-a/_expected/amd/main4.js new file mode 100644 index 00000000000..a9c8374a0b5 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-a/_expected/amd/main4.js @@ -0,0 +1,5 @@ +define(['./generated-chunk2'], (function (chunk2) { 'use strict'; + + console.log(chunk2.big2); + +})); diff --git a/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-a/_expected/cjs/generated-chunk1.js b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-a/_expected/cjs/generated-chunk1.js new file mode 100644 index 00000000000..692146ccf23 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-a/_expected/cjs/generated-chunk1.js @@ -0,0 +1,9 @@ +'use strict'; + +const small = '0'; + +const big1 = + '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'; + +exports.big1 = big1; +exports.small = small; diff --git a/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-a/_expected/cjs/generated-chunk2.js b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-a/_expected/cjs/generated-chunk2.js new file mode 100644 index 00000000000..956f49b679c --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-a/_expected/cjs/generated-chunk2.js @@ -0,0 +1,6 @@ +'use strict'; + +const big2 = + '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'; + +exports.big2 = big2; diff --git a/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-a/_expected/cjs/main1.js b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-a/_expected/cjs/main1.js new file mode 100644 index 00000000000..51f8c795cd2 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-a/_expected/cjs/main1.js @@ -0,0 +1,6 @@ +'use strict'; + +var chunk1 = require('./generated-chunk1.js'); +var chunk2 = require('./generated-chunk2.js'); + +console.log(chunk1.small, chunk1.big1, chunk2.big2); diff --git a/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-a/_expected/cjs/main2.js b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-a/_expected/cjs/main2.js new file mode 100644 index 00000000000..51f8c795cd2 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-a/_expected/cjs/main2.js @@ -0,0 +1,6 @@ +'use strict'; + +var chunk1 = require('./generated-chunk1.js'); +var chunk2 = require('./generated-chunk2.js'); + +console.log(chunk1.small, chunk1.big1, chunk2.big2); diff --git a/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-a/_expected/cjs/main3.js b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-a/_expected/cjs/main3.js new file mode 100644 index 00000000000..8cda222e165 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-a/_expected/cjs/main3.js @@ -0,0 +1,6 @@ +'use strict'; + +var chunk1 = require('./generated-chunk1.js'); +var chunk2 = require('./generated-chunk2.js'); + +console.log(chunk1.big1, chunk2.big2); diff --git a/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-a/_expected/cjs/main4.js b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-a/_expected/cjs/main4.js new file mode 100644 index 00000000000..14808a1e785 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-a/_expected/cjs/main4.js @@ -0,0 +1,5 @@ +'use strict'; + +var chunk2 = require('./generated-chunk2.js'); + +console.log(chunk2.big2); diff --git a/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-a/_expected/es/generated-chunk1.js b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-a/_expected/es/generated-chunk1.js new file mode 100644 index 00000000000..4fa7fa3ee1c --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-a/_expected/es/generated-chunk1.js @@ -0,0 +1,6 @@ +const small = '0'; + +const big1 = + '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'; + +export { big1 as b, small as s }; diff --git a/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-a/_expected/es/generated-chunk2.js b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-a/_expected/es/generated-chunk2.js new file mode 100644 index 00000000000..dcd92e45d1a --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-a/_expected/es/generated-chunk2.js @@ -0,0 +1,4 @@ +const big2 = + '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'; + +export { big2 as b }; diff --git a/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-a/_expected/es/main1.js b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-a/_expected/es/main1.js new file mode 100644 index 00000000000..16cd68310d7 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-a/_expected/es/main1.js @@ -0,0 +1,4 @@ +import { s as small, b as big1 } from './generated-chunk1.js'; +import { b as big2 } from './generated-chunk2.js'; + +console.log(small, big1, big2); diff --git a/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-a/_expected/es/main2.js b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-a/_expected/es/main2.js new file mode 100644 index 00000000000..16cd68310d7 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-a/_expected/es/main2.js @@ -0,0 +1,4 @@ +import { s as small, b as big1 } from './generated-chunk1.js'; +import { b as big2 } from './generated-chunk2.js'; + +console.log(small, big1, big2); diff --git a/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-a/_expected/es/main3.js b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-a/_expected/es/main3.js new file mode 100644 index 00000000000..46d383ce10d --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-a/_expected/es/main3.js @@ -0,0 +1,4 @@ +import { b as big1 } from './generated-chunk1.js'; +import { b as big2 } from './generated-chunk2.js'; + +console.log(big1, big2); diff --git a/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-a/_expected/es/main4.js b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-a/_expected/es/main4.js new file mode 100644 index 00000000000..870e263805f --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-a/_expected/es/main4.js @@ -0,0 +1,3 @@ +import { b as big2 } from './generated-chunk2.js'; + +console.log(big2); diff --git a/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-a/_expected/system/generated-chunk1.js b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-a/_expected/system/generated-chunk1.js new file mode 100644 index 00000000000..6c44b964714 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-a/_expected/system/generated-chunk1.js @@ -0,0 +1,13 @@ +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + + const small = exports("s", '0'); + + const big1 = + exports("b", '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'); + + }) + }; +})); diff --git a/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-a/_expected/system/generated-chunk2.js b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-a/_expected/system/generated-chunk2.js new file mode 100644 index 00000000000..ae37a3c35a8 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-a/_expected/system/generated-chunk2.js @@ -0,0 +1,11 @@ +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + + const big2 = + exports("b", '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'); + + }) + }; +})); diff --git a/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-a/_expected/system/main1.js b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-a/_expected/system/main1.js new file mode 100644 index 00000000000..8d939116d32 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-a/_expected/system/main1.js @@ -0,0 +1,17 @@ +System.register(['./generated-chunk1.js', './generated-chunk2.js'], (function () { + 'use strict'; + var small, big1, big2; + return { + setters: [function (module) { + small = module.s; + big1 = module.b; + }, function (module) { + big2 = module.b; + }], + execute: (function () { + + console.log(small, big1, big2); + + }) + }; +})); diff --git a/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-a/_expected/system/main2.js b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-a/_expected/system/main2.js new file mode 100644 index 00000000000..8d939116d32 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-a/_expected/system/main2.js @@ -0,0 +1,17 @@ +System.register(['./generated-chunk1.js', './generated-chunk2.js'], (function () { + 'use strict'; + var small, big1, big2; + return { + setters: [function (module) { + small = module.s; + big1 = module.b; + }, function (module) { + big2 = module.b; + }], + execute: (function () { + + console.log(small, big1, big2); + + }) + }; +})); diff --git a/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-a/_expected/system/main3.js b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-a/_expected/system/main3.js new file mode 100644 index 00000000000..5166ce5286d --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-a/_expected/system/main3.js @@ -0,0 +1,16 @@ +System.register(['./generated-chunk1.js', './generated-chunk2.js'], (function () { + 'use strict'; + var big1, big2; + return { + setters: [function (module) { + big1 = module.b; + }, function (module) { + big2 = module.b; + }], + execute: (function () { + + console.log(big1, big2); + + }) + }; +})); diff --git a/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-a/_expected/system/main4.js b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-a/_expected/system/main4.js new file mode 100644 index 00000000000..28e6fa818cd --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-a/_expected/system/main4.js @@ -0,0 +1,14 @@ +System.register(['./generated-chunk2.js'], (function () { + 'use strict'; + var big2; + return { + setters: [function (module) { + big2 = module.b; + }], + execute: (function () { + + console.log(big2); + + }) + }; +})); diff --git a/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-a/chunk1.js b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-a/chunk1.js new file mode 100644 index 00000000000..e5515bee8a1 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-a/chunk1.js @@ -0,0 +1,2 @@ +export const big1 = + '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'; diff --git a/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-a/chunk2.js b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-a/chunk2.js new file mode 100644 index 00000000000..f52d5c6df25 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-a/chunk2.js @@ -0,0 +1,2 @@ +export const big2 = + '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'; diff --git a/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-a/main1.js b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-a/main1.js new file mode 100644 index 00000000000..2193ad7b501 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-a/main1.js @@ -0,0 +1,5 @@ +import { small } from './small'; +import { big1 } from './chunk1'; +import { big2 } from './chunk2'; + +console.log(small, big1, big2); diff --git a/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-a/main2.js b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-a/main2.js new file mode 100644 index 00000000000..2193ad7b501 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-a/main2.js @@ -0,0 +1,5 @@ +import { small } from './small'; +import { big1 } from './chunk1'; +import { big2 } from './chunk2'; + +console.log(small, big1, big2); diff --git a/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-a/main3.js b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-a/main3.js new file mode 100644 index 00000000000..65ca4afd16a --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-a/main3.js @@ -0,0 +1,4 @@ +import { big1 } from './chunk1'; +import { big2 } from './chunk2'; + +console.log(big1, big2); diff --git a/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-a/main4.js b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-a/main4.js new file mode 100644 index 00000000000..bc2dab9d8b4 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-a/main4.js @@ -0,0 +1,3 @@ +import { big2 } from './chunk2'; + +console.log(big2); diff --git a/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-a/small.js b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-a/small.js new file mode 100644 index 00000000000..1f81fbc27dd --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-a/small.js @@ -0,0 +1 @@ +export const small = '0'; diff --git a/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-b/_config.js b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-b/_config.js new file mode 100644 index 00000000000..18809bd51c7 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-b/_config.js @@ -0,0 +1,10 @@ +module.exports = defineTest({ + description: + 'when there are two valid merge targets, the one that is loaded under more similar conditions is preferred', + options: { + input: ['main1.js', 'main2.js', 'main3.js', 'main4.js'], + output: { + experimentalMinChunkSize: 100 + } + } +}); diff --git a/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-b/_expected/amd/generated-chunk1.js b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-b/_expected/amd/generated-chunk1.js new file mode 100644 index 00000000000..e8220dca082 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-b/_expected/amd/generated-chunk1.js @@ -0,0 +1,11 @@ +define(['exports'], (function (exports) { 'use strict'; + + const small = '0'; + + const big1 = + '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'; + + exports.big1 = big1; + exports.small = small; + +})); diff --git a/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-b/_expected/amd/generated-chunk2.js b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-b/_expected/amd/generated-chunk2.js new file mode 100644 index 00000000000..dd86f0a8619 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-b/_expected/amd/generated-chunk2.js @@ -0,0 +1,8 @@ +define(['exports'], (function (exports) { 'use strict'; + + const big2 = + '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'; + + exports.big2 = big2; + +})); diff --git a/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-b/_expected/amd/main1.js b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-b/_expected/amd/main1.js new file mode 100644 index 00000000000..cc2340c2087 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-b/_expected/amd/main1.js @@ -0,0 +1,5 @@ +define(['./generated-chunk1', './generated-chunk2'], (function (chunk1, chunk2) { 'use strict'; + + console.log(chunk1.small, chunk1.big1, chunk2.big2); + +})); diff --git a/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-b/_expected/amd/main2.js b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-b/_expected/amd/main2.js new file mode 100644 index 00000000000..cc2340c2087 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-b/_expected/amd/main2.js @@ -0,0 +1,5 @@ +define(['./generated-chunk1', './generated-chunk2'], (function (chunk1, chunk2) { 'use strict'; + + console.log(chunk1.small, chunk1.big1, chunk2.big2); + +})); diff --git a/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-b/_expected/amd/main3.js b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-b/_expected/amd/main3.js new file mode 100644 index 00000000000..6f235b89cee --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-b/_expected/amd/main3.js @@ -0,0 +1,5 @@ +define(['./generated-chunk2', './generated-chunk1'], (function (chunk2, chunk1) { 'use strict'; + + console.log(chunk1.big1, chunk2.big2); + +})); diff --git a/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-b/_expected/amd/main4.js b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-b/_expected/amd/main4.js new file mode 100644 index 00000000000..a9c8374a0b5 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-b/_expected/amd/main4.js @@ -0,0 +1,5 @@ +define(['./generated-chunk2'], (function (chunk2) { 'use strict'; + + console.log(chunk2.big2); + +})); diff --git a/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-b/_expected/cjs/generated-chunk1.js b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-b/_expected/cjs/generated-chunk1.js new file mode 100644 index 00000000000..692146ccf23 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-b/_expected/cjs/generated-chunk1.js @@ -0,0 +1,9 @@ +'use strict'; + +const small = '0'; + +const big1 = + '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'; + +exports.big1 = big1; +exports.small = small; diff --git a/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-b/_expected/cjs/generated-chunk2.js b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-b/_expected/cjs/generated-chunk2.js new file mode 100644 index 00000000000..956f49b679c --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-b/_expected/cjs/generated-chunk2.js @@ -0,0 +1,6 @@ +'use strict'; + +const big2 = + '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'; + +exports.big2 = big2; diff --git a/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-b/_expected/cjs/main1.js b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-b/_expected/cjs/main1.js new file mode 100644 index 00000000000..51f8c795cd2 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-b/_expected/cjs/main1.js @@ -0,0 +1,6 @@ +'use strict'; + +var chunk1 = require('./generated-chunk1.js'); +var chunk2 = require('./generated-chunk2.js'); + +console.log(chunk1.small, chunk1.big1, chunk2.big2); diff --git a/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-b/_expected/cjs/main2.js b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-b/_expected/cjs/main2.js new file mode 100644 index 00000000000..51f8c795cd2 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-b/_expected/cjs/main2.js @@ -0,0 +1,6 @@ +'use strict'; + +var chunk1 = require('./generated-chunk1.js'); +var chunk2 = require('./generated-chunk2.js'); + +console.log(chunk1.small, chunk1.big1, chunk2.big2); diff --git a/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-b/_expected/cjs/main3.js b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-b/_expected/cjs/main3.js new file mode 100644 index 00000000000..20943f67a0d --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-b/_expected/cjs/main3.js @@ -0,0 +1,6 @@ +'use strict'; + +var chunk2 = require('./generated-chunk2.js'); +var chunk1 = require('./generated-chunk1.js'); + +console.log(chunk1.big1, chunk2.big2); diff --git a/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-b/_expected/cjs/main4.js b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-b/_expected/cjs/main4.js new file mode 100644 index 00000000000..14808a1e785 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-b/_expected/cjs/main4.js @@ -0,0 +1,5 @@ +'use strict'; + +var chunk2 = require('./generated-chunk2.js'); + +console.log(chunk2.big2); diff --git a/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-b/_expected/es/generated-chunk1.js b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-b/_expected/es/generated-chunk1.js new file mode 100644 index 00000000000..4fa7fa3ee1c --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-b/_expected/es/generated-chunk1.js @@ -0,0 +1,6 @@ +const small = '0'; + +const big1 = + '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'; + +export { big1 as b, small as s }; diff --git a/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-b/_expected/es/generated-chunk2.js b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-b/_expected/es/generated-chunk2.js new file mode 100644 index 00000000000..dcd92e45d1a --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-b/_expected/es/generated-chunk2.js @@ -0,0 +1,4 @@ +const big2 = + '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'; + +export { big2 as b }; diff --git a/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-b/_expected/es/main1.js b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-b/_expected/es/main1.js new file mode 100644 index 00000000000..16cd68310d7 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-b/_expected/es/main1.js @@ -0,0 +1,4 @@ +import { s as small, b as big1 } from './generated-chunk1.js'; +import { b as big2 } from './generated-chunk2.js'; + +console.log(small, big1, big2); diff --git a/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-b/_expected/es/main2.js b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-b/_expected/es/main2.js new file mode 100644 index 00000000000..16cd68310d7 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-b/_expected/es/main2.js @@ -0,0 +1,4 @@ +import { s as small, b as big1 } from './generated-chunk1.js'; +import { b as big2 } from './generated-chunk2.js'; + +console.log(small, big1, big2); diff --git a/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-b/_expected/es/main3.js b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-b/_expected/es/main3.js new file mode 100644 index 00000000000..ad7a76d86d1 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-b/_expected/es/main3.js @@ -0,0 +1,4 @@ +import { b as big2 } from './generated-chunk2.js'; +import { b as big1 } from './generated-chunk1.js'; + +console.log(big1, big2); diff --git a/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-b/_expected/es/main4.js b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-b/_expected/es/main4.js new file mode 100644 index 00000000000..870e263805f --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-b/_expected/es/main4.js @@ -0,0 +1,3 @@ +import { b as big2 } from './generated-chunk2.js'; + +console.log(big2); diff --git a/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-b/_expected/system/generated-chunk1.js b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-b/_expected/system/generated-chunk1.js new file mode 100644 index 00000000000..6c44b964714 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-b/_expected/system/generated-chunk1.js @@ -0,0 +1,13 @@ +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + + const small = exports("s", '0'); + + const big1 = + exports("b", '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'); + + }) + }; +})); diff --git a/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-b/_expected/system/generated-chunk2.js b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-b/_expected/system/generated-chunk2.js new file mode 100644 index 00000000000..ae37a3c35a8 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-b/_expected/system/generated-chunk2.js @@ -0,0 +1,11 @@ +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + + const big2 = + exports("b", '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'); + + }) + }; +})); diff --git a/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-b/_expected/system/main1.js b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-b/_expected/system/main1.js new file mode 100644 index 00000000000..8d939116d32 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-b/_expected/system/main1.js @@ -0,0 +1,17 @@ +System.register(['./generated-chunk1.js', './generated-chunk2.js'], (function () { + 'use strict'; + var small, big1, big2; + return { + setters: [function (module) { + small = module.s; + big1 = module.b; + }, function (module) { + big2 = module.b; + }], + execute: (function () { + + console.log(small, big1, big2); + + }) + }; +})); diff --git a/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-b/_expected/system/main2.js b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-b/_expected/system/main2.js new file mode 100644 index 00000000000..8d939116d32 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-b/_expected/system/main2.js @@ -0,0 +1,17 @@ +System.register(['./generated-chunk1.js', './generated-chunk2.js'], (function () { + 'use strict'; + var small, big1, big2; + return { + setters: [function (module) { + small = module.s; + big1 = module.b; + }, function (module) { + big2 = module.b; + }], + execute: (function () { + + console.log(small, big1, big2); + + }) + }; +})); diff --git a/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-b/_expected/system/main3.js b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-b/_expected/system/main3.js new file mode 100644 index 00000000000..e9fde093ff8 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-b/_expected/system/main3.js @@ -0,0 +1,16 @@ +System.register(['./generated-chunk2.js', './generated-chunk1.js'], (function () { + 'use strict'; + var big2, big1; + return { + setters: [function (module) { + big2 = module.b; + }, function (module) { + big1 = module.b; + }], + execute: (function () { + + console.log(big1, big2); + + }) + }; +})); diff --git a/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-b/_expected/system/main4.js b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-b/_expected/system/main4.js new file mode 100644 index 00000000000..28e6fa818cd --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-b/_expected/system/main4.js @@ -0,0 +1,14 @@ +System.register(['./generated-chunk2.js'], (function () { + 'use strict'; + var big2; + return { + setters: [function (module) { + big2 = module.b; + }], + execute: (function () { + + console.log(big2); + + }) + }; +})); diff --git a/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-b/chunk1.js b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-b/chunk1.js new file mode 100644 index 00000000000..e5515bee8a1 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-b/chunk1.js @@ -0,0 +1,2 @@ +export const big1 = + '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'; diff --git a/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-b/chunk2.js b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-b/chunk2.js new file mode 100644 index 00000000000..f52d5c6df25 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-b/chunk2.js @@ -0,0 +1,2 @@ +export const big2 = + '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'; diff --git a/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-b/main1.js b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-b/main1.js new file mode 100644 index 00000000000..c69e1a9b427 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-b/main1.js @@ -0,0 +1,5 @@ +import { small } from './small'; +import { big2 } from './chunk2'; +import { big1 } from './chunk1'; + +console.log(small, big1, big2); diff --git a/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-b/main2.js b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-b/main2.js new file mode 100644 index 00000000000..c69e1a9b427 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-b/main2.js @@ -0,0 +1,5 @@ +import { small } from './small'; +import { big2 } from './chunk2'; +import { big1 } from './chunk1'; + +console.log(small, big1, big2); diff --git a/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-b/main3.js b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-b/main3.js new file mode 100644 index 00000000000..300e124adfa --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-b/main3.js @@ -0,0 +1,4 @@ +import { big2 } from './chunk2'; +import { big1 } from './chunk1'; + +console.log(big1, big2); diff --git a/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-b/main4.js b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-b/main4.js new file mode 100644 index 00000000000..bc2dab9d8b4 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-b/main4.js @@ -0,0 +1,3 @@ +import { big2 } from './chunk2'; + +console.log(big2); diff --git a/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-b/small.js b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-b/small.js new file mode 100644 index 00000000000..1f81fbc27dd --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-close-merge-target-b/small.js @@ -0,0 +1 @@ +export const small = '0'; diff --git a/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-a/_config.js b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-a/_config.js new file mode 100644 index 00000000000..77cd812c0c9 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-a/_config.js @@ -0,0 +1,9 @@ +module.exports = defineTest({ + description: 'when there are two equally valid merge targets, the smaller is preferred', + options: { + input: ['main1.js', 'main2.js', 'main3.js', 'main4.js'], + output: { + experimentalMinChunkSize: 100 + } + } +}); diff --git a/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-a/_expected/amd/generated-chunk1.js b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-a/_expected/amd/generated-chunk1.js new file mode 100644 index 00000000000..82c13ea07bd --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-a/_expected/amd/generated-chunk1.js @@ -0,0 +1,11 @@ +define(['exports'], (function (exports) { 'use strict'; + + const small = '0'; + + const big = + '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'; + + exports.big = big; + exports.small = small; + +})); diff --git a/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-a/_expected/amd/generated-chunk2.js b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-a/_expected/amd/generated-chunk2.js new file mode 100644 index 00000000000..9d9f86f43ab --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-a/_expected/amd/generated-chunk2.js @@ -0,0 +1,8 @@ +define(['exports'], (function (exports) { 'use strict'; + + const huge = + '12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'; + + exports.huge = huge; + +})); diff --git a/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-a/_expected/amd/main1.js b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-a/_expected/amd/main1.js new file mode 100644 index 00000000000..f0f4d2608a8 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-a/_expected/amd/main1.js @@ -0,0 +1,5 @@ +define(['./generated-chunk1', './generated-chunk2'], (function (chunk1, chunk2) { 'use strict'; + + console.log(chunk1.small, chunk1.big, chunk2.huge); + +})); diff --git a/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-a/_expected/amd/main2.js b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-a/_expected/amd/main2.js new file mode 100644 index 00000000000..f0f4d2608a8 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-a/_expected/amd/main2.js @@ -0,0 +1,5 @@ +define(['./generated-chunk1', './generated-chunk2'], (function (chunk1, chunk2) { 'use strict'; + + console.log(chunk1.small, chunk1.big, chunk2.huge); + +})); diff --git a/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-a/_expected/amd/main3.js b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-a/_expected/amd/main3.js new file mode 100644 index 00000000000..6af165504d5 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-a/_expected/amd/main3.js @@ -0,0 +1,5 @@ +define(['./generated-chunk1'], (function (chunk1) { 'use strict'; + + console.log(chunk1.big); + +})); diff --git a/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-a/_expected/amd/main4.js b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-a/_expected/amd/main4.js new file mode 100644 index 00000000000..3470975cdf0 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-a/_expected/amd/main4.js @@ -0,0 +1,5 @@ +define(['./generated-chunk2'], (function (chunk2) { 'use strict'; + + console.log(chunk2.huge); + +})); diff --git a/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-a/_expected/cjs/generated-chunk1.js b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-a/_expected/cjs/generated-chunk1.js new file mode 100644 index 00000000000..ce0a635ceb1 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-a/_expected/cjs/generated-chunk1.js @@ -0,0 +1,9 @@ +'use strict'; + +const small = '0'; + +const big = + '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'; + +exports.big = big; +exports.small = small; diff --git a/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-a/_expected/cjs/generated-chunk2.js b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-a/_expected/cjs/generated-chunk2.js new file mode 100644 index 00000000000..6d8fbb03da1 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-a/_expected/cjs/generated-chunk2.js @@ -0,0 +1,6 @@ +'use strict'; + +const huge = + '12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'; + +exports.huge = huge; diff --git a/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-a/_expected/cjs/main1.js b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-a/_expected/cjs/main1.js new file mode 100644 index 00000000000..209fe0f0148 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-a/_expected/cjs/main1.js @@ -0,0 +1,6 @@ +'use strict'; + +var chunk1 = require('./generated-chunk1.js'); +var chunk2 = require('./generated-chunk2.js'); + +console.log(chunk1.small, chunk1.big, chunk2.huge); diff --git a/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-a/_expected/cjs/main2.js b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-a/_expected/cjs/main2.js new file mode 100644 index 00000000000..209fe0f0148 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-a/_expected/cjs/main2.js @@ -0,0 +1,6 @@ +'use strict'; + +var chunk1 = require('./generated-chunk1.js'); +var chunk2 = require('./generated-chunk2.js'); + +console.log(chunk1.small, chunk1.big, chunk2.huge); diff --git a/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-a/_expected/cjs/main3.js b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-a/_expected/cjs/main3.js new file mode 100644 index 00000000000..c786b71e8ff --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-a/_expected/cjs/main3.js @@ -0,0 +1,5 @@ +'use strict'; + +var chunk1 = require('./generated-chunk1.js'); + +console.log(chunk1.big); diff --git a/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-a/_expected/cjs/main4.js b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-a/_expected/cjs/main4.js new file mode 100644 index 00000000000..420b0e591d7 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-a/_expected/cjs/main4.js @@ -0,0 +1,5 @@ +'use strict'; + +var chunk2 = require('./generated-chunk2.js'); + +console.log(chunk2.huge); diff --git a/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-a/_expected/es/generated-chunk1.js b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-a/_expected/es/generated-chunk1.js new file mode 100644 index 00000000000..e321fa7efba --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-a/_expected/es/generated-chunk1.js @@ -0,0 +1,6 @@ +const small = '0'; + +const big = + '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'; + +export { big as b, small as s }; diff --git a/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-a/_expected/es/generated-chunk2.js b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-a/_expected/es/generated-chunk2.js new file mode 100644 index 00000000000..7509424e313 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-a/_expected/es/generated-chunk2.js @@ -0,0 +1,4 @@ +const huge = + '12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'; + +export { huge as h }; diff --git a/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-a/_expected/es/main1.js b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-a/_expected/es/main1.js new file mode 100644 index 00000000000..ab5022a8a32 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-a/_expected/es/main1.js @@ -0,0 +1,4 @@ +import { s as small, b as big } from './generated-chunk1.js'; +import { h as huge } from './generated-chunk2.js'; + +console.log(small, big, huge); diff --git a/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-a/_expected/es/main2.js b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-a/_expected/es/main2.js new file mode 100644 index 00000000000..ab5022a8a32 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-a/_expected/es/main2.js @@ -0,0 +1,4 @@ +import { s as small, b as big } from './generated-chunk1.js'; +import { h as huge } from './generated-chunk2.js'; + +console.log(small, big, huge); diff --git a/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-a/_expected/es/main3.js b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-a/_expected/es/main3.js new file mode 100644 index 00000000000..284e5ab75ec --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-a/_expected/es/main3.js @@ -0,0 +1,3 @@ +import { b as big } from './generated-chunk1.js'; + +console.log(big); diff --git a/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-a/_expected/es/main4.js b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-a/_expected/es/main4.js new file mode 100644 index 00000000000..d948a6f1d92 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-a/_expected/es/main4.js @@ -0,0 +1,3 @@ +import { h as huge } from './generated-chunk2.js'; + +console.log(huge); diff --git a/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-a/_expected/system/generated-chunk1.js b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-a/_expected/system/generated-chunk1.js new file mode 100644 index 00000000000..d1e93865aea --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-a/_expected/system/generated-chunk1.js @@ -0,0 +1,13 @@ +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + + const small = exports("s", '0'); + + const big = + exports("b", '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'); + + }) + }; +})); diff --git a/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-a/_expected/system/generated-chunk2.js b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-a/_expected/system/generated-chunk2.js new file mode 100644 index 00000000000..97242eba5da --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-a/_expected/system/generated-chunk2.js @@ -0,0 +1,11 @@ +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + + const huge = + exports("h", '12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'); + + }) + }; +})); diff --git a/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-a/_expected/system/main1.js b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-a/_expected/system/main1.js new file mode 100644 index 00000000000..81bdb55e1c7 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-a/_expected/system/main1.js @@ -0,0 +1,17 @@ +System.register(['./generated-chunk1.js', './generated-chunk2.js'], (function () { + 'use strict'; + var small, big, huge; + return { + setters: [function (module) { + small = module.s; + big = module.b; + }, function (module) { + huge = module.h; + }], + execute: (function () { + + console.log(small, big, huge); + + }) + }; +})); diff --git a/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-a/_expected/system/main2.js b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-a/_expected/system/main2.js new file mode 100644 index 00000000000..81bdb55e1c7 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-a/_expected/system/main2.js @@ -0,0 +1,17 @@ +System.register(['./generated-chunk1.js', './generated-chunk2.js'], (function () { + 'use strict'; + var small, big, huge; + return { + setters: [function (module) { + small = module.s; + big = module.b; + }, function (module) { + huge = module.h; + }], + execute: (function () { + + console.log(small, big, huge); + + }) + }; +})); diff --git a/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-a/_expected/system/main3.js b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-a/_expected/system/main3.js new file mode 100644 index 00000000000..6874b91c5bf --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-a/_expected/system/main3.js @@ -0,0 +1,14 @@ +System.register(['./generated-chunk1.js'], (function () { + 'use strict'; + var big; + return { + setters: [function (module) { + big = module.b; + }], + execute: (function () { + + console.log(big); + + }) + }; +})); diff --git a/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-a/_expected/system/main4.js b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-a/_expected/system/main4.js new file mode 100644 index 00000000000..a8e4f25cc09 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-a/_expected/system/main4.js @@ -0,0 +1,14 @@ +System.register(['./generated-chunk2.js'], (function () { + 'use strict'; + var huge; + return { + setters: [function (module) { + huge = module.h; + }], + execute: (function () { + + console.log(huge); + + }) + }; +})); diff --git a/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-a/chunk1.js b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-a/chunk1.js new file mode 100644 index 00000000000..dff9edc7c18 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-a/chunk1.js @@ -0,0 +1,2 @@ +export const big = + '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'; diff --git a/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-a/chunk2.js b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-a/chunk2.js new file mode 100644 index 00000000000..d2122f7f416 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-a/chunk2.js @@ -0,0 +1,2 @@ +export const huge = + '12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'; diff --git a/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-a/main1.js b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-a/main1.js new file mode 100644 index 00000000000..f526bdefe20 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-a/main1.js @@ -0,0 +1,5 @@ +import { small } from './small'; +import { big } from './chunk1'; +import { huge } from './chunk2'; + +console.log(small, big, huge); diff --git a/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-a/main2.js b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-a/main2.js new file mode 100644 index 00000000000..f526bdefe20 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-a/main2.js @@ -0,0 +1,5 @@ +import { small } from './small'; +import { big } from './chunk1'; +import { huge } from './chunk2'; + +console.log(small, big, huge); diff --git a/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-a/main3.js b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-a/main3.js new file mode 100644 index 00000000000..db77cab45a7 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-a/main3.js @@ -0,0 +1,3 @@ +import { big } from './chunk1'; + +console.log(big); diff --git a/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-a/main4.js b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-a/main4.js new file mode 100644 index 00000000000..5d866d15e35 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-a/main4.js @@ -0,0 +1,3 @@ +import { huge } from './chunk2'; + +console.log(huge); diff --git a/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-a/small.js b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-a/small.js new file mode 100644 index 00000000000..1f81fbc27dd --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-a/small.js @@ -0,0 +1 @@ +export const small = '0'; diff --git a/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-b/_config.js b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-b/_config.js new file mode 100644 index 00000000000..77cd812c0c9 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-b/_config.js @@ -0,0 +1,9 @@ +module.exports = defineTest({ + description: 'when there are two equally valid merge targets, the smaller is preferred', + options: { + input: ['main1.js', 'main2.js', 'main3.js', 'main4.js'], + output: { + experimentalMinChunkSize: 100 + } + } +}); diff --git a/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-b/_expected/amd/generated-chunk1.js b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-b/_expected/amd/generated-chunk1.js new file mode 100644 index 00000000000..9d9f86f43ab --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-b/_expected/amd/generated-chunk1.js @@ -0,0 +1,8 @@ +define(['exports'], (function (exports) { 'use strict'; + + const huge = + '12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'; + + exports.huge = huge; + +})); diff --git a/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-b/_expected/amd/generated-chunk2.js b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-b/_expected/amd/generated-chunk2.js new file mode 100644 index 00000000000..82c13ea07bd --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-b/_expected/amd/generated-chunk2.js @@ -0,0 +1,11 @@ +define(['exports'], (function (exports) { 'use strict'; + + const small = '0'; + + const big = + '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'; + + exports.big = big; + exports.small = small; + +})); diff --git a/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-b/_expected/amd/main1.js b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-b/_expected/amd/main1.js new file mode 100644 index 00000000000..0cf15ff1b00 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-b/_expected/amd/main1.js @@ -0,0 +1,5 @@ +define(['./generated-chunk2', './generated-chunk1'], (function (chunk2, chunk1) { 'use strict'; + + console.log(chunk2.small, chunk2.big, chunk1.huge); + +})); diff --git a/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-b/_expected/amd/main2.js b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-b/_expected/amd/main2.js new file mode 100644 index 00000000000..0cf15ff1b00 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-b/_expected/amd/main2.js @@ -0,0 +1,5 @@ +define(['./generated-chunk2', './generated-chunk1'], (function (chunk2, chunk1) { 'use strict'; + + console.log(chunk2.small, chunk2.big, chunk1.huge); + +})); diff --git a/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-b/_expected/amd/main3.js b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-b/_expected/amd/main3.js new file mode 100644 index 00000000000..4de103021d2 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-b/_expected/amd/main3.js @@ -0,0 +1,5 @@ +define(['./generated-chunk1'], (function (chunk1) { 'use strict'; + + console.log(chunk1.huge); + +})); diff --git a/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-b/_expected/amd/main4.js b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-b/_expected/amd/main4.js new file mode 100644 index 00000000000..1619a2930c4 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-b/_expected/amd/main4.js @@ -0,0 +1,5 @@ +define(['./generated-chunk2'], (function (chunk2) { 'use strict'; + + console.log(chunk2.big); + +})); diff --git a/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-b/_expected/cjs/generated-chunk1.js b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-b/_expected/cjs/generated-chunk1.js new file mode 100644 index 00000000000..6d8fbb03da1 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-b/_expected/cjs/generated-chunk1.js @@ -0,0 +1,6 @@ +'use strict'; + +const huge = + '12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'; + +exports.huge = huge; diff --git a/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-b/_expected/cjs/generated-chunk2.js b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-b/_expected/cjs/generated-chunk2.js new file mode 100644 index 00000000000..ce0a635ceb1 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-b/_expected/cjs/generated-chunk2.js @@ -0,0 +1,9 @@ +'use strict'; + +const small = '0'; + +const big = + '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'; + +exports.big = big; +exports.small = small; diff --git a/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-b/_expected/cjs/main1.js b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-b/_expected/cjs/main1.js new file mode 100644 index 00000000000..39e3659839f --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-b/_expected/cjs/main1.js @@ -0,0 +1,6 @@ +'use strict'; + +var chunk2 = require('./generated-chunk2.js'); +var chunk1 = require('./generated-chunk1.js'); + +console.log(chunk2.small, chunk2.big, chunk1.huge); diff --git a/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-b/_expected/cjs/main2.js b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-b/_expected/cjs/main2.js new file mode 100644 index 00000000000..39e3659839f --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-b/_expected/cjs/main2.js @@ -0,0 +1,6 @@ +'use strict'; + +var chunk2 = require('./generated-chunk2.js'); +var chunk1 = require('./generated-chunk1.js'); + +console.log(chunk2.small, chunk2.big, chunk1.huge); diff --git a/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-b/_expected/cjs/main3.js b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-b/_expected/cjs/main3.js new file mode 100644 index 00000000000..6ee72e66101 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-b/_expected/cjs/main3.js @@ -0,0 +1,5 @@ +'use strict'; + +var chunk1 = require('./generated-chunk1.js'); + +console.log(chunk1.huge); diff --git a/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-b/_expected/cjs/main4.js b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-b/_expected/cjs/main4.js new file mode 100644 index 00000000000..0bf1478b67a --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-b/_expected/cjs/main4.js @@ -0,0 +1,5 @@ +'use strict'; + +var chunk2 = require('./generated-chunk2.js'); + +console.log(chunk2.big); diff --git a/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-b/_expected/es/generated-chunk1.js b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-b/_expected/es/generated-chunk1.js new file mode 100644 index 00000000000..7509424e313 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-b/_expected/es/generated-chunk1.js @@ -0,0 +1,4 @@ +const huge = + '12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'; + +export { huge as h }; diff --git a/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-b/_expected/es/generated-chunk2.js b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-b/_expected/es/generated-chunk2.js new file mode 100644 index 00000000000..e321fa7efba --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-b/_expected/es/generated-chunk2.js @@ -0,0 +1,6 @@ +const small = '0'; + +const big = + '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'; + +export { big as b, small as s }; diff --git a/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-b/_expected/es/main1.js b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-b/_expected/es/main1.js new file mode 100644 index 00000000000..55875a8ec85 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-b/_expected/es/main1.js @@ -0,0 +1,4 @@ +import { s as small, b as big } from './generated-chunk2.js'; +import { h as huge } from './generated-chunk1.js'; + +console.log(small, big, huge); diff --git a/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-b/_expected/es/main2.js b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-b/_expected/es/main2.js new file mode 100644 index 00000000000..55875a8ec85 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-b/_expected/es/main2.js @@ -0,0 +1,4 @@ +import { s as small, b as big } from './generated-chunk2.js'; +import { h as huge } from './generated-chunk1.js'; + +console.log(small, big, huge); diff --git a/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-b/_expected/es/main3.js b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-b/_expected/es/main3.js new file mode 100644 index 00000000000..085a93e692e --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-b/_expected/es/main3.js @@ -0,0 +1,3 @@ +import { h as huge } from './generated-chunk1.js'; + +console.log(huge); diff --git a/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-b/_expected/es/main4.js b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-b/_expected/es/main4.js new file mode 100644 index 00000000000..0754908661e --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-b/_expected/es/main4.js @@ -0,0 +1,3 @@ +import { b as big } from './generated-chunk2.js'; + +console.log(big); diff --git a/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-b/_expected/system/generated-chunk1.js b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-b/_expected/system/generated-chunk1.js new file mode 100644 index 00000000000..97242eba5da --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-b/_expected/system/generated-chunk1.js @@ -0,0 +1,11 @@ +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + + const huge = + exports("h", '12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'); + + }) + }; +})); diff --git a/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-b/_expected/system/generated-chunk2.js b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-b/_expected/system/generated-chunk2.js new file mode 100644 index 00000000000..d1e93865aea --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-b/_expected/system/generated-chunk2.js @@ -0,0 +1,13 @@ +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + + const small = exports("s", '0'); + + const big = + exports("b", '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'); + + }) + }; +})); diff --git a/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-b/_expected/system/main1.js b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-b/_expected/system/main1.js new file mode 100644 index 00000000000..319a5f95e50 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-b/_expected/system/main1.js @@ -0,0 +1,17 @@ +System.register(['./generated-chunk2.js', './generated-chunk1.js'], (function () { + 'use strict'; + var small, big, huge; + return { + setters: [function (module) { + small = module.s; + big = module.b; + }, function (module) { + huge = module.h; + }], + execute: (function () { + + console.log(small, big, huge); + + }) + }; +})); diff --git a/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-b/_expected/system/main2.js b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-b/_expected/system/main2.js new file mode 100644 index 00000000000..319a5f95e50 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-b/_expected/system/main2.js @@ -0,0 +1,17 @@ +System.register(['./generated-chunk2.js', './generated-chunk1.js'], (function () { + 'use strict'; + var small, big, huge; + return { + setters: [function (module) { + small = module.s; + big = module.b; + }, function (module) { + huge = module.h; + }], + execute: (function () { + + console.log(small, big, huge); + + }) + }; +})); diff --git a/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-b/_expected/system/main3.js b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-b/_expected/system/main3.js new file mode 100644 index 00000000000..0d0ef12912a --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-b/_expected/system/main3.js @@ -0,0 +1,14 @@ +System.register(['./generated-chunk1.js'], (function () { + 'use strict'; + var huge; + return { + setters: [function (module) { + huge = module.h; + }], + execute: (function () { + + console.log(huge); + + }) + }; +})); diff --git a/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-b/_expected/system/main4.js b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-b/_expected/system/main4.js new file mode 100644 index 00000000000..c17e0d5357b --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-b/_expected/system/main4.js @@ -0,0 +1,14 @@ +System.register(['./generated-chunk2.js'], (function () { + 'use strict'; + var big; + return { + setters: [function (module) { + big = module.b; + }], + execute: (function () { + + console.log(big); + + }) + }; +})); diff --git a/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-b/chunk1.js b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-b/chunk1.js new file mode 100644 index 00000000000..d2122f7f416 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-b/chunk1.js @@ -0,0 +1,2 @@ +export const huge = + '12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'; diff --git a/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-b/chunk2.js b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-b/chunk2.js new file mode 100644 index 00000000000..dff9edc7c18 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-b/chunk2.js @@ -0,0 +1,2 @@ +export const big = + '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'; diff --git a/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-b/main1.js b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-b/main1.js new file mode 100644 index 00000000000..fd8e3ab6fdd --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-b/main1.js @@ -0,0 +1,5 @@ +import { small } from './small'; +import { huge } from './chunk1'; +import { big } from './chunk2'; + +console.log(small, big, huge); diff --git a/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-b/main2.js b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-b/main2.js new file mode 100644 index 00000000000..fd8e3ab6fdd --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-b/main2.js @@ -0,0 +1,5 @@ +import { small } from './small'; +import { huge } from './chunk1'; +import { big } from './chunk2'; + +console.log(small, big, huge); diff --git a/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-b/main3.js b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-b/main3.js new file mode 100644 index 00000000000..be37a1e47b3 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-b/main3.js @@ -0,0 +1,3 @@ +import { huge } from './chunk1'; + +console.log(huge); diff --git a/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-b/main4.js b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-b/main4.js new file mode 100644 index 00000000000..78c69cdef4a --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-b/main4.js @@ -0,0 +1,3 @@ +import { big } from './chunk2'; + +console.log(big); diff --git a/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-b/small.js b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-b/small.js new file mode 100644 index 00000000000..1f81fbc27dd --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/prefer-small-merge-target-b/small.js @@ -0,0 +1 @@ +export const small = '0'; diff --git a/test/chunking-form/samples/min-chunk-size/track-external-effects/_config.js b/test/chunking-form/samples/min-chunk-size/track-external-effects/_config.js new file mode 100644 index 00000000000..38348470866 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/track-external-effects/_config.js @@ -0,0 +1,10 @@ +module.exports = defineTest({ + description: 'tracks external imports as side effects', + options: { + input: ['main1.js', 'main2.js'], + external: ['external1', 'external2'], + output: { + experimentalMinChunkSize: 100 + } + } +}); diff --git a/test/chunking-form/samples/min-chunk-size/track-external-effects/_expected/amd/generated-shared.js b/test/chunking-form/samples/min-chunk-size/track-external-effects/_expected/amd/generated-shared.js new file mode 100644 index 00000000000..988f9188618 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/track-external-effects/_expected/amd/generated-shared.js @@ -0,0 +1,5 @@ +define((function () { 'use strict'; + + console.log('shared'); + +})); diff --git a/test/chunking-form/samples/min-chunk-size/track-external-effects/_expected/amd/main1.js b/test/chunking-form/samples/min-chunk-size/track-external-effects/_expected/amd/main1.js new file mode 100644 index 00000000000..2cb837c94f7 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/track-external-effects/_expected/amd/main1.js @@ -0,0 +1,10 @@ +define(['exports', 'external1', './generated-shared'], (function (exports, external1, shared) { 'use strict'; + + + + Object.defineProperty(exports, "foo", { + enumerable: true, + get: function () { return external1.foo; } + }); + +})); diff --git a/test/chunking-form/samples/min-chunk-size/track-external-effects/_expected/amd/main2.js b/test/chunking-form/samples/min-chunk-size/track-external-effects/_expected/amd/main2.js new file mode 100644 index 00000000000..fcf3705d2e4 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/track-external-effects/_expected/amd/main2.js @@ -0,0 +1,10 @@ +define(['exports', 'external2', './generated-shared'], (function (exports, external2, shared) { 'use strict'; + + + + Object.defineProperty(exports, "foo", { + enumerable: true, + get: function () { return external2.foo; } + }); + +})); diff --git a/test/chunking-form/samples/min-chunk-size/track-external-effects/_expected/cjs/generated-shared.js b/test/chunking-form/samples/min-chunk-size/track-external-effects/_expected/cjs/generated-shared.js new file mode 100644 index 00000000000..2c23ccc927d --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/track-external-effects/_expected/cjs/generated-shared.js @@ -0,0 +1,3 @@ +'use strict'; + +console.log('shared'); diff --git a/test/chunking-form/samples/min-chunk-size/track-external-effects/_expected/cjs/main1.js b/test/chunking-form/samples/min-chunk-size/track-external-effects/_expected/cjs/main1.js new file mode 100644 index 00000000000..a5dcc75add6 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/track-external-effects/_expected/cjs/main1.js @@ -0,0 +1,11 @@ +'use strict'; + +var external1 = require('external1'); +require('./generated-shared.js'); + + + +Object.defineProperty(exports, "foo", { + enumerable: true, + get: function () { return external1.foo; } +}); diff --git a/test/chunking-form/samples/min-chunk-size/track-external-effects/_expected/cjs/main2.js b/test/chunking-form/samples/min-chunk-size/track-external-effects/_expected/cjs/main2.js new file mode 100644 index 00000000000..6e5e065d3f8 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/track-external-effects/_expected/cjs/main2.js @@ -0,0 +1,11 @@ +'use strict'; + +var external2 = require('external2'); +require('./generated-shared.js'); + + + +Object.defineProperty(exports, "foo", { + enumerable: true, + get: function () { return external2.foo; } +}); diff --git a/test/chunking-form/samples/min-chunk-size/track-external-effects/_expected/es/generated-shared.js b/test/chunking-form/samples/min-chunk-size/track-external-effects/_expected/es/generated-shared.js new file mode 100644 index 00000000000..59b494c5580 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/track-external-effects/_expected/es/generated-shared.js @@ -0,0 +1 @@ +console.log('shared'); diff --git a/test/chunking-form/samples/min-chunk-size/track-external-effects/_expected/es/main1.js b/test/chunking-form/samples/min-chunk-size/track-external-effects/_expected/es/main1.js new file mode 100644 index 00000000000..f362f513a9a --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/track-external-effects/_expected/es/main1.js @@ -0,0 +1,2 @@ +export { foo } from 'external1'; +import './generated-shared.js'; diff --git a/test/chunking-form/samples/min-chunk-size/track-external-effects/_expected/es/main2.js b/test/chunking-form/samples/min-chunk-size/track-external-effects/_expected/es/main2.js new file mode 100644 index 00000000000..ca835338451 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/track-external-effects/_expected/es/main2.js @@ -0,0 +1,2 @@ +export { foo } from 'external2'; +import './generated-shared.js'; diff --git a/test/chunking-form/samples/min-chunk-size/track-external-effects/_expected/system/generated-shared.js b/test/chunking-form/samples/min-chunk-size/track-external-effects/_expected/system/generated-shared.js new file mode 100644 index 00000000000..e2575c4b8c0 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/track-external-effects/_expected/system/generated-shared.js @@ -0,0 +1,10 @@ +System.register([], (function () { + 'use strict'; + return { + execute: (function () { + + console.log('shared'); + + }) + }; +})); diff --git a/test/chunking-form/samples/min-chunk-size/track-external-effects/_expected/system/main1.js b/test/chunking-form/samples/min-chunk-size/track-external-effects/_expected/system/main1.js new file mode 100644 index 00000000000..bf04ddaa1b5 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/track-external-effects/_expected/system/main1.js @@ -0,0 +1,13 @@ +System.register(['external1', './generated-shared.js'], (function (exports) { + 'use strict'; + return { + setters: [function (module) { + exports("foo", module.foo); + }, null], + execute: (function () { + + + + }) + }; +})); diff --git a/test/chunking-form/samples/min-chunk-size/track-external-effects/_expected/system/main2.js b/test/chunking-form/samples/min-chunk-size/track-external-effects/_expected/system/main2.js new file mode 100644 index 00000000000..98e82b4ac86 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/track-external-effects/_expected/system/main2.js @@ -0,0 +1,13 @@ +System.register(['external2', './generated-shared.js'], (function (exports) { + 'use strict'; + return { + setters: [function (module) { + exports("foo", module.foo); + }, null], + execute: (function () { + + + + }) + }; +})); diff --git a/test/chunking-form/samples/min-chunk-size/track-external-effects/main1.js b/test/chunking-form/samples/min-chunk-size/track-external-effects/main1.js new file mode 100644 index 00000000000..1fd0bf2e8d4 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/track-external-effects/main1.js @@ -0,0 +1,2 @@ +export { foo } from 'external1'; +import './shared'; diff --git a/test/chunking-form/samples/min-chunk-size/track-external-effects/main2.js b/test/chunking-form/samples/min-chunk-size/track-external-effects/main2.js new file mode 100644 index 00000000000..04802c96a1b --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/track-external-effects/main2.js @@ -0,0 +1,2 @@ +export { foo } from 'external2'; +import './shared'; diff --git a/test/chunking-form/samples/min-chunk-size/track-external-effects/shared.js b/test/chunking-form/samples/min-chunk-size/track-external-effects/shared.js new file mode 100644 index 00000000000..59b494c5580 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/track-external-effects/shared.js @@ -0,0 +1 @@ +console.log('shared'); diff --git a/test/chunking-form/samples/min-chunk-size/track-external-effects2/_config.js b/test/chunking-form/samples/min-chunk-size/track-external-effects2/_config.js new file mode 100644 index 00000000000..0df9f3c7bc2 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/track-external-effects2/_config.js @@ -0,0 +1,14 @@ +module.exports = defineTest({ + description: + 'does not tracks external imports as side effects if they are marked as side effect free', + options: { + input: ['main1.js', 'main2.js'], + external: ['external1', 'external2'], + treeshake: { + moduleSideEffects: 'no-external' + }, + output: { + experimentalMinChunkSize: 100 + } + } +}); diff --git a/test/chunking-form/samples/min-chunk-size/track-external-effects2/_expected/amd/main1.js b/test/chunking-form/samples/min-chunk-size/track-external-effects2/_expected/amd/main1.js new file mode 100644 index 00000000000..2059807cd44 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/track-external-effects2/_expected/amd/main1.js @@ -0,0 +1,10 @@ +define(['exports', 'external1', 'external2'], (function (exports, external1, external2) { 'use strict'; + + console.log('shared'); + + Object.defineProperty(exports, "foo", { + enumerable: true, + get: function () { return external1.foo; } + }); + +})); diff --git a/test/chunking-form/samples/min-chunk-size/track-external-effects2/_expected/amd/main2.js b/test/chunking-form/samples/min-chunk-size/track-external-effects2/_expected/amd/main2.js new file mode 100644 index 00000000000..48d6a18b72b --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/track-external-effects2/_expected/amd/main2.js @@ -0,0 +1,10 @@ +define(['exports', 'external2', './main1', 'external1'], (function (exports, external2, main1, external1) { 'use strict'; + + + + Object.defineProperty(exports, "foo", { + enumerable: true, + get: function () { return external2.foo; } + }); + +})); diff --git a/test/chunking-form/samples/min-chunk-size/track-external-effects2/_expected/cjs/main1.js b/test/chunking-form/samples/min-chunk-size/track-external-effects2/_expected/cjs/main1.js new file mode 100644 index 00000000000..297c828e488 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/track-external-effects2/_expected/cjs/main1.js @@ -0,0 +1,11 @@ +'use strict'; + +var external1 = require('external1'); +require('external2'); + +console.log('shared'); + +Object.defineProperty(exports, "foo", { + enumerable: true, + get: function () { return external1.foo; } +}); diff --git a/test/chunking-form/samples/min-chunk-size/track-external-effects2/_expected/cjs/main2.js b/test/chunking-form/samples/min-chunk-size/track-external-effects2/_expected/cjs/main2.js new file mode 100644 index 00000000000..7fb0a426f64 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/track-external-effects2/_expected/cjs/main2.js @@ -0,0 +1,12 @@ +'use strict'; + +var external2 = require('external2'); +require('./main1.js'); +require('external1'); + + + +Object.defineProperty(exports, "foo", { + enumerable: true, + get: function () { return external2.foo; } +}); diff --git a/test/chunking-form/samples/min-chunk-size/track-external-effects2/_expected/es/main1.js b/test/chunking-form/samples/min-chunk-size/track-external-effects2/_expected/es/main1.js new file mode 100644 index 00000000000..ace55ecbb25 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/track-external-effects2/_expected/es/main1.js @@ -0,0 +1,4 @@ +export { foo } from 'external1'; +import 'external2'; + +console.log('shared'); diff --git a/test/chunking-form/samples/min-chunk-size/track-external-effects2/_expected/es/main2.js b/test/chunking-form/samples/min-chunk-size/track-external-effects2/_expected/es/main2.js new file mode 100644 index 00000000000..15d591f7e88 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/track-external-effects2/_expected/es/main2.js @@ -0,0 +1,3 @@ +export { foo } from 'external2'; +import './main1.js'; +import 'external1'; diff --git a/test/chunking-form/samples/min-chunk-size/track-external-effects2/_expected/system/main1.js b/test/chunking-form/samples/min-chunk-size/track-external-effects2/_expected/system/main1.js new file mode 100644 index 00000000000..98a962090d1 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/track-external-effects2/_expected/system/main1.js @@ -0,0 +1,13 @@ +System.register(['external1', 'external2'], (function (exports) { + 'use strict'; + return { + setters: [function (module) { + exports("foo", module.foo); + }, null], + execute: (function () { + + console.log('shared'); + + }) + }; +})); diff --git a/test/chunking-form/samples/min-chunk-size/track-external-effects2/_expected/system/main2.js b/test/chunking-form/samples/min-chunk-size/track-external-effects2/_expected/system/main2.js new file mode 100644 index 00000000000..0a385cfeec9 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/track-external-effects2/_expected/system/main2.js @@ -0,0 +1,13 @@ +System.register(['external2', './main1.js', 'external1'], (function (exports) { + 'use strict'; + return { + setters: [function (module) { + exports("foo", module.foo); + }, null, null], + execute: (function () { + + + + }) + }; +})); diff --git a/test/chunking-form/samples/min-chunk-size/track-external-effects2/main1.js b/test/chunking-form/samples/min-chunk-size/track-external-effects2/main1.js new file mode 100644 index 00000000000..1fd0bf2e8d4 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/track-external-effects2/main1.js @@ -0,0 +1,2 @@ +export { foo } from 'external1'; +import './shared'; diff --git a/test/chunking-form/samples/min-chunk-size/track-external-effects2/main2.js b/test/chunking-form/samples/min-chunk-size/track-external-effects2/main2.js new file mode 100644 index 00000000000..04802c96a1b --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/track-external-effects2/main2.js @@ -0,0 +1,2 @@ +export { foo } from 'external2'; +import './shared'; diff --git a/test/chunking-form/samples/min-chunk-size/track-external-effects2/shared.js b/test/chunking-form/samples/min-chunk-size/track-external-effects2/shared.js new file mode 100644 index 00000000000..59b494c5580 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/track-external-effects2/shared.js @@ -0,0 +1 @@ +console.log('shared'); diff --git a/test/chunking-form/samples/min-chunk-size/tree-shaking/_config.js b/test/chunking-form/samples/min-chunk-size/tree-shaking/_config.js new file mode 100644 index 00000000000..7861df6dc6a --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/tree-shaking/_config.js @@ -0,0 +1,9 @@ +module.exports = defineTest({ + description: 'takes tree-shaking into account and ignores top-level comments', + options: { + input: ['main1.js', 'main2.js'], + output: { + experimentalMinChunkSize: 100 + } + } +}); diff --git a/test/chunking-form/samples/min-chunk-size/tree-shaking/_expected/amd/main1.js b/test/chunking-form/samples/min-chunk-size/tree-shaking/_expected/amd/main1.js new file mode 100644 index 00000000000..3af0af5846c --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/tree-shaking/_expected/amd/main1.js @@ -0,0 +1,9 @@ +define(['exports'], (function (exports) { 'use strict'; + + console.log('shared'); + + const main = 'main'; + + exports.main = main; + +})); diff --git a/test/chunking-form/samples/min-chunk-size/tree-shaking/_expected/amd/main2.js b/test/chunking-form/samples/min-chunk-size/tree-shaking/_expected/amd/main2.js new file mode 100644 index 00000000000..e0b343c64a1 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/tree-shaking/_expected/amd/main2.js @@ -0,0 +1,5 @@ +define(['./main1'], (function (main1) { 'use strict'; + + console.log('other'); + +})); diff --git a/test/chunking-form/samples/min-chunk-size/tree-shaking/_expected/cjs/main1.js b/test/chunking-form/samples/min-chunk-size/tree-shaking/_expected/cjs/main1.js new file mode 100644 index 00000000000..520db8e0dc5 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/tree-shaking/_expected/cjs/main1.js @@ -0,0 +1,7 @@ +'use strict'; + +console.log('shared'); + +const main = 'main'; + +exports.main = main; diff --git a/test/chunking-form/samples/min-chunk-size/tree-shaking/_expected/cjs/main2.js b/test/chunking-form/samples/min-chunk-size/tree-shaking/_expected/cjs/main2.js new file mode 100644 index 00000000000..25093b58f8e --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/tree-shaking/_expected/cjs/main2.js @@ -0,0 +1,5 @@ +'use strict'; + +require('./main1.js'); + +console.log('other'); diff --git a/test/chunking-form/samples/min-chunk-size/tree-shaking/_expected/es/main1.js b/test/chunking-form/samples/min-chunk-size/tree-shaking/_expected/es/main1.js new file mode 100644 index 00000000000..bc9792e7f53 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/tree-shaking/_expected/es/main1.js @@ -0,0 +1,5 @@ +console.log('shared'); + +const main = 'main'; + +export { main }; diff --git a/test/chunking-form/samples/min-chunk-size/tree-shaking/_expected/es/main2.js b/test/chunking-form/samples/min-chunk-size/tree-shaking/_expected/es/main2.js new file mode 100644 index 00000000000..20a86753f36 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/tree-shaking/_expected/es/main2.js @@ -0,0 +1,3 @@ +import './main1.js'; + +console.log('other'); diff --git a/test/chunking-form/samples/min-chunk-size/tree-shaking/_expected/system/main1.js b/test/chunking-form/samples/min-chunk-size/tree-shaking/_expected/system/main1.js new file mode 100644 index 00000000000..59105e7bfc8 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/tree-shaking/_expected/system/main1.js @@ -0,0 +1,12 @@ +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + + console.log('shared'); + + const main = exports("main", 'main'); + + }) + }; +})); diff --git a/test/chunking-form/samples/min-chunk-size/tree-shaking/_expected/system/main2.js b/test/chunking-form/samples/min-chunk-size/tree-shaking/_expected/system/main2.js new file mode 100644 index 00000000000..920c9d7d0eb --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/tree-shaking/_expected/system/main2.js @@ -0,0 +1,11 @@ +System.register(['./main1.js'], (function () { + 'use strict'; + return { + setters: [null], + execute: (function () { + + console.log('other'); + + }) + }; +})); diff --git a/test/chunking-form/samples/min-chunk-size/tree-shaking/main1.js b/test/chunking-form/samples/min-chunk-size/tree-shaking/main1.js new file mode 100644 index 00000000000..cfd8a9f8bc8 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/tree-shaking/main1.js @@ -0,0 +1,4 @@ +export const main = 'main'; +/* a very long comment exceeding 100 characters + -------------------------------------------- */ +import './shared'; diff --git a/test/chunking-form/samples/min-chunk-size/tree-shaking/main2.js b/test/chunking-form/samples/min-chunk-size/tree-shaking/main2.js new file mode 100644 index 00000000000..7cd409d7acd --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/tree-shaking/main2.js @@ -0,0 +1,2 @@ +import './shared'; +console.log('other'); diff --git a/test/chunking-form/samples/min-chunk-size/tree-shaking/shared.js b/test/chunking-form/samples/min-chunk-size/tree-shaking/shared.js new file mode 100644 index 00000000000..c2664921069 --- /dev/null +++ b/test/chunking-form/samples/min-chunk-size/tree-shaking/shared.js @@ -0,0 +1,4 @@ +console.log('shared'); +/* a very long comment exceeding 100 characters + -------------------------------------------- */ +export const unused = 'also very long and very unused'; diff --git a/test/chunking-form/samples/minify-internal-exports/_config.js b/test/chunking-form/samples/minify-internal-exports/_config.js index e550586d56d..aff56c6f69d 100644 --- a/test/chunking-form/samples/minify-internal-exports/_config.js +++ b/test/chunking-form/samples/minify-internal-exports/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'allows to force the minification of internal exports', options: { input: ['main1.js', 'main2.js'], @@ -6,4 +6,4 @@ module.exports = { minifyInternalExports: true } } -}; +}); diff --git a/test/chunking-form/samples/minify-internal-exports/_expected/amd/generated-shared2.js b/test/chunking-form/samples/minify-internal-exports/_expected/amd/generated-shared2.js index 61a976eced5..dfafa8ac1f9 100644 --- a/test/chunking-form/samples/minify-internal-exports/_expected/amd/generated-shared2.js +++ b/test/chunking-form/samples/minify-internal-exports/_expected/amd/generated-shared2.js @@ -1,4 +1,4 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; const shared1 = 'shared1'; const foo$1 = 'foo1'; @@ -11,4 +11,4 @@ define(['exports'], function (exports) { 'use strict'; exports.f = foo$1; exports.s = shared1; -}); +})); diff --git a/test/chunking-form/samples/minify-internal-exports/_expected/amd/main1.js b/test/chunking-form/samples/minify-internal-exports/_expected/amd/main1.js index 24f7e65ba8b..76811b28fb4 100644 --- a/test/chunking-form/samples/minify-internal-exports/_expected/amd/main1.js +++ b/test/chunking-form/samples/minify-internal-exports/_expected/amd/main1.js @@ -1,5 +1,5 @@ -define(['./generated-shared2'], function (shared2) { 'use strict'; +define(['./generated-shared2'], (function (shared2) { 'use strict'; console.log(shared2.s, shared2.a, shared2.f); -}); +})); diff --git a/test/chunking-form/samples/minify-internal-exports/_expected/amd/main2.js b/test/chunking-form/samples/minify-internal-exports/_expected/amd/main2.js index faa005356a3..187bd22216b 100644 --- a/test/chunking-form/samples/minify-internal-exports/_expected/amd/main2.js +++ b/test/chunking-form/samples/minify-internal-exports/_expected/amd/main2.js @@ -1,5 +1,5 @@ -define(['./generated-shared2'], function (shared2) { 'use strict'; +define(['./generated-shared2'], (function (shared2) { 'use strict'; console.log(shared2.s, shared2.a, shared2.b); -}); +})); diff --git a/test/chunking-form/samples/minify-internal-exports/_expected/system/generated-shared2.js b/test/chunking-form/samples/minify-internal-exports/_expected/system/generated-shared2.js index f00d62e9e24..478d588ebf2 100644 --- a/test/chunking-form/samples/minify-internal-exports/_expected/system/generated-shared2.js +++ b/test/chunking-form/samples/minify-internal-exports/_expected/system/generated-shared2.js @@ -1,14 +1,14 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - const shared1 = exports('s', 'shared1'); - const foo$1 = exports('f', 'foo1'); + const shared1 = exports("s", 'shared1'); + const foo$1 = exports("f", 'foo1'); - var shared2 = exports('a', 'shared2'); - const foo = exports('b', 'foo2'); + var shared2 = exports("a", 'shared2'); + const foo = exports("b", 'foo2'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/minify-internal-exports/_expected/system/main1.js b/test/chunking-form/samples/minify-internal-exports/_expected/system/main1.js index c2bdbb741a1..061c6d5b85c 100644 --- a/test/chunking-form/samples/minify-internal-exports/_expected/system/main1.js +++ b/test/chunking-form/samples/minify-internal-exports/_expected/system/main1.js @@ -1,4 +1,4 @@ -System.register(['./generated-shared2.js'], function () { +System.register(['./generated-shared2.js'], (function () { 'use strict'; var shared1, shared2, foo; return { @@ -7,10 +7,10 @@ System.register(['./generated-shared2.js'], function () { shared2 = module.a; foo = module.f; }], - execute: function () { + execute: (function () { console.log(shared1, shared2, foo); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/minify-internal-exports/_expected/system/main2.js b/test/chunking-form/samples/minify-internal-exports/_expected/system/main2.js index 35d91984a0c..d9b017a884e 100644 --- a/test/chunking-form/samples/minify-internal-exports/_expected/system/main2.js +++ b/test/chunking-form/samples/minify-internal-exports/_expected/system/main2.js @@ -1,4 +1,4 @@ -System.register(['./generated-shared2.js'], function () { +System.register(['./generated-shared2.js'], (function () { 'use strict'; var shared1, shared2, foo; return { @@ -7,10 +7,10 @@ System.register(['./generated-shared2.js'], function () { shared2 = module.a; foo = module.b; }], - execute: function () { + execute: (function () { console.log(shared1, shared2, foo); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/missing-export-compact/_config.js b/test/chunking-form/samples/missing-export-compact/_config.js index 236f582eb45..f7b35f0f4e4 100644 --- a/test/chunking-form/samples/missing-export-compact/_config.js +++ b/test/chunking-form/samples/missing-export-compact/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'missing export compact', expectedWarnings: ['SHIMMED_EXPORT'], options: { @@ -8,4 +8,4 @@ module.exports = { compact: true } } -}; +}); diff --git a/test/chunking-form/samples/missing-export-compact/_expected/amd/dep.js b/test/chunking-form/samples/missing-export-compact/_expected/amd/dep.js index 086ad0730e7..88127064eb5 100644 --- a/test/chunking-form/samples/missing-export-compact/_expected/amd/dep.js +++ b/test/chunking-form/samples/missing-export-compact/_expected/amd/dep.js @@ -1,3 +1,3 @@ -define(['exports'],function(exports){'use strict';var _missingExportShim=void 0;function x (arg) { +define(['exports'],(function(exports){'use strict';var _missingExportShim=void 0;function x (arg) { sideEffect(arg); -}exports.missingExport=_missingExportShim;exports.missingFn=_missingExportShim;exports.x=x;Object.defineProperty(exports,'__esModule',{value:true});}); \ No newline at end of file +}exports.missingExport=_missingExportShim;exports.missingFn=_missingExportShim;exports.x=x;})); \ No newline at end of file diff --git a/test/chunking-form/samples/missing-export-compact/_expected/amd/main.js b/test/chunking-form/samples/missing-export-compact/_expected/amd/main.js index 99e530fa9c8..24109fb301b 100644 --- a/test/chunking-form/samples/missing-export-compact/_expected/amd/main.js +++ b/test/chunking-form/samples/missing-export-compact/_expected/amd/main.js @@ -1,2 +1,2 @@ -define(['./dep'],function(dep){'use strict';dep.missingFn(); -dep.x(dep.missingFn);}); \ No newline at end of file +define(['./dep'],(function(dep){'use strict';dep.missingExport(); +dep.x(dep.missingExport);})); \ No newline at end of file diff --git a/test/chunking-form/samples/missing-export-compact/_expected/cjs/dep.js b/test/chunking-form/samples/missing-export-compact/_expected/cjs/dep.js index 7dba4c72167..3ba21254500 100644 --- a/test/chunking-form/samples/missing-export-compact/_expected/cjs/dep.js +++ b/test/chunking-form/samples/missing-export-compact/_expected/cjs/dep.js @@ -1,3 +1,3 @@ -'use strict';Object.defineProperty(exports,'__esModule',{value:true});var _missingExportShim=void 0;function x (arg) { +'use strict';var _missingExportShim=void 0;function x (arg) { sideEffect(arg); }exports.missingExport=_missingExportShim;exports.missingFn=_missingExportShim;exports.x=x; \ No newline at end of file diff --git a/test/chunking-form/samples/missing-export-compact/_expected/cjs/main.js b/test/chunking-form/samples/missing-export-compact/_expected/cjs/main.js index 08c4ad39ce0..9a4a3ab2737 100644 --- a/test/chunking-form/samples/missing-export-compact/_expected/cjs/main.js +++ b/test/chunking-form/samples/missing-export-compact/_expected/cjs/main.js @@ -1,2 +1,2 @@ -'use strict';var dep=require('./dep.js');dep.missingFn(); -dep.x(dep.missingFn); \ No newline at end of file +'use strict';var dep=require('./dep.js');dep.missingExport(); +dep.x(dep.missingExport); \ No newline at end of file diff --git a/test/chunking-form/samples/missing-export-compact/_expected/es/main.js b/test/chunking-form/samples/missing-export-compact/_expected/es/main.js index f1d0a6754a0..3cd05d105a9 100644 --- a/test/chunking-form/samples/missing-export-compact/_expected/es/main.js +++ b/test/chunking-form/samples/missing-export-compact/_expected/es/main.js @@ -1,2 +1,2 @@ -import {missingFn as _missingExportShim,x}from'./dep.js';_missingExportShim(); +import {missingExport as _missingExportShim,x}from'./dep.js';_missingExportShim(); x(_missingExportShim); \ No newline at end of file diff --git a/test/chunking-form/samples/missing-export-compact/_expected/system/dep.js b/test/chunking-form/samples/missing-export-compact/_expected/system/dep.js index 0513609b4f3..d41bd98a9ef 100644 --- a/test/chunking-form/samples/missing-export-compact/_expected/system/dep.js +++ b/test/chunking-form/samples/missing-export-compact/_expected/system/dep.js @@ -1,3 +1,3 @@ -System.register([],function(exports){'use strict';return{execute:function(){exports('x',x);var _missingExportShim=void 0;function x (arg) { +System.register([],(function(exports){'use strict';return{execute:(function(){exports("x",x);var _missingExportShim=void 0;function x (arg) { sideEffect(arg); -}exports({missingExport:_missingExportShim,missingFn:_missingExportShim});}}}); \ No newline at end of file +}exports({missingExport:_missingExportShim,missingFn:_missingExportShim});})}})); \ No newline at end of file diff --git a/test/chunking-form/samples/missing-export-compact/_expected/system/main.js b/test/chunking-form/samples/missing-export-compact/_expected/system/main.js index bf186d6ef5b..bc077664a48 100644 --- a/test/chunking-form/samples/missing-export-compact/_expected/system/main.js +++ b/test/chunking-form/samples/missing-export-compact/_expected/system/main.js @@ -1,2 +1,2 @@ -System.register(['./dep.js'],function(){'use strict';var _missingExportShim,x;return{setters:[function(module){_missingExportShim=module.missingFn;x=module.x;}],execute:function(){_missingExportShim(); -x(_missingExportShim);}}}); \ No newline at end of file +System.register(['./dep.js'],(function(){'use strict';var _missingExportShim,x;return{setters:[function(module){_missingExportShim=module.missingExport;x=module.x;}],execute:(function(){_missingExportShim(); +x(_missingExportShim);})}})); \ No newline at end of file diff --git a/test/chunking-form/samples/missing-export-reused-deconflicting/_config.js b/test/chunking-form/samples/missing-export-reused-deconflicting/_config.js index fa8ef996a91..1f82231f9ca 100644 --- a/test/chunking-form/samples/missing-export-reused-deconflicting/_config.js +++ b/test/chunking-form/samples/missing-export-reused-deconflicting/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'handles using dependencies with shimmed missing exports as ', expectedWarnings: ['SHIMMED_EXPORT'], options: { @@ -6,4 +6,4 @@ module.exports = { shimMissingExports: true, output: { preserveModules: true } } -}; +}); diff --git a/test/chunking-form/samples/missing-export-reused-deconflicting/_expected/amd/dep1.js b/test/chunking-form/samples/missing-export-reused-deconflicting/_expected/amd/dep1.js index 4e6617810fb..c0bb33a6273 100644 --- a/test/chunking-form/samples/missing-export-reused-deconflicting/_expected/amd/dep1.js +++ b/test/chunking-form/samples/missing-export-reused-deconflicting/_expected/amd/dep1.js @@ -1,19 +1,18 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; var _missingExportShim = void 0; console.log('This is the output when a missing export is used internally but not reexported'); function almostUseUnused(useIt) { - if (useIt) { + { + console.log(useIt); console.log(_missingExportShim); } } - almostUseUnused(false); + almostUseUnused(true); exports.missing1 = _missingExportShim; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/missing-export-reused-deconflicting/_expected/amd/dep2.js b/test/chunking-form/samples/missing-export-reused-deconflicting/_expected/amd/dep2.js index c9382183868..94c9d52cf2c 100644 --- a/test/chunking-form/samples/missing-export-reused-deconflicting/_expected/amd/dep2.js +++ b/test/chunking-form/samples/missing-export-reused-deconflicting/_expected/amd/dep2.js @@ -1,4 +1,4 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; var _missingExportShim = void 0; @@ -11,6 +11,4 @@ define(['exports'], function (exports) { 'use strict'; exports.missing2 = _missingExportShim; exports.previousShimmedExport = _missingExportShim$1; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/missing-export-reused-deconflicting/_expected/amd/main.js b/test/chunking-form/samples/missing-export-reused-deconflicting/_expected/amd/main.js index ec4beefe55b..86f8c833698 100644 --- a/test/chunking-form/samples/missing-export-reused-deconflicting/_expected/amd/main.js +++ b/test/chunking-form/samples/missing-export-reused-deconflicting/_expected/amd/main.js @@ -1,5 +1,5 @@ -define(['./dep1', './dep2'], function (dep1, dep2) { 'use strict'; +define(['./dep1', './dep2'], (function (dep1, dep2) { 'use strict'; console.log(dep1.missing1, dep2.missing2, dep2.previousShimmedExport); -}); +})); diff --git a/test/chunking-form/samples/missing-export-reused-deconflicting/_expected/cjs/dep1.js b/test/chunking-form/samples/missing-export-reused-deconflicting/_expected/cjs/dep1.js index 58c566f2849..31b08b56a1f 100644 --- a/test/chunking-form/samples/missing-export-reused-deconflicting/_expected/cjs/dep1.js +++ b/test/chunking-form/samples/missing-export-reused-deconflicting/_expected/cjs/dep1.js @@ -1,17 +1,16 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - var _missingExportShim = void 0; console.log('This is the output when a missing export is used internally but not reexported'); function almostUseUnused(useIt) { - if (useIt) { + { + console.log(useIt); console.log(_missingExportShim); } } -almostUseUnused(false); +almostUseUnused(true); exports.missing1 = _missingExportShim; diff --git a/test/chunking-form/samples/missing-export-reused-deconflicting/_expected/cjs/dep2.js b/test/chunking-form/samples/missing-export-reused-deconflicting/_expected/cjs/dep2.js index 8a01d991453..f411ae56976 100644 --- a/test/chunking-form/samples/missing-export-reused-deconflicting/_expected/cjs/dep2.js +++ b/test/chunking-form/samples/missing-export-reused-deconflicting/_expected/cjs/dep2.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - var _missingExportShim = void 0; console.log('This is the output when a missing export is reexported'); diff --git a/test/chunking-form/samples/missing-export-reused-deconflicting/_expected/es/dep1.js b/test/chunking-form/samples/missing-export-reused-deconflicting/_expected/es/dep1.js index 99f4196bf72..d9c8b65f05c 100644 --- a/test/chunking-form/samples/missing-export-reused-deconflicting/_expected/es/dep1.js +++ b/test/chunking-form/samples/missing-export-reused-deconflicting/_expected/es/dep1.js @@ -3,11 +3,12 @@ var _missingExportShim = void 0; console.log('This is the output when a missing export is used internally but not reexported'); function almostUseUnused(useIt) { - if (useIt) { + { + console.log(useIt); console.log(_missingExportShim); } } -almostUseUnused(false); +almostUseUnused(true); export { _missingExportShim as missing1 }; diff --git a/test/chunking-form/samples/missing-export-reused-deconflicting/_expected/system/dep1.js b/test/chunking-form/samples/missing-export-reused-deconflicting/_expected/system/dep1.js index 292047e5ff6..24aa7ab54ea 100644 --- a/test/chunking-form/samples/missing-export-reused-deconflicting/_expected/system/dep1.js +++ b/test/chunking-form/samples/missing-export-reused-deconflicting/_expected/system/dep1.js @@ -1,22 +1,23 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { var _missingExportShim = void 0; console.log('This is the output when a missing export is used internally but not reexported'); function almostUseUnused(useIt) { - if (useIt) { + { + console.log(useIt); console.log(_missingExportShim); } } - almostUseUnused(false); + almostUseUnused(true); - exports('missing1', _missingExportShim); + exports("missing1", _missingExportShim); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/missing-export-reused-deconflicting/_expected/system/dep2.js b/test/chunking-form/samples/missing-export-reused-deconflicting/_expected/system/dep2.js index da8178d1d7f..5e1fde53548 100644 --- a/test/chunking-form/samples/missing-export-reused-deconflicting/_expected/system/dep2.js +++ b/test/chunking-form/samples/missing-export-reused-deconflicting/_expected/system/dep2.js @@ -1,18 +1,18 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { var _missingExportShim = void 0; console.log('This is the output when a missing export is reexported'); - var _missingExportShim$1 = exports('previousShimmedExport', void 0); + var _missingExportShim$1 = exports("previousShimmedExport", void 0); console.log(_missingExportShim$1); - exports('missing2', _missingExportShim); + exports("missing2", _missingExportShim); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/missing-export-reused-deconflicting/_expected/system/main.js b/test/chunking-form/samples/missing-export-reused-deconflicting/_expected/system/main.js index fa94551b2ef..85562809d93 100644 --- a/test/chunking-form/samples/missing-export-reused-deconflicting/_expected/system/main.js +++ b/test/chunking-form/samples/missing-export-reused-deconflicting/_expected/system/main.js @@ -1,4 +1,4 @@ -System.register(['./dep1.js', './dep2.js'], function () { +System.register(['./dep1.js', './dep2.js'], (function () { 'use strict'; var _missingExportShim, _missingExportShim$1, _missingExportShim$2; return { @@ -8,10 +8,10 @@ System.register(['./dep1.js', './dep2.js'], function () { _missingExportShim$1 = module.missing2; _missingExportShim$2 = module.previousShimmedExport; }], - execute: function () { + execute: (function () { console.log(_missingExportShim, _missingExportShim$1, _missingExportShim$2); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/missing-export-reused-deconflicting/dep1.js b/test/chunking-form/samples/missing-export-reused-deconflicting/dep1.js index 84e22e0fe8f..f0751ef4cf6 100644 --- a/test/chunking-form/samples/missing-export-reused-deconflicting/dep1.js +++ b/test/chunking-form/samples/missing-export-reused-deconflicting/dep1.js @@ -2,8 +2,9 @@ console.log('This is the output when a missing export is used internally but not function almostUseUnused(useIt) { if (useIt) { + console.log(useIt); console.log(_missingExportShim); } } -almostUseUnused(false); +almostUseUnused(true); diff --git a/test/chunking-form/samples/missing-export/_config.js b/test/chunking-form/samples/missing-export/_config.js index bd55b234392..3681e1060c0 100644 --- a/test/chunking-form/samples/missing-export/_config.js +++ b/test/chunking-form/samples/missing-export/_config.js @@ -1,8 +1,8 @@ -module.exports = { +module.exports = defineTest({ description: 'missing export', expectedWarnings: ['SHIMMED_EXPORT', 'MIXED_EXPORTS'], options: { input: ['main.js', 'dep.js'], shimMissingExports: true } -}; +}); diff --git a/test/chunking-form/samples/missing-export/_expected/amd/dep.js b/test/chunking-form/samples/missing-export/_expected/amd/dep.js index b0a4d553740..c0dc8c6fb63 100644 --- a/test/chunking-form/samples/missing-export/_expected/amd/dep.js +++ b/test/chunking-form/samples/missing-export/_expected/amd/dep.js @@ -1,4 +1,4 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; var _missingExportShim = void 0; @@ -13,4 +13,4 @@ define(['exports'], function (exports) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); -}); +})); diff --git a/test/chunking-form/samples/missing-export/_expected/amd/main.js b/test/chunking-form/samples/missing-export/_expected/amd/main.js index b26a873671d..d83459bf244 100644 --- a/test/chunking-form/samples/missing-export/_expected/amd/main.js +++ b/test/chunking-form/samples/missing-export/_expected/amd/main.js @@ -1,6 +1,6 @@ -define(['./dep'], function (dep) { 'use strict'; +define(['./dep'], (function (dep) { 'use strict'; - dep.missingFn(); - dep.x(dep.missingFn); + dep.default(); + dep.x(dep.default); -}); +})); diff --git a/test/chunking-form/samples/missing-export/_expected/cjs/main.js b/test/chunking-form/samples/missing-export/_expected/cjs/main.js index 60f71a76480..3800d33f8e0 100644 --- a/test/chunking-form/samples/missing-export/_expected/cjs/main.js +++ b/test/chunking-form/samples/missing-export/_expected/cjs/main.js @@ -2,5 +2,5 @@ var dep = require('./dep.js'); -dep.missingFn(); -dep.x(dep.missingFn); +dep.default(); +dep.x(dep.default); diff --git a/test/chunking-form/samples/missing-export/_expected/es/dep.js b/test/chunking-form/samples/missing-export/_expected/es/dep.js index 5fe7b66c9fe..f5a92f04745 100644 --- a/test/chunking-form/samples/missing-export/_expected/es/dep.js +++ b/test/chunking-form/samples/missing-export/_expected/es/dep.js @@ -4,5 +4,4 @@ function x (arg) { sideEffect(arg); } -export default _missingExportShim; -export { _missingExportShim as missingExport, _missingExportShim as missingFn, x }; +export { _missingExportShim as default, _missingExportShim as missingExport, _missingExportShim as missingFn, x }; diff --git a/test/chunking-form/samples/missing-export/_expected/es/main.js b/test/chunking-form/samples/missing-export/_expected/es/main.js index 69c955048c8..c836876073a 100644 --- a/test/chunking-form/samples/missing-export/_expected/es/main.js +++ b/test/chunking-form/samples/missing-export/_expected/es/main.js @@ -1,4 +1,4 @@ -import { missingFn as _missingExportShim, x } from './dep.js'; +import _missingExportShim, { x } from './dep.js'; _missingExportShim(); x(_missingExportShim); diff --git a/test/chunking-form/samples/missing-export/_expected/system/dep.js b/test/chunking-form/samples/missing-export/_expected/system/dep.js index 550be0c3cf2..6a6f32bb2e5 100644 --- a/test/chunking-form/samples/missing-export/_expected/system/dep.js +++ b/test/chunking-form/samples/missing-export/_expected/system/dep.js @@ -1,9 +1,9 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - exports('x', x); + exports("x", x); var _missingExportShim = void 0; @@ -17,6 +17,6 @@ System.register([], function (exports) { missingFn: _missingExportShim }); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/missing-export/_expected/system/main.js b/test/chunking-form/samples/missing-export/_expected/system/main.js index f7e096a7b2c..ccbc4932958 100644 --- a/test/chunking-form/samples/missing-export/_expected/system/main.js +++ b/test/chunking-form/samples/missing-export/_expected/system/main.js @@ -1,16 +1,16 @@ -System.register(['./dep.js'], function () { +System.register(['./dep.js'], (function () { 'use strict'; var _missingExportShim, x; return { setters: [function (module) { - _missingExportShim = module.missingFn; + _missingExportShim = module.default; x = module.x; }], - execute: function () { + execute: (function () { _missingExportShim(); x(_missingExportShim); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/multi-chunking/_config.js b/test/chunking-form/samples/multi-chunking/_config.js index 7e89c5b03b0..3ad13c73f33 100644 --- a/test/chunking-form/samples/multi-chunking/_config.js +++ b/test/chunking-form/samples/multi-chunking/_config.js @@ -1,6 +1,6 @@ -module.exports = { +module.exports = defineTest({ description: 'simple chunking', options: { input: ['main1.js', 'main2.js', 'main3.js'] } -}; +}); diff --git a/test/chunking-form/samples/multi-chunking/_expected/amd/generated-dep1.js b/test/chunking-form/samples/multi-chunking/_expected/amd/generated-dep1.js index adcda74465b..972b13ee121 100644 --- a/test/chunking-form/samples/multi-chunking/_expected/amd/generated-dep1.js +++ b/test/chunking-form/samples/multi-chunking/_expected/amd/generated-dep1.js @@ -1,7 +1,7 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; var num = 1; exports.num = num; -}); +})); diff --git a/test/chunking-form/samples/multi-chunking/_expected/amd/generated-dep2.js b/test/chunking-form/samples/multi-chunking/_expected/amd/generated-dep2.js index a1d8833c67a..76b78a38c0a 100644 --- a/test/chunking-form/samples/multi-chunking/_expected/amd/generated-dep2.js +++ b/test/chunking-form/samples/multi-chunking/_expected/amd/generated-dep2.js @@ -1,7 +1,7 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; var num = 2; exports.num = num; -}); +})); diff --git a/test/chunking-form/samples/multi-chunking/_expected/amd/generated-dep3.js b/test/chunking-form/samples/multi-chunking/_expected/amd/generated-dep3.js index 301f565bc07..69a887664de 100644 --- a/test/chunking-form/samples/multi-chunking/_expected/amd/generated-dep3.js +++ b/test/chunking-form/samples/multi-chunking/_expected/amd/generated-dep3.js @@ -1,7 +1,7 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; var num = 3; exports.num = num; -}); +})); diff --git a/test/chunking-form/samples/multi-chunking/_expected/amd/main1.js b/test/chunking-form/samples/multi-chunking/_expected/amd/main1.js index d80fcec60b9..8e9958d5d4a 100644 --- a/test/chunking-form/samples/multi-chunking/_expected/amd/main1.js +++ b/test/chunking-form/samples/multi-chunking/_expected/amd/main1.js @@ -1,5 +1,5 @@ -define(['./generated-dep1', './generated-dep2'], function (dep1, dep2) { 'use strict'; +define(['./generated-dep1', './generated-dep2'], (function (dep1, dep2) { 'use strict'; console.log(dep1.num + dep2.num); -}); +})); diff --git a/test/chunking-form/samples/multi-chunking/_expected/amd/main2.js b/test/chunking-form/samples/multi-chunking/_expected/amd/main2.js index a1004c1c5e5..b71c96573be 100644 --- a/test/chunking-form/samples/multi-chunking/_expected/amd/main2.js +++ b/test/chunking-form/samples/multi-chunking/_expected/amd/main2.js @@ -1,5 +1,5 @@ -define(['./generated-dep2', './generated-dep3'], function (dep2, dep3) { 'use strict'; +define(['./generated-dep2', './generated-dep3'], (function (dep2, dep3) { 'use strict'; console.log(dep2.num + dep3.num); -}); +})); diff --git a/test/chunking-form/samples/multi-chunking/_expected/amd/main3.js b/test/chunking-form/samples/multi-chunking/_expected/amd/main3.js index d7f5a6375ad..db99b601ef6 100644 --- a/test/chunking-form/samples/multi-chunking/_expected/amd/main3.js +++ b/test/chunking-form/samples/multi-chunking/_expected/amd/main3.js @@ -1,5 +1,5 @@ -define(['./generated-dep1', './generated-dep3'], function (dep1, dep3) { 'use strict'; +define(['./generated-dep1', './generated-dep3'], (function (dep1, dep3) { 'use strict'; console.log(dep1.num + dep3.num); -}); +})); diff --git a/test/chunking-form/samples/multi-chunking/_expected/system/generated-dep1.js b/test/chunking-form/samples/multi-chunking/_expected/system/generated-dep1.js index 6f90b945280..6766b5b369e 100644 --- a/test/chunking-form/samples/multi-chunking/_expected/system/generated-dep1.js +++ b/test/chunking-form/samples/multi-chunking/_expected/system/generated-dep1.js @@ -1,10 +1,10 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - var num = exports('n', 1); + var num = exports("n", 1); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/multi-chunking/_expected/system/generated-dep2.js b/test/chunking-form/samples/multi-chunking/_expected/system/generated-dep2.js index cb32055bf44..f200dffc1ed 100644 --- a/test/chunking-form/samples/multi-chunking/_expected/system/generated-dep2.js +++ b/test/chunking-form/samples/multi-chunking/_expected/system/generated-dep2.js @@ -1,10 +1,10 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - var num = exports('n', 2); + var num = exports("n", 2); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/multi-chunking/_expected/system/generated-dep3.js b/test/chunking-form/samples/multi-chunking/_expected/system/generated-dep3.js index 77b824db0df..b0a345d9b4e 100644 --- a/test/chunking-form/samples/multi-chunking/_expected/system/generated-dep3.js +++ b/test/chunking-form/samples/multi-chunking/_expected/system/generated-dep3.js @@ -1,10 +1,10 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - var num = exports('n', 3); + var num = exports("n", 3); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/multi-chunking/_expected/system/main1.js b/test/chunking-form/samples/multi-chunking/_expected/system/main1.js index 3225e3904ba..d6c446c9440 100644 --- a/test/chunking-form/samples/multi-chunking/_expected/system/main1.js +++ b/test/chunking-form/samples/multi-chunking/_expected/system/main1.js @@ -1,4 +1,4 @@ -System.register(['./generated-dep1.js', './generated-dep2.js'], function () { +System.register(['./generated-dep1.js', './generated-dep2.js'], (function () { 'use strict'; var num, num$1; return { @@ -7,10 +7,10 @@ System.register(['./generated-dep1.js', './generated-dep2.js'], function () { }, function (module) { num$1 = module.n; }], - execute: function () { + execute: (function () { console.log(num + num$1); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/multi-chunking/_expected/system/main2.js b/test/chunking-form/samples/multi-chunking/_expected/system/main2.js index 36473866c15..a7c20f30e94 100644 --- a/test/chunking-form/samples/multi-chunking/_expected/system/main2.js +++ b/test/chunking-form/samples/multi-chunking/_expected/system/main2.js @@ -1,4 +1,4 @@ -System.register(['./generated-dep2.js', './generated-dep3.js'], function () { +System.register(['./generated-dep2.js', './generated-dep3.js'], (function () { 'use strict'; var num, num$1; return { @@ -7,10 +7,10 @@ System.register(['./generated-dep2.js', './generated-dep3.js'], function () { }, function (module) { num$1 = module.n; }], - execute: function () { + execute: (function () { console.log(num + num$1); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/multi-chunking/_expected/system/main3.js b/test/chunking-form/samples/multi-chunking/_expected/system/main3.js index 969f68fdd31..b0866a7c086 100644 --- a/test/chunking-form/samples/multi-chunking/_expected/system/main3.js +++ b/test/chunking-form/samples/multi-chunking/_expected/system/main3.js @@ -1,4 +1,4 @@ -System.register(['./generated-dep1.js', './generated-dep3.js'], function () { +System.register(['./generated-dep1.js', './generated-dep3.js'], (function () { 'use strict'; var num, num$1; return { @@ -7,10 +7,10 @@ System.register(['./generated-dep1.js', './generated-dep3.js'], function () { }, function (module) { num$1 = module.n; }], - execute: function () { + execute: (function () { console.log(num + num$1); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/multiple-entry-points/_config.js b/test/chunking-form/samples/multiple-entry-points/_config.js index e8f588be523..4ca7d1a2563 100644 --- a/test/chunking-form/samples/multiple-entry-points/_config.js +++ b/test/chunking-form/samples/multiple-entry-points/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'handles multiple entry points with a shared dependency', options: { input: ['main', 'other'], @@ -7,4 +7,4 @@ module.exports = { } }, runAmd: true -}; +}); diff --git a/test/chunking-form/samples/multiple-entry-points/_expected/amd/chunks/shared.js b/test/chunking-form/samples/multiple-entry-points/_expected/amd/chunks/shared.js deleted file mode 100644 index 65e59158953..00000000000 --- a/test/chunking-form/samples/multiple-entry-points/_expected/amd/chunks/shared.js +++ /dev/null @@ -1,7 +0,0 @@ -define(['exports'], function (exports) { 'use strict'; - - const sharedValue = 'shared'; - - exports.sharedValue = sharedValue; - -}); diff --git a/test/chunking-form/samples/multiple-entry-points/_expected/amd/main.js b/test/chunking-form/samples/multiple-entry-points/_expected/amd/main.js index d9da2d72b7c..336128932ce 100644 --- a/test/chunking-form/samples/multiple-entry-points/_expected/amd/main.js +++ b/test/chunking-form/samples/multiple-entry-points/_expected/amd/main.js @@ -1,5 +1,5 @@ -define(['./chunks/shared'], function (shared) { 'use strict'; +define(['./other'], (function (other) { 'use strict'; - assert.equal(shared.sharedValue, 'shared'); + assert.equal(other.sharedValue, 'shared'); -}); +})); diff --git a/test/chunking-form/samples/multiple-entry-points/_expected/amd/other.js b/test/chunking-form/samples/multiple-entry-points/_expected/amd/other.js index dbb13d1f811..5e9a4c1e85b 100644 --- a/test/chunking-form/samples/multiple-entry-points/_expected/amd/other.js +++ b/test/chunking-form/samples/multiple-entry-points/_expected/amd/other.js @@ -1,9 +1,7 @@ -define(['exports', './chunks/shared'], function (exports, shared) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; + const sharedValue = 'shared'; + exports.sharedValue = sharedValue; - exports.sharedValue = shared.sharedValue; - - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/multiple-entry-points/_expected/cjs/chunks/shared.js b/test/chunking-form/samples/multiple-entry-points/_expected/cjs/chunks/shared.js deleted file mode 100644 index 5a6d40af489..00000000000 --- a/test/chunking-form/samples/multiple-entry-points/_expected/cjs/chunks/shared.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -const sharedValue = 'shared'; - -exports.sharedValue = sharedValue; diff --git a/test/chunking-form/samples/multiple-entry-points/_expected/cjs/main.js b/test/chunking-form/samples/multiple-entry-points/_expected/cjs/main.js index 713701b7e81..21ab3a39e5d 100644 --- a/test/chunking-form/samples/multiple-entry-points/_expected/cjs/main.js +++ b/test/chunking-form/samples/multiple-entry-points/_expected/cjs/main.js @@ -1,5 +1,5 @@ 'use strict'; -var shared = require('./chunks/shared.js'); +var other = require('./other.js'); -assert.equal(shared.sharedValue, 'shared'); +assert.equal(other.sharedValue, 'shared'); diff --git a/test/chunking-form/samples/multiple-entry-points/_expected/cjs/other.js b/test/chunking-form/samples/multiple-entry-points/_expected/cjs/other.js index 40cf77c3578..5a6d40af489 100644 --- a/test/chunking-form/samples/multiple-entry-points/_expected/cjs/other.js +++ b/test/chunking-form/samples/multiple-entry-points/_expected/cjs/other.js @@ -1,9 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); +const sharedValue = 'shared'; -var shared = require('./chunks/shared.js'); - - - -exports.sharedValue = shared.sharedValue; +exports.sharedValue = sharedValue; diff --git a/test/chunking-form/samples/multiple-entry-points/_expected/es/chunks/shared.js b/test/chunking-form/samples/multiple-entry-points/_expected/es/chunks/shared.js deleted file mode 100644 index d5f271b2232..00000000000 --- a/test/chunking-form/samples/multiple-entry-points/_expected/es/chunks/shared.js +++ /dev/null @@ -1,3 +0,0 @@ -const sharedValue = 'shared'; - -export { sharedValue as s }; diff --git a/test/chunking-form/samples/multiple-entry-points/_expected/es/main.js b/test/chunking-form/samples/multiple-entry-points/_expected/es/main.js index 9af3da63084..0e4cbfb7d14 100644 --- a/test/chunking-form/samples/multiple-entry-points/_expected/es/main.js +++ b/test/chunking-form/samples/multiple-entry-points/_expected/es/main.js @@ -1,3 +1,3 @@ -import { s as sharedValue } from './chunks/shared.js'; +import { sharedValue } from './other.js'; assert.equal(sharedValue, 'shared'); diff --git a/test/chunking-form/samples/multiple-entry-points/_expected/es/other.js b/test/chunking-form/samples/multiple-entry-points/_expected/es/other.js index 7500959c939..5a4fd1b6713 100644 --- a/test/chunking-form/samples/multiple-entry-points/_expected/es/other.js +++ b/test/chunking-form/samples/multiple-entry-points/_expected/es/other.js @@ -1 +1,3 @@ -export { s as sharedValue } from './chunks/shared.js'; +const sharedValue = 'shared'; + +export { sharedValue }; diff --git a/test/chunking-form/samples/multiple-entry-points/_expected/system/chunks/shared.js b/test/chunking-form/samples/multiple-entry-points/_expected/system/chunks/shared.js deleted file mode 100644 index e50702721a5..00000000000 --- a/test/chunking-form/samples/multiple-entry-points/_expected/system/chunks/shared.js +++ /dev/null @@ -1,10 +0,0 @@ -System.register([], function (exports) { - 'use strict'; - return { - execute: function () { - - const sharedValue = exports('s', 'shared'); - - } - }; -}); diff --git a/test/chunking-form/samples/multiple-entry-points/_expected/system/main.js b/test/chunking-form/samples/multiple-entry-points/_expected/system/main.js index e1235fab616..5ac298477a7 100644 --- a/test/chunking-form/samples/multiple-entry-points/_expected/system/main.js +++ b/test/chunking-form/samples/multiple-entry-points/_expected/system/main.js @@ -1,14 +1,14 @@ -System.register(['./chunks/shared.js'], function () { +System.register(['./other.js'], (function () { 'use strict'; var sharedValue; return { setters: [function (module) { - sharedValue = module.s; + sharedValue = module.sharedValue; }], - execute: function () { + execute: (function () { assert.equal(sharedValue, 'shared'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/multiple-entry-points/_expected/system/other.js b/test/chunking-form/samples/multiple-entry-points/_expected/system/other.js index 3dac21b55e7..c265217647e 100644 --- a/test/chunking-form/samples/multiple-entry-points/_expected/system/other.js +++ b/test/chunking-form/samples/multiple-entry-points/_expected/system/other.js @@ -1,13 +1,10 @@ -System.register(['./chunks/shared.js'], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - setters: [function (module) { - exports('sharedValue', module.s); - }], - execute: function () { + execute: (function () { + const sharedValue = exports("sharedValue", 'shared'); - - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/namespace-imports-from-chunks/_config.js b/test/chunking-form/samples/namespace-imports-from-chunks/_config.js index b5ff817c4b6..88847634fb8 100644 --- a/test/chunking-form/samples/namespace-imports-from-chunks/_config.js +++ b/test/chunking-form/samples/namespace-imports-from-chunks/_config.js @@ -1,6 +1,6 @@ -module.exports = { +module.exports = defineTest({ description: 'handle namespace imports from chunks', options: { input: ['main1.js', 'main2.js'] } -}; +}); diff --git a/test/chunking-form/samples/namespace-imports-from-chunks/_expected/amd/main1.js b/test/chunking-form/samples/namespace-imports-from-chunks/_expected/amd/main1.js index c995123442f..7d5df252b9d 100644 --- a/test/chunking-form/samples/namespace-imports-from-chunks/_expected/amd/main1.js +++ b/test/chunking-form/samples/namespace-imports-from-chunks/_expected/amd/main1.js @@ -1,9 +1,7 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; var p = 42; exports.p = p; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/namespace-imports-from-chunks/_expected/amd/main2.js b/test/chunking-form/samples/namespace-imports-from-chunks/_expected/amd/main2.js index 40c8ca3127f..12c62badd61 100644 --- a/test/chunking-form/samples/namespace-imports-from-chunks/_expected/amd/main2.js +++ b/test/chunking-form/samples/namespace-imports-from-chunks/_expected/amd/main2.js @@ -1,5 +1,5 @@ -define(['./main1'], function (main1) { 'use strict'; +define(['./main1'], (function (main1) { 'use strict'; console.log( main1.p ); -}); +})); diff --git a/test/chunking-form/samples/namespace-imports-from-chunks/_expected/cjs/main1.js b/test/chunking-form/samples/namespace-imports-from-chunks/_expected/cjs/main1.js index 64b0a704dde..eb9a14fc40b 100644 --- a/test/chunking-form/samples/namespace-imports-from-chunks/_expected/cjs/main1.js +++ b/test/chunking-form/samples/namespace-imports-from-chunks/_expected/cjs/main1.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - var p = 42; exports.p = p; diff --git a/test/chunking-form/samples/namespace-imports-from-chunks/_expected/system/main1.js b/test/chunking-form/samples/namespace-imports-from-chunks/_expected/system/main1.js index d77d432a877..b57b7303c3c 100644 --- a/test/chunking-form/samples/namespace-imports-from-chunks/_expected/system/main1.js +++ b/test/chunking-form/samples/namespace-imports-from-chunks/_expected/system/main1.js @@ -1,10 +1,10 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - var p = exports('p', 42); + var p = exports("p", 42); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/namespace-imports-from-chunks/_expected/system/main2.js b/test/chunking-form/samples/namespace-imports-from-chunks/_expected/system/main2.js index 73dd0438811..388e8eea74a 100644 --- a/test/chunking-form/samples/namespace-imports-from-chunks/_expected/system/main2.js +++ b/test/chunking-form/samples/namespace-imports-from-chunks/_expected/system/main2.js @@ -1,14 +1,14 @@ -System.register(['./main1.js'], function () { +System.register(['./main1.js'], (function () { 'use strict'; var p; return { setters: [function (module) { p = module.p; }], - execute: function () { + execute: (function () { console.log( p ); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/namespace-object-import/_config.js b/test/chunking-form/samples/namespace-object-import/_config.js index c746cbbbf8a..a1e72cbf8ec 100644 --- a/test/chunking-form/samples/namespace-object-import/_config.js +++ b/test/chunking-form/samples/namespace-object-import/_config.js @@ -1,6 +1,6 @@ -module.exports = { +module.exports = defineTest({ description: 'namespace object import', options: { input: ['main1.js', 'main2.js'] } -}; +}); diff --git a/test/chunking-form/samples/namespace-object-import/_expected/amd/generated-main2.js b/test/chunking-form/samples/namespace-object-import/_expected/amd/generated-main2.js index 607a4ae6825..efef101a5c8 100644 --- a/test/chunking-form/samples/namespace-object-import/_expected/amd/generated-main2.js +++ b/test/chunking-form/samples/namespace-object-import/_expected/amd/generated-main2.js @@ -1,4 +1,4 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; var a = 'a'; var b = 'a'; @@ -13,4 +13,4 @@ define(['exports'], function (exports) { 'use strict'; exports.b = b; exports.main2 = main2; -}); +})); diff --git a/test/chunking-form/samples/namespace-object-import/_expected/amd/main1.js b/test/chunking-form/samples/namespace-object-import/_expected/amd/main1.js index 78484e848f0..e1924f3212b 100644 --- a/test/chunking-form/samples/namespace-object-import/_expected/amd/main1.js +++ b/test/chunking-form/samples/namespace-object-import/_expected/amd/main1.js @@ -1,7 +1,7 @@ -define(['./generated-main2'], function (main2) { 'use strict'; +define(['./generated-main2'], (function (main2) { 'use strict'; console.log(main2.a); console.log(main2.main2); -}); +})); diff --git a/test/chunking-form/samples/namespace-object-import/_expected/amd/main2.js b/test/chunking-form/samples/namespace-object-import/_expected/amd/main2.js index 58cbd115137..6d7842ba8d4 100644 --- a/test/chunking-form/samples/namespace-object-import/_expected/amd/main2.js +++ b/test/chunking-form/samples/namespace-object-import/_expected/amd/main2.js @@ -1,10 +1,8 @@ -define(['exports', './generated-main2'], function (exports, main2) { 'use strict'; +define(['exports', './generated-main2'], (function (exports, main2) { 'use strict'; exports.a = main2.a; exports.b = main2.b; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/namespace-object-import/_expected/cjs/main2.js b/test/chunking-form/samples/namespace-object-import/_expected/cjs/main2.js index 688bfd2c811..473d5bd10b2 100644 --- a/test/chunking-form/samples/namespace-object-import/_expected/cjs/main2.js +++ b/test/chunking-form/samples/namespace-object-import/_expected/cjs/main2.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - var main2 = require('./generated-main2.js'); diff --git a/test/chunking-form/samples/namespace-object-import/_expected/system/generated-main2.js b/test/chunking-form/samples/namespace-object-import/_expected/system/generated-main2.js index f30d34dac44..0e1925b8a87 100644 --- a/test/chunking-form/samples/namespace-object-import/_expected/system/generated-main2.js +++ b/test/chunking-form/samples/namespace-object-import/_expected/system/generated-main2.js @@ -1,18 +1,18 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - var a = exports('a', 'a'); - var b = exports('b', 'a'); + var a = exports("a", 'a'); + var b = exports("b", 'a'); var main2 = /*#__PURE__*/Object.freeze({ __proto__: null, a: a, b: b }); - exports('m', main2); + exports("m", main2); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/namespace-object-import/_expected/system/main1.js b/test/chunking-form/samples/namespace-object-import/_expected/system/main1.js index 7e0b6ecc415..3cd0aeaf331 100644 --- a/test/chunking-form/samples/namespace-object-import/_expected/system/main1.js +++ b/test/chunking-form/samples/namespace-object-import/_expected/system/main1.js @@ -1,4 +1,4 @@ -System.register(['./generated-main2.js'], function () { +System.register(['./generated-main2.js'], (function () { 'use strict'; var a, main2; return { @@ -6,12 +6,12 @@ System.register(['./generated-main2.js'], function () { a = module.a; main2 = module.m; }], - execute: function () { + execute: (function () { console.log(a); console.log(main2); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/namespace-object-import/_expected/system/main2.js b/test/chunking-form/samples/namespace-object-import/_expected/system/main2.js index b72cf2e0366..2c07104fef3 100644 --- a/test/chunking-form/samples/namespace-object-import/_expected/system/main2.js +++ b/test/chunking-form/samples/namespace-object-import/_expected/system/main2.js @@ -1,16 +1,13 @@ -System.register(['./generated-main2.js'], function (exports) { +System.register(['./generated-main2.js'], (function (exports) { 'use strict'; return { setters: [function (module) { - var _setter = {}; - _setter.a = module.a; - _setter.b = module.b; - exports(_setter); + exports({ a: module.a, b: module.b }); }], - execute: function () { + execute: (function () { - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/namespace-reexport-name-conflict/_config.js b/test/chunking-form/samples/namespace-reexport-name-conflict/_config.js index 538fbb40363..20533781645 100644 --- a/test/chunking-form/samples/namespace-reexport-name-conflict/_config.js +++ b/test/chunking-form/samples/namespace-reexport-name-conflict/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'renders namespaces with reexports that conflict with existing imports', options: { input: ['main1.js', 'main2.js', 'main3.js'], @@ -7,4 +7,4 @@ module.exports = { exports: 'named' } } -}; +}); diff --git a/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/amd/generated-dep.js b/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/amd/generated-dep.js index d0bef9bda22..3697e55bfe8 100644 --- a/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/amd/generated-dep.js +++ b/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/amd/generated-dep.js @@ -1,7 +1,7 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; const reexported = 1; exports.reexported = reexported; -}); +})); diff --git a/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/amd/generated-index.js b/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/amd/generated-index.js index 417ce1f1d08..8081c7cbacf 100644 --- a/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/amd/generated-index.js +++ b/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/amd/generated-index.js @@ -1,4 +1,4 @@ -define(['exports', './generated-dep', 'external'], function (exports, dep, external) { 'use strict'; +define(['exports', './generated-dep', 'external'], (function (exports, dep, external) { 'use strict'; console.log(external.reexported); @@ -9,4 +9,4 @@ define(['exports', './generated-dep', 'external'], function (exports, dep, exter exports.lib = lib; -}); +})); diff --git a/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/amd/main1.js b/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/amd/main1.js index 9a63a48b663..ec8e9fd2f93 100644 --- a/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/amd/main1.js +++ b/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/amd/main1.js @@ -1,5 +1,5 @@ -define(['./generated-index', './generated-dep', 'external'], function (index, dep, external) { 'use strict'; +define(['./generated-index', './generated-dep', 'external'], (function (index, dep, external) { 'use strict'; console.log(index.lib); -}); +})); diff --git a/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/amd/main2.js b/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/amd/main2.js index 29fd4bfafc4..d4c5e28d66e 100644 --- a/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/amd/main2.js +++ b/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/amd/main2.js @@ -1,5 +1,5 @@ -define(['./generated-index', './generated-dep', 'external'], function (index, dep, external) { 'use strict'; +define(['./generated-index', './generated-dep', 'external'], (function (index, dep, external) { 'use strict'; console.log(dep.reexported); -}); +})); diff --git a/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/amd/main3.js b/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/amd/main3.js index 8e61c58a778..b984cf984d5 100644 --- a/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/amd/main3.js +++ b/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/amd/main3.js @@ -1,5 +1,5 @@ -define(['./generated-dep'], function (dep) { 'use strict'; +define(['./generated-dep'], (function (dep) { 'use strict'; console.log(dep.reexported); -}); +})); diff --git a/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/system/generated-dep.js b/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/system/generated-dep.js index 30c03448c5e..5cd687976c4 100644 --- a/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/system/generated-dep.js +++ b/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/system/generated-dep.js @@ -1,10 +1,10 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - const reexported = exports('r', 1); + const reexported = exports("r", 1); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/system/generated-index.js b/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/system/generated-index.js index 8f6d3bfd693..832fba39f68 100644 --- a/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/system/generated-index.js +++ b/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/system/generated-index.js @@ -1,4 +1,4 @@ -System.register(['./generated-dep.js', 'external'], function (exports) { +System.register(['./generated-dep.js', 'external'], (function (exports) { 'use strict'; var reexported$1, reexported; return { @@ -7,7 +7,7 @@ System.register(['./generated-dep.js', 'external'], function (exports) { }, function (module) { reexported = module.reexported; }], - execute: function () { + execute: (function () { console.log(reexported); @@ -15,8 +15,8 @@ System.register(['./generated-dep.js', 'external'], function (exports) { __proto__: null, reexported: reexported$1 }); - exports('l', lib); + exports("l", lib); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/system/main1.js b/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/system/main1.js index 4f903980c6c..f813ed17452 100644 --- a/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/system/main1.js +++ b/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/system/main1.js @@ -1,14 +1,14 @@ -System.register(['./generated-index.js', './generated-dep.js', 'external'], function () { +System.register(['./generated-index.js', './generated-dep.js', 'external'], (function () { 'use strict'; var lib; return { setters: [function (module) { lib = module.l; - }, function () {}, function () {}], - execute: function () { + }, null, null], + execute: (function () { console.log(lib); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/system/main2.js b/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/system/main2.js index 1b7f0f1e9ab..ee341e566cd 100644 --- a/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/system/main2.js +++ b/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/system/main2.js @@ -1,14 +1,14 @@ -System.register(['./generated-index.js', './generated-dep.js', 'external'], function () { +System.register(['./generated-index.js', './generated-dep.js', 'external'], (function () { 'use strict'; var reexported; return { - setters: [function () {}, function (module) { + setters: [null, function (module) { reexported = module.r; - }, function () {}], - execute: function () { + }, null], + execute: (function () { console.log(reexported); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/system/main3.js b/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/system/main3.js index 5469d008508..bd67c0ead1d 100644 --- a/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/system/main3.js +++ b/test/chunking-form/samples/namespace-reexport-name-conflict/_expected/system/main3.js @@ -1,14 +1,14 @@ -System.register(['./generated-dep.js'], function () { +System.register(['./generated-dep.js'], (function () { 'use strict'; var reexported; return { setters: [function (module) { reexported = module.r; }], - execute: function () { + execute: (function () { console.log(reexported); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/namespace-reexports/_config.js b/test/chunking-form/samples/namespace-reexports/_config.js index 16b17829701..aee9dcd1d1a 100644 --- a/test/chunking-form/samples/namespace-reexports/_config.js +++ b/test/chunking-form/samples/namespace-reexports/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'namespace rendering with reexports', options: { input: ['main.js', 'hsl2hsv.js', 'index.js'], @@ -6,4 +6,4 @@ module.exports = { exports: 'named' } } -}; +}); diff --git a/test/chunking-form/samples/namespace-reexports/_expected/amd/generated-index.js b/test/chunking-form/samples/namespace-reexports/_expected/amd/generated-index.js index 279cd8a2300..3b963796f61 100644 --- a/test/chunking-form/samples/namespace-reexports/_expected/amd/generated-index.js +++ b/test/chunking-form/samples/namespace-reexports/_expected/amd/generated-index.js @@ -1,4 +1,4 @@ -define(['exports', './hsl2hsv'], function (exports, hsl2hsv$1) { 'use strict'; +define(['exports', './hsl2hsv'], (function (exports, hsl2hsv$1) { 'use strict'; var hsl2hsv = 'asdf'; @@ -6,9 +6,9 @@ define(['exports', './hsl2hsv'], function (exports, hsl2hsv$1) { 'use strict'; var lib = /*#__PURE__*/Object.freeze({ __proto__: null, - hsl2hsv: hsl2hsv$1['default'] + hsl2hsv: hsl2hsv$1.default }); exports.lib = lib; -}); +})); diff --git a/test/chunking-form/samples/namespace-reexports/_expected/amd/hsl2hsv.js b/test/chunking-form/samples/namespace-reexports/_expected/amd/hsl2hsv.js index 3b4de4c78d8..1b82315e05f 100644 --- a/test/chunking-form/samples/namespace-reexports/_expected/amd/hsl2hsv.js +++ b/test/chunking-form/samples/namespace-reexports/_expected/amd/hsl2hsv.js @@ -1,4 +1,4 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; var hsl2hsv = (h, s, l) => { const t = s * (l < 0.5 ? 1 : 1 - l), @@ -14,4 +14,4 @@ define(['exports'], function (exports) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); -}); +})); diff --git a/test/chunking-form/samples/namespace-reexports/_expected/amd/index.js b/test/chunking-form/samples/namespace-reexports/_expected/amd/index.js index 0bd0247ae7f..8da4a0f9746 100644 --- a/test/chunking-form/samples/namespace-reexports/_expected/amd/index.js +++ b/test/chunking-form/samples/namespace-reexports/_expected/amd/index.js @@ -1,9 +1,7 @@ -define(['exports', './hsl2hsv', './generated-index'], function (exports, hsl2hsv, index) { 'use strict'; +define(['exports', './hsl2hsv', './generated-index'], (function (exports, hsl2hsv, index) { 'use strict'; - exports.hsl2hsv = hsl2hsv['default']; + exports.hsl2hsv = hsl2hsv.default; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/namespace-reexports/_expected/amd/main.js b/test/chunking-form/samples/namespace-reexports/_expected/amd/main.js index 66a16c83d6c..6aa1143fc07 100644 --- a/test/chunking-form/samples/namespace-reexports/_expected/amd/main.js +++ b/test/chunking-form/samples/namespace-reexports/_expected/amd/main.js @@ -1,4 +1,4 @@ -define(['exports', './generated-index', './hsl2hsv'], function (exports, index, hsl2hsv) { 'use strict'; +define(['exports', './generated-index', './hsl2hsv'], (function (exports, index, hsl2hsv) { 'use strict'; console.log(hsl2hsv.p); var main = new Map(Object.entries(index.lib)); @@ -7,4 +7,4 @@ define(['exports', './generated-index', './hsl2hsv'], function (exports, index, Object.defineProperty(exports, '__esModule', { value: true }); -}); +})); diff --git a/test/chunking-form/samples/namespace-reexports/_expected/cjs/generated-index.js b/test/chunking-form/samples/namespace-reexports/_expected/cjs/generated-index.js index 228b8216e3f..ba17616743a 100644 --- a/test/chunking-form/samples/namespace-reexports/_expected/cjs/generated-index.js +++ b/test/chunking-form/samples/namespace-reexports/_expected/cjs/generated-index.js @@ -8,7 +8,7 @@ console.log(hsl2hsv); var lib = /*#__PURE__*/Object.freeze({ __proto__: null, - hsl2hsv: hsl2hsv$1['default'] + hsl2hsv: hsl2hsv$1.default }); exports.lib = lib; diff --git a/test/chunking-form/samples/namespace-reexports/_expected/cjs/index.js b/test/chunking-form/samples/namespace-reexports/_expected/cjs/index.js index 00a9851c62d..1249fe336ad 100644 --- a/test/chunking-form/samples/namespace-reexports/_expected/cjs/index.js +++ b/test/chunking-form/samples/namespace-reexports/_expected/cjs/index.js @@ -1,10 +1,8 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - var hsl2hsv = require('./hsl2hsv.js'); require('./generated-index.js'); -exports.hsl2hsv = hsl2hsv['default']; +exports.hsl2hsv = hsl2hsv.default; diff --git a/test/chunking-form/samples/namespace-reexports/_expected/es/hsl2hsv.js b/test/chunking-form/samples/namespace-reexports/_expected/es/hsl2hsv.js index e2b167b0949..ed70b7b160c 100644 --- a/test/chunking-form/samples/namespace-reexports/_expected/es/hsl2hsv.js +++ b/test/chunking-form/samples/namespace-reexports/_expected/es/hsl2hsv.js @@ -7,5 +7,4 @@ var hsl2hsv = (h, s, l) => { var p = 5; -export default hsl2hsv; -export { p }; +export { hsl2hsv as default, p }; diff --git a/test/chunking-form/samples/namespace-reexports/_expected/es/main.js b/test/chunking-form/samples/namespace-reexports/_expected/es/main.js index 716aeaba0fa..afa6b6f2359 100644 --- a/test/chunking-form/samples/namespace-reexports/_expected/es/main.js +++ b/test/chunking-form/samples/namespace-reexports/_expected/es/main.js @@ -4,4 +4,4 @@ import { p } from './hsl2hsv.js'; console.log(p); var main = new Map(Object.entries(lib)); -export default main; +export { main as default }; diff --git a/test/chunking-form/samples/namespace-reexports/_expected/system/generated-index.js b/test/chunking-form/samples/namespace-reexports/_expected/system/generated-index.js index 118caaa4461..8d401f64ce3 100644 --- a/test/chunking-form/samples/namespace-reexports/_expected/system/generated-index.js +++ b/test/chunking-form/samples/namespace-reexports/_expected/system/generated-index.js @@ -1,11 +1,11 @@ -System.register(['./hsl2hsv.js'], function (exports) { +System.register(['./hsl2hsv.js'], (function (exports) { 'use strict'; var hsl2hsv$1; return { setters: [function (module) { hsl2hsv$1 = module.default; }], - execute: function () { + execute: (function () { var hsl2hsv = 'asdf'; @@ -15,8 +15,8 @@ System.register(['./hsl2hsv.js'], function (exports) { __proto__: null, hsl2hsv: hsl2hsv$1 }); - exports('l', lib); + exports("l", lib); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/namespace-reexports/_expected/system/hsl2hsv.js b/test/chunking-form/samples/namespace-reexports/_expected/system/hsl2hsv.js index 2ccb8a5d8c7..cbfe403b0fc 100644 --- a/test/chunking-form/samples/namespace-reexports/_expected/system/hsl2hsv.js +++ b/test/chunking-form/samples/namespace-reexports/_expected/system/hsl2hsv.js @@ -1,17 +1,17 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - var hsl2hsv = exports('default', (h, s, l) => { + var hsl2hsv = exports("default", (h, s, l) => { const t = s * (l < 0.5 ? 1 : 1 - l), V = 1 + t, S = 2 * t / V ; return [h, S, V]; }); - var p = exports('p', 5); + var p = exports("p", 5); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/namespace-reexports/_expected/system/index.js b/test/chunking-form/samples/namespace-reexports/_expected/system/index.js index 3df535ca051..41161aa43bd 100644 --- a/test/chunking-form/samples/namespace-reexports/_expected/system/index.js +++ b/test/chunking-form/samples/namespace-reexports/_expected/system/index.js @@ -1,13 +1,13 @@ -System.register(['./hsl2hsv.js', './generated-index.js'], function (exports) { +System.register(['./hsl2hsv.js', './generated-index.js'], (function (exports) { 'use strict'; return { setters: [function (module) { - exports('hsl2hsv', module.default); - }, function () {}], - execute: function () { + exports("hsl2hsv", module.default); + }, null], + execute: (function () { - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/namespace-reexports/_expected/system/main.js b/test/chunking-form/samples/namespace-reexports/_expected/system/main.js index cb3c1c8b4ec..18869b87e20 100644 --- a/test/chunking-form/samples/namespace-reexports/_expected/system/main.js +++ b/test/chunking-form/samples/namespace-reexports/_expected/system/main.js @@ -1,4 +1,4 @@ -System.register(['./generated-index.js', './hsl2hsv.js'], function (exports) { +System.register(['./generated-index.js', './hsl2hsv.js'], (function (exports) { 'use strict'; var lib, p; return { @@ -7,11 +7,11 @@ System.register(['./generated-index.js', './hsl2hsv.js'], function (exports) { }, function (module) { p = module.p; }], - execute: function () { + execute: (function () { console.log(p); - var main = exports('default', new Map(Object.entries(lib))); + var main = exports("default", new Map(Object.entries(lib))); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/namespace-retracing/_config.js b/test/chunking-form/samples/namespace-retracing/_config.js index 6169fb37668..81c0950bea2 100644 --- a/test/chunking-form/samples/namespace-retracing/_config.js +++ b/test/chunking-form/samples/namespace-retracing/_config.js @@ -1,6 +1,6 @@ -module.exports = { +module.exports = defineTest({ description: 'internal reexported namespaces over chunk boundaries', options: { input: ['main-a.js', 'main-b.js'] } -}; +}); diff --git a/test/chunking-form/samples/namespace-retracing/_expected/amd/generated-other.js b/test/chunking-form/samples/namespace-retracing/_expected/amd/generated-other.js index 66808ac4942..c915035b9e2 100644 --- a/test/chunking-form/samples/namespace-retracing/_expected/amd/generated-other.js +++ b/test/chunking-form/samples/namespace-retracing/_expected/amd/generated-other.js @@ -1,4 +1,4 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; class Broken { } @@ -15,4 +15,4 @@ define(['exports'], function (exports) { 'use strict'; exports.Broken = Broken; exports.Other = Other; -}); +})); diff --git a/test/chunking-form/samples/namespace-retracing/_expected/amd/main-a.js b/test/chunking-form/samples/namespace-retracing/_expected/amd/main-a.js index 8dae1d07429..43776dc9fa6 100644 --- a/test/chunking-form/samples/namespace-retracing/_expected/amd/main-a.js +++ b/test/chunking-form/samples/namespace-retracing/_expected/amd/main-a.js @@ -1,6 +1,6 @@ -define(['./generated-other'], function (other) { 'use strict'; +define(['./generated-other'], (function (other) { 'use strict'; other.Other.doSomething(); other.Broken.doSomething(); -}); +})); diff --git a/test/chunking-form/samples/namespace-retracing/_expected/amd/main-b.js b/test/chunking-form/samples/namespace-retracing/_expected/amd/main-b.js index 0466893c505..43776d2cebe 100644 --- a/test/chunking-form/samples/namespace-retracing/_expected/amd/main-b.js +++ b/test/chunking-form/samples/namespace-retracing/_expected/amd/main-b.js @@ -1,5 +1,5 @@ -define(['./generated-other'], function (other) { 'use strict'; +define(['./generated-other'], (function (other) { 'use strict'; other.Other.doSomething(); -}); +})); diff --git a/test/chunking-form/samples/namespace-retracing/_expected/system/generated-other.js b/test/chunking-form/samples/namespace-retracing/_expected/system/generated-other.js index 9ca624860ab..4f6d55e92ef 100644 --- a/test/chunking-form/samples/namespace-retracing/_expected/system/generated-other.js +++ b/test/chunking-form/samples/namespace-retracing/_expected/system/generated-other.js @@ -1,20 +1,20 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { class Broken { - } exports('B', Broken); + } exports("B", Broken); Broken.doSomething = function() { console.log('broken'); }; Broken.doSomething(); class Other { - } exports('O', Other); + } exports("O", Other); Other.doSomething = function() { console.log('other'); }; - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/namespace-retracing/_expected/system/main-a.js b/test/chunking-form/samples/namespace-retracing/_expected/system/main-a.js index 8e17f8f314a..4d968d27bc0 100644 --- a/test/chunking-form/samples/namespace-retracing/_expected/system/main-a.js +++ b/test/chunking-form/samples/namespace-retracing/_expected/system/main-a.js @@ -1,4 +1,4 @@ -System.register(['./generated-other.js'], function () { +System.register(['./generated-other.js'], (function () { 'use strict'; var Other, Broken; return { @@ -6,11 +6,11 @@ System.register(['./generated-other.js'], function () { Other = module.O; Broken = module.B; }], - execute: function () { + execute: (function () { Other.doSomething(); Broken.doSomething(); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/namespace-retracing/_expected/system/main-b.js b/test/chunking-form/samples/namespace-retracing/_expected/system/main-b.js index 8d057522e89..7c5f355d4f2 100644 --- a/test/chunking-form/samples/namespace-retracing/_expected/system/main-b.js +++ b/test/chunking-form/samples/namespace-retracing/_expected/system/main-b.js @@ -1,14 +1,14 @@ -System.register(['./generated-other.js'], function () { +System.register(['./generated-other.js'], (function () { 'use strict'; var Other; return { setters: [function (module) { Other = module.O; }], - execute: function () { + execute: (function () { Other.doSomething(); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/namespace-tostring/dynamic-import-default-mode/_config.js b/test/chunking-form/samples/namespace-tostring/dynamic-import-default-mode/_config.js index af0e0e6af98..d396528a6e9 100644 --- a/test/chunking-form/samples/namespace-tostring/dynamic-import-default-mode/_config.js +++ b/test/chunking-form/samples/namespace-tostring/dynamic-import-default-mode/_config.js @@ -1,10 +1,10 @@ -module.exports = { +module.exports = defineTest({ description: 'adds Symbol.toStringTag property to dynamic imports of entry chunks with default export mode', options: { input: ['main', 'foo'], output: { - namespaceToStringTag: true + generatedCode: { symbols: true } } } -}; +}); diff --git a/test/chunking-form/samples/namespace-tostring/dynamic-import-default-mode/_expected/amd/foo.js b/test/chunking-form/samples/namespace-tostring/dynamic-import-default-mode/_expected/amd/foo.js index 2bc02b35588..69228f8fb6e 100644 --- a/test/chunking-form/samples/namespace-tostring/dynamic-import-default-mode/_expected/amd/foo.js +++ b/test/chunking-form/samples/namespace-tostring/dynamic-import-default-mode/_expected/amd/foo.js @@ -1,7 +1,7 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; var foo = 42; return foo; -}); +})); diff --git a/test/chunking-form/samples/namespace-tostring/dynamic-import-default-mode/_expected/amd/main.js b/test/chunking-form/samples/namespace-tostring/dynamic-import-default-mode/_expected/amd/main.js index ef7142ed35c..8f783a26d7a 100644 --- a/test/chunking-form/samples/namespace-tostring/dynamic-import-default-mode/_expected/amd/main.js +++ b/test/chunking-form/samples/namespace-tostring/dynamic-import-default-mode/_expected/amd/main.js @@ -1,9 +1,7 @@ -define(['require'], function (require) { 'use strict'; +define(['require'], (function (require) { 'use strict'; - function _interopNamespaceDefaultOnly(e) { - return Object.freeze({__proto__: null, [Symbol.toStringTag]: 'Module', 'default': e}); - } + function _interopNamespaceDefaultOnly (e) { return Object.freeze(Object.defineProperty({ __proto__: null, default: e }, Symbol.toStringTag, { value: 'Module' })); } - new Promise(function (resolve, reject) { require(['./foo'], function (m) { resolve(/*#__PURE__*/_interopNamespaceDefaultOnly(m)); }, reject) }).then(console.log); + new Promise(function (resolve, reject) { require(['./foo'], function (m) { resolve(/*#__PURE__*/_interopNamespaceDefaultOnly(m)); }, reject); }).then(console.log); -}); +})); diff --git a/test/chunking-form/samples/namespace-tostring/dynamic-import-default-mode/_expected/cjs/main.js b/test/chunking-form/samples/namespace-tostring/dynamic-import-default-mode/_expected/cjs/main.js index fce5a893ce9..fc716bca3de 100644 --- a/test/chunking-form/samples/namespace-tostring/dynamic-import-default-mode/_expected/cjs/main.js +++ b/test/chunking-form/samples/namespace-tostring/dynamic-import-default-mode/_expected/cjs/main.js @@ -1,7 +1,5 @@ 'use strict'; -function _interopNamespaceDefaultOnly(e) { - return Object.freeze({__proto__: null, [Symbol.toStringTag]: 'Module', 'default': e}); -} +function _interopNamespaceDefaultOnly (e) { return Object.freeze(Object.defineProperty({ __proto__: null, default: e }, Symbol.toStringTag, { value: 'Module' })); } Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespaceDefaultOnly(require('./foo.js')); }).then(console.log); diff --git a/test/chunking-form/samples/namespace-tostring/dynamic-import-default-mode/_expected/es/foo.js b/test/chunking-form/samples/namespace-tostring/dynamic-import-default-mode/_expected/es/foo.js index 8ac2b2169a4..2685886fe7a 100644 --- a/test/chunking-form/samples/namespace-tostring/dynamic-import-default-mode/_expected/es/foo.js +++ b/test/chunking-form/samples/namespace-tostring/dynamic-import-default-mode/_expected/es/foo.js @@ -1,3 +1,3 @@ var foo = 42; -export default foo; +export { foo as default }; diff --git a/test/chunking-form/samples/namespace-tostring/dynamic-import-default-mode/_expected/system/foo.js b/test/chunking-form/samples/namespace-tostring/dynamic-import-default-mode/_expected/system/foo.js index 81b45b772a8..a5b1fc0d011 100644 --- a/test/chunking-form/samples/namespace-tostring/dynamic-import-default-mode/_expected/system/foo.js +++ b/test/chunking-form/samples/namespace-tostring/dynamic-import-default-mode/_expected/system/foo.js @@ -1,10 +1,10 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - var foo = exports('default', 42); + var foo = exports("default", 42); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/namespace-tostring/dynamic-import-default-mode/_expected/system/main.js b/test/chunking-form/samples/namespace-tostring/dynamic-import-default-mode/_expected/system/main.js index 5635ea11806..a5552580fb2 100644 --- a/test/chunking-form/samples/namespace-tostring/dynamic-import-default-mode/_expected/system/main.js +++ b/test/chunking-form/samples/namespace-tostring/dynamic-import-default-mode/_expected/system/main.js @@ -1,10 +1,10 @@ -System.register([], function (exports, module) { +System.register([], (function (exports, module) { 'use strict'; return { - execute: function () { + execute: (function () { module.import('./foo.js').then(console.log); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/namespace-tostring/dynamic-import/_config.js b/test/chunking-form/samples/namespace-tostring/dynamic-import/_config.js index 8cb42fbd52a..fd0d299f4a6 100644 --- a/test/chunking-form/samples/namespace-tostring/dynamic-import/_config.js +++ b/test/chunking-form/samples/namespace-tostring/dynamic-import/_config.js @@ -1,8 +1,8 @@ -module.exports = { +module.exports = defineTest({ description: 'adds Symbol.toStringTag property to dynamic imports', options: { output: { - namespaceToStringTag: true + generatedCode: { symbols: true } } } -}; +}); diff --git a/test/chunking-form/samples/namespace-tostring/dynamic-import/_expected/amd/generated-foo.js b/test/chunking-form/samples/namespace-tostring/dynamic-import/_expected/amd/generated-foo.js index 144e6c7a0fa..ceaf138a547 100644 --- a/test/chunking-form/samples/namespace-tostring/dynamic-import/_expected/amd/generated-foo.js +++ b/test/chunking-form/samples/namespace-tostring/dynamic-import/_expected/amd/generated-foo.js @@ -1,9 +1,9 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; const bar = 42; exports.bar = bar; - exports[Symbol.toStringTag] = 'Module'; + Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); -}); +})); diff --git a/test/chunking-form/samples/namespace-tostring/dynamic-import/_expected/amd/main.js b/test/chunking-form/samples/namespace-tostring/dynamic-import/_expected/amd/main.js index 9809bf12c66..5268640bab9 100644 --- a/test/chunking-form/samples/namespace-tostring/dynamic-import/_expected/amd/main.js +++ b/test/chunking-form/samples/namespace-tostring/dynamic-import/_expected/amd/main.js @@ -1,5 +1,5 @@ -define(['require'], function (require) { 'use strict'; +define(['require'], (function (require) { 'use strict'; - new Promise(function (resolve, reject) { require(['./generated-foo'], resolve, reject) }).then(console.log); + new Promise(function (resolve, reject) { require(['./generated-foo'], resolve, reject); }).then(console.log); -}); +})); diff --git a/test/chunking-form/samples/namespace-tostring/dynamic-import/_expected/cjs/generated-foo.js b/test/chunking-form/samples/namespace-tostring/dynamic-import/_expected/cjs/generated-foo.js index 1dba95c4b6a..7e415cb7783 100644 --- a/test/chunking-form/samples/namespace-tostring/dynamic-import/_expected/cjs/generated-foo.js +++ b/test/chunking-form/samples/namespace-tostring/dynamic-import/_expected/cjs/generated-foo.js @@ -1,6 +1,6 @@ 'use strict'; -exports[Symbol.toStringTag] = 'Module'; +Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); const bar = 42; diff --git a/test/chunking-form/samples/namespace-tostring/dynamic-import/_expected/system/generated-foo.js b/test/chunking-form/samples/namespace-tostring/dynamic-import/_expected/system/generated-foo.js index 04fc5e57c91..47e67e00322 100644 --- a/test/chunking-form/samples/namespace-tostring/dynamic-import/_expected/system/generated-foo.js +++ b/test/chunking-form/samples/namespace-tostring/dynamic-import/_expected/system/generated-foo.js @@ -1,10 +1,10 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - const bar = exports('bar', 42); + const bar = exports("bar", 42); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/namespace-tostring/dynamic-import/_expected/system/main.js b/test/chunking-form/samples/namespace-tostring/dynamic-import/_expected/system/main.js index 365a5e373e3..ed21ee675a3 100644 --- a/test/chunking-form/samples/namespace-tostring/dynamic-import/_expected/system/main.js +++ b/test/chunking-form/samples/namespace-tostring/dynamic-import/_expected/system/main.js @@ -1,10 +1,10 @@ -System.register([], function (exports, module) { +System.register([], (function (exports, module) { 'use strict'; return { - execute: function () { + execute: (function () { module.import('./generated-foo.js').then(console.log); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/namespace-tracing/_config.js b/test/chunking-form/samples/namespace-tracing/_config.js index 230f2306e52..2e3781c5ad2 100644 --- a/test/chunking-form/samples/namespace-tracing/_config.js +++ b/test/chunking-form/samples/namespace-tracing/_config.js @@ -1,6 +1,6 @@ -module.exports = { +module.exports = defineTest({ description: 'Something', options: { input: ['main-a.js', 'main-b.js', 'main-c.js'] } -}; +}); diff --git a/test/chunking-form/samples/namespace-tracing/_expected/amd/generated-bar.js b/test/chunking-form/samples/namespace-tracing/_expected/amd/generated-bar.js index f8f78c489f8..e72450d0cc5 100644 --- a/test/chunking-form/samples/namespace-tracing/_expected/amd/generated-bar.js +++ b/test/chunking-form/samples/namespace-tracing/_expected/amd/generated-bar.js @@ -1,4 +1,4 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; function bar() { console.log('bar'); @@ -6,4 +6,4 @@ define(['exports'], function (exports) { 'use strict'; exports.bar = bar; -}); +})); diff --git a/test/chunking-form/samples/namespace-tracing/_expected/amd/generated-broken.js b/test/chunking-form/samples/namespace-tracing/_expected/amd/generated-broken.js index 1d95e385541..af37af53fe2 100644 --- a/test/chunking-form/samples/namespace-tracing/_expected/amd/generated-broken.js +++ b/test/chunking-form/samples/namespace-tracing/_expected/amd/generated-broken.js @@ -1,4 +1,4 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; function broken() { console.log('broken'); @@ -6,4 +6,4 @@ define(['exports'], function (exports) { 'use strict'; exports.broken = broken; -}); +})); diff --git a/test/chunking-form/samples/namespace-tracing/_expected/amd/generated-foo.js b/test/chunking-form/samples/namespace-tracing/_expected/amd/generated-foo.js index 2ba41e836d7..def7a367dc4 100644 --- a/test/chunking-form/samples/namespace-tracing/_expected/amd/generated-foo.js +++ b/test/chunking-form/samples/namespace-tracing/_expected/amd/generated-foo.js @@ -1,4 +1,4 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; function foo() { console.log('foo'); @@ -6,4 +6,4 @@ define(['exports'], function (exports) { 'use strict'; exports.foo = foo; -}); +})); diff --git a/test/chunking-form/samples/namespace-tracing/_expected/amd/main-a.js b/test/chunking-form/samples/namespace-tracing/_expected/amd/main-a.js index 5b5590c79d7..71e00bfe9a6 100644 --- a/test/chunking-form/samples/namespace-tracing/_expected/amd/main-a.js +++ b/test/chunking-form/samples/namespace-tracing/_expected/amd/main-a.js @@ -1,6 +1,6 @@ -define(['./generated-foo', './generated-broken'], function (foo, broken) { 'use strict'; +define(['./generated-foo', './generated-broken'], (function (foo, broken) { 'use strict'; foo.foo(); broken.broken(); -}); +})); diff --git a/test/chunking-form/samples/namespace-tracing/_expected/amd/main-b.js b/test/chunking-form/samples/namespace-tracing/_expected/amd/main-b.js index 70d5de78739..9e97e5b72b8 100644 --- a/test/chunking-form/samples/namespace-tracing/_expected/amd/main-b.js +++ b/test/chunking-form/samples/namespace-tracing/_expected/amd/main-b.js @@ -1,8 +1,8 @@ -define(['./generated-foo', './generated-bar', './generated-broken'], function (foo, bar, broken) { 'use strict'; +define(['./generated-foo', './generated-bar', './generated-broken'], (function (foo, bar, broken) { 'use strict'; foo.foo(); broken.broken(); bar.bar(); broken.broken(); -}); +})); diff --git a/test/chunking-form/samples/namespace-tracing/_expected/amd/main-c.js b/test/chunking-form/samples/namespace-tracing/_expected/amd/main-c.js index da9307f8f27..91877dc2b26 100644 --- a/test/chunking-form/samples/namespace-tracing/_expected/amd/main-c.js +++ b/test/chunking-form/samples/namespace-tracing/_expected/amd/main-c.js @@ -1,6 +1,6 @@ -define(['./generated-bar', './generated-broken'], function (bar, broken) { 'use strict'; +define(['./generated-bar', './generated-broken'], (function (bar, broken) { 'use strict'; bar.bar(); broken.broken(); -}); +})); diff --git a/test/chunking-form/samples/namespace-tracing/_expected/system/generated-bar.js b/test/chunking-form/samples/namespace-tracing/_expected/system/generated-bar.js index 699cd2779fb..8ae8f06a29b 100644 --- a/test/chunking-form/samples/namespace-tracing/_expected/system/generated-bar.js +++ b/test/chunking-form/samples/namespace-tracing/_expected/system/generated-bar.js @@ -1,14 +1,14 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - exports('b', bar); + exports("b", bar); function bar() { console.log('bar'); } - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/namespace-tracing/_expected/system/generated-broken.js b/test/chunking-form/samples/namespace-tracing/_expected/system/generated-broken.js index 57e3ae75e87..8b16e666835 100644 --- a/test/chunking-form/samples/namespace-tracing/_expected/system/generated-broken.js +++ b/test/chunking-form/samples/namespace-tracing/_expected/system/generated-broken.js @@ -1,14 +1,14 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - exports('b', broken); + exports("b", broken); function broken() { console.log('broken'); } - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/namespace-tracing/_expected/system/generated-foo.js b/test/chunking-form/samples/namespace-tracing/_expected/system/generated-foo.js index 6081a999a89..ac6837a55bc 100644 --- a/test/chunking-form/samples/namespace-tracing/_expected/system/generated-foo.js +++ b/test/chunking-form/samples/namespace-tracing/_expected/system/generated-foo.js @@ -1,14 +1,14 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - exports('f', foo); + exports("f", foo); function foo() { console.log('foo'); } - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/namespace-tracing/_expected/system/main-a.js b/test/chunking-form/samples/namespace-tracing/_expected/system/main-a.js index baeeced58ea..3f40251129e 100644 --- a/test/chunking-form/samples/namespace-tracing/_expected/system/main-a.js +++ b/test/chunking-form/samples/namespace-tracing/_expected/system/main-a.js @@ -1,4 +1,4 @@ -System.register(['./generated-foo.js', './generated-broken.js'], function () { +System.register(['./generated-foo.js', './generated-broken.js'], (function () { 'use strict'; var foo, broken; return { @@ -7,11 +7,11 @@ System.register(['./generated-foo.js', './generated-broken.js'], function () { }, function (module) { broken = module.b; }], - execute: function () { + execute: (function () { foo(); broken(); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/namespace-tracing/_expected/system/main-b.js b/test/chunking-form/samples/namespace-tracing/_expected/system/main-b.js index 557263c8f57..4742de3c8b2 100644 --- a/test/chunking-form/samples/namespace-tracing/_expected/system/main-b.js +++ b/test/chunking-form/samples/namespace-tracing/_expected/system/main-b.js @@ -1,4 +1,4 @@ -System.register(['./generated-foo.js', './generated-bar.js', './generated-broken.js'], function () { +System.register(['./generated-foo.js', './generated-bar.js', './generated-broken.js'], (function () { 'use strict'; var foo, bar, broken; return { @@ -9,13 +9,13 @@ System.register(['./generated-foo.js', './generated-bar.js', './generated-broken }, function (module) { broken = module.b; }], - execute: function () { + execute: (function () { foo(); broken(); bar(); broken(); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/namespace-tracing/_expected/system/main-c.js b/test/chunking-form/samples/namespace-tracing/_expected/system/main-c.js index eb1d3899180..6f413253175 100644 --- a/test/chunking-form/samples/namespace-tracing/_expected/system/main-c.js +++ b/test/chunking-form/samples/namespace-tracing/_expected/system/main-c.js @@ -1,4 +1,4 @@ -System.register(['./generated-bar.js', './generated-broken.js'], function () { +System.register(['./generated-bar.js', './generated-broken.js'], (function () { 'use strict'; var bar, broken; return { @@ -7,11 +7,11 @@ System.register(['./generated-bar.js', './generated-broken.js'], function () { }, function (module) { broken = module.b; }], - execute: function () { + execute: (function () { bar(); broken(); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/nested-chunks/_config.js b/test/chunking-form/samples/nested-chunks/_config.js index c9c0bdd593b..9d312e61ab8 100644 --- a/test/chunking-form/samples/nested-chunks/_config.js +++ b/test/chunking-form/samples/nested-chunks/_config.js @@ -1,7 +1,7 @@ -module.exports = { +module.exports = defineTest({ description: 'nested chunks', options: { input: { main1: 'main1', 'nested/main2': 'main2' }, external: './external.js' } -}; +}); diff --git a/test/chunking-form/samples/nested-chunks/_expected/amd/generated-dep.js b/test/chunking-form/samples/nested-chunks/_expected/amd/generated-dep.js index bf7989e606f..947ad1cbafd 100644 --- a/test/chunking-form/samples/nested-chunks/_expected/amd/generated-dep.js +++ b/test/chunking-form/samples/nested-chunks/_expected/amd/generated-dep.js @@ -1,7 +1,7 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; const value = 42; exports.value = value; -}); +})); diff --git a/test/chunking-form/samples/nested-chunks/_expected/amd/generated-dynamic.js b/test/chunking-form/samples/nested-chunks/_expected/amd/generated-dynamic.js index 74e365684fd..0e60f11cc65 100644 --- a/test/chunking-form/samples/nested-chunks/_expected/amd/generated-dynamic.js +++ b/test/chunking-form/samples/nested-chunks/_expected/amd/generated-dynamic.js @@ -1,7 +1,7 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; const value = 43; exports.value = value; -}); +})); diff --git a/test/chunking-form/samples/nested-chunks/_expected/amd/main1.js b/test/chunking-form/samples/nested-chunks/_expected/amd/main1.js index a66f64b873b..653c379fd13 100644 --- a/test/chunking-form/samples/nested-chunks/_expected/amd/main1.js +++ b/test/chunking-form/samples/nested-chunks/_expected/amd/main1.js @@ -1,7 +1,6 @@ -define(['require', './generated-dep'], function (require, dep) { 'use strict'; +define(['require', './generated-dep'], (function (require, dep) { 'use strict'; - function _interopNamespace(e) { - if (e && e.__esModule) return e; + function _interopNamespaceDefault(e) { var n = Object.create(null); if (e) { Object.keys(e).forEach(function (k) { @@ -9,20 +8,18 @@ define(['require', './generated-dep'], function (require, dep) { 'use strict'; var d = Object.getOwnPropertyDescriptor(e, k); Object.defineProperty(n, k, d.get ? d : { enumerable: true, - get: function () { - return e[k]; - } + get: function () { return e[k]; } }); } }); } - n['default'] = e; + n.default = e; return Object.freeze(n); } console.log('main1', dep.value); - new Promise(function (resolve, reject) { require(['./generated-dynamic'], resolve, reject) }).then(result => console.log(result)); - new Promise(function (resolve, reject) { require(['./external'], function (m) { resolve(/*#__PURE__*/_interopNamespace(m)); }, reject) }).then(result => console.log(result)); + new Promise(function (resolve, reject) { require(['./generated-dynamic'], resolve, reject); }).then(result => console.log(result)); + new Promise(function (resolve, reject) { require(['./external'], function (m) { resolve(/*#__PURE__*/_interopNamespaceDefault(m)); }, reject); }).then(result => console.log(result)); -}); +})); diff --git a/test/chunking-form/samples/nested-chunks/_expected/amd/nested/main2.js b/test/chunking-form/samples/nested-chunks/_expected/amd/nested/main2.js index 686b3bbb5af..4df02a79b5e 100644 --- a/test/chunking-form/samples/nested-chunks/_expected/amd/nested/main2.js +++ b/test/chunking-form/samples/nested-chunks/_expected/amd/nested/main2.js @@ -1,7 +1,6 @@ -define(['require', '../generated-dep'], function (require, dep) { 'use strict'; +define(['require', '../generated-dep'], (function (require, dep) { 'use strict'; - function _interopNamespace(e) { - if (e && e.__esModule) return e; + function _interopNamespaceDefault(e) { var n = Object.create(null); if (e) { Object.keys(e).forEach(function (k) { @@ -9,20 +8,18 @@ define(['require', '../generated-dep'], function (require, dep) { 'use strict'; var d = Object.getOwnPropertyDescriptor(e, k); Object.defineProperty(n, k, d.get ? d : { enumerable: true, - get: function () { - return e[k]; - } + get: function () { return e[k]; } }); } }); } - n['default'] = e; + n.default = e; return Object.freeze(n); } console.log('main2', dep.value); - new Promise(function (resolve, reject) { require(['../generated-dynamic'], resolve, reject) }).then(result => console.log(result)); - new Promise(function (resolve, reject) { require(['../external'], function (m) { resolve(/*#__PURE__*/_interopNamespace(m)); }, reject) }).then(result => console.log(result)); + new Promise(function (resolve, reject) { require(['../generated-dynamic'], resolve, reject); }).then(result => console.log(result)); + new Promise(function (resolve, reject) { require(['../external'], function (m) { resolve(/*#__PURE__*/_interopNamespaceDefault(m)); }, reject); }).then(result => console.log(result)); -}); +})); diff --git a/test/chunking-form/samples/nested-chunks/_expected/cjs/main1.js b/test/chunking-form/samples/nested-chunks/_expected/cjs/main1.js index 509eda83177..6a45175f346 100644 --- a/test/chunking-form/samples/nested-chunks/_expected/cjs/main1.js +++ b/test/chunking-form/samples/nested-chunks/_expected/cjs/main1.js @@ -2,27 +2,7 @@ var dep = require('./generated-dep.js'); -function _interopNamespace(e) { - if (e && e.__esModule) return e; - var n = Object.create(null); - if (e) { - Object.keys(e).forEach(function (k) { - if (k !== 'default') { - var d = Object.getOwnPropertyDescriptor(e, k); - Object.defineProperty(n, k, d.get ? d : { - enumerable: true, - get: function () { - return e[k]; - } - }); - } - }); - } - n['default'] = e; - return Object.freeze(n); -} - console.log('main1', dep.value); Promise.resolve().then(function () { return require('./generated-dynamic.js'); }).then(result => console.log(result)); -Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('./external.js')); }).then(result => console.log(result)); +import('./external.js').then(result => console.log(result)); diff --git a/test/chunking-form/samples/nested-chunks/_expected/cjs/nested/main2.js b/test/chunking-form/samples/nested-chunks/_expected/cjs/nested/main2.js index 56b77b82676..cb85e04600c 100644 --- a/test/chunking-form/samples/nested-chunks/_expected/cjs/nested/main2.js +++ b/test/chunking-form/samples/nested-chunks/_expected/cjs/nested/main2.js @@ -2,27 +2,7 @@ var dep = require('../generated-dep.js'); -function _interopNamespace(e) { - if (e && e.__esModule) return e; - var n = Object.create(null); - if (e) { - Object.keys(e).forEach(function (k) { - if (k !== 'default') { - var d = Object.getOwnPropertyDescriptor(e, k); - Object.defineProperty(n, k, d.get ? d : { - enumerable: true, - get: function () { - return e[k]; - } - }); - } - }); - } - n['default'] = e; - return Object.freeze(n); -} - console.log('main2', dep.value); Promise.resolve().then(function () { return require('../generated-dynamic.js'); }).then(result => console.log(result)); -Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('../external.js')); }).then(result => console.log(result)); +import('../external.js').then(result => console.log(result)); diff --git a/test/chunking-form/samples/nested-chunks/_expected/system/generated-dep.js b/test/chunking-form/samples/nested-chunks/_expected/system/generated-dep.js index 1fc955eb247..6ca617cd0d2 100644 --- a/test/chunking-form/samples/nested-chunks/_expected/system/generated-dep.js +++ b/test/chunking-form/samples/nested-chunks/_expected/system/generated-dep.js @@ -1,10 +1,10 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - const value = exports('v', 42); + const value = exports("v", 42); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/nested-chunks/_expected/system/generated-dynamic.js b/test/chunking-form/samples/nested-chunks/_expected/system/generated-dynamic.js index 8f4da831c09..e7964ae6bba 100644 --- a/test/chunking-form/samples/nested-chunks/_expected/system/generated-dynamic.js +++ b/test/chunking-form/samples/nested-chunks/_expected/system/generated-dynamic.js @@ -1,10 +1,10 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - const value = exports('value', 43); + const value = exports("value", 43); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/nested-chunks/_expected/system/main1.js b/test/chunking-form/samples/nested-chunks/_expected/system/main1.js index 079ee4a97fb..10d6348547d 100644 --- a/test/chunking-form/samples/nested-chunks/_expected/system/main1.js +++ b/test/chunking-form/samples/nested-chunks/_expected/system/main1.js @@ -1,17 +1,17 @@ -System.register(['./generated-dep.js'], function (exports, module) { +System.register(['./generated-dep.js'], (function (exports, module) { 'use strict'; var value; return { setters: [function (module) { value = module.v; }], - execute: function () { + execute: (function () { console.log('main1', value); module.import('./generated-dynamic.js').then(result => console.log(result)); module.import('./external.js').then(result => console.log(result)); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/nested-chunks/_expected/system/nested/main2.js b/test/chunking-form/samples/nested-chunks/_expected/system/nested/main2.js index 9b7473ec5cf..6de795a1d50 100644 --- a/test/chunking-form/samples/nested-chunks/_expected/system/nested/main2.js +++ b/test/chunking-form/samples/nested-chunks/_expected/system/nested/main2.js @@ -1,17 +1,17 @@ -System.register(['../generated-dep.js'], function (exports, module) { +System.register(['../generated-dep.js'], (function (exports, module) { 'use strict'; var value; return { setters: [function (module) { value = module.v; }], - execute: function () { + execute: (function () { console.log('main2', value); module.import('../generated-dynamic.js').then(result => console.log(result)); module.import('../external.js').then(result => console.log(result)); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/nested-dynamic-imports/_config.js b/test/chunking-form/samples/nested-dynamic-imports/_config.js index f96b6c536d2..26be48ddbea 100644 --- a/test/chunking-form/samples/nested-dynamic-imports/_config.js +++ b/test/chunking-form/samples/nested-dynamic-imports/_config.js @@ -1,6 +1,6 @@ -module.exports = { +module.exports = defineTest({ description: 'handles dynamic imports containing dynamic imports', options: { input: 'main' } -}; +}); diff --git a/test/chunking-form/samples/nested-dynamic-imports/_expected/amd/generated-dynamic1.js b/test/chunking-form/samples/nested-dynamic-imports/_expected/amd/generated-dynamic1.js index be41dd73ba2..b6491460a46 100644 --- a/test/chunking-form/samples/nested-dynamic-imports/_expected/amd/generated-dynamic1.js +++ b/test/chunking-form/samples/nested-dynamic-imports/_expected/amd/generated-dynamic1.js @@ -1,6 +1,6 @@ -define(['require'], function (require) { 'use strict'; +define(['require'], (function (require) { 'use strict'; - new Promise(function (resolve, reject) { require(['./generated-dynamic2'], resolve, reject) }); + new Promise(function (resolve, reject) { require(['./generated-dynamic2'], resolve, reject); }); console.log('dynamic1'); -}); +})); diff --git a/test/chunking-form/samples/nested-dynamic-imports/_expected/amd/generated-dynamic2.js b/test/chunking-form/samples/nested-dynamic-imports/_expected/amd/generated-dynamic2.js index 109eafa86de..b4ecca6dcc8 100644 --- a/test/chunking-form/samples/nested-dynamic-imports/_expected/amd/generated-dynamic2.js +++ b/test/chunking-form/samples/nested-dynamic-imports/_expected/amd/generated-dynamic2.js @@ -1,6 +1,6 @@ -define(['require'], function (require) { 'use strict'; +define(['require'], (function (require) { 'use strict'; - new Promise(function (resolve, reject) { require(['./generated-dynamic3'], resolve, reject) }); + new Promise(function (resolve, reject) { require(['./generated-dynamic3'], resolve, reject); }); console.log('dynamic2'); -}); +})); diff --git a/test/chunking-form/samples/nested-dynamic-imports/_expected/amd/generated-dynamic3.js b/test/chunking-form/samples/nested-dynamic-imports/_expected/amd/generated-dynamic3.js index 87c99b617b8..2a3fd9af18e 100644 --- a/test/chunking-form/samples/nested-dynamic-imports/_expected/amd/generated-dynamic3.js +++ b/test/chunking-form/samples/nested-dynamic-imports/_expected/amd/generated-dynamic3.js @@ -1,6 +1,6 @@ -define(['require'], function (require) { 'use strict'; +define(['require'], (function (require) { 'use strict'; - new Promise(function (resolve, reject) { require(['./generated-dynamic4'], resolve, reject) }); + new Promise(function (resolve, reject) { require(['./generated-dynamic4'], resolve, reject); }); console.log('dynamic3'); -}); +})); diff --git a/test/chunking-form/samples/nested-dynamic-imports/_expected/amd/generated-dynamic4.js b/test/chunking-form/samples/nested-dynamic-imports/_expected/amd/generated-dynamic4.js index eed6272d3aa..789418b5f6a 100644 --- a/test/chunking-form/samples/nested-dynamic-imports/_expected/amd/generated-dynamic4.js +++ b/test/chunking-form/samples/nested-dynamic-imports/_expected/amd/generated-dynamic4.js @@ -1,6 +1,6 @@ -define(['require'], function (require) { 'use strict'; +define(['require'], (function (require) { 'use strict'; - new Promise(function (resolve, reject) { require(['./generated-dynamic5'], resolve, reject) }); + new Promise(function (resolve, reject) { require(['./generated-dynamic5'], resolve, reject); }); console.log('dynamic4'); -}); +})); diff --git a/test/chunking-form/samples/nested-dynamic-imports/_expected/amd/generated-dynamic5.js b/test/chunking-form/samples/nested-dynamic-imports/_expected/amd/generated-dynamic5.js index 3bbcbbb8a61..7efce92c409 100644 --- a/test/chunking-form/samples/nested-dynamic-imports/_expected/amd/generated-dynamic5.js +++ b/test/chunking-form/samples/nested-dynamic-imports/_expected/amd/generated-dynamic5.js @@ -1,5 +1,5 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; console.log('dynamic5'); -}); +})); diff --git a/test/chunking-form/samples/nested-dynamic-imports/_expected/amd/main.js b/test/chunking-form/samples/nested-dynamic-imports/_expected/amd/main.js index 317bb5f6206..cfed5654679 100644 --- a/test/chunking-form/samples/nested-dynamic-imports/_expected/amd/main.js +++ b/test/chunking-form/samples/nested-dynamic-imports/_expected/amd/main.js @@ -1,6 +1,6 @@ -define(['require'], function (require) { 'use strict'; +define(['require'], (function (require) { 'use strict'; - new Promise(function (resolve, reject) { require(['./generated-dynamic1'], resolve, reject) }); + new Promise(function (resolve, reject) { require(['./generated-dynamic1'], resolve, reject); }); console.log('main'); -}); +})); diff --git a/test/chunking-form/samples/nested-dynamic-imports/_expected/system/generated-dynamic1.js b/test/chunking-form/samples/nested-dynamic-imports/_expected/system/generated-dynamic1.js index 4885888ccf8..3dd67ec612b 100644 --- a/test/chunking-form/samples/nested-dynamic-imports/_expected/system/generated-dynamic1.js +++ b/test/chunking-form/samples/nested-dynamic-imports/_expected/system/generated-dynamic1.js @@ -1,11 +1,11 @@ -System.register([], function (exports, module) { +System.register([], (function (exports, module) { 'use strict'; return { - execute: function () { + execute: (function () { module.import('./generated-dynamic2.js'); console.log('dynamic1'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/nested-dynamic-imports/_expected/system/generated-dynamic2.js b/test/chunking-form/samples/nested-dynamic-imports/_expected/system/generated-dynamic2.js index 186a6116c10..454058ecf2a 100644 --- a/test/chunking-form/samples/nested-dynamic-imports/_expected/system/generated-dynamic2.js +++ b/test/chunking-form/samples/nested-dynamic-imports/_expected/system/generated-dynamic2.js @@ -1,11 +1,11 @@ -System.register([], function (exports, module) { +System.register([], (function (exports, module) { 'use strict'; return { - execute: function () { + execute: (function () { module.import('./generated-dynamic3.js'); console.log('dynamic2'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/nested-dynamic-imports/_expected/system/generated-dynamic3.js b/test/chunking-form/samples/nested-dynamic-imports/_expected/system/generated-dynamic3.js index 96e85221924..89570bf511b 100644 --- a/test/chunking-form/samples/nested-dynamic-imports/_expected/system/generated-dynamic3.js +++ b/test/chunking-form/samples/nested-dynamic-imports/_expected/system/generated-dynamic3.js @@ -1,11 +1,11 @@ -System.register([], function (exports, module) { +System.register([], (function (exports, module) { 'use strict'; return { - execute: function () { + execute: (function () { module.import('./generated-dynamic4.js'); console.log('dynamic3'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/nested-dynamic-imports/_expected/system/generated-dynamic4.js b/test/chunking-form/samples/nested-dynamic-imports/_expected/system/generated-dynamic4.js index d2859ce1ff5..0ee8447b4e7 100644 --- a/test/chunking-form/samples/nested-dynamic-imports/_expected/system/generated-dynamic4.js +++ b/test/chunking-form/samples/nested-dynamic-imports/_expected/system/generated-dynamic4.js @@ -1,11 +1,11 @@ -System.register([], function (exports, module) { +System.register([], (function (exports, module) { 'use strict'; return { - execute: function () { + execute: (function () { module.import('./generated-dynamic5.js'); console.log('dynamic4'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/nested-dynamic-imports/_expected/system/generated-dynamic5.js b/test/chunking-form/samples/nested-dynamic-imports/_expected/system/generated-dynamic5.js index 17bd51f9265..aed40142484 100644 --- a/test/chunking-form/samples/nested-dynamic-imports/_expected/system/generated-dynamic5.js +++ b/test/chunking-form/samples/nested-dynamic-imports/_expected/system/generated-dynamic5.js @@ -1,10 +1,10 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { console.log('dynamic5'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/nested-dynamic-imports/_expected/system/main.js b/test/chunking-form/samples/nested-dynamic-imports/_expected/system/main.js index 356dfbd0378..3e81ca685ca 100644 --- a/test/chunking-form/samples/nested-dynamic-imports/_expected/system/main.js +++ b/test/chunking-form/samples/nested-dynamic-imports/_expected/system/main.js @@ -1,11 +1,11 @@ -System.register([], function (exports, module) { +System.register([], (function (exports, module) { 'use strict'; return { - execute: function () { + execute: (function () { module.import('./generated-dynamic1.js'); console.log('main'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/no-minify-internal-exports/_config.js b/test/chunking-form/samples/no-minify-internal-exports/_config.js index c6a38b51532..a6d329040ea 100644 --- a/test/chunking-form/samples/no-minify-internal-exports/_config.js +++ b/test/chunking-form/samples/no-minify-internal-exports/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'allows to disable the minification of internal exports', options: { input: ['main1.js', 'main2.js'], @@ -6,4 +6,4 @@ module.exports = { minifyInternalExports: false } } -}; +}); diff --git a/test/chunking-form/samples/no-minify-internal-exports/_expected/amd/generated-shared2.js b/test/chunking-form/samples/no-minify-internal-exports/_expected/amd/generated-shared2.js index f5f7152d4b1..230359844b6 100644 --- a/test/chunking-form/samples/no-minify-internal-exports/_expected/amd/generated-shared2.js +++ b/test/chunking-form/samples/no-minify-internal-exports/_expected/amd/generated-shared2.js @@ -1,4 +1,4 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; const shared1 = 'shared1'; const foo$1 = 'foo1'; @@ -11,4 +11,4 @@ define(['exports'], function (exports) { 'use strict'; exports.shared1 = shared1; exports.shared2 = shared2; -}); +})); diff --git a/test/chunking-form/samples/no-minify-internal-exports/_expected/amd/main1.js b/test/chunking-form/samples/no-minify-internal-exports/_expected/amd/main1.js index 44152668b42..065164190dc 100644 --- a/test/chunking-form/samples/no-minify-internal-exports/_expected/amd/main1.js +++ b/test/chunking-form/samples/no-minify-internal-exports/_expected/amd/main1.js @@ -1,5 +1,5 @@ -define(['./generated-shared2'], function (shared2) { 'use strict'; +define(['./generated-shared2'], (function (shared2) { 'use strict'; console.log(shared2.shared1, shared2.shared2, shared2.foo); -}); +})); diff --git a/test/chunking-form/samples/no-minify-internal-exports/_expected/amd/main2.js b/test/chunking-form/samples/no-minify-internal-exports/_expected/amd/main2.js index 11014cbff2a..24978e0e4b8 100644 --- a/test/chunking-form/samples/no-minify-internal-exports/_expected/amd/main2.js +++ b/test/chunking-form/samples/no-minify-internal-exports/_expected/amd/main2.js @@ -1,5 +1,5 @@ -define(['./generated-shared2'], function (shared2) { 'use strict'; +define(['./generated-shared2'], (function (shared2) { 'use strict'; console.log(shared2.shared1, shared2.shared2, shared2.foo$1); -}); +})); diff --git a/test/chunking-form/samples/no-minify-internal-exports/_expected/system/generated-shared2.js b/test/chunking-form/samples/no-minify-internal-exports/_expected/system/generated-shared2.js index 3d42d48eea9..4c1e5866770 100644 --- a/test/chunking-form/samples/no-minify-internal-exports/_expected/system/generated-shared2.js +++ b/test/chunking-form/samples/no-minify-internal-exports/_expected/system/generated-shared2.js @@ -1,14 +1,14 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - const shared1 = exports('shared1', 'shared1'); - const foo$1 = exports('foo', 'foo1'); + const shared1 = exports("shared1", 'shared1'); + const foo$1 = exports("foo", 'foo1'); - var shared2 = exports('shared2', 'shared2'); - const foo = exports('foo$1', 'foo2'); + var shared2 = exports("shared2", 'shared2'); + const foo = exports("foo$1", 'foo2'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/no-minify-internal-exports/_expected/system/main1.js b/test/chunking-form/samples/no-minify-internal-exports/_expected/system/main1.js index 994637999bd..22bcab2a084 100644 --- a/test/chunking-form/samples/no-minify-internal-exports/_expected/system/main1.js +++ b/test/chunking-form/samples/no-minify-internal-exports/_expected/system/main1.js @@ -1,4 +1,4 @@ -System.register(['./generated-shared2.js'], function () { +System.register(['./generated-shared2.js'], (function () { 'use strict'; var shared1, shared2, foo; return { @@ -7,10 +7,10 @@ System.register(['./generated-shared2.js'], function () { shared2 = module.shared2; foo = module.foo; }], - execute: function () { + execute: (function () { console.log(shared1, shared2, foo); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/no-minify-internal-exports/_expected/system/main2.js b/test/chunking-form/samples/no-minify-internal-exports/_expected/system/main2.js index fd9b128a124..a428d3a434f 100644 --- a/test/chunking-form/samples/no-minify-internal-exports/_expected/system/main2.js +++ b/test/chunking-form/samples/no-minify-internal-exports/_expected/system/main2.js @@ -1,4 +1,4 @@ -System.register(['./generated-shared2.js'], function () { +System.register(['./generated-shared2.js'], (function () { 'use strict'; var shared1, shared2, foo; return { @@ -7,10 +7,10 @@ System.register(['./generated-shared2.js'], function () { shared2 = module.shared2; foo = module.foo$1; }], - execute: function () { + execute: (function () { console.log(shared1, shared2, foo); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/no-treeshake-imports/_config.js b/test/chunking-form/samples/no-treeshake-imports/_config.js new file mode 100644 index 00000000000..260389b9f7e --- /dev/null +++ b/test/chunking-form/samples/no-treeshake-imports/_config.js @@ -0,0 +1,13 @@ +module.exports = defineTest({ + description: 'includes all imports when setting moduleSideEffects to "no-treeshake"', + options: { + input: ['main1', 'main2'], + plugins: { + transform(code, id) { + if (id.includes('main')) { + return { moduleSideEffects: 'no-treeshake' }; + } + } + } + } +}); diff --git a/test/chunking-form/samples/no-treeshake-imports/_expected/amd/generated-empty.js b/test/chunking-form/samples/no-treeshake-imports/_expected/amd/generated-empty.js new file mode 100644 index 00000000000..a9e9419e212 --- /dev/null +++ b/test/chunking-form/samples/no-treeshake-imports/_expected/amd/generated-empty.js @@ -0,0 +1,5 @@ +define((function () { 'use strict'; + + + +})); diff --git a/test/chunking-form/samples/no-treeshake-imports/_expected/amd/main1.js b/test/chunking-form/samples/no-treeshake-imports/_expected/amd/main1.js new file mode 100644 index 00000000000..40759ad6e36 --- /dev/null +++ b/test/chunking-form/samples/no-treeshake-imports/_expected/amd/main1.js @@ -0,0 +1,6 @@ +define(['./generated-empty'], (function (empty) { 'use strict'; + + console.log('main1'); + const unused = 1; + +})); diff --git a/test/chunking-form/samples/no-treeshake-imports/_expected/amd/main2.js b/test/chunking-form/samples/no-treeshake-imports/_expected/amd/main2.js new file mode 100644 index 00000000000..b939e9c08d4 --- /dev/null +++ b/test/chunking-form/samples/no-treeshake-imports/_expected/amd/main2.js @@ -0,0 +1,6 @@ +define(['./generated-empty'], (function (empty) { 'use strict'; + + console.log('main2'); + const unused = 2; + +})); diff --git a/test/form/samples/deprecated/prune-pure-unused-import/_expected/cjs.js b/test/chunking-form/samples/no-treeshake-imports/_expected/cjs/generated-empty.js similarity index 100% rename from test/form/samples/deprecated/prune-pure-unused-import/_expected/cjs.js rename to test/chunking-form/samples/no-treeshake-imports/_expected/cjs/generated-empty.js diff --git a/test/chunking-form/samples/no-treeshake-imports/_expected/cjs/main1.js b/test/chunking-form/samples/no-treeshake-imports/_expected/cjs/main1.js new file mode 100644 index 00000000000..f7dc919fc44 --- /dev/null +++ b/test/chunking-form/samples/no-treeshake-imports/_expected/cjs/main1.js @@ -0,0 +1,6 @@ +'use strict'; + +require('./generated-empty.js'); + +console.log('main1'); +const unused = 1; diff --git a/test/chunking-form/samples/no-treeshake-imports/_expected/cjs/main2.js b/test/chunking-form/samples/no-treeshake-imports/_expected/cjs/main2.js new file mode 100644 index 00000000000..f79e097d074 --- /dev/null +++ b/test/chunking-form/samples/no-treeshake-imports/_expected/cjs/main2.js @@ -0,0 +1,6 @@ +'use strict'; + +require('./generated-empty.js'); + +console.log('main2'); +const unused = 2; diff --git a/test/form/samples/deprecated/prune-pure-unused-import/_expected/es.js b/test/chunking-form/samples/no-treeshake-imports/_expected/es/generated-empty.js similarity index 100% rename from test/form/samples/deprecated/prune-pure-unused-import/_expected/es.js rename to test/chunking-form/samples/no-treeshake-imports/_expected/es/generated-empty.js diff --git a/test/chunking-form/samples/no-treeshake-imports/_expected/es/main1.js b/test/chunking-form/samples/no-treeshake-imports/_expected/es/main1.js new file mode 100644 index 00000000000..de95c6a85d5 --- /dev/null +++ b/test/chunking-form/samples/no-treeshake-imports/_expected/es/main1.js @@ -0,0 +1,4 @@ +import './generated-empty.js'; + +console.log('main1'); +const unused = 1; diff --git a/test/chunking-form/samples/no-treeshake-imports/_expected/es/main2.js b/test/chunking-form/samples/no-treeshake-imports/_expected/es/main2.js new file mode 100644 index 00000000000..d60200ad93b --- /dev/null +++ b/test/chunking-form/samples/no-treeshake-imports/_expected/es/main2.js @@ -0,0 +1,4 @@ +import './generated-empty.js'; + +console.log('main2'); +const unused = 2; diff --git a/test/chunking-form/samples/no-treeshake-imports/_expected/system/generated-empty.js b/test/chunking-form/samples/no-treeshake-imports/_expected/system/generated-empty.js new file mode 100644 index 00000000000..343cc3a5100 --- /dev/null +++ b/test/chunking-form/samples/no-treeshake-imports/_expected/system/generated-empty.js @@ -0,0 +1,10 @@ +System.register([], (function () { + 'use strict'; + return { + execute: (function () { + + + + }) + }; +})); diff --git a/test/chunking-form/samples/no-treeshake-imports/_expected/system/main1.js b/test/chunking-form/samples/no-treeshake-imports/_expected/system/main1.js new file mode 100644 index 00000000000..e77afbebb4f --- /dev/null +++ b/test/chunking-form/samples/no-treeshake-imports/_expected/system/main1.js @@ -0,0 +1,12 @@ +System.register(['./generated-empty.js'], (function () { + 'use strict'; + return { + setters: [null], + execute: (function () { + + console.log('main1'); + const unused = 1; + + }) + }; +})); diff --git a/test/chunking-form/samples/no-treeshake-imports/_expected/system/main2.js b/test/chunking-form/samples/no-treeshake-imports/_expected/system/main2.js new file mode 100644 index 00000000000..08f489340c7 --- /dev/null +++ b/test/chunking-form/samples/no-treeshake-imports/_expected/system/main2.js @@ -0,0 +1,12 @@ +System.register(['./generated-empty.js'], (function () { + 'use strict'; + return { + setters: [null], + execute: (function () { + + console.log('main2'); + const unused = 2; + + }) + }; +})); diff --git a/test/cli/samples/empty-chunk-multiple/a.js b/test/chunking-form/samples/no-treeshake-imports/empty.js similarity index 100% rename from test/cli/samples/empty-chunk-multiple/a.js rename to test/chunking-form/samples/no-treeshake-imports/empty.js diff --git a/test/chunking-form/samples/no-treeshake-imports/main1.js b/test/chunking-form/samples/no-treeshake-imports/main1.js new file mode 100644 index 00000000000..20297c703dc --- /dev/null +++ b/test/chunking-form/samples/no-treeshake-imports/main1.js @@ -0,0 +1,4 @@ +import './empty'; + +console.log('main1'); +const unused = 1; diff --git a/test/chunking-form/samples/no-treeshake-imports/main2.js b/test/chunking-form/samples/no-treeshake-imports/main2.js new file mode 100644 index 00000000000..503e8c03b60 --- /dev/null +++ b/test/chunking-form/samples/no-treeshake-imports/main2.js @@ -0,0 +1,4 @@ +import './empty'; + +console.log('main2'); +const unused = 2; diff --git a/test/chunking-form/samples/option-virtual-dirname/_config.js b/test/chunking-form/samples/option-virtual-dirname/_config.js new file mode 100644 index 00000000000..8093bc5a5c2 --- /dev/null +++ b/test/chunking-form/samples/option-virtual-dirname/_config.js @@ -0,0 +1,9 @@ +const commonjs = require('@rollup/plugin-commonjs'); + +module.exports = defineTest({ + description: 'expect the directory name for "virtual" files to be rollup_virtual', + options: { + plugins: [commonjs()], + output: { preserveModules: true, virtualDirname: 'rollup_virtual' } + } +}); diff --git a/test/chunking-form/samples/option-virtual-dirname/_expected/amd/main.js b/test/chunking-form/samples/option-virtual-dirname/_expected/amd/main.js new file mode 100644 index 00000000000..fbbd1bd70b9 --- /dev/null +++ b/test/chunking-form/samples/option-virtual-dirname/_expected/amd/main.js @@ -0,0 +1,8 @@ +define(['./rollup_virtual/_commonjsHelpers', './main2'], (function (_commonjsHelpers, main$1) { 'use strict'; + + var mainExports = main$1.__require(); + var main = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(mainExports); + + return main; + +})); diff --git a/test/chunking-form/samples/option-virtual-dirname/_expected/amd/main2.js b/test/chunking-form/samples/option-virtual-dirname/_expected/amd/main2.js new file mode 100644 index 00000000000..e3bc1a34e4e --- /dev/null +++ b/test/chunking-form/samples/option-virtual-dirname/_expected/amd/main2.js @@ -0,0 +1,15 @@ +define(['exports'], (function (exports) { 'use strict'; + + var main; + var hasRequiredMain; + + function requireMain () { + if (hasRequiredMain) return main; + hasRequiredMain = 1; + main = true; + return main; + } + + exports.__require = requireMain; + +})); diff --git a/test/chunking-form/samples/option-virtual-dirname/_expected/amd/rollup_virtual/_commonjsHelpers.js b/test/chunking-form/samples/option-virtual-dirname/_expected/amd/rollup_virtual/_commonjsHelpers.js new file mode 100644 index 00000000000..f35ac4ef0d7 --- /dev/null +++ b/test/chunking-form/samples/option-virtual-dirname/_expected/amd/rollup_virtual/_commonjsHelpers.js @@ -0,0 +1,9 @@ +define(['exports'], (function (exports) { 'use strict'; + + function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; + } + + exports.getDefaultExportFromCjs = getDefaultExportFromCjs; + +})); diff --git a/test/chunking-form/samples/option-virtual-dirname/_expected/cjs/main.js b/test/chunking-form/samples/option-virtual-dirname/_expected/cjs/main.js new file mode 100644 index 00000000000..dccddab444c --- /dev/null +++ b/test/chunking-form/samples/option-virtual-dirname/_expected/cjs/main.js @@ -0,0 +1,9 @@ +'use strict'; + +var _commonjsHelpers = require('./rollup_virtual/_commonjsHelpers.js'); +var main$1 = require('./main2.js'); + +var mainExports = main$1.__require(); +var main = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(mainExports); + +module.exports = main; diff --git a/test/chunking-form/samples/option-virtual-dirname/_expected/cjs/main2.js b/test/chunking-form/samples/option-virtual-dirname/_expected/cjs/main2.js new file mode 100644 index 00000000000..de768bbbde3 --- /dev/null +++ b/test/chunking-form/samples/option-virtual-dirname/_expected/cjs/main2.js @@ -0,0 +1,13 @@ +'use strict'; + +var main; +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main; + hasRequiredMain = 1; + main = true; + return main; +} + +exports.__require = requireMain; diff --git a/test/chunking-form/samples/option-virtual-dirname/_expected/cjs/rollup_virtual/_commonjsHelpers.js b/test/chunking-form/samples/option-virtual-dirname/_expected/cjs/rollup_virtual/_commonjsHelpers.js new file mode 100644 index 00000000000..ceeaa4d077f --- /dev/null +++ b/test/chunking-form/samples/option-virtual-dirname/_expected/cjs/rollup_virtual/_commonjsHelpers.js @@ -0,0 +1,7 @@ +'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +exports.getDefaultExportFromCjs = getDefaultExportFromCjs; diff --git a/test/chunking-form/samples/option-virtual-dirname/_expected/es/main.js b/test/chunking-form/samples/option-virtual-dirname/_expected/es/main.js new file mode 100644 index 00000000000..e126b162a96 --- /dev/null +++ b/test/chunking-form/samples/option-virtual-dirname/_expected/es/main.js @@ -0,0 +1,7 @@ +import { getDefaultExportFromCjs } from './rollup_virtual/_commonjsHelpers.js'; +import { __require as requireMain } from './main2.js'; + +var mainExports = requireMain(); +var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports); + +export { main as default }; diff --git a/test/chunking-form/samples/option-virtual-dirname/_expected/es/main2.js b/test/chunking-form/samples/option-virtual-dirname/_expected/es/main2.js new file mode 100644 index 00000000000..489d0638a28 --- /dev/null +++ b/test/chunking-form/samples/option-virtual-dirname/_expected/es/main2.js @@ -0,0 +1,11 @@ +var main; +var hasRequiredMain; + +function requireMain () { + if (hasRequiredMain) return main; + hasRequiredMain = 1; + main = true; + return main; +} + +export { requireMain as __require }; diff --git a/test/chunking-form/samples/option-virtual-dirname/_expected/es/rollup_virtual/_commonjsHelpers.js b/test/chunking-form/samples/option-virtual-dirname/_expected/es/rollup_virtual/_commonjsHelpers.js new file mode 100644 index 00000000000..7b7c5f4f531 --- /dev/null +++ b/test/chunking-form/samples/option-virtual-dirname/_expected/es/rollup_virtual/_commonjsHelpers.js @@ -0,0 +1,5 @@ +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +export { getDefaultExportFromCjs }; diff --git a/test/chunking-form/samples/option-virtual-dirname/_expected/system/main.js b/test/chunking-form/samples/option-virtual-dirname/_expected/system/main.js new file mode 100644 index 00000000000..2ff22aad45e --- /dev/null +++ b/test/chunking-form/samples/option-virtual-dirname/_expected/system/main.js @@ -0,0 +1,17 @@ +System.register(['./rollup_virtual/_commonjsHelpers.js', './main2.js'], (function (exports) { + 'use strict'; + var getDefaultExportFromCjs, requireMain; + return { + setters: [function (module) { + getDefaultExportFromCjs = module.getDefaultExportFromCjs; + }, function (module) { + requireMain = module.__require; + }], + execute: (function () { + + var mainExports = requireMain(); + var main = exports("default", /*@__PURE__*/getDefaultExportFromCjs(mainExports)); + + }) + }; +})); diff --git a/test/chunking-form/samples/option-virtual-dirname/_expected/system/main2.js b/test/chunking-form/samples/option-virtual-dirname/_expected/system/main2.js new file mode 100644 index 00000000000..13724b4cc01 --- /dev/null +++ b/test/chunking-form/samples/option-virtual-dirname/_expected/system/main2.js @@ -0,0 +1,20 @@ +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + + exports("__require", requireMain); + + var main; + var hasRequiredMain; + + function requireMain () { + if (hasRequiredMain) return main; + hasRequiredMain = 1; + main = true; + return main; + } + + }) + }; +})); diff --git a/test/chunking-form/samples/option-virtual-dirname/_expected/system/rollup_virtual/_commonjsHelpers.js b/test/chunking-form/samples/option-virtual-dirname/_expected/system/rollup_virtual/_commonjsHelpers.js new file mode 100644 index 00000000000..dd2c5886a6d --- /dev/null +++ b/test/chunking-form/samples/option-virtual-dirname/_expected/system/rollup_virtual/_commonjsHelpers.js @@ -0,0 +1,14 @@ +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + + exports("getDefaultExportFromCjs", getDefaultExportFromCjs); + + function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; + } + + }) + }; +})); diff --git a/test/chunking-form/samples/option-virtual-dirname/main.js b/test/chunking-form/samples/option-virtual-dirname/main.js new file mode 100644 index 00000000000..ec01c2c1416 --- /dev/null +++ b/test/chunking-form/samples/option-virtual-dirname/main.js @@ -0,0 +1 @@ +module.exports = true; diff --git a/test/chunking-form/samples/preserve-entry-signatures/allow-extension/_config.js b/test/chunking-form/samples/preserve-entry-signatures/allow-extension/_config.js index ea3e5f737cf..d62c434a28f 100644 --- a/test/chunking-form/samples/preserve-entry-signatures/allow-extension/_config.js +++ b/test/chunking-form/samples/preserve-entry-signatures/allow-extension/_config.js @@ -1,6 +1,6 @@ -module.exports = { +module.exports = defineTest({ description: 'Never creates facades for allow-extension', options: { preserveEntrySignatures: 'allow-extension' } -}; +}); diff --git a/test/chunking-form/samples/preserve-entry-signatures/allow-extension/_expected/amd/generated-dynamic.js b/test/chunking-form/samples/preserve-entry-signatures/allow-extension/_expected/amd/generated-dynamic.js index e2dd062c8c8..3104ef05b1f 100644 --- a/test/chunking-form/samples/preserve-entry-signatures/allow-extension/_expected/amd/generated-dynamic.js +++ b/test/chunking-form/samples/preserve-entry-signatures/allow-extension/_expected/amd/generated-dynamic.js @@ -1,5 +1,5 @@ -define(['./main'], function (main) { 'use strict'; +define(['./main'], (function (main) { 'use strict'; globalThis.sharedDynamic = main.shared; -}); +})); diff --git a/test/chunking-form/samples/preserve-entry-signatures/allow-extension/_expected/amd/main.js b/test/chunking-form/samples/preserve-entry-signatures/allow-extension/_expected/amd/main.js index a53f43faafd..7de2080ff71 100644 --- a/test/chunking-form/samples/preserve-entry-signatures/allow-extension/_expected/amd/main.js +++ b/test/chunking-form/samples/preserve-entry-signatures/allow-extension/_expected/amd/main.js @@ -1,9 +1,9 @@ -define(['require', 'exports'], function (require, exports) { 'use strict'; +define(['require', 'exports'], (function (require, exports) { 'use strict'; const shared = 'shared'; const unused = 'unused'; - const dynamic = new Promise(function (resolve, reject) { require(['./generated-dynamic'], resolve, reject) }); + const dynamic = new Promise(function (resolve, reject) { require(['./generated-dynamic'], resolve, reject); }); globalThis.sharedStatic = shared; @@ -11,6 +11,4 @@ define(['require', 'exports'], function (require, exports) { 'use strict'; exports.shared = shared; exports.unused = unused; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/preserve-entry-signatures/allow-extension/_expected/cjs/main.js b/test/chunking-form/samples/preserve-entry-signatures/allow-extension/_expected/cjs/main.js index 896c5006615..637f70585c5 100644 --- a/test/chunking-form/samples/preserve-entry-signatures/allow-extension/_expected/cjs/main.js +++ b/test/chunking-form/samples/preserve-entry-signatures/allow-extension/_expected/cjs/main.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - const shared = 'shared'; const unused = 'unused'; diff --git a/test/chunking-form/samples/preserve-entry-signatures/allow-extension/_expected/system/generated-dynamic.js b/test/chunking-form/samples/preserve-entry-signatures/allow-extension/_expected/system/generated-dynamic.js index 908608f1e52..3dfd6db40f0 100644 --- a/test/chunking-form/samples/preserve-entry-signatures/allow-extension/_expected/system/generated-dynamic.js +++ b/test/chunking-form/samples/preserve-entry-signatures/allow-extension/_expected/system/generated-dynamic.js @@ -1,14 +1,14 @@ -System.register(['./main.js'], function () { +System.register(['./main.js'], (function () { 'use strict'; var shared; return { setters: [function (module) { shared = module.s; }], - execute: function () { + execute: (function () { globalThis.sharedDynamic = shared; - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/preserve-entry-signatures/allow-extension/_expected/system/main.js b/test/chunking-form/samples/preserve-entry-signatures/allow-extension/_expected/system/main.js index 2b5f284b327..1924e732eb0 100644 --- a/test/chunking-form/samples/preserve-entry-signatures/allow-extension/_expected/system/main.js +++ b/test/chunking-form/samples/preserve-entry-signatures/allow-extension/_expected/system/main.js @@ -1,15 +1,15 @@ -System.register([], function (exports, module) { +System.register([], (function (exports, module) { 'use strict'; return { - execute: function () { + execute: (function () { - const shared = exports('s', 'shared'); + const shared = exports("s", 'shared'); - const unused = exports('unused', 'unused'); - const dynamic = exports('dynamic', module.import('./generated-dynamic.js')); + const unused = exports("unused", 'unused'); + const dynamic = exports("dynamic", module.import('./generated-dynamic.js')); globalThis.sharedStatic = shared; - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/preserve-entry-signatures/exports-only-no-exports/_config.js b/test/chunking-form/samples/preserve-entry-signatures/exports-only-no-exports/_config.js index 6fb75a89816..94a26a987c1 100644 --- a/test/chunking-form/samples/preserve-entry-signatures/exports-only-no-exports/_config.js +++ b/test/chunking-form/samples/preserve-entry-signatures/exports-only-no-exports/_config.js @@ -1,6 +1,6 @@ -module.exports = { +module.exports = defineTest({ description: 'Does not create a facade for exports-only if there are no exports', options: { preserveEntrySignatures: 'exports-only' } -}; +}); diff --git a/test/chunking-form/samples/preserve-entry-signatures/exports-only-no-exports/_expected/amd/generated-dynamic.js b/test/chunking-form/samples/preserve-entry-signatures/exports-only-no-exports/_expected/amd/generated-dynamic.js index e2dd062c8c8..3104ef05b1f 100644 --- a/test/chunking-form/samples/preserve-entry-signatures/exports-only-no-exports/_expected/amd/generated-dynamic.js +++ b/test/chunking-form/samples/preserve-entry-signatures/exports-only-no-exports/_expected/amd/generated-dynamic.js @@ -1,5 +1,5 @@ -define(['./main'], function (main) { 'use strict'; +define(['./main'], (function (main) { 'use strict'; globalThis.sharedDynamic = main.shared; -}); +})); diff --git a/test/chunking-form/samples/preserve-entry-signatures/exports-only-no-exports/_expected/amd/main.js b/test/chunking-form/samples/preserve-entry-signatures/exports-only-no-exports/_expected/amd/main.js index 4bf088d0b94..cd6807e1b06 100644 --- a/test/chunking-form/samples/preserve-entry-signatures/exports-only-no-exports/_expected/amd/main.js +++ b/test/chunking-form/samples/preserve-entry-signatures/exports-only-no-exports/_expected/amd/main.js @@ -1,13 +1,11 @@ -define(['require', 'exports'], function (require, exports) { 'use strict'; +define(['require', 'exports'], (function (require, exports) { 'use strict'; const shared = 'shared'; - new Promise(function (resolve, reject) { require(['./generated-dynamic'], resolve, reject) }); + new Promise(function (resolve, reject) { require(['./generated-dynamic'], resolve, reject); }); globalThis.sharedStatic = shared; exports.shared = shared; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/preserve-entry-signatures/exports-only-no-exports/_expected/cjs/main.js b/test/chunking-form/samples/preserve-entry-signatures/exports-only-no-exports/_expected/cjs/main.js index 9b8458335f7..90c998ec33b 100644 --- a/test/chunking-form/samples/preserve-entry-signatures/exports-only-no-exports/_expected/cjs/main.js +++ b/test/chunking-form/samples/preserve-entry-signatures/exports-only-no-exports/_expected/cjs/main.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - const shared = 'shared'; Promise.resolve().then(function () { return require('./generated-dynamic.js'); }); diff --git a/test/chunking-form/samples/preserve-entry-signatures/exports-only-no-exports/_expected/system/generated-dynamic.js b/test/chunking-form/samples/preserve-entry-signatures/exports-only-no-exports/_expected/system/generated-dynamic.js index 908608f1e52..3dfd6db40f0 100644 --- a/test/chunking-form/samples/preserve-entry-signatures/exports-only-no-exports/_expected/system/generated-dynamic.js +++ b/test/chunking-form/samples/preserve-entry-signatures/exports-only-no-exports/_expected/system/generated-dynamic.js @@ -1,14 +1,14 @@ -System.register(['./main.js'], function () { +System.register(['./main.js'], (function () { 'use strict'; var shared; return { setters: [function (module) { shared = module.s; }], - execute: function () { + execute: (function () { globalThis.sharedDynamic = shared; - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/preserve-entry-signatures/exports-only-no-exports/_expected/system/main.js b/test/chunking-form/samples/preserve-entry-signatures/exports-only-no-exports/_expected/system/main.js index fd31d2c3d4d..40759e14cf8 100644 --- a/test/chunking-form/samples/preserve-entry-signatures/exports-only-no-exports/_expected/system/main.js +++ b/test/chunking-form/samples/preserve-entry-signatures/exports-only-no-exports/_expected/system/main.js @@ -1,14 +1,14 @@ -System.register([], function (exports, module) { +System.register([], (function (exports, module) { 'use strict'; return { - execute: function () { + execute: (function () { - const shared = exports('s', 'shared'); + const shared = exports("s", 'shared'); module.import('./generated-dynamic.js'); globalThis.sharedStatic = shared; - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/preserve-entry-signatures/exports-only/_config.js b/test/chunking-form/samples/preserve-entry-signatures/exports-only/_config.js index e00716aa766..60bfa49a3a7 100644 --- a/test/chunking-form/samples/preserve-entry-signatures/exports-only/_config.js +++ b/test/chunking-form/samples/preserve-entry-signatures/exports-only/_config.js @@ -1,6 +1,6 @@ -module.exports = { +module.exports = defineTest({ description: 'Creates a facade if necessary for exports-only if there are exports', options: { preserveEntrySignatures: 'exports-only' } -}; +}); diff --git a/test/chunking-form/samples/preserve-entry-signatures/exports-only/_expected/amd/generated-dynamic.js b/test/chunking-form/samples/preserve-entry-signatures/exports-only/_expected/amd/generated-dynamic.js index 6d87a0e4805..dee0d879719 100644 --- a/test/chunking-form/samples/preserve-entry-signatures/exports-only/_expected/amd/generated-dynamic.js +++ b/test/chunking-form/samples/preserve-entry-signatures/exports-only/_expected/amd/generated-dynamic.js @@ -1,5 +1,5 @@ -define(['./generated-main'], function (main) { 'use strict'; +define(['./generated-main'], (function (main) { 'use strict'; globalThis.sharedDynamic = main.shared; -}); +})); diff --git a/test/chunking-form/samples/preserve-entry-signatures/exports-only/_expected/amd/generated-main.js b/test/chunking-form/samples/preserve-entry-signatures/exports-only/_expected/amd/generated-main.js index f1c6db85df8..7de2080ff71 100644 --- a/test/chunking-form/samples/preserve-entry-signatures/exports-only/_expected/amd/generated-main.js +++ b/test/chunking-form/samples/preserve-entry-signatures/exports-only/_expected/amd/generated-main.js @@ -1,9 +1,9 @@ -define(['require', 'exports'], function (require, exports) { 'use strict'; +define(['require', 'exports'], (function (require, exports) { 'use strict'; const shared = 'shared'; const unused = 'unused'; - const dynamic = new Promise(function (resolve, reject) { require(['./generated-dynamic'], resolve, reject) }); + const dynamic = new Promise(function (resolve, reject) { require(['./generated-dynamic'], resolve, reject); }); globalThis.sharedStatic = shared; @@ -11,4 +11,4 @@ define(['require', 'exports'], function (require, exports) { 'use strict'; exports.shared = shared; exports.unused = unused; -}); +})); diff --git a/test/chunking-form/samples/preserve-entry-signatures/exports-only/_expected/amd/main.js b/test/chunking-form/samples/preserve-entry-signatures/exports-only/_expected/amd/main.js index 3189f6ac52e..eb2d7c46ed3 100644 --- a/test/chunking-form/samples/preserve-entry-signatures/exports-only/_expected/amd/main.js +++ b/test/chunking-form/samples/preserve-entry-signatures/exports-only/_expected/amd/main.js @@ -1,10 +1,8 @@ -define(['exports', './generated-main'], function (exports, main) { 'use strict'; +define(['exports', './generated-main'], (function (exports, main) { 'use strict'; exports.dynamic = main.dynamic; exports.unused = main.unused; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/preserve-entry-signatures/exports-only/_expected/cjs/main.js b/test/chunking-form/samples/preserve-entry-signatures/exports-only/_expected/cjs/main.js index 85dcc48bca5..48b0c5d8247 100644 --- a/test/chunking-form/samples/preserve-entry-signatures/exports-only/_expected/cjs/main.js +++ b/test/chunking-form/samples/preserve-entry-signatures/exports-only/_expected/cjs/main.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - var main = require('./generated-main.js'); diff --git a/test/chunking-form/samples/preserve-entry-signatures/exports-only/_expected/system/generated-dynamic.js b/test/chunking-form/samples/preserve-entry-signatures/exports-only/_expected/system/generated-dynamic.js index 187cb5f2c9f..76d2f1834e0 100644 --- a/test/chunking-form/samples/preserve-entry-signatures/exports-only/_expected/system/generated-dynamic.js +++ b/test/chunking-form/samples/preserve-entry-signatures/exports-only/_expected/system/generated-dynamic.js @@ -1,14 +1,14 @@ -System.register(['./generated-main.js'], function () { +System.register(['./generated-main.js'], (function () { 'use strict'; var shared; return { setters: [function (module) { shared = module.s; }], - execute: function () { + execute: (function () { globalThis.sharedDynamic = shared; - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/preserve-entry-signatures/exports-only/_expected/system/generated-main.js b/test/chunking-form/samples/preserve-entry-signatures/exports-only/_expected/system/generated-main.js index c31de9052a8..9899c451328 100644 --- a/test/chunking-form/samples/preserve-entry-signatures/exports-only/_expected/system/generated-main.js +++ b/test/chunking-form/samples/preserve-entry-signatures/exports-only/_expected/system/generated-main.js @@ -1,15 +1,15 @@ -System.register([], function (exports, module) { +System.register([], (function (exports, module) { 'use strict'; return { - execute: function () { + execute: (function () { - const shared = exports('s', 'shared'); + const shared = exports("s", 'shared'); - const unused = exports('u', 'unused'); - const dynamic = exports('d', module.import('./generated-dynamic.js')); + const unused = exports("u", 'unused'); + const dynamic = exports("d", module.import('./generated-dynamic.js')); globalThis.sharedStatic = shared; - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/preserve-entry-signatures/exports-only/_expected/system/main.js b/test/chunking-form/samples/preserve-entry-signatures/exports-only/_expected/system/main.js index 07c5c3e8995..461d214ff24 100644 --- a/test/chunking-form/samples/preserve-entry-signatures/exports-only/_expected/system/main.js +++ b/test/chunking-form/samples/preserve-entry-signatures/exports-only/_expected/system/main.js @@ -1,16 +1,13 @@ -System.register(['./generated-main.js'], function (exports) { +System.register(['./generated-main.js'], (function (exports) { 'use strict'; return { setters: [function (module) { - var _setter = {}; - _setter.dynamic = module.d; - _setter.unused = module.u; - exports(_setter); + exports({ dynamic: module.d, unused: module.u }); }], - execute: function () { + execute: (function () { - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/preserve-entry-signatures/false/_config.js b/test/chunking-form/samples/preserve-entry-signatures/false/_config.js index 601608a5d93..f38aeae9f00 100644 --- a/test/chunking-form/samples/preserve-entry-signatures/false/_config.js +++ b/test/chunking-form/samples/preserve-entry-signatures/false/_config.js @@ -1,6 +1,6 @@ -module.exports = { +module.exports = defineTest({ description: 'Does not include entry exports and does not preserve the signature', options: { preserveEntrySignatures: false } -}; +}); diff --git a/test/chunking-form/samples/preserve-entry-signatures/false/_expected/amd/generated-dynamic.js b/test/chunking-form/samples/preserve-entry-signatures/false/_expected/amd/generated-dynamic.js index e2dd062c8c8..3104ef05b1f 100644 --- a/test/chunking-form/samples/preserve-entry-signatures/false/_expected/amd/generated-dynamic.js +++ b/test/chunking-form/samples/preserve-entry-signatures/false/_expected/amd/generated-dynamic.js @@ -1,5 +1,5 @@ -define(['./main'], function (main) { 'use strict'; +define(['./main'], (function (main) { 'use strict'; globalThis.sharedDynamic = main.shared; -}); +})); diff --git a/test/chunking-form/samples/preserve-entry-signatures/false/_expected/amd/main.js b/test/chunking-form/samples/preserve-entry-signatures/false/_expected/amd/main.js index 4bf088d0b94..cd6807e1b06 100644 --- a/test/chunking-form/samples/preserve-entry-signatures/false/_expected/amd/main.js +++ b/test/chunking-form/samples/preserve-entry-signatures/false/_expected/amd/main.js @@ -1,13 +1,11 @@ -define(['require', 'exports'], function (require, exports) { 'use strict'; +define(['require', 'exports'], (function (require, exports) { 'use strict'; const shared = 'shared'; - new Promise(function (resolve, reject) { require(['./generated-dynamic'], resolve, reject) }); + new Promise(function (resolve, reject) { require(['./generated-dynamic'], resolve, reject); }); globalThis.sharedStatic = shared; exports.shared = shared; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/preserve-entry-signatures/false/_expected/cjs/main.js b/test/chunking-form/samples/preserve-entry-signatures/false/_expected/cjs/main.js index 9b8458335f7..90c998ec33b 100644 --- a/test/chunking-form/samples/preserve-entry-signatures/false/_expected/cjs/main.js +++ b/test/chunking-form/samples/preserve-entry-signatures/false/_expected/cjs/main.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - const shared = 'shared'; Promise.resolve().then(function () { return require('./generated-dynamic.js'); }); diff --git a/test/chunking-form/samples/preserve-entry-signatures/false/_expected/system/generated-dynamic.js b/test/chunking-form/samples/preserve-entry-signatures/false/_expected/system/generated-dynamic.js index 908608f1e52..3dfd6db40f0 100644 --- a/test/chunking-form/samples/preserve-entry-signatures/false/_expected/system/generated-dynamic.js +++ b/test/chunking-form/samples/preserve-entry-signatures/false/_expected/system/generated-dynamic.js @@ -1,14 +1,14 @@ -System.register(['./main.js'], function () { +System.register(['./main.js'], (function () { 'use strict'; var shared; return { setters: [function (module) { shared = module.s; }], - execute: function () { + execute: (function () { globalThis.sharedDynamic = shared; - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/preserve-entry-signatures/false/_expected/system/main.js b/test/chunking-form/samples/preserve-entry-signatures/false/_expected/system/main.js index fd31d2c3d4d..40759e14cf8 100644 --- a/test/chunking-form/samples/preserve-entry-signatures/false/_expected/system/main.js +++ b/test/chunking-form/samples/preserve-entry-signatures/false/_expected/system/main.js @@ -1,14 +1,14 @@ -System.register([], function (exports, module) { +System.register([], (function (exports, module) { 'use strict'; return { - execute: function () { + execute: (function () { - const shared = exports('s', 'shared'); + const shared = exports("s", 'shared'); module.import('./generated-dynamic.js'); globalThis.sharedStatic = shared; - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_config.js b/test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_config.js index d4888307bcf..3614e1b10d5 100644 --- a/test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_config.js +++ b/test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'Allows overriding behaviour for emitted chunks', options: { input: [], @@ -32,4 +32,4 @@ module.exports = { } } } -}; +}); diff --git a/test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/amd/generated-allow-extension.js b/test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/amd/generated-allow-extension.js index a2fc8c8d510..2eb0839b29b 100644 --- a/test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/amd/generated-allow-extension.js +++ b/test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/amd/generated-allow-extension.js @@ -1,14 +1,12 @@ -define(['require', 'exports'], function (require, exports) { 'use strict'; +define(['require', 'exports'], (function (require, exports) { 'use strict'; const shared = 'shared'; console.log(shared); - new Promise(function (resolve, reject) { require(['./generated-dynamic2'], resolve, reject) }); + new Promise(function (resolve, reject) { require(['./generated-dynamic2'], resolve, reject); }); const unused = 42; exports.shared = shared; exports.unused = unused; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/amd/generated-dynamic.js b/test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/amd/generated-dynamic.js index 83bcde586dd..261177fd183 100644 --- a/test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/amd/generated-dynamic.js +++ b/test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/amd/generated-dynamic.js @@ -1,5 +1,5 @@ -define(['./generated-main'], function (strict) { 'use strict'; +define(['./generated-main'], (function (strict) { 'use strict'; console.log(strict.shared); -}); +})); diff --git a/test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/amd/generated-dynamic2.js b/test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/amd/generated-dynamic2.js index 70518c53bc9..4d5aac0374e 100644 --- a/test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/amd/generated-dynamic2.js +++ b/test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/amd/generated-dynamic2.js @@ -1,5 +1,5 @@ -define(['./generated-allow-extension'], function (allowExtension) { 'use strict'; +define(['./generated-allow-extension'], (function (allowExtension) { 'use strict'; console.log(allowExtension.shared); -}); +})); diff --git a/test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/amd/generated-dynamic3.js b/test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/amd/generated-dynamic3.js index 5bf2e7c4f03..86ec1f9be73 100644 --- a/test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/amd/generated-dynamic3.js +++ b/test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/amd/generated-dynamic3.js @@ -1,5 +1,5 @@ -define(['./generated-false'], function (_false) { 'use strict'; +define(['./generated-false'], (function (_false) { 'use strict'; console.log(_false.shared); -}); +})); diff --git a/test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/amd/generated-dynamic4.js b/test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/amd/generated-dynamic4.js index 46a02f2f587..8330a0078b9 100644 --- a/test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/amd/generated-dynamic4.js +++ b/test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/amd/generated-dynamic4.js @@ -1,5 +1,5 @@ -define(['./generated-not-specified'], function (notSpecified) { 'use strict'; +define(['./generated-not-specified'], (function (notSpecified) { 'use strict'; console.log(notSpecified.shared); -}); +})); diff --git a/test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/amd/generated-false.js b/test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/amd/generated-false.js index a204f3da10f..7fcf256410f 100644 --- a/test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/amd/generated-false.js +++ b/test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/amd/generated-false.js @@ -1,12 +1,10 @@ -define(['require', 'exports'], function (require, exports) { 'use strict'; +define(['require', 'exports'], (function (require, exports) { 'use strict'; const shared = 'shared'; console.log(shared); - new Promise(function (resolve, reject) { require(['./generated-dynamic3'], resolve, reject) }); + new Promise(function (resolve, reject) { require(['./generated-dynamic3'], resolve, reject); }); exports.shared = shared; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/amd/generated-main.js b/test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/amd/generated-main.js index 6243c982e1a..207650de431 100644 --- a/test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/amd/generated-main.js +++ b/test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/amd/generated-main.js @@ -1,12 +1,12 @@ -define(['require', 'exports'], function (require, exports) { 'use strict'; +define(['require', 'exports'], (function (require, exports) { 'use strict'; const shared = 'shared'; console.log(shared); - new Promise(function (resolve, reject) { require(['./generated-dynamic'], resolve, reject) }); + new Promise(function (resolve, reject) { require(['./generated-dynamic'], resolve, reject); }); const unused = 42; exports.shared = shared; exports.unused = unused; -}); +})); diff --git a/test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/amd/generated-not-specified.js b/test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/amd/generated-not-specified.js index e21f556a837..bc3999b11e6 100644 --- a/test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/amd/generated-not-specified.js +++ b/test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/amd/generated-not-specified.js @@ -1,14 +1,12 @@ -define(['require', 'exports'], function (require, exports) { 'use strict'; +define(['require', 'exports'], (function (require, exports) { 'use strict'; const shared = 'shared'; console.log(shared); - new Promise(function (resolve, reject) { require(['./generated-dynamic4'], resolve, reject) }); + new Promise(function (resolve, reject) { require(['./generated-dynamic4'], resolve, reject); }); const unused = 42; exports.shared = shared; exports.unused = unused; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/amd/generated-strict.js b/test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/amd/generated-strict.js index fa13ffb3e3d..52495b70f4d 100644 --- a/test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/amd/generated-strict.js +++ b/test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/amd/generated-strict.js @@ -1,9 +1,7 @@ -define(['exports', './generated-main'], function (exports, strict) { 'use strict'; +define(['exports', './generated-main'], (function (exports, strict) { 'use strict'; exports.unused = strict.unused; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/cjs/generated-allow-extension.js b/test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/cjs/generated-allow-extension.js index 09e16f7d592..4e1da50883f 100644 --- a/test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/cjs/generated-allow-extension.js +++ b/test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/cjs/generated-allow-extension.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - const shared = 'shared'; console.log(shared); diff --git a/test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/cjs/generated-false.js b/test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/cjs/generated-false.js index 1d3c3154aad..ff45728699a 100644 --- a/test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/cjs/generated-false.js +++ b/test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/cjs/generated-false.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - const shared = 'shared'; console.log(shared); diff --git a/test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/cjs/generated-not-specified.js b/test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/cjs/generated-not-specified.js index a54ad55bd99..dfd2786741d 100644 --- a/test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/cjs/generated-not-specified.js +++ b/test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/cjs/generated-not-specified.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - const shared = 'shared'; console.log(shared); diff --git a/test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/cjs/generated-strict.js b/test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/cjs/generated-strict.js index bc762b95755..564f9fdbe94 100644 --- a/test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/cjs/generated-strict.js +++ b/test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/cjs/generated-strict.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - var strict = require('./generated-main.js'); diff --git a/test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/system/generated-allow-extension.js b/test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/system/generated-allow-extension.js index eabe01d5584..48157f64263 100644 --- a/test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/system/generated-allow-extension.js +++ b/test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/system/generated-allow-extension.js @@ -1,14 +1,14 @@ -System.register([], function (exports, module) { +System.register([], (function (exports, module) { 'use strict'; return { - execute: function () { + execute: (function () { - const shared = exports('s', 'shared'); + const shared = exports("s", 'shared'); console.log(shared); module.import('./generated-dynamic2.js'); - const unused = exports('unused', 42); + const unused = exports("unused", 42); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/system/generated-dynamic.js b/test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/system/generated-dynamic.js index cb45ff710c6..316ac53ece9 100644 --- a/test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/system/generated-dynamic.js +++ b/test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/system/generated-dynamic.js @@ -1,14 +1,14 @@ -System.register(['./generated-main.js'], function () { +System.register(['./generated-main.js'], (function () { 'use strict'; var shared; return { setters: [function (module) { shared = module.s; }], - execute: function () { + execute: (function () { console.log(shared); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/system/generated-dynamic2.js b/test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/system/generated-dynamic2.js index ac828c226b8..81383bdb137 100644 --- a/test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/system/generated-dynamic2.js +++ b/test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/system/generated-dynamic2.js @@ -1,14 +1,14 @@ -System.register(['./generated-allow-extension.js'], function () { +System.register(['./generated-allow-extension.js'], (function () { 'use strict'; var shared; return { setters: [function (module) { shared = module.s; }], - execute: function () { + execute: (function () { console.log(shared); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/system/generated-dynamic3.js b/test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/system/generated-dynamic3.js index 8fa2ba05265..1978c684efc 100644 --- a/test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/system/generated-dynamic3.js +++ b/test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/system/generated-dynamic3.js @@ -1,14 +1,14 @@ -System.register(['./generated-false.js'], function () { +System.register(['./generated-false.js'], (function () { 'use strict'; var shared; return { setters: [function (module) { shared = module.s; }], - execute: function () { + execute: (function () { console.log(shared); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/system/generated-dynamic4.js b/test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/system/generated-dynamic4.js index b41e2229fc6..3ee0f88c5b7 100644 --- a/test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/system/generated-dynamic4.js +++ b/test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/system/generated-dynamic4.js @@ -1,14 +1,14 @@ -System.register(['./generated-not-specified.js'], function () { +System.register(['./generated-not-specified.js'], (function () { 'use strict'; var shared; return { setters: [function (module) { shared = module.s; }], - execute: function () { + execute: (function () { console.log(shared); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/system/generated-false.js b/test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/system/generated-false.js index 674dea5b449..27e69d00937 100644 --- a/test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/system/generated-false.js +++ b/test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/system/generated-false.js @@ -1,13 +1,13 @@ -System.register([], function (exports, module) { +System.register([], (function (exports, module) { 'use strict'; return { - execute: function () { + execute: (function () { - const shared = exports('s', 'shared'); + const shared = exports("s", 'shared'); console.log(shared); module.import('./generated-dynamic3.js'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/system/generated-main.js b/test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/system/generated-main.js index d19257dee34..681ccc6ec52 100644 --- a/test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/system/generated-main.js +++ b/test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/system/generated-main.js @@ -1,14 +1,14 @@ -System.register([], function (exports, module) { +System.register([], (function (exports, module) { 'use strict'; return { - execute: function () { + execute: (function () { - const shared = exports('s', 'shared'); + const shared = exports("s", 'shared'); console.log(shared); module.import('./generated-dynamic.js'); - const unused = exports('u', 42); + const unused = exports("u", 42); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/system/generated-not-specified.js b/test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/system/generated-not-specified.js index 5104a4ed1ac..6b953584948 100644 --- a/test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/system/generated-not-specified.js +++ b/test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/system/generated-not-specified.js @@ -1,14 +1,14 @@ -System.register([], function (exports, module) { +System.register([], (function (exports, module) { 'use strict'; return { - execute: function () { + execute: (function () { - const shared = exports('s', 'shared'); + const shared = exports("s", 'shared'); console.log(shared); module.import('./generated-dynamic4.js'); - const unused = exports('unused', 42); + const unused = exports("unused", 42); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/system/generated-strict.js b/test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/system/generated-strict.js index 1cf07015291..2cb4a1f10f7 100644 --- a/test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/system/generated-strict.js +++ b/test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/system/generated-strict.js @@ -1,13 +1,13 @@ -System.register(['./generated-main.js'], function (exports) { +System.register(['./generated-main.js'], (function (exports) { 'use strict'; return { setters: [function (module) { - exports('unused', module.u); + exports("unused", module.u); }], - execute: function () { + execute: (function () { - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/preserve-entry-signatures/strict/_config.js b/test/chunking-form/samples/preserve-entry-signatures/strict/_config.js index 858e5fd4d3e..ce374249b17 100644 --- a/test/chunking-form/samples/preserve-entry-signatures/strict/_config.js +++ b/test/chunking-form/samples/preserve-entry-signatures/strict/_config.js @@ -1,6 +1,6 @@ -module.exports = { +module.exports = defineTest({ description: 'Creates a facade if necessary for strict entry signatures', options: { preserveEntrySignatures: 'strict' } -}; +}); diff --git a/test/chunking-form/samples/preserve-entry-signatures/strict/_expected/amd/generated-dynamic.js b/test/chunking-form/samples/preserve-entry-signatures/strict/_expected/amd/generated-dynamic.js index 6d87a0e4805..dee0d879719 100644 --- a/test/chunking-form/samples/preserve-entry-signatures/strict/_expected/amd/generated-dynamic.js +++ b/test/chunking-form/samples/preserve-entry-signatures/strict/_expected/amd/generated-dynamic.js @@ -1,5 +1,5 @@ -define(['./generated-main'], function (main) { 'use strict'; +define(['./generated-main'], (function (main) { 'use strict'; globalThis.sharedDynamic = main.shared; -}); +})); diff --git a/test/chunking-form/samples/preserve-entry-signatures/strict/_expected/amd/generated-main.js b/test/chunking-form/samples/preserve-entry-signatures/strict/_expected/amd/generated-main.js index f1c6db85df8..7de2080ff71 100644 --- a/test/chunking-form/samples/preserve-entry-signatures/strict/_expected/amd/generated-main.js +++ b/test/chunking-form/samples/preserve-entry-signatures/strict/_expected/amd/generated-main.js @@ -1,9 +1,9 @@ -define(['require', 'exports'], function (require, exports) { 'use strict'; +define(['require', 'exports'], (function (require, exports) { 'use strict'; const shared = 'shared'; const unused = 'unused'; - const dynamic = new Promise(function (resolve, reject) { require(['./generated-dynamic'], resolve, reject) }); + const dynamic = new Promise(function (resolve, reject) { require(['./generated-dynamic'], resolve, reject); }); globalThis.sharedStatic = shared; @@ -11,4 +11,4 @@ define(['require', 'exports'], function (require, exports) { 'use strict'; exports.shared = shared; exports.unused = unused; -}); +})); diff --git a/test/chunking-form/samples/preserve-entry-signatures/strict/_expected/amd/main.js b/test/chunking-form/samples/preserve-entry-signatures/strict/_expected/amd/main.js index 3189f6ac52e..eb2d7c46ed3 100644 --- a/test/chunking-form/samples/preserve-entry-signatures/strict/_expected/amd/main.js +++ b/test/chunking-form/samples/preserve-entry-signatures/strict/_expected/amd/main.js @@ -1,10 +1,8 @@ -define(['exports', './generated-main'], function (exports, main) { 'use strict'; +define(['exports', './generated-main'], (function (exports, main) { 'use strict'; exports.dynamic = main.dynamic; exports.unused = main.unused; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/preserve-entry-signatures/strict/_expected/cjs/main.js b/test/chunking-form/samples/preserve-entry-signatures/strict/_expected/cjs/main.js index 85dcc48bca5..48b0c5d8247 100644 --- a/test/chunking-form/samples/preserve-entry-signatures/strict/_expected/cjs/main.js +++ b/test/chunking-form/samples/preserve-entry-signatures/strict/_expected/cjs/main.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - var main = require('./generated-main.js'); diff --git a/test/chunking-form/samples/preserve-entry-signatures/strict/_expected/system/generated-dynamic.js b/test/chunking-form/samples/preserve-entry-signatures/strict/_expected/system/generated-dynamic.js index 187cb5f2c9f..76d2f1834e0 100644 --- a/test/chunking-form/samples/preserve-entry-signatures/strict/_expected/system/generated-dynamic.js +++ b/test/chunking-form/samples/preserve-entry-signatures/strict/_expected/system/generated-dynamic.js @@ -1,14 +1,14 @@ -System.register(['./generated-main.js'], function () { +System.register(['./generated-main.js'], (function () { 'use strict'; var shared; return { setters: [function (module) { shared = module.s; }], - execute: function () { + execute: (function () { globalThis.sharedDynamic = shared; - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/preserve-entry-signatures/strict/_expected/system/generated-main.js b/test/chunking-form/samples/preserve-entry-signatures/strict/_expected/system/generated-main.js index c31de9052a8..9899c451328 100644 --- a/test/chunking-form/samples/preserve-entry-signatures/strict/_expected/system/generated-main.js +++ b/test/chunking-form/samples/preserve-entry-signatures/strict/_expected/system/generated-main.js @@ -1,15 +1,15 @@ -System.register([], function (exports, module) { +System.register([], (function (exports, module) { 'use strict'; return { - execute: function () { + execute: (function () { - const shared = exports('s', 'shared'); + const shared = exports("s", 'shared'); - const unused = exports('u', 'unused'); - const dynamic = exports('d', module.import('./generated-dynamic.js')); + const unused = exports("u", 'unused'); + const dynamic = exports("d", module.import('./generated-dynamic.js')); globalThis.sharedStatic = shared; - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/preserve-entry-signatures/strict/_expected/system/main.js b/test/chunking-form/samples/preserve-entry-signatures/strict/_expected/system/main.js index 07c5c3e8995..461d214ff24 100644 --- a/test/chunking-form/samples/preserve-entry-signatures/strict/_expected/system/main.js +++ b/test/chunking-form/samples/preserve-entry-signatures/strict/_expected/system/main.js @@ -1,16 +1,13 @@ -System.register(['./generated-main.js'], function (exports) { +System.register(['./generated-main.js'], (function (exports) { 'use strict'; return { setters: [function (module) { - var _setter = {}; - _setter.dynamic = module.d; - _setter.unused = module.u; - exports(_setter); + exports({ dynamic: module.d, unused: module.u }); }], - execute: function () { + execute: (function () { - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/preserve-entry-signatures/undefined-with-tainted-plugin-chunk/_config.js b/test/chunking-form/samples/preserve-entry-signatures/undefined-with-tainted-plugin-chunk/_config.js deleted file mode 100644 index 4044ae8b0a7..00000000000 --- a/test/chunking-form/samples/preserve-entry-signatures/undefined-with-tainted-plugin-chunk/_config.js +++ /dev/null @@ -1,12 +0,0 @@ -module.exports = { - description: - 'Does not warn if preserveEntrySignatures is not set and an empty facade is created for a plugin chunk', - options: { - input: [], - plugins: { - buildStart() { - this.emitFile({ type: 'chunk', id: 'main', name: 'entry' }); - } - } - } -}; diff --git a/test/chunking-form/samples/preserve-entry-signatures/undefined-with-tainted-plugin-chunk/_expected/amd/generated-dynamic.js b/test/chunking-form/samples/preserve-entry-signatures/undefined-with-tainted-plugin-chunk/_expected/amd/generated-dynamic.js deleted file mode 100644 index c3e9198a9e0..00000000000 --- a/test/chunking-form/samples/preserve-entry-signatures/undefined-with-tainted-plugin-chunk/_expected/amd/generated-dynamic.js +++ /dev/null @@ -1,5 +0,0 @@ -define(['./generated-main'], function (entry) { 'use strict'; - - globalThis.sharedDynamic = entry.shared; - -}); diff --git a/test/chunking-form/samples/preserve-entry-signatures/undefined-with-tainted-plugin-chunk/_expected/amd/generated-entry.js b/test/chunking-form/samples/preserve-entry-signatures/undefined-with-tainted-plugin-chunk/_expected/amd/generated-entry.js deleted file mode 100644 index e3d796aab12..00000000000 --- a/test/chunking-form/samples/preserve-entry-signatures/undefined-with-tainted-plugin-chunk/_expected/amd/generated-entry.js +++ /dev/null @@ -1,5 +0,0 @@ -define(['./generated-main'], function (entry) { 'use strict'; - - - -}); diff --git a/test/chunking-form/samples/preserve-entry-signatures/undefined-with-tainted-plugin-chunk/_expected/amd/generated-main.js b/test/chunking-form/samples/preserve-entry-signatures/undefined-with-tainted-plugin-chunk/_expected/amd/generated-main.js deleted file mode 100644 index 4258e7c7161..00000000000 --- a/test/chunking-form/samples/preserve-entry-signatures/undefined-with-tainted-plugin-chunk/_expected/amd/generated-main.js +++ /dev/null @@ -1,10 +0,0 @@ -define(['require', 'exports'], function (require, exports) { 'use strict'; - - const shared = 'shared'; - - new Promise(function (resolve, reject) { require(['./generated-dynamic'], resolve, reject) }); - globalThis.sharedStatic = shared; - - exports.shared = shared; - -}); diff --git a/test/chunking-form/samples/preserve-entry-signatures/undefined-with-tainted-plugin-chunk/_expected/cjs/generated-dynamic.js b/test/chunking-form/samples/preserve-entry-signatures/undefined-with-tainted-plugin-chunk/_expected/cjs/generated-dynamic.js deleted file mode 100644 index 5585f0a0567..00000000000 --- a/test/chunking-form/samples/preserve-entry-signatures/undefined-with-tainted-plugin-chunk/_expected/cjs/generated-dynamic.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -var entry = require('./generated-main.js'); - -globalThis.sharedDynamic = entry.shared; diff --git a/test/chunking-form/samples/preserve-entry-signatures/undefined-with-tainted-plugin-chunk/_expected/cjs/generated-entry.js b/test/chunking-form/samples/preserve-entry-signatures/undefined-with-tainted-plugin-chunk/_expected/cjs/generated-entry.js deleted file mode 100644 index 464b4ce8e34..00000000000 --- a/test/chunking-form/samples/preserve-entry-signatures/undefined-with-tainted-plugin-chunk/_expected/cjs/generated-entry.js +++ /dev/null @@ -1,4 +0,0 @@ -'use strict'; - -require('./generated-main.js'); - diff --git a/test/chunking-form/samples/preserve-entry-signatures/undefined-with-tainted-plugin-chunk/_expected/cjs/generated-main.js b/test/chunking-form/samples/preserve-entry-signatures/undefined-with-tainted-plugin-chunk/_expected/cjs/generated-main.js deleted file mode 100644 index e9d30866266..00000000000 --- a/test/chunking-form/samples/preserve-entry-signatures/undefined-with-tainted-plugin-chunk/_expected/cjs/generated-main.js +++ /dev/null @@ -1,8 +0,0 @@ -'use strict'; - -const shared = 'shared'; - -Promise.resolve().then(function () { return require('./generated-dynamic.js'); }); -globalThis.sharedStatic = shared; - -exports.shared = shared; diff --git a/test/chunking-form/samples/preserve-entry-signatures/undefined-with-tainted-plugin-chunk/_expected/es/generated-dynamic.js b/test/chunking-form/samples/preserve-entry-signatures/undefined-with-tainted-plugin-chunk/_expected/es/generated-dynamic.js deleted file mode 100644 index 3bae49ca2fb..00000000000 --- a/test/chunking-form/samples/preserve-entry-signatures/undefined-with-tainted-plugin-chunk/_expected/es/generated-dynamic.js +++ /dev/null @@ -1,3 +0,0 @@ -import { s as shared } from './generated-main.js'; - -globalThis.sharedDynamic = shared; diff --git a/test/chunking-form/samples/preserve-entry-signatures/undefined-with-tainted-plugin-chunk/_expected/es/generated-entry.js b/test/chunking-form/samples/preserve-entry-signatures/undefined-with-tainted-plugin-chunk/_expected/es/generated-entry.js deleted file mode 100644 index bc3090f4a30..00000000000 --- a/test/chunking-form/samples/preserve-entry-signatures/undefined-with-tainted-plugin-chunk/_expected/es/generated-entry.js +++ /dev/null @@ -1 +0,0 @@ -import './generated-main.js'; diff --git a/test/chunking-form/samples/preserve-entry-signatures/undefined-with-tainted-plugin-chunk/_expected/es/generated-main.js b/test/chunking-form/samples/preserve-entry-signatures/undefined-with-tainted-plugin-chunk/_expected/es/generated-main.js deleted file mode 100644 index 90b5ce20955..00000000000 --- a/test/chunking-form/samples/preserve-entry-signatures/undefined-with-tainted-plugin-chunk/_expected/es/generated-main.js +++ /dev/null @@ -1,6 +0,0 @@ -const shared = 'shared'; - -import('./generated-dynamic.js'); -globalThis.sharedStatic = shared; - -export { shared as s }; diff --git a/test/chunking-form/samples/preserve-entry-signatures/undefined-with-tainted-plugin-chunk/_expected/system/generated-dynamic.js b/test/chunking-form/samples/preserve-entry-signatures/undefined-with-tainted-plugin-chunk/_expected/system/generated-dynamic.js deleted file mode 100644 index 187cb5f2c9f..00000000000 --- a/test/chunking-form/samples/preserve-entry-signatures/undefined-with-tainted-plugin-chunk/_expected/system/generated-dynamic.js +++ /dev/null @@ -1,14 +0,0 @@ -System.register(['./generated-main.js'], function () { - 'use strict'; - var shared; - return { - setters: [function (module) { - shared = module.s; - }], - execute: function () { - - globalThis.sharedDynamic = shared; - - } - }; -}); diff --git a/test/chunking-form/samples/preserve-entry-signatures/undefined-with-tainted-plugin-chunk/_expected/system/generated-entry.js b/test/chunking-form/samples/preserve-entry-signatures/undefined-with-tainted-plugin-chunk/_expected/system/generated-entry.js deleted file mode 100644 index 1312c7a3bd6..00000000000 --- a/test/chunking-form/samples/preserve-entry-signatures/undefined-with-tainted-plugin-chunk/_expected/system/generated-entry.js +++ /dev/null @@ -1,11 +0,0 @@ -System.register(['./generated-main.js'], function () { - 'use strict'; - return { - setters: [function () {}], - execute: function () { - - - - } - }; -}); diff --git a/test/chunking-form/samples/preserve-entry-signatures/undefined-with-tainted-plugin-chunk/_expected/system/generated-main.js b/test/chunking-form/samples/preserve-entry-signatures/undefined-with-tainted-plugin-chunk/_expected/system/generated-main.js deleted file mode 100644 index fa458794a7b..00000000000 --- a/test/chunking-form/samples/preserve-entry-signatures/undefined-with-tainted-plugin-chunk/_expected/system/generated-main.js +++ /dev/null @@ -1,13 +0,0 @@ -System.register([], function (exports, module) { - 'use strict'; - return { - execute: function () { - - const shared = exports('s', 'shared'); - - module.import('./generated-dynamic.js'); - globalThis.sharedStatic = shared; - - } - }; -}); diff --git a/test/chunking-form/samples/preserve-entry-signatures/undefined-with-tainted-plugin-chunk/dynamic.js b/test/chunking-form/samples/preserve-entry-signatures/undefined-with-tainted-plugin-chunk/dynamic.js deleted file mode 100644 index d7a191e6ace..00000000000 --- a/test/chunking-form/samples/preserve-entry-signatures/undefined-with-tainted-plugin-chunk/dynamic.js +++ /dev/null @@ -1,3 +0,0 @@ -import { shared } from './lib.js'; - -globalThis.sharedDynamic = shared; diff --git a/test/chunking-form/samples/preserve-entry-signatures/undefined-with-tainted-plugin-chunk/lib.js b/test/chunking-form/samples/preserve-entry-signatures/undefined-with-tainted-plugin-chunk/lib.js deleted file mode 100644 index cd35843de7a..00000000000 --- a/test/chunking-form/samples/preserve-entry-signatures/undefined-with-tainted-plugin-chunk/lib.js +++ /dev/null @@ -1 +0,0 @@ -export const shared = 'shared'; diff --git a/test/chunking-form/samples/preserve-entry-signatures/undefined-with-tainted-plugin-chunk/main.js b/test/chunking-form/samples/preserve-entry-signatures/undefined-with-tainted-plugin-chunk/main.js deleted file mode 100644 index 20bd28fbede..00000000000 --- a/test/chunking-form/samples/preserve-entry-signatures/undefined-with-tainted-plugin-chunk/main.js +++ /dev/null @@ -1,3 +0,0 @@ -import { shared } from './lib.js'; -import('./dynamic.js'); -globalThis.sharedStatic = shared; diff --git a/test/chunking-form/samples/preserve-modules-auto-export-mode/_config.js b/test/chunking-form/samples/preserve-modules-auto-export-mode/_config.js index 7afad981a92..fd549715124 100644 --- a/test/chunking-form/samples/preserve-modules-auto-export-mode/_config.js +++ b/test/chunking-form/samples/preserve-modules-auto-export-mode/_config.js @@ -1,7 +1,7 @@ -module.exports = { +module.exports = defineTest({ description: 'Uses entry point semantics for all files when preserving modules', options: { input: 'main.js', output: { preserveModules: true } } -}; +}); diff --git a/test/chunking-form/samples/preserve-modules-auto-export-mode/_expected/amd/default.js b/test/chunking-form/samples/preserve-modules-auto-export-mode/_expected/amd/default.js index 9101b3f3d25..855cb78e217 100644 --- a/test/chunking-form/samples/preserve-modules-auto-export-mode/_expected/amd/default.js +++ b/test/chunking-form/samples/preserve-modules-auto-export-mode/_expected/amd/default.js @@ -1,7 +1,7 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; var foo = 'default'; return foo; -}); +})); diff --git a/test/chunking-form/samples/preserve-modules-auto-export-mode/_expected/amd/main.js b/test/chunking-form/samples/preserve-modules-auto-export-mode/_expected/amd/main.js index e9283e83bd9..fdb3413c434 100644 --- a/test/chunking-form/samples/preserve-modules-auto-export-mode/_expected/amd/main.js +++ b/test/chunking-form/samples/preserve-modules-auto-export-mode/_expected/amd/main.js @@ -1,14 +1,12 @@ -define(['require', './default', './named'], function (require, _default, named) { 'use strict'; +define(['require', './default', './named'], (function (require, _default, named) { 'use strict'; - function _interopNamespaceDefaultOnly(e) { - return Object.freeze({__proto__: null, 'default': e}); - } + function _interopNamespaceDefaultOnly (e) { return Object.freeze({ __proto__: null, default: e }); } console.log(_default, named.value); - new Promise(function (resolve, reject) { require(['./default'], function (m) { resolve(/*#__PURE__*/_interopNamespaceDefaultOnly(m)); }, reject) }).then(result => console.log(result.default)); - new Promise(function (resolve, reject) { require(['./named'], resolve, reject) }).then(result => console.log(result.value)); + new Promise(function (resolve, reject) { require(['./default'], function (m) { resolve(/*#__PURE__*/_interopNamespaceDefaultOnly(m)); }, reject); }).then(result => console.log(result.default)); + new Promise(function (resolve, reject) { require(['./named'], resolve, reject); }).then(result => console.log(result.value)); return _default; -}); +})); diff --git a/test/chunking-form/samples/preserve-modules-auto-export-mode/_expected/amd/named.js b/test/chunking-form/samples/preserve-modules-auto-export-mode/_expected/amd/named.js index 37e6d25bd85..2896dcf1065 100644 --- a/test/chunking-form/samples/preserve-modules-auto-export-mode/_expected/amd/named.js +++ b/test/chunking-form/samples/preserve-modules-auto-export-mode/_expected/amd/named.js @@ -1,9 +1,7 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; const value = 'named'; exports.value = value; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/preserve-modules-auto-export-mode/_expected/cjs/main.js b/test/chunking-form/samples/preserve-modules-auto-export-mode/_expected/cjs/main.js index f1ded2b4a64..5f9d03b262e 100644 --- a/test/chunking-form/samples/preserve-modules-auto-export-mode/_expected/cjs/main.js +++ b/test/chunking-form/samples/preserve-modules-auto-export-mode/_expected/cjs/main.js @@ -3,9 +3,7 @@ var _default = require('./default.js'); var named = require('./named.js'); -function _interopNamespaceDefaultOnly(e) { - return Object.freeze({__proto__: null, 'default': e}); -} +function _interopNamespaceDefaultOnly (e) { return Object.freeze({ __proto__: null, default: e }); } console.log(_default, named.value); diff --git a/test/chunking-form/samples/preserve-modules-auto-export-mode/_expected/cjs/named.js b/test/chunking-form/samples/preserve-modules-auto-export-mode/_expected/cjs/named.js index 491f8569447..ec20bc0d7ff 100644 --- a/test/chunking-form/samples/preserve-modules-auto-export-mode/_expected/cjs/named.js +++ b/test/chunking-form/samples/preserve-modules-auto-export-mode/_expected/cjs/named.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - const value = 'named'; exports.value = value; diff --git a/test/chunking-form/samples/preserve-modules-auto-export-mode/_expected/es/default.js b/test/chunking-form/samples/preserve-modules-auto-export-mode/_expected/es/default.js index 97dcda8cdc9..888d95cb398 100644 --- a/test/chunking-form/samples/preserve-modules-auto-export-mode/_expected/es/default.js +++ b/test/chunking-form/samples/preserve-modules-auto-export-mode/_expected/es/default.js @@ -1,3 +1,3 @@ var foo = 'default'; -export default foo; +export { foo as default }; diff --git a/test/chunking-form/samples/preserve-modules-auto-export-mode/_expected/es/main.js b/test/chunking-form/samples/preserve-modules-auto-export-mode/_expected/es/main.js index 1db891a835f..4aad85561da 100644 --- a/test/chunking-form/samples/preserve-modules-auto-export-mode/_expected/es/main.js +++ b/test/chunking-form/samples/preserve-modules-auto-export-mode/_expected/es/main.js @@ -1,8 +1,9 @@ import foo from './default.js'; -export { default } from './default.js'; import { value } from './named.js'; console.log(foo, value); import('./default.js').then(result => console.log(result.default)); import('./named.js').then(result => console.log(result.value)); + +export { foo as default }; diff --git a/test/chunking-form/samples/preserve-modules-auto-export-mode/_expected/system/default.js b/test/chunking-form/samples/preserve-modules-auto-export-mode/_expected/system/default.js index 0505d3144dd..cb797cc76ce 100644 --- a/test/chunking-form/samples/preserve-modules-auto-export-mode/_expected/system/default.js +++ b/test/chunking-form/samples/preserve-modules-auto-export-mode/_expected/system/default.js @@ -1,10 +1,10 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - var foo = exports('default', 'default'); + var foo = exports("default", 'default'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/preserve-modules-auto-export-mode/_expected/system/main.js b/test/chunking-form/samples/preserve-modules-auto-export-mode/_expected/system/main.js index 12e707aee57..a4eec95f2c8 100644 --- a/test/chunking-form/samples/preserve-modules-auto-export-mode/_expected/system/main.js +++ b/test/chunking-form/samples/preserve-modules-auto-export-mode/_expected/system/main.js @@ -1,20 +1,20 @@ -System.register(['./default.js', './named.js'], function (exports, module) { +System.register(['./default.js', './named.js'], (function (exports, module) { 'use strict'; var foo, value; return { setters: [function (module) { foo = module.default; - exports('default', module.default); + exports("default", module.default); }, function (module) { value = module.value; }], - execute: function () { + execute: (function () { console.log(foo, value); module.import('./default.js').then(result => console.log(result.default)); module.import('./named.js').then(result => console.log(result.value)); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/preserve-modules-auto-export-mode/_expected/system/named.js b/test/chunking-form/samples/preserve-modules-auto-export-mode/_expected/system/named.js index 431654fc285..2fb3fee2dae 100644 --- a/test/chunking-form/samples/preserve-modules-auto-export-mode/_expected/system/named.js +++ b/test/chunking-form/samples/preserve-modules-auto-export-mode/_expected/system/named.js @@ -1,10 +1,10 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - const value = exports('value', 'named'); + const value = exports("value", 'named'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/preserve-modules-commonjs/_config.js b/test/chunking-form/samples/preserve-modules-commonjs/_config.js index c748f85794d..9b98044a176 100644 --- a/test/chunking-form/samples/preserve-modules-commonjs/_config.js +++ b/test/chunking-form/samples/preserve-modules-commonjs/_config.js @@ -1,6 +1,6 @@ const commonjs = require('@rollup/plugin-commonjs'); -module.exports = { +module.exports = defineTest({ description: 'Handles output from @rollup/plugin-commonjs', expectedWarnings: ['MIXED_EXPORTS'], options: { @@ -9,4 +9,4 @@ module.exports = { plugins: [commonjs()], output: { preserveModules: true } } -}; +}); diff --git a/test/chunking-form/samples/preserve-modules-commonjs/_expected/amd/_virtual/_commonjsHelpers.js b/test/chunking-form/samples/preserve-modules-commonjs/_expected/amd/_virtual/_commonjsHelpers.js new file mode 100644 index 00000000000..f35ac4ef0d7 --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-commonjs/_expected/amd/_virtual/_commonjsHelpers.js @@ -0,0 +1,9 @@ +define(['exports'], (function (exports) { 'use strict'; + + function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; + } + + exports.getDefaultExportFromCjs = getDefaultExportFromCjs; + +})); diff --git a/test/chunking-form/samples/preserve-modules-commonjs/_expected/amd/_virtual/commonjs.js b/test/chunking-form/samples/preserve-modules-commonjs/_expected/amd/_virtual/commonjs.js new file mode 100644 index 00000000000..bb034a103d8 --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-commonjs/_expected/amd/_virtual/commonjs.js @@ -0,0 +1,8 @@ +define(['./_commonjsHelpers', '../commonjs'], (function (_commonjsHelpers, commonjs) { 'use strict'; + + var commonjsExports = commonjs.__require(); + var value = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(commonjsExports); + + return value; + +})); diff --git a/test/chunking-form/samples/preserve-modules-commonjs/_expected/amd/_virtual/other.js b/test/chunking-form/samples/preserve-modules-commonjs/_expected/amd/_virtual/other.js new file mode 100644 index 00000000000..ab90c1d68e7 --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-commonjs/_expected/amd/_virtual/other.js @@ -0,0 +1,7 @@ +define(['exports'], (function (exports) { 'use strict'; + + var other = {}; + + exports.__exports = other; + +})); diff --git a/test/chunking-form/samples/preserve-modules-commonjs/_expected/amd/_virtual/other.js_commonjs-exports b/test/chunking-form/samples/preserve-modules-commonjs/_expected/amd/_virtual/other.js_commonjs-exports deleted file mode 100644 index c85e5adb0f9..00000000000 --- a/test/chunking-form/samples/preserve-modules-commonjs/_expected/amd/_virtual/other.js_commonjs-exports +++ /dev/null @@ -1,9 +0,0 @@ -define(['exports'], function (exports) { 'use strict'; - - var other = {}; - - exports.__exports = other; - - Object.defineProperty(exports, '__esModule', { value: true }); - -}); diff --git a/test/chunking-form/samples/preserve-modules-commonjs/_expected/amd/commonjs.js b/test/chunking-form/samples/preserve-modules-commonjs/_expected/amd/commonjs.js index 530d96e07be..a2d2bca7e35 100644 --- a/test/chunking-form/samples/preserve-modules-commonjs/_expected/amd/commonjs.js +++ b/test/chunking-form/samples/preserve-modules-commonjs/_expected/amd/commonjs.js @@ -1,16 +1,20 @@ -define(['external', './other', './_virtual/other.js_commonjs-exports'], function (require$$0, other$1, other) { 'use strict'; +define(['exports', 'external', './other'], (function (exports, require$$0, other) { 'use strict'; - function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } + var commonjs; + var hasRequiredCommonjs; - var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0); + function requireCommonjs () { + if (hasRequiredCommonjs) return commonjs; + hasRequiredCommonjs = 1; + const external = require$$0; + const { value } = other.__require(); - const external = require$$0__default['default']; - const { value } = other.__exports; + console.log(external, value); - console.log(external, value); + commonjs = 42; + return commonjs; + } - var commonjs = 42; + exports.__require = requireCommonjs; - return commonjs; - -}); +})); diff --git a/test/chunking-form/samples/preserve-modules-commonjs/_expected/amd/main.js b/test/chunking-form/samples/preserve-modules-commonjs/_expected/amd/main.js index 59ea43e35ad..c840ba70e44 100644 --- a/test/chunking-form/samples/preserve-modules-commonjs/_expected/amd/main.js +++ b/test/chunking-form/samples/preserve-modules-commonjs/_expected/amd/main.js @@ -1,9 +1,5 @@ -define(['./commonjs', 'external'], function (commonjs, require$$0) { 'use strict'; +define(['./_virtual/commonjs', 'external'], (function (commonjs, require$$0) { 'use strict'; - function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } + console.log(commonjs, require$$0); - var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0); - - console.log(commonjs, require$$0__default['default']); - -}); +})); diff --git a/test/chunking-form/samples/preserve-modules-commonjs/_expected/amd/other.js b/test/chunking-form/samples/preserve-modules-commonjs/_expected/amd/other.js index 72f196e0562..7f6a9cbece3 100644 --- a/test/chunking-form/samples/preserve-modules-commonjs/_expected/amd/other.js +++ b/test/chunking-form/samples/preserve-modules-commonjs/_expected/amd/other.js @@ -1,7 +1,14 @@ -define(['./_virtual/other.js_commonjs-exports'], function (other) { 'use strict'; +define(['exports', './_virtual/other'], (function (exports, other) { 'use strict'; - other.__exports.value = 43; + var hasRequiredOther; - return other.__exports; + function requireOther () { + if (hasRequiredOther) return other.__exports; + hasRequiredOther = 1; + other.__exports.value = 43; + return other.__exports; + } -}); + exports.__require = requireOther; + +})); diff --git a/test/chunking-form/samples/preserve-modules-commonjs/_expected/cjs/_virtual/_commonjsHelpers.js b/test/chunking-form/samples/preserve-modules-commonjs/_expected/cjs/_virtual/_commonjsHelpers.js new file mode 100644 index 00000000000..ceeaa4d077f --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-commonjs/_expected/cjs/_virtual/_commonjsHelpers.js @@ -0,0 +1,7 @@ +'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +exports.getDefaultExportFromCjs = getDefaultExportFromCjs; diff --git a/test/chunking-form/samples/preserve-modules-commonjs/_expected/cjs/_virtual/commonjs.js b/test/chunking-form/samples/preserve-modules-commonjs/_expected/cjs/_virtual/commonjs.js new file mode 100644 index 00000000000..52ed3aeea0a --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-commonjs/_expected/cjs/_virtual/commonjs.js @@ -0,0 +1,9 @@ +'use strict'; + +var _commonjsHelpers = require('./_commonjsHelpers.js'); +var commonjs = require('../commonjs.js'); + +var commonjsExports = commonjs.__require(); +var value = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(commonjsExports); + +module.exports = value; diff --git a/test/chunking-form/samples/preserve-modules-commonjs/_expected/cjs/_virtual/other.js b/test/chunking-form/samples/preserve-modules-commonjs/_expected/cjs/_virtual/other.js new file mode 100644 index 00000000000..6569c1d2a46 --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-commonjs/_expected/cjs/_virtual/other.js @@ -0,0 +1,5 @@ +'use strict'; + +var other = {}; + +exports.__exports = other; diff --git a/test/chunking-form/samples/preserve-modules-commonjs/_expected/cjs/_virtual/other.js_commonjs-exports b/test/chunking-form/samples/preserve-modules-commonjs/_expected/cjs/_virtual/other.js_commonjs-exports deleted file mode 100644 index bc3ca602c7c..00000000000 --- a/test/chunking-form/samples/preserve-modules-commonjs/_expected/cjs/_virtual/other.js_commonjs-exports +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { value: true }); - -var other = {}; - -exports.__exports = other; diff --git a/test/chunking-form/samples/preserve-modules-commonjs/_expected/cjs/commonjs.js b/test/chunking-form/samples/preserve-modules-commonjs/_expected/cjs/commonjs.js index 01c49bb95e2..1cb677b9e42 100644 --- a/test/chunking-form/samples/preserve-modules-commonjs/_expected/cjs/commonjs.js +++ b/test/chunking-form/samples/preserve-modules-commonjs/_expected/cjs/commonjs.js @@ -1,18 +1,21 @@ 'use strict'; var require$$0 = require('external'); -require('./other.js'); -var other = require('./_virtual/other.js_commonjs-exports'); +var other = require('./other.js'); -function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } +var commonjs; +var hasRequiredCommonjs; -var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0); +function requireCommonjs () { + if (hasRequiredCommonjs) return commonjs; + hasRequiredCommonjs = 1; + const external = require$$0; + const { value } = other.__require(); -const external = require$$0__default['default']; -const { value } = other.__exports; + console.log(external, value); -console.log(external, value); + commonjs = 42; + return commonjs; +} -var commonjs = 42; - -module.exports = commonjs; +exports.__require = requireCommonjs; diff --git a/test/chunking-form/samples/preserve-modules-commonjs/_expected/cjs/main.js b/test/chunking-form/samples/preserve-modules-commonjs/_expected/cjs/main.js index d7fe0c9c3a7..81b8b36e38b 100644 --- a/test/chunking-form/samples/preserve-modules-commonjs/_expected/cjs/main.js +++ b/test/chunking-form/samples/preserve-modules-commonjs/_expected/cjs/main.js @@ -1,10 +1,6 @@ 'use strict'; -var commonjs = require('./commonjs.js'); +var commonjs = require('./_virtual/commonjs.js'); var require$$0 = require('external'); -function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } - -var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0); - -console.log(commonjs, require$$0__default['default']); +console.log(commonjs, require$$0); diff --git a/test/chunking-form/samples/preserve-modules-commonjs/_expected/cjs/other.js b/test/chunking-form/samples/preserve-modules-commonjs/_expected/cjs/other.js index a514a7d358f..13cbea37000 100644 --- a/test/chunking-form/samples/preserve-modules-commonjs/_expected/cjs/other.js +++ b/test/chunking-form/samples/preserve-modules-commonjs/_expected/cjs/other.js @@ -1,7 +1,14 @@ 'use strict'; -var other = require('./_virtual/other.js_commonjs-exports'); +var other = require('./_virtual/other.js'); -other.__exports.value = 43; +var hasRequiredOther; -module.exports = other.__exports; +function requireOther () { + if (hasRequiredOther) return other.__exports; + hasRequiredOther = 1; + other.__exports.value = 43; + return other.__exports; +} + +exports.__require = requireOther; diff --git a/test/chunking-form/samples/preserve-modules-commonjs/_expected/es/_virtual/_commonjsHelpers.js b/test/chunking-form/samples/preserve-modules-commonjs/_expected/es/_virtual/_commonjsHelpers.js new file mode 100644 index 00000000000..7b7c5f4f531 --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-commonjs/_expected/es/_virtual/_commonjsHelpers.js @@ -0,0 +1,5 @@ +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +export { getDefaultExportFromCjs }; diff --git a/test/chunking-form/samples/preserve-modules-commonjs/_expected/es/_virtual/commonjs.js b/test/chunking-form/samples/preserve-modules-commonjs/_expected/es/_virtual/commonjs.js new file mode 100644 index 00000000000..e71a2bb1e27 --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-commonjs/_expected/es/_virtual/commonjs.js @@ -0,0 +1,7 @@ +import { getDefaultExportFromCjs } from './_commonjsHelpers.js'; +import { __require as requireCommonjs } from '../commonjs.js'; + +var commonjsExports = requireCommonjs(); +var value = /*@__PURE__*/getDefaultExportFromCjs(commonjsExports); + +export { value as default }; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-commonjs/_expected/es/_virtual/other.js_commonjs-exports b/test/chunking-form/samples/preserve-modules-commonjs/_expected/es/_virtual/other.js similarity index 100% rename from test/chunking-form/samples/deprecated/preserve-modules-commonjs/_expected/es/_virtual/other.js_commonjs-exports rename to test/chunking-form/samples/preserve-modules-commonjs/_expected/es/_virtual/other.js diff --git a/test/chunking-form/samples/preserve-modules-commonjs/_expected/es/_virtual/other.js_commonjs-exports b/test/chunking-form/samples/preserve-modules-commonjs/_expected/es/_virtual/other.js_commonjs-exports deleted file mode 100644 index 4825c11ddb0..00000000000 --- a/test/chunking-form/samples/preserve-modules-commonjs/_expected/es/_virtual/other.js_commonjs-exports +++ /dev/null @@ -1,3 +0,0 @@ -var other = {}; - -export { other as __exports }; diff --git a/test/chunking-form/samples/preserve-modules-commonjs/_expected/es/commonjs.js b/test/chunking-form/samples/preserve-modules-commonjs/_expected/es/commonjs.js index 75c39f48f46..531b67dd27f 100644 --- a/test/chunking-form/samples/preserve-modules-commonjs/_expected/es/commonjs.js +++ b/test/chunking-form/samples/preserve-modules-commonjs/_expected/es/commonjs.js @@ -1,12 +1,19 @@ import require$$0 from 'external'; -import './other.js'; -import { __exports as other } from './_virtual/other.js_commonjs-exports'; +import { __require as requireOther } from './other.js'; -const external = require$$0; -const { value } = other; +var commonjs; +var hasRequiredCommonjs; -console.log(external, value); +function requireCommonjs () { + if (hasRequiredCommonjs) return commonjs; + hasRequiredCommonjs = 1; + const external = require$$0; + const { value } = requireOther(); -var commonjs = 42; + console.log(external, value); -export default commonjs; + commonjs = 42; + return commonjs; +} + +export { requireCommonjs as __require }; diff --git a/test/chunking-form/samples/preserve-modules-commonjs/_expected/es/main.js b/test/chunking-form/samples/preserve-modules-commonjs/_expected/es/main.js index de8bda2bf4c..30722a4efe5 100644 --- a/test/chunking-form/samples/preserve-modules-commonjs/_expected/es/main.js +++ b/test/chunking-form/samples/preserve-modules-commonjs/_expected/es/main.js @@ -1,4 +1,4 @@ -import commonjs from './commonjs.js'; +import value from './_virtual/commonjs.js'; import require$$0 from 'external'; -console.log(commonjs, require$$0); +console.log(value, require$$0); diff --git a/test/chunking-form/samples/preserve-modules-commonjs/_expected/es/other.js b/test/chunking-form/samples/preserve-modules-commonjs/_expected/es/other.js index f9d6ad0cb3c..681f9fb6035 100644 --- a/test/chunking-form/samples/preserve-modules-commonjs/_expected/es/other.js +++ b/test/chunking-form/samples/preserve-modules-commonjs/_expected/es/other.js @@ -1,4 +1,12 @@ -import { __exports as other } from './_virtual/other.js_commonjs-exports'; -export { __exports as default } from './_virtual/other.js_commonjs-exports'; +import { __exports as other } from './_virtual/other.js'; -other.value = 43; +var hasRequiredOther; + +function requireOther () { + if (hasRequiredOther) return other; + hasRequiredOther = 1; + other.value = 43; + return other; +} + +export { requireOther as __require }; diff --git a/test/chunking-form/samples/preserve-modules-commonjs/_expected/system/_virtual/_commonjsHelpers.js b/test/chunking-form/samples/preserve-modules-commonjs/_expected/system/_virtual/_commonjsHelpers.js new file mode 100644 index 00000000000..dd2c5886a6d --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-commonjs/_expected/system/_virtual/_commonjsHelpers.js @@ -0,0 +1,14 @@ +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + + exports("getDefaultExportFromCjs", getDefaultExportFromCjs); + + function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; + } + + }) + }; +})); diff --git a/test/chunking-form/samples/preserve-modules-commonjs/_expected/system/_virtual/commonjs.js b/test/chunking-form/samples/preserve-modules-commonjs/_expected/system/_virtual/commonjs.js new file mode 100644 index 00000000000..152beddc8fb --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-commonjs/_expected/system/_virtual/commonjs.js @@ -0,0 +1,17 @@ +System.register(['./_commonjsHelpers.js', '../commonjs.js'], (function (exports) { + 'use strict'; + var getDefaultExportFromCjs, requireCommonjs; + return { + setters: [function (module) { + getDefaultExportFromCjs = module.getDefaultExportFromCjs; + }, function (module) { + requireCommonjs = module.__require; + }], + execute: (function () { + + var commonjsExports = requireCommonjs(); + var value = exports("default", /*@__PURE__*/getDefaultExportFromCjs(commonjsExports)); + + }) + }; +})); diff --git a/test/chunking-form/samples/preserve-modules-commonjs/_expected/system/_virtual/other.js b/test/chunking-form/samples/preserve-modules-commonjs/_expected/system/_virtual/other.js new file mode 100644 index 00000000000..da8e0a2f229 --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-commonjs/_expected/system/_virtual/other.js @@ -0,0 +1,10 @@ +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + + var other = exports("__exports", {}); + + }) + }; +})); diff --git a/test/chunking-form/samples/preserve-modules-commonjs/_expected/system/_virtual/other.js_commonjs-exports b/test/chunking-form/samples/preserve-modules-commonjs/_expected/system/_virtual/other.js_commonjs-exports deleted file mode 100644 index 99e54f7255f..00000000000 --- a/test/chunking-form/samples/preserve-modules-commonjs/_expected/system/_virtual/other.js_commonjs-exports +++ /dev/null @@ -1,10 +0,0 @@ -System.register([], function (exports) { - 'use strict'; - return { - execute: function () { - - var other = exports('__exports', {}); - - } - }; -}); diff --git a/test/chunking-form/samples/preserve-modules-commonjs/_expected/system/commonjs.js b/test/chunking-form/samples/preserve-modules-commonjs/_expected/system/commonjs.js index 61194b78720..749fab63c36 100644 --- a/test/chunking-form/samples/preserve-modules-commonjs/_expected/system/commonjs.js +++ b/test/chunking-form/samples/preserve-modules-commonjs/_expected/system/commonjs.js @@ -1,21 +1,31 @@ -System.register(['external', './other.js', './_virtual/other.js_commonjs-exports'], function (exports) { +System.register(['external', './other.js'], (function (exports) { 'use strict'; - var require$$0, other; + var require$$0, requireOther; return { setters: [function (module) { require$$0 = module.default; - }, function () {}, function (module) { - other = module.__exports; + }, function (module) { + requireOther = module.__require; }], - execute: function () { + execute: (function () { - const external = require$$0; - const { value } = other; + exports("__require", requireCommonjs); - console.log(external, value); + var commonjs; + var hasRequiredCommonjs; - var commonjs = exports('default', 42); + function requireCommonjs () { + if (hasRequiredCommonjs) return commonjs; + hasRequiredCommonjs = 1; + const external = require$$0; + const { value } = requireOther(); - } + console.log(external, value); + + commonjs = 42; + return commonjs; + } + + }) }; -}); +})); diff --git a/test/chunking-form/samples/preserve-modules-commonjs/_expected/system/main.js b/test/chunking-form/samples/preserve-modules-commonjs/_expected/system/main.js index 903fc6c4977..d93798ed584 100644 --- a/test/chunking-form/samples/preserve-modules-commonjs/_expected/system/main.js +++ b/test/chunking-form/samples/preserve-modules-commonjs/_expected/system/main.js @@ -1,16 +1,16 @@ -System.register(['./commonjs.js', 'external'], function () { +System.register(['./_virtual/commonjs.js', 'external'], (function () { 'use strict'; - var commonjs, require$$0; + var value, require$$0; return { setters: [function (module) { - commonjs = module.default; + value = module.default; }, function (module) { require$$0 = module.default; }], - execute: function () { + execute: (function () { - console.log(commonjs, require$$0); + console.log(value, require$$0); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/preserve-modules-commonjs/_expected/system/other.js b/test/chunking-form/samples/preserve-modules-commonjs/_expected/system/other.js index ce56d7889f6..73bf9afa967 100644 --- a/test/chunking-form/samples/preserve-modules-commonjs/_expected/system/other.js +++ b/test/chunking-form/samples/preserve-modules-commonjs/_expected/system/other.js @@ -1,15 +1,23 @@ -System.register(['./_virtual/other.js_commonjs-exports'], function (exports) { +System.register(['./_virtual/other.js'], (function (exports) { 'use strict'; var other; return { setters: [function (module) { other = module.__exports; - exports('default', module.__exports); }], - execute: function () { + execute: (function () { - other.value = 43; + exports("__require", requireOther); - } + var hasRequiredOther; + + function requireOther () { + if (hasRequiredOther) return other; + hasRequiredOther = 1; + other.value = 43; + return other; + } + + }) }; -}); +})); diff --git a/test/chunking-form/samples/preserve-modules-default-mode-namespace/_config.js b/test/chunking-form/samples/preserve-modules-default-mode-namespace/_config.js index 12e5ced8b34..3cdaf10c851 100644 --- a/test/chunking-form/samples/preserve-modules-default-mode-namespace/_config.js +++ b/test/chunking-form/samples/preserve-modules-default-mode-namespace/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'import namespace from chunks with default export mode when preserving modules', options: { input: ['main', 'lib'], @@ -6,4 +6,4 @@ module.exports = { preserveModules: true } } -}; +}); diff --git a/test/chunking-form/samples/preserve-modules-default-mode-namespace/_expected/amd/lib.js b/test/chunking-form/samples/preserve-modules-default-mode-namespace/_expected/amd/lib.js index dedcf1cdf11..30214a2ec93 100644 --- a/test/chunking-form/samples/preserve-modules-default-mode-namespace/_expected/amd/lib.js +++ b/test/chunking-form/samples/preserve-modules-default-mode-namespace/_expected/amd/lib.js @@ -1,7 +1,7 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; var lib = 'foo'; return lib; -}); +})); diff --git a/test/chunking-form/samples/preserve-modules-default-mode-namespace/_expected/amd/main.js b/test/chunking-form/samples/preserve-modules-default-mode-namespace/_expected/amd/main.js index 0d9d87fc9bc..523aba257a4 100644 --- a/test/chunking-form/samples/preserve-modules-default-mode-namespace/_expected/amd/main.js +++ b/test/chunking-form/samples/preserve-modules-default-mode-namespace/_expected/amd/main.js @@ -1,16 +1,12 @@ -define(['require', 'exports', './lib'], function (require, exports, lib) { 'use strict'; +define(['require', 'exports', './lib'], (function (require, exports, lib) { 'use strict'; - function _interopNamespaceDefaultOnly(e) { - return Object.freeze({__proto__: null, 'default': e}); - } + function _interopNamespaceDefaultOnly (e) { return Object.freeze({ __proto__: null, default: e }); } var lib__namespace = /*#__PURE__*/_interopNamespaceDefaultOnly(lib); console.log(lib__namespace); - new Promise(function (resolve, reject) { require(['./lib'], function (m) { resolve(/*#__PURE__*/_interopNamespaceDefaultOnly(m)); }, reject) }).then(console.log); + new Promise(function (resolve, reject) { require(['./lib'], function (m) { resolve(/*#__PURE__*/_interopNamespaceDefaultOnly(m)); }, reject); }).then(console.log); exports.lib = lib__namespace; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/preserve-modules-default-mode-namespace/_expected/cjs/main.js b/test/chunking-form/samples/preserve-modules-default-mode-namespace/_expected/cjs/main.js index 5a2da29a1c3..31a192f780e 100644 --- a/test/chunking-form/samples/preserve-modules-default-mode-namespace/_expected/cjs/main.js +++ b/test/chunking-form/samples/preserve-modules-default-mode-namespace/_expected/cjs/main.js @@ -1,12 +1,8 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - var lib = require('./lib.js'); -function _interopNamespaceDefaultOnly(e) { - return Object.freeze({__proto__: null, 'default': e}); -} +function _interopNamespaceDefaultOnly (e) { return Object.freeze({ __proto__: null, default: e }); } var lib__namespace = /*#__PURE__*/_interopNamespaceDefaultOnly(lib); diff --git a/test/chunking-form/samples/preserve-modules-default-mode-namespace/_expected/es/lib.js b/test/chunking-form/samples/preserve-modules-default-mode-namespace/_expected/es/lib.js index 53bd733a775..67d49bee15f 100644 --- a/test/chunking-form/samples/preserve-modules-default-mode-namespace/_expected/es/lib.js +++ b/test/chunking-form/samples/preserve-modules-default-mode-namespace/_expected/es/lib.js @@ -1,3 +1,3 @@ var lib = 'foo'; -export default lib; +export { lib as default }; diff --git a/test/chunking-form/samples/preserve-modules-default-mode-namespace/_expected/es/main.js b/test/chunking-form/samples/preserve-modules-default-mode-namespace/_expected/es/main.js index 17433b486bb..e4f825b8bb8 100644 --- a/test/chunking-form/samples/preserve-modules-default-mode-namespace/_expected/es/main.js +++ b/test/chunking-form/samples/preserve-modules-default-mode-namespace/_expected/es/main.js @@ -1,5 +1,6 @@ import * as lib from './lib.js'; -export { lib }; console.log(lib); import('./lib.js').then(console.log); + +export { lib }; diff --git a/test/chunking-form/samples/preserve-modules-default-mode-namespace/_expected/system/lib.js b/test/chunking-form/samples/preserve-modules-default-mode-namespace/_expected/system/lib.js index bae4f648370..f51d7c6420f 100644 --- a/test/chunking-form/samples/preserve-modules-default-mode-namespace/_expected/system/lib.js +++ b/test/chunking-form/samples/preserve-modules-default-mode-namespace/_expected/system/lib.js @@ -1,10 +1,10 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - var lib = exports('default', 'foo'); + var lib = exports("default", 'foo'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/preserve-modules-default-mode-namespace/_expected/system/main.js b/test/chunking-form/samples/preserve-modules-default-mode-namespace/_expected/system/main.js index 8b552ec64fe..8737c0c08b5 100644 --- a/test/chunking-form/samples/preserve-modules-default-mode-namespace/_expected/system/main.js +++ b/test/chunking-form/samples/preserve-modules-default-mode-namespace/_expected/system/main.js @@ -1,16 +1,16 @@ -System.register(['./lib.js'], function (exports, module) { +System.register(['./lib.js'], (function (exports, module) { 'use strict'; var lib; return { setters: [function (module) { lib = module; - exports('lib', module); + exports("lib", module); }], - execute: function () { + execute: (function () { console.log(lib); module.import('./lib.js').then(console.log); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/preserve-modules-default-mode-namespace2/_config.js b/test/chunking-form/samples/preserve-modules-default-mode-namespace2/_config.js index 12e5ced8b34..3cdaf10c851 100644 --- a/test/chunking-form/samples/preserve-modules-default-mode-namespace2/_config.js +++ b/test/chunking-form/samples/preserve-modules-default-mode-namespace2/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'import namespace from chunks with default export mode when preserving modules', options: { input: ['main', 'lib'], @@ -6,4 +6,4 @@ module.exports = { preserveModules: true } } -}; +}); diff --git a/test/chunking-form/samples/preserve-modules-default-mode-namespace2/_expected/amd/lib.js b/test/chunking-form/samples/preserve-modules-default-mode-namespace2/_expected/amd/lib.js index dedcf1cdf11..30214a2ec93 100644 --- a/test/chunking-form/samples/preserve-modules-default-mode-namespace2/_expected/amd/lib.js +++ b/test/chunking-form/samples/preserve-modules-default-mode-namespace2/_expected/amd/lib.js @@ -1,7 +1,7 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; var lib = 'foo'; return lib; -}); +})); diff --git a/test/chunking-form/samples/preserve-modules-default-mode-namespace2/_expected/amd/main.js b/test/chunking-form/samples/preserve-modules-default-mode-namespace2/_expected/amd/main.js index 497eae42fbd..510601fa8ab 100644 --- a/test/chunking-form/samples/preserve-modules-default-mode-namespace2/_expected/amd/main.js +++ b/test/chunking-form/samples/preserve-modules-default-mode-namespace2/_expected/amd/main.js @@ -1,11 +1,9 @@ -define(['./lib'], function (lib) { 'use strict'; +define(['./lib'], (function (lib) { 'use strict'; - function _interopNamespaceDefaultOnly(e) { - return Object.freeze({__proto__: null, 'default': e}); - } + function _interopNamespaceDefaultOnly (e) { return Object.freeze({ __proto__: null, default: e }); } var lib__namespace = /*#__PURE__*/_interopNamespaceDefaultOnly(lib); console.log(lib__namespace); -}); +})); diff --git a/test/chunking-form/samples/preserve-modules-default-mode-namespace2/_expected/cjs/main.js b/test/chunking-form/samples/preserve-modules-default-mode-namespace2/_expected/cjs/main.js index b6e183999c1..ac73b8bc39e 100644 --- a/test/chunking-form/samples/preserve-modules-default-mode-namespace2/_expected/cjs/main.js +++ b/test/chunking-form/samples/preserve-modules-default-mode-namespace2/_expected/cjs/main.js @@ -2,9 +2,7 @@ var lib = require('./lib.js'); -function _interopNamespaceDefaultOnly(e) { - return Object.freeze({__proto__: null, 'default': e}); -} +function _interopNamespaceDefaultOnly (e) { return Object.freeze({ __proto__: null, default: e }); } var lib__namespace = /*#__PURE__*/_interopNamespaceDefaultOnly(lib); diff --git a/test/chunking-form/samples/preserve-modules-default-mode-namespace2/_expected/es/lib.js b/test/chunking-form/samples/preserve-modules-default-mode-namespace2/_expected/es/lib.js index 53bd733a775..67d49bee15f 100644 --- a/test/chunking-form/samples/preserve-modules-default-mode-namespace2/_expected/es/lib.js +++ b/test/chunking-form/samples/preserve-modules-default-mode-namespace2/_expected/es/lib.js @@ -1,3 +1,3 @@ var lib = 'foo'; -export default lib; +export { lib as default }; diff --git a/test/chunking-form/samples/preserve-modules-default-mode-namespace2/_expected/system/lib.js b/test/chunking-form/samples/preserve-modules-default-mode-namespace2/_expected/system/lib.js index bae4f648370..f51d7c6420f 100644 --- a/test/chunking-form/samples/preserve-modules-default-mode-namespace2/_expected/system/lib.js +++ b/test/chunking-form/samples/preserve-modules-default-mode-namespace2/_expected/system/lib.js @@ -1,10 +1,10 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - var lib = exports('default', 'foo'); + var lib = exports("default", 'foo'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/preserve-modules-default-mode-namespace2/_expected/system/main.js b/test/chunking-form/samples/preserve-modules-default-mode-namespace2/_expected/system/main.js index 211538e5350..3dfb2cd9a0f 100644 --- a/test/chunking-form/samples/preserve-modules-default-mode-namespace2/_expected/system/main.js +++ b/test/chunking-form/samples/preserve-modules-default-mode-namespace2/_expected/system/main.js @@ -1,14 +1,14 @@ -System.register(['./lib.js'], function () { +System.register(['./lib.js'], (function () { 'use strict'; var lib; return { setters: [function (module) { lib = module; }], - execute: function () { + execute: (function () { console.log(lib); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/preserve-modules-dynamic-imports/_config.js b/test/chunking-form/samples/preserve-modules-dynamic-imports/_config.js index cd38717b589..5046f3f8aec 100644 --- a/test/chunking-form/samples/preserve-modules-dynamic-imports/_config.js +++ b/test/chunking-form/samples/preserve-modules-dynamic-imports/_config.js @@ -1,7 +1,7 @@ -module.exports = { +module.exports = defineTest({ description: 'dynamic imports are handled correctly when preserving modules', options: { input: ['main.js'], output: { preserveModules: true } } -}; +}); diff --git a/test/chunking-form/samples/preserve-modules-dynamic-imports/_expected/amd/dynamic-included.js b/test/chunking-form/samples/preserve-modules-dynamic-imports/_expected/amd/dynamic-included.js index afd117130dc..19414d6fd6d 100644 --- a/test/chunking-form/samples/preserve-modules-dynamic-imports/_expected/amd/dynamic-included.js +++ b/test/chunking-form/samples/preserve-modules-dynamic-imports/_expected/amd/dynamic-included.js @@ -1,9 +1,7 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; const value = 'included'; exports.value = value; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/preserve-modules-dynamic-imports/_expected/amd/main.js b/test/chunking-form/samples/preserve-modules-dynamic-imports/_expected/amd/main.js index 2ec310c64aa..d46b5b5edf5 100644 --- a/test/chunking-form/samples/preserve-modules-dynamic-imports/_expected/amd/main.js +++ b/test/chunking-form/samples/preserve-modules-dynamic-imports/_expected/amd/main.js @@ -1,5 +1,5 @@ -define(['require'], function (require) { 'use strict'; +define(['require'], (function (require) { 'use strict'; - new Promise(function (resolve, reject) { require(['./dynamic-included'], resolve, reject) }).then(result => console.log(result)); + new Promise(function (resolve, reject) { require(['./dynamic-included'], resolve, reject); }).then(result => console.log(result)); -}); +})); diff --git a/test/chunking-form/samples/preserve-modules-dynamic-imports/_expected/cjs/dynamic-included.js b/test/chunking-form/samples/preserve-modules-dynamic-imports/_expected/cjs/dynamic-included.js index 2c8d642e303..7ce0b0473fe 100644 --- a/test/chunking-form/samples/preserve-modules-dynamic-imports/_expected/cjs/dynamic-included.js +++ b/test/chunking-form/samples/preserve-modules-dynamic-imports/_expected/cjs/dynamic-included.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - const value = 'included'; exports.value = value; diff --git a/test/chunking-form/samples/preserve-modules-dynamic-imports/_expected/system/dynamic-included.js b/test/chunking-form/samples/preserve-modules-dynamic-imports/_expected/system/dynamic-included.js index 3a6e756071e..c04229514a9 100644 --- a/test/chunking-form/samples/preserve-modules-dynamic-imports/_expected/system/dynamic-included.js +++ b/test/chunking-form/samples/preserve-modules-dynamic-imports/_expected/system/dynamic-included.js @@ -1,10 +1,10 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - const value = exports('value', 'included'); + const value = exports("value", 'included'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/preserve-modules-dynamic-imports/_expected/system/main.js b/test/chunking-form/samples/preserve-modules-dynamic-imports/_expected/system/main.js index 26c21dcccb5..46d09c0e364 100644 --- a/test/chunking-form/samples/preserve-modules-dynamic-imports/_expected/system/main.js +++ b/test/chunking-form/samples/preserve-modules-dynamic-imports/_expected/system/main.js @@ -1,10 +1,10 @@ -System.register([], function (exports, module) { +System.register([], (function (exports, module) { 'use strict'; return { - execute: function () { + execute: (function () { module.import('./dynamic-included.js').then(result => console.log(result)); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/preserve-modules-dynamic-namespace/_config.js b/test/chunking-form/samples/preserve-modules-dynamic-namespace/_config.js index 10c317cd8fc..a1eb968e676 100644 --- a/test/chunking-form/samples/preserve-modules-dynamic-namespace/_config.js +++ b/test/chunking-form/samples/preserve-modules-dynamic-namespace/_config.js @@ -1,7 +1,7 @@ -module.exports = { +module.exports = defineTest({ description: 'Preserve modules properly handles internal namespace imports (#2576)', options: { input: ['main.js'], output: { preserveModules: true } } -}; +}); diff --git a/test/chunking-form/samples/preserve-modules-dynamic-namespace/_expected/amd/m1.js b/test/chunking-form/samples/preserve-modules-dynamic-namespace/_expected/amd/m1.js index 25f53d93a63..f5475ebcc07 100644 --- a/test/chunking-form/samples/preserve-modules-dynamic-namespace/_expected/amd/m1.js +++ b/test/chunking-form/samples/preserve-modules-dynamic-namespace/_expected/amd/m1.js @@ -1,10 +1,8 @@ -define(['exports', './m2', './m3'], function (exports, m2, m3) { 'use strict'; +define(['exports', './m2', './m3'], (function (exports, m2, m3) { 'use strict'; exports.m2 = m2; exports.m3 = m3; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/preserve-modules-dynamic-namespace/_expected/amd/m2.js b/test/chunking-form/samples/preserve-modules-dynamic-namespace/_expected/amd/m2.js index 22e08de419f..098da5f2a56 100644 --- a/test/chunking-form/samples/preserve-modules-dynamic-namespace/_expected/amd/m2.js +++ b/test/chunking-form/samples/preserve-modules-dynamic-namespace/_expected/amd/m2.js @@ -1,7 +1,7 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; var m2 = {a:1}; return m2; -}); +})); diff --git a/test/chunking-form/samples/preserve-modules-dynamic-namespace/_expected/amd/m3.js b/test/chunking-form/samples/preserve-modules-dynamic-namespace/_expected/amd/m3.js index 685448b54a5..54273ec86e7 100644 --- a/test/chunking-form/samples/preserve-modules-dynamic-namespace/_expected/amd/m3.js +++ b/test/chunking-form/samples/preserve-modules-dynamic-namespace/_expected/amd/m3.js @@ -1,7 +1,7 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; var m3 = {b:2}; return m3; -}); +})); diff --git a/test/chunking-form/samples/preserve-modules-dynamic-namespace/_expected/amd/main.js b/test/chunking-form/samples/preserve-modules-dynamic-namespace/_expected/amd/main.js index b73da45ad1d..46411907b40 100644 --- a/test/chunking-form/samples/preserve-modules-dynamic-namespace/_expected/amd/main.js +++ b/test/chunking-form/samples/preserve-modules-dynamic-namespace/_expected/amd/main.js @@ -1,5 +1,5 @@ -define(['./m1'], function (m1) { 'use strict'; +define(['./m1'], (function (m1) { 'use strict'; console.log(m1); -}); +})); diff --git a/test/chunking-form/samples/preserve-modules-dynamic-namespace/_expected/cjs/m1.js b/test/chunking-form/samples/preserve-modules-dynamic-namespace/_expected/cjs/m1.js index 2dcf78656c6..bd9f1e27347 100644 --- a/test/chunking-form/samples/preserve-modules-dynamic-namespace/_expected/cjs/m1.js +++ b/test/chunking-form/samples/preserve-modules-dynamic-namespace/_expected/cjs/m1.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - var m2 = require('./m2.js'); var m3 = require('./m3.js'); diff --git a/test/chunking-form/samples/preserve-modules-dynamic-namespace/_expected/es/m2.js b/test/chunking-form/samples/preserve-modules-dynamic-namespace/_expected/es/m2.js index 0ee68395af0..2e316b8ff07 100644 --- a/test/chunking-form/samples/preserve-modules-dynamic-namespace/_expected/es/m2.js +++ b/test/chunking-form/samples/preserve-modules-dynamic-namespace/_expected/es/m2.js @@ -1,3 +1,3 @@ var m2 = {a:1}; -export default m2; +export { m2 as default }; diff --git a/test/chunking-form/samples/preserve-modules-dynamic-namespace/_expected/es/m3.js b/test/chunking-form/samples/preserve-modules-dynamic-namespace/_expected/es/m3.js index 0d65aa10bb9..4e4d52f9878 100644 --- a/test/chunking-form/samples/preserve-modules-dynamic-namespace/_expected/es/m3.js +++ b/test/chunking-form/samples/preserve-modules-dynamic-namespace/_expected/es/m3.js @@ -1,3 +1,3 @@ var m3 = {b:2}; -export default m3; +export { m3 as default }; diff --git a/test/chunking-form/samples/preserve-modules-dynamic-namespace/_expected/system/m1.js b/test/chunking-form/samples/preserve-modules-dynamic-namespace/_expected/system/m1.js index 9f2d67db2a9..ae4e9bfd01d 100644 --- a/test/chunking-form/samples/preserve-modules-dynamic-namespace/_expected/system/m1.js +++ b/test/chunking-form/samples/preserve-modules-dynamic-namespace/_expected/system/m1.js @@ -1,15 +1,15 @@ -System.register(['./m2.js', './m3.js'], function (exports) { +System.register(['./m2.js', './m3.js'], (function (exports) { 'use strict'; return { setters: [function (module) { - exports('m2', module.default); + exports("m2", module.default); }, function (module) { - exports('m3', module.default); + exports("m3", module.default); }], - execute: function () { + execute: (function () { - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/preserve-modules-dynamic-namespace/_expected/system/m2.js b/test/chunking-form/samples/preserve-modules-dynamic-namespace/_expected/system/m2.js index d724fa35251..29c9a5fad13 100644 --- a/test/chunking-form/samples/preserve-modules-dynamic-namespace/_expected/system/m2.js +++ b/test/chunking-form/samples/preserve-modules-dynamic-namespace/_expected/system/m2.js @@ -1,10 +1,10 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - var m2 = exports('default', {a:1}); + var m2 = exports("default", {a:1}); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/preserve-modules-dynamic-namespace/_expected/system/m3.js b/test/chunking-form/samples/preserve-modules-dynamic-namespace/_expected/system/m3.js index 1181b9a04ec..e9c83daf2ea 100644 --- a/test/chunking-form/samples/preserve-modules-dynamic-namespace/_expected/system/m3.js +++ b/test/chunking-form/samples/preserve-modules-dynamic-namespace/_expected/system/m3.js @@ -1,10 +1,10 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - var m3 = exports('default', {b:2}); + var m3 = exports("default", {b:2}); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/preserve-modules-dynamic-namespace/_expected/system/main.js b/test/chunking-form/samples/preserve-modules-dynamic-namespace/_expected/system/main.js index 8ee4b05a8af..2055d1533cc 100644 --- a/test/chunking-form/samples/preserve-modules-dynamic-namespace/_expected/system/main.js +++ b/test/chunking-form/samples/preserve-modules-dynamic-namespace/_expected/system/main.js @@ -1,14 +1,14 @@ -System.register(['./m1.js'], function () { +System.register(['./m1.js'], (function () { 'use strict'; var m1; return { setters: [function (module) { m1 = module; }], - execute: function () { + execute: (function () { console.log(m1); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/preserve-modules-empty/_config.js b/test/chunking-form/samples/preserve-modules-empty/_config.js index 7b9d517b336..1e169c004f9 100644 --- a/test/chunking-form/samples/preserve-modules-empty/_config.js +++ b/test/chunking-form/samples/preserve-modules-empty/_config.js @@ -1,7 +1,7 @@ -module.exports = { +module.exports = defineTest({ description: 'Preserve modules remove empty dependencies', options: { input: 'main.js', output: { preserveModules: true } } -}; +}); diff --git a/test/chunking-form/samples/preserve-modules-empty/_expected/amd/main.js b/test/chunking-form/samples/preserve-modules-empty/_expected/amd/main.js index 6fd312fad67..a52a88cf67e 100644 --- a/test/chunking-form/samples/preserve-modules-empty/_expected/amd/main.js +++ b/test/chunking-form/samples/preserve-modules-empty/_expected/amd/main.js @@ -1,5 +1,5 @@ -define(['./two'], function (two) { 'use strict'; +define(['./two'], (function (two) { 'use strict'; window.APP = { a: two }; -}); +})); diff --git a/test/chunking-form/samples/preserve-modules-empty/_expected/amd/two.js b/test/chunking-form/samples/preserve-modules-empty/_expected/amd/two.js index 68dcf822ab8..813004c18ee 100644 --- a/test/chunking-form/samples/preserve-modules-empty/_expected/amd/two.js +++ b/test/chunking-form/samples/preserve-modules-empty/_expected/amd/two.js @@ -1,7 +1,7 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; var a = {}; return a; -}); +})); diff --git a/test/chunking-form/samples/preserve-modules-empty/_expected/es/two.js b/test/chunking-form/samples/preserve-modules-empty/_expected/es/two.js index 0938a073152..2c1648548f6 100644 --- a/test/chunking-form/samples/preserve-modules-empty/_expected/es/two.js +++ b/test/chunking-form/samples/preserve-modules-empty/_expected/es/two.js @@ -1,3 +1,3 @@ var a = {}; -export default a; +export { a as default }; diff --git a/test/chunking-form/samples/preserve-modules-empty/_expected/system/main.js b/test/chunking-form/samples/preserve-modules-empty/_expected/system/main.js index b0664a8cd59..1d72392b699 100644 --- a/test/chunking-form/samples/preserve-modules-empty/_expected/system/main.js +++ b/test/chunking-form/samples/preserve-modules-empty/_expected/system/main.js @@ -1,14 +1,14 @@ -System.register(['./two.js'], function () { +System.register(['./two.js'], (function () { 'use strict'; var a; return { setters: [function (module) { a = module.default; }], - execute: function () { + execute: (function () { window.APP = { a }; - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/preserve-modules-empty/_expected/system/two.js b/test/chunking-form/samples/preserve-modules-empty/_expected/system/two.js index 015fc0193bb..6e170ad6446 100644 --- a/test/chunking-form/samples/preserve-modules-empty/_expected/system/two.js +++ b/test/chunking-form/samples/preserve-modules-empty/_expected/system/two.js @@ -1,10 +1,10 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - var a = exports('default', {}); + var a = exports("default", {}); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/preserve-modules-export-alias/_config.js b/test/chunking-form/samples/preserve-modules-export-alias/_config.js index 9c422ba3d6d..e85d07a9b9e 100644 --- a/test/chunking-form/samples/preserve-modules-export-alias/_config.js +++ b/test/chunking-form/samples/preserve-modules-export-alias/_config.js @@ -1,7 +1,7 @@ -module.exports = { +module.exports = defineTest({ description: 'confirm export aliases are preserved in modules', options: { input: ['main1.js', 'main2.js'], output: { preserveModules: true } } -}; +}); diff --git a/test/chunking-form/samples/preserve-modules-export-alias/_expected/amd/dep.js b/test/chunking-form/samples/preserve-modules-export-alias/_expected/amd/dep.js index cab959ad2ca..42ccc5f1207 100644 --- a/test/chunking-form/samples/preserve-modules-export-alias/_expected/amd/dep.js +++ b/test/chunking-form/samples/preserve-modules-export-alias/_expected/amd/dep.js @@ -1,10 +1,8 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; const foo = 1; exports.bar = foo; exports.foo = foo; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/preserve-modules-export-alias/_expected/amd/main1.js b/test/chunking-form/samples/preserve-modules-export-alias/_expected/amd/main1.js index 4c30c2b8f1e..eacb7bcd214 100644 --- a/test/chunking-form/samples/preserve-modules-export-alias/_expected/amd/main1.js +++ b/test/chunking-form/samples/preserve-modules-export-alias/_expected/amd/main1.js @@ -1,10 +1,8 @@ -define(['exports', './dep'], function (exports, dep) { 'use strict'; +define(['exports', './dep'], (function (exports, dep) { 'use strict'; - exports.bar = dep.foo; - exports.foo = dep.foo; + exports.bar = dep.bar; + exports.foo = dep.bar; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/preserve-modules-export-alias/_expected/amd/main2.js b/test/chunking-form/samples/preserve-modules-export-alias/_expected/amd/main2.js index 0d4dfce05b3..977b6550d99 100644 --- a/test/chunking-form/samples/preserve-modules-export-alias/_expected/amd/main2.js +++ b/test/chunking-form/samples/preserve-modules-export-alias/_expected/amd/main2.js @@ -1,9 +1,7 @@ -define(['exports', './dep'], function (exports, dep) { 'use strict'; +define(['exports', './dep'], (function (exports, dep) { 'use strict'; - exports.bar = dep.foo; + exports.bar = dep.bar; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/preserve-modules-export-alias/_expected/cjs/dep.js b/test/chunking-form/samples/preserve-modules-export-alias/_expected/cjs/dep.js index 7bf4532c451..ce2fd9a6532 100644 --- a/test/chunking-form/samples/preserve-modules-export-alias/_expected/cjs/dep.js +++ b/test/chunking-form/samples/preserve-modules-export-alias/_expected/cjs/dep.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - const foo = 1; exports.bar = foo; diff --git a/test/chunking-form/samples/preserve-modules-export-alias/_expected/cjs/main1.js b/test/chunking-form/samples/preserve-modules-export-alias/_expected/cjs/main1.js index 801c4e75c53..a63e6d0d40c 100644 --- a/test/chunking-form/samples/preserve-modules-export-alias/_expected/cjs/main1.js +++ b/test/chunking-form/samples/preserve-modules-export-alias/_expected/cjs/main1.js @@ -1,10 +1,8 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - var dep = require('./dep.js'); -exports.bar = dep.foo; -exports.foo = dep.foo; +exports.bar = dep.bar; +exports.foo = dep.bar; diff --git a/test/chunking-form/samples/preserve-modules-export-alias/_expected/cjs/main2.js b/test/chunking-form/samples/preserve-modules-export-alias/_expected/cjs/main2.js index 1c1f62cd337..f19d81f4bdc 100644 --- a/test/chunking-form/samples/preserve-modules-export-alias/_expected/cjs/main2.js +++ b/test/chunking-form/samples/preserve-modules-export-alias/_expected/cjs/main2.js @@ -1,9 +1,7 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - var dep = require('./dep.js'); -exports.bar = dep.foo; +exports.bar = dep.bar; diff --git a/test/chunking-form/samples/preserve-modules-export-alias/_expected/es/main1.js b/test/chunking-form/samples/preserve-modules-export-alias/_expected/es/main1.js index ed1ba0cbfbb..b06f05ac1e3 100644 --- a/test/chunking-form/samples/preserve-modules-export-alias/_expected/es/main1.js +++ b/test/chunking-form/samples/preserve-modules-export-alias/_expected/es/main1.js @@ -1 +1 @@ -export { foo as bar, foo } from './dep.js'; +export { bar, bar as foo } from './dep.js'; diff --git a/test/chunking-form/samples/preserve-modules-export-alias/_expected/es/main2.js b/test/chunking-form/samples/preserve-modules-export-alias/_expected/es/main2.js index e7cedc5ee48..833d229ec37 100644 --- a/test/chunking-form/samples/preserve-modules-export-alias/_expected/es/main2.js +++ b/test/chunking-form/samples/preserve-modules-export-alias/_expected/es/main2.js @@ -1 +1 @@ -export { foo as bar } from './dep.js'; +export { bar } from './dep.js'; diff --git a/test/chunking-form/samples/preserve-modules-export-alias/_expected/system/dep.js b/test/chunking-form/samples/preserve-modules-export-alias/_expected/system/dep.js index 850241b9ad6..ffbc3b2280d 100644 --- a/test/chunking-form/samples/preserve-modules-export-alias/_expected/system/dep.js +++ b/test/chunking-form/samples/preserve-modules-export-alias/_expected/system/dep.js @@ -1,10 +1,10 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - const foo = function (v) { return exports({ foo: v, bar: v }), v; }(1); + const foo = 1; exports({ bar: foo, foo: foo }); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/preserve-modules-export-alias/_expected/system/main1.js b/test/chunking-form/samples/preserve-modules-export-alias/_expected/system/main1.js index bfffe939f7a..51fe708ffd3 100644 --- a/test/chunking-form/samples/preserve-modules-export-alias/_expected/system/main1.js +++ b/test/chunking-form/samples/preserve-modules-export-alias/_expected/system/main1.js @@ -1,16 +1,13 @@ -System.register(['./dep.js'], function (exports) { +System.register(['./dep.js'], (function (exports) { 'use strict'; return { setters: [function (module) { - var _setter = {}; - _setter.bar = module.foo; - _setter.foo = module.foo; - exports(_setter); + exports({ bar: module.bar, foo: module.bar }); }], - execute: function () { + execute: (function () { - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/preserve-modules-export-alias/_expected/system/main2.js b/test/chunking-form/samples/preserve-modules-export-alias/_expected/system/main2.js index d995245e8f6..d63b9b580bb 100644 --- a/test/chunking-form/samples/preserve-modules-export-alias/_expected/system/main2.js +++ b/test/chunking-form/samples/preserve-modules-export-alias/_expected/system/main2.js @@ -1,13 +1,13 @@ -System.register(['./dep.js'], function (exports) { +System.register(['./dep.js'], (function (exports) { 'use strict'; return { setters: [function (module) { - exports('bar', module.foo); + exports("bar", module.bar); }], - execute: function () { + execute: (function () { - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/preserve-modules-filename-pattern/_config.js b/test/chunking-form/samples/preserve-modules-filename-pattern/_config.js index f8e36cb7cbd..798beadfb1f 100644 --- a/test/chunking-form/samples/preserve-modules-filename-pattern/_config.js +++ b/test/chunking-form/samples/preserve-modules-filename-pattern/_config.js @@ -1,10 +1,44 @@ -module.exports = { +const assert = require('node:assert'); +const path = require('node:path'); + +const expectedNames = new Set([ + 'nested/a', + 'b.str', + 'c', + 'd', + 'e', + 'f', + 'g', + 'h', + 'main', + 'no-ext' +]); + +module.exports = defineTest({ description: 'entryFileNames pattern supported in combination with preserveModules', options: { - input: 'src/main.ts', + input: 'src/main.js', output: { - entryFileNames: 'entry-[name]-[format]-[ext][extname].js', + entryFileNames({ name }) { + assert.ok(expectedNames.has(name), `Unexpected name ${name}.`); + return '[name]-[format]-[hash].js'; + }, preserveModules: true - } + }, + plugins: [ + { + name: 'str-plugin', + transform(code, id) { + switch (path.extname(id)) { + case '.str': { + return { code: `export default "${code.trim()}"` }; + } + default: { + return null; + } + } + } + } + ] } -}; +}); diff --git a/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/amd/b.str-amd-DF7A0kMb.js b/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/amd/b.str-amd-DF7A0kMb.js new file mode 100644 index 00000000000..a2cb4560512 --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/amd/b.str-amd-DF7A0kMb.js @@ -0,0 +1,7 @@ +define((function () { 'use strict'; + + var b = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."; + + return b; + +})); diff --git a/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/amd/c-amd-Dx6wblfB.js b/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/amd/c-amd-Dx6wblfB.js new file mode 100644 index 00000000000..ecde41797bb --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/amd/c-amd-Dx6wblfB.js @@ -0,0 +1,7 @@ +define((function () { 'use strict'; + + var c = 42; + + return c; + +})); diff --git a/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/amd/d-amd-D-AkRk0H.js b/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/amd/d-amd-D-AkRk0H.js new file mode 100644 index 00000000000..31034cc71fa --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/amd/d-amd-D-AkRk0H.js @@ -0,0 +1,7 @@ +define((function () { 'use strict'; + + var d = 42; + + return d; + +})); diff --git a/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/amd/e-amd-CzsEaS33.js b/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/amd/e-amd-CzsEaS33.js new file mode 100644 index 00000000000..48384a4d534 --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/amd/e-amd-CzsEaS33.js @@ -0,0 +1,7 @@ +define((function () { 'use strict'; + + var e = 42; + + return e; + +})); diff --git a/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/amd/entry-foo-amd-ts.ts.js b/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/amd/entry-foo-amd-ts.ts.js deleted file mode 100644 index 2bc02b35588..00000000000 --- a/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/amd/entry-foo-amd-ts.ts.js +++ /dev/null @@ -1,7 +0,0 @@ -define(function () { 'use strict'; - - var foo = 42; - - return foo; - -}); diff --git a/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/amd/entry-main-amd-ts.ts.js b/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/amd/entry-main-amd-ts.ts.js deleted file mode 100644 index 1018355bd77..00000000000 --- a/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/amd/entry-main-amd-ts.ts.js +++ /dev/null @@ -1,12 +0,0 @@ -define(['exports', './entry-foo-amd-ts.ts', './nested/entry-bar-amd-ts.ts', './nested/entry-baz-amd-ts.ts', './entry-no-ext-amd-'], function (exports, foo, bar, baz, noExt) { 'use strict'; - - - - exports.foo = foo; - exports.bar = bar; - exports.baz = baz; - exports.noExt = noExt; - - Object.defineProperty(exports, '__esModule', { value: true }); - -}); diff --git a/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/amd/entry-no-ext-amd-.js b/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/amd/entry-no-ext-amd-.js deleted file mode 100644 index 8e2da77223e..00000000000 --- a/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/amd/entry-no-ext-amd-.js +++ /dev/null @@ -1,7 +0,0 @@ -define(function () { 'use strict'; - - var noExt = 'no-ext'; - - return noExt; - -}); diff --git a/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/amd/f-amd-BmQk4H5I.js b/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/amd/f-amd-BmQk4H5I.js new file mode 100644 index 00000000000..40a885c45dd --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/amd/f-amd-BmQk4H5I.js @@ -0,0 +1,7 @@ +define((function () { 'use strict'; + + var f = 42; + + return f; + +})); diff --git a/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/amd/g-amd-BWU4b_ZQ.js b/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/amd/g-amd-BWU4b_ZQ.js new file mode 100644 index 00000000000..0b90b0dd1e2 --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/amd/g-amd-BWU4b_ZQ.js @@ -0,0 +1,7 @@ +define((function () { 'use strict'; + + var g = 42; + + return g; + +})); diff --git a/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/amd/h-amd-BHKDy5vy.js b/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/amd/h-amd-BHKDy5vy.js new file mode 100644 index 00000000000..6c3c1958ff7 --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/amd/h-amd-BHKDy5vy.js @@ -0,0 +1,7 @@ +define((function () { 'use strict'; + + var h = 42; + + return h; + +})); diff --git a/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/amd/main-amd-CyX39dyD.js b/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/amd/main-amd-CyX39dyD.js new file mode 100644 index 00000000000..00107fd187a --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/amd/main-amd-CyX39dyD.js @@ -0,0 +1,15 @@ +define(['exports', './nested/a-amd-DtRZNXzf', './b.str-amd-DF7A0kMb', './c-amd-Dx6wblfB', './d-amd-D-AkRk0H', './e-amd-CzsEaS33', './f-amd-BmQk4H5I', './g-amd-BWU4b_ZQ', './h-amd-BHKDy5vy', './no-ext-amd-Dpy8IO7f'], (function (exports, a, b, c, d, e, f, g, h, noExt) { 'use strict'; + + + + exports.a = a; + exports.b = b; + exports.c = c; + exports.d = d; + exports.e = e; + exports.f = f; + exports.g = g; + exports.h = h; + exports.x = noExt; + +})); diff --git a/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/amd/nested/a-amd-DtRZNXzf.js b/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/amd/nested/a-amd-DtRZNXzf.js new file mode 100644 index 00000000000..b71fcc65956 --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/amd/nested/a-amd-DtRZNXzf.js @@ -0,0 +1,7 @@ +define((function () { 'use strict'; + + var a = 'banana'; + + return a; + +})); diff --git a/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/amd/nested/entry-bar-amd-ts.ts.js b/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/amd/nested/entry-bar-amd-ts.ts.js deleted file mode 100644 index cb3bfcd5d1d..00000000000 --- a/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/amd/nested/entry-bar-amd-ts.ts.js +++ /dev/null @@ -1,7 +0,0 @@ -define(function () { 'use strict'; - - var bar = 'banana'; - - return bar; - -}); diff --git a/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/amd/nested/entry-baz-amd-ts.ts.js b/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/amd/nested/entry-baz-amd-ts.ts.js deleted file mode 100644 index 35018f30618..00000000000 --- a/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/amd/nested/entry-baz-amd-ts.ts.js +++ /dev/null @@ -1,7 +0,0 @@ -define(function () { 'use strict'; - - var baz = 'whatever'; - - return baz; - -}); diff --git a/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/amd/no-ext-amd-Dpy8IO7f.js b/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/amd/no-ext-amd-Dpy8IO7f.js new file mode 100644 index 00000000000..4d9b6f89602 --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/amd/no-ext-amd-Dpy8IO7f.js @@ -0,0 +1,7 @@ +define((function () { 'use strict'; + + var noExt = 'no-ext'; + + return noExt; + +})); diff --git a/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/cjs/b.str-cjs-BS5lKJ39.js b/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/cjs/b.str-cjs-BS5lKJ39.js new file mode 100644 index 00000000000..d10c6f206a8 --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/cjs/b.str-cjs-BS5lKJ39.js @@ -0,0 +1,5 @@ +'use strict'; + +var b = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."; + +module.exports = b; diff --git a/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/cjs/c-cjs-BR0xAsc5.js b/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/cjs/c-cjs-BR0xAsc5.js new file mode 100644 index 00000000000..e420a593611 --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/cjs/c-cjs-BR0xAsc5.js @@ -0,0 +1,5 @@ +'use strict'; + +var c = 42; + +module.exports = c; diff --git a/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/cjs/d-cjs-C8q7hg53.js b/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/cjs/d-cjs-C8q7hg53.js new file mode 100644 index 00000000000..ed89c1ca8fd --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/cjs/d-cjs-C8q7hg53.js @@ -0,0 +1,5 @@ +'use strict'; + +var d = 42; + +module.exports = d; diff --git a/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/cjs/e-cjs-bNQwZe-W.js b/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/cjs/e-cjs-bNQwZe-W.js new file mode 100644 index 00000000000..3f277409ebd --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/cjs/e-cjs-bNQwZe-W.js @@ -0,0 +1,5 @@ +'use strict'; + +var e = 42; + +module.exports = e; diff --git a/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/cjs/entry-foo-cjs-ts.ts.js b/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/cjs/entry-foo-cjs-ts.ts.js deleted file mode 100644 index 476c8ac92d3..00000000000 --- a/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/cjs/entry-foo-cjs-ts.ts.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -var foo = 42; - -module.exports = foo; diff --git a/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/cjs/entry-main-cjs-ts.ts.js b/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/cjs/entry-main-cjs-ts.ts.js deleted file mode 100644 index aff83e1b5d2..00000000000 --- a/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/cjs/entry-main-cjs-ts.ts.js +++ /dev/null @@ -1,15 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { value: true }); - -var foo = require('./entry-foo-cjs-ts.ts.js'); -var bar = require('./nested/entry-bar-cjs-ts.ts.js'); -var baz = require('./nested/entry-baz-cjs-ts.ts.js'); -var noExt = require('./entry-no-ext-cjs-.js'); - - - -exports.foo = foo; -exports.bar = bar; -exports.baz = baz; -exports.noExt = noExt; diff --git a/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/cjs/entry-no-ext-cjs-.js b/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/cjs/entry-no-ext-cjs-.js deleted file mode 100644 index 5e9e9eb2cb5..00000000000 --- a/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/cjs/entry-no-ext-cjs-.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -var noExt = 'no-ext'; - -module.exports = noExt; diff --git a/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/cjs/f-cjs-C1wIZHEU.js b/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/cjs/f-cjs-C1wIZHEU.js new file mode 100644 index 00000000000..ea9880943de --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/cjs/f-cjs-C1wIZHEU.js @@ -0,0 +1,5 @@ +'use strict'; + +var f = 42; + +module.exports = f; diff --git a/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/cjs/g-cjs-GDJ2GCjN.js b/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/cjs/g-cjs-GDJ2GCjN.js new file mode 100644 index 00000000000..c4db5bc9fb5 --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/cjs/g-cjs-GDJ2GCjN.js @@ -0,0 +1,5 @@ +'use strict'; + +var g = 42; + +module.exports = g; diff --git a/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/cjs/h-cjs-047ra2yr.js b/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/cjs/h-cjs-047ra2yr.js new file mode 100644 index 00000000000..3b130d05726 --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/cjs/h-cjs-047ra2yr.js @@ -0,0 +1,5 @@ +'use strict'; + +var h = 42; + +module.exports = h; diff --git a/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/cjs/main-cjs-BqXS_zT0.js b/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/cjs/main-cjs-BqXS_zT0.js new file mode 100644 index 00000000000..49504b0d4f4 --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/cjs/main-cjs-BqXS_zT0.js @@ -0,0 +1,23 @@ +'use strict'; + +var a = require('./nested/a-cjs-C_nfDF22.js'); +var b = require('./b.str-cjs-BS5lKJ39.js'); +var c = require('./c-cjs-BR0xAsc5.js'); +var d = require('./d-cjs-C8q7hg53.js'); +var e = require('./e-cjs-bNQwZe-W.js'); +var f = require('./f-cjs-C1wIZHEU.js'); +var g = require('./g-cjs-GDJ2GCjN.js'); +var h = require('./h-cjs-047ra2yr.js'); +var noExt = require('./no-ext-cjs-BGwLFM9Z.js'); + + + +exports.a = a; +exports.b = b; +exports.c = c; +exports.d = d; +exports.e = e; +exports.f = f; +exports.g = g; +exports.h = h; +exports.x = noExt; diff --git a/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/cjs/nested/a-cjs-C_nfDF22.js b/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/cjs/nested/a-cjs-C_nfDF22.js new file mode 100644 index 00000000000..30baa93901a --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/cjs/nested/a-cjs-C_nfDF22.js @@ -0,0 +1,5 @@ +'use strict'; + +var a = 'banana'; + +module.exports = a; diff --git a/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/cjs/nested/entry-bar-cjs-ts.ts.js b/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/cjs/nested/entry-bar-cjs-ts.ts.js deleted file mode 100644 index f8f56e6fc51..00000000000 --- a/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/cjs/nested/entry-bar-cjs-ts.ts.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -var bar = 'banana'; - -module.exports = bar; diff --git a/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/cjs/nested/entry-baz-cjs-ts.ts.js b/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/cjs/nested/entry-baz-cjs-ts.ts.js deleted file mode 100644 index 0ba506ad3eb..00000000000 --- a/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/cjs/nested/entry-baz-cjs-ts.ts.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -var baz = 'whatever'; - -module.exports = baz; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-filename-pattern/_expected/cjs/entry-no-ext-cjs-.js b/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/cjs/no-ext-cjs-BGwLFM9Z.js similarity index 100% rename from test/chunking-form/samples/deprecated/preserve-modules-filename-pattern/_expected/cjs/entry-no-ext-cjs-.js rename to test/chunking-form/samples/preserve-modules-filename-pattern/_expected/cjs/no-ext-cjs-BGwLFM9Z.js diff --git a/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/es/b.str-es-Gs0GwhVF.js b/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/es/b.str-es-Gs0GwhVF.js new file mode 100644 index 00000000000..1242cee6cd0 --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/es/b.str-es-Gs0GwhVF.js @@ -0,0 +1,3 @@ +var b = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."; + +export { b as default }; diff --git a/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/es/c-es-ZYTOn0Eh.js b/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/es/c-es-ZYTOn0Eh.js new file mode 100644 index 00000000000..e863eed1725 --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/es/c-es-ZYTOn0Eh.js @@ -0,0 +1,3 @@ +var c = 42; + +export { c as default }; diff --git a/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/es/d-es-Dr4mq94c.js b/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/es/d-es-Dr4mq94c.js new file mode 100644 index 00000000000..7195f9fc80f --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/es/d-es-Dr4mq94c.js @@ -0,0 +1,3 @@ +var d = 42; + +export { d as default }; diff --git a/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/es/e-es-C2SWm0pY.js b/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/es/e-es-C2SWm0pY.js new file mode 100644 index 00000000000..b1d1efc9f45 --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/es/e-es-C2SWm0pY.js @@ -0,0 +1,3 @@ +var e = 42; + +export { e as default }; diff --git a/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/es/entry-foo-es-ts.ts.js b/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/es/entry-foo-es-ts.ts.js deleted file mode 100644 index 8ac2b2169a4..00000000000 --- a/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/es/entry-foo-es-ts.ts.js +++ /dev/null @@ -1,3 +0,0 @@ -var foo = 42; - -export default foo; diff --git a/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/es/entry-main-es-ts.ts.js b/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/es/entry-main-es-ts.ts.js deleted file mode 100644 index 341e9d48d9b..00000000000 --- a/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/es/entry-main-es-ts.ts.js +++ /dev/null @@ -1,4 +0,0 @@ -export { default as foo } from './entry-foo-es-ts.ts.js'; -export { default as bar } from './nested/entry-bar-es-ts.ts.js'; -export { default as baz } from './nested/entry-baz-es-ts.ts.js'; -export { default as noExt } from './entry-no-ext-es-.js'; diff --git a/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/es/entry-no-ext-es-.js b/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/es/entry-no-ext-es-.js deleted file mode 100644 index e630b7b5e9d..00000000000 --- a/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/es/entry-no-ext-es-.js +++ /dev/null @@ -1,3 +0,0 @@ -var noExt = 'no-ext'; - -export default noExt; diff --git a/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/es/f-es-Bm_ir2Io.js b/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/es/f-es-Bm_ir2Io.js new file mode 100644 index 00000000000..82ad55c5fd6 --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/es/f-es-Bm_ir2Io.js @@ -0,0 +1,3 @@ +var f = 42; + +export { f as default }; diff --git a/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/es/g-es-BbU0foyF.js b/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/es/g-es-BbU0foyF.js new file mode 100644 index 00000000000..78334adafcd --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/es/g-es-BbU0foyF.js @@ -0,0 +1,3 @@ +var g = 42; + +export { g as default }; diff --git a/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/es/h-es-DwzmIMUF.js b/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/es/h-es-DwzmIMUF.js new file mode 100644 index 00000000000..8bbc4352412 --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/es/h-es-DwzmIMUF.js @@ -0,0 +1,3 @@ +var h = 42; + +export { h as default }; diff --git a/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/es/main-es-CMLd0Z43.js b/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/es/main-es-CMLd0Z43.js new file mode 100644 index 00000000000..05f16734f37 --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/es/main-es-CMLd0Z43.js @@ -0,0 +1,9 @@ +export { default as a } from './nested/a-es-GMZjp5vx.js'; +export { default as b } from './b.str-es-Gs0GwhVF.js'; +export { default as c } from './c-es-ZYTOn0Eh.js'; +export { default as d } from './d-es-Dr4mq94c.js'; +export { default as e } from './e-es-C2SWm0pY.js'; +export { default as f } from './f-es-Bm_ir2Io.js'; +export { default as g } from './g-es-BbU0foyF.js'; +export { default as h } from './h-es-DwzmIMUF.js'; +export { default as x } from './no-ext-es-aP4Nui9G.js'; diff --git a/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/es/nested/a-es-GMZjp5vx.js b/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/es/nested/a-es-GMZjp5vx.js new file mode 100644 index 00000000000..9767dacb2ec --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/es/nested/a-es-GMZjp5vx.js @@ -0,0 +1,3 @@ +var a = 'banana'; + +export { a as default }; diff --git a/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/es/nested/entry-bar-es-ts.ts.js b/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/es/nested/entry-bar-es-ts.ts.js deleted file mode 100644 index bbf65d4599d..00000000000 --- a/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/es/nested/entry-bar-es-ts.ts.js +++ /dev/null @@ -1,3 +0,0 @@ -var bar = 'banana'; - -export default bar; diff --git a/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/es/nested/entry-baz-es-ts.ts.js b/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/es/nested/entry-baz-es-ts.ts.js deleted file mode 100644 index 03a3023d32b..00000000000 --- a/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/es/nested/entry-baz-es-ts.ts.js +++ /dev/null @@ -1,3 +0,0 @@ -var baz = 'whatever'; - -export default baz; diff --git a/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/es/no-ext-es-aP4Nui9G.js b/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/es/no-ext-es-aP4Nui9G.js new file mode 100644 index 00000000000..ae037040be2 --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/es/no-ext-es-aP4Nui9G.js @@ -0,0 +1,3 @@ +var noExt = 'no-ext'; + +export { noExt as default }; diff --git a/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/system/b.str-system-Bdh1JWaH.js b/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/system/b.str-system-Bdh1JWaH.js new file mode 100644 index 00000000000..0afc1109b06 --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/system/b.str-system-Bdh1JWaH.js @@ -0,0 +1,10 @@ +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + + var b = exports("default", "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."); + + }) + }; +})); diff --git a/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/system/c-system-CfMXlo_7.js b/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/system/c-system-CfMXlo_7.js new file mode 100644 index 00000000000..895e4b299e0 --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/system/c-system-CfMXlo_7.js @@ -0,0 +1,10 @@ +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + + var c = exports("default", 42); + + }) + }; +})); diff --git a/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/system/d-system-CjBJ6c43.js b/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/system/d-system-CjBJ6c43.js new file mode 100644 index 00000000000..9b5d953a918 --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/system/d-system-CjBJ6c43.js @@ -0,0 +1,10 @@ +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + + var d = exports("default", 42); + + }) + }; +})); diff --git a/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/system/e-system-kCTp4Cbh.js b/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/system/e-system-kCTp4Cbh.js new file mode 100644 index 00000000000..3eaaa6eb979 --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/system/e-system-kCTp4Cbh.js @@ -0,0 +1,10 @@ +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + + var e = exports("default", 42); + + }) + }; +})); diff --git a/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/system/entry-foo-system-ts.ts.js b/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/system/entry-foo-system-ts.ts.js deleted file mode 100644 index 81b45b772a8..00000000000 --- a/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/system/entry-foo-system-ts.ts.js +++ /dev/null @@ -1,10 +0,0 @@ -System.register([], function (exports) { - 'use strict'; - return { - execute: function () { - - var foo = exports('default', 42); - - } - }; -}); diff --git a/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/system/entry-main-system-ts.ts.js b/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/system/entry-main-system-ts.ts.js deleted file mode 100644 index 22b35a8d704..00000000000 --- a/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/system/entry-main-system-ts.ts.js +++ /dev/null @@ -1,19 +0,0 @@ -System.register(['./entry-foo-system-ts.ts.js', './nested/entry-bar-system-ts.ts.js', './nested/entry-baz-system-ts.ts.js', './entry-no-ext-system-.js'], function (exports) { - 'use strict'; - return { - setters: [function (module) { - exports('foo', module.default); - }, function (module) { - exports('bar', module.default); - }, function (module) { - exports('baz', module.default); - }, function (module) { - exports('noExt', module.default); - }], - execute: function () { - - - - } - }; -}); diff --git a/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/system/entry-no-ext-system-.js b/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/system/entry-no-ext-system-.js deleted file mode 100644 index 91546e66d5b..00000000000 --- a/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/system/entry-no-ext-system-.js +++ /dev/null @@ -1,10 +0,0 @@ -System.register([], function (exports) { - 'use strict'; - return { - execute: function () { - - var noExt = exports('default', 'no-ext'); - - } - }; -}); diff --git a/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/system/f-system-0MCeGExm.js b/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/system/f-system-0MCeGExm.js new file mode 100644 index 00000000000..d7ce1cfafb1 --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/system/f-system-0MCeGExm.js @@ -0,0 +1,10 @@ +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + + var f = exports("default", 42); + + }) + }; +})); diff --git a/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/system/g-system-BOKAS6Fy.js b/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/system/g-system-BOKAS6Fy.js new file mode 100644 index 00000000000..bc6539c9892 --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/system/g-system-BOKAS6Fy.js @@ -0,0 +1,10 @@ +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + + var g = exports("default", 42); + + }) + }; +})); diff --git a/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/system/h-system-BDND_AXe.js b/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/system/h-system-BDND_AXe.js new file mode 100644 index 00000000000..08ed707aaef --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/system/h-system-BDND_AXe.js @@ -0,0 +1,10 @@ +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + + var h = exports("default", 42); + + }) + }; +})); diff --git a/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/system/main-system-D680kXvc.js b/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/system/main-system-D680kXvc.js new file mode 100644 index 00000000000..32f063beec8 --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/system/main-system-D680kXvc.js @@ -0,0 +1,29 @@ +System.register(['./nested/a-system-C0NakMeD.js', './b.str-system-Bdh1JWaH.js', './c-system-CfMXlo_7.js', './d-system-CjBJ6c43.js', './e-system-kCTp4Cbh.js', './f-system-0MCeGExm.js', './g-system-BOKAS6Fy.js', './h-system-BDND_AXe.js', './no-ext-system-DT8lOU6x.js'], (function (exports) { + 'use strict'; + return { + setters: [function (module) { + exports("a", module.default); + }, function (module) { + exports("b", module.default); + }, function (module) { + exports("c", module.default); + }, function (module) { + exports("d", module.default); + }, function (module) { + exports("e", module.default); + }, function (module) { + exports("f", module.default); + }, function (module) { + exports("g", module.default); + }, function (module) { + exports("h", module.default); + }, function (module) { + exports("x", module.default); + }], + execute: (function () { + + + + }) + }; +})); diff --git a/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/system/nested/a-system-C0NakMeD.js b/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/system/nested/a-system-C0NakMeD.js new file mode 100644 index 00000000000..0fe5cadfcf2 --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/system/nested/a-system-C0NakMeD.js @@ -0,0 +1,10 @@ +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + + var a = exports("default", 'banana'); + + }) + }; +})); diff --git a/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/system/nested/entry-bar-system-ts.ts.js b/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/system/nested/entry-bar-system-ts.ts.js deleted file mode 100644 index 5ef23f15879..00000000000 --- a/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/system/nested/entry-bar-system-ts.ts.js +++ /dev/null @@ -1,10 +0,0 @@ -System.register([], function (exports) { - 'use strict'; - return { - execute: function () { - - var bar = exports('default', 'banana'); - - } - }; -}); diff --git a/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/system/nested/entry-baz-system-ts.ts.js b/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/system/nested/entry-baz-system-ts.ts.js deleted file mode 100644 index a0526b56624..00000000000 --- a/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/system/nested/entry-baz-system-ts.ts.js +++ /dev/null @@ -1,10 +0,0 @@ -System.register([], function (exports) { - 'use strict'; - return { - execute: function () { - - var baz = exports('default', 'whatever'); - - } - }; -}); diff --git a/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/system/no-ext-system-DT8lOU6x.js b/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/system/no-ext-system-DT8lOU6x.js new file mode 100644 index 00000000000..70c25a85eca --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-filename-pattern/_expected/system/no-ext-system-DT8lOU6x.js @@ -0,0 +1,10 @@ +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + + var noExt = exports("default", 'no-ext'); + + }) + }; +})); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-scriptified-assets/src/lorem.str b/test/chunking-form/samples/preserve-modules-filename-pattern/src/b.str similarity index 100% rename from test/chunking-form/samples/deprecated/preserve-modules-scriptified-assets/src/lorem.str rename to test/chunking-form/samples/preserve-modules-filename-pattern/src/b.str diff --git a/test/chunking-form/samples/deprecated/emit-chunk/dep.js b/test/chunking-form/samples/preserve-modules-filename-pattern/src/c.mjs similarity index 100% rename from test/chunking-form/samples/deprecated/emit-chunk/dep.js rename to test/chunking-form/samples/preserve-modules-filename-pattern/src/c.mjs diff --git a/test/chunking-form/samples/deprecated/preserve-modules-filename-pattern/src/foo.ts b/test/chunking-form/samples/preserve-modules-filename-pattern/src/d.cjs similarity index 100% rename from test/chunking-form/samples/deprecated/preserve-modules-filename-pattern/src/foo.ts rename to test/chunking-form/samples/preserve-modules-filename-pattern/src/d.cjs diff --git a/test/chunking-form/samples/preserve-modules-filename-pattern/src/foo.ts b/test/chunking-form/samples/preserve-modules-filename-pattern/src/e.jsx similarity index 100% rename from test/chunking-form/samples/preserve-modules-filename-pattern/src/foo.ts rename to test/chunking-form/samples/preserve-modules-filename-pattern/src/e.jsx diff --git a/test/cli/samples/config-no-module/sub/main.js b/test/chunking-form/samples/preserve-modules-filename-pattern/src/f.mts similarity index 100% rename from test/cli/samples/config-no-module/sub/main.js rename to test/chunking-form/samples/preserve-modules-filename-pattern/src/f.mts diff --git a/test/function/samples/deprecated/manual-chunks-info/lib.js b/test/chunking-form/samples/preserve-modules-filename-pattern/src/g.cts similarity index 100% rename from test/function/samples/deprecated/manual-chunks-info/lib.js rename to test/chunking-form/samples/preserve-modules-filename-pattern/src/g.cts diff --git a/test/function/samples/deprecated/preserveModules/mixed-exports/lib2.js b/test/chunking-form/samples/preserve-modules-filename-pattern/src/h.tsx similarity index 100% rename from test/function/samples/deprecated/preserveModules/mixed-exports/lib2.js rename to test/chunking-form/samples/preserve-modules-filename-pattern/src/h.tsx diff --git a/test/chunking-form/samples/preserve-modules-filename-pattern/src/main.js b/test/chunking-form/samples/preserve-modules-filename-pattern/src/main.js new file mode 100644 index 00000000000..6b8f2a64281 --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-filename-pattern/src/main.js @@ -0,0 +1,9 @@ +export { default as a } from './nested/a.ts'; +export { default as b } from './b.str'; +export { default as c } from './c.mjs'; +export { default as d } from './d.cjs'; +export { default as e } from './e.jsx'; +export { default as f } from './f.mts'; +export { default as g } from './g.cts'; +export { default as h } from './h.tsx'; +export { default as x } from './no-ext'; diff --git a/test/chunking-form/samples/preserve-modules-filename-pattern/src/main.ts b/test/chunking-form/samples/preserve-modules-filename-pattern/src/main.ts deleted file mode 100644 index 3f169c8f476..00000000000 --- a/test/chunking-form/samples/preserve-modules-filename-pattern/src/main.ts +++ /dev/null @@ -1,8 +0,0 @@ -// @ts-ignore -export { default as foo } from './foo.ts'; -// @ts-ignore -export { default as bar } from './nested/bar.ts'; -// @ts-ignore -export { default as baz } from './nested/baz.ts'; -// @ts-ignore -export { default as noExt } from './no-ext'; diff --git a/test/chunking-form/samples/deprecated/preserve-modules-filename-pattern/src/nested/bar.ts b/test/chunking-form/samples/preserve-modules-filename-pattern/src/nested/a.ts similarity index 100% rename from test/chunking-form/samples/deprecated/preserve-modules-filename-pattern/src/nested/bar.ts rename to test/chunking-form/samples/preserve-modules-filename-pattern/src/nested/a.ts diff --git a/test/chunking-form/samples/preserve-modules-filename-pattern/src/nested/bar.ts b/test/chunking-form/samples/preserve-modules-filename-pattern/src/nested/bar.ts deleted file mode 100644 index 7d79d5a99a8..00000000000 --- a/test/chunking-form/samples/preserve-modules-filename-pattern/src/nested/bar.ts +++ /dev/null @@ -1 +0,0 @@ -export default 'banana'; diff --git a/test/chunking-form/samples/preserve-modules-filename-pattern/src/nested/baz.ts b/test/chunking-form/samples/preserve-modules-filename-pattern/src/nested/baz.ts deleted file mode 100644 index 6d70feca8ec..00000000000 --- a/test/chunking-form/samples/preserve-modules-filename-pattern/src/nested/baz.ts +++ /dev/null @@ -1 +0,0 @@ -export default 'whatever'; diff --git a/test/chunking-form/samples/preserve-modules-id-case-sensitive/_config.js b/test/chunking-form/samples/preserve-modules-id-case-sensitive/_config.js index 7650f6f19b0..ccdcb862f4b 100644 --- a/test/chunking-form/samples/preserve-modules-id-case-sensitive/_config.js +++ b/test/chunking-form/samples/preserve-modules-id-case-sensitive/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'Preserve modules id case sensitive', options: { input: 'main.js', @@ -18,4 +18,4 @@ module.exports = { } ] } -}; +}); diff --git a/test/chunking-form/samples/preserve-modules-id-case-sensitive/_expected/amd/_virtual/_One1.js b/test/chunking-form/samples/preserve-modules-id-case-sensitive/_expected/amd/_virtual/_One1.js index 0383829b24e..c6281aeed91 100644 --- a/test/chunking-form/samples/preserve-modules-id-case-sensitive/_expected/amd/_virtual/_One1.js +++ b/test/chunking-form/samples/preserve-modules-id-case-sensitive/_expected/amd/_virtual/_One1.js @@ -1,7 +1,7 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; var c = 'One1.js'; return c; -}); +})); diff --git a/test/chunking-form/samples/preserve-modules-id-case-sensitive/_expected/amd/_virtual/_One2.js b/test/chunking-form/samples/preserve-modules-id-case-sensitive/_expected/amd/_virtual/_One2.js index 1febaba2ef7..e34aacf5562 100644 --- a/test/chunking-form/samples/preserve-modules-id-case-sensitive/_expected/amd/_virtual/_One2.js +++ b/test/chunking-form/samples/preserve-modules-id-case-sensitive/_expected/amd/_virtual/_One2.js @@ -1,7 +1,7 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; var b = 'One.js'; return b; -}); +})); diff --git a/test/chunking-form/samples/preserve-modules-id-case-sensitive/_expected/amd/_virtual/_one.js b/test/chunking-form/samples/preserve-modules-id-case-sensitive/_expected/amd/_virtual/_one.js index 469b63f9f86..80666603e6e 100644 --- a/test/chunking-form/samples/preserve-modules-id-case-sensitive/_expected/amd/_virtual/_one.js +++ b/test/chunking-form/samples/preserve-modules-id-case-sensitive/_expected/amd/_virtual/_one.js @@ -1,7 +1,7 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; var a = 'one.js'; return a; -}); +})); diff --git a/test/chunking-form/samples/preserve-modules-id-case-sensitive/_expected/amd/main.js b/test/chunking-form/samples/preserve-modules-id-case-sensitive/_expected/amd/main.js index 803eecb1652..581279681ff 100644 --- a/test/chunking-form/samples/preserve-modules-id-case-sensitive/_expected/amd/main.js +++ b/test/chunking-form/samples/preserve-modules-id-case-sensitive/_expected/amd/main.js @@ -1,5 +1,5 @@ -define(['./_virtual/_one', './_virtual/_One2', './_virtual/_One1'], function (_one, _One, _One1) { 'use strict'; +define(['./_virtual/_one', './_virtual/_One2', './_virtual/_One1'], (function (_one, _One, _One1) { 'use strict'; window.APP = { a: _one, b: _One, c: _One1 }; -}); +})); diff --git a/test/chunking-form/samples/preserve-modules-id-case-sensitive/_expected/es/_virtual/_One1.js b/test/chunking-form/samples/preserve-modules-id-case-sensitive/_expected/es/_virtual/_One1.js index 3ea816df737..0a993ba1f64 100644 --- a/test/chunking-form/samples/preserve-modules-id-case-sensitive/_expected/es/_virtual/_One1.js +++ b/test/chunking-form/samples/preserve-modules-id-case-sensitive/_expected/es/_virtual/_One1.js @@ -1,3 +1,3 @@ var c = 'One1.js'; -export default c; +export { c as default }; diff --git a/test/chunking-form/samples/preserve-modules-id-case-sensitive/_expected/es/_virtual/_One2.js b/test/chunking-form/samples/preserve-modules-id-case-sensitive/_expected/es/_virtual/_One2.js index d889775b3d6..127ca31fe6f 100644 --- a/test/chunking-form/samples/preserve-modules-id-case-sensitive/_expected/es/_virtual/_One2.js +++ b/test/chunking-form/samples/preserve-modules-id-case-sensitive/_expected/es/_virtual/_One2.js @@ -1,3 +1,3 @@ var b = 'One.js'; -export default b; +export { b as default }; diff --git a/test/chunking-form/samples/preserve-modules-id-case-sensitive/_expected/es/_virtual/_one.js b/test/chunking-form/samples/preserve-modules-id-case-sensitive/_expected/es/_virtual/_one.js index 615c3de0ca9..d53f39de114 100644 --- a/test/chunking-form/samples/preserve-modules-id-case-sensitive/_expected/es/_virtual/_one.js +++ b/test/chunking-form/samples/preserve-modules-id-case-sensitive/_expected/es/_virtual/_one.js @@ -1,3 +1,3 @@ var a = 'one.js'; -export default a; +export { a as default }; diff --git a/test/chunking-form/samples/preserve-modules-id-case-sensitive/_expected/system/_virtual/_One1.js b/test/chunking-form/samples/preserve-modules-id-case-sensitive/_expected/system/_virtual/_One1.js index eb4e015bab5..e83e82562de 100644 --- a/test/chunking-form/samples/preserve-modules-id-case-sensitive/_expected/system/_virtual/_One1.js +++ b/test/chunking-form/samples/preserve-modules-id-case-sensitive/_expected/system/_virtual/_One1.js @@ -1,10 +1,10 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - var c = exports('default', 'One1.js'); + var c = exports("default", 'One1.js'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/preserve-modules-id-case-sensitive/_expected/system/_virtual/_One2.js b/test/chunking-form/samples/preserve-modules-id-case-sensitive/_expected/system/_virtual/_One2.js index 04b90908308..cee300203a0 100644 --- a/test/chunking-form/samples/preserve-modules-id-case-sensitive/_expected/system/_virtual/_One2.js +++ b/test/chunking-form/samples/preserve-modules-id-case-sensitive/_expected/system/_virtual/_One2.js @@ -1,10 +1,10 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - var b = exports('default', 'One.js'); + var b = exports("default", 'One.js'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/preserve-modules-id-case-sensitive/_expected/system/_virtual/_one.js b/test/chunking-form/samples/preserve-modules-id-case-sensitive/_expected/system/_virtual/_one.js index f6c4ac9f9fd..d22765e22bb 100644 --- a/test/chunking-form/samples/preserve-modules-id-case-sensitive/_expected/system/_virtual/_one.js +++ b/test/chunking-form/samples/preserve-modules-id-case-sensitive/_expected/system/_virtual/_one.js @@ -1,10 +1,10 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - var a = exports('default', 'one.js'); + var a = exports("default", 'one.js'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/preserve-modules-id-case-sensitive/_expected/system/main.js b/test/chunking-form/samples/preserve-modules-id-case-sensitive/_expected/system/main.js index 17303445bb0..df50fc52031 100644 --- a/test/chunking-form/samples/preserve-modules-id-case-sensitive/_expected/system/main.js +++ b/test/chunking-form/samples/preserve-modules-id-case-sensitive/_expected/system/main.js @@ -1,4 +1,4 @@ -System.register(['./_virtual/_one.js', './_virtual/_One2.js', './_virtual/_One1.js'], function () { +System.register(['./_virtual/_one.js', './_virtual/_One2.js', './_virtual/_One1.js'], (function () { 'use strict'; var a, b, c; return { @@ -9,10 +9,10 @@ System.register(['./_virtual/_one.js', './_virtual/_One2.js', './_virtual/_One1. }, function (module) { c = module.default; }], - execute: function () { + execute: (function () { window.APP = { a, b, c }; - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/preserve-modules-named-export-mode/_config.js b/test/chunking-form/samples/preserve-modules-named-export-mode/_config.js index 0ad8d5aad54..f122cde6746 100644 --- a/test/chunking-form/samples/preserve-modules-named-export-mode/_config.js +++ b/test/chunking-form/samples/preserve-modules-named-export-mode/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'respects "named" export mode in all chunks when preserving modules', options: { input: 'main.js', @@ -7,4 +7,4 @@ module.exports = { preserveModules: true } } -}; +}); diff --git a/test/chunking-form/samples/preserve-modules-named-export-mode/_expected/amd/default.js b/test/chunking-form/samples/preserve-modules-named-export-mode/_expected/amd/default.js index e8359fc2e7b..18d757daa08 100644 --- a/test/chunking-form/samples/preserve-modules-named-export-mode/_expected/amd/default.js +++ b/test/chunking-form/samples/preserve-modules-named-export-mode/_expected/amd/default.js @@ -1,4 +1,4 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; var foo = 'default'; @@ -6,4 +6,4 @@ define(['exports'], function (exports) { 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); -}); +})); diff --git a/test/chunking-form/samples/preserve-modules-named-export-mode/_expected/amd/main.js b/test/chunking-form/samples/preserve-modules-named-export-mode/_expected/amd/main.js index 8d0b41b8c5c..2b82f1bb651 100644 --- a/test/chunking-form/samples/preserve-modules-named-export-mode/_expected/amd/main.js +++ b/test/chunking-form/samples/preserve-modules-named-export-mode/_expected/amd/main.js @@ -1,12 +1,12 @@ -define(['require', 'exports', './default', './named'], function (require, exports, _default, named) { 'use strict'; +define(['require', 'exports', './default', './named'], (function (require, exports, _default, named) { 'use strict'; - console.log(_default['default'], named.value); + console.log(_default.default, named.value); - new Promise(function (resolve, reject) { require(['./default'], resolve, reject) }).then(result => console.log(result.default)); - new Promise(function (resolve, reject) { require(['./named'], resolve, reject) }).then(result => console.log(result.value)); + new Promise(function (resolve, reject) { require(['./default'], resolve, reject); }).then(result => console.log(result.default)); + new Promise(function (resolve, reject) { require(['./named'], resolve, reject); }).then(result => console.log(result.value)); - exports.default = _default['default']; + exports.default = _default.default; Object.defineProperty(exports, '__esModule', { value: true }); -}); +})); diff --git a/test/chunking-form/samples/preserve-modules-named-export-mode/_expected/amd/named.js b/test/chunking-form/samples/preserve-modules-named-export-mode/_expected/amd/named.js index 37e6d25bd85..2896dcf1065 100644 --- a/test/chunking-form/samples/preserve-modules-named-export-mode/_expected/amd/named.js +++ b/test/chunking-form/samples/preserve-modules-named-export-mode/_expected/amd/named.js @@ -1,9 +1,7 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; const value = 'named'; exports.value = value; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/preserve-modules-named-export-mode/_expected/cjs/main.js b/test/chunking-form/samples/preserve-modules-named-export-mode/_expected/cjs/main.js index 8c9a245414b..9ff3162badf 100644 --- a/test/chunking-form/samples/preserve-modules-named-export-mode/_expected/cjs/main.js +++ b/test/chunking-form/samples/preserve-modules-named-export-mode/_expected/cjs/main.js @@ -5,9 +5,9 @@ Object.defineProperty(exports, '__esModule', { value: true }); var _default = require('./default.js'); var named = require('./named.js'); -console.log(_default['default'], named.value); +console.log(_default.default, named.value); Promise.resolve().then(function () { return require('./default.js'); }).then(result => console.log(result.default)); Promise.resolve().then(function () { return require('./named.js'); }).then(result => console.log(result.value)); -exports.default = _default['default']; +exports.default = _default.default; diff --git a/test/chunking-form/samples/preserve-modules-named-export-mode/_expected/cjs/named.js b/test/chunking-form/samples/preserve-modules-named-export-mode/_expected/cjs/named.js index 491f8569447..ec20bc0d7ff 100644 --- a/test/chunking-form/samples/preserve-modules-named-export-mode/_expected/cjs/named.js +++ b/test/chunking-form/samples/preserve-modules-named-export-mode/_expected/cjs/named.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - const value = 'named'; exports.value = value; diff --git a/test/chunking-form/samples/preserve-modules-named-export-mode/_expected/es/default.js b/test/chunking-form/samples/preserve-modules-named-export-mode/_expected/es/default.js index 97dcda8cdc9..888d95cb398 100644 --- a/test/chunking-form/samples/preserve-modules-named-export-mode/_expected/es/default.js +++ b/test/chunking-form/samples/preserve-modules-named-export-mode/_expected/es/default.js @@ -1,3 +1,3 @@ var foo = 'default'; -export default foo; +export { foo as default }; diff --git a/test/chunking-form/samples/preserve-modules-named-export-mode/_expected/es/main.js b/test/chunking-form/samples/preserve-modules-named-export-mode/_expected/es/main.js index 1db891a835f..4aad85561da 100644 --- a/test/chunking-form/samples/preserve-modules-named-export-mode/_expected/es/main.js +++ b/test/chunking-form/samples/preserve-modules-named-export-mode/_expected/es/main.js @@ -1,8 +1,9 @@ import foo from './default.js'; -export { default } from './default.js'; import { value } from './named.js'; console.log(foo, value); import('./default.js').then(result => console.log(result.default)); import('./named.js').then(result => console.log(result.value)); + +export { foo as default }; diff --git a/test/chunking-form/samples/preserve-modules-named-export-mode/_expected/system/default.js b/test/chunking-form/samples/preserve-modules-named-export-mode/_expected/system/default.js index 0505d3144dd..cb797cc76ce 100644 --- a/test/chunking-form/samples/preserve-modules-named-export-mode/_expected/system/default.js +++ b/test/chunking-form/samples/preserve-modules-named-export-mode/_expected/system/default.js @@ -1,10 +1,10 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - var foo = exports('default', 'default'); + var foo = exports("default", 'default'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/preserve-modules-named-export-mode/_expected/system/main.js b/test/chunking-form/samples/preserve-modules-named-export-mode/_expected/system/main.js index 12e707aee57..a4eec95f2c8 100644 --- a/test/chunking-form/samples/preserve-modules-named-export-mode/_expected/system/main.js +++ b/test/chunking-form/samples/preserve-modules-named-export-mode/_expected/system/main.js @@ -1,20 +1,20 @@ -System.register(['./default.js', './named.js'], function (exports, module) { +System.register(['./default.js', './named.js'], (function (exports, module) { 'use strict'; var foo, value; return { setters: [function (module) { foo = module.default; - exports('default', module.default); + exports("default", module.default); }, function (module) { value = module.value; }], - execute: function () { + execute: (function () { console.log(foo, value); module.import('./default.js').then(result => console.log(result.default)); module.import('./named.js').then(result => console.log(result.value)); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/preserve-modules-named-export-mode/_expected/system/named.js b/test/chunking-form/samples/preserve-modules-named-export-mode/_expected/system/named.js index 431654fc285..2fb3fee2dae 100644 --- a/test/chunking-form/samples/preserve-modules-named-export-mode/_expected/system/named.js +++ b/test/chunking-form/samples/preserve-modules-named-export-mode/_expected/system/named.js @@ -1,10 +1,10 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - const value = exports('value', 'named'); + const value = exports("value", 'named'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/preserve-modules-namespace-reexport-reexport/_config.js b/test/chunking-form/samples/preserve-modules-namespace-reexport-reexport/_config.js new file mode 100644 index 00000000000..5500db098f9 --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-namespace-reexport-reexport/_config.js @@ -0,0 +1,8 @@ +module.exports = defineTest({ + description: 'handles doing a namespace reexport of a reexport', + options: { + output: { + preserveModules: true + } + } +}); diff --git a/test/chunking-form/samples/preserve-modules-namespace-reexport-reexport/_expected/amd/dep.js b/test/chunking-form/samples/preserve-modules-namespace-reexport-reexport/_expected/amd/dep.js new file mode 100644 index 00000000000..031d5da68f7 --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-namespace-reexport-reexport/_expected/amd/dep.js @@ -0,0 +1,7 @@ +define(['exports'], (function (exports) { 'use strict'; + + const value = 'foo'; + + exports.value = value; + +})); diff --git a/test/chunking-form/samples/preserve-modules-namespace-reexport-reexport/_expected/amd/main.js b/test/chunking-form/samples/preserve-modules-namespace-reexport-reexport/_expected/amd/main.js new file mode 100644 index 00000000000..4be01e4b3a8 --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-namespace-reexport-reexport/_expected/amd/main.js @@ -0,0 +1,5 @@ +define(['./reexport', './dep'], (function (reexport, dep) { 'use strict'; + + console.log(dep.value); + +})); diff --git a/test/chunking-form/samples/preserve-modules-namespace-reexport-reexport/_expected/amd/reexport.js b/test/chunking-form/samples/preserve-modules-namespace-reexport-reexport/_expected/amd/reexport.js new file mode 100644 index 00000000000..7092f3ac843 --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-namespace-reexport-reexport/_expected/amd/reexport.js @@ -0,0 +1,5 @@ +define((function () { 'use strict'; + + console.log('reexport'); + +})); diff --git a/test/chunking-form/samples/preserve-modules-namespace-reexport-reexport/_expected/cjs/dep.js b/test/chunking-form/samples/preserve-modules-namespace-reexport-reexport/_expected/cjs/dep.js new file mode 100644 index 00000000000..baf8e2d9969 --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-namespace-reexport-reexport/_expected/cjs/dep.js @@ -0,0 +1,5 @@ +'use strict'; + +const value = 'foo'; + +exports.value = value; diff --git a/test/chunking-form/samples/preserve-modules-namespace-reexport-reexport/_expected/cjs/main.js b/test/chunking-form/samples/preserve-modules-namespace-reexport-reexport/_expected/cjs/main.js new file mode 100644 index 00000000000..532f4eb3659 --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-namespace-reexport-reexport/_expected/cjs/main.js @@ -0,0 +1,6 @@ +'use strict'; + +require('./reexport.js'); +var dep = require('./dep.js'); + +console.log(dep.value); diff --git a/test/chunking-form/samples/preserve-modules-namespace-reexport-reexport/_expected/cjs/reexport.js b/test/chunking-form/samples/preserve-modules-namespace-reexport-reexport/_expected/cjs/reexport.js new file mode 100644 index 00000000000..319ed64fc1a --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-namespace-reexport-reexport/_expected/cjs/reexport.js @@ -0,0 +1,3 @@ +'use strict'; + +console.log('reexport'); diff --git a/test/chunking-form/samples/preserve-modules-namespace-reexport-reexport/_expected/es/dep.js b/test/chunking-form/samples/preserve-modules-namespace-reexport-reexport/_expected/es/dep.js new file mode 100644 index 00000000000..ff45a89931e --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-namespace-reexport-reexport/_expected/es/dep.js @@ -0,0 +1,3 @@ +const value = 'foo'; + +export { value }; diff --git a/test/chunking-form/samples/preserve-modules-namespace-reexport-reexport/_expected/es/main.js b/test/chunking-form/samples/preserve-modules-namespace-reexport-reexport/_expected/es/main.js new file mode 100644 index 00000000000..882ae81d92e --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-namespace-reexport-reexport/_expected/es/main.js @@ -0,0 +1,4 @@ +import './reexport.js'; +import { value } from './dep.js'; + +console.log(value); diff --git a/test/chunking-form/samples/preserve-modules-namespace-reexport-reexport/_expected/es/reexport.js b/test/chunking-form/samples/preserve-modules-namespace-reexport-reexport/_expected/es/reexport.js new file mode 100644 index 00000000000..639e7055010 --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-namespace-reexport-reexport/_expected/es/reexport.js @@ -0,0 +1 @@ +console.log('reexport'); diff --git a/test/chunking-form/samples/preserve-modules-namespace-reexport-reexport/_expected/system/dep.js b/test/chunking-form/samples/preserve-modules-namespace-reexport-reexport/_expected/system/dep.js new file mode 100644 index 00000000000..f96cce39666 --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-namespace-reexport-reexport/_expected/system/dep.js @@ -0,0 +1,10 @@ +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + + const value = exports("value", 'foo'); + + }) + }; +})); diff --git a/test/chunking-form/samples/preserve-modules-namespace-reexport-reexport/_expected/system/main.js b/test/chunking-form/samples/preserve-modules-namespace-reexport-reexport/_expected/system/main.js new file mode 100644 index 00000000000..dc82dc8904d --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-namespace-reexport-reexport/_expected/system/main.js @@ -0,0 +1,14 @@ +System.register(['./reexport.js', './dep.js'], (function () { + 'use strict'; + var value; + return { + setters: [null, function (module) { + value = module.value; + }], + execute: (function () { + + console.log(value); + + }) + }; +})); diff --git a/test/chunking-form/samples/preserve-modules-namespace-reexport-reexport/_expected/system/reexport.js b/test/chunking-form/samples/preserve-modules-namespace-reexport-reexport/_expected/system/reexport.js new file mode 100644 index 00000000000..281427db4f6 --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-namespace-reexport-reexport/_expected/system/reexport.js @@ -0,0 +1,10 @@ +System.register([], (function () { + 'use strict'; + return { + execute: (function () { + + console.log('reexport'); + + }) + }; +})); diff --git a/test/chunking-form/samples/preserve-modules-namespace-reexport-reexport/dep.js b/test/chunking-form/samples/preserve-modules-namespace-reexport-reexport/dep.js new file mode 100644 index 00000000000..481f5a3fb18 --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-namespace-reexport-reexport/dep.js @@ -0,0 +1 @@ +export const value = 'foo'; diff --git a/test/chunking-form/samples/preserve-modules-namespace-reexport-reexport/main.js b/test/chunking-form/samples/preserve-modules-namespace-reexport-reexport/main.js new file mode 100644 index 00000000000..0fb6785265b --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-namespace-reexport-reexport/main.js @@ -0,0 +1,3 @@ +import { value } from './reexport2'; + +console.log(value); diff --git a/test/chunking-form/samples/preserve-modules-namespace-reexport-reexport/reexport.js b/test/chunking-form/samples/preserve-modules-namespace-reexport-reexport/reexport.js new file mode 100644 index 00000000000..c77533c0c52 --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-namespace-reexport-reexport/reexport.js @@ -0,0 +1,2 @@ +export { value } from './dep.js'; +console.log('reexport'); diff --git a/test/chunking-form/samples/preserve-modules-namespace-reexport-reexport/reexport2.js b/test/chunking-form/samples/preserve-modules-namespace-reexport-reexport/reexport2.js new file mode 100644 index 00000000000..e537ea94935 --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-namespace-reexport-reexport/reexport2.js @@ -0,0 +1 @@ +export * from './reexport.js'; diff --git a/test/chunking-form/samples/preserve-modules-nested-barrel-es-export/_config.js b/test/chunking-form/samples/preserve-modules-nested-barrel-es-export/_config.js index 209f77d87a8..35fa916f7ea 100644 --- a/test/chunking-form/samples/preserve-modules-nested-barrel-es-export/_config.js +++ b/test/chunking-form/samples/preserve-modules-nested-barrel-es-export/_config.js @@ -1,7 +1,7 @@ -module.exports = { +module.exports = defineTest({ description: 'confirm exports are deconflicted when exporting nested index aliases', options: { input: 'main.js', output: { preserveModules: true } } -}; +}); diff --git a/test/chunking-form/samples/preserve-modules-nested-barrel-es-export/_expected/amd/main.js b/test/chunking-form/samples/preserve-modules-nested-barrel-es-export/_expected/amd/main.js index 12dccf71f8f..0a1b6a12cba 100644 --- a/test/chunking-form/samples/preserve-modules-nested-barrel-es-export/_expected/amd/main.js +++ b/test/chunking-form/samples/preserve-modules-nested-barrel-es-export/_expected/amd/main.js @@ -1,10 +1,8 @@ -define(['exports', './module-a/v1/index', './module-b/v1/index'], function (exports, index, index$1) { 'use strict'; +define(['exports', './module-a/v1/index', './module-b/v1/index'], (function (exports, index, index$1) { 'use strict'; exports.ModuleA_V1 = index; exports.ModuleB_V1 = index$1; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/preserve-modules-nested-barrel-es-export/_expected/amd/module-a/v1/index.js b/test/chunking-form/samples/preserve-modules-nested-barrel-es-export/_expected/amd/module-a/v1/index.js index 2c1cbb5248d..6b677084b74 100644 --- a/test/chunking-form/samples/preserve-modules-nested-barrel-es-export/_expected/amd/module-a/v1/index.js +++ b/test/chunking-form/samples/preserve-modules-nested-barrel-es-export/_expected/amd/module-a/v1/index.js @@ -1,9 +1,7 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; const TEST_MODULE_A = 'A'; exports.TEST_MODULE_A = TEST_MODULE_A; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/preserve-modules-nested-barrel-es-export/_expected/amd/module-b/v1/index.js b/test/chunking-form/samples/preserve-modules-nested-barrel-es-export/_expected/amd/module-b/v1/index.js index b56f633d9fb..5d1b35b6a7e 100644 --- a/test/chunking-form/samples/preserve-modules-nested-barrel-es-export/_expected/amd/module-b/v1/index.js +++ b/test/chunking-form/samples/preserve-modules-nested-barrel-es-export/_expected/amd/module-b/v1/index.js @@ -1,9 +1,7 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; const TEST_MODULE_B = 'A'; exports.TEST_MODULE_B = TEST_MODULE_B; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/preserve-modules-nested-barrel-es-export/_expected/cjs/main.js b/test/chunking-form/samples/preserve-modules-nested-barrel-es-export/_expected/cjs/main.js index 632ce47b9ae..85ed071a23c 100644 --- a/test/chunking-form/samples/preserve-modules-nested-barrel-es-export/_expected/cjs/main.js +++ b/test/chunking-form/samples/preserve-modules-nested-barrel-es-export/_expected/cjs/main.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - var index = require('./module-a/v1/index.js'); var index$1 = require('./module-b/v1/index.js'); diff --git a/test/chunking-form/samples/preserve-modules-nested-barrel-es-export/_expected/cjs/module-a/v1/index.js b/test/chunking-form/samples/preserve-modules-nested-barrel-es-export/_expected/cjs/module-a/v1/index.js index a8ab4802133..6f57cdac859 100644 --- a/test/chunking-form/samples/preserve-modules-nested-barrel-es-export/_expected/cjs/module-a/v1/index.js +++ b/test/chunking-form/samples/preserve-modules-nested-barrel-es-export/_expected/cjs/module-a/v1/index.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - const TEST_MODULE_A = 'A'; exports.TEST_MODULE_A = TEST_MODULE_A; diff --git a/test/chunking-form/samples/preserve-modules-nested-barrel-es-export/_expected/cjs/module-b/v1/index.js b/test/chunking-form/samples/preserve-modules-nested-barrel-es-export/_expected/cjs/module-b/v1/index.js index 2c2b23c7d63..99cce36ed4d 100644 --- a/test/chunking-form/samples/preserve-modules-nested-barrel-es-export/_expected/cjs/module-b/v1/index.js +++ b/test/chunking-form/samples/preserve-modules-nested-barrel-es-export/_expected/cjs/module-b/v1/index.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - const TEST_MODULE_B = 'A'; exports.TEST_MODULE_B = TEST_MODULE_B; diff --git a/test/chunking-form/samples/preserve-modules-nested-barrel-es-export/_expected/system/main.js b/test/chunking-form/samples/preserve-modules-nested-barrel-es-export/_expected/system/main.js index 69423415aa6..458dfbe898a 100644 --- a/test/chunking-form/samples/preserve-modules-nested-barrel-es-export/_expected/system/main.js +++ b/test/chunking-form/samples/preserve-modules-nested-barrel-es-export/_expected/system/main.js @@ -1,15 +1,15 @@ -System.register(['./module-a/v1/index.js', './module-b/v1/index.js'], function (exports) { +System.register(['./module-a/v1/index.js', './module-b/v1/index.js'], (function (exports) { 'use strict'; return { setters: [function (module) { - exports('ModuleA_V1', module); + exports("ModuleA_V1", module); }, function (module) { - exports('ModuleB_V1', module); + exports("ModuleB_V1", module); }], - execute: function () { + execute: (function () { - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/preserve-modules-nested-barrel-es-export/_expected/system/module-a/v1/index.js b/test/chunking-form/samples/preserve-modules-nested-barrel-es-export/_expected/system/module-a/v1/index.js index 400a5460fc9..e1f0ffbdb5d 100644 --- a/test/chunking-form/samples/preserve-modules-nested-barrel-es-export/_expected/system/module-a/v1/index.js +++ b/test/chunking-form/samples/preserve-modules-nested-barrel-es-export/_expected/system/module-a/v1/index.js @@ -1,10 +1,10 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - const TEST_MODULE_A = exports('TEST_MODULE_A', 'A'); + const TEST_MODULE_A = exports("TEST_MODULE_A", 'A'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/preserve-modules-nested-barrel-es-export/_expected/system/module-b/v1/index.js b/test/chunking-form/samples/preserve-modules-nested-barrel-es-export/_expected/system/module-b/v1/index.js index 337b556bb25..81efe0230f6 100644 --- a/test/chunking-form/samples/preserve-modules-nested-barrel-es-export/_expected/system/module-b/v1/index.js +++ b/test/chunking-form/samples/preserve-modules-nested-barrel-es-export/_expected/system/module-b/v1/index.js @@ -1,10 +1,10 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - const TEST_MODULE_B = exports('TEST_MODULE_B', 'A'); + const TEST_MODULE_B = exports("TEST_MODULE_B", 'A'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/preserve-modules-nested-export/_config.js b/test/chunking-form/samples/preserve-modules-nested-export/_config.js index f2cdd1cc149..adec95d353a 100644 --- a/test/chunking-form/samples/preserve-modules-nested-export/_config.js +++ b/test/chunking-form/samples/preserve-modules-nested-export/_config.js @@ -1,7 +1,7 @@ -module.exports = { +module.exports = defineTest({ description: 'confirm exports are preserved when exporting a module', options: { input: 'main.js', output: { preserveModules: true } } -}; +}); diff --git a/test/chunking-form/samples/preserve-modules-nested-export/_expected/amd/inner/more_inner/something.js b/test/chunking-form/samples/preserve-modules-nested-export/_expected/amd/inner/more_inner/something.js index 138d9ba9e40..9e690e2c1a8 100644 --- a/test/chunking-form/samples/preserve-modules-nested-export/_expected/amd/inner/more_inner/something.js +++ b/test/chunking-form/samples/preserve-modules-nested-export/_expected/amd/inner/more_inner/something.js @@ -1,9 +1,7 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; const Something = 'Hello World'; exports.Something = Something; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/preserve-modules-nested-export/_expected/amd/inner/some_effect.js b/test/chunking-form/samples/preserve-modules-nested-export/_expected/amd/inner/some_effect.js index 621699a15d1..3edb2a5952d 100644 --- a/test/chunking-form/samples/preserve-modules-nested-export/_expected/amd/inner/some_effect.js +++ b/test/chunking-form/samples/preserve-modules-nested-export/_expected/amd/inner/some_effect.js @@ -1,5 +1,5 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; console.log('side-effect'); -}); +})); diff --git a/test/chunking-form/samples/preserve-modules-nested-export/_expected/amd/main.js b/test/chunking-form/samples/preserve-modules-nested-export/_expected/amd/main.js index c89b17c4c11..8519607224b 100644 --- a/test/chunking-form/samples/preserve-modules-nested-export/_expected/amd/main.js +++ b/test/chunking-form/samples/preserve-modules-nested-export/_expected/amd/main.js @@ -1,9 +1,7 @@ -define(['exports', './inner/more_inner/something', './inner/some_effect'], function (exports, something, some_effect) { 'use strict'; +define(['exports', './inner/more_inner/something', './inner/some_effect'], (function (exports, something, some_effect) { 'use strict'; exports.Something = something.Something; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/preserve-modules-nested-export/_expected/cjs/inner/more_inner/something.js b/test/chunking-form/samples/preserve-modules-nested-export/_expected/cjs/inner/more_inner/something.js index 32f3040b7c0..12aa3ba79a7 100644 --- a/test/chunking-form/samples/preserve-modules-nested-export/_expected/cjs/inner/more_inner/something.js +++ b/test/chunking-form/samples/preserve-modules-nested-export/_expected/cjs/inner/more_inner/something.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - const Something = 'Hello World'; exports.Something = Something; diff --git a/test/chunking-form/samples/preserve-modules-nested-export/_expected/cjs/main.js b/test/chunking-form/samples/preserve-modules-nested-export/_expected/cjs/main.js index ffa1d0bc5bb..affdcc85a46 100644 --- a/test/chunking-form/samples/preserve-modules-nested-export/_expected/cjs/main.js +++ b/test/chunking-form/samples/preserve-modules-nested-export/_expected/cjs/main.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - var something = require('./inner/more_inner/something.js'); require('./inner/some_effect.js'); diff --git a/test/chunking-form/samples/preserve-modules-nested-export/_expected/system/inner/more_inner/something.js b/test/chunking-form/samples/preserve-modules-nested-export/_expected/system/inner/more_inner/something.js index 1b4bba21314..164692a9aa2 100644 --- a/test/chunking-form/samples/preserve-modules-nested-export/_expected/system/inner/more_inner/something.js +++ b/test/chunking-form/samples/preserve-modules-nested-export/_expected/system/inner/more_inner/something.js @@ -1,10 +1,10 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - const Something = exports('Something', 'Hello World'); + const Something = exports("Something", 'Hello World'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/preserve-modules-nested-export/_expected/system/inner/some_effect.js b/test/chunking-form/samples/preserve-modules-nested-export/_expected/system/inner/some_effect.js index 19dd3ec79bd..f019bf7e781 100644 --- a/test/chunking-form/samples/preserve-modules-nested-export/_expected/system/inner/some_effect.js +++ b/test/chunking-form/samples/preserve-modules-nested-export/_expected/system/inner/some_effect.js @@ -1,10 +1,10 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { console.log('side-effect'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/preserve-modules-nested-export/_expected/system/main.js b/test/chunking-form/samples/preserve-modules-nested-export/_expected/system/main.js index 16e27681d9a..1762d9669a6 100644 --- a/test/chunking-form/samples/preserve-modules-nested-export/_expected/system/main.js +++ b/test/chunking-form/samples/preserve-modules-nested-export/_expected/system/main.js @@ -1,13 +1,13 @@ -System.register(['./inner/more_inner/something.js', './inner/some_effect.js'], function (exports) { +System.register(['./inner/more_inner/something.js', './inner/some_effect.js'], (function (exports) { 'use strict'; return { setters: [function (module) { - exports('Something', module.Something); - }, function () {}], - execute: function () { + exports("Something", module.Something); + }, null], + execute: (function () { - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/preserve-modules-non-entry-imports/_config.js b/test/chunking-form/samples/preserve-modules-non-entry-imports/_config.js index 732fa455ebe..d1e1a6df084 100644 --- a/test/chunking-form/samples/preserve-modules-non-entry-imports/_config.js +++ b/test/chunking-form/samples/preserve-modules-non-entry-imports/_config.js @@ -1,7 +1,7 @@ -module.exports = { +module.exports = defineTest({ description: 'imports and exports of non-entry points are tracked', options: { input: 'main.js', output: { preserveModules: true } } -}; +}); diff --git a/test/chunking-form/samples/preserve-modules-non-entry-imports/_expected/amd/dep2.js b/test/chunking-form/samples/preserve-modules-non-entry-imports/_expected/amd/dep2.js index 16210f80f24..4ee99d6066e 100644 --- a/test/chunking-form/samples/preserve-modules-non-entry-imports/_expected/amd/dep2.js +++ b/test/chunking-form/samples/preserve-modules-non-entry-imports/_expected/amd/dep2.js @@ -1,7 +1,7 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; function foo() {} return foo; -}); +})); diff --git a/test/chunking-form/samples/preserve-modules-non-entry-imports/_expected/amd/main.js b/test/chunking-form/samples/preserve-modules-non-entry-imports/_expected/amd/main.js index 085588168a4..2121744c94b 100644 --- a/test/chunking-form/samples/preserve-modules-non-entry-imports/_expected/amd/main.js +++ b/test/chunking-form/samples/preserve-modules-non-entry-imports/_expected/amd/main.js @@ -1,7 +1,7 @@ -define(['./dep2'], function (dep2) { 'use strict'; +define(['./dep2'], (function (dep2) { 'use strict'; return dep2; -}); +})); diff --git a/test/chunking-form/samples/preserve-modules-non-entry-imports/_expected/es/dep2.js b/test/chunking-form/samples/preserve-modules-non-entry-imports/_expected/es/dep2.js index e39ccfc8db2..4987d698ddd 100644 --- a/test/chunking-form/samples/preserve-modules-non-entry-imports/_expected/es/dep2.js +++ b/test/chunking-form/samples/preserve-modules-non-entry-imports/_expected/es/dep2.js @@ -1,3 +1,3 @@ function foo() {} -export default foo; +export { foo as default }; diff --git a/test/chunking-form/samples/preserve-modules-non-entry-imports/_expected/es/main.js b/test/chunking-form/samples/preserve-modules-non-entry-imports/_expected/es/main.js index 845c1582956..46cbf60f18d 100644 --- a/test/chunking-form/samples/preserve-modules-non-entry-imports/_expected/es/main.js +++ b/test/chunking-form/samples/preserve-modules-non-entry-imports/_expected/es/main.js @@ -1,2 +1,5 @@ import foo from './dep2.js'; -export { default } from './dep2.js'; + + + +export { foo as default }; diff --git a/test/chunking-form/samples/preserve-modules-non-entry-imports/_expected/system/dep2.js b/test/chunking-form/samples/preserve-modules-non-entry-imports/_expected/system/dep2.js index eb88d79aeda..a589d5ddc89 100644 --- a/test/chunking-form/samples/preserve-modules-non-entry-imports/_expected/system/dep2.js +++ b/test/chunking-form/samples/preserve-modules-non-entry-imports/_expected/system/dep2.js @@ -1,12 +1,12 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - exports('default', foo); + exports("default", foo); function foo() {} - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/preserve-modules-non-entry-imports/_expected/system/main.js b/test/chunking-form/samples/preserve-modules-non-entry-imports/_expected/system/main.js index 8f2d06a8f51..332c1d3a33e 100644 --- a/test/chunking-form/samples/preserve-modules-non-entry-imports/_expected/system/main.js +++ b/test/chunking-form/samples/preserve-modules-non-entry-imports/_expected/system/main.js @@ -1,15 +1,15 @@ -System.register(['./dep2.js'], function (exports) { +System.register(['./dep2.js'], (function (exports) { 'use strict'; var foo; return { setters: [function (module) { foo = module.default; - exports('default', module.default); + exports("default", module.default); }], - execute: function () { + execute: (function () { - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/preserve-modules-proxy-import/_config.js b/test/chunking-form/samples/preserve-modules-proxy-import/_config.js index 23a87ffcbec..b4a3b14ba8b 100644 --- a/test/chunking-form/samples/preserve-modules-proxy-import/_config.js +++ b/test/chunking-form/samples/preserve-modules-proxy-import/_config.js @@ -1,8 +1,8 @@ -module.exports = { +module.exports = defineTest({ description: 'correctly resolves imports via a proxy module as direct imports when preserving modules', options: { external: 'external', output: { preserveModules: true } } -}; +}); diff --git a/test/chunking-form/samples/preserve-modules-proxy-import/_expected/amd/main.js b/test/chunking-form/samples/preserve-modules-proxy-import/_expected/amd/main.js index 0abc6cfe931..b58d356d5af 100644 --- a/test/chunking-form/samples/preserve-modules-proxy-import/_expected/amd/main.js +++ b/test/chunking-form/samples/preserve-modules-proxy-import/_expected/amd/main.js @@ -1,10 +1,6 @@ -define(['external'], function (path) { 'use strict'; +define(['external'], (function (path) { 'use strict'; - function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } + console.log(path.normalize('foo\\bar')); + console.log(path.normalize('foo\\bar')); - var path__default = /*#__PURE__*/_interopDefaultLegacy(path); - - console.log(path__default['default'].normalize('foo\\bar')); - console.log(path__default['default'].normalize('foo\\bar')); - -}); +})); diff --git a/test/chunking-form/samples/preserve-modules-proxy-import/_expected/amd/proxy.js b/test/chunking-form/samples/preserve-modules-proxy-import/_expected/amd/proxy.js index e130c8d6da4..40b6b7b8b15 100644 --- a/test/chunking-form/samples/preserve-modules-proxy-import/_expected/amd/proxy.js +++ b/test/chunking-form/samples/preserve-modules-proxy-import/_expected/amd/proxy.js @@ -1,11 +1,7 @@ -define(['external'], function (path) { 'use strict'; +define(['external'], (function (path) { 'use strict'; - function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } - var path__default = /*#__PURE__*/_interopDefaultLegacy(path); + return path; - - return path__default['default']; - -}); +})); diff --git a/test/chunking-form/samples/preserve-modules-proxy-import/_expected/cjs/main.js b/test/chunking-form/samples/preserve-modules-proxy-import/_expected/cjs/main.js index b018def073b..7db07e7274a 100644 --- a/test/chunking-form/samples/preserve-modules-proxy-import/_expected/cjs/main.js +++ b/test/chunking-form/samples/preserve-modules-proxy-import/_expected/cjs/main.js @@ -2,9 +2,5 @@ var path = require('external'); -function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } - -var path__default = /*#__PURE__*/_interopDefaultLegacy(path); - -console.log(path__default['default'].normalize('foo\\bar')); -console.log(path__default['default'].normalize('foo\\bar')); +console.log(path.normalize('foo\\bar')); +console.log(path.normalize('foo\\bar')); diff --git a/test/chunking-form/samples/preserve-modules-proxy-import/_expected/cjs/proxy.js b/test/chunking-form/samples/preserve-modules-proxy-import/_expected/cjs/proxy.js index f536101936d..de6089fad1b 100644 --- a/test/chunking-form/samples/preserve-modules-proxy-import/_expected/cjs/proxy.js +++ b/test/chunking-form/samples/preserve-modules-proxy-import/_expected/cjs/proxy.js @@ -2,10 +2,6 @@ var path = require('external'); -function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } -var path__default = /*#__PURE__*/_interopDefaultLegacy(path); - - -module.exports = path__default['default']; +module.exports = path; diff --git a/test/chunking-form/samples/preserve-modules-proxy-import/_expected/system/main.js b/test/chunking-form/samples/preserve-modules-proxy-import/_expected/system/main.js index cdb1f31d2d8..1955da8f289 100644 --- a/test/chunking-form/samples/preserve-modules-proxy-import/_expected/system/main.js +++ b/test/chunking-form/samples/preserve-modules-proxy-import/_expected/system/main.js @@ -1,15 +1,15 @@ -System.register(['external'], function () { +System.register(['external'], (function () { 'use strict'; var path; return { setters: [function (module) { path = module.default; }], - execute: function () { + execute: (function () { console.log(path.normalize('foo\\bar')); console.log(path.normalize('foo\\bar')); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/preserve-modules-proxy-import/_expected/system/proxy.js b/test/chunking-form/samples/preserve-modules-proxy-import/_expected/system/proxy.js index 131f0eac764..51800595b19 100644 --- a/test/chunking-form/samples/preserve-modules-proxy-import/_expected/system/proxy.js +++ b/test/chunking-form/samples/preserve-modules-proxy-import/_expected/system/proxy.js @@ -1,15 +1,15 @@ -System.register(['external'], function (exports) { +System.register(['external'], (function (exports) { 'use strict'; var path; return { setters: [function (module) { path = module.default; - exports('default', module.default); + exports("default", module.default); }], - execute: function () { + execute: (function () { - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/preserve-modules-reaching-outside/_config.js b/test/chunking-form/samples/preserve-modules-reaching-outside/_config.js index 61fa9b612c1..0eeb2359c12 100644 --- a/test/chunking-form/samples/preserve-modules-reaching-outside/_config.js +++ b/test/chunking-form/samples/preserve-modules-reaching-outside/_config.js @@ -1,7 +1,7 @@ -module.exports = { +module.exports = defineTest({ description: 'change the module destination', options: { input: 'src/lib/main.js', output: { preserveModules: true } } -}; +}); diff --git a/test/chunking-form/samples/preserve-modules-reaching-outside/_expected/amd/dep.js b/test/chunking-form/samples/preserve-modules-reaching-outside/_expected/amd/dep.js index 93365a06219..e919531b930 100644 --- a/test/chunking-form/samples/preserve-modules-reaching-outside/_expected/amd/dep.js +++ b/test/chunking-form/samples/preserve-modules-reaching-outside/_expected/amd/dep.js @@ -1,4 +1,4 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; function fn () { console.log('dep fn'); @@ -6,6 +6,4 @@ define(['exports'], function (exports) { 'use strict'; exports.fn = fn; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/preserve-modules-reaching-outside/_expected/amd/lib/main.js b/test/chunking-form/samples/preserve-modules-reaching-outside/_expected/amd/lib/main.js index ff8eacced99..7530d2bf1c8 100644 --- a/test/chunking-form/samples/preserve-modules-reaching-outside/_expected/amd/lib/main.js +++ b/test/chunking-form/samples/preserve-modules-reaching-outside/_expected/amd/lib/main.js @@ -1,4 +1,4 @@ -define(['../dep'], function (dep) { 'use strict'; +define(['../dep'], (function (dep) { 'use strict'; class Main { constructor () { @@ -8,4 +8,4 @@ define(['../dep'], function (dep) { 'use strict'; return Main; -}); +})); diff --git a/test/chunking-form/samples/preserve-modules-reaching-outside/_expected/cjs/dep.js b/test/chunking-form/samples/preserve-modules-reaching-outside/_expected/cjs/dep.js index b67a1e41d97..119bca3ddc7 100644 --- a/test/chunking-form/samples/preserve-modules-reaching-outside/_expected/cjs/dep.js +++ b/test/chunking-form/samples/preserve-modules-reaching-outside/_expected/cjs/dep.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - function fn () { console.log('dep fn'); } diff --git a/test/chunking-form/samples/preserve-modules-reaching-outside/_expected/es/lib/main.js b/test/chunking-form/samples/preserve-modules-reaching-outside/_expected/es/lib/main.js index 6285f240de1..7e0751fbcb0 100644 --- a/test/chunking-form/samples/preserve-modules-reaching-outside/_expected/es/lib/main.js +++ b/test/chunking-form/samples/preserve-modules-reaching-outside/_expected/es/lib/main.js @@ -6,4 +6,4 @@ class Main { } } -export default Main; +export { Main as default }; diff --git a/test/chunking-form/samples/preserve-modules-reaching-outside/_expected/system/dep.js b/test/chunking-form/samples/preserve-modules-reaching-outside/_expected/system/dep.js index 3228f5b2991..5999de6b585 100644 --- a/test/chunking-form/samples/preserve-modules-reaching-outside/_expected/system/dep.js +++ b/test/chunking-form/samples/preserve-modules-reaching-outside/_expected/system/dep.js @@ -1,14 +1,14 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - exports('fn', fn); + exports("fn", fn); function fn () { console.log('dep fn'); } - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/preserve-modules-reaching-outside/_expected/system/lib/main.js b/test/chunking-form/samples/preserve-modules-reaching-outside/_expected/system/lib/main.js index 2c8238dca02..823bbead87a 100644 --- a/test/chunking-form/samples/preserve-modules-reaching-outside/_expected/system/lib/main.js +++ b/test/chunking-form/samples/preserve-modules-reaching-outside/_expected/system/lib/main.js @@ -1,18 +1,18 @@ -System.register(['../dep.js'], function (exports) { +System.register(['../dep.js'], (function (exports) { 'use strict'; var fn; return { setters: [function (module) { fn = module.fn; }], - execute: function () { + execute: (function () { class Main { constructor () { fn(); } - } exports('default', Main); + } exports("default", Main); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/preserve-modules-root/_config.js b/test/chunking-form/samples/preserve-modules-root/_config.js index 61ff285d344..bc486962d19 100644 --- a/test/chunking-form/samples/preserve-modules-root/_config.js +++ b/test/chunking-form/samples/preserve-modules-root/_config.js @@ -1,12 +1,20 @@ const commonjs = require('@rollup/plugin-commonjs'); const resolve = require('@rollup/plugin-node-resolve').default; -module.exports = { +module.exports = defineTest({ description: 'confirm preserveModulesRoot restructures src appropriately', expectedWarnings: ['MIXED_EXPORTS'], options: { input: ['src/under-build.js', 'src/below/module.js'], plugins: [ + { + name: 'convert-slashes', + // This simulates converted slashes as used by e.g. Vite + async resolveId(source, importer, options) { + const resolved = await this.resolve(source, importer, options); + return { ...resolved, id: resolved.id.replace(/\\/g, '/') }; + } + }, resolve({ moduleDirectories: ['custom_modules'] }), @@ -17,4 +25,4 @@ module.exports = { preserveModulesRoot: 'src' } } -}; +}); diff --git a/test/chunking-form/samples/preserve-modules-root/_expected/amd/_virtual/_commonjsHelpers.js b/test/chunking-form/samples/preserve-modules-root/_expected/amd/_virtual/_commonjsHelpers.js new file mode 100644 index 00000000000..f35ac4ef0d7 --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-root/_expected/amd/_virtual/_commonjsHelpers.js @@ -0,0 +1,9 @@ +define(['exports'], (function (exports) { 'use strict'; + + function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; + } + + exports.getDefaultExportFromCjs = getDefaultExportFromCjs; + +})); diff --git a/test/chunking-form/samples/preserve-modules-root/_expected/amd/_virtual/index.js b/test/chunking-form/samples/preserve-modules-root/_expected/amd/_virtual/index.js new file mode 100644 index 00000000000..de1c8bfd4b5 --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-root/_expected/amd/_virtual/index.js @@ -0,0 +1,7 @@ +define(['exports'], (function (exports) { 'use strict'; + + var myBasePkg = {}; + + exports.__exports = myBasePkg; + +})); diff --git a/test/chunking-form/samples/preserve-modules-root/_expected/amd/_virtual/index.js_commonjs-exports b/test/chunking-form/samples/preserve-modules-root/_expected/amd/_virtual/index.js_commonjs-exports deleted file mode 100644 index eabd9c47063..00000000000 --- a/test/chunking-form/samples/preserve-modules-root/_expected/amd/_virtual/index.js_commonjs-exports +++ /dev/null @@ -1,9 +0,0 @@ -define(['exports'], function (exports) { 'use strict'; - - var myBasePkg = {}; - - exports.__exports = myBasePkg; - - Object.defineProperty(exports, '__esModule', { value: true }); - -}); diff --git a/test/chunking-form/samples/preserve-modules-root/_expected/amd/below/module.js b/test/chunking-form/samples/preserve-modules-root/_expected/amd/below/module.js index cb45eacc81b..2432888df91 100644 --- a/test/chunking-form/samples/preserve-modules-root/_expected/amd/below/module.js +++ b/test/chunking-form/samples/preserve-modules-root/_expected/amd/below/module.js @@ -1,11 +1,8 @@ -define(['../custom_modules/@my-scope/my-base-pkg/index', '../_virtual/index.js_commonjs-exports'], function (index$1, index) { 'use strict'; +define(['../_virtual/_commonjsHelpers', './module2'], (function (_commonjsHelpers, module$2) { 'use strict'; - const base2 = index.__exports; + var moduleExports = module$2.__require(); + var module$1 = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(moduleExports); - var module = { - base2, - }; + return module$1; - return module; - -}); +})); diff --git a/test/chunking-form/samples/preserve-modules-root/_expected/amd/below/module2.js b/test/chunking-form/samples/preserve-modules-root/_expected/amd/below/module2.js new file mode 100644 index 00000000000..9bc583e9e64 --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-root/_expected/amd/below/module2.js @@ -0,0 +1,19 @@ +define(['exports', '../custom_modules/@my-scope/my-base-pkg/index'], (function (exports, index) { 'use strict'; + + var module$1; + var hasRequiredModule; + + function requireModule () { + if (hasRequiredModule) return module$1; + hasRequiredModule = 1; + const base2 = index.__require(); + + module$1 = { + base2, + }; + return module$1; + } + + exports.__require = requireModule; + +})); diff --git a/test/chunking-form/samples/preserve-modules-root/_expected/amd/custom_modules/@my-scope/my-base-pkg/index.js b/test/chunking-form/samples/preserve-modules-root/_expected/amd/custom_modules/@my-scope/my-base-pkg/index.js index bfcc73a2f77..467c4a1af0a 100644 --- a/test/chunking-form/samples/preserve-modules-root/_expected/amd/custom_modules/@my-scope/my-base-pkg/index.js +++ b/test/chunking-form/samples/preserve-modules-root/_expected/amd/custom_modules/@my-scope/my-base-pkg/index.js @@ -1,11 +1,19 @@ -define(['../../../_virtual/index.js_commonjs-exports'], function (index) { 'use strict'; +define(['exports', '../../../_virtual/index'], (function (exports, index) { 'use strict'; - Object.defineProperty(index.__exports, '__esModule', { value: true }); + var hasRequiredMyBasePkg; - var hello = 'world'; + function requireMyBasePkg () { + if (hasRequiredMyBasePkg) return index.__exports; + hasRequiredMyBasePkg = 1; - index.__exports.hello = hello; + Object.defineProperty(index.__exports, '__esModule', { value: true }); - return index.__exports; + var hello = 'world'; -}); + index.__exports.hello = hello; + return index.__exports; + } + + exports.__require = requireMyBasePkg; + +})); diff --git a/test/chunking-form/samples/preserve-modules-root/_expected/amd/under-build.js b/test/chunking-form/samples/preserve-modules-root/_expected/amd/under-build.js index 921637f1c6b..032a4c5fb03 100644 --- a/test/chunking-form/samples/preserve-modules-root/_expected/amd/under-build.js +++ b/test/chunking-form/samples/preserve-modules-root/_expected/amd/under-build.js @@ -1,11 +1,8 @@ -define(['./custom_modules/@my-scope/my-base-pkg/index', './_virtual/index.js_commonjs-exports'], function (index$1, index) { 'use strict'; +define(['./_virtual/_commonjsHelpers', './under-build2'], (function (_commonjsHelpers, underBuild$1) { 'use strict'; - const base = index.__exports; - - var underBuild = { - base - }; + var underBuildExports = underBuild$1.__require(); + var underBuild = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(underBuildExports); return underBuild; -}); +})); diff --git a/test/chunking-form/samples/preserve-modules-root/_expected/amd/under-build2.js b/test/chunking-form/samples/preserve-modules-root/_expected/amd/under-build2.js new file mode 100644 index 00000000000..f32a6efc111 --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-root/_expected/amd/under-build2.js @@ -0,0 +1,19 @@ +define(['exports', './custom_modules/@my-scope/my-base-pkg/index'], (function (exports, index) { 'use strict'; + + var underBuild; + var hasRequiredUnderBuild; + + function requireUnderBuild () { + if (hasRequiredUnderBuild) return underBuild; + hasRequiredUnderBuild = 1; + const base = index.__require(); + + underBuild = { + base + }; + return underBuild; + } + + exports.__require = requireUnderBuild; + +})); diff --git a/test/chunking-form/samples/preserve-modules-root/_expected/cjs/_virtual/_commonjsHelpers.js b/test/chunking-form/samples/preserve-modules-root/_expected/cjs/_virtual/_commonjsHelpers.js new file mode 100644 index 00000000000..ceeaa4d077f --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-root/_expected/cjs/_virtual/_commonjsHelpers.js @@ -0,0 +1,7 @@ +'use strict'; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +exports.getDefaultExportFromCjs = getDefaultExportFromCjs; diff --git a/test/chunking-form/samples/preserve-modules-root/_expected/cjs/_virtual/index.js b/test/chunking-form/samples/preserve-modules-root/_expected/cjs/_virtual/index.js new file mode 100644 index 00000000000..a63ab9198a2 --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-root/_expected/cjs/_virtual/index.js @@ -0,0 +1,5 @@ +'use strict'; + +var myBasePkg = {}; + +exports.__exports = myBasePkg; diff --git a/test/chunking-form/samples/preserve-modules-root/_expected/cjs/_virtual/index.js_commonjs-exports b/test/chunking-form/samples/preserve-modules-root/_expected/cjs/_virtual/index.js_commonjs-exports deleted file mode 100644 index ad613c469e5..00000000000 --- a/test/chunking-form/samples/preserve-modules-root/_expected/cjs/_virtual/index.js_commonjs-exports +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { value: true }); - -var myBasePkg = {}; - -exports.__exports = myBasePkg; diff --git a/test/chunking-form/samples/preserve-modules-root/_expected/cjs/below/module.js b/test/chunking-form/samples/preserve-modules-root/_expected/cjs/below/module.js index e3a47727a0d..a35987bb6db 100644 --- a/test/chunking-form/samples/preserve-modules-root/_expected/cjs/below/module.js +++ b/test/chunking-form/samples/preserve-modules-root/_expected/cjs/below/module.js @@ -1,12 +1,9 @@ 'use strict'; -require('../custom_modules/@my-scope/my-base-pkg/index.js'); -var index = require('../_virtual/index.js_commonjs-exports'); +var _commonjsHelpers = require('../_virtual/_commonjsHelpers.js'); +var module$2 = require('./module2.js'); -const base2 = index.__exports; - -var module$1 = { - base2, -}; +var moduleExports = module$2.__require(); +var module$1 = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(moduleExports); module.exports = module$1; diff --git a/test/chunking-form/samples/preserve-modules-root/_expected/cjs/below/module2.js b/test/chunking-form/samples/preserve-modules-root/_expected/cjs/below/module2.js new file mode 100644 index 00000000000..593beba5355 --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-root/_expected/cjs/below/module2.js @@ -0,0 +1,19 @@ +'use strict'; + +var index = require('../custom_modules/@my-scope/my-base-pkg/index.js'); + +var module$1; +var hasRequiredModule; + +function requireModule () { + if (hasRequiredModule) return module$1; + hasRequiredModule = 1; + const base2 = index.__require(); + + module$1 = { + base2, + }; + return module$1; +} + +exports.__require = requireModule; diff --git a/test/chunking-form/samples/preserve-modules-root/_expected/cjs/custom_modules/@my-scope/my-base-pkg/index.js b/test/chunking-form/samples/preserve-modules-root/_expected/cjs/custom_modules/@my-scope/my-base-pkg/index.js index 64f5ebacc3f..71779ce66df 100644 --- a/test/chunking-form/samples/preserve-modules-root/_expected/cjs/custom_modules/@my-scope/my-base-pkg/index.js +++ b/test/chunking-form/samples/preserve-modules-root/_expected/cjs/custom_modules/@my-scope/my-base-pkg/index.js @@ -1,11 +1,19 @@ 'use strict'; -var index = require('../../../_virtual/index.js_commonjs-exports'); +var index = require('../../../_virtual/index.js'); -Object.defineProperty(index.__exports, '__esModule', { value: true }); +var hasRequiredMyBasePkg; -var hello = 'world'; +function requireMyBasePkg () { + if (hasRequiredMyBasePkg) return index.__exports; + hasRequiredMyBasePkg = 1; -index.__exports.hello = hello; + Object.defineProperty(index.__exports, '__esModule', { value: true }); -module.exports = index.__exports; + var hello = 'world'; + + index.__exports.hello = hello; + return index.__exports; +} + +exports.__require = requireMyBasePkg; diff --git a/test/chunking-form/samples/preserve-modules-root/_expected/cjs/under-build.js b/test/chunking-form/samples/preserve-modules-root/_expected/cjs/under-build.js index 60f12b2b07f..7b0ad760ec5 100644 --- a/test/chunking-form/samples/preserve-modules-root/_expected/cjs/under-build.js +++ b/test/chunking-form/samples/preserve-modules-root/_expected/cjs/under-build.js @@ -1,12 +1,9 @@ 'use strict'; -require('./custom_modules/@my-scope/my-base-pkg/index.js'); -var index = require('./_virtual/index.js_commonjs-exports'); +var _commonjsHelpers = require('./_virtual/_commonjsHelpers.js'); +var underBuild$1 = require('./under-build2.js'); -const base = index.__exports; - -var underBuild = { - base -}; +var underBuildExports = underBuild$1.__require(); +var underBuild = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(underBuildExports); module.exports = underBuild; diff --git a/test/chunking-form/samples/preserve-modules-root/_expected/cjs/under-build2.js b/test/chunking-form/samples/preserve-modules-root/_expected/cjs/under-build2.js new file mode 100644 index 00000000000..ec64c0391eb --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-root/_expected/cjs/under-build2.js @@ -0,0 +1,19 @@ +'use strict'; + +var index = require('./custom_modules/@my-scope/my-base-pkg/index.js'); + +var underBuild; +var hasRequiredUnderBuild; + +function requireUnderBuild () { + if (hasRequiredUnderBuild) return underBuild; + hasRequiredUnderBuild = 1; + const base = index.__require(); + + underBuild = { + base + }; + return underBuild; +} + +exports.__require = requireUnderBuild; diff --git a/test/chunking-form/samples/preserve-modules-root/_expected/es/_virtual/_commonjsHelpers.js b/test/chunking-form/samples/preserve-modules-root/_expected/es/_virtual/_commonjsHelpers.js new file mode 100644 index 00000000000..7b7c5f4f531 --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-root/_expected/es/_virtual/_commonjsHelpers.js @@ -0,0 +1,5 @@ +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +export { getDefaultExportFromCjs }; diff --git a/test/chunking-form/samples/preserve-modules-root/_expected/es/_virtual/index.js_commonjs-exports b/test/chunking-form/samples/preserve-modules-root/_expected/es/_virtual/index.js similarity index 100% rename from test/chunking-form/samples/preserve-modules-root/_expected/es/_virtual/index.js_commonjs-exports rename to test/chunking-form/samples/preserve-modules-root/_expected/es/_virtual/index.js diff --git a/test/chunking-form/samples/preserve-modules-root/_expected/es/below/module.js b/test/chunking-form/samples/preserve-modules-root/_expected/es/below/module.js index 3933207d721..b8f4ba9cc8d 100644 --- a/test/chunking-form/samples/preserve-modules-root/_expected/es/below/module.js +++ b/test/chunking-form/samples/preserve-modules-root/_expected/es/below/module.js @@ -1,10 +1,7 @@ -import '../custom_modules/@my-scope/my-base-pkg/index.js'; -import { __exports as myBasePkg } from '../_virtual/index.js_commonjs-exports'; +import { getDefaultExportFromCjs } from '../_virtual/_commonjsHelpers.js'; +import { __require as requireModule } from './module2.js'; -const base2 = myBasePkg; +var moduleExports = requireModule(); +var module$1 = /*@__PURE__*/getDefaultExportFromCjs(moduleExports); -var module = { - base2, -}; - -export default module; +export { module$1 as default }; diff --git a/test/chunking-form/samples/preserve-modules-root/_expected/es/below/module2.js b/test/chunking-form/samples/preserve-modules-root/_expected/es/below/module2.js new file mode 100644 index 00000000000..a9fb9189791 --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-root/_expected/es/below/module2.js @@ -0,0 +1,17 @@ +import { __require as requireMyBasePkg } from '../custom_modules/@my-scope/my-base-pkg/index.js'; + +var module$1; +var hasRequiredModule; + +function requireModule () { + if (hasRequiredModule) return module$1; + hasRequiredModule = 1; + const base2 = requireMyBasePkg(); + + module$1 = { + base2, + }; + return module$1; +} + +export { requireModule as __require }; diff --git a/test/chunking-form/samples/preserve-modules-root/_expected/es/custom_modules/@my-scope/my-base-pkg/index.js b/test/chunking-form/samples/preserve-modules-root/_expected/es/custom_modules/@my-scope/my-base-pkg/index.js index 5c1ff69b019..4a22b7fee8a 100644 --- a/test/chunking-form/samples/preserve-modules-root/_expected/es/custom_modules/@my-scope/my-base-pkg/index.js +++ b/test/chunking-form/samples/preserve-modules-root/_expected/es/custom_modules/@my-scope/my-base-pkg/index.js @@ -1,8 +1,17 @@ -import { __exports as myBasePkg } from '../../../_virtual/index.js_commonjs-exports'; -export { __exports as default } from '../../../_virtual/index.js_commonjs-exports'; +import { __exports as myBasePkg } from '../../../_virtual/index.js'; -Object.defineProperty(myBasePkg, '__esModule', { value: true }); +var hasRequiredMyBasePkg; -var hello = 'world'; +function requireMyBasePkg () { + if (hasRequiredMyBasePkg) return myBasePkg; + hasRequiredMyBasePkg = 1; -myBasePkg.hello = hello; + Object.defineProperty(myBasePkg, '__esModule', { value: true }); + + var hello = 'world'; + + myBasePkg.hello = hello; + return myBasePkg; +} + +export { requireMyBasePkg as __require }; diff --git a/test/chunking-form/samples/preserve-modules-root/_expected/es/under-build.js b/test/chunking-form/samples/preserve-modules-root/_expected/es/under-build.js index d2328847049..cf5b83b5640 100644 --- a/test/chunking-form/samples/preserve-modules-root/_expected/es/under-build.js +++ b/test/chunking-form/samples/preserve-modules-root/_expected/es/under-build.js @@ -1,10 +1,7 @@ -import './custom_modules/@my-scope/my-base-pkg/index.js'; -import { __exports as myBasePkg } from './_virtual/index.js_commonjs-exports'; +import { getDefaultExportFromCjs } from './_virtual/_commonjsHelpers.js'; +import { __require as requireUnderBuild } from './under-build2.js'; -const base = myBasePkg; +var underBuildExports = requireUnderBuild(); +var underBuild = /*@__PURE__*/getDefaultExportFromCjs(underBuildExports); -var underBuild = { - base -}; - -export default underBuild; +export { underBuild as default }; diff --git a/test/chunking-form/samples/preserve-modules-root/_expected/es/under-build2.js b/test/chunking-form/samples/preserve-modules-root/_expected/es/under-build2.js new file mode 100644 index 00000000000..94282185573 --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-root/_expected/es/under-build2.js @@ -0,0 +1,17 @@ +import { __require as requireMyBasePkg } from './custom_modules/@my-scope/my-base-pkg/index.js'; + +var underBuild; +var hasRequiredUnderBuild; + +function requireUnderBuild () { + if (hasRequiredUnderBuild) return underBuild; + hasRequiredUnderBuild = 1; + const base = requireMyBasePkg(); + + underBuild = { + base + }; + return underBuild; +} + +export { requireUnderBuild as __require }; diff --git a/test/chunking-form/samples/preserve-modules-root/_expected/system/_virtual/_commonjsHelpers.js b/test/chunking-form/samples/preserve-modules-root/_expected/system/_virtual/_commonjsHelpers.js new file mode 100644 index 00000000000..dd2c5886a6d --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-root/_expected/system/_virtual/_commonjsHelpers.js @@ -0,0 +1,14 @@ +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + + exports("getDefaultExportFromCjs", getDefaultExportFromCjs); + + function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; + } + + }) + }; +})); diff --git a/test/chunking-form/samples/preserve-modules-root/_expected/system/_virtual/index.js b/test/chunking-form/samples/preserve-modules-root/_expected/system/_virtual/index.js new file mode 100644 index 00000000000..26185ba5eb5 --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-root/_expected/system/_virtual/index.js @@ -0,0 +1,10 @@ +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + + var myBasePkg = exports("__exports", {}); + + }) + }; +})); diff --git a/test/chunking-form/samples/preserve-modules-root/_expected/system/_virtual/index.js_commonjs-exports b/test/chunking-form/samples/preserve-modules-root/_expected/system/_virtual/index.js_commonjs-exports deleted file mode 100644 index ea7363b2075..00000000000 --- a/test/chunking-form/samples/preserve-modules-root/_expected/system/_virtual/index.js_commonjs-exports +++ /dev/null @@ -1,10 +0,0 @@ -System.register([], function (exports) { - 'use strict'; - return { - execute: function () { - - var myBasePkg = exports('__exports', {}); - - } - }; -}); diff --git a/test/chunking-form/samples/preserve-modules-root/_expected/system/below/module.js b/test/chunking-form/samples/preserve-modules-root/_expected/system/below/module.js index e0fd73bc68e..4f0b467258f 100644 --- a/test/chunking-form/samples/preserve-modules-root/_expected/system/below/module.js +++ b/test/chunking-form/samples/preserve-modules-root/_expected/system/below/module.js @@ -1,18 +1,17 @@ -System.register(['../custom_modules/@my-scope/my-base-pkg/index.js', '../_virtual/index.js_commonjs-exports'], function (exports) { - 'use strict'; - var myBasePkg; - return { - setters: [function () {}, function (module) { - myBasePkg = module.__exports; - }], - execute: function () { +System.register(['../_virtual/_commonjsHelpers.js', './module2.js'], (function (exports) { + 'use strict'; + var getDefaultExportFromCjs, requireModule; + return { + setters: [function (module) { + getDefaultExportFromCjs = module.getDefaultExportFromCjs; + }, function (module) { + requireModule = module.__require; + }], + execute: (function () { - const base2 = myBasePkg; + var moduleExports = requireModule(); + var module$1 = exports("default", /*@__PURE__*/getDefaultExportFromCjs(moduleExports)); - var module$1 = exports('default', { - base2, - }); - - } - }; -}); + }) + }; +})); diff --git a/test/chunking-form/samples/preserve-modules-root/_expected/system/below/module2.js b/test/chunking-form/samples/preserve-modules-root/_expected/system/below/module2.js new file mode 100644 index 00000000000..de80046f4c0 --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-root/_expected/system/below/module2.js @@ -0,0 +1,28 @@ +System.register(['../custom_modules/@my-scope/my-base-pkg/index.js'], (function (exports) { + 'use strict'; + var requireMyBasePkg; + return { + setters: [function (module) { + requireMyBasePkg = module.__require; + }], + execute: (function () { + + exports("__require", requireModule); + + var module$1; + var hasRequiredModule; + + function requireModule () { + if (hasRequiredModule) return module$1; + hasRequiredModule = 1; + const base2 = requireMyBasePkg(); + + module$1 = { + base2, + }; + return module$1; + } + + }) + }; +})); diff --git a/test/chunking-form/samples/preserve-modules-root/_expected/system/custom_modules/@my-scope/my-base-pkg/index.js b/test/chunking-form/samples/preserve-modules-root/_expected/system/custom_modules/@my-scope/my-base-pkg/index.js index 899f95b223d..9f8ae5196d1 100644 --- a/test/chunking-form/samples/preserve-modules-root/_expected/system/custom_modules/@my-scope/my-base-pkg/index.js +++ b/test/chunking-form/samples/preserve-modules-root/_expected/system/custom_modules/@my-scope/my-base-pkg/index.js @@ -1,19 +1,28 @@ -System.register(['../../../_virtual/index.js_commonjs-exports'], function (exports) { +System.register(['../../../_virtual/index.js'], (function (exports) { 'use strict'; var myBasePkg; return { setters: [function (module) { myBasePkg = module.__exports; - exports('default', module.__exports); }], - execute: function () { + execute: (function () { - Object.defineProperty(myBasePkg, '__esModule', { value: true }); + exports("__require", requireMyBasePkg); - var hello = 'world'; + var hasRequiredMyBasePkg; - myBasePkg.hello = hello; + function requireMyBasePkg () { + if (hasRequiredMyBasePkg) return myBasePkg; + hasRequiredMyBasePkg = 1; - } + Object.defineProperty(myBasePkg, '__esModule', { value: true }); + + var hello = 'world'; + + myBasePkg.hello = hello; + return myBasePkg; + } + + }) }; -}); +})); diff --git a/test/chunking-form/samples/preserve-modules-root/_expected/system/under-build.js b/test/chunking-form/samples/preserve-modules-root/_expected/system/under-build.js index 6b49c154bf3..49fe38e4375 100644 --- a/test/chunking-form/samples/preserve-modules-root/_expected/system/under-build.js +++ b/test/chunking-form/samples/preserve-modules-root/_expected/system/under-build.js @@ -1,18 +1,17 @@ -System.register(['./custom_modules/@my-scope/my-base-pkg/index.js', './_virtual/index.js_commonjs-exports'], function (exports) { +System.register(['./_virtual/_commonjsHelpers.js', './under-build2.js'], (function (exports) { 'use strict'; - var myBasePkg; + var getDefaultExportFromCjs, requireUnderBuild; return { - setters: [function () {}, function (module) { - myBasePkg = module.__exports; + setters: [function (module) { + getDefaultExportFromCjs = module.getDefaultExportFromCjs; + }, function (module) { + requireUnderBuild = module.__require; }], - execute: function () { + execute: (function () { - const base = myBasePkg; + var underBuildExports = requireUnderBuild(); + var underBuild = exports("default", /*@__PURE__*/getDefaultExportFromCjs(underBuildExports)); - var underBuild = exports('default', { - base - }); - - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/preserve-modules-root/_expected/system/under-build2.js b/test/chunking-form/samples/preserve-modules-root/_expected/system/under-build2.js new file mode 100644 index 00000000000..bb0e01c1bfa --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-root/_expected/system/under-build2.js @@ -0,0 +1,28 @@ +System.register(['./custom_modules/@my-scope/my-base-pkg/index.js'], (function (exports) { + 'use strict'; + var requireMyBasePkg; + return { + setters: [function (module) { + requireMyBasePkg = module.__require; + }], + execute: (function () { + + exports("__require", requireUnderBuild); + + var underBuild; + var hasRequiredUnderBuild; + + function requireUnderBuild () { + if (hasRequiredUnderBuild) return underBuild; + hasRequiredUnderBuild = 1; + const base = requireMyBasePkg(); + + underBuild = { + base + }; + return underBuild; + } + + }) + }; +})); diff --git a/test/chunking-form/samples/preserve-modules-scriptified-assets/_config.js b/test/chunking-form/samples/preserve-modules-scriptified-assets/_config.js index 6022c27f9cf..3ab8101f7a5 100644 --- a/test/chunking-form/samples/preserve-modules-scriptified-assets/_config.js +++ b/test/chunking-form/samples/preserve-modules-scriptified-assets/_config.js @@ -1,6 +1,6 @@ -const path = require('path'); +const path = require('node:path'); -module.exports = { +module.exports = defineTest({ description: 'scriptified assets have extension in preserveModules output filename', options: { input: 'src/main.js', @@ -10,17 +10,21 @@ module.exports = { name: 'str-num-plugin', transform(code, id) { switch (path.extname(id)) { - case '.num': + case '.num': { return { code: `export default ${code.trim()}` }; - case '.str': + } + case '.str': { return { code: `export default "${code.trim()}"` }; - case '': + } + case '': { return { code: 'export default "COULDN\'T TRANSFORM"' }; - default: + } + default: { return null; + } } } } ] } -}; +}); diff --git a/test/chunking-form/samples/preserve-modules-scriptified-assets/_expected/amd/answer.num.js b/test/chunking-form/samples/preserve-modules-scriptified-assets/_expected/amd/answer.num.js index 66a5b0c010f..29099bd217e 100644 --- a/test/chunking-form/samples/preserve-modules-scriptified-assets/_expected/amd/answer.num.js +++ b/test/chunking-form/samples/preserve-modules-scriptified-assets/_expected/amd/answer.num.js @@ -1,7 +1,7 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; var answer = 42; return answer; -}); +})); diff --git a/test/chunking-form/samples/preserve-modules-scriptified-assets/_expected/amd/lorem.str.js b/test/chunking-form/samples/preserve-modules-scriptified-assets/_expected/amd/lorem.str.js index 8aeeca012a0..82deb072ec3 100644 --- a/test/chunking-form/samples/preserve-modules-scriptified-assets/_expected/amd/lorem.str.js +++ b/test/chunking-form/samples/preserve-modules-scriptified-assets/_expected/amd/lorem.str.js @@ -1,7 +1,7 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; var lorem = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."; return lorem; -}); +})); diff --git a/test/chunking-form/samples/preserve-modules-scriptified-assets/_expected/amd/main.js b/test/chunking-form/samples/preserve-modules-scriptified-assets/_expected/amd/main.js index 889e72fdb24..11b93e1cea6 100644 --- a/test/chunking-form/samples/preserve-modules-scriptified-assets/_expected/amd/main.js +++ b/test/chunking-form/samples/preserve-modules-scriptified-assets/_expected/amd/main.js @@ -1,4 +1,4 @@ -define(['exports', './answer.num', './lorem.str', './no-ext'], function (exports, answer, lorem, noExt) { 'use strict'; +define(['exports', './answer.num', './lorem.str', './no-ext'], (function (exports, answer, lorem, noExt) { 'use strict'; @@ -6,6 +6,4 @@ define(['exports', './answer.num', './lorem.str', './no-ext'], function (exports exports.lorem = lorem; exports.noExt = noExt; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/preserve-modules-scriptified-assets/_expected/amd/no-ext.js b/test/chunking-form/samples/preserve-modules-scriptified-assets/_expected/amd/no-ext.js index b60c10d9158..2395eddcd5e 100644 --- a/test/chunking-form/samples/preserve-modules-scriptified-assets/_expected/amd/no-ext.js +++ b/test/chunking-form/samples/preserve-modules-scriptified-assets/_expected/amd/no-ext.js @@ -1,7 +1,7 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; var noExt = "COULDN'T TRANSFORM"; return noExt; -}); +})); diff --git a/test/chunking-form/samples/preserve-modules-scriptified-assets/_expected/cjs/main.js b/test/chunking-form/samples/preserve-modules-scriptified-assets/_expected/cjs/main.js index 0c13700934e..463a11a27e6 100644 --- a/test/chunking-form/samples/preserve-modules-scriptified-assets/_expected/cjs/main.js +++ b/test/chunking-form/samples/preserve-modules-scriptified-assets/_expected/cjs/main.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - var answer = require('./answer.num.js'); var lorem = require('./lorem.str.js'); var noExt = require('./no-ext.js'); diff --git a/test/chunking-form/samples/preserve-modules-scriptified-assets/_expected/es/answer.num.js b/test/chunking-form/samples/preserve-modules-scriptified-assets/_expected/es/answer.num.js index b91051d4a13..bc6c6c354cd 100644 --- a/test/chunking-form/samples/preserve-modules-scriptified-assets/_expected/es/answer.num.js +++ b/test/chunking-form/samples/preserve-modules-scriptified-assets/_expected/es/answer.num.js @@ -1,3 +1,3 @@ var answer = 42; -export default answer; +export { answer as default }; diff --git a/test/chunking-form/samples/preserve-modules-scriptified-assets/_expected/es/lorem.str.js b/test/chunking-form/samples/preserve-modules-scriptified-assets/_expected/es/lorem.str.js index 64a054f651b..20a4e34f1ea 100644 --- a/test/chunking-form/samples/preserve-modules-scriptified-assets/_expected/es/lorem.str.js +++ b/test/chunking-form/samples/preserve-modules-scriptified-assets/_expected/es/lorem.str.js @@ -1,3 +1,3 @@ var lorem = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."; -export default lorem; +export { lorem as default }; diff --git a/test/chunking-form/samples/preserve-modules-scriptified-assets/_expected/es/no-ext.js b/test/chunking-form/samples/preserve-modules-scriptified-assets/_expected/es/no-ext.js index b1b723a7068..10cc7f5851b 100644 --- a/test/chunking-form/samples/preserve-modules-scriptified-assets/_expected/es/no-ext.js +++ b/test/chunking-form/samples/preserve-modules-scriptified-assets/_expected/es/no-ext.js @@ -1,3 +1,3 @@ var noExt = "COULDN'T TRANSFORM"; -export default noExt; +export { noExt as default }; diff --git a/test/chunking-form/samples/preserve-modules-scriptified-assets/_expected/system/answer.num.js b/test/chunking-form/samples/preserve-modules-scriptified-assets/_expected/system/answer.num.js index e897f1a3be2..4d88fd1b921 100644 --- a/test/chunking-form/samples/preserve-modules-scriptified-assets/_expected/system/answer.num.js +++ b/test/chunking-form/samples/preserve-modules-scriptified-assets/_expected/system/answer.num.js @@ -1,10 +1,10 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - var answer = exports('default', 42); + var answer = exports("default", 42); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/preserve-modules-scriptified-assets/_expected/system/lorem.str.js b/test/chunking-form/samples/preserve-modules-scriptified-assets/_expected/system/lorem.str.js index 7ebf110f98b..f8ff5ce2ab7 100644 --- a/test/chunking-form/samples/preserve-modules-scriptified-assets/_expected/system/lorem.str.js +++ b/test/chunking-form/samples/preserve-modules-scriptified-assets/_expected/system/lorem.str.js @@ -1,10 +1,10 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - var lorem = exports('default', "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."); + var lorem = exports("default", "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/preserve-modules-scriptified-assets/_expected/system/main.js b/test/chunking-form/samples/preserve-modules-scriptified-assets/_expected/system/main.js index 57340411039..eda477581bf 100644 --- a/test/chunking-form/samples/preserve-modules-scriptified-assets/_expected/system/main.js +++ b/test/chunking-form/samples/preserve-modules-scriptified-assets/_expected/system/main.js @@ -1,17 +1,17 @@ -System.register(['./answer.num.js', './lorem.str.js', './no-ext.js'], function (exports) { +System.register(['./answer.num.js', './lorem.str.js', './no-ext.js'], (function (exports) { 'use strict'; return { setters: [function (module) { - exports('answer', module.default); + exports("answer", module.default); }, function (module) { - exports('lorem', module.default); + exports("lorem", module.default); }, function (module) { - exports('noExt', module.default); + exports("noExt", module.default); }], - execute: function () { + execute: (function () { - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/preserve-modules-scriptified-assets/_expected/system/no-ext.js b/test/chunking-form/samples/preserve-modules-scriptified-assets/_expected/system/no-ext.js index bd0ec5a3c61..69174cec5f3 100644 --- a/test/chunking-form/samples/preserve-modules-scriptified-assets/_expected/system/no-ext.js +++ b/test/chunking-form/samples/preserve-modules-scriptified-assets/_expected/system/no-ext.js @@ -1,10 +1,10 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - var noExt = exports('default', "COULDN'T TRANSFORM"); + var noExt = exports("default", "COULDN'T TRANSFORM"); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/preserve-modules-single-entry/_config.js b/test/chunking-form/samples/preserve-modules-single-entry/_config.js index 05ac0170147..f9d48d1e891 100644 --- a/test/chunking-form/samples/preserve-modules-single-entry/_config.js +++ b/test/chunking-form/samples/preserve-modules-single-entry/_config.js @@ -1,7 +1,7 @@ -module.exports = { +module.exports = defineTest({ description: 'single entry names file correctly', options: { input: 'main.js', output: { preserveModules: true } } -}; +}); diff --git a/test/chunking-form/samples/preserve-modules-single-entry/_expected/amd/main.js b/test/chunking-form/samples/preserve-modules-single-entry/_expected/amd/main.js index 799d8161ff5..7b0ad1252c9 100644 --- a/test/chunking-form/samples/preserve-modules-single-entry/_expected/amd/main.js +++ b/test/chunking-form/samples/preserve-modules-single-entry/_expected/amd/main.js @@ -1,5 +1,5 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; console.log(); -}); +})); diff --git a/test/chunking-form/samples/preserve-modules-single-entry/_expected/system/main.js b/test/chunking-form/samples/preserve-modules-single-entry/_expected/system/main.js index 9c717dc8ff3..1063ea641e0 100644 --- a/test/chunking-form/samples/preserve-modules-single-entry/_expected/system/main.js +++ b/test/chunking-form/samples/preserve-modules-single-entry/_expected/system/main.js @@ -1,10 +1,10 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { console.log(); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/preserve-modules-special-chunk-names/_config.js b/test/chunking-form/samples/preserve-modules-special-chunk-names/_config.js new file mode 100644 index 00000000000..8c139e437c0 --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-special-chunk-names/_config.js @@ -0,0 +1,18 @@ +const path = require('node:path'); + +module.exports = defineTest({ + description: 'Supports chunk names from config when preserving modules', + options: { + input: { 'main-entry': 'main.js' }, + output: { + preserveModules: true + }, + plugins: [ + { + buildStart() { + this.emitFile({ type: 'chunk', id: path.join(__dirname, 'b.js'), name: 'emitted' }); + } + } + ] + } +}); diff --git a/test/chunking-form/samples/preserve-modules-special-chunk-names/_expected/amd/a.js b/test/chunking-form/samples/preserve-modules-special-chunk-names/_expected/amd/a.js new file mode 100644 index 00000000000..6d0638c63e4 --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-special-chunk-names/_expected/amd/a.js @@ -0,0 +1,5 @@ +define((function () { 'use strict'; + + console.log('a'); + +})); diff --git a/test/chunking-form/samples/preserve-modules-special-chunk-names/_expected/amd/emitted.js b/test/chunking-form/samples/preserve-modules-special-chunk-names/_expected/amd/emitted.js new file mode 100644 index 00000000000..b8ffc59b2da --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-special-chunk-names/_expected/amd/emitted.js @@ -0,0 +1,5 @@ +define((function () { 'use strict'; + + console.log('b'); + +})); diff --git a/test/chunking-form/samples/preserve-modules-special-chunk-names/_expected/amd/main-entry.js b/test/chunking-form/samples/preserve-modules-special-chunk-names/_expected/amd/main-entry.js new file mode 100644 index 00000000000..1ca395ac358 --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-special-chunk-names/_expected/amd/main-entry.js @@ -0,0 +1,5 @@ +define(['./a'], (function (a) { 'use strict'; + + console.log('main'); + +})); diff --git a/test/chunking-form/samples/preserve-modules-special-chunk-names/_expected/cjs/a.js b/test/chunking-form/samples/preserve-modules-special-chunk-names/_expected/cjs/a.js new file mode 100644 index 00000000000..4151e09bdbf --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-special-chunk-names/_expected/cjs/a.js @@ -0,0 +1,3 @@ +'use strict'; + +console.log('a'); diff --git a/test/chunking-form/samples/preserve-modules-special-chunk-names/_expected/cjs/emitted.js b/test/chunking-form/samples/preserve-modules-special-chunk-names/_expected/cjs/emitted.js new file mode 100644 index 00000000000..099afa3ff4c --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-special-chunk-names/_expected/cjs/emitted.js @@ -0,0 +1,3 @@ +'use strict'; + +console.log('b'); diff --git a/test/chunking-form/samples/preserve-modules-special-chunk-names/_expected/cjs/main-entry.js b/test/chunking-form/samples/preserve-modules-special-chunk-names/_expected/cjs/main-entry.js new file mode 100644 index 00000000000..51fbee028ad --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-special-chunk-names/_expected/cjs/main-entry.js @@ -0,0 +1,5 @@ +'use strict'; + +require('./a.js'); + +console.log('main'); diff --git a/test/chunking-form/samples/preserve-modules-special-chunk-names/_expected/es/a.js b/test/chunking-form/samples/preserve-modules-special-chunk-names/_expected/es/a.js new file mode 100644 index 00000000000..8609d075540 --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-special-chunk-names/_expected/es/a.js @@ -0,0 +1 @@ +console.log('a'); diff --git a/test/chunking-form/samples/preserve-modules-special-chunk-names/_expected/es/emitted.js b/test/chunking-form/samples/preserve-modules-special-chunk-names/_expected/es/emitted.js new file mode 100644 index 00000000000..eeb313a0347 --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-special-chunk-names/_expected/es/emitted.js @@ -0,0 +1 @@ +console.log('b'); diff --git a/test/chunking-form/samples/preserve-modules-special-chunk-names/_expected/es/main-entry.js b/test/chunking-form/samples/preserve-modules-special-chunk-names/_expected/es/main-entry.js new file mode 100644 index 00000000000..8874885af3b --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-special-chunk-names/_expected/es/main-entry.js @@ -0,0 +1,3 @@ +import './a.js'; + +console.log('main'); diff --git a/test/chunking-form/samples/preserve-modules-special-chunk-names/_expected/system/a.js b/test/chunking-form/samples/preserve-modules-special-chunk-names/_expected/system/a.js new file mode 100644 index 00000000000..2859a1e855c --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-special-chunk-names/_expected/system/a.js @@ -0,0 +1,10 @@ +System.register([], (function () { + 'use strict'; + return { + execute: (function () { + + console.log('a'); + + }) + }; +})); diff --git a/test/chunking-form/samples/preserve-modules-special-chunk-names/_expected/system/emitted.js b/test/chunking-form/samples/preserve-modules-special-chunk-names/_expected/system/emitted.js new file mode 100644 index 00000000000..17b43387a91 --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-special-chunk-names/_expected/system/emitted.js @@ -0,0 +1,10 @@ +System.register([], (function () { + 'use strict'; + return { + execute: (function () { + + console.log('b'); + + }) + }; +})); diff --git a/test/chunking-form/samples/preserve-modules-special-chunk-names/_expected/system/main-entry.js b/test/chunking-form/samples/preserve-modules-special-chunk-names/_expected/system/main-entry.js new file mode 100644 index 00000000000..cfcde79b594 --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-special-chunk-names/_expected/system/main-entry.js @@ -0,0 +1,11 @@ +System.register(['./a.js'], (function () { + 'use strict'; + return { + setters: [null], + execute: (function () { + + console.log('main'); + + }) + }; +})); diff --git a/test/chunking-form/samples/preserve-modules-special-chunk-names/a.js b/test/chunking-form/samples/preserve-modules-special-chunk-names/a.js new file mode 100644 index 00000000000..8609d075540 --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-special-chunk-names/a.js @@ -0,0 +1 @@ +console.log('a'); diff --git a/test/chunking-form/samples/preserve-modules-special-chunk-names/b.js b/test/chunking-form/samples/preserve-modules-special-chunk-names/b.js new file mode 100644 index 00000000000..eeb313a0347 --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-special-chunk-names/b.js @@ -0,0 +1 @@ +console.log('b'); diff --git a/test/chunking-form/samples/preserve-modules-special-chunk-names/main.js b/test/chunking-form/samples/preserve-modules-special-chunk-names/main.js new file mode 100644 index 00000000000..0cf5c3a5a53 --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-special-chunk-names/main.js @@ -0,0 +1,2 @@ +import './a.js'; +console.log('main'); diff --git a/test/chunking-form/samples/preserve-modules-virtual-modules-filename-pattern/_config.js b/test/chunking-form/samples/preserve-modules-virtual-modules-filename-pattern/_config.js new file mode 100644 index 00000000000..5c22c2167db --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-virtual-modules-filename-pattern/_config.js @@ -0,0 +1,34 @@ +module.exports = defineTest({ + description: + 'Generates actual files whose filename adheres to entryFileNames for virtual modules when preserving modules', + options: { + input: 'main.js', + output: { + preserveModules: true, + entryFileNames: '[name]-[format]-[hash].mjs' + }, + plugins: [ + { + resolveId(id) { + if (id === '\0virtualModule') return id; + if (id === '\0virtualWithExt.js') return id; + if (id === '\0virtualWithAssetExt.str') return id; + }, + load(id) { + if (id === '\0virtualModule') return 'export const virtual = "Virtual!";\n'; + if (id === '\0virtualWithExt.js') return 'export const virtual2 = "Virtual2!";\n'; + if (id === '\0virtualWithAssetExt.str') return 'export const virtual3 = "Virtual3!";\n'; + }, + transform(code, id) { + if (id === '\0virtualModule') return null; + if (id === '\0virtualWithExt.js') return null; + if (id === '\0virtualWithAssetExt.str') return null; + return ( + 'import {virtual} from "\0virtualModule";\nimport {virtual2} from "\0virtualWithExt.js";\nimport {virtual3} from "\0virtualWithAssetExt.str";' + + code + ); + } + } + ] + } +}); diff --git a/test/chunking-form/samples/preserve-modules-virtual-modules-filename-pattern/_expected/amd/_virtual/_virtualModule-amd-CqgD4cJS.mjs b/test/chunking-form/samples/preserve-modules-virtual-modules-filename-pattern/_expected/amd/_virtual/_virtualModule-amd-CqgD4cJS.mjs new file mode 100644 index 00000000000..dc4e209f365 --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-virtual-modules-filename-pattern/_expected/amd/_virtual/_virtualModule-amd-CqgD4cJS.mjs @@ -0,0 +1,7 @@ +define(['exports'], (function (exports) { 'use strict'; + + const virtual = "Virtual!"; + + exports.virtual = virtual; + +})); diff --git a/test/chunking-form/samples/preserve-modules-virtual-modules-filename-pattern/_expected/amd/_virtual/_virtualWithAssetExt.str-amd-Ca4QZAgp.mjs b/test/chunking-form/samples/preserve-modules-virtual-modules-filename-pattern/_expected/amd/_virtual/_virtualWithAssetExt.str-amd-Ca4QZAgp.mjs new file mode 100644 index 00000000000..9884d224922 --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-virtual-modules-filename-pattern/_expected/amd/_virtual/_virtualWithAssetExt.str-amd-Ca4QZAgp.mjs @@ -0,0 +1,7 @@ +define(['exports'], (function (exports) { 'use strict'; + + const virtual3 = "Virtual3!"; + + exports.virtual3 = virtual3; + +})); diff --git a/test/chunking-form/samples/preserve-modules-virtual-modules-filename-pattern/_expected/amd/_virtual/_virtualWithExt-amd-De_T627R.mjs b/test/chunking-form/samples/preserve-modules-virtual-modules-filename-pattern/_expected/amd/_virtual/_virtualWithExt-amd-De_T627R.mjs new file mode 100644 index 00000000000..93ea3381bfa --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-virtual-modules-filename-pattern/_expected/amd/_virtual/_virtualWithExt-amd-De_T627R.mjs @@ -0,0 +1,7 @@ +define(['exports'], (function (exports) { 'use strict'; + + const virtual2 = "Virtual2!"; + + exports.virtual2 = virtual2; + +})); diff --git a/test/chunking-form/samples/preserve-modules-virtual-modules-filename-pattern/_expected/amd/main-amd-D0B6q8JD.mjs b/test/chunking-form/samples/preserve-modules-virtual-modules-filename-pattern/_expected/amd/main-amd-D0B6q8JD.mjs new file mode 100644 index 00000000000..18d10400fed --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-virtual-modules-filename-pattern/_expected/amd/main-amd-D0B6q8JD.mjs @@ -0,0 +1,7 @@ +define(['./_virtual/_virtualModule-amd-CqgD4cJS.mjs', './_virtual/_virtualWithExt-amd-De_T627R.mjs', './_virtual/_virtualWithAssetExt.str-amd-Ca4QZAgp.mjs'], (function (_virtualModule, _virtualWithExt, _virtualWithAssetExt) { 'use strict'; + + assert.equal(_virtualModule.virtual, 'Virtual!'); + assert.equal(_virtualWithExt.virtual2, 'Virtual2!'); + assert.equal(_virtualWithAssetExt.virtual3, 'Virtual3!'); + +})); diff --git a/test/chunking-form/samples/preserve-modules-virtual-modules-filename-pattern/_expected/cjs/_virtual/_virtualModule-cjs-MENa5NhI.mjs b/test/chunking-form/samples/preserve-modules-virtual-modules-filename-pattern/_expected/cjs/_virtual/_virtualModule-cjs-MENa5NhI.mjs new file mode 100644 index 00000000000..266f8b02432 --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-virtual-modules-filename-pattern/_expected/cjs/_virtual/_virtualModule-cjs-MENa5NhI.mjs @@ -0,0 +1,5 @@ +'use strict'; + +const virtual = "Virtual!"; + +exports.virtual = virtual; diff --git a/test/chunking-form/samples/preserve-modules-virtual-modules-filename-pattern/_expected/cjs/_virtual/_virtualWithAssetExt.str-cjs-B_lO0aYW.mjs b/test/chunking-form/samples/preserve-modules-virtual-modules-filename-pattern/_expected/cjs/_virtual/_virtualWithAssetExt.str-cjs-B_lO0aYW.mjs new file mode 100644 index 00000000000..86d86076aa7 --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-virtual-modules-filename-pattern/_expected/cjs/_virtual/_virtualWithAssetExt.str-cjs-B_lO0aYW.mjs @@ -0,0 +1,5 @@ +'use strict'; + +const virtual3 = "Virtual3!"; + +exports.virtual3 = virtual3; diff --git a/test/chunking-form/samples/preserve-modules-virtual-modules-filename-pattern/_expected/cjs/_virtual/_virtualWithExt-cjs-DP7-0s5h.mjs b/test/chunking-form/samples/preserve-modules-virtual-modules-filename-pattern/_expected/cjs/_virtual/_virtualWithExt-cjs-DP7-0s5h.mjs new file mode 100644 index 00000000000..97d09a41ce6 --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-virtual-modules-filename-pattern/_expected/cjs/_virtual/_virtualWithExt-cjs-DP7-0s5h.mjs @@ -0,0 +1,5 @@ +'use strict'; + +const virtual2 = "Virtual2!"; + +exports.virtual2 = virtual2; diff --git a/test/chunking-form/samples/preserve-modules-virtual-modules-filename-pattern/_expected/cjs/main-cjs-Dj-jXKJ4.mjs b/test/chunking-form/samples/preserve-modules-virtual-modules-filename-pattern/_expected/cjs/main-cjs-Dj-jXKJ4.mjs new file mode 100644 index 00000000000..fcd04083a24 --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-virtual-modules-filename-pattern/_expected/cjs/main-cjs-Dj-jXKJ4.mjs @@ -0,0 +1,9 @@ +'use strict'; + +var _virtualModule = require('./_virtual/_virtualModule-cjs-MENa5NhI.mjs'); +var _virtualWithExt = require('./_virtual/_virtualWithExt-cjs-DP7-0s5h.mjs'); +var _virtualWithAssetExt = require('./_virtual/_virtualWithAssetExt.str-cjs-B_lO0aYW.mjs'); + +assert.equal(_virtualModule.virtual, 'Virtual!'); +assert.equal(_virtualWithExt.virtual2, 'Virtual2!'); +assert.equal(_virtualWithAssetExt.virtual3, 'Virtual3!'); diff --git a/test/chunking-form/samples/deprecated/preserve-modules-virtual-modules/_expected/es/_virtual/_virtualModule b/test/chunking-form/samples/preserve-modules-virtual-modules-filename-pattern/_expected/es/_virtual/_virtualModule-es-DVZZJXTX.mjs similarity index 100% rename from test/chunking-form/samples/deprecated/preserve-modules-virtual-modules/_expected/es/_virtual/_virtualModule rename to test/chunking-form/samples/preserve-modules-virtual-modules-filename-pattern/_expected/es/_virtual/_virtualModule-es-DVZZJXTX.mjs diff --git a/test/chunking-form/samples/preserve-modules-virtual-modules-filename-pattern/_expected/es/_virtual/_virtualWithAssetExt.str-es-BMZSdKwo.mjs b/test/chunking-form/samples/preserve-modules-virtual-modules-filename-pattern/_expected/es/_virtual/_virtualWithAssetExt.str-es-BMZSdKwo.mjs new file mode 100644 index 00000000000..51e7e8dd9ed --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-virtual-modules-filename-pattern/_expected/es/_virtual/_virtualWithAssetExt.str-es-BMZSdKwo.mjs @@ -0,0 +1,3 @@ +const virtual3 = "Virtual3!"; + +export { virtual3 }; diff --git a/test/chunking-form/samples/preserve-modules-virtual-modules-filename-pattern/_expected/es/_virtual/_virtualWithExt-es-Cy2tYbl9.mjs b/test/chunking-form/samples/preserve-modules-virtual-modules-filename-pattern/_expected/es/_virtual/_virtualWithExt-es-Cy2tYbl9.mjs new file mode 100644 index 00000000000..b5c5634d0a3 --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-virtual-modules-filename-pattern/_expected/es/_virtual/_virtualWithExt-es-Cy2tYbl9.mjs @@ -0,0 +1,3 @@ +const virtual2 = "Virtual2!"; + +export { virtual2 }; diff --git a/test/chunking-form/samples/preserve-modules-virtual-modules-filename-pattern/_expected/es/main-es-Bw8Pzpud.mjs b/test/chunking-form/samples/preserve-modules-virtual-modules-filename-pattern/_expected/es/main-es-Bw8Pzpud.mjs new file mode 100644 index 00000000000..2d75fe13e28 --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-virtual-modules-filename-pattern/_expected/es/main-es-Bw8Pzpud.mjs @@ -0,0 +1,7 @@ +import { virtual } from './_virtual/_virtualModule-es-DVZZJXTX.mjs'; +import { virtual2 } from './_virtual/_virtualWithExt-es-Cy2tYbl9.mjs'; +import { virtual3 } from './_virtual/_virtualWithAssetExt.str-es-BMZSdKwo.mjs'; + +assert.equal(virtual, 'Virtual!'); +assert.equal(virtual2, 'Virtual2!'); +assert.equal(virtual3, 'Virtual3!'); diff --git a/test/chunking-form/samples/preserve-modules-virtual-modules-filename-pattern/_expected/system/_virtual/_virtualModule-system-Cwdr94yk.mjs b/test/chunking-form/samples/preserve-modules-virtual-modules-filename-pattern/_expected/system/_virtual/_virtualModule-system-Cwdr94yk.mjs new file mode 100644 index 00000000000..19d86a38ebc --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-virtual-modules-filename-pattern/_expected/system/_virtual/_virtualModule-system-Cwdr94yk.mjs @@ -0,0 +1,10 @@ +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + + const virtual = exports("virtual", "Virtual!"); + + }) + }; +})); diff --git a/test/chunking-form/samples/preserve-modules-virtual-modules-filename-pattern/_expected/system/_virtual/_virtualWithAssetExt.str-system-_UXDi4fY.mjs b/test/chunking-form/samples/preserve-modules-virtual-modules-filename-pattern/_expected/system/_virtual/_virtualWithAssetExt.str-system-_UXDi4fY.mjs new file mode 100644 index 00000000000..51678f1484e --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-virtual-modules-filename-pattern/_expected/system/_virtual/_virtualWithAssetExt.str-system-_UXDi4fY.mjs @@ -0,0 +1,10 @@ +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + + const virtual3 = exports("virtual3", "Virtual3!"); + + }) + }; +})); diff --git a/test/chunking-form/samples/preserve-modules-virtual-modules-filename-pattern/_expected/system/_virtual/_virtualWithExt-system-DFQIpSQr.mjs b/test/chunking-form/samples/preserve-modules-virtual-modules-filename-pattern/_expected/system/_virtual/_virtualWithExt-system-DFQIpSQr.mjs new file mode 100644 index 00000000000..0495f363a80 --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-virtual-modules-filename-pattern/_expected/system/_virtual/_virtualWithExt-system-DFQIpSQr.mjs @@ -0,0 +1,10 @@ +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + + const virtual2 = exports("virtual2", "Virtual2!"); + + }) + }; +})); diff --git a/test/chunking-form/samples/preserve-modules-virtual-modules-filename-pattern/_expected/system/main-system-Bly5EEDC.mjs b/test/chunking-form/samples/preserve-modules-virtual-modules-filename-pattern/_expected/system/main-system-Bly5EEDC.mjs new file mode 100644 index 00000000000..7fde9e63a5d --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-virtual-modules-filename-pattern/_expected/system/main-system-Bly5EEDC.mjs @@ -0,0 +1,20 @@ +System.register(['./_virtual/_virtualModule-system-Cwdr94yk.mjs', './_virtual/_virtualWithExt-system-DFQIpSQr.mjs', './_virtual/_virtualWithAssetExt.str-system-_UXDi4fY.mjs'], (function () { + 'use strict'; + var virtual, virtual2, virtual3; + return { + setters: [function (module) { + virtual = module.virtual; + }, function (module) { + virtual2 = module.virtual2; + }, function (module) { + virtual3 = module.virtual3; + }], + execute: (function () { + + assert.equal(virtual, 'Virtual!'); + assert.equal(virtual2, 'Virtual2!'); + assert.equal(virtual3, 'Virtual3!'); + + }) + }; +})); diff --git a/test/chunking-form/samples/preserve-modules-virtual-modules-filename-pattern/main.js b/test/chunking-form/samples/preserve-modules-virtual-modules-filename-pattern/main.js new file mode 100644 index 00000000000..f5d5d01a912 --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-virtual-modules-filename-pattern/main.js @@ -0,0 +1,3 @@ +assert.equal(virtual, 'Virtual!'); +assert.equal(virtual2, 'Virtual2!'); +assert.equal(virtual3, 'Virtual3!'); diff --git a/test/chunking-form/samples/preserve-modules-virtual-modules/_config.js b/test/chunking-form/samples/preserve-modules-virtual-modules/_config.js index bd10fa0ad02..59601cf9557 100644 --- a/test/chunking-form/samples/preserve-modules-virtual-modules/_config.js +++ b/test/chunking-form/samples/preserve-modules-virtual-modules/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'Generates actual files for virtual modules when preserving modules', options: { input: 'main.js', @@ -19,4 +19,4 @@ module.exports = { } ] } -}; +}); diff --git a/test/chunking-form/samples/preserve-modules-virtual-modules/_expected/amd/_virtual/_virtualModule b/test/chunking-form/samples/preserve-modules-virtual-modules/_expected/amd/_virtual/_virtualModule deleted file mode 100644 index e847f6c12b8..00000000000 --- a/test/chunking-form/samples/preserve-modules-virtual-modules/_expected/amd/_virtual/_virtualModule +++ /dev/null @@ -1,9 +0,0 @@ -define(['exports'], function (exports) { 'use strict'; - - const virtual = "Virtual!"; - - exports.virtual = virtual; - - Object.defineProperty(exports, '__esModule', { value: true }); - -}); diff --git a/test/chunking-form/samples/preserve-modules-virtual-modules/_expected/amd/_virtual/_virtualModule.js b/test/chunking-form/samples/preserve-modules-virtual-modules/_expected/amd/_virtual/_virtualModule.js new file mode 100644 index 00000000000..dc4e209f365 --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-virtual-modules/_expected/amd/_virtual/_virtualModule.js @@ -0,0 +1,7 @@ +define(['exports'], (function (exports) { 'use strict'; + + const virtual = "Virtual!"; + + exports.virtual = virtual; + +})); diff --git a/test/chunking-form/samples/preserve-modules-virtual-modules/_expected/amd/main.js b/test/chunking-form/samples/preserve-modules-virtual-modules/_expected/amd/main.js index 452f5c4b435..744ca4ba554 100644 --- a/test/chunking-form/samples/preserve-modules-virtual-modules/_expected/amd/main.js +++ b/test/chunking-form/samples/preserve-modules-virtual-modules/_expected/amd/main.js @@ -1,5 +1,5 @@ -define(['./_virtual/_virtualModule'], function (_virtualModule) { 'use strict'; +define(['./_virtual/_virtualModule'], (function (_virtualModule) { 'use strict'; assert.equal(_virtualModule.virtual, 'Virtual!'); -}); +})); diff --git a/test/chunking-form/samples/preserve-modules-virtual-modules/_expected/cjs/_virtual/_virtualModule b/test/chunking-form/samples/preserve-modules-virtual-modules/_expected/cjs/_virtual/_virtualModule deleted file mode 100644 index 3b40ebf67c2..00000000000 --- a/test/chunking-form/samples/preserve-modules-virtual-modules/_expected/cjs/_virtual/_virtualModule +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { value: true }); - -const virtual = "Virtual!"; - -exports.virtual = virtual; diff --git a/test/chunking-form/samples/preserve-modules-virtual-modules/_expected/cjs/_virtual/_virtualModule.js b/test/chunking-form/samples/preserve-modules-virtual-modules/_expected/cjs/_virtual/_virtualModule.js new file mode 100644 index 00000000000..266f8b02432 --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-virtual-modules/_expected/cjs/_virtual/_virtualModule.js @@ -0,0 +1,5 @@ +'use strict'; + +const virtual = "Virtual!"; + +exports.virtual = virtual; diff --git a/test/chunking-form/samples/preserve-modules-virtual-modules/_expected/cjs/main.js b/test/chunking-form/samples/preserve-modules-virtual-modules/_expected/cjs/main.js index c32672f1b85..a3d4133c5c7 100644 --- a/test/chunking-form/samples/preserve-modules-virtual-modules/_expected/cjs/main.js +++ b/test/chunking-form/samples/preserve-modules-virtual-modules/_expected/cjs/main.js @@ -1,5 +1,5 @@ 'use strict'; -var _virtualModule = require('./_virtual/_virtualModule'); +var _virtualModule = require('./_virtual/_virtualModule.js'); assert.equal(_virtualModule.virtual, 'Virtual!'); diff --git a/test/chunking-form/samples/preserve-modules-virtual-modules/_expected/es/_virtual/_virtualModule b/test/chunking-form/samples/preserve-modules-virtual-modules/_expected/es/_virtual/_virtualModule.js similarity index 100% rename from test/chunking-form/samples/preserve-modules-virtual-modules/_expected/es/_virtual/_virtualModule rename to test/chunking-form/samples/preserve-modules-virtual-modules/_expected/es/_virtual/_virtualModule.js diff --git a/test/chunking-form/samples/preserve-modules-virtual-modules/_expected/es/main.js b/test/chunking-form/samples/preserve-modules-virtual-modules/_expected/es/main.js index 6bb75abdf27..96f7b331789 100644 --- a/test/chunking-form/samples/preserve-modules-virtual-modules/_expected/es/main.js +++ b/test/chunking-form/samples/preserve-modules-virtual-modules/_expected/es/main.js @@ -1,3 +1,3 @@ -import { virtual } from './_virtual/_virtualModule'; +import { virtual } from './_virtual/_virtualModule.js'; assert.equal(virtual, 'Virtual!'); diff --git a/test/chunking-form/samples/preserve-modules-virtual-modules/_expected/system/_virtual/_virtualModule b/test/chunking-form/samples/preserve-modules-virtual-modules/_expected/system/_virtual/_virtualModule deleted file mode 100644 index 2281d70c5a9..00000000000 --- a/test/chunking-form/samples/preserve-modules-virtual-modules/_expected/system/_virtual/_virtualModule +++ /dev/null @@ -1,10 +0,0 @@ -System.register([], function (exports) { - 'use strict'; - return { - execute: function () { - - const virtual = exports('virtual', "Virtual!"); - - } - }; -}); diff --git a/test/chunking-form/samples/preserve-modules-virtual-modules/_expected/system/_virtual/_virtualModule.js b/test/chunking-form/samples/preserve-modules-virtual-modules/_expected/system/_virtual/_virtualModule.js new file mode 100644 index 00000000000..19d86a38ebc --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-virtual-modules/_expected/system/_virtual/_virtualModule.js @@ -0,0 +1,10 @@ +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + + const virtual = exports("virtual", "Virtual!"); + + }) + }; +})); diff --git a/test/chunking-form/samples/preserve-modules-virtual-modules/_expected/system/main.js b/test/chunking-form/samples/preserve-modules-virtual-modules/_expected/system/main.js index 7b8b65e237d..f92fd60397b 100644 --- a/test/chunking-form/samples/preserve-modules-virtual-modules/_expected/system/main.js +++ b/test/chunking-form/samples/preserve-modules-virtual-modules/_expected/system/main.js @@ -1,14 +1,14 @@ -System.register(['./_virtual/_virtualModule'], function () { +System.register(['./_virtual/_virtualModule.js'], (function () { 'use strict'; var virtual; return { setters: [function (module) { virtual = module.virtual; }], - execute: function () { + execute: (function () { assert.equal(virtual, 'Virtual!'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/preserve-modules/_config.js b/test/chunking-form/samples/preserve-modules/_config.js index 54d9611466a..6f3d052f35a 100644 --- a/test/chunking-form/samples/preserve-modules/_config.js +++ b/test/chunking-form/samples/preserve-modules/_config.js @@ -1,7 +1,7 @@ -module.exports = { +module.exports = defineTest({ description: 'Rewrite modules in-place', options: { input: ['main1.js', 'main2.js'], output: { preserveModules: true } } -}; +}); diff --git a/test/chunking-form/samples/preserve-modules/_expected/amd/deps/dep1.js b/test/chunking-form/samples/preserve-modules/_expected/amd/deps/dep1.js index eb1b2814d87..59783d02d35 100644 --- a/test/chunking-form/samples/preserve-modules/_expected/amd/deps/dep1.js +++ b/test/chunking-form/samples/preserve-modules/_expected/amd/deps/dep1.js @@ -1,4 +1,4 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; function fn () { console.log('dep1 fn'); @@ -6,6 +6,4 @@ define(['exports'], function (exports) { 'use strict'; exports.fn = fn; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/preserve-modules/_expected/amd/deps/dep2.js b/test/chunking-form/samples/preserve-modules/_expected/amd/deps/dep2.js index 2a152d376d9..2ab2557abf3 100644 --- a/test/chunking-form/samples/preserve-modules/_expected/amd/deps/dep2.js +++ b/test/chunking-form/samples/preserve-modules/_expected/amd/deps/dep2.js @@ -1,4 +1,4 @@ -define(['exports', '../lib/lib2'], function (exports, lib2) { 'use strict'; +define(['exports', '../lib/lib2'], (function (exports, lib2) { 'use strict'; function fn () { lib2.fn(); @@ -7,6 +7,4 @@ define(['exports', '../lib/lib2'], function (exports, lib2) { 'use strict'; exports.fn = fn; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/preserve-modules/_expected/amd/deps/dep3.js b/test/chunking-form/samples/preserve-modules/_expected/amd/deps/dep3.js index bfc8f877c33..3b871ce769d 100644 --- a/test/chunking-form/samples/preserve-modules/_expected/amd/deps/dep3.js +++ b/test/chunking-form/samples/preserve-modules/_expected/amd/deps/dep3.js @@ -1,4 +1,4 @@ -define(['exports', '../lib/lib1'], function (exports, lib1) { 'use strict'; +define(['exports', '../lib/lib1'], (function (exports, lib1) { 'use strict'; function fn () { lib1.fn(); @@ -7,6 +7,4 @@ define(['exports', '../lib/lib1'], function (exports, lib1) { 'use strict'; exports.fn = fn; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/preserve-modules/_expected/amd/lib/lib1.js b/test/chunking-form/samples/preserve-modules/_expected/amd/lib/lib1.js index 93c0a3a4169..6d846653cf3 100644 --- a/test/chunking-form/samples/preserve-modules/_expected/amd/lib/lib1.js +++ b/test/chunking-form/samples/preserve-modules/_expected/amd/lib/lib1.js @@ -1,4 +1,4 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; function fn () { console.log('lib1 fn'); @@ -6,6 +6,4 @@ define(['exports'], function (exports) { 'use strict'; exports.fn = fn; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/preserve-modules/_expected/amd/lib/lib2.js b/test/chunking-form/samples/preserve-modules/_expected/amd/lib/lib2.js index 8e8e2d17cdc..be6d55fa49d 100644 --- a/test/chunking-form/samples/preserve-modules/_expected/amd/lib/lib2.js +++ b/test/chunking-form/samples/preserve-modules/_expected/amd/lib/lib2.js @@ -1,4 +1,4 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; function fn () { console.log('lib2 fn'); @@ -6,6 +6,4 @@ define(['exports'], function (exports) { 'use strict'; exports.fn = fn; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/preserve-modules/_expected/amd/main1.js b/test/chunking-form/samples/preserve-modules/_expected/amd/main1.js index 70e5862bab7..296879effe5 100644 --- a/test/chunking-form/samples/preserve-modules/_expected/amd/main1.js +++ b/test/chunking-form/samples/preserve-modules/_expected/amd/main1.js @@ -1,4 +1,4 @@ -define(['./deps/dep1', './deps/dep2'], function (dep1, dep2) { 'use strict'; +define(['./deps/dep1', './deps/dep2'], (function (dep1, dep2) { 'use strict'; class Main1 { constructor () { @@ -9,4 +9,4 @@ define(['./deps/dep1', './deps/dep2'], function (dep1, dep2) { 'use strict'; return Main1; -}); +})); diff --git a/test/chunking-form/samples/preserve-modules/_expected/amd/main2.js b/test/chunking-form/samples/preserve-modules/_expected/amd/main2.js index b9dd02ca10c..adff70c2354 100644 --- a/test/chunking-form/samples/preserve-modules/_expected/amd/main2.js +++ b/test/chunking-form/samples/preserve-modules/_expected/amd/main2.js @@ -1,4 +1,4 @@ -define(['./deps/dep2', './deps/dep3'], function (dep2, dep3) { 'use strict'; +define(['./deps/dep2', './deps/dep3'], (function (dep2, dep3) { 'use strict'; class Main2 { constructor () { @@ -9,4 +9,4 @@ define(['./deps/dep2', './deps/dep3'], function (dep2, dep3) { 'use strict'; return Main2; -}); +})); diff --git a/test/chunking-form/samples/preserve-modules/_expected/cjs/deps/dep1.js b/test/chunking-form/samples/preserve-modules/_expected/cjs/deps/dep1.js index 94bfa086430..5d2f022faa9 100644 --- a/test/chunking-form/samples/preserve-modules/_expected/cjs/deps/dep1.js +++ b/test/chunking-form/samples/preserve-modules/_expected/cjs/deps/dep1.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - function fn () { console.log('dep1 fn'); } diff --git a/test/chunking-form/samples/preserve-modules/_expected/cjs/deps/dep2.js b/test/chunking-form/samples/preserve-modules/_expected/cjs/deps/dep2.js index a9f8fb62635..1c35a7c280c 100644 --- a/test/chunking-form/samples/preserve-modules/_expected/cjs/deps/dep2.js +++ b/test/chunking-form/samples/preserve-modules/_expected/cjs/deps/dep2.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - var lib2 = require('../lib/lib2.js'); function fn () { diff --git a/test/chunking-form/samples/preserve-modules/_expected/cjs/deps/dep3.js b/test/chunking-form/samples/preserve-modules/_expected/cjs/deps/dep3.js index eb901c61adc..9459cf55dea 100644 --- a/test/chunking-form/samples/preserve-modules/_expected/cjs/deps/dep3.js +++ b/test/chunking-form/samples/preserve-modules/_expected/cjs/deps/dep3.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - var lib1 = require('../lib/lib1.js'); function fn () { diff --git a/test/chunking-form/samples/preserve-modules/_expected/cjs/lib/lib1.js b/test/chunking-form/samples/preserve-modules/_expected/cjs/lib/lib1.js index 135c3023fcc..6a9d99129d3 100644 --- a/test/chunking-form/samples/preserve-modules/_expected/cjs/lib/lib1.js +++ b/test/chunking-form/samples/preserve-modules/_expected/cjs/lib/lib1.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - function fn () { console.log('lib1 fn'); } diff --git a/test/chunking-form/samples/preserve-modules/_expected/cjs/lib/lib2.js b/test/chunking-form/samples/preserve-modules/_expected/cjs/lib/lib2.js index ee3ad249352..cf6e36b03dd 100644 --- a/test/chunking-form/samples/preserve-modules/_expected/cjs/lib/lib2.js +++ b/test/chunking-form/samples/preserve-modules/_expected/cjs/lib/lib2.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - function fn () { console.log('lib2 fn'); } diff --git a/test/chunking-form/samples/preserve-modules/_expected/es/main1.js b/test/chunking-form/samples/preserve-modules/_expected/es/main1.js index db71b463402..a7780fee299 100644 --- a/test/chunking-form/samples/preserve-modules/_expected/es/main1.js +++ b/test/chunking-form/samples/preserve-modules/_expected/es/main1.js @@ -8,4 +8,4 @@ class Main1 { } } -export default Main1; +export { Main1 as default }; diff --git a/test/chunking-form/samples/preserve-modules/_expected/es/main2.js b/test/chunking-form/samples/preserve-modules/_expected/es/main2.js index a3b4ef89ff7..4e89541f07e 100644 --- a/test/chunking-form/samples/preserve-modules/_expected/es/main2.js +++ b/test/chunking-form/samples/preserve-modules/_expected/es/main2.js @@ -8,4 +8,4 @@ class Main2 { } } -export default Main2; +export { Main2 as default }; diff --git a/test/chunking-form/samples/preserve-modules/_expected/system/deps/dep1.js b/test/chunking-form/samples/preserve-modules/_expected/system/deps/dep1.js index 813157baf2d..387ad9ab796 100644 --- a/test/chunking-form/samples/preserve-modules/_expected/system/deps/dep1.js +++ b/test/chunking-form/samples/preserve-modules/_expected/system/deps/dep1.js @@ -1,14 +1,14 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - exports('fn', fn); + exports("fn", fn); function fn () { console.log('dep1 fn'); } - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/preserve-modules/_expected/system/deps/dep2.js b/test/chunking-form/samples/preserve-modules/_expected/system/deps/dep2.js index e659b606bfb..168ba41a34e 100644 --- a/test/chunking-form/samples/preserve-modules/_expected/system/deps/dep2.js +++ b/test/chunking-form/samples/preserve-modules/_expected/system/deps/dep2.js @@ -1,19 +1,19 @@ -System.register(['../lib/lib2.js'], function (exports) { +System.register(['../lib/lib2.js'], (function (exports) { 'use strict'; var fn$1; return { setters: [function (module) { fn$1 = module.fn; }], - execute: function () { + execute: (function () { - exports('fn', fn); + exports("fn", fn); function fn () { fn$1(); console.log('dep2 fn'); } - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/preserve-modules/_expected/system/deps/dep3.js b/test/chunking-form/samples/preserve-modules/_expected/system/deps/dep3.js index bd88b3e2d36..0e5c1f4df07 100644 --- a/test/chunking-form/samples/preserve-modules/_expected/system/deps/dep3.js +++ b/test/chunking-form/samples/preserve-modules/_expected/system/deps/dep3.js @@ -1,19 +1,19 @@ -System.register(['../lib/lib1.js'], function (exports) { +System.register(['../lib/lib1.js'], (function (exports) { 'use strict'; var fn$1; return { setters: [function (module) { fn$1 = module.fn; }], - execute: function () { + execute: (function () { - exports('fn', fn); + exports("fn", fn); function fn () { fn$1(); console.log('dep3 fn'); } - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/preserve-modules/_expected/system/lib/lib1.js b/test/chunking-form/samples/preserve-modules/_expected/system/lib/lib1.js index 744d84434d7..78bbfea10b7 100644 --- a/test/chunking-form/samples/preserve-modules/_expected/system/lib/lib1.js +++ b/test/chunking-form/samples/preserve-modules/_expected/system/lib/lib1.js @@ -1,14 +1,14 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - exports('fn', fn); + exports("fn", fn); function fn () { console.log('lib1 fn'); } - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/preserve-modules/_expected/system/lib/lib2.js b/test/chunking-form/samples/preserve-modules/_expected/system/lib/lib2.js index b27f09d18bd..0a3a50b7d4d 100644 --- a/test/chunking-form/samples/preserve-modules/_expected/system/lib/lib2.js +++ b/test/chunking-form/samples/preserve-modules/_expected/system/lib/lib2.js @@ -1,14 +1,14 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - exports('fn', fn); + exports("fn", fn); function fn () { console.log('lib2 fn'); } - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/preserve-modules/_expected/system/main1.js b/test/chunking-form/samples/preserve-modules/_expected/system/main1.js index 17f7ddb453e..f61a2d65eff 100644 --- a/test/chunking-form/samples/preserve-modules/_expected/system/main1.js +++ b/test/chunking-form/samples/preserve-modules/_expected/system/main1.js @@ -1,4 +1,4 @@ -System.register(['./deps/dep1.js', './deps/dep2.js'], function (exports) { +System.register(['./deps/dep1.js', './deps/dep2.js'], (function (exports) { 'use strict'; var fn, fn$1; return { @@ -7,15 +7,15 @@ System.register(['./deps/dep1.js', './deps/dep2.js'], function (exports) { }, function (module) { fn$1 = module.fn; }], - execute: function () { + execute: (function () { class Main1 { constructor () { fn(); fn$1(); } - } exports('default', Main1); + } exports("default", Main1); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/preserve-modules/_expected/system/main2.js b/test/chunking-form/samples/preserve-modules/_expected/system/main2.js index 4833f43826d..240336265c9 100644 --- a/test/chunking-form/samples/preserve-modules/_expected/system/main2.js +++ b/test/chunking-form/samples/preserve-modules/_expected/system/main2.js @@ -1,4 +1,4 @@ -System.register(['./deps/dep2.js', './deps/dep3.js'], function (exports) { +System.register(['./deps/dep2.js', './deps/dep3.js'], (function (exports) { 'use strict'; var fn$1, fn; return { @@ -7,15 +7,15 @@ System.register(['./deps/dep2.js', './deps/dep3.js'], function (exports) { }, function (module) { fn = module.fn; }], - execute: function () { + execute: (function () { class Main2 { constructor () { fn(); fn$1(); } - } exports('default', Main2); + } exports("default", Main2); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/reexport-from-entry/_config.js b/test/chunking-form/samples/reexport-from-entry/_config.js index ad0d2c5dfd1..9973acbb734 100644 --- a/test/chunking-form/samples/reexport-from-entry/_config.js +++ b/test/chunking-form/samples/reexport-from-entry/_config.js @@ -1,6 +1,6 @@ -module.exports = { +module.exports = defineTest({ description: 'allows reexporting from other entry points', options: { input: ['main', 'otherEntry'] } -}; +}); diff --git a/test/chunking-form/samples/reexport-from-entry/_expected/amd/generated-otherEntry.js b/test/chunking-form/samples/reexport-from-entry/_expected/amd/generated-otherEntry.js deleted file mode 100644 index 9abcdf199e7..00000000000 --- a/test/chunking-form/samples/reexport-from-entry/_expected/amd/generated-otherEntry.js +++ /dev/null @@ -1,12 +0,0 @@ -define(['exports'], function (exports) { 'use strict'; - - let a = {}; - let b = {}; - - let c = {}; - - exports.a = a; - exports.b = b; - exports.c = c; - -}); diff --git a/test/chunking-form/samples/reexport-from-entry/_expected/amd/main.js b/test/chunking-form/samples/reexport-from-entry/_expected/amd/main.js index a917dd64a09..296b62853fa 100644 --- a/test/chunking-form/samples/reexport-from-entry/_expected/amd/main.js +++ b/test/chunking-form/samples/reexport-from-entry/_expected/amd/main.js @@ -1,10 +1,8 @@ -define(['exports', './generated-otherEntry'], function (exports, otherEntry) { 'use strict'; +define(['exports', './otherEntry'], (function (exports, otherEntry) { 'use strict'; exports.a = otherEntry.a; exports.c = otherEntry.c; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/reexport-from-entry/_expected/amd/otherEntry.js b/test/chunking-form/samples/reexport-from-entry/_expected/amd/otherEntry.js index 67cdcc8d4ad..77796cfa099 100644 --- a/test/chunking-form/samples/reexport-from-entry/_expected/amd/otherEntry.js +++ b/test/chunking-form/samples/reexport-from-entry/_expected/amd/otherEntry.js @@ -1,10 +1,12 @@ -define(['exports', './generated-otherEntry'], function (exports, otherEntry) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; + let a = {}; + let b = {}; + let c = {}; - exports.b = otherEntry.b; - exports.c = otherEntry.c; + exports.a = a; + exports.b = b; + exports.c = c; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/reexport-from-entry/_expected/cjs/generated-otherEntry.js b/test/chunking-form/samples/reexport-from-entry/_expected/cjs/generated-otherEntry.js deleted file mode 100644 index a803dae8a95..00000000000 --- a/test/chunking-form/samples/reexport-from-entry/_expected/cjs/generated-otherEntry.js +++ /dev/null @@ -1,10 +0,0 @@ -'use strict'; - -let a = {}; -let b = {}; - -let c = {}; - -exports.a = a; -exports.b = b; -exports.c = c; diff --git a/test/chunking-form/samples/reexport-from-entry/_expected/cjs/main.js b/test/chunking-form/samples/reexport-from-entry/_expected/cjs/main.js index f20f54e462f..9f1202bfb4f 100644 --- a/test/chunking-form/samples/reexport-from-entry/_expected/cjs/main.js +++ b/test/chunking-form/samples/reexport-from-entry/_expected/cjs/main.js @@ -1,8 +1,6 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - -var otherEntry = require('./generated-otherEntry.js'); +var otherEntry = require('./otherEntry.js'); diff --git a/test/chunking-form/samples/reexport-from-entry/_expected/cjs/otherEntry.js b/test/chunking-form/samples/reexport-from-entry/_expected/cjs/otherEntry.js index 683a67be054..a803dae8a95 100644 --- a/test/chunking-form/samples/reexport-from-entry/_expected/cjs/otherEntry.js +++ b/test/chunking-form/samples/reexport-from-entry/_expected/cjs/otherEntry.js @@ -1,10 +1,10 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); +let a = {}; +let b = {}; -var otherEntry = require('./generated-otherEntry.js'); +let c = {}; - - -exports.b = otherEntry.b; -exports.c = otherEntry.c; +exports.a = a; +exports.b = b; +exports.c = c; diff --git a/test/chunking-form/samples/reexport-from-entry/_expected/es/generated-otherEntry.js b/test/chunking-form/samples/reexport-from-entry/_expected/es/generated-otherEntry.js deleted file mode 100644 index 3835176db86..00000000000 --- a/test/chunking-form/samples/reexport-from-entry/_expected/es/generated-otherEntry.js +++ /dev/null @@ -1,6 +0,0 @@ -let a = {}; -let b = {}; - -let c = {}; - -export { a, b, c }; diff --git a/test/chunking-form/samples/reexport-from-entry/_expected/es/main.js b/test/chunking-form/samples/reexport-from-entry/_expected/es/main.js index f3332346bba..c3d42267faa 100644 --- a/test/chunking-form/samples/reexport-from-entry/_expected/es/main.js +++ b/test/chunking-form/samples/reexport-from-entry/_expected/es/main.js @@ -1 +1 @@ -export { a, c } from './generated-otherEntry.js'; +export { a, c } from './otherEntry.js'; diff --git a/test/chunking-form/samples/reexport-from-entry/_expected/es/otherEntry.js b/test/chunking-form/samples/reexport-from-entry/_expected/es/otherEntry.js index 55b811935d3..3835176db86 100644 --- a/test/chunking-form/samples/reexport-from-entry/_expected/es/otherEntry.js +++ b/test/chunking-form/samples/reexport-from-entry/_expected/es/otherEntry.js @@ -1 +1,6 @@ -export { b, c } from './generated-otherEntry.js'; +let a = {}; +let b = {}; + +let c = {}; + +export { a, b, c }; diff --git a/test/chunking-form/samples/reexport-from-entry/_expected/system/generated-otherEntry.js b/test/chunking-form/samples/reexport-from-entry/_expected/system/generated-otherEntry.js deleted file mode 100644 index 1755a56fb29..00000000000 --- a/test/chunking-form/samples/reexport-from-entry/_expected/system/generated-otherEntry.js +++ /dev/null @@ -1,13 +0,0 @@ -System.register([], function (exports) { - 'use strict'; - return { - execute: function () { - - let a = exports('a', {}); - let b = exports('b', {}); - - let c = exports('c', {}); - - } - }; -}); diff --git a/test/chunking-form/samples/reexport-from-entry/_expected/system/main.js b/test/chunking-form/samples/reexport-from-entry/_expected/system/main.js index ed7997ea08b..e65f6c25a16 100644 --- a/test/chunking-form/samples/reexport-from-entry/_expected/system/main.js +++ b/test/chunking-form/samples/reexport-from-entry/_expected/system/main.js @@ -1,16 +1,13 @@ -System.register(['./generated-otherEntry.js'], function (exports) { +System.register(['./otherEntry.js'], (function (exports) { 'use strict'; return { setters: [function (module) { - var _setter = {}; - _setter.a = module.a; - _setter.c = module.c; - exports(_setter); + exports({ a: module.a, c: module.c }); }], - execute: function () { + execute: (function () { - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/reexport-from-entry/_expected/system/otherEntry.js b/test/chunking-form/samples/reexport-from-entry/_expected/system/otherEntry.js index 54a7527b442..c0ac49997ab 100644 --- a/test/chunking-form/samples/reexport-from-entry/_expected/system/otherEntry.js +++ b/test/chunking-form/samples/reexport-from-entry/_expected/system/otherEntry.js @@ -1,16 +1,13 @@ -System.register(['./generated-otherEntry.js'], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - setters: [function (module) { - var _setter = {}; - _setter.b = module.b; - _setter.c = module.c; - exports(_setter); - }], - execute: function () { + execute: (function () { + let a = exports("a", {}); + let b = exports("b", {}); + let c = exports("c", {}); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/reexport-shortpaths/_config.js b/test/chunking-form/samples/reexport-shortpaths/_config.js index 965cd2a2c6b..0be61507777 100644 --- a/test/chunking-form/samples/reexport-shortpaths/_config.js +++ b/test/chunking-form/samples/reexport-shortpaths/_config.js @@ -1,6 +1,6 @@ -module.exports = { +module.exports = defineTest({ description: 'Tracing reexport shortpaths to entry points', options: { input: ['main1.js', 'main2.js', 'main3.js'] } -}; +}); diff --git a/test/chunking-form/samples/reexport-shortpaths/_expected/amd/generated-dep2.js b/test/chunking-form/samples/reexport-shortpaths/_expected/amd/generated-dep2.js deleted file mode 100644 index a6664f9addc..00000000000 --- a/test/chunking-form/samples/reexport-shortpaths/_expected/amd/generated-dep2.js +++ /dev/null @@ -1,8 +0,0 @@ -define(['exports'], function (exports) { 'use strict'; - - function foo() {} - console.log('dep2'); - - exports.foo = foo; - -}); diff --git a/test/chunking-form/samples/reexport-shortpaths/_expected/amd/main1.js b/test/chunking-form/samples/reexport-shortpaths/_expected/amd/main1.js index c20bbae9105..b3541656ea0 100644 --- a/test/chunking-form/samples/reexport-shortpaths/_expected/amd/main1.js +++ b/test/chunking-form/samples/reexport-shortpaths/_expected/amd/main1.js @@ -1,7 +1,7 @@ -define(['./generated-dep2'], function (dep2) { 'use strict'; +define(['./main2'], (function (main2) { 'use strict'; - return dep2.foo; + return main2.foo; -}); +})); diff --git a/test/chunking-form/samples/reexport-shortpaths/_expected/amd/main2.js b/test/chunking-form/samples/reexport-shortpaths/_expected/amd/main2.js index 8806f30b198..251a08f1a09 100644 --- a/test/chunking-form/samples/reexport-shortpaths/_expected/amd/main2.js +++ b/test/chunking-form/samples/reexport-shortpaths/_expected/amd/main2.js @@ -1,5 +1,8 @@ -define(['./generated-dep2'], function (dep2) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; + function foo() {} + console.log('dep2'); + exports.foo = foo; -}); +})); diff --git a/test/chunking-form/samples/reexport-shortpaths/_expected/amd/main3.js b/test/chunking-form/samples/reexport-shortpaths/_expected/amd/main3.js index 8806f30b198..70cc16bd14a 100644 --- a/test/chunking-form/samples/reexport-shortpaths/_expected/amd/main3.js +++ b/test/chunking-form/samples/reexport-shortpaths/_expected/amd/main3.js @@ -1,5 +1,5 @@ -define(['./generated-dep2'], function (dep2) { 'use strict'; +define(['./main2'], (function (main2) { 'use strict'; -}); +})); diff --git a/test/chunking-form/samples/reexport-shortpaths/_expected/cjs/generated-dep2.js b/test/chunking-form/samples/reexport-shortpaths/_expected/cjs/generated-dep2.js deleted file mode 100644 index e71bc446c48..00000000000 --- a/test/chunking-form/samples/reexport-shortpaths/_expected/cjs/generated-dep2.js +++ /dev/null @@ -1,6 +0,0 @@ -'use strict'; - -function foo() {} -console.log('dep2'); - -exports.foo = foo; diff --git a/test/chunking-form/samples/reexport-shortpaths/_expected/cjs/main1.js b/test/chunking-form/samples/reexport-shortpaths/_expected/cjs/main1.js index 660ed01c2f9..7ff2e607734 100644 --- a/test/chunking-form/samples/reexport-shortpaths/_expected/cjs/main1.js +++ b/test/chunking-form/samples/reexport-shortpaths/_expected/cjs/main1.js @@ -1,7 +1,7 @@ 'use strict'; -var dep2 = require('./generated-dep2.js'); +var main2 = require('./main2.js'); -module.exports = dep2.foo; +module.exports = main2.foo; diff --git a/test/chunking-form/samples/reexport-shortpaths/_expected/cjs/main2.js b/test/chunking-form/samples/reexport-shortpaths/_expected/cjs/main2.js index 8bcaed1c530..e71bc446c48 100644 --- a/test/chunking-form/samples/reexport-shortpaths/_expected/cjs/main2.js +++ b/test/chunking-form/samples/reexport-shortpaths/_expected/cjs/main2.js @@ -1,4 +1,6 @@ 'use strict'; -require('./generated-dep2.js'); +function foo() {} +console.log('dep2'); +exports.foo = foo; diff --git a/test/chunking-form/samples/reexport-shortpaths/_expected/cjs/main3.js b/test/chunking-form/samples/reexport-shortpaths/_expected/cjs/main3.js index 8bcaed1c530..700d8990ae5 100644 --- a/test/chunking-form/samples/reexport-shortpaths/_expected/cjs/main3.js +++ b/test/chunking-form/samples/reexport-shortpaths/_expected/cjs/main3.js @@ -1,4 +1,4 @@ 'use strict'; -require('./generated-dep2.js'); +require('./main2.js'); diff --git a/test/chunking-form/samples/reexport-shortpaths/_expected/es/generated-dep2.js b/test/chunking-form/samples/reexport-shortpaths/_expected/es/generated-dep2.js deleted file mode 100644 index 5c686abbfa1..00000000000 --- a/test/chunking-form/samples/reexport-shortpaths/_expected/es/generated-dep2.js +++ /dev/null @@ -1,4 +0,0 @@ -function foo() {} -console.log('dep2'); - -export { foo as f }; diff --git a/test/chunking-form/samples/reexport-shortpaths/_expected/es/main1.js b/test/chunking-form/samples/reexport-shortpaths/_expected/es/main1.js index 017843b99a5..a44697e6af4 100644 --- a/test/chunking-form/samples/reexport-shortpaths/_expected/es/main1.js +++ b/test/chunking-form/samples/reexport-shortpaths/_expected/es/main1.js @@ -1,2 +1,5 @@ -import { f as foo } from './generated-dep2.js'; -export { f as default } from './generated-dep2.js'; +import { f as foo } from './main2.js'; + + + +export { foo as default }; diff --git a/test/chunking-form/samples/reexport-shortpaths/_expected/es/main2.js b/test/chunking-form/samples/reexport-shortpaths/_expected/es/main2.js index e38989d38f2..5c686abbfa1 100644 --- a/test/chunking-form/samples/reexport-shortpaths/_expected/es/main2.js +++ b/test/chunking-form/samples/reexport-shortpaths/_expected/es/main2.js @@ -1 +1,4 @@ -import './generated-dep2.js'; +function foo() {} +console.log('dep2'); + +export { foo as f }; diff --git a/test/chunking-form/samples/reexport-shortpaths/_expected/es/main3.js b/test/chunking-form/samples/reexport-shortpaths/_expected/es/main3.js index e38989d38f2..5c07fb3a323 100644 --- a/test/chunking-form/samples/reexport-shortpaths/_expected/es/main3.js +++ b/test/chunking-form/samples/reexport-shortpaths/_expected/es/main3.js @@ -1 +1 @@ -import './generated-dep2.js'; +import './main2.js'; diff --git a/test/chunking-form/samples/reexport-shortpaths/_expected/system/generated-dep2.js b/test/chunking-form/samples/reexport-shortpaths/_expected/system/generated-dep2.js deleted file mode 100644 index b8c52e10393..00000000000 --- a/test/chunking-form/samples/reexport-shortpaths/_expected/system/generated-dep2.js +++ /dev/null @@ -1,13 +0,0 @@ -System.register([], function (exports) { - 'use strict'; - return { - execute: function () { - - exports('f', foo); - - function foo() {} - console.log('dep2'); - - } - }; -}); diff --git a/test/chunking-form/samples/reexport-shortpaths/_expected/system/main1.js b/test/chunking-form/samples/reexport-shortpaths/_expected/system/main1.js index cb219e6b1d5..ae49c995280 100644 --- a/test/chunking-form/samples/reexport-shortpaths/_expected/system/main1.js +++ b/test/chunking-form/samples/reexport-shortpaths/_expected/system/main1.js @@ -1,15 +1,15 @@ -System.register(['./generated-dep2.js'], function (exports) { +System.register(['./main2.js'], (function (exports) { 'use strict'; var foo; return { setters: [function (module) { foo = module.f; - exports('default', module.f); + exports("default", module.f); }], - execute: function () { + execute: (function () { - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/reexport-shortpaths/_expected/system/main2.js b/test/chunking-form/samples/reexport-shortpaths/_expected/system/main2.js index 73473efce7c..bdac61aa1e7 100644 --- a/test/chunking-form/samples/reexport-shortpaths/_expected/system/main2.js +++ b/test/chunking-form/samples/reexport-shortpaths/_expected/system/main2.js @@ -1,11 +1,13 @@ -System.register(['./generated-dep2.js'], function () { +System.register([], (function (exports) { 'use strict'; return { - setters: [function () {}], - execute: function () { + execute: (function () { + exports("f", foo); + function foo() {} + console.log('dep2'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/reexport-shortpaths/_expected/system/main3.js b/test/chunking-form/samples/reexport-shortpaths/_expected/system/main3.js index 73473efce7c..e81455fc230 100644 --- a/test/chunking-form/samples/reexport-shortpaths/_expected/system/main3.js +++ b/test/chunking-form/samples/reexport-shortpaths/_expected/system/main3.js @@ -1,11 +1,11 @@ -System.register(['./generated-dep2.js'], function () { +System.register(['./main2.js'], (function () { 'use strict'; return { - setters: [function () {}], - execute: function () { + setters: [null], + execute: (function () { - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/relative-external-outside-output/_config.js b/test/chunking-form/samples/relative-external-outside-output/_config.js new file mode 100644 index 00000000000..976bc8cb99c --- /dev/null +++ b/test/chunking-form/samples/relative-external-outside-output/_config.js @@ -0,0 +1,9 @@ +module.exports = defineTest({ + description: 'allows relative external dependencies outside of output dir', + options: { + input: { main: 'main.js', 'nested/main': 'nested/main.js' }, + external(id) { + return id.startsWith('../'); + } + } +}); diff --git a/test/chunking-form/samples/relative-external-outside-output/_expected/amd/main.js b/test/chunking-form/samples/relative-external-outside-output/_expected/amd/main.js new file mode 100644 index 00000000000..3c4fd1fb27f --- /dev/null +++ b/test/chunking-form/samples/relative-external-outside-output/_expected/amd/main.js @@ -0,0 +1,5 @@ +define(['../first', '../../second'], (function (first_js, second_js) { 'use strict'; + + console.log(first_js.first, second_js.second); + +})); diff --git a/test/chunking-form/samples/relative-external-outside-output/_expected/amd/nested/main.js b/test/chunking-form/samples/relative-external-outside-output/_expected/amd/nested/main.js new file mode 100644 index 00000000000..44daed2b0cc --- /dev/null +++ b/test/chunking-form/samples/relative-external-outside-output/_expected/amd/nested/main.js @@ -0,0 +1,5 @@ +define(['../../first', '../../../second'], (function (first_js, second_js) { 'use strict'; + + console.log(first_js.first, second_js.second); + +})); diff --git a/test/chunking-form/samples/relative-external-outside-output/_expected/cjs/main.js b/test/chunking-form/samples/relative-external-outside-output/_expected/cjs/main.js new file mode 100644 index 00000000000..11ed1a072df --- /dev/null +++ b/test/chunking-form/samples/relative-external-outside-output/_expected/cjs/main.js @@ -0,0 +1,6 @@ +'use strict'; + +var first_js = require('../first.js'); +var second_js = require('../../second.js'); + +console.log(first_js.first, second_js.second); diff --git a/test/chunking-form/samples/relative-external-outside-output/_expected/cjs/nested/main.js b/test/chunking-form/samples/relative-external-outside-output/_expected/cjs/nested/main.js new file mode 100644 index 00000000000..7f1caaf19e1 --- /dev/null +++ b/test/chunking-form/samples/relative-external-outside-output/_expected/cjs/nested/main.js @@ -0,0 +1,6 @@ +'use strict'; + +var first_js = require('../../first.js'); +var second_js = require('../../../second.js'); + +console.log(first_js.first, second_js.second); diff --git a/test/chunking-form/samples/relative-external-outside-output/_expected/es/main.js b/test/chunking-form/samples/relative-external-outside-output/_expected/es/main.js new file mode 100644 index 00000000000..96c5858ea9a --- /dev/null +++ b/test/chunking-form/samples/relative-external-outside-output/_expected/es/main.js @@ -0,0 +1,4 @@ +import { first } from '../first.js'; +import { second } from '../../second.js'; + +console.log(first, second); diff --git a/test/chunking-form/samples/relative-external-outside-output/_expected/es/nested/main.js b/test/chunking-form/samples/relative-external-outside-output/_expected/es/nested/main.js new file mode 100644 index 00000000000..92384ef8344 --- /dev/null +++ b/test/chunking-form/samples/relative-external-outside-output/_expected/es/nested/main.js @@ -0,0 +1,4 @@ +import { first } from '../../first.js'; +import { second } from '../../../second.js'; + +console.log(first, second); diff --git a/test/chunking-form/samples/relative-external-outside-output/_expected/system/main.js b/test/chunking-form/samples/relative-external-outside-output/_expected/system/main.js new file mode 100644 index 00000000000..3a230b93a1e --- /dev/null +++ b/test/chunking-form/samples/relative-external-outside-output/_expected/system/main.js @@ -0,0 +1,16 @@ +System.register(['../first.js', '../../second.js'], (function () { + 'use strict'; + var first, second; + return { + setters: [function (module) { + first = module.first; + }, function (module) { + second = module.second; + }], + execute: (function () { + + console.log(first, second); + + }) + }; +})); diff --git a/test/chunking-form/samples/relative-external-outside-output/_expected/system/nested/main.js b/test/chunking-form/samples/relative-external-outside-output/_expected/system/nested/main.js new file mode 100644 index 00000000000..525f6adf53a --- /dev/null +++ b/test/chunking-form/samples/relative-external-outside-output/_expected/system/nested/main.js @@ -0,0 +1,16 @@ +System.register(['../../first.js', '../../../second.js'], (function () { + 'use strict'; + var first, second; + return { + setters: [function (module) { + first = module.first; + }, function (module) { + second = module.second; + }], + execute: (function () { + + console.log(first, second); + + }) + }; +})); diff --git a/test/chunking-form/samples/relative-external-outside-output/main.js b/test/chunking-form/samples/relative-external-outside-output/main.js new file mode 100644 index 00000000000..ddf6b833e8d --- /dev/null +++ b/test/chunking-form/samples/relative-external-outside-output/main.js @@ -0,0 +1,3 @@ +import { first } from '../first.js'; +import { second } from '../../second.js'; +console.log(first, second); diff --git a/test/chunking-form/samples/relative-external-outside-output/nested/main.js b/test/chunking-form/samples/relative-external-outside-output/nested/main.js new file mode 100644 index 00000000000..d402e5c1313 --- /dev/null +++ b/test/chunking-form/samples/relative-external-outside-output/nested/main.js @@ -0,0 +1,3 @@ +import { first } from '../../first.js'; +import { second } from '../../../second.js'; +console.log(first, second); diff --git a/test/chunking-form/samples/remove-attribute-declarations-for-internal-dynamic-imports/_config.js b/test/chunking-form/samples/remove-attribute-declarations-for-internal-dynamic-imports/_config.js new file mode 100644 index 00000000000..b1195c2e2a1 --- /dev/null +++ b/test/chunking-form/samples/remove-attribute-declarations-for-internal-dynamic-imports/_config.js @@ -0,0 +1,14 @@ +module.exports = defineTest({ + description: 'Remove the attribute declarations for internal dynamic imports', + expectedWarnings: ['INVALID_IMPORT_ATTRIBUTE'], + options: { + plugins: [ + { + resolveDynamicImport() { + return { id: './foo.js' }; + } + } + ] + }, + verifyAst: false +}); diff --git a/test/chunking-form/samples/remove-attribute-declarations-for-internal-dynamic-imports/_expected/amd/generated-foo.js b/test/chunking-form/samples/remove-attribute-declarations-for-internal-dynamic-imports/_expected/amd/generated-foo.js new file mode 100644 index 00000000000..377f0e06f80 --- /dev/null +++ b/test/chunking-form/samples/remove-attribute-declarations-for-internal-dynamic-imports/_expected/amd/generated-foo.js @@ -0,0 +1,8 @@ +define(['exports'], (function (exports) { 'use strict'; + + const foo = 'foo'; + console.log(foo); + + exports.foo = foo; + +})); diff --git a/test/chunking-form/samples/remove-attribute-declarations-for-internal-dynamic-imports/_expected/amd/main.js b/test/chunking-form/samples/remove-attribute-declarations-for-internal-dynamic-imports/_expected/amd/main.js new file mode 100644 index 00000000000..30c5f54efda --- /dev/null +++ b/test/chunking-form/samples/remove-attribute-declarations-for-internal-dynamic-imports/_expected/amd/main.js @@ -0,0 +1,5 @@ +define(['require'], (function (require) { 'use strict'; + + new Promise(function (resolve, reject) { require(['./generated-foo'], resolve, reject); }); + +})); diff --git a/test/chunking-form/samples/remove-attribute-declarations-for-internal-dynamic-imports/_expected/cjs/generated-foo.js b/test/chunking-form/samples/remove-attribute-declarations-for-internal-dynamic-imports/_expected/cjs/generated-foo.js new file mode 100644 index 00000000000..186abffa7c4 --- /dev/null +++ b/test/chunking-form/samples/remove-attribute-declarations-for-internal-dynamic-imports/_expected/cjs/generated-foo.js @@ -0,0 +1,6 @@ +'use strict'; + +const foo = 'foo'; +console.log(foo); + +exports.foo = foo; diff --git a/test/chunking-form/samples/remove-attribute-declarations-for-internal-dynamic-imports/_expected/cjs/main.js b/test/chunking-form/samples/remove-attribute-declarations-for-internal-dynamic-imports/_expected/cjs/main.js new file mode 100644 index 00000000000..6fbd51e3ad2 --- /dev/null +++ b/test/chunking-form/samples/remove-attribute-declarations-for-internal-dynamic-imports/_expected/cjs/main.js @@ -0,0 +1,3 @@ +'use strict'; + +Promise.resolve().then(function () { return require('./generated-foo.js'); }); diff --git a/test/chunking-form/samples/remove-attribute-declarations-for-internal-dynamic-imports/_expected/es/generated-foo.js b/test/chunking-form/samples/remove-attribute-declarations-for-internal-dynamic-imports/_expected/es/generated-foo.js new file mode 100644 index 00000000000..00ab90252de --- /dev/null +++ b/test/chunking-form/samples/remove-attribute-declarations-for-internal-dynamic-imports/_expected/es/generated-foo.js @@ -0,0 +1,4 @@ +const foo = 'foo'; +console.log(foo); + +export { foo }; diff --git a/test/chunking-form/samples/remove-attribute-declarations-for-internal-dynamic-imports/_expected/es/main.js b/test/chunking-form/samples/remove-attribute-declarations-for-internal-dynamic-imports/_expected/es/main.js new file mode 100644 index 00000000000..da05d25c6b2 --- /dev/null +++ b/test/chunking-form/samples/remove-attribute-declarations-for-internal-dynamic-imports/_expected/es/main.js @@ -0,0 +1 @@ +import('./generated-foo.js'); diff --git a/test/chunking-form/samples/remove-attribute-declarations-for-internal-dynamic-imports/_expected/system/generated-foo.js b/test/chunking-form/samples/remove-attribute-declarations-for-internal-dynamic-imports/_expected/system/generated-foo.js new file mode 100644 index 00000000000..4ff31e577cf --- /dev/null +++ b/test/chunking-form/samples/remove-attribute-declarations-for-internal-dynamic-imports/_expected/system/generated-foo.js @@ -0,0 +1,11 @@ +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + + const foo = exports("foo", 'foo'); + console.log(foo); + + }) + }; +})); diff --git a/test/chunking-form/samples/remove-attribute-declarations-for-internal-dynamic-imports/_expected/system/main.js b/test/chunking-form/samples/remove-attribute-declarations-for-internal-dynamic-imports/_expected/system/main.js new file mode 100644 index 00000000000..e2adf5ca7cc --- /dev/null +++ b/test/chunking-form/samples/remove-attribute-declarations-for-internal-dynamic-imports/_expected/system/main.js @@ -0,0 +1,10 @@ +System.register([], (function (exports, module) { + 'use strict'; + return { + execute: (function () { + + module.import('./generated-foo.js'); + + }) + }; +})); diff --git a/test/chunking-form/samples/remove-attribute-declarations-for-internal-dynamic-imports/foo.js b/test/chunking-form/samples/remove-attribute-declarations-for-internal-dynamic-imports/foo.js new file mode 100644 index 00000000000..e07c34b9e09 --- /dev/null +++ b/test/chunking-form/samples/remove-attribute-declarations-for-internal-dynamic-imports/foo.js @@ -0,0 +1,2 @@ +export const foo = 'foo'; +console.log(foo); \ No newline at end of file diff --git a/test/chunking-form/samples/remove-attribute-declarations-for-internal-dynamic-imports/main.js b/test/chunking-form/samples/remove-attribute-declarations-for-internal-dynamic-imports/main.js new file mode 100644 index 00000000000..323ed9d4023 --- /dev/null +++ b/test/chunking-form/samples/remove-attribute-declarations-for-internal-dynamic-imports/main.js @@ -0,0 +1,3 @@ +const extra = { with: { type: 'json' } }; +import(specifier, extra); + diff --git a/test/chunking-form/samples/render-chunk-transform/_config.js b/test/chunking-form/samples/render-chunk-transform/_config.js new file mode 100644 index 00000000000..bc2bf05b4ff --- /dev/null +++ b/test/chunking-form/samples/render-chunk-transform/_config.js @@ -0,0 +1,80 @@ +const assert = require('node:assert'); +const { replaceDirectoryInStringifiedObject } = require('../../../testHelpers'); + +module.exports = defineTest({ + description: 'replaces hashes when mutating chunk info in renderChunk', + options: { + input: ['main1', 'main2'], + plugins: { + renderChunk(code, chunk, options, { chunks }) { + if (chunk.fileName.includes('main2')) { + const main1Chunk = Object.keys(chunks).find(fileName => fileName.includes('main1')); + chunk.imports.push(main1Chunk); + chunk.importedBindings[main1Chunk] = ['added']; + return `import { added } from ${JSON.stringify( + `./${main1Chunk}` + )};\nconsole.log(added);\n${code}`; + } + chunk.exports.push('added'); + return `${code}\nexport const added = 'added';`; + }, + generateBundle(options, bundle) { + const sanitizedBundle = JSON.parse( + replaceDirectoryInStringifiedObject(bundle, __dirname).replace( + /(entry-\w+)-[\w|-]+\.js/g, + (match, name) => `${name}.js` + ) + ); + for (const fileName of Object.keys(sanitizedBundle)) { + delete sanitizedBundle[fileName].code; + delete sanitizedBundle[fileName].modules; + } + + assert.deepStrictEqual(sanitizedBundle, { + 'entry-main1.js': { + exports: ['added'], + facadeModuleId: '**/main1.js', + isDynamicEntry: false, + isEntry: true, + isImplicitEntry: false, + moduleIds: ['**/main1.js'], + name: 'main1', + type: 'chunk', + dynamicImports: [], + fileName: 'entry-main1.js', + implicitlyLoadedBefore: [], + importedBindings: {}, + imports: [], + preliminaryFileName: 'entry-main1-!~{001}~.js', + referencedFiles: [], + map: null, + sourcemapFileName: null + }, + 'entry-main2.js': { + exports: [], + facadeModuleId: '**/main2.js', + isDynamicEntry: false, + isEntry: true, + isImplicitEntry: false, + moduleIds: ['**/main2.js'], + name: 'main2', + type: 'chunk', + dynamicImports: [], + fileName: 'entry-main2.js', + implicitlyLoadedBefore: [], + importedBindings: { 'entry-main1.js': ['added'] }, + imports: ['entry-main1.js'], + preliminaryFileName: 'entry-main2-!~{002}~.js', + referencedFiles: [], + map: null, + sourcemapFileName: null + } + }); + } + }, + output: { + entryFileNames: 'entry-[name]-[hash].js', + chunkFileNames: 'chunk-[name]-[hash].js' + } + } +}); diff --git a/test/chunking-form/samples/render-chunk-transform/_expected/amd/entry-main1-DTXeRbrN.js b/test/chunking-form/samples/render-chunk-transform/_expected/amd/entry-main1-DTXeRbrN.js new file mode 100644 index 00000000000..baddcd1c81c --- /dev/null +++ b/test/chunking-form/samples/render-chunk-transform/_expected/amd/entry-main1-DTXeRbrN.js @@ -0,0 +1,6 @@ +define((function () { 'use strict'; + + console.log('main1'); + +})); +export const added = 'added'; diff --git a/test/chunking-form/samples/render-chunk-transform/_expected/amd/entry-main2-BUwyD6FV.js b/test/chunking-form/samples/render-chunk-transform/_expected/amd/entry-main2-BUwyD6FV.js new file mode 100644 index 00000000000..22475c20936 --- /dev/null +++ b/test/chunking-form/samples/render-chunk-transform/_expected/amd/entry-main2-BUwyD6FV.js @@ -0,0 +1,7 @@ +import { added } from "./entry-main1-DTXeRbrN.js"; +console.log(added); +define((function () { 'use strict'; + + console.log('main2'); + +})); diff --git a/test/chunking-form/samples/render-chunk-transform/_expected/cjs/entry-main1-CinfcDMy.js b/test/chunking-form/samples/render-chunk-transform/_expected/cjs/entry-main1-CinfcDMy.js new file mode 100644 index 00000000000..27e474e9ef1 --- /dev/null +++ b/test/chunking-form/samples/render-chunk-transform/_expected/cjs/entry-main1-CinfcDMy.js @@ -0,0 +1,4 @@ +'use strict'; + +console.log('main1'); +export const added = 'added'; diff --git a/test/chunking-form/samples/render-chunk-transform/_expected/cjs/entry-main2-i24vGdI5.js b/test/chunking-form/samples/render-chunk-transform/_expected/cjs/entry-main2-i24vGdI5.js new file mode 100644 index 00000000000..b09294b1ad1 --- /dev/null +++ b/test/chunking-form/samples/render-chunk-transform/_expected/cjs/entry-main2-i24vGdI5.js @@ -0,0 +1,5 @@ +import { added } from "./entry-main1-CinfcDMy.js"; +console.log(added); +'use strict'; + +console.log('main2'); diff --git a/test/chunking-form/samples/render-chunk-transform/_expected/es/entry-main1-bUD0z9Dn.js b/test/chunking-form/samples/render-chunk-transform/_expected/es/entry-main1-bUD0z9Dn.js new file mode 100644 index 00000000000..93378fe3d56 --- /dev/null +++ b/test/chunking-form/samples/render-chunk-transform/_expected/es/entry-main1-bUD0z9Dn.js @@ -0,0 +1,2 @@ +console.log('main1'); +export const added = 'added'; diff --git a/test/chunking-form/samples/render-chunk-transform/_expected/es/entry-main2-NdATofhS.js b/test/chunking-form/samples/render-chunk-transform/_expected/es/entry-main2-NdATofhS.js new file mode 100644 index 00000000000..0991aa025f3 --- /dev/null +++ b/test/chunking-form/samples/render-chunk-transform/_expected/es/entry-main2-NdATofhS.js @@ -0,0 +1,3 @@ +import { added } from "./entry-main1-bUD0z9Dn.js"; +console.log(added); +console.log('main2'); diff --git a/test/chunking-form/samples/render-chunk-transform/_expected/system/entry-main1-D-6QAEdu.js b/test/chunking-form/samples/render-chunk-transform/_expected/system/entry-main1-D-6QAEdu.js new file mode 100644 index 00000000000..a1b90cb4147 --- /dev/null +++ b/test/chunking-form/samples/render-chunk-transform/_expected/system/entry-main1-D-6QAEdu.js @@ -0,0 +1,11 @@ +System.register([], (function () { + 'use strict'; + return { + execute: (function () { + + console.log('main1'); + + }) + }; +})); +export const added = 'added'; diff --git a/test/chunking-form/samples/render-chunk-transform/_expected/system/entry-main2-Bk_CgiOM.js b/test/chunking-form/samples/render-chunk-transform/_expected/system/entry-main2-Bk_CgiOM.js new file mode 100644 index 00000000000..b567ba5dac5 --- /dev/null +++ b/test/chunking-form/samples/render-chunk-transform/_expected/system/entry-main2-Bk_CgiOM.js @@ -0,0 +1,12 @@ +import { added } from "./entry-main1-D-6QAEdu.js"; +console.log(added); +System.register([], (function () { + 'use strict'; + return { + execute: (function () { + + console.log('main2'); + + }) + }; +})); diff --git a/test/chunking-form/samples/render-chunk-transform/main1.js b/test/chunking-form/samples/render-chunk-transform/main1.js new file mode 100644 index 00000000000..fda34828717 --- /dev/null +++ b/test/chunking-form/samples/render-chunk-transform/main1.js @@ -0,0 +1 @@ +console.log('main1'); diff --git a/test/chunking-form/samples/render-chunk-transform/main2.js b/test/chunking-form/samples/render-chunk-transform/main2.js new file mode 100644 index 00000000000..ac653633351 --- /dev/null +++ b/test/chunking-form/samples/render-chunk-transform/main2.js @@ -0,0 +1 @@ +console.log('main2'); diff --git a/test/chunking-form/samples/render-chunk/_config.js b/test/chunking-form/samples/render-chunk/_config.js index 6c925c5e62a..2d7328aa4e9 100644 --- a/test/chunking-form/samples/render-chunk/_config.js +++ b/test/chunking-form/samples/render-chunk/_config.js @@ -1,24 +1,33 @@ -const assert = require('assert'); +const assert = require('node:assert'); +const { replaceDirectoryInStringifiedObject } = require('../../../testHelpers'); -module.exports = { - description: 'transforms chunks in the renderChunk hook', +module.exports = defineTest({ + description: + 'transforms chunks in the renderChunk hook, also transforming hashes added in the hook', options: { input: ['main1', 'main2'], plugins: { - renderChunk(code, chunk, options) { - assert.strictEqual(options.chunkFileNames, 'chunk-[name].js'); + transform(code) { + const referenceId = this.emitFile({ type: 'asset', name: 'test', source: 'test' }); + return `${code}\nconsole.log('referenced asset', import.meta.ROLLUP_FILE_URL_${referenceId});`; + }, + renderChunk(code, chunk, options, { chunks }) { + // Ensure the entries in "chunks" reference the actual chunk objects + assert.strictEqual(chunks[chunk.fileName], chunk); return ( code + - `\nconsole.log('fileName', '${chunk.fileName}');` + - `\nconsole.log('imports', '${chunk.imports.join(', ')}');` + - `\nconsole.log('isEntry', ${chunk.isEntry});` + - `\nconsole.log('name', '${chunk.name}');` + - `\nconsole.log('modules.length', ${Object.keys(chunk.modules).length});` + `\nconsole.log(${replaceDirectoryInStringifiedObject(chunk, __dirname)});` + + `\nconsole.log('all chunks', ${JSON.stringify(Object.keys(chunks))})` + + `\nconsole.log('referenced asset in renderChunk', '${this.getFileName( + this.emitFile({ type: 'asset', name: 'test', source: 'test' }) + )}');` ); } }, output: { - chunkFileNames: 'chunk-[name].js' + entryFileNames: 'entry-[name]-[hash].js', + chunkFileNames: 'chunk-[name]-[hash].js', + assetFileNames: 'asset-[name]-[hash][extname]' } } -}; +}); diff --git a/test/chunking-form/samples/render-chunk/_expected/amd/asset-test-C4X7hChn b/test/chunking-form/samples/render-chunk/_expected/amd/asset-test-C4X7hChn new file mode 100644 index 00000000000..30d74d25844 --- /dev/null +++ b/test/chunking-form/samples/render-chunk/_expected/amd/asset-test-C4X7hChn @@ -0,0 +1 @@ +test \ No newline at end of file diff --git a/test/chunking-form/samples/render-chunk/_expected/amd/chunk-dep2-ughyJKkd.js b/test/chunking-form/samples/render-chunk/_expected/amd/chunk-dep2-ughyJKkd.js new file mode 100644 index 00000000000..280851161f3 --- /dev/null +++ b/test/chunking-form/samples/render-chunk/_expected/amd/chunk-dep2-ughyJKkd.js @@ -0,0 +1,43 @@ +define(['require', 'exports'], (function (require, exports) { 'use strict'; + + var num = 2; + console.log('referenced asset', new URL(require.toUrl('./asset-test-C4X7hChn'), document.baseURI).href); + + exports.num = num; + +})); +console.log({ + "exports": [ + "num" + ], + "facadeModuleId": null, + "isDynamicEntry": false, + "isEntry": false, + "isImplicitEntry": false, + "moduleIds": [ + "**/dep2.js" + ], + "name": "dep2", + "type": "chunk", + "dynamicImports": [], + "fileName": "chunk-dep2-ughyJKkd.js", + "implicitlyLoadedBefore": [], + "importedBindings": {}, + "imports": [], + "modules": { + "**/dep2.js": { + "code": "\tvar num = 2;\n\tconsole.log('referenced asset', new URL(require.toUrl('./asset-test-C4X7hChn'), document.baseURI).href);", + "originalLength": 19, + "removedExports": [], + "renderedExports": [ + "num" + ], + "renderedLength": 117 + } + }, + "referencedFiles": [ + "asset-test-C4X7hChn" + ] +}); +console.log('all chunks', ["entry-main1-utR7jRA-.js","entry-main2-CUgn7sNH.js","chunk-dep2-ughyJKkd.js"]) +console.log('referenced asset in renderChunk', 'asset-test-C4X7hChn'); diff --git a/test/chunking-form/samples/render-chunk/_expected/amd/chunk-dep2.js b/test/chunking-form/samples/render-chunk/_expected/amd/chunk-dep2.js deleted file mode 100644 index ab30e5c7536..00000000000 --- a/test/chunking-form/samples/render-chunk/_expected/amd/chunk-dep2.js +++ /dev/null @@ -1,12 +0,0 @@ -define(['exports'], function (exports) { 'use strict'; - - var num = 2; - - exports.num = num; - -}); -console.log('fileName', 'chunk-dep2.js'); -console.log('imports', ''); -console.log('isEntry', false); -console.log('name', 'dep2'); -console.log('modules.length', 1); diff --git a/test/chunking-form/samples/render-chunk/_expected/amd/entry-main1-utR7jRA-.js b/test/chunking-form/samples/render-chunk/_expected/amd/entry-main1-utR7jRA-.js new file mode 100644 index 00000000000..204211dbde1 --- /dev/null +++ b/test/chunking-form/samples/render-chunk/_expected/amd/entry-main1-utR7jRA-.js @@ -0,0 +1,56 @@ +define(['require', './chunk-dep2-ughyJKkd'], (function (require, dep2) { 'use strict'; + + var num = 1; + console.log('referenced asset', new URL(require.toUrl('./asset-test-C4X7hChn'), document.baseURI).href); + + console.log(num + dep2.num); + console.log('referenced asset', new URL(require.toUrl('./asset-test-C4X7hChn'), document.baseURI).href); + +})); +console.log({ + "exports": [], + "facadeModuleId": "**/main1.js", + "isDynamicEntry": false, + "isEntry": true, + "isImplicitEntry": false, + "moduleIds": [ + "**/dep1.js", + "**/main1.js" + ], + "name": "main1", + "type": "chunk", + "dynamicImports": [], + "fileName": "entry-main1-utR7jRA-.js", + "implicitlyLoadedBefore": [], + "importedBindings": { + "chunk-dep2-ughyJKkd.js": [ + "num" + ] + }, + "imports": [ + "chunk-dep2-ughyJKkd.js" + ], + "modules": { + "**/dep1.js": { + "code": "\tvar num = 1;\n\tconsole.log('referenced asset', new URL(require.toUrl('./asset-test-C4X7hChn'), document.baseURI).href);", + "originalLength": 19, + "removedExports": [], + "renderedExports": [ + "num" + ], + "renderedLength": 117 + }, + "**/main1.js": { + "code": "\tconsole.log(num + dep2.num);\n\tconsole.log('referenced asset', new URL(require.toUrl('./asset-test-C4X7hChn'), document.baseURI).href);", + "originalLength": 102, + "removedExports": [], + "renderedExports": [], + "renderedLength": 133 + } + }, + "referencedFiles": [ + "asset-test-C4X7hChn" + ] +}); +console.log('all chunks', ["entry-main1-utR7jRA-.js","entry-main2-CUgn7sNH.js","chunk-dep2-ughyJKkd.js"]) +console.log('referenced asset in renderChunk', 'asset-test-C4X7hChn'); diff --git a/test/chunking-form/samples/render-chunk/_expected/amd/entry-main2-CUgn7sNH.js b/test/chunking-form/samples/render-chunk/_expected/amd/entry-main2-CUgn7sNH.js new file mode 100644 index 00000000000..586c20d5fdf --- /dev/null +++ b/test/chunking-form/samples/render-chunk/_expected/amd/entry-main2-CUgn7sNH.js @@ -0,0 +1,56 @@ +define(['require', './chunk-dep2-ughyJKkd'], (function (require, dep2) { 'use strict'; + + var num = 3; + console.log('referenced asset', new URL(require.toUrl('./asset-test-C4X7hChn'), document.baseURI).href); + + console.log(dep2.num + num); + console.log('referenced asset', new URL(require.toUrl('./asset-test-C4X7hChn'), document.baseURI).href); + +})); +console.log({ + "exports": [], + "facadeModuleId": "**/main2.js", + "isDynamicEntry": false, + "isEntry": true, + "isImplicitEntry": false, + "moduleIds": [ + "**/dep3.js", + "**/main2.js" + ], + "name": "main2", + "type": "chunk", + "dynamicImports": [], + "fileName": "entry-main2-CUgn7sNH.js", + "implicitlyLoadedBefore": [], + "importedBindings": { + "chunk-dep2-ughyJKkd.js": [ + "num" + ] + }, + "imports": [ + "chunk-dep2-ughyJKkd.js" + ], + "modules": { + "**/dep3.js": { + "code": "\tvar num = 3;\n\tconsole.log('referenced asset', new URL(require.toUrl('./asset-test-C4X7hChn'), document.baseURI).href);", + "originalLength": 19, + "removedExports": [], + "renderedExports": [ + "num" + ], + "renderedLength": 117 + }, + "**/main2.js": { + "code": "\tconsole.log(dep2.num + num);\n\tconsole.log('referenced asset', new URL(require.toUrl('./asset-test-C4X7hChn'), document.baseURI).href);", + "originalLength": 102, + "removedExports": [], + "renderedExports": [], + "renderedLength": 133 + } + }, + "referencedFiles": [ + "asset-test-C4X7hChn" + ] +}); +console.log('all chunks', ["entry-main1-utR7jRA-.js","entry-main2-CUgn7sNH.js","chunk-dep2-ughyJKkd.js"]) +console.log('referenced asset in renderChunk', 'asset-test-C4X7hChn'); diff --git a/test/chunking-form/samples/render-chunk/_expected/amd/main1.js b/test/chunking-form/samples/render-chunk/_expected/amd/main1.js deleted file mode 100644 index ea52a11c0f9..00000000000 --- a/test/chunking-form/samples/render-chunk/_expected/amd/main1.js +++ /dev/null @@ -1,12 +0,0 @@ -define(['./chunk-dep2'], function (dep2) { 'use strict'; - - var num = 1; - - console.log(num + dep2.num); - -}); -console.log('fileName', 'main1.js'); -console.log('imports', 'chunk-dep2.js'); -console.log('isEntry', true); -console.log('name', 'main1'); -console.log('modules.length', 2); diff --git a/test/chunking-form/samples/render-chunk/_expected/amd/main2.js b/test/chunking-form/samples/render-chunk/_expected/amd/main2.js deleted file mode 100644 index 9dee74671ae..00000000000 --- a/test/chunking-form/samples/render-chunk/_expected/amd/main2.js +++ /dev/null @@ -1,12 +0,0 @@ -define(['./chunk-dep2'], function (dep2) { 'use strict'; - - var num = 3; - - console.log(dep2.num + num); - -}); -console.log('fileName', 'main2.js'); -console.log('imports', 'chunk-dep2.js'); -console.log('isEntry', true); -console.log('name', 'main2'); -console.log('modules.length', 2); diff --git a/test/chunking-form/samples/render-chunk/_expected/cjs/asset-test-C4X7hChn b/test/chunking-form/samples/render-chunk/_expected/cjs/asset-test-C4X7hChn new file mode 100644 index 00000000000..30d74d25844 --- /dev/null +++ b/test/chunking-form/samples/render-chunk/_expected/cjs/asset-test-C4X7hChn @@ -0,0 +1 @@ +test \ No newline at end of file diff --git a/test/chunking-form/samples/render-chunk/_expected/cjs/chunk-dep2-Cr_zOuBy.js b/test/chunking-form/samples/render-chunk/_expected/cjs/chunk-dep2-Cr_zOuBy.js new file mode 100644 index 00000000000..65cd4727d94 --- /dev/null +++ b/test/chunking-form/samples/render-chunk/_expected/cjs/chunk-dep2-Cr_zOuBy.js @@ -0,0 +1,41 @@ +'use strict'; + +var num = 2; +console.log('referenced asset', (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__dirname + '/asset-test-C4X7hChn').href : new URL('asset-test-C4X7hChn', document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT' && document.currentScript.src || document.baseURI).href)); + +exports.num = num; +console.log({ + "exports": [ + "num" + ], + "facadeModuleId": null, + "isDynamicEntry": false, + "isEntry": false, + "isImplicitEntry": false, + "moduleIds": [ + "**/dep2.js" + ], + "name": "dep2", + "type": "chunk", + "dynamicImports": [], + "fileName": "chunk-dep2-Cr_zOuBy.js", + "implicitlyLoadedBefore": [], + "importedBindings": {}, + "imports": [], + "modules": { + "**/dep2.js": { + "code": "var num = 2;\nconsole.log('referenced asset', (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__dirname + '/asset-test-C4X7hChn').href : new URL('asset-test-C4X7hChn', document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT' && document.currentScript.src || document.baseURI).href));", + "originalLength": 19, + "removedExports": [], + "renderedExports": [ + "num" + ], + "renderedLength": 330 + } + }, + "referencedFiles": [ + "asset-test-C4X7hChn" + ] +}); +console.log('all chunks', ["entry-main1-CW_cw0go.js","entry-main2-CvqsXhWd.js","chunk-dep2-Cr_zOuBy.js"]) +console.log('referenced asset in renderChunk', 'asset-test-C4X7hChn'); diff --git a/test/chunking-form/samples/render-chunk/_expected/cjs/chunk-dep2.js b/test/chunking-form/samples/render-chunk/_expected/cjs/chunk-dep2.js deleted file mode 100644 index ad01f5c7b03..00000000000 --- a/test/chunking-form/samples/render-chunk/_expected/cjs/chunk-dep2.js +++ /dev/null @@ -1,10 +0,0 @@ -'use strict'; - -var num = 2; - -exports.num = num; -console.log('fileName', 'chunk-dep2.js'); -console.log('imports', ''); -console.log('isEntry', false); -console.log('name', 'dep2'); -console.log('modules.length', 1); diff --git a/test/chunking-form/samples/render-chunk/_expected/cjs/entry-main1-CW_cw0go.js b/test/chunking-form/samples/render-chunk/_expected/cjs/entry-main1-CW_cw0go.js new file mode 100644 index 00000000000..a10e73c7c5c --- /dev/null +++ b/test/chunking-form/samples/render-chunk/_expected/cjs/entry-main1-CW_cw0go.js @@ -0,0 +1,56 @@ +'use strict'; + +var dep2 = require('./chunk-dep2-Cr_zOuBy.js'); + +var num = 1; +console.log('referenced asset', (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__dirname + '/asset-test-C4X7hChn').href : new URL('asset-test-C4X7hChn', document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT' && document.currentScript.src || document.baseURI).href)); + +console.log(num + dep2.num); +console.log('referenced asset', (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__dirname + '/asset-test-C4X7hChn').href : new URL('asset-test-C4X7hChn', document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT' && document.currentScript.src || document.baseURI).href)); +console.log({ + "exports": [], + "facadeModuleId": "**/main1.js", + "isDynamicEntry": false, + "isEntry": true, + "isImplicitEntry": false, + "moduleIds": [ + "**/dep1.js", + "**/main1.js" + ], + "name": "main1", + "type": "chunk", + "dynamicImports": [], + "fileName": "entry-main1-CW_cw0go.js", + "implicitlyLoadedBefore": [], + "importedBindings": { + "chunk-dep2-Cr_zOuBy.js": [ + "num" + ] + }, + "imports": [ + "chunk-dep2-Cr_zOuBy.js" + ], + "modules": { + "**/dep1.js": { + "code": "var num = 1;\nconsole.log('referenced asset', (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__dirname + '/asset-test-C4X7hChn').href : new URL('asset-test-C4X7hChn', document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT' && document.currentScript.src || document.baseURI).href));", + "originalLength": 19, + "removedExports": [], + "renderedExports": [ + "num" + ], + "renderedLength": 330 + }, + "**/main1.js": { + "code": "console.log(num + dep2.num);\nconsole.log('referenced asset', (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__dirname + '/asset-test-C4X7hChn').href : new URL('asset-test-C4X7hChn', document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT' && document.currentScript.src || document.baseURI).href));", + "originalLength": 102, + "removedExports": [], + "renderedExports": [], + "renderedLength": 346 + } + }, + "referencedFiles": [ + "asset-test-C4X7hChn" + ] +}); +console.log('all chunks', ["entry-main1-CW_cw0go.js","entry-main2-CvqsXhWd.js","chunk-dep2-Cr_zOuBy.js"]) +console.log('referenced asset in renderChunk', 'asset-test-C4X7hChn'); diff --git a/test/chunking-form/samples/render-chunk/_expected/cjs/entry-main2-CvqsXhWd.js b/test/chunking-form/samples/render-chunk/_expected/cjs/entry-main2-CvqsXhWd.js new file mode 100644 index 00000000000..95904e0384c --- /dev/null +++ b/test/chunking-form/samples/render-chunk/_expected/cjs/entry-main2-CvqsXhWd.js @@ -0,0 +1,56 @@ +'use strict'; + +var dep2 = require('./chunk-dep2-Cr_zOuBy.js'); + +var num = 3; +console.log('referenced asset', (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__dirname + '/asset-test-C4X7hChn').href : new URL('asset-test-C4X7hChn', document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT' && document.currentScript.src || document.baseURI).href)); + +console.log(dep2.num + num); +console.log('referenced asset', (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__dirname + '/asset-test-C4X7hChn').href : new URL('asset-test-C4X7hChn', document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT' && document.currentScript.src || document.baseURI).href)); +console.log({ + "exports": [], + "facadeModuleId": "**/main2.js", + "isDynamicEntry": false, + "isEntry": true, + "isImplicitEntry": false, + "moduleIds": [ + "**/dep3.js", + "**/main2.js" + ], + "name": "main2", + "type": "chunk", + "dynamicImports": [], + "fileName": "entry-main2-CvqsXhWd.js", + "implicitlyLoadedBefore": [], + "importedBindings": { + "chunk-dep2-Cr_zOuBy.js": [ + "num" + ] + }, + "imports": [ + "chunk-dep2-Cr_zOuBy.js" + ], + "modules": { + "**/dep3.js": { + "code": "var num = 3;\nconsole.log('referenced asset', (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__dirname + '/asset-test-C4X7hChn').href : new URL('asset-test-C4X7hChn', document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT' && document.currentScript.src || document.baseURI).href));", + "originalLength": 19, + "removedExports": [], + "renderedExports": [ + "num" + ], + "renderedLength": 330 + }, + "**/main2.js": { + "code": "console.log(dep2.num + num);\nconsole.log('referenced asset', (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__dirname + '/asset-test-C4X7hChn').href : new URL('asset-test-C4X7hChn', document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT' && document.currentScript.src || document.baseURI).href));", + "originalLength": 102, + "removedExports": [], + "renderedExports": [], + "renderedLength": 346 + } + }, + "referencedFiles": [ + "asset-test-C4X7hChn" + ] +}); +console.log('all chunks', ["entry-main1-CW_cw0go.js","entry-main2-CvqsXhWd.js","chunk-dep2-Cr_zOuBy.js"]) +console.log('referenced asset in renderChunk', 'asset-test-C4X7hChn'); diff --git a/test/chunking-form/samples/render-chunk/_expected/cjs/main1.js b/test/chunking-form/samples/render-chunk/_expected/cjs/main1.js deleted file mode 100644 index 86d308be0b0..00000000000 --- a/test/chunking-form/samples/render-chunk/_expected/cjs/main1.js +++ /dev/null @@ -1,12 +0,0 @@ -'use strict'; - -var dep2 = require('./chunk-dep2.js'); - -var num = 1; - -console.log(num + dep2.num); -console.log('fileName', 'main1.js'); -console.log('imports', 'chunk-dep2.js'); -console.log('isEntry', true); -console.log('name', 'main1'); -console.log('modules.length', 2); diff --git a/test/chunking-form/samples/render-chunk/_expected/cjs/main2.js b/test/chunking-form/samples/render-chunk/_expected/cjs/main2.js deleted file mode 100644 index f142d493e16..00000000000 --- a/test/chunking-form/samples/render-chunk/_expected/cjs/main2.js +++ /dev/null @@ -1,12 +0,0 @@ -'use strict'; - -var dep2 = require('./chunk-dep2.js'); - -var num = 3; - -console.log(dep2.num + num); -console.log('fileName', 'main2.js'); -console.log('imports', 'chunk-dep2.js'); -console.log('isEntry', true); -console.log('name', 'main2'); -console.log('modules.length', 2); diff --git a/test/chunking-form/samples/render-chunk/_expected/es/asset-test-C4X7hChn b/test/chunking-form/samples/render-chunk/_expected/es/asset-test-C4X7hChn new file mode 100644 index 00000000000..30d74d25844 --- /dev/null +++ b/test/chunking-form/samples/render-chunk/_expected/es/asset-test-C4X7hChn @@ -0,0 +1 @@ +test \ No newline at end of file diff --git a/test/chunking-form/samples/render-chunk/_expected/es/chunk-dep2-CQDaPkp1.js b/test/chunking-form/samples/render-chunk/_expected/es/chunk-dep2-CQDaPkp1.js new file mode 100644 index 00000000000..6f2a7b74446 --- /dev/null +++ b/test/chunking-form/samples/render-chunk/_expected/es/chunk-dep2-CQDaPkp1.js @@ -0,0 +1,39 @@ +var num = 2; +console.log('referenced asset', new URL('asset-test-C4X7hChn', import.meta.url).href); + +export { num as n }; +console.log({ + "exports": [ + "n" + ], + "facadeModuleId": null, + "isDynamicEntry": false, + "isEntry": false, + "isImplicitEntry": false, + "moduleIds": [ + "**/dep2.js" + ], + "name": "dep2", + "type": "chunk", + "dynamicImports": [], + "fileName": "chunk-dep2-CQDaPkp1.js", + "implicitlyLoadedBefore": [], + "importedBindings": {}, + "imports": [], + "modules": { + "**/dep2.js": { + "code": "var num = 2;\nconsole.log('referenced asset', new URL('asset-test-C4X7hChn', import.meta.url).href);", + "originalLength": 19, + "removedExports": [], + "renderedExports": [ + "num" + ], + "renderedLength": 99 + } + }, + "referencedFiles": [ + "asset-test-C4X7hChn" + ] +}); +console.log('all chunks', ["entry-main1-Ckv7K5sz.js","entry-main2-Ckd5ikIS.js","chunk-dep2-CQDaPkp1.js"]) +console.log('referenced asset in renderChunk', 'asset-test-C4X7hChn'); diff --git a/test/chunking-form/samples/render-chunk/_expected/es/chunk-dep2.js b/test/chunking-form/samples/render-chunk/_expected/es/chunk-dep2.js deleted file mode 100644 index 20ae277758e..00000000000 --- a/test/chunking-form/samples/render-chunk/_expected/es/chunk-dep2.js +++ /dev/null @@ -1,8 +0,0 @@ -var num = 2; - -export { num as n }; -console.log('fileName', 'chunk-dep2.js'); -console.log('imports', ''); -console.log('isEntry', false); -console.log('name', 'dep2'); -console.log('modules.length', 1); diff --git a/test/chunking-form/samples/render-chunk/_expected/es/entry-main1-Ckv7K5sz.js b/test/chunking-form/samples/render-chunk/_expected/es/entry-main1-Ckv7K5sz.js new file mode 100644 index 00000000000..671376f4b31 --- /dev/null +++ b/test/chunking-form/samples/render-chunk/_expected/es/entry-main1-Ckv7K5sz.js @@ -0,0 +1,54 @@ +import { n as num$1 } from './chunk-dep2-CQDaPkp1.js'; + +var num = 1; +console.log('referenced asset', new URL('asset-test-C4X7hChn', import.meta.url).href); + +console.log(num + num$1); +console.log('referenced asset', new URL('asset-test-C4X7hChn', import.meta.url).href); +console.log({ + "exports": [], + "facadeModuleId": "**/main1.js", + "isDynamicEntry": false, + "isEntry": true, + "isImplicitEntry": false, + "moduleIds": [ + "**/dep1.js", + "**/main1.js" + ], + "name": "main1", + "type": "chunk", + "dynamicImports": [], + "fileName": "entry-main1-Ckv7K5sz.js", + "implicitlyLoadedBefore": [], + "importedBindings": { + "chunk-dep2-CQDaPkp1.js": [ + "n" + ] + }, + "imports": [ + "chunk-dep2-CQDaPkp1.js" + ], + "modules": { + "**/dep1.js": { + "code": "var num = 1;\nconsole.log('referenced asset', new URL('asset-test-C4X7hChn', import.meta.url).href);", + "originalLength": 19, + "removedExports": [], + "renderedExports": [ + "num" + ], + "renderedLength": 99 + }, + "**/main1.js": { + "code": "console.log(num + num$1);\nconsole.log('referenced asset', new URL('asset-test-C4X7hChn', import.meta.url).href);", + "originalLength": 102, + "removedExports": [], + "renderedExports": [], + "renderedLength": 112 + } + }, + "referencedFiles": [ + "asset-test-C4X7hChn" + ] +}); +console.log('all chunks', ["entry-main1-Ckv7K5sz.js","entry-main2-Ckd5ikIS.js","chunk-dep2-CQDaPkp1.js"]) +console.log('referenced asset in renderChunk', 'asset-test-C4X7hChn'); diff --git a/test/chunking-form/samples/render-chunk/_expected/es/entry-main2-Ckd5ikIS.js b/test/chunking-form/samples/render-chunk/_expected/es/entry-main2-Ckd5ikIS.js new file mode 100644 index 00000000000..0f9ec667370 --- /dev/null +++ b/test/chunking-form/samples/render-chunk/_expected/es/entry-main2-Ckd5ikIS.js @@ -0,0 +1,54 @@ +import { n as num$1 } from './chunk-dep2-CQDaPkp1.js'; + +var num = 3; +console.log('referenced asset', new URL('asset-test-C4X7hChn', import.meta.url).href); + +console.log(num$1 + num); +console.log('referenced asset', new URL('asset-test-C4X7hChn', import.meta.url).href); +console.log({ + "exports": [], + "facadeModuleId": "**/main2.js", + "isDynamicEntry": false, + "isEntry": true, + "isImplicitEntry": false, + "moduleIds": [ + "**/dep3.js", + "**/main2.js" + ], + "name": "main2", + "type": "chunk", + "dynamicImports": [], + "fileName": "entry-main2-Ckd5ikIS.js", + "implicitlyLoadedBefore": [], + "importedBindings": { + "chunk-dep2-CQDaPkp1.js": [ + "n" + ] + }, + "imports": [ + "chunk-dep2-CQDaPkp1.js" + ], + "modules": { + "**/dep3.js": { + "code": "var num = 3;\nconsole.log('referenced asset', new URL('asset-test-C4X7hChn', import.meta.url).href);", + "originalLength": 19, + "removedExports": [], + "renderedExports": [ + "num" + ], + "renderedLength": 99 + }, + "**/main2.js": { + "code": "console.log(num$1 + num);\nconsole.log('referenced asset', new URL('asset-test-C4X7hChn', import.meta.url).href);", + "originalLength": 102, + "removedExports": [], + "renderedExports": [], + "renderedLength": 112 + } + }, + "referencedFiles": [ + "asset-test-C4X7hChn" + ] +}); +console.log('all chunks', ["entry-main1-Ckv7K5sz.js","entry-main2-Ckd5ikIS.js","chunk-dep2-CQDaPkp1.js"]) +console.log('referenced asset in renderChunk', 'asset-test-C4X7hChn'); diff --git a/test/chunking-form/samples/render-chunk/_expected/es/main1.js b/test/chunking-form/samples/render-chunk/_expected/es/main1.js deleted file mode 100644 index c4b243a3998..00000000000 --- a/test/chunking-form/samples/render-chunk/_expected/es/main1.js +++ /dev/null @@ -1,10 +0,0 @@ -import { n as num$1 } from './chunk-dep2.js'; - -var num = 1; - -console.log(num + num$1); -console.log('fileName', 'main1.js'); -console.log('imports', 'chunk-dep2.js'); -console.log('isEntry', true); -console.log('name', 'main1'); -console.log('modules.length', 2); diff --git a/test/chunking-form/samples/render-chunk/_expected/es/main2.js b/test/chunking-form/samples/render-chunk/_expected/es/main2.js deleted file mode 100644 index 2666225853f..00000000000 --- a/test/chunking-form/samples/render-chunk/_expected/es/main2.js +++ /dev/null @@ -1,10 +0,0 @@ -import { n as num$1 } from './chunk-dep2.js'; - -var num = 3; - -console.log(num$1 + num); -console.log('fileName', 'main2.js'); -console.log('imports', 'chunk-dep2.js'); -console.log('isEntry', true); -console.log('name', 'main2'); -console.log('modules.length', 2); diff --git a/test/chunking-form/samples/render-chunk/_expected/system/asset-test-C4X7hChn b/test/chunking-form/samples/render-chunk/_expected/system/asset-test-C4X7hChn new file mode 100644 index 00000000000..30d74d25844 --- /dev/null +++ b/test/chunking-form/samples/render-chunk/_expected/system/asset-test-C4X7hChn @@ -0,0 +1 @@ +test \ No newline at end of file diff --git a/test/chunking-form/samples/render-chunk/_expected/system/chunk-dep2-C9ddpexS.js b/test/chunking-form/samples/render-chunk/_expected/system/chunk-dep2-C9ddpexS.js new file mode 100644 index 00000000000..43d81893192 --- /dev/null +++ b/test/chunking-form/samples/render-chunk/_expected/system/chunk-dep2-C9ddpexS.js @@ -0,0 +1,46 @@ +System.register([], (function (exports, module) { + 'use strict'; + return { + execute: (function () { + + var num = exports("n", 2); + console.log('referenced asset', new URL('asset-test-C4X7hChn', module.meta.url).href); + + }) + }; +})); +console.log({ + "exports": [ + "n" + ], + "facadeModuleId": null, + "isDynamicEntry": false, + "isEntry": false, + "isImplicitEntry": false, + "moduleIds": [ + "**/dep2.js" + ], + "name": "dep2", + "type": "chunk", + "dynamicImports": [], + "fileName": "chunk-dep2-C9ddpexS.js", + "implicitlyLoadedBefore": [], + "importedBindings": {}, + "imports": [], + "modules": { + "**/dep2.js": { + "code": "\t\t\tvar num = exports(\"n\", 2);\n\t\t\tconsole.log('referenced asset', new URL('asset-test-C4X7hChn', module.meta.url).href);", + "originalLength": 19, + "removedExports": [], + "renderedExports": [ + "num" + ], + "renderedLength": 113 + } + }, + "referencedFiles": [ + "asset-test-C4X7hChn" + ] +}); +console.log('all chunks', ["entry-main1-Jmzu7nOJ.js","entry-main2-ByL47NtH.js","chunk-dep2-C9ddpexS.js"]) +console.log('referenced asset in renderChunk', 'asset-test-C4X7hChn'); diff --git a/test/chunking-form/samples/render-chunk/_expected/system/chunk-dep2.js b/test/chunking-form/samples/render-chunk/_expected/system/chunk-dep2.js deleted file mode 100644 index e408a3daf21..00000000000 --- a/test/chunking-form/samples/render-chunk/_expected/system/chunk-dep2.js +++ /dev/null @@ -1,15 +0,0 @@ -System.register([], function (exports) { - 'use strict'; - return { - execute: function () { - - var num = exports('n', 2); - - } - }; -}); -console.log('fileName', 'chunk-dep2.js'); -console.log('imports', ''); -console.log('isEntry', false); -console.log('name', 'dep2'); -console.log('modules.length', 1); diff --git a/test/chunking-form/samples/render-chunk/_expected/system/entry-main1-Jmzu7nOJ.js b/test/chunking-form/samples/render-chunk/_expected/system/entry-main1-Jmzu7nOJ.js new file mode 100644 index 00000000000..3bc647d2122 --- /dev/null +++ b/test/chunking-form/samples/render-chunk/_expected/system/entry-main1-Jmzu7nOJ.js @@ -0,0 +1,65 @@ +System.register(['./chunk-dep2-C9ddpexS.js'], (function (exports, module) { + 'use strict'; + var num$1; + return { + setters: [function (module) { + num$1 = module.n; + }], + execute: (function () { + + var num = 1; + console.log('referenced asset', new URL('asset-test-C4X7hChn', module.meta.url).href); + + console.log(num + num$1); + console.log('referenced asset', new URL('asset-test-C4X7hChn', module.meta.url).href); + + }) + }; +})); +console.log({ + "exports": [], + "facadeModuleId": "**/main1.js", + "isDynamicEntry": false, + "isEntry": true, + "isImplicitEntry": false, + "moduleIds": [ + "**/dep1.js", + "**/main1.js" + ], + "name": "main1", + "type": "chunk", + "dynamicImports": [], + "fileName": "entry-main1-Jmzu7nOJ.js", + "implicitlyLoadedBefore": [], + "importedBindings": { + "chunk-dep2-C9ddpexS.js": [ + "n" + ] + }, + "imports": [ + "chunk-dep2-C9ddpexS.js" + ], + "modules": { + "**/dep1.js": { + "code": "\t\t\tvar num = 1;\n\t\t\tconsole.log('referenced asset', new URL('asset-test-C4X7hChn', module.meta.url).href);", + "originalLength": 19, + "removedExports": [], + "renderedExports": [ + "num" + ], + "renderedLength": 99 + }, + "**/main1.js": { + "code": "\t\t\tconsole.log(num + num$1);\n\t\t\tconsole.log('referenced asset', new URL('asset-test-C4X7hChn', module.meta.url).href);", + "originalLength": 102, + "removedExports": [], + "renderedExports": [], + "renderedLength": 112 + } + }, + "referencedFiles": [ + "asset-test-C4X7hChn" + ] +}); +console.log('all chunks', ["entry-main1-Jmzu7nOJ.js","entry-main2-ByL47NtH.js","chunk-dep2-C9ddpexS.js"]) +console.log('referenced asset in renderChunk', 'asset-test-C4X7hChn'); diff --git a/test/chunking-form/samples/render-chunk/_expected/system/entry-main2-ByL47NtH.js b/test/chunking-form/samples/render-chunk/_expected/system/entry-main2-ByL47NtH.js new file mode 100644 index 00000000000..dcdefe3374d --- /dev/null +++ b/test/chunking-form/samples/render-chunk/_expected/system/entry-main2-ByL47NtH.js @@ -0,0 +1,65 @@ +System.register(['./chunk-dep2-C9ddpexS.js'], (function (exports, module) { + 'use strict'; + var num$1; + return { + setters: [function (module) { + num$1 = module.n; + }], + execute: (function () { + + var num = 3; + console.log('referenced asset', new URL('asset-test-C4X7hChn', module.meta.url).href); + + console.log(num$1 + num); + console.log('referenced asset', new URL('asset-test-C4X7hChn', module.meta.url).href); + + }) + }; +})); +console.log({ + "exports": [], + "facadeModuleId": "**/main2.js", + "isDynamicEntry": false, + "isEntry": true, + "isImplicitEntry": false, + "moduleIds": [ + "**/dep3.js", + "**/main2.js" + ], + "name": "main2", + "type": "chunk", + "dynamicImports": [], + "fileName": "entry-main2-ByL47NtH.js", + "implicitlyLoadedBefore": [], + "importedBindings": { + "chunk-dep2-C9ddpexS.js": [ + "n" + ] + }, + "imports": [ + "chunk-dep2-C9ddpexS.js" + ], + "modules": { + "**/dep3.js": { + "code": "\t\t\tvar num = 3;\n\t\t\tconsole.log('referenced asset', new URL('asset-test-C4X7hChn', module.meta.url).href);", + "originalLength": 19, + "removedExports": [], + "renderedExports": [ + "num" + ], + "renderedLength": 99 + }, + "**/main2.js": { + "code": "\t\t\tconsole.log(num$1 + num);\n\t\t\tconsole.log('referenced asset', new URL('asset-test-C4X7hChn', module.meta.url).href);", + "originalLength": 102, + "removedExports": [], + "renderedExports": [], + "renderedLength": 112 + } + }, + "referencedFiles": [ + "asset-test-C4X7hChn" + ] +}); +console.log('all chunks', ["entry-main1-Jmzu7nOJ.js","entry-main2-ByL47NtH.js","chunk-dep2-C9ddpexS.js"]) +console.log('referenced asset in renderChunk', 'asset-test-C4X7hChn'); diff --git a/test/chunking-form/samples/render-chunk/_expected/system/main1.js b/test/chunking-form/samples/render-chunk/_expected/system/main1.js deleted file mode 100644 index 4120600f1c7..00000000000 --- a/test/chunking-form/samples/render-chunk/_expected/system/main1.js +++ /dev/null @@ -1,21 +0,0 @@ -System.register(['./chunk-dep2.js'], function () { - 'use strict'; - var num$1; - return { - setters: [function (module) { - num$1 = module.n; - }], - execute: function () { - - var num = 1; - - console.log(num + num$1); - - } - }; -}); -console.log('fileName', 'main1.js'); -console.log('imports', 'chunk-dep2.js'); -console.log('isEntry', true); -console.log('name', 'main1'); -console.log('modules.length', 2); diff --git a/test/chunking-form/samples/render-chunk/_expected/system/main2.js b/test/chunking-form/samples/render-chunk/_expected/system/main2.js deleted file mode 100644 index 952563b2e78..00000000000 --- a/test/chunking-form/samples/render-chunk/_expected/system/main2.js +++ /dev/null @@ -1,21 +0,0 @@ -System.register(['./chunk-dep2.js'], function () { - 'use strict'; - var num$1; - return { - setters: [function (module) { - num$1 = module.n; - }], - execute: function () { - - var num = 3; - - console.log(num$1 + num); - - } - }; -}); -console.log('fileName', 'main2.js'); -console.log('imports', 'chunk-dep2.js'); -console.log('isEntry', true); -console.log('name', 'main2'); -console.log('modules.length', 2); diff --git a/test/chunking-form/samples/render-dynamic-import-extended/_config.js b/test/chunking-form/samples/render-dynamic-import-extended/_config.js new file mode 100644 index 00000000000..b90f38c6277 --- /dev/null +++ b/test/chunking-form/samples/render-dynamic-import-extended/_config.js @@ -0,0 +1,26 @@ +module.exports = defineTest({ + description: 'supports extended custom rendering for dynamic imports', + options: { + output: { + manualChunks(id) { + if (id.includes('leaf')) return 'leaf'; + } + }, + external: ['external-module'], + plugins: { + name: 'test-plugin', + renderDynamicImport({ format, chunk, targetChunk, getTargetChunkImports }) { + const transitiveImports = getTargetChunkImports(); + const resolvedImports = transitiveImports + ? Object.fromEntries( + getTargetChunkImports().map(chunk => [chunk.fileName, chunk.resolvedImportPath]) + ) + : null; + return { + left: `${format}DynamicImportPreload(`, + right: `, ${JSON.stringify(resolvedImports)}, ${JSON.stringify(chunk?.fileName ?? null)}, ${JSON.stringify(targetChunk?.fileName ?? null)})` + }; + } + } + } +}); diff --git a/test/chunking-form/samples/render-dynamic-import-extended/_expected/amd/generated-chain-2.js b/test/chunking-form/samples/render-dynamic-import-extended/_expected/amd/generated-chain-2.js new file mode 100644 index 00000000000..43019de85b0 --- /dev/null +++ b/test/chunking-form/samples/render-dynamic-import-extended/_expected/amd/generated-chain-2.js @@ -0,0 +1,9 @@ +define(['exports', './generated-leaf'], (function (exports, leaf) { 'use strict'; + + const four = leaf.three + 1; + var fortyTwo = 42; + + exports.default = fortyTwo; + exports.four = four; + +})); diff --git a/test/chunking-form/samples/render-dynamic-import-extended/_expected/amd/generated-chain-3.js b/test/chunking-form/samples/render-dynamic-import-extended/_expected/amd/generated-chain-3.js new file mode 100644 index 00000000000..d2a5f5bf842 --- /dev/null +++ b/test/chunking-form/samples/render-dynamic-import-extended/_expected/amd/generated-chain-3.js @@ -0,0 +1,5 @@ +define(['./generated-chain-2', './generated-leaf'], (function (chain2, leaf) { 'use strict'; + + console.log('from import:', chain2.default, chain2.four); + +})); diff --git a/test/chunking-form/samples/render-dynamic-import-extended/_expected/amd/generated-imports-external.js b/test/chunking-form/samples/render-dynamic-import-extended/_expected/amd/generated-imports-external.js new file mode 100644 index 00000000000..69bcbba106b --- /dev/null +++ b/test/chunking-form/samples/render-dynamic-import-extended/_expected/amd/generated-imports-external.js @@ -0,0 +1,26 @@ +define(['exports', 'external-module'], (function (exports, externalModule) { 'use strict'; + + function _interopNamespaceDefault(e) { + var n = Object.create(null); + if (e) { + Object.keys(e).forEach(function (k) { + if (k !== 'default') { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + } + n.default = e; + return Object.freeze(n); + } + + var externalModule__namespace = /*#__PURE__*/_interopNamespaceDefault(externalModule); + + + + exports.fromExternal = externalModule__namespace; + +})); diff --git a/test/chunking-form/samples/render-dynamic-import-extended/_expected/amd/generated-leaf.js b/test/chunking-form/samples/render-dynamic-import-extended/_expected/amd/generated-leaf.js new file mode 100644 index 00000000000..9d890746f98 --- /dev/null +++ b/test/chunking-form/samples/render-dynamic-import-extended/_expected/amd/generated-leaf.js @@ -0,0 +1,7 @@ +define(['exports'], (function (exports) { 'use strict'; + + var three = 3; + + exports.three = three; + +})); diff --git a/test/chunking-form/samples/render-dynamic-import-extended/_expected/amd/main.js b/test/chunking-form/samples/render-dynamic-import-extended/_expected/amd/main.js new file mode 100644 index 00000000000..bd6445cbd80 --- /dev/null +++ b/test/chunking-form/samples/render-dynamic-import-extended/_expected/amd/main.js @@ -0,0 +1,9 @@ +define(['require'], (function (require) { 'use strict'; + + amdDynamicImportPreload('./generated-chain-3', {"generated-chain-2.js":"'./generated-chain-2'","generated-leaf.js":"'./generated-leaf'"}, "main.js", "generated-chain-3.js"); + amdDynamicImportPreload('./generated-chain-2', {"generated-leaf.js":"'./generated-leaf'"}, "main.js", "generated-chain-2.js"); + amdDynamicImportPreload(somethingElse, null, "main.js", null); + amdDynamicImportPreload('external-module', null, "main.js", null); + amdDynamicImportPreload('./generated-imports-external', {"external-module":"'external-module'"}, "main.js", "generated-imports-external.js"); + +})); diff --git a/test/chunking-form/samples/render-dynamic-import-extended/_expected/cjs/generated-chain-2.js b/test/chunking-form/samples/render-dynamic-import-extended/_expected/cjs/generated-chain-2.js new file mode 100644 index 00000000000..0c45d05f94e --- /dev/null +++ b/test/chunking-form/samples/render-dynamic-import-extended/_expected/cjs/generated-chain-2.js @@ -0,0 +1,9 @@ +'use strict'; + +var leaf = require('./generated-leaf.js'); + +const four = leaf.three + 1; +var fortyTwo = 42; + +exports.default = fortyTwo; +exports.four = four; diff --git a/test/chunking-form/samples/render-dynamic-import-extended/_expected/cjs/generated-chain-3.js b/test/chunking-form/samples/render-dynamic-import-extended/_expected/cjs/generated-chain-3.js new file mode 100644 index 00000000000..e270b236b78 --- /dev/null +++ b/test/chunking-form/samples/render-dynamic-import-extended/_expected/cjs/generated-chain-3.js @@ -0,0 +1,6 @@ +'use strict'; + +var chain2 = require('./generated-chain-2.js'); +require('./generated-leaf.js'); + +console.log('from import:', chain2.default, chain2.four); diff --git a/test/chunking-form/samples/render-dynamic-import-extended/_expected/cjs/generated-imports-external.js b/test/chunking-form/samples/render-dynamic-import-extended/_expected/cjs/generated-imports-external.js new file mode 100644 index 00000000000..80836fa33b2 --- /dev/null +++ b/test/chunking-form/samples/render-dynamic-import-extended/_expected/cjs/generated-imports-external.js @@ -0,0 +1,26 @@ +'use strict'; + +var externalModule = require('external-module'); + +function _interopNamespaceDefault(e) { + var n = Object.create(null); + if (e) { + Object.keys(e).forEach(function (k) { + if (k !== 'default') { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + } + n.default = e; + return Object.freeze(n); +} + +var externalModule__namespace = /*#__PURE__*/_interopNamespaceDefault(externalModule); + + + +exports.fromExternal = externalModule__namespace; diff --git a/test/chunking-form/samples/render-dynamic-import-extended/_expected/cjs/generated-leaf.js b/test/chunking-form/samples/render-dynamic-import-extended/_expected/cjs/generated-leaf.js new file mode 100644 index 00000000000..e8bd4a62928 --- /dev/null +++ b/test/chunking-form/samples/render-dynamic-import-extended/_expected/cjs/generated-leaf.js @@ -0,0 +1,5 @@ +'use strict'; + +var three = 3; + +exports.three = three; diff --git a/test/chunking-form/samples/render-dynamic-import-extended/_expected/cjs/main.js b/test/chunking-form/samples/render-dynamic-import-extended/_expected/cjs/main.js new file mode 100644 index 00000000000..c7391885434 --- /dev/null +++ b/test/chunking-form/samples/render-dynamic-import-extended/_expected/cjs/main.js @@ -0,0 +1,7 @@ +'use strict'; + +cjsDynamicImportPreload('./generated-chain-3.js', {"generated-chain-2.js":"'./generated-chain-2.js'","generated-leaf.js":"'./generated-leaf.js'"}, "main.js", "generated-chain-3.js"); +cjsDynamicImportPreload('./generated-chain-2.js', {"generated-leaf.js":"'./generated-leaf.js'"}, "main.js", "generated-chain-2.js"); +cjsDynamicImportPreload(somethingElse, null, "main.js", null); +cjsDynamicImportPreload('external-module', null, "main.js", null); +cjsDynamicImportPreload('./generated-imports-external.js', {"external-module":"'external-module'"}, "main.js", "generated-imports-external.js"); diff --git a/test/chunking-form/samples/render-dynamic-import-extended/_expected/es/generated-chain-2.js b/test/chunking-form/samples/render-dynamic-import-extended/_expected/es/generated-chain-2.js new file mode 100644 index 00000000000..37e754b15f7 --- /dev/null +++ b/test/chunking-form/samples/render-dynamic-import-extended/_expected/es/generated-chain-2.js @@ -0,0 +1,6 @@ +import { t as three } from './generated-leaf.js'; + +const four = three + 1; +var fortyTwo = 42; + +export { fortyTwo as default, four }; diff --git a/test/chunking-form/samples/render-dynamic-import-extended/_expected/es/generated-chain-3.js b/test/chunking-form/samples/render-dynamic-import-extended/_expected/es/generated-chain-3.js new file mode 100644 index 00000000000..861676c8e19 --- /dev/null +++ b/test/chunking-form/samples/render-dynamic-import-extended/_expected/es/generated-chain-3.js @@ -0,0 +1,4 @@ +import fortyTwo, { four } from './generated-chain-2.js'; +import './generated-leaf.js'; + +console.log('from import:', fortyTwo, four); diff --git a/test/chunking-form/samples/render-dynamic-import-extended/_expected/es/generated-imports-external.js b/test/chunking-form/samples/render-dynamic-import-extended/_expected/es/generated-imports-external.js new file mode 100644 index 00000000000..8e668df8a1a --- /dev/null +++ b/test/chunking-form/samples/render-dynamic-import-extended/_expected/es/generated-imports-external.js @@ -0,0 +1,2 @@ +import * as externalModule from 'external-module'; +export { externalModule as fromExternal }; diff --git a/test/chunking-form/samples/render-dynamic-import-extended/_expected/es/generated-leaf.js b/test/chunking-form/samples/render-dynamic-import-extended/_expected/es/generated-leaf.js new file mode 100644 index 00000000000..f87639251be --- /dev/null +++ b/test/chunking-form/samples/render-dynamic-import-extended/_expected/es/generated-leaf.js @@ -0,0 +1,3 @@ +var three = 3; + +export { three as t }; diff --git a/test/chunking-form/samples/render-dynamic-import-extended/_expected/es/main.js b/test/chunking-form/samples/render-dynamic-import-extended/_expected/es/main.js new file mode 100644 index 00000000000..ab5a839e5a7 --- /dev/null +++ b/test/chunking-form/samples/render-dynamic-import-extended/_expected/es/main.js @@ -0,0 +1,5 @@ +esDynamicImportPreload('./generated-chain-3.js', {"generated-chain-2.js":"'./generated-chain-2.js'","generated-leaf.js":"'./generated-leaf.js'"}, "main.js", "generated-chain-3.js"); +esDynamicImportPreload('./generated-chain-2.js', {"generated-leaf.js":"'./generated-leaf.js'"}, "main.js", "generated-chain-2.js"); +esDynamicImportPreload(somethingElse, null, "main.js", null); +esDynamicImportPreload('external-module', null, "main.js", null); +esDynamicImportPreload('./generated-imports-external.js', {"external-module":"'external-module'"}, "main.js", "generated-imports-external.js"); diff --git a/test/chunking-form/samples/render-dynamic-import-extended/_expected/system/generated-chain-2.js b/test/chunking-form/samples/render-dynamic-import-extended/_expected/system/generated-chain-2.js new file mode 100644 index 00000000000..4552092a8dc --- /dev/null +++ b/test/chunking-form/samples/render-dynamic-import-extended/_expected/system/generated-chain-2.js @@ -0,0 +1,15 @@ +System.register(['./generated-leaf.js'], (function (exports) { + 'use strict'; + var three; + return { + setters: [function (module) { + three = module.t; + }], + execute: (function () { + + const four = exports("four", three + 1); + var fortyTwo = exports("default", 42); + + }) + }; +})); diff --git a/test/chunking-form/samples/render-dynamic-import-extended/_expected/system/generated-chain-3.js b/test/chunking-form/samples/render-dynamic-import-extended/_expected/system/generated-chain-3.js new file mode 100644 index 00000000000..eb301798efa --- /dev/null +++ b/test/chunking-form/samples/render-dynamic-import-extended/_expected/system/generated-chain-3.js @@ -0,0 +1,15 @@ +System.register(['./generated-chain-2.js', './generated-leaf.js'], (function () { + 'use strict'; + var fortyTwo, four; + return { + setters: [function (module) { + fortyTwo = module.default; + four = module.four; + }, null], + execute: (function () { + + console.log('from import:', fortyTwo, four); + + }) + }; +})); diff --git a/test/chunking-form/samples/render-dynamic-import-extended/_expected/system/generated-imports-external.js b/test/chunking-form/samples/render-dynamic-import-extended/_expected/system/generated-imports-external.js new file mode 100644 index 00000000000..c7c2317756f --- /dev/null +++ b/test/chunking-form/samples/render-dynamic-import-extended/_expected/system/generated-imports-external.js @@ -0,0 +1,13 @@ +System.register(['external-module'], (function (exports) { + 'use strict'; + return { + setters: [function (module) { + exports("fromExternal", module); + }], + execute: (function () { + + + + }) + }; +})); diff --git a/test/chunking-form/samples/render-dynamic-import-extended/_expected/system/generated-leaf.js b/test/chunking-form/samples/render-dynamic-import-extended/_expected/system/generated-leaf.js new file mode 100644 index 00000000000..c3814211d6b --- /dev/null +++ b/test/chunking-form/samples/render-dynamic-import-extended/_expected/system/generated-leaf.js @@ -0,0 +1,10 @@ +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + + var three = exports("t", 3); + + }) + }; +})); diff --git a/test/chunking-form/samples/render-dynamic-import-extended/_expected/system/main.js b/test/chunking-form/samples/render-dynamic-import-extended/_expected/system/main.js new file mode 100644 index 00000000000..a5935983a50 --- /dev/null +++ b/test/chunking-form/samples/render-dynamic-import-extended/_expected/system/main.js @@ -0,0 +1,14 @@ +System.register([], (function (exports, module) { + 'use strict'; + return { + execute: (function () { + + systemDynamicImportPreload('./generated-chain-3.js', {"generated-chain-2.js":"'./generated-chain-2.js'","generated-leaf.js":"'./generated-leaf.js'"}, "main.js", "generated-chain-3.js"); + systemDynamicImportPreload('./generated-chain-2.js', {"generated-leaf.js":"'./generated-leaf.js'"}, "main.js", "generated-chain-2.js"); + systemDynamicImportPreload(somethingElse, null, "main.js", null); + systemDynamicImportPreload('external-module', null, "main.js", null); + systemDynamicImportPreload('./generated-imports-external.js', {"external-module":"'external-module'"}, "main.js", "generated-imports-external.js"); + + }) + }; +})); diff --git a/test/chunking-form/samples/render-dynamic-import-extended/chain-2.js b/test/chunking-form/samples/render-dynamic-import-extended/chain-2.js new file mode 100644 index 00000000000..cbbbe3769c7 --- /dev/null +++ b/test/chunking-form/samples/render-dynamic-import-extended/chain-2.js @@ -0,0 +1,4 @@ +import three from './leaf.js'; + +export const four = three + 1; +export default 42; diff --git a/test/chunking-form/samples/render-dynamic-import-extended/chain-3.js b/test/chunking-form/samples/render-dynamic-import-extended/chain-3.js new file mode 100644 index 00000000000..3f9055eca78 --- /dev/null +++ b/test/chunking-form/samples/render-dynamic-import-extended/chain-3.js @@ -0,0 +1,3 @@ +import fortyTwo, { four } from './chain-2.js'; +console.log('from import:', fortyTwo, four); +export default fortyTwo; diff --git a/test/chunking-form/samples/render-dynamic-import-extended/imports-external.js b/test/chunking-form/samples/render-dynamic-import-extended/imports-external.js new file mode 100644 index 00000000000..d419b8e0320 --- /dev/null +++ b/test/chunking-form/samples/render-dynamic-import-extended/imports-external.js @@ -0,0 +1 @@ +export * as fromExternal from 'external-module'; diff --git a/test/chunking-form/samples/render-dynamic-import-extended/leaf.js b/test/chunking-form/samples/render-dynamic-import-extended/leaf.js new file mode 100644 index 00000000000..dbb41f0e1f6 --- /dev/null +++ b/test/chunking-form/samples/render-dynamic-import-extended/leaf.js @@ -0,0 +1 @@ +export default 3; diff --git a/test/chunking-form/samples/render-dynamic-import-extended/main.js b/test/chunking-form/samples/render-dynamic-import-extended/main.js new file mode 100644 index 00000000000..dca5409be9c --- /dev/null +++ b/test/chunking-form/samples/render-dynamic-import-extended/main.js @@ -0,0 +1,5 @@ +import('./chain-3.js'); +import('./chain-2.js'); +import(somethingElse); +import('external-module'); +import('./imports-external.js'); diff --git a/test/chunking-form/samples/render-dynamic-import/_config.js b/test/chunking-form/samples/render-dynamic-import/_config.js index c841123e304..6c4d9f60823 100644 --- a/test/chunking-form/samples/render-dynamic-import/_config.js +++ b/test/chunking-form/samples/render-dynamic-import/_config.js @@ -1,6 +1,6 @@ -const path = require('path'); +const path = require('node:path'); -module.exports = { +module.exports = defineTest({ description: 'supports custom rendering for dynamic imports', options: { plugins: { @@ -13,10 +13,11 @@ module.exports = { renderDynamicImport({ customResolution, format, moduleId, targetModuleId }) { return { left: `${format}SpecialHandler(`, - right: `, '${path.relative(__dirname, moduleId)}', '${targetModuleId && - path.relative(__dirname, targetModuleId)}', ${customResolution})` + right: `, '${path.relative(__dirname, moduleId)}', '${ + targetModuleId && path.relative(__dirname, targetModuleId) + }', ${customResolution})` }; } } } -}; +}); diff --git a/test/chunking-form/samples/render-dynamic-import/_expected/amd/generated-imported-via-special-handler.js b/test/chunking-form/samples/render-dynamic-import/_expected/amd/generated-imported-via-special-handler.js index 96ce7e1d3f0..d5e57ed3614 100644 --- a/test/chunking-form/samples/render-dynamic-import/_expected/amd/generated-imported-via-special-handler.js +++ b/test/chunking-form/samples/render-dynamic-import/_expected/amd/generated-imported-via-special-handler.js @@ -1,5 +1,5 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; console.log('special'); -}); +})); diff --git a/test/chunking-form/samples/render-dynamic-import/_expected/amd/main.js b/test/chunking-form/samples/render-dynamic-import/_expected/amd/main.js index 1230df01911..e4a2786230c 100644 --- a/test/chunking-form/samples/render-dynamic-import/_expected/amd/main.js +++ b/test/chunking-form/samples/render-dynamic-import/_expected/amd/main.js @@ -1,7 +1,7 @@ -define(['require'], function (require) { 'use strict'; +define(['require'], (function (require) { 'use strict'; amdSpecialHandler('./generated-imported-via-special-handler', 'main.js', 'imported-via-special-handler.js', null); amdSpecialHandler(someVariable, 'main.js', 'null', null); amdSpecialHandler(someCustomlyResolvedVariable, 'main.js', 'null', someCustomlyResolvedVariable); -}); +})); diff --git a/test/chunking-form/samples/render-dynamic-import/_expected/system/generated-imported-via-special-handler.js b/test/chunking-form/samples/render-dynamic-import/_expected/system/generated-imported-via-special-handler.js index 8dd5d86ac58..1a82259c7f7 100644 --- a/test/chunking-form/samples/render-dynamic-import/_expected/system/generated-imported-via-special-handler.js +++ b/test/chunking-form/samples/render-dynamic-import/_expected/system/generated-imported-via-special-handler.js @@ -1,10 +1,10 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { console.log('special'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/render-dynamic-import/_expected/system/main.js b/test/chunking-form/samples/render-dynamic-import/_expected/system/main.js index 52306b00fc1..c119bf4c091 100644 --- a/test/chunking-form/samples/render-dynamic-import/_expected/system/main.js +++ b/test/chunking-form/samples/render-dynamic-import/_expected/system/main.js @@ -1,12 +1,12 @@ -System.register([], function (exports, module) { +System.register([], (function (exports, module) { 'use strict'; return { - execute: function () { + execute: (function () { systemSpecialHandler('./generated-imported-via-special-handler.js', 'main.js', 'imported-via-special-handler.js', null); systemSpecialHandler(someVariable, 'main.js', 'null', null); systemSpecialHandler(someCustomlyResolvedVariable, 'main.js', 'null', someCustomlyResolvedVariable); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/resolve-dynamic-import/_config.js b/test/chunking-form/samples/resolve-dynamic-import/_config.js index fc84d61a62e..18a97107189 100644 --- a/test/chunking-form/samples/resolve-dynamic-import/_config.js +++ b/test/chunking-form/samples/resolve-dynamic-import/_config.js @@ -1,75 +1,91 @@ -const path = require('path'); +const path = require('node:path'); const EXISTING = path.resolve(__dirname, 'existing.js'); -module.exports = { +module.exports = defineTest({ description: 'Supports all resolution formats for dynamic imports', options: { plugins: { resolveId(source) { switch (source) { - case 'existing-name': + case 'existing-name': { return EXISTING; - case './direct-relative-external': + } + case './direct-relative-external': { return false; - case './indirect-relative-external': + } + case './indirect-relative-external': { return { id: 'to-indirect-relative-external', external: true }; - case 'direct-absolute-external': + } + case 'direct-absolute-external': { return false; - case 'indirect-absolute-external': + } + case 'indirect-absolute-external': { return { id: 'to-indirect-absolute-external', external: true }; + } } }, resolveDynamicImport(specifier) { if (typeof specifier === 'string') { switch (specifier) { - case 'existing-name': + case 'existing-name': { return EXISTING; + } case './direct-relative-external': - case '../direct-relative-external': + case '../direct-relative-external': { return false; + } case './indirect-relative-external': - case '../indirect-relative-external': + case '../indirect-relative-external': { return { id: 'to-indirect-relative-external', external: true }; - case 'direct-absolute-external': + } + case 'direct-absolute-external': { return false; - case 'indirect-absolute-external': + } + case 'indirect-absolute-external': { return { id: 'to-indirect-absolute-external', external: true }; - default: + } + default: { throw new Error(`Unexpected import ${specifier}`); + } } } switch (specifier.left.value) { - case 'dynamic-direct-external': + case 'dynamic-direct-external': { return false; - case 'dynamic-indirect-external': + } + case 'dynamic-indirect-external': { return { id: 'to-dynamic-indirect-external', external: true }; - case 'dynamic-indirect-existing': + } + case 'dynamic-indirect-existing': { return { id: EXISTING, external: false }; - case 'dynamic-replaced': + } + case 'dynamic-replaced': { return `'my' + 'replacement'`; - default: + } + default: { throw new Error(`Unexpected import ${specifier.left.value}`); + } } } } } -}; +}); diff --git a/test/chunking-form/samples/resolve-dynamic-import/_expected/amd/main.js b/test/chunking-form/samples/resolve-dynamic-import/_expected/amd/main.js index 27a5ecd2a3f..07244980fcc 100644 --- a/test/chunking-form/samples/resolve-dynamic-import/_expected/amd/main.js +++ b/test/chunking-form/samples/resolve-dynamic-import/_expected/amd/main.js @@ -1,7 +1,6 @@ -define(['require', './direct-relative-external', 'to-indirect-relative-external', 'direct-absolute-external', 'to-indirect-absolute-external'], function (require, directRelativeExternal, toIndirectRelativeExternal, directAbsoluteExternal, toIndirectAbsoluteExternal) { 'use strict'; +define(['require', './direct-relative-external', 'to-indirect-relative-external', 'direct-absolute-external', 'to-indirect-absolute-external'], (function (require, directRelativeExternal, toIndirectRelativeExternal, directAbsoluteExternal, toIndirectAbsoluteExternal) { 'use strict'; - function _interopNamespace(e) { - if (e && e.__esModule) return e; + function _interopNamespaceDefault(e) { var n = Object.create(null); if (e) { Object.keys(e).forEach(function (k) { @@ -9,42 +8,38 @@ define(['require', './direct-relative-external', 'to-indirect-relative-external' var d = Object.getOwnPropertyDescriptor(e, k); Object.defineProperty(n, k, d.get ? d : { enumerable: true, - get: function () { - return e[k]; - } + get: function () { return e[k]; } }); } }); } - n['default'] = e; + n.default = e; return Object.freeze(n); } // nested Promise.resolve().then(function () { return existing; }); - new Promise(function (resolve, reject) { require(['./direct-relative-external'], function (m) { resolve(/*#__PURE__*/_interopNamespace(m)); }, reject) }); - new Promise(function (resolve, reject) { require(['to-indirect-relative-external'], function (m) { resolve(/*#__PURE__*/_interopNamespace(m)); }, reject) }); - new Promise(function (resolve, reject) { require(['direct-absolute-external'], function (m) { resolve(/*#__PURE__*/_interopNamespace(m)); }, reject) }); - new Promise(function (resolve, reject) { require(['to-indirect-absolute-external'], function (m) { resolve(/*#__PURE__*/_interopNamespace(m)); }, reject) }); + new Promise(function (resolve, reject) { require(['./direct-relative-external'], function (m) { resolve(/*#__PURE__*/_interopNamespaceDefault(m)); }, reject); }); + new Promise(function (resolve, reject) { require(['to-indirect-relative-external'], function (m) { resolve(/*#__PURE__*/_interopNamespaceDefault(m)); }, reject); }); + new Promise(function (resolve, reject) { require(['direct-absolute-external'], function (m) { resolve(/*#__PURE__*/_interopNamespaceDefault(m)); }, reject); }); + new Promise(function (resolve, reject) { require(['to-indirect-absolute-external'], function (m) { resolve(/*#__PURE__*/_interopNamespaceDefault(m)); }, reject); }); - const value = 'existing'; console.log('existing'); var existing = /*#__PURE__*/Object.freeze({ - __proto__: null, - value: value + __proto__: null }); //main Promise.resolve().then(function () { return existing; }); - new Promise(function (resolve, reject) { require(['./direct-relative-external'], function (m) { resolve(/*#__PURE__*/_interopNamespace(m)); }, reject) }); - new Promise(function (resolve, reject) { require(['to-indirect-relative-external'], function (m) { resolve(/*#__PURE__*/_interopNamespace(m)); }, reject) }); - new Promise(function (resolve, reject) { require(['direct-absolute-external'], function (m) { resolve(/*#__PURE__*/_interopNamespace(m)); }, reject) }); - new Promise(function (resolve, reject) { require(['to-indirect-absolute-external'], function (m) { resolve(/*#__PURE__*/_interopNamespace(m)); }, reject) }); + new Promise(function (resolve, reject) { require(['./direct-relative-external'], function (m) { resolve(/*#__PURE__*/_interopNamespaceDefault(m)); }, reject); }); + new Promise(function (resolve, reject) { require(['to-indirect-relative-external'], function (m) { resolve(/*#__PURE__*/_interopNamespaceDefault(m)); }, reject); }); + new Promise(function (resolve, reject) { require(['direct-absolute-external'], function (m) { resolve(/*#__PURE__*/_interopNamespaceDefault(m)); }, reject); }); + new Promise(function (resolve, reject) { require(['to-indirect-absolute-external'], function (m) { resolve(/*#__PURE__*/_interopNamespaceDefault(m)); }, reject); }); - new Promise(function (resolve, reject) { require(['dynamic-direct-external' + unknown], function (m) { resolve(/*#__PURE__*/_interopNamespace(m)); }, reject) }); - new Promise(function (resolve, reject) { require(['to-dynamic-indirect-external'], function (m) { resolve(/*#__PURE__*/_interopNamespace(m)); }, reject) }); + (function (t) { return new Promise(function (resolve, reject) { require([t], function (m) { resolve(/*#__PURE__*/_interopNamespaceDefault(m)); }, reject); }); })('dynamic-direct-external' + unknown); + new Promise(function (resolve, reject) { require(['to-dynamic-indirect-external'], function (m) { resolve(/*#__PURE__*/_interopNamespaceDefault(m)); }, reject); }); Promise.resolve().then(function () { return existing; }); - new Promise(function (resolve, reject) { require(['my' + 'replacement'], function (m) { resolve(/*#__PURE__*/_interopNamespace(m)); }, reject) }); + (function (t) { return new Promise(function (resolve, reject) { require([t], function (m) { resolve(/*#__PURE__*/_interopNamespaceDefault(m)); }, reject); }); })('my' + 'replacement'); -}); +})); diff --git a/test/chunking-form/samples/resolve-dynamic-import/_expected/cjs/main.js b/test/chunking-form/samples/resolve-dynamic-import/_expected/cjs/main.js index ffb0c96bd0d..118daa57a84 100644 --- a/test/chunking-form/samples/resolve-dynamic-import/_expected/cjs/main.js +++ b/test/chunking-form/samples/resolve-dynamic-import/_expected/cjs/main.js @@ -5,49 +5,27 @@ require('to-indirect-relative-external'); require('direct-absolute-external'); require('to-indirect-absolute-external'); -function _interopNamespace(e) { - if (e && e.__esModule) return e; - var n = Object.create(null); - if (e) { - Object.keys(e).forEach(function (k) { - if (k !== 'default') { - var d = Object.getOwnPropertyDescriptor(e, k); - Object.defineProperty(n, k, d.get ? d : { - enumerable: true, - get: function () { - return e[k]; - } - }); - } - }); - } - n['default'] = e; - return Object.freeze(n); -} - // nested Promise.resolve().then(function () { return existing; }); -Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('./direct-relative-external')); }); -Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('to-indirect-relative-external')); }); -Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('direct-absolute-external')); }); -Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('to-indirect-absolute-external')); }); +import('./direct-relative-external'); +import('to-indirect-relative-external'); +import('direct-absolute-external'); +import('to-indirect-absolute-external'); -const value = 'existing'; console.log('existing'); var existing = /*#__PURE__*/Object.freeze({ - __proto__: null, - value: value + __proto__: null }); //main Promise.resolve().then(function () { return existing; }); -Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('./direct-relative-external')); }); -Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('to-indirect-relative-external')); }); -Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('direct-absolute-external')); }); -Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('to-indirect-absolute-external')); }); +import('./direct-relative-external'); +import('to-indirect-relative-external'); +import('direct-absolute-external'); +import('to-indirect-absolute-external'); -Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('dynamic-direct-external' + unknown)); }); -Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('to-dynamic-indirect-external')); }); +import('dynamic-direct-external' + unknown); +import('to-dynamic-indirect-external'); Promise.resolve().then(function () { return existing; }); -Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('my' + 'replacement')); }); +import('my' + 'replacement'); diff --git a/test/chunking-form/samples/resolve-dynamic-import/_expected/es/main.js b/test/chunking-form/samples/resolve-dynamic-import/_expected/es/main.js index fb6bacbadd2..821ceee41c6 100644 --- a/test/chunking-form/samples/resolve-dynamic-import/_expected/es/main.js +++ b/test/chunking-form/samples/resolve-dynamic-import/_expected/es/main.js @@ -10,12 +10,10 @@ import('to-indirect-relative-external'); import('direct-absolute-external'); import('to-indirect-absolute-external'); -const value = 'existing'; console.log('existing'); var existing = /*#__PURE__*/Object.freeze({ - __proto__: null, - value: value + __proto__: null }); //main diff --git a/test/chunking-form/samples/resolve-dynamic-import/_expected/system/main.js b/test/chunking-form/samples/resolve-dynamic-import/_expected/system/main.js index d1c80b61a3c..425eeb50564 100644 --- a/test/chunking-form/samples/resolve-dynamic-import/_expected/system/main.js +++ b/test/chunking-form/samples/resolve-dynamic-import/_expected/system/main.js @@ -1,8 +1,8 @@ -System.register(['./direct-relative-external', 'to-indirect-relative-external', 'direct-absolute-external', 'to-indirect-absolute-external'], function (exports, module) { +System.register(['./direct-relative-external', 'to-indirect-relative-external', 'direct-absolute-external', 'to-indirect-absolute-external'], (function (exports, module) { 'use strict'; return { - setters: [function () {}, function () {}, function () {}, function () {}], - execute: function () { + setters: [null, null, null, null], + execute: (function () { // nested Promise.resolve().then(function () { return existing; }); @@ -11,12 +11,10 @@ System.register(['./direct-relative-external', 'to-indirect-relative-external', module.import('direct-absolute-external'); module.import('to-indirect-absolute-external'); - const value = 'existing'; console.log('existing'); var existing = /*#__PURE__*/Object.freeze({ - __proto__: null, - value: value + __proto__: null }); //main @@ -31,6 +29,6 @@ System.register(['./direct-relative-external', 'to-indirect-relative-external', Promise.resolve().then(function () { return existing; }); module.import('my' + 'replacement'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/resolve-file-url-obj/_config.js b/test/chunking-form/samples/resolve-file-url-obj/_config.js new file mode 100644 index 00000000000..db08e25affa --- /dev/null +++ b/test/chunking-form/samples/resolve-file-url-obj/_config.js @@ -0,0 +1,29 @@ +module.exports = defineTest({ + description: 'allows to use ROLLUP_FILE_URL_OBJ to get URL objects directly', + options: { + plugins: [ + { + resolveId(id) { + if (id === 'url-test') { + return id; + } + }, + load(id) { + if (id === 'url-test') { + const assetId = this.emitFile({ + type: 'asset', + name: 'test.txt', + source: 'test content' + }); + return ` + // Test string URL replacement + export const assetString = import.meta.ROLLUP_FILE_URL_${assetId}; + // Test URL object replacement + export const assetObject = import.meta.ROLLUP_FILE_URL_OBJ_${assetId}; + `; + } + } + } + ] + } +}); diff --git a/test/chunking-form/samples/resolve-file-url-obj/_expected/amd/assets/test-r6af3lUh.txt b/test/chunking-form/samples/resolve-file-url-obj/_expected/amd/assets/test-r6af3lUh.txt new file mode 100644 index 00000000000..08cf6101416 --- /dev/null +++ b/test/chunking-form/samples/resolve-file-url-obj/_expected/amd/assets/test-r6af3lUh.txt @@ -0,0 +1 @@ +test content \ No newline at end of file diff --git a/test/chunking-form/samples/resolve-file-url-obj/_expected/amd/main.js b/test/chunking-form/samples/resolve-file-url-obj/_expected/amd/main.js new file mode 100644 index 00000000000..63b443d5873 --- /dev/null +++ b/test/chunking-form/samples/resolve-file-url-obj/_expected/amd/main.js @@ -0,0 +1,11 @@ +define(['require'], (function (require) { 'use strict'; + + // Test string URL replacement + const assetString = new URL(require.toUrl('./assets/test-r6af3lUh.txt'), document.baseURI).href; + // Test URL object replacement + const assetObject = new URL(require.toUrl('./assets/test-r6af3lUh.txt'), document.baseURI); + + console.log('String URL:', assetString); + console.log('URL Object:', assetObject); + +})); diff --git a/test/chunking-form/samples/resolve-file-url-obj/_expected/cjs/assets/test-r6af3lUh.txt b/test/chunking-form/samples/resolve-file-url-obj/_expected/cjs/assets/test-r6af3lUh.txt new file mode 100644 index 00000000000..08cf6101416 --- /dev/null +++ b/test/chunking-form/samples/resolve-file-url-obj/_expected/cjs/assets/test-r6af3lUh.txt @@ -0,0 +1 @@ +test content \ No newline at end of file diff --git a/test/chunking-form/samples/resolve-file-url-obj/_expected/cjs/main.js b/test/chunking-form/samples/resolve-file-url-obj/_expected/cjs/main.js new file mode 100644 index 00000000000..3a34d3a4dda --- /dev/null +++ b/test/chunking-form/samples/resolve-file-url-obj/_expected/cjs/main.js @@ -0,0 +1,9 @@ +'use strict'; + +// Test string URL replacement + const assetString = (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__dirname + '/assets/test-r6af3lUh.txt').href : new URL('assets/test-r6af3lUh.txt', document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT' && document.currentScript.src || document.baseURI).href); + // Test URL object replacement + const assetObject = (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__dirname + '/assets/test-r6af3lUh.txt') : new URL('assets/test-r6af3lUh.txt', document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT' && document.currentScript.src || document.baseURI)); + +console.log('String URL:', assetString); +console.log('URL Object:', assetObject); diff --git a/test/chunking-form/samples/resolve-file-url-obj/_expected/es/assets/test-r6af3lUh.txt b/test/chunking-form/samples/resolve-file-url-obj/_expected/es/assets/test-r6af3lUh.txt new file mode 100644 index 00000000000..08cf6101416 --- /dev/null +++ b/test/chunking-form/samples/resolve-file-url-obj/_expected/es/assets/test-r6af3lUh.txt @@ -0,0 +1 @@ +test content \ No newline at end of file diff --git a/test/chunking-form/samples/resolve-file-url-obj/_expected/es/main.js b/test/chunking-form/samples/resolve-file-url-obj/_expected/es/main.js new file mode 100644 index 00000000000..6e88b3e355e --- /dev/null +++ b/test/chunking-form/samples/resolve-file-url-obj/_expected/es/main.js @@ -0,0 +1,7 @@ +// Test string URL replacement + const assetString = new URL('assets/test-r6af3lUh.txt', import.meta.url).href; + // Test URL object replacement + const assetObject = new URL('assets/test-r6af3lUh.txt', import.meta.url); + +console.log('String URL:', assetString); +console.log('URL Object:', assetObject); diff --git a/test/chunking-form/samples/resolve-file-url-obj/_expected/system/assets/test-r6af3lUh.txt b/test/chunking-form/samples/resolve-file-url-obj/_expected/system/assets/test-r6af3lUh.txt new file mode 100644 index 00000000000..08cf6101416 --- /dev/null +++ b/test/chunking-form/samples/resolve-file-url-obj/_expected/system/assets/test-r6af3lUh.txt @@ -0,0 +1 @@ +test content \ No newline at end of file diff --git a/test/chunking-form/samples/resolve-file-url-obj/_expected/system/main.js b/test/chunking-form/samples/resolve-file-url-obj/_expected/system/main.js new file mode 100644 index 00000000000..44063d5c0e1 --- /dev/null +++ b/test/chunking-form/samples/resolve-file-url-obj/_expected/system/main.js @@ -0,0 +1,16 @@ +System.register([], (function (exports, module) { + 'use strict'; + return { + execute: (function () { + + // Test string URL replacement + const assetString = new URL('assets/test-r6af3lUh.txt', module.meta.url).href; + // Test URL object replacement + const assetObject = new URL('assets/test-r6af3lUh.txt', module.meta.url); + + console.log('String URL:', assetString); + console.log('URL Object:', assetObject); + + }) + }; +})); diff --git a/test/chunking-form/samples/resolve-file-url-obj/main.js b/test/chunking-form/samples/resolve-file-url-obj/main.js new file mode 100644 index 00000000000..e5beaebf8f9 --- /dev/null +++ b/test/chunking-form/samples/resolve-file-url-obj/main.js @@ -0,0 +1,4 @@ +import { assetString, assetObject } from 'url-test'; + +console.log('String URL:', assetString); +console.log('URL Object:', assetObject); \ No newline at end of file diff --git a/test/chunking-form/samples/resolve-file-url/_config.js b/test/chunking-form/samples/resolve-file-url/_config.js index 7116c2b042d..eb4921765c1 100644 --- a/test/chunking-form/samples/resolve-file-url/_config.js +++ b/test/chunking-form/samples/resolve-file-url/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'allows to configure file urls', options: { output: { @@ -48,4 +48,4 @@ module.exports = { } ] } -}; +}); diff --git a/test/chunking-form/samples/resolve-file-url/_expected/amd/assets/asset-resolved-8bd22e6e.txt b/test/chunking-form/samples/resolve-file-url/_expected/amd/assets/asset-resolved-8bd22e6e.txt deleted file mode 100644 index 31fb300f988..00000000000 --- a/test/chunking-form/samples/resolve-file-url/_expected/amd/assets/asset-resolved-8bd22e6e.txt +++ /dev/null @@ -1 +0,0 @@ -Asset for: resolved \ No newline at end of file diff --git a/test/chunking-form/samples/deprecated/configure-asset-url/_expected/amd/assets/asset-resolved-8bd22e6e.txt b/test/chunking-form/samples/resolve-file-url/_expected/amd/assets/asset-resolved-DukuHpJ1.txt similarity index 100% rename from test/chunking-form/samples/deprecated/configure-asset-url/_expected/amd/assets/asset-resolved-8bd22e6e.txt rename to test/chunking-form/samples/resolve-file-url/_expected/amd/assets/asset-resolved-DukuHpJ1.txt diff --git a/test/chunking-form/samples/resolve-file-url/_expected/amd/assets/asset-solved-28a7ac89.txt b/test/chunking-form/samples/resolve-file-url/_expected/amd/assets/asset-solved-28a7ac89.txt deleted file mode 100644 index 07c7a096c7e..00000000000 --- a/test/chunking-form/samples/resolve-file-url/_expected/amd/assets/asset-solved-28a7ac89.txt +++ /dev/null @@ -1 +0,0 @@ -Asset for: solved \ No newline at end of file diff --git a/test/chunking-form/samples/deprecated/configure-asset-url/_expected/amd/assets/asset-solved-28a7ac89.txt b/test/chunking-form/samples/resolve-file-url/_expected/amd/assets/asset-solved-DSjIjiFN.txt similarity index 100% rename from test/chunking-form/samples/deprecated/configure-asset-url/_expected/amd/assets/asset-solved-28a7ac89.txt rename to test/chunking-form/samples/resolve-file-url/_expected/amd/assets/asset-solved-DSjIjiFN.txt diff --git a/test/chunking-form/samples/resolve-file-url/_expected/amd/assets/asset-unresolved-8dcd7fca.txt b/test/chunking-form/samples/resolve-file-url/_expected/amd/assets/asset-unresolved-8dcd7fca.txt deleted file mode 100644 index fd3ad6261cc..00000000000 --- a/test/chunking-form/samples/resolve-file-url/_expected/amd/assets/asset-unresolved-8dcd7fca.txt +++ /dev/null @@ -1 +0,0 @@ -Asset for: unresolved \ No newline at end of file diff --git a/test/chunking-form/samples/deprecated/configure-asset-url/_expected/amd/assets/asset-unresolved-8dcd7fca.txt b/test/chunking-form/samples/resolve-file-url/_expected/amd/assets/asset-unresolved-B7Qh6_pN.txt similarity index 100% rename from test/chunking-form/samples/deprecated/configure-asset-url/_expected/amd/assets/asset-unresolved-8dcd7fca.txt rename to test/chunking-form/samples/resolve-file-url/_expected/amd/assets/asset-unresolved-B7Qh6_pN.txt diff --git a/test/chunking-form/samples/resolve-file-url/_expected/amd/main.js b/test/chunking-form/samples/resolve-file-url/_expected/amd/main.js index 5bae0b1bdb6..c8976301282 100644 --- a/test/chunking-form/samples/resolve-file-url/_expected/amd/main.js +++ b/test/chunking-form/samples/resolve-file-url/_expected/amd/main.js @@ -1,11 +1,11 @@ -define(['require'], function (require) { 'use strict'; +define(['require'], (function (require) { 'use strict'; const asset$1 = 'resolved'; const chunk$1 = 'resolved'; - const asset = new URL(require.toUrl('./assets/asset-unresolved-8dcd7fca.txt'), document.baseURI).href; - const chunk = new URL(require.toUrl('./nested/chunk.js'), document.baseURI).href; + const asset = new URL(require.toUrl('./assets/asset-unresolved-B7Qh6_pN.txt'), document.baseURI).href; + const chunk = new URL(require.toUrl('./nested/chunk2.js'), document.baseURI).href; - new Promise(function (resolve, reject) { require(['./nested/chunk2'], resolve, reject) }).then(result => console.log(result, chunk$1, chunk, asset$1, asset)); + new Promise(function (resolve, reject) { require(['./nested/chunk'], resolve, reject); }).then(result => console.log(result, chunk$1, chunk, asset$1, asset)); -}); +})); diff --git a/test/chunking-form/samples/resolve-file-url/_expected/amd/nested/chunk.js b/test/chunking-form/samples/resolve-file-url/_expected/amd/nested/chunk.js index 32f0814a584..dfcca36a8bb 100644 --- a/test/chunking-form/samples/resolve-file-url/_expected/amd/nested/chunk.js +++ b/test/chunking-form/samples/resolve-file-url/_expected/amd/nested/chunk.js @@ -1,5 +1,9 @@ -define(function () { 'use strict'; +define(['require', 'exports'], (function (require, exports) { 'use strict'; - console.log('chunk'); + const asset = 'chunkId=nested/chunk.js:moduleId=solved:fileName=assets/asset-solved-DSjIjiFN.txt:format=amd:relativePath=../assets/asset-solved-DSjIjiFN.txt:referenceId=lj6zEdlc'; + const chunk = 'chunkId=nested/chunk.js:moduleId=solved:fileName=nested/chunk2.js:format=amd:relativePath=chunk2.js:referenceId=CEb$4JXK'; -}); + exports.asset = asset; + exports.chunk = chunk; + +})); diff --git a/test/chunking-form/samples/resolve-file-url/_expected/amd/nested/chunk2.js b/test/chunking-form/samples/resolve-file-url/_expected/amd/nested/chunk2.js index 76a6be30872..f29221faf6c 100644 --- a/test/chunking-form/samples/resolve-file-url/_expected/amd/nested/chunk2.js +++ b/test/chunking-form/samples/resolve-file-url/_expected/amd/nested/chunk2.js @@ -1,9 +1,5 @@ -define(['require', 'exports'], function (require, exports) { 'use strict'; +define((function () { 'use strict'; - const asset = 'chunkId=nested/chunk2.js:moduleId=solved:fileName=assets/asset-solved-28a7ac89.txt:format=amd:relativePath=../assets/asset-solved-28a7ac89.txt:referenceId=6296c678'; - const chunk = 'chunkId=nested/chunk2.js:moduleId=solved:fileName=nested/chunk.js:format=amd:relativePath=chunk.js:referenceId=f6c25ae7'; + console.log('chunk'); - exports.asset = asset; - exports.chunk = chunk; - -}); +})); diff --git a/test/chunking-form/samples/resolve-file-url/_expected/cjs/assets/asset-resolved-8bd22e6e.txt b/test/chunking-form/samples/resolve-file-url/_expected/cjs/assets/asset-resolved-8bd22e6e.txt deleted file mode 100644 index 31fb300f988..00000000000 --- a/test/chunking-form/samples/resolve-file-url/_expected/cjs/assets/asset-resolved-8bd22e6e.txt +++ /dev/null @@ -1 +0,0 @@ -Asset for: resolved \ No newline at end of file diff --git a/test/chunking-form/samples/deprecated/configure-asset-url/_expected/cjs/assets/asset-resolved-8bd22e6e.txt b/test/chunking-form/samples/resolve-file-url/_expected/cjs/assets/asset-resolved-DukuHpJ1.txt similarity index 100% rename from test/chunking-form/samples/deprecated/configure-asset-url/_expected/cjs/assets/asset-resolved-8bd22e6e.txt rename to test/chunking-form/samples/resolve-file-url/_expected/cjs/assets/asset-resolved-DukuHpJ1.txt diff --git a/test/chunking-form/samples/resolve-file-url/_expected/cjs/assets/asset-solved-28a7ac89.txt b/test/chunking-form/samples/resolve-file-url/_expected/cjs/assets/asset-solved-28a7ac89.txt deleted file mode 100644 index 07c7a096c7e..00000000000 --- a/test/chunking-form/samples/resolve-file-url/_expected/cjs/assets/asset-solved-28a7ac89.txt +++ /dev/null @@ -1 +0,0 @@ -Asset for: solved \ No newline at end of file diff --git a/test/chunking-form/samples/deprecated/configure-asset-url/_expected/cjs/assets/asset-solved-28a7ac89.txt b/test/chunking-form/samples/resolve-file-url/_expected/cjs/assets/asset-solved-DSjIjiFN.txt similarity index 100% rename from test/chunking-form/samples/deprecated/configure-asset-url/_expected/cjs/assets/asset-solved-28a7ac89.txt rename to test/chunking-form/samples/resolve-file-url/_expected/cjs/assets/asset-solved-DSjIjiFN.txt diff --git a/test/chunking-form/samples/resolve-file-url/_expected/cjs/assets/asset-unresolved-8dcd7fca.txt b/test/chunking-form/samples/resolve-file-url/_expected/cjs/assets/asset-unresolved-8dcd7fca.txt deleted file mode 100644 index fd3ad6261cc..00000000000 --- a/test/chunking-form/samples/resolve-file-url/_expected/cjs/assets/asset-unresolved-8dcd7fca.txt +++ /dev/null @@ -1 +0,0 @@ -Asset for: unresolved \ No newline at end of file diff --git a/test/chunking-form/samples/deprecated/configure-asset-url/_expected/cjs/assets/asset-unresolved-8dcd7fca.txt b/test/chunking-form/samples/resolve-file-url/_expected/cjs/assets/asset-unresolved-B7Qh6_pN.txt similarity index 100% rename from test/chunking-form/samples/deprecated/configure-asset-url/_expected/cjs/assets/asset-unresolved-8dcd7fca.txt rename to test/chunking-form/samples/resolve-file-url/_expected/cjs/assets/asset-unresolved-B7Qh6_pN.txt diff --git a/test/chunking-form/samples/resolve-file-url/_expected/cjs/main.js b/test/chunking-form/samples/resolve-file-url/_expected/cjs/main.js index feea03def6e..4406e594f63 100644 --- a/test/chunking-form/samples/resolve-file-url/_expected/cjs/main.js +++ b/test/chunking-form/samples/resolve-file-url/_expected/cjs/main.js @@ -3,7 +3,7 @@ const asset$1 = 'resolved'; const chunk$1 = 'resolved'; -const asset = (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __dirname + '/assets/asset-unresolved-8dcd7fca.txt').href : new URL('assets/asset-unresolved-8dcd7fca.txt', document.currentScript && document.currentScript.src || document.baseURI).href); -const chunk = (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __dirname + '/nested/chunk.js').href : new URL('nested/chunk.js', document.currentScript && document.currentScript.src || document.baseURI).href); +const asset = (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__dirname + '/assets/asset-unresolved-B7Qh6_pN.txt').href : new URL('assets/asset-unresolved-B7Qh6_pN.txt', document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT' && document.currentScript.src || document.baseURI).href); +const chunk = (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__dirname + '/nested/chunk2.js').href : new URL('nested/chunk2.js', document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT' && document.currentScript.src || document.baseURI).href); -Promise.resolve().then(function () { return require('./nested/chunk2.js'); }).then(result => console.log(result, chunk$1, chunk, asset$1, asset)); +Promise.resolve().then(function () { return require('./nested/chunk.js'); }).then(result => console.log(result, chunk$1, chunk, asset$1, asset)); diff --git a/test/chunking-form/samples/resolve-file-url/_expected/cjs/nested/chunk.js b/test/chunking-form/samples/resolve-file-url/_expected/cjs/nested/chunk.js index 9bd6f06e964..5cdcbeea23d 100644 --- a/test/chunking-form/samples/resolve-file-url/_expected/cjs/nested/chunk.js +++ b/test/chunking-form/samples/resolve-file-url/_expected/cjs/nested/chunk.js @@ -1,3 +1,7 @@ 'use strict'; -console.log('chunk'); +const asset = 'chunkId=nested/chunk.js:moduleId=solved:fileName=assets/asset-solved-DSjIjiFN.txt:format=cjs:relativePath=../assets/asset-solved-DSjIjiFN.txt:referenceId=lj6zEdlc'; +const chunk = 'chunkId=nested/chunk.js:moduleId=solved:fileName=nested/chunk2.js:format=cjs:relativePath=chunk2.js:referenceId=CEb$4JXK'; + +exports.asset = asset; +exports.chunk = chunk; diff --git a/test/chunking-form/samples/resolve-file-url/_expected/cjs/nested/chunk2.js b/test/chunking-form/samples/resolve-file-url/_expected/cjs/nested/chunk2.js index 79b46e5bd8f..9bd6f06e964 100644 --- a/test/chunking-form/samples/resolve-file-url/_expected/cjs/nested/chunk2.js +++ b/test/chunking-form/samples/resolve-file-url/_expected/cjs/nested/chunk2.js @@ -1,7 +1,3 @@ 'use strict'; -const asset = 'chunkId=nested/chunk2.js:moduleId=solved:fileName=assets/asset-solved-28a7ac89.txt:format=cjs:relativePath=../assets/asset-solved-28a7ac89.txt:referenceId=6296c678'; -const chunk = 'chunkId=nested/chunk2.js:moduleId=solved:fileName=nested/chunk.js:format=cjs:relativePath=chunk.js:referenceId=f6c25ae7'; - -exports.asset = asset; -exports.chunk = chunk; +console.log('chunk'); diff --git a/test/chunking-form/samples/resolve-file-url/_expected/es/assets/asset-resolved-8bd22e6e.txt b/test/chunking-form/samples/resolve-file-url/_expected/es/assets/asset-resolved-8bd22e6e.txt deleted file mode 100644 index 31fb300f988..00000000000 --- a/test/chunking-form/samples/resolve-file-url/_expected/es/assets/asset-resolved-8bd22e6e.txt +++ /dev/null @@ -1 +0,0 @@ -Asset for: resolved \ No newline at end of file diff --git a/test/chunking-form/samples/deprecated/configure-asset-url/_expected/es/assets/asset-resolved-8bd22e6e.txt b/test/chunking-form/samples/resolve-file-url/_expected/es/assets/asset-resolved-DukuHpJ1.txt similarity index 100% rename from test/chunking-form/samples/deprecated/configure-asset-url/_expected/es/assets/asset-resolved-8bd22e6e.txt rename to test/chunking-form/samples/resolve-file-url/_expected/es/assets/asset-resolved-DukuHpJ1.txt diff --git a/test/chunking-form/samples/resolve-file-url/_expected/es/assets/asset-solved-28a7ac89.txt b/test/chunking-form/samples/resolve-file-url/_expected/es/assets/asset-solved-28a7ac89.txt deleted file mode 100644 index 07c7a096c7e..00000000000 --- a/test/chunking-form/samples/resolve-file-url/_expected/es/assets/asset-solved-28a7ac89.txt +++ /dev/null @@ -1 +0,0 @@ -Asset for: solved \ No newline at end of file diff --git a/test/chunking-form/samples/deprecated/configure-asset-url/_expected/es/assets/asset-solved-28a7ac89.txt b/test/chunking-form/samples/resolve-file-url/_expected/es/assets/asset-solved-DSjIjiFN.txt similarity index 100% rename from test/chunking-form/samples/deprecated/configure-asset-url/_expected/es/assets/asset-solved-28a7ac89.txt rename to test/chunking-form/samples/resolve-file-url/_expected/es/assets/asset-solved-DSjIjiFN.txt diff --git a/test/chunking-form/samples/resolve-file-url/_expected/es/assets/asset-unresolved-8dcd7fca.txt b/test/chunking-form/samples/resolve-file-url/_expected/es/assets/asset-unresolved-8dcd7fca.txt deleted file mode 100644 index fd3ad6261cc..00000000000 --- a/test/chunking-form/samples/resolve-file-url/_expected/es/assets/asset-unresolved-8dcd7fca.txt +++ /dev/null @@ -1 +0,0 @@ -Asset for: unresolved \ No newline at end of file diff --git a/test/chunking-form/samples/deprecated/configure-asset-url/_expected/es/assets/asset-unresolved-8dcd7fca.txt b/test/chunking-form/samples/resolve-file-url/_expected/es/assets/asset-unresolved-B7Qh6_pN.txt similarity index 100% rename from test/chunking-form/samples/deprecated/configure-asset-url/_expected/es/assets/asset-unresolved-8dcd7fca.txt rename to test/chunking-form/samples/resolve-file-url/_expected/es/assets/asset-unresolved-B7Qh6_pN.txt diff --git a/test/chunking-form/samples/resolve-file-url/_expected/es/main.js b/test/chunking-form/samples/resolve-file-url/_expected/es/main.js index 1f84c485bd4..92f86a1a76a 100644 --- a/test/chunking-form/samples/resolve-file-url/_expected/es/main.js +++ b/test/chunking-form/samples/resolve-file-url/_expected/es/main.js @@ -1,7 +1,7 @@ const asset$1 = 'resolved'; const chunk$1 = 'resolved'; -const asset = new URL('assets/asset-unresolved-8dcd7fca.txt', import.meta.url).href; -const chunk = new URL('nested/chunk.js', import.meta.url).href; +const asset = new URL('assets/asset-unresolved-B7Qh6_pN.txt', import.meta.url).href; +const chunk = new URL('nested/chunk2.js', import.meta.url).href; -import('./nested/chunk2.js').then(result => console.log(result, chunk$1, chunk, asset$1, asset)); +import('./nested/chunk.js').then(result => console.log(result, chunk$1, chunk, asset$1, asset)); diff --git a/test/chunking-form/samples/resolve-file-url/_expected/es/nested/chunk.js b/test/chunking-form/samples/resolve-file-url/_expected/es/nested/chunk.js index 36b1d61dd25..4e81eb34088 100644 --- a/test/chunking-form/samples/resolve-file-url/_expected/es/nested/chunk.js +++ b/test/chunking-form/samples/resolve-file-url/_expected/es/nested/chunk.js @@ -1 +1,4 @@ -console.log('chunk'); +const asset = 'chunkId=nested/chunk.js:moduleId=solved:fileName=assets/asset-solved-DSjIjiFN.txt:format=es:relativePath=../assets/asset-solved-DSjIjiFN.txt:referenceId=lj6zEdlc'; +const chunk = 'chunkId=nested/chunk.js:moduleId=solved:fileName=nested/chunk2.js:format=es:relativePath=chunk2.js:referenceId=CEb$4JXK'; + +export { asset, chunk }; diff --git a/test/chunking-form/samples/resolve-file-url/_expected/es/nested/chunk2.js b/test/chunking-form/samples/resolve-file-url/_expected/es/nested/chunk2.js index 295616b7273..36b1d61dd25 100644 --- a/test/chunking-form/samples/resolve-file-url/_expected/es/nested/chunk2.js +++ b/test/chunking-form/samples/resolve-file-url/_expected/es/nested/chunk2.js @@ -1,4 +1 @@ -const asset = 'chunkId=nested/chunk2.js:moduleId=solved:fileName=assets/asset-solved-28a7ac89.txt:format=es:relativePath=../assets/asset-solved-28a7ac89.txt:referenceId=6296c678'; -const chunk = 'chunkId=nested/chunk2.js:moduleId=solved:fileName=nested/chunk.js:format=es:relativePath=chunk.js:referenceId=f6c25ae7'; - -export { asset, chunk }; +console.log('chunk'); diff --git a/test/chunking-form/samples/resolve-file-url/_expected/system/assets/asset-resolved-8bd22e6e.txt b/test/chunking-form/samples/resolve-file-url/_expected/system/assets/asset-resolved-8bd22e6e.txt deleted file mode 100644 index 31fb300f988..00000000000 --- a/test/chunking-form/samples/resolve-file-url/_expected/system/assets/asset-resolved-8bd22e6e.txt +++ /dev/null @@ -1 +0,0 @@ -Asset for: resolved \ No newline at end of file diff --git a/test/chunking-form/samples/deprecated/configure-asset-url/_expected/system/assets/asset-resolved-8bd22e6e.txt b/test/chunking-form/samples/resolve-file-url/_expected/system/assets/asset-resolved-DukuHpJ1.txt similarity index 100% rename from test/chunking-form/samples/deprecated/configure-asset-url/_expected/system/assets/asset-resolved-8bd22e6e.txt rename to test/chunking-form/samples/resolve-file-url/_expected/system/assets/asset-resolved-DukuHpJ1.txt diff --git a/test/chunking-form/samples/resolve-file-url/_expected/system/assets/asset-solved-28a7ac89.txt b/test/chunking-form/samples/resolve-file-url/_expected/system/assets/asset-solved-28a7ac89.txt deleted file mode 100644 index 07c7a096c7e..00000000000 --- a/test/chunking-form/samples/resolve-file-url/_expected/system/assets/asset-solved-28a7ac89.txt +++ /dev/null @@ -1 +0,0 @@ -Asset for: solved \ No newline at end of file diff --git a/test/chunking-form/samples/deprecated/configure-asset-url/_expected/system/assets/asset-solved-28a7ac89.txt b/test/chunking-form/samples/resolve-file-url/_expected/system/assets/asset-solved-DSjIjiFN.txt similarity index 100% rename from test/chunking-form/samples/deprecated/configure-asset-url/_expected/system/assets/asset-solved-28a7ac89.txt rename to test/chunking-form/samples/resolve-file-url/_expected/system/assets/asset-solved-DSjIjiFN.txt diff --git a/test/chunking-form/samples/resolve-file-url/_expected/system/assets/asset-unresolved-8dcd7fca.txt b/test/chunking-form/samples/resolve-file-url/_expected/system/assets/asset-unresolved-8dcd7fca.txt deleted file mode 100644 index fd3ad6261cc..00000000000 --- a/test/chunking-form/samples/resolve-file-url/_expected/system/assets/asset-unresolved-8dcd7fca.txt +++ /dev/null @@ -1 +0,0 @@ -Asset for: unresolved \ No newline at end of file diff --git a/test/chunking-form/samples/deprecated/configure-asset-url/_expected/system/assets/asset-unresolved-8dcd7fca.txt b/test/chunking-form/samples/resolve-file-url/_expected/system/assets/asset-unresolved-B7Qh6_pN.txt similarity index 100% rename from test/chunking-form/samples/deprecated/configure-asset-url/_expected/system/assets/asset-unresolved-8dcd7fca.txt rename to test/chunking-form/samples/resolve-file-url/_expected/system/assets/asset-unresolved-B7Qh6_pN.txt diff --git a/test/chunking-form/samples/resolve-file-url/_expected/system/main.js b/test/chunking-form/samples/resolve-file-url/_expected/system/main.js index c7f3e654ea4..6bd75a5cff5 100644 --- a/test/chunking-form/samples/resolve-file-url/_expected/system/main.js +++ b/test/chunking-form/samples/resolve-file-url/_expected/system/main.js @@ -1,16 +1,16 @@ -System.register([], function (exports, module) { +System.register([], (function (exports, module) { 'use strict'; return { - execute: function () { + execute: (function () { const asset$1 = 'resolved'; const chunk$1 = 'resolved'; - const asset = new URL('assets/asset-unresolved-8dcd7fca.txt', module.meta.url).href; - const chunk = new URL('nested/chunk.js', module.meta.url).href; + const asset = new URL('assets/asset-unresolved-B7Qh6_pN.txt', module.meta.url).href; + const chunk = new URL('nested/chunk2.js', module.meta.url).href; - module.import('./nested/chunk2.js').then(result => console.log(result, chunk$1, chunk, asset$1, asset)); + module.import('./nested/chunk.js').then(result => console.log(result, chunk$1, chunk, asset$1, asset)); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/resolve-file-url/_expected/system/nested/chunk.js b/test/chunking-form/samples/resolve-file-url/_expected/system/nested/chunk.js index 9d080a80d2d..68079905b41 100644 --- a/test/chunking-form/samples/resolve-file-url/_expected/system/nested/chunk.js +++ b/test/chunking-form/samples/resolve-file-url/_expected/system/nested/chunk.js @@ -1,10 +1,11 @@ -System.register([], function () { +System.register([], (function (exports, module) { 'use strict'; return { - execute: function () { + execute: (function () { - console.log('chunk'); + const asset = exports("asset", 'chunkId=nested/chunk.js:moduleId=solved:fileName=assets/asset-solved-DSjIjiFN.txt:format=system:relativePath=../assets/asset-solved-DSjIjiFN.txt:referenceId=lj6zEdlc'); + const chunk = exports("chunk", 'chunkId=nested/chunk.js:moduleId=solved:fileName=nested/chunk2.js:format=system:relativePath=chunk2.js:referenceId=CEb$4JXK'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/resolve-file-url/_expected/system/nested/chunk2.js b/test/chunking-form/samples/resolve-file-url/_expected/system/nested/chunk2.js index 2749e0efa7c..1443cae1e05 100644 --- a/test/chunking-form/samples/resolve-file-url/_expected/system/nested/chunk2.js +++ b/test/chunking-form/samples/resolve-file-url/_expected/system/nested/chunk2.js @@ -1,11 +1,10 @@ -System.register([], function (exports, module) { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { - const asset = exports('asset', 'chunkId=nested/chunk2.js:moduleId=solved:fileName=assets/asset-solved-28a7ac89.txt:format=system:relativePath=../assets/asset-solved-28a7ac89.txt:referenceId=6296c678'); - const chunk = exports('chunk', 'chunkId=nested/chunk2.js:moduleId=solved:fileName=nested/chunk.js:format=system:relativePath=chunk.js:referenceId=f6c25ae7'); + console.log('chunk'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/sanitize-chunk-names/_config.js b/test/chunking-form/samples/sanitize-chunk-names/_config.js index ef6faaae57c..88231449099 100644 --- a/test/chunking-form/samples/sanitize-chunk-names/_config.js +++ b/test/chunking-form/samples/sanitize-chunk-names/_config.js @@ -1,11 +1,11 @@ -module.exports = { +module.exports = defineTest({ description: 'sanitizes chunk names from virtual entry points', options: { input: ['main1'], plugins: [ { options(options) { - options.input = ['\0virtual:entry-1', '\0virtual:entry-2']; + options.input = ['\0virtual:entry-1', '\0virtual:entry-2', 'another-[slug]-#result']; return options; }, resolveId(id) { @@ -17,4 +17,4 @@ module.exports = { } ] } -}; +}); diff --git a/test/chunking-form/samples/sanitize-chunk-names/_expected/amd/_virtual_entry-1.js b/test/chunking-form/samples/sanitize-chunk-names/_expected/amd/_virtual_entry-1.js index f41ce27ab24..0b268a6c9a4 100644 --- a/test/chunking-form/samples/sanitize-chunk-names/_expected/amd/_virtual_entry-1.js +++ b/test/chunking-form/samples/sanitize-chunk-names/_expected/amd/_virtual_entry-1.js @@ -1,7 +1,7 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; var _virtual_entry1 = "\u0000virtual:entry-1"; return _virtual_entry1; -}); +})); diff --git a/test/chunking-form/samples/sanitize-chunk-names/_expected/amd/_virtual_entry-2.js b/test/chunking-form/samples/sanitize-chunk-names/_expected/amd/_virtual_entry-2.js index 5746e5e45e9..3ae42dce3b9 100644 --- a/test/chunking-form/samples/sanitize-chunk-names/_expected/amd/_virtual_entry-2.js +++ b/test/chunking-form/samples/sanitize-chunk-names/_expected/amd/_virtual_entry-2.js @@ -1,7 +1,7 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; var _virtual_entry2 = "\u0000virtual:entry-2"; return _virtual_entry2; -}); +})); diff --git a/test/chunking-form/samples/sanitize-chunk-names/_expected/amd/another-_slug_-_result.js b/test/chunking-form/samples/sanitize-chunk-names/_expected/amd/another-_slug_-_result.js new file mode 100644 index 00000000000..8084d5299ae --- /dev/null +++ b/test/chunking-form/samples/sanitize-chunk-names/_expected/amd/another-_slug_-_result.js @@ -0,0 +1,7 @@ +define((function () { 'use strict'; + + var another__slug___result = "another-[slug]-#result"; + + return another__slug___result; + +})); diff --git a/test/chunking-form/samples/sanitize-chunk-names/_expected/cjs/another-_slug_-_result.js b/test/chunking-form/samples/sanitize-chunk-names/_expected/cjs/another-_slug_-_result.js new file mode 100644 index 00000000000..f65b7e77854 --- /dev/null +++ b/test/chunking-form/samples/sanitize-chunk-names/_expected/cjs/another-_slug_-_result.js @@ -0,0 +1,5 @@ +'use strict'; + +var another__slug___result = "another-[slug]-#result"; + +module.exports = another__slug___result; diff --git a/test/chunking-form/samples/sanitize-chunk-names/_expected/es/_virtual_entry-1.js b/test/chunking-form/samples/sanitize-chunk-names/_expected/es/_virtual_entry-1.js index 9fa2c9b2926..85a32d22298 100644 --- a/test/chunking-form/samples/sanitize-chunk-names/_expected/es/_virtual_entry-1.js +++ b/test/chunking-form/samples/sanitize-chunk-names/_expected/es/_virtual_entry-1.js @@ -1,3 +1,3 @@ var _virtual_entry1 = "\u0000virtual:entry-1"; -export default _virtual_entry1; +export { _virtual_entry1 as default }; diff --git a/test/chunking-form/samples/sanitize-chunk-names/_expected/es/_virtual_entry-2.js b/test/chunking-form/samples/sanitize-chunk-names/_expected/es/_virtual_entry-2.js index c228f2ab38b..8d56d3ff099 100644 --- a/test/chunking-form/samples/sanitize-chunk-names/_expected/es/_virtual_entry-2.js +++ b/test/chunking-form/samples/sanitize-chunk-names/_expected/es/_virtual_entry-2.js @@ -1,3 +1,3 @@ var _virtual_entry2 = "\u0000virtual:entry-2"; -export default _virtual_entry2; +export { _virtual_entry2 as default }; diff --git a/test/chunking-form/samples/sanitize-chunk-names/_expected/es/another-_slug_-_result.js b/test/chunking-form/samples/sanitize-chunk-names/_expected/es/another-_slug_-_result.js new file mode 100644 index 00000000000..1e0602cfd60 --- /dev/null +++ b/test/chunking-form/samples/sanitize-chunk-names/_expected/es/another-_slug_-_result.js @@ -0,0 +1,3 @@ +var another__slug___result = "another-[slug]-#result"; + +export { another__slug___result as default }; diff --git a/test/chunking-form/samples/sanitize-chunk-names/_expected/system/_virtual_entry-1.js b/test/chunking-form/samples/sanitize-chunk-names/_expected/system/_virtual_entry-1.js index 26aafc0c353..3d20f87e51e 100644 --- a/test/chunking-form/samples/sanitize-chunk-names/_expected/system/_virtual_entry-1.js +++ b/test/chunking-form/samples/sanitize-chunk-names/_expected/system/_virtual_entry-1.js @@ -1,10 +1,10 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - var _virtual_entry1 = exports('default', "\u0000virtual:entry-1"); + var _virtual_entry1 = exports("default", "\u0000virtual:entry-1"); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/sanitize-chunk-names/_expected/system/_virtual_entry-2.js b/test/chunking-form/samples/sanitize-chunk-names/_expected/system/_virtual_entry-2.js index af4edfd003e..f3718b94948 100644 --- a/test/chunking-form/samples/sanitize-chunk-names/_expected/system/_virtual_entry-2.js +++ b/test/chunking-form/samples/sanitize-chunk-names/_expected/system/_virtual_entry-2.js @@ -1,10 +1,10 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - var _virtual_entry2 = exports('default', "\u0000virtual:entry-2"); + var _virtual_entry2 = exports("default", "\u0000virtual:entry-2"); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/sanitize-chunk-names/_expected/system/another-_slug_-_result.js b/test/chunking-form/samples/sanitize-chunk-names/_expected/system/another-_slug_-_result.js new file mode 100644 index 00000000000..ba5dc6c5a51 --- /dev/null +++ b/test/chunking-form/samples/sanitize-chunk-names/_expected/system/another-_slug_-_result.js @@ -0,0 +1,10 @@ +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + + var another__slug___result = exports("default", "another-[slug]-#result"); + + }) + }; +})); diff --git a/test/chunking-form/samples/sanitize-internal-exports/_config.js b/test/chunking-form/samples/sanitize-internal-exports/_config.js index b387cc182e6..bc1bda3508b 100644 --- a/test/chunking-form/samples/sanitize-internal-exports/_config.js +++ b/test/chunking-form/samples/sanitize-internal-exports/_config.js @@ -1,6 +1,6 @@ -module.exports = { +module.exports = defineTest({ description: 'make sure internal exports are sanitized', options: { input: ['main.js'] } -}; +}); diff --git a/test/chunking-form/samples/sanitize-internal-exports/_expected/amd/generated-lazy.js b/test/chunking-form/samples/sanitize-internal-exports/_expected/amd/generated-lazy.js index 2a891f78402..24c4cc63141 100644 --- a/test/chunking-form/samples/sanitize-internal-exports/_expected/amd/generated-lazy.js +++ b/test/chunking-form/samples/sanitize-internal-exports/_expected/amd/generated-lazy.js @@ -1,7 +1,7 @@ -define(['exports', './main'], function (exports, main) { 'use strict'; +define(['exports', './main'], (function (exports, main) { 'use strict'; var lazy = () => main.v1; exports.default = lazy; -}); +})); diff --git a/test/chunking-form/samples/sanitize-internal-exports/_expected/amd/main.js b/test/chunking-form/samples/sanitize-internal-exports/_expected/amd/main.js index 8e5567e744a..05da39c0842 100644 --- a/test/chunking-form/samples/sanitize-internal-exports/_expected/amd/main.js +++ b/test/chunking-form/samples/sanitize-internal-exports/_expected/amd/main.js @@ -1,4 +1,4 @@ -define(['require', 'exports'], function (require, exports) { 'use strict'; +define(['require', 'exports'], (function (require, exports) { 'use strict'; var v1, v2, @@ -273,7 +273,7 @@ define(['require', 'exports'], function (require, exports) { 'use strict'; v271, v272; - const lazy = new Promise(function (resolve, reject) { require(['./generated-lazy'], resolve, reject) }); + const lazy = new Promise(function (resolve, reject) { require(['./generated-lazy'], resolve, reject); }); exports.lazy = lazy; exports.v1 = v1; @@ -549,6 +549,4 @@ define(['require', 'exports'], function (require, exports) { 'use strict'; exports.v98 = v98; exports.v99 = v99; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/sanitize-internal-exports/_expected/cjs/main.js b/test/chunking-form/samples/sanitize-internal-exports/_expected/cjs/main.js index 37dd0facd48..a496761c74c 100644 --- a/test/chunking-form/samples/sanitize-internal-exports/_expected/cjs/main.js +++ b/test/chunking-form/samples/sanitize-internal-exports/_expected/cjs/main.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - var v1, v2, v3, diff --git a/test/chunking-form/samples/sanitize-internal-exports/_expected/es/generated-lazy.js b/test/chunking-form/samples/sanitize-internal-exports/_expected/es/generated-lazy.js index b2a43ed12d5..e798025c4ad 100644 --- a/test/chunking-form/samples/sanitize-internal-exports/_expected/es/generated-lazy.js +++ b/test/chunking-form/samples/sanitize-internal-exports/_expected/es/generated-lazy.js @@ -2,4 +2,4 @@ import { v1 } from './main.js'; var lazy = () => v1; -export default lazy; +export { lazy as default }; diff --git a/test/chunking-form/samples/sanitize-internal-exports/_expected/system/generated-lazy.js b/test/chunking-form/samples/sanitize-internal-exports/_expected/system/generated-lazy.js index c74475324d0..16297175719 100644 --- a/test/chunking-form/samples/sanitize-internal-exports/_expected/system/generated-lazy.js +++ b/test/chunking-form/samples/sanitize-internal-exports/_expected/system/generated-lazy.js @@ -1,14 +1,14 @@ -System.register(['./main.js'], function (exports) { +System.register(['./main.js'], (function (exports) { 'use strict'; var v1; return { setters: [function (module) { v1 = module.v1; }], - execute: function () { + execute: (function () { - var lazy = exports('default', () => v1); + var lazy = exports("default", () => v1); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/sanitize-internal-exports/_expected/system/main.js b/test/chunking-form/samples/sanitize-internal-exports/_expected/system/main.js index 8cd65e22484..07fb3c3b7db 100644 --- a/test/chunking-form/samples/sanitize-internal-exports/_expected/system/main.js +++ b/test/chunking-form/samples/sanitize-internal-exports/_expected/system/main.js @@ -1,282 +1,7 @@ -System.register([], function (exports, module) { +System.register([], (function (exports, module) { 'use strict'; return { - execute: function () { - - exports({ - v1: void 0, - v10: void 0, - v100: void 0, - v101: void 0, - v102: void 0, - v103: void 0, - v104: void 0, - v105: void 0, - v106: void 0, - v107: void 0, - v108: void 0, - v109: void 0, - v11: void 0, - v110: void 0, - v111: void 0, - v112: void 0, - v113: void 0, - v114: void 0, - v115: void 0, - v116: void 0, - v117: void 0, - v118: void 0, - v119: void 0, - v12: void 0, - v120: void 0, - v121: void 0, - v122: void 0, - v123: void 0, - v124: void 0, - v125: void 0, - v126: void 0, - v127: void 0, - v128: void 0, - v129: void 0, - v13: void 0, - v130: void 0, - v131: void 0, - v132: void 0, - v133: void 0, - v134: void 0, - v135: void 0, - v136: void 0, - v137: void 0, - v138: void 0, - v139: void 0, - v14: void 0, - v140: void 0, - v141: void 0, - v142: void 0, - v143: void 0, - v144: void 0, - v145: void 0, - v146: void 0, - v147: void 0, - v148: void 0, - v149: void 0, - v15: void 0, - v150: void 0, - v151: void 0, - v152: void 0, - v153: void 0, - v154: void 0, - v155: void 0, - v156: void 0, - v157: void 0, - v158: void 0, - v159: void 0, - v16: void 0, - v160: void 0, - v161: void 0, - v162: void 0, - v163: void 0, - v164: void 0, - v165: void 0, - v166: void 0, - v167: void 0, - v168: void 0, - v169: void 0, - v17: void 0, - v170: void 0, - v171: void 0, - v172: void 0, - v173: void 0, - v174: void 0, - v175: void 0, - v176: void 0, - v177: void 0, - v178: void 0, - v179: void 0, - v18: void 0, - v180: void 0, - v181: void 0, - v182: void 0, - v183: void 0, - v184: void 0, - v185: void 0, - v186: void 0, - v187: void 0, - v188: void 0, - v189: void 0, - v19: void 0, - v190: void 0, - v191: void 0, - v192: void 0, - v193: void 0, - v194: void 0, - v195: void 0, - v196: void 0, - v197: void 0, - v198: void 0, - v199: void 0, - v2: void 0, - v20: void 0, - v200: void 0, - v201: void 0, - v202: void 0, - v203: void 0, - v204: void 0, - v205: void 0, - v206: void 0, - v207: void 0, - v208: void 0, - v209: void 0, - v21: void 0, - v210: void 0, - v211: void 0, - v212: void 0, - v213: void 0, - v214: void 0, - v215: void 0, - v216: void 0, - v217: void 0, - v218: void 0, - v219: void 0, - v22: void 0, - v220: void 0, - v221: void 0, - v222: void 0, - v223: void 0, - v224: void 0, - v225: void 0, - v226: void 0, - v227: void 0, - v228: void 0, - v229: void 0, - v23: void 0, - v230: void 0, - v231: void 0, - v232: void 0, - v233: void 0, - v234: void 0, - v235: void 0, - v236: void 0, - v237: void 0, - v238: void 0, - v239: void 0, - v24: void 0, - v240: void 0, - v241: void 0, - v242: void 0, - v243: void 0, - v244: void 0, - v245: void 0, - v246: void 0, - v247: void 0, - v248: void 0, - v249: void 0, - v25: void 0, - v250: void 0, - v251: void 0, - v252: void 0, - v253: void 0, - v254: void 0, - v255: void 0, - v256: void 0, - v257: void 0, - v258: void 0, - v259: void 0, - v26: void 0, - v260: void 0, - v261: void 0, - v262: void 0, - v263: void 0, - v264: void 0, - v265: void 0, - v266: void 0, - v267: void 0, - v268: void 0, - v269: void 0, - v27: void 0, - v270: void 0, - v271: void 0, - v272: void 0, - v28: void 0, - v29: void 0, - v3: void 0, - v30: void 0, - v31: void 0, - v32: void 0, - v33: void 0, - v34: void 0, - v35: void 0, - v36: void 0, - v37: void 0, - v38: void 0, - v39: void 0, - v4: void 0, - v40: void 0, - v41: void 0, - v42: void 0, - v43: void 0, - v44: void 0, - v45: void 0, - v46: void 0, - v47: void 0, - v48: void 0, - v49: void 0, - v5: void 0, - v50: void 0, - v51: void 0, - v52: void 0, - v53: void 0, - v54: void 0, - v55: void 0, - v56: void 0, - v57: void 0, - v58: void 0, - v59: void 0, - v6: void 0, - v60: void 0, - v61: void 0, - v62: void 0, - v63: void 0, - v64: void 0, - v65: void 0, - v66: void 0, - v67: void 0, - v68: void 0, - v69: void 0, - v7: void 0, - v70: void 0, - v71: void 0, - v72: void 0, - v73: void 0, - v74: void 0, - v75: void 0, - v76: void 0, - v77: void 0, - v78: void 0, - v79: void 0, - v8: void 0, - v80: void 0, - v81: void 0, - v82: void 0, - v83: void 0, - v84: void 0, - v85: void 0, - v86: void 0, - v87: void 0, - v88: void 0, - v89: void 0, - v9: void 0, - v90: void 0, - v91: void 0, - v92: void 0, - v93: void 0, - v94: void 0, - v95: void 0, - v96: void 0, - v97: void 0, - v98: void 0, - v99: void 0 - }); + execute: (function () { var v1, v2, @@ -549,10 +274,10 @@ System.register([], function (exports, module) { v269, v270, v271, - v272; + v272; exports({ v1: v1, v2: v2, v3: v3, v4: v4, v5: v5, v6: v6, v7: v7, v8: v8, v9: v9, v10: v10, v11: v11, v12: v12, v13: v13, v14: v14, v15: v15, v16: v16, v17: v17, v18: v18, v19: v19, v20: v20, v21: v21, v22: v22, v23: v23, v24: v24, v25: v25, v26: v26, v27: v27, v28: v28, v29: v29, v30: v30, v31: v31, v32: v32, v33: v33, v34: v34, v35: v35, v36: v36, v37: v37, v38: v38, v39: v39, v40: v40, v41: v41, v42: v42, v43: v43, v44: v44, v45: v45, v46: v46, v47: v47, v48: v48, v49: v49, v50: v50, v51: v51, v52: v52, v53: v53, v54: v54, v55: v55, v56: v56, v57: v57, v58: v58, v59: v59, v60: v60, v61: v61, v62: v62, v63: v63, v64: v64, v65: v65, v66: v66, v67: v67, v68: v68, v69: v69, v70: v70, v71: v71, v72: v72, v73: v73, v74: v74, v75: v75, v76: v76, v77: v77, v78: v78, v79: v79, v80: v80, v81: v81, v82: v82, v83: v83, v84: v84, v85: v85, v86: v86, v87: v87, v88: v88, v89: v89, v90: v90, v91: v91, v92: v92, v93: v93, v94: v94, v95: v95, v96: v96, v97: v97, v98: v98, v99: v99, v100: v100, v101: v101, v102: v102, v103: v103, v104: v104, v105: v105, v106: v106, v107: v107, v108: v108, v109: v109, v110: v110, v111: v111, v112: v112, v113: v113, v114: v114, v115: v115, v116: v116, v117: v117, v118: v118, v119: v119, v120: v120, v121: v121, v122: v122, v123: v123, v124: v124, v125: v125, v126: v126, v127: v127, v128: v128, v129: v129, v130: v130, v131: v131, v132: v132, v133: v133, v134: v134, v135: v135, v136: v136, v137: v137, v138: v138, v139: v139, v140: v140, v141: v141, v142: v142, v143: v143, v144: v144, v145: v145, v146: v146, v147: v147, v148: v148, v149: v149, v150: v150, v151: v151, v152: v152, v153: v153, v154: v154, v155: v155, v156: v156, v157: v157, v158: v158, v159: v159, v160: v160, v161: v161, v162: v162, v163: v163, v164: v164, v165: v165, v166: v166, v167: v167, v168: v168, v169: v169, v170: v170, v171: v171, v172: v172, v173: v173, v174: v174, v175: v175, v176: v176, v177: v177, v178: v178, v179: v179, v180: v180, v181: v181, v182: v182, v183: v183, v184: v184, v185: v185, v186: v186, v187: v187, v188: v188, v189: v189, v190: v190, v191: v191, v192: v192, v193: v193, v194: v194, v195: v195, v196: v196, v197: v197, v198: v198, v199: v199, v200: v200, v201: v201, v202: v202, v203: v203, v204: v204, v205: v205, v206: v206, v207: v207, v208: v208, v209: v209, v210: v210, v211: v211, v212: v212, v213: v213, v214: v214, v215: v215, v216: v216, v217: v217, v218: v218, v219: v219, v220: v220, v221: v221, v222: v222, v223: v223, v224: v224, v225: v225, v226: v226, v227: v227, v228: v228, v229: v229, v230: v230, v231: v231, v232: v232, v233: v233, v234: v234, v235: v235, v236: v236, v237: v237, v238: v238, v239: v239, v240: v240, v241: v241, v242: v242, v243: v243, v244: v244, v245: v245, v246: v246, v247: v247, v248: v248, v249: v249, v250: v250, v251: v251, v252: v252, v253: v253, v254: v254, v255: v255, v256: v256, v257: v257, v258: v258, v259: v259, v260: v260, v261: v261, v262: v262, v263: v263, v264: v264, v265: v265, v266: v266, v267: v267, v268: v268, v269: v269, v270: v270, v271: v271, v272: v272 }); - const lazy = exports('lazy', module.import('./generated-lazy.js')); + const lazy = exports("lazy", module.import('./generated-lazy.js')); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/sanitize-percent-encoding1/_config.js b/test/chunking-form/samples/sanitize-percent-encoding1/_config.js new file mode 100644 index 00000000000..7681012d004 --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding1/_config.js @@ -0,0 +1,6 @@ +module.exports = defineTest({ + description: 'make sure illegal percent encoding is sanitized', + options: { + input: ['main.js'] + } +}); diff --git a/test/chunking-form/samples/sanitize-percent-encoding1/_expected/amd/main.js b/test/chunking-form/samples/sanitize-percent-encoding1/_expected/amd/main.js new file mode 100644 index 00000000000..1d4ce3a6aad --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding1/_expected/amd/main.js @@ -0,0 +1,24 @@ +define((function () { 'use strict'; + + function module1() { + console.log('foo%20bar'); + } + + function module2() { + console.log('foo%bar'); + } + + function module3() { + console.log('foo%E3%81%82bar'); + } + + function module4() { + console.log('foo%E3%81bar'); + } + + module1(); + module2(); + module3(); + module4(); + +})); diff --git a/test/chunking-form/samples/sanitize-percent-encoding1/_expected/cjs/main.js b/test/chunking-form/samples/sanitize-percent-encoding1/_expected/cjs/main.js new file mode 100644 index 00000000000..a697390075f --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding1/_expected/cjs/main.js @@ -0,0 +1,22 @@ +'use strict'; + +function module1() { + console.log('foo%20bar'); +} + +function module2() { + console.log('foo%bar'); +} + +function module3() { + console.log('foo%E3%81%82bar'); +} + +function module4() { + console.log('foo%E3%81bar'); +} + +module1(); +module2(); +module3(); +module4(); diff --git a/test/chunking-form/samples/sanitize-percent-encoding1/_expected/es/main.js b/test/chunking-form/samples/sanitize-percent-encoding1/_expected/es/main.js new file mode 100644 index 00000000000..71c6665688f --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding1/_expected/es/main.js @@ -0,0 +1,20 @@ +function module1() { + console.log('foo%20bar'); +} + +function module2() { + console.log('foo%bar'); +} + +function module3() { + console.log('foo%E3%81%82bar'); +} + +function module4() { + console.log('foo%E3%81bar'); +} + +module1(); +module2(); +module3(); +module4(); diff --git a/test/chunking-form/samples/sanitize-percent-encoding1/_expected/system/main.js b/test/chunking-form/samples/sanitize-percent-encoding1/_expected/system/main.js new file mode 100644 index 00000000000..b581ef78708 --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding1/_expected/system/main.js @@ -0,0 +1,29 @@ +System.register([], (function () { + 'use strict'; + return { + execute: (function () { + + function module1() { + console.log('foo%20bar'); + } + + function module2() { + console.log('foo%bar'); + } + + function module3() { + console.log('foo%E3%81%82bar'); + } + + function module4() { + console.log('foo%E3%81bar'); + } + + module1(); + module2(); + module3(); + module4(); + + }) + }; +})); diff --git a/test/chunking-form/samples/sanitize-percent-encoding1/foo%20bar.js b/test/chunking-form/samples/sanitize-percent-encoding1/foo%20bar.js new file mode 100644 index 00000000000..62faaa1dcd4 --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding1/foo%20bar.js @@ -0,0 +1,3 @@ +export function module1() { + console.log('foo%20bar'); +} diff --git a/test/chunking-form/samples/sanitize-percent-encoding1/foo%E3%81%82bar.js b/test/chunking-form/samples/sanitize-percent-encoding1/foo%E3%81%82bar.js new file mode 100644 index 00000000000..394b0346b06 --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding1/foo%E3%81%82bar.js @@ -0,0 +1,3 @@ +export function module3() { + console.log('foo%E3%81%82bar'); +} diff --git a/test/chunking-form/samples/sanitize-percent-encoding1/foo%E3%81bar.js b/test/chunking-form/samples/sanitize-percent-encoding1/foo%E3%81bar.js new file mode 100644 index 00000000000..0faac620393 --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding1/foo%E3%81bar.js @@ -0,0 +1,3 @@ +export function module4() { + console.log('foo%E3%81bar'); +} diff --git a/test/chunking-form/samples/sanitize-percent-encoding1/foo%bar.js b/test/chunking-form/samples/sanitize-percent-encoding1/foo%bar.js new file mode 100644 index 00000000000..7bf1be884fc --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding1/foo%bar.js @@ -0,0 +1,3 @@ +export function module2() { + console.log('foo%bar'); +} diff --git a/test/chunking-form/samples/sanitize-percent-encoding1/main.js b/test/chunking-form/samples/sanitize-percent-encoding1/main.js new file mode 100644 index 00000000000..bd76f12e727 --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding1/main.js @@ -0,0 +1,9 @@ +import { module1 } from './foo%20bar'; +import { module2 } from './foo%bar'; +import { module3 } from './foo%E3%81%82bar'; +import { module4 } from './foo%E3%81bar'; + +module1(); +module2(); +module3(); +module4(); diff --git a/test/chunking-form/samples/sanitize-percent-encoding2/_config.js b/test/chunking-form/samples/sanitize-percent-encoding2/_config.js new file mode 100644 index 00000000000..6a596f1ffea --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding2/_config.js @@ -0,0 +1,6 @@ +module.exports = defineTest({ + description: 'make sure illegal percent encoding is sanitized for dynamic imports', + options: { + input: ['main.js'] + } +}); diff --git a/test/chunking-form/samples/sanitize-percent-encoding2/_expected/amd/generated-foo_20bar.js b/test/chunking-form/samples/sanitize-percent-encoding2/_expected/amd/generated-foo_20bar.js new file mode 100644 index 00000000000..d9b628c8ad9 --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding2/_expected/amd/generated-foo_20bar.js @@ -0,0 +1,5 @@ +define((function () { 'use strict'; + + console.log('foo%20bar'); + +})); diff --git a/test/chunking-form/samples/sanitize-percent-encoding2/_expected/amd/generated-foo_E3_81_82bar.js b/test/chunking-form/samples/sanitize-percent-encoding2/_expected/amd/generated-foo_E3_81_82bar.js new file mode 100644 index 00000000000..09260e1a1a7 --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding2/_expected/amd/generated-foo_E3_81_82bar.js @@ -0,0 +1,5 @@ +define((function () { 'use strict'; + + console.log('foo%E3%81%82bar'); + +})); diff --git a/test/chunking-form/samples/sanitize-percent-encoding2/_expected/amd/generated-foo_E3_81bar.js b/test/chunking-form/samples/sanitize-percent-encoding2/_expected/amd/generated-foo_E3_81bar.js new file mode 100644 index 00000000000..71aabe25bbd --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding2/_expected/amd/generated-foo_E3_81bar.js @@ -0,0 +1,5 @@ +define((function () { 'use strict'; + + console.log('foo%E3%81bar'); + +})); diff --git a/test/chunking-form/samples/sanitize-percent-encoding2/_expected/amd/generated-foo_bar.js b/test/chunking-form/samples/sanitize-percent-encoding2/_expected/amd/generated-foo_bar.js new file mode 100644 index 00000000000..2aee12279e9 --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding2/_expected/amd/generated-foo_bar.js @@ -0,0 +1,5 @@ +define((function () { 'use strict'; + + console.log('foo%bar'); + +})); diff --git a/test/chunking-form/samples/sanitize-percent-encoding2/_expected/amd/main.js b/test/chunking-form/samples/sanitize-percent-encoding2/_expected/amd/main.js new file mode 100644 index 00000000000..d436cc2ddbe --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding2/_expected/amd/main.js @@ -0,0 +1,13 @@ +define(['require', 'exports'], (function (require, exports) { 'use strict'; + + const lazy1 = new Promise(function (resolve, reject) { require(['./generated-foo_20bar'], resolve, reject); }); + const lazy2 = new Promise(function (resolve, reject) { require(['./generated-foo_bar'], resolve, reject); }); + const lazy3 = new Promise(function (resolve, reject) { require(['./generated-foo_E3_81_82bar'], resolve, reject); }); + const lazy4 = new Promise(function (resolve, reject) { require(['./generated-foo_E3_81bar'], resolve, reject); }); + + exports.lazy1 = lazy1; + exports.lazy2 = lazy2; + exports.lazy3 = lazy3; + exports.lazy4 = lazy4; + +})); diff --git a/test/chunking-form/samples/sanitize-percent-encoding2/_expected/cjs/generated-foo_20bar.js b/test/chunking-form/samples/sanitize-percent-encoding2/_expected/cjs/generated-foo_20bar.js new file mode 100644 index 00000000000..186700cae23 --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding2/_expected/cjs/generated-foo_20bar.js @@ -0,0 +1,3 @@ +'use strict'; + +console.log('foo%20bar'); diff --git a/test/chunking-form/samples/sanitize-percent-encoding2/_expected/cjs/generated-foo_E3_81_82bar.js b/test/chunking-form/samples/sanitize-percent-encoding2/_expected/cjs/generated-foo_E3_81_82bar.js new file mode 100644 index 00000000000..8d509077865 --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding2/_expected/cjs/generated-foo_E3_81_82bar.js @@ -0,0 +1,3 @@ +'use strict'; + +console.log('foo%E3%81%82bar'); diff --git a/test/chunking-form/samples/sanitize-percent-encoding2/_expected/cjs/generated-foo_E3_81bar.js b/test/chunking-form/samples/sanitize-percent-encoding2/_expected/cjs/generated-foo_E3_81bar.js new file mode 100644 index 00000000000..acf063d905d --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding2/_expected/cjs/generated-foo_E3_81bar.js @@ -0,0 +1,3 @@ +'use strict'; + +console.log('foo%E3%81bar'); diff --git a/test/chunking-form/samples/sanitize-percent-encoding2/_expected/cjs/generated-foo_bar.js b/test/chunking-form/samples/sanitize-percent-encoding2/_expected/cjs/generated-foo_bar.js new file mode 100644 index 00000000000..5c05a1e8195 --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding2/_expected/cjs/generated-foo_bar.js @@ -0,0 +1,3 @@ +'use strict'; + +console.log('foo%bar'); diff --git a/test/chunking-form/samples/sanitize-percent-encoding2/_expected/cjs/main.js b/test/chunking-form/samples/sanitize-percent-encoding2/_expected/cjs/main.js new file mode 100644 index 00000000000..c9b23f67fb7 --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding2/_expected/cjs/main.js @@ -0,0 +1,11 @@ +'use strict'; + +const lazy1 = Promise.resolve().then(function () { return require('./generated-foo_20bar.js'); }); +const lazy2 = Promise.resolve().then(function () { return require('./generated-foo_bar.js'); }); +const lazy3 = Promise.resolve().then(function () { return require('./generated-foo_E3_81_82bar.js'); }); +const lazy4 = Promise.resolve().then(function () { return require('./generated-foo_E3_81bar.js'); }); + +exports.lazy1 = lazy1; +exports.lazy2 = lazy2; +exports.lazy3 = lazy3; +exports.lazy4 = lazy4; diff --git a/test/chunking-form/samples/sanitize-percent-encoding2/_expected/es/generated-foo_20bar.js b/test/chunking-form/samples/sanitize-percent-encoding2/_expected/es/generated-foo_20bar.js new file mode 100644 index 00000000000..522490d6ca2 --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding2/_expected/es/generated-foo_20bar.js @@ -0,0 +1 @@ +console.log('foo%20bar'); diff --git a/test/chunking-form/samples/sanitize-percent-encoding2/_expected/es/generated-foo_E3_81_82bar.js b/test/chunking-form/samples/sanitize-percent-encoding2/_expected/es/generated-foo_E3_81_82bar.js new file mode 100644 index 00000000000..20a52edefd3 --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding2/_expected/es/generated-foo_E3_81_82bar.js @@ -0,0 +1 @@ +console.log('foo%E3%81%82bar'); diff --git a/test/chunking-form/samples/sanitize-percent-encoding2/_expected/es/generated-foo_E3_81bar.js b/test/chunking-form/samples/sanitize-percent-encoding2/_expected/es/generated-foo_E3_81bar.js new file mode 100644 index 00000000000..790aefd8ff3 --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding2/_expected/es/generated-foo_E3_81bar.js @@ -0,0 +1 @@ +console.log('foo%E3%81bar'); diff --git a/test/chunking-form/samples/sanitize-percent-encoding2/_expected/es/generated-foo_bar.js b/test/chunking-form/samples/sanitize-percent-encoding2/_expected/es/generated-foo_bar.js new file mode 100644 index 00000000000..cc1acddddb4 --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding2/_expected/es/generated-foo_bar.js @@ -0,0 +1 @@ +console.log('foo%bar'); diff --git a/test/chunking-form/samples/sanitize-percent-encoding2/_expected/es/main.js b/test/chunking-form/samples/sanitize-percent-encoding2/_expected/es/main.js new file mode 100644 index 00000000000..79aaf34044f --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding2/_expected/es/main.js @@ -0,0 +1,6 @@ +const lazy1 = import('./generated-foo_20bar.js'); +const lazy2 = import('./generated-foo_bar.js'); +const lazy3 = import('./generated-foo_E3_81_82bar.js'); +const lazy4 = import('./generated-foo_E3_81bar.js'); + +export { lazy1, lazy2, lazy3, lazy4 }; diff --git a/test/chunking-form/samples/sanitize-percent-encoding2/_expected/system/generated-foo_20bar.js b/test/chunking-form/samples/sanitize-percent-encoding2/_expected/system/generated-foo_20bar.js new file mode 100644 index 00000000000..001206a011f --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding2/_expected/system/generated-foo_20bar.js @@ -0,0 +1,10 @@ +System.register([], (function () { + 'use strict'; + return { + execute: (function () { + + console.log('foo%20bar'); + + }) + }; +})); diff --git a/test/chunking-form/samples/sanitize-percent-encoding2/_expected/system/generated-foo_E3_81_82bar.js b/test/chunking-form/samples/sanitize-percent-encoding2/_expected/system/generated-foo_E3_81_82bar.js new file mode 100644 index 00000000000..b4c31ee0187 --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding2/_expected/system/generated-foo_E3_81_82bar.js @@ -0,0 +1,10 @@ +System.register([], (function () { + 'use strict'; + return { + execute: (function () { + + console.log('foo%E3%81%82bar'); + + }) + }; +})); diff --git a/test/chunking-form/samples/sanitize-percent-encoding2/_expected/system/generated-foo_E3_81bar.js b/test/chunking-form/samples/sanitize-percent-encoding2/_expected/system/generated-foo_E3_81bar.js new file mode 100644 index 00000000000..f750c3ae963 --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding2/_expected/system/generated-foo_E3_81bar.js @@ -0,0 +1,10 @@ +System.register([], (function () { + 'use strict'; + return { + execute: (function () { + + console.log('foo%E3%81bar'); + + }) + }; +})); diff --git a/test/chunking-form/samples/sanitize-percent-encoding2/_expected/system/generated-foo_bar.js b/test/chunking-form/samples/sanitize-percent-encoding2/_expected/system/generated-foo_bar.js new file mode 100644 index 00000000000..b060386b139 --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding2/_expected/system/generated-foo_bar.js @@ -0,0 +1,10 @@ +System.register([], (function () { + 'use strict'; + return { + execute: (function () { + + console.log('foo%bar'); + + }) + }; +})); diff --git a/test/chunking-form/samples/sanitize-percent-encoding2/_expected/system/main.js b/test/chunking-form/samples/sanitize-percent-encoding2/_expected/system/main.js new file mode 100644 index 00000000000..2dc4c5ddad2 --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding2/_expected/system/main.js @@ -0,0 +1,13 @@ +System.register([], (function (exports, module) { + 'use strict'; + return { + execute: (function () { + + const lazy1 = exports("lazy1", module.import('./generated-foo_20bar.js')); + const lazy2 = exports("lazy2", module.import('./generated-foo_bar.js')); + const lazy3 = exports("lazy3", module.import('./generated-foo_E3_81_82bar.js')); + const lazy4 = exports("lazy4", module.import('./generated-foo_E3_81bar.js')); + + }) + }; +})); diff --git a/test/chunking-form/samples/sanitize-percent-encoding2/foo%20bar.js b/test/chunking-form/samples/sanitize-percent-encoding2/foo%20bar.js new file mode 100644 index 00000000000..522490d6ca2 --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding2/foo%20bar.js @@ -0,0 +1 @@ +console.log('foo%20bar'); diff --git a/test/chunking-form/samples/sanitize-percent-encoding2/foo%E3%81%82bar.js b/test/chunking-form/samples/sanitize-percent-encoding2/foo%E3%81%82bar.js new file mode 100644 index 00000000000..20a52edefd3 --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding2/foo%E3%81%82bar.js @@ -0,0 +1 @@ +console.log('foo%E3%81%82bar'); diff --git a/test/chunking-form/samples/sanitize-percent-encoding2/foo%E3%81bar.js b/test/chunking-form/samples/sanitize-percent-encoding2/foo%E3%81bar.js new file mode 100644 index 00000000000..790aefd8ff3 --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding2/foo%E3%81bar.js @@ -0,0 +1 @@ +console.log('foo%E3%81bar'); diff --git a/test/chunking-form/samples/sanitize-percent-encoding2/foo%bar.js b/test/chunking-form/samples/sanitize-percent-encoding2/foo%bar.js new file mode 100644 index 00000000000..cc1acddddb4 --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding2/foo%bar.js @@ -0,0 +1 @@ +console.log('foo%bar'); diff --git a/test/chunking-form/samples/sanitize-percent-encoding2/main.js b/test/chunking-form/samples/sanitize-percent-encoding2/main.js new file mode 100644 index 00000000000..87093e4b87e --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding2/main.js @@ -0,0 +1,4 @@ +export const lazy1 = import('./foo%20bar'); +export const lazy2 = import('./foo%bar'); +export const lazy3 = import('./foo%E3%81%82bar'); +export const lazy4 = import('./foo%E3%81bar'); diff --git a/test/chunking-form/samples/sanitize-percent-encoding3/_config.js b/test/chunking-form/samples/sanitize-percent-encoding3/_config.js new file mode 100644 index 00000000000..52230552d5b --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding3/_config.js @@ -0,0 +1,20 @@ +module.exports = defineTest({ + description: 'make sure illegal percent encoding is sanitized for virtual entry points', + options: { + input: ['main'], + plugins: [ + { + options(options) { + options.input = ['foo%bar', 'foo%20bar', 'foo%E3%81%82bar', 'foo%E3%81bar']; + return options; + }, + resolveId(id) { + return id; + }, + load(id) { + return 'export default ' + JSON.stringify(id); + } + } + ] + } +}); diff --git a/test/chunking-form/samples/sanitize-percent-encoding3/_expected/amd/foo_20bar.js b/test/chunking-form/samples/sanitize-percent-encoding3/_expected/amd/foo_20bar.js new file mode 100644 index 00000000000..29f1883f999 --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding3/_expected/amd/foo_20bar.js @@ -0,0 +1,7 @@ +define((function () { 'use strict'; + + var foo_20bar = "foo%20bar"; + + return foo_20bar; + +})); diff --git a/test/chunking-form/samples/sanitize-percent-encoding3/_expected/amd/foo_E3_81_82bar.js b/test/chunking-form/samples/sanitize-percent-encoding3/_expected/amd/foo_E3_81_82bar.js new file mode 100644 index 00000000000..7f23a1c35dd --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding3/_expected/amd/foo_E3_81_82bar.js @@ -0,0 +1,7 @@ +define((function () { 'use strict'; + + var foo_E3_81_82bar = "foo%E3%81%82bar"; + + return foo_E3_81_82bar; + +})); diff --git a/test/chunking-form/samples/sanitize-percent-encoding3/_expected/amd/foo_E3_81bar.js b/test/chunking-form/samples/sanitize-percent-encoding3/_expected/amd/foo_E3_81bar.js new file mode 100644 index 00000000000..3015861872d --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding3/_expected/amd/foo_E3_81bar.js @@ -0,0 +1,7 @@ +define((function () { 'use strict'; + + var foo_E3_81bar = "foo%E3%81bar"; + + return foo_E3_81bar; + +})); diff --git a/test/chunking-form/samples/sanitize-percent-encoding3/_expected/amd/foo_bar.js b/test/chunking-form/samples/sanitize-percent-encoding3/_expected/amd/foo_bar.js new file mode 100644 index 00000000000..292b7be9a8a --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding3/_expected/amd/foo_bar.js @@ -0,0 +1,7 @@ +define((function () { 'use strict'; + + var foo_bar = "foo%bar"; + + return foo_bar; + +})); diff --git a/test/chunking-form/samples/sanitize-percent-encoding3/_expected/cjs/foo_20bar.js b/test/chunking-form/samples/sanitize-percent-encoding3/_expected/cjs/foo_20bar.js new file mode 100644 index 00000000000..81775d75d55 --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding3/_expected/cjs/foo_20bar.js @@ -0,0 +1,5 @@ +'use strict'; + +var foo_20bar = "foo%20bar"; + +module.exports = foo_20bar; diff --git a/test/chunking-form/samples/sanitize-percent-encoding3/_expected/cjs/foo_E3_81_82bar.js b/test/chunking-form/samples/sanitize-percent-encoding3/_expected/cjs/foo_E3_81_82bar.js new file mode 100644 index 00000000000..5708ee7bbe5 --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding3/_expected/cjs/foo_E3_81_82bar.js @@ -0,0 +1,5 @@ +'use strict'; + +var foo_E3_81_82bar = "foo%E3%81%82bar"; + +module.exports = foo_E3_81_82bar; diff --git a/test/chunking-form/samples/sanitize-percent-encoding3/_expected/cjs/foo_E3_81bar.js b/test/chunking-form/samples/sanitize-percent-encoding3/_expected/cjs/foo_E3_81bar.js new file mode 100644 index 00000000000..2b0ef97c1f7 --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding3/_expected/cjs/foo_E3_81bar.js @@ -0,0 +1,5 @@ +'use strict'; + +var foo_E3_81bar = "foo%E3%81bar"; + +module.exports = foo_E3_81bar; diff --git a/test/chunking-form/samples/sanitize-percent-encoding3/_expected/cjs/foo_bar.js b/test/chunking-form/samples/sanitize-percent-encoding3/_expected/cjs/foo_bar.js new file mode 100644 index 00000000000..1a9eb2ddab8 --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding3/_expected/cjs/foo_bar.js @@ -0,0 +1,5 @@ +'use strict'; + +var foo_bar = "foo%bar"; + +module.exports = foo_bar; diff --git a/test/chunking-form/samples/sanitize-percent-encoding3/_expected/es/foo_20bar.js b/test/chunking-form/samples/sanitize-percent-encoding3/_expected/es/foo_20bar.js new file mode 100644 index 00000000000..52120eeaaf3 --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding3/_expected/es/foo_20bar.js @@ -0,0 +1,3 @@ +var foo_20bar = "foo%20bar"; + +export { foo_20bar as default }; diff --git a/test/chunking-form/samples/sanitize-percent-encoding3/_expected/es/foo_E3_81_82bar.js b/test/chunking-form/samples/sanitize-percent-encoding3/_expected/es/foo_E3_81_82bar.js new file mode 100644 index 00000000000..f5c8c225b30 --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding3/_expected/es/foo_E3_81_82bar.js @@ -0,0 +1,3 @@ +var foo_E3_81_82bar = "foo%E3%81%82bar"; + +export { foo_E3_81_82bar as default }; diff --git a/test/chunking-form/samples/sanitize-percent-encoding3/_expected/es/foo_E3_81bar.js b/test/chunking-form/samples/sanitize-percent-encoding3/_expected/es/foo_E3_81bar.js new file mode 100644 index 00000000000..0fefbf64a43 --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding3/_expected/es/foo_E3_81bar.js @@ -0,0 +1,3 @@ +var foo_E3_81bar = "foo%E3%81bar"; + +export { foo_E3_81bar as default }; diff --git a/test/chunking-form/samples/sanitize-percent-encoding3/_expected/es/foo_bar.js b/test/chunking-form/samples/sanitize-percent-encoding3/_expected/es/foo_bar.js new file mode 100644 index 00000000000..9634f9d877c --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding3/_expected/es/foo_bar.js @@ -0,0 +1,3 @@ +var foo_bar = "foo%bar"; + +export { foo_bar as default }; diff --git a/test/chunking-form/samples/sanitize-percent-encoding3/_expected/system/foo_20bar.js b/test/chunking-form/samples/sanitize-percent-encoding3/_expected/system/foo_20bar.js new file mode 100644 index 00000000000..8e31ab66304 --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding3/_expected/system/foo_20bar.js @@ -0,0 +1,10 @@ +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + + var foo_20bar = exports("default", "foo%20bar"); + + }) + }; +})); diff --git a/test/chunking-form/samples/sanitize-percent-encoding3/_expected/system/foo_E3_81_82bar.js b/test/chunking-form/samples/sanitize-percent-encoding3/_expected/system/foo_E3_81_82bar.js new file mode 100644 index 00000000000..0d0712f191c --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding3/_expected/system/foo_E3_81_82bar.js @@ -0,0 +1,10 @@ +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + + var foo_E3_81_82bar = exports("default", "foo%E3%81%82bar"); + + }) + }; +})); diff --git a/test/chunking-form/samples/sanitize-percent-encoding3/_expected/system/foo_E3_81bar.js b/test/chunking-form/samples/sanitize-percent-encoding3/_expected/system/foo_E3_81bar.js new file mode 100644 index 00000000000..6ff12d465dd --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding3/_expected/system/foo_E3_81bar.js @@ -0,0 +1,10 @@ +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + + var foo_E3_81bar = exports("default", "foo%E3%81bar"); + + }) + }; +})); diff --git a/test/chunking-form/samples/sanitize-percent-encoding3/_expected/system/foo_bar.js b/test/chunking-form/samples/sanitize-percent-encoding3/_expected/system/foo_bar.js new file mode 100644 index 00000000000..202e15f9f5e --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding3/_expected/system/foo_bar.js @@ -0,0 +1,10 @@ +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + + var foo_bar = exports("default", "foo%bar"); + + }) + }; +})); diff --git a/test/chunking-form/samples/sanitize-percent-encoding3/main.js b/test/chunking-form/samples/sanitize-percent-encoding3/main.js new file mode 100644 index 00000000000..c0b933d7b56 --- /dev/null +++ b/test/chunking-form/samples/sanitize-percent-encoding3/main.js @@ -0,0 +1 @@ +console.log('main'); diff --git a/test/chunking-form/samples/side-effect-free-dependencies/avoid-imports-preserve-modules/_config.js b/test/chunking-form/samples/side-effect-free-dependencies/avoid-imports-preserve-modules/_config.js index 48c8a85b3ff..f705ab8af4b 100644 --- a/test/chunking-form/samples/side-effect-free-dependencies/avoid-imports-preserve-modules/_config.js +++ b/test/chunking-form/samples/side-effect-free-dependencies/avoid-imports-preserve-modules/_config.js @@ -1,7 +1,7 @@ -module.exports = { +module.exports = defineTest({ description: 'avoids empty imports if they do not have side-effects when preserving modules (#3359)', options: { output: { preserveModules: true } } -}; +}); diff --git a/test/chunking-form/samples/side-effect-free-dependencies/avoid-imports-preserve-modules/_expected/amd/a.js b/test/chunking-form/samples/side-effect-free-dependencies/avoid-imports-preserve-modules/_expected/amd/a.js index a0ee4d5c962..3cffb947ed7 100644 --- a/test/chunking-form/samples/side-effect-free-dependencies/avoid-imports-preserve-modules/_expected/amd/a.js +++ b/test/chunking-form/samples/side-effect-free-dependencies/avoid-imports-preserve-modules/_expected/amd/a.js @@ -1,9 +1,7 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; const a = 1; exports.a = a; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/side-effect-free-dependencies/avoid-imports-preserve-modules/_expected/amd/b.js b/test/chunking-form/samples/side-effect-free-dependencies/avoid-imports-preserve-modules/_expected/amd/b.js index 71d3b650e8d..b24bc116cef 100644 --- a/test/chunking-form/samples/side-effect-free-dependencies/avoid-imports-preserve-modules/_expected/amd/b.js +++ b/test/chunking-form/samples/side-effect-free-dependencies/avoid-imports-preserve-modules/_expected/amd/b.js @@ -1,9 +1,7 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; const b = 2; exports.b = b; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/side-effect-free-dependencies/avoid-imports-preserve-modules/_expected/amd/main.js b/test/chunking-form/samples/side-effect-free-dependencies/avoid-imports-preserve-modules/_expected/amd/main.js index 854a7e8dca1..4e0843caa8b 100644 --- a/test/chunking-form/samples/side-effect-free-dependencies/avoid-imports-preserve-modules/_expected/amd/main.js +++ b/test/chunking-form/samples/side-effect-free-dependencies/avoid-imports-preserve-modules/_expected/amd/main.js @@ -1,5 +1,5 @@ -define(['./a', './one'], function (a, one) { 'use strict'; +define(['./a', './one'], (function (a, one) { 'use strict'; console.log(a.a + one.d); -}); +})); diff --git a/test/chunking-form/samples/side-effect-free-dependencies/avoid-imports-preserve-modules/_expected/amd/one.js b/test/chunking-form/samples/side-effect-free-dependencies/avoid-imports-preserve-modules/_expected/amd/one.js index 2d8ca9bd394..2c0c07355e0 100644 --- a/test/chunking-form/samples/side-effect-free-dependencies/avoid-imports-preserve-modules/_expected/amd/one.js +++ b/test/chunking-form/samples/side-effect-free-dependencies/avoid-imports-preserve-modules/_expected/amd/one.js @@ -1,9 +1,7 @@ -define(['exports', './b'], function (exports, b) { 'use strict'; +define(['exports', './b'], (function (exports, b) { 'use strict'; const d = b.b + 4; exports.d = d; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/side-effect-free-dependencies/avoid-imports-preserve-modules/_expected/cjs/a.js b/test/chunking-form/samples/side-effect-free-dependencies/avoid-imports-preserve-modules/_expected/cjs/a.js index 97007408241..418c69d2577 100644 --- a/test/chunking-form/samples/side-effect-free-dependencies/avoid-imports-preserve-modules/_expected/cjs/a.js +++ b/test/chunking-form/samples/side-effect-free-dependencies/avoid-imports-preserve-modules/_expected/cjs/a.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - const a = 1; exports.a = a; diff --git a/test/chunking-form/samples/side-effect-free-dependencies/avoid-imports-preserve-modules/_expected/cjs/b.js b/test/chunking-form/samples/side-effect-free-dependencies/avoid-imports-preserve-modules/_expected/cjs/b.js index 3c417e8458a..f3fc6f22489 100644 --- a/test/chunking-form/samples/side-effect-free-dependencies/avoid-imports-preserve-modules/_expected/cjs/b.js +++ b/test/chunking-form/samples/side-effect-free-dependencies/avoid-imports-preserve-modules/_expected/cjs/b.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - const b = 2; exports.b = b; diff --git a/test/chunking-form/samples/side-effect-free-dependencies/avoid-imports-preserve-modules/_expected/cjs/one.js b/test/chunking-form/samples/side-effect-free-dependencies/avoid-imports-preserve-modules/_expected/cjs/one.js index 9eea4c87a9f..98e3a99e3a3 100644 --- a/test/chunking-form/samples/side-effect-free-dependencies/avoid-imports-preserve-modules/_expected/cjs/one.js +++ b/test/chunking-form/samples/side-effect-free-dependencies/avoid-imports-preserve-modules/_expected/cjs/one.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - var b = require('./b.js'); const d = b.b + 4; diff --git a/test/chunking-form/samples/side-effect-free-dependencies/avoid-imports-preserve-modules/_expected/system/a.js b/test/chunking-form/samples/side-effect-free-dependencies/avoid-imports-preserve-modules/_expected/system/a.js index 50f0d7760ca..d1765ca7ff3 100644 --- a/test/chunking-form/samples/side-effect-free-dependencies/avoid-imports-preserve-modules/_expected/system/a.js +++ b/test/chunking-form/samples/side-effect-free-dependencies/avoid-imports-preserve-modules/_expected/system/a.js @@ -1,10 +1,10 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - const a = exports('a', 1); + const a = exports("a", 1); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/side-effect-free-dependencies/avoid-imports-preserve-modules/_expected/system/b.js b/test/chunking-form/samples/side-effect-free-dependencies/avoid-imports-preserve-modules/_expected/system/b.js index baa28369184..b6383d1016f 100644 --- a/test/chunking-form/samples/side-effect-free-dependencies/avoid-imports-preserve-modules/_expected/system/b.js +++ b/test/chunking-form/samples/side-effect-free-dependencies/avoid-imports-preserve-modules/_expected/system/b.js @@ -1,10 +1,10 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - const b = exports('b', 2); + const b = exports("b", 2); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/side-effect-free-dependencies/avoid-imports-preserve-modules/_expected/system/main.js b/test/chunking-form/samples/side-effect-free-dependencies/avoid-imports-preserve-modules/_expected/system/main.js index 306aa2895cd..fc9155ecdac 100644 --- a/test/chunking-form/samples/side-effect-free-dependencies/avoid-imports-preserve-modules/_expected/system/main.js +++ b/test/chunking-form/samples/side-effect-free-dependencies/avoid-imports-preserve-modules/_expected/system/main.js @@ -1,4 +1,4 @@ -System.register(['./a.js', './one.js'], function () { +System.register(['./a.js', './one.js'], (function () { 'use strict'; var a, d; return { @@ -7,10 +7,10 @@ System.register(['./a.js', './one.js'], function () { }, function (module) { d = module.d; }], - execute: function () { + execute: (function () { console.log(a + d); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/side-effect-free-dependencies/avoid-imports-preserve-modules/_expected/system/one.js b/test/chunking-form/samples/side-effect-free-dependencies/avoid-imports-preserve-modules/_expected/system/one.js index dac01a3453c..839bd3795cb 100644 --- a/test/chunking-form/samples/side-effect-free-dependencies/avoid-imports-preserve-modules/_expected/system/one.js +++ b/test/chunking-form/samples/side-effect-free-dependencies/avoid-imports-preserve-modules/_expected/system/one.js @@ -1,14 +1,14 @@ -System.register(['./b.js'], function (exports) { +System.register(['./b.js'], (function (exports) { 'use strict'; var b; return { setters: [function (module) { b = module.b; }], - execute: function () { + execute: (function () { - const d = exports('d', b + 4); + const d = exports("d", b + 4); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/side-effect-free-dependencies/avoid-side-effect-free-empty-imports/_config.js b/test/chunking-form/samples/side-effect-free-dependencies/avoid-side-effect-free-empty-imports/_config.js index 78767a46819..c558939ed93 100644 --- a/test/chunking-form/samples/side-effect-free-dependencies/avoid-side-effect-free-empty-imports/_config.js +++ b/test/chunking-form/samples/side-effect-free-dependencies/avoid-side-effect-free-empty-imports/_config.js @@ -1,7 +1,7 @@ -module.exports = { +module.exports = defineTest({ description: 'avoids empty imports if they do not have side-effects', options: { input: ['main1', 'main2'], external: ['external-side-effect'] } -}; +}); diff --git a/test/chunking-form/samples/side-effect-free-dependencies/avoid-side-effect-free-empty-imports/_expected/amd/main1.js b/test/chunking-form/samples/side-effect-free-dependencies/avoid-side-effect-free-empty-imports/_expected/amd/main1.js index 8acd4520991..43b937ba19b 100644 --- a/test/chunking-form/samples/side-effect-free-dependencies/avoid-side-effect-free-empty-imports/_expected/amd/main1.js +++ b/test/chunking-form/samples/side-effect-free-dependencies/avoid-side-effect-free-empty-imports/_expected/amd/main1.js @@ -1,4 +1,4 @@ -define(['external-side-effect'], function (externalSideEffect) { 'use strict'; +define(['external-side-effect'], (function (externalSideEffect) { 'use strict'; function onlyUsedByOne() { console.log('Hello'); @@ -6,4 +6,4 @@ define(['external-side-effect'], function (externalSideEffect) { 'use strict'; onlyUsedByOne(); -}); +})); diff --git a/test/chunking-form/samples/side-effect-free-dependencies/avoid-side-effect-free-empty-imports/_expected/amd/main2.js b/test/chunking-form/samples/side-effect-free-dependencies/avoid-side-effect-free-empty-imports/_expected/amd/main2.js index 52c48560358..f8bce44d5c9 100644 --- a/test/chunking-form/samples/side-effect-free-dependencies/avoid-side-effect-free-empty-imports/_expected/amd/main2.js +++ b/test/chunking-form/samples/side-effect-free-dependencies/avoid-side-effect-free-empty-imports/_expected/amd/main2.js @@ -1,5 +1,5 @@ -define(['external-side-effect'], function (externalSideEffect) { 'use strict'; +define(['external-side-effect'], (function (externalSideEffect) { 'use strict'; console.log('main2'); -}); +})); diff --git a/test/chunking-form/samples/side-effect-free-dependencies/avoid-side-effect-free-empty-imports/_expected/system/main1.js b/test/chunking-form/samples/side-effect-free-dependencies/avoid-side-effect-free-empty-imports/_expected/system/main1.js index 184dec65313..580b3148a28 100644 --- a/test/chunking-form/samples/side-effect-free-dependencies/avoid-side-effect-free-empty-imports/_expected/system/main1.js +++ b/test/chunking-form/samples/side-effect-free-dependencies/avoid-side-effect-free-empty-imports/_expected/system/main1.js @@ -1,8 +1,8 @@ -System.register(['external-side-effect'], function () { +System.register(['external-side-effect'], (function () { 'use strict'; return { - setters: [function () {}], - execute: function () { + setters: [null], + execute: (function () { function onlyUsedByOne() { console.log('Hello'); @@ -10,6 +10,6 @@ System.register(['external-side-effect'], function () { onlyUsedByOne(); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/side-effect-free-dependencies/avoid-side-effect-free-empty-imports/_expected/system/main2.js b/test/chunking-form/samples/side-effect-free-dependencies/avoid-side-effect-free-empty-imports/_expected/system/main2.js index 978a1d82672..1cbf54d6293 100644 --- a/test/chunking-form/samples/side-effect-free-dependencies/avoid-side-effect-free-empty-imports/_expected/system/main2.js +++ b/test/chunking-form/samples/side-effect-free-dependencies/avoid-side-effect-free-empty-imports/_expected/system/main2.js @@ -1,11 +1,11 @@ -System.register(['external-side-effect'], function () { +System.register(['external-side-effect'], (function () { 'use strict'; return { - setters: [function () {}], - execute: function () { + setters: [null], + execute: (function () { console.log('main2'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/side-effect-free-dependencies/hoist-side-effect-modules/_config.js b/test/chunking-form/samples/side-effect-free-dependencies/hoist-side-effect-modules/_config.js index 0e131b8996e..96fd2d53044 100644 --- a/test/chunking-form/samples/side-effect-free-dependencies/hoist-side-effect-modules/_config.js +++ b/test/chunking-form/samples/side-effect-free-dependencies/hoist-side-effect-modules/_config.js @@ -1,7 +1,7 @@ -module.exports = { +module.exports = defineTest({ description: 'hoist side-effect imports when avoiding empty imports', options: { input: ['main1', 'main2', 'main3'] }, expectedWarnings: ['CIRCULAR_DEPENDENCY'] -}; +}); diff --git a/test/chunking-form/samples/side-effect-free-dependencies/hoist-side-effect-modules/_expected/amd/generated-dep2-effect.js b/test/chunking-form/samples/side-effect-free-dependencies/hoist-side-effect-modules/_expected/amd/generated-dep2-effect.js index af27f254599..8b19534cf38 100644 --- a/test/chunking-form/samples/side-effect-free-dependencies/hoist-side-effect-modules/_expected/amd/generated-dep2-effect.js +++ b/test/chunking-form/samples/side-effect-free-dependencies/hoist-side-effect-modules/_expected/amd/generated-dep2-effect.js @@ -1,5 +1,5 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; console.log('dep2'); -}); +})); diff --git a/test/chunking-form/samples/side-effect-free-dependencies/hoist-side-effect-modules/_expected/amd/generated-dep4-effect.js b/test/chunking-form/samples/side-effect-free-dependencies/hoist-side-effect-modules/_expected/amd/generated-dep4-effect.js index 8848968aaf5..75e0b0258a9 100644 --- a/test/chunking-form/samples/side-effect-free-dependencies/hoist-side-effect-modules/_expected/amd/generated-dep4-effect.js +++ b/test/chunking-form/samples/side-effect-free-dependencies/hoist-side-effect-modules/_expected/amd/generated-dep4-effect.js @@ -1,5 +1,5 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; console.log('dep4'); -}); +})); diff --git a/test/chunking-form/samples/side-effect-free-dependencies/hoist-side-effect-modules/_expected/amd/main1.js b/test/chunking-form/samples/side-effect-free-dependencies/hoist-side-effect-modules/_expected/amd/main1.js index a878d2dfa06..4f47de9daf7 100644 --- a/test/chunking-form/samples/side-effect-free-dependencies/hoist-side-effect-modules/_expected/amd/main1.js +++ b/test/chunking-form/samples/side-effect-free-dependencies/hoist-side-effect-modules/_expected/amd/main1.js @@ -1,4 +1,4 @@ -define(['./generated-dep2-effect', './generated-dep4-effect'], function (dep2Effect, dep4Effect) { 'use strict'; +define(['./generated-dep2-effect', './generated-dep4-effect'], (function (dep2Effect, dep4Effect) { 'use strict'; var value = 42; @@ -8,4 +8,4 @@ define(['./generated-dep2-effect', './generated-dep4-effect'], function (dep2Eff onlyUsedByOne(value); -}); +})); diff --git a/test/chunking-form/samples/side-effect-free-dependencies/hoist-side-effect-modules/_expected/amd/main2.js b/test/chunking-form/samples/side-effect-free-dependencies/hoist-side-effect-modules/_expected/amd/main2.js index 63cd356d00e..595d8f8fed2 100644 --- a/test/chunking-form/samples/side-effect-free-dependencies/hoist-side-effect-modules/_expected/amd/main2.js +++ b/test/chunking-form/samples/side-effect-free-dependencies/hoist-side-effect-modules/_expected/amd/main2.js @@ -1,5 +1,5 @@ -define(['./generated-dep2-effect', './generated-dep4-effect'], function (dep2Effect, dep4Effect) { 'use strict'; +define(['./generated-dep2-effect', './generated-dep4-effect'], (function (dep2Effect, dep4Effect) { 'use strict'; console.log('main2'); -}); +})); diff --git a/test/chunking-form/samples/side-effect-free-dependencies/hoist-side-effect-modules/_expected/amd/main3.js b/test/chunking-form/samples/side-effect-free-dependencies/hoist-side-effect-modules/_expected/amd/main3.js index daf45b47633..f86da914deb 100644 --- a/test/chunking-form/samples/side-effect-free-dependencies/hoist-side-effect-modules/_expected/amd/main3.js +++ b/test/chunking-form/samples/side-effect-free-dependencies/hoist-side-effect-modules/_expected/amd/main3.js @@ -1,5 +1,5 @@ -define(['./generated-dep4-effect'], function (dep4Effect) { 'use strict'; +define(['./generated-dep4-effect'], (function (dep4Effect) { 'use strict'; console.log('main3'); -}); +})); diff --git a/test/chunking-form/samples/side-effect-free-dependencies/hoist-side-effect-modules/_expected/system/generated-dep2-effect.js b/test/chunking-form/samples/side-effect-free-dependencies/hoist-side-effect-modules/_expected/system/generated-dep2-effect.js index 535b40f550f..e97665c4ed9 100644 --- a/test/chunking-form/samples/side-effect-free-dependencies/hoist-side-effect-modules/_expected/system/generated-dep2-effect.js +++ b/test/chunking-form/samples/side-effect-free-dependencies/hoist-side-effect-modules/_expected/system/generated-dep2-effect.js @@ -1,10 +1,10 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { console.log('dep2'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/side-effect-free-dependencies/hoist-side-effect-modules/_expected/system/generated-dep4-effect.js b/test/chunking-form/samples/side-effect-free-dependencies/hoist-side-effect-modules/_expected/system/generated-dep4-effect.js index b85397ce320..e81abc3c645 100644 --- a/test/chunking-form/samples/side-effect-free-dependencies/hoist-side-effect-modules/_expected/system/generated-dep4-effect.js +++ b/test/chunking-form/samples/side-effect-free-dependencies/hoist-side-effect-modules/_expected/system/generated-dep4-effect.js @@ -1,10 +1,10 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { console.log('dep4'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/side-effect-free-dependencies/hoist-side-effect-modules/_expected/system/main1.js b/test/chunking-form/samples/side-effect-free-dependencies/hoist-side-effect-modules/_expected/system/main1.js index 9ba48709b62..6c056ecf0ee 100644 --- a/test/chunking-form/samples/side-effect-free-dependencies/hoist-side-effect-modules/_expected/system/main1.js +++ b/test/chunking-form/samples/side-effect-free-dependencies/hoist-side-effect-modules/_expected/system/main1.js @@ -1,8 +1,8 @@ -System.register(['./generated-dep2-effect.js', './generated-dep4-effect.js'], function () { +System.register(['./generated-dep2-effect.js', './generated-dep4-effect.js'], (function () { 'use strict'; return { - setters: [function () {}, function () {}], - execute: function () { + setters: [null, null], + execute: (function () { var value = 42; @@ -12,6 +12,6 @@ System.register(['./generated-dep2-effect.js', './generated-dep4-effect.js'], fu onlyUsedByOne(value); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/side-effect-free-dependencies/hoist-side-effect-modules/_expected/system/main2.js b/test/chunking-form/samples/side-effect-free-dependencies/hoist-side-effect-modules/_expected/system/main2.js index d285b264147..beb77057158 100644 --- a/test/chunking-form/samples/side-effect-free-dependencies/hoist-side-effect-modules/_expected/system/main2.js +++ b/test/chunking-form/samples/side-effect-free-dependencies/hoist-side-effect-modules/_expected/system/main2.js @@ -1,11 +1,11 @@ -System.register(['./generated-dep2-effect.js', './generated-dep4-effect.js'], function () { +System.register(['./generated-dep2-effect.js', './generated-dep4-effect.js'], (function () { 'use strict'; return { - setters: [function () {}, function () {}], - execute: function () { + setters: [null, null], + execute: (function () { console.log('main2'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/side-effect-free-dependencies/hoist-side-effect-modules/_expected/system/main3.js b/test/chunking-form/samples/side-effect-free-dependencies/hoist-side-effect-modules/_expected/system/main3.js index 260b1872457..130a2f990a8 100644 --- a/test/chunking-form/samples/side-effect-free-dependencies/hoist-side-effect-modules/_expected/system/main3.js +++ b/test/chunking-form/samples/side-effect-free-dependencies/hoist-side-effect-modules/_expected/system/main3.js @@ -1,11 +1,11 @@ -System.register(['./generated-dep4-effect.js'], function () { +System.register(['./generated-dep4-effect.js'], (function () { 'use strict'; return { - setters: [function () {}], - execute: function () { + setters: [null], + execute: (function () { console.log('main3'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/side-effect-free-dependencies/module-side-effects-empty-imports/_config.js b/test/chunking-form/samples/side-effect-free-dependencies/module-side-effects-empty-imports/_config.js index 615562a76d9..6855779e88e 100644 --- a/test/chunking-form/samples/side-effect-free-dependencies/module-side-effects-empty-imports/_config.js +++ b/test/chunking-form/samples/side-effect-free-dependencies/module-side-effects-empty-imports/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'avoids empty imports if moduleSideEffects are false', options: { input: ['main1', 'main2'], @@ -6,4 +6,4 @@ module.exports = { moduleSideEffects: false } } -}; +}); diff --git a/test/chunking-form/samples/side-effect-free-dependencies/module-side-effects-empty-imports/_expected/amd/main1.js b/test/chunking-form/samples/side-effect-free-dependencies/module-side-effects-empty-imports/_expected/amd/main1.js index b6a9613a883..24c21123811 100644 --- a/test/chunking-form/samples/side-effect-free-dependencies/module-side-effects-empty-imports/_expected/amd/main1.js +++ b/test/chunking-form/samples/side-effect-free-dependencies/module-side-effects-empty-imports/_expected/amd/main1.js @@ -1,8 +1,8 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; var value = 42; console.log('Ignored side-effect'); console.log('main1', value); -}); +})); diff --git a/test/chunking-form/samples/side-effect-free-dependencies/module-side-effects-empty-imports/_expected/amd/main2.js b/test/chunking-form/samples/side-effect-free-dependencies/module-side-effects-empty-imports/_expected/amd/main2.js index b58286ca58e..50131c97c96 100644 --- a/test/chunking-form/samples/side-effect-free-dependencies/module-side-effects-empty-imports/_expected/amd/main2.js +++ b/test/chunking-form/samples/side-effect-free-dependencies/module-side-effects-empty-imports/_expected/amd/main2.js @@ -1,5 +1,5 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; console.log('main2'); -}); +})); diff --git a/test/chunking-form/samples/side-effect-free-dependencies/module-side-effects-empty-imports/_expected/system/main1.js b/test/chunking-form/samples/side-effect-free-dependencies/module-side-effects-empty-imports/_expected/system/main1.js index 8eb92a30566..d537b433420 100644 --- a/test/chunking-form/samples/side-effect-free-dependencies/module-side-effects-empty-imports/_expected/system/main1.js +++ b/test/chunking-form/samples/side-effect-free-dependencies/module-side-effects-empty-imports/_expected/system/main1.js @@ -1,13 +1,13 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { var value = 42; console.log('Ignored side-effect'); console.log('main1', value); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/side-effect-free-dependencies/module-side-effects-empty-imports/_expected/system/main2.js b/test/chunking-form/samples/side-effect-free-dependencies/module-side-effects-empty-imports/_expected/system/main2.js index a272843f834..b91e108e596 100644 --- a/test/chunking-form/samples/side-effect-free-dependencies/module-side-effects-empty-imports/_expected/system/main2.js +++ b/test/chunking-form/samples/side-effect-free-dependencies/module-side-effects-empty-imports/_expected/system/main2.js @@ -1,10 +1,10 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { console.log('main2'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/side-effect-free-dependencies/module-side-effects-reexports-1/_config.js b/test/chunking-form/samples/side-effect-free-dependencies/module-side-effects-reexports-1/_config.js index ba74be8e44a..a47b3d02f34 100644 --- a/test/chunking-form/samples/side-effect-free-dependencies/module-side-effects-reexports-1/_config.js +++ b/test/chunking-form/samples/side-effect-free-dependencies/module-side-effects-reexports-1/_config.js @@ -1,8 +1,8 @@ -module.exports = { +module.exports = defineTest({ description: 'handles re-exports in entry points if moduleSideEffects are false', options: { treeshake: { moduleSideEffects: false } } -}; +}); diff --git a/test/chunking-form/samples/side-effect-free-dependencies/module-side-effects-reexports-1/_expected/amd/main.js b/test/chunking-form/samples/side-effect-free-dependencies/module-side-effects-reexports-1/_expected/amd/main.js index 876aec76659..947ad1cbafd 100644 --- a/test/chunking-form/samples/side-effect-free-dependencies/module-side-effects-reexports-1/_expected/amd/main.js +++ b/test/chunking-form/samples/side-effect-free-dependencies/module-side-effects-reexports-1/_expected/amd/main.js @@ -1,9 +1,7 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; const value = 42; exports.value = value; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/side-effect-free-dependencies/module-side-effects-reexports-1/_expected/cjs/main.js b/test/chunking-form/samples/side-effect-free-dependencies/module-side-effects-reexports-1/_expected/cjs/main.js index 181fa0fd711..9549eb32880 100644 --- a/test/chunking-form/samples/side-effect-free-dependencies/module-side-effects-reexports-1/_expected/cjs/main.js +++ b/test/chunking-form/samples/side-effect-free-dependencies/module-side-effects-reexports-1/_expected/cjs/main.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - const value = 42; exports.value = value; diff --git a/test/chunking-form/samples/side-effect-free-dependencies/module-side-effects-reexports-1/_expected/system/main.js b/test/chunking-form/samples/side-effect-free-dependencies/module-side-effects-reexports-1/_expected/system/main.js index 437f1af456e..f80269f9009 100644 --- a/test/chunking-form/samples/side-effect-free-dependencies/module-side-effects-reexports-1/_expected/system/main.js +++ b/test/chunking-form/samples/side-effect-free-dependencies/module-side-effects-reexports-1/_expected/system/main.js @@ -1,10 +1,10 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - const value = exports('value', 42); + const value = exports("value", 42); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/side-effect-free-dependencies/module-side-effects-reexports-2/_config.js b/test/chunking-form/samples/side-effect-free-dependencies/module-side-effects-reexports-2/_config.js index ba74be8e44a..a47b3d02f34 100644 --- a/test/chunking-form/samples/side-effect-free-dependencies/module-side-effects-reexports-2/_config.js +++ b/test/chunking-form/samples/side-effect-free-dependencies/module-side-effects-reexports-2/_config.js @@ -1,8 +1,8 @@ -module.exports = { +module.exports = defineTest({ description: 'handles re-exports in entry points if moduleSideEffects are false', options: { treeshake: { moduleSideEffects: false } } -}; +}); diff --git a/test/chunking-form/samples/side-effect-free-dependencies/module-side-effects-reexports-2/_expected/amd/main.js b/test/chunking-form/samples/side-effect-free-dependencies/module-side-effects-reexports-2/_expected/amd/main.js index 876aec76659..947ad1cbafd 100644 --- a/test/chunking-form/samples/side-effect-free-dependencies/module-side-effects-reexports-2/_expected/amd/main.js +++ b/test/chunking-form/samples/side-effect-free-dependencies/module-side-effects-reexports-2/_expected/amd/main.js @@ -1,9 +1,7 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; const value = 42; exports.value = value; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/side-effect-free-dependencies/module-side-effects-reexports-2/_expected/cjs/main.js b/test/chunking-form/samples/side-effect-free-dependencies/module-side-effects-reexports-2/_expected/cjs/main.js index 181fa0fd711..9549eb32880 100644 --- a/test/chunking-form/samples/side-effect-free-dependencies/module-side-effects-reexports-2/_expected/cjs/main.js +++ b/test/chunking-form/samples/side-effect-free-dependencies/module-side-effects-reexports-2/_expected/cjs/main.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - const value = 42; exports.value = value; diff --git a/test/chunking-form/samples/side-effect-free-dependencies/module-side-effects-reexports-2/_expected/system/main.js b/test/chunking-form/samples/side-effect-free-dependencies/module-side-effects-reexports-2/_expected/system/main.js index 437f1af456e..f80269f9009 100644 --- a/test/chunking-form/samples/side-effect-free-dependencies/module-side-effects-reexports-2/_expected/system/main.js +++ b/test/chunking-form/samples/side-effect-free-dependencies/module-side-effects-reexports-2/_expected/system/main.js @@ -1,10 +1,10 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - const value = exports('value', 42); + const value = exports("value", 42); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/side-effect-free-dependencies/module-side-effects-reexports-3/_config.js b/test/chunking-form/samples/side-effect-free-dependencies/module-side-effects-reexports-3/_config.js index ba74be8e44a..a47b3d02f34 100644 --- a/test/chunking-form/samples/side-effect-free-dependencies/module-side-effects-reexports-3/_config.js +++ b/test/chunking-form/samples/side-effect-free-dependencies/module-side-effects-reexports-3/_config.js @@ -1,8 +1,8 @@ -module.exports = { +module.exports = defineTest({ description: 'handles re-exports in entry points if moduleSideEffects are false', options: { treeshake: { moduleSideEffects: false } } -}; +}); diff --git a/test/chunking-form/samples/side-effect-free-dependencies/module-side-effects-reexports-3/_expected/amd/main.js b/test/chunking-form/samples/side-effect-free-dependencies/module-side-effects-reexports-3/_expected/amd/main.js index 876aec76659..947ad1cbafd 100644 --- a/test/chunking-form/samples/side-effect-free-dependencies/module-side-effects-reexports-3/_expected/amd/main.js +++ b/test/chunking-form/samples/side-effect-free-dependencies/module-side-effects-reexports-3/_expected/amd/main.js @@ -1,9 +1,7 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; const value = 42; exports.value = value; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/side-effect-free-dependencies/module-side-effects-reexports-3/_expected/cjs/main.js b/test/chunking-form/samples/side-effect-free-dependencies/module-side-effects-reexports-3/_expected/cjs/main.js index 181fa0fd711..9549eb32880 100644 --- a/test/chunking-form/samples/side-effect-free-dependencies/module-side-effects-reexports-3/_expected/cjs/main.js +++ b/test/chunking-form/samples/side-effect-free-dependencies/module-side-effects-reexports-3/_expected/cjs/main.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - const value = 42; exports.value = value; diff --git a/test/chunking-form/samples/side-effect-free-dependencies/module-side-effects-reexports-3/_expected/system/main.js b/test/chunking-form/samples/side-effect-free-dependencies/module-side-effects-reexports-3/_expected/system/main.js index 437f1af456e..f80269f9009 100644 --- a/test/chunking-form/samples/side-effect-free-dependencies/module-side-effects-reexports-3/_expected/system/main.js +++ b/test/chunking-form/samples/side-effect-free-dependencies/module-side-effects-reexports-3/_expected/system/main.js @@ -1,10 +1,10 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - const value = exports('value', 42); + const value = exports("value", 42); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/single-file-manual-chunk/_config.js b/test/chunking-form/samples/single-file-manual-chunk/_config.js index 99a67c2a3e4..ad4828a51a5 100644 --- a/test/chunking-form/samples/single-file-manual-chunk/_config.js +++ b/test/chunking-form/samples/single-file-manual-chunk/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'chunk aliasing with extensions', options: { output: { @@ -9,4 +9,4 @@ module.exports = { } } } -}; +}); diff --git a/test/chunking-form/samples/single-file-manual-chunk/_expected/amd/generated-first.js b/test/chunking-form/samples/single-file-manual-chunk/_expected/amd/generated-first.js index 3f7def0a742..6d0638c63e4 100644 --- a/test/chunking-form/samples/single-file-manual-chunk/_expected/amd/generated-first.js +++ b/test/chunking-form/samples/single-file-manual-chunk/_expected/amd/generated-first.js @@ -1,5 +1,5 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; console.log('a'); -}); +})); diff --git a/test/chunking-form/samples/single-file-manual-chunk/_expected/amd/generated-second.js b/test/chunking-form/samples/single-file-manual-chunk/_expected/amd/generated-second.js index 5c36ece535a..8c1e8bedad0 100644 --- a/test/chunking-form/samples/single-file-manual-chunk/_expected/amd/generated-second.js +++ b/test/chunking-form/samples/single-file-manual-chunk/_expected/amd/generated-second.js @@ -1,4 +1,4 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; console.log('b'); @@ -15,4 +15,4 @@ define(['exports'], function (exports) { 'use strict'; exports.b = b; exports.c = c; -}); +})); diff --git a/test/chunking-form/samples/single-file-manual-chunk/_expected/amd/main.js b/test/chunking-form/samples/single-file-manual-chunk/_expected/amd/main.js index 2d26a374d19..225ad9b55e5 100644 --- a/test/chunking-form/samples/single-file-manual-chunk/_expected/amd/main.js +++ b/test/chunking-form/samples/single-file-manual-chunk/_expected/amd/main.js @@ -1,7 +1,7 @@ -define(['require'], function (require) { 'use strict'; +define(['require'], (function (require) { 'use strict'; - new Promise(function (resolve, reject) { require(['./generated-first'], resolve, reject) }); - new Promise(function (resolve, reject) { require(['./generated-second'], resolve, reject) }).then(function (n) { return n.b; }); - new Promise(function (resolve, reject) { require(['./generated-second'], resolve, reject) }).then(function (n) { return n.c; }); + new Promise(function (resolve, reject) { require(['./generated-first'], resolve, reject); }); + new Promise(function (resolve, reject) { require(['./generated-second'], resolve, reject); }).then(function (n) { return n.b; }); + new Promise(function (resolve, reject) { require(['./generated-second'], resolve, reject); }).then(function (n) { return n.c; }); -}); +})); diff --git a/test/chunking-form/samples/single-file-manual-chunk/_expected/system/generated-first.js b/test/chunking-form/samples/single-file-manual-chunk/_expected/system/generated-first.js index 9542f039b8d..2859a1e855c 100644 --- a/test/chunking-form/samples/single-file-manual-chunk/_expected/system/generated-first.js +++ b/test/chunking-form/samples/single-file-manual-chunk/_expected/system/generated-first.js @@ -1,10 +1,10 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { console.log('a'); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/single-file-manual-chunk/_expected/system/generated-second.js b/test/chunking-form/samples/single-file-manual-chunk/_expected/system/generated-second.js index 18cdd0c5006..6e284601d27 100644 --- a/test/chunking-form/samples/single-file-manual-chunk/_expected/system/generated-second.js +++ b/test/chunking-form/samples/single-file-manual-chunk/_expected/system/generated-second.js @@ -1,22 +1,22 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { console.log('b'); var b = /*#__PURE__*/Object.freeze({ __proto__: null }); - exports('b', b); + exports("b", b); console.log('c'); var c = /*#__PURE__*/Object.freeze({ __proto__: null }); - exports('c', c); + exports("c", c); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/single-file-manual-chunk/_expected/system/main.js b/test/chunking-form/samples/single-file-manual-chunk/_expected/system/main.js index ea256d97a18..d6d2137ce06 100644 --- a/test/chunking-form/samples/single-file-manual-chunk/_expected/system/main.js +++ b/test/chunking-form/samples/single-file-manual-chunk/_expected/system/main.js @@ -1,12 +1,12 @@ -System.register([], function (exports, module) { +System.register([], (function (exports, module) { 'use strict'; return { - execute: function () { + execute: (function () { module.import('./generated-first.js'); module.import('./generated-second.js').then(function (n) { return n.b; }); module.import('./generated-second.js').then(function (n) { return n.c; }); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/sourcemap-file-names-function/_config.js b/test/chunking-form/samples/sourcemap-file-names-function/_config.js new file mode 100644 index 00000000000..aaee5329757 --- /dev/null +++ b/test/chunking-form/samples/sourcemap-file-names-function/_config.js @@ -0,0 +1,27 @@ +module.exports = defineTest({ + description: 'observes sourcemapFileNames property when using a function', + options: { + output: { + sourcemap: true, + entryFileNames: '[name].js', + chunkFileNames: '[name]-[hash].js', + sourcemapFileNames: ({ name }) => { + switch (name) { + case 'main': { + // chunkhash should be empty string + return 'main[chunkhash].js.map'; + } + case 'dynamic': { + return 'dynamic.js.map'; + } + case 'dynamic-hashed': { + return 'dynamic-[hash:12]-[chunkhash].js.map'; + } + default: { + throw new Error(`Unexpected name ${name}`); + } + } + } + } + } +}); diff --git a/test/chunking-form/samples/sourcemap-file-names-function/_expected/amd/dynamic-CBK0ZRhv.js b/test/chunking-form/samples/sourcemap-file-names-function/_expected/amd/dynamic-CBK0ZRhv.js new file mode 100644 index 00000000000..6e68bc23d4e --- /dev/null +++ b/test/chunking-form/samples/sourcemap-file-names-function/_expected/amd/dynamic-CBK0ZRhv.js @@ -0,0 +1,6 @@ +define((function () { 'use strict'; + + console.log('dynamic'); + +})); +//# sourceMappingURL=dynamic.js.map diff --git a/test/chunking-form/samples/sourcemap-file-names-function/_expected/amd/dynamic-eDJZN3REc8ya-DAVPlGJs.js.map b/test/chunking-form/samples/sourcemap-file-names-function/_expected/amd/dynamic-eDJZN3REc8ya-DAVPlGJs.js.map new file mode 100644 index 00000000000..0f9c68d0cc3 --- /dev/null +++ b/test/chunking-form/samples/sourcemap-file-names-function/_expected/amd/dynamic-eDJZN3REc8ya-DAVPlGJs.js.map @@ -0,0 +1 @@ +{"version":3,"file":"dynamic-hashed-DAVPlGJs.js","sources":["../../dynamic-hashed.js"],"sourcesContent":["console.log('dynamic-hashed');\n"],"names":[],"mappings":";;CAAA,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC;;;;;;"} \ No newline at end of file diff --git a/test/chunking-form/samples/sourcemap-file-names-function/_expected/amd/dynamic-hashed-DAVPlGJs.js b/test/chunking-form/samples/sourcemap-file-names-function/_expected/amd/dynamic-hashed-DAVPlGJs.js new file mode 100644 index 00000000000..0b84ccfb41c --- /dev/null +++ b/test/chunking-form/samples/sourcemap-file-names-function/_expected/amd/dynamic-hashed-DAVPlGJs.js @@ -0,0 +1,6 @@ +define((function () { 'use strict'; + + console.log('dynamic-hashed'); + +})); +//# sourceMappingURL=dynamic-eDJZN3REc8ya-DAVPlGJs.js.map diff --git a/test/chunking-form/samples/sourcemap-file-names-function/_expected/amd/dynamic.js.map b/test/chunking-form/samples/sourcemap-file-names-function/_expected/amd/dynamic.js.map new file mode 100644 index 00000000000..6eee4a886e2 --- /dev/null +++ b/test/chunking-form/samples/sourcemap-file-names-function/_expected/amd/dynamic.js.map @@ -0,0 +1 @@ +{"version":3,"file":"dynamic-CBK0ZRhv.js","sources":["../../dynamic.js"],"sourcesContent":["console.log('dynamic');\n"],"names":[],"mappings":";;CAAA,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC;;;;;;"} \ No newline at end of file diff --git a/test/chunking-form/samples/sourcemap-file-names-function/_expected/amd/main.js b/test/chunking-form/samples/sourcemap-file-names-function/_expected/amd/main.js new file mode 100644 index 00000000000..bfbd53a9822 --- /dev/null +++ b/test/chunking-form/samples/sourcemap-file-names-function/_expected/amd/main.js @@ -0,0 +1,7 @@ +define(['require'], (function (require) { 'use strict'; + + new Promise(function (resolve, reject) { require(['./dynamic-CBK0ZRhv'], resolve, reject); }); + new Promise(function (resolve, reject) { require(['./dynamic-hashed-DAVPlGJs'], resolve, reject); }); + +})); +//# sourceMappingURL=main.js.map diff --git a/test/chunking-form/samples/sourcemap-file-names-function/_expected/amd/main.js.map b/test/chunking-form/samples/sourcemap-file-names-function/_expected/amd/main.js.map new file mode 100644 index 00000000000..9bd54c052fc --- /dev/null +++ b/test/chunking-form/samples/sourcemap-file-names-function/_expected/amd/main.js.map @@ -0,0 +1 @@ +{"version":3,"file":"main.js","sources":["../../main.js"],"sourcesContent":["import('./dynamic.js');\nimport('./dynamic-hashed.js');\n"],"names":[],"mappings":";;AAAA,mDAAO,oBAAc,uBAAC;AACtB,mDAAO,2BAAqB,uBAAC;;;;;;"} \ No newline at end of file diff --git a/test/chunking-form/samples/sourcemap-file-names-function/_expected/cjs/dynamic-Dke4V8eM.js b/test/chunking-form/samples/sourcemap-file-names-function/_expected/cjs/dynamic-Dke4V8eM.js new file mode 100644 index 00000000000..7de73b8dd2f --- /dev/null +++ b/test/chunking-form/samples/sourcemap-file-names-function/_expected/cjs/dynamic-Dke4V8eM.js @@ -0,0 +1,4 @@ +'use strict'; + +console.log('dynamic'); +//# sourceMappingURL=dynamic.js.map diff --git a/test/chunking-form/samples/sourcemap-file-names-function/_expected/cjs/dynamic-GPeKpCVQmc82-BgHsqIXR.js.map b/test/chunking-form/samples/sourcemap-file-names-function/_expected/cjs/dynamic-GPeKpCVQmc82-BgHsqIXR.js.map new file mode 100644 index 00000000000..02375c5974a --- /dev/null +++ b/test/chunking-form/samples/sourcemap-file-names-function/_expected/cjs/dynamic-GPeKpCVQmc82-BgHsqIXR.js.map @@ -0,0 +1 @@ +{"version":3,"file":"dynamic-hashed-BgHsqIXR.js","sources":["../../dynamic-hashed.js"],"sourcesContent":["console.log('dynamic-hashed');\n"],"names":[],"mappings":";;AAAA,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC;;"} \ No newline at end of file diff --git a/test/chunking-form/samples/sourcemap-file-names-function/_expected/cjs/dynamic-hashed-BgHsqIXR.js b/test/chunking-form/samples/sourcemap-file-names-function/_expected/cjs/dynamic-hashed-BgHsqIXR.js new file mode 100644 index 00000000000..d72cbbddb69 --- /dev/null +++ b/test/chunking-form/samples/sourcemap-file-names-function/_expected/cjs/dynamic-hashed-BgHsqIXR.js @@ -0,0 +1,4 @@ +'use strict'; + +console.log('dynamic-hashed'); +//# sourceMappingURL=dynamic-GPeKpCVQmc82-BgHsqIXR.js.map diff --git a/test/chunking-form/samples/sourcemap-file-names-function/_expected/cjs/dynamic.js.map b/test/chunking-form/samples/sourcemap-file-names-function/_expected/cjs/dynamic.js.map new file mode 100644 index 00000000000..17ecb008264 --- /dev/null +++ b/test/chunking-form/samples/sourcemap-file-names-function/_expected/cjs/dynamic.js.map @@ -0,0 +1 @@ +{"version":3,"file":"dynamic-Dke4V8eM.js","sources":["../../dynamic.js"],"sourcesContent":["console.log('dynamic');\n"],"names":[],"mappings":";;AAAA,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC;;"} \ No newline at end of file diff --git a/test/chunking-form/samples/sourcemap-file-names-function/_expected/cjs/main.js b/test/chunking-form/samples/sourcemap-file-names-function/_expected/cjs/main.js new file mode 100644 index 00000000000..48563e74204 --- /dev/null +++ b/test/chunking-form/samples/sourcemap-file-names-function/_expected/cjs/main.js @@ -0,0 +1,5 @@ +'use strict'; + +Promise.resolve().then(function () { return require('./dynamic-Dke4V8eM.js'); }); +Promise.resolve().then(function () { return require('./dynamic-hashed-BgHsqIXR.js'); }); +//# sourceMappingURL=main.js.map diff --git a/test/chunking-form/samples/sourcemap-file-names-function/_expected/cjs/main.js.map b/test/chunking-form/samples/sourcemap-file-names-function/_expected/cjs/main.js.map new file mode 100644 index 00000000000..f82b7199728 --- /dev/null +++ b/test/chunking-form/samples/sourcemap-file-names-function/_expected/cjs/main.js.map @@ -0,0 +1 @@ +{"version":3,"file":"main.js","sources":["../../main.js"],"sourcesContent":["import('./dynamic.js');\nimport('./dynamic-hashed.js');\n"],"names":[],"mappings":";;AAAA,oDAAO,uBAAc,KAAC;AACtB,oDAAO,8BAAqB,KAAC;;"} \ No newline at end of file diff --git a/test/chunking-form/samples/sourcemap-file-names-function/_expected/es/dynamic-CQROc0LN5Ob6-DyVTGFM1.js.map b/test/chunking-form/samples/sourcemap-file-names-function/_expected/es/dynamic-CQROc0LN5Ob6-DyVTGFM1.js.map new file mode 100644 index 00000000000..e0c368dd7ae --- /dev/null +++ b/test/chunking-form/samples/sourcemap-file-names-function/_expected/es/dynamic-CQROc0LN5Ob6-DyVTGFM1.js.map @@ -0,0 +1 @@ +{"version":3,"file":"dynamic-hashed-DyVTGFM1.js","sources":["../../dynamic-hashed.js"],"sourcesContent":["console.log('dynamic-hashed');\n"],"names":[],"mappings":"AAAA,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC"} \ No newline at end of file diff --git a/test/chunking-form/samples/sourcemap-file-names-function/_expected/es/dynamic-TiCFiI2A.js b/test/chunking-form/samples/sourcemap-file-names-function/_expected/es/dynamic-TiCFiI2A.js new file mode 100644 index 00000000000..e3094ebbb86 --- /dev/null +++ b/test/chunking-form/samples/sourcemap-file-names-function/_expected/es/dynamic-TiCFiI2A.js @@ -0,0 +1,2 @@ +console.log('dynamic'); +//# sourceMappingURL=dynamic.js.map diff --git a/test/chunking-form/samples/sourcemap-file-names-function/_expected/es/dynamic-hashed-DyVTGFM1.js b/test/chunking-form/samples/sourcemap-file-names-function/_expected/es/dynamic-hashed-DyVTGFM1.js new file mode 100644 index 00000000000..d7fd8b8cc8f --- /dev/null +++ b/test/chunking-form/samples/sourcemap-file-names-function/_expected/es/dynamic-hashed-DyVTGFM1.js @@ -0,0 +1,2 @@ +console.log('dynamic-hashed'); +//# sourceMappingURL=dynamic-CQROc0LN5Ob6-DyVTGFM1.js.map diff --git a/test/chunking-form/samples/sourcemap-file-names-function/_expected/es/dynamic.js.map b/test/chunking-form/samples/sourcemap-file-names-function/_expected/es/dynamic.js.map new file mode 100644 index 00000000000..7ce9b9ba760 --- /dev/null +++ b/test/chunking-form/samples/sourcemap-file-names-function/_expected/es/dynamic.js.map @@ -0,0 +1 @@ +{"version":3,"file":"dynamic-TiCFiI2A.js","sources":["../../dynamic.js"],"sourcesContent":["console.log('dynamic');\n"],"names":[],"mappings":"AAAA,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC"} \ No newline at end of file diff --git a/test/chunking-form/samples/sourcemap-file-names-function/_expected/es/main.js b/test/chunking-form/samples/sourcemap-file-names-function/_expected/es/main.js new file mode 100644 index 00000000000..c8141b477d4 --- /dev/null +++ b/test/chunking-form/samples/sourcemap-file-names-function/_expected/es/main.js @@ -0,0 +1,3 @@ +import('./dynamic-TiCFiI2A.js'); +import('./dynamic-hashed-DyVTGFM1.js'); +//# sourceMappingURL=main.js.map diff --git a/test/chunking-form/samples/sourcemap-file-names-function/_expected/es/main.js.map b/test/chunking-form/samples/sourcemap-file-names-function/_expected/es/main.js.map new file mode 100644 index 00000000000..9a6f6537325 --- /dev/null +++ b/test/chunking-form/samples/sourcemap-file-names-function/_expected/es/main.js.map @@ -0,0 +1 @@ +{"version":3,"file":"main.js","sources":["../../main.js"],"sourcesContent":["import('./dynamic.js');\nimport('./dynamic-hashed.js');\n"],"names":[],"mappings":"AAAA,OAAO,uBAAc,CAAC;AACtB,OAAO,8BAAqB,CAAC"} \ No newline at end of file diff --git a/test/chunking-form/samples/sourcemap-file-names-function/_expected/system/dynamic-CwNl7PrZ87mg-CkE_tUGn.js.map b/test/chunking-form/samples/sourcemap-file-names-function/_expected/system/dynamic-CwNl7PrZ87mg-CkE_tUGn.js.map new file mode 100644 index 00000000000..c30c144591b --- /dev/null +++ b/test/chunking-form/samples/sourcemap-file-names-function/_expected/system/dynamic-CwNl7PrZ87mg-CkE_tUGn.js.map @@ -0,0 +1 @@ +{"version":3,"file":"dynamic-hashed-CkE_tUGn.js","sources":["../../dynamic-hashed.js"],"sourcesContent":["console.log('dynamic-hashed');\n"],"names":[],"mappings":";;;;;GAAA,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC;;;;;;;;"} \ No newline at end of file diff --git a/test/chunking-form/samples/sourcemap-file-names-function/_expected/system/dynamic-D_Zs3yGr.js b/test/chunking-form/samples/sourcemap-file-names-function/_expected/system/dynamic-D_Zs3yGr.js new file mode 100644 index 00000000000..6b9651b1e14 --- /dev/null +++ b/test/chunking-form/samples/sourcemap-file-names-function/_expected/system/dynamic-D_Zs3yGr.js @@ -0,0 +1,11 @@ +System.register([], (function () { + 'use strict'; + return { + execute: (function () { + + console.log('dynamic'); + + }) + }; +})); +//# sourceMappingURL=dynamic.js.map diff --git a/test/chunking-form/samples/sourcemap-file-names-function/_expected/system/dynamic-hashed-CkE_tUGn.js b/test/chunking-form/samples/sourcemap-file-names-function/_expected/system/dynamic-hashed-CkE_tUGn.js new file mode 100644 index 00000000000..1832d5335b5 --- /dev/null +++ b/test/chunking-form/samples/sourcemap-file-names-function/_expected/system/dynamic-hashed-CkE_tUGn.js @@ -0,0 +1,11 @@ +System.register([], (function () { + 'use strict'; + return { + execute: (function () { + + console.log('dynamic-hashed'); + + }) + }; +})); +//# sourceMappingURL=dynamic-CwNl7PrZ87mg-CkE_tUGn.js.map diff --git a/test/chunking-form/samples/sourcemap-file-names-function/_expected/system/dynamic.js.map b/test/chunking-form/samples/sourcemap-file-names-function/_expected/system/dynamic.js.map new file mode 100644 index 00000000000..f46706bcf5a --- /dev/null +++ b/test/chunking-form/samples/sourcemap-file-names-function/_expected/system/dynamic.js.map @@ -0,0 +1 @@ +{"version":3,"file":"dynamic-D_Zs3yGr.js","sources":["../../dynamic.js"],"sourcesContent":["console.log('dynamic');\n"],"names":[],"mappings":";;;;;GAAA,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC;;;;;;;;"} \ No newline at end of file diff --git a/test/chunking-form/samples/sourcemap-file-names-function/_expected/system/main.js b/test/chunking-form/samples/sourcemap-file-names-function/_expected/system/main.js new file mode 100644 index 00000000000..3e6987e4cfe --- /dev/null +++ b/test/chunking-form/samples/sourcemap-file-names-function/_expected/system/main.js @@ -0,0 +1,12 @@ +System.register([], (function (exports, module) { + 'use strict'; + return { + execute: (function () { + + module.import('./dynamic-D_Zs3yGr.js'); + module.import('./dynamic-hashed-CkE_tUGn.js'); + + }) + }; +})); +//# sourceMappingURL=main.js.map diff --git a/test/chunking-form/samples/sourcemap-file-names-function/_expected/system/main.js.map b/test/chunking-form/samples/sourcemap-file-names-function/_expected/system/main.js.map new file mode 100644 index 00000000000..c42923021ee --- /dev/null +++ b/test/chunking-form/samples/sourcemap-file-names-function/_expected/system/main.js.map @@ -0,0 +1 @@ +{"version":3,"file":"main.js","sources":["../../main.js"],"sourcesContent":["import('./dynamic.js');\nimport('./dynamic-hashed.js');\n"],"names":[],"mappings":";;;;;AAAA,iBAAO,uBAAc,CAAC;AACtB,iBAAO,8BAAqB,CAAC;;;;;;;;"} \ No newline at end of file diff --git a/test/chunking-form/samples/sourcemap-file-names-function/dynamic-hashed.js b/test/chunking-form/samples/sourcemap-file-names-function/dynamic-hashed.js new file mode 100644 index 00000000000..477aa42f8dd --- /dev/null +++ b/test/chunking-form/samples/sourcemap-file-names-function/dynamic-hashed.js @@ -0,0 +1 @@ +console.log('dynamic-hashed'); diff --git a/test/chunking-form/samples/sourcemap-file-names-function/dynamic.js b/test/chunking-form/samples/sourcemap-file-names-function/dynamic.js new file mode 100644 index 00000000000..955cedef82d --- /dev/null +++ b/test/chunking-form/samples/sourcemap-file-names-function/dynamic.js @@ -0,0 +1 @@ +console.log('dynamic'); diff --git a/test/chunking-form/samples/sourcemap-file-names-function/main.js b/test/chunking-form/samples/sourcemap-file-names-function/main.js new file mode 100644 index 00000000000..29507b1756e --- /dev/null +++ b/test/chunking-form/samples/sourcemap-file-names-function/main.js @@ -0,0 +1,2 @@ +import('./dynamic.js'); +import('./dynamic-hashed.js'); diff --git a/test/chunking-form/samples/sourcemap-file-names/_config.js b/test/chunking-form/samples/sourcemap-file-names/_config.js new file mode 100644 index 00000000000..2ea7138dc18 --- /dev/null +++ b/test/chunking-form/samples/sourcemap-file-names/_config.js @@ -0,0 +1,22 @@ +const assert = require('node:assert'); + +module.exports = defineTest({ + description: + 'populates sourcemapFileName property of OutputChunk with final name when using sourcemapFileNames option', + options: { + output: { + sourcemap: true, + entryFileNames: '[name]-[hash]-[format].js', + sourcemapFileNames: '[name]-[chunkhash]-[format]-[hash].js.map' + }, + plugins: [ + { + name: 'test-bundle', + generateBundle(options, bundle) { + const [sourcemapFileName, fileName] = Object.keys(bundle).sort(); + assert.strictEqual(bundle[fileName].sourcemapFileName, sourcemapFileName); + } + } + ] + } +}); diff --git a/test/chunking-form/samples/sourcemap-file-names/_expected/amd/main-CxF_f73M-amd-Bp_heMCp.js.map b/test/chunking-form/samples/sourcemap-file-names/_expected/amd/main-CxF_f73M-amd-Bp_heMCp.js.map new file mode 100644 index 00000000000..3bb1dd9c479 --- /dev/null +++ b/test/chunking-form/samples/sourcemap-file-names/_expected/amd/main-CxF_f73M-amd-Bp_heMCp.js.map @@ -0,0 +1 @@ +{"version":3,"file":"main-CxF_f73M-amd.js","sources":["../../main.js"],"sourcesContent":["console.log( 42 );\n"],"names":[],"mappings":";;CAAA,OAAO,CAAC,GAAG,EAAE,EAAE,EAAE;;;;;;"} \ No newline at end of file diff --git a/test/chunking-form/samples/sourcemap-file-names/_expected/amd/main-CxF_f73M-amd.js b/test/chunking-form/samples/sourcemap-file-names/_expected/amd/main-CxF_f73M-amd.js new file mode 100644 index 00000000000..63d3f72fc07 --- /dev/null +++ b/test/chunking-form/samples/sourcemap-file-names/_expected/amd/main-CxF_f73M-amd.js @@ -0,0 +1,6 @@ +define((function () { 'use strict'; + + console.log( 42 ); + +})); +//# sourceMappingURL=main-CxF_f73M-amd-Bp_heMCp.js.map diff --git a/test/chunking-form/samples/sourcemap-file-names/_expected/cjs/main-Br8Lt4cy-cjs-CQbnB8B7.js.map b/test/chunking-form/samples/sourcemap-file-names/_expected/cjs/main-Br8Lt4cy-cjs-CQbnB8B7.js.map new file mode 100644 index 00000000000..d499c7b9dc8 --- /dev/null +++ b/test/chunking-form/samples/sourcemap-file-names/_expected/cjs/main-Br8Lt4cy-cjs-CQbnB8B7.js.map @@ -0,0 +1 @@ +{"version":3,"file":"main-Br8Lt4cy-cjs.js","sources":["../../main.js"],"sourcesContent":["console.log( 42 );\n"],"names":[],"mappings":";;AAAA,OAAO,CAAC,GAAG,EAAE,EAAE,EAAE;;"} \ No newline at end of file diff --git a/test/chunking-form/samples/sourcemap-file-names/_expected/cjs/main-Br8Lt4cy-cjs.js b/test/chunking-form/samples/sourcemap-file-names/_expected/cjs/main-Br8Lt4cy-cjs.js new file mode 100644 index 00000000000..e18b70e60e3 --- /dev/null +++ b/test/chunking-form/samples/sourcemap-file-names/_expected/cjs/main-Br8Lt4cy-cjs.js @@ -0,0 +1,4 @@ +'use strict'; + +console.log( 42 ); +//# sourceMappingURL=main-Br8Lt4cy-cjs-CQbnB8B7.js.map diff --git a/test/chunking-form/samples/sourcemap-file-names/_expected/es/main-afmxdKJU-es-Dymp7TDl.js.map b/test/chunking-form/samples/sourcemap-file-names/_expected/es/main-afmxdKJU-es-Dymp7TDl.js.map new file mode 100644 index 00000000000..f5bc73958fb --- /dev/null +++ b/test/chunking-form/samples/sourcemap-file-names/_expected/es/main-afmxdKJU-es-Dymp7TDl.js.map @@ -0,0 +1 @@ +{"version":3,"file":"main-afmxdKJU-es.js","sources":["../../main.js"],"sourcesContent":["console.log( 42 );\n"],"names":[],"mappings":"AAAA,OAAO,CAAC,GAAG,EAAE,EAAE,EAAE"} \ No newline at end of file diff --git a/test/chunking-form/samples/sourcemap-file-names/_expected/es/main-afmxdKJU-es.js b/test/chunking-form/samples/sourcemap-file-names/_expected/es/main-afmxdKJU-es.js new file mode 100644 index 00000000000..b598fad1ff6 --- /dev/null +++ b/test/chunking-form/samples/sourcemap-file-names/_expected/es/main-afmxdKJU-es.js @@ -0,0 +1,2 @@ +console.log( 42 ); +//# sourceMappingURL=main-afmxdKJU-es-Dymp7TDl.js.map diff --git a/test/chunking-form/samples/sourcemap-file-names/_expected/system/main-DSPrUs6M-system-CaCM_p0F.js.map b/test/chunking-form/samples/sourcemap-file-names/_expected/system/main-DSPrUs6M-system-CaCM_p0F.js.map new file mode 100644 index 00000000000..a5fd6220a30 --- /dev/null +++ b/test/chunking-form/samples/sourcemap-file-names/_expected/system/main-DSPrUs6M-system-CaCM_p0F.js.map @@ -0,0 +1 @@ +{"version":3,"file":"main-DSPrUs6M-system.js","sources":["../../main.js"],"sourcesContent":["console.log( 42 );\n"],"names":[],"mappings":";;;;;GAAA,OAAO,CAAC,GAAG,EAAE,EAAE,EAAE;;;;;;;;"} \ No newline at end of file diff --git a/test/chunking-form/samples/sourcemap-file-names/_expected/system/main-DSPrUs6M-system.js b/test/chunking-form/samples/sourcemap-file-names/_expected/system/main-DSPrUs6M-system.js new file mode 100644 index 00000000000..e748ce7bfd7 --- /dev/null +++ b/test/chunking-form/samples/sourcemap-file-names/_expected/system/main-DSPrUs6M-system.js @@ -0,0 +1,11 @@ +System.register([], (function () { + 'use strict'; + return { + execute: (function () { + + console.log( 42 ); + + }) + }; +})); +//# sourceMappingURL=main-DSPrUs6M-system-CaCM_p0F.js.map diff --git a/test/sourcemaps/samples/transform-without-sourcemap-render-chunk/main.js b/test/chunking-form/samples/sourcemap-file-names/main.js similarity index 100% rename from test/sourcemaps/samples/transform-without-sourcemap-render-chunk/main.js rename to test/chunking-form/samples/sourcemap-file-names/main.js diff --git a/test/chunking-form/samples/splitting-cycles-module-with-TLA-and-dynamic-importer/_config.js b/test/chunking-form/samples/splitting-cycles-module-with-TLA-and-dynamic-importer/_config.js new file mode 100644 index 00000000000..558161a5967 --- /dev/null +++ b/test/chunking-form/samples/splitting-cycles-module-with-TLA-and-dynamic-importer/_config.js @@ -0,0 +1,6 @@ +module.exports = defineTest({ + description: + 'splitting module in cycles that is dynamically imported by a module with TLA into a separate chunk', + formats: ['es', 'system'], + expectedWarnings: ['CIRCULAR_DEPENDENCY'] +}); diff --git a/test/chunking-form/samples/splitting-cycles-module-with-TLA-and-dynamic-importer/_expected/es/generated-a.js b/test/chunking-form/samples/splitting-cycles-module-with-TLA-and-dynamic-importer/_expected/es/generated-a.js new file mode 100644 index 00000000000..98e053d26bc --- /dev/null +++ b/test/chunking-form/samples/splitting-cycles-module-with-TLA-and-dynamic-importer/_expected/es/generated-a.js @@ -0,0 +1,11 @@ +class B { + async foo() { + const foo = await import('./generated-foo.js'); + return new foo.Foo(); + } +} +await Promise.resolve(); + +class A extends B {} + +export { A }; diff --git a/test/chunking-form/samples/splitting-cycles-module-with-TLA-and-dynamic-importer/_expected/es/generated-foo.js b/test/chunking-form/samples/splitting-cycles-module-with-TLA-and-dynamic-importer/_expected/es/generated-foo.js new file mode 100644 index 00000000000..08a62726d76 --- /dev/null +++ b/test/chunking-form/samples/splitting-cycles-module-with-TLA-and-dynamic-importer/_expected/es/generated-foo.js @@ -0,0 +1,7 @@ +import { A } from './generated-a.js'; + +class Foo extends A { + foo() { console.log("hello"); } +} + +export { Foo as default }; diff --git a/test/chunking-form/samples/splitting-cycles-module-with-TLA-and-dynamic-importer/_expected/es/main.js b/test/chunking-form/samples/splitting-cycles-module-with-TLA-and-dynamic-importer/_expected/es/main.js new file mode 100644 index 00000000000..62ffcf1658a --- /dev/null +++ b/test/chunking-form/samples/splitting-cycles-module-with-TLA-and-dynamic-importer/_expected/es/main.js @@ -0,0 +1,10 @@ +import { A } from './generated-a.js'; +import Foo from './generated-foo.js'; + +class Bar extends A { + bar() { + return new Foo().foo(); + } +} + +new Bar().bar(); diff --git a/test/chunking-form/samples/splitting-cycles-module-with-TLA-and-dynamic-importer/_expected/system/generated-a.js b/test/chunking-form/samples/splitting-cycles-module-with-TLA-and-dynamic-importer/_expected/system/generated-a.js new file mode 100644 index 00000000000..999caf457ef --- /dev/null +++ b/test/chunking-form/samples/splitting-cycles-module-with-TLA-and-dynamic-importer/_expected/system/generated-a.js @@ -0,0 +1,18 @@ +System.register([], (function (exports, module) { + 'use strict'; + return { + execute: (async function () { + + class B { + async foo() { + const foo = await module.import('./generated-foo.js'); + return new foo.Foo(); + } + } + await Promise.resolve(); + + class A extends B {} exports("A", A); + + }) + }; +})); diff --git a/test/chunking-form/samples/splitting-cycles-module-with-TLA-and-dynamic-importer/_expected/system/generated-foo.js b/test/chunking-form/samples/splitting-cycles-module-with-TLA-and-dynamic-importer/_expected/system/generated-foo.js new file mode 100644 index 00000000000..7256f4fdcd8 --- /dev/null +++ b/test/chunking-form/samples/splitting-cycles-module-with-TLA-and-dynamic-importer/_expected/system/generated-foo.js @@ -0,0 +1,16 @@ +System.register(['./generated-a.js'], (function (exports) { + 'use strict'; + var A; + return { + setters: [function (module) { + A = module.A; + }], + execute: (function () { + + class Foo extends A { + foo() { console.log("hello"); } + } exports("default", Foo); + + }) + }; +})); diff --git a/test/chunking-form/samples/splitting-cycles-module-with-TLA-and-dynamic-importer/_expected/system/main.js b/test/chunking-form/samples/splitting-cycles-module-with-TLA-and-dynamic-importer/_expected/system/main.js new file mode 100644 index 00000000000..e4972a3006d --- /dev/null +++ b/test/chunking-form/samples/splitting-cycles-module-with-TLA-and-dynamic-importer/_expected/system/main.js @@ -0,0 +1,22 @@ +System.register(['./generated-a.js', './generated-foo.js'], (function () { + 'use strict'; + var A, Foo; + return { + setters: [function (module) { + A = module.A; + }, function (module) { + Foo = module.default; + }], + execute: (function () { + + class Bar extends A { + bar() { + return new Foo().foo(); + } + } + + new Bar().bar(); + + }) + }; +})); diff --git a/test/chunking-form/samples/splitting-cycles-module-with-TLA-and-dynamic-importer/a.js b/test/chunking-form/samples/splitting-cycles-module-with-TLA-and-dynamic-importer/a.js new file mode 100644 index 00000000000..46f03a1103b --- /dev/null +++ b/test/chunking-form/samples/splitting-cycles-module-with-TLA-and-dynamic-importer/a.js @@ -0,0 +1,3 @@ +import B from "./b.js" + +export default class A extends B {} diff --git a/test/chunking-form/samples/splitting-cycles-module-with-TLA-and-dynamic-importer/b.js b/test/chunking-form/samples/splitting-cycles-module-with-TLA-and-dynamic-importer/b.js new file mode 100644 index 00000000000..83ae53ed62f --- /dev/null +++ b/test/chunking-form/samples/splitting-cycles-module-with-TLA-and-dynamic-importer/b.js @@ -0,0 +1,7 @@ +export default class B { + async foo() { + const foo = await import("./foo.js"); + return new foo.Foo(); + } +} +await Promise.resolve(); diff --git a/test/chunking-form/samples/splitting-cycles-module-with-TLA-and-dynamic-importer/foo.js b/test/chunking-form/samples/splitting-cycles-module-with-TLA-and-dynamic-importer/foo.js new file mode 100644 index 00000000000..bfaaca158a0 --- /dev/null +++ b/test/chunking-form/samples/splitting-cycles-module-with-TLA-and-dynamic-importer/foo.js @@ -0,0 +1,5 @@ +import A from "./a.js" + +export default class Foo extends A { + foo() { console.log("hello") } +} diff --git a/test/chunking-form/samples/splitting-cycles-module-with-TLA-and-dynamic-importer/main.js b/test/chunking-form/samples/splitting-cycles-module-with-TLA-and-dynamic-importer/main.js new file mode 100644 index 00000000000..bebdc5bf99f --- /dev/null +++ b/test/chunking-form/samples/splitting-cycles-module-with-TLA-and-dynamic-importer/main.js @@ -0,0 +1,10 @@ +import A from "./a.js" +import Foo from "./foo.js" + +class Bar extends A { + bar() { + return new Foo().foo(); + } +} + +new Bar().bar(); diff --git a/test/chunking-form/samples/synthetic-named-exports/chained-default-reexport/_config.js b/test/chunking-form/samples/synthetic-named-exports/chained-default-reexport/_config.js index 78f0aef3f81..a30da76068b 100644 --- a/test/chunking-form/samples/synthetic-named-exports/chained-default-reexport/_config.js +++ b/test/chunking-form/samples/synthetic-named-exports/chained-default-reexport/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'handles synthetic named exports that are reexported as a default export over several stages', options: { @@ -9,4 +9,4 @@ module.exports = { } } } -}; +}); diff --git a/test/chunking-form/samples/synthetic-named-exports/chained-default-reexport/_expected/amd/generated-component.js b/test/chunking-form/samples/synthetic-named-exports/chained-default-reexport/_expected/amd/generated-component.js index 2f235fc0f72..834cbb472cb 100644 --- a/test/chunking-form/samples/synthetic-named-exports/chained-default-reexport/_expected/amd/generated-component.js +++ b/test/chunking-form/samples/synthetic-named-exports/chained-default-reexport/_expected/amd/generated-component.js @@ -1,11 +1,27 @@ -define(['exports', './generated-main'], function (exports, main) { 'use strict'; +define(['exports', './generated-main'], (function (exports, main) { 'use strict'; + + function _mergeNamespaces(n, m) { + m.forEach(function (e) { + e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) { + if (k !== 'default' && !(k in n)) { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + }); + return Object.freeze(n); + } var component = { lib: main.lib, lib2: main.lib.named, lib3: main.lib.named.named }; - var component$1 = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.assign(/*#__PURE__*/Object.create(null), component, { - 'default': component - })); + var component$1 = /*#__PURE__*/_mergeNamespaces({ + __proto__: null, + default: component + }, [component]); exports.component = component$1; -}); +})); diff --git a/test/chunking-form/samples/synthetic-named-exports/chained-default-reexport/_expected/amd/generated-main.js b/test/chunking-form/samples/synthetic-named-exports/chained-default-reexport/_expected/amd/generated-main.js index bb7506c4c4e..f5cf4463381 100644 --- a/test/chunking-form/samples/synthetic-named-exports/chained-default-reexport/_expected/amd/generated-main.js +++ b/test/chunking-form/samples/synthetic-named-exports/chained-default-reexport/_expected/amd/generated-main.js @@ -1,4 +1,4 @@ -define(['require', 'exports'], function (require, exports) { 'use strict'; +define(['require', 'exports'], (function (require, exports) { 'use strict'; const lib = { named: { named: 42 } }; @@ -6,9 +6,9 @@ define(['require', 'exports'], function (require, exports) { 'use strict'; console.log('side-effect', lib.named.named); - const component = new Promise(function (resolve, reject) { require(['./generated-component'], resolve, reject) }).then(function (n) { return n.component; }); + const component = new Promise(function (resolve, reject) { require(['./generated-component'], resolve, reject); }).then(function (n) { return n.component; }); exports.component = component; exports.lib = lib; -}); +})); diff --git a/test/chunking-form/samples/synthetic-named-exports/chained-default-reexport/_expected/amd/main.js b/test/chunking-form/samples/synthetic-named-exports/chained-default-reexport/_expected/amd/main.js index e467a6ebe84..5499ce03b53 100644 --- a/test/chunking-form/samples/synthetic-named-exports/chained-default-reexport/_expected/amd/main.js +++ b/test/chunking-form/samples/synthetic-named-exports/chained-default-reexport/_expected/amd/main.js @@ -1,10 +1,8 @@ -define(['exports', './generated-main'], function (exports, main) { 'use strict'; +define(['exports', './generated-main'], (function (exports, main) { 'use strict'; exports.component = main.component; exports.lib = main.lib.named.named; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/synthetic-named-exports/chained-default-reexport/_expected/cjs/generated-component.js b/test/chunking-form/samples/synthetic-named-exports/chained-default-reexport/_expected/cjs/generated-component.js index 58f27d2e15e..54e01c10f30 100644 --- a/test/chunking-form/samples/synthetic-named-exports/chained-default-reexport/_expected/cjs/generated-component.js +++ b/test/chunking-form/samples/synthetic-named-exports/chained-default-reexport/_expected/cjs/generated-component.js @@ -2,10 +2,26 @@ var main = require('./generated-main.js'); +function _mergeNamespaces(n, m) { + m.forEach(function (e) { + e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) { + if (k !== 'default' && !(k in n)) { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + }); + return Object.freeze(n); +} + var component = { lib: main.lib, lib2: main.lib.named, lib3: main.lib.named.named }; -var component$1 = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.assign(/*#__PURE__*/Object.create(null), component, { - 'default': component -})); +var component$1 = /*#__PURE__*/_mergeNamespaces({ + __proto__: null, + default: component +}, [component]); exports.component = component$1; diff --git a/test/chunking-form/samples/synthetic-named-exports/chained-default-reexport/_expected/cjs/main.js b/test/chunking-form/samples/synthetic-named-exports/chained-default-reexport/_expected/cjs/main.js index 351234d241f..e8fba38781c 100644 --- a/test/chunking-form/samples/synthetic-named-exports/chained-default-reexport/_expected/cjs/main.js +++ b/test/chunking-form/samples/synthetic-named-exports/chained-default-reexport/_expected/cjs/main.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - var main = require('./generated-main.js'); diff --git a/test/chunking-form/samples/synthetic-named-exports/chained-default-reexport/_expected/es/generated-component.js b/test/chunking-form/samples/synthetic-named-exports/chained-default-reexport/_expected/es/generated-component.js index c3a53df5f49..3f800ff3271 100644 --- a/test/chunking-form/samples/synthetic-named-exports/chained-default-reexport/_expected/es/generated-component.js +++ b/test/chunking-form/samples/synthetic-named-exports/chained-default-reexport/_expected/es/generated-component.js @@ -1,9 +1,25 @@ import { l as lib } from './generated-main.js'; +function _mergeNamespaces(n, m) { + m.forEach(function (e) { + e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) { + if (k !== 'default' && !(k in n)) { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + }); + return Object.freeze(n); +} + var component = { lib, lib2: lib.named, lib3: lib.named.named }; -var component$1 = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.assign(/*#__PURE__*/Object.create(null), component, { - 'default': component -})); +var component$1 = /*#__PURE__*/_mergeNamespaces({ + __proto__: null, + default: component +}, [component]); export { component$1 as c }; diff --git a/test/chunking-form/samples/synthetic-named-exports/chained-default-reexport/_expected/system/generated-component.js b/test/chunking-form/samples/synthetic-named-exports/chained-default-reexport/_expected/system/generated-component.js index 0336366b0a3..6435b82d8b3 100644 --- a/test/chunking-form/samples/synthetic-named-exports/chained-default-reexport/_expected/system/generated-component.js +++ b/test/chunking-form/samples/synthetic-named-exports/chained-default-reexport/_expected/system/generated-component.js @@ -1,19 +1,35 @@ -System.register(['./generated-main.js'], function (exports) { +System.register(['./generated-main.js'], (function (exports) { 'use strict'; var lib; return { setters: [function (module) { lib = module.l; }], - execute: function () { + execute: (function () { + + function _mergeNamespaces(n, m) { + m.forEach(function (e) { + e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) { + if (k !== 'default' && !(k in n)) { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + }); + return Object.freeze(n); + } var component = { lib, lib2: lib.named, lib3: lib.named.named }; - var component$1 = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.assign(/*#__PURE__*/Object.create(null), component, { - 'default': component - })); - exports('c', component$1); + var component$1 = /*#__PURE__*/_mergeNamespaces({ + __proto__: null, + default: component + }, [component]); + exports("c", component$1); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/synthetic-named-exports/chained-default-reexport/_expected/system/generated-main.js b/test/chunking-form/samples/synthetic-named-exports/chained-default-reexport/_expected/system/generated-main.js index 22b25341239..585c7b2d436 100644 --- a/test/chunking-form/samples/synthetic-named-exports/chained-default-reexport/_expected/system/generated-main.js +++ b/test/chunking-form/samples/synthetic-named-exports/chained-default-reexport/_expected/system/generated-main.js @@ -1,16 +1,16 @@ -System.register([], function (exports, module) { +System.register([], (function (exports, module) { 'use strict'; return { - execute: function () { + execute: (function () { - const lib = exports('l', { named: { named: 42 } }); + const lib = exports("l", { named: { named: 42 } }); console.log('side-effect', lib.named); console.log('side-effect', lib.named.named); - const component = exports('c', module.import('./generated-component.js').then(function (n) { return n.c; })); + const component = exports("c", module.import('./generated-component.js').then(function (n) { return n.c; })); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/synthetic-named-exports/chained-default-reexport/_expected/system/main.js b/test/chunking-form/samples/synthetic-named-exports/chained-default-reexport/_expected/system/main.js index 93f798d3b7d..d1a2906e7b8 100644 --- a/test/chunking-form/samples/synthetic-named-exports/chained-default-reexport/_expected/system/main.js +++ b/test/chunking-form/samples/synthetic-named-exports/chained-default-reexport/_expected/system/main.js @@ -1,17 +1,17 @@ -System.register(['./generated-main.js'], function (exports) { +System.register(['./generated-main.js'], (function (exports) { 'use strict'; var lib; return { setters: [function (module) { lib = module.l; - exports('component', module.c); + exports("component", module.c); }], - execute: function () { + execute: (function () { - exports('lib', lib.named.named); + exports("lib", lib.named.named); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/synthetic-named-exports/deduplicate-synthetic-named-exports-and-default/_config.js b/test/chunking-form/samples/synthetic-named-exports/deduplicate-synthetic-named-exports-and-default/_config.js index 9553f613606..55d81a22772 100644 --- a/test/chunking-form/samples/synthetic-named-exports/deduplicate-synthetic-named-exports-and-default/_config.js +++ b/test/chunking-form/samples/synthetic-named-exports/deduplicate-synthetic-named-exports-and-default/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'handles importing a synthetic named export together with the default export', options: { input: ['main1', 'main2', 'main3'], @@ -14,4 +14,4 @@ module.exports = { } ] } -}; +}); diff --git a/test/chunking-form/samples/synthetic-named-exports/deduplicate-synthetic-named-exports-and-default/_expected/amd/generated-lib.js b/test/chunking-form/samples/synthetic-named-exports/deduplicate-synthetic-named-exports-and-default/_expected/amd/generated-lib.js deleted file mode 100644 index ddc3e67c5c1..00000000000 --- a/test/chunking-form/samples/synthetic-named-exports/deduplicate-synthetic-named-exports-and-default/_expected/amd/generated-lib.js +++ /dev/null @@ -1,7 +0,0 @@ -define(['exports'], function (exports) { 'use strict'; - - var lib = { foo: true, bar: true, baz: true }; - - exports.lib = lib; - -}); diff --git a/test/chunking-form/samples/synthetic-named-exports/deduplicate-synthetic-named-exports-and-default/_expected/amd/main1.js b/test/chunking-form/samples/synthetic-named-exports/deduplicate-synthetic-named-exports-and-default/_expected/amd/main1.js index 016e31a212b..77212c9788a 100644 --- a/test/chunking-form/samples/synthetic-named-exports/deduplicate-synthetic-named-exports-and-default/_expected/amd/main1.js +++ b/test/chunking-form/samples/synthetic-named-exports/deduplicate-synthetic-named-exports-and-default/_expected/amd/main1.js @@ -1,10 +1,8 @@ -define(['exports', './generated-lib'], function (exports, lib) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; + var lib = { foo: true, bar: true, baz: true }; + exports.foo = lib.foo; + exports.lib = lib; - exports.lib = lib.lib; - exports.foo = lib.lib.foo; - - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/synthetic-named-exports/deduplicate-synthetic-named-exports-and-default/_expected/amd/main2.js b/test/chunking-form/samples/synthetic-named-exports/deduplicate-synthetic-named-exports-and-default/_expected/amd/main2.js index 11d3c897835..6b4c741df82 100644 --- a/test/chunking-form/samples/synthetic-named-exports/deduplicate-synthetic-named-exports-and-default/_expected/amd/main2.js +++ b/test/chunking-form/samples/synthetic-named-exports/deduplicate-synthetic-named-exports-and-default/_expected/amd/main2.js @@ -1,5 +1,5 @@ -define(['./generated-lib'], function (lib) { 'use strict'; +define(['./main1'], (function (main1) { 'use strict'; - console.log(lib.lib, lib.lib.foo, lib.lib.bar, lib.lib.baz); + console.log(main1.lib, main1.lib.foo, main1.lib.bar, main1.lib.baz); -}); +})); diff --git a/test/chunking-form/samples/synthetic-named-exports/deduplicate-synthetic-named-exports-and-default/_expected/amd/main3.js b/test/chunking-form/samples/synthetic-named-exports/deduplicate-synthetic-named-exports-and-default/_expected/amd/main3.js index 503be04cea0..582504359ca 100644 --- a/test/chunking-form/samples/synthetic-named-exports/deduplicate-synthetic-named-exports-and-default/_expected/amd/main3.js +++ b/test/chunking-form/samples/synthetic-named-exports/deduplicate-synthetic-named-exports-and-default/_expected/amd/main3.js @@ -1,9 +1,7 @@ -define(['exports', './generated-lib'], function (exports, lib) { 'use strict'; +define(['exports', './main1'], (function (exports, main1) { 'use strict'; - exports.foo = lib.lib.foo; + exports.foo = main1.lib.foo; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/synthetic-named-exports/deduplicate-synthetic-named-exports-and-default/_expected/cjs/generated-lib.js b/test/chunking-form/samples/synthetic-named-exports/deduplicate-synthetic-named-exports-and-default/_expected/cjs/generated-lib.js deleted file mode 100644 index 8f023f26e39..00000000000 --- a/test/chunking-form/samples/synthetic-named-exports/deduplicate-synthetic-named-exports-and-default/_expected/cjs/generated-lib.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -var lib = { foo: true, bar: true, baz: true }; - -exports.lib = lib; diff --git a/test/chunking-form/samples/synthetic-named-exports/deduplicate-synthetic-named-exports-and-default/_expected/cjs/main1.js b/test/chunking-form/samples/synthetic-named-exports/deduplicate-synthetic-named-exports-and-default/_expected/cjs/main1.js index c161933fa8b..7a8569163e5 100644 --- a/test/chunking-form/samples/synthetic-named-exports/deduplicate-synthetic-named-exports-and-default/_expected/cjs/main1.js +++ b/test/chunking-form/samples/synthetic-named-exports/deduplicate-synthetic-named-exports-and-default/_expected/cjs/main1.js @@ -1,10 +1,6 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); +var lib = { foo: true, bar: true, baz: true }; -var lib = require('./generated-lib.js'); - - - -exports.lib = lib.lib; -exports.foo = lib.lib.foo; +exports.foo = lib.foo; +exports.lib = lib; diff --git a/test/chunking-form/samples/synthetic-named-exports/deduplicate-synthetic-named-exports-and-default/_expected/cjs/main2.js b/test/chunking-form/samples/synthetic-named-exports/deduplicate-synthetic-named-exports-and-default/_expected/cjs/main2.js index 96ce48edb46..fa13db42b6f 100644 --- a/test/chunking-form/samples/synthetic-named-exports/deduplicate-synthetic-named-exports-and-default/_expected/cjs/main2.js +++ b/test/chunking-form/samples/synthetic-named-exports/deduplicate-synthetic-named-exports-and-default/_expected/cjs/main2.js @@ -1,5 +1,5 @@ 'use strict'; -var lib = require('./generated-lib.js'); +var main1 = require('./main1.js'); -console.log(lib.lib, lib.lib.foo, lib.lib.bar, lib.lib.baz); +console.log(main1.lib, main1.lib.foo, main1.lib.bar, main1.lib.baz); diff --git a/test/chunking-form/samples/synthetic-named-exports/deduplicate-synthetic-named-exports-and-default/_expected/cjs/main3.js b/test/chunking-form/samples/synthetic-named-exports/deduplicate-synthetic-named-exports-and-default/_expected/cjs/main3.js index 060e43c4807..bd507bf42fa 100644 --- a/test/chunking-form/samples/synthetic-named-exports/deduplicate-synthetic-named-exports-and-default/_expected/cjs/main3.js +++ b/test/chunking-form/samples/synthetic-named-exports/deduplicate-synthetic-named-exports-and-default/_expected/cjs/main3.js @@ -1,9 +1,7 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); +var main1 = require('./main1.js'); -var lib = require('./generated-lib.js'); - -exports.foo = lib.lib.foo; +exports.foo = main1.lib.foo; diff --git a/test/chunking-form/samples/synthetic-named-exports/deduplicate-synthetic-named-exports-and-default/_expected/es/generated-lib.js b/test/chunking-form/samples/synthetic-named-exports/deduplicate-synthetic-named-exports-and-default/_expected/es/generated-lib.js deleted file mode 100644 index 9196d1bda06..00000000000 --- a/test/chunking-form/samples/synthetic-named-exports/deduplicate-synthetic-named-exports-and-default/_expected/es/generated-lib.js +++ /dev/null @@ -1,3 +0,0 @@ -var lib = { foo: true, bar: true, baz: true }; - -export { lib as l }; diff --git a/test/chunking-form/samples/synthetic-named-exports/deduplicate-synthetic-named-exports-and-default/_expected/es/main1.js b/test/chunking-form/samples/synthetic-named-exports/deduplicate-synthetic-named-exports-and-default/_expected/es/main1.js index fd5fab10b7a..3c2424265a4 100644 --- a/test/chunking-form/samples/synthetic-named-exports/deduplicate-synthetic-named-exports-and-default/_expected/es/main1.js +++ b/test/chunking-form/samples/synthetic-named-exports/deduplicate-synthetic-named-exports-and-default/_expected/es/main1.js @@ -1,7 +1,4 @@ -import { l as lib } from './generated-lib.js'; -export { l as lib } from './generated-lib.js'; - - +var lib = { foo: true, bar: true, baz: true }; var foo = lib.foo; -export { foo }; +export { foo, lib }; diff --git a/test/chunking-form/samples/synthetic-named-exports/deduplicate-synthetic-named-exports-and-default/_expected/es/main2.js b/test/chunking-form/samples/synthetic-named-exports/deduplicate-synthetic-named-exports-and-default/_expected/es/main2.js index 84d281eca4e..c927ef6ce31 100644 --- a/test/chunking-form/samples/synthetic-named-exports/deduplicate-synthetic-named-exports-and-default/_expected/es/main2.js +++ b/test/chunking-form/samples/synthetic-named-exports/deduplicate-synthetic-named-exports-and-default/_expected/es/main2.js @@ -1,3 +1,3 @@ -import { l as lib } from './generated-lib.js'; +import { lib } from './main1.js'; console.log(lib, lib.foo, lib.bar, lib.baz); diff --git a/test/chunking-form/samples/synthetic-named-exports/deduplicate-synthetic-named-exports-and-default/_expected/es/main3.js b/test/chunking-form/samples/synthetic-named-exports/deduplicate-synthetic-named-exports-and-default/_expected/es/main3.js index 76cd1353449..e6592ff26e5 100644 --- a/test/chunking-form/samples/synthetic-named-exports/deduplicate-synthetic-named-exports-and-default/_expected/es/main3.js +++ b/test/chunking-form/samples/synthetic-named-exports/deduplicate-synthetic-named-exports-and-default/_expected/es/main3.js @@ -1,4 +1,4 @@ -import { l as lib } from './generated-lib.js'; +import { lib } from './main1.js'; diff --git a/test/chunking-form/samples/synthetic-named-exports/deduplicate-synthetic-named-exports-and-default/_expected/system/generated-lib.js b/test/chunking-form/samples/synthetic-named-exports/deduplicate-synthetic-named-exports-and-default/_expected/system/generated-lib.js deleted file mode 100644 index 5ec5bda9998..00000000000 --- a/test/chunking-form/samples/synthetic-named-exports/deduplicate-synthetic-named-exports-and-default/_expected/system/generated-lib.js +++ /dev/null @@ -1,10 +0,0 @@ -System.register([], function (exports) { - 'use strict'; - return { - execute: function () { - - var lib = exports('l', { foo: true, bar: true, baz: true }); - - } - }; -}); diff --git a/test/chunking-form/samples/synthetic-named-exports/deduplicate-synthetic-named-exports-and-default/_expected/system/main1.js b/test/chunking-form/samples/synthetic-named-exports/deduplicate-synthetic-named-exports-and-default/_expected/system/main1.js index 040f04f92e1..c6a0573aa2d 100644 --- a/test/chunking-form/samples/synthetic-named-exports/deduplicate-synthetic-named-exports-and-default/_expected/system/main1.js +++ b/test/chunking-form/samples/synthetic-named-exports/deduplicate-synthetic-named-exports-and-default/_expected/system/main1.js @@ -1,17 +1,12 @@ -System.register(['./generated-lib.js'], function (exports) { +System.register([], (function (exports) { 'use strict'; - var lib; return { - setters: [function (module) { - lib = module.l; - exports('lib', module.l); - }], - execute: function () { + execute: (function () { + var lib = exports("lib", { foo: true, bar: true, baz: true }); + exports("foo", lib.foo); - exports('foo', lib.foo); - - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/synthetic-named-exports/deduplicate-synthetic-named-exports-and-default/_expected/system/main2.js b/test/chunking-form/samples/synthetic-named-exports/deduplicate-synthetic-named-exports-and-default/_expected/system/main2.js index f5170242109..b7d77d70bbc 100644 --- a/test/chunking-form/samples/synthetic-named-exports/deduplicate-synthetic-named-exports-and-default/_expected/system/main2.js +++ b/test/chunking-form/samples/synthetic-named-exports/deduplicate-synthetic-named-exports-and-default/_expected/system/main2.js @@ -1,14 +1,14 @@ -System.register(['./generated-lib.js'], function () { +System.register(['./main1.js'], (function () { 'use strict'; var lib; return { setters: [function (module) { - lib = module.l; + lib = module.lib; }], - execute: function () { + execute: (function () { console.log(lib, lib.foo, lib.bar, lib.baz); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/synthetic-named-exports/deduplicate-synthetic-named-exports-and-default/_expected/system/main3.js b/test/chunking-form/samples/synthetic-named-exports/deduplicate-synthetic-named-exports-and-default/_expected/system/main3.js index 6a5024c167d..1d9a2e5f8c0 100644 --- a/test/chunking-form/samples/synthetic-named-exports/deduplicate-synthetic-named-exports-and-default/_expected/system/main3.js +++ b/test/chunking-form/samples/synthetic-named-exports/deduplicate-synthetic-named-exports-and-default/_expected/system/main3.js @@ -1,16 +1,16 @@ -System.register(['./generated-lib.js'], function (exports) { +System.register(['./main1.js'], (function (exports) { 'use strict'; var lib; return { setters: [function (module) { - lib = module.l; + lib = module.lib; }], - execute: function () { + execute: (function () { - exports('foo', lib.foo); + exports("foo", lib.foo); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/synthetic-named-exports/default-reexport/_config.js b/test/chunking-form/samples/synthetic-named-exports/default-reexport/_config.js index fec9cd1e44b..45fab3730c5 100644 --- a/test/chunking-form/samples/synthetic-named-exports/default-reexport/_config.js +++ b/test/chunking-form/samples/synthetic-named-exports/default-reexport/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'handles synthetic named exports that are reexported as a default export where both the default and a named export is used', options: { @@ -9,4 +9,4 @@ module.exports = { } } } -}; +}); diff --git a/test/chunking-form/samples/synthetic-named-exports/default-reexport/_expected/amd/generated-component.js b/test/chunking-form/samples/synthetic-named-exports/default-reexport/_expected/amd/generated-component.js index c882ef815da..5caa5ebc209 100644 --- a/test/chunking-form/samples/synthetic-named-exports/default-reexport/_expected/amd/generated-component.js +++ b/test/chunking-form/samples/synthetic-named-exports/default-reexport/_expected/amd/generated-component.js @@ -1,11 +1,27 @@ -define(['exports', './main'], function (exports, main) { 'use strict'; +define(['exports', './main'], (function (exports, main) { 'use strict'; + + function _mergeNamespaces(n, m) { + m.forEach(function (e) { + e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) { + if (k !== 'default' && !(k in n)) { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + }); + return Object.freeze(n); + } var component = { lib: main.lib, someExport: main.lib.someExport }; - var component$1 = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.assign(/*#__PURE__*/Object.create(null), component, { - 'default': component - })); + var component$1 = /*#__PURE__*/_mergeNamespaces({ + __proto__: null, + default: component + }, [component]); exports.component = component$1; -}); +})); diff --git a/test/chunking-form/samples/synthetic-named-exports/default-reexport/_expected/amd/main.js b/test/chunking-form/samples/synthetic-named-exports/default-reexport/_expected/amd/main.js index 0674d98842c..12f2cfbf093 100644 --- a/test/chunking-form/samples/synthetic-named-exports/default-reexport/_expected/amd/main.js +++ b/test/chunking-form/samples/synthetic-named-exports/default-reexport/_expected/amd/main.js @@ -1,14 +1,12 @@ -define(['require', 'exports'], function (require, exports) { 'use strict'; +define(['require', 'exports'], (function (require, exports) { 'use strict'; var lib = {}; console.log('side-effect', lib); - const component = new Promise(function (resolve, reject) { require(['./generated-component'], resolve, reject) }).then(function (n) { return n.component; }); + const component = new Promise(function (resolve, reject) { require(['./generated-component'], resolve, reject); }).then(function (n) { return n.component; }); exports.component = component; exports.lib = lib; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/synthetic-named-exports/default-reexport/_expected/cjs/generated-component.js b/test/chunking-form/samples/synthetic-named-exports/default-reexport/_expected/cjs/generated-component.js index 14615547735..f38d41c1139 100644 --- a/test/chunking-form/samples/synthetic-named-exports/default-reexport/_expected/cjs/generated-component.js +++ b/test/chunking-form/samples/synthetic-named-exports/default-reexport/_expected/cjs/generated-component.js @@ -2,10 +2,26 @@ var main = require('./main.js'); +function _mergeNamespaces(n, m) { + m.forEach(function (e) { + e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) { + if (k !== 'default' && !(k in n)) { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + }); + return Object.freeze(n); +} + var component = { lib: main.lib, someExport: main.lib.someExport }; -var component$1 = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.assign(/*#__PURE__*/Object.create(null), component, { - 'default': component -})); +var component$1 = /*#__PURE__*/_mergeNamespaces({ + __proto__: null, + default: component +}, [component]); exports.component = component$1; diff --git a/test/chunking-form/samples/synthetic-named-exports/default-reexport/_expected/cjs/main.js b/test/chunking-form/samples/synthetic-named-exports/default-reexport/_expected/cjs/main.js index 17f88ab1c4e..76efd251ca5 100644 --- a/test/chunking-form/samples/synthetic-named-exports/default-reexport/_expected/cjs/main.js +++ b/test/chunking-form/samples/synthetic-named-exports/default-reexport/_expected/cjs/main.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - var lib = {}; console.log('side-effect', lib); diff --git a/test/chunking-form/samples/synthetic-named-exports/default-reexport/_expected/es/generated-component.js b/test/chunking-form/samples/synthetic-named-exports/default-reexport/_expected/es/generated-component.js index 43f2816ca83..d625fba3610 100644 --- a/test/chunking-form/samples/synthetic-named-exports/default-reexport/_expected/es/generated-component.js +++ b/test/chunking-form/samples/synthetic-named-exports/default-reexport/_expected/es/generated-component.js @@ -1,9 +1,25 @@ import { lib } from './main.js'; +function _mergeNamespaces(n, m) { + m.forEach(function (e) { + e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) { + if (k !== 'default' && !(k in n)) { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + }); + return Object.freeze(n); +} + var component = { lib, someExport: lib.someExport }; -var component$1 = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.assign(/*#__PURE__*/Object.create(null), component, { - 'default': component -})); +var component$1 = /*#__PURE__*/_mergeNamespaces({ + __proto__: null, + default: component +}, [component]); export { component$1 as c }; diff --git a/test/chunking-form/samples/synthetic-named-exports/default-reexport/_expected/system/generated-component.js b/test/chunking-form/samples/synthetic-named-exports/default-reexport/_expected/system/generated-component.js index 974cee4dec1..bc737358652 100644 --- a/test/chunking-form/samples/synthetic-named-exports/default-reexport/_expected/system/generated-component.js +++ b/test/chunking-form/samples/synthetic-named-exports/default-reexport/_expected/system/generated-component.js @@ -1,19 +1,35 @@ -System.register(['./main.js'], function (exports) { +System.register(['./main.js'], (function (exports) { 'use strict'; var lib; return { setters: [function (module) { lib = module.lib; }], - execute: function () { + execute: (function () { + + function _mergeNamespaces(n, m) { + m.forEach(function (e) { + e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) { + if (k !== 'default' && !(k in n)) { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + }); + return Object.freeze(n); + } var component = { lib, someExport: lib.someExport }; - var component$1 = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.assign(/*#__PURE__*/Object.create(null), component, { - 'default': component - })); - exports('c', component$1); + var component$1 = /*#__PURE__*/_mergeNamespaces({ + __proto__: null, + default: component + }, [component]); + exports("c", component$1); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/synthetic-named-exports/default-reexport/_expected/system/main.js b/test/chunking-form/samples/synthetic-named-exports/default-reexport/_expected/system/main.js index bc136b49a0a..a762ac14dbb 100644 --- a/test/chunking-form/samples/synthetic-named-exports/default-reexport/_expected/system/main.js +++ b/test/chunking-form/samples/synthetic-named-exports/default-reexport/_expected/system/main.js @@ -1,14 +1,14 @@ -System.register([], function (exports, module) { +System.register([], (function (exports, module) { 'use strict'; return { - execute: function () { + execute: (function () { - var lib = exports('lib', {}); + var lib = exports("lib", {}); console.log('side-effect', lib); - const component = exports('component', module.import('./generated-component.js').then(function (n) { return n.c; })); + const component = exports("component", module.import('./generated-component.js').then(function (n) { return n.c; })); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/synthetic-named-exports/dynamic-import/_config.js b/test/chunking-form/samples/synthetic-named-exports/dynamic-import/_config.js index 9a5dad50910..a0df85e8d12 100644 --- a/test/chunking-form/samples/synthetic-named-exports/dynamic-import/_config.js +++ b/test/chunking-form/samples/synthetic-named-exports/dynamic-import/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'synthetic named exports', options: { input: ['main.js'], @@ -12,4 +12,4 @@ module.exports = { } ] } -}; +}); diff --git a/test/chunking-form/samples/synthetic-named-exports/dynamic-import/_expected/amd/generated-dep.js b/test/chunking-form/samples/synthetic-named-exports/dynamic-import/_expected/amd/generated-dep.js index dce8fca82c1..9b804b611db 100644 --- a/test/chunking-form/samples/synthetic-named-exports/dynamic-import/_expected/amd/generated-dep.js +++ b/test/chunking-form/samples/synthetic-named-exports/dynamic-import/_expected/amd/generated-dep.js @@ -1,13 +1,29 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; + + function _mergeNamespaces(n, m) { + m.forEach(function (e) { + e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) { + if (k !== 'default' && !(k in n)) { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + }); + return Object.freeze(n); + } var dep = { foo: 1 }; const bar = 2; - var dep$1 = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.assign(/*#__PURE__*/Object.create(null), dep, { - 'default': dep, - bar: bar - })); + var dep$1 = /*#__PURE__*/_mergeNamespaces({ + __proto__: null, + bar: bar, + default: dep + }, [dep]); exports.dep = dep$1; -}); +})); diff --git a/test/chunking-form/samples/synthetic-named-exports/dynamic-import/_expected/amd/main.js b/test/chunking-form/samples/synthetic-named-exports/dynamic-import/_expected/amd/main.js index edbdecbe1b0..ec2671f67f2 100644 --- a/test/chunking-form/samples/synthetic-named-exports/dynamic-import/_expected/amd/main.js +++ b/test/chunking-form/samples/synthetic-named-exports/dynamic-import/_expected/amd/main.js @@ -1,5 +1,5 @@ -define(['require'], function (require) { 'use strict'; +define(['require'], (function (require) { 'use strict'; - new Promise(function (resolve, reject) { require(['./generated-dep'], resolve, reject) }).then(function (n) { return n.dep; }).then(({ foo, bar, baz }) => console.log(foo, bar, baz)); + new Promise(function (resolve, reject) { require(['./generated-dep'], resolve, reject); }).then(function (n) { return n.dep; }).then(({ foo, bar, baz }) => console.log(foo, bar, baz)); -}); +})); diff --git a/test/chunking-form/samples/synthetic-named-exports/dynamic-import/_expected/cjs/generated-dep.js b/test/chunking-form/samples/synthetic-named-exports/dynamic-import/_expected/cjs/generated-dep.js index cdb9f3cb23d..13562d62a66 100644 --- a/test/chunking-form/samples/synthetic-named-exports/dynamic-import/_expected/cjs/generated-dep.js +++ b/test/chunking-form/samples/synthetic-named-exports/dynamic-import/_expected/cjs/generated-dep.js @@ -1,11 +1,27 @@ 'use strict'; +function _mergeNamespaces(n, m) { + m.forEach(function (e) { + e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) { + if (k !== 'default' && !(k in n)) { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + }); + return Object.freeze(n); +} + var dep = { foo: 1 }; const bar = 2; -var dep$1 = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.assign(/*#__PURE__*/Object.create(null), dep, { - 'default': dep, - bar: bar -})); +var dep$1 = /*#__PURE__*/_mergeNamespaces({ + __proto__: null, + bar: bar, + default: dep +}, [dep]); exports.dep = dep$1; diff --git a/test/chunking-form/samples/synthetic-named-exports/dynamic-import/_expected/es/generated-dep.js b/test/chunking-form/samples/synthetic-named-exports/dynamic-import/_expected/es/generated-dep.js index e7de5ffdecb..bf8c667fea1 100644 --- a/test/chunking-form/samples/synthetic-named-exports/dynamic-import/_expected/es/generated-dep.js +++ b/test/chunking-form/samples/synthetic-named-exports/dynamic-import/_expected/es/generated-dep.js @@ -1,9 +1,25 @@ +function _mergeNamespaces(n, m) { + m.forEach(function (e) { + e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) { + if (k !== 'default' && !(k in n)) { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + }); + return Object.freeze(n); +} + var dep = { foo: 1 }; const bar = 2; -var dep$1 = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.assign(/*#__PURE__*/Object.create(null), dep, { - 'default': dep, - bar: bar -})); +var dep$1 = /*#__PURE__*/_mergeNamespaces({ + __proto__: null, + bar: bar, + default: dep +}, [dep]); export { dep$1 as d }; diff --git a/test/chunking-form/samples/synthetic-named-exports/dynamic-import/_expected/system/generated-dep.js b/test/chunking-form/samples/synthetic-named-exports/dynamic-import/_expected/system/generated-dep.js index 09f22b8706e..076f01f7c38 100644 --- a/test/chunking-form/samples/synthetic-named-exports/dynamic-import/_expected/system/generated-dep.js +++ b/test/chunking-form/samples/synthetic-named-exports/dynamic-import/_expected/system/generated-dep.js @@ -1,17 +1,33 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { + + function _mergeNamespaces(n, m) { + m.forEach(function (e) { + e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) { + if (k !== 'default' && !(k in n)) { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + }); + return Object.freeze(n); + } var dep = { foo: 1 }; const bar = 2; - var dep$1 = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.assign(/*#__PURE__*/Object.create(null), dep, { - 'default': dep, - bar: bar - })); - exports('d', dep$1); + var dep$1 = /*#__PURE__*/_mergeNamespaces({ + __proto__: null, + bar: bar, + default: dep + }, [dep]); + exports("d", dep$1); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/synthetic-named-exports/dynamic-import/_expected/system/main.js b/test/chunking-form/samples/synthetic-named-exports/dynamic-import/_expected/system/main.js index 577783aa881..dba7ac8e00e 100644 --- a/test/chunking-form/samples/synthetic-named-exports/dynamic-import/_expected/system/main.js +++ b/test/chunking-form/samples/synthetic-named-exports/dynamic-import/_expected/system/main.js @@ -1,10 +1,10 @@ -System.register([], function (exports, module) { +System.register([], (function (exports, module) { 'use strict'; return { - execute: function () { + execute: (function () { module.import('./generated-dep.js').then(function (n) { return n.d; }).then(({ foo, bar, baz }) => console.log(foo, bar, baz)); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/synthetic-named-exports/entry/_config.js b/test/chunking-form/samples/synthetic-named-exports/entry/_config.js index dc6f4350347..f89a194c13b 100644 --- a/test/chunking-form/samples/synthetic-named-exports/entry/_config.js +++ b/test/chunking-form/samples/synthetic-named-exports/entry/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'does not expose the synthetic namespace if an entry point uses a string value', options: { input: ['main', 'other'], @@ -10,4 +10,4 @@ module.exports = { } ] } -}; +}); diff --git a/test/chunking-form/samples/synthetic-named-exports/entry/_expected/amd/generated-main.js b/test/chunking-form/samples/synthetic-named-exports/entry/_expected/amd/generated-main.js index 6bd13c4d639..8fe7283a5fc 100644 --- a/test/chunking-form/samples/synthetic-named-exports/entry/_expected/amd/generated-main.js +++ b/test/chunking-form/samples/synthetic-named-exports/entry/_expected/amd/generated-main.js @@ -1,4 +1,4 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; const exists = 'exists'; const __synthetic = { synthetic: 'synthetic' }; @@ -6,4 +6,4 @@ define(['exports'], function (exports) { 'use strict'; exports.__synthetic = __synthetic; exports.exists = exists; -}); +})); diff --git a/test/chunking-form/samples/synthetic-named-exports/entry/_expected/amd/main.js b/test/chunking-form/samples/synthetic-named-exports/entry/_expected/amd/main.js index 7fa5260fdb6..140a5f9b811 100644 --- a/test/chunking-form/samples/synthetic-named-exports/entry/_expected/amd/main.js +++ b/test/chunking-form/samples/synthetic-named-exports/entry/_expected/amd/main.js @@ -1,9 +1,7 @@ -define(['exports', './generated-main'], function (exports, main) { 'use strict'; +define(['exports', './generated-main'], (function (exports, main) { 'use strict'; exports.exists = main.exists; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/synthetic-named-exports/entry/_expected/amd/other.js b/test/chunking-form/samples/synthetic-named-exports/entry/_expected/amd/other.js index f743f074f0a..553e6ef3830 100644 --- a/test/chunking-form/samples/synthetic-named-exports/entry/_expected/amd/other.js +++ b/test/chunking-form/samples/synthetic-named-exports/entry/_expected/amd/other.js @@ -1,5 +1,5 @@ -define(['./generated-main'], function (main) { 'use strict'; +define(['./generated-main'], (function (main) { 'use strict'; console.log(main.__synthetic.synthetic); -}); +})); diff --git a/test/chunking-form/samples/synthetic-named-exports/entry/_expected/cjs/main.js b/test/chunking-form/samples/synthetic-named-exports/entry/_expected/cjs/main.js index b940c24073e..65f17c50da2 100644 --- a/test/chunking-form/samples/synthetic-named-exports/entry/_expected/cjs/main.js +++ b/test/chunking-form/samples/synthetic-named-exports/entry/_expected/cjs/main.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - var main = require('./generated-main.js'); diff --git a/test/chunking-form/samples/synthetic-named-exports/entry/_expected/system/generated-main.js b/test/chunking-form/samples/synthetic-named-exports/entry/_expected/system/generated-main.js index 3909d8a990d..cd158178c21 100644 --- a/test/chunking-form/samples/synthetic-named-exports/entry/_expected/system/generated-main.js +++ b/test/chunking-form/samples/synthetic-named-exports/entry/_expected/system/generated-main.js @@ -1,11 +1,11 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - const exists = exports('e', 'exists'); - const __synthetic = exports('_', { synthetic: 'synthetic' }); + const exists = exports("e", 'exists'); + const __synthetic = exports("_", { synthetic: 'synthetic' }); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/synthetic-named-exports/entry/_expected/system/main.js b/test/chunking-form/samples/synthetic-named-exports/entry/_expected/system/main.js index 28a5eaf0dbc..c0a2ee57495 100644 --- a/test/chunking-form/samples/synthetic-named-exports/entry/_expected/system/main.js +++ b/test/chunking-form/samples/synthetic-named-exports/entry/_expected/system/main.js @@ -1,13 +1,13 @@ -System.register(['./generated-main.js'], function (exports) { +System.register(['./generated-main.js'], (function (exports) { 'use strict'; return { setters: [function (module) { - exports('exists', module.e); + exports("exists", module.e); }], - execute: function () { + execute: (function () { - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/synthetic-named-exports/entry/_expected/system/other.js b/test/chunking-form/samples/synthetic-named-exports/entry/_expected/system/other.js index 3fbc52af486..524d4416c9d 100644 --- a/test/chunking-form/samples/synthetic-named-exports/entry/_expected/system/other.js +++ b/test/chunking-form/samples/synthetic-named-exports/entry/_expected/system/other.js @@ -1,14 +1,14 @@ -System.register(['./generated-main.js'], function () { +System.register(['./generated-main.js'], (function () { 'use strict'; var __synthetic; return { setters: [function (module) { __synthetic = module._; }], - execute: function () { + execute: (function () { console.log(__synthetic.synthetic); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/synthetic-named-exports/global-conflict/_config.js b/test/chunking-form/samples/synthetic-named-exports/global-conflict/_config.js index 5848d32b403..d1f812437d6 100644 --- a/test/chunking-form/samples/synthetic-named-exports/global-conflict/_config.js +++ b/test/chunking-form/samples/synthetic-named-exports/global-conflict/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'avoids conflicts with global variables when re-exporting synthetic named exports', options: { plugins: [ @@ -13,4 +13,4 @@ module.exports = { } ] } -}; +}); diff --git a/test/chunking-form/samples/synthetic-named-exports/global-conflict/_expected/amd/main.js b/test/chunking-form/samples/synthetic-named-exports/global-conflict/_expected/amd/main.js index f959819397b..ef1566d4b26 100644 --- a/test/chunking-form/samples/synthetic-named-exports/global-conflict/_expected/amd/main.js +++ b/test/chunking-form/samples/synthetic-named-exports/global-conflict/_expected/amd/main.js @@ -1,4 +1,4 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; var dep = { foo: 'bar' }; // This should log a global variable @@ -6,6 +6,4 @@ define(['exports'], function (exports) { 'use strict'; exports.foo = dep.foo; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/synthetic-named-exports/global-conflict/_expected/cjs/main.js b/test/chunking-form/samples/synthetic-named-exports/global-conflict/_expected/cjs/main.js index 124960daafa..a711eb778e6 100644 --- a/test/chunking-form/samples/synthetic-named-exports/global-conflict/_expected/cjs/main.js +++ b/test/chunking-form/samples/synthetic-named-exports/global-conflict/_expected/cjs/main.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - var dep = { foo: 'bar' }; // This should log a global variable console.log(foo); diff --git a/test/chunking-form/samples/synthetic-named-exports/global-conflict/_expected/system/main.js b/test/chunking-form/samples/synthetic-named-exports/global-conflict/_expected/system/main.js index 87797e647ca..781b6606a61 100644 --- a/test/chunking-form/samples/synthetic-named-exports/global-conflict/_expected/system/main.js +++ b/test/chunking-form/samples/synthetic-named-exports/global-conflict/_expected/system/main.js @@ -1,14 +1,14 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { var dep = { foo: 'bar' }; // This should log a global variable console.log(foo); - exports('foo', dep.foo); + exports("foo", dep.foo); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/synthetic-named-exports/mixed-synthetic-named-exports-2/_config.js b/test/chunking-form/samples/synthetic-named-exports/mixed-synthetic-named-exports-2/_config.js index 9627155afc2..2bfd99aa85f 100644 --- a/test/chunking-form/samples/synthetic-named-exports/mixed-synthetic-named-exports-2/_config.js +++ b/test/chunking-form/samples/synthetic-named-exports/mixed-synthetic-named-exports-2/_config.js @@ -1,9 +1,10 @@ -module.exports = { +module.exports = defineTest({ description: 'mixed synthetic named exports 2', options: { input: ['main.js', 'main2.js'], plugins: [ { + name: 'test-plugin', transform(code, id) { if (id.endsWith('dep1.js') || id.endsWith('dep2.js')) { return { @@ -16,4 +17,4 @@ module.exports = { } ] } -}; +}); diff --git a/test/chunking-form/samples/synthetic-named-exports/mixed-synthetic-named-exports-2/_expected/amd/generated-dep2.js b/test/chunking-form/samples/synthetic-named-exports/mixed-synthetic-named-exports-2/_expected/amd/generated-dep2.js index bf8ce12ad97..dc66d9134bf 100644 --- a/test/chunking-form/samples/synthetic-named-exports/mixed-synthetic-named-exports-2/_expected/amd/generated-dep2.js +++ b/test/chunking-form/samples/synthetic-named-exports/mixed-synthetic-named-exports-2/_expected/amd/generated-dep2.js @@ -1,7 +1,7 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; var dep2 = {bar: {foo: 'works'}}; exports.dep2 = dep2; -}); +})); diff --git a/test/chunking-form/samples/synthetic-named-exports/mixed-synthetic-named-exports-2/_expected/amd/main.js b/test/chunking-form/samples/synthetic-named-exports/mixed-synthetic-named-exports-2/_expected/amd/main.js index d8e2d49a49b..07a5ea7730f 100644 --- a/test/chunking-form/samples/synthetic-named-exports/mixed-synthetic-named-exports-2/_expected/amd/main.js +++ b/test/chunking-form/samples/synthetic-named-exports/mixed-synthetic-named-exports-2/_expected/amd/main.js @@ -1,5 +1,5 @@ -define(['./generated-dep2'], function (dep2) { 'use strict'; +define(['./generated-dep2'], (function (dep2) { 'use strict'; console.log(dep2.dep2.bar.foo); -}); +})); diff --git a/test/chunking-form/samples/synthetic-named-exports/mixed-synthetic-named-exports-2/_expected/amd/main2.js b/test/chunking-form/samples/synthetic-named-exports/mixed-synthetic-named-exports-2/_expected/amd/main2.js index d8e2d49a49b..07a5ea7730f 100644 --- a/test/chunking-form/samples/synthetic-named-exports/mixed-synthetic-named-exports-2/_expected/amd/main2.js +++ b/test/chunking-form/samples/synthetic-named-exports/mixed-synthetic-named-exports-2/_expected/amd/main2.js @@ -1,5 +1,5 @@ -define(['./generated-dep2'], function (dep2) { 'use strict'; +define(['./generated-dep2'], (function (dep2) { 'use strict'; console.log(dep2.dep2.bar.foo); -}); +})); diff --git a/test/chunking-form/samples/synthetic-named-exports/mixed-synthetic-named-exports-2/_expected/system/generated-dep2.js b/test/chunking-form/samples/synthetic-named-exports/mixed-synthetic-named-exports-2/_expected/system/generated-dep2.js index 7b4cb15fbc9..bc2e4a846f5 100644 --- a/test/chunking-form/samples/synthetic-named-exports/mixed-synthetic-named-exports-2/_expected/system/generated-dep2.js +++ b/test/chunking-form/samples/synthetic-named-exports/mixed-synthetic-named-exports-2/_expected/system/generated-dep2.js @@ -1,10 +1,10 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - var dep2 = exports('d', {bar: {foo: 'works'}}); + var dep2 = exports("d", {bar: {foo: 'works'}}); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/synthetic-named-exports/mixed-synthetic-named-exports-2/_expected/system/main.js b/test/chunking-form/samples/synthetic-named-exports/mixed-synthetic-named-exports-2/_expected/system/main.js index db0259f47e2..57904850333 100644 --- a/test/chunking-form/samples/synthetic-named-exports/mixed-synthetic-named-exports-2/_expected/system/main.js +++ b/test/chunking-form/samples/synthetic-named-exports/mixed-synthetic-named-exports-2/_expected/system/main.js @@ -1,14 +1,14 @@ -System.register(['./generated-dep2.js'], function () { +System.register(['./generated-dep2.js'], (function () { 'use strict'; var dep2; return { setters: [function (module) { dep2 = module.d; }], - execute: function () { + execute: (function () { console.log(dep2.bar.foo); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/synthetic-named-exports/mixed-synthetic-named-exports-2/_expected/system/main2.js b/test/chunking-form/samples/synthetic-named-exports/mixed-synthetic-named-exports-2/_expected/system/main2.js index db0259f47e2..57904850333 100644 --- a/test/chunking-form/samples/synthetic-named-exports/mixed-synthetic-named-exports-2/_expected/system/main2.js +++ b/test/chunking-form/samples/synthetic-named-exports/mixed-synthetic-named-exports-2/_expected/system/main2.js @@ -1,14 +1,14 @@ -System.register(['./generated-dep2.js'], function () { +System.register(['./generated-dep2.js'], (function () { 'use strict'; var dep2; return { setters: [function (module) { dep2 = module.d; }], - execute: function () { + execute: (function () { console.log(dep2.bar.foo); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/synthetic-named-exports/mixed-synthetic-named-exports/_config.js b/test/chunking-form/samples/synthetic-named-exports/mixed-synthetic-named-exports/_config.js index b13731d1b7d..c1236b71da2 100644 --- a/test/chunking-form/samples/synthetic-named-exports/mixed-synthetic-named-exports/_config.js +++ b/test/chunking-form/samples/synthetic-named-exports/mixed-synthetic-named-exports/_config.js @@ -1,9 +1,10 @@ -module.exports = { +module.exports = defineTest({ description: 'mixed synthetic named exports', options: { input: ['main.js'], plugins: [ { + name: 'test-plugin', resolveId(id) { if (id.endsWith('dep1.js')) { return { @@ -11,9 +12,8 @@ module.exports = { syntheticNamedExports: true }; } - return null; } } ] } -}; +}); diff --git a/test/chunking-form/samples/synthetic-named-exports/mixed-synthetic-named-exports/_expected/amd/main.js b/test/chunking-form/samples/synthetic-named-exports/mixed-synthetic-named-exports/_expected/amd/main.js index 8186f765ca9..062ec4df971 100644 --- a/test/chunking-form/samples/synthetic-named-exports/mixed-synthetic-named-exports/_expected/amd/main.js +++ b/test/chunking-form/samples/synthetic-named-exports/mixed-synthetic-named-exports/_expected/amd/main.js @@ -1,4 +1,19 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; + + function _mergeNamespaces(n, m) { + m.forEach(function (e) { + e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) { + if (k !== 'default' && !(k in n)) { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + }); + return Object.freeze(n); + } const d = { fn: 42, @@ -6,10 +21,11 @@ define(['exports'], function (exports) { 'use strict'; }; const foo = 100; - var ns = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.assign(/*#__PURE__*/Object.create(null), d, { - foo: foo, - 'default': d - })); + var ns = /*#__PURE__*/_mergeNamespaces({ + __proto__: null, + default: d, + foo: foo + }, [d]); const stuff = 12; console.log(stuff); @@ -22,6 +38,4 @@ define(['exports'], function (exports) { 'use strict'; exports.foo = foo; exports.stuff = d.stuff; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/synthetic-named-exports/mixed-synthetic-named-exports/_expected/cjs/main.js b/test/chunking-form/samples/synthetic-named-exports/mixed-synthetic-named-exports/_expected/cjs/main.js index 07b00cddba6..49318bf8562 100644 --- a/test/chunking-form/samples/synthetic-named-exports/mixed-synthetic-named-exports/_expected/cjs/main.js +++ b/test/chunking-form/samples/synthetic-named-exports/mixed-synthetic-named-exports/_expected/cjs/main.js @@ -1,6 +1,19 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); +function _mergeNamespaces(n, m) { + m.forEach(function (e) { + e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) { + if (k !== 'default' && !(k in n)) { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + }); + return Object.freeze(n); +} const d = { fn: 42, @@ -8,10 +21,11 @@ const d = { }; const foo = 100; -var ns = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.assign(/*#__PURE__*/Object.create(null), d, { - foo: foo, - 'default': d -})); +var ns = /*#__PURE__*/_mergeNamespaces({ + __proto__: null, + default: d, + foo: foo +}, [d]); const stuff = 12; console.log(stuff); diff --git a/test/chunking-form/samples/synthetic-named-exports/mixed-synthetic-named-exports/_expected/es/main.js b/test/chunking-form/samples/synthetic-named-exports/mixed-synthetic-named-exports/_expected/es/main.js index a9a0d834108..9ba08160665 100644 --- a/test/chunking-form/samples/synthetic-named-exports/mixed-synthetic-named-exports/_expected/es/main.js +++ b/test/chunking-form/samples/synthetic-named-exports/mixed-synthetic-named-exports/_expected/es/main.js @@ -1,13 +1,29 @@ +function _mergeNamespaces(n, m) { + m.forEach(function (e) { + e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) { + if (k !== 'default' && !(k in n)) { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + }); + return Object.freeze(n); +} + const d = { fn: 42, hello: 'hola' }; const foo = 100; -var ns = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.assign(/*#__PURE__*/Object.create(null), d, { - foo: foo, - 'default': d -})); +var ns = /*#__PURE__*/_mergeNamespaces({ + __proto__: null, + default: d, + foo: foo +}, [d]); const stuff = 12; console.log(stuff); diff --git a/test/chunking-form/samples/synthetic-named-exports/mixed-synthetic-named-exports/_expected/system/main.js b/test/chunking-form/samples/synthetic-named-exports/mixed-synthetic-named-exports/_expected/system/main.js index 01f53a09d05..b26bbadfc5a 100644 --- a/test/chunking-form/samples/synthetic-named-exports/mixed-synthetic-named-exports/_expected/system/main.js +++ b/test/chunking-form/samples/synthetic-named-exports/mixed-synthetic-named-exports/_expected/system/main.js @@ -1,18 +1,34 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { + + function _mergeNamespaces(n, m) { + m.forEach(function (e) { + e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) { + if (k !== 'default' && !(k in n)) { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + }); + return Object.freeze(n); + } const d = { fn: 42, hello: 'hola' }; - const foo = exports('foo', 100); + const foo = exports("foo", 100); - var ns = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.assign(/*#__PURE__*/Object.create(null), d, { - foo: foo, - 'default': d - })); + var ns = /*#__PURE__*/_mergeNamespaces({ + __proto__: null, + default: d, + foo: foo + }, [d]); const stuff = 12; console.log(stuff); @@ -26,6 +42,6 @@ System.register([], function (exports) { stuff: d.stuff }); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/synthetic-named-exports/multi-level/_config.js b/test/chunking-form/samples/synthetic-named-exports/multi-level/_config.js index 428b9202e06..ca7cb93658c 100644 --- a/test/chunking-form/samples/synthetic-named-exports/multi-level/_config.js +++ b/test/chunking-form/samples/synthetic-named-exports/multi-level/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'handles multiple levels of synthetic named exports', options: { input: ['main.js', 'main2.js', 'main3.js', 'main4.js', 'main5.js'], @@ -14,4 +14,4 @@ module.exports = { } ] } -}; +}); diff --git a/test/chunking-form/samples/synthetic-named-exports/multi-level/_expected/amd/main.js b/test/chunking-form/samples/synthetic-named-exports/multi-level/_expected/amd/main.js index 5345ab01ede..6d3cf0f170f 100644 --- a/test/chunking-form/samples/synthetic-named-exports/multi-level/_expected/amd/main.js +++ b/test/chunking-form/samples/synthetic-named-exports/multi-level/_expected/amd/main.js @@ -1,7 +1,7 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; var main = { one: { two: { three: { four: 42 } } } }; return main; -}); +})); diff --git a/test/chunking-form/samples/synthetic-named-exports/multi-level/_expected/amd/main2.js b/test/chunking-form/samples/synthetic-named-exports/multi-level/_expected/amd/main2.js index 69d6be24e95..60eff4045aa 100644 --- a/test/chunking-form/samples/synthetic-named-exports/multi-level/_expected/amd/main2.js +++ b/test/chunking-form/samples/synthetic-named-exports/multi-level/_expected/amd/main2.js @@ -1,7 +1,7 @@ -define(['./main'], function (main) { 'use strict'; +define(['./main'], (function (main) { 'use strict'; return main.one; -}); +})); diff --git a/test/chunking-form/samples/synthetic-named-exports/multi-level/_expected/amd/main3.js b/test/chunking-form/samples/synthetic-named-exports/multi-level/_expected/amd/main3.js index ddd801950f3..a01f17ba912 100644 --- a/test/chunking-form/samples/synthetic-named-exports/multi-level/_expected/amd/main3.js +++ b/test/chunking-form/samples/synthetic-named-exports/multi-level/_expected/amd/main3.js @@ -1,7 +1,7 @@ -define(['./main'], function (main) { 'use strict'; +define(['./main'], (function (main) { 'use strict'; return main.one.two; -}); +})); diff --git a/test/chunking-form/samples/synthetic-named-exports/multi-level/_expected/amd/main4.js b/test/chunking-form/samples/synthetic-named-exports/multi-level/_expected/amd/main4.js index 571fd05288e..62899f0bf21 100644 --- a/test/chunking-form/samples/synthetic-named-exports/multi-level/_expected/amd/main4.js +++ b/test/chunking-form/samples/synthetic-named-exports/multi-level/_expected/amd/main4.js @@ -1,7 +1,7 @@ -define(['./main'], function (main) { 'use strict'; +define(['./main'], (function (main) { 'use strict'; return main.one.two.three; -}); +})); diff --git a/test/chunking-form/samples/synthetic-named-exports/multi-level/_expected/amd/main5.js b/test/chunking-form/samples/synthetic-named-exports/multi-level/_expected/amd/main5.js index a57fdf1e8a9..d16a82459c2 100644 --- a/test/chunking-form/samples/synthetic-named-exports/multi-level/_expected/amd/main5.js +++ b/test/chunking-form/samples/synthetic-named-exports/multi-level/_expected/amd/main5.js @@ -1,7 +1,7 @@ -define(['./main'], function (main) { 'use strict'; +define(['./main'], (function (main) { 'use strict'; return main.one.two.three.four; -}); +})); diff --git a/test/chunking-form/samples/synthetic-named-exports/multi-level/_expected/es/main.js b/test/chunking-form/samples/synthetic-named-exports/multi-level/_expected/es/main.js index e8e776d75c4..98f55136a53 100644 --- a/test/chunking-form/samples/synthetic-named-exports/multi-level/_expected/es/main.js +++ b/test/chunking-form/samples/synthetic-named-exports/multi-level/_expected/es/main.js @@ -1,3 +1,3 @@ var main = { one: { two: { three: { four: 42 } } } }; -export default main; +export { main as default }; diff --git a/test/chunking-form/samples/synthetic-named-exports/multi-level/_expected/es/main2.js b/test/chunking-form/samples/synthetic-named-exports/multi-level/_expected/es/main2.js index 90a5c6eebb0..b2f465ad1c0 100644 --- a/test/chunking-form/samples/synthetic-named-exports/multi-level/_expected/es/main2.js +++ b/test/chunking-form/samples/synthetic-named-exports/multi-level/_expected/es/main2.js @@ -2,4 +2,5 @@ import main from './main.js'; -export default main.one; +var one = main.one; +export { one as default }; diff --git a/test/chunking-form/samples/synthetic-named-exports/multi-level/_expected/es/main3.js b/test/chunking-form/samples/synthetic-named-exports/multi-level/_expected/es/main3.js index f9bb1e916dc..9726b0aadd9 100644 --- a/test/chunking-form/samples/synthetic-named-exports/multi-level/_expected/es/main3.js +++ b/test/chunking-form/samples/synthetic-named-exports/multi-level/_expected/es/main3.js @@ -2,4 +2,5 @@ import main from './main.js'; -export default main.one.two; +var two = main.one.two; +export { two as default }; diff --git a/test/chunking-form/samples/synthetic-named-exports/multi-level/_expected/es/main4.js b/test/chunking-form/samples/synthetic-named-exports/multi-level/_expected/es/main4.js index 1a9f5e0da78..03300653ad4 100644 --- a/test/chunking-form/samples/synthetic-named-exports/multi-level/_expected/es/main4.js +++ b/test/chunking-form/samples/synthetic-named-exports/multi-level/_expected/es/main4.js @@ -2,4 +2,5 @@ import main from './main.js'; -export default main.one.two.three; +var three = main.one.two.three; +export { three as default }; diff --git a/test/chunking-form/samples/synthetic-named-exports/multi-level/_expected/es/main5.js b/test/chunking-form/samples/synthetic-named-exports/multi-level/_expected/es/main5.js index 03ca87e27a3..d3e85222f17 100644 --- a/test/chunking-form/samples/synthetic-named-exports/multi-level/_expected/es/main5.js +++ b/test/chunking-form/samples/synthetic-named-exports/multi-level/_expected/es/main5.js @@ -2,4 +2,5 @@ import main from './main.js'; -export default main.one.two.three.four; +var four = main.one.two.three.four; +export { four as default }; diff --git a/test/chunking-form/samples/synthetic-named-exports/multi-level/_expected/system/main.js b/test/chunking-form/samples/synthetic-named-exports/multi-level/_expected/system/main.js index 99003e9f1e9..f7ab8942733 100644 --- a/test/chunking-form/samples/synthetic-named-exports/multi-level/_expected/system/main.js +++ b/test/chunking-form/samples/synthetic-named-exports/multi-level/_expected/system/main.js @@ -1,10 +1,10 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - var main = exports('default', { one: { two: { three: { four: 42 } } } }); + var main = exports("default", { one: { two: { three: { four: 42 } } } }); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/synthetic-named-exports/multi-level/_expected/system/main2.js b/test/chunking-form/samples/synthetic-named-exports/multi-level/_expected/system/main2.js index 9b5ce5eb807..0cc3d51e8ab 100644 --- a/test/chunking-form/samples/synthetic-named-exports/multi-level/_expected/system/main2.js +++ b/test/chunking-form/samples/synthetic-named-exports/multi-level/_expected/system/main2.js @@ -1,16 +1,16 @@ -System.register(['./main.js'], function (exports) { +System.register(['./main.js'], (function (exports) { 'use strict'; var main; return { setters: [function (module) { main = module.default; }], - execute: function () { + execute: (function () { - exports('default', main.one); + exports("default", main.one); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/synthetic-named-exports/multi-level/_expected/system/main3.js b/test/chunking-form/samples/synthetic-named-exports/multi-level/_expected/system/main3.js index 6fac0bfa41b..b1d140208cb 100644 --- a/test/chunking-form/samples/synthetic-named-exports/multi-level/_expected/system/main3.js +++ b/test/chunking-form/samples/synthetic-named-exports/multi-level/_expected/system/main3.js @@ -1,16 +1,16 @@ -System.register(['./main.js'], function (exports) { +System.register(['./main.js'], (function (exports) { 'use strict'; var main; return { setters: [function (module) { main = module.default; }], - execute: function () { + execute: (function () { - exports('default', main.one.two); + exports("default", main.one.two); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/synthetic-named-exports/multi-level/_expected/system/main4.js b/test/chunking-form/samples/synthetic-named-exports/multi-level/_expected/system/main4.js index cd109a5c27d..1f795f41013 100644 --- a/test/chunking-form/samples/synthetic-named-exports/multi-level/_expected/system/main4.js +++ b/test/chunking-form/samples/synthetic-named-exports/multi-level/_expected/system/main4.js @@ -1,16 +1,16 @@ -System.register(['./main.js'], function (exports) { +System.register(['./main.js'], (function (exports) { 'use strict'; var main; return { setters: [function (module) { main = module.default; }], - execute: function () { + execute: (function () { - exports('default', main.one.two.three); + exports("default", main.one.two.three); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/synthetic-named-exports/multi-level/_expected/system/main5.js b/test/chunking-form/samples/synthetic-named-exports/multi-level/_expected/system/main5.js index 20e0cef2195..28523ef9fce 100644 --- a/test/chunking-form/samples/synthetic-named-exports/multi-level/_expected/system/main5.js +++ b/test/chunking-form/samples/synthetic-named-exports/multi-level/_expected/system/main5.js @@ -1,16 +1,16 @@ -System.register(['./main.js'], function (exports) { +System.register(['./main.js'], (function (exports) { 'use strict'; var main; return { setters: [function (module) { main = module.default; }], - execute: function () { + execute: (function () { - exports('default', main.one.two.three.four); + exports("default", main.one.two.three.four); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/synthetic-named-exports/namespace/_config.js b/test/chunking-form/samples/synthetic-named-exports/namespace/_config.js index cfc5383d876..3882d278781 100644 --- a/test/chunking-form/samples/synthetic-named-exports/namespace/_config.js +++ b/test/chunking-form/samples/synthetic-named-exports/namespace/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'supports re-exported synthetic exports in namespace objects', options: { plugins: [ @@ -15,4 +15,4 @@ module.exports = { } ] } -}; +}); diff --git a/test/chunking-form/samples/synthetic-named-exports/namespace/_expected/amd/main.js b/test/chunking-form/samples/synthetic-named-exports/namespace/_expected/amd/main.js index a7cc7e7dc2c..e9620337aec 100644 --- a/test/chunking-form/samples/synthetic-named-exports/namespace/_expected/amd/main.js +++ b/test/chunking-form/samples/synthetic-named-exports/namespace/_expected/amd/main.js @@ -1,4 +1,19 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; + + function _mergeNamespaces(n, m) { + m.forEach(function (e) { + e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) { + if (k !== 'default' && !(k in n)) { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + }); + return Object.freeze(n); + } var synthetic = { foo: 'synthetic-foo', @@ -8,23 +23,23 @@ define(['exports'], function (exports) { 'use strict'; }; const foo = 'foo'; - var synthetic$1 = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.assign(/*#__PURE__*/Object.create(null), synthetic, { - 'default': synthetic, + var synthetic$1 = /*#__PURE__*/_mergeNamespaces({ + __proto__: null, + default: synthetic, foo: foo - })); + }, [synthetic]); const bar = 'bar'; var dep = 'not-overwritten'; - var dep$1 = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.assign(/*#__PURE__*/Object.create(null), synthetic, { + var dep$1 = /*#__PURE__*/_mergeNamespaces({ + __proto__: null, bar: bar, - 'default': dep, - synthetic: synthetic$1, - foo: foo - })); + default: dep, + foo: foo, + synthetic: synthetic$1 + }, [synthetic]); exports.dep = dep$1; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/chunking-form/samples/synthetic-named-exports/namespace/_expected/cjs/main.js b/test/chunking-form/samples/synthetic-named-exports/namespace/_expected/cjs/main.js index a15bddf8416..fdd5569d9d8 100644 --- a/test/chunking-form/samples/synthetic-named-exports/namespace/_expected/cjs/main.js +++ b/test/chunking-form/samples/synthetic-named-exports/namespace/_expected/cjs/main.js @@ -1,6 +1,19 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); +function _mergeNamespaces(n, m) { + m.forEach(function (e) { + e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) { + if (k !== 'default' && !(k in n)) { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + }); + return Object.freeze(n); +} var synthetic = { foo: 'synthetic-foo', @@ -10,19 +23,21 @@ var synthetic = { }; const foo = 'foo'; -var synthetic$1 = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.assign(/*#__PURE__*/Object.create(null), synthetic, { - 'default': synthetic, +var synthetic$1 = /*#__PURE__*/_mergeNamespaces({ + __proto__: null, + default: synthetic, foo: foo -})); +}, [synthetic]); const bar = 'bar'; var dep = 'not-overwritten'; -var dep$1 = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.assign(/*#__PURE__*/Object.create(null), synthetic, { +var dep$1 = /*#__PURE__*/_mergeNamespaces({ + __proto__: null, bar: bar, - 'default': dep, - synthetic: synthetic$1, - foo: foo -})); + default: dep, + foo: foo, + synthetic: synthetic$1 +}, [synthetic]); exports.dep = dep$1; diff --git a/test/chunking-form/samples/synthetic-named-exports/namespace/_expected/es/main.js b/test/chunking-form/samples/synthetic-named-exports/namespace/_expected/es/main.js index 4868b649580..617525cacc8 100644 --- a/test/chunking-form/samples/synthetic-named-exports/namespace/_expected/es/main.js +++ b/test/chunking-form/samples/synthetic-named-exports/namespace/_expected/es/main.js @@ -1,3 +1,18 @@ +function _mergeNamespaces(n, m) { + m.forEach(function (e) { + e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) { + if (k !== 'default' && !(k in n)) { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + }); + return Object.freeze(n); +} + var synthetic = { foo: 'synthetic-foo', bar: 'synthetic-bar', @@ -6,19 +21,21 @@ var synthetic = { }; const foo = 'foo'; -var synthetic$1 = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.assign(/*#__PURE__*/Object.create(null), synthetic, { - 'default': synthetic, +var synthetic$1 = /*#__PURE__*/_mergeNamespaces({ + __proto__: null, + default: synthetic, foo: foo -})); +}, [synthetic]); const bar = 'bar'; var dep = 'not-overwritten'; -var dep$1 = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.assign(/*#__PURE__*/Object.create(null), synthetic, { +var dep$1 = /*#__PURE__*/_mergeNamespaces({ + __proto__: null, bar: bar, - 'default': dep, - synthetic: synthetic$1, - foo: foo -})); + default: dep, + foo: foo, + synthetic: synthetic$1 +}, [synthetic]); export { dep$1 as dep }; diff --git a/test/chunking-form/samples/synthetic-named-exports/namespace/_expected/system/main.js b/test/chunking-form/samples/synthetic-named-exports/namespace/_expected/system/main.js index 42195788910..6f0f249e1d2 100644 --- a/test/chunking-form/samples/synthetic-named-exports/namespace/_expected/system/main.js +++ b/test/chunking-form/samples/synthetic-named-exports/namespace/_expected/system/main.js @@ -1,7 +1,22 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { + + function _mergeNamespaces(n, m) { + m.forEach(function (e) { + e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) { + if (k !== 'default' && !(k in n)) { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + }); + return Object.freeze(n); + } var synthetic = { foo: 'synthetic-foo', @@ -11,22 +26,24 @@ System.register([], function (exports) { }; const foo = 'foo'; - var synthetic$1 = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.assign(/*#__PURE__*/Object.create(null), synthetic, { - 'default': synthetic, + var synthetic$1 = /*#__PURE__*/_mergeNamespaces({ + __proto__: null, + default: synthetic, foo: foo - })); + }, [synthetic]); const bar = 'bar'; var dep = 'not-overwritten'; - var dep$1 = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.assign(/*#__PURE__*/Object.create(null), synthetic, { + var dep$1 = /*#__PURE__*/_mergeNamespaces({ + __proto__: null, bar: bar, - 'default': dep, - synthetic: synthetic$1, - foo: foo - })); - exports('dep', dep$1); + default: dep, + foo: foo, + synthetic: synthetic$1 + }, [synthetic]); + exports("dep", dep$1); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/system-exports-wrap-pure-annotation/_config.js b/test/chunking-form/samples/system-exports-wrap-pure-annotation/_config.js index 61cb9b863f7..ccde3427005 100644 --- a/test/chunking-form/samples/system-exports-wrap-pure-annotation/_config.js +++ b/test/chunking-form/samples/system-exports-wrap-pure-annotation/_config.js @@ -1,6 +1,6 @@ -module.exports = { +module.exports = defineTest({ description: 'system exports should wrap pure annotations', options: { - input: ['main1.js', 'main2.js'], + input: ['main1.js', 'main2.js'] } -}; +}); diff --git a/test/chunking-form/samples/system-exports-wrap-pure-annotation/_expected/amd/generated-dep.js b/test/chunking-form/samples/system-exports-wrap-pure-annotation/_expected/amd/generated-dep.js index e36aa892fc7..7094abf1a7d 100644 --- a/test/chunking-form/samples/system-exports-wrap-pure-annotation/_expected/amd/generated-dep.js +++ b/test/chunking-form/samples/system-exports-wrap-pure-annotation/_expected/amd/generated-dep.js @@ -1,4 +1,4 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; var dep = /*#__PURE__*/ @@ -8,4 +8,4 @@ define(['exports'], function (exports) { 'use strict'; exports.dep = dep; -}); +})); diff --git a/test/chunking-form/samples/system-exports-wrap-pure-annotation/_expected/amd/main1.js b/test/chunking-form/samples/system-exports-wrap-pure-annotation/_expected/amd/main1.js index 70e8b91dfca..b7799b3983b 100644 --- a/test/chunking-form/samples/system-exports-wrap-pure-annotation/_expected/amd/main1.js +++ b/test/chunking-form/samples/system-exports-wrap-pure-annotation/_expected/amd/main1.js @@ -1,5 +1,5 @@ -define(['./generated-dep'], function (dep) { 'use strict'; +define(['./generated-dep'], (function (dep) { 'use strict'; console.log('1', dep.dep); -}); +})); diff --git a/test/chunking-form/samples/system-exports-wrap-pure-annotation/_expected/amd/main2.js b/test/chunking-form/samples/system-exports-wrap-pure-annotation/_expected/amd/main2.js index 16bc0f7b408..84fb4390b6f 100644 --- a/test/chunking-form/samples/system-exports-wrap-pure-annotation/_expected/amd/main2.js +++ b/test/chunking-form/samples/system-exports-wrap-pure-annotation/_expected/amd/main2.js @@ -1,5 +1,5 @@ -define(['./generated-dep'], function (dep) { 'use strict'; +define(['./generated-dep'], (function (dep) { 'use strict'; console.log('2', dep.dep); -}); +})); diff --git a/test/chunking-form/samples/system-exports-wrap-pure-annotation/_expected/system/generated-dep.js b/test/chunking-form/samples/system-exports-wrap-pure-annotation/_expected/system/generated-dep.js index ed1f2e46e86..886a6b7a6ed 100644 --- a/test/chunking-form/samples/system-exports-wrap-pure-annotation/_expected/system/generated-dep.js +++ b/test/chunking-form/samples/system-exports-wrap-pure-annotation/_expected/system/generated-dep.js @@ -1,14 +1,14 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { var dep = - exports('d', /*#__PURE__*/ + exports("d", /*#__PURE__*/ (function() { return 0; })()); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/system-exports-wrap-pure-annotation/_expected/system/main1.js b/test/chunking-form/samples/system-exports-wrap-pure-annotation/_expected/system/main1.js index 8daf064dae0..9024cabcf1f 100644 --- a/test/chunking-form/samples/system-exports-wrap-pure-annotation/_expected/system/main1.js +++ b/test/chunking-form/samples/system-exports-wrap-pure-annotation/_expected/system/main1.js @@ -1,14 +1,14 @@ -System.register(['./generated-dep.js'], function () { +System.register(['./generated-dep.js'], (function () { 'use strict'; var dep; return { setters: [function (module) { dep = module.d; }], - execute: function () { + execute: (function () { console.log('1', dep); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/system-exports-wrap-pure-annotation/_expected/system/main2.js b/test/chunking-form/samples/system-exports-wrap-pure-annotation/_expected/system/main2.js index 23664a93e78..b3ce5d94b99 100644 --- a/test/chunking-form/samples/system-exports-wrap-pure-annotation/_expected/system/main2.js +++ b/test/chunking-form/samples/system-exports-wrap-pure-annotation/_expected/system/main2.js @@ -1,14 +1,14 @@ -System.register(['./generated-dep.js'], function () { +System.register(['./generated-dep.js'], (function () { 'use strict'; var dep; return { setters: [function (module) { dep = module.d; }], - execute: function () { + execute: (function () { console.log('2', dep); - } + }) }; -}); +})); diff --git a/test/chunking-form/samples/top-level-await-import-2/_config.js b/test/chunking-form/samples/top-level-await-import-2/_config.js new file mode 100644 index 00000000000..f67247ce954 --- /dev/null +++ b/test/chunking-form/samples/top-level-await-import-2/_config.js @@ -0,0 +1,5 @@ +module.exports = defineTest({ + description: + 'avoiding circular TLA dynamic imports between chunks even with TLA dynamic imports in non-entry modules', + formats: ['es', 'system'] +}); diff --git a/test/chunking-form/samples/top-level-await-import-2/_expected/es/generated-foo-prefix.js b/test/chunking-form/samples/top-level-await-import-2/_expected/es/generated-foo-prefix.js new file mode 100644 index 00000000000..64f05f95d40 --- /dev/null +++ b/test/chunking-form/samples/top-level-await-import-2/_expected/es/generated-foo-prefix.js @@ -0,0 +1,3 @@ +const fooPrefix = 'fooPrefix'; + +export { fooPrefix as f }; diff --git a/test/chunking-form/samples/top-level-await-import-2/_expected/es/generated-foo.js b/test/chunking-form/samples/top-level-await-import-2/_expected/es/generated-foo.js new file mode 100644 index 00000000000..d30cac4b519 --- /dev/null +++ b/test/chunking-form/samples/top-level-await-import-2/_expected/es/generated-foo.js @@ -0,0 +1,5 @@ +import { f as fooPrefix } from './generated-foo-prefix.js'; + +const foo = fooPrefix + 'foo'; + +export { foo }; diff --git a/test/chunking-form/samples/top-level-await-import-2/_expected/es/main.js b/test/chunking-form/samples/top-level-await-import-2/_expected/es/main.js new file mode 100644 index 00000000000..9010b0c2533 --- /dev/null +++ b/test/chunking-form/samples/top-level-await-import-2/_expected/es/main.js @@ -0,0 +1,9 @@ +import { f as fooPrefix } from './generated-foo-prefix.js'; + +const { foo } = await import('./generated-foo.js'); + +function getFoo() { + return unknownFlag ? foo : fooPrefix; +} + +console.log(getFoo()); diff --git a/test/chunking-form/samples/top-level-await-import-2/_expected/system/generated-foo-prefix.js b/test/chunking-form/samples/top-level-await-import-2/_expected/system/generated-foo-prefix.js new file mode 100644 index 00000000000..385edc6bbc0 --- /dev/null +++ b/test/chunking-form/samples/top-level-await-import-2/_expected/system/generated-foo-prefix.js @@ -0,0 +1,10 @@ +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + + const fooPrefix = exports("f", 'fooPrefix'); + + }) + }; +})); diff --git a/test/chunking-form/samples/top-level-await-import-2/_expected/system/generated-foo.js b/test/chunking-form/samples/top-level-await-import-2/_expected/system/generated-foo.js new file mode 100644 index 00000000000..760d65652e7 --- /dev/null +++ b/test/chunking-form/samples/top-level-await-import-2/_expected/system/generated-foo.js @@ -0,0 +1,14 @@ +System.register(['./generated-foo-prefix.js'], (function (exports) { + 'use strict'; + var fooPrefix; + return { + setters: [function (module) { + fooPrefix = module.f; + }], + execute: (function () { + + const foo = exports("foo", fooPrefix + 'foo'); + + }) + }; +})); diff --git a/test/chunking-form/samples/top-level-await-import-2/_expected/system/main.js b/test/chunking-form/samples/top-level-await-import-2/_expected/system/main.js new file mode 100644 index 00000000000..4614f6a9ca4 --- /dev/null +++ b/test/chunking-form/samples/top-level-await-import-2/_expected/system/main.js @@ -0,0 +1,20 @@ +System.register(['./generated-foo-prefix.js'], (function (exports, module) { + 'use strict'; + var fooPrefix; + return { + setters: [function (module) { + fooPrefix = module.f; + }], + execute: (async function () { + + const { foo } = await module.import('./generated-foo.js'); + + function getFoo() { + return unknownFlag ? foo : fooPrefix; + } + + console.log(getFoo()); + + }) + }; +})); diff --git a/test/chunking-form/samples/top-level-await-import-2/foo-prefix.js b/test/chunking-form/samples/top-level-await-import-2/foo-prefix.js new file mode 100644 index 00000000000..4516a8a67b5 --- /dev/null +++ b/test/chunking-form/samples/top-level-await-import-2/foo-prefix.js @@ -0,0 +1 @@ +export const fooPrefix = 'fooPrefix'; diff --git a/test/chunking-form/samples/top-level-await-import-2/foo.js b/test/chunking-form/samples/top-level-await-import-2/foo.js new file mode 100644 index 00000000000..d41533ee21c --- /dev/null +++ b/test/chunking-form/samples/top-level-await-import-2/foo.js @@ -0,0 +1,2 @@ +import { fooPrefix } from './foo-prefix.js'; +export const foo = fooPrefix + 'foo'; diff --git a/test/chunking-form/samples/top-level-await-import-2/lib.js b/test/chunking-form/samples/top-level-await-import-2/lib.js new file mode 100644 index 00000000000..eefccecfa11 --- /dev/null +++ b/test/chunking-form/samples/top-level-await-import-2/lib.js @@ -0,0 +1,7 @@ +import { fooPrefix } from './foo-prefix.js'; + +const { foo } = await import('./foo.js'); + +export function getFoo() { + return unknownFlag ? foo : fooPrefix; +} diff --git a/test/chunking-form/samples/top-level-await-import-2/main.js b/test/chunking-form/samples/top-level-await-import-2/main.js new file mode 100644 index 00000000000..1cf981a7edb --- /dev/null +++ b/test/chunking-form/samples/top-level-await-import-2/main.js @@ -0,0 +1,3 @@ +import { getFoo } from './lib.js'; + +console.log(getFoo()); diff --git a/test/chunking-form/samples/top-level-await-import-3/_config.js b/test/chunking-form/samples/top-level-await-import-3/_config.js new file mode 100644 index 00000000000..9511e658a3b --- /dev/null +++ b/test/chunking-form/samples/top-level-await-import-3/_config.js @@ -0,0 +1,5 @@ +module.exports = defineTest({ + description: + 'avoids circular TLA dynamic imports between chunks even when import is wrapped in a function', + formats: ['es', 'system'] +}); diff --git a/test/chunking-form/samples/top-level-await-import-3/_expected/es/generated-maths.js b/test/chunking-form/samples/top-level-await-import-3/_expected/es/generated-maths.js new file mode 100644 index 00000000000..81e0ed6a524 --- /dev/null +++ b/test/chunking-form/samples/top-level-await-import-3/_expected/es/generated-maths.js @@ -0,0 +1,5 @@ +import { s as square } from './generated-square.js'; + +const cube = x => square(x) * x; + +export { cube, square }; diff --git a/test/chunking-form/samples/top-level-await-import-3/_expected/es/generated-square.js b/test/chunking-form/samples/top-level-await-import-3/_expected/es/generated-square.js new file mode 100644 index 00000000000..93a77e3f2cf --- /dev/null +++ b/test/chunking-form/samples/top-level-await-import-3/_expected/es/generated-square.js @@ -0,0 +1,3 @@ +var square = x => x * x; + +export { square as s }; diff --git a/test/chunking-form/samples/top-level-await-import-3/_expected/es/main.js b/test/chunking-form/samples/top-level-await-import-3/_expected/es/main.js new file mode 100644 index 00000000000..7642a418741 --- /dev/null +++ b/test/chunking-form/samples/top-level-await-import-3/_expected/es/main.js @@ -0,0 +1,10 @@ +import { s as square } from './generated-square.js'; + +async function doMaths() { + const maths = await import('./generated-maths.js'); + assert.equal(maths.square(5), 25); + assert.equal(maths.cube(5), 125); +} + +assert.equal(square(2), 4); +await doMaths(); diff --git a/test/chunking-form/samples/top-level-await-import-3/_expected/system/generated-maths.js b/test/chunking-form/samples/top-level-await-import-3/_expected/system/generated-maths.js new file mode 100644 index 00000000000..aaacbc6e3c5 --- /dev/null +++ b/test/chunking-form/samples/top-level-await-import-3/_expected/system/generated-maths.js @@ -0,0 +1,15 @@ +System.register(['./generated-square.js'], (function (exports) { + 'use strict'; + var square; + return { + setters: [function (module) { + square = module.s; + exports("square", module.s); + }], + execute: (function () { + + const cube = exports("cube", x => square(x) * x); + + }) + }; +})); diff --git a/test/chunking-form/samples/top-level-await-import-3/_expected/system/generated-square.js b/test/chunking-form/samples/top-level-await-import-3/_expected/system/generated-square.js new file mode 100644 index 00000000000..2832c48e393 --- /dev/null +++ b/test/chunking-form/samples/top-level-await-import-3/_expected/system/generated-square.js @@ -0,0 +1,10 @@ +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + + var square = exports("s", x => x * x); + + }) + }; +})); diff --git a/test/chunking-form/samples/top-level-await-import-3/_expected/system/main.js b/test/chunking-form/samples/top-level-await-import-3/_expected/system/main.js new file mode 100644 index 00000000000..b58bf06c2cb --- /dev/null +++ b/test/chunking-form/samples/top-level-await-import-3/_expected/system/main.js @@ -0,0 +1,21 @@ +System.register(['./generated-square.js'], (function (exports, module) { + 'use strict'; + var square; + return { + setters: [function (module) { + square = module.s; + }], + execute: (async function () { + + async function doMaths() { + const maths = await module.import('./generated-maths.js'); + assert.equal(maths.square(5), 25); + assert.equal(maths.cube(5), 125); + } + + assert.equal(square(2), 4); + await doMaths(); + + }) + }; +})); diff --git a/test/chunking-form/samples/top-level-await-import-3/main.js b/test/chunking-form/samples/top-level-await-import-3/main.js new file mode 100644 index 00000000000..cd634f22491 --- /dev/null +++ b/test/chunking-form/samples/top-level-await-import-3/main.js @@ -0,0 +1,10 @@ +import square from './square.js'; + +async function doMaths() { + const maths = await import('./maths.js'); + assert.equal(maths.square(5), 25); + assert.equal(maths.cube(5), 125); +} + +assert.equal(square(2), 4); +await doMaths(); diff --git a/test/chunking-form/samples/top-level-await-import-3/maths.js b/test/chunking-form/samples/top-level-await-import-3/maths.js new file mode 100644 index 00000000000..f2197ae0d34 --- /dev/null +++ b/test/chunking-form/samples/top-level-await-import-3/maths.js @@ -0,0 +1,5 @@ +import square from './square.js'; + +export { default as square } from './square.js'; + +export const cube = x => square(x) * x; diff --git a/test/chunking-form/samples/top-level-await-import-3/square.js b/test/chunking-form/samples/top-level-await-import-3/square.js new file mode 100644 index 00000000000..0a59f351b4d --- /dev/null +++ b/test/chunking-form/samples/top-level-await-import-3/square.js @@ -0,0 +1 @@ +export default x => x * x; diff --git a/test/chunking-form/samples/top-level-await-import-mixed/_config.js b/test/chunking-form/samples/top-level-await-import-mixed/_config.js new file mode 100644 index 00000000000..28776a09a26 --- /dev/null +++ b/test/chunking-form/samples/top-level-await-import-mixed/_config.js @@ -0,0 +1,4 @@ +module.exports = defineTest({ + description: 'avoiding top-level await critical path for chunks', + formats: ['es', 'system'] +}); diff --git a/test/chunking-form/samples/top-level-await-import-mixed/_expected/es/generated-lib-used.js b/test/chunking-form/samples/top-level-await-import-mixed/_expected/es/generated-lib-used.js new file mode 100644 index 00000000000..5753546d3f3 --- /dev/null +++ b/test/chunking-form/samples/top-level-await-import-mixed/_expected/es/generated-lib-used.js @@ -0,0 +1,7 @@ +import { g as getInfo } from './generated-lib.js'; + +function getInfoWithUsed() { + return getInfo() + '_used'; +} + +export { getInfoWithUsed }; diff --git a/test/chunking-form/samples/top-level-await-import-mixed/_expected/es/generated-lib-variant.js b/test/chunking-form/samples/top-level-await-import-mixed/_expected/es/generated-lib-variant.js new file mode 100644 index 00000000000..4b074adb5f5 --- /dev/null +++ b/test/chunking-form/samples/top-level-await-import-mixed/_expected/es/generated-lib-variant.js @@ -0,0 +1,7 @@ +import { g as getInfo } from './generated-lib.js'; + +function getInfoWithVariant() { + return getInfo() + '_variant'; +} + +export { getInfoWithVariant }; diff --git a/test/chunking-form/samples/top-level-await-import-mixed/_expected/es/generated-lib.js b/test/chunking-form/samples/top-level-await-import-mixed/_expected/es/generated-lib.js new file mode 100644 index 00000000000..b9c6222cc99 --- /dev/null +++ b/test/chunking-form/samples/top-level-await-import-mixed/_expected/es/generated-lib.js @@ -0,0 +1,5 @@ +function getInfo() { + return 'info'; +} + +export { getInfo as g }; diff --git a/test/chunking-form/samples/top-level-await-import-mixed/_expected/es/main.js b/test/chunking-form/samples/top-level-await-import-mixed/_expected/es/main.js new file mode 100644 index 00000000000..b5950df59bb --- /dev/null +++ b/test/chunking-form/samples/top-level-await-import-mixed/_expected/es/main.js @@ -0,0 +1,12 @@ +import { g as getInfo } from './generated-lib.js'; + +let getCommonInfo = getInfo; + +import('./generated-lib-used.js').then(({ getInfoWithUsed }) => { + getCommonInfo = getInfoWithUsed; +}); + +const { getInfoWithVariant } = await import('./generated-lib-variant.js'); +getCommonInfo = getInfoWithVariant; + +export { getCommonInfo }; diff --git a/test/chunking-form/samples/top-level-await-import-mixed/_expected/system/generated-lib-used.js b/test/chunking-form/samples/top-level-await-import-mixed/_expected/system/generated-lib-used.js new file mode 100644 index 00000000000..99e5e7248fc --- /dev/null +++ b/test/chunking-form/samples/top-level-await-import-mixed/_expected/system/generated-lib-used.js @@ -0,0 +1,18 @@ +System.register(['./generated-lib.js'], (function (exports) { + 'use strict'; + var getInfo; + return { + setters: [function (module) { + getInfo = module.g; + }], + execute: (function () { + + exports("getInfoWithUsed", getInfoWithUsed); + + function getInfoWithUsed() { + return getInfo() + '_used'; + } + + }) + }; +})); diff --git a/test/chunking-form/samples/top-level-await-import-mixed/_expected/system/generated-lib-variant.js b/test/chunking-form/samples/top-level-await-import-mixed/_expected/system/generated-lib-variant.js new file mode 100644 index 00000000000..69075b56138 --- /dev/null +++ b/test/chunking-form/samples/top-level-await-import-mixed/_expected/system/generated-lib-variant.js @@ -0,0 +1,18 @@ +System.register(['./generated-lib.js'], (function (exports) { + 'use strict'; + var getInfo; + return { + setters: [function (module) { + getInfo = module.g; + }], + execute: (function () { + + exports("getInfoWithVariant", getInfoWithVariant); + + function getInfoWithVariant() { + return getInfo() + '_variant'; + } + + }) + }; +})); diff --git a/test/chunking-form/samples/top-level-await-import-mixed/_expected/system/generated-lib.js b/test/chunking-form/samples/top-level-await-import-mixed/_expected/system/generated-lib.js new file mode 100644 index 00000000000..59ed1f2a0ea --- /dev/null +++ b/test/chunking-form/samples/top-level-await-import-mixed/_expected/system/generated-lib.js @@ -0,0 +1,14 @@ +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + + exports("g", getInfo); + + function getInfo() { + return 'info'; + } + + }) + }; +})); diff --git a/test/chunking-form/samples/top-level-await-import-mixed/_expected/system/main.js b/test/chunking-form/samples/top-level-await-import-mixed/_expected/system/main.js new file mode 100644 index 00000000000..8a708ede5a1 --- /dev/null +++ b/test/chunking-form/samples/top-level-await-import-mixed/_expected/system/main.js @@ -0,0 +1,21 @@ +System.register(['./generated-lib.js'], (function (exports, module) { + 'use strict'; + var getInfo; + return { + setters: [function (module) { + getInfo = module.g; + }], + execute: (async function () { + + let getCommonInfo = exports("getCommonInfo", getInfo); + + module.import('./generated-lib-used.js').then(({ getInfoWithUsed }) => { + exports("getCommonInfo", getCommonInfo = getInfoWithUsed); + }); + + const { getInfoWithVariant } = await module.import('./generated-lib-variant.js'); + exports("getCommonInfo", getCommonInfo = getInfoWithVariant); + + }) + }; +})); diff --git a/test/chunking-form/samples/top-level-await-import-mixed/lib-used.js b/test/chunking-form/samples/top-level-await-import-mixed/lib-used.js new file mode 100644 index 00000000000..df58e52a5d2 --- /dev/null +++ b/test/chunking-form/samples/top-level-await-import-mixed/lib-used.js @@ -0,0 +1,5 @@ +import { getInfo } from './lib.js'; + +export function getInfoWithUsed() { + return getInfo() + '_used'; +} diff --git a/test/chunking-form/samples/top-level-await-import-mixed/lib-variant.js b/test/chunking-form/samples/top-level-await-import-mixed/lib-variant.js new file mode 100644 index 00000000000..57b99a9e156 --- /dev/null +++ b/test/chunking-form/samples/top-level-await-import-mixed/lib-variant.js @@ -0,0 +1,5 @@ +import { getInfo } from './lib.js'; + +export function getInfoWithVariant() { + return getInfo() + '_variant'; +} diff --git a/test/chunking-form/samples/top-level-await-import-mixed/lib.js b/test/chunking-form/samples/top-level-await-import-mixed/lib.js new file mode 100644 index 00000000000..60807167eb5 --- /dev/null +++ b/test/chunking-form/samples/top-level-await-import-mixed/lib.js @@ -0,0 +1,3 @@ +export function getInfo() { + return 'info'; +} diff --git a/test/chunking-form/samples/top-level-await-import-mixed/main.js b/test/chunking-form/samples/top-level-await-import-mixed/main.js new file mode 100644 index 00000000000..ecae9de7b46 --- /dev/null +++ b/test/chunking-form/samples/top-level-await-import-mixed/main.js @@ -0,0 +1,10 @@ +import { getInfo } from './lib.js'; + +export let getCommonInfo = getInfo; + +import('./lib-used.js').then(({ getInfoWithUsed }) => { + getCommonInfo = getInfoWithUsed; +}); + +const { getInfoWithVariant } = await import('./lib-variant.js'); +getCommonInfo = getInfoWithVariant; diff --git a/test/chunking-form/samples/top-level-await-import-within-a-top-level-await-call-expression/_config.js b/test/chunking-form/samples/top-level-await-import-within-a-top-level-await-call-expression/_config.js new file mode 100644 index 00000000000..061513031ff --- /dev/null +++ b/test/chunking-form/samples/top-level-await-import-within-a-top-level-await-call-expression/_config.js @@ -0,0 +1,4 @@ +module.exports = defineTest({ + description: 'detected top-level await import within a top-level await call expression', + formats: ['es', 'system'] +}); diff --git a/test/chunking-form/samples/top-level-await-import-within-a-top-level-await-call-expression/_expected/es/generated-lib-used.js b/test/chunking-form/samples/top-level-await-import-within-a-top-level-await-call-expression/_expected/es/generated-lib-used.js new file mode 100644 index 00000000000..5753546d3f3 --- /dev/null +++ b/test/chunking-form/samples/top-level-await-import-within-a-top-level-await-call-expression/_expected/es/generated-lib-used.js @@ -0,0 +1,7 @@ +import { g as getInfo } from './generated-lib.js'; + +function getInfoWithUsed() { + return getInfo() + '_used'; +} + +export { getInfoWithUsed }; diff --git a/test/chunking-form/samples/top-level-await-import-within-a-top-level-await-call-expression/_expected/es/generated-lib-variant.js b/test/chunking-form/samples/top-level-await-import-within-a-top-level-await-call-expression/_expected/es/generated-lib-variant.js new file mode 100644 index 00000000000..2e24ab2e14d --- /dev/null +++ b/test/chunking-form/samples/top-level-await-import-within-a-top-level-await-call-expression/_expected/es/generated-lib-variant.js @@ -0,0 +1,7 @@ +const { getInfoWithUsed } = await import('./generated-lib-used.js'); + +function getInfoWithVariant() { + return getInfoWithUsed() + '_variant'; +} + +export { getInfoWithVariant }; diff --git a/test/chunking-form/samples/top-level-await-import-within-a-top-level-await-call-expression/_expected/es/generated-lib.js b/test/chunking-form/samples/top-level-await-import-within-a-top-level-await-call-expression/_expected/es/generated-lib.js new file mode 100644 index 00000000000..b9c6222cc99 --- /dev/null +++ b/test/chunking-form/samples/top-level-await-import-within-a-top-level-await-call-expression/_expected/es/generated-lib.js @@ -0,0 +1,5 @@ +function getInfo() { + return 'info'; +} + +export { getInfo as g }; diff --git a/test/chunking-form/samples/top-level-await-import-within-a-top-level-await-call-expression/_expected/es/main.js b/test/chunking-form/samples/top-level-await-import-within-a-top-level-await-call-expression/_expected/es/main.js new file mode 100644 index 00000000000..9123703614b --- /dev/null +++ b/test/chunking-form/samples/top-level-await-import-within-a-top-level-await-call-expression/_expected/es/main.js @@ -0,0 +1,12 @@ +import { g as getInfo } from './generated-lib.js'; + +let getCommonInfo = getInfo; + +function wrapper(cb) { + return cb(); +} + +const { getInfoWithVariant } = await wrapper(() => import('./generated-lib-variant.js')); +getCommonInfo = getInfoWithVariant; + +export { getCommonInfo }; diff --git a/test/chunking-form/samples/top-level-await-import-within-a-top-level-await-call-expression/_expected/system/generated-lib-used.js b/test/chunking-form/samples/top-level-await-import-within-a-top-level-await-call-expression/_expected/system/generated-lib-used.js new file mode 100644 index 00000000000..99e5e7248fc --- /dev/null +++ b/test/chunking-form/samples/top-level-await-import-within-a-top-level-await-call-expression/_expected/system/generated-lib-used.js @@ -0,0 +1,18 @@ +System.register(['./generated-lib.js'], (function (exports) { + 'use strict'; + var getInfo; + return { + setters: [function (module) { + getInfo = module.g; + }], + execute: (function () { + + exports("getInfoWithUsed", getInfoWithUsed); + + function getInfoWithUsed() { + return getInfo() + '_used'; + } + + }) + }; +})); diff --git a/test/chunking-form/samples/top-level-await-import-within-a-top-level-await-call-expression/_expected/system/generated-lib-variant.js b/test/chunking-form/samples/top-level-await-import-within-a-top-level-await-call-expression/_expected/system/generated-lib-variant.js new file mode 100644 index 00000000000..3220c641706 --- /dev/null +++ b/test/chunking-form/samples/top-level-await-import-within-a-top-level-await-call-expression/_expected/system/generated-lib-variant.js @@ -0,0 +1,16 @@ +System.register([], (function (exports, module) { + 'use strict'; + return { + execute: (async function () { + + exports("getInfoWithVariant", getInfoWithVariant); + + const { getInfoWithUsed } = await module.import('./generated-lib-used.js'); + + function getInfoWithVariant() { + return getInfoWithUsed() + '_variant'; + } + + }) + }; +})); diff --git a/test/chunking-form/samples/top-level-await-import-within-a-top-level-await-call-expression/_expected/system/generated-lib.js b/test/chunking-form/samples/top-level-await-import-within-a-top-level-await-call-expression/_expected/system/generated-lib.js new file mode 100644 index 00000000000..59ed1f2a0ea --- /dev/null +++ b/test/chunking-form/samples/top-level-await-import-within-a-top-level-await-call-expression/_expected/system/generated-lib.js @@ -0,0 +1,14 @@ +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + + exports("g", getInfo); + + function getInfo() { + return 'info'; + } + + }) + }; +})); diff --git a/test/chunking-form/samples/top-level-await-import-within-a-top-level-await-call-expression/_expected/system/main.js b/test/chunking-form/samples/top-level-await-import-within-a-top-level-await-call-expression/_expected/system/main.js new file mode 100644 index 00000000000..3c60114bda5 --- /dev/null +++ b/test/chunking-form/samples/top-level-await-import-within-a-top-level-await-call-expression/_expected/system/main.js @@ -0,0 +1,21 @@ +System.register(['./generated-lib.js'], (function (exports, module) { + 'use strict'; + var getInfo; + return { + setters: [function (module) { + getInfo = module.g; + }], + execute: (async function () { + + let getCommonInfo = exports("getCommonInfo", getInfo); + + function wrapper(cb) { + return cb(); + } + + const { getInfoWithVariant } = await wrapper(() => module.import('./generated-lib-variant.js')); + exports("getCommonInfo", getCommonInfo = getInfoWithVariant); + + }) + }; +})); diff --git a/test/chunking-form/samples/top-level-await-import-within-a-top-level-await-call-expression/lib-used.js b/test/chunking-form/samples/top-level-await-import-within-a-top-level-await-call-expression/lib-used.js new file mode 100644 index 00000000000..df58e52a5d2 --- /dev/null +++ b/test/chunking-form/samples/top-level-await-import-within-a-top-level-await-call-expression/lib-used.js @@ -0,0 +1,5 @@ +import { getInfo } from './lib.js'; + +export function getInfoWithUsed() { + return getInfo() + '_used'; +} diff --git a/test/chunking-form/samples/top-level-await-import-within-a-top-level-await-call-expression/lib-variant.js b/test/chunking-form/samples/top-level-await-import-within-a-top-level-await-call-expression/lib-variant.js new file mode 100644 index 00000000000..b2aa14578b6 --- /dev/null +++ b/test/chunking-form/samples/top-level-await-import-within-a-top-level-await-call-expression/lib-variant.js @@ -0,0 +1,5 @@ +const { getInfoWithUsed } = await import('./lib-used.js'); + +export function getInfoWithVariant() { + return getInfoWithUsed() + '_variant'; +} diff --git a/test/chunking-form/samples/top-level-await-import-within-a-top-level-await-call-expression/lib.js b/test/chunking-form/samples/top-level-await-import-within-a-top-level-await-call-expression/lib.js new file mode 100644 index 00000000000..60807167eb5 --- /dev/null +++ b/test/chunking-form/samples/top-level-await-import-within-a-top-level-await-call-expression/lib.js @@ -0,0 +1,3 @@ +export function getInfo() { + return 'info'; +} diff --git a/test/chunking-form/samples/top-level-await-import-within-a-top-level-await-call-expression/main.js b/test/chunking-form/samples/top-level-await-import-within-a-top-level-await-call-expression/main.js new file mode 100644 index 00000000000..977cc991b06 --- /dev/null +++ b/test/chunking-form/samples/top-level-await-import-within-a-top-level-await-call-expression/main.js @@ -0,0 +1,10 @@ +import { getInfo } from './lib.js'; + +export let getCommonInfo = getInfo; + +function wrapper(cb) { + return cb(); +} + +const { getInfoWithVariant } = await wrapper(() => import('./lib-variant.js')); +getCommonInfo = getInfoWithVariant; diff --git a/test/chunking-form/samples/top-level-await-import/_config.js b/test/chunking-form/samples/top-level-await-import/_config.js new file mode 100644 index 00000000000..28776a09a26 --- /dev/null +++ b/test/chunking-form/samples/top-level-await-import/_config.js @@ -0,0 +1,4 @@ +module.exports = defineTest({ + description: 'avoiding top-level await critical path for chunks', + formats: ['es', 'system'] +}); diff --git a/test/chunking-form/samples/top-level-await-import/_expected/es/generated-lib-used.js b/test/chunking-form/samples/top-level-await-import/_expected/es/generated-lib-used.js new file mode 100644 index 00000000000..5753546d3f3 --- /dev/null +++ b/test/chunking-form/samples/top-level-await-import/_expected/es/generated-lib-used.js @@ -0,0 +1,7 @@ +import { g as getInfo } from './generated-lib.js'; + +function getInfoWithUsed() { + return getInfo() + '_used'; +} + +export { getInfoWithUsed }; diff --git a/test/chunking-form/samples/top-level-await-import/_expected/es/generated-lib-variant.js b/test/chunking-form/samples/top-level-await-import/_expected/es/generated-lib-variant.js new file mode 100644 index 00000000000..2e24ab2e14d --- /dev/null +++ b/test/chunking-form/samples/top-level-await-import/_expected/es/generated-lib-variant.js @@ -0,0 +1,7 @@ +const { getInfoWithUsed } = await import('./generated-lib-used.js'); + +function getInfoWithVariant() { + return getInfoWithUsed() + '_variant'; +} + +export { getInfoWithVariant }; diff --git a/test/chunking-form/samples/top-level-await-import/_expected/es/generated-lib.js b/test/chunking-form/samples/top-level-await-import/_expected/es/generated-lib.js new file mode 100644 index 00000000000..b9c6222cc99 --- /dev/null +++ b/test/chunking-form/samples/top-level-await-import/_expected/es/generated-lib.js @@ -0,0 +1,5 @@ +function getInfo() { + return 'info'; +} + +export { getInfo as g }; diff --git a/test/chunking-form/samples/top-level-await-import/_expected/es/main.js b/test/chunking-form/samples/top-level-await-import/_expected/es/main.js new file mode 100644 index 00000000000..78c21f63971 --- /dev/null +++ b/test/chunking-form/samples/top-level-await-import/_expected/es/main.js @@ -0,0 +1,8 @@ +import { g as getInfo } from './generated-lib.js'; + +let getCommonInfo = getInfo; + +const { getInfoWithVariant } = await import('./generated-lib-variant.js'); +getCommonInfo = getInfoWithVariant; + +export { getCommonInfo }; diff --git a/test/chunking-form/samples/top-level-await-import/_expected/system/generated-lib-used.js b/test/chunking-form/samples/top-level-await-import/_expected/system/generated-lib-used.js new file mode 100644 index 00000000000..99e5e7248fc --- /dev/null +++ b/test/chunking-form/samples/top-level-await-import/_expected/system/generated-lib-used.js @@ -0,0 +1,18 @@ +System.register(['./generated-lib.js'], (function (exports) { + 'use strict'; + var getInfo; + return { + setters: [function (module) { + getInfo = module.g; + }], + execute: (function () { + + exports("getInfoWithUsed", getInfoWithUsed); + + function getInfoWithUsed() { + return getInfo() + '_used'; + } + + }) + }; +})); diff --git a/test/chunking-form/samples/top-level-await-import/_expected/system/generated-lib-variant.js b/test/chunking-form/samples/top-level-await-import/_expected/system/generated-lib-variant.js new file mode 100644 index 00000000000..3220c641706 --- /dev/null +++ b/test/chunking-form/samples/top-level-await-import/_expected/system/generated-lib-variant.js @@ -0,0 +1,16 @@ +System.register([], (function (exports, module) { + 'use strict'; + return { + execute: (async function () { + + exports("getInfoWithVariant", getInfoWithVariant); + + const { getInfoWithUsed } = await module.import('./generated-lib-used.js'); + + function getInfoWithVariant() { + return getInfoWithUsed() + '_variant'; + } + + }) + }; +})); diff --git a/test/chunking-form/samples/top-level-await-import/_expected/system/generated-lib.js b/test/chunking-form/samples/top-level-await-import/_expected/system/generated-lib.js new file mode 100644 index 00000000000..59ed1f2a0ea --- /dev/null +++ b/test/chunking-form/samples/top-level-await-import/_expected/system/generated-lib.js @@ -0,0 +1,14 @@ +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + + exports("g", getInfo); + + function getInfo() { + return 'info'; + } + + }) + }; +})); diff --git a/test/chunking-form/samples/top-level-await-import/_expected/system/main.js b/test/chunking-form/samples/top-level-await-import/_expected/system/main.js new file mode 100644 index 00000000000..cd8a7ef99fb --- /dev/null +++ b/test/chunking-form/samples/top-level-await-import/_expected/system/main.js @@ -0,0 +1,17 @@ +System.register(['./generated-lib.js'], (function (exports, module) { + 'use strict'; + var getInfo; + return { + setters: [function (module) { + getInfo = module.g; + }], + execute: (async function () { + + let getCommonInfo = exports("getCommonInfo", getInfo); + + const { getInfoWithVariant } = await module.import('./generated-lib-variant.js'); + exports("getCommonInfo", getCommonInfo = getInfoWithVariant); + + }) + }; +})); diff --git a/test/chunking-form/samples/top-level-await-import/lib-used.js b/test/chunking-form/samples/top-level-await-import/lib-used.js new file mode 100644 index 00000000000..df58e52a5d2 --- /dev/null +++ b/test/chunking-form/samples/top-level-await-import/lib-used.js @@ -0,0 +1,5 @@ +import { getInfo } from './lib.js'; + +export function getInfoWithUsed() { + return getInfo() + '_used'; +} diff --git a/test/chunking-form/samples/top-level-await-import/lib-variant.js b/test/chunking-form/samples/top-level-await-import/lib-variant.js new file mode 100644 index 00000000000..b2aa14578b6 --- /dev/null +++ b/test/chunking-form/samples/top-level-await-import/lib-variant.js @@ -0,0 +1,5 @@ +const { getInfoWithUsed } = await import('./lib-used.js'); + +export function getInfoWithVariant() { + return getInfoWithUsed() + '_variant'; +} diff --git a/test/chunking-form/samples/top-level-await-import/lib.js b/test/chunking-form/samples/top-level-await-import/lib.js new file mode 100644 index 00000000000..60807167eb5 --- /dev/null +++ b/test/chunking-form/samples/top-level-await-import/lib.js @@ -0,0 +1,3 @@ +export function getInfo() { + return 'info'; +} diff --git a/test/chunking-form/samples/top-level-await-import/main.js b/test/chunking-form/samples/top-level-await-import/main.js new file mode 100644 index 00000000000..ab81b8ed7e4 --- /dev/null +++ b/test/chunking-form/samples/top-level-await-import/main.js @@ -0,0 +1,6 @@ +import { getInfo } from './lib.js'; + +export let getCommonInfo = getInfo; + +const { getInfoWithVariant } = await import('./lib-variant.js'); +getCommonInfo = getInfoWithVariant; diff --git a/test/chunking-form/samples/tree-shaken-dynamic-hash/_config.js b/test/chunking-form/samples/tree-shaken-dynamic-hash/_config.js deleted file mode 100644 index fde4c170eb6..00000000000 --- a/test/chunking-form/samples/tree-shaken-dynamic-hash/_config.js +++ /dev/null @@ -1,10 +0,0 @@ -module.exports = { - description: - 'Does not fail when calculating the hash of a file containing a tree-shaken dynamic import', - options: { - input: ['main.js'], - output: { - entryFileNames: '[hash].js' - } - } -}; diff --git a/test/chunking-form/samples/tree-shaken-dynamic-hash/_expected/amd/16d985e6.js b/test/chunking-form/samples/tree-shaken-dynamic-hash/_expected/amd/16d985e6.js deleted file mode 100644 index 6cd703051b6..00000000000 --- a/test/chunking-form/samples/tree-shaken-dynamic-hash/_expected/amd/16d985e6.js +++ /dev/null @@ -1,7 +0,0 @@ -define(function () { 'use strict'; - - var main = null; - - return main; - -}); diff --git a/test/chunking-form/samples/tree-shaken-dynamic-hash/_expected/es/bed29d35.js b/test/chunking-form/samples/tree-shaken-dynamic-hash/_expected/es/bed29d35.js deleted file mode 100644 index ed075f84a16..00000000000 --- a/test/chunking-form/samples/tree-shaken-dynamic-hash/_expected/es/bed29d35.js +++ /dev/null @@ -1,3 +0,0 @@ -var main = null; - -export default main; diff --git a/test/chunking-form/samples/tree-shaken-dynamic-hash/_expected/system/0998116a.js b/test/chunking-form/samples/tree-shaken-dynamic-hash/_expected/system/0998116a.js deleted file mode 100644 index f54762cad18..00000000000 --- a/test/chunking-form/samples/tree-shaken-dynamic-hash/_expected/system/0998116a.js +++ /dev/null @@ -1,10 +0,0 @@ -System.register([], function (exports) { - 'use strict'; - return { - execute: function () { - - var main = exports('default', null); - - } - }; -}); diff --git a/test/chunking-form/tsconfig.json b/test/chunking-form/tsconfig.json new file mode 100644 index 00000000000..4a26f3ee84c --- /dev/null +++ b/test/chunking-form/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": "../tsconfig.base.json", + "include": [ + "**/_config.js", + "./index.js", + "./define.d.ts" + ] +} diff --git a/test/cli/define.d.ts b/test/cli/define.d.ts new file mode 100644 index 00000000000..6e172947d43 --- /dev/null +++ b/test/cli/define.d.ts @@ -0,0 +1,5 @@ +import type { TestConfigCli } from '../types'; + +declare global { + function defineTest(config: TestConfigCli): TestConfigCli; +} diff --git a/test/cli/index.js b/test/cli/index.js index 8abed01c543..13d0ed2bc82 100644 --- a/test/cli/index.js +++ b/test/cli/index.js @@ -1,139 +1,175 @@ -const path = require('path'); -const assert = require('assert'); -const sander = require('sander'); -const { exec } = require('child_process'); +const assert = require('node:assert'); +const { exec, spawn } = require('node:child_process'); +const { existsSync, readFileSync } = require('node:fs'); +const path = require('node:path'); +const process = require('node:process'); +const { copySync, removeSync, statSync } = require('fs-extra'); const { normaliseOutput, runTestSuiteWithSamples, assertDirectoriesAreEqual -} = require('../utils.js'); +} = require('../testHelpers.js'); const cwd = process.cwd(); +const rollupBinary = `${path.resolve(__dirname, '../../dist/bin')}${path.sep}rollup`; -sander.rimrafSync(__dirname, 'node_modules'); -sander.copydirSync(__dirname, 'node_modules_rename_me').to(__dirname, 'node_modules'); +removeSync(path.resolve(__dirname, 'node_modules')); +copySync( + path.resolve(__dirname, 'node_modules_rename_me'), + path.resolve(__dirname, 'node_modules') +); runTestSuiteWithSamples( 'cli', path.resolve(__dirname, 'samples'), - (dir, config) => { - (config.skip ? it.skip : config.solo ? it.only : it)( - path.basename(dir) + ': ' + config.description, - done => { - process.chdir(config.cwd || dir); - if (config.before) config.before(); - - const command = config.command.replace( - /(^| )rollup($| )/g, - `node ${path.resolve(__dirname, '../../dist/bin')}${path.sep}rollup ` - ); - - const childProcess = exec( - command, - { - timeout: 40000, - env: Object.assign({}, process.env, { FORCE_COLOR: '0' }, config.env) - }, - (err, code, stderr) => { - if (config.after) config.after(); - if (err && !err.killed) { - if (config.error) { - const shouldContinue = config.error(err); - if (!shouldContinue) return done(); - } else { - throw err; - } + /** + * @param {string} directory + * @param {import('../types').TestConfigCli} config + */ + (directory, config) => { + for (let iteration = 0; iteration < (config.repeat || 1); iteration++) { + const description = `${path.basename(directory)}: ${config.description}${iteration > 0 ? ` (run ${iteration + 1})` : ''}`; + (config.skip ? it.skip : config.solo ? it.only : it)(description, async () => { + process.chdir(config.cwd || directory); + try { + await runTest(config); + } catch (error) { + if (config.retry) { + console.error('Initial test run failed: ' + error.message + '\nRETRYING...\n'); + return runTest(config); + } + throw error; + } + }).timeout(80_000); + } + }, + () => process.chdir(cwd) +); + +async function runTest(config) { + if (config.before) { + await config.before(); + } + return new Promise((resolve, reject) => { + let stdout = ''; + let stderr = ''; + + const spawnOptions = { + timeout: 40_000, + env: { ...process.env, FORCE_COLOR: '0', ...config.env }, + killSignal: 'SIGKILL' + }; + const childProcess = config.spawnArgs + ? spawn('node', [config.spawnScript || rollupBinary, ...config.spawnArgs], spawnOptions) + : exec(config.command.replace(/(^| )rollup($| )/g, ` node ${rollupBinary} `), spawnOptions); + + childProcess.stdout.on('data', data => { + stdout += String(data); + }); + + childProcess.stderr.on('data', async data => { + stderr += String(data); + if (config.abortOnStderr) { + try { + if (await config.abortOnStderr(String(data))) { + childProcess.kill('SIGTERM'); + } + } catch (error) { + childProcess.kill('SIGTERM'); + reject(error); + } + } + }); + + childProcess.on('error', error => { + console.log('GOT AN ERROR', error); + reject(error); + childProcess.kill('SIGKILL'); + }); + + childProcess.on('close', async code => { + try { + let error; + if (code > 0) { + error = new Error(stderr); + error.code = code; + } + if (config.after) { + await config.after(error, stdout, stderr); + } + if (error && !childProcess.killed) { + if (config.error) { + if (!config.error(error)) { + return resolve(); } + } else { + return reject(error); + } + } + if (childProcess.signalCode === 'SIGKILL') { + return reject( + new Error(`Test aborted due to timeout.\nstdout: ${stdout}\n\nstderr: ${stderr}\n`) + ); + } + + if ('stderr' in config) { + const shouldContinue = config.stderr(stderr); + if (!shouldContinue) return resolve(); + } else if (stderr) { + console.error(stderr); + } + + let unintendedError; - if ('stderr' in config) { - const shouldContinue = config.stderr(stderr); - if (!shouldContinue) return done(); - } else if (stderr) { - console.error(stderr); + if (config.execute) { + try { + const function_ = new Function('require', 'module', 'exports', 'assert', stdout); + const module = { + exports: {} + }; + function_(require, module, module.exports, assert); + + if (config.error) { + unintendedError = new Error('Expected an error while executing output'); } - let unintendedError; - - if (config.execute) { - try { - const fn = new Function('require', 'module', 'exports', 'assert', code); - const module = { - exports: {} - }; - fn(require, module, module.exports, assert); - - if (config.error) { - unintendedError = new Error('Expected an error while executing output'); - } - - if (config.exports) { - config.exports(module.exports); - } - } catch (err) { - if (config.error) { - config.error(err); - } else { - unintendedError = err; - } - } - - if (config.show || unintendedError) { - console.log(code + '\n\n\n'); - } - - if (config.solo) console.groupEnd(); - - unintendedError ? done(unintendedError) : done(); - } else if (config.result) { - try { - config.result(code); - done(); - } catch (err) { - done(err); - } - } else if (config.test) { - try { - config.test(); - done(); - } catch (err) { - done(err); - } - } else if ( - sander.existsSync('_expected') && - sander.statSync('_expected').isDirectory() - ) { - try { - assertDirectoriesAreEqual('_actual', '_expected'); - done(); - } catch (err) { - done(err); - } + if (config.exports) { + config.exports(module.exports); + } + } catch (error) { + if (config.error) { + config.error(error); } else { - const expected = sander.readFileSync('_expected.js').toString(); - try { - assert.equal(normaliseOutput(code), normaliseOutput(expected)); - done(); - } catch (err) { - done(err); - } + unintendedError = error; } } - ); - - childProcess.stderr.on('data', async data => { - if (config.abortOnStderr) { - try { - if (await config.abortOnStderr(data)) { - childProcess.kill('SIGTERM'); - } - } catch (err) { - childProcess.kill('SIGTERM'); - done(err); - } + + if (config.show || unintendedError) { + console.log(stdout + '\n\n\n'); } - }); + + if (config.solo) console.groupEnd(); + + return unintendedError ? reject(unintendedError) : resolve(); + } + if (config.result) { + config.result(stdout); + return resolve(); + } + if (config.test) { + config.test(); + return resolve(); + } + if (existsSync('_expected') && statSync('_expected').isDirectory()) { + assertDirectoriesAreEqual('_actual', '_expected'); + return resolve(); + } + const expected = readFileSync('_expected.js', 'utf8'); + assert.equal(normaliseOutput(stdout), normaliseOutput(expected)); + return resolve(); + } catch (error) { + return reject(error); } - ).timeout(50000); - }, - () => process.chdir(cwd) -); + }); + }); +} diff --git a/test/cli/node_modules/bar/lib/config.js b/test/cli/node_modules/bar/lib/config.js index 785d84d0212..1fe16463eb7 100644 --- a/test/cli/node_modules/bar/lib/config.js +++ b/test/cli/node_modules/bar/lib/config.js @@ -1,11 +1,9 @@ -const replace = require( '@rollup/plugin-replace' ); +const replace = require('@rollup/plugin-replace'); module.exports = { input: 'main.js', output: { format: 'cjs' }, - plugins: [ - replace( { ANSWER: 42 } ) - ] + plugins: [replace({ preventAssignment: true, ANSWER: 42 })] }; diff --git a/test/cli/node_modules/esm-dep/index.js b/test/cli/node_modules/esm-dep/index.js new file mode 100644 index 00000000000..61b7e747ee3 --- /dev/null +++ b/test/cli/node_modules/esm-dep/index.js @@ -0,0 +1 @@ +export default 'esm-default'; diff --git a/test/cli/node_modules/esm-dep/package.json b/test/cli/node_modules/esm-dep/package.json new file mode 100644 index 00000000000..feb093e15ad --- /dev/null +++ b/test/cli/node_modules/esm-dep/package.json @@ -0,0 +1,4 @@ +{ + "main": "index.js", + "type": "module" +} diff --git a/test/cli/node_modules/rollup-config-foo/lib/config.js b/test/cli/node_modules/rollup-config-foo/lib/config.js index 785d84d0212..1fe16463eb7 100644 --- a/test/cli/node_modules/rollup-config-foo/lib/config.js +++ b/test/cli/node_modules/rollup-config-foo/lib/config.js @@ -1,11 +1,9 @@ -const replace = require( '@rollup/plugin-replace' ); +const replace = require('@rollup/plugin-replace'); module.exports = { input: 'main.js', output: { format: 'cjs' }, - plugins: [ - replace( { ANSWER: 42 } ) - ] + plugins: [replace({ preventAssignment: true, ANSWER: 42 })] }; diff --git a/test/cli/node_modules/rollup-plugin-esm-test/index.mjs b/test/cli/node_modules/rollup-plugin-esm-test/index.mjs new file mode 100644 index 00000000000..f923e4d823a --- /dev/null +++ b/test/cli/node_modules/rollup-plugin-esm-test/index.mjs @@ -0,0 +1,9 @@ +export function esmTest() { + return { + transform(code, id) { + if (id.includes('\0')) return null; + const name = JSON.stringify(id.replace(/^.*\/advanced-esm\//, 'esm-test: ')); + return `console.log(${name});\n${code}`; + } + }; +} diff --git a/test/cli/node_modules/rollup-plugin-esm-test/package.json b/test/cli/node_modules/rollup-plugin-esm-test/package.json new file mode 100644 index 00000000000..7084d6ebcc0 --- /dev/null +++ b/test/cli/node_modules/rollup-plugin-esm-test/package.json @@ -0,0 +1,4 @@ +{ + "type": "module", + "main": "index.mjs" +} diff --git a/test/cli/node_modules_rename_me/bar/lib/config.js b/test/cli/node_modules_rename_me/bar/lib/config.js index 785d84d0212..1fe16463eb7 100644 --- a/test/cli/node_modules_rename_me/bar/lib/config.js +++ b/test/cli/node_modules_rename_me/bar/lib/config.js @@ -1,11 +1,9 @@ -const replace = require( '@rollup/plugin-replace' ); +const replace = require('@rollup/plugin-replace'); module.exports = { input: 'main.js', output: { format: 'cjs' }, - plugins: [ - replace( { ANSWER: 42 } ) - ] + plugins: [replace({ preventAssignment: true, ANSWER: 42 })] }; diff --git a/test/cli/node_modules_rename_me/esm-dep/index.js b/test/cli/node_modules_rename_me/esm-dep/index.js new file mode 100644 index 00000000000..61b7e747ee3 --- /dev/null +++ b/test/cli/node_modules_rename_me/esm-dep/index.js @@ -0,0 +1 @@ +export default 'esm-default'; diff --git a/test/cli/node_modules_rename_me/esm-dep/package.json b/test/cli/node_modules_rename_me/esm-dep/package.json new file mode 100644 index 00000000000..feb093e15ad --- /dev/null +++ b/test/cli/node_modules_rename_me/esm-dep/package.json @@ -0,0 +1,4 @@ +{ + "main": "index.js", + "type": "module" +} diff --git a/test/cli/node_modules_rename_me/rollup-config-foo/lib/config.js b/test/cli/node_modules_rename_me/rollup-config-foo/lib/config.js index 785d84d0212..1fe16463eb7 100644 --- a/test/cli/node_modules_rename_me/rollup-config-foo/lib/config.js +++ b/test/cli/node_modules_rename_me/rollup-config-foo/lib/config.js @@ -1,11 +1,9 @@ -const replace = require( '@rollup/plugin-replace' ); +const replace = require('@rollup/plugin-replace'); module.exports = { input: 'main.js', output: { format: 'cjs' }, - plugins: [ - replace( { ANSWER: 42 } ) - ] + plugins: [replace({ preventAssignment: true, ANSWER: 42 })] }; diff --git a/test/cli/node_modules_rename_me/rollup-plugin-esm-test/index.mjs b/test/cli/node_modules_rename_me/rollup-plugin-esm-test/index.mjs new file mode 100644 index 00000000000..f923e4d823a --- /dev/null +++ b/test/cli/node_modules_rename_me/rollup-plugin-esm-test/index.mjs @@ -0,0 +1,9 @@ +export function esmTest() { + return { + transform(code, id) { + if (id.includes('\0')) return null; + const name = JSON.stringify(id.replace(/^.*\/advanced-esm\//, 'esm-test: ')); + return `console.log(${name});\n${code}`; + } + }; +} diff --git a/test/cli/node_modules_rename_me/rollup-plugin-esm-test/package.json b/test/cli/node_modules_rename_me/rollup-plugin-esm-test/package.json new file mode 100644 index 00000000000..7084d6ebcc0 --- /dev/null +++ b/test/cli/node_modules_rename_me/rollup-plugin-esm-test/package.json @@ -0,0 +1,4 @@ +{ + "type": "module", + "main": "index.mjs" +} diff --git a/test/cli/samples/allow-output-prefix/_config.js b/test/cli/samples/allow-output-prefix/_config.js index db33b01555a..db6a9cb57aa 100644 --- a/test/cli/samples/allow-output-prefix/_config.js +++ b/test/cli/samples/allow-output-prefix/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'allows output options to be prefixed with "output."', - command: 'rollup main.js --output.format es --output.footer "console.log(\'Rollup!\')"' -}; + spawnArgs: ['main.js', '--output.format', 'es', '--output.footer', "console.log('Rollup!')"] +}); diff --git a/test/cli/samples/amd/_config.js b/test/cli/samples/amd/_config.js index 3a6ddb0ff66..4fab5e77a02 100644 --- a/test/cli/samples/amd/_config.js +++ b/test/cli/samples/amd/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'sets AMD module ID and define function', - command: 'rollup -i main.js -f amd --amd.id foo --amd.define defn' -}; + spawnArgs: ['-i', 'main.js', '-f', 'amd', '--amd.id', 'foo', '--amd.define', 'defn'] +}); diff --git a/test/cli/samples/amd/_expected.js b/test/cli/samples/amd/_expected.js index 71e98ac5b39..ce9592df896 100644 --- a/test/cli/samples/amd/_expected.js +++ b/test/cli/samples/amd/_expected.js @@ -1,7 +1,7 @@ -defn('foo', function () { 'use strict'; +defn('foo', (function () { 'use strict'; var main = 42; return main; -}); +})); diff --git a/test/cli/samples/banner-intro-outro-footer/_config.js b/test/cli/samples/banner-intro-outro-footer/_config.js index 5c37680a1af..de714c925b7 100644 --- a/test/cli/samples/banner-intro-outro-footer/_config.js +++ b/test/cli/samples/banner-intro-outro-footer/_config.js @@ -1,5 +1,18 @@ -module.exports = { +module.exports = defineTest({ description: 'adds banner/intro/outro/footer', - command: - 'rollup -i main.js -f iife --indent --banner "// banner" --intro "// intro" --outro "// outro" --footer "// footer"' -}; + spawnArgs: [ + '-i', + 'main.js', + '-f', + 'iife', + '--indent', + '--banner', + '// banner', + '--intro', + '// intro', + '--outro', + '// outro', + '--footer', + '// footer' + ] +}); diff --git a/test/cli/samples/banner-intro-outro-footer/_expected.js b/test/cli/samples/banner-intro-outro-footer/_expected.js index 84932761496..1a9d2003ddc 100644 --- a/test/cli/samples/banner-intro-outro-footer/_expected.js +++ b/test/cli/samples/banner-intro-outro-footer/_expected.js @@ -8,5 +8,5 @@ // outro -}()); +})(); // footer diff --git a/test/cli/samples/code-splitting-named-default-inputs/_config.js b/test/cli/samples/code-splitting-named-default-inputs/_config.js index 28ac0795a3f..158d16482d0 100644 --- a/test/cli/samples/code-splitting-named-default-inputs/_config.js +++ b/test/cli/samples/code-splitting-named-default-inputs/_config.js @@ -1,21 +1,28 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'allows defining names via CLI', - command: - 'rollup entry1=main1.js "Entry 2"="main 2.js" "main3.js" --entryFileNames [name]-[hash].js -f es', + spawnArgs: [ + 'entry1=main1.js', + 'Entry 2=main 2.js', + 'main3.js', + '--entryFileNames', + '[name]-[hash].js', + '-f', + 'es' + ], result(code) { assert.equal( code, '\n' + - `//→ entry1-b70571c1.js:\n` + + `//→ entry1-F7XBegnP.js:\n` + "console.log('main1');\n" + '\n' + - `//→ Entry 2-cc781491.js:\n` + + `//→ Entry 2-DJUOC_be.js:\n` + "console.log('main2');\n" + '\n' + - `//→ main3-5e259623.js:\n` + + `//→ main3-CcbE82tV.js:\n` + "console.log('main3');\n" ); } -}; +}); diff --git a/test/cli/samples/code-splitting-named-inputs/_config.js b/test/cli/samples/code-splitting-named-inputs/_config.js index 420bde6475a..b4e791fef60 100644 --- a/test/cli/samples/code-splitting-named-inputs/_config.js +++ b/test/cli/samples/code-splitting-named-inputs/_config.js @@ -1,21 +1,31 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'allows defining names via CLI', - command: - 'rollup --entryFileNames [name]-[hash].js --input entry1=main1.js -i "Entry 2"="main 2.js" -i "main3.js" -f es', + spawnArgs: [ + '--entryFileNames', + '[name]-[hash].js', + '--input', + 'entry1=main1.js', + '-i', + 'Entry 2=main 2.js', + '-i', + 'main3.js', + '-f', + 'es' + ], result(code) { assert.equal( code, '\n' + - `//→ entry1-b70571c1.js:\n` + + `//→ entry1-F7XBegnP.js:\n` + "console.log('main1');\n" + '\n' + - `//→ Entry 2-cc781491.js:\n` + + `//→ Entry 2-DJUOC_be.js:\n` + "console.log('main2');\n" + '\n' + - `//→ main3-5e259623.js:\n` + + `//→ main3-CcbE82tV.js:\n` + "console.log('main3');\n" ); } -}; +}); diff --git a/test/cli/samples/config-async-function/_config.js b/test/cli/samples/config-async-function/_config.js index 5fc2f43e411..5103fc8ad04 100644 --- a/test/cli/samples/config-async-function/_config.js +++ b/test/cli/samples/config-async-function/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'supports using an async function as config', - command: 'rollup -c', -}; + spawnArgs: ['-c'] +}); diff --git a/test/cli/samples/config-async-function/rollup.config.js b/test/cli/samples/config-async-function/rollup.config.js deleted file mode 100644 index 49cf552519d..00000000000 --- a/test/cli/samples/config-async-function/rollup.config.js +++ /dev/null @@ -1,7 +0,0 @@ -export default async () => ({ - input: 'main.js', - output: { - format: 'cjs', - exports: 'auto' - }, -}); diff --git a/test/cli/samples/config-async-function/rollup.config.mjs b/test/cli/samples/config-async-function/rollup.config.mjs new file mode 100644 index 00000000000..5507bf729ea --- /dev/null +++ b/test/cli/samples/config-async-function/rollup.config.mjs @@ -0,0 +1,7 @@ +export default async () => ({ + input: 'main.js', + output: { + format: 'cjs', + exports: 'auto' + } +}); diff --git a/test/cli/samples/config-cjs-dirname/_config.js b/test/cli/samples/config-cjs-dirname/_config.js index 7b8f251fc3e..bfff69a14db 100644 --- a/test/cli/samples/config-cjs-dirname/_config.js +++ b/test/cli/samples/config-cjs-dirname/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'does not transpile cjs configs and provides correct __filename', - command: 'rollup -c' -}; + spawnArgs: ['-c'] +}); diff --git a/test/cli/samples/config-cjs-dirname/_expected.js b/test/cli/samples/config-cjs-dirname/_expected.js index 6e0be4aa7be..e630a2462b6 100644 --- a/test/cli/samples/config-cjs-dirname/_expected.js +++ b/test/cli/samples/config-cjs-dirname/_expected.js @@ -2,4 +2,4 @@ console.log('nested/plugin.js'); console.log('plugin.js'); var main = 42; -export default main; +export { main as default }; diff --git a/test/cli/samples/config-cwd-case-insensitive-es6/_config.js b/test/cli/samples/config-cwd-case-insensitive-es6/_config.js new file mode 100644 index 00000000000..b1b61ec4bf7 --- /dev/null +++ b/test/cli/samples/config-cwd-case-insensitive-es6/_config.js @@ -0,0 +1,11 @@ +function toggleCase(s) { + return s == s.toLowerCase() ? s.toUpperCase() : s.toLowerCase(); +} + +module.exports = defineTest({ + onlyWindows: true, + description: "can load ES6 config with cwd that doesn't match realpath", + spawnArgs: ['-c'], + cwd: __dirname.replace(/^[a-z]:\\/i, toggleCase), + execute: true +}); diff --git a/test/cli/samples/config-cwd-case-insensitive-es6/main.js b/test/cli/samples/config-cwd-case-insensitive-es6/main.js new file mode 100644 index 00000000000..df16c1b06b9 --- /dev/null +++ b/test/cli/samples/config-cwd-case-insensitive-es6/main.js @@ -0,0 +1 @@ +assert.equal( ANSWER, 42 ); diff --git a/test/cli/samples/config-cwd-case-insensitive-es6/rollup.config.mjs b/test/cli/samples/config-cwd-case-insensitive-es6/rollup.config.mjs new file mode 100644 index 00000000000..dee04a33fb1 --- /dev/null +++ b/test/cli/samples/config-cwd-case-insensitive-es6/rollup.config.mjs @@ -0,0 +1,9 @@ +import replace from '@rollup/plugin-replace'; + +export default { + input: 'main.js', + output: { + format: 'cjs' + }, + plugins: [replace({ preventAssignment: true, ANSWER: 42 })] +}; diff --git a/test/cli/samples/config-cwd-case-insensitive/_config.js b/test/cli/samples/config-cwd-case-insensitive/_config.js index aa70c6ca632..08f6109c76a 100644 --- a/test/cli/samples/config-cwd-case-insensitive/_config.js +++ b/test/cli/samples/config-cwd-case-insensitive/_config.js @@ -2,10 +2,10 @@ function toggleCase(s) { return s == s.toLowerCase() ? s.toUpperCase() : s.toLowerCase(); } -module.exports = { +module.exports = defineTest({ onlyWindows: true, description: "can load config with cwd that doesn't match realpath", - command: 'rollup -c', - cwd: __dirname.replace(/^[A-Z]:\\/i, toggleCase), + spawnArgs: ['-c'], + cwd: __dirname.replace(/^[a-z]:\\/i, toggleCase), execute: true -}; +}); diff --git a/test/cli/samples/config-cwd-case-insensitive/rollup.config.js b/test/cli/samples/config-cwd-case-insensitive/rollup.config.js index 997b775f21c..f39a8930bd4 100644 --- a/test/cli/samples/config-cwd-case-insensitive/rollup.config.js +++ b/test/cli/samples/config-cwd-case-insensitive/rollup.config.js @@ -1,11 +1,9 @@ -var replace = require( '@rollup/plugin-replace' ); +var replace = require('@rollup/plugin-replace'); module.exports = { input: 'main.js', output: { format: 'cjs' }, - plugins: [ - replace( { 'ANSWER': 42 } ) - ] + plugins: [replace({ preventAssignment: true, ANSWER: 42 })] }; diff --git a/test/cli/samples/config-defineConfig-cjs/_config.js b/test/cli/samples/config-defineConfig-cjs/_config.js new file mode 100644 index 00000000000..6fcad868b5d --- /dev/null +++ b/test/cli/samples/config-defineConfig-cjs/_config.js @@ -0,0 +1,5 @@ +module.exports = defineTest({ + description: 'uses cjs config file which return config wrapped by defineConfig', + spawnArgs: ['--config', 'rollup.config.js'], + execute: true +}); diff --git a/test/cli/samples/config-defineConfig-cjs/main.js b/test/cli/samples/config-defineConfig-cjs/main.js new file mode 100644 index 00000000000..888cae37af9 --- /dev/null +++ b/test/cli/samples/config-defineConfig-cjs/main.js @@ -0,0 +1 @@ +module.exports = 42; diff --git a/test/cli/samples/config-defineConfig-cjs/rollup.config.js b/test/cli/samples/config-defineConfig-cjs/rollup.config.js new file mode 100644 index 00000000000..6131769bef9 --- /dev/null +++ b/test/cli/samples/config-defineConfig-cjs/rollup.config.js @@ -0,0 +1,8 @@ +const { defineConfig } = require('../../../../dist/rollup'); + +module.exports = defineConfig({ + input: 'main.js', + output: { + format: 'cjs' + } +}); diff --git a/test/cli/samples/config-defineConfig-mjs/_config.js b/test/cli/samples/config-defineConfig-mjs/_config.js new file mode 100644 index 00000000000..b84e6ba3093 --- /dev/null +++ b/test/cli/samples/config-defineConfig-mjs/_config.js @@ -0,0 +1,9 @@ +// @ts-expect-error not included in types +const { hasEsBuild } = require('../../../testHelpers'); + +module.exports = defineTest({ + skip: !hasEsBuild, + description: 'uses mjs config file which return config wrapped by defineConfig', + spawnArgs: ['--config', 'rollup.config.mjs'], + execute: true +}); diff --git a/test/cli/samples/config-defineConfig-mjs/main.js b/test/cli/samples/config-defineConfig-mjs/main.js new file mode 100644 index 00000000000..888cae37af9 --- /dev/null +++ b/test/cli/samples/config-defineConfig-mjs/main.js @@ -0,0 +1 @@ +module.exports = 42; diff --git a/test/cli/samples/config-defineConfig-mjs/rollup.config.mjs b/test/cli/samples/config-defineConfig-mjs/rollup.config.mjs new file mode 100644 index 00000000000..10abdde3d84 --- /dev/null +++ b/test/cli/samples/config-defineConfig-mjs/rollup.config.mjs @@ -0,0 +1,8 @@ +import { defineConfig } from "../../../../dist/es/rollup.js" + +export default defineConfig({ + input: 'main.js', + output: { + format: 'cjs' + }, +}); diff --git a/test/cli/samples/config-env-multiple/_config.js b/test/cli/samples/config-env-multiple/_config.js index b13de2ecb04..6f58933a88b 100644 --- a/test/cli/samples/config-env-multiple/_config.js +++ b/test/cli/samples/config-env-multiple/_config.js @@ -1,5 +1,13 @@ -module.exports = { +module.exports = defineTest({ description: 'passes environment variables to config file via multiple --environment values', - command: 'rollup --config --environment PRODUCTION,FOO:bar --environment SECOND,KEY:value --environment FOO:foo', + spawnArgs: [ + '--config', + '--environment', + 'PRODUCTION,FOO:bar', + '--environment', + 'SECOND,KEY:value', + '--environment', + 'FOO:foo' + ], execute: true -}; +}); diff --git a/test/cli/samples/config-env-multiple/rollup.config.js b/test/cli/samples/config-env-multiple/rollup.config.js index e8ab3b9c65c..3c329a3adcb 100644 --- a/test/cli/samples/config-env-multiple/rollup.config.js +++ b/test/cli/samples/config-env-multiple/rollup.config.js @@ -1,4 +1,4 @@ -var replace = require( '@rollup/plugin-replace' ); +var replace = require('@rollup/plugin-replace'); module.exports = { input: 'main.js', @@ -6,11 +6,12 @@ module.exports = { format: 'cjs' }, plugins: [ - replace( { + replace({ + preventAssignment: true, __ENVIRONMENT__: process.env.PRODUCTION ? 'production' : 'development', __FOO__: process.env.FOO, __SECOND__: process.env.SECOND, __KEY__: process.env.KEY - } ) + }) ] }; diff --git a/test/cli/samples/config-env/_config.js b/test/cli/samples/config-env/_config.js index 3036cc208f5..c0089a9a578 100644 --- a/test/cli/samples/config-env/_config.js +++ b/test/cli/samples/config-env/_config.js @@ -1,5 +1,5 @@ -module.exports = { +module.exports = defineTest({ description: 'passes environment variables to config file', - command: 'rollup --config --environment PRODUCTION,FOO:bar,HOST:http://localhost:4000', + spawnArgs: ['--config', '--environment', 'PRODUCTION,FOO:bar,HOST:http://localhost:4000'], execute: true -}; +}); diff --git a/test/cli/samples/config-env/rollup.config.js b/test/cli/samples/config-env/rollup.config.js index c1ce83c96cb..6f03b85644f 100644 --- a/test/cli/samples/config-env/rollup.config.js +++ b/test/cli/samples/config-env/rollup.config.js @@ -1,4 +1,4 @@ -var replace = require( '@rollup/plugin-replace' ); +var replace = require('@rollup/plugin-replace'); module.exports = { input: 'main.js', @@ -6,10 +6,11 @@ module.exports = { format: 'cjs' }, plugins: [ - replace( { + replace({ + preventAssignment: true, __ENVIRONMENT__: process.env.PRODUCTION ? 'production' : 'development', __FOO__: process.env.FOO, __HOST__: process.env.HOST - } ) + }) ] }; diff --git a/test/cli/samples/config-es6/_config.js b/test/cli/samples/config-es6/_config.js index 0db10ef3b26..428f9fa9444 100644 --- a/test/cli/samples/config-es6/_config.js +++ b/test/cli/samples/config-es6/_config.js @@ -1,5 +1,5 @@ -module.exports = { +module.exports = defineTest({ description: 'uses ES6 module config file', - command: 'rollup --config rollup.config.js', + spawnArgs: ['--config', 'rollup.config.js', '--bundleConfigAsCjs'], execute: true -}; +}); diff --git a/test/cli/samples/config-es6/rollup.config.js b/test/cli/samples/config-es6/rollup.config.js index f501818ff13..1c845e5a830 100644 --- a/test/cli/samples/config-es6/rollup.config.js +++ b/test/cli/samples/config-es6/rollup.config.js @@ -1,13 +1,11 @@ import replace from '@rollup/plugin-replace'; -export const ignoresNonDefaultExports = true +export const ignoresNonDefaultExports = true; export default { input: 'main.js', output: { format: 'cjs' }, - plugins: [ - replace( { 'ANSWER': 42 } ) - ] + plugins: [replace({ preventAssignment: true, ANSWER: 42 })] }; diff --git a/test/cli/samples/config-external-function/_config.js b/test/cli/samples/config-external-function/_config.js index 9f21d968ead..53ddc5b8c8b 100644 --- a/test/cli/samples/config-external-function/_config.js +++ b/test/cli/samples/config-external-function/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'external option gets passed from config', - command: 'rollup -c -e assert,external-module' -}; + spawnArgs: ['-c', '-e', 'assert,external-module'] +}); diff --git a/test/cli/samples/config-external-function/rollup.config.js b/test/cli/samples/config-external-function/rollup.config.js deleted file mode 100644 index 778569aab08..00000000000 --- a/test/cli/samples/config-external-function/rollup.config.js +++ /dev/null @@ -1,21 +0,0 @@ -import assert from 'assert'; -import { resolve } from 'path'; - -var config = resolve( './_config.js' ); - -export default { - input: 'main.js', - output: { - format: 'cjs' - }, - external: function ( id ) { - return id === config; - }, - plugins: [ - { - load: function ( id ) { - assert.notEqual( id, config ); - } - } - ] -}; diff --git a/test/cli/samples/config-external-function/rollup.config.mjs b/test/cli/samples/config-external-function/rollup.config.mjs new file mode 100644 index 00000000000..1e7cd7af787 --- /dev/null +++ b/test/cli/samples/config-external-function/rollup.config.mjs @@ -0,0 +1,21 @@ +import assert from 'assert'; +import { resolve } from 'path'; + +var config = resolve('./_config.js'); + +export default { + input: 'main.js', + output: { + format: 'cjs' + }, + external(id) { + return id === config; + }, + plugins: [ + { + load(id) { + assert.notEqual(id, config); + } + } + ] +}; diff --git a/test/cli/samples/config-external/_config.js b/test/cli/samples/config-external/_config.js index 59df4b7dbd7..2357c3aae5c 100644 --- a/test/cli/samples/config-external/_config.js +++ b/test/cli/samples/config-external/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'external option gets passed from config', - command: 'rollup -c' -}; + spawnArgs: ['-c'] +}); diff --git a/test/cli/samples/config-external/rollup.config.js b/test/cli/samples/config-external/rollup.config.js deleted file mode 100644 index 37705b99853..00000000000 --- a/test/cli/samples/config-external/rollup.config.js +++ /dev/null @@ -1,19 +0,0 @@ -import assert from 'assert'; -import { resolve } from 'path'; - -var config = resolve( './_config.js' ); - -export default { - input: 'main.js', - output: { - format: 'cjs' - }, - external: [ 'assert', config ], - plugins: [ - { - load: function ( id ) { - assert.notEqual( id, config ); - } - } - ] -}; diff --git a/test/cli/samples/config-external/rollup.config.mjs b/test/cli/samples/config-external/rollup.config.mjs new file mode 100644 index 00000000000..244001841f4 --- /dev/null +++ b/test/cli/samples/config-external/rollup.config.mjs @@ -0,0 +1,19 @@ +import assert from 'assert'; +import { resolve } from 'path'; + +var config = resolve('./_config.js'); + +export default { + input: 'main.js', + output: { + format: 'cjs' + }, + external: ['assert', config], + plugins: [ + { + load(id) { + assert.notEqual(id, config); + } + } + ] +}; diff --git a/test/cli/samples/config-file-bundle-with-extensionless-importee/_config.js b/test/cli/samples/config-file-bundle-with-extensionless-importee/_config.js new file mode 100644 index 00000000000..2d9f72d7c8a --- /dev/null +++ b/test/cli/samples/config-file-bundle-with-extensionless-importee/_config.js @@ -0,0 +1,5 @@ +module.exports = defineTest({ + description: 'Support for bundling config files as cjs which import extensionless files', + spawnArgs: ['--config', 'rollup.config.mjs', '--bundleConfigAsCjs'], + execute: false +}); diff --git a/test/cli/samples/config-file-bundle-with-extensionless-importee/_expected.js b/test/cli/samples/config-file-bundle-with-extensionless-importee/_expected.js new file mode 100644 index 00000000000..cc1d88a24fa --- /dev/null +++ b/test/cli/samples/config-file-bundle-with-extensionless-importee/_expected.js @@ -0,0 +1 @@ +assert.ok(true); diff --git a/test/cli/samples/config-file-bundle-with-extensionless-importee/input.js b/test/cli/samples/config-file-bundle-with-extensionless-importee/input.js new file mode 100644 index 00000000000..cc1d88a24fa --- /dev/null +++ b/test/cli/samples/config-file-bundle-with-extensionless-importee/input.js @@ -0,0 +1 @@ +assert.ok(true); diff --git a/test/cli/samples/config-file-bundle-with-extensionless-importee/rollup.base.config.mjs b/test/cli/samples/config-file-bundle-with-extensionless-importee/rollup.base.config.mjs new file mode 100644 index 00000000000..e6c02c09bef --- /dev/null +++ b/test/cli/samples/config-file-bundle-with-extensionless-importee/rollup.base.config.mjs @@ -0,0 +1,3 @@ +export default { + input: 'input.js' +}; diff --git a/test/cli/samples/config-file-bundle-with-extensionless-importee/rollup.config.mjs b/test/cli/samples/config-file-bundle-with-extensionless-importee/rollup.config.mjs new file mode 100644 index 00000000000..e1de53303bb --- /dev/null +++ b/test/cli/samples/config-file-bundle-with-extensionless-importee/rollup.config.mjs @@ -0,0 +1,3 @@ +import baseConfig from './rollup.base.config'; + +export default baseConfig; diff --git a/test/cli/samples/config-function-modify-command/_config.js b/test/cli/samples/config-function-modify-command/_config.js index c14498e84da..df72e6bc5ba 100644 --- a/test/cli/samples/config-function-modify-command/_config.js +++ b/test/cli/samples/config-function-modify-command/_config.js @@ -1,5 +1,5 @@ -module.exports = { +module.exports = defineTest({ description: 'allows cleaning up and modifying the command args in the config file', - command: 'rollup --config rollup.config.js --some-option="foo" --another-option=42', + spawnArgs: ['--config', 'rollup.config.mjs', '--some-option="foo"', '--another-option=42'], execute: true -}; +}); diff --git a/test/cli/samples/config-function-modify-command/main.js b/test/cli/samples/config-function-modify-command/main.js index aadfbd9aaf0..bbbb2db8f28 100644 --- a/test/cli/samples/config-function-modify-command/main.js +++ b/test/cli/samples/config-function-modify-command/main.js @@ -1,7 +1,7 @@ assert.deepEqual(COMMAND_OPTIONS, { _: [], - config: 'rollup.config.js', - c: 'rollup.config.js', + config: 'rollup.config.mjs', + c: 'rollup.config.mjs', 'some-option': 'foo', 'another-option': 42 }); diff --git a/test/cli/samples/config-function-modify-command/rollup.config.js b/test/cli/samples/config-function-modify-command/rollup.config.js deleted file mode 100644 index c91b46d6bc1..00000000000 --- a/test/cli/samples/config-function-modify-command/rollup.config.js +++ /dev/null @@ -1,15 +0,0 @@ -import replace from '@rollup/plugin-replace'; - -export default commandOptions => { - const COMMAND_OPTIONS = JSON.stringify(commandOptions); - delete commandOptions['some-option']; - delete commandOptions['another-option']; - commandOptions.format = 'cjs'; - return { - input: 'main.js', - onwarn(warning) { - throw new Error(`Unexpected warning: ${warning.message}`); - }, - plugins: [replace({ COMMAND_OPTIONS })] - }; -}; diff --git a/test/cli/samples/config-function-modify-command/rollup.config.mjs b/test/cli/samples/config-function-modify-command/rollup.config.mjs new file mode 100644 index 00000000000..7ff538002a9 --- /dev/null +++ b/test/cli/samples/config-function-modify-command/rollup.config.mjs @@ -0,0 +1,15 @@ +import replace from '@rollup/plugin-replace'; + +export default commandOptions => { + const COMMAND_OPTIONS = JSON.stringify(commandOptions); + delete commandOptions['some-option']; + delete commandOptions['another-option']; + commandOptions.format = 'cjs'; + return { + input: 'main.js', + onwarn(warning) { + throw new Error(`Unexpected warning: ${warning.message}`); + }, + plugins: [replace({ preventAssignment: true, COMMAND_OPTIONS })] + }; +}; diff --git a/test/cli/samples/config-function/_config.js b/test/cli/samples/config-function/_config.js index 162c7bd13b3..f8428c327b2 100644 --- a/test/cli/samples/config-function/_config.js +++ b/test/cli/samples/config-function/_config.js @@ -1,6 +1,6 @@ -module.exports = { +module.exports = defineTest({ description: 'if the config file returns a function then this will be called with the command args', - command: 'rollup --config rollup.config.js --silent', + spawnArgs: ['--config', 'rollup.config.mjs', '--silent'], execute: true -}; +}); diff --git a/test/cli/samples/config-function/main.js b/test/cli/samples/config-function/main.js index ec5d5d2e316..9117e22968b 100644 --- a/test/cli/samples/config-function/main.js +++ b/test/cli/samples/config-function/main.js @@ -1,6 +1,6 @@ assert.deepEqual(COMMAND_OPTIONS, { _: [], - config: 'rollup.config.js', - c: 'rollup.config.js', + config: 'rollup.config.mjs', + c: 'rollup.config.mjs', silent: true }); diff --git a/test/cli/samples/config-function/rollup.config.js b/test/cli/samples/config-function/rollup.config.js deleted file mode 100644 index 88f649db3c3..00000000000 --- a/test/cli/samples/config-function/rollup.config.js +++ /dev/null @@ -1,18 +0,0 @@ -import assert from 'assert'; -import replace from '@rollup/plugin-replace'; - -export default commandOptions => { - assert.equal(commandOptions.silent, true); - return { - input: 'main.js', - output: { - format: 'cjs' - }, - onwarn(warning) { - throw new Error(`Unexpected warning: ${warning.message}`); - }, - plugins: [ - replace( { 'COMMAND_OPTIONS': JSON.stringify(commandOptions) } ) - ] - }; -}; diff --git a/test/cli/samples/config-function/rollup.config.mjs b/test/cli/samples/config-function/rollup.config.mjs new file mode 100644 index 00000000000..a5d719a4d9f --- /dev/null +++ b/test/cli/samples/config-function/rollup.config.mjs @@ -0,0 +1,16 @@ +import assert from 'assert'; +import replace from '@rollup/plugin-replace'; + +export default commandOptions => { + assert.equal(commandOptions.silent, true); + return { + input: 'main.js', + output: { + format: 'cjs' + }, + onwarn(warning) { + throw new Error(`Unexpected warning: ${warning.message}`); + }, + plugins: [replace({ preventAssignment: true, COMMAND_OPTIONS: JSON.stringify(commandOptions) })] + }; +}; diff --git a/test/cli/samples/config-import-attributes-key/_config.js b/test/cli/samples/config-import-attributes-key/_config.js new file mode 100644 index 00000000000..0f9d00d6c08 --- /dev/null +++ b/test/cli/samples/config-import-attributes-key/_config.js @@ -0,0 +1,12 @@ +module.exports = defineTest({ + description: 'supports modify the import attributes key in the config file', + spawnArgs: [ + '--config', + 'rollup.config.ts', + '--configPlugin', + 'typescript', + '--configImportAttributesKey', + 'with' + ], + minNodeVersion: 22 +}); diff --git a/test/cli/samples/config-import-attributes-key/_expected.js b/test/cli/samples/config-import-attributes-key/_expected.js new file mode 100644 index 00000000000..6fd42ba0b32 --- /dev/null +++ b/test/cli/samples/config-import-attributes-key/_expected.js @@ -0,0 +1,3 @@ +'use strict'; + +assert.ok(true); diff --git a/test/cli/samples/config-import-attributes-key/foo.js b/test/cli/samples/config-import-attributes-key/foo.js new file mode 100644 index 00000000000..cc1d88a24fa --- /dev/null +++ b/test/cli/samples/config-import-attributes-key/foo.js @@ -0,0 +1 @@ +assert.ok(true); diff --git a/test/cli/samples/config-import-attributes-key/foo.json b/test/cli/samples/config-import-attributes-key/foo.json new file mode 100644 index 00000000000..d97196bc01b --- /dev/null +++ b/test/cli/samples/config-import-attributes-key/foo.json @@ -0,0 +1 @@ +{ "name": "foo" } diff --git a/test/cli/samples/config-import-attributes-key/rollup.config.ts b/test/cli/samples/config-import-attributes-key/rollup.config.ts new file mode 100644 index 00000000000..2993ab858c7 --- /dev/null +++ b/test/cli/samples/config-import-attributes-key/rollup.config.ts @@ -0,0 +1,8 @@ +import foo from './foo.json' with { type: 'json' }; + +export default { + input: `${foo.name}.js`, + output: { + format: 'cjs', + } +}; diff --git a/test/cli/samples/config-import-meta/_config.js b/test/cli/samples/config-import-meta/_config.js index 241b4c526db..e44297ef689 100644 --- a/test/cli/samples/config-import-meta/_config.js +++ b/test/cli/samples/config-import-meta/_config.js @@ -1,4 +1,4 @@ -module.exports = { - description: 'uses correct import.meta.url in config files', - command: 'rollup -c' -}; +module.exports = defineTest({ + description: 'uses correct import.meta.{url,filename,dirname} in config files', + spawnArgs: ['-c', '--bundleConfigAsCjs'] +}); diff --git a/test/cli/samples/config-import-meta/plugin/plugin.js b/test/cli/samples/config-import-meta/plugin/plugin.js index c6d15f8db0b..29f042c94b2 100644 --- a/test/cli/samples/config-import-meta/plugin/plugin.js +++ b/test/cli/samples/config-import-meta/plugin/plugin.js @@ -9,6 +9,8 @@ const fileName = `test.txt`; function validateImportMeta(importMeta) { assert.strictEqual(importMeta.url, import.meta.url); + assert.strictEqual(importMeta.filename, import.meta.filename); + assert.strictEqual(importMeta.dirname, import.meta.dirname); } validateImportMeta(import.meta); diff --git a/test/cli/samples/config-json/_config.js b/test/cli/samples/config-json/_config.js index 64763fb55cf..2234f82d09c 100644 --- a/test/cli/samples/config-json/_config.js +++ b/test/cli/samples/config-json/_config.js @@ -1,5 +1,5 @@ -module.exports = { +module.exports = defineTest({ description: 'allows config file to import json', - command: 'rollup --config rollup.config.js', + spawnArgs: ['--config', 'rollup.config.js', '--bundleConfigAsCjs'], execute: true -}; +}); diff --git a/test/cli/samples/config-json/rollup.config.js b/test/cli/samples/config-json/rollup.config.js index 1e08c7bbf5a..38f31b74264 100644 --- a/test/cli/samples/config-json/rollup.config.js +++ b/test/cli/samples/config-json/rollup.config.js @@ -1,12 +1,10 @@ import replace from '@rollup/plugin-replace'; -import pkg from './package.json'; +import package_ from './package.json'; module.exports = { input: 'main.js', output: { format: 'cjs' }, - plugins: [ - replace( { '__VERSION__': pkg.version } ) - ] + plugins: [replace({ preventAssignment: true, __VERSION__: package_.version })] }; diff --git a/test/cli/samples/config-missing-export/_config.js b/test/cli/samples/config-missing-export/_config.js index 13e2fc2dff1..ddd555d8427 100644 --- a/test/cli/samples/config-missing-export/_config.js +++ b/test/cli/samples/config-missing-export/_config.js @@ -1,9 +1,9 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'throws error if config does not export an object', - command: 'rollup -c', - error(err) { - assert.ok(/Config file must export an options object/.test(err.message)); + spawnArgs: ['-c'], + error(error) { + assert.ok(/Config file must export an options object/.test(error.message)); } -}; +}); diff --git a/test/cli/samples/config-mjs-plugins/_config.js b/test/cli/samples/config-mjs-plugins/_config.js index e12031215b1..d77cae455f8 100644 --- a/test/cli/samples/config-mjs-plugins/_config.js +++ b/test/cli/samples/config-mjs-plugins/_config.js @@ -1,5 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'supports native esm as well as CJS plugins when using .mjs in Node 13+', - minNodeVersion: 13, - command: 'rollup -c' -}; + spawnArgs: ['-c'] +}); diff --git a/test/cli/samples/config-mjs-plugins/nested/plugin.mjs b/test/cli/samples/config-mjs-plugins/nested/plugin.mjs index 7ecc957ef55..f88eb31677b 100644 --- a/test/cli/samples/config-mjs-plugins/nested/plugin.mjs +++ b/test/cli/samples/config-mjs-plugins/nested/plugin.mjs @@ -3,7 +3,7 @@ import { fileURLToPath } from 'url'; export default () => ({ transform(code) { - return `console.log('${relative(process.cwd(), fileURLToPath(import.meta.url)).replace( + return `#!/usr/bin/env node\nconsole.log('${relative(process.cwd(), fileURLToPath(import.meta.url)).replace( '\\', '/' )}');\n${code}`; diff --git a/test/cli/samples/config-mjs-plugins/rollup.config.mjs b/test/cli/samples/config-mjs-plugins/rollup.config.mjs index 86e5ecb4155..c1caeb3483c 100644 --- a/test/cli/samples/config-mjs-plugins/rollup.config.mjs +++ b/test/cli/samples/config-mjs-plugins/rollup.config.mjs @@ -1,12 +1,9 @@ -// This is a CJS plugin -import replace from '@rollup/plugin-replace/dist/rollup-plugin-replace.cjs.js'; -// This is an ESM plugin -import { shebang } from 'rollup-plugin-thatworks'; +import replace from '@rollup/plugin-replace'; import nestedPlugin from './nested/plugin.mjs'; import plugin from './plugin.mjs'; export default { input: 'main.js', output: { format: 'cjs', exports: 'auto' }, - plugins: [shebang(), replace({ ANSWER: 42 }), plugin(), nestedPlugin()] + plugins: [replace({ preventAssignment: true, ANSWER: 42 }), plugin(), nestedPlugin()] }; diff --git a/test/cli/samples/config-mjs/_config.js b/test/cli/samples/config-mjs/_config.js index bd9fe8544ed..49bb8e1dbbb 100644 --- a/test/cli/samples/config-mjs/_config.js +++ b/test/cli/samples/config-mjs/_config.js @@ -1,5 +1,5 @@ -module.exports = { +module.exports = defineTest({ description: 'uses config file (.mjs)', - command: 'rollup --config rollup.config.mjs', + spawnArgs: ['--config', 'rollup.config.mjs'], execute: true -}; +}); diff --git a/test/cli/samples/config-mjs/rollup.config.mjs b/test/cli/samples/config-mjs/rollup.config.mjs index 1e3dc16035d..7474272d592 100644 --- a/test/cli/samples/config-mjs/rollup.config.mjs +++ b/test/cli/samples/config-mjs/rollup.config.mjs @@ -6,6 +6,6 @@ export default { format: 'cjs' }, plugins: [ - replace( { ANSWER: 42 } ) + replace( { preventAssignment: true, ANSWER: 42 } ) ] }; diff --git a/test/cli/samples/config-multiple-getfilename/_config.js b/test/cli/samples/config-multiple-getfilename/_config.js index 842113b93e1..a7a18e4f5d8 100644 --- a/test/cli/samples/config-multiple-getfilename/_config.js +++ b/test/cli/samples/config-multiple-getfilename/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'returns correct file names for multiple outputs (#3467)', - command: 'rollup -c' -}; + spawnArgs: ['-c'] +}); diff --git a/test/cli/samples/config-multiple-getfilename/_expected/es-main.js b/test/cli/samples/config-multiple-getfilename/_expected/es-main.js index d862de816a3..c3e30233192 100644 --- a/test/cli/samples/config-multiple-getfilename/_expected/es-main.js +++ b/test/cli/samples/config-multiple-getfilename/_expected/es-main.js @@ -1,3 +1,3 @@ var main = 42; -export default main; +export { main as default }; diff --git a/test/cli/samples/config-multiple-getfilename/rollup.config.js b/test/cli/samples/config-multiple-getfilename/rollup.config.js deleted file mode 100644 index bbce2e4c07d..00000000000 --- a/test/cli/samples/config-multiple-getfilename/rollup.config.js +++ /dev/null @@ -1,31 +0,0 @@ -let fileReference; - -export default { - input: 'main.js', - plugins: { - name: 'test', - buildStart() { - fileReference = this.emitFile({ type: 'chunk', id: 'main.js' }); - }, - generateBundle(options) { - this.emitFile({ - type: 'asset', - fileName: `${options.format}.txt`, - source: this.getFileName(fileReference), - }); - }, - }, - output: [ - { - format: 'es', - dir: '_actual', - entryFileNames: 'es-[name].js', - }, - { - format: 'cjs', - dir: '_actual', - entryFileNames: 'cjs-[name].js', - exports: 'auto' - }, - ], -}; diff --git a/test/cli/samples/config-multiple-getfilename/rollup.config.mjs b/test/cli/samples/config-multiple-getfilename/rollup.config.mjs new file mode 100644 index 00000000000..b6395b304b5 --- /dev/null +++ b/test/cli/samples/config-multiple-getfilename/rollup.config.mjs @@ -0,0 +1,31 @@ +let fileReference; + +export default { + input: 'main.js', + plugins: { + name: 'test', + buildStart() { + fileReference = this.emitFile({ type: 'chunk', id: 'main.js' }); + }, + generateBundle(options) { + this.emitFile({ + type: 'asset', + fileName: `${options.format}.txt`, + source: this.getFileName(fileReference) + }); + } + }, + output: [ + { + format: 'es', + dir: '_actual', + entryFileNames: 'es-[name].js' + }, + { + format: 'cjs', + dir: '_actual', + entryFileNames: 'cjs-[name].js', + exports: 'auto' + } + ] +}; diff --git a/test/cli/samples/config-multiple-source-maps/_config.js b/test/cli/samples/config-multiple-source-maps/_config.js index a91d466ccdc..43619a694b0 100644 --- a/test/cli/samples/config-multiple-source-maps/_config.js +++ b/test/cli/samples/config-multiple-source-maps/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'correctly generates sourcemaps for multiple outputs', - command: 'rollup -c' -}; + spawnArgs: ['-c', '--bundleConfigAsCjs'] +}); diff --git a/test/cli/samples/config-multiple-source-maps/rollup.config.js b/test/cli/samples/config-multiple-source-maps/rollup.config.js index db2092f239e..8aac1159fd3 100644 --- a/test/cli/samples/config-multiple-source-maps/rollup.config.js +++ b/test/cli/samples/config-multiple-source-maps/rollup.config.js @@ -5,7 +5,7 @@ export default { format: 'cjs', dir: '_actual', entryFileNames: '[name]-[format].js', - sourcemap: true, + sourcemap: true }, { format: 'es', diff --git a/test/cli/samples/config-no-module/_config.js b/test/cli/samples/config-no-module/_config.js deleted file mode 100644 index e481b95c1b4..00000000000 --- a/test/cli/samples/config-no-module/_config.js +++ /dev/null @@ -1,17 +0,0 @@ -const { assertIncludes } = require('../../../utils.js'); - -module.exports = { - description: 'provides a helpful error message if a transpiled config is interpreted as "module"', - minNodeVersion: 13, - command: 'cd sub && rollup -c', - error: () => true, - stderr: stderr => - assertIncludes( - stderr, - '[!] Error: While loading the Rollup configuration from "rollup.config.js", Node tried to require an ES module from a CommonJS ' + - 'file, which is not supported. A common cause is if there is a package.json file with "type": "module" in the same folder. You can ' + - 'try to fix this by changing the extension of your configuration file to ".cjs" or ".mjs" depending on the content, which will ' + - 'prevent Rollup from trying to preprocess the file but rather hand it to Node directly.\n' + - 'https://rollupjs.org/guide/en/#using-untranspiled-config-files' - ) -}; diff --git a/test/cli/samples/config-no-module/sub/rollup.config.js b/test/cli/samples/config-no-module/sub/rollup.config.js deleted file mode 100644 index 28f443866ee..00000000000 --- a/test/cli/samples/config-no-module/sub/rollup.config.js +++ /dev/null @@ -1,7 +0,0 @@ -import { shebang } from 'rollup-plugin-thatworks'; - -export default { - input: 'main.js', - output: { format: 'cjs' }, - plugins: [shebang()] -}; diff --git a/test/cli/samples/config-no-output/_config.js b/test/cli/samples/config-no-output/_config.js index e01213244c1..a62c935b968 100644 --- a/test/cli/samples/config-no-output/_config.js +++ b/test/cli/samples/config-no-output/_config.js @@ -1,12 +1,12 @@ -const fs = require('fs'); -const assert = require('assert'); +const assert = require('node:assert'); +const { readFileSync, unlinkSync } = require('node:fs'); -module.exports = { +module.exports = defineTest({ description: 'uses -o from CLI', - command: 'rollup -c -o output.js', + spawnArgs: ['-c', '-o', 'output.js'], test() { - const output = fs.readFileSync('output.js', 'utf-8'); + const output = readFileSync('output.js', 'utf8'); assert.equal(output.trim(), 'console.log(42);'); - fs.unlinkSync('output.js'); + unlinkSync('output.js'); } -}; +}); diff --git a/test/cli/samples/config-no-output/rollup.config.js b/test/cli/samples/config-no-output/rollup.config.js deleted file mode 100644 index deb82a90ffe..00000000000 --- a/test/cli/samples/config-no-output/rollup.config.js +++ /dev/null @@ -1,6 +0,0 @@ -export default { - input: 'main.js', - output: { - format: 'es' - } -}; \ No newline at end of file diff --git a/test/cli/samples/config-no-output/rollup.config.mjs b/test/cli/samples/config-no-output/rollup.config.mjs new file mode 100644 index 00000000000..d804b11cdfc --- /dev/null +++ b/test/cli/samples/config-no-output/rollup.config.mjs @@ -0,0 +1,6 @@ +export default { + input: 'main.js', + output: { + format: 'es' + } +}; diff --git a/test/cli/samples/config-override/_config.js b/test/cli/samples/config-override/_config.js index 49fc4811440..e7c310cd5fe 100644 --- a/test/cli/samples/config-override/_config.js +++ b/test/cli/samples/config-override/_config.js @@ -1,5 +1,5 @@ -module.exports = { +module.exports = defineTest({ description: 'overrides config file with command line arguments', - command: 'rollup -c -i main.js -f cjs', + spawnArgs: ['-c', '-i', 'main.js', '-f', 'cjs'], execute: true -}; +}); diff --git a/test/cli/samples/config-override/rollup.config.js b/test/cli/samples/config-override/rollup.config.js deleted file mode 100644 index 23ce9173133..00000000000 --- a/test/cli/samples/config-override/rollup.config.js +++ /dev/null @@ -1,11 +0,0 @@ -import replace from '@rollup/plugin-replace'; - -export default { - input: 'nope.js', - output: { - format: 'amd' - }, - plugins: [ - replace( { 'ANSWER': 42 } ) - ] -}; diff --git a/test/cli/samples/config-override/rollup.config.mjs b/test/cli/samples/config-override/rollup.config.mjs new file mode 100644 index 00000000000..c72b224a7db --- /dev/null +++ b/test/cli/samples/config-override/rollup.config.mjs @@ -0,0 +1,9 @@ +import replace from '@rollup/plugin-replace'; + +export default { + input: 'nope.js', + output: { + format: 'amd' + }, + plugins: [replace({ preventAssignment: true, ANSWER: 42 })] +}; diff --git a/test/cli/samples/config-plugin-entry/_config.js b/test/cli/samples/config-plugin-entry/_config.js index 87345ed15e9..d6121f65903 100644 --- a/test/cli/samples/config-plugin-entry/_config.js +++ b/test/cli/samples/config-plugin-entry/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'allows plugins to set options.entry', - command: 'rollup -c' -}; + spawnArgs: ['-c', '--bundleConfigAsCjs'] +}); diff --git a/test/cli/samples/config-plugin-entry/rollup.config.js b/test/cli/samples/config-plugin-entry/rollup.config.js index 0688f0c1e4d..dcbd3f02d09 100644 --- a/test/cli/samples/config-plugin-entry/rollup.config.js +++ b/test/cli/samples/config-plugin-entry/rollup.config.js @@ -4,8 +4,8 @@ export default { }, plugins: [ { - options: opts => { - opts.input = 'main.js'; + options: options => { + options.input = 'main.js'; } } ] diff --git a/test/cli/samples/config-promise-cjs/_config.js b/test/cli/samples/config-promise-cjs/_config.js index 75219d417ed..7dad793af3d 100644 --- a/test/cli/samples/config-promise-cjs/_config.js +++ b/test/cli/samples/config-promise-cjs/_config.js @@ -1,5 +1,5 @@ -module.exports = { +module.exports = defineTest({ description: 'uses cjs config file which returns a Promise', - command: 'rollup --config rollup.config.cjs', + spawnArgs: ['--config', 'rollup.config.cjs'], execute: true -}; +}); diff --git a/test/cli/samples/config-promise-cjs/rollup.config.cjs b/test/cli/samples/config-promise-cjs/rollup.config.cjs index e9f06d4fe87..6927f51a9f2 100644 --- a/test/cli/samples/config-promise-cjs/rollup.config.cjs +++ b/test/cli/samples/config-promise-cjs/rollup.config.cjs @@ -5,5 +5,5 @@ module.exports = Promise.resolve({ output: { format: 'cjs' }, - plugins: [replace({ ANSWER: 42 })] + plugins: [replace({ preventAssignment: true, ANSWER: 42 })] }); diff --git a/test/cli/samples/config-promise-mjs/_config.js b/test/cli/samples/config-promise-mjs/_config.js index 7cfdef3e2d7..df2a615fc71 100644 --- a/test/cli/samples/config-promise-mjs/_config.js +++ b/test/cli/samples/config-promise-mjs/_config.js @@ -1,6 +1,5 @@ -module.exports = { +module.exports = defineTest({ description: 'uses mjs config file which returns a Promise', - minNodeVersion: 13, - command: 'rollup --config rollup.config.mjs', + spawnArgs: ['--config', 'rollup.config.mjs'], execute: true -}; +}); diff --git a/test/cli/samples/config-promise-mjs/rollup.config.mjs b/test/cli/samples/config-promise-mjs/rollup.config.mjs index 1fbb95608c9..8af5a348936 100644 --- a/test/cli/samples/config-promise-mjs/rollup.config.mjs +++ b/test/cli/samples/config-promise-mjs/rollup.config.mjs @@ -5,5 +5,5 @@ export default Promise.resolve({ output: { format: 'cjs' }, - plugins: [replace({ ANSWER: 42 })] + plugins: [replace({ preventAssignment: true, ANSWER: 42 })] }); diff --git a/test/cli/samples/config-promise/_config.js b/test/cli/samples/config-promise/_config.js index 395579ed8ee..a9ce7a232e0 100644 --- a/test/cli/samples/config-promise/_config.js +++ b/test/cli/samples/config-promise/_config.js @@ -1,5 +1,5 @@ -module.exports = { +module.exports = defineTest({ description: 'uses config file which returns a Promise', - command: 'rollup --config rollup.config.js', + spawnArgs: ['--config', 'rollup.config.mjs'], execute: true -}; +}); diff --git a/test/cli/samples/config-promise/rollup.config.js b/test/cli/samples/config-promise/rollup.config.mjs similarity index 100% rename from test/cli/samples/config-promise/rollup.config.js rename to test/cli/samples/config-promise/rollup.config.mjs diff --git a/test/cli/samples/config-true/_config.js b/test/cli/samples/config-true/_config.js index 95252f58d24..5fcd4bf1f2c 100644 --- a/test/cli/samples/config-true/_config.js +++ b/test/cli/samples/config-true/_config.js @@ -1,5 +1,5 @@ -module.exports = { +module.exports = defineTest({ description: 'defaults to rollup.config.js', - command: 'rollup -c', + spawnArgs: ['-c', '--bundleConfigAsCjs'], execute: true -}; +}); diff --git a/test/cli/samples/config-true/rollup.config.js b/test/cli/samples/config-true/rollup.config.js index 7e55ade7fe9..dee04a33fb1 100644 --- a/test/cli/samples/config-true/rollup.config.js +++ b/test/cli/samples/config-true/rollup.config.js @@ -5,7 +5,5 @@ export default { output: { format: 'cjs' }, - plugins: [ - replace( { 'ANSWER': 42 } ) - ] + plugins: [replace({ preventAssignment: true, ANSWER: 42 })] }; diff --git a/test/cli/samples/config-ts-with-workspace-refs/_config.js b/test/cli/samples/config-ts-with-workspace-refs/_config.js new file mode 100644 index 00000000000..f91a9578d33 --- /dev/null +++ b/test/cli/samples/config-ts-with-workspace-refs/_config.js @@ -0,0 +1,5 @@ +module.exports = defineTest({ + description: 'supports loading TypeScript config files referencing workspace projects', + spawnArgs: ['--config', 'rollup.config.ts', '--configPlugin', 'typescript'], + execute: false +}); diff --git a/test/cli/samples/config-ts-with-workspace-refs/_expected.js b/test/cli/samples/config-ts-with-workspace-refs/_expected.js new file mode 100644 index 00000000000..cc1d88a24fa --- /dev/null +++ b/test/cli/samples/config-ts-with-workspace-refs/_expected.js @@ -0,0 +1 @@ +assert.ok(true); diff --git a/test/cli/samples/config-ts-with-workspace-refs/input.js b/test/cli/samples/config-ts-with-workspace-refs/input.js new file mode 100644 index 00000000000..cc1d88a24fa --- /dev/null +++ b/test/cli/samples/config-ts-with-workspace-refs/input.js @@ -0,0 +1 @@ +assert.ok(true); diff --git a/test/cli/samples/config-ts-with-workspace-refs/node_modules/referenced-link b/test/cli/samples/config-ts-with-workspace-refs/node_modules/referenced-link new file mode 120000 index 00000000000..9fdaedb4fd6 --- /dev/null +++ b/test/cli/samples/config-ts-with-workspace-refs/node_modules/referenced-link @@ -0,0 +1 @@ +../packages/referenced \ No newline at end of file diff --git a/test/cli/samples/config-ts-with-workspace-refs/packages/referenced/index.ts b/test/cli/samples/config-ts-with-workspace-refs/packages/referenced/index.ts new file mode 100644 index 00000000000..bc33164ac00 --- /dev/null +++ b/test/cli/samples/config-ts-with-workspace-refs/packages/referenced/index.ts @@ -0,0 +1,8 @@ +import type { RollupOptions } from '../../../../../../dist/rollup'; + +export const MY_CUSTOM_OPTIONS: RollupOptions = { + input: 'input.js', + output: { + format: 'esm', + } +}; diff --git a/test/cli/samples/config-ts-with-workspace-refs/packages/referenced/package.json b/test/cli/samples/config-ts-with-workspace-refs/packages/referenced/package.json new file mode 100644 index 00000000000..c0b7a316979 --- /dev/null +++ b/test/cli/samples/config-ts-with-workspace-refs/packages/referenced/package.json @@ -0,0 +1,3 @@ +{ + "main": "index.ts" +} \ No newline at end of file diff --git a/test/cli/samples/config-ts-with-workspace-refs/rollup.config.ts b/test/cli/samples/config-ts-with-workspace-refs/rollup.config.ts new file mode 100644 index 00000000000..00d67a64225 --- /dev/null +++ b/test/cli/samples/config-ts-with-workspace-refs/rollup.config.ts @@ -0,0 +1,3 @@ +import { MY_CUSTOM_OPTIONS } from "referenced-link"; + +export default MY_CUSTOM_OPTIONS; diff --git a/test/cli/samples/config-ts/_config.js b/test/cli/samples/config-ts/_config.js new file mode 100644 index 00000000000..f2626cd15a7 --- /dev/null +++ b/test/cli/samples/config-ts/_config.js @@ -0,0 +1,5 @@ +module.exports = defineTest({ + description: 'supports loading TypeScript config files via plugin option', + spawnArgs: ['--config', 'rollup.config.ts', '--configPlugin', 'typescript'], + execute: true +}); diff --git a/test/cli/samples/config-ts/main.js b/test/cli/samples/config-ts/main.js new file mode 100644 index 00000000000..e37ed30c344 --- /dev/null +++ b/test/cli/samples/config-ts/main.js @@ -0,0 +1 @@ +assert.ok( true ); diff --git a/test/cli/samples/config-ts/rollup.config.ts b/test/cli/samples/config-ts/rollup.config.ts new file mode 100644 index 00000000000..33f98d1b575 --- /dev/null +++ b/test/cli/samples/config-ts/rollup.config.ts @@ -0,0 +1,10 @@ +import { RollupOptions } from '../../../../dist/rollup'; + +const options: RollupOptions = { + input: 'main.js', + output: { + format: 'cjs' + } +}; + +export { options as default }; diff --git a/test/cli/samples/config-type-module/_config.js b/test/cli/samples/config-type-module/_config.js new file mode 100644 index 00000000000..83d7df4ad7d --- /dev/null +++ b/test/cli/samples/config-type-module/_config.js @@ -0,0 +1,19 @@ +// @ts-expect-error not included in types +const { assertIncludes } = require('../../../testHelpers.js'); + +module.exports = defineTest({ + description: 'tries to load .js config file if package type is "module"', + command: 'cd sub && rollup -c rollup.config.js', + error: () => true, + stderr: stderr => { + assertIncludes( + stderr, + 'Original error: module is not defined in ES module scope\n' + + "This file is being treated as an ES module because it has a '.js' file extension and" + ); + assertIncludes( + stderr, + 'contains "type": "module". To treat it as a CommonJS script, rename it to use the \'.cjs\' file extension.' + ); + } +}); diff --git a/test/cli/samples/config-type-module/sub/main.js b/test/cli/samples/config-type-module/sub/main.js new file mode 100644 index 00000000000..753a47d529e --- /dev/null +++ b/test/cli/samples/config-type-module/sub/main.js @@ -0,0 +1 @@ +console.log(42); diff --git a/test/cli/samples/config-no-module/sub/package.json b/test/cli/samples/config-type-module/sub/package.json similarity index 100% rename from test/cli/samples/config-no-module/sub/package.json rename to test/cli/samples/config-type-module/sub/package.json diff --git a/test/cli/samples/config-type-module/sub/rollup.config.js b/test/cli/samples/config-type-module/sub/rollup.config.js new file mode 100644 index 00000000000..d3fce68c3a7 --- /dev/null +++ b/test/cli/samples/config-type-module/sub/rollup.config.js @@ -0,0 +1,6 @@ +module.exports = { + input: 'main.js', + output: { + format: 'cjs' + } +}; diff --git a/test/cli/samples/config-warnings/_config.js b/test/cli/samples/config-warnings/_config.js index e7177b4ca90..f8fa19c8d0f 100644 --- a/test/cli/samples/config-warnings/_config.js +++ b/test/cli/samples/config-warnings/_config.js @@ -1,11 +1,11 @@ -const { assertIncludes } = require('../../../utils.js'); +const { assertIncludes } = require('../../../testHelpers.js'); -module.exports = { +module.exports = defineTest({ description: 'displays warnings when a config is loaded', - command: 'rollup -c', + spawnArgs: ['-c', '--bundleConfigAsCjs'], stderr: stderr => assertIncludes( stderr, 'loaded rollup.config.js with warnings\n(!) Use of eval is strongly discouraged' ) -}; +}); diff --git a/test/cli/samples/config/_config.js b/test/cli/samples/config/_config.js index 4dff8e5be22..7378d46554d 100644 --- a/test/cli/samples/config/_config.js +++ b/test/cli/samples/config/_config.js @@ -1,5 +1,5 @@ -module.exports = { +module.exports = defineTest({ description: 'uses config file', - command: 'rollup --config rollup.config.js', + spawnArgs: ['--config', 'rollup.config.js'], execute: true -}; +}); diff --git a/test/cli/samples/config/rollup.config.js b/test/cli/samples/config/rollup.config.js index 997b775f21c..f39a8930bd4 100644 --- a/test/cli/samples/config/rollup.config.js +++ b/test/cli/samples/config/rollup.config.js @@ -1,11 +1,9 @@ -var replace = require( '@rollup/plugin-replace' ); +var replace = require('@rollup/plugin-replace'); module.exports = { input: 'main.js', output: { format: 'cjs' }, - plugins: [ - replace( { 'ANSWER': 42 } ) - ] + plugins: [replace({ preventAssignment: true, ANSWER: 42 })] }; diff --git a/test/cli/samples/context/_config.js b/test/cli/samples/context/_config.js index 9f2d46d6667..3054807c06e 100644 --- a/test/cli/samples/context/_config.js +++ b/test/cli/samples/context/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'Uses --context to set `this` value', - command: 'rollup main.js --format commonjs --context window' -}; + spawnArgs: ['main.js', '--format', 'commonjs', '--context', 'window'] +}); diff --git a/test/cli/samples/context/_expected.js b/test/cli/samples/context/_expected.js index 882cf0cbf21..53752c4dfa7 100644 --- a/test/cli/samples/context/_expected.js +++ b/test/cli/samples/context/_expected.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - console.log(window); const foo = 42; diff --git a/test/cli/samples/custom-frame-with-pos/_config.js b/test/cli/samples/custom-frame-with-pos/_config.js index e778c6418a4..690dde174c7 100644 --- a/test/cli/samples/custom-frame-with-pos/_config.js +++ b/test/cli/samples/custom-frame-with-pos/_config.js @@ -1,15 +1,12 @@ -const { assertIncludes } = require('../../../utils.js'); +const { assertIncludes } = require('../../../testHelpers.js'); -module.exports = { +module.exports = defineTest({ description: 'custom (plugin generated) code frame taking priority over pos generated one', - command: 'rollup -c', + spawnArgs: ['-c'], error: () => true, stderr: stderr => assertIncludes( stderr, - '[!] (plugin at position 1) Error: My error.\n' + - 'main.js (1:5)\n' + - 'custom code frame\n' + - 'Error: My error.' + '[!] (plugin at position 1) Error: My error.\n' + 'main.js (1:5)\n' + 'custom code frame\n' ) -}; +}); diff --git a/test/cli/samples/custom-frame-with-pos/rollup.config.js b/test/cli/samples/custom-frame-with-pos/rollup.config.js index 16a980820f6..f1cb4456284 100644 --- a/test/cli/samples/custom-frame-with-pos/rollup.config.js +++ b/test/cli/samples/custom-frame-with-pos/rollup.config.js @@ -6,13 +6,13 @@ module.exports = { plugins: [ { transform() { - const err = new Error('My error.'); - err.frame = 'custom code frame'; - this.error(err, { + const error = new Error('My error.'); + error.frame = 'custom code frame'; + this.error(error, { line: 1, - column: 5, + column: 5 }); } - }, + } ] }; diff --git a/test/cli/samples/custom-frame/_config.js b/test/cli/samples/custom-frame/_config.js index 7999022fd71..5ef900a9190 100644 --- a/test/cli/samples/custom-frame/_config.js +++ b/test/cli/samples/custom-frame/_config.js @@ -1,16 +1,16 @@ -const { assertIncludes } = require('../../../utils.js'); +const { assertIncludes } = require('../../../testHelpers.js'); -module.exports = { +module.exports = defineTest({ description: 'errors with plugin generated code frames also contain stack', - command: 'rollup -c', + spawnArgs: ['-c'], error: () => true, stderr: stderr => { assertIncludes( stderr, '[!] (plugin at position 1) Error: My error.\n' + - 'main.js\ncustom code frame\nError: My error.\n' + - ' at Object.transform' + 'main.js\ncustom code frame\n' + + ' at Object.' ); - assertIncludes(stderr, 'rollup.config.js:11:17'); + assertIncludes(stderr, 'rollup.config.js:9:19'); } -}; +}); diff --git a/test/cli/samples/custom-frame/rollup.config.js b/test/cli/samples/custom-frame/rollup.config.js index dcf59c3105a..bdd07cc900d 100644 --- a/test/cli/samples/custom-frame/rollup.config.js +++ b/test/cli/samples/custom-frame/rollup.config.js @@ -6,10 +6,10 @@ module.exports = { plugins: [ { transform() { - const err = new Error('My error.'); - err.frame = 'custom code frame'; - this.error(err); + const error = new Error('My error.'); + error.frame = 'custom code frame'; + this.error(error); } - }, + } ] }; diff --git a/test/cli/samples/deconflict-entry-point-in-subdir/_config.js b/test/cli/samples/deconflict-entry-point-in-subdir/_config.js index e45bfaeb3b0..9e1f600e202 100644 --- a/test/cli/samples/deconflict-entry-point-in-subdir/_config.js +++ b/test/cli/samples/deconflict-entry-point-in-subdir/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'deconflict entry points with the same name in different directories', - command: 'rollup --input main.js --input sub/main.js --format es --dir _actual' -}; + spawnArgs: ['--input', 'main.js', '--input', 'sub/main.js', '--format', 'es', '--dir', '_actual'] +}); diff --git a/test/cli/samples/duplicate-import-options/_config.js b/test/cli/samples/duplicate-import-options/_config.js index 14ff13ae654..b8033715828 100644 --- a/test/cli/samples/duplicate-import-options/_config.js +++ b/test/cli/samples/duplicate-import-options/_config.js @@ -1,10 +1,10 @@ -const { assertIncludes } = require('../../../utils.js'); +const { assertIncludes } = require('../../../testHelpers.js'); -module.exports = { +module.exports = defineTest({ description: 'throws if different types of entries are combined', - command: 'rollup main.js --format es --input main.js', + spawnArgs: ['main.js', '--format', 'es', '--input', 'main.js'], error: () => true, stderr(stderr) { assertIncludes(stderr, '[!] Either use --input, or pass input path as argument'); } -}; +}); diff --git a/test/cli/samples/emit-file-multiple-dirs/_config.js b/test/cli/samples/emit-file-multiple-dirs/_config.js index 34c81bf123b..35c393811b6 100644 --- a/test/cli/samples/emit-file-multiple-dirs/_config.js +++ b/test/cli/samples/emit-file-multiple-dirs/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'writes files emitted by plugins in different output dirs', - command: 'rollup -c' -}; + spawnArgs: ['-c'] +}); diff --git a/test/cli/samples/emit-file-multiple-dirs/rollup.config.js b/test/cli/samples/emit-file-multiple-dirs/rollup.config.js deleted file mode 100644 index 416e64898e3..00000000000 --- a/test/cli/samples/emit-file-multiple-dirs/rollup.config.js +++ /dev/null @@ -1,18 +0,0 @@ -export default { - input: "main.js", - output: [ - { - dir: "_actual/dist1", - format: "cjs" - }, - { - dir: "_actual/dist2", - format: "es" - } - ], - plugins: [{ - generateBundle() { - this.emitFile({type: "asset", fileName: "myfile", source: "abc"}) - } - }] -} diff --git a/test/cli/samples/emit-file-multiple-dirs/rollup.config.mjs b/test/cli/samples/emit-file-multiple-dirs/rollup.config.mjs new file mode 100644 index 00000000000..590fadf49c3 --- /dev/null +++ b/test/cli/samples/emit-file-multiple-dirs/rollup.config.mjs @@ -0,0 +1,20 @@ +export default { + input: 'main.js', + output: [ + { + dir: '_actual/dist1', + format: 'cjs' + }, + { + dir: '_actual/dist2', + format: 'es' + } + ], + plugins: [ + { + generateBundle() { + this.emitFile({ type: 'asset', fileName: 'myfile', source: 'abc' }); + } + } + ] +}; diff --git a/test/cli/samples/empty-chunk-multiple/_config.js b/test/cli/samples/empty-chunk-multiple/_config.js index d20e2f09500..9d0efc86b82 100644 --- a/test/cli/samples/empty-chunk-multiple/_config.js +++ b/test/cli/samples/empty-chunk-multiple/_config.js @@ -1,8 +1,8 @@ -const { assertIncludes } = require('../../../utils.js'); +const { assertIncludes } = require('../../../testHelpers.js'); -module.exports = { +module.exports = defineTest({ description: 'shows warning when multiple chunks empty', - command: 'rollup -c', + spawnArgs: ['-c'], error: () => true, - stderr: stderr => assertIncludes(stderr, '(!) Generated empty chunks\na, b') -}; + stderr: stderr => assertIncludes(stderr, '(!) Generated empty chunks\n"main1" and "main2"') +}); diff --git a/test/cli/samples/empty-chunk-multiple/main.js b/test/cli/samples/empty-chunk-multiple/main.js deleted file mode 100644 index f0bdb216130..00000000000 --- a/test/cli/samples/empty-chunk-multiple/main.js +++ /dev/null @@ -1,2 +0,0 @@ -import('./a.js'); -import('./b.js'); diff --git a/test/cli/samples/empty-chunk-multiple/b.js b/test/cli/samples/empty-chunk-multiple/main1.js similarity index 100% rename from test/cli/samples/empty-chunk-multiple/b.js rename to test/cli/samples/empty-chunk-multiple/main1.js diff --git a/test/function/samples/add-watch-file-generate/watched.js b/test/cli/samples/empty-chunk-multiple/main2.js similarity index 100% rename from test/function/samples/add-watch-file-generate/watched.js rename to test/cli/samples/empty-chunk-multiple/main2.js diff --git a/test/cli/samples/empty-chunk-multiple/rollup.config.js b/test/cli/samples/empty-chunk-multiple/rollup.config.js index d3fce68c3a7..7120b077ccf 100644 --- a/test/cli/samples/empty-chunk-multiple/rollup.config.js +++ b/test/cli/samples/empty-chunk-multiple/rollup.config.js @@ -1,5 +1,5 @@ module.exports = { - input: 'main.js', + input: ['main1.js', 'main2.js'], output: { format: 'cjs' } diff --git a/test/cli/samples/empty-chunk/_config.js b/test/cli/samples/empty-chunk/_config.js index 29694a07f72..c90d6e5ea51 100644 --- a/test/cli/samples/empty-chunk/_config.js +++ b/test/cli/samples/empty-chunk/_config.js @@ -1,8 +1,8 @@ -const { assertIncludes } = require('../../../utils.js'); +const { assertIncludes } = require('../../../testHelpers.js'); -module.exports = { +module.exports = defineTest({ description: 'shows warning when chunk empty', - command: 'rollup -c', + spawnArgs: ['-c'], error: () => true, - stderr: stderr => assertIncludes(stderr, '(!) Generated an empty chunk\nmain') -}; + stderr: stderr => assertIncludes(stderr, '(!) Generated an empty chunk\n"main"') +}); diff --git a/test/cli/samples/external-modules-auto-global/_config.js b/test/cli/samples/external-modules-auto-global/_config.js index 8163c5ad414..cf804d3018b 100644 --- a/test/cli/samples/external-modules-auto-global/_config.js +++ b/test/cli/samples/external-modules-auto-global/_config.js @@ -1,11 +1,18 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'populates options.external with --global keys', - command: - 'rollup main.js --format iife --globals mathematics:Math,promises:Promise --external promises', + spawnArgs: [ + 'main.js', + '--format', + 'iife', + '--globals', + 'mathematics:Math,promises:Promise', + '--external', + 'promises' + ], execute: true, stderr(stderr) { - assert.strictEqual(stderr.indexOf('(!)'), -1); + assert.ok(!stderr.includes('(!)')); } -}; +}); diff --git a/test/cli/samples/external-modules/_config.js b/test/cli/samples/external-modules/_config.js index dbae8e93f67..8710294fc27 100644 --- a/test/cli/samples/external-modules/_config.js +++ b/test/cli/samples/external-modules/_config.js @@ -1,10 +1,10 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'allows external modules to be specified with --external=foo,bar,baz', - command: 'rollup main.js --format cjs --external=path,util', + spawnArgs: ['main.js', '--format', 'cjs', '--external=path,util'], execute: true, stderr(stderr) { - assert.strictEqual(stderr.indexOf('(!)'), -1); + assert.ok(!stderr.includes('(!)')); } -}; +}); diff --git a/test/cli/samples/fail-after-warnings/_config.js b/test/cli/samples/fail-after-warnings/_config.js index a525e9eb155..9d3e9f0eb92 100644 --- a/test/cli/samples/fail-after-warnings/_config.js +++ b/test/cli/samples/fail-after-warnings/_config.js @@ -1,11 +1,11 @@ -const { assertIncludes } = require('../../../utils.js'); +const { assertIncludes } = require('../../../testHelpers.js'); -module.exports = { +module.exports = defineTest({ description: 'errors on warnings with --failAfterWarnings', - command: 'rollup -i main.js --failAfterWarnings', + spawnArgs: ['-i', 'main.js', '--failAfterWarnings'], error: () => true, stderr: stderr => { assertIncludes(stderr, '[!] Warnings occurred and --failAfterWarnings flag present'); return true; } -}; +}); diff --git a/test/cli/samples/filter-logs/_config.js b/test/cli/samples/filter-logs/_config.js new file mode 100644 index 00000000000..d1428e20978 --- /dev/null +++ b/test/cli/samples/filter-logs/_config.js @@ -0,0 +1,28 @@ +const assert = require('node:assert'); + +module.exports = defineTest({ + description: 'filters logs via CLI', + spawnArgs: [ + '--config', + '--filterLogs="pluginCode:FIRST,pluginCode:SECOND"', + '--filterLogs=pluginCode:THIRD' + ], + env: { + FORCE_COLOR: undefined, + NO_COLOR: true, + ROLLUP_FILTER_LOGS: 'pluginCode:FOURTH,pluginCode:FIFTH' + }, + stderr(stderr) { + assert.strictEqual( + stderr, + ` +main.js → stdout... +[plugin test] first +[plugin test] second +[plugin test] third +[plugin test] fourth +[plugin test] fifth +` + ); + } +}); diff --git a/test/cli/samples/filter-logs/main.js b/test/cli/samples/filter-logs/main.js new file mode 100644 index 00000000000..e37ed30c344 --- /dev/null +++ b/test/cli/samples/filter-logs/main.js @@ -0,0 +1 @@ +assert.ok( true ); diff --git a/test/cli/samples/filter-logs/rollup.config.mjs b/test/cli/samples/filter-logs/rollup.config.mjs new file mode 100644 index 00000000000..1aeaf461d3d --- /dev/null +++ b/test/cli/samples/filter-logs/rollup.config.mjs @@ -0,0 +1,21 @@ +export default { + input: 'main.js', + logLevel: 'debug', + plugins: [ + { + name: 'test', + buildStart() { + this.info({message: 'removed', pluginCode: 'REMOVED'}); + this.info({message: 'first', pluginCode: 'FIRST'}); + this.info({message: 'second', pluginCode: 'SECOND'}); + this.info({message: 'third', pluginCode: 'THIRD'}); + this.info({message: 'fourth', pluginCode: 'FOURTH'}); + this.info({message: 'fifth', pluginCode: 'FIFTH'}); + this.info({message: 'filtered', pluginCode: 'FILTERED'}); + }, + } + ], + output: { + format: 'es' + } +}; diff --git a/test/cli/samples/filter-logs/wrapper.js b/test/cli/samples/filter-logs/wrapper.js new file mode 100755 index 00000000000..355d81420fa --- /dev/null +++ b/test/cli/samples/filter-logs/wrapper.js @@ -0,0 +1,4 @@ +#!/usr/bin/env node + +process.stdout.isTTY = true; +require('../../../../dist/bin/rollup'); diff --git a/test/cli/samples/force-exit/_config.js b/test/cli/samples/force-exit/_config.js new file mode 100644 index 00000000000..65c47a209b5 --- /dev/null +++ b/test/cli/samples/force-exit/_config.js @@ -0,0 +1,4 @@ +module.exports = defineTest({ + description: 'force exits even with open handles', + spawnArgs: ['--config', 'rollup.config.js', '--forceExit'] +}); diff --git a/test/cli/samples/force-exit/_expected.js b/test/cli/samples/force-exit/_expected.js new file mode 100644 index 00000000000..bb06158e22d --- /dev/null +++ b/test/cli/samples/force-exit/_expected.js @@ -0,0 +1,2 @@ +console.log('ok'); + diff --git a/test/cli/samples/force-exit/main.js b/test/cli/samples/force-exit/main.js new file mode 100644 index 00000000000..37108886b56 --- /dev/null +++ b/test/cli/samples/force-exit/main.js @@ -0,0 +1 @@ +console.log('ok'); diff --git a/test/cli/samples/force-exit/rollup.config.js b/test/cli/samples/force-exit/rollup.config.js new file mode 100644 index 00000000000..fabd38cfe9b --- /dev/null +++ b/test/cli/samples/force-exit/rollup.config.js @@ -0,0 +1,16 @@ +module.exports = { + input: 'main.js', + onwarn(warning) { + throw new Error(`Unexpected warning: ${warning.message}`); + }, + plugins: [ + { + name: 'open-handles', + buildStart() { + setInterval(() => { + // hang forever + }, 2 ** 24); + } + } + ] +}; diff --git a/test/cli/samples/format-aliases/_config.js b/test/cli/samples/format-aliases/_config.js index f9f9d685f72..6b3a5ecf4d0 100644 --- a/test/cli/samples/format-aliases/_config.js +++ b/test/cli/samples/format-aliases/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'supports format aliases', - command: 'rollup --config' -}; + spawnArgs: ['--config'] +}); diff --git a/test/cli/samples/format-aliases/_expected/amd.js b/test/cli/samples/format-aliases/_expected/amd.js index caabb39724c..7ba10bc5c83 100644 --- a/test/cli/samples/format-aliases/_expected/amd.js +++ b/test/cli/samples/format-aliases/_expected/amd.js @@ -1,18 +1,7 @@ -define(['exports', 'external'], function (exports, external) { 'use strict'; - - function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } - - var external__default = /*#__PURE__*/_interopDefaultLegacy(external); +define(['exports', 'external'], (function (exports, external) { 'use strict'; console.log('main'); - Object.defineProperty(exports, 'value', { - enumerable: true, - get: function () { - return external__default['default']; - } - }); - - Object.defineProperty(exports, '__esModule', { value: true }); + exports.value = external; -}); +})); diff --git a/test/cli/samples/format-aliases/_expected/cjs.js b/test/cli/samples/format-aliases/_expected/cjs.js index 38846076ad5..fffa8f1676f 100644 --- a/test/cli/samples/format-aliases/_expected/cjs.js +++ b/test/cli/samples/format-aliases/_expected/cjs.js @@ -1,18 +1,7 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - var external = require('external'); -function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } - -var external__default = /*#__PURE__*/_interopDefaultLegacy(external); - console.log('main'); -Object.defineProperty(exports, 'value', { - enumerable: true, - get: function () { - return external__default['default']; - } -}); +exports.value = external; diff --git a/test/cli/samples/format-aliases/_expected/commonjs.js b/test/cli/samples/format-aliases/_expected/commonjs.js index 38846076ad5..fffa8f1676f 100644 --- a/test/cli/samples/format-aliases/_expected/commonjs.js +++ b/test/cli/samples/format-aliases/_expected/commonjs.js @@ -1,18 +1,7 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - var external = require('external'); -function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } - -var external__default = /*#__PURE__*/_interopDefaultLegacy(external); - console.log('main'); -Object.defineProperty(exports, 'value', { - enumerable: true, - get: function () { - return external__default['default']; - } -}); +exports.value = external; diff --git a/test/cli/samples/format-aliases/_expected/iife.js b/test/cli/samples/format-aliases/_expected/iife.js index 5a80cd67764..666d2511e3c 100644 --- a/test/cli/samples/format-aliases/_expected/iife.js +++ b/test/cli/samples/format-aliases/_expected/iife.js @@ -1,21 +1,10 @@ var bundle = (function (exports, external) { 'use strict'; - function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } - - var external__default = /*#__PURE__*/_interopDefaultLegacy(external); - console.log('main'); - Object.defineProperty(exports, 'value', { - enumerable: true, - get: function () { - return external__default['default']; - } - }); - - Object.defineProperty(exports, '__esModule', { value: true }); + exports.value = external; return exports; -}({}, external)); +})({}, external); diff --git a/test/cli/samples/format-aliases/_expected/system.js b/test/cli/samples/format-aliases/_expected/system.js index 4a614a259f8..2592f2affd5 100644 --- a/test/cli/samples/format-aliases/_expected/system.js +++ b/test/cli/samples/format-aliases/_expected/system.js @@ -1,13 +1,13 @@ -System.register('bundle', ['external'], function (exports) { +System.register('bundle', ['external'], (function (exports) { 'use strict'; return { setters: [function (module) { - exports('value', module.default); + exports("value", module.default); }], - execute: function () { + execute: (function () { console.log('main'); - } + }) }; -}); +})); diff --git a/test/cli/samples/format-aliases/_expected/systemjs.js b/test/cli/samples/format-aliases/_expected/systemjs.js index 4a614a259f8..2592f2affd5 100644 --- a/test/cli/samples/format-aliases/_expected/systemjs.js +++ b/test/cli/samples/format-aliases/_expected/systemjs.js @@ -1,13 +1,13 @@ -System.register('bundle', ['external'], function (exports) { +System.register('bundle', ['external'], (function (exports) { 'use strict'; return { setters: [function (module) { - exports('value', module.default); + exports("value", module.default); }], - execute: function () { + execute: (function () { console.log('main'); - } + }) }; -}); +})); diff --git a/test/cli/samples/format-aliases/_expected/umd.js b/test/cli/samples/format-aliases/_expected/umd.js index 5a2f0ade3fd..0047ebd22ad 100644 --- a/test/cli/samples/format-aliases/_expected/umd.js +++ b/test/cli/samples/format-aliases/_expected/umd.js @@ -2,21 +2,10 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('external')) : typeof define === 'function' && define.amd ? define(['exports', 'external'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.bundle = {}, global.external)); -}(this, (function (exports, external) { 'use strict'; - - function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } - - var external__default = /*#__PURE__*/_interopDefaultLegacy(external); +})(this, (function (exports, external) { 'use strict'; console.log('main'); - Object.defineProperty(exports, 'value', { - enumerable: true, - get: function () { - return external__default['default']; - } - }); - - Object.defineProperty(exports, '__esModule', { value: true }); + exports.value = external; -}))); +})); diff --git a/test/cli/samples/format-aliases/rollup.config.js b/test/cli/samples/format-aliases/rollup.config.mjs similarity index 100% rename from test/cli/samples/format-aliases/rollup.config.js rename to test/cli/samples/format-aliases/rollup.config.mjs diff --git a/test/cli/samples/generated-code-preset-override/_config.js b/test/cli/samples/generated-code-preset-override/_config.js new file mode 100644 index 00000000000..768144d83a9 --- /dev/null +++ b/test/cli/samples/generated-code-preset-override/_config.js @@ -0,0 +1,4 @@ +module.exports = defineTest({ + description: 'overrides the generatedCode option when using presets', + spawnArgs: ['--config', '--generatedCode', 'es5', '--generatedCode.arrowFunctions'] +}); diff --git a/test/cli/samples/generated-code-preset-override/_expected.js b/test/cli/samples/generated-code-preset-override/_expected.js new file mode 100644 index 00000000000..f82a98ff1a0 --- /dev/null +++ b/test/cli/samples/generated-code-preset-override/_expected.js @@ -0,0 +1,13 @@ +System.register(['external'], (function (exports) { + 'use strict'; + return { + setters: [module => { + exports("baz", module.baz); + }], + execute: (function () { + + const foo = 1; exports({ bar: foo, default: foo, foo: foo }); + + }) + }; +})); diff --git a/test/cli/samples/generated-code-preset-override/main.js b/test/cli/samples/generated-code-preset-override/main.js new file mode 100644 index 00000000000..809d1ad15e3 --- /dev/null +++ b/test/cli/samples/generated-code-preset-override/main.js @@ -0,0 +1,3 @@ +export { baz } from 'external'; +const foo = 1; +export { foo, foo as bar, foo as default }; diff --git a/test/cli/samples/generated-code-preset-override/rollup.config.mjs b/test/cli/samples/generated-code-preset-override/rollup.config.mjs new file mode 100644 index 00000000000..e58de8bb6b5 --- /dev/null +++ b/test/cli/samples/generated-code-preset-override/rollup.config.mjs @@ -0,0 +1,11 @@ +export default { + input: 'main.js', + output: { + format: 'system', + generatedCode: { + arrowFunctions: true, + objectShorthand: true, + reservedNamesAsProps: false + } + } +}; diff --git a/test/cli/samples/generated-code-unknown-preset/_config.js b/test/cli/samples/generated-code-unknown-preset/_config.js new file mode 100644 index 00000000000..5aceae08b04 --- /dev/null +++ b/test/cli/samples/generated-code-unknown-preset/_config.js @@ -0,0 +1,14 @@ +const { assertIncludes } = require('../../../testHelpers.js'); + +module.exports = defineTest({ + description: 'overrides the generatedCode option when using presets', + spawnArgs: ['main.js', '--format', 'es', '--generatedCode', 'unknown'], + error: () => true, + stderr: stderr => { + assertIncludes( + stderr, + '[!] RollupError: Invalid value "unknown" for option "output.generatedCode" - valid values are "es2015" and "es5". You can also supply an object for more fine-grained control.\n' + + 'https://rollupjs.org/configuration-options/#output-generatedcode' + ); + } +}); diff --git a/test/cli/samples/generated-code-unknown-preset/main.js b/test/cli/samples/generated-code-unknown-preset/main.js new file mode 100644 index 00000000000..c0b933d7b56 --- /dev/null +++ b/test/cli/samples/generated-code-unknown-preset/main.js @@ -0,0 +1 @@ +console.log('main'); diff --git a/test/cli/samples/get-chunk-name/_config.js b/test/cli/samples/get-chunk-name/_config.js new file mode 100644 index 00000000000..be7700785e0 --- /dev/null +++ b/test/cli/samples/get-chunk-name/_config.js @@ -0,0 +1,11 @@ +const assert = require('node:assert'); +module.exports = defineTest({ + description: 'get right chunk name for preserve modules', + spawnArgs: ['-c'], + result(code) { + assert.ok( + code.includes(`//→ ${__dirname.replace(/^(\/|[a-zA-Z]:\\)/, '').replace(/\\/g, '/')}/main.js`) + ); + assert.ok(code.includes(`//→ sub.js`)); + } +}); diff --git a/test/cli/samples/get-chunk-name/main.js b/test/cli/samples/get-chunk-name/main.js new file mode 100644 index 00000000000..63cd1928dd3 --- /dev/null +++ b/test/cli/samples/get-chunk-name/main.js @@ -0,0 +1,2 @@ +import sub from '/sub.js'; +assert.ok(sub); diff --git a/test/cli/samples/get-chunk-name/rollup.config.mjs b/test/cli/samples/get-chunk-name/rollup.config.mjs new file mode 100644 index 00000000000..511c0dd2d13 --- /dev/null +++ b/test/cli/samples/get-chunk-name/rollup.config.mjs @@ -0,0 +1,21 @@ +export default { + input: 'main.js', + output: { + format: 'es', + preserveModules: true + }, + plugins: [ + { + resolveId(id) { + if (id.endsWith('sub.js')) { + return id; + } + }, + load(id) { + if (id.endsWith('sub.js')) { + return 'export default "sub.js url"'; + } + } + } + ] +}; diff --git a/test/cli/samples/handles-errors-cause/_config.js b/test/cli/samples/handles-errors-cause/_config.js new file mode 100644 index 00000000000..3de5e91034e --- /dev/null +++ b/test/cli/samples/handles-errors-cause/_config.js @@ -0,0 +1,14 @@ +const { assertIncludes } = require('../../../testHelpers.js'); + +module.exports = defineTest({ + description: 'prints error cause', + spawnArgs: ['--config', 'rollup.config.mjs'], + // We expect an error and want to make assertions about the output + error: () => true, + stderr: stderr => { + // We just assert the parts of the output that do not change + assertIncludes(stderr, '\n[!] (plugin at position 1) Error: Outer error\n at '); + assertIncludes(stderr, '\n [cause] Error: Inner error\n at '); + assertIncludes(stderr, '\n [cause] Error: Innermost error\n at '); + } +}); diff --git a/test/cli/samples/handles-errors-cause/main.js b/test/cli/samples/handles-errors-cause/main.js new file mode 100644 index 00000000000..de87bba6701 --- /dev/null +++ b/test/cli/samples/handles-errors-cause/main.js @@ -0,0 +1 @@ +assert.ok(true); \ No newline at end of file diff --git a/test/cli/samples/handles-errors-cause/rollup.config.mjs b/test/cli/samples/handles-errors-cause/rollup.config.mjs new file mode 100644 index 00000000000..8e783b3d305 --- /dev/null +++ b/test/cli/samples/handles-errors-cause/rollup.config.mjs @@ -0,0 +1,14 @@ +export default { + input: "main.js", + plugins: [ + { + buildStart() { + throw new Error("Outer error", { + cause: new Error("Inner error", { + cause: new Error("Innermost error") + }) + }); + } + } + ] +}; diff --git a/test/cli/samples/handles-uncaught-errors-under-watch/_config.js b/test/cli/samples/handles-uncaught-errors-under-watch/_config.js new file mode 100644 index 00000000000..d4541beb2f3 --- /dev/null +++ b/test/cli/samples/handles-uncaught-errors-under-watch/_config.js @@ -0,0 +1,10 @@ +const { assertIncludes } = require('../../../testHelpers.js'); + +module.exports = defineTest({ + description: 'handles uncaught errors under watch', + spawnArgs: ['--config', 'rollup.config.js', '-w'], + error: () => true, + stderr(stderr) { + assertIncludes(stderr, 'Uncaught RollupError: [plugin test] LOL'); + } +}); diff --git a/test/cli/samples/handles-uncaught-errors-under-watch/main.js b/test/cli/samples/handles-uncaught-errors-under-watch/main.js new file mode 100644 index 00000000000..fd53873812e --- /dev/null +++ b/test/cli/samples/handles-uncaught-errors-under-watch/main.js @@ -0,0 +1 @@ +assert.equal( 42, 42 ); diff --git a/test/cli/samples/handles-uncaught-errors-under-watch/rollup.config.js b/test/cli/samples/handles-uncaught-errors-under-watch/rollup.config.js new file mode 100644 index 00000000000..efa2872d942 --- /dev/null +++ b/test/cli/samples/handles-uncaught-errors-under-watch/rollup.config.js @@ -0,0 +1,16 @@ +module.exports = { + input: 'main.js', + output: { + format: 'es' + }, + plugins: [ + { + name: 'test', + buildStart() { + Promise.resolve().then(() => { + this.error('LOL'); + }); + } + } + ] +}; diff --git a/test/cli/samples/handles-uncaught-errors/_config.js b/test/cli/samples/handles-uncaught-errors/_config.js new file mode 100644 index 00000000000..9c0289c67d4 --- /dev/null +++ b/test/cli/samples/handles-uncaught-errors/_config.js @@ -0,0 +1,10 @@ +const { assertIncludes } = require('../../../testHelpers.js'); + +module.exports = defineTest({ + description: 'handles uncaught errors', + spawnArgs: ['--config', 'rollup.config.js'], + error: () => true, + stderr(stderr) { + assertIncludes(stderr, 'TypeError: foo'); + } +}); diff --git a/test/cli/samples/handles-uncaught-errors/main.js b/test/cli/samples/handles-uncaught-errors/main.js new file mode 100644 index 00000000000..fd53873812e --- /dev/null +++ b/test/cli/samples/handles-uncaught-errors/main.js @@ -0,0 +1 @@ +assert.equal( 42, 42 ); diff --git a/test/cli/samples/handles-uncaught-errors/rollup.config.js b/test/cli/samples/handles-uncaught-errors/rollup.config.js new file mode 100644 index 00000000000..b1370c7df91 --- /dev/null +++ b/test/cli/samples/handles-uncaught-errors/rollup.config.js @@ -0,0 +1,16 @@ +module.exports = { + input: 'main.js', + output: { + format: 'cjs' + }, + plugins: [ + { + name: 'test', + buildStart() { + Promise.resolve().then(() => { + throw new TypeError('foo'); + }); + } + } + ] +}; diff --git a/test/cli/samples/help/_config.js b/test/cli/samples/help/_config.js new file mode 100644 index 00000000000..db030e2484a --- /dev/null +++ b/test/cli/samples/help/_config.js @@ -0,0 +1,14 @@ +const { readFileSync } = require('node:fs'); +const { join } = require('node:path'); +const assert = require('node:assert'); + +module.exports = defineTest({ + description: 'displays the help text', + spawnArgs: ['--help'], + result(stdout) { + const [firstLine, ...restLines] = stdout.trim().split('\n'); + assert.match(firstLine, /^rollup version \d+\.\d+\.\d+(-\d+)?$/); + const expected = readFileSync(join(__dirname, '_expected'), 'utf8'); + assert.equal([...restLines].join('\n'), expected.trim()); + } +}); diff --git a/test/cli/samples/help/_expected b/test/cli/samples/help/_expected new file mode 100644 index 00000000000..388ecfadb60 --- /dev/null +++ b/test/cli/samples/help/_expected @@ -0,0 +1,128 @@ +===================================== + +Usage: rollup [options] + +Options: + +-c, --config Use this config file (if argument is used but value + is unspecified, Rollup will try to load configuration files in + the following order: + rollup.config.mjs -> rollup.config.cjs -> rollup.config.js) +-d, --dir Directory for chunks (if absent, prints to stdout) +-e, --external Comma-separate list of module IDs to exclude +-f, --format Type of output (amd, cjs, es, iife, umd, system) +-g, --globals Comma-separate list of `moduleID:Global` pairs +-h, --help Show this help message +-i, --input Input (alternative to ) +-m, --sourcemap Generate sourcemap (`-m inline` for inline map) +-n, --name Name for UMD export +-o, --file Single output file (if absent, prints to stdout) +-p, --plugin Use the plugin specified (may be repeated) +-v, --version Show version number +-w, --watch Watch files in bundle and rebuild on changes +--amd.autoId Generate the AMD ID based off the chunk name +--amd.basePath Path to prepend to auto generated AMD ID +--amd.define Function to use in place of `define` +--amd.forceJsExtensionForImports Use `.js` extension in AMD imports +--amd.id ID for AMD module (default is anonymous) +--assetFileNames Name pattern for emitted assets +--banner Code to insert at top of bundle (outside wrapper) +--chunkFileNames Name pattern for emitted secondary chunks +--compact Minify wrapper code +--context Specify top-level `this` value +--no-dynamicImportInCjs Write external dynamic CommonJS imports as require +--entryFileNames Name pattern for emitted entry chunks +--environment Settings passed to config file (see example) +--no-esModule Do not add __esModule property +--exports Specify export mode (auto, default, named, none) +--extend Extend global variable defined by --name +--no-externalImportAttributes Omit import attributes in "es" output +--no-externalLiveBindings Do not generate code to support live bindings +--failAfterWarnings Exit with an error if the build produced warnings +--filterLogs Filter log messages +--footer Code to insert at end of bundle (outside wrapper) +--forceExit Force exit the process when done +--no-freeze Do not freeze namespace objects +--generatedCode Which code features to use (es5/es2015) +--generatedCode.arrowFunctions Use arrow functions in generated code +--generatedCode.constBindings Use "const" in generated code +--generatedCode.objectShorthand Use shorthand properties in generated code +--no-generatedCode.reservedNamesAsProps Always quote reserved names as props +--generatedCode.symbols Use symbols in generated code +--hashCharacters Use the specified character set for file hashes +--no-hoistTransitiveImports Do not hoist transitive imports into entry chunks +--importAttributesKey Use the specified keyword for import attributes +--no-indent Don't indent result +--inlineDynamicImports Create single bundle when using dynamic imports +--no-interop Do not include interop block +--intro Code to insert at top of bundle (inside wrapper) +--logLevel Which kind of logs to display +--no-makeAbsoluteExternalsRelative Prevent normalization of external imports +--maxParallelFileOps How many files to read in parallel +--minifyInternalExports Force or disable minification of internal exports +--noConflict Generate a noConflict method for UMD globals +--outro Code to insert at end of bundle (inside wrapper) +--perf Display performance timings +--no-preserveEntrySignatures Avoid facade chunks for entry points +--preserveModules Preserve module structure +--preserveModulesRoot Put preserved modules under this path at root level +--preserveSymlinks Do not follow symlinks when resolving files +--no-reexportProtoFromExternal Ignore `__proto__` in star re-exports +--no-sanitizeFileName Do not replace invalid characters in file names +--shimMissingExports Create shim variables for missing exports +--silent Don't print warnings +--sourcemapBaseUrl Emit absolute sourcemap URLs with given base +--sourcemapDebugIds Emit unique debug ids in source and sourcemaps +--sourcemapExcludeSources Do not include source code in source maps +--sourcemapFile Specify bundle position for source maps +--sourcemapFileNames Name pattern for emitted sourcemaps +--stdin=ext Specify file extension used for stdin input +--no-stdin Do not read "-" from stdin +--no-strict Don't emit `"use strict";` in the generated modules +--strictDeprecations Throw errors for deprecated features +--no-systemNullSetters Do not replace empty SystemJS setters with `null` +--no-treeshake Disable tree-shaking optimisations +--no-treeshake.annotations Ignore pure call annotations +--treeshake.correctVarValueBeforeDeclaration Deoptimize variables until declared +--treeshake.manualPureFunctions Manually declare functions as pure +--no-treeshake.moduleSideEffects Assume modules have no side effects +--no-treeshake.propertyReadSideEffects Ignore property access side effects +--no-treeshake.tryCatchDeoptimization Do not turn off try-catch-tree-shaking +--no-treeshake.unknownGlobalSideEffects Assume unknown globals do not throw +--validate Validate output +--waitForBundleInput Wait for bundle input files +--watch.allowInputInsideOutputPath Whether the input path is allowed to be a + subpath of the output path +--watch.buildDelay Throttle watch rebuilds +--no-watch.clearScreen Do not clear the screen when rebuilding +--watch.exclude Exclude files from being watched +--watch.include Limit watching to specified files +--watch.onBundleEnd Shell command to run on `"BUNDLE_END"` event +--watch.onBundleStart Shell command to run on `"BUNDLE_START"` event +--watch.onEnd Shell command to run on `"END"` event +--watch.onError Shell command to run on `"ERROR"` event +--watch.onStart Shell command to run on `"START"` event +--watch.skipWrite Do not write files to disk when watching + +Examples: + +# use settings in config file +rollup -c + +# in config file, process.env.INCLUDE_DEPS === 'true' +# and process.env.BUILD === 'production' +rollup -c --environment INCLUDE_DEPS,BUILD:production + +# create CommonJS bundle.js from src/main.js +rollup --format=cjs --file=bundle.js -- src/main.js + +# create self-executing IIFE using `window.jQuery` +# and `window._` as external globals +rollup -f iife --globals jquery:jQuery,lodash:_ \ + -i src/app.js -o build/app.js -m build/app.js.map + +Notes: + +* When piping to stdout, only inline sourcemaps are permitted + +For more information visit https://rollupjs.org diff --git a/test/cli/samples/import-esm-package/_config.js b/test/cli/samples/import-esm-package/_config.js new file mode 100644 index 00000000000..5ea07946a47 --- /dev/null +++ b/test/cli/samples/import-esm-package/_config.js @@ -0,0 +1,5 @@ +module.exports = defineTest({ + description: 'allows to import ESM dependencies from transpiled config files', + skipIfWindows: true, + spawnArgs: ['--config', '--configPlugin', '{transform:c => c}'] +}); diff --git a/test/cli/samples/import-esm-package/_expected/main.js b/test/cli/samples/import-esm-package/_expected/main.js new file mode 100644 index 00000000000..9a8209b3ccd --- /dev/null +++ b/test/cli/samples/import-esm-package/_expected/main.js @@ -0,0 +1,2 @@ +/* esm-default */ +assert.ok(true); diff --git a/test/cli/samples/import-esm-package/main.js b/test/cli/samples/import-esm-package/main.js new file mode 100644 index 00000000000..cc1d88a24fa --- /dev/null +++ b/test/cli/samples/import-esm-package/main.js @@ -0,0 +1 @@ +assert.ok(true); diff --git a/test/cli/samples/import-esm-package/rollup.config.js b/test/cli/samples/import-esm-package/rollup.config.js new file mode 100644 index 00000000000..0a38f897471 --- /dev/null +++ b/test/cli/samples/import-esm-package/rollup.config.js @@ -0,0 +1,10 @@ +import esmDep from 'esm-dep'; + +export default { + input: 'main.js', + output: { + banner: `/* ${esmDep} */`, + format: 'es', + dir: '_actual' + } +}; diff --git a/test/cli/samples/indent-none/_config.js b/test/cli/samples/indent-none/_config.js index e37aead6bc1..a1118217774 100644 --- a/test/cli/samples/indent-none/_config.js +++ b/test/cli/samples/indent-none/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'disables indentation with --no-indent', - command: 'rollup main.js --format umd --no-indent' -}; + spawnArgs: ['main.js', '--format', 'umd', '--no-indent'] +}); diff --git a/test/cli/samples/indent-none/_expected.js b/test/cli/samples/indent-none/_expected.js index dcb207285e0..28a3046a85c 100644 --- a/test/cli/samples/indent-none/_expected.js +++ b/test/cli/samples/indent-none/_expected.js @@ -1,8 +1,8 @@ (function (factory) { typeof define === 'function' && define.amd ? define(factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; assert.equal( 1 + 1, 2 ); -}))); +})); diff --git a/test/cli/samples/interop/_config.js b/test/cli/samples/interop/_config.js index 2e1b21bdbf9..dd6c02e09c1 100644 --- a/test/cli/samples/interop/_config.js +++ b/test/cli/samples/interop/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'does not include the interop block', - command: 'rollup -i main.js -f cjs --external test --no-interop' -}; + spawnArgs: ['-i', 'main.js', '-f', 'cjs', '--external', 'test', '--interop', 'default'] +}); diff --git a/test/cli/samples/jsx/_config.js b/test/cli/samples/jsx/_config.js new file mode 100644 index 00000000000..1b0bef3d13a --- /dev/null +++ b/test/cli/samples/jsx/_config.js @@ -0,0 +1,4 @@ +module.exports = defineTest({ + description: 'supports jsx presets via CLI', + spawnArgs: ['-i', 'main.js', '--jsx', 'react', '--external', 'react'] +}); diff --git a/test/cli/samples/jsx/_expected.js b/test/cli/samples/jsx/_expected.js new file mode 100644 index 00000000000..abf18f99bc1 --- /dev/null +++ b/test/cli/samples/jsx/_expected.js @@ -0,0 +1,3 @@ +import react from 'react'; + +console.log(/*#__PURE__*/react.createElement("div", null, "Hello, world!")); diff --git a/test/cli/samples/jsx/main.js b/test/cli/samples/jsx/main.js new file mode 100644 index 00000000000..877d1e6d90b --- /dev/null +++ b/test/cli/samples/jsx/main.js @@ -0,0 +1,2 @@ +import React from 'react'; +console.log(
Hello, world!
); diff --git a/test/cli/samples/log-side-effects/_config.js b/test/cli/samples/log-side-effects/_config.js new file mode 100644 index 00000000000..f9baf1cb1df --- /dev/null +++ b/test/cli/samples/log-side-effects/_config.js @@ -0,0 +1,37 @@ +const path = require('node:path'); +const { assertIncludes } = require('../../../testHelpers.js'); + +module.exports = defineTest({ + description: 'logs side effects', + spawnArgs: ['--config'], + env: { FORCE_COLOR: undefined, NO_COLOR: true }, + stderr: stderr => + assertIncludes( + stderr.replaceAll(__dirname + path.sep, 'CWD/'), + `dep-mapped.js (1:0): First side effect in dep-mapped.js is at (2:26) +1: const removed = true; +2: const alsoRemoved = true; console.log('mapped effect'); + ^ +CWD/dep-mapped.js:1:0 +1: console.log('mapped effect'); + ^ +dep-long-line.js (1:126): First side effect in dep-long-line.js is at (1:126) +1: /* This side effect is deeply hidden inside a very long line, beyond the 120-character limit that we impose for truncation */ console.lo... + ^ +CWD/dep-long-line.js:1:126 +1: /* This side effect is deeply hidden inside a very long line, beyond the 120-character limit that we impose for truncation */ console.lo... + ^ +main.js (3:0): First side effect in main.js is at (3:0) +1: import './dep-mapped'; +2: import './dep-long-line'; +3: console.log('main effect'); + ^ +4: console.log('other effect'); +CWD/main.js:3:0 +1: import './dep-mapped'; +2: import './dep-long-line'; +3: console.log('main effect'); + ^ +4: console.log('other effect');` + ) +}); diff --git a/test/cli/samples/log-side-effects/dep-long-line.js b/test/cli/samples/log-side-effects/dep-long-line.js new file mode 100644 index 00000000000..6e58e0f260a --- /dev/null +++ b/test/cli/samples/log-side-effects/dep-long-line.js @@ -0,0 +1 @@ +/* This side effect is deeply hidden inside a very long line, beyond the 120-character limit that we impose for truncation */ console.log('mapped effect'); /* and there is more on this line */ diff --git a/test/cli/samples/log-side-effects/dep-mapped.js b/test/cli/samples/log-side-effects/dep-mapped.js new file mode 100644 index 00000000000..dffbed8b079 --- /dev/null +++ b/test/cli/samples/log-side-effects/dep-mapped.js @@ -0,0 +1 @@ +console.log('mapped effect'); diff --git a/test/cli/samples/log-side-effects/main.js b/test/cli/samples/log-side-effects/main.js new file mode 100644 index 00000000000..14f67f27761 --- /dev/null +++ b/test/cli/samples/log-side-effects/main.js @@ -0,0 +1,4 @@ +import './dep-mapped'; +import './dep-long-line'; +console.log('main effect'); +console.log('other effect'); diff --git a/test/cli/samples/log-side-effects/rollup.config.mjs b/test/cli/samples/log-side-effects/rollup.config.mjs new file mode 100644 index 00000000000..c4748763a33 --- /dev/null +++ b/test/cli/samples/log-side-effects/rollup.config.mjs @@ -0,0 +1,18 @@ +import MagicString from 'magic-string'; + +export default { + input: 'main.js', + experimentalLogSideEffects: true, + plugins: [ + { + name: 'insert-lines', + transform(code, id) { + if (id.endsWith('mapped.js')) { + const magicString = new MagicString(code); + magicString.prepend('const removed = true;\nconst alsoRemoved = true; '); + return { code: magicString.toString(), map: magicString.generateMap({ hires: true }) }; + } + } + } + ] +}; diff --git a/test/cli/samples/logs/_config.js b/test/cli/samples/logs/_config.js new file mode 100644 index 00000000000..45e64bdde9a --- /dev/null +++ b/test/cli/samples/logs/_config.js @@ -0,0 +1,40 @@ +const assert = require('node:assert'); +const path = require('node:path'); + +const BOLD = '\u001B[1m'; +const BLUE = '\u001B[34m'; +const CYAN = '\u001B[36m'; +const GRAY = '\u001B[90m'; +const NOCOLOR = '\u001B[39m'; +const REGULAR = '\u001B[22m'; + +module.exports = defineTest({ + description: 'displays logs', + skipIfWindows: true, + spawnArgs: ['--config'], + env: { FORCE_COLOR: '1', TERM: 'xterm' }, + stderr(stderr) { + assert.strictEqual( + stderr.replaceAll(__dirname + path.sep, 'CWD/'), + `${CYAN} +${BOLD}main.js${REGULAR} → ${BOLD}stdout${REGULAR}...${NOCOLOR} +${BOLD}${CYAN}[plugin test] simple-info${NOCOLOR}${REGULAR} +${BOLD}${CYAN}[plugin test] complex-info${NOCOLOR}${REGULAR} +${GRAY}https://my-url.net${NOCOLOR} +${BOLD}${BLUE}[plugin test] simple-debug${NOCOLOR}${REGULAR} +${BOLD}${BLUE}[plugin test] complex-debug${NOCOLOR}${REGULAR} +${GRAY}https://my-url.net${NOCOLOR} +${BOLD}${CYAN}[plugin test] main.js (1:12): transform-info${NOCOLOR}${REGULAR} +${GRAY}https://my-url.net${NOCOLOR} +${BOLD}CWD/main.js:1:12${REGULAR} +${GRAY}1: assert.ok( true ); + ^${NOCOLOR} +${BOLD}${BLUE}[plugin test] main.js (1:13): transform-debug${NOCOLOR}${REGULAR} +${GRAY}https://my-url.net${NOCOLOR} +${BOLD}CWD/main.js:1:13${REGULAR} +${GRAY}1: assert.ok( true ); + ^${NOCOLOR} +` + ); + } +}); diff --git a/test/cli/samples/logs/main.js b/test/cli/samples/logs/main.js new file mode 100644 index 00000000000..e37ed30c344 --- /dev/null +++ b/test/cli/samples/logs/main.js @@ -0,0 +1 @@ +assert.ok( true ); diff --git a/test/cli/samples/logs/rollup.config.mjs b/test/cli/samples/logs/rollup.config.mjs new file mode 100644 index 00000000000..9b22386450e --- /dev/null +++ b/test/cli/samples/logs/rollup.config.mjs @@ -0,0 +1,22 @@ +export default { + input: 'main.js', + logLevel: 'debug', + plugins: [ + { + name: 'test', + buildStart() { + this.info('simple-info'); + this.info({ message: 'complex-info', url: 'https://my-url.net' }); + this.debug('simple-debug'); + this.debug({ message: 'complex-debug', url: 'https://my-url.net' }); + }, + transform() { + this.info({ message: 'transform-info', url: 'https://my-url.net' }, 12); + this.debug({ message: 'transform-debug', url: 'https://my-url.net' }, 13); + } + } + ], + output: { + format: 'es' + } +}; diff --git a/test/cli/samples/logs/wrapper.js b/test/cli/samples/logs/wrapper.js new file mode 100755 index 00000000000..355d81420fa --- /dev/null +++ b/test/cli/samples/logs/wrapper.js @@ -0,0 +1,4 @@ +#!/usr/bin/env node + +process.stdout.isTTY = true; +require('../../../../dist/bin/rollup'); diff --git a/test/cli/samples/merge-deprecations/_config.js b/test/cli/samples/merge-deprecations/_config.js index 6d0000bd4f5..2f105cee35d 100644 --- a/test/cli/samples/merge-deprecations/_config.js +++ b/test/cli/samples/merge-deprecations/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'merges deprecated with current options', - command: 'rollup --config rollup.config.js' -}; + spawnArgs: ['--config', 'rollup.config.js'] +}); diff --git a/test/cli/samples/merge-deprecations/rollup.config.js b/test/cli/samples/merge-deprecations/rollup.config.js index 58e522b6dd4..458f63928ca 100644 --- a/test/cli/samples/merge-deprecations/rollup.config.js +++ b/test/cli/samples/merge-deprecations/rollup.config.js @@ -1,4 +1,4 @@ -var replace = require( '@rollup/plugin-replace' ); +var replace = require('@rollup/plugin-replace'); module.exports = { entry: 'main.js', @@ -9,7 +9,5 @@ module.exports = { file: '_actual/bundle2.js', format: 'es' }, - plugins: [ - replace( { 'ANSWER': 42 } ) - ] + plugins: [replace({ preventAssignment: true, ANSWER: 42 })] }; diff --git a/test/cli/samples/merge-treeshake-false/_config.js b/test/cli/samples/merge-treeshake-false/_config.js index 5ae50196368..c7ce23362d1 100644 --- a/test/cli/samples/merge-treeshake-false/_config.js +++ b/test/cli/samples/merge-treeshake-false/_config.js @@ -1,5 +1,14 @@ -module.exports = { +module.exports = defineTest({ description: 'sets all tree-shaking to false if one option disables it', - command: - 'rollup main.js --format es --external external --treeshake.moduleSideEffects no-external --no-treeshake --no-treeshake.unknownGlobalSideEffects' -}; + spawnArgs: [ + 'main.js', + '--format', + 'es', + '--external', + 'external', + '--treeshake.moduleSideEffects', + 'no-external', + '--no-treeshake', + '--no-treeshake.unknownGlobalSideEffects' + ] +}); diff --git a/test/cli/samples/merge-treeshake/_config.js b/test/cli/samples/merge-treeshake/_config.js index ace0199f7d2..3e61a6277d3 100644 --- a/test/cli/samples/merge-treeshake/_config.js +++ b/test/cli/samples/merge-treeshake/_config.js @@ -1,5 +1,14 @@ -module.exports = { +module.exports = defineTest({ description: 'merges treeshake options', - command: - 'rollup main.js --format es --external external --treeshake.moduleSideEffects no-external --treeshake --no-treeshake.unknownGlobalSideEffects' -}; + spawnArgs: [ + 'main.js', + '--format', + 'es', + '--external', + 'external', + '--treeshake.moduleSideEffects', + 'no-external', + '--treeshake', + '--no-treeshake.unknownGlobalSideEffects' + ] +}); diff --git a/test/cli/samples/module-name/_config.js b/test/cli/samples/module-name/_config.js index 8b5f7e892ff..a7f9620d8de 100644 --- a/test/cli/samples/module-name/_config.js +++ b/test/cli/samples/module-name/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'generates UMD export with correct name', - command: 'rollup main.js --format umd --name myBundle --indent' -}; + spawnArgs: ['main.js', '--format', 'umd', '--name', 'myBundle', '--indent'] +}); diff --git a/test/cli/samples/module-name/_expected.js b/test/cli/samples/module-name/_expected.js index 6fa2ed81429..cd252572ff6 100644 --- a/test/cli/samples/module-name/_expected.js +++ b/test/cli/samples/module-name/_expected.js @@ -2,10 +2,10 @@ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.myBundle = factory()); -}(this, (function () { 'use strict'; +})(this, (function () { 'use strict'; var main = 42; return main; -}))); +})); diff --git a/test/cli/samples/multiple-configs/_config.js b/test/cli/samples/multiple-configs/_config.js index 844064e6cd1..b6df78d5b2a 100644 --- a/test/cli/samples/multiple-configs/_config.js +++ b/test/cli/samples/multiple-configs/_config.js @@ -1,10 +1,11 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { - description: 'generates output file when multiple configurations are specified and one build fails', - command: 'rollup -c', - error: err => { - assert.ok(/Unexpected Exception/.test(err.message)); +module.exports = defineTest({ + description: + 'generates output file when multiple configurations are specified and one build fails', + spawnArgs: ['-c'], + error: error => { + assert.ok(/Unexpected Exception/.test(error.message)); return true; } -}; +}); diff --git a/test/cli/samples/multiple-configs/rollup.config.js b/test/cli/samples/multiple-configs/rollup.config.js deleted file mode 100644 index 3b14b96a934..00000000000 --- a/test/cli/samples/multiple-configs/rollup.config.js +++ /dev/null @@ -1,20 +0,0 @@ -export default [{ - input: 'main.js', - output: { - file: '_actual/bundle1.js', - format: 'cjs', - exports: 'auto' - } -}, { - input: 'main.js', - plugins: [{ - resolveId(id) { - throw new Error("Unexpected Exception"); - } - }], - output: { - file: '_actual/bundle2.js', - format: 'cjs', - exports: 'auto' - } -}]; diff --git a/test/cli/samples/multiple-configs/rollup.config.mjs b/test/cli/samples/multiple-configs/rollup.config.mjs new file mode 100644 index 00000000000..268a9957a5e --- /dev/null +++ b/test/cli/samples/multiple-configs/rollup.config.mjs @@ -0,0 +1,25 @@ +export default [ + { + input: 'main.js', + output: { + file: '_actual/bundle1.js', + format: 'cjs', + exports: 'auto' + } + }, + { + input: 'main.js', + plugins: [ + { + resolveId(id) { + throw new Error('Unexpected Exception'); + } + } + ], + output: { + file: '_actual/bundle2.js', + format: 'cjs', + exports: 'auto' + } + } +]; diff --git a/test/cli/samples/multiple-targets-different-plugins/_config.js b/test/cli/samples/multiple-targets-different-plugins/_config.js index e9ded7da1c6..59f27ed5d81 100644 --- a/test/cli/samples/multiple-targets-different-plugins/_config.js +++ b/test/cli/samples/multiple-targets-different-plugins/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'generates multiple output files, only one of which is minified', - command: 'rollup -c' -}; + spawnArgs: ['-c'] +}); diff --git a/test/cli/samples/multiple-targets-different-plugins/rollup.config.js b/test/cli/samples/multiple-targets-different-plugins/rollup.config.js deleted file mode 100644 index 21f557756f2..00000000000 --- a/test/cli/samples/multiple-targets-different-plugins/rollup.config.js +++ /dev/null @@ -1,18 +0,0 @@ -import { terser } from 'rollup-plugin-terser'; - -export default { - input: 'main.js', - output: [ - { - format: 'cjs', - file: '_actual/main.js', - exports: 'auto' - }, - { - format: 'cjs', - file: '_actual/minified.js', - exports: 'auto', - plugins: [terser()] - } - ] -}; diff --git a/test/cli/samples/multiple-targets-different-plugins/rollup.config.mjs b/test/cli/samples/multiple-targets-different-plugins/rollup.config.mjs new file mode 100644 index 00000000000..b0046858d8c --- /dev/null +++ b/test/cli/samples/multiple-targets-different-plugins/rollup.config.mjs @@ -0,0 +1,18 @@ +import terser from '@rollup/plugin-terser'; + +export default { + input: 'main.js', + output: [ + { + format: 'cjs', + file: '_actual/main.js', + exports: 'auto' + }, + { + format: 'cjs', + file: '_actual/minified.js', + exports: 'auto', + plugins: [terser()] + } + ] +}; diff --git a/test/cli/samples/multiple-targets-shared-config/_config.js b/test/cli/samples/multiple-targets-shared-config/_config.js index 6d7125c8d54..7f4abfaf143 100644 --- a/test/cli/samples/multiple-targets-shared-config/_config.js +++ b/test/cli/samples/multiple-targets-shared-config/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'uses shared config for each target', - command: 'rollup -c' -}; + spawnArgs: ['-c'] +}); diff --git a/test/cli/samples/multiple-targets-shared-config/_expected/es.js b/test/cli/samples/multiple-targets-shared-config/_expected/es.js index 9c36d9fe10b..dfc3c74445f 100644 --- a/test/cli/samples/multiple-targets-shared-config/_expected/es.js +++ b/test/cli/samples/multiple-targets-shared-config/_expected/es.js @@ -1,4 +1,4 @@ var main = 0; -export default main; +export { main as default }; //# sourceMappingURL=es.js.map diff --git a/test/cli/samples/multiple-targets-shared-config/rollup.config.js b/test/cli/samples/multiple-targets-shared-config/rollup.config.mjs similarity index 100% rename from test/cli/samples/multiple-targets-shared-config/rollup.config.js rename to test/cli/samples/multiple-targets-shared-config/rollup.config.mjs diff --git a/test/cli/samples/multiple-targets/_config.js b/test/cli/samples/multiple-targets/_config.js index 73d5d28f379..f731f254f4a 100644 --- a/test/cli/samples/multiple-targets/_config.js +++ b/test/cli/samples/multiple-targets/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'generates multiple output files when multiple targets are specified', - command: 'rollup -c' -}; + spawnArgs: ['-c'] +}); diff --git a/test/cli/samples/multiple-targets/_expected/es.js b/test/cli/samples/multiple-targets/_expected/es.js index d3265929a72..88bc45275ad 100644 --- a/test/cli/samples/multiple-targets/_expected/es.js +++ b/test/cli/samples/multiple-targets/_expected/es.js @@ -1,3 +1,3 @@ var main = 0; -export default main; +export { main as default }; diff --git a/test/cli/samples/multiple-targets/rollup.config.js b/test/cli/samples/multiple-targets/rollup.config.mjs similarity index 100% rename from test/cli/samples/multiple-targets/rollup.config.js rename to test/cli/samples/multiple-targets/rollup.config.mjs diff --git a/test/cli/samples/no-color/_config.js b/test/cli/samples/no-color/_config.js index f9796160d46..e70e309133b 100644 --- a/test/cli/samples/no-color/_config.js +++ b/test/cli/samples/no-color/_config.js @@ -1,8 +1,8 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'respects the NO_COLOR environment variable', - command: 'rollup -i main1.js -i main2.js -f es', + spawnArgs: ['-i', 'main1.js', '-i', 'main2.js', '-f', 'es'], env: { FORCE_COLOR: undefined, NO_COLOR: true }, result(code) { assert.equal( @@ -15,4 +15,4 @@ module.exports = { "console.log('main2');\n" ); } -}; +}); diff --git a/test/cli/samples/no-conflict/_config.js b/test/cli/samples/no-conflict/_config.js index cc870f8a263..18e24e22f56 100644 --- a/test/cli/samples/no-conflict/_config.js +++ b/test/cli/samples/no-conflict/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'respects noConflict option', - command: 'rollup --config rollup.config.js' -}; + spawnArgs: ['--config', 'rollup.config.js'] +}); diff --git a/test/cli/samples/no-conflict/_expected.js b/test/cli/samples/no-conflict/_expected.js index 6eb1cdf800a..70ecd3d07bc 100644 --- a/test/cli/samples/no-conflict/_expected.js +++ b/test/cli/samples/no-conflict/_expected.js @@ -5,11 +5,11 @@ var current = global.conflictyName; var exports = global.conflictyName = factory(); exports.noConflict = function () { global.conflictyName = current; return exports; }; - }())); -}(this, (function () { 'use strict'; + })()); +})(this, (function () { 'use strict'; var main = {}; return main; -}))); \ No newline at end of file +})); \ No newline at end of file diff --git a/test/cli/samples/no-strict/_config.js b/test/cli/samples/no-strict/_config.js index 72d4a3242ee..91eca9d1235 100644 --- a/test/cli/samples/no-strict/_config.js +++ b/test/cli/samples/no-strict/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'use no strict option', - command: 'rollup -i main.js -f iife --no-strict --indent' -}; + spawnArgs: ['-i', 'main.js', '-f', 'iife', '--no-strict', '--indent'] +}); diff --git a/test/cli/samples/no-strict/_expected.js b/test/cli/samples/no-strict/_expected.js index 61893ba1ab6..df1baa1958d 100644 --- a/test/cli/samples/no-strict/_expected.js +++ b/test/cli/samples/no-strict/_expected.js @@ -2,4 +2,4 @@ console.log( 42 ); -}()); +})(); diff --git a/test/cli/samples/no-treeshake/_config.js b/test/cli/samples/no-treeshake/_config.js index 9cd57bca6ff..68632d07441 100644 --- a/test/cli/samples/no-treeshake/_config.js +++ b/test/cli/samples/no-treeshake/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'generates IIFE export with all code and overrides config', - command: 'rollup -c --no-treeshake' -}; + spawnArgs: ['-c', '--no-treeshake'] +}); diff --git a/test/cli/samples/no-treeshake/_expected.js b/test/cli/samples/no-treeshake/_expected.js index 6c3cf534143..4726b2a106d 100644 --- a/test/cli/samples/no-treeshake/_expected.js +++ b/test/cli/samples/no-treeshake/_expected.js @@ -7,4 +7,4 @@ var shakeless = (function () { return main; -}()); +})(); diff --git a/test/cli/samples/node-config-auto-prefix/_config.js b/test/cli/samples/node-config-auto-prefix/_config.js index 084ade901da..c1694984679 100644 --- a/test/cli/samples/node-config-auto-prefix/_config.js +++ b/test/cli/samples/node-config-auto-prefix/_config.js @@ -1,5 +1,5 @@ -module.exports = { +module.exports = defineTest({ description: 'uses config file installed from npm, automatically adding a rollup-config- prefix', - command: 'rollup --config node:foo', + spawnArgs: ['--config', 'node:foo'], execute: true -}; +}); diff --git a/test/cli/samples/node-config-not-found/_config.js b/test/cli/samples/node-config-not-found/_config.js index f4ad14d9ed4..26747778e5f 100644 --- a/test/cli/samples/node-config-not-found/_config.js +++ b/test/cli/samples/node-config-not-found/_config.js @@ -1,10 +1,10 @@ -const { assertIncludes } = require('../../../utils.js'); +const { assertIncludes } = require('../../../testHelpers.js'); -module.exports = { +module.exports = defineTest({ description: 'throws if a config in node_modules cannot be found', - command: 'rollup --config node:baz', + spawnArgs: ['--config', 'node:baz'], error: () => true, stderr(stderr) { assertIncludes(stderr, '[!] Could not resolve config file "node:baz"'); } -}; +}); diff --git a/test/cli/samples/node-config/_config.js b/test/cli/samples/node-config/_config.js index fdd13b0cc98..359f3e8f1e2 100644 --- a/test/cli/samples/node-config/_config.js +++ b/test/cli/samples/node-config/_config.js @@ -1,6 +1,6 @@ -module.exports = { +module.exports = defineTest({ description: 'uses config file installed from npm', - command: 'rollup --config node:bar', + spawnArgs: ['--config', 'node:bar'], cwd: __dirname, execute: true -}; +}); diff --git a/test/cli/samples/paths-output-option/_config.js b/test/cli/samples/paths-output-option/_config.js index e0c7edd32a1..a0c9287502d 100644 --- a/test/cli/samples/paths-output-option/_config.js +++ b/test/cli/samples/paths-output-option/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'allows paths to be set as an output option', - command: 'rollup --config rollup.config.js' -}; + spawnArgs: ['--config', 'rollup.config.js'] +}); diff --git a/test/cli/samples/paths-output-option/rollup.config.js b/test/cli/samples/paths-output-option/rollup.config.js index b8841169924..c4933f5f317 100644 --- a/test/cli/samples/paths-output-option/rollup.config.js +++ b/test/cli/samples/paths-output-option/rollup.config.js @@ -4,8 +4,7 @@ module.exports = { output: { format: 'cjs', paths: { - 'foo': 'bar' - }, - interop: false + foo: 'bar' + } } }; diff --git a/test/cli/samples/plugin/absolute-esm/_config.js b/test/cli/samples/plugin/absolute-esm/_config.js new file mode 100644 index 00000000000..92874e8d1c3 --- /dev/null +++ b/test/cli/samples/plugin/absolute-esm/_config.js @@ -0,0 +1,6 @@ +const path = require('node:path'); + +module.exports = defineTest({ + description: 'ESM CLI --plugin /absolute/path', + spawnArgs: ['main.js', '-p', `${__dirname}${path.sep}my-esm-plugin.mjs={comment: 'Absolute ESM'}`] +}); diff --git a/test/cli/samples/plugin/absolute-esm/_expected.js b/test/cli/samples/plugin/absolute-esm/_expected.js new file mode 100644 index 00000000000..4adbb01e16e --- /dev/null +++ b/test/cli/samples/plugin/absolute-esm/_expected.js @@ -0,0 +1,2 @@ +// Hello Absolute ESM +console.log(2 ); diff --git a/test/cli/samples/plugin/absolute-esm/main.js b/test/cli/samples/plugin/absolute-esm/main.js new file mode 100644 index 00000000000..8b068518106 --- /dev/null +++ b/test/cli/samples/plugin/absolute-esm/main.js @@ -0,0 +1 @@ +console.log(1 ? 2 : 3); diff --git a/test/cli/samples/plugin/absolute-esm/my-esm-plugin.mjs b/test/cli/samples/plugin/absolute-esm/my-esm-plugin.mjs new file mode 100644 index 00000000000..dc135d072a9 --- /dev/null +++ b/test/cli/samples/plugin/absolute-esm/my-esm-plugin.mjs @@ -0,0 +1,8 @@ +export default function(options = {}) { + const {comment} = options; + return { + transform(code) { + return `// Hello ${comment}\n${code}`; + } + }; +}; diff --git a/test/cli/samples/plugin/absolute/_config.js b/test/cli/samples/plugin/absolute/_config.js index 9f8cebd1f00..81d5a99d383 100644 --- a/test/cli/samples/plugin/absolute/_config.js +++ b/test/cli/samples/plugin/absolute/_config.js @@ -1,5 +1,6 @@ -module.exports = { +const path = require('node:path'); + +module.exports = defineTest({ description: 'CLI --plugin /absolute/path', - skipIfWindows: true, - command: `echo 'console.log(VALUE);' | rollup -p "\`pwd\`/my-plugin={VALUE: 'absolute', ZZZ: 1}"` -}; + spawnArgs: ['main.js', '-p', `${__dirname}${path.sep}my-plugin.js={VALUE: 'absolute', ZZZ: 1}`] +}); diff --git a/test/cli/samples/plugin/absolute/main.js b/test/cli/samples/plugin/absolute/main.js new file mode 100644 index 00000000000..394321ee72e --- /dev/null +++ b/test/cli/samples/plugin/absolute/main.js @@ -0,0 +1 @@ +console.log(VALUE); diff --git a/test/cli/samples/plugin/advanced-esm/_config.js b/test/cli/samples/plugin/advanced-esm/_config.js new file mode 100644 index 00000000000..c5f8b989499 --- /dev/null +++ b/test/cli/samples/plugin/advanced-esm/_config.js @@ -0,0 +1,9 @@ +module.exports = defineTest({ + description: 'load an ESM-only rollup plugin from node_modules as well as CJS plugins', + skipIfWindows: true, + + // The NodeJS resolution rules for ESM modules are more restrictive than CJS. + // Must copy the ESM plugin into the main node_modules in order to use and test it. + + command: `rm -rf ../../../../../node_modules/rollup-plugin-esm-test && cp -rp ../../../node_modules_rename_me/rollup-plugin-esm-test ../../../../../node_modules/ && rollup -c -p node-resolve,commonjs,esm-test -p "terser={mangle: false, output: {beautify: true, indent_level: 2}}"` +}); diff --git a/test/cli/samples/plugin/advanced-esm/_expected/cjs.js b/test/cli/samples/plugin/advanced-esm/_expected/cjs.js new file mode 100644 index 00000000000..7b9ca6d7d22 --- /dev/null +++ b/test/cli/samples/plugin/advanced-esm/_expected/cjs.js @@ -0,0 +1,27 @@ +"use strict"; + +var print, hasRequiredPrint, hasRequiredFoo, foo$1 = {}; + +function requirePrint() { + return hasRequiredPrint ? print : (hasRequiredPrint = 1, print = function(value) { + console.log(value); + }); +} + +console.log("esm-test: node_modules/print/index.js"), console.log("esm-test: node_modules/foo/index.js"); + +var fooExports = function() { + if (hasRequiredFoo) return foo$1; + hasRequiredFoo = 1; + var print = requirePrint(); + return foo$1.Foo = function() { + function Foo(x) { + this.x = x; + } + return Foo.prototype.output = function() { + print(this.x); + }, Foo; + }(), foo$1; +}(); + +console.log("esm-test: main.js"), new fooExports.Foo(123).output(), exports.Bar = fooExports.Foo; diff --git a/test/cli/samples/plugin/advanced-esm/_expected/es.js b/test/cli/samples/plugin/advanced-esm/_expected/es.js new file mode 100644 index 00000000000..cb328ecd27b --- /dev/null +++ b/test/cli/samples/plugin/advanced-esm/_expected/es.js @@ -0,0 +1,29 @@ +var print, hasRequiredPrint, hasRequiredFoo, foo$1 = {}; + +function requirePrint() { + return hasRequiredPrint ? print : (hasRequiredPrint = 1, print = function(value) { + console.log(value); + }); +} + +console.log("esm-test: node_modules/print/index.js"), console.log("esm-test: node_modules/foo/index.js"); + +var fooExports = function() { + if (hasRequiredFoo) return foo$1; + hasRequiredFoo = 1; + var print = requirePrint(); + return foo$1.Foo = function() { + function Foo(x) { + this.x = x; + } + return Foo.prototype.output = function() { + print(this.x); + }, Foo; + }(), foo$1; +}(); + +console.log("esm-test: main.js"), new fooExports.Foo(123).output(); + +var Foo = fooExports.Foo; + +export { Foo as Bar }; diff --git a/test/cli/samples/plugin/advanced-esm/main.js b/test/cli/samples/plugin/advanced-esm/main.js new file mode 100644 index 00000000000..e04e2255af9 --- /dev/null +++ b/test/cli/samples/plugin/advanced-esm/main.js @@ -0,0 +1,4 @@ +import {Foo} from "foo"; +var foo = new Foo(123); +foo.output(); +export {Foo as Bar}; diff --git a/test/cli/samples/plugin/advanced-esm/node_modules/foo/index.js b/test/cli/samples/plugin/advanced-esm/node_modules/foo/index.js new file mode 100644 index 00000000000..87e1bc97c38 --- /dev/null +++ b/test/cli/samples/plugin/advanced-esm/node_modules/foo/index.js @@ -0,0 +1,10 @@ +var print = require('print'); + +exports.Foo = class { + constructor(x) { + this.x = x; + } + output() { + print(this.x); + } +}; diff --git a/test/cli/samples/plugin/advanced-esm/node_modules/print/index.js b/test/cli/samples/plugin/advanced-esm/node_modules/print/index.js new file mode 100644 index 00000000000..be89775f9d0 --- /dev/null +++ b/test/cli/samples/plugin/advanced-esm/node_modules/print/index.js @@ -0,0 +1,3 @@ +module.exports = function(value) { + console.log(value); +}; diff --git a/test/cli/samples/plugin/advanced-esm/rollup.config.mjs b/test/cli/samples/plugin/advanced-esm/rollup.config.mjs new file mode 100644 index 00000000000..7e9855a13ff --- /dev/null +++ b/test/cli/samples/plugin/advanced-esm/rollup.config.mjs @@ -0,0 +1,16 @@ +import buble from '@rollup/plugin-buble'; + +export default { + input: 'main.js', + plugins: [buble()], + output: [ + { + file: '_actual/cjs.js', + format: 'cjs' + }, + { + file: '_actual/es.js', + format: 'esm' + } + ] +}; diff --git a/test/cli/samples/plugin/advanced/_config.js b/test/cli/samples/plugin/advanced/_config.js index 8028fd603e7..797d1877da7 100644 --- a/test/cli/samples/plugin/advanced/_config.js +++ b/test/cli/samples/plugin/advanced/_config.js @@ -1,5 +1,10 @@ -module.exports = { +module.exports = defineTest({ description: 'advanced CLI --plugin functionality with rollup config', - skipIfWindows: true, - command: `rollup -c -p node-resolve,commonjs -p "terser={output: {beautify: true, indent_level: 2}}"` -}; + spawnArgs: [ + '-c', + '-p', + 'node-resolve,commonjs', + '-p', + 'terser={output: {beautify: true, indent_level: 2}}' + ] +}); diff --git a/test/cli/samples/plugin/advanced/_expected/cjs.js b/test/cli/samples/plugin/advanced/_expected/cjs.js index 755dfc90ce8..826b412611f 100644 --- a/test/cli/samples/plugin/advanced/_expected/cjs.js +++ b/test/cli/samples/plugin/advanced/_expected/cjs.js @@ -1,18 +1,25 @@ "use strict"; -Object.defineProperty(exports, "__esModule", { - value: !0 -}); +var t, o, n, r = {}; -var t = function(t) { - console.log(t); -}, o = function() { - function o(t) { - this.x = t; - } - return o.prototype.output = function() { - t(this.x); - }, o; +function u() { + return o ? t : (o = 1, t = function(t) { + console.log(t); + }); +} + +var i = function() { + if (n) return r; + n = 1; + var t = u(); + return r.Foo = function() { + function o(t) { + this.x = t; + } + return o.prototype.output = function() { + t(this.x); + }, o; + }(), r; }(); -new o(123).output(), exports.Bar = o; +new i.Foo(123).output(), exports.Bar = i.Foo; diff --git a/test/cli/samples/plugin/advanced/_expected/es.js b/test/cli/samples/plugin/advanced/_expected/es.js index 88f81d92462..cc21b90009b 100644 --- a/test/cli/samples/plugin/advanced/_expected/es.js +++ b/test/cli/samples/plugin/advanced/_expected/es.js @@ -1,14 +1,27 @@ -var t = function(t) { - console.log(t); -}, o = function() { - function o(t) { - this.x = t; - } - return o.prototype.output = function() { - t(this.x); - }, o; +var o, t, n, r = {}; + +function u() { + return t ? o : (t = 1, o = function(o) { + console.log(o); + }); +} + +var i = function() { + if (n) return r; + n = 1; + var o = u(); + return r.Foo = function() { + function t(o) { + this.x = o; + } + return t.prototype.output = function() { + o(this.x); + }, t; + }(), r; }(); -new o(123).output(); +new i.Foo(123).output(); + +var e = i.Foo; -export { o as Bar }; +export { e as Bar }; diff --git a/test/cli/samples/plugin/advanced/rollup.config.js b/test/cli/samples/plugin/advanced/rollup.config.js deleted file mode 100644 index f2db773934b..00000000000 --- a/test/cli/samples/plugin/advanced/rollup.config.js +++ /dev/null @@ -1,18 +0,0 @@ -const buble = require('@rollup/plugin-buble'); - -export default { - input: 'main.js', - plugins: [ - buble() - ], - output: [ - { - file: '_actual/cjs.js', - format: 'cjs' - }, - { - file: '_actual/es.js', - format: 'esm' - } - ] -}; diff --git a/test/cli/samples/plugin/advanced/rollup.config.mjs b/test/cli/samples/plugin/advanced/rollup.config.mjs new file mode 100644 index 00000000000..7e9855a13ff --- /dev/null +++ b/test/cli/samples/plugin/advanced/rollup.config.mjs @@ -0,0 +1,16 @@ +import buble from '@rollup/plugin-buble'; + +export default { + input: 'main.js', + plugins: [buble()], + output: [ + { + file: '_actual/cjs.js', + format: 'cjs' + }, + { + file: '_actual/es.js', + format: 'esm' + } + ] +}; diff --git a/test/cli/samples/plugin/basic/_config.js b/test/cli/samples/plugin/basic/_config.js index 4914b4a27a0..a5c79733831 100644 --- a/test/cli/samples/plugin/basic/_config.js +++ b/test/cli/samples/plugin/basic/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'basic CLI --plugin functionality', - command: `rollup main.js -f cjs --plugin @rollup/plugin-buble` -}; + spawnArgs: ['main.js', '-f', 'cjs', '--plugin', '@rollup/plugin-buble'] +}); diff --git a/test/cli/samples/plugin/basic/_expected.js b/test/cli/samples/plugin/basic/_expected.js index e83de861ed5..eac860b0927 100644 --- a/test/cli/samples/plugin/basic/_expected.js +++ b/test/cli/samples/plugin/basic/_expected.js @@ -1,8 +1,6 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - -var Bar = function Bar(x) { +var Bar = function Bar(value) { this.x = value; }; Bar.prototype.value = function value () { diff --git a/test/cli/samples/plugin/basic/main.js b/test/cli/samples/plugin/basic/main.js index 49486331fe7..a42c7cc4c5c 100644 --- a/test/cli/samples/plugin/basic/main.js +++ b/test/cli/samples/plugin/basic/main.js @@ -1,5 +1,5 @@ export class Bar { - constructor(x) { + constructor(value) { this.x = value; } value() { diff --git a/test/cli/samples/plugin/cannot-load/_config.js b/test/cli/samples/plugin/cannot-load/_config.js index e1e93989c9b..e75568843e6 100644 --- a/test/cli/samples/plugin/cannot-load/_config.js +++ b/test/cli/samples/plugin/cannot-load/_config.js @@ -1,10 +1,10 @@ -const { assertIncludes } = require('../../../../utils.js'); +const { assertIncludes } = require('../../../../testHelpers.js'); -module.exports = { +module.exports = defineTest({ description: 'unknown CLI --plugin results in an error', skipIfWindows: true, command: `echo "console.log(123);" | rollup --plugin foobar`, - error(err) { - assertIncludes(err.message, '[!] Error: Cannot load plugin "foobar"'); + error(error) { + assertIncludes(error.message, '[!] Error: Cannot load plugin "foobar"'); } -}; +}); diff --git a/test/cli/samples/plugin/default-export/_config.js b/test/cli/samples/plugin/default-export/_config.js index 2a74334e40b..c30a5078550 100644 --- a/test/cli/samples/plugin/default-export/_config.js +++ b/test/cli/samples/plugin/default-export/_config.js @@ -1,5 +1,5 @@ -module.exports = { +module.exports = defineTest({ description: 'CLI --plugin with default export', skipIfWindows: true, command: `echo 'console.log(VALUE);' | rollup -p "./my-plugin={VALUE: 'default', ZZZ: 1}"` -}; +}); diff --git a/test/cli/samples/plugin/export-not-found/_config.js b/test/cli/samples/plugin/export-not-found/_config.js index 014fb0827c0..e38676dd07e 100644 --- a/test/cli/samples/plugin/export-not-found/_config.js +++ b/test/cli/samples/plugin/export-not-found/_config.js @@ -1,17 +1,17 @@ -const { assertIncludes } = require('../../../../utils.js'); -const path = require('path'); +const path = require('node:path'); +const { assertIncludes } = require('../../../../testHelpers.js'); -module.exports = { +module.exports = defineTest({ description: 'Throws when the plugin export cannot be found', skipIfWindows: true, command: `echo 'console.log("ignored");' | rollup -p "./my-missing-plugin"`, - error(err) { + error(error) { assertIncludes( - err.message, + error.message, `[!] Error: Cannot find entry for plugin "${path.join( __dirname, 'my-missing-plugin' )}". The plugin needs to export a function either as "default" or "myMissingPlugin" for Rollup to recognize it.` ); } -}; +}); diff --git a/test/cli/samples/plugin/invalid-argument/_config.js b/test/cli/samples/plugin/invalid-argument/_config.js index 7344209219a..e28cce7f870 100644 --- a/test/cli/samples/plugin/invalid-argument/_config.js +++ b/test/cli/samples/plugin/invalid-argument/_config.js @@ -1,10 +1,10 @@ -const { assertIncludes } = require('../../../../utils.js'); +const { assertIncludes } = require('../../../../testHelpers.js'); -module.exports = { +module.exports = defineTest({ description: 'invalid CLI --plugin argument format', skipIfWindows: true, command: `echo "console.log(123);" | rollup --plugin 'foo bar'`, - error(err) { - assertIncludes(err.message, '[!] Error: Invalid --plugin argument format: "foo bar"'); + error(error) { + assertIncludes(error.message, '[!] Error: Invalid --plugin argument format: "foo bar"'); } -}; +}); diff --git a/test/cli/samples/plugin/named-export/_config.js b/test/cli/samples/plugin/named-export/_config.js deleted file mode 100644 index 92a84aeb1db..00000000000 --- a/test/cli/samples/plugin/named-export/_config.js +++ /dev/null @@ -1,5 +0,0 @@ -module.exports = { - description: 'supports stripping "rollup-config" prefix to find named plugin export', - skipIfWindows: true, - command: `rollup -c -p rollup-plugin-terser` -}; diff --git a/test/cli/samples/plugin/named-export/_expected/cjs.js b/test/cli/samples/plugin/named-export/_expected/cjs.js deleted file mode 100644 index 112c5d4af42..00000000000 --- a/test/cli/samples/plugin/named-export/_expected/cjs.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=function(t){this.x=t};t.prototype.output=function(){console.log(this.x)},new t(123).output(),exports.Bar=t; diff --git a/test/cli/samples/plugin/named-export/_expected/es.js b/test/cli/samples/plugin/named-export/_expected/es.js deleted file mode 100644 index 6b973ec0d27..00000000000 --- a/test/cli/samples/plugin/named-export/_expected/es.js +++ /dev/null @@ -1 +0,0 @@ -var t=function(t){this.x=t};t.prototype.output=function(){console.log(this.x)},new t(123).output();export{t as Bar}; diff --git a/test/cli/samples/plugin/named-export/main.js b/test/cli/samples/plugin/named-export/main.js deleted file mode 100644 index 649a9dfefdc..00000000000 --- a/test/cli/samples/plugin/named-export/main.js +++ /dev/null @@ -1,12 +0,0 @@ -class Foo { - constructor(x) { - this.x = x; - } - output() { - console.log(this.x); - } -} - -const foo = new Foo(123); -foo.output(); -export { Foo as Bar }; diff --git a/test/cli/samples/plugin/named-export/rollup.config.js b/test/cli/samples/plugin/named-export/rollup.config.js deleted file mode 100644 index f2db773934b..00000000000 --- a/test/cli/samples/plugin/named-export/rollup.config.js +++ /dev/null @@ -1,18 +0,0 @@ -const buble = require('@rollup/plugin-buble'); - -export default { - input: 'main.js', - plugins: [ - buble() - ], - output: [ - { - file: '_actual/cjs.js', - format: 'cjs' - }, - { - file: '_actual/es.js', - format: 'esm' - } - ] -}; diff --git a/test/cli/samples/plugin/object/_config.js b/test/cli/samples/plugin/object/_config.js index f102a47afeb..935d3d82c89 100644 --- a/test/cli/samples/plugin/object/_config.js +++ b/test/cli/samples/plugin/object/_config.js @@ -1,5 +1,5 @@ -module.exports = { +module.exports = defineTest({ description: 'CLI --plugin object', skipIfWindows: true, command: `echo 'console.log(42);' | rollup -f cjs -p '{transform: c => c + String.fromCharCode(10) + c}'` -}; +}); diff --git a/test/cli/samples/plugin/relative-camelized/_config.js b/test/cli/samples/plugin/relative-camelized/_config.js index 6ee87968574..b6f0e4b8fa3 100644 --- a/test/cli/samples/plugin/relative-camelized/_config.js +++ b/test/cli/samples/plugin/relative-camelized/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'handles plugins where the export name is the camelized file name', skipIfWindows: true, command: @@ -7,4 +7,4 @@ module.exports = { '-p "./plugins/rollup-plugin-my-super-plugin2.js" ' + '-p "./plugins/rollup-plugin-" ' + '-p "./plugins/@rollup/plugin-supreme"' -}; +}); diff --git a/test/cli/samples/plugin/relative-esm/_config.js b/test/cli/samples/plugin/relative-esm/_config.js new file mode 100644 index 00000000000..2ba56b771ce --- /dev/null +++ b/test/cli/samples/plugin/relative-esm/_config.js @@ -0,0 +1,5 @@ +module.exports = defineTest({ + description: 'ESM CLI --plugin ../relative/path', + skipIfWindows: true, + command: `echo 'console.log(1 ? 2 : 3);' | rollup -p "../absolute-esm/my-esm-plugin.mjs={comment: 'Relative ESM'}"` +}); diff --git a/test/cli/samples/plugin/relative-esm/_expected.js b/test/cli/samples/plugin/relative-esm/_expected.js new file mode 100644 index 00000000000..1c1ba68f176 --- /dev/null +++ b/test/cli/samples/plugin/relative-esm/_expected.js @@ -0,0 +1,2 @@ +// Hello Relative ESM +console.log(2 ); diff --git a/test/cli/samples/plugin/relative/_config.js b/test/cli/samples/plugin/relative/_config.js index 177951ac68e..fb09dc5b717 100644 --- a/test/cli/samples/plugin/relative/_config.js +++ b/test/cli/samples/plugin/relative/_config.js @@ -1,5 +1,5 @@ -module.exports = { +module.exports = defineTest({ description: 'CLI --plugin ../relative/path', skipIfWindows: true, command: `echo 'console.log(VALUE);' | rollup -p "../absolute/my-plugin={VALUE: 'relative', ZZZ: 1}"` -}; +}); diff --git a/test/cli/samples/property-read-side-effects/_config.js b/test/cli/samples/property-read-side-effects/_config.js index 9cb2ce5fd62..81cbb7caf26 100644 --- a/test/cli/samples/property-read-side-effects/_config.js +++ b/test/cli/samples/property-read-side-effects/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'allows disabling side-effects when accessing properties', - command: 'rollup main.js --format es --no-treeshake.propertyReadSideEffects' -}; + spawnArgs: ['main.js', '--format', 'es', '--no-treeshake.propertyReadSideEffects'] +}); diff --git a/test/cli/samples/propertyReadSideEffects-always/_config.js b/test/cli/samples/propertyReadSideEffects-always/_config.js index 1c76838ca53..a6236d5cbae 100644 --- a/test/cli/samples/propertyReadSideEffects-always/_config.js +++ b/test/cli/samples/propertyReadSideEffects-always/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'verify property accesses are retained for getters with side effects', - command: `rollup main.js --validate --treeshake.propertyReadSideEffects=always` -}; + spawnArgs: ['main.js', '--validate', '--treeshake.propertyReadSideEffects=always'] +}); diff --git a/test/cli/samples/silent-onwarn/_config.js b/test/cli/samples/silent-onwarn/_config.js index 0bbc667c79a..cb4c2a26037 100644 --- a/test/cli/samples/silent-onwarn/_config.js +++ b/test/cli/samples/silent-onwarn/_config.js @@ -1,10 +1,10 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'triggers onwarn with --silent', - command: 'rollup -c --silent', + spawnArgs: ['-c', '--silent'], stderr: stderr => { assert.equal(stderr, ''); return true; } -}; +}); diff --git a/test/cli/samples/silent-onwarn/_expected.js b/test/cli/samples/silent-onwarn/_expected.js index 29af3b17871..2a1f0d5785d 100644 --- a/test/cli/samples/silent-onwarn/_expected.js +++ b/test/cli/samples/silent-onwarn/_expected.js @@ -2,4 +2,4 @@ var doIt = () => console.log('main'); doIt(); -export default doIt; +export { doIt as default }; diff --git a/test/cli/samples/silent-onwarn/rollup.config.js b/test/cli/samples/silent-onwarn/rollup.config.js deleted file mode 100644 index 051e24861d9..00000000000 --- a/test/cli/samples/silent-onwarn/rollup.config.js +++ /dev/null @@ -1,20 +0,0 @@ -import assert from 'assert'; - -const warnings = []; - -export default { - input: 'main.js', - output: { - format: 'es' - }, - onwarn(warning) { - warnings.push(warning); - }, - plugins: { - generateBundle(bundle) { - assert.strictEqual(warnings.length, 1); - assert.strictEqual(warnings[0].code, 'CIRCULAR_DEPENDENCY'); - } - } - -} diff --git a/test/cli/samples/silent-onwarn/rollup.config.mjs b/test/cli/samples/silent-onwarn/rollup.config.mjs new file mode 100644 index 00000000000..1c102c32c66 --- /dev/null +++ b/test/cli/samples/silent-onwarn/rollup.config.mjs @@ -0,0 +1,19 @@ +import assert from 'assert'; + +const warnings = []; + +export default { + input: 'main.js', + output: { + format: 'es' + }, + onwarn(warning) { + warnings.push(warning); + }, + plugins: { + generateBundle(bundle) { + assert.strictEqual(warnings.length, 1); + assert.strictEqual(warnings[0].code, 'CIRCULAR_DEPENDENCY'); + } + } +}; diff --git a/test/cli/samples/silent/_config.js b/test/cli/samples/silent/_config.js index 94076dd402f..16f83c1ec6f 100644 --- a/test/cli/samples/silent/_config.js +++ b/test/cli/samples/silent/_config.js @@ -1,10 +1,10 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { - description: 'does not print warnings with --silent', - command: 'rollup -i main.js -f cjs --silent', +module.exports = defineTest({ + description: 'does not print logs with --silent', + spawnArgs: ['--config', '--silent'], stderr: stderr => { assert.equal(stderr, ''); return true; } -}; +}); diff --git a/test/cli/samples/silent/rollup.config.mjs b/test/cli/samples/silent/rollup.config.mjs new file mode 100644 index 00000000000..1a5329a05e1 --- /dev/null +++ b/test/cli/samples/silent/rollup.config.mjs @@ -0,0 +1,17 @@ +export default { + input: 'main.js', + logLevel: 'debug', + plugins: [ + { + name: 'test', + buildStart() { + this.debug('debug-log'); + this.info('info-log'); + this.warn('warn-log'); + } + } + ], + output: { + format: 'cjs' + } +} diff --git a/test/cli/samples/sourcemap-hidden/_config.js b/test/cli/samples/sourcemap-hidden/_config.js index 6ddf4a16d2c..ca5cea2fe7d 100644 --- a/test/cli/samples/sourcemap-hidden/_config.js +++ b/test/cli/samples/sourcemap-hidden/_config.js @@ -1,16 +1,16 @@ -const fs = require('fs'); -const assert = require('assert'); +const assert = require('node:assert'); +const { readFileSync, unlinkSync } = require('node:fs'); -module.exports = { +module.exports = defineTest({ description: 'omits sourcemap comments', - command: 'rollup -i main.js -f es -m hidden -o output.js', + spawnArgs: ['-i', 'main.js', '-f', 'es', '-m', 'hidden', '-o', 'output.js'], test() { - assert.equal(fs.readFileSync('output.js', 'utf-8').trim(), 'console.log( 42 );'); - fs.unlinkSync('output.js'); + assert.equal(readFileSync('output.js', 'utf8').trim(), 'console.log( 42 );'); + unlinkSync('output.js'); assert.equal( - fs.readFileSync('output.js.map', 'utf-8').trim(), + readFileSync('output.js.map', 'utf8').trim(), '{"version":3,"file":"output.js","sources":["main.js"],"sourcesContent":["console.log( 42 );\\n"],"names":[],"mappings":"AAAA,OAAO,CAAC,GAAG,EAAE,EAAE,EAAE"}' ); - fs.unlinkSync('output.js.map'); + unlinkSync('output.js.map'); } -}; +}); diff --git a/test/cli/samples/sourcemap-newline/_config.js b/test/cli/samples/sourcemap-newline/_config.js index ada18189d6d..33add313903 100644 --- a/test/cli/samples/sourcemap-newline/_config.js +++ b/test/cli/samples/sourcemap-newline/_config.js @@ -1,9 +1,9 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'adds a newline after the sourceMappingURL comment (#756)', - command: 'rollup -i main.js -f es -m inline', + spawnArgs: ['-i', 'main.js', '-f', 'es', '-m', 'inline'], result: code => { assert.equal(code.slice(-1), '\n'); } -}; +}); diff --git a/test/cli/samples/stdin/commonjs/_config.js b/test/cli/samples/stdin/commonjs/_config.js index 5ce8ad4a188..1fd14514f58 100644 --- a/test/cli/samples/stdin/commonjs/_config.js +++ b/test/cli/samples/stdin/commonjs/_config.js @@ -1,5 +1,5 @@ -module.exports = { +module.exports = defineTest({ description: 'uses stdin to inline a require()', skipIfWindows: true, command: `echo 'console.log(require("./add.js")(2, 1));' | rollup --stdin=js -p commonjs -f cjs --exports=auto` -}; +}); diff --git a/test/cli/samples/stdin/commonjs/_expected.js b/test/cli/samples/stdin/commonjs/_expected.js index 6fb715c5405..d2b27b9ba19 100644 --- a/test/cli/samples/stdin/commonjs/_expected.js +++ b/test/cli/samples/stdin/commonjs/_expected.js @@ -1,9 +1,3 @@ 'use strict'; -var _ = {}; - -var add = (x, y) => x + y; - -console.log(add(2, 1)); - -module.exports = _; +console.log(require("./add.js")(2, 1)); diff --git a/test/cli/samples/stdin/config-file/_config.js b/test/cli/samples/stdin/config-file/_config.js index 09d1acef0bf..ae73172b6dd 100644 --- a/test/cli/samples/stdin/config-file/_config.js +++ b/test/cli/samples/stdin/config-file/_config.js @@ -1,6 +1,6 @@ -module.exports = { +module.exports = defineTest({ description: 'does not replace input with stdin but allows referencing it when using a config file', skipIfWindows: true, command: `echo "import {PRINT as p} from './a'; import C from './b'; 0 && fail() || p(C); export {C as value, p as print}" | rollup -c` -}; +}); diff --git a/test/cli/samples/stdin/config-file/_expected/cjs.js b/test/cli/samples/stdin/config-file/_expected/cjs.js index ece324c0d9e..6add2511b1c 100644 --- a/test/cli/samples/stdin/config-file/_expected/cjs.js +++ b/test/cli/samples/stdin/config-file/_expected/cjs.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - const PRINT = x => console.log(x); var C = 123; diff --git a/test/cli/samples/stdin/config-file/rollup.config.js b/test/cli/samples/stdin/config-file/rollup.config.mjs similarity index 100% rename from test/cli/samples/stdin/config-file/rollup.config.js rename to test/cli/samples/stdin/config-file/rollup.config.mjs diff --git a/test/cli/samples/stdin/force-stdin-tty/_config.js b/test/cli/samples/stdin/force-stdin-tty/_config.js index 754e74be351..65d6b5f2314 100644 --- a/test/cli/samples/stdin/force-stdin-tty/_config.js +++ b/test/cli/samples/stdin/force-stdin-tty/_config.js @@ -1,5 +1,5 @@ -module.exports = { +module.exports = defineTest({ description: 'allows forcing stdin input on TTY interfaces via option', skipIfWindows: true, command: `echo "console.log('PASS');" | ./wrapper.js -f es --stdin` -}; +}); diff --git a/test/cli/samples/stdin/json/_config.js b/test/cli/samples/stdin/json/_config.js index e9443f0667f..00f0d2528d0 100644 --- a/test/cli/samples/stdin/json/_config.js +++ b/test/cli/samples/stdin/json/_config.js @@ -1,5 +1,5 @@ -module.exports = { +module.exports = defineTest({ description: 'pipe JSON over stdin to create a module', skipIfWindows: true, command: `echo '{"foo": 42, "bar": "ok"}' | rollup --stdin=json -p json` -}; +}); diff --git a/test/cli/samples/stdin/json/_expected.js b/test/cli/samples/stdin/json/_expected.js index 2fa6079fa2d..46e0e3a0967 100644 --- a/test/cli/samples/stdin/json/_expected.js +++ b/test/cli/samples/stdin/json/_expected.js @@ -5,5 +5,4 @@ var _ = { bar: bar }; -export default _; -export { bar, foo }; +export { bar, _ as default, foo }; diff --git a/test/cli/samples/stdin/no-dash/_config.js b/test/cli/samples/stdin/no-dash/_config.js index bc97f7e7214..71524f914b5 100644 --- a/test/cli/samples/stdin/no-dash/_config.js +++ b/test/cli/samples/stdin/no-dash/_config.js @@ -1,5 +1,5 @@ -module.exports = { +module.exports = defineTest({ description: 'uses stdin input when piping into Rollup without an input', skipIfWindows: true, command: `echo "0 && fail() || console.log('PASS');" | rollup` -}; +}); diff --git a/test/cli/samples/stdin/no-stdin-config-file/_config.js b/test/cli/samples/stdin/no-stdin-config-file/_config.js index 069b2eca2ae..ead4a2e286a 100644 --- a/test/cli/samples/stdin/no-stdin-config-file/_config.js +++ b/test/cli/samples/stdin/no-stdin-config-file/_config.js @@ -1,5 +1,5 @@ -module.exports = { +module.exports = defineTest({ description: 'allows using "-" as a regular file name via flag', skipIfWindows: true, command: `echo "console.log('IGNORED');" | rollup -c --no-stdin` -}; +}); diff --git a/test/cli/samples/stdin/no-stdin-config-file/_expected/cjs.js b/test/cli/samples/stdin/no-stdin-config-file/_expected/cjs.js index ad2b476f9ed..ce8fc1d9fef 100644 --- a/test/cli/samples/stdin/no-stdin-config-file/_expected/cjs.js +++ b/test/cli/samples/stdin/no-stdin-config-file/_expected/cjs.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - const PRINT = x => console.log(x); exports.PRINT = PRINT; diff --git a/test/cli/samples/stdin/no-stdin-config-file/rollup.config.js b/test/cli/samples/stdin/no-stdin-config-file/rollup.config.mjs similarity index 100% rename from test/cli/samples/stdin/no-stdin-config-file/rollup.config.js rename to test/cli/samples/stdin/no-stdin-config-file/rollup.config.mjs diff --git a/test/cli/samples/stdin/no-stdin-tty/_config.js b/test/cli/samples/stdin/no-stdin-tty/_config.js index 5ae67db4147..47524b4e4cd 100644 --- a/test/cli/samples/stdin/no-stdin-tty/_config.js +++ b/test/cli/samples/stdin/no-stdin-tty/_config.js @@ -1,10 +1,10 @@ -const { assertIncludes } = require('../../../../utils.js'); +const { assertIncludes } = require('../../../../testHelpers.js'); -module.exports = { +module.exports = defineTest({ description: 'does not use input as stdin on TTY interfaces', skipIfWindows: true, command: `echo "console.log('PASS');" | ./wrapper.js -f es`, - error(err) { - assertIncludes(err.message, 'You must supply options.input to rollup'); + error(error) { + assertIncludes(error.message, 'You must supply options.input to rollup'); } -}; +}); diff --git a/test/cli/samples/stdin/self-import/_config.js b/test/cli/samples/stdin/self-import/_config.js index 0d03f53502f..ec1f5195976 100644 --- a/test/cli/samples/stdin/self-import/_config.js +++ b/test/cli/samples/stdin/self-import/_config.js @@ -1,5 +1,5 @@ -module.exports = { +module.exports = defineTest({ description: 'stdin input of code that imports a copy of itself', skipIfWindows: true, command: `cat input.txt | rollup -f cjs --silent` -}; +}); diff --git a/test/cli/samples/stdin/stdin-error/_config.js b/test/cli/samples/stdin/stdin-error/_config.js index 4bfdb75d767..dfb871ceb30 100644 --- a/test/cli/samples/stdin/stdin-error/_config.js +++ b/test/cli/samples/stdin/stdin-error/_config.js @@ -1,9 +1,10 @@ -const { assertIncludes } = require('../../../../utils.js'); +const { assertIncludes } = require('../../../../testHelpers.js'); -module.exports = { +module.exports = defineTest({ description: 'handles stdin errors', - command: `node wrapper.js`, - error(err) { - assertIncludes(err.message, 'Could not load -: Stream is broken.'); + spawnScript: 'wrapper.js', + spawnArgs: [], + error(error) { + assertIncludes(error.message, 'Could not load -: Stream is broken.'); } -}; +}); diff --git a/test/cli/samples/stdin/with-dash/_config.js b/test/cli/samples/stdin/with-dash/_config.js index 332119cd6ca..780147e9ed8 100644 --- a/test/cli/samples/stdin/with-dash/_config.js +++ b/test/cli/samples/stdin/with-dash/_config.js @@ -1,5 +1,5 @@ -module.exports = { +module.exports = defineTest({ description: 'stdin input with dash on CLI', skipIfWindows: true, command: `echo "0 && fail() || console.log('PASS');" | rollup -` -}; +}); diff --git a/test/cli/samples/stdout-code-splitting/_config.js b/test/cli/samples/stdout-code-splitting/_config.js index d924cb990fe..48336d9351f 100644 --- a/test/cli/samples/stdout-code-splitting/_config.js +++ b/test/cli/samples/stdout-code-splitting/_config.js @@ -1,14 +1,22 @@ -const assert = require('assert'); +const assert = require('node:assert'); -const COLOR = '\u001b[36m\u001b[1m'; -const STANDARD = '\u001b[22m\u001b[39m'; +const COLOR = '\u001B[36m\u001B[1m'; +const STANDARD = '\u001B[22m\u001B[39m'; -module.exports = { +module.exports = defineTest({ description: 'bundles multiple files to stdout while adding file names', skipIfWindows: true, - command: - 'node wrapper.js -i main1.js -i main2.js -f es ' + - `-p '{buildStart(){this.emitFile({type: "asset",source:"Hello"})}}'`, + spawnScript: 'wrapper.js', + spawnArgs: [ + '-i', + 'main1.js', + '-i', + 'main2.js', + '-f', + 'es', + '-p', + '{buildStart(){this.emitFile({type: "asset",source:"Hello"})}}' + ], env: { FORCE_COLOR: '1', TERM: 'xterm' }, result(code) { assert.equal( @@ -20,8 +28,8 @@ module.exports = { `${COLOR}//→ main2.js:${STANDARD}\n` + "console.log('main2');\n" + '\n' + - `${COLOR}//→ assets/asset-74b448a5:${STANDARD}\n` + + `${COLOR}//→ assets/asset-Bt0YMVe0:${STANDARD}\n` + 'Hello' ); - }, -}; + } +}); diff --git a/test/cli/samples/stdout-only-inline-sourcemaps/_config.js b/test/cli/samples/stdout-only-inline-sourcemaps/_config.js index 4f1d38e41f1..0ec7acc685d 100644 --- a/test/cli/samples/stdout-only-inline-sourcemaps/_config.js +++ b/test/cli/samples/stdout-only-inline-sourcemaps/_config.js @@ -1,10 +1,10 @@ -const { assertIncludes } = require('../../../utils.js'); +const { assertIncludes } = require('../../../testHelpers.js'); -module.exports = { +module.exports = defineTest({ description: 'fails when using non-inline sourcemaps when bundling to stdout', - command: 'rollup -i main.js -f es -m', + spawnArgs: ['-i', 'main.js', '-f', 'es', '-m'], error: () => true, stderr: stderr => { assertIncludes(stderr, '[!] Only inline sourcemaps are supported when bundling to stdout.\n'); } -}; +}); diff --git a/test/cli/samples/stdout-single-input/_config.js b/test/cli/samples/stdout-single-input/_config.js index 10177e23ba0..a62deecd6a2 100644 --- a/test/cli/samples/stdout-single-input/_config.js +++ b/test/cli/samples/stdout-single-input/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'bundles a single input to stdout without modifications', - command: 'rollup -i main.js -f es -m inline', -}; + spawnArgs: ['-i', 'main.js', '-f', 'es', '-m', 'inline'] +}); diff --git a/test/cli/samples/stdout-single-input/_expected.js b/test/cli/samples/stdout-single-input/_expected.js index 70449540ecd..c7ae3534c56 100644 --- a/test/cli/samples/stdout-single-input/_expected.js +++ b/test/cli/samples/stdout-single-input/_expected.js @@ -1,3 +1,2 @@ console.log( 42 ); - //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibWFpbi5qcyIsInNvdXJjZXMiOlsibWFpbi5qcyJdLCJzb3VyY2VzQ29udGVudCI6WyJjb25zb2xlLmxvZyggNDIgKTtcbiJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLENBQUMsR0FBRyxFQUFFLEVBQUUsRUFBRSJ9 diff --git a/test/cli/samples/symlinked-config/_config.js b/test/cli/samples/symlinked-config/_config.js index 3d221fb433c..1d6f301966b 100644 --- a/test/cli/samples/symlinked-config/_config.js +++ b/test/cli/samples/symlinked-config/_config.js @@ -1,5 +1,5 @@ -module.exports = { +module.exports = defineTest({ description: 'loads a symlinked config file', - command: 'rollup -c', + spawnArgs: ['-c', '--bundleConfigAsCjs'], execute: true -}; +}); diff --git a/test/cli/samples/symlinked-config/rollup.config.symlinked b/test/cli/samples/symlinked-config/rollup.config.symlinked index cfa15bcaf7f..dee04a33fb1 100644 --- a/test/cli/samples/symlinked-config/rollup.config.symlinked +++ b/test/cli/samples/symlinked-config/rollup.config.symlinked @@ -5,7 +5,5 @@ export default { output: { format: 'cjs' }, - plugins: [ - replace({ 'ANSWER': 42 }) - ] + plugins: [replace({ preventAssignment: true, ANSWER: 42 })] }; diff --git a/test/cli/samples/symlinked-named-config/_config.js b/test/cli/samples/symlinked-named-config/_config.js index 59f830679b8..375d3425e92 100644 --- a/test/cli/samples/symlinked-named-config/_config.js +++ b/test/cli/samples/symlinked-named-config/_config.js @@ -1,5 +1,5 @@ -module.exports = { +module.exports = defineTest({ description: 'loads a symlinked config file with the given name', - command: 'rollup --config my.rollup.config.js', + spawnArgs: ['--config', 'my.rollup.config.js', '--bundleConfigAsCjs'], execute: true -}; +}); diff --git a/test/cli/samples/symlinked-named-config/rollup.config.symlinked b/test/cli/samples/symlinked-named-config/rollup.config.symlinked index cfa15bcaf7f..bac35929110 100644 --- a/test/cli/samples/symlinked-named-config/rollup.config.symlinked +++ b/test/cli/samples/symlinked-named-config/rollup.config.symlinked @@ -6,6 +6,6 @@ export default { format: 'cjs' }, plugins: [ - replace({ 'ANSWER': 42 }) + replace({ preventAssignment: true, 'ANSWER': 42 }) ] }; diff --git a/test/cli/samples/treeshake-preset-override/_config.js b/test/cli/samples/treeshake-preset-override/_config.js new file mode 100644 index 00000000000..53a0684ad51 --- /dev/null +++ b/test/cli/samples/treeshake-preset-override/_config.js @@ -0,0 +1,10 @@ +module.exports = defineTest({ + description: 'overrides the treeshake option when using presets', + spawnArgs: [ + '--config', + '--treeshake', + 'recommended', + '--treeshake.unknownGlobalSideEffects', + '--no-treeshake.moduleSideEffects' + ] +}); diff --git a/test/cli/samples/treeshake-preset-override/_expected.js b/test/cli/samples/treeshake-preset-override/_expected.js new file mode 100644 index 00000000000..b2f6eafc5cf --- /dev/null +++ b/test/cli/samples/treeshake-preset-override/_expected.js @@ -0,0 +1,27 @@ +console.log('main'); + +({ + get foo() { + console.log('effect'); + } +}.foo); + +try { + const noeffect = 1; +} catch {} + +unknownGlobal; + +let flag = true; + +function test() { + if (flag) var x = true; + if (x) { + return; + } + console.log('effect'); +} + +test(); +flag = false; +test(); diff --git a/test/cli/samples/treeshake-preset-override/dep.js b/test/cli/samples/treeshake-preset-override/dep.js new file mode 100644 index 00000000000..b74a9837c07 --- /dev/null +++ b/test/cli/samples/treeshake-preset-override/dep.js @@ -0,0 +1 @@ +console.log('dep'); diff --git a/test/cli/samples/treeshake-preset-override/main.js b/test/cli/samples/treeshake-preset-override/main.js new file mode 100644 index 00000000000..25388db20b9 --- /dev/null +++ b/test/cli/samples/treeshake-preset-override/main.js @@ -0,0 +1,29 @@ +import './dep.js'; + +console.log('main'); + +({ + get foo() { + console.log('effect'); + } +}.foo); + +try { + const noeffect = 1; +} catch {} + +unknownGlobal; + +let flag = true; + +function test() { + if (flag) var x = true; + if (x) { + return; + } + console.log('effect'); +} + +test(); +flag = false; +test(); \ No newline at end of file diff --git a/test/cli/samples/treeshake-preset-override/rollup.config.mjs b/test/cli/samples/treeshake-preset-override/rollup.config.mjs new file mode 100644 index 00000000000..88d41643ba5 --- /dev/null +++ b/test/cli/samples/treeshake-preset-override/rollup.config.mjs @@ -0,0 +1,10 @@ +export default { + input: 'main.js', + treeshake: { + unknownGlobalSideEffects: false, + tryCatchDeoptimization: false + }, + output: { + format: 'es' + } +}; diff --git a/test/cli/samples/treeshake-unknown-preset/_config.js b/test/cli/samples/treeshake-unknown-preset/_config.js new file mode 100644 index 00000000000..34a2f0814ba --- /dev/null +++ b/test/cli/samples/treeshake-unknown-preset/_config.js @@ -0,0 +1,14 @@ +const { assertIncludes } = require('../../../testHelpers.js'); + +module.exports = defineTest({ + description: 'overrides the treeshake option when using presets', + spawnArgs: ['main.js', '--format', 'es', '--treeshake', 'unknown'], + error: () => true, + stderr: stderr => { + assertIncludes( + stderr, + '[!] RollupError: Invalid value "unknown" for option "treeshake" - valid values are false, true, "recommended", "safest" and "smallest". You can also supply an object for more fine-grained control.\n' + + 'https://rollupjs.org/configuration-options/#treeshake' + ); + } +}); diff --git a/test/cli/samples/treeshake-unknown-preset/main.js b/test/cli/samples/treeshake-unknown-preset/main.js new file mode 100644 index 00000000000..c0b933d7b56 --- /dev/null +++ b/test/cli/samples/treeshake-unknown-preset/main.js @@ -0,0 +1 @@ +console.log('main'); diff --git a/test/cli/samples/unfulfilled-hook-actions-error/_config.js b/test/cli/samples/unfulfilled-hook-actions-error/_config.js new file mode 100644 index 00000000000..5080d0dcf87 --- /dev/null +++ b/test/cli/samples/unfulfilled-hook-actions-error/_config.js @@ -0,0 +1,17 @@ +const assert = require('node:assert'); +const { assertIncludes, assertDoesNotInclude, hasEsBuild } = require('../../../testHelpers.js'); + +module.exports = defineTest({ + skip: !hasEsBuild, + description: 'does not show unfulfilled hook actions if there are errors', + spawnScript: 'build.mjs', + spawnArgs: [], + after(error) { + // exit code check has to be here as error(err) is only called upon failure + assert.strictEqual(error, undefined); + }, + stderr(stderr) { + assertIncludes(stderr, 'Error: Error must be displayed.'); + assertDoesNotInclude(stderr, 'Unfinished'); + } +}); diff --git a/test/function/samples/shims-missing-exports/dep2.js b/test/cli/samples/unfulfilled-hook-actions-error/_expected.js similarity index 100% rename from test/function/samples/shims-missing-exports/dep2.js rename to test/cli/samples/unfulfilled-hook-actions-error/_expected.js diff --git a/test/cli/samples/unfulfilled-hook-actions-error/a.js b/test/cli/samples/unfulfilled-hook-actions-error/a.js new file mode 100644 index 00000000000..8609d075540 --- /dev/null +++ b/test/cli/samples/unfulfilled-hook-actions-error/a.js @@ -0,0 +1 @@ +console.log('a'); diff --git a/test/cli/samples/unfulfilled-hook-actions-error/b.js b/test/cli/samples/unfulfilled-hook-actions-error/b.js new file mode 100644 index 00000000000..eeb313a0347 --- /dev/null +++ b/test/cli/samples/unfulfilled-hook-actions-error/b.js @@ -0,0 +1 @@ +console.log('b'); diff --git a/test/cli/samples/unfulfilled-hook-actions-error/build.mjs b/test/cli/samples/unfulfilled-hook-actions-error/build.mjs new file mode 100644 index 00000000000..9b2bf0f535e --- /dev/null +++ b/test/cli/samples/unfulfilled-hook-actions-error/build.mjs @@ -0,0 +1,27 @@ +import { rollup } from 'rollup'; + +let resolveA; +const waitForA = new Promise(resolve => (resolveA = resolve)); + +try { + // The error must not be swallowed when using top-level-await + await rollup({ + input: './index.js', + plugins: [ + { + name: 'test', + transform(code, id) { + if (id.endsWith('a.js')) { + resolveA(); + return new Promise(() => {}); + } + if (id.endsWith('b.js')) { + return waitForA.then(() => Promise.reject(new Error('Error must be displayed.'))); + } + } + } + ] + }); +} catch (err) { + console.error(err); +} diff --git a/test/cli/samples/unfulfilled-hook-actions-error/c.js b/test/cli/samples/unfulfilled-hook-actions-error/c.js new file mode 100644 index 00000000000..c7857d5f484 --- /dev/null +++ b/test/cli/samples/unfulfilled-hook-actions-error/c.js @@ -0,0 +1 @@ +console.log('c'); diff --git a/test/cli/samples/unfulfilled-hook-actions-error/index.js b/test/cli/samples/unfulfilled-hook-actions-error/index.js new file mode 100644 index 00000000000..35468cc3f20 --- /dev/null +++ b/test/cli/samples/unfulfilled-hook-actions-error/index.js @@ -0,0 +1,3 @@ +import './a.js'; +import './b.js'; +import './c.js'; diff --git a/test/cli/samples/unfulfilled-hook-actions-manual-exit/_config.js b/test/cli/samples/unfulfilled-hook-actions-manual-exit/_config.js new file mode 100644 index 00000000000..6e3a90292ab --- /dev/null +++ b/test/cli/samples/unfulfilled-hook-actions-manual-exit/_config.js @@ -0,0 +1,20 @@ +const assert = require('node:assert'); +const { assertDoesNotInclude } = require('../../../testHelpers'); +const { assertIncludes } = require('../../../testHelpers.js'); + +module.exports = defineTest({ + description: + 'does not show unfulfilled hook actions when exiting manually with a non-zero exit code', + spawnArgs: ['-c', '--silent'], + after(error) { + assert.strictEqual(error && error.code, 1); + }, + error() { + // do not abort test upon error + return true; + }, + stderr(stderr) { + assertDoesNotInclude(stderr, 'Unfinished'); + assertIncludes(stderr, 'Manual exit'); + } +}); diff --git a/test/cli/samples/unfulfilled-hook-actions-manual-exit/_expected.js b/test/cli/samples/unfulfilled-hook-actions-manual-exit/_expected.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/cli/samples/unfulfilled-hook-actions-manual-exit/a.js b/test/cli/samples/unfulfilled-hook-actions-manual-exit/a.js new file mode 100644 index 00000000000..8609d075540 --- /dev/null +++ b/test/cli/samples/unfulfilled-hook-actions-manual-exit/a.js @@ -0,0 +1 @@ +console.log('a'); diff --git a/test/cli/samples/unfulfilled-hook-actions-manual-exit/b.js b/test/cli/samples/unfulfilled-hook-actions-manual-exit/b.js new file mode 100644 index 00000000000..eeb313a0347 --- /dev/null +++ b/test/cli/samples/unfulfilled-hook-actions-manual-exit/b.js @@ -0,0 +1 @@ +console.log('b'); diff --git a/test/cli/samples/unfulfilled-hook-actions-manual-exit/c.js b/test/cli/samples/unfulfilled-hook-actions-manual-exit/c.js new file mode 100644 index 00000000000..c7857d5f484 --- /dev/null +++ b/test/cli/samples/unfulfilled-hook-actions-manual-exit/c.js @@ -0,0 +1 @@ +console.log('c'); diff --git a/test/cli/samples/unfulfilled-hook-actions-manual-exit/index.js b/test/cli/samples/unfulfilled-hook-actions-manual-exit/index.js new file mode 100644 index 00000000000..35468cc3f20 --- /dev/null +++ b/test/cli/samples/unfulfilled-hook-actions-manual-exit/index.js @@ -0,0 +1,3 @@ +import './a.js'; +import './b.js'; +import './c.js'; diff --git a/test/cli/samples/unfulfilled-hook-actions-manual-exit/rollup.config.js b/test/cli/samples/unfulfilled-hook-actions-manual-exit/rollup.config.js new file mode 100644 index 00000000000..0c565b2e067 --- /dev/null +++ b/test/cli/samples/unfulfilled-hook-actions-manual-exit/rollup.config.js @@ -0,0 +1,27 @@ +let resolveA; +const waitForA = new Promise(resolve => (resolveA = resolve)); + +module.exports = { + input: './index.js', + plugins: [ + { + name: 'test', + transform(code, id) { + if (id.endsWith('a.js')) { + resolveA(); + return new Promise(() => {}); + } + if (id.endsWith('b.js')) { + return waitForA.then(() => { + console.error('Manual exit'); + process.exit(1); + return new Promise(() => {}); + }); + } + } + } + ], + output: { + format: 'es' + } +}; diff --git a/test/cli/samples/unfulfilled-hook-actions/_config.js b/test/cli/samples/unfulfilled-hook-actions/_config.js new file mode 100644 index 00000000000..6a420f06fce --- /dev/null +++ b/test/cli/samples/unfulfilled-hook-actions/_config.js @@ -0,0 +1,29 @@ +const assert = require('node:assert'); +const { assertIncludes } = require('../../../testHelpers.js'); + +module.exports = defineTest({ + description: 'show errors with non-zero exit code for unfulfilled async plugin actions on exit', + spawnArgs: ['-c', '--silent'], + after(error) { + // exit code check has to be here as error(err) is only called upon failure + assert.strictEqual(error && error.code, 1); + }, + error() { + // do not abort test upon error + return true; + }, + stderr(stderr) { + console.error(stderr); + assertIncludes( + stderr, + 'Error: Unexpected early exit. This happens when Promises returned by plugins cannot resolve. Unfinished hook action(s) on exit:' + ); + + // these unfulfilled async hook actions may occur in random order + assertIncludes(stderr, '(buggy-plugin) resolveId "./c.js" "main.js"'); + assertIncludes(stderr, '(buggy-plugin) load "./b.js"'); + assertIncludes(stderr, '(buggy-plugin) transform "./a.js"'); + assertIncludes(stderr, '(buggy-plugin) moduleParsed "./d.js"'); + assertIncludes(stderr, '(buggy-plugin) shouldTransformCachedModule "./e.js"'); + } +}); diff --git a/test/cli/samples/unfulfilled-hook-actions/_expected.js b/test/cli/samples/unfulfilled-hook-actions/_expected.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/cli/samples/unfulfilled-hook-actions/a.js b/test/cli/samples/unfulfilled-hook-actions/a.js new file mode 100644 index 00000000000..8609d075540 --- /dev/null +++ b/test/cli/samples/unfulfilled-hook-actions/a.js @@ -0,0 +1 @@ +console.log('a'); diff --git a/test/cli/samples/unfulfilled-hook-actions/b.js b/test/cli/samples/unfulfilled-hook-actions/b.js new file mode 100644 index 00000000000..eeb313a0347 --- /dev/null +++ b/test/cli/samples/unfulfilled-hook-actions/b.js @@ -0,0 +1 @@ +console.log('b'); diff --git a/test/cli/samples/unfulfilled-hook-actions/c.js b/test/cli/samples/unfulfilled-hook-actions/c.js new file mode 100644 index 00000000000..c7857d5f484 --- /dev/null +++ b/test/cli/samples/unfulfilled-hook-actions/c.js @@ -0,0 +1 @@ +console.log('c'); diff --git a/test/cli/samples/unfulfilled-hook-actions/d.js b/test/cli/samples/unfulfilled-hook-actions/d.js new file mode 100644 index 00000000000..3c130f85474 --- /dev/null +++ b/test/cli/samples/unfulfilled-hook-actions/d.js @@ -0,0 +1 @@ +console.log('d'); diff --git a/test/cli/samples/unfulfilled-hook-actions/e.js b/test/cli/samples/unfulfilled-hook-actions/e.js new file mode 100644 index 00000000000..fe97ae732c1 --- /dev/null +++ b/test/cli/samples/unfulfilled-hook-actions/e.js @@ -0,0 +1 @@ +console.log('e'); diff --git a/test/cli/samples/unfulfilled-hook-actions/main.js b/test/cli/samples/unfulfilled-hook-actions/main.js new file mode 100644 index 00000000000..4240ab41f0c --- /dev/null +++ b/test/cli/samples/unfulfilled-hook-actions/main.js @@ -0,0 +1,6 @@ +import './a.js'; +import './b.js'; +import './c.js'; +import './d.js'; +import './e.js'; +console.log('main'); diff --git a/test/cli/samples/unfulfilled-hook-actions/rollup.config.js b/test/cli/samples/unfulfilled-hook-actions/rollup.config.js new file mode 100644 index 00000000000..cc207d43ab3 --- /dev/null +++ b/test/cli/samples/unfulfilled-hook-actions/rollup.config.js @@ -0,0 +1,65 @@ +const path = require('node:path'); +const acorn = require('acorn'); + +function relative(id) { + if (id[0] !== '/') return id; + if (id[0] !== '\\') return id; + return './' + path.relative(process.cwd(), id); +} + +const moduleECode = "console.log('e');\n"; + +module.exports = { + input: 'main.js', + cache: { + modules: [ + { + id: './e.js', + ast: acorn.parse(moduleECode, { + ecmaVersion: 6, + sourceType: 'module' + }), + code: moduleECode, + dependencies: [], + customTransformCache: false, + originalCode: moduleECode, + originalSourcemap: null, + resolvedIds: {}, + sourcemapChain: [], + transformDependencies: [] + } + ] + }, + plugins: [ + { + name: 'buggy-plugin', + resolveId(id) { + if (id.includes('\0')) return; + + // this action will never resolve or reject + if (id.endsWith('c.js')) return new Promise(() => {}); + + return relative(id); + }, + load(id) { + // this action will never resolve or reject + if (id.endsWith('b.js')) return new Promise(() => {}); + }, + transform(code, id) { + // this action will never resolve or reject + if (id.endsWith('a.js')) return new Promise(() => {}); + }, + moduleParsed({ id }) { + // this action will never resolve or reject + if (id.endsWith('d.js')) return new Promise(() => {}); + }, + shouldTransformCachedModule({ id }) { + // this action will never resolve or reject + if (id.endsWith('e.js')) return new Promise(() => {}); + } + } + ], + output: { + format: 'es' + } +}; diff --git a/test/cli/samples/validate/_config.js b/test/cli/samples/validate/_config.js index 5ac726397c6..aab53f1a3f5 100644 --- a/test/cli/samples/validate/_config.js +++ b/test/cli/samples/validate/_config.js @@ -1,18 +1,16 @@ -const { assertIncludes } = require('../../../utils.js'); +const { assertIncludes } = require('../../../testHelpers.js'); -module.exports = { +module.exports = defineTest({ description: 'use CLI --validate to test whether output is well formed', skipIfWindows: true, - command: `rollup main.js --silent --outro 'console.log("end"); /*' -o _actual/out.js --validate`, + spawnArgs: ['main.js', '--outro', 'console.log("end"); /*', '-o', '_actual/out.js', '--validate'], error: () => true, stderr: stderr => assertIncludes( stderr, - `(!) Chunk "out.js" is not valid JavaScript: Unterminated comment (3:20). -out.js (3:20) -1: console.log(2 ); + `(!) out.js (4:0): Chunk "out.js" is not valid JavaScript: Unterminated block comment. +out.js:4:0 2: -3: console.log("end"); /* - ^` +3: console.log("end"); /*` ) -}; +}); diff --git a/test/cli/samples/wait-for-bundle-input-object/_config.js b/test/cli/samples/wait-for-bundle-input-object/_config.js index 981f3ba47a9..f12718a1f30 100644 --- a/test/cli/samples/wait-for-bundle-input-object/_config.js +++ b/test/cli/samples/wait-for-bundle-input-object/_config.js @@ -1,25 +1,26 @@ -const fs = require('fs'); -const path = require('path'); +const { unlinkSync } = require('node:fs'); +const path = require('node:path'); +const { atomicWriteFileSync } = require('../../../testHelpers'); let second; let third; -module.exports = { +module.exports = defineTest({ description: 'waits for multiple named bundle inputs', - command: 'rollup -c --waitForBundleInput', + spawnArgs: ['-c', '--waitForBundleInput'], before() { second = path.resolve(__dirname, 'second.js'); third = path.resolve(__dirname, 'third.js'); }, after() { - fs.unlinkSync(second); - fs.unlinkSync(third); + unlinkSync(second); + unlinkSync(third); }, abortOnStderr(data) { if (data.includes('waiting for input second')) { - fs.writeFileSync(second, "export default 'second'"); + atomicWriteFileSync(second, "export default 'second'"); } else if (data.includes('waiting for input third')) { - fs.writeFileSync(third, "export default 'third'"); + atomicWriteFileSync(third, "export default 'third'"); } } -}; +}); diff --git a/test/cli/samples/wait-for-bundle-input-object/_expected/first.js b/test/cli/samples/wait-for-bundle-input-object/_expected/first.js index 785eab34675..bb02369248d 100644 --- a/test/cli/samples/wait-for-bundle-input-object/_expected/first.js +++ b/test/cli/samples/wait-for-bundle-input-object/_expected/first.js @@ -1,3 +1,3 @@ var first = 'first'; -export default first; +export { first as default }; diff --git a/test/cli/samples/wait-for-bundle-input-object/_expected/second.js b/test/cli/samples/wait-for-bundle-input-object/_expected/second.js index 899b1b288b5..1f1f99ca5b0 100644 --- a/test/cli/samples/wait-for-bundle-input-object/_expected/second.js +++ b/test/cli/samples/wait-for-bundle-input-object/_expected/second.js @@ -1,3 +1,3 @@ var second = 'second'; -export default second; +export { second as default }; diff --git a/test/cli/samples/wait-for-bundle-input-object/_expected/third.js b/test/cli/samples/wait-for-bundle-input-object/_expected/third.js index dce57281308..c7c9bd05263 100644 --- a/test/cli/samples/wait-for-bundle-input-object/_expected/third.js +++ b/test/cli/samples/wait-for-bundle-input-object/_expected/third.js @@ -1,3 +1,3 @@ var third = 'third'; -export default third; +export { third as default }; diff --git a/test/cli/samples/wait-for-bundle-input-object/rollup.config.js b/test/cli/samples/wait-for-bundle-input-object/rollup.config.js index 3a407c77c98..41a3ccaa00a 100644 --- a/test/cli/samples/wait-for-bundle-input-object/rollup.config.js +++ b/test/cli/samples/wait-for-bundle-input-object/rollup.config.js @@ -1,5 +1,3 @@ -var replace = require( '@rollup/plugin-replace' ); - module.exports = { input: { first: 'first', diff --git a/test/cli/samples/wait-for-bundle-input/_config.js b/test/cli/samples/wait-for-bundle-input/_config.js index 045097c443b..3f9df0d7826 100644 --- a/test/cli/samples/wait-for-bundle-input/_config.js +++ b/test/cli/samples/wait-for-bundle-input/_config.js @@ -1,21 +1,24 @@ -const fs = require('fs'); -const path = require('path'); +const { unlinkSync } = require('node:fs'); +const path = require('node:path'); +const { atomicWriteFileSync } = require('../../../testHelpers'); let mainFile; -module.exports = { +module.exports = defineTest({ description: 'waits for bundle input', - command: 'rollup -c --waitForBundleInput', + spawnArgs: ['-c', '--waitForBundleInput'], before() { mainFile = path.resolve(__dirname, 'main.js'); }, after() { - fs.unlinkSync(mainFile); + unlinkSync(mainFile); }, abortOnStderr(data) { if (data.includes('waiting for input main.js')) { // wait longer than one polling interval - setTimeout(() => fs.writeFileSync(mainFile, 'export default 42;'), 600); + setTimeout(() => atomicWriteFileSync(mainFile, 'export default 42;'), 600); } + // We wait for a regular abort as we do not watch + return false; } -}; +}); diff --git a/test/cli/samples/wait-for-bundle-input/_expected.js b/test/cli/samples/wait-for-bundle-input/_expected.js index d862de816a3..c3e30233192 100644 --- a/test/cli/samples/wait-for-bundle-input/_expected.js +++ b/test/cli/samples/wait-for-bundle-input/_expected.js @@ -1,3 +1,3 @@ var main = 42; -export default main; +export { main as default }; diff --git a/test/cli/samples/wait-for-bundle-input/rollup.config.js b/test/cli/samples/wait-for-bundle-input/rollup.config.js index 41a11c6b060..f5c018248fc 100644 --- a/test/cli/samples/wait-for-bundle-input/rollup.config.js +++ b/test/cli/samples/wait-for-bundle-input/rollup.config.js @@ -1,5 +1,3 @@ -var replace = require( '@rollup/plugin-replace' ); - module.exports = { input: 'main.js', output: { diff --git a/test/cli/samples/warn-broken-sourcemap/_config.js b/test/cli/samples/warn-broken-sourcemap/_config.js index 072e9c77998..be7f2b0c5a6 100644 --- a/test/cli/samples/warn-broken-sourcemap/_config.js +++ b/test/cli/samples/warn-broken-sourcemap/_config.js @@ -1,18 +1,18 @@ -const fs = require('fs'); -const path = require('path'); -const { assertIncludes } = require('../../../utils.js'); +const { unlinkSync } = require('node:fs'); +const path = require('node:path'); +const { assertIncludes } = require('../../../testHelpers.js'); -module.exports = { +module.exports = defineTest({ description: 'displays warnings for broken sourcemaps', - command: 'rollup -c', + spawnArgs: ['-c'], stderr: stderr => { - fs.unlinkSync(path.resolve(__dirname, 'bundle')); - fs.unlinkSync(path.resolve(__dirname, 'bundle.map')); + unlinkSync(path.resolve(__dirname, 'bundle')); + unlinkSync(path.resolve(__dirname, 'bundle.map')); assertIncludes( stderr, '(!) Broken sourcemap\n' + - 'https://rollupjs.org/guide/en/#warning-sourcemap-is-likely-to-be-incorrect\n' + - "Plugins that transform code (such as 'test-plugin1') should generate accompanying sourcemaps\n" + 'https://rollupjs.org/troubleshooting/#warning-sourcemap-is-likely-to-be-incorrect\n' + + 'Plugins that transform code (such as "test-plugin1") should generate accompanying sourcemaps.\n' ); } -}; +}); diff --git a/test/cli/samples/warn-broken-sourcemaps/_config.js b/test/cli/samples/warn-broken-sourcemaps/_config.js index 3b7fd70a5eb..b569b346a63 100644 --- a/test/cli/samples/warn-broken-sourcemaps/_config.js +++ b/test/cli/samples/warn-broken-sourcemaps/_config.js @@ -1,18 +1,18 @@ -const fs = require('fs'); -const path = require('path'); -const { assertIncludes } = require('../../../utils.js'); +const { unlinkSync } = require('node:fs'); +const path = require('node:path'); +const { assertIncludes } = require('../../../testHelpers.js'); -module.exports = { +module.exports = defineTest({ description: 'displays warnings for broken sourcemaps', - command: 'rollup -c', + spawnArgs: ['-c'], stderr: stderr => { - fs.unlinkSync(path.resolve(__dirname, 'bundle')); - fs.unlinkSync(path.resolve(__dirname, 'bundle.map')); + unlinkSync(path.resolve(__dirname, 'bundle')); + unlinkSync(path.resolve(__dirname, 'bundle.map')); assertIncludes( stderr, '(!) Broken sourcemap\n' + - 'https://rollupjs.org/guide/en/#warning-sourcemap-is-likely-to-be-incorrect\n' + - "Plugins that transform code (such as 'test-plugin1', 'test-plugin2' and 'test-plugin3') should generate accompanying sourcemaps" + 'https://rollupjs.org/troubleshooting/#warning-sourcemap-is-likely-to-be-incorrect\n' + + 'Plugins that transform code (such as "test-plugin1", "test-plugin2" and "test-plugin3") should generate accompanying sourcemaps' ); } -}; +}); diff --git a/test/cli/samples/warn-circular-multiple/_config.js b/test/cli/samples/warn-circular-multiple/_config.js index 49bf737b7f6..51d522dc170 100644 --- a/test/cli/samples/warn-circular-multiple/_config.js +++ b/test/cli/samples/warn-circular-multiple/_config.js @@ -1,8 +1,8 @@ -const { assertIncludes } = require('../../../utils.js'); +const { assertIncludes } = require('../../../testHelpers.js'); -module.exports = { +module.exports = defineTest({ description: 'warns for multiple circular dependencies', - command: 'rollup -c', + spawnArgs: ['-c'], stderr: stderr => assertIncludes( stderr, @@ -13,4 +13,4 @@ module.exports = { '...and 3 more\n' + '' ) -}; +}); diff --git a/test/cli/samples/warn-circular/_config.js b/test/cli/samples/warn-circular/_config.js index 20038499a4a..aee42d0fe5e 100644 --- a/test/cli/samples/warn-circular/_config.js +++ b/test/cli/samples/warn-circular/_config.js @@ -1,9 +1,9 @@ -const { assertIncludes } = require('../../../utils.js'); +const { assertIncludes } = require('../../../testHelpers.js'); -module.exports = { +module.exports = defineTest({ description: 'warns for circular dependencies', - command: 'rollup -c', + spawnArgs: ['-c'], stderr(stderr) { assertIncludes(stderr, '(!) Circular dependency\nmain.js -> dep.js -> main.js\n'); } -}; +}); diff --git a/test/cli/samples/warn-eval-multiple/_config.js b/test/cli/samples/warn-eval-multiple/_config.js index bd3351df874..562ca6094be 100644 --- a/test/cli/samples/warn-eval-multiple/_config.js +++ b/test/cli/samples/warn-eval-multiple/_config.js @@ -1,13 +1,13 @@ -const { assertIncludes } = require('../../../utils.js'); +const { assertIncludes } = require('../../../testHelpers.js'); -module.exports = { +module.exports = defineTest({ description: 'warns when eval is used multiple times', - command: 'rollup -c', + spawnArgs: ['-c'], stderr: stderr => assertIncludes( stderr, '(!) Use of eval is strongly discouraged\n' + - 'https://rollupjs.org/guide/en/#avoiding-eval\n' + + 'https://rollupjs.org/troubleshooting/#avoiding-eval\n' + 'dep1.js\n' + '1: eval(\'console.log("Hello");\');\n' + ' ^\n' + @@ -25,4 +25,4 @@ module.exports = { '\n' + '...and 3 other files' ) -}; +}); diff --git a/test/cli/samples/warn-eval-multiple/dep6.js b/test/cli/samples/warn-eval-multiple/dep6.js new file mode 100644 index 00000000000..72440d92f09 --- /dev/null +++ b/test/cli/samples/warn-eval-multiple/dep6.js @@ -0,0 +1,3 @@ +export function unused() { + eval('console.log("This eval is unused");'); +} diff --git a/test/cli/samples/warn-eval-multiple/main.js b/test/cli/samples/warn-eval-multiple/main.js index 4ccabe761ef..91d93a77973 100644 --- a/test/cli/samples/warn-eval-multiple/main.js +++ b/test/cli/samples/warn-eval-multiple/main.js @@ -3,5 +3,6 @@ import './dep2.js'; import './dep3.js'; import './dep4.js'; import './dep5.js'; +import './dep6.js'; eval('foo'); diff --git a/test/cli/samples/warn-eval/_config.js b/test/cli/samples/warn-eval/_config.js index 485d58c0f90..bf7226cb087 100644 --- a/test/cli/samples/warn-eval/_config.js +++ b/test/cli/samples/warn-eval/_config.js @@ -1,15 +1,15 @@ -const { assertIncludes } = require('../../../utils.js'); +const { assertIncludes } = require('../../../testHelpers.js'); -module.exports = { +module.exports = defineTest({ description: 'warns when eval is used', - command: 'rollup -c', + spawnArgs: ['-c'], stderr: stderr => assertIncludes( stderr, '(!) Use of eval is strongly discouraged\n' + - 'https://rollupjs.org/guide/en/#avoiding-eval\n' + + 'https://rollupjs.org/troubleshooting/#avoiding-eval\n' + 'main.js\n' + "1: eval('foo');\n" + ' ^' ) -}; +}); diff --git a/test/cli/samples/warn-import-export/_config.js b/test/cli/samples/warn-import-export/_config.js index 904557f5686..b36dd9867b4 100644 --- a/test/cli/samples/warn-import-export/_config.js +++ b/test/cli/samples/warn-import-export/_config.js @@ -1,57 +1,54 @@ -const { assertIncludes } = require('../../../utils.js'); +const { assertIncludes } = require('../../../testHelpers.js'); -module.exports = { +module.exports = defineTest({ description: 'warns about import and export related issues', - command: 'rollup -c', + spawnArgs: ['-c'], stderr: stderr => { assertIncludes( stderr, '(!) Mixing named and default exports\n' + - 'https://rollupjs.org/guide/en/#outputexports\n' + + 'https://rollupjs.org/configuration-options/#output-exports\n' + 'The following entry modules are using named and default exports together:\n' + 'main.js\n' + '\n' + - "Consumers of your bundle will have to use chunk['default'] to access their default export, which may not be what you want. Use `output.exports: 'named'` to disable this warning\n" + 'Consumers of your bundle will have to use chunk.default to access their default export, which may not be what you want. Use `output.exports: "named"` to disable this warning.\n' ); assertIncludes( stderr, '(!) Unused external imports\n' + - "default imported from external module 'external' but never used\n" - ); - assertIncludes( - stderr, - '(!) Import of non-existent export\n' + - 'main.js\n' + - "1: import unused from 'external';\n" + - "2: import * as dep from './dep.js';\n" + - "3: import alsoUnused from './dep.js';\n" + - ' ^\n' + - "4: import 'unresolvedExternal';\n" + `default imported from external module "external" but never used in "main.js".\n` ); assertIncludes( stderr, '(!) Missing exports\n' + - 'https://rollupjs.org/guide/en/#error-name-is-not-exported-by-module\n' + + 'https://rollupjs.org/troubleshooting/#error-name-is-not-exported-by-module\n' + 'main.js\n' + 'missing is not exported by dep.js\n' + "4: import 'unresolvedExternal';\n" + '5: \n' + '6: export const missing = dep.missing;\n' + ' ^\n' + - '7: export default 42;\n' + '7: export default 42;\n' + + 'main.js\n' + + 'default is not exported by dep.js\n' + + "1: import unused from 'external';\n" + + "2: import * as dep from './dep.js';\n" + + "3: import alsoUnused from './dep.js';\n" + + ' ^\n' + + "4: import 'unresolvedExternal';\n" ); assertIncludes( stderr, '(!) Conflicting re-exports\n' + - "main.js re-exports 'foo' from both dep.js and dep2.js (will be ignored)\n" + - "main.js re-exports 'bar' from both dep.js and dep2.js (will be ignored)\n" + '"main.js" re-exports "bar" from both "dep.js" and "dep2.js" (will be ignored).\n' + + '"main.js" re-exports "foo" from both "dep.js" and "dep2.js" (will be ignored).\n' ); assertIncludes( stderr, '(!) Unresolved dependencies\n' + - 'https://rollupjs.org/guide/en/#warning-treating-module-as-external-dependency\n' + - 'unresolvedExternal (imported by main.js, dep.js)\n' + - 'otherUnresolvedExternal (imported by dep.js)\n' + 'https://rollupjs.org/troubleshooting/#warning-treating-module-as-external-dependency\n' + + 'unresolvedExternal (imported by "main.js" and "dep.js")\n' + + 'otherUnresolvedExternal (imported by "dep.js")\n' ); } -}; +}); diff --git a/test/cli/samples/warn-missing-global-multiple/_config.js b/test/cli/samples/warn-missing-global-multiple/_config.js index ecb11f71e5e..53867125758 100644 --- a/test/cli/samples/warn-missing-global-multiple/_config.js +++ b/test/cli/samples/warn-missing-global-multiple/_config.js @@ -1,15 +1,16 @@ -const { assertIncludes } = require('../../../utils.js'); +const { assertIncludes } = require('../../../testHelpers.js'); -module.exports = { +module.exports = defineTest({ description: 'warns when there are multiple missing globals', - command: 'rollup -c', + spawnArgs: ['-c'], stderr: stderr => assertIncludes( stderr, '(!) Missing global variable names\n' + - 'Use output.globals to specify browser global variable names corresponding to external modules\n' + - "external1 (guessing 'foo1')\n" + - "external2 (guessing 'foo2')\n" + - "external3 (guessing 'foo3')" + 'https://rollupjs.org/configuration-options/#output-globals\n' + + 'Use "output.globals" to specify browser global variable names corresponding to external modules:\n' + + 'external1 (guessing "foo1")\n' + + 'external2 (guessing "foo2")\n' + + 'external3 (guessing "foo3")' ) -}; +}); diff --git a/test/cli/samples/warn-missing-global/_config.js b/test/cli/samples/warn-missing-global/_config.js index ffa8470c384..f4f55f05999 100644 --- a/test/cli/samples/warn-missing-global/_config.js +++ b/test/cli/samples/warn-missing-global/_config.js @@ -1,13 +1,14 @@ -const { assertIncludes } = require('../../../utils.js'); +const { assertIncludes } = require('../../../testHelpers.js'); -module.exports = { +module.exports = defineTest({ description: 'warns when there is a missing global variable name', - command: 'rollup -c', + spawnArgs: ['-c'], stderr: stderr => assertIncludes( stderr, '(!) Missing global variable name\n' + - 'Use output.globals to specify browser global variable names corresponding to external modules\n' + - "external (guessing 'foo')" + 'https://rollupjs.org/configuration-options/#output-globals\n' + + 'Use "output.globals" to specify browser global variable names corresponding to external modules:\n' + + 'external (guessing "foo")' ) -}; +}); diff --git a/test/cli/samples/warn-mixed-exports-multiple/_config.js b/test/cli/samples/warn-mixed-exports-multiple/_config.js index 7fc2b822221..3a7d96f5e92 100644 --- a/test/cli/samples/warn-mixed-exports-multiple/_config.js +++ b/test/cli/samples/warn-mixed-exports-multiple/_config.js @@ -1,20 +1,20 @@ -const { assertIncludes } = require('../../../utils.js'); +const { assertIncludes } = require('../../../testHelpers.js'); -module.exports = { +module.exports = defineTest({ description: 'warns when mixed exports are used', - command: 'rollup -c', + spawnArgs: ['-c'], stderr: stderr => { assertIncludes( stderr, '(!) Mixing named and default exports\n' + - 'https://rollupjs.org/guide/en/#outputexports\n' + + 'https://rollupjs.org/configuration-options/#output-exports\n' + 'The following entry modules are using named and default exports together:\n' + - 'main.js\n' + 'lib1.js\n' + 'lib2.js\n' + + 'lib3.js\n' + '...and 3 other entry modules\n' + '\n' + - "Consumers of your bundle will have to use chunk['default'] to access their default export, which may not be what you want. Use `output.exports: 'named'` to disable this warning\n" + 'Consumers of your bundle will have to use chunk.default to access their default export, which may not be what you want. Use `output.exports: "named"` to disable this warning.\n' ); } -}; +}); diff --git a/test/cli/samples/warn-mixed-exports-multiple/rollup.config.js b/test/cli/samples/warn-mixed-exports-multiple/rollup.config.js index 2ee4513c4c5..083e1a120ef 100644 --- a/test/cli/samples/warn-mixed-exports-multiple/rollup.config.js +++ b/test/cli/samples/warn-mixed-exports-multiple/rollup.config.js @@ -1,7 +1,7 @@ module.exports = { input: 'main.js', - preserveModules: true, output: { - format: 'amd' + format: 'amd', + preserveModules: true } }; diff --git a/test/cli/samples/warn-multiple/_config.js b/test/cli/samples/warn-multiple/_config.js index 3b3474524de..72b939acf6b 100644 --- a/test/cli/samples/warn-multiple/_config.js +++ b/test/cli/samples/warn-multiple/_config.js @@ -1,35 +1,44 @@ -const { assertIncludes } = require('../../../utils.js'); +const path = require('node:path'); +const { assertIncludes } = require('../../../testHelpers.js'); -module.exports = { +module.exports = defineTest({ description: 'aggregates warnings of different types', - command: 'rollup -c', + spawnArgs: ['-c'], stderr: stderr => { assertIncludes( stderr, '(!) Missing shims for Node.js built-ins\n' + - "Creating a browser bundle that depends on 'url', 'assert' and 'path'. You might need to include https://github.com/ionic-team/rollup-plugin-node-polyfills\n" + 'Creating a browser bundle that depends on "url", "assert" and "node:path". You might need to include https://github.com/FredKSchott/rollup-plugin-polyfill-node\n' ); assertIncludes( stderr, - '(!) Import of non-existent exports\n' + + '(!) Missing exports\n' + + 'https://rollupjs.org/troubleshooting/#error-name-is-not-exported-by-module\n' + 'main.js\n' + + 'doesNotExist is not exported by dep.js\n' + "4: import assert from 'assert';\n" + - "5: import path from 'path';\n" + + "5: import path from 'node:path';\n" + "6: import {doesNotExist, alsoNotFound} from './dep.js';\n" + ' ^\n' + '7: \n' + '8: export {url, assert, path};\n' + - '...and 1 other occurrence\n' + 'main.js\n' + + 'alsoNotFound is not exported by dep.js\n' + + "4: import assert from 'assert';\n" + + "5: import path from 'node:path';\n" + + "6: import {doesNotExist, alsoNotFound} from './dep.js';\n" + + ' ^\n' + + '7: \n' + + '8: export {url, assert, path};' ); assertIncludes( - stderr, - - "(!) Module level directives cause errors when bundled, 'use stuff' was ignored.\n" + - 'main.js (1:0)\n' + + stderr.replaceAll(__dirname + path.sep, 'CWD/'), + '(!) main.js (1:0): Module level directives cause errors when bundled, "use stuff" in "main.js" was ignored.\n' + + 'CWD/main.js:1:0\n' + "1: 'use stuff';\n" + ' ^\n' + '2: \n' + "3: import url from 'url';\n" ); } -}; +}); diff --git a/test/cli/samples/warn-multiple/main.js b/test/cli/samples/warn-multiple/main.js index 809f20ffe84..968daf9ba57 100644 --- a/test/cli/samples/warn-multiple/main.js +++ b/test/cli/samples/warn-multiple/main.js @@ -2,7 +2,7 @@ import url from 'url'; import assert from 'assert'; -import path from 'path'; +import path from 'node:path'; import {doesNotExist, alsoNotFound} from './dep.js'; export {url, assert, path}; diff --git a/test/cli/samples/warn-plugin-loc/_config.js b/test/cli/samples/warn-plugin-loc/_config.js index 8b8f52bb4e9..ba60f8a9324 100644 --- a/test/cli/samples/warn-plugin-loc/_config.js +++ b/test/cli/samples/warn-plugin-loc/_config.js @@ -1,17 +1,18 @@ -const { assertIncludes } = require('../../../utils.js'); +const path = require('node:path'); +const { assertIncludes } = require('../../../testHelpers.js'); -module.exports = { +module.exports = defineTest({ description: 'correctly adds locations to plugin warnings', - command: 'rollup -c', + spawnArgs: ['-c'], stderr: stderr => { assertIncludes( - stderr, - '(!) Plugin test: Warning with file and id\n' + - 'file1: (1:2)\n' + - '(!) Plugin test: Warning with file\n' + - 'file2: (2:3)\n' + - '(!) Plugin test: Warning with id\n' + - 'file-id3: (3:4)\n' + stderr.replaceAll(__dirname + path.sep, 'CWD/'), + '(!) [plugin test] file1 (1:2): Warning with file and id\n' + + 'CWD/file1:1:2\n' + + '(!) [plugin test] file2 (2:3): Warning with file\n' + + 'CWD/file2:2:3\n' + + '(!) [plugin test] file-id3 (3:4): Warning with id\n' + + 'CWD/file-id3:3:4\n' ); } -}; +}); diff --git a/test/cli/samples/warn-plugin-loc/rollup.config.js b/test/cli/samples/warn-plugin-loc/rollup.config.js index 78f47655e95..c3ac82c3866 100644 --- a/test/cli/samples/warn-plugin-loc/rollup.config.js +++ b/test/cli/samples/warn-plugin-loc/rollup.config.js @@ -1,4 +1,4 @@ -const path = require('path'); +const path = require('node:path'); module.exports = { input: 'main.js', diff --git a/test/cli/samples/warn-plugin/_config.js b/test/cli/samples/warn-plugin/_config.js index c02c8d5b693..bc2591457fc 100644 --- a/test/cli/samples/warn-plugin/_config.js +++ b/test/cli/samples/warn-plugin/_config.js @@ -1,18 +1,25 @@ -const { assertIncludes } = require('../../../utils.js'); +const path = require('node:path'); +const { assertIncludes } = require('../../../testHelpers.js'); -module.exports = { +module.exports = defineTest({ description: 'displays warnings from plugins', - command: 'rollup -c', - stderr: stderr => + spawnArgs: ['-c'], + env: { FORCE_COLOR: undefined, NO_COLOR: true }, + stderr: stderr => { assertIncludes( - stderr, - '(!) Plugin test-plugin: First\n' + - '(!) Plugin test-plugin: Second\n' + + stderr.replaceAll(__dirname + path.sep, 'CWD/'), + '[plugin second-plugin] other.js: Fifth\n' + 'CWD/other.js\n' + ); + assertIncludes( + stderr.replaceAll(__dirname + path.sep, 'CWD/'), + '(!) [plugin test-plugin] First\n' + + '(!) [plugin test-plugin] Second\n' + 'https://information\n' + - '(!) Plugin second-plugin: Third\n' + - 'other.js\n' + - '(!) Plugin second-plugin: Fourth\n' + - 'other.js: (1:2)\n' + + '(!) [plugin second-plugin] other.js: Third\n' + + 'CWD/other.js\n' + + '(!) [plugin second-plugin] other.js (1:2): Fourth\n' + + 'CWD/other.js:1:2\n' + 'custom frame' - ) -}; + ); + } +}); diff --git a/test/cli/samples/warn-plugin/rollup.config.js b/test/cli/samples/warn-plugin/rollup.config.js index 55404aa5ab5..1adb93cb3b6 100644 --- a/test/cli/samples/warn-plugin/rollup.config.js +++ b/test/cli/samples/warn-plugin/rollup.config.js @@ -1,4 +1,4 @@ -const path = require('path'); +const path = require('node:path'); module.exports = { input: 'main.js', @@ -25,6 +25,7 @@ module.exports = { loc: { line: 1, column: 2 }, frame: 'custom frame' }); + this.info({ message: 'Fifth', id: path.resolve(__dirname, 'other.js') }); } } ] diff --git a/test/cli/samples/warn-this/_config.js b/test/cli/samples/warn-this/_config.js index 8b6990286bd..3fe691215d9 100644 --- a/test/cli/samples/warn-this/_config.js +++ b/test/cli/samples/warn-this/_config.js @@ -1,15 +1,15 @@ -const { assertIncludes } = require('../../../utils.js'); +const { assertIncludes } = require('../../../testHelpers.js'); -module.exports = { +module.exports = defineTest({ description: 'warns "this" is used on the top level', - command: 'rollup -c', + spawnArgs: ['-c'], stderr: stderr => assertIncludes( stderr, - '(!) `this` has been rewritten to `undefined`\n' + - 'https://rollupjs.org/guide/en/#error-this-is-undefined\n' + + '(!) "this" has been rewritten to "undefined"\n' + + 'https://rollupjs.org/troubleshooting/#error-this-is-undefined\n' + 'main.js\n' + '1: console.log(this);\n' + ' ^' ) -}; +}); diff --git a/test/cli/samples/warn-unknown-options/_config.js b/test/cli/samples/warn-unknown-options/_config.js index 5b68f78dcce..ef865517bbc 100644 --- a/test/cli/samples/warn-unknown-options/_config.js +++ b/test/cli/samples/warn-unknown-options/_config.js @@ -1,4 +1,12 @@ -module.exports = { +module.exports = defineTest({ description: 'warns about unknown CLI options', - command: 'rollup --config rollup.config.js --format es --configAnswer 42 --unknownOption' -}; + spawnArgs: [ + '--config', + 'rollup.config.js', + '--format', + 'es', + '--configAnswer', + '42', + '--unknownOption' + ] +}); diff --git a/test/cli/samples/warn-unknown-options/rollup.config.js b/test/cli/samples/warn-unknown-options/rollup.config.js index 86f91664236..4a166b64040 100644 --- a/test/cli/samples/warn-unknown-options/rollup.config.js +++ b/test/cli/samples/warn-unknown-options/rollup.config.js @@ -1,26 +1,28 @@ -var replace = require('@rollup/plugin-replace'); -var assert = require('assert'); +const assert = require('node:assert'); +const replace = require('@rollup/plugin-replace'); let warnings = 0; -module.exports = commands => ({ - input: 'main.js', - plugins: [ - { - generateBundle() { - assert.strictEqual(warnings, 1); - } - }, - replace({ ANSWER: commands.configAnswer }) - ], - onwarn(warning) { - warnings++; - assert.equal(warning.code, 'UNKNOWN_OPTION'); - assert.equal( - warning.message, - `Unknown CLI flags: unknownOption. Allowed options: ${ - require('../../../misc/optionList').flags - }` - ); - } -}); +module.exports = function getConfig(commands) { + return { + input: 'main.js', + plugins: [ + { + generateBundle() { + assert.strictEqual(warnings, 1); + } + }, + replace({ preventAssignment: true, ANSWER: commands.configAnswer }) + ], + onwarn(warning) { + warnings++; + assert.equal(warning.code, 'UNKNOWN_OPTION'); + assert.equal( + warning.message, + `Unknown CLI flags: unknownOption. Allowed options: ${ + require('../../../misc/optionList').flags + }` + ); + } + }; +}; diff --git a/test/cli/samples/watch/bundle-error/_config.js b/test/cli/samples/watch/bundle-error/_config.js index 7b101a1bc14..322eea18d07 100644 --- a/test/cli/samples/watch/bundle-error/_config.js +++ b/test/cli/samples/watch/bundle-error/_config.js @@ -1,26 +1,27 @@ -const fs = require('fs'); -const path = require('path'); +const { unlinkSync, writeFileSync } = require('node:fs'); +const path = require('node:path'); +const { atomicWriteFileSync } = require('../../../../testHelpers'); let mainFile; -module.exports = { +module.exports = defineTest({ description: 'recovers from errors during bundling', - command: 'rollup -cw', + spawnArgs: ['-cw', '--bundleConfigAsCjs'], before() { mainFile = path.resolve(__dirname, 'main.js'); - fs.writeFileSync(mainFile, '<=>'); + writeFileSync(mainFile, '<=>'); }, after() { // synchronous sometimes does not seem to work, probably because the watch is not yet removed properly - setTimeout(() => fs.unlinkSync(mainFile), 300); + setTimeout(() => unlinkSync(mainFile), 300); }, abortOnStderr(data) { - if (data.includes('Error: Unexpected token')) { - setTimeout(() => fs.writeFileSync(mainFile, 'export default 42;'), 500); + if (data.includes('[!] RollupError: main.js (1:0): Expression expected')) { + setTimeout(() => atomicWriteFileSync(mainFile, 'export default 42;'), 500); return false; } if (data.includes('created _actual')) { return true; } } -}; +}); diff --git a/test/cli/samples/watch/bundle-error/_expected/main.js b/test/cli/samples/watch/bundle-error/_expected/main.js index d862de816a3..c3e30233192 100644 --- a/test/cli/samples/watch/bundle-error/_expected/main.js +++ b/test/cli/samples/watch/bundle-error/_expected/main.js @@ -1,3 +1,3 @@ var main = 42; -export default main; +export { main as default }; diff --git a/test/cli/samples/watch/bundle-error/rollup.config.js b/test/cli/samples/watch/bundle-error/rollup.config.js index 0c8c1cb886e..d6f089f1d52 100644 --- a/test/cli/samples/watch/bundle-error/rollup.config.js +++ b/test/cli/samples/watch/bundle-error/rollup.config.js @@ -1,7 +1,7 @@ export default { input: 'main.js', output: { - dir: "_actual", - format: "es" + dir: '_actual', + format: 'es' } }; diff --git a/test/cli/samples/watch/clearScreen/_config.js b/test/cli/samples/watch/clearScreen/_config.js index 12e37ec1e8c..ee6bd9eb1fd 100644 --- a/test/cli/samples/watch/clearScreen/_config.js +++ b/test/cli/samples/watch/clearScreen/_config.js @@ -1,11 +1,12 @@ -const assert = require('assert'); +const assert = require('node:assert'); -const CLEAR_SCREEN = '\u001bc'; -const UNDERLINE = '\u001b[4m'; +const CLEAR_SCREEN = '\u001Bc'; +const UNDERLINE = '\u001B[4m'; -module.exports = { +module.exports = defineTest({ description: 'clears the screen before bundling', - command: 'node wrapper.js -cw', + spawnScript: 'wrapper.js', + spawnArgs: ['-cw'], env: { FORCE_COLOR: '1', TERM: 'xterm' }, abortOnStderr(data) { if (data.includes('waiting for changes')) { @@ -14,5 +15,5 @@ module.exports = { }, stderr(stderr) { assert.strictEqual(stderr.slice(0, 12), `${CLEAR_SCREEN}${UNDERLINE}rollup`); - }, -}; + } +}); diff --git a/test/cli/samples/watch/clearScreen/rollup.config.js b/test/cli/samples/watch/clearScreen/rollup.config.mjs similarity index 100% rename from test/cli/samples/watch/clearScreen/rollup.config.js rename to test/cli/samples/watch/clearScreen/rollup.config.mjs diff --git a/test/cli/samples/watch/clearScreen/wrapper.js b/test/cli/samples/watch/clearScreen/wrapper.js index 8f733cc8815..57f1e1c7333 100755 --- a/test/cli/samples/watch/clearScreen/wrapper.js +++ b/test/cli/samples/watch/clearScreen/wrapper.js @@ -2,4 +2,5 @@ process.stdout.isTTY = true; process.stderr.isTTY = true; +process.stderr.hasColors = () => true; require('../../../../../dist/bin/rollup'); diff --git a/test/cli/samples/watch/close-error/_config.js b/test/cli/samples/watch/close-error/_config.js index 02dbfdd4b9e..97754104656 100644 --- a/test/cli/samples/watch/close-error/_config.js +++ b/test/cli/samples/watch/close-error/_config.js @@ -1,9 +1,9 @@ -module.exports = { +module.exports = defineTest({ description: 'displays errors when closing the watcher', - command: 'rollup -cw', + spawnArgs: ['-cw'], abortOnStderr(data) { if (data.includes('[!] (plugin faulty-close) Error: Close bundle failed')) { return true; } } -}; +}); diff --git a/test/cli/samples/watch/close-error/_expected/main.js b/test/cli/samples/watch/close-error/_expected/main.js index d862de816a3..c3e30233192 100644 --- a/test/cli/samples/watch/close-error/_expected/main.js +++ b/test/cli/samples/watch/close-error/_expected/main.js @@ -1,3 +1,3 @@ var main = 42; -export default main; +export { main as default }; diff --git a/test/cli/samples/watch/close-error/rollup.config.js b/test/cli/samples/watch/close-error/rollup.config.js deleted file mode 100644 index f115555c1e4..00000000000 --- a/test/cli/samples/watch/close-error/rollup.config.js +++ /dev/null @@ -1,15 +0,0 @@ -export default { - input: 'main.js', - plugins: [ - { - name: 'faulty-close', - closeBundle() { - throw new Error('Close bundle failed'); - } - } - ], - output: { - dir: "_actual", - format: "es" - } -}; diff --git a/test/cli/samples/watch/close-error/rollup.config.mjs b/test/cli/samples/watch/close-error/rollup.config.mjs new file mode 100644 index 00000000000..cdd8bdc5f4a --- /dev/null +++ b/test/cli/samples/watch/close-error/rollup.config.mjs @@ -0,0 +1,15 @@ +export default { + input: 'main.js', + plugins: [ + { + name: 'faulty-close', + closeBundle() { + throw new Error('Close bundle failed'); + } + } + ], + output: { + dir: '_actual', + format: 'es' + } +}; diff --git a/test/cli/samples/watch/close-on-generate-error/_config.js b/test/cli/samples/watch/close-on-generate-error/_config.js index a94f8646c41..f22ccf54880 100644 --- a/test/cli/samples/watch/close-on-generate-error/_config.js +++ b/test/cli/samples/watch/close-on-generate-error/_config.js @@ -1,8 +1,8 @@ -const { assertIncludes } = require('../../../../utils.js'); +const { assertIncludes } = require('../../../../testHelpers.js'); -module.exports = { +module.exports = defineTest({ description: 'closes the bundle on generate errors', - command: 'rollup -cw', + spawnArgs: ['-cw'], abortOnStderr(data) { if (data.includes('Bundle closed')) { return true; @@ -11,9 +11,9 @@ module.exports = { stderr(stderr) { assertIncludes( stderr, - '[!] Error: You must specify "output.file" or "output.dir" for the build.' + '[!] RollupError: You must specify "output.file" or "output.dir" for the build.' ); assertIncludes(stderr, 'Bundle closed'); return false; } -}; +}); diff --git a/test/cli/samples/watch/close-on-generate-error/rollup.config.js b/test/cli/samples/watch/close-on-generate-error/rollup.config.js deleted file mode 100644 index 2b5ed8843ea..00000000000 --- a/test/cli/samples/watch/close-on-generate-error/rollup.config.js +++ /dev/null @@ -1,14 +0,0 @@ -export default { - input: 'main.js', - plugins: [ - { - name: 'faulty-close', - closeBundle() { - console.error('Bundle closed') - } - } - ], - output: { - format: "es" - } -}; diff --git a/test/cli/samples/watch/close-on-generate-error/rollup.config.mjs b/test/cli/samples/watch/close-on-generate-error/rollup.config.mjs new file mode 100644 index 00000000000..17b7459115e --- /dev/null +++ b/test/cli/samples/watch/close-on-generate-error/rollup.config.mjs @@ -0,0 +1,14 @@ +export default { + input: 'main.js', + plugins: [ + { + name: 'faulty-close', + closeBundle() { + console.error('Bundle closed'); + } + } + ], + output: { + format: 'es' + } +}; diff --git a/test/cli/samples/watch/close-stdin/_config.js b/test/cli/samples/watch/close-stdin/_config.js index 5237535140f..646a07e7e76 100644 --- a/test/cli/samples/watch/close-stdin/_config.js +++ b/test/cli/samples/watch/close-stdin/_config.js @@ -1,4 +1,10 @@ -module.exports = { - command: 'node wrapper.js main.js --watch --format es --file _actual/out.js', - description: 'closes the watcher when stdin closes' -}; +module.exports = defineTest({ + description: 'does not close the watcher when stdin closes to support watch mode in containers', + spawnScript: 'wrapper.js', + spawnArgs: ['main.js', '--watch', '--format', 'es', '--file', '_actual/out.js'], + abortOnStderr(data) { + if (data.includes('waiting for changes')) { + return true; + } + } +}); diff --git a/test/cli/samples/watch/close-stdin/_expected/out.js b/test/cli/samples/watch/close-stdin/_expected/out.js index d862de816a3..c3e30233192 100644 --- a/test/cli/samples/watch/close-stdin/_expected/out.js +++ b/test/cli/samples/watch/close-stdin/_expected/out.js @@ -1,3 +1,3 @@ var main = 42; -export default main; +export { main as default }; diff --git a/test/cli/samples/watch/close-stdin/wrapper.js b/test/cli/samples/watch/close-stdin/wrapper.js index a978de79c4b..d727e6e8ead 100755 --- a/test/cli/samples/watch/close-stdin/wrapper.js +++ b/test/cli/samples/watch/close-stdin/wrapper.js @@ -1,30 +1,15 @@ #!/usr/bin/env node -const stream = require('stream'); -const fs = require('fs'); -const chokidar = require('chokidar'); -const path = require('path'); +const { Readable } = require('node:stream'); delete process.stdin; -process.stdin = new stream.Readable({ +process.stdin = new Readable({ encoding: 'utf8', read() { return null; } }); -const outputDir = path.resolve(__dirname, '_actual'); -fs.mkdirSync(outputDir); -const outputFile = path.resolve(outputDir, 'out.js'); -const INITIAL_OUTPUT = 'NOT WRITTEN'; -fs.writeFileSync(outputFile, INITIAL_OUTPUT); - -const watcher = chokidar.watch(outputFile).on('change', () => { - if (fs.readFileSync(outputFile, 'utf8') !== INITIAL_OUTPUT) { - watcher.close(); - // This closes stdin - process.stdin.push(null); - } -}); +process.stdin.push(null) require('../../../../../dist/bin/rollup'); diff --git a/test/cli/samples/watch/filter-logs/_config.js b/test/cli/samples/watch/filter-logs/_config.js new file mode 100644 index 00000000000..9872abac21d --- /dev/null +++ b/test/cli/samples/watch/filter-logs/_config.js @@ -0,0 +1,34 @@ +const { assertIncludes } = require('../../../../testHelpers.js'); + +module.exports = defineTest({ + description: 'filters logs via CLI in watch mode', + spawnArgs: [ + '--config', + '--watch', + '--filterLogs=pluginCode:FIRST,pluginCode:SECOND', + '--filterLogs=pluginCode:THIRD' + ], + env: { + FORCE_COLOR: undefined, + NO_COLOR: true, + ROLLUP_FILTER_LOGS: 'pluginCode:FOURTH,pluginCode:FIFTH' + }, + abortOnStderr(data) { + if (data.startsWith('created _actual.js')) { + return true; + } + }, + stderr(stderr) { + assertIncludes( + stderr, + ` +bundles main.js → _actual.js... +[plugin test] first +[plugin test] second +[plugin test] third +[plugin test] fourth +[plugin test] fifth +created _actual.js` + ); + } +}); diff --git a/test/cli/samples/watch/filter-logs/main.js b/test/cli/samples/watch/filter-logs/main.js new file mode 100644 index 00000000000..e37ed30c344 --- /dev/null +++ b/test/cli/samples/watch/filter-logs/main.js @@ -0,0 +1 @@ +assert.ok( true ); diff --git a/test/cli/samples/watch/filter-logs/rollup.config.mjs b/test/cli/samples/watch/filter-logs/rollup.config.mjs new file mode 100644 index 00000000000..202638a96c2 --- /dev/null +++ b/test/cli/samples/watch/filter-logs/rollup.config.mjs @@ -0,0 +1,22 @@ +export default { + input: 'main.js', + logLevel: 'debug', + plugins: [ + { + name: 'test', + buildStart() { + this.info({message: 'removed', pluginCode: 'REMOVED'}); + this.info({message: 'first', pluginCode: 'FIRST'}); + this.info({message: 'second', pluginCode: 'SECOND'}); + this.info({message: 'third', pluginCode: 'THIRD'}); + this.info({message: 'fourth', pluginCode: 'FOURTH'}); + this.info({message: 'fifth', pluginCode: 'FIFTH'}); + this.info({message: 'filtered', pluginCode: 'FILTERED'}); + }, + } + ], + output: { + format: 'es', + file: '_actual.js' + } +}; diff --git a/test/cli/samples/watch/filter-logs/wrapper.js b/test/cli/samples/watch/filter-logs/wrapper.js new file mode 100755 index 00000000000..355d81420fa --- /dev/null +++ b/test/cli/samples/watch/filter-logs/wrapper.js @@ -0,0 +1,4 @@ +#!/usr/bin/env node + +process.stdout.isTTY = true; +require('../../../../dist/bin/rollup'); diff --git a/test/cli/samples/watch/no-clearScreen-command/_config.js b/test/cli/samples/watch/no-clearScreen-command/_config.js index 827267699ae..b8510c0bb67 100644 --- a/test/cli/samples/watch/no-clearScreen-command/_config.js +++ b/test/cli/samples/watch/no-clearScreen-command/_config.js @@ -1,10 +1,19 @@ -const assert = require('assert'); +const assert = require('node:assert'); -const UNDERLINE = '\u001b[4m'; +const UNDERLINE = '\u001B[4m'; -module.exports = { +module.exports = defineTest({ description: 'allows disabling clearing the screen from the command line', - command: 'node wrapper.js main.js --format es --file _actual.js --watch --no-watch.clearScreen', + spawnScript: 'wrapper.js', + spawnArgs: [ + 'main.js', + '--format', + 'es', + '--file', + '_actual.js', + '--watch', + '--no-watch.clearScreen' + ], env: { FORCE_COLOR: '1', TERM: 'xterm' }, abortOnStderr(data) { if (data.includes('waiting for changes')) { @@ -14,4 +23,4 @@ module.exports = { stderr(stderr) { assert.strictEqual(stderr.slice(0, 10), `${UNDERLINE}rollup`); } -}; +}); diff --git a/test/cli/samples/watch/no-clearScreen-command/wrapper.js b/test/cli/samples/watch/no-clearScreen-command/wrapper.js index 8f733cc8815..57f1e1c7333 100755 --- a/test/cli/samples/watch/no-clearScreen-command/wrapper.js +++ b/test/cli/samples/watch/no-clearScreen-command/wrapper.js @@ -2,4 +2,5 @@ process.stdout.isTTY = true; process.stderr.isTTY = true; +process.stderr.hasColors = () => true; require('../../../../../dist/bin/rollup'); diff --git a/test/cli/samples/watch/no-clearScreen/_config.js b/test/cli/samples/watch/no-clearScreen/_config.js index 88a66da2061..bb7142d603f 100644 --- a/test/cli/samples/watch/no-clearScreen/_config.js +++ b/test/cli/samples/watch/no-clearScreen/_config.js @@ -1,10 +1,11 @@ -const assert = require('assert'); +const assert = require('node:assert'); -const UNDERLINE = '\u001b[4m'; +const UNDERLINE = '\u001B[4m'; -module.exports = { +module.exports = defineTest({ description: 'allows disabling clearing the screen', - command: 'node wrapper.js -cw', + spawnScript: 'wrapper.js', + spawnArgs: ['-cw'], env: { FORCE_COLOR: '1', TERM: 'xterm' }, abortOnStderr(data) { if (data.includes('waiting for changes')) { @@ -13,5 +14,5 @@ module.exports = { }, stderr(stderr) { assert.strictEqual(stderr.slice(0, 10), `${UNDERLINE}rollup`); - }, -}; + } +}); diff --git a/test/cli/samples/watch/no-clearScreen/rollup.config.js b/test/cli/samples/watch/no-clearScreen/rollup.config.js deleted file mode 100644 index a171128d7c0..00000000000 --- a/test/cli/samples/watch/no-clearScreen/rollup.config.js +++ /dev/null @@ -1,22 +0,0 @@ -export default [ - { - input: 'main.js', - output: { - file: '_actual.js', - format: 'es', - }, - watch: { - clearScreen: true, - }, - }, - { - input: 'main.js', - output: { - file: '_actual.js', - format: 'es', - }, - watch: { - clearScreen: false, - }, - }, -]; diff --git a/test/cli/samples/watch/no-clearScreen/rollup.config.mjs b/test/cli/samples/watch/no-clearScreen/rollup.config.mjs new file mode 100644 index 00000000000..e9a069dccb2 --- /dev/null +++ b/test/cli/samples/watch/no-clearScreen/rollup.config.mjs @@ -0,0 +1,22 @@ +export default [ + { + input: 'main.js', + output: { + file: '_actual.js', + format: 'es' + }, + watch: { + clearScreen: true + } + }, + { + input: 'main.js', + output: { + file: '_actual.js', + format: 'es' + }, + watch: { + clearScreen: false + } + } +]; diff --git a/test/cli/samples/watch/no-clearScreen/wrapper.js b/test/cli/samples/watch/no-clearScreen/wrapper.js index 8f733cc8815..57f1e1c7333 100755 --- a/test/cli/samples/watch/no-clearScreen/wrapper.js +++ b/test/cli/samples/watch/no-clearScreen/wrapper.js @@ -2,4 +2,5 @@ process.stdout.isTTY = true; process.stderr.isTTY = true; +process.stderr.hasColors = () => true; require('../../../../../dist/bin/rollup'); diff --git a/test/cli/samples/watch/no-config-file/_config.js b/test/cli/samples/watch/no-config-file/_config.js index f3f030d4806..d9a650f07bf 100644 --- a/test/cli/samples/watch/no-config-file/_config.js +++ b/test/cli/samples/watch/no-config-file/_config.js @@ -1,9 +1,9 @@ -module.exports = { +module.exports = defineTest({ description: 'watches without a config file', - command: 'rollup main.js --watch --format es --file _actual/main.js', + spawnArgs: ['main.js', '--watch', '--format', 'es', '--file', '_actual/main.js'], abortOnStderr(data) { - if (data.includes('created _actual/main.js')) { + if (data.includes(`created _actual/main.js`)) { return true; } - }, -}; + } +}); diff --git a/test/cli/samples/watch/no-watch-by-default/_config.js b/test/cli/samples/watch/no-watch-by-default/_config.js new file mode 100644 index 00000000000..b2498922108 --- /dev/null +++ b/test/cli/samples/watch/no-watch-by-default/_config.js @@ -0,0 +1,13 @@ +const { assertIncludes } = require('../../../../testHelpers'); + +module.exports = defineTest({ + description: 'does not watch if --watch is missing', + spawnScript: 'wrapper.js', + spawnArgs: ['-c', '--no-watch.clearScreen'], + stderr: stderr => assertIncludes(stderr, 'main.js → _actual.js...\ncreated _actual.js in'), + abortOnStderr(data) { + if (data.includes('waiting for changes')) { + throw new Error('Watch initiated'); + } + } +}); diff --git a/test/function/samples/deprecations/inlineDynamicImports/main.js b/test/cli/samples/watch/no-watch-by-default/main.js similarity index 100% rename from test/function/samples/deprecations/inlineDynamicImports/main.js rename to test/cli/samples/watch/no-watch-by-default/main.js diff --git a/test/cli/samples/watch/no-watch-by-default/rollup.config.mjs b/test/cli/samples/watch/no-watch-by-default/rollup.config.mjs new file mode 100644 index 00000000000..c76705abd68 --- /dev/null +++ b/test/cli/samples/watch/no-watch-by-default/rollup.config.mjs @@ -0,0 +1,9 @@ +export default [ + { + input: 'main.js', + output: { + file: '_actual.js', + format: 'es' + } + } +]; diff --git a/test/cli/samples/watch/no-watch-by-default/wrapper.js b/test/cli/samples/watch/no-watch-by-default/wrapper.js new file mode 100755 index 00000000000..57f1e1c7333 --- /dev/null +++ b/test/cli/samples/watch/no-watch-by-default/wrapper.js @@ -0,0 +1,6 @@ +#!/usr/bin/env node + +process.stdout.isTTY = true; +process.stderr.isTTY = true; +process.stderr.hasColors = () => true; +require('../../../../../dist/bin/rollup'); diff --git a/test/cli/samples/watch/no-watched-config/_config.js b/test/cli/samples/watch/no-watched-config/_config.js index fbf10ff6755..ce3ec650fec 100644 --- a/test/cli/samples/watch/no-watched-config/_config.js +++ b/test/cli/samples/watch/no-watched-config/_config.js @@ -1,13 +1,13 @@ -const { assertIncludes } = require('../../../../utils.js'); +const { assertIncludes } = require('../../../../testHelpers.js'); -module.exports = { +module.exports = defineTest({ description: 'throws if no config is watched', - command: 'rollup -cw', + spawnArgs: ['-cw'], error: () => true, stderr(stderr) { assertIncludes( stderr, - '[!] Error: Invalid value for option "watch" - there must be at least one config where "watch" is not set to "false".' + '[!] RollupError: Invalid value for option "watch" - there must be at least one config where "watch" is not set to "false".' ); } -}; +}); diff --git a/test/cli/samples/watch/no-watched-config/rollup.config.js b/test/cli/samples/watch/no-watched-config/rollup.config.mjs similarity index 100% rename from test/cli/samples/watch/no-watched-config/rollup.config.js rename to test/cli/samples/watch/no-watched-config/rollup.config.mjs diff --git a/test/cli/samples/watch/node-config-file/_config.js b/test/cli/samples/watch/node-config-file/_config.js index 76205f3ea1b..722a6ef1094 100644 --- a/test/cli/samples/watch/node-config-file/_config.js +++ b/test/cli/samples/watch/node-config-file/_config.js @@ -1,9 +1,9 @@ -module.exports = { +module.exports = defineTest({ description: 'watches using a node_modules config files', - command: 'rollup --watch --config node:custom', + spawnArgs: ['--watch', '--config', 'node:custom'], abortOnStderr(data) { - if (data.includes('created _actual/main.js')) { + if (data.includes(`created _actual/main.js`)) { return true; } - }, -}; + } +}); diff --git a/test/cli/samples/watch/signal-close-watcher/_config.js b/test/cli/samples/watch/signal-close-watcher/_config.js new file mode 100644 index 00000000000..93479361292 --- /dev/null +++ b/test/cli/samples/watch/signal-close-watcher/_config.js @@ -0,0 +1,15 @@ +const { assertIncludes } = require('../../../../testHelpers.js'); + +module.exports = defineTest({ + description: 'calls closeWatcher plugin hooks when rollup is terminated due to a signal', + spawnArgs: ['-cw'], + skipIfWindows: true, + abortOnStderr(data) { + if (data.includes('created _actual')) { + return true; + } + }, + stderr(stderr) { + assertIncludes(stderr, 'close first\nclose second'); + } +}); diff --git a/test/cli/samples/watch/signal-close-watcher/_expected/main.js b/test/cli/samples/watch/signal-close-watcher/_expected/main.js new file mode 100644 index 00000000000..c3e30233192 --- /dev/null +++ b/test/cli/samples/watch/signal-close-watcher/_expected/main.js @@ -0,0 +1,3 @@ +var main = 42; + +export { main as default }; diff --git a/test/function/samples/deprecations/manualChunks/main.js b/test/cli/samples/watch/signal-close-watcher/main.js similarity index 100% rename from test/function/samples/deprecations/manualChunks/main.js rename to test/cli/samples/watch/signal-close-watcher/main.js diff --git a/test/cli/samples/watch/signal-close-watcher/rollup.config.mjs b/test/cli/samples/watch/signal-close-watcher/rollup.config.mjs new file mode 100644 index 00000000000..2637108a48a --- /dev/null +++ b/test/cli/samples/watch/signal-close-watcher/rollup.config.mjs @@ -0,0 +1,22 @@ +export default { + input: 'main.js', + output: { + dir: '_actual', + format: 'es' + }, + plugins: [ + { + name: 'first', + closeWatcher() { + console.error('close first'); + } + }, + { + name: 'second', + async closeWatcher() { + await new Promise(resolve => setTimeout(resolve)); + console.error('close second'); + } + } + ] +}; diff --git a/test/cli/samples/watch/watch-config-early-update/_config.js b/test/cli/samples/watch/watch-config-early-update/_config.js index 93e7190886d..c3d801a6962 100644 --- a/test/cli/samples/watch/watch-config-early-update/_config.js +++ b/test/cli/samples/watch/watch-config-early-update/_config.js @@ -1,56 +1,73 @@ -const fs = require('fs'); -const path = require('path'); +const { mkdirSync, unlinkSync } = require('node:fs'); +const path = require('node:path'); +const { wait, writeAndSync, writeAndRetry } = require('../../../../testHelpers'); -let configFile; +const configFile = path.join(__dirname, 'rollup.config.mjs'); +let stopUpdate; -module.exports = { +module.exports = defineTest({ description: 'immediately reloads the config file if a change happens while it is parsed', - command: 'rollup -cw', + spawnArgs: ['-cw'], before() { - fs.mkdirSync(path.resolve(__dirname, '_actual')); - configFile = path.resolve(__dirname, 'rollup.config.js'); - fs.writeFileSync( + // This test writes a config file that prints a message to stderr which signals to the test that + // the config files has been parsed, at which point the test replaces the config file. The + // initial file returns a Promise that only resolves once the second config file has been + // parsed. To do that, the first config hooks into process.stderr and looks for a log from the + // second config. + // That way, we simulate a complicated config file being changed while it is parsed. + mkdirSync(path.join(__dirname, '_actual')); + writeAndSync( configFile, ` - console.error('initial'); + import { Writable } from 'stream'; + process.stderr.write('initial\\n'); + const processStderr = process.stderr; export default new Promise(resolve => { - setTimeout( - () => - resolve({ - input: { output1: 'main.js' }, - output: { - dir: '_actual', - format: 'es' - } - }), - 500 - ); - }); - ` + delete process.stderr; + process.stderr = new Writable({ + write(chunk, encoding, next) { + processStderr.write(chunk, encoding, next); + if (chunk.toString() === 'updated\\n') { + process.stderr.end(); + process.stderr = processStderr; + resolve({ + input: 'main.js', + output: { + file: '_actual/output1.js', + format: 'es' + } + }) + } + }, + }); + });` ); }, after() { - fs.unlinkSync(configFile); + unlinkSync(configFile); + stopUpdate(); }, abortOnStderr(data) { if (data === 'initial\n') { - fs.writeFileSync( - configFile, - ` + wait(200).then(() => { + stopUpdate = writeAndRetry( + configFile, + ` console.error('updated'); export default { - input: {output2: "main.js"}, + input: 'main.js', output: { - dir: "_actual", + file: '_actual/output2.js', format: "es" } - }; - ` - ); + };` + ); + }); return false; } - if (data === 'updated\n') { - return new Promise(resolve => setTimeout(() => resolve(true), 500)); + if (data.includes(`created _actual/output2.js`)) { + stopUpdate(); + return true; } } -}; +}); diff --git a/test/cli/samples/watch/watch-config-error/_config.js b/test/cli/samples/watch/watch-config-error/_config.js index caa161f4052..a77283eb8d7 100644 --- a/test/cli/samples/watch/watch-config-error/_config.js +++ b/test/cli/samples/watch/watch-config-error/_config.js @@ -1,36 +1,41 @@ -const fs = require('fs'); -const path = require('path'); +const { unlinkSync, writeFileSync } = require('node:fs'); +const path = require('node:path'); +const { atomicWriteFileSync } = require('../../../../testHelpers'); let configFile; -module.exports = { +module.exports = defineTest({ description: 'keeps watching the config file in case the config is changed to an invalid state', - command: 'rollup -cw', + spawnArgs: ['-cw'], before() { - configFile = path.resolve(__dirname, 'rollup.config.js'); - fs.writeFileSync( + configFile = path.resolve(__dirname, 'rollup.config.mjs'); + writeFileSync( configFile, - 'export default {\n' + - '\tinput: "main.js",\n' + - '\toutput: {\n' + - '\t\tfile: "_actual/main1.js",\n' + - '\t\tformat: "es"\n' + - '\t}\n' + - '};' + ` + export default { + input: "main.js", + output: { + file: "_actual/main1.js", + format: "es" + } + };` ); }, after() { // synchronous sometimes does not seem to work, probably because the watch is not yet removed properly - setTimeout(() => fs.unlinkSync(configFile), 300); + setTimeout(() => unlinkSync(configFile), 300); }, abortOnStderr(data) { - if (data.includes(`created _actual${path.sep}main1.js`)) { - fs.writeFileSync(configFile, 'throw new Error("Config contains errors");'); + if (data.includes(`created _actual/main1.js`)) { + setTimeout( + () => atomicWriteFileSync(configFile, 'throw new Error("Config contains errors");'), + 600 + ); return false; } if (data.includes('Config contains errors')) { setTimeout(() => { - fs.writeFileSync( + atomicWriteFileSync( configFile, 'export default {\n' + '\tinput: "main.js",\n' + @@ -40,11 +45,11 @@ module.exports = { '\t}\n' + '};' ); - }, 400); + }, 600); return false; } - if (data.includes(`created _actual${path.sep}main2.js`)) { + if (data.includes(`created _actual/main2.js`)) { return true; } } -}; +}); diff --git a/test/cli/samples/watch/watch-config-initial-error/_config.js b/test/cli/samples/watch/watch-config-initial-error/_config.js index 9fd2eb4def9..9325dea4f35 100644 --- a/test/cli/samples/watch/watch-config-initial-error/_config.js +++ b/test/cli/samples/watch/watch-config-initial-error/_config.js @@ -1,22 +1,25 @@ -const fs = require('fs'); -const path = require('path'); +const { unlinkSync, writeFileSync } = require('node:fs'); +const path = require('node:path'); +const { atomicWriteFileSync } = require('../../../../testHelpers'); let configFile; -module.exports = { +module.exports = defineTest({ description: 'keeps watching the config file in case the initial file contains an error', - command: 'rollup -cw', + retry: true, + spawnArgs: ['-cw'], before() { - configFile = path.join(__dirname, 'rollup.config.js'); - fs.writeFileSync(configFile, 'throw new Error("Config contains initial errors");'); + configFile = path.join(__dirname, 'rollup.config.mjs'); + writeFileSync(configFile, 'throw new Error("Config contains initial errors");'); }, after() { - fs.unlinkSync(configFile); + // synchronous sometimes does not seem to work, probably because the watch is not yet removed properly + setTimeout(() => unlinkSync(configFile), 300); }, async abortOnStderr(data) { if (data.includes('Config contains initial errors')) { await new Promise(resolve => setTimeout(resolve, 100)); - fs.writeFileSync( + atomicWriteFileSync( configFile, 'export default {\n' + '\tinput: "main.js",\n' + @@ -32,4 +35,4 @@ module.exports = { return true; } } -}; +}); diff --git a/test/cli/samples/watch/watch-config-no-update/_config.js b/test/cli/samples/watch/watch-config-no-update/_config.js index c93075b0cc3..2023ed9be11 100644 --- a/test/cli/samples/watch/watch-config-no-update/_config.js +++ b/test/cli/samples/watch/watch-config-no-update/_config.js @@ -1,5 +1,6 @@ -const fs = require('fs'); -const path = require('path'); +const { unlinkSync, writeFileSync } = require('node:fs'); +const path = require('node:path'); +const { atomicWriteFileSync } = require('../../../../testHelpers'); let configFile; const configContent = @@ -11,29 +12,30 @@ const configContent = '\t}\n' + '};'; -module.exports = { +module.exports = defineTest({ description: 'does not rebuild if the config file is updated without change', - command: 'rollup -cw', + spawnArgs: ['-cw'], before() { - configFile = path.resolve(__dirname, 'rollup.config.js'); - fs.writeFileSync(configFile, configContent); + configFile = path.resolve(__dirname, 'rollup.config.mjs'); + writeFileSync(configFile, configContent); }, after() { - fs.unlinkSync(configFile); + unlinkSync(configFile); }, abortOnStderr(data) { - if (data.includes('created _actual/main.js')) { - fs.writeFileSync(configFile, configContent); - return new Promise(resolve => setTimeout(() => resolve(true), 500)); + if (data.includes(`created _actual/main.js`)) { + atomicWriteFileSync(configFile, configContent); + // wait some time for the watcher to trigger + return new Promise(resolve => setTimeout(() => resolve(true), 600)); } }, stderr(stderr) { if ( - !/^rollup v\d+\.\d+\.\d+\nbundles main.js → _actual[\\/]main.js...\ncreated _actual[\\/]main.js in \d+ms\n$/.test( + !/^rollup v\d+\.\d+\.\d+(-\d+)?\nbundles main.js → _actual[/\\]main.js...\ncreated _actual[/\\]main.js in \d+ms\n\n\[\d+-\d+-\d+ \d+:\d+:\d+] waiting for changes...\n$/.test( stderr ) ) { throw new Error(`stderr output does not match: ${JSON.stringify(stderr)}`); } } -}; +}); diff --git a/test/cli/samples/watch/watch-event-hooks-error/_config.js b/test/cli/samples/watch/watch-event-hooks-error/_config.js new file mode 100644 index 00000000000..5e0a06a018f --- /dev/null +++ b/test/cli/samples/watch/watch-event-hooks-error/_config.js @@ -0,0 +1,21 @@ +const { assertIncludes, wait } = require('../../../../testHelpers.js'); + +module.exports = defineTest({ + description: 'onError event hook shell commands write to stderr', + spawnScript: 'wrapper.js', + spawnArgs: ['-cw', '--watch.onError', 'echo error'], + async abortOnStderr(data) { + if (data.includes('waiting for changes')) { + // Wait a little for the child process to complete the command + await wait(300); + return true; + } + }, + stderr(stderr) { + assertIncludes( + stderr, + `watch.onError $ echo error +error` + ); + } +}); diff --git a/test/cli/samples/watch/watch-event-hooks-error/main.js b/test/cli/samples/watch/watch-event-hooks-error/main.js new file mode 100644 index 00000000000..81e7000be89 --- /dev/null +++ b/test/cli/samples/watch/watch-event-hooks-error/main.js @@ -0,0 +1,4 @@ +// missing `=` to trigger onError +var main 42; + +export { main as default }; diff --git a/test/cli/samples/watch/watch-event-hooks-error/rollup.config.mjs b/test/cli/samples/watch/watch-event-hooks-error/rollup.config.mjs new file mode 100644 index 00000000000..d6f089f1d52 --- /dev/null +++ b/test/cli/samples/watch/watch-event-hooks-error/rollup.config.mjs @@ -0,0 +1,7 @@ +export default { + input: 'main.js', + output: { + dir: '_actual', + format: 'es' + } +}; diff --git a/test/cli/samples/watch/watch-event-hooks-error/wrapper.js b/test/cli/samples/watch/watch-event-hooks-error/wrapper.js new file mode 100644 index 00000000000..57f1e1c7333 --- /dev/null +++ b/test/cli/samples/watch/watch-event-hooks-error/wrapper.js @@ -0,0 +1,6 @@ +#!/usr/bin/env node + +process.stdout.isTTY = true; +process.stderr.isTTY = true; +process.stderr.hasColors = () => true; +require('../../../../../dist/bin/rollup'); diff --git a/test/cli/samples/watch/watch-event-hooks/_config.js b/test/cli/samples/watch/watch-event-hooks/_config.js new file mode 100644 index 00000000000..93d6f6d1ecc --- /dev/null +++ b/test/cli/samples/watch/watch-event-hooks/_config.js @@ -0,0 +1,47 @@ +const { assertIncludes } = require('../../../../testHelpers.js'); + +module.exports = defineTest({ + description: 'event hook shell commands write to stderr', + retry: true, + spawnScript: 'wrapper.js', + spawnArgs: [ + '-cw', + '--watch.onStart', + 'echo start', + '--watch.onBundleStart', + 'echo bundleStart', + '--watch.onBundleEnd', + 'echo bundleEnd', + '--watch.onEnd', + 'echo end' + ], + abortOnStderr(data) { + process.stderr.write(data); + if (data.includes('waiting for changes')) { + return true; + } + }, + stderr(stderr) { + // assert each hook individually + assertIncludes( + stderr, + `watch.onStart $ echo start +start` + ); + assertIncludes( + stderr, + `watch.onBundleStart $ echo bundleStart +bundleStart` + ); + assertIncludes( + stderr, + `watch.onBundleEnd $ echo bundleEnd +bundleEnd` + ); + assertIncludes( + stderr, + `watch.onEnd $ echo end +end` + ); + } +}); diff --git a/test/cli/samples/watch/watch-event-hooks/main.js b/test/cli/samples/watch/watch-event-hooks/main.js new file mode 100644 index 00000000000..c3e30233192 --- /dev/null +++ b/test/cli/samples/watch/watch-event-hooks/main.js @@ -0,0 +1,3 @@ +var main = 42; + +export { main as default }; diff --git a/test/cli/samples/watch/watch-event-hooks/rollup.config.mjs b/test/cli/samples/watch/watch-event-hooks/rollup.config.mjs new file mode 100644 index 00000000000..d6f089f1d52 --- /dev/null +++ b/test/cli/samples/watch/watch-event-hooks/rollup.config.mjs @@ -0,0 +1,7 @@ +export default { + input: 'main.js', + output: { + dir: '_actual', + format: 'es' + } +}; diff --git a/test/cli/samples/watch/watch-event-hooks/wrapper.js b/test/cli/samples/watch/watch-event-hooks/wrapper.js new file mode 100644 index 00000000000..57f1e1c7333 --- /dev/null +++ b/test/cli/samples/watch/watch-event-hooks/wrapper.js @@ -0,0 +1,6 @@ +#!/usr/bin/env node + +process.stdout.isTTY = true; +process.stderr.isTTY = true; +process.stderr.hasColors = () => true; +require('../../../../../dist/bin/rollup'); diff --git a/test/cli/samples/watch/watch-output-contain-input-allowInputInsideOutputPath/_config.js b/test/cli/samples/watch/watch-output-contain-input-allowInputInsideOutputPath/_config.js new file mode 100644 index 00000000000..79acda4b678 --- /dev/null +++ b/test/cli/samples/watch/watch-output-contain-input-allowInputInsideOutputPath/_config.js @@ -0,0 +1,9 @@ +module.exports = defineTest({ + description: + 'allowInputInsideOutputPath set to true, should not throw an error when input is inside output path', + spawnArgs: ['-cw'], + abortOnStderr(data) { + return data.includes('waiting for changes'); + }, + execute: true +}); diff --git a/test/cli/samples/watch/watch-output-contain-input-allowInputInsideOutputPath/output/main.js b/test/cli/samples/watch/watch-output-contain-input-allowInputInsideOutputPath/output/main.js new file mode 100644 index 00000000000..17eee8f1f7e --- /dev/null +++ b/test/cli/samples/watch/watch-output-contain-input-allowInputInsideOutputPath/output/main.js @@ -0,0 +1 @@ +assert.equal( 1 + 1, 2 ); diff --git a/test/cli/samples/watch/watch-output-contain-input-allowInputInsideOutputPath/output/out.js b/test/cli/samples/watch/watch-output-contain-input-allowInputInsideOutputPath/output/out.js new file mode 100644 index 00000000000..17eee8f1f7e --- /dev/null +++ b/test/cli/samples/watch/watch-output-contain-input-allowInputInsideOutputPath/output/out.js @@ -0,0 +1 @@ +assert.equal( 1 + 1, 2 ); diff --git a/test/cli/samples/watch/watch-output-contain-input-allowInputInsideOutputPath/rollup.config.mjs b/test/cli/samples/watch/watch-output-contain-input-allowInputInsideOutputPath/rollup.config.mjs new file mode 100644 index 00000000000..51fa9da4424 --- /dev/null +++ b/test/cli/samples/watch/watch-output-contain-input-allowInputInsideOutputPath/rollup.config.mjs @@ -0,0 +1,12 @@ +export default [ + { + input: {'out': 'output/main.js'}, + watch: { + allowInputInsideOutputPath: true, + }, + output: { + dir: 'output', + format: 'es' + } + }, +]; diff --git a/test/cli/samples/watch/watch-output-contain-input/_config.js b/test/cli/samples/watch/watch-output-contain-input/_config.js new file mode 100644 index 00000000000..21ea6714e36 --- /dev/null +++ b/test/cli/samples/watch/watch-output-contain-input/_config.js @@ -0,0 +1,13 @@ +const { assertIncludes } = require('../../../../testHelpers.js'); + +module.exports = defineTest({ + description: 'throws if output contains input', + spawnArgs: ['-cw'], + error: () => true, + stderr(stderr) { + assertIncludes( + stderr, + '[!] RollupError: Invalid value for option "watch" - the input "main.js" is a subpath of the output "main.js".' + ); + } +}); diff --git a/test/cli/samples/watch/watch-output-contain-input/main.js b/test/cli/samples/watch/watch-output-contain-input/main.js new file mode 100644 index 00000000000..17eee8f1f7e --- /dev/null +++ b/test/cli/samples/watch/watch-output-contain-input/main.js @@ -0,0 +1 @@ +assert.equal( 1 + 1, 2 ); diff --git a/test/cli/samples/watch/watch-output-contain-input/rollup.config.mjs b/test/cli/samples/watch/watch-output-contain-input/rollup.config.mjs new file mode 100644 index 00000000000..d2719d4d1a3 --- /dev/null +++ b/test/cli/samples/watch/watch-output-contain-input/rollup.config.mjs @@ -0,0 +1,10 @@ +export default [ + { + input: 'main.js', + watch: true, + output: { + dir: 'main.js', + format: 'es' + } + }, +]; diff --git a/test/cli/tsconfig.json b/test/cli/tsconfig.json new file mode 100644 index 00000000000..4a26f3ee84c --- /dev/null +++ b/test/cli/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": "../tsconfig.base.json", + "include": [ + "**/_config.js", + "./index.js", + "./define.d.ts" + ] +} diff --git a/test/file-hashes/define.d.ts b/test/file-hashes/define.d.ts new file mode 100644 index 00000000000..e44c14045fa --- /dev/null +++ b/test/file-hashes/define.d.ts @@ -0,0 +1,5 @@ +import type { TestConfigFileHash } from '../types'; + +declare global { + function defineTest(config: TestConfigFileHash): TestConfigFileHash; +} diff --git a/test/file-hashes/index.js b/test/file-hashes/index.js index 1ea7d1dab49..b91fbfcfd48 100644 --- a/test/file-hashes/index.js +++ b/test/file-hashes/index.js @@ -1,49 +1,59 @@ -const path = require('path'); +const path = require('node:path'); +/** + * @type {import('../../src/rollup/types')} Rollup + */ +// @ts-expect-error not included in types const rollup = require('../../dist/rollup'); -const { runTestSuiteWithSamples } = require('../utils.js'); +// @ts-expect-error not included in types +const { runTestSuiteWithSamples } = require('../testHelpers.js'); -runTestSuiteWithSamples('file hashes', path.resolve(__dirname, 'samples'), (dir, config) => { - (config.skip ? describe.skip : config.solo ? describe.only : describe)( - path.basename(dir) + ': ' + config.description, - () => { - it(`generates correct hashes`, () => { - process.chdir(dir); - return Promise.all( - [config.options1, config.options2].map(options => - rollup - .rollup(options) - .then(bundle => - bundle.generate( - Object.assign( - { format: 'es', chunkFileNames: '[hash]', entryFileNames: '[hash]' }, - options.output - ) - ) +runTestSuiteWithSamples( + 'file hashes', + path.resolve(__dirname, 'samples'), + /** + * @param {import('../types').TestConfigFileHash} config + */ + (directory, config) => { + (config.skip ? describe.skip : config.solo ? describe.only : describe)( + path.basename(directory) + ': ' + config.description, + () => { + it(`generates correct hashes`, () => { + process.chdir(directory); + return Promise.all( + [config.options1, config.options2].map(options => + rollup.rollup(options).then(bundle => + bundle.generate({ + format: 'es', + chunkFileNames: '[hash]', + entryFileNames: '[hash]', + ...options.output + }) ) - ) - ).then(([generated1, generated2]) => { - const fileContentsByHash = new Map(); - addFileContentsByFileName(fileContentsByHash, generated1); - addFileContentsByFileName(fileContentsByHash, generated2); - if (config.show) { - console.log(fileContentsByHash); - } - for (const contents of fileContentsByHash.values()) { - if (contents.size > 1) { - throw new Error( - `Two chunks contained different code even though the hashes were the same: ${Array.from( - contents - ) - .map(JSON.stringify) - .join(' != ')}` - ); + ) + ).then(([generated1, generated2]) => { + const fileContentsByHash = new Map(); + addFileContentsByFileName(fileContentsByHash, generated1); + addFileContentsByFileName(fileContentsByHash, generated2); + if (config.show) { + console.log(fileContentsByHash); } - } + for (const contents of fileContentsByHash.values()) { + if (contents.size > 1) { + throw new Error( + `Two chunks contained different code even though the hashes were the same: ${[ + ...contents + ] + .map(error => JSON.stringify(error)) + .join(' != ')}` + ); + } + } + }); }); - }); - } - ); -}); + } + ); + } +); function addFileContentsByFileName(fileContentsByFileName, generated) { for (const chunk of generated.output) { diff --git a/test/file-hashes/samples/augment-chunk-hash/_config.js b/test/file-hashes/samples/augment-chunk-hash/_config.js index 06b9498eb86..a8fe2f2e7bf 100644 --- a/test/file-hashes/samples/augment-chunk-hash/_config.js +++ b/test/file-hashes/samples/augment-chunk-hash/_config.js @@ -1,6 +1,7 @@ const augment1 = '/*foo*/'; const augment2 = '/*bar*/'; -module.exports = { + +module.exports = defineTest({ description: 'augmentChunkHash updates hashes across all modules when returning something', options1: { input: 'main', @@ -46,4 +47,4 @@ module.exports = { } ] } -}; +}); diff --git a/test/file-hashes/samples/banner/_config.js b/test/file-hashes/samples/banner/_config.js index 805b2096a6f..b4224453c28 100644 --- a/test/file-hashes/samples/banner/_config.js +++ b/test/file-hashes/samples/banner/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'creates different hashes if the banner differs', options1: { input: 'main', @@ -12,4 +12,4 @@ module.exports = { banner: 'console.log(2);' } } -}; +}); diff --git a/test/file-hashes/samples/chunk-name/_config.js b/test/file-hashes/samples/chunk-name/_config.js index 5e4473d7d48..b1fb6968483 100644 --- a/test/file-hashes/samples/chunk-name/_config.js +++ b/test/file-hashes/samples/chunk-name/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'creates different hashes if the name pattern differs', options1: { input: { @@ -18,4 +18,4 @@ module.exports = { entryFileNames: '[name]-[hash].js' } } -}; +}); diff --git a/test/file-hashes/samples/content/_config.js b/test/file-hashes/samples/content/_config.js index dd2047a083e..ccc0f9fca85 100644 --- a/test/file-hashes/samples/content/_config.js +++ b/test/file-hashes/samples/content/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'creates different hashes if the content differs', options1: { input: { main: 'main1', dep: 'dep1' } @@ -6,4 +6,4 @@ module.exports = { options2: { input: { main: 'main2', dep: 'dep2' } } -}; +}); diff --git a/test/file-hashes/samples/dependency-content/_config.js b/test/file-hashes/samples/dependency-content/_config.js index bfc9ca3485d..325e0523415 100644 --- a/test/file-hashes/samples/dependency-content/_config.js +++ b/test/file-hashes/samples/dependency-content/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'creates different hashes if the content of dependencies differs', options1: { input: { main: 'main1', dep: 'dep1' } @@ -6,4 +6,4 @@ module.exports = { options2: { input: { main: 'main2', dep: 'dep2' } } -}; +}); diff --git a/test/file-hashes/samples/export-order-2/_config.js b/test/file-hashes/samples/export-order-2/_config.js index 3840ab69b9c..5e4d37e6aad 100644 --- a/test/file-hashes/samples/export-order-2/_config.js +++ b/test/file-hashes/samples/export-order-2/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'creates different hashes if different variables are exported under the same name', options1: { input: ['main1', 'dep'] @@ -6,4 +6,4 @@ module.exports = { options2: { input: ['main2', 'dep'] } -}; +}); diff --git a/test/file-hashes/samples/export-order/_config.js b/test/file-hashes/samples/export-order/_config.js index 342bef8136a..022540c31aa 100644 --- a/test/file-hashes/samples/export-order/_config.js +++ b/test/file-hashes/samples/export-order/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'creates different hashes if different variables are exported under the same name', options1: { input: ['main1'] @@ -6,4 +6,4 @@ module.exports = { options2: { input: ['main2'] } -}; +}); diff --git a/test/file-hashes/samples/exports/_config.js b/test/file-hashes/samples/exports/_config.js index 10b8e4c6c99..bd16c09f922 100644 --- a/test/file-hashes/samples/exports/_config.js +++ b/test/file-hashes/samples/exports/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'creates different hashes if the generated exports differ', options1: { input: ['main1', 'other'] @@ -6,4 +6,4 @@ module.exports = { options2: { input: ['main2', 'other'] } -}; +}); diff --git a/test/file-hashes/samples/external-dependency-names/_config.js b/test/file-hashes/samples/external-dependency-names/_config.js index e3a80e8db9d..3bf0ce57c8a 100644 --- a/test/file-hashes/samples/external-dependency-names/_config.js +++ b/test/file-hashes/samples/external-dependency-names/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'creates different hashes if the names of external dependencies differ', options1: { input: { mainA: 'main1a', mainB: 'main1b' }, @@ -8,4 +8,4 @@ module.exports = { input: { mainA: 'main2a', mainB: 'main2b' }, external: ['external', 'external2'] } -}; +}); diff --git a/test/file-hashes/samples/footer/_config.js b/test/file-hashes/samples/footer/_config.js index 49b41fc6d05..8d637560b9a 100644 --- a/test/file-hashes/samples/footer/_config.js +++ b/test/file-hashes/samples/footer/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'creates different hashes if the footer differs', options1: { input: 'main', @@ -12,4 +12,4 @@ module.exports = { footer: 'console.log(2);' } } -}; +}); diff --git a/test/file-hashes/samples/format/_config.js b/test/file-hashes/samples/format/_config.js index 1ea5521d2bd..bf79a5a8e50 100644 --- a/test/file-hashes/samples/format/_config.js +++ b/test/file-hashes/samples/format/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'creates different hashes if the format differs', options1: { input: 'main', @@ -12,4 +12,4 @@ module.exports = { format: 'cjs' } } -}; +}); diff --git a/test/file-hashes/samples/internal-exports/_config.js b/test/file-hashes/samples/internal-exports/_config.js index c77a5d4686c..0632fb47d0b 100644 --- a/test/file-hashes/samples/internal-exports/_config.js +++ b/test/file-hashes/samples/internal-exports/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'creates different hashes if generated internal exports differ', options1: { input: ['main1', 'other'] @@ -6,4 +6,4 @@ module.exports = { options2: { input: ['main2', 'other'] } -}; +}); diff --git a/test/file-hashes/samples/intro/_config.js b/test/file-hashes/samples/intro/_config.js index 04eb80772c6..d95710ecb1b 100644 --- a/test/file-hashes/samples/intro/_config.js +++ b/test/file-hashes/samples/intro/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'creates different hashes if the intro differs', options1: { input: 'main', @@ -12,4 +12,4 @@ module.exports = { intro: 'console.log(2);' } } -}; +}); diff --git a/test/file-hashes/samples/name-pattern/_config.js b/test/file-hashes/samples/name-pattern/_config.js index e0127aa0aab..ea118ef4545 100644 --- a/test/file-hashes/samples/name-pattern/_config.js +++ b/test/file-hashes/samples/name-pattern/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'creates different hashes if the name pattern differs', options1: { input: 'main', @@ -12,4 +12,4 @@ module.exports = { chunkFileNames: '[name]-[hash]' } } -}; +}); diff --git a/test/file-hashes/samples/outro/_config.js b/test/file-hashes/samples/outro/_config.js index 5248af72f0e..a7d0c40d7e4 100644 --- a/test/file-hashes/samples/outro/_config.js +++ b/test/file-hashes/samples/outro/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'creates different hashes if the outro differs', options1: { input: 'main', @@ -12,4 +12,4 @@ module.exports = { outro: 'console.log(2);' } } -}; +}); diff --git a/test/file-hashes/samples/render-chunk-changes/_config.js b/test/file-hashes/samples/render-chunk-changes/_config.js new file mode 100644 index 00000000000..c0222125e59 --- /dev/null +++ b/test/file-hashes/samples/render-chunk-changes/_config.js @@ -0,0 +1,27 @@ +module.exports = defineTest({ + description: 'reflects changes in renderChunk', + options1: { + input: 'main', + plugins: [ + { + renderChunk(code, chunk) { + if (chunk.name === 'main') { + return "console.log('first');" + code; + } + } + } + ] + }, + options2: { + input: 'main', + plugins: [ + { + renderChunk(code, chunk) { + if (chunk.name === 'main') { + return "console.log('second');" + code; + } + } + } + ] + } +}); diff --git a/test/file-hashes/samples/render-chunk-changes/main.js b/test/file-hashes/samples/render-chunk-changes/main.js new file mode 100644 index 00000000000..c0b933d7b56 --- /dev/null +++ b/test/file-hashes/samples/render-chunk-changes/main.js @@ -0,0 +1 @@ +console.log('main'); diff --git a/test/file-hashes/tsconfig.json b/test/file-hashes/tsconfig.json new file mode 100644 index 00000000000..4a26f3ee84c --- /dev/null +++ b/test/file-hashes/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": "../tsconfig.base.json", + "include": [ + "**/_config.js", + "./index.js", + "./define.d.ts" + ] +} diff --git a/test/form/define.d.ts b/test/form/define.d.ts new file mode 100644 index 00000000000..70a9f24e7b0 --- /dev/null +++ b/test/form/define.d.ts @@ -0,0 +1,5 @@ +import type { TestConfigForm } from '../types'; + +declare global { + function defineTest(config: TestConfigForm): TestConfigForm; +} diff --git a/test/form/index.js b/test/form/index.js index 1a712e550cb..fdf468d3538 100644 --- a/test/form/index.js +++ b/test/form/index.js @@ -1,120 +1,162 @@ -const path = require('path'); -const assert = require('assert'); -const sander = require('sander'); -const rollup = require('../../dist/rollup'); -const { normaliseOutput, runTestSuiteWithSamples } = require('../utils.js'); +const assert = require('node:assert'); +const { existsSync, readFileSync } = require('node:fs'); +const path = require('node:path'); +/** + * @type {import('../../src/rollup/types')} Rollup + */ +// @ts-expect-error not included in types +const { rollup } = require('../../dist/rollup'); +const { + compareLogs, + getRandomElement, + normaliseOutput, + runTestSuiteWithSamples, + shuffle, + verifyAstPlugin +} = require('../testHelpers.js'); const FORMATS = ['amd', 'cjs', 'system', 'es', 'iife', 'umd']; -runTestSuiteWithSamples('form', path.resolve(__dirname, 'samples'), (dir, config) => { - const isSingleFormatTest = sander.existsSync(dir + '/_expected.js'); - const itOrDescribe = isSingleFormatTest ? it : describe; - (config.skip ? itOrDescribe.skip : config.solo ? itOrDescribe.only : itOrDescribe)( - path.basename(dir) + ': ' + config.description, - () => { - let bundle; - const runRollupTest = async (inputFile, bundleFile, defaultFormat) => { +runTestSuiteWithSamples( + 'form', + path.resolve(__dirname, 'samples'), + /** + * @param {import('../types').TestConfigForm} config + */ + (directory, config) => { + const isSingleFormatTest = existsSync(directory + '/_expected.js'); + const itOrDescribe = isSingleFormatTest ? it : describe; + (config.skip ? itOrDescribe.skip : config.solo ? itOrDescribe.only : itOrDescribe)( + path.basename(directory) + ': ' + config.description, + () => { + let bundle; + const logs = []; const warnings = []; - if (config.before) config.before(); - try { - process.chdir(dir); - bundle = - bundle || - (await rollup.rollup( - Object.assign( - { - input: dir + '/main.js', - onwarn: warning => { - if ( - !( - config.expectedWarnings && - config.expectedWarnings.indexOf(warning.code) >= 0 - ) - ) { - warnings.push(warning); - } - }, - strictDeprecations: true + + const runRollupTest = async (inputFile, bundleFile, format, fromCache) => { + if (config.before) { + await config.before(); + } + try { + process.chdir(directory); + bundle = + (!fromCache && bundle) || + (await rollup({ + input: directory + '/main.js', + onLog: (level, log) => { + if (!fromCache) { + logs.push({ level, ...log }); + } + if (level === 'warn' && !config.expectedWarnings?.includes(log.code)) { + warnings.push(log); + } }, - config.options || {} - ) - )); - await generateAndTestBundle( - bundle, - Object.assign( + strictDeprecations: true, + ...config.options, + ...(fromCache ? { cache: bundle.cache } : {}), + plugins: + config.verifyAst === false + ? config.options?.plugins + : config.options?.plugins === undefined + ? verifyAstPlugin + : Array.isArray(config.options.plugins) + ? [...config.options.plugins, verifyAstPlugin] + : config.options.plugins + })); + await generateAndTestBundle( + bundle, { exports: 'auto', file: inputFile, - format: defaultFormat, - validate: true + format, + validate: true, + ...(config.options || {}).output }, - (config.options || {}).output || {} - ), - bundleFile, - config - ); - } finally { - if (config.after) config.after(); - } - if (warnings.length > 0) { - const codes = new Set(); - for (const { code } of warnings) { - codes.add(code); + bundleFile, + config + ); + } finally { + if (config.after) { + await config.after(); + } + } + if (warnings.length > 0) { + const codes = new Set(); + for (const { code } of warnings) { + codes.add(code); + } + const messages = warnings.map(({ message }) => `${message}\n\n`).join(''); + warnings.length = 0; + throw new Error( + `Unexpected warnings (${[...codes].join(', ')}): \n${messages}` + + 'If you expect warnings, list their codes in config.expectedWarnings' + ); } - throw new Error( - `Unexpected warnings (${[...codes].join(', ')}): \n${warnings - .map(({ message }) => `${message}\n\n`) - .join('')}` + 'If you expect warnings, list their codes in config.expectedWarnings' - ); + }; + + if (isSingleFormatTest) { + // We are running Rollup twice where the second time checks if it + // works the same when using the cache + return runRollupTest(`${directory}/_actual.js`, `${directory}/_expected.js`, 'es', false) + .then(() => + runRollupTest(`${directory}/_actual.js`, `${directory}/_expected.js`, 'es', true) + ) + .then(() => config.logs && compareLogs(logs, config.logs)); } - }; - if (isSingleFormatTest) { - return runRollupTest(dir + '/_actual.js', dir + '/_expected.js', 'es'); - } + const unshuffledFormats = config.formats || FORMATS; + const formats = + config.shuffleFormats === false ? unshuffledFormats : shuffle(unshuffledFormats); + for (const format of formats) { + after(() => config.logs && compareLogs(logs, config.logs)); + + it(`generates ${format}`, () => + runRollupTest( + `${directory}/_actual/${format}.js`, + `${directory}/_expected/${format}.js`, + format, + false + )); + } - (config.formats || FORMATS).forEach(format => - it('generates ' + format, () => + const format = getRandomElement(formats); + it(`generates ${format} from the cache`, () => runRollupTest( - dir + '/_actual/' + format + '.js', - dir + '/_expected/' + format + '.js', - format - ) - ) - ); - } - ); -}); + `${directory}/_actual/${format}.js`, + `${directory}/_expected/${format}.js`, + format, + true + )); + } + ); + } +); async function generateAndTestBundle(bundle, outputOptions, expectedFile, { show }) { await bundle.write(outputOptions); - const actualCode = normaliseOutput(sander.readFileSync(outputOptions.file)); + const actualCode = normaliseOutput(readFileSync(outputOptions.file, 'utf8')); let expectedCode; let actualMap; let expectedMap; try { - expectedCode = normaliseOutput(sander.readFileSync(expectedFile)); - } catch (err) { + expectedCode = normaliseOutput(readFileSync(expectedFile, 'utf8')); + } catch { expectedCode = 'missing file'; } try { - actualMap = JSON.parse(sander.readFileSync(outputOptions.file + '.map').toString()); - actualMap.sourcesContent = actualMap.sourcesContent - ? actualMap.sourcesContent.map(normaliseOutput) - : null; - } catch (err) { - assert.strictEqual(err.code, 'ENOENT'); + actualMap = JSON.parse(readFileSync(outputOptions.file + '.map', 'utf8')); + actualMap.sourcesContent &&= actualMap.sourcesContent.map(normaliseOutput); + } catch (error) { + assert.strictEqual(error.code, 'ENOENT'); } try { - expectedMap = JSON.parse(sander.readFileSync(expectedFile + '.map').toString()); - expectedMap.sourcesContent = actualMap.sourcesContent - ? expectedMap.sourcesContent.map(normaliseOutput) - : null; - } catch (err) { - assert.equal(err.code, 'ENOENT'); + expectedMap = JSON.parse(readFileSync(expectedFile + '.map', 'utf8')); + expectedMap.sourcesContent &&= expectedMap.sourcesContent.map(normaliseOutput); + } catch (error) { + assert.equal(error.code, 'ENOENT'); } if (show) { diff --git a/test/form/samples/absolute-path-resolver/_config.js b/test/form/samples/absolute-path-resolver/_config.js index 27910c3cead..3463f2ed7cb 100644 --- a/test/form/samples/absolute-path-resolver/_config.js +++ b/test/form/samples/absolute-path-resolver/_config.js @@ -1,10 +1,11 @@ -const path = require('path'); +const path = require('node:path'); -module.exports = { +module.exports = defineTest({ description: 'normalizes absolute ids', options: { plugins: [ { + name: 'test', transform(code, id) { if (/main/.test(id)) { return code.replace('"./a.js"', JSON.stringify(path.resolve(__dirname, 'a.js'))); @@ -13,4 +14,4 @@ module.exports = { } ] } -}; +}); diff --git a/test/form/samples/absolute-path-resolver/a.js b/test/form/samples/absolute-path-resolver/a.js index 3223031dc70..7ad3ccb5b83 100644 --- a/test/form/samples/absolute-path-resolver/a.js +++ b/test/form/samples/absolute-path-resolver/a.js @@ -1,3 +1,3 @@ export var a = () => { console.log('props'); -}; \ No newline at end of file +}; diff --git a/test/form/samples/acorn-external-plugins/_config.js b/test/form/samples/acorn-external-plugins/_config.js deleted file mode 100644 index 48682b384b0..00000000000 --- a/test/form/samples/acorn-external-plugins/_config.js +++ /dev/null @@ -1,8 +0,0 @@ -const jsx = require('acorn-jsx'); - -module.exports = { - description: 'supports official acorn plugins that may rely on a shared acorn instance', - options: { - acornInjectPlugins: [jsx()] - } -}; diff --git a/test/form/samples/acorn-external-plugins/_expected.js b/test/form/samples/acorn-external-plugins/_expected.js deleted file mode 100644 index 8f865a3e6ee..00000000000 --- a/test/form/samples/acorn-external-plugins/_expected.js +++ /dev/null @@ -1,3 +0,0 @@ -var main =
This is not JavaScript
; - -export default main; diff --git a/test/form/samples/acorn-external-plugins/main.js b/test/form/samples/acorn-external-plugins/main.js deleted file mode 100644 index 5113b9c30a8..00000000000 --- a/test/form/samples/acorn-external-plugins/main.js +++ /dev/null @@ -1 +0,0 @@ -export default
This is not JavaScript
; diff --git a/test/form/samples/addon-functions/_config.js b/test/form/samples/addon-functions/_config.js new file mode 100644 index 00000000000..8f382ace5e5 --- /dev/null +++ b/test/form/samples/addon-functions/_config.js @@ -0,0 +1,97 @@ +const assert = require('node:assert'); +// @ts-expect-error not included in types +const { replaceDirectoryInStringifiedObject } = require('../../../testHelpers'); +const assertChunkData = chunk => + assert.strictEqual( + replaceDirectoryInStringifiedObject({ ...chunk, fileName: undefined }, __dirname), + '{\n' + + ' "exports": [],\n' + + ' "facadeModuleId": "**/main.js",\n' + + ' "isDynamicEntry": false,\n' + + ' "isEntry": true,\n' + + ' "isImplicitEntry": false,\n' + + ' "moduleIds": [\n' + + ' "**/main.js"\n' + + ' ],\n' + + ' "name": "main",\n' + + ' "type": "chunk",\n' + + ' "dynamicImports": [],\n' + + ' "implicitlyLoadedBefore": [],\n' + + ' "importedBindings": {},\n' + + ' "imports": [],\n' + + ' "modules": {\n' + + ' "**/main.js": {\n' + + ' "code": "console.log(\'main\');",\n' + + ' "originalLength": 21,\n' + + ' "removedExports": [],\n' + + ' "renderedExports": [],\n' + + ' "renderedLength": 20\n' + + ' }\n' + + ' },\n' + + ' "referencedFiles": []\n' + + '}' + ); + +module.exports = defineTest({ + description: 'provides module information when adding addons', + options: { + output: { + intro(chunk) { + assertChunkData(chunk); + return `/* intro-option ${chunk.fileName} */`; + }, + outro(chunk) { + assertChunkData(chunk); + return `/* outro-option ${chunk.fileName} */`; + }, + banner(chunk) { + assertChunkData(chunk); + return `/* banner-option ${chunk.fileName} */`; + }, + footer(chunk) { + assertChunkData(chunk); + return `/* footer-option ${chunk.fileName} */`; + } + }, + plugins: [ + { + name: 'first', + intro(chunk) { + assertChunkData(chunk); + return `/* intro-first ${chunk.fileName} */`; + }, + outro(chunk) { + assertChunkData(chunk); + return `/* outro-first ${chunk.fileName} */`; + }, + banner(chunk) { + assertChunkData(chunk); + return `/* banner-first ${chunk.fileName} */`; + }, + footer(chunk) { + assertChunkData(chunk); + return `/* footer-first ${chunk.fileName} */`; + } + }, + { + name: 'second', + intro(chunk) { + assertChunkData(chunk); + return `/* intro-second ${chunk.fileName} */`; + }, + outro(chunk) { + assertChunkData(chunk); + return `/* outro-second ${chunk.fileName} */`; + }, + banner(chunk) { + assertChunkData(chunk); + return `/* banner-second ${chunk.fileName} */`; + }, + footer(chunk) { + assertChunkData(chunk); + return `/* footer-second ${chunk.fileName} */`; + } + } + ] + } +}); diff --git a/test/form/samples/addon-functions/_expected/amd.js b/test/form/samples/addon-functions/_expected/amd.js new file mode 100644 index 00000000000..7de22f7a2f7 --- /dev/null +++ b/test/form/samples/addon-functions/_expected/amd.js @@ -0,0 +1,23 @@ +/* banner-option amd.js */ +/* banner-first amd.js */ +/* banner-second amd.js */ +define((function () { 'use strict'; + + /* intro-option amd.js */ + + /* intro-first amd.js */ + + /* intro-second amd.js */ + + console.log('main'); + + /* outro-option amd.js */ + + /* outro-first amd.js */ + + /* outro-second amd.js */ + +})); +/* footer-option amd.js */ +/* footer-first amd.js */ +/* footer-second amd.js */ diff --git a/test/form/samples/addon-functions/_expected/cjs.js b/test/form/samples/addon-functions/_expected/cjs.js new file mode 100644 index 00000000000..6d08b1eb5f6 --- /dev/null +++ b/test/form/samples/addon-functions/_expected/cjs.js @@ -0,0 +1,21 @@ +/* banner-option cjs.js */ +/* banner-first cjs.js */ +/* banner-second cjs.js */ +'use strict'; + +/* intro-option cjs.js */ + +/* intro-first cjs.js */ + +/* intro-second cjs.js */ + +console.log('main'); + +/* outro-option cjs.js */ + +/* outro-first cjs.js */ + +/* outro-second cjs.js */ +/* footer-option cjs.js */ +/* footer-first cjs.js */ +/* footer-second cjs.js */ diff --git a/test/form/samples/addon-functions/_expected/es.js b/test/form/samples/addon-functions/_expected/es.js new file mode 100644 index 00000000000..a8227dff141 --- /dev/null +++ b/test/form/samples/addon-functions/_expected/es.js @@ -0,0 +1,19 @@ +/* banner-option es.js */ +/* banner-first es.js */ +/* banner-second es.js */ +/* intro-option es.js */ + +/* intro-first es.js */ + +/* intro-second es.js */ + +console.log('main'); + +/* outro-option es.js */ + +/* outro-first es.js */ + +/* outro-second es.js */ +/* footer-option es.js */ +/* footer-first es.js */ +/* footer-second es.js */ diff --git a/test/form/samples/addon-functions/_expected/iife.js b/test/form/samples/addon-functions/_expected/iife.js new file mode 100644 index 00000000000..196271275c0 --- /dev/null +++ b/test/form/samples/addon-functions/_expected/iife.js @@ -0,0 +1,24 @@ +/* banner-option iife.js */ +/* banner-first iife.js */ +/* banner-second iife.js */ +(function () { + 'use strict'; + + /* intro-option iife.js */ + + /* intro-first iife.js */ + + /* intro-second iife.js */ + + console.log('main'); + + /* outro-option iife.js */ + + /* outro-first iife.js */ + + /* outro-second iife.js */ + +})(); +/* footer-option iife.js */ +/* footer-first iife.js */ +/* footer-second iife.js */ diff --git a/test/form/samples/addon-functions/_expected/system.js b/test/form/samples/addon-functions/_expected/system.js new file mode 100644 index 00000000000..60ec2175458 --- /dev/null +++ b/test/form/samples/addon-functions/_expected/system.js @@ -0,0 +1,28 @@ +/* banner-option system.js */ +/* banner-first system.js */ +/* banner-second system.js */ +System.register([], (function () { + 'use strict'; + return { + execute: (function () { + + /* intro-option system.js */ + + /* intro-first system.js */ + + /* intro-second system.js */ + + console.log('main'); + + /* outro-option system.js */ + + /* outro-first system.js */ + + /* outro-second system.js */ + + }) + }; +})); +/* footer-option system.js */ +/* footer-first system.js */ +/* footer-second system.js */ diff --git a/test/form/samples/addon-functions/_expected/umd.js b/test/form/samples/addon-functions/_expected/umd.js new file mode 100644 index 00000000000..9497d95f225 --- /dev/null +++ b/test/form/samples/addon-functions/_expected/umd.js @@ -0,0 +1,26 @@ +/* banner-option umd.js */ +/* banner-first umd.js */ +/* banner-second umd.js */ +(function (factory) { + typeof define === 'function' && define.amd ? define(factory) : + factory(); +})((function () { 'use strict'; + + /* intro-option umd.js */ + + /* intro-first umd.js */ + + /* intro-second umd.js */ + + console.log('main'); + + /* outro-option umd.js */ + + /* outro-first umd.js */ + + /* outro-second umd.js */ + +})); +/* footer-option umd.js */ +/* footer-first umd.js */ +/* footer-second umd.js */ diff --git a/test/form/samples/addon-functions/main.js b/test/form/samples/addon-functions/main.js new file mode 100644 index 00000000000..c0b933d7b56 --- /dev/null +++ b/test/form/samples/addon-functions/main.js @@ -0,0 +1 @@ +console.log('main'); diff --git a/test/form/samples/amd-id-auto/_config.js b/test/form/samples/amd-id-auto/_config.js index c08fbc50402..0d8bb4090c8 100644 --- a/test/form/samples/amd-id-auto/_config.js +++ b/test/form/samples/amd-id-auto/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'allows to use amd.autoId', options: { output: { amd: { autoId: true } } } -}; +}); diff --git a/test/form/samples/amd-id-auto/_expected/amd.js b/test/form/samples/amd-id-auto/_expected/amd.js index 21cce6c0389..4716f5ca5ed 100644 --- a/test/form/samples/amd-id-auto/_expected/amd.js +++ b/test/form/samples/amd-id-auto/_expected/amd.js @@ -1,5 +1,5 @@ -define('amd', function () { 'use strict'; +define('amd', (function () { 'use strict'; console.log(42); -}); +})); diff --git a/test/form/samples/amd-id-auto/_expected/iife.js b/test/form/samples/amd-id-auto/_expected/iife.js index 3a2d4df530d..26c81bfb6d0 100644 --- a/test/form/samples/amd-id-auto/_expected/iife.js +++ b/test/form/samples/amd-id-auto/_expected/iife.js @@ -3,4 +3,4 @@ console.log(42); -}()); +})(); diff --git a/test/form/samples/amd-id-auto/_expected/system.js b/test/form/samples/amd-id-auto/_expected/system.js index 424a0c00ec5..845bdcc4ef0 100644 --- a/test/form/samples/amd-id-auto/_expected/system.js +++ b/test/form/samples/amd-id-auto/_expected/system.js @@ -1,10 +1,10 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { console.log(42); - } + }) }; -}); +})); diff --git a/test/form/samples/amd-id-auto/_expected/umd.js b/test/form/samples/amd-id-auto/_expected/umd.js index e7c8a2c40f8..51bd5b85622 100644 --- a/test/form/samples/amd-id-auto/_expected/umd.js +++ b/test/form/samples/amd-id-auto/_expected/umd.js @@ -1,8 +1,8 @@ (function (factory) { typeof define === 'function' && define.amd ? define('umd', factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; console.log(42); -}))); +})); diff --git a/test/form/samples/amd-id/_config.js b/test/form/samples/amd-id/_config.js index 2fb7c876ffa..25ebcbd5193 100644 --- a/test/form/samples/amd-id/_config.js +++ b/test/form/samples/amd-id/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'allows to declare an AMD id', options: { output: { amd: { id: 'my-id' } } } -}; +}); diff --git a/test/form/samples/amd-id/_expected/amd.js b/test/form/samples/amd-id/_expected/amd.js index 9e9ba54188c..ef33aeb74d9 100644 --- a/test/form/samples/amd-id/_expected/amd.js +++ b/test/form/samples/amd-id/_expected/amd.js @@ -1,5 +1,5 @@ -define('my-id', function () { 'use strict'; +define('my-id', (function () { 'use strict'; console.log(42); -}); +})); diff --git a/test/form/samples/amd-id/_expected/iife.js b/test/form/samples/amd-id/_expected/iife.js index 3a2d4df530d..26c81bfb6d0 100644 --- a/test/form/samples/amd-id/_expected/iife.js +++ b/test/form/samples/amd-id/_expected/iife.js @@ -3,4 +3,4 @@ console.log(42); -}()); +})(); diff --git a/test/form/samples/amd-id/_expected/system.js b/test/form/samples/amd-id/_expected/system.js index 424a0c00ec5..845bdcc4ef0 100644 --- a/test/form/samples/amd-id/_expected/system.js +++ b/test/form/samples/amd-id/_expected/system.js @@ -1,10 +1,10 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { console.log(42); - } + }) }; -}); +})); diff --git a/test/form/samples/amd-id/_expected/umd.js b/test/form/samples/amd-id/_expected/umd.js index 8f348b1d4f8..5ce7aff7d44 100644 --- a/test/form/samples/amd-id/_expected/umd.js +++ b/test/form/samples/amd-id/_expected/umd.js @@ -1,8 +1,8 @@ (function (factory) { typeof define === 'function' && define.amd ? define('my-id', factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; console.log(42); -}))); +})); diff --git a/test/form/samples/amd-keep-extension/_config.js b/test/form/samples/amd-keep-extension/_config.js new file mode 100644 index 00000000000..5215a1530fb --- /dev/null +++ b/test/form/samples/amd-keep-extension/_config.js @@ -0,0 +1,11 @@ +module.exports = defineTest({ + description: 'keep extension for AMD modules', + options: { + external: ['./relative', 'abso/lute', './relative.js', 'abso/lute.js'], + output: { + amd: { forceJsExtensionForImports: true }, + globals: id => id.split(/[/\\]/).pop().replace('.', '_'), + interop: 'default' + } + } +}); diff --git a/test/form/samples/amd-keep-extension/_expected/amd.js b/test/form/samples/amd-keep-extension/_expected/amd.js new file mode 100644 index 00000000000..85d309017dd --- /dev/null +++ b/test/form/samples/amd-keep-extension/_expected/amd.js @@ -0,0 +1,5 @@ +define(['./relative.js', 'abso/lute', './relative.js', 'abso/lute.js'], (function (relative, absolute, relativeExtension, absoluteExtension) { 'use strict'; + + console.log(relative, absolute, relativeExtension, absoluteExtension); + +})); diff --git a/test/form/samples/amd-keep-extension/_expected/cjs.js b/test/form/samples/amd-keep-extension/_expected/cjs.js new file mode 100644 index 00000000000..d2ccd7929f1 --- /dev/null +++ b/test/form/samples/amd-keep-extension/_expected/cjs.js @@ -0,0 +1,8 @@ +'use strict'; + +var relative = require('./relative'); +var absolute = require('abso/lute'); +var relativeExtension = require('./relative.js'); +var absoluteExtension = require('abso/lute.js'); + +console.log(relative, absolute, relativeExtension, absoluteExtension); diff --git a/test/form/samples/amd-keep-extension/_expected/es.js b/test/form/samples/amd-keep-extension/_expected/es.js new file mode 100644 index 00000000000..946ad911dcd --- /dev/null +++ b/test/form/samples/amd-keep-extension/_expected/es.js @@ -0,0 +1,6 @@ +import relative from './relative'; +import absolute from 'abso/lute'; +import relativeExtension from './relative.js'; +import absoluteExtension from 'abso/lute.js'; + +console.log(relative, absolute, relativeExtension, absoluteExtension); diff --git a/test/form/samples/amd-keep-extension/_expected/iife.js b/test/form/samples/amd-keep-extension/_expected/iife.js new file mode 100644 index 00000000000..63684b13ca3 --- /dev/null +++ b/test/form/samples/amd-keep-extension/_expected/iife.js @@ -0,0 +1,6 @@ +(function (relative, absolute, relativeExtension, absoluteExtension) { + 'use strict'; + + console.log(relative, absolute, relativeExtension, absoluteExtension); + +})(relative, lute, relative_js, lute_js); diff --git a/test/form/samples/amd-keep-extension/_expected/system.js b/test/form/samples/amd-keep-extension/_expected/system.js new file mode 100644 index 00000000000..660f3360b3b --- /dev/null +++ b/test/form/samples/amd-keep-extension/_expected/system.js @@ -0,0 +1,20 @@ +System.register(['./relative', 'abso/lute', './relative.js', 'abso/lute.js'], (function () { + 'use strict'; + var relative, absolute, relativeExtension, absoluteExtension; + return { + setters: [function (module) { + relative = module.default; + }, function (module) { + absolute = module.default; + }, function (module) { + relativeExtension = module.default; + }, function (module) { + absoluteExtension = module.default; + }], + execute: (function () { + + console.log(relative, absolute, relativeExtension, absoluteExtension); + + }) + }; +})); diff --git a/test/form/samples/amd-keep-extension/_expected/umd.js b/test/form/samples/amd-keep-extension/_expected/umd.js new file mode 100644 index 00000000000..229dfcd69ef --- /dev/null +++ b/test/form/samples/amd-keep-extension/_expected/umd.js @@ -0,0 +1,9 @@ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('./relative'), require('abso/lute'), require('./relative.js'), require('abso/lute.js')) : + typeof define === 'function' && define.amd ? define(['./relative.js', 'abso/lute', './relative.js', 'abso/lute.js'], factory) : + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.relative, global.lute, global.relative_js, global.lute_js)); +})(this, (function (relative, absolute, relativeExtension, absoluteExtension) { 'use strict'; + + console.log(relative, absolute, relativeExtension, absoluteExtension); + +})); diff --git a/test/form/samples/amd-keep-extension/main.js b/test/form/samples/amd-keep-extension/main.js new file mode 100644 index 00000000000..946ad911dcd --- /dev/null +++ b/test/form/samples/amd-keep-extension/main.js @@ -0,0 +1,6 @@ +import relative from './relative'; +import absolute from 'abso/lute'; +import relativeExtension from './relative.js'; +import absoluteExtension from 'abso/lute.js'; + +console.log(relative, absolute, relativeExtension, absoluteExtension); diff --git a/test/form/samples/arbitrary-module-namespace-identifiers/_config.js b/test/form/samples/arbitrary-module-namespace-identifiers/_config.js new file mode 100644 index 00000000000..f178af90836 --- /dev/null +++ b/test/form/samples/arbitrary-module-namespace-identifiers/_config.js @@ -0,0 +1,12 @@ +module.exports = defineTest({ + description: 'renders exports that are not identifiers', + verifyAst: false, + expectedWarnings: ['CIRCULAR_DEPENDENCY'], + options: { + external: ['external'], + output: { + globals: { external: 'external' }, + name: 'bundle' + } + } +}); diff --git a/test/form/samples/arbitrary-module-namespace-identifiers/_expected/amd.js b/test/form/samples/arbitrary-module-namespace-identifiers/_expected/amd.js new file mode 100644 index 00000000000..dcfeb856cb5 --- /dev/null +++ b/test/form/samples/arbitrary-module-namespace-identifiers/_expected/amd.js @@ -0,0 +1,65 @@ +define(['exports', 'external'], (function (exports, external) { 'use strict'; + + function _interopNamespaceDefault(e) { + var n = Object.create(null); + if (e) { + Object.keys(e).forEach(function (k) { + if (k !== 'default') { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + } + n.default = e; + return Object.freeze(n); + } + + var external__namespace = /*#__PURE__*/_interopNamespaceDefault(external); + + var main = /*#__PURE__*/Object.freeze({ + __proto__: null, + get 1 () { return one; }, + get bar () { return bar; }, + get "bar:\nfrom main'\"`" () { return bar; }, + get "class:\nfrom main'\"`" () { return C; }, + get "external:\nnamespace'\"`" () { return external__namespace; }, + get "external:\nre-exported'\"`" () { return external["external:\nre-exported'\"`"]; }, + get "foo:\nin quotes'\"`" () { return foo; }, + get 你好 () { return 你好; } + }); + + const foo = 42; + const one$1 = 43; + const 你好$1 = 44; + + var dep = /*#__PURE__*/Object.freeze({ + __proto__: null, + 1: one$1, + "foo:\nin quotes'\"`": foo, + 你好: 你好$1 + }); + + console.log(external["external:\nfoo'\"`"], main, dep); + + const bar = 42; + const one = 43; + class C {} + + const 你好 = 44; + + exports["external:\nnamespace'\"`"] = external__namespace; + Object.defineProperty(exports, "external:\nre-exported'\"`", { + enumerable: true, + get: function () { return external["external:\nre-exported'\"`"]; } + }); + exports["1"] = one; + exports.bar = bar; + exports["bar:\nfrom main'\"`"] = bar; + exports["class:\nfrom main'\"`"] = C; + exports["foo:\nin quotes'\"`"] = foo; + exports.你好 = 你好; + +})); diff --git a/test/form/samples/arbitrary-module-namespace-identifiers/_expected/cjs.js b/test/form/samples/arbitrary-module-namespace-identifiers/_expected/cjs.js new file mode 100644 index 00000000000..9d815673c3f --- /dev/null +++ b/test/form/samples/arbitrary-module-namespace-identifiers/_expected/cjs.js @@ -0,0 +1,65 @@ +'use strict'; + +var external = require('external'); + +function _interopNamespaceDefault(e) { + var n = Object.create(null); + if (e) { + Object.keys(e).forEach(function (k) { + if (k !== 'default') { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + } + n.default = e; + return Object.freeze(n); +} + +var external__namespace = /*#__PURE__*/_interopNamespaceDefault(external); + +var main = /*#__PURE__*/Object.freeze({ + __proto__: null, + get 1 () { return one; }, + get bar () { return bar; }, + get "bar:\nfrom main'\"`" () { return bar; }, + get "class:\nfrom main'\"`" () { return C; }, + get "external:\nnamespace'\"`" () { return external__namespace; }, + get "external:\nre-exported'\"`" () { return external["external:\nre-exported'\"`"]; }, + get "foo:\nin quotes'\"`" () { return foo; }, + get 你好 () { return 你好; } +}); + +const foo = 42; +const one$1 = 43; +const 你好$1 = 44; + +var dep = /*#__PURE__*/Object.freeze({ + __proto__: null, + 1: one$1, + "foo:\nin quotes'\"`": foo, + 你好: 你好$1 +}); + +console.log(external["external:\nfoo'\"`"], main, dep); + +const bar = 42; +const one = 43; +class C {} + +const 你好 = 44; + +exports["external:\nnamespace'\"`"] = external__namespace; +Object.defineProperty(exports, "external:\nre-exported'\"`", { + enumerable: true, + get: function () { return external["external:\nre-exported'\"`"]; } +}); +exports["1"] = one; +exports.bar = bar; +exports["bar:\nfrom main'\"`"] = bar; +exports["class:\nfrom main'\"`"] = C; +exports["foo:\nin quotes'\"`"] = foo; +exports.你好 = 你好; diff --git a/test/form/samples/arbitrary-module-namespace-identifiers/_expected/es.js b/test/form/samples/arbitrary-module-namespace-identifiers/_expected/es.js new file mode 100644 index 00000000000..af21cf6e7a3 --- /dev/null +++ b/test/form/samples/arbitrary-module-namespace-identifiers/_expected/es.js @@ -0,0 +1,37 @@ +import * as external from 'external'; +import { "external:\nfoo'\"`" as external__foo___, "external:\nre-exported'\"`" as external__reExported___ } from 'external'; +export { external as "external:\nnamespace'\"`" }; +export { "external:\nre-exported'\"`" } from 'external'; + +var main = /*#__PURE__*/Object.freeze({ + __proto__: null, + get 1 () { return one; }, + get bar () { return bar; }, + get "bar:\nfrom main'\"`" () { return bar; }, + get "class:\nfrom main'\"`" () { return C; }, + get "external:\nnamespace'\"`" () { return external; }, + get "external:\nre-exported'\"`" () { return external__reExported___; }, + get "foo:\nin quotes'\"`" () { return foo; }, + get 你好 () { return 你好; } +}); + +const foo = 42; +const one$1 = 43; +const 你好$1 = 44; + +var dep = /*#__PURE__*/Object.freeze({ + __proto__: null, + 1: one$1, + "foo:\nin quotes'\"`": foo, + 你好: 你好$1 +}); + +console.log(external__foo___, main, dep); + +const bar = 42; +const one = 43; +class C {} + +const 你好 = 44; + +export { one as "1", bar, bar as "bar:\nfrom main'\"`", C as "class:\nfrom main'\"`", foo as "foo:\nin quotes'\"`", 你好 }; diff --git a/test/form/samples/arbitrary-module-namespace-identifiers/_expected/iife.js b/test/form/samples/arbitrary-module-namespace-identifiers/_expected/iife.js new file mode 100644 index 00000000000..826deb2892a --- /dev/null +++ b/test/form/samples/arbitrary-module-namespace-identifiers/_expected/iife.js @@ -0,0 +1,68 @@ +var bundle = (function (exports, external) { + 'use strict'; + + function _interopNamespaceDefault(e) { + var n = Object.create(null); + if (e) { + Object.keys(e).forEach(function (k) { + if (k !== 'default') { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + } + n.default = e; + return Object.freeze(n); + } + + var external__namespace = /*#__PURE__*/_interopNamespaceDefault(external); + + var main = /*#__PURE__*/Object.freeze({ + __proto__: null, + get 1 () { return one; }, + get bar () { return bar; }, + get "bar:\nfrom main'\"`" () { return bar; }, + get "class:\nfrom main'\"`" () { return C; }, + get "external:\nnamespace'\"`" () { return external__namespace; }, + get "external:\nre-exported'\"`" () { return external["external:\nre-exported'\"`"]; }, + get "foo:\nin quotes'\"`" () { return foo; }, + get 你好 () { return 你好; } + }); + + const foo = 42; + const one$1 = 43; + const 你好$1 = 44; + + var dep = /*#__PURE__*/Object.freeze({ + __proto__: null, + 1: one$1, + "foo:\nin quotes'\"`": foo, + 你好: 你好$1 + }); + + console.log(external["external:\nfoo'\"`"], main, dep); + + const bar = 42; + const one = 43; + class C {} + + const 你好 = 44; + + exports["external:\nnamespace'\"`"] = external__namespace; + Object.defineProperty(exports, "external:\nre-exported'\"`", { + enumerable: true, + get: function () { return external["external:\nre-exported'\"`"]; } + }); + exports["1"] = one; + exports.bar = bar; + exports["bar:\nfrom main'\"`"] = bar; + exports["class:\nfrom main'\"`"] = C; + exports["foo:\nin quotes'\"`"] = foo; + exports.你好 = 你好; + + return exports; + +})({}, external); diff --git a/test/form/samples/arbitrary-module-namespace-identifiers/_expected/system.js b/test/form/samples/arbitrary-module-namespace-identifiers/_expected/system.js new file mode 100644 index 00000000000..8ff04cadeb6 --- /dev/null +++ b/test/form/samples/arbitrary-module-namespace-identifiers/_expected/system.js @@ -0,0 +1,46 @@ +System.register('bundle', ['external'], (function (exports) { + 'use strict'; + var external__foo___, external, external__reExported___; + return { + setters: [function (module) { + external__foo___ = module["external:\nfoo'\"`"]; + external = module; + external__reExported___ = module["external:\nre-exported'\"`"]; + exports({ "external:\nnamespace'\"`": module, "external:\nre-exported'\"`": module["external:\nre-exported'\"`"] }); + }], + execute: (function () { + + var main = /*#__PURE__*/Object.freeze({ + __proto__: null, + get 1 () { return one; }, + get bar () { return bar; }, + get "bar:\nfrom main'\"`" () { return bar; }, + get "class:\nfrom main'\"`" () { return C; }, + get "external:\nnamespace'\"`" () { return external; }, + get "external:\nre-exported'\"`" () { return external__reExported___; }, + get "foo:\nin quotes'\"`" () { return foo; }, + get 你好 () { return 你好; } + }); + + const foo = exports("foo:\nin quotes'\"`", 42); + const one$1 = 43; + const 你好$1 = 44; + + var dep = /*#__PURE__*/Object.freeze({ + __proto__: null, + 1: one$1, + "foo:\nin quotes'\"`": foo, + 你好: 你好$1 + }); + + console.log(external__foo___, main, dep); + + const bar = 42; exports({ bar: bar, "bar:\nfrom main'\"`": bar }); + const one = exports("1", 43); + class C {} exports("class:\nfrom main'\"`", C); + + const 你好 = exports("你好", 44); + + }) + }; +})); diff --git a/test/form/samples/arbitrary-module-namespace-identifiers/_expected/umd.js b/test/form/samples/arbitrary-module-namespace-identifiers/_expected/umd.js new file mode 100644 index 00000000000..ec5cd3d1f6b --- /dev/null +++ b/test/form/samples/arbitrary-module-namespace-identifiers/_expected/umd.js @@ -0,0 +1,69 @@ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('external')) : + typeof define === 'function' && define.amd ? define(['exports', 'external'], factory) : + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.bundle = {}, global.external)); +})(this, (function (exports, external) { 'use strict'; + + function _interopNamespaceDefault(e) { + var n = Object.create(null); + if (e) { + Object.keys(e).forEach(function (k) { + if (k !== 'default') { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + } + n.default = e; + return Object.freeze(n); + } + + var external__namespace = /*#__PURE__*/_interopNamespaceDefault(external); + + var main = /*#__PURE__*/Object.freeze({ + __proto__: null, + get 1 () { return one; }, + get bar () { return bar; }, + get "bar:\nfrom main'\"`" () { return bar; }, + get "class:\nfrom main'\"`" () { return C; }, + get "external:\nnamespace'\"`" () { return external__namespace; }, + get "external:\nre-exported'\"`" () { return external["external:\nre-exported'\"`"]; }, + get "foo:\nin quotes'\"`" () { return foo; }, + get 你好 () { return 你好; } + }); + + const foo = 42; + const one$1 = 43; + const 你好$1 = 44; + + var dep = /*#__PURE__*/Object.freeze({ + __proto__: null, + 1: one$1, + "foo:\nin quotes'\"`": foo, + 你好: 你好$1 + }); + + console.log(external["external:\nfoo'\"`"], main, dep); + + const bar = 42; + const one = 43; + class C {} + + const 你好 = 44; + + exports["external:\nnamespace'\"`"] = external__namespace; + Object.defineProperty(exports, "external:\nre-exported'\"`", { + enumerable: true, + get: function () { return external["external:\nre-exported'\"`"]; } + }); + exports["1"] = one; + exports.bar = bar; + exports["bar:\nfrom main'\"`"] = bar; + exports["class:\nfrom main'\"`"] = C; + exports["foo:\nin quotes'\"`"] = foo; + exports.你好 = 你好; + +})); diff --git a/test/form/samples/arbitrary-module-namespace-identifiers/dep.js b/test/form/samples/arbitrary-module-namespace-identifiers/dep.js new file mode 100644 index 00000000000..c050853c88c --- /dev/null +++ b/test/form/samples/arbitrary-module-namespace-identifiers/dep.js @@ -0,0 +1,5 @@ +const foo = 42; +const one = 43; +export const 你好 = 44; + +export { one as '1', foo as 'foo:\nin quotes\'"`' }; diff --git a/test/form/samples/arbitrary-module-namespace-identifiers/main.js b/test/form/samples/arbitrary-module-namespace-identifiers/main.js new file mode 100644 index 00000000000..5c0443d7719 --- /dev/null +++ b/test/form/samples/arbitrary-module-namespace-identifiers/main.js @@ -0,0 +1,16 @@ +import * as dep from './dep.js'; +import * as main from './main.js'; +import { 'external:\nfoo\'"`' as foo } from 'external'; + +console.log(foo, main, dep); + +export const bar = 42; +const one = 43; +class C {} + +export const 你好 = 44; + +export { one as '1', bar as 'bar:\nfrom main\'"`', C as 'class:\nfrom main\'"`' }; +export * from './dep'; +export * as 'external:\nnamespace\'"`' from 'external'; +export { 'external:\nre-exported\'"`' } from 'external'; diff --git a/test/form/samples/arbitrary-module-namespace-identifiers2/_config.js b/test/form/samples/arbitrary-module-namespace-identifiers2/_config.js new file mode 100644 index 00000000000..58fd6154710 --- /dev/null +++ b/test/form/samples/arbitrary-module-namespace-identifiers2/_config.js @@ -0,0 +1,11 @@ +module.exports = defineTest({ + description: 'renders exports that are not identifiers', + verifyAst: false, + options: { + external: ['external'], + output: { + globals: { external: 'external' }, + name: 'myBundle' + } + } +}); diff --git a/test/form/samples/arbitrary-module-namespace-identifiers2/_expected/amd.js b/test/form/samples/arbitrary-module-namespace-identifiers2/_expected/amd.js new file mode 100644 index 00000000000..85cc35c7300 --- /dev/null +++ b/test/form/samples/arbitrary-module-namespace-identifiers2/_expected/amd.js @@ -0,0 +1,13 @@ +define(['exports', 'external'], (function (exports, external) { 'use strict'; + + function a () {} + function b () {} + + Object.defineProperty(exports, "'x", { + enumerable: true, + get: function () { return external.x; } + }); + exports["'a"] = a; + exports["'b"] = b; + +})); diff --git a/test/form/samples/arbitrary-module-namespace-identifiers2/_expected/cjs.js b/test/form/samples/arbitrary-module-namespace-identifiers2/_expected/cjs.js new file mode 100644 index 00000000000..62140665aa4 --- /dev/null +++ b/test/form/samples/arbitrary-module-namespace-identifiers2/_expected/cjs.js @@ -0,0 +1,13 @@ +'use strict'; + +var external = require('external'); + +function a () {} +function b () {} + +Object.defineProperty(exports, "'x", { + enumerable: true, + get: function () { return external.x; } +}); +exports["'a"] = a; +exports["'b"] = b; diff --git a/test/form/samples/arbitrary-module-namespace-identifiers2/_expected/es.js b/test/form/samples/arbitrary-module-namespace-identifiers2/_expected/es.js new file mode 100644 index 00000000000..c0837313335 --- /dev/null +++ b/test/form/samples/arbitrary-module-namespace-identifiers2/_expected/es.js @@ -0,0 +1,6 @@ +export { x as "'x" } from 'external'; + +function a () {} +function b () {} + +export { a as "'a", b as "'b" }; diff --git a/test/form/samples/arbitrary-module-namespace-identifiers2/_expected/iife.js b/test/form/samples/arbitrary-module-namespace-identifiers2/_expected/iife.js new file mode 100644 index 00000000000..855f8a64759 --- /dev/null +++ b/test/form/samples/arbitrary-module-namespace-identifiers2/_expected/iife.js @@ -0,0 +1,16 @@ +var myBundle = (function (exports, external) { + 'use strict'; + + function a () {} + function b () {} + + Object.defineProperty(exports, "'x", { + enumerable: true, + get: function () { return external.x; } + }); + exports["'a"] = a; + exports["'b"] = b; + + return exports; + +})({}, external); diff --git a/test/form/samples/arbitrary-module-namespace-identifiers2/_expected/system.js b/test/form/samples/arbitrary-module-namespace-identifiers2/_expected/system.js new file mode 100644 index 00000000000..99a535f824b --- /dev/null +++ b/test/form/samples/arbitrary-module-namespace-identifiers2/_expected/system.js @@ -0,0 +1,19 @@ +System.register('myBundle', ['external'], (function (exports) { + 'use strict'; + return { + setters: [function (module) { + exports("'x", module.x); + }], + execute: (function () { + + exports({ + "'a": a, + "'b": b + }); + + function a () {} + function b () {} + + }) + }; +})); diff --git a/test/form/samples/arbitrary-module-namespace-identifiers2/_expected/umd.js b/test/form/samples/arbitrary-module-namespace-identifiers2/_expected/umd.js new file mode 100644 index 00000000000..d8184071909 --- /dev/null +++ b/test/form/samples/arbitrary-module-namespace-identifiers2/_expected/umd.js @@ -0,0 +1,17 @@ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('external')) : + typeof define === 'function' && define.amd ? define(['exports', 'external'], factory) : + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.myBundle = {}, global.external)); +})(this, (function (exports, external) { 'use strict'; + + function a () {} + function b () {} + + Object.defineProperty(exports, "'x", { + enumerable: true, + get: function () { return external.x; } + }); + exports["'a"] = a; + exports["'b"] = b; + +})); diff --git a/test/form/samples/arbitrary-module-namespace-identifiers2/main.js b/test/form/samples/arbitrary-module-namespace-identifiers2/main.js new file mode 100644 index 00000000000..fa584e70e25 --- /dev/null +++ b/test/form/samples/arbitrary-module-namespace-identifiers2/main.js @@ -0,0 +1,5 @@ +export { x as "'x" } from 'external'; + +function a () {} +function b () {} +export { a as "'a", b as "'b" }; diff --git a/test/form/samples/argument-deoptimization/no-default-deoptimization/_config.js b/test/form/samples/argument-deoptimization/no-default-deoptimization/_config.js new file mode 100644 index 00000000000..6d2d48368e9 --- /dev/null +++ b/test/form/samples/argument-deoptimization/no-default-deoptimization/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'does not deoptimize call arguments by default' +}); diff --git a/test/form/samples/argument-deoptimization/no-default-deoptimization/_expected.js b/test/form/samples/argument-deoptimization/no-default-deoptimization/_expected.js new file mode 100644 index 00000000000..4825187a84f --- /dev/null +++ b/test/form/samples/argument-deoptimization/no-default-deoptimization/_expected.js @@ -0,0 +1,9 @@ +const obj = { mutated: false}; + +function updateObj(target) { + target.mutated = true; +} + +updateObj(obj); + +console.log(obj.mutated ? 'OK' : 'FAIL'); diff --git a/test/form/samples/argument-deoptimization/no-default-deoptimization/main.js b/test/form/samples/argument-deoptimization/no-default-deoptimization/main.js new file mode 100644 index 00000000000..e893fd5e1be --- /dev/null +++ b/test/form/samples/argument-deoptimization/no-default-deoptimization/main.js @@ -0,0 +1,12 @@ +const obj = { mutated: false, noEffect() {} }; + +function updateObj(target) { + target.mutated = true; +} + +updateObj(obj); + +// removed +obj.noEffect(); + +console.log(obj.mutated ? 'OK' : 'FAIL'); diff --git a/test/form/samples/argument-deoptimization/no-global-call-deoptimization/_config.js b/test/form/samples/argument-deoptimization/no-global-call-deoptimization/_config.js new file mode 100644 index 00000000000..0b2c36660ab --- /dev/null +++ b/test/form/samples/argument-deoptimization/no-global-call-deoptimization/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'does not deoptimize call arguments of calls to globals by default' +}); diff --git a/test/form/samples/argument-deoptimization/no-global-call-deoptimization/_expected.js b/test/form/samples/argument-deoptimization/no-global-call-deoptimization/_expected.js new file mode 100644 index 00000000000..457bfa2ffc0 --- /dev/null +++ b/test/form/samples/argument-deoptimization/no-global-call-deoptimization/_expected.js @@ -0,0 +1,5 @@ +const obj = { foo: true, noEffect() {} }; + +console.log(obj); + +console.log('OK' ); diff --git a/test/form/samples/argument-deoptimization/no-global-call-deoptimization/main.js b/test/form/samples/argument-deoptimization/no-global-call-deoptimization/main.js new file mode 100644 index 00000000000..16f72307b9c --- /dev/null +++ b/test/form/samples/argument-deoptimization/no-global-call-deoptimization/main.js @@ -0,0 +1,8 @@ +const obj = { foo: true, noEffect() {} }; + +console.log(obj); + +// removed +obj.noEffect(); + +console.log(obj.foo ? 'OK' : 'FAIL'); diff --git a/test/form/samples/argument-deoptimization/return-function-deoptimization/_config.js b/test/form/samples/argument-deoptimization/return-function-deoptimization/_config.js new file mode 100644 index 00000000000..111afff1537 --- /dev/null +++ b/test/form/samples/argument-deoptimization/return-function-deoptimization/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'does not deoptimize call arguments of returned functions by default' +}); diff --git a/test/form/samples/argument-deoptimization/return-function-deoptimization/_expected.js b/test/form/samples/argument-deoptimization/return-function-deoptimization/_expected.js new file mode 100644 index 00000000000..baaee93d818 --- /dev/null +++ b/test/form/samples/argument-deoptimization/return-function-deoptimization/_expected.js @@ -0,0 +1,11 @@ +const obj = { mutated: false, noEffect() {} }; + +function foo() { + return x => { + x.mutated = true; + }; +} + +foo()(obj); + +console.log(obj.mutated ? 'OK' : 'FAIL'); diff --git a/test/form/samples/argument-deoptimization/return-function-deoptimization/main.js b/test/form/samples/argument-deoptimization/return-function-deoptimization/main.js new file mode 100644 index 00000000000..607770940c6 --- /dev/null +++ b/test/form/samples/argument-deoptimization/return-function-deoptimization/main.js @@ -0,0 +1,14 @@ +const obj = { mutated: false, noEffect() {} }; + +function foo() { + return x => { + x.mutated = true; + }; +} + +foo()(obj); + +// removed +obj.noEffect(); + +console.log(obj.mutated ? 'OK' : 'FAIL'); diff --git a/test/form/samples/array-element-tracking/array-elements/_config.js b/test/form/samples/array-element-tracking/array-elements/_config.js new file mode 100644 index 00000000000..33a97fb0a9e --- /dev/null +++ b/test/form/samples/array-element-tracking/array-elements/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'tracks elements of arrays' +}); diff --git a/test/form/samples/array-element-tracking/array-elements/_expected.js b/test/form/samples/array-element-tracking/array-elements/_expected.js new file mode 100644 index 00000000000..350400b9918 --- /dev/null +++ b/test/form/samples/array-element-tracking/array-elements/_expected.js @@ -0,0 +1,4 @@ +console.log('retained'); +console.log('retained'); +console.log('retained'); +console.log('retained'); diff --git a/test/form/samples/array-element-tracking/array-elements/main.js b/test/form/samples/array-element-tracking/array-elements/main.js new file mode 100644 index 00000000000..31792cf92ec --- /dev/null +++ b/test/form/samples/array-element-tracking/array-elements/main.js @@ -0,0 +1,10 @@ +const array = [true, false, 3]; + +if (array[0]) console.log('retained'); +else console.log('removed'); +if (array[1]) console.log('removed'); +else console.log('retained'); +if (array[2] === 3) console.log('retained'); +else console.log('removed'); +if (array[3]) console.log('removed'); +else console.log('retained'); diff --git a/test/form/samples/array-element-tracking/array-mutation/_config.js b/test/form/samples/array-element-tracking/array-mutation/_config.js new file mode 100644 index 00000000000..65ce34ca346 --- /dev/null +++ b/test/form/samples/array-element-tracking/array-mutation/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'tracks mutations of array elements' +}); diff --git a/test/form/samples/array-element-tracking/array-mutation/_expected.js b/test/form/samples/array-element-tracking/array-mutation/_expected.js new file mode 100644 index 00000000000..b4c4acc5b9a --- /dev/null +++ b/test/form/samples/array-element-tracking/array-mutation/_expected.js @@ -0,0 +1,10 @@ +const array = [true, true]; + +array[1] = false; +array[2] = true; + +console.log('retained'); +if (array[1]) console.log('unimportant'); +else console.log('retained'); +if (array[2]) console.log('retained'); +else console.log('unimportant'); diff --git a/test/form/samples/array-element-tracking/array-mutation/main.js b/test/form/samples/array-element-tracking/array-mutation/main.js new file mode 100644 index 00000000000..37327b20616 --- /dev/null +++ b/test/form/samples/array-element-tracking/array-mutation/main.js @@ -0,0 +1,11 @@ +const array = [true, true]; + +array[1] = false; +array[2] = true; + +if (array[0]) console.log('retained'); +else console.log('removed'); +if (array[1]) console.log('unimportant'); +else console.log('retained'); +if (array[2]) console.log('retained'); +else console.log('unimportant'); diff --git a/test/form/samples/array-element-tracking/array-spread/_config.js b/test/form/samples/array-element-tracking/array-spread/_config.js new file mode 100644 index 00000000000..d29aa6bf18e --- /dev/null +++ b/test/form/samples/array-element-tracking/array-spread/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'tracks elements of arrays with spread elements' +}); diff --git a/test/form/samples/array-element-tracking/array-spread/_expected.js b/test/form/samples/array-element-tracking/array-spread/_expected.js new file mode 100644 index 00000000000..2d0ec880684 --- /dev/null +++ b/test/form/samples/array-element-tracking/array-spread/_expected.js @@ -0,0 +1,9 @@ +const spread = [true, false]; +const array = [true, false, ...spread]; + +console.log('retained'); +console.log('retained'); +if (array[2]) console.log('retained'); +else console.log('unimportant'); +if (array[3]) console.log('unimportant'); +else console.log('retained'); diff --git a/test/form/samples/array-element-tracking/array-spread/main.js b/test/form/samples/array-element-tracking/array-spread/main.js new file mode 100644 index 00000000000..cf36dae8591 --- /dev/null +++ b/test/form/samples/array-element-tracking/array-spread/main.js @@ -0,0 +1,11 @@ +const spread = [true, false]; +const array = [true, false, ...spread]; + +if (array[0]) console.log('retained'); +else console.log('removed'); +if (array[1]) console.log('removed'); +else console.log('retained'); +if (array[2]) console.log('retained'); +else console.log('unimportant'); +if (array[3]) console.log('unimportant'); +else console.log('retained'); diff --git a/test/form/samples/array-element-tracking/spread-element-deoptimization/_config.js b/test/form/samples/array-element-tracking/spread-element-deoptimization/_config.js new file mode 100644 index 00000000000..ad7ae85213c --- /dev/null +++ b/test/form/samples/array-element-tracking/spread-element-deoptimization/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'deoptimizes array spread elements' +}); diff --git a/test/form/samples/array-element-tracking/spread-element-deoptimization/_expected.js b/test/form/samples/array-element-tracking/spread-element-deoptimization/_expected.js new file mode 100644 index 00000000000..a2633a81cc0 --- /dev/null +++ b/test/form/samples/array-element-tracking/spread-element-deoptimization/_expected.js @@ -0,0 +1,3 @@ +const spread = [{ effect() {} }]; +[...spread][0].effect = () => console.log('effect'); +spread[0].effect(); diff --git a/test/form/samples/array-element-tracking/spread-element-deoptimization/main.js b/test/form/samples/array-element-tracking/spread-element-deoptimization/main.js new file mode 100644 index 00000000000..a2633a81cc0 --- /dev/null +++ b/test/form/samples/array-element-tracking/spread-element-deoptimization/main.js @@ -0,0 +1,3 @@ +const spread = [{ effect() {} }]; +[...spread][0].effect = () => console.log('effect'); +spread[0].effect(); diff --git a/test/form/samples/arrow-function-call-parameters/_config.js b/test/form/samples/arrow-function-call-parameters/_config.js index 3ffe2078d48..ced3d3e3a24 100644 --- a/test/form/samples/arrow-function-call-parameters/_config.js +++ b/test/form/samples/arrow-function-call-parameters/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'take actual parameters into account when determining side-effects of calls to arrow functions' -}; +}); diff --git a/test/form/samples/arrow-function-return-values/_config.js b/test/form/samples/arrow-function-return-values/_config.js index ec78acb1bad..81fabffcdd2 100644 --- a/test/form/samples/arrow-function-return-values/_config.js +++ b/test/form/samples/arrow-function-return-values/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'forwards return values of arrow functions' -}; +}); diff --git a/test/form/samples/arrow-function-return-values/_expected.js b/test/form/samples/arrow-function-return-values/_expected.js index 1bedb0a7bbe..a3fd2df3d87 100644 --- a/test/form/samples/arrow-function-return-values/_expected.js +++ b/test/form/samples/arrow-function-return-values/_expected.js @@ -6,9 +6,5 @@ retained1()(); (() => { return () => console.log( 'effect' ); })()(); - -(() => ({ foo: () => {} }))().foo(); (() => ({ foo: () => console.log( 'effect' ) }))().foo(); - -(() => ({ foo: () => ({ bar: () => ({ baz: () => {} }) }) }))().foo().bar().baz(); (() => ({ foo: () => ({ bar: () => console.log( 'effect' ) }) }))().foo().bar(); diff --git a/test/form/samples/assignment-to-array-buffer-view/_config.js b/test/form/samples/assignment-to-array-buffer-view/_config.js index 0984b6ee615..74f502ac83d 100644 --- a/test/form/samples/assignment-to-array-buffer-view/_config.js +++ b/test/form/samples/assignment-to-array-buffer-view/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'assignment to views of buffers should be kept', options: { output: { name: 'bundle' } } -}; +}); diff --git a/test/form/samples/assignment-to-array-buffer-view/_expected/amd.js b/test/form/samples/assignment-to-array-buffer-view/_expected/amd.js index 77c8c89fe85..a1975c8d08c 100644 --- a/test/form/samples/assignment-to-array-buffer-view/_expected/amd.js +++ b/test/form/samples/assignment-to-array-buffer-view/_expected/amd.js @@ -1,4 +1,4 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; var buffer = new ArrayBuffer( 8 ); @@ -9,6 +9,4 @@ define(['exports'], function (exports) { 'use strict'; exports.view8 = view8; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/form/samples/assignment-to-array-buffer-view/_expected/cjs.js b/test/form/samples/assignment-to-array-buffer-view/_expected/cjs.js index 1c6f45c06e4..4ed86ce4035 100644 --- a/test/form/samples/assignment-to-array-buffer-view/_expected/cjs.js +++ b/test/form/samples/assignment-to-array-buffer-view/_expected/cjs.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - var buffer = new ArrayBuffer( 8 ); var view8 = new Int8Array( buffer ); diff --git a/test/form/samples/assignment-to-array-buffer-view/_expected/iife.js b/test/form/samples/assignment-to-array-buffer-view/_expected/iife.js index 1c822db4d33..411c2483655 100644 --- a/test/form/samples/assignment-to-array-buffer-view/_expected/iife.js +++ b/test/form/samples/assignment-to-array-buffer-view/_expected/iife.js @@ -10,8 +10,6 @@ var bundle = (function (exports) { exports.view8 = view8; - Object.defineProperty(exports, '__esModule', { value: true }); - return exports; -}({})); +})({}); diff --git a/test/form/samples/assignment-to-array-buffer-view/_expected/system.js b/test/form/samples/assignment-to-array-buffer-view/_expected/system.js index 4ce5f627364..8634ac30c3e 100644 --- a/test/form/samples/assignment-to-array-buffer-view/_expected/system.js +++ b/test/form/samples/assignment-to-array-buffer-view/_expected/system.js @@ -1,15 +1,15 @@ -System.register('bundle', [], function (exports) { +System.register('bundle', [], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { var buffer = new ArrayBuffer( 8 ); - var view8 = exports('view8', new Int8Array( buffer )); + var view8 = exports("view8", new Int8Array( buffer )); var view16 = new Int16Array( buffer ); view16[ 0 ] = 3; - } + }) }; -}); +})); diff --git a/test/form/samples/assignment-to-array-buffer-view/_expected/umd.js b/test/form/samples/assignment-to-array-buffer-view/_expected/umd.js index 3f2fcec0635..7d64178bdeb 100644 --- a/test/form/samples/assignment-to-array-buffer-view/_expected/umd.js +++ b/test/form/samples/assignment-to-array-buffer-view/_expected/umd.js @@ -2,7 +2,7 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.bundle = {})); -}(this, (function (exports) { 'use strict'; +})(this, (function (exports) { 'use strict'; var buffer = new ArrayBuffer( 8 ); @@ -13,6 +13,4 @@ exports.view8 = view8; - Object.defineProperty(exports, '__esModule', { value: true }); - -}))); +})); diff --git a/test/form/samples/assignment-to-exports-class-declaration/_config.js b/test/form/samples/assignment-to-exports-class-declaration/_config.js index f4e1cb7acbd..512ae789de2 100644 --- a/test/form/samples/assignment-to-exports-class-declaration/_config.js +++ b/test/form/samples/assignment-to-exports-class-declaration/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'does not rewrite class expression IDs', options: { output: { name: 'myModule' } } -}; +}); diff --git a/test/form/samples/assignment-to-exports-class-declaration/_expected/amd.js b/test/form/samples/assignment-to-exports-class-declaration/_expected/amd.js index b6e6ac96007..da832accde6 100644 --- a/test/form/samples/assignment-to-exports-class-declaration/_expected/amd.js +++ b/test/form/samples/assignment-to-exports-class-declaration/_expected/amd.js @@ -1,8 +1,6 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; exports.Foo = class Foo {}; exports.Foo = lol( exports.Foo ); - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/form/samples/assignment-to-exports-class-declaration/_expected/cjs.js b/test/form/samples/assignment-to-exports-class-declaration/_expected/cjs.js index d291984995d..cc841d47787 100644 --- a/test/form/samples/assignment-to-exports-class-declaration/_expected/cjs.js +++ b/test/form/samples/assignment-to-exports-class-declaration/_expected/cjs.js @@ -1,6 +1,4 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - exports.Foo = class Foo {}; exports.Foo = lol( exports.Foo ); diff --git a/test/form/samples/assignment-to-exports-class-declaration/_expected/iife.js b/test/form/samples/assignment-to-exports-class-declaration/_expected/iife.js index d98dc6a914b..de9e3facacb 100644 --- a/test/form/samples/assignment-to-exports-class-declaration/_expected/iife.js +++ b/test/form/samples/assignment-to-exports-class-declaration/_expected/iife.js @@ -4,8 +4,6 @@ var myModule = (function (exports) { exports.Foo = class Foo {}; exports.Foo = lol( exports.Foo ); - Object.defineProperty(exports, '__esModule', { value: true }); - return exports; -}({})); +})({}); diff --git a/test/form/samples/assignment-to-exports-class-declaration/_expected/system.js b/test/form/samples/assignment-to-exports-class-declaration/_expected/system.js index d868c404bdd..06f379e4cf7 100644 --- a/test/form/samples/assignment-to-exports-class-declaration/_expected/system.js +++ b/test/form/samples/assignment-to-exports-class-declaration/_expected/system.js @@ -1,11 +1,11 @@ -System.register('myModule', [], function (exports) { +System.register('myModule', [], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - let Foo = exports('Foo', class Foo {}); - Foo = exports('Foo', lol( Foo )); + let Foo = exports("Foo", class Foo {}); + exports("Foo", Foo = lol( Foo )); - } + }) }; -}); +})); diff --git a/test/form/samples/assignment-to-exports-class-declaration/_expected/umd.js b/test/form/samples/assignment-to-exports-class-declaration/_expected/umd.js index 88f72565ed4..6dbf8df37b0 100644 --- a/test/form/samples/assignment-to-exports-class-declaration/_expected/umd.js +++ b/test/form/samples/assignment-to-exports-class-declaration/_expected/umd.js @@ -2,11 +2,9 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.myModule = {})); -}(this, (function (exports) { 'use strict'; +})(this, (function (exports) { 'use strict'; exports.Foo = class Foo {}; exports.Foo = lol( exports.Foo ); - Object.defineProperty(exports, '__esModule', { value: true }); - -}))); +})); diff --git a/test/form/samples/assignment-to-exports/_config.js b/test/form/samples/assignment-to-exports/_config.js index 015759bc6cc..548407a86e1 100644 --- a/test/form/samples/assignment-to-exports/_config.js +++ b/test/form/samples/assignment-to-exports/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'declares updated variable in ES output (#755)', options: { output: { name: 'bundle' } } -}; +}); diff --git a/test/form/samples/assignment-to-exports/_expected/amd.js b/test/form/samples/assignment-to-exports/_expected/amd.js index 0dd931f9d2c..0399eb4f93b 100644 --- a/test/form/samples/assignment-to-exports/_expected/amd.js +++ b/test/form/samples/assignment-to-exports/_expected/amd.js @@ -1,4 +1,4 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; // Unassigned export var foo1; @@ -27,6 +27,4 @@ define(['exports'], function (exports) { 'use strict'; exports.foo1 = foo1; exports.foo2 = foo2; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/form/samples/assignment-to-exports/_expected/cjs.js b/test/form/samples/assignment-to-exports/_expected/cjs.js index 2adec04748f..7423913d78b 100644 --- a/test/form/samples/assignment-to-exports/_expected/cjs.js +++ b/test/form/samples/assignment-to-exports/_expected/cjs.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - // Unassigned export var foo1; diff --git a/test/form/samples/assignment-to-exports/_expected/iife.js b/test/form/samples/assignment-to-exports/_expected/iife.js index a26ab26dabe..dcceb411557 100644 --- a/test/form/samples/assignment-to-exports/_expected/iife.js +++ b/test/form/samples/assignment-to-exports/_expected/iife.js @@ -28,8 +28,6 @@ var bundle = (function (exports) { exports.foo1 = foo1; exports.foo2 = foo2; - Object.defineProperty(exports, '__esModule', { value: true }); - return exports; -}({})); +})({}); diff --git a/test/form/samples/assignment-to-exports/_expected/system.js b/test/form/samples/assignment-to-exports/_expected/system.js index 4c730ae6d67..ba9f74c1c4a 100644 --- a/test/form/samples/assignment-to-exports/_expected/system.js +++ b/test/form/samples/assignment-to-exports/_expected/system.js @@ -1,39 +1,32 @@ -System.register('bundle', [], function (exports) { +System.register('bundle', [], (function (exports) { 'use strict'; return { - execute: function () { - - exports({ - bar1: void 0, - bar2: void 0, - foo1: void 0, - foo2: void 0 - }); + execute: (function () { // Unassigned export - var foo1; + var foo1; exports("foo1", foo1); // Reassigned uninitialised export - bar1 = exports('bar1', 1); - var bar1; + exports("bar1", bar1 = 1); + var bar1; exports("bar1", bar1); // Reassigned initialised export - var baz1 = exports('baz1', 1); - baz1 = exports('baz1', 2); + var baz1 = exports("baz1", 1); + exports("baz1", baz1 = 2); // Unassigned export - var kept1, foo2, kept2; + var kept1, foo2, kept2; exports("foo2", foo2); // Reassigned uninitialised export - var kept1, bar2, kept2; - bar2 = exports('bar2', 1); + var kept1, bar2, kept2; exports("bar2", bar2); + exports("bar2", bar2 = 1); // Reassigned initialised export - var kept1, baz2 = exports('baz2', 1), kept2; - baz2 = exports('baz2', 2); + var kept1, baz2 = exports("baz2", 1), kept2; + exports("baz2", baz2 = 2); console.log( kept1, kept2 ); - } + }) }; -}); +})); diff --git a/test/form/samples/assignment-to-exports/_expected/umd.js b/test/form/samples/assignment-to-exports/_expected/umd.js index 3f3358fec23..36f0efb2e55 100644 --- a/test/form/samples/assignment-to-exports/_expected/umd.js +++ b/test/form/samples/assignment-to-exports/_expected/umd.js @@ -2,7 +2,7 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.bundle = {})); -}(this, (function (exports) { 'use strict'; +})(this, (function (exports) { 'use strict'; // Unassigned export var foo1; @@ -31,6 +31,4 @@ exports.foo1 = foo1; exports.foo2 = foo2; - Object.defineProperty(exports, '__esModule', { value: true }); - -}))); +})); diff --git a/test/form/samples/assignment-to-global/_config.js b/test/form/samples/assignment-to-global/_config.js index c619f9549db..df48d86d200 100644 --- a/test/form/samples/assignment-to-global/_config.js +++ b/test/form/samples/assignment-to-global/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'Assignments to global variables should be effects (#1587)' -}; +}); diff --git a/test/form/samples/async-function-effects/_config.js b/test/form/samples/async-function-effects/_config.js new file mode 100644 index 00000000000..ce3f3de1bb2 --- /dev/null +++ b/test/form/samples/async-function-effects/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'tracks effects when awaiting thenables' +}); diff --git a/test/form/samples/async-function-effects/_expected.js b/test/form/samples/async-function-effects/_expected.js new file mode 100644 index 00000000000..5950c36e857 --- /dev/null +++ b/test/form/samples/async-function-effects/_expected.js @@ -0,0 +1,110 @@ +(async function () { + return { + then() { + console.log(1); + } + }; +})(); + +(async function () { + return { + get then() { + console.log(2); + return () => {}; + } + }; +})(); + +(async function () { + return { + get then() { + return () => console.log(3); + } + }; +})(); + +(async () => ({ + then() { + console.log(4); + } +}))(); + +(async () => ({ + get then() { + console.log(5); + return () => {}; + } +}))(); + +(async () => ({ + get then() { + return () => console.log(6); + } +}))(); + +(async function () { + await { + then: function () { + console.log(7); + } + }; + return { then() {} }; +})(); + +(async function () { + await { + get then() { + console.log(8); + return () => {}; + } + }; + return { then() {} }; +})(); + +(async function () { + await { + get then() { + return () => console.log(9); + } + }; + return { then() {} }; +})(); + +(async function () { + await await { + then(resolve) { + resolve({ + then() { + console.log(10); + } + }); + } + }; + return { then() {} }; +})(); + +async function asyncIdentity(x) { + return x; +} + +asyncIdentity({}); // no side effects - may be dropped + +const promise = asyncIdentity(11); + +promise.then(x => console.log(x)); + +asyncIdentity({ + then(success, fail) { + success(console.log(12)); + } +}); + +asyncIdentity({ + then(resolve) { + resolve({ + then() { + console.log(13); + } + }); + } +}); diff --git a/test/form/samples/async-function-effects/main.js b/test/form/samples/async-function-effects/main.js new file mode 100644 index 00000000000..c870d8d364f --- /dev/null +++ b/test/form/samples/async-function-effects/main.js @@ -0,0 +1,136 @@ +(async function () { + return { + then() { + console.log(1); + } + }; +})(); + +// removed +(async function () { + return { then() {} }; +})(); + +(async function () { + return { + get then() { + console.log(2); + return () => {}; + } + }; +})(); + +(async function () { + return { + get then() { + return () => console.log(3); + } + }; +})(); + +// removed +(async function () { + return { + get then() { + return () => {}; + } + }; +})(); + +(async () => ({ + then() { + console.log(4); + } +}))(); + +// removed +(async () => ({ + then() {} +}))(); + +(async () => ({ + get then() { + console.log(5); + return () => {}; + } +}))(); + +(async () => ({ + get then() { + return () => console.log(6); + } +}))(); + +// removed +(async () => ({ + get then() { + return () => {}; + } +}))(); + +(async function () { + await { + then: function () { + console.log(7); + } + }; + return { then() {} }; +})(); + +(async function () { + await { + get then() { + console.log(8); + return () => {}; + } + }; + return { then() {} }; +})(); + +(async function () { + await { + get then() { + return () => console.log(9); + } + }; + return { then() {} }; +})(); + +(async function () { + await await { + then(resolve) { + resolve({ + then() { + console.log(10); + } + }); + } + }; + return { then() {} }; +})(); + +async function asyncIdentity(x) { + return x; +} + +asyncIdentity({}); // no side effects - may be dropped + +const promise = asyncIdentity(11); + +promise.then(x => console.log(x)); + +asyncIdentity({ + then(success, fail) { + success(console.log(12)); + } +}); + +asyncIdentity({ + then(resolve) { + resolve({ + then() { + console.log(13); + } + }); + } +}); diff --git a/test/form/samples/async-function-unused/_config.js b/test/form/samples/async-function-unused/_config.js index 7a2ae9d0a21..d6ec16b8d2e 100644 --- a/test/form/samples/async-function-unused/_config.js +++ b/test/form/samples/async-function-unused/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'treeshakes async functions (#492)' -}; +}); diff --git a/test/form/samples/automatic-semicolon-insertion-var/_config.js b/test/form/samples/automatic-semicolon-insertion-var/_config.js index f27e98a2fa0..2b6f0339bfc 100644 --- a/test/form/samples/automatic-semicolon-insertion-var/_config.js +++ b/test/form/samples/automatic-semicolon-insertion-var/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'Adds trailing semicolons for modules' -}; +}); diff --git a/test/form/samples/avoid-unnecessary-conditional-deopt/_config.js b/test/form/samples/avoid-unnecessary-conditional-deopt/_config.js index 2c7ad61c32a..4d3ddb9f77f 100644 --- a/test/form/samples/avoid-unnecessary-conditional-deopt/_config.js +++ b/test/form/samples/avoid-unnecessary-conditional-deopt/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'avoids unnecessary deoptimizations of conditional expressions' -}; +}); diff --git a/test/form/samples/avoid-unnecessary-conditional-deopt/_expected.js b/test/form/samples/avoid-unnecessary-conditional-deopt/_expected.js index 92a9ac36f0f..8274a7e0e1a 100644 --- a/test/form/samples/avoid-unnecessary-conditional-deopt/_expected.js +++ b/test/form/samples/avoid-unnecessary-conditional-deopt/_expected.js @@ -2,7 +2,7 @@ console.log('not modified'); let x2 = false; modifyX2(); -const obj2 = {}; +const obj2 = { modified: false }; (x2 ? obj2 : {}).modified = true; if (obj2.modified) console.log('modified'); @@ -16,7 +16,7 @@ console.log('not modified'); let x4 = false; modifyX4(); -const obj4 = {}; +const obj4 = { modified: false }; (x4 && obj4).modified = true; if (obj4.modified) console.log('modified'); diff --git a/test/form/samples/avoid-unnecessary-conditional-deopt/main.js b/test/form/samples/avoid-unnecessary-conditional-deopt/main.js index c00050cbaf4..4c7337a5824 100644 --- a/test/form/samples/avoid-unnecessary-conditional-deopt/main.js +++ b/test/form/samples/avoid-unnecessary-conditional-deopt/main.js @@ -1,6 +1,6 @@ let x1 = false; modifyX1(); -const obj1 = {}; +const obj1 = { modified: false }; x1 ? obj1 : {}; if (obj1.modified) console.log('should not happen'); @@ -12,7 +12,7 @@ function modifyX1() { let x2 = false; modifyX2(); -const obj2 = {}; +const obj2 = { modified: false }; (x2 ? obj2 : {}).modified = true; if (obj2.modified) console.log('modified'); @@ -24,7 +24,7 @@ function modifyX2() { let x3 = false; modifyX3(); -const obj3 = {}; +const obj3 = { modified: false }; x3 && obj3; if (obj3.modified) console.log('should not happen'); @@ -36,7 +36,7 @@ function modifyX3() { let x4 = false; modifyX4(); -const obj4 = {}; +const obj4 = { modified: false }; (x4 && obj4).modified = true; if (obj4.modified) console.log('modified'); diff --git a/test/form/samples/banner-and-footer/_config.js b/test/form/samples/banner-and-footer/_config.js index ab91877aba2..157cf9fdf55 100644 --- a/test/form/samples/banner-and-footer/_config.js +++ b/test/form/samples/banner-and-footer/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'adds a banner/footer', options: { output: { @@ -7,18 +7,21 @@ module.exports = { }, plugins: [ { + name: 'first', banner: '/* first banner */', footer() { return '/* first footer */'; } }, { + name: 'second', banner() { return '/* second banner */'; }, footer: '/* second footer */' }, { + name: 'third', banner() { return Promise.resolve('/* 3rd banner */'); }, @@ -26,4 +29,4 @@ module.exports = { } ] } -}; +}); diff --git a/test/form/samples/banner-and-footer/_expected/amd.js b/test/form/samples/banner-and-footer/_expected/amd.js index 830cdd4c090..90633f3f764 100644 --- a/test/form/samples/banner-and-footer/_expected/amd.js +++ b/test/form/samples/banner-and-footer/_expected/amd.js @@ -2,11 +2,11 @@ /* first banner */ /* second banner */ /* 3rd banner */ -define(function () { 'use strict'; +define((function () { 'use strict'; console.log( 'hello world' ); -}); +})); /* this is a footer */ /* first footer */ /* second footer */ diff --git a/test/form/samples/banner-and-footer/_expected/iife.js b/test/form/samples/banner-and-footer/_expected/iife.js index 8caca79a92e..ab6bc46f79c 100644 --- a/test/form/samples/banner-and-footer/_expected/iife.js +++ b/test/form/samples/banner-and-footer/_expected/iife.js @@ -7,7 +7,7 @@ console.log( 'hello world' ); -}()); +})(); /* this is a footer */ /* first footer */ /* second footer */ diff --git a/test/form/samples/banner-and-footer/_expected/system.js b/test/form/samples/banner-and-footer/_expected/system.js index cb1cf9f798a..539452c8f92 100644 --- a/test/form/samples/banner-and-footer/_expected/system.js +++ b/test/form/samples/banner-and-footer/_expected/system.js @@ -2,16 +2,16 @@ /* first banner */ /* second banner */ /* 3rd banner */ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { console.log( 'hello world' ); - } + }) }; -}); +})); /* this is a footer */ /* first footer */ /* second footer */ diff --git a/test/form/samples/banner-and-footer/_expected/umd.js b/test/form/samples/banner-and-footer/_expected/umd.js index 050b6778ea2..9d3dac92637 100644 --- a/test/form/samples/banner-and-footer/_expected/umd.js +++ b/test/form/samples/banner-and-footer/_expected/umd.js @@ -5,11 +5,11 @@ (function (factory) { typeof define === 'function' && define.amd ? define(factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; console.log( 'hello world' ); -}))); +})); /* this is a footer */ /* first footer */ /* second footer */ diff --git a/test/form/samples/base64-deshadow/_config.js b/test/form/samples/base64-deshadow/_config.js index fec209a69a8..77f1c1e1cf9 100644 --- a/test/form/samples/base64-deshadow/_config.js +++ b/test/form/samples/base64-deshadow/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'base64 deshadowing indices' -}; +}); diff --git a/test/form/samples/big-int/_config.js b/test/form/samples/big-int/_config.js index 6386e7ec26f..256ffa6ca25 100644 --- a/test/form/samples/big-int/_config.js +++ b/test/form/samples/big-int/_config.js @@ -1,4 +1,3 @@ -module.exports = { - description: 'supports bigint via acorn plugin', - options: {} -}; +module.exports = defineTest({ + description: 'supports bigint' +}); diff --git a/test/form/samples/big-int/_expected.js b/test/form/samples/big-int/_expected.js index 88a90aaf59d..98a593c45e6 100644 --- a/test/form/samples/big-int/_expected.js +++ b/test/form/samples/big-int/_expected.js @@ -17,4 +17,4 @@ function isSafe (int) { return min<=int && int<=max; } -export default isSafe; +export { isSafe as default }; diff --git a/test/form/samples/binary-expressions/_config.js b/test/form/samples/binary-expressions/_config.js index 1c861eec011..2e2230aca35 100644 --- a/test/form/samples/binary-expressions/_config.js +++ b/test/form/samples/binary-expressions/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'handles binary expression side-effects' -}; +}); diff --git a/test/form/samples/block-comments/_config.js b/test/form/samples/block-comments/_config.js index f18362ceace..3c5a1b11616 100644 --- a/test/form/samples/block-comments/_config.js +++ b/test/form/samples/block-comments/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'block comments are printed correctly' -}; +}); diff --git a/test/form/samples/body-less-for-loops/_config.js b/test/form/samples/body-less-for-loops/_config.js index a748fa03e69..20b681adcf9 100644 --- a/test/form/samples/body-less-for-loops/_config.js +++ b/test/form/samples/body-less-for-loops/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'supports body-less for loops' -}; +}); diff --git a/test/form/samples/body-less-for-loops/_expected/es.js b/test/form/samples/body-less-for-loops/_expected.js similarity index 100% rename from test/form/samples/body-less-for-loops/_expected/es.js rename to test/form/samples/body-less-for-loops/_expected.js diff --git a/test/form/samples/body-less-for-loops/_expected/amd.js b/test/form/samples/body-less-for-loops/_expected/amd.js deleted file mode 100644 index 77757417926..00000000000 --- a/test/form/samples/body-less-for-loops/_expected/amd.js +++ /dev/null @@ -1,16 +0,0 @@ -define(function () { 'use strict'; - - for ( let i = 0; i < 10; i += 1 ) console.log( i ); - for ( const letter of array ) console.log( letter ); - for ( const index in array ) console.log( index ); - - let i; - for ( i = 0; i < 10; i += 1 ) console.log( i ); - - let letter; - for ( letter of array ) console.log( letter ); - - let index; - for ( index in array ) console.log( index ); - -}); diff --git a/test/form/samples/body-less-for-loops/_expected/cjs.js b/test/form/samples/body-less-for-loops/_expected/cjs.js deleted file mode 100644 index c230de3843d..00000000000 --- a/test/form/samples/body-less-for-loops/_expected/cjs.js +++ /dev/null @@ -1,14 +0,0 @@ -'use strict'; - -for ( let i = 0; i < 10; i += 1 ) console.log( i ); -for ( const letter of array ) console.log( letter ); -for ( const index in array ) console.log( index ); - -let i; -for ( i = 0; i < 10; i += 1 ) console.log( i ); - -let letter; -for ( letter of array ) console.log( letter ); - -let index; -for ( index in array ) console.log( index ); diff --git a/test/form/samples/body-less-for-loops/_expected/iife.js b/test/form/samples/body-less-for-loops/_expected/iife.js deleted file mode 100644 index 746d2213774..00000000000 --- a/test/form/samples/body-less-for-loops/_expected/iife.js +++ /dev/null @@ -1,17 +0,0 @@ -(function () { - 'use strict'; - - for ( let i = 0; i < 10; i += 1 ) console.log( i ); - for ( const letter of array ) console.log( letter ); - for ( const index in array ) console.log( index ); - - let i; - for ( i = 0; i < 10; i += 1 ) console.log( i ); - - let letter; - for ( letter of array ) console.log( letter ); - - let index; - for ( index in array ) console.log( index ); - -}()); diff --git a/test/form/samples/body-less-for-loops/_expected/system.js b/test/form/samples/body-less-for-loops/_expected/system.js deleted file mode 100644 index b2622e10bb0..00000000000 --- a/test/form/samples/body-less-for-loops/_expected/system.js +++ /dev/null @@ -1,21 +0,0 @@ -System.register([], function () { - 'use strict'; - return { - execute: function () { - - for ( let i = 0; i < 10; i += 1 ) console.log( i ); - for ( const letter of array ) console.log( letter ); - for ( const index in array ) console.log( index ); - - let i; - for ( i = 0; i < 10; i += 1 ) console.log( i ); - - let letter; - for ( letter of array ) console.log( letter ); - - let index; - for ( index in array ) console.log( index ); - - } - }; -}); diff --git a/test/form/samples/body-less-for-loops/_expected/umd.js b/test/form/samples/body-less-for-loops/_expected/umd.js deleted file mode 100644 index f4e40ccd807..00000000000 --- a/test/form/samples/body-less-for-loops/_expected/umd.js +++ /dev/null @@ -1,19 +0,0 @@ -(function (factory) { - typeof define === 'function' && define.amd ? define(factory) : - factory(); -}((function () { 'use strict'; - - for ( let i = 0; i < 10; i += 1 ) console.log( i ); - for ( const letter of array ) console.log( letter ); - for ( const index in array ) console.log( index ); - - let i; - for ( i = 0; i < 10; i += 1 ) console.log( i ); - - let letter; - for ( letter of array ) console.log( letter ); - - let index; - for ( index in array ) console.log( index ); - -}))); diff --git a/test/form/samples/break-control-flow/break-statement-labels-in-loops/_config.js b/test/form/samples/break-control-flow/break-statement-labels-in-loops/_config.js index 08ea0622523..ac0341f1214 100644 --- a/test/form/samples/break-control-flow/break-statement-labels-in-loops/_config.js +++ b/test/form/samples/break-control-flow/break-statement-labels-in-loops/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'handles breaking to loops inside labeled statements' -}; +}); diff --git a/test/form/samples/break-control-flow/break-statement-labels-switch/_config.js b/test/form/samples/break-control-flow/break-statement-labels-switch/_config.js index ffce5a641d6..76f7dbde3c6 100644 --- a/test/form/samples/break-control-flow/break-statement-labels-switch/_config.js +++ b/test/form/samples/break-control-flow/break-statement-labels-switch/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'supports labels when breaking control flow from a switch statement' -}; +}); diff --git a/test/form/samples/break-control-flow/break-statement-labels/_config.js b/test/form/samples/break-control-flow/break-statement-labels/_config.js index 44fe205431f..7566e972006 100644 --- a/test/form/samples/break-control-flow/break-statement-labels/_config.js +++ b/test/form/samples/break-control-flow/break-statement-labels/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'supports labels when breaking control flow' -}; +}); diff --git a/test/form/samples/break-control-flow/break-statement-labels/_expected.js b/test/form/samples/break-control-flow/break-statement-labels/_expected.js index aabe93c3509..9010f4e7a0a 100644 --- a/test/form/samples/break-control-flow/break-statement-labels/_expected.js +++ b/test/form/samples/break-control-flow/break-statement-labels/_expected.js @@ -31,6 +31,17 @@ outer: { console.log('retained'); } +outer: { + switch (globalThis.unknown) { + case 1: + (() => { + console.log('retained'); + })(); + case 2: + break outer; + } +} + function withConsequentReturn() { { inner: { diff --git a/test/form/samples/break-control-flow/break-statement-labels/main.js b/test/form/samples/break-control-flow/break-statement-labels/main.js index 688bb5cba69..53cf636e5bd 100644 --- a/test/form/samples/break-control-flow/break-statement-labels/main.js +++ b/test/form/samples/break-control-flow/break-statement-labels/main.js @@ -20,7 +20,7 @@ outer: { } outer: { - inner:/* retained comment */ { + inner: /* retained comment */ { console.log('retained'); break outer; console.log('removed'); @@ -48,6 +48,33 @@ outer: { console.log('retained'); } +outer: { + switch (globalThis.unknown) { + case 1: + (() => { + outer: console.log('retained'); + })(); + case 2: + break outer; + } +} + +// removed +outer: { + if (globalThis.unknown) { + break outer; + } else { + (() => { + inner: { + outer: { + break inner; + } + console.log('removed'); + } + })(); + } +} + function withConsequentReturn() { outer: { inner: { diff --git a/test/form/samples/break-control-flow/break-statement-loops/_config.js b/test/form/samples/break-control-flow/break-statement-loops/_config.js index dab03d4632d..d3f588fa7e7 100644 --- a/test/form/samples/break-control-flow/break-statement-loops/_config.js +++ b/test/form/samples/break-control-flow/break-statement-loops/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'breaks control flow when a break statement is encountered inside a loop' -}; +}); diff --git a/test/form/samples/break-control-flow/caught-errors/_config.js b/test/form/samples/break-control-flow/caught-errors/_config.js index 618e294de16..46e851e64fa 100644 --- a/test/form/samples/break-control-flow/caught-errors/_config.js +++ b/test/form/samples/break-control-flow/caught-errors/_config.js @@ -1,6 +1,6 @@ -module.exports = { +module.exports = defineTest({ description: 'breaks control flow when an error is thrown inside a catch block', options: { treeshake: { tryCatchDeoptimization: false } } -}; +}); diff --git a/test/form/samples/break-control-flow/hoisted-declarations/_config.js b/test/form/samples/break-control-flow/hoisted-declarations/_config.js index 6fddb43932a..c6cd817604f 100644 --- a/test/form/samples/break-control-flow/hoisted-declarations/_config.js +++ b/test/form/samples/break-control-flow/hoisted-declarations/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'includes hoisted declarations when control flow is broken' -}; +}); diff --git a/test/form/samples/break-control-flow/if-statement-breaks/_config.js b/test/form/samples/break-control-flow/if-statement-breaks/_config.js index 642237e7aa8..7324bb6a309 100644 --- a/test/form/samples/break-control-flow/if-statement-breaks/_config.js +++ b/test/form/samples/break-control-flow/if-statement-breaks/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'handles conditionally broken execution' -}; +}); diff --git a/test/form/samples/break-control-flow/if-statement-errors/_config.js b/test/form/samples/break-control-flow/if-statement-errors/_config.js index 5b83386fecd..8a2b54134e0 100644 --- a/test/form/samples/break-control-flow/if-statement-errors/_config.js +++ b/test/form/samples/break-control-flow/if-statement-errors/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'handles conditionally thrown errors' -}; +}); diff --git a/test/form/samples/break-control-flow/loop-errors/_config.js b/test/form/samples/break-control-flow/loop-errors/_config.js index bd5c24a0782..567b4e9ac85 100644 --- a/test/form/samples/break-control-flow/loop-errors/_config.js +++ b/test/form/samples/break-control-flow/loop-errors/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'does not break flow from inside loops that may not have executed' -}; +}); diff --git a/test/form/samples/break-control-flow/return-statements/_config.js b/test/form/samples/break-control-flow/return-statements/_config.js index f5f2cb40612..b7b18f5f469 100644 --- a/test/form/samples/break-control-flow/return-statements/_config.js +++ b/test/form/samples/break-control-flow/return-statements/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'breaks control flow when a return statement is encountered' -}; +}); diff --git a/test/form/samples/break-control-flow/switch-errors/_config.js b/test/form/samples/break-control-flow/switch-errors/_config.js index 441dcd44f44..23da799b6ed 100644 --- a/test/form/samples/break-control-flow/switch-errors/_config.js +++ b/test/form/samples/break-control-flow/switch-errors/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'handles errors in switch statements' -}; +}); diff --git a/test/form/samples/break-control-flow/thrown-errors/_config.js b/test/form/samples/break-control-flow/thrown-errors/_config.js index 6ce1e181f39..8f3eda10b57 100644 --- a/test/form/samples/break-control-flow/thrown-errors/_config.js +++ b/test/form/samples/break-control-flow/thrown-errors/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'breaks control flow when an error is thrown' -}; +}); diff --git a/test/form/samples/builtin-prototypes/array-expression/_config.js b/test/form/samples/builtin-prototypes/array-expression/_config.js index c18d1c7f176..5649d4c8cae 100644 --- a/test/form/samples/builtin-prototypes/array-expression/_config.js +++ b/test/form/samples/builtin-prototypes/array-expression/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'Tree-shake known array prototype functions' -}; +}); diff --git a/test/form/samples/builtin-prototypes/array-expression/_expected.js b/test/form/samples/builtin-prototypes/array-expression/_expected.js index 6d040eeda50..4fea44f0ad9 100644 --- a/test/form/samples/builtin-prototypes/array-expression/_expected.js +++ b/test/form/samples/builtin-prototypes/array-expression/_expected.js @@ -1,31 +1,88 @@ -[ 1 ].map( x => console.log( 1 ) ); -[ 1 ].map( x => x ).map( x => console.log( 1 ) ); -[ 1 ].map( x => console.log( 1 ) ).map( x => x ); -[ 1 ].map( x => x ).map( x => x ).map( x => console.log( 1 ) ); -[ 1 ].map( x => x ).map( x => console.log( 1 ) ).map( x => x ); +[1].map(x => console.log(1)); +[1].map(x => x).map(x => console.log(1)); +[1].map(x => console.log(1)).map(x => x); +[1] + .map(x => x) + .map(x => x) + .map(x => console.log(1)); +[1] + .map(x => x) + .map(x => console.log(1)) + .map(x => x); [](); -[ 1 ].every( () => console.log( 1 ) || true ); -[ 1 ].filter( () => console.log( 1 ) || true ); -[ 1 ].find( () => console.log( 1 ) || true ); -[ 1 ].findIndex( () => console.log( 1 ) || true ); -[ 1 ].forEach( () => console.log( 1 ) || true ); -[ 1 ].map( () => console.log( 1 ) || 1 ); -[ 1 ].reduce( () => console.log( 1 ) || 1, 1 ); -[ 1 ].reduceRight( () => console.log( 1 ) || 1, 1 ); -[ 1 ].some( () => console.log( 1 ) || true ); +const _atArray = [{ effect() {} }]; +_atArray.at(0).effect = () => console.log(1); +_atArray[0].effect(); +const _entriesArray = [{ effect() {} }]; +[..._entriesArray.entries()][0][1].effect = () => console.log(1); +_entriesArray[0].effect(); +const _sliceArray = [{ effect() {} }]; +_sliceArray.slice()[0].effect = () => console.log(1); +_sliceArray[0].effect(); +const _valuesArray = [{ effect() {} }]; +[..._valuesArray.values()][0].effect = () => console.log(1); +_valuesArray[0].effect(); +[1].every(() => console.log(1) || true); +const _everyArray = [{ effect() {} }]; +_everyArray.every(element => (element.effect = () => console.log(1))); +_everyArray[0].effect(); +[1].filter(() => console.log(1) || true); +const _filterArray = [{ effect() {} }]; +_filterArray.filter(element => (element.effect = () => console.log(1))); +_filterArray[0].effect(); +[1].find(() => console.log(1) || true); +const _findArray = [{ effect() {} }]; +_findArray.find(element => (element.effect = () => console.log(1))); +_findArray[0].effect(); +[1].findLast(() => console.log(1) || true); +const _findLastArray = [{ effect() {} }]; +_findLastArray.findLast(element => (element.effect = () => console.log(1))); +_findLastArray[0].effect(); +[1].findIndex(() => console.log(1) || true); +const _findIndexArray = [{ effect() {} }]; +_findIndexArray.findIndex(element => (element.effect = () => console.log(1))); +_findIndexArray[0].effect(); +[1].findLastIndex(() => console.log(1) || true); +const _findLastIndexArray = [{ effect() {} }]; +_findLastIndexArray.findLastIndex(element => (element.effect = () => console.log(1))); +_findLastIndexArray[0].effect(); +[1].flatMap(() => console.log(1) || 1); +const _flatMapArray = [{ effect() {} }]; +_flatMapArray.flatMap(element => (element.effect = () => console.log(1))); +_flatMapArray[0].effect(); +[1].forEach(() => console.log(1) || true); +const _forEachArray = [{ effect() {} }]; +_forEachArray.forEach(element => (element.effect = () => console.log(1))); +_forEachArray[0].effect(); +[1].map(() => console.log(1) || 1); +const _mapArray = [{ effect() {} }]; +_mapArray.map(element => (element.effect = () => console.log(1))); +_mapArray[0].effect(); +[1].reduce(() => console.log(1) || 1, 1); +const _reduceArray = [{ effect() {} }]; +_reduceArray.reduce((_, element) => (element.effect = () => console.log(1)), 1); +_reduceArray[0].effect(); +[1].reduceRight(() => console.log(1) || 1, 1); +const _reduceRightArray = [{ effect() {} }]; +_reduceRightArray.reduceRight((_, element) => (element.effect = () => console.log(1)), 1); +_reduceRightArray[0].effect(); +[1].some(() => console.log(1) || true); +const _someArray = [{ effect() {} }]; +_someArray.some(element => (element.effect = () => console.log(1))); +_someArray[0].effect(); // mutator methods -const exported = [ 1 ]; -exported.copyWithin( 0 ); -exported.fill( 0 ); +const exported = [1]; +exported.copyWithin(0); +exported.fill(0); exported.pop(); -exported.push( 0 ); +exported.push(0); exported.reverse(); exported.shift(); -[ 1 ].sort( () => console.log( 1 ) || 0 ); +[1].sort(() => console.log(1) || 0); exported.sort(); -exported.splice( 0 ); -exported.unshift( 0 ); +exported.splice(0); +exported.unshift(0); export { exported }; diff --git a/test/form/samples/builtin-prototypes/array-expression/main.js b/test/form/samples/builtin-prototypes/array-expression/main.js index a04bdfa57e3..3cf1b47ca43 100644 --- a/test/form/samples/builtin-prototypes/array-expression/main.js +++ b/test/form/samples/builtin-prototypes/array-expression/main.js @@ -1,73 +1,161 @@ const array = []; -const join1 = array.join( ',' ); -const join2 = [].join( ',' ); -const join3 = [].join( ',' ).trim(); +const join1 = array.join(','); +const join2 = [].join(','); +const join3 = [].join(',').trim(); const length = [].length; -const map1 = [ 1 ].map( x => x ); -const map2 = [ 1 ].map( x => console.log( 1 ) ); -const map3 = [ 1 ].map( x => x ).map( x => x ); -const map4 = [ 1 ].map( x => x ).map( x => console.log( 1 ) ); -const map5 = [ 1 ].map( x => console.log( 1 ) ).map( x => x ); -const map6 = [ 1 ].map( x => x ).map( x => x ).map( x => x ); -const map7 = [ 1 ].map( x => x ).map( x => x ).map( x => console.log( 1 ) ); -const map8 = [ 1 ].map( x => x ).map( x => console.log( 1 ) ).map( x => x ); +const map1 = [1].map(x => x); +const map2 = [1].map(x => console.log(1)); +const map3 = [1].map(x => x).map(x => x); +const map4 = [1].map(x => x).map(x => console.log(1)); +const map5 = [1].map(x => console.log(1)).map(x => x); +const map6 = [1] + .map(x => x) + .map(x => x) + .map(x => x); +const map7 = [1] + .map(x => x) + .map(x => x) + .map(x => console.log(1)); +const map8 = [1] + .map(x => x) + .map(x => console.log(1)) + .map(x => x); [](); // accessor methods -const _includes = [].includes( 1 ).valueOf(); -const _indexOf = [].indexOf( 1 ).toPrecision( 1 ); -const _join = [].join( ',' ).trim(); -const _lastIndexOf = [].lastIndexOf( 1 ).toPrecision( 1 ); -const _slice = [].slice( 1 ).concat( [] ); +const removedTestArray = [{ noEffect() {} }]; +removedTestArray[0].noEffect(); + +const _at = [].at(1); +const _atArray = [{ effect() {} }]; +_atArray.at(0).effect = () => console.log(1); +_atArray[0].effect(); + +const _entries = [].entries(); +const _entriesArray = [{ effect() {} }]; +[..._entriesArray.entries()][0][1].effect = () => console.log(1); +_entriesArray[0].effect(); + +const _flat = [].flat().join(',').trim(); +const _flat2 = [].flat(1).join(',').trim(); +const _includes = [].includes(1).valueOf(); +const _indexOf = [].indexOf(1).toPrecision(1); +const _join = [].join(',').trim(); +const _keys = [].keys(); +const _lastIndexOf = [].lastIndexOf(1).toPrecision(1); + +const _slice = [].slice(1).concat([]); +const _sliceArray = [{ effect() {} }]; +_sliceArray.slice()[0].effect = () => console.log(1); +_sliceArray[0].effect(); + +const _values = [].values(); +const _valuesArray = [{ effect() {} }]; +[..._valuesArray.values()][0].effect = () => console.log(1); +_valuesArray[0].effect(); // iteration methods -const _every = [ 1 ].every( () => true ).valueOf(); -const _everyEffect = [ 1 ].every( () => console.log( 1 ) || true ); -const _filter = [ 1 ].filter( () => true ).join( ',' ); -const _filterEffect = [ 1 ].filter( () => console.log( 1 ) || true ); -const _find = [ 1 ].find( () => true ); -const _findEffect = [ 1 ].find( () => console.log( 1 ) || true ); -const _findIndex = [ 1 ].findIndex( () => true ).toPrecision( 1 ); -const _findIndexEffect = [ 1 ].findIndex( () => console.log( 1 ) || true ); -const _forEach = [ 1 ].forEach( () => {} ); -const _forEachEffect = [ 1 ].forEach( () => console.log( 1 ) || true ); -const _map = [ 1 ].map( () => 1 ).join( ',' ); -const _mapEffect = [ 1 ].map( () => console.log( 1 ) || 1 ); -const _reduce = [ 1 ].reduce( () => 1, 1 ); -const _reduceEffect = [ 1 ].reduce( () => console.log( 1 ) || 1, 1 ); -const _reduceRight = [ 1 ].reduceRight( () => 1, 1 ); -const _reduceRightEffect = [ 1 ].reduceRight( () => console.log( 1 ) || 1, 1 ); -const _some = [ 1 ].some( () => true ).valueOf(); -const _someEffect = [ 1 ].some( () => console.log( 1 ) || true ); +const _every = [1].every(() => true).valueOf(); +const _everyEffect = [1].every(() => console.log(1) || true); +const _everyArray = [{ effect() {} }]; +_everyArray.every(element => (element.effect = () => console.log(1))); +_everyArray[0].effect(); + +const _filter = [1].filter(() => true).join(','); +const _filterEffect = [1].filter(() => console.log(1) || true); +const _filterArray = [{ effect() {} }]; +_filterArray.filter(element => (element.effect = () => console.log(1))); +_filterArray[0].effect(); + +const _find = [1].find(() => true); +const _findEffect = [1].find(() => console.log(1) || true); +const _findArray = [{ effect() {} }]; +_findArray.find(element => (element.effect = () => console.log(1))); +_findArray[0].effect(); + +const _findLast = [1].findLast(() => true); +const _findLastEffect = [1].findLast(() => console.log(1) || true); +const _findLastArray = [{ effect() {} }]; +_findLastArray.findLast(element => (element.effect = () => console.log(1))); +_findLastArray[0].effect(); + +const _findIndex = [1].findIndex(() => true).toPrecision(1); +const _findIndexEffect = [1].findIndex(() => console.log(1) || true); +const _findIndexArray = [{ effect() {} }]; +_findIndexArray.findIndex(element => (element.effect = () => console.log(1))); +_findIndexArray[0].effect(); + +const _findLastIndex = [1].findLastIndex(() => true).toPrecision(1); +const _findLastIndexEffect = [1].findLastIndex(() => console.log(1) || true); +const _findLastIndexArray = [{ effect() {} }]; +_findLastIndexArray.findLastIndex(element => (element.effect = () => console.log(1))); +_findLastIndexArray[0].effect(); + +const _flatMap = [1].flatMap(() => 1).join(','); +const _flatMapEffect = [1].flatMap(() => console.log(1) || 1); +const _flatMapArray = [{ effect() {} }]; +_flatMapArray.flatMap(element => (element.effect = () => console.log(1))); +_flatMapArray[0].effect(); + +const _forEach = [1].forEach(() => {}); +const _forEachEffect = [1].forEach(() => console.log(1) || true); +const _forEachArray = [{ effect() {} }]; +_forEachArray.forEach(element => (element.effect = () => console.log(1))); +_forEachArray[0].effect(); + +const _map = [1].map(() => 1).join(','); +const _mapEffect = [1].map(() => console.log(1) || 1); +const _mapArray = [{ effect() {} }]; +_mapArray.map(element => (element.effect = () => console.log(1))); +_mapArray[0].effect(); + +const _reduce = [1].reduce(() => 1, 1); +const _reduceEffect = [1].reduce(() => console.log(1) || 1, 1); +const _reduceArray = [{ effect() {} }]; +_reduceArray.reduce((_, element) => (element.effect = () => console.log(1)), 1); +_reduceArray[0].effect(); + +const _reduceRight = [1].reduceRight(() => 1, 1); +const _reduceRightEffect = [1].reduceRight(() => console.log(1) || 1, 1); +const _reduceRightArray = [{ effect() {} }]; +_reduceRightArray.reduceRight((_, element) => (element.effect = () => console.log(1)), 1); +_reduceRightArray[0].effect(); + +const _some = [1].some(() => true).valueOf(); +const _someEffect = [1].some(() => console.log(1) || true); +const _someArray = [{ effect() {} }]; +_someArray.some(element => (element.effect = () => console.log(1))); +_someArray[0].effect(); // mutator methods -export const exported = [ 1 ]; +export const exported = [1]; -const _copyWithin = [ 1 ].copyWithin( 0 ).join( ',' ); -exported.copyWithin( 0 ); -const _fill = [ 1 ].fill( 0 ).join( ',' ); -exported.fill( 0 ); -const _pop = [ 1 ].pop(); +const _copyWithin = [1].copyWithin(0).join(','); +exported.copyWithin(0); +const _fill = [1].fill(0).join(','); +exported.fill(0); +const _pop = [1].pop(); exported.pop(); -const _push = [ 1 ].push( 0 ).toPrecision( 1 ); -exported.push( 0 ); -const _reverse = [ 1 ].reverse().join( ',' ); +const _push = [1].push(0).toPrecision(1); +exported.push(0); +const _reverse = [1].reverse().join(','); exported.reverse(); -const _shift = [ 1 ].shift(); +const _shift = [1].shift(); exported.shift(); -const _sort = [ 1 ].sort( () => 0 ).join( ',' ); -const _sortEffect = [ 1 ].sort( () => console.log( 1 ) || 0 ); +const _sort = [1].sort(() => 0).join(','); +const _sortEffect = [1].sort(() => console.log(1) || 0); exported.sort(); -const _splice = [ 1 ].splice( 0 ).join( ',' ); -exported.splice( 0 ); -const _unshift = [ 1 ].unshift( 0 ).toPrecision( 1 ); -exported.unshift( 0 ); +const _splice = [1].splice(0).join(','); +exported.splice(0); +const _unshift = [1].unshift(0).toPrecision(1); +exported.unshift(0); + +const _toLocaleString = [1].toLocaleString().trim(); +const _toString = [1].toString().trim(); // inherited -const _hasOwnProperty = [ 1 ].hasOwnProperty( 'toString' ).valueOf(); -const _isPrototypeOf = [ 1 ].isPrototypeOf( [] ).valueOf(); -const _propertyIsEnumerable = [ 1 ].propertyIsEnumerable( 'toString' ).valueOf(); -const _toLocaleString = [ 1 ].toLocaleString().trim(); -const _toString = [ 1 ].toString().trim(); -const _valueOf = [ 1 ].valueOf(); +const _hasOwnProperty = [1].hasOwnProperty('toString').valueOf(); +const _isPrototypeOf = [1].isPrototypeOf([]).valueOf(); +const _propertyIsEnumerable = [1].propertyIsEnumerable('toString').valueOf(); +const _valueOf = [1].valueOf(); diff --git a/test/form/samples/builtin-prototypes/check-tree-shake-on-regexp-if-it-is-used/_config.js b/test/form/samples/builtin-prototypes/check-tree-shake-on-regexp-if-it-is-used/_config.js new file mode 100644 index 00000000000..98135a3c698 --- /dev/null +++ b/test/form/samples/builtin-prototypes/check-tree-shake-on-regexp-if-it-is-used/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'check tree-shake on RegExp if it is used' +}); diff --git a/test/form/samples/builtin-prototypes/check-tree-shake-on-regexp-if-it-is-used/_expected.js b/test/form/samples/builtin-prototypes/check-tree-shake-on-regexp-if-it-is-used/_expected.js new file mode 100644 index 00000000000..72a94a069d1 --- /dev/null +++ b/test/form/samples/builtin-prototypes/check-tree-shake-on-regexp-if-it-is-used/_expected.js @@ -0,0 +1,23 @@ +const commonRegexp_1 = /1/; +const commonRegexp_2 = /1/; + +assert.strictEqual(commonRegexp_1.test('1'), true); +assert.ok(commonRegexp_2.exec('1')); + +const globalRegexp_1 = /1/g; +const globalRegexp_2 = /1/g; + +globalRegexp_1.test('1'); +globalRegexp_2.exec('1'); + +assert.strictEqual(globalRegexp_1.test('1'), null); +assert.strictEqual(globalRegexp_2.exec('1'), null); + +const stickyRegexp_1 = /1/y; +const stickyRegexp_2 = /1/y; + +stickyRegexp_1.test('1'); +stickyRegexp_2.exec('1'); + +assert.strictEqual(stickyRegexp_1.test('1'), null); +assert.strictEqual(stickyRegexp_2.exec('1'), null); diff --git a/test/form/samples/builtin-prototypes/check-tree-shake-on-regexp-if-it-is-used/main.js b/test/form/samples/builtin-prototypes/check-tree-shake-on-regexp-if-it-is-used/main.js new file mode 100644 index 00000000000..4124af7072d --- /dev/null +++ b/test/form/samples/builtin-prototypes/check-tree-shake-on-regexp-if-it-is-used/main.js @@ -0,0 +1,26 @@ +const commonRegexp_1 = /1/; +const commonRegexp_2 = /1/; + +commonRegexp_1.test('1'); +commonRegexp_2.exec('1'); + +assert.strictEqual(commonRegexp_1.test('1'), true); +assert.ok(commonRegexp_2.exec('1')); + +const globalRegexp_1 = /1/g; +const globalRegexp_2 = /1/g; + +globalRegexp_1.test('1'); +globalRegexp_2.exec('1'); + +assert.strictEqual(globalRegexp_1.test('1'), null); +assert.strictEqual(globalRegexp_2.exec('1'), null); + +const stickyRegexp_1 = /1/y; +const stickyRegexp_2 = /1/y; + +stickyRegexp_1.test('1'); +stickyRegexp_2.exec('1'); + +assert.strictEqual(stickyRegexp_1.test('1'), null); +assert.strictEqual(stickyRegexp_2.exec('1'), null); diff --git a/test/form/samples/builtin-prototypes/literal/_config.js b/test/form/samples/builtin-prototypes/literal/_config.js index e137067cf34..24ca1bdb44a 100644 --- a/test/form/samples/builtin-prototypes/literal/_config.js +++ b/test/form/samples/builtin-prototypes/literal/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'Tree-shake known literal prototype functions' -}; +}); diff --git a/test/form/samples/builtin-prototypes/literal/_expected.js b/test/form/samples/builtin-prototypes/literal/_expected.js index a2c2161b645..fe60d5932c9 100644 --- a/test/form/samples/builtin-prototypes/literal/_expected.js +++ b/test/form/samples/builtin-prototypes/literal/_expected.js @@ -1,4 +1,25 @@ -'ab'.replace( 'a', () => console.log( 1 ) || 'b' ); +// retained +true.valueOf()(); +true.valueOf()[globalThis.unknown](); +true.valueOf().unknown(); +true.valueOf().unknown.unknown(); +true.valueOf().unknown.unknown().unknown; + +(1).valueOf()(); +(1).valueOf()[globalThis.unknown](); +(1).valueOf().unknown(); +(1).valueOf().unknown.unknown(); +(1).valueOf().unknown.unknown().unknown; + +'ab'.charAt(1)(); +'ab'.charAt(1)[globalThis.unknown](); +'ab'.charAt(1).unknown(); +'ab'.charAt(1).unknown.unknown(); +'ab'.charAt(1).unknown.unknown().unknown; + +null.unknown; +'ab'.replace('a', () => console.log(1) || 'b'); +'ab'.replaceAll('a', () => console.log(1) || 'b'); // deep property access is forbidden true.x.y; diff --git a/test/form/samples/builtin-prototypes/literal/main.js b/test/form/samples/builtin-prototypes/literal/main.js index edba0b1ee4f..cb99661a2ed 100644 --- a/test/form/samples/builtin-prototypes/literal/main.js +++ b/test/form/samples/builtin-prototypes/literal/main.js @@ -1,77 +1,123 @@ -const boolean = true; -const valueOf1 = boolean.valueOf(); -const valueOf2 = true.valueOf(); -const valueOf3 = true.valueOf().valueOf(); -const valueOf4 = true.valueOf().valueOf().valueOf(); +// retained +true.valueOf()(); +true.valueOf()[globalThis.unknown](); +true.valueOf().unknown(); +true.valueOf().unknown.unknown(); +true.valueOf().unknown.unknown().unknown; -const number = 1; -const toExponential1 = number.toExponential( 2 ); -const toExponential2 = (1).toExponential( 2 ); -const toExponential3 = (1).toExponential( 2 ).trim(); +(1).valueOf()(); +(1).valueOf()[globalThis.unknown](); +(1).valueOf().unknown(); +(1).valueOf().unknown.unknown(); +(1).valueOf().unknown.unknown().unknown; -const string = ' b '; -const trim1 = string.trim(); -const trim2 = ' x '.trim(); -const trim3 = ' x '.trim().trim(); -const trim4 = ' x '.trim().trim().trim(); +'ab'.charAt(1)(); +'ab'.charAt(1)[globalThis.unknown](); +'ab'.charAt(1).unknown(); +'ab'.charAt(1).unknown.unknown(); +'ab'.charAt(1).unknown.unknown().unknown; + +null.unknown; // boolean prototype +true.valueOf(); +true.valueOf().valueOf(); +true.valueOf().valueOf().valueOf(); +const _booleanToString = true.toString().trim(); const _booleanValueOf = true.valueOf().valueOf(); + // inherited -const _booleanHasOwnProperty = true.hasOwnProperty( 'toString' ).valueOf(); -const _booleanIsPrototypeOf = true.isPrototypeOf( true ).valueOf(); -const _booleanPropertyIsEnumerable = true.propertyIsEnumerable( 'toString' ).valueOf(); +const _booleanHasOwnProperty = true.hasOwnProperty('toString').valueOf(); +const _booleanIsPrototypeOf = true.isPrototypeOf(true).valueOf(); +const _booleanPropertyIsEnumerable = true.propertyIsEnumerable('toString').valueOf(); const _booleanToLocaleString = true.toLocaleString().trim(); -const _booleanToString = true.toString().trim(); // number prototype -const _toExponential = (1).toExponential( 2 ).trim(); -const _toFixed = (1).toFixed( 2 ).trim(); -const _toLocaleString = (1).toLocaleString().trim(); -const _toPrecision = (1).toPrecision( 2 ).trim(); -const _numberValueOf = (1).valueOf().toExponential( 2 ); -// inherited -const _numberHasOwnProperty = (1).hasOwnProperty( 'toString' ).valueOf(); -const _numberIsPrototypeOf = (1).isPrototypeOf( 1 ).valueOf(); -const _numberPropertyIsEnumerable = (1).propertyIsEnumerable( 'toString' ).valueOf(); +(1).valueOf(); +(1).valueOf().valueOf(); +(1).valueOf().valueOf().valueOf(); +const _numberToExponential = (1).toExponential(2).trim(); +const _numberToFixed = (1).toFixed(2).trim(); const _numberToLocaleString = (1).toLocaleString().trim(); +const _numberToPrecision = (1).toPrecision(2).trim(); const _numberToString = (1).toString().trim(); +const _numberValueOf = (1).valueOf().toExponential(2); + +// inherited +const _numberHasOwnProperty = (1).hasOwnProperty('toString').valueOf(); +const _numberIsPrototypeOf = (1).isPrototypeOf(1).valueOf(); +const _numberPropertyIsEnumerable = (1).propertyIsEnumerable('toString').valueOf(); + +// RegExp prototype +/1/.test('1'); +/1/.exec('1'); +/1/y.test('1'); +/1/y.exec('1'); +/1/g.test('1'); +/1/g.exec('1'); // string prototype -const _charAt = 'ab'.charAt( 1 ).trim(); -const _charCodeAt = 'ab'.charCodeAt( 1 ).toExponential( 2 ); -const _codePointAt = 'ab'.codePointAt( 1 ).toExponential( 2 ); -const _concat = 'ab'.concat( 'c' ).trim(); -const _includes = 'ab'.includes( 'a' ).valueOf(); -const _endsWith = 'ab'.endsWith( 'a' ).valueOf(); -const _indexOf = 'ab'.indexOf( 'a' ).toExponential( 2 ); -const _lastIndexOf = 'ab'.lastIndexOf( 'a' ).toExponential( 2 ); -const _localeCompare = 'ab'.localeCompare( 'a' ).toExponential( 2 ); -const _match = 'ab'.match( /a/ ).valueOf(); -const _normalize = 'ab'.normalize().trim(); -const _padEnd = 'ab'.padEnd( 4, 'a' ).trim(); -const _padStart = 'ab'.padStart( 4, 'a' ).trim(); -const _repeat = 'ab'.repeat( 2 ).trim(); -const _replace = 'ab'.replace( 'a', () => 'b' ).trim(); -const _replaceEffect = 'ab'.replace( 'a', () => console.log( 1 ) || 'b' ); -const _search = 'ab'.search( /a/ ).toExponential( 2 ); -const _slice = 'ab'.slice( 0, 1 ).trim(); -const _split = 'ab'.split( 'a' ).join(); -const _startsWith = 'ab'.startsWith( 'a' ).valueOf(); -const _substr = 'ab'.substr( 0, 1 ).trim(); -const _substring = 'ab'.substring( 0, 1 ).trim(); -const _toLocaleLowerCase = 'ab'.toLocaleLowerCase().trim(); -const _toLocaleUpperCase = 'ab'.toLocaleUpperCase().trim(); -const _toLowerCase = 'ab'.toLowerCase().trim(); -const _toUpperCase = 'ab'.toUpperCase().trim(); -const _trim = 'ab'.trim().trim(); +'ab'.valueOf(); +'ab'.valueOf().valueOf(); +'ab'.valueOf().valueOf().valueOf(); +const _stringAt = 'ab'.at(1); +const _stringCharAt = 'ab'.charAt(1).trim(); +const _stringCharCodeAt = 'ab'.charCodeAt(1).toExponential(2); +const _stringCodePointAt = 'ab'.codePointAt(1); +const _stringConcat = 'ab'.concat('c').trim(); +const _stringEndsWith = 'ab'.endsWith('a').valueOf(); +const _stringIncludes = 'ab'.includes('a').valueOf(); +const _stringIndexOf = 'ab'.indexOf('a').toExponential(2); +const _stringLastIndexOf = 'ab'.lastIndexOf('a').toExponential(2); +const _stringLocaleCompare = 'ab'.localeCompare('a').toExponential(2); +const _stringMatch = 'ab'.match(/a/); +const _stringMatchAll = 'ab'.matchAll(/a/); +const _stringNormalize = 'ab'.normalize().trim(); +const _stringPadEnd = 'ab'.padEnd(4, 'a').trim(); +const _stringPadStart = 'ab'.padStart(4, 'a').trim(); +const _stringRepeat = 'ab'.repeat(2).trim(); +const _stringReplace = 'ab'.replace('a', () => 'b').trim(); +const _stringReplaceEffect = 'ab'.replace('a', () => console.log(1) || 'b'); +const _stringReplaceAll = 'ab'.replaceAll('a', () => 'b').trim(); +const _stringReplaceAllEffect = 'ab'.replaceAll('a', () => console.log(1) || 'b'); +const _stringSearch = 'ab'.search(/a/).toExponential(2); +const _stringSlice = 'ab'.slice(0, 1).trim(); +const _stringSplit = 'ab'.split('a'); +const _stringStartsWith = 'ab'.startsWith('a').valueOf(); +const _stringSubstring = 'ab'.substring(0, 1).trim(); +const _stringToLocaleLowerCase = 'ab'.toLocaleLowerCase().trim(); +const _stringToLocaleUpperCase = 'ab'.toLocaleUpperCase().trim(); +const _stringToLowerCase = 'ab'.toLowerCase().trim(); +const _stringToString = 'ab'.trim(); +const _stringToUpperCase = 'ab'.toUpperCase().trim(); +const _stringTrim = 'ab'.trim().trim(); +const _stringTrimEnd = 'ab'.trimEnd().trim(); +const _stringTrimStart = 'ab'.trimStart().trim(); const _stringValueOf = 'ab'.valueOf().trim(); + +// DEPRECATED prototype methods +const _anchor = 'ab'.anchor().trim(); +const _big = 'ab'.big().trim(); +const _blink = 'ab'.blink().trim(); +const _bold = 'ab'.bold().trim(); +const _fixed = 'ab'.fixed().trim(); +const _fontcolor = 'ab'.fontcolor().trim(); +const _fontsize = 'ab'.fontsize().trim(); +const _italics = 'ab'.italics().trim(); +const _link = 'ab'.link().trim(); +const _small = 'ab'.small().trim(); +const _strike = 'ab'.strike().trim(); +const _sub = 'ab'.sub().trim(); +const _substr = 'ab'.substr(0, 1).trim(); +const _sup = 'ab'.sup().trim(); +const _trimLeft = 'ab'.trimLeft().trim(); +const _trimRight = 'ab'.trimRight().trim(); + // inherited -const _stringHasOwnProperty = 'ab'.hasOwnProperty( 'toString' ).valueOf(); -const _stringIsPrototypeOf = 'ab'.isPrototypeOf( '' ).valueOf(); -const _stringPropertyIsEnumerable = 'ab'.propertyIsEnumerable( 'toString' ).valueOf(); +const _stringHasOwnProperty = 'ab'.hasOwnProperty('toString').valueOf(); +const _stringIsPrototypeOf = 'ab'.isPrototypeOf('').valueOf(); +const _stringPropertyIsEnumerable = 'ab'.propertyIsEnumerable('toString').valueOf(); const _stringToLocaleString = 'ab'.toLocaleString().trim(); -const _stringToString = 'ab'.toString().trim(); // property access is allowed const accessBoolean = true.x; diff --git a/test/form/samples/builtin-prototypes/object-expression/_config.js b/test/form/samples/builtin-prototypes/object-expression/_config.js index dae66a24375..8f33ba0787f 100644 --- a/test/form/samples/builtin-prototypes/object-expression/_config.js +++ b/test/form/samples/builtin-prototypes/object-expression/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'Tree-shake known object prototype functions', expectedWarnings: ['EMPTY_BUNDLE'] -}; +}); diff --git a/test/form/samples/builtin-prototypes/object-expression/_expected.js b/test/form/samples/builtin-prototypes/object-expression/_expected.js index 95b55b099ae..8b137891791 100644 --- a/test/form/samples/builtin-prototypes/object-expression/_expected.js +++ b/test/form/samples/builtin-prototypes/object-expression/_expected.js @@ -1,11 +1 @@ -const object = {}; -object.propertyIsEnumerable( 'toString' ); -({}).propertyIsEnumerable( 'toString' ); -({}).propertyIsEnumerable( 'toString' ).valueOf(); -({}).hasOwnProperty( 'toString' ).valueOf(); -({}).isPrototypeOf( {} ).valueOf(); -({}).propertyIsEnumerable( 'toString' ).valueOf(); -({}).toLocaleString().trim(); -({}).toString().trim(); -({}).valueOf(); diff --git a/test/form/samples/builtin-prototypes/side-effect-free-array-expression/_config.js b/test/form/samples/builtin-prototypes/side-effect-free-array-expression/_config.js new file mode 100644 index 00000000000..277135ac8b1 --- /dev/null +++ b/test/form/samples/builtin-prototypes/side-effect-free-array-expression/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'Tree-shakes side-effect-free array functions if only their return value is unused' +}); diff --git a/test/form/samples/builtin-prototypes/side-effect-free-array-expression/_expected.js b/test/form/samples/builtin-prototypes/side-effect-free-array-expression/_expected.js new file mode 100644 index 00000000000..7765ed08dce --- /dev/null +++ b/test/form/samples/builtin-prototypes/side-effect-free-array-expression/_expected.js @@ -0,0 +1,41 @@ +const foo1 = [1, 2, 3]; +console.log(foo1[0]); + +const foo2 = [1, 2, 3]; +console.log(foo2[0]); + +const foo3 = [1, 2, 3]; +console.log(foo3[0]); + +const foo4 = [1, 2, 3]; +console.log(foo4[0]); + +const foo5 = [1, 2, 3]; +console.log(foo5[0]); + +const foo6 = [1, 2, 3]; +console.log(foo6[0]); + +const foo7 = [1, 2, 3]; +console.log(foo7[0]); + +const foo8 = [1, 2, 3]; +console.log(foo8[0]); + +const foo9 = [1, 2, 3]; +console.log(foo9[0]); + +const foo10 = [1, 2, 3]; +console.log(foo10[0]); + +const foo11 = [1, 2, 3]; +console.log(foo11[0]); + +const foo12 = [1, 2, 3]; +console.log(foo12[0]); + +const foo13 = [1, 2, 3]; +console.log(foo13[0]); + +const foo14 = [1, 2, 3]; +console.log(foo14[0]); diff --git a/test/form/samples/builtin-prototypes/side-effect-free-array-expression/main.js b/test/form/samples/builtin-prototypes/side-effect-free-array-expression/main.js new file mode 100644 index 00000000000..c14e5d8fb87 --- /dev/null +++ b/test/form/samples/builtin-prototypes/side-effect-free-array-expression/main.js @@ -0,0 +1,55 @@ +const foo1 = [1, 2, 3]; +foo1.at(0); +console.log(foo1[0]); + +const foo2 = [1, 2, 3]; +foo2.concat([0]); +console.log(foo2[0]); + +const foo3 = [1, 2, 3]; +foo3.entries(); +console.log(foo3[0]); + +const foo4 = [1, 2, 3]; +foo4.every(v => v); +console.log(foo4[0]); + +const foo5 = [1, 2, 3]; +foo5.filter(v => v % 1 === 0); +console.log(foo5[0]); + +const foo6 = [1, 2, 3]; +foo6.find(v => v); +console.log(foo6[0]); + +const foo7 = [1, 2, 3]; +foo7.findIndex(v => v); +console.log(foo7[0]); + +const foo8 = [1, 2, 3]; +foo8.forEach(() => {}); +console.log(foo8[0]); + +const foo9 = [1, 2, 3]; +foo9.map(v => v); +console.log(foo9[0]); + +const foo10 = [1, 2, 3]; +foo10.reduce((a, v) => a + v, 0); +console.log(foo10[0]); + +const foo11 = [1, 2, 3]; +foo11.reduceRight((a, v) => a + v, 0); +console.log(foo11[0]); + +const foo12 = [1, 2, 3]; +foo12.slice(1); +console.log(foo12[0]); + +const foo13 = [1, 2, 3]; +foo13.some(v => v); +console.log(foo13[0]); + +const foo14 = [1, 2, 3]; +foo14.values(); +console.log(foo14[0]); diff --git a/test/form/samples/builtin-prototypes/template-literal/_config.js b/test/form/samples/builtin-prototypes/template-literal/_config.js new file mode 100644 index 00000000000..297cb8bb116 --- /dev/null +++ b/test/form/samples/builtin-prototypes/template-literal/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'Tree-shake known string template literal prototype functions' +}); diff --git a/test/form/samples/builtin-prototypes/template-literal/_expected.js b/test/form/samples/builtin-prototypes/template-literal/_expected.js new file mode 100644 index 00000000000..fecddc5bb9b --- /dev/null +++ b/test/form/samples/builtin-prototypes/template-literal/_expected.js @@ -0,0 +1,13 @@ +// retained +`ab`(); +`ab`.unknown.unknown(); +`ab`.unknown.unknown().unknown; + +// deep property access is forbidden +`ab`.x.y; + +// due to strict mode, extension is forbidden +`ab`.x = 1; + +// throws when called +`ab`(); diff --git a/test/form/samples/builtin-prototypes/template-literal/main.js b/test/form/samples/builtin-prototypes/template-literal/main.js new file mode 100644 index 00000000000..eeb37ccacb1 --- /dev/null +++ b/test/form/samples/builtin-prototypes/template-literal/main.js @@ -0,0 +1,21 @@ +// retained +`ab`(); +`ab`.unknown.unknown(); +`ab`.unknown.unknown().unknown; + +// removed +`ab`.trim(); +`ab`.trim().trim(); +`ab`.toString().trim(); + +// property access is allowed +const accessString = `ab`.x; + +// deep property access is forbidden +const deepString = `ab`.x.y; + +// due to strict mode, extension is forbidden +`ab`.x = 1; + +// throws when called +`ab`(); diff --git a/test/form/samples/catch-parameter-shadowing/_config.js b/test/form/samples/catch-parameter-shadowing/_config.js index 9de0f865dcd..8a5be57bcbf 100644 --- a/test/form/samples/catch-parameter-shadowing/_config.js +++ b/test/form/samples/catch-parameter-shadowing/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'the parameter of a catch block should correctly shadow an import (#1391)', options: { output: { name: 'bundle' } } -}; +}); diff --git a/test/form/samples/catch-scope-default/_config.js b/test/form/samples/catch-scope-default/_config.js new file mode 100644 index 00000000000..7e8ac2a80a8 --- /dev/null +++ b/test/form/samples/catch-scope-default/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'associates default values in catch parameters with the outer scope' +}); diff --git a/test/form/samples/catch-scope-default/_expected.js b/test/form/samples/catch-scope-default/_expected.js new file mode 100644 index 00000000000..51686868fd8 --- /dev/null +++ b/test/form/samples/catch-scope-default/_expected.js @@ -0,0 +1,6 @@ +var value = 'PASS'; +try { + throw new Error(); +} catch ({ code = value }) { + assert.equal(code, 'PASS'); +} diff --git a/test/form/samples/catch-scope-default/main.js b/test/form/samples/catch-scope-default/main.js new file mode 100644 index 00000000000..c18cf8a4709 --- /dev/null +++ b/test/form/samples/catch-scope-default/main.js @@ -0,0 +1,7 @@ +var value = 'PASS'; +try { + throw new Error(); +} catch ({ code = value }) { + const value = 'FAIL'; + assert.equal(code, 'PASS'); +} diff --git a/test/form/samples/chained-assignments/_config.js b/test/form/samples/chained-assignments/_config.js index ddbf4e78e64..3711528c63b 100644 --- a/test/form/samples/chained-assignments/_config.js +++ b/test/form/samples/chained-assignments/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'treeshakes chained assignments' -}; +}); diff --git a/test/form/samples/circular-member-expression/_config.js b/test/form/samples/circular-member-expression/_config.js index 119556fc1d2..4041b64baa4 100644 --- a/test/form/samples/circular-member-expression/_config.js +++ b/test/form/samples/circular-member-expression/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'circular member expression' -}; +}); diff --git a/test/form/samples/circular-member-expression/_expected/amd.js b/test/form/samples/circular-member-expression/_expected/amd.js index 7a4989aaa48..cdc4dd63d00 100644 --- a/test/form/samples/circular-member-expression/_expected/amd.js +++ b/test/form/samples/circular-member-expression/_expected/amd.js @@ -1,4 +1,4 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; var foo = function() { foo.toString = null; @@ -6,4 +6,4 @@ define(function () { 'use strict'; console.log(foo); -}); +})); diff --git a/test/form/samples/circular-member-expression/_expected/iife.js b/test/form/samples/circular-member-expression/_expected/iife.js index 2ff6077515c..2abdb179884 100644 --- a/test/form/samples/circular-member-expression/_expected/iife.js +++ b/test/form/samples/circular-member-expression/_expected/iife.js @@ -7,4 +7,4 @@ console.log(foo); -}()); +})(); diff --git a/test/form/samples/circular-member-expression/_expected/system.js b/test/form/samples/circular-member-expression/_expected/system.js index a43460aeaf0..409bb3dc983 100644 --- a/test/form/samples/circular-member-expression/_expected/system.js +++ b/test/form/samples/circular-member-expression/_expected/system.js @@ -1,7 +1,7 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { var foo = function() { foo.toString = null; @@ -9,6 +9,6 @@ System.register([], function () { console.log(foo); - } + }) }; -}); +})); diff --git a/test/form/samples/circular-member-expression/_expected/umd.js b/test/form/samples/circular-member-expression/_expected/umd.js index 9c18b844987..e9dd7ef9de0 100644 --- a/test/form/samples/circular-member-expression/_expected/umd.js +++ b/test/form/samples/circular-member-expression/_expected/umd.js @@ -1,7 +1,7 @@ (function (factory) { typeof define === 'function' && define.amd ? define(factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; var foo = function() { foo.toString = null; @@ -9,4 +9,4 @@ console.log(foo); -}))); +})); diff --git a/test/form/samples/cjs-transpiler-re-exports-1/_config.js b/test/form/samples/cjs-transpiler-re-exports-1/_config.js new file mode 100644 index 00000000000..1a7136b790b --- /dev/null +++ b/test/form/samples/cjs-transpiler-re-exports-1/_config.js @@ -0,0 +1,50 @@ +const { execSync } = require('node:child_process'); + +module.exports = defineTest({ + description: + 'Disable reexporting the __proto__ from the external module if both output.externalLiveBindings and output.reExportProtoFromExternal are false', + formats: ['cjs'], + options: { + output: { + externalLiveBindings: false, + reexportProtoFromExternal: false + }, + plugins: [ + { + resolveId(id) { + if (id.endsWith('main.js')) { + return { id }; + } + return { + id, + external: true + }; + }, + buildEnd() { + this.emitFile({ + type: 'prebuilt-chunk', + fileName: 'foo.js', + code: + 'exports.foo = 1;\n' + + 'Object.defineProperty(exports, "__proto__", {\n' + + ' enumerable: true,\n' + + ' value: 2\n' + + '});' + }); + this.emitFile({ + type: 'prebuilt-chunk', + fileName: 'execute.mjs', + code: + 'import assert from "node:assert";\n' + + 'import { foo, __proto__ } from "./cjs.js";\n' + + 'assert.strictEqual(foo, 1);\n' + + 'assert.strictEqual(__proto__, undefined);' + }); + } + } + ] + }, + after() { + execSync('node _actual/execute.mjs', { cwd: __dirname }); + } +}); diff --git a/test/form/samples/cjs-transpiler-re-exports-1/_expected/cjs.js b/test/form/samples/cjs-transpiler-re-exports-1/_expected/cjs.js new file mode 100644 index 00000000000..693e6066484 --- /dev/null +++ b/test/form/samples/cjs-transpiler-re-exports-1/_expected/cjs.js @@ -0,0 +1,9 @@ +'use strict'; + +var foo_js = require('./foo.js'); + + + +Object.keys(foo_js).forEach(function (k) { + if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) exports[k] = foo_js[k]; +}); diff --git a/test/form/samples/cjs-transpiler-re-exports-1/_expected/execute.mjs b/test/form/samples/cjs-transpiler-re-exports-1/_expected/execute.mjs new file mode 100644 index 00000000000..15b9a0c4f86 --- /dev/null +++ b/test/form/samples/cjs-transpiler-re-exports-1/_expected/execute.mjs @@ -0,0 +1,4 @@ +import assert from "node:assert"; +import { foo, __proto__ } from "./cjs.js"; +assert.strictEqual(foo, 1); +assert.strictEqual(__proto__, undefined); \ No newline at end of file diff --git a/test/form/samples/cjs-transpiler-re-exports-1/_expected/foo.js b/test/form/samples/cjs-transpiler-re-exports-1/_expected/foo.js new file mode 100644 index 00000000000..a34e9e489b4 --- /dev/null +++ b/test/form/samples/cjs-transpiler-re-exports-1/_expected/foo.js @@ -0,0 +1,5 @@ +exports.foo = 1; +Object.defineProperty(exports, "__proto__", { + enumerable: true, + value: 2 +}); \ No newline at end of file diff --git a/test/form/samples/cjs-transpiler-re-exports-1/main.js b/test/form/samples/cjs-transpiler-re-exports-1/main.js new file mode 100644 index 00000000000..7b7aceca583 --- /dev/null +++ b/test/form/samples/cjs-transpiler-re-exports-1/main.js @@ -0,0 +1 @@ +export * from './foo.js'; diff --git a/test/form/samples/cjs-transpiler-re-exports/_config.js b/test/form/samples/cjs-transpiler-re-exports/_config.js new file mode 100644 index 00000000000..86e9ce8872c --- /dev/null +++ b/test/form/samples/cjs-transpiler-re-exports/_config.js @@ -0,0 +1,49 @@ +const { execSync } = require('node:child_process'); + +module.exports = defineTest({ + description: + 'Compatibility with CJS Transpiler Re-exports if output.externalLiveBindings is false', + formats: ['cjs'], + options: { + output: { + externalLiveBindings: false + }, + plugins: [ + { + resolveId(id) { + if (id.endsWith('main.js')) { + return { id }; + } + return { + id, + external: true + }; + }, + buildEnd() { + this.emitFile({ + type: 'prebuilt-chunk', + fileName: 'foo.js', + code: + 'exports.foo = 1;\n' + + 'Object.defineProperty(exports, "__proto__", {\n' + + ' enumerable: true,\n' + + ' value: 2\n' + + '});' + }); + this.emitFile({ + type: 'prebuilt-chunk', + fileName: 'execute.mjs', + code: + 'import assert from "node:assert";\n' + + 'import { foo, __proto__ } from "./cjs.js";\n' + + 'assert.strictEqual(foo, 1);\n' + + 'assert.strictEqual(__proto__, 2);' + }); + } + } + ] + }, + after() { + execSync('node _actual/execute.mjs', { cwd: __dirname }); + } +}); diff --git a/test/form/samples/cjs-transpiler-re-exports/_expected/cjs.js b/test/form/samples/cjs-transpiler-re-exports/_expected/cjs.js new file mode 100644 index 00000000000..ba78178189a --- /dev/null +++ b/test/form/samples/cjs-transpiler-re-exports/_expected/cjs.js @@ -0,0 +1,16 @@ +'use strict'; + +var foo_js = require('./foo.js'); + + + +Object.prototype.hasOwnProperty.call(foo_js, '__proto__') && + !Object.prototype.hasOwnProperty.call(exports, '__proto__') && + Object.defineProperty(exports, '__proto__', { + enumerable: true, + value: foo_js['__proto__'] + }); + +Object.keys(foo_js).forEach(function (k) { + if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) exports[k] = foo_js[k]; +}); diff --git a/test/form/samples/cjs-transpiler-re-exports/_expected/execute.mjs b/test/form/samples/cjs-transpiler-re-exports/_expected/execute.mjs new file mode 100644 index 00000000000..fe4ca2d9dab --- /dev/null +++ b/test/form/samples/cjs-transpiler-re-exports/_expected/execute.mjs @@ -0,0 +1,4 @@ +import assert from "node:assert"; +import { foo, __proto__ } from "./cjs.js"; +assert.strictEqual(foo, 1); +assert.strictEqual(__proto__, 2); \ No newline at end of file diff --git a/test/form/samples/cjs-transpiler-re-exports/_expected/foo.js b/test/form/samples/cjs-transpiler-re-exports/_expected/foo.js new file mode 100644 index 00000000000..a34e9e489b4 --- /dev/null +++ b/test/form/samples/cjs-transpiler-re-exports/_expected/foo.js @@ -0,0 +1,5 @@ +exports.foo = 1; +Object.defineProperty(exports, "__proto__", { + enumerable: true, + value: 2 +}); \ No newline at end of file diff --git a/test/form/samples/cjs-transpiler-re-exports/main.js b/test/form/samples/cjs-transpiler-re-exports/main.js new file mode 100644 index 00000000000..7b7aceca583 --- /dev/null +++ b/test/form/samples/cjs-transpiler-re-exports/main.js @@ -0,0 +1 @@ +export * from './foo.js'; diff --git a/test/form/samples/class-constructor-side-effect/_config.js b/test/form/samples/class-constructor-side-effect/_config.js index 5c8a4a09e2c..92a7c200ed6 100644 --- a/test/form/samples/class-constructor-side-effect/_config.js +++ b/test/form/samples/class-constructor-side-effect/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'preserves side-effects in a class constructor (#1233)' -}; +}); diff --git a/test/form/samples/class-fields/_config.js b/test/form/samples/class-fields/_config.js index cacf9cc3917..ca98033f2c7 100644 --- a/test/form/samples/class-fields/_config.js +++ b/test/form/samples/class-fields/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'supports class fields' -}; +}); diff --git a/test/form/samples/class-method-access/_config.js b/test/form/samples/class-method-access/_config.js new file mode 100644 index 00000000000..c0005ee1516 --- /dev/null +++ b/test/form/samples/class-method-access/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'tracks side-effects when accessing class methods' +}); diff --git a/test/form/samples/class-method-access/_expected.js b/test/form/samples/class-method-access/_expected.js new file mode 100644 index 00000000000..6bebedb86d1 --- /dev/null +++ b/test/form/samples/class-method-access/_expected.js @@ -0,0 +1,16 @@ +console.log('retained'); + +class Used { + static method() {} + static get getter() { + return { foo: { throws: null }, throws: null }; + } +} +Used.method.doesNotExist.throws; +Used.getter.doesNotExist.throws; +Used.getter.foo.doesNotExist.throws; +Used.getter.throws(); +Used.getter.foo.throws(); + +Used.method.reassigned = 1; +Used.getter.reassigned = 2; diff --git a/test/form/samples/class-method-access/main.js b/test/form/samples/class-method-access/main.js new file mode 100644 index 00000000000..f017bee050d --- /dev/null +++ b/test/form/samples/class-method-access/main.js @@ -0,0 +1,34 @@ +class Removed { + static get isTrue() { + return true; + } +} + +if (Removed.isTrue) console.log('retained'); +else console.log('removed'); + +class Used { + static method() {} + static get getter() { + return { foo: { throws: null }, throws: null }; + } +} + +Used.method.doesNotExist; +Used.method.doesNotExist.throws; +Used.getter.doesNotExist; +Used.getter.doesNotExist.throws; +Used.getter.foo; +Used.getter.foo.doesNotExist; +Used.getter.foo.doesNotExist.throws; +Used.getter.hasOwnProperty('foo'); +Used.getter.foo.hasOwnProperty('bar'); +Used.getter.throws(); +Used.getter.foo.throws(); + +Used.method.reassigned = 1; +Used.getter.reassigned = 2; + +class ValueEffect { + static foo; +} diff --git a/test/form/samples/class-static-initialization-block/_config.js b/test/form/samples/class-static-initialization-block/_config.js new file mode 100644 index 00000000000..1a4a4fd8972 --- /dev/null +++ b/test/form/samples/class-static-initialization-block/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'supports class static initialization blocks' +}); diff --git a/test/form/samples/class-static-initialization-block/_expected.js b/test/form/samples/class-static-initialization-block/_expected.js new file mode 100644 index 00000000000..38b361a50c0 --- /dev/null +++ b/test/form/samples/class-static-initialization-block/_expected.js @@ -0,0 +1,40 @@ +class Example { + static #foo; + static foo; + + static { + this.#foo = 'static-initialization-block'; + } + + static { + this.foo = 'another-static-initialization-block'; + } + + // We can not yet remove unused class body elements + static { + } + + static {} +} + +class WithAssignment { + static foo = 'bar'; + + static someStatic() { + return 'foo'; + } + + static { + WithAssignment.foo = WithAssignment.someStatic(); + } +} + +console.log(WithAssignment.foo); + +class UnusedWithError { + static { + throw new Error('no code after this point'); + } +} + +export { Example }; diff --git a/test/form/samples/class-static-initialization-block/main.js b/test/form/samples/class-static-initialization-block/main.js new file mode 100644 index 00000000000..a929ffbbf7b --- /dev/null +++ b/test/form/samples/class-static-initialization-block/main.js @@ -0,0 +1,60 @@ +export class Example { + static #foo; + static foo; + + static { + const foo = 'tree-shaken'; + this.#foo = 'static-initialization-block'; + } + + static { + const foo = 'tree-shaken'; + this.foo = 'another-static-initialization-block'; + } + + // We can not yet remove unused class body elements + static { + const foo = 'tree-shaken'; + } + + static {} +} + +class WithAssignment { + static foo = 'bar'; + + static someStatic() { + return 'foo'; + } + + static { + WithAssignment.foo = WithAssignment.someStatic(); + } +} + +console.log(WithAssignment.foo); + +class UnusedNoEffect { + static { + const foo = 'unused'; + } +} + +class UnusedWithError { + static { + throw new Error('no code after this point'); + console.log('removed'); + } +} + +console.log(UsedAfterError); + +throw new Error('No side-effects after this point'); + +console.log('removed'); + +class UsedAfterError { + static { + console.log('removed'); + } +} diff --git a/test/form/samples/class-without-new/_config.js b/test/form/samples/class-without-new/_config.js index db77abbdd9e..ca7d246380e 100644 --- a/test/form/samples/class-without-new/_config.js +++ b/test/form/samples/class-without-new/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'instantiating a class without "new" is a side-effect' -}; +}); diff --git a/test/form/samples/comment-before-import/_config.js b/test/form/samples/comment-before-import/_config.js index 823ac6379a3..4dac0737c5f 100644 --- a/test/form/samples/comment-before-import/_config.js +++ b/test/form/samples/comment-before-import/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'preserves comments before imports' -}; +}); diff --git a/test/form/samples/comment-before-import/_expected/amd.js b/test/form/samples/comment-before-import/_expected/amd.js index 95d9a9cc3aa..29185c3388f 100644 --- a/test/form/samples/comment-before-import/_expected/amd.js +++ b/test/form/samples/comment-before-import/_expected/amd.js @@ -1,4 +1,4 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; // bar.js var bar = 21; @@ -11,4 +11,4 @@ define(function () { 'use strict'; console.log( foo ); -}); +})); diff --git a/test/form/samples/comment-before-import/_expected/iife.js b/test/form/samples/comment-before-import/_expected/iife.js index 7f209da4263..7857198ed7d 100644 --- a/test/form/samples/comment-before-import/_expected/iife.js +++ b/test/form/samples/comment-before-import/_expected/iife.js @@ -12,4 +12,4 @@ console.log( foo ); -}()); +})(); diff --git a/test/form/samples/comment-before-import/_expected/system.js b/test/form/samples/comment-before-import/_expected/system.js index b902888d194..16d8190bf2b 100644 --- a/test/form/samples/comment-before-import/_expected/system.js +++ b/test/form/samples/comment-before-import/_expected/system.js @@ -1,7 +1,7 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { // bar.js var bar = 21; @@ -14,6 +14,6 @@ System.register([], function () { console.log( foo ); - } + }) }; -}); +})); diff --git a/test/form/samples/comment-before-import/_expected/umd.js b/test/form/samples/comment-before-import/_expected/umd.js index 4e8826db707..4f6ec207d90 100644 --- a/test/form/samples/comment-before-import/_expected/umd.js +++ b/test/form/samples/comment-before-import/_expected/umd.js @@ -1,7 +1,7 @@ (function (factory) { typeof define === 'function' && define.amd ? define(factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; // bar.js var bar = 21; @@ -14,4 +14,4 @@ console.log( foo ); -}))); +})); diff --git a/test/form/samples/comment-start-inside-comment/_config.js b/test/form/samples/comment-start-inside-comment/_config.js index 29086152e27..fba7e976cad 100644 --- a/test/form/samples/comment-start-inside-comment/_config.js +++ b/test/form/samples/comment-start-inside-comment/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'properly remove coments above import statements' -}; +}); diff --git a/test/form/samples/comment-start-inside-comment/_expected/amd.js b/test/form/samples/comment-start-inside-comment/_expected/amd.js index 9d28de147d5..995c74b8488 100644 --- a/test/form/samples/comment-start-inside-comment/_expected/amd.js +++ b/test/form/samples/comment-start-inside-comment/_expected/amd.js @@ -1,8 +1,8 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; var foo = () => 'foo'; // /* console.log(foo()); -}); +})); diff --git a/test/form/samples/comment-start-inside-comment/_expected/iife.js b/test/form/samples/comment-start-inside-comment/_expected/iife.js index e1ada891f95..9be90207de0 100644 --- a/test/form/samples/comment-start-inside-comment/_expected/iife.js +++ b/test/form/samples/comment-start-inside-comment/_expected/iife.js @@ -6,4 +6,4 @@ // /* console.log(foo()); -}()); +})(); diff --git a/test/form/samples/comment-start-inside-comment/_expected/system.js b/test/form/samples/comment-start-inside-comment/_expected/system.js index a3a39ad1fac..b9b00deca94 100644 --- a/test/form/samples/comment-start-inside-comment/_expected/system.js +++ b/test/form/samples/comment-start-inside-comment/_expected/system.js @@ -1,13 +1,13 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { var foo = () => 'foo'; // /* console.log(foo()); - } + }) }; -}); +})); diff --git a/test/form/samples/comment-start-inside-comment/_expected/umd.js b/test/form/samples/comment-start-inside-comment/_expected/umd.js index 6aafad97b12..8b599e0a824 100644 --- a/test/form/samples/comment-start-inside-comment/_expected/umd.js +++ b/test/form/samples/comment-start-inside-comment/_expected/umd.js @@ -1,11 +1,11 @@ (function (factory) { typeof define === 'function' && define.amd ? define(factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; var foo = () => 'foo'; // /* console.log(foo()); -}))); +})); diff --git a/test/form/samples/compact-empty-external/_config.js b/test/form/samples/compact-empty-external/_config.js index d27624aaa2a..5ddc7cd7bf9 100644 --- a/test/form/samples/compact-empty-external/_config.js +++ b/test/form/samples/compact-empty-external/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'correctly handles empty external imports in compact mode', options: { external: ['external'], @@ -6,4 +6,4 @@ module.exports = { compact: true } } -}; +}); diff --git a/test/form/samples/compact-empty-external/_expected/amd.js b/test/form/samples/compact-empty-external/_expected/amd.js index f200316fb2f..dfbce87bb5e 100644 --- a/test/form/samples/compact-empty-external/_expected/amd.js +++ b/test/form/samples/compact-empty-external/_expected/amd.js @@ -1 +1 @@ -define(['external'],function(external){'use strict';}); \ No newline at end of file +define(['external'],(function(external){'use strict';})); \ No newline at end of file diff --git a/test/form/samples/compact-empty-external/_expected/iife.js b/test/form/samples/compact-empty-external/_expected/iife.js index 695ff0122dd..b66e081df5d 100644 --- a/test/form/samples/compact-empty-external/_expected/iife.js +++ b/test/form/samples/compact-empty-external/_expected/iife.js @@ -1 +1 @@ -(function(){'use strict';}()); \ No newline at end of file +(function(){'use strict';})(); \ No newline at end of file diff --git a/test/form/samples/compact-empty-external/_expected/system.js b/test/form/samples/compact-empty-external/_expected/system.js index a66ca35598e..6331e57a2c8 100644 --- a/test/form/samples/compact-empty-external/_expected/system.js +++ b/test/form/samples/compact-empty-external/_expected/system.js @@ -1 +1 @@ -System.register(['external'],function(){'use strict';return{setters:[function(){}],execute:function(){}}}); \ No newline at end of file +System.register(['external'],(function(){'use strict';return{setters:[null],execute:(function(){})}})); \ No newline at end of file diff --git a/test/form/samples/compact-empty-external/_expected/umd.js b/test/form/samples/compact-empty-external/_expected/umd.js index 17b8ab6b34d..42748759513 100644 --- a/test/form/samples/compact-empty-external/_expected/umd.js +++ b/test/form/samples/compact-empty-external/_expected/umd.js @@ -1 +1 @@ -(function(f){typeof define==='function'&&define.amd?define(['external'],f):f();}((function(){'use strict';}))); \ No newline at end of file +(function(f){typeof define==='function'&&define.amd?define(['external'],f):f();})((function(){'use strict';})); \ No newline at end of file diff --git a/test/form/samples/compact-multiple-imports/_config.js b/test/form/samples/compact-multiple-imports/_config.js index 83042b1631c..f3cc88b91ea 100644 --- a/test/form/samples/compact-multiple-imports/_config.js +++ b/test/form/samples/compact-multiple-imports/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'correctly handles empty external imports in compact mode', options: { external(id) { @@ -12,4 +12,4 @@ module.exports = { compact: true } } -}; +}); diff --git a/test/form/samples/compact-multiple-imports/_expected/amd.js b/test/form/samples/compact-multiple-imports/_expected/amd.js index e65d614c8d1..dbc86fed8db 100644 --- a/test/form/samples/compact-multiple-imports/_expected/amd.js +++ b/test/form/samples/compact-multiple-imports/_expected/amd.js @@ -1,2 +1,2 @@ -define(['external-1','external-2','external-3','external-4','external-5'],function(external1,external2,external3,external4,external5){'use strict';assert.equal(external3.value, '3'); -assert.equal(external4.value, '4');}); \ No newline at end of file +define(['external-1','external-2','external-3','external-4','external-5'],(function(external1,external2,external3,external4,external5){'use strict';assert.equal(external3.value, '3'); +assert.equal(external4.value, '4');})); \ No newline at end of file diff --git a/test/form/samples/compact-multiple-imports/_expected/iife.js b/test/form/samples/compact-multiple-imports/_expected/iife.js index 76e54472fc9..c640a86fd43 100644 --- a/test/form/samples/compact-multiple-imports/_expected/iife.js +++ b/test/form/samples/compact-multiple-imports/_expected/iife.js @@ -1,2 +1,2 @@ (function(external1,external2,external3,external4){'use strict';assert.equal(external3.value, '3'); -assert.equal(external4.value, '4');}(null,null,external3,external4)); \ No newline at end of file +assert.equal(external4.value, '4');})(null,null,external3,external4); \ No newline at end of file diff --git a/test/form/samples/compact-multiple-imports/_expected/system.js b/test/form/samples/compact-multiple-imports/_expected/system.js index ef4ab610952..072eb5fb969 100644 --- a/test/form/samples/compact-multiple-imports/_expected/system.js +++ b/test/form/samples/compact-multiple-imports/_expected/system.js @@ -1,2 +1,2 @@ -System.register(['external-1','external-2','external-3','external-4','external-5'],function(){'use strict';var value,value$1;return{setters:[function(){},function(){},function(module){value=module.value;},function(module){value$1=module.value;},function(){}],execute:function(){assert.equal(value, '3'); -assert.equal(value$1, '4');}}}); \ No newline at end of file +System.register(['external-1','external-2','external-3','external-4','external-5'],(function(){'use strict';var value,value$1;return{setters:[null,null,function(module){value=module.value;},function(module){value$1=module.value;},null],execute:(function(){assert.equal(value, '3'); +assert.equal(value$1, '4');})}})); \ No newline at end of file diff --git a/test/form/samples/compact-multiple-imports/_expected/umd.js b/test/form/samples/compact-multiple-imports/_expected/umd.js index 4d432d71461..94bab9a504b 100644 --- a/test/form/samples/compact-multiple-imports/_expected/umd.js +++ b/test/form/samples/compact-multiple-imports/_expected/umd.js @@ -1,2 +1,2 @@ -(function(g,f){typeof exports==='object'&&typeof module!=='undefined'?f(require('external-1'),require('external-2'),require('external-3'),require('external-4'),require('external-5')):typeof define==='function'&&define.amd?define(['external-1','external-2','external-3','external-4','external-5'],f):(g=typeof globalThis!=='undefined'?globalThis:g||self,f(null,null,g.external3,g.external4));}(this,(function(external1, external2, external3, external4){'use strict';assert.equal(external3.value, '3'); -assert.equal(external4.value, '4');}))); \ No newline at end of file +(function(g,f){typeof exports==='object'&&typeof module!=='undefined'?f(require('external-1'),require('external-2'),require('external-3'),require('external-4'),require('external-5')):typeof define==='function'&&define.amd?define(['external-1','external-2','external-3','external-4','external-5'],f):(g=typeof globalThis!=='undefined'?globalThis:g||self,f(null,null,g.external3,g.external4));})(this,(function(external1,external2,external3,external4){'use strict';assert.equal(external3.value, '3'); +assert.equal(external4.value, '4');})); \ No newline at end of file diff --git a/test/form/samples/compact-named-export/_config.js b/test/form/samples/compact-named-export/_config.js index 2b3a4cf92f8..602a6480c76 100644 --- a/test/form/samples/compact-named-export/_config.js +++ b/test/form/samples/compact-named-export/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'properly handles named export live bindings in compact mode', options: { output: { @@ -6,4 +6,4 @@ module.exports = { compact: true } } -}; +}); diff --git a/test/form/samples/compact-named-export/_expected/amd.js b/test/form/samples/compact-named-export/_expected/amd.js index 05dec91b064..5945f0f0fc5 100644 --- a/test/form/samples/compact-named-export/_expected/amd.js +++ b/test/form/samples/compact-named-export/_expected/amd.js @@ -1,5 +1,5 @@ -define(['exports'],function(exports){'use strict';exports.x = 42; +define(['exports'],(function(exports){'use strict';exports.x = 42; exports.x+=1; exports.x=exports.x+1; exports.x++; -++exports.x;Object.defineProperty(exports,'__esModule',{value:true});}); \ No newline at end of file +++exports.x;})); \ No newline at end of file diff --git a/test/form/samples/compact-named-export/_expected/cjs.js b/test/form/samples/compact-named-export/_expected/cjs.js index 28ef8bf08b2..019dacd8bed 100644 --- a/test/form/samples/compact-named-export/_expected/cjs.js +++ b/test/form/samples/compact-named-export/_expected/cjs.js @@ -1,4 +1,4 @@ -'use strict';Object.defineProperty(exports,'__esModule',{value:true});exports.x = 42; +'use strict';exports.x = 42; exports.x+=1; exports.x=exports.x+1; exports.x++; diff --git a/test/form/samples/compact-named-export/_expected/iife.js b/test/form/samples/compact-named-export/_expected/iife.js index 2cbb80b6609..6a8e9b55a6e 100644 --- a/test/form/samples/compact-named-export/_expected/iife.js +++ b/test/form/samples/compact-named-export/_expected/iife.js @@ -2,4 +2,4 @@ var foo=(function(exports){'use strict';exports.x = 42; exports.x+=1; exports.x=exports.x+1; exports.x++; -++exports.x;Object.defineProperty(exports,'__esModule',{value:true});return exports;}({})); \ No newline at end of file +++exports.x;return exports;})({}); \ No newline at end of file diff --git a/test/form/samples/compact-named-export/_expected/system.js b/test/form/samples/compact-named-export/_expected/system.js index d6d3896ceb8..49f0e1d6d36 100644 --- a/test/form/samples/compact-named-export/_expected/system.js +++ b/test/form/samples/compact-named-export/_expected/system.js @@ -1,5 +1,5 @@ -System.register('foo',[],function(exports){'use strict';return{execute:function(){let x = exports('x',42); -x=exports('x',x+1); -x=exports('x',x+1); -(exports('x',x+1),x++); -exports('x',++x);}}}); \ No newline at end of file +System.register('foo',[],(function(exports){'use strict';return{execute:(function(){let x = exports("x",42); +exports("x",x+=1); +exports("x",x=x+1); +exports("x",x+1),x++; +exports("x",++x);})}})); \ No newline at end of file diff --git a/test/form/samples/compact-named-export/_expected/umd.js b/test/form/samples/compact-named-export/_expected/umd.js index c9b3a51f728..026339711b8 100644 --- a/test/form/samples/compact-named-export/_expected/umd.js +++ b/test/form/samples/compact-named-export/_expected/umd.js @@ -1,5 +1,5 @@ -(function(g,f){typeof exports==='object'&&typeof module!=='undefined'?f(exports):typeof define==='function'&&define.amd?define(['exports'],f):(g=typeof globalThis!=='undefined'?globalThis:g||self,f(g.foo={}));}(this,(function(exports){'use strict';exports.x = 42; +(function(g,f){typeof exports==='object'&&typeof module!=='undefined'?f(exports):typeof define==='function'&&define.amd?define(['exports'],f):(g=typeof globalThis!=='undefined'?globalThis:g||self,f(g.foo={}));})(this,(function(exports){'use strict';exports.x = 42; exports.x+=1; exports.x=exports.x+1; exports.x++; -++exports.x;Object.defineProperty(exports,'__esModule',{value:true});}))); \ No newline at end of file +++exports.x;})); \ No newline at end of file diff --git a/test/form/samples/compact/_config.js b/test/form/samples/compact/_config.js index f7e8d144e33..bb9b84a67e8 100644 --- a/test/form/samples/compact/_config.js +++ b/test/form/samples/compact/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'supports compact output with compact: true', expectedWarnings: ['CIRCULAR_DEPENDENCY'], options: { @@ -6,10 +6,10 @@ module.exports = { output: { name: 'foo', compact: true, - namespaceToStringTag: true, + generatedCode: { symbols: true }, globals: { external: 'x' } } } -}; +}); diff --git a/test/form/samples/compact/_expected/amd.js b/test/form/samples/compact/_expected/amd.js index bb7bdd22551..cbe6c518856 100644 --- a/test/form/samples/compact/_expected/amd.js +++ b/test/form/samples/compact/_expected/amd.js @@ -1,6 +1,6 @@ -define(['external'],function(x){'use strict';function _interopDefaultLegacy(e){return e&&typeof e==='object'&&'default'in e?e:{'default':e}}var x__default=/*#__PURE__*/_interopDefaultLegacy(x);var self=/*#__PURE__*/Object.freeze({__proto__:null,[Symbol.toStringTag]:'Module',get default(){return foo}});console.log(self); +define(['external'],(function(x){'use strict';var self=/*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({__proto__:null,get default(){return foo}},Symbol.toStringTag,{value:'Module'}));console.log(self); function foo () { - console.log( x__default['default'] ); + console.log( x ); } // trailing comment -return foo;}); \ No newline at end of file +return foo;})); \ No newline at end of file diff --git a/test/form/samples/compact/_expected/cjs.js b/test/form/samples/compact/_expected/cjs.js index c35561735a9..546ece8a356 100644 --- a/test/form/samples/compact/_expected/cjs.js +++ b/test/form/samples/compact/_expected/cjs.js @@ -1,6 +1,6 @@ -'use strict';var x=require('external');function _interopDefaultLegacy(e){return e&&typeof e==='object'&&'default'in e?e:{'default':e}}var x__default=/*#__PURE__*/_interopDefaultLegacy(x);var self=/*#__PURE__*/Object.freeze({__proto__:null,[Symbol.toStringTag]:'Module',get default(){return foo}});console.log(self); +'use strict';var x=require('external');var self=/*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({__proto__:null,get default(){return foo}},Symbol.toStringTag,{value:'Module'}));console.log(self); function foo () { - console.log( x__default['default'] ); + console.log( x ); } // trailing comment module.exports=foo; \ No newline at end of file diff --git a/test/form/samples/compact/_expected/es.js b/test/form/samples/compact/_expected/es.js index a580d524969..13b262bc497 100644 --- a/test/form/samples/compact/_expected/es.js +++ b/test/form/samples/compact/_expected/es.js @@ -1,6 +1,6 @@ -import x from'external';var self=/*#__PURE__*/Object.freeze({__proto__:null,[Symbol.toStringTag]:'Module',get default(){return foo}});console.log(self); +import x from'external';var self=/*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({__proto__:null,get default(){return foo}},Symbol.toStringTag,{value:'Module'}));console.log(self); function foo () { console.log( x ); } // trailing comment -export default foo; \ No newline at end of file +export{foo as default}; \ No newline at end of file diff --git a/test/form/samples/compact/_expected/iife.js b/test/form/samples/compact/_expected/iife.js index 53166a61fe7..07347b86a4f 100644 --- a/test/form/samples/compact/_expected/iife.js +++ b/test/form/samples/compact/_expected/iife.js @@ -1,6 +1,6 @@ -var foo=(function(x){'use strict';function _interopDefaultLegacy(e){return e&&typeof e==='object'&&'default'in e?e:{'default':e}}var x__default=/*#__PURE__*/_interopDefaultLegacy(x);var self=/*#__PURE__*/Object.freeze({__proto__:null,[Symbol.toStringTag]:'Module',get default(){return foo}});console.log(self); +var foo=(function(x){'use strict';var self=/*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({__proto__:null,get default(){return foo}},Symbol.toStringTag,{value:'Module'}));console.log(self); function foo () { - console.log( x__default['default'] ); + console.log( x ); } // trailing comment -return foo;}(x)); \ No newline at end of file +return foo;})(x); \ No newline at end of file diff --git a/test/form/samples/compact/_expected/system.js b/test/form/samples/compact/_expected/system.js index 31cc2cf03b0..2f6491da871 100644 --- a/test/form/samples/compact/_expected/system.js +++ b/test/form/samples/compact/_expected/system.js @@ -1,6 +1,6 @@ -System.register('foo',['external'],function(exports){'use strict';var x;return{setters:[function(module){x=module.default;}],execute:function(){exports('default',foo);var self=/*#__PURE__*/Object.freeze({__proto__:null,[Symbol.toStringTag]:'Module',get default(){return foo}});console.log(self); +System.register('foo',['external'],(function(exports){'use strict';var x;return{setters:[function(module){x=module.default;}],execute:(function(){exports("default",foo);var self=/*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({__proto__:null,get default(){return foo}},Symbol.toStringTag,{value:'Module'}));console.log(self); function foo () { console.log( x ); } // trailing comment -}}}); \ No newline at end of file +})}})); \ No newline at end of file diff --git a/test/form/samples/compact/_expected/umd.js b/test/form/samples/compact/_expected/umd.js index 7eb8da259c9..8347e816cf1 100644 --- a/test/form/samples/compact/_expected/umd.js +++ b/test/form/samples/compact/_expected/umd.js @@ -1,6 +1,6 @@ -(function(g,f){typeof exports==='object'&&typeof module!=='undefined'?module.exports=f(require('external')):typeof define==='function'&&define.amd?define(['external'],f):(g=typeof globalThis!=='undefined'?globalThis:g||self,g.foo=f(g.x));}(this,(function(x){'use strict';function _interopDefaultLegacy(e){return e&&typeof e==='object'&&'default'in e?e:{'default':e}}var x__default=/*#__PURE__*/_interopDefaultLegacy(x);var self=/*#__PURE__*/Object.freeze({__proto__:null,[Symbol.toStringTag]:'Module',get default(){return foo}});console.log(self); +(function(g,f){typeof exports==='object'&&typeof module!=='undefined'?module.exports=f(require('external')):typeof define==='function'&&define.amd?define(['external'],f):(g=typeof globalThis!=='undefined'?globalThis:g||self,g.foo=f(g.x));})(this,(function(x){'use strict';var self=/*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({__proto__:null,get default(){return foo}},Symbol.toStringTag,{value:'Module'}));console.log(self); function foo () { - console.log( x__default['default'] ); + console.log( x ); } // trailing comment -return foo;}))); \ No newline at end of file +return foo;})); \ No newline at end of file diff --git a/test/form/samples/computed-member-expression-assignments/_config.js b/test/form/samples/computed-member-expression-assignments/_config.js index 28124ab2672..6ad78ce80a4 100644 --- a/test/form/samples/computed-member-expression-assignments/_config.js +++ b/test/form/samples/computed-member-expression-assignments/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'detect side-effects in assignments involving computed members' -}; +}); diff --git a/test/form/samples/computed-properties/_config.js b/test/form/samples/computed-properties/_config.js index f71657f27d2..8319b816557 100644 --- a/test/form/samples/computed-properties/_config.js +++ b/test/form/samples/computed-properties/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'computed property keys include declarations of referenced identifiers', options: { output: { name: 'computedProperties' } } -}; +}); diff --git a/test/form/samples/computed-properties/_expected/es.js b/test/form/samples/computed-properties/_expected.js similarity index 100% rename from test/form/samples/computed-properties/_expected/es.js rename to test/form/samples/computed-properties/_expected.js diff --git a/test/form/samples/computed-properties/_expected/amd.js b/test/form/samples/computed-properties/_expected/amd.js deleted file mode 100644 index b1a333f8b4e..00000000000 --- a/test/form/samples/computed-properties/_expected/amd.js +++ /dev/null @@ -1,21 +0,0 @@ -define(['exports'], function (exports) { 'use strict'; - - var foo = 'foo'; - var bar = 'bar'; - var baz = 'baz'; - var bam = 'bam'; - - var x = { [foo]: 'bar' }; - - class X { - [bar] () {} - get [baz] () {} - set [bam] ( value ) {} - } - - exports.X = X; - exports.x = x; - - Object.defineProperty(exports, '__esModule', { value: true }); - -}); diff --git a/test/form/samples/computed-properties/_expected/cjs.js b/test/form/samples/computed-properties/_expected/cjs.js deleted file mode 100644 index 25c4292652b..00000000000 --- a/test/form/samples/computed-properties/_expected/cjs.js +++ /dev/null @@ -1,19 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { value: true }); - -var foo = 'foo'; -var bar = 'bar'; -var baz = 'baz'; -var bam = 'bam'; - -var x = { [foo]: 'bar' }; - -class X { - [bar] () {} - get [baz] () {} - set [bam] ( value ) {} -} - -exports.X = X; -exports.x = x; diff --git a/test/form/samples/computed-properties/_expected/iife.js b/test/form/samples/computed-properties/_expected/iife.js deleted file mode 100644 index c6d332db696..00000000000 --- a/test/form/samples/computed-properties/_expected/iife.js +++ /dev/null @@ -1,24 +0,0 @@ -var computedProperties = (function (exports) { - 'use strict'; - - var foo = 'foo'; - var bar = 'bar'; - var baz = 'baz'; - var bam = 'bam'; - - var x = { [foo]: 'bar' }; - - class X { - [bar] () {} - get [baz] () {} - set [bam] ( value ) {} - } - - exports.X = X; - exports.x = x; - - Object.defineProperty(exports, '__esModule', { value: true }); - - return exports; - -}({})); diff --git a/test/form/samples/computed-properties/_expected/system.js b/test/form/samples/computed-properties/_expected/system.js deleted file mode 100644 index 5b417b1cac2..00000000000 --- a/test/form/samples/computed-properties/_expected/system.js +++ /dev/null @@ -1,21 +0,0 @@ -System.register('computedProperties', [], function (exports) { - 'use strict'; - return { - execute: function () { - - var foo = 'foo'; - var bar = 'bar'; - var baz = 'baz'; - var bam = 'bam'; - - var x = exports('x', { [foo]: 'bar' }); - - class X { - [bar] () {} - get [baz] () {} - set [bam] ( value ) {} - } exports('X', X); - - } - }; -}); diff --git a/test/form/samples/computed-properties/_expected/umd.js b/test/form/samples/computed-properties/_expected/umd.js deleted file mode 100644 index 2dc079505e1..00000000000 --- a/test/form/samples/computed-properties/_expected/umd.js +++ /dev/null @@ -1,25 +0,0 @@ -(function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : - typeof define === 'function' && define.amd ? define(['exports'], factory) : - (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.computedProperties = {})); -}(this, (function (exports) { 'use strict'; - - var foo = 'foo'; - var bar = 'bar'; - var baz = 'baz'; - var bam = 'bam'; - - var x = { [foo]: 'bar' }; - - class X { - [bar] () {} - get [baz] () {} - set [bam] ( value ) {} - } - - exports.X = X; - exports.x = x; - - Object.defineProperty(exports, '__esModule', { value: true }); - -}))); diff --git a/test/form/samples/conditional-expression-deopzimize-while-included/_config.js b/test/form/samples/conditional-expression-deopzimize-while-included/_config.js index 343a9689d60..aba539b2fdb 100644 --- a/test/form/samples/conditional-expression-deopzimize-while-included/_config.js +++ b/test/form/samples/conditional-expression-deopzimize-while-included/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'handles deoptimizations of logical expression while they are inlcuded (#3324)' -}; +}); diff --git a/test/form/samples/conditional-expression-paths/_config.js b/test/form/samples/conditional-expression-paths/_config.js index aadb52f877d..b712273200b 100644 --- a/test/form/samples/conditional-expression-paths/_config.js +++ b/test/form/samples/conditional-expression-paths/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'only retain branches with side-effects' -}; +}); diff --git a/test/form/samples/conditional-expression-paths/_expected.js b/test/form/samples/conditional-expression-paths/_expected.js index f78090cebcb..ae60637a8b9 100644 --- a/test/form/samples/conditional-expression-paths/_expected.js +++ b/test/form/samples/conditional-expression-paths/_expected.js @@ -1,22 +1,11 @@ var unknownValue = globalThis.unknown(); var foo = { x: () => {}, y: {} }; -var bar = { x: () => {}, y: {} }; var baz = { x: () => console.log('effect') }; -// unknown branch without side-effects -(unknownValue ? foo : bar).y.z; -(unknownValue ? foo : bar).x(); - // unknown branch with side-effect (unknownValue ? foo : baz).y.z; (unknownValue ? foo : baz).x(); -// known branch without side-effects -(foo ).y.z; -(foo).y.z; -(foo ).x(); -(foo).x(); - // known branch with side-effect (baz ).y.z; (baz).y.z; diff --git a/test/form/samples/conditional-expression-paths/main.js b/test/form/samples/conditional-expression-paths/main.js index 67d2162a495..bfafbf296c1 100644 --- a/test/form/samples/conditional-expression-paths/main.js +++ b/test/form/samples/conditional-expression-paths/main.js @@ -19,8 +19,8 @@ var d3 = (false ? baz : foo).x(); var foo2 = { y: {} }; var baz2 = {}; -(true ? foo2 : baz).y.z = 1; -(false ? baz : foo2).y.z = 1; +(true ? foo2 : baz2).y.z = 1; +(false ? baz2 : foo2).y.z = 1; // known branch with side-effect var a4 = (true ? baz : foo).y.z; diff --git a/test/form/samples/conditional-expression/_config.js b/test/form/samples/conditional-expression/_config.js index aadb52f877d..b712273200b 100644 --- a/test/form/samples/conditional-expression/_config.js +++ b/test/form/samples/conditional-expression/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'only retain branches with side-effects' -}; +}); diff --git a/test/form/samples/conditional-expression/_expected.js b/test/form/samples/conditional-expression/_expected.js index e9277e08e7a..7250914dc0c 100644 --- a/test/form/samples/conditional-expression/_expected.js +++ b/test/form/samples/conditional-expression/_expected.js @@ -10,8 +10,8 @@ unknownValue ? 1 : foo(); // known side-effect foo() ; -(function () {this.x = 1;} )(); +((function () {this.x = 1;}) )(); (() => () => console.log( 'effect' ) )()(); foo(); -(function () {this.x = 1;})(); +((function () {this.x = 1;}))(); (() => () => console.log( 'effect' ))()(); diff --git a/test/form/samples/conditional-put-parens-around-sequence/_config.js b/test/form/samples/conditional-put-parens-around-sequence/_config.js index a040c92d6de..78ba85bf809 100644 --- a/test/form/samples/conditional-put-parens-around-sequence/_config.js +++ b/test/form/samples/conditional-put-parens-around-sequence/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'put parens around sequences if conditional simplified (#1311)' -}; +}); diff --git a/test/form/samples/configure-file-url/_config.js b/test/form/samples/configure-file-url/_config.js index 10db41d3835..9be0556b22e 100644 --- a/test/form/samples/configure-file-url/_config.js +++ b/test/form/samples/configure-file-url/_config.js @@ -1,8 +1,9 @@ -module.exports = { +module.exports = defineTest({ description: 'allows to configure file urls', options: { plugins: [ { + name: 'first', resolveId(id) { if (id.endsWith('solved')) { return id; @@ -32,6 +33,7 @@ module.exports = { } }, { + name: 'second', resolveFileUrl({ moduleId }) { if (moduleId === 'resolved') { return `'resolved'`; @@ -41,4 +43,4 @@ module.exports = { } ] } -}; +}); diff --git a/test/form/samples/configure-file-url/_expected/amd.js b/test/form/samples/configure-file-url/_expected/amd.js index ecd6bd1ac2d..0089e366486 100644 --- a/test/form/samples/configure-file-url/_expected/amd.js +++ b/test/form/samples/configure-file-url/_expected/amd.js @@ -1,11 +1,11 @@ -define(['require'], function (require) { 'use strict'; +define(['require'], (function (require) { 'use strict'; - var asset1 = 'chunkId=amd.js:moduleId=solved:fileName=assets/asset-solved-28a7ac89.txt:format=amd:relativePath=assets/asset-solved-28a7ac89.txt:referenceId=6296c678'; + var asset1 = 'chunkId=amd.js:moduleId=solved:fileName=assets/asset-solved-DSjIjiFN.txt:format=amd:relativePath=assets/asset-solved-DSjIjiFN.txt:referenceId=lj6zEdlc'; var asset2 = 'resolved'; - var asset3 = new URL(require.toUrl('./assets/asset-unresolved-8dcd7fca.txt'), document.baseURI).href; + var asset3 = new URL(require.toUrl('./assets/asset-unresolved-B7Qh6_pN.txt'), document.baseURI).href; console.log(asset1, asset2, asset3); -}); +})); diff --git a/test/form/samples/configure-file-url/_expected/assets/asset-resolved-8bd22e6e.txt b/test/form/samples/configure-file-url/_expected/assets/asset-resolved-8bd22e6e.txt deleted file mode 100644 index 31fb300f988..00000000000 --- a/test/form/samples/configure-file-url/_expected/assets/asset-resolved-8bd22e6e.txt +++ /dev/null @@ -1 +0,0 @@ -Asset for: resolved \ No newline at end of file diff --git a/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/amd/assets/asset-resolved-8bd22e6e.txt b/test/form/samples/configure-file-url/_expected/assets/asset-resolved-DukuHpJ1.txt similarity index 100% rename from test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/amd/assets/asset-resolved-8bd22e6e.txt rename to test/form/samples/configure-file-url/_expected/assets/asset-resolved-DukuHpJ1.txt diff --git a/test/form/samples/configure-file-url/_expected/assets/asset-solved-28a7ac89.txt b/test/form/samples/configure-file-url/_expected/assets/asset-solved-28a7ac89.txt deleted file mode 100644 index 07c7a096c7e..00000000000 --- a/test/form/samples/configure-file-url/_expected/assets/asset-solved-28a7ac89.txt +++ /dev/null @@ -1 +0,0 @@ -Asset for: solved \ No newline at end of file diff --git a/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/amd/assets/asset-solved-28a7ac89.txt b/test/form/samples/configure-file-url/_expected/assets/asset-solved-DSjIjiFN.txt similarity index 100% rename from test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/amd/assets/asset-solved-28a7ac89.txt rename to test/form/samples/configure-file-url/_expected/assets/asset-solved-DSjIjiFN.txt diff --git a/test/form/samples/configure-file-url/_expected/assets/asset-unresolved-8dcd7fca.txt b/test/form/samples/configure-file-url/_expected/assets/asset-unresolved-8dcd7fca.txt deleted file mode 100644 index fd3ad6261cc..00000000000 --- a/test/form/samples/configure-file-url/_expected/assets/asset-unresolved-8dcd7fca.txt +++ /dev/null @@ -1 +0,0 @@ -Asset for: unresolved \ No newline at end of file diff --git a/test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/amd/assets/asset-unresolved-8dcd7fca.txt b/test/form/samples/configure-file-url/_expected/assets/asset-unresolved-B7Qh6_pN.txt similarity index 100% rename from test/chunking-form/samples/deprecated/configure-file-url-for-assets-and-chunks/_expected/amd/assets/asset-unresolved-8dcd7fca.txt rename to test/form/samples/configure-file-url/_expected/assets/asset-unresolved-B7Qh6_pN.txt diff --git a/test/form/samples/configure-file-url/_expected/cjs.js b/test/form/samples/configure-file-url/_expected/cjs.js index 3f400f8f30d..dc1ef8f2d96 100644 --- a/test/form/samples/configure-file-url/_expected/cjs.js +++ b/test/form/samples/configure-file-url/_expected/cjs.js @@ -1,9 +1,9 @@ 'use strict'; -var asset1 = 'chunkId=cjs.js:moduleId=solved:fileName=assets/asset-solved-28a7ac89.txt:format=cjs:relativePath=assets/asset-solved-28a7ac89.txt:referenceId=6296c678'; +var asset1 = 'chunkId=cjs.js:moduleId=solved:fileName=assets/asset-solved-DSjIjiFN.txt:format=cjs:relativePath=assets/asset-solved-DSjIjiFN.txt:referenceId=lj6zEdlc'; var asset2 = 'resolved'; -var asset3 = (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __dirname + '/assets/asset-unresolved-8dcd7fca.txt').href : new URL('assets/asset-unresolved-8dcd7fca.txt', document.currentScript && document.currentScript.src || document.baseURI).href); +var asset3 = (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__dirname + '/assets/asset-unresolved-B7Qh6_pN.txt').href : new URL('assets/asset-unresolved-B7Qh6_pN.txt', document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT' && document.currentScript.src || document.baseURI).href); console.log(asset1, asset2, asset3); diff --git a/test/form/samples/configure-file-url/_expected/es.js b/test/form/samples/configure-file-url/_expected/es.js index 07d1b27b495..633ef0addee 100644 --- a/test/form/samples/configure-file-url/_expected/es.js +++ b/test/form/samples/configure-file-url/_expected/es.js @@ -1,7 +1,7 @@ -var asset1 = 'chunkId=es.js:moduleId=solved:fileName=assets/asset-solved-28a7ac89.txt:format=es:relativePath=assets/asset-solved-28a7ac89.txt:referenceId=6296c678'; +var asset1 = 'chunkId=es.js:moduleId=solved:fileName=assets/asset-solved-DSjIjiFN.txt:format=es:relativePath=assets/asset-solved-DSjIjiFN.txt:referenceId=lj6zEdlc'; var asset2 = 'resolved'; -var asset3 = new URL('assets/asset-unresolved-8dcd7fca.txt', import.meta.url).href; +var asset3 = new URL('assets/asset-unresolved-B7Qh6_pN.txt', import.meta.url).href; console.log(asset1, asset2, asset3); diff --git a/test/form/samples/configure-file-url/_expected/iife.js b/test/form/samples/configure-file-url/_expected/iife.js index 0453c7222e4..a53ad90da57 100644 --- a/test/form/samples/configure-file-url/_expected/iife.js +++ b/test/form/samples/configure-file-url/_expected/iife.js @@ -1,12 +1,12 @@ (function () { 'use strict'; - var asset1 = 'chunkId=iife.js:moduleId=solved:fileName=assets/asset-solved-28a7ac89.txt:format=iife:relativePath=assets/asset-solved-28a7ac89.txt:referenceId=6296c678'; + var asset1 = 'chunkId=iife.js:moduleId=solved:fileName=assets/asset-solved-DSjIjiFN.txt:format=iife:relativePath=assets/asset-solved-DSjIjiFN.txt:referenceId=lj6zEdlc'; var asset2 = 'resolved'; - var asset3 = new URL('assets/asset-unresolved-8dcd7fca.txt', document.currentScript && document.currentScript.src || document.baseURI).href; + var asset3 = new URL('assets/asset-unresolved-B7Qh6_pN.txt', document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT' && document.currentScript.src || document.baseURI).href; console.log(asset1, asset2, asset3); -}()); +})(); diff --git a/test/form/samples/configure-file-url/_expected/system.js b/test/form/samples/configure-file-url/_expected/system.js index 975f1607f00..73ebf710ee8 100644 --- a/test/form/samples/configure-file-url/_expected/system.js +++ b/test/form/samples/configure-file-url/_expected/system.js @@ -1,16 +1,16 @@ -System.register([], function (exports, module) { +System.register([], (function (exports, module) { 'use strict'; return { - execute: function () { + execute: (function () { - var asset1 = 'chunkId=system.js:moduleId=solved:fileName=assets/asset-solved-28a7ac89.txt:format=system:relativePath=assets/asset-solved-28a7ac89.txt:referenceId=6296c678'; + var asset1 = 'chunkId=system.js:moduleId=solved:fileName=assets/asset-solved-DSjIjiFN.txt:format=system:relativePath=assets/asset-solved-DSjIjiFN.txt:referenceId=lj6zEdlc'; var asset2 = 'resolved'; - var asset3 = new URL('assets/asset-unresolved-8dcd7fca.txt', module.meta.url).href; + var asset3 = new URL('assets/asset-unresolved-B7Qh6_pN.txt', module.meta.url).href; console.log(asset1, asset2, asset3); - } + }) }; -}); +})); diff --git a/test/form/samples/configure-file-url/_expected/umd.js b/test/form/samples/configure-file-url/_expected/umd.js index c032668765d..ba84ba7407b 100644 --- a/test/form/samples/configure-file-url/_expected/umd.js +++ b/test/form/samples/configure-file-url/_expected/umd.js @@ -1,14 +1,14 @@ (function (factory) { typeof define === 'function' && define.amd ? define(factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; - var asset1 = 'chunkId=umd.js:moduleId=solved:fileName=assets/asset-solved-28a7ac89.txt:format=umd:relativePath=assets/asset-solved-28a7ac89.txt:referenceId=6296c678'; + var asset1 = 'chunkId=umd.js:moduleId=solved:fileName=assets/asset-solved-DSjIjiFN.txt:format=umd:relativePath=assets/asset-solved-DSjIjiFN.txt:referenceId=lj6zEdlc'; var asset2 = 'resolved'; - var asset3 = (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __dirname + '/assets/asset-unresolved-8dcd7fca.txt').href : new URL('assets/asset-unresolved-8dcd7fca.txt', document.currentScript && document.currentScript.src || document.baseURI).href); + var asset3 = (typeof document === 'undefined' && typeof location === 'undefined' ? require('u' + 'rl').pathToFileURL(__dirname + '/assets/asset-unresolved-B7Qh6_pN.txt').href : new URL('assets/asset-unresolved-B7Qh6_pN.txt', typeof document === 'undefined' ? location.href : document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT' && document.currentScript.src || document.baseURI).href); console.log(asset1, asset2, asset3); -}))); +})); diff --git a/test/form/samples/conflicting-imports/_config.js b/test/form/samples/conflicting-imports/_config.js index 3c157f5752f..cf75f094f0b 100644 --- a/test/form/samples/conflicting-imports/_config.js +++ b/test/form/samples/conflicting-imports/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'ensures bundle imports are deconflicted (#659)', options: { external: ['foo', 'bar'], @@ -9,4 +9,4 @@ module.exports = { } } } -}; +}); diff --git a/test/form/samples/conflicting-imports/_expected/amd.js b/test/form/samples/conflicting-imports/_expected/amd.js index f051278878d..c8f8eadc2a2 100644 --- a/test/form/samples/conflicting-imports/_expected/amd.js +++ b/test/form/samples/conflicting-imports/_expected/amd.js @@ -1,7 +1,7 @@ -define(['foo', 'bar'], function (foo, bar) { 'use strict'; +define(['foo', 'bar'], (function (foo, bar) { 'use strict'; console.log( bar.a ); console.log( foo.a ); -}); +})); diff --git a/test/form/samples/conflicting-imports/_expected/iife.js b/test/form/samples/conflicting-imports/_expected/iife.js index a5ef4fbff06..13a9a66a075 100644 --- a/test/form/samples/conflicting-imports/_expected/iife.js +++ b/test/form/samples/conflicting-imports/_expected/iife.js @@ -5,4 +5,4 @@ console.log( foo.a ); -}(foo, bar)); +})(foo, bar); diff --git a/test/form/samples/conflicting-imports/_expected/system.js b/test/form/samples/conflicting-imports/_expected/system.js index f3cc9c27a46..815a407593f 100644 --- a/test/form/samples/conflicting-imports/_expected/system.js +++ b/test/form/samples/conflicting-imports/_expected/system.js @@ -1,4 +1,4 @@ -System.register(['foo', 'bar'], function () { +System.register(['foo', 'bar'], (function () { 'use strict'; var a$1, a; return { @@ -7,12 +7,12 @@ System.register(['foo', 'bar'], function () { }, function (module) { a = module.a; }], - execute: function () { + execute: (function () { console.log( a ); console.log( a$1 ); - } + }) }; -}); +})); diff --git a/test/form/samples/conflicting-imports/_expected/umd.js b/test/form/samples/conflicting-imports/_expected/umd.js index 656a6dcf548..b5d4e6a6e69 100644 --- a/test/form/samples/conflicting-imports/_expected/umd.js +++ b/test/form/samples/conflicting-imports/_expected/umd.js @@ -2,10 +2,10 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('foo'), require('bar')) : typeof define === 'function' && define.amd ? define(['foo', 'bar'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.foo, global.bar)); -}(this, (function (foo, bar) { 'use strict'; +})(this, (function (foo, bar) { 'use strict'; console.log( bar.a ); console.log( foo.a ); -}))); +})); diff --git a/test/form/samples/curried-function/_config.js b/test/form/samples/curried-function/_config.js index 8b932f491dd..63ce038bce0 100644 --- a/test/form/samples/curried-function/_config.js +++ b/test/form/samples/curried-function/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'properly handles a curried function' -}; +}); diff --git a/test/form/samples/custom-ast/_config.js b/test/form/samples/custom-ast/_config.js new file mode 100644 index 00000000000..2690c6412e9 --- /dev/null +++ b/test/form/samples/custom-ast/_config.js @@ -0,0 +1,68 @@ +module.exports = defineTest({ + description: 'supports returning a custom AST from a plugin', + verifyAst: false, + options: { + output: { validate: false }, + plugins: [ + { + name: 'test', + load(id) { + if (id.endsWith('main.js')) { + return { + code: `import './dep.js'; +<=>custom<=>; +'removed';`, + ast: { + type: 'Program', + start: 0, + end: 42, + body: [ + { + type: 'ImportDeclaration', + start: 0, + end: 18, + specifiers: [], + source: { + type: 'Literal', + start: 7, + end: 17, + value: './dep.js', + raw: "'./dep.js'" + } + }, + { type: 'FancyNode', start: 19, end: 32 }, + { + type: 'ExpressionStatement', + start: 33, + end: 43, + expression: { + type: 'Literal', + start: 33, + end: 42, + value: 'removed', + raw: "'removed'" + } + } + ] + } + }; + } + }, + transform(code, id) { + if (id.endsWith('dep.js')) { + return { + code: `<=>other<=>;`, + ast: { + type: 'Program', + start: 0, + end: 12, + body: [{ type: 'FancyNode', start: 0, end: 12 }], + sourceType: 'module' + } + }; + } + } + } + ] + } +}); diff --git a/test/form/samples/custom-ast/_expected.js b/test/form/samples/custom-ast/_expected.js new file mode 100644 index 00000000000..a2f9eaf692c --- /dev/null +++ b/test/form/samples/custom-ast/_expected.js @@ -0,0 +1,3 @@ +<=>other<=>; + +<=>custom<=>; diff --git a/test/form/samples/custom-ast/dep.js b/test/form/samples/custom-ast/dep.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/form/samples/custom-ast/main.js b/test/form/samples/custom-ast/main.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/form/samples/custom-context/_config.js b/test/form/samples/custom-context/_config.js index 84f2dbd814e..02b233fe3a7 100644 --- a/test/form/samples/custom-context/_config.js +++ b/test/form/samples/custom-context/_config.js @@ -1,6 +1,6 @@ -module.exports = { +module.exports = defineTest({ description: 'allows custom context', options: { context: `lolwut` } -}; +}); diff --git a/test/form/samples/custom-context/_expected/amd.js b/test/form/samples/custom-context/_expected/amd.js index a160d17a1b8..9968330c8f3 100644 --- a/test/form/samples/custom-context/_expected/amd.js +++ b/test/form/samples/custom-context/_expected/amd.js @@ -1,5 +1,5 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; lolwut.prop = '???'; -}); +})); diff --git a/test/form/samples/custom-context/_expected/iife.js b/test/form/samples/custom-context/_expected/iife.js index a41619eb432..777399a6ea2 100644 --- a/test/form/samples/custom-context/_expected/iife.js +++ b/test/form/samples/custom-context/_expected/iife.js @@ -3,4 +3,4 @@ lolwut.prop = '???'; -}()); +})(); diff --git a/test/form/samples/custom-context/_expected/system.js b/test/form/samples/custom-context/_expected/system.js index c06b894ca6f..94e34efa25e 100644 --- a/test/form/samples/custom-context/_expected/system.js +++ b/test/form/samples/custom-context/_expected/system.js @@ -1,10 +1,10 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { lolwut.prop = '???'; - } + }) }; -}); +})); diff --git a/test/form/samples/custom-context/_expected/umd.js b/test/form/samples/custom-context/_expected/umd.js index 6273fa12816..35aa2a55f35 100644 --- a/test/form/samples/custom-context/_expected/umd.js +++ b/test/form/samples/custom-context/_expected/umd.js @@ -1,8 +1,8 @@ (function (factory) { typeof define === 'function' && define.amd ? define(factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; lolwut.prop = '???'; -}))); +})); diff --git a/test/form/samples/custom-dynamic-import-no-interop/_config.js b/test/form/samples/custom-dynamic-import-no-interop/_config.js index e381fb736ea..91f8f55c3b7 100644 --- a/test/form/samples/custom-dynamic-import-no-interop/_config.js +++ b/test/form/samples/custom-dynamic-import-no-interop/_config.js @@ -1,14 +1,17 @@ -module.exports = { +module.exports = defineTest({ description: 'does not add any interop when using a custom dynamic import handler', options: { external: 'external', output: { interop: 'auto' }, - plugins: { - renderDynamicImport() { - return { left: 'getIt(', right: ')' }; + plugins: [ + { + name: 'test', + renderDynamicImport() { + return { left: 'getIt(', right: ')' }; + } } - } + ] } -}; +}); diff --git a/test/form/samples/custom-dynamic-import-no-interop/_expected/amd.js b/test/form/samples/custom-dynamic-import-no-interop/_expected/amd.js index a2e3f58e8ba..49353506f82 100644 --- a/test/form/samples/custom-dynamic-import-no-interop/_expected/amd.js +++ b/test/form/samples/custom-dynamic-import-no-interop/_expected/amd.js @@ -1,5 +1,5 @@ -define(['require'], function (require) { 'use strict'; +define(['require'], (function (require) { 'use strict'; getIt('external').then(console.log); -}); +})); diff --git a/test/form/samples/custom-dynamic-import-no-interop/_expected/iife.js b/test/form/samples/custom-dynamic-import-no-interop/_expected/iife.js index 2450cf6aa54..638e6d39452 100644 --- a/test/form/samples/custom-dynamic-import-no-interop/_expected/iife.js +++ b/test/form/samples/custom-dynamic-import-no-interop/_expected/iife.js @@ -3,4 +3,4 @@ getIt('external').then(console.log); -}()); +})(); diff --git a/test/form/samples/custom-dynamic-import-no-interop/_expected/system.js b/test/form/samples/custom-dynamic-import-no-interop/_expected/system.js index b9573779542..21dfaf0f4a6 100644 --- a/test/form/samples/custom-dynamic-import-no-interop/_expected/system.js +++ b/test/form/samples/custom-dynamic-import-no-interop/_expected/system.js @@ -1,10 +1,10 @@ -System.register([], function (exports, module) { +System.register([], (function (exports, module) { 'use strict'; return { - execute: function () { + execute: (function () { getIt('external').then(console.log); - } + }) }; -}); +})); diff --git a/test/form/samples/custom-dynamic-import-no-interop/_expected/umd.js b/test/form/samples/custom-dynamic-import-no-interop/_expected/umd.js index ae1c25b2256..7a222025649 100644 --- a/test/form/samples/custom-dynamic-import-no-interop/_expected/umd.js +++ b/test/form/samples/custom-dynamic-import-no-interop/_expected/umd.js @@ -1,8 +1,8 @@ (function (factory) { typeof define === 'function' && define.amd ? define(factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; getIt('external').then(console.log); -}))); +})); diff --git a/test/form/samples/custom-event-detail/_config.js b/test/form/samples/custom-event-detail/_config.js new file mode 100644 index 00000000000..e9a52e0fd06 --- /dev/null +++ b/test/form/samples/custom-event-detail/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'observes side effects for custom event payloads' +}); diff --git a/test/form/samples/custom-event-detail/_expected.js b/test/form/samples/custom-event-detail/_expected.js new file mode 100644 index 00000000000..098316cf8d6 --- /dev/null +++ b/test/form/samples/custom-event-detail/_expected.js @@ -0,0 +1,5 @@ +const detail = { value: null }; +const event = new CustomEvent('test', { detail }); +event.detail.value = true; +if (detail.value) console.log('ok'); +else console.log('failed'); diff --git a/test/form/samples/custom-event-detail/main.js b/test/form/samples/custom-event-detail/main.js new file mode 100644 index 00000000000..098316cf8d6 --- /dev/null +++ b/test/form/samples/custom-event-detail/main.js @@ -0,0 +1,5 @@ +const detail = { value: null }; +const event = new CustomEvent('test', { detail }); +event.detail.value = true; +if (detail.value) console.log('ok'); +else console.log('failed'); diff --git a/test/form/samples/custom-module-context-function/_config.js b/test/form/samples/custom-module-context-function/_config.js index c10efdfacbe..e0b7153fb0c 100644 --- a/test/form/samples/custom-module-context-function/_config.js +++ b/test/form/samples/custom-module-context-function/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'allows custom module-specific context with a function option', expectedWarnings: ['THIS_IS_UNDEFINED'], options: { @@ -11,4 +11,4 @@ module.exports = { } } } -}; +}); diff --git a/test/form/samples/custom-module-context/_config.js b/test/form/samples/custom-module-context/_config.js index 8b5dd23cbfb..d34d646df5d 100644 --- a/test/form/samples/custom-module-context/_config.js +++ b/test/form/samples/custom-module-context/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'allows custom module-specific context', expectedWarnings: ['THIS_IS_UNDEFINED'], options: { @@ -6,4 +6,4 @@ module.exports = { 'main.js': 'lolwut' } } -}; +}); diff --git a/test/form/samples/custom-module-context/_expected/amd.js b/test/form/samples/custom-module-context/_expected/amd.js index 92747997ff2..c13531e4359 100644 --- a/test/form/samples/custom-module-context/_expected/amd.js +++ b/test/form/samples/custom-module-context/_expected/amd.js @@ -1,7 +1,7 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; undefined.prop = 'nope'; lolwut.prop = '???'; -}); +})); diff --git a/test/form/samples/custom-module-context/_expected/iife.js b/test/form/samples/custom-module-context/_expected/iife.js index 7926fe6e7ea..384c6140193 100644 --- a/test/form/samples/custom-module-context/_expected/iife.js +++ b/test/form/samples/custom-module-context/_expected/iife.js @@ -5,4 +5,4 @@ lolwut.prop = '???'; -}()); +})(); diff --git a/test/form/samples/custom-module-context/_expected/system.js b/test/form/samples/custom-module-context/_expected/system.js index 1e323399d00..5c1452338fb 100644 --- a/test/form/samples/custom-module-context/_expected/system.js +++ b/test/form/samples/custom-module-context/_expected/system.js @@ -1,12 +1,12 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { undefined.prop = 'nope'; lolwut.prop = '???'; - } + }) }; -}); +})); diff --git a/test/form/samples/custom-module-context/_expected/umd.js b/test/form/samples/custom-module-context/_expected/umd.js index 79188921edf..028ee996590 100644 --- a/test/form/samples/custom-module-context/_expected/umd.js +++ b/test/form/samples/custom-module-context/_expected/umd.js @@ -1,10 +1,10 @@ (function (factory) { typeof define === 'function' && define.amd ? define(factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; undefined.prop = 'nope'; lolwut.prop = '???'; -}))); +})); diff --git a/test/form/samples/cycles-dependency-with-TLA-await-import/_config.js b/test/form/samples/cycles-dependency-with-TLA-await-import/_config.js new file mode 100644 index 00000000000..60523134d45 --- /dev/null +++ b/test/form/samples/cycles-dependency-with-TLA-await-import/_config.js @@ -0,0 +1,21 @@ +const path = require('node:path'); +const ID_MAIN = path.join(__dirname, 'main.js'); +const ID_LIB = path.join(__dirname, 'lib.js'); + +module.exports = defineTest({ + description: 'throw a warn when a cycle is detected which includes a top-level await import', + options: { + output: { + inlineDynamicImports: true + } + }, + expectedWarnings: ['CIRCULAR_DEPENDENCY'], + logs: [ + { + code: 'CIRCULAR_DEPENDENCY', + ids: [ID_MAIN, ID_LIB, ID_MAIN], + level: 'warn', + message: 'Circular dependency: main.js -> lib.js -> main.js' + } + ] +}); diff --git a/test/form/samples/cycles-dependency-with-TLA-await-import/_expected.js b/test/form/samples/cycles-dependency-with-TLA-await-import/_expected.js new file mode 100644 index 00000000000..4f5d10bf369 --- /dev/null +++ b/test/form/samples/cycles-dependency-with-TLA-await-import/_expected.js @@ -0,0 +1,18 @@ +setTimeout(() => { + console.log(main); +}); + +const square$1 = x => x; + +var lib = /*#__PURE__*/Object.freeze({ + __proto__: null, + square: square$1 +}); + +const { square } = await Promise.resolve().then(function () { return lib; }); + +console.log(square(5)); + +const main = 'main'; + +export { main }; diff --git a/test/form/samples/cycles-dependency-with-TLA-await-import/lib.js b/test/form/samples/cycles-dependency-with-TLA-await-import/lib.js new file mode 100644 index 00000000000..6d2ac700782 --- /dev/null +++ b/test/form/samples/cycles-dependency-with-TLA-await-import/lib.js @@ -0,0 +1,7 @@ +import { main } from './main.js'; + +setTimeout(() => { + console.log(main); +}); + +export const square = x => x; diff --git a/test/form/samples/cycles-dependency-with-TLA-await-import/main.js b/test/form/samples/cycles-dependency-with-TLA-await-import/main.js new file mode 100644 index 00000000000..2b927b08fcf --- /dev/null +++ b/test/form/samples/cycles-dependency-with-TLA-await-import/main.js @@ -0,0 +1,5 @@ +const { square } = await import('./lib.js'); + +console.log(square(5)); + +export const main = 'main'; diff --git a/test/form/samples/declarations-with-side-effects/_config.js b/test/form/samples/declarations-with-side-effects/_config.js index ac63c345d62..8905efcd41f 100644 --- a/test/form/samples/declarations-with-side-effects/_config.js +++ b/test/form/samples/declarations-with-side-effects/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'retains side-effects in declarations will tree-shaking the declared variable' -}; +}); diff --git a/test/form/samples/deconflict-format-specific-exports/_config.js b/test/form/samples/deconflict-format-specific-exports/_config.js index 3618b693baf..6603d8c137f 100644 --- a/test/form/samples/deconflict-format-specific-exports/_config.js +++ b/test/form/samples/deconflict-format-specific-exports/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'only deconflict "exports" for formats where it is necessary', options: { output: { name: 'bundle' } } -}; +}); diff --git a/test/form/samples/deconflict-format-specific-exports/_expected/amd.js b/test/form/samples/deconflict-format-specific-exports/_expected/amd.js index e060619b182..b26f9e08ba6 100644 --- a/test/form/samples/deconflict-format-specific-exports/_expected/amd.js +++ b/test/form/samples/deconflict-format-specific-exports/_expected/amd.js @@ -1,4 +1,4 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; const exports$1 = { x: 42 @@ -14,16 +14,14 @@ define(['exports'], function (exports) { 'use strict'; } function nestedNoConflict() { - const exports = { + const exports$1 = { x: 42 }; - console.log(exports); + console.log(exports$1); } exports.x = 43; nestedConflict(); nestedNoConflict(); - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/form/samples/deconflict-format-specific-exports/_expected/cjs.js b/test/form/samples/deconflict-format-specific-exports/_expected/cjs.js index 21cadc195ec..fb1df04c1d2 100644 --- a/test/form/samples/deconflict-format-specific-exports/_expected/cjs.js +++ b/test/form/samples/deconflict-format-specific-exports/_expected/cjs.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - const exports$1 = { x: 42 }; @@ -16,10 +14,10 @@ function nestedConflict() { } function nestedNoConflict() { - const exports = { + const exports$1 = { x: 42 }; - console.log(exports); + console.log(exports$1); } exports.x = 43; diff --git a/test/form/samples/deconflict-format-specific-exports/_expected/es.js b/test/form/samples/deconflict-format-specific-exports/_expected/es.js index 131a3701263..7b8dd48359d 100644 --- a/test/form/samples/deconflict-format-specific-exports/_expected/es.js +++ b/test/form/samples/deconflict-format-specific-exports/_expected/es.js @@ -1,21 +1,21 @@ -const exports = { +const exports$1 = { x: 42 }; -console.log(exports); +console.log(exports$1); function nestedConflict() { - const exports = { + const exports$1 = { x: 42 }; - console.log(exports); + console.log(exports$1); x++; } function nestedNoConflict() { - const exports = { + const exports$1 = { x: 42 }; - console.log(exports); + console.log(exports$1); } var x = 43; diff --git a/test/form/samples/deconflict-format-specific-exports/_expected/iife.js b/test/form/samples/deconflict-format-specific-exports/_expected/iife.js index 5ffcc33e9e0..d2ff0f031e3 100644 --- a/test/form/samples/deconflict-format-specific-exports/_expected/iife.js +++ b/test/form/samples/deconflict-format-specific-exports/_expected/iife.js @@ -15,18 +15,16 @@ var bundle = (function (exports) { } function nestedNoConflict() { - const exports = { + const exports$1 = { x: 42 }; - console.log(exports); + console.log(exports$1); } exports.x = 43; nestedConflict(); nestedNoConflict(); - Object.defineProperty(exports, '__esModule', { value: true }); - return exports; -}({})); +})({}); diff --git a/test/form/samples/deconflict-format-specific-exports/_expected/system.js b/test/form/samples/deconflict-format-specific-exports/_expected/system.js index db840212d24..baae40b66d6 100644 --- a/test/form/samples/deconflict-format-specific-exports/_expected/system.js +++ b/test/form/samples/deconflict-format-specific-exports/_expected/system.js @@ -1,7 +1,7 @@ -System.register('bundle', [], function (exports) { +System.register('bundle', [], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { const exports$1 = { x: 42 @@ -13,20 +13,20 @@ System.register('bundle', [], function (exports) { x: 42 }; console.log(exports$1); - (exports('x', x + 1), x++); + exports("x", x + 1), x++; } function nestedNoConflict() { - const exports = { + const exports$1 = { x: 42 }; - console.log(exports); + console.log(exports$1); } - var x = exports('x', 43); + var x = exports("x", 43); nestedConflict(); nestedNoConflict(); - } + }) }; -}); +})); diff --git a/test/form/samples/deconflict-format-specific-exports/_expected/umd.js b/test/form/samples/deconflict-format-specific-exports/_expected/umd.js index 75d2fee10aa..6d1d58f93ad 100644 --- a/test/form/samples/deconflict-format-specific-exports/_expected/umd.js +++ b/test/form/samples/deconflict-format-specific-exports/_expected/umd.js @@ -2,7 +2,7 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.bundle = {})); -}(this, (function (exports) { 'use strict'; +})(this, (function (exports) { 'use strict'; const exports$1 = { x: 42 @@ -18,16 +18,14 @@ } function nestedNoConflict() { - const exports = { + const exports$1 = { x: 42 }; - console.log(exports); + console.log(exports$1); } exports.x = 43; nestedConflict(); nestedNoConflict(); - Object.defineProperty(exports, '__esModule', { value: true }); - -}))); +})); diff --git a/test/form/samples/deconflict-format-specific-globals/_config.js b/test/form/samples/deconflict-format-specific-globals/_config.js index 5dc0b5bb2bb..7e9abe513ff 100644 --- a/test/form/samples/deconflict-format-specific-globals/_config.js +++ b/test/form/samples/deconflict-format-specific-globals/_config.js @@ -1,10 +1,16 @@ -module.exports = { +module.exports = defineTest({ description: 'deconflicts format specific globals', + // Due to deconflicted variable name caching, there will be more deconflicted + // names in "es" or "system" if they render after one of the other formats. + // This is fine, but we need to disable shuffling to keep the test stable. + shuffleFormats: false, options: { external: 'external', output: { globals: { external: 'external' }, - name: 'bundle' + name: 'bundle', + interop: 'auto', + dynamicImportInCjs: false } } -}; +}); diff --git a/test/form/samples/deconflict-format-specific-globals/_expected/amd.js b/test/form/samples/deconflict-format-specific-globals/_expected/amd.js index dc87229044a..85c54872e9b 100644 --- a/test/form/samples/deconflict-format-specific-globals/_expected/amd.js +++ b/test/form/samples/deconflict-format-specific-globals/_expected/amd.js @@ -1,6 +1,6 @@ -define(['module', 'require', 'external'], function (module, require, external) { 'use strict'; +define(['module', 'require', 'exports', 'external'], (function (module, require, exports, external) { 'use strict'; - function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } + function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; } function _interopNamespace(e) { if (e && e.__esModule) return e; @@ -11,20 +11,18 @@ define(['module', 'require', 'external'], function (module, require, external) { var d = Object.getOwnPropertyDescriptor(e, k); Object.defineProperty(n, k, d.get ? d : { enumerable: true, - get: function () { - return e[k]; - } + get: function () { return e[k]; } }); } }); } - n['default'] = e; + n.default = e; return Object.freeze(n); } - var external__default = /*#__PURE__*/_interopDefaultLegacy(external); + var external__default = /*#__PURE__*/_interopDefault(external); - console.log(external__default['default']); + console.log(external__default.default); const _interopDefault$1 = 1; const _interopNamespace$1 = 1; @@ -35,8 +33,8 @@ define(['module', 'require', 'external'], function (module, require, external) { const URL$1 = 1; console.log(_interopDefault$1, _interopNamespace$1, module$1, require$1, exports$1, document$1, URL$1); - new Promise(function (resolve, reject) { require(['external'], function (m) { resolve(/*#__PURE__*/_interopNamespace(m)); }, reject) }).then(console.log); - exports['default'] = 0; + new Promise(function (resolve, reject) { require(['external'], function (m) { resolve(/*#__PURE__*/_interopNamespace(m)); }, reject); }).then(console.log); + exports.default = 0; console.log(new URL(module.uri, document.baseURI).href); function nested1() { @@ -49,8 +47,8 @@ define(['module', 'require', 'external'], function (module, require, external) { const URL$1 = 1; console.log(_interopDefault, _interopNamespace$1, module$1, require$1, exports$1, document$1, URL$1); - new Promise(function (resolve, reject) { require(['external'], function (m) { resolve(/*#__PURE__*/_interopNamespace(m)); }, reject) }).then(console.log); - exports['default'] = 1; + new Promise(function (resolve, reject) { require(['external'], function (m) { resolve(/*#__PURE__*/_interopNamespace(m)); }, reject); }).then(console.log); + exports.default = 1; console.log(new URL(module.uri, document.baseURI).href); } @@ -61,14 +59,14 @@ define(['module', 'require', 'external'], function (module, require, external) { const _interopNamespace = 1; const module = 1; const require = 1; - const exports = 1; + const exports$1 = 1; const document = 1; const URL = 1; - console.log(_interopDefault, _interopNamespace, module, require, exports, document, URL); + console.log(_interopDefault, _interopNamespace, module, require, exports$1, document, URL); } nested2(); - return exports['default']; + return exports.default; -}); +})); diff --git a/test/form/samples/deconflict-format-specific-globals/_expected/cjs.js b/test/form/samples/deconflict-format-specific-globals/_expected/cjs.js index ee8ed5ba7ec..4f847d3fcaf 100644 --- a/test/form/samples/deconflict-format-specific-globals/_expected/cjs.js +++ b/test/form/samples/deconflict-format-specific-globals/_expected/cjs.js @@ -2,7 +2,8 @@ var external = require('external'); -function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } +var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null; +function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; } function _interopNamespace(e) { if (e && e.__esModule) return e; @@ -13,20 +14,18 @@ function _interopNamespace(e) { var d = Object.getOwnPropertyDescriptor(e, k); Object.defineProperty(n, k, d.get ? d : { enumerable: true, - get: function () { - return e[k]; - } + get: function () { return e[k]; } }); } }); } - n['default'] = e; + n.default = e; return Object.freeze(n); } -var external__default = /*#__PURE__*/_interopDefaultLegacy(external); +var external__default = /*#__PURE__*/_interopDefault(external); -console.log(external__default['default']); +console.log(external__default.default); const _interopDefault$1 = 1; const _interopNamespace$1 = 1; @@ -38,8 +37,8 @@ const URL$1 = 1; console.log(_interopDefault$1, _interopNamespace$1, module$1, require$1, exports$1, document$1, URL$1); Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('external')); }).then(console.log); -exports['default'] = 0; -console.log((typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('cjs.js', document.baseURI).href))); +exports.default = 0; +console.log((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cjs.js', document.baseURI).href))); function nested1() { const _interopDefault = 1; @@ -52,8 +51,8 @@ function nested1() { console.log(_interopDefault, _interopNamespace$1, module, require$1, exports$1, document$1, URL$1); Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('external')); }).then(console.log); - exports['default'] = 1; - console.log((typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('cjs.js', document.baseURI).href))); + exports.default = 1; + console.log((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cjs.js', document.baseURI).href))); } nested1(); @@ -63,12 +62,12 @@ function nested2() { const _interopNamespace = 1; const module = 1; const require = 1; - const exports = 1; + const exports$1 = 1; const document = 1; const URL = 1; - console.log(_interopDefault, _interopNamespace, module, require, exports, document, URL); + console.log(_interopDefault, _interopNamespace, module, require, exports$1, document, URL); } nested2(); -module.exports = exports['default']; +module.exports = exports.default; diff --git a/test/form/samples/deconflict-format-specific-globals/_expected/es.js b/test/form/samples/deconflict-format-specific-globals/_expected/es.js index 7242dcffa80..69293601a2c 100644 --- a/test/form/samples/deconflict-format-specific-globals/_expected/es.js +++ b/test/form/samples/deconflict-format-specific-globals/_expected/es.js @@ -2,14 +2,14 @@ import external from 'external'; console.log(external); -const _interopDefault = 1; -const _interopNamespace = 1; -const module = 1; -const require = 1; -const exports = 1; -const document = 1; -const URL = 1; -console.log(_interopDefault, _interopNamespace, module, require, exports, document, URL); +const _interopDefault$1 = 1; +const _interopNamespace$1 = 1; +const module$1 = 1; +const require$1 = 1; +const exports$1 = 1; +const document$1 = 1; +const URL$1 = 1; +console.log(_interopDefault$1, _interopNamespace$1, module$1, require$1, exports$1, document$1, URL$1); import('external').then(console.log); let value = 0; @@ -20,10 +20,10 @@ function nested1() { const _interopNamespace = 1; const module = 1; const require = 1; - const exports = 1; + const exports$1 = 1; const document = 1; const URL = 1; - console.log(_interopDefault, _interopNamespace, module, require, exports, document, URL); + console.log(_interopDefault, _interopNamespace, module, require, exports$1, document, URL); import('external').then(console.log); value = 1; @@ -37,12 +37,12 @@ function nested2() { const _interopNamespace = 1; const module = 1; const require = 1; - const exports = 1; + const exports$1 = 1; const document = 1; const URL = 1; - console.log(_interopDefault, _interopNamespace, module, require, exports, document, URL); + console.log(_interopDefault, _interopNamespace, module, require, exports$1, document, URL); } nested2(); -export default value; +export { value as default }; diff --git a/test/form/samples/deconflict-format-specific-globals/_expected/iife.js b/test/form/samples/deconflict-format-specific-globals/_expected/iife.js index db6f1736e31..5e67dbb6bfb 100644 --- a/test/form/samples/deconflict-format-specific-globals/_expected/iife.js +++ b/test/form/samples/deconflict-format-specific-globals/_expected/iife.js @@ -1,24 +1,25 @@ -var bundle = (function (external) { +var bundle = (function (exports, external) { 'use strict'; - function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } + var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null; + function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; } - var external__default = /*#__PURE__*/_interopDefaultLegacy(external); + var external__default = /*#__PURE__*/_interopDefault(external); - console.log(external__default['default']); + console.log(external__default.default); const _interopDefault$1 = 1; const _interopNamespace$1 = 1; - const module = 1; - const require = 1; + const module$1 = 1; + const require$1 = 1; const exports$1 = 1; const document$1 = 1; const URL$1 = 1; - console.log(_interopDefault$1, _interopNamespace$1, module, require, exports$1, document$1, URL$1); + console.log(_interopDefault$1, _interopNamespace$1, module$1, require$1, exports$1, document$1, URL$1); import('external').then(console.log); - exports['default'] = 0; - console.log((document.currentScript && document.currentScript.src || new URL('iife.js', document.baseURI).href)); + exports.default = 0; + console.log((_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('iife.js', document.baseURI).href)); function nested1() { const _interopDefault = 1; @@ -31,8 +32,8 @@ var bundle = (function (external) { console.log(_interopDefault, _interopNamespace, module, require, exports$1, document$1, URL$1); import('external').then(console.log); - exports['default'] = 1; - console.log((document.currentScript && document.currentScript.src || new URL('iife.js', document.baseURI).href)); + exports.default = 1; + console.log((_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('iife.js', document.baseURI).href)); } nested1(); @@ -42,14 +43,14 @@ var bundle = (function (external) { const _interopNamespace = 1; const module = 1; const require = 1; - const exports = 1; + const exports$1 = 1; const document = 1; const URL = 1; - console.log(_interopDefault, _interopNamespace, module, require, exports, document, URL); + console.log(_interopDefault, _interopNamespace, module, require, exports$1, document, URL); } nested2(); - return exports['default']; + return exports.default; -}(external)); +})({}, external); diff --git a/test/form/samples/deconflict-format-specific-globals/_expected/system.js b/test/form/samples/deconflict-format-specific-globals/_expected/system.js index a75b2da52c3..48ea558caa4 100644 --- a/test/form/samples/deconflict-format-specific-globals/_expected/system.js +++ b/test/form/samples/deconflict-format-specific-globals/_expected/system.js @@ -1,25 +1,25 @@ -System.register('bundle', ['external'], function (exports, module) { +System.register('bundle', ['external'], (function (exports, module) { 'use strict'; var external; return { setters: [function (module) { external = module.default; }], - execute: function () { + execute: (function () { console.log(external); - const _interopDefault = 1; - const _interopNamespace = 1; + const _interopDefault$1 = 1; + const _interopNamespace$1 = 1; const module$1 = 1; - const require = 1; + const require$1 = 1; const exports$1 = 1; - const document = 1; - const URL = 1; - console.log(_interopDefault, _interopNamespace, module$1, require, exports$1, document, URL); + const document$1 = 1; + const URL$1 = 1; + console.log(_interopDefault$1, _interopNamespace$1, module$1, require$1, exports$1, document$1, URL$1); module.import('external').then(console.log); - let value = exports('default', 0); + let value = exports("default", 0); console.log(module.meta.url); function nested1() { @@ -33,7 +33,7 @@ System.register('bundle', ['external'], function (exports, module) { console.log(_interopDefault, _interopNamespace, module$1, require, exports$1, document, URL); module.import('external').then(console.log); - value = exports('default', 1); + exports("default", value = 1); console.log(module.meta.url); } @@ -44,14 +44,14 @@ System.register('bundle', ['external'], function (exports, module) { const _interopNamespace = 1; const module = 1; const require = 1; - const exports = 1; + const exports$1 = 1; const document = 1; const URL = 1; - console.log(_interopDefault, _interopNamespace, module, require, exports, document, URL); + console.log(_interopDefault, _interopNamespace, module, require, exports$1, document, URL); } nested2(); - } + }) }; -}); +})); diff --git a/test/form/samples/deconflict-format-specific-globals/_expected/umd.js b/test/form/samples/deconflict-format-specific-globals/_expected/umd.js index 3a2206c125a..5cc00bef9a7 100644 --- a/test/form/samples/deconflict-format-specific-globals/_expected/umd.js +++ b/test/form/samples/deconflict-format-specific-globals/_expected/umd.js @@ -1,27 +1,28 @@ (function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('external')) : - typeof define === 'function' && define.amd ? define(['external'], factory) : - (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.bundle = factory(global.external)); -}(this, (function (external) { 'use strict'; + typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(exports, require('external')) : + typeof define === 'function' && define.amd ? define(['exports', 'external'], factory) : + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.bundle = factory(global.bundle = {}, global.external)); +})(this, (function (exports, external) { 'use strict'; - function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } + var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null; + function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; } - var external__default = /*#__PURE__*/_interopDefaultLegacy(external); + var external__default = /*#__PURE__*/_interopDefault(external); - console.log(external__default['default']); + console.log(external__default.default); const _interopDefault$1 = 1; const _interopNamespace$1 = 1; - const module = 1; + const module$1 = 1; const require$1 = 1; const exports$1 = 1; const document$1 = 1; const URL$1 = 1; - console.log(_interopDefault$1, _interopNamespace$1, module, require$1, exports$1, document$1, URL$1); + console.log(_interopDefault$1, _interopNamespace$1, module$1, require$1, exports$1, document$1, URL$1); import('external').then(console.log); - exports['default'] = 0; - console.log((typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('umd.js', document.baseURI).href))); + exports.default = 0; + console.log((typeof document === 'undefined' && typeof location === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : typeof document === 'undefined' ? location.href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('umd.js', document.baseURI).href))); function nested1() { const _interopDefault = 1; @@ -34,8 +35,8 @@ console.log(_interopDefault, _interopNamespace, module, require$1, exports$1, document$1, URL$1); import('external').then(console.log); - exports['default'] = 1; - console.log((typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('umd.js', document.baseURI).href))); + exports.default = 1; + console.log((typeof document === 'undefined' && typeof location === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : typeof document === 'undefined' ? location.href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('umd.js', document.baseURI).href))); } nested1(); @@ -45,14 +46,14 @@ const _interopNamespace = 1; const module = 1; const require = 1; - const exports = 1; + const exports$1 = 1; const document = 1; const URL = 1; - console.log(_interopDefault, _interopNamespace, module, require, exports, document, URL); + console.log(_interopDefault, _interopNamespace, module, require, exports$1, document, URL); } nested2(); - return exports['default']; + return exports.default; -}))); +})); diff --git a/test/form/samples/deconflict-module-priority/_config.js b/test/form/samples/deconflict-module-priority/_config.js index 5ea1e7a90a8..e19c23a79b9 100644 --- a/test/form/samples/deconflict-module-priority/_config.js +++ b/test/form/samples/deconflict-module-priority/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'prioritizes entry modules over dependencies when deconflicting' -}; +}); diff --git a/test/form/samples/deconflict-nested-tree-shaking/_config.js b/test/form/samples/deconflict-nested-tree-shaking/_config.js index f423de7c702..c9c747df289 100644 --- a/test/form/samples/deconflict-nested-tree-shaking/_config.js +++ b/test/form/samples/deconflict-nested-tree-shaking/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'does not consider nested tree-shaken variables when deconflicting' -}; +}); diff --git a/test/form/samples/deconflict-tree-shaken-globals/_config.js b/test/form/samples/deconflict-tree-shaken-globals/_config.js index 233206fcd76..d1f174625b8 100644 --- a/test/form/samples/deconflict-tree-shaken-globals/_config.js +++ b/test/form/samples/deconflict-tree-shaken-globals/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'does not deconflict due to tree-shaken global variables' -}; +}); diff --git a/test/form/samples/deconflict-tree-shaken/_config.js b/test/form/samples/deconflict-tree-shaken/_config.js index 96c6ef18178..2fab7e1bb32 100644 --- a/test/form/samples/deconflict-tree-shaken/_config.js +++ b/test/form/samples/deconflict-tree-shaken/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'does not consider tree-shaken variables when deconflicting' -}; +}); diff --git a/test/form/samples/decorator-identifiers-deconflict/_config.js b/test/form/samples/decorator-identifiers-deconflict/_config.js new file mode 100644 index 00000000000..1202dfce6df --- /dev/null +++ b/test/form/samples/decorator-identifiers-deconflict/_config.js @@ -0,0 +1,4 @@ +module.exports = defineTest({ + description: 'de-conflict identifiers of decorators', + verifyAst: false +}); diff --git a/test/form/samples/decorator-identifiers-deconflict/_expected.js b/test/form/samples/decorator-identifiers-deconflict/_expected.js new file mode 100644 index 00000000000..f09535c5661 --- /dev/null +++ b/test/form/samples/decorator-identifiers-deconflict/_expected.js @@ -0,0 +1,13 @@ +function fooDecorator$1() { + console.log('first effect'); +} + +let Foo$1 = @fooDecorator$1 +class Foo {}; + +function fooDecorator() { + console.log('second effect'); +} + +@fooDecorator +class Foo {} diff --git a/test/form/samples/decorator-identifiers-deconflict/first.js b/test/form/samples/decorator-identifiers-deconflict/first.js new file mode 100644 index 00000000000..abab3322cf7 --- /dev/null +++ b/test/form/samples/decorator-identifiers-deconflict/first.js @@ -0,0 +1,6 @@ +function fooDecorator() { + console.log('first effect'); +} + +@fooDecorator +class Foo {} diff --git a/test/form/samples/decorator-identifiers-deconflict/main.js b/test/form/samples/decorator-identifiers-deconflict/main.js new file mode 100644 index 00000000000..0da9babd2ab --- /dev/null +++ b/test/form/samples/decorator-identifiers-deconflict/main.js @@ -0,0 +1,2 @@ +import './first'; +import './second'; diff --git a/test/form/samples/decorator-identifiers-deconflict/second.js b/test/form/samples/decorator-identifiers-deconflict/second.js new file mode 100644 index 00000000000..5278ed5dede --- /dev/null +++ b/test/form/samples/decorator-identifiers-deconflict/second.js @@ -0,0 +1,6 @@ +function fooDecorator() { + console.log('second effect'); +} + +@fooDecorator +class Foo {} diff --git a/test/form/samples/decorator-tree-shaking-2/_config.js b/test/form/samples/decorator-tree-shaking-2/_config.js new file mode 100644 index 00000000000..e964fc29c0b --- /dev/null +++ b/test/form/samples/decorator-tree-shaking-2/_config.js @@ -0,0 +1,4 @@ +module.exports = defineTest({ + description: 'retain the decorator function if the decorated class is retained', + verifyAst: false +}); diff --git a/test/form/samples/decorator-tree-shaking-2/_expected.js b/test/form/samples/decorator-tree-shaking-2/_expected.js new file mode 100644 index 00000000000..1e4722ff352 --- /dev/null +++ b/test/form/samples/decorator-tree-shaking-2/_expected.js @@ -0,0 +1,6 @@ +function decorator() {} + +@decorator +class Main {} + +assert.ok(Main); diff --git a/test/form/samples/decorator-tree-shaking-2/main.js b/test/form/samples/decorator-tree-shaking-2/main.js new file mode 100644 index 00000000000..1e4722ff352 --- /dev/null +++ b/test/form/samples/decorator-tree-shaking-2/main.js @@ -0,0 +1,6 @@ +function decorator() {} + +@decorator +class Main {} + +assert.ok(Main); diff --git a/test/form/samples/decorator-tree-shaking/_config.js b/test/form/samples/decorator-tree-shaking/_config.js new file mode 100644 index 00000000000..bb849b653ac --- /dev/null +++ b/test/form/samples/decorator-tree-shaking/_config.js @@ -0,0 +1,4 @@ +module.exports = defineTest({ + description: 'retain the class if the calling of decorator function has effects', + verifyAst: false +}); diff --git a/test/form/samples/decorator-tree-shaking/_expected.js b/test/form/samples/decorator-tree-shaking/_expected.js new file mode 100644 index 00000000000..0c0332f7b38 --- /dev/null +++ b/test/form/samples/decorator-tree-shaking/_expected.js @@ -0,0 +1,52 @@ +// retained +function decorator() { + console.log('effect'); +} + +@decorator +class Main {} + +// retained +function decorator2() { + console.log('effect'); +} + +class Main2 { + @decorator2 + a = 1; +} + +// retained +function decorator3() { + console.log('effect'); +} +class Main3 { + @decorator3 + a() {} +} + +// retained +function decorator5() { + console.log('effect'); + return () => {}; +} +@decorator5() +class Main5 {} + +// retained +function decorator6() { + return () => { + console.log('effect'); + }; +} +@decorator6() +class Main6 {} + +// retained +function decorator8() { + console.log('effect'); + return () => {}; +} + +@(decorator8()) +class Main8 {} diff --git a/test/form/samples/decorator-tree-shaking/main.js b/test/form/samples/decorator-tree-shaking/main.js new file mode 100644 index 00000000000..8e84011b5ea --- /dev/null +++ b/test/form/samples/decorator-tree-shaking/main.js @@ -0,0 +1,70 @@ +// retained +function decorator() { + console.log('effect'); +} + +@decorator +class Main {} + +// retained +function decorator2() { + console.log('effect'); +} + +class Main2 { + @decorator2 + a = 1; +} + +// retained +function decorator3() { + console.log('effect'); +} +class Main3 { + @decorator3 + a() {} +} + +// removed +function decorator4() {} + +@decorator4 +class Main4 { + @decorator4 + a = 1; + @decorator4 + b() {} +} + +// retained +function decorator5() { + console.log('effect'); + return () => {}; +} +@decorator5() +class Main5 {} + +// retained +function decorator6() { + return () => { + console.log('effect'); + }; +} +@decorator6() +class Main6 {} + +// removed +function decorator7() { + return () => {}; +} +@decorator7() +class Main7 {} + +// retained +function decorator8() { + console.log('effect'); + return () => {}; +} + +@(false || decorator8()) +class Main8 {} diff --git a/test/form/samples/decorator/_config.js b/test/form/samples/decorator/_config.js new file mode 100644 index 00000000000..b2ea582ac45 --- /dev/null +++ b/test/form/samples/decorator/_config.js @@ -0,0 +1,4 @@ +module.exports = defineTest({ + description: 'parsing decorators successfully', + verifyAst: false +}); diff --git a/test/form/samples/decorator/_expected.js b/test/form/samples/decorator/_expected.js new file mode 100644 index 00000000000..6d007e7f7d8 --- /dev/null +++ b/test/form/samples/decorator/_expected.js @@ -0,0 +1,10 @@ +function decorator() {} + +@decorator +@decorator2 +class Test { + @decorator + a = 1; + @decorator + b() {} +} diff --git a/test/form/samples/decorator/main.js b/test/form/samples/decorator/main.js new file mode 100644 index 00000000000..6d007e7f7d8 --- /dev/null +++ b/test/form/samples/decorator/main.js @@ -0,0 +1,10 @@ +function decorator() {} + +@decorator +@decorator2 +class Test { + @decorator + a = 1; + @decorator + b() {} +} diff --git a/test/form/samples/dedupes-external-imports/_config.js b/test/form/samples/dedupes-external-imports/_config.js index 937ee5ed574..2827740b09e 100644 --- a/test/form/samples/dedupes-external-imports/_config.js +++ b/test/form/samples/dedupes-external-imports/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'dedupes external imports', options: { external: ['external'], @@ -7,4 +7,4 @@ module.exports = { name: 'myBundle' } } -}; +}); diff --git a/test/form/samples/dedupes-external-imports/_expected/amd.js b/test/form/samples/dedupes-external-imports/_expected/amd.js index 3a2d1bc8ad7..d0c85ec3616 100644 --- a/test/form/samples/dedupes-external-imports/_expected/amd.js +++ b/test/form/samples/dedupes-external-imports/_expected/amd.js @@ -1,4 +1,4 @@ -define(['exports', 'external'], function (exports, external) { 'use strict'; +define(['exports', 'external'], (function (exports, external) { 'use strict'; class Foo extends external.Component { constructor () { @@ -29,6 +29,4 @@ define(['exports', 'external'], function (exports, external) { 'use strict'; exports.baz = baz; exports.foo = foo; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/form/samples/dedupes-external-imports/_expected/cjs.js b/test/form/samples/dedupes-external-imports/_expected/cjs.js index 08e53049670..e456043e7fa 100644 --- a/test/form/samples/dedupes-external-imports/_expected/cjs.js +++ b/test/form/samples/dedupes-external-imports/_expected/cjs.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - var external = require('external'); class Foo extends external.Component { diff --git a/test/form/samples/dedupes-external-imports/_expected/iife.js b/test/form/samples/dedupes-external-imports/_expected/iife.js index c075acfa351..45d749bd275 100644 --- a/test/form/samples/dedupes-external-imports/_expected/iife.js +++ b/test/form/samples/dedupes-external-imports/_expected/iife.js @@ -30,8 +30,6 @@ var myBundle = (function (exports, external) { exports.baz = baz; exports.foo = foo; - Object.defineProperty(exports, '__esModule', { value: true }); - return exports; -}({}, external)); +})({}, external); diff --git a/test/form/samples/dedupes-external-imports/_expected/system.js b/test/form/samples/dedupes-external-imports/_expected/system.js index 26d44c1ff55..107268d007f 100644 --- a/test/form/samples/dedupes-external-imports/_expected/system.js +++ b/test/form/samples/dedupes-external-imports/_expected/system.js @@ -1,11 +1,11 @@ -System.register('myBundle', ['external'], function (exports) { +System.register('myBundle', ['external'], (function (exports) { 'use strict'; var Component; return { setters: [function (module) { Component = module.Component; }], - execute: function () { + execute: (function () { class Foo extends Component { constructor () { @@ -28,10 +28,10 @@ System.register('myBundle', ['external'], function (exports) { } } - const foo = exports('foo', new Foo()); - const bar = exports('bar', new Bar()); - const baz = exports('baz', new Baz()); + const foo = exports("foo", new Foo()); + const bar = exports("bar", new Bar()); + const baz = exports("baz", new Baz()); - } + }) }; -}); +})); diff --git a/test/form/samples/dedupes-external-imports/_expected/umd.js b/test/form/samples/dedupes-external-imports/_expected/umd.js index 740ffc45599..0fc435e239f 100644 --- a/test/form/samples/dedupes-external-imports/_expected/umd.js +++ b/test/form/samples/dedupes-external-imports/_expected/umd.js @@ -2,7 +2,7 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('external')) : typeof define === 'function' && define.amd ? define(['exports', 'external'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.myBundle = {}, global.external)); -}(this, (function (exports, external) { 'use strict'; +})(this, (function (exports, external) { 'use strict'; class Foo extends external.Component { constructor () { @@ -33,6 +33,4 @@ exports.baz = baz; exports.foo = foo; - Object.defineProperty(exports, '__esModule', { value: true }); - -}))); +})); diff --git a/test/form/samples/deep-properties-access/_config.js b/test/form/samples/deep-properties-access/_config.js new file mode 100644 index 00000000000..7b4d8d4a237 --- /dev/null +++ b/test/form/samples/deep-properties-access/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'handles deeply nested property accesses' +}); diff --git a/test/form/samples/deep-properties-access/_expected.js b/test/form/samples/deep-properties-access/_expected.js new file mode 100644 index 00000000000..c1d319eb87d --- /dev/null +++ b/test/form/samples/deep-properties-access/_expected.js @@ -0,0 +1,2 @@ +var obj = { obj: {obj: {obj: {obj: {obj: {obj: {obj: {obj: {obj: {obj: {}}}}}}}}}}}; +console.log(obj.obj.obj.obj.obj.obj.obj.obj.obj.foo); diff --git a/test/form/samples/deep-properties-access/main.js b/test/form/samples/deep-properties-access/main.js new file mode 100644 index 00000000000..c1d319eb87d --- /dev/null +++ b/test/form/samples/deep-properties-access/main.js @@ -0,0 +1,2 @@ +var obj = { obj: {obj: {obj: {obj: {obj: {obj: {obj: {obj: {obj: {obj: {}}}}}}}}}}}; +console.log(obj.obj.obj.obj.obj.obj.obj.obj.obj.foo); diff --git a/test/form/samples/deep-properties/_config.js b/test/form/samples/deep-properties/_config.js new file mode 100644 index 00000000000..57dc036e406 --- /dev/null +++ b/test/form/samples/deep-properties/_config.js @@ -0,0 +1,6 @@ +module.exports = defineTest({ + description: 'handles deeply nested properties', + options: { + treeshake: { propertyReadSideEffects: false } + } +}); diff --git a/test/form/samples/deep-properties/_expected.js b/test/form/samples/deep-properties/_expected.js new file mode 100644 index 00000000000..ea78417e0f4 --- /dev/null +++ b/test/form/samples/deep-properties/_expected.js @@ -0,0 +1,11 @@ +var obj1 = obj1; +console.log(obj1.foo()); + +var obj2 = { obj: {obj: {obj: {obj: {obj: {obj: {obj: {obj: {obj: {obj: {}}}}}}}}}}}; +obj2.obj.obj.obj.obj.obj.obj.obj.foo(); + +var obj3 = { obj: {obj: {obj: {obj: {obj: {obj: {obj: {obj: {obj: {obj: {}}}}}}}}}}}; +if (obj3.obj.obj.obj.obj.obj.obj.obj.obj.foo) console.log('nested'); + +var obj4 = { obj: {obj: {obj: {obj: {obj: {obj: {obj: {obj: {obj: {obj: {}}}}}}}}}}}; +obj4.obj.obj.obj.obj.obj.obj.obj.foo = 'nested'; diff --git a/test/form/samples/deep-properties/main.js b/test/form/samples/deep-properties/main.js new file mode 100644 index 00000000000..ea78417e0f4 --- /dev/null +++ b/test/form/samples/deep-properties/main.js @@ -0,0 +1,11 @@ +var obj1 = obj1; +console.log(obj1.foo()); + +var obj2 = { obj: {obj: {obj: {obj: {obj: {obj: {obj: {obj: {obj: {obj: {}}}}}}}}}}}; +obj2.obj.obj.obj.obj.obj.obj.obj.foo(); + +var obj3 = { obj: {obj: {obj: {obj: {obj: {obj: {obj: {obj: {obj: {obj: {}}}}}}}}}}}; +if (obj3.obj.obj.obj.obj.obj.obj.obj.obj.foo) console.log('nested'); + +var obj4 = { obj: {obj: {obj: {obj: {obj: {obj: {obj: {obj: {obj: {obj: {}}}}}}}}}}}; +obj4.obj.obj.obj.obj.obj.obj.obj.foo = 'nested'; diff --git a/test/form/samples/deep-switch-declarations/_config.js b/test/form/samples/deep-switch-declarations/_config.js new file mode 100644 index 00000000000..889608337ff --- /dev/null +++ b/test/form/samples/deep-switch-declarations/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'handles hoisted declarations in deeply nested switch statements' +}); diff --git a/test/form/samples/deep-switch-declarations/_expected.js b/test/form/samples/deep-switch-declarations/_expected.js new file mode 100644 index 00000000000..4b15e14b28c --- /dev/null +++ b/test/form/samples/deep-switch-declarations/_expected.js @@ -0,0 +1,32 @@ +switch(x){ default: var x=1; + switch(x){ default: var x=2; + switch(x){ default: var x=3; + switch(x){ default: var x=4; + switch(x){ default: var x=5; + switch(x){ default: var x=6; + switch(x){ default: var x=7; + switch(x){ default: var x=8; + switch(x){ default: var x=9; + switch(x){ default: var x=10; + switch(x){ default: var x=11; + switch(x){ default: var x=12; + switch(x){ default: var x=13; + switch(x){ default: var x=14; + switch(x){ default: var x=15; + switch(x){ default: var x=16; + switch(x){ default: var x=17; + switch(x){ default: var x=18; + switch(x){ default: var x=19; + switch(x){ default: var x=20; + switch(x){ default: var x=21; + switch(x){ default: var x=22; + switch(x){ default: var x=23; + switch(x){ default: var x=24; + switch(x){ default: var x=25; + switch(x){ default: var x=26; + switch(x){ default: var x=27; + switch(x){ default: var x=28; + switch(x){ default: var x=29; + switch(x){ default: var x=30; + }}}}}}}}}}}}}}}}}}}}}}}}}}}}}} +console.log(x); diff --git a/test/form/samples/deep-switch-declarations/main.js b/test/form/samples/deep-switch-declarations/main.js new file mode 100644 index 00000000000..03d8f89b61d --- /dev/null +++ b/test/form/samples/deep-switch-declarations/main.js @@ -0,0 +1,32 @@ +switch(x){ default: var x=1; + switch(x){ default: var x=2; + switch(x){ default: var x=3; + switch(x){ default: var x=4; + switch(x){ default: var x=5; + switch(x){ default: var x=6; + switch(x){ default: var x=7; + switch(x){ default: var x=8; + switch(x){ default: var x=9; + switch(x){ default: var x=10; + switch(x){ default: var x=11; + switch(x){ default: var x=12; + switch(x){ default: var x=13; + switch(x){ default: var x=14; + switch(x){ default: var x=15; + switch(x){ default: var x=16; + switch(x){ default: var x=17; + switch(x){ default: var x=18; + switch(x){ default: var x=19; + switch(x){ default: var x=20; + switch(x){ default: var x=21; + switch(x){ default: var x=22; + switch(x){ default: var x=23; + switch(x){ default: var x=24; + switch(x){ default: var x=25; + switch(x){ default: var x=26; + switch(x){ default: var x=27; + switch(x){ default: var x=28; + switch(x){ default: var x=29; + switch(x){ default: var x=30; + }}}}}}}}}}}}}}}}}}}}}}}}}}}}}} +console.log(x); \ No newline at end of file diff --git a/test/form/samples/default-export-anonymous-class-extends/_config.js b/test/form/samples/default-export-anonymous-class-extends/_config.js new file mode 100644 index 00000000000..090c96a8f59 --- /dev/null +++ b/test/form/samples/default-export-anonymous-class-extends/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'handles default exported classes extending a regular expression argument (#4783)' +}); diff --git a/test/form/samples/default-export-anonymous-class-extends/_expected.js b/test/form/samples/default-export-anonymous-class-extends/_expected.js new file mode 100644 index 00000000000..f8f4d1e17a5 --- /dev/null +++ b/test/form/samples/default-export-anonymous-class-extends/_expected.js @@ -0,0 +1,7 @@ +function foo(val) { + return val; +} + +class main extends foo(/1/) {} + +export { main as default }; diff --git a/test/form/samples/default-export-anonymous-class-extends/main.js b/test/form/samples/default-export-anonymous-class-extends/main.js new file mode 100644 index 00000000000..87344a1ea57 --- /dev/null +++ b/test/form/samples/default-export-anonymous-class-extends/main.js @@ -0,0 +1,5 @@ +function foo(val) { + return val; +} + +export default class extends foo(/1/) {} diff --git a/test/form/samples/default-export-class/_config.js b/test/form/samples/default-export-class/_config.js index 0d37406db4c..b665d6b7bfb 100644 --- a/test/form/samples/default-export-class/_config.js +++ b/test/form/samples/default-export-class/_config.js @@ -1,8 +1,8 @@ -module.exports = { +module.exports = defineTest({ description: 'puts the export after the declaration for default exported classes in SystemJS', options: { output: { name: 'bundle' } } -}; +}); diff --git a/test/form/samples/default-export-class/_expected/amd.js b/test/form/samples/default-export-class/_expected/amd.js index 74b32fc6c2b..4b27076c0c4 100644 --- a/test/form/samples/default-export-class/_expected/amd.js +++ b/test/form/samples/default-export-class/_expected/amd.js @@ -1,4 +1,4 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; class main { constructor() { @@ -8,4 +8,4 @@ define(function () { 'use strict'; return main; -}); +})); diff --git a/test/form/samples/default-export-class/_expected/es.js b/test/form/samples/default-export-class/_expected/es.js index 42c0fbaed1d..a40aeb82b7c 100644 --- a/test/form/samples/default-export-class/_expected/es.js +++ b/test/form/samples/default-export-class/_expected/es.js @@ -4,4 +4,4 @@ class main { } } -export default main; +export { main as default }; diff --git a/test/form/samples/default-export-class/_expected/iife.js b/test/form/samples/default-export-class/_expected/iife.js index 2c4c7f70fbb..35ede82148a 100644 --- a/test/form/samples/default-export-class/_expected/iife.js +++ b/test/form/samples/default-export-class/_expected/iife.js @@ -9,4 +9,4 @@ var bundle = (function () { return main; -}()); +})(); diff --git a/test/form/samples/default-export-class/_expected/system.js b/test/form/samples/default-export-class/_expected/system.js index 417f2e3ff17..458541c455a 100644 --- a/test/form/samples/default-export-class/_expected/system.js +++ b/test/form/samples/default-export-class/_expected/system.js @@ -1,14 +1,14 @@ -System.register('bundle', [], function (exports) { +System.register('bundle', [], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { class main { constructor() { console.log('class'); } - } exports('default', main); + } exports("default", main); - } + }) }; -}); +})); diff --git a/test/form/samples/default-export-class/_expected/umd.js b/test/form/samples/default-export-class/_expected/umd.js index abcf315edfa..4ea43442c4c 100644 --- a/test/form/samples/default-export-class/_expected/umd.js +++ b/test/form/samples/default-export-class/_expected/umd.js @@ -2,7 +2,7 @@ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.bundle = factory()); -}(this, (function () { 'use strict'; +})(this, (function () { 'use strict'; class main { constructor() { @@ -12,4 +12,4 @@ return main; -}))); +})); diff --git a/test/form/samples/default-export-live-binding/_config.js b/test/form/samples/default-export-live-binding/_config.js new file mode 100644 index 00000000000..123b4620673 --- /dev/null +++ b/test/form/samples/default-export-live-binding/_config.js @@ -0,0 +1,6 @@ +module.exports = defineTest({ + description: 'allows live bindings for default exports', + options: { + output: { exports: 'named', name: 'bundle' } + } +}); diff --git a/test/form/samples/default-export-live-binding/_expected/amd.js b/test/form/samples/default-export-live-binding/_expected/amd.js new file mode 100644 index 00000000000..e112c6966c8 --- /dev/null +++ b/test/form/samples/default-export-live-binding/_expected/amd.js @@ -0,0 +1,10 @@ +define(['exports'], (function (exports) { 'use strict'; + + exports.default = null; + const setFoo = value => (exports.default = value); + + exports.setFoo = setFoo; + + Object.defineProperty(exports, '__esModule', { value: true }); + +})); diff --git a/test/form/samples/default-export-live-binding/_expected/cjs.js b/test/form/samples/default-export-live-binding/_expected/cjs.js new file mode 100644 index 00000000000..2eb7b4d2111 --- /dev/null +++ b/test/form/samples/default-export-live-binding/_expected/cjs.js @@ -0,0 +1,8 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { value: true }); + +exports.default = null; +const setFoo = value => (exports.default = value); + +exports.setFoo = setFoo; diff --git a/test/form/samples/default-export-live-binding/_expected/es.js b/test/form/samples/default-export-live-binding/_expected/es.js new file mode 100644 index 00000000000..ada29959104 --- /dev/null +++ b/test/form/samples/default-export-live-binding/_expected/es.js @@ -0,0 +1,4 @@ +let foo = null; +const setFoo = value => (foo = value); + +export { foo as default, setFoo }; diff --git a/test/form/samples/default-export-live-binding/_expected/iife.js b/test/form/samples/default-export-live-binding/_expected/iife.js new file mode 100644 index 00000000000..07fdc51f075 --- /dev/null +++ b/test/form/samples/default-export-live-binding/_expected/iife.js @@ -0,0 +1,13 @@ +var bundle = (function (exports) { + 'use strict'; + + exports.default = null; + const setFoo = value => (exports.default = value); + + exports.setFoo = setFoo; + + Object.defineProperty(exports, '__esModule', { value: true }); + + return exports; + +})({}); diff --git a/test/form/samples/default-export-live-binding/_expected/system.js b/test/form/samples/default-export-live-binding/_expected/system.js new file mode 100644 index 00000000000..56cc6b2a16b --- /dev/null +++ b/test/form/samples/default-export-live-binding/_expected/system.js @@ -0,0 +1,11 @@ +System.register('bundle', [], (function (exports) { + 'use strict'; + return { + execute: (function () { + + let foo = exports("default", null); + const setFoo = exports("setFoo", value => (exports("default", foo = value))); + + }) + }; +})); diff --git a/test/form/samples/default-export-live-binding/_expected/umd.js b/test/form/samples/default-export-live-binding/_expected/umd.js new file mode 100644 index 00000000000..463f5501a0a --- /dev/null +++ b/test/form/samples/default-export-live-binding/_expected/umd.js @@ -0,0 +1,14 @@ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : + typeof define === 'function' && define.amd ? define(['exports'], factory) : + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.bundle = {})); +})(this, (function (exports) { 'use strict'; + + exports.default = null; + const setFoo = value => (exports.default = value); + + exports.setFoo = setFoo; + + Object.defineProperty(exports, '__esModule', { value: true }); + +})); diff --git a/test/form/samples/default-export-live-binding/main.js b/test/form/samples/default-export-live-binding/main.js new file mode 100644 index 00000000000..35cb61e045c --- /dev/null +++ b/test/form/samples/default-export-live-binding/main.js @@ -0,0 +1,3 @@ +let foo = null; +const setFoo = value => (foo = value); +export { foo as default, setFoo }; diff --git a/test/form/samples/default-export-mode/_config.js b/test/form/samples/default-export-mode/_config.js index bc4638b956c..c3e9935ba77 100644 --- a/test/form/samples/default-export-mode/_config.js +++ b/test/form/samples/default-export-mode/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'allows specifying the export mode to be "default"', options: { output: { @@ -6,4 +6,4 @@ module.exports = { name: 'bundle' } } -}; +}); diff --git a/test/form/samples/default-export-mode/_expected/amd.js b/test/form/samples/default-export-mode/_expected/amd.js index 37d25711e09..538fc7738a6 100644 --- a/test/form/samples/default-export-mode/_expected/amd.js +++ b/test/form/samples/default-export-mode/_expected/amd.js @@ -1,7 +1,7 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; var main = 42; return main; -}); +})); diff --git a/test/form/samples/default-export-mode/_expected/es.js b/test/form/samples/default-export-mode/_expected/es.js index d862de816a3..c3e30233192 100644 --- a/test/form/samples/default-export-mode/_expected/es.js +++ b/test/form/samples/default-export-mode/_expected/es.js @@ -1,3 +1,3 @@ var main = 42; -export default main; +export { main as default }; diff --git a/test/form/samples/default-export-mode/_expected/iife.js b/test/form/samples/default-export-mode/_expected/iife.js index 3578ebdc148..587b0a95fce 100644 --- a/test/form/samples/default-export-mode/_expected/iife.js +++ b/test/form/samples/default-export-mode/_expected/iife.js @@ -5,4 +5,4 @@ var bundle = (function () { return main; -}()); +})(); diff --git a/test/form/samples/default-export-mode/_expected/system.js b/test/form/samples/default-export-mode/_expected/system.js index 6d902c53457..f8768fe4d50 100644 --- a/test/form/samples/default-export-mode/_expected/system.js +++ b/test/form/samples/default-export-mode/_expected/system.js @@ -1,10 +1,10 @@ -System.register('bundle', [], function (exports) { +System.register('bundle', [], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - var main = exports('default', 42); + var main = exports("default", 42); - } + }) }; -}); +})); diff --git a/test/form/samples/default-export-mode/_expected/umd.js b/test/form/samples/default-export-mode/_expected/umd.js index 0bfa722997b..f0c0c0dd3f5 100644 --- a/test/form/samples/default-export-mode/_expected/umd.js +++ b/test/form/samples/default-export-mode/_expected/umd.js @@ -2,10 +2,10 @@ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.bundle = factory()); -}(this, (function () { 'use strict'; +})(this, (function () { 'use strict'; var main = 42; return main; -}))); +})); diff --git a/test/form/samples/default-identifier-deshadowing/_config.js b/test/form/samples/default-identifier-deshadowing/_config.js index 0b3f4bc1169..ed2c7173d11 100644 --- a/test/form/samples/default-identifier-deshadowing/_config.js +++ b/test/form/samples/default-identifier-deshadowing/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'Handles export default identifier reassignment deshadowing' -}; +}); diff --git a/test/form/samples/default-identifier-deshadowing/_expected/amd.js b/test/form/samples/default-identifier-deshadowing/_expected/amd.js index 230f6ee680b..09b1c3a5d00 100644 --- a/test/form/samples/default-identifier-deshadowing/_expected/amd.js +++ b/test/form/samples/default-identifier-deshadowing/_expected/amd.js @@ -1,4 +1,4 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; function a() { a = someGlobal; @@ -7,4 +7,4 @@ define(function () { 'use strict'; a(); -}); +})); diff --git a/test/form/samples/default-identifier-deshadowing/_expected/iife.js b/test/form/samples/default-identifier-deshadowing/_expected/iife.js index 2648f6d25d3..dfd62b01595 100644 --- a/test/form/samples/default-identifier-deshadowing/_expected/iife.js +++ b/test/form/samples/default-identifier-deshadowing/_expected/iife.js @@ -8,4 +8,4 @@ a(); -}()); +})(); diff --git a/test/form/samples/default-identifier-deshadowing/_expected/system.js b/test/form/samples/default-identifier-deshadowing/_expected/system.js index 874a7969d81..ec805795621 100644 --- a/test/form/samples/default-identifier-deshadowing/_expected/system.js +++ b/test/form/samples/default-identifier-deshadowing/_expected/system.js @@ -1,7 +1,7 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { function a() { a = someGlobal; @@ -10,6 +10,6 @@ System.register([], function () { a(); - } + }) }; -}); +})); diff --git a/test/form/samples/default-identifier-deshadowing/_expected/umd.js b/test/form/samples/default-identifier-deshadowing/_expected/umd.js index 84fe8f702f8..0a402ebb5a9 100644 --- a/test/form/samples/default-identifier-deshadowing/_expected/umd.js +++ b/test/form/samples/default-identifier-deshadowing/_expected/umd.js @@ -1,7 +1,7 @@ (function (factory) { typeof define === 'function' && define.amd ? define(factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; function a() { a = someGlobal; @@ -10,4 +10,4 @@ a(); -}))); +})); diff --git a/test/form/samples/define-es-modules-false/_config.js b/test/form/samples/define-es-modules-false/_config.js index a1638543113..332ff8fb294 100644 --- a/test/form/samples/define-es-modules-false/_config.js +++ b/test/form/samples/define-es-modules-false/_config.js @@ -1,6 +1,6 @@ -module.exports = { +module.exports = defineTest({ description: 'Not add __esModule property to exports with esModule: false', options: { - output: { name: 'foo', esModule: false }, + output: { name: 'foo', esModule: false } } -}; +}); diff --git a/test/form/samples/define-es-modules-false/_expected/amd.js b/test/form/samples/define-es-modules-false/_expected/amd.js index ce1360181eb..8677959a047 100644 --- a/test/form/samples/define-es-modules-false/_expected/amd.js +++ b/test/form/samples/define-es-modules-false/_expected/amd.js @@ -1,4 +1,4 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; const make1 = () => {}; @@ -7,4 +7,4 @@ define(['exports'], function (exports) { 'use strict'; exports.make1 = make1; exports.make2 = make2; -}); +})); diff --git a/test/form/samples/define-es-modules-false/_expected/iife.js b/test/form/samples/define-es-modules-false/_expected/iife.js index 1968288c091..052cc3dfd4b 100644 --- a/test/form/samples/define-es-modules-false/_expected/iife.js +++ b/test/form/samples/define-es-modules-false/_expected/iife.js @@ -10,4 +10,4 @@ var foo = (function (exports) { return exports; -}({})); +})({}); diff --git a/test/form/samples/define-es-modules-false/_expected/system.js b/test/form/samples/define-es-modules-false/_expected/system.js index e615e3599d0..0c8113ea6ca 100644 --- a/test/form/samples/define-es-modules-false/_expected/system.js +++ b/test/form/samples/define-es-modules-false/_expected/system.js @@ -1,12 +1,12 @@ -System.register('foo', [], function (exports) { +System.register('foo', [], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - const make1 = exports('make1', () => {}); + const make1 = exports("make1", () => {}); - const make2 = exports('make2', () => {}); + const make2 = exports("make2", () => {}); - } + }) }; -}); +})); diff --git a/test/form/samples/define-es-modules-false/_expected/umd.js b/test/form/samples/define-es-modules-false/_expected/umd.js index 17898ff1ef2..5657e9662bc 100644 --- a/test/form/samples/define-es-modules-false/_expected/umd.js +++ b/test/form/samples/define-es-modules-false/_expected/umd.js @@ -2,7 +2,7 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.foo = {})); -}(this, (function (exports) { 'use strict'; +})(this, (function (exports) { 'use strict'; const make1 = () => {}; @@ -11,4 +11,4 @@ exports.make1 = make1; exports.make2 = make2; -}))); +})); diff --git a/test/form/samples/define-replacement/_config.js b/test/form/samples/define-replacement/_config.js index f9a9a68462f..6920038fcff 100644 --- a/test/form/samples/define-replacement/_config.js +++ b/test/form/samples/define-replacement/_config.js @@ -1,8 +1,8 @@ -module.exports = { +module.exports = defineTest({ description: 'amd.define', options: { output: { amd: { define: 'enifed' } } } -}; +}); diff --git a/test/form/samples/define-replacement/_expected/amd.js b/test/form/samples/define-replacement/_expected/amd.js index 59833b03363..b5cfe37c560 100644 --- a/test/form/samples/define-replacement/_expected/amd.js +++ b/test/form/samples/define-replacement/_expected/amd.js @@ -1,4 +1,4 @@ -enifed(function () { 'use strict'; +enifed((function () { 'use strict'; var a = () => { console.log('props'); @@ -7,4 +7,4 @@ enifed(function () { 'use strict'; a(); a(); -}); +})); diff --git a/test/form/samples/define-replacement/_expected/iife.js b/test/form/samples/define-replacement/_expected/iife.js index 46c38fba33b..c6900c648ca 100644 --- a/test/form/samples/define-replacement/_expected/iife.js +++ b/test/form/samples/define-replacement/_expected/iife.js @@ -8,4 +8,4 @@ a(); a(); -}()); +})(); diff --git a/test/form/samples/define-replacement/_expected/system.js b/test/form/samples/define-replacement/_expected/system.js index 349af935327..32ad9c3e7e2 100644 --- a/test/form/samples/define-replacement/_expected/system.js +++ b/test/form/samples/define-replacement/_expected/system.js @@ -1,7 +1,7 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { var a = () => { console.log('props'); @@ -10,6 +10,6 @@ System.register([], function () { a(); a(); - } + }) }; -}); +})); diff --git a/test/form/samples/define-replacement/_expected/umd.js b/test/form/samples/define-replacement/_expected/umd.js index 494fde64074..e821769cd88 100644 --- a/test/form/samples/define-replacement/_expected/umd.js +++ b/test/form/samples/define-replacement/_expected/umd.js @@ -1,7 +1,7 @@ (function (factory) { typeof enifed === 'function' && enifed.amd ? enifed(factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; var a = () => { console.log('props'); @@ -10,4 +10,4 @@ a(); a(); -}))); +})); diff --git a/test/form/samples/deopt-regexp-type/_config.js b/test/form/samples/deopt-regexp-type/_config.js index 18ccd606be5..5745d07af27 100644 --- a/test/form/samples/deopt-regexp-type/_config.js +++ b/test/form/samples/deopt-regexp-type/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'deoptimizes typeof for regular expressions to better support es6-sim' -}; +}); diff --git a/test/form/samples/deopt-string-concatenation/_config.js b/test/form/samples/deopt-string-concatenation/_config.js index 36697ba2394..1326c114d68 100644 --- a/test/form/samples/deopt-string-concatenation/_config.js +++ b/test/form/samples/deopt-string-concatenation/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'deoptimize concatenation when used as an expression statement to better support es5-shim' -}; +}); diff --git a/test/form/samples/deopt-string-concatenation/_expected.js b/test/form/samples/deopt-string-concatenation/_expected.js index 68a30dc4f66..42785de7340 100644 --- a/test/form/samples/deopt-string-concatenation/_expected.js +++ b/test/form/samples/deopt-string-concatenation/_expected.js @@ -9,3 +9,4 @@ function parseInt(str, radix) { } console.log(parseInt('1')); +console.log(parseInt(Symbol('1'))); diff --git a/test/form/samples/deopt-string-concatenation/main.js b/test/form/samples/deopt-string-concatenation/main.js index 68a30dc4f66..42785de7340 100644 --- a/test/form/samples/deopt-string-concatenation/main.js +++ b/test/form/samples/deopt-string-concatenation/main.js @@ -9,3 +9,4 @@ function parseInt(str, radix) { } console.log(parseInt('1')); +console.log(parseInt(Symbol('1'))); diff --git a/test/form/samples/deoptimize-superclass/_config.js b/test/form/samples/deoptimize-superclass/_config.js new file mode 100644 index 00000000000..de245c1cb5b --- /dev/null +++ b/test/form/samples/deoptimize-superclass/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'does not deoptimize the entire superclass when reassigning a property' +}); diff --git a/test/form/samples/deoptimize-superclass/_expected.js b/test/form/samples/deoptimize-superclass/_expected.js new file mode 100644 index 00000000000..32b6ab236d7 --- /dev/null +++ b/test/form/samples/deoptimize-superclass/_expected.js @@ -0,0 +1,2 @@ +// Everything else should be removed +console.log('retained'); diff --git a/test/form/samples/deoptimize-superclass/main.js b/test/form/samples/deoptimize-superclass/main.js new file mode 100644 index 00000000000..bce385b816e --- /dev/null +++ b/test/form/samples/deoptimize-superclass/main.js @@ -0,0 +1,10 @@ +class Foo {} + +Foo.prototype.bar = {}; + +class Bar extends Foo {} + +Bar.baz = {}; + +// Everything else should be removed +console.log('retained'); diff --git a/test/form/samples/deoptimize-var-in-hoisted-scopes/_config.js b/test/form/samples/deoptimize-var-in-hoisted-scopes/_config.js new file mode 100644 index 00000000000..47826267e90 --- /dev/null +++ b/test/form/samples/deoptimize-var-in-hoisted-scopes/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'deoptimizes var variables in hoisted scopes' +}); diff --git a/test/form/samples/deoptimize-var-in-hoisted-scopes/_expected.js b/test/form/samples/deoptimize-var-in-hoisted-scopes/_expected.js new file mode 100644 index 00000000000..fc12a80c520 --- /dev/null +++ b/test/form/samples/deoptimize-var-in-hoisted-scopes/_expected.js @@ -0,0 +1,15 @@ +const obj1 = { flag: false }; +{ + var foo = obj1; + foo.flag = true; +} +if (obj1.flag) console.log('retained'); + +const obj2 = { flag: false }; +try { + throw new Error(); +} catch { + var foo = obj2; + foo.flag = true; +} +if (obj2.flag) console.log('retained'); diff --git a/test/form/samples/deoptimize-var-in-hoisted-scopes/main.js b/test/form/samples/deoptimize-var-in-hoisted-scopes/main.js new file mode 100644 index 00000000000..fc12a80c520 --- /dev/null +++ b/test/form/samples/deoptimize-var-in-hoisted-scopes/main.js @@ -0,0 +1,15 @@ +const obj1 = { flag: false }; +{ + var foo = obj1; + foo.flag = true; +} +if (obj1.flag) console.log('retained'); + +const obj2 = { flag: false }; +try { + throw new Error(); +} catch { + var foo = obj2; + foo.flag = true; +} +if (obj2.flag) console.log('retained'); diff --git a/test/form/samples/deprecated/configure-asset-url/_config.js b/test/form/samples/deprecated/configure-asset-url/_config.js deleted file mode 100644 index 56f8d0d0398..00000000000 --- a/test/form/samples/deprecated/configure-asset-url/_config.js +++ /dev/null @@ -1,40 +0,0 @@ -module.exports = { - description: 'allows to configure asset urls', - expectedWarnings: ['DEPRECATED_FEATURE'], - options: { - strictDeprecations: false, - plugins: [ - { - resolveId(id) { - if (id.endsWith('solved')) { - return id; - } - }, - load(id) { - if (id.endsWith('solved')) { - const assetId = this.emitAsset(`asset-${id}.txt`, `Asset for: ${id}`); - return `export default import.meta.ROLLUP_ASSET_URL_${assetId};`; - } - }, - resolveAssetUrl({ chunkId, moduleId, assetFileName, relativeAssetPath }) { - if (!moduleId.endsWith('resolved')) { - return `'${chunkId}:${moduleId - .replace(/\\/g, '/') - .split('/') - .slice(-2) - .join('/')}:${assetFileName}:${relativeAssetPath}'`; - } - return null; - } - }, - { - resolveAssetUrl({ moduleId }) { - if (moduleId === 'resolved') { - return `'resolved'`; - } - return null; - } - } - ] - } -}; diff --git a/test/form/samples/deprecated/configure-asset-url/_expected/amd.js b/test/form/samples/deprecated/configure-asset-url/_expected/amd.js deleted file mode 100644 index 60d09eb0292..00000000000 --- a/test/form/samples/deprecated/configure-asset-url/_expected/amd.js +++ /dev/null @@ -1,11 +0,0 @@ -define(['require'], function (require) { 'use strict'; - - var asset1 = 'amd.js:solved:assets/asset-solved-28a7ac89.txt:assets/asset-solved-28a7ac89.txt'; - - var asset2 = 'resolved'; - - var asset3 = new URL(require.toUrl('./assets/asset-unresolved-8dcd7fca.txt'), document.baseURI).href; - - console.log(asset1, asset2, asset3); - -}); diff --git a/test/form/samples/deprecated/configure-asset-url/_expected/assets/asset-resolved-8bd22e6e.txt b/test/form/samples/deprecated/configure-asset-url/_expected/assets/asset-resolved-8bd22e6e.txt deleted file mode 100644 index 31fb300f988..00000000000 --- a/test/form/samples/deprecated/configure-asset-url/_expected/assets/asset-resolved-8bd22e6e.txt +++ /dev/null @@ -1 +0,0 @@ -Asset for: resolved \ No newline at end of file diff --git a/test/form/samples/deprecated/configure-asset-url/_expected/assets/asset-solved-28a7ac89.txt b/test/form/samples/deprecated/configure-asset-url/_expected/assets/asset-solved-28a7ac89.txt deleted file mode 100644 index 07c7a096c7e..00000000000 --- a/test/form/samples/deprecated/configure-asset-url/_expected/assets/asset-solved-28a7ac89.txt +++ /dev/null @@ -1 +0,0 @@ -Asset for: solved \ No newline at end of file diff --git a/test/form/samples/deprecated/configure-asset-url/_expected/assets/asset-unresolved-8dcd7fca.txt b/test/form/samples/deprecated/configure-asset-url/_expected/assets/asset-unresolved-8dcd7fca.txt deleted file mode 100644 index fd3ad6261cc..00000000000 --- a/test/form/samples/deprecated/configure-asset-url/_expected/assets/asset-unresolved-8dcd7fca.txt +++ /dev/null @@ -1 +0,0 @@ -Asset for: unresolved \ No newline at end of file diff --git a/test/form/samples/deprecated/configure-asset-url/_expected/cjs.js b/test/form/samples/deprecated/configure-asset-url/_expected/cjs.js deleted file mode 100644 index bdd515403db..00000000000 --- a/test/form/samples/deprecated/configure-asset-url/_expected/cjs.js +++ /dev/null @@ -1,9 +0,0 @@ -'use strict'; - -var asset1 = 'cjs.js:solved:assets/asset-solved-28a7ac89.txt:assets/asset-solved-28a7ac89.txt'; - -var asset2 = 'resolved'; - -var asset3 = (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __dirname + '/assets/asset-unresolved-8dcd7fca.txt').href : new URL('assets/asset-unresolved-8dcd7fca.txt', document.currentScript && document.currentScript.src || document.baseURI).href); - -console.log(asset1, asset2, asset3); diff --git a/test/form/samples/deprecated/configure-asset-url/_expected/es.js b/test/form/samples/deprecated/configure-asset-url/_expected/es.js deleted file mode 100644 index 35ee8b1dee0..00000000000 --- a/test/form/samples/deprecated/configure-asset-url/_expected/es.js +++ /dev/null @@ -1,7 +0,0 @@ -var asset1 = 'es.js:solved:assets/asset-solved-28a7ac89.txt:assets/asset-solved-28a7ac89.txt'; - -var asset2 = 'resolved'; - -var asset3 = new URL('assets/asset-unresolved-8dcd7fca.txt', import.meta.url).href; - -console.log(asset1, asset2, asset3); diff --git a/test/form/samples/deprecated/configure-asset-url/_expected/iife.js b/test/form/samples/deprecated/configure-asset-url/_expected/iife.js deleted file mode 100644 index 6ff9d4359f2..00000000000 --- a/test/form/samples/deprecated/configure-asset-url/_expected/iife.js +++ /dev/null @@ -1,12 +0,0 @@ -(function () { - 'use strict'; - - var asset1 = 'iife.js:solved:assets/asset-solved-28a7ac89.txt:assets/asset-solved-28a7ac89.txt'; - - var asset2 = 'resolved'; - - var asset3 = new URL('assets/asset-unresolved-8dcd7fca.txt', document.currentScript && document.currentScript.src || document.baseURI).href; - - console.log(asset1, asset2, asset3); - -}()); diff --git a/test/form/samples/deprecated/configure-asset-url/_expected/system.js b/test/form/samples/deprecated/configure-asset-url/_expected/system.js deleted file mode 100644 index f875262689a..00000000000 --- a/test/form/samples/deprecated/configure-asset-url/_expected/system.js +++ /dev/null @@ -1,16 +0,0 @@ -System.register([], function (exports, module) { - 'use strict'; - return { - execute: function () { - - var asset1 = 'system.js:solved:assets/asset-solved-28a7ac89.txt:assets/asset-solved-28a7ac89.txt'; - - var asset2 = 'resolved'; - - var asset3 = new URL('assets/asset-unresolved-8dcd7fca.txt', module.meta.url).href; - - console.log(asset1, asset2, asset3); - - } - }; -}); diff --git a/test/form/samples/deprecated/configure-asset-url/_expected/umd.js b/test/form/samples/deprecated/configure-asset-url/_expected/umd.js deleted file mode 100644 index 203e93624e1..00000000000 --- a/test/form/samples/deprecated/configure-asset-url/_expected/umd.js +++ /dev/null @@ -1,14 +0,0 @@ -(function (factory) { - typeof define === 'function' && define.amd ? define(factory) : - factory(); -}((function () { 'use strict'; - - var asset1 = 'umd.js:solved:assets/asset-solved-28a7ac89.txt:assets/asset-solved-28a7ac89.txt'; - - var asset2 = 'resolved'; - - var asset3 = (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __dirname + '/assets/asset-unresolved-8dcd7fca.txt').href : new URL('assets/asset-unresolved-8dcd7fca.txt', document.currentScript && document.currentScript.src || document.baseURI).href); - - console.log(asset1, asset2, asset3); - -}))); diff --git a/test/form/samples/deprecated/configure-asset-url/main.js b/test/form/samples/deprecated/configure-asset-url/main.js deleted file mode 100644 index 74a56461e3a..00000000000 --- a/test/form/samples/deprecated/configure-asset-url/main.js +++ /dev/null @@ -1,5 +0,0 @@ -import asset1 from 'solved'; -import asset2 from 'resolved'; -import asset3 from 'unresolved'; - -console.log(asset1, asset2, asset3); diff --git a/test/form/samples/deprecated/dynamic-import-inlining-array/_config.js b/test/form/samples/deprecated/dynamic-import-inlining-array/_config.js deleted file mode 100644 index 5f4382d6a8b..00000000000 --- a/test/form/samples/deprecated/dynamic-import-inlining-array/_config.js +++ /dev/null @@ -1,8 +0,0 @@ -module.exports = { - description: 'supports an array with a single entry when inlining dynamic imports', - options: { - strictDeprecations: false, - inlineDynamicImports: true, - input: ['main'] - } -}; diff --git a/test/form/samples/deprecated/dynamic-import-inlining-array/_expected.js b/test/form/samples/deprecated/dynamic-import-inlining-array/_expected.js deleted file mode 100644 index ae434046e6c..00000000000 --- a/test/form/samples/deprecated/dynamic-import-inlining-array/_expected.js +++ /dev/null @@ -1,11 +0,0 @@ -const bar = 2; -Promise.resolve().then(function () { return foo$1; }); - -const foo = 1; - -var foo$1 = /*#__PURE__*/Object.freeze({ - __proto__: null, - foo: foo -}); - -export { bar }; diff --git a/test/form/samples/deprecated/dynamic-import-inlining-array/foo.js b/test/form/samples/deprecated/dynamic-import-inlining-array/foo.js deleted file mode 100644 index 6a8018af412..00000000000 --- a/test/form/samples/deprecated/dynamic-import-inlining-array/foo.js +++ /dev/null @@ -1 +0,0 @@ -export const foo = 1; \ No newline at end of file diff --git a/test/form/samples/deprecated/dynamic-import-inlining-array/main.js b/test/form/samples/deprecated/dynamic-import-inlining-array/main.js deleted file mode 100644 index ee3e6a770d6..00000000000 --- a/test/form/samples/deprecated/dynamic-import-inlining-array/main.js +++ /dev/null @@ -1,2 +0,0 @@ -export const bar = 2; -import('./foo.js'); diff --git a/test/form/samples/deprecated/dynamic-import-inlining/_config.js b/test/form/samples/deprecated/dynamic-import-inlining/_config.js deleted file mode 100644 index 42be3fab8a0..00000000000 --- a/test/form/samples/deprecated/dynamic-import-inlining/_config.js +++ /dev/null @@ -1,7 +0,0 @@ -module.exports = { - description: 'dynamic import inlining', - options: { - strictDeprecations: false, - inlineDynamicImports: true - } -}; diff --git a/test/form/samples/deprecated/dynamic-import-inlining/_expected.js b/test/form/samples/deprecated/dynamic-import-inlining/_expected.js deleted file mode 100644 index ae434046e6c..00000000000 --- a/test/form/samples/deprecated/dynamic-import-inlining/_expected.js +++ /dev/null @@ -1,11 +0,0 @@ -const bar = 2; -Promise.resolve().then(function () { return foo$1; }); - -const foo = 1; - -var foo$1 = /*#__PURE__*/Object.freeze({ - __proto__: null, - foo: foo -}); - -export { bar }; diff --git a/test/form/samples/deprecated/dynamic-import-inlining/foo.js b/test/form/samples/deprecated/dynamic-import-inlining/foo.js deleted file mode 100644 index 6a8018af412..00000000000 --- a/test/form/samples/deprecated/dynamic-import-inlining/foo.js +++ /dev/null @@ -1 +0,0 @@ -export const foo = 1; \ No newline at end of file diff --git a/test/form/samples/deprecated/dynamic-import-inlining/main.js b/test/form/samples/deprecated/dynamic-import-inlining/main.js deleted file mode 100644 index ee3e6a770d6..00000000000 --- a/test/form/samples/deprecated/dynamic-import-inlining/main.js +++ /dev/null @@ -1,2 +0,0 @@ -export const bar = 2; -import('./foo.js'); diff --git a/test/form/samples/deprecated/emit-asset-hacky/_config.js b/test/form/samples/deprecated/emit-asset-hacky/_config.js deleted file mode 100644 index 15b90c920a6..00000000000 --- a/test/form/samples/deprecated/emit-asset-hacky/_config.js +++ /dev/null @@ -1,17 +0,0 @@ -module.exports = { - description: 'supports emitting assets in a hacky way by editing the bundle object', - expectedWarnings: ['DEPRECATED_FEATURE'], - options: { - strictDeprecations: false, - plugins: { - generateBundle(options, outputBundle) { - const file = { - fileName: 'my-hacky-asset.txt', - isAsset: true, - source: 'My Hacky Source' - }; - outputBundle[file.fileName] = file; - } - } - } -}; diff --git a/test/form/samples/deprecated/emit-asset-hacky/_expected/amd.js b/test/form/samples/deprecated/emit-asset-hacky/_expected/amd.js deleted file mode 100644 index 126aa22ee83..00000000000 --- a/test/form/samples/deprecated/emit-asset-hacky/_expected/amd.js +++ /dev/null @@ -1,5 +0,0 @@ -define(function () { 'use strict'; - - console.log('main'); - -}); diff --git a/test/form/samples/deprecated/emit-asset-hacky/_expected/iife.js b/test/form/samples/deprecated/emit-asset-hacky/_expected/iife.js deleted file mode 100644 index d283cbce8ba..00000000000 --- a/test/form/samples/deprecated/emit-asset-hacky/_expected/iife.js +++ /dev/null @@ -1,6 +0,0 @@ -(function () { - 'use strict'; - - console.log('main'); - -}()); diff --git a/test/form/samples/deprecated/emit-asset-hacky/_expected/my-hacky-asset.txt b/test/form/samples/deprecated/emit-asset-hacky/_expected/my-hacky-asset.txt deleted file mode 100644 index 61db1bb6537..00000000000 --- a/test/form/samples/deprecated/emit-asset-hacky/_expected/my-hacky-asset.txt +++ /dev/null @@ -1 +0,0 @@ -My Hacky Source \ No newline at end of file diff --git a/test/form/samples/deprecated/emit-asset-hacky/_expected/system.js b/test/form/samples/deprecated/emit-asset-hacky/_expected/system.js deleted file mode 100644 index c83499bc2d4..00000000000 --- a/test/form/samples/deprecated/emit-asset-hacky/_expected/system.js +++ /dev/null @@ -1,10 +0,0 @@ -System.register([], function () { - 'use strict'; - return { - execute: function () { - - console.log('main'); - - } - }; -}); diff --git a/test/form/samples/deprecated/emit-asset-hacky/_expected/umd.js b/test/form/samples/deprecated/emit-asset-hacky/_expected/umd.js deleted file mode 100644 index f69e11c0256..00000000000 --- a/test/form/samples/deprecated/emit-asset-hacky/_expected/umd.js +++ /dev/null @@ -1,8 +0,0 @@ -(function (factory) { - typeof define === 'function' && define.amd ? define(factory) : - factory(); -}((function () { 'use strict'; - - console.log('main'); - -}))); diff --git a/test/form/samples/deprecated/emit-asset/_config.js b/test/form/samples/deprecated/emit-asset/_config.js deleted file mode 100644 index e17ea0f8934..00000000000 --- a/test/form/samples/deprecated/emit-asset/_config.js +++ /dev/null @@ -1,40 +0,0 @@ -const fs = require('fs'); -const path = require('path'); -const assert = require('assert'); - -module.exports = { - description: 'supports emitting assets from plugin hooks', - expectedWarnings: ['DEPRECATED_FEATURE'], - options: { - strictDeprecations: false, - plugins: { - resolveId(id, importee) { - if (id.endsWith('.svg')) { - return path.resolve(path.dirname(importee), id); - } - }, - load(id) { - if (id.endsWith('.svg')) { - return `export default import.meta.ROLLUP_ASSET_URL_${this.emitAsset( - path.basename(id), - fs.readFileSync(id) - )};`; - } - }, - generateBundle(options, outputBundle) { - const keys = Object.keys(outputBundle); - assert.strictEqual(keys.length, 2); - assert.strictEqual(keys[0], 'assets/logo-25585ac1.svg'); - const asset = outputBundle[keys[0]]; - assert.strictEqual(asset.fileName, 'assets/logo-25585ac1.svg'); - assert.strictEqual(asset.isAsset, true); - assert.strictEqual(asset.type, 'asset'); - assert.ok( - asset.source.equals(fs.readFileSync(path.resolve(__dirname, 'logo.svg'))), - 'asset has correct source' - ); - assert.ok(keys[1].endsWith('.js'), `${keys[1]} ends with ".js"`); - } - } - } -}; diff --git a/test/form/samples/deprecated/emit-asset/_expected/amd.js b/test/form/samples/deprecated/emit-asset/_expected/amd.js deleted file mode 100644 index 36634121098..00000000000 --- a/test/form/samples/deprecated/emit-asset/_expected/amd.js +++ /dev/null @@ -1,16 +0,0 @@ -define(['require'], function (require) { 'use strict'; - - var logo = new URL(require.toUrl('./assets/logo-25585ac1.svg'), document.baseURI).href; - - function showImage(url) { - console.log(url); - if (typeof document !== 'undefined') { - const image = document.createElement('img'); - image.src = url; - document.body.appendChild(image); - } - } - - showImage(logo); - -}); diff --git a/test/form/samples/deprecated/emit-asset/_expected/cjs.js b/test/form/samples/deprecated/emit-asset/_expected/cjs.js deleted file mode 100644 index f9a9dac3e1e..00000000000 --- a/test/form/samples/deprecated/emit-asset/_expected/cjs.js +++ /dev/null @@ -1,14 +0,0 @@ -'use strict'; - -var logo = (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __dirname + '/assets/logo-25585ac1.svg').href : new URL('assets/logo-25585ac1.svg', document.currentScript && document.currentScript.src || document.baseURI).href); - -function showImage(url) { - console.log(url); - if (typeof document !== 'undefined') { - const image = document.createElement('img'); - image.src = url; - document.body.appendChild(image); - } -} - -showImage(logo); diff --git a/test/form/samples/deprecated/emit-asset/_expected/es.js b/test/form/samples/deprecated/emit-asset/_expected/es.js deleted file mode 100644 index d100d42e367..00000000000 --- a/test/form/samples/deprecated/emit-asset/_expected/es.js +++ /dev/null @@ -1,12 +0,0 @@ -var logo = new URL('assets/logo-25585ac1.svg', import.meta.url).href; - -function showImage(url) { - console.log(url); - if (typeof document !== 'undefined') { - const image = document.createElement('img'); - image.src = url; - document.body.appendChild(image); - } -} - -showImage(logo); diff --git a/test/form/samples/deprecated/emit-asset/_expected/iife.js b/test/form/samples/deprecated/emit-asset/_expected/iife.js deleted file mode 100644 index 97c9c3432a2..00000000000 --- a/test/form/samples/deprecated/emit-asset/_expected/iife.js +++ /dev/null @@ -1,17 +0,0 @@ -(function () { - 'use strict'; - - var logo = new URL('assets/logo-25585ac1.svg', document.currentScript && document.currentScript.src || document.baseURI).href; - - function showImage(url) { - console.log(url); - if (typeof document !== 'undefined') { - const image = document.createElement('img'); - image.src = url; - document.body.appendChild(image); - } - } - - showImage(logo); - -}()); diff --git a/test/form/samples/deprecated/emit-asset/_expected/system.js b/test/form/samples/deprecated/emit-asset/_expected/system.js deleted file mode 100644 index 0c3f132dc7f..00000000000 --- a/test/form/samples/deprecated/emit-asset/_expected/system.js +++ /dev/null @@ -1,21 +0,0 @@ -System.register([], function (exports, module) { - 'use strict'; - return { - execute: function () { - - var logo = new URL('assets/logo-25585ac1.svg', module.meta.url).href; - - function showImage(url) { - console.log(url); - if (typeof document !== 'undefined') { - const image = document.createElement('img'); - image.src = url; - document.body.appendChild(image); - } - } - - showImage(logo); - - } - }; -}); diff --git a/test/form/samples/deprecated/emit-asset/_expected/umd.js b/test/form/samples/deprecated/emit-asset/_expected/umd.js deleted file mode 100644 index 313ffcb5169..00000000000 --- a/test/form/samples/deprecated/emit-asset/_expected/umd.js +++ /dev/null @@ -1,19 +0,0 @@ -(function (factory) { - typeof define === 'function' && define.amd ? define(factory) : - factory(); -}((function () { 'use strict'; - - var logo = (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __dirname + '/assets/logo-25585ac1.svg').href : new URL('assets/logo-25585ac1.svg', document.currentScript && document.currentScript.src || document.baseURI).href); - - function showImage(url) { - console.log(url); - if (typeof document !== 'undefined') { - const image = document.createElement('img'); - image.src = url; - document.body.appendChild(image); - } - } - - showImage(logo); - -}))); diff --git a/test/form/samples/deprecated/emit-asset/index-amd.html b/test/form/samples/deprecated/emit-asset/index-amd.html deleted file mode 100644 index 14c7c2fa4ac..00000000000 --- a/test/form/samples/deprecated/emit-asset/index-amd.html +++ /dev/null @@ -1,10 +0,0 @@ - - - - - AMD - - - - - diff --git a/test/form/samples/deprecated/emit-asset/index-cjs.html b/test/form/samples/deprecated/emit-asset/index-cjs.html deleted file mode 100644 index c5b18ec148f..00000000000 --- a/test/form/samples/deprecated/emit-asset/index-cjs.html +++ /dev/null @@ -1,10 +0,0 @@ - - - - - CommonJS - - - - - diff --git a/test/form/samples/deprecated/emit-asset/index-es.html b/test/form/samples/deprecated/emit-asset/index-es.html deleted file mode 100644 index 5079fce53d8..00000000000 --- a/test/form/samples/deprecated/emit-asset/index-es.html +++ /dev/null @@ -1,10 +0,0 @@ - - - - - ES Module - - - - - diff --git a/test/form/samples/deprecated/emit-asset/index-iife.html b/test/form/samples/deprecated/emit-asset/index-iife.html deleted file mode 100644 index aaf475f1505..00000000000 --- a/test/form/samples/deprecated/emit-asset/index-iife.html +++ /dev/null @@ -1,10 +0,0 @@ - - - - - IIFE - - - - - diff --git a/test/form/samples/deprecated/emit-asset/index-system.html b/test/form/samples/deprecated/emit-asset/index-system.html deleted file mode 100644 index 750eabdba25..00000000000 --- a/test/form/samples/deprecated/emit-asset/index-system.html +++ /dev/null @@ -1,11 +0,0 @@ - - - - - SystemJS - - - - - - diff --git a/test/form/samples/deprecated/emit-asset/index-umd-amd.html b/test/form/samples/deprecated/emit-asset/index-umd-amd.html deleted file mode 100644 index e7c9217ece0..00000000000 --- a/test/form/samples/deprecated/emit-asset/index-umd-amd.html +++ /dev/null @@ -1,10 +0,0 @@ - - - - - UMD (AMD) - - - - - diff --git a/test/form/samples/deprecated/emit-asset/index-umd-iife-queryparam.html b/test/form/samples/deprecated/emit-asset/index-umd-iife-queryparam.html deleted file mode 100644 index fda3f3f6195..00000000000 --- a/test/form/samples/deprecated/emit-asset/index-umd-iife-queryparam.html +++ /dev/null @@ -1,10 +0,0 @@ - - - - - UMD (IIFE) + query parameter - - - - - diff --git a/test/form/samples/deprecated/emit-asset/index-umd-iife.html b/test/form/samples/deprecated/emit-asset/index-umd-iife.html deleted file mode 100644 index 202c1dad8f0..00000000000 --- a/test/form/samples/deprecated/emit-asset/index-umd-iife.html +++ /dev/null @@ -1,10 +0,0 @@ - - - - - UMD (IIFE) - - - - - diff --git a/test/form/samples/deprecated/emit-asset/main.js b/test/form/samples/deprecated/emit-asset/main.js deleted file mode 100644 index c63771af02d..00000000000 --- a/test/form/samples/deprecated/emit-asset/main.js +++ /dev/null @@ -1,12 +0,0 @@ -import logo from './logo.svg'; - -function showImage(url) { - console.log(url); - if (typeof document !== 'undefined') { - const image = document.createElement('img'); - image.src = url; - document.body.appendChild(image); - } -} - -showImage(logo); diff --git a/test/form/samples/deprecated/inlined-treeshaken-dynamic-import/_config.js b/test/form/samples/deprecated/inlined-treeshaken-dynamic-import/_config.js deleted file mode 100644 index 70a30536aa8..00000000000 --- a/test/form/samples/deprecated/inlined-treeshaken-dynamic-import/_config.js +++ /dev/null @@ -1,7 +0,0 @@ -module.exports = { - description: 'completely removes tree-shaken dynamic imports ', - options: { - strictDeprecations: false, - inlineDynamicImports: true - } -}; diff --git a/test/form/samples/deprecated/inlined-treeshaken-dynamic-import/_expected/amd.js b/test/form/samples/deprecated/inlined-treeshaken-dynamic-import/_expected/amd.js deleted file mode 100644 index 126aa22ee83..00000000000 --- a/test/form/samples/deprecated/inlined-treeshaken-dynamic-import/_expected/amd.js +++ /dev/null @@ -1,5 +0,0 @@ -define(function () { 'use strict'; - - console.log('main'); - -}); diff --git a/test/form/samples/deprecated/inlined-treeshaken-dynamic-import/_expected/iife.js b/test/form/samples/deprecated/inlined-treeshaken-dynamic-import/_expected/iife.js deleted file mode 100644 index d283cbce8ba..00000000000 --- a/test/form/samples/deprecated/inlined-treeshaken-dynamic-import/_expected/iife.js +++ /dev/null @@ -1,6 +0,0 @@ -(function () { - 'use strict'; - - console.log('main'); - -}()); diff --git a/test/form/samples/deprecated/inlined-treeshaken-dynamic-import/_expected/system.js b/test/form/samples/deprecated/inlined-treeshaken-dynamic-import/_expected/system.js deleted file mode 100644 index c83499bc2d4..00000000000 --- a/test/form/samples/deprecated/inlined-treeshaken-dynamic-import/_expected/system.js +++ /dev/null @@ -1,10 +0,0 @@ -System.register([], function () { - 'use strict'; - return { - execute: function () { - - console.log('main'); - - } - }; -}); diff --git a/test/form/samples/deprecated/inlined-treeshaken-dynamic-import/_expected/umd.js b/test/form/samples/deprecated/inlined-treeshaken-dynamic-import/_expected/umd.js deleted file mode 100644 index f69e11c0256..00000000000 --- a/test/form/samples/deprecated/inlined-treeshaken-dynamic-import/_expected/umd.js +++ /dev/null @@ -1,8 +0,0 @@ -(function (factory) { - typeof define === 'function' && define.amd ? define(factory) : - factory(); -}((function () { 'use strict'; - - console.log('main'); - -}))); diff --git a/test/form/samples/deprecated/inlined-treeshaken-dynamic-import/dynamic.js b/test/form/samples/deprecated/inlined-treeshaken-dynamic-import/dynamic.js deleted file mode 100644 index 1d7a1acc1b8..00000000000 --- a/test/form/samples/deprecated/inlined-treeshaken-dynamic-import/dynamic.js +++ /dev/null @@ -1,2 +0,0 @@ -console.log('dynamic'); -export var dynamic = 42; diff --git a/test/form/samples/deprecated/inlined-treeshaken-dynamic-import/main.js b/test/form/samples/deprecated/inlined-treeshaken-dynamic-import/main.js deleted file mode 100644 index 9b0aad2c210..00000000000 --- a/test/form/samples/deprecated/inlined-treeshaken-dynamic-import/main.js +++ /dev/null @@ -1,2 +0,0 @@ -console.log('main'); -const getFoo = () => import('./dynamic.js'); diff --git a/test/form/samples/deprecated/interop-boolean-per-dependency/_config.js b/test/form/samples/deprecated/interop-boolean-per-dependency/_config.js deleted file mode 100644 index 9ac55a664fd..00000000000 --- a/test/form/samples/deprecated/interop-boolean-per-dependency/_config.js +++ /dev/null @@ -1,15 +0,0 @@ -module.exports = { - description: 'allows to configure the interop type per external dependency for boolean values', - options: { - strictDeprecations: false, - external: id => id.startsWith('external'), - output: { - interop(id) { - return JSON.parse(id.split('-')[1]); - }, - globals(id) { - return id.replace('-', ''); - } - } - } -}; diff --git a/test/form/samples/deprecated/interop-boolean-per-dependency/_expected/amd.js b/test/form/samples/deprecated/interop-boolean-per-dependency/_expected/amd.js deleted file mode 100644 index 6979526fe8d..00000000000 --- a/test/form/samples/deprecated/interop-boolean-per-dependency/_expected/amd.js +++ /dev/null @@ -1,34 +0,0 @@ -define(['require', 'external-false', 'external-true'], function (require, fooFalse, fooTrue) { 'use strict'; - - function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } - - function _interopNamespace(e) { - if (e && e.__esModule) return e; - var n = Object.create(null); - if (e) { - Object.keys(e).forEach(function (k) { - if (k !== 'default') { - var d = Object.getOwnPropertyDescriptor(e, k); - Object.defineProperty(n, k, d.get ? d : { - enumerable: true, - get: function () { - return e[k]; - } - }); - } - }); - } - n['default'] = e; - return Object.freeze(n); - } - - var fooTrue__default = /*#__PURE__*/_interopDefaultLegacy(fooTrue); - var fooTrue__namespace = /*#__PURE__*/_interopNamespace(fooTrue); - - console.log(fooFalse, fooFalse.barFalse, fooFalse); - console.log(fooTrue__default['default'], fooTrue.barTrue, fooTrue__namespace); - - new Promise(function (resolve, reject) { require(['external-false'], resolve, reject) }).then(console.log); - new Promise(function (resolve, reject) { require(['external-true'], function (m) { resolve(/*#__PURE__*/_interopNamespace(m)); }, reject) }).then(console.log); - -}); diff --git a/test/form/samples/deprecated/interop-boolean-per-dependency/_expected/cjs.js b/test/form/samples/deprecated/interop-boolean-per-dependency/_expected/cjs.js deleted file mode 100644 index 6d8a7941551..00000000000 --- a/test/form/samples/deprecated/interop-boolean-per-dependency/_expected/cjs.js +++ /dev/null @@ -1,35 +0,0 @@ -'use strict'; - -var fooFalse = require('external-false'); -var fooTrue = require('external-true'); - -function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } - -function _interopNamespace(e) { - if (e && e.__esModule) return e; - var n = Object.create(null); - if (e) { - Object.keys(e).forEach(function (k) { - if (k !== 'default') { - var d = Object.getOwnPropertyDescriptor(e, k); - Object.defineProperty(n, k, d.get ? d : { - enumerable: true, - get: function () { - return e[k]; - } - }); - } - }); - } - n['default'] = e; - return Object.freeze(n); -} - -var fooTrue__default = /*#__PURE__*/_interopDefaultLegacy(fooTrue); -var fooTrue__namespace = /*#__PURE__*/_interopNamespace(fooTrue); - -console.log(fooFalse, fooFalse.barFalse, fooFalse); -console.log(fooTrue__default['default'], fooTrue.barTrue, fooTrue__namespace); - -Promise.resolve().then(function () { return require('external-false'); }).then(console.log); -Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('external-true')); }).then(console.log); diff --git a/test/form/samples/deprecated/interop-boolean-per-dependency/_expected/es.js b/test/form/samples/deprecated/interop-boolean-per-dependency/_expected/es.js deleted file mode 100644 index acdcb2a663b..00000000000 --- a/test/form/samples/deprecated/interop-boolean-per-dependency/_expected/es.js +++ /dev/null @@ -1,10 +0,0 @@ -import * as fooFalse from 'external-false'; -import fooFalse__default, { barFalse } from 'external-false'; -import * as fooTrue from 'external-true'; -import fooTrue__default, { barTrue } from 'external-true'; - -console.log(fooFalse__default, barFalse, fooFalse); -console.log(fooTrue__default, barTrue, fooTrue); - -import('external-false').then(console.log); -import('external-true').then(console.log); diff --git a/test/form/samples/deprecated/interop-boolean-per-dependency/_expected/iife.js b/test/form/samples/deprecated/interop-boolean-per-dependency/_expected/iife.js deleted file mode 100644 index 552eb77c4ab..00000000000 --- a/test/form/samples/deprecated/interop-boolean-per-dependency/_expected/iife.js +++ /dev/null @@ -1,35 +0,0 @@ -(function (fooFalse, fooTrue) { - 'use strict'; - - function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } - - function _interopNamespace(e) { - if (e && e.__esModule) return e; - var n = Object.create(null); - if (e) { - Object.keys(e).forEach(function (k) { - if (k !== 'default') { - var d = Object.getOwnPropertyDescriptor(e, k); - Object.defineProperty(n, k, d.get ? d : { - enumerable: true, - get: function () { - return e[k]; - } - }); - } - }); - } - n['default'] = e; - return Object.freeze(n); - } - - var fooTrue__default = /*#__PURE__*/_interopDefaultLegacy(fooTrue); - var fooTrue__namespace = /*#__PURE__*/_interopNamespace(fooTrue); - - console.log(fooFalse, fooFalse.barFalse, fooFalse); - console.log(fooTrue__default['default'], fooTrue.barTrue, fooTrue__namespace); - - import('external-false').then(console.log); - import('external-true').then(console.log); - -}(externalfalse, externaltrue)); diff --git a/test/form/samples/deprecated/interop-boolean-per-dependency/_expected/system.js b/test/form/samples/deprecated/interop-boolean-per-dependency/_expected/system.js deleted file mode 100644 index d813e4d25c7..00000000000 --- a/test/form/samples/deprecated/interop-boolean-per-dependency/_expected/system.js +++ /dev/null @@ -1,24 +0,0 @@ -System.register(['external-false', 'external-true'], function (exports, module) { - 'use strict'; - var fooFalse__default, barFalse, fooFalse, fooTrue__default, barTrue, fooTrue; - return { - setters: [function (module) { - fooFalse__default = module.default; - barFalse = module.barFalse; - fooFalse = module; - }, function (module) { - fooTrue__default = module.default; - barTrue = module.barTrue; - fooTrue = module; - }], - execute: function () { - - console.log(fooFalse__default, barFalse, fooFalse); - console.log(fooTrue__default, barTrue, fooTrue); - - module.import('external-false').then(console.log); - module.import('external-true').then(console.log); - - } - }; -}); diff --git a/test/form/samples/deprecated/interop-boolean-per-dependency/_expected/umd.js b/test/form/samples/deprecated/interop-boolean-per-dependency/_expected/umd.js deleted file mode 100644 index 558032e560f..00000000000 --- a/test/form/samples/deprecated/interop-boolean-per-dependency/_expected/umd.js +++ /dev/null @@ -1,38 +0,0 @@ -(function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('external-false'), require('external-true')) : - typeof define === 'function' && define.amd ? define(['external-false', 'external-true'], factory) : - (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.externalfalse, global.externaltrue)); -}(this, (function (fooFalse, fooTrue) { 'use strict'; - - function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } - - function _interopNamespace(e) { - if (e && e.__esModule) return e; - var n = Object.create(null); - if (e) { - Object.keys(e).forEach(function (k) { - if (k !== 'default') { - var d = Object.getOwnPropertyDescriptor(e, k); - Object.defineProperty(n, k, d.get ? d : { - enumerable: true, - get: function () { - return e[k]; - } - }); - } - }); - } - n['default'] = e; - return Object.freeze(n); - } - - var fooTrue__default = /*#__PURE__*/_interopDefaultLegacy(fooTrue); - var fooTrue__namespace = /*#__PURE__*/_interopNamespace(fooTrue); - - console.log(fooFalse, fooFalse.barFalse, fooFalse); - console.log(fooTrue__default['default'], fooTrue.barTrue, fooTrue__namespace); - - import('external-false').then(console.log); - import('external-true').then(console.log); - -}))); diff --git a/test/form/samples/deprecated/interop-boolean-per-dependency/main.js b/test/form/samples/deprecated/interop-boolean-per-dependency/main.js deleted file mode 100644 index c39f04ba19a..00000000000 --- a/test/form/samples/deprecated/interop-boolean-per-dependency/main.js +++ /dev/null @@ -1,10 +0,0 @@ -import fooFalse, { barFalse } from 'external-false'; -import fooTrue, { barTrue } from 'external-true'; -import * as externalFalse from 'external-false'; -import * as externalTrue from 'external-true'; - -console.log(fooFalse, barFalse, externalFalse); -console.log(fooTrue, barTrue, externalTrue); - -import('external-false').then(console.log); -import('external-true').then(console.log); diff --git a/test/form/samples/deprecated/interop-boolean-per-reexported-dependency/_config.js b/test/form/samples/deprecated/interop-boolean-per-reexported-dependency/_config.js deleted file mode 100644 index 8cf9078d7ed..00000000000 --- a/test/form/samples/deprecated/interop-boolean-per-reexported-dependency/_config.js +++ /dev/null @@ -1,16 +0,0 @@ -module.exports = { - description: 'allows to configure the interop type per reexported external dependency', - options: { - strictDeprecations: false, - external: id => id.startsWith('external'), - output: { - interop(id) { - return JSON.parse(id.split('-')[1]); - }, - globals(id) { - return id.replace('-', ''); - }, - name: 'bundle' - } - } -}; diff --git a/test/form/samples/deprecated/interop-boolean-per-reexported-dependency/_expected/amd.js b/test/form/samples/deprecated/interop-boolean-per-reexported-dependency/_expected/amd.js deleted file mode 100644 index 378fa8c1a46..00000000000 --- a/test/form/samples/deprecated/interop-boolean-per-reexported-dependency/_expected/amd.js +++ /dev/null @@ -1,54 +0,0 @@ -define(['exports', 'external-false', 'external-true'], function (exports, externalFalse, externalTrue) { 'use strict'; - - function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } - - function _interopNamespace(e) { - if (e && e.__esModule) return e; - var n = Object.create(null); - if (e) { - Object.keys(e).forEach(function (k) { - if (k !== 'default') { - var d = Object.getOwnPropertyDescriptor(e, k); - Object.defineProperty(n, k, d.get ? d : { - enumerable: true, - get: function () { - return e[k]; - } - }); - } - }); - } - n['default'] = e; - return Object.freeze(n); - } - - var externalTrue__namespace = /*#__PURE__*/_interopNamespace(externalTrue); - var externalTrue__default = /*#__PURE__*/_interopDefaultLegacy(externalTrue); - - - - Object.defineProperty(exports, 'barFalse', { - enumerable: true, - get: function () { - return externalFalse.barFalse; - } - }); - exports.externalFalse = externalFalse; - exports.fooFalse = externalFalse; - Object.defineProperty(exports, 'barTrue', { - enumerable: true, - get: function () { - return externalTrue.barTrue; - } - }); - exports.externalTrue = externalTrue__namespace; - Object.defineProperty(exports, 'fooTrue', { - enumerable: true, - get: function () { - return externalTrue__default['default']; - } - }); - - Object.defineProperty(exports, '__esModule', { value: true }); - -}); diff --git a/test/form/samples/deprecated/interop-boolean-per-reexported-dependency/_expected/cjs.js b/test/form/samples/deprecated/interop-boolean-per-reexported-dependency/_expected/cjs.js deleted file mode 100644 index 8a2e42577f1..00000000000 --- a/test/form/samples/deprecated/interop-boolean-per-reexported-dependency/_expected/cjs.js +++ /dev/null @@ -1,55 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { value: true }); - -var externalFalse = require('external-false'); -var externalTrue = require('external-true'); - -function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } - -function _interopNamespace(e) { - if (e && e.__esModule) return e; - var n = Object.create(null); - if (e) { - Object.keys(e).forEach(function (k) { - if (k !== 'default') { - var d = Object.getOwnPropertyDescriptor(e, k); - Object.defineProperty(n, k, d.get ? d : { - enumerable: true, - get: function () { - return e[k]; - } - }); - } - }); - } - n['default'] = e; - return Object.freeze(n); -} - -var externalTrue__namespace = /*#__PURE__*/_interopNamespace(externalTrue); -var externalTrue__default = /*#__PURE__*/_interopDefaultLegacy(externalTrue); - - - -Object.defineProperty(exports, 'barFalse', { - enumerable: true, - get: function () { - return externalFalse.barFalse; - } -}); -exports.externalFalse = externalFalse; -exports.fooFalse = externalFalse; -Object.defineProperty(exports, 'barTrue', { - enumerable: true, - get: function () { - return externalTrue.barTrue; - } -}); -exports.externalTrue = externalTrue__namespace; -Object.defineProperty(exports, 'fooTrue', { - enumerable: true, - get: function () { - return externalTrue__default['default']; - } -}); diff --git a/test/form/samples/deprecated/interop-boolean-per-reexported-dependency/_expected/es.js b/test/form/samples/deprecated/interop-boolean-per-reexported-dependency/_expected/es.js deleted file mode 100644 index 048911f2e2b..00000000000 --- a/test/form/samples/deprecated/interop-boolean-per-reexported-dependency/_expected/es.js +++ /dev/null @@ -1,6 +0,0 @@ -import * as externalFalse from 'external-false'; -export { externalFalse }; -export { barFalse, default as fooFalse } from 'external-false'; -import * as externalTrue from 'external-true'; -export { externalTrue }; -export { barTrue, default as fooTrue } from 'external-true'; diff --git a/test/form/samples/deprecated/interop-boolean-per-reexported-dependency/_expected/iife.js b/test/form/samples/deprecated/interop-boolean-per-reexported-dependency/_expected/iife.js deleted file mode 100644 index 28586702c76..00000000000 --- a/test/form/samples/deprecated/interop-boolean-per-reexported-dependency/_expected/iife.js +++ /dev/null @@ -1,57 +0,0 @@ -var bundle = (function (exports, externalFalse, externalTrue) { - 'use strict'; - - function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } - - function _interopNamespace(e) { - if (e && e.__esModule) return e; - var n = Object.create(null); - if (e) { - Object.keys(e).forEach(function (k) { - if (k !== 'default') { - var d = Object.getOwnPropertyDescriptor(e, k); - Object.defineProperty(n, k, d.get ? d : { - enumerable: true, - get: function () { - return e[k]; - } - }); - } - }); - } - n['default'] = e; - return Object.freeze(n); - } - - var externalTrue__namespace = /*#__PURE__*/_interopNamespace(externalTrue); - var externalTrue__default = /*#__PURE__*/_interopDefaultLegacy(externalTrue); - - - - Object.defineProperty(exports, 'barFalse', { - enumerable: true, - get: function () { - return externalFalse.barFalse; - } - }); - exports.externalFalse = externalFalse; - exports.fooFalse = externalFalse; - Object.defineProperty(exports, 'barTrue', { - enumerable: true, - get: function () { - return externalTrue.barTrue; - } - }); - exports.externalTrue = externalTrue__namespace; - Object.defineProperty(exports, 'fooTrue', { - enumerable: true, - get: function () { - return externalTrue__default['default']; - } - }); - - Object.defineProperty(exports, '__esModule', { value: true }); - - return exports; - -}({}, externalfalse, externaltrue)); diff --git a/test/form/samples/deprecated/interop-boolean-per-reexported-dependency/_expected/system.js b/test/form/samples/deprecated/interop-boolean-per-reexported-dependency/_expected/system.js deleted file mode 100644 index 24d9dede5d9..00000000000 --- a/test/form/samples/deprecated/interop-boolean-per-reexported-dependency/_expected/system.js +++ /dev/null @@ -1,23 +0,0 @@ -System.register('bundle', ['external-false', 'external-true'], function (exports) { - 'use strict'; - return { - setters: [function (module) { - exports('externalFalse', module); - var _setter = {}; - _setter.barFalse = module.barFalse; - _setter.fooFalse = module.default; - exports(_setter); - }, function (module) { - exports('externalTrue', module); - var _setter = {}; - _setter.barTrue = module.barTrue; - _setter.fooTrue = module.default; - exports(_setter); - }], - execute: function () { - - - - } - }; -}); diff --git a/test/form/samples/deprecated/interop-boolean-per-reexported-dependency/_expected/umd.js b/test/form/samples/deprecated/interop-boolean-per-reexported-dependency/_expected/umd.js deleted file mode 100644 index a65ee7138ea..00000000000 --- a/test/form/samples/deprecated/interop-boolean-per-reexported-dependency/_expected/umd.js +++ /dev/null @@ -1,58 +0,0 @@ -(function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('external-false'), require('external-true')) : - typeof define === 'function' && define.amd ? define(['exports', 'external-false', 'external-true'], factory) : - (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.bundle = {}, global.externalfalse, global.externaltrue)); -}(this, (function (exports, externalFalse, externalTrue) { 'use strict'; - - function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } - - function _interopNamespace(e) { - if (e && e.__esModule) return e; - var n = Object.create(null); - if (e) { - Object.keys(e).forEach(function (k) { - if (k !== 'default') { - var d = Object.getOwnPropertyDescriptor(e, k); - Object.defineProperty(n, k, d.get ? d : { - enumerable: true, - get: function () { - return e[k]; - } - }); - } - }); - } - n['default'] = e; - return Object.freeze(n); - } - - var externalTrue__namespace = /*#__PURE__*/_interopNamespace(externalTrue); - var externalTrue__default = /*#__PURE__*/_interopDefaultLegacy(externalTrue); - - - - Object.defineProperty(exports, 'barFalse', { - enumerable: true, - get: function () { - return externalFalse.barFalse; - } - }); - exports.externalFalse = externalFalse; - exports.fooFalse = externalFalse; - Object.defineProperty(exports, 'barTrue', { - enumerable: true, - get: function () { - return externalTrue.barTrue; - } - }); - exports.externalTrue = externalTrue__namespace; - Object.defineProperty(exports, 'fooTrue', { - enumerable: true, - get: function () { - return externalTrue__default['default']; - } - }); - - Object.defineProperty(exports, '__esModule', { value: true }); - -}))); diff --git a/test/form/samples/deprecated/interop-boolean-per-reexported-dependency/main.js b/test/form/samples/deprecated/interop-boolean-per-reexported-dependency/main.js deleted file mode 100644 index c6f8983e9ce..00000000000 --- a/test/form/samples/deprecated/interop-boolean-per-reexported-dependency/main.js +++ /dev/null @@ -1,4 +0,0 @@ -export { default as fooFalse, barFalse } from 'external-false'; -export { default as fooTrue, barTrue } from 'external-true'; -export * as externalFalse from 'external-false'; -export * as externalTrue from 'external-true'; diff --git a/test/form/samples/deprecated/interop-false-reexport/_config.js b/test/form/samples/deprecated/interop-false-reexport/_config.js deleted file mode 100644 index 1505f8be29b..00000000000 --- a/test/form/samples/deprecated/interop-false-reexport/_config.js +++ /dev/null @@ -1,12 +0,0 @@ -module.exports = { - description: 'reexports with interop: false', - options: { - strictDeprecations: false, - external: ['external'], - output: { - globals: { external: 'external' }, - name: 'foo', - interop: false - } - } -}; diff --git a/test/form/samples/deprecated/interop-false-reexport/_expected/amd.js b/test/form/samples/deprecated/interop-false-reexport/_expected/amd.js deleted file mode 100644 index 93dc4eca817..00000000000 --- a/test/form/samples/deprecated/interop-false-reexport/_expected/amd.js +++ /dev/null @@ -1,15 +0,0 @@ -define(['exports', 'external'], function (exports, external) { 'use strict'; - - - - exports.p = external; - Object.defineProperty(exports, 'q', { - enumerable: true, - get: function () { - return external.p; - } - }); - - Object.defineProperty(exports, '__esModule', { value: true }); - -}); diff --git a/test/form/samples/deprecated/interop-false-reexport/_expected/cjs.js b/test/form/samples/deprecated/interop-false-reexport/_expected/cjs.js deleted file mode 100644 index ac6a99b829d..00000000000 --- a/test/form/samples/deprecated/interop-false-reexport/_expected/cjs.js +++ /dev/null @@ -1,15 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { value: true }); - -var external = require('external'); - - - -exports.p = external; -Object.defineProperty(exports, 'q', { - enumerable: true, - get: function () { - return external.p; - } -}); diff --git a/test/form/samples/deprecated/interop-false-reexport/_expected/es.js b/test/form/samples/deprecated/interop-false-reexport/_expected/es.js deleted file mode 100644 index e80bd564609..00000000000 --- a/test/form/samples/deprecated/interop-false-reexport/_expected/es.js +++ /dev/null @@ -1 +0,0 @@ -export { default as p, p as q } from 'external'; diff --git a/test/form/samples/deprecated/interop-false-reexport/_expected/iife.js b/test/form/samples/deprecated/interop-false-reexport/_expected/iife.js deleted file mode 100644 index 395bfb7ef37..00000000000 --- a/test/form/samples/deprecated/interop-false-reexport/_expected/iife.js +++ /dev/null @@ -1,18 +0,0 @@ -var foo = (function (exports, external) { - 'use strict'; - - - - exports.p = external; - Object.defineProperty(exports, 'q', { - enumerable: true, - get: function () { - return external.p; - } - }); - - Object.defineProperty(exports, '__esModule', { value: true }); - - return exports; - -}({}, external)); diff --git a/test/form/samples/deprecated/interop-false-reexport/_expected/system.js b/test/form/samples/deprecated/interop-false-reexport/_expected/system.js deleted file mode 100644 index 413b2e7423c..00000000000 --- a/test/form/samples/deprecated/interop-false-reexport/_expected/system.js +++ /dev/null @@ -1,16 +0,0 @@ -System.register('foo', ['external'], function (exports) { - 'use strict'; - return { - setters: [function (module) { - var _setter = {}; - _setter.p = module.default; - _setter.q = module.p; - exports(_setter); - }], - execute: function () { - - - - } - }; -}); diff --git a/test/form/samples/deprecated/interop-false-reexport/_expected/umd.js b/test/form/samples/deprecated/interop-false-reexport/_expected/umd.js deleted file mode 100644 index 27f5c8e7f68..00000000000 --- a/test/form/samples/deprecated/interop-false-reexport/_expected/umd.js +++ /dev/null @@ -1,17 +0,0 @@ -(function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('external')) : - typeof define === 'function' && define.amd ? define(['exports', 'external'], factory) : - (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.foo = {}, global.external)); -}(this, (function (exports, external) { 'use strict'; - - exports.p = external; - Object.defineProperty(exports, 'q', { - enumerable: true, - get: function () { - return external.p; - } - }); - - Object.defineProperty(exports, '__esModule', { value: true }); - -}))); diff --git a/test/form/samples/deprecated/interop-false-reexport/main.js b/test/form/samples/deprecated/interop-false-reexport/main.js deleted file mode 100644 index 9552bfcdcef..00000000000 --- a/test/form/samples/deprecated/interop-false-reexport/main.js +++ /dev/null @@ -1,2 +0,0 @@ -export { p as q } from 'external'; -export { default as p } from 'external'; \ No newline at end of file diff --git a/test/form/samples/deprecated/interop-false/_config.js b/test/form/samples/deprecated/interop-false/_config.js deleted file mode 100644 index 29fb546c761..00000000000 --- a/test/form/samples/deprecated/interop-false/_config.js +++ /dev/null @@ -1,13 +0,0 @@ -module.exports = { - description: 'getInterop with interop: false', - expectedWarnings: ['UNUSED_EXTERNAL_IMPORT'], - options: { - strictDeprecations: false, - external: ['core/view'], - output: { - globals: { 'core/view': 'View' }, - name: 'foo', - interop: false - } - } -}; diff --git a/test/form/samples/deprecated/interop-false/_expected/amd.js b/test/form/samples/deprecated/interop-false/_expected/amd.js deleted file mode 100644 index 9245883ba6c..00000000000 --- a/test/form/samples/deprecated/interop-false/_expected/amd.js +++ /dev/null @@ -1,7 +0,0 @@ -define(['core/view'], function (View) { 'use strict'; - - var main = View.extend({}); - - return main; - -}); diff --git a/test/form/samples/deprecated/interop-false/_expected/cjs.js b/test/form/samples/deprecated/interop-false/_expected/cjs.js deleted file mode 100644 index 8396bc764b9..00000000000 --- a/test/form/samples/deprecated/interop-false/_expected/cjs.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -var View = require('core/view'); - -var main = View.extend({}); - -module.exports = main; diff --git a/test/form/samples/deprecated/interop-false/_expected/es.js b/test/form/samples/deprecated/interop-false/_expected/es.js deleted file mode 100644 index d5e775e86a2..00000000000 --- a/test/form/samples/deprecated/interop-false/_expected/es.js +++ /dev/null @@ -1,5 +0,0 @@ -import View from 'core/view'; - -var main = View.extend({}); - -export default main; diff --git a/test/form/samples/deprecated/interop-false/_expected/iife.js b/test/form/samples/deprecated/interop-false/_expected/iife.js deleted file mode 100644 index d94c4325cc1..00000000000 --- a/test/form/samples/deprecated/interop-false/_expected/iife.js +++ /dev/null @@ -1,8 +0,0 @@ -var foo = (function (View) { - 'use strict'; - - var main = View.extend({}); - - return main; - -}(View)); diff --git a/test/form/samples/deprecated/interop-false/_expected/system.js b/test/form/samples/deprecated/interop-false/_expected/system.js deleted file mode 100644 index 6063c9dfb22..00000000000 --- a/test/form/samples/deprecated/interop-false/_expected/system.js +++ /dev/null @@ -1,14 +0,0 @@ -System.register('foo', ['core/view'], function (exports) { - 'use strict'; - var View; - return { - setters: [function (module) { - View = module.default; - }], - execute: function () { - - var main = exports('default', View.extend({})); - - } - }; -}); diff --git a/test/form/samples/deprecated/interop-false/_expected/umd.js b/test/form/samples/deprecated/interop-false/_expected/umd.js deleted file mode 100644 index ddd96284903..00000000000 --- a/test/form/samples/deprecated/interop-false/_expected/umd.js +++ /dev/null @@ -1,11 +0,0 @@ -(function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('core/view')) : - typeof define === 'function' && define.amd ? define(['core/view'], factory) : - (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.foo = factory(global.View)); -}(this, (function (View) { 'use strict'; - - var main = View.extend({}); - - return main; - -}))); diff --git a/test/form/samples/deprecated/interop-false/main.js b/test/form/samples/deprecated/interop-false/main.js deleted file mode 100644 index 31688d4a16a..00000000000 --- a/test/form/samples/deprecated/interop-false/main.js +++ /dev/null @@ -1,2 +0,0 @@ -import View, { name } from 'core/view'; -export default View.extend({}); diff --git a/test/form/samples/deprecated/interop-per-dependency-no-live-binding-boolean/_config.js b/test/form/samples/deprecated/interop-per-dependency-no-live-binding-boolean/_config.js deleted file mode 100644 index 40e9c43350b..00000000000 --- a/test/form/samples/deprecated/interop-per-dependency-no-live-binding-boolean/_config.js +++ /dev/null @@ -1,20 +0,0 @@ -const checkedIds = new Set(); - -module.exports = { - description: 'allows to configure the interop type per external dependency for boolean values', - options: { - strictDeprecations: false, - external: id => id.startsWith('external'), - output: { - externalLiveBindings: false, - interop(id) { - if (checkedIds.has(id)) { - throw new Error(`Interop for id ${id} has been requested twice.`); - } - checkedIds.add(id); - return JSON.parse(id.split('-')[1]); - }, - format: 'cjs' - } - } -}; diff --git a/test/form/samples/deprecated/interop-per-dependency-no-live-binding-boolean/_expected.js b/test/form/samples/deprecated/interop-per-dependency-no-live-binding-boolean/_expected.js deleted file mode 100644 index 7d41aa33dfd..00000000000 --- a/test/form/samples/deprecated/interop-per-dependency-no-live-binding-boolean/_expected.js +++ /dev/null @@ -1,27 +0,0 @@ -'use strict'; - -var fooFalse = require('external-false'); -var fooTrue = require('external-true'); - -function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e['default'] : e; } - -function _interopNamespace(e) { - if (e && e.__esModule) return e; - var n = Object.create(null); - if (e) { - Object.keys(e).forEach(function (k) { - n[k] = e[k]; - }); - } - n['default'] = e; - return Object.freeze(n); -} - -var fooTrue__default = /*#__PURE__*/_interopDefaultLegacy(fooTrue); -var fooTrue__namespace = /*#__PURE__*/_interopNamespace(fooTrue); - -console.log(fooFalse, fooFalse.barFalse, fooFalse); -console.log(fooTrue__default, fooTrue.barTrue, fooTrue__namespace); - -Promise.resolve().then(function () { return require('external-false'); }).then(console.log); -Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('external-true')); }).then(console.log); diff --git a/test/form/samples/deprecated/interop-per-dependency-no-live-binding-boolean/main.js b/test/form/samples/deprecated/interop-per-dependency-no-live-binding-boolean/main.js deleted file mode 100644 index c39f04ba19a..00000000000 --- a/test/form/samples/deprecated/interop-per-dependency-no-live-binding-boolean/main.js +++ /dev/null @@ -1,10 +0,0 @@ -import fooFalse, { barFalse } from 'external-false'; -import fooTrue, { barTrue } from 'external-true'; -import * as externalFalse from 'external-false'; -import * as externalTrue from 'external-true'; - -console.log(fooFalse, barFalse, externalFalse); -console.log(fooTrue, barTrue, externalTrue); - -import('external-false').then(console.log); -import('external-true').then(console.log); diff --git a/test/form/samples/deprecated/nested-inlined-dynamic-import/_config.js b/test/form/samples/deprecated/nested-inlined-dynamic-import/_config.js deleted file mode 100644 index b72d8e62afc..00000000000 --- a/test/form/samples/deprecated/nested-inlined-dynamic-import/_config.js +++ /dev/null @@ -1,7 +0,0 @@ -module.exports = { - description: 'deconflicts variables when nested dynamic imports are inlined', - options: { - strictDeprecations: false, - inlineDynamicImports: true - } -}; diff --git a/test/form/samples/deprecated/nested-inlined-dynamic-import/_expected/amd.js b/test/form/samples/deprecated/nested-inlined-dynamic-import/_expected/amd.js deleted file mode 100644 index 83e0443cf4b..00000000000 --- a/test/form/samples/deprecated/nested-inlined-dynamic-import/_expected/amd.js +++ /dev/null @@ -1,18 +0,0 @@ -define(function () { 'use strict'; - - async function main() { - const foo$1 = 1; - const ns = await Promise.resolve().then(function () { return foo; }); - console.log(ns.value + foo$1); - } - - main(); - - const value = 42; - - var foo = /*#__PURE__*/Object.freeze({ - __proto__: null, - value: value - }); - -}); diff --git a/test/form/samples/deprecated/nested-inlined-dynamic-import/_expected/cjs.js b/test/form/samples/deprecated/nested-inlined-dynamic-import/_expected/cjs.js deleted file mode 100644 index 9226d1268d7..00000000000 --- a/test/form/samples/deprecated/nested-inlined-dynamic-import/_expected/cjs.js +++ /dev/null @@ -1,16 +0,0 @@ -'use strict'; - -async function main() { - const foo$1 = 1; - const ns = await Promise.resolve().then(function () { return foo; }); - console.log(ns.value + foo$1); -} - -main(); - -const value = 42; - -var foo = /*#__PURE__*/Object.freeze({ - __proto__: null, - value: value -}); diff --git a/test/form/samples/deprecated/nested-inlined-dynamic-import/_expected/es.js b/test/form/samples/deprecated/nested-inlined-dynamic-import/_expected/es.js deleted file mode 100644 index 97b0b8e51f5..00000000000 --- a/test/form/samples/deprecated/nested-inlined-dynamic-import/_expected/es.js +++ /dev/null @@ -1,14 +0,0 @@ -async function main() { - const foo$1 = 1; - const ns = await Promise.resolve().then(function () { return foo; }); - console.log(ns.value + foo$1); -} - -main(); - -const value = 42; - -var foo = /*#__PURE__*/Object.freeze({ - __proto__: null, - value: value -}); diff --git a/test/form/samples/deprecated/nested-inlined-dynamic-import/_expected/iife.js b/test/form/samples/deprecated/nested-inlined-dynamic-import/_expected/iife.js deleted file mode 100644 index 6a2dd7b2aaa..00000000000 --- a/test/form/samples/deprecated/nested-inlined-dynamic-import/_expected/iife.js +++ /dev/null @@ -1,19 +0,0 @@ -(function () { - 'use strict'; - - async function main() { - const foo$1 = 1; - const ns = await Promise.resolve().then(function () { return foo; }); - console.log(ns.value + foo$1); - } - - main(); - - const value = 42; - - var foo = /*#__PURE__*/Object.freeze({ - __proto__: null, - value: value - }); - -}()); diff --git a/test/form/samples/deprecated/nested-inlined-dynamic-import/_expected/system.js b/test/form/samples/deprecated/nested-inlined-dynamic-import/_expected/system.js deleted file mode 100644 index a11234126c3..00000000000 --- a/test/form/samples/deprecated/nested-inlined-dynamic-import/_expected/system.js +++ /dev/null @@ -1,23 +0,0 @@ -System.register([], function () { - 'use strict'; - return { - execute: function () { - - async function main() { - const foo$1 = 1; - const ns = await Promise.resolve().then(function () { return foo; }); - console.log(ns.value + foo$1); - } - - main(); - - const value = 42; - - var foo = /*#__PURE__*/Object.freeze({ - __proto__: null, - value: value - }); - - } - }; -}); diff --git a/test/form/samples/deprecated/nested-inlined-dynamic-import/_expected/umd.js b/test/form/samples/deprecated/nested-inlined-dynamic-import/_expected/umd.js deleted file mode 100644 index 04bde1cc42f..00000000000 --- a/test/form/samples/deprecated/nested-inlined-dynamic-import/_expected/umd.js +++ /dev/null @@ -1,21 +0,0 @@ -(function (factory) { - typeof define === 'function' && define.amd ? define(factory) : - factory(); -}((function () { 'use strict'; - - async function main() { - const foo$1 = 1; - const ns = await Promise.resolve().then(function () { return foo; }); - console.log(ns.value + foo$1); - } - - main(); - - const value = 42; - - var foo = /*#__PURE__*/Object.freeze({ - __proto__: null, - value: value - }); - -}))); diff --git a/test/form/samples/deprecated/nested-inlined-dynamic-import/main.js b/test/form/samples/deprecated/nested-inlined-dynamic-import/main.js deleted file mode 100644 index 685c5cc1aef..00000000000 --- a/test/form/samples/deprecated/nested-inlined-dynamic-import/main.js +++ /dev/null @@ -1,7 +0,0 @@ -async function main() { - const foo = 1; - const ns = await import('./foo.js'); - console.log(ns.value + foo); -} - -main(); diff --git a/test/form/samples/deprecated/prune-pure-unused-import-array/_config.js b/test/form/samples/deprecated/prune-pure-unused-import-array/_config.js deleted file mode 100644 index 6dd4090563a..00000000000 --- a/test/form/samples/deprecated/prune-pure-unused-import-array/_config.js +++ /dev/null @@ -1,12 +0,0 @@ -module.exports = { - description: 'prunes pure unused external imports ([#1352])', - expectedWarnings: ['DEPRECATED_FEATURE'], - options: { - strictDeprecations: false, - external: ['external', 'other'], - treeshake: { pureExternalModules: ['external'] }, - output: { - globals: { other: 'other' } - } - } -}; diff --git a/test/form/samples/deprecated/prune-pure-unused-import-array/_expected/amd.js b/test/form/samples/deprecated/prune-pure-unused-import-array/_expected/amd.js deleted file mode 100644 index f02c330d436..00000000000 --- a/test/form/samples/deprecated/prune-pure-unused-import-array/_expected/amd.js +++ /dev/null @@ -1,5 +0,0 @@ -define(['other'], function (other) { 'use strict'; - - - -}); diff --git a/test/form/samples/deprecated/prune-pure-unused-import-array/_expected/cjs.js b/test/form/samples/deprecated/prune-pure-unused-import-array/_expected/cjs.js deleted file mode 100644 index d4c04157586..00000000000 --- a/test/form/samples/deprecated/prune-pure-unused-import-array/_expected/cjs.js +++ /dev/null @@ -1,4 +0,0 @@ -'use strict'; - -require('other'); - diff --git a/test/form/samples/deprecated/prune-pure-unused-import-array/_expected/es.js b/test/form/samples/deprecated/prune-pure-unused-import-array/_expected/es.js deleted file mode 100644 index 4c6a1dd1289..00000000000 --- a/test/form/samples/deprecated/prune-pure-unused-import-array/_expected/es.js +++ /dev/null @@ -1 +0,0 @@ -import 'other'; diff --git a/test/form/samples/deprecated/prune-pure-unused-import-array/_expected/iife.js b/test/form/samples/deprecated/prune-pure-unused-import-array/_expected/iife.js deleted file mode 100644 index 43ef5426880..00000000000 --- a/test/form/samples/deprecated/prune-pure-unused-import-array/_expected/iife.js +++ /dev/null @@ -1,6 +0,0 @@ -(function () { - 'use strict'; - - - -}()); diff --git a/test/form/samples/deprecated/prune-pure-unused-import-array/_expected/system.js b/test/form/samples/deprecated/prune-pure-unused-import-array/_expected/system.js deleted file mode 100644 index 44f1ac2d34d..00000000000 --- a/test/form/samples/deprecated/prune-pure-unused-import-array/_expected/system.js +++ /dev/null @@ -1,11 +0,0 @@ -System.register(['other'], function () { - 'use strict'; - return { - setters: [function () {}], - execute: function () { - - - - } - }; -}); diff --git a/test/form/samples/deprecated/prune-pure-unused-import-array/_expected/umd.js b/test/form/samples/deprecated/prune-pure-unused-import-array/_expected/umd.js deleted file mode 100644 index 44508fbc372..00000000000 --- a/test/form/samples/deprecated/prune-pure-unused-import-array/_expected/umd.js +++ /dev/null @@ -1,8 +0,0 @@ -(function (factory) { - typeof define === 'function' && define.amd ? define(['other'], factory) : - factory(); -}((function () { 'use strict'; - - - -}))); diff --git a/test/form/samples/deprecated/prune-pure-unused-import-array/main.js b/test/form/samples/deprecated/prune-pure-unused-import-array/main.js deleted file mode 100644 index 558f459bd2a..00000000000 --- a/test/form/samples/deprecated/prune-pure-unused-import-array/main.js +++ /dev/null @@ -1,7 +0,0 @@ -import { unused } from 'external'; -import { notused } from 'other'; - -function alsoUnused () { - unused(); - notused(); -} diff --git a/test/form/samples/deprecated/prune-pure-unused-import-function/_config.js b/test/form/samples/deprecated/prune-pure-unused-import-function/_config.js deleted file mode 100644 index ca46cdf2ddd..00000000000 --- a/test/form/samples/deprecated/prune-pure-unused-import-function/_config.js +++ /dev/null @@ -1,12 +0,0 @@ -module.exports = { - description: 'prunes pure unused external imports ([#1352])', - expectedWarnings: ['DEPRECATED_FEATURE', 'EMPTY_BUNDLE'], - options: { - strictDeprecations: false, - external: ['external', 'other'], - treeshake: { pureExternalModules: id => id === 'external' }, - output: { - globals: { other: 'other' } - } - } -}; diff --git a/test/form/samples/deprecated/prune-pure-unused-import-function/_expected/amd.js b/test/form/samples/deprecated/prune-pure-unused-import-function/_expected/amd.js deleted file mode 100644 index f02c330d436..00000000000 --- a/test/form/samples/deprecated/prune-pure-unused-import-function/_expected/amd.js +++ /dev/null @@ -1,5 +0,0 @@ -define(['other'], function (other) { 'use strict'; - - - -}); diff --git a/test/form/samples/deprecated/prune-pure-unused-import-function/_expected/cjs.js b/test/form/samples/deprecated/prune-pure-unused-import-function/_expected/cjs.js deleted file mode 100644 index d4c04157586..00000000000 --- a/test/form/samples/deprecated/prune-pure-unused-import-function/_expected/cjs.js +++ /dev/null @@ -1,4 +0,0 @@ -'use strict'; - -require('other'); - diff --git a/test/form/samples/deprecated/prune-pure-unused-import-function/_expected/es.js b/test/form/samples/deprecated/prune-pure-unused-import-function/_expected/es.js deleted file mode 100644 index 4c6a1dd1289..00000000000 --- a/test/form/samples/deprecated/prune-pure-unused-import-function/_expected/es.js +++ /dev/null @@ -1 +0,0 @@ -import 'other'; diff --git a/test/form/samples/deprecated/prune-pure-unused-import-function/_expected/iife.js b/test/form/samples/deprecated/prune-pure-unused-import-function/_expected/iife.js deleted file mode 100644 index 43ef5426880..00000000000 --- a/test/form/samples/deprecated/prune-pure-unused-import-function/_expected/iife.js +++ /dev/null @@ -1,6 +0,0 @@ -(function () { - 'use strict'; - - - -}()); diff --git a/test/form/samples/deprecated/prune-pure-unused-import-function/_expected/system.js b/test/form/samples/deprecated/prune-pure-unused-import-function/_expected/system.js deleted file mode 100644 index 44f1ac2d34d..00000000000 --- a/test/form/samples/deprecated/prune-pure-unused-import-function/_expected/system.js +++ /dev/null @@ -1,11 +0,0 @@ -System.register(['other'], function () { - 'use strict'; - return { - setters: [function () {}], - execute: function () { - - - - } - }; -}); diff --git a/test/form/samples/deprecated/prune-pure-unused-import-function/_expected/umd.js b/test/form/samples/deprecated/prune-pure-unused-import-function/_expected/umd.js deleted file mode 100644 index 44508fbc372..00000000000 --- a/test/form/samples/deprecated/prune-pure-unused-import-function/_expected/umd.js +++ /dev/null @@ -1,8 +0,0 @@ -(function (factory) { - typeof define === 'function' && define.amd ? define(['other'], factory) : - factory(); -}((function () { 'use strict'; - - - -}))); diff --git a/test/form/samples/deprecated/prune-pure-unused-import-function/main.js b/test/form/samples/deprecated/prune-pure-unused-import-function/main.js deleted file mode 100644 index 558f459bd2a..00000000000 --- a/test/form/samples/deprecated/prune-pure-unused-import-function/main.js +++ /dev/null @@ -1,7 +0,0 @@ -import { unused } from 'external'; -import { notused } from 'other'; - -function alsoUnused () { - unused(); - notused(); -} diff --git a/test/form/samples/deprecated/prune-pure-unused-import/_config.js b/test/form/samples/deprecated/prune-pure-unused-import/_config.js deleted file mode 100644 index fe513326305..00000000000 --- a/test/form/samples/deprecated/prune-pure-unused-import/_config.js +++ /dev/null @@ -1,9 +0,0 @@ -module.exports = { - description: 'prunes pure unused external imports ([#1352])', - expectedWarnings: ['DEPRECATED_FEATURE', 'EMPTY_BUNDLE'], - options: { - strictDeprecations: false, - external: ['external', 'other'], - treeshake: { pureExternalModules: true } - } -}; diff --git a/test/form/samples/deprecated/prune-pure-unused-import/_expected/amd.js b/test/form/samples/deprecated/prune-pure-unused-import/_expected/amd.js deleted file mode 100644 index f9f8229aa40..00000000000 --- a/test/form/samples/deprecated/prune-pure-unused-import/_expected/amd.js +++ /dev/null @@ -1,5 +0,0 @@ -define(function () { 'use strict'; - - - -}); diff --git a/test/form/samples/deprecated/prune-pure-unused-import/_expected/iife.js b/test/form/samples/deprecated/prune-pure-unused-import/_expected/iife.js deleted file mode 100644 index 43ef5426880..00000000000 --- a/test/form/samples/deprecated/prune-pure-unused-import/_expected/iife.js +++ /dev/null @@ -1,6 +0,0 @@ -(function () { - 'use strict'; - - - -}()); diff --git a/test/form/samples/deprecated/prune-pure-unused-import/_expected/system.js b/test/form/samples/deprecated/prune-pure-unused-import/_expected/system.js deleted file mode 100644 index a702f2b06ef..00000000000 --- a/test/form/samples/deprecated/prune-pure-unused-import/_expected/system.js +++ /dev/null @@ -1,10 +0,0 @@ -System.register([], function () { - 'use strict'; - return { - execute: function () { - - - - } - }; -}); diff --git a/test/form/samples/deprecated/prune-pure-unused-import/_expected/umd.js b/test/form/samples/deprecated/prune-pure-unused-import/_expected/umd.js deleted file mode 100644 index 8bf6301d469..00000000000 --- a/test/form/samples/deprecated/prune-pure-unused-import/_expected/umd.js +++ /dev/null @@ -1,8 +0,0 @@ -(function (factory) { - typeof define === 'function' && define.amd ? define(factory) : - factory(); -}((function () { 'use strict'; - - - -}))); diff --git a/test/form/samples/deprecated/prune-pure-unused-import/main.js b/test/form/samples/deprecated/prune-pure-unused-import/main.js deleted file mode 100644 index ce3e0cb6298..00000000000 --- a/test/form/samples/deprecated/prune-pure-unused-import/main.js +++ /dev/null @@ -1,5 +0,0 @@ -import { unused } from 'external'; - -function alsoUnused () { - unused(); -} diff --git a/test/form/samples/deprecated/removes-dynamic-assertions/_config.js b/test/form/samples/deprecated/removes-dynamic-assertions/_config.js new file mode 100644 index 00000000000..cc9d7daddf2 --- /dev/null +++ b/test/form/samples/deprecated/removes-dynamic-assertions/_config.js @@ -0,0 +1,30 @@ +module.exports = defineTest({ + description: 'keep import assertions for dynamic imports', + expectedWarnings: ['UNRESOLVED_IMPORT', 'DEPRECATED_FEATURE'], + options: { + strictDeprecations: false, + external: id => { + if (id === 'unresolved') return null; + return true; + }, + plugins: [ + { + name: 'test', + resolveDynamicImport(specifier) { + if (typeof specifier === 'object') { + if (specifier.type === 'TemplateLiteral') { + return "'resolvedString'"; + } + if (specifier.type === 'BinaryExpression') { + return { id: 'resolved-id', external: true }; + } + } else if (specifier === 'external-resolved') { + return { id: 'resolved-different', external: true }; + } + return null; + } + } + ], + output: { externalImportAssertions: false } + } +}); diff --git a/test/form/samples/deprecated/removes-dynamic-assertions/_expected.js b/test/form/samples/deprecated/removes-dynamic-assertions/_expected.js new file mode 100644 index 00000000000..2d417264620 --- /dev/null +++ b/test/form/samples/deprecated/removes-dynamic-assertions/_expected.js @@ -0,0 +1,6 @@ +import('external'); +import(globalThis.unknown); +import('resolvedString'); +import('resolved-id'); +import('resolved-different'); +import('unresolved'); diff --git a/test/form/samples/deprecated/removes-dynamic-assertions/main.js b/test/form/samples/deprecated/removes-dynamic-assertions/main.js new file mode 100644 index 00000000000..025b6045192 --- /dev/null +++ b/test/form/samples/deprecated/removes-dynamic-assertions/main.js @@ -0,0 +1,6 @@ +import('external', { with: { type: 'special' } }); +import(globalThis.unknown, { with: { type: 'special' } }); +import(`external-${globalThis.unknown}`, { with: { type: 'special' } }); +import('external' + globalThis.unknown, { with: { type: 'special' } }); +import('external-resolved', { with: { type: 'special' } }); +import('unresolved', { with: { type: 'special' } }); diff --git a/test/form/samples/deprecated/removes-static-attributes/_config.js b/test/form/samples/deprecated/removes-static-attributes/_config.js new file mode 100644 index 00000000000..0fae6d8519d --- /dev/null +++ b/test/form/samples/deprecated/removes-static-attributes/_config.js @@ -0,0 +1,12 @@ +module.exports = defineTest({ + description: 'keeps any import assertions on input', + expectedWarnings: ['UNRESOLVED_IMPORT', 'DEPRECATED_FEATURE'], + options: { + strictDeprecations: false, + external: id => { + if (id === 'unresolved') return null; + return true; + }, + output: { name: 'bundle', externalImportAssertions: false } + } +}); diff --git a/test/form/samples/deprecated/removes-static-attributes/_expected.js b/test/form/samples/deprecated/removes-static-attributes/_expected.js new file mode 100644 index 00000000000..40f55f22388 --- /dev/null +++ b/test/form/samples/deprecated/removes-static-attributes/_expected.js @@ -0,0 +1,7 @@ +import { a } from 'a'; +import * as b from 'b'; +export { c } from 'c'; +export * from 'd'; +import 'unresolved'; + +console.log(a, b, d); diff --git a/test/form/samples/deprecated/removes-static-attributes/main.js b/test/form/samples/deprecated/removes-static-attributes/main.js new file mode 100644 index 00000000000..64538165030 --- /dev/null +++ b/test/form/samples/deprecated/removes-static-attributes/main.js @@ -0,0 +1,9 @@ +import { a } from 'a' with { type: 'a', extra: 'extra' }; +import * as b from 'b' with { type: 'b' }; +export { c } from 'c' with { type: 'c' }; +export * from 'd' with { type: 'd' }; +import 'unresolved' with { type: 'e' }; + +console.log(a, b, d); + + diff --git a/test/form/samples/destructured-known-arguments/_config.js b/test/form/samples/destructured-known-arguments/_config.js new file mode 100644 index 00000000000..62a46d2e945 --- /dev/null +++ b/test/form/samples/destructured-known-arguments/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'tracks known argument values through destructuring' +}); diff --git a/test/form/samples/destructured-known-arguments/_expected.js b/test/form/samples/destructured-known-arguments/_expected.js new file mode 100644 index 00000000000..cfd0627c142 --- /dev/null +++ b/test/form/samples/destructured-known-arguments/_expected.js @@ -0,0 +1,28 @@ +function test1({ a, noEffect, effect }) { + console.log('OK'); + effect(); +} + +test1({ + a: true, + noEffect() {}, + effect() { + console.log('effect'); + } +}); + +function test2({ a, noEffect, effect }) { + console.log('OK'); + effect(); +} + +const obj2 = { + a: true, + noEffect() {}, + effect() { + console.log('effect'); + } +}; + +test2(obj2); +test2(obj2); diff --git a/test/form/samples/destructured-known-arguments/main.js b/test/form/samples/destructured-known-arguments/main.js new file mode 100644 index 00000000000..c4a22063cb9 --- /dev/null +++ b/test/form/samples/destructured-known-arguments/main.js @@ -0,0 +1,32 @@ +function test1({ a, noEffect, effect }) { + if (a) console.log('OK'); + else console.log('REMOVED'); + noEffect(); + effect(); +} + +test1({ + a: true, + noEffect() {}, + effect() { + console.log('effect'); + } +}); + +function test2({ a, noEffect, effect }) { + if (a) console.log('OK'); + else console.log('REMOVED'); + noEffect(); + effect(); +} + +const obj2 = { + a: true, + noEffect() {}, + effect() { + console.log('effect'); + } +}; + +test2(obj2); +test2(obj2); diff --git a/test/form/samples/duplicated-var-declarations/_config.js b/test/form/samples/duplicated-var-declarations/_config.js index 4c3038c2012..fedf39bb118 100644 --- a/test/form/samples/duplicated-var-declarations/_config.js +++ b/test/form/samples/duplicated-var-declarations/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'does not remove duplicated var declarations (#716)' -}; +}); diff --git a/test/form/samples/duplicated-var-declarations/_expected/amd.js b/test/form/samples/duplicated-var-declarations/_expected/amd.js index 727a84d0fe3..a00723d6c0b 100644 --- a/test/form/samples/duplicated-var-declarations/_expected/amd.js +++ b/test/form/samples/duplicated-var-declarations/_expected/amd.js @@ -1,4 +1,4 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; var a = 1, b = 2; @@ -11,4 +11,4 @@ define(function () { 'use strict'; assert.equal( b, 4 ); assert.equal( c, 5 ); -}); +})); diff --git a/test/form/samples/duplicated-var-declarations/_expected/iife.js b/test/form/samples/duplicated-var-declarations/_expected/iife.js index 8251bd3d75e..fb01b3d0bfa 100644 --- a/test/form/samples/duplicated-var-declarations/_expected/iife.js +++ b/test/form/samples/duplicated-var-declarations/_expected/iife.js @@ -12,4 +12,4 @@ assert.equal( b, 4 ); assert.equal( c, 5 ); -}()); +})(); diff --git a/test/form/samples/duplicated-var-declarations/_expected/system.js b/test/form/samples/duplicated-var-declarations/_expected/system.js index c6ea73f5996..ef959a97611 100644 --- a/test/form/samples/duplicated-var-declarations/_expected/system.js +++ b/test/form/samples/duplicated-var-declarations/_expected/system.js @@ -1,7 +1,7 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { var a = 1, b = 2; @@ -14,6 +14,6 @@ System.register([], function () { assert.equal( b, 4 ); assert.equal( c, 5 ); - } + }) }; -}); +})); diff --git a/test/form/samples/duplicated-var-declarations/_expected/umd.js b/test/form/samples/duplicated-var-declarations/_expected/umd.js index b4f8ac51504..a01042ce3d2 100644 --- a/test/form/samples/duplicated-var-declarations/_expected/umd.js +++ b/test/form/samples/duplicated-var-declarations/_expected/umd.js @@ -1,7 +1,7 @@ (function (factory) { typeof define === 'function' && define.amd ? define(factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; var a = 1, b = 2; @@ -14,4 +14,4 @@ assert.equal( b, 4 ); assert.equal( c, 5 ); -}))); +})); diff --git a/test/form/samples/dynamic-import-inlining-array/_config.js b/test/form/samples/dynamic-import-inlining-array/_config.js index 81ad9e51008..dec5250f526 100644 --- a/test/form/samples/dynamic-import-inlining-array/_config.js +++ b/test/form/samples/dynamic-import-inlining-array/_config.js @@ -1,7 +1,7 @@ -module.exports = { +module.exports = defineTest({ description: 'supports an array with a single entry when inlining dynamic imports', options: { output: { inlineDynamicImports: true }, input: ['main'] } -}; +}); diff --git a/test/form/samples/dynamic-import-inlining-array/_expected.js b/test/form/samples/dynamic-import-inlining-array/_expected.js index ae434046e6c..5a35de939db 100644 --- a/test/form/samples/dynamic-import-inlining-array/_expected.js +++ b/test/form/samples/dynamic-import-inlining-array/_expected.js @@ -1,11 +1,8 @@ const bar = 2; -Promise.resolve().then(function () { return foo$1; }); +Promise.resolve().then(function () { return foo; }); -const foo = 1; - -var foo$1 = /*#__PURE__*/Object.freeze({ - __proto__: null, - foo: foo +var foo = /*#__PURE__*/Object.freeze({ + __proto__: null }); export { bar }; diff --git a/test/form/samples/dynamic-import-inlining/_config.js b/test/form/samples/dynamic-import-inlining/_config.js index 7e80cf62b7f..044e3ad0dad 100644 --- a/test/form/samples/dynamic-import-inlining/_config.js +++ b/test/form/samples/dynamic-import-inlining/_config.js @@ -1,6 +1,6 @@ -module.exports = { +module.exports = defineTest({ description: 'dynamic import inlining', options: { output: { inlineDynamicImports: true } } -}; +}); diff --git a/test/form/samples/dynamic-import-inlining/_expected.js b/test/form/samples/dynamic-import-inlining/_expected.js index ae434046e6c..5a35de939db 100644 --- a/test/form/samples/dynamic-import-inlining/_expected.js +++ b/test/form/samples/dynamic-import-inlining/_expected.js @@ -1,11 +1,8 @@ const bar = 2; -Promise.resolve().then(function () { return foo$1; }); +Promise.resolve().then(function () { return foo; }); -const foo = 1; - -var foo$1 = /*#__PURE__*/Object.freeze({ - __proto__: null, - foo: foo +var foo = /*#__PURE__*/Object.freeze({ + __proto__: null }); export { bar }; diff --git a/test/form/samples/dynamic-import-this-arrow/_config.js b/test/form/samples/dynamic-import-this-arrow/_config.js new file mode 100644 index 00000000000..d9417b39078 --- /dev/null +++ b/test/form/samples/dynamic-import-this-arrow/_config.js @@ -0,0 +1,12 @@ +module.exports = defineTest({ + description: 'uses correct "this" in dynamic imports when using arrow functions', + options: { + external: ['input', 'output'], + output: { + dynamicImportInCjs: false, + generatedCode: { arrowFunctions: true }, + globals: { input: 'input', output: 'output' }, + name: 'bundle' + } + } +}); diff --git a/test/form/samples/dynamic-import-this-arrow/_expected/amd.js b/test/form/samples/dynamic-import-this-arrow/_expected/amd.js new file mode 100644 index 00000000000..8385cbfa3df --- /dev/null +++ b/test/form/samples/dynamic-import-this-arrow/_expected/amd.js @@ -0,0 +1,34 @@ +define(['require', 'exports', 'input'], (function (require, exports, input) { 'use strict'; + + function _interopNamespaceDefault(e) { + var n = Object.create(null); + if (e) { + Object.keys(e).forEach(k => { + if (k !== 'default') { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: () => e[k] + }); + } + }); + } + n.default = e; + return Object.freeze(n); + } + + class Importer { + constructor() { + this.outputPath = input.outputPath; + } + + getImport() { + return new Promise((resolve, reject) => require([this.outputPath], m => resolve(/*#__PURE__*/_interopNamespaceDefault(m)), reject)); + } + } + + const promise = new Importer().getImport(); + + exports.promise = promise; + +})); diff --git a/test/form/samples/dynamic-import-this-arrow/_expected/cjs.js b/test/form/samples/dynamic-import-this-arrow/_expected/cjs.js new file mode 100644 index 00000000000..5a9c79f87e3 --- /dev/null +++ b/test/form/samples/dynamic-import-this-arrow/_expected/cjs.js @@ -0,0 +1,34 @@ +'use strict'; + +var input = require('input'); + +function _interopNamespaceDefault(e) { + var n = Object.create(null); + if (e) { + Object.keys(e).forEach(k => { + if (k !== 'default') { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: () => e[k] + }); + } + }); + } + n.default = e; + return Object.freeze(n); +} + +class Importer { + constructor() { + this.outputPath = input.outputPath; + } + + getImport() { + return Promise.resolve().then(() => /*#__PURE__*/_interopNamespaceDefault(require(this.outputPath))); + } +} + +const promise = new Importer().getImport(); + +exports.promise = promise; diff --git a/test/form/samples/dynamic-import-this-arrow/_expected/es.js b/test/form/samples/dynamic-import-this-arrow/_expected/es.js new file mode 100644 index 00000000000..256926d1ce5 --- /dev/null +++ b/test/form/samples/dynamic-import-this-arrow/_expected/es.js @@ -0,0 +1,15 @@ +import { outputPath } from 'input'; + +class Importer { + constructor() { + this.outputPath = outputPath; + } + + getImport() { + return import(this.outputPath); + } +} + +const promise = new Importer().getImport(); + +export { promise }; diff --git a/test/form/samples/dynamic-import-this-arrow/_expected/iife.js b/test/form/samples/dynamic-import-this-arrow/_expected/iife.js new file mode 100644 index 00000000000..0cf64319d02 --- /dev/null +++ b/test/form/samples/dynamic-import-this-arrow/_expected/iife.js @@ -0,0 +1,20 @@ +var bundle = (function (exports, input) { + 'use strict'; + + class Importer { + constructor() { + this.outputPath = input.outputPath; + } + + getImport() { + return import(this.outputPath); + } + } + + const promise = new Importer().getImport(); + + exports.promise = promise; + + return exports; + +})({}, input); diff --git a/test/form/samples/dynamic-import-this-arrow/_expected/system.js b/test/form/samples/dynamic-import-this-arrow/_expected/system.js new file mode 100644 index 00000000000..c73faeaa83f --- /dev/null +++ b/test/form/samples/dynamic-import-this-arrow/_expected/system.js @@ -0,0 +1,24 @@ +System.register('bundle', ['input'], (function (exports, module) { + 'use strict'; + var outputPath; + return { + setters: [module => { + outputPath = module.outputPath; + }], + execute: (function () { + + class Importer { + constructor() { + this.outputPath = outputPath; + } + + getImport() { + return module.import(this.outputPath); + } + } + + const promise = exports("promise", new Importer().getImport()); + + }) + }; +})); diff --git a/test/form/samples/dynamic-import-this-arrow/_expected/umd.js b/test/form/samples/dynamic-import-this-arrow/_expected/umd.js new file mode 100644 index 00000000000..dae70b6a615 --- /dev/null +++ b/test/form/samples/dynamic-import-this-arrow/_expected/umd.js @@ -0,0 +1,21 @@ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('input')) : + typeof define === 'function' && define.amd ? define(['exports', 'input'], factory) : + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.bundle = {}, global.input)); +})(this, (function (exports, input) { 'use strict'; + + class Importer { + constructor() { + this.outputPath = input.outputPath; + } + + getImport() { + return import(this.outputPath); + } + } + + const promise = new Importer().getImport(); + + exports.promise = promise; + +})); diff --git a/test/form/samples/dynamic-import-this-arrow/main.js b/test/form/samples/dynamic-import-this-arrow/main.js new file mode 100644 index 00000000000..bfe419d7fef --- /dev/null +++ b/test/form/samples/dynamic-import-this-arrow/main.js @@ -0,0 +1,13 @@ +import { outputPath } from 'input'; + +class Importer { + constructor() { + this.outputPath = outputPath; + } + + getImport() { + return import(this.outputPath); + } +} + +export const promise = new Importer().getImport(); diff --git a/test/form/samples/dynamic-import-this-function/_config.js b/test/form/samples/dynamic-import-this-function/_config.js new file mode 100644 index 00000000000..a9ec090f100 --- /dev/null +++ b/test/form/samples/dynamic-import-this-function/_config.js @@ -0,0 +1,12 @@ +module.exports = defineTest({ + description: 'uses correct "this" in dynamic imports when not using arrow functions', + options: { + external: ['input', 'output'], + output: { + dynamicImportInCjs: false, + generatedCode: { arrowFunctions: false }, + globals: { input: 'input', output: 'output' }, + name: 'bundle' + } + } +}); diff --git a/test/form/samples/dynamic-import-this-function/_expected/amd.js b/test/form/samples/dynamic-import-this-function/_expected/amd.js new file mode 100644 index 00000000000..bfec23bb7f0 --- /dev/null +++ b/test/form/samples/dynamic-import-this-function/_expected/amd.js @@ -0,0 +1,34 @@ +define(['require', 'exports', 'input'], (function (require, exports, input) { 'use strict'; + + function _interopNamespaceDefault(e) { + var n = Object.create(null); + if (e) { + Object.keys(e).forEach(function (k) { + if (k !== 'default') { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + } + n.default = e; + return Object.freeze(n); + } + + class Importer { + constructor() { + this.outputPath = input.outputPath; + } + + getImport() { + return (function (t) { return new Promise(function (resolve, reject) { require([t], function (m) { resolve(/*#__PURE__*/_interopNamespaceDefault(m)); }, reject); }); })(this.outputPath); + } + } + + const promise = new Importer().getImport(); + + exports.promise = promise; + +})); diff --git a/test/form/samples/dynamic-import-this-function/_expected/cjs.js b/test/form/samples/dynamic-import-this-function/_expected/cjs.js new file mode 100644 index 00000000000..64d752617c3 --- /dev/null +++ b/test/form/samples/dynamic-import-this-function/_expected/cjs.js @@ -0,0 +1,34 @@ +'use strict'; + +var input = require('input'); + +function _interopNamespaceDefault(e) { + var n = Object.create(null); + if (e) { + Object.keys(e).forEach(function (k) { + if (k !== 'default') { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + } + n.default = e; + return Object.freeze(n); +} + +class Importer { + constructor() { + this.outputPath = input.outputPath; + } + + getImport() { + return (function (t) { return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespaceDefault(require(t)); }); })(this.outputPath); + } +} + +const promise = new Importer().getImport(); + +exports.promise = promise; diff --git a/test/form/samples/dynamic-import-this-function/_expected/es.js b/test/form/samples/dynamic-import-this-function/_expected/es.js new file mode 100644 index 00000000000..256926d1ce5 --- /dev/null +++ b/test/form/samples/dynamic-import-this-function/_expected/es.js @@ -0,0 +1,15 @@ +import { outputPath } from 'input'; + +class Importer { + constructor() { + this.outputPath = outputPath; + } + + getImport() { + return import(this.outputPath); + } +} + +const promise = new Importer().getImport(); + +export { promise }; diff --git a/test/form/samples/dynamic-import-this-function/_expected/iife.js b/test/form/samples/dynamic-import-this-function/_expected/iife.js new file mode 100644 index 00000000000..0cf64319d02 --- /dev/null +++ b/test/form/samples/dynamic-import-this-function/_expected/iife.js @@ -0,0 +1,20 @@ +var bundle = (function (exports, input) { + 'use strict'; + + class Importer { + constructor() { + this.outputPath = input.outputPath; + } + + getImport() { + return import(this.outputPath); + } + } + + const promise = new Importer().getImport(); + + exports.promise = promise; + + return exports; + +})({}, input); diff --git a/test/form/samples/dynamic-import-this-function/_expected/system.js b/test/form/samples/dynamic-import-this-function/_expected/system.js new file mode 100644 index 00000000000..6c25c1ac18b --- /dev/null +++ b/test/form/samples/dynamic-import-this-function/_expected/system.js @@ -0,0 +1,24 @@ +System.register('bundle', ['input'], (function (exports, module) { + 'use strict'; + var outputPath; + return { + setters: [function (module) { + outputPath = module.outputPath; + }], + execute: (function () { + + class Importer { + constructor() { + this.outputPath = outputPath; + } + + getImport() { + return module.import(this.outputPath); + } + } + + const promise = exports("promise", new Importer().getImport()); + + }) + }; +})); diff --git a/test/form/samples/dynamic-import-this-function/_expected/umd.js b/test/form/samples/dynamic-import-this-function/_expected/umd.js new file mode 100644 index 00000000000..dae70b6a615 --- /dev/null +++ b/test/form/samples/dynamic-import-this-function/_expected/umd.js @@ -0,0 +1,21 @@ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('input')) : + typeof define === 'function' && define.amd ? define(['exports', 'input'], factory) : + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.bundle = {}, global.input)); +})(this, (function (exports, input) { 'use strict'; + + class Importer { + constructor() { + this.outputPath = input.outputPath; + } + + getImport() { + return import(this.outputPath); + } + } + + const promise = new Importer().getImport(); + + exports.promise = promise; + +})); diff --git a/test/form/samples/dynamic-import-this-function/main.js b/test/form/samples/dynamic-import-this-function/main.js new file mode 100644 index 00000000000..bfe419d7fef --- /dev/null +++ b/test/form/samples/dynamic-import-this-function/main.js @@ -0,0 +1,13 @@ +import { outputPath } from 'input'; + +class Importer { + constructor() { + this.outputPath = outputPath; + } + + getImport() { + return import(this.outputPath); + } +} + +export const promise = new Importer().getImport(); diff --git a/test/form/samples/dynamic-import-unresolvable/_config.js b/test/form/samples/dynamic-import-unresolvable/_config.js index 66a9e5692d6..ed910b7c271 100644 --- a/test/form/samples/dynamic-import-unresolvable/_config.js +++ b/test/form/samples/dynamic-import-unresolvable/_config.js @@ -1,16 +1,19 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'Returns the raw AST nodes for unresolvable dynamic imports', options: { plugins: [ { + name: 'test', resolveDynamicImport(specifier) { if (specifier === './seven.js') { return false; } assert.ok(specifier); - assert.strictEqual(typeof specifier, 'object'); + if (typeof specifier !== 'object') { + throw new TypeError(`Unexpected specifier type ${typeof specifier}.`); + } if (specifier.type === 'Literal') { return "'./seven.js'"; } @@ -22,4 +25,4 @@ module.exports = { } ] } -}; +}); diff --git a/test/form/samples/dynamic-import-unresolvable/_expected/amd.js b/test/form/samples/dynamic-import-unresolvable/_expected/amd.js index 4f28a13d7c6..8f187653112 100644 --- a/test/form/samples/dynamic-import-unresolvable/_expected/amd.js +++ b/test/form/samples/dynamic-import-unresolvable/_expected/amd.js @@ -1,7 +1,6 @@ -define(['require'], function (require) { 'use strict'; +define(['require'], (function (require) { 'use strict'; - function _interopNamespace(e) { - if (e && e.__esModule) return e; + function _interopNamespaceDefault(e) { var n = Object.create(null); if (e) { Object.keys(e).forEach(function (k) { @@ -9,20 +8,18 @@ define(['require'], function (require) { 'use strict'; var d = Object.getOwnPropertyDescriptor(e, k); Object.defineProperty(n, k, d.get ? d : { enumerable: true, - get: function () { - return e[k]; - } + get: function () { return e[k]; } }); } }); } - n['default'] = e; + n.default = e; return Object.freeze(n); } - new Promise(function (resolve, reject) { require([`${globalThis.unknown}`], function (m) { resolve(/*#__PURE__*/_interopNamespace(m)); }, reject) }); - new Promise(function (resolve, reject) { require([`My ${globalThis.unknown}`], function (m) { resolve(/*#__PURE__*/_interopNamespace(m)); }, reject) }); - new Promise(function (resolve, reject) { require(['./seven.js'], function (m) { resolve(/*#__PURE__*/_interopNamespace(m)); }, reject) }); - new Promise(function (resolve, reject) { require(['./seven'], function (m) { resolve(/*#__PURE__*/_interopNamespace(m)); }, reject) }); + (function (t) { return new Promise(function (resolve, reject) { require([t], function (m) { resolve(/*#__PURE__*/_interopNamespaceDefault(m)); }, reject); }); })(`${globalThis.unknown}`); + (function (t) { return new Promise(function (resolve, reject) { require([t], function (m) { resolve(/*#__PURE__*/_interopNamespaceDefault(m)); }, reject); }); })(`My ${globalThis.unknown}`); + (function (t) { return new Promise(function (resolve, reject) { require([t], function (m) { resolve(/*#__PURE__*/_interopNamespaceDefault(m)); }, reject); }); })('./seven.js'); + new Promise(function (resolve, reject) { require(['./seven'], function (m) { resolve(/*#__PURE__*/_interopNamespaceDefault(m)); }, reject); }); -}); +})); diff --git a/test/form/samples/dynamic-import-unresolvable/_expected/cjs.js b/test/form/samples/dynamic-import-unresolvable/_expected/cjs.js index a9d51c59d13..d566db97089 100644 --- a/test/form/samples/dynamic-import-unresolvable/_expected/cjs.js +++ b/test/form/samples/dynamic-import-unresolvable/_expected/cjs.js @@ -1,26 +1,6 @@ 'use strict'; -function _interopNamespace(e) { - if (e && e.__esModule) return e; - var n = Object.create(null); - if (e) { - Object.keys(e).forEach(function (k) { - if (k !== 'default') { - var d = Object.getOwnPropertyDescriptor(e, k); - Object.defineProperty(n, k, d.get ? d : { - enumerable: true, - get: function () { - return e[k]; - } - }); - } - }); - } - n['default'] = e; - return Object.freeze(n); -} - -Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(`${globalThis.unknown}`)); }); -Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(`My ${globalThis.unknown}`)); }); -Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('./seven.js')); }); -Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('./seven.js')); }); +import(`${globalThis.unknown}`); +import(`My ${globalThis.unknown}`); +import('./seven.js'); +import('./seven.js'); diff --git a/test/form/samples/dynamic-import-unresolvable/_expected/iife.js b/test/form/samples/dynamic-import-unresolvable/_expected/iife.js index 83008aee524..4cf1fdf053e 100644 --- a/test/form/samples/dynamic-import-unresolvable/_expected/iife.js +++ b/test/form/samples/dynamic-import-unresolvable/_expected/iife.js @@ -6,4 +6,4 @@ import('./seven.js'); import('./seven.js'); -}()); +})(); diff --git a/test/form/samples/dynamic-import-unresolvable/_expected/system.js b/test/form/samples/dynamic-import-unresolvable/_expected/system.js index ec2f668e4b4..d0c1de08c8e 100644 --- a/test/form/samples/dynamic-import-unresolvable/_expected/system.js +++ b/test/form/samples/dynamic-import-unresolvable/_expected/system.js @@ -1,13 +1,13 @@ -System.register([], function (exports, module) { +System.register([], (function (exports, module) { 'use strict'; return { - execute: function () { + execute: (function () { module.import(`${globalThis.unknown}`); module.import(`My ${globalThis.unknown}`); module.import('./seven.js'); module.import('./seven.js'); - } + }) }; -}); +})); diff --git a/test/form/samples/dynamic-import-unresolvable/_expected/umd.js b/test/form/samples/dynamic-import-unresolvable/_expected/umd.js index d5aee0821a3..f35d647d90f 100644 --- a/test/form/samples/dynamic-import-unresolvable/_expected/umd.js +++ b/test/form/samples/dynamic-import-unresolvable/_expected/umd.js @@ -1,11 +1,11 @@ (function (factory) { typeof define === 'function' && define.amd ? define(factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; import(`${globalThis.unknown}`); import(`My ${globalThis.unknown}`); import('./seven.js'); import('./seven.js'); -}))); +})); diff --git a/test/form/samples/dynamic-resolvable-if-statements/_config.js b/test/form/samples/dynamic-resolvable-if-statements/_config.js index d091bcf95d1..5e014dd0e7e 100644 --- a/test/form/samples/dynamic-resolvable-if-statements/_config.js +++ b/test/form/samples/dynamic-resolvable-if-statements/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'allows using variables to resolve conditionals' -}; +}); diff --git a/test/form/samples/early-bind-member-expressions/_config.js b/test/form/samples/early-bind-member-expressions/_config.js index bfd03baa8d6..8a6ee776cdf 100644 --- a/test/form/samples/early-bind-member-expressions/_config.js +++ b/test/form/samples/early-bind-member-expressions/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'correctly resolves namespace members when accessed early (#2895)', options: { external: 'external' } -}; +}); diff --git a/test/form/samples/early-bind-member-expressions/_expected.js b/test/form/samples/early-bind-member-expressions/_expected.js index 9fefa5dfc12..b3755754a13 100644 --- a/test/form/samples/early-bind-member-expressions/_expected.js +++ b/test/form/samples/early-bind-member-expressions/_expected.js @@ -1,3 +1,3 @@ import * as stuff from 'external'; -stuff.y(); +const {x} = stuff.y(); diff --git a/test/form/samples/effect-in-for-of-loop-in-functions/_config.js b/test/form/samples/effect-in-for-of-loop-in-functions/_config.js index 0e80a63f4a0..6077ac42d3a 100644 --- a/test/form/samples/effect-in-for-of-loop-in-functions/_config.js +++ b/test/form/samples/effect-in-for-of-loop-in-functions/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'includes effects in for-of loop (#870)' -}; +}); diff --git a/test/form/samples/effect-in-for-of-loop-in-functions/_expected/amd.js b/test/form/samples/effect-in-for-of-loop-in-functions/_expected/amd.js index 4d69a4b15b7..92d30ca9892 100644 --- a/test/form/samples/effect-in-for-of-loop-in-functions/_expected/amd.js +++ b/test/form/samples/effect-in-for-of-loop-in-functions/_expected/amd.js @@ -1,4 +1,4 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; const items = { children: [ {}, {}, {} ] }; @@ -25,4 +25,4 @@ define(function () { 'use strict'; { foo: 'a', bar: 'c' } ] ); -}); +})); diff --git a/test/form/samples/effect-in-for-of-loop-in-functions/_expected/iife.js b/test/form/samples/effect-in-for-of-loop-in-functions/_expected/iife.js index 7e12d263cb1..25ef94a0fc6 100644 --- a/test/form/samples/effect-in-for-of-loop-in-functions/_expected/iife.js +++ b/test/form/samples/effect-in-for-of-loop-in-functions/_expected/iife.js @@ -26,4 +26,4 @@ { foo: 'a', bar: 'c' } ] ); -}()); +})(); diff --git a/test/form/samples/effect-in-for-of-loop-in-functions/_expected/system.js b/test/form/samples/effect-in-for-of-loop-in-functions/_expected/system.js index 93ba5ca8f18..96b2d32a5a1 100644 --- a/test/form/samples/effect-in-for-of-loop-in-functions/_expected/system.js +++ b/test/form/samples/effect-in-for-of-loop-in-functions/_expected/system.js @@ -1,7 +1,7 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { const items = { children: [ {}, {}, {} ] }; @@ -28,6 +28,6 @@ System.register([], function () { { foo: 'a', bar: 'c' } ] ); - } + }) }; -}); +})); diff --git a/test/form/samples/effect-in-for-of-loop-in-functions/_expected/umd.js b/test/form/samples/effect-in-for-of-loop-in-functions/_expected/umd.js index f40d70d267d..2a4e15423ea 100644 --- a/test/form/samples/effect-in-for-of-loop-in-functions/_expected/umd.js +++ b/test/form/samples/effect-in-for-of-loop-in-functions/_expected/umd.js @@ -1,7 +1,7 @@ (function (factory) { typeof define === 'function' && define.amd ? define(factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; const items = { children: [ {}, {}, {} ] }; @@ -28,4 +28,4 @@ { foo: 'a', bar: 'c' } ] ); -}))); +})); diff --git a/test/form/samples/effect-in-for-of-loop/_config.js b/test/form/samples/effect-in-for-of-loop/_config.js index 0e80a63f4a0..6077ac42d3a 100644 --- a/test/form/samples/effect-in-for-of-loop/_config.js +++ b/test/form/samples/effect-in-for-of-loop/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'includes effects in for-of loop (#870)' -}; +}); diff --git a/test/form/samples/effect-in-for-of-loop/_expected/amd.js b/test/form/samples/effect-in-for-of-loop/_expected/amd.js index cba6da29411..7e9ab29e99a 100644 --- a/test/form/samples/effect-in-for-of-loop/_expected/amd.js +++ b/test/form/samples/effect-in-for-of-loop/_expected/amd.js @@ -1,4 +1,4 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; const items = [{}, {}, {}]; @@ -22,4 +22,4 @@ define(function () { 'use strict'; { foo: 'a', bar: 'c', baz: 'e' } ]); -}); +})); diff --git a/test/form/samples/effect-in-for-of-loop/_expected/iife.js b/test/form/samples/effect-in-for-of-loop/_expected/iife.js index 5a3e4a30f96..2e5cc1718d1 100644 --- a/test/form/samples/effect-in-for-of-loop/_expected/iife.js +++ b/test/form/samples/effect-in-for-of-loop/_expected/iife.js @@ -23,4 +23,4 @@ { foo: 'a', bar: 'c', baz: 'e' } ]); -}()); +})(); diff --git a/test/form/samples/effect-in-for-of-loop/_expected/system.js b/test/form/samples/effect-in-for-of-loop/_expected/system.js index c8f28682e02..12f7f0867b6 100644 --- a/test/form/samples/effect-in-for-of-loop/_expected/system.js +++ b/test/form/samples/effect-in-for-of-loop/_expected/system.js @@ -1,7 +1,7 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { const items = [{}, {}, {}]; @@ -25,6 +25,6 @@ System.register([], function () { { foo: 'a', bar: 'c', baz: 'e' } ]); - } + }) }; -}); +})); diff --git a/test/form/samples/effect-in-for-of-loop/_expected/umd.js b/test/form/samples/effect-in-for-of-loop/_expected/umd.js index 89a3d13361c..d77229f41f4 100644 --- a/test/form/samples/effect-in-for-of-loop/_expected/umd.js +++ b/test/form/samples/effect-in-for-of-loop/_expected/umd.js @@ -1,7 +1,7 @@ (function (factory) { typeof define === 'function' && define.amd ? define(factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; const items = [{}, {}, {}]; @@ -25,4 +25,4 @@ { foo: 'a', bar: 'c', baz: 'e' } ]); -}))); +})); diff --git a/test/form/samples/emit-asset-file/_config.js b/test/form/samples/emit-asset-file/_config.js index b9f1d83de22..80effd6d608 100644 --- a/test/form/samples/emit-asset-file/_config.js +++ b/test/form/samples/emit-asset-file/_config.js @@ -1,38 +1,46 @@ -const fs = require('fs'); -const path = require('path'); -const assert = require('assert'); +const assert = require('node:assert'); +const { readFileSync } = require('node:fs'); +const path = require('node:path'); -module.exports = { +module.exports = defineTest({ description: 'supports emitting assets from plugin hooks', options: { - plugins: { - resolveId(id, importee) { - if (id.endsWith('.svg')) { - return path.resolve(path.dirname(importee), id); + plugins: [ + { + name: 'test', + resolveId(id, importee) { + if (id.endsWith('.svg')) { + return path.resolve(path.dirname(importee), id); + } + }, + load(id) { + if (id.endsWith('.svg')) { + return `export default import.meta.ROLLUP_FILE_URL_${this.emitFile({ + type: 'asset', + name: path.basename(id), + source: readFileSync(id) + })};`; + } + }, + generateBundle(options, outputBundle) { + const keys = Object.keys(outputBundle); + assert.strictEqual(keys.length, 3); + assert.strictEqual(keys[0], 'assets/logo-zDlmrXar.svg'); + const asset = outputBundle[keys[0]]; + assert.strictEqual(asset.fileName, 'assets/logo-zDlmrXar.svg'); + if (asset.type !== 'asset') { + throw new Error(`Unexpected asset type ${asset.type}.`); + } + /** @type {any} */ + const source = asset.source; + assert.ok( + source.equals(readFileSync(path.resolve(__dirname, 'logo.svg'))), + 'asset has correct source' + ); + assert.ok(keys[1].endsWith('.svg'), `${keys[1]} ends with ".svg"`); + assert.ok(keys[2].endsWith('.js'), `${keys[2]} ends with ".js"`); } - }, - load(id) { - if (id.endsWith('.svg')) { - return `export default import.meta.ROLLUP_FILE_URL_${this.emitFile({ - type: 'asset', - name: path.basename(id), - source: fs.readFileSync(id) - })};`; - } - }, - generateBundle(options, outputBundle) { - const keys = Object.keys(outputBundle); - assert.strictEqual(keys.length, 2); - assert.strictEqual(keys[0], 'assets/logo-25585ac1.svg'); - const asset = outputBundle[keys[0]]; - assert.strictEqual(asset.fileName, 'assets/logo-25585ac1.svg'); - assert.strictEqual(asset.type, 'asset'); - assert.ok( - asset.source.equals(fs.readFileSync(path.resolve(__dirname, 'logo.svg'))), - 'asset has correct source' - ); - assert.ok(keys[1].endsWith('.js'), `${keys[1]} ends with ".js"`); } - } + ] } -}; +}); diff --git a/test/form/samples/emit-asset-file/_expected/amd.js b/test/form/samples/emit-asset-file/_expected/amd.js index 36634121098..8382fa7270d 100644 --- a/test/form/samples/emit-asset-file/_expected/amd.js +++ b/test/form/samples/emit-asset-file/_expected/amd.js @@ -1,6 +1,8 @@ -define(['require'], function (require) { 'use strict'; +define(['require'], (function (require) { 'use strict'; - var logo = new URL(require.toUrl('./assets/logo-25585ac1.svg'), document.baseURI).href; + var logo = new URL(require.toUrl('./assets/logo-zDlmrXar.svg'), document.baseURI).href; + + var logoReverse = new URL(require.toUrl('./assets/logo_reverse\'-DbGK2oiS.svg'), document.baseURI).href; function showImage(url) { console.log(url); @@ -12,5 +14,6 @@ define(['require'], function (require) { 'use strict'; } showImage(logo); + showImage(logoReverse); -}); +})); diff --git a/test/form/samples/emit-asset-file/_expected/assets/logo-25585ac1.svg b/test/form/samples/emit-asset-file/_expected/assets/logo-25585ac1.svg deleted file mode 100644 index 20bb5dfe639..00000000000 --- a/test/form/samples/emit-asset-file/_expected/assets/logo-25585ac1.svg +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/test/form/samples/deprecated/emit-asset/_expected/assets/logo-25585ac1.svg b/test/form/samples/emit-asset-file/_expected/assets/logo-zDlmrXar.svg similarity index 100% rename from test/form/samples/deprecated/emit-asset/_expected/assets/logo-25585ac1.svg rename to test/form/samples/emit-asset-file/_expected/assets/logo-zDlmrXar.svg diff --git a/test/form/samples/emit-asset-file/_expected/assets/logo_reverse'-DbGK2oiS.svg b/test/form/samples/emit-asset-file/_expected/assets/logo_reverse'-DbGK2oiS.svg new file mode 100644 index 00000000000..31bbbec2741 --- /dev/null +++ b/test/form/samples/emit-asset-file/_expected/assets/logo_reverse'-DbGK2oiS.svg @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/form/samples/emit-asset-file/_expected/cjs.js b/test/form/samples/emit-asset-file/_expected/cjs.js index f9a9dac3e1e..a045b662ea4 100644 --- a/test/form/samples/emit-asset-file/_expected/cjs.js +++ b/test/form/samples/emit-asset-file/_expected/cjs.js @@ -1,6 +1,8 @@ 'use strict'; -var logo = (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __dirname + '/assets/logo-25585ac1.svg').href : new URL('assets/logo-25585ac1.svg', document.currentScript && document.currentScript.src || document.baseURI).href); +var logo = (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__dirname + '/assets/logo-zDlmrXar.svg').href : new URL('assets/logo-zDlmrXar.svg', document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT' && document.currentScript.src || document.baseURI).href); + +var logoReverse = (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__dirname + '/assets/logo_reverse\'-DbGK2oiS.svg').href : new URL('assets/logo_reverse\'-DbGK2oiS.svg', document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT' && document.currentScript.src || document.baseURI).href); function showImage(url) { console.log(url); @@ -12,3 +14,4 @@ function showImage(url) { } showImage(logo); +showImage(logoReverse); diff --git a/test/form/samples/emit-asset-file/_expected/es.js b/test/form/samples/emit-asset-file/_expected/es.js index d100d42e367..a10d0191da5 100644 --- a/test/form/samples/emit-asset-file/_expected/es.js +++ b/test/form/samples/emit-asset-file/_expected/es.js @@ -1,4 +1,6 @@ -var logo = new URL('assets/logo-25585ac1.svg', import.meta.url).href; +var logo = new URL('assets/logo-zDlmrXar.svg', import.meta.url).href; + +var logoReverse = new URL('assets/logo_reverse\'-DbGK2oiS.svg', import.meta.url).href; function showImage(url) { console.log(url); @@ -10,3 +12,4 @@ function showImage(url) { } showImage(logo); +showImage(logoReverse); diff --git a/test/form/samples/emit-asset-file/_expected/iife.js b/test/form/samples/emit-asset-file/_expected/iife.js index 97c9c3432a2..99f0cd4ef98 100644 --- a/test/form/samples/emit-asset-file/_expected/iife.js +++ b/test/form/samples/emit-asset-file/_expected/iife.js @@ -1,7 +1,9 @@ (function () { 'use strict'; - var logo = new URL('assets/logo-25585ac1.svg', document.currentScript && document.currentScript.src || document.baseURI).href; + var logo = new URL('assets/logo-zDlmrXar.svg', document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT' && document.currentScript.src || document.baseURI).href; + + var logoReverse = new URL('assets/logo_reverse\'-DbGK2oiS.svg', document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT' && document.currentScript.src || document.baseURI).href; function showImage(url) { console.log(url); @@ -13,5 +15,6 @@ } showImage(logo); + showImage(logoReverse); -}()); +})(); diff --git a/test/form/samples/emit-asset-file/_expected/system.js b/test/form/samples/emit-asset-file/_expected/system.js index 0c3f132dc7f..f30b86f49e8 100644 --- a/test/form/samples/emit-asset-file/_expected/system.js +++ b/test/form/samples/emit-asset-file/_expected/system.js @@ -1,9 +1,11 @@ -System.register([], function (exports, module) { +System.register([], (function (exports, module) { 'use strict'; return { - execute: function () { + execute: (function () { - var logo = new URL('assets/logo-25585ac1.svg', module.meta.url).href; + var logo = new URL('assets/logo-zDlmrXar.svg', module.meta.url).href; + + var logoReverse = new URL('assets/logo_reverse\'-DbGK2oiS.svg', module.meta.url).href; function showImage(url) { console.log(url); @@ -15,7 +17,8 @@ System.register([], function (exports, module) { } showImage(logo); + showImage(logoReverse); - } + }) }; -}); +})); diff --git a/test/form/samples/emit-asset-file/_expected/umd.js b/test/form/samples/emit-asset-file/_expected/umd.js index 313ffcb5169..b0a946f43b8 100644 --- a/test/form/samples/emit-asset-file/_expected/umd.js +++ b/test/form/samples/emit-asset-file/_expected/umd.js @@ -1,9 +1,11 @@ (function (factory) { typeof define === 'function' && define.amd ? define(factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; - var logo = (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __dirname + '/assets/logo-25585ac1.svg').href : new URL('assets/logo-25585ac1.svg', document.currentScript && document.currentScript.src || document.baseURI).href); + var logo = (typeof document === 'undefined' && typeof location === 'undefined' ? require('u' + 'rl').pathToFileURL(__dirname + '/assets/logo-zDlmrXar.svg').href : new URL('assets/logo-zDlmrXar.svg', typeof document === 'undefined' ? location.href : document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT' && document.currentScript.src || document.baseURI).href); + + var logoReverse = (typeof document === 'undefined' && typeof location === 'undefined' ? require('u' + 'rl').pathToFileURL(__dirname + '/assets/logo_reverse\'-DbGK2oiS.svg').href : new URL('assets/logo_reverse\'-DbGK2oiS.svg', typeof document === 'undefined' ? location.href : document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT' && document.currentScript.src || document.baseURI).href); function showImage(url) { console.log(url); @@ -15,5 +17,6 @@ } showImage(logo); + showImage(logoReverse); -}))); +})); diff --git a/test/form/samples/emit-asset-file/logo_reverse'.svg b/test/form/samples/emit-asset-file/logo_reverse'.svg new file mode 100644 index 00000000000..31bbbec2741 --- /dev/null +++ b/test/form/samples/emit-asset-file/logo_reverse'.svg @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/form/samples/emit-asset-file/main.js b/test/form/samples/emit-asset-file/main.js index c63771af02d..b6ce90e15ca 100644 --- a/test/form/samples/emit-asset-file/main.js +++ b/test/form/samples/emit-asset-file/main.js @@ -1,4 +1,5 @@ import logo from './logo.svg'; +import logoReverse from "./logo_reverse'.svg" function showImage(url) { console.log(url); @@ -10,3 +11,4 @@ function showImage(url) { } showImage(logo); +showImage(logoReverse); diff --git a/test/form/samples/emit-file-tree-shaken-access/_config.js b/test/form/samples/emit-file-tree-shaken-access/_config.js index 1feae6664f4..03475f0ea47 100644 --- a/test/form/samples/emit-file-tree-shaken-access/_config.js +++ b/test/form/samples/emit-file-tree-shaken-access/_config.js @@ -1,24 +1,27 @@ -const fs = require('fs'); -const path = require('path'); +const { readFileSync } = require('node:fs'); +const path = require('node:path'); -module.exports = { +module.exports = defineTest({ description: 'does not include format globals when tree-shaking an asset access', options: { - plugins: { - resolveId(id, importee) { - if (id.endsWith('.svg')) { - return path.resolve(path.dirname(importee), id); - } - }, - load(id) { - if (id.endsWith('.svg')) { - return `export default import.meta.ROLLUP_FILE_URL_${this.emitFile({ - type: 'asset', - name: path.basename(id), - source: fs.readFileSync(id) - })};`; + plugins: [ + { + name: 'test', + resolveId(id, importee) { + if (id.endsWith('.svg')) { + return path.resolve(path.dirname(importee), id); + } + }, + load(id) { + if (id.endsWith('.svg')) { + return `export default import.meta.ROLLUP_FILE_URL_${this.emitFile({ + type: 'asset', + name: path.basename(id), + source: readFileSync(id) + })};`; + } } } - } + ] } -}; +}); diff --git a/test/form/samples/emit-file-tree-shaken-access/_expected/amd.js b/test/form/samples/emit-file-tree-shaken-access/_expected/amd.js index 126aa22ee83..49540b44d78 100644 --- a/test/form/samples/emit-file-tree-shaken-access/_expected/amd.js +++ b/test/form/samples/emit-file-tree-shaken-access/_expected/amd.js @@ -1,5 +1,5 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; console.log('main'); -}); +})); diff --git a/test/form/samples/emit-file-tree-shaken-access/_expected/assets/logo-25585ac1.svg b/test/form/samples/emit-file-tree-shaken-access/_expected/assets/logo-25585ac1.svg deleted file mode 100644 index 20bb5dfe639..00000000000 --- a/test/form/samples/emit-file-tree-shaken-access/_expected/assets/logo-25585ac1.svg +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/test/form/samples/deprecated/emit-asset/logo.svg b/test/form/samples/emit-file-tree-shaken-access/_expected/assets/logo-zDlmrXar.svg similarity index 100% rename from test/form/samples/deprecated/emit-asset/logo.svg rename to test/form/samples/emit-file-tree-shaken-access/_expected/assets/logo-zDlmrXar.svg diff --git a/test/form/samples/emit-file-tree-shaken-access/_expected/iife.js b/test/form/samples/emit-file-tree-shaken-access/_expected/iife.js index d283cbce8ba..455edee6aa6 100644 --- a/test/form/samples/emit-file-tree-shaken-access/_expected/iife.js +++ b/test/form/samples/emit-file-tree-shaken-access/_expected/iife.js @@ -3,4 +3,4 @@ console.log('main'); -}()); +})(); diff --git a/test/form/samples/emit-file-tree-shaken-access/_expected/system.js b/test/form/samples/emit-file-tree-shaken-access/_expected/system.js index c83499bc2d4..35e2693371a 100644 --- a/test/form/samples/emit-file-tree-shaken-access/_expected/system.js +++ b/test/form/samples/emit-file-tree-shaken-access/_expected/system.js @@ -1,10 +1,10 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { console.log('main'); - } + }) }; -}); +})); diff --git a/test/form/samples/emit-file-tree-shaken-access/_expected/umd.js b/test/form/samples/emit-file-tree-shaken-access/_expected/umd.js index f69e11c0256..c8ba7daa897 100644 --- a/test/form/samples/emit-file-tree-shaken-access/_expected/umd.js +++ b/test/form/samples/emit-file-tree-shaken-access/_expected/umd.js @@ -1,8 +1,8 @@ (function (factory) { typeof define === 'function' && define.amd ? define(factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; console.log('main'); -}))); +})); diff --git a/test/form/samples/emit-uint8array-no-buffer/_config.js b/test/form/samples/emit-uint8array-no-buffer/_config.js index 501a5319eca..2d77cc8a255 100644 --- a/test/form/samples/emit-uint8array-no-buffer/_config.js +++ b/test/form/samples/emit-uint8array-no-buffer/_config.js @@ -1,8 +1,7 @@ const Buffer = global.Buffer; -module.exports = { - description: - 'supports emitting assets as Uint8Arrays when Buffer is not available with deduplication', +module.exports = defineTest({ + description: 'supports emitting assets as Uint8Arrays when Buffer is not available', before() { delete global.Buffer; }, @@ -10,20 +9,23 @@ module.exports = { global.Buffer = Buffer; }, options: { - plugins: { - resolveId(id) { - if (id.startsWith('asset')) { - return id; - } - }, - load(id) { - if (id.startsWith('asset')) { - return `export default import.meta.ROLLUP_FILE_URL_${this.emitFile({ - type: 'asset', - source: Uint8Array.from(Array.from(id.slice(0, -1)).map(char => char.charCodeAt(0))) - })};`; + plugins: [ + { + name: 'test', + resolveId(id) { + if (id.startsWith('asset')) { + return id; + } + }, + load(id) { + if (id.startsWith('asset')) { + return `export default import.meta.ROLLUP_FILE_URL_${this.emitFile({ + type: 'asset', + source: Uint8Array.from([...id].map(char => char.charCodeAt(0))) + })};`; + } } } - } + ] } -}; +}); diff --git a/test/form/samples/emit-uint8array-no-buffer/_expected/amd.js b/test/form/samples/emit-uint8array-no-buffer/_expected/amd.js index bb05752946f..db474e03d9c 100644 --- a/test/form/samples/emit-uint8array-no-buffer/_expected/amd.js +++ b/test/form/samples/emit-uint8array-no-buffer/_expected/amd.js @@ -1,15 +1,11 @@ -define(['require'], function (require) { 'use strict'; +define(['require'], (function (require) { 'use strict'; - var asset1a = new URL(require.toUrl('./assets/asset-dc5cb674'), document.baseURI).href; + var asset1 = new URL(require.toUrl('./assets/asset-C1v24hPj'), document.baseURI).href; - var asset1b = new URL(require.toUrl('./assets/asset-dc5cb674'), document.baseURI).href; + var asset2 = new URL(require.toUrl('./assets/asset-CtWoGP2A'), document.baseURI).href; - var asset2a = new URL(require.toUrl('./assets/asset-52cbd095'), document.baseURI).href; + var asset99 = new URL(require.toUrl('./assets/asset-8_Inlget'), document.baseURI).href; - var asset2b = new URL(require.toUrl('./assets/asset-52cbd095'), document.baseURI).href; + console.log(asset1, asset2, asset99); - var asset99a = new URL(require.toUrl('./assets/asset-c568a840'), document.baseURI).href; - - console.log(asset1a, asset1b, asset2a, asset2b, asset99a); - -}); +})); diff --git a/test/form/samples/emit-uint8array-no-buffer/_expected/assets/asset-c568a840 b/test/form/samples/emit-uint8array-no-buffer/_expected/assets/asset-8_Inlget similarity index 100% rename from test/form/samples/emit-uint8array-no-buffer/_expected/assets/asset-c568a840 rename to test/form/samples/emit-uint8array-no-buffer/_expected/assets/asset-8_Inlget diff --git a/test/form/samples/emit-uint8array-no-buffer/_expected/assets/asset-dc5cb674 b/test/form/samples/emit-uint8array-no-buffer/_expected/assets/asset-C1v24hPj similarity index 100% rename from test/form/samples/emit-uint8array-no-buffer/_expected/assets/asset-dc5cb674 rename to test/form/samples/emit-uint8array-no-buffer/_expected/assets/asset-C1v24hPj diff --git a/test/form/samples/emit-uint8array-no-buffer/_expected/assets/asset-52cbd095 b/test/form/samples/emit-uint8array-no-buffer/_expected/assets/asset-CtWoGP2A similarity index 100% rename from test/form/samples/emit-uint8array-no-buffer/_expected/assets/asset-52cbd095 rename to test/form/samples/emit-uint8array-no-buffer/_expected/assets/asset-CtWoGP2A diff --git a/test/form/samples/emit-uint8array-no-buffer/_expected/cjs.js b/test/form/samples/emit-uint8array-no-buffer/_expected/cjs.js index 52e66b16df3..34b0f4e18c8 100644 --- a/test/form/samples/emit-uint8array-no-buffer/_expected/cjs.js +++ b/test/form/samples/emit-uint8array-no-buffer/_expected/cjs.js @@ -1,13 +1,9 @@ 'use strict'; -var asset1a = (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __dirname + '/assets/asset-dc5cb674').href : new URL('assets/asset-dc5cb674', document.currentScript && document.currentScript.src || document.baseURI).href); +var asset1 = (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__dirname + '/assets/asset-C1v24hPj').href : new URL('assets/asset-C1v24hPj', document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT' && document.currentScript.src || document.baseURI).href); -var asset1b = (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __dirname + '/assets/asset-dc5cb674').href : new URL('assets/asset-dc5cb674', document.currentScript && document.currentScript.src || document.baseURI).href); +var asset2 = (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__dirname + '/assets/asset-CtWoGP2A').href : new URL('assets/asset-CtWoGP2A', document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT' && document.currentScript.src || document.baseURI).href); -var asset2a = (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __dirname + '/assets/asset-52cbd095').href : new URL('assets/asset-52cbd095', document.currentScript && document.currentScript.src || document.baseURI).href); +var asset99 = (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__dirname + '/assets/asset-8_Inlget').href : new URL('assets/asset-8_Inlget', document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT' && document.currentScript.src || document.baseURI).href); -var asset2b = (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __dirname + '/assets/asset-52cbd095').href : new URL('assets/asset-52cbd095', document.currentScript && document.currentScript.src || document.baseURI).href); - -var asset99a = (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __dirname + '/assets/asset-c568a840').href : new URL('assets/asset-c568a840', document.currentScript && document.currentScript.src || document.baseURI).href); - -console.log(asset1a, asset1b, asset2a, asset2b, asset99a); +console.log(asset1, asset2, asset99); diff --git a/test/form/samples/emit-uint8array-no-buffer/_expected/es.js b/test/form/samples/emit-uint8array-no-buffer/_expected/es.js index 8853325ff06..14fc6472454 100644 --- a/test/form/samples/emit-uint8array-no-buffer/_expected/es.js +++ b/test/form/samples/emit-uint8array-no-buffer/_expected/es.js @@ -1,11 +1,7 @@ -var asset1a = new URL('assets/asset-dc5cb674', import.meta.url).href; +var asset1 = new URL('assets/asset-C1v24hPj', import.meta.url).href; -var asset1b = new URL('assets/asset-dc5cb674', import.meta.url).href; +var asset2 = new URL('assets/asset-CtWoGP2A', import.meta.url).href; -var asset2a = new URL('assets/asset-52cbd095', import.meta.url).href; +var asset99 = new URL('assets/asset-8_Inlget', import.meta.url).href; -var asset2b = new URL('assets/asset-52cbd095', import.meta.url).href; - -var asset99a = new URL('assets/asset-c568a840', import.meta.url).href; - -console.log(asset1a, asset1b, asset2a, asset2b, asset99a); +console.log(asset1, asset2, asset99); diff --git a/test/form/samples/emit-uint8array-no-buffer/_expected/iife.js b/test/form/samples/emit-uint8array-no-buffer/_expected/iife.js index 42e09ca153a..34744b4be32 100644 --- a/test/form/samples/emit-uint8array-no-buffer/_expected/iife.js +++ b/test/form/samples/emit-uint8array-no-buffer/_expected/iife.js @@ -1,16 +1,12 @@ (function () { 'use strict'; - var asset1a = new URL('assets/asset-dc5cb674', document.currentScript && document.currentScript.src || document.baseURI).href; + var asset1 = new URL('assets/asset-C1v24hPj', document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT' && document.currentScript.src || document.baseURI).href; - var asset1b = new URL('assets/asset-dc5cb674', document.currentScript && document.currentScript.src || document.baseURI).href; + var asset2 = new URL('assets/asset-CtWoGP2A', document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT' && document.currentScript.src || document.baseURI).href; - var asset2a = new URL('assets/asset-52cbd095', document.currentScript && document.currentScript.src || document.baseURI).href; + var asset99 = new URL('assets/asset-8_Inlget', document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT' && document.currentScript.src || document.baseURI).href; - var asset2b = new URL('assets/asset-52cbd095', document.currentScript && document.currentScript.src || document.baseURI).href; + console.log(asset1, asset2, asset99); - var asset99a = new URL('assets/asset-c568a840', document.currentScript && document.currentScript.src || document.baseURI).href; - - console.log(asset1a, asset1b, asset2a, asset2b, asset99a); - -}()); +})(); diff --git a/test/form/samples/emit-uint8array-no-buffer/_expected/system.js b/test/form/samples/emit-uint8array-no-buffer/_expected/system.js index a44ddb97598..c8636a69a0e 100644 --- a/test/form/samples/emit-uint8array-no-buffer/_expected/system.js +++ b/test/form/samples/emit-uint8array-no-buffer/_expected/system.js @@ -1,20 +1,16 @@ -System.register([], function (exports, module) { +System.register([], (function (exports, module) { 'use strict'; return { - execute: function () { + execute: (function () { - var asset1a = new URL('assets/asset-dc5cb674', module.meta.url).href; + var asset1 = new URL('assets/asset-C1v24hPj', module.meta.url).href; - var asset1b = new URL('assets/asset-dc5cb674', module.meta.url).href; + var asset2 = new URL('assets/asset-CtWoGP2A', module.meta.url).href; - var asset2a = new URL('assets/asset-52cbd095', module.meta.url).href; + var asset99 = new URL('assets/asset-8_Inlget', module.meta.url).href; - var asset2b = new URL('assets/asset-52cbd095', module.meta.url).href; + console.log(asset1, asset2, asset99); - var asset99a = new URL('assets/asset-c568a840', module.meta.url).href; - - console.log(asset1a, asset1b, asset2a, asset2b, asset99a); - - } + }) }; -}); +})); diff --git a/test/form/samples/emit-uint8array-no-buffer/_expected/umd.js b/test/form/samples/emit-uint8array-no-buffer/_expected/umd.js index 1e07d70a4da..400d4144218 100644 --- a/test/form/samples/emit-uint8array-no-buffer/_expected/umd.js +++ b/test/form/samples/emit-uint8array-no-buffer/_expected/umd.js @@ -1,18 +1,14 @@ (function (factory) { typeof define === 'function' && define.amd ? define(factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; - var asset1a = (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __dirname + '/assets/asset-dc5cb674').href : new URL('assets/asset-dc5cb674', document.currentScript && document.currentScript.src || document.baseURI).href); + var asset1 = (typeof document === 'undefined' && typeof location === 'undefined' ? require('u' + 'rl').pathToFileURL(__dirname + '/assets/asset-C1v24hPj').href : new URL('assets/asset-C1v24hPj', typeof document === 'undefined' ? location.href : document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT' && document.currentScript.src || document.baseURI).href); - var asset1b = (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __dirname + '/assets/asset-dc5cb674').href : new URL('assets/asset-dc5cb674', document.currentScript && document.currentScript.src || document.baseURI).href); + var asset2 = (typeof document === 'undefined' && typeof location === 'undefined' ? require('u' + 'rl').pathToFileURL(__dirname + '/assets/asset-CtWoGP2A').href : new URL('assets/asset-CtWoGP2A', typeof document === 'undefined' ? location.href : document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT' && document.currentScript.src || document.baseURI).href); - var asset2a = (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __dirname + '/assets/asset-52cbd095').href : new URL('assets/asset-52cbd095', document.currentScript && document.currentScript.src || document.baseURI).href); + var asset99 = (typeof document === 'undefined' && typeof location === 'undefined' ? require('u' + 'rl').pathToFileURL(__dirname + '/assets/asset-8_Inlget').href : new URL('assets/asset-8_Inlget', typeof document === 'undefined' ? location.href : document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT' && document.currentScript.src || document.baseURI).href); - var asset2b = (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __dirname + '/assets/asset-52cbd095').href : new URL('assets/asset-52cbd095', document.currentScript && document.currentScript.src || document.baseURI).href); + console.log(asset1, asset2, asset99); - var asset99a = (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __dirname + '/assets/asset-c568a840').href : new URL('assets/asset-c568a840', document.currentScript && document.currentScript.src || document.baseURI).href); - - console.log(asset1a, asset1b, asset2a, asset2b, asset99a); - -}))); +})); diff --git a/test/form/samples/emit-uint8array-no-buffer/main.js b/test/form/samples/emit-uint8array-no-buffer/main.js index ce1ffc35765..443b7587476 100644 --- a/test/form/samples/emit-uint8array-no-buffer/main.js +++ b/test/form/samples/emit-uint8array-no-buffer/main.js @@ -1,7 +1,5 @@ -import asset1a from 'asset1a'; -import asset1b from 'asset1b'; -import asset2a from 'asset2a'; -import asset2b from 'asset2b'; -import asset99a from 'asset99a'; +import asset1 from 'asset1'; +import asset2 from 'asset2'; +import asset99 from 'asset99'; -console.log(asset1a, asset1b, asset2a, asset2b, asset99a); +console.log(asset1, asset2, asset99); diff --git a/test/form/samples/empty-block-comment/_config.js b/test/form/samples/empty-block-comment/_config.js new file mode 100644 index 00000000000..684e7b6a458 --- /dev/null +++ b/test/form/samples/empty-block-comment/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'renders empty block comments after tree-shaken statements (#5230)' +}); diff --git a/test/form/samples/empty-block-comment/_expected.js b/test/form/samples/empty-block-comment/_expected.js new file mode 100644 index 00000000000..8c45b40c122 --- /dev/null +++ b/test/form/samples/empty-block-comment/_expected.js @@ -0,0 +1,4 @@ +function instance() { +} + +export { instance }; diff --git a/test/form/samples/empty-block-comment/main.js b/test/form/samples/empty-block-comment/main.js new file mode 100644 index 00000000000..12eb2bb324f --- /dev/null +++ b/test/form/samples/empty-block-comment/main.js @@ -0,0 +1,3 @@ +export function instance() { + const b = 2; /**/ +} diff --git a/test/form/samples/empty-block-statement/_config.js b/test/form/samples/empty-block-statement/_config.js index 283b0b6931b..3915a619d31 100644 --- a/test/form/samples/empty-block-statement/_config.js +++ b/test/form/samples/empty-block-statement/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'removes an empty block statement' -}; +}); diff --git a/test/form/samples/empty-block-statement/_expected/amd.js b/test/form/samples/empty-block-statement/_expected/amd.js index 6036f2851d3..7dd42b0172c 100644 --- a/test/form/samples/empty-block-statement/_expected/amd.js +++ b/test/form/samples/empty-block-statement/_expected/amd.js @@ -1,6 +1,6 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; console.log( 1 ); console.log( 2 ); -}); +})); diff --git a/test/form/samples/empty-block-statement/_expected/iife.js b/test/form/samples/empty-block-statement/_expected/iife.js index 08a84a95e53..2aa3986d94b 100644 --- a/test/form/samples/empty-block-statement/_expected/iife.js +++ b/test/form/samples/empty-block-statement/_expected/iife.js @@ -4,4 +4,4 @@ console.log( 1 ); console.log( 2 ); -}()); +})(); diff --git a/test/form/samples/empty-block-statement/_expected/system.js b/test/form/samples/empty-block-statement/_expected/system.js index d8a0e92b62a..8d78842c3e3 100644 --- a/test/form/samples/empty-block-statement/_expected/system.js +++ b/test/form/samples/empty-block-statement/_expected/system.js @@ -1,11 +1,11 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { console.log( 1 ); console.log( 2 ); - } + }) }; -}); +})); diff --git a/test/form/samples/empty-block-statement/_expected/umd.js b/test/form/samples/empty-block-statement/_expected/umd.js index 3ec33621e87..a5ab90a2b29 100644 --- a/test/form/samples/empty-block-statement/_expected/umd.js +++ b/test/form/samples/empty-block-statement/_expected/umd.js @@ -1,9 +1,9 @@ (function (factory) { typeof define === 'function' && define.amd ? define(factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; console.log( 1 ); console.log( 2 ); -}))); +})); diff --git a/test/form/samples/empty-do-while-statement/_config.js b/test/form/samples/empty-do-while-statement/_config.js index 00672ede4ed..6fd27ba3009 100644 --- a/test/form/samples/empty-do-while-statement/_config.js +++ b/test/form/samples/empty-do-while-statement/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'removes an empty do-while statement' -}; +}); diff --git a/test/form/samples/empty-do-while-statement/_expected/amd.js b/test/form/samples/empty-do-while-statement/_expected/amd.js index 6036f2851d3..7dd42b0172c 100644 --- a/test/form/samples/empty-do-while-statement/_expected/amd.js +++ b/test/form/samples/empty-do-while-statement/_expected/amd.js @@ -1,6 +1,6 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; console.log( 1 ); console.log( 2 ); -}); +})); diff --git a/test/form/samples/empty-do-while-statement/_expected/iife.js b/test/form/samples/empty-do-while-statement/_expected/iife.js index 08a84a95e53..2aa3986d94b 100644 --- a/test/form/samples/empty-do-while-statement/_expected/iife.js +++ b/test/form/samples/empty-do-while-statement/_expected/iife.js @@ -4,4 +4,4 @@ console.log( 1 ); console.log( 2 ); -}()); +})(); diff --git a/test/form/samples/empty-do-while-statement/_expected/system.js b/test/form/samples/empty-do-while-statement/_expected/system.js index d8a0e92b62a..8d78842c3e3 100644 --- a/test/form/samples/empty-do-while-statement/_expected/system.js +++ b/test/form/samples/empty-do-while-statement/_expected/system.js @@ -1,11 +1,11 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { console.log( 1 ); console.log( 2 ); - } + }) }; -}); +})); diff --git a/test/form/samples/empty-do-while-statement/_expected/umd.js b/test/form/samples/empty-do-while-statement/_expected/umd.js index 3ec33621e87..a5ab90a2b29 100644 --- a/test/form/samples/empty-do-while-statement/_expected/umd.js +++ b/test/form/samples/empty-do-while-statement/_expected/umd.js @@ -1,9 +1,9 @@ (function (factory) { typeof define === 'function' && define.amd ? define(factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; console.log( 1 ); console.log( 2 ); -}))); +})); diff --git a/test/form/samples/empty-export/_config.js b/test/form/samples/empty-export/_config.js new file mode 100644 index 00000000000..ea67178e391 --- /dev/null +++ b/test/form/samples/empty-export/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'handles empty exports' +}); diff --git a/test/form/samples/empty-export/_expected/amd.js b/test/form/samples/empty-export/_expected/amd.js new file mode 100644 index 00000000000..49540b44d78 --- /dev/null +++ b/test/form/samples/empty-export/_expected/amd.js @@ -0,0 +1,5 @@ +define((function () { 'use strict'; + + console.log('main'); + +})); diff --git a/test/form/samples/empty-export/_expected/cjs.js b/test/form/samples/empty-export/_expected/cjs.js new file mode 100644 index 00000000000..d0ed06d8c90 --- /dev/null +++ b/test/form/samples/empty-export/_expected/cjs.js @@ -0,0 +1,3 @@ +'use strict'; + +console.log('main'); diff --git a/test/form/samples/empty-export/_expected/es.js b/test/form/samples/empty-export/_expected/es.js new file mode 100644 index 00000000000..c0b933d7b56 --- /dev/null +++ b/test/form/samples/empty-export/_expected/es.js @@ -0,0 +1 @@ +console.log('main'); diff --git a/test/form/samples/empty-export/_expected/iife.js b/test/form/samples/empty-export/_expected/iife.js new file mode 100644 index 00000000000..455edee6aa6 --- /dev/null +++ b/test/form/samples/empty-export/_expected/iife.js @@ -0,0 +1,6 @@ +(function () { + 'use strict'; + + console.log('main'); + +})(); diff --git a/test/form/samples/empty-export/_expected/system.js b/test/form/samples/empty-export/_expected/system.js new file mode 100644 index 00000000000..35e2693371a --- /dev/null +++ b/test/form/samples/empty-export/_expected/system.js @@ -0,0 +1,10 @@ +System.register([], (function () { + 'use strict'; + return { + execute: (function () { + + console.log('main'); + + }) + }; +})); diff --git a/test/form/samples/empty-export/_expected/umd.js b/test/form/samples/empty-export/_expected/umd.js new file mode 100644 index 00000000000..c8ba7daa897 --- /dev/null +++ b/test/form/samples/empty-export/_expected/umd.js @@ -0,0 +1,8 @@ +(function (factory) { + typeof define === 'function' && define.amd ? define(factory) : + factory(); +})((function () { 'use strict'; + + console.log('main'); + +})); diff --git a/test/form/samples/empty-export/main.js b/test/form/samples/empty-export/main.js new file mode 100644 index 00000000000..40f1e1d7bd3 --- /dev/null +++ b/test/form/samples/empty-export/main.js @@ -0,0 +1,2 @@ +console.log('main'); +export {}; diff --git a/test/form/samples/empty-for-in-statement/_config.js b/test/form/samples/empty-for-in-statement/_config.js index b95837c9a9f..93cd18efe18 100644 --- a/test/form/samples/empty-for-in-statement/_config.js +++ b/test/form/samples/empty-for-in-statement/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'removes an empty for-in statement' -}; +}); diff --git a/test/form/samples/empty-for-statement/_config.js b/test/form/samples/empty-for-statement/_config.js index f448ddf8e8b..abbbce82750 100644 --- a/test/form/samples/empty-for-statement/_config.js +++ b/test/form/samples/empty-for-statement/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'removes an empty for statement' -}; +}); diff --git a/test/form/samples/empty-for-statement/_expected/amd.js b/test/form/samples/empty-for-statement/_expected/amd.js index 6036f2851d3..7dd42b0172c 100644 --- a/test/form/samples/empty-for-statement/_expected/amd.js +++ b/test/form/samples/empty-for-statement/_expected/amd.js @@ -1,6 +1,6 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; console.log( 1 ); console.log( 2 ); -}); +})); diff --git a/test/form/samples/empty-for-statement/_expected/iife.js b/test/form/samples/empty-for-statement/_expected/iife.js index 08a84a95e53..2aa3986d94b 100644 --- a/test/form/samples/empty-for-statement/_expected/iife.js +++ b/test/form/samples/empty-for-statement/_expected/iife.js @@ -4,4 +4,4 @@ console.log( 1 ); console.log( 2 ); -}()); +})(); diff --git a/test/form/samples/empty-for-statement/_expected/system.js b/test/form/samples/empty-for-statement/_expected/system.js index d8a0e92b62a..8d78842c3e3 100644 --- a/test/form/samples/empty-for-statement/_expected/system.js +++ b/test/form/samples/empty-for-statement/_expected/system.js @@ -1,11 +1,11 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { console.log( 1 ); console.log( 2 ); - } + }) }; -}); +})); diff --git a/test/form/samples/empty-for-statement/_expected/umd.js b/test/form/samples/empty-for-statement/_expected/umd.js index 3ec33621e87..a5ab90a2b29 100644 --- a/test/form/samples/empty-for-statement/_expected/umd.js +++ b/test/form/samples/empty-for-statement/_expected/umd.js @@ -1,9 +1,9 @@ (function (factory) { typeof define === 'function' && define.amd ? define(factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; console.log( 1 ); console.log( 2 ); -}))); +})); diff --git a/test/form/samples/empty-if-statement/_config.js b/test/form/samples/empty-if-statement/_config.js index abea88980c5..bb36f917a7f 100644 --- a/test/form/samples/empty-if-statement/_config.js +++ b/test/form/samples/empty-if-statement/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'removes an empty if statement' -}; +}); diff --git a/test/form/samples/empty-statament-class-member/_config.js b/test/form/samples/empty-statament-class-member/_config.js new file mode 100644 index 00000000000..31e35cc41d9 --- /dev/null +++ b/test/form/samples/empty-statament-class-member/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'Do not crash if class body has empty statements' +}); diff --git a/test/form/samples/empty-statament-class-member/_expected/amd.js b/test/form/samples/empty-statament-class-member/_expected/amd.js new file mode 100644 index 00000000000..5300be6a48a --- /dev/null +++ b/test/form/samples/empty-statament-class-member/_expected/amd.js @@ -0,0 +1,11 @@ +define((function () { 'use strict'; + + class Foo { + foo() { + console.log('foo'); + }; + } + + console.log(Foo); + +})); diff --git a/test/form/samples/empty-statament-class-member/_expected/cjs.js b/test/form/samples/empty-statament-class-member/_expected/cjs.js new file mode 100644 index 00000000000..5c7b09b47ea --- /dev/null +++ b/test/form/samples/empty-statament-class-member/_expected/cjs.js @@ -0,0 +1,9 @@ +'use strict'; + +class Foo { + foo() { + console.log('foo'); + }; +} + +console.log(Foo); diff --git a/test/form/samples/empty-statament-class-member/_expected/es.js b/test/form/samples/empty-statament-class-member/_expected/es.js new file mode 100644 index 00000000000..d6767f3d081 --- /dev/null +++ b/test/form/samples/empty-statament-class-member/_expected/es.js @@ -0,0 +1,7 @@ +class Foo { + foo() { + console.log('foo'); + }; +} + +console.log(Foo); diff --git a/test/form/samples/empty-statament-class-member/_expected/iife.js b/test/form/samples/empty-statament-class-member/_expected/iife.js new file mode 100644 index 00000000000..59053d3a137 --- /dev/null +++ b/test/form/samples/empty-statament-class-member/_expected/iife.js @@ -0,0 +1,12 @@ +(function () { + 'use strict'; + + class Foo { + foo() { + console.log('foo'); + }; + } + + console.log(Foo); + +})(); diff --git a/test/form/samples/empty-statament-class-member/_expected/system.js b/test/form/samples/empty-statament-class-member/_expected/system.js new file mode 100644 index 00000000000..dc2eff5bbcc --- /dev/null +++ b/test/form/samples/empty-statament-class-member/_expected/system.js @@ -0,0 +1,16 @@ +System.register([], (function () { + 'use strict'; + return { + execute: (function () { + + class Foo { + foo() { + console.log('foo'); + }; + } + + console.log(Foo); + + }) + }; +})); diff --git a/test/form/samples/empty-statament-class-member/_expected/umd.js b/test/form/samples/empty-statament-class-member/_expected/umd.js new file mode 100644 index 00000000000..dd4f83d3483 --- /dev/null +++ b/test/form/samples/empty-statament-class-member/_expected/umd.js @@ -0,0 +1,14 @@ +(function (factory) { + typeof define === 'function' && define.amd ? define(factory) : + factory(); +})((function () { 'use strict'; + + class Foo { + foo() { + console.log('foo'); + }; + } + + console.log(Foo); + +})); diff --git a/test/form/samples/empty-statament-class-member/main.js b/test/form/samples/empty-statament-class-member/main.js new file mode 100644 index 00000000000..d6767f3d081 --- /dev/null +++ b/test/form/samples/empty-statament-class-member/main.js @@ -0,0 +1,7 @@ +class Foo { + foo() { + console.log('foo'); + }; +} + +console.log(Foo); diff --git a/test/form/samples/empty-statement-consequent/_config.js b/test/form/samples/empty-statement-consequent/_config.js index dc10538fbfb..77b0e7eb8dc 100644 --- a/test/form/samples/empty-statement-consequent/_config.js +++ b/test/form/samples/empty-statement-consequent/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'preserves empty statements used as the consequent of conditionals' -}; +}); diff --git a/test/form/samples/empty-statement-consequent/_expected/amd.js b/test/form/samples/empty-statement-consequent/_expected/amd.js index eeea4a59f27..844607bb6fc 100644 --- a/test/form/samples/empty-statement-consequent/_expected/amd.js +++ b/test/form/samples/empty-statement-consequent/_expected/amd.js @@ -1,6 +1,6 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; if ( a === 0 ); else a++; -}); +})); diff --git a/test/form/samples/empty-statement-consequent/_expected/iife.js b/test/form/samples/empty-statement-consequent/_expected/iife.js index 1e4d2d74b16..41fdcb2de19 100644 --- a/test/form/samples/empty-statement-consequent/_expected/iife.js +++ b/test/form/samples/empty-statement-consequent/_expected/iife.js @@ -4,4 +4,4 @@ if ( a === 0 ); else a++; -}()); +})(); diff --git a/test/form/samples/empty-statement-consequent/_expected/system.js b/test/form/samples/empty-statement-consequent/_expected/system.js index d3ab2c83eb2..a78d266e019 100644 --- a/test/form/samples/empty-statement-consequent/_expected/system.js +++ b/test/form/samples/empty-statement-consequent/_expected/system.js @@ -1,11 +1,11 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { if ( a === 0 ); else a++; - } + }) }; -}); +})); diff --git a/test/form/samples/empty-statement-consequent/_expected/umd.js b/test/form/samples/empty-statement-consequent/_expected/umd.js index 1da163ba3fa..6454a87ab68 100644 --- a/test/form/samples/empty-statement-consequent/_expected/umd.js +++ b/test/form/samples/empty-statement-consequent/_expected/umd.js @@ -1,9 +1,9 @@ (function (factory) { typeof define === 'function' && define.amd ? define(factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; if ( a === 0 ); else a++; -}))); +})); diff --git a/test/form/samples/empty-statement/_config.js b/test/form/samples/empty-statement/_config.js index 76e4fa332b4..a69a0d88686 100644 --- a/test/form/samples/empty-statement/_config.js +++ b/test/form/samples/empty-statement/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'removes an empty statement' -}; +}); diff --git a/test/form/samples/empty-statement/_expected/amd.js b/test/form/samples/empty-statement/_expected/amd.js index 6255bc57cbf..e2d75c6a56f 100644 --- a/test/form/samples/empty-statement/_expected/amd.js +++ b/test/form/samples/empty-statement/_expected/amd.js @@ -1,5 +1,5 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; console.log( 1 );console.log( 2 ); -}); +})); diff --git a/test/form/samples/empty-statement/_expected/iife.js b/test/form/samples/empty-statement/_expected/iife.js index 60508d61edf..74d61f5b90c 100644 --- a/test/form/samples/empty-statement/_expected/iife.js +++ b/test/form/samples/empty-statement/_expected/iife.js @@ -3,4 +3,4 @@ console.log( 1 );console.log( 2 ); -}()); +})(); diff --git a/test/form/samples/empty-statement/_expected/system.js b/test/form/samples/empty-statement/_expected/system.js index 811a8f6327e..0acd02cc93b 100644 --- a/test/form/samples/empty-statement/_expected/system.js +++ b/test/form/samples/empty-statement/_expected/system.js @@ -1,10 +1,10 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { console.log( 1 );console.log( 2 ); - } + }) }; -}); +})); diff --git a/test/form/samples/empty-statement/_expected/umd.js b/test/form/samples/empty-statement/_expected/umd.js index 6eb30720111..921fb951f46 100644 --- a/test/form/samples/empty-statement/_expected/umd.js +++ b/test/form/samples/empty-statement/_expected/umd.js @@ -1,8 +1,8 @@ (function (factory) { typeof define === 'function' && define.amd ? define(factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; console.log( 1 );console.log( 2 ); -}))); +})); diff --git a/test/form/samples/empty-switch-statement/_config.js b/test/form/samples/empty-switch-statement/_config.js index 29c051733d4..a77fbe2b87a 100644 --- a/test/form/samples/empty-switch-statement/_config.js +++ b/test/form/samples/empty-switch-statement/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'removes an empty switch statement' -}; +}); diff --git a/test/form/samples/empty-try-catch-statement/_config.js b/test/form/samples/empty-try-catch-statement/_config.js index 70bf6529913..577d6d3cb00 100644 --- a/test/form/samples/empty-try-catch-statement/_config.js +++ b/test/form/samples/empty-try-catch-statement/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'removes an empty try-catch-finally statement' -}; +}); diff --git a/test/form/samples/empty-try-catch-statement/_expected/amd.js b/test/form/samples/empty-try-catch-statement/_expected/amd.js index 6036f2851d3..7dd42b0172c 100644 --- a/test/form/samples/empty-try-catch-statement/_expected/amd.js +++ b/test/form/samples/empty-try-catch-statement/_expected/amd.js @@ -1,6 +1,6 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; console.log( 1 ); console.log( 2 ); -}); +})); diff --git a/test/form/samples/empty-try-catch-statement/_expected/iife.js b/test/form/samples/empty-try-catch-statement/_expected/iife.js index 08a84a95e53..2aa3986d94b 100644 --- a/test/form/samples/empty-try-catch-statement/_expected/iife.js +++ b/test/form/samples/empty-try-catch-statement/_expected/iife.js @@ -4,4 +4,4 @@ console.log( 1 ); console.log( 2 ); -}()); +})(); diff --git a/test/form/samples/empty-try-catch-statement/_expected/system.js b/test/form/samples/empty-try-catch-statement/_expected/system.js index d8a0e92b62a..8d78842c3e3 100644 --- a/test/form/samples/empty-try-catch-statement/_expected/system.js +++ b/test/form/samples/empty-try-catch-statement/_expected/system.js @@ -1,11 +1,11 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { console.log( 1 ); console.log( 2 ); - } + }) }; -}); +})); diff --git a/test/form/samples/empty-try-catch-statement/_expected/umd.js b/test/form/samples/empty-try-catch-statement/_expected/umd.js index 3ec33621e87..a5ab90a2b29 100644 --- a/test/form/samples/empty-try-catch-statement/_expected/umd.js +++ b/test/form/samples/empty-try-catch-statement/_expected/umd.js @@ -1,9 +1,9 @@ (function (factory) { typeof define === 'function' && define.amd ? define(factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; console.log( 1 ); console.log( 2 ); -}))); +})); diff --git a/test/form/samples/empty-while-statement/_config.js b/test/form/samples/empty-while-statement/_config.js index 8db2e7f8646..52b112ee82f 100644 --- a/test/form/samples/empty-while-statement/_config.js +++ b/test/form/samples/empty-while-statement/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'removes an empty while statement' -}; +}); diff --git a/test/form/samples/empty-while-statement/_expected/amd.js b/test/form/samples/empty-while-statement/_expected/amd.js index 6036f2851d3..7dd42b0172c 100644 --- a/test/form/samples/empty-while-statement/_expected/amd.js +++ b/test/form/samples/empty-while-statement/_expected/amd.js @@ -1,6 +1,6 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; console.log( 1 ); console.log( 2 ); -}); +})); diff --git a/test/form/samples/empty-while-statement/_expected/iife.js b/test/form/samples/empty-while-statement/_expected/iife.js index 08a84a95e53..2aa3986d94b 100644 --- a/test/form/samples/empty-while-statement/_expected/iife.js +++ b/test/form/samples/empty-while-statement/_expected/iife.js @@ -4,4 +4,4 @@ console.log( 1 ); console.log( 2 ); -}()); +})(); diff --git a/test/form/samples/empty-while-statement/_expected/system.js b/test/form/samples/empty-while-statement/_expected/system.js index d8a0e92b62a..8d78842c3e3 100644 --- a/test/form/samples/empty-while-statement/_expected/system.js +++ b/test/form/samples/empty-while-statement/_expected/system.js @@ -1,11 +1,11 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { console.log( 1 ); console.log( 2 ); - } + }) }; -}); +})); diff --git a/test/form/samples/empty-while-statement/_expected/umd.js b/test/form/samples/empty-while-statement/_expected/umd.js index 3ec33621e87..a5ab90a2b29 100644 --- a/test/form/samples/empty-while-statement/_expected/umd.js +++ b/test/form/samples/empty-while-statement/_expected/umd.js @@ -1,9 +1,9 @@ (function (factory) { typeof define === 'function' && define.amd ? define(factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; console.log( 1 ); console.log( 2 ); -}))); +})); diff --git a/test/form/samples/enforce-addon-order/_config.js b/test/form/samples/enforce-addon-order/_config.js new file mode 100644 index 00000000000..878479c6e9b --- /dev/null +++ b/test/form/samples/enforce-addon-order/_config.js @@ -0,0 +1,32 @@ +const hooks = ['banner', 'footer', 'intro', 'outro']; + +const plugins = []; +addPlugin(null); +addPlugin('pre'); +addPlugin('post'); +addPlugin('post'); +addPlugin('pre'); +addPlugin(); +function addPlugin(order) { + const name = `${order}-${(plugins.length >> 1) + 1}`; + const plugin = { name }; + const stringPlugin = { name: `string-${name}` }; + for (const hook of hooks) { + plugin[hook] = { + order, + handler: () => `// ${hook}-${name}` + }; + stringPlugin[hook] = { + order, + handler: `// ${hook}-string-${name}` + }; + } + plugins.push(plugin, stringPlugin); +} + +module.exports = defineTest({ + description: 'allows to enforce addon order', + options: { + plugins + } +}); diff --git a/test/form/samples/enforce-addon-order/_expected.js b/test/form/samples/enforce-addon-order/_expected.js new file mode 100644 index 00000000000..ac10e4bb458 --- /dev/null +++ b/test/form/samples/enforce-addon-order/_expected.js @@ -0,0 +1,77 @@ + +// banner-pre-2 +// banner-string-pre-2 +// banner-pre-5 +// banner-string-pre-5 +// banner-null-1 +// banner-string-null-1 +// banner-undefined-6 +// banner-string-undefined-6 +// banner-post-3 +// banner-string-post-3 +// banner-post-4 +// banner-string-post-4 +// intro-pre-2 + +// intro-string-pre-2 + +// intro-pre-5 + +// intro-string-pre-5 + +// intro-null-1 + +// intro-string-null-1 + +// intro-undefined-6 + +// intro-string-undefined-6 + +// intro-post-3 + +// intro-string-post-3 + +// intro-post-4 + +// intro-string-post-4 + +console.log('main'); + + + +// outro-pre-2 + +// outro-string-pre-2 + +// outro-pre-5 + +// outro-string-pre-5 + +// outro-null-1 + +// outro-string-null-1 + +// outro-undefined-6 + +// outro-string-undefined-6 + +// outro-post-3 + +// outro-string-post-3 + +// outro-post-4 + +// outro-string-post-4 + +// footer-pre-2 +// footer-string-pre-2 +// footer-pre-5 +// footer-string-pre-5 +// footer-null-1 +// footer-string-null-1 +// footer-undefined-6 +// footer-string-undefined-6 +// footer-post-3 +// footer-string-post-3 +// footer-post-4 +// footer-string-post-4 diff --git a/test/form/samples/enforce-addon-order/main.js b/test/form/samples/enforce-addon-order/main.js new file mode 100644 index 00000000000..c0b933d7b56 --- /dev/null +++ b/test/form/samples/enforce-addon-order/main.js @@ -0,0 +1 @@ +console.log('main'); diff --git a/test/form/samples/entry-with-unused-synthetic-exports/_config.js b/test/form/samples/entry-with-unused-synthetic-exports/_config.js index 00f9a60009b..e79ba880fc1 100644 --- a/test/form/samples/entry-with-unused-synthetic-exports/_config.js +++ b/test/form/samples/entry-with-unused-synthetic-exports/_config.js @@ -1,11 +1,13 @@ -module.exports = { +module.exports = defineTest({ description: 'does not include unused synthetic namespace object in entry points', options: { - plugins: { - name: 'test-plugin', - transform(code) { - return { code, syntheticNamedExports: '__moduleExports' }; + plugins: [ + { + name: 'test-plugin', + transform(code) { + return { code, syntheticNamedExports: '__moduleExports' }; + } } - } + ] } -}; +}); diff --git a/test/form/samples/entry-with-unused-synthetic-exports/_expected/amd.js b/test/form/samples/entry-with-unused-synthetic-exports/_expected/amd.js index ab9c5a9f95c..49540b44d78 100644 --- a/test/form/samples/entry-with-unused-synthetic-exports/_expected/amd.js +++ b/test/form/samples/entry-with-unused-synthetic-exports/_expected/amd.js @@ -1,5 +1,5 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; - console.log(lib); + console.log('main'); -}); +})); diff --git a/test/form/samples/entry-with-unused-synthetic-exports/_expected/cjs.js b/test/form/samples/entry-with-unused-synthetic-exports/_expected/cjs.js index 2856d44c78d..d0ed06d8c90 100644 --- a/test/form/samples/entry-with-unused-synthetic-exports/_expected/cjs.js +++ b/test/form/samples/entry-with-unused-synthetic-exports/_expected/cjs.js @@ -1,3 +1,3 @@ 'use strict'; -console.log(lib); +console.log('main'); diff --git a/test/form/samples/entry-with-unused-synthetic-exports/_expected/es.js b/test/form/samples/entry-with-unused-synthetic-exports/_expected/es.js index 9edbef9bc88..c0b933d7b56 100644 --- a/test/form/samples/entry-with-unused-synthetic-exports/_expected/es.js +++ b/test/form/samples/entry-with-unused-synthetic-exports/_expected/es.js @@ -1 +1 @@ -console.log(lib); +console.log('main'); diff --git a/test/form/samples/entry-with-unused-synthetic-exports/_expected/iife.js b/test/form/samples/entry-with-unused-synthetic-exports/_expected/iife.js index d6a387986ba..455edee6aa6 100644 --- a/test/form/samples/entry-with-unused-synthetic-exports/_expected/iife.js +++ b/test/form/samples/entry-with-unused-synthetic-exports/_expected/iife.js @@ -1,6 +1,6 @@ (function () { 'use strict'; - console.log(lib); + console.log('main'); -}()); +})(); diff --git a/test/form/samples/entry-with-unused-synthetic-exports/_expected/system.js b/test/form/samples/entry-with-unused-synthetic-exports/_expected/system.js index d9efd72dea2..35e2693371a 100644 --- a/test/form/samples/entry-with-unused-synthetic-exports/_expected/system.js +++ b/test/form/samples/entry-with-unused-synthetic-exports/_expected/system.js @@ -1,10 +1,10 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { - console.log(lib); + console.log('main'); - } + }) }; -}); +})); diff --git a/test/form/samples/entry-with-unused-synthetic-exports/_expected/umd.js b/test/form/samples/entry-with-unused-synthetic-exports/_expected/umd.js index 470991219df..c8ba7daa897 100644 --- a/test/form/samples/entry-with-unused-synthetic-exports/_expected/umd.js +++ b/test/form/samples/entry-with-unused-synthetic-exports/_expected/umd.js @@ -1,8 +1,8 @@ (function (factory) { typeof define === 'function' && define.amd ? define(factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; - console.log(lib); + console.log('main'); -}))); +})); diff --git a/test/form/samples/entry-with-unused-synthetic-exports/main.js b/test/form/samples/entry-with-unused-synthetic-exports/main.js index d30979994b4..68e937b93b9 100644 --- a/test/form/samples/entry-with-unused-synthetic-exports/main.js +++ b/test/form/samples/entry-with-unused-synthetic-exports/main.js @@ -1,2 +1,2 @@ -console.log(lib); +console.log('main'); export const __moduleExports = { not: 'included' }; diff --git a/test/form/samples/erroneous-nested-member-expression/_config.js b/test/form/samples/erroneous-nested-member-expression/_config.js index 684fe7cc0b8..c9540eb7aae 100644 --- a/test/form/samples/erroneous-nested-member-expression/_config.js +++ b/test/form/samples/erroneous-nested-member-expression/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'erroneous nested member expression does not mess up naming' -}; +}); diff --git a/test/form/samples/erroneous-nested-member-expression/_expected/amd.js b/test/form/samples/erroneous-nested-member-expression/_expected/amd.js index 4b402c74930..91eec3163b0 100644 --- a/test/form/samples/erroneous-nested-member-expression/_expected/amd.js +++ b/test/form/samples/erroneous-nested-member-expression/_expected/amd.js @@ -1,4 +1,4 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; function yar() { return { @@ -10,4 +10,4 @@ define(function () { 'use strict'; yar.har(); -}); +})); diff --git a/test/form/samples/erroneous-nested-member-expression/_expected/iife.js b/test/form/samples/erroneous-nested-member-expression/_expected/iife.js index 8a8d65ed589..45c45e17f2f 100644 --- a/test/form/samples/erroneous-nested-member-expression/_expected/iife.js +++ b/test/form/samples/erroneous-nested-member-expression/_expected/iife.js @@ -11,4 +11,4 @@ yar.har(); -}()); +})(); diff --git a/test/form/samples/erroneous-nested-member-expression/_expected/system.js b/test/form/samples/erroneous-nested-member-expression/_expected/system.js index 5e5b4921d1b..596f93f76ce 100644 --- a/test/form/samples/erroneous-nested-member-expression/_expected/system.js +++ b/test/form/samples/erroneous-nested-member-expression/_expected/system.js @@ -1,7 +1,7 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { function yar() { return { @@ -13,6 +13,6 @@ System.register([], function () { yar.har(); - } + }) }; -}); +})); diff --git a/test/form/samples/erroneous-nested-member-expression/_expected/umd.js b/test/form/samples/erroneous-nested-member-expression/_expected/umd.js index 1d8758be014..accb4f237e3 100644 --- a/test/form/samples/erroneous-nested-member-expression/_expected/umd.js +++ b/test/form/samples/erroneous-nested-member-expression/_expected/umd.js @@ -1,7 +1,7 @@ (function (factory) { typeof define === 'function' && define.amd ? define(factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; function yar() { return { @@ -13,4 +13,4 @@ yar.har(); -}))); +})); diff --git a/test/form/samples/exclude-unnecessary-modifications/_config.js b/test/form/samples/exclude-unnecessary-modifications/_config.js index 2b3de2b830a..15de81719c5 100644 --- a/test/form/samples/exclude-unnecessary-modifications/_config.js +++ b/test/form/samples/exclude-unnecessary-modifications/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'statements that modify definitions within unused functions are excluded' -}; +}); diff --git a/test/form/samples/exclude-unnecessary-modifications/_expected/amd.js b/test/form/samples/exclude-unnecessary-modifications/_expected/amd.js index 36fce8b38ed..5af134c8d5e 100644 --- a/test/form/samples/exclude-unnecessary-modifications/_expected/amd.js +++ b/test/form/samples/exclude-unnecessary-modifications/_expected/amd.js @@ -1,4 +1,4 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; var foo = {}; @@ -25,4 +25,4 @@ define(function () { 'use strict'; console.log( foo ); -}); +})); diff --git a/test/form/samples/exclude-unnecessary-modifications/_expected/iife.js b/test/form/samples/exclude-unnecessary-modifications/_expected/iife.js index 84e2328cc7b..21109afde42 100644 --- a/test/form/samples/exclude-unnecessary-modifications/_expected/iife.js +++ b/test/form/samples/exclude-unnecessary-modifications/_expected/iife.js @@ -26,4 +26,4 @@ console.log( foo ); -}()); +})(); diff --git a/test/form/samples/exclude-unnecessary-modifications/_expected/system.js b/test/form/samples/exclude-unnecessary-modifications/_expected/system.js index e653701513c..0ddcf03c6dd 100644 --- a/test/form/samples/exclude-unnecessary-modifications/_expected/system.js +++ b/test/form/samples/exclude-unnecessary-modifications/_expected/system.js @@ -1,7 +1,7 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { var foo = {}; @@ -28,6 +28,6 @@ System.register([], function () { console.log( foo ); - } + }) }; -}); +})); diff --git a/test/form/samples/exclude-unnecessary-modifications/_expected/umd.js b/test/form/samples/exclude-unnecessary-modifications/_expected/umd.js index 556555674ab..2187f3f512f 100644 --- a/test/form/samples/exclude-unnecessary-modifications/_expected/umd.js +++ b/test/form/samples/exclude-unnecessary-modifications/_expected/umd.js @@ -1,7 +1,7 @@ (function (factory) { typeof define === 'function' && define.amd ? define(factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; var foo = {}; @@ -28,4 +28,4 @@ console.log( foo ); -}))); +})); diff --git a/test/form/samples/exponentiation-operator/_config.js b/test/form/samples/exponentiation-operator/_config.js index 34bf4b764f9..ebbd034ae75 100644 --- a/test/form/samples/exponentiation-operator/_config.js +++ b/test/form/samples/exponentiation-operator/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'folds exponentiation operator when considering dead code' -}; +}); diff --git a/test/form/samples/exponentiation-operator/_expected/amd.js b/test/form/samples/exponentiation-operator/_expected/amd.js index 7a576448702..4b4c11e57df 100644 --- a/test/form/samples/exponentiation-operator/_expected/amd.js +++ b/test/form/samples/exponentiation-operator/_expected/amd.js @@ -1,7 +1,7 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; { console.log('8 is larger than 7'); } -}); +})); diff --git a/test/form/samples/exponentiation-operator/_expected/iife.js b/test/form/samples/exponentiation-operator/_expected/iife.js index dbc5a02d497..29e081d4739 100644 --- a/test/form/samples/exponentiation-operator/_expected/iife.js +++ b/test/form/samples/exponentiation-operator/_expected/iife.js @@ -5,4 +5,4 @@ console.log('8 is larger than 7'); } -}()); +})(); diff --git a/test/form/samples/exponentiation-operator/_expected/system.js b/test/form/samples/exponentiation-operator/_expected/system.js index eb116fe8abe..43f698c2a18 100644 --- a/test/form/samples/exponentiation-operator/_expected/system.js +++ b/test/form/samples/exponentiation-operator/_expected/system.js @@ -1,12 +1,12 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { { console.log('8 is larger than 7'); } - } + }) }; -}); +})); diff --git a/test/form/samples/exponentiation-operator/_expected/umd.js b/test/form/samples/exponentiation-operator/_expected/umd.js index 05759d7cce6..e1538f67e67 100644 --- a/test/form/samples/exponentiation-operator/_expected/umd.js +++ b/test/form/samples/exponentiation-operator/_expected/umd.js @@ -1,10 +1,10 @@ (function (factory) { typeof define === 'function' && define.amd ? define(factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; { console.log('8 is larger than 7'); } -}))); +})); diff --git a/test/form/samples/export-__proto__-from/_config.js b/test/form/samples/export-__proto__-from/_config.js new file mode 100644 index 00000000000..d9684884ec6 --- /dev/null +++ b/test/form/samples/export-__proto__-from/_config.js @@ -0,0 +1,13 @@ +module.exports = defineTest({ + description: 'export __proto__ from', + options: { + external: ['x'], + output: { + externalLiveBindings: false, + globals: { + x: 'x' + }, + name: 'bundle' + } + } +}); diff --git a/test/form/samples/export-__proto__-from/_expected/amd.js b/test/form/samples/export-__proto__-from/_expected/amd.js new file mode 100644 index 00000000000..9eb8a1a5d63 --- /dev/null +++ b/test/form/samples/export-__proto__-from/_expected/amd.js @@ -0,0 +1,10 @@ +define(['exports', 'x'], (function (exports, x) { 'use strict'; + + + + Object.defineProperty(exports, "__proto__", { + enumerable: true, + value: x.__proto__ + }); + +})); diff --git a/test/form/samples/export-__proto__-from/_expected/cjs.js b/test/form/samples/export-__proto__-from/_expected/cjs.js new file mode 100644 index 00000000000..56eef6e2b55 --- /dev/null +++ b/test/form/samples/export-__proto__-from/_expected/cjs.js @@ -0,0 +1,10 @@ +'use strict'; + +var x = require('x'); + + + +Object.defineProperty(exports, "__proto__", { + enumerable: true, + value: x.__proto__ +}); diff --git a/test/form/samples/export-__proto__-from/_expected/es.js b/test/form/samples/export-__proto__-from/_expected/es.js new file mode 100644 index 00000000000..6a5462dbf88 --- /dev/null +++ b/test/form/samples/export-__proto__-from/_expected/es.js @@ -0,0 +1 @@ +export { __proto__ } from 'x'; diff --git a/test/form/samples/export-__proto__-from/_expected/iife.js b/test/form/samples/export-__proto__-from/_expected/iife.js new file mode 100644 index 00000000000..ac08ba69ef8 --- /dev/null +++ b/test/form/samples/export-__proto__-from/_expected/iife.js @@ -0,0 +1,13 @@ +var bundle = (function (exports, x) { + 'use strict'; + + + + Object.defineProperty(exports, "__proto__", { + enumerable: true, + value: x.__proto__ + }); + + return exports; + +})({}, x); diff --git a/test/form/samples/export-__proto__-from/_expected/system.js b/test/form/samples/export-__proto__-from/_expected/system.js new file mode 100644 index 00000000000..cfa68bd09ed --- /dev/null +++ b/test/form/samples/export-__proto__-from/_expected/system.js @@ -0,0 +1,13 @@ +System.register('bundle', ['x'], (function (exports) { + 'use strict'; + return { + setters: [function (module) { + exports("__proto__", module.__proto__); + }], + execute: (function () { + + + + }) + }; +})); diff --git a/test/form/samples/export-__proto__-from/_expected/umd.js b/test/form/samples/export-__proto__-from/_expected/umd.js new file mode 100644 index 00000000000..98dec858899 --- /dev/null +++ b/test/form/samples/export-__proto__-from/_expected/umd.js @@ -0,0 +1,12 @@ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('x')) : + typeof define === 'function' && define.amd ? define(['exports', 'x'], factory) : + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.bundle = {}, global.x)); +})(this, (function (exports, x) { 'use strict'; + + Object.defineProperty(exports, "__proto__", { + enumerable: true, + value: x.__proto__ + }); + +})); diff --git a/test/form/samples/export-__proto__-from/main.js b/test/form/samples/export-__proto__-from/main.js new file mode 100644 index 00000000000..6a5462dbf88 --- /dev/null +++ b/test/form/samples/export-__proto__-from/main.js @@ -0,0 +1 @@ +export { __proto__ } from 'x'; diff --git a/test/form/samples/export-__proto__/_config.js b/test/form/samples/export-__proto__/_config.js new file mode 100644 index 00000000000..5f59d0b7705 --- /dev/null +++ b/test/form/samples/export-__proto__/_config.js @@ -0,0 +1,13 @@ +module.exports = defineTest({ + description: 'export __proto__', + options: { + external: ['x'], + output: { + externalLiveBindings: false, + globals: { + x: 'x' + }, + name: 'bundle' + } + } +}); diff --git a/test/form/samples/export-__proto__/_expected/amd.js b/test/form/samples/export-__proto__/_expected/amd.js new file mode 100644 index 00000000000..a0cf4215a09 --- /dev/null +++ b/test/form/samples/export-__proto__/_expected/amd.js @@ -0,0 +1,26 @@ +define(['exports', 'x'], (function (exports, x$1) { 'use strict'; + + const __proto__ = 1; + + var x = /*#__PURE__*/Object.freeze({ + __proto__: null, + ["__proto__"]: __proto__ + }); + + Object.defineProperty(exports, "__proto__", { + enumerable: true, + value: __proto__ + }); + exports.x = x; + Object.prototype.hasOwnProperty.call(x$1, '__proto__') && + !Object.prototype.hasOwnProperty.call(exports, '__proto__') && + Object.defineProperty(exports, '__proto__', { + enumerable: true, + value: x$1['__proto__'] + }); + + Object.keys(x$1).forEach(function (k) { + if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) exports[k] = x$1[k]; + }); + +})); diff --git a/test/form/samples/export-__proto__/_expected/cjs.js b/test/form/samples/export-__proto__/_expected/cjs.js new file mode 100644 index 00000000000..5435be03437 --- /dev/null +++ b/test/form/samples/export-__proto__/_expected/cjs.js @@ -0,0 +1,26 @@ +'use strict'; + +var x$1 = require('x'); + +const __proto__ = 1; + +var x = /*#__PURE__*/Object.freeze({ + __proto__: null, + ["__proto__"]: __proto__ +}); + +Object.defineProperty(exports, "__proto__", { + enumerable: true, + value: __proto__ +}); +exports.x = x; +Object.prototype.hasOwnProperty.call(x$1, '__proto__') && + !Object.prototype.hasOwnProperty.call(exports, '__proto__') && + Object.defineProperty(exports, '__proto__', { + enumerable: true, + value: x$1['__proto__'] + }); + +Object.keys(x$1).forEach(function (k) { + if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) exports[k] = x$1[k]; +}); diff --git a/test/form/samples/export-__proto__/_expected/es.js b/test/form/samples/export-__proto__/_expected/es.js new file mode 100644 index 00000000000..bf7bcf728a4 --- /dev/null +++ b/test/form/samples/export-__proto__/_expected/es.js @@ -0,0 +1,10 @@ +export * from 'x'; + +const __proto__ = 1; + +var x = /*#__PURE__*/Object.freeze({ + __proto__: null, + ["__proto__"]: __proto__ +}); + +export { __proto__, x }; diff --git a/test/form/samples/export-__proto__/_expected/iife.js b/test/form/samples/export-__proto__/_expected/iife.js new file mode 100644 index 00000000000..e436ea14401 --- /dev/null +++ b/test/form/samples/export-__proto__/_expected/iife.js @@ -0,0 +1,29 @@ +var bundle = (function (exports, x$1) { + 'use strict'; + + const __proto__ = 1; + + var x = /*#__PURE__*/Object.freeze({ + __proto__: null, + ["__proto__"]: __proto__ + }); + + Object.defineProperty(exports, "__proto__", { + enumerable: true, + value: __proto__ + }); + exports.x = x; + Object.prototype.hasOwnProperty.call(x$1, '__proto__') && + !Object.prototype.hasOwnProperty.call(exports, '__proto__') && + Object.defineProperty(exports, '__proto__', { + enumerable: true, + value: x$1['__proto__'] + }); + + Object.keys(x$1).forEach(function (k) { + if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) exports[k] = x$1[k]; + }); + + return exports; + +})({}, x); diff --git a/test/form/samples/export-__proto__/_expected/system.js b/test/form/samples/export-__proto__/_expected/system.js new file mode 100644 index 00000000000..d9526555a12 --- /dev/null +++ b/test/form/samples/export-__proto__/_expected/system.js @@ -0,0 +1,29 @@ +System.register('bundle', ['x'], (function (exports) { + 'use strict'; + var _starExcludes = { + __proto__: null, + ["__proto__"]: 1, + x: 1, + default: 1 + }; + return { + setters: [function (module) { + var setter = { __proto__: null }; + for (var name in module) { + if (!_starExcludes[name]) setter[name] = module[name]; + } + exports(setter); + }], + execute: (function () { + + const __proto__ = exports("__proto__", 1); + + var x = /*#__PURE__*/Object.freeze({ + __proto__: null, + ["__proto__"]: __proto__ + }); + exports("x", x); + + }) + }; +})); diff --git a/test/form/samples/export-__proto__/_expected/umd.js b/test/form/samples/export-__proto__/_expected/umd.js new file mode 100644 index 00000000000..210b822f9a1 --- /dev/null +++ b/test/form/samples/export-__proto__/_expected/umd.js @@ -0,0 +1,30 @@ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('x')) : + typeof define === 'function' && define.amd ? define(['exports', 'x'], factory) : + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.bundle = {}, global.x)); +})(this, (function (exports, x$1) { 'use strict'; + + const __proto__ = 1; + + var x = /*#__PURE__*/Object.freeze({ + __proto__: null, + ["__proto__"]: __proto__ + }); + + Object.defineProperty(exports, "__proto__", { + enumerable: true, + value: __proto__ + }); + exports.x = x; + Object.prototype.hasOwnProperty.call(x$1, '__proto__') && + !Object.prototype.hasOwnProperty.call(exports, '__proto__') && + Object.defineProperty(exports, '__proto__', { + enumerable: true, + value: x$1['__proto__'] + }); + + Object.keys(x$1).forEach(function (k) { + if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) exports[k] = x$1[k]; + }); + +})); diff --git a/test/form/samples/export-__proto__/main.js b/test/form/samples/export-__proto__/main.js new file mode 100644 index 00000000000..658d23f6b92 --- /dev/null +++ b/test/form/samples/export-__proto__/main.js @@ -0,0 +1,3 @@ +export { __proto__ } from './x'; +export * as x from './x'; +export * from 'x'; diff --git a/test/form/samples/export-__proto__/x.js b/test/form/samples/export-__proto__/x.js new file mode 100644 index 00000000000..b7d6c33b265 --- /dev/null +++ b/test/form/samples/export-__proto__/x.js @@ -0,0 +1 @@ +export const __proto__ = 1; diff --git a/test/form/samples/export-all-before-named/_config.js b/test/form/samples/export-all-before-named/_config.js index b84d76b6669..91f7f20ccb1 100644 --- a/test/form/samples/export-all-before-named/_config.js +++ b/test/form/samples/export-all-before-named/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'external `export *` must not interfere with internal exports', options: { output: { @@ -7,4 +7,4 @@ module.exports = { }, external: ['external'] } -}; +}); diff --git a/test/form/samples/export-all-before-named/_expected/amd.js b/test/form/samples/export-all-before-named/_expected/amd.js index 992516bce48..bd0d2cf9ff2 100644 --- a/test/form/samples/export-all-before-named/_expected/amd.js +++ b/test/form/samples/export-all-before-named/_expected/amd.js @@ -1,4 +1,4 @@ -define(['exports', 'external'], function (exports, external) { 'use strict'; +define(['exports', 'external'], (function (exports, external) { 'use strict'; function internalFn(path) { return path[0] === '.'; @@ -6,14 +6,10 @@ define(['exports', 'external'], function (exports, external) { 'use strict'; exports.internalFn = internalFn; Object.keys(external).forEach(function (k) { - if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, { + if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, { enumerable: true, - get: function () { - return external[k]; - } + get: function () { return external[k]; } }); }); - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/form/samples/export-all-before-named/_expected/cjs.js b/test/form/samples/export-all-before-named/_expected/cjs.js index ca91d57ba6c..b57552512e3 100644 --- a/test/form/samples/export-all-before-named/_expected/cjs.js +++ b/test/form/samples/export-all-before-named/_expected/cjs.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - var external = require('external'); function internalFn(path) { @@ -10,10 +8,8 @@ function internalFn(path) { exports.internalFn = internalFn; Object.keys(external).forEach(function (k) { - if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, { + if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, { enumerable: true, - get: function () { - return external[k]; - } + get: function () { return external[k]; } }); }); diff --git a/test/form/samples/export-all-before-named/_expected/iife.js b/test/form/samples/export-all-before-named/_expected/iife.js index 524791eb5f4..3c881b08fa8 100644 --- a/test/form/samples/export-all-before-named/_expected/iife.js +++ b/test/form/samples/export-all-before-named/_expected/iife.js @@ -7,16 +7,12 @@ var exposedInternals = (function (exports, external) { exports.internalFn = internalFn; Object.keys(external).forEach(function (k) { - if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, { + if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, { enumerable: true, - get: function () { - return external[k]; - } + get: function () { return external[k]; } }); }); - Object.defineProperty(exports, '__esModule', { value: true }); - return exports; -}({}, external)); +})({}, external); diff --git a/test/form/samples/export-all-before-named/_expected/system.js b/test/form/samples/export-all-before-named/_expected/system.js index 3325a7ce5ed..c74881924d2 100644 --- a/test/form/samples/export-all-before-named/_expected/system.js +++ b/test/form/samples/export-all-before-named/_expected/system.js @@ -1,22 +1,26 @@ -System.register('exposedInternals', ['external'], function (exports) { +System.register('exposedInternals', ['external'], (function (exports) { 'use strict'; - var _starExcludes = { internalFn: 1, default: 1 }; + var _starExcludes = { + __proto__: null, + internalFn: 1, + default: 1 + }; return { setters: [function (module) { - var _setter = {}; - for (var _$p in module) { - if (!_starExcludes[_$p]) _setter[_$p] = module[_$p]; + var setter = { __proto__: null }; + for (var name in module) { + if (!_starExcludes[name]) setter[name] = module[name]; } - exports(_setter); + exports(setter); }], - execute: function () { + execute: (function () { - exports('internalFn', internalFn); + exports("internalFn", internalFn); function internalFn(path) { return path[0] === '.'; } - } + }) }; -}); +})); diff --git a/test/form/samples/export-all-before-named/_expected/umd.js b/test/form/samples/export-all-before-named/_expected/umd.js index b6ef3fc25a9..060a931a33b 100644 --- a/test/form/samples/export-all-before-named/_expected/umd.js +++ b/test/form/samples/export-all-before-named/_expected/umd.js @@ -2,7 +2,7 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('external')) : typeof define === 'function' && define.amd ? define(['exports', 'external'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.exposedInternals = {}, global.external)); -}(this, (function (exports, external) { 'use strict'; +})(this, (function (exports, external) { 'use strict'; function internalFn(path) { return path[0] === '.'; @@ -10,14 +10,10 @@ exports.internalFn = internalFn; Object.keys(external).forEach(function (k) { - if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, { + if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, { enumerable: true, - get: function () { - return external[k]; - } + get: function () { return external[k]; } }); }); - Object.defineProperty(exports, '__esModule', { value: true }); - -}))); +})); diff --git a/test/form/samples/export-all-from-internal/_config.js b/test/form/samples/export-all-from-internal/_config.js index da1154dcb29..a60e721b826 100644 --- a/test/form/samples/export-all-from-internal/_config.js +++ b/test/form/samples/export-all-from-internal/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'should be able to export * from the bundle', options: { output: { name: 'exposedInternals' } } -}; +}); diff --git a/test/form/samples/export-all-from-internal/_expected/amd.js b/test/form/samples/export-all-from-internal/_expected/amd.js index c3acbb07b16..c9db0af538d 100644 --- a/test/form/samples/export-all-from-internal/_expected/amd.js +++ b/test/form/samples/export-all-from-internal/_expected/amd.js @@ -1,4 +1,4 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; const a = 1; const b = 2; @@ -6,6 +6,4 @@ define(['exports'], function (exports) { 'use strict'; exports.a = a; exports.b = b; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/form/samples/export-all-from-internal/_expected/cjs.js b/test/form/samples/export-all-from-internal/_expected/cjs.js index e208b74e989..869bba079af 100644 --- a/test/form/samples/export-all-from-internal/_expected/cjs.js +++ b/test/form/samples/export-all-from-internal/_expected/cjs.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - const a = 1; const b = 2; diff --git a/test/form/samples/export-all-from-internal/_expected/iife.js b/test/form/samples/export-all-from-internal/_expected/iife.js index eb22ecec63a..4ba6ea0a271 100644 --- a/test/form/samples/export-all-from-internal/_expected/iife.js +++ b/test/form/samples/export-all-from-internal/_expected/iife.js @@ -7,8 +7,6 @@ var exposedInternals = (function (exports) { exports.a = a; exports.b = b; - Object.defineProperty(exports, '__esModule', { value: true }); - return exports; -}({})); +})({}); diff --git a/test/form/samples/export-all-from-internal/_expected/system.js b/test/form/samples/export-all-from-internal/_expected/system.js index 3cc1a07271a..58837c7625e 100644 --- a/test/form/samples/export-all-from-internal/_expected/system.js +++ b/test/form/samples/export-all-from-internal/_expected/system.js @@ -1,11 +1,11 @@ -System.register('exposedInternals', [], function (exports) { +System.register('exposedInternals', [], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - const a = exports('a', 1); - const b = exports('b', 2); + const a = exports("a", 1); + const b = exports("b", 2); - } + }) }; -}); +})); diff --git a/test/form/samples/export-all-from-internal/_expected/umd.js b/test/form/samples/export-all-from-internal/_expected/umd.js index c0ed3fee9eb..c0a8d223420 100644 --- a/test/form/samples/export-all-from-internal/_expected/umd.js +++ b/test/form/samples/export-all-from-internal/_expected/umd.js @@ -2,7 +2,7 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.exposedInternals = {})); -}(this, (function (exports) { 'use strict'; +})(this, (function (exports) { 'use strict'; const a = 1; const b = 2; @@ -10,6 +10,4 @@ exports.a = a; exports.b = b; - Object.defineProperty(exports, '__esModule', { value: true }); - -}))); +})); diff --git a/test/form/samples/export-all-multiple/_config.js b/test/form/samples/export-all-multiple/_config.js index e66c29bacbc..7c70deaae7b 100644 --- a/test/form/samples/export-all-multiple/_config.js +++ b/test/form/samples/export-all-multiple/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'correctly handles multiple export * declarations (#1252)', options: { external: ['foo', 'bar', 'baz'], @@ -7,4 +7,4 @@ module.exports = { name: 'myBundle' } } -}; +}); diff --git a/test/form/samples/export-all-multiple/_expected/amd.js b/test/form/samples/export-all-multiple/_expected/amd.js index 76d538855b1..af08cdf25cf 100644 --- a/test/form/samples/export-all-multiple/_expected/amd.js +++ b/test/form/samples/export-all-multiple/_expected/amd.js @@ -1,32 +1,24 @@ -define(['exports', 'foo', 'bar', 'baz'], function (exports, foo, bar, baz) { 'use strict'; +define(['exports', 'foo', 'bar', 'baz'], (function (exports, foo, bar, baz) { 'use strict'; Object.keys(foo).forEach(function (k) { - if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, { + if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, { enumerable: true, - get: function () { - return foo[k]; - } + get: function () { return foo[k]; } }); }); Object.keys(bar).forEach(function (k) { - if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, { + if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, { enumerable: true, - get: function () { - return bar[k]; - } + get: function () { return bar[k]; } }); }); Object.keys(baz).forEach(function (k) { - if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, { + if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, { enumerable: true, - get: function () { - return baz[k]; - } + get: function () { return baz[k]; } }); }); - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/form/samples/export-all-multiple/_expected/cjs.js b/test/form/samples/export-all-multiple/_expected/cjs.js index 63491e13df6..abe3b4f82a6 100644 --- a/test/form/samples/export-all-multiple/_expected/cjs.js +++ b/test/form/samples/export-all-multiple/_expected/cjs.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - var foo = require('foo'); var bar = require('bar'); var baz = require('baz'); @@ -9,26 +7,20 @@ var baz = require('baz'); Object.keys(foo).forEach(function (k) { - if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, { + if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, { enumerable: true, - get: function () { - return foo[k]; - } + get: function () { return foo[k]; } }); }); Object.keys(bar).forEach(function (k) { - if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, { + if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, { enumerable: true, - get: function () { - return bar[k]; - } + get: function () { return bar[k]; } }); }); Object.keys(baz).forEach(function (k) { - if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, { + if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, { enumerable: true, - get: function () { - return baz[k]; - } + get: function () { return baz[k]; } }); }); diff --git a/test/form/samples/export-all-multiple/_expected/iife.js b/test/form/samples/export-all-multiple/_expected/iife.js index fe9a5885453..0ab57cba79c 100644 --- a/test/form/samples/export-all-multiple/_expected/iife.js +++ b/test/form/samples/export-all-multiple/_expected/iife.js @@ -4,32 +4,24 @@ var myBundle = (function (exports, foo, bar, baz) { Object.keys(foo).forEach(function (k) { - if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, { + if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, { enumerable: true, - get: function () { - return foo[k]; - } + get: function () { return foo[k]; } }); }); Object.keys(bar).forEach(function (k) { - if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, { + if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, { enumerable: true, - get: function () { - return bar[k]; - } + get: function () { return bar[k]; } }); }); Object.keys(baz).forEach(function (k) { - if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, { + if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, { enumerable: true, - get: function () { - return baz[k]; - } + get: function () { return baz[k]; } }); }); - Object.defineProperty(exports, '__esModule', { value: true }); - return exports; -}({}, foo, bar, baz)); +})({}, foo, bar, baz); diff --git a/test/form/samples/export-all-multiple/_expected/system.js b/test/form/samples/export-all-multiple/_expected/system.js index ebb64473fa3..d5680b2dbec 100644 --- a/test/form/samples/export-all-multiple/_expected/system.js +++ b/test/form/samples/export-all-multiple/_expected/system.js @@ -1,30 +1,33 @@ -System.register('myBundle', ['foo', 'bar', 'baz'], function (exports) { +System.register('myBundle', ['foo', 'bar', 'baz'], (function (exports) { 'use strict'; - var _starExcludes = { default: 1 }; + var _starExcludes = { + __proto__: null, + default: 1 + }; return { setters: [function (module) { - var _setter = {}; - for (var _$p in module) { - if (!_starExcludes[_$p]) _setter[_$p] = module[_$p]; + var setter = { __proto__: null }; + for (var name in module) { + if (!_starExcludes[name]) setter[name] = module[name]; } - exports(_setter); + exports(setter); }, function (module) { - var _setter = {}; - for (var _$p in module) { - if (!_starExcludes[_$p]) _setter[_$p] = module[_$p]; + var setter = { __proto__: null }; + for (var name in module) { + if (!_starExcludes[name]) setter[name] = module[name]; } - exports(_setter); + exports(setter); }, function (module) { - var _setter = {}; - for (var _$p in module) { - if (!_starExcludes[_$p]) _setter[_$p] = module[_$p]; + var setter = { __proto__: null }; + for (var name in module) { + if (!_starExcludes[name]) setter[name] = module[name]; } - exports(_setter); + exports(setter); }], - execute: function () { + execute: (function () { - } + }) }; -}); +})); diff --git a/test/form/samples/export-all-multiple/_expected/umd.js b/test/form/samples/export-all-multiple/_expected/umd.js index 14fca7409e6..c1ffe0296e0 100644 --- a/test/form/samples/export-all-multiple/_expected/umd.js +++ b/test/form/samples/export-all-multiple/_expected/umd.js @@ -2,33 +2,25 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('foo'), require('bar'), require('baz')) : typeof define === 'function' && define.amd ? define(['exports', 'foo', 'bar', 'baz'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.myBundle = {}, global.foo, global.bar, global.baz)); -}(this, (function (exports, foo, bar, baz) { 'use strict'; +})(this, (function (exports, foo, bar, baz) { 'use strict'; Object.keys(foo).forEach(function (k) { - if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, { + if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, { enumerable: true, - get: function () { - return foo[k]; - } + get: function () { return foo[k]; } }); }); Object.keys(bar).forEach(function (k) { - if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, { + if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, { enumerable: true, - get: function () { - return bar[k]; - } + get: function () { return bar[k]; } }); }); Object.keys(baz).forEach(function (k) { - if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, { + if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, { enumerable: true, - get: function () { - return baz[k]; - } + get: function () { return baz[k]; } }); }); - Object.defineProperty(exports, '__esModule', { value: true }); - -}))); +})); diff --git a/test/form/samples/export-default-2/_config.js b/test/form/samples/export-default-2/_config.js index 76310657af8..8675d82dd4c 100644 --- a/test/form/samples/export-default-2/_config.js +++ b/test/form/samples/export-default-2/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 're-exporting a default export', options: { output: { name: 'myBundle' } } -}; +}); diff --git a/test/form/samples/export-default-2/_expected/amd.js b/test/form/samples/export-default-2/_expected/amd.js index 7b9dcd11379..dfc84dd75d4 100644 --- a/test/form/samples/export-default-2/_expected/amd.js +++ b/test/form/samples/export-default-2/_expected/amd.js @@ -1,7 +1,7 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; var bar = 1; return bar; -}); +})); diff --git a/test/form/samples/export-default-2/_expected/es.js b/test/form/samples/export-default-2/_expected/es.js index 095bf806d8f..1f6587a8542 100644 --- a/test/form/samples/export-default-2/_expected/es.js +++ b/test/form/samples/export-default-2/_expected/es.js @@ -1,3 +1,3 @@ var bar = 1; -export default bar; +export { bar as default }; diff --git a/test/form/samples/export-default-2/_expected/iife.js b/test/form/samples/export-default-2/_expected/iife.js index 240a5fe7872..fe62cfdfded 100644 --- a/test/form/samples/export-default-2/_expected/iife.js +++ b/test/form/samples/export-default-2/_expected/iife.js @@ -5,4 +5,4 @@ var myBundle = (function () { return bar; -}()); +})(); diff --git a/test/form/samples/export-default-2/_expected/system.js b/test/form/samples/export-default-2/_expected/system.js index a7450c3b933..c4a0a104323 100644 --- a/test/form/samples/export-default-2/_expected/system.js +++ b/test/form/samples/export-default-2/_expected/system.js @@ -1,10 +1,10 @@ -System.register('myBundle', [], function (exports) { +System.register('myBundle', [], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - var bar = exports('default', 1); + var bar = exports("default", 1); - } + }) }; -}); +})); diff --git a/test/form/samples/export-default-2/_expected/umd.js b/test/form/samples/export-default-2/_expected/umd.js index 9e3d59ff229..84e9930bccc 100644 --- a/test/form/samples/export-default-2/_expected/umd.js +++ b/test/form/samples/export-default-2/_expected/umd.js @@ -2,10 +2,10 @@ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.myBundle = factory()); -}(this, (function () { 'use strict'; +})(this, (function () { 'use strict'; var bar = 1; return bar; -}))); +})); diff --git a/test/form/samples/export-default-3/_config.js b/test/form/samples/export-default-3/_config.js index 76310657af8..8675d82dd4c 100644 --- a/test/form/samples/export-default-3/_config.js +++ b/test/form/samples/export-default-3/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 're-exporting a default export', options: { output: { name: 'myBundle' } } -}; +}); diff --git a/test/form/samples/export-default-3/_expected/amd.js b/test/form/samples/export-default-3/_expected/amd.js index 7b9dcd11379..dfc84dd75d4 100644 --- a/test/form/samples/export-default-3/_expected/amd.js +++ b/test/form/samples/export-default-3/_expected/amd.js @@ -1,7 +1,7 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; var bar = 1; return bar; -}); +})); diff --git a/test/form/samples/export-default-3/_expected/es.js b/test/form/samples/export-default-3/_expected/es.js index 095bf806d8f..1f6587a8542 100644 --- a/test/form/samples/export-default-3/_expected/es.js +++ b/test/form/samples/export-default-3/_expected/es.js @@ -1,3 +1,3 @@ var bar = 1; -export default bar; +export { bar as default }; diff --git a/test/form/samples/export-default-3/_expected/iife.js b/test/form/samples/export-default-3/_expected/iife.js index 240a5fe7872..fe62cfdfded 100644 --- a/test/form/samples/export-default-3/_expected/iife.js +++ b/test/form/samples/export-default-3/_expected/iife.js @@ -5,4 +5,4 @@ var myBundle = (function () { return bar; -}()); +})(); diff --git a/test/form/samples/export-default-3/_expected/system.js b/test/form/samples/export-default-3/_expected/system.js index a7450c3b933..c4a0a104323 100644 --- a/test/form/samples/export-default-3/_expected/system.js +++ b/test/form/samples/export-default-3/_expected/system.js @@ -1,10 +1,10 @@ -System.register('myBundle', [], function (exports) { +System.register('myBundle', [], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - var bar = exports('default', 1); + var bar = exports("default", 1); - } + }) }; -}); +})); diff --git a/test/form/samples/export-default-3/_expected/umd.js b/test/form/samples/export-default-3/_expected/umd.js index 9e3d59ff229..84e9930bccc 100644 --- a/test/form/samples/export-default-3/_expected/umd.js +++ b/test/form/samples/export-default-3/_expected/umd.js @@ -2,10 +2,10 @@ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.myBundle = factory()); -}(this, (function () { 'use strict'; +})(this, (function () { 'use strict'; var bar = 1; return bar; -}))); +})); diff --git a/test/form/samples/export-default-4/_config.js b/test/form/samples/export-default-4/_config.js index a3d71b3ae40..17be4468792 100644 --- a/test/form/samples/export-default-4/_config.js +++ b/test/form/samples/export-default-4/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'single default export in deep namespace', options: { output: { name: 'my.global.namespace' } } -}; +}); diff --git a/test/form/samples/export-default-4/_expected/amd.js b/test/form/samples/export-default-4/_expected/amd.js index 37d25711e09..538fc7738a6 100644 --- a/test/form/samples/export-default-4/_expected/amd.js +++ b/test/form/samples/export-default-4/_expected/amd.js @@ -1,7 +1,7 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; var main = 42; return main; -}); +})); diff --git a/test/form/samples/export-default-4/_expected/es.js b/test/form/samples/export-default-4/_expected/es.js index d862de816a3..c3e30233192 100644 --- a/test/form/samples/export-default-4/_expected/es.js +++ b/test/form/samples/export-default-4/_expected/es.js @@ -1,3 +1,3 @@ var main = 42; -export default main; +export { main as default }; diff --git a/test/form/samples/export-default-4/_expected/iife.js b/test/form/samples/export-default-4/_expected/iife.js index 7ad35103978..3a75d08c76e 100644 --- a/test/form/samples/export-default-4/_expected/iife.js +++ b/test/form/samples/export-default-4/_expected/iife.js @@ -7,4 +7,4 @@ this.my.global.namespace = (function () { return main; -}()); +})(); diff --git a/test/form/samples/export-default-4/_expected/system.js b/test/form/samples/export-default-4/_expected/system.js index 944f6665e80..999e6d95935 100644 --- a/test/form/samples/export-default-4/_expected/system.js +++ b/test/form/samples/export-default-4/_expected/system.js @@ -1,10 +1,10 @@ -System.register('my.global.namespace', [], function (exports) { +System.register('my.global.namespace', [], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - var main = exports('default', 42); + var main = exports("default", 42); - } + }) }; -}); +})); diff --git a/test/form/samples/export-default-4/_expected/umd.js b/test/form/samples/export-default-4/_expected/umd.js index 1b9c9d9e201..afebcefeb92 100644 --- a/test/form/samples/export-default-4/_expected/umd.js +++ b/test/form/samples/export-default-4/_expected/umd.js @@ -2,10 +2,10 @@ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, (global.my = global.my || {}, global.my.global = global.my.global || {}, global.my.global.namespace = factory())); -}(this, (function () { 'use strict'; +})(this, (function () { 'use strict'; var main = 42; return main; -}))); +})); diff --git a/test/form/samples/export-default-anonymous-declarations/_config.js b/test/form/samples/export-default-anonymous-declarations/_config.js index 954cb9097f7..416f8b5ae28 100644 --- a/test/form/samples/export-default-anonymous-declarations/_config.js +++ b/test/form/samples/export-default-anonymous-declarations/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'export default [Declaration] with spaces and comments' -}; +}); diff --git a/test/form/samples/export-default-anonymous-declarations/_expected/amd.js b/test/form/samples/export-default-anonymous-declarations/_expected/amd.js index 7afc55c0998..88598ec73d3 100644 --- a/test/form/samples/export-default-anonymous-declarations/_expected/amd.js +++ b/test/form/samples/export-default-anonymous-declarations/_expected/amd.js @@ -1,4 +1,4 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; // jsjjjsjjjjsjs @@ -87,4 +87,4 @@ define(function () { 'use strict'; spacelessFn(); spacelessGenerator(); -}); +})); diff --git a/test/form/samples/export-default-anonymous-declarations/_expected/iife.js b/test/form/samples/export-default-anonymous-declarations/_expected/iife.js index 333f54e91fd..ebd10c6ba63 100644 --- a/test/form/samples/export-default-anonymous-declarations/_expected/iife.js +++ b/test/form/samples/export-default-anonymous-declarations/_expected/iife.js @@ -88,4 +88,4 @@ spacelessFn(); spacelessGenerator(); -}()); +})(); diff --git a/test/form/samples/export-default-anonymous-declarations/_expected/system.js b/test/form/samples/export-default-anonymous-declarations/_expected/system.js index fb0d9f2bd10..1935b586ae5 100644 --- a/test/form/samples/export-default-anonymous-declarations/_expected/system.js +++ b/test/form/samples/export-default-anonymous-declarations/_expected/system.js @@ -1,7 +1,7 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { // jsjjjsjjjjsjs @@ -90,6 +90,6 @@ System.register([], function () { spacelessFn(); spacelessGenerator(); - } + }) }; -}); +})); diff --git a/test/form/samples/export-default-anonymous-declarations/_expected/umd.js b/test/form/samples/export-default-anonymous-declarations/_expected/umd.js index c3cb449560c..f0499be9def 100644 --- a/test/form/samples/export-default-anonymous-declarations/_expected/umd.js +++ b/test/form/samples/export-default-anonymous-declarations/_expected/umd.js @@ -1,7 +1,7 @@ (function (factory) { typeof define === 'function' && define.amd ? define(factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; // jsjjjsjjjjsjs @@ -90,4 +90,4 @@ spacelessFn(); spacelessGenerator(); -}))); +})); diff --git a/test/form/samples/export-default-binding/_config.js b/test/form/samples/export-default-binding/_config.js new file mode 100644 index 00000000000..9102853637c --- /dev/null +++ b/test/form/samples/export-default-binding/_config.js @@ -0,0 +1,4 @@ +module.exports = defineTest({ + description: 'single (named default) export', + options: { output: { name: 'myBundle' } } +}); diff --git a/test/form/samples/export-default-binding/_expected/amd.js b/test/form/samples/export-default-binding/_expected/amd.js new file mode 100644 index 00000000000..e7a29be76ef --- /dev/null +++ b/test/form/samples/export-default-binding/_expected/amd.js @@ -0,0 +1,9 @@ +define(['exports'], (function (exports) { 'use strict'; + + exports.default = 0; + console.log(exports.default); + exports.default = 1; + + return exports.default; + +})); diff --git a/test/form/samples/export-default-binding/_expected/cjs.js b/test/form/samples/export-default-binding/_expected/cjs.js new file mode 100644 index 00000000000..40ee3485e01 --- /dev/null +++ b/test/form/samples/export-default-binding/_expected/cjs.js @@ -0,0 +1,7 @@ +'use strict'; + +exports.default = 0; +console.log(exports.default); +exports.default = 1; + +module.exports = exports.default; diff --git a/test/form/samples/export-default-binding/_expected/es.js b/test/form/samples/export-default-binding/_expected/es.js new file mode 100644 index 00000000000..acd412e5385 --- /dev/null +++ b/test/form/samples/export-default-binding/_expected/es.js @@ -0,0 +1,5 @@ +let value = 0; +console.log(value); +value = 1; + +export { value as default }; diff --git a/test/form/samples/export-default-binding/_expected/iife.js b/test/form/samples/export-default-binding/_expected/iife.js new file mode 100644 index 00000000000..1c35bb97b29 --- /dev/null +++ b/test/form/samples/export-default-binding/_expected/iife.js @@ -0,0 +1,10 @@ +var myBundle = (function (exports) { + 'use strict'; + + exports.default = 0; + console.log(exports.default); + exports.default = 1; + + return exports.default; + +})({}); diff --git a/test/form/samples/export-default-binding/_expected/system.js b/test/form/samples/export-default-binding/_expected/system.js new file mode 100644 index 00000000000..3e60e69d0d4 --- /dev/null +++ b/test/form/samples/export-default-binding/_expected/system.js @@ -0,0 +1,12 @@ +System.register('myBundle', [], (function (exports) { + 'use strict'; + return { + execute: (function () { + + let value = exports("default", 0); + console.log(value); + exports("default", value = 1); + + }) + }; +})); diff --git a/test/form/samples/export-default-binding/_expected/umd.js b/test/form/samples/export-default-binding/_expected/umd.js new file mode 100644 index 00000000000..7abb62319c1 --- /dev/null +++ b/test/form/samples/export-default-binding/_expected/umd.js @@ -0,0 +1,13 @@ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(exports) : + typeof define === 'function' && define.amd ? define(['exports'], factory) : + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.myBundle = factory(global.myBundle = {})); +})(this, (function (exports) { 'use strict'; + + exports.default = 0; + console.log(exports.default); + exports.default = 1; + + return exports.default; + +})); diff --git a/test/form/samples/export-default-binding/main.js b/test/form/samples/export-default-binding/main.js new file mode 100644 index 00000000000..f43cbfea3ad --- /dev/null +++ b/test/form/samples/export-default-binding/main.js @@ -0,0 +1,5 @@ +let value = 0; +console.log(value) +value = 1; + +export { value as default }; diff --git a/test/form/samples/export-default-global/_config.js b/test/form/samples/export-default-global/_config.js index aa46da8cf0b..63a2bb092df 100644 --- a/test/form/samples/export-default-global/_config.js +++ b/test/form/samples/export-default-global/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'handles default exporting global variables', options: { output: { name: 'bundle' } } -}; +}); diff --git a/test/form/samples/export-default-global/_expected/amd.js b/test/form/samples/export-default-global/_expected/amd.js index 11c4b8a2b0f..a6daec5fdd0 100644 --- a/test/form/samples/export-default-global/_expected/amd.js +++ b/test/form/samples/export-default-global/_expected/amd.js @@ -1,4 +1,4 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; var value = global; @@ -6,4 +6,4 @@ define(function () { 'use strict'; return value; -}); +})); diff --git a/test/form/samples/export-default-global/_expected/es.js b/test/form/samples/export-default-global/_expected/es.js index 9ac6503fbb0..c5178223ac9 100644 --- a/test/form/samples/export-default-global/_expected/es.js +++ b/test/form/samples/export-default-global/_expected/es.js @@ -2,4 +2,4 @@ var value = global; console.log(value); -export default value; +export { value as default }; diff --git a/test/form/samples/export-default-global/_expected/iife.js b/test/form/samples/export-default-global/_expected/iife.js index f6ecf1c56d4..abfe29231f1 100644 --- a/test/form/samples/export-default-global/_expected/iife.js +++ b/test/form/samples/export-default-global/_expected/iife.js @@ -7,4 +7,4 @@ var bundle = (function () { return value; -}()); +})(); diff --git a/test/form/samples/export-default-global/_expected/system.js b/test/form/samples/export-default-global/_expected/system.js index 832f55e60d5..89e0b35e998 100644 --- a/test/form/samples/export-default-global/_expected/system.js +++ b/test/form/samples/export-default-global/_expected/system.js @@ -1,12 +1,12 @@ -System.register('bundle', [], function (exports) { +System.register('bundle', [], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - var value = exports('default', global); + var value = exports("default", global); console.log(value); - } + }) }; -}); +})); diff --git a/test/form/samples/export-default-global/_expected/umd.js b/test/form/samples/export-default-global/_expected/umd.js index 05c82322486..e50a58623e1 100644 --- a/test/form/samples/export-default-global/_expected/umd.js +++ b/test/form/samples/export-default-global/_expected/umd.js @@ -2,7 +2,7 @@ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.bundle = factory()); -}(this, (function () { 'use strict'; +})(this, (function () { 'use strict'; var value = global; @@ -10,4 +10,4 @@ return value; -}))); +})); diff --git a/test/form/samples/export-default-import/_config.js b/test/form/samples/export-default-import/_config.js index 2feb1b34171..6a5fb88b638 100644 --- a/test/form/samples/export-default-import/_config.js +++ b/test/form/samples/export-default-import/_config.js @@ -1,10 +1,11 @@ -module.exports = { +module.exports = defineTest({ description: 'correctly exports a default import, even in ES mode (#513)', options: { external: ['x'], output: { globals: { x: 'x' }, + interop: 'compat', name: 'myBundle' } } -}; +}); diff --git a/test/form/samples/export-default-import/_expected/amd.js b/test/form/samples/export-default-import/_expected/amd.js index 9374f722d4c..a1848741e0c 100644 --- a/test/form/samples/export-default-import/_expected/amd.js +++ b/test/form/samples/export-default-import/_expected/amd.js @@ -1,18 +1,14 @@ -define(['exports', 'x'], function (exports, x) { 'use strict'; +define(['exports', 'x'], (function (exports, x) { 'use strict'; - function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } + function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; } - var x__default = /*#__PURE__*/_interopDefaultLegacy(x); + var x__default = /*#__PURE__*/_interopDefaultCompat(x); - Object.defineProperty(exports, 'x', { + Object.defineProperty(exports, "x", { enumerable: true, - get: function () { - return x__default['default']; - } + get: function () { return x__default.default; } }); - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/form/samples/export-default-import/_expected/cjs.js b/test/form/samples/export-default-import/_expected/cjs.js index 1eb4eacef16..107b2dca2d0 100644 --- a/test/form/samples/export-default-import/_expected/cjs.js +++ b/test/form/samples/export-default-import/_expected/cjs.js @@ -1,18 +1,14 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - var x = require('x'); -function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } +function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; } -var x__default = /*#__PURE__*/_interopDefaultLegacy(x); +var x__default = /*#__PURE__*/_interopDefaultCompat(x); -Object.defineProperty(exports, 'x', { +Object.defineProperty(exports, "x", { enumerable: true, - get: function () { - return x__default['default']; - } + get: function () { return x__default.default; } }); diff --git a/test/form/samples/export-default-import/_expected/iife.js b/test/form/samples/export-default-import/_expected/iife.js index a5fa3cc6fd3..ffd89a648ff 100644 --- a/test/form/samples/export-default-import/_expected/iife.js +++ b/test/form/samples/export-default-import/_expected/iife.js @@ -1,21 +1,17 @@ var myBundle = (function (exports, x) { 'use strict'; - function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } + function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; } - var x__default = /*#__PURE__*/_interopDefaultLegacy(x); + var x__default = /*#__PURE__*/_interopDefaultCompat(x); - Object.defineProperty(exports, 'x', { + Object.defineProperty(exports, "x", { enumerable: true, - get: function () { - return x__default['default']; - } + get: function () { return x__default.default; } }); - Object.defineProperty(exports, '__esModule', { value: true }); - return exports; -}({}, x)); +})({}, x); diff --git a/test/form/samples/export-default-import/_expected/system.js b/test/form/samples/export-default-import/_expected/system.js index a3bb75db593..fb06241c980 100644 --- a/test/form/samples/export-default-import/_expected/system.js +++ b/test/form/samples/export-default-import/_expected/system.js @@ -1,13 +1,13 @@ -System.register('myBundle', ['x'], function (exports) { +System.register('myBundle', ['x'], (function (exports) { 'use strict'; return { setters: [function (module) { - exports('x', module.default); + exports("x", module.default); }], - execute: function () { + execute: (function () { - } + }) }; -}); +})); diff --git a/test/form/samples/export-default-import/_expected/umd.js b/test/form/samples/export-default-import/_expected/umd.js index 7d1f9ad7282..7b9aeb3a92c 100644 --- a/test/form/samples/export-default-import/_expected/umd.js +++ b/test/form/samples/export-default-import/_expected/umd.js @@ -2,21 +2,17 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('x')) : typeof define === 'function' && define.amd ? define(['exports', 'x'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.myBundle = {}, global.x)); -}(this, (function (exports, x) { 'use strict'; +})(this, (function (exports, x) { 'use strict'; - function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } + function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; } - var x__default = /*#__PURE__*/_interopDefaultLegacy(x); + var x__default = /*#__PURE__*/_interopDefaultCompat(x); - Object.defineProperty(exports, 'x', { + Object.defineProperty(exports, "x", { enumerable: true, - get: function () { - return x__default['default']; - } + get: function () { return x__default.default; } }); - Object.defineProperty(exports, '__esModule', { value: true }); - -}))); +})); diff --git a/test/form/samples/export-default/_config.js b/test/form/samples/export-default/_config.js index dd454c4c39f..f6dd8a9b705 100644 --- a/test/form/samples/export-default/_config.js +++ b/test/form/samples/export-default/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'single (default) exports', options: { output: { name: 'myBundle' } } -}; +}); diff --git a/test/form/samples/export-default/_expected/amd.js b/test/form/samples/export-default/_expected/amd.js index 37d25711e09..538fc7738a6 100644 --- a/test/form/samples/export-default/_expected/amd.js +++ b/test/form/samples/export-default/_expected/amd.js @@ -1,7 +1,7 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; var main = 42; return main; -}); +})); diff --git a/test/form/samples/export-default/_expected/es.js b/test/form/samples/export-default/_expected/es.js index d862de816a3..c3e30233192 100644 --- a/test/form/samples/export-default/_expected/es.js +++ b/test/form/samples/export-default/_expected/es.js @@ -1,3 +1,3 @@ var main = 42; -export default main; +export { main as default }; diff --git a/test/form/samples/export-default/_expected/iife.js b/test/form/samples/export-default/_expected/iife.js index 69d1387d37e..69055258fc3 100644 --- a/test/form/samples/export-default/_expected/iife.js +++ b/test/form/samples/export-default/_expected/iife.js @@ -5,4 +5,4 @@ var myBundle = (function () { return main; -}()); +})(); diff --git a/test/form/samples/export-default/_expected/system.js b/test/form/samples/export-default/_expected/system.js index 28ccfcd3c31..f655f84521b 100644 --- a/test/form/samples/export-default/_expected/system.js +++ b/test/form/samples/export-default/_expected/system.js @@ -1,10 +1,10 @@ -System.register('myBundle', [], function (exports) { +System.register('myBundle', [], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - var main = exports('default', 42); + var main = exports("default", 42); - } + }) }; -}); +})); diff --git a/test/form/samples/export-default/_expected/umd.js b/test/form/samples/export-default/_expected/umd.js index 6fa2ed81429..cd252572ff6 100644 --- a/test/form/samples/export-default/_expected/umd.js +++ b/test/form/samples/export-default/_expected/umd.js @@ -2,10 +2,10 @@ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.myBundle = factory()); -}(this, (function () { 'use strict'; +})(this, (function () { 'use strict'; var main = 42; return main; -}))); +})); diff --git a/test/form/samples/export-globals/_config.js b/test/form/samples/export-globals/_config.js index 2c6a4f4f9a0..d4fb00a0529 100644 --- a/test/form/samples/export-globals/_config.js +++ b/test/form/samples/export-globals/_config.js @@ -1,11 +1,8 @@ -// Changed due to https://github.com/acornjs/acorn/issues/806 -// Consider reverting this change should this become an acorn option - -module.exports = { +module.exports = defineTest({ description: 'Supports reexports of globals with namespace access', options: { output: { name: 'myBundle' } } -}; +}); diff --git a/test/form/samples/export-globals/_expected/amd.js b/test/form/samples/export-globals/_expected/amd.js index d0070ffa614..5b28ab9cc66 100644 --- a/test/form/samples/export-globals/_expected/amd.js +++ b/test/form/samples/export-globals/_expected/amd.js @@ -1,4 +1,4 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; const localIsNaN = isNaN; @@ -6,6 +6,4 @@ define(['exports'], function (exports) { 'use strict'; exports.isNaN = isNaN$1; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/form/samples/export-globals/_expected/cjs.js b/test/form/samples/export-globals/_expected/cjs.js index c83da075373..2f1ab86f010 100644 --- a/test/form/samples/export-globals/_expected/cjs.js +++ b/test/form/samples/export-globals/_expected/cjs.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - const localIsNaN = isNaN; const isNaN$1 = localIsNaN; diff --git a/test/form/samples/export-globals/_expected/iife.js b/test/form/samples/export-globals/_expected/iife.js index 5186540ab8f..208fb78b5ec 100644 --- a/test/form/samples/export-globals/_expected/iife.js +++ b/test/form/samples/export-globals/_expected/iife.js @@ -7,8 +7,6 @@ var myBundle = (function (exports) { exports.isNaN = isNaN$1; - Object.defineProperty(exports, '__esModule', { value: true }); - return exports; -}({})); +})({}); diff --git a/test/form/samples/export-globals/_expected/system.js b/test/form/samples/export-globals/_expected/system.js index 7f3a8eaf979..19ccd0ad1f6 100644 --- a/test/form/samples/export-globals/_expected/system.js +++ b/test/form/samples/export-globals/_expected/system.js @@ -1,12 +1,12 @@ -System.register('myBundle', [], function (exports) { +System.register('myBundle', [], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { const localIsNaN = isNaN; - const isNaN$1 = exports('isNaN', localIsNaN); + const isNaN$1 = exports("isNaN", localIsNaN); - } + }) }; -}); +})); diff --git a/test/form/samples/export-globals/_expected/umd.js b/test/form/samples/export-globals/_expected/umd.js index 5cf968e9682..b67e0006f5e 100644 --- a/test/form/samples/export-globals/_expected/umd.js +++ b/test/form/samples/export-globals/_expected/umd.js @@ -2,7 +2,7 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.myBundle = {})); -}(this, (function (exports) { 'use strict'; +})(this, (function (exports) { 'use strict'; const localIsNaN = isNaN; @@ -10,6 +10,4 @@ exports.isNaN = isNaN$1; - Object.defineProperty(exports, '__esModule', { value: true }); - -}))); +})); diff --git a/test/form/samples/export-internal-namespace-as/_config.js b/test/form/samples/export-internal-namespace-as/_config.js index 71792b71529..d9e1cb9af78 100644 --- a/test/form/samples/export-internal-namespace-as/_config.js +++ b/test/form/samples/export-internal-namespace-as/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'supports exporting and resolving internal namespaces as names' -}; +}); diff --git a/test/form/samples/export-internal-namespace-as/_expected.js b/test/form/samples/export-internal-namespace-as/_expected.js index ade81d9a944..c232683a250 100644 --- a/test/form/samples/export-internal-namespace-as/_expected.js +++ b/test/form/samples/export-internal-namespace-as/_expected.js @@ -5,8 +5,8 @@ const bar = 'bar2'; var dep2 = /*#__PURE__*/Object.freeze({ __proto__: null, - foo: foo, - bar: bar + bar: bar, + foo: foo }); console.log(foo$1); diff --git a/test/form/samples/export-live-bindings/_config.js b/test/form/samples/export-live-bindings/_config.js index 5e9f7bd8115..c8377f8dbbd 100644 --- a/test/form/samples/export-live-bindings/_config.js +++ b/test/form/samples/export-live-bindings/_config.js @@ -1,8 +1,8 @@ -module.exports = { +module.exports = defineTest({ description: 'exported live bindings', options: { output: { name: 'iife' } } -}; +}); diff --git a/test/form/samples/export-live-bindings/_expected/amd.js b/test/form/samples/export-live-bindings/_expected/amd.js index ddcf72690be..9d26797adbe 100644 --- a/test/form/samples/export-live-bindings/_expected/amd.js +++ b/test/form/samples/export-live-bindings/_expected/amd.js @@ -1,4 +1,4 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; function update$2 () { exports.foo += 10; @@ -32,6 +32,4 @@ define(['exports'], function (exports) { 'use strict'; exports.updateBaz = update; exports.updateFoo = update$2; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/form/samples/export-live-bindings/_expected/cjs.js b/test/form/samples/export-live-bindings/_expected/cjs.js index 3650e960cbb..c0655cff2a4 100644 --- a/test/form/samples/export-live-bindings/_expected/cjs.js +++ b/test/form/samples/export-live-bindings/_expected/cjs.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - function update$2 () { exports.foo += 10; } diff --git a/test/form/samples/export-live-bindings/_expected/iife.js b/test/form/samples/export-live-bindings/_expected/iife.js index af63726977e..1ae944f4734 100644 --- a/test/form/samples/export-live-bindings/_expected/iife.js +++ b/test/form/samples/export-live-bindings/_expected/iife.js @@ -33,8 +33,6 @@ var iife = (function (exports) { exports.updateBaz = update; exports.updateFoo = update$2; - Object.defineProperty(exports, '__esModule', { value: true }); - return exports; -}({})); +})({}); diff --git a/test/form/samples/export-live-bindings/_expected/system.js b/test/form/samples/export-live-bindings/_expected/system.js index 5dfb541a56a..357f5b39e27 100644 --- a/test/form/samples/export-live-bindings/_expected/system.js +++ b/test/form/samples/export-live-bindings/_expected/system.js @@ -1,7 +1,7 @@ -System.register('iife', [], function (exports) { +System.register('iife', [], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { exports({ updateBar: update$1, @@ -10,22 +10,22 @@ System.register('iife', [], function (exports) { }); function update$2 () { - foo = exports('foo', foo + 10); + exports("foo", foo += 10); } - let foo = exports('foo', 10); + let foo = exports("foo", 10); function update$1 () { - (exports('bar', bar + 1), bar++); + exports("bar", bar + 1), bar++; } - let bar = exports('bar', 10); + let bar = exports("bar", 10); function update () { - exports('baz', ++baz); + exports("baz", ++baz); } - let baz = exports('baz', 10); + let baz = exports("baz", 10); console.log(foo); update$2(); @@ -37,6 +37,6 @@ System.register('iife', [], function (exports) { update(); console.log(baz); - } + }) }; -}); +})); diff --git a/test/form/samples/export-live-bindings/_expected/umd.js b/test/form/samples/export-live-bindings/_expected/umd.js index ef1ea60cd40..a85d6b84d3b 100644 --- a/test/form/samples/export-live-bindings/_expected/umd.js +++ b/test/form/samples/export-live-bindings/_expected/umd.js @@ -2,7 +2,7 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.iife = {})); -}(this, (function (exports) { 'use strict'; +})(this, (function (exports) { 'use strict'; function update$2 () { exports.foo += 10; @@ -36,6 +36,4 @@ exports.updateBaz = update; exports.updateFoo = update$2; - Object.defineProperty(exports, '__esModule', { value: true }); - -}))); +})); diff --git a/test/form/samples/export-multiple-vars/_config.js b/test/form/samples/export-multiple-vars/_config.js index 6e8403586ac..23cf12deddd 100644 --- a/test/form/samples/export-multiple-vars/_config.js +++ b/test/form/samples/export-multiple-vars/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'splits up multiple vars in a single export declaration' -}; +}); diff --git a/test/form/samples/export-multiple-vars/_expected/amd.js b/test/form/samples/export-multiple-vars/_expected/amd.js index 37a26783c9a..80bffa19078 100644 --- a/test/form/samples/export-multiple-vars/_expected/amd.js +++ b/test/form/samples/export-multiple-vars/_expected/amd.js @@ -1,4 +1,4 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; var a = 1; @@ -10,4 +10,4 @@ define(function () { 'use strict'; assert.equal( e, 5 ); assert.equal( i, 9 ); -}); +})); diff --git a/test/form/samples/export-multiple-vars/_expected/iife.js b/test/form/samples/export-multiple-vars/_expected/iife.js index 2bc534b5352..f3ba61f9bf0 100644 --- a/test/form/samples/export-multiple-vars/_expected/iife.js +++ b/test/form/samples/export-multiple-vars/_expected/iife.js @@ -11,4 +11,4 @@ assert.equal( e, 5 ); assert.equal( i, 9 ); -}()); +})(); diff --git a/test/form/samples/export-multiple-vars/_expected/system.js b/test/form/samples/export-multiple-vars/_expected/system.js index bde10e4df6c..e56dc3842b3 100644 --- a/test/form/samples/export-multiple-vars/_expected/system.js +++ b/test/form/samples/export-multiple-vars/_expected/system.js @@ -1,7 +1,7 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { var a = 1; @@ -13,6 +13,6 @@ System.register([], function () { assert.equal( e, 5 ); assert.equal( i, 9 ); - } + }) }; -}); +})); diff --git a/test/form/samples/export-multiple-vars/_expected/umd.js b/test/form/samples/export-multiple-vars/_expected/umd.js index 83f49903e00..fb641304bf2 100644 --- a/test/form/samples/export-multiple-vars/_expected/umd.js +++ b/test/form/samples/export-multiple-vars/_expected/umd.js @@ -1,7 +1,7 @@ (function (factory) { typeof define === 'function' && define.amd ? define(factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; var a = 1; @@ -13,4 +13,4 @@ assert.equal( e, 5 ); assert.equal( i, 9 ); -}))); +})); diff --git a/test/form/samples/export-namespace-as/_config.js b/test/form/samples/export-namespace-as/_config.js index 81eb160f2ee..1020407da73 100644 --- a/test/form/samples/export-namespace-as/_config.js +++ b/test/form/samples/export-namespace-as/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'supports exporting namespaces as names in entry points', options: { output: { name: 'bundle' } } -}; +}); diff --git a/test/form/samples/export-namespace-as/_expected/amd.js b/test/form/samples/export-namespace-as/_expected/amd.js index 289423f76bc..fa390875abc 100644 --- a/test/form/samples/export-namespace-as/_expected/amd.js +++ b/test/form/samples/export-namespace-as/_expected/amd.js @@ -1,16 +1,14 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; const foo = 'foo1'; const bar = 'bar1'; var dep = /*#__PURE__*/Object.freeze({ __proto__: null, - foo: foo, - bar: bar + bar: bar, + foo: foo }); exports.dep = dep; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/form/samples/export-namespace-as/_expected/cjs.js b/test/form/samples/export-namespace-as/_expected/cjs.js index f4d06b1841a..fca07553f6d 100644 --- a/test/form/samples/export-namespace-as/_expected/cjs.js +++ b/test/form/samples/export-namespace-as/_expected/cjs.js @@ -1,14 +1,12 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - const foo = 'foo1'; const bar = 'bar1'; var dep = /*#__PURE__*/Object.freeze({ __proto__: null, - foo: foo, - bar: bar + bar: bar, + foo: foo }); exports.dep = dep; diff --git a/test/form/samples/export-namespace-as/_expected/es.js b/test/form/samples/export-namespace-as/_expected/es.js index 484e3a8e398..8f5baa54d0e 100644 --- a/test/form/samples/export-namespace-as/_expected/es.js +++ b/test/form/samples/export-namespace-as/_expected/es.js @@ -3,8 +3,8 @@ const bar = 'bar1'; var dep = /*#__PURE__*/Object.freeze({ __proto__: null, - foo: foo, - bar: bar + bar: bar, + foo: foo }); export { dep }; diff --git a/test/form/samples/export-namespace-as/_expected/iife.js b/test/form/samples/export-namespace-as/_expected/iife.js index 47b399d40d1..310c2851bf6 100644 --- a/test/form/samples/export-namespace-as/_expected/iife.js +++ b/test/form/samples/export-namespace-as/_expected/iife.js @@ -6,14 +6,12 @@ var bundle = (function (exports) { var dep = /*#__PURE__*/Object.freeze({ __proto__: null, - foo: foo, - bar: bar + bar: bar, + foo: foo }); exports.dep = dep; - Object.defineProperty(exports, '__esModule', { value: true }); - return exports; -}({})); +})({}); diff --git a/test/form/samples/export-namespace-as/_expected/system.js b/test/form/samples/export-namespace-as/_expected/system.js index e1e4e1c0131..546a2c07450 100644 --- a/test/form/samples/export-namespace-as/_expected/system.js +++ b/test/form/samples/export-namespace-as/_expected/system.js @@ -1,18 +1,18 @@ -System.register('bundle', [], function (exports) { +System.register('bundle', [], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { const foo = 'foo1'; const bar = 'bar1'; var dep = /*#__PURE__*/Object.freeze({ __proto__: null, - foo: foo, - bar: bar + bar: bar, + foo: foo }); - exports('dep', dep); + exports("dep", dep); - } + }) }; -}); +})); diff --git a/test/form/samples/export-namespace-as/_expected/umd.js b/test/form/samples/export-namespace-as/_expected/umd.js index a32e9ef17d4..384243f82c1 100644 --- a/test/form/samples/export-namespace-as/_expected/umd.js +++ b/test/form/samples/export-namespace-as/_expected/umd.js @@ -2,19 +2,17 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.bundle = {})); -}(this, (function (exports) { 'use strict'; +})(this, (function (exports) { 'use strict'; const foo = 'foo1'; const bar = 'bar1'; var dep = /*#__PURE__*/Object.freeze({ __proto__: null, - foo: foo, - bar: bar + bar: bar, + foo: foo }); exports.dep = dep; - Object.defineProperty(exports, '__esModule', { value: true }); - -}))); +})); diff --git a/test/form/samples/export-string-name/_config.js b/test/form/samples/export-string-name/_config.js new file mode 100644 index 00000000000..bcee7606de7 --- /dev/null +++ b/test/form/samples/export-string-name/_config.js @@ -0,0 +1,13 @@ +module.exports = defineTest({ + description: 'export string name', + options: { + external: ['x'], + output: { + externalLiveBindings: false, + globals: { + x: 'x' + }, + name: 'bundle' + } + } +}); diff --git a/test/form/samples/export-string-name/_expected/amd.js b/test/form/samples/export-string-name/_expected/amd.js new file mode 100644 index 00000000000..4d076f48df1 --- /dev/null +++ b/test/form/samples/export-string-name/_expected/amd.js @@ -0,0 +1,13 @@ +define(['exports', 'x'], (function (exports, x) { 'use strict'; + + const y = 1; + + function a () {} + function b () {} + + exports["'x"] = x.x; + exports["'a"] = a; + exports["'b"] = b; + exports["'y"] = y; + +})); diff --git a/test/form/samples/export-string-name/_expected/cjs.js b/test/form/samples/export-string-name/_expected/cjs.js new file mode 100644 index 00000000000..ea0769cd1e2 --- /dev/null +++ b/test/form/samples/export-string-name/_expected/cjs.js @@ -0,0 +1,13 @@ +'use strict'; + +var x = require('x'); + +const y = 1; + +function a () {} +function b () {} + +exports["'x"] = x.x; +exports["'a"] = a; +exports["'b"] = b; +exports["'y"] = y; diff --git a/test/form/samples/export-string-name/_expected/es.js b/test/form/samples/export-string-name/_expected/es.js new file mode 100644 index 00000000000..82c742fa4e3 --- /dev/null +++ b/test/form/samples/export-string-name/_expected/es.js @@ -0,0 +1,8 @@ +export { x as "'x" } from 'x'; + +const y = 1; + +function a () {} +function b () {} + +export { a as "'a", b as "'b", y as "'y" }; diff --git a/test/form/samples/export-string-name/_expected/iife.js b/test/form/samples/export-string-name/_expected/iife.js new file mode 100644 index 00000000000..318cf2a7408 --- /dev/null +++ b/test/form/samples/export-string-name/_expected/iife.js @@ -0,0 +1,16 @@ +var bundle = (function (exports, x) { + 'use strict'; + + const y = 1; + + function a () {} + function b () {} + + exports["'x"] = x.x; + exports["'a"] = a; + exports["'b"] = b; + exports["'y"] = y; + + return exports; + +})({}, x); diff --git a/test/form/samples/export-string-name/_expected/system.js b/test/form/samples/export-string-name/_expected/system.js new file mode 100644 index 00000000000..12c50985485 --- /dev/null +++ b/test/form/samples/export-string-name/_expected/system.js @@ -0,0 +1,21 @@ +System.register('bundle', ['x'], (function (exports) { + 'use strict'; + return { + setters: [function (module) { + exports("'x", module.x); + }], + execute: (function () { + + exports({ + "'a": a, + "'b": b + }); + + const y = exports("'y", 1); + + function a () {} + function b () {} + + }) + }; +})); diff --git a/test/form/samples/export-string-name/_expected/umd.js b/test/form/samples/export-string-name/_expected/umd.js new file mode 100644 index 00000000000..f44abd508e2 --- /dev/null +++ b/test/form/samples/export-string-name/_expected/umd.js @@ -0,0 +1,17 @@ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('x')) : + typeof define === 'function' && define.amd ? define(['exports', 'x'], factory) : + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.bundle = {}, global.x)); +})(this, (function (exports, x) { 'use strict'; + + const y = 1; + + function a () {} + function b () {} + + exports["'x"] = x.x; + exports["'a"] = a; + exports["'b"] = b; + exports["'y"] = y; + +})); diff --git a/test/form/samples/export-string-name/main.js b/test/form/samples/export-string-name/main.js new file mode 100644 index 00000000000..b976b71ebbd --- /dev/null +++ b/test/form/samples/export-string-name/main.js @@ -0,0 +1,8 @@ +export { x as "'x" } from 'x'; + +const y = 1; +export { y as "'y"}; + +function a () {} +function b () {} +export { a as "'a", b as "'b" }; diff --git a/test/form/samples/exported-class-declaration-conflict/_config.js b/test/form/samples/exported-class-declaration-conflict/_config.js new file mode 100644 index 00000000000..28937382c5b --- /dev/null +++ b/test/form/samples/exported-class-declaration-conflict/_config.js @@ -0,0 +1,4 @@ +module.exports = defineTest({ + description: 'handles exporting class declarations with name conflicts in SystemJS', + options: { output: { name: 'bundle' } } +}); diff --git a/test/form/samples/exported-class-declaration-conflict/_expected/amd.js b/test/form/samples/exported-class-declaration-conflict/_expected/amd.js new file mode 100644 index 00000000000..451650f9385 --- /dev/null +++ b/test/form/samples/exported-class-declaration-conflict/_expected/amd.js @@ -0,0 +1,10 @@ +define(['exports'], (function (exports) { 'use strict'; + + let Foo$1 = class Foo {}; + + class Foo {} + + exports.First = Foo$1; + exports.Second = Foo; + +})); diff --git a/test/form/samples/exported-class-declaration-conflict/_expected/cjs.js b/test/form/samples/exported-class-declaration-conflict/_expected/cjs.js new file mode 100644 index 00000000000..b78094b81ce --- /dev/null +++ b/test/form/samples/exported-class-declaration-conflict/_expected/cjs.js @@ -0,0 +1,8 @@ +'use strict'; + +let Foo$1 = class Foo {}; + +class Foo {} + +exports.First = Foo$1; +exports.Second = Foo; diff --git a/test/form/samples/exported-class-declaration-conflict/_expected/es.js b/test/form/samples/exported-class-declaration-conflict/_expected/es.js new file mode 100644 index 00000000000..e64a800dc17 --- /dev/null +++ b/test/form/samples/exported-class-declaration-conflict/_expected/es.js @@ -0,0 +1,5 @@ +let Foo$1 = class Foo {}; + +class Foo {} + +export { Foo$1 as First, Foo as Second }; diff --git a/test/form/samples/exported-class-declaration-conflict/_expected/iife.js b/test/form/samples/exported-class-declaration-conflict/_expected/iife.js new file mode 100644 index 00000000000..7e31b50ef39 --- /dev/null +++ b/test/form/samples/exported-class-declaration-conflict/_expected/iife.js @@ -0,0 +1,13 @@ +var bundle = (function (exports) { + 'use strict'; + + let Foo$1 = class Foo {}; + + class Foo {} + + exports.First = Foo$1; + exports.Second = Foo; + + return exports; + +})({}); diff --git a/test/form/samples/exported-class-declaration-conflict/_expected/system.js b/test/form/samples/exported-class-declaration-conflict/_expected/system.js new file mode 100644 index 00000000000..9fe245fab5d --- /dev/null +++ b/test/form/samples/exported-class-declaration-conflict/_expected/system.js @@ -0,0 +1,12 @@ +System.register('bundle', [], (function (exports) { + 'use strict'; + return { + execute: (function () { + + let Foo$1 = class Foo {}; exports("First", Foo$1); + + class Foo {} exports("Second", Foo); + + }) + }; +})); diff --git a/test/form/samples/exported-class-declaration-conflict/_expected/umd.js b/test/form/samples/exported-class-declaration-conflict/_expected/umd.js new file mode 100644 index 00000000000..a3e0900a821 --- /dev/null +++ b/test/form/samples/exported-class-declaration-conflict/_expected/umd.js @@ -0,0 +1,14 @@ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : + typeof define === 'function' && define.amd ? define(['exports'], factory) : + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.bundle = {})); +})(this, (function (exports) { 'use strict'; + + let Foo$1 = class Foo {}; + + class Foo {} + + exports.First = Foo$1; + exports.Second = Foo; + +})); diff --git a/test/form/samples/exported-class-declaration-conflict/first.js b/test/form/samples/exported-class-declaration-conflict/first.js new file mode 100644 index 00000000000..a5ae7c9e1cd --- /dev/null +++ b/test/form/samples/exported-class-declaration-conflict/first.js @@ -0,0 +1,2 @@ +class Foo {} +export { Foo }; diff --git a/test/form/samples/exported-class-declaration-conflict/main.js b/test/form/samples/exported-class-declaration-conflict/main.js new file mode 100644 index 00000000000..dc165351514 --- /dev/null +++ b/test/form/samples/exported-class-declaration-conflict/main.js @@ -0,0 +1,2 @@ +export { Foo as First } from './first'; +export { Foo as Second } from './second'; diff --git a/test/form/samples/exported-class-declaration-conflict/second.js b/test/form/samples/exported-class-declaration-conflict/second.js new file mode 100644 index 00000000000..a5ae7c9e1cd --- /dev/null +++ b/test/form/samples/exported-class-declaration-conflict/second.js @@ -0,0 +1,2 @@ +class Foo {} +export { Foo }; diff --git a/test/form/samples/exports-at-end-if-possible/_config.js b/test/form/samples/exports-at-end-if-possible/_config.js index 7399d554c73..d7c16115fa6 100644 --- a/test/form/samples/exports-at-end-if-possible/_config.js +++ b/test/form/samples/exports-at-end-if-possible/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'exports variables at end, if possible', options: { output: { name: 'myBundle' } } -}; +}); diff --git a/test/form/samples/exports-at-end-if-possible/_expected/amd.js b/test/form/samples/exports-at-end-if-possible/_expected/amd.js index 7138aff3dcf..9bf1231a7b7 100644 --- a/test/form/samples/exports-at-end-if-possible/_expected/amd.js +++ b/test/form/samples/exports-at-end-if-possible/_expected/amd.js @@ -1,4 +1,4 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; var FOO = 'foo'; @@ -8,6 +8,4 @@ define(['exports'], function (exports) { 'use strict'; exports.FOO = FOO; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/form/samples/exports-at-end-if-possible/_expected/cjs.js b/test/form/samples/exports-at-end-if-possible/_expected/cjs.js index f62037c89b9..57d55d3cb81 100644 --- a/test/form/samples/exports-at-end-if-possible/_expected/cjs.js +++ b/test/form/samples/exports-at-end-if-possible/_expected/cjs.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - var FOO = 'foo'; console.log( FOO ); diff --git a/test/form/samples/exports-at-end-if-possible/_expected/iife.js b/test/form/samples/exports-at-end-if-possible/_expected/iife.js index e38bd7d01b3..81f75f465ed 100644 --- a/test/form/samples/exports-at-end-if-possible/_expected/iife.js +++ b/test/form/samples/exports-at-end-if-possible/_expected/iife.js @@ -9,8 +9,6 @@ var myBundle = (function (exports) { exports.FOO = FOO; - Object.defineProperty(exports, '__esModule', { value: true }); - return exports; -}({})); +})({}); diff --git a/test/form/samples/exports-at-end-if-possible/_expected/system.js b/test/form/samples/exports-at-end-if-possible/_expected/system.js index 22213a19860..c494de54a4e 100644 --- a/test/form/samples/exports-at-end-if-possible/_expected/system.js +++ b/test/form/samples/exports-at-end-if-possible/_expected/system.js @@ -1,14 +1,14 @@ -System.register('myBundle', [], function (exports) { +System.register('myBundle', [], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - var FOO = exports('FOO', 'foo'); + var FOO = exports("FOO", 'foo'); console.log( FOO ); console.log( FOO ); console.log( FOO ); - } + }) }; -}); +})); diff --git a/test/form/samples/exports-at-end-if-possible/_expected/umd.js b/test/form/samples/exports-at-end-if-possible/_expected/umd.js index 7caa83aa1f3..b9ae739b3b7 100644 --- a/test/form/samples/exports-at-end-if-possible/_expected/umd.js +++ b/test/form/samples/exports-at-end-if-possible/_expected/umd.js @@ -2,7 +2,7 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.myBundle = {})); -}(this, (function (exports) { 'use strict'; +})(this, (function (exports) { 'use strict'; var FOO = 'foo'; @@ -12,6 +12,4 @@ exports.FOO = FOO; - Object.defineProperty(exports, '__esModule', { value: true }); - -}))); +})); diff --git a/test/form/samples/extend-exports/_config.js b/test/form/samples/extend-exports/_config.js index b2f3aac6c76..de6f96f242f 100644 --- a/test/form/samples/extend-exports/_config.js +++ b/test/form/samples/extend-exports/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'extends module correctly', options: { output: { @@ -6,4 +6,4 @@ module.exports = { name: 'foo' } } -}; +}); diff --git a/test/form/samples/extend-exports/_expected/amd.js b/test/form/samples/extend-exports/_expected/amd.js index 8e845b5433b..abf361b15be 100644 --- a/test/form/samples/extend-exports/_expected/amd.js +++ b/test/form/samples/extend-exports/_expected/amd.js @@ -1,9 +1,7 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; const answer = 42; exports.answer = answer; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/form/samples/extend-exports/_expected/cjs.js b/test/form/samples/extend-exports/_expected/cjs.js index 316e49a5c1b..94b8c7ce11f 100644 --- a/test/form/samples/extend-exports/_expected/cjs.js +++ b/test/form/samples/extend-exports/_expected/cjs.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - const answer = 42; exports.answer = answer; diff --git a/test/form/samples/extend-exports/_expected/iife.js b/test/form/samples/extend-exports/_expected/iife.js index 99010aa0213..ad53d6c41f6 100644 --- a/test/form/samples/extend-exports/_expected/iife.js +++ b/test/form/samples/extend-exports/_expected/iife.js @@ -5,6 +5,4 @@ exports.answer = answer; - Object.defineProperty(exports, '__esModule', { value: true }); - -}(this.foo = this.foo || {})); +})(this.foo = this.foo || {}); diff --git a/test/form/samples/extend-exports/_expected/system.js b/test/form/samples/extend-exports/_expected/system.js index c6f5464d013..22627011dce 100644 --- a/test/form/samples/extend-exports/_expected/system.js +++ b/test/form/samples/extend-exports/_expected/system.js @@ -1,10 +1,10 @@ -System.register('foo', [], function (exports) { +System.register('foo', [], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - const answer = exports('answer', 42); + const answer = exports("answer", 42); - } + }) }; -}); +})); diff --git a/test/form/samples/extend-exports/_expected/umd.js b/test/form/samples/extend-exports/_expected/umd.js index 8bdb1ef5e5a..853481054c3 100644 --- a/test/form/samples/extend-exports/_expected/umd.js +++ b/test/form/samples/extend-exports/_expected/umd.js @@ -2,12 +2,10 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.foo = global.foo || {})); -}(this, (function (exports) { 'use strict'; +})(this, (function (exports) { 'use strict'; const answer = 42; exports.answer = answer; - Object.defineProperty(exports, '__esModule', { value: true }); - -}))); +})); diff --git a/test/form/samples/extend-namespaced-exports/_config.js b/test/form/samples/extend-namespaced-exports/_config.js index eece0816e6b..f8d9407c1bf 100644 --- a/test/form/samples/extend-namespaced-exports/_config.js +++ b/test/form/samples/extend-namespaced-exports/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'extends namespaced module name', options: { output: { @@ -6,4 +6,4 @@ module.exports = { name: 'foo.bar.baz' } } -}; +}); diff --git a/test/form/samples/extend-namespaced-exports/_expected/amd.js b/test/form/samples/extend-namespaced-exports/_expected/amd.js index 8e845b5433b..abf361b15be 100644 --- a/test/form/samples/extend-namespaced-exports/_expected/amd.js +++ b/test/form/samples/extend-namespaced-exports/_expected/amd.js @@ -1,9 +1,7 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; const answer = 42; exports.answer = answer; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/form/samples/extend-namespaced-exports/_expected/cjs.js b/test/form/samples/extend-namespaced-exports/_expected/cjs.js index 316e49a5c1b..94b8c7ce11f 100644 --- a/test/form/samples/extend-namespaced-exports/_expected/cjs.js +++ b/test/form/samples/extend-namespaced-exports/_expected/cjs.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - const answer = 42; exports.answer = answer; diff --git a/test/form/samples/extend-namespaced-exports/_expected/iife.js b/test/form/samples/extend-namespaced-exports/_expected/iife.js index a32a30b5257..76ebf3dc5dd 100644 --- a/test/form/samples/extend-namespaced-exports/_expected/iife.js +++ b/test/form/samples/extend-namespaced-exports/_expected/iife.js @@ -7,6 +7,4 @@ this.foo.bar = this.foo.bar || {}; exports.answer = answer; - Object.defineProperty(exports, '__esModule', { value: true }); - -}(this.foo.bar.baz = this.foo.bar.baz || {})); +})(this.foo.bar.baz = this.foo.bar.baz || {}); diff --git a/test/form/samples/extend-namespaced-exports/_expected/system.js b/test/form/samples/extend-namespaced-exports/_expected/system.js index b9ad7297724..20352fdc680 100644 --- a/test/form/samples/extend-namespaced-exports/_expected/system.js +++ b/test/form/samples/extend-namespaced-exports/_expected/system.js @@ -1,10 +1,10 @@ -System.register('foo.bar.baz', [], function (exports) { +System.register('foo.bar.baz', [], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - const answer = exports('answer', 42); + const answer = exports("answer", 42); - } + }) }; -}); +})); diff --git a/test/form/samples/extend-namespaced-exports/_expected/umd.js b/test/form/samples/extend-namespaced-exports/_expected/umd.js index 5723cec509f..7e77624dadb 100644 --- a/test/form/samples/extend-namespaced-exports/_expected/umd.js +++ b/test/form/samples/extend-namespaced-exports/_expected/umd.js @@ -2,12 +2,10 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.foo = global.foo || {}, global.foo.bar = global.foo.bar || {}, global.foo.bar.baz = global.foo.bar.baz || {}))); -}(this, (function (exports) { 'use strict'; +})(this, (function (exports) { 'use strict'; const answer = 42; exports.answer = answer; - Object.defineProperty(exports, '__esModule', { value: true }); - -}))); +})); diff --git a/test/form/samples/external-deshadowing/_config.js b/test/form/samples/external-deshadowing/_config.js index d46d28e9e6c..944fd4e0b94 100644 --- a/test/form/samples/external-deshadowing/_config.js +++ b/test/form/samples/external-deshadowing/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'Externals aliases with deshadowing', options: { external: ['a', 'b'], @@ -7,4 +7,4 @@ module.exports = { name: 'myBundle' } } -}; +}); diff --git a/test/form/samples/external-deshadowing/_expected/amd.js b/test/form/samples/external-deshadowing/_expected/amd.js index 562eefc8d31..122452ecd6f 100644 --- a/test/form/samples/external-deshadowing/_expected/amd.js +++ b/test/form/samples/external-deshadowing/_expected/amd.js @@ -1,20 +1,14 @@ -define(['exports', 'a', 'b'], function (exports, a, Test$1) { 'use strict'; - - function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } - - var Test__default = /*#__PURE__*/_interopDefaultLegacy(Test$1); +define(['exports', 'a', 'b'], (function (exports, a, Test$1) { 'use strict'; const Test = () => { console.log(a.Test); }; const Test1 = () => { - console.log(Test__default['default']); + console.log(Test$1); }; exports.Test = Test; exports.Test1 = Test1; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/form/samples/external-deshadowing/_expected/cjs.js b/test/form/samples/external-deshadowing/_expected/cjs.js index 7bb98d46f4c..9f00f05c1a9 100644 --- a/test/form/samples/external-deshadowing/_expected/cjs.js +++ b/test/form/samples/external-deshadowing/_expected/cjs.js @@ -1,20 +1,14 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - var a = require('a'); var Test$1 = require('b'); -function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } - -var Test__default = /*#__PURE__*/_interopDefaultLegacy(Test$1); - const Test = () => { console.log(a.Test); }; const Test1 = () => { - console.log(Test__default['default']); + console.log(Test$1); }; exports.Test = Test; diff --git a/test/form/samples/external-deshadowing/_expected/iife.js b/test/form/samples/external-deshadowing/_expected/iife.js index 76f082e94cd..a201360e0ee 100644 --- a/test/form/samples/external-deshadowing/_expected/iife.js +++ b/test/form/samples/external-deshadowing/_expected/iife.js @@ -1,23 +1,17 @@ var myBundle = (function (exports, a, Test$1) { 'use strict'; - function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } - - var Test__default = /*#__PURE__*/_interopDefaultLegacy(Test$1); - const Test = () => { console.log(a.Test); }; const Test1 = () => { - console.log(Test__default['default']); + console.log(Test$1); }; exports.Test = Test; exports.Test1 = Test1; - Object.defineProperty(exports, '__esModule', { value: true }); - return exports; -}({}, a, b)); +})({}, a, b); diff --git a/test/form/samples/external-deshadowing/_expected/system.js b/test/form/samples/external-deshadowing/_expected/system.js index d4ffc8320ac..8a6ce3c1d1f 100644 --- a/test/form/samples/external-deshadowing/_expected/system.js +++ b/test/form/samples/external-deshadowing/_expected/system.js @@ -1,4 +1,4 @@ -System.register('myBundle', ['a', 'b'], function (exports) { +System.register('myBundle', ['a', 'b'], (function (exports) { 'use strict'; var Test$1, Test$2; return { @@ -7,16 +7,16 @@ System.register('myBundle', ['a', 'b'], function (exports) { }, function (module) { Test$2 = module.default; }], - execute: function () { + execute: (function () { - const Test = exports('Test', () => { + const Test = exports("Test", () => { console.log(Test$1); }); - const Test1 = exports('Test1', () => { + const Test1 = exports("Test1", () => { console.log(Test$2); }); - } + }) }; -}); +})); diff --git a/test/form/samples/external-deshadowing/_expected/umd.js b/test/form/samples/external-deshadowing/_expected/umd.js index 6c1b57796f8..98eb524c2df 100644 --- a/test/form/samples/external-deshadowing/_expected/umd.js +++ b/test/form/samples/external-deshadowing/_expected/umd.js @@ -2,23 +2,17 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('a'), require('b')) : typeof define === 'function' && define.amd ? define(['exports', 'a', 'b'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.myBundle = {}, global.a, global.b)); -}(this, (function (exports, a, Test$1) { 'use strict'; - - function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } - - var Test__default = /*#__PURE__*/_interopDefaultLegacy(Test$1); +})(this, (function (exports, a, Test$1) { 'use strict'; const Test = () => { console.log(a.Test); }; const Test1 = () => { - console.log(Test__default['default']); + console.log(Test$1); }; exports.Test = Test; exports.Test1 = Test1; - Object.defineProperty(exports, '__esModule', { value: true }); - -}))); +})); diff --git a/test/form/samples/external-empty-import-no-global-b/_config.js b/test/form/samples/external-empty-import-no-global-b/_config.js index 531386bd5b6..dc9e9b1cb4d 100644 --- a/test/form/samples/external-empty-import-no-global-b/_config.js +++ b/test/form/samples/external-empty-import-no-global-b/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'does not expect a global to be provided for empty imports (#1217)', options: { external: ['babel-polyfill', 'other'], @@ -10,4 +10,4 @@ module.exports = { globals: { other: 'other' } } } -}; +}); diff --git a/test/form/samples/external-empty-import-no-global-b/_expected/amd.js b/test/form/samples/external-empty-import-no-global-b/_expected/amd.js index 1881f360160..a49da482adc 100644 --- a/test/form/samples/external-empty-import-no-global-b/_expected/amd.js +++ b/test/form/samples/external-empty-import-no-global-b/_expected/amd.js @@ -1,4 +1,4 @@ -define(['babel-polyfill', 'other'], function (babelPolyfill, other) { 'use strict'; +define(['babel-polyfill', 'other'], (function (babelPolyfill, other) { 'use strict'; other.x(); @@ -6,4 +6,4 @@ define(['babel-polyfill', 'other'], function (babelPolyfill, other) { 'use stric return main; -}); +})); diff --git a/test/form/samples/external-empty-import-no-global-b/_expected/es.js b/test/form/samples/external-empty-import-no-global-b/_expected/es.js index 6c29fd8c045..106fcf0c2db 100644 --- a/test/form/samples/external-empty-import-no-global-b/_expected/es.js +++ b/test/form/samples/external-empty-import-no-global-b/_expected/es.js @@ -5,4 +5,4 @@ x(); var main = new WeakMap(); -export default main; +export { main as default }; diff --git a/test/form/samples/external-empty-import-no-global-b/_expected/iife.js b/test/form/samples/external-empty-import-no-global-b/_expected/iife.js index f0f77a3c473..b9b1e92fd52 100644 --- a/test/form/samples/external-empty-import-no-global-b/_expected/iife.js +++ b/test/form/samples/external-empty-import-no-global-b/_expected/iife.js @@ -7,4 +7,4 @@ var myBundle = (function (babelPolyfill, other) { return main; -}(null, other)); +})(null, other); diff --git a/test/form/samples/external-empty-import-no-global-b/_expected/system.js b/test/form/samples/external-empty-import-no-global-b/_expected/system.js index 81d11c022f8..061a4256635 100644 --- a/test/form/samples/external-empty-import-no-global-b/_expected/system.js +++ b/test/form/samples/external-empty-import-no-global-b/_expected/system.js @@ -1,16 +1,16 @@ -System.register('myBundle', ['babel-polyfill', 'other'], function (exports) { +System.register('myBundle', ['babel-polyfill', 'other'], (function (exports) { 'use strict'; var x; return { - setters: [function () {}, function (module) { + setters: [null, function (module) { x = module.x; }], - execute: function () { + execute: (function () { x(); - var main = exports('default', new WeakMap()); + var main = exports("default", new WeakMap()); - } + }) }; -}); +})); diff --git a/test/form/samples/external-empty-import-no-global-b/_expected/umd.js b/test/form/samples/external-empty-import-no-global-b/_expected/umd.js index 2e717783832..e361ffd357e 100644 --- a/test/form/samples/external-empty-import-no-global-b/_expected/umd.js +++ b/test/form/samples/external-empty-import-no-global-b/_expected/umd.js @@ -2,7 +2,7 @@ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('babel-polyfill'), require('other')) : typeof define === 'function' && define.amd ? define(['babel-polyfill', 'other'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.myBundle = factory(null, global.other)); -}(this, (function (babelPolyfill, other) { 'use strict'; +})(this, (function (babelPolyfill, other) { 'use strict'; other.x(); @@ -10,4 +10,4 @@ return main; -}))); +})); diff --git a/test/form/samples/external-empty-import-no-global/_config.js b/test/form/samples/external-empty-import-no-global/_config.js index 8895d91054e..9070629e0b0 100644 --- a/test/form/samples/external-empty-import-no-global/_config.js +++ b/test/form/samples/external-empty-import-no-global/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'does not expect a global to be provided for empty imports (#1217)', options: { external: ['babel-polyfill'], @@ -9,4 +9,4 @@ module.exports = { name: 'myBundle' } } -}; +}); diff --git a/test/form/samples/external-empty-import-no-global/_expected/amd.js b/test/form/samples/external-empty-import-no-global/_expected/amd.js index a54a8285ee1..871015b77b4 100644 --- a/test/form/samples/external-empty-import-no-global/_expected/amd.js +++ b/test/form/samples/external-empty-import-no-global/_expected/amd.js @@ -1,7 +1,7 @@ -define(['babel-polyfill'], function (babelPolyfill) { 'use strict'; +define(['babel-polyfill'], (function (babelPolyfill) { 'use strict'; var main = new WeakMap(); return main; -}); +})); diff --git a/test/form/samples/external-empty-import-no-global/_expected/es.js b/test/form/samples/external-empty-import-no-global/_expected/es.js index 7ac0688f155..67622e85cd7 100644 --- a/test/form/samples/external-empty-import-no-global/_expected/es.js +++ b/test/form/samples/external-empty-import-no-global/_expected/es.js @@ -2,4 +2,4 @@ import 'babel-polyfill'; var main = new WeakMap(); -export default main; +export { main as default }; diff --git a/test/form/samples/external-empty-import-no-global/_expected/iife.js b/test/form/samples/external-empty-import-no-global/_expected/iife.js index 02b6db6bbcf..00adedc97a9 100644 --- a/test/form/samples/external-empty-import-no-global/_expected/iife.js +++ b/test/form/samples/external-empty-import-no-global/_expected/iife.js @@ -5,4 +5,4 @@ var myBundle = (function () { return main; -}()); +})(); diff --git a/test/form/samples/external-empty-import-no-global/_expected/system.js b/test/form/samples/external-empty-import-no-global/_expected/system.js index f1c91387b3c..0dfcecd97e0 100644 --- a/test/form/samples/external-empty-import-no-global/_expected/system.js +++ b/test/form/samples/external-empty-import-no-global/_expected/system.js @@ -1,11 +1,11 @@ -System.register('myBundle', ['babel-polyfill'], function (exports) { +System.register('myBundle', ['babel-polyfill'], (function (exports) { 'use strict'; return { - setters: [function () {}], - execute: function () { + setters: [null], + execute: (function () { - var main = exports('default', new WeakMap()); + var main = exports("default", new WeakMap()); - } + }) }; -}); +})); diff --git a/test/form/samples/external-empty-import-no-global/_expected/umd.js b/test/form/samples/external-empty-import-no-global/_expected/umd.js index 591772afb13..c1aa940c137 100644 --- a/test/form/samples/external-empty-import-no-global/_expected/umd.js +++ b/test/form/samples/external-empty-import-no-global/_expected/umd.js @@ -2,10 +2,10 @@ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('babel-polyfill')) : typeof define === 'function' && define.amd ? define(['babel-polyfill'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.myBundle = factory()); -}(this, (function () { 'use strict'; +})(this, (function () { 'use strict'; var main = new WeakMap(); return main; -}))); +})); diff --git a/test/form/samples/external-export-tracing/_config.js b/test/form/samples/external-export-tracing/_config.js index f4140c4ed86..734f88b588f 100644 --- a/test/form/samples/external-export-tracing/_config.js +++ b/test/form/samples/external-export-tracing/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'Support external namespace reexport', options: { external: ['external'], @@ -7,4 +7,4 @@ module.exports = { name: 'myBundle' } } -}; +}); diff --git a/test/form/samples/external-export-tracing/_expected/amd.js b/test/form/samples/external-export-tracing/_expected/amd.js index 3feb4663adc..2e15f43d910 100644 --- a/test/form/samples/external-export-tracing/_expected/amd.js +++ b/test/form/samples/external-export-tracing/_expected/amd.js @@ -1,14 +1,10 @@ -define(['exports', 'external'], function (exports, external) { 'use strict'; +define(['exports', 'external'], (function (exports, external) { 'use strict'; - Object.defineProperty(exports, 's', { + Object.defineProperty(exports, "s", { enumerable: true, - get: function () { - return external.p; - } + get: function () { return external.p; } }); - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/form/samples/external-export-tracing/_expected/cjs.js b/test/form/samples/external-export-tracing/_expected/cjs.js index 90e80982b1c..21eb1aba951 100644 --- a/test/form/samples/external-export-tracing/_expected/cjs.js +++ b/test/form/samples/external-export-tracing/_expected/cjs.js @@ -1,14 +1,10 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - var external = require('external'); -Object.defineProperty(exports, 's', { +Object.defineProperty(exports, "s", { enumerable: true, - get: function () { - return external.p; - } + get: function () { return external.p; } }); diff --git a/test/form/samples/external-export-tracing/_expected/iife.js b/test/form/samples/external-export-tracing/_expected/iife.js index 003e55a49c2..7da1baf9925 100644 --- a/test/form/samples/external-export-tracing/_expected/iife.js +++ b/test/form/samples/external-export-tracing/_expected/iife.js @@ -3,15 +3,11 @@ var myBundle = (function (exports, external) { - Object.defineProperty(exports, 's', { + Object.defineProperty(exports, "s", { enumerable: true, - get: function () { - return external.p; - } + get: function () { return external.p; } }); - Object.defineProperty(exports, '__esModule', { value: true }); - return exports; -}({}, external)); +})({}, external); diff --git a/test/form/samples/external-export-tracing/_expected/system.js b/test/form/samples/external-export-tracing/_expected/system.js index d19d560effd..e9229997b0a 100644 --- a/test/form/samples/external-export-tracing/_expected/system.js +++ b/test/form/samples/external-export-tracing/_expected/system.js @@ -1,13 +1,13 @@ -System.register('myBundle', ['external'], function (exports) { +System.register('myBundle', ['external'], (function (exports) { 'use strict'; return { setters: [function (module) { - exports('s', module.p); + exports("s", module.p); }], - execute: function () { + execute: (function () { - } + }) }; -}); +})); diff --git a/test/form/samples/external-export-tracing/_expected/umd.js b/test/form/samples/external-export-tracing/_expected/umd.js index cb2447cda1a..925ebce93d7 100644 --- a/test/form/samples/external-export-tracing/_expected/umd.js +++ b/test/form/samples/external-export-tracing/_expected/umd.js @@ -2,15 +2,11 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('external')) : typeof define === 'function' && define.amd ? define(['exports', 'external'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.myBundle = {}, global.external)); -}(this, (function (exports, external) { 'use strict'; +})(this, (function (exports, external) { 'use strict'; - Object.defineProperty(exports, 's', { + Object.defineProperty(exports, "s", { enumerable: true, - get: function () { - return external.p; - } + get: function () { return external.p; } }); - Object.defineProperty(exports, '__esModule', { value: true }); - -}))); +})); diff --git a/test/form/samples/external-import-alias-shadow/_config.js b/test/form/samples/external-import-alias-shadow/_config.js index acc8ed78eb7..5d95e9b1ea0 100644 --- a/test/form/samples/external-import-alias-shadow/_config.js +++ b/test/form/samples/external-import-alias-shadow/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'handles external aliased named imports that shadow another name', options: { external: ['acorn'], @@ -6,4 +6,4 @@ module.exports = { globals: { acorn: 'acorn' } } } -}; +}); diff --git a/test/form/samples/external-import-alias-shadow/_expected/amd.js b/test/form/samples/external-import-alias-shadow/_expected/amd.js index c2c8da9d170..afdbb9bd578 100644 --- a/test/form/samples/external-import-alias-shadow/_expected/amd.js +++ b/test/form/samples/external-import-alias-shadow/_expected/amd.js @@ -1,4 +1,4 @@ -define(['acorn'], function (acorn) { 'use strict'; +define(['acorn'], (function (acorn) { 'use strict'; function parse(source) { return acorn.parse(source, { ecmaVersion: 6 }); @@ -6,4 +6,4 @@ define(['acorn'], function (acorn) { 'use strict'; console.log(parse('foo')); -}); +})); diff --git a/test/form/samples/external-import-alias-shadow/_expected/iife.js b/test/form/samples/external-import-alias-shadow/_expected/iife.js index 22334d72437..0e1e67ca291 100644 --- a/test/form/samples/external-import-alias-shadow/_expected/iife.js +++ b/test/form/samples/external-import-alias-shadow/_expected/iife.js @@ -7,4 +7,4 @@ console.log(parse('foo')); -}(acorn)); +})(acorn); diff --git a/test/form/samples/external-import-alias-shadow/_expected/system.js b/test/form/samples/external-import-alias-shadow/_expected/system.js index 9f2513b2175..176ff3d7dbf 100644 --- a/test/form/samples/external-import-alias-shadow/_expected/system.js +++ b/test/form/samples/external-import-alias-shadow/_expected/system.js @@ -1,11 +1,11 @@ -System.register(['acorn'], function () { +System.register(['acorn'], (function () { 'use strict'; var parse$1; return { setters: [function (module) { parse$1 = module.parse; }], - execute: function () { + execute: (function () { function parse(source) { return parse$1(source, { ecmaVersion: 6 }); @@ -13,6 +13,6 @@ System.register(['acorn'], function () { console.log(parse('foo')); - } + }) }; -}); +})); diff --git a/test/form/samples/external-import-alias-shadow/_expected/umd.js b/test/form/samples/external-import-alias-shadow/_expected/umd.js index 1a0eaf0cf5c..0873a02e336 100644 --- a/test/form/samples/external-import-alias-shadow/_expected/umd.js +++ b/test/form/samples/external-import-alias-shadow/_expected/umd.js @@ -2,7 +2,7 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('acorn')) : typeof define === 'function' && define.amd ? define(['acorn'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.acorn)); -}(this, (function (acorn) { 'use strict'; +})(this, (function (acorn) { 'use strict'; function parse(source) { return acorn.parse(source, { ecmaVersion: 6 }); @@ -10,4 +10,4 @@ console.log(parse('foo')); -}))); +})); diff --git a/test/form/samples/external-import-order/_config.js b/test/form/samples/external-import-order/_config.js index d35e42d0265..eccb2fe28d0 100644 --- a/test/form/samples/external-import-order/_config.js +++ b/test/form/samples/external-import-order/_config.js @@ -1,8 +1,8 @@ -module.exports = { +module.exports = defineTest({ description: 'Retain the execution order of external imports', options: { external(id) { return id.startsWith('external'); } } -}; +}); diff --git a/test/form/samples/external-imports-custom-names-function/_config.js b/test/form/samples/external-imports-custom-names-function/_config.js index 188a8841c56..68aafe26bb4 100644 --- a/test/form/samples/external-imports-custom-names-function/_config.js +++ b/test/form/samples/external-imports-custom-names-function/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'allows globals to be specified as a function', options: { external: ['a-b-c'], @@ -8,4 +8,4 @@ module.exports = { } } } -}; +}); diff --git a/test/form/samples/external-imports-custom-names-function/_expected/amd.js b/test/form/samples/external-imports-custom-names-function/_expected/amd.js index bc3f1b57e05..4cad3d08183 100644 --- a/test/form/samples/external-imports-custom-names-function/_expected/amd.js +++ b/test/form/samples/external-imports-custom-names-function/_expected/amd.js @@ -1,5 +1,5 @@ -define(['a-b-c'], function (aBC) { 'use strict'; +define(['a-b-c'], (function (aBC) { 'use strict'; aBC.foo(); -}); +})); diff --git a/test/form/samples/external-imports-custom-names-function/_expected/iife.js b/test/form/samples/external-imports-custom-names-function/_expected/iife.js index 7618f149095..67641e975b0 100644 --- a/test/form/samples/external-imports-custom-names-function/_expected/iife.js +++ b/test/form/samples/external-imports-custom-names-function/_expected/iife.js @@ -3,4 +3,4 @@ aBC.foo(); -}(a_b_c)); +})(a_b_c); diff --git a/test/form/samples/external-imports-custom-names-function/_expected/system.js b/test/form/samples/external-imports-custom-names-function/_expected/system.js index fcea6a8ddd1..1143e473ecf 100644 --- a/test/form/samples/external-imports-custom-names-function/_expected/system.js +++ b/test/form/samples/external-imports-custom-names-function/_expected/system.js @@ -1,14 +1,14 @@ -System.register(['a-b-c'], function () { +System.register(['a-b-c'], (function () { 'use strict'; var foo; return { setters: [function (module) { foo = module.foo; }], - execute: function () { + execute: (function () { foo(); - } + }) }; -}); +})); diff --git a/test/form/samples/external-imports-custom-names-function/_expected/umd.js b/test/form/samples/external-imports-custom-names-function/_expected/umd.js index 13eb618cd86..9efed3d496e 100644 --- a/test/form/samples/external-imports-custom-names-function/_expected/umd.js +++ b/test/form/samples/external-imports-custom-names-function/_expected/umd.js @@ -2,8 +2,8 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('a-b-c')) : typeof define === 'function' && define.amd ? define(['a-b-c'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.a_b_c)); -}(this, (function (aBC) { 'use strict'; +})(this, (function (aBC) { 'use strict'; aBC.foo(); -}))); +})); diff --git a/test/form/samples/external-imports-custom-names/_config.js b/test/form/samples/external-imports-custom-names/_config.js index f614da0d314..c047d627307 100644 --- a/test/form/samples/external-imports-custom-names/_config.js +++ b/test/form/samples/external-imports-custom-names/_config.js @@ -1,7 +1,7 @@ -module.exports = { +module.exports = defineTest({ description: 'allows global names to be specified for IIFE/UMD exports', options: { external: ['jquery'], output: { globals: { jquery: 'jQuery' } } } -}; +}); diff --git a/test/form/samples/external-imports-custom-names/_expected/amd.js b/test/form/samples/external-imports-custom-names/_expected/amd.js index 0a219ce968d..624cea58dd0 100644 --- a/test/form/samples/external-imports-custom-names/_expected/amd.js +++ b/test/form/samples/external-imports-custom-names/_expected/amd.js @@ -1,11 +1,7 @@ -define(['jquery'], function ($) { 'use strict'; +define(['jquery'], (function ($) { 'use strict'; - function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } - - var $__default = /*#__PURE__*/_interopDefaultLegacy($); - - $__default['default']( function () { - $__default['default']( 'body' ).html( '

hello world!

' ); + $( function () { + $( 'body' ).html( '

hello world!

' ); }); -}); +})); diff --git a/test/form/samples/external-imports-custom-names/_expected/cjs.js b/test/form/samples/external-imports-custom-names/_expected/cjs.js index 28f51051717..f9889a5926e 100644 --- a/test/form/samples/external-imports-custom-names/_expected/cjs.js +++ b/test/form/samples/external-imports-custom-names/_expected/cjs.js @@ -2,10 +2,6 @@ var $ = require('jquery'); -function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } - -var $__default = /*#__PURE__*/_interopDefaultLegacy($); - -$__default['default']( function () { - $__default['default']( 'body' ).html( '

hello world!

' ); +$( function () { + $( 'body' ).html( '

hello world!

' ); }); diff --git a/test/form/samples/external-imports-custom-names/_expected/iife.js b/test/form/samples/external-imports-custom-names/_expected/iife.js index 5616022b3cb..a7957b8efa2 100644 --- a/test/form/samples/external-imports-custom-names/_expected/iife.js +++ b/test/form/samples/external-imports-custom-names/_expected/iife.js @@ -1,12 +1,8 @@ (function ($) { 'use strict'; - function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } - - var $__default = /*#__PURE__*/_interopDefaultLegacy($); - - $__default['default']( function () { - $__default['default']( 'body' ).html( '

hello world!

' ); + $( function () { + $( 'body' ).html( '

hello world!

' ); }); -}(jQuery)); +})(jQuery); diff --git a/test/form/samples/external-imports-custom-names/_expected/system.js b/test/form/samples/external-imports-custom-names/_expected/system.js index 578940cdf31..257755c0dc3 100644 --- a/test/form/samples/external-imports-custom-names/_expected/system.js +++ b/test/form/samples/external-imports-custom-names/_expected/system.js @@ -1,16 +1,16 @@ -System.register(['jquery'], function () { +System.register(['jquery'], (function () { 'use strict'; var $; return { setters: [function (module) { $ = module.default; }], - execute: function () { + execute: (function () { $( function () { $( 'body' ).html( '

hello world!

' ); }); - } + }) }; -}); +})); diff --git a/test/form/samples/external-imports-custom-names/_expected/umd.js b/test/form/samples/external-imports-custom-names/_expected/umd.js index 51cdb789467..5c76e5cfc63 100644 --- a/test/form/samples/external-imports-custom-names/_expected/umd.js +++ b/test/form/samples/external-imports-custom-names/_expected/umd.js @@ -2,14 +2,10 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('jquery')) : typeof define === 'function' && define.amd ? define(['jquery'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.jQuery)); -}(this, (function ($) { 'use strict'; +})(this, (function ($) { 'use strict'; - function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } - - var $__default = /*#__PURE__*/_interopDefaultLegacy($); - - $__default['default']( function () { - $__default['default']( 'body' ).html( '

hello world!

' ); + $( function () { + $( 'body' ).html( '

hello world!

' ); }); -}))); +})); diff --git a/test/form/samples/external-imports/_config.js b/test/form/samples/external-imports/_config.js index 46cde903266..c1bd02260f1 100644 --- a/test/form/samples/external-imports/_config.js +++ b/test/form/samples/external-imports/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'prefixes global names with `global.` when creating UMD bundle (#57)', expectedWarnings: ['UNUSED_EXTERNAL_IMPORT'], options: { @@ -12,4 +12,4 @@ module.exports = { } } } -}; +}); diff --git a/test/form/samples/external-imports/_expected/amd.js b/test/form/samples/external-imports/_expected/amd.js index ebca9e90d93..4e59b501e11 100644 --- a/test/form/samples/external-imports/_expected/amd.js +++ b/test/form/samples/external-imports/_expected/amd.js @@ -1,9 +1,6 @@ -define(['factory', 'baz', 'shipping-port', 'alphabet'], function (factory, baz, containers, alphabet) { 'use strict'; +define(['factory', 'baz', 'shipping-port', 'alphabet'], (function (factory, baz, containers, alphabet) { 'use strict'; - function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } - - function _interopNamespace(e) { - if (e && e.__esModule) return e; + function _interopNamespaceDefault(e) { var n = Object.create(null); if (e) { Object.keys(e).forEach(function (k) { @@ -11,25 +8,21 @@ define(['factory', 'baz', 'shipping-port', 'alphabet'], function (factory, baz, var d = Object.getOwnPropertyDescriptor(e, k); Object.defineProperty(n, k, d.get ? d : { enumerable: true, - get: function () { - return e[k]; - } + get: function () { return e[k]; } }); } }); } - n['default'] = e; + n.default = e; return Object.freeze(n); } - var factory__default = /*#__PURE__*/_interopDefaultLegacy(factory); - var containers__namespace = /*#__PURE__*/_interopNamespace(containers); - var alphabet__default = /*#__PURE__*/_interopDefaultLegacy(alphabet); + var containers__namespace = /*#__PURE__*/_interopNamespaceDefault(containers); - factory__default['default']( null ); + factory( null ); baz.foo( baz.bar, containers.port ); containers__namespace.forEach( console.log, console ); console.log( alphabet.a ); - console.log( alphabet__default['default'].length ); + console.log( alphabet.length ); -}); +})); diff --git a/test/form/samples/external-imports/_expected/cjs.js b/test/form/samples/external-imports/_expected/cjs.js index edba84b5de8..c267c41c964 100644 --- a/test/form/samples/external-imports/_expected/cjs.js +++ b/test/form/samples/external-imports/_expected/cjs.js @@ -5,10 +5,7 @@ var baz = require('baz'); var containers = require('shipping-port'); var alphabet = require('alphabet'); -function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } - -function _interopNamespace(e) { - if (e && e.__esModule) return e; +function _interopNamespaceDefault(e) { var n = Object.create(null); if (e) { Object.keys(e).forEach(function (k) { @@ -16,23 +13,19 @@ function _interopNamespace(e) { var d = Object.getOwnPropertyDescriptor(e, k); Object.defineProperty(n, k, d.get ? d : { enumerable: true, - get: function () { - return e[k]; - } + get: function () { return e[k]; } }); } }); } - n['default'] = e; + n.default = e; return Object.freeze(n); } -var factory__default = /*#__PURE__*/_interopDefaultLegacy(factory); -var containers__namespace = /*#__PURE__*/_interopNamespace(containers); -var alphabet__default = /*#__PURE__*/_interopDefaultLegacy(alphabet); +var containers__namespace = /*#__PURE__*/_interopNamespaceDefault(containers); -factory__default['default']( null ); +factory( null ); baz.foo( baz.bar, containers.port ); containers__namespace.forEach( console.log, console ); console.log( alphabet.a ); -console.log( alphabet__default['default'].length ); +console.log( alphabet.length ); diff --git a/test/form/samples/external-imports/_expected/iife.js b/test/form/samples/external-imports/_expected/iife.js index 3f4c572365d..d62456725f8 100644 --- a/test/form/samples/external-imports/_expected/iife.js +++ b/test/form/samples/external-imports/_expected/iife.js @@ -1,10 +1,7 @@ (function (factory, baz, containers, alphabet) { 'use strict'; - function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } - - function _interopNamespace(e) { - if (e && e.__esModule) return e; + function _interopNamespaceDefault(e) { var n = Object.create(null); if (e) { Object.keys(e).forEach(function (k) { @@ -12,25 +9,21 @@ var d = Object.getOwnPropertyDescriptor(e, k); Object.defineProperty(n, k, d.get ? d : { enumerable: true, - get: function () { - return e[k]; - } + get: function () { return e[k]; } }); } }); } - n['default'] = e; + n.default = e; return Object.freeze(n); } - var factory__default = /*#__PURE__*/_interopDefaultLegacy(factory); - var containers__namespace = /*#__PURE__*/_interopNamespace(containers); - var alphabet__default = /*#__PURE__*/_interopDefaultLegacy(alphabet); + var containers__namespace = /*#__PURE__*/_interopNamespaceDefault(containers); - factory__default['default']( null ); + factory( null ); baz.foo( baz.bar, containers.port ); containers__namespace.forEach( console.log, console ); console.log( alphabet.a ); - console.log( alphabet__default['default'].length ); + console.log( alphabet.length ); -}(factory, baz, containers, alphabet)); +})(factory, baz, containers, alphabet); diff --git a/test/form/samples/external-imports/_expected/system.js b/test/form/samples/external-imports/_expected/system.js index 2bdce04513e..b5c6c08e7bc 100644 --- a/test/form/samples/external-imports/_expected/system.js +++ b/test/form/samples/external-imports/_expected/system.js @@ -1,4 +1,4 @@ -System.register(['factory', 'baz', 'shipping-port', 'alphabet'], function () { +System.register(['factory', 'baz', 'shipping-port', 'alphabet'], (function () { 'use strict'; var factory, foo, bar, port, containers, a, alphabet; return { @@ -14,7 +14,7 @@ System.register(['factory', 'baz', 'shipping-port', 'alphabet'], function () { a = module.a; alphabet = module.default; }], - execute: function () { + execute: (function () { factory( null ); foo( bar, port ); @@ -22,6 +22,6 @@ System.register(['factory', 'baz', 'shipping-port', 'alphabet'], function () { console.log( a ); console.log( alphabet.length ); - } + }) }; -}); +})); diff --git a/test/form/samples/external-imports/_expected/umd.js b/test/form/samples/external-imports/_expected/umd.js index 287214a4369..bbcd4235d49 100644 --- a/test/form/samples/external-imports/_expected/umd.js +++ b/test/form/samples/external-imports/_expected/umd.js @@ -2,12 +2,9 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('factory'), require('baz'), require('shipping-port'), require('alphabet')) : typeof define === 'function' && define.amd ? define(['factory', 'baz', 'shipping-port', 'alphabet'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.factory, global.baz, global.containers, global.alphabet)); -}(this, (function (factory, baz, containers, alphabet) { 'use strict'; +})(this, (function (factory, baz, containers, alphabet) { 'use strict'; - function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } - - function _interopNamespace(e) { - if (e && e.__esModule) return e; + function _interopNamespaceDefault(e) { var n = Object.create(null); if (e) { Object.keys(e).forEach(function (k) { @@ -15,25 +12,21 @@ var d = Object.getOwnPropertyDescriptor(e, k); Object.defineProperty(n, k, d.get ? d : { enumerable: true, - get: function () { - return e[k]; - } + get: function () { return e[k]; } }); } }); } - n['default'] = e; + n.default = e; return Object.freeze(n); } - var factory__default = /*#__PURE__*/_interopDefaultLegacy(factory); - var containers__namespace = /*#__PURE__*/_interopNamespace(containers); - var alphabet__default = /*#__PURE__*/_interopDefaultLegacy(alphabet); + var containers__namespace = /*#__PURE__*/_interopNamespaceDefault(containers); - factory__default['default']( null ); + factory( null ); baz.foo( baz.bar, containers.port ); containers__namespace.forEach( console.log, console ); console.log( alphabet.a ); - console.log( alphabet__default['default'].length ); + console.log( alphabet.length ); -}))); +})); diff --git a/test/form/samples/external-modules-could-not-be-passed-to-the-manualChunks/_config.js b/test/form/samples/external-modules-could-not-be-passed-to-the-manualChunks/_config.js new file mode 100644 index 00000000000..7d534ea309d --- /dev/null +++ b/test/form/samples/external-modules-could-not-be-passed-to-the-manualChunks/_config.js @@ -0,0 +1,19 @@ +const text = "External modules couldn't be passed to the manualChunks."; + +module.exports = defineTest({ + description: text, + options: { + external: id => { + if (id.endsWith('external.js')) { + return true; + } + }, + output: { + manualChunks(id) { + if (id.endsWith('external.js')) { + throw new Error(text); + } + } + } + } +}); diff --git a/test/form/samples/external-modules-could-not-be-passed-to-the-manualChunks/_expected.js b/test/form/samples/external-modules-could-not-be-passed-to-the-manualChunks/_expected.js new file mode 100644 index 00000000000..24f4cd70c44 --- /dev/null +++ b/test/form/samples/external-modules-could-not-be-passed-to-the-manualChunks/_expected.js @@ -0,0 +1 @@ +import './external.js'; diff --git a/test/form/samples/external-modules-could-not-be-passed-to-the-manualChunks/main.js b/test/form/samples/external-modules-could-not-be-passed-to-the-manualChunks/main.js new file mode 100644 index 00000000000..24f4cd70c44 --- /dev/null +++ b/test/form/samples/external-modules-could-not-be-passed-to-the-manualChunks/main.js @@ -0,0 +1 @@ +import './external.js'; diff --git a/test/form/samples/external-namespace-and-named/_config.js b/test/form/samples/external-namespace-and-named/_config.js index 836a753798a..dba2bf0ca6c 100644 --- a/test/form/samples/external-namespace-and-named/_config.js +++ b/test/form/samples/external-namespace-and-named/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'Correctly handles external namespace tracing with both namespace and named exports', options: { external: ['foo'], @@ -6,4 +6,4 @@ module.exports = { globals: { foo: 'foo' } } } -}; +}); diff --git a/test/form/samples/external-namespace-and-named/_expected/amd.js b/test/form/samples/external-namespace-and-named/_expected/amd.js index 36e658f1b4f..c5bb406d9cf 100644 --- a/test/form/samples/external-namespace-and-named/_expected/amd.js +++ b/test/form/samples/external-namespace-and-named/_expected/amd.js @@ -1,7 +1,6 @@ -define(['foo'], function (foo) { 'use strict'; +define(['foo'], (function (foo) { 'use strict'; - function _interopNamespace(e) { - if (e && e.__esModule) return e; + function _interopNamespaceDefault(e) { var n = Object.create(null); if (e) { Object.keys(e).forEach(function (k) { @@ -9,21 +8,19 @@ define(['foo'], function (foo) { 'use strict'; var d = Object.getOwnPropertyDescriptor(e, k); Object.defineProperty(n, k, d.get ? d : { enumerable: true, - get: function () { - return e[k]; - } + get: function () { return e[k]; } }); } }); } - n['default'] = e; + n.default = e; return Object.freeze(n); } - var foo__namespace = /*#__PURE__*/_interopNamespace(foo); + var foo__namespace = /*#__PURE__*/_interopNamespaceDefault(foo); console.log(foo__namespace); console.log(foo.blah); console.log(foo.bar); -}); +})); diff --git a/test/form/samples/external-namespace-and-named/_expected/cjs.js b/test/form/samples/external-namespace-and-named/_expected/cjs.js index 45ac12b51f7..3c3f9bed195 100644 --- a/test/form/samples/external-namespace-and-named/_expected/cjs.js +++ b/test/form/samples/external-namespace-and-named/_expected/cjs.js @@ -2,8 +2,7 @@ var foo = require('foo'); -function _interopNamespace(e) { - if (e && e.__esModule) return e; +function _interopNamespaceDefault(e) { var n = Object.create(null); if (e) { Object.keys(e).forEach(function (k) { @@ -11,18 +10,16 @@ function _interopNamespace(e) { var d = Object.getOwnPropertyDescriptor(e, k); Object.defineProperty(n, k, d.get ? d : { enumerable: true, - get: function () { - return e[k]; - } + get: function () { return e[k]; } }); } }); } - n['default'] = e; + n.default = e; return Object.freeze(n); } -var foo__namespace = /*#__PURE__*/_interopNamespace(foo); +var foo__namespace = /*#__PURE__*/_interopNamespaceDefault(foo); console.log(foo__namespace); console.log(foo.blah); diff --git a/test/form/samples/external-namespace-and-named/_expected/iife.js b/test/form/samples/external-namespace-and-named/_expected/iife.js index d6fc1602b11..f83d069253e 100644 --- a/test/form/samples/external-namespace-and-named/_expected/iife.js +++ b/test/form/samples/external-namespace-and-named/_expected/iife.js @@ -1,8 +1,7 @@ (function (foo) { 'use strict'; - function _interopNamespace(e) { - if (e && e.__esModule) return e; + function _interopNamespaceDefault(e) { var n = Object.create(null); if (e) { Object.keys(e).forEach(function (k) { @@ -10,21 +9,19 @@ var d = Object.getOwnPropertyDescriptor(e, k); Object.defineProperty(n, k, d.get ? d : { enumerable: true, - get: function () { - return e[k]; - } + get: function () { return e[k]; } }); } }); } - n['default'] = e; + n.default = e; return Object.freeze(n); } - var foo__namespace = /*#__PURE__*/_interopNamespace(foo); + var foo__namespace = /*#__PURE__*/_interopNamespaceDefault(foo); console.log(foo__namespace); console.log(foo.blah); console.log(foo.bar); -}(foo)); +})(foo); diff --git a/test/form/samples/external-namespace-and-named/_expected/system.js b/test/form/samples/external-namespace-and-named/_expected/system.js index b5dcc06e593..afb78f8ac71 100644 --- a/test/form/samples/external-namespace-and-named/_expected/system.js +++ b/test/form/samples/external-namespace-and-named/_expected/system.js @@ -1,4 +1,4 @@ -System.register(['foo'], function () { +System.register(['foo'], (function () { 'use strict'; var foo, blah, bar; return { @@ -7,12 +7,12 @@ System.register(['foo'], function () { blah = module.blah; bar = module.bar; }], - execute: function () { + execute: (function () { console.log(foo); console.log(blah); console.log(bar); - } + }) }; -}); +})); diff --git a/test/form/samples/external-namespace-and-named/_expected/umd.js b/test/form/samples/external-namespace-and-named/_expected/umd.js index 97d68c705cc..064917cbecc 100644 --- a/test/form/samples/external-namespace-and-named/_expected/umd.js +++ b/test/form/samples/external-namespace-and-named/_expected/umd.js @@ -2,10 +2,9 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('foo')) : typeof define === 'function' && define.amd ? define(['foo'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.foo)); -}(this, (function (foo) { 'use strict'; +})(this, (function (foo) { 'use strict'; - function _interopNamespace(e) { - if (e && e.__esModule) return e; + function _interopNamespaceDefault(e) { var n = Object.create(null); if (e) { Object.keys(e).forEach(function (k) { @@ -13,21 +12,19 @@ var d = Object.getOwnPropertyDescriptor(e, k); Object.defineProperty(n, k, d.get ? d : { enumerable: true, - get: function () { - return e[k]; - } + get: function () { return e[k]; } }); } }); } - n['default'] = e; + n.default = e; return Object.freeze(n); } - var foo__namespace = /*#__PURE__*/_interopNamespace(foo); + var foo__namespace = /*#__PURE__*/_interopNamespaceDefault(foo); console.log(foo__namespace); console.log(foo.blah); console.log(foo.bar); -}))); +})); diff --git a/test/form/samples/external-namespace-optimzation-in-operator/_config.js b/test/form/samples/external-namespace-optimzation-in-operator/_config.js new file mode 100644 index 00000000000..e8b8e8d6aed --- /dev/null +++ b/test/form/samples/external-namespace-optimzation-in-operator/_config.js @@ -0,0 +1,6 @@ +module.exports = { + description: 'disables optimization for external namespace when using the in operator', + options: { + external: ['node:crypto', './ext.js'] + } +}; diff --git a/test/form/samples/external-namespace-optimzation-in-operator/_expected.js b/test/form/samples/external-namespace-optimzation-in-operator/_expected.js new file mode 100644 index 00000000000..c4aee3950f4 --- /dev/null +++ b/test/form/samples/external-namespace-optimzation-in-operator/_expected.js @@ -0,0 +1,27 @@ +import * as nc from 'node:crypto'; +import * as ext from './ext.js'; + +function _mergeNamespaces(n, m) { + m.forEach(function (e) { + e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) { + if (k !== 'default' && !(k in n)) { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + }); + return Object.freeze(n); +} + +var pt = /*#__PURE__*/_mergeNamespaces({ + __proto__: null +}, [ext]); + +const crypto = 'webcrypto' in nc; +const direct = 'whatever' in ext; +const indirect = 'whatever' in pt; + +export { crypto, direct, indirect }; diff --git a/test/form/samples/external-namespace-optimzation-in-operator/ext.js b/test/form/samples/external-namespace-optimzation-in-operator/ext.js new file mode 100644 index 00000000000..79716867daa --- /dev/null +++ b/test/form/samples/external-namespace-optimzation-in-operator/ext.js @@ -0,0 +1 @@ +export const whatever = 1 diff --git a/test/form/samples/external-namespace-optimzation-in-operator/main.js b/test/form/samples/external-namespace-optimzation-in-operator/main.js new file mode 100644 index 00000000000..02fd0a0de85 --- /dev/null +++ b/test/form/samples/external-namespace-optimzation-in-operator/main.js @@ -0,0 +1,7 @@ +import * as nc from 'node:crypto'; +import * as ext from './ext.js'; +import * as pt from './passthrough.js'; + +export const crypto = 'webcrypto' in nc; +export const direct = 'whatever' in ext; +export const indirect = 'whatever' in pt; diff --git a/test/form/samples/external-namespace-optimzation-in-operator/passthrough.js b/test/form/samples/external-namespace-optimzation-in-operator/passthrough.js new file mode 100644 index 00000000000..8ea6df22889 --- /dev/null +++ b/test/form/samples/external-namespace-optimzation-in-operator/passthrough.js @@ -0,0 +1 @@ +export * from './ext.js' diff --git a/test/form/samples/external-namespace-reexport/_config.js b/test/form/samples/external-namespace-reexport/_config.js index 7e15b263f44..4fc57ee9de6 100644 --- a/test/form/samples/external-namespace-reexport/_config.js +++ b/test/form/samples/external-namespace-reexport/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'Support external namespace reexport', options: { external: ['highcharts'], @@ -7,4 +7,4 @@ module.exports = { name: 'myBundle' } } -}; +}); diff --git a/test/form/samples/external-namespace-reexport/_expected/amd.js b/test/form/samples/external-namespace-reexport/_expected/amd.js index da3ea841133..0aa09e1e5bc 100644 --- a/test/form/samples/external-namespace-reexport/_expected/amd.js +++ b/test/form/samples/external-namespace-reexport/_expected/amd.js @@ -1,7 +1,6 @@ -define(['exports', 'highcharts'], function (exports, highcharts) { 'use strict'; +define(['exports', 'highcharts'], (function (exports, highcharts) { 'use strict'; - function _interopNamespace(e) { - if (e && e.__esModule) return e; + function _interopNamespaceDefault(e) { var n = Object.create(null); if (e) { Object.keys(e).forEach(function (k) { @@ -9,23 +8,19 @@ define(['exports', 'highcharts'], function (exports, highcharts) { 'use strict'; var d = Object.getOwnPropertyDescriptor(e, k); Object.defineProperty(n, k, d.get ? d : { enumerable: true, - get: function () { - return e[k]; - } + get: function () { return e[k]; } }); } }); } - n['default'] = e; + n.default = e; return Object.freeze(n); } - var highcharts__namespace = /*#__PURE__*/_interopNamespace(highcharts); + var highcharts__namespace = /*#__PURE__*/_interopNamespaceDefault(highcharts); exports.Highcharts = highcharts__namespace; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/form/samples/external-namespace-reexport/_expected/cjs.js b/test/form/samples/external-namespace-reexport/_expected/cjs.js index 0910a223d0e..f6c032ceac1 100644 --- a/test/form/samples/external-namespace-reexport/_expected/cjs.js +++ b/test/form/samples/external-namespace-reexport/_expected/cjs.js @@ -1,11 +1,8 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - var highcharts = require('highcharts'); -function _interopNamespace(e) { - if (e && e.__esModule) return e; +function _interopNamespaceDefault(e) { var n = Object.create(null); if (e) { Object.keys(e).forEach(function (k) { @@ -13,18 +10,16 @@ function _interopNamespace(e) { var d = Object.getOwnPropertyDescriptor(e, k); Object.defineProperty(n, k, d.get ? d : { enumerable: true, - get: function () { - return e[k]; - } + get: function () { return e[k]; } }); } }); } - n['default'] = e; + n.default = e; return Object.freeze(n); } -var highcharts__namespace = /*#__PURE__*/_interopNamespace(highcharts); +var highcharts__namespace = /*#__PURE__*/_interopNamespaceDefault(highcharts); diff --git a/test/form/samples/external-namespace-reexport/_expected/iife.js b/test/form/samples/external-namespace-reexport/_expected/iife.js index d0342edfe29..490db1dc774 100644 --- a/test/form/samples/external-namespace-reexport/_expected/iife.js +++ b/test/form/samples/external-namespace-reexport/_expected/iife.js @@ -1,8 +1,7 @@ var myBundle = (function (exports, highcharts) { 'use strict'; - function _interopNamespace(e) { - if (e && e.__esModule) return e; + function _interopNamespaceDefault(e) { var n = Object.create(null); if (e) { Object.keys(e).forEach(function (k) { @@ -10,25 +9,21 @@ var myBundle = (function (exports, highcharts) { var d = Object.getOwnPropertyDescriptor(e, k); Object.defineProperty(n, k, d.get ? d : { enumerable: true, - get: function () { - return e[k]; - } + get: function () { return e[k]; } }); } }); } - n['default'] = e; + n.default = e; return Object.freeze(n); } - var highcharts__namespace = /*#__PURE__*/_interopNamespace(highcharts); + var highcharts__namespace = /*#__PURE__*/_interopNamespaceDefault(highcharts); exports.Highcharts = highcharts__namespace; - Object.defineProperty(exports, '__esModule', { value: true }); - return exports; -}({}, highcharts)); +})({}, highcharts); diff --git a/test/form/samples/external-namespace-reexport/_expected/system.js b/test/form/samples/external-namespace-reexport/_expected/system.js index a37440ce7a0..5dad7918e27 100644 --- a/test/form/samples/external-namespace-reexport/_expected/system.js +++ b/test/form/samples/external-namespace-reexport/_expected/system.js @@ -1,13 +1,13 @@ -System.register('myBundle', ['highcharts'], function (exports) { +System.register('myBundle', ['highcharts'], (function (exports) { 'use strict'; return { setters: [function (module) { - exports('Highcharts', module); + exports("Highcharts", module); }], - execute: function () { + execute: (function () { - } + }) }; -}); +})); diff --git a/test/form/samples/external-namespace-reexport/_expected/umd.js b/test/form/samples/external-namespace-reexport/_expected/umd.js index 14db1a480d9..85c14cbfb00 100644 --- a/test/form/samples/external-namespace-reexport/_expected/umd.js +++ b/test/form/samples/external-namespace-reexport/_expected/umd.js @@ -2,10 +2,9 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('highcharts')) : typeof define === 'function' && define.amd ? define(['exports', 'highcharts'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.myBundle = {}, global.highcharts)); -}(this, (function (exports, highcharts) { 'use strict'; +})(this, (function (exports, highcharts) { 'use strict'; - function _interopNamespace(e) { - if (e && e.__esModule) return e; + function _interopNamespaceDefault(e) { var n = Object.create(null); if (e) { Object.keys(e).forEach(function (k) { @@ -13,23 +12,19 @@ var d = Object.getOwnPropertyDescriptor(e, k); Object.defineProperty(n, k, d.get ? d : { enumerable: true, - get: function () { - return e[k]; - } + get: function () { return e[k]; } }); } }); } - n['default'] = e; + n.default = e; return Object.freeze(n); } - var highcharts__namespace = /*#__PURE__*/_interopNamespace(highcharts); + var highcharts__namespace = /*#__PURE__*/_interopNamespaceDefault(highcharts); exports.Highcharts = highcharts__namespace; - Object.defineProperty(exports, '__esModule', { value: true }); - -}))); +})); diff --git a/test/form/samples/for-in-scopes/_config.js b/test/form/samples/for-in-scopes/_config.js index 96ccae80614..3960d227369 100644 --- a/test/form/samples/for-in-scopes/_config.js +++ b/test/form/samples/for-in-scopes/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'properly associate or shadow variables in and around for-in-loops' -}; +}); diff --git a/test/form/samples/for-loop-assignment/_config.js b/test/form/samples/for-loop-assignment/_config.js new file mode 100644 index 00000000000..2675850e9a2 --- /dev/null +++ b/test/form/samples/for-loop-assignment/_config.js @@ -0,0 +1,4 @@ +module.exports = defineTest({ + description: 'removes assignments with computed indexes in for loops', + expectedWarnings: ['EMPTY_BUNDLE'] +}); diff --git a/test/form/samples/undefined-properties/_expected.js b/test/form/samples/for-loop-assignment/_expected.js similarity index 100% rename from test/form/samples/undefined-properties/_expected.js rename to test/form/samples/for-loop-assignment/_expected.js diff --git a/test/form/samples/for-loop-assignment/main.js b/test/form/samples/for-loop-assignment/main.js new file mode 100644 index 00000000000..948cb07f092 --- /dev/null +++ b/test/form/samples/for-loop-assignment/main.js @@ -0,0 +1,5 @@ +const lut = []; + +for (let i = 0; i < 256; i++) { + lut[i] = i < 16 ? '0' : ''; +} diff --git a/test/form/samples/for-loop-body-var-declaration/_config.js b/test/form/samples/for-loop-body-var-declaration/_config.js index 9a0504cf967..4a81a595b59 100644 --- a/test/form/samples/for-loop-body-var-declaration/_config.js +++ b/test/form/samples/for-loop-body-var-declaration/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'use a newline for line wraps removing a necessary semicolon (#1275)' -}; +}); diff --git a/test/form/samples/for-loop-body-var-declaration/_expected/amd.js b/test/form/samples/for-loop-body-var-declaration/_expected/amd.js index 65f8e046cf7..f84f617f9f8 100644 --- a/test/form/samples/for-loop-body-var-declaration/_expected/amd.js +++ b/test/form/samples/for-loop-body-var-declaration/_expected/amd.js @@ -1,5 +1,5 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; for(var x=1;x<2;x++)var d=x|0;console.log(d); -}); +})); diff --git a/test/form/samples/for-loop-body-var-declaration/_expected/iife.js b/test/form/samples/for-loop-body-var-declaration/_expected/iife.js index 1619ca1df29..dea724f2aad 100644 --- a/test/form/samples/for-loop-body-var-declaration/_expected/iife.js +++ b/test/form/samples/for-loop-body-var-declaration/_expected/iife.js @@ -3,4 +3,4 @@ for(var x=1;x<2;x++)var d=x|0;console.log(d); -}()); +})(); diff --git a/test/form/samples/for-loop-body-var-declaration/_expected/system.js b/test/form/samples/for-loop-body-var-declaration/_expected/system.js index 5bb134edf03..ce190d9aefc 100644 --- a/test/form/samples/for-loop-body-var-declaration/_expected/system.js +++ b/test/form/samples/for-loop-body-var-declaration/_expected/system.js @@ -1,10 +1,10 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { for(var x=1;x<2;x++)var d=x|0;console.log(d); - } + }) }; -}); +})); diff --git a/test/form/samples/for-loop-body-var-declaration/_expected/umd.js b/test/form/samples/for-loop-body-var-declaration/_expected/umd.js index cde29d795c5..e056f893197 100644 --- a/test/form/samples/for-loop-body-var-declaration/_expected/umd.js +++ b/test/form/samples/for-loop-body-var-declaration/_expected/umd.js @@ -1,8 +1,8 @@ (function (factory) { typeof define === 'function' && define.amd ? define(factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; for(var x=1;x<2;x++)var d=x|0;console.log(d); -}))); +})); diff --git a/test/form/samples/for-loop-with-empty-head/_config.js b/test/form/samples/for-loop-with-empty-head/_config.js index 3fc4a6756e5..2c6f483247d 100644 --- a/test/form/samples/for-loop-with-empty-head/_config.js +++ b/test/form/samples/for-loop-with-empty-head/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'handles for loop with empty head' -}; +}); diff --git a/test/form/samples/for-loop-with-empty-head/_expected/amd.js b/test/form/samples/for-loop-with-empty-head/_expected/amd.js index ed463fcf960..53c25fed8f9 100644 --- a/test/form/samples/for-loop-with-empty-head/_expected/amd.js +++ b/test/form/samples/for-loop-with-empty-head/_expected/amd.js @@ -1,7 +1,7 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; for ( ; ; ) { console.log( 42 ); } -}); +})); diff --git a/test/form/samples/for-loop-with-empty-head/_expected/iife.js b/test/form/samples/for-loop-with-empty-head/_expected/iife.js index ec08c262c7e..1a8a296f6b2 100644 --- a/test/form/samples/for-loop-with-empty-head/_expected/iife.js +++ b/test/form/samples/for-loop-with-empty-head/_expected/iife.js @@ -5,4 +5,4 @@ console.log( 42 ); } -}()); +})(); diff --git a/test/form/samples/for-loop-with-empty-head/_expected/system.js b/test/form/samples/for-loop-with-empty-head/_expected/system.js index 14aba10ca6e..c11bef05b26 100644 --- a/test/form/samples/for-loop-with-empty-head/_expected/system.js +++ b/test/form/samples/for-loop-with-empty-head/_expected/system.js @@ -1,12 +1,12 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { for ( ; ; ) { console.log( 42 ); } - } + }) }; -}); +})); diff --git a/test/form/samples/for-loop-with-empty-head/_expected/umd.js b/test/form/samples/for-loop-with-empty-head/_expected/umd.js index 4c6d53beaa8..a16c18e27f6 100644 --- a/test/form/samples/for-loop-with-empty-head/_expected/umd.js +++ b/test/form/samples/for-loop-with-empty-head/_expected/umd.js @@ -1,10 +1,10 @@ (function (factory) { typeof define === 'function' && define.amd ? define(factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; for ( ; ; ) { console.log( 42 ); } -}))); +})); diff --git a/test/form/samples/for-of-scopes/_config.js b/test/form/samples/for-of-scopes/_config.js index 4d8d348e4a4..fd2c66957ca 100644 --- a/test/form/samples/for-of-scopes/_config.js +++ b/test/form/samples/for-of-scopes/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'properly associate or shadow variables in and around for-of-loops' -}; +}); diff --git a/test/form/samples/for-scopes/_config.js b/test/form/samples/for-scopes/_config.js index 552d2e34790..27d13b692eb 100644 --- a/test/form/samples/for-scopes/_config.js +++ b/test/form/samples/for-scopes/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'properly associate or shadow variables in and around for-loops' -}; +}); diff --git a/test/form/samples/for-scopes/_expected/amd.js b/test/form/samples/for-scopes/_expected/amd.js index 72223f25919..c5ffbbd054c 100644 --- a/test/form/samples/for-scopes/_expected/amd.js +++ b/test/form/samples/for-scopes/_expected/amd.js @@ -1,4 +1,4 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; var effect1 = () => console.log( 'effect' ); var associated = () => {}; @@ -13,4 +13,4 @@ define(function () { 'use strict'; break; } -}); +})); diff --git a/test/form/samples/for-scopes/_expected/iife.js b/test/form/samples/for-scopes/_expected/iife.js index 3a8413c8386..22af3f35779 100644 --- a/test/form/samples/for-scopes/_expected/iife.js +++ b/test/form/samples/for-scopes/_expected/iife.js @@ -14,4 +14,4 @@ break; } -}()); +})(); diff --git a/test/form/samples/for-scopes/_expected/system.js b/test/form/samples/for-scopes/_expected/system.js index 7a467a415a5..b89327168b9 100644 --- a/test/form/samples/for-scopes/_expected/system.js +++ b/test/form/samples/for-scopes/_expected/system.js @@ -1,7 +1,7 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { var effect1 = () => console.log( 'effect' ); var associated = () => {}; @@ -16,6 +16,6 @@ System.register([], function () { break; } - } + }) }; -}); +})); diff --git a/test/form/samples/for-scopes/_expected/umd.js b/test/form/samples/for-scopes/_expected/umd.js index e13a8263ce5..f7ca579200c 100644 --- a/test/form/samples/for-scopes/_expected/umd.js +++ b/test/form/samples/for-scopes/_expected/umd.js @@ -1,7 +1,7 @@ (function (factory) { typeof define === 'function' && define.amd ? define(factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; var effect1 = () => console.log( 'effect' ); var associated = () => {}; @@ -16,4 +16,4 @@ break; } -}))); +})); diff --git a/test/form/samples/freeze/_config.js b/test/form/samples/freeze/_config.js index f21ca943d82..12ac7d22b83 100644 --- a/test/form/samples/freeze/_config.js +++ b/test/form/samples/freeze/_config.js @@ -1,6 +1,6 @@ -module.exports = { +module.exports = defineTest({ description: 'supports opt-ing out of usage of Object.freeze', options: { output: { name: 'myBundle', freeze: false } } -}; +}); diff --git a/test/form/samples/freeze/_expected/amd.js b/test/form/samples/freeze/_expected/amd.js index 6d5f5acc935..934e631a95e 100644 --- a/test/form/samples/freeze/_expected/amd.js +++ b/test/form/samples/freeze/_expected/amd.js @@ -1,12 +1,12 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; const foo = 1; const bar = 2; var namespace = { __proto__: null, - foo: foo, - bar: bar + bar: bar, + foo: foo }; console.log( Object.keys( namespace ) ); @@ -17,6 +17,4 @@ define(['exports'], function (exports) { 'use strict'; exports.a = a; exports.b = b; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/form/samples/freeze/_expected/cjs.js b/test/form/samples/freeze/_expected/cjs.js index 2ee4ef34da1..a5c526297d6 100644 --- a/test/form/samples/freeze/_expected/cjs.js +++ b/test/form/samples/freeze/_expected/cjs.js @@ -1,14 +1,12 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - const foo = 1; const bar = 2; var namespace = { __proto__: null, - foo: foo, - bar: bar + bar: bar, + foo: foo }; console.log( Object.keys( namespace ) ); diff --git a/test/form/samples/freeze/_expected/es.js b/test/form/samples/freeze/_expected/es.js index 1285f913af8..fc5a8ebec31 100644 --- a/test/form/samples/freeze/_expected/es.js +++ b/test/form/samples/freeze/_expected/es.js @@ -3,8 +3,8 @@ const bar = 2; var namespace = { __proto__: null, - foo: foo, - bar: bar + bar: bar, + foo: foo }; console.log( Object.keys( namespace ) ); diff --git a/test/form/samples/freeze/_expected/iife.js b/test/form/samples/freeze/_expected/iife.js index ab4dcbd0dde..c5a94eb937b 100644 --- a/test/form/samples/freeze/_expected/iife.js +++ b/test/form/samples/freeze/_expected/iife.js @@ -6,8 +6,8 @@ var myBundle = (function (exports) { var namespace = { __proto__: null, - foo: foo, - bar: bar + bar: bar, + foo: foo }; console.log( Object.keys( namespace ) ); @@ -18,8 +18,6 @@ var myBundle = (function (exports) { exports.a = a; exports.b = b; - Object.defineProperty(exports, '__esModule', { value: true }); - return exports; -}({})); +})({}); diff --git a/test/form/samples/freeze/_expected/system.js b/test/form/samples/freeze/_expected/system.js index 61af5d66116..aa1385dbdc3 100644 --- a/test/form/samples/freeze/_expected/system.js +++ b/test/form/samples/freeze/_expected/system.js @@ -1,22 +1,22 @@ -System.register('myBundle', [], function (exports) { +System.register('myBundle', [], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { const foo = 1; const bar = 2; var namespace = { __proto__: null, - foo: foo, - bar: bar + bar: bar, + foo: foo }; console.log( Object.keys( namespace ) ); - const a = exports('a', 1); - const b = exports('b', 2); + const a = exports("a", 1); + const b = exports("b", 2); - } + }) }; -}); +})); diff --git a/test/form/samples/freeze/_expected/umd.js b/test/form/samples/freeze/_expected/umd.js index c40ed7b7449..9c4ea5d1020 100644 --- a/test/form/samples/freeze/_expected/umd.js +++ b/test/form/samples/freeze/_expected/umd.js @@ -2,15 +2,15 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.myBundle = {})); -}(this, (function (exports) { 'use strict'; +})(this, (function (exports) { 'use strict'; const foo = 1; const bar = 2; var namespace = { __proto__: null, - foo: foo, - bar: bar + bar: bar, + foo: foo }; console.log( Object.keys( namespace ) ); @@ -21,6 +21,4 @@ exports.a = a; exports.b = b; - Object.defineProperty(exports, '__esModule', { value: true }); - -}))); +})); diff --git a/test/form/samples/function-body-return-values/_config.js b/test/form/samples/function-body-return-values/_config.js index 4fd56e83a8a..df2edb7831b 100644 --- a/test/form/samples/function-body-return-values/_config.js +++ b/test/form/samples/function-body-return-values/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'properly extract return values from function bodies' -}; +}); diff --git a/test/form/samples/function-body-return-values/_expected.js b/test/form/samples/function-body-return-values/_expected.js index cd4f77d4ce6..0064a3f4c4a 100644 --- a/test/form/samples/function-body-return-values/_expected.js +++ b/test/form/samples/function-body-return-values/_expected.js @@ -1,9 +1,3 @@ -function removed3 () { - return { x: () => {} }; -} - -removed3().x(); - function retained1 () { return () => console.log( 'effect' ); } diff --git a/test/form/samples/function-call-parameters/_config.js b/test/form/samples/function-call-parameters/_config.js index bbbe71969f8..097877563f5 100644 --- a/test/form/samples/function-call-parameters/_config.js +++ b/test/form/samples/function-call-parameters/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'take actual parameters into account when determining side-effects of calls to functions' -}; +}); diff --git a/test/form/samples/function-call-parameters/_expected/es.js b/test/form/samples/function-call-parameters/_expected.js similarity index 100% rename from test/form/samples/function-call-parameters/_expected/es.js rename to test/form/samples/function-call-parameters/_expected.js diff --git a/test/form/samples/function-call-parameters/_expected/amd.js b/test/form/samples/function-call-parameters/_expected/amd.js deleted file mode 100644 index d864d70c3c9..00000000000 --- a/test/form/samples/function-call-parameters/_expected/amd.js +++ /dev/null @@ -1,46 +0,0 @@ -define(function () { 'use strict'; - - // parameters are associated correctly - const retained1 = function ( func, obj ) { return func( obj ); }; - retained1( obj => obj(), () => () => console.log( 'effect' ) )(); - - const retained2 = function ( func, obj ) { return func( obj ); }; - retained2( obj => ({ foo: obj }), {} ).foo.bar.baz = 1; - - // parameters and arguments have the same values - function retained3 ( x ) { - x.foo.bar = 1; - } - - retained3( {} ); - - function retained4 ( x ) { - arguments[ 0 ].foo.bar = 1; - } - - retained4( {} ); - - // assigning to an argument will change the corresponding parameter - function retained5 ( x ) { - arguments[ 0 ] = {}; - x.foo.bar = 1; - } - - retained5( { foo: {} } ); - - // assigning to a parameter will change the corresponding argument - function retained6 ( x ) { - x = {}; - arguments[ 0 ].foo.bar = 1; - } - - retained6( { foo: {} } ); - - // the number of arguments does not depend on the number of parameters - function retained7 ( x ) { - arguments[ 1 ].foo.bar = 1; - } - - retained7( {}, {} ); - -}); diff --git a/test/form/samples/function-call-parameters/_expected/cjs.js b/test/form/samples/function-call-parameters/_expected/cjs.js deleted file mode 100644 index 69e2e8f7186..00000000000 --- a/test/form/samples/function-call-parameters/_expected/cjs.js +++ /dev/null @@ -1,44 +0,0 @@ -'use strict'; - -// parameters are associated correctly -const retained1 = function ( func, obj ) { return func( obj ); }; -retained1( obj => obj(), () => () => console.log( 'effect' ) )(); - -const retained2 = function ( func, obj ) { return func( obj ); }; -retained2( obj => ({ foo: obj }), {} ).foo.bar.baz = 1; - -// parameters and arguments have the same values -function retained3 ( x ) { - x.foo.bar = 1; -} - -retained3( {} ); - -function retained4 ( x ) { - arguments[ 0 ].foo.bar = 1; -} - -retained4( {} ); - -// assigning to an argument will change the corresponding parameter -function retained5 ( x ) { - arguments[ 0 ] = {}; - x.foo.bar = 1; -} - -retained5( { foo: {} } ); - -// assigning to a parameter will change the corresponding argument -function retained6 ( x ) { - x = {}; - arguments[ 0 ].foo.bar = 1; -} - -retained6( { foo: {} } ); - -// the number of arguments does not depend on the number of parameters -function retained7 ( x ) { - arguments[ 1 ].foo.bar = 1; -} - -retained7( {}, {} ); diff --git a/test/form/samples/function-call-parameters/_expected/iife.js b/test/form/samples/function-call-parameters/_expected/iife.js deleted file mode 100644 index 4c7db0eab57..00000000000 --- a/test/form/samples/function-call-parameters/_expected/iife.js +++ /dev/null @@ -1,47 +0,0 @@ -(function () { - 'use strict'; - - // parameters are associated correctly - const retained1 = function ( func, obj ) { return func( obj ); }; - retained1( obj => obj(), () => () => console.log( 'effect' ) )(); - - const retained2 = function ( func, obj ) { return func( obj ); }; - retained2( obj => ({ foo: obj }), {} ).foo.bar.baz = 1; - - // parameters and arguments have the same values - function retained3 ( x ) { - x.foo.bar = 1; - } - - retained3( {} ); - - function retained4 ( x ) { - arguments[ 0 ].foo.bar = 1; - } - - retained4( {} ); - - // assigning to an argument will change the corresponding parameter - function retained5 ( x ) { - arguments[ 0 ] = {}; - x.foo.bar = 1; - } - - retained5( { foo: {} } ); - - // assigning to a parameter will change the corresponding argument - function retained6 ( x ) { - x = {}; - arguments[ 0 ].foo.bar = 1; - } - - retained6( { foo: {} } ); - - // the number of arguments does not depend on the number of parameters - function retained7 ( x ) { - arguments[ 1 ].foo.bar = 1; - } - - retained7( {}, {} ); - -}()); diff --git a/test/form/samples/function-call-parameters/_expected/system.js b/test/form/samples/function-call-parameters/_expected/system.js deleted file mode 100644 index 506151effa4..00000000000 --- a/test/form/samples/function-call-parameters/_expected/system.js +++ /dev/null @@ -1,51 +0,0 @@ -System.register([], function () { - 'use strict'; - return { - execute: function () { - - // parameters are associated correctly - const retained1 = function ( func, obj ) { return func( obj ); }; - retained1( obj => obj(), () => () => console.log( 'effect' ) )(); - - const retained2 = function ( func, obj ) { return func( obj ); }; - retained2( obj => ({ foo: obj }), {} ).foo.bar.baz = 1; - - // parameters and arguments have the same values - function retained3 ( x ) { - x.foo.bar = 1; - } - - retained3( {} ); - - function retained4 ( x ) { - arguments[ 0 ].foo.bar = 1; - } - - retained4( {} ); - - // assigning to an argument will change the corresponding parameter - function retained5 ( x ) { - arguments[ 0 ] = {}; - x.foo.bar = 1; - } - - retained5( { foo: {} } ); - - // assigning to a parameter will change the corresponding argument - function retained6 ( x ) { - x = {}; - arguments[ 0 ].foo.bar = 1; - } - - retained6( { foo: {} } ); - - // the number of arguments does not depend on the number of parameters - function retained7 ( x ) { - arguments[ 1 ].foo.bar = 1; - } - - retained7( {}, {} ); - - } - }; -}); diff --git a/test/form/samples/function-call-parameters/_expected/umd.js b/test/form/samples/function-call-parameters/_expected/umd.js deleted file mode 100644 index b634bd8389b..00000000000 --- a/test/form/samples/function-call-parameters/_expected/umd.js +++ /dev/null @@ -1,49 +0,0 @@ -(function (factory) { - typeof define === 'function' && define.amd ? define(factory) : - factory(); -}((function () { 'use strict'; - - // parameters are associated correctly - const retained1 = function ( func, obj ) { return func( obj ); }; - retained1( obj => obj(), () => () => console.log( 'effect' ) )(); - - const retained2 = function ( func, obj ) { return func( obj ); }; - retained2( obj => ({ foo: obj }), {} ).foo.bar.baz = 1; - - // parameters and arguments have the same values - function retained3 ( x ) { - x.foo.bar = 1; - } - - retained3( {} ); - - function retained4 ( x ) { - arguments[ 0 ].foo.bar = 1; - } - - retained4( {} ); - - // assigning to an argument will change the corresponding parameter - function retained5 ( x ) { - arguments[ 0 ] = {}; - x.foo.bar = 1; - } - - retained5( { foo: {} } ); - - // assigning to a parameter will change the corresponding argument - function retained6 ( x ) { - x = {}; - arguments[ 0 ].foo.bar = 1; - } - - retained6( { foo: {} } ); - - // the number of arguments does not depend on the number of parameters - function retained7 ( x ) { - arguments[ 1 ].foo.bar = 1; - } - - retained7( {}, {} ); - -}))); diff --git a/test/form/samples/function-id-as-parameter/_config.js b/test/form/samples/function-id-as-parameter/_config.js new file mode 100644 index 00000000000..66b9b447d6e --- /dev/null +++ b/test/form/samples/function-id-as-parameter/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'allows function expression parameters to shadow their id' +}); diff --git a/test/form/samples/function-id-as-parameter/_expected.js b/test/form/samples/function-id-as-parameter/_expected.js new file mode 100644 index 00000000000..f28b0525e4e --- /dev/null +++ b/test/form/samples/function-id-as-parameter/_expected.js @@ -0,0 +1,5 @@ +const foo = function foo(foo) { + console.log(foo); +}; + +foo(42); diff --git a/test/form/samples/function-id-as-parameter/main.js b/test/form/samples/function-id-as-parameter/main.js new file mode 100644 index 00000000000..5bf1dd60b93 --- /dev/null +++ b/test/form/samples/function-id-as-parameter/main.js @@ -0,0 +1,5 @@ +const foo = function foo(foo) { + console.log(foo); +} + +foo(42); diff --git a/test/form/samples/function-iterable-prototype/_config.js b/test/form/samples/function-iterable-prototype/_config.js new file mode 100644 index 00000000000..68a969a9ddd --- /dev/null +++ b/test/form/samples/function-iterable-prototype/_config.js @@ -0,0 +1,4 @@ +module.exports = defineTest({ + description: 'Removes unused functions where the prototype is iterable', + expectedWarnings: ['EMPTY_BUNDLE'] +}); diff --git a/test/form/samples/function-iterable-prototype/_expected.js b/test/form/samples/function-iterable-prototype/_expected.js new file mode 100644 index 00000000000..8b137891791 --- /dev/null +++ b/test/form/samples/function-iterable-prototype/_expected.js @@ -0,0 +1 @@ + diff --git a/test/form/samples/function-iterable-prototype/main.js b/test/form/samples/function-iterable-prototype/main.js new file mode 100644 index 00000000000..fd07b376992 --- /dev/null +++ b/test/form/samples/function-iterable-prototype/main.js @@ -0,0 +1,5 @@ +function AsyncGenerator(gen) {} + +AsyncGenerator.prototype[Symbol.asyncIterator] = function () { + return this; +}; diff --git a/test/form/samples/function-mutation/_config.js b/test/form/samples/function-mutation/_config.js index daf7066a19e..6c2feccf835 100644 --- a/test/form/samples/function-mutation/_config.js +++ b/test/form/samples/function-mutation/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'function-mutations do not have effects', options: { output: { name: 'bundle' } } -}; +}); diff --git a/test/form/samples/function-mutation/_expected/amd.js b/test/form/samples/function-mutation/_expected/amd.js index c234d477bda..25fec9ef334 100644 --- a/test/form/samples/function-mutation/_expected/amd.js +++ b/test/form/samples/function-mutation/_expected/amd.js @@ -1,4 +1,4 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; function foo () { console.log( 'foo' ); @@ -45,6 +45,4 @@ define(['exports'], function (exports) { 'use strict'; exports.g = g; exports.i = i; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/form/samples/function-mutation/_expected/cjs.js b/test/form/samples/function-mutation/_expected/cjs.js index 51b5d461cf8..5291f114edb 100644 --- a/test/form/samples/function-mutation/_expected/cjs.js +++ b/test/form/samples/function-mutation/_expected/cjs.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - function foo () { console.log( 'foo' ); } diff --git a/test/form/samples/function-mutation/_expected/iife.js b/test/form/samples/function-mutation/_expected/iife.js index 80540ce3178..8ee2f0ac6fc 100644 --- a/test/form/samples/function-mutation/_expected/iife.js +++ b/test/form/samples/function-mutation/_expected/iife.js @@ -46,8 +46,6 @@ var bundle = (function (exports) { exports.g = g; exports.i = i; - Object.defineProperty(exports, '__esModule', { value: true }); - return exports; -}({})); +})({}); diff --git a/test/form/samples/function-mutation/_expected/system.js b/test/form/samples/function-mutation/_expected/system.js index 84a75118444..898ddf78143 100644 --- a/test/form/samples/function-mutation/_expected/system.js +++ b/test/form/samples/function-mutation/_expected/system.js @@ -1,9 +1,9 @@ -System.register('bundle', [], function (exports) { +System.register('bundle', [], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - exports('a', a); + exports("a", a); function foo () { console.log( 'foo' ); @@ -21,29 +21,29 @@ System.register('bundle', [], function (exports) { a.foo = foo; - const c = exports('c', function () { + const c = exports("c", function () { console.log( 'c' ); }); c.bar = bar; - const e = exports('e', () => console.log( 'e' )); + const e = exports("e", () => console.log( 'e' )); e.baz = baz; class g { constructor () { console.log( 'g' ); } - } exports('g', g); + } exports("g", g); g.foo = foo; - const i = exports('i', class { + const i = exports("i", class { constructor () { console.log( 'i' ); } }); i.foo = foo; - } + }) }; -}); +})); diff --git a/test/form/samples/function-mutation/_expected/umd.js b/test/form/samples/function-mutation/_expected/umd.js index 7425cc7efb0..d7d3e2fe237 100644 --- a/test/form/samples/function-mutation/_expected/umd.js +++ b/test/form/samples/function-mutation/_expected/umd.js @@ -2,7 +2,7 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.bundle = {})); -}(this, (function (exports) { 'use strict'; +})(this, (function (exports) { 'use strict'; function foo () { console.log( 'foo' ); @@ -49,6 +49,4 @@ exports.g = g; exports.i = i; - Object.defineProperty(exports, '__esModule', { value: true }); - -}))); +})); diff --git a/test/form/samples/function-scopes/_config.js b/test/form/samples/function-scopes/_config.js index 5b8670f6496..9712643a9f1 100644 --- a/test/form/samples/function-scopes/_config.js +++ b/test/form/samples/function-scopes/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'properly associate or shadow variables in and around functions' -}; +}); diff --git a/test/form/samples/function-scopes/_expected/es.js b/test/form/samples/function-scopes/_expected.js similarity index 100% rename from test/form/samples/function-scopes/_expected/es.js rename to test/form/samples/function-scopes/_expected.js diff --git a/test/form/samples/function-scopes/_expected/amd.js b/test/form/samples/function-scopes/_expected/amd.js deleted file mode 100644 index fbfeceffe43..00000000000 --- a/test/form/samples/function-scopes/_expected/amd.js +++ /dev/null @@ -1,21 +0,0 @@ -define(function () { 'use strict'; - - var effect1 = () => console.log( 'effect' ); // must not be removed! - function isKept1 ( x = effect1 ) { - x(); - } - isKept1(); - - var effect2 = () => console.log( 'effect' ); // must not be removed! - var isKept2 = function ( x = effect2 ) { - x(); - }; - isKept2(); - - var effect3 = () => console.log( 'effect' ); // must not be removed! - var isKept3 = ( x = effect3 ) => { - x(); - }; - isKept3(); - -}); diff --git a/test/form/samples/function-scopes/_expected/cjs.js b/test/form/samples/function-scopes/_expected/cjs.js deleted file mode 100644 index 8200a3c4745..00000000000 --- a/test/form/samples/function-scopes/_expected/cjs.js +++ /dev/null @@ -1,19 +0,0 @@ -'use strict'; - -var effect1 = () => console.log( 'effect' ); // must not be removed! -function isKept1 ( x = effect1 ) { - x(); -} -isKept1(); - -var effect2 = () => console.log( 'effect' ); // must not be removed! -var isKept2 = function ( x = effect2 ) { - x(); -}; -isKept2(); - -var effect3 = () => console.log( 'effect' ); // must not be removed! -var isKept3 = ( x = effect3 ) => { - x(); -}; -isKept3(); diff --git a/test/form/samples/function-scopes/_expected/iife.js b/test/form/samples/function-scopes/_expected/iife.js deleted file mode 100644 index 4369e6543df..00000000000 --- a/test/form/samples/function-scopes/_expected/iife.js +++ /dev/null @@ -1,22 +0,0 @@ -(function () { - 'use strict'; - - var effect1 = () => console.log( 'effect' ); // must not be removed! - function isKept1 ( x = effect1 ) { - x(); - } - isKept1(); - - var effect2 = () => console.log( 'effect' ); // must not be removed! - var isKept2 = function ( x = effect2 ) { - x(); - }; - isKept2(); - - var effect3 = () => console.log( 'effect' ); // must not be removed! - var isKept3 = ( x = effect3 ) => { - x(); - }; - isKept3(); - -}()); diff --git a/test/form/samples/function-scopes/_expected/system.js b/test/form/samples/function-scopes/_expected/system.js deleted file mode 100644 index 2f36e9fa173..00000000000 --- a/test/form/samples/function-scopes/_expected/system.js +++ /dev/null @@ -1,26 +0,0 @@ -System.register([], function () { - 'use strict'; - return { - execute: function () { - - var effect1 = () => console.log( 'effect' ); // must not be removed! - function isKept1 ( x = effect1 ) { - x(); - } - isKept1(); - - var effect2 = () => console.log( 'effect' ); // must not be removed! - var isKept2 = function ( x = effect2 ) { - x(); - }; - isKept2(); - - var effect3 = () => console.log( 'effect' ); // must not be removed! - var isKept3 = ( x = effect3 ) => { - x(); - }; - isKept3(); - - } - }; -}); diff --git a/test/form/samples/function-scopes/_expected/umd.js b/test/form/samples/function-scopes/_expected/umd.js deleted file mode 100644 index 64465236861..00000000000 --- a/test/form/samples/function-scopes/_expected/umd.js +++ /dev/null @@ -1,24 +0,0 @@ -(function (factory) { - typeof define === 'function' && define.amd ? define(factory) : - factory(); -}((function () { 'use strict'; - - var effect1 = () => console.log( 'effect' ); // must not be removed! - function isKept1 ( x = effect1 ) { - x(); - } - isKept1(); - - var effect2 = () => console.log( 'effect' ); // must not be removed! - var isKept2 = function ( x = effect2 ) { - x(); - }; - isKept2(); - - var effect3 = () => console.log( 'effect' ); // must not be removed! - var isKept3 = ( x = effect3 ) => { - x(); - }; - isKept3(); - -}))); diff --git a/test/form/samples/generated-code-compact/arrow-functions-false/_config.js b/test/form/samples/generated-code-compact/arrow-functions-false/_config.js new file mode 100644 index 00000000000..f93370f7292 --- /dev/null +++ b/test/form/samples/generated-code-compact/arrow-functions-false/_config.js @@ -0,0 +1,35 @@ +module.exports = defineTest({ + description: 'does not use arrow functions', + options: { + external: [ + 'external', + 'externalAuto', + 'externalDefault', + 'externalDefaultOnly', + 'externalNoImport' + ], + strictDeprecations: false, + output: { + compact: true, + dynamicImportInCjs: false, + generatedCode: { arrowFunctions: false }, + interop(id) { + if (id === 'externalDefault') { + return 'default'; + } + if (id === 'externalDefaultOnly') { + return 'defaultOnly'; + } + if (id === 'externalAuto') { + return 'auto'; + } + return 'compat'; + }, + globals: id => id, + name: 'bundle', + noConflict: true, + systemNullSetters: false + } + }, + expectedWarnings: ['DEPRECATED_FEATURE'] +}); diff --git a/test/form/samples/generated-code-compact/arrow-functions-false/_expected/amd.js b/test/form/samples/generated-code-compact/arrow-functions-false/_expected/amd.js new file mode 100644 index 00000000000..0bbeba09101 --- /dev/null +++ b/test/form/samples/generated-code-compact/arrow-functions-false/_expected/amd.js @@ -0,0 +1,12 @@ +define(['require','exports','externalNoImport','external','externalAuto','externalDefault','externalDefaultOnly'],(function(require,exports,externalNoImport,defaultCompat,externalAuto,externalDefault,externalDefaultOnly){'use strict';function _interopDefault(e){return e&&e.__esModule?e:{default:e}}function _interopNamespaceCompat(e){return e&&typeof e==='object'&&'default'in e?e:_interopNamespaceDefault(e)}function _interopNamespaceDefaultOnly(e){return Object.freeze({__proto__:null,default:e})}function _interopNamespaceDefault(e){var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}function _mergeNamespaces(n, m){m.forEach(function(e){e&&typeof e!=='string'&&!Array.isArray(e)&&Object.keys(e).forEach(function(k){if(k!=='default'&&!(k in n)){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})});return Object.freeze(n);}var defaultCompat__namespace=/*#__PURE__*/_interopNamespaceCompat(defaultCompat);var externalAuto__default=/*#__PURE__*/_interopDefault(externalAuto);var externalDefault__namespace=/*#__PURE__*/_interopNamespaceDefault(externalDefault);var externalDefaultOnly__namespace=/*#__PURE__*/_interopNamespaceDefaultOnly(externalDefaultOnly);exports.a=void 0; + +({ a: exports.a } = defaultCompat.b); +console.log({ a: exports.a } = defaultCompat.b); + +Promise.resolve().then(function(){return main}).then(console.log); + +new Promise(function(c,e){require(['external'],function(m){c(/*#__PURE__*/_interopNamespaceCompat(m))},e)}).then(console.log); +console.log(defaultCompat__namespace.default); +console.log(externalAuto__default.default); +console.log(externalDefault__namespace); +console.log(externalDefaultOnly__namespace);var main=/*#__PURE__*/_mergeNamespaces({__proto__:null,get a(){return exports.a},foo:foo},[defaultCompat__namespace]);Object.defineProperty(exports,"foo",{enumerable:true,get:function(){return defaultCompat.foo}});Object.keys(defaultCompat).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return defaultCompat[k]}})});})); \ No newline at end of file diff --git a/test/form/samples/generated-code-compact/arrow-functions-false/_expected/cjs.js b/test/form/samples/generated-code-compact/arrow-functions-false/_expected/cjs.js new file mode 100644 index 00000000000..4c8e1edcfb2 --- /dev/null +++ b/test/form/samples/generated-code-compact/arrow-functions-false/_expected/cjs.js @@ -0,0 +1,12 @@ +'use strict';require('externalNoImport');var defaultCompat=require('external'),externalAuto=require('externalAuto'),externalDefault=require('externalDefault'),externalDefaultOnly=require('externalDefaultOnly');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}function _interopNamespaceCompat(e){return e&&typeof e==='object'&&'default'in e?e:_interopNamespaceDefault(e)}function _interopNamespaceDefaultOnly(e){return Object.freeze({__proto__:null,default:e})}function _interopNamespaceDefault(e){var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}function _mergeNamespaces(n, m){m.forEach(function(e){e&&typeof e!=='string'&&!Array.isArray(e)&&Object.keys(e).forEach(function(k){if(k!=='default'&&!(k in n)){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})});return Object.freeze(n);}var defaultCompat__namespace=/*#__PURE__*/_interopNamespaceCompat(defaultCompat);var externalAuto__default=/*#__PURE__*/_interopDefault(externalAuto);var externalDefault__namespace=/*#__PURE__*/_interopNamespaceDefault(externalDefault);var externalDefaultOnly__namespace=/*#__PURE__*/_interopNamespaceDefaultOnly(externalDefaultOnly);exports.a=void 0; + +({ a: exports.a } = defaultCompat.b); +console.log({ a: exports.a } = defaultCompat.b); + +Promise.resolve().then(function(){return main}).then(console.log); + +Promise.resolve().then(function(){return /*#__PURE__*/_interopNamespaceCompat(require('external'))}).then(console.log); +console.log(defaultCompat__namespace.default); +console.log(externalAuto__default.default); +console.log(externalDefault__namespace); +console.log(externalDefaultOnly__namespace);var main=/*#__PURE__*/_mergeNamespaces({__proto__:null,get a(){return exports.a},foo:foo},[defaultCompat__namespace]);Object.defineProperty(exports,"foo",{enumerable:true,get:function(){return defaultCompat.foo}});Object.keys(defaultCompat).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return defaultCompat[k]}})}); \ No newline at end of file diff --git a/test/form/samples/generated-code-compact/arrow-functions-false/_expected/es.js b/test/form/samples/generated-code-compact/arrow-functions-false/_expected/es.js new file mode 100644 index 00000000000..02ee2e9e379 --- /dev/null +++ b/test/form/samples/generated-code-compact/arrow-functions-false/_expected/es.js @@ -0,0 +1,12 @@ +import'externalNoImport';import*as defaultCompat from'external';import defaultCompat__default,{b}from'external';export*from'external';export{foo}from'external';import externalAuto from'externalAuto';import*as externalDefault from'externalDefault';import*as externalDefaultOnly from'externalDefaultOnly';function _mergeNamespaces(n, m){m.forEach(function(e){e&&typeof e!=='string'&&!Array.isArray(e)&&Object.keys(e).forEach(function(k){if(k!=='default'&&!(k in n)){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})});return Object.freeze(n);}let a; + +({ a } = b); +console.log({ a } = b); + +Promise.resolve().then(function(){return main}).then(console.log); + +import('external').then(console.log); +console.log(defaultCompat__default); +console.log(externalAuto); +console.log(externalDefault); +console.log(externalDefaultOnly);var main=/*#__PURE__*/_mergeNamespaces({__proto__:null,get a(){return a},foo:foo},[defaultCompat]);export{a}; \ No newline at end of file diff --git a/test/form/samples/generated-code-compact/arrow-functions-false/_expected/iife.js b/test/form/samples/generated-code-compact/arrow-functions-false/_expected/iife.js new file mode 100644 index 00000000000..d8628ad562f --- /dev/null +++ b/test/form/samples/generated-code-compact/arrow-functions-false/_expected/iife.js @@ -0,0 +1,12 @@ +var bundle=(function(exports,externalNoImport,defaultCompat,externalAuto,externalDefault,externalDefaultOnly){'use strict';function _interopDefault(e){return e&&e.__esModule?e:{default:e}}function _interopNamespaceCompat(e){return e&&typeof e==='object'&&'default'in e?e:_interopNamespaceDefault(e)}function _interopNamespaceDefaultOnly(e){return Object.freeze({__proto__:null,default:e})}function _interopNamespaceDefault(e){var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}function _mergeNamespaces(n, m){m.forEach(function(e){e&&typeof e!=='string'&&!Array.isArray(e)&&Object.keys(e).forEach(function(k){if(k!=='default'&&!(k in n)){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})});return Object.freeze(n);}var defaultCompat__namespace=/*#__PURE__*/_interopNamespaceCompat(defaultCompat);var externalAuto__default=/*#__PURE__*/_interopDefault(externalAuto);var externalDefault__namespace=/*#__PURE__*/_interopNamespaceDefault(externalDefault);var externalDefaultOnly__namespace=/*#__PURE__*/_interopNamespaceDefaultOnly(externalDefaultOnly);exports.a=void 0; + +({ a: exports.a } = defaultCompat.b); +console.log({ a: exports.a } = defaultCompat.b); + +Promise.resolve().then(function(){return main}).then(console.log); + +import('external').then(console.log); +console.log(defaultCompat__namespace.default); +console.log(externalAuto__default.default); +console.log(externalDefault__namespace); +console.log(externalDefaultOnly__namespace);var main=/*#__PURE__*/_mergeNamespaces({__proto__:null,get a(){return exports.a},foo:foo},[defaultCompat__namespace]);Object.defineProperty(exports,"foo",{enumerable:true,get:function(){return defaultCompat.foo}});Object.keys(defaultCompat).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return defaultCompat[k]}})});return exports;})({},externalNoImport,external,externalAuto,externalDefault,externalDefaultOnly); \ No newline at end of file diff --git a/test/form/samples/generated-code-compact/arrow-functions-false/_expected/system.js b/test/form/samples/generated-code-compact/arrow-functions-false/_expected/system.js new file mode 100644 index 00000000000..fc2ea83b71e --- /dev/null +++ b/test/form/samples/generated-code-compact/arrow-functions-false/_expected/system.js @@ -0,0 +1,12 @@ +System.register('bundle',['externalNoImport','external','externalAuto','externalDefault','externalDefaultOnly'],(function(exports,module){'use strict';var _starExcludes={__proto__:null,a:1,default:1,foo:1};var b,defaultCompat,defaultCompat__default,externalAuto,externalDefault,externalDefaultOnly;return{setters:[function(){},function(module){b=module.b;defaultCompat=module;defaultCompat__default=module.default;var setter={__proto__:null,foo:module.foo};for(var name in module){if(!_starExcludes[name])setter[name]=module[name];}exports(setter);},function(module){externalAuto=module.default;},function(module){externalDefault=module;},function(module){externalDefaultOnly=module;}],execute:(function(){function _mergeNamespaces(n, m){m.forEach(function(e){e&&typeof e!=='string'&&!Array.isArray(e)&&Object.keys(e).forEach(function(k){if(k!=='default'&&!(k in n)){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})});return Object.freeze(n);}let a; exports("a",a); + +(function(v){return exports("a",a),v})({ a } = b); +console.log(function(v){return exports("a",a),v}({ a } = b)); + +Promise.resolve().then(function(){return main}).then(console.log); + +module.import('external').then(console.log); +console.log(defaultCompat__default); +console.log(externalAuto); +console.log(externalDefault); +console.log(externalDefaultOnly);var main=/*#__PURE__*/_mergeNamespaces({__proto__:null,get a(){return a},foo:foo},[defaultCompat]);})}})); \ No newline at end of file diff --git a/test/form/samples/generated-code-compact/arrow-functions-false/_expected/umd.js b/test/form/samples/generated-code-compact/arrow-functions-false/_expected/umd.js new file mode 100644 index 00000000000..b8021e1ad6e --- /dev/null +++ b/test/form/samples/generated-code-compact/arrow-functions-false/_expected/umd.js @@ -0,0 +1,12 @@ +(function(g,f){typeof exports==='object'&&typeof module!=='undefined'?f(exports,require('externalNoImport'),require('external'),require('externalAuto'),require('externalDefault'),require('externalDefaultOnly')):typeof define==='function'&&define.amd?define(['exports','externalNoImport','external','externalAuto','externalDefault','externalDefaultOnly'],f):(g=typeof globalThis!=='undefined'?globalThis:g||self,(function(){var current=g.bundle;var e=g.bundle={};f(e,g.externalNoImport,g.external,g.externalAuto,g.externalDefault,g.externalDefaultOnly);e.noConflict=function(){g.bundle=current;return e};})());})(this,(function(exports,externalNoImport,defaultCompat,externalAuto,externalDefault,externalDefaultOnly){'use strict';function _interopDefault(e){return e&&e.__esModule?e:{default:e}}function _interopNamespaceCompat(e){return e&&typeof e==='object'&&'default'in e?e:_interopNamespaceDefault(e)}function _interopNamespaceDefaultOnly(e){return Object.freeze({__proto__:null,default:e})}function _interopNamespaceDefault(e){var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}function _mergeNamespaces(n, m){m.forEach(function(e){e&&typeof e!=='string'&&!Array.isArray(e)&&Object.keys(e).forEach(function(k){if(k!=='default'&&!(k in n)){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})});return Object.freeze(n);}var defaultCompat__namespace=/*#__PURE__*/_interopNamespaceCompat(defaultCompat);var externalAuto__default=/*#__PURE__*/_interopDefault(externalAuto);var externalDefault__namespace=/*#__PURE__*/_interopNamespaceDefault(externalDefault);var externalDefaultOnly__namespace=/*#__PURE__*/_interopNamespaceDefaultOnly(externalDefaultOnly);exports.a=void 0; + +({ a: exports.a } = defaultCompat.b); +console.log({ a: exports.a } = defaultCompat.b); + +Promise.resolve().then(function(){return main}).then(console.log); + +import('external').then(console.log); +console.log(defaultCompat__namespace.default); +console.log(externalAuto__default.default); +console.log(externalDefault__namespace); +console.log(externalDefaultOnly__namespace);var main=/*#__PURE__*/_mergeNamespaces({__proto__:null,get a(){return exports.a},foo:foo},[defaultCompat__namespace]);Object.defineProperty(exports,"foo",{enumerable:true,get:function(){return defaultCompat.foo}});Object.keys(defaultCompat).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return defaultCompat[k]}})});})); \ No newline at end of file diff --git a/test/form/samples/generated-code-compact/arrow-functions-false/main.js b/test/form/samples/generated-code-compact/arrow-functions-false/main.js new file mode 120000 index 00000000000..85a708339de --- /dev/null +++ b/test/form/samples/generated-code-compact/arrow-functions-false/main.js @@ -0,0 +1 @@ +../../generated-code/arrow-functions-false/main.js \ No newline at end of file diff --git a/test/form/samples/generated-code-compact/arrow-functions-true/_config.js b/test/form/samples/generated-code-compact/arrow-functions-true/_config.js new file mode 100644 index 00000000000..26854739dff --- /dev/null +++ b/test/form/samples/generated-code-compact/arrow-functions-true/_config.js @@ -0,0 +1,35 @@ +module.exports = defineTest({ + description: 'uses arrow functions', + options: { + external: [ + 'external', + 'externalAuto', + 'externalDefault', + 'externalDefaultOnly', + 'externalNoImport' + ], + strictDeprecations: false, + output: { + compact: true, + dynamicImportInCjs: false, + generatedCode: { arrowFunctions: true }, + globals: id => id, + interop(id) { + if (id === 'externalDefault') { + return 'default'; + } + if (id === 'externalDefaultOnly') { + return 'defaultOnly'; + } + if (id === 'externalAuto') { + return 'auto'; + } + return 'compat'; + }, + name: 'bundle', + noConflict: true, + systemNullSetters: false + } + }, + expectedWarnings: ['DEPRECATED_FEATURE'] +}); diff --git a/test/form/samples/generated-code-compact/arrow-functions-true/_expected/amd.js b/test/form/samples/generated-code-compact/arrow-functions-true/_expected/amd.js new file mode 100644 index 00000000000..1a6d6cde553 --- /dev/null +++ b/test/form/samples/generated-code-compact/arrow-functions-true/_expected/amd.js @@ -0,0 +1,12 @@ +define(['require','exports','externalNoImport','external','externalAuto','externalDefault','externalDefaultOnly'],(function(require,exports,externalNoImport,defaultCompat,externalAuto,externalDefault,externalDefaultOnly){'use strict';var _interopDefault=e=>e&&e.__esModule?e:{default:e};var _interopNamespaceCompat=e=>e&&typeof e==='object'&&'default'in e?e:_interopNamespaceDefault(e);var _interopNamespaceDefaultOnly=e=>Object.freeze({__proto__:null,default:e});function _interopNamespaceDefault(e){var n=Object.create(null);if(e){Object.keys(e).forEach(k=>{if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:()=>e[k]});}})}n.default=e;return Object.freeze(n)}function _mergeNamespaces(n, m){m.forEach(e=>e&&typeof e!=='string'&&!Array.isArray(e)&&Object.keys(e).forEach(k=>{if(k!=='default'&&!(k in n)){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:()=>e[k]});}}));return Object.freeze(n);}var defaultCompat__namespace=/*#__PURE__*/_interopNamespaceCompat(defaultCompat);var externalAuto__default=/*#__PURE__*/_interopDefault(externalAuto);var externalDefault__namespace=/*#__PURE__*/_interopNamespaceDefault(externalDefault);var externalDefaultOnly__namespace=/*#__PURE__*/_interopNamespaceDefaultOnly(externalDefaultOnly);exports.a=void 0; + +({ a: exports.a } = defaultCompat.b); +console.log({ a: exports.a } = defaultCompat.b); + +Promise.resolve().then(()=>main).then(console.log); + +new Promise((c,e)=>require(['external'],m=>c(/*#__PURE__*/_interopNamespaceCompat(m)),e)).then(console.log); +console.log(defaultCompat__namespace.default); +console.log(externalAuto__default.default); +console.log(externalDefault__namespace); +console.log(externalDefaultOnly__namespace);var main=/*#__PURE__*/_mergeNamespaces({__proto__:null,get a(){return exports.a},foo:foo},[defaultCompat__namespace]);Object.defineProperty(exports,"foo",{enumerable:true,get:()=>defaultCompat.foo});Object.keys(defaultCompat).forEach(k=>{if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:()=>defaultCompat[k]})});})); \ No newline at end of file diff --git a/test/form/samples/generated-code-compact/arrow-functions-true/_expected/cjs.js b/test/form/samples/generated-code-compact/arrow-functions-true/_expected/cjs.js new file mode 100644 index 00000000000..7bbc1fcd124 --- /dev/null +++ b/test/form/samples/generated-code-compact/arrow-functions-true/_expected/cjs.js @@ -0,0 +1,12 @@ +'use strict';require('externalNoImport');var defaultCompat=require('external'),externalAuto=require('externalAuto'),externalDefault=require('externalDefault'),externalDefaultOnly=require('externalDefaultOnly');var _interopDefault=e=>e&&e.__esModule?e:{default:e};var _interopNamespaceCompat=e=>e&&typeof e==='object'&&'default'in e?e:_interopNamespaceDefault(e);var _interopNamespaceDefaultOnly=e=>Object.freeze({__proto__:null,default:e});function _interopNamespaceDefault(e){var n=Object.create(null);if(e){Object.keys(e).forEach(k=>{if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:()=>e[k]});}})}n.default=e;return Object.freeze(n)}function _mergeNamespaces(n, m){m.forEach(e=>e&&typeof e!=='string'&&!Array.isArray(e)&&Object.keys(e).forEach(k=>{if(k!=='default'&&!(k in n)){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:()=>e[k]});}}));return Object.freeze(n);}var defaultCompat__namespace=/*#__PURE__*/_interopNamespaceCompat(defaultCompat);var externalAuto__default=/*#__PURE__*/_interopDefault(externalAuto);var externalDefault__namespace=/*#__PURE__*/_interopNamespaceDefault(externalDefault);var externalDefaultOnly__namespace=/*#__PURE__*/_interopNamespaceDefaultOnly(externalDefaultOnly);exports.a=void 0; + +({ a: exports.a } = defaultCompat.b); +console.log({ a: exports.a } = defaultCompat.b); + +Promise.resolve().then(()=>main).then(console.log); + +Promise.resolve().then(()=>/*#__PURE__*/_interopNamespaceCompat(require('external'))).then(console.log); +console.log(defaultCompat__namespace.default); +console.log(externalAuto__default.default); +console.log(externalDefault__namespace); +console.log(externalDefaultOnly__namespace);var main=/*#__PURE__*/_mergeNamespaces({__proto__:null,get a(){return exports.a},foo:foo},[defaultCompat__namespace]);Object.defineProperty(exports,"foo",{enumerable:true,get:()=>defaultCompat.foo});Object.keys(defaultCompat).forEach(k=>{if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:()=>defaultCompat[k]})}); \ No newline at end of file diff --git a/test/form/samples/generated-code-compact/arrow-functions-true/_expected/es.js b/test/form/samples/generated-code-compact/arrow-functions-true/_expected/es.js new file mode 100644 index 00000000000..76de101e176 --- /dev/null +++ b/test/form/samples/generated-code-compact/arrow-functions-true/_expected/es.js @@ -0,0 +1,12 @@ +import'externalNoImport';import*as defaultCompat from'external';import defaultCompat__default,{b}from'external';export*from'external';export{foo}from'external';import externalAuto from'externalAuto';import*as externalDefault from'externalDefault';import*as externalDefaultOnly from'externalDefaultOnly';function _mergeNamespaces(n, m){m.forEach(e=>e&&typeof e!=='string'&&!Array.isArray(e)&&Object.keys(e).forEach(k=>{if(k!=='default'&&!(k in n)){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:()=>e[k]});}}));return Object.freeze(n);}let a; + +({ a } = b); +console.log({ a } = b); + +Promise.resolve().then(()=>main).then(console.log); + +import('external').then(console.log); +console.log(defaultCompat__default); +console.log(externalAuto); +console.log(externalDefault); +console.log(externalDefaultOnly);var main=/*#__PURE__*/_mergeNamespaces({__proto__:null,get a(){return a},foo:foo},[defaultCompat]);export{a}; \ No newline at end of file diff --git a/test/form/samples/generated-code-compact/arrow-functions-true/_expected/iife.js b/test/form/samples/generated-code-compact/arrow-functions-true/_expected/iife.js new file mode 100644 index 00000000000..ef54a8c317b --- /dev/null +++ b/test/form/samples/generated-code-compact/arrow-functions-true/_expected/iife.js @@ -0,0 +1,12 @@ +var bundle=(function(exports,externalNoImport,defaultCompat,externalAuto,externalDefault,externalDefaultOnly){'use strict';var _interopDefault=e=>e&&e.__esModule?e:{default:e};var _interopNamespaceCompat=e=>e&&typeof e==='object'&&'default'in e?e:_interopNamespaceDefault(e);var _interopNamespaceDefaultOnly=e=>Object.freeze({__proto__:null,default:e});function _interopNamespaceDefault(e){var n=Object.create(null);if(e){Object.keys(e).forEach(k=>{if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:()=>e[k]});}})}n.default=e;return Object.freeze(n)}function _mergeNamespaces(n, m){m.forEach(e=>e&&typeof e!=='string'&&!Array.isArray(e)&&Object.keys(e).forEach(k=>{if(k!=='default'&&!(k in n)){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:()=>e[k]});}}));return Object.freeze(n);}var defaultCompat__namespace=/*#__PURE__*/_interopNamespaceCompat(defaultCompat);var externalAuto__default=/*#__PURE__*/_interopDefault(externalAuto);var externalDefault__namespace=/*#__PURE__*/_interopNamespaceDefault(externalDefault);var externalDefaultOnly__namespace=/*#__PURE__*/_interopNamespaceDefaultOnly(externalDefaultOnly);exports.a=void 0; + +({ a: exports.a } = defaultCompat.b); +console.log({ a: exports.a } = defaultCompat.b); + +Promise.resolve().then(()=>main).then(console.log); + +import('external').then(console.log); +console.log(defaultCompat__namespace.default); +console.log(externalAuto__default.default); +console.log(externalDefault__namespace); +console.log(externalDefaultOnly__namespace);var main=/*#__PURE__*/_mergeNamespaces({__proto__:null,get a(){return exports.a},foo:foo},[defaultCompat__namespace]);Object.defineProperty(exports,"foo",{enumerable:true,get:()=>defaultCompat.foo});Object.keys(defaultCompat).forEach(k=>{if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:()=>defaultCompat[k]})});return exports;})({},externalNoImport,external,externalAuto,externalDefault,externalDefaultOnly); \ No newline at end of file diff --git a/test/form/samples/generated-code-compact/arrow-functions-true/_expected/system.js b/test/form/samples/generated-code-compact/arrow-functions-true/_expected/system.js new file mode 100644 index 00000000000..c9bf2b5a52b --- /dev/null +++ b/test/form/samples/generated-code-compact/arrow-functions-true/_expected/system.js @@ -0,0 +1,12 @@ +System.register('bundle',['externalNoImport','external','externalAuto','externalDefault','externalDefaultOnly'],(function(exports,module){'use strict';var _starExcludes={__proto__:null,a:1,default:1,foo:1};var b,defaultCompat,defaultCompat__default,externalAuto,externalDefault,externalDefaultOnly;return{setters:[()=>{},module=>{b=module.b;defaultCompat=module;defaultCompat__default=module.default;var setter={__proto__:null,foo:module.foo};for(var name in module){if(!_starExcludes[name])setter[name]=module[name];}exports(setter);},module=>{externalAuto=module.default;},module=>{externalDefault=module;},module=>{externalDefaultOnly=module;}],execute:(function(){function _mergeNamespaces(n, m){m.forEach(e=>e&&typeof e!=='string'&&!Array.isArray(e)&&Object.keys(e).forEach(k=>{if(k!=='default'&&!(k in n)){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:()=>e[k]});}}));return Object.freeze(n);}let a; exports("a",a); + +(v=>(exports("a",a),v))({ a } = b); +console.log((v=>(exports("a",a),v))({ a } = b)); + +Promise.resolve().then(()=>main).then(console.log); + +module.import('external').then(console.log); +console.log(defaultCompat__default); +console.log(externalAuto); +console.log(externalDefault); +console.log(externalDefaultOnly);var main=/*#__PURE__*/_mergeNamespaces({__proto__:null,get a(){return a},foo:foo},[defaultCompat]);})}})); \ No newline at end of file diff --git a/test/form/samples/generated-code-compact/arrow-functions-true/_expected/umd.js b/test/form/samples/generated-code-compact/arrow-functions-true/_expected/umd.js new file mode 100644 index 00000000000..b7f0f1f1659 --- /dev/null +++ b/test/form/samples/generated-code-compact/arrow-functions-true/_expected/umd.js @@ -0,0 +1,12 @@ +(function(g,f){typeof exports==='object'&&typeof module!=='undefined'?f(exports,require('externalNoImport'),require('external'),require('externalAuto'),require('externalDefault'),require('externalDefaultOnly')):typeof define==='function'&&define.amd?define(['exports','externalNoImport','external','externalAuto','externalDefault','externalDefaultOnly'],f):(g=typeof globalThis!=='undefined'?globalThis:g||self,(()=>{var current=g.bundle;var e=g.bundle={};f(e,g.externalNoImport,g.external,g.externalAuto,g.externalDefault,g.externalDefaultOnly);e.noConflict=()=>{g.bundle=current;return e};})());})(this,(function(exports,externalNoImport,defaultCompat,externalAuto,externalDefault,externalDefaultOnly){'use strict';var _interopDefault=e=>e&&e.__esModule?e:{default:e};var _interopNamespaceCompat=e=>e&&typeof e==='object'&&'default'in e?e:_interopNamespaceDefault(e);var _interopNamespaceDefaultOnly=e=>Object.freeze({__proto__:null,default:e});function _interopNamespaceDefault(e){var n=Object.create(null);if(e){Object.keys(e).forEach(k=>{if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:()=>e[k]});}})}n.default=e;return Object.freeze(n)}function _mergeNamespaces(n, m){m.forEach(e=>e&&typeof e!=='string'&&!Array.isArray(e)&&Object.keys(e).forEach(k=>{if(k!=='default'&&!(k in n)){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:()=>e[k]});}}));return Object.freeze(n);}var defaultCompat__namespace=/*#__PURE__*/_interopNamespaceCompat(defaultCompat);var externalAuto__default=/*#__PURE__*/_interopDefault(externalAuto);var externalDefault__namespace=/*#__PURE__*/_interopNamespaceDefault(externalDefault);var externalDefaultOnly__namespace=/*#__PURE__*/_interopNamespaceDefaultOnly(externalDefaultOnly);exports.a=void 0; + +({ a: exports.a } = defaultCompat.b); +console.log({ a: exports.a } = defaultCompat.b); + +Promise.resolve().then(()=>main).then(console.log); + +import('external').then(console.log); +console.log(defaultCompat__namespace.default); +console.log(externalAuto__default.default); +console.log(externalDefault__namespace); +console.log(externalDefaultOnly__namespace);var main=/*#__PURE__*/_mergeNamespaces({__proto__:null,get a(){return exports.a},foo:foo},[defaultCompat__namespace]);Object.defineProperty(exports,"foo",{enumerable:true,get:()=>defaultCompat.foo});Object.keys(defaultCompat).forEach(k=>{if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:()=>defaultCompat[k]})});})); \ No newline at end of file diff --git a/test/form/samples/generated-code-compact/arrow-functions-true/main.js b/test/form/samples/generated-code-compact/arrow-functions-true/main.js new file mode 120000 index 00000000000..85a708339de --- /dev/null +++ b/test/form/samples/generated-code-compact/arrow-functions-true/main.js @@ -0,0 +1 @@ +../../generated-code/arrow-functions-false/main.js \ No newline at end of file diff --git a/test/form/samples/generated-code-compact/const-bindings-false/_config.js b/test/form/samples/generated-code-compact/const-bindings-false/_config.js new file mode 100644 index 00000000000..6ce9ba093fa --- /dev/null +++ b/test/form/samples/generated-code-compact/const-bindings-false/_config.js @@ -0,0 +1,27 @@ +module.exports = defineTest({ + description: 'does not use block bindings', + expectedWarnings: ['SHIMMED_EXPORT'], + options: { + external: ['external'], + shimMissingExports: true, + output: { + compact: true, + exports: 'named', + generatedCode: { arrowFunctions: true, constBindings: true }, + globals: id => id, + interop: 'compat', + name: 'bundle', + noConflict: true + }, + plugins: [ + { + name: 'test', + transform(code, id) { + if (id.endsWith('synthetic.js')) { + return { syntheticNamedExports: true }; + } + } + } + ] + } +}); diff --git a/test/form/samples/generated-code-compact/const-bindings-false/_expected/amd.js b/test/form/samples/generated-code-compact/const-bindings-false/_expected/amd.js new file mode 100644 index 00000000000..c216c01229c --- /dev/null +++ b/test/form/samples/generated-code-compact/const-bindings-false/_expected/amd.js @@ -0,0 +1,2 @@ +define(['exports','external'],(function(exports,foo$1){'use strict';function _interopNamespaceCompat(e){if(e&&typeof e==='object'&&'default'in e)return e;const n=Object.create(null);if(e){for(const k in e){if(k!=='default'){const d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:()=>e[k]});}}}n.default=e;return Object.freeze(n)}const foo__namespace=/*#__PURE__*/_interopNamespaceCompat(foo$1);const _missingExportShim=void 0;const foo = 'bar';const other=/*#__PURE__*/Object.freeze({__proto__:null,foo:foo,missing:_missingExportShim});const synthetic = { bar: 'baz'};console.log(foo__namespace.default, foo__namespace, other, synthetic.bar, _missingExportShim); +const main = 42;exports.default=main;exports.syntheticMissing=synthetic.syntheticMissing;Object.keys(foo$1).forEach(k=>{if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:()=>foo$1[k]})});Object.defineProperty(exports,'__esModule',{value:true});})); \ No newline at end of file diff --git a/test/form/samples/generated-code-compact/const-bindings-false/_expected/cjs.js b/test/form/samples/generated-code-compact/const-bindings-false/_expected/cjs.js new file mode 100644 index 00000000000..7f898d8d678 --- /dev/null +++ b/test/form/samples/generated-code-compact/const-bindings-false/_expected/cjs.js @@ -0,0 +1,2 @@ +'use strict';Object.defineProperty(exports,'__esModule',{value:true});const foo$1=require('external');function _interopNamespaceCompat(e){if(e&&typeof e==='object'&&'default'in e)return e;const n=Object.create(null);if(e){for(const k in e){if(k!=='default'){const d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:()=>e[k]});}}}n.default=e;return Object.freeze(n)}const foo__namespace=/*#__PURE__*/_interopNamespaceCompat(foo$1);const _missingExportShim=void 0;const foo = 'bar';const other=/*#__PURE__*/Object.freeze({__proto__:null,foo:foo,missing:_missingExportShim});const synthetic = { bar: 'baz'};console.log(foo__namespace.default, foo__namespace, other, synthetic.bar, _missingExportShim); +const main = 42;exports.default=main;exports.syntheticMissing=synthetic.syntheticMissing;Object.keys(foo$1).forEach(k=>{if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:()=>foo$1[k]})}); \ No newline at end of file diff --git a/test/form/samples/generated-code-compact/const-bindings-false/_expected/es.js b/test/form/samples/generated-code-compact/const-bindings-false/_expected/es.js new file mode 100644 index 00000000000..73038ab0ed5 --- /dev/null +++ b/test/form/samples/generated-code-compact/const-bindings-false/_expected/es.js @@ -0,0 +1,2 @@ +import*as foo$1 from'external';import foo__default from'external';export*from'external';const _missingExportShim=void 0;const foo = 'bar';const other=/*#__PURE__*/Object.freeze({__proto__:null,foo:foo,missing:_missingExportShim});const synthetic = { bar: 'baz'};console.log(foo__default, foo$1, other, synthetic.bar, _missingExportShim); +const main = 42;const syntheticMissing=synthetic.syntheticMissing;export{main as default,syntheticMissing}; \ No newline at end of file diff --git a/test/form/samples/generated-code-compact/const-bindings-false/_expected/iife.js b/test/form/samples/generated-code-compact/const-bindings-false/_expected/iife.js new file mode 100644 index 00000000000..54eacb59754 --- /dev/null +++ b/test/form/samples/generated-code-compact/const-bindings-false/_expected/iife.js @@ -0,0 +1,2 @@ +var bundle=(function(exports,foo$1){'use strict';function _interopNamespaceCompat(e){if(e&&typeof e==='object'&&'default'in e)return e;const n=Object.create(null);if(e){for(const k in e){if(k!=='default'){const d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:()=>e[k]});}}}n.default=e;return Object.freeze(n)}const foo__namespace=/*#__PURE__*/_interopNamespaceCompat(foo$1);const _missingExportShim=void 0;const foo = 'bar';const other=/*#__PURE__*/Object.freeze({__proto__:null,foo:foo,missing:_missingExportShim});const synthetic = { bar: 'baz'};console.log(foo__namespace.default, foo__namespace, other, synthetic.bar, _missingExportShim); +const main = 42;exports.default=main;exports.syntheticMissing=synthetic.syntheticMissing;Object.keys(foo$1).forEach(k=>{if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:()=>foo$1[k]})});Object.defineProperty(exports,'__esModule',{value:true});return exports;})({},external); \ No newline at end of file diff --git a/test/form/samples/generated-code-compact/const-bindings-false/_expected/system.js b/test/form/samples/generated-code-compact/const-bindings-false/_expected/system.js new file mode 100644 index 00000000000..14ddec224d4 --- /dev/null +++ b/test/form/samples/generated-code-compact/const-bindings-false/_expected/system.js @@ -0,0 +1,2 @@ +System.register('bundle',['external'],(function(exports){'use strict';const _starExcludes={__proto__:null,default:1,syntheticMissing:1};var foo__default,foo$1;return{setters:[module=>{foo__default=module.default;foo$1=module;const setter={__proto__:null};for(const name in module){if(!_starExcludes[name])setter[name]=module[name];}exports(setter);}],execute:(function(){const _missingExportShim=void 0;const foo = 'bar';const other=/*#__PURE__*/Object.freeze({__proto__:null,foo:foo,missing:_missingExportShim});const synthetic = { bar: 'baz'};console.log(foo__default, foo$1, other, synthetic.bar, _missingExportShim); +const main = exports("default", 42);exports("syntheticMissing",synthetic.syntheticMissing);})}})); \ No newline at end of file diff --git a/test/form/samples/generated-code-compact/const-bindings-false/_expected/umd.js b/test/form/samples/generated-code-compact/const-bindings-false/_expected/umd.js new file mode 100644 index 00000000000..0d6a583f1b3 --- /dev/null +++ b/test/form/samples/generated-code-compact/const-bindings-false/_expected/umd.js @@ -0,0 +1,2 @@ +(function(g,f){typeof exports==='object'&&typeof module!=='undefined'?f(exports,require('external')):typeof define==='function'&&define.amd?define(['exports','external'],f):(g=typeof globalThis!=='undefined'?globalThis:g||self,(()=>{const current=g.bundle;const e=g.bundle={};f(e,g.external);e.noConflict=()=>{g.bundle=current;return e};})());})(this,(function(exports,foo$1){'use strict';function _interopNamespaceCompat(e){if(e&&typeof e==='object'&&'default'in e)return e;const n=Object.create(null);if(e){for(const k in e){if(k!=='default'){const d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:()=>e[k]});}}}n.default=e;return Object.freeze(n)}const foo__namespace=/*#__PURE__*/_interopNamespaceCompat(foo$1);const _missingExportShim=void 0;const foo = 'bar';const other=/*#__PURE__*/Object.freeze({__proto__:null,foo:foo,missing:_missingExportShim});const synthetic = { bar: 'baz'};console.log(foo__namespace.default, foo__namespace, other, synthetic.bar, _missingExportShim); +const main = 42;exports.default=main;exports.syntheticMissing=synthetic.syntheticMissing;Object.keys(foo$1).forEach(k=>{if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:()=>foo$1[k]})});Object.defineProperty(exports,'__esModule',{value:true});})); \ No newline at end of file diff --git a/test/form/samples/generated-code-compact/const-bindings-false/main.js b/test/form/samples/generated-code-compact/const-bindings-false/main.js new file mode 120000 index 00000000000..3fa65076585 --- /dev/null +++ b/test/form/samples/generated-code-compact/const-bindings-false/main.js @@ -0,0 +1 @@ +../../generated-code/const-bindings-false/main.js \ No newline at end of file diff --git a/test/form/samples/generated-code-compact/const-bindings-true/_config.js b/test/form/samples/generated-code-compact/const-bindings-true/_config.js new file mode 100644 index 00000000000..cd4ab42308c --- /dev/null +++ b/test/form/samples/generated-code-compact/const-bindings-true/_config.js @@ -0,0 +1,27 @@ +module.exports = defineTest({ + description: 'uses block bindings', + expectedWarnings: ['SHIMMED_EXPORT'], + options: { + external: ['external'], + shimMissingExports: true, + output: { + compact: true, + exports: 'named', + generatedCode: { arrowFunctions: true, constBindings: true }, + globals: id => id, + interop: 'compat', + name: 'bundle', + noConflict: true + }, + plugins: [ + { + name: 'test', + transform(code, id) { + if (id.endsWith('synthetic.js')) { + return { syntheticNamedExports: true }; + } + } + } + ] + } +}); diff --git a/test/form/samples/generated-code-compact/const-bindings-true/_expected/amd.js b/test/form/samples/generated-code-compact/const-bindings-true/_expected/amd.js new file mode 100644 index 00000000000..c216c01229c --- /dev/null +++ b/test/form/samples/generated-code-compact/const-bindings-true/_expected/amd.js @@ -0,0 +1,2 @@ +define(['exports','external'],(function(exports,foo$1){'use strict';function _interopNamespaceCompat(e){if(e&&typeof e==='object'&&'default'in e)return e;const n=Object.create(null);if(e){for(const k in e){if(k!=='default'){const d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:()=>e[k]});}}}n.default=e;return Object.freeze(n)}const foo__namespace=/*#__PURE__*/_interopNamespaceCompat(foo$1);const _missingExportShim=void 0;const foo = 'bar';const other=/*#__PURE__*/Object.freeze({__proto__:null,foo:foo,missing:_missingExportShim});const synthetic = { bar: 'baz'};console.log(foo__namespace.default, foo__namespace, other, synthetic.bar, _missingExportShim); +const main = 42;exports.default=main;exports.syntheticMissing=synthetic.syntheticMissing;Object.keys(foo$1).forEach(k=>{if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:()=>foo$1[k]})});Object.defineProperty(exports,'__esModule',{value:true});})); \ No newline at end of file diff --git a/test/form/samples/generated-code-compact/const-bindings-true/_expected/cjs.js b/test/form/samples/generated-code-compact/const-bindings-true/_expected/cjs.js new file mode 100644 index 00000000000..7f898d8d678 --- /dev/null +++ b/test/form/samples/generated-code-compact/const-bindings-true/_expected/cjs.js @@ -0,0 +1,2 @@ +'use strict';Object.defineProperty(exports,'__esModule',{value:true});const foo$1=require('external');function _interopNamespaceCompat(e){if(e&&typeof e==='object'&&'default'in e)return e;const n=Object.create(null);if(e){for(const k in e){if(k!=='default'){const d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:()=>e[k]});}}}n.default=e;return Object.freeze(n)}const foo__namespace=/*#__PURE__*/_interopNamespaceCompat(foo$1);const _missingExportShim=void 0;const foo = 'bar';const other=/*#__PURE__*/Object.freeze({__proto__:null,foo:foo,missing:_missingExportShim});const synthetic = { bar: 'baz'};console.log(foo__namespace.default, foo__namespace, other, synthetic.bar, _missingExportShim); +const main = 42;exports.default=main;exports.syntheticMissing=synthetic.syntheticMissing;Object.keys(foo$1).forEach(k=>{if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:()=>foo$1[k]})}); \ No newline at end of file diff --git a/test/form/samples/generated-code-compact/const-bindings-true/_expected/es.js b/test/form/samples/generated-code-compact/const-bindings-true/_expected/es.js new file mode 100644 index 00000000000..73038ab0ed5 --- /dev/null +++ b/test/form/samples/generated-code-compact/const-bindings-true/_expected/es.js @@ -0,0 +1,2 @@ +import*as foo$1 from'external';import foo__default from'external';export*from'external';const _missingExportShim=void 0;const foo = 'bar';const other=/*#__PURE__*/Object.freeze({__proto__:null,foo:foo,missing:_missingExportShim});const synthetic = { bar: 'baz'};console.log(foo__default, foo$1, other, synthetic.bar, _missingExportShim); +const main = 42;const syntheticMissing=synthetic.syntheticMissing;export{main as default,syntheticMissing}; \ No newline at end of file diff --git a/test/form/samples/generated-code-compact/const-bindings-true/_expected/iife.js b/test/form/samples/generated-code-compact/const-bindings-true/_expected/iife.js new file mode 100644 index 00000000000..54eacb59754 --- /dev/null +++ b/test/form/samples/generated-code-compact/const-bindings-true/_expected/iife.js @@ -0,0 +1,2 @@ +var bundle=(function(exports,foo$1){'use strict';function _interopNamespaceCompat(e){if(e&&typeof e==='object'&&'default'in e)return e;const n=Object.create(null);if(e){for(const k in e){if(k!=='default'){const d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:()=>e[k]});}}}n.default=e;return Object.freeze(n)}const foo__namespace=/*#__PURE__*/_interopNamespaceCompat(foo$1);const _missingExportShim=void 0;const foo = 'bar';const other=/*#__PURE__*/Object.freeze({__proto__:null,foo:foo,missing:_missingExportShim});const synthetic = { bar: 'baz'};console.log(foo__namespace.default, foo__namespace, other, synthetic.bar, _missingExportShim); +const main = 42;exports.default=main;exports.syntheticMissing=synthetic.syntheticMissing;Object.keys(foo$1).forEach(k=>{if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:()=>foo$1[k]})});Object.defineProperty(exports,'__esModule',{value:true});return exports;})({},external); \ No newline at end of file diff --git a/test/form/samples/generated-code-compact/const-bindings-true/_expected/system.js b/test/form/samples/generated-code-compact/const-bindings-true/_expected/system.js new file mode 100644 index 00000000000..14ddec224d4 --- /dev/null +++ b/test/form/samples/generated-code-compact/const-bindings-true/_expected/system.js @@ -0,0 +1,2 @@ +System.register('bundle',['external'],(function(exports){'use strict';const _starExcludes={__proto__:null,default:1,syntheticMissing:1};var foo__default,foo$1;return{setters:[module=>{foo__default=module.default;foo$1=module;const setter={__proto__:null};for(const name in module){if(!_starExcludes[name])setter[name]=module[name];}exports(setter);}],execute:(function(){const _missingExportShim=void 0;const foo = 'bar';const other=/*#__PURE__*/Object.freeze({__proto__:null,foo:foo,missing:_missingExportShim});const synthetic = { bar: 'baz'};console.log(foo__default, foo$1, other, synthetic.bar, _missingExportShim); +const main = exports("default", 42);exports("syntheticMissing",synthetic.syntheticMissing);})}})); \ No newline at end of file diff --git a/test/form/samples/generated-code-compact/const-bindings-true/_expected/umd.js b/test/form/samples/generated-code-compact/const-bindings-true/_expected/umd.js new file mode 100644 index 00000000000..0d6a583f1b3 --- /dev/null +++ b/test/form/samples/generated-code-compact/const-bindings-true/_expected/umd.js @@ -0,0 +1,2 @@ +(function(g,f){typeof exports==='object'&&typeof module!=='undefined'?f(exports,require('external')):typeof define==='function'&&define.amd?define(['exports','external'],f):(g=typeof globalThis!=='undefined'?globalThis:g||self,(()=>{const current=g.bundle;const e=g.bundle={};f(e,g.external);e.noConflict=()=>{g.bundle=current;return e};})());})(this,(function(exports,foo$1){'use strict';function _interopNamespaceCompat(e){if(e&&typeof e==='object'&&'default'in e)return e;const n=Object.create(null);if(e){for(const k in e){if(k!=='default'){const d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:()=>e[k]});}}}n.default=e;return Object.freeze(n)}const foo__namespace=/*#__PURE__*/_interopNamespaceCompat(foo$1);const _missingExportShim=void 0;const foo = 'bar';const other=/*#__PURE__*/Object.freeze({__proto__:null,foo:foo,missing:_missingExportShim});const synthetic = { bar: 'baz'};console.log(foo__namespace.default, foo__namespace, other, synthetic.bar, _missingExportShim); +const main = 42;exports.default=main;exports.syntheticMissing=synthetic.syntheticMissing;Object.keys(foo$1).forEach(k=>{if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:()=>foo$1[k]})});Object.defineProperty(exports,'__esModule',{value:true});})); \ No newline at end of file diff --git a/test/form/samples/generated-code-compact/const-bindings-true/main.js b/test/form/samples/generated-code-compact/const-bindings-true/main.js new file mode 120000 index 00000000000..3fa65076585 --- /dev/null +++ b/test/form/samples/generated-code-compact/const-bindings-true/main.js @@ -0,0 +1 @@ +../../generated-code/const-bindings-false/main.js \ No newline at end of file diff --git a/test/form/samples/generated-code-compact/object-shorthand-false/_config.js b/test/form/samples/generated-code-compact/object-shorthand-false/_config.js new file mode 100644 index 00000000000..754cb7f6c20 --- /dev/null +++ b/test/form/samples/generated-code-compact/object-shorthand-false/_config.js @@ -0,0 +1,12 @@ +module.exports = defineTest({ + description: 'does not use object shorthand syntax', + options: { + output: { + compact: true, + exports: 'named', + format: 'system', + generatedCode: { objectShorthand: false }, + name: 'bundle' + } + } +}); diff --git a/test/form/samples/generated-code-compact/object-shorthand-false/_expected.js b/test/form/samples/generated-code-compact/object-shorthand-false/_expected.js new file mode 100644 index 00000000000..ba6a7689721 --- /dev/null +++ b/test/form/samples/generated-code-compact/object-shorthand-false/_expected.js @@ -0,0 +1,3 @@ +System.register('bundle',[],(function(exports){'use strict';return{execute:(function(){const a = 'a';var ns=/*#__PURE__*/Object.freeze({__proto__:null,a:a,b:a,default:a});console.log(ns); + +const foo = 1; exports({bar:foo,default:foo,foo:foo});})}})); \ No newline at end of file diff --git a/test/form/samples/generated-code-compact/object-shorthand-false/main.js b/test/form/samples/generated-code-compact/object-shorthand-false/main.js new file mode 120000 index 00000000000..21bdc213a91 --- /dev/null +++ b/test/form/samples/generated-code-compact/object-shorthand-false/main.js @@ -0,0 +1 @@ +../../generated-code/object-shorthand-false/main.js \ No newline at end of file diff --git a/test/form/samples/generated-code-compact/object-shorthand-true/_config.js b/test/form/samples/generated-code-compact/object-shorthand-true/_config.js new file mode 100644 index 00000000000..ecdbd32adf6 --- /dev/null +++ b/test/form/samples/generated-code-compact/object-shorthand-true/_config.js @@ -0,0 +1,12 @@ +module.exports = defineTest({ + description: 'uses object shorthand syntax', + options: { + output: { + compact: true, + exports: 'named', + format: 'system', + generatedCode: { objectShorthand: true }, + name: 'bundle' + } + } +}); diff --git a/test/form/samples/generated-code-compact/object-shorthand-true/_expected.js b/test/form/samples/generated-code-compact/object-shorthand-true/_expected.js new file mode 100644 index 00000000000..1ce25acb178 --- /dev/null +++ b/test/form/samples/generated-code-compact/object-shorthand-true/_expected.js @@ -0,0 +1,3 @@ +System.register('bundle',[],(function(exports){'use strict';return{execute:(function(){const a = 'a';var ns=/*#__PURE__*/Object.freeze({__proto__:null,a,b:a,default:a});console.log(ns); + +const foo = 1; exports({bar:foo,default:foo,foo});})}})); \ No newline at end of file diff --git a/test/form/samples/generated-code-compact/object-shorthand-true/main.js b/test/form/samples/generated-code-compact/object-shorthand-true/main.js new file mode 120000 index 00000000000..21bdc213a91 --- /dev/null +++ b/test/form/samples/generated-code-compact/object-shorthand-true/main.js @@ -0,0 +1 @@ +../../generated-code/object-shorthand-false/main.js \ No newline at end of file diff --git a/test/form/samples/generated-code-compact/reserved-names-as-props-false-no-external-live-bindings/_config.js b/test/form/samples/generated-code-compact/reserved-names-as-props-false-no-external-live-bindings/_config.js new file mode 100644 index 00000000000..be0d0091b46 --- /dev/null +++ b/test/form/samples/generated-code-compact/reserved-names-as-props-false-no-external-live-bindings/_config.js @@ -0,0 +1,15 @@ +module.exports = defineTest({ + description: 'escapes reserved names used as props when external live-bindings are off', + options: { + external: ['external'], + output: { + compact: true, + exports: 'named', + externalLiveBindings: false, + generatedCode: { reservedNamesAsProps: false }, + globals: id => id, + interop: 'compat', + name: 'bundle' + } + } +}); diff --git a/test/form/samples/generated-code-compact/reserved-names-as-props-false-no-external-live-bindings/_expected/amd.js b/test/form/samples/generated-code-compact/reserved-names-as-props-false-no-external-live-bindings/_expected/amd.js new file mode 100644 index 00000000000..64e977fcb73 --- /dev/null +++ b/test/form/samples/generated-code-compact/reserved-names-as-props-false-no-external-live-bindings/_expected/amd.js @@ -0,0 +1 @@ +define(['external'],(function(ns){'use strict';function _interopDefaultCompat(e){return e&&typeof e==='object'&&'default'in e?e["default"]:e}var ns__default=/*#__PURE__*/_interopDefaultCompat(ns);console.log(ns__default);})); \ No newline at end of file diff --git a/test/form/samples/generated-code-compact/reserved-names-as-props-false-no-external-live-bindings/_expected/cjs.js b/test/form/samples/generated-code-compact/reserved-names-as-props-false-no-external-live-bindings/_expected/cjs.js new file mode 100644 index 00000000000..a83347d0f31 --- /dev/null +++ b/test/form/samples/generated-code-compact/reserved-names-as-props-false-no-external-live-bindings/_expected/cjs.js @@ -0,0 +1 @@ +'use strict';var ns=require('external');function _interopDefaultCompat(e){return e&&typeof e==='object'&&'default'in e?e["default"]:e}var ns__default=/*#__PURE__*/_interopDefaultCompat(ns);console.log(ns__default); \ No newline at end of file diff --git a/test/form/samples/generated-code-compact/reserved-names-as-props-false-no-external-live-bindings/_expected/es.js b/test/form/samples/generated-code-compact/reserved-names-as-props-false-no-external-live-bindings/_expected/es.js new file mode 100644 index 00000000000..f26633e0880 --- /dev/null +++ b/test/form/samples/generated-code-compact/reserved-names-as-props-false-no-external-live-bindings/_expected/es.js @@ -0,0 +1 @@ +import ns from'external';console.log(ns); \ No newline at end of file diff --git a/test/form/samples/generated-code-compact/reserved-names-as-props-false-no-external-live-bindings/_expected/iife.js b/test/form/samples/generated-code-compact/reserved-names-as-props-false-no-external-live-bindings/_expected/iife.js new file mode 100644 index 00000000000..7db324df20a --- /dev/null +++ b/test/form/samples/generated-code-compact/reserved-names-as-props-false-no-external-live-bindings/_expected/iife.js @@ -0,0 +1 @@ +(function(ns){'use strict';function _interopDefaultCompat(e){return e&&typeof e==='object'&&'default'in e?e["default"]:e}var ns__default=/*#__PURE__*/_interopDefaultCompat(ns);console.log(ns__default);})(external); \ No newline at end of file diff --git a/test/form/samples/generated-code-compact/reserved-names-as-props-false-no-external-live-bindings/_expected/system.js b/test/form/samples/generated-code-compact/reserved-names-as-props-false-no-external-live-bindings/_expected/system.js new file mode 100644 index 00000000000..5bb5c3b4f2f --- /dev/null +++ b/test/form/samples/generated-code-compact/reserved-names-as-props-false-no-external-live-bindings/_expected/system.js @@ -0,0 +1 @@ +System.register('bundle',['external'],(function(){'use strict';var ns;return{setters:[function(module){ns=module["default"];}],execute:(function(){console.log(ns);})}})); \ No newline at end of file diff --git a/test/form/samples/generated-code-compact/reserved-names-as-props-false-no-external-live-bindings/_expected/umd.js b/test/form/samples/generated-code-compact/reserved-names-as-props-false-no-external-live-bindings/_expected/umd.js new file mode 100644 index 00000000000..e3e239c26d4 --- /dev/null +++ b/test/form/samples/generated-code-compact/reserved-names-as-props-false-no-external-live-bindings/_expected/umd.js @@ -0,0 +1 @@ +(function(g,f){typeof exports==='object'&&typeof module!=='undefined'?f(require('external')):typeof define==='function'&&define.amd?define(['external'],f):(g=typeof globalThis!=='undefined'?globalThis:g||self,f(g.external));})(this,(function(ns){'use strict';function _interopDefaultCompat(e){return e&&typeof e==='object'&&'default'in e?e["default"]:e}var ns__default=/*#__PURE__*/_interopDefaultCompat(ns);console.log(ns__default);})); \ No newline at end of file diff --git a/test/form/samples/generated-code-compact/reserved-names-as-props-false-no-external-live-bindings/main.js b/test/form/samples/generated-code-compact/reserved-names-as-props-false-no-external-live-bindings/main.js new file mode 120000 index 00000000000..b667be2b6cd --- /dev/null +++ b/test/form/samples/generated-code-compact/reserved-names-as-props-false-no-external-live-bindings/main.js @@ -0,0 +1 @@ +../../generated-code/reserved-names-as-props-false-no-external-live-bindings/main.js \ No newline at end of file diff --git a/test/form/samples/generated-code-compact/reserved-names-as-props-false/_config.js b/test/form/samples/generated-code-compact/reserved-names-as-props-false/_config.js new file mode 100644 index 00000000000..b1b2f35a657 --- /dev/null +++ b/test/form/samples/generated-code-compact/reserved-names-as-props-false/_config.js @@ -0,0 +1,25 @@ +module.exports = defineTest({ + description: 'escapes reserved names used as props', + options: { + external: ['external', 'external2', 'externalDefaultOnly'], + output: { + compact: true, + exports: 'named', + generatedCode: { reservedNamesAsProps: false }, + globals: id => id, + interop(id) { + if (id === 'externalDefaultOnly') return 'defaultOnly'; + return 'auto'; + }, + name: 'bundle' + }, + plugins: [ + { + name: 'test', + transform() { + return { syntheticNamedExports: true }; + } + } + ] + } +}); diff --git a/test/form/samples/generated-code-compact/reserved-names-as-props-false/_expected/amd.js b/test/form/samples/generated-code-compact/reserved-names-as-props-false/_expected/amd.js new file mode 100644 index 00000000000..783031cc1e1 --- /dev/null +++ b/test/form/samples/generated-code-compact/reserved-names-as-props-false/_expected/amd.js @@ -0,0 +1,7 @@ +define(['module','exports','external','externalDefaultOnly','external2'],(function(module,exports,external,defaultOnly,someDefault){'use strict';function _interopDefault(e){return e&&e.__esModule?e:{default:e}}function _interopNamespaceDefaultOnly(e){return Object.freeze({__proto__:null,default:e})}function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n["default"]=e;return Object.freeze(n)}function _mergeNamespaces(n, m){m.forEach(function(e){e&&typeof e!=='string'&&!Array.isArray(e)&&Object.keys(e).forEach(function(k){if(k!=='default'&&!(k in n)){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})});return Object.freeze(n);}var external__namespace=/*#__PURE__*/_interopNamespace(external);var defaultOnly__namespace=/*#__PURE__*/_interopNamespaceDefaultOnly(defaultOnly);var someDefault__default=/*#__PURE__*/_interopDefault(someDefault);var other = { + foo: 'bar' +};var ns=/*#__PURE__*/_mergeNamespaces({__proto__:null,default:other},[other]);console.log(ns, other.foo, other["function"], other["some-prop"], external["function"], someDefault__default["default"], defaultOnly__namespace); +console.log(undefined, undefined); + +exports["function"] = 1; +exports["function"]++;Object.defineProperty(exports,"bar",{enumerable:true,get:function(){return external["function"]}});exports["default"]=external__namespace;Object.defineProperty(exports,"void",{enumerable:true,get:function(){return external__namespace["default"]}});Object.defineProperty(exports,'__esModule',{value:true});})); \ No newline at end of file diff --git a/test/form/samples/generated-code-compact/reserved-names-as-props-false/_expected/cjs.js b/test/form/samples/generated-code-compact/reserved-names-as-props-false/_expected/cjs.js new file mode 100644 index 00000000000..d9596a54c8b --- /dev/null +++ b/test/form/samples/generated-code-compact/reserved-names-as-props-false/_expected/cjs.js @@ -0,0 +1,7 @@ +'use strict';Object.defineProperty(exports,'__esModule',{value:true});var external=require('external'),defaultOnly=require('externalDefaultOnly'),someDefault=require('external2');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}function _interopNamespaceDefaultOnly(e){return Object.freeze({__proto__:null,default:e})}function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n["default"]=e;return Object.freeze(n)}function _mergeNamespaces(n, m){m.forEach(function(e){e&&typeof e!=='string'&&!Array.isArray(e)&&Object.keys(e).forEach(function(k){if(k!=='default'&&!(k in n)){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})});return Object.freeze(n);}var external__namespace=/*#__PURE__*/_interopNamespace(external);var defaultOnly__namespace=/*#__PURE__*/_interopNamespaceDefaultOnly(defaultOnly);var someDefault__default=/*#__PURE__*/_interopDefault(someDefault);var other = { + foo: 'bar' +};var ns=/*#__PURE__*/_mergeNamespaces({__proto__:null,default:other},[other]);console.log(ns, other.foo, other["function"], other["some-prop"], external["function"], someDefault__default["default"], defaultOnly__namespace); +console.log(undefined, undefined); + +exports["function"] = 1; +exports["function"]++;Object.defineProperty(exports,"bar",{enumerable:true,get:function(){return external["function"]}});exports["default"]=external__namespace;Object.defineProperty(exports,"void",{enumerable:true,get:function(){return external__namespace["default"]}}); \ No newline at end of file diff --git a/test/form/samples/generated-code-compact/reserved-names-as-props-false/_expected/es.js b/test/form/samples/generated-code-compact/reserved-names-as-props-false/_expected/es.js new file mode 100644 index 00000000000..995dc376179 --- /dev/null +++ b/test/form/samples/generated-code-compact/reserved-names-as-props-false/_expected/es.js @@ -0,0 +1,7 @@ +import {function as _function}from'external';import*as external from'external';export{external as default };export{function as bar,default as void}from'external';import*as defaultOnly from'externalDefaultOnly';import someDefault from'external2';function _mergeNamespaces(n, m){m.forEach(function(e){e&&typeof e!=='string'&&!Array.isArray(e)&&Object.keys(e).forEach(function(k){if(k!=='default'&&!(k in n)){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})});return Object.freeze(n);}var other = { + foo: 'bar' +};var ns=/*#__PURE__*/_mergeNamespaces({__proto__:null,default:other},[other]);console.log(ns, other.foo, other["function"], other["some-prop"], _function, someDefault, defaultOnly); +console.log(import.meta['function'], import.meta['some-prop']); + +let f = 1; +f++;export{f as function}; \ No newline at end of file diff --git a/test/form/samples/generated-code-compact/reserved-names-as-props-false/_expected/iife.js b/test/form/samples/generated-code-compact/reserved-names-as-props-false/_expected/iife.js new file mode 100644 index 00000000000..6fd665e5e2a --- /dev/null +++ b/test/form/samples/generated-code-compact/reserved-names-as-props-false/_expected/iife.js @@ -0,0 +1,7 @@ +var bundle=(function(exports,external,defaultOnly,someDefault){'use strict';function _interopDefault(e){return e&&e.__esModule?e:{default:e}}function _interopNamespaceDefaultOnly(e){return Object.freeze({__proto__:null,default:e})}function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n["default"]=e;return Object.freeze(n)}function _mergeNamespaces(n, m){m.forEach(function(e){e&&typeof e!=='string'&&!Array.isArray(e)&&Object.keys(e).forEach(function(k){if(k!=='default'&&!(k in n)){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})});return Object.freeze(n);}var external__namespace=/*#__PURE__*/_interopNamespace(external);var defaultOnly__namespace=/*#__PURE__*/_interopNamespaceDefaultOnly(defaultOnly);var someDefault__default=/*#__PURE__*/_interopDefault(someDefault);var other = { + foo: 'bar' +};var ns=/*#__PURE__*/_mergeNamespaces({__proto__:null,default:other},[other]);console.log(ns, other.foo, other["function"], other["some-prop"], external["function"], someDefault__default["default"], defaultOnly__namespace); +console.log(undefined, undefined); + +exports["function"] = 1; +exports["function"]++;Object.defineProperty(exports,"bar",{enumerable:true,get:function(){return external["function"]}});exports["default"]=external__namespace;Object.defineProperty(exports,"void",{enumerable:true,get:function(){return external__namespace["default"]}});Object.defineProperty(exports,'__esModule',{value:true});return exports;})({},external,externalDefaultOnly,external2); \ No newline at end of file diff --git a/test/form/samples/generated-code-compact/reserved-names-as-props-false/_expected/system.js b/test/form/samples/generated-code-compact/reserved-names-as-props-false/_expected/system.js new file mode 100644 index 00000000000..ad2a65f4048 --- /dev/null +++ b/test/form/samples/generated-code-compact/reserved-names-as-props-false/_expected/system.js @@ -0,0 +1,7 @@ +System.register('bundle',['external','externalDefaultOnly','external2'],(function(exports,module){'use strict';var _function,defaultOnly,someDefault;return{setters:[function(module){_function=module["function"];exports({bar:module["function"],default:module,void:module["default"]});},function(module){defaultOnly=module;},function(module){someDefault=module["default"];}],execute:(function(){function _mergeNamespaces(n, m){m.forEach(function(e){e&&typeof e!=='string'&&!Array.isArray(e)&&Object.keys(e).forEach(function(k){if(k!=='default'&&!(k in n)){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})});return Object.freeze(n);}var other = { + foo: 'bar' +};var ns=/*#__PURE__*/_mergeNamespaces({__proto__:null,default:other},[other]);console.log(ns, other.foo, other["function"], other["some-prop"], _function, someDefault, defaultOnly); +console.log(module.meta["function"], module.meta["some-prop"]); + +let f = exports("function",1); +exports("function",f+1),f++;})}})); \ No newline at end of file diff --git a/test/form/samples/generated-code-compact/reserved-names-as-props-false/_expected/umd.js b/test/form/samples/generated-code-compact/reserved-names-as-props-false/_expected/umd.js new file mode 100644 index 00000000000..dc5ec431242 --- /dev/null +++ b/test/form/samples/generated-code-compact/reserved-names-as-props-false/_expected/umd.js @@ -0,0 +1,7 @@ +(function(g,f){typeof exports==='object'&&typeof module!=='undefined'?f(exports,require('external'),require('externalDefaultOnly'),require('external2')):typeof define==='function'&&define.amd?define(['exports','external','externalDefaultOnly','external2'],f):(g=typeof globalThis!=='undefined'?globalThis:g||self,f(g.bundle={},g.external,g.externalDefaultOnly,g.external2));})(this,(function(exports,external,defaultOnly,someDefault){'use strict';function _interopDefault(e){return e&&e.__esModule?e:{default:e}}function _interopNamespaceDefaultOnly(e){return Object.freeze({__proto__:null,default:e})}function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n["default"]=e;return Object.freeze(n)}function _mergeNamespaces(n, m){m.forEach(function(e){e&&typeof e!=='string'&&!Array.isArray(e)&&Object.keys(e).forEach(function(k){if(k!=='default'&&!(k in n)){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})});return Object.freeze(n);}var external__namespace=/*#__PURE__*/_interopNamespace(external);var defaultOnly__namespace=/*#__PURE__*/_interopNamespaceDefaultOnly(defaultOnly);var someDefault__default=/*#__PURE__*/_interopDefault(someDefault);var other = { + foo: 'bar' +};var ns=/*#__PURE__*/_mergeNamespaces({__proto__:null,default:other},[other]);console.log(ns, other.foo, other["function"], other["some-prop"], external["function"], someDefault__default["default"], defaultOnly__namespace); +console.log(undefined, undefined); + +exports["function"] = 1; +exports["function"]++;Object.defineProperty(exports,"bar",{enumerable:true,get:function(){return external["function"]}});exports["default"]=external__namespace;Object.defineProperty(exports,"void",{enumerable:true,get:function(){return external__namespace["default"]}});Object.defineProperty(exports,'__esModule',{value:true});})); \ No newline at end of file diff --git a/test/form/samples/generated-code-compact/reserved-names-as-props-false/main.js b/test/form/samples/generated-code-compact/reserved-names-as-props-false/main.js new file mode 120000 index 00000000000..c711a9c52a1 --- /dev/null +++ b/test/form/samples/generated-code-compact/reserved-names-as-props-false/main.js @@ -0,0 +1 @@ +../../generated-code/reserved-names-as-props-false/main.js \ No newline at end of file diff --git a/test/form/samples/generated-code-compact/reserved-names-as-props-true-no-external-live-bindings/_config.js b/test/form/samples/generated-code-compact/reserved-names-as-props-true-no-external-live-bindings/_config.js new file mode 100644 index 00000000000..cc52037199f --- /dev/null +++ b/test/form/samples/generated-code-compact/reserved-names-as-props-true-no-external-live-bindings/_config.js @@ -0,0 +1,15 @@ +module.exports = defineTest({ + description: 'escapes reserved names used as props when external live-bindings are off', + options: { + external: ['external'], + output: { + compact: true, + exports: 'named', + externalLiveBindings: false, + generatedCode: { reservedNamesAsProps: true }, + globals: id => id, + interop: 'compat', + name: 'bundle' + } + } +}); diff --git a/test/form/samples/generated-code-compact/reserved-names-as-props-true-no-external-live-bindings/_expected/amd.js b/test/form/samples/generated-code-compact/reserved-names-as-props-true-no-external-live-bindings/_expected/amd.js new file mode 100644 index 00000000000..e2454cec019 --- /dev/null +++ b/test/form/samples/generated-code-compact/reserved-names-as-props-true-no-external-live-bindings/_expected/amd.js @@ -0,0 +1 @@ +define(['external'],(function(ns){'use strict';function _interopDefaultCompat(e){return e&&typeof e==='object'&&'default'in e?e.default:e}var ns__default=/*#__PURE__*/_interopDefaultCompat(ns);console.log(ns__default);})); \ No newline at end of file diff --git a/test/form/samples/generated-code-compact/reserved-names-as-props-true-no-external-live-bindings/_expected/cjs.js b/test/form/samples/generated-code-compact/reserved-names-as-props-true-no-external-live-bindings/_expected/cjs.js new file mode 100644 index 00000000000..6e1fa869425 --- /dev/null +++ b/test/form/samples/generated-code-compact/reserved-names-as-props-true-no-external-live-bindings/_expected/cjs.js @@ -0,0 +1 @@ +'use strict';var ns=require('external');function _interopDefaultCompat(e){return e&&typeof e==='object'&&'default'in e?e.default:e}var ns__default=/*#__PURE__*/_interopDefaultCompat(ns);console.log(ns__default); \ No newline at end of file diff --git a/test/form/samples/generated-code-compact/reserved-names-as-props-true-no-external-live-bindings/_expected/es.js b/test/form/samples/generated-code-compact/reserved-names-as-props-true-no-external-live-bindings/_expected/es.js new file mode 100644 index 00000000000..f26633e0880 --- /dev/null +++ b/test/form/samples/generated-code-compact/reserved-names-as-props-true-no-external-live-bindings/_expected/es.js @@ -0,0 +1 @@ +import ns from'external';console.log(ns); \ No newline at end of file diff --git a/test/form/samples/generated-code-compact/reserved-names-as-props-true-no-external-live-bindings/_expected/iife.js b/test/form/samples/generated-code-compact/reserved-names-as-props-true-no-external-live-bindings/_expected/iife.js new file mode 100644 index 00000000000..490a7240b61 --- /dev/null +++ b/test/form/samples/generated-code-compact/reserved-names-as-props-true-no-external-live-bindings/_expected/iife.js @@ -0,0 +1 @@ +(function(ns){'use strict';function _interopDefaultCompat(e){return e&&typeof e==='object'&&'default'in e?e.default:e}var ns__default=/*#__PURE__*/_interopDefaultCompat(ns);console.log(ns__default);})(external); \ No newline at end of file diff --git a/test/form/samples/generated-code-compact/reserved-names-as-props-true-no-external-live-bindings/_expected/system.js b/test/form/samples/generated-code-compact/reserved-names-as-props-true-no-external-live-bindings/_expected/system.js new file mode 100644 index 00000000000..6ce74bdff15 --- /dev/null +++ b/test/form/samples/generated-code-compact/reserved-names-as-props-true-no-external-live-bindings/_expected/system.js @@ -0,0 +1 @@ +System.register('bundle',['external'],(function(){'use strict';var ns;return{setters:[function(module){ns=module.default;}],execute:(function(){console.log(ns);})}})); \ No newline at end of file diff --git a/test/form/samples/generated-code-compact/reserved-names-as-props-true-no-external-live-bindings/_expected/umd.js b/test/form/samples/generated-code-compact/reserved-names-as-props-true-no-external-live-bindings/_expected/umd.js new file mode 100644 index 00000000000..b452b942121 --- /dev/null +++ b/test/form/samples/generated-code-compact/reserved-names-as-props-true-no-external-live-bindings/_expected/umd.js @@ -0,0 +1 @@ +(function(g,f){typeof exports==='object'&&typeof module!=='undefined'?f(require('external')):typeof define==='function'&&define.amd?define(['external'],f):(g=typeof globalThis!=='undefined'?globalThis:g||self,f(g.external));})(this,(function(ns){'use strict';function _interopDefaultCompat(e){return e&&typeof e==='object'&&'default'in e?e.default:e}var ns__default=/*#__PURE__*/_interopDefaultCompat(ns);console.log(ns__default);})); \ No newline at end of file diff --git a/test/form/samples/generated-code-compact/reserved-names-as-props-true-no-external-live-bindings/main.js b/test/form/samples/generated-code-compact/reserved-names-as-props-true-no-external-live-bindings/main.js new file mode 120000 index 00000000000..b667be2b6cd --- /dev/null +++ b/test/form/samples/generated-code-compact/reserved-names-as-props-true-no-external-live-bindings/main.js @@ -0,0 +1 @@ +../../generated-code/reserved-names-as-props-false-no-external-live-bindings/main.js \ No newline at end of file diff --git a/test/form/samples/generated-code-compact/reserved-names-as-props-true/_config.js b/test/form/samples/generated-code-compact/reserved-names-as-props-true/_config.js new file mode 100644 index 00000000000..dd733105cfb --- /dev/null +++ b/test/form/samples/generated-code-compact/reserved-names-as-props-true/_config.js @@ -0,0 +1,25 @@ +module.exports = defineTest({ + description: 'escapes reserved names used as props', + options: { + external: ['external', 'external2', 'externalDefaultOnly'], + output: { + compact: true, + exports: 'named', + generatedCode: { reservedNamesAsProps: true }, + globals: id => id, + interop(id) { + if (id === 'externalDefaultOnly') return 'defaultOnly'; + return 'auto'; + }, + name: 'bundle' + }, + plugins: [ + { + name: 'test', + transform() { + return { syntheticNamedExports: true }; + } + } + ] + } +}); diff --git a/test/form/samples/generated-code-compact/reserved-names-as-props-true/_expected/amd.js b/test/form/samples/generated-code-compact/reserved-names-as-props-true/_expected/amd.js new file mode 100644 index 00000000000..18bc3f6fc55 --- /dev/null +++ b/test/form/samples/generated-code-compact/reserved-names-as-props-true/_expected/amd.js @@ -0,0 +1,7 @@ +define(['module','exports','external','externalDefaultOnly','external2'],(function(module,exports,external,defaultOnly,someDefault){'use strict';function _interopDefault(e){return e&&e.__esModule?e:{default:e}}function _interopNamespaceDefaultOnly(e){return Object.freeze({__proto__:null,default:e})}function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}function _mergeNamespaces(n, m){m.forEach(function(e){e&&typeof e!=='string'&&!Array.isArray(e)&&Object.keys(e).forEach(function(k){if(k!=='default'&&!(k in n)){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})});return Object.freeze(n);}var external__namespace=/*#__PURE__*/_interopNamespace(external);var defaultOnly__namespace=/*#__PURE__*/_interopNamespaceDefaultOnly(defaultOnly);var someDefault__default=/*#__PURE__*/_interopDefault(someDefault);var other = { + foo: 'bar' +};var ns=/*#__PURE__*/_mergeNamespaces({__proto__:null,default:other},[other]);console.log(ns, other.foo, other.function, other["some-prop"], external.function, someDefault__default.default, defaultOnly__namespace); +console.log(undefined, undefined); + +exports.function = 1; +exports.function++;Object.defineProperty(exports,"bar",{enumerable:true,get:function(){return external.function}});exports.default=external__namespace;Object.defineProperty(exports,"void",{enumerable:true,get:function(){return external__namespace.default}});Object.defineProperty(exports,'__esModule',{value:true});})); \ No newline at end of file diff --git a/test/form/samples/generated-code-compact/reserved-names-as-props-true/_expected/cjs.js b/test/form/samples/generated-code-compact/reserved-names-as-props-true/_expected/cjs.js new file mode 100644 index 00000000000..20cfaeb32a4 --- /dev/null +++ b/test/form/samples/generated-code-compact/reserved-names-as-props-true/_expected/cjs.js @@ -0,0 +1,7 @@ +'use strict';Object.defineProperty(exports,'__esModule',{value:true});var external=require('external'),defaultOnly=require('externalDefaultOnly'),someDefault=require('external2');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}function _interopNamespaceDefaultOnly(e){return Object.freeze({__proto__:null,default:e})}function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}function _mergeNamespaces(n, m){m.forEach(function(e){e&&typeof e!=='string'&&!Array.isArray(e)&&Object.keys(e).forEach(function(k){if(k!=='default'&&!(k in n)){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})});return Object.freeze(n);}var external__namespace=/*#__PURE__*/_interopNamespace(external);var defaultOnly__namespace=/*#__PURE__*/_interopNamespaceDefaultOnly(defaultOnly);var someDefault__default=/*#__PURE__*/_interopDefault(someDefault);var other = { + foo: 'bar' +};var ns=/*#__PURE__*/_mergeNamespaces({__proto__:null,default:other},[other]);console.log(ns, other.foo, other.function, other["some-prop"], external.function, someDefault__default.default, defaultOnly__namespace); +console.log(undefined, undefined); + +exports.function = 1; +exports.function++;Object.defineProperty(exports,"bar",{enumerable:true,get:function(){return external.function}});exports.default=external__namespace;Object.defineProperty(exports,"void",{enumerable:true,get:function(){return external__namespace.default}}); \ No newline at end of file diff --git a/test/form/samples/generated-code-compact/reserved-names-as-props-true/_expected/es.js b/test/form/samples/generated-code-compact/reserved-names-as-props-true/_expected/es.js new file mode 100644 index 00000000000..a49393e2c6a --- /dev/null +++ b/test/form/samples/generated-code-compact/reserved-names-as-props-true/_expected/es.js @@ -0,0 +1,7 @@ +import {function as _function}from'external';import*as external from'external';export{external as default };export{function as bar,default as void}from'external';import*as defaultOnly from'externalDefaultOnly';import someDefault from'external2';function _mergeNamespaces(n, m){m.forEach(function(e){e&&typeof e!=='string'&&!Array.isArray(e)&&Object.keys(e).forEach(function(k){if(k!=='default'&&!(k in n)){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})});return Object.freeze(n);}var other = { + foo: 'bar' +};var ns=/*#__PURE__*/_mergeNamespaces({__proto__:null,default:other},[other]);console.log(ns, other.foo, other.function, other["some-prop"], _function, someDefault, defaultOnly); +console.log(import.meta['function'], import.meta['some-prop']); + +let f = 1; +f++;export{f as function}; \ No newline at end of file diff --git a/test/form/samples/generated-code-compact/reserved-names-as-props-true/_expected/iife.js b/test/form/samples/generated-code-compact/reserved-names-as-props-true/_expected/iife.js new file mode 100644 index 00000000000..986a882e98b --- /dev/null +++ b/test/form/samples/generated-code-compact/reserved-names-as-props-true/_expected/iife.js @@ -0,0 +1,7 @@ +var bundle=(function(exports,external,defaultOnly,someDefault){'use strict';function _interopDefault(e){return e&&e.__esModule?e:{default:e}}function _interopNamespaceDefaultOnly(e){return Object.freeze({__proto__:null,default:e})}function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}function _mergeNamespaces(n, m){m.forEach(function(e){e&&typeof e!=='string'&&!Array.isArray(e)&&Object.keys(e).forEach(function(k){if(k!=='default'&&!(k in n)){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})});return Object.freeze(n);}var external__namespace=/*#__PURE__*/_interopNamespace(external);var defaultOnly__namespace=/*#__PURE__*/_interopNamespaceDefaultOnly(defaultOnly);var someDefault__default=/*#__PURE__*/_interopDefault(someDefault);var other = { + foo: 'bar' +};var ns=/*#__PURE__*/_mergeNamespaces({__proto__:null,default:other},[other]);console.log(ns, other.foo, other.function, other["some-prop"], external.function, someDefault__default.default, defaultOnly__namespace); +console.log(undefined, undefined); + +exports.function = 1; +exports.function++;Object.defineProperty(exports,"bar",{enumerable:true,get:function(){return external.function}});exports.default=external__namespace;Object.defineProperty(exports,"void",{enumerable:true,get:function(){return external__namespace.default}});Object.defineProperty(exports,'__esModule',{value:true});return exports;})({},external,externalDefaultOnly,external2); \ No newline at end of file diff --git a/test/form/samples/generated-code-compact/reserved-names-as-props-true/_expected/system.js b/test/form/samples/generated-code-compact/reserved-names-as-props-true/_expected/system.js new file mode 100644 index 00000000000..8a6db4fff10 --- /dev/null +++ b/test/form/samples/generated-code-compact/reserved-names-as-props-true/_expected/system.js @@ -0,0 +1,7 @@ +System.register('bundle',['external','externalDefaultOnly','external2'],(function(exports,module){'use strict';var _function,defaultOnly,someDefault;return{setters:[function(module){_function=module.function;exports({bar:module.function,default:module,void:module.default});},function(module){defaultOnly=module;},function(module){someDefault=module.default;}],execute:(function(){function _mergeNamespaces(n, m){m.forEach(function(e){e&&typeof e!=='string'&&!Array.isArray(e)&&Object.keys(e).forEach(function(k){if(k!=='default'&&!(k in n)){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})});return Object.freeze(n);}var other = { + foo: 'bar' +};var ns=/*#__PURE__*/_mergeNamespaces({__proto__:null,default:other},[other]);console.log(ns, other.foo, other.function, other["some-prop"], _function, someDefault, defaultOnly); +console.log(module.meta.function, module.meta["some-prop"]); + +let f = exports("function",1); +exports("function",f+1),f++;})}})); \ No newline at end of file diff --git a/test/form/samples/generated-code-compact/reserved-names-as-props-true/_expected/umd.js b/test/form/samples/generated-code-compact/reserved-names-as-props-true/_expected/umd.js new file mode 100644 index 00000000000..ff171327a77 --- /dev/null +++ b/test/form/samples/generated-code-compact/reserved-names-as-props-true/_expected/umd.js @@ -0,0 +1,7 @@ +(function(g,f){typeof exports==='object'&&typeof module!=='undefined'?f(exports,require('external'),require('externalDefaultOnly'),require('external2')):typeof define==='function'&&define.amd?define(['exports','external','externalDefaultOnly','external2'],f):(g=typeof globalThis!=='undefined'?globalThis:g||self,f(g.bundle={},g.external,g.externalDefaultOnly,g.external2));})(this,(function(exports,external,defaultOnly,someDefault){'use strict';function _interopDefault(e){return e&&e.__esModule?e:{default:e}}function _interopNamespaceDefaultOnly(e){return Object.freeze({__proto__:null,default:e})}function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}function _mergeNamespaces(n, m){m.forEach(function(e){e&&typeof e!=='string'&&!Array.isArray(e)&&Object.keys(e).forEach(function(k){if(k!=='default'&&!(k in n)){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})});return Object.freeze(n);}var external__namespace=/*#__PURE__*/_interopNamespace(external);var defaultOnly__namespace=/*#__PURE__*/_interopNamespaceDefaultOnly(defaultOnly);var someDefault__default=/*#__PURE__*/_interopDefault(someDefault);var other = { + foo: 'bar' +};var ns=/*#__PURE__*/_mergeNamespaces({__proto__:null,default:other},[other]);console.log(ns, other.foo, other.function, other["some-prop"], external.function, someDefault__default.default, defaultOnly__namespace); +console.log(undefined, undefined); + +exports.function = 1; +exports.function++;Object.defineProperty(exports,"bar",{enumerable:true,get:function(){return external.function}});exports.default=external__namespace;Object.defineProperty(exports,"void",{enumerable:true,get:function(){return external__namespace.default}});Object.defineProperty(exports,'__esModule',{value:true});})); \ No newline at end of file diff --git a/test/form/samples/generated-code-compact/reserved-names-as-props-true/main.js b/test/form/samples/generated-code-compact/reserved-names-as-props-true/main.js new file mode 120000 index 00000000000..c711a9c52a1 --- /dev/null +++ b/test/form/samples/generated-code-compact/reserved-names-as-props-true/main.js @@ -0,0 +1 @@ +../../generated-code/reserved-names-as-props-false/main.js \ No newline at end of file diff --git a/test/form/samples/generated-code-presets/es2015/_config.js b/test/form/samples/generated-code-presets/es2015/_config.js new file mode 100644 index 00000000000..02b793a8e58 --- /dev/null +++ b/test/form/samples/generated-code-presets/es2015/_config.js @@ -0,0 +1,23 @@ +const assert = require('node:assert'); + +module.exports = defineTest({ + description: 'handles generatedCode preset "es2015"', + options: { + output: { + exports: 'named', + format: 'system', + generatedCode: 'es2015', + name: 'bundle' + }, + plugins: [ + { + name: 'test', + renderStart(options) { + assert.strictEqual(options.generatedCode.arrowFunctions, true); + assert.strictEqual(options.generatedCode.objectShorthand, true); + assert.strictEqual(options.generatedCode.reservedNamesAsProps, true); + } + } + ] + } +}); diff --git a/test/form/samples/generated-code-presets/es2015/_expected.js b/test/form/samples/generated-code-presets/es2015/_expected.js new file mode 100644 index 00000000000..1bf2aed1282 --- /dev/null +++ b/test/form/samples/generated-code-presets/es2015/_expected.js @@ -0,0 +1,10 @@ +System.register('bundle', [], (function (exports) { + 'use strict'; + return { + execute: (function () { + + const foo = 1; exports({ bar: foo, default: foo, foo }); + + }) + }; +})); diff --git a/test/form/samples/generated-code-presets/es2015/main.js b/test/form/samples/generated-code-presets/es2015/main.js new file mode 100644 index 00000000000..a88ddfd3956 --- /dev/null +++ b/test/form/samples/generated-code-presets/es2015/main.js @@ -0,0 +1,2 @@ +const foo = 1; +export { foo, foo as bar, foo as default }; diff --git a/test/form/samples/generated-code-presets/es5/_config.js b/test/form/samples/generated-code-presets/es5/_config.js new file mode 100644 index 00000000000..c7dd1d166d6 --- /dev/null +++ b/test/form/samples/generated-code-presets/es5/_config.js @@ -0,0 +1,23 @@ +const assert = require('node:assert'); + +module.exports = defineTest({ + description: 'handles generatedCode preset "es5"', + options: { + output: { + exports: 'named', + format: 'system', + generatedCode: 'es5', + name: 'bundle' + }, + plugins: [ + { + name: 'test', + renderStart(options) { + assert.strictEqual(options.generatedCode.arrowFunctions, false); + assert.strictEqual(options.generatedCode.objectShorthand, false); + assert.strictEqual(options.generatedCode.reservedNamesAsProps, true); + } + } + ] + } +}); diff --git a/test/form/samples/generated-code-presets/es5/_expected.js b/test/form/samples/generated-code-presets/es5/_expected.js new file mode 100644 index 00000000000..fb0c1966faf --- /dev/null +++ b/test/form/samples/generated-code-presets/es5/_expected.js @@ -0,0 +1,10 @@ +System.register('bundle', [], (function (exports) { + 'use strict'; + return { + execute: (function () { + + const foo = 1; exports({ bar: foo, default: foo, foo: foo }); + + }) + }; +})); diff --git a/test/form/samples/generated-code-presets/es5/main.js b/test/form/samples/generated-code-presets/es5/main.js new file mode 100644 index 00000000000..a88ddfd3956 --- /dev/null +++ b/test/form/samples/generated-code-presets/es5/main.js @@ -0,0 +1,2 @@ +const foo = 1; +export { foo, foo as bar, foo as default }; diff --git a/test/form/samples/generated-code-presets/preset-with-override/_config.js b/test/form/samples/generated-code-presets/preset-with-override/_config.js new file mode 100644 index 00000000000..11ebdbd10fb --- /dev/null +++ b/test/form/samples/generated-code-presets/preset-with-override/_config.js @@ -0,0 +1,26 @@ +const assert = require('node:assert'); + +module.exports = defineTest({ + description: 'handles generatedCode preset "es2015"', + options: { + output: { + exports: 'named', + format: 'system', + generatedCode: { + preset: 'es2015', + arrowFunctions: false + }, + name: 'bundle' + }, + plugins: [ + { + name: 'test', + renderStart(options) { + assert.strictEqual(options.generatedCode.arrowFunctions, false); + assert.strictEqual(options.generatedCode.objectShorthand, true); + assert.strictEqual(options.generatedCode.reservedNamesAsProps, true); + } + } + ] + } +}); diff --git a/test/form/samples/generated-code-presets/preset-with-override/_expected.js b/test/form/samples/generated-code-presets/preset-with-override/_expected.js new file mode 100644 index 00000000000..1bf2aed1282 --- /dev/null +++ b/test/form/samples/generated-code-presets/preset-with-override/_expected.js @@ -0,0 +1,10 @@ +System.register('bundle', [], (function (exports) { + 'use strict'; + return { + execute: (function () { + + const foo = 1; exports({ bar: foo, default: foo, foo }); + + }) + }; +})); diff --git a/test/form/samples/generated-code-presets/preset-with-override/main.js b/test/form/samples/generated-code-presets/preset-with-override/main.js new file mode 100644 index 00000000000..a88ddfd3956 --- /dev/null +++ b/test/form/samples/generated-code-presets/preset-with-override/main.js @@ -0,0 +1,2 @@ +const foo = 1; +export { foo, foo as bar, foo as default }; diff --git a/test/form/samples/generated-code/arrow-functions-false/_config.js b/test/form/samples/generated-code/arrow-functions-false/_config.js new file mode 100644 index 00000000000..940aadb86dd --- /dev/null +++ b/test/form/samples/generated-code/arrow-functions-false/_config.js @@ -0,0 +1,34 @@ +module.exports = defineTest({ + description: 'does not use arrow functions', + options: { + external: [ + 'external', + 'externalAuto', + 'externalDefault', + 'externalDefaultOnly', + 'externalNoImport' + ], + strictDeprecations: false, + output: { + dynamicImportInCjs: false, + generatedCode: { arrowFunctions: false }, + globals: id => id, + interop(id) { + if (id === 'externalDefault') { + return 'default'; + } + if (id === 'externalDefaultOnly') { + return 'defaultOnly'; + } + if (id === 'externalAuto') { + return 'auto'; + } + return 'compat'; + }, + name: 'bundle', + noConflict: true, + systemNullSetters: false + } + }, + expectedWarnings: ['DEPRECATED_FEATURE'] +}); diff --git a/test/form/samples/generated-code/arrow-functions-false/_expected/amd.js b/test/form/samples/generated-code/arrow-functions-false/_expected/amd.js new file mode 100644 index 00000000000..5ee1de021da --- /dev/null +++ b/test/form/samples/generated-code/arrow-functions-false/_expected/amd.js @@ -0,0 +1,76 @@ +define(['require', 'exports', 'externalNoImport', 'external', 'externalAuto', 'externalDefault', 'externalDefaultOnly'], (function (require, exports, externalNoImport, defaultCompat, externalAuto, externalDefault, externalDefaultOnly) { 'use strict'; + + function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; } + + function _interopNamespaceCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : _interopNamespaceDefault(e); } + + function _interopNamespaceDefaultOnly (e) { return Object.freeze({ __proto__: null, default: e }); } + + function _interopNamespaceDefault(e) { + var n = Object.create(null); + if (e) { + Object.keys(e).forEach(function (k) { + if (k !== 'default') { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + } + n.default = e; + return Object.freeze(n); + } + + function _mergeNamespaces(n, m) { + m.forEach(function (e) { + e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) { + if (k !== 'default' && !(k in n)) { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + }); + return Object.freeze(n); + } + + var defaultCompat__namespace = /*#__PURE__*/_interopNamespaceCompat(defaultCompat); + var externalAuto__default = /*#__PURE__*/_interopDefault(externalAuto); + var externalDefault__namespace = /*#__PURE__*/_interopNamespaceDefault(externalDefault); + var externalDefaultOnly__namespace = /*#__PURE__*/_interopNamespaceDefaultOnly(externalDefaultOnly); + + exports.a = void 0; + + ({ a: exports.a } = defaultCompat.b); + console.log({ a: exports.a } = defaultCompat.b); + + Promise.resolve().then(function () { return main; }).then(console.log); + + new Promise(function (resolve, reject) { require(['external'], function (m) { resolve(/*#__PURE__*/_interopNamespaceCompat(m)); }, reject); }).then(console.log); + console.log(defaultCompat__namespace.default); + console.log(externalAuto__default.default); + console.log(externalDefault__namespace); + console.log(externalDefaultOnly__namespace); + + var main = /*#__PURE__*/_mergeNamespaces({ + __proto__: null, + get a () { return exports.a; }, + foo: foo + }, [defaultCompat__namespace]); + + Object.defineProperty(exports, "foo", { + enumerable: true, + get: function () { return defaultCompat.foo; } + }); + Object.keys(defaultCompat).forEach(function (k) { + if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, { + enumerable: true, + get: function () { return defaultCompat[k]; } + }); + }); + +})); diff --git a/test/form/samples/generated-code/arrow-functions-false/_expected/cjs.js b/test/form/samples/generated-code/arrow-functions-false/_expected/cjs.js new file mode 100644 index 00000000000..7f74048a243 --- /dev/null +++ b/test/form/samples/generated-code/arrow-functions-false/_expected/cjs.js @@ -0,0 +1,80 @@ +'use strict'; + +require('externalNoImport'); +var defaultCompat = require('external'); +var externalAuto = require('externalAuto'); +var externalDefault = require('externalDefault'); +var externalDefaultOnly = require('externalDefaultOnly'); + +function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; } + +function _interopNamespaceCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : _interopNamespaceDefault(e); } + +function _interopNamespaceDefaultOnly (e) { return Object.freeze({ __proto__: null, default: e }); } + +function _interopNamespaceDefault(e) { + var n = Object.create(null); + if (e) { + Object.keys(e).forEach(function (k) { + if (k !== 'default') { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + } + n.default = e; + return Object.freeze(n); +} + +function _mergeNamespaces(n, m) { + m.forEach(function (e) { + e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) { + if (k !== 'default' && !(k in n)) { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + }); + return Object.freeze(n); +} + +var defaultCompat__namespace = /*#__PURE__*/_interopNamespaceCompat(defaultCompat); +var externalAuto__default = /*#__PURE__*/_interopDefault(externalAuto); +var externalDefault__namespace = /*#__PURE__*/_interopNamespaceDefault(externalDefault); +var externalDefaultOnly__namespace = /*#__PURE__*/_interopNamespaceDefaultOnly(externalDefaultOnly); + +exports.a = void 0; + +({ a: exports.a } = defaultCompat.b); +console.log({ a: exports.a } = defaultCompat.b); + +Promise.resolve().then(function () { return main; }).then(console.log); + +Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespaceCompat(require('external')); }).then(console.log); +console.log(defaultCompat__namespace.default); +console.log(externalAuto__default.default); +console.log(externalDefault__namespace); +console.log(externalDefaultOnly__namespace); + +var main = /*#__PURE__*/_mergeNamespaces({ + __proto__: null, + get a () { return exports.a; }, + foo: foo +}, [defaultCompat__namespace]); + +Object.defineProperty(exports, "foo", { + enumerable: true, + get: function () { return defaultCompat.foo; } +}); +Object.keys(defaultCompat).forEach(function (k) { + if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, { + enumerable: true, + get: function () { return defaultCompat[k]; } + }); +}); diff --git a/test/form/samples/generated-code/arrow-functions-false/_expected/es.js b/test/form/samples/generated-code/arrow-functions-false/_expected/es.js new file mode 100644 index 00000000000..74722401369 --- /dev/null +++ b/test/form/samples/generated-code/arrow-functions-false/_expected/es.js @@ -0,0 +1,44 @@ +import 'externalNoImport'; +import * as defaultCompat from 'external'; +import defaultCompat__default, { b } from 'external'; +export * from 'external'; +export { foo } from 'external'; +import externalAuto from 'externalAuto'; +import * as externalDefault from 'externalDefault'; +import * as externalDefaultOnly from 'externalDefaultOnly'; + +function _mergeNamespaces(n, m) { + m.forEach(function (e) { + e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) { + if (k !== 'default' && !(k in n)) { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + }); + return Object.freeze(n); +} + +let a; + +({ a } = b); +console.log({ a } = b); + +Promise.resolve().then(function () { return main; }).then(console.log); + +import('external').then(console.log); +console.log(defaultCompat__default); +console.log(externalAuto); +console.log(externalDefault); +console.log(externalDefaultOnly); + +var main = /*#__PURE__*/_mergeNamespaces({ + __proto__: null, + get a () { return a; }, + foo: foo +}, [defaultCompat]); + +export { a }; diff --git a/test/form/samples/generated-code/arrow-functions-false/_expected/iife.js b/test/form/samples/generated-code/arrow-functions-false/_expected/iife.js new file mode 100644 index 00000000000..2a598040937 --- /dev/null +++ b/test/form/samples/generated-code/arrow-functions-false/_expected/iife.js @@ -0,0 +1,79 @@ +var bundle = (function (exports, externalNoImport, defaultCompat, externalAuto, externalDefault, externalDefaultOnly) { + 'use strict'; + + function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; } + + function _interopNamespaceCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : _interopNamespaceDefault(e); } + + function _interopNamespaceDefaultOnly (e) { return Object.freeze({ __proto__: null, default: e }); } + + function _interopNamespaceDefault(e) { + var n = Object.create(null); + if (e) { + Object.keys(e).forEach(function (k) { + if (k !== 'default') { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + } + n.default = e; + return Object.freeze(n); + } + + function _mergeNamespaces(n, m) { + m.forEach(function (e) { + e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) { + if (k !== 'default' && !(k in n)) { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + }); + return Object.freeze(n); + } + + var defaultCompat__namespace = /*#__PURE__*/_interopNamespaceCompat(defaultCompat); + var externalAuto__default = /*#__PURE__*/_interopDefault(externalAuto); + var externalDefault__namespace = /*#__PURE__*/_interopNamespaceDefault(externalDefault); + var externalDefaultOnly__namespace = /*#__PURE__*/_interopNamespaceDefaultOnly(externalDefaultOnly); + + exports.a = void 0; + + ({ a: exports.a } = defaultCompat.b); + console.log({ a: exports.a } = defaultCompat.b); + + Promise.resolve().then(function () { return main; }).then(console.log); + + import('external').then(console.log); + console.log(defaultCompat__namespace.default); + console.log(externalAuto__default.default); + console.log(externalDefault__namespace); + console.log(externalDefaultOnly__namespace); + + var main = /*#__PURE__*/_mergeNamespaces({ + __proto__: null, + get a () { return exports.a; }, + foo: foo + }, [defaultCompat__namespace]); + + Object.defineProperty(exports, "foo", { + enumerable: true, + get: function () { return defaultCompat.foo; } + }); + Object.keys(defaultCompat).forEach(function (k) { + if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, { + enumerable: true, + get: function () { return defaultCompat[k]; } + }); + }); + + return exports; + +})({}, externalNoImport, external, externalAuto, externalDefault, externalDefaultOnly); diff --git a/test/form/samples/generated-code/arrow-functions-false/_expected/system.js b/test/form/samples/generated-code/arrow-functions-false/_expected/system.js new file mode 100644 index 00000000000..85cd5c9d3fc --- /dev/null +++ b/test/form/samples/generated-code/arrow-functions-false/_expected/system.js @@ -0,0 +1,65 @@ +System.register('bundle', ['externalNoImport', 'external', 'externalAuto', 'externalDefault', 'externalDefaultOnly'], (function (exports, module) { + 'use strict'; + var _starExcludes = { + __proto__: null, + a: 1, + default: 1, + foo: 1 + }; + var b, defaultCompat, defaultCompat__default, externalAuto, externalDefault, externalDefaultOnly; + return { + setters: [function () {}, function (module) { + b = module.b; + defaultCompat = module; + defaultCompat__default = module.default; + var setter = { __proto__: null, foo: module.foo }; + for (var name in module) { + if (!_starExcludes[name]) setter[name] = module[name]; + } + exports(setter); + }, function (module) { + externalAuto = module.default; + }, function (module) { + externalDefault = module; + }, function (module) { + externalDefaultOnly = module; + }], + execute: (function () { + + function _mergeNamespaces(n, m) { + m.forEach(function (e) { + e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) { + if (k !== 'default' && !(k in n)) { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + }); + return Object.freeze(n); + } + + let a; exports("a", a); + + (function (v) { return exports("a", a), v; })({ a } = b); + console.log(function (v) { return exports("a", a), v; }({ a } = b)); + + Promise.resolve().then(function () { return main; }).then(console.log); + + module.import('external').then(console.log); + console.log(defaultCompat__default); + console.log(externalAuto); + console.log(externalDefault); + console.log(externalDefaultOnly); + + var main = /*#__PURE__*/_mergeNamespaces({ + __proto__: null, + get a () { return a; }, + foo: foo + }, [defaultCompat]); + + }) + }; +})); diff --git a/test/form/samples/generated-code/arrow-functions-false/_expected/umd.js b/test/form/samples/generated-code/arrow-functions-false/_expected/umd.js new file mode 100644 index 00000000000..06eab843cd0 --- /dev/null +++ b/test/form/samples/generated-code/arrow-functions-false/_expected/umd.js @@ -0,0 +1,85 @@ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('externalNoImport'), require('external'), require('externalAuto'), require('externalDefault'), require('externalDefaultOnly')) : + typeof define === 'function' && define.amd ? define(['exports', 'externalNoImport', 'external', 'externalAuto', 'externalDefault', 'externalDefaultOnly'], factory) : + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, (function () { + var current = global.bundle; + var exports = global.bundle = {}; + factory(exports, global.externalNoImport, global.external, global.externalAuto, global.externalDefault, global.externalDefaultOnly); + exports.noConflict = function () { global.bundle = current; return exports; }; + })()); +})(this, (function (exports, externalNoImport, defaultCompat, externalAuto, externalDefault, externalDefaultOnly) { 'use strict'; + + function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; } + + function _interopNamespaceCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : _interopNamespaceDefault(e); } + + function _interopNamespaceDefaultOnly (e) { return Object.freeze({ __proto__: null, default: e }); } + + function _interopNamespaceDefault(e) { + var n = Object.create(null); + if (e) { + Object.keys(e).forEach(function (k) { + if (k !== 'default') { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + } + n.default = e; + return Object.freeze(n); + } + + function _mergeNamespaces(n, m) { + m.forEach(function (e) { + e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) { + if (k !== 'default' && !(k in n)) { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + }); + return Object.freeze(n); + } + + var defaultCompat__namespace = /*#__PURE__*/_interopNamespaceCompat(defaultCompat); + var externalAuto__default = /*#__PURE__*/_interopDefault(externalAuto); + var externalDefault__namespace = /*#__PURE__*/_interopNamespaceDefault(externalDefault); + var externalDefaultOnly__namespace = /*#__PURE__*/_interopNamespaceDefaultOnly(externalDefaultOnly); + + exports.a = void 0; + + ({ a: exports.a } = defaultCompat.b); + console.log({ a: exports.a } = defaultCompat.b); + + Promise.resolve().then(function () { return main; }).then(console.log); + + import('external').then(console.log); + console.log(defaultCompat__namespace.default); + console.log(externalAuto__default.default); + console.log(externalDefault__namespace); + console.log(externalDefaultOnly__namespace); + + var main = /*#__PURE__*/_mergeNamespaces({ + __proto__: null, + get a () { return exports.a; }, + foo: foo + }, [defaultCompat__namespace]); + + Object.defineProperty(exports, "foo", { + enumerable: true, + get: function () { return defaultCompat.foo; } + }); + Object.keys(defaultCompat).forEach(function (k) { + if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, { + enumerable: true, + get: function () { return defaultCompat[k]; } + }); + }); + +})); diff --git a/test/form/samples/generated-code/arrow-functions-false/main.js b/test/form/samples/generated-code/arrow-functions-false/main.js new file mode 100644 index 00000000000..06db4163961 --- /dev/null +++ b/test/form/samples/generated-code/arrow-functions-false/main.js @@ -0,0 +1,24 @@ +import 'externalNoImport'; +import { b } from 'external'; +export let a; + +null, { a } = b; +console.log({ a } = b); + +import('./main.js').then(console.log); + +import('external').then(console.log); +export * from 'external'; +export { foo } from 'external'; + +import defaultCompat from 'external'; +console.log(defaultCompat); + +import externalAuto from 'externalAuto'; +console.log(externalAuto); + +import * as externalDefault from 'externalDefault'; +console.log(externalDefault); + +import * as externalDefaultOnly from 'externalDefaultOnly'; +console.log(externalDefaultOnly); diff --git a/test/form/samples/generated-code/arrow-functions-true/_config.js b/test/form/samples/generated-code/arrow-functions-true/_config.js new file mode 100644 index 00000000000..40f2751dcbb --- /dev/null +++ b/test/form/samples/generated-code/arrow-functions-true/_config.js @@ -0,0 +1,34 @@ +module.exports = defineTest({ + description: 'uses arrow functions', + options: { + external: [ + 'external', + 'externalAuto', + 'externalDefault', + 'externalDefaultOnly', + 'externalNoImport' + ], + strictDeprecations: false, + output: { + dynamicImportInCjs: false, + generatedCode: { arrowFunctions: true }, + globals: id => id, + interop(id) { + if (id === 'externalDefault') { + return 'default'; + } + if (id === 'externalDefaultOnly') { + return 'defaultOnly'; + } + if (id === 'externalAuto') { + return 'auto'; + } + return 'compat'; + }, + name: 'bundle', + noConflict: true, + systemNullSetters: false + } + }, + expectedWarnings: ['DEPRECATED_FEATURE'] +}); diff --git a/test/form/samples/generated-code/arrow-functions-true/_expected/amd.js b/test/form/samples/generated-code/arrow-functions-true/_expected/amd.js new file mode 100644 index 00000000000..28a25806253 --- /dev/null +++ b/test/form/samples/generated-code/arrow-functions-true/_expected/amd.js @@ -0,0 +1,76 @@ +define(['require', 'exports', 'externalNoImport', 'external', 'externalAuto', 'externalDefault', 'externalDefaultOnly'], (function (require, exports, externalNoImport, defaultCompat, externalAuto, externalDefault, externalDefaultOnly) { 'use strict'; + + var _interopDefault = e => e && e.__esModule ? e : { default: e }; + + var _interopNamespaceCompat = e => e && typeof e === 'object' && 'default' in e ? e : _interopNamespaceDefault(e); + + var _interopNamespaceDefaultOnly = e => Object.freeze({ __proto__: null, default: e }); + + function _interopNamespaceDefault(e) { + var n = Object.create(null); + if (e) { + Object.keys(e).forEach(k => { + if (k !== 'default') { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: () => e[k] + }); + } + }); + } + n.default = e; + return Object.freeze(n); + } + + function _mergeNamespaces(n, m) { + m.forEach(e => + e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(k => { + if (k !== 'default' && !(k in n)) { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: () => e[k] + }); + } + }) + ); + return Object.freeze(n); + } + + var defaultCompat__namespace = /*#__PURE__*/_interopNamespaceCompat(defaultCompat); + var externalAuto__default = /*#__PURE__*/_interopDefault(externalAuto); + var externalDefault__namespace = /*#__PURE__*/_interopNamespaceDefault(externalDefault); + var externalDefaultOnly__namespace = /*#__PURE__*/_interopNamespaceDefaultOnly(externalDefaultOnly); + + exports.a = void 0; + + ({ a: exports.a } = defaultCompat.b); + console.log({ a: exports.a } = defaultCompat.b); + + Promise.resolve().then(() => main).then(console.log); + + new Promise((resolve, reject) => require(['external'], m => resolve(/*#__PURE__*/_interopNamespaceCompat(m)), reject)).then(console.log); + console.log(defaultCompat__namespace.default); + console.log(externalAuto__default.default); + console.log(externalDefault__namespace); + console.log(externalDefaultOnly__namespace); + + var main = /*#__PURE__*/_mergeNamespaces({ + __proto__: null, + get a () { return exports.a; }, + foo: foo + }, [defaultCompat__namespace]); + + Object.defineProperty(exports, "foo", { + enumerable: true, + get: () => defaultCompat.foo + }); + Object.keys(defaultCompat).forEach(k => { + if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, { + enumerable: true, + get: () => defaultCompat[k] + }); + }); + +})); diff --git a/test/form/samples/generated-code/arrow-functions-true/_expected/cjs.js b/test/form/samples/generated-code/arrow-functions-true/_expected/cjs.js new file mode 100644 index 00000000000..f61b91e755f --- /dev/null +++ b/test/form/samples/generated-code/arrow-functions-true/_expected/cjs.js @@ -0,0 +1,80 @@ +'use strict'; + +require('externalNoImport'); +var defaultCompat = require('external'); +var externalAuto = require('externalAuto'); +var externalDefault = require('externalDefault'); +var externalDefaultOnly = require('externalDefaultOnly'); + +var _interopDefault = e => e && e.__esModule ? e : { default: e }; + +var _interopNamespaceCompat = e => e && typeof e === 'object' && 'default' in e ? e : _interopNamespaceDefault(e); + +var _interopNamespaceDefaultOnly = e => Object.freeze({ __proto__: null, default: e }); + +function _interopNamespaceDefault(e) { + var n = Object.create(null); + if (e) { + Object.keys(e).forEach(k => { + if (k !== 'default') { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: () => e[k] + }); + } + }); + } + n.default = e; + return Object.freeze(n); +} + +function _mergeNamespaces(n, m) { + m.forEach(e => + e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(k => { + if (k !== 'default' && !(k in n)) { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: () => e[k] + }); + } + }) + ); + return Object.freeze(n); +} + +var defaultCompat__namespace = /*#__PURE__*/_interopNamespaceCompat(defaultCompat); +var externalAuto__default = /*#__PURE__*/_interopDefault(externalAuto); +var externalDefault__namespace = /*#__PURE__*/_interopNamespaceDefault(externalDefault); +var externalDefaultOnly__namespace = /*#__PURE__*/_interopNamespaceDefaultOnly(externalDefaultOnly); + +exports.a = void 0; + +({ a: exports.a } = defaultCompat.b); +console.log({ a: exports.a } = defaultCompat.b); + +Promise.resolve().then(() => main).then(console.log); + +Promise.resolve().then(() => /*#__PURE__*/_interopNamespaceCompat(require('external'))).then(console.log); +console.log(defaultCompat__namespace.default); +console.log(externalAuto__default.default); +console.log(externalDefault__namespace); +console.log(externalDefaultOnly__namespace); + +var main = /*#__PURE__*/_mergeNamespaces({ + __proto__: null, + get a () { return exports.a; }, + foo: foo +}, [defaultCompat__namespace]); + +Object.defineProperty(exports, "foo", { + enumerable: true, + get: () => defaultCompat.foo +}); +Object.keys(defaultCompat).forEach(k => { + if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, { + enumerable: true, + get: () => defaultCompat[k] + }); +}); diff --git a/test/form/samples/generated-code/arrow-functions-true/_expected/es.js b/test/form/samples/generated-code/arrow-functions-true/_expected/es.js new file mode 100644 index 00000000000..bed422f4b5c --- /dev/null +++ b/test/form/samples/generated-code/arrow-functions-true/_expected/es.js @@ -0,0 +1,44 @@ +import 'externalNoImport'; +import * as defaultCompat from 'external'; +import defaultCompat__default, { b } from 'external'; +export * from 'external'; +export { foo } from 'external'; +import externalAuto from 'externalAuto'; +import * as externalDefault from 'externalDefault'; +import * as externalDefaultOnly from 'externalDefaultOnly'; + +function _mergeNamespaces(n, m) { + m.forEach(e => + e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(k => { + if (k !== 'default' && !(k in n)) { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: () => e[k] + }); + } + }) + ); + return Object.freeze(n); +} + +let a; + +({ a } = b); +console.log({ a } = b); + +Promise.resolve().then(() => main).then(console.log); + +import('external').then(console.log); +console.log(defaultCompat__default); +console.log(externalAuto); +console.log(externalDefault); +console.log(externalDefaultOnly); + +var main = /*#__PURE__*/_mergeNamespaces({ + __proto__: null, + get a () { return a; }, + foo: foo +}, [defaultCompat]); + +export { a }; diff --git a/test/form/samples/generated-code/arrow-functions-true/_expected/iife.js b/test/form/samples/generated-code/arrow-functions-true/_expected/iife.js new file mode 100644 index 00000000000..c2b81889f42 --- /dev/null +++ b/test/form/samples/generated-code/arrow-functions-true/_expected/iife.js @@ -0,0 +1,79 @@ +var bundle = (function (exports, externalNoImport, defaultCompat, externalAuto, externalDefault, externalDefaultOnly) { + 'use strict'; + + var _interopDefault = e => e && e.__esModule ? e : { default: e }; + + var _interopNamespaceCompat = e => e && typeof e === 'object' && 'default' in e ? e : _interopNamespaceDefault(e); + + var _interopNamespaceDefaultOnly = e => Object.freeze({ __proto__: null, default: e }); + + function _interopNamespaceDefault(e) { + var n = Object.create(null); + if (e) { + Object.keys(e).forEach(k => { + if (k !== 'default') { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: () => e[k] + }); + } + }); + } + n.default = e; + return Object.freeze(n); + } + + function _mergeNamespaces(n, m) { + m.forEach(e => + e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(k => { + if (k !== 'default' && !(k in n)) { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: () => e[k] + }); + } + }) + ); + return Object.freeze(n); + } + + var defaultCompat__namespace = /*#__PURE__*/_interopNamespaceCompat(defaultCompat); + var externalAuto__default = /*#__PURE__*/_interopDefault(externalAuto); + var externalDefault__namespace = /*#__PURE__*/_interopNamespaceDefault(externalDefault); + var externalDefaultOnly__namespace = /*#__PURE__*/_interopNamespaceDefaultOnly(externalDefaultOnly); + + exports.a = void 0; + + ({ a: exports.a } = defaultCompat.b); + console.log({ a: exports.a } = defaultCompat.b); + + Promise.resolve().then(() => main).then(console.log); + + import('external').then(console.log); + console.log(defaultCompat__namespace.default); + console.log(externalAuto__default.default); + console.log(externalDefault__namespace); + console.log(externalDefaultOnly__namespace); + + var main = /*#__PURE__*/_mergeNamespaces({ + __proto__: null, + get a () { return exports.a; }, + foo: foo + }, [defaultCompat__namespace]); + + Object.defineProperty(exports, "foo", { + enumerable: true, + get: () => defaultCompat.foo + }); + Object.keys(defaultCompat).forEach(k => { + if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, { + enumerable: true, + get: () => defaultCompat[k] + }); + }); + + return exports; + +})({}, externalNoImport, external, externalAuto, externalDefault, externalDefaultOnly); diff --git a/test/form/samples/generated-code/arrow-functions-true/_expected/system.js b/test/form/samples/generated-code/arrow-functions-true/_expected/system.js new file mode 100644 index 00000000000..5296d578d74 --- /dev/null +++ b/test/form/samples/generated-code/arrow-functions-true/_expected/system.js @@ -0,0 +1,65 @@ +System.register('bundle', ['externalNoImport', 'external', 'externalAuto', 'externalDefault', 'externalDefaultOnly'], (function (exports, module) { + 'use strict'; + var _starExcludes = { + __proto__: null, + a: 1, + default: 1, + foo: 1 + }; + var b, defaultCompat, defaultCompat__default, externalAuto, externalDefault, externalDefaultOnly; + return { + setters: [() => {}, module => { + b = module.b; + defaultCompat = module; + defaultCompat__default = module.default; + var setter = { __proto__: null, foo: module.foo }; + for (var name in module) { + if (!_starExcludes[name]) setter[name] = module[name]; + } + exports(setter); + }, module => { + externalAuto = module.default; + }, module => { + externalDefault = module; + }, module => { + externalDefaultOnly = module; + }], + execute: (function () { + + function _mergeNamespaces(n, m) { + m.forEach(e => + e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(k => { + if (k !== 'default' && !(k in n)) { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: () => e[k] + }); + } + }) + ); + return Object.freeze(n); + } + + let a; exports("a", a); + + (v => (exports("a", a), v))({ a } = b); + console.log((v => (exports("a", a), v))({ a } = b)); + + Promise.resolve().then(() => main).then(console.log); + + module.import('external').then(console.log); + console.log(defaultCompat__default); + console.log(externalAuto); + console.log(externalDefault); + console.log(externalDefaultOnly); + + var main = /*#__PURE__*/_mergeNamespaces({ + __proto__: null, + get a () { return a; }, + foo: foo + }, [defaultCompat]); + + }) + }; +})); diff --git a/test/form/samples/generated-code/arrow-functions-true/_expected/umd.js b/test/form/samples/generated-code/arrow-functions-true/_expected/umd.js new file mode 100644 index 00000000000..c4c25fe78e7 --- /dev/null +++ b/test/form/samples/generated-code/arrow-functions-true/_expected/umd.js @@ -0,0 +1,85 @@ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('externalNoImport'), require('external'), require('externalAuto'), require('externalDefault'), require('externalDefaultOnly')) : + typeof define === 'function' && define.amd ? define(['exports', 'externalNoImport', 'external', 'externalAuto', 'externalDefault', 'externalDefaultOnly'], factory) : + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, (() => { + var current = global.bundle; + var exports = global.bundle = {}; + factory(exports, global.externalNoImport, global.external, global.externalAuto, global.externalDefault, global.externalDefaultOnly); + exports.noConflict = () => { global.bundle = current; return exports; }; + })()); +})(this, (function (exports, externalNoImport, defaultCompat, externalAuto, externalDefault, externalDefaultOnly) { 'use strict'; + + var _interopDefault = e => e && e.__esModule ? e : { default: e }; + + var _interopNamespaceCompat = e => e && typeof e === 'object' && 'default' in e ? e : _interopNamespaceDefault(e); + + var _interopNamespaceDefaultOnly = e => Object.freeze({ __proto__: null, default: e }); + + function _interopNamespaceDefault(e) { + var n = Object.create(null); + if (e) { + Object.keys(e).forEach(k => { + if (k !== 'default') { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: () => e[k] + }); + } + }); + } + n.default = e; + return Object.freeze(n); + } + + function _mergeNamespaces(n, m) { + m.forEach(e => + e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(k => { + if (k !== 'default' && !(k in n)) { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: () => e[k] + }); + } + }) + ); + return Object.freeze(n); + } + + var defaultCompat__namespace = /*#__PURE__*/_interopNamespaceCompat(defaultCompat); + var externalAuto__default = /*#__PURE__*/_interopDefault(externalAuto); + var externalDefault__namespace = /*#__PURE__*/_interopNamespaceDefault(externalDefault); + var externalDefaultOnly__namespace = /*#__PURE__*/_interopNamespaceDefaultOnly(externalDefaultOnly); + + exports.a = void 0; + + ({ a: exports.a } = defaultCompat.b); + console.log({ a: exports.a } = defaultCompat.b); + + Promise.resolve().then(() => main).then(console.log); + + import('external').then(console.log); + console.log(defaultCompat__namespace.default); + console.log(externalAuto__default.default); + console.log(externalDefault__namespace); + console.log(externalDefaultOnly__namespace); + + var main = /*#__PURE__*/_mergeNamespaces({ + __proto__: null, + get a () { return exports.a; }, + foo: foo + }, [defaultCompat__namespace]); + + Object.defineProperty(exports, "foo", { + enumerable: true, + get: () => defaultCompat.foo + }); + Object.keys(defaultCompat).forEach(k => { + if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, { + enumerable: true, + get: () => defaultCompat[k] + }); + }); + +})); diff --git a/test/form/samples/generated-code/arrow-functions-true/main.js b/test/form/samples/generated-code/arrow-functions-true/main.js new file mode 120000 index 00000000000..e5cef6e9cde --- /dev/null +++ b/test/form/samples/generated-code/arrow-functions-true/main.js @@ -0,0 +1 @@ +../arrow-functions-false/main.js \ No newline at end of file diff --git a/test/form/samples/generated-code/const-bindings-false/_config.js b/test/form/samples/generated-code/const-bindings-false/_config.js new file mode 100644 index 00000000000..70092a6b918 --- /dev/null +++ b/test/form/samples/generated-code/const-bindings-false/_config.js @@ -0,0 +1,26 @@ +module.exports = defineTest({ + description: 'does not use block bindings', + expectedWarnings: ['SHIMMED_EXPORT'], + options: { + external: ['external'], + shimMissingExports: true, + output: { + exports: 'named', + generatedCode: { arrowFunctions: true, constBindings: false }, + globals: id => id, + interop: 'compat', + name: 'bundle', + noConflict: true + }, + plugins: [ + { + name: 'test', + transform(code, id) { + if (id.endsWith('synthetic.js')) { + return { syntheticNamedExports: true }; + } + } + } + ] + } +}); diff --git a/test/form/samples/generated-code/const-bindings-false/_expected/amd.js b/test/form/samples/generated-code/const-bindings-false/_expected/amd.js new file mode 100644 index 00000000000..db89cf0ce96 --- /dev/null +++ b/test/form/samples/generated-code/const-bindings-false/_expected/amd.js @@ -0,0 +1,49 @@ +define(['exports', 'external'], (function (exports, foo$1) { 'use strict'; + + function _interopNamespaceCompat(e) { + if (e && typeof e === 'object' && 'default' in e) return e; + var n = Object.create(null); + if (e) { + Object.keys(e).forEach(k => { + if (k !== 'default') { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: () => e[k] + }); + } + }); + } + n.default = e; + return Object.freeze(n); + } + + var foo__namespace = /*#__PURE__*/_interopNamespaceCompat(foo$1); + + var _missingExportShim = void 0; + + const foo = 'bar'; + + var other = /*#__PURE__*/Object.freeze({ + __proto__: null, + foo: foo, + missing: _missingExportShim + }); + + var synthetic = { bar: 'baz'}; + + console.log(foo__namespace.default, foo__namespace, other, synthetic.bar, _missingExportShim); + var main = 42; + + exports.default = main; + exports.syntheticMissing = synthetic.syntheticMissing; + Object.keys(foo$1).forEach(k => { + if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, { + enumerable: true, + get: () => foo$1[k] + }); + }); + + Object.defineProperty(exports, '__esModule', { value: true }); + +})); diff --git a/test/form/samples/generated-code/const-bindings-false/_expected/cjs.js b/test/form/samples/generated-code/const-bindings-false/_expected/cjs.js new file mode 100644 index 00000000000..5ae5ab7553d --- /dev/null +++ b/test/form/samples/generated-code/const-bindings-false/_expected/cjs.js @@ -0,0 +1,49 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { value: true }); + +var foo$1 = require('external'); + +function _interopNamespaceCompat(e) { + if (e && typeof e === 'object' && 'default' in e) return e; + var n = Object.create(null); + if (e) { + Object.keys(e).forEach(k => { + if (k !== 'default') { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: () => e[k] + }); + } + }); + } + n.default = e; + return Object.freeze(n); +} + +var foo__namespace = /*#__PURE__*/_interopNamespaceCompat(foo$1); + +var _missingExportShim = void 0; + +const foo = 'bar'; + +var other = /*#__PURE__*/Object.freeze({ + __proto__: null, + foo: foo, + missing: _missingExportShim +}); + +var synthetic = { bar: 'baz'}; + +console.log(foo__namespace.default, foo__namespace, other, synthetic.bar, _missingExportShim); +var main = 42; + +exports.default = main; +exports.syntheticMissing = synthetic.syntheticMissing; +Object.keys(foo$1).forEach(k => { + if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, { + enumerable: true, + get: () => foo$1[k] + }); +}); diff --git a/test/form/samples/generated-code/const-bindings-false/_expected/es.js b/test/form/samples/generated-code/const-bindings-false/_expected/es.js new file mode 100644 index 00000000000..eed5b9f8e1a --- /dev/null +++ b/test/form/samples/generated-code/const-bindings-false/_expected/es.js @@ -0,0 +1,21 @@ +import * as foo$1 from 'external'; +import foo__default from 'external'; +export * from 'external'; + +var _missingExportShim = void 0; + +const foo = 'bar'; + +var other = /*#__PURE__*/Object.freeze({ + __proto__: null, + foo: foo, + missing: _missingExportShim +}); + +var synthetic = { bar: 'baz'}; + +console.log(foo__default, foo$1, other, synthetic.bar, _missingExportShim); +var main = 42; + +var syntheticMissing = synthetic.syntheticMissing; +export { main as default, syntheticMissing }; diff --git a/test/form/samples/generated-code/const-bindings-false/_expected/iife.js b/test/form/samples/generated-code/const-bindings-false/_expected/iife.js new file mode 100644 index 00000000000..91880331edd --- /dev/null +++ b/test/form/samples/generated-code/const-bindings-false/_expected/iife.js @@ -0,0 +1,52 @@ +var bundle = (function (exports, foo$1) { + 'use strict'; + + function _interopNamespaceCompat(e) { + if (e && typeof e === 'object' && 'default' in e) return e; + var n = Object.create(null); + if (e) { + Object.keys(e).forEach(k => { + if (k !== 'default') { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: () => e[k] + }); + } + }); + } + n.default = e; + return Object.freeze(n); + } + + var foo__namespace = /*#__PURE__*/_interopNamespaceCompat(foo$1); + + var _missingExportShim = void 0; + + const foo = 'bar'; + + var other = /*#__PURE__*/Object.freeze({ + __proto__: null, + foo: foo, + missing: _missingExportShim + }); + + var synthetic = { bar: 'baz'}; + + console.log(foo__namespace.default, foo__namespace, other, synthetic.bar, _missingExportShim); + var main = 42; + + exports.default = main; + exports.syntheticMissing = synthetic.syntheticMissing; + Object.keys(foo$1).forEach(k => { + if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, { + enumerable: true, + get: () => foo$1[k] + }); + }); + + Object.defineProperty(exports, '__esModule', { value: true }); + + return exports; + +})({}, external); diff --git a/test/form/samples/generated-code/const-bindings-false/_expected/system.js b/test/form/samples/generated-code/const-bindings-false/_expected/system.js new file mode 100644 index 00000000000..cc84886c0ca --- /dev/null +++ b/test/form/samples/generated-code/const-bindings-false/_expected/system.js @@ -0,0 +1,40 @@ +System.register('bundle', ['external'], (function (exports) { + 'use strict'; + var _starExcludes = { + __proto__: null, + default: 1, + syntheticMissing: 1 + }; + var foo__default, foo$1; + return { + setters: [module => { + foo__default = module.default; + foo$1 = module; + var setter = { __proto__: null }; + for (var name in module) { + if (!_starExcludes[name]) setter[name] = module[name]; + } + exports(setter); + }], + execute: (function () { + + var _missingExportShim = void 0; + + const foo = 'bar'; + + var other = /*#__PURE__*/Object.freeze({ + __proto__: null, + foo: foo, + missing: _missingExportShim + }); + + var synthetic = { bar: 'baz'}; + + console.log(foo__default, foo$1, other, synthetic.bar, _missingExportShim); + var main = exports("default", 42); + + exports("syntheticMissing", synthetic.syntheticMissing); + + }) + }; +})); diff --git a/test/form/samples/generated-code/const-bindings-false/_expected/umd.js b/test/form/samples/generated-code/const-bindings-false/_expected/umd.js new file mode 100644 index 00000000000..2f59245c321 --- /dev/null +++ b/test/form/samples/generated-code/const-bindings-false/_expected/umd.js @@ -0,0 +1,58 @@ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('external')) : + typeof define === 'function' && define.amd ? define(['exports', 'external'], factory) : + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, (() => { + var current = global.bundle; + var exports = global.bundle = {}; + factory(exports, global.external); + exports.noConflict = () => { global.bundle = current; return exports; }; + })()); +})(this, (function (exports, foo$1) { 'use strict'; + + function _interopNamespaceCompat(e) { + if (e && typeof e === 'object' && 'default' in e) return e; + var n = Object.create(null); + if (e) { + Object.keys(e).forEach(k => { + if (k !== 'default') { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: () => e[k] + }); + } + }); + } + n.default = e; + return Object.freeze(n); + } + + var foo__namespace = /*#__PURE__*/_interopNamespaceCompat(foo$1); + + var _missingExportShim = void 0; + + const foo = 'bar'; + + var other = /*#__PURE__*/Object.freeze({ + __proto__: null, + foo: foo, + missing: _missingExportShim + }); + + var synthetic = { bar: 'baz'}; + + console.log(foo__namespace.default, foo__namespace, other, synthetic.bar, _missingExportShim); + var main = 42; + + exports.default = main; + exports.syntheticMissing = synthetic.syntheticMissing; + Object.keys(foo$1).forEach(k => { + if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, { + enumerable: true, + get: () => foo$1[k] + }); + }); + + Object.defineProperty(exports, '__esModule', { value: true }); + +})); diff --git a/test/form/samples/generated-code/const-bindings-false/main.js b/test/form/samples/generated-code/const-bindings-false/main.js new file mode 100644 index 00000000000..e7828346010 --- /dev/null +++ b/test/form/samples/generated-code/const-bindings-false/main.js @@ -0,0 +1,8 @@ +import foo, * as ns from 'external'; +import * as other from './other'; +import { missing } from './other'; +import { bar } from './synthetic'; +export { syntheticMissing } from './synthetic'; +console.log(foo, ns, other, bar, missing); +export * from 'external'; +export default 42; diff --git a/test/form/samples/generated-code/const-bindings-false/other.js b/test/form/samples/generated-code/const-bindings-false/other.js new file mode 100644 index 00000000000..c155820bf77 --- /dev/null +++ b/test/form/samples/generated-code/const-bindings-false/other.js @@ -0,0 +1 @@ +export const foo = 'bar'; diff --git a/test/form/samples/generated-code/const-bindings-false/synthetic.js b/test/form/samples/generated-code/const-bindings-false/synthetic.js new file mode 100644 index 00000000000..cba461594c4 --- /dev/null +++ b/test/form/samples/generated-code/const-bindings-false/synthetic.js @@ -0,0 +1 @@ +export default { bar: 'baz', unused: 'removed' }; diff --git a/test/form/samples/generated-code/const-bindings-true/_config.js b/test/form/samples/generated-code/const-bindings-true/_config.js new file mode 100644 index 00000000000..072718bf429 --- /dev/null +++ b/test/form/samples/generated-code/const-bindings-true/_config.js @@ -0,0 +1,26 @@ +module.exports = defineTest({ + description: 'uses block bindings', + expectedWarnings: ['SHIMMED_EXPORT'], + options: { + external: ['external'], + shimMissingExports: true, + output: { + exports: 'named', + generatedCode: { arrowFunctions: true, constBindings: true }, + globals: id => id, + interop: 'compat', + name: 'bundle', + noConflict: true + }, + plugins: [ + { + name: 'test', + transform(code, id) { + if (id.endsWith('synthetic.js')) { + return { syntheticNamedExports: true }; + } + } + } + ] + } +}); diff --git a/test/form/samples/generated-code/const-bindings-true/_expected/amd.js b/test/form/samples/generated-code/const-bindings-true/_expected/amd.js new file mode 100644 index 00000000000..e4a343e05b7 --- /dev/null +++ b/test/form/samples/generated-code/const-bindings-true/_expected/amd.js @@ -0,0 +1,49 @@ +define(['exports', 'external'], (function (exports, foo$1) { 'use strict'; + + function _interopNamespaceCompat(e) { + if (e && typeof e === 'object' && 'default' in e) return e; + const n = Object.create(null); + if (e) { + for (const k in e) { + if (k !== 'default') { + const d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: () => e[k] + }); + } + } + } + n.default = e; + return Object.freeze(n); + } + + const foo__namespace = /*#__PURE__*/_interopNamespaceCompat(foo$1); + + const _missingExportShim = void 0; + + const foo = 'bar'; + + const other = /*#__PURE__*/Object.freeze({ + __proto__: null, + foo: foo, + missing: _missingExportShim + }); + + const synthetic = { bar: 'baz'}; + + console.log(foo__namespace.default, foo__namespace, other, synthetic.bar, _missingExportShim); + const main = 42; + + exports.default = main; + exports.syntheticMissing = synthetic.syntheticMissing; + Object.keys(foo$1).forEach(k => { + if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, { + enumerable: true, + get: () => foo$1[k] + }); + }); + + Object.defineProperty(exports, '__esModule', { value: true }); + +})); diff --git a/test/form/samples/generated-code/const-bindings-true/_expected/cjs.js b/test/form/samples/generated-code/const-bindings-true/_expected/cjs.js new file mode 100644 index 00000000000..b81037586bd --- /dev/null +++ b/test/form/samples/generated-code/const-bindings-true/_expected/cjs.js @@ -0,0 +1,49 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { value: true }); + +const foo$1 = require('external'); + +function _interopNamespaceCompat(e) { + if (e && typeof e === 'object' && 'default' in e) return e; + const n = Object.create(null); + if (e) { + for (const k in e) { + if (k !== 'default') { + const d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: () => e[k] + }); + } + } + } + n.default = e; + return Object.freeze(n); +} + +const foo__namespace = /*#__PURE__*/_interopNamespaceCompat(foo$1); + +const _missingExportShim = void 0; + +const foo = 'bar'; + +const other = /*#__PURE__*/Object.freeze({ + __proto__: null, + foo: foo, + missing: _missingExportShim +}); + +const synthetic = { bar: 'baz'}; + +console.log(foo__namespace.default, foo__namespace, other, synthetic.bar, _missingExportShim); +const main = 42; + +exports.default = main; +exports.syntheticMissing = synthetic.syntheticMissing; +Object.keys(foo$1).forEach(k => { + if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, { + enumerable: true, + get: () => foo$1[k] + }); +}); diff --git a/test/form/samples/generated-code/const-bindings-true/_expected/es.js b/test/form/samples/generated-code/const-bindings-true/_expected/es.js new file mode 100644 index 00000000000..8ac67a3c469 --- /dev/null +++ b/test/form/samples/generated-code/const-bindings-true/_expected/es.js @@ -0,0 +1,21 @@ +import * as foo$1 from 'external'; +import foo__default from 'external'; +export * from 'external'; + +const _missingExportShim = void 0; + +const foo = 'bar'; + +const other = /*#__PURE__*/Object.freeze({ + __proto__: null, + foo: foo, + missing: _missingExportShim +}); + +const synthetic = { bar: 'baz'}; + +console.log(foo__default, foo$1, other, synthetic.bar, _missingExportShim); +const main = 42; + +const syntheticMissing = synthetic.syntheticMissing; +export { main as default, syntheticMissing }; diff --git a/test/form/samples/generated-code/const-bindings-true/_expected/iife.js b/test/form/samples/generated-code/const-bindings-true/_expected/iife.js new file mode 100644 index 00000000000..5a73e29f589 --- /dev/null +++ b/test/form/samples/generated-code/const-bindings-true/_expected/iife.js @@ -0,0 +1,52 @@ +var bundle = (function (exports, foo$1) { + 'use strict'; + + function _interopNamespaceCompat(e) { + if (e && typeof e === 'object' && 'default' in e) return e; + const n = Object.create(null); + if (e) { + for (const k in e) { + if (k !== 'default') { + const d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: () => e[k] + }); + } + } + } + n.default = e; + return Object.freeze(n); + } + + const foo__namespace = /*#__PURE__*/_interopNamespaceCompat(foo$1); + + const _missingExportShim = void 0; + + const foo = 'bar'; + + const other = /*#__PURE__*/Object.freeze({ + __proto__: null, + foo: foo, + missing: _missingExportShim + }); + + const synthetic = { bar: 'baz'}; + + console.log(foo__namespace.default, foo__namespace, other, synthetic.bar, _missingExportShim); + const main = 42; + + exports.default = main; + exports.syntheticMissing = synthetic.syntheticMissing; + Object.keys(foo$1).forEach(k => { + if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, { + enumerable: true, + get: () => foo$1[k] + }); + }); + + Object.defineProperty(exports, '__esModule', { value: true }); + + return exports; + +})({}, external); diff --git a/test/form/samples/generated-code/const-bindings-true/_expected/system.js b/test/form/samples/generated-code/const-bindings-true/_expected/system.js new file mode 100644 index 00000000000..4f717ee83a1 --- /dev/null +++ b/test/form/samples/generated-code/const-bindings-true/_expected/system.js @@ -0,0 +1,40 @@ +System.register('bundle', ['external'], (function (exports) { + 'use strict'; + const _starExcludes = { + __proto__: null, + default: 1, + syntheticMissing: 1 + }; + var foo__default, foo$1; + return { + setters: [module => { + foo__default = module.default; + foo$1 = module; + const setter = { __proto__: null }; + for (const name in module) { + if (!_starExcludes[name]) setter[name] = module[name]; + } + exports(setter); + }], + execute: (function () { + + const _missingExportShim = void 0; + + const foo = 'bar'; + + const other = /*#__PURE__*/Object.freeze({ + __proto__: null, + foo: foo, + missing: _missingExportShim + }); + + const synthetic = { bar: 'baz'}; + + console.log(foo__default, foo$1, other, synthetic.bar, _missingExportShim); + const main = exports("default", 42); + + exports("syntheticMissing", synthetic.syntheticMissing); + + }) + }; +})); diff --git a/test/form/samples/generated-code/const-bindings-true/_expected/umd.js b/test/form/samples/generated-code/const-bindings-true/_expected/umd.js new file mode 100644 index 00000000000..4121946e09c --- /dev/null +++ b/test/form/samples/generated-code/const-bindings-true/_expected/umd.js @@ -0,0 +1,58 @@ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('external')) : + typeof define === 'function' && define.amd ? define(['exports', 'external'], factory) : + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, (() => { + const current = global.bundle; + const exports = global.bundle = {}; + factory(exports, global.external); + exports.noConflict = () => { global.bundle = current; return exports; }; + })()); +})(this, (function (exports, foo$1) { 'use strict'; + + function _interopNamespaceCompat(e) { + if (e && typeof e === 'object' && 'default' in e) return e; + const n = Object.create(null); + if (e) { + for (const k in e) { + if (k !== 'default') { + const d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: () => e[k] + }); + } + } + } + n.default = e; + return Object.freeze(n); + } + + const foo__namespace = /*#__PURE__*/_interopNamespaceCompat(foo$1); + + const _missingExportShim = void 0; + + const foo = 'bar'; + + const other = /*#__PURE__*/Object.freeze({ + __proto__: null, + foo: foo, + missing: _missingExportShim + }); + + const synthetic = { bar: 'baz'}; + + console.log(foo__namespace.default, foo__namespace, other, synthetic.bar, _missingExportShim); + const main = 42; + + exports.default = main; + exports.syntheticMissing = synthetic.syntheticMissing; + Object.keys(foo$1).forEach(k => { + if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, { + enumerable: true, + get: () => foo$1[k] + }); + }); + + Object.defineProperty(exports, '__esModule', { value: true }); + +})); diff --git a/test/form/samples/generated-code/const-bindings-true/main.js b/test/form/samples/generated-code/const-bindings-true/main.js new file mode 120000 index 00000000000..3fa65076585 --- /dev/null +++ b/test/form/samples/generated-code/const-bindings-true/main.js @@ -0,0 +1 @@ +../../generated-code/const-bindings-false/main.js \ No newline at end of file diff --git a/test/form/samples/generated-code/object-shorthand-false/_config.js b/test/form/samples/generated-code/object-shorthand-false/_config.js new file mode 100644 index 00000000000..dabf728a180 --- /dev/null +++ b/test/form/samples/generated-code/object-shorthand-false/_config.js @@ -0,0 +1,11 @@ +module.exports = defineTest({ + description: 'does not use object shorthand syntax', + options: { + output: { + exports: 'named', + format: 'system', + generatedCode: { objectShorthand: false }, + name: 'bundle' + } + } +}); diff --git a/test/form/samples/generated-code/object-shorthand-false/_expected.js b/test/form/samples/generated-code/object-shorthand-false/_expected.js new file mode 100644 index 00000000000..2286fbc91cd --- /dev/null +++ b/test/form/samples/generated-code/object-shorthand-false/_expected.js @@ -0,0 +1,21 @@ +System.register('bundle', [], (function (exports) { + 'use strict'; + return { + execute: (function () { + + const a = 'a'; + + var ns = /*#__PURE__*/Object.freeze({ + __proto__: null, + a: a, + b: a, + default: a + }); + + console.log(ns); + + const foo = 1; exports({ bar: foo, default: foo, foo: foo }); + + }) + }; +})); diff --git a/test/form/samples/generated-code/object-shorthand-false/main.js b/test/form/samples/generated-code/object-shorthand-false/main.js new file mode 100644 index 00000000000..cbf74148be2 --- /dev/null +++ b/test/form/samples/generated-code/object-shorthand-false/main.js @@ -0,0 +1,5 @@ +import * as ns from './other.js'; +console.log(ns); + +const foo = 1; +export { foo, foo as bar, foo as default }; diff --git a/test/form/samples/generated-code/object-shorthand-false/other.js b/test/form/samples/generated-code/object-shorthand-false/other.js new file mode 100644 index 00000000000..e30e31333c8 --- /dev/null +++ b/test/form/samples/generated-code/object-shorthand-false/other.js @@ -0,0 +1,2 @@ +const a = 'a'; +export { a, a as b, a as default }; diff --git a/test/form/samples/generated-code/object-shorthand-true/_config.js b/test/form/samples/generated-code/object-shorthand-true/_config.js new file mode 100644 index 00000000000..65f0bd04d5f --- /dev/null +++ b/test/form/samples/generated-code/object-shorthand-true/_config.js @@ -0,0 +1,11 @@ +module.exports = defineTest({ + description: 'uses object shorthand syntax', + options: { + output: { + exports: 'named', + format: 'system', + generatedCode: { objectShorthand: true }, + name: 'bundle' + } + } +}); diff --git a/test/form/samples/generated-code/object-shorthand-true/_expected.js b/test/form/samples/generated-code/object-shorthand-true/_expected.js new file mode 100644 index 00000000000..3753e9ad143 --- /dev/null +++ b/test/form/samples/generated-code/object-shorthand-true/_expected.js @@ -0,0 +1,21 @@ +System.register('bundle', [], (function (exports) { + 'use strict'; + return { + execute: (function () { + + const a = 'a'; + + var ns = /*#__PURE__*/Object.freeze({ + __proto__: null, + a, + b: a, + default: a + }); + + console.log(ns); + + const foo = 1; exports({ bar: foo, default: foo, foo }); + + }) + }; +})); diff --git a/test/form/samples/generated-code/object-shorthand-true/main.js b/test/form/samples/generated-code/object-shorthand-true/main.js new file mode 120000 index 00000000000..21bdc213a91 --- /dev/null +++ b/test/form/samples/generated-code/object-shorthand-true/main.js @@ -0,0 +1 @@ +../../generated-code/object-shorthand-false/main.js \ No newline at end of file diff --git a/test/form/samples/generated-code/reserved-names-as-props-false-no-external-live-bindings/_config.js b/test/form/samples/generated-code/reserved-names-as-props-false-no-external-live-bindings/_config.js new file mode 100644 index 00000000000..6a108abffa7 --- /dev/null +++ b/test/form/samples/generated-code/reserved-names-as-props-false-no-external-live-bindings/_config.js @@ -0,0 +1,14 @@ +module.exports = defineTest({ + description: 'escapes reserved names used as props when external live-bindings are off', + options: { + external: ['external'], + output: { + exports: 'named', + externalLiveBindings: false, + generatedCode: { reservedNamesAsProps: false }, + globals: id => id, + interop: 'compat', + name: 'bundle' + } + } +}); diff --git a/test/form/samples/generated-code/reserved-names-as-props-false-no-external-live-bindings/_expected/amd.js b/test/form/samples/generated-code/reserved-names-as-props-false-no-external-live-bindings/_expected/amd.js new file mode 100644 index 00000000000..6ac599a7021 --- /dev/null +++ b/test/form/samples/generated-code/reserved-names-as-props-false-no-external-live-bindings/_expected/amd.js @@ -0,0 +1,9 @@ +define(['external'], (function (ns) { 'use strict'; + + function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e["default"] : e; } + + var ns__default = /*#__PURE__*/_interopDefaultCompat(ns); + + console.log(ns__default); + +})); diff --git a/test/form/samples/generated-code/reserved-names-as-props-false-no-external-live-bindings/_expected/cjs.js b/test/form/samples/generated-code/reserved-names-as-props-false-no-external-live-bindings/_expected/cjs.js new file mode 100644 index 00000000000..b77bbc6913c --- /dev/null +++ b/test/form/samples/generated-code/reserved-names-as-props-false-no-external-live-bindings/_expected/cjs.js @@ -0,0 +1,9 @@ +'use strict'; + +var ns = require('external'); + +function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e["default"] : e; } + +var ns__default = /*#__PURE__*/_interopDefaultCompat(ns); + +console.log(ns__default); diff --git a/test/form/samples/generated-code/reserved-names-as-props-false-no-external-live-bindings/_expected/es.js b/test/form/samples/generated-code/reserved-names-as-props-false-no-external-live-bindings/_expected/es.js new file mode 100644 index 00000000000..f066c6c4387 --- /dev/null +++ b/test/form/samples/generated-code/reserved-names-as-props-false-no-external-live-bindings/_expected/es.js @@ -0,0 +1,3 @@ +import ns from 'external'; + +console.log(ns); diff --git a/test/form/samples/generated-code/reserved-names-as-props-false-no-external-live-bindings/_expected/iife.js b/test/form/samples/generated-code/reserved-names-as-props-false-no-external-live-bindings/_expected/iife.js new file mode 100644 index 00000000000..4cce83d68b6 --- /dev/null +++ b/test/form/samples/generated-code/reserved-names-as-props-false-no-external-live-bindings/_expected/iife.js @@ -0,0 +1,10 @@ +(function (ns) { + 'use strict'; + + function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e["default"] : e; } + + var ns__default = /*#__PURE__*/_interopDefaultCompat(ns); + + console.log(ns__default); + +})(external); diff --git a/test/form/samples/generated-code/reserved-names-as-props-false-no-external-live-bindings/_expected/system.js b/test/form/samples/generated-code/reserved-names-as-props-false-no-external-live-bindings/_expected/system.js new file mode 100644 index 00000000000..9492986904f --- /dev/null +++ b/test/form/samples/generated-code/reserved-names-as-props-false-no-external-live-bindings/_expected/system.js @@ -0,0 +1,14 @@ +System.register('bundle', ['external'], (function () { + 'use strict'; + var ns; + return { + setters: [function (module) { + ns = module["default"]; + }], + execute: (function () { + + console.log(ns); + + }) + }; +})); diff --git a/test/form/samples/generated-code/reserved-names-as-props-false-no-external-live-bindings/_expected/umd.js b/test/form/samples/generated-code/reserved-names-as-props-false-no-external-live-bindings/_expected/umd.js new file mode 100644 index 00000000000..a7a02f3bb91 --- /dev/null +++ b/test/form/samples/generated-code/reserved-names-as-props-false-no-external-live-bindings/_expected/umd.js @@ -0,0 +1,13 @@ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('external')) : + typeof define === 'function' && define.amd ? define(['external'], factory) : + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.external)); +})(this, (function (ns) { 'use strict'; + + function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e["default"] : e; } + + var ns__default = /*#__PURE__*/_interopDefaultCompat(ns); + + console.log(ns__default); + +})); diff --git a/test/form/samples/generated-code/reserved-names-as-props-false-no-external-live-bindings/main.js b/test/form/samples/generated-code/reserved-names-as-props-false-no-external-live-bindings/main.js new file mode 100644 index 00000000000..f96ed8bc598 --- /dev/null +++ b/test/form/samples/generated-code/reserved-names-as-props-false-no-external-live-bindings/main.js @@ -0,0 +1,2 @@ +import ns from 'external'; +console.log(ns); diff --git a/test/form/samples/generated-code/reserved-names-as-props-false/_config.js b/test/form/samples/generated-code/reserved-names-as-props-false/_config.js new file mode 100644 index 00000000000..654ac22856c --- /dev/null +++ b/test/form/samples/generated-code/reserved-names-as-props-false/_config.js @@ -0,0 +1,24 @@ +module.exports = defineTest({ + description: 'escapes reserved names used as props', + options: { + external: ['external', 'external2', 'externalDefaultOnly'], + output: { + exports: 'named', + generatedCode: { reservedNamesAsProps: false }, + globals: id => id, + interop(id) { + if (id === 'externalDefaultOnly') return 'defaultOnly'; + return 'auto'; + }, + name: 'bundle' + }, + plugins: [ + { + name: 'test', + transform() { + return { syntheticNamedExports: true }; + } + } + ] + } +}); diff --git a/test/form/samples/generated-code/reserved-names-as-props-false/_expected/amd.js b/test/form/samples/generated-code/reserved-names-as-props-false/_expected/amd.js new file mode 100644 index 00000000000..21efd4c5707 --- /dev/null +++ b/test/form/samples/generated-code/reserved-names-as-props-false/_expected/amd.js @@ -0,0 +1,71 @@ +define(['module', 'exports', 'external', 'externalDefaultOnly', 'external2'], (function (module, exports, external, defaultOnly, someDefault) { 'use strict'; + + function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; } + + function _interopNamespaceDefaultOnly (e) { return Object.freeze({ __proto__: null, default: e }); } + + function _interopNamespace(e) { + if (e && e.__esModule) return e; + var n = Object.create(null); + if (e) { + Object.keys(e).forEach(function (k) { + if (k !== 'default') { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + } + n["default"] = e; + return Object.freeze(n); + } + + function _mergeNamespaces(n, m) { + m.forEach(function (e) { + e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) { + if (k !== 'default' && !(k in n)) { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + }); + return Object.freeze(n); + } + + var external__namespace = /*#__PURE__*/_interopNamespace(external); + var defaultOnly__namespace = /*#__PURE__*/_interopNamespaceDefaultOnly(defaultOnly); + var someDefault__default = /*#__PURE__*/_interopDefault(someDefault); + + var other = { + foo: 'bar' + }; + + var ns = /*#__PURE__*/_mergeNamespaces({ + __proto__: null, + default: other + }, [other]); + + console.log(ns, other.foo, other["function"], other["some-prop"], external["function"], someDefault__default["default"], defaultOnly__namespace); + console.log(undefined, undefined); + + exports["function"] = 1; + exports["function"]++; + + Object.defineProperty(exports, "bar", { + enumerable: true, + get: function () { return external["function"]; } + }); + exports["default"] = external__namespace; + Object.defineProperty(exports, "void", { + enumerable: true, + get: function () { return external__namespace["default"]; } + }); + + Object.defineProperty(exports, '__esModule', { value: true }); + +})); diff --git a/test/form/samples/generated-code/reserved-names-as-props-false/_expected/cjs.js b/test/form/samples/generated-code/reserved-names-as-props-false/_expected/cjs.js new file mode 100644 index 00000000000..06df22373f7 --- /dev/null +++ b/test/form/samples/generated-code/reserved-names-as-props-false/_expected/cjs.js @@ -0,0 +1,73 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { value: true }); + +var external = require('external'); +var defaultOnly = require('externalDefaultOnly'); +var someDefault = require('external2'); + +function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; } + +function _interopNamespaceDefaultOnly (e) { return Object.freeze({ __proto__: null, default: e }); } + +function _interopNamespace(e) { + if (e && e.__esModule) return e; + var n = Object.create(null); + if (e) { + Object.keys(e).forEach(function (k) { + if (k !== 'default') { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + } + n["default"] = e; + return Object.freeze(n); +} + +function _mergeNamespaces(n, m) { + m.forEach(function (e) { + e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) { + if (k !== 'default' && !(k in n)) { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + }); + return Object.freeze(n); +} + +var external__namespace = /*#__PURE__*/_interopNamespace(external); +var defaultOnly__namespace = /*#__PURE__*/_interopNamespaceDefaultOnly(defaultOnly); +var someDefault__default = /*#__PURE__*/_interopDefault(someDefault); + +var other = { + foo: 'bar' +}; + +var ns = /*#__PURE__*/_mergeNamespaces({ + __proto__: null, + default: other +}, [other]); + +console.log(ns, other.foo, other["function"], other["some-prop"], external["function"], someDefault__default["default"], defaultOnly__namespace); +console.log(undefined, undefined); + +exports["function"] = 1; +exports["function"]++; + +Object.defineProperty(exports, "bar", { + enumerable: true, + get: function () { return external["function"]; } +}); +exports["default"] = external__namespace; +Object.defineProperty(exports, "void", { + enumerable: true, + get: function () { return external__namespace["default"]; } +}); diff --git a/test/form/samples/generated-code/reserved-names-as-props-false/_expected/es.js b/test/form/samples/generated-code/reserved-names-as-props-false/_expected/es.js new file mode 100644 index 00000000000..50ee2c0d674 --- /dev/null +++ b/test/form/samples/generated-code/reserved-names-as-props-false/_expected/es.js @@ -0,0 +1,38 @@ +import { function as _function } from 'external'; +import * as external from 'external'; +export { external as default }; +export { function as bar, default as void } from 'external'; +import * as defaultOnly from 'externalDefaultOnly'; +import someDefault from 'external2'; + +function _mergeNamespaces(n, m) { + m.forEach(function (e) { + e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) { + if (k !== 'default' && !(k in n)) { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + }); + return Object.freeze(n); +} + +var other = { + foo: 'bar' +}; + +var ns = /*#__PURE__*/_mergeNamespaces({ + __proto__: null, + default: other +}, [other]); + +console.log(ns, other.foo, other["function"], other["some-prop"], _function, someDefault, defaultOnly); +console.log(import.meta['function'], import.meta['some-prop']); + +let f = 1; +f++; + +export { f as function }; diff --git a/test/form/samples/generated-code/reserved-names-as-props-false/_expected/iife.js b/test/form/samples/generated-code/reserved-names-as-props-false/_expected/iife.js new file mode 100644 index 00000000000..eff1486ba20 --- /dev/null +++ b/test/form/samples/generated-code/reserved-names-as-props-false/_expected/iife.js @@ -0,0 +1,74 @@ +var bundle = (function (exports, external, defaultOnly, someDefault) { + 'use strict'; + + function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; } + + function _interopNamespaceDefaultOnly (e) { return Object.freeze({ __proto__: null, default: e }); } + + function _interopNamespace(e) { + if (e && e.__esModule) return e; + var n = Object.create(null); + if (e) { + Object.keys(e).forEach(function (k) { + if (k !== 'default') { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + } + n["default"] = e; + return Object.freeze(n); + } + + function _mergeNamespaces(n, m) { + m.forEach(function (e) { + e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) { + if (k !== 'default' && !(k in n)) { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + }); + return Object.freeze(n); + } + + var external__namespace = /*#__PURE__*/_interopNamespace(external); + var defaultOnly__namespace = /*#__PURE__*/_interopNamespaceDefaultOnly(defaultOnly); + var someDefault__default = /*#__PURE__*/_interopDefault(someDefault); + + var other = { + foo: 'bar' + }; + + var ns = /*#__PURE__*/_mergeNamespaces({ + __proto__: null, + default: other + }, [other]); + + console.log(ns, other.foo, other["function"], other["some-prop"], external["function"], someDefault__default["default"], defaultOnly__namespace); + console.log(undefined, undefined); + + exports["function"] = 1; + exports["function"]++; + + Object.defineProperty(exports, "bar", { + enumerable: true, + get: function () { return external["function"]; } + }); + exports["default"] = external__namespace; + Object.defineProperty(exports, "void", { + enumerable: true, + get: function () { return external__namespace["default"]; } + }); + + Object.defineProperty(exports, '__esModule', { value: true }); + + return exports; + +})({}, external, externalDefaultOnly, external2); diff --git a/test/form/samples/generated-code/reserved-names-as-props-false/_expected/system.js b/test/form/samples/generated-code/reserved-names-as-props-false/_expected/system.js new file mode 100644 index 00000000000..35ae53805d1 --- /dev/null +++ b/test/form/samples/generated-code/reserved-names-as-props-false/_expected/system.js @@ -0,0 +1,47 @@ +System.register('bundle', ['external', 'externalDefaultOnly', 'external2'], (function (exports, module) { + 'use strict'; + var _function, defaultOnly, someDefault; + return { + setters: [function (module) { + _function = module["function"]; + exports({ bar: module["function"], default: module, void: module["default"] }); + }, function (module) { + defaultOnly = module; + }, function (module) { + someDefault = module["default"]; + }], + execute: (function () { + + function _mergeNamespaces(n, m) { + m.forEach(function (e) { + e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) { + if (k !== 'default' && !(k in n)) { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + }); + return Object.freeze(n); + } + + var other = { + foo: 'bar' + }; + + var ns = /*#__PURE__*/_mergeNamespaces({ + __proto__: null, + default: other + }, [other]); + + console.log(ns, other.foo, other["function"], other["some-prop"], _function, someDefault, defaultOnly); + console.log(module.meta["function"], module.meta["some-prop"]); + + let f = exports("function", 1); + exports("function", f + 1), f++; + + }) + }; +})); diff --git a/test/form/samples/generated-code/reserved-names-as-props-false/_expected/umd.js b/test/form/samples/generated-code/reserved-names-as-props-false/_expected/umd.js new file mode 100644 index 00000000000..d258ce7e009 --- /dev/null +++ b/test/form/samples/generated-code/reserved-names-as-props-false/_expected/umd.js @@ -0,0 +1,75 @@ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('external'), require('externalDefaultOnly'), require('external2')) : + typeof define === 'function' && define.amd ? define(['exports', 'external', 'externalDefaultOnly', 'external2'], factory) : + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.bundle = {}, global.external, global.externalDefaultOnly, global.external2)); +})(this, (function (exports, external, defaultOnly, someDefault) { 'use strict'; + + function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; } + + function _interopNamespaceDefaultOnly (e) { return Object.freeze({ __proto__: null, default: e }); } + + function _interopNamespace(e) { + if (e && e.__esModule) return e; + var n = Object.create(null); + if (e) { + Object.keys(e).forEach(function (k) { + if (k !== 'default') { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + } + n["default"] = e; + return Object.freeze(n); + } + + function _mergeNamespaces(n, m) { + m.forEach(function (e) { + e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) { + if (k !== 'default' && !(k in n)) { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + }); + return Object.freeze(n); + } + + var external__namespace = /*#__PURE__*/_interopNamespace(external); + var defaultOnly__namespace = /*#__PURE__*/_interopNamespaceDefaultOnly(defaultOnly); + var someDefault__default = /*#__PURE__*/_interopDefault(someDefault); + + var other = { + foo: 'bar' + }; + + var ns = /*#__PURE__*/_mergeNamespaces({ + __proto__: null, + default: other + }, [other]); + + console.log(ns, other.foo, other["function"], other["some-prop"], external["function"], someDefault__default["default"], defaultOnly__namespace); + console.log(undefined, undefined); + + exports["function"] = 1; + exports["function"]++; + + Object.defineProperty(exports, "bar", { + enumerable: true, + get: function () { return external["function"]; } + }); + exports["default"] = external__namespace; + Object.defineProperty(exports, "void", { + enumerable: true, + get: function () { return external__namespace["default"]; } + }); + + Object.defineProperty(exports, '__esModule', { value: true }); + +})); diff --git a/test/form/samples/generated-code/reserved-names-as-props-false/main.js b/test/form/samples/generated-code/reserved-names-as-props-false/main.js new file mode 100644 index 00000000000..dab4942256d --- /dev/null +++ b/test/form/samples/generated-code/reserved-names-as-props-false/main.js @@ -0,0 +1,14 @@ +import * as ns from './other.js'; +import { function as g } from 'external'; +import * as defaultOnly from 'externalDefaultOnly' +import someDefault from 'external2' + +console.log(ns, ns.foo, ns['function'], ns['some-prop'], g, someDefault, defaultOnly); +console.log(import.meta['function'], import.meta['some-prop']); + +let f = 1; +f++; + +export { f as function }; +export * as default from 'external'; +export { default as void, function as bar } from 'external'; diff --git a/test/form/samples/generated-code/reserved-names-as-props-false/other.js b/test/form/samples/generated-code/reserved-names-as-props-false/other.js new file mode 100644 index 00000000000..ca6b727784f --- /dev/null +++ b/test/form/samples/generated-code/reserved-names-as-props-false/other.js @@ -0,0 +1,3 @@ +export default { + foo: 'bar' +}; diff --git a/test/form/samples/generated-code/reserved-names-as-props-true-no-external-live-bindings/_config.js b/test/form/samples/generated-code/reserved-names-as-props-true-no-external-live-bindings/_config.js new file mode 100644 index 00000000000..fa9347430ad --- /dev/null +++ b/test/form/samples/generated-code/reserved-names-as-props-true-no-external-live-bindings/_config.js @@ -0,0 +1,14 @@ +module.exports = defineTest({ + description: 'escapes reserved names used as props when external live-bindings are off', + options: { + external: ['external'], + output: { + exports: 'named', + externalLiveBindings: false, + generatedCode: { reservedNamesAsProps: true }, + globals: id => id, + interop: 'compat', + name: 'bundle' + } + } +}); diff --git a/test/form/samples/generated-code/reserved-names-as-props-true-no-external-live-bindings/_expected/amd.js b/test/form/samples/generated-code/reserved-names-as-props-true-no-external-live-bindings/_expected/amd.js new file mode 100644 index 00000000000..36efb5f32f7 --- /dev/null +++ b/test/form/samples/generated-code/reserved-names-as-props-true-no-external-live-bindings/_expected/amd.js @@ -0,0 +1,9 @@ +define(['external'], (function (ns) { 'use strict'; + + function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; } + + var ns__default = /*#__PURE__*/_interopDefaultCompat(ns); + + console.log(ns__default); + +})); diff --git a/test/form/samples/generated-code/reserved-names-as-props-true-no-external-live-bindings/_expected/cjs.js b/test/form/samples/generated-code/reserved-names-as-props-true-no-external-live-bindings/_expected/cjs.js new file mode 100644 index 00000000000..8b89b78436a --- /dev/null +++ b/test/form/samples/generated-code/reserved-names-as-props-true-no-external-live-bindings/_expected/cjs.js @@ -0,0 +1,9 @@ +'use strict'; + +var ns = require('external'); + +function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; } + +var ns__default = /*#__PURE__*/_interopDefaultCompat(ns); + +console.log(ns__default); diff --git a/test/form/samples/generated-code/reserved-names-as-props-true-no-external-live-bindings/_expected/es.js b/test/form/samples/generated-code/reserved-names-as-props-true-no-external-live-bindings/_expected/es.js new file mode 100644 index 00000000000..f066c6c4387 --- /dev/null +++ b/test/form/samples/generated-code/reserved-names-as-props-true-no-external-live-bindings/_expected/es.js @@ -0,0 +1,3 @@ +import ns from 'external'; + +console.log(ns); diff --git a/test/form/samples/generated-code/reserved-names-as-props-true-no-external-live-bindings/_expected/iife.js b/test/form/samples/generated-code/reserved-names-as-props-true-no-external-live-bindings/_expected/iife.js new file mode 100644 index 00000000000..1b6d3220aa4 --- /dev/null +++ b/test/form/samples/generated-code/reserved-names-as-props-true-no-external-live-bindings/_expected/iife.js @@ -0,0 +1,10 @@ +(function (ns) { + 'use strict'; + + function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; } + + var ns__default = /*#__PURE__*/_interopDefaultCompat(ns); + + console.log(ns__default); + +})(external); diff --git a/test/form/samples/generated-code/reserved-names-as-props-true-no-external-live-bindings/_expected/system.js b/test/form/samples/generated-code/reserved-names-as-props-true-no-external-live-bindings/_expected/system.js new file mode 100644 index 00000000000..cdd74b852bf --- /dev/null +++ b/test/form/samples/generated-code/reserved-names-as-props-true-no-external-live-bindings/_expected/system.js @@ -0,0 +1,14 @@ +System.register('bundle', ['external'], (function () { + 'use strict'; + var ns; + return { + setters: [function (module) { + ns = module.default; + }], + execute: (function () { + + console.log(ns); + + }) + }; +})); diff --git a/test/form/samples/generated-code/reserved-names-as-props-true-no-external-live-bindings/_expected/umd.js b/test/form/samples/generated-code/reserved-names-as-props-true-no-external-live-bindings/_expected/umd.js new file mode 100644 index 00000000000..400e63c6a85 --- /dev/null +++ b/test/form/samples/generated-code/reserved-names-as-props-true-no-external-live-bindings/_expected/umd.js @@ -0,0 +1,13 @@ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('external')) : + typeof define === 'function' && define.amd ? define(['external'], factory) : + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.external)); +})(this, (function (ns) { 'use strict'; + + function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; } + + var ns__default = /*#__PURE__*/_interopDefaultCompat(ns); + + console.log(ns__default); + +})); diff --git a/test/form/samples/generated-code/reserved-names-as-props-true-no-external-live-bindings/main.js b/test/form/samples/generated-code/reserved-names-as-props-true-no-external-live-bindings/main.js new file mode 120000 index 00000000000..b667be2b6cd --- /dev/null +++ b/test/form/samples/generated-code/reserved-names-as-props-true-no-external-live-bindings/main.js @@ -0,0 +1 @@ +../../generated-code/reserved-names-as-props-false-no-external-live-bindings/main.js \ No newline at end of file diff --git a/test/form/samples/generated-code/reserved-names-as-props-true/_config.js b/test/form/samples/generated-code/reserved-names-as-props-true/_config.js new file mode 100644 index 00000000000..554242f8213 --- /dev/null +++ b/test/form/samples/generated-code/reserved-names-as-props-true/_config.js @@ -0,0 +1,24 @@ +module.exports = defineTest({ + description: 'escapes reserved names used as props', + options: { + external: ['external', 'external2', 'externalDefaultOnly'], + output: { + exports: 'named', + generatedCode: { reservedNamesAsProps: true }, + globals: id => id, + interop(id) { + if (id === 'externalDefaultOnly') return 'defaultOnly'; + return 'auto'; + }, + name: 'bundle' + }, + plugins: [ + { + name: 'test', + transform() { + return { syntheticNamedExports: true }; + } + } + ] + } +}); diff --git a/test/form/samples/generated-code/reserved-names-as-props-true/_expected/amd.js b/test/form/samples/generated-code/reserved-names-as-props-true/_expected/amd.js new file mode 100644 index 00000000000..2c50a700ddc --- /dev/null +++ b/test/form/samples/generated-code/reserved-names-as-props-true/_expected/amd.js @@ -0,0 +1,71 @@ +define(['module', 'exports', 'external', 'externalDefaultOnly', 'external2'], (function (module, exports, external, defaultOnly, someDefault) { 'use strict'; + + function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; } + + function _interopNamespaceDefaultOnly (e) { return Object.freeze({ __proto__: null, default: e }); } + + function _interopNamespace(e) { + if (e && e.__esModule) return e; + var n = Object.create(null); + if (e) { + Object.keys(e).forEach(function (k) { + if (k !== 'default') { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + } + n.default = e; + return Object.freeze(n); + } + + function _mergeNamespaces(n, m) { + m.forEach(function (e) { + e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) { + if (k !== 'default' && !(k in n)) { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + }); + return Object.freeze(n); + } + + var external__namespace = /*#__PURE__*/_interopNamespace(external); + var defaultOnly__namespace = /*#__PURE__*/_interopNamespaceDefaultOnly(defaultOnly); + var someDefault__default = /*#__PURE__*/_interopDefault(someDefault); + + var other = { + foo: 'bar' + }; + + var ns = /*#__PURE__*/_mergeNamespaces({ + __proto__: null, + default: other + }, [other]); + + console.log(ns, other.foo, other.function, other["some-prop"], external.function, someDefault__default.default, defaultOnly__namespace); + console.log(undefined, undefined); + + exports.function = 1; + exports.function++; + + Object.defineProperty(exports, "bar", { + enumerable: true, + get: function () { return external.function; } + }); + exports.default = external__namespace; + Object.defineProperty(exports, "void", { + enumerable: true, + get: function () { return external__namespace.default; } + }); + + Object.defineProperty(exports, '__esModule', { value: true }); + +})); diff --git a/test/form/samples/generated-code/reserved-names-as-props-true/_expected/cjs.js b/test/form/samples/generated-code/reserved-names-as-props-true/_expected/cjs.js new file mode 100644 index 00000000000..5ec615f7439 --- /dev/null +++ b/test/form/samples/generated-code/reserved-names-as-props-true/_expected/cjs.js @@ -0,0 +1,73 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { value: true }); + +var external = require('external'); +var defaultOnly = require('externalDefaultOnly'); +var someDefault = require('external2'); + +function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; } + +function _interopNamespaceDefaultOnly (e) { return Object.freeze({ __proto__: null, default: e }); } + +function _interopNamespace(e) { + if (e && e.__esModule) return e; + var n = Object.create(null); + if (e) { + Object.keys(e).forEach(function (k) { + if (k !== 'default') { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + } + n.default = e; + return Object.freeze(n); +} + +function _mergeNamespaces(n, m) { + m.forEach(function (e) { + e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) { + if (k !== 'default' && !(k in n)) { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + }); + return Object.freeze(n); +} + +var external__namespace = /*#__PURE__*/_interopNamespace(external); +var defaultOnly__namespace = /*#__PURE__*/_interopNamespaceDefaultOnly(defaultOnly); +var someDefault__default = /*#__PURE__*/_interopDefault(someDefault); + +var other = { + foo: 'bar' +}; + +var ns = /*#__PURE__*/_mergeNamespaces({ + __proto__: null, + default: other +}, [other]); + +console.log(ns, other.foo, other.function, other["some-prop"], external.function, someDefault__default.default, defaultOnly__namespace); +console.log(undefined, undefined); + +exports.function = 1; +exports.function++; + +Object.defineProperty(exports, "bar", { + enumerable: true, + get: function () { return external.function; } +}); +exports.default = external__namespace; +Object.defineProperty(exports, "void", { + enumerable: true, + get: function () { return external__namespace.default; } +}); diff --git a/test/form/samples/generated-code/reserved-names-as-props-true/_expected/es.js b/test/form/samples/generated-code/reserved-names-as-props-true/_expected/es.js new file mode 100644 index 00000000000..cc835576ff9 --- /dev/null +++ b/test/form/samples/generated-code/reserved-names-as-props-true/_expected/es.js @@ -0,0 +1,38 @@ +import { function as _function } from 'external'; +import * as external from 'external'; +export { external as default }; +export { function as bar, default as void } from 'external'; +import * as defaultOnly from 'externalDefaultOnly'; +import someDefault from 'external2'; + +function _mergeNamespaces(n, m) { + m.forEach(function (e) { + e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) { + if (k !== 'default' && !(k in n)) { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + }); + return Object.freeze(n); +} + +var other = { + foo: 'bar' +}; + +var ns = /*#__PURE__*/_mergeNamespaces({ + __proto__: null, + default: other +}, [other]); + +console.log(ns, other.foo, other.function, other["some-prop"], _function, someDefault, defaultOnly); +console.log(import.meta['function'], import.meta['some-prop']); + +let f = 1; +f++; + +export { f as function }; diff --git a/test/form/samples/generated-code/reserved-names-as-props-true/_expected/iife.js b/test/form/samples/generated-code/reserved-names-as-props-true/_expected/iife.js new file mode 100644 index 00000000000..3195b23d0a1 --- /dev/null +++ b/test/form/samples/generated-code/reserved-names-as-props-true/_expected/iife.js @@ -0,0 +1,74 @@ +var bundle = (function (exports, external, defaultOnly, someDefault) { + 'use strict'; + + function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; } + + function _interopNamespaceDefaultOnly (e) { return Object.freeze({ __proto__: null, default: e }); } + + function _interopNamespace(e) { + if (e && e.__esModule) return e; + var n = Object.create(null); + if (e) { + Object.keys(e).forEach(function (k) { + if (k !== 'default') { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + } + n.default = e; + return Object.freeze(n); + } + + function _mergeNamespaces(n, m) { + m.forEach(function (e) { + e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) { + if (k !== 'default' && !(k in n)) { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + }); + return Object.freeze(n); + } + + var external__namespace = /*#__PURE__*/_interopNamespace(external); + var defaultOnly__namespace = /*#__PURE__*/_interopNamespaceDefaultOnly(defaultOnly); + var someDefault__default = /*#__PURE__*/_interopDefault(someDefault); + + var other = { + foo: 'bar' + }; + + var ns = /*#__PURE__*/_mergeNamespaces({ + __proto__: null, + default: other + }, [other]); + + console.log(ns, other.foo, other.function, other["some-prop"], external.function, someDefault__default.default, defaultOnly__namespace); + console.log(undefined, undefined); + + exports.function = 1; + exports.function++; + + Object.defineProperty(exports, "bar", { + enumerable: true, + get: function () { return external.function; } + }); + exports.default = external__namespace; + Object.defineProperty(exports, "void", { + enumerable: true, + get: function () { return external__namespace.default; } + }); + + Object.defineProperty(exports, '__esModule', { value: true }); + + return exports; + +})({}, external, externalDefaultOnly, external2); diff --git a/test/form/samples/generated-code/reserved-names-as-props-true/_expected/system.js b/test/form/samples/generated-code/reserved-names-as-props-true/_expected/system.js new file mode 100644 index 00000000000..3535693f44b --- /dev/null +++ b/test/form/samples/generated-code/reserved-names-as-props-true/_expected/system.js @@ -0,0 +1,47 @@ +System.register('bundle', ['external', 'externalDefaultOnly', 'external2'], (function (exports, module) { + 'use strict'; + var _function, defaultOnly, someDefault; + return { + setters: [function (module) { + _function = module.function; + exports({ bar: module.function, default: module, void: module.default }); + }, function (module) { + defaultOnly = module; + }, function (module) { + someDefault = module.default; + }], + execute: (function () { + + function _mergeNamespaces(n, m) { + m.forEach(function (e) { + e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) { + if (k !== 'default' && !(k in n)) { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + }); + return Object.freeze(n); + } + + var other = { + foo: 'bar' + }; + + var ns = /*#__PURE__*/_mergeNamespaces({ + __proto__: null, + default: other + }, [other]); + + console.log(ns, other.foo, other.function, other["some-prop"], _function, someDefault, defaultOnly); + console.log(module.meta.function, module.meta["some-prop"]); + + let f = exports("function", 1); + exports("function", f + 1), f++; + + }) + }; +})); diff --git a/test/form/samples/generated-code/reserved-names-as-props-true/_expected/umd.js b/test/form/samples/generated-code/reserved-names-as-props-true/_expected/umd.js new file mode 100644 index 00000000000..4442ac6dab4 --- /dev/null +++ b/test/form/samples/generated-code/reserved-names-as-props-true/_expected/umd.js @@ -0,0 +1,75 @@ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('external'), require('externalDefaultOnly'), require('external2')) : + typeof define === 'function' && define.amd ? define(['exports', 'external', 'externalDefaultOnly', 'external2'], factory) : + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.bundle = {}, global.external, global.externalDefaultOnly, global.external2)); +})(this, (function (exports, external, defaultOnly, someDefault) { 'use strict'; + + function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; } + + function _interopNamespaceDefaultOnly (e) { return Object.freeze({ __proto__: null, default: e }); } + + function _interopNamespace(e) { + if (e && e.__esModule) return e; + var n = Object.create(null); + if (e) { + Object.keys(e).forEach(function (k) { + if (k !== 'default') { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + } + n.default = e; + return Object.freeze(n); + } + + function _mergeNamespaces(n, m) { + m.forEach(function (e) { + e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) { + if (k !== 'default' && !(k in n)) { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + }); + return Object.freeze(n); + } + + var external__namespace = /*#__PURE__*/_interopNamespace(external); + var defaultOnly__namespace = /*#__PURE__*/_interopNamespaceDefaultOnly(defaultOnly); + var someDefault__default = /*#__PURE__*/_interopDefault(someDefault); + + var other = { + foo: 'bar' + }; + + var ns = /*#__PURE__*/_mergeNamespaces({ + __proto__: null, + default: other + }, [other]); + + console.log(ns, other.foo, other.function, other["some-prop"], external.function, someDefault__default.default, defaultOnly__namespace); + console.log(undefined, undefined); + + exports.function = 1; + exports.function++; + + Object.defineProperty(exports, "bar", { + enumerable: true, + get: function () { return external.function; } + }); + exports.default = external__namespace; + Object.defineProperty(exports, "void", { + enumerable: true, + get: function () { return external__namespace.default; } + }); + + Object.defineProperty(exports, '__esModule', { value: true }); + +})); diff --git a/test/form/samples/generated-code/reserved-names-as-props-true/main.js b/test/form/samples/generated-code/reserved-names-as-props-true/main.js new file mode 120000 index 00000000000..c711a9c52a1 --- /dev/null +++ b/test/form/samples/generated-code/reserved-names-as-props-true/main.js @@ -0,0 +1 @@ +../../generated-code/reserved-names-as-props-false/main.js \ No newline at end of file diff --git a/test/form/samples/getter-return-values/_config.js b/test/form/samples/getter-return-values/_config.js index 0c6bc6a1647..49e4e90c27e 100644 --- a/test/form/samples/getter-return-values/_config.js +++ b/test/form/samples/getter-return-values/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'forwards return values of getters' -}; +}); diff --git a/test/form/samples/globals-function/_config.js b/test/form/samples/globals-function/_config.js index 8c1bcef98a3..a4725202ba2 100644 --- a/test/form/samples/globals-function/_config.js +++ b/test/form/samples/globals-function/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'Externals aliases with deshadowing', options: { external: ['a', 'b'], @@ -7,4 +7,4 @@ module.exports = { name: 'myBundle' } } -}; +}); diff --git a/test/form/samples/globals-function/_expected/amd.js b/test/form/samples/globals-function/_expected/amd.js index bb2c1554f0d..719a1d9c314 100644 --- a/test/form/samples/globals-function/_expected/amd.js +++ b/test/form/samples/globals-function/_expected/amd.js @@ -1,10 +1,5 @@ -define(['a', 'b'], function (a, b) { 'use strict'; +define(['a', 'b'], (function (a, b) { 'use strict'; - function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } + console.log(a, b); - var a__default = /*#__PURE__*/_interopDefaultLegacy(a); - var b__default = /*#__PURE__*/_interopDefaultLegacy(b); - - console.log(a__default['default'], b__default['default']); - -}); +})); diff --git a/test/form/samples/globals-function/_expected/cjs.js b/test/form/samples/globals-function/_expected/cjs.js index 033fece9ba3..be7de890703 100644 --- a/test/form/samples/globals-function/_expected/cjs.js +++ b/test/form/samples/globals-function/_expected/cjs.js @@ -3,9 +3,4 @@ var a = require('a'); var b = require('b'); -function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } - -var a__default = /*#__PURE__*/_interopDefaultLegacy(a); -var b__default = /*#__PURE__*/_interopDefaultLegacy(b); - -console.log(a__default['default'], b__default['default']); +console.log(a, b); diff --git a/test/form/samples/globals-function/_expected/iife.js b/test/form/samples/globals-function/_expected/iife.js index 1170fbe0012..7d7aea264c0 100644 --- a/test/form/samples/globals-function/_expected/iife.js +++ b/test/form/samples/globals-function/_expected/iife.js @@ -1,11 +1,6 @@ (function (a, b) { 'use strict'; - function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } + console.log(a, b); - var a__default = /*#__PURE__*/_interopDefaultLegacy(a); - var b__default = /*#__PURE__*/_interopDefaultLegacy(b); - - console.log(a__default['default'], b__default['default']); - -}(thisIsA, thisIsB)); +})(thisIsA, thisIsB); diff --git a/test/form/samples/globals-function/_expected/system.js b/test/form/samples/globals-function/_expected/system.js index 932ae55e4ff..e66e4a1a49b 100644 --- a/test/form/samples/globals-function/_expected/system.js +++ b/test/form/samples/globals-function/_expected/system.js @@ -1,4 +1,4 @@ -System.register('myBundle', ['a', 'b'], function () { +System.register('myBundle', ['a', 'b'], (function () { 'use strict'; var a, b; return { @@ -7,10 +7,10 @@ System.register('myBundle', ['a', 'b'], function () { }, function (module) { b = module.default; }], - execute: function () { + execute: (function () { console.log(a, b); - } + }) }; -}); +})); diff --git a/test/form/samples/globals-function/_expected/umd.js b/test/form/samples/globals-function/_expected/umd.js index 060773e9c86..7e62c1ce521 100644 --- a/test/form/samples/globals-function/_expected/umd.js +++ b/test/form/samples/globals-function/_expected/umd.js @@ -2,13 +2,8 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('a'), require('b')) : typeof define === 'function' && define.amd ? define(['a', 'b'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.thisIsA, global.thisIsB)); -}(this, (function (a, b) { 'use strict'; +})(this, (function (a, b) { 'use strict'; - function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } + console.log(a, b); - var a__default = /*#__PURE__*/_interopDefaultLegacy(a); - var b__default = /*#__PURE__*/_interopDefaultLegacy(b); - - console.log(a__default['default'], b__default['default']); - -}))); +})); diff --git a/test/form/samples/globals-removes-access-to-pure-function-members/_config.js b/test/form/samples/globals-removes-access-to-pure-function-members/_config.js index af2c4421073..b3d3d53f49e 100644 --- a/test/form/samples/globals-removes-access-to-pure-function-members/_config.js +++ b/test/form/samples/globals-removes-access-to-pure-function-members/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'accessing members of pure functions and their prototypes is not a side-effect' -}; +}); diff --git a/test/form/samples/globals-removes-access-to-pure-function-members/_expected/amd.js b/test/form/samples/globals-removes-access-to-pure-function-members/_expected/amd.js index b8c20625cd5..168f63efb75 100644 --- a/test/form/samples/globals-removes-access-to-pure-function-members/_expected/amd.js +++ b/test/form/samples/globals-removes-access-to-pure-function-members/_expected/amd.js @@ -1,6 +1,6 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; Unknown.staticMember; Unknown.prototype.method; -}); +})); diff --git a/test/form/samples/globals-removes-access-to-pure-function-members/_expected/iife.js b/test/form/samples/globals-removes-access-to-pure-function-members/_expected/iife.js index 5bc83f4bb61..82fcd79ab36 100644 --- a/test/form/samples/globals-removes-access-to-pure-function-members/_expected/iife.js +++ b/test/form/samples/globals-removes-access-to-pure-function-members/_expected/iife.js @@ -4,4 +4,4 @@ Unknown.staticMember; Unknown.prototype.method; -}()); +})(); diff --git a/test/form/samples/globals-removes-access-to-pure-function-members/_expected/system.js b/test/form/samples/globals-removes-access-to-pure-function-members/_expected/system.js index 92cece42c40..5789730827b 100644 --- a/test/form/samples/globals-removes-access-to-pure-function-members/_expected/system.js +++ b/test/form/samples/globals-removes-access-to-pure-function-members/_expected/system.js @@ -1,11 +1,11 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { Unknown.staticMember; Unknown.prototype.method; - } + }) }; -}); +})); diff --git a/test/form/samples/globals-removes-access-to-pure-function-members/_expected/umd.js b/test/form/samples/globals-removes-access-to-pure-function-members/_expected/umd.js index 63a99c48e6e..4d3c7bdc4a2 100644 --- a/test/form/samples/globals-removes-access-to-pure-function-members/_expected/umd.js +++ b/test/form/samples/globals-removes-access-to-pure-function-members/_expected/umd.js @@ -1,9 +1,9 @@ (function (factory) { typeof define === 'function' && define.amd ? define(factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; Unknown.staticMember; Unknown.prototype.method; -}))); +})); diff --git a/test/form/samples/guessed-global-names/_config.js b/test/form/samples/guessed-global-names/_config.js index eb564fe7be1..4f063098ddc 100644 --- a/test/form/samples/guessed-global-names/_config.js +++ b/test/form/samples/guessed-global-names/_config.js @@ -1,6 +1,6 @@ -const { resolve } = require('path'); +const path = require('node:path'); -module.exports = { +module.exports = defineTest({ description: 'guesses global names if necessary', expectedWarnings: ['MISSING_GLOBAL_NAME'], options: { @@ -9,7 +9,7 @@ module.exports = { 'changed', 'special-character', 'with/slash', - resolve(__dirname, 'relative.js') + path.resolve(__dirname, 'relative.js') ] } -}; +}); diff --git a/test/form/samples/guessed-global-names/_expected/amd.js b/test/form/samples/guessed-global-names/_expected/amd.js index d4ff1e6249b..2d81a6a092e 100644 --- a/test/form/samples/guessed-global-names/_expected/amd.js +++ b/test/form/samples/guessed-global-names/_expected/amd.js @@ -1,9 +1,5 @@ -define(['unchanged', 'changed', 'special-character', 'with/slash', './relative'], function (unchanged, changedName, specialCharacter, slash, relative_js) { 'use strict'; +define(['unchanged', 'changed', 'special-character', 'with/slash', './relative'], (function (unchanged, changedName, specialCharacter, slash, relative_js) { 'use strict'; - function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } + console.log(unchanged.foo, changedName, specialCharacter.bar, slash.baz, relative_js.quux); - var changedName__default = /*#__PURE__*/_interopDefaultLegacy(changedName); - - console.log(unchanged.foo, changedName__default['default'], specialCharacter.bar, slash.baz, relative_js.quux); - -}); +})); diff --git a/test/form/samples/guessed-global-names/_expected/cjs.js b/test/form/samples/guessed-global-names/_expected/cjs.js index b36a1f7de02..4a0861f19af 100644 --- a/test/form/samples/guessed-global-names/_expected/cjs.js +++ b/test/form/samples/guessed-global-names/_expected/cjs.js @@ -6,8 +6,4 @@ var specialCharacter = require('special-character'); var slash = require('with/slash'); var relative_js = require('./relative.js'); -function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } - -var changedName__default = /*#__PURE__*/_interopDefaultLegacy(changedName); - -console.log(unchanged.foo, changedName__default['default'], specialCharacter.bar, slash.baz, relative_js.quux); +console.log(unchanged.foo, changedName, specialCharacter.bar, slash.baz, relative_js.quux); diff --git a/test/form/samples/guessed-global-names/_expected/iife.js b/test/form/samples/guessed-global-names/_expected/iife.js index 5dfa8b9e691..80d65b02ac9 100644 --- a/test/form/samples/guessed-global-names/_expected/iife.js +++ b/test/form/samples/guessed-global-names/_expected/iife.js @@ -1,10 +1,6 @@ (function (unchanged, changedName, specialCharacter, slash, relative_js) { 'use strict'; - function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } + console.log(unchanged.foo, changedName, specialCharacter.bar, slash.baz, relative_js.quux); - var changedName__default = /*#__PURE__*/_interopDefaultLegacy(changedName); - - console.log(unchanged.foo, changedName__default['default'], specialCharacter.bar, slash.baz, relative_js.quux); - -}(unchanged, changedName, specialCharacter, slash, relative_js)); +})(unchanged, changedName, specialCharacter, slash, relative_js); diff --git a/test/form/samples/guessed-global-names/_expected/system.js b/test/form/samples/guessed-global-names/_expected/system.js index ee1dadc5362..76166806a38 100644 --- a/test/form/samples/guessed-global-names/_expected/system.js +++ b/test/form/samples/guessed-global-names/_expected/system.js @@ -1,4 +1,4 @@ -System.register(['unchanged', 'changed', 'special-character', 'with/slash', './relative.js'], function () { +System.register(['unchanged', 'changed', 'special-character', 'with/slash', './relative.js'], (function () { 'use strict'; var foo, changedName, bar, baz, quux; return { @@ -13,10 +13,10 @@ System.register(['unchanged', 'changed', 'special-character', 'with/slash', './r }, function (module) { quux = module.quux; }], - execute: function () { + execute: (function () { console.log(foo, changedName, bar, baz, quux); - } + }) }; -}); +})); diff --git a/test/form/samples/guessed-global-names/_expected/umd.js b/test/form/samples/guessed-global-names/_expected/umd.js index 76474a609c0..a4cc825e023 100644 --- a/test/form/samples/guessed-global-names/_expected/umd.js +++ b/test/form/samples/guessed-global-names/_expected/umd.js @@ -2,12 +2,8 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('unchanged'), require('changed'), require('special-character'), require('with/slash'), require('./relative.js')) : typeof define === 'function' && define.amd ? define(['unchanged', 'changed', 'special-character', 'with/slash', './relative'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.unchanged, global.changedName, global.specialCharacter, global.slash, global.relative_js)); -}(this, (function (unchanged, changedName, specialCharacter, slash, relative_js) { 'use strict'; +})(this, (function (unchanged, changedName, specialCharacter, slash, relative_js) { 'use strict'; - function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } + console.log(unchanged.foo, changedName, specialCharacter.bar, slash.baz, relative_js.quux); - var changedName__default = /*#__PURE__*/_interopDefaultLegacy(changedName); - - console.log(unchanged.foo, changedName__default['default'], specialCharacter.bar, slash.baz, relative_js.quux); - -}))); +})); diff --git a/test/form/samples/handles-async-await/_config.js b/test/form/samples/handles-async-await/_config.js index 9c17f942ab8..cf026ce4bd2 100644 --- a/test/form/samples/handles-async-await/_config.js +++ b/test/form/samples/handles-async-await/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'properly handles exporting async functions' -}; +}); diff --git a/test/form/samples/handles-empty-imports-iife/_config.js b/test/form/samples/handles-empty-imports-iife/_config.js index d20eb8d00a8..0cc79137cf7 100644 --- a/test/form/samples/handles-empty-imports-iife/_config.js +++ b/test/form/samples/handles-empty-imports-iife/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'handles empty imports when generating IIFE output', expectedWarnings: ['MISSING_NODE_BUILTINS', 'UNRESOLVED_IMPORT'], options: { @@ -11,4 +11,4 @@ module.exports = { } } } -}; +}); diff --git a/test/form/samples/handles-empty-imports-iife/_expected.js b/test/form/samples/handles-empty-imports-iife/_expected.js index b5f303961fc..81d783ad038 100644 --- a/test/form/samples/handles-empty-imports-iife/_expected.js +++ b/test/form/samples/handles-empty-imports-iife/_expected.js @@ -4,4 +4,4 @@ dns.resolve('name'); fs.writeFileSync('foo', 'bar'); -}(dns, util, fs)); +})(dns, util, fs); diff --git a/test/form/samples/handles-empty-imports-umd/_config.js b/test/form/samples/handles-empty-imports-umd/_config.js index 7caa9a477ac..1226ef2187e 100644 --- a/test/form/samples/handles-empty-imports-umd/_config.js +++ b/test/form/samples/handles-empty-imports-umd/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'handles empty imports when generating IIFE output', expectedWarnings: ['MISSING_NODE_BUILTINS', 'UNRESOLVED_IMPORT'], options: { @@ -11,4 +11,4 @@ module.exports = { } } } -}; +}); diff --git a/test/form/samples/handles-empty-imports-umd/_expected.js b/test/form/samples/handles-empty-imports-umd/_expected.js index 621913b5669..15c27d16c44 100644 --- a/test/form/samples/handles-empty-imports-umd/_expected.js +++ b/test/form/samples/handles-empty-imports-umd/_expected.js @@ -2,9 +2,9 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('dns'), require('util'), require('fs')) : typeof define === 'function' && define.amd ? define(['dns', 'util', 'fs'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.dns, global.util, global.fs)); -}(this, (function (dns, util, fs) { 'use strict'; +})(this, (function (dns, util, fs) { 'use strict'; dns.resolve('name'); fs.writeFileSync('foo', 'bar'); -}))); +})); diff --git a/test/form/samples/handles-special-comments/_config.js b/test/form/samples/handles-special-comments/_config.js new file mode 100644 index 00000000000..f1866b5bfb4 --- /dev/null +++ b/test/form/samples/handles-special-comments/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'does not fail on certain comments (#5174)' +}); diff --git a/test/form/samples/handles-special-comments/_expected.js b/test/form/samples/handles-special-comments/_expected.js new file mode 100644 index 00000000000..e9a293a6319 --- /dev/null +++ b/test/form/samples/handles-special-comments/_expected.js @@ -0,0 +1,2 @@ +// “__ +console.log('main'); diff --git a/test/form/samples/handles-special-comments/main.js b/test/form/samples/handles-special-comments/main.js new file mode 100644 index 00000000000..e9a293a6319 --- /dev/null +++ b/test/form/samples/handles-special-comments/main.js @@ -0,0 +1,2 @@ +// “__ +console.log('main'); diff --git a/test/form/samples/hoisted-unused-conditional/_config.js b/test/form/samples/hoisted-unused-conditional/_config.js index ebb7fcbcec3..8607e410006 100644 --- a/test/form/samples/hoisted-unused-conditional/_config.js +++ b/test/form/samples/hoisted-unused-conditional/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'Properly renders conditionals in hoisted variables in dead branches' -}; +}); diff --git a/test/form/samples/hoisted-variable-case-stmt/_config.js b/test/form/samples/hoisted-variable-case-stmt/_config.js index f4ec792209e..156c5550180 100644 --- a/test/form/samples/hoisted-variable-case-stmt/_config.js +++ b/test/form/samples/hoisted-variable-case-stmt/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'Properly handles a variable hoisted from within a fallthrough switch case' -}; +}); diff --git a/test/form/samples/hoisted-variable-if-stmt/_config.js b/test/form/samples/hoisted-variable-if-stmt/_config.js index c6e376a856b..c18b43edd40 100644 --- a/test/form/samples/hoisted-variable-if-stmt/_config.js +++ b/test/form/samples/hoisted-variable-if-stmt/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'Properly renders branches which refer to hoisted variables from other lexical scopes' -}; +}); diff --git a/test/form/samples/hoisted-vars-in-dead-branches/_config.js b/test/form/samples/hoisted-vars-in-dead-branches/_config.js index b27559e4d8e..39dc21c20f7 100644 --- a/test/form/samples/hoisted-vars-in-dead-branches/_config.js +++ b/test/form/samples/hoisted-vars-in-dead-branches/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'renders hoisted variables in dead branches' -}; +}); diff --git a/test/form/samples/ignore-property-access-side-effects/_config.js b/test/form/samples/ignore-property-access-side-effects/_config.js index 2db50db018f..005169f9446 100644 --- a/test/form/samples/ignore-property-access-side-effects/_config.js +++ b/test/form/samples/ignore-property-access-side-effects/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'ignore side-effects when accessing properties if treeshake.propertyReadSideEffects is false', expectedWarnings: ['EMPTY_BUNDLE'], @@ -7,4 +7,4 @@ module.exports = { propertyReadSideEffects: false } } -}; +}); diff --git a/test/form/samples/ignore-property-access-side-effects/main.js b/test/form/samples/ignore-property-access-side-effects/main.js index a501b27ef3f..c0c2b1d6432 100644 --- a/test/form/samples/ignore-property-access-side-effects/main.js +++ b/test/form/samples/ignore-property-access-side-effects/main.js @@ -1,6 +1,6 @@ const getter = { - get foo () { - console.log( 'effect' ); + get foo() { + console.log('effect'); } }; const foo1 = getter.foo; @@ -13,4 +13,28 @@ function accessArg(arg) { } accessArg(null); -const foo4 = globalThis.globalThis.unknown.unknownProperty; +const foo4 = globalThis.unknown.unknownProperty; + +const foo5 = { + ...{ + get prop() { + console.log('effect'); + } + } +}; + +const foo6 = (async function () { + return { + get then() { + console.log('effect'); + return () => {}; + } + }; +})(); + +const foo7 = (async () => ({ + get then() { + console.log('effect'); + return () => {}; + } +}))(); diff --git a/test/form/samples/ignore-unknown-global-side-effects/_config.js b/test/form/samples/ignore-unknown-global-side-effects/_config.js index 08ae295d520..748249b9a28 100644 --- a/test/form/samples/ignore-unknown-global-side-effects/_config.js +++ b/test/form/samples/ignore-unknown-global-side-effects/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'ignore side-effects when accessing unknown globals if treeshake.unknownGlobalSideEffects is false', expectedWarnings: ['EMPTY_BUNDLE'], @@ -7,4 +7,4 @@ module.exports = { unknownGlobalSideEffects: false } } -}; +}); diff --git a/test/form/samples/implicit-undefined-assignments/_config.js b/test/form/samples/implicit-undefined-assignments/_config.js index 5422058eb2d..6d5dc6e2e4c 100644 --- a/test/form/samples/implicit-undefined-assignments/_config.js +++ b/test/form/samples/implicit-undefined-assignments/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'Make sure implicit undefined assignments in declarations are not ignored' -}; +}); diff --git a/test/form/samples/implicit-undefined-assignments/_expected/amd.js b/test/form/samples/implicit-undefined-assignments/_expected/amd.js index db9113757df..583a8be3b96 100644 --- a/test/form/samples/implicit-undefined-assignments/_expected/amd.js +++ b/test/form/samples/implicit-undefined-assignments/_expected/amd.js @@ -1,4 +1,4 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; let a; a(); @@ -12,4 +12,4 @@ define(function () { 'use strict'; let { d } = {}; d.foo = 'bar'; -}); +})); diff --git a/test/form/samples/implicit-undefined-assignments/_expected/iife.js b/test/form/samples/implicit-undefined-assignments/_expected/iife.js index be372d793fa..9d70dd52c38 100644 --- a/test/form/samples/implicit-undefined-assignments/_expected/iife.js +++ b/test/form/samples/implicit-undefined-assignments/_expected/iife.js @@ -13,4 +13,4 @@ let { d } = {}; d.foo = 'bar'; -}()); +})(); diff --git a/test/form/samples/implicit-undefined-assignments/_expected/system.js b/test/form/samples/implicit-undefined-assignments/_expected/system.js index 7a66925a24b..0edbf78c713 100644 --- a/test/form/samples/implicit-undefined-assignments/_expected/system.js +++ b/test/form/samples/implicit-undefined-assignments/_expected/system.js @@ -1,7 +1,7 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { let a; a(); @@ -15,6 +15,6 @@ System.register([], function () { let { d } = {}; d.foo = 'bar'; - } + }) }; -}); +})); diff --git a/test/form/samples/implicit-undefined-assignments/_expected/umd.js b/test/form/samples/implicit-undefined-assignments/_expected/umd.js index e2ebd8dd29a..b2657711892 100644 --- a/test/form/samples/implicit-undefined-assignments/_expected/umd.js +++ b/test/form/samples/implicit-undefined-assignments/_expected/umd.js @@ -1,7 +1,7 @@ (function (factory) { typeof define === 'function' && define.amd ? define(factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; let a; a(); @@ -15,4 +15,4 @@ let { d } = {}; d.foo = 'bar'; -}))); +})); diff --git a/test/form/samples/import-attributes/attribute-shapes/_config.js b/test/form/samples/import-attributes/attribute-shapes/_config.js new file mode 100644 index 00000000000..e0cd94ceaf4 --- /dev/null +++ b/test/form/samples/import-attributes/attribute-shapes/_config.js @@ -0,0 +1,7 @@ +module.exports = defineTest({ + description: 'handles special shapes of attributes', + options: { + external: () => true + }, + expectedWarnings: ['INVALID_IMPORT_ATTRIBUTE'] +}); diff --git a/test/form/samples/import-attributes/attribute-shapes/_expected.js b/test/form/samples/import-attributes/attribute-shapes/_expected.js new file mode 100644 index 00000000000..3e8611361b1 --- /dev/null +++ b/test/form/samples/import-attributes/attribute-shapes/_expected.js @@ -0,0 +1,4 @@ +import('external-a', { assert: { type: 'json' } }); +import('external-b', { with: {} }); +import('external-c', { ...{} }); +import('external-d', {}); diff --git a/test/form/samples/import-attributes/attribute-shapes/main.js b/test/form/samples/import-attributes/attribute-shapes/main.js new file mode 100644 index 00000000000..63f5bb69b6f --- /dev/null +++ b/test/form/samples/import-attributes/attribute-shapes/main.js @@ -0,0 +1,4 @@ +import('external-a', { 'with': { 'type': 'json', foo: 1, ...{} } }); +import('external-b', { with: {} }); +import('external-c', { ...{} }); +import('external-d', {}); diff --git a/test/form/samples/import-attributes/keep-attribute-declarations-for-external-dynamic-imports/_config.js b/test/form/samples/import-attributes/keep-attribute-declarations-for-external-dynamic-imports/_config.js new file mode 100644 index 00000000000..de7010b0538 --- /dev/null +++ b/test/form/samples/import-attributes/keep-attribute-declarations-for-external-dynamic-imports/_config.js @@ -0,0 +1,19 @@ +module.exports = defineTest({ + description: 'Keep the attribute declarations for external dynamic imports', + expectedWarnings: ['INVALID_IMPORT_ATTRIBUTE'], + options: { + plugins: [ + { + resolveDynamicImport(specifier) { + if (specifier === 'specifier3' || specifier === 'specifier4') { + return { id: specifier, external: true }; + } + if (specifier.name === 'specifier5' || specifier.name === 'specifier6') { + return `'${specifier.name}-replacement'`; + } + } + } + ] + }, + verifyAst: false +}); diff --git a/test/form/samples/import-attributes/keep-attribute-declarations-for-external-dynamic-imports/_expected.js b/test/form/samples/import-attributes/keep-attribute-declarations-for-external-dynamic-imports/_expected.js new file mode 100644 index 00000000000..97618386fd4 --- /dev/null +++ b/test/form/samples/import-attributes/keep-attribute-declarations-for-external-dynamic-imports/_expected.js @@ -0,0 +1,17 @@ +const extra1 = { with: { type: 'json' } }; +import(specifier1, extra1); + +const extra2 = { with: { type: 'json' } }; +import(specifier2, { with: extra2.with }); + +const extra3 = { with: { type: 'json' } }; +import('specifier3', extra3); + +const extra4 = { with: { type: 'json' } }; +import('specifier4', { with: extra4.with }); + +const extra5 = { with: { type: 'json' } }; +import('specifier5-replacement', extra5); + +const extra6 = { with: { type: 'json' } }; +import('specifier6-replacement', { with: extra6.with }); diff --git a/test/form/samples/import-attributes/keep-attribute-declarations-for-external-dynamic-imports/main.js b/test/form/samples/import-attributes/keep-attribute-declarations-for-external-dynamic-imports/main.js new file mode 100644 index 00000000000..e369b75088d --- /dev/null +++ b/test/form/samples/import-attributes/keep-attribute-declarations-for-external-dynamic-imports/main.js @@ -0,0 +1,17 @@ +const extra1 = { with: { type: 'json' } }; +import(specifier1, extra1); + +const extra2 = { with: { type: 'json' } }; +import(specifier2, { with: extra2.with }); + +const extra3 = { with: { type: 'json' } }; +import('specifier3', extra3); + +const extra4 = { with: { type: 'json' } }; +import('specifier4', { with: extra4.with }); + +const extra5 = { with: { type: 'json' } }; +import(specifier5, extra5); + +const extra6 = { with: { type: 'json' } }; +import(specifier6, { with: extra6.with }); diff --git a/test/form/samples/import-attributes/keep-dynamic-attributes-assert/_config.js b/test/form/samples/import-attributes/keep-dynamic-attributes-assert/_config.js new file mode 100644 index 00000000000..ba397d8be51 --- /dev/null +++ b/test/form/samples/import-attributes/keep-dynamic-attributes-assert/_config.js @@ -0,0 +1,31 @@ +module.exports = defineTest({ + description: 'keep import attributes for dynamic imports with "assert" key', + expectedWarnings: ['UNRESOLVED_IMPORT'], + options: { + output: { + importAttributesKey: 'assert' + }, + external: id => { + if (id === 'unresolved') return null; + return true; + }, + plugins: [ + { + name: 'test', + resolveDynamicImport(specifier) { + if (typeof specifier === 'object') { + if (specifier.type === 'TemplateLiteral') { + return "'resolvedString'"; + } + if (specifier.type === 'BinaryExpression') { + return { id: 'resolved-id', external: true }; + } + } else if (specifier === 'external-resolved') { + return { id: 'resolved-different', external: true }; + } + return null; + } + } + ] + } +}); diff --git a/test/form/samples/import-attributes/keep-dynamic-attributes-assert/_expected/amd.js b/test/form/samples/import-attributes/keep-dynamic-attributes-assert/_expected/amd.js new file mode 100644 index 00000000000..e9478c8fc48 --- /dev/null +++ b/test/form/samples/import-attributes/keep-dynamic-attributes-assert/_expected/amd.js @@ -0,0 +1,27 @@ +define(['require'], (function (require) { 'use strict'; + + function _interopNamespaceDefault(e) { + var n = Object.create(null); + if (e) { + Object.keys(e).forEach(function (k) { + if (k !== 'default') { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + } + n.default = e; + return Object.freeze(n); + } + + new Promise(function (resolve, reject) { require(['external'], function (m) { resolve(/*#__PURE__*/_interopNamespaceDefault(m)); }, reject); }); + (function (t) { return new Promise(function (resolve, reject) { require([t], function (m) { resolve(/*#__PURE__*/_interopNamespaceDefault(m)); }, reject); }); })(globalThis.unknown); + (function (t) { return new Promise(function (resolve, reject) { require([t], function (m) { resolve(/*#__PURE__*/_interopNamespaceDefault(m)); }, reject); }); })('resolvedString'); + new Promise(function (resolve, reject) { require(['resolved-id'], function (m) { resolve(/*#__PURE__*/_interopNamespaceDefault(m)); }, reject); }); + new Promise(function (resolve, reject) { require(['resolved-different'], function (m) { resolve(/*#__PURE__*/_interopNamespaceDefault(m)); }, reject); }); + new Promise(function (resolve, reject) { require(['unresolved'], function (m) { resolve(/*#__PURE__*/_interopNamespaceDefault(m)); }, reject); }); + +})); diff --git a/test/form/samples/import-attributes/keep-dynamic-attributes-assert/_expected/cjs.js b/test/form/samples/import-attributes/keep-dynamic-attributes-assert/_expected/cjs.js new file mode 100644 index 00000000000..b282bbbc674 --- /dev/null +++ b/test/form/samples/import-attributes/keep-dynamic-attributes-assert/_expected/cjs.js @@ -0,0 +1,8 @@ +'use strict'; + +import('external', { assert: { type: 'special' } }); +import(globalThis.unknown, { assert: { type: 'special' } }); +import('resolvedString', { assert: { type: 'special' } }); +import('resolved-id', { assert: { type: 'special' } }); +import('resolved-different', { assert: { type: 'special' } }); +import('unresolved', { assert: { type: 'special' } }); diff --git a/test/form/samples/import-attributes/keep-dynamic-attributes-assert/_expected/es.js b/test/form/samples/import-attributes/keep-dynamic-attributes-assert/_expected/es.js new file mode 100644 index 00000000000..87164b7871f --- /dev/null +++ b/test/form/samples/import-attributes/keep-dynamic-attributes-assert/_expected/es.js @@ -0,0 +1,6 @@ +import('external', { assert: { type: 'special' } }); +import(globalThis.unknown, { assert: { type: 'special' } }); +import('resolvedString', { assert: { type: 'special' } }); +import('resolved-id', { assert: { type: 'special' } }); +import('resolved-different', { assert: { type: 'special' } }); +import('unresolved', { assert: { type: 'special' } }); diff --git a/test/form/samples/import-attributes/keep-dynamic-attributes-assert/_expected/iife.js b/test/form/samples/import-attributes/keep-dynamic-attributes-assert/_expected/iife.js new file mode 100644 index 00000000000..0da8002824f --- /dev/null +++ b/test/form/samples/import-attributes/keep-dynamic-attributes-assert/_expected/iife.js @@ -0,0 +1,11 @@ +(function () { + 'use strict'; + + import('external'); + import(globalThis.unknown); + import('resolvedString'); + import('resolved-id'); + import('resolved-different'); + import('unresolved'); + +})(); diff --git a/test/form/samples/import-attributes/keep-dynamic-attributes-assert/_expected/system.js b/test/form/samples/import-attributes/keep-dynamic-attributes-assert/_expected/system.js new file mode 100644 index 00000000000..44c758c2912 --- /dev/null +++ b/test/form/samples/import-attributes/keep-dynamic-attributes-assert/_expected/system.js @@ -0,0 +1,15 @@ +System.register([], (function (exports, module) { + 'use strict'; + return { + execute: (function () { + + module.import('external'); + module.import(globalThis.unknown); + module.import('resolvedString'); + module.import('resolved-id'); + module.import('resolved-different'); + module.import('unresolved'); + + }) + }; +})); diff --git a/test/form/samples/import-attributes/keep-dynamic-attributes-assert/_expected/umd.js b/test/form/samples/import-attributes/keep-dynamic-attributes-assert/_expected/umd.js new file mode 100644 index 00000000000..cd9d7642deb --- /dev/null +++ b/test/form/samples/import-attributes/keep-dynamic-attributes-assert/_expected/umd.js @@ -0,0 +1,13 @@ +(function (factory) { + typeof define === 'function' && define.amd ? define(factory) : + factory(); +})((function () { 'use strict'; + + import('external'); + import(globalThis.unknown); + import('resolvedString'); + import('resolved-id'); + import('resolved-different'); + import('unresolved'); + +})); diff --git a/test/form/samples/import-attributes/keep-dynamic-attributes-assert/main.js b/test/form/samples/import-attributes/keep-dynamic-attributes-assert/main.js new file mode 100644 index 00000000000..95a0320bd73 --- /dev/null +++ b/test/form/samples/import-attributes/keep-dynamic-attributes-assert/main.js @@ -0,0 +1,6 @@ +import('external', { assert: { type: 'special' } }); +import(globalThis.unknown, { assert: { type: 'special' } }); +import(`external-${globalThis.unknown}`, { with: { type: 'special' } }); +import('external' + globalThis.unknown, { assert: { type: 'special' } }); +import('external-resolved', { with: { type: 'special' } }); +import('unresolved', { assert: { type: 'special' } }); diff --git a/test/form/samples/import-attributes/keep-dynamic-attributes-default/_config.js b/test/form/samples/import-attributes/keep-dynamic-attributes-default/_config.js new file mode 100644 index 00000000000..a75f1818911 --- /dev/null +++ b/test/form/samples/import-attributes/keep-dynamic-attributes-default/_config.js @@ -0,0 +1,28 @@ +module.exports = defineTest({ + description: 'keep import attributes for dynamic imports', + expectedWarnings: ['UNRESOLVED_IMPORT'], + options: { + external: id => { + if (id === 'unresolved') return null; + return true; + }, + plugins: [ + { + name: 'test', + resolveDynamicImport(specifier) { + if (typeof specifier === 'object') { + if (specifier.type === 'TemplateLiteral') { + return "'resolvedString'"; + } + if (specifier.type === 'BinaryExpression') { + return { id: 'resolved-id', external: true }; + } + } else if (specifier === 'external-resolved') { + return { id: 'resolved-different', external: true }; + } + return null; + } + } + ] + } +}); diff --git a/test/form/samples/import-attributes/keep-dynamic-attributes-default/_expected/amd.js b/test/form/samples/import-attributes/keep-dynamic-attributes-default/_expected/amd.js new file mode 100644 index 00000000000..e9478c8fc48 --- /dev/null +++ b/test/form/samples/import-attributes/keep-dynamic-attributes-default/_expected/amd.js @@ -0,0 +1,27 @@ +define(['require'], (function (require) { 'use strict'; + + function _interopNamespaceDefault(e) { + var n = Object.create(null); + if (e) { + Object.keys(e).forEach(function (k) { + if (k !== 'default') { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + } + n.default = e; + return Object.freeze(n); + } + + new Promise(function (resolve, reject) { require(['external'], function (m) { resolve(/*#__PURE__*/_interopNamespaceDefault(m)); }, reject); }); + (function (t) { return new Promise(function (resolve, reject) { require([t], function (m) { resolve(/*#__PURE__*/_interopNamespaceDefault(m)); }, reject); }); })(globalThis.unknown); + (function (t) { return new Promise(function (resolve, reject) { require([t], function (m) { resolve(/*#__PURE__*/_interopNamespaceDefault(m)); }, reject); }); })('resolvedString'); + new Promise(function (resolve, reject) { require(['resolved-id'], function (m) { resolve(/*#__PURE__*/_interopNamespaceDefault(m)); }, reject); }); + new Promise(function (resolve, reject) { require(['resolved-different'], function (m) { resolve(/*#__PURE__*/_interopNamespaceDefault(m)); }, reject); }); + new Promise(function (resolve, reject) { require(['unresolved'], function (m) { resolve(/*#__PURE__*/_interopNamespaceDefault(m)); }, reject); }); + +})); diff --git a/test/form/samples/import-attributes/keep-dynamic-attributes-default/_expected/cjs.js b/test/form/samples/import-attributes/keep-dynamic-attributes-default/_expected/cjs.js new file mode 100644 index 00000000000..b282bbbc674 --- /dev/null +++ b/test/form/samples/import-attributes/keep-dynamic-attributes-default/_expected/cjs.js @@ -0,0 +1,8 @@ +'use strict'; + +import('external', { assert: { type: 'special' } }); +import(globalThis.unknown, { assert: { type: 'special' } }); +import('resolvedString', { assert: { type: 'special' } }); +import('resolved-id', { assert: { type: 'special' } }); +import('resolved-different', { assert: { type: 'special' } }); +import('unresolved', { assert: { type: 'special' } }); diff --git a/test/form/samples/import-attributes/keep-dynamic-attributes-default/_expected/es.js b/test/form/samples/import-attributes/keep-dynamic-attributes-default/_expected/es.js new file mode 100644 index 00000000000..87164b7871f --- /dev/null +++ b/test/form/samples/import-attributes/keep-dynamic-attributes-default/_expected/es.js @@ -0,0 +1,6 @@ +import('external', { assert: { type: 'special' } }); +import(globalThis.unknown, { assert: { type: 'special' } }); +import('resolvedString', { assert: { type: 'special' } }); +import('resolved-id', { assert: { type: 'special' } }); +import('resolved-different', { assert: { type: 'special' } }); +import('unresolved', { assert: { type: 'special' } }); diff --git a/test/form/samples/import-attributes/keep-dynamic-attributes-default/_expected/iife.js b/test/form/samples/import-attributes/keep-dynamic-attributes-default/_expected/iife.js new file mode 100644 index 00000000000..0da8002824f --- /dev/null +++ b/test/form/samples/import-attributes/keep-dynamic-attributes-default/_expected/iife.js @@ -0,0 +1,11 @@ +(function () { + 'use strict'; + + import('external'); + import(globalThis.unknown); + import('resolvedString'); + import('resolved-id'); + import('resolved-different'); + import('unresolved'); + +})(); diff --git a/test/form/samples/import-attributes/keep-dynamic-attributes-default/_expected/system.js b/test/form/samples/import-attributes/keep-dynamic-attributes-default/_expected/system.js new file mode 100644 index 00000000000..44c758c2912 --- /dev/null +++ b/test/form/samples/import-attributes/keep-dynamic-attributes-default/_expected/system.js @@ -0,0 +1,15 @@ +System.register([], (function (exports, module) { + 'use strict'; + return { + execute: (function () { + + module.import('external'); + module.import(globalThis.unknown); + module.import('resolvedString'); + module.import('resolved-id'); + module.import('resolved-different'); + module.import('unresolved'); + + }) + }; +})); diff --git a/test/form/samples/import-attributes/keep-dynamic-attributes-default/_expected/umd.js b/test/form/samples/import-attributes/keep-dynamic-attributes-default/_expected/umd.js new file mode 100644 index 00000000000..cd9d7642deb --- /dev/null +++ b/test/form/samples/import-attributes/keep-dynamic-attributes-default/_expected/umd.js @@ -0,0 +1,13 @@ +(function (factory) { + typeof define === 'function' && define.amd ? define(factory) : + factory(); +})((function () { 'use strict'; + + import('external'); + import(globalThis.unknown); + import('resolvedString'); + import('resolved-id'); + import('resolved-different'); + import('unresolved'); + +})); diff --git a/test/form/samples/import-attributes/keep-dynamic-attributes-default/main.js b/test/form/samples/import-attributes/keep-dynamic-attributes-default/main.js new file mode 100644 index 00000000000..95a0320bd73 --- /dev/null +++ b/test/form/samples/import-attributes/keep-dynamic-attributes-default/main.js @@ -0,0 +1,6 @@ +import('external', { assert: { type: 'special' } }); +import(globalThis.unknown, { assert: { type: 'special' } }); +import(`external-${globalThis.unknown}`, { with: { type: 'special' } }); +import('external' + globalThis.unknown, { assert: { type: 'special' } }); +import('external-resolved', { with: { type: 'special' } }); +import('unresolved', { assert: { type: 'special' } }); diff --git a/test/form/samples/import-attributes/keep-dynamic-attributes-with/_config.js b/test/form/samples/import-attributes/keep-dynamic-attributes-with/_config.js new file mode 100644 index 00000000000..d17b4f3df4f --- /dev/null +++ b/test/form/samples/import-attributes/keep-dynamic-attributes-with/_config.js @@ -0,0 +1,31 @@ +module.exports = defineTest({ + description: 'keep import attributes for dynamic imports with "with" key', + expectedWarnings: ['UNRESOLVED_IMPORT'], + options: { + output: { + importAttributesKey: 'with' + }, + external: id => { + if (id === 'unresolved') return null; + return true; + }, + plugins: [ + { + name: 'test', + resolveDynamicImport(specifier) { + if (typeof specifier === 'object') { + if (specifier.type === 'TemplateLiteral') { + return "'resolvedString'"; + } + if (specifier.type === 'BinaryExpression') { + return { id: 'resolved-id', external: true }; + } + } else if (specifier === 'external-resolved') { + return { id: 'resolved-different', external: true }; + } + return null; + } + } + ] + } +}); diff --git a/test/form/samples/import-attributes/keep-dynamic-attributes-with/_expected/amd.js b/test/form/samples/import-attributes/keep-dynamic-attributes-with/_expected/amd.js new file mode 100644 index 00000000000..e9478c8fc48 --- /dev/null +++ b/test/form/samples/import-attributes/keep-dynamic-attributes-with/_expected/amd.js @@ -0,0 +1,27 @@ +define(['require'], (function (require) { 'use strict'; + + function _interopNamespaceDefault(e) { + var n = Object.create(null); + if (e) { + Object.keys(e).forEach(function (k) { + if (k !== 'default') { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + } + n.default = e; + return Object.freeze(n); + } + + new Promise(function (resolve, reject) { require(['external'], function (m) { resolve(/*#__PURE__*/_interopNamespaceDefault(m)); }, reject); }); + (function (t) { return new Promise(function (resolve, reject) { require([t], function (m) { resolve(/*#__PURE__*/_interopNamespaceDefault(m)); }, reject); }); })(globalThis.unknown); + (function (t) { return new Promise(function (resolve, reject) { require([t], function (m) { resolve(/*#__PURE__*/_interopNamespaceDefault(m)); }, reject); }); })('resolvedString'); + new Promise(function (resolve, reject) { require(['resolved-id'], function (m) { resolve(/*#__PURE__*/_interopNamespaceDefault(m)); }, reject); }); + new Promise(function (resolve, reject) { require(['resolved-different'], function (m) { resolve(/*#__PURE__*/_interopNamespaceDefault(m)); }, reject); }); + new Promise(function (resolve, reject) { require(['unresolved'], function (m) { resolve(/*#__PURE__*/_interopNamespaceDefault(m)); }, reject); }); + +})); diff --git a/test/form/samples/import-attributes/keep-dynamic-attributes-with/_expected/cjs.js b/test/form/samples/import-attributes/keep-dynamic-attributes-with/_expected/cjs.js new file mode 100644 index 00000000000..fdd4e6ff146 --- /dev/null +++ b/test/form/samples/import-attributes/keep-dynamic-attributes-with/_expected/cjs.js @@ -0,0 +1,8 @@ +'use strict'; + +import('external', { with: { type: 'special' } }); +import(globalThis.unknown, { with: { type: 'special' } }); +import('resolvedString', { with: { type: 'special' } }); +import('resolved-id', { with: { type: 'special' } }); +import('resolved-different', { with: { type: 'special' } }); +import('unresolved', { with: { type: 'special' } }); diff --git a/test/form/samples/import-attributes/keep-dynamic-attributes-with/_expected/es.js b/test/form/samples/import-attributes/keep-dynamic-attributes-with/_expected/es.js new file mode 100644 index 00000000000..eb0be1c177d --- /dev/null +++ b/test/form/samples/import-attributes/keep-dynamic-attributes-with/_expected/es.js @@ -0,0 +1,6 @@ +import('external', { with: { type: 'special' } }); +import(globalThis.unknown, { with: { type: 'special' } }); +import('resolvedString', { with: { type: 'special' } }); +import('resolved-id', { with: { type: 'special' } }); +import('resolved-different', { with: { type: 'special' } }); +import('unresolved', { with: { type: 'special' } }); diff --git a/test/form/samples/import-attributes/keep-dynamic-attributes-with/_expected/iife.js b/test/form/samples/import-attributes/keep-dynamic-attributes-with/_expected/iife.js new file mode 100644 index 00000000000..0da8002824f --- /dev/null +++ b/test/form/samples/import-attributes/keep-dynamic-attributes-with/_expected/iife.js @@ -0,0 +1,11 @@ +(function () { + 'use strict'; + + import('external'); + import(globalThis.unknown); + import('resolvedString'); + import('resolved-id'); + import('resolved-different'); + import('unresolved'); + +})(); diff --git a/test/form/samples/import-attributes/keep-dynamic-attributes-with/_expected/system.js b/test/form/samples/import-attributes/keep-dynamic-attributes-with/_expected/system.js new file mode 100644 index 00000000000..44c758c2912 --- /dev/null +++ b/test/form/samples/import-attributes/keep-dynamic-attributes-with/_expected/system.js @@ -0,0 +1,15 @@ +System.register([], (function (exports, module) { + 'use strict'; + return { + execute: (function () { + + module.import('external'); + module.import(globalThis.unknown); + module.import('resolvedString'); + module.import('resolved-id'); + module.import('resolved-different'); + module.import('unresolved'); + + }) + }; +})); diff --git a/test/form/samples/import-attributes/keep-dynamic-attributes-with/_expected/umd.js b/test/form/samples/import-attributes/keep-dynamic-attributes-with/_expected/umd.js new file mode 100644 index 00000000000..cd9d7642deb --- /dev/null +++ b/test/form/samples/import-attributes/keep-dynamic-attributes-with/_expected/umd.js @@ -0,0 +1,13 @@ +(function (factory) { + typeof define === 'function' && define.amd ? define(factory) : + factory(); +})((function () { 'use strict'; + + import('external'); + import(globalThis.unknown); + import('resolvedString'); + import('resolved-id'); + import('resolved-different'); + import('unresolved'); + +})); diff --git a/test/form/samples/import-attributes/keep-dynamic-attributes-with/main.js b/test/form/samples/import-attributes/keep-dynamic-attributes-with/main.js new file mode 100644 index 00000000000..95a0320bd73 --- /dev/null +++ b/test/form/samples/import-attributes/keep-dynamic-attributes-with/main.js @@ -0,0 +1,6 @@ +import('external', { assert: { type: 'special' } }); +import(globalThis.unknown, { assert: { type: 'special' } }); +import(`external-${globalThis.unknown}`, { with: { type: 'special' } }); +import('external' + globalThis.unknown, { assert: { type: 'special' } }); +import('external-resolved', { with: { type: 'special' } }); +import('unresolved', { assert: { type: 'special' } }); diff --git a/test/form/samples/import-attributes/keeps-static-assertions/_config.js b/test/form/samples/import-attributes/keeps-static-assertions/_config.js new file mode 100644 index 00000000000..9e18f637f0b --- /dev/null +++ b/test/form/samples/import-attributes/keeps-static-assertions/_config.js @@ -0,0 +1,14 @@ +module.exports = defineTest({ + description: 'keeps any import assertions on input', + expectedWarnings: ['UNRESOLVED_IMPORT'], + options: { + external: id => { + if (id === 'unresolved') return null; + return true; + }, + output: { + globals: id => id, + name: 'bundle' + } + } +}); diff --git a/test/form/samples/import-attributes/keeps-static-assertions/_expected/amd.js b/test/form/samples/import-attributes/keeps-static-assertions/_expected/amd.js new file mode 100644 index 00000000000..57334be0e8a --- /dev/null +++ b/test/form/samples/import-attributes/keeps-static-assertions/_expected/amd.js @@ -0,0 +1,35 @@ +define(['exports', 'a', 'b', 'c', 'd', 'unresolved'], (function (exports, a, b, c, d$1, unresolved) { 'use strict'; + + function _interopNamespaceDefault(e) { + var n = Object.create(null); + if (e) { + Object.keys(e).forEach(function (k) { + if (k !== 'default') { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + } + n.default = e; + return Object.freeze(n); + } + + var b__namespace = /*#__PURE__*/_interopNamespaceDefault(b); + + console.log(a.a, b__namespace, d); + + Object.defineProperty(exports, "c", { + enumerable: true, + get: function () { return c.c; } + }); + Object.keys(d$1).forEach(function (k) { + if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, { + enumerable: true, + get: function () { return d$1[k]; } + }); + }); + +})); diff --git a/test/form/samples/import-attributes/keeps-static-assertions/_expected/cjs.js b/test/form/samples/import-attributes/keeps-static-assertions/_expected/cjs.js new file mode 100644 index 00000000000..c8fe9e7fa64 --- /dev/null +++ b/test/form/samples/import-attributes/keeps-static-assertions/_expected/cjs.js @@ -0,0 +1,39 @@ +'use strict'; + +var a = require('a'); +var b = require('b'); +var c = require('c'); +var d$1 = require('d'); +require('unresolved'); + +function _interopNamespaceDefault(e) { + var n = Object.create(null); + if (e) { + Object.keys(e).forEach(function (k) { + if (k !== 'default') { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + } + n.default = e; + return Object.freeze(n); +} + +var b__namespace = /*#__PURE__*/_interopNamespaceDefault(b); + +console.log(a.a, b__namespace, d); + +Object.defineProperty(exports, "c", { + enumerable: true, + get: function () { return c.c; } +}); +Object.keys(d$1).forEach(function (k) { + if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, { + enumerable: true, + get: function () { return d$1[k]; } + }); +}); diff --git a/test/form/samples/import-attributes/keeps-static-assertions/_expected/es.js b/test/form/samples/import-attributes/keeps-static-assertions/_expected/es.js new file mode 100644 index 00000000000..ba6c7ba4532 --- /dev/null +++ b/test/form/samples/import-attributes/keeps-static-assertions/_expected/es.js @@ -0,0 +1,7 @@ +import { a } from 'a' assert { type: 'a', extra: 'extra' }; +import * as b from 'b' assert { type: 'b' }; +export { c } from 'c' assert { type: 'c' }; +export * from 'd' assert { type: 'd' }; +import 'unresolved' assert { type: 'e' }; + +console.log(a, b, d); diff --git a/test/form/samples/import-attributes/keeps-static-assertions/_expected/iife.js b/test/form/samples/import-attributes/keeps-static-assertions/_expected/iife.js new file mode 100644 index 00000000000..6ded01a39a1 --- /dev/null +++ b/test/form/samples/import-attributes/keeps-static-assertions/_expected/iife.js @@ -0,0 +1,38 @@ +var bundle = (function (exports, a, b, c, d$1) { + 'use strict'; + + function _interopNamespaceDefault(e) { + var n = Object.create(null); + if (e) { + Object.keys(e).forEach(function (k) { + if (k !== 'default') { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + } + n.default = e; + return Object.freeze(n); + } + + var b__namespace = /*#__PURE__*/_interopNamespaceDefault(b); + + console.log(a.a, b__namespace, d); + + Object.defineProperty(exports, "c", { + enumerable: true, + get: function () { return c.c; } + }); + Object.keys(d$1).forEach(function (k) { + if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, { + enumerable: true, + get: function () { return d$1[k]; } + }); + }); + + return exports; + +})({}, a, b, c, d); diff --git a/test/form/samples/import-attributes/keeps-static-assertions/_expected/system.js b/test/form/samples/import-attributes/keeps-static-assertions/_expected/system.js new file mode 100644 index 00000000000..d823b361ff6 --- /dev/null +++ b/test/form/samples/import-attributes/keeps-static-assertions/_expected/system.js @@ -0,0 +1,29 @@ +System.register('bundle', ['a', 'b', 'c', 'd', 'unresolved'], (function (exports) { + 'use strict'; + var _starExcludes = { + __proto__: null, + default: 1, + c: 1 + }; + var a, b; + return { + setters: [function (module) { + a = module.a; + }, function (module) { + b = module; + }, function (module) { + exports("c", module.c); + }, function (module) { + var setter = { __proto__: null }; + for (var name in module) { + if (!_starExcludes[name]) setter[name] = module[name]; + } + exports(setter); + }, null], + execute: (function () { + + console.log(a, b, d); + + }) + }; +})); diff --git a/test/form/samples/import-attributes/keeps-static-assertions/_expected/umd.js b/test/form/samples/import-attributes/keeps-static-assertions/_expected/umd.js new file mode 100644 index 00000000000..78d4e9f91d0 --- /dev/null +++ b/test/form/samples/import-attributes/keeps-static-assertions/_expected/umd.js @@ -0,0 +1,39 @@ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('a'), require('b'), require('c'), require('d'), require('unresolved')) : + typeof define === 'function' && define.amd ? define(['exports', 'a', 'b', 'c', 'd', 'unresolved'], factory) : + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.bundle = {}, global.a, global.b, global.c, global.d)); +})(this, (function (exports, a, b, c, d$1) { 'use strict'; + + function _interopNamespaceDefault(e) { + var n = Object.create(null); + if (e) { + Object.keys(e).forEach(function (k) { + if (k !== 'default') { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + } + n.default = e; + return Object.freeze(n); + } + + var b__namespace = /*#__PURE__*/_interopNamespaceDefault(b); + + console.log(a.a, b__namespace, d); + + Object.defineProperty(exports, "c", { + enumerable: true, + get: function () { return c.c; } + }); + Object.keys(d$1).forEach(function (k) { + if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, { + enumerable: true, + get: function () { return d$1[k]; } + }); + }); + +})); diff --git a/test/form/samples/import-attributes/keeps-static-assertions/main.js b/test/form/samples/import-attributes/keeps-static-assertions/main.js new file mode 100644 index 00000000000..02b154c863a --- /dev/null +++ b/test/form/samples/import-attributes/keeps-static-assertions/main.js @@ -0,0 +1,9 @@ +import { a } from 'a' assert { type: 'a', extra: 'extra' }; +import * as b from 'b' assert { type: 'b' }; +export { c } from 'c' assert { type: 'c' }; +export * from 'd' assert { type: 'd' }; +import 'unresolved' assert { type: 'e' }; + +console.log(a, b, d); + + diff --git a/test/form/samples/import-attributes/keeps-static-attributes-key-assert/_config.js b/test/form/samples/import-attributes/keeps-static-attributes-key-assert/_config.js new file mode 100644 index 00000000000..e99b7c97197 --- /dev/null +++ b/test/form/samples/import-attributes/keeps-static-attributes-key-assert/_config.js @@ -0,0 +1,15 @@ +module.exports = defineTest({ + description: 'keeps any import attributes on input using import attributes with "with" key', + expectedWarnings: ['UNRESOLVED_IMPORT'], + options: { + external: id => { + if (id === 'unresolved') return null; + return true; + }, + output: { + globals: id => id, + importAttributesKey: 'assert', + name: 'bundle' + } + } +}); diff --git a/test/form/samples/import-attributes/keeps-static-attributes-key-assert/_expected/amd.js b/test/form/samples/import-attributes/keeps-static-attributes-key-assert/_expected/amd.js new file mode 100644 index 00000000000..57334be0e8a --- /dev/null +++ b/test/form/samples/import-attributes/keeps-static-attributes-key-assert/_expected/amd.js @@ -0,0 +1,35 @@ +define(['exports', 'a', 'b', 'c', 'd', 'unresolved'], (function (exports, a, b, c, d$1, unresolved) { 'use strict'; + + function _interopNamespaceDefault(e) { + var n = Object.create(null); + if (e) { + Object.keys(e).forEach(function (k) { + if (k !== 'default') { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + } + n.default = e; + return Object.freeze(n); + } + + var b__namespace = /*#__PURE__*/_interopNamespaceDefault(b); + + console.log(a.a, b__namespace, d); + + Object.defineProperty(exports, "c", { + enumerable: true, + get: function () { return c.c; } + }); + Object.keys(d$1).forEach(function (k) { + if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, { + enumerable: true, + get: function () { return d$1[k]; } + }); + }); + +})); diff --git a/test/form/samples/import-attributes/keeps-static-attributes-key-assert/_expected/cjs.js b/test/form/samples/import-attributes/keeps-static-attributes-key-assert/_expected/cjs.js new file mode 100644 index 00000000000..c8fe9e7fa64 --- /dev/null +++ b/test/form/samples/import-attributes/keeps-static-attributes-key-assert/_expected/cjs.js @@ -0,0 +1,39 @@ +'use strict'; + +var a = require('a'); +var b = require('b'); +var c = require('c'); +var d$1 = require('d'); +require('unresolved'); + +function _interopNamespaceDefault(e) { + var n = Object.create(null); + if (e) { + Object.keys(e).forEach(function (k) { + if (k !== 'default') { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + } + n.default = e; + return Object.freeze(n); +} + +var b__namespace = /*#__PURE__*/_interopNamespaceDefault(b); + +console.log(a.a, b__namespace, d); + +Object.defineProperty(exports, "c", { + enumerable: true, + get: function () { return c.c; } +}); +Object.keys(d$1).forEach(function (k) { + if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, { + enumerable: true, + get: function () { return d$1[k]; } + }); +}); diff --git a/test/form/samples/import-attributes/keeps-static-attributes-key-assert/_expected/es.js b/test/form/samples/import-attributes/keeps-static-attributes-key-assert/_expected/es.js new file mode 100644 index 00000000000..ba6c7ba4532 --- /dev/null +++ b/test/form/samples/import-attributes/keeps-static-attributes-key-assert/_expected/es.js @@ -0,0 +1,7 @@ +import { a } from 'a' assert { type: 'a', extra: 'extra' }; +import * as b from 'b' assert { type: 'b' }; +export { c } from 'c' assert { type: 'c' }; +export * from 'd' assert { type: 'd' }; +import 'unresolved' assert { type: 'e' }; + +console.log(a, b, d); diff --git a/test/form/samples/import-attributes/keeps-static-attributes-key-assert/_expected/iife.js b/test/form/samples/import-attributes/keeps-static-attributes-key-assert/_expected/iife.js new file mode 100644 index 00000000000..6ded01a39a1 --- /dev/null +++ b/test/form/samples/import-attributes/keeps-static-attributes-key-assert/_expected/iife.js @@ -0,0 +1,38 @@ +var bundle = (function (exports, a, b, c, d$1) { + 'use strict'; + + function _interopNamespaceDefault(e) { + var n = Object.create(null); + if (e) { + Object.keys(e).forEach(function (k) { + if (k !== 'default') { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + } + n.default = e; + return Object.freeze(n); + } + + var b__namespace = /*#__PURE__*/_interopNamespaceDefault(b); + + console.log(a.a, b__namespace, d); + + Object.defineProperty(exports, "c", { + enumerable: true, + get: function () { return c.c; } + }); + Object.keys(d$1).forEach(function (k) { + if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, { + enumerable: true, + get: function () { return d$1[k]; } + }); + }); + + return exports; + +})({}, a, b, c, d); diff --git a/test/form/samples/import-attributes/keeps-static-attributes-key-assert/_expected/system.js b/test/form/samples/import-attributes/keeps-static-attributes-key-assert/_expected/system.js new file mode 100644 index 00000000000..d823b361ff6 --- /dev/null +++ b/test/form/samples/import-attributes/keeps-static-attributes-key-assert/_expected/system.js @@ -0,0 +1,29 @@ +System.register('bundle', ['a', 'b', 'c', 'd', 'unresolved'], (function (exports) { + 'use strict'; + var _starExcludes = { + __proto__: null, + default: 1, + c: 1 + }; + var a, b; + return { + setters: [function (module) { + a = module.a; + }, function (module) { + b = module; + }, function (module) { + exports("c", module.c); + }, function (module) { + var setter = { __proto__: null }; + for (var name in module) { + if (!_starExcludes[name]) setter[name] = module[name]; + } + exports(setter); + }, null], + execute: (function () { + + console.log(a, b, d); + + }) + }; +})); diff --git a/test/form/samples/import-attributes/keeps-static-attributes-key-assert/_expected/umd.js b/test/form/samples/import-attributes/keeps-static-attributes-key-assert/_expected/umd.js new file mode 100644 index 00000000000..78d4e9f91d0 --- /dev/null +++ b/test/form/samples/import-attributes/keeps-static-attributes-key-assert/_expected/umd.js @@ -0,0 +1,39 @@ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('a'), require('b'), require('c'), require('d'), require('unresolved')) : + typeof define === 'function' && define.amd ? define(['exports', 'a', 'b', 'c', 'd', 'unresolved'], factory) : + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.bundle = {}, global.a, global.b, global.c, global.d)); +})(this, (function (exports, a, b, c, d$1) { 'use strict'; + + function _interopNamespaceDefault(e) { + var n = Object.create(null); + if (e) { + Object.keys(e).forEach(function (k) { + if (k !== 'default') { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + } + n.default = e; + return Object.freeze(n); + } + + var b__namespace = /*#__PURE__*/_interopNamespaceDefault(b); + + console.log(a.a, b__namespace, d); + + Object.defineProperty(exports, "c", { + enumerable: true, + get: function () { return c.c; } + }); + Object.keys(d$1).forEach(function (k) { + if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, { + enumerable: true, + get: function () { return d$1[k]; } + }); + }); + +})); diff --git a/test/form/samples/import-attributes/keeps-static-attributes-key-assert/main.js b/test/form/samples/import-attributes/keeps-static-attributes-key-assert/main.js new file mode 100644 index 00000000000..64538165030 --- /dev/null +++ b/test/form/samples/import-attributes/keeps-static-attributes-key-assert/main.js @@ -0,0 +1,9 @@ +import { a } from 'a' with { type: 'a', extra: 'extra' }; +import * as b from 'b' with { type: 'b' }; +export { c } from 'c' with { type: 'c' }; +export * from 'd' with { type: 'd' }; +import 'unresolved' with { type: 'e' }; + +console.log(a, b, d); + + diff --git a/test/form/samples/import-attributes/keeps-static-attributes-key-default/_config.js b/test/form/samples/import-attributes/keeps-static-attributes-key-default/_config.js new file mode 100644 index 00000000000..30f4ed46495 --- /dev/null +++ b/test/form/samples/import-attributes/keeps-static-attributes-key-default/_config.js @@ -0,0 +1,14 @@ +module.exports = defineTest({ + description: 'keeps any import attributes on input using import attributes with "with" key', + expectedWarnings: ['UNRESOLVED_IMPORT'], + options: { + external: id => { + if (id === 'unresolved') return null; + return true; + }, + output: { + globals: id => id, + name: 'bundle' + } + } +}); diff --git a/test/form/samples/import-attributes/keeps-static-attributes-key-default/_expected/amd.js b/test/form/samples/import-attributes/keeps-static-attributes-key-default/_expected/amd.js new file mode 100644 index 00000000000..57334be0e8a --- /dev/null +++ b/test/form/samples/import-attributes/keeps-static-attributes-key-default/_expected/amd.js @@ -0,0 +1,35 @@ +define(['exports', 'a', 'b', 'c', 'd', 'unresolved'], (function (exports, a, b, c, d$1, unresolved) { 'use strict'; + + function _interopNamespaceDefault(e) { + var n = Object.create(null); + if (e) { + Object.keys(e).forEach(function (k) { + if (k !== 'default') { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + } + n.default = e; + return Object.freeze(n); + } + + var b__namespace = /*#__PURE__*/_interopNamespaceDefault(b); + + console.log(a.a, b__namespace, d); + + Object.defineProperty(exports, "c", { + enumerable: true, + get: function () { return c.c; } + }); + Object.keys(d$1).forEach(function (k) { + if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, { + enumerable: true, + get: function () { return d$1[k]; } + }); + }); + +})); diff --git a/test/form/samples/import-attributes/keeps-static-attributes-key-default/_expected/cjs.js b/test/form/samples/import-attributes/keeps-static-attributes-key-default/_expected/cjs.js new file mode 100644 index 00000000000..c8fe9e7fa64 --- /dev/null +++ b/test/form/samples/import-attributes/keeps-static-attributes-key-default/_expected/cjs.js @@ -0,0 +1,39 @@ +'use strict'; + +var a = require('a'); +var b = require('b'); +var c = require('c'); +var d$1 = require('d'); +require('unresolved'); + +function _interopNamespaceDefault(e) { + var n = Object.create(null); + if (e) { + Object.keys(e).forEach(function (k) { + if (k !== 'default') { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + } + n.default = e; + return Object.freeze(n); +} + +var b__namespace = /*#__PURE__*/_interopNamespaceDefault(b); + +console.log(a.a, b__namespace, d); + +Object.defineProperty(exports, "c", { + enumerable: true, + get: function () { return c.c; } +}); +Object.keys(d$1).forEach(function (k) { + if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, { + enumerable: true, + get: function () { return d$1[k]; } + }); +}); diff --git a/test/form/samples/import-attributes/keeps-static-attributes-key-default/_expected/es.js b/test/form/samples/import-attributes/keeps-static-attributes-key-default/_expected/es.js new file mode 100644 index 00000000000..ba6c7ba4532 --- /dev/null +++ b/test/form/samples/import-attributes/keeps-static-attributes-key-default/_expected/es.js @@ -0,0 +1,7 @@ +import { a } from 'a' assert { type: 'a', extra: 'extra' }; +import * as b from 'b' assert { type: 'b' }; +export { c } from 'c' assert { type: 'c' }; +export * from 'd' assert { type: 'd' }; +import 'unresolved' assert { type: 'e' }; + +console.log(a, b, d); diff --git a/test/form/samples/import-attributes/keeps-static-attributes-key-default/_expected/iife.js b/test/form/samples/import-attributes/keeps-static-attributes-key-default/_expected/iife.js new file mode 100644 index 00000000000..6ded01a39a1 --- /dev/null +++ b/test/form/samples/import-attributes/keeps-static-attributes-key-default/_expected/iife.js @@ -0,0 +1,38 @@ +var bundle = (function (exports, a, b, c, d$1) { + 'use strict'; + + function _interopNamespaceDefault(e) { + var n = Object.create(null); + if (e) { + Object.keys(e).forEach(function (k) { + if (k !== 'default') { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + } + n.default = e; + return Object.freeze(n); + } + + var b__namespace = /*#__PURE__*/_interopNamespaceDefault(b); + + console.log(a.a, b__namespace, d); + + Object.defineProperty(exports, "c", { + enumerable: true, + get: function () { return c.c; } + }); + Object.keys(d$1).forEach(function (k) { + if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, { + enumerable: true, + get: function () { return d$1[k]; } + }); + }); + + return exports; + +})({}, a, b, c, d); diff --git a/test/form/samples/import-attributes/keeps-static-attributes-key-default/_expected/system.js b/test/form/samples/import-attributes/keeps-static-attributes-key-default/_expected/system.js new file mode 100644 index 00000000000..d823b361ff6 --- /dev/null +++ b/test/form/samples/import-attributes/keeps-static-attributes-key-default/_expected/system.js @@ -0,0 +1,29 @@ +System.register('bundle', ['a', 'b', 'c', 'd', 'unresolved'], (function (exports) { + 'use strict'; + var _starExcludes = { + __proto__: null, + default: 1, + c: 1 + }; + var a, b; + return { + setters: [function (module) { + a = module.a; + }, function (module) { + b = module; + }, function (module) { + exports("c", module.c); + }, function (module) { + var setter = { __proto__: null }; + for (var name in module) { + if (!_starExcludes[name]) setter[name] = module[name]; + } + exports(setter); + }, null], + execute: (function () { + + console.log(a, b, d); + + }) + }; +})); diff --git a/test/form/samples/import-attributes/keeps-static-attributes-key-default/_expected/umd.js b/test/form/samples/import-attributes/keeps-static-attributes-key-default/_expected/umd.js new file mode 100644 index 00000000000..78d4e9f91d0 --- /dev/null +++ b/test/form/samples/import-attributes/keeps-static-attributes-key-default/_expected/umd.js @@ -0,0 +1,39 @@ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('a'), require('b'), require('c'), require('d'), require('unresolved')) : + typeof define === 'function' && define.amd ? define(['exports', 'a', 'b', 'c', 'd', 'unresolved'], factory) : + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.bundle = {}, global.a, global.b, global.c, global.d)); +})(this, (function (exports, a, b, c, d$1) { 'use strict'; + + function _interopNamespaceDefault(e) { + var n = Object.create(null); + if (e) { + Object.keys(e).forEach(function (k) { + if (k !== 'default') { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + } + n.default = e; + return Object.freeze(n); + } + + var b__namespace = /*#__PURE__*/_interopNamespaceDefault(b); + + console.log(a.a, b__namespace, d); + + Object.defineProperty(exports, "c", { + enumerable: true, + get: function () { return c.c; } + }); + Object.keys(d$1).forEach(function (k) { + if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, { + enumerable: true, + get: function () { return d$1[k]; } + }); + }); + +})); diff --git a/test/form/samples/import-attributes/keeps-static-attributes-key-default/main.js b/test/form/samples/import-attributes/keeps-static-attributes-key-default/main.js new file mode 100644 index 00000000000..64538165030 --- /dev/null +++ b/test/form/samples/import-attributes/keeps-static-attributes-key-default/main.js @@ -0,0 +1,9 @@ +import { a } from 'a' with { type: 'a', extra: 'extra' }; +import * as b from 'b' with { type: 'b' }; +export { c } from 'c' with { type: 'c' }; +export * from 'd' with { type: 'd' }; +import 'unresolved' with { type: 'e' }; + +console.log(a, b, d); + + diff --git a/test/form/samples/import-attributes/keeps-static-attributes-key-with/_config.js b/test/form/samples/import-attributes/keeps-static-attributes-key-with/_config.js new file mode 100644 index 00000000000..64422f6ace8 --- /dev/null +++ b/test/form/samples/import-attributes/keeps-static-attributes-key-with/_config.js @@ -0,0 +1,15 @@ +module.exports = defineTest({ + description: 'keeps any import attributes on input using import attributes with "with" key', + expectedWarnings: ['UNRESOLVED_IMPORT'], + options: { + external: id => { + if (id === 'unresolved') return null; + return true; + }, + output: { + globals: id => id, + importAttributesKey: 'with', + name: 'bundle' + } + } +}); diff --git a/test/form/samples/import-attributes/keeps-static-attributes-key-with/_expected/amd.js b/test/form/samples/import-attributes/keeps-static-attributes-key-with/_expected/amd.js new file mode 100644 index 00000000000..57334be0e8a --- /dev/null +++ b/test/form/samples/import-attributes/keeps-static-attributes-key-with/_expected/amd.js @@ -0,0 +1,35 @@ +define(['exports', 'a', 'b', 'c', 'd', 'unresolved'], (function (exports, a, b, c, d$1, unresolved) { 'use strict'; + + function _interopNamespaceDefault(e) { + var n = Object.create(null); + if (e) { + Object.keys(e).forEach(function (k) { + if (k !== 'default') { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + } + n.default = e; + return Object.freeze(n); + } + + var b__namespace = /*#__PURE__*/_interopNamespaceDefault(b); + + console.log(a.a, b__namespace, d); + + Object.defineProperty(exports, "c", { + enumerable: true, + get: function () { return c.c; } + }); + Object.keys(d$1).forEach(function (k) { + if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, { + enumerable: true, + get: function () { return d$1[k]; } + }); + }); + +})); diff --git a/test/form/samples/import-attributes/keeps-static-attributes-key-with/_expected/cjs.js b/test/form/samples/import-attributes/keeps-static-attributes-key-with/_expected/cjs.js new file mode 100644 index 00000000000..c8fe9e7fa64 --- /dev/null +++ b/test/form/samples/import-attributes/keeps-static-attributes-key-with/_expected/cjs.js @@ -0,0 +1,39 @@ +'use strict'; + +var a = require('a'); +var b = require('b'); +var c = require('c'); +var d$1 = require('d'); +require('unresolved'); + +function _interopNamespaceDefault(e) { + var n = Object.create(null); + if (e) { + Object.keys(e).forEach(function (k) { + if (k !== 'default') { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + } + n.default = e; + return Object.freeze(n); +} + +var b__namespace = /*#__PURE__*/_interopNamespaceDefault(b); + +console.log(a.a, b__namespace, d); + +Object.defineProperty(exports, "c", { + enumerable: true, + get: function () { return c.c; } +}); +Object.keys(d$1).forEach(function (k) { + if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, { + enumerable: true, + get: function () { return d$1[k]; } + }); +}); diff --git a/test/form/samples/import-attributes/keeps-static-attributes-key-with/_expected/es.js b/test/form/samples/import-attributes/keeps-static-attributes-key-with/_expected/es.js new file mode 100644 index 00000000000..e51512351ea --- /dev/null +++ b/test/form/samples/import-attributes/keeps-static-attributes-key-with/_expected/es.js @@ -0,0 +1,7 @@ +import { a } from 'a' with { type: 'a', extra: 'extra' }; +import * as b from 'b' with { type: 'b' }; +export { c } from 'c' with { type: 'c' }; +export * from 'd' with { type: 'd' }; +import 'unresolved' with { type: 'e' }; + +console.log(a, b, d); diff --git a/test/form/samples/import-attributes/keeps-static-attributes-key-with/_expected/iife.js b/test/form/samples/import-attributes/keeps-static-attributes-key-with/_expected/iife.js new file mode 100644 index 00000000000..6ded01a39a1 --- /dev/null +++ b/test/form/samples/import-attributes/keeps-static-attributes-key-with/_expected/iife.js @@ -0,0 +1,38 @@ +var bundle = (function (exports, a, b, c, d$1) { + 'use strict'; + + function _interopNamespaceDefault(e) { + var n = Object.create(null); + if (e) { + Object.keys(e).forEach(function (k) { + if (k !== 'default') { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + } + n.default = e; + return Object.freeze(n); + } + + var b__namespace = /*#__PURE__*/_interopNamespaceDefault(b); + + console.log(a.a, b__namespace, d); + + Object.defineProperty(exports, "c", { + enumerable: true, + get: function () { return c.c; } + }); + Object.keys(d$1).forEach(function (k) { + if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, { + enumerable: true, + get: function () { return d$1[k]; } + }); + }); + + return exports; + +})({}, a, b, c, d); diff --git a/test/form/samples/import-attributes/keeps-static-attributes-key-with/_expected/system.js b/test/form/samples/import-attributes/keeps-static-attributes-key-with/_expected/system.js new file mode 100644 index 00000000000..d823b361ff6 --- /dev/null +++ b/test/form/samples/import-attributes/keeps-static-attributes-key-with/_expected/system.js @@ -0,0 +1,29 @@ +System.register('bundle', ['a', 'b', 'c', 'd', 'unresolved'], (function (exports) { + 'use strict'; + var _starExcludes = { + __proto__: null, + default: 1, + c: 1 + }; + var a, b; + return { + setters: [function (module) { + a = module.a; + }, function (module) { + b = module; + }, function (module) { + exports("c", module.c); + }, function (module) { + var setter = { __proto__: null }; + for (var name in module) { + if (!_starExcludes[name]) setter[name] = module[name]; + } + exports(setter); + }, null], + execute: (function () { + + console.log(a, b, d); + + }) + }; +})); diff --git a/test/form/samples/import-attributes/keeps-static-attributes-key-with/_expected/umd.js b/test/form/samples/import-attributes/keeps-static-attributes-key-with/_expected/umd.js new file mode 100644 index 00000000000..78d4e9f91d0 --- /dev/null +++ b/test/form/samples/import-attributes/keeps-static-attributes-key-with/_expected/umd.js @@ -0,0 +1,39 @@ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('a'), require('b'), require('c'), require('d'), require('unresolved')) : + typeof define === 'function' && define.amd ? define(['exports', 'a', 'b', 'c', 'd', 'unresolved'], factory) : + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.bundle = {}, global.a, global.b, global.c, global.d)); +})(this, (function (exports, a, b, c, d$1) { 'use strict'; + + function _interopNamespaceDefault(e) { + var n = Object.create(null); + if (e) { + Object.keys(e).forEach(function (k) { + if (k !== 'default') { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + } + n.default = e; + return Object.freeze(n); + } + + var b__namespace = /*#__PURE__*/_interopNamespaceDefault(b); + + console.log(a.a, b__namespace, d); + + Object.defineProperty(exports, "c", { + enumerable: true, + get: function () { return c.c; } + }); + Object.keys(d$1).forEach(function (k) { + if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, { + enumerable: true, + get: function () { return d$1[k]; } + }); + }); + +})); diff --git a/test/form/samples/import-attributes/keeps-static-attributes-key-with/main.js b/test/form/samples/import-attributes/keeps-static-attributes-key-with/main.js new file mode 100644 index 00000000000..64538165030 --- /dev/null +++ b/test/form/samples/import-attributes/keeps-static-attributes-key-with/main.js @@ -0,0 +1,9 @@ +import { a } from 'a' with { type: 'a', extra: 'extra' }; +import * as b from 'b' with { type: 'b' }; +export { c } from 'c' with { type: 'c' }; +export * from 'd' with { type: 'd' }; +import 'unresolved' with { type: 'e' }; + +console.log(a, b, d); + + diff --git a/test/form/samples/import-attributes/keeps-static-attributes/_config.js b/test/form/samples/import-attributes/keeps-static-attributes/_config.js new file mode 100644 index 00000000000..335bd901a97 --- /dev/null +++ b/test/form/samples/import-attributes/keeps-static-attributes/_config.js @@ -0,0 +1,14 @@ +module.exports = defineTest({ + description: 'keeps any import attributes on input', + expectedWarnings: ['UNRESOLVED_IMPORT'], + options: { + external: id => { + if (id === 'unresolved') return null; + return true; + }, + output: { + globals: id => id, + name: 'bundle' + } + } +}); diff --git a/test/form/samples/import-attributes/keeps-static-attributes/_expected/amd.js b/test/form/samples/import-attributes/keeps-static-attributes/_expected/amd.js new file mode 100644 index 00000000000..57334be0e8a --- /dev/null +++ b/test/form/samples/import-attributes/keeps-static-attributes/_expected/amd.js @@ -0,0 +1,35 @@ +define(['exports', 'a', 'b', 'c', 'd', 'unresolved'], (function (exports, a, b, c, d$1, unresolved) { 'use strict'; + + function _interopNamespaceDefault(e) { + var n = Object.create(null); + if (e) { + Object.keys(e).forEach(function (k) { + if (k !== 'default') { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + } + n.default = e; + return Object.freeze(n); + } + + var b__namespace = /*#__PURE__*/_interopNamespaceDefault(b); + + console.log(a.a, b__namespace, d); + + Object.defineProperty(exports, "c", { + enumerable: true, + get: function () { return c.c; } + }); + Object.keys(d$1).forEach(function (k) { + if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, { + enumerable: true, + get: function () { return d$1[k]; } + }); + }); + +})); diff --git a/test/form/samples/import-attributes/keeps-static-attributes/_expected/cjs.js b/test/form/samples/import-attributes/keeps-static-attributes/_expected/cjs.js new file mode 100644 index 00000000000..c8fe9e7fa64 --- /dev/null +++ b/test/form/samples/import-attributes/keeps-static-attributes/_expected/cjs.js @@ -0,0 +1,39 @@ +'use strict'; + +var a = require('a'); +var b = require('b'); +var c = require('c'); +var d$1 = require('d'); +require('unresolved'); + +function _interopNamespaceDefault(e) { + var n = Object.create(null); + if (e) { + Object.keys(e).forEach(function (k) { + if (k !== 'default') { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + } + n.default = e; + return Object.freeze(n); +} + +var b__namespace = /*#__PURE__*/_interopNamespaceDefault(b); + +console.log(a.a, b__namespace, d); + +Object.defineProperty(exports, "c", { + enumerable: true, + get: function () { return c.c; } +}); +Object.keys(d$1).forEach(function (k) { + if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, { + enumerable: true, + get: function () { return d$1[k]; } + }); +}); diff --git a/test/form/samples/import-attributes/keeps-static-attributes/_expected/es.js b/test/form/samples/import-attributes/keeps-static-attributes/_expected/es.js new file mode 100644 index 00000000000..ba6c7ba4532 --- /dev/null +++ b/test/form/samples/import-attributes/keeps-static-attributes/_expected/es.js @@ -0,0 +1,7 @@ +import { a } from 'a' assert { type: 'a', extra: 'extra' }; +import * as b from 'b' assert { type: 'b' }; +export { c } from 'c' assert { type: 'c' }; +export * from 'd' assert { type: 'd' }; +import 'unresolved' assert { type: 'e' }; + +console.log(a, b, d); diff --git a/test/form/samples/import-attributes/keeps-static-attributes/_expected/iife.js b/test/form/samples/import-attributes/keeps-static-attributes/_expected/iife.js new file mode 100644 index 00000000000..6ded01a39a1 --- /dev/null +++ b/test/form/samples/import-attributes/keeps-static-attributes/_expected/iife.js @@ -0,0 +1,38 @@ +var bundle = (function (exports, a, b, c, d$1) { + 'use strict'; + + function _interopNamespaceDefault(e) { + var n = Object.create(null); + if (e) { + Object.keys(e).forEach(function (k) { + if (k !== 'default') { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + } + n.default = e; + return Object.freeze(n); + } + + var b__namespace = /*#__PURE__*/_interopNamespaceDefault(b); + + console.log(a.a, b__namespace, d); + + Object.defineProperty(exports, "c", { + enumerable: true, + get: function () { return c.c; } + }); + Object.keys(d$1).forEach(function (k) { + if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, { + enumerable: true, + get: function () { return d$1[k]; } + }); + }); + + return exports; + +})({}, a, b, c, d); diff --git a/test/form/samples/import-attributes/keeps-static-attributes/_expected/system.js b/test/form/samples/import-attributes/keeps-static-attributes/_expected/system.js new file mode 100644 index 00000000000..d823b361ff6 --- /dev/null +++ b/test/form/samples/import-attributes/keeps-static-attributes/_expected/system.js @@ -0,0 +1,29 @@ +System.register('bundle', ['a', 'b', 'c', 'd', 'unresolved'], (function (exports) { + 'use strict'; + var _starExcludes = { + __proto__: null, + default: 1, + c: 1 + }; + var a, b; + return { + setters: [function (module) { + a = module.a; + }, function (module) { + b = module; + }, function (module) { + exports("c", module.c); + }, function (module) { + var setter = { __proto__: null }; + for (var name in module) { + if (!_starExcludes[name]) setter[name] = module[name]; + } + exports(setter); + }, null], + execute: (function () { + + console.log(a, b, d); + + }) + }; +})); diff --git a/test/form/samples/import-attributes/keeps-static-attributes/_expected/umd.js b/test/form/samples/import-attributes/keeps-static-attributes/_expected/umd.js new file mode 100644 index 00000000000..78d4e9f91d0 --- /dev/null +++ b/test/form/samples/import-attributes/keeps-static-attributes/_expected/umd.js @@ -0,0 +1,39 @@ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('a'), require('b'), require('c'), require('d'), require('unresolved')) : + typeof define === 'function' && define.amd ? define(['exports', 'a', 'b', 'c', 'd', 'unresolved'], factory) : + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.bundle = {}, global.a, global.b, global.c, global.d)); +})(this, (function (exports, a, b, c, d$1) { 'use strict'; + + function _interopNamespaceDefault(e) { + var n = Object.create(null); + if (e) { + Object.keys(e).forEach(function (k) { + if (k !== 'default') { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + } + n.default = e; + return Object.freeze(n); + } + + var b__namespace = /*#__PURE__*/_interopNamespaceDefault(b); + + console.log(a.a, b__namespace, d); + + Object.defineProperty(exports, "c", { + enumerable: true, + get: function () { return c.c; } + }); + Object.keys(d$1).forEach(function (k) { + if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, { + enumerable: true, + get: function () { return d$1[k]; } + }); + }); + +})); diff --git a/test/form/samples/import-attributes/keeps-static-attributes/main.js b/test/form/samples/import-attributes/keeps-static-attributes/main.js new file mode 100644 index 00000000000..64538165030 --- /dev/null +++ b/test/form/samples/import-attributes/keeps-static-attributes/main.js @@ -0,0 +1,9 @@ +import { a } from 'a' with { type: 'a', extra: 'extra' }; +import * as b from 'b' with { type: 'b' }; +export { c } from 'c' with { type: 'c' }; +export * from 'd' with { type: 'd' }; +import 'unresolved' with { type: 'e' }; + +console.log(a, b, d); + + diff --git a/test/form/samples/import-attributes/plugin-attributes-resolvedynamicimport/_config.js b/test/form/samples/import-attributes/plugin-attributes-resolvedynamicimport/_config.js new file mode 100644 index 00000000000..77e37956df4 --- /dev/null +++ b/test/form/samples/import-attributes/plugin-attributes-resolvedynamicimport/_config.js @@ -0,0 +1,23 @@ +module.exports = defineTest({ + description: 'allows plugins to read and write import attributes in resolveDynamicImport', + options: { + plugins: [ + { + name: 'test', + resolveDynamicImport(specifier, importer, { attributes }) { + const resolutionOptions = { + external: true, + attributes: Object.fromEntries(Object.keys(attributes).map(key => [key, 'changed'])) + }; + if (typeof specifier === 'object') { + if (specifier.type === 'TemplateLiteral') { + return { id: 'resolved-a', ...resolutionOptions }; + } + return { id: 'resolved-b', ...resolutionOptions }; + } + return { id: specifier, ...resolutionOptions }; + } + } + ] + } +}); diff --git a/test/form/samples/import-attributes/plugin-attributes-resolvedynamicimport/_expected.js b/test/form/samples/import-attributes/plugin-attributes-resolvedynamicimport/_expected.js new file mode 100644 index 00000000000..279b0c9a4f0 --- /dev/null +++ b/test/form/samples/import-attributes/plugin-attributes-resolvedynamicimport/_expected.js @@ -0,0 +1,4 @@ +import('a', { assert: { type: 'changed' } }); +import('resolved-b', { assert: { type: 'changed', extra: 'changed' } }); +import('b'); +import('resolved-a'); diff --git a/test/form/samples/import-attributes/plugin-attributes-resolvedynamicimport/main.js b/test/form/samples/import-attributes/plugin-attributes-resolvedynamicimport/main.js new file mode 100644 index 00000000000..d4fd36770cb --- /dev/null +++ b/test/form/samples/import-attributes/plugin-attributes-resolvedynamicimport/main.js @@ -0,0 +1,4 @@ +import('a', { with: { type: 'special' } }); +import(globalThis.unknown, { with: { type: 'special', extra: 'value' } }); +import('b'); +import(`external-${globalThis.unknown}`); diff --git a/test/form/samples/import-attributes/plugin-attributes-resolveid/_config.js b/test/form/samples/import-attributes/plugin-attributes-resolveid/_config.js new file mode 100644 index 00000000000..67fe341aacc --- /dev/null +++ b/test/form/samples/import-attributes/plugin-attributes-resolveid/_config.js @@ -0,0 +1,21 @@ +module.exports = defineTest({ + description: 'allows plugins to read and write import attributes in resolveId', + // This is an artifact of how we check for attribute conflicts with + // dynamic dependencies and caching + expectedWarnings: ['INCONSISTENT_IMPORT_ATTRIBUTES'], + options: { + output: { name: 'bundle' }, + plugins: [ + { + name: 'test', + resolveId(source, importer, { attributes, isEntry }) { + return { + id: source, + external: !isEntry, + attributes: Object.fromEntries(Object.keys(attributes).map(key => [key, 'changed'])) + }; + } + } + ] + } +}); diff --git a/test/form/samples/import-attributes/plugin-attributes-resolveid/_expected.js b/test/form/samples/import-attributes/plugin-attributes-resolveid/_expected.js new file mode 100644 index 00000000000..200aa397375 --- /dev/null +++ b/test/form/samples/import-attributes/plugin-attributes-resolveid/_expected.js @@ -0,0 +1,9 @@ +import { a } from 'a' assert { type: 'changed', extra: 'changed' }; +import * as b from 'b' assert { type: 'changed' }; +export { c } from 'c' assert { type: 'changed' }; +export * from 'd' assert { type: 'changed' }; +import 'e'; + +console.log(a, b, d); +import('f', { assert: { type: 'changed' } }); +import('g'); diff --git a/test/form/samples/import-attributes/plugin-attributes-resolveid/main.js b/test/form/samples/import-attributes/plugin-attributes-resolveid/main.js new file mode 100644 index 00000000000..239d325724e --- /dev/null +++ b/test/form/samples/import-attributes/plugin-attributes-resolveid/main.js @@ -0,0 +1,9 @@ +import { a } from 'a' with { type: 'a', extra: 'extra' }; +import * as b from 'b' with { type: 'b' }; +export { c } from 'c' with { type: 'c' }; +export * from 'd' with { type: 'd' }; +import 'e'; + +console.log(a, b, d); +import('f', { with: { type: 'f' } }); +import('g'); diff --git a/test/form/samples/import-attributes/removes-dynamic-attributes/_config.js b/test/form/samples/import-attributes/removes-dynamic-attributes/_config.js new file mode 100644 index 00000000000..0c8e6bfc1e2 --- /dev/null +++ b/test/form/samples/import-attributes/removes-dynamic-attributes/_config.js @@ -0,0 +1,29 @@ +module.exports = defineTest({ + description: 'keep import attributes for dynamic imports', + expectedWarnings: ['UNRESOLVED_IMPORT'], + options: { + external: id => { + if (id === 'unresolved') return null; + return true; + }, + plugins: [ + { + name: 'test', + resolveDynamicImport(specifier) { + if (typeof specifier === 'object') { + if (specifier.type === 'TemplateLiteral') { + return "'resolvedString'"; + } + if (specifier.type === 'BinaryExpression') { + return { id: 'resolved-id', external: true }; + } + } else if (specifier === 'external-resolved') { + return { id: 'resolved-different', external: true }; + } + return null; + } + } + ], + output: { externalImportAttributes: false } + } +}); diff --git a/test/form/samples/import-attributes/removes-dynamic-attributes/_expected.js b/test/form/samples/import-attributes/removes-dynamic-attributes/_expected.js new file mode 100644 index 00000000000..2d417264620 --- /dev/null +++ b/test/form/samples/import-attributes/removes-dynamic-attributes/_expected.js @@ -0,0 +1,6 @@ +import('external'); +import(globalThis.unknown); +import('resolvedString'); +import('resolved-id'); +import('resolved-different'); +import('unresolved'); diff --git a/test/form/samples/import-attributes/removes-dynamic-attributes/main.js b/test/form/samples/import-attributes/removes-dynamic-attributes/main.js new file mode 100644 index 00000000000..025b6045192 --- /dev/null +++ b/test/form/samples/import-attributes/removes-dynamic-attributes/main.js @@ -0,0 +1,6 @@ +import('external', { with: { type: 'special' } }); +import(globalThis.unknown, { with: { type: 'special' } }); +import(`external-${globalThis.unknown}`, { with: { type: 'special' } }); +import('external' + globalThis.unknown, { with: { type: 'special' } }); +import('external-resolved', { with: { type: 'special' } }); +import('unresolved', { with: { type: 'special' } }); diff --git a/test/form/samples/import-attributes/removes-static-attributes/_config.js b/test/form/samples/import-attributes/removes-static-attributes/_config.js new file mode 100644 index 00000000000..92caa7dded2 --- /dev/null +++ b/test/form/samples/import-attributes/removes-static-attributes/_config.js @@ -0,0 +1,11 @@ +module.exports = defineTest({ + description: 'keeps any import attributes on input', + expectedWarnings: ['UNRESOLVED_IMPORT'], + options: { + external: id => { + if (id === 'unresolved') return null; + return true; + }, + output: { name: 'bundle', externalImportAttributes: false } + } +}); diff --git a/test/form/samples/import-attributes/removes-static-attributes/_expected.js b/test/form/samples/import-attributes/removes-static-attributes/_expected.js new file mode 100644 index 00000000000..40f55f22388 --- /dev/null +++ b/test/form/samples/import-attributes/removes-static-attributes/_expected.js @@ -0,0 +1,7 @@ +import { a } from 'a'; +import * as b from 'b'; +export { c } from 'c'; +export * from 'd'; +import 'unresolved'; + +console.log(a, b, d); diff --git a/test/form/samples/import-attributes/removes-static-attributes/main.js b/test/form/samples/import-attributes/removes-static-attributes/main.js new file mode 100644 index 00000000000..64538165030 --- /dev/null +++ b/test/form/samples/import-attributes/removes-static-attributes/main.js @@ -0,0 +1,9 @@ +import { a } from 'a' with { type: 'a', extra: 'extra' }; +import * as b from 'b' with { type: 'b' }; +export { c } from 'c' with { type: 'c' }; +export * from 'd' with { type: 'd' }; +import 'unresolved' with { type: 'e' }; + +console.log(a, b, d); + + diff --git a/test/form/samples/import-expression/_config.js b/test/form/samples/import-expression/_config.js index b8e2cfab5eb..d9da2eb415a 100644 --- a/test/form/samples/import-expression/_config.js +++ b/test/form/samples/import-expression/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'correctly transforms variables in imported expressions', options: { external: 'external', @@ -6,4 +6,4 @@ module.exports = { globals: { external: 'external' } } } -}; +}); diff --git a/test/form/samples/import-expression/_expected/amd.js b/test/form/samples/import-expression/_expected/amd.js index 9c9391b17d8..46b13e91831 100644 --- a/test/form/samples/import-expression/_expected/amd.js +++ b/test/form/samples/import-expression/_expected/amd.js @@ -1,7 +1,6 @@ -define(['require', 'external'], function (require, external) { 'use strict'; +define(['require', 'external'], (function (require, external) { 'use strict'; - function _interopNamespace(e) { - if (e && e.__esModule) return e; + function _interopNamespaceDefault(e) { var n = Object.create(null); if (e) { Object.keys(e).forEach(function (k) { @@ -9,18 +8,16 @@ define(['require', 'external'], function (require, external) { 'use strict'; var d = Object.getOwnPropertyDescriptor(e, k); Object.defineProperty(n, k, d.get ? d : { enumerable: true, - get: function () { - return e[k]; - } + get: function () { return e[k]; } }); } }); } - n['default'] = e; + n.default = e; return Object.freeze(n); } - new Promise(function (resolve, reject) { require([external.join('a', 'b')], function (m) { resolve(/*#__PURE__*/_interopNamespace(m)); }, reject) }); + (function (t) { return new Promise(function (resolve, reject) { require([t], function (m) { resolve(/*#__PURE__*/_interopNamespaceDefault(m)); }, reject); }); })(external.join('a', 'b')); console.log(external.join); -}); +})); diff --git a/test/form/samples/import-expression/_expected/cjs.js b/test/form/samples/import-expression/_expected/cjs.js index 4c12f87304f..bd463137fe4 100644 --- a/test/form/samples/import-expression/_expected/cjs.js +++ b/test/form/samples/import-expression/_expected/cjs.js @@ -2,25 +2,5 @@ var external = require('external'); -function _interopNamespace(e) { - if (e && e.__esModule) return e; - var n = Object.create(null); - if (e) { - Object.keys(e).forEach(function (k) { - if (k !== 'default') { - var d = Object.getOwnPropertyDescriptor(e, k); - Object.defineProperty(n, k, d.get ? d : { - enumerable: true, - get: function () { - return e[k]; - } - }); - } - }); - } - n['default'] = e; - return Object.freeze(n); -} - -Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(external.join('a', 'b'))); }); +import(external.join('a', 'b')); console.log(external.join); diff --git a/test/form/samples/import-expression/_expected/iife.js b/test/form/samples/import-expression/_expected/iife.js index 54270fe7ccd..d97655336d9 100644 --- a/test/form/samples/import-expression/_expected/iife.js +++ b/test/form/samples/import-expression/_expected/iife.js @@ -4,4 +4,4 @@ import(external.join('a', 'b')); console.log(external.join); -}(external)); +})(external); diff --git a/test/form/samples/import-expression/_expected/system.js b/test/form/samples/import-expression/_expected/system.js index 89ed58a9db0..ea9aa2a765d 100644 --- a/test/form/samples/import-expression/_expected/system.js +++ b/test/form/samples/import-expression/_expected/system.js @@ -1,15 +1,15 @@ -System.register(['external'], function (exports, module) { +System.register(['external'], (function (exports, module) { 'use strict'; var join; return { setters: [function (module) { join = module.join; }], - execute: function () { + execute: (function () { module.import(join('a', 'b')); console.log(join); - } + }) }; -}); +})); diff --git a/test/form/samples/import-expression/_expected/umd.js b/test/form/samples/import-expression/_expected/umd.js index aa6214a28b3..1780e9bccdd 100644 --- a/test/form/samples/import-expression/_expected/umd.js +++ b/test/form/samples/import-expression/_expected/umd.js @@ -2,9 +2,9 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('external')) : typeof define === 'function' && define.amd ? define(['external'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.external)); -}(this, (function (external) { 'use strict'; +})(this, (function (external) { 'use strict'; import(external.join('a', 'b')); console.log(external.join); -}))); +})); diff --git a/test/form/samples/import-external-namespace-and-default/_config.js b/test/form/samples/import-external-namespace-and-default/_config.js index b6823ebd061..b2346601267 100644 --- a/test/form/samples/import-external-namespace-and-default/_config.js +++ b/test/form/samples/import-external-namespace-and-default/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'disinguishes between external default and namespace (#637)', options: { external: ['foo'], @@ -6,4 +6,4 @@ module.exports = { globals: { foo: 'foo' } } } -}; +}); diff --git a/test/form/samples/import-external-namespace-and-default/_expected/amd.js b/test/form/samples/import-external-namespace-and-default/_expected/amd.js index 28798499acb..61835687399 100644 --- a/test/form/samples/import-external-namespace-and-default/_expected/amd.js +++ b/test/form/samples/import-external-namespace-and-default/_expected/amd.js @@ -1,9 +1,6 @@ -define(['foo'], function (foo) { 'use strict'; +define(['foo'], (function (foo) { 'use strict'; - function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } - - function _interopNamespace(e) { - if (e && e.__esModule) return e; + function _interopNamespaceDefault(e) { var n = Object.create(null); if (e) { Object.keys(e).forEach(function (k) { @@ -11,22 +8,19 @@ define(['foo'], function (foo) { 'use strict'; var d = Object.getOwnPropertyDescriptor(e, k); Object.defineProperty(n, k, d.get ? d : { enumerable: true, - get: function () { - return e[k]; - } + get: function () { return e[k]; } }); } }); } - n['default'] = e; + n.default = e; return Object.freeze(n); } - var foo__namespace = /*#__PURE__*/_interopNamespace(foo); - var foo__default = /*#__PURE__*/_interopDefaultLegacy(foo); + var foo__namespace = /*#__PURE__*/_interopNamespaceDefault(foo); console.log( foo__namespace.bar ); - console.log( foo__default['default'] ); + console.log( foo ); -}); +})); diff --git a/test/form/samples/import-external-namespace-and-default/_expected/cjs.js b/test/form/samples/import-external-namespace-and-default/_expected/cjs.js index 9afd83e0227..a87e8e98b7d 100644 --- a/test/form/samples/import-external-namespace-and-default/_expected/cjs.js +++ b/test/form/samples/import-external-namespace-and-default/_expected/cjs.js @@ -2,10 +2,7 @@ var foo = require('foo'); -function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } - -function _interopNamespace(e) { - if (e && e.__esModule) return e; +function _interopNamespaceDefault(e) { var n = Object.create(null); if (e) { Object.keys(e).forEach(function (k) { @@ -13,20 +10,17 @@ function _interopNamespace(e) { var d = Object.getOwnPropertyDescriptor(e, k); Object.defineProperty(n, k, d.get ? d : { enumerable: true, - get: function () { - return e[k]; - } + get: function () { return e[k]; } }); } }); } - n['default'] = e; + n.default = e; return Object.freeze(n); } -var foo__namespace = /*#__PURE__*/_interopNamespace(foo); -var foo__default = /*#__PURE__*/_interopDefaultLegacy(foo); +var foo__namespace = /*#__PURE__*/_interopNamespaceDefault(foo); console.log( foo__namespace.bar ); -console.log( foo__default['default'] ); +console.log( foo ); diff --git a/test/form/samples/import-external-namespace-and-default/_expected/iife.js b/test/form/samples/import-external-namespace-and-default/_expected/iife.js index eedaf597795..c8b2179cde3 100644 --- a/test/form/samples/import-external-namespace-and-default/_expected/iife.js +++ b/test/form/samples/import-external-namespace-and-default/_expected/iife.js @@ -1,10 +1,7 @@ (function (foo) { 'use strict'; - function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } - - function _interopNamespace(e) { - if (e && e.__esModule) return e; + function _interopNamespaceDefault(e) { var n = Object.create(null); if (e) { Object.keys(e).forEach(function (k) { @@ -12,22 +9,19 @@ var d = Object.getOwnPropertyDescriptor(e, k); Object.defineProperty(n, k, d.get ? d : { enumerable: true, - get: function () { - return e[k]; - } + get: function () { return e[k]; } }); } }); } - n['default'] = e; + n.default = e; return Object.freeze(n); } - var foo__namespace = /*#__PURE__*/_interopNamespace(foo); - var foo__default = /*#__PURE__*/_interopDefaultLegacy(foo); + var foo__namespace = /*#__PURE__*/_interopNamespaceDefault(foo); console.log( foo__namespace.bar ); - console.log( foo__default['default'] ); + console.log( foo ); -}(foo)); +})(foo); diff --git a/test/form/samples/import-external-namespace-and-default/_expected/system.js b/test/form/samples/import-external-namespace-and-default/_expected/system.js index e5cbc1b3094..3dd4c33ab22 100644 --- a/test/form/samples/import-external-namespace-and-default/_expected/system.js +++ b/test/form/samples/import-external-namespace-and-default/_expected/system.js @@ -1,4 +1,4 @@ -System.register(['foo'], function () { +System.register(['foo'], (function () { 'use strict'; var foo, foo__default; return { @@ -6,12 +6,12 @@ System.register(['foo'], function () { foo = module; foo__default = module.default; }], - execute: function () { + execute: (function () { console.log( foo.bar ); console.log( foo__default ); - } + }) }; -}); +})); diff --git a/test/form/samples/import-external-namespace-and-default/_expected/umd.js b/test/form/samples/import-external-namespace-and-default/_expected/umd.js index 42458000e2d..16e31de8fd9 100644 --- a/test/form/samples/import-external-namespace-and-default/_expected/umd.js +++ b/test/form/samples/import-external-namespace-and-default/_expected/umd.js @@ -2,12 +2,9 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('foo')) : typeof define === 'function' && define.amd ? define(['foo'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.foo)); -}(this, (function (foo) { 'use strict'; +})(this, (function (foo) { 'use strict'; - function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } - - function _interopNamespace(e) { - if (e && e.__esModule) return e; + function _interopNamespaceDefault(e) { var n = Object.create(null); if (e) { Object.keys(e).forEach(function (k) { @@ -15,22 +12,19 @@ var d = Object.getOwnPropertyDescriptor(e, k); Object.defineProperty(n, k, d.get ? d : { enumerable: true, - get: function () { - return e[k]; - } + get: function () { return e[k]; } }); } }); } - n['default'] = e; + n.default = e; return Object.freeze(n); } - var foo__namespace = /*#__PURE__*/_interopNamespace(foo); - var foo__default = /*#__PURE__*/_interopDefaultLegacy(foo); + var foo__namespace = /*#__PURE__*/_interopNamespaceDefault(foo); console.log( foo__namespace.bar ); - console.log( foo__default['default'] ); + console.log( foo ); -}))); +})); diff --git a/test/form/samples/import-meta-resolve/_config.js b/test/form/samples/import-meta-resolve/_config.js index aba00ef3ded..ec452a28ec0 100644 --- a/test/form/samples/import-meta-resolve/_config.js +++ b/test/form/samples/import-meta-resolve/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'supports import.meta.resolve' -}; +}); diff --git a/test/form/samples/import-meta-resolve/_expected/amd.js b/test/form/samples/import-meta-resolve/_expected/amd.js index b5156ab0be7..506c2c92f53 100644 --- a/test/form/samples/import-meta-resolve/_expected/amd.js +++ b/test/form/samples/import-meta-resolve/_expected/amd.js @@ -1,5 +1,5 @@ -define(['module'], function (module) { 'use strict'; +define(['module'], (function (module) { 'use strict'; undefined('./foo.js'); -}); +})); diff --git a/test/form/samples/import-meta-resolve/_expected/iife.js b/test/form/samples/import-meta-resolve/_expected/iife.js index 902be78fdce..283388ca905 100644 --- a/test/form/samples/import-meta-resolve/_expected/iife.js +++ b/test/form/samples/import-meta-resolve/_expected/iife.js @@ -3,4 +3,4 @@ undefined('./foo.js'); -}()); +})(); diff --git a/test/form/samples/import-meta-resolve/_expected/system.js b/test/form/samples/import-meta-resolve/_expected/system.js index 9712e5d98d3..efe2617bf87 100644 --- a/test/form/samples/import-meta-resolve/_expected/system.js +++ b/test/form/samples/import-meta-resolve/_expected/system.js @@ -1,10 +1,10 @@ -System.register([], function (exports, module) { +System.register([], (function (exports, module) { 'use strict'; return { - execute: function () { + execute: (function () { module.meta.resolve('./foo.js'); - } + }) }; -}); +})); diff --git a/test/form/samples/import-meta-resolve/_expected/umd.js b/test/form/samples/import-meta-resolve/_expected/umd.js index b176c944f93..f3a44fe2bf8 100644 --- a/test/form/samples/import-meta-resolve/_expected/umd.js +++ b/test/form/samples/import-meta-resolve/_expected/umd.js @@ -1,8 +1,8 @@ (function (factory) { typeof define === 'function' && define.amd ? define(factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; undefined('./foo.js'); -}))); +})); diff --git a/test/form/samples/import-meta-url/_config.js b/test/form/samples/import-meta-url/_config.js index 7acc8dce0e5..4a331c30c54 100644 --- a/test/form/samples/import-meta-url/_config.js +++ b/test/form/samples/import-meta-url/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'supports import.meta.url' -}; +}); diff --git a/test/form/samples/import-meta-url/_expected/amd.js b/test/form/samples/import-meta-url/_expected/amd.js index 3ea98d3db9b..ea090ed42c7 100644 --- a/test/form/samples/import-meta-url/_expected/amd.js +++ b/test/form/samples/import-meta-url/_expected/amd.js @@ -1,4 +1,4 @@ -define(['module'], function (module) { 'use strict'; +define(['module'], (function (module) { 'use strict'; function log(url) { if (typeof document === 'undefined') { @@ -10,4 +10,4 @@ define(['module'], function (module) { 'use strict'; log(new URL(module.uri, document.baseURI).href); -}); +})); diff --git a/test/form/samples/import-meta-url/_expected/cjs.js b/test/form/samples/import-meta-url/_expected/cjs.js index 58fb168b483..627bdaafb55 100644 --- a/test/form/samples/import-meta-url/_expected/cjs.js +++ b/test/form/samples/import-meta-url/_expected/cjs.js @@ -1,5 +1,6 @@ 'use strict'; +var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null; function log(url) { if (typeof document === 'undefined') { console.log(url); @@ -8,4 +9,4 @@ function log(url) { } } -log((typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('cjs.js', document.baseURI).href))); +log((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cjs.js', document.baseURI).href))); diff --git a/test/form/samples/import-meta-url/_expected/iife.js b/test/form/samples/import-meta-url/_expected/iife.js index 2ceafdeef6b..78e89b6f5a5 100644 --- a/test/form/samples/import-meta-url/_expected/iife.js +++ b/test/form/samples/import-meta-url/_expected/iife.js @@ -1,6 +1,7 @@ (function () { 'use strict'; + var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null; function log(url) { if (typeof document === 'undefined') { console.log(url); @@ -9,6 +10,6 @@ } } - log((document.currentScript && document.currentScript.src || new URL('iife.js', document.baseURI).href)); + log((_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('iife.js', document.baseURI).href)); -}()); +})(); diff --git a/test/form/samples/import-meta-url/_expected/system.js b/test/form/samples/import-meta-url/_expected/system.js index 85f9c9532f7..97a185e78e3 100644 --- a/test/form/samples/import-meta-url/_expected/system.js +++ b/test/form/samples/import-meta-url/_expected/system.js @@ -1,7 +1,7 @@ -System.register([], function (exports, module) { +System.register([], (function (exports, module) { 'use strict'; return { - execute: function () { + execute: (function () { function log(url) { if (typeof document === 'undefined') { @@ -13,6 +13,6 @@ System.register([], function (exports, module) { log(module.meta.url); - } + }) }; -}); +})); diff --git a/test/form/samples/import-meta-url/_expected/umd.js b/test/form/samples/import-meta-url/_expected/umd.js index 31f722ed30b..16bfbc0c7d9 100644 --- a/test/form/samples/import-meta-url/_expected/umd.js +++ b/test/form/samples/import-meta-url/_expected/umd.js @@ -1,8 +1,9 @@ (function (factory) { typeof define === 'function' && define.amd ? define(factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; + var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null; function log(url) { if (typeof document === 'undefined') { console.log(url); @@ -11,6 +12,6 @@ } } - log((typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('umd.js', document.baseURI).href))); + log((typeof document === 'undefined' && typeof location === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : typeof document === 'undefined' ? location.href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('umd.js', document.baseURI).href))); -}))); +})); diff --git a/test/form/samples/import-meta/_config.js b/test/form/samples/import-meta/_config.js index 0475fdfdf7c..e44c1592c0d 100644 --- a/test/form/samples/import-meta/_config.js +++ b/test/form/samples/import-meta/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'supports directly accessing import.meta' -}; +}); diff --git a/test/form/samples/import-meta/_expected/amd.js b/test/form/samples/import-meta/_expected/amd.js index eb0d3dbf1fc..933569fc33b 100644 --- a/test/form/samples/import-meta/_expected/amd.js +++ b/test/form/samples/import-meta/_expected/amd.js @@ -1,5 +1,5 @@ -define(['module'], function (module) { 'use strict'; +define(['module'], (function (module) { 'use strict'; console.log(({ url: new URL(module.uri, document.baseURI).href })); -}); +})); diff --git a/test/form/samples/import-meta/_expected/cjs.js b/test/form/samples/import-meta/_expected/cjs.js index 94e7ab87a9a..e9237dfc42d 100644 --- a/test/form/samples/import-meta/_expected/cjs.js +++ b/test/form/samples/import-meta/_expected/cjs.js @@ -1,3 +1,4 @@ 'use strict'; -console.log(({ url: (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('cjs.js', document.baseURI).href)) })); +var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null; +console.log(({ url: (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cjs.js', document.baseURI).href)) })); diff --git a/test/form/samples/import-meta/_expected/iife.js b/test/form/samples/import-meta/_expected/iife.js index 8e30453792d..fb1536378da 100644 --- a/test/form/samples/import-meta/_expected/iife.js +++ b/test/form/samples/import-meta/_expected/iife.js @@ -1,6 +1,7 @@ (function () { 'use strict'; - console.log(({ url: (document.currentScript && document.currentScript.src || new URL('iife.js', document.baseURI).href) })); + var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null; + console.log(({ url: (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('iife.js', document.baseURI).href) })); -}()); +})(); diff --git a/test/form/samples/import-meta/_expected/system.js b/test/form/samples/import-meta/_expected/system.js index bf12e3c7997..feb9132ef0c 100644 --- a/test/form/samples/import-meta/_expected/system.js +++ b/test/form/samples/import-meta/_expected/system.js @@ -1,10 +1,10 @@ -System.register([], function (exports, module) { +System.register([], (function (exports, module) { 'use strict'; return { - execute: function () { + execute: (function () { console.log(module.meta); - } + }) }; -}); +})); diff --git a/test/form/samples/import-meta/_expected/umd.js b/test/form/samples/import-meta/_expected/umd.js index 56d3917be05..7d52eac886b 100644 --- a/test/form/samples/import-meta/_expected/umd.js +++ b/test/form/samples/import-meta/_expected/umd.js @@ -1,8 +1,9 @@ (function (factory) { typeof define === 'function' && define.amd ? define(factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; - console.log(({ url: (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('umd.js', document.baseURI).href)) })); + var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null; + console.log(({ url: (typeof document === 'undefined' && typeof location === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : typeof document === 'undefined' ? location.href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('umd.js', document.baseURI).href)) })); -}))); +})); diff --git a/test/form/samples/import-named-exported-global-with-alias/_config.js b/test/form/samples/import-named-exported-global-with-alias/_config.js index 3ed95b58d27..ed0df9a0354 100644 --- a/test/form/samples/import-named-exported-global-with-alias/_config.js +++ b/test/form/samples/import-named-exported-global-with-alias/_config.js @@ -1,8 +1,5 @@ -// Changed due to https://github.com/acornjs/acorn/issues/806 -// Consider reverting this change should this become an acorn option - -module.exports = { +module.exports = defineTest({ description: 'allow globals to be exported and imported', expectedWarnings: ['EMPTY_BUNDLE'], options: { output: { name: 'doc' } } -}; +}); diff --git a/test/form/samples/import-namespace-systemjs/_config.js b/test/form/samples/import-namespace-systemjs/_config.js index 1708f21cd7a..5fc7ae30401 100644 --- a/test/form/samples/import-namespace-systemjs/_config.js +++ b/test/form/samples/import-namespace-systemjs/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'imports namespace (systemjs only)', options: { external: ['dependency'], @@ -6,4 +6,4 @@ module.exports = { format: 'system' } } -}; +}); diff --git a/test/form/samples/import-namespace-systemjs/_expected.js b/test/form/samples/import-namespace-systemjs/_expected.js index bf9cf083af3..06533e7c576 100644 --- a/test/form/samples/import-namespace-systemjs/_expected.js +++ b/test/form/samples/import-namespace-systemjs/_expected.js @@ -1,14 +1,14 @@ -System.register(['dependency'], function () { +System.register(['dependency'], (function () { 'use strict'; var dependency; return { setters: [function (module) { dependency = module; }], - execute: function () { + execute: (function () { console.log(dependency); - } + }) }; -}); +})); diff --git a/test/form/samples/import-namespace/_config.js b/test/form/samples/import-namespace/_config.js index 2cd57f110ff..abd8444309d 100644 --- a/test/form/samples/import-namespace/_config.js +++ b/test/form/samples/import-namespace/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'imports external namespaces', options: { external: ['foo', 'bar'], @@ -6,4 +6,4 @@ module.exports = { globals: { foo: 'foo', bar: 'bar' } } } -}; +}); diff --git a/test/form/samples/import-namespace/_expected/amd.js b/test/form/samples/import-namespace/_expected/amd.js index 1263372b7e1..4ca4e92e3e2 100644 --- a/test/form/samples/import-namespace/_expected/amd.js +++ b/test/form/samples/import-namespace/_expected/amd.js @@ -1,7 +1,6 @@ -define(['foo', 'bar'], function (foo, bar) { 'use strict'; +define(['foo', 'bar'], (function (foo, bar) { 'use strict'; - function _interopNamespace(e) { - if (e && e.__esModule) return e; + function _interopNamespaceDefault(e) { var n = Object.create(null); if (e) { Object.keys(e).forEach(function (k) { @@ -9,21 +8,19 @@ define(['foo', 'bar'], function (foo, bar) { 'use strict'; var d = Object.getOwnPropertyDescriptor(e, k); Object.defineProperty(n, k, d.get ? d : { enumerable: true, - get: function () { - return e[k]; - } + get: function () { return e[k]; } }); } }); } - n['default'] = e; + n.default = e; return Object.freeze(n); } - var foo__namespace = /*#__PURE__*/_interopNamespace(foo); - var bar__namespace = /*#__PURE__*/_interopNamespace(bar); + var foo__namespace = /*#__PURE__*/_interopNamespaceDefault(foo); + var bar__namespace = /*#__PURE__*/_interopNamespaceDefault(bar); foo__namespace.x(); console.log(bar__namespace); -}); +})); diff --git a/test/form/samples/import-namespace/_expected/cjs.js b/test/form/samples/import-namespace/_expected/cjs.js index 6c8ca325ace..fc036591852 100644 --- a/test/form/samples/import-namespace/_expected/cjs.js +++ b/test/form/samples/import-namespace/_expected/cjs.js @@ -3,8 +3,7 @@ var foo = require('foo'); var bar = require('bar'); -function _interopNamespace(e) { - if (e && e.__esModule) return e; +function _interopNamespaceDefault(e) { var n = Object.create(null); if (e) { Object.keys(e).forEach(function (k) { @@ -12,19 +11,17 @@ function _interopNamespace(e) { var d = Object.getOwnPropertyDescriptor(e, k); Object.defineProperty(n, k, d.get ? d : { enumerable: true, - get: function () { - return e[k]; - } + get: function () { return e[k]; } }); } }); } - n['default'] = e; + n.default = e; return Object.freeze(n); } -var foo__namespace = /*#__PURE__*/_interopNamespace(foo); -var bar__namespace = /*#__PURE__*/_interopNamespace(bar); +var foo__namespace = /*#__PURE__*/_interopNamespaceDefault(foo); +var bar__namespace = /*#__PURE__*/_interopNamespaceDefault(bar); foo__namespace.x(); console.log(bar__namespace); diff --git a/test/form/samples/import-namespace/_expected/iife.js b/test/form/samples/import-namespace/_expected/iife.js index 8fa0de2f166..e1c6cd61b7e 100644 --- a/test/form/samples/import-namespace/_expected/iife.js +++ b/test/form/samples/import-namespace/_expected/iife.js @@ -1,8 +1,7 @@ (function (foo, bar) { 'use strict'; - function _interopNamespace(e) { - if (e && e.__esModule) return e; + function _interopNamespaceDefault(e) { var n = Object.create(null); if (e) { Object.keys(e).forEach(function (k) { @@ -10,21 +9,19 @@ var d = Object.getOwnPropertyDescriptor(e, k); Object.defineProperty(n, k, d.get ? d : { enumerable: true, - get: function () { - return e[k]; - } + get: function () { return e[k]; } }); } }); } - n['default'] = e; + n.default = e; return Object.freeze(n); } - var foo__namespace = /*#__PURE__*/_interopNamespace(foo); - var bar__namespace = /*#__PURE__*/_interopNamespace(bar); + var foo__namespace = /*#__PURE__*/_interopNamespaceDefault(foo); + var bar__namespace = /*#__PURE__*/_interopNamespaceDefault(bar); foo__namespace.x(); console.log(bar__namespace); -}(foo, bar)); +})(foo, bar); diff --git a/test/form/samples/import-namespace/_expected/system.js b/test/form/samples/import-namespace/_expected/system.js index f26486109a1..a623e44a868 100644 --- a/test/form/samples/import-namespace/_expected/system.js +++ b/test/form/samples/import-namespace/_expected/system.js @@ -1,4 +1,4 @@ -System.register(['foo', 'bar'], function () { +System.register(['foo', 'bar'], (function () { 'use strict'; var foo, bar; return { @@ -7,11 +7,11 @@ System.register(['foo', 'bar'], function () { }, function (module) { bar = module; }], - execute: function () { + execute: (function () { foo.x(); console.log(bar); - } + }) }; -}); +})); diff --git a/test/form/samples/import-namespace/_expected/umd.js b/test/form/samples/import-namespace/_expected/umd.js index f0436e49663..cf37bab5994 100644 --- a/test/form/samples/import-namespace/_expected/umd.js +++ b/test/form/samples/import-namespace/_expected/umd.js @@ -2,10 +2,9 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('foo'), require('bar')) : typeof define === 'function' && define.amd ? define(['foo', 'bar'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.foo, global.bar)); -}(this, (function (foo, bar) { 'use strict'; +})(this, (function (foo, bar) { 'use strict'; - function _interopNamespace(e) { - if (e && e.__esModule) return e; + function _interopNamespaceDefault(e) { var n = Object.create(null); if (e) { Object.keys(e).forEach(function (k) { @@ -13,21 +12,19 @@ var d = Object.getOwnPropertyDescriptor(e, k); Object.defineProperty(n, k, d.get ? d : { enumerable: true, - get: function () { - return e[k]; - } + get: function () { return e[k]; } }); } }); } - n['default'] = e; + n.default = e; return Object.freeze(n); } - var foo__namespace = /*#__PURE__*/_interopNamespace(foo); - var bar__namespace = /*#__PURE__*/_interopNamespace(bar); + var foo__namespace = /*#__PURE__*/_interopNamespaceDefault(foo); + var bar__namespace = /*#__PURE__*/_interopNamespaceDefault(bar); foo__namespace.x(); console.log(bar__namespace); -}))); +})); diff --git a/test/form/samples/import-specifier-deshadowing/_config.js b/test/form/samples/import-specifier-deshadowing/_config.js index 26457a50db3..eb4603a66f3 100644 --- a/test/form/samples/import-specifier-deshadowing/_config.js +++ b/test/form/samples/import-specifier-deshadowing/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'deshadows aliased import bindings', options: { external: ['react-sticky'], @@ -7,4 +7,4 @@ module.exports = { name: 'Sticky' } } -}; +}); diff --git a/test/form/samples/import-specifier-deshadowing/_expected/amd.js b/test/form/samples/import-specifier-deshadowing/_expected/amd.js index 6d5e92100dd..661c8159480 100644 --- a/test/form/samples/import-specifier-deshadowing/_expected/amd.js +++ b/test/form/samples/import-specifier-deshadowing/_expected/amd.js @@ -1,4 +1,4 @@ -define(['react-sticky'], function (reactSticky) { 'use strict'; +define(['react-sticky'], (function (reactSticky) { 'use strict'; var Sticky = function () { function Sticky() {} @@ -10,4 +10,4 @@ define(['react-sticky'], function (reactSticky) { 'use strict'; return Sticky; -}); +})); diff --git a/test/form/samples/import-specifier-deshadowing/_expected/es.js b/test/form/samples/import-specifier-deshadowing/_expected/es.js index 9cfd965e950..2ae42d3f88e 100644 --- a/test/form/samples/import-specifier-deshadowing/_expected/es.js +++ b/test/form/samples/import-specifier-deshadowing/_expected/es.js @@ -8,4 +8,4 @@ var Sticky = function () { return Sticky; }(); -export default Sticky; +export { Sticky as default }; diff --git a/test/form/samples/import-specifier-deshadowing/_expected/iife.js b/test/form/samples/import-specifier-deshadowing/_expected/iife.js index debcd23f1a9..0bb51c713f3 100644 --- a/test/form/samples/import-specifier-deshadowing/_expected/iife.js +++ b/test/form/samples/import-specifier-deshadowing/_expected/iife.js @@ -11,4 +11,4 @@ var Sticky = (function (reactSticky) { return Sticky; -}(reactSticky)); +})(reactSticky); diff --git a/test/form/samples/import-specifier-deshadowing/_expected/system.js b/test/form/samples/import-specifier-deshadowing/_expected/system.js index 0838a092911..cbc06f65231 100644 --- a/test/form/samples/import-specifier-deshadowing/_expected/system.js +++ b/test/form/samples/import-specifier-deshadowing/_expected/system.js @@ -1,13 +1,13 @@ -System.register('Sticky', ['react-sticky'], function (exports) { +System.register('Sticky', ['react-sticky'], (function (exports) { 'use strict'; var Sticky$1; return { setters: [function (module) { Sticky$1 = module.Sticky; }], - execute: function () { + execute: (function () { - var Sticky = exports('default', function () { + var Sticky = exports("default", function () { function Sticky() {} Sticky.foo = Sticky$1; @@ -15,6 +15,6 @@ System.register('Sticky', ['react-sticky'], function (exports) { return Sticky; }()); - } + }) }; -}); +})); diff --git a/test/form/samples/import-specifier-deshadowing/_expected/umd.js b/test/form/samples/import-specifier-deshadowing/_expected/umd.js index 3e5baacc22c..5c993c955d4 100644 --- a/test/form/samples/import-specifier-deshadowing/_expected/umd.js +++ b/test/form/samples/import-specifier-deshadowing/_expected/umd.js @@ -2,7 +2,7 @@ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('react-sticky')) : typeof define === 'function' && define.amd ? define(['react-sticky'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Sticky = factory(global.reactSticky)); -}(this, (function (reactSticky) { 'use strict'; +})(this, (function (reactSticky) { 'use strict'; var Sticky = function () { function Sticky() {} @@ -14,4 +14,4 @@ return Sticky; -}))); +})); diff --git a/test/form/samples/include-recursive-call-arguments/_config.js b/test/form/samples/include-recursive-call-arguments/_config.js index 5944997b49f..5e5931e99ec 100644 --- a/test/form/samples/include-recursive-call-arguments/_config.js +++ b/test/form/samples/include-recursive-call-arguments/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'handles recursive declarations' -}; +}); diff --git a/test/form/samples/includes-all-namespace-declarations/_config.js b/test/form/samples/includes-all-namespace-declarations/_config.js index afd3cf26746..a0c51a54418 100644 --- a/test/form/samples/includes-all-namespace-declarations/_config.js +++ b/test/form/samples/includes-all-namespace-declarations/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'includes all declarations referenced by reified namespaces', expectedWarnings: ['EMPTY_BUNDLE'] -}; +}); diff --git a/test/form/samples/includes-all-namespace-declarations/_expected/amd.js b/test/form/samples/includes-all-namespace-declarations/_expected/amd.js index f9f8229aa40..a9e9419e212 100644 --- a/test/form/samples/includes-all-namespace-declarations/_expected/amd.js +++ b/test/form/samples/includes-all-namespace-declarations/_expected/amd.js @@ -1,5 +1,5 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; -}); +})); diff --git a/test/form/samples/includes-all-namespace-declarations/_expected/iife.js b/test/form/samples/includes-all-namespace-declarations/_expected/iife.js index 43ef5426880..31dfeb95ed9 100644 --- a/test/form/samples/includes-all-namespace-declarations/_expected/iife.js +++ b/test/form/samples/includes-all-namespace-declarations/_expected/iife.js @@ -3,4 +3,4 @@ -}()); +})(); diff --git a/test/form/samples/includes-all-namespace-declarations/_expected/system.js b/test/form/samples/includes-all-namespace-declarations/_expected/system.js index a702f2b06ef..343cc3a5100 100644 --- a/test/form/samples/includes-all-namespace-declarations/_expected/system.js +++ b/test/form/samples/includes-all-namespace-declarations/_expected/system.js @@ -1,10 +1,10 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { - } + }) }; -}); +})); diff --git a/test/form/samples/includes-all-namespace-declarations/_expected/umd.js b/test/form/samples/includes-all-namespace-declarations/_expected/umd.js index 8bf6301d469..a39fba4f3da 100644 --- a/test/form/samples/includes-all-namespace-declarations/_expected/umd.js +++ b/test/form/samples/includes-all-namespace-declarations/_expected/umd.js @@ -1,8 +1,8 @@ (function (factory) { typeof define === 'function' && define.amd ? define(factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; -}))); +})); diff --git a/test/form/samples/indent-false/_config.js b/test/form/samples/indent-false/_config.js index 869d6498ed7..163c898084f 100644 --- a/test/form/samples/indent-false/_config.js +++ b/test/form/samples/indent-false/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'does not indent with indent: false', options: { output: { @@ -6,4 +6,4 @@ module.exports = { indent: false } } -}; +}); diff --git a/test/form/samples/indent-false/_expected/amd.js b/test/form/samples/indent-false/_expected/amd.js index 2ef21fb3c94..01b9bef0fcd 100644 --- a/test/form/samples/indent-false/_expected/amd.js +++ b/test/form/samples/indent-false/_expected/amd.js @@ -1,4 +1,4 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; function foo () { console.log( 'not indented' ); @@ -6,4 +6,4 @@ function foo () { return foo; -}); +})); diff --git a/test/form/samples/indent-false/_expected/es.js b/test/form/samples/indent-false/_expected/es.js index 2710c80e469..7232a6b2644 100644 --- a/test/form/samples/indent-false/_expected/es.js +++ b/test/form/samples/indent-false/_expected/es.js @@ -2,4 +2,4 @@ function foo () { console.log( 'not indented' ); } -export default foo; +export { foo as default }; diff --git a/test/form/samples/indent-false/_expected/iife.js b/test/form/samples/indent-false/_expected/iife.js index 0b46c842f63..7c717311d25 100644 --- a/test/form/samples/indent-false/_expected/iife.js +++ b/test/form/samples/indent-false/_expected/iife.js @@ -7,4 +7,4 @@ function foo () { return foo; -}()); +})(); diff --git a/test/form/samples/indent-false/_expected/system.js b/test/form/samples/indent-false/_expected/system.js index d33c79d42ef..91899d41e03 100644 --- a/test/form/samples/indent-false/_expected/system.js +++ b/test/form/samples/indent-false/_expected/system.js @@ -1,14 +1,14 @@ -System.register('foo', [], function (exports) { +System.register('foo', [], (function (exports) { 'use strict'; return { -execute: function () { +execute: (function () { -exports('default', foo); +exports("default", foo); function foo () { console.log( 'not indented' ); } -} +}) }; -}); +})); diff --git a/test/form/samples/indent-false/_expected/umd.js b/test/form/samples/indent-false/_expected/umd.js index e68634f726c..34d33d99b7d 100644 --- a/test/form/samples/indent-false/_expected/umd.js +++ b/test/form/samples/indent-false/_expected/umd.js @@ -2,7 +2,7 @@ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.foo = factory()); -}(this, (function () { 'use strict'; +})(this, (function () { 'use strict'; function foo () { console.log( 'not indented' ); @@ -10,4 +10,4 @@ function foo () { return foo; -}))); +})); diff --git a/test/form/samples/indent-spaces/_config.js b/test/form/samples/indent-spaces/_config.js index b49bec76a0d..cc9b301eca6 100644 --- a/test/form/samples/indent-spaces/_config.js +++ b/test/form/samples/indent-spaces/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'auto-indents with indent: true', options: { output: { @@ -6,4 +6,4 @@ module.exports = { indent: ' ' } } -}; +}); diff --git a/test/form/samples/indent-spaces/_expected/amd.js b/test/form/samples/indent-spaces/_expected/amd.js index 445c02f07d4..be2404bff0a 100644 --- a/test/form/samples/indent-spaces/_expected/amd.js +++ b/test/form/samples/indent-spaces/_expected/amd.js @@ -1,4 +1,4 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; function foo () { console.log( 'indented with tabs' ); @@ -6,4 +6,4 @@ define(function () { 'use strict'; return foo; -}); +})); diff --git a/test/form/samples/indent-spaces/_expected/es.js b/test/form/samples/indent-spaces/_expected/es.js index d4b23ef94cd..c141611cbbb 100644 --- a/test/form/samples/indent-spaces/_expected/es.js +++ b/test/form/samples/indent-spaces/_expected/es.js @@ -2,4 +2,4 @@ function foo () { console.log( 'indented with tabs' ); } -export default foo; +export { foo as default }; diff --git a/test/form/samples/indent-spaces/_expected/iife.js b/test/form/samples/indent-spaces/_expected/iife.js index f83141cbed0..535b6306beb 100644 --- a/test/form/samples/indent-spaces/_expected/iife.js +++ b/test/form/samples/indent-spaces/_expected/iife.js @@ -7,4 +7,4 @@ var foo = (function () { return foo; -}()); +})(); diff --git a/test/form/samples/indent-spaces/_expected/system.js b/test/form/samples/indent-spaces/_expected/system.js index 982f2203547..d99f09f1dea 100644 --- a/test/form/samples/indent-spaces/_expected/system.js +++ b/test/form/samples/indent-spaces/_expected/system.js @@ -1,14 +1,14 @@ -System.register('foo', [], function (exports) { +System.register('foo', [], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - exports('default', foo); + exports("default", foo); function foo () { console.log( 'indented with tabs' ); } - } + }) }; -}); +})); diff --git a/test/form/samples/indent-spaces/_expected/umd.js b/test/form/samples/indent-spaces/_expected/umd.js index 2aedd26baa8..34d83551dc2 100644 --- a/test/form/samples/indent-spaces/_expected/umd.js +++ b/test/form/samples/indent-spaces/_expected/umd.js @@ -2,7 +2,7 @@ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.foo = factory()); -}(this, (function () { 'use strict'; +})(this, (function () { 'use strict'; function foo () { console.log( 'indented with tabs' ); @@ -10,4 +10,4 @@ return foo; -}))); +})); diff --git a/test/form/samples/indent-true-spaces/_config.js b/test/form/samples/indent-true-spaces/_config.js index c78911da9ec..a06b41859d6 100644 --- a/test/form/samples/indent-true-spaces/_config.js +++ b/test/form/samples/indent-true-spaces/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'auto-indents with spaces and indent: true', options: { output: { @@ -6,4 +6,4 @@ module.exports = { indent: true } } -}; +}); diff --git a/test/form/samples/indent-true-spaces/_expected/amd.js b/test/form/samples/indent-true-spaces/_expected/amd.js index 2210188f45b..4789bdbe5fd 100644 --- a/test/form/samples/indent-true-spaces/_expected/amd.js +++ b/test/form/samples/indent-true-spaces/_expected/amd.js @@ -1,4 +1,4 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; function foo () { console.log( 'indented with spaces' ); @@ -6,4 +6,4 @@ define(function () { 'use strict'; return foo; -}); +})); diff --git a/test/form/samples/indent-true-spaces/_expected/es.js b/test/form/samples/indent-true-spaces/_expected/es.js index 3263bb6425b..b31c3b61edd 100644 --- a/test/form/samples/indent-true-spaces/_expected/es.js +++ b/test/form/samples/indent-true-spaces/_expected/es.js @@ -2,4 +2,4 @@ function foo () { console.log( 'indented with spaces' ); } -export default foo; +export { foo as default }; diff --git a/test/form/samples/indent-true-spaces/_expected/iife.js b/test/form/samples/indent-true-spaces/_expected/iife.js index e22164fdd56..36a7c27f7d6 100644 --- a/test/form/samples/indent-true-spaces/_expected/iife.js +++ b/test/form/samples/indent-true-spaces/_expected/iife.js @@ -7,4 +7,4 @@ var foo = (function () { return foo; -}()); +})(); diff --git a/test/form/samples/indent-true-spaces/_expected/system.js b/test/form/samples/indent-true-spaces/_expected/system.js index 399f876f681..9915aad42c7 100644 --- a/test/form/samples/indent-true-spaces/_expected/system.js +++ b/test/form/samples/indent-true-spaces/_expected/system.js @@ -1,14 +1,14 @@ -System.register('foo', [], function (exports) { +System.register('foo', [], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - exports('default', foo); + exports("default", foo); function foo () { console.log( 'indented with spaces' ); } - } + }) }; -}); +})); diff --git a/test/form/samples/indent-true-spaces/_expected/umd.js b/test/form/samples/indent-true-spaces/_expected/umd.js index 3e8efdcd83c..4ab2afb1174 100644 --- a/test/form/samples/indent-true-spaces/_expected/umd.js +++ b/test/form/samples/indent-true-spaces/_expected/umd.js @@ -2,7 +2,7 @@ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.foo = factory()); -}(this, (function () { 'use strict'; +})(this, (function () { 'use strict'; function foo () { console.log( 'indented with spaces' ); @@ -10,4 +10,4 @@ return foo; -}))); +})); diff --git a/test/form/samples/indent-true/_config.js b/test/form/samples/indent-true/_config.js index ad1ec81a073..d31ad024e90 100644 --- a/test/form/samples/indent-true/_config.js +++ b/test/form/samples/indent-true/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'auto-indents with indent: true', options: { output: { @@ -6,4 +6,4 @@ module.exports = { indent: true } } -}; +}); diff --git a/test/form/samples/indent-true/_expected/amd.js b/test/form/samples/indent-true/_expected/amd.js index fab8ba4a216..d703751c9ab 100644 --- a/test/form/samples/indent-true/_expected/amd.js +++ b/test/form/samples/indent-true/_expected/amd.js @@ -1,4 +1,4 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; function foo () { console.log( 'indented with tabs' ); @@ -6,4 +6,4 @@ define(function () { 'use strict'; return foo; -}); +})); diff --git a/test/form/samples/indent-true/_expected/es.js b/test/form/samples/indent-true/_expected/es.js index d4b23ef94cd..c141611cbbb 100644 --- a/test/form/samples/indent-true/_expected/es.js +++ b/test/form/samples/indent-true/_expected/es.js @@ -2,4 +2,4 @@ function foo () { console.log( 'indented with tabs' ); } -export default foo; +export { foo as default }; diff --git a/test/form/samples/indent-true/_expected/iife.js b/test/form/samples/indent-true/_expected/iife.js index 14d0a763c1a..6f4aca6a36f 100644 --- a/test/form/samples/indent-true/_expected/iife.js +++ b/test/form/samples/indent-true/_expected/iife.js @@ -7,4 +7,4 @@ var foo = (function () { return foo; -}()); +})(); diff --git a/test/form/samples/indent-true/_expected/system.js b/test/form/samples/indent-true/_expected/system.js index d2f4ed5b9c5..78b2e4cc01e 100644 --- a/test/form/samples/indent-true/_expected/system.js +++ b/test/form/samples/indent-true/_expected/system.js @@ -1,14 +1,14 @@ -System.register('foo', [], function (exports) { +System.register('foo', [], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - exports('default', foo); + exports("default", foo); function foo () { console.log( 'indented with tabs' ); } - } + }) }; -}); +})); diff --git a/test/form/samples/indent-true/_expected/umd.js b/test/form/samples/indent-true/_expected/umd.js index 7ed678e39c9..2ab3f96547f 100644 --- a/test/form/samples/indent-true/_expected/umd.js +++ b/test/form/samples/indent-true/_expected/umd.js @@ -2,7 +2,7 @@ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.foo = factory()); -}(this, (function () { 'use strict'; +})(this, (function () { 'use strict'; function foo () { console.log( 'indented with tabs' ); @@ -10,4 +10,4 @@ return foo; -}))); +})); diff --git a/test/form/samples/index-key/_config.js b/test/form/samples/index-key/_config.js new file mode 100644 index 00000000000..4b48327fcdc --- /dev/null +++ b/test/form/samples/index-key/_config.js @@ -0,0 +1,11 @@ +module.exports = defineTest({ + description: 'index key', + options: { + external: ['x'], + output: { + globals: { + x: 'x' + } + } + } +}); diff --git a/test/form/samples/index-key/_expected/amd.js b/test/form/samples/index-key/_expected/amd.js new file mode 100644 index 00000000000..9cce90f5b44 --- /dev/null +++ b/test/form/samples/index-key/_expected/amd.js @@ -0,0 +1,11 @@ +define(['x'], (function (x$1) { 'use strict'; + + var x = /*#__PURE__*/Object.freeze({ + __proto__: null, + "00": x$1["00"], + "9007199254740993": x$1["9007199254740993"] + }); + + console.log(x); + +})); diff --git a/test/form/samples/index-key/_expected/cjs.js b/test/form/samples/index-key/_expected/cjs.js new file mode 100644 index 00000000000..fbd029d2fc4 --- /dev/null +++ b/test/form/samples/index-key/_expected/cjs.js @@ -0,0 +1,11 @@ +'use strict'; + +var x$1 = require('x'); + +var x = /*#__PURE__*/Object.freeze({ + __proto__: null, + "00": x$1["00"], + "9007199254740993": x$1["9007199254740993"] +}); + +console.log(x); diff --git a/test/form/samples/index-key/_expected/es.js b/test/form/samples/index-key/_expected/es.js new file mode 100644 index 00000000000..a9563078313 --- /dev/null +++ b/test/form/samples/index-key/_expected/es.js @@ -0,0 +1,9 @@ +import { "00" as _00, "9007199254740993" as _9007199254740993 } from 'x'; + +var x = /*#__PURE__*/Object.freeze({ + __proto__: null, + "00": _00, + "9007199254740993": _9007199254740993 +}); + +console.log(x); diff --git a/test/form/samples/index-key/_expected/iife.js b/test/form/samples/index-key/_expected/iife.js new file mode 100644 index 00000000000..2bd668288b5 --- /dev/null +++ b/test/form/samples/index-key/_expected/iife.js @@ -0,0 +1,12 @@ +(function (x$1) { + 'use strict'; + + var x = /*#__PURE__*/Object.freeze({ + __proto__: null, + "00": x$1["00"], + "9007199254740993": x$1["9007199254740993"] + }); + + console.log(x); + +})(x); diff --git a/test/form/samples/index-key/_expected/system.js b/test/form/samples/index-key/_expected/system.js new file mode 100644 index 00000000000..86a4f3edb79 --- /dev/null +++ b/test/form/samples/index-key/_expected/system.js @@ -0,0 +1,21 @@ +System.register(['x'], (function () { + 'use strict'; + var _00, _9007199254740993; + return { + setters: [function (module) { + _00 = module["00"]; + _9007199254740993 = module["9007199254740993"]; + }], + execute: (function () { + + var x = /*#__PURE__*/Object.freeze({ + __proto__: null, + "00": _00, + "9007199254740993": _9007199254740993 + }); + + console.log(x); + + }) + }; +})); diff --git a/test/form/samples/index-key/_expected/umd.js b/test/form/samples/index-key/_expected/umd.js new file mode 100644 index 00000000000..82cbb8f74ee --- /dev/null +++ b/test/form/samples/index-key/_expected/umd.js @@ -0,0 +1,15 @@ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('x')) : + typeof define === 'function' && define.amd ? define(['x'], factory) : + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.x)); +})(this, (function (x$1) { 'use strict'; + + var x = /*#__PURE__*/Object.freeze({ + __proto__: null, + "00": x$1["00"], + "9007199254740993": x$1["9007199254740993"] + }); + + console.log(x); + +})); diff --git a/test/form/samples/index-key/main.js b/test/form/samples/index-key/main.js new file mode 100644 index 00000000000..a7264a387ed --- /dev/null +++ b/test/form/samples/index-key/main.js @@ -0,0 +1,2 @@ +import * as x from './x'; +console.log(x); diff --git a/test/form/samples/index-key/x.js b/test/form/samples/index-key/x.js new file mode 100644 index 00000000000..d238e1a8dc5 --- /dev/null +++ b/test/form/samples/index-key/x.js @@ -0,0 +1 @@ +export { '00', '9007199254740993' } from 'x'; diff --git a/test/form/samples/inline-with-reexport/_config.js b/test/form/samples/inline-with-reexport/_config.js new file mode 100644 index 00000000000..6f8e45d7902 --- /dev/null +++ b/test/form/samples/inline-with-reexport/_config.js @@ -0,0 +1,8 @@ +module.exports = defineTest({ + description: 'handles inlining dynamic imports when the imported module contains reexports', + options: { + output: { + inlineDynamicImports: true + } + } +}); diff --git a/test/form/samples/inline-with-reexport/_expected.js b/test/form/samples/inline-with-reexport/_expected.js new file mode 100644 index 00000000000..37cfcb197ca --- /dev/null +++ b/test/form/samples/inline-with-reexport/_expected.js @@ -0,0 +1,5 @@ +Promise.resolve().then(function () { return a; }); + +var a = /*#__PURE__*/Object.freeze({ + __proto__: null +}); diff --git a/test/form/samples/inline-with-reexport/a.js b/test/form/samples/inline-with-reexport/a.js new file mode 100644 index 00000000000..a040b04894a --- /dev/null +++ b/test/form/samples/inline-with-reexport/a.js @@ -0,0 +1 @@ +export { b } from './b.js'; diff --git a/test/form/samples/inline-with-reexport/b.js b/test/form/samples/inline-with-reexport/b.js new file mode 100644 index 00000000000..c59284ebf9d --- /dev/null +++ b/test/form/samples/inline-with-reexport/b.js @@ -0,0 +1 @@ +export const b = 42; diff --git a/test/form/samples/inline-with-reexport/main.js b/test/form/samples/inline-with-reexport/main.js new file mode 100644 index 00000000000..14c0bf22494 --- /dev/null +++ b/test/form/samples/inline-with-reexport/main.js @@ -0,0 +1 @@ +import('./a.js'); diff --git a/test/form/samples/inlined-treeshaken-dynamic-import/_config.js b/test/form/samples/inlined-treeshaken-dynamic-import/_config.js index 1703f4c9c1f..58505c25d55 100644 --- a/test/form/samples/inlined-treeshaken-dynamic-import/_config.js +++ b/test/form/samples/inlined-treeshaken-dynamic-import/_config.js @@ -1,6 +1,6 @@ -module.exports = { +module.exports = defineTest({ description: 'completely removes tree-shaken dynamic imports ', options: { output: { inlineDynamicImports: true } } -}; +}); diff --git a/test/form/samples/inlined-treeshaken-dynamic-import/_expected/amd.js b/test/form/samples/inlined-treeshaken-dynamic-import/_expected/amd.js index 126aa22ee83..49540b44d78 100644 --- a/test/form/samples/inlined-treeshaken-dynamic-import/_expected/amd.js +++ b/test/form/samples/inlined-treeshaken-dynamic-import/_expected/amd.js @@ -1,5 +1,5 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; console.log('main'); -}); +})); diff --git a/test/form/samples/inlined-treeshaken-dynamic-import/_expected/iife.js b/test/form/samples/inlined-treeshaken-dynamic-import/_expected/iife.js index d283cbce8ba..455edee6aa6 100644 --- a/test/form/samples/inlined-treeshaken-dynamic-import/_expected/iife.js +++ b/test/form/samples/inlined-treeshaken-dynamic-import/_expected/iife.js @@ -3,4 +3,4 @@ console.log('main'); -}()); +})(); diff --git a/test/form/samples/inlined-treeshaken-dynamic-import/_expected/system.js b/test/form/samples/inlined-treeshaken-dynamic-import/_expected/system.js index c83499bc2d4..35e2693371a 100644 --- a/test/form/samples/inlined-treeshaken-dynamic-import/_expected/system.js +++ b/test/form/samples/inlined-treeshaken-dynamic-import/_expected/system.js @@ -1,10 +1,10 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { console.log('main'); - } + }) }; -}); +})); diff --git a/test/form/samples/inlined-treeshaken-dynamic-import/_expected/umd.js b/test/form/samples/inlined-treeshaken-dynamic-import/_expected/umd.js index f69e11c0256..c8ba7daa897 100644 --- a/test/form/samples/inlined-treeshaken-dynamic-import/_expected/umd.js +++ b/test/form/samples/inlined-treeshaken-dynamic-import/_expected/umd.js @@ -1,8 +1,8 @@ (function (factory) { typeof define === 'function' && define.amd ? define(factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; console.log('main'); -}))); +})); diff --git a/test/form/samples/internal-conflict-resolution/_config.js b/test/form/samples/internal-conflict-resolution/_config.js index 921d1748e30..bd2f02eb476 100644 --- a/test/form/samples/internal-conflict-resolution/_config.js +++ b/test/form/samples/internal-conflict-resolution/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'internal name conflicts are resolved sanely' -}; +}); diff --git a/test/form/samples/internal-conflict-resolution/_expected/amd.js b/test/form/samples/internal-conflict-resolution/_expected/amd.js index 24d63fa2e30..15e4e22213f 100644 --- a/test/form/samples/internal-conflict-resolution/_expected/amd.js +++ b/test/form/samples/internal-conflict-resolution/_expected/amd.js @@ -1,4 +1,4 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; var bar$1 = 42; @@ -12,4 +12,4 @@ define(function () { 'use strict'; bar(); -}); +})); diff --git a/test/form/samples/internal-conflict-resolution/_expected/iife.js b/test/form/samples/internal-conflict-resolution/_expected/iife.js index 6e484fd42bd..548556e2379 100644 --- a/test/form/samples/internal-conflict-resolution/_expected/iife.js +++ b/test/form/samples/internal-conflict-resolution/_expected/iife.js @@ -13,4 +13,4 @@ bar(); -}()); +})(); diff --git a/test/form/samples/internal-conflict-resolution/_expected/system.js b/test/form/samples/internal-conflict-resolution/_expected/system.js index c6ca37ea4e0..5c65f8443a7 100644 --- a/test/form/samples/internal-conflict-resolution/_expected/system.js +++ b/test/form/samples/internal-conflict-resolution/_expected/system.js @@ -1,7 +1,7 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { var bar$1 = 42; @@ -15,6 +15,6 @@ System.register([], function () { bar(); - } + }) }; -}); +})); diff --git a/test/form/samples/internal-conflict-resolution/_expected/umd.js b/test/form/samples/internal-conflict-resolution/_expected/umd.js index 0446ee87db5..94ecb1aa8af 100644 --- a/test/form/samples/internal-conflict-resolution/_expected/umd.js +++ b/test/form/samples/internal-conflict-resolution/_expected/umd.js @@ -1,7 +1,7 @@ (function (factory) { typeof define === 'function' && define.amd ? define(factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; var bar$1 = 42; @@ -15,4 +15,4 @@ bar(); -}))); +})); diff --git a/test/form/samples/interop-per-dependency-no-freeze/_config.js b/test/form/samples/interop-per-dependency-no-freeze/_config.js index 87fef95a7de..f020ef7820c 100644 --- a/test/form/samples/interop-per-dependency-no-freeze/_config.js +++ b/test/form/samples/interop-per-dependency-no-freeze/_config.js @@ -1,15 +1,17 @@ -module.exports = { +module.exports = defineTest({ description: 'respects the freeze option', options: { external: id => id.startsWith('external'), output: { freeze: false, + /** @type any */ interop(id) { return id.split('-')[1]; }, globals(id) { return id.replace('-', ''); - } + }, + dynamicImportInCjs: false } } -}; +}); diff --git a/test/form/samples/interop-per-dependency-no-freeze/_expected/amd.js b/test/form/samples/interop-per-dependency-no-freeze/_expected/amd.js index e8da6a9f766..1afbccf68be 100644 --- a/test/form/samples/interop-per-dependency-no-freeze/_expected/amd.js +++ b/test/form/samples/interop-per-dependency-no-freeze/_expected/amd.js @@ -1,8 +1,6 @@ -define(['require', 'external-auto', 'external-default', 'external-defaultOnly', 'external-esModule'], function (require, fooAuto, fooDefault, fooDefaultOnly, fooEsModule) { 'use strict'; +define(['require', 'external-auto', 'external-default', 'external-defaultOnly', 'external-esModule'], (function (require, fooAuto, fooDefault, fooDefaultOnly, fooEsModule) { 'use strict'; - function _interopNamespace(e) { - return e && e.__esModule ? e : _interopNamespaceDefault(e); - } + function _interopNamespaceDefaultOnly (e) { return { __proto__: null, default: e }; } function _interopNamespaceDefault(e) { var n = Object.create(null); @@ -12,33 +10,29 @@ define(['require', 'external-auto', 'external-default', 'external-defaultOnly', var d = Object.getOwnPropertyDescriptor(e, k); Object.defineProperty(n, k, d.get ? d : { enumerable: true, - get: function () { - return e[k]; - } + get: function () { return e[k]; } }); } }); } - n['default'] = e; + n.default = e; return n; } - function _interopNamespaceDefaultOnly(e) { - return {__proto__: null, 'default': e}; - } + function _interopNamespace (e) { return e && e.__esModule ? e : _interopNamespaceDefault(e); } var fooAuto__namespace = /*#__PURE__*/_interopNamespace(fooAuto); var fooDefault__namespace = /*#__PURE__*/_interopNamespaceDefault(fooDefault); var fooDefaultOnly__namespace = /*#__PURE__*/_interopNamespaceDefaultOnly(fooDefaultOnly); - console.log(fooAuto__namespace['default'], fooAuto.barAuto, fooAuto__namespace); + console.log(fooAuto__namespace.default, fooAuto.barAuto, fooAuto__namespace); console.log(fooDefault, fooDefault.barDefault, fooDefault__namespace); console.log(fooDefaultOnly, fooDefaultOnly__namespace); - console.log(fooEsModule['default'], fooEsModule.barEsModule, fooEsModule); + console.log(fooEsModule.default, fooEsModule.barEsModule, fooEsModule); - new Promise(function (resolve, reject) { require(['external-auto'], function (m) { resolve(/*#__PURE__*/_interopNamespace(m)); }, reject) }).then(console.log); - new Promise(function (resolve, reject) { require(['external-default'], function (m) { resolve(/*#__PURE__*/_interopNamespaceDefault(m)); }, reject) }).then(console.log); - new Promise(function (resolve, reject) { require(['external-defaultOnly'], function (m) { resolve(/*#__PURE__*/_interopNamespaceDefaultOnly(m)); }, reject) }).then(console.log); - new Promise(function (resolve, reject) { require(['external-esModule'], resolve, reject) }).then(console.log); + new Promise(function (resolve, reject) { require(['external-auto'], function (m) { resolve(/*#__PURE__*/_interopNamespace(m)); }, reject); }).then(console.log); + new Promise(function (resolve, reject) { require(['external-default'], function (m) { resolve(/*#__PURE__*/_interopNamespaceDefault(m)); }, reject); }).then(console.log); + new Promise(function (resolve, reject) { require(['external-defaultOnly'], function (m) { resolve(/*#__PURE__*/_interopNamespaceDefaultOnly(m)); }, reject); }).then(console.log); + new Promise(function (resolve, reject) { require(['external-esModule'], resolve, reject); }).then(console.log); -}); +})); diff --git a/test/form/samples/interop-per-dependency-no-freeze/_expected/cjs.js b/test/form/samples/interop-per-dependency-no-freeze/_expected/cjs.js index c0cdfa90f74..9f9c717b143 100644 --- a/test/form/samples/interop-per-dependency-no-freeze/_expected/cjs.js +++ b/test/form/samples/interop-per-dependency-no-freeze/_expected/cjs.js @@ -5,9 +5,7 @@ var fooDefault = require('external-default'); var fooDefaultOnly = require('external-defaultOnly'); var fooEsModule = require('external-esModule'); -function _interopNamespace(e) { - return e && e.__esModule ? e : _interopNamespaceDefault(e); -} +function _interopNamespaceDefaultOnly (e) { return { __proto__: null, default: e }; } function _interopNamespaceDefault(e) { var n = Object.create(null); @@ -17,29 +15,25 @@ function _interopNamespaceDefault(e) { var d = Object.getOwnPropertyDescriptor(e, k); Object.defineProperty(n, k, d.get ? d : { enumerable: true, - get: function () { - return e[k]; - } + get: function () { return e[k]; } }); } }); } - n['default'] = e; + n.default = e; return n; } -function _interopNamespaceDefaultOnly(e) { - return {__proto__: null, 'default': e}; -} +function _interopNamespace (e) { return e && e.__esModule ? e : _interopNamespaceDefault(e); } var fooAuto__namespace = /*#__PURE__*/_interopNamespace(fooAuto); var fooDefault__namespace = /*#__PURE__*/_interopNamespaceDefault(fooDefault); var fooDefaultOnly__namespace = /*#__PURE__*/_interopNamespaceDefaultOnly(fooDefaultOnly); -console.log(fooAuto__namespace['default'], fooAuto.barAuto, fooAuto__namespace); +console.log(fooAuto__namespace.default, fooAuto.barAuto, fooAuto__namespace); console.log(fooDefault, fooDefault.barDefault, fooDefault__namespace); console.log(fooDefaultOnly, fooDefaultOnly__namespace); -console.log(fooEsModule['default'], fooEsModule.barEsModule, fooEsModule); +console.log(fooEsModule.default, fooEsModule.barEsModule, fooEsModule); Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('external-auto')); }).then(console.log); Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespaceDefault(require('external-default')); }).then(console.log); diff --git a/test/form/samples/interop-per-dependency-no-freeze/_expected/iife.js b/test/form/samples/interop-per-dependency-no-freeze/_expected/iife.js index fd60f59afd0..54a463e6d9c 100644 --- a/test/form/samples/interop-per-dependency-no-freeze/_expected/iife.js +++ b/test/form/samples/interop-per-dependency-no-freeze/_expected/iife.js @@ -1,9 +1,7 @@ (function (fooAuto, fooDefault, fooDefaultOnly, fooEsModule) { 'use strict'; - function _interopNamespace(e) { - return e && e.__esModule ? e : _interopNamespaceDefault(e); - } + function _interopNamespaceDefaultOnly (e) { return { __proto__: null, default: e }; } function _interopNamespaceDefault(e) { var n = Object.create(null); @@ -13,33 +11,29 @@ var d = Object.getOwnPropertyDescriptor(e, k); Object.defineProperty(n, k, d.get ? d : { enumerable: true, - get: function () { - return e[k]; - } + get: function () { return e[k]; } }); } }); } - n['default'] = e; + n.default = e; return n; } - function _interopNamespaceDefaultOnly(e) { - return {__proto__: null, 'default': e}; - } + function _interopNamespace (e) { return e && e.__esModule ? e : _interopNamespaceDefault(e); } var fooAuto__namespace = /*#__PURE__*/_interopNamespace(fooAuto); var fooDefault__namespace = /*#__PURE__*/_interopNamespaceDefault(fooDefault); var fooDefaultOnly__namespace = /*#__PURE__*/_interopNamespaceDefaultOnly(fooDefaultOnly); - console.log(fooAuto__namespace['default'], fooAuto.barAuto, fooAuto__namespace); + console.log(fooAuto__namespace.default, fooAuto.barAuto, fooAuto__namespace); console.log(fooDefault, fooDefault.barDefault, fooDefault__namespace); console.log(fooDefaultOnly, fooDefaultOnly__namespace); - console.log(fooEsModule['default'], fooEsModule.barEsModule, fooEsModule); + console.log(fooEsModule.default, fooEsModule.barEsModule, fooEsModule); import('external-auto').then(console.log); import('external-default').then(console.log); import('external-defaultOnly').then(console.log); import('external-esModule').then(console.log); -}(externalauto, externaldefault, externaldefaultOnly, externalesModule)); +})(externalauto, externaldefault, externaldefaultOnly, externalesModule); diff --git a/test/form/samples/interop-per-dependency-no-freeze/_expected/system.js b/test/form/samples/interop-per-dependency-no-freeze/_expected/system.js index f384a481644..a827badd2ca 100644 --- a/test/form/samples/interop-per-dependency-no-freeze/_expected/system.js +++ b/test/form/samples/interop-per-dependency-no-freeze/_expected/system.js @@ -1,4 +1,4 @@ -System.register(['external-auto', 'external-default', 'external-defaultOnly', 'external-esModule'], function (exports, module) { +System.register(['external-auto', 'external-default', 'external-defaultOnly', 'external-esModule'], (function (exports, module) { 'use strict'; var fooAuto__default, barAuto, fooAuto, fooDefault__default, barDefault, fooDefault, fooDefaultOnly__default, fooDefaultOnly, fooEsModule__default, barEsModule, fooEsModule; return { @@ -18,7 +18,7 @@ System.register(['external-auto', 'external-default', 'external-defaultOnly', 'e barEsModule = module.barEsModule; fooEsModule = module; }], - execute: function () { + execute: (function () { console.log(fooAuto__default, barAuto, fooAuto); console.log(fooDefault__default, barDefault, fooDefault); @@ -30,6 +30,6 @@ System.register(['external-auto', 'external-default', 'external-defaultOnly', 'e module.import('external-defaultOnly').then(console.log); module.import('external-esModule').then(console.log); - } + }) }; -}); +})); diff --git a/test/form/samples/interop-per-dependency-no-freeze/_expected/umd.js b/test/form/samples/interop-per-dependency-no-freeze/_expected/umd.js index 7e25ae75b27..1a644e8b92f 100644 --- a/test/form/samples/interop-per-dependency-no-freeze/_expected/umd.js +++ b/test/form/samples/interop-per-dependency-no-freeze/_expected/umd.js @@ -2,11 +2,9 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('external-auto'), require('external-default'), require('external-defaultOnly'), require('external-esModule')) : typeof define === 'function' && define.amd ? define(['external-auto', 'external-default', 'external-defaultOnly', 'external-esModule'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.externalauto, global.externaldefault, global.externaldefaultOnly, global.externalesModule)); -}(this, (function (fooAuto, fooDefault, fooDefaultOnly, fooEsModule) { 'use strict'; +})(this, (function (fooAuto, fooDefault, fooDefaultOnly, fooEsModule) { 'use strict'; - function _interopNamespace(e) { - return e && e.__esModule ? e : _interopNamespaceDefault(e); - } + function _interopNamespaceDefaultOnly (e) { return { __proto__: null, default: e }; } function _interopNamespaceDefault(e) { var n = Object.create(null); @@ -16,33 +14,29 @@ var d = Object.getOwnPropertyDescriptor(e, k); Object.defineProperty(n, k, d.get ? d : { enumerable: true, - get: function () { - return e[k]; - } + get: function () { return e[k]; } }); } }); } - n['default'] = e; + n.default = e; return n; } - function _interopNamespaceDefaultOnly(e) { - return {__proto__: null, 'default': e}; - } + function _interopNamespace (e) { return e && e.__esModule ? e : _interopNamespaceDefault(e); } var fooAuto__namespace = /*#__PURE__*/_interopNamespace(fooAuto); var fooDefault__namespace = /*#__PURE__*/_interopNamespaceDefault(fooDefault); var fooDefaultOnly__namespace = /*#__PURE__*/_interopNamespaceDefaultOnly(fooDefaultOnly); - console.log(fooAuto__namespace['default'], fooAuto.barAuto, fooAuto__namespace); + console.log(fooAuto__namespace.default, fooAuto.barAuto, fooAuto__namespace); console.log(fooDefault, fooDefault.barDefault, fooDefault__namespace); console.log(fooDefaultOnly, fooDefaultOnly__namespace); - console.log(fooEsModule['default'], fooEsModule.barEsModule, fooEsModule); + console.log(fooEsModule.default, fooEsModule.barEsModule, fooEsModule); import('external-auto').then(console.log); import('external-default').then(console.log); import('external-defaultOnly').then(console.log); import('external-esModule').then(console.log); -}))); +})); diff --git a/test/form/samples/interop-per-dependency-no-live-binding/_config.js b/test/form/samples/interop-per-dependency-no-live-binding/_config.js index 4c8a5549d3a..532a2dd7ced 100644 --- a/test/form/samples/interop-per-dependency-no-live-binding/_config.js +++ b/test/form/samples/interop-per-dependency-no-live-binding/_config.js @@ -1,11 +1,12 @@ const checkedIds = new Set(); -module.exports = { +module.exports = defineTest({ description: 'allows to configure the interop type per external dependency', options: { external: id => id.startsWith('external'), output: { externalLiveBindings: false, + /** @type any */ interop(id) { if (checkedIds.has(id)) { throw new Error(`Interop for id ${id} has been requested twice.`); @@ -13,7 +14,16 @@ module.exports = { checkedIds.add(id); return id.split('-')[1]; }, - format: 'cjs' + format: 'cjs', + dynamicImportInCjs: false, + plugins: [ + { + name: 'test', + renderStart() { + checkedIds.clear(); + } + } + ] } } -}; +}); diff --git a/test/form/samples/interop-per-dependency-no-live-binding/_expected.js b/test/form/samples/interop-per-dependency-no-live-binding/_expected.js index 087d4d96d14..417f270bde6 100644 --- a/test/form/samples/interop-per-dependency-no-live-binding/_expected.js +++ b/test/form/samples/interop-per-dependency-no-live-binding/_expected.js @@ -5,26 +5,22 @@ var fooDefault = require('external-default'); var fooDefaultOnly = require('external-defaultOnly'); var fooEsModule = require('external-esModule'); -function _interopDefault (e) { return e && e.__esModule ? e['default'] : e; } +function _interopDefault (e) { return e && e.__esModule ? e.default : e; } -function _interopNamespace(e) { - return e && e.__esModule ? e : _interopNamespaceDefault(e); -} +function _interopNamespaceDefaultOnly (e) { return Object.freeze({ __proto__: null, default: e }); } function _interopNamespaceDefault(e) { var n = Object.create(null); if (e) { - Object.keys(e).forEach(function (k) { + for (var k in e) { n[k] = e[k]; - }); + } } - n['default'] = e; + n.default = e; return Object.freeze(n); } -function _interopNamespaceDefaultOnly(e) { - return Object.freeze({__proto__: null, 'default': e}); -} +function _interopNamespace (e) { return e && e.__esModule ? e : _interopNamespaceDefault(e); } var fooAuto__default = /*#__PURE__*/_interopDefault(fooAuto); var fooAuto__namespace = /*#__PURE__*/_interopNamespace(fooAuto); @@ -34,7 +30,7 @@ var fooDefaultOnly__namespace = /*#__PURE__*/_interopNamespaceDefaultOnly(fooDef console.log(fooAuto__default, fooAuto.barAuto, fooAuto__namespace); console.log(fooDefault, fooDefault.barDefault, fooDefault__namespace); console.log(fooDefaultOnly, fooDefaultOnly__namespace); -console.log(fooEsModule['default'], fooEsModule.barEsModule, fooEsModule); +console.log(fooEsModule.default, fooEsModule.barEsModule, fooEsModule); Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('external-auto')); }).then(console.log); Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespaceDefault(require('external-default')); }).then(console.log); diff --git a/test/form/samples/interop-per-dependency/_config.js b/test/form/samples/interop-per-dependency/_config.js index 1212b8c0f57..00be3c6e95a 100644 --- a/test/form/samples/interop-per-dependency/_config.js +++ b/test/form/samples/interop-per-dependency/_config.js @@ -1,8 +1,9 @@ -module.exports = { +module.exports = defineTest({ description: 'allows to configure the interop type per external dependency', options: { external: id => id.startsWith('external'), output: { + /** @type any*/ interop(id) { if (id === null) { return 'auto'; @@ -11,7 +12,8 @@ module.exports = { }, globals(id) { return id.replace('-', ''); - } + }, + dynamicImportInCjs: false } } -}; +}); diff --git a/test/form/samples/interop-per-dependency/_expected/amd.js b/test/form/samples/interop-per-dependency/_expected/amd.js index b5a0a7f48ad..7ecf86d0f4f 100644 --- a/test/form/samples/interop-per-dependency/_expected/amd.js +++ b/test/form/samples/interop-per-dependency/_expected/amd.js @@ -1,8 +1,6 @@ -define(['require', 'external-auto', 'external-default', 'external-defaultOnly', 'external-esModule'], function (require, fooAuto, fooDefault, fooDefaultOnly, fooEsModule) { 'use strict'; +define(['require', 'external-auto', 'external-default', 'external-defaultOnly', 'external-esModule'], (function (require, fooAuto, fooDefault, fooDefaultOnly, fooEsModule) { 'use strict'; - function _interopNamespace(e) { - return e && e.__esModule ? e : _interopNamespaceDefault(e); - } + function _interopNamespaceDefaultOnly (e) { return Object.freeze({ __proto__: null, default: e }); } function _interopNamespaceDefault(e) { var n = Object.create(null); @@ -12,35 +10,31 @@ define(['require', 'external-auto', 'external-default', 'external-defaultOnly', var d = Object.getOwnPropertyDescriptor(e, k); Object.defineProperty(n, k, d.get ? d : { enumerable: true, - get: function () { - return e[k]; - } + get: function () { return e[k]; } }); } }); } - n['default'] = e; + n.default = e; return Object.freeze(n); } - function _interopNamespaceDefaultOnly(e) { - return Object.freeze({__proto__: null, 'default': e}); - } + function _interopNamespace (e) { return e && e.__esModule ? e : _interopNamespaceDefault(e); } var fooAuto__namespace = /*#__PURE__*/_interopNamespace(fooAuto); var fooDefault__namespace = /*#__PURE__*/_interopNamespaceDefault(fooDefault); var fooDefaultOnly__namespace = /*#__PURE__*/_interopNamespaceDefaultOnly(fooDefaultOnly); - console.log(fooAuto__namespace['default'], fooAuto.barAuto, fooAuto__namespace); + console.log(fooAuto__namespace.default, fooAuto.barAuto, fooAuto__namespace); console.log(fooDefault, fooDefault.barDefault, fooDefault__namespace); console.log(fooDefaultOnly, fooDefaultOnly__namespace); - console.log(fooEsModule['default'], fooEsModule.barEsModule, fooEsModule); + console.log(fooEsModule.default, fooEsModule.barEsModule, fooEsModule); - new Promise(function (resolve, reject) { require(['external-auto'], function (m) { resolve(/*#__PURE__*/_interopNamespace(m)); }, reject) }).then(console.log); - new Promise(function (resolve, reject) { require(['external-default'], function (m) { resolve(/*#__PURE__*/_interopNamespaceDefault(m)); }, reject) }).then(console.log); - new Promise(function (resolve, reject) { require(['external-defaultOnly'], function (m) { resolve(/*#__PURE__*/_interopNamespaceDefaultOnly(m)); }, reject) }).then(console.log); - new Promise(function (resolve, reject) { require(['external-esModule'], resolve, reject) }).then(console.log); - new Promise(function (resolve, reject) { require([globalThis.external1], function (m) { resolve(/*#__PURE__*/_interopNamespace(m)); }, reject) }).then(console.log); - new Promise(function (resolve, reject) { require([globalThis.external2], function (m) { resolve(/*#__PURE__*/_interopNamespace(m)); }, reject) }).then(console.log); + new Promise(function (resolve, reject) { require(['external-auto'], function (m) { resolve(/*#__PURE__*/_interopNamespace(m)); }, reject); }).then(console.log); + new Promise(function (resolve, reject) { require(['external-default'], function (m) { resolve(/*#__PURE__*/_interopNamespaceDefault(m)); }, reject); }).then(console.log); + new Promise(function (resolve, reject) { require(['external-defaultOnly'], function (m) { resolve(/*#__PURE__*/_interopNamespaceDefaultOnly(m)); }, reject); }).then(console.log); + new Promise(function (resolve, reject) { require(['external-esModule'], resolve, reject); }).then(console.log); + (function (t) { return new Promise(function (resolve, reject) { require([t], function (m) { resolve(/*#__PURE__*/_interopNamespace(m)); }, reject); }); })(globalThis.external1).then(console.log); + (function (t) { return new Promise(function (resolve, reject) { require([t], function (m) { resolve(/*#__PURE__*/_interopNamespace(m)); }, reject); }); })(globalThis.external2).then(console.log); -}); +})); diff --git a/test/form/samples/interop-per-dependency/_expected/cjs.js b/test/form/samples/interop-per-dependency/_expected/cjs.js index 6f400ce7b2b..e73675dd0fa 100644 --- a/test/form/samples/interop-per-dependency/_expected/cjs.js +++ b/test/form/samples/interop-per-dependency/_expected/cjs.js @@ -5,9 +5,7 @@ var fooDefault = require('external-default'); var fooDefaultOnly = require('external-defaultOnly'); var fooEsModule = require('external-esModule'); -function _interopNamespace(e) { - return e && e.__esModule ? e : _interopNamespaceDefault(e); -} +function _interopNamespaceDefaultOnly (e) { return Object.freeze({ __proto__: null, default: e }); } function _interopNamespaceDefault(e) { var n = Object.create(null); @@ -17,33 +15,29 @@ function _interopNamespaceDefault(e) { var d = Object.getOwnPropertyDescriptor(e, k); Object.defineProperty(n, k, d.get ? d : { enumerable: true, - get: function () { - return e[k]; - } + get: function () { return e[k]; } }); } }); } - n['default'] = e; + n.default = e; return Object.freeze(n); } -function _interopNamespaceDefaultOnly(e) { - return Object.freeze({__proto__: null, 'default': e}); -} +function _interopNamespace (e) { return e && e.__esModule ? e : _interopNamespaceDefault(e); } var fooAuto__namespace = /*#__PURE__*/_interopNamespace(fooAuto); var fooDefault__namespace = /*#__PURE__*/_interopNamespaceDefault(fooDefault); var fooDefaultOnly__namespace = /*#__PURE__*/_interopNamespaceDefaultOnly(fooDefaultOnly); -console.log(fooAuto__namespace['default'], fooAuto.barAuto, fooAuto__namespace); +console.log(fooAuto__namespace.default, fooAuto.barAuto, fooAuto__namespace); console.log(fooDefault, fooDefault.barDefault, fooDefault__namespace); console.log(fooDefaultOnly, fooDefaultOnly__namespace); -console.log(fooEsModule['default'], fooEsModule.barEsModule, fooEsModule); +console.log(fooEsModule.default, fooEsModule.barEsModule, fooEsModule); Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('external-auto')); }).then(console.log); Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespaceDefault(require('external-default')); }).then(console.log); Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespaceDefaultOnly(require('external-defaultOnly')); }).then(console.log); Promise.resolve().then(function () { return require('external-esModule'); }).then(console.log); -Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(globalThis.external1)); }).then(console.log); -Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(globalThis.external2)); }).then(console.log); +(function (t) { return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(t)); }); })(globalThis.external1).then(console.log); +(function (t) { return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(t)); }); })(globalThis.external2).then(console.log); diff --git a/test/form/samples/interop-per-dependency/_expected/iife.js b/test/form/samples/interop-per-dependency/_expected/iife.js index 569783868fd..4f7f0ab4f72 100644 --- a/test/form/samples/interop-per-dependency/_expected/iife.js +++ b/test/form/samples/interop-per-dependency/_expected/iife.js @@ -1,9 +1,7 @@ (function (fooAuto, fooDefault, fooDefaultOnly, fooEsModule) { 'use strict'; - function _interopNamespace(e) { - return e && e.__esModule ? e : _interopNamespaceDefault(e); - } + function _interopNamespaceDefaultOnly (e) { return Object.freeze({ __proto__: null, default: e }); } function _interopNamespaceDefault(e) { var n = Object.create(null); @@ -13,29 +11,25 @@ var d = Object.getOwnPropertyDescriptor(e, k); Object.defineProperty(n, k, d.get ? d : { enumerable: true, - get: function () { - return e[k]; - } + get: function () { return e[k]; } }); } }); } - n['default'] = e; + n.default = e; return Object.freeze(n); } - function _interopNamespaceDefaultOnly(e) { - return Object.freeze({__proto__: null, 'default': e}); - } + function _interopNamespace (e) { return e && e.__esModule ? e : _interopNamespaceDefault(e); } var fooAuto__namespace = /*#__PURE__*/_interopNamespace(fooAuto); var fooDefault__namespace = /*#__PURE__*/_interopNamespaceDefault(fooDefault); var fooDefaultOnly__namespace = /*#__PURE__*/_interopNamespaceDefaultOnly(fooDefaultOnly); - console.log(fooAuto__namespace['default'], fooAuto.barAuto, fooAuto__namespace); + console.log(fooAuto__namespace.default, fooAuto.barAuto, fooAuto__namespace); console.log(fooDefault, fooDefault.barDefault, fooDefault__namespace); console.log(fooDefaultOnly, fooDefaultOnly__namespace); - console.log(fooEsModule['default'], fooEsModule.barEsModule, fooEsModule); + console.log(fooEsModule.default, fooEsModule.barEsModule, fooEsModule); import('external-auto').then(console.log); import('external-default').then(console.log); @@ -44,4 +38,4 @@ import(globalThis.external1).then(console.log); import(globalThis.external2).then(console.log); -}(externalauto, externaldefault, externaldefaultOnly, externalesModule)); +})(externalauto, externaldefault, externaldefaultOnly, externalesModule); diff --git a/test/form/samples/interop-per-dependency/_expected/system.js b/test/form/samples/interop-per-dependency/_expected/system.js index f5ea1a7b91f..dc541e62635 100644 --- a/test/form/samples/interop-per-dependency/_expected/system.js +++ b/test/form/samples/interop-per-dependency/_expected/system.js @@ -1,4 +1,4 @@ -System.register(['external-auto', 'external-default', 'external-defaultOnly', 'external-esModule'], function (exports, module) { +System.register(['external-auto', 'external-default', 'external-defaultOnly', 'external-esModule'], (function (exports, module) { 'use strict'; var fooAuto__default, barAuto, fooAuto, fooDefault__default, barDefault, fooDefault, fooDefaultOnly__default, fooDefaultOnly, fooEsModule__default, barEsModule, fooEsModule; return { @@ -18,7 +18,7 @@ System.register(['external-auto', 'external-default', 'external-defaultOnly', 'e barEsModule = module.barEsModule; fooEsModule = module; }], - execute: function () { + execute: (function () { console.log(fooAuto__default, barAuto, fooAuto); console.log(fooDefault__default, barDefault, fooDefault); @@ -32,6 +32,6 @@ System.register(['external-auto', 'external-default', 'external-defaultOnly', 'e module.import(globalThis.external1).then(console.log); module.import(globalThis.external2).then(console.log); - } + }) }; -}); +})); diff --git a/test/form/samples/interop-per-dependency/_expected/umd.js b/test/form/samples/interop-per-dependency/_expected/umd.js index 4d57d7de70a..6365aaa3330 100644 --- a/test/form/samples/interop-per-dependency/_expected/umd.js +++ b/test/form/samples/interop-per-dependency/_expected/umd.js @@ -2,11 +2,9 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('external-auto'), require('external-default'), require('external-defaultOnly'), require('external-esModule')) : typeof define === 'function' && define.amd ? define(['external-auto', 'external-default', 'external-defaultOnly', 'external-esModule'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.externalauto, global.externaldefault, global.externaldefaultOnly, global.externalesModule)); -}(this, (function (fooAuto, fooDefault, fooDefaultOnly, fooEsModule) { 'use strict'; +})(this, (function (fooAuto, fooDefault, fooDefaultOnly, fooEsModule) { 'use strict'; - function _interopNamespace(e) { - return e && e.__esModule ? e : _interopNamespaceDefault(e); - } + function _interopNamespaceDefaultOnly (e) { return Object.freeze({ __proto__: null, default: e }); } function _interopNamespaceDefault(e) { var n = Object.create(null); @@ -16,29 +14,25 @@ var d = Object.getOwnPropertyDescriptor(e, k); Object.defineProperty(n, k, d.get ? d : { enumerable: true, - get: function () { - return e[k]; - } + get: function () { return e[k]; } }); } }); } - n['default'] = e; + n.default = e; return Object.freeze(n); } - function _interopNamespaceDefaultOnly(e) { - return Object.freeze({__proto__: null, 'default': e}); - } + function _interopNamespace (e) { return e && e.__esModule ? e : _interopNamespaceDefault(e); } var fooAuto__namespace = /*#__PURE__*/_interopNamespace(fooAuto); var fooDefault__namespace = /*#__PURE__*/_interopNamespaceDefault(fooDefault); var fooDefaultOnly__namespace = /*#__PURE__*/_interopNamespaceDefaultOnly(fooDefaultOnly); - console.log(fooAuto__namespace['default'], fooAuto.barAuto, fooAuto__namespace); + console.log(fooAuto__namespace.default, fooAuto.barAuto, fooAuto__namespace); console.log(fooDefault, fooDefault.barDefault, fooDefault__namespace); console.log(fooDefaultOnly, fooDefaultOnly__namespace); - console.log(fooEsModule['default'], fooEsModule.barEsModule, fooEsModule); + console.log(fooEsModule.default, fooEsModule.barEsModule, fooEsModule); import('external-auto').then(console.log); import('external-default').then(console.log); @@ -47,4 +41,4 @@ import(globalThis.external1).then(console.log); import(globalThis.external2).then(console.log); -}))); +})); diff --git a/test/form/samples/interop-per-reexported-dependency/_config.js b/test/form/samples/interop-per-reexported-dependency/_config.js index 8d2772f7d6f..125ced57302 100644 --- a/test/form/samples/interop-per-reexported-dependency/_config.js +++ b/test/form/samples/interop-per-reexported-dependency/_config.js @@ -1,8 +1,9 @@ -module.exports = { +module.exports = defineTest({ description: 'allows to configure the interop type per reexported external dependency', options: { external: id => id.startsWith('external'), output: { + /** @type any */ interop(id) { return id.split('-')[1]; }, @@ -12,4 +13,4 @@ module.exports = { name: 'bundle' } } -}; +}); diff --git a/test/form/samples/interop-per-reexported-dependency/_expected/amd.js b/test/form/samples/interop-per-reexported-dependency/_expected/amd.js index fc76b372f4c..18838235eb9 100644 --- a/test/form/samples/interop-per-reexported-dependency/_expected/amd.js +++ b/test/form/samples/interop-per-reexported-dependency/_expected/amd.js @@ -1,8 +1,4 @@ -define(['exports', 'external-auto', 'external-default', 'external-defaultOnly', 'external-esModule'], function (exports, externalAuto, externalDefault, externalDefaultOnly, externalEsModule) { 'use strict'; - - function _interopNamespace(e) { - return e && e.__esModule ? e : _interopNamespaceDefault(e); - } +define(['exports', 'external-auto', 'external-default', 'external-defaultOnly', 'external-esModule'], (function (exports, externalAuto, externalDefault, externalDefaultOnly, externalEsModule) { 'use strict'; function _interopNamespaceDefault(e) { var n = Object.create(null); @@ -12,58 +8,46 @@ define(['exports', 'external-auto', 'external-default', 'external-defaultOnly', var d = Object.getOwnPropertyDescriptor(e, k); Object.defineProperty(n, k, d.get ? d : { enumerable: true, - get: function () { - return e[k]; - } + get: function () { return e[k]; } }); } }); } - n['default'] = e; + n.default = e; return Object.freeze(n); } + function _interopNamespace (e) { return e && e.__esModule ? e : _interopNamespaceDefault(e); } + var externalAuto__namespace = /*#__PURE__*/_interopNamespace(externalAuto); var externalDefault__namespace = /*#__PURE__*/_interopNamespaceDefault(externalDefault); - Object.defineProperty(exports, 'barAuto', { + Object.defineProperty(exports, "barAuto", { enumerable: true, - get: function () { - return externalAuto.barAuto; - } + get: function () { return externalAuto.barAuto; } }); exports.externalAuto = externalAuto__namespace; - Object.defineProperty(exports, 'fooAuto', { + Object.defineProperty(exports, "fooAuto", { enumerable: true, - get: function () { - return externalAuto__namespace['default']; - } + get: function () { return externalAuto__namespace.default; } }); - Object.defineProperty(exports, 'barDefault', { + Object.defineProperty(exports, "barDefault", { enumerable: true, - get: function () { - return externalDefault.barDefault; - } + get: function () { return externalDefault.barDefault; } }); exports.externalDefault = externalDefault__namespace; exports.fooDefault = externalDefault; exports.fooDefaultOnly = externalDefaultOnly; - Object.defineProperty(exports, 'barEsModule', { + Object.defineProperty(exports, "barEsModule", { enumerable: true, - get: function () { - return externalEsModule.barEsModule; - } + get: function () { return externalEsModule.barEsModule; } }); exports.externalEsModule = externalEsModule; - Object.defineProperty(exports, 'fooEsModule', { + Object.defineProperty(exports, "fooEsModule", { enumerable: true, - get: function () { - return externalEsModule['default']; - } + get: function () { return externalEsModule.default; } }); - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/form/samples/interop-per-reexported-dependency/_expected/cjs.js b/test/form/samples/interop-per-reexported-dependency/_expected/cjs.js index f4db1ca5b5e..8ced95fc7ab 100644 --- a/test/form/samples/interop-per-reexported-dependency/_expected/cjs.js +++ b/test/form/samples/interop-per-reexported-dependency/_expected/cjs.js @@ -1,16 +1,10 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - var externalAuto = require('external-auto'); var externalDefault = require('external-default'); var externalDefaultOnly = require('external-defaultOnly'); var externalEsModule = require('external-esModule'); -function _interopNamespace(e) { - return e && e.__esModule ? e : _interopNamespaceDefault(e); -} - function _interopNamespaceDefault(e) { var n = Object.create(null); if (e) { @@ -19,54 +13,44 @@ function _interopNamespaceDefault(e) { var d = Object.getOwnPropertyDescriptor(e, k); Object.defineProperty(n, k, d.get ? d : { enumerable: true, - get: function () { - return e[k]; - } + get: function () { return e[k]; } }); } }); } - n['default'] = e; + n.default = e; return Object.freeze(n); } +function _interopNamespace (e) { return e && e.__esModule ? e : _interopNamespaceDefault(e); } + var externalAuto__namespace = /*#__PURE__*/_interopNamespace(externalAuto); var externalDefault__namespace = /*#__PURE__*/_interopNamespaceDefault(externalDefault); -Object.defineProperty(exports, 'barAuto', { +Object.defineProperty(exports, "barAuto", { enumerable: true, - get: function () { - return externalAuto.barAuto; - } + get: function () { return externalAuto.barAuto; } }); exports.externalAuto = externalAuto__namespace; -Object.defineProperty(exports, 'fooAuto', { +Object.defineProperty(exports, "fooAuto", { enumerable: true, - get: function () { - return externalAuto__namespace['default']; - } + get: function () { return externalAuto__namespace.default; } }); -Object.defineProperty(exports, 'barDefault', { +Object.defineProperty(exports, "barDefault", { enumerable: true, - get: function () { - return externalDefault.barDefault; - } + get: function () { return externalDefault.barDefault; } }); exports.externalDefault = externalDefault__namespace; exports.fooDefault = externalDefault; exports.fooDefaultOnly = externalDefaultOnly; -Object.defineProperty(exports, 'barEsModule', { +Object.defineProperty(exports, "barEsModule", { enumerable: true, - get: function () { - return externalEsModule.barEsModule; - } + get: function () { return externalEsModule.barEsModule; } }); exports.externalEsModule = externalEsModule; -Object.defineProperty(exports, 'fooEsModule', { +Object.defineProperty(exports, "fooEsModule", { enumerable: true, - get: function () { - return externalEsModule['default']; - } + get: function () { return externalEsModule.default; } }); diff --git a/test/form/samples/interop-per-reexported-dependency/_expected/iife.js b/test/form/samples/interop-per-reexported-dependency/_expected/iife.js index 1cc677b6cd1..81bb6d1951e 100644 --- a/test/form/samples/interop-per-reexported-dependency/_expected/iife.js +++ b/test/form/samples/interop-per-reexported-dependency/_expected/iife.js @@ -1,10 +1,6 @@ var bundle = (function (exports, externalAuto, externalDefault, externalDefaultOnly, externalEsModule) { 'use strict'; - function _interopNamespace(e) { - return e && e.__esModule ? e : _interopNamespaceDefault(e); - } - function _interopNamespaceDefault(e) { var n = Object.create(null); if (e) { @@ -13,60 +9,48 @@ var bundle = (function (exports, externalAuto, externalDefault, externalDefaultO var d = Object.getOwnPropertyDescriptor(e, k); Object.defineProperty(n, k, d.get ? d : { enumerable: true, - get: function () { - return e[k]; - } + get: function () { return e[k]; } }); } }); } - n['default'] = e; + n.default = e; return Object.freeze(n); } + function _interopNamespace (e) { return e && e.__esModule ? e : _interopNamespaceDefault(e); } + var externalAuto__namespace = /*#__PURE__*/_interopNamespace(externalAuto); var externalDefault__namespace = /*#__PURE__*/_interopNamespaceDefault(externalDefault); - Object.defineProperty(exports, 'barAuto', { + Object.defineProperty(exports, "barAuto", { enumerable: true, - get: function () { - return externalAuto.barAuto; - } + get: function () { return externalAuto.barAuto; } }); exports.externalAuto = externalAuto__namespace; - Object.defineProperty(exports, 'fooAuto', { + Object.defineProperty(exports, "fooAuto", { enumerable: true, - get: function () { - return externalAuto__namespace['default']; - } + get: function () { return externalAuto__namespace.default; } }); - Object.defineProperty(exports, 'barDefault', { + Object.defineProperty(exports, "barDefault", { enumerable: true, - get: function () { - return externalDefault.barDefault; - } + get: function () { return externalDefault.barDefault; } }); exports.externalDefault = externalDefault__namespace; exports.fooDefault = externalDefault; exports.fooDefaultOnly = externalDefaultOnly; - Object.defineProperty(exports, 'barEsModule', { + Object.defineProperty(exports, "barEsModule", { enumerable: true, - get: function () { - return externalEsModule.barEsModule; - } + get: function () { return externalEsModule.barEsModule; } }); exports.externalEsModule = externalEsModule; - Object.defineProperty(exports, 'fooEsModule', { + Object.defineProperty(exports, "fooEsModule", { enumerable: true, - get: function () { - return externalEsModule['default']; - } + get: function () { return externalEsModule.default; } }); - Object.defineProperty(exports, '__esModule', { value: true }); - return exports; -}({}, externalauto, externaldefault, externaldefaultOnly, externalesModule)); +})({}, externalauto, externaldefault, externaldefaultOnly, externalesModule); diff --git a/test/form/samples/interop-per-reexported-dependency/_expected/system.js b/test/form/samples/interop-per-reexported-dependency/_expected/system.js index af83c96da93..b6379938cfd 100644 --- a/test/form/samples/interop-per-reexported-dependency/_expected/system.js +++ b/test/form/samples/interop-per-reexported-dependency/_expected/system.js @@ -1,31 +1,19 @@ -System.register('bundle', ['external-auto', 'external-default', 'external-defaultOnly', 'external-esModule'], function (exports) { +System.register('bundle', ['external-auto', 'external-default', 'external-defaultOnly', 'external-esModule'], (function (exports) { 'use strict'; return { setters: [function (module) { - exports('externalAuto', module); - var _setter = {}; - _setter.barAuto = module.barAuto; - _setter.fooAuto = module.default; - exports(_setter); + exports({ barAuto: module.barAuto, externalAuto: module, fooAuto: module.default }); }, function (module) { - exports('externalDefault', module); - var _setter = {}; - _setter.barDefault = module.barDefault; - _setter.fooDefault = module.default; - exports(_setter); + exports({ barDefault: module.barDefault, externalDefault: module, fooDefault: module.default }); }, function (module) { - exports('fooDefaultOnly', module.default); + exports("fooDefaultOnly", module.default); }, function (module) { - exports('externalEsModule', module); - var _setter = {}; - _setter.barEsModule = module.barEsModule; - _setter.fooEsModule = module.default; - exports(_setter); + exports({ barEsModule: module.barEsModule, externalEsModule: module, fooEsModule: module.default }); }], - execute: function () { + execute: (function () { - } + }) }; -}); +})); diff --git a/test/form/samples/interop-per-reexported-dependency/_expected/umd.js b/test/form/samples/interop-per-reexported-dependency/_expected/umd.js index 1bccf0ab73c..d1463fd0ffc 100644 --- a/test/form/samples/interop-per-reexported-dependency/_expected/umd.js +++ b/test/form/samples/interop-per-reexported-dependency/_expected/umd.js @@ -2,11 +2,7 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('external-auto'), require('external-default'), require('external-defaultOnly'), require('external-esModule')) : typeof define === 'function' && define.amd ? define(['exports', 'external-auto', 'external-default', 'external-defaultOnly', 'external-esModule'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.bundle = {}, global.externalauto, global.externaldefault, global.externaldefaultOnly, global.externalesModule)); -}(this, (function (exports, externalAuto, externalDefault, externalDefaultOnly, externalEsModule) { 'use strict'; - - function _interopNamespace(e) { - return e && e.__esModule ? e : _interopNamespaceDefault(e); - } +})(this, (function (exports, externalAuto, externalDefault, externalDefaultOnly, externalEsModule) { 'use strict'; function _interopNamespaceDefault(e) { var n = Object.create(null); @@ -16,58 +12,46 @@ var d = Object.getOwnPropertyDescriptor(e, k); Object.defineProperty(n, k, d.get ? d : { enumerable: true, - get: function () { - return e[k]; - } + get: function () { return e[k]; } }); } }); } - n['default'] = e; + n.default = e; return Object.freeze(n); } + function _interopNamespace (e) { return e && e.__esModule ? e : _interopNamespaceDefault(e); } + var externalAuto__namespace = /*#__PURE__*/_interopNamespace(externalAuto); var externalDefault__namespace = /*#__PURE__*/_interopNamespaceDefault(externalDefault); - Object.defineProperty(exports, 'barAuto', { + Object.defineProperty(exports, "barAuto", { enumerable: true, - get: function () { - return externalAuto.barAuto; - } + get: function () { return externalAuto.barAuto; } }); exports.externalAuto = externalAuto__namespace; - Object.defineProperty(exports, 'fooAuto', { + Object.defineProperty(exports, "fooAuto", { enumerable: true, - get: function () { - return externalAuto__namespace['default']; - } + get: function () { return externalAuto__namespace.default; } }); - Object.defineProperty(exports, 'barDefault', { + Object.defineProperty(exports, "barDefault", { enumerable: true, - get: function () { - return externalDefault.barDefault; - } + get: function () { return externalDefault.barDefault; } }); exports.externalDefault = externalDefault__namespace; exports.fooDefault = externalDefault; exports.fooDefaultOnly = externalDefaultOnly; - Object.defineProperty(exports, 'barEsModule', { + Object.defineProperty(exports, "barEsModule", { enumerable: true, - get: function () { - return externalEsModule.barEsModule; - } + get: function () { return externalEsModule.barEsModule; } }); exports.externalEsModule = externalEsModule; - Object.defineProperty(exports, 'fooEsModule', { + Object.defineProperty(exports, "fooEsModule", { enumerable: true, - get: function () { - return externalEsModule['default']; - } + get: function () { return externalEsModule.default; } }); - Object.defineProperty(exports, '__esModule', { value: true }); - -}))); +})); diff --git a/test/form/samples/intro-and-outro/_config.js b/test/form/samples/intro-and-outro/_config.js index 6b525adedb8..467a7697513 100644 --- a/test/form/samples/intro-and-outro/_config.js +++ b/test/form/samples/intro-and-outro/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'adds an intro/outro', options: { output: { @@ -10,6 +10,7 @@ module.exports = { external: ['external'], plugins: [ { + name: 'first', intro() { return '// intro 1'; }, @@ -18,6 +19,7 @@ module.exports = { } }, { + name: 'second', intro() { return '// intro 2'; }, @@ -26,6 +28,7 @@ module.exports = { } }, { + name: 'third', intro() { return Promise.resolve('// intro 3'); }, @@ -34,9 +37,10 @@ module.exports = { } }, { + name: 'fourth', intro: '// intro 4', outro: '// outro 4' } ] } -}; +}); diff --git a/test/form/samples/intro-and-outro/_expected/amd.js b/test/form/samples/intro-and-outro/_expected/amd.js index d314c42fba2..9b87d2fb7fe 100644 --- a/test/form/samples/intro-and-outro/_expected/amd.js +++ b/test/form/samples/intro-and-outro/_expected/amd.js @@ -1,4 +1,4 @@ -define(['external'], function (a) { 'use strict'; +define(['external'], (function (a) { 'use strict'; /* this is an intro */ @@ -10,11 +10,7 @@ define(['external'], function (a) { 'use strict'; // intro 4 - function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } - - var a__default = /*#__PURE__*/_interopDefaultLegacy(a); - - console.log( a__default['default'] ); + console.log( a ); console.log( a.b ); var main = 42; @@ -31,4 +27,4 @@ define(['external'], function (a) { 'use strict'; // outro 4 -}); +})); diff --git a/test/form/samples/intro-and-outro/_expected/cjs.js b/test/form/samples/intro-and-outro/_expected/cjs.js index 4a91444707c..fbad540caf3 100644 --- a/test/form/samples/intro-and-outro/_expected/cjs.js +++ b/test/form/samples/intro-and-outro/_expected/cjs.js @@ -12,11 +12,7 @@ var a = require('external'); -function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } - -var a__default = /*#__PURE__*/_interopDefaultLegacy(a); - -console.log( a__default['default'] ); +console.log( a ); console.log( a.b ); var main = 42; diff --git a/test/form/samples/intro-and-outro/_expected/es.js b/test/form/samples/intro-and-outro/_expected/es.js index 067f92bffe2..055fe211abc 100644 --- a/test/form/samples/intro-and-outro/_expected/es.js +++ b/test/form/samples/intro-and-outro/_expected/es.js @@ -15,7 +15,7 @@ console.log( b ); var main = 42; -export default main; +export { main as default }; /* this is an outro */ diff --git a/test/form/samples/intro-and-outro/_expected/iife.js b/test/form/samples/intro-and-outro/_expected/iife.js index 64b483b9165..aca33e2f112 100644 --- a/test/form/samples/intro-and-outro/_expected/iife.js +++ b/test/form/samples/intro-and-outro/_expected/iife.js @@ -11,11 +11,7 @@ var foo = (function (a) { // intro 4 - function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } - - var a__default = /*#__PURE__*/_interopDefaultLegacy(a); - - console.log( a__default['default'] ); + console.log( a ); console.log( a.b ); var main = 42; @@ -32,4 +28,4 @@ var foo = (function (a) { // outro 4 -}(a)); +})(a); diff --git a/test/form/samples/intro-and-outro/_expected/system.js b/test/form/samples/intro-and-outro/_expected/system.js index dd50ce74f96..652d9c08e8a 100644 --- a/test/form/samples/intro-and-outro/_expected/system.js +++ b/test/form/samples/intro-and-outro/_expected/system.js @@ -1,4 +1,4 @@ -System.register('foo', ['external'], function (exports) { +System.register('foo', ['external'], (function (exports) { 'use strict'; var a, b; return { @@ -6,7 +6,7 @@ System.register('foo', ['external'], function (exports) { a = module.default; b = module.b; }], - execute: function () { + execute: (function () { /* this is an intro */ @@ -21,7 +21,7 @@ System.register('foo', ['external'], function (exports) { console.log( a ); console.log( b ); - var main = exports('default', 42); + var main = exports("default", 42); /* this is an outro */ @@ -33,6 +33,6 @@ System.register('foo', ['external'], function (exports) { // outro 4 - } + }) }; -}); +})); diff --git a/test/form/samples/intro-and-outro/_expected/umd.js b/test/form/samples/intro-and-outro/_expected/umd.js index d60e50cc8ab..6aec22600e3 100644 --- a/test/form/samples/intro-and-outro/_expected/umd.js +++ b/test/form/samples/intro-and-outro/_expected/umd.js @@ -2,7 +2,7 @@ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('external')) : typeof define === 'function' && define.amd ? define(['external'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.foo = factory(global.a)); -}(this, (function (a) { 'use strict'; +})(this, (function (a) { 'use strict'; /* this is an intro */ @@ -14,11 +14,7 @@ // intro 4 - function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } - - var a__default = /*#__PURE__*/_interopDefaultLegacy(a); - - console.log( a__default['default'] ); + console.log( a ); console.log( a.b ); var main = 42; @@ -35,4 +31,4 @@ // outro 4 -}))); +})); diff --git a/test/form/samples/invalid-binary-expressions/_config.js b/test/form/samples/invalid-binary-expressions/_config.js index 6e229db19cb..9793cc6d678 100644 --- a/test/form/samples/invalid-binary-expressions/_config.js +++ b/test/form/samples/invalid-binary-expressions/_config.js @@ -1,3 +1,4 @@ -module.exports = { - description: 'Does not fail when bundling code where the `in`-operator is used with invalid right sides' -}; +module.exports = defineTest({ + description: + 'Does not fail when bundling code where the `in`-operator is used with invalid right sides' +}); diff --git a/test/form/samples/json-parse-is-not-pure/_config.js b/test/form/samples/json-parse-is-not-pure/_config.js index b7636146475..667c498f718 100644 --- a/test/form/samples/json-parse-is-not-pure/_config.js +++ b/test/form/samples/json-parse-is-not-pure/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'JSON.parse is not pure as it can throw on invalid json strings', options: { output: { name: 'myBundle' } } -}; +}); diff --git a/test/form/samples/json-parse-is-not-pure/_expected/amd.js b/test/form/samples/json-parse-is-not-pure/_expected/amd.js index 377fac44d0b..2e76a23c54f 100644 --- a/test/form/samples/json-parse-is-not-pure/_expected/amd.js +++ b/test/form/samples/json-parse-is-not-pure/_expected/amd.js @@ -1,4 +1,4 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; var main = (input) => { try { @@ -11,4 +11,4 @@ define(function () { 'use strict'; return main; -}); +})); diff --git a/test/form/samples/json-parse-is-not-pure/_expected/es.js b/test/form/samples/json-parse-is-not-pure/_expected/es.js index 6c8e625ed61..8223400baae 100644 --- a/test/form/samples/json-parse-is-not-pure/_expected/es.js +++ b/test/form/samples/json-parse-is-not-pure/_expected/es.js @@ -7,4 +7,4 @@ var main = (input) => { } }; -export default main; +export { main as default }; diff --git a/test/form/samples/json-parse-is-not-pure/_expected/iife.js b/test/form/samples/json-parse-is-not-pure/_expected/iife.js index 5eaf4240172..3f9a88701d8 100644 --- a/test/form/samples/json-parse-is-not-pure/_expected/iife.js +++ b/test/form/samples/json-parse-is-not-pure/_expected/iife.js @@ -12,4 +12,4 @@ var myBundle = (function () { return main; -}()); +})(); diff --git a/test/form/samples/json-parse-is-not-pure/_expected/system.js b/test/form/samples/json-parse-is-not-pure/_expected/system.js index e3ad17667ec..dc36fbe5c18 100644 --- a/test/form/samples/json-parse-is-not-pure/_expected/system.js +++ b/test/form/samples/json-parse-is-not-pure/_expected/system.js @@ -1,9 +1,9 @@ -System.register('myBundle', [], function (exports) { +System.register('myBundle', [], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - var main = exports('default', (input) => { + var main = exports("default", (input) => { try { JSON.parse(input); return true; @@ -12,6 +12,6 @@ System.register('myBundle', [], function (exports) { } }); - } + }) }; -}); +})); diff --git a/test/form/samples/json-parse-is-not-pure/_expected/umd.js b/test/form/samples/json-parse-is-not-pure/_expected/umd.js index 7d4e78d64e6..08d08153c69 100644 --- a/test/form/samples/json-parse-is-not-pure/_expected/umd.js +++ b/test/form/samples/json-parse-is-not-pure/_expected/umd.js @@ -2,7 +2,7 @@ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.myBundle = factory()); -}(this, (function () { 'use strict'; +})(this, (function () { 'use strict'; var main = (input) => { try { @@ -15,4 +15,4 @@ return main; -}))); +})); diff --git a/test/form/samples/json-stringify-is-not-pure/_config.js b/test/form/samples/json-stringify-is-not-pure/_config.js index 1d840390ca2..9573e383bfa 100644 --- a/test/form/samples/json-stringify-is-not-pure/_config.js +++ b/test/form/samples/json-stringify-is-not-pure/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'JSON.stringify is not pure as it can throw on circular structures', options: { output: { name: 'myBundle' } } -}; +}); diff --git a/test/form/samples/json-stringify-is-not-pure/_expected/amd.js b/test/form/samples/json-stringify-is-not-pure/_expected/amd.js index fe0568ca3ef..51a64fb8dd8 100644 --- a/test/form/samples/json-stringify-is-not-pure/_expected/amd.js +++ b/test/form/samples/json-stringify-is-not-pure/_expected/amd.js @@ -1,4 +1,4 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; var main = (input) => { try { @@ -11,4 +11,4 @@ define(function () { 'use strict'; return main; -}); +})); diff --git a/test/form/samples/json-stringify-is-not-pure/_expected/es.js b/test/form/samples/json-stringify-is-not-pure/_expected/es.js index 8228a4a9e8c..c5f3b695787 100644 --- a/test/form/samples/json-stringify-is-not-pure/_expected/es.js +++ b/test/form/samples/json-stringify-is-not-pure/_expected/es.js @@ -7,4 +7,4 @@ var main = (input) => { } }; -export default main; +export { main as default }; diff --git a/test/form/samples/json-stringify-is-not-pure/_expected/iife.js b/test/form/samples/json-stringify-is-not-pure/_expected/iife.js index 061b3f221fe..96425d5faae 100644 --- a/test/form/samples/json-stringify-is-not-pure/_expected/iife.js +++ b/test/form/samples/json-stringify-is-not-pure/_expected/iife.js @@ -12,4 +12,4 @@ var myBundle = (function () { return main; -}()); +})(); diff --git a/test/form/samples/json-stringify-is-not-pure/_expected/system.js b/test/form/samples/json-stringify-is-not-pure/_expected/system.js index 2b241dd2fe9..41ba13212a9 100644 --- a/test/form/samples/json-stringify-is-not-pure/_expected/system.js +++ b/test/form/samples/json-stringify-is-not-pure/_expected/system.js @@ -1,9 +1,9 @@ -System.register('myBundle', [], function (exports) { +System.register('myBundle', [], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - var main = exports('default', (input) => { + var main = exports("default", (input) => { try { JSON.stringify(input); return true; @@ -12,6 +12,6 @@ System.register('myBundle', [], function (exports) { } }); - } + }) }; -}); +})); diff --git a/test/form/samples/json-stringify-is-not-pure/_expected/umd.js b/test/form/samples/json-stringify-is-not-pure/_expected/umd.js index 27843272ca0..a43b6b6dfab 100644 --- a/test/form/samples/json-stringify-is-not-pure/_expected/umd.js +++ b/test/form/samples/json-stringify-is-not-pure/_expected/umd.js @@ -2,7 +2,7 @@ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.myBundle = factory()); -}(this, (function () { 'use strict'; +})(this, (function () { 'use strict'; var main = (input) => { try { @@ -15,4 +15,4 @@ return main; -}))); +})); diff --git a/test/form/samples/jsx/preserves-jsx-attributes/_config.js b/test/form/samples/jsx/preserves-jsx-attributes/_config.js new file mode 100644 index 00000000000..741ed769f87 --- /dev/null +++ b/test/form/samples/jsx/preserves-jsx-attributes/_config.js @@ -0,0 +1,7 @@ +module.exports = defineTest({ + description: 'preserves JSX with string attributes output', + options: { + external: ['react'], + jsx: 'preserve' + } +}); diff --git a/test/form/samples/jsx/preserves-jsx-attributes/_expected.js b/test/form/samples/jsx/preserves-jsx-attributes/_expected.js new file mode 100644 index 00000000000..652f261869c --- /dev/null +++ b/test/form/samples/jsx/preserves-jsx-attributes/_expected.js @@ -0,0 +1,21 @@ +const Foo$2 = () => {}; +const value$2 = 'value 1'; +console.log(Foo$2, value$2); + +const Foo$1 = () => {}; +const value$1 = 'value 2'; +console.log(Foo$1, value$1); + +const Foo = () => {}; +const value = 'value 3'; +console.log(Foo, value); + +const result = + fragment=<> +/>; + +export { result }; diff --git a/test/form/samples/jsx/preserves-jsx-attributes/dep1.js b/test/form/samples/jsx/preserves-jsx-attributes/dep1.js new file mode 100644 index 00000000000..7e4f005d564 --- /dev/null +++ b/test/form/samples/jsx/preserves-jsx-attributes/dep1.js @@ -0,0 +1,3 @@ +export const Foo = () => {}; +export const value = 'value 1'; +console.log(Foo, value); diff --git a/test/form/samples/jsx/preserves-jsx-attributes/dep2.js b/test/form/samples/jsx/preserves-jsx-attributes/dep2.js new file mode 100644 index 00000000000..697b1397701 --- /dev/null +++ b/test/form/samples/jsx/preserves-jsx-attributes/dep2.js @@ -0,0 +1,3 @@ +export const Foo = () => {}; +export const value = 'value 2'; +console.log(Foo, value); diff --git a/test/form/samples/jsx/preserves-jsx-attributes/dep3.js b/test/form/samples/jsx/preserves-jsx-attributes/dep3.js new file mode 100644 index 00000000000..d80368ea8cf --- /dev/null +++ b/test/form/samples/jsx/preserves-jsx-attributes/dep3.js @@ -0,0 +1,3 @@ +export const Foo = () => {}; +export const value = 'value 3'; +console.log(Foo, value); diff --git a/test/form/samples/jsx/preserves-jsx-attributes/main.js b/test/form/samples/jsx/preserves-jsx-attributes/main.js new file mode 100644 index 00000000000..2297bc014f8 --- /dev/null +++ b/test/form/samples/jsx/preserves-jsx-attributes/main.js @@ -0,0 +1,11 @@ +import './dep1.js'; +import { Foo, value } from './dep2.js'; +import './dep3.js'; + +export const result = + fragment=<> +/>; diff --git a/test/form/samples/jsx/preserves-jsx-child/_config.js b/test/form/samples/jsx/preserves-jsx-child/_config.js new file mode 100644 index 00000000000..6eb31e3795c --- /dev/null +++ b/test/form/samples/jsx/preserves-jsx-child/_config.js @@ -0,0 +1,7 @@ +module.exports = defineTest({ + description: 'preserves JSX children', + options: { + external: ['react'], + jsx: 'preserve' + } +}); diff --git a/test/form/samples/jsx/preserves-jsx-child/_expected.js b/test/form/samples/jsx/preserves-jsx-child/_expected.js new file mode 100644 index 00000000000..151374d5c7b --- /dev/null +++ b/test/form/samples/jsx/preserves-jsx-child/_expected.js @@ -0,0 +1,8 @@ +const Foo$2 = 'wrong Foo 1'; +console.log(Foo$2); + +const Foo$1 = () => {}; +console.log(); + +const Foo = 'wrong Foo 2'; +console.log(Foo); diff --git a/test/form/samples/jsx/preserves-jsx-child/jsx.js b/test/form/samples/jsx/preserves-jsx-child/jsx.js new file mode 100644 index 00000000000..ed02421e9af --- /dev/null +++ b/test/form/samples/jsx/preserves-jsx-child/jsx.js @@ -0,0 +1,2 @@ +const Foo = () => {}; +console.log(); diff --git a/test/form/samples/jsx/preserves-jsx-child/main.js b/test/form/samples/jsx/preserves-jsx-child/main.js new file mode 100644 index 00000000000..dfccae85926 --- /dev/null +++ b/test/form/samples/jsx/preserves-jsx-child/main.js @@ -0,0 +1,3 @@ +import "./other1.js"; +import "./jsx.js"; +import "./other2.js"; diff --git a/test/form/samples/jsx/preserves-jsx-child/other1.js b/test/form/samples/jsx/preserves-jsx-child/other1.js new file mode 100644 index 00000000000..297f5dfcc5b --- /dev/null +++ b/test/form/samples/jsx/preserves-jsx-child/other1.js @@ -0,0 +1,2 @@ +const Foo = 'wrong Foo 1'; +console.log(Foo); diff --git a/test/form/samples/jsx/preserves-jsx-child/other2.js b/test/form/samples/jsx/preserves-jsx-child/other2.js new file mode 100644 index 00000000000..e274d4042dd --- /dev/null +++ b/test/form/samples/jsx/preserves-jsx-child/other2.js @@ -0,0 +1,2 @@ +const Foo = 'wrong Foo 2'; +console.log(Foo); diff --git a/test/form/samples/jsx/preserves-jsx-closing/_config.js b/test/form/samples/jsx/preserves-jsx-closing/_config.js new file mode 100644 index 00000000000..b5f1855f6a3 --- /dev/null +++ b/test/form/samples/jsx/preserves-jsx-closing/_config.js @@ -0,0 +1,7 @@ +module.exports = defineTest({ + description: 'preserves JSX closing element', + options: { + external: ['react'], + jsx: 'preserve' + } +}); diff --git a/test/form/samples/jsx/preserves-jsx-closing/_expected.js b/test/form/samples/jsx/preserves-jsx-closing/_expected.js new file mode 100644 index 00000000000..7b202a3cf51 --- /dev/null +++ b/test/form/samples/jsx/preserves-jsx-closing/_expected.js @@ -0,0 +1,4 @@ +const Foo = () => {}; +const result = ; + +export { result }; diff --git a/test/form/samples/jsx/preserves-jsx-closing/main.js b/test/form/samples/jsx/preserves-jsx-closing/main.js new file mode 100644 index 00000000000..9c2716421ca --- /dev/null +++ b/test/form/samples/jsx/preserves-jsx-closing/main.js @@ -0,0 +1,2 @@ +const Foo = () => {}; +export const result = ; diff --git a/test/form/samples/jsx/preserves-jsx-empty-expression/_config.js b/test/form/samples/jsx/preserves-jsx-empty-expression/_config.js new file mode 100644 index 00000000000..1563f600507 --- /dev/null +++ b/test/form/samples/jsx/preserves-jsx-empty-expression/_config.js @@ -0,0 +1,7 @@ +module.exports = defineTest({ + description: 'preserves JSX output', + options: { + external: ['react'], + jsx: 'preserve' + } +}); diff --git a/test/form/samples/jsx/preserves-jsx-empty-expression/_expected.js b/test/form/samples/jsx/preserves-jsx-empty-expression/_expected.js new file mode 100644 index 00000000000..f450ad4b610 --- /dev/null +++ b/test/form/samples/jsx/preserves-jsx-empty-expression/_expected.js @@ -0,0 +1,4 @@ +const Foo = () => {}; +const result = {/*Wohoo*/}; + +export { result }; diff --git a/test/form/samples/jsx/preserves-jsx-empty-expression/main.js b/test/form/samples/jsx/preserves-jsx-empty-expression/main.js new file mode 100644 index 00000000000..d37a6f1949a --- /dev/null +++ b/test/form/samples/jsx/preserves-jsx-empty-expression/main.js @@ -0,0 +1,2 @@ +const Foo = () => {}; +export const result = {/*Wohoo*/}; diff --git a/test/form/samples/jsx/preserves-jsx-expression/_config.js b/test/form/samples/jsx/preserves-jsx-expression/_config.js new file mode 100644 index 00000000000..5d94a414623 --- /dev/null +++ b/test/form/samples/jsx/preserves-jsx-expression/_config.js @@ -0,0 +1,7 @@ +module.exports = defineTest({ + description: 'preserves JSX expressions', + options: { + external: ['react'], + jsx: 'preserve' + } +}); diff --git a/test/form/samples/jsx/preserves-jsx-expression/_expected.js b/test/form/samples/jsx/preserves-jsx-expression/_expected.js new file mode 100644 index 00000000000..09dcebdd9d3 --- /dev/null +++ b/test/form/samples/jsx/preserves-jsx-expression/_expected.js @@ -0,0 +1,13 @@ +const element$2 = 'element 1'; +console.log(element$2); + +const element$1 = 'element 2'; +console.log(element$1); + +const element = 'element 3'; +console.log(element); + +const Foo = () => {}; +const result = {'test' + element$1}; + +export { result }; diff --git a/test/form/samples/jsx/preserves-jsx-expression/dep1.js b/test/form/samples/jsx/preserves-jsx-expression/dep1.js new file mode 100644 index 00000000000..dd37912ccca --- /dev/null +++ b/test/form/samples/jsx/preserves-jsx-expression/dep1.js @@ -0,0 +1,2 @@ +export const element = 'element 1'; +console.log(element); diff --git a/test/form/samples/jsx/preserves-jsx-expression/dep2.js b/test/form/samples/jsx/preserves-jsx-expression/dep2.js new file mode 100644 index 00000000000..a9713f489a9 --- /dev/null +++ b/test/form/samples/jsx/preserves-jsx-expression/dep2.js @@ -0,0 +1,2 @@ +export const element = 'element 2'; +console.log(element); diff --git a/test/form/samples/jsx/preserves-jsx-expression/dep3.js b/test/form/samples/jsx/preserves-jsx-expression/dep3.js new file mode 100644 index 00000000000..de220a40890 --- /dev/null +++ b/test/form/samples/jsx/preserves-jsx-expression/dep3.js @@ -0,0 +1,2 @@ +export const element = 'element 3'; +console.log(element); diff --git a/test/form/samples/jsx/preserves-jsx-expression/main.js b/test/form/samples/jsx/preserves-jsx-expression/main.js new file mode 100644 index 00000000000..910b3247986 --- /dev/null +++ b/test/form/samples/jsx/preserves-jsx-expression/main.js @@ -0,0 +1,6 @@ +import "./dep1.js"; +import { element } from "./dep2.js"; +import "./dep3.js"; + +const Foo = () => {}; +export const result = {'test' + element}; diff --git a/test/form/samples/jsx/preserves-jsx-fragment/_config.js b/test/form/samples/jsx/preserves-jsx-fragment/_config.js new file mode 100644 index 00000000000..1563f600507 --- /dev/null +++ b/test/form/samples/jsx/preserves-jsx-fragment/_config.js @@ -0,0 +1,7 @@ +module.exports = defineTest({ + description: 'preserves JSX output', + options: { + external: ['react'], + jsx: 'preserve' + } +}); diff --git a/test/form/samples/jsx/preserves-jsx-fragment/_expected.js b/test/form/samples/jsx/preserves-jsx-fragment/_expected.js new file mode 100644 index 00000000000..594a20cbde1 --- /dev/null +++ b/test/form/samples/jsx/preserves-jsx-fragment/_expected.js @@ -0,0 +1,4 @@ +const Foo = () => {}; +const result = <>; + +export { result }; diff --git a/test/form/samples/jsx/preserves-jsx-fragment/main.js b/test/form/samples/jsx/preserves-jsx-fragment/main.js new file mode 100644 index 00000000000..14a6baf4604 --- /dev/null +++ b/test/form/samples/jsx/preserves-jsx-fragment/main.js @@ -0,0 +1,2 @@ +const Foo = () => {}; +export const result = <>; diff --git a/test/form/samples/jsx/preserves-jsx-member-expression/_config.js b/test/form/samples/jsx/preserves-jsx-member-expression/_config.js new file mode 100644 index 00000000000..2b51fdc7286 --- /dev/null +++ b/test/form/samples/jsx/preserves-jsx-member-expression/_config.js @@ -0,0 +1,7 @@ +module.exports = defineTest({ + description: 'preserves JSX member expressions', + options: { + external: ['react'], + jsx: 'preserve' + } +}); diff --git a/test/form/samples/jsx/preserves-jsx-member-expression/_expected.js b/test/form/samples/jsx/preserves-jsx-member-expression/_expected.js new file mode 100644 index 00000000000..e4db00ef475 --- /dev/null +++ b/test/form/samples/jsx/preserves-jsx-member-expression/_expected.js @@ -0,0 +1,9 @@ +const obj = { + Foo: () => {}, + bar: { Baz: () => {} } +}; + +const result1 = ; +const result2 = ; + +export { result1, result2 }; diff --git a/test/form/samples/jsx/preserves-jsx-member-expression/main.js b/test/form/samples/jsx/preserves-jsx-member-expression/main.js new file mode 100644 index 00000000000..04e40c09d07 --- /dev/null +++ b/test/form/samples/jsx/preserves-jsx-member-expression/main.js @@ -0,0 +1,7 @@ +const obj = { + Foo: () => {}, + bar: { Baz: () => {} } +}; + +export const result1 = ; +export const result2 = ; diff --git a/test/form/samples/jsx/preserves-jsx-self-closing/_config.js b/test/form/samples/jsx/preserves-jsx-self-closing/_config.js new file mode 100644 index 00000000000..a94325994ee --- /dev/null +++ b/test/form/samples/jsx/preserves-jsx-self-closing/_config.js @@ -0,0 +1,6 @@ +module.exports = defineTest({ + description: 'preserves self-closing JSX elements', + options: { + jsx: 'preserve' + } +}); diff --git a/test/form/samples/jsx/preserves-jsx-self-closing/_expected.js b/test/form/samples/jsx/preserves-jsx-self-closing/_expected.js new file mode 100644 index 00000000000..5764a03cb8e --- /dev/null +++ b/test/form/samples/jsx/preserves-jsx-self-closing/_expected.js @@ -0,0 +1,4 @@ +const Foo = () => {}; +const result = ; + +export { result }; diff --git a/test/form/samples/jsx/preserves-jsx-self-closing/main.js b/test/form/samples/jsx/preserves-jsx-self-closing/main.js new file mode 100644 index 00000000000..1e56ff70298 --- /dev/null +++ b/test/form/samples/jsx/preserves-jsx-self-closing/main.js @@ -0,0 +1,2 @@ +const Foo = () => {}; +export const result = ; diff --git a/test/form/samples/jsx/preserves-jsx-spread-attribute/_config.js b/test/form/samples/jsx/preserves-jsx-spread-attribute/_config.js new file mode 100644 index 00000000000..5554b472072 --- /dev/null +++ b/test/form/samples/jsx/preserves-jsx-spread-attribute/_config.js @@ -0,0 +1,7 @@ +module.exports = defineTest({ + description: 'preserves JSX spread attributes', + options: { + external: ['react'], + jsx: 'preserve' + } +}); diff --git a/test/form/samples/jsx/preserves-jsx-spread-attribute/_expected.js b/test/form/samples/jsx/preserves-jsx-spread-attribute/_expected.js new file mode 100644 index 00000000000..382aa99a5cf --- /dev/null +++ b/test/form/samples/jsx/preserves-jsx-spread-attribute/_expected.js @@ -0,0 +1,20 @@ +const obj$2 = { value1: true }; +console.log(obj$2); + +const obj$1 = { value2: true }; +console.log(obj$1); + +const obj = { value3: true }; +console.log(obj); + +const Foo = () => {}; +const result1 = ; +const result2 = ; +const result3 = ; + +export { result1, result2, result3 }; diff --git a/test/form/samples/jsx/preserves-jsx-spread-attribute/dep1.js b/test/form/samples/jsx/preserves-jsx-spread-attribute/dep1.js new file mode 100644 index 00000000000..658d5636c5a --- /dev/null +++ b/test/form/samples/jsx/preserves-jsx-spread-attribute/dep1.js @@ -0,0 +1,2 @@ +export const obj = { value1: true }; +console.log(obj); diff --git a/test/form/samples/jsx/preserves-jsx-spread-attribute/dep2.js b/test/form/samples/jsx/preserves-jsx-spread-attribute/dep2.js new file mode 100644 index 00000000000..bdbe905d08d --- /dev/null +++ b/test/form/samples/jsx/preserves-jsx-spread-attribute/dep2.js @@ -0,0 +1,2 @@ +export const obj = { value2: true }; +console.log(obj); diff --git a/test/form/samples/jsx/preserves-jsx-spread-attribute/dep3.js b/test/form/samples/jsx/preserves-jsx-spread-attribute/dep3.js new file mode 100644 index 00000000000..f18273863e3 --- /dev/null +++ b/test/form/samples/jsx/preserves-jsx-spread-attribute/dep3.js @@ -0,0 +1,2 @@ +export const obj = { value3: true }; +console.log(obj); diff --git a/test/form/samples/jsx/preserves-jsx-spread-attribute/main.js b/test/form/samples/jsx/preserves-jsx-spread-attribute/main.js new file mode 100644 index 00000000000..22953c47609 --- /dev/null +++ b/test/form/samples/jsx/preserves-jsx-spread-attribute/main.js @@ -0,0 +1,13 @@ +import './dep1.js'; +import { obj } from './dep2.js'; +import './dep3.js'; + +const Foo = () => {}; +export const result1 = ; +export const result2 = ; +export const result3 = ; diff --git a/test/form/samples/jsx/preserves-jsx-spread-child/_config.js b/test/form/samples/jsx/preserves-jsx-spread-child/_config.js new file mode 100644 index 00000000000..e846a8043e6 --- /dev/null +++ b/test/form/samples/jsx/preserves-jsx-spread-child/_config.js @@ -0,0 +1,9 @@ +module.exports = defineTest({ + description: 'preserves JSX spread children', + options: { + external: ['react'], + jsx: 'preserve' + }, + // apparently, acorn-jsx does not support spread children + verifyAst: false +}); diff --git a/test/form/samples/jsx/preserves-jsx-spread-child/_expected.js b/test/form/samples/jsx/preserves-jsx-spread-child/_expected.js new file mode 100644 index 00000000000..139d1277ca3 --- /dev/null +++ b/test/form/samples/jsx/preserves-jsx-spread-child/_expected.js @@ -0,0 +1,14 @@ +const spread$2 = ['spread 1']; +console.log(spread$2); + +const spread$1 = ['spread 2']; +console.log(spread$1); + +const spread = ['spread 3']; +console.log(spread); + +const Foo = () => {}; +const element = {...spread$1}; +const fragment = <>{...spread$1}; + +export { element, fragment }; diff --git a/test/form/samples/jsx/preserves-jsx-spread-child/dep1.js b/test/form/samples/jsx/preserves-jsx-spread-child/dep1.js new file mode 100644 index 00000000000..53572b805ec --- /dev/null +++ b/test/form/samples/jsx/preserves-jsx-spread-child/dep1.js @@ -0,0 +1,2 @@ +export const spread = ['spread 1']; +console.log(spread); diff --git a/test/form/samples/jsx/preserves-jsx-spread-child/dep2.js b/test/form/samples/jsx/preserves-jsx-spread-child/dep2.js new file mode 100644 index 00000000000..bbea244bcfb --- /dev/null +++ b/test/form/samples/jsx/preserves-jsx-spread-child/dep2.js @@ -0,0 +1,2 @@ +export const spread = ['spread 2']; +console.log(spread); diff --git a/test/form/samples/jsx/preserves-jsx-spread-child/dep3.js b/test/form/samples/jsx/preserves-jsx-spread-child/dep3.js new file mode 100644 index 00000000000..666d48094d1 --- /dev/null +++ b/test/form/samples/jsx/preserves-jsx-spread-child/dep3.js @@ -0,0 +1,2 @@ +export const spread = ['spread 3']; +console.log(spread); diff --git a/test/form/samples/jsx/preserves-jsx-spread-child/main.js b/test/form/samples/jsx/preserves-jsx-spread-child/main.js new file mode 100644 index 00000000000..10e217564e0 --- /dev/null +++ b/test/form/samples/jsx/preserves-jsx-spread-child/main.js @@ -0,0 +1,6 @@ +import './dep1.js'; +import { spread } from './dep2.js'; +import './dep3.js'; +const Foo = () => {}; +export const element = {...spread}; +export const fragment = <>{...spread}; diff --git a/test/form/samples/jsx/preserves-jsx-text/_config.js b/test/form/samples/jsx/preserves-jsx-text/_config.js new file mode 100644 index 00000000000..74acdb423be --- /dev/null +++ b/test/form/samples/jsx/preserves-jsx-text/_config.js @@ -0,0 +1,7 @@ +module.exports = defineTest({ + description: 'preserves JSX text', + options: { + external: ['react'], + jsx: 'preserve' + } +}); diff --git a/test/form/samples/jsx/preserves-jsx-text/_expected.js b/test/form/samples/jsx/preserves-jsx-text/_expected.js new file mode 100644 index 00000000000..3e62794eb38 --- /dev/null +++ b/test/form/samples/jsx/preserves-jsx-text/_expected.js @@ -0,0 +1,5 @@ +const Foo = () => {}; +const element = some&\text; +const fragment = <>other&\text; + +export { element, fragment }; diff --git a/test/form/samples/jsx/preserves-jsx-text/main.js b/test/form/samples/jsx/preserves-jsx-text/main.js new file mode 100644 index 00000000000..e8e2d995543 --- /dev/null +++ b/test/form/samples/jsx/preserves-jsx-text/main.js @@ -0,0 +1,3 @@ +const Foo = () => {}; +export const element = some&\text; +export const fragment = <>other&\text; diff --git a/test/form/samples/jsx/preserves-native-elements/_config.js b/test/form/samples/jsx/preserves-native-elements/_config.js new file mode 100644 index 00000000000..d64ae8ee707 --- /dev/null +++ b/test/form/samples/jsx/preserves-native-elements/_config.js @@ -0,0 +1,6 @@ +module.exports = defineTest({ + description: 'preserves native JSX elements', + options: { + jsx: 'preserve' + } +}); diff --git a/test/form/samples/jsx/preserves-native-elements/_expected.js b/test/form/samples/jsx/preserves-native-elements/_expected.js new file mode 100644 index 00000000000..c0427dd888e --- /dev/null +++ b/test/form/samples/jsx/preserves-native-elements/_expected.js @@ -0,0 +1,10 @@ +const div$1 = 'wrong div 1'; +const span$1 = 'wrong span 1'; +console.log(div$1, span$1); + +console.log(
); +console.log(
); + +const div = 'wrong div 2'; +const span = 'wrong span 2'; +console.log(div, span); diff --git a/test/form/samples/jsx/preserves-native-elements/jsx.js b/test/form/samples/jsx/preserves-native-elements/jsx.js new file mode 100644 index 00000000000..02159671af3 --- /dev/null +++ b/test/form/samples/jsx/preserves-native-elements/jsx.js @@ -0,0 +1,5 @@ +const div = 'wrong div'; +const span = 'wrong span'; + +console.log(
); +console.log(
); diff --git a/test/form/samples/jsx/preserves-native-elements/main.js b/test/form/samples/jsx/preserves-native-elements/main.js new file mode 100644 index 00000000000..dfccae85926 --- /dev/null +++ b/test/form/samples/jsx/preserves-native-elements/main.js @@ -0,0 +1,3 @@ +import "./other1.js"; +import "./jsx.js"; +import "./other2.js"; diff --git a/test/form/samples/jsx/preserves-native-elements/other1.js b/test/form/samples/jsx/preserves-native-elements/other1.js new file mode 100644 index 00000000000..d607c512add --- /dev/null +++ b/test/form/samples/jsx/preserves-native-elements/other1.js @@ -0,0 +1,3 @@ +const div = 'wrong div 1'; +const span = 'wrong span 1'; +console.log(div, span); diff --git a/test/form/samples/jsx/preserves-native-elements/other2.js b/test/form/samples/jsx/preserves-native-elements/other2.js new file mode 100644 index 00000000000..25f1a5e7ad7 --- /dev/null +++ b/test/form/samples/jsx/preserves-native-elements/other2.js @@ -0,0 +1,3 @@ +const div = 'wrong div 2'; +const span = 'wrong span 2'; +console.log(div, span); diff --git a/test/form/samples/jsx/preserves-react-global/_config.js b/test/form/samples/jsx/preserves-react-global/_config.js new file mode 100644 index 00000000000..c694db34942 --- /dev/null +++ b/test/form/samples/jsx/preserves-react-global/_config.js @@ -0,0 +1,10 @@ +module.exports = defineTest({ + description: 'preserves React variable when preserving JSX output', + options: { + jsx: { + factory: 'React.createElement', + fragmentFactory: 'React.Fragment', + mode: 'preserve' + } + } +}); diff --git a/test/form/samples/jsx/preserves-react-global/_expected.js b/test/form/samples/jsx/preserves-react-global/_expected.js new file mode 100644 index 00000000000..62f669e6899 --- /dev/null +++ b/test/form/samples/jsx/preserves-react-global/_expected.js @@ -0,0 +1,10 @@ +const Foo$2 = () => {}; +const React$2 = () => {}; +console.log(Foo$2, React$2); + +const Foo$1 = () => {}; +console.log(); + +const Foo = () => {}; +const React$1 = () => {}; +console.log(Foo, React$1); diff --git a/test/form/samples/jsx/preserves-react-global/jsx.js b/test/form/samples/jsx/preserves-react-global/jsx.js new file mode 100644 index 00000000000..4b5671bbbac --- /dev/null +++ b/test/form/samples/jsx/preserves-react-global/jsx.js @@ -0,0 +1,2 @@ +const Foo = () => {}; +console.log(); diff --git a/test/form/samples/jsx/preserves-react-global/main.js b/test/form/samples/jsx/preserves-react-global/main.js new file mode 100644 index 00000000000..dfccae85926 --- /dev/null +++ b/test/form/samples/jsx/preserves-react-global/main.js @@ -0,0 +1,3 @@ +import "./other1.js"; +import "./jsx.js"; +import "./other2.js"; diff --git a/test/form/samples/jsx/preserves-react-global/other1.js b/test/form/samples/jsx/preserves-react-global/other1.js new file mode 100644 index 00000000000..dc7480c221c --- /dev/null +++ b/test/form/samples/jsx/preserves-react-global/other1.js @@ -0,0 +1,3 @@ +const Foo = () => {}; +const React = () => {}; +console.log(Foo, React); diff --git a/test/form/samples/jsx/preserves-react-global/other2.js b/test/form/samples/jsx/preserves-react-global/other2.js new file mode 100644 index 00000000000..dc7480c221c --- /dev/null +++ b/test/form/samples/jsx/preserves-react-global/other2.js @@ -0,0 +1,3 @@ +const Foo = () => {}; +const React = () => {}; +console.log(Foo, React); diff --git a/test/form/samples/jsx/preserves-react-internal/_config.js b/test/form/samples/jsx/preserves-react-internal/_config.js new file mode 100644 index 00000000000..4601d0902f0 --- /dev/null +++ b/test/form/samples/jsx/preserves-react-internal/_config.js @@ -0,0 +1,11 @@ +const path = require('node:path'); + +module.exports = defineTest({ + description: 'preserves internal React variable when preserving JSX output', + options: { + jsx: { + importSource: path.join(__dirname, 'react.js'), + preset: 'preserve-react' + } + } +}); diff --git a/test/form/samples/jsx/preserves-react-internal/_expected.js b/test/form/samples/jsx/preserves-react-internal/_expected.js new file mode 100644 index 00000000000..1d4e574bb0e --- /dev/null +++ b/test/form/samples/jsx/preserves-react-internal/_expected.js @@ -0,0 +1,16 @@ +const Foo$2 = () => {}; +const React$2 = () => {}; +console.log(Foo$2, React$2); + +var React = { + createElement() { + console.log('createElement'); + } +}; + +const Foo$1 = () => {}; +console.log(); + +const Foo = () => {}; +const React$1 = () => {}; +console.log(Foo, React$1); diff --git a/test/form/samples/jsx/preserves-react-internal/jsx.js b/test/form/samples/jsx/preserves-react-internal/jsx.js new file mode 100644 index 00000000000..4b5671bbbac --- /dev/null +++ b/test/form/samples/jsx/preserves-react-internal/jsx.js @@ -0,0 +1,2 @@ +const Foo = () => {}; +console.log(); diff --git a/test/form/samples/jsx/preserves-react-internal/main.js b/test/form/samples/jsx/preserves-react-internal/main.js new file mode 100644 index 00000000000..dfccae85926 --- /dev/null +++ b/test/form/samples/jsx/preserves-react-internal/main.js @@ -0,0 +1,3 @@ +import "./other1.js"; +import "./jsx.js"; +import "./other2.js"; diff --git a/test/form/samples/jsx/preserves-react-internal/other1.js b/test/form/samples/jsx/preserves-react-internal/other1.js new file mode 100644 index 00000000000..dc7480c221c --- /dev/null +++ b/test/form/samples/jsx/preserves-react-internal/other1.js @@ -0,0 +1,3 @@ +const Foo = () => {}; +const React = () => {}; +console.log(Foo, React); diff --git a/test/form/samples/jsx/preserves-react-internal/other2.js b/test/form/samples/jsx/preserves-react-internal/other2.js new file mode 100644 index 00000000000..dc7480c221c --- /dev/null +++ b/test/form/samples/jsx/preserves-react-internal/other2.js @@ -0,0 +1,3 @@ +const Foo = () => {}; +const React = () => {}; +console.log(Foo, React); diff --git a/test/form/samples/jsx/preserves-react-internal/react.js b/test/form/samples/jsx/preserves-react-internal/react.js new file mode 100644 index 00000000000..62d36813017 --- /dev/null +++ b/test/form/samples/jsx/preserves-react-internal/react.js @@ -0,0 +1,5 @@ +export default { + createElement() { + console.log('createElement'); + } +}; diff --git a/test/form/samples/jsx/preserves-react/_config.js b/test/form/samples/jsx/preserves-react/_config.js new file mode 100644 index 00000000000..ca4145a5e30 --- /dev/null +++ b/test/form/samples/jsx/preserves-react/_config.js @@ -0,0 +1,7 @@ +module.exports = defineTest({ + description: 'preserves React variable when preserving JSX output', + options: { + external: ['react'], + jsx: 'preserve-react' + } +}); diff --git a/test/form/samples/jsx/preserves-react/_expected.js b/test/form/samples/jsx/preserves-react/_expected.js new file mode 100644 index 00000000000..62586a3c8a3 --- /dev/null +++ b/test/form/samples/jsx/preserves-react/_expected.js @@ -0,0 +1,12 @@ +import React from 'react'; + +const Foo$2 = () => {}; +const React$2 = () => {}; +console.log(Foo$2, React$2); + +const Foo$1 = () => {}; +console.log(); + +const Foo = () => {}; +const React$1 = () => {}; +console.log(Foo, React$1); diff --git a/test/form/samples/jsx/preserves-react/jsx.js b/test/form/samples/jsx/preserves-react/jsx.js new file mode 100644 index 00000000000..bb22f6edde5 --- /dev/null +++ b/test/form/samples/jsx/preserves-react/jsx.js @@ -0,0 +1,4 @@ +import React from "react"; + +const Foo = () => {}; +console.log(); diff --git a/test/form/samples/jsx/preserves-react/main.js b/test/form/samples/jsx/preserves-react/main.js new file mode 100644 index 00000000000..dfccae85926 --- /dev/null +++ b/test/form/samples/jsx/preserves-react/main.js @@ -0,0 +1,3 @@ +import "./other1.js"; +import "./jsx.js"; +import "./other2.js"; diff --git a/test/form/samples/jsx/preserves-react/other1.js b/test/form/samples/jsx/preserves-react/other1.js new file mode 100644 index 00000000000..dc7480c221c --- /dev/null +++ b/test/form/samples/jsx/preserves-react/other1.js @@ -0,0 +1,3 @@ +const Foo = () => {}; +const React = () => {}; +console.log(Foo, React); diff --git a/test/form/samples/jsx/preserves-react/other2.js b/test/form/samples/jsx/preserves-react/other2.js new file mode 100644 index 00000000000..dc7480c221c --- /dev/null +++ b/test/form/samples/jsx/preserves-react/other2.js @@ -0,0 +1,3 @@ +const Foo = () => {}; +const React = () => {}; +console.log(Foo, React); diff --git a/test/form/samples/jsx/react-jsx-declarations-with-key-attribute/_config.js b/test/form/samples/jsx/react-jsx-declarations-with-key-attribute/_config.js new file mode 100644 index 00000000000..f3d4e709bb0 --- /dev/null +++ b/test/form/samples/jsx/react-jsx-declarations-with-key-attribute/_config.js @@ -0,0 +1,8 @@ +module.exports = defineTest({ + description: + 'JSX with react-jsx uses correct semicolon positions in variable declarations with key attributes', + options: { + external: ['react/jsx-runtime'], + jsx: 'react-jsx' + } +}); diff --git a/test/form/samples/jsx/react-jsx-declarations-with-key-attribute/_expected.js b/test/form/samples/jsx/react-jsx-declarations-with-key-attribute/_expected.js new file mode 100644 index 00000000000..c376f983607 --- /dev/null +++ b/test/form/samples/jsx/react-jsx-declarations-with-key-attribute/_expected.js @@ -0,0 +1,11 @@ +import { jsx } from 'react/jsx-runtime'; + +/*#__PURE__*/jsx(Foo, {}, 123); +const b = /*#__PURE__*/jsx(Foo, {}, 123); +/*#__PURE__*/jsx(Foo, { a: "1", b: "2" }, 123); +const d = /*#__PURE__*/jsx(Foo, { a: "1", b: "2" }, 123); +/*#__PURE__*/jsx(Foo, {}, 123); +const f = /*#__PURE__*/jsx(Foo, {}, 123); +/*#__PURE__*/jsx(Foo, { a: "1", b: "2" }, 123); +const h = /*#__PURE__*/jsx(Foo, { a: "1", b: "2" }, 123); +console.log(b,d,f,h); diff --git a/test/form/samples/jsx/react-jsx-declarations-with-key-attribute/main.js b/test/form/samples/jsx/react-jsx-declarations-with-key-attribute/main.js new file mode 100644 index 00000000000..2581b06601d --- /dev/null +++ b/test/form/samples/jsx/react-jsx-declarations-with-key-attribute/main.js @@ -0,0 +1,9 @@ +const a = +const b = +const c = +const d = +const e = ; +const f = ; +const g = ; +const h = ; +console.log(b,d,f,h); diff --git a/test/form/samples/jsx/transpiles-automatic-with-defaults/_config.js b/test/form/samples/jsx/transpiles-automatic-with-defaults/_config.js new file mode 100644 index 00000000000..77000dc3995 --- /dev/null +++ b/test/form/samples/jsx/transpiles-automatic-with-defaults/_config.js @@ -0,0 +1,7 @@ +module.exports = defineTest({ + description: 'transpiles JSX for react', + options: { + external: ['react', 'react/jsx-runtime'], + jsx: { mode: 'automatic' } + } +}); diff --git a/test/form/samples/jsx/transpiles-automatic-with-defaults/_expected.js b/test/form/samples/jsx/transpiles-automatic-with-defaults/_expected.js new file mode 100644 index 00000000000..4181ccce6f9 --- /dev/null +++ b/test/form/samples/jsx/transpiles-automatic-with-defaults/_expected.js @@ -0,0 +1,11 @@ +import { jsx, Fragment, jsxs } from 'react/jsx-runtime'; +import react from 'react'; + +const Foo = () => {}; +const obj = { key: '2' }; + +console.log(/*#__PURE__*/jsx(Foo, {})); +console.log(/*#__PURE__*/jsx(Fragment, { children: /*#__PURE__*/jsx(Foo, {}) })); +console.log(/*#__PURE__*/jsxs(Foo, { children: [/*#__PURE__*/jsx(Foo, {}), /*#__PURE__*/jsx(Foo, {})] })); +console.log(/*#__PURE__*/jsxs(Fragment, { children: [/*#__PURE__*/jsx(Foo, {}), /*#__PURE__*/jsx(Foo, {})] })); +console.log(/*#__PURE__*/react.createElement(Foo, Object.assign({}, obj, { key: "1" }))); diff --git a/test/form/samples/jsx/transpiles-automatic-with-defaults/main.js b/test/form/samples/jsx/transpiles-automatic-with-defaults/main.js new file mode 100644 index 00000000000..13f357d5f77 --- /dev/null +++ b/test/form/samples/jsx/transpiles-automatic-with-defaults/main.js @@ -0,0 +1,8 @@ +const Foo = () => {}; +const obj = { key: '2' }; + +console.log(); +console.log(<>); +console.log(); +console.log(<>); +console.log(); diff --git a/test/form/samples/jsx/transpiles-classic-with-defaults/_config.js b/test/form/samples/jsx/transpiles-classic-with-defaults/_config.js new file mode 100644 index 00000000000..61589a99124 --- /dev/null +++ b/test/form/samples/jsx/transpiles-classic-with-defaults/_config.js @@ -0,0 +1,7 @@ +module.exports = defineTest({ + description: 'transpiles JSX for react', + options: { + external: ['react', 'react/jsx-runtime'], + jsx: { mode: 'classic' } + } +}); diff --git a/test/form/samples/jsx/transpiles-classic-with-defaults/_expected.js b/test/form/samples/jsx/transpiles-classic-with-defaults/_expected.js new file mode 100644 index 00000000000..758900d85bb --- /dev/null +++ b/test/form/samples/jsx/transpiles-classic-with-defaults/_expected.js @@ -0,0 +1,8 @@ +const Foo = () => {}; +const obj = { key: '2' }; + +console.log(/*#__PURE__*/React.createElement(Foo, null)); +console.log(/*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Foo, null))); +console.log(/*#__PURE__*/React.createElement(Foo, null, /*#__PURE__*/React.createElement(Foo, null), /*#__PURE__*/React.createElement(Foo, null))); +console.log(/*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Foo, null), /*#__PURE__*/React.createElement(Foo, null))); +console.log(/*#__PURE__*/React.createElement(Foo, Object.assign({}, obj, { key: "1" }))); diff --git a/test/form/samples/jsx/transpiles-classic-with-defaults/main.js b/test/form/samples/jsx/transpiles-classic-with-defaults/main.js new file mode 100644 index 00000000000..13f357d5f77 --- /dev/null +++ b/test/form/samples/jsx/transpiles-classic-with-defaults/main.js @@ -0,0 +1,8 @@ +const Foo = () => {}; +const obj = { key: '2' }; + +console.log(); +console.log(<>); +console.log(); +console.log(<>); +console.log(); diff --git a/test/form/samples/jsx/transpiles-empty-fragment/_config.js b/test/form/samples/jsx/transpiles-empty-fragment/_config.js new file mode 100644 index 00000000000..d9c8a8452c7 --- /dev/null +++ b/test/form/samples/jsx/transpiles-empty-fragment/_config.js @@ -0,0 +1,7 @@ +module.exports = defineTest({ + description: 'transpiles JSX for react', + options: { + external: ['react', 'react/jsx-runtime'], + jsx: 'react-jsx' + } +}); diff --git a/test/form/samples/jsx/transpiles-empty-fragment/_expected.js b/test/form/samples/jsx/transpiles-empty-fragment/_expected.js new file mode 100644 index 00000000000..5fd112f7f75 --- /dev/null +++ b/test/form/samples/jsx/transpiles-empty-fragment/_expected.js @@ -0,0 +1,3 @@ +import { jsx, Fragment } from 'react/jsx-runtime'; + +console.log(/*#__PURE__*/jsx(Fragment, {})); diff --git a/test/form/samples/jsx/transpiles-empty-fragment/main.js b/test/form/samples/jsx/transpiles-empty-fragment/main.js new file mode 100644 index 00000000000..f6957f2d75b --- /dev/null +++ b/test/form/samples/jsx/transpiles-empty-fragment/main.js @@ -0,0 +1 @@ +console.log(<>); diff --git a/test/form/samples/jsx/transpiles-jsx-attributes/_config.js b/test/form/samples/jsx/transpiles-jsx-attributes/_config.js new file mode 100644 index 00000000000..6eec3cae05e --- /dev/null +++ b/test/form/samples/jsx/transpiles-jsx-attributes/_config.js @@ -0,0 +1,7 @@ +module.exports = defineTest({ + description: 'transpiles JSX with string attributes output', + options: { + external: ['react'], + jsx: 'react' + } +}); diff --git a/test/form/samples/jsx/transpiles-jsx-attributes/_expected.js b/test/form/samples/jsx/transpiles-jsx-attributes/_expected.js new file mode 100644 index 00000000000..f058ee679e1 --- /dev/null +++ b/test/form/samples/jsx/transpiles-jsx-attributes/_expected.js @@ -0,0 +1,22 @@ +import react from 'react'; + +const Foo$2 = () => {}; +const value$2 = 'value 1'; +console.log(Foo$2, value$2); + +const Foo$1 = () => {}; +const value$1 = 'value 2'; +console.log(Foo$1, value$1); + +const Foo = () => {}; +const value = 'value 3'; +console.log(Foo, value); + +const result = /*#__PURE__*/react.createElement(Foo$1, + { bar: true, + "baz:foo": "string", + "quux-nix": value$1, + element: /*#__PURE__*/react.createElement(Foo$1, null), + fragment: /*#__PURE__*/react.createElement(react.Fragment, null) }); + +export { result }; diff --git a/test/form/samples/jsx/transpiles-jsx-attributes/dep1.js b/test/form/samples/jsx/transpiles-jsx-attributes/dep1.js new file mode 100644 index 00000000000..7e4f005d564 --- /dev/null +++ b/test/form/samples/jsx/transpiles-jsx-attributes/dep1.js @@ -0,0 +1,3 @@ +export const Foo = () => {}; +export const value = 'value 1'; +console.log(Foo, value); diff --git a/test/form/samples/jsx/transpiles-jsx-attributes/dep2.js b/test/form/samples/jsx/transpiles-jsx-attributes/dep2.js new file mode 100644 index 00000000000..697b1397701 --- /dev/null +++ b/test/form/samples/jsx/transpiles-jsx-attributes/dep2.js @@ -0,0 +1,3 @@ +export const Foo = () => {}; +export const value = 'value 2'; +console.log(Foo, value); diff --git a/test/form/samples/jsx/transpiles-jsx-attributes/dep3.js b/test/form/samples/jsx/transpiles-jsx-attributes/dep3.js new file mode 100644 index 00000000000..d80368ea8cf --- /dev/null +++ b/test/form/samples/jsx/transpiles-jsx-attributes/dep3.js @@ -0,0 +1,3 @@ +export const Foo = () => {}; +export const value = 'value 3'; +console.log(Foo, value); diff --git a/test/form/samples/jsx/transpiles-jsx-attributes/main.js b/test/form/samples/jsx/transpiles-jsx-attributes/main.js new file mode 100644 index 00000000000..2297bc014f8 --- /dev/null +++ b/test/form/samples/jsx/transpiles-jsx-attributes/main.js @@ -0,0 +1,11 @@ +import './dep1.js'; +import { Foo, value } from './dep2.js'; +import './dep3.js'; + +export const result = + fragment=<> +/>; diff --git a/test/form/samples/jsx/transpiles-jsx-child/_config.js b/test/form/samples/jsx/transpiles-jsx-child/_config.js new file mode 100644 index 00000000000..66790a15999 --- /dev/null +++ b/test/form/samples/jsx/transpiles-jsx-child/_config.js @@ -0,0 +1,7 @@ +module.exports = defineTest({ + description: 'transpiles JSX children', + options: { + external: ['react'], + jsx: 'react' + } +}); diff --git a/test/form/samples/jsx/transpiles-jsx-child/_expected.js b/test/form/samples/jsx/transpiles-jsx-child/_expected.js new file mode 100644 index 00000000000..4bd347ce59f --- /dev/null +++ b/test/form/samples/jsx/transpiles-jsx-child/_expected.js @@ -0,0 +1,6 @@ +import react from 'react'; + +const Foo = () => {}; +const result = /*#__PURE__*/react.createElement(Foo, null, /*#__PURE__*/react.createElement(Foo, null)); + +export { result }; diff --git a/test/form/samples/jsx/transpiles-jsx-child/main.js b/test/form/samples/jsx/transpiles-jsx-child/main.js new file mode 100644 index 00000000000..c863c74f668 --- /dev/null +++ b/test/form/samples/jsx/transpiles-jsx-child/main.js @@ -0,0 +1,2 @@ +const Foo = () => {}; +export const result = ; diff --git a/test/form/samples/jsx/transpiles-jsx-closing/_config.js b/test/form/samples/jsx/transpiles-jsx-closing/_config.js new file mode 100644 index 00000000000..719ece5beb1 --- /dev/null +++ b/test/form/samples/jsx/transpiles-jsx-closing/_config.js @@ -0,0 +1,7 @@ +module.exports = defineTest({ + description: 'transpiles JSX closing element', + options: { + external: ['react'], + jsx: 'react' + } +}); diff --git a/test/form/samples/jsx/transpiles-jsx-closing/_expected.js b/test/form/samples/jsx/transpiles-jsx-closing/_expected.js new file mode 100644 index 00000000000..1a54860615d --- /dev/null +++ b/test/form/samples/jsx/transpiles-jsx-closing/_expected.js @@ -0,0 +1,6 @@ +import react from 'react'; + +const Foo = () => {}; +const result = /*#__PURE__*/react.createElement(Foo, null); + +export { result }; diff --git a/test/form/samples/jsx/transpiles-jsx-closing/main.js b/test/form/samples/jsx/transpiles-jsx-closing/main.js new file mode 100644 index 00000000000..9c2716421ca --- /dev/null +++ b/test/form/samples/jsx/transpiles-jsx-closing/main.js @@ -0,0 +1,2 @@ +const Foo = () => {}; +export const result = ; diff --git a/test/form/samples/jsx/transpiles-jsx-empty-expression/_config.js b/test/form/samples/jsx/transpiles-jsx-empty-expression/_config.js new file mode 100644 index 00000000000..154660bc4ed --- /dev/null +++ b/test/form/samples/jsx/transpiles-jsx-empty-expression/_config.js @@ -0,0 +1,7 @@ +module.exports = defineTest({ + description: 'transpiles JSX output', + options: { + external: ['react'], + jsx: 'react' + } +}); diff --git a/test/form/samples/jsx/transpiles-jsx-empty-expression/_expected.js b/test/form/samples/jsx/transpiles-jsx-empty-expression/_expected.js new file mode 100644 index 00000000000..1a54860615d --- /dev/null +++ b/test/form/samples/jsx/transpiles-jsx-empty-expression/_expected.js @@ -0,0 +1,6 @@ +import react from 'react'; + +const Foo = () => {}; +const result = /*#__PURE__*/react.createElement(Foo, null); + +export { result }; diff --git a/test/form/samples/jsx/transpiles-jsx-empty-expression/main.js b/test/form/samples/jsx/transpiles-jsx-empty-expression/main.js new file mode 100644 index 00000000000..d37a6f1949a --- /dev/null +++ b/test/form/samples/jsx/transpiles-jsx-empty-expression/main.js @@ -0,0 +1,2 @@ +const Foo = () => {}; +export const result = {/*Wohoo*/}; diff --git a/test/form/samples/jsx/transpiles-jsx-expression/_config.js b/test/form/samples/jsx/transpiles-jsx-expression/_config.js new file mode 100644 index 00000000000..217e03f576b --- /dev/null +++ b/test/form/samples/jsx/transpiles-jsx-expression/_config.js @@ -0,0 +1,7 @@ +module.exports = defineTest({ + description: 'transpiles JSX expressions', + options: { + external: ['react'], + jsx: 'react' + } +}); diff --git a/test/form/samples/jsx/transpiles-jsx-expression/_expected.js b/test/form/samples/jsx/transpiles-jsx-expression/_expected.js new file mode 100644 index 00000000000..3a792d73525 --- /dev/null +++ b/test/form/samples/jsx/transpiles-jsx-expression/_expected.js @@ -0,0 +1,15 @@ +import react from 'react'; + +const element$2 = 'element 1'; +console.log(element$2); + +const element$1 = 'element 2'; +console.log(element$1); + +const element = 'element 3'; +console.log(element); + +const Foo = () => {}; +const result = /*#__PURE__*/react.createElement(Foo, null, 'test' + element$1); + +export { result }; diff --git a/test/form/samples/jsx/transpiles-jsx-expression/dep1.js b/test/form/samples/jsx/transpiles-jsx-expression/dep1.js new file mode 100644 index 00000000000..dd37912ccca --- /dev/null +++ b/test/form/samples/jsx/transpiles-jsx-expression/dep1.js @@ -0,0 +1,2 @@ +export const element = 'element 1'; +console.log(element); diff --git a/test/form/samples/jsx/transpiles-jsx-expression/dep2.js b/test/form/samples/jsx/transpiles-jsx-expression/dep2.js new file mode 100644 index 00000000000..a9713f489a9 --- /dev/null +++ b/test/form/samples/jsx/transpiles-jsx-expression/dep2.js @@ -0,0 +1,2 @@ +export const element = 'element 2'; +console.log(element); diff --git a/test/form/samples/jsx/transpiles-jsx-expression/dep3.js b/test/form/samples/jsx/transpiles-jsx-expression/dep3.js new file mode 100644 index 00000000000..de220a40890 --- /dev/null +++ b/test/form/samples/jsx/transpiles-jsx-expression/dep3.js @@ -0,0 +1,2 @@ +export const element = 'element 3'; +console.log(element); diff --git a/test/form/samples/jsx/transpiles-jsx-expression/main.js b/test/form/samples/jsx/transpiles-jsx-expression/main.js new file mode 100644 index 00000000000..910b3247986 --- /dev/null +++ b/test/form/samples/jsx/transpiles-jsx-expression/main.js @@ -0,0 +1,6 @@ +import "./dep1.js"; +import { element } from "./dep2.js"; +import "./dep3.js"; + +const Foo = () => {}; +export const result = {'test' + element}; diff --git a/test/form/samples/jsx/transpiles-jsx-fragment/_config.js b/test/form/samples/jsx/transpiles-jsx-fragment/_config.js new file mode 100644 index 00000000000..154660bc4ed --- /dev/null +++ b/test/form/samples/jsx/transpiles-jsx-fragment/_config.js @@ -0,0 +1,7 @@ +module.exports = defineTest({ + description: 'transpiles JSX output', + options: { + external: ['react'], + jsx: 'react' + } +}); diff --git a/test/form/samples/jsx/transpiles-jsx-fragment/_expected.js b/test/form/samples/jsx/transpiles-jsx-fragment/_expected.js new file mode 100644 index 00000000000..c9a08b770b8 --- /dev/null +++ b/test/form/samples/jsx/transpiles-jsx-fragment/_expected.js @@ -0,0 +1,6 @@ +import react from 'react'; + +const Foo = () => {}; +const result = /*#__PURE__*/react.createElement(Foo, null, /*#__PURE__*/react.createElement(react.Fragment, null)); + +export { result }; diff --git a/test/form/samples/jsx/transpiles-jsx-fragment/main.js b/test/form/samples/jsx/transpiles-jsx-fragment/main.js new file mode 100644 index 00000000000..14a6baf4604 --- /dev/null +++ b/test/form/samples/jsx/transpiles-jsx-fragment/main.js @@ -0,0 +1,2 @@ +const Foo = () => {}; +export const result = <>; diff --git a/test/form/samples/jsx/transpiles-jsx-member-expression/_config.js b/test/form/samples/jsx/transpiles-jsx-member-expression/_config.js new file mode 100644 index 00000000000..dfd4b69c2a6 --- /dev/null +++ b/test/form/samples/jsx/transpiles-jsx-member-expression/_config.js @@ -0,0 +1,7 @@ +module.exports = defineTest({ + description: 'transpiles JSX member expressions', + options: { + external: ['react'], + jsx: 'react' + } +}); diff --git a/test/form/samples/jsx/transpiles-jsx-member-expression/_expected.js b/test/form/samples/jsx/transpiles-jsx-member-expression/_expected.js new file mode 100644 index 00000000000..7549595c533 --- /dev/null +++ b/test/form/samples/jsx/transpiles-jsx-member-expression/_expected.js @@ -0,0 +1,11 @@ +import react from 'react'; + +const obj = { + Foo: () => {}, + bar: { Baz: () => {} } +}; + +const result1 = /*#__PURE__*/react.createElement(obj.Foo, null); +const result2 = /*#__PURE__*/react.createElement(obj.bar.Baz, null); + +export { result1, result2 }; diff --git a/test/form/samples/jsx/transpiles-jsx-member-expression/main.js b/test/form/samples/jsx/transpiles-jsx-member-expression/main.js new file mode 100644 index 00000000000..04e40c09d07 --- /dev/null +++ b/test/form/samples/jsx/transpiles-jsx-member-expression/main.js @@ -0,0 +1,7 @@ +const obj = { + Foo: () => {}, + bar: { Baz: () => {} } +}; + +export const result1 = ; +export const result2 = ; diff --git a/test/form/samples/jsx/transpiles-jsx-self-closing/_config.js b/test/form/samples/jsx/transpiles-jsx-self-closing/_config.js new file mode 100644 index 00000000000..ec1eb81a545 --- /dev/null +++ b/test/form/samples/jsx/transpiles-jsx-self-closing/_config.js @@ -0,0 +1,7 @@ +module.exports = defineTest({ + description: 'transpiles self-closing JSX elements', + options: { + external: ['react'], + jsx: 'react' + } +}); diff --git a/test/form/samples/jsx/transpiles-jsx-self-closing/_expected.js b/test/form/samples/jsx/transpiles-jsx-self-closing/_expected.js new file mode 100644 index 00000000000..1a54860615d --- /dev/null +++ b/test/form/samples/jsx/transpiles-jsx-self-closing/_expected.js @@ -0,0 +1,6 @@ +import react from 'react'; + +const Foo = () => {}; +const result = /*#__PURE__*/react.createElement(Foo, null); + +export { result }; diff --git a/test/form/samples/jsx/transpiles-jsx-self-closing/main.js b/test/form/samples/jsx/transpiles-jsx-self-closing/main.js new file mode 100644 index 00000000000..1e56ff70298 --- /dev/null +++ b/test/form/samples/jsx/transpiles-jsx-self-closing/main.js @@ -0,0 +1,2 @@ +const Foo = () => {}; +export const result = ; diff --git a/test/form/samples/jsx/transpiles-jsx-spread-attribute/_config.js b/test/form/samples/jsx/transpiles-jsx-spread-attribute/_config.js new file mode 100644 index 00000000000..edcac60d1e7 --- /dev/null +++ b/test/form/samples/jsx/transpiles-jsx-spread-attribute/_config.js @@ -0,0 +1,7 @@ +module.exports = defineTest({ + description: 'transpiles JSX spread attributes', + options: { + external: ['react'], + jsx: 'react' + } +}); diff --git a/test/form/samples/jsx/transpiles-jsx-spread-attribute/_expected.js b/test/form/samples/jsx/transpiles-jsx-spread-attribute/_expected.js new file mode 100644 index 00000000000..4329ca93823 --- /dev/null +++ b/test/form/samples/jsx/transpiles-jsx-spread-attribute/_expected.js @@ -0,0 +1,21 @@ +import react from 'react'; + +const obj$2 = { value1: true }; +console.log(obj$2); + +const obj$1 = { value2: true }; +console.log(obj$1); + +const obj = { value3: true }; +console.log(obj); + +const Foo = () => {}; +const result1 = /*#__PURE__*/react.createElement(Foo, obj$1); +const result2 = /*#__PURE__*/react.createElement(Foo, Object.assign({}, obj$1, { prop: true })); +const result3 = /*#__PURE__*/react.createElement(Foo, + Object.assign({ prop1: true, + prop2: true }, + obj$1, + obj$1)); + +export { result1, result2, result3 }; diff --git a/test/form/samples/jsx/transpiles-jsx-spread-attribute/dep1.js b/test/form/samples/jsx/transpiles-jsx-spread-attribute/dep1.js new file mode 100644 index 00000000000..658d5636c5a --- /dev/null +++ b/test/form/samples/jsx/transpiles-jsx-spread-attribute/dep1.js @@ -0,0 +1,2 @@ +export const obj = { value1: true }; +console.log(obj); diff --git a/test/form/samples/jsx/transpiles-jsx-spread-attribute/dep2.js b/test/form/samples/jsx/transpiles-jsx-spread-attribute/dep2.js new file mode 100644 index 00000000000..bdbe905d08d --- /dev/null +++ b/test/form/samples/jsx/transpiles-jsx-spread-attribute/dep2.js @@ -0,0 +1,2 @@ +export const obj = { value2: true }; +console.log(obj); diff --git a/test/form/samples/jsx/transpiles-jsx-spread-attribute/dep3.js b/test/form/samples/jsx/transpiles-jsx-spread-attribute/dep3.js new file mode 100644 index 00000000000..f18273863e3 --- /dev/null +++ b/test/form/samples/jsx/transpiles-jsx-spread-attribute/dep3.js @@ -0,0 +1,2 @@ +export const obj = { value3: true }; +console.log(obj); diff --git a/test/form/samples/jsx/transpiles-jsx-spread-attribute/main.js b/test/form/samples/jsx/transpiles-jsx-spread-attribute/main.js new file mode 100644 index 00000000000..22953c47609 --- /dev/null +++ b/test/form/samples/jsx/transpiles-jsx-spread-attribute/main.js @@ -0,0 +1,13 @@ +import './dep1.js'; +import { obj } from './dep2.js'; +import './dep3.js'; + +const Foo = () => {}; +export const result1 = ; +export const result2 = ; +export const result3 = ; diff --git a/test/form/samples/jsx/transpiles-jsx-spread-child/_config.js b/test/form/samples/jsx/transpiles-jsx-spread-child/_config.js new file mode 100644 index 00000000000..cc06baae2bd --- /dev/null +++ b/test/form/samples/jsx/transpiles-jsx-spread-child/_config.js @@ -0,0 +1,9 @@ +module.exports = defineTest({ + description: 'transpiles JSX spread children', + options: { + external: ['react'], + jsx: 'react' + }, + // apparently, acorn-jsx does not support spread children + verifyAst: false +}); diff --git a/test/form/samples/jsx/transpiles-jsx-spread-child/_expected.js b/test/form/samples/jsx/transpiles-jsx-spread-child/_expected.js new file mode 100644 index 00000000000..9a1f05f7ff9 --- /dev/null +++ b/test/form/samples/jsx/transpiles-jsx-spread-child/_expected.js @@ -0,0 +1,16 @@ +import react from 'react'; + +const spread$2 = ['spread 1']; +console.log(spread$2); + +const spread$1 = ['spread 2']; +console.log(spread$1); + +const spread = ['spread 3']; +console.log(spread); + +const Foo = () => {}; +const element = /*#__PURE__*/react.createElement(Foo, null, ...spread$1); +const fragment = /*#__PURE__*/react.createElement(react.Fragment, null, ...spread$1); + +export { element, fragment }; diff --git a/test/form/samples/jsx/transpiles-jsx-spread-child/dep1.js b/test/form/samples/jsx/transpiles-jsx-spread-child/dep1.js new file mode 100644 index 00000000000..53572b805ec --- /dev/null +++ b/test/form/samples/jsx/transpiles-jsx-spread-child/dep1.js @@ -0,0 +1,2 @@ +export const spread = ['spread 1']; +console.log(spread); diff --git a/test/form/samples/jsx/transpiles-jsx-spread-child/dep2.js b/test/form/samples/jsx/transpiles-jsx-spread-child/dep2.js new file mode 100644 index 00000000000..bbea244bcfb --- /dev/null +++ b/test/form/samples/jsx/transpiles-jsx-spread-child/dep2.js @@ -0,0 +1,2 @@ +export const spread = ['spread 2']; +console.log(spread); diff --git a/test/form/samples/jsx/transpiles-jsx-spread-child/dep3.js b/test/form/samples/jsx/transpiles-jsx-spread-child/dep3.js new file mode 100644 index 00000000000..666d48094d1 --- /dev/null +++ b/test/form/samples/jsx/transpiles-jsx-spread-child/dep3.js @@ -0,0 +1,2 @@ +export const spread = ['spread 3']; +console.log(spread); diff --git a/test/form/samples/jsx/transpiles-jsx-spread-child/main.js b/test/form/samples/jsx/transpiles-jsx-spread-child/main.js new file mode 100644 index 00000000000..10e217564e0 --- /dev/null +++ b/test/form/samples/jsx/transpiles-jsx-spread-child/main.js @@ -0,0 +1,6 @@ +import './dep1.js'; +import { spread } from './dep2.js'; +import './dep3.js'; +const Foo = () => {}; +export const element = {...spread}; +export const fragment = <>{...spread}; diff --git a/test/form/samples/jsx/transpiles-jsx-text/_config.js b/test/form/samples/jsx/transpiles-jsx-text/_config.js new file mode 100644 index 00000000000..d3fcf6b7956 --- /dev/null +++ b/test/form/samples/jsx/transpiles-jsx-text/_config.js @@ -0,0 +1,7 @@ +module.exports = defineTest({ + description: 'transpiles JSX text', + options: { + external: ['react'], + jsx: 'react' + } +}); diff --git a/test/form/samples/jsx/transpiles-jsx-text/_expected.js b/test/form/samples/jsx/transpiles-jsx-text/_expected.js new file mode 100644 index 00000000000..52f72067dad --- /dev/null +++ b/test/form/samples/jsx/transpiles-jsx-text/_expected.js @@ -0,0 +1,7 @@ +import react from 'react'; + +const Foo = () => {}; +const element = /*#__PURE__*/react.createElement(Foo, null, "some&\\text"); +const fragment = /*#__PURE__*/react.createElement(react.Fragment, null, "other&\\text"); + +export { element, fragment }; diff --git a/test/form/samples/jsx/transpiles-jsx-text/main.js b/test/form/samples/jsx/transpiles-jsx-text/main.js new file mode 100644 index 00000000000..e8e2d995543 --- /dev/null +++ b/test/form/samples/jsx/transpiles-jsx-text/main.js @@ -0,0 +1,3 @@ +const Foo = () => {}; +export const element = some&\text; +export const fragment = <>other&\text; diff --git a/test/form/samples/jsx/transpiles-native-elements/_config.js b/test/form/samples/jsx/transpiles-native-elements/_config.js new file mode 100644 index 00000000000..52b1628b576 --- /dev/null +++ b/test/form/samples/jsx/transpiles-native-elements/_config.js @@ -0,0 +1,7 @@ +module.exports = defineTest({ + description: 'preserves native JSX elements', + options: { + external: ['react'], + jsx: 'react' + } +}); diff --git a/test/form/samples/jsx/transpiles-native-elements/_expected.js b/test/form/samples/jsx/transpiles-native-elements/_expected.js new file mode 100644 index 00000000000..fa825355679 --- /dev/null +++ b/test/form/samples/jsx/transpiles-native-elements/_expected.js @@ -0,0 +1,12 @@ +import react from 'react'; + +const div$1 = 'wrong div 1'; +const span$1 = 'wrong span 1'; +console.log(div$1, span$1); + +console.log(/*#__PURE__*/react.createElement("div", null)); +console.log(/*#__PURE__*/react.createElement("div", null, /*#__PURE__*/react.createElement("span", null))); + +const div = 'wrong div 2'; +const span = 'wrong span 2'; +console.log(div, span); diff --git a/test/form/samples/jsx/transpiles-native-elements/jsx.js b/test/form/samples/jsx/transpiles-native-elements/jsx.js new file mode 100644 index 00000000000..02159671af3 --- /dev/null +++ b/test/form/samples/jsx/transpiles-native-elements/jsx.js @@ -0,0 +1,5 @@ +const div = 'wrong div'; +const span = 'wrong span'; + +console.log(
); +console.log(
); diff --git a/test/form/samples/jsx/transpiles-native-elements/main.js b/test/form/samples/jsx/transpiles-native-elements/main.js new file mode 100644 index 00000000000..dfccae85926 --- /dev/null +++ b/test/form/samples/jsx/transpiles-native-elements/main.js @@ -0,0 +1,3 @@ +import "./other1.js"; +import "./jsx.js"; +import "./other2.js"; diff --git a/test/form/samples/jsx/transpiles-native-elements/other1.js b/test/form/samples/jsx/transpiles-native-elements/other1.js new file mode 100644 index 00000000000..d607c512add --- /dev/null +++ b/test/form/samples/jsx/transpiles-native-elements/other1.js @@ -0,0 +1,3 @@ +const div = 'wrong div 1'; +const span = 'wrong span 1'; +console.log(div, span); diff --git a/test/form/samples/jsx/transpiles-native-elements/other2.js b/test/form/samples/jsx/transpiles-native-elements/other2.js new file mode 100644 index 00000000000..25f1a5e7ad7 --- /dev/null +++ b/test/form/samples/jsx/transpiles-native-elements/other2.js @@ -0,0 +1,3 @@ +const div = 'wrong div 2'; +const span = 'wrong span 2'; +console.log(div, span); diff --git a/test/form/samples/jsx/transpiles-react-global/_config.js b/test/form/samples/jsx/transpiles-react-global/_config.js new file mode 100644 index 00000000000..3af41f24e69 --- /dev/null +++ b/test/form/samples/jsx/transpiles-react-global/_config.js @@ -0,0 +1,9 @@ +module.exports = defineTest({ + description: 'transpiles JSX for react', + options: { + jsx: { + factory: 'React.createElement', + fragmentFactory: 'React.Fragment' + } + } +}); diff --git a/test/form/samples/jsx/transpiles-react-global/_expected.js b/test/form/samples/jsx/transpiles-react-global/_expected.js new file mode 100644 index 00000000000..0dab4df904b --- /dev/null +++ b/test/form/samples/jsx/transpiles-react-global/_expected.js @@ -0,0 +1,10 @@ +const Foo$2 = 'wrong Foo 1'; +const React$2 = 'wrong React 1'; +console.log(Foo$2, React$2); + +const Foo$1 = () => {}; +console.log(/*#__PURE__*/React.createElement(Foo$1, null)); + +const Foo = 'wrong Foo 2'; +const React$1 = 'wrong React 2'; +console.log(Foo, React$1); diff --git a/test/form/samples/jsx/transpiles-react-global/jsx.js b/test/form/samples/jsx/transpiles-react-global/jsx.js new file mode 100644 index 00000000000..4b5671bbbac --- /dev/null +++ b/test/form/samples/jsx/transpiles-react-global/jsx.js @@ -0,0 +1,2 @@ +const Foo = () => {}; +console.log(); diff --git a/test/form/samples/jsx/transpiles-react-global/main.js b/test/form/samples/jsx/transpiles-react-global/main.js new file mode 100644 index 00000000000..dfccae85926 --- /dev/null +++ b/test/form/samples/jsx/transpiles-react-global/main.js @@ -0,0 +1,3 @@ +import "./other1.js"; +import "./jsx.js"; +import "./other2.js"; diff --git a/test/form/samples/jsx/transpiles-react-global/other1.js b/test/form/samples/jsx/transpiles-react-global/other1.js new file mode 100644 index 00000000000..7b5145191de --- /dev/null +++ b/test/form/samples/jsx/transpiles-react-global/other1.js @@ -0,0 +1,3 @@ +const Foo = 'wrong Foo 1'; +const React = 'wrong React 1'; +console.log(Foo, React); diff --git a/test/form/samples/jsx/transpiles-react-global/other2.js b/test/form/samples/jsx/transpiles-react-global/other2.js new file mode 100644 index 00000000000..10b37745be6 --- /dev/null +++ b/test/form/samples/jsx/transpiles-react-global/other2.js @@ -0,0 +1,3 @@ +const Foo = 'wrong Foo 2'; +const React = 'wrong React 2'; +console.log(Foo, React); diff --git a/test/form/samples/jsx/transpiles-react-internal/_config.js b/test/form/samples/jsx/transpiles-react-internal/_config.js new file mode 100644 index 00000000000..4a1583e82f8 --- /dev/null +++ b/test/form/samples/jsx/transpiles-react-internal/_config.js @@ -0,0 +1,10 @@ +const path = require('node:path'); +module.exports = defineTest({ + description: 'transpiles JSX for react', + options: { + jsx: { + importSource: path.join(__dirname, 'react.js'), + preset: 'react' + } + } +}); diff --git a/test/form/samples/jsx/transpiles-react-internal/_expected.js b/test/form/samples/jsx/transpiles-react-internal/_expected.js new file mode 100644 index 00000000000..0e6ceaa7ccd --- /dev/null +++ b/test/form/samples/jsx/transpiles-react-internal/_expected.js @@ -0,0 +1,16 @@ +const Foo$2 = 'wrong Foo 1'; +const React$1 = 'wrong React 1'; +console.log(Foo$2, React$1); + +var react = { + createElement() { + console.log('createElement'); + } +}; + +const Foo$1 = () => {}; +console.log(/*#__PURE__*/react.createElement(Foo$1, null)); + +const Foo = 'wrong Foo 2'; +const React = 'wrong React 2'; +console.log(Foo, React); diff --git a/test/form/samples/jsx/transpiles-react-internal/jsx.js b/test/form/samples/jsx/transpiles-react-internal/jsx.js new file mode 100644 index 00000000000..4b5671bbbac --- /dev/null +++ b/test/form/samples/jsx/transpiles-react-internal/jsx.js @@ -0,0 +1,2 @@ +const Foo = () => {}; +console.log(); diff --git a/test/form/samples/jsx/transpiles-react-internal/main.js b/test/form/samples/jsx/transpiles-react-internal/main.js new file mode 100644 index 00000000000..dfccae85926 --- /dev/null +++ b/test/form/samples/jsx/transpiles-react-internal/main.js @@ -0,0 +1,3 @@ +import "./other1.js"; +import "./jsx.js"; +import "./other2.js"; diff --git a/test/form/samples/jsx/transpiles-react-internal/other1.js b/test/form/samples/jsx/transpiles-react-internal/other1.js new file mode 100644 index 00000000000..7b5145191de --- /dev/null +++ b/test/form/samples/jsx/transpiles-react-internal/other1.js @@ -0,0 +1,3 @@ +const Foo = 'wrong Foo 1'; +const React = 'wrong React 1'; +console.log(Foo, React); diff --git a/test/form/samples/jsx/transpiles-react-internal/other2.js b/test/form/samples/jsx/transpiles-react-internal/other2.js new file mode 100644 index 00000000000..10b37745be6 --- /dev/null +++ b/test/form/samples/jsx/transpiles-react-internal/other2.js @@ -0,0 +1,3 @@ +const Foo = 'wrong Foo 2'; +const React = 'wrong React 2'; +console.log(Foo, React); diff --git a/test/form/samples/jsx/transpiles-react-internal/react.js b/test/form/samples/jsx/transpiles-react-internal/react.js new file mode 100644 index 00000000000..62d36813017 --- /dev/null +++ b/test/form/samples/jsx/transpiles-react-internal/react.js @@ -0,0 +1,5 @@ +export default { + createElement() { + console.log('createElement'); + } +}; diff --git a/test/form/samples/jsx/transpiles-react-jsx-expression-semicolon/_config.js b/test/form/samples/jsx/transpiles-react-jsx-expression-semicolon/_config.js new file mode 100644 index 00000000000..80868636cd4 --- /dev/null +++ b/test/form/samples/jsx/transpiles-react-jsx-expression-semicolon/_config.js @@ -0,0 +1,7 @@ +module.exports = defineTest({ + description: 'Adds semicolons at the correct positions in transpiled JSX', + options: { + external: ['react', 'react/jsx-runtime'], + jsx: 'react-jsx' + } +}); diff --git a/test/form/samples/jsx/transpiles-react-jsx-expression-semicolon/_expected.js b/test/form/samples/jsx/transpiles-react-jsx-expression-semicolon/_expected.js new file mode 100644 index 00000000000..2b610a6fec9 --- /dev/null +++ b/test/form/samples/jsx/transpiles-react-jsx-expression-semicolon/_expected.js @@ -0,0 +1,3 @@ +import { jsx } from 'react/jsx-runtime'; + +/*#__PURE__*/jsx(Foo, {}, 123); diff --git a/test/form/samples/jsx/transpiles-react-jsx-expression-semicolon/main.js b/test/form/samples/jsx/transpiles-react-jsx-expression-semicolon/main.js new file mode 100644 index 00000000000..1732f3ed75d --- /dev/null +++ b/test/form/samples/jsx/transpiles-react-jsx-expression-semicolon/main.js @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test/form/samples/jsx/transpiles-react-jsx/_config.js b/test/form/samples/jsx/transpiles-react-jsx/_config.js new file mode 100644 index 00000000000..d9c8a8452c7 --- /dev/null +++ b/test/form/samples/jsx/transpiles-react-jsx/_config.js @@ -0,0 +1,7 @@ +module.exports = defineTest({ + description: 'transpiles JSX for react', + options: { + external: ['react', 'react/jsx-runtime'], + jsx: 'react-jsx' + } +}); diff --git a/test/form/samples/jsx/transpiles-react-jsx/_expected.js b/test/form/samples/jsx/transpiles-react-jsx/_expected.js new file mode 100644 index 00000000000..5a95432bff1 --- /dev/null +++ b/test/form/samples/jsx/transpiles-react-jsx/_expected.js @@ -0,0 +1,83 @@ +import { jsx as jsx$2, Fragment, jsxs as jsxs$2 } from 'react/jsx-runtime'; +import react from 'react'; + +const Foo$2 = 'wrong Foo 1'; +const obj$2 = 'wrong obj 1'; +const jsx$1 = 'wrong jsx 1'; +const jsxs$1 = 'wrong jsxs 1'; +console.log(Foo$2, obj$2, jsx$1, jsxs$1); + +const Foo$1 = () => {}; +const obj$1 = { key: '2' }; + +// jsx +console.log(/*#__PURE__*/jsx$2(Foo$1, {})); +console.log(/*#__PURE__*/jsx$2(Foo$1, { x: true })); +console.log(/*#__PURE__*/jsx$2(Foo$1, { x: "1" })); +console.log(/*#__PURE__*/jsx$2(Foo$1, { x: "1" })); +console.log(/*#__PURE__*/jsx$2(Foo$1, {}, true)); +console.log(/*#__PURE__*/jsx$2(Foo$1, {}, "1")); +console.log(/*#__PURE__*/jsx$2(Foo$1, {}, "1")); +console.log(/*#__PURE__*/jsx$2(Foo$1, obj$1)); +console.log(/*#__PURE__*/jsx$2(Foo$1, Object.assign({}, obj$1, { x: "1" }))); +console.log(/*#__PURE__*/jsx$2(Foo$1, obj$1, "1")); +console.log(/*#__PURE__*/jsx$2(Foo$1, obj$1, true)); +console.log(/*#__PURE__*/jsx$2(Foo$1, Object.assign({ x: "1", y: "1" }, obj$1, obj$1))); +console.log(/*#__PURE__*/jsx$2(Foo$1, Object.assign({ x: "1", y: "1" }, obj$1, obj$1), "1")); +console.log(/*#__PURE__*/jsx$2(Foo$1, Object.assign({ x: "1", y: "1" }, obj$1, obj$1), true)); + +console.log(/*#__PURE__*/jsx$2(Foo$1, {})); +console.log(/*#__PURE__*/jsx$2(Foo$1, { x: "1" })); +console.log(/*#__PURE__*/jsx$2(Foo$1, {}, "1")); +console.log(/*#__PURE__*/jsx$2(Foo$1, {}, true)); + +console.log(/*#__PURE__*/jsx$2(Foo$1, { children: /*#__PURE__*/jsx$2(Foo$1, {}) })); +console.log(/*#__PURE__*/jsx$2(Foo$1, { x: "1", children: /*#__PURE__*/jsx$2(Foo$1, {}) })); +console.log(/*#__PURE__*/jsx$2(Foo$1, { children: /*#__PURE__*/jsx$2(Foo$1, {}) }, "1")); +console.log(/*#__PURE__*/jsx$2(Foo$1, { children: /*#__PURE__*/jsx$2(Foo$1, {}) }, true)); +console.log(/*#__PURE__*/jsx$2(Foo$1, Object.assign({}, obj$1, { children: /*#__PURE__*/jsx$2(Foo$1, {}) }))); +console.log(/*#__PURE__*/jsx$2(Foo$1, Object.assign({}, obj$1, { x: "1", children: /*#__PURE__*/jsx$2(Foo$1, {}) }))); +console.log(/*#__PURE__*/jsx$2(Foo$1, Object.assign({}, obj$1, { children: /*#__PURE__*/jsx$2(Foo$1, {}) }), "1")); +console.log(/*#__PURE__*/jsx$2(Foo$1, Object.assign({}, obj$1, { children: /*#__PURE__*/jsx$2(Foo$1, {}) }), true)); +console.log(/*#__PURE__*/jsx$2(Foo$1, Object.assign({ x: "1", y: "1" }, obj$1, obj$1, { children: /*#__PURE__*/jsx$2(Foo$1, {}) }))); +console.log(/*#__PURE__*/jsx$2(Foo$1, Object.assign({ x: "1", y: "1" }, obj$1, obj$1, { children: /*#__PURE__*/jsx$2(Foo$1, {}) }), "1")); +console.log(/*#__PURE__*/jsx$2(Foo$1, Object.assign({ x: "1", y: "1" }, obj$1, obj$1, { children: /*#__PURE__*/jsx$2(Foo$1, {}) }), true)); + +console.log(/*#__PURE__*/jsx$2(Foo$1, { children: /*#__PURE__*/jsx$2(Foo$1, {}) })); + +console.log(/*#__PURE__*/jsx$2(Fragment, {})); +console.log(/*#__PURE__*/jsx$2(Fragment, { children: /*#__PURE__*/jsx$2(Foo$1, {}) })); + +// jsxs +console.log(/*#__PURE__*/jsxs$2(Foo$1, { children: [/*#__PURE__*/jsx$2(Foo$1, {}), /*#__PURE__*/jsx$2(Foo$1, {})] })); +console.log(/*#__PURE__*/jsxs$2(Foo$1, { x: "1", children: [/*#__PURE__*/jsx$2(Foo$1, {}), /*#__PURE__*/jsx$2(Foo$1, {})] })); +console.log(/*#__PURE__*/jsxs$2(Foo$1, { children: [/*#__PURE__*/jsx$2(Foo$1, {}), /*#__PURE__*/jsx$2(Foo$1, {})] }, "1")); +console.log(/*#__PURE__*/jsxs$2(Foo$1, { children: [/*#__PURE__*/jsx$2(Foo$1, {}), /*#__PURE__*/jsx$2(Foo$1, {})] }, true)); +console.log(/*#__PURE__*/jsxs$2(Foo$1, Object.assign({}, obj$1, { children: [/*#__PURE__*/jsx$2(Foo$1, {}), /*#__PURE__*/jsx$2(Foo$1, {})] }))); +console.log(/*#__PURE__*/jsxs$2(Foo$1, Object.assign({}, obj$1, { x: "1", children: [/*#__PURE__*/jsx$2(Foo$1, {}), /*#__PURE__*/jsx$2(Foo$1, {})] }))); +console.log(/*#__PURE__*/jsxs$2(Foo$1, Object.assign({}, obj$1, { children: [/*#__PURE__*/jsx$2(Foo$1, {}), /*#__PURE__*/jsx$2(Foo$1, {})] }), "1")); +console.log(/*#__PURE__*/jsxs$2(Foo$1, Object.assign({}, obj$1, { children: [/*#__PURE__*/jsx$2(Foo$1, {}), /*#__PURE__*/jsx$2(Foo$1, {})] }), true)); +console.log(/*#__PURE__*/jsxs$2(Foo$1, Object.assign({ x: "1", y: "1" }, obj$1, obj$1, { children: [/*#__PURE__*/jsx$2(Foo$1, {}), /*#__PURE__*/jsx$2(Foo$1, {})] }))); +console.log(/*#__PURE__*/jsxs$2(Foo$1, Object.assign({ x: "1", y: "1" }, obj$1, obj$1, { children: [/*#__PURE__*/jsx$2(Foo$1, {}), /*#__PURE__*/jsx$2(Foo$1, {})] }), "1")); +console.log(/*#__PURE__*/jsxs$2(Foo$1, Object.assign({ x: "1", y: "1" }, obj$1, obj$1, { children: [/*#__PURE__*/jsx$2(Foo$1, {}), /*#__PURE__*/jsx$2(Foo$1, {})] }), true)); + +console.log(/*#__PURE__*/jsxs$2(Fragment, { children: [/*#__PURE__*/jsx$2(Foo$1, {}), /*#__PURE__*/jsx$2(Foo$1, {})] })); + +// createElement +console.log(/*#__PURE__*/react.createElement(Foo$1, Object.assign({}, obj$1, { key: "1" }))); +console.log(/*#__PURE__*/react.createElement(Foo$1, Object.assign({}, obj$1, { key: true }))); +console.log(/*#__PURE__*/react.createElement(Foo$1, Object.assign({}, obj$1, obj$1, { x: "1", key: "1", y: "1" }))); +console.log(/*#__PURE__*/react.createElement(Foo$1, Object.assign({}, obj$1, obj$1, { x: "1", key: true, y: "1" }))); +console.log(/*#__PURE__*/react.createElement(Foo$1, Object.assign({}, obj$1, { key: "1" }))); +console.log(/*#__PURE__*/react.createElement(Foo$1, Object.assign({}, obj$1, { key: "1" }), /*#__PURE__*/jsx$2(Foo$1, {}))); + +// whitespace nightmares +console.log( + /*#__PURE__*/jsxs$2("div", { children: ["Hello World", /*#__PURE__*/jsxs$2("p", { children: [" JSX ", /*#__PURE__*/jsx$2("b", { children: "whitespaces" }), " are so A N N O Y I N G to deal with!! "] }), /*#__PURE__*/jsx$2("span", { foo: "bar\n baz" }), /*#__PURE__*/jsx$2("p", { children: "x y" }), /*#__PURE__*/jsx$2(Fragment, { children: /*#__PURE__*/jsx$2("div", {}) }), /*#__PURE__*/jsx$2(Fragment, { children: /*#__PURE__*/jsx$2("div", {}) })] }) +); + +const Foo = 'wrong Foo 2'; +const obj = 'wrong obj 2'; +const jsx = 'wrong jsx 2'; +const jsxs = 'wrong jsxs 2'; +console.log(Foo, obj, jsx, jsxs); diff --git a/test/form/samples/jsx/transpiles-react-jsx/jsx.js b/test/form/samples/jsx/transpiles-react-jsx/jsx.js new file mode 100644 index 00000000000..b0b4880d195 --- /dev/null +++ b/test/form/samples/jsx/transpiles-react-jsx/jsx.js @@ -0,0 +1,96 @@ +const Foo = () => {}; +const obj = { key: '2' }; + +// jsx +console.log(); +console.log(); +console.log(); +console.log(); +console.log(); +console.log(); +console.log(); +console.log(); +console.log(); +console.log(); +console.log(); +console.log(); +console.log(); +console.log(); + +console.log(); +console.log(); +console.log(); +console.log(); + +console.log(); +console.log(); +console.log(); +console.log(); +console.log(); +console.log(); +console.log(); +console.log(); +console.log(); +console.log(); +console.log(); + +console.log({/* comment */}{/* comment */}); + +console.log(<>); +console.log(<>); + +// jsxs +console.log(); +console.log(); +console.log(); +console.log(); +console.log(); +console.log(); +console.log(); +console.log(); +console.log(); +console.log(); +console.log(); + +console.log(<>); + +// createElement +console.log(); +console.log(); +console.log(); +console.log(); +console.log(); +console.log(); + +// whitespace nightmares +console.log( +
+ Hello + World +

JSX whitespaces are + so A N N O Y I N G to +deal with!!

+ + +

+ + + + + x + + + y + + + + + +

+ <>
+ <> +
+ +
+) diff --git a/test/form/samples/jsx/transpiles-react-jsx/main.js b/test/form/samples/jsx/transpiles-react-jsx/main.js new file mode 100644 index 00000000000..dfccae85926 --- /dev/null +++ b/test/form/samples/jsx/transpiles-react-jsx/main.js @@ -0,0 +1,3 @@ +import "./other1.js"; +import "./jsx.js"; +import "./other2.js"; diff --git a/test/form/samples/jsx/transpiles-react-jsx/other1.js b/test/form/samples/jsx/transpiles-react-jsx/other1.js new file mode 100644 index 00000000000..9514c12c816 --- /dev/null +++ b/test/form/samples/jsx/transpiles-react-jsx/other1.js @@ -0,0 +1,5 @@ +const Foo = 'wrong Foo 1'; +const obj = 'wrong obj 1'; +const jsx = 'wrong jsx 1'; +const jsxs = 'wrong jsxs 1'; +console.log(Foo, obj, jsx, jsxs); diff --git a/test/form/samples/jsx/transpiles-react-jsx/other2.js b/test/form/samples/jsx/transpiles-react-jsx/other2.js new file mode 100644 index 00000000000..802e2216e58 --- /dev/null +++ b/test/form/samples/jsx/transpiles-react-jsx/other2.js @@ -0,0 +1,5 @@ +const Foo = 'wrong Foo 2'; +const obj = 'wrong obj 2'; +const jsx = 'wrong jsx 2'; +const jsxs = 'wrong jsxs 2'; +console.log(Foo, obj, jsx, jsxs); diff --git a/test/form/samples/jsx/transpiles-react/_config.js b/test/form/samples/jsx/transpiles-react/_config.js new file mode 100644 index 00000000000..4b546d0fdcd --- /dev/null +++ b/test/form/samples/jsx/transpiles-react/_config.js @@ -0,0 +1,7 @@ +module.exports = defineTest({ + description: 'transpiles JSX for react', + options: { + external: ['react'], + jsx: 'react' + } +}); diff --git a/test/form/samples/jsx/transpiles-react/_expected.js b/test/form/samples/jsx/transpiles-react/_expected.js new file mode 100644 index 00000000000..c588a702040 --- /dev/null +++ b/test/form/samples/jsx/transpiles-react/_expected.js @@ -0,0 +1,12 @@ +import react from 'react'; + +const Foo$2 = 'wrong Foo 1'; +const React$1 = 'wrong React 1'; +console.log(Foo$2, React$1); + +const Foo$1 = () => {}; +console.log(/*#__PURE__*/react.createElement(Foo$1, null)); + +const Foo = 'wrong Foo 2'; +const React = 'wrong React 2'; +console.log(Foo, React); diff --git a/test/form/samples/jsx/transpiles-react/jsx.js b/test/form/samples/jsx/transpiles-react/jsx.js new file mode 100644 index 00000000000..4b5671bbbac --- /dev/null +++ b/test/form/samples/jsx/transpiles-react/jsx.js @@ -0,0 +1,2 @@ +const Foo = () => {}; +console.log(); diff --git a/test/form/samples/jsx/transpiles-react/main.js b/test/form/samples/jsx/transpiles-react/main.js new file mode 100644 index 00000000000..dfccae85926 --- /dev/null +++ b/test/form/samples/jsx/transpiles-react/main.js @@ -0,0 +1,3 @@ +import "./other1.js"; +import "./jsx.js"; +import "./other2.js"; diff --git a/test/form/samples/jsx/transpiles-react/other1.js b/test/form/samples/jsx/transpiles-react/other1.js new file mode 100644 index 00000000000..7b5145191de --- /dev/null +++ b/test/form/samples/jsx/transpiles-react/other1.js @@ -0,0 +1,3 @@ +const Foo = 'wrong Foo 1'; +const React = 'wrong React 1'; +console.log(Foo, React); diff --git a/test/form/samples/jsx/transpiles-react/other2.js b/test/form/samples/jsx/transpiles-react/other2.js new file mode 100644 index 00000000000..10b37745be6 --- /dev/null +++ b/test/form/samples/jsx/transpiles-react/other2.js @@ -0,0 +1,3 @@ +const Foo = 'wrong Foo 2'; +const React = 'wrong React 2'; +console.log(Foo, React); diff --git a/test/form/samples/keep-property-access-side-effects/_config.js b/test/form/samples/keep-property-access-side-effects/_config.js index 0d6db906551..f08c79347ca 100644 --- a/test/form/samples/keep-property-access-side-effects/_config.js +++ b/test/form/samples/keep-property-access-side-effects/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'keep side-effects when accessing properties if treeshake.propertyReadSideEffects is true', options: { @@ -6,4 +6,4 @@ module.exports = { propertyReadSideEffects: true } } -}; +}); diff --git a/test/form/samples/keep-property-access-side-effects/_expected.js b/test/form/samples/keep-property-access-side-effects/_expected.js index cf72b049414..9c97a8ddda5 100644 --- a/test/form/samples/keep-property-access-side-effects/_expected.js +++ b/test/form/samples/keep-property-access-side-effects/_expected.js @@ -1,6 +1,6 @@ const getter = { - get foo () { - console.log( 'effect' ); + get foo() { + console.log('effect'); } }; getter.foo; @@ -14,3 +14,37 @@ function accessArg(arg) { accessArg(null); globalThis.unknown.unknownProperty; + +({ + ...{ + get prop() { + console.log('effect'); + } + } +}); + +((async function () { + return { + get then() { + console.log('effect'); + return () => {}; + } + }; +}))(); + +(async () => ({ + get then() { + console.log('effect'); + return () => {}; + } +}))(); + +((async function () { + await { + get then() { + console.log('effect'); + return () => {}; + } + }; + return { then() {} }; +}))(); diff --git a/test/form/samples/keep-property-access-side-effects/main.js b/test/form/samples/keep-property-access-side-effects/main.js index 79c0b9bf78d..a5a0020200d 100644 --- a/test/form/samples/keep-property-access-side-effects/main.js +++ b/test/form/samples/keep-property-access-side-effects/main.js @@ -1,6 +1,6 @@ const getter = { - get foo () { - console.log( 'effect' ); + get foo() { + console.log('effect'); } }; const foo1 = getter.foo; @@ -14,3 +14,37 @@ function accessArg(arg) { accessArg(null); const foo4 = globalThis.unknown.unknownProperty; + +const foo5 = { + ...{ + get prop() { + console.log('effect'); + } + } +}; + +const foo6 = (async function () { + return { + get then() { + console.log('effect'); + return () => {}; + } + }; +})(); + +const foo7 = (async () => ({ + get then() { + console.log('effect'); + return () => {}; + } +}))(); + +const foo8 = (async function () { + await { + get then() { + console.log('effect'); + return () => {}; + } + }; + return { then() {} }; +})(); diff --git a/test/form/samples/keep-tree-shaking-comments-no-asi/_config.js b/test/form/samples/keep-tree-shaking-comments-no-asi/_config.js index 74cf0990a83..d0e04ee0cb5 100644 --- a/test/form/samples/keep-tree-shaking-comments-no-asi/_config.js +++ b/test/form/samples/keep-tree-shaking-comments-no-asi/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'always keep leading comments when tree-shaking and no automatic semicolons are inserted' -}; +}); diff --git a/test/form/samples/known-globals/_config.js b/test/form/samples/known-globals/_config.js index 9811990bbd2..f14cb5d63a2 100644 --- a/test/form/samples/known-globals/_config.js +++ b/test/form/samples/known-globals/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'does not consider it a side-effect if a known global variable is accessed' -}; +}); diff --git a/test/form/samples/known-globals/_expected.js b/test/form/samples/known-globals/_expected.js index c0b933d7b56..94e37d9d5ec 100644 --- a/test/form/samples/known-globals/_expected.js +++ b/test/form/samples/known-globals/_expected.js @@ -1 +1,2 @@ -console.log('main'); +// retained +Math[globalThis.unknown].foo; diff --git a/test/form/samples/known-globals/main.js b/test/form/samples/known-globals/main.js index 01b36b51d3a..f0a93f55834 100644 --- a/test/form/samples/known-globals/main.js +++ b/test/form/samples/known-globals/main.js @@ -1,4 +1,7 @@ -console.log('main'); +// retained +Math[globalThis.unknown].foo; + +// removed const a = setTimeout; const b = globalThis.setTimeout; const c = Math.max(1, 2); diff --git a/test/form/samples/labeled-break-statements/_config.js b/test/form/samples/labeled-break-statements/_config.js index 037b0db339c..20892371667 100644 --- a/test/form/samples/labeled-break-statements/_config.js +++ b/test/form/samples/labeled-break-statements/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'keep break statements if their label is included' -}; +}); diff --git a/test/form/samples/labeled-continue-statements/_config.js b/test/form/samples/labeled-continue-statements/_config.js index 3aa496920c8..9665ed990c0 100644 --- a/test/form/samples/labeled-continue-statements/_config.js +++ b/test/form/samples/labeled-continue-statements/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'keep continue statements if their label is included' -}; +}); diff --git a/test/form/samples/large-var-cnt-deduping/_config.js b/test/form/samples/large-var-cnt-deduping/_config.js index b038b5af02e..b26281f1e9c 100644 --- a/test/form/samples/large-var-cnt-deduping/_config.js +++ b/test/form/samples/large-var-cnt-deduping/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'large variable count deduping' -}; +}); diff --git a/test/form/samples/lazy-assignment-deoptimization/_config.js b/test/form/samples/lazy-assignment-deoptimization/_config.js index 3d2fbfd1923..040916440fd 100644 --- a/test/form/samples/lazy-assignment-deoptimization/_config.js +++ b/test/form/samples/lazy-assignment-deoptimization/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'only deoptimizes assigned variables when the assignment is included' -}; +}); diff --git a/test/form/samples/leading-comments/_config.js b/test/form/samples/leading-comments/_config.js new file mode 100644 index 00000000000..0df87ffe825 --- /dev/null +++ b/test/form/samples/leading-comments/_config.js @@ -0,0 +1,6 @@ +module.exports = defineTest({ + description: 'keeps leading comments on consecutive lines', + options: { + external: ['external'] + } +}); diff --git a/test/form/samples/leading-comments/_expected.js b/test/form/samples/leading-comments/_expected.js new file mode 100644 index 00000000000..88ed7dae079 --- /dev/null +++ b/test/form/samples/leading-comments/_expected.js @@ -0,0 +1,14 @@ +#! /usr/bin/env node +import 'external'; + +// comment dep 1/3 +/* comment +*/ // comment dep 2/3 +// comment dep 3/3 + +console.log('dep'); + +// comment main 1/2 +// comment main 2/2 + +console.log('main'); diff --git a/test/form/samples/leading-comments/dep.js b/test/form/samples/leading-comments/dep.js new file mode 100644 index 00000000000..dffa1075a82 --- /dev/null +++ b/test/form/samples/leading-comments/dep.js @@ -0,0 +1,7 @@ +// comment dep 1/3 +/* comment +*/ // comment dep 2/3 +// comment dep 3/3 +/* import comment */ import 'external'; + +console.log('dep'); diff --git a/test/form/samples/leading-comments/main.js b/test/form/samples/leading-comments/main.js new file mode 100644 index 00000000000..f17e3915705 --- /dev/null +++ b/test/form/samples/leading-comments/main.js @@ -0,0 +1,6 @@ +#! /usr/bin/env node +// comment main 1/2 +// comment main 2/2 +import './dep.js'; + +console.log('main'); diff --git a/test/form/samples/literals-from-class-statics/_config.js b/test/form/samples/literals-from-class-statics/_config.js new file mode 100644 index 00000000000..e5a57c5caf1 --- /dev/null +++ b/test/form/samples/literals-from-class-statics/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'tracks literal values in class static fields' +}); diff --git a/test/form/samples/literals-from-class-statics/_expected.js b/test/form/samples/literals-from-class-statics/_expected.js new file mode 100644 index 00000000000..09ce1e861ac --- /dev/null +++ b/test/form/samples/literals-from-class-statics/_expected.js @@ -0,0 +1,13 @@ +log("t"); +log("x"); + +class Undef { + static 'y'; +} +if (Undef.y) log("y"); + +class Deopt { + static z = false; +} +unknown(Deopt); +if (Deopt.z) log("z"); diff --git a/test/form/samples/literals-from-class-statics/main.js b/test/form/samples/literals-from-class-statics/main.js new file mode 100644 index 00000000000..a8cdcb481d4 --- /dev/null +++ b/test/form/samples/literals-from-class-statics/main.js @@ -0,0 +1,21 @@ +class Static { + static t() { return true; } + static f() { return false; } + static x = 10; +} + +if (Static.t()) log("t"); +if (Static.f()) log("f"); +if (!Static.t()) log("!t"); +if (Static.x) log("x"); + +class Undef { + static 'y'; +} +if (Undef.y) log("y"); + +class Deopt { + static z = false; +} +unknown(Deopt); +if (Deopt.z) log("z"); diff --git a/test/form/samples/literals-from-return-expressions/_config.js b/test/form/samples/literals-from-return-expressions/_config.js index 80621ca80a3..e236d2ba647 100644 --- a/test/form/samples/literals-from-return-expressions/_config.js +++ b/test/form/samples/literals-from-return-expressions/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'tracks literal values across return expressions' -}; +}); diff --git a/test/form/samples/log-side-effects/_config.js b/test/form/samples/log-side-effects/_config.js new file mode 100644 index 00000000000..ed517a127ab --- /dev/null +++ b/test/form/samples/log-side-effects/_config.js @@ -0,0 +1,68 @@ +const path = require('node:path'); +const MagicString = require('magic-string'); + +const ID_MAIN = path.join(__dirname, 'main.js'); +const ID_MAPPED = path.join(__dirname, 'dep-mapped.js'); + +module.exports = defineTest({ + description: 'logs side effects', + options: { + experimentalLogSideEffects: true, + plugins: [ + { + name: 'insert-lines', + transform(code, id) { + if (id.endsWith('mapped.js')) { + const magicString = new MagicString(code); + magicString.prepend('const removed = true;\nconst alsoRemoved = true; '); + return { + code: magicString.toString(), + map: magicString.generateMap({ hires: true }) + }; + } + } + } + ] + }, + logs: [ + { + level: 'info', + code: 'FIRST_SIDE_EFFECT', + message: `dep-mapped.js (1:0): First side effect in dep-mapped.js is at (2:26) +1: const removed = true; +2: const alsoRemoved = true; console.log('mapped effect'); + ^`, + id: ID_MAPPED, + pos: 48, + loc: { + column: 0, + file: ID_MAPPED, + line: 1 + }, + frame: ` + 1: console.log('mapped effect'); + ^` + }, + { + level: 'info', + code: 'FIRST_SIDE_EFFECT', + message: `main.js (2:0): First side effect in main.js is at (2:0) +1: import './dep-mapped'; +2: console.log('main effect'); + ^ +3: console.log('other effect');`, + id: ID_MAIN, + pos: 23, + loc: { + column: 0, + file: ID_MAIN, + line: 2 + }, + frame: ` + 1: import './dep-mapped'; + 2: console.log('main effect'); + ^ + 3: console.log('other effect');` + } + ] +}); diff --git a/test/form/samples/log-side-effects/_expected.js b/test/form/samples/log-side-effects/_expected.js new file mode 100644 index 00000000000..fb3d0438ba4 --- /dev/null +++ b/test/form/samples/log-side-effects/_expected.js @@ -0,0 +1,4 @@ +console.log('mapped effect'); + +console.log('main effect'); +console.log('other effect'); diff --git a/test/form/samples/log-side-effects/dep-mapped.js b/test/form/samples/log-side-effects/dep-mapped.js new file mode 100644 index 00000000000..dffbed8b079 --- /dev/null +++ b/test/form/samples/log-side-effects/dep-mapped.js @@ -0,0 +1 @@ +console.log('mapped effect'); diff --git a/test/form/samples/log-side-effects/main.js b/test/form/samples/log-side-effects/main.js new file mode 100644 index 00000000000..a18f3778c39 --- /dev/null +++ b/test/form/samples/log-side-effects/main.js @@ -0,0 +1,3 @@ +import './dep-mapped'; +console.log('main effect'); +console.log('other effect'); diff --git a/test/form/samples/logical-expression-with-property-access/_config.js b/test/form/samples/logical-expression-with-property-access/_config.js new file mode 100644 index 00000000000..b1636b09a40 --- /dev/null +++ b/test/form/samples/logical-expression-with-property-access/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'keep logical expressions' +}); diff --git a/test/form/samples/logical-expression-with-property-access/_expected.js b/test/form/samples/logical-expression-with-property-access/_expected.js new file mode 100644 index 00000000000..87feb1127db --- /dev/null +++ b/test/form/samples/logical-expression-with-property-access/_expected.js @@ -0,0 +1,8 @@ +const config = { + someComponent: { }, + default: { config1: 'config1DefaultValue' } +}; + +var main = (config.someComponent || config.default).config1 || 'config1DefaultValue'; + +export { main as default }; diff --git a/test/form/samples/logical-expression-with-property-access/main.js b/test/form/samples/logical-expression-with-property-access/main.js new file mode 100644 index 00000000000..0355da37fef --- /dev/null +++ b/test/form/samples/logical-expression-with-property-access/main.js @@ -0,0 +1,6 @@ +const config = { + someComponent: { someOtherConfig: false }, + default: { config1: 'config1DefaultValue' } +}; + +export default (config.someComponent || config.default).config1 || 'config1DefaultValue'; diff --git a/test/form/samples/logical-expression/deopzimize-while-included/_config.js b/test/form/samples/logical-expression/deopzimize-while-included/_config.js index 343a9689d60..aba539b2fdb 100644 --- a/test/form/samples/logical-expression/deopzimize-while-included/_config.js +++ b/test/form/samples/logical-expression/deopzimize-while-included/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'handles deoptimizations of logical expression while they are inlcuded (#3324)' -}; +}); diff --git a/test/form/samples/logical-expression/deopzimize-while-included/_expected.js b/test/form/samples/logical-expression/deopzimize-while-included/_expected.js index 0bdbdb545f5..fb0bdf81f5e 100644 --- a/test/form/samples/logical-expression/deopzimize-while-included/_expected.js +++ b/test/form/samples/logical-expression/deopzimize-while-included/_expected.js @@ -1,6 +1,6 @@ let isFirstReassigned = false; -const result1 = (foo(), isFirstReassigned ); +const result1 = (foo(), isFirstReassigned); console.log(result1); let isSecondReassigned = false; diff --git a/test/form/samples/logical-expression/mutate-logical-expression/_config.js b/test/form/samples/logical-expression/mutate-logical-expression/_config.js index 718edcc7ca7..0446f8aa8be 100644 --- a/test/form/samples/logical-expression/mutate-logical-expression/_config.js +++ b/test/form/samples/logical-expression/mutate-logical-expression/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'properly handle the results of mutating logical expressions', options: { output: { name: 'bundle' } } -}; +}); diff --git a/test/form/samples/logical-expression/mutate-logical-expression/_expected/amd.js b/test/form/samples/logical-expression/mutate-logical-expression/_expected/amd.js index a3a822306d0..5b474e013d4 100644 --- a/test/form/samples/logical-expression/mutate-logical-expression/_expected/amd.js +++ b/test/form/samples/logical-expression/mutate-logical-expression/_expected/amd.js @@ -1,4 +1,4 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; var aExp = {}; var logicalAExp = aExp || {}; @@ -16,6 +16,4 @@ define(['exports'], function (exports) { 'use strict'; exports.bExp = bExp; exports.cExp = cExp; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/form/samples/logical-expression/mutate-logical-expression/_expected/cjs.js b/test/form/samples/logical-expression/mutate-logical-expression/_expected/cjs.js index cb639a91a09..2a72123b962 100644 --- a/test/form/samples/logical-expression/mutate-logical-expression/_expected/cjs.js +++ b/test/form/samples/logical-expression/mutate-logical-expression/_expected/cjs.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - var aExp = {}; var logicalAExp = aExp || {}; logicalAExp.bar = 1; diff --git a/test/form/samples/logical-expression/mutate-logical-expression/_expected/iife.js b/test/form/samples/logical-expression/mutate-logical-expression/_expected/iife.js index 5a799268786..7dcdf795cbf 100644 --- a/test/form/samples/logical-expression/mutate-logical-expression/_expected/iife.js +++ b/test/form/samples/logical-expression/mutate-logical-expression/_expected/iife.js @@ -17,8 +17,6 @@ var bundle = (function (exports) { exports.bExp = bExp; exports.cExp = cExp; - Object.defineProperty(exports, '__esModule', { value: true }); - return exports; -}({})); +})({}); diff --git a/test/form/samples/logical-expression/mutate-logical-expression/_expected/system.js b/test/form/samples/logical-expression/mutate-logical-expression/_expected/system.js index ff4e7b3145d..640086779a3 100644 --- a/test/form/samples/logical-expression/mutate-logical-expression/_expected/system.js +++ b/test/form/samples/logical-expression/mutate-logical-expression/_expected/system.js @@ -1,20 +1,20 @@ -System.register('bundle', [], function (exports) { +System.register('bundle', [], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - var aExp = exports('aExp', {}); + var aExp = exports("aExp", {}); var logicalAExp = aExp || {}; logicalAExp.bar = 1; - var bExp = exports('bExp', {}); + var bExp = exports("bExp", {}); var logicalBExp = bExp; logicalBExp.bar = 1; - var cExp = exports('cExp', {}); + var cExp = exports("cExp", {}); var logicalCExp = cExp; logicalCExp.bar = 1; - } + }) }; -}); +})); diff --git a/test/form/samples/logical-expression/mutate-logical-expression/_expected/umd.js b/test/form/samples/logical-expression/mutate-logical-expression/_expected/umd.js index d1dc4f9a7d3..f14730028f0 100644 --- a/test/form/samples/logical-expression/mutate-logical-expression/_expected/umd.js +++ b/test/form/samples/logical-expression/mutate-logical-expression/_expected/umd.js @@ -2,7 +2,7 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.bundle = {})); -}(this, (function (exports) { 'use strict'; +})(this, (function (exports) { 'use strict'; var aExp = {}; var logicalAExp = aExp || {}; @@ -20,6 +20,4 @@ exports.bExp = bExp; exports.cExp = cExp; - Object.defineProperty(exports, '__esModule', { value: true }); - -}))); +})); diff --git a/test/form/samples/logical-expression/simplify-non-boolean/_config.js b/test/form/samples/logical-expression/simplify-non-boolean/_config.js index d9e89aa08a1..687f0950ff9 100644 --- a/test/form/samples/logical-expression/simplify-non-boolean/_config.js +++ b/test/form/samples/logical-expression/simplify-non-boolean/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'simplifies logical expressions that resolve statically to non-boolean values' -}; +}); diff --git a/test/form/samples/logical-expression/simplify-non-boolean/_expected.js b/test/form/samples/logical-expression/simplify-non-boolean/_expected.js index d887e0745c8..9aba650ea35 100644 --- a/test/form/samples/logical-expression/simplify-non-boolean/_expected.js +++ b/test/form/samples/logical-expression/simplify-non-boolean/_expected.js @@ -1,6 +1,6 @@ -console.log('keep' ); +console.log('keep'); console.log('keep'); const x = 'keep'; -console.log(x ); +console.log(x); console.log(x); diff --git a/test/form/samples/make-absolute-externals-relative/make-relative-false/_config.js b/test/form/samples/make-absolute-externals-relative/make-relative-false/_config.js index b364476bf6c..40376e9a69d 100644 --- a/test/form/samples/make-absolute-externals-relative/make-relative-false/_config.js +++ b/test/form/samples/make-absolute-externals-relative/make-relative-false/_config.js @@ -1,9 +1,9 @@ -const path = require('path'); -const assert = require('assert'); +const assert = require('node:assert'); +const path = require('node:path'); const ID_MAIN = path.join(__dirname, 'main.js'); -module.exports = { +module.exports = defineTest({ description: 'does not normalize external paths when set to false', options: { makeAbsoluteExternalsRelative: false, @@ -18,28 +18,35 @@ module.exports = { ) return true; }, - plugins: { - async buildStart() { - const testExternal = async (source, expected) => - assert.deepStrictEqual((await this.resolve(source, ID_MAIN)).external, expected, source); + plugins: [ + { + name: 'test', + async buildStart() { + const testExternal = async (source, expected) => + assert.deepStrictEqual( + (await this.resolve(source, ID_MAIN, { skipSelf: false })).external, + expected, + source + ); - await testExternal('./relativeUnresolved.js', true); - await testExternal('/absolute.js', 'absolute'); - await testExternal('./pluginDirect.js', true); - await testExternal('/pluginDifferentAbsolute.js', 'absolute'); - await testExternal('./pluginTrue.js', 'absolute'); - await testExternal('./pluginForceAbsolute.js', 'absolute'); - await testExternal('./pluginForceRelative.js', true); - }, - resolveId(source) { - if (source.endsWith('/pluginDirect.js')) return false; - if (source.endsWith('/pluginDifferentAbsolute.js')) return '/pluginAbsolute.js'; - if (source.endsWith('/pluginTrue.js')) return { id: '/pluginTrue.js', external: true }; - if (source.endsWith('/pluginForceAbsolute.js')) - return { id: '/pluginForceAbsolute.js', external: 'absolute' }; - if (source.endsWith('/pluginForceRelative.js')) - return { id: path.join(__dirname, 'pluginForceRelative.js'), external: 'relative' }; + await testExternal('./relativeUnresolved.js', true); + await testExternal('/absolute.js', 'absolute'); + await testExternal('./pluginDirect.js', true); + await testExternal('/pluginDifferentAbsolute.js', 'absolute'); + await testExternal('./pluginTrue.js', 'absolute'); + await testExternal('./pluginForceAbsolute.js', 'absolute'); + await testExternal('./pluginForceRelative.js', true); + }, + resolveId(source) { + if (source.endsWith('/pluginDirect.js')) return false; + if (source.endsWith('/pluginDifferentAbsolute.js')) return '/pluginAbsolute.js'; + if (source.endsWith('/pluginTrue.js')) return { id: '/pluginTrue.js', external: true }; + if (source.endsWith('/pluginForceAbsolute.js')) + return { id: '/pluginForceAbsolute.js', external: 'absolute' }; + if (source.endsWith('/pluginForceRelative.js')) + return { id: path.join(__dirname, 'pluginForceRelative.js'), external: 'relative' }; + } } - } + ] } -}; +}); diff --git a/test/form/samples/make-absolute-externals-relative/make-relative-relative/_config.js b/test/form/samples/make-absolute-externals-relative/make-relative-relative/_config.js index 2c5cfd74053..bfea6235c72 100644 --- a/test/form/samples/make-absolute-externals-relative/make-relative-relative/_config.js +++ b/test/form/samples/make-absolute-externals-relative/make-relative-relative/_config.js @@ -1,9 +1,9 @@ -const path = require('path'); -const assert = require('assert'); +const assert = require('node:assert'); +const path = require('node:path'); const ID_MAIN = path.join(__dirname, 'main.js'); -module.exports = { +module.exports = defineTest({ description: 'only normalizes external paths that were originally relative when set to "ifRelativeSource"', options: { @@ -21,31 +21,38 @@ module.exports = { ) return true; }, - plugins: { - async buildStart() { - const testExternal = async (source, expected) => - assert.deepStrictEqual((await this.resolve(source, ID_MAIN)).external, expected, source); + plugins: [ + { + name: 'test', + async buildStart() { + const testExternal = async (source, expected) => + assert.deepStrictEqual( + (await this.resolve(source, ID_MAIN, { skipSelf: false })).external, + expected, + source + ); - await testExternal('./relativeUnresolved.js', true); - await testExternal('./relativeMissing.js', true); - await testExternal('./relativeExisting.js', true); - await testExternal('/absolute.js', 'absolute'); - await testExternal('./pluginDirect.js', true); - await testExternal('/pluginDifferentAbsolute.js', 'absolute'); - await testExternal('./pluginTrue.js', true); - await testExternal('./pluginForceAbsolute.js', 'absolute'); - await testExternal('./pluginForceRelative.js', true); - }, - resolveId(source) { - if (source.endsWith('/pluginDirect.js')) return false; - if (source.endsWith('/pluginDifferentAbsolute.js')) return '/pluginAbsolute.js'; - if (source.endsWith('/pluginTrue.js')) - return { id: path.join(__dirname, 'pluginTrue.js'), external: true }; - if (source.endsWith('/pluginForceAbsolute.js')) - return { id: '/pluginForceAbsolute.js', external: 'absolute' }; - if (source.endsWith('/pluginForceRelative.js')) - return { id: path.join(__dirname, 'pluginForceRelative.js'), external: 'relative' }; + await testExternal('./relativeUnresolved.js', true); + await testExternal('./relativeMissing.js', true); + await testExternal('./relativeExisting.js', true); + await testExternal('/absolute.js', 'absolute'); + await testExternal('./pluginDirect.js', true); + await testExternal('/pluginDifferentAbsolute.js', 'absolute'); + await testExternal('./pluginTrue.js', true); + await testExternal('./pluginForceAbsolute.js', 'absolute'); + await testExternal('./pluginForceRelative.js', true); + }, + resolveId(source) { + if (source.endsWith('/pluginDirect.js')) return false; + if (source.endsWith('/pluginDifferentAbsolute.js')) return '/pluginAbsolute.js'; + if (source.endsWith('/pluginTrue.js')) + return { id: path.join(__dirname, 'pluginTrue.js'), external: true }; + if (source.endsWith('/pluginForceAbsolute.js')) + return { id: '/pluginForceAbsolute.js', external: 'absolute' }; + if (source.endsWith('/pluginForceRelative.js')) + return { id: path.join(__dirname, 'pluginForceRelative.js'), external: 'relative' }; + } } - } + ] } -}; +}); diff --git a/test/form/samples/make-absolute-externals-relative/make-relative-true/_config.js b/test/form/samples/make-absolute-externals-relative/make-relative-true/_config.js index 100574d7e54..f67034020a6 100644 --- a/test/form/samples/make-absolute-externals-relative/make-relative-true/_config.js +++ b/test/form/samples/make-absolute-externals-relative/make-relative-true/_config.js @@ -1,9 +1,9 @@ -const path = require('path'); -const assert = require('assert'); +const assert = require('node:assert'); +const path = require('node:path'); const ID_MAIN = path.join(__dirname, 'main.js'); -module.exports = { +module.exports = defineTest({ description: 'normalizes both relative and absolute external paths when set to true', options: { makeAbsoluteExternalsRelative: true, @@ -20,33 +20,40 @@ module.exports = { ) return true; }, - plugins: { - async buildStart() { - const testExternal = async (source, expected) => - assert.deepStrictEqual((await this.resolve(source, ID_MAIN)).external, expected, source); + plugins: [ + { + name: 'test', + async buildStart() { + const testExternal = async (source, expected) => + assert.deepStrictEqual( + (await this.resolve(source, ID_MAIN, { skipSelf: false })).external, + expected, + source + ); - await testExternal('./relativeUnresolved.js', true); - await testExternal('./relativeMissing.js', true); - await testExternal('./relativeExisting.js', true); - await testExternal('/absolute.js', true); - await testExternal('./pluginDirect.js', true); - await testExternal('/pluginDifferentAbsolute.js', true); - await testExternal('./pluginTrue.js', true); - await testExternal('./pluginForceAbsolute.js', 'absolute'); - await testExternal('./pluginForceRelative.js', true); - }, - resolveId(source) { - if (source.endsWith('/pluginDirect.js')) return false; - if (source.endsWith('/pluginDifferentAbsolute.js')) - return path.join(__dirname, 'pluginAbsolute.js'); - if (source.endsWith('/pluginTrue.js')) - return { id: path.join(__dirname, 'pluginTrue.js'), external: true }; - if (source.endsWith('/pluginForceAbsolute.js')) - return { id: '/pluginForceAbsolute.js', external: 'absolute' }; - if (source.endsWith('/pluginForceRelative.js')) - return { id: path.join(__dirname, 'pluginForceRelative.js'), external: 'relative' }; - if (source === '/absolute.js') return path.join(__dirname, 'absolute.js'); + await testExternal('./relativeUnresolved.js', true); + await testExternal('./relativeMissing.js', true); + await testExternal('./relativeExisting.js', true); + await testExternal('/absolute.js', true); + await testExternal('./pluginDirect.js', true); + await testExternal('/pluginDifferentAbsolute.js', true); + await testExternal('./pluginTrue.js', true); + await testExternal('./pluginForceAbsolute.js', 'absolute'); + await testExternal('./pluginForceRelative.js', true); + }, + resolveId(source) { + if (source.endsWith('/pluginDirect.js')) return false; + if (source.endsWith('/pluginDifferentAbsolute.js')) + return path.join(__dirname, 'pluginAbsolute.js'); + if (source.endsWith('/pluginTrue.js')) + return { id: path.join(__dirname, 'pluginTrue.js'), external: true }; + if (source.endsWith('/pluginForceAbsolute.js')) + return { id: '/pluginForceAbsolute.js', external: 'absolute' }; + if (source.endsWith('/pluginForceRelative.js')) + return { id: path.join(__dirname, 'pluginForceRelative.js'), external: 'relative' }; + if (source === '/absolute.js') return path.join(__dirname, 'absolute.js'); + } } - } + ] } -}; +}); diff --git a/test/form/samples/manual-pure-functions/_config.js b/test/form/samples/manual-pure-functions/_config.js new file mode 100644 index 00000000000..246a6298b8b --- /dev/null +++ b/test/form/samples/manual-pure-functions/_config.js @@ -0,0 +1,6 @@ +module.exports = defineTest({ + description: 'allows to manually declare functions as pure by name', + options: { + treeshake: { manualPureFunctions: ['foo', 'bar.a'] } + } +}); diff --git a/test/form/samples/manual-pure-functions/_expected.js b/test/form/samples/manual-pure-functions/_expected.js new file mode 100644 index 00000000000..85b4bcc2aef --- /dev/null +++ b/test/form/samples/manual-pure-functions/_expected.js @@ -0,0 +1,15 @@ +const lib = { + a: () => { + console.log(); + return () => { + console.log(); + return () => { + console.log(); + return console.log; + } + } + } +}; + +lib(); // not removed +lib.b(); // not removed diff --git a/test/form/samples/manual-pure-functions/main.js b/test/form/samples/manual-pure-functions/main.js new file mode 100644 index 00000000000..4e1f1774424 --- /dev/null +++ b/test/form/samples/manual-pure-functions/main.js @@ -0,0 +1,27 @@ +import { lib as bar } from './other'; + +foo; // removed +foo(); // removed +foo.a; // removed +foo.a(); // removed +foo.a()(); // removed +foo.a().a; // removed +foo.a().a(); // removed +foo.a().a()(); // removed +foo.a().a().a; // removed +foo.a().a().a(); // removed + +bar(); // not removed +bar.b(); // not removed + +bar.a(); // removed +bar?.a(); // removed +bar.a.a; // removed +bar.a.a(); // removed +bar.a()(); //removed +bar.a().a; //removed +bar.a().a(); //removed +bar.a()()(); //removed +bar.a()().a; //removed +bar.a()().a(); //removed + diff --git a/test/form/samples/manual-pure-functions/other.js b/test/form/samples/manual-pure-functions/other.js new file mode 100644 index 00000000000..26d73ff481a --- /dev/null +++ b/test/form/samples/manual-pure-functions/other.js @@ -0,0 +1,12 @@ +export const lib = { + a: () => { + console.log(); + return () => { + console.log(); + return () => { + console.log(); + return console.log; + } + } + } +}; diff --git a/test/form/samples/merge-namespaces-non-live/_config.js b/test/form/samples/merge-namespaces-non-live/_config.js new file mode 100644 index 00000000000..7a35b13fc6d --- /dev/null +++ b/test/form/samples/merge-namespaces-non-live/_config.js @@ -0,0 +1,14 @@ +module.exports = defineTest({ + description: 'merges namespaces without live-bindings', + options: { + external: ['external1', 'external2'], + output: { externalLiveBindings: false }, + plugins: [ + { + transform() { + return { syntheticNamedExports: '__synthetic' }; + } + } + ] + } +}); diff --git a/test/form/samples/merge-namespaces-non-live/_expected.js b/test/form/samples/merge-namespaces-non-live/_expected.js new file mode 100644 index 00000000000..db09de273d3 --- /dev/null +++ b/test/form/samples/merge-namespaces-non-live/_expected.js @@ -0,0 +1,24 @@ +import * as external1 from 'external1'; +import * as external2 from 'external2'; + +function _mergeNamespaces(n, m) { + for (var i = 0; i < m.length; i++) { + var e = m[i]; + if (typeof e !== 'string' && !Array.isArray(e)) { for (var k in e) { + if (k !== 'default' && !(k in n)) { + n[k] = e[k]; + } + } } + } + return Object.freeze(n); +} + +const __synthetic$1 = { module: 'synthetic' }; + +const __synthetic = { module: 'reexport' }; + +var ns = /*#__PURE__*/_mergeNamespaces({ + __proto__: null +}, [__synthetic, __synthetic$1, external1, external2]); + +console.log(ns); diff --git a/test/form/samples/merge-namespaces-non-live/main.js b/test/form/samples/merge-namespaces-non-live/main.js new file mode 100644 index 00000000000..284d29f7127 --- /dev/null +++ b/test/form/samples/merge-namespaces-non-live/main.js @@ -0,0 +1,2 @@ +import * as ns from './reexport'; +console.log(ns); diff --git a/test/form/samples/merge-namespaces-non-live/reexport.js b/test/form/samples/merge-namespaces-non-live/reexport.js new file mode 100644 index 00000000000..9204c816376 --- /dev/null +++ b/test/form/samples/merge-namespaces-non-live/reexport.js @@ -0,0 +1,4 @@ +export * from 'external1'; +export * from './synthetic'; +export * from 'external2'; +export const __synthetic = { module: 'reexport' }; diff --git a/test/form/samples/merge-namespaces-non-live/synthetic.js b/test/form/samples/merge-namespaces-non-live/synthetic.js new file mode 100644 index 00000000000..b180a18b691 --- /dev/null +++ b/test/form/samples/merge-namespaces-non-live/synthetic.js @@ -0,0 +1 @@ +export const __synthetic = { module: 'synthetic' }; diff --git a/test/form/samples/merge-namespaces/_config.js b/test/form/samples/merge-namespaces/_config.js new file mode 100644 index 00000000000..be3a1da6d64 --- /dev/null +++ b/test/form/samples/merge-namespaces/_config.js @@ -0,0 +1,14 @@ +module.exports = defineTest({ + description: 'merges namespaces with live-bindings', + options: { + external: ['external1', 'external2'], + plugins: [ + { + name: 'test', + transform() { + return { syntheticNamedExports: '__synthetic' }; + } + } + ] + } +}); diff --git a/test/form/samples/merge-namespaces/_expected.js b/test/form/samples/merge-namespaces/_expected.js new file mode 100644 index 00000000000..e3d670024b7 --- /dev/null +++ b/test/form/samples/merge-namespaces/_expected.js @@ -0,0 +1,27 @@ +import * as external1 from 'external1'; +import * as external2 from 'external2'; + +function _mergeNamespaces(n, m) { + m.forEach(function (e) { + e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) { + if (k !== 'default' && !(k in n)) { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + }); + return Object.freeze(n); +} + +const __synthetic$1 = { module: 'synthetic' }; + +const __synthetic = { module: 'reexport' }; + +var ns = /*#__PURE__*/_mergeNamespaces({ + __proto__: null +}, [__synthetic, __synthetic$1, external1, external2]); + +console.log(ns); diff --git a/test/form/samples/merge-namespaces/main.js b/test/form/samples/merge-namespaces/main.js new file mode 100644 index 00000000000..284d29f7127 --- /dev/null +++ b/test/form/samples/merge-namespaces/main.js @@ -0,0 +1,2 @@ +import * as ns from './reexport'; +console.log(ns); diff --git a/test/form/samples/merge-namespaces/reexport.js b/test/form/samples/merge-namespaces/reexport.js new file mode 100644 index 00000000000..9204c816376 --- /dev/null +++ b/test/form/samples/merge-namespaces/reexport.js @@ -0,0 +1,4 @@ +export * from 'external1'; +export * from './synthetic'; +export * from 'external2'; +export const __synthetic = { module: 'reexport' }; diff --git a/test/form/samples/merge-namespaces/synthetic.js b/test/form/samples/merge-namespaces/synthetic.js new file mode 100644 index 00000000000..b180a18b691 --- /dev/null +++ b/test/form/samples/merge-namespaces/synthetic.js @@ -0,0 +1 @@ +export const __synthetic = { module: 'synthetic' }; diff --git a/test/form/samples/minimal-this-mutation/_config.js b/test/form/samples/minimal-this-mutation/_config.js new file mode 100644 index 00000000000..4a103617241 --- /dev/null +++ b/test/form/samples/minimal-this-mutation/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'mutates "this" only if necessary on function calls' +}); diff --git a/test/form/samples/minimal-this-mutation/_expected.js b/test/form/samples/minimal-this-mutation/_expected.js new file mode 100644 index 00000000000..58798f2302d --- /dev/null +++ b/test/form/samples/minimal-this-mutation/_expected.js @@ -0,0 +1,42 @@ +console.log('retained'); + +const obj2 = { + noMutationEffect() { + console.log('effect'); + }, + prop: true +}; +obj2.noMutationEffect(); +console.log('retained'); + +const obj3 = { + mutateProp() { + this.prop = false; + }, + prop: true +}; +obj3.mutateProp(); +if (obj3.prop) console.log('unimportant'); +else console.log('retained'); + +const obj4 = { + mutateUnknownProp() { + this[globalThis.unknown] = false; + }, + prop: true +}; +obj4.mutateUnknownProp(); +if (obj4.prop) console.log('retained'); +else console.log('retained'); + +const obj5 = { + mutateNestedProp() { + this.nested.prop = false; + }, + nested: { + prop: true + } +}; +obj5.mutateNestedProp(); +if (obj5.nested.prop) console.log('unimportant'); +else console.log('retained'); diff --git a/test/form/samples/minimal-this-mutation/main.js b/test/form/samples/minimal-this-mutation/main.js new file mode 100644 index 00000000000..39643af9776 --- /dev/null +++ b/test/form/samples/minimal-this-mutation/main.js @@ -0,0 +1,49 @@ +const obj1 = { + noMutation() {}, + prop: true +}; +obj1.noMutation(); +if (obj1.prop) console.log('retained'); +else console.log('removed'); + +const obj2 = { + noMutationEffect() { + console.log('effect'); + }, + prop: true +}; +obj2.noMutationEffect(); +if (obj2.prop) console.log('retained'); +else console.log('removed'); + +const obj3 = { + mutateProp() { + this.prop = false; + }, + prop: true +}; +obj3.mutateProp(); +if (obj3.prop) console.log('unimportant'); +else console.log('retained'); + +const obj4 = { + mutateUnknownProp() { + this[globalThis.unknown] = false; + }, + prop: true +}; +obj4.mutateUnknownProp(); +if (obj4.prop) console.log('retained'); +else console.log('retained'); + +const obj5 = { + mutateNestedProp() { + this.nested.prop = false; + }, + nested: { + prop: true + } +}; +obj5.mutateNestedProp(); +if (obj5.nested.prop) console.log('unimportant'); +else console.log('retained'); diff --git a/test/form/samples/mjs/_config.js b/test/form/samples/mjs/_config.js index 60c794c3f75..715a733d317 100644 --- a/test/form/samples/mjs/_config.js +++ b/test/form/samples/mjs/_config.js @@ -1,6 +1,6 @@ -module.exports = { +module.exports = defineTest({ description: 'supports loading mjs with precedence', options: { output: { name: 'myBundle' } } -}; +}); diff --git a/test/form/samples/mjs/_expected/amd.js b/test/form/samples/mjs/_expected/amd.js index 91c442efc04..387e4aaf6c2 100644 --- a/test/form/samples/mjs/_expected/amd.js +++ b/test/form/samples/mjs/_expected/amd.js @@ -1,4 +1,4 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; var dep$1 = 'js'; @@ -7,6 +7,4 @@ define(['exports'], function (exports) { 'use strict'; exports.depJs = dep$1; exports.depMjs = dep; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/form/samples/mjs/_expected/cjs.js b/test/form/samples/mjs/_expected/cjs.js index e4cae3624e3..50133a96f36 100644 --- a/test/form/samples/mjs/_expected/cjs.js +++ b/test/form/samples/mjs/_expected/cjs.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - var dep$1 = 'js'; var dep = 'mjs'; diff --git a/test/form/samples/mjs/_expected/iife.js b/test/form/samples/mjs/_expected/iife.js index 9e444ea167c..f6988777ecd 100644 --- a/test/form/samples/mjs/_expected/iife.js +++ b/test/form/samples/mjs/_expected/iife.js @@ -8,8 +8,6 @@ var myBundle = (function (exports) { exports.depJs = dep$1; exports.depMjs = dep; - Object.defineProperty(exports, '__esModule', { value: true }); - return exports; -}({})); +})({}); diff --git a/test/form/samples/mjs/_expected/system.js b/test/form/samples/mjs/_expected/system.js index 00fd6bc565c..b8215648755 100644 --- a/test/form/samples/mjs/_expected/system.js +++ b/test/form/samples/mjs/_expected/system.js @@ -1,12 +1,12 @@ -System.register('myBundle', [], function (exports) { +System.register('myBundle', [], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - var dep$1 = exports('depJs', 'js'); + var dep$1 = exports("depJs", 'js'); - var dep = exports('depMjs', 'mjs'); + var dep = exports("depMjs", 'mjs'); - } + }) }; -}); +})); diff --git a/test/form/samples/mjs/_expected/umd.js b/test/form/samples/mjs/_expected/umd.js index d1e95c0e1c1..1fcc3857b96 100644 --- a/test/form/samples/mjs/_expected/umd.js +++ b/test/form/samples/mjs/_expected/umd.js @@ -2,7 +2,7 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.myBundle = {})); -}(this, (function (exports) { 'use strict'; +})(this, (function (exports) { 'use strict'; var dep$1 = 'js'; @@ -11,6 +11,4 @@ exports.depJs = dep$1; exports.depMjs = dep; - Object.defineProperty(exports, '__esModule', { value: true }); - -}))); +})); diff --git a/test/form/samples/modify-class-prototype/_config.js b/test/form/samples/modify-class-prototype/_config.js index dbb4ba7c10b..e72a389e0d7 100644 --- a/test/form/samples/modify-class-prototype/_config.js +++ b/test/form/samples/modify-class-prototype/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'tree-shakes prototype modifications of classes' -}; +}); diff --git a/test/form/samples/modify-class-prototype/_expected.js b/test/form/samples/modify-class-prototype/_expected.js index 61e4f3c329f..8dd53679723 100644 --- a/test/form/samples/modify-class-prototype/_expected.js +++ b/test/form/samples/modify-class-prototype/_expected.js @@ -3,4 +3,12 @@ Retained.prop = 42; Retained.prototype.prop = 43; Retained.prototype.prop2 = Retained.prototype.prop; +class RetainedSuper { + set prop(v) { + console.log('effect', v); + } +} +class RetainedWithSuper extends RetainedSuper {} +RetainedWithSuper.prototype.prop = 42; + export { Retained }; diff --git a/test/form/samples/modify-class-prototype/main.js b/test/form/samples/modify-class-prototype/main.js index 38f8fa9abf0..1bf13d724dc 100644 --- a/test/form/samples/modify-class-prototype/main.js +++ b/test/form/samples/modify-class-prototype/main.js @@ -7,3 +7,18 @@ export class Retained {} Retained.prop = 42; Retained.prototype.prop = 43; Retained.prototype.prop2 = Retained.prototype.prop; + +class RemovedSuper { + prop() {} +} +class RemovedWithSuper extends RemovedSuper {} +RemovedWithSuper.prototype.prop = 42; +RemovedWithSuper.prototype.prop2 = 43; + +class RetainedSuper { + set prop(v) { + console.log('effect', v); + } +} +class RetainedWithSuper extends RetainedSuper {} +RetainedWithSuper.prototype.prop = 42; diff --git a/test/form/samples/modify-export-semi/_config.js b/test/form/samples/modify-export-semi/_config.js index fdfad5c045b..940d37cb3bc 100644 --- a/test/form/samples/modify-export-semi/_config.js +++ b/test/form/samples/modify-export-semi/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'inserts semicolons correctly when modifying SystemJS exports', formats: ['system'] -}; +}); diff --git a/test/form/samples/modify-export-semi/_expected/system.js b/test/form/samples/modify-export-semi/_expected/system.js index 1362736a2ba..ac4972a78fb 100644 --- a/test/form/samples/modify-export-semi/_expected/system.js +++ b/test/form/samples/modify-export-semi/_expected/system.js @@ -1,12 +1,12 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - let foo = exports('foo', 'foo'); + let foo = exports("foo", 'foo'); - foo = exports('foo', 'bar'); + exports("foo", foo = 'bar'); - } + }) }; -}); +})); diff --git a/test/form/samples/module-name-scoped-package/_config.js b/test/form/samples/module-name-scoped-package/_config.js index 626820672e1..f8007adfdf8 100644 --- a/test/form/samples/module-name-scoped-package/_config.js +++ b/test/form/samples/module-name-scoped-package/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'allows module name with dashes to be added to the global object', options: { output: { @@ -6,4 +6,4 @@ module.exports = { name: '@scoped/npm-package' } } -}; +}); diff --git a/test/form/samples/module-name-scoped-package/_expected/amd.js b/test/form/samples/module-name-scoped-package/_expected/amd.js index 69586a0bf90..30fcfbbe3fd 100644 --- a/test/form/samples/module-name-scoped-package/_expected/amd.js +++ b/test/form/samples/module-name-scoped-package/_expected/amd.js @@ -1,9 +1,7 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; let foo = 'foo'; exports.foo = foo; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/form/samples/module-name-scoped-package/_expected/cjs.js b/test/form/samples/module-name-scoped-package/_expected/cjs.js index 796e3ef7f16..0814d99690d 100644 --- a/test/form/samples/module-name-scoped-package/_expected/cjs.js +++ b/test/form/samples/module-name-scoped-package/_expected/cjs.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - let foo = 'foo'; exports.foo = foo; diff --git a/test/form/samples/module-name-scoped-package/_expected/iife.js b/test/form/samples/module-name-scoped-package/_expected/iife.js index fc011459c39..6568d188a8b 100644 --- a/test/form/samples/module-name-scoped-package/_expected/iife.js +++ b/test/form/samples/module-name-scoped-package/_expected/iife.js @@ -5,6 +5,4 @@ exports.foo = foo; - Object.defineProperty(exports, '__esModule', { value: true }); - -}(this['@scoped/npm-package'] = this['@scoped/npm-package'] || {})); +})(this["@scoped/npm-package"] = this["@scoped/npm-package"] || {}); diff --git a/test/form/samples/module-name-scoped-package/_expected/system.js b/test/form/samples/module-name-scoped-package/_expected/system.js index 108c8452186..671a803bb96 100644 --- a/test/form/samples/module-name-scoped-package/_expected/system.js +++ b/test/form/samples/module-name-scoped-package/_expected/system.js @@ -1,10 +1,10 @@ -System.register('@scoped/npm-package', [], function (exports) { +System.register('@scoped/npm-package', [], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - let foo = exports('foo', 'foo'); + let foo = exports("foo", 'foo'); - } + }) }; -}); +})); diff --git a/test/form/samples/module-name-scoped-package/_expected/umd.js b/test/form/samples/module-name-scoped-package/_expected/umd.js index 166d41cb4d2..9fd7f3b9c0e 100644 --- a/test/form/samples/module-name-scoped-package/_expected/umd.js +++ b/test/form/samples/module-name-scoped-package/_expected/umd.js @@ -1,13 +1,11 @@ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'], factory) : - (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global['@scoped/npm-package'] = global['@scoped/npm-package'] || {})); -}(this, (function (exports) { 'use strict'; + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["@scoped/npm-package"] = global["@scoped/npm-package"] || {})); +})(this, (function (exports) { 'use strict'; let foo = 'foo'; exports.foo = foo; - Object.defineProperty(exports, '__esModule', { value: true }); - -}))); +})); diff --git a/test/form/samples/module-name-wat/_config.js b/test/form/samples/module-name-wat/_config.js index 9ad3bdab211..ba778abf7a4 100644 --- a/test/form/samples/module-name-wat/_config.js +++ b/test/form/samples/module-name-wat/_config.js @@ -1,6 +1,6 @@ -module.exports = { +module.exports = defineTest({ description: 'properly dereferences properties on the global object regardless of nesting', options: { output: { name: 'foo.@scoped/npm-package.bar.why-would-you-do-this' } } -}; +}); diff --git a/test/form/samples/module-name-wat/_expected/amd.js b/test/form/samples/module-name-wat/_expected/amd.js index 69586a0bf90..30fcfbbe3fd 100644 --- a/test/form/samples/module-name-wat/_expected/amd.js +++ b/test/form/samples/module-name-wat/_expected/amd.js @@ -1,9 +1,7 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; let foo = 'foo'; exports.foo = foo; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/form/samples/module-name-wat/_expected/cjs.js b/test/form/samples/module-name-wat/_expected/cjs.js index 796e3ef7f16..0814d99690d 100644 --- a/test/form/samples/module-name-wat/_expected/cjs.js +++ b/test/form/samples/module-name-wat/_expected/cjs.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - let foo = 'foo'; exports.foo = foo; diff --git a/test/form/samples/module-name-wat/_expected/iife.js b/test/form/samples/module-name-wat/_expected/iife.js index d178e0a8e3f..999bbce831e 100644 --- a/test/form/samples/module-name-wat/_expected/iife.js +++ b/test/form/samples/module-name-wat/_expected/iife.js @@ -1,15 +1,13 @@ this.foo = this.foo || {}; -this.foo['@scoped/npm-package'] = this.foo['@scoped/npm-package'] || {}; -this.foo['@scoped/npm-package'].bar = this.foo['@scoped/npm-package'].bar || {}; -this.foo['@scoped/npm-package'].bar['why-would-you-do-this'] = (function (exports) { +this.foo["@scoped/npm-package"] = this.foo["@scoped/npm-package"] || {}; +this.foo["@scoped/npm-package"].bar = this.foo["@scoped/npm-package"].bar || {}; +this.foo["@scoped/npm-package"].bar["why-would-you-do-this"] = (function (exports) { 'use strict'; let foo = 'foo'; exports.foo = foo; - Object.defineProperty(exports, '__esModule', { value: true }); - return exports; -}({})); +})({}); diff --git a/test/form/samples/module-name-wat/_expected/system.js b/test/form/samples/module-name-wat/_expected/system.js index 3c99ddb52d0..215182055b3 100644 --- a/test/form/samples/module-name-wat/_expected/system.js +++ b/test/form/samples/module-name-wat/_expected/system.js @@ -1,10 +1,10 @@ -System.register('foo.@scoped/npm-package.bar.why-would-you-do-this', [], function (exports) { +System.register('foo.@scoped/npm-package.bar.why-would-you-do-this', [], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - let foo = exports('foo', 'foo'); + let foo = exports("foo", 'foo'); - } + }) }; -}); +})); diff --git a/test/form/samples/module-name-wat/_expected/umd.js b/test/form/samples/module-name-wat/_expected/umd.js index 3f76848c075..87d8fb89915 100644 --- a/test/form/samples/module-name-wat/_expected/umd.js +++ b/test/form/samples/module-name-wat/_expected/umd.js @@ -1,13 +1,11 @@ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'], factory) : - (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.foo = global.foo || {}, global.foo['@scoped/npm-package'] = global.foo['@scoped/npm-package'] || {}, global.foo['@scoped/npm-package'].bar = global.foo['@scoped/npm-package'].bar || {}, global.foo['@scoped/npm-package'].bar['why-would-you-do-this'] = {}))); -}(this, (function (exports) { 'use strict'; + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.foo = global.foo || {}, global.foo["@scoped/npm-package"] = global.foo["@scoped/npm-package"] || {}, global.foo["@scoped/npm-package"].bar = global.foo["@scoped/npm-package"].bar || {}, global.foo["@scoped/npm-package"].bar["why-would-you-do-this"] = {}))); +})(this, (function (exports) { 'use strict'; let foo = 'foo'; exports.foo = foo; - Object.defineProperty(exports, '__esModule', { value: true }); - -}))); +})); diff --git a/test/form/samples/module-name-with-dashes/_config.js b/test/form/samples/module-name-with-dashes/_config.js index 81896a88172..635eda74c3b 100644 --- a/test/form/samples/module-name-with-dashes/_config.js +++ b/test/form/samples/module-name-with-dashes/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'allows module name with dashes to be added to the global object', options: { output: { @@ -6,4 +6,4 @@ module.exports = { name: 'module-name-with-dashes' } } -}; +}); diff --git a/test/form/samples/module-name-with-dashes/_expected/amd.js b/test/form/samples/module-name-with-dashes/_expected/amd.js index 69586a0bf90..30fcfbbe3fd 100644 --- a/test/form/samples/module-name-with-dashes/_expected/amd.js +++ b/test/form/samples/module-name-with-dashes/_expected/amd.js @@ -1,9 +1,7 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; let foo = 'foo'; exports.foo = foo; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/form/samples/module-name-with-dashes/_expected/cjs.js b/test/form/samples/module-name-with-dashes/_expected/cjs.js index 796e3ef7f16..0814d99690d 100644 --- a/test/form/samples/module-name-with-dashes/_expected/cjs.js +++ b/test/form/samples/module-name-with-dashes/_expected/cjs.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - let foo = 'foo'; exports.foo = foo; diff --git a/test/form/samples/module-name-with-dashes/_expected/iife.js b/test/form/samples/module-name-with-dashes/_expected/iife.js index 9ee7dad90d3..2576c4735ca 100644 --- a/test/form/samples/module-name-with-dashes/_expected/iife.js +++ b/test/form/samples/module-name-with-dashes/_expected/iife.js @@ -5,6 +5,4 @@ exports.foo = foo; - Object.defineProperty(exports, '__esModule', { value: true }); - -}(this['module-name-with-dashes'] = this['module-name-with-dashes'] || {})); +})(this["module-name-with-dashes"] = this["module-name-with-dashes"] || {}); diff --git a/test/form/samples/module-name-with-dashes/_expected/system.js b/test/form/samples/module-name-with-dashes/_expected/system.js index 7bc269a7391..9cb5aaeeef9 100644 --- a/test/form/samples/module-name-with-dashes/_expected/system.js +++ b/test/form/samples/module-name-with-dashes/_expected/system.js @@ -1,10 +1,10 @@ -System.register('module-name-with-dashes', [], function (exports) { +System.register('module-name-with-dashes', [], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - let foo = exports('foo', 'foo'); + let foo = exports("foo", 'foo'); - } + }) }; -}); +})); diff --git a/test/form/samples/module-name-with-dashes/_expected/umd.js b/test/form/samples/module-name-with-dashes/_expected/umd.js index 1c4f3846955..be8d785c33b 100644 --- a/test/form/samples/module-name-with-dashes/_expected/umd.js +++ b/test/form/samples/module-name-with-dashes/_expected/umd.js @@ -1,13 +1,11 @@ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'], factory) : - (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global['module-name-with-dashes'] = global['module-name-with-dashes'] || {})); -}(this, (function (exports) { 'use strict'; + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["module-name-with-dashes"] = global["module-name-with-dashes"] || {})); +})(this, (function (exports) { 'use strict'; let foo = 'foo'; exports.foo = foo; - Object.defineProperty(exports, '__esModule', { value: true }); - -}))); +})); diff --git a/test/form/samples/module-no-treeshake/_config.js b/test/form/samples/module-no-treeshake/_config.js index cc6f3fede85..49b72992fc0 100644 --- a/test/form/samples/module-no-treeshake/_config.js +++ b/test/form/samples/module-no-treeshake/_config.js @@ -2,40 +2,42 @@ function getCode(id) { return `const unused = 'unused in ${id}';`; } -module.exports = { +module.exports = defineTest({ description: 'allows disabling tree-shaking for modules', options: { - plugins: { - resolveId(id) { - if (id.startsWith('dep')) { - if (id === 'depResolved') { - return { - id, - moduleSideEffects: 'no-treeshake' - }; + plugins: [ + { + resolveId(id) { + if (id.startsWith('dep')) { + if (id === 'depResolved') { + return { + id, + moduleSideEffects: 'no-treeshake' + }; + } + return id; } - return id; - } - }, - load(id) { - if (id.startsWith('dep')) { - if (id === 'depLoaded') { + }, + load(id) { + if (id.startsWith('dep')) { + if (id === 'depLoaded') { + return { + code: getCode(id), + moduleSideEffects: 'no-treeshake' + }; + } + return getCode(id); + } + }, + transform(code, id) { + if (id === 'depTransformed') { return { code: getCode(id), moduleSideEffects: 'no-treeshake' }; } - return getCode(id); - } - }, - transform(code, id) { - if (id === 'depTransformed') { - return { - code: getCode(id), - moduleSideEffects: 'no-treeshake' - }; } } - } + ] } -}; +}); diff --git a/test/form/samples/multi-expression-calls/_config.js b/test/form/samples/multi-expression-calls/_config.js index 5ba44790f77..80292784761 100644 --- a/test/form/samples/multi-expression-calls/_config.js +++ b/test/form/samples/multi-expression-calls/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'handles side-effect-free multi-expressions' -}; +}); diff --git a/test/form/samples/multiple-exports/_config.js b/test/form/samples/multiple-exports/_config.js index fb5a9c63a72..1ae72acd952 100644 --- a/test/form/samples/multiple-exports/_config.js +++ b/test/form/samples/multiple-exports/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'multiple named exports', options: { output: { name: 'myBundle' } } -}; +}); diff --git a/test/form/samples/multiple-exports/_expected/amd.js b/test/form/samples/multiple-exports/_expected/amd.js index be67569e034..fb736e6346e 100644 --- a/test/form/samples/multiple-exports/_expected/amd.js +++ b/test/form/samples/multiple-exports/_expected/amd.js @@ -1,4 +1,4 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; var foo = 1; var bar = 2; @@ -6,6 +6,4 @@ define(['exports'], function (exports) { 'use strict'; exports.bar = bar; exports.foo = foo; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/form/samples/multiple-exports/_expected/cjs.js b/test/form/samples/multiple-exports/_expected/cjs.js index 20d23e9d884..1301b1283b9 100644 --- a/test/form/samples/multiple-exports/_expected/cjs.js +++ b/test/form/samples/multiple-exports/_expected/cjs.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - var foo = 1; var bar = 2; diff --git a/test/form/samples/multiple-exports/_expected/iife.js b/test/form/samples/multiple-exports/_expected/iife.js index 6d8658e030a..2ad00847523 100644 --- a/test/form/samples/multiple-exports/_expected/iife.js +++ b/test/form/samples/multiple-exports/_expected/iife.js @@ -7,8 +7,6 @@ var myBundle = (function (exports) { exports.bar = bar; exports.foo = foo; - Object.defineProperty(exports, '__esModule', { value: true }); - return exports; -}({})); +})({}); diff --git a/test/form/samples/multiple-exports/_expected/system.js b/test/form/samples/multiple-exports/_expected/system.js index 55a7bebb24c..5c776655771 100644 --- a/test/form/samples/multiple-exports/_expected/system.js +++ b/test/form/samples/multiple-exports/_expected/system.js @@ -1,11 +1,11 @@ -System.register('myBundle', [], function (exports) { +System.register('myBundle', [], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - var foo = exports('foo', 1); - var bar = exports('bar', 2); + var foo = exports("foo", 1); + var bar = exports("bar", 2); - } + }) }; -}); +})); diff --git a/test/form/samples/multiple-exports/_expected/umd.js b/test/form/samples/multiple-exports/_expected/umd.js index e7ddc4e4ab0..4f557b3813b 100644 --- a/test/form/samples/multiple-exports/_expected/umd.js +++ b/test/form/samples/multiple-exports/_expected/umd.js @@ -2,7 +2,7 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.myBundle = {})); -}(this, (function (exports) { 'use strict'; +})(this, (function (exports) { 'use strict'; var foo = 1; var bar = 2; @@ -10,6 +10,4 @@ exports.bar = bar; exports.foo = foo; - Object.defineProperty(exports, '__esModule', { value: true }); - -}))); +})); diff --git a/test/form/samples/mutations-in-imports/_config.js b/test/form/samples/mutations-in-imports/_config.js index bfb50011d5e..6adcaee7b4d 100644 --- a/test/form/samples/mutations-in-imports/_config.js +++ b/test/form/samples/mutations-in-imports/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'track mutations of imports' -}; +}); diff --git a/test/form/samples/mutations-in-imports/_expected/es.js b/test/form/samples/mutations-in-imports/_expected.js similarity index 100% rename from test/form/samples/mutations-in-imports/_expected/es.js rename to test/form/samples/mutations-in-imports/_expected.js diff --git a/test/form/samples/mutations-in-imports/_expected/amd.js b/test/form/samples/mutations-in-imports/_expected/amd.js deleted file mode 100644 index 09c62bf4aae..00000000000 --- a/test/form/samples/mutations-in-imports/_expected/amd.js +++ /dev/null @@ -1,21 +0,0 @@ -define(function () { 'use strict'; - - const x$2 = { a: { b: () => {} } }; - const y$2 = { a: x$2.a }; - - const x$1 = { a: { b: () => {} } }; - const y$1 = { a: x$1.a }; - - const x = { a: { b: () => {} } }; - const y = { a: x.a }; - - y$2.a.b = () => console.log( 'effect' ); - x$2.a.b(); - - y$1.a.b = () => console.log( 'effect' ); - x$1.a.b(); - - y.a.b = () => console.log( 'effect' ); - x.a.b(); - -}); diff --git a/test/form/samples/mutations-in-imports/_expected/cjs.js b/test/form/samples/mutations-in-imports/_expected/cjs.js deleted file mode 100644 index 9572605a3dd..00000000000 --- a/test/form/samples/mutations-in-imports/_expected/cjs.js +++ /dev/null @@ -1,19 +0,0 @@ -'use strict'; - -const x$2 = { a: { b: () => {} } }; -const y$2 = { a: x$2.a }; - -const x$1 = { a: { b: () => {} } }; -const y$1 = { a: x$1.a }; - -const x = { a: { b: () => {} } }; -const y = { a: x.a }; - -y$2.a.b = () => console.log( 'effect' ); -x$2.a.b(); - -y$1.a.b = () => console.log( 'effect' ); -x$1.a.b(); - -y.a.b = () => console.log( 'effect' ); -x.a.b(); diff --git a/test/form/samples/mutations-in-imports/_expected/iife.js b/test/form/samples/mutations-in-imports/_expected/iife.js deleted file mode 100644 index 4b599c44e60..00000000000 --- a/test/form/samples/mutations-in-imports/_expected/iife.js +++ /dev/null @@ -1,22 +0,0 @@ -(function () { - 'use strict'; - - const x$2 = { a: { b: () => {} } }; - const y$2 = { a: x$2.a }; - - const x$1 = { a: { b: () => {} } }; - const y$1 = { a: x$1.a }; - - const x = { a: { b: () => {} } }; - const y = { a: x.a }; - - y$2.a.b = () => console.log( 'effect' ); - x$2.a.b(); - - y$1.a.b = () => console.log( 'effect' ); - x$1.a.b(); - - y.a.b = () => console.log( 'effect' ); - x.a.b(); - -}()); diff --git a/test/form/samples/mutations-in-imports/_expected/system.js b/test/form/samples/mutations-in-imports/_expected/system.js deleted file mode 100644 index 798c09f8b28..00000000000 --- a/test/form/samples/mutations-in-imports/_expected/system.js +++ /dev/null @@ -1,26 +0,0 @@ -System.register([], function () { - 'use strict'; - return { - execute: function () { - - const x$2 = { a: { b: () => {} } }; - const y$2 = { a: x$2.a }; - - const x$1 = { a: { b: () => {} } }; - const y$1 = { a: x$1.a }; - - const x = { a: { b: () => {} } }; - const y = { a: x.a }; - - y$2.a.b = () => console.log( 'effect' ); - x$2.a.b(); - - y$1.a.b = () => console.log( 'effect' ); - x$1.a.b(); - - y.a.b = () => console.log( 'effect' ); - x.a.b(); - - } - }; -}); diff --git a/test/form/samples/mutations-in-imports/_expected/umd.js b/test/form/samples/mutations-in-imports/_expected/umd.js deleted file mode 100644 index 5e64442e43b..00000000000 --- a/test/form/samples/mutations-in-imports/_expected/umd.js +++ /dev/null @@ -1,24 +0,0 @@ -(function (factory) { - typeof define === 'function' && define.amd ? define(factory) : - factory(); -}((function () { 'use strict'; - - const x$2 = { a: { b: () => {} } }; - const y$2 = { a: x$2.a }; - - const x$1 = { a: { b: () => {} } }; - const y$1 = { a: x$1.a }; - - const x = { a: { b: () => {} } }; - const y = { a: x.a }; - - y$2.a.b = () => console.log( 'effect' ); - x$2.a.b(); - - y$1.a.b = () => console.log( 'effect' ); - x$1.a.b(); - - y.a.b = () => console.log( 'effect' ); - x.a.b(); - -}))); diff --git a/test/form/samples/namespace-conflict/_config.js b/test/form/samples/namespace-conflict/_config.js new file mode 100644 index 00000000000..da7e20ebf22 --- /dev/null +++ b/test/form/samples/namespace-conflict/_config.js @@ -0,0 +1,4 @@ +module.exports = defineTest({ + description: 'replaces conflicting namespace properties with undefined', + expectedWarnings: ['NAMESPACE_CONFLICT', 'MISSING_EXPORT'] +}); diff --git a/test/form/samples/namespace-conflict/_expected.js b/test/form/samples/namespace-conflict/_expected.js new file mode 100644 index 00000000000..3f7bf02341c --- /dev/null +++ b/test/form/samples/namespace-conflict/_expected.js @@ -0,0 +1 @@ +console.log(undefined); diff --git a/test/form/samples/namespace-conflict/first.js b/test/form/samples/namespace-conflict/first.js new file mode 100644 index 00000000000..bb1843d113a --- /dev/null +++ b/test/form/samples/namespace-conflict/first.js @@ -0,0 +1 @@ +export const foo = 1; diff --git a/test/form/samples/namespace-conflict/main.js b/test/form/samples/namespace-conflict/main.js new file mode 100644 index 00000000000..5991f689169 --- /dev/null +++ b/test/form/samples/namespace-conflict/main.js @@ -0,0 +1,3 @@ +import * as ns from './reexport'; + +console.log(ns.foo); diff --git a/test/form/samples/namespace-conflict/reexport.js b/test/form/samples/namespace-conflict/reexport.js new file mode 100644 index 00000000000..636e32d8531 --- /dev/null +++ b/test/form/samples/namespace-conflict/reexport.js @@ -0,0 +1,2 @@ +export * from './first'; +export * from './second'; diff --git a/test/form/samples/namespace-conflict/second.js b/test/form/samples/namespace-conflict/second.js new file mode 100644 index 00000000000..cc57a55e257 --- /dev/null +++ b/test/form/samples/namespace-conflict/second.js @@ -0,0 +1 @@ +export const foo = 2; diff --git a/test/form/samples/namespace-import-reexport-2/_config.js b/test/form/samples/namespace-import-reexport-2/_config.js index a8be2ee28c8..d21220d4db9 100644 --- a/test/form/samples/namespace-import-reexport-2/_config.js +++ b/test/form/samples/namespace-import-reexport-2/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'properly associate or shadow variables in and around functions', options: { external: ['external1', 'external2'], @@ -7,4 +7,4 @@ module.exports = { name: 'iife' } } -}; +}); diff --git a/test/form/samples/namespace-import-reexport-2/_expected/amd.js b/test/form/samples/namespace-import-reexport-2/_expected/amd.js index cba948a6301..eb901e93fbe 100644 --- a/test/form/samples/namespace-import-reexport-2/_expected/amd.js +++ b/test/form/samples/namespace-import-reexport-2/_expected/amd.js @@ -1,7 +1,6 @@ -define(['exports', 'external1', 'external2'], function (exports, external1, external2) { 'use strict'; +define(['exports', 'external1', 'external2'], (function (exports, external1, external2) { 'use strict'; - function _interopNamespace(e) { - if (e && e.__esModule) return e; + function _interopNamespaceDefault(e) { var n = Object.create(null); if (e) { Object.keys(e).forEach(function (k) { @@ -9,29 +8,23 @@ define(['exports', 'external1', 'external2'], function (exports, external1, exte var d = Object.getOwnPropertyDescriptor(e, k); Object.defineProperty(n, k, d.get ? d : { enumerable: true, - get: function () { - return e[k]; - } + get: function () { return e[k]; } }); } }); } - n['default'] = e; + n.default = e; return Object.freeze(n); } - var external2__namespace = /*#__PURE__*/_interopNamespace(external2); + var external2__namespace = /*#__PURE__*/_interopNamespaceDefault(external2); - Object.defineProperty(exports, 'x', { + Object.defineProperty(exports, "x", { enumerable: true, - get: function () { - return external1.x; - } + get: function () { return external1.x; } }); exports.ext = external2__namespace; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/form/samples/namespace-import-reexport-2/_expected/cjs.js b/test/form/samples/namespace-import-reexport-2/_expected/cjs.js index 0eb0c70635a..dc84c1c7504 100644 --- a/test/form/samples/namespace-import-reexport-2/_expected/cjs.js +++ b/test/form/samples/namespace-import-reexport-2/_expected/cjs.js @@ -1,12 +1,9 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - var external1 = require('external1'); var external2 = require('external2'); -function _interopNamespace(e) { - if (e && e.__esModule) return e; +function _interopNamespaceDefault(e) { var n = Object.create(null); if (e) { Object.keys(e).forEach(function (k) { @@ -14,25 +11,21 @@ function _interopNamespace(e) { var d = Object.getOwnPropertyDescriptor(e, k); Object.defineProperty(n, k, d.get ? d : { enumerable: true, - get: function () { - return e[k]; - } + get: function () { return e[k]; } }); } }); } - n['default'] = e; + n.default = e; return Object.freeze(n); } -var external2__namespace = /*#__PURE__*/_interopNamespace(external2); +var external2__namespace = /*#__PURE__*/_interopNamespaceDefault(external2); -Object.defineProperty(exports, 'x', { +Object.defineProperty(exports, "x", { enumerable: true, - get: function () { - return external1.x; - } + get: function () { return external1.x; } }); exports.ext = external2__namespace; diff --git a/test/form/samples/namespace-import-reexport-2/_expected/iife.js b/test/form/samples/namespace-import-reexport-2/_expected/iife.js index 8d119d90a4a..92bf3b93b36 100644 --- a/test/form/samples/namespace-import-reexport-2/_expected/iife.js +++ b/test/form/samples/namespace-import-reexport-2/_expected/iife.js @@ -1,8 +1,7 @@ var iife = (function (exports, external1, external2) { 'use strict'; - function _interopNamespace(e) { - if (e && e.__esModule) return e; + function _interopNamespaceDefault(e) { var n = Object.create(null); if (e) { Object.keys(e).forEach(function (k) { @@ -10,31 +9,25 @@ var iife = (function (exports, external1, external2) { var d = Object.getOwnPropertyDescriptor(e, k); Object.defineProperty(n, k, d.get ? d : { enumerable: true, - get: function () { - return e[k]; - } + get: function () { return e[k]; } }); } }); } - n['default'] = e; + n.default = e; return Object.freeze(n); } - var external2__namespace = /*#__PURE__*/_interopNamespace(external2); + var external2__namespace = /*#__PURE__*/_interopNamespaceDefault(external2); - Object.defineProperty(exports, 'x', { + Object.defineProperty(exports, "x", { enumerable: true, - get: function () { - return external1.x; - } + get: function () { return external1.x; } }); exports.ext = external2__namespace; - Object.defineProperty(exports, '__esModule', { value: true }); - return exports; -}({}, external1, external2)); +})({}, external1, external2); diff --git a/test/form/samples/namespace-import-reexport-2/_expected/system.js b/test/form/samples/namespace-import-reexport-2/_expected/system.js index 9da3b2bee66..66fd6842e9c 100644 --- a/test/form/samples/namespace-import-reexport-2/_expected/system.js +++ b/test/form/samples/namespace-import-reexport-2/_expected/system.js @@ -1,15 +1,15 @@ -System.register('iife', ['external1', 'external2'], function (exports) { +System.register('iife', ['external1', 'external2'], (function (exports) { 'use strict'; return { setters: [function (module) { - exports('x', module.x); + exports("x", module.x); }, function (module) { - exports('ext', module); + exports("ext", module); }], - execute: function () { + execute: (function () { - } + }) }; -}); +})); diff --git a/test/form/samples/namespace-import-reexport-2/_expected/umd.js b/test/form/samples/namespace-import-reexport-2/_expected/umd.js index a04493c9c98..6f94c25a069 100644 --- a/test/form/samples/namespace-import-reexport-2/_expected/umd.js +++ b/test/form/samples/namespace-import-reexport-2/_expected/umd.js @@ -2,10 +2,9 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('external1'), require('external2')) : typeof define === 'function' && define.amd ? define(['exports', 'external1', 'external2'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.iife = {}, global.external1, global.external2)); -}(this, (function (exports, external1, external2) { 'use strict'; +})(this, (function (exports, external1, external2) { 'use strict'; - function _interopNamespace(e) { - if (e && e.__esModule) return e; + function _interopNamespaceDefault(e) { var n = Object.create(null); if (e) { Object.keys(e).forEach(function (k) { @@ -13,29 +12,23 @@ var d = Object.getOwnPropertyDescriptor(e, k); Object.defineProperty(n, k, d.get ? d : { enumerable: true, - get: function () { - return e[k]; - } + get: function () { return e[k]; } }); } }); } - n['default'] = e; + n.default = e; return Object.freeze(n); } - var external2__namespace = /*#__PURE__*/_interopNamespace(external2); + var external2__namespace = /*#__PURE__*/_interopNamespaceDefault(external2); - Object.defineProperty(exports, 'x', { + Object.defineProperty(exports, "x", { enumerable: true, - get: function () { - return external1.x; - } + get: function () { return external1.x; } }); exports.ext = external2__namespace; - Object.defineProperty(exports, '__esModule', { value: true }); - -}))); +})); diff --git a/test/form/samples/namespace-import-reexport/_config.js b/test/form/samples/namespace-import-reexport/_config.js index 3530557b978..eaf653150ce 100644 --- a/test/form/samples/namespace-import-reexport/_config.js +++ b/test/form/samples/namespace-import-reexport/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'properly associate or shadow variables in and around functions', options: { external: ['external-package'], @@ -7,4 +7,4 @@ module.exports = { name: 'iife' } } -}; +}); diff --git a/test/form/samples/namespace-import-reexport/_expected/amd.js b/test/form/samples/namespace-import-reexport/_expected/amd.js index 24ff21b6645..bef93879c10 100644 --- a/test/form/samples/namespace-import-reexport/_expected/amd.js +++ b/test/form/samples/namespace-import-reexport/_expected/amd.js @@ -1,7 +1,6 @@ -define(['exports', 'external-package'], function (exports, externalPackage) { 'use strict'; +define(['exports', 'external-package'], (function (exports, externalPackage) { 'use strict'; - function _interopNamespace(e) { - if (e && e.__esModule) return e; + function _interopNamespaceDefault(e) { var n = Object.create(null); if (e) { Object.keys(e).forEach(function (k) { @@ -9,23 +8,19 @@ define(['exports', 'external-package'], function (exports, externalPackage) { 'u var d = Object.getOwnPropertyDescriptor(e, k); Object.defineProperty(n, k, d.get ? d : { enumerable: true, - get: function () { - return e[k]; - } + get: function () { return e[k]; } }); } }); } - n['default'] = e; + n.default = e; return Object.freeze(n); } - var externalPackage__namespace = /*#__PURE__*/_interopNamespace(externalPackage); + var externalPackage__namespace = /*#__PURE__*/_interopNamespaceDefault(externalPackage); exports.ext = externalPackage__namespace; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/form/samples/namespace-import-reexport/_expected/cjs.js b/test/form/samples/namespace-import-reexport/_expected/cjs.js index b776a0baeb4..019cf183b3b 100644 --- a/test/form/samples/namespace-import-reexport/_expected/cjs.js +++ b/test/form/samples/namespace-import-reexport/_expected/cjs.js @@ -1,11 +1,8 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - var externalPackage = require('external-package'); -function _interopNamespace(e) { - if (e && e.__esModule) return e; +function _interopNamespaceDefault(e) { var n = Object.create(null); if (e) { Object.keys(e).forEach(function (k) { @@ -13,18 +10,16 @@ function _interopNamespace(e) { var d = Object.getOwnPropertyDescriptor(e, k); Object.defineProperty(n, k, d.get ? d : { enumerable: true, - get: function () { - return e[k]; - } + get: function () { return e[k]; } }); } }); } - n['default'] = e; + n.default = e; return Object.freeze(n); } -var externalPackage__namespace = /*#__PURE__*/_interopNamespace(externalPackage); +var externalPackage__namespace = /*#__PURE__*/_interopNamespaceDefault(externalPackage); diff --git a/test/form/samples/namespace-import-reexport/_expected/iife.js b/test/form/samples/namespace-import-reexport/_expected/iife.js index e7b26c55ec8..ce7e2147e87 100644 --- a/test/form/samples/namespace-import-reexport/_expected/iife.js +++ b/test/form/samples/namespace-import-reexport/_expected/iife.js @@ -1,8 +1,7 @@ var iife = (function (exports, externalPackage) { 'use strict'; - function _interopNamespace(e) { - if (e && e.__esModule) return e; + function _interopNamespaceDefault(e) { var n = Object.create(null); if (e) { Object.keys(e).forEach(function (k) { @@ -10,25 +9,21 @@ var iife = (function (exports, externalPackage) { var d = Object.getOwnPropertyDescriptor(e, k); Object.defineProperty(n, k, d.get ? d : { enumerable: true, - get: function () { - return e[k]; - } + get: function () { return e[k]; } }); } }); } - n['default'] = e; + n.default = e; return Object.freeze(n); } - var externalPackage__namespace = /*#__PURE__*/_interopNamespace(externalPackage); + var externalPackage__namespace = /*#__PURE__*/_interopNamespaceDefault(externalPackage); exports.ext = externalPackage__namespace; - Object.defineProperty(exports, '__esModule', { value: true }); - return exports; -}({}, externalPackage)); +})({}, externalPackage); diff --git a/test/form/samples/namespace-import-reexport/_expected/system.js b/test/form/samples/namespace-import-reexport/_expected/system.js index 73fc2930465..bbd0b1d557e 100644 --- a/test/form/samples/namespace-import-reexport/_expected/system.js +++ b/test/form/samples/namespace-import-reexport/_expected/system.js @@ -1,13 +1,13 @@ -System.register('iife', ['external-package'], function (exports) { +System.register('iife', ['external-package'], (function (exports) { 'use strict'; return { setters: [function (module) { - exports('ext', module); + exports("ext", module); }], - execute: function () { + execute: (function () { - } + }) }; -}); +})); diff --git a/test/form/samples/namespace-import-reexport/_expected/umd.js b/test/form/samples/namespace-import-reexport/_expected/umd.js index e0c79f6039c..a274c3b5b76 100644 --- a/test/form/samples/namespace-import-reexport/_expected/umd.js +++ b/test/form/samples/namespace-import-reexport/_expected/umd.js @@ -2,10 +2,9 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('external-package')) : typeof define === 'function' && define.amd ? define(['exports', 'external-package'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.iife = {}, global.externalPackage)); -}(this, (function (exports, externalPackage) { 'use strict'; +})(this, (function (exports, externalPackage) { 'use strict'; - function _interopNamespace(e) { - if (e && e.__esModule) return e; + function _interopNamespaceDefault(e) { var n = Object.create(null); if (e) { Object.keys(e).forEach(function (k) { @@ -13,23 +12,19 @@ var d = Object.getOwnPropertyDescriptor(e, k); Object.defineProperty(n, k, d.get ? d : { enumerable: true, - get: function () { - return e[k]; - } + get: function () { return e[k]; } }); } }); } - n['default'] = e; + n.default = e; return Object.freeze(n); } - var externalPackage__namespace = /*#__PURE__*/_interopNamespace(externalPackage); + var externalPackage__namespace = /*#__PURE__*/_interopNamespaceDefault(externalPackage); exports.ext = externalPackage__namespace; - Object.defineProperty(exports, '__esModule', { value: true }); - -}))); +})); diff --git a/test/form/samples/namespace-missing-export-effects/_config.js b/test/form/samples/namespace-missing-export-effects/_config.js new file mode 100644 index 00000000000..11446e94688 --- /dev/null +++ b/test/form/samples/namespace-missing-export-effects/_config.js @@ -0,0 +1,4 @@ +module.exports = defineTest({ + description: 'handles interacting with missing namespace members', + expectedWarnings: ['MISSING_EXPORT'] +}); diff --git a/test/form/samples/namespace-missing-export-effects/_expected.js b/test/form/samples/namespace-missing-export-effects/_expected.js new file mode 100644 index 00000000000..d2825d5c2fc --- /dev/null +++ b/test/form/samples/namespace-missing-export-effects/_expected.js @@ -0,0 +1,5 @@ +console.log(1); +if (undefined()) ; +const foo = undefined; +foo.bar; +(0, undefined)(); diff --git a/test/form/samples/namespace-missing-export-effects/main.js b/test/form/samples/namespace-missing-export-effects/main.js new file mode 100644 index 00000000000..e37bad3f8ac --- /dev/null +++ b/test/form/samples/namespace-missing-export-effects/main.js @@ -0,0 +1,7 @@ +import * as ns from './other.js'; + +if (!ns.foo) console.log(1); +if (ns.foo()) console.log(2); +const foo = ns.foo; +foo.bar; +(true && ns.foo)(); diff --git a/test/form/samples/namespace-missing-export-effects/other.js b/test/form/samples/namespace-missing-export-effects/other.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/form/samples/namespace-mutation/_config.js b/test/form/samples/namespace-mutation/_config.js new file mode 100644 index 00000000000..40863fb2cf5 --- /dev/null +++ b/test/form/samples/namespace-mutation/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'does not automatically include the entire namespace if members are mutated' +}); diff --git a/test/form/samples/namespace-mutation/_expected.js b/test/form/samples/namespace-mutation/_expected.js new file mode 100644 index 00000000000..a91a2873c8e --- /dev/null +++ b/test/form/samples/namespace-mutation/_expected.js @@ -0,0 +1,29 @@ +const value2 = { mutated: false }; +const other2 = 'other'; + +const value = { mutated: false }; +const other = 'other'; + +var a = /*#__PURE__*/Object.freeze({ + __proto__: null, + other: other, + other2: other2, + value: value, + value2: value2 +}); + +// It is important that the unused keys are missing from the namespace object +const b = a; +b.value.mutated = true; + +if (!value.mutated) { + throw new Error('Mutation 1 not reflected'); +} + +b.value2.mutated = true; + +if (!value2.mutated) { + throw new Error('Mutation 2 not reflected'); +} + +console.log(b.other, b.other2); diff --git a/test/form/samples/namespace-mutation/dep.js b/test/form/samples/namespace-mutation/dep.js new file mode 100644 index 00000000000..3fb46fd8794 --- /dev/null +++ b/test/form/samples/namespace-mutation/dep.js @@ -0,0 +1,4 @@ +export const value = { mutated: false }; +export const unused = 'unused'; +export const other = 'other'; +export * from './dep2.js'; diff --git a/test/form/samples/namespace-mutation/dep2.js b/test/form/samples/namespace-mutation/dep2.js new file mode 100644 index 00000000000..e009e48819a --- /dev/null +++ b/test/form/samples/namespace-mutation/dep2.js @@ -0,0 +1,3 @@ +export const value2 = { mutated: false }; +export const unused2 = 'unused'; +export const other2 = 'other'; diff --git a/test/form/samples/namespace-mutation/main.js b/test/form/samples/namespace-mutation/main.js new file mode 100644 index 00000000000..f28a9f1d0e2 --- /dev/null +++ b/test/form/samples/namespace-mutation/main.js @@ -0,0 +1,18 @@ +import * as a from './dep.js'; +import { value2 } from './dep2.js'; + +// It is important that the unused keys are missing from the namespace object +const b = a; +b.value.mutated = true; + +if (!a.value.mutated) { + throw new Error('Mutation 1 not reflected'); +} + +b.value2.mutated = true; + +if (!value2.mutated) { + throw new Error('Mutation 2 not reflected'); +} + +console.log(b.other, b.other2); diff --git a/test/form/samples/namespace-object-import/_config.js b/test/form/samples/namespace-object-import/_config.js index 010ac0d5f9d..cdd9a10a2ce 100644 --- a/test/form/samples/namespace-object-import/_config.js +++ b/test/form/samples/namespace-object-import/_config.js @@ -1,6 +1,6 @@ -module.exports = { +module.exports = defineTest({ description: 'properly encodes reserved names if namespace import is used', options: { input: ['main.js'] } -}; +}); diff --git a/test/form/samples/namespace-object-import/_expected/amd.js b/test/form/samples/namespace-object-import/_expected/amd.js index 0e663d37254..fafe02c50c3 100644 --- a/test/form/samples/namespace-object-import/_expected/amd.js +++ b/test/form/samples/namespace-object-import/_expected/amd.js @@ -1,12 +1,12 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; var dep = "default"; var dep$1 = /*#__PURE__*/Object.freeze({ __proto__: null, - 'default': dep + default: dep }); console.log(dep$1); -}); +})); diff --git a/test/form/samples/namespace-object-import/_expected/cjs.js b/test/form/samples/namespace-object-import/_expected/cjs.js index c27e146679f..d24368a350c 100644 --- a/test/form/samples/namespace-object-import/_expected/cjs.js +++ b/test/form/samples/namespace-object-import/_expected/cjs.js @@ -4,7 +4,7 @@ var dep = "default"; var dep$1 = /*#__PURE__*/Object.freeze({ __proto__: null, - 'default': dep + default: dep }); console.log(dep$1); diff --git a/test/form/samples/namespace-object-import/_expected/es.js b/test/form/samples/namespace-object-import/_expected/es.js index fc850f02f55..4c82461196f 100644 --- a/test/form/samples/namespace-object-import/_expected/es.js +++ b/test/form/samples/namespace-object-import/_expected/es.js @@ -2,7 +2,7 @@ var dep = "default"; var dep$1 = /*#__PURE__*/Object.freeze({ __proto__: null, - 'default': dep + default: dep }); console.log(dep$1); diff --git a/test/form/samples/namespace-object-import/_expected/iife.js b/test/form/samples/namespace-object-import/_expected/iife.js index 8048e57105b..9719eed80cf 100644 --- a/test/form/samples/namespace-object-import/_expected/iife.js +++ b/test/form/samples/namespace-object-import/_expected/iife.js @@ -5,9 +5,9 @@ var dep$1 = /*#__PURE__*/Object.freeze({ __proto__: null, - 'default': dep + default: dep }); console.log(dep$1); -}()); +})(); diff --git a/test/form/samples/namespace-object-import/_expected/system.js b/test/form/samples/namespace-object-import/_expected/system.js index 782f2137b93..ab8b81032e9 100644 --- a/test/form/samples/namespace-object-import/_expected/system.js +++ b/test/form/samples/namespace-object-import/_expected/system.js @@ -1,17 +1,17 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { var dep = "default"; var dep$1 = /*#__PURE__*/Object.freeze({ __proto__: null, - 'default': dep + default: dep }); console.log(dep$1); - } + }) }; -}); +})); diff --git a/test/form/samples/namespace-object-import/_expected/umd.js b/test/form/samples/namespace-object-import/_expected/umd.js index ff063b406ec..794d891edac 100644 --- a/test/form/samples/namespace-object-import/_expected/umd.js +++ b/test/form/samples/namespace-object-import/_expected/umd.js @@ -1,15 +1,15 @@ (function (factory) { typeof define === 'function' && define.amd ? define(factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; var dep = "default"; var dep$1 = /*#__PURE__*/Object.freeze({ __proto__: null, - 'default': dep + default: dep }); console.log(dep$1); -}))); +})); diff --git a/test/form/samples/namespace-optimization-b/_config.js b/test/form/samples/namespace-optimization-b/_config.js index fb36203de4a..2d09245c688 100644 --- a/test/form/samples/namespace-optimization-b/_config.js +++ b/test/form/samples/namespace-optimization-b/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'it does static lookup optimization of internal namespaces, coping with multiple namespaces in one function' -}; +}); diff --git a/test/form/samples/namespace-optimization-b/_expected/amd.js b/test/form/samples/namespace-optimization-b/_expected/amd.js index 0284af7e93b..446dafa5aae 100644 --- a/test/form/samples/namespace-optimization-b/_expected/amd.js +++ b/test/form/samples/namespace-optimization-b/_expected/amd.js @@ -1,4 +1,4 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; function foo () { console.log( 'foo' ); @@ -14,4 +14,4 @@ define(function () { 'use strict'; a(); -}); +})); diff --git a/test/form/samples/namespace-optimization-b/_expected/iife.js b/test/form/samples/namespace-optimization-b/_expected/iife.js index b3ac0b30bbe..a0e1d030521 100644 --- a/test/form/samples/namespace-optimization-b/_expected/iife.js +++ b/test/form/samples/namespace-optimization-b/_expected/iife.js @@ -15,4 +15,4 @@ a(); -}()); +})(); diff --git a/test/form/samples/namespace-optimization-b/_expected/system.js b/test/form/samples/namespace-optimization-b/_expected/system.js index cf59616b698..c7eb1ac6683 100644 --- a/test/form/samples/namespace-optimization-b/_expected/system.js +++ b/test/form/samples/namespace-optimization-b/_expected/system.js @@ -1,7 +1,7 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { function foo () { console.log( 'foo' ); @@ -17,6 +17,6 @@ System.register([], function () { a(); - } + }) }; -}); +})); diff --git a/test/form/samples/namespace-optimization-b/_expected/umd.js b/test/form/samples/namespace-optimization-b/_expected/umd.js index 07a65887c57..b19c688a0dc 100644 --- a/test/form/samples/namespace-optimization-b/_expected/umd.js +++ b/test/form/samples/namespace-optimization-b/_expected/umd.js @@ -1,7 +1,7 @@ (function (factory) { typeof define === 'function' && define.amd ? define(factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; function foo () { console.log( 'foo' ); @@ -17,4 +17,4 @@ a(); -}))); +})); diff --git a/test/form/samples/namespace-optimization-computed-string/_config.js b/test/form/samples/namespace-optimization-computed-string/_config.js index 1e58a85afb5..704326185fa 100644 --- a/test/form/samples/namespace-optimization-computed-string/_config.js +++ b/test/form/samples/namespace-optimization-computed-string/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'it does dynamic lookup optimization of internal namespaces for string-literal keys' -}; +}); diff --git a/test/form/samples/namespace-optimization-computed-string/_expected/amd.js b/test/form/samples/namespace-optimization-computed-string/_expected/amd.js index d32ea8602cb..0fb3b0d1b20 100644 --- a/test/form/samples/namespace-optimization-computed-string/_expected/amd.js +++ b/test/form/samples/namespace-optimization-computed-string/_expected/amd.js @@ -1,4 +1,4 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; function a () { console.log('effect'); @@ -6,4 +6,4 @@ define(function () { 'use strict'; a(); -}); +})); diff --git a/test/form/samples/namespace-optimization-computed-string/_expected/iife.js b/test/form/samples/namespace-optimization-computed-string/_expected/iife.js index afc368ba7ec..f6f743bb508 100644 --- a/test/form/samples/namespace-optimization-computed-string/_expected/iife.js +++ b/test/form/samples/namespace-optimization-computed-string/_expected/iife.js @@ -7,4 +7,4 @@ a(); -}()); +})(); diff --git a/test/form/samples/namespace-optimization-computed-string/_expected/system.js b/test/form/samples/namespace-optimization-computed-string/_expected/system.js index 0a24cf9de27..fce6b6b9ebe 100644 --- a/test/form/samples/namespace-optimization-computed-string/_expected/system.js +++ b/test/form/samples/namespace-optimization-computed-string/_expected/system.js @@ -1,7 +1,7 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { function a () { console.log('effect'); @@ -9,6 +9,6 @@ System.register([], function () { a(); - } + }) }; -}); +})); diff --git a/test/form/samples/namespace-optimization-computed-string/_expected/umd.js b/test/form/samples/namespace-optimization-computed-string/_expected/umd.js index 2e0e742d8d1..fafd23729c7 100644 --- a/test/form/samples/namespace-optimization-computed-string/_expected/umd.js +++ b/test/form/samples/namespace-optimization-computed-string/_expected/umd.js @@ -1,7 +1,7 @@ (function (factory) { typeof define === 'function' && define.amd ? define(factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; function a () { console.log('effect'); @@ -9,4 +9,4 @@ a(); -}))); +})); diff --git a/test/form/samples/namespace-optimization-in-operator-synthetic/_config.js b/test/form/samples/namespace-optimization-in-operator-synthetic/_config.js new file mode 100644 index 00000000000..7406d247796 --- /dev/null +++ b/test/form/samples/namespace-optimization-in-operator-synthetic/_config.js @@ -0,0 +1,26 @@ +module.exports = defineTest({ + description: 'disables optimization for synthetic named exports when using the in operator', + options: { + plugins: [ + { + name: 'virtual-synthatic', + resolveId(id) { + if (id === 'virtual:synthetic') { + return '\0' + id; + } + }, + load(id) { + if (id === '\0virtual:synthetic') { + const code = ` + export const __moduleExports = { a: true }; + `; + return { + code, + syntheticNamedExports: '__moduleExports' + }; + } + } + } + ] + } +}); diff --git a/test/form/samples/namespace-optimization-in-operator-synthetic/_expected.js b/test/form/samples/namespace-optimization-in-operator-synthetic/_expected.js new file mode 100644 index 00000000000..5f002c592b4 --- /dev/null +++ b/test/form/samples/namespace-optimization-in-operator-synthetic/_expected.js @@ -0,0 +1,23 @@ +function _mergeNamespaces(n, m) { + m.forEach(function (e) { + e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) { + if (k !== 'default' && !(k in n)) { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + }); + return Object.freeze(n); +} + +const __moduleExports = { a: true }; + +var mod = /*#__PURE__*/_mergeNamespaces({ + __proto__: null +}, [__moduleExports]); + +if ('a' in mod) console.log(`'a' in mod`); +if ('b' in mod) console.log(`'b' in mod`); diff --git a/test/form/samples/namespace-optimization-in-operator-synthetic/main.js b/test/form/samples/namespace-optimization-in-operator-synthetic/main.js new file mode 100644 index 00000000000..66262142b4b --- /dev/null +++ b/test/form/samples/namespace-optimization-in-operator-synthetic/main.js @@ -0,0 +1,4 @@ +import * as mod from 'virtual:synthetic'; + +if ('a' in mod) console.log(`'a' in mod`) +if ('b' in mod) console.log(`'b' in mod`) diff --git a/test/form/samples/namespace-optimization-in-operator/_config.js b/test/form/samples/namespace-optimization-in-operator/_config.js new file mode 100644 index 00000000000..b5e6c3c5660 --- /dev/null +++ b/test/form/samples/namespace-optimization-in-operator/_config.js @@ -0,0 +1,8 @@ +module.exports = defineTest({ + description: + 'it does static optimization of internal namespaces when checking whether an export exists', + expectedWarnings: [ + // That's a bit of an annoyance that Rollup still complains despite the if gate... + 'MISSING_EXPORT' + ] +}); diff --git a/test/form/samples/namespace-optimization-in-operator/_expected.js b/test/form/samples/namespace-optimization-in-operator/_expected.js new file mode 100644 index 00000000000..2259bb79ab7 --- /dev/null +++ b/test/form/samples/namespace-optimization-in-operator/_expected.js @@ -0,0 +1,4 @@ +function c() {} + +console.log(c()); +console.log(true); diff --git a/test/form/samples/namespace-optimization-in-operator/foo.js b/test/form/samples/namespace-optimization-in-operator/foo.js new file mode 100644 index 00000000000..a0ee2782f3e --- /dev/null +++ b/test/form/samples/namespace-optimization-in-operator/foo.js @@ -0,0 +1,3 @@ +export function a() {} +export function b() {} +export function c() {} diff --git a/test/form/samples/namespace-optimization-in-operator/main.js b/test/form/samples/namespace-optimization-in-operator/main.js new file mode 100644 index 00000000000..7aa3bcffb32 --- /dev/null +++ b/test/form/samples/namespace-optimization-in-operator/main.js @@ -0,0 +1,5 @@ +import * as foo from './foo'; + +if ('d' in foo) console.log(foo.d()); +if ('c' in foo) console.log(foo.c()); +console.log('c' in foo); diff --git a/test/form/samples/namespace-optimization/_config.js b/test/form/samples/namespace-optimization/_config.js index ec882435252..88e1dacf88a 100644 --- a/test/form/samples/namespace-optimization/_config.js +++ b/test/form/samples/namespace-optimization/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'it does static lookup optimization of internal namespaces' -}; +}); diff --git a/test/form/samples/namespace-optimization/_expected/es.js b/test/form/samples/namespace-optimization/_expected.js similarity index 100% rename from test/form/samples/namespace-optimization/_expected/es.js rename to test/form/samples/namespace-optimization/_expected.js diff --git a/test/form/samples/namespace-optimization/_expected/amd.js b/test/form/samples/namespace-optimization/_expected/amd.js deleted file mode 100644 index 95231f1878b..00000000000 --- a/test/form/samples/namespace-optimization/_expected/amd.js +++ /dev/null @@ -1,7 +0,0 @@ -define(function () { 'use strict'; - - function a () {} - - console.log( a() ); - -}); diff --git a/test/form/samples/namespace-optimization/_expected/cjs.js b/test/form/samples/namespace-optimization/_expected/cjs.js deleted file mode 100644 index 33a83e92c84..00000000000 --- a/test/form/samples/namespace-optimization/_expected/cjs.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -function a () {} - -console.log( a() ); diff --git a/test/form/samples/namespace-optimization/_expected/iife.js b/test/form/samples/namespace-optimization/_expected/iife.js deleted file mode 100644 index 64673c93d43..00000000000 --- a/test/form/samples/namespace-optimization/_expected/iife.js +++ /dev/null @@ -1,8 +0,0 @@ -(function () { - 'use strict'; - - function a () {} - - console.log( a() ); - -}()); diff --git a/test/form/samples/namespace-optimization/_expected/system.js b/test/form/samples/namespace-optimization/_expected/system.js deleted file mode 100644 index dacc31b2984..00000000000 --- a/test/form/samples/namespace-optimization/_expected/system.js +++ /dev/null @@ -1,12 +0,0 @@ -System.register([], function () { - 'use strict'; - return { - execute: function () { - - function a () {} - - console.log( a() ); - - } - }; -}); diff --git a/test/form/samples/namespace-optimization/_expected/umd.js b/test/form/samples/namespace-optimization/_expected/umd.js deleted file mode 100644 index 2163f63c851..00000000000 --- a/test/form/samples/namespace-optimization/_expected/umd.js +++ /dev/null @@ -1,10 +0,0 @@ -(function (factory) { - typeof define === 'function' && define.amd ? define(factory) : - factory(); -}((function () { 'use strict'; - - function a () {} - - console.log( a() ); - -}))); diff --git a/test/form/samples/namespace-optimization/bar.js b/test/form/samples/namespace-optimization/bar.js index aa96676744d..ad92a1a3d6b 100644 --- a/test/form/samples/namespace-optimization/bar.js +++ b/test/form/samples/namespace-optimization/bar.js @@ -1,3 +1,3 @@ import * as quux from './quux'; -export { quux }; +export { quux }; diff --git a/test/form/samples/namespace-optimization/foo.js b/test/form/samples/namespace-optimization/foo.js index 42a93ae6fe9..d7132d920d3 100644 --- a/test/form/samples/namespace-optimization/foo.js +++ b/test/form/samples/namespace-optimization/foo.js @@ -1,3 +1,3 @@ import * as bar from './bar'; -export { bar }; +export { bar }; diff --git a/test/form/samples/namespace-reexport-name/_config.js b/test/form/samples/namespace-reexport-name/_config.js new file mode 100644 index 00000000000..5aa41a43910 --- /dev/null +++ b/test/form/samples/namespace-reexport-name/_config.js @@ -0,0 +1,10 @@ +module.exports = defineTest({ + description: 'uses correct names when reexporting from namespace reexports (#4049)', + options: { + external: 'external', + output: { + globals: { external: 'external' }, + name: 'bundle' + } + } +}); diff --git a/test/form/samples/namespace-reexport-name/_expected/amd.js b/test/form/samples/namespace-reexport-name/_expected/amd.js new file mode 100644 index 00000000000..601a30404ee --- /dev/null +++ b/test/form/samples/namespace-reexport-name/_expected/amd.js @@ -0,0 +1,17 @@ +define(['exports', 'external'], (function (exports, external) { 'use strict'; + + const renamedIndirectOverride = external.indirectOverride; + + Object.defineProperty(exports, "renamedDirectOverride", { + enumerable: true, + get: function () { return external.directOverride; } + }); + exports.renamedIndirectOverride = renamedIndirectOverride; + Object.keys(external).forEach(function (k) { + if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, { + enumerable: true, + get: function () { return external[k]; } + }); + }); + +})); diff --git a/test/form/samples/namespace-reexport-name/_expected/cjs.js b/test/form/samples/namespace-reexport-name/_expected/cjs.js new file mode 100644 index 00000000000..9ce664554d3 --- /dev/null +++ b/test/form/samples/namespace-reexport-name/_expected/cjs.js @@ -0,0 +1,17 @@ +'use strict'; + +var external = require('external'); + +const renamedIndirectOverride = external.indirectOverride; + +Object.defineProperty(exports, "renamedDirectOverride", { + enumerable: true, + get: function () { return external.directOverride; } +}); +exports.renamedIndirectOverride = renamedIndirectOverride; +Object.keys(external).forEach(function (k) { + if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, { + enumerable: true, + get: function () { return external[k]; } + }); +}); diff --git a/test/form/samples/namespace-reexport-name/_expected/es.js b/test/form/samples/namespace-reexport-name/_expected/es.js new file mode 100644 index 00000000000..5eb8042653f --- /dev/null +++ b/test/form/samples/namespace-reexport-name/_expected/es.js @@ -0,0 +1,7 @@ +import { indirectOverride } from 'external'; +export * from 'external'; +export { directOverride as renamedDirectOverride } from 'external'; + +const renamedIndirectOverride = indirectOverride; + +export { renamedIndirectOverride }; diff --git a/test/form/samples/namespace-reexport-name/_expected/iife.js b/test/form/samples/namespace-reexport-name/_expected/iife.js new file mode 100644 index 00000000000..13dd0b10f66 --- /dev/null +++ b/test/form/samples/namespace-reexport-name/_expected/iife.js @@ -0,0 +1,20 @@ +var bundle = (function (exports, external) { + 'use strict'; + + const renamedIndirectOverride = external.indirectOverride; + + Object.defineProperty(exports, "renamedDirectOverride", { + enumerable: true, + get: function () { return external.directOverride; } + }); + exports.renamedIndirectOverride = renamedIndirectOverride; + Object.keys(external).forEach(function (k) { + if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, { + enumerable: true, + get: function () { return external[k]; } + }); + }); + + return exports; + +})({}, external); diff --git a/test/form/samples/namespace-reexport-name/_expected/system.js b/test/form/samples/namespace-reexport-name/_expected/system.js new file mode 100644 index 00000000000..fdb17e5797b --- /dev/null +++ b/test/form/samples/namespace-reexport-name/_expected/system.js @@ -0,0 +1,25 @@ +System.register('bundle', ['external'], (function (exports) { + 'use strict'; + var _starExcludes = { + __proto__: null, + renamedIndirectOverride: 1, + default: 1, + renamedDirectOverride: 1 + }; + var indirectOverride; + return { + setters: [function (module) { + indirectOverride = module.indirectOverride; + var setter = { __proto__: null, renamedDirectOverride: module.directOverride }; + for (var name in module) { + if (!_starExcludes[name]) setter[name] = module[name]; + } + exports(setter); + }], + execute: (function () { + + const renamedIndirectOverride = exports("renamedIndirectOverride", indirectOverride); + + }) + }; +})); diff --git a/test/form/samples/namespace-reexport-name/_expected/umd.js b/test/form/samples/namespace-reexport-name/_expected/umd.js new file mode 100644 index 00000000000..74f05f4a6ee --- /dev/null +++ b/test/form/samples/namespace-reexport-name/_expected/umd.js @@ -0,0 +1,21 @@ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('external')) : + typeof define === 'function' && define.amd ? define(['exports', 'external'], factory) : + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.bundle = {}, global.external)); +})(this, (function (exports, external) { 'use strict'; + + const renamedIndirectOverride = external.indirectOverride; + + Object.defineProperty(exports, "renamedDirectOverride", { + enumerable: true, + get: function () { return external.directOverride; } + }); + exports.renamedIndirectOverride = renamedIndirectOverride; + Object.keys(external).forEach(function (k) { + if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, { + enumerable: true, + get: function () { return external[k]; } + }); + }); + +})); diff --git a/test/form/samples/namespace-reexport-name/external-reexport.js b/test/form/samples/namespace-reexport-name/external-reexport.js new file mode 100644 index 00000000000..4953eb6e351 --- /dev/null +++ b/test/form/samples/namespace-reexport-name/external-reexport.js @@ -0,0 +1 @@ +export * from 'external'; diff --git a/test/form/samples/namespace-reexport-name/main.js b/test/form/samples/namespace-reexport-name/main.js new file mode 100644 index 00000000000..804f5b8ba52 --- /dev/null +++ b/test/form/samples/namespace-reexport-name/main.js @@ -0,0 +1,2 @@ +export * from './external-reexport'; +export * from './overrides'; diff --git a/test/form/samples/namespace-reexport-name/overrides.js b/test/form/samples/namespace-reexport-name/overrides.js new file mode 100644 index 00000000000..f2cb2622f0d --- /dev/null +++ b/test/form/samples/namespace-reexport-name/overrides.js @@ -0,0 +1,4 @@ +import { indirectOverride } from './external-reexport'; +export { directOverride as renamedDirectOverride } from './external-reexport'; + +export const renamedIndirectOverride = indirectOverride; diff --git a/test/form/samples/namespace-self-import/_config.js b/test/form/samples/namespace-self-import/_config.js index cd21e5703f8..0400c5303cb 100644 --- a/test/form/samples/namespace-self-import/_config.js +++ b/test/form/samples/namespace-self-import/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'namespace early import hoisting', expectedWarnings: ['CIRCULAR_DEPENDENCY'], options: { @@ -6,4 +6,4 @@ module.exports = { name: 'iife' } } -}; +}); diff --git a/test/form/samples/namespace-self-import/_expected/amd.js b/test/form/samples/namespace-self-import/_expected/amd.js index 38976dc388e..7e2de6bb781 100644 --- a/test/form/samples/namespace-self-import/_expected/amd.js +++ b/test/form/samples/namespace-self-import/_expected/amd.js @@ -1,4 +1,4 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; var self = /*#__PURE__*/Object.freeze({ __proto__: null, @@ -11,6 +11,4 @@ define(['exports'], function (exports) { 'use strict'; exports.p = p; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/form/samples/namespace-self-import/_expected/cjs.js b/test/form/samples/namespace-self-import/_expected/cjs.js index 286ebc2c57a..8ce75a0202c 100644 --- a/test/form/samples/namespace-self-import/_expected/cjs.js +++ b/test/form/samples/namespace-self-import/_expected/cjs.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - var self = /*#__PURE__*/Object.freeze({ __proto__: null, get p () { return p; } diff --git a/test/form/samples/namespace-self-import/_expected/iife.js b/test/form/samples/namespace-self-import/_expected/iife.js index 51b9cb63515..cbb4aa0c432 100644 --- a/test/form/samples/namespace-self-import/_expected/iife.js +++ b/test/form/samples/namespace-self-import/_expected/iife.js @@ -12,8 +12,6 @@ var iife = (function (exports) { exports.p = p; - Object.defineProperty(exports, '__esModule', { value: true }); - return exports; -}({})); +})({}); diff --git a/test/form/samples/namespace-self-import/_expected/system.js b/test/form/samples/namespace-self-import/_expected/system.js index 370359f60d3..f784e8400a3 100644 --- a/test/form/samples/namespace-self-import/_expected/system.js +++ b/test/form/samples/namespace-self-import/_expected/system.js @@ -1,7 +1,7 @@ -System.register('iife', [], function (exports) { +System.register('iife', [], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { var self = /*#__PURE__*/Object.freeze({ __proto__: null, @@ -10,8 +10,8 @@ System.register('iife', [], function (exports) { console.log(Object.keys(self)); - var p = exports('p', 5); + var p = exports("p", 5); - } + }) }; -}); +})); diff --git a/test/form/samples/namespace-self-import/_expected/umd.js b/test/form/samples/namespace-self-import/_expected/umd.js index 50ee20bca6f..586f27e7895 100644 --- a/test/form/samples/namespace-self-import/_expected/umd.js +++ b/test/form/samples/namespace-self-import/_expected/umd.js @@ -2,7 +2,7 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.iife = {})); -}(this, (function (exports) { 'use strict'; +})(this, (function (exports) { 'use strict'; var self = /*#__PURE__*/Object.freeze({ __proto__: null, @@ -15,6 +15,4 @@ exports.p = p; - Object.defineProperty(exports, '__esModule', { value: true }); - -}))); +})); diff --git a/test/form/samples/namespace-tostring/entry-default/_config.js b/test/form/samples/namespace-tostring/entry-default/_config.js index 2b68c154c07..b0971867c35 100644 --- a/test/form/samples/namespace-tostring/entry-default/_config.js +++ b/test/form/samples/namespace-tostring/entry-default/_config.js @@ -1,10 +1,10 @@ -module.exports = { +module.exports = defineTest({ description: 'does not add Symbol.toStringTag property to entry chunks with default export mode', options: { output: { - namespaceToStringTag: true, + generatedCode: { symbols: true }, exports: 'default', name: 'bundle' } } -}; +}); diff --git a/test/form/samples/namespace-tostring/entry-default/_expected/amd.js b/test/form/samples/namespace-tostring/entry-default/_expected/amd.js index f7dd1665f27..3c31a8f0b9d 100644 --- a/test/form/samples/namespace-tostring/entry-default/_expected/amd.js +++ b/test/form/samples/namespace-tostring/entry-default/_expected/amd.js @@ -1,7 +1,7 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; var main = { foo: 42 }; return main; -}); +})); diff --git a/test/form/samples/namespace-tostring/entry-default/_expected/es.js b/test/form/samples/namespace-tostring/entry-default/_expected/es.js index 96b6f747e58..9f84202e42f 100644 --- a/test/form/samples/namespace-tostring/entry-default/_expected/es.js +++ b/test/form/samples/namespace-tostring/entry-default/_expected/es.js @@ -1,3 +1,3 @@ var main = { foo: 42 }; -export default main; +export { main as default }; diff --git a/test/form/samples/namespace-tostring/entry-default/_expected/iife.js b/test/form/samples/namespace-tostring/entry-default/_expected/iife.js index 6a9aa88e4d0..b9892e03936 100644 --- a/test/form/samples/namespace-tostring/entry-default/_expected/iife.js +++ b/test/form/samples/namespace-tostring/entry-default/_expected/iife.js @@ -5,4 +5,4 @@ var bundle = (function () { return main; -}()); +})(); diff --git a/test/form/samples/namespace-tostring/entry-default/_expected/system.js b/test/form/samples/namespace-tostring/entry-default/_expected/system.js index 75f648528ce..81501c9b6f6 100644 --- a/test/form/samples/namespace-tostring/entry-default/_expected/system.js +++ b/test/form/samples/namespace-tostring/entry-default/_expected/system.js @@ -1,10 +1,10 @@ -System.register('bundle', [], function (exports) { +System.register('bundle', [], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - var main = exports('default', { foo: 42 }); + var main = exports("default", { foo: 42 }); - } + }) }; -}); +})); diff --git a/test/form/samples/namespace-tostring/entry-default/_expected/umd.js b/test/form/samples/namespace-tostring/entry-default/_expected/umd.js index 91d6f5073b1..8bea7766204 100644 --- a/test/form/samples/namespace-tostring/entry-default/_expected/umd.js +++ b/test/form/samples/namespace-tostring/entry-default/_expected/umd.js @@ -2,10 +2,10 @@ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.bundle = factory()); -}(this, (function () { 'use strict'; +})(this, (function () { 'use strict'; var main = { foo: 42 }; return main; -}))); +})); diff --git a/test/form/samples/namespace-tostring/entry-named/_config.js b/test/form/samples/namespace-tostring/entry-named/_config.js index d329caa8833..b0a2337b448 100644 --- a/test/form/samples/namespace-tostring/entry-named/_config.js +++ b/test/form/samples/namespace-tostring/entry-named/_config.js @@ -1,10 +1,10 @@ -module.exports = { +module.exports = defineTest({ description: 'adds Symbol.toStringTag property to entry chunks with named exports', options: { output: { - namespaceToStringTag: true, + generatedCode: { symbols: true }, exports: 'named', name: 'bundle' } } -}; +}); diff --git a/test/form/samples/namespace-tostring/entry-named/_expected/amd.js b/test/form/samples/namespace-tostring/entry-named/_expected/amd.js index eb6ac0df3d7..71a562107fa 100644 --- a/test/form/samples/namespace-tostring/entry-named/_expected/amd.js +++ b/test/form/samples/namespace-tostring/entry-named/_expected/amd.js @@ -1,10 +1,11 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; const foo = 42; + var main = 43; + exports.default = main; exports.foo = foo; - Object.defineProperty(exports, '__esModule', { value: true }); - exports[Symbol.toStringTag] = 'Module'; + Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } }); -}); +})); diff --git a/test/form/samples/namespace-tostring/entry-named/_expected/cjs.js b/test/form/samples/namespace-tostring/entry-named/_expected/cjs.js index 66fbbf71292..450bed9063f 100644 --- a/test/form/samples/namespace-tostring/entry-named/_expected/cjs.js +++ b/test/form/samples/namespace-tostring/entry-named/_expected/cjs.js @@ -1,8 +1,9 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); -exports[Symbol.toStringTag] = 'Module'; +Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } }); const foo = 42; +var main = 43; +exports.default = main; exports.foo = foo; diff --git a/test/form/samples/namespace-tostring/entry-named/_expected/es.js b/test/form/samples/namespace-tostring/entry-named/_expected/es.js index b72a22eac84..0c66d6bd04f 100644 --- a/test/form/samples/namespace-tostring/entry-named/_expected/es.js +++ b/test/form/samples/namespace-tostring/entry-named/_expected/es.js @@ -1,3 +1,4 @@ const foo = 42; +var main = 43; -export { foo }; +export { main as default, foo }; diff --git a/test/form/samples/namespace-tostring/entry-named/_expected/iife.js b/test/form/samples/namespace-tostring/entry-named/_expected/iife.js index e5372e8d92c..011a32e5fec 100644 --- a/test/form/samples/namespace-tostring/entry-named/_expected/iife.js +++ b/test/form/samples/namespace-tostring/entry-named/_expected/iife.js @@ -2,12 +2,13 @@ var bundle = (function (exports) { 'use strict'; const foo = 42; + var main = 43; + exports.default = main; exports.foo = foo; - Object.defineProperty(exports, '__esModule', { value: true }); - exports[Symbol.toStringTag] = 'Module'; + Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } }); return exports; -}({})); +})({}); diff --git a/test/form/samples/namespace-tostring/entry-named/_expected/system.js b/test/form/samples/namespace-tostring/entry-named/_expected/system.js index f86b5831d03..00a4dd7eaa4 100644 --- a/test/form/samples/namespace-tostring/entry-named/_expected/system.js +++ b/test/form/samples/namespace-tostring/entry-named/_expected/system.js @@ -1,10 +1,11 @@ -System.register('bundle', [], function (exports) { +System.register('bundle', [], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - const foo = exports('foo', 42); + const foo = exports("foo", 42); + var main = exports("default", 43); - } + }) }; -}); +})); diff --git a/test/form/samples/namespace-tostring/entry-named/_expected/umd.js b/test/form/samples/namespace-tostring/entry-named/_expected/umd.js index 1da1dd5513e..45a1f7c818c 100644 --- a/test/form/samples/namespace-tostring/entry-named/_expected/umd.js +++ b/test/form/samples/namespace-tostring/entry-named/_expected/umd.js @@ -2,13 +2,14 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.bundle = {})); -}(this, (function (exports) { 'use strict'; +})(this, (function (exports) { 'use strict'; const foo = 42; + var main = 43; + exports.default = main; exports.foo = foo; - Object.defineProperty(exports, '__esModule', { value: true }); - exports[Symbol.toStringTag] = 'Module'; + Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } }); -}))); +})); diff --git a/test/form/samples/namespace-tostring/entry-named/main.js b/test/form/samples/namespace-tostring/entry-named/main.js index 9d7381d29f6..fb4655c7e32 100644 --- a/test/form/samples/namespace-tostring/entry-named/main.js +++ b/test/form/samples/namespace-tostring/entry-named/main.js @@ -1 +1,2 @@ export const foo = 42; +export default 43; diff --git a/test/form/samples/namespace-tostring/external-namespaces/_config.js b/test/form/samples/namespace-tostring/external-namespaces/_config.js index a6cacfa987a..ad8b50cc11a 100644 --- a/test/form/samples/namespace-tostring/external-namespaces/_config.js +++ b/test/form/samples/namespace-tostring/external-namespaces/_config.js @@ -1,11 +1,11 @@ -module.exports = { +module.exports = defineTest({ description: 'adds Symbol.toStringTag property to external namespaces', options: { external(id) { return id.startsWith('external'); }, output: { - namespaceToStringTag: true, + generatedCode: { symbols: true }, globals: { 'external-auto': 'externalAuto', 'external-default': 'externalDefault', @@ -13,16 +13,20 @@ module.exports = { }, interop(id) { switch (id) { - case 'external-auto': + case 'external-auto': { return 'auto'; - case 'external-default': + } + case 'external-default': { return 'default'; - case 'external-defaultOnly': + } + case 'external-defaultOnly': { return 'defaultOnly'; - default: + } + default: { throw new Error(`Unexpected require "${id}"`); + } } } } } -}; +}); diff --git a/test/form/samples/namespace-tostring/external-namespaces/_expected/amd.js b/test/form/samples/namespace-tostring/external-namespaces/_expected/amd.js index ac42fa24284..5a24d36b99f 100644 --- a/test/form/samples/namespace-tostring/external-namespaces/_expected/amd.js +++ b/test/form/samples/namespace-tostring/external-namespaces/_expected/amd.js @@ -1,31 +1,25 @@ -define(['external-auto', 'external-default', 'external-defaultOnly'], function (externalAuto, externalDefault, externalDefaultOnly) { 'use strict'; +define(['external-auto', 'external-default', 'external-defaultOnly'], (function (externalAuto, externalDefault, externalDefaultOnly) { 'use strict'; - function _interopNamespace(e) { - return e && e.__esModule ? e : _interopNamespaceDefault(e); - } + function _interopNamespaceDefaultOnly (e) { return Object.freeze(Object.defineProperty({ __proto__: null, default: e }, Symbol.toStringTag, { value: 'Module' })); } function _interopNamespaceDefault(e) { - var n = {__proto__: null, [Symbol.toStringTag]: 'Module'}; + var n = Object.create(null, { [Symbol.toStringTag]: { value: 'Module' } }); if (e) { Object.keys(e).forEach(function (k) { if (k !== 'default') { var d = Object.getOwnPropertyDescriptor(e, k); Object.defineProperty(n, k, d.get ? d : { enumerable: true, - get: function () { - return e[k]; - } + get: function () { return e[k]; } }); } }); } - n['default'] = e; + n.default = e; return Object.freeze(n); } - function _interopNamespaceDefaultOnly(e) { - return Object.freeze({__proto__: null, [Symbol.toStringTag]: 'Module', 'default': e}); - } + function _interopNamespace (e) { return e && e.__esModule ? e : _interopNamespaceDefault(e); } var externalAuto__namespace = /*#__PURE__*/_interopNamespace(externalAuto); var externalDefault__namespace = /*#__PURE__*/_interopNamespaceDefault(externalDefault); @@ -43,4 +37,4 @@ define(['external-auto', 'external-default', 'external-defaultOnly'], function ( assert.strictEqual(Object.prototype.toString.call(externalDefaultOnly__namespace), '[object Module]'); assert.deepStrictEqual(externalDefaultOnly__namespace.default, { foo: 42 }); -}); +})); diff --git a/test/form/samples/namespace-tostring/external-namespaces/_expected/cjs.js b/test/form/samples/namespace-tostring/external-namespaces/_expected/cjs.js index 174c00e1f38..d06f93db4db 100644 --- a/test/form/samples/namespace-tostring/external-namespaces/_expected/cjs.js +++ b/test/form/samples/namespace-tostring/external-namespaces/_expected/cjs.js @@ -4,32 +4,26 @@ var externalAuto = require('external-auto'); var externalDefault = require('external-default'); var externalDefaultOnly = require('external-defaultOnly'); -function _interopNamespace(e) { - return e && e.__esModule ? e : _interopNamespaceDefault(e); -} +function _interopNamespaceDefaultOnly (e) { return Object.freeze(Object.defineProperty({ __proto__: null, default: e }, Symbol.toStringTag, { value: 'Module' })); } function _interopNamespaceDefault(e) { - var n = {__proto__: null, [Symbol.toStringTag]: 'Module'}; + var n = Object.create(null, { [Symbol.toStringTag]: { value: 'Module' } }); if (e) { Object.keys(e).forEach(function (k) { if (k !== 'default') { var d = Object.getOwnPropertyDescriptor(e, k); Object.defineProperty(n, k, d.get ? d : { enumerable: true, - get: function () { - return e[k]; - } + get: function () { return e[k]; } }); } }); } - n['default'] = e; + n.default = e; return Object.freeze(n); } -function _interopNamespaceDefaultOnly(e) { - return Object.freeze({__proto__: null, [Symbol.toStringTag]: 'Module', 'default': e}); -} +function _interopNamespace (e) { return e && e.__esModule ? e : _interopNamespaceDefault(e); } var externalAuto__namespace = /*#__PURE__*/_interopNamespace(externalAuto); var externalDefault__namespace = /*#__PURE__*/_interopNamespaceDefault(externalDefault); diff --git a/test/form/samples/namespace-tostring/external-namespaces/_expected/iife.js b/test/form/samples/namespace-tostring/external-namespaces/_expected/iife.js index 36c1364a6e2..eb04205bc5d 100644 --- a/test/form/samples/namespace-tostring/external-namespaces/_expected/iife.js +++ b/test/form/samples/namespace-tostring/external-namespaces/_expected/iife.js @@ -1,32 +1,26 @@ (function (externalAuto, externalDefault, externalDefaultOnly) { 'use strict'; - function _interopNamespace(e) { - return e && e.__esModule ? e : _interopNamespaceDefault(e); - } + function _interopNamespaceDefaultOnly (e) { return Object.freeze(Object.defineProperty({ __proto__: null, default: e }, Symbol.toStringTag, { value: 'Module' })); } function _interopNamespaceDefault(e) { - var n = {__proto__: null, [Symbol.toStringTag]: 'Module'}; + var n = Object.create(null, { [Symbol.toStringTag]: { value: 'Module' } }); if (e) { Object.keys(e).forEach(function (k) { if (k !== 'default') { var d = Object.getOwnPropertyDescriptor(e, k); Object.defineProperty(n, k, d.get ? d : { enumerable: true, - get: function () { - return e[k]; - } + get: function () { return e[k]; } }); } }); } - n['default'] = e; + n.default = e; return Object.freeze(n); } - function _interopNamespaceDefaultOnly(e) { - return Object.freeze({__proto__: null, [Symbol.toStringTag]: 'Module', 'default': e}); - } + function _interopNamespace (e) { return e && e.__esModule ? e : _interopNamespaceDefault(e); } var externalAuto__namespace = /*#__PURE__*/_interopNamespace(externalAuto); var externalDefault__namespace = /*#__PURE__*/_interopNamespaceDefault(externalDefault); @@ -44,4 +38,4 @@ assert.strictEqual(Object.prototype.toString.call(externalDefaultOnly__namespace), '[object Module]'); assert.deepStrictEqual(externalDefaultOnly__namespace.default, { foo: 42 }); -}(externalAuto, externalDefault, externalDefaultOnly)); +})(externalAuto, externalDefault, externalDefaultOnly); diff --git a/test/form/samples/namespace-tostring/external-namespaces/_expected/system.js b/test/form/samples/namespace-tostring/external-namespaces/_expected/system.js index 148582a190f..76dd2bf6c12 100644 --- a/test/form/samples/namespace-tostring/external-namespaces/_expected/system.js +++ b/test/form/samples/namespace-tostring/external-namespaces/_expected/system.js @@ -1,4 +1,4 @@ -System.register(['external-auto', 'external-default', 'external-defaultOnly'], function () { +System.register(['external-auto', 'external-default', 'external-defaultOnly'], (function () { 'use strict'; var externalAuto, externalDefault, externalDefaultOnly; return { @@ -9,7 +9,7 @@ System.register(['external-auto', 'external-default', 'external-defaultOnly'], f }, function (module) { externalDefaultOnly = module; }], - execute: function () { + execute: (function () { assert.strictEqual(externalAuto[Symbol.toStringTag], 'Module'); assert.strictEqual(Object.prototype.toString.call(externalAuto), '[object Module]'); @@ -23,6 +23,6 @@ System.register(['external-auto', 'external-default', 'external-defaultOnly'], f assert.strictEqual(Object.prototype.toString.call(externalDefaultOnly), '[object Module]'); assert.deepStrictEqual(externalDefaultOnly.default, { foo: 42 }); - } + }) }; -}); +})); diff --git a/test/form/samples/namespace-tostring/external-namespaces/_expected/umd.js b/test/form/samples/namespace-tostring/external-namespaces/_expected/umd.js index 9616c3a0ccf..8c3d88c660d 100644 --- a/test/form/samples/namespace-tostring/external-namespaces/_expected/umd.js +++ b/test/form/samples/namespace-tostring/external-namespaces/_expected/umd.js @@ -2,34 +2,28 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('external-auto'), require('external-default'), require('external-defaultOnly')) : typeof define === 'function' && define.amd ? define(['external-auto', 'external-default', 'external-defaultOnly'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.externalAuto, global.externalDefault, global.externalDefaultOnly)); -}(this, (function (externalAuto, externalDefault, externalDefaultOnly) { 'use strict'; +})(this, (function (externalAuto, externalDefault, externalDefaultOnly) { 'use strict'; - function _interopNamespace(e) { - return e && e.__esModule ? e : _interopNamespaceDefault(e); - } + function _interopNamespaceDefaultOnly (e) { return Object.freeze(Object.defineProperty({ __proto__: null, default: e }, Symbol.toStringTag, { value: 'Module' })); } function _interopNamespaceDefault(e) { - var n = {__proto__: null, [Symbol.toStringTag]: 'Module'}; + var n = Object.create(null, { [Symbol.toStringTag]: { value: 'Module' } }); if (e) { Object.keys(e).forEach(function (k) { if (k !== 'default') { var d = Object.getOwnPropertyDescriptor(e, k); Object.defineProperty(n, k, d.get ? d : { enumerable: true, - get: function () { - return e[k]; - } + get: function () { return e[k]; } }); } }); } - n['default'] = e; + n.default = e; return Object.freeze(n); } - function _interopNamespaceDefaultOnly(e) { - return Object.freeze({__proto__: null, [Symbol.toStringTag]: 'Module', 'default': e}); - } + function _interopNamespace (e) { return e && e.__esModule ? e : _interopNamespaceDefault(e); } var externalAuto__namespace = /*#__PURE__*/_interopNamespace(externalAuto); var externalDefault__namespace = /*#__PURE__*/_interopNamespaceDefault(externalDefault); @@ -47,4 +41,4 @@ assert.strictEqual(Object.prototype.toString.call(externalDefaultOnly__namespace), '[object Module]'); assert.deepStrictEqual(externalDefaultOnly__namespace.default, { foo: 42 }); -}))); +})); diff --git a/test/form/samples/namespace-tostring/inlined-namespace-static-resolution/_config.js b/test/form/samples/namespace-tostring/inlined-namespace-static-resolution/_config.js new file mode 100644 index 00000000000..0b1bcb348c6 --- /dev/null +++ b/test/form/samples/namespace-tostring/inlined-namespace-static-resolution/_config.js @@ -0,0 +1,9 @@ +module.exports = defineTest({ + description: 'statically resolves Symbol.toStringTag for inlined namespaces', + expectedWarnings: ['MISSING_EXPORT'], + options: { + output: { + generatedCode: { symbols: true } + } + } +}); diff --git a/test/form/samples/namespace-tostring/inlined-namespace-static-resolution/_expected.js b/test/form/samples/namespace-tostring/inlined-namespace-static-resolution/_expected.js new file mode 100644 index 00000000000..91824e2b5ac --- /dev/null +++ b/test/form/samples/namespace-tostring/inlined-namespace-static-resolution/_expected.js @@ -0,0 +1,5 @@ +console.log('OK'); + +console.log('OK'); + +console.log('OK'); diff --git a/test/form/samples/namespace-tostring/inlined-namespace-static-resolution/foo.js b/test/form/samples/namespace-tostring/inlined-namespace-static-resolution/foo.js new file mode 100644 index 00000000000..308e102fe9a --- /dev/null +++ b/test/form/samples/namespace-tostring/inlined-namespace-static-resolution/foo.js @@ -0,0 +1 @@ +export const bar = 42; diff --git a/test/form/samples/namespace-tostring/inlined-namespace-static-resolution/main.js b/test/form/samples/namespace-tostring/inlined-namespace-static-resolution/main.js new file mode 100644 index 00000000000..0e4f8743818 --- /dev/null +++ b/test/form/samples/namespace-tostring/inlined-namespace-static-resolution/main.js @@ -0,0 +1,10 @@ +import * as foo from './foo'; + +if (foo[Symbol.toStringTag]) console.log('OK'); +else console.log('FAIL'); + +if (foo.bar) console.log('OK'); +else console.log('FAIL'); + +if (foo.foo) console.log('FAIL'); +else console.log('OK'); diff --git a/test/form/samples/namespace-tostring/inlined-namespace/_config.js b/test/form/samples/namespace-tostring/inlined-namespace/_config.js index 62ccb9bf2cc..84f1a0b3d2c 100644 --- a/test/form/samples/namespace-tostring/inlined-namespace/_config.js +++ b/test/form/samples/namespace-tostring/inlined-namespace/_config.js @@ -1,8 +1,8 @@ -module.exports = { +module.exports = defineTest({ description: 'adds Symbol.toStringTag property to inlined namespaces', options: { output: { - namespaceToStringTag: true + generatedCode: { symbols: true } } } -}; +}); diff --git a/test/form/samples/namespace-tostring/inlined-namespace/_expected/amd.js b/test/form/samples/namespace-tostring/inlined-namespace/_expected/amd.js index 98a30ca049a..0fd10487115 100644 --- a/test/form/samples/namespace-tostring/inlined-namespace/_expected/amd.js +++ b/test/form/samples/namespace-tostring/inlined-namespace/_expected/amd.js @@ -1,15 +1,14 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; const bar = 42; - var foo = /*#__PURE__*/Object.freeze({ + var foo = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({ __proto__: null, - [Symbol.toStringTag]: 'Module', bar: bar - }); + }, Symbol.toStringTag, { value: 'Module' })); assert.strictEqual(foo[Symbol.toStringTag], 'Module'); assert.strictEqual(Object.prototype.toString.call(foo), '[object Module]'); assert.strictEqual(bar, 42); -}); +})); diff --git a/test/form/samples/namespace-tostring/inlined-namespace/_expected/cjs.js b/test/form/samples/namespace-tostring/inlined-namespace/_expected/cjs.js index 72ea5c72080..1d2be7a0b92 100644 --- a/test/form/samples/namespace-tostring/inlined-namespace/_expected/cjs.js +++ b/test/form/samples/namespace-tostring/inlined-namespace/_expected/cjs.js @@ -2,11 +2,10 @@ const bar = 42; -var foo = /*#__PURE__*/Object.freeze({ +var foo = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({ __proto__: null, - [Symbol.toStringTag]: 'Module', bar: bar -}); +}, Symbol.toStringTag, { value: 'Module' })); assert.strictEqual(foo[Symbol.toStringTag], 'Module'); assert.strictEqual(Object.prototype.toString.call(foo), '[object Module]'); diff --git a/test/form/samples/namespace-tostring/inlined-namespace/_expected/es.js b/test/form/samples/namespace-tostring/inlined-namespace/_expected/es.js index ae232b6b724..a74e0a8f263 100644 --- a/test/form/samples/namespace-tostring/inlined-namespace/_expected/es.js +++ b/test/form/samples/namespace-tostring/inlined-namespace/_expected/es.js @@ -1,10 +1,9 @@ const bar = 42; -var foo = /*#__PURE__*/Object.freeze({ +var foo = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({ __proto__: null, - [Symbol.toStringTag]: 'Module', bar: bar -}); +}, Symbol.toStringTag, { value: 'Module' })); assert.strictEqual(foo[Symbol.toStringTag], 'Module'); assert.strictEqual(Object.prototype.toString.call(foo), '[object Module]'); diff --git a/test/form/samples/namespace-tostring/inlined-namespace/_expected/iife.js b/test/form/samples/namespace-tostring/inlined-namespace/_expected/iife.js index 7902a3a3d4b..d960020bd7a 100644 --- a/test/form/samples/namespace-tostring/inlined-namespace/_expected/iife.js +++ b/test/form/samples/namespace-tostring/inlined-namespace/_expected/iife.js @@ -3,14 +3,13 @@ const bar = 42; - var foo = /*#__PURE__*/Object.freeze({ + var foo = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({ __proto__: null, - [Symbol.toStringTag]: 'Module', bar: bar - }); + }, Symbol.toStringTag, { value: 'Module' })); assert.strictEqual(foo[Symbol.toStringTag], 'Module'); assert.strictEqual(Object.prototype.toString.call(foo), '[object Module]'); assert.strictEqual(bar, 42); -}()); +})(); diff --git a/test/form/samples/namespace-tostring/inlined-namespace/_expected/system.js b/test/form/samples/namespace-tostring/inlined-namespace/_expected/system.js index 857ef5aea99..d26e5038939 100644 --- a/test/form/samples/namespace-tostring/inlined-namespace/_expected/system.js +++ b/test/form/samples/namespace-tostring/inlined-namespace/_expected/system.js @@ -1,20 +1,19 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { const bar = 42; - var foo = /*#__PURE__*/Object.freeze({ + var foo = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({ __proto__: null, - [Symbol.toStringTag]: 'Module', bar: bar - }); + }, Symbol.toStringTag, { value: 'Module' })); assert.strictEqual(foo[Symbol.toStringTag], 'Module'); assert.strictEqual(Object.prototype.toString.call(foo), '[object Module]'); assert.strictEqual(bar, 42); - } + }) }; -}); +})); diff --git a/test/form/samples/namespace-tostring/inlined-namespace/_expected/umd.js b/test/form/samples/namespace-tostring/inlined-namespace/_expected/umd.js index 191811d7058..fdb31a26ccd 100644 --- a/test/form/samples/namespace-tostring/inlined-namespace/_expected/umd.js +++ b/test/form/samples/namespace-tostring/inlined-namespace/_expected/umd.js @@ -1,18 +1,17 @@ (function (factory) { typeof define === 'function' && define.amd ? define(factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; const bar = 42; - var foo = /*#__PURE__*/Object.freeze({ + var foo = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({ __proto__: null, - [Symbol.toStringTag]: 'Module', bar: bar - }); + }, Symbol.toStringTag, { value: 'Module' })); assert.strictEqual(foo[Symbol.toStringTag], 'Module'); assert.strictEqual(Object.prototype.toString.call(foo), '[object Module]'); assert.strictEqual(bar, 42); -}))); +})); diff --git a/test/form/samples/namespaced-default-exports/_config.js b/test/form/samples/namespaced-default-exports/_config.js index 547e6ad2e2d..78f1c95d7a1 100644 --- a/test/form/samples/namespaced-default-exports/_config.js +++ b/test/form/samples/namespaced-default-exports/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'creates namespaced module names', options: { output: { name: 'foo.bar.baz' } } -}; +}); diff --git a/test/form/samples/namespaced-default-exports/_expected/amd.js b/test/form/samples/namespaced-default-exports/_expected/amd.js index 37d25711e09..538fc7738a6 100644 --- a/test/form/samples/namespaced-default-exports/_expected/amd.js +++ b/test/form/samples/namespaced-default-exports/_expected/amd.js @@ -1,7 +1,7 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; var main = 42; return main; -}); +})); diff --git a/test/form/samples/namespaced-default-exports/_expected/es.js b/test/form/samples/namespaced-default-exports/_expected/es.js index d862de816a3..c3e30233192 100644 --- a/test/form/samples/namespaced-default-exports/_expected/es.js +++ b/test/form/samples/namespaced-default-exports/_expected/es.js @@ -1,3 +1,3 @@ var main = 42; -export default main; +export { main as default }; diff --git a/test/form/samples/namespaced-default-exports/_expected/iife.js b/test/form/samples/namespaced-default-exports/_expected/iife.js index cf8f3648bb9..0e051ac46ac 100644 --- a/test/form/samples/namespaced-default-exports/_expected/iife.js +++ b/test/form/samples/namespaced-default-exports/_expected/iife.js @@ -7,4 +7,4 @@ this.foo.bar.baz = (function () { return main; -}()); +})(); diff --git a/test/form/samples/namespaced-default-exports/_expected/system.js b/test/form/samples/namespaced-default-exports/_expected/system.js index e6a02565ef7..fbc063e3507 100644 --- a/test/form/samples/namespaced-default-exports/_expected/system.js +++ b/test/form/samples/namespaced-default-exports/_expected/system.js @@ -1,10 +1,10 @@ -System.register('foo.bar.baz', [], function (exports) { +System.register('foo.bar.baz', [], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - var main = exports('default', 42); + var main = exports("default", 42); - } + }) }; -}); +})); diff --git a/test/form/samples/namespaced-default-exports/_expected/umd.js b/test/form/samples/namespaced-default-exports/_expected/umd.js index 87ef18a8386..fc92b56337c 100644 --- a/test/form/samples/namespaced-default-exports/_expected/umd.js +++ b/test/form/samples/namespaced-default-exports/_expected/umd.js @@ -2,10 +2,10 @@ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, (global.foo = global.foo || {}, global.foo.bar = global.foo.bar || {}, global.foo.bar.baz = factory())); -}(this, (function () { 'use strict'; +})(this, (function () { 'use strict'; var main = 42; return main; -}))); +})); diff --git a/test/form/samples/namespaced-named-exports/_config.js b/test/form/samples/namespaced-named-exports/_config.js index 547e6ad2e2d..78f1c95d7a1 100644 --- a/test/form/samples/namespaced-named-exports/_config.js +++ b/test/form/samples/namespaced-named-exports/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'creates namespaced module names', options: { output: { name: 'foo.bar.baz' } } -}; +}); diff --git a/test/form/samples/namespaced-named-exports/_expected/amd.js b/test/form/samples/namespaced-named-exports/_expected/amd.js index cec0f513af2..17e9e504d62 100644 --- a/test/form/samples/namespaced-named-exports/_expected/amd.js +++ b/test/form/samples/namespaced-named-exports/_expected/amd.js @@ -1,9 +1,7 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; var answer = 42; exports.answer = answer; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/form/samples/namespaced-named-exports/_expected/cjs.js b/test/form/samples/namespaced-named-exports/_expected/cjs.js index f58e06dbe20..9ac4d858bc4 100644 --- a/test/form/samples/namespaced-named-exports/_expected/cjs.js +++ b/test/form/samples/namespaced-named-exports/_expected/cjs.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - var answer = 42; exports.answer = answer; diff --git a/test/form/samples/namespaced-named-exports/_expected/iife.js b/test/form/samples/namespaced-named-exports/_expected/iife.js index 5f61e011c49..6863e4b811f 100644 --- a/test/form/samples/namespaced-named-exports/_expected/iife.js +++ b/test/form/samples/namespaced-named-exports/_expected/iife.js @@ -7,8 +7,6 @@ this.foo.bar.baz = (function (exports) { exports.answer = answer; - Object.defineProperty(exports, '__esModule', { value: true }); - return exports; -}({})); +})({}); diff --git a/test/form/samples/namespaced-named-exports/_expected/system.js b/test/form/samples/namespaced-named-exports/_expected/system.js index cd79c05caff..a296a94e55e 100644 --- a/test/form/samples/namespaced-named-exports/_expected/system.js +++ b/test/form/samples/namespaced-named-exports/_expected/system.js @@ -1,10 +1,10 @@ -System.register('foo.bar.baz', [], function (exports) { +System.register('foo.bar.baz', [], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - var answer = exports('answer', 42); + var answer = exports("answer", 42); - } + }) }; -}); +})); diff --git a/test/form/samples/namespaced-named-exports/_expected/umd.js b/test/form/samples/namespaced-named-exports/_expected/umd.js index 8f0ca405703..73df328eaa4 100644 --- a/test/form/samples/namespaced-named-exports/_expected/umd.js +++ b/test/form/samples/namespaced-named-exports/_expected/umd.js @@ -2,12 +2,10 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.foo = global.foo || {}, global.foo.bar = global.foo.bar || {}, global.foo.bar.baz = {}))); -}(this, (function (exports) { 'use strict'; +})(this, (function (exports) { 'use strict'; var answer = 42; exports.answer = answer; - Object.defineProperty(exports, '__esModule', { value: true }); - -}))); +})); diff --git a/test/form/samples/namespaces-have-null-prototype/_config.js b/test/form/samples/namespaces-have-null-prototype/_config.js index faa0ac1b8e7..01d92a96f28 100644 --- a/test/form/samples/namespaces-have-null-prototype/_config.js +++ b/test/form/samples/namespaces-have-null-prototype/_config.js @@ -1,6 +1,6 @@ -module.exports = { +module.exports = defineTest({ description: 'creates namespaces with null prototypes', options: { output: { name: 'myBundle' } } -}; +}); diff --git a/test/form/samples/namespaces-have-null-prototype/_expected/amd.js b/test/form/samples/namespaces-have-null-prototype/_expected/amd.js index b53ccd4d76e..fedf9103f8b 100644 --- a/test/form/samples/namespaces-have-null-prototype/_expected/amd.js +++ b/test/form/samples/namespaces-have-null-prototype/_expected/amd.js @@ -1,12 +1,12 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; const foo = 1; const bar = 2; var namespace = /*#__PURE__*/Object.freeze({ __proto__: null, - foo: foo, - bar: bar + bar: bar, + foo: foo }); console.log( Object.keys( namespace ) ); @@ -17,6 +17,4 @@ define(['exports'], function (exports) { 'use strict'; exports.a = a; exports.b = b; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/form/samples/namespaces-have-null-prototype/_expected/cjs.js b/test/form/samples/namespaces-have-null-prototype/_expected/cjs.js index 445e1b89d69..efc188dc41a 100644 --- a/test/form/samples/namespaces-have-null-prototype/_expected/cjs.js +++ b/test/form/samples/namespaces-have-null-prototype/_expected/cjs.js @@ -1,14 +1,12 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - const foo = 1; const bar = 2; var namespace = /*#__PURE__*/Object.freeze({ __proto__: null, - foo: foo, - bar: bar + bar: bar, + foo: foo }); console.log( Object.keys( namespace ) ); diff --git a/test/form/samples/namespaces-have-null-prototype/_expected/es.js b/test/form/samples/namespaces-have-null-prototype/_expected/es.js index 6f660a34a59..e6b5d926475 100644 --- a/test/form/samples/namespaces-have-null-prototype/_expected/es.js +++ b/test/form/samples/namespaces-have-null-prototype/_expected/es.js @@ -3,8 +3,8 @@ const bar = 2; var namespace = /*#__PURE__*/Object.freeze({ __proto__: null, - foo: foo, - bar: bar + bar: bar, + foo: foo }); console.log( Object.keys( namespace ) ); diff --git a/test/form/samples/namespaces-have-null-prototype/_expected/iife.js b/test/form/samples/namespaces-have-null-prototype/_expected/iife.js index 577cfbf55c6..074023c24a1 100644 --- a/test/form/samples/namespaces-have-null-prototype/_expected/iife.js +++ b/test/form/samples/namespaces-have-null-prototype/_expected/iife.js @@ -6,8 +6,8 @@ var myBundle = (function (exports) { var namespace = /*#__PURE__*/Object.freeze({ __proto__: null, - foo: foo, - bar: bar + bar: bar, + foo: foo }); console.log( Object.keys( namespace ) ); @@ -18,8 +18,6 @@ var myBundle = (function (exports) { exports.a = a; exports.b = b; - Object.defineProperty(exports, '__esModule', { value: true }); - return exports; -}({})); +})({}); diff --git a/test/form/samples/namespaces-have-null-prototype/_expected/system.js b/test/form/samples/namespaces-have-null-prototype/_expected/system.js index 258f8497c83..e1a40e0a786 100644 --- a/test/form/samples/namespaces-have-null-prototype/_expected/system.js +++ b/test/form/samples/namespaces-have-null-prototype/_expected/system.js @@ -1,22 +1,22 @@ -System.register('myBundle', [], function (exports) { +System.register('myBundle', [], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { const foo = 1; const bar = 2; var namespace = /*#__PURE__*/Object.freeze({ __proto__: null, - foo: foo, - bar: bar + bar: bar, + foo: foo }); console.log( Object.keys( namespace ) ); - const a = exports('a', 1); - const b = exports('b', 2); + const a = exports("a", 1); + const b = exports("b", 2); - } + }) }; -}); +})); diff --git a/test/form/samples/namespaces-have-null-prototype/_expected/umd.js b/test/form/samples/namespaces-have-null-prototype/_expected/umd.js index 8a26898fc1f..6ded5ef1af7 100644 --- a/test/form/samples/namespaces-have-null-prototype/_expected/umd.js +++ b/test/form/samples/namespaces-have-null-prototype/_expected/umd.js @@ -2,15 +2,15 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.myBundle = {})); -}(this, (function (exports) { 'use strict'; +})(this, (function (exports) { 'use strict'; const foo = 1; const bar = 2; var namespace = /*#__PURE__*/Object.freeze({ __proto__: null, - foo: foo, - bar: bar + bar: bar, + foo: foo }); console.log( Object.keys( namespace ) ); @@ -21,6 +21,4 @@ exports.a = a; exports.b = b; - Object.defineProperty(exports, '__esModule', { value: true }); - -}))); +})); diff --git a/test/form/samples/nested-deoptimization/_config.js b/test/form/samples/nested-deoptimization/_config.js new file mode 100644 index 00000000000..21cd6f596f4 --- /dev/null +++ b/test/form/samples/nested-deoptimization/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'handles deoptimization of nested properties' +}); diff --git a/test/form/samples/nested-deoptimization/_expected.js b/test/form/samples/nested-deoptimization/_expected.js new file mode 100644 index 00000000000..04bb1a1620c --- /dev/null +++ b/test/form/samples/nested-deoptimization/_expected.js @@ -0,0 +1,11 @@ +const obj = { + foo: { prop: true }, + bar: { otherProp: true }, + prop: true +}; +obj[globalThis.unknown].prop = false; + +if (obj.foo.prop) console.log('retained'); +else console.log('also retained'); +console.log('retained'); +console.log('retained'); diff --git a/test/form/samples/nested-deoptimization/main.js b/test/form/samples/nested-deoptimization/main.js new file mode 100644 index 00000000000..df9ff8d41f7 --- /dev/null +++ b/test/form/samples/nested-deoptimization/main.js @@ -0,0 +1,13 @@ +const obj = { + foo: { prop: true }, + bar: { otherProp: true }, + prop: true +}; +obj[globalThis.unknown].prop = false; + +if (obj.foo.prop) console.log('retained'); +else console.log('also retained'); +if (obj.bar.otherProp) console.log('retained'); +else console.log('removed'); +if (obj.prop) console.log('retained'); +else console.log('removed'); diff --git a/test/form/samples/nested-inlined-dynamic-import/_config.js b/test/form/samples/nested-inlined-dynamic-import/_config.js index 11403c10e01..da6eca5d69a 100644 --- a/test/form/samples/nested-inlined-dynamic-import/_config.js +++ b/test/form/samples/nested-inlined-dynamic-import/_config.js @@ -1,6 +1,6 @@ -module.exports = { +module.exports = defineTest({ description: 'deconflicts variables when nested dynamic imports are inlined', options: { output: { inlineDynamicImports: true } } -}; +}); diff --git a/test/form/samples/nested-inlined-dynamic-import/_expected/amd.js b/test/form/samples/nested-inlined-dynamic-import/_expected/amd.js index 83e0443cf4b..9786f514ae5 100644 --- a/test/form/samples/nested-inlined-dynamic-import/_expected/amd.js +++ b/test/form/samples/nested-inlined-dynamic-import/_expected/amd.js @@ -1,4 +1,4 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; async function main() { const foo$1 = 1; @@ -15,4 +15,4 @@ define(function () { 'use strict'; value: value }); -}); +})); diff --git a/test/form/samples/nested-inlined-dynamic-import/_expected/iife.js b/test/form/samples/nested-inlined-dynamic-import/_expected/iife.js index 6a2dd7b2aaa..3dbed43ba8a 100644 --- a/test/form/samples/nested-inlined-dynamic-import/_expected/iife.js +++ b/test/form/samples/nested-inlined-dynamic-import/_expected/iife.js @@ -16,4 +16,4 @@ value: value }); -}()); +})(); diff --git a/test/form/samples/nested-inlined-dynamic-import/_expected/system.js b/test/form/samples/nested-inlined-dynamic-import/_expected/system.js index a11234126c3..8cb925481ca 100644 --- a/test/form/samples/nested-inlined-dynamic-import/_expected/system.js +++ b/test/form/samples/nested-inlined-dynamic-import/_expected/system.js @@ -1,7 +1,7 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { async function main() { const foo$1 = 1; @@ -18,6 +18,6 @@ System.register([], function () { value: value }); - } + }) }; -}); +})); diff --git a/test/form/samples/nested-inlined-dynamic-import/_expected/umd.js b/test/form/samples/nested-inlined-dynamic-import/_expected/umd.js index 04bde1cc42f..5fa0792d5da 100644 --- a/test/form/samples/nested-inlined-dynamic-import/_expected/umd.js +++ b/test/form/samples/nested-inlined-dynamic-import/_expected/umd.js @@ -1,7 +1,7 @@ (function (factory) { typeof define === 'function' && define.amd ? define(factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; async function main() { const foo$1 = 1; @@ -18,4 +18,4 @@ value: value }); -}))); +})); diff --git a/test/form/samples/nested-member-access/_config.js b/test/form/samples/nested-member-access/_config.js index 7c37a494f01..e15fc6430df 100644 --- a/test/form/samples/nested-member-access/_config.js +++ b/test/form/samples/nested-member-access/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'throw an error when accessing members of null or undefined' -}; +}); diff --git a/test/form/samples/nested-member-access/_expected.js b/test/form/samples/nested-member-access/_expected.js index 748859e2c7e..2878ad6f6c7 100644 --- a/test/form/samples/nested-member-access/_expected.js +++ b/test/form/samples/nested-member-access/_expected.js @@ -4,7 +4,7 @@ retained1.foo.bar; const retained2 = new function () {}(); retained2.foo.bar; -const retained3 = void {}; +const retained3 = void 0; retained3.foo; const retained4b = undefined; retained4b.foo; diff --git a/test/form/samples/nested-member-access/main.js b/test/form/samples/nested-member-access/main.js index 323ca9e7885..6a46a73687e 100644 --- a/test/form/samples/nested-member-access/main.js +++ b/test/form/samples/nested-member-access/main.js @@ -4,16 +4,9 @@ const removedResult1 = removed1.foo; const removed2 = { foo: {} }; const removedResult2 = removed2.foo.bar; -const removed3 = new function () {}(); -const removedResult3 = removed3.foo; - const removed4 = !{}; const removedResult4 = removed4.foo; -let removed5a; -const removed5b = removed5a = {}; -const removedResult5 = removed5b.foo; - const removed6 = 1 + 2; const removedResult6 = removed6.foo; diff --git a/test/form/samples/nested-pure-comments/_config.js b/test/form/samples/nested-pure-comments/_config.js new file mode 100644 index 00000000000..8f300142c3e --- /dev/null +++ b/test/form/samples/nested-pure-comments/_config.js @@ -0,0 +1,4 @@ +module.exports = defineTest({ + description: 'correctly associates pure comments before sequence expressions etc.', + expectedWarnings: ['INVALID_ANNOTATION'] +}); diff --git a/test/form/samples/nested-pure-comments/_expected.js b/test/form/samples/nested-pure-comments/_expected.js new file mode 100644 index 00000000000..62590bf63dc --- /dev/null +++ b/test/form/samples/nested-pure-comments/_expected.js @@ -0,0 +1,18 @@ +// Sequence expression +(keep()); +keep(); +const foo = (/*@__PURE__*/keep()); + +// Conditional expression +(keep() ? 1 : 2); +keep(); + +// Logical expression +(keep() || 1); +keep(); + +// Binary expression +(keep() / 1); +1 / keep(); + +export { foo }; diff --git a/test/form/samples/nested-pure-comments/main.js b/test/form/samples/nested-pure-comments/main.js new file mode 100644 index 00000000000..d9791f075af --- /dev/null +++ b/test/form/samples/nested-pure-comments/main.js @@ -0,0 +1,26 @@ +// Sequence expression +/*@__PURE__*/(keep(), /*@__PURE__*/remove()); +/*@__PURE__*/remove(), keep(), /*@__PURE__*/remove(); +/*@__PURE__*/remove(), /*@__PURE__*/remove(); +export const foo = /*@__PURE__*/(/*@__PURE__*/remove(), /*@__PURE__*/keep()); + +// Conditional expression +/*@__PURE__*/(keep() ? 1 : 2); +/*@__PURE__*/remove() ? /*@__PURE__*/remove() : /*@__PURE__*/remove(); +false ? 1 /*@__PURE__*/ : keep(); + +// Logical expression +/*@__PURE__*/(keep() || 1); +/*@__PURE__*/remove() || /*@__PURE__*/remove(); +false /*@__PURE__*/ || keep(); + +// Binary expression +/* @__PURE__ */(keep() / 1); +/* @__PURE__ */remove() / /* @__PURE__ */remove(); +1 /* @__PURE__ */ / keep(); + +// Calls with parentheses +/*@__PURE__*/(remove()); +/*@__PURE__*/(((remove()))); +/*@__PURE__*/(new Remove()); +/*@__PURE__*/(((new Remove()))); diff --git a/test/form/samples/nested-this-expressions/_config.js b/test/form/samples/nested-this-expressions/_config.js index ec7aac395ed..d54b9366b3d 100644 --- a/test/form/samples/nested-this-expressions/_config.js +++ b/test/form/samples/nested-this-expressions/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'properly keep or ignore nested "this"-expressions' -}; +}); diff --git a/test/form/samples/nested-tree-shaking/_config.js b/test/form/samples/nested-tree-shaking/_config.js index 44335e294be..07001ced025 100644 --- a/test/form/samples/nested-tree-shaking/_config.js +++ b/test/form/samples/nested-tree-shaking/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'removes unused nested statements' -}; +}); diff --git a/test/form/samples/new-target-meta-property/_config.js b/test/form/samples/new-target-meta-property/_config.js index 0b9edf38046..4a3867dbb81 100644 --- a/test/form/samples/new-target-meta-property/_config.js +++ b/test/form/samples/new-target-meta-property/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'supports the new.target meta property' -}; +}); diff --git a/test/form/samples/new-target-meta-property/_expected/amd.js b/test/form/samples/new-target-meta-property/_expected/amd.js new file mode 100644 index 00000000000..dd4f32a0c00 --- /dev/null +++ b/test/form/samples/new-target-meta-property/_expected/amd.js @@ -0,0 +1,11 @@ +define((function () { 'use strict'; + + class Foo { + constructor() { + console.log(new.target.name); + } + } + + new Foo(); + +})); diff --git a/test/form/samples/new-target-meta-property/_expected/cjs.js b/test/form/samples/new-target-meta-property/_expected/cjs.js new file mode 100644 index 00000000000..ab9ae691acd --- /dev/null +++ b/test/form/samples/new-target-meta-property/_expected/cjs.js @@ -0,0 +1,9 @@ +'use strict'; + +class Foo { + constructor() { + console.log(new.target.name); + } +} + +new Foo(); diff --git a/test/form/samples/new-target-meta-property/_expected.js b/test/form/samples/new-target-meta-property/_expected/es.js similarity index 100% rename from test/form/samples/new-target-meta-property/_expected.js rename to test/form/samples/new-target-meta-property/_expected/es.js diff --git a/test/form/samples/new-target-meta-property/_expected/iife.js b/test/form/samples/new-target-meta-property/_expected/iife.js new file mode 100644 index 00000000000..0c3d26e367c --- /dev/null +++ b/test/form/samples/new-target-meta-property/_expected/iife.js @@ -0,0 +1,12 @@ +(function () { + 'use strict'; + + class Foo { + constructor() { + console.log(new.target.name); + } + } + + new Foo(); + +})(); diff --git a/test/form/samples/new-target-meta-property/_expected/system.js b/test/form/samples/new-target-meta-property/_expected/system.js new file mode 100644 index 00000000000..7cfbd402995 --- /dev/null +++ b/test/form/samples/new-target-meta-property/_expected/system.js @@ -0,0 +1,16 @@ +System.register([], (function () { + 'use strict'; + return { + execute: (function () { + + class Foo { + constructor() { + console.log(new.target.name); + } + } + + new Foo(); + + }) + }; +})); diff --git a/test/form/samples/new-target-meta-property/_expected/umd.js b/test/form/samples/new-target-meta-property/_expected/umd.js new file mode 100644 index 00000000000..40340fa863a --- /dev/null +++ b/test/form/samples/new-target-meta-property/_expected/umd.js @@ -0,0 +1,14 @@ +(function (factory) { + typeof define === 'function' && define.amd ? define(factory) : + factory(); +})((function () { 'use strict'; + + class Foo { + constructor() { + console.log(new.target.name); + } + } + + new Foo(); + +})); diff --git a/test/form/samples/no-external-live-bindings-compact/_config.js b/test/form/samples/no-external-live-bindings-compact/_config.js index 875b61c29c6..df3e7448f7b 100644 --- a/test/form/samples/no-external-live-bindings-compact/_config.js +++ b/test/form/samples/no-external-live-bindings-compact/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'Allows omitting the code that handles external live bindings in compact mode', options: { external: () => true, @@ -9,7 +9,8 @@ module.exports = { }, compact: true, externalLiveBindings: false, - name: 'bundle' + name: 'bundle', + dynamicImportInCjs: false } } -}; +}); diff --git a/test/form/samples/no-external-live-bindings-compact/_expected/amd.js b/test/form/samples/no-external-live-bindings-compact/_expected/amd.js index 4d4d211ae47..c4dae77cf91 100644 --- a/test/form/samples/no-external-live-bindings-compact/_expected/amd.js +++ b/test/form/samples/no-external-live-bindings-compact/_expected/amd.js @@ -1 +1 @@ -define(['require','exports','external1','external2'],function(require,exports,external1,external2){'use strict';function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){n[k]=e[k];});}n['default']=e;return Object.freeze(n);}const dynamic = new Promise(function(c,e){require(['external3'],function(m){c(/*#__PURE__*/_interopNamespace(m));},e)});exports.external1=external1.external1;exports.dynamic=dynamic;Object.keys(external2).forEach(function(k){if(k!=='default'&&!exports.hasOwnProperty(k))exports[k]=external2[k];});Object.defineProperty(exports,'__esModule',{value:true});}); \ No newline at end of file +define(['require','exports','external1','external2'],(function(require,exports,external1,external2){'use strict';function _interopNamespaceDefault(e){var n=Object.create(null);if(e){for(var k in e){n[k]=e[k];}}n.default=e;return Object.freeze(n)}const dynamic = new Promise(function(c,e){require(['external3'],function(m){c(/*#__PURE__*/_interopNamespaceDefault(m))},e)});exports.external1=external1.external1;exports.dynamic=dynamic;Object.prototype.hasOwnProperty.call(external2,'__proto__')&&!Object.prototype.hasOwnProperty.call(exports,'__proto__')&&Object.defineProperty(exports,'__proto__',{enumerable:true,value:external2['__proto__']});Object.keys(external2).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))exports[k]=external2[k]});})); \ No newline at end of file diff --git a/test/form/samples/no-external-live-bindings-compact/_expected/cjs.js b/test/form/samples/no-external-live-bindings-compact/_expected/cjs.js index 95ba0066264..25a4ea46fb6 100644 --- a/test/form/samples/no-external-live-bindings-compact/_expected/cjs.js +++ b/test/form/samples/no-external-live-bindings-compact/_expected/cjs.js @@ -1 +1 @@ -'use strict';Object.defineProperty(exports,'__esModule',{value:true});var external1=require('external1'),external2=require('external2');function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){n[k]=e[k];});}n['default']=e;return Object.freeze(n);}const dynamic = Promise.resolve().then(function(){return /*#__PURE__*/_interopNamespace(require('external3'))});exports.external1=external1.external1;exports.dynamic=dynamic;Object.keys(external2).forEach(function(k){if(k!=='default'&&!exports.hasOwnProperty(k))exports[k]=external2[k];}); \ No newline at end of file +'use strict';var external1=require('external1'),external2=require('external2');function _interopNamespaceDefault(e){var n=Object.create(null);if(e){for(var k in e){n[k]=e[k];}}n.default=e;return Object.freeze(n)}const dynamic = Promise.resolve().then(function(){return /*#__PURE__*/_interopNamespaceDefault(require('external3'))});exports.external1=external1.external1;exports.dynamic=dynamic;Object.prototype.hasOwnProperty.call(external2,'__proto__')&&!Object.prototype.hasOwnProperty.call(exports,'__proto__')&&Object.defineProperty(exports,'__proto__',{enumerable:true,value:external2['__proto__']});Object.keys(external2).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))exports[k]=external2[k]}); \ No newline at end of file diff --git a/test/form/samples/no-external-live-bindings-compact/_expected/iife.js b/test/form/samples/no-external-live-bindings-compact/_expected/iife.js index 9b545fb7682..3769d36439b 100644 --- a/test/form/samples/no-external-live-bindings-compact/_expected/iife.js +++ b/test/form/samples/no-external-live-bindings-compact/_expected/iife.js @@ -1 +1 @@ -var bundle=(function(exports,external1,external2){'use strict';const dynamic = import('external3');exports.external1=external1.external1;exports.dynamic=dynamic;Object.keys(external2).forEach(function(k){if(k!=='default'&&!exports.hasOwnProperty(k))exports[k]=external2[k];});Object.defineProperty(exports,'__esModule',{value:true});return exports;}({},external1,external2)); \ No newline at end of file +var bundle=(function(exports,external1,external2){'use strict';const dynamic = import('external3');exports.external1=external1.external1;exports.dynamic=dynamic;Object.prototype.hasOwnProperty.call(external2,'__proto__')&&!Object.prototype.hasOwnProperty.call(exports,'__proto__')&&Object.defineProperty(exports,'__proto__',{enumerable:true,value:external2['__proto__']});Object.keys(external2).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))exports[k]=external2[k]});return exports;})({},external1,external2); \ No newline at end of file diff --git a/test/form/samples/no-external-live-bindings-compact/_expected/system.js b/test/form/samples/no-external-live-bindings-compact/_expected/system.js index 50263d42352..195274170e3 100644 --- a/test/form/samples/no-external-live-bindings-compact/_expected/system.js +++ b/test/form/samples/no-external-live-bindings-compact/_expected/system.js @@ -1 +1 @@ -System.register('bundle',['external1','external2'],function(exports,module){'use strict';var _starExcludes={dynamic:1,default:1,external1:1};return{setters:[function(module){exports('external1',module.external1);},function(module){var _setter={};for(var _$pinmodule){if(!_starExcludes[_$p])_setter[_$p]=module[_$p];}exports(_setter);}],execute:function(){const dynamic = exports('dynamic',module.import('external3'));}}}); \ No newline at end of file +System.register('bundle',['external1','external2'],(function(exports,module){'use strict';var _starExcludes={__proto__:null,dynamic:1,default:1,external1:1};return{setters:[function(module){exports("external1",module.external1);},function(module){var setter={__proto__:null};for(var name in module){if(!_starExcludes[name])setter[name]=module[name];}exports(setter);}],execute:(function(){const dynamic = exports("dynamic",module.import('external3'));})}})); \ No newline at end of file diff --git a/test/form/samples/no-external-live-bindings-compact/_expected/umd.js b/test/form/samples/no-external-live-bindings-compact/_expected/umd.js index 58c3d25f209..d77e1de90a0 100644 --- a/test/form/samples/no-external-live-bindings-compact/_expected/umd.js +++ b/test/form/samples/no-external-live-bindings-compact/_expected/umd.js @@ -1 +1 @@ -(function(g,f){typeof exports==='object'&&typeof module!=='undefined'?f(exports,require('external1'),require('external2')):typeof define==='function'&&define.amd?define(['exports','external1','external2'],f):(g=typeof globalThis!=='undefined'?globalThis:g||self,f(g.bundle={},g.external1,g.external2));}(this,(function(exports, external1, external2){'use strict';const dynamic = import('external3');exports.external1=external1.external1;exports.dynamic=dynamic;Object.keys(external2).forEach(function(k){if(k!=='default'&&!exports.hasOwnProperty(k))exports[k]=external2[k];});Object.defineProperty(exports,'__esModule',{value:true});}))); \ No newline at end of file +(function(g,f){typeof exports==='object'&&typeof module!=='undefined'?f(exports,require('external1'),require('external2')):typeof define==='function'&&define.amd?define(['exports','external1','external2'],f):(g=typeof globalThis!=='undefined'?globalThis:g||self,f(g.bundle={},g.external1,g.external2));})(this,(function(exports,external1,external2){'use strict';const dynamic = import('external3');exports.external1=external1.external1;exports.dynamic=dynamic;Object.prototype.hasOwnProperty.call(external2,'__proto__')&&!Object.prototype.hasOwnProperty.call(exports,'__proto__')&&Object.defineProperty(exports,'__proto__',{enumerable:true,value:external2['__proto__']});Object.keys(external2).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))exports[k]=external2[k]});})); \ No newline at end of file diff --git a/test/form/samples/no-external-live-bindings/_config.js b/test/form/samples/no-external-live-bindings/_config.js index 55b97a19b34..27dc80bbb56 100644 --- a/test/form/samples/no-external-live-bindings/_config.js +++ b/test/form/samples/no-external-live-bindings/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'Allows omitting the code that handles external live bindings', options: { external: () => true, @@ -8,7 +8,8 @@ module.exports = { external2: 'external2' }, externalLiveBindings: false, - name: 'bundle' + name: 'bundle', + dynamicImportInCjs: false } } -}; +}); diff --git a/test/form/samples/no-external-live-bindings/_expected/amd.js b/test/form/samples/no-external-live-bindings/_expected/amd.js index 9b35d440d96..cd9e2ceb128 100644 --- a/test/form/samples/no-external-live-bindings/_expected/amd.js +++ b/test/form/samples/no-external-live-bindings/_expected/amd.js @@ -1,25 +1,29 @@ -define(['require', 'exports', 'external1', 'external2'], function (require, exports, external1, external2) { 'use strict'; +define(['require', 'exports', 'external1', 'external2'], (function (require, exports, external1, external2) { 'use strict'; - function _interopNamespace(e) { - if (e && e.__esModule) return e; + function _interopNamespaceDefault(e) { var n = Object.create(null); if (e) { - Object.keys(e).forEach(function (k) { + for (var k in e) { n[k] = e[k]; - }); + } } - n['default'] = e; + n.default = e; return Object.freeze(n); } - const dynamic = new Promise(function (resolve, reject) { require(['external3'], function (m) { resolve(/*#__PURE__*/_interopNamespace(m)); }, reject) }); + const dynamic = new Promise(function (resolve, reject) { require(['external3'], function (m) { resolve(/*#__PURE__*/_interopNamespaceDefault(m)); }, reject); }); exports.external1 = external1.external1; exports.dynamic = dynamic; + Object.prototype.hasOwnProperty.call(external2, '__proto__') && + !Object.prototype.hasOwnProperty.call(exports, '__proto__') && + Object.defineProperty(exports, '__proto__', { + enumerable: true, + value: external2['__proto__'] + }); + Object.keys(external2).forEach(function (k) { - if (k !== 'default' && !exports.hasOwnProperty(k)) exports[k] = external2[k]; + if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) exports[k] = external2[k]; }); - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/form/samples/no-external-live-bindings/_expected/cjs.js b/test/form/samples/no-external-live-bindings/_expected/cjs.js index 2c9efccf213..1372b5590a5 100644 --- a/test/form/samples/no-external-live-bindings/_expected/cjs.js +++ b/test/form/samples/no-external-live-bindings/_expected/cjs.js @@ -1,26 +1,30 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - var external1 = require('external1'); var external2 = require('external2'); -function _interopNamespace(e) { - if (e && e.__esModule) return e; +function _interopNamespaceDefault(e) { var n = Object.create(null); if (e) { - Object.keys(e).forEach(function (k) { + for (var k in e) { n[k] = e[k]; - }); + } } - n['default'] = e; + n.default = e; return Object.freeze(n); } -const dynamic = Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('external3')); }); +const dynamic = Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespaceDefault(require('external3')); }); exports.external1 = external1.external1; exports.dynamic = dynamic; +Object.prototype.hasOwnProperty.call(external2, '__proto__') && + !Object.prototype.hasOwnProperty.call(exports, '__proto__') && + Object.defineProperty(exports, '__proto__', { + enumerable: true, + value: external2['__proto__'] + }); + Object.keys(external2).forEach(function (k) { - if (k !== 'default' && !exports.hasOwnProperty(k)) exports[k] = external2[k]; + if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) exports[k] = external2[k]; }); diff --git a/test/form/samples/no-external-live-bindings/_expected/iife.js b/test/form/samples/no-external-live-bindings/_expected/iife.js index 65bc640d59c..09d0e40736b 100644 --- a/test/form/samples/no-external-live-bindings/_expected/iife.js +++ b/test/form/samples/no-external-live-bindings/_expected/iife.js @@ -5,12 +5,17 @@ var bundle = (function (exports, external1, external2) { exports.external1 = external1.external1; exports.dynamic = dynamic; + Object.prototype.hasOwnProperty.call(external2, '__proto__') && + !Object.prototype.hasOwnProperty.call(exports, '__proto__') && + Object.defineProperty(exports, '__proto__', { + enumerable: true, + value: external2['__proto__'] + }); + Object.keys(external2).forEach(function (k) { - if (k !== 'default' && !exports.hasOwnProperty(k)) exports[k] = external2[k]; + if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) exports[k] = external2[k]; }); - Object.defineProperty(exports, '__esModule', { value: true }); - return exports; -}({}, external1, external2)); +})({}, external1, external2); diff --git a/test/form/samples/no-external-live-bindings/_expected/system.js b/test/form/samples/no-external-live-bindings/_expected/system.js index 0b5739a7de3..a0ee1c762ee 100644 --- a/test/form/samples/no-external-live-bindings/_expected/system.js +++ b/test/form/samples/no-external-live-bindings/_expected/system.js @@ -1,20 +1,25 @@ -System.register('bundle', ['external1', 'external2'], function (exports, module) { +System.register('bundle', ['external1', 'external2'], (function (exports, module) { 'use strict'; - var _starExcludes = { dynamic: 1, default: 1, external1: 1 }; + var _starExcludes = { + __proto__: null, + dynamic: 1, + default: 1, + external1: 1 + }; return { setters: [function (module) { - exports('external1', module.external1); + exports("external1", module.external1); }, function (module) { - var _setter = {}; - for (var _$p in module) { - if (!_starExcludes[_$p]) _setter[_$p] = module[_$p]; + var setter = { __proto__: null }; + for (var name in module) { + if (!_starExcludes[name]) setter[name] = module[name]; } - exports(_setter); + exports(setter); }], - execute: function () { + execute: (function () { - const dynamic = exports('dynamic', module.import('external3')); + const dynamic = exports("dynamic", module.import('external3')); - } + }) }; -}); +})); diff --git a/test/form/samples/no-external-live-bindings/_expected/umd.js b/test/form/samples/no-external-live-bindings/_expected/umd.js index 09d4d9e60bc..e5fdc6f1b11 100644 --- a/test/form/samples/no-external-live-bindings/_expected/umd.js +++ b/test/form/samples/no-external-live-bindings/_expected/umd.js @@ -2,16 +2,21 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('external1'), require('external2')) : typeof define === 'function' && define.amd ? define(['exports', 'external1', 'external2'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.bundle = {}, global.external1, global.external2)); -}(this, (function (exports, external1, external2) { 'use strict'; +})(this, (function (exports, external1, external2) { 'use strict'; const dynamic = import('external3'); exports.external1 = external1.external1; exports.dynamic = dynamic; + Object.prototype.hasOwnProperty.call(external2, '__proto__') && + !Object.prototype.hasOwnProperty.call(exports, '__proto__') && + Object.defineProperty(exports, '__proto__', { + enumerable: true, + value: external2['__proto__'] + }); + Object.keys(external2).forEach(function (k) { - if (k !== 'default' && !exports.hasOwnProperty(k)) exports[k] = external2[k]; + if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) exports[k] = external2[k]; }); - Object.defineProperty(exports, '__esModule', { value: true }); - -}))); +})); diff --git a/test/form/samples/no-imports-or-exports/_config.js b/test/form/samples/no-imports-or-exports/_config.js index 88d37593495..aa847d49b30 100644 --- a/test/form/samples/no-imports-or-exports/_config.js +++ b/test/form/samples/no-imports-or-exports/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'single module, no imports or exports' -}; +}); diff --git a/test/form/samples/no-imports-or-exports/_expected/amd.js b/test/form/samples/no-imports-or-exports/_expected/amd.js index f0eeb441363..c8b47c1c251 100644 --- a/test/form/samples/no-imports-or-exports/_expected/amd.js +++ b/test/form/samples/no-imports-or-exports/_expected/amd.js @@ -1,5 +1,5 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; console.log( 'this is it' ); -}); +})); diff --git a/test/form/samples/no-imports-or-exports/_expected/iife.js b/test/form/samples/no-imports-or-exports/_expected/iife.js index a57b26d3aae..0cc176eb331 100644 --- a/test/form/samples/no-imports-or-exports/_expected/iife.js +++ b/test/form/samples/no-imports-or-exports/_expected/iife.js @@ -3,4 +3,4 @@ console.log( 'this is it' ); -}()); +})(); diff --git a/test/form/samples/no-imports-or-exports/_expected/system.js b/test/form/samples/no-imports-or-exports/_expected/system.js index 5bee7fdd063..23d9818aa1f 100644 --- a/test/form/samples/no-imports-or-exports/_expected/system.js +++ b/test/form/samples/no-imports-or-exports/_expected/system.js @@ -1,10 +1,10 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { console.log( 'this is it' ); - } + }) }; -}); +})); diff --git a/test/form/samples/no-imports-or-exports/_expected/umd.js b/test/form/samples/no-imports-or-exports/_expected/umd.js index 3c5125e49ea..593d845ca96 100644 --- a/test/form/samples/no-imports-or-exports/_expected/umd.js +++ b/test/form/samples/no-imports-or-exports/_expected/umd.js @@ -1,8 +1,8 @@ (function (factory) { typeof define === 'function' && define.amd ? define(factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; console.log( 'this is it' ); -}))); +})); diff --git a/test/form/samples/no-side-effects-function-declaration-preserve/_config.js b/test/form/samples/no-side-effects-function-declaration-preserve/_config.js new file mode 100644 index 00000000000..7878d064aef --- /dev/null +++ b/test/form/samples/no-side-effects-function-declaration-preserve/_config.js @@ -0,0 +1,4 @@ +module.exports = defineTest({ + description: 'preserve __NO_SIDE_EFFECTS__ annotations for function declarations', + expectedWarnings: ['INVALID_ANNOTATION'] +}); diff --git a/test/form/samples/no-side-effects-function-declaration-preserve/_expected.js b/test/form/samples/no-side-effects-function-declaration-preserve/_expected.js new file mode 100644 index 00000000000..841bb6ee087 --- /dev/null +++ b/test/form/samples/no-side-effects-function-declaration-preserve/_expected.js @@ -0,0 +1,66 @@ +/*#__NO_SIDE_EFFECTS__*/ +function fnFromSub (args) { + console.log(args); + return args +} + +function fnPure(args) { + return args +} + +function fnEffects(args) { + console.log(args); + return args +} + +/*#__NO_SIDE_EFFECTS__*/ +function fnA (args) { + console.log(args); + return args +} + +/*#__NO_SIDE_EFFECTS__*/ +function fnB (args) { + console.log(args); + return args +} + +const fnC = /*#__NO_SIDE_EFFECTS__*/ (args) => { + console.log(args); + return args +}; + + +/*#__NO_SIDE_EFFECTS__*/ +const fnD = (args) => { + console.log(args); + return args +}; + +/*#__NO_SIDE_EFFECTS__*/ +const fnE = (args) => { + console.log(args); + return args +}; + +/** + * This is a jsdoc comment, with no side effects annotation + * + * @param {any} args + * @__NO_SIDE_EFFECTS__ + */ +const fnF = (args) => { + console.log(args); + return args +}; + +const fnAlias = fnA; + +// This annonation get ignored + +let fnLet = (args) => { + console.log(args); + return args +}; + +export { fnA, fnAlias, fnB, fnC, fnD, fnE, fnEffects, fnF, fnFromSub, fnLet, fnPure }; diff --git a/test/form/samples/no-side-effects-function-declaration-preserve/functions.js b/test/form/samples/no-side-effects-function-declaration-preserve/functions.js new file mode 100644 index 00000000000..59c37d8d97f --- /dev/null +++ b/test/form/samples/no-side-effects-function-declaration-preserve/functions.js @@ -0,0 +1,69 @@ +export function fnPure(args) { + return args +} + +export function fnEffects(args) { + console.log(args) + return args +} + +/*#__NO_SIDE_EFFECTS__*/ +function fnA (args) { + console.log(args) + return args +} +export { fnA } + +/*#__NO_SIDE_EFFECTS__*/ +export function fnB (args) { + console.log(args) + return args +} + +export const fnC = /*#__NO_SIDE_EFFECTS__*/ (args) => { + console.log(args) + return args +} + + +/*#__NO_SIDE_EFFECTS__*/ +const fnD = (args) => { + console.log(args) + return args +} + +export { fnD } + +/*#__NO_SIDE_EFFECTS__*/ +export const fnE = (args) => { + console.log(args) + return args +} + +/** + * This is a jsdoc comment, with no side effects annotation + * + * @param {any} args + * @__NO_SIDE_EFFECTS__ + */ +export const fnF = (args) => { + console.log(args) + return args +} + +/*#__NO_SIDE_EFFECTS__*/ +export default function fnDefault(args) { + console.log(args) + return args +} + +export * from './sub-functions' + +export const fnAlias = fnA + +// This annonation get ignored +/** @__NO_SIDE_EFFECTS__ */ +export let fnLet = (args) => { + console.log(args) + return args +} diff --git a/test/form/samples/no-side-effects-function-declaration-preserve/main.js b/test/form/samples/no-side-effects-function-declaration-preserve/main.js new file mode 100644 index 00000000000..326e35231ee --- /dev/null +++ b/test/form/samples/no-side-effects-function-declaration-preserve/main.js @@ -0,0 +1 @@ +export * from './functions' diff --git a/test/form/samples/no-side-effects-function-declaration-preserve/sub-functions.js b/test/form/samples/no-side-effects-function-declaration-preserve/sub-functions.js new file mode 100644 index 00000000000..ed703deb9db --- /dev/null +++ b/test/form/samples/no-side-effects-function-declaration-preserve/sub-functions.js @@ -0,0 +1,5 @@ +/*#__NO_SIDE_EFFECTS__*/ +export function fnFromSub (args) { + console.log(args) + return args +} diff --git a/test/form/samples/no-side-effects-function-declaration/_config.js b/test/form/samples/no-side-effects-function-declaration/_config.js new file mode 100644 index 00000000000..5d7379912bb --- /dev/null +++ b/test/form/samples/no-side-effects-function-declaration/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: '__NO_SIDE_EFFECTS__ annotations for function declarations' +}); diff --git a/test/form/samples/no-side-effects-function-declaration/_expected.js b/test/form/samples/no-side-effects-function-declaration/_expected.js new file mode 100644 index 00000000000..bc3b94942f6 --- /dev/null +++ b/test/form/samples/no-side-effects-function-declaration/_expected.js @@ -0,0 +1,6 @@ +function fnEffects(args) { + console.log(args); + return args +} + +fnEffects(2); diff --git a/test/form/samples/no-side-effects-function-declaration/functions.js b/test/form/samples/no-side-effects-function-declaration/functions.js new file mode 100644 index 00000000000..83d130ce844 --- /dev/null +++ b/test/form/samples/no-side-effects-function-declaration/functions.js @@ -0,0 +1,98 @@ +export function fnPure(args) { + return args +} + +export function fnEffects(args) { + console.log(args) + return args +} + +/*#__NO_SIDE_EFFECTS__*/ +function fnA (args) { + console.log(args) + return args +} +export { fnA } + +/*#__NO_SIDE_EFFECTS__*/ +export function fnB (args) { + console.log(args) + return args +} + +export const fnC = /*#__NO_SIDE_EFFECTS__*/ (args) => { + console.log(args) + return args +} + + +/*#__NO_SIDE_EFFECTS__*/ +const fnD = (args) => { + console.log(args) + return args +} + +export { fnD } + +/*#__NO_SIDE_EFFECTS__*/ +export const fnE = (args) => { + console.log(args) + return args +} + +/** + * This is a jsdoc comment, with pure annotation + * + * @param {any} args + * @__NO_SIDE_EFFECTS__ + */ +export const fnF = (args) => { + console.log(args) + return args +} + +// #__NO_SIDE_EFFECTS__ +export async function fnG(args) { + console.log(args) + return args +} + +/** + * #__NO_SIDE_EFFECTS__ + */ +export const fnH = async (args) => { + console.log(args) + return args +} + +export const fnI = /*#__NO_SIDE_EFFECTS__*/ async (args) => { + console.log(args) + return args +} + + +/** + * #__NO_SIDE_EFFECTS__ + */ +export function * fnJ(args) { + console.log(args) + return args +} + +/** + * #__NO_SIDE_EFFECTS__ + */ +export async function * fnK(args) { + console.log(args) + return args +} + +/*#__NO_SIDE_EFFECTS__*/ +export default function fnDefault(args) { + console.log(args) + return args +} + +export * from './sub-functions' + +export const fnAlias = fnA diff --git a/test/form/samples/no-side-effects-function-declaration/main.js b/test/form/samples/no-side-effects-function-declaration/main.js new file mode 100644 index 00000000000..bdef73a43b8 --- /dev/null +++ b/test/form/samples/no-side-effects-function-declaration/main.js @@ -0,0 +1,21 @@ +import fnDefault, { fnPure, fnEffects, fnA, fnB, fnC, fnD, fnE, fnF, fnI, fnG, fnJ, fnK, fnAlias, fnFromSub } from './functions' + +const pure = fnPure(1) +const effects = fnEffects(2) + +const a = fnA(1) +const b = fnB(2) +const c = fnC(3) +const d = fnD(4) +const e = fnE(5) +const f = fnF(6) +const g = fnG(7) +const i = fnI(8) +const j = fnJ(9) +const k = fnK(10) + +const defaults = fnDefault(3) +const alias = fnAlias(6) +const fromSub = fnFromSub(7) + +const _ = /*#__PURE__*/ fnEffects(1) diff --git a/test/form/samples/no-side-effects-function-declaration/sub-functions.js b/test/form/samples/no-side-effects-function-declaration/sub-functions.js new file mode 100644 index 00000000000..ed703deb9db --- /dev/null +++ b/test/form/samples/no-side-effects-function-declaration/sub-functions.js @@ -0,0 +1,5 @@ +/*#__NO_SIDE_EFFECTS__*/ +export function fnFromSub (args) { + console.log(args) + return args +} diff --git a/test/form/samples/no-treeshake-conflict/_config.js b/test/form/samples/no-treeshake-conflict/_config.js index 76055873d17..eb63f37d959 100644 --- a/test/form/samples/no-treeshake-conflict/_config.js +++ b/test/form/samples/no-treeshake-conflict/_config.js @@ -1,7 +1,7 @@ -module.exports = { +module.exports = defineTest({ description: 'does not introduce conflicting variables with treeshake: false', options: { output: { name: /* not shaken, but */ 'stirred' }, treeshake: false } -}; +}); diff --git a/test/form/samples/no-treeshake-conflict/_expected/amd.js b/test/form/samples/no-treeshake-conflict/_expected/amd.js index 301c4950be6..d8223bac511 100644 --- a/test/form/samples/no-treeshake-conflict/_expected/amd.js +++ b/test/form/samples/no-treeshake-conflict/_expected/amd.js @@ -1,4 +1,4 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; const other$1 = { something: 'here' @@ -8,4 +8,4 @@ define(function () { 'use strict'; somethingElse: 'here' }; -}); +})); diff --git a/test/form/samples/no-treeshake-conflict/_expected/iife.js b/test/form/samples/no-treeshake-conflict/_expected/iife.js index 278e907160c..66f6b17bd66 100644 --- a/test/form/samples/no-treeshake-conflict/_expected/iife.js +++ b/test/form/samples/no-treeshake-conflict/_expected/iife.js @@ -9,4 +9,4 @@ somethingElse: 'here' }; -}()); +})(); diff --git a/test/form/samples/no-treeshake-conflict/_expected/system.js b/test/form/samples/no-treeshake-conflict/_expected/system.js index 094b4f81437..20b793cca1f 100644 --- a/test/form/samples/no-treeshake-conflict/_expected/system.js +++ b/test/form/samples/no-treeshake-conflict/_expected/system.js @@ -1,7 +1,7 @@ -System.register('stirred', [], function () { +System.register('stirred', [], (function () { 'use strict'; return { - execute: function () { + execute: (function () { const other$1 = { something: 'here' @@ -11,6 +11,6 @@ System.register('stirred', [], function () { somethingElse: 'here' }; - } + }) }; -}); +})); diff --git a/test/form/samples/no-treeshake-conflict/_expected/umd.js b/test/form/samples/no-treeshake-conflict/_expected/umd.js index be7d134e4a5..5095f828563 100644 --- a/test/form/samples/no-treeshake-conflict/_expected/umd.js +++ b/test/form/samples/no-treeshake-conflict/_expected/umd.js @@ -1,7 +1,7 @@ (function (factory) { typeof define === 'function' && define.amd ? define(factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; const other$1 = { something: 'here' @@ -11,4 +11,4 @@ somethingElse: 'here' }; -}))); +})); diff --git a/test/form/samples/no-treeshake-default-export-conflict/_config.js b/test/form/samples/no-treeshake-default-export-conflict/_config.js index b312d610d77..0502768db48 100644 --- a/test/form/samples/no-treeshake-default-export-conflict/_config.js +++ b/test/form/samples/no-treeshake-default-export-conflict/_config.js @@ -1,6 +1,6 @@ -module.exports = { +module.exports = defineTest({ description: 'properly deconflicts default exports when not tree-shaking', options: { treeshake: false } -}; +}); diff --git a/test/form/samples/no-treeshake-default-export-conflict/_expected.js b/test/form/samples/no-treeshake-default-export-conflict/_expected.js index 825d8841cf5..cf22df69b4f 100644 --- a/test/form/samples/no-treeshake-default-export-conflict/_expected.js +++ b/test/form/samples/no-treeshake-default-export-conflict/_expected.js @@ -2,6 +2,6 @@ function foo() { return 'foo'; } -function foo$1() { +function foo_default() { return 'default'; } diff --git a/test/form/samples/no-treeshake-include-labels/_config.js b/test/form/samples/no-treeshake-include-labels/_config.js index fc8487608b1..3e2a1f75970 100644 --- a/test/form/samples/no-treeshake-include-labels/_config.js +++ b/test/form/samples/no-treeshake-include-labels/_config.js @@ -1,7 +1,7 @@ -module.exports = { +module.exports = defineTest({ description: 'always includes labels when tree-shaking is turned off (#3473)', expectedWarnings: ['CIRCULAR_DEPENDENCY'], options: { treeshake: false } -}; +}); diff --git a/test/form/samples/no-treeshake-namespace-object/_config.js b/test/form/samples/no-treeshake-namespace-object/_config.js new file mode 100644 index 00000000000..58637fb03e5 --- /dev/null +++ b/test/form/samples/no-treeshake-namespace-object/_config.js @@ -0,0 +1,6 @@ +module.exports = defineTest({ + description: 'generates namespace objects when not tree-shaking', + options: { + treeshake: false + } +}); diff --git a/test/form/samples/no-treeshake-namespace-object/_expected.js b/test/form/samples/no-treeshake-namespace-object/_expected.js new file mode 100644 index 00000000000..cddaf554c82 --- /dev/null +++ b/test/form/samples/no-treeshake-namespace-object/_expected.js @@ -0,0 +1,11 @@ +function foo() {} + +var namespace = /*#__PURE__*/Object.freeze({ + __proto__: null, + foo: foo +}); + +const a = 1; +const b = 2; + +export { a, b, namespace as ns1, namespace as ns2 }; diff --git a/test/form/samples/no-treeshake-namespace-object/main.js b/test/form/samples/no-treeshake-namespace-object/main.js new file mode 100644 index 00000000000..5e4ca4d7427 --- /dev/null +++ b/test/form/samples/no-treeshake-namespace-object/main.js @@ -0,0 +1,8 @@ +import * as ns1 from './namespace'; + +export { ns1 }; + +export * as ns2 from './namespace'; + +export const a = 1; +export const b = 2; diff --git a/test/form/samples/no-treeshake-namespace-object/namespace.js b/test/form/samples/no-treeshake-namespace-object/namespace.js new file mode 100644 index 00000000000..f99d4277774 --- /dev/null +++ b/test/form/samples/no-treeshake-namespace-object/namespace.js @@ -0,0 +1 @@ +export function foo() {} diff --git a/test/form/samples/no-treeshake/_config.js b/test/form/samples/no-treeshake/_config.js index 76d525b3517..bb626f86bb2 100644 --- a/test/form/samples/no-treeshake/_config.js +++ b/test/form/samples/no-treeshake/_config.js @@ -1,11 +1,12 @@ -module.exports = { +module.exports = defineTest({ description: 'all code should be included if tree-shaking is disabled', options: { external: ['external'], treeshake: false, output: { globals: { external: 'external' }, - name: /* not shaken, but */ 'stirred' + name: /* not shaken, but */ 'stirred', + inlineDynamicImports: true } } -}; +}); diff --git a/test/form/samples/no-treeshake/_expected.js b/test/form/samples/no-treeshake/_expected.js index d0a6b53417a..d733aba270d 100644 --- a/test/form/samples/no-treeshake/_expected.js +++ b/test/form/samples/no-treeshake/_expected.js @@ -6,6 +6,16 @@ const quux = 1; const other = () => quux; +const fred$1 = 1; + +var dynamicImported = () => fred$1; + +var dynamicImported$1 = /*#__PURE__*/Object.freeze({ + __proto__: null, + default: dynamicImported, + fred: fred$1 +}); + function baz() { return foo + external.value; } @@ -54,4 +64,6 @@ try { const x = 1; } catch {} +const { fred } = await Promise.resolve().then(function () { return dynamicImported$1; }); + export { create, getPrototypeOf, quux, quux as strange }; diff --git a/test/form/samples/no-treeshake/dynamic-imported.js b/test/form/samples/no-treeshake/dynamic-imported.js new file mode 100644 index 00000000000..42eb4136650 --- /dev/null +++ b/test/form/samples/no-treeshake/dynamic-imported.js @@ -0,0 +1,3 @@ +export const fred = 1; + +export default () => fred; diff --git a/test/form/samples/no-treeshake/main.js b/test/form/samples/no-treeshake/main.js index 2dde2e93fa0..c60d8840915 100644 --- a/test/form/samples/no-treeshake/main.js +++ b/test/form/samples/no-treeshake/main.js @@ -51,3 +51,5 @@ test({ try { const x = 1; } catch {} + +const { fred } = await import('./dynamic-imported.js'); diff --git a/test/form/samples/non-empty-block-statement/_config.js b/test/form/samples/non-empty-block-statement/_config.js index 92803d709a4..0842b108698 100644 --- a/test/form/samples/non-empty-block-statement/_config.js +++ b/test/form/samples/non-empty-block-statement/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'do not remove non an empty block statement' -}; +}); diff --git a/test/form/samples/non-empty-block-statement/_expected/amd.js b/test/form/samples/non-empty-block-statement/_expected/amd.js index aaad1ffce51..73fea2d7361 100644 --- a/test/form/samples/non-empty-block-statement/_expected/amd.js +++ b/test/form/samples/non-empty-block-statement/_expected/amd.js @@ -1,4 +1,4 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; console.log( 1 ); { @@ -6,4 +6,4 @@ define(function () { 'use strict'; } console.log( tmp ); -}); +})); diff --git a/test/form/samples/non-empty-block-statement/_expected/iife.js b/test/form/samples/non-empty-block-statement/_expected/iife.js index 611fa6e610d..3555580f647 100644 --- a/test/form/samples/non-empty-block-statement/_expected/iife.js +++ b/test/form/samples/non-empty-block-statement/_expected/iife.js @@ -7,4 +7,4 @@ } console.log( tmp ); -}()); +})(); diff --git a/test/form/samples/non-empty-block-statement/_expected/system.js b/test/form/samples/non-empty-block-statement/_expected/system.js index 782deaeb872..c89478c2953 100644 --- a/test/form/samples/non-empty-block-statement/_expected/system.js +++ b/test/form/samples/non-empty-block-statement/_expected/system.js @@ -1,7 +1,7 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { console.log( 1 ); { @@ -9,6 +9,6 @@ System.register([], function () { } console.log( tmp ); - } + }) }; -}); +})); diff --git a/test/form/samples/non-empty-block-statement/_expected/umd.js b/test/form/samples/non-empty-block-statement/_expected/umd.js index 065115dc27b..e374d68160a 100644 --- a/test/form/samples/non-empty-block-statement/_expected/umd.js +++ b/test/form/samples/non-empty-block-statement/_expected/umd.js @@ -1,7 +1,7 @@ (function (factory) { typeof define === 'function' && define.amd ? define(factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; console.log( 1 ); { @@ -9,4 +9,4 @@ } console.log( tmp ); -}))); +})); diff --git a/test/form/samples/ns-external-star-reexport/_config.js b/test/form/samples/ns-external-star-reexport/_config.js index 06cdf4d0268..a556f5bcd45 100644 --- a/test/form/samples/ns-external-star-reexport/_config.js +++ b/test/form/samples/ns-external-star-reexport/_config.js @@ -1,18 +1,20 @@ -module.exports = { +module.exports = defineTest({ description: 'supports namespaces with external star reexports', options: { external: ['external1', 'external2'], - plugins: { - transform(code, id) { - if (id.endsWith('override.js')) { - return { - code, - syntheticNamedExports: true - }; + plugins: [ + { + transform(code, id) { + if (id.endsWith('override.js')) { + return { + code, + syntheticNamedExports: true + }; + } + return null; } - return null; } - }, + ], output: { globals: { external1: 'external1', @@ -21,4 +23,4 @@ module.exports = { name: 'bundle' } } -}; +}); diff --git a/test/form/samples/ns-external-star-reexport/_expected/amd.js b/test/form/samples/ns-external-star-reexport/_expected/amd.js index 49a07ca772d..c69b34bf472 100644 --- a/test/form/samples/ns-external-star-reexport/_expected/amd.js +++ b/test/form/samples/ns-external-star-reexport/_expected/amd.js @@ -1,7 +1,6 @@ -define(['exports', 'external1', 'external2'], function (exports, external1, external2) { 'use strict'; +define(['exports', 'external1', 'external2'], (function (exports, external1, external2) { 'use strict'; - function _interopNamespace(e) { - if (e && e.__esModule) return e; + function _interopNamespaceDefault(e) { var n = Object.create(null); if (e) { Object.keys(e).forEach(function (k) { @@ -9,36 +8,50 @@ define(['exports', 'external1', 'external2'], function (exports, external1, exte var d = Object.getOwnPropertyDescriptor(e, k); Object.defineProperty(n, k, d.get ? d : { enumerable: true, - get: function () { - return e[k]; - } + get: function () { return e[k]; } }); } }); } - n['default'] = e; + n.default = e; return Object.freeze(n); } - var external1__namespace = /*#__PURE__*/_interopNamespace(external1); - var external2__namespace = /*#__PURE__*/_interopNamespace(external2); + function _mergeNamespaces(n, m) { + m.forEach(function (e) { + e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) { + if (k !== 'default' && !(k in n)) { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + }); + return Object.freeze(n); + } - var reexportExternal = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.assign(/*#__PURE__*/Object.create(null), external1__namespace)); + var external1__namespace = /*#__PURE__*/_interopNamespaceDefault(external1); + var external2__namespace = /*#__PURE__*/_interopNamespaceDefault(external2); + + var reexportExternal = /*#__PURE__*/_mergeNamespaces({ + __proto__: null + }, [external1__namespace]); const extra = 'extra'; const override = 'override'; var reexportExternalsWithOverride = { synthetic: 'synthetic' }; - var reexportExternalsWithOverride$1 = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.assign(/*#__PURE__*/Object.create(null), external1__namespace, external2__namespace, reexportExternalsWithOverride, { - override: override, - 'default': reexportExternalsWithOverride, - extra: extra - })); + var reexportExternalsWithOverride$1 = /*#__PURE__*/_mergeNamespaces({ + __proto__: null, + default: reexportExternalsWithOverride, + extra: extra, + override: override + }, [reexportExternalsWithOverride, external1__namespace, external2__namespace]); exports.external = reexportExternal; exports.externalOverride = reexportExternalsWithOverride$1; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/form/samples/ns-external-star-reexport/_expected/cjs.js b/test/form/samples/ns-external-star-reexport/_expected/cjs.js index eef8965a511..dde5700cdcc 100644 --- a/test/form/samples/ns-external-star-reexport/_expected/cjs.js +++ b/test/form/samples/ns-external-star-reexport/_expected/cjs.js @@ -1,12 +1,9 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - var external1 = require('external1'); var external2 = require('external2'); -function _interopNamespace(e) { - if (e && e.__esModule) return e; +function _interopNamespaceDefault(e) { var n = Object.create(null); if (e) { Object.keys(e).forEach(function (k) { @@ -14,32 +11,48 @@ function _interopNamespace(e) { var d = Object.getOwnPropertyDescriptor(e, k); Object.defineProperty(n, k, d.get ? d : { enumerable: true, - get: function () { - return e[k]; - } + get: function () { return e[k]; } }); } }); } - n['default'] = e; + n.default = e; + return Object.freeze(n); +} + +function _mergeNamespaces(n, m) { + m.forEach(function (e) { + e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) { + if (k !== 'default' && !(k in n)) { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + }); return Object.freeze(n); } -var external1__namespace = /*#__PURE__*/_interopNamespace(external1); -var external2__namespace = /*#__PURE__*/_interopNamespace(external2); +var external1__namespace = /*#__PURE__*/_interopNamespaceDefault(external1); +var external2__namespace = /*#__PURE__*/_interopNamespaceDefault(external2); -var reexportExternal = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.assign(/*#__PURE__*/Object.create(null), external1__namespace)); +var reexportExternal = /*#__PURE__*/_mergeNamespaces({ + __proto__: null +}, [external1__namespace]); const extra = 'extra'; const override = 'override'; var reexportExternalsWithOverride = { synthetic: 'synthetic' }; -var reexportExternalsWithOverride$1 = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.assign(/*#__PURE__*/Object.create(null), external1__namespace, external2__namespace, reexportExternalsWithOverride, { - override: override, - 'default': reexportExternalsWithOverride, - extra: extra -})); +var reexportExternalsWithOverride$1 = /*#__PURE__*/_mergeNamespaces({ + __proto__: null, + default: reexportExternalsWithOverride, + extra: extra, + override: override +}, [reexportExternalsWithOverride, external1__namespace, external2__namespace]); exports.external = reexportExternal; exports.externalOverride = reexportExternalsWithOverride$1; diff --git a/test/form/samples/ns-external-star-reexport/_expected/es.js b/test/form/samples/ns-external-star-reexport/_expected/es.js index ed3032da5ac..6b69dce45ac 100644 --- a/test/form/samples/ns-external-star-reexport/_expected/es.js +++ b/test/form/samples/ns-external-star-reexport/_expected/es.js @@ -1,17 +1,35 @@ import * as external1 from 'external1'; import * as external2 from 'external2'; -var reexportExternal = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.assign(/*#__PURE__*/Object.create(null), external1)); +function _mergeNamespaces(n, m) { + m.forEach(function (e) { + e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) { + if (k !== 'default' && !(k in n)) { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + }); + return Object.freeze(n); +} + +var reexportExternal = /*#__PURE__*/_mergeNamespaces({ + __proto__: null +}, [external1]); const extra = 'extra'; const override = 'override'; var reexportExternalsWithOverride = { synthetic: 'synthetic' }; -var reexportExternalsWithOverride$1 = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.assign(/*#__PURE__*/Object.create(null), external1, external2, reexportExternalsWithOverride, { - override: override, - 'default': reexportExternalsWithOverride, - extra: extra -})); +var reexportExternalsWithOverride$1 = /*#__PURE__*/_mergeNamespaces({ + __proto__: null, + default: reexportExternalsWithOverride, + extra: extra, + override: override +}, [reexportExternalsWithOverride, external1, external2]); export { reexportExternal as external, reexportExternalsWithOverride$1 as externalOverride }; diff --git a/test/form/samples/ns-external-star-reexport/_expected/iife.js b/test/form/samples/ns-external-star-reexport/_expected/iife.js index d1dd7978230..14c4c8d1c90 100644 --- a/test/form/samples/ns-external-star-reexport/_expected/iife.js +++ b/test/form/samples/ns-external-star-reexport/_expected/iife.js @@ -1,8 +1,7 @@ var bundle = (function (exports, external1, external2) { 'use strict'; - function _interopNamespace(e) { - if (e && e.__esModule) return e; + function _interopNamespaceDefault(e) { var n = Object.create(null); if (e) { Object.keys(e).forEach(function (k) { @@ -10,38 +9,52 @@ var bundle = (function (exports, external1, external2) { var d = Object.getOwnPropertyDescriptor(e, k); Object.defineProperty(n, k, d.get ? d : { enumerable: true, - get: function () { - return e[k]; - } + get: function () { return e[k]; } }); } }); } - n['default'] = e; + n.default = e; return Object.freeze(n); } - var external1__namespace = /*#__PURE__*/_interopNamespace(external1); - var external2__namespace = /*#__PURE__*/_interopNamespace(external2); + function _mergeNamespaces(n, m) { + m.forEach(function (e) { + e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) { + if (k !== 'default' && !(k in n)) { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + }); + return Object.freeze(n); + } - var reexportExternal = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.assign(/*#__PURE__*/Object.create(null), external1__namespace)); + var external1__namespace = /*#__PURE__*/_interopNamespaceDefault(external1); + var external2__namespace = /*#__PURE__*/_interopNamespaceDefault(external2); + + var reexportExternal = /*#__PURE__*/_mergeNamespaces({ + __proto__: null + }, [external1__namespace]); const extra = 'extra'; const override = 'override'; var reexportExternalsWithOverride = { synthetic: 'synthetic' }; - var reexportExternalsWithOverride$1 = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.assign(/*#__PURE__*/Object.create(null), external1__namespace, external2__namespace, reexportExternalsWithOverride, { - override: override, - 'default': reexportExternalsWithOverride, - extra: extra - })); + var reexportExternalsWithOverride$1 = /*#__PURE__*/_mergeNamespaces({ + __proto__: null, + default: reexportExternalsWithOverride, + extra: extra, + override: override + }, [reexportExternalsWithOverride, external1__namespace, external2__namespace]); exports.external = reexportExternal; exports.externalOverride = reexportExternalsWithOverride$1; - Object.defineProperty(exports, '__esModule', { value: true }); - return exports; -}({}, external1, external2)); +})({}, external1, external2); diff --git a/test/form/samples/ns-external-star-reexport/_expected/system.js b/test/form/samples/ns-external-star-reexport/_expected/system.js index 6ad689bd7a8..80807779204 100644 --- a/test/form/samples/ns-external-star-reexport/_expected/system.js +++ b/test/form/samples/ns-external-star-reexport/_expected/system.js @@ -1,4 +1,4 @@ -System.register('bundle', ['external1', 'external2'], function (exports) { +System.register('bundle', ['external1', 'external2'], (function (exports) { 'use strict'; var external1, external2; return { @@ -7,23 +7,41 @@ System.register('bundle', ['external1', 'external2'], function (exports) { }, function (module) { external2 = module; }], - execute: function () { + execute: (function () { - var reexportExternal = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.assign(/*#__PURE__*/Object.create(null), external1)); - exports('external', reexportExternal); + function _mergeNamespaces(n, m) { + m.forEach(function (e) { + e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) { + if (k !== 'default' && !(k in n)) { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + }); + return Object.freeze(n); + } + + var reexportExternal = /*#__PURE__*/_mergeNamespaces({ + __proto__: null + }, [external1]); + exports("external", reexportExternal); const extra = 'extra'; const override = 'override'; var reexportExternalsWithOverride = { synthetic: 'synthetic' }; - var reexportExternalsWithOverride$1 = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.assign(/*#__PURE__*/Object.create(null), external1, external2, reexportExternalsWithOverride, { - override: override, - 'default': reexportExternalsWithOverride, - extra: extra - })); - exports('externalOverride', reexportExternalsWithOverride$1); + var reexportExternalsWithOverride$1 = /*#__PURE__*/_mergeNamespaces({ + __proto__: null, + default: reexportExternalsWithOverride, + extra: extra, + override: override + }, [reexportExternalsWithOverride, external1, external2]); + exports("externalOverride", reexportExternalsWithOverride$1); - } + }) }; -}); +})); diff --git a/test/form/samples/ns-external-star-reexport/_expected/umd.js b/test/form/samples/ns-external-star-reexport/_expected/umd.js index 75662d134f8..420ca3487ac 100644 --- a/test/form/samples/ns-external-star-reexport/_expected/umd.js +++ b/test/form/samples/ns-external-star-reexport/_expected/umd.js @@ -2,10 +2,9 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('external1'), require('external2')) : typeof define === 'function' && define.amd ? define(['exports', 'external1', 'external2'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.bundle = {}, global.external1, global.external2)); -}(this, (function (exports, external1, external2) { 'use strict'; +})(this, (function (exports, external1, external2) { 'use strict'; - function _interopNamespace(e) { - if (e && e.__esModule) return e; + function _interopNamespaceDefault(e) { var n = Object.create(null); if (e) { Object.keys(e).forEach(function (k) { @@ -13,36 +12,50 @@ var d = Object.getOwnPropertyDescriptor(e, k); Object.defineProperty(n, k, d.get ? d : { enumerable: true, - get: function () { - return e[k]; - } + get: function () { return e[k]; } }); } }); } - n['default'] = e; + n.default = e; return Object.freeze(n); } - var external1__namespace = /*#__PURE__*/_interopNamespace(external1); - var external2__namespace = /*#__PURE__*/_interopNamespace(external2); + function _mergeNamespaces(n, m) { + m.forEach(function (e) { + e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) { + if (k !== 'default' && !(k in n)) { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + }); + return Object.freeze(n); + } - var reexportExternal = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.assign(/*#__PURE__*/Object.create(null), external1__namespace)); + var external1__namespace = /*#__PURE__*/_interopNamespaceDefault(external1); + var external2__namespace = /*#__PURE__*/_interopNamespaceDefault(external2); + + var reexportExternal = /*#__PURE__*/_mergeNamespaces({ + __proto__: null + }, [external1__namespace]); const extra = 'extra'; const override = 'override'; var reexportExternalsWithOverride = { synthetic: 'synthetic' }; - var reexportExternalsWithOverride$1 = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.assign(/*#__PURE__*/Object.create(null), external1__namespace, external2__namespace, reexportExternalsWithOverride, { - override: override, - 'default': reexportExternalsWithOverride, - extra: extra - })); + var reexportExternalsWithOverride$1 = /*#__PURE__*/_mergeNamespaces({ + __proto__: null, + default: reexportExternalsWithOverride, + extra: extra, + override: override + }, [reexportExternalsWithOverride, external1__namespace, external2__namespace]); exports.external = reexportExternal; exports.externalOverride = reexportExternalsWithOverride$1; - Object.defineProperty(exports, '__esModule', { value: true }); - -}))); +})); diff --git a/test/form/samples/nullish-coalescing/_config.js b/test/form/samples/nullish-coalescing/_config.js index 0999be29d39..e5e84bbdbc1 100644 --- a/test/form/samples/nullish-coalescing/_config.js +++ b/test/form/samples/nullish-coalescing/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'supports tree-shaking with nullish-coalescing' -}; +}); diff --git a/test/form/samples/nullish-coalescing/_expected.js b/test/form/samples/nullish-coalescing/_expected.js index 16ea2b26039..e1465d60c73 100644 --- a/test/form/samples/nullish-coalescing/_expected.js +++ b/test/form/samples/nullish-coalescing/_expected.js @@ -5,9 +5,9 @@ function getNullSideEffect() { console.log('null'); console.log('undefined'); -console.log(0 ); -console.log('' ); -console.log('Hello' ); +console.log(0); +console.log(''); +console.log('Hello'); console.log('null return'); console.log(getNullSideEffect() ?? 'null return with side-effect'); diff --git a/test/form/samples/numeric_separators/_config.js b/test/form/samples/numeric_separators/_config.js index 1809c1b9e07..35361d09a58 100644 --- a/test/form/samples/numeric_separators/_config.js +++ b/test/form/samples/numeric_separators/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'supports numeric separators' -}; +}); diff --git a/test/form/samples/object-define-property/_config.js b/test/form/samples/object-define-property/_config.js new file mode 100644 index 00000000000..db74095ed16 --- /dev/null +++ b/test/form/samples/object-define-property/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'allows globals to have parameter mutation side effects' +}); diff --git a/test/form/samples/object-define-property/_expected.js b/test/form/samples/object-define-property/_expected.js new file mode 100644 index 00000000000..58141e185ae --- /dev/null +++ b/test/form/samples/object-define-property/_expected.js @@ -0,0 +1,7 @@ +const retained1 = {}; +Object.defineProperty(retained1, 'foo', { value: true }); +console.log(retained1); + +const retained2 = {}; +Object.defineProperties(retained2, { bar: { value: true } }); +console.log(retained2); diff --git a/test/form/samples/object-define-property/main.js b/test/form/samples/object-define-property/main.js new file mode 100644 index 00000000000..ee9e5d9df05 --- /dev/null +++ b/test/form/samples/object-define-property/main.js @@ -0,0 +1,23 @@ +const removed = {}; +Object.defineProperty(removed, 'foo', { value: true }); +Object.defineProperties(removed, { bar: { value: true } }); + +const retained1 = {}; +Object.defineProperty(retained1, 'foo', { value: true }); +console.log(retained1); + +const retained2 = {}; +Object.defineProperties(retained2, { bar: { value: true } }); +console.log(retained2); + +const removed2 = []; +Object.defineProperty(removed2, 'foo', { value: true }); + +class removed3 {} +Object.defineProperty(removed3, 'foo', { value: true }); + +function removed4() {} +Object.defineProperty(removed4, 'foo', { value: true }); + +const removed5 = () => {}; +Object.defineProperty(removed5, 'foo', { value: true }); diff --git a/test/form/samples/object-destructuring-default-values/_config.js b/test/form/samples/object-destructuring-default-values/_config.js index c4ccc90db14..2ccf86cc27a 100644 --- a/test/form/samples/object-destructuring-default-values/_config.js +++ b/test/form/samples/object-destructuring-default-values/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'object destructuring default values are preserved' -}; +}); diff --git a/test/form/samples/object-destructuring-default-values/_expected/amd.js b/test/form/samples/object-destructuring-default-values/_expected/amd.js index 257a7650a63..9dd56462518 100644 --- a/test/form/samples/object-destructuring-default-values/_expected/amd.js +++ b/test/form/samples/object-destructuring-default-values/_expected/amd.js @@ -1,4 +1,4 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; const a = 1; const b = 2; @@ -6,4 +6,4 @@ define(function () { 'use strict'; const [ d = b ] = []; console.log(c, d); -}); +})); diff --git a/test/form/samples/object-destructuring-default-values/_expected/iife.js b/test/form/samples/object-destructuring-default-values/_expected/iife.js index 6923ccc809a..f2724d6b580 100644 --- a/test/form/samples/object-destructuring-default-values/_expected/iife.js +++ b/test/form/samples/object-destructuring-default-values/_expected/iife.js @@ -7,4 +7,4 @@ const [ d = b ] = []; console.log(c, d); -}()); +})(); diff --git a/test/form/samples/object-destructuring-default-values/_expected/system.js b/test/form/samples/object-destructuring-default-values/_expected/system.js index e5b25902b2a..7e70f0756c6 100644 --- a/test/form/samples/object-destructuring-default-values/_expected/system.js +++ b/test/form/samples/object-destructuring-default-values/_expected/system.js @@ -1,7 +1,7 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { const a = 1; const b = 2; @@ -9,6 +9,6 @@ System.register([], function () { const [ d = b ] = []; console.log(c, d); - } + }) }; -}); +})); diff --git a/test/form/samples/object-destructuring-default-values/_expected/umd.js b/test/form/samples/object-destructuring-default-values/_expected/umd.js index 6895039f945..00fa496471b 100644 --- a/test/form/samples/object-destructuring-default-values/_expected/umd.js +++ b/test/form/samples/object-destructuring-default-values/_expected/umd.js @@ -1,7 +1,7 @@ (function (factory) { typeof define === 'function' && define.amd ? define(factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; const a = 1; const b = 2; @@ -9,4 +9,4 @@ const [ d = b ] = []; console.log(c, d); -}))); +})); diff --git a/test/form/samples/object-expression-treeshaking/ignore-property-read-side-effects/_config.js b/test/form/samples/object-expression-treeshaking/ignore-property-read-side-effects/_config.js new file mode 100644 index 00000000000..2871b74fd01 --- /dev/null +++ b/test/form/samples/object-expression-treeshaking/ignore-property-read-side-effects/_config.js @@ -0,0 +1,4 @@ +module.exports = defineTest({ + description: 'ignores property read side effects via option', + options: { treeshake: { propertyReadSideEffects: false } } +}); diff --git a/test/form/samples/object-expression-treeshaking/ignore-property-read-side-effects/_expected.js b/test/form/samples/object-expression-treeshaking/ignore-property-read-side-effects/_expected.js new file mode 100644 index 00000000000..59b5fe8e2e5 --- /dev/null +++ b/test/form/samples/object-expression-treeshaking/ignore-property-read-side-effects/_expected.js @@ -0,0 +1,4 @@ +const { a} = { + a: true}; + +console.log(a.b); diff --git a/test/form/samples/object-expression-treeshaking/ignore-property-read-side-effects/main.js b/test/form/samples/object-expression-treeshaking/ignore-property-read-side-effects/main.js new file mode 100644 index 00000000000..2a5bf6c92e8 --- /dev/null +++ b/test/form/samples/object-expression-treeshaking/ignore-property-read-side-effects/main.js @@ -0,0 +1,8 @@ +const { a, b } = { + a: true, + get b() { + console.log('effect'); + } +}; + +console.log(a.b); diff --git a/test/form/samples/object-expression-treeshaking/only-include-destructured-parameter-props/_config.js b/test/form/samples/object-expression-treeshaking/only-include-destructured-parameter-props/_config.js new file mode 100644 index 00000000000..a9129d7fb64 --- /dev/null +++ b/test/form/samples/object-expression-treeshaking/only-include-destructured-parameter-props/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'only includes destructured parameter props' +}); diff --git a/test/form/samples/object-expression-treeshaking/only-include-destructured-parameter-props/_expected.js b/test/form/samples/object-expression-treeshaking/only-include-destructured-parameter-props/_expected.js new file mode 100644 index 00000000000..b822667d2ff --- /dev/null +++ b/test/form/samples/object-expression-treeshaking/only-include-destructured-parameter-props/_expected.js @@ -0,0 +1,7 @@ +function test({ a, d: { e } }) { + console.log(a, e); +} + +test({ + a: { b: 1, c: 2 }, + d: { e: 4}}); diff --git a/test/form/samples/object-expression-treeshaking/only-include-destructured-parameter-props/main.js b/test/form/samples/object-expression-treeshaking/only-include-destructured-parameter-props/main.js new file mode 100644 index 00000000000..d7e782dbd5a --- /dev/null +++ b/test/form/samples/object-expression-treeshaking/only-include-destructured-parameter-props/main.js @@ -0,0 +1,9 @@ +function test({ a, d: { e } }) { + console.log(a, e); +} + +test({ + a: { b: 1, c: 2 }, + d: { e: 4, f: 5 }, + g: 6 +}); diff --git a/test/form/samples/object-expression-treeshaking/preserve-unknown-wellknown/_config.js b/test/form/samples/object-expression-treeshaking/preserve-unknown-wellknown/_config.js new file mode 100644 index 00000000000..6571968b135 --- /dev/null +++ b/test/form/samples/object-expression-treeshaking/preserve-unknown-wellknown/_config.js @@ -0,0 +1,4 @@ +module.exports = defineTest({ + description: + 'always preserves well-known properties from objects if Rollup does not know about them' +}); diff --git a/test/form/samples/object-expression-treeshaking/preserve-unknown-wellknown/_expected.js b/test/form/samples/object-expression-treeshaking/preserve-unknown-wellknown/_expected.js new file mode 100644 index 00000000000..674654b7b44 --- /dev/null +++ b/test/form/samples/object-expression-treeshaking/preserve-unknown-wellknown/_expected.js @@ -0,0 +1,5 @@ +const obj1 = { + [Symbol.wellKnownThatMightHaveBeenIntroducedInNewerVersionsOfECMAScript]: true, + z: 1, +}; +console.log(obj1.z); diff --git a/test/form/samples/object-expression-treeshaking/preserve-unknown-wellknown/main.js b/test/form/samples/object-expression-treeshaking/preserve-unknown-wellknown/main.js new file mode 100644 index 00000000000..fd35d4dd28d --- /dev/null +++ b/test/form/samples/object-expression-treeshaking/preserve-unknown-wellknown/main.js @@ -0,0 +1,6 @@ +const obj1 = { + [Symbol.wellKnownThatMightHaveBeenIntroducedInNewerVersionsOfECMAScript]: true, + zz: 1, + z: 1, +}; +console.log(obj1.z); diff --git a/test/form/samples/object-expression-treeshaking/remove-props-via-destructuring/_config.js b/test/form/samples/object-expression-treeshaking/remove-props-via-destructuring/_config.js new file mode 100644 index 00000000000..c25c9638e99 --- /dev/null +++ b/test/form/samples/object-expression-treeshaking/remove-props-via-destructuring/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'removes unused nested properties through destructuring declarations' +}); diff --git a/test/form/samples/object-expression-treeshaking/remove-props-via-destructuring/_expected.js b/test/form/samples/object-expression-treeshaking/remove-props-via-destructuring/_expected.js new file mode 100644 index 00000000000..48ef3c76dbd --- /dev/null +++ b/test/form/samples/object-expression-treeshaking/remove-props-via-destructuring/_expected.js @@ -0,0 +1,9 @@ +const { + a: { b } +} = { a: { b: { c: 1}}}; +console.log(b.c); + +const { + a: { ...rest } +} = { a: { b: { c: 1, d: 1 }, e: 1 }}; +console.log(rest); diff --git a/test/form/samples/object-expression-treeshaking/remove-props-via-destructuring/main.js b/test/form/samples/object-expression-treeshaking/remove-props-via-destructuring/main.js new file mode 100644 index 00000000000..5c07932ed4a --- /dev/null +++ b/test/form/samples/object-expression-treeshaking/remove-props-via-destructuring/main.js @@ -0,0 +1,12 @@ +const { + a: { b } +} = { a: { b: { c: 1, d: 1 }, e: 1 }, f: 1 }; +console.log(b.c); + +const { + a: { ...rest } +} = { a: { b: { c: 1, d: 1 }, e: 1 }, f: 1 }; +console.log(rest); + +// for improving test coverage +const {} = { a: { b: { c: 1, d: 1 }, e: 1 }, f: 1 }; diff --git a/test/form/samples/object-expression-treeshaking/remove-unused-nested-props/_config.js b/test/form/samples/object-expression-treeshaking/remove-unused-nested-props/_config.js new file mode 100644 index 00000000000..b0f0e703a50 --- /dev/null +++ b/test/form/samples/object-expression-treeshaking/remove-unused-nested-props/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'removes unused nested properties' +}); diff --git a/test/form/samples/object-expression-treeshaking/remove-unused-nested-props/_expected.js b/test/form/samples/object-expression-treeshaking/remove-unused-nested-props/_expected.js new file mode 100644 index 00000000000..a87f92cf005 --- /dev/null +++ b/test/form/samples/object-expression-treeshaking/remove-unused-nested-props/_expected.js @@ -0,0 +1,2 @@ +const obj = { y: { a: 1} }; +console.log(obj.y.a); diff --git a/test/form/samples/object-expression-treeshaking/remove-unused-nested-props/main.js b/test/form/samples/object-expression-treeshaking/remove-unused-nested-props/main.js new file mode 100644 index 00000000000..1a46a5cf649 --- /dev/null +++ b/test/form/samples/object-expression-treeshaking/remove-unused-nested-props/main.js @@ -0,0 +1,2 @@ +const obj = { x: 1, y: { a: 1, b: 2 } }; +console.log(obj.y.a); diff --git a/test/form/samples/object-expression-treeshaking/remove-unused-parameter-props-external-call/_config.js b/test/form/samples/object-expression-treeshaking/remove-unused-parameter-props-external-call/_config.js new file mode 100644 index 00000000000..780dd0a5068 --- /dev/null +++ b/test/form/samples/object-expression-treeshaking/remove-unused-parameter-props-external-call/_config.js @@ -0,0 +1,4 @@ +module.exports = defineTest({ + description: + 'removes props that are not used in a function when part of the parameter is passed to an external function' +}); diff --git a/test/form/samples/object-expression-treeshaking/remove-unused-parameter-props-external-call/_expected.js b/test/form/samples/object-expression-treeshaking/remove-unused-parameter-props-external-call/_expected.js new file mode 100644 index 00000000000..7e3e405c4ad --- /dev/null +++ b/test/form/samples/object-expression-treeshaking/remove-unused-parameter-props-external-call/_expected.js @@ -0,0 +1,6 @@ +function test(obj) { + externalFunc(obj.a); +} + +test({ + a: { b: 1, c: 2 }}); diff --git a/test/form/samples/object-expression-treeshaking/remove-unused-parameter-props-external-call/main.js b/test/form/samples/object-expression-treeshaking/remove-unused-parameter-props-external-call/main.js new file mode 100644 index 00000000000..4f29aed21b4 --- /dev/null +++ b/test/form/samples/object-expression-treeshaking/remove-unused-parameter-props-external-call/main.js @@ -0,0 +1,8 @@ +function test(obj) { + externalFunc(obj.a); +} + +test({ + a: { b: 1, c: 2 }, + d: { e: 4, f: 5 } +}); diff --git a/test/form/samples/object-expression-treeshaking/remove-unused-parameter-props/_config.js b/test/form/samples/object-expression-treeshaking/remove-unused-parameter-props/_config.js new file mode 100644 index 00000000000..8a144734955 --- /dev/null +++ b/test/form/samples/object-expression-treeshaking/remove-unused-parameter-props/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'removes props that are not used in a function' +}); diff --git a/test/form/samples/object-expression-treeshaking/remove-unused-parameter-props/_expected.js b/test/form/samples/object-expression-treeshaking/remove-unused-parameter-props/_expected.js new file mode 100644 index 00000000000..00e03a61dce --- /dev/null +++ b/test/form/samples/object-expression-treeshaking/remove-unused-parameter-props/_expected.js @@ -0,0 +1,18 @@ +function test1(obj) { + return [obj.a, obj.d.e]; +} + +console.log( + test1({ + a: { b: 1, c: 2 }, + d: { e: 4, f: 5 }}) +); + +function test2(obj) { + console.log(obj.a); + console.log(obj.d.e); +} + +test2({ + a: { b: 1, c: 2 }, + d: { e: 4, f: 5 }}); diff --git a/test/form/samples/object-expression-treeshaking/remove-unused-parameter-props/main.js b/test/form/samples/object-expression-treeshaking/remove-unused-parameter-props/main.js new file mode 100644 index 00000000000..3c381fe9637 --- /dev/null +++ b/test/form/samples/object-expression-treeshaking/remove-unused-parameter-props/main.js @@ -0,0 +1,22 @@ +function test1(obj) { + return [obj.a, obj.d.e]; +} + +console.log( + test1({ + a: { b: 1, c: 2 }, + d: { e: 4, f: 5 }, + g: 6 + }) +); + +function test2(obj) { + console.log(obj.a); + console.log(obj.d.e); +} + +test2({ + a: { b: 1, c: 2 }, + d: { e: 4, f: 5 }, + g: 6 +}); diff --git a/test/form/samples/object-expression-treeshaking/remove-unused-props/_config.js b/test/form/samples/object-expression-treeshaking/remove-unused-props/_config.js new file mode 100644 index 00000000000..efeec207d65 --- /dev/null +++ b/test/form/samples/object-expression-treeshaking/remove-unused-props/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'removes unused object properties' +}); diff --git a/test/form/samples/object-expression-treeshaking/remove-unused-props/_expected.js b/test/form/samples/object-expression-treeshaking/remove-unused-props/_expected.js new file mode 100644 index 00000000000..f730158871d --- /dev/null +++ b/test/form/samples/object-expression-treeshaking/remove-unused-props/_expected.js @@ -0,0 +1,5 @@ +const obj1 = { x: 1}; +const obj2 = { y: { a: 1, b: 2 } }; +const obj3 = { y: { a: 1} }; +const obj4 = { }; +console.log(obj1.x, obj2.y, obj3.y.a, obj4.z); diff --git a/test/form/samples/object-expression-treeshaking/remove-unused-props/main.js b/test/form/samples/object-expression-treeshaking/remove-unused-props/main.js new file mode 100644 index 00000000000..3b2940aaa76 --- /dev/null +++ b/test/form/samples/object-expression-treeshaking/remove-unused-props/main.js @@ -0,0 +1,5 @@ +const obj1 = { x: 1, y: { a: 1, b: 2 } }; +const obj2 = { x: 1, y: { a: 1, b: 2 } }; +const obj3 = { x: 1, y: { a: 1, b: 2 } }; +const obj4 = { x: 1, y: { a: 1, b: 2 } }; +console.log(obj1.x, obj2.y, obj3.y.a, obj4.z); diff --git a/test/form/samples/object-expression-treeshaking/remove-unused-wellknown-hasInstance/_config.js b/test/form/samples/object-expression-treeshaking/remove-unused-wellknown-hasInstance/_config.js new file mode 100644 index 00000000000..45dc3b49bad --- /dev/null +++ b/test/form/samples/object-expression-treeshaking/remove-unused-wellknown-hasInstance/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'removes unused Symbol.hasInstance from objects' +}); diff --git a/test/form/samples/object-expression-treeshaking/remove-unused-wellknown-hasInstance/_expected.js b/test/form/samples/object-expression-treeshaking/remove-unused-wellknown-hasInstance/_expected.js new file mode 100644 index 00000000000..cde6ee22780 --- /dev/null +++ b/test/form/samples/object-expression-treeshaking/remove-unused-wellknown-hasInstance/_expected.js @@ -0,0 +1,3 @@ +const obj1 = { [Symbol.hasInstance]: () => true }; +const obj2 = { }; +console.log(null instanceof obj1, obj2.z); diff --git a/test/form/samples/object-expression-treeshaking/remove-unused-wellknown-hasInstance/main.js b/test/form/samples/object-expression-treeshaking/remove-unused-wellknown-hasInstance/main.js new file mode 100644 index 00000000000..b9723392fdd --- /dev/null +++ b/test/form/samples/object-expression-treeshaking/remove-unused-wellknown-hasInstance/main.js @@ -0,0 +1,3 @@ +const obj1 = { [Symbol.hasInstance]: () => true }; +const obj2 = { [Symbol.hasInstance]: () => true }; +console.log(null instanceof obj1, obj2.z); diff --git a/test/form/samples/object-expression-treeshaking/track-through-chain-expressions/_config.js b/test/form/samples/object-expression-treeshaking/track-through-chain-expressions/_config.js new file mode 100644 index 00000000000..ac6cebc360a --- /dev/null +++ b/test/form/samples/object-expression-treeshaking/track-through-chain-expressions/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'tracks property access through optional chains' +}); diff --git a/test/form/samples/object-expression-treeshaking/track-through-chain-expressions/_expected.js b/test/form/samples/object-expression-treeshaking/track-through-chain-expressions/_expected.js new file mode 100644 index 00000000000..642bd2e3d1b --- /dev/null +++ b/test/form/samples/object-expression-treeshaking/track-through-chain-expressions/_expected.js @@ -0,0 +1,3 @@ +const a = { b: { c: 1}}; +const b = a?.b; +console.log(b?.c); diff --git a/test/form/samples/object-expression-treeshaking/track-through-chain-expressions/main.js b/test/form/samples/object-expression-treeshaking/track-through-chain-expressions/main.js new file mode 100644 index 00000000000..bbbc0e5f09b --- /dev/null +++ b/test/form/samples/object-expression-treeshaking/track-through-chain-expressions/main.js @@ -0,0 +1,3 @@ +const a = { b: { c: 1, removed: true }, removed: true }; +const b = a?.b; +console.log(b?.c); diff --git a/test/form/samples/object-expression-treeshaking/tree-shake-jsx-namespace/_config.js b/test/form/samples/object-expression-treeshaking/tree-shake-jsx-namespace/_config.js new file mode 100644 index 00000000000..2c211e43c55 --- /dev/null +++ b/test/form/samples/object-expression-treeshaking/tree-shake-jsx-namespace/_config.js @@ -0,0 +1,4 @@ +module.exports = defineTest({ + description: 'tree-shakes unused properties of JSX namespaces', + options: { jsx: 'preserve' } +}); diff --git a/test/form/samples/object-expression-treeshaking/tree-shake-jsx-namespace/_expected.js b/test/form/samples/object-expression-treeshaking/tree-shake-jsx-namespace/_expected.js new file mode 100644 index 00000000000..00696f749a5 --- /dev/null +++ b/test/form/samples/object-expression-treeshaking/tree-shake-jsx-namespace/_expected.js @@ -0,0 +1,7 @@ +const ns = { + Bar: () => null +}; + +const a = ; + +export { a }; diff --git a/test/form/samples/object-expression-treeshaking/tree-shake-jsx-namespace/main.js b/test/form/samples/object-expression-treeshaking/tree-shake-jsx-namespace/main.js new file mode 100644 index 00000000000..0fbcaca66d9 --- /dev/null +++ b/test/form/samples/object-expression-treeshaking/tree-shake-jsx-namespace/main.js @@ -0,0 +1,6 @@ +const ns = { + Foo: () => null, + Bar: () => null +} + +export const a = diff --git a/test/form/samples/object-expression/computed-properties/_config.js b/test/form/samples/object-expression/computed-properties/_config.js index e306359eb2b..9d89548d6b2 100644 --- a/test/form/samples/object-expression/computed-properties/_config.js +++ b/test/form/samples/object-expression/computed-properties/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'Associates non-string keys with string keys' -}; +}); diff --git a/test/form/samples/object-expression/method-side-effects/_config.js b/test/form/samples/object-expression/method-side-effects/_config.js index efbb2502435..d6c47c7a8e4 100644 --- a/test/form/samples/object-expression/method-side-effects/_config.js +++ b/test/form/samples/object-expression/method-side-effects/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'Track side-effects of method calls' -}; +}); diff --git a/test/form/samples/object-expression/nested-literal-assignment-without-access-side-effect/_config.js b/test/form/samples/object-expression/nested-literal-assignment-without-access-side-effect/_config.js new file mode 100644 index 00000000000..48a69f2f7c3 --- /dev/null +++ b/test/form/samples/object-expression/nested-literal-assignment-without-access-side-effect/_config.js @@ -0,0 +1,6 @@ +module.exports = defineTest({ + description: 'treats mutating nested properties as side effects', + options: { + treeshake: { propertyReadSideEffects: false } + } +}); diff --git a/test/form/samples/object-expression/nested-literal-assignment-without-access-side-effect/_expected.js b/test/form/samples/object-expression/nested-literal-assignment-without-access-side-effect/_expected.js new file mode 100644 index 00000000000..a1aec95dee4 --- /dev/null +++ b/test/form/samples/object-expression/nested-literal-assignment-without-access-side-effect/_expected.js @@ -0,0 +1,3 @@ +const obj = { __proto__: null }; + +obj.foo.bar = 'retained'; diff --git a/test/form/samples/object-expression/nested-literal-assignment-without-access-side-effect/main.js b/test/form/samples/object-expression/nested-literal-assignment-without-access-side-effect/main.js new file mode 100644 index 00000000000..a1aec95dee4 --- /dev/null +++ b/test/form/samples/object-expression/nested-literal-assignment-without-access-side-effect/main.js @@ -0,0 +1,3 @@ +const obj = { __proto__: null }; + +obj.foo.bar = 'retained'; diff --git a/test/form/samples/object-expression/nested-literal-value-without-access-side-effect/_config.js b/test/form/samples/object-expression/nested-literal-value-without-access-side-effect/_config.js new file mode 100644 index 00000000000..fb7f8e68d4e --- /dev/null +++ b/test/form/samples/object-expression/nested-literal-value-without-access-side-effect/_config.js @@ -0,0 +1,6 @@ +module.exports = defineTest({ + description: 'uses an unknown value for nested properties', + options: { + treeshake: { propertyReadSideEffects: false } + } +}); diff --git a/test/form/samples/object-expression/nested-literal-value-without-access-side-effect/_expected.js b/test/form/samples/object-expression/nested-literal-value-without-access-side-effect/_expected.js new file mode 100644 index 00000000000..b80a0b6731d --- /dev/null +++ b/test/form/samples/object-expression/nested-literal-value-without-access-side-effect/_expected.js @@ -0,0 +1,5 @@ +const obj = { __proto__: null }; + +if (obj.foo.bar) { + console.log('retained'); +} diff --git a/test/form/samples/object-expression/nested-literal-value-without-access-side-effect/main.js b/test/form/samples/object-expression/nested-literal-value-without-access-side-effect/main.js new file mode 100644 index 00000000000..b80a0b6731d --- /dev/null +++ b/test/form/samples/object-expression/nested-literal-value-without-access-side-effect/main.js @@ -0,0 +1,5 @@ +const obj = { __proto__: null }; + +if (obj.foo.bar) { + console.log('retained'); +} diff --git a/test/form/samples/object-expression/proto-property/_config.js b/test/form/samples/object-expression/proto-property/_config.js index f70608e1109..6d30962f73e 100644 --- a/test/form/samples/object-expression/proto-property/_config.js +++ b/test/form/samples/object-expression/proto-property/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'Deoptimize when __proto__ is used' -}; +}); diff --git a/test/form/samples/object-expression/reassign-prop-without-proto/_config.js b/test/form/samples/object-expression/reassign-prop-without-proto/_config.js new file mode 100644 index 00000000000..131e3581fbf --- /dev/null +++ b/test/form/samples/object-expression/reassign-prop-without-proto/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'correctly deoptimizes when there is no proto' +}); diff --git a/test/form/samples/object-expression/reassign-prop-without-proto/_expected.js b/test/form/samples/object-expression/reassign-prop-without-proto/_expected.js new file mode 100644 index 00000000000..a9f8799ef48 --- /dev/null +++ b/test/form/samples/object-expression/reassign-prop-without-proto/_expected.js @@ -0,0 +1,7 @@ +const obj = { __proto__: null }; + +obj.flag = true; + +if (obj.flag) { + console.log('mutated'); +} diff --git a/test/form/samples/object-expression/reassign-prop-without-proto/main.js b/test/form/samples/object-expression/reassign-prop-without-proto/main.js new file mode 100644 index 00000000000..a9f8799ef48 --- /dev/null +++ b/test/form/samples/object-expression/reassign-prop-without-proto/main.js @@ -0,0 +1,7 @@ +const obj = { __proto__: null }; + +obj.flag = true; + +if (obj.flag) { + console.log('mutated'); +} diff --git a/test/form/samples/object-expression/return-expressions/_config.js b/test/form/samples/object-expression/return-expressions/_config.js index 8e3a8d7be88..0a0a701310f 100644 --- a/test/form/samples/object-expression/return-expressions/_config.js +++ b/test/form/samples/object-expression/return-expressions/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'Track side-effects of method return values' -}; +}); diff --git a/test/form/samples/object-expression/return-expressions/_expected.js b/test/form/samples/object-expression/return-expressions/_expected.js index 0405706b107..3538f6d9b82 100644 --- a/test/form/samples/object-expression/return-expressions/_expected.js +++ b/test/form/samples/object-expression/return-expressions/_expected.js @@ -12,8 +12,6 @@ const z = { z.a()(); const v = {}; - -v.toString().charCodeAt(0); // removed v.toString().doesNotExist(0); // retained const w = { diff --git a/test/form/samples/object-expression/unknown-getter-no-side-effect/_config.js b/test/form/samples/object-expression/unknown-getter-no-side-effect/_config.js new file mode 100644 index 00000000000..709d2882c58 --- /dev/null +++ b/test/form/samples/object-expression/unknown-getter-no-side-effect/_config.js @@ -0,0 +1,4 @@ +module.exports = defineTest({ + description: 'removes unknown getter access without side effect', + options: { external: ['external'] } +}); diff --git a/test/form/samples/object-expression/unknown-getter-no-side-effect/_expected.js b/test/form/samples/object-expression/unknown-getter-no-side-effect/_expected.js new file mode 100644 index 00000000000..b2bc48d5b02 --- /dev/null +++ b/test/form/samples/object-expression/unknown-getter-no-side-effect/_expected.js @@ -0,0 +1 @@ +import 'external'; diff --git a/test/form/samples/object-expression/unknown-getter-no-side-effect/main.js b/test/form/samples/object-expression/unknown-getter-no-side-effect/main.js new file mode 100644 index 00000000000..5942af957b4 --- /dev/null +++ b/test/form/samples/object-expression/unknown-getter-no-side-effect/main.js @@ -0,0 +1,7 @@ +import { unknown } from 'external'; + +const obj = { + get [unknown]() {} +}; + +obj.prop; diff --git a/test/form/samples/object-expression/unknown-setter-no-side-effect/_config.js b/test/form/samples/object-expression/unknown-setter-no-side-effect/_config.js new file mode 100644 index 00000000000..3fc7e1153f8 --- /dev/null +++ b/test/form/samples/object-expression/unknown-setter-no-side-effect/_config.js @@ -0,0 +1,4 @@ +module.exports = defineTest({ + description: 'removes unknown setter access without side effect', + options: { external: ['external'] } +}); diff --git a/test/form/samples/object-expression/unknown-setter-no-side-effect/_expected.js b/test/form/samples/object-expression/unknown-setter-no-side-effect/_expected.js new file mode 100644 index 00000000000..b2bc48d5b02 --- /dev/null +++ b/test/form/samples/object-expression/unknown-setter-no-side-effect/_expected.js @@ -0,0 +1 @@ +import 'external'; diff --git a/test/form/samples/object-expression/unknown-setter-no-side-effect/main.js b/test/form/samples/object-expression/unknown-setter-no-side-effect/main.js new file mode 100644 index 00000000000..c9042a7970e --- /dev/null +++ b/test/form/samples/object-expression/unknown-setter-no-side-effect/main.js @@ -0,0 +1,7 @@ +import { unknown } from 'external'; + +const obj = { + set [unknown](value) {} +}; + +obj.prop = true; diff --git a/test/form/samples/object-expression/unknown-setter-no-side-effect2/_config.js b/test/form/samples/object-expression/unknown-setter-no-side-effect2/_config.js new file mode 100644 index 00000000000..3fc7e1153f8 --- /dev/null +++ b/test/form/samples/object-expression/unknown-setter-no-side-effect2/_config.js @@ -0,0 +1,4 @@ +module.exports = defineTest({ + description: 'removes unknown setter access without side effect', + options: { external: ['external'] } +}); diff --git a/test/form/samples/object-expression/unknown-setter-no-side-effect2/_expected.js b/test/form/samples/object-expression/unknown-setter-no-side-effect2/_expected.js new file mode 100644 index 00000000000..bb9900f6dcc --- /dev/null +++ b/test/form/samples/object-expression/unknown-setter-no-side-effect2/_expected.js @@ -0,0 +1,9 @@ +import { unknown } from 'external'; + +const obj2 = { + set [unknown](value) { + console.log('effect'); + } +}; + +obj2[unknown] = true; diff --git a/test/form/samples/object-expression/unknown-setter-no-side-effect2/main.js b/test/form/samples/object-expression/unknown-setter-no-side-effect2/main.js new file mode 100644 index 00000000000..5a8c4863ad1 --- /dev/null +++ b/test/form/samples/object-expression/unknown-setter-no-side-effect2/main.js @@ -0,0 +1,15 @@ +import { unknown } from 'external'; + +const obj = { + set [unknown](value) {} +}; + +obj[unknown] = true; + +const obj2 = { + set [unknown](value) { + console.log('effect'); + } +}; + +obj2[unknown] = true; diff --git a/test/form/samples/object-freeze-effects/_config.js b/test/form/samples/object-freeze-effects/_config.js new file mode 100644 index 00000000000..ffcabf6b9c8 --- /dev/null +++ b/test/form/samples/object-freeze-effects/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'Only treats Object.freeze as a side effect if the argument is used' +}); diff --git a/test/form/samples/object-freeze-effects/_expected.js b/test/form/samples/object-freeze-effects/_expected.js new file mode 100644 index 00000000000..32378bba82b --- /dev/null +++ b/test/form/samples/object-freeze-effects/_expected.js @@ -0,0 +1,6 @@ +const b = Object.freeze({ foo: 'bar' }); +console.log(b); + +const c = { foo: 'bar' }; +Object.freeze(c); // retained +console.log(c); diff --git a/test/form/samples/object-freeze-effects/main.js b/test/form/samples/object-freeze-effects/main.js new file mode 100644 index 00000000000..023a4fd5dfc --- /dev/null +++ b/test/form/samples/object-freeze-effects/main.js @@ -0,0 +1,11 @@ +Object.freeze({ foo: 'bar' }); // removed + +const a = { foo: 'bar' }; // removed +Object.freeze(a); // removed + +const b = Object.freeze({ foo: 'bar' }); +console.log(b); + +const c = { foo: 'bar' }; +Object.freeze(c); // retained +console.log(c); diff --git a/test/form/samples/object-literal-property-overwrites/_config.js b/test/form/samples/object-literal-property-overwrites/_config.js index 4c75daffbfe..3cba590ed04 100644 --- a/test/form/samples/object-literal-property-overwrites/_config.js +++ b/test/form/samples/object-literal-property-overwrites/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'detect side-effects in overwritten properties of object literals' -}; +}); diff --git a/test/form/samples/object-literal-property-overwrites/_expected.js b/test/form/samples/object-literal-property-overwrites/_expected.js index ecd783e1d52..0d2ad4b1dcd 100644 --- a/test/form/samples/object-literal-property-overwrites/_expected.js +++ b/test/form/samples/object-literal-property-overwrites/_expected.js @@ -18,20 +18,14 @@ const retained3 = { retained3.bar(); const retained4 = { - foo: {}, foo: globalThis.unknown }; retained4.foo.bar = 1; const retained5 = { - foo: {}, - ['f' + 'oo']: globalThis.unknown, - ['b' + 'ar']: {}, -}; + ['f' + 'oo']: globalThis.unknown}; retained5.foo.bar = 1; const retained6 = { - ['fo' + 'o']: {}, - ['f' + 'oo']: {} -}; + }; retained6.bar.baz = 1; diff --git a/test/form/samples/object-tree-shaking-issue-5734/_config.js b/test/form/samples/object-tree-shaking-issue-5734/_config.js new file mode 100644 index 00000000000..c6e2b401e07 --- /dev/null +++ b/test/form/samples/object-tree-shaking-issue-5734/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'do not throw error Maximum call stack size exceeded' +}); diff --git a/test/form/samples/object-tree-shaking-issue-5734/_expected.js b/test/form/samples/object-tree-shaking-issue-5734/_expected.js new file mode 100644 index 00000000000..46d40da7e35 --- /dev/null +++ b/test/form/samples/object-tree-shaking-issue-5734/_expected.js @@ -0,0 +1,45586 @@ +class MySqlParser extends SQLParserBase { + get grammarFileName() { return "MySqlParser.g4"; } + get literalNames() { return MySqlParser.literalNames; } + get symbolicNames() { return MySqlParser.symbolicNames; } + get ruleNames() { return MySqlParser.ruleNames; } + get serializedATN() { return MySqlParser._serializedATN; } + createFailedPredicateException(predicate, message) { + return new antlr.FailedPredicateException(this, predicate, message); + } + constructor(input) { + super(input); + this.interpreter = new antlr.ParserATNSimulator(this, MySqlParser._ATN, MySqlParser.decisionsToDFA, new antlr.PredictionContextCache()); + } + program() { + let localContext = new ProgramContext(this.context, this.state); + this.enterRule(localContext, 0, MySqlParser.RULE_program); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 837; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while ((((_la) & ~0x1F) === 0 && ((1 << _la) & 169870592) !== 0) || ((((_la - 34)) & ~0x1F) === 0 && ((1 << (_la - 34)) & 268573697) !== 0) || ((((_la - 72)) & ~0x1F) === 0 && ((1 << (_la - 72)) & 2151694339) !== 0) || ((((_la - 104)) & ~0x1F) === 0 && ((1 << (_la - 104)) & 536936449) !== 0) || ((((_la - 140)) & ~0x1F) === 0 && ((1 << (_la - 140)) & 442923) !== 0) || ((((_la - 173)) & ~0x1F) === 0 && ((1 << (_la - 173)) & 2184193) !== 0) || ((((_la - 317)) & ~0x1F) === 0 && ((1 << (_la - 317)) & 16781443) !== 0) || _la === 362 || _la === 371 || ((((_la - 404)) & ~0x1F) === 0 && ((1 << (_la - 404)) & 270573569) !== 0) || _la === 540 || _la === 562 || ((((_la - 575)) & ~0x1F) === 0 && ((1 << (_la - 575)) & 16643) !== 0) || ((((_la - 640)) & ~0x1F) === 0 && ((1 << (_la - 640)) & 268435521) !== 0) || _la === 673 || _la === 694 || _la === 713 || _la === 717 || _la === 749 || _la === 866 || _la === 869) { + { + { + this.state = 834; + this.singleStatement(); + } + } + this.state = 839; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 840; + this.match(MySqlParser.EOF); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + singleStatement() { + let localContext = new SingleStatementContext(this.context, this.state); + this.enterRule(localContext, 2, MySqlParser.RULE_singleStatement); + try { + this.state = 847; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_ALTER: + case MySqlParser.KW_ANALYZE: + case MySqlParser.KW_CALL: + case MySqlParser.KW_CHANGE: + case MySqlParser.KW_CHECK: + case MySqlParser.KW_CREATE: + case MySqlParser.KW_DELETE: + case MySqlParser.KW_DESC: + case MySqlParser.KW_DESCRIBE: + case MySqlParser.KW_DROP: + case MySqlParser.KW_EXPLAIN: + case MySqlParser.KW_GET: + case MySqlParser.KW_GRANT: + case MySqlParser.KW_INSERT: + case MySqlParser.KW_KILL: + case MySqlParser.KW_LOAD: + case MySqlParser.KW_LOCK: + case MySqlParser.KW_OPTIMIZE: + case MySqlParser.KW_PURGE: + case MySqlParser.KW_RELEASE: + case MySqlParser.KW_RENAME: + case MySqlParser.KW_REPLACE: + case MySqlParser.KW_RESIGNAL: + case MySqlParser.KW_REVOKE: + case MySqlParser.KW_SELECT: + case MySqlParser.KW_SET: + case MySqlParser.KW_SHOW: + case MySqlParser.KW_SIGNAL: + case MySqlParser.KW_TABLE: + case MySqlParser.KW_UNLOCK: + case MySqlParser.KW_UPDATE: + case MySqlParser.KW_USE: + case MySqlParser.KW_VALUES: + case MySqlParser.KW_WITH: + case MySqlParser.KW_BEGIN: + case MySqlParser.KW_BINLOG: + case MySqlParser.KW_CACHE: + case MySqlParser.KW_CHECKSUM: + case MySqlParser.KW_COMMIT: + case MySqlParser.KW_DEALLOCATE: + case MySqlParser.KW_DO: + case MySqlParser.KW_FLUSH: + case MySqlParser.KW_HANDLER: + case MySqlParser.KW_HELP: + case MySqlParser.KW_IMPORT: + case MySqlParser.KW_INSTALL: + case MySqlParser.KW_PREPARE: + case MySqlParser.KW_REPAIR: + case MySqlParser.KW_RESET: + case MySqlParser.KW_RESTART: + case MySqlParser.KW_ROLLBACK: + case MySqlParser.KW_SAVEPOINT: + case MySqlParser.KW_START: + case MySqlParser.KW_STOP: + case MySqlParser.KW_TRUNCATE: + case MySqlParser.KW_UNINSTALL: + case MySqlParser.KW_XA: + case MySqlParser.KW_CLONE: + case MySqlParser.KW_EXECUTE: + case MySqlParser.KW_SHUTDOWN: + case MySqlParser.LR_BRACKET: + this.enterOuterAlt(localContext, 1); + { + this.state = 842; + this.sqlStatement(); + this.state = 844; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1, this.context)) { + case 1: + { + this.state = 843; + this.match(MySqlParser.SEMI); + } + break; + } + } + break; + case MySqlParser.SEMI: + this.enterOuterAlt(localContext, 2); + { + this.state = 846; + this.emptyStatement_(); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + sqlStatement() { + let localContext = new SqlStatementContext(this.context, this.state); + this.enterRule(localContext, 4, MySqlParser.RULE_sqlStatement); + try { + this.state = 856; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 3, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 849; + this.ddlStatement(); + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 850; + this.dmlStatement(); + } + break; + case 3: + this.enterOuterAlt(localContext, 3); + { + this.state = 851; + this.transactionStatement(); + } + break; + case 4: + this.enterOuterAlt(localContext, 4); + { + this.state = 852; + this.replicationStatement(); + } + break; + case 5: + this.enterOuterAlt(localContext, 5); + { + this.state = 853; + this.preparedStatement(); + } + break; + case 6: + this.enterOuterAlt(localContext, 6); + { + this.state = 854; + this.administrationStatement(); + } + break; + case 7: + this.enterOuterAlt(localContext, 7); + { + this.state = 855; + this.utilityStatement(); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + emptyStatement_() { + let localContext = new EmptyStatement_Context(this.context, this.state); + this.enterRule(localContext, 6, MySqlParser.RULE_emptyStatement_); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 858; + this.match(MySqlParser.SEMI); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + ddlStatement() { + let localContext = new DdlStatementContext(this.context, this.state); + this.enterRule(localContext, 8, MySqlParser.RULE_ddlStatement); + try { + this.state = 899; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 4, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 860; + this.createDatabase(); + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 861; + this.createEvent(); + } + break; + case 3: + this.enterOuterAlt(localContext, 3); + { + this.state = 862; + this.createIndex(); + } + break; + case 4: + this.enterOuterAlt(localContext, 4); + { + this.state = 863; + this.createLogfileGroup(); + } + break; + case 5: + this.enterOuterAlt(localContext, 5); + { + this.state = 864; + this.createProcedure(); + } + break; + case 6: + this.enterOuterAlt(localContext, 6); + { + this.state = 865; + this.createFunction(); + } + break; + case 7: + this.enterOuterAlt(localContext, 7); + { + this.state = 866; + this.createServer(); + } + break; + case 8: + this.enterOuterAlt(localContext, 8); + { + this.state = 867; + this.createTable(); + } + break; + case 9: + this.enterOuterAlt(localContext, 9); + { + this.state = 868; + this.createTablespaceInnodb(); + } + break; + case 10: + this.enterOuterAlt(localContext, 10); + { + this.state = 869; + this.createTablespaceNdb(); + } + break; + case 11: + this.enterOuterAlt(localContext, 11); + { + this.state = 870; + this.createTrigger(); + } + break; + case 12: + this.enterOuterAlt(localContext, 12); + { + this.state = 871; + this.createView(); + } + break; + case 13: + this.enterOuterAlt(localContext, 13); + { + this.state = 872; + this.createRole(); + } + break; + case 14: + this.enterOuterAlt(localContext, 14); + { + this.state = 873; + this.alterDatabase(); + } + break; + case 15: + this.enterOuterAlt(localContext, 15); + { + this.state = 874; + this.alterEvent(); + } + break; + case 16: + this.enterOuterAlt(localContext, 16); + { + this.state = 875; + this.alterFunction(); + } + break; + case 17: + this.enterOuterAlt(localContext, 17); + { + this.state = 876; + this.alterInstance(); + } + break; + case 18: + this.enterOuterAlt(localContext, 18); + { + this.state = 877; + this.alterLogfileGroup(); + } + break; + case 19: + this.enterOuterAlt(localContext, 19); + { + this.state = 878; + this.alterProcedure(); + } + break; + case 20: + this.enterOuterAlt(localContext, 20); + { + this.state = 879; + this.alterServer(); + } + break; + case 21: + this.enterOuterAlt(localContext, 21); + { + this.state = 880; + this.alterTable(); + } + break; + case 22: + this.enterOuterAlt(localContext, 22); + { + this.state = 881; + this.alterTablespace(); + } + break; + case 23: + this.enterOuterAlt(localContext, 23); + { + this.state = 882; + this.alterView(); + } + break; + case 24: + this.enterOuterAlt(localContext, 24); + { + this.state = 883; + this.dropDatabase(); + } + break; + case 25: + this.enterOuterAlt(localContext, 25); + { + this.state = 884; + this.dropEvent(); + } + break; + case 26: + this.enterOuterAlt(localContext, 26); + { + this.state = 885; + this.dropIndex(); + } + break; + case 27: + this.enterOuterAlt(localContext, 27); + { + this.state = 886; + this.dropLogfileGroup(); + } + break; + case 28: + this.enterOuterAlt(localContext, 28); + { + this.state = 887; + this.dropProcedure(); + } + break; + case 29: + this.enterOuterAlt(localContext, 29); + { + this.state = 888; + this.dropFunction(); + } + break; + case 30: + this.enterOuterAlt(localContext, 30); + { + this.state = 889; + this.dropServer(); + } + break; + case 31: + this.enterOuterAlt(localContext, 31); + { + this.state = 890; + this.dropSpatial(); + } + break; + case 32: + this.enterOuterAlt(localContext, 32); + { + this.state = 891; + this.dropTable(); + } + break; + case 33: + this.enterOuterAlt(localContext, 33); + { + this.state = 892; + this.dropTablespace(); + } + break; + case 34: + this.enterOuterAlt(localContext, 34); + { + this.state = 893; + this.dropTrigger(); + } + break; + case 35: + this.enterOuterAlt(localContext, 35); + { + this.state = 894; + this.dropView(); + } + break; + case 36: + this.enterOuterAlt(localContext, 36); + { + this.state = 895; + this.dropRole(); + } + break; + case 37: + this.enterOuterAlt(localContext, 37); + { + this.state = 896; + this.setRole(); + } + break; + case 38: + this.enterOuterAlt(localContext, 38); + { + this.state = 897; + this.renameTable(); + } + break; + case 39: + this.enterOuterAlt(localContext, 39); + { + this.state = 898; + this.truncateTable(); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + dmlStatement() { + let localContext = new DmlStatementContext(this.context, this.state); + this.enterRule(localContext, 10, MySqlParser.RULE_dmlStatement); + try { + this.state = 918; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 5, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 901; + this.selectStatement(); + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 902; + this.setOperations(); + } + break; + case 3: + this.enterOuterAlt(localContext, 3); + { + this.state = 903; + this.insertStatement(); + } + break; + case 4: + this.enterOuterAlt(localContext, 4); + { + this.state = 904; + this.updateStatement(); + } + break; + case 5: + this.enterOuterAlt(localContext, 5); + { + this.state = 905; + this.deleteStatement(); + } + break; + case 6: + this.enterOuterAlt(localContext, 6); + { + this.state = 906; + this.replaceStatement(); + } + break; + case 7: + this.enterOuterAlt(localContext, 7); + { + this.state = 907; + this.callStatement(); + } + break; + case 8: + this.enterOuterAlt(localContext, 8); + { + this.state = 908; + this.interSectStatement(); + } + break; + case 9: + this.enterOuterAlt(localContext, 9); + { + this.state = 909; + this.loadDataStatement(); + } + break; + case 10: + this.enterOuterAlt(localContext, 10); + { + this.state = 910; + this.loadXmlStatement(); + } + break; + case 11: + this.enterOuterAlt(localContext, 11); + { + this.state = 911; + this.parenthesizedQuery(); + } + break; + case 12: + this.enterOuterAlt(localContext, 12); + { + this.state = 912; + this.doStatement(); + } + break; + case 13: + this.enterOuterAlt(localContext, 13); + { + this.state = 913; + this.handlerStatement(); + } + break; + case 14: + this.enterOuterAlt(localContext, 14); + { + this.state = 914; + this.importTableStatement(); + } + break; + case 15: + this.enterOuterAlt(localContext, 15); + { + this.state = 915; + this.valuesStatement(); + } + break; + case 16: + this.enterOuterAlt(localContext, 16); + { + this.state = 916; + this.withStatement(); + } + break; + case 17: + this.enterOuterAlt(localContext, 17); + { + this.state = 917; + this.tableStatement(); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + transactionStatement() { + let localContext = new TransactionStatementContext(this.context, this.state); + this.enterRule(localContext, 12, MySqlParser.RULE_transactionStatement); + try { + this.state = 929; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 6, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 920; + this.startTransaction(); + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 921; + this.beginWork(); + } + break; + case 3: + this.enterOuterAlt(localContext, 3); + { + this.state = 922; + this.commitWork(); + } + break; + case 4: + this.enterOuterAlt(localContext, 4); + { + this.state = 923; + this.rollbackWork(); + } + break; + case 5: + this.enterOuterAlt(localContext, 5); + { + this.state = 924; + this.savepointStatement(); + } + break; + case 6: + this.enterOuterAlt(localContext, 6); + { + this.state = 925; + this.rollbackStatement(); + } + break; + case 7: + this.enterOuterAlt(localContext, 7); + { + this.state = 926; + this.releaseStatement(); + } + break; + case 8: + this.enterOuterAlt(localContext, 8); + { + this.state = 927; + this.lockTables(); + } + break; + case 9: + this.enterOuterAlt(localContext, 9); + { + this.state = 928; + this.unlockTables(); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + replicationStatement() { + let localContext = new ReplicationStatementContext(this.context, this.state); + this.enterRule(localContext, 14, MySqlParser.RULE_replicationStatement); + try { + this.state = 945; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 7, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 931; + this.changeMaster(); + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 932; + this.changeReplicationFilter(); + } + break; + case 3: + this.enterOuterAlt(localContext, 3); + { + this.state = 933; + this.changeReplicationSource(); + } + break; + case 4: + this.enterOuterAlt(localContext, 4); + { + this.state = 934; + this.purgeBinaryLogs(); + } + break; + case 5: + this.enterOuterAlt(localContext, 5); + { + this.state = 935; + this.startSlaveOrReplica(); + } + break; + case 6: + this.enterOuterAlt(localContext, 6); + { + this.state = 936; + this.stopSlaveOrReplica(); + } + break; + case 7: + this.enterOuterAlt(localContext, 7); + { + this.state = 937; + this.startGroupReplication(); + } + break; + case 8: + this.enterOuterAlt(localContext, 8); + { + this.state = 938; + this.stopGroupReplication(); + } + break; + case 9: + this.enterOuterAlt(localContext, 9); + { + this.state = 939; + this.xaStartTransaction(); + } + break; + case 10: + this.enterOuterAlt(localContext, 10); + { + this.state = 940; + this.xaEndTransaction(); + } + break; + case 11: + this.enterOuterAlt(localContext, 11); + { + this.state = 941; + this.xaPrepareStatement(); + } + break; + case 12: + this.enterOuterAlt(localContext, 12); + { + this.state = 942; + this.xaCommitWork(); + } + break; + case 13: + this.enterOuterAlt(localContext, 13); + { + this.state = 943; + this.xaRollbackWork(); + } + break; + case 14: + this.enterOuterAlt(localContext, 14); + { + this.state = 944; + this.xaRecoverWork(); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + preparedStatement() { + let localContext = new PreparedStatementContext(this.context, this.state); + this.enterRule(localContext, 16, MySqlParser.RULE_preparedStatement); + try { + this.state = 950; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_PREPARE: + this.enterOuterAlt(localContext, 1); + { + this.state = 947; + this.prepareStatement(); + } + break; + case MySqlParser.KW_EXECUTE: + this.enterOuterAlt(localContext, 2); + { + this.state = 948; + this.executeStatement(); + } + break; + case MySqlParser.KW_DROP: + case MySqlParser.KW_DEALLOCATE: + this.enterOuterAlt(localContext, 3); + { + this.state = 949; + this.deallocatePrepare(); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + compoundStatement() { + let localContext = new CompoundStatementContext(this.context, this.state); + this.enterRule(localContext, 18, MySqlParser.RULE_compoundStatement); + try { + this.state = 962; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 9, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 952; + this.blockStatement(); + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 953; + this.caseStatement(); + } + break; + case 3: + this.enterOuterAlt(localContext, 3); + { + this.state = 954; + this.ifStatement(); + } + break; + case 4: + this.enterOuterAlt(localContext, 4); + { + this.state = 955; + this.leaveStatement(); + } + break; + case 5: + this.enterOuterAlt(localContext, 5); + { + this.state = 956; + this.loopStatement(); + } + break; + case 6: + this.enterOuterAlt(localContext, 6); + { + this.state = 957; + this.repeatStatement(); + } + break; + case 7: + this.enterOuterAlt(localContext, 7); + { + this.state = 958; + this.whileStatement(); + } + break; + case 8: + this.enterOuterAlt(localContext, 8); + { + this.state = 959; + this.iterateStatement(); + } + break; + case 9: + this.enterOuterAlt(localContext, 9); + { + this.state = 960; + this.returnStatement(); + } + break; + case 10: + this.enterOuterAlt(localContext, 10); + { + this.state = 961; + this.cursorStatement(); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + administrationStatement() { + let localContext = new AdministrationStatementContext(this.context, this.state); + this.enterRule(localContext, 20, MySqlParser.RULE_administrationStatement); + try { + this.state = 997; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 10, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 964; + this.alterUser(); + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 965; + this.createUser(); + } + break; + case 3: + this.enterOuterAlt(localContext, 3); + { + this.state = 966; + this.dropUser(); + } + break; + case 4: + this.enterOuterAlt(localContext, 4); + { + this.state = 967; + this.grantStatement(); + } + break; + case 5: + this.enterOuterAlt(localContext, 5); + { + this.state = 968; + this.grantProxy(); + } + break; + case 6: + this.enterOuterAlt(localContext, 6); + { + this.state = 969; + this.renameUser(); + } + break; + case 7: + this.enterOuterAlt(localContext, 7); + { + this.state = 970; + this.revokeStatement(); + } + break; + case 8: + this.enterOuterAlt(localContext, 8); + { + this.state = 971; + this.alterResourceGroup(); + } + break; + case 9: + this.enterOuterAlt(localContext, 9); + { + this.state = 972; + this.createResourceGroup(); + } + break; + case 10: + this.enterOuterAlt(localContext, 10); + { + this.state = 973; + this.dropResourceGroup(); + } + break; + case 11: + this.enterOuterAlt(localContext, 11); + { + this.state = 974; + this.setResourceGroup(); + } + break; + case 12: + this.enterOuterAlt(localContext, 12); + { + this.state = 975; + this.analyzeTable(); + } + break; + case 13: + this.enterOuterAlt(localContext, 13); + { + this.state = 976; + this.checkTable(); + } + break; + case 14: + this.enterOuterAlt(localContext, 14); + { + this.state = 977; + this.checksumTable(); + } + break; + case 15: + this.enterOuterAlt(localContext, 15); + { + this.state = 978; + this.optimizeTable(); + } + break; + case 16: + this.enterOuterAlt(localContext, 16); + { + this.state = 979; + this.repairTable(); + } + break; + case 17: + this.enterOuterAlt(localContext, 17); + { + this.state = 980; + this.installComponent(); + } + break; + case 18: + this.enterOuterAlt(localContext, 18); + { + this.state = 981; + this.uninstallComponent(); + } + break; + case 19: + this.enterOuterAlt(localContext, 19); + { + this.state = 982; + this.installPlugin(); + } + break; + case 20: + this.enterOuterAlt(localContext, 20); + { + this.state = 983; + this.uninstallPlugin(); + } + break; + case 21: + this.enterOuterAlt(localContext, 21); + { + this.state = 984; + this.cloneStatement(); + } + break; + case 22: + this.enterOuterAlt(localContext, 22); + { + this.state = 985; + this.setStatement(); + } + break; + case 23: + this.enterOuterAlt(localContext, 23); + { + this.state = 986; + this.showStatement(); + } + break; + case 24: + this.enterOuterAlt(localContext, 24); + { + this.state = 987; + this.binlogStatement(); + } + break; + case 25: + this.enterOuterAlt(localContext, 25); + { + this.state = 988; + this.cacheIndexStatement(); + } + break; + case 26: + this.enterOuterAlt(localContext, 26); + { + this.state = 989; + this.flushStatement(); + } + break; + case 27: + this.enterOuterAlt(localContext, 27); + { + this.state = 990; + this.killStatement(); + } + break; + case 28: + this.enterOuterAlt(localContext, 28); + { + this.state = 991; + this.loadIndexIntoCache(); + } + break; + case 29: + this.enterOuterAlt(localContext, 29); + { + this.state = 992; + this.resetStatement(); + } + break; + case 30: + this.enterOuterAlt(localContext, 30); + { + this.state = 993; + this.resetPersist(); + } + break; + case 31: + this.enterOuterAlt(localContext, 31); + { + this.state = 994; + this.resetAllChannel(); + } + break; + case 32: + this.enterOuterAlt(localContext, 32); + { + this.state = 995; + this.reStartStatement(); + } + break; + case 33: + this.enterOuterAlt(localContext, 33); + { + this.state = 996; + this.shutdownStatement(); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + utilityStatement() { + let localContext = new UtilityStatementContext(this.context, this.state); + this.enterRule(localContext, 22, MySqlParser.RULE_utilityStatement); + try { + this.state = 1007; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 11, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 999; + this.fullDescribeStatement(); + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 1000; + this.simpleDescribeStatement(); + } + break; + case 3: + this.enterOuterAlt(localContext, 3); + { + this.state = 1001; + this.analyzeDescribeStatement(); + } + break; + case 4: + this.enterOuterAlt(localContext, 4); + { + this.state = 1002; + this.helpStatement(); + } + break; + case 5: + this.enterOuterAlt(localContext, 5); + { + this.state = 1003; + this.useStatement(); + } + break; + case 6: + this.enterOuterAlt(localContext, 6); + { + this.state = 1004; + this.signalStatement(); + } + break; + case 7: + this.enterOuterAlt(localContext, 7); + { + this.state = 1005; + this.resignalStatement(); + } + break; + case 8: + this.enterOuterAlt(localContext, 8); + { + this.state = 1006; + this.diagnosticsStatement(); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + createDatabase() { + let localContext = new CreateDatabaseContext(this.context, this.state); + this.enterRule(localContext, 24, MySqlParser.RULE_createDatabase); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 1009; + this.match(MySqlParser.KW_CREATE); + this.state = 1010; + localContext._dbFormat = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 39 || _la === 152)) { + localContext._dbFormat = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 1012; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 12, this.context)) { + case 1: + { + this.state = 1011; + this.ifNotExists(); + } + break; + } + this.state = 1014; + this.databaseNameCreate(); + this.state = 1018; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (((((_la - 26)) & ~0x1F) === 0 && ((1 << (_la - 26)) & 65541) !== 0) || _la === 135 || _la === 224 || _la === 376 || _la === 823) { + { + { + this.state = 1015; + this.createDatabaseOption(); + } + } + this.state = 1020; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + createEvent() { + let localContext = new CreateEventContext(this.context, this.state); + this.enterRule(localContext, 26, MySqlParser.RULE_createEvent); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 1021; + this.match(MySqlParser.KW_CREATE); + this.state = 1023; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 364) { + { + this.state = 1022; + this.ownerStatement(); + } + } + this.state = 1025; + this.match(MySqlParser.KW_EVENT); + this.state = 1027; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 15, this.context)) { + case 1: + { + this.state = 1026; + this.ifNotExists(); + } + break; + } + this.state = 1029; + localContext._event_name = this.fullId(); + this.state = 1030; + this.match(MySqlParser.KW_ON); + this.state = 1031; + this.match(MySqlParser.KW_SCHEDULE); + this.state = 1032; + this.scheduleExpression(); + this.state = 1039; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 119) { + { + this.state = 1033; + this.match(MySqlParser.KW_ON); + this.state = 1034; + this.match(MySqlParser.KW_COMPLETION); + this.state = 1036; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 114) { + { + this.state = 1035; + this.match(MySqlParser.KW_NOT); + } + } + this.state = 1038; + this.match(MySqlParser.KW_PRESERVE); + } + } + this.state = 1042; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 368 || _la === 375) { + { + this.state = 1041; + this.enableType(); + } + } + this.state = 1046; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 340) { + { + this.state = 1044; + this.match(MySqlParser.KW_COMMENT); + this.state = 1045; + this.match(MySqlParser.STRING_LITERAL); + } + } + this.state = 1048; + this.match(MySqlParser.KW_DO); + this.state = 1049; + this.routineBody(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + createIndex() { + let localContext = new CreateIndexContext(this.context, this.state); + this.enterRule(localContext, 28, MySqlParser.RULE_createIndex); + let _la; + try { + let alternative; + this.enterOuterAlt(localContext, 1); + { + this.state = 1051; + this.match(MySqlParser.KW_CREATE); + this.state = 1053; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 508 || _la === 514) { + { + this.state = 1052; + localContext._intimeAction = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 508 || _la === 514)) { + localContext._intimeAction = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + this.state = 1056; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 69 || _la === 161 || _la === 182) { + { + this.state = 1055; + localContext._indexCategory = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 69 || _la === 161 || _la === 182)) { + localContext._indexCategory = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + this.state = 1058; + this.match(MySqlParser.KW_INDEX); + this.state = 1059; + this.indexNameCreate(); + this.state = 1061; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 188) { + { + this.state = 1060; + this.indexType(); + } + } + this.state = 1063; + this.match(MySqlParser.KW_ON); + this.state = 1064; + this.tableName(); + this.state = 1065; + this.indexColumnNames(); + this.state = 1069; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 23, this.context); + while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER) { + if (alternative === 1) { + { + { + this.state = 1066; + this.indexOption(); + } + } + } + this.state = 1071; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 23, this.context); + } + this.state = 1084; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 27, this.context); + while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER) { + if (alternative === 1) { + { + this.state = 1082; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_ALGORITHM: + { + this.state = 1072; + this.match(MySqlParser.KW_ALGORITHM); + this.state = 1074; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 1073; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 1076; + localContext._algType = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 42 || _la === 357 || _la === 430)) { + localContext._algType = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + break; + case MySqlParser.KW_LOCK: + { + this.state = 1077; + this.match(MySqlParser.KW_LOCK); + this.state = 1079; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 1078; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 1081; + localContext._lockType = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 42 || _la === 389 || _la === 505 || _la === 595)) { + localContext._lockType = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + } + this.state = 1086; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 27, this.context); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + createLogfileGroup() { + let localContext = new CreateLogfileGroupContext(this.context, this.state); + this.enterRule(localContext, 30, MySqlParser.RULE_createLogfileGroup); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 1087; + this.match(MySqlParser.KW_CREATE); + this.state = 1088; + this.match(MySqlParser.KW_LOGFILE); + this.state = 1089; + this.match(MySqlParser.KW_GROUP); + this.state = 1090; + localContext._logfileGroupName = this.uid(); + this.state = 1091; + this.match(MySqlParser.KW_ADD); + this.state = 1092; + this.match(MySqlParser.KW_UNDOFILE); + this.state = 1093; + localContext._undoFile = this.match(MySqlParser.STRING_LITERAL); + this.state = 1099; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 428) { + { + this.state = 1094; + this.match(MySqlParser.KW_INITIAL_SIZE); + this.state = 1096; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 1095; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 1098; + localContext._initSize = this.fileSizeLiteral(); + } + } + this.state = 1106; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 672) { + { + this.state = 1101; + this.match(MySqlParser.KW_UNDO_BUFFER_SIZE); + this.state = 1103; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 1102; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 1105; + localContext._undoSize = this.fileSizeLiteral(); + } + } + this.state = 1113; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 553) { + { + this.state = 1108; + this.match(MySqlParser.KW_REDO_BUFFER_SIZE); + this.state = 1110; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 1109; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 1112; + localContext._redoSize = this.fileSizeLiteral(); + } + } + this.state = 1120; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 504) { + { + this.state = 1115; + this.match(MySqlParser.KW_NODEGROUP); + this.state = 1117; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 1116; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 1119; + localContext._nodegroup = this.uid(); + } + } + this.state = 1123; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 687) { + { + this.state = 1122; + this.match(MySqlParser.KW_WAIT); + } + } + this.state = 1130; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 340) { + { + this.state = 1125; + this.match(MySqlParser.KW_COMMENT); + this.state = 1127; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 1126; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 1129; + localContext._comment = this.match(MySqlParser.STRING_LITERAL); + } + } + this.state = 1132; + this.match(MySqlParser.KW_ENGINE); + this.state = 1134; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 1133; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 1136; + this.engineName(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + createProcedure() { + let localContext = new CreateProcedureContext(this.context, this.state); + this.enterRule(localContext, 32, MySqlParser.RULE_createProcedure); + let _la; + try { + let alternative; + this.enterOuterAlt(localContext, 1); + { + this.state = 1138; + this.match(MySqlParser.KW_CREATE); + this.state = 1140; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 364) { + { + this.state = 1139; + this.ownerStatement(); + } + } + this.state = 1142; + this.match(MySqlParser.KW_PROCEDURE); + this.state = 1144; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 41, this.context)) { + case 1: + { + this.state = 1143; + this.ifNotExists(); + } + break; + } + this.state = 1146; + localContext._sp_name = this.fullId(); + this.state = 1147; + this.match(MySqlParser.LR_BRACKET); + this.state = 1149; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if ((((_la) & ~0x1F) === 0 && ((1 << _la) & 1074302976) !== 0) || ((((_la - 36)) & ~0x1F) === 0 && ((1 << (_la - 36)) & 11014219) !== 0) || ((((_la - 74)) & ~0x1F) === 0 && ((1 << (_la - 74)) & 18880593) !== 0) || ((((_la - 117)) & ~0x1F) === 0 && ((1 << (_la - 117)) & 100680481) !== 0) || ((((_la - 150)) & ~0x1F) === 0 && ((1 << (_la - 150)) & 1049605) !== 0) || ((((_la - 219)) & ~0x1F) === 0 && ((1 << (_la - 219)) & 5374495) !== 0) || ((((_la - 253)) & ~0x1F) === 0 && ((1 << (_la - 253)) & 4294967295) !== 0) || ((((_la - 285)) & ~0x1F) === 0 && ((1 << (_la - 285)) & 4261412607) !== 0) || ((((_la - 317)) & ~0x1F) === 0 && ((1 << (_la - 317)) & 4160741375) !== 0) || ((((_la - 349)) & ~0x1F) === 0 && ((1 << (_la - 349)) & 4026531839) !== 0) || ((((_la - 381)) & ~0x1F) === 0 && ((1 << (_la - 381)) & 1055907839) !== 0) || ((((_la - 413)) & ~0x1F) === 0 && ((1 << (_la - 413)) & 4294885367) !== 0) || ((((_la - 445)) & ~0x1F) === 0 && ((1 << (_la - 445)) & 3757571071) !== 0) || ((((_la - 478)) & ~0x1F) === 0 && ((1 << (_la - 478)) & 3755999231) !== 0) || ((((_la - 510)) & ~0x1F) === 0 && ((1 << (_la - 510)) & 3751780349) !== 0) || ((((_la - 542)) & ~0x1F) === 0 && ((1 << (_la - 542)) & 2141183997) !== 0) || ((((_la - 575)) & ~0x1F) === 0 && ((1 << (_la - 575)) & 2147483629) !== 0) || ((((_la - 633)) & ~0x1F) === 0 && ((1 << (_la - 633)) & 4294934527) !== 0) || ((((_la - 665)) & ~0x1F) === 0 && ((1 << (_la - 665)) & 4278189053) !== 0) || ((((_la - 697)) & ~0x1F) === 0 && ((1 << (_la - 697)) & 1644099327) !== 0) || ((((_la - 729)) & ~0x1F) === 0 && ((1 << (_la - 729)) & 4294900735) !== 0) || ((((_la - 761)) & ~0x1F) === 0 && ((1 << (_la - 761)) & 4294967295) !== 0) || ((((_la - 793)) & ~0x1F) === 0 && ((1 << (_la - 793)) & 4288675839) !== 0) || ((((_la - 825)) & ~0x1F) === 0 && ((1 << (_la - 825)) & 2147527671) !== 0) || ((((_la - 879)) & ~0x1F) === 0 && ((1 << (_la - 879)) & 1033) !== 0)) { + { + this.state = 1148; + this.procedureParameter(); + } + } + this.state = 1155; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 1151; + this.match(MySqlParser.COMMA); + this.state = 1152; + this.procedureParameter(); + } + } + this.state = 1157; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 1158; + this.match(MySqlParser.RR_BRACKET); + this.state = 1162; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 44, this.context); + while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER) { + if (alternative === 1) { + { + { + this.state = 1159; + this.routineOption(); + } + } + } + this.state = 1164; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 44, this.context); + } + this.state = 1165; + this.routineBody(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + createRole() { + let localContext = new CreateRoleContext(this.context, this.state); + this.enterRule(localContext, 34, MySqlParser.RULE_createRole); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 1167; + this.match(MySqlParser.KW_CREATE); + this.state = 1168; + this.match(MySqlParser.KW_ROLE); + this.state = 1170; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 45, this.context)) { + case 1: + { + this.state = 1169; + this.ifNotExists(); + } + break; + } + this.state = 1172; + this.userOrRoleNames(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + createServer() { + let localContext = new CreateServerContext(this.context, this.state); + this.enterRule(localContext, 36, MySqlParser.RULE_createServer); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 1174; + this.match(MySqlParser.KW_CREATE); + this.state = 1175; + this.match(MySqlParser.KW_SERVER); + this.state = 1176; + localContext._servername = this.uid(); + this.state = 1177; + this.match(MySqlParser.KW_FOREIGN); + this.state = 1178; + this.match(MySqlParser.KW_DATA); + this.state = 1179; + this.match(MySqlParser.KW_WRAPPER); + this.state = 1180; + localContext._wrapperName = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 494 || _la === 882)) { + localContext._wrapperName = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 1181; + this.match(MySqlParser.KW_OPTIONS); + this.state = 1182; + this.match(MySqlParser.LR_BRACKET); + this.state = 1183; + this.serverOption(); + this.state = 1188; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 1184; + this.match(MySqlParser.COMMA); + this.state = 1185; + this.serverOption(); + } + } + this.state = 1190; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 1191; + this.match(MySqlParser.RR_BRACKET); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + createTable() { + let localContext = new CreateTableContext(this.context, this.state); + this.enterRule(localContext, 38, MySqlParser.RULE_createTable); + let _la; + try { + let alternative; + this.state = 1271; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 65, this.context)) { + case 1: + localContext = new QueryCreateTableContext(localContext); + this.enterOuterAlt(localContext, 1); + { + this.state = 1193; + this.match(MySqlParser.KW_CREATE); + this.state = 1195; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 660) { + { + this.state = 1194; + this.match(MySqlParser.KW_TEMPORARY); + } + } + this.state = 1197; + this.match(MySqlParser.KW_TABLE); + this.state = 1199; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 48, this.context)) { + case 1: + { + this.state = 1198; + this.ifNotExists(); + } + break; + } + this.state = 1201; + localContext._tb = this.tableNameCreate(); + this.state = 1203; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 49, this.context)) { + case 1: + { + this.state = 1202; + localContext._col = this.createDefinitions(); + } + break; + } + this.state = 1215; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (((((_la - 26)) & ~0x1F) === 0 && ((1 << (_la - 26)) & 65541) !== 0) || _la === 82 || _la === 181 || _la === 224 || ((((_la - 314)) & ~0x1F) === 0 && ((1 << (_la - 314)) & 67141639) !== 0) || ((((_la - 346)) & ~0x1F) === 0 && ((1 << (_la - 346)) & 3221766153) !== 0) || _la === 380 || _la === 431 || _la === 443 || _la === 480 || _la === 490 || ((((_la - 520)) & ~0x1F) === 0 && ((1 << (_la - 520)) & 541) !== 0) || _la === 588 || ((((_la - 640)) & ~0x1F) === 0 && ((1 << (_la - 640)) & 34341021) !== 0) || ((((_la - 823)) & ~0x1F) === 0 && ((1 << (_la - 823)) & 1029) !== 0) || _la === 882) { + { + this.state = 1205; + this.tableOption(); + this.state = 1212; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (((((_la - 26)) & ~0x1F) === 0 && ((1 << (_la - 26)) & 65541) !== 0) || _la === 82 || _la === 181 || _la === 224 || ((((_la - 314)) & ~0x1F) === 0 && ((1 << (_la - 314)) & 67141639) !== 0) || ((((_la - 346)) & ~0x1F) === 0 && ((1 << (_la - 346)) & 3221766153) !== 0) || _la === 380 || _la === 431 || _la === 443 || _la === 480 || _la === 490 || ((((_la - 520)) & ~0x1F) === 0 && ((1 << (_la - 520)) & 541) !== 0) || _la === 588 || ((((_la - 640)) & ~0x1F) === 0 && ((1 << (_la - 640)) & 34341021) !== 0) || ((((_la - 823)) & ~0x1F) === 0 && ((1 << (_la - 823)) & 1029) !== 0) || _la === 868 || _la === 882) { + { + { + this.state = 1207; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 868) { + { + this.state = 1206; + this.match(MySqlParser.COMMA); + } + } + this.state = 1209; + this.tableOption(); + } + } + this.state = 1214; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + } + this.state = 1218; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 130) { + { + this.state = 1217; + this.partitionDefinitions(); + } + } + this.state = 1221; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 79 || _la === 143) { + { + this.state = 1220; + _la = this.tokenStream.LA(1); + if (!(_la === 79 || _la === 143)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + this.state = 1224; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 13) { + { + this.state = 1223; + this.match(MySqlParser.KW_AS); + } + } + this.state = 1226; + this.selectStatement(); + } + break; + case 2: + localContext = new CopyCreateTableContext(localContext); + this.enterOuterAlt(localContext, 2); + { + this.state = 1228; + this.match(MySqlParser.KW_CREATE); + this.state = 1230; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 660) { + { + this.state = 1229; + this.match(MySqlParser.KW_TEMPORARY); + } + } + this.state = 1232; + this.match(MySqlParser.KW_TABLE); + this.state = 1234; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 57, this.context)) { + case 1: + { + this.state = 1233; + this.ifNotExists(); + } + break; + } + this.state = 1236; + this.tableNameCreate(); + this.state = 1244; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_LIKE: + { + this.state = 1237; + this.match(MySqlParser.KW_LIKE); + this.state = 1238; + this.tableName(); + } + break; + case MySqlParser.LR_BRACKET: + { + this.state = 1239; + this.match(MySqlParser.LR_BRACKET); + this.state = 1240; + this.match(MySqlParser.KW_LIKE); + this.state = 1241; + this.tableName(); + this.state = 1242; + this.match(MySqlParser.RR_BRACKET); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + break; + case 3: + localContext = new ColumnCreateTableContext(localContext); + this.enterOuterAlt(localContext, 3); + { + this.state = 1246; + this.match(MySqlParser.KW_CREATE); + this.state = 1248; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 660) { + { + this.state = 1247; + this.match(MySqlParser.KW_TEMPORARY); + } + } + this.state = 1250; + this.match(MySqlParser.KW_TABLE); + this.state = 1252; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 60, this.context)) { + case 1: + { + this.state = 1251; + this.ifNotExists(); + } + break; + } + this.state = 1254; + this.tableNameCreate(); + this.state = 1255; + this.createDefinitions(); + this.state = 1266; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 63, this.context)) { + case 1: + { + this.state = 1256; + this.tableOption(); + this.state = 1263; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 62, this.context); + while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER) { + if (alternative === 1) { + { + { + this.state = 1258; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 868) { + { + this.state = 1257; + this.match(MySqlParser.COMMA); + } + } + this.state = 1260; + this.tableOption(); + } + } + } + this.state = 1265; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 62, this.context); + } + } + break; + } + this.state = 1269; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 130) { + { + this.state = 1268; + this.partitionDefinitions(); + } + } + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + createTablespaceInnodb() { + let localContext = new CreateTablespaceInnodbContext(this.context, this.state); + this.enterRule(localContext, 40, MySqlParser.RULE_createTablespaceInnodb); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 1273; + this.match(MySqlParser.KW_CREATE); + this.state = 1275; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 180) { + { + this.state = 1274; + this.match(MySqlParser.KW_UNDO); + } + } + this.state = 1277; + this.match(MySqlParser.KW_TABLESPACE); + this.state = 1278; + this.tablespaceNameCreate(); + this.state = 1282; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 6) { + { + this.state = 1279; + this.match(MySqlParser.KW_ADD); + this.state = 1280; + this.match(MySqlParser.KW_DATAFILE); + this.state = 1281; + localContext._datafile = this.match(MySqlParser.STRING_LITERAL); + } + } + this.state = 1289; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 314) { + { + this.state = 1284; + this.match(MySqlParser.KW_AUTOEXTEND_SIZE); + this.state = 1286; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 1285; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 1288; + localContext._autoextendSize = this.fileSizeLiteral(); + } + } + this.state = 1294; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 399) { + { + this.state = 1291; + this.match(MySqlParser.KW_FILE_BLOCK_SIZE); + this.state = 1292; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 1293; + localContext._fileBlockSize = this.fileSizeLiteral(); + } + } + this.state = 1301; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 380) { + { + this.state = 1296; + this.match(MySqlParser.KW_ENGINE); + this.state = 1298; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 1297; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 1300; + this.engineName(); + } + } + this.state = 1308; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 825) { + { + this.state = 1303; + this.match(MySqlParser.KW_ENGINE_ATTRIBUTE); + this.state = 1305; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 1304; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 1307; + this.match(MySqlParser.STRING_LITERAL); + } + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + createTablespaceNdb() { + let localContext = new CreateTablespaceNdbContext(this.context, this.state); + this.enterRule(localContext, 42, MySqlParser.RULE_createTablespaceNdb); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 1310; + this.match(MySqlParser.KW_CREATE); + this.state = 1312; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 180) { + { + this.state = 1311; + this.match(MySqlParser.KW_UNDO); + } + } + this.state = 1314; + this.match(MySqlParser.KW_TABLESPACE); + this.state = 1315; + this.tablespaceNameCreate(); + this.state = 1316; + this.match(MySqlParser.KW_ADD); + this.state = 1317; + this.match(MySqlParser.KW_DATAFILE); + this.state = 1318; + localContext._datafile = this.match(MySqlParser.STRING_LITERAL); + this.state = 1319; + this.match(MySqlParser.KW_USE); + this.state = 1320; + this.match(MySqlParser.KW_LOGFILE); + this.state = 1321; + this.match(MySqlParser.KW_GROUP); + this.state = 1322; + localContext._logfileGroupName = this.uid(); + this.state = 1328; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 393) { + { + this.state = 1323; + this.match(MySqlParser.KW_EXTENT_SIZE); + this.state = 1325; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 1324; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 1327; + localContext._extentSize = this.fileSizeLiteral(); + } + } + this.state = 1335; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 428) { + { + this.state = 1330; + this.match(MySqlParser.KW_INITIAL_SIZE); + this.state = 1332; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 1331; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 1334; + localContext._initialSize = this.fileSizeLiteral(); + } + } + this.state = 1342; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 314) { + { + this.state = 1337; + this.match(MySqlParser.KW_AUTOEXTEND_SIZE); + this.state = 1339; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 1338; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 1341; + localContext._autoextendSize = this.fileSizeLiteral(); + } + } + this.state = 1349; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 481) { + { + this.state = 1344; + this.match(MySqlParser.KW_MAX_SIZE); + this.state = 1346; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 1345; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 1348; + localContext._maxSize = this.fileSizeLiteral(); + } + } + this.state = 1356; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 504) { + { + this.state = 1351; + this.match(MySqlParser.KW_NODEGROUP); + this.state = 1353; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 1352; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 1355; + localContext._nodegroup = this.uid(); + } + } + this.state = 1359; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 687) { + { + this.state = 1358; + this.match(MySqlParser.KW_WAIT); + } + } + this.state = 1366; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 340) { + { + this.state = 1361; + this.match(MySqlParser.KW_COMMENT); + this.state = 1363; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 1362; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 1365; + localContext._comment = this.match(MySqlParser.STRING_LITERAL); + } + } + this.state = 1368; + this.match(MySqlParser.KW_ENGINE); + this.state = 1370; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 1369; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 1372; + this.engineName(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + createTrigger() { + let localContext = new CreateTriggerContext(this.context, this.state); + this.enterRule(localContext, 44, MySqlParser.RULE_createTrigger); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 1374; + this.match(MySqlParser.KW_CREATE); + this.state = 1376; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 364) { + { + this.state = 1375; + this.ownerStatement(); + } + } + this.state = 1378; + this.match(MySqlParser.KW_TRIGGER); + this.state = 1380; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 91, this.context)) { + case 1: + { + this.state = 1379; + this.ifNotExists(); + } + break; + } + this.state = 1382; + localContext._trigger_name = this.fullId(); + this.state = 1383; + localContext._triggerTime = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 16 || _la === 306)) { + localContext._triggerTime = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 1384; + localContext._triggerEvent = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 44 || _la === 86 || _la === 185)) { + localContext._triggerEvent = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 1385; + this.match(MySqlParser.KW_ON); + this.state = 1386; + this.tableName(); + this.state = 1387; + this.match(MySqlParser.KW_FOR); + this.state = 1388; + this.match(MySqlParser.KW_EACH); + this.state = 1389; + this.match(MySqlParser.KW_ROW); + this.state = 1392; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 92, this.context)) { + case 1: + { + this.state = 1390; + localContext._triggerPlace = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 406 || _la === 538)) { + localContext._triggerPlace = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 1391; + localContext._other_trigger_name = this.fullId(); + } + break; + } + this.state = 1394; + this.routineBody(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + withClause() { + let localContext = new WithClauseContext(this.context, this.state); + this.enterRule(localContext, 46, MySqlParser.RULE_withClause); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 1396; + this.match(MySqlParser.KW_WITH); + this.state = 1398; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 93, this.context)) { + case 1: + { + this.state = 1397; + this.match(MySqlParser.KW_RECURSIVE); + } + break; + } + this.state = 1400; + this.commonTableExpressions(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + commonTableExpressions() { + let localContext = new CommonTableExpressionsContext(this.context, this.state); + this.enterRule(localContext, 48, MySqlParser.RULE_commonTableExpressions); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 1402; + localContext._cteName = this.uid(); + this.state = 1414; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 866) { + { + this.state = 1403; + this.match(MySqlParser.LR_BRACKET); + this.state = 1404; + localContext._cteColumnName = this.uid(); + this.state = 1409; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 1405; + this.match(MySqlParser.COMMA); + this.state = 1406; + localContext._cteColumnName = this.uid(); + } + } + this.state = 1411; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 1412; + this.match(MySqlParser.RR_BRACKET); + } + } + this.state = 1416; + this.match(MySqlParser.KW_AS); + this.state = 1417; + this.match(MySqlParser.LR_BRACKET); + this.state = 1418; + this.dmlStatement(); + this.state = 1419; + this.match(MySqlParser.RR_BRACKET); + this.state = 1422; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 96, this.context)) { + case 1: + { + this.state = 1420; + this.match(MySqlParser.COMMA); + this.state = 1421; + this.commonTableExpressions(); + } + break; + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + createView() { + let localContext = new CreateViewContext(this.context, this.state); + this.enterRule(localContext, 50, MySqlParser.RULE_createView); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 1424; + this.match(MySqlParser.KW_CREATE); + this.state = 1426; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 124) { + { + this.state = 1425; + this.orReplace(); + } + } + this.state = 1431; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 308) { + { + this.state = 1428; + this.match(MySqlParser.KW_ALGORITHM); + this.state = 1429; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 1430; + localContext._algType = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 486 || _la === 661 || _la === 670)) { + localContext._algType = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + this.state = 1434; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 364) { + { + this.state = 1433; + this.ownerStatement(); + } + } + this.state = 1439; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 162) { + { + this.state = 1436; + this.match(MySqlParser.KW_SQL); + this.state = 1437; + this.match(MySqlParser.KW_SECURITY); + this.state = 1438; + localContext._secContext = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 364 || _la === 436)) { + localContext._secContext = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + this.state = 1441; + this.match(MySqlParser.KW_VIEW); + this.state = 1442; + this.viewNameCreate(); + this.state = 1454; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 866) { + { + this.state = 1443; + this.match(MySqlParser.LR_BRACKET); + this.state = 1444; + this.columnNameCreate(); + this.state = 1449; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 1445; + this.match(MySqlParser.COMMA); + this.state = 1446; + this.columnNameCreate(); + } + } + this.state = 1451; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 1452; + this.match(MySqlParser.RR_BRACKET); + } + } + this.state = 1456; + this.match(MySqlParser.KW_AS); + this.state = 1476; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 107, this.context)) { + case 1: + { + this.state = 1457; + this.match(MySqlParser.LR_BRACKET); + this.state = 1459; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 194) { + { + this.state = 1458; + this.withClause(); + } + } + this.state = 1461; + this.selectStatement(); + this.state = 1462; + this.match(MySqlParser.RR_BRACKET); + } + break; + case 2: + { + this.state = 1465; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 194) { + { + this.state = 1464; + this.withClause(); + } + } + this.state = 1467; + this.selectStatement(); + this.state = 1474; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 106, this.context)) { + case 1: + { + this.state = 1468; + this.match(MySqlParser.KW_WITH); + this.state = 1470; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 325 || _la === 450) { + { + this.state = 1469; + localContext._checkOption = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 325 || _la === 450)) { + localContext._checkOption = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + this.state = 1472; + this.match(MySqlParser.KW_CHECK); + this.state = 1473; + this.match(MySqlParser.KW_OPTION); + } + break; + } + } + break; + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + createDatabaseOption() { + let localContext = new CreateDatabaseOptionContext(this.context, this.state); + this.enterRule(localContext, 52, MySqlParser.RULE_createDatabaseOption); + let _la; + try { + this.state = 1511; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 116, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 1479; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 42) { + { + this.state = 1478; + this.match(MySqlParser.KW_DEFAULT); + } + } + this.state = 1481; + this.charSet(); + this.state = 1483; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 1482; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 1487; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_BINARY: + case MySqlParser.KW_ARMSCII8: + case MySqlParser.KW_ASCII: + case MySqlParser.KW_BIG5: + case MySqlParser.KW_CP1250: + case MySqlParser.KW_CP1251: + case MySqlParser.KW_CP1256: + case MySqlParser.KW_CP1257: + case MySqlParser.KW_CP850: + case MySqlParser.KW_CP852: + case MySqlParser.KW_CP866: + case MySqlParser.KW_CP932: + case MySqlParser.KW_DEC8: + case MySqlParser.KW_EUCJPMS: + case MySqlParser.KW_EUCKR: + case MySqlParser.KW_GB18030: + case MySqlParser.KW_GB2312: + case MySqlParser.KW_GBK: + case MySqlParser.KW_GEOSTD8: + case MySqlParser.KW_GREEK: + case MySqlParser.KW_HEBREW: + case MySqlParser.KW_HP8: + case MySqlParser.KW_KEYBCS2: + case MySqlParser.KW_KOI8R: + case MySqlParser.KW_KOI8U: + case MySqlParser.KW_LATIN1: + case MySqlParser.KW_LATIN2: + case MySqlParser.KW_LATIN5: + case MySqlParser.KW_LATIN7: + case MySqlParser.KW_MACCE: + case MySqlParser.KW_MACROMAN: + case MySqlParser.KW_SJIS: + case MySqlParser.KW_SWE7: + case MySqlParser.KW_TIS620: + case MySqlParser.KW_UCS2: + case MySqlParser.KW_UJIS: + case MySqlParser.KW_UTF16: + case MySqlParser.KW_UTF16LE: + case MySqlParser.KW_UTF32: + case MySqlParser.KW_UTF8: + case MySqlParser.KW_UTF8MB3: + case MySqlParser.KW_UTF8MB4: + case MySqlParser.CHARSET_REVERSE_QOUTE_STRING: + case MySqlParser.STRING_LITERAL: + { + this.state = 1485; + this.charsetName(); + } + break; + case MySqlParser.KW_DEFAULT: + { + this.state = 1486; + this.match(MySqlParser.KW_DEFAULT); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 1490; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 42) { + { + this.state = 1489; + this.match(MySqlParser.KW_DEFAULT); + } + } + this.state = 1492; + this.match(MySqlParser.KW_COLLATE); + this.state = 1494; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 1493; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 1496; + this.collationName(); + } + break; + case 3: + this.enterOuterAlt(localContext, 3); + { + this.state = 1498; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 42) { + { + this.state = 1497; + this.match(MySqlParser.KW_DEFAULT); + } + } + this.state = 1500; + this.match(MySqlParser.KW_ENCRYPTION); + this.state = 1502; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 1501; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 1504; + this.match(MySqlParser.STRING_LITERAL); + } + break; + case 4: + this.enterOuterAlt(localContext, 4); + { + this.state = 1505; + this.match(MySqlParser.KW_READ); + this.state = 1506; + this.match(MySqlParser.KW_ONLY); + this.state = 1508; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 1507; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 1510; + _la = this.tokenStream.LA(1); + if (!(_la === 42 || _la === 871 || _la === 872)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + charSet() { + let localContext = new CharSetContext(this.context, this.state); + this.enterRule(localContext, 54, MySqlParser.RULE_charSet); + try { + this.state = 1518; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_CHARACTER: + this.enterOuterAlt(localContext, 1); + { + this.state = 1513; + this.match(MySqlParser.KW_CHARACTER); + this.state = 1514; + this.match(MySqlParser.KW_SET); + } + break; + case MySqlParser.KW_CHARSET: + this.enterOuterAlt(localContext, 2); + { + this.state = 1515; + this.match(MySqlParser.KW_CHARSET); + } + break; + case MySqlParser.KW_CHAR: + this.enterOuterAlt(localContext, 3); + { + this.state = 1516; + this.match(MySqlParser.KW_CHAR); + this.state = 1517; + this.match(MySqlParser.KW_SET); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + currentUserExpression() { + let localContext = new CurrentUserExpressionContext(this.context, this.state); + this.enterRule(localContext, 56, MySqlParser.RULE_currentUserExpression); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 1520; + _la = this.tokenStream.LA(1); + if (!(_la === 37 || _la === 678)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 1523; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 118, this.context)) { + case 1: + { + this.state = 1521; + this.match(MySqlParser.LR_BRACKET); + this.state = 1522; + this.match(MySqlParser.RR_BRACKET); + } + break; + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + ownerStatement() { + let localContext = new OwnerStatementContext(this.context, this.state); + this.enterRule(localContext, 58, MySqlParser.RULE_ownerStatement); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 1525; + this.match(MySqlParser.KW_DEFINER); + this.state = 1526; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 1529; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 119, this.context)) { + case 1: + { + this.state = 1527; + this.userName(); + } + break; + case 2: + { + this.state = 1528; + this.currentUserExpression(); + } + break; + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + scheduleExpression() { + let localContext = new ScheduleExpressionContext(this.context, this.state); + this.enterRule(localContext, 60, MySqlParser.RULE_scheduleExpression); + let _la; + try { + this.state = 1565; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_AT: + localContext = new PreciseScheduleContext(localContext); + this.enterOuterAlt(localContext, 1); + { + this.state = 1531; + this.match(MySqlParser.KW_AT); + this.state = 1532; + this.timestampValue(); + this.state = 1536; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 853) { + { + { + this.state = 1533; + this.intervalExpr(); + } + } + this.state = 1538; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + break; + case MySqlParser.KW_EVERY: + localContext = new IntervalScheduleContext(localContext); + this.enterOuterAlt(localContext, 2); + { + this.state = 1539; + this.match(MySqlParser.KW_EVERY); + this.state = 1542; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 121, this.context)) { + case 1: + { + this.state = 1540; + this.decimalLiteral(); + } + break; + case 2: + { + this.state = 1541; + this.expression(0); + } + break; + } + this.state = 1544; + this.intervalType(); + this.state = 1553; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 641) { + { + this.state = 1545; + this.match(MySqlParser.KW_STARTS); + this.state = 1546; + localContext._startTimestamp = this.timestampValue(); + this.state = 1550; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 853) { + { + { + this.state = 1547; + localContext._intervalExpr = this.intervalExpr(); + localContext._startIntervals.push(localContext._intervalExpr); + } + } + this.state = 1552; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + } + this.state = 1563; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 379) { + { + this.state = 1555; + this.match(MySqlParser.KW_ENDS); + this.state = 1556; + localContext._endTimestamp = this.timestampValue(); + this.state = 1560; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 853) { + { + { + this.state = 1557; + localContext._intervalExpr = this.intervalExpr(); + localContext._endIntervals.push(localContext._intervalExpr); + } + } + this.state = 1562; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + } + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + timestampValue() { + let localContext = new TimestampValueContext(this.context, this.state); + this.enterRule(localContext, 62, MySqlParser.RULE_timestampValue); + try { + this.state = 1571; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 127, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 1567; + this.match(MySqlParser.KW_CURRENT_TIMESTAMP); + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 1568; + this.stringLiteral(); + } + break; + case 3: + this.enterOuterAlt(localContext, 3); + { + this.state = 1569; + this.decimalLiteral(); + } + break; + case 4: + this.enterOuterAlt(localContext, 4); + { + this.state = 1570; + this.expression(0); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + intervalExpr() { + let localContext = new IntervalExprContext(this.context, this.state); + this.enterRule(localContext, 64, MySqlParser.RULE_intervalExpr); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 1573; + this.match(MySqlParser.PLUS); + this.state = 1574; + this.match(MySqlParser.KW_INTERVAL); + this.state = 1577; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 128, this.context)) { + case 1: + { + this.state = 1575; + this.decimalLiteral(); + } + break; + case 2: + { + this.state = 1576; + this.expression(0); + } + break; + } + this.state = 1579; + this.intervalType(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + intervalType() { + let localContext = new IntervalTypeContext(this.context, this.state); + this.enterRule(localContext, 66, MySqlParser.RULE_intervalType); + try { + this.state = 1594; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_QUARTER: + case MySqlParser.KW_MONTH: + case MySqlParser.KW_DAY: + case MySqlParser.KW_HOUR: + case MySqlParser.KW_MINUTE: + case MySqlParser.KW_WEEK: + case MySqlParser.KW_SECOND: + case MySqlParser.KW_MICROSECOND: + this.enterOuterAlt(localContext, 1); + { + this.state = 1581; + this.intervalTypeBase(); + } + break; + case MySqlParser.KW_YEAR: + this.enterOuterAlt(localContext, 2); + { + this.state = 1582; + this.match(MySqlParser.KW_YEAR); + } + break; + case MySqlParser.KW_YEAR_MONTH: + this.enterOuterAlt(localContext, 3); + { + this.state = 1583; + this.match(MySqlParser.KW_YEAR_MONTH); + } + break; + case MySqlParser.KW_DAY_HOUR: + this.enterOuterAlt(localContext, 4); + { + this.state = 1584; + this.match(MySqlParser.KW_DAY_HOUR); + } + break; + case MySqlParser.KW_DAY_MINUTE: + this.enterOuterAlt(localContext, 5); + { + this.state = 1585; + this.match(MySqlParser.KW_DAY_MINUTE); + } + break; + case MySqlParser.KW_DAY_SECOND: + this.enterOuterAlt(localContext, 6); + { + this.state = 1586; + this.match(MySqlParser.KW_DAY_SECOND); + } + break; + case MySqlParser.KW_HOUR_MINUTE: + this.enterOuterAlt(localContext, 7); + { + this.state = 1587; + this.match(MySqlParser.KW_HOUR_MINUTE); + } + break; + case MySqlParser.KW_HOUR_SECOND: + this.enterOuterAlt(localContext, 8); + { + this.state = 1588; + this.match(MySqlParser.KW_HOUR_SECOND); + } + break; + case MySqlParser.KW_MINUTE_SECOND: + this.enterOuterAlt(localContext, 9); + { + this.state = 1589; + this.match(MySqlParser.KW_MINUTE_SECOND); + } + break; + case MySqlParser.KW_SECOND_MICROSECOND: + this.enterOuterAlt(localContext, 10); + { + this.state = 1590; + this.match(MySqlParser.KW_SECOND_MICROSECOND); + } + break; + case MySqlParser.KW_MINUTE_MICROSECOND: + this.enterOuterAlt(localContext, 11); + { + this.state = 1591; + this.match(MySqlParser.KW_MINUTE_MICROSECOND); + } + break; + case MySqlParser.KW_HOUR_MICROSECOND: + this.enterOuterAlt(localContext, 12); + { + this.state = 1592; + this.match(MySqlParser.KW_HOUR_MICROSECOND); + } + break; + case MySqlParser.KW_DAY_MICROSECOND: + this.enterOuterAlt(localContext, 13); + { + this.state = 1593; + this.match(MySqlParser.KW_DAY_MICROSECOND); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + enableType() { + let localContext = new EnableTypeContext(this.context, this.state); + this.enterRule(localContext, 68, MySqlParser.RULE_enableType); + try { + this.state = 1601; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 130, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 1596; + this.match(MySqlParser.KW_ENABLE); + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 1597; + this.match(MySqlParser.KW_DISABLE); + } + break; + case 3: + this.enterOuterAlt(localContext, 3); + { + this.state = 1598; + this.match(MySqlParser.KW_DISABLE); + this.state = 1599; + this.match(MySqlParser.KW_ON); + this.state = 1600; + this.match(MySqlParser.KW_SLAVE); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + indexType() { + let localContext = new IndexTypeContext(this.context, this.state); + this.enterRule(localContext, 70, MySqlParser.RULE_indexType); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 1603; + this.match(MySqlParser.KW_USING); + this.state = 1604; + _la = this.tokenStream.LA(1); + if (!(_la === 323 || _la === 418)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + indexOption() { + let localContext = new IndexOptionContext(this.context, this.state); + this.enterRule(localContext, 72, MySqlParser.RULE_indexOption); + let _la; + try { + this.state = 1628; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_KEY_BLOCK_SIZE: + this.enterOuterAlt(localContext, 1); + { + this.state = 1606; + this.match(MySqlParser.KW_KEY_BLOCK_SIZE); + this.state = 1608; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 1607; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 1610; + this.fileSizeLiteral(); + } + break; + case MySqlParser.KW_USING: + this.enterOuterAlt(localContext, 2); + { + this.state = 1611; + this.indexType(); + } + break; + case MySqlParser.KW_WITH: + this.enterOuterAlt(localContext, 3); + { + this.state = 1612; + this.match(MySqlParser.KW_WITH); + this.state = 1613; + this.match(MySqlParser.KW_PARSER); + this.state = 1614; + localContext._parserName = this.uid(); + } + break; + case MySqlParser.KW_COMMENT: + this.enterOuterAlt(localContext, 4); + { + this.state = 1615; + this.match(MySqlParser.KW_COMMENT); + this.state = 1616; + this.match(MySqlParser.STRING_LITERAL); + } + break; + case MySqlParser.KW_INVISIBLE: + case MySqlParser.KW_VISIBLE: + this.enterOuterAlt(localContext, 5); + { + this.state = 1617; + _la = this.tokenStream.LA(1); + if (!(_la === 435 || _la === 686)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + break; + case MySqlParser.KW_ENGINE_ATTRIBUTE: + this.enterOuterAlt(localContext, 6); + { + this.state = 1618; + this.match(MySqlParser.KW_ENGINE_ATTRIBUTE); + this.state = 1620; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 1619; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 1622; + this.match(MySqlParser.STRING_LITERAL); + } + break; + case MySqlParser.KW_SECONDARY_ENGINE_ATTRIBUTE: + this.enterOuterAlt(localContext, 7); + { + this.state = 1623; + this.match(MySqlParser.KW_SECONDARY_ENGINE_ATTRIBUTE); + this.state = 1625; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 1624; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 1627; + this.match(MySqlParser.STRING_LITERAL); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + procedureParameter() { + let localContext = new ProcedureParameterContext(this.context, this.state); + this.enterRule(localContext, 74, MySqlParser.RULE_procedureParameter); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 1631; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 80 || _la === 85 || _la === 126) { + { + this.state = 1630; + localContext._direction = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 80 || _la === 85 || _la === 126)) { + localContext._direction = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + this.state = 1633; + localContext._paramName = this.uid(); + this.state = 1634; + this.dataType(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + routineOption() { + let localContext = new RoutineOptionContext(this.context, this.state); + this.enterRule(localContext, 76, MySqlParser.RULE_routineOption); + let _la; + try { + this.state = 1659; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_COMMENT: + localContext = new RoutineCommentContext(localContext); + this.enterOuterAlt(localContext, 1); + { + this.state = 1636; + this.match(MySqlParser.KW_COMMENT); + this.state = 1637; + this.match(MySqlParser.STRING_LITERAL); + } + break; + case MySqlParser.KW_LANGUAGE: + localContext = new RoutineLanguageContext(localContext); + this.enterOuterAlt(localContext, 2); + { + this.state = 1638; + this.match(MySqlParser.KW_LANGUAGE); + this.state = 1639; + this.match(MySqlParser.KW_SQL); + } + break; + case MySqlParser.KW_DETERMINISTIC: + case MySqlParser.KW_NOT: + localContext = new RoutineBehaviorContext(localContext); + this.enterOuterAlt(localContext, 3); + { + this.state = 1641; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 114) { + { + this.state = 1640; + this.match(MySqlParser.KW_NOT); + } + } + this.state = 1643; + this.match(MySqlParser.KW_DETERMINISTIC); + } + break; + case MySqlParser.KW_MODIFIES: + case MySqlParser.KW_READS: + case MySqlParser.KW_CONTAINS: + case MySqlParser.KW_NO: + localContext = new RoutineDataContext(localContext); + this.enterOuterAlt(localContext, 4); + { + this.state = 1654; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_CONTAINS: + { + this.state = 1644; + this.match(MySqlParser.KW_CONTAINS); + this.state = 1645; + this.match(MySqlParser.KW_SQL); + } + break; + case MySqlParser.KW_NO: + { + this.state = 1646; + this.match(MySqlParser.KW_NO); + this.state = 1647; + this.match(MySqlParser.KW_SQL); + } + break; + case MySqlParser.KW_READS: + { + this.state = 1648; + this.match(MySqlParser.KW_READS); + this.state = 1649; + this.match(MySqlParser.KW_SQL); + this.state = 1650; + this.match(MySqlParser.KW_DATA); + } + break; + case MySqlParser.KW_MODIFIES: + { + this.state = 1651; + this.match(MySqlParser.KW_MODIFIES); + this.state = 1652; + this.match(MySqlParser.KW_SQL); + this.state = 1653; + this.match(MySqlParser.KW_DATA); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + break; + case MySqlParser.KW_SQL: + localContext = new RoutineSecurityContext(localContext); + this.enterOuterAlt(localContext, 5); + { + this.state = 1656; + this.match(MySqlParser.KW_SQL); + this.state = 1657; + this.match(MySqlParser.KW_SECURITY); + this.state = 1658; + localContext._context = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 364 || _la === 436)) { + localContext._context = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + serverOption() { + let localContext = new ServerOptionContext(this.context, this.state); + this.enterRule(localContext, 78, MySqlParser.RULE_serverOption); + try { + this.state = 1675; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_HOST: + this.enterOuterAlt(localContext, 1); + { + this.state = 1661; + this.match(MySqlParser.KW_HOST); + this.state = 1662; + this.match(MySqlParser.STRING_LITERAL); + } + break; + case MySqlParser.KW_DATABASE: + this.enterOuterAlt(localContext, 2); + { + this.state = 1663; + this.match(MySqlParser.KW_DATABASE); + this.state = 1664; + this.match(MySqlParser.STRING_LITERAL); + } + break; + case MySqlParser.KW_USER: + this.enterOuterAlt(localContext, 3); + { + this.state = 1665; + this.match(MySqlParser.KW_USER); + this.state = 1666; + this.match(MySqlParser.STRING_LITERAL); + } + break; + case MySqlParser.KW_PASSWORD: + this.enterOuterAlt(localContext, 4); + { + this.state = 1667; + this.match(MySqlParser.KW_PASSWORD); + this.state = 1668; + this.match(MySqlParser.STRING_LITERAL); + } + break; + case MySqlParser.KW_SOCKET: + this.enterOuterAlt(localContext, 5); + { + this.state = 1669; + this.match(MySqlParser.KW_SOCKET); + this.state = 1670; + this.match(MySqlParser.STRING_LITERAL); + } + break; + case MySqlParser.KW_OWNER: + this.enterOuterAlt(localContext, 6); + { + this.state = 1671; + this.match(MySqlParser.KW_OWNER); + this.state = 1672; + this.match(MySqlParser.STRING_LITERAL); + } + break; + case MySqlParser.KW_PORT: + this.enterOuterAlt(localContext, 7); + { + this.state = 1673; + this.match(MySqlParser.KW_PORT); + this.state = 1674; + this.decimalLiteral(); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + createDefinitions() { + let localContext = new CreateDefinitionsContext(this.context, this.state); + this.enterRule(localContext, 80, MySqlParser.RULE_createDefinitions); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 1677; + this.match(MySqlParser.LR_BRACKET); + this.state = 1678; + this.createDefinition(); + this.state = 1683; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 1679; + this.match(MySqlParser.COMMA); + this.state = 1680; + this.createDefinition(); + } + } + this.state = 1685; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 1686; + this.match(MySqlParser.RR_BRACKET); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + createDefinition() { + let localContext = new CreateDefinitionContext(this.context, this.state); + this.enterRule(localContext, 82, MySqlParser.RULE_createDefinition); + let _la; + try { + this.state = 1771; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 157, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 1688; + this.columnNameCreate(); + this.state = 1689; + this.columnDefinition(); + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 1691; + _la = this.tokenStream.LA(1); + if (!(_la === 82 || _la === 92)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 1693; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if ((((_la) & ~0x1F) === 0 && ((1 << _la) & 1074302976) !== 0) || ((((_la - 36)) & ~0x1F) === 0 && ((1 << (_la - 36)) & 11014219) !== 0) || ((((_la - 74)) & ~0x1F) === 0 && ((1 << (_la - 74)) & 18878481) !== 0) || ((((_la - 117)) & ~0x1F) === 0 && ((1 << (_la - 117)) & 100679969) !== 0) || ((((_la - 150)) & ~0x1F) === 0 && ((1 << (_la - 150)) & 1049605) !== 0) || ((((_la - 219)) & ~0x1F) === 0 && ((1 << (_la - 219)) & 5374495) !== 0) || ((((_la - 253)) & ~0x1F) === 0 && ((1 << (_la - 253)) & 4294967295) !== 0) || ((((_la - 285)) & ~0x1F) === 0 && ((1 << (_la - 285)) & 4261412607) !== 0) || ((((_la - 317)) & ~0x1F) === 0 && ((1 << (_la - 317)) & 4160741375) !== 0) || ((((_la - 349)) & ~0x1F) === 0 && ((1 << (_la - 349)) & 4026531839) !== 0) || ((((_la - 381)) & ~0x1F) === 0 && ((1 << (_la - 381)) & 1055907839) !== 0) || ((((_la - 413)) & ~0x1F) === 0 && ((1 << (_la - 413)) & 4294885367) !== 0) || ((((_la - 445)) & ~0x1F) === 0 && ((1 << (_la - 445)) & 3757571071) !== 0) || ((((_la - 478)) & ~0x1F) === 0 && ((1 << (_la - 478)) & 3755999231) !== 0) || ((((_la - 510)) & ~0x1F) === 0 && ((1 << (_la - 510)) & 3751780349) !== 0) || ((((_la - 542)) & ~0x1F) === 0 && ((1 << (_la - 542)) & 2141183997) !== 0) || ((((_la - 575)) & ~0x1F) === 0 && ((1 << (_la - 575)) & 2147483629) !== 0) || ((((_la - 633)) & ~0x1F) === 0 && ((1 << (_la - 633)) & 4294934527) !== 0) || ((((_la - 665)) & ~0x1F) === 0 && ((1 << (_la - 665)) & 4278189053) !== 0) || ((((_la - 697)) & ~0x1F) === 0 && ((1 << (_la - 697)) & 1644099327) !== 0) || ((((_la - 729)) & ~0x1F) === 0 && ((1 << (_la - 729)) & 4294900735) !== 0) || ((((_la - 761)) & ~0x1F) === 0 && ((1 << (_la - 761)) & 4294967295) !== 0) || ((((_la - 793)) & ~0x1F) === 0 && ((1 << (_la - 793)) & 4288675839) !== 0) || ((((_la - 825)) & ~0x1F) === 0 && ((1 << (_la - 825)) & 2147527671) !== 0) || ((((_la - 879)) & ~0x1F) === 0 && ((1 << (_la - 879)) & 1033) !== 0)) { + { + this.state = 1692; + this.indexName(); + } + } + this.state = 1696; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 188) { + { + this.state = 1695; + this.indexType(); + } + } + this.state = 1698; + this.indexColumnNames(); + this.state = 1702; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 188 || _la === 194 || _la === 340 || _la === 435 || _la === 443 || _la === 686 || _la === 825 || _la === 833) { + { + { + this.state = 1699; + this.indexOption(); + } + } + this.state = 1704; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + break; + case 3: + this.enterOuterAlt(localContext, 3); + { + this.state = 1705; + _la = this.tokenStream.LA(1); + if (!(_la === 69 || _la === 161)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 1707; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 82 || _la === 92) { + { + this.state = 1706; + _la = this.tokenStream.LA(1); + if (!(_la === 82 || _la === 92)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + this.state = 1710; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if ((((_la) & ~0x1F) === 0 && ((1 << _la) & 1074302976) !== 0) || ((((_la - 36)) & ~0x1F) === 0 && ((1 << (_la - 36)) & 11014219) !== 0) || ((((_la - 74)) & ~0x1F) === 0 && ((1 << (_la - 74)) & 18878481) !== 0) || ((((_la - 117)) & ~0x1F) === 0 && ((1 << (_la - 117)) & 100679969) !== 0) || ((((_la - 150)) & ~0x1F) === 0 && ((1 << (_la - 150)) & 1049605) !== 0) || ((((_la - 219)) & ~0x1F) === 0 && ((1 << (_la - 219)) & 5374495) !== 0) || ((((_la - 253)) & ~0x1F) === 0 && ((1 << (_la - 253)) & 4294967295) !== 0) || ((((_la - 285)) & ~0x1F) === 0 && ((1 << (_la - 285)) & 4261412607) !== 0) || ((((_la - 317)) & ~0x1F) === 0 && ((1 << (_la - 317)) & 4160741375) !== 0) || ((((_la - 349)) & ~0x1F) === 0 && ((1 << (_la - 349)) & 4026531839) !== 0) || ((((_la - 381)) & ~0x1F) === 0 && ((1 << (_la - 381)) & 1055907839) !== 0) || ((((_la - 413)) & ~0x1F) === 0 && ((1 << (_la - 413)) & 4294885367) !== 0) || ((((_la - 445)) & ~0x1F) === 0 && ((1 << (_la - 445)) & 3757571071) !== 0) || ((((_la - 478)) & ~0x1F) === 0 && ((1 << (_la - 478)) & 3755999231) !== 0) || ((((_la - 510)) & ~0x1F) === 0 && ((1 << (_la - 510)) & 3751780349) !== 0) || ((((_la - 542)) & ~0x1F) === 0 && ((1 << (_la - 542)) & 2141183997) !== 0) || ((((_la - 575)) & ~0x1F) === 0 && ((1 << (_la - 575)) & 2147483629) !== 0) || ((((_la - 633)) & ~0x1F) === 0 && ((1 << (_la - 633)) & 4294934527) !== 0) || ((((_la - 665)) & ~0x1F) === 0 && ((1 << (_la - 665)) & 4278189053) !== 0) || ((((_la - 697)) & ~0x1F) === 0 && ((1 << (_la - 697)) & 1644099327) !== 0) || ((((_la - 729)) & ~0x1F) === 0 && ((1 << (_la - 729)) & 4294900735) !== 0) || ((((_la - 761)) & ~0x1F) === 0 && ((1 << (_la - 761)) & 4294967295) !== 0) || ((((_la - 793)) & ~0x1F) === 0 && ((1 << (_la - 793)) & 4288675839) !== 0) || ((((_la - 825)) & ~0x1F) === 0 && ((1 << (_la - 825)) & 2147527671) !== 0) || ((((_la - 879)) & ~0x1F) === 0 && ((1 << (_la - 879)) & 1033) !== 0)) { + { + this.state = 1709; + this.indexName(); + } + } + this.state = 1712; + this.indexColumnNames(); + this.state = 1716; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 188 || _la === 194 || _la === 340 || _la === 435 || _la === 443 || _la === 686 || _la === 825 || _la === 833) { + { + { + this.state = 1713; + this.indexOption(); + } + } + this.state = 1718; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + break; + case 4: + this.enterOuterAlt(localContext, 4); + { + this.state = 1720; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 31) { + { + this.state = 1719; + this.constraintSymbol(); + } + } + this.state = 1722; + this.match(MySqlParser.KW_PRIMARY); + this.state = 1723; + this.match(MySqlParser.KW_KEY); + this.state = 1725; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 188) { + { + this.state = 1724; + this.indexType(); + } + } + this.state = 1727; + this.indexColumnNames(); + this.state = 1731; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 188 || _la === 194 || _la === 340 || _la === 435 || _la === 443 || _la === 686 || _la === 825 || _la === 833) { + { + { + this.state = 1728; + this.indexOption(); + } + } + this.state = 1733; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + break; + case 5: + this.enterOuterAlt(localContext, 5); + { + this.state = 1735; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 31) { + { + this.state = 1734; + this.constraintSymbol(); + } + } + this.state = 1737; + this.match(MySqlParser.KW_UNIQUE); + this.state = 1739; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 82 || _la === 92) { + { + this.state = 1738; + _la = this.tokenStream.LA(1); + if (!(_la === 82 || _la === 92)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + this.state = 1742; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if ((((_la) & ~0x1F) === 0 && ((1 << _la) & 1074302976) !== 0) || ((((_la - 36)) & ~0x1F) === 0 && ((1 << (_la - 36)) & 11014219) !== 0) || ((((_la - 74)) & ~0x1F) === 0 && ((1 << (_la - 74)) & 18878481) !== 0) || ((((_la - 117)) & ~0x1F) === 0 && ((1 << (_la - 117)) & 100679969) !== 0) || ((((_la - 150)) & ~0x1F) === 0 && ((1 << (_la - 150)) & 1049605) !== 0) || ((((_la - 219)) & ~0x1F) === 0 && ((1 << (_la - 219)) & 5374495) !== 0) || ((((_la - 253)) & ~0x1F) === 0 && ((1 << (_la - 253)) & 4294967295) !== 0) || ((((_la - 285)) & ~0x1F) === 0 && ((1 << (_la - 285)) & 4261412607) !== 0) || ((((_la - 317)) & ~0x1F) === 0 && ((1 << (_la - 317)) & 4160741375) !== 0) || ((((_la - 349)) & ~0x1F) === 0 && ((1 << (_la - 349)) & 4026531839) !== 0) || ((((_la - 381)) & ~0x1F) === 0 && ((1 << (_la - 381)) & 1055907839) !== 0) || ((((_la - 413)) & ~0x1F) === 0 && ((1 << (_la - 413)) & 4294885367) !== 0) || ((((_la - 445)) & ~0x1F) === 0 && ((1 << (_la - 445)) & 3757571071) !== 0) || ((((_la - 478)) & ~0x1F) === 0 && ((1 << (_la - 478)) & 3755999231) !== 0) || ((((_la - 510)) & ~0x1F) === 0 && ((1 << (_la - 510)) & 3751780349) !== 0) || ((((_la - 542)) & ~0x1F) === 0 && ((1 << (_la - 542)) & 2141183997) !== 0) || ((((_la - 575)) & ~0x1F) === 0 && ((1 << (_la - 575)) & 2147483629) !== 0) || ((((_la - 633)) & ~0x1F) === 0 && ((1 << (_la - 633)) & 4294934527) !== 0) || ((((_la - 665)) & ~0x1F) === 0 && ((1 << (_la - 665)) & 4278189053) !== 0) || ((((_la - 697)) & ~0x1F) === 0 && ((1 << (_la - 697)) & 1644099327) !== 0) || ((((_la - 729)) & ~0x1F) === 0 && ((1 << (_la - 729)) & 4294900735) !== 0) || ((((_la - 761)) & ~0x1F) === 0 && ((1 << (_la - 761)) & 4294967295) !== 0) || ((((_la - 793)) & ~0x1F) === 0 && ((1 << (_la - 793)) & 4288675839) !== 0) || ((((_la - 825)) & ~0x1F) === 0 && ((1 << (_la - 825)) & 2147527671) !== 0) || ((((_la - 879)) & ~0x1F) === 0 && ((1 << (_la - 879)) & 1033) !== 0)) { + { + this.state = 1741; + this.indexName(); + } + } + this.state = 1745; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 188) { + { + this.state = 1744; + this.indexType(); + } + } + this.state = 1747; + this.indexColumnNames(); + this.state = 1751; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 188 || _la === 194 || _la === 340 || _la === 435 || _la === 443 || _la === 686 || _la === 825 || _la === 833) { + { + { + this.state = 1748; + this.indexOption(); + } + } + this.state = 1753; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + break; + case 6: + this.enterOuterAlt(localContext, 6); + { + this.state = 1755; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 31) { + { + this.state = 1754; + this.constraintSymbol(); + } + } + this.state = 1757; + this.match(MySqlParser.KW_FOREIGN); + this.state = 1758; + this.match(MySqlParser.KW_KEY); + this.state = 1760; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if ((((_la) & ~0x1F) === 0 && ((1 << _la) & 1074302976) !== 0) || ((((_la - 36)) & ~0x1F) === 0 && ((1 << (_la - 36)) & 11014219) !== 0) || ((((_la - 74)) & ~0x1F) === 0 && ((1 << (_la - 74)) & 18878481) !== 0) || ((((_la - 117)) & ~0x1F) === 0 && ((1 << (_la - 117)) & 100679969) !== 0) || ((((_la - 150)) & ~0x1F) === 0 && ((1 << (_la - 150)) & 1049605) !== 0) || ((((_la - 219)) & ~0x1F) === 0 && ((1 << (_la - 219)) & 5374495) !== 0) || ((((_la - 253)) & ~0x1F) === 0 && ((1 << (_la - 253)) & 4294967295) !== 0) || ((((_la - 285)) & ~0x1F) === 0 && ((1 << (_la - 285)) & 4261412607) !== 0) || ((((_la - 317)) & ~0x1F) === 0 && ((1 << (_la - 317)) & 4160741375) !== 0) || ((((_la - 349)) & ~0x1F) === 0 && ((1 << (_la - 349)) & 4026531839) !== 0) || ((((_la - 381)) & ~0x1F) === 0 && ((1 << (_la - 381)) & 1055907839) !== 0) || ((((_la - 413)) & ~0x1F) === 0 && ((1 << (_la - 413)) & 4294885367) !== 0) || ((((_la - 445)) & ~0x1F) === 0 && ((1 << (_la - 445)) & 3757571071) !== 0) || ((((_la - 478)) & ~0x1F) === 0 && ((1 << (_la - 478)) & 3755999231) !== 0) || ((((_la - 510)) & ~0x1F) === 0 && ((1 << (_la - 510)) & 3751780349) !== 0) || ((((_la - 542)) & ~0x1F) === 0 && ((1 << (_la - 542)) & 2141183997) !== 0) || ((((_la - 575)) & ~0x1F) === 0 && ((1 << (_la - 575)) & 2147483629) !== 0) || ((((_la - 633)) & ~0x1F) === 0 && ((1 << (_la - 633)) & 4294934527) !== 0) || ((((_la - 665)) & ~0x1F) === 0 && ((1 << (_la - 665)) & 4278189053) !== 0) || ((((_la - 697)) & ~0x1F) === 0 && ((1 << (_la - 697)) & 1644099327) !== 0) || ((((_la - 729)) & ~0x1F) === 0 && ((1 << (_la - 729)) & 4294900735) !== 0) || ((((_la - 761)) & ~0x1F) === 0 && ((1 << (_la - 761)) & 4294967295) !== 0) || ((((_la - 793)) & ~0x1F) === 0 && ((1 << (_la - 793)) & 4288675839) !== 0) || ((((_la - 825)) & ~0x1F) === 0 && ((1 << (_la - 825)) & 2147527671) !== 0) || ((((_la - 879)) & ~0x1F) === 0 && ((1 << (_la - 879)) & 1033) !== 0)) { + { + this.state = 1759; + this.indexName(); + } + } + this.state = 1762; + this.indexColumnNames(); + this.state = 1763; + this.referenceDefinition(); + } + break; + case 7: + this.enterOuterAlt(localContext, 7); + { + this.state = 1765; + this.match(MySqlParser.KW_CHECK); + this.state = 1766; + this.match(MySqlParser.LR_BRACKET); + this.state = 1767; + this.expression(0); + this.state = 1768; + this.match(MySqlParser.RR_BRACKET); + } + break; + case 8: + this.enterOuterAlt(localContext, 8); + { + this.state = 1770; + this.checkConstraintDefinition(); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + checkConstraintDefinition() { + let localContext = new CheckConstraintDefinitionContext(this.context, this.state); + this.enterRule(localContext, 84, MySqlParser.RULE_checkConstraintDefinition); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 1774; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 31) { + { + this.state = 1773; + this.constraintSymbol(); + } + } + this.state = 1776; + this.match(MySqlParser.KW_CHECK); + this.state = 1777; + this.match(MySqlParser.LR_BRACKET); + this.state = 1778; + this.expression(0); + this.state = 1779; + this.match(MySqlParser.RR_BRACKET); + this.state = 1784; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 160, this.context)) { + case 1: + { + this.state = 1781; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 114) { + { + this.state = 1780; + this.match(MySqlParser.KW_NOT); + } + } + this.state = 1783; + this.match(MySqlParser.KW_ENFORCED); + } + break; + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + constraintSymbol() { + let localContext = new ConstraintSymbolContext(this.context, this.state); + this.enterRule(localContext, 86, MySqlParser.RULE_constraintSymbol); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 1786; + this.match(MySqlParser.KW_CONSTRAINT); + this.state = 1788; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 161, this.context)) { + case 1: + { + this.state = 1787; + localContext._symbol_ = this.uid(); + } + break; + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + columnDefinition() { + let localContext = new ColumnDefinitionContext(this.context, this.state); + this.enterRule(localContext, 88, MySqlParser.RULE_columnDefinition); + try { + let alternative; + this.enterOuterAlt(localContext, 1); + { + this.state = 1790; + this.dataType(); + this.state = 1794; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 162, this.context); + while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER) { + if (alternative === 1) { + { + { + this.state = 1791; + this.columnConstraint(); + } + } + } + this.state = 1796; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 162, this.context); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + columnConstraint() { + let localContext = new ColumnConstraintContext(this.context, this.state); + this.enterRule(localContext, 90, MySqlParser.RULE_columnConstraint); + let _la; + try { + this.state = 1840; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_NOT: + case MySqlParser.KW_NULL_LITERAL: + case MySqlParser.NULL_SPEC_LITERAL: + localContext = new NullColumnConstraintContext(localContext); + this.enterOuterAlt(localContext, 1); + { + this.state = 1797; + this.nullNotnull(); + } + break; + case MySqlParser.KW_DEFAULT: + localContext = new DefaultColumnConstraintContext(localContext); + this.enterOuterAlt(localContext, 2); + { + this.state = 1798; + this.match(MySqlParser.KW_DEFAULT); + this.state = 1799; + this.defaultValue(); + } + break; + case MySqlParser.KW_VISIBLE: + localContext = new VisibilityColumnConstraintContext(localContext); + this.enterOuterAlt(localContext, 3); + { + this.state = 1800; + this.match(MySqlParser.KW_VISIBLE); + } + break; + case MySqlParser.KW_INVISIBLE: + localContext = new InvisibilityColumnConstraintContext(localContext); + this.enterOuterAlt(localContext, 4); + { + this.state = 1801; + this.match(MySqlParser.KW_INVISIBLE); + } + break; + case MySqlParser.KW_ON: + case MySqlParser.KW_AUTO_INCREMENT: + localContext = new AutoIncrementColumnConstraintContext(localContext); + this.enterOuterAlt(localContext, 5); + { + this.state = 1806; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_AUTO_INCREMENT: + { + this.state = 1802; + this.match(MySqlParser.KW_AUTO_INCREMENT); + } + break; + case MySqlParser.KW_ON: + { + this.state = 1803; + this.match(MySqlParser.KW_ON); + this.state = 1804; + this.match(MySqlParser.KW_UPDATE); + this.state = 1805; + this.currentTimestamp(); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + break; + case MySqlParser.KW_KEY: + case MySqlParser.KW_PRIMARY: + localContext = new PrimaryKeyColumnConstraintContext(localContext); + this.enterOuterAlt(localContext, 6); + { + this.state = 1809; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 131) { + { + this.state = 1808; + this.match(MySqlParser.KW_PRIMARY); + } + } + this.state = 1811; + this.match(MySqlParser.KW_KEY); + } + break; + case MySqlParser.KW_UNIQUE: + localContext = new UniqueKeyColumnConstraintContext(localContext); + this.enterOuterAlt(localContext, 7); + { + this.state = 1812; + this.match(MySqlParser.KW_UNIQUE); + this.state = 1814; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 165, this.context)) { + case 1: + { + this.state = 1813; + this.match(MySqlParser.KW_KEY); + } + break; + } + } + break; + case MySqlParser.KW_COMMENT: + localContext = new CommentColumnConstraintContext(localContext); + this.enterOuterAlt(localContext, 8); + { + this.state = 1816; + this.match(MySqlParser.KW_COMMENT); + this.state = 1817; + this.match(MySqlParser.STRING_LITERAL); + } + break; + case MySqlParser.KW_COLUMN_FORMAT: + localContext = new FormatColumnConstraintContext(localContext); + this.enterOuterAlt(localContext, 9); + { + this.state = 1818; + this.match(MySqlParser.KW_COLUMN_FORMAT); + this.state = 1819; + localContext._colformat = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 42 || _la === 374 || _la === 403)) { + localContext._colformat = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + break; + case MySqlParser.KW_STORAGE: + localContext = new StorageColumnConstraintContext(localContext); + this.enterOuterAlt(localContext, 10); + { + this.state = 1820; + this.match(MySqlParser.KW_STORAGE); + this.state = 1821; + localContext._storageval = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 42 || _la === 370 || _la === 802)) { + localContext._storageval = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + break; + case MySqlParser.KW_REFERENCES: + localContext = new ReferenceColumnConstraintContext(localContext); + this.enterOuterAlt(localContext, 11); + { + this.state = 1822; + this.referenceDefinition(); + } + break; + case MySqlParser.KW_COLLATE: + localContext = new CollateColumnConstraintContext(localContext); + this.enterOuterAlt(localContext, 12); + { + this.state = 1823; + this.match(MySqlParser.KW_COLLATE); + this.state = 1824; + this.collationName(); + } + break; + case MySqlParser.KW_AS: + case MySqlParser.KW_GENERATED: + localContext = new GeneratedColumnConstraintContext(localContext); + this.enterOuterAlt(localContext, 13); + { + this.state = 1827; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 71) { + { + this.state = 1825; + this.match(MySqlParser.KW_GENERATED); + this.state = 1826; + this.match(MySqlParser.KW_ALWAYS); + } + } + this.state = 1829; + this.match(MySqlParser.KW_AS); + this.state = 1830; + this.match(MySqlParser.LR_BRACKET); + this.state = 1831; + this.expression(0); + this.state = 1832; + this.match(MySqlParser.RR_BRACKET); + this.state = 1834; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 648 || _la === 685) { + { + this.state = 1833; + _la = this.tokenStream.LA(1); + if (!(_la === 648 || _la === 685)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + } + break; + case MySqlParser.KW_SERIAL: + localContext = new SerialDefaultColumnConstraintContext(localContext); + this.enterOuterAlt(localContext, 14); + { + this.state = 1836; + this.match(MySqlParser.KW_SERIAL); + this.state = 1837; + this.match(MySqlParser.KW_DEFAULT); + this.state = 1838; + this.match(MySqlParser.KW_VALUE); + } + break; + case MySqlParser.KW_CHECK: + case MySqlParser.KW_CONSTRAINT: + localContext = new CheckExprContext(localContext); + this.enterOuterAlt(localContext, 15); + { + this.state = 1839; + this.checkConstraintDefinition(); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + referenceDefinition() { + let localContext = new ReferenceDefinitionContext(this.context, this.state); + this.enterRule(localContext, 92, MySqlParser.RULE_referenceDefinition); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 1842; + this.match(MySqlParser.KW_REFERENCES); + this.state = 1843; + this.tableName(); + this.state = 1845; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 169, this.context)) { + case 1: + { + this.state = 1844; + this.indexColumnNames(); + } + break; + } + this.state = 1849; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 110) { + { + this.state = 1847; + this.match(MySqlParser.KW_MATCH); + this.state = 1848; + localContext._matchType = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 408 || _la === 526 || _la === 597)) { + localContext._matchType = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + this.state = 1852; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 171, this.context)) { + case 1: + { + this.state = 1851; + this.referenceAction(); + } + break; + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + referenceAction() { + let localContext = new ReferenceActionContext(this.context, this.state); + this.enterRule(localContext, 94, MySqlParser.RULE_referenceAction); + try { + this.state = 1870; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 174, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 1854; + this.match(MySqlParser.KW_ON); + this.state = 1855; + this.match(MySqlParser.KW_DELETE); + this.state = 1856; + localContext._onDelete = this.referenceControlType(); + this.state = 1860; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 172, this.context)) { + case 1: + { + this.state = 1857; + this.match(MySqlParser.KW_ON); + this.state = 1858; + this.match(MySqlParser.KW_UPDATE); + this.state = 1859; + localContext._onUpdate = this.referenceControlType(); + } + break; + } + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 1862; + this.match(MySqlParser.KW_ON); + this.state = 1863; + this.match(MySqlParser.KW_UPDATE); + this.state = 1864; + localContext._onUpdate = this.referenceControlType(); + this.state = 1868; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 173, this.context)) { + case 1: + { + this.state = 1865; + this.match(MySqlParser.KW_ON); + this.state = 1866; + this.match(MySqlParser.KW_DELETE); + this.state = 1867; + localContext._onDelete = this.referenceControlType(); + } + break; + } + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + referenceControlType() { + let localContext = new ReferenceControlTypeContext(this.context, this.state); + this.enterRule(localContext, 96, MySqlParser.RULE_referenceControlType); + try { + this.state = 1880; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 175, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 1872; + this.match(MySqlParser.KW_RESTRICT); + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 1873; + this.match(MySqlParser.KW_CASCADE); + } + break; + case 3: + this.enterOuterAlt(localContext, 3); + { + this.state = 1874; + this.match(MySqlParser.KW_SET); + this.state = 1875; + this.match(MySqlParser.KW_NULL_LITERAL); + } + break; + case 4: + this.enterOuterAlt(localContext, 4); + { + this.state = 1876; + this.match(MySqlParser.KW_NO); + this.state = 1877; + this.match(MySqlParser.KW_ACTION); + } + break; + case 5: + this.enterOuterAlt(localContext, 5); + { + this.state = 1878; + this.match(MySqlParser.KW_SET); + this.state = 1879; + this.match(MySqlParser.KW_DEFAULT); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + tableOption() { + let localContext = new TableOptionContext(this.context, this.state); + this.enterRule(localContext, 98, MySqlParser.RULE_tableOption); + let _la; + try { + this.state = 2067; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 213, this.context)) { + case 1: + localContext = new TableOptionEngineContext(localContext); + this.enterOuterAlt(localContext, 1); + { + this.state = 1882; + this.match(MySqlParser.KW_ENGINE); + this.state = 1884; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 1883; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 1887; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 177, this.context)) { + case 1: + { + this.state = 1886; + this.engineName(); + } + break; + } + } + break; + case 2: + localContext = new TableOptionEngineAttributeContext(localContext); + this.enterOuterAlt(localContext, 2); + { + this.state = 1889; + this.match(MySqlParser.KW_ENGINE_ATTRIBUTE); + this.state = 1891; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 1890; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 1893; + this.match(MySqlParser.STRING_LITERAL); + } + break; + case 3: + localContext = new TableOptionAutoextendSizeContext(localContext); + this.enterOuterAlt(localContext, 3); + { + this.state = 1894; + this.match(MySqlParser.KW_AUTOEXTEND_SIZE); + this.state = 1896; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 1895; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 1898; + this.decimalLiteral(); + } + break; + case 4: + localContext = new TableOptionAutoIncrementContext(localContext); + this.enterOuterAlt(localContext, 4); + { + this.state = 1899; + this.match(MySqlParser.KW_AUTO_INCREMENT); + this.state = 1901; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 1900; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 1903; + this.decimalLiteral(); + } + break; + case 5: + localContext = new TableOptionAverageContext(localContext); + this.enterOuterAlt(localContext, 5); + { + this.state = 1904; + this.match(MySqlParser.KW_AVG_ROW_LENGTH); + this.state = 1906; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 1905; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 1908; + this.decimalLiteral(); + } + break; + case 6: + localContext = new TableOptionCharsetContext(localContext); + this.enterOuterAlt(localContext, 6); + { + this.state = 1910; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 42) { + { + this.state = 1909; + this.match(MySqlParser.KW_DEFAULT); + } + } + this.state = 1912; + this.charSet(); + this.state = 1914; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 1913; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 1918; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_BINARY: + case MySqlParser.KW_ARMSCII8: + case MySqlParser.KW_ASCII: + case MySqlParser.KW_BIG5: + case MySqlParser.KW_CP1250: + case MySqlParser.KW_CP1251: + case MySqlParser.KW_CP1256: + case MySqlParser.KW_CP1257: + case MySqlParser.KW_CP850: + case MySqlParser.KW_CP852: + case MySqlParser.KW_CP866: + case MySqlParser.KW_CP932: + case MySqlParser.KW_DEC8: + case MySqlParser.KW_EUCJPMS: + case MySqlParser.KW_EUCKR: + case MySqlParser.KW_GB18030: + case MySqlParser.KW_GB2312: + case MySqlParser.KW_GBK: + case MySqlParser.KW_GEOSTD8: + case MySqlParser.KW_GREEK: + case MySqlParser.KW_HEBREW: + case MySqlParser.KW_HP8: + case MySqlParser.KW_KEYBCS2: + case MySqlParser.KW_KOI8R: + case MySqlParser.KW_KOI8U: + case MySqlParser.KW_LATIN1: + case MySqlParser.KW_LATIN2: + case MySqlParser.KW_LATIN5: + case MySqlParser.KW_LATIN7: + case MySqlParser.KW_MACCE: + case MySqlParser.KW_MACROMAN: + case MySqlParser.KW_SJIS: + case MySqlParser.KW_SWE7: + case MySqlParser.KW_TIS620: + case MySqlParser.KW_UCS2: + case MySqlParser.KW_UJIS: + case MySqlParser.KW_UTF16: + case MySqlParser.KW_UTF16LE: + case MySqlParser.KW_UTF32: + case MySqlParser.KW_UTF8: + case MySqlParser.KW_UTF8MB3: + case MySqlParser.KW_UTF8MB4: + case MySqlParser.CHARSET_REVERSE_QOUTE_STRING: + case MySqlParser.STRING_LITERAL: + { + this.state = 1916; + this.charsetName(); + } + break; + case MySqlParser.KW_DEFAULT: + { + this.state = 1917; + this.match(MySqlParser.KW_DEFAULT); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + break; + case 7: + localContext = new TableOptionChecksumContext(localContext); + this.enterOuterAlt(localContext, 7); + { + this.state = 1920; + _la = this.tokenStream.LA(1); + if (!(_la === 329 || _la === 522)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 1922; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 1921; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 1924; + localContext._boolValue = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 871 || _la === 872)) { + localContext._boolValue = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + break; + case 8: + localContext = new TableOptionCollateContext(localContext); + this.enterOuterAlt(localContext, 8); + { + this.state = 1926; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 42) { + { + this.state = 1925; + this.match(MySqlParser.KW_DEFAULT); + } + } + this.state = 1928; + this.match(MySqlParser.KW_COLLATE); + this.state = 1930; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 1929; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 1932; + this.collationName(); + } + break; + case 9: + localContext = new TableOptionCommentContext(localContext); + this.enterOuterAlt(localContext, 9); + { + this.state = 1933; + this.match(MySqlParser.KW_COMMENT); + this.state = 1935; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 1934; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 1937; + this.match(MySqlParser.STRING_LITERAL); + } + break; + case 10: + localContext = new TableOptionCompressionContext(localContext); + this.enterOuterAlt(localContext, 10); + { + this.state = 1938; + this.match(MySqlParser.KW_COMPRESSION); + this.state = 1940; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 1939; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 1942; + _la = this.tokenStream.LA(1); + if (!(_la === 882 || _la === 889)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + break; + case 11: + localContext = new TableOptionConnectionContext(localContext); + this.enterOuterAlt(localContext, 11); + { + this.state = 1943; + this.match(MySqlParser.KW_CONNECTION); + this.state = 1945; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 1944; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 1947; + this.match(MySqlParser.STRING_LITERAL); + } + break; + case 12: + localContext = new TableOptionDataDirectoryContext(localContext); + this.enterOuterAlt(localContext, 12); + { + this.state = 1948; + _la = this.tokenStream.LA(1); + if (!(_la === 82 || _la === 360)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 1949; + this.match(MySqlParser.KW_DIRECTORY); + this.state = 1951; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 1950; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 1953; + this.match(MySqlParser.STRING_LITERAL); + } + break; + case 13: + localContext = new TableOptionDelayContext(localContext); + this.enterOuterAlt(localContext, 13); + { + this.state = 1954; + this.match(MySqlParser.KW_DELAY_KEY_WRITE); + this.state = 1956; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 1955; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 1958; + localContext._boolValue = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 871 || _la === 872)) { + localContext._boolValue = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + break; + case 14: + localContext = new TableOptionEncryptionContext(localContext); + this.enterOuterAlt(localContext, 14); + { + this.state = 1959; + this.match(MySqlParser.KW_ENCRYPTION); + this.state = 1961; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 1960; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 1963; + this.match(MySqlParser.STRING_LITERAL); + } + break; + case 15: + localContext = new TableOptionPageCompressedContext(localContext); + this.enterOuterAlt(localContext, 15); + { + this.state = 1964; + _la = this.tokenStream.LA(1); + if (!(_la === 523 || _la === 882)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 1966; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 1965; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 1968; + _la = this.tokenStream.LA(1); + if (!(_la === 871 || _la === 872)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + break; + case 16: + localContext = new TableOptionPageCompressionLevelContext(localContext); + this.enterOuterAlt(localContext, 16); + { + this.state = 1969; + _la = this.tokenStream.LA(1); + if (!(_la === 524 || _la === 882)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 1971; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 1970; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 1973; + this.decimalLiteral(); + } + break; + case 17: + localContext = new TableOptionEncryptionKeyIdContext(localContext); + this.enterOuterAlt(localContext, 17); + { + this.state = 1974; + this.match(MySqlParser.KW_ENCRYPTION_KEY_ID); + this.state = 1976; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 1975; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 1978; + this.decimalLiteral(); + } + break; + case 18: + localContext = new TableOptionIndexDirectoryContext(localContext); + this.enterOuterAlt(localContext, 18); + { + this.state = 1979; + this.match(MySqlParser.KW_INDEX); + this.state = 1980; + this.match(MySqlParser.KW_DIRECTORY); + this.state = 1982; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 1981; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 1984; + this.match(MySqlParser.STRING_LITERAL); + } + break; + case 19: + localContext = new TableOptionInsertMethodContext(localContext); + this.enterOuterAlt(localContext, 19); + { + this.state = 1985; + this.match(MySqlParser.KW_INSERT_METHOD); + this.state = 1987; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 1986; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 1989; + localContext._insertMethod = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 402 || _la === 445 || _la === 502)) { + localContext._insertMethod = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + break; + case 20: + localContext = new TableOptionKeyBlockSizeContext(localContext); + this.enterOuterAlt(localContext, 20); + { + this.state = 1990; + this.match(MySqlParser.KW_KEY_BLOCK_SIZE); + this.state = 1992; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 1991; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 1994; + this.fileSizeLiteral(); + } + break; + case 21: + localContext = new TableOptionMaxRowsContext(localContext); + this.enterOuterAlt(localContext, 21); + { + this.state = 1995; + this.match(MySqlParser.KW_MAX_ROWS); + this.state = 1997; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 1996; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 1999; + this.decimalLiteral(); + } + break; + case 22: + localContext = new TableOptionMinRowsContext(localContext); + this.enterOuterAlt(localContext, 22); + { + this.state = 2000; + this.match(MySqlParser.KW_MIN_ROWS); + this.state = 2002; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 2001; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 2004; + this.decimalLiteral(); + } + break; + case 23: + localContext = new TableOptionPackKeysContext(localContext); + this.enterOuterAlt(localContext, 23); + { + this.state = 2005; + this.match(MySqlParser.KW_PACK_KEYS); + this.state = 2007; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 2006; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 2009; + localContext._extBoolValue = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 42 || _la === 871 || _la === 872)) { + localContext._extBoolValue = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + break; + case 24: + localContext = new TableOptionPasswordContext(localContext); + this.enterOuterAlt(localContext, 24); + { + this.state = 2010; + this.match(MySqlParser.KW_PASSWORD); + this.state = 2012; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 2011; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 2014; + this.match(MySqlParser.STRING_LITERAL); + } + break; + case 25: + localContext = new TableOptionRowFormatContext(localContext); + this.enterOuterAlt(localContext, 25); + { + this.state = 2015; + this.match(MySqlParser.KW_ROW_FORMAT); + this.state = 2017; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 2016; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 2019; + localContext._rowFormat = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 42 || _la === 342 || _la === 345 || _la === 374 || _la === 403 || _la === 554 || _la === 889)) { + localContext._rowFormat = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + break; + case 26: + localContext = new TableOptionStartTransactionContext(localContext); + this.enterOuterAlt(localContext, 26); + { + this.state = 2020; + this.match(MySqlParser.KW_START); + this.state = 2021; + this.match(MySqlParser.KW_TRANSACTION); + } + break; + case 27: + localContext = new TableOptionSecondaryEngineAttributeContext(localContext); + this.enterOuterAlt(localContext, 27); + { + this.state = 2022; + this.match(MySqlParser.KW_SECONDARY_ENGINE_ATTRIBUTE); + this.state = 2024; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 2023; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 2026; + this.match(MySqlParser.STRING_LITERAL); + } + break; + case 28: + localContext = new TableOptionRecalculationContext(localContext); + this.enterOuterAlt(localContext, 28); + { + this.state = 2027; + this.match(MySqlParser.KW_STATS_AUTO_RECALC); + this.state = 2029; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 2028; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 2031; + localContext._extBoolValue = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 42 || _la === 871 || _la === 872)) { + localContext._extBoolValue = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + break; + case 29: + localContext = new TableOptionPersistentContext(localContext); + this.enterOuterAlt(localContext, 29); + { + this.state = 2032; + this.match(MySqlParser.KW_STATS_PERSISTENT); + this.state = 2034; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 2033; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 2036; + localContext._extBoolValue = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 42 || _la === 871 || _la === 872)) { + localContext._extBoolValue = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + break; + case 30: + localContext = new TableOptionSamplePageContext(localContext); + this.enterOuterAlt(localContext, 30); + { + this.state = 2037; + this.match(MySqlParser.KW_STATS_SAMPLE_PAGES); + this.state = 2039; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 2038; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 2043; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_DEFAULT: + { + this.state = 2041; + this.match(MySqlParser.KW_DEFAULT); + } + break; + case MySqlParser.ZERO_DECIMAL: + case MySqlParser.ONE_DECIMAL: + case MySqlParser.TWO_DECIMAL: + case MySqlParser.THREE_DECIMAL: + case MySqlParser.DECIMAL_LITERAL: + case MySqlParser.REAL_LITERAL: + { + this.state = 2042; + this.decimalLiteral(); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + break; + case 31: + localContext = new TableOptionTablespaceContext(localContext); + this.enterOuterAlt(localContext, 31); + { + this.state = 2045; + this.match(MySqlParser.KW_TABLESPACE); + this.state = 2046; + this.tablespaceName(); + this.state = 2048; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 210, this.context)) { + case 1: + { + this.state = 2047; + this.tablespaceStorage(); + } + break; + } + } + break; + case 32: + localContext = new TableOptionTableTypeContext(localContext); + this.enterOuterAlt(localContext, 32); + { + this.state = 2050; + this.match(MySqlParser.KW_TABLE_TYPE); + this.state = 2051; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 2052; + this.tableType(); + } + break; + case 33: + localContext = new TableOptionTablespaceContext(localContext); + this.enterOuterAlt(localContext, 33); + { + this.state = 2053; + this.tablespaceStorage(); + } + break; + case 34: + localContext = new TableOptionTransactionalContext(localContext); + this.enterOuterAlt(localContext, 34); + { + this.state = 2054; + this.match(MySqlParser.KW_TRANSACTIONAL); + this.state = 2056; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 2055; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 2058; + _la = this.tokenStream.LA(1); + if (!(_la === 871 || _la === 872)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + break; + case 35: + localContext = new TableOptionUnionContext(localContext); + this.enterOuterAlt(localContext, 35); + { + this.state = 2059; + this.match(MySqlParser.KW_UNION); + this.state = 2061; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 2060; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 2063; + this.match(MySqlParser.LR_BRACKET); + this.state = 2064; + this.tableNames(); + this.state = 2065; + this.match(MySqlParser.RR_BRACKET); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + tableType() { + let localContext = new TableTypeContext(this.context, this.state); + this.enterRule(localContext, 100, MySqlParser.RULE_tableType); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 2069; + _la = this.tokenStream.LA(1); + if (!(_la === 494 || _la === 506)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + tablespaceStorage() { + let localContext = new TablespaceStorageContext(this.context, this.state); + this.enterRule(localContext, 102, MySqlParser.RULE_tablespaceStorage); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 2071; + this.match(MySqlParser.KW_STORAGE); + this.state = 2072; + _la = this.tokenStream.LA(1); + if (!(_la === 42 || _la === 370 || _la === 802)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + partitionDefinitions() { + let localContext = new PartitionDefinitionsContext(this.context, this.state); + this.enterRule(localContext, 104, MySqlParser.RULE_partitionDefinitions); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 2074; + this.match(MySqlParser.KW_PARTITION); + this.state = 2075; + this.match(MySqlParser.KW_BY); + this.state = 2076; + this.partitionFunctionDefinition(); + this.state = 2079; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 528) { + { + this.state = 2077; + this.match(MySqlParser.KW_PARTITIONS); + this.state = 2078; + localContext._count = this.decimalLiteral(); + } + } + this.state = 2088; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 652) { + { + this.state = 2081; + this.match(MySqlParser.KW_SUBPARTITION); + this.state = 2082; + this.match(MySqlParser.KW_BY); + this.state = 2083; + this.subpartitionFunctionDefinition(); + this.state = 2086; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 653) { + { + this.state = 2084; + this.match(MySqlParser.KW_SUBPARTITIONS); + this.state = 2085; + localContext._subCount = this.decimalLiteral(); + } + } + } + } + this.state = 2101; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 218, this.context)) { + case 1: + { + this.state = 2090; + this.match(MySqlParser.LR_BRACKET); + this.state = 2091; + this.partitionDefinition(); + this.state = 2096; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 2092; + this.match(MySqlParser.COMMA); + this.state = 2093; + this.partitionDefinition(); + } + } + this.state = 2098; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 2099; + this.match(MySqlParser.RR_BRACKET); + } + break; + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + partitionFunctionDefinition() { + let localContext = new PartitionFunctionDefinitionContext(this.context, this.state); + this.enterRule(localContext, 106, MySqlParser.RULE_partitionFunctionDefinition); + let _la; + try { + this.state = 2149; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 225, this.context)) { + case 1: + localContext = new PartitionFunctionHashContext(localContext); + this.enterOuterAlt(localContext, 1); + { + this.state = 2104; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 101) { + { + this.state = 2103; + this.match(MySqlParser.KW_LINEAR); + } + } + this.state = 2106; + this.match(MySqlParser.KW_HASH); + this.state = 2107; + this.match(MySqlParser.LR_BRACKET); + this.state = 2108; + this.expression(0); + this.state = 2109; + this.match(MySqlParser.RR_BRACKET); + } + break; + case 2: + localContext = new PartitionFunctionKeyContext(localContext); + this.enterOuterAlt(localContext, 2); + { + this.state = 2112; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 101) { + { + this.state = 2111; + this.match(MySqlParser.KW_LINEAR); + } + } + this.state = 2114; + this.match(MySqlParser.KW_KEY); + this.state = 2118; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 308) { + { + this.state = 2115; + this.match(MySqlParser.KW_ALGORITHM); + this.state = 2116; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 2117; + localContext._algType = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 872 || _la === 873)) { + localContext._algType = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + this.state = 2120; + this.match(MySqlParser.LR_BRACKET); + this.state = 2122; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 222, this.context)) { + case 1: + { + this.state = 2121; + this.columnNames(); + } + break; + } + this.state = 2124; + this.match(MySqlParser.RR_BRACKET); + } + break; + case 3: + localContext = new PartitionFunctionRangeContext(localContext); + this.enterOuterAlt(localContext, 3); + { + this.state = 2125; + this.match(MySqlParser.KW_RANGE); + this.state = 2135; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.LR_BRACKET: + { + this.state = 2126; + this.match(MySqlParser.LR_BRACKET); + this.state = 2127; + this.expression(0); + this.state = 2128; + this.match(MySqlParser.RR_BRACKET); + } + break; + case MySqlParser.KW_COLUMNS: + { + this.state = 2130; + this.match(MySqlParser.KW_COLUMNS); + this.state = 2131; + this.match(MySqlParser.LR_BRACKET); + this.state = 2132; + this.columnNames(); + this.state = 2133; + this.match(MySqlParser.RR_BRACKET); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + break; + case 4: + localContext = new PartitionFunctionListContext(localContext); + this.enterOuterAlt(localContext, 4); + { + this.state = 2137; + this.match(MySqlParser.KW_LIST); + this.state = 2147; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.LR_BRACKET: + { + this.state = 2138; + this.match(MySqlParser.LR_BRACKET); + this.state = 2139; + this.expression(0); + this.state = 2140; + this.match(MySqlParser.RR_BRACKET); + } + break; + case MySqlParser.KW_COLUMNS: + { + this.state = 2142; + this.match(MySqlParser.KW_COLUMNS); + this.state = 2143; + this.match(MySqlParser.LR_BRACKET); + this.state = 2144; + this.columnNames(); + this.state = 2145; + this.match(MySqlParser.RR_BRACKET); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + subpartitionFunctionDefinition() { + let localContext = new SubpartitionFunctionDefinitionContext(this.context, this.state); + this.enterRule(localContext, 108, MySqlParser.RULE_subpartitionFunctionDefinition); + let _la; + try { + this.state = 2172; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 229, this.context)) { + case 1: + localContext = new SubPartitionFunctionHashContext(localContext); + this.enterOuterAlt(localContext, 1); + { + this.state = 2152; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 101) { + { + this.state = 2151; + this.match(MySqlParser.KW_LINEAR); + } + } + this.state = 2154; + this.match(MySqlParser.KW_HASH); + this.state = 2155; + this.match(MySqlParser.LR_BRACKET); + this.state = 2156; + this.expression(0); + this.state = 2157; + this.match(MySqlParser.RR_BRACKET); + } + break; + case 2: + localContext = new SubPartitionFunctionKeyContext(localContext); + this.enterOuterAlt(localContext, 2); + { + this.state = 2160; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 101) { + { + this.state = 2159; + this.match(MySqlParser.KW_LINEAR); + } + } + this.state = 2162; + this.match(MySqlParser.KW_KEY); + this.state = 2166; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 308) { + { + this.state = 2163; + this.match(MySqlParser.KW_ALGORITHM); + this.state = 2164; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 2165; + localContext._algType = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 872 || _la === 873)) { + localContext._algType = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + this.state = 2168; + this.match(MySqlParser.LR_BRACKET); + this.state = 2169; + this.columnNames(); + this.state = 2170; + this.match(MySqlParser.RR_BRACKET); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + partitionDefinition() { + let localContext = new PartitionDefinitionContext(this.context, this.state); + this.enterRule(localContext, 110, MySqlParser.RULE_partitionDefinition); + let _la; + try { + this.state = 2320; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 248, this.context)) { + case 1: + localContext = new PartitionComparisonContext(localContext); + this.enterOuterAlt(localContext, 1); + { + this.state = 2174; + this.match(MySqlParser.KW_PARTITION); + this.state = 2175; + this.partitionName(); + this.state = 2176; + this.match(MySqlParser.KW_VALUES); + this.state = 2177; + this.match(MySqlParser.KW_LESS); + this.state = 2178; + this.match(MySqlParser.KW_THAN); + this.state = 2179; + this.match(MySqlParser.LR_BRACKET); + this.state = 2180; + this.partitionDefinerAtom(); + this.state = 2185; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 2181; + this.match(MySqlParser.COMMA); + this.state = 2182; + this.partitionDefinerAtom(); + } + } + this.state = 2187; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 2188; + this.match(MySqlParser.RR_BRACKET); + this.state = 2192; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 42 || _la === 82 || _la === 340 || _la === 360 || _la === 380 || ((((_la - 480)) & ~0x1F) === 0 && ((1 << (_la - 480)) & 16778241) !== 0) || _la === 647 || _la === 658) { + { + { + this.state = 2189; + this.partitionOption(); + } + } + this.state = 2194; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 2206; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 866) { + { + this.state = 2195; + this.match(MySqlParser.LR_BRACKET); + this.state = 2196; + this.subpartitionDefinition(); + this.state = 2201; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 2197; + this.match(MySqlParser.COMMA); + this.state = 2198; + this.subpartitionDefinition(); + } + } + this.state = 2203; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 2204; + this.match(MySqlParser.RR_BRACKET); + } + } + } + break; + case 2: + localContext = new PartitionComparisonContext(localContext); + this.enterOuterAlt(localContext, 2); + { + this.state = 2208; + this.match(MySqlParser.KW_PARTITION); + this.state = 2209; + this.partitionName(); + this.state = 2210; + this.match(MySqlParser.KW_VALUES); + this.state = 2211; + this.match(MySqlParser.KW_LESS); + this.state = 2212; + this.match(MySqlParser.KW_THAN); + this.state = 2213; + this.partitionDefinerAtom(); + this.state = 2217; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 42 || _la === 82 || _la === 340 || _la === 360 || _la === 380 || ((((_la - 480)) & ~0x1F) === 0 && ((1 << (_la - 480)) & 16778241) !== 0) || _la === 647 || _la === 658) { + { + { + this.state = 2214; + this.partitionOption(); + } + } + this.state = 2219; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 2231; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 866) { + { + this.state = 2220; + this.match(MySqlParser.LR_BRACKET); + this.state = 2221; + this.subpartitionDefinition(); + this.state = 2226; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 2222; + this.match(MySqlParser.COMMA); + this.state = 2223; + this.subpartitionDefinition(); + } + } + this.state = 2228; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 2229; + this.match(MySqlParser.RR_BRACKET); + } + } + } + break; + case 3: + localContext = new PartitionListAtomContext(localContext); + this.enterOuterAlt(localContext, 3); + { + this.state = 2233; + this.match(MySqlParser.KW_PARTITION); + this.state = 2234; + this.partitionName(); + this.state = 2235; + this.match(MySqlParser.KW_VALUES); + this.state = 2236; + this.match(MySqlParser.KW_IN); + this.state = 2237; + this.match(MySqlParser.LR_BRACKET); + this.state = 2238; + this.partitionDefinerAtom(); + this.state = 2243; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 2239; + this.match(MySqlParser.COMMA); + this.state = 2240; + this.partitionDefinerAtom(); + } + } + this.state = 2245; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 2246; + this.match(MySqlParser.RR_BRACKET); + this.state = 2250; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 42 || _la === 82 || _la === 340 || _la === 360 || _la === 380 || ((((_la - 480)) & ~0x1F) === 0 && ((1 << (_la - 480)) & 16778241) !== 0) || _la === 647 || _la === 658) { + { + { + this.state = 2247; + this.partitionOption(); + } + } + this.state = 2252; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 2264; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 866) { + { + this.state = 2253; + this.match(MySqlParser.LR_BRACKET); + this.state = 2254; + this.subpartitionDefinition(); + this.state = 2259; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 2255; + this.match(MySqlParser.COMMA); + this.state = 2256; + this.subpartitionDefinition(); + } + } + this.state = 2261; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 2262; + this.match(MySqlParser.RR_BRACKET); + } + } + } + break; + case 4: + localContext = new PartitionListVectorContext(localContext); + this.enterOuterAlt(localContext, 4); + { + this.state = 2266; + this.match(MySqlParser.KW_PARTITION); + this.state = 2267; + this.partitionName(); + this.state = 2268; + this.match(MySqlParser.KW_VALUES); + this.state = 2269; + this.match(MySqlParser.KW_IN); + this.state = 2270; + this.match(MySqlParser.LR_BRACKET); + this.state = 2271; + this.partitionDefinerVector(); + this.state = 2276; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 2272; + this.match(MySqlParser.COMMA); + this.state = 2273; + this.partitionDefinerVector(); + } + } + this.state = 2278; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 2279; + this.match(MySqlParser.RR_BRACKET); + this.state = 2283; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 42 || _la === 82 || _la === 340 || _la === 360 || _la === 380 || ((((_la - 480)) & ~0x1F) === 0 && ((1 << (_la - 480)) & 16778241) !== 0) || _la === 647 || _la === 658) { + { + { + this.state = 2280; + this.partitionOption(); + } + } + this.state = 2285; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 2297; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 866) { + { + this.state = 2286; + this.match(MySqlParser.LR_BRACKET); + this.state = 2287; + this.subpartitionDefinition(); + this.state = 2292; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 2288; + this.match(MySqlParser.COMMA); + this.state = 2289; + this.subpartitionDefinition(); + } + } + this.state = 2294; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 2295; + this.match(MySqlParser.RR_BRACKET); + } + } + } + break; + case 5: + localContext = new PartitionSimpleContext(localContext); + this.enterOuterAlt(localContext, 5); + { + this.state = 2299; + this.match(MySqlParser.KW_PARTITION); + this.state = 2300; + this.partitionName(); + this.state = 2304; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 42 || _la === 82 || _la === 340 || _la === 360 || _la === 380 || ((((_la - 480)) & ~0x1F) === 0 && ((1 << (_la - 480)) & 16778241) !== 0) || _la === 647 || _la === 658) { + { + { + this.state = 2301; + this.partitionOption(); + } + } + this.state = 2306; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 2318; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 866) { + { + this.state = 2307; + this.match(MySqlParser.LR_BRACKET); + this.state = 2308; + this.subpartitionDefinition(); + this.state = 2313; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 2309; + this.match(MySqlParser.COMMA); + this.state = 2310; + this.subpartitionDefinition(); + } + } + this.state = 2315; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 2316; + this.match(MySqlParser.RR_BRACKET); + } + } + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + partitionDefinerAtom() { + let localContext = new PartitionDefinerAtomContext(this.context, this.state); + this.enterRule(localContext, 112, MySqlParser.RULE_partitionDefinerAtom); + try { + this.state = 2325; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 249, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 2322; + this.constant(); + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 2323; + this.expression(0); + } + break; + case 3: + this.enterOuterAlt(localContext, 3); + { + this.state = 2324; + this.match(MySqlParser.KW_MAXVALUE); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + partitionDefinerVector() { + let localContext = new PartitionDefinerVectorContext(this.context, this.state); + this.enterRule(localContext, 114, MySqlParser.RULE_partitionDefinerVector); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 2327; + this.match(MySqlParser.LR_BRACKET); + this.state = 2328; + this.partitionDefinerAtom(); + this.state = 2331; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + do { + { + { + this.state = 2329; + this.match(MySqlParser.COMMA); + this.state = 2330; + this.partitionDefinerAtom(); + } + } + this.state = 2333; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } while (_la === 868); + this.state = 2335; + this.match(MySqlParser.RR_BRACKET); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + subpartitionDefinition() { + let localContext = new SubpartitionDefinitionContext(this.context, this.state); + this.enterRule(localContext, 116, MySqlParser.RULE_subpartitionDefinition); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 2337; + this.match(MySqlParser.KW_SUBPARTITION); + this.state = 2338; + localContext._logicalName = this.uid(); + this.state = 2342; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 42 || _la === 82 || _la === 340 || _la === 360 || _la === 380 || ((((_la - 480)) & ~0x1F) === 0 && ((1 << (_la - 480)) & 16778241) !== 0) || _la === 647 || _la === 658) { + { + { + this.state = 2339; + this.partitionOption(); + } + } + this.state = 2344; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + partitionOption() { + let localContext = new PartitionOptionContext(this.context, this.state); + this.enterRule(localContext, 118, MySqlParser.RULE_partitionOption); + let _la; + try { + this.state = 2393; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_DEFAULT: + case MySqlParser.KW_ENGINE: + case MySqlParser.KW_STORAGE: + localContext = new PartitionOptionEngineContext(localContext); + this.enterOuterAlt(localContext, 1); + { + this.state = 2346; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 42) { + { + this.state = 2345; + this.match(MySqlParser.KW_DEFAULT); + } + } + this.state = 2349; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 647) { + { + this.state = 2348; + this.match(MySqlParser.KW_STORAGE); + } + } + this.state = 2351; + this.match(MySqlParser.KW_ENGINE); + this.state = 2353; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 2352; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 2355; + this.engineName(); + } + break; + case MySqlParser.KW_COMMENT: + localContext = new PartitionOptionCommentContext(localContext); + this.enterOuterAlt(localContext, 2); + { + this.state = 2356; + this.match(MySqlParser.KW_COMMENT); + this.state = 2358; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 2357; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 2360; + localContext._comment = this.match(MySqlParser.STRING_LITERAL); + } + break; + case MySqlParser.KW_DATA: + localContext = new PartitionOptionDataDirectoryContext(localContext); + this.enterOuterAlt(localContext, 3); + { + this.state = 2361; + this.match(MySqlParser.KW_DATA); + this.state = 2362; + this.match(MySqlParser.KW_DIRECTORY); + this.state = 2364; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 2363; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 2366; + localContext._dataDirectory = this.match(MySqlParser.STRING_LITERAL); + } + break; + case MySqlParser.KW_INDEX: + localContext = new PartitionOptionIndexDirectoryContext(localContext); + this.enterOuterAlt(localContext, 4); + { + this.state = 2367; + this.match(MySqlParser.KW_INDEX); + this.state = 2368; + this.match(MySqlParser.KW_DIRECTORY); + this.state = 2370; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 2369; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 2372; + localContext._indexDirectory = this.match(MySqlParser.STRING_LITERAL); + } + break; + case MySqlParser.KW_MAX_ROWS: + localContext = new PartitionOptionMaxRowsContext(localContext); + this.enterOuterAlt(localContext, 5); + { + this.state = 2373; + this.match(MySqlParser.KW_MAX_ROWS); + this.state = 2375; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 2374; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 2377; + localContext._maxRows = this.decimalLiteral(); + } + break; + case MySqlParser.KW_MIN_ROWS: + localContext = new PartitionOptionMinRowsContext(localContext); + this.enterOuterAlt(localContext, 6); + { + this.state = 2378; + this.match(MySqlParser.KW_MIN_ROWS); + this.state = 2380; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 2379; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 2382; + localContext._minRows = this.decimalLiteral(); + } + break; + case MySqlParser.KW_TABLESPACE: + localContext = new PartitionOptionTablespaceContext(localContext); + this.enterOuterAlt(localContext, 7); + { + this.state = 2383; + this.match(MySqlParser.KW_TABLESPACE); + this.state = 2385; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 2384; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 2387; + this.tablespaceName(); + } + break; + case MySqlParser.KW_NODEGROUP: + localContext = new PartitionOptionNodeGroupContext(localContext); + this.enterOuterAlt(localContext, 8); + { + this.state = 2388; + this.match(MySqlParser.KW_NODEGROUP); + this.state = 2390; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 2389; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 2392; + localContext._nodegroup = this.uid(); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + alterDatabase() { + let localContext = new AlterDatabaseContext(this.context, this.state); + this.enterRule(localContext, 120, MySqlParser.RULE_alterDatabase); + let _la; + try { + this.state = 2413; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 265, this.context)) { + case 1: + localContext = new AlterSimpleDatabaseContext(localContext); + this.enterOuterAlt(localContext, 1); + { + this.state = 2395; + this.match(MySqlParser.KW_ALTER); + this.state = 2396; + localContext._dbFormat = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 39 || _la === 152)) { + localContext._dbFormat = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 2398; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 263, this.context)) { + case 1: + { + this.state = 2397; + this.databaseName(); + } + break; + } + this.state = 2401; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + do { + { + { + this.state = 2400; + this.createDatabaseOption(); + } + } + this.state = 2403; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } while (((((_la - 26)) & ~0x1F) === 0 && ((1 << (_la - 26)) & 65541) !== 0) || _la === 135 || _la === 224 || _la === 376 || _la === 823); + } + break; + case 2: + localContext = new AlterUpgradeNameContext(localContext); + this.enterOuterAlt(localContext, 2); + { + this.state = 2405; + this.match(MySqlParser.KW_ALTER); + this.state = 2406; + localContext._dbFormat = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 39 || _la === 152)) { + localContext._dbFormat = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 2407; + this.databaseName(); + this.state = 2408; + this.match(MySqlParser.KW_UPGRADE); + this.state = 2409; + this.match(MySqlParser.KW_DATA); + this.state = 2410; + this.match(MySqlParser.KW_DIRECTORY); + this.state = 2411; + this.match(MySqlParser.KW_NAME); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + alterEvent() { + let localContext = new AlterEventContext(this.context, this.state); + this.enterRule(localContext, 122, MySqlParser.RULE_alterEvent); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 2415; + this.match(MySqlParser.KW_ALTER); + this.state = 2417; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 364) { + { + this.state = 2416; + this.ownerStatement(); + } + } + this.state = 2419; + this.match(MySqlParser.KW_EVENT); + this.state = 2420; + localContext._event_name = this.fullId(); + this.state = 2424; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 267, this.context)) { + case 1: + { + this.state = 2421; + this.match(MySqlParser.KW_ON); + this.state = 2422; + this.match(MySqlParser.KW_SCHEDULE); + this.state = 2423; + this.scheduleExpression(); + } + break; + } + this.state = 2432; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 119) { + { + this.state = 2426; + this.match(MySqlParser.KW_ON); + this.state = 2427; + this.match(MySqlParser.KW_COMPLETION); + this.state = 2429; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 114) { + { + this.state = 2428; + this.match(MySqlParser.KW_NOT); + } + } + this.state = 2431; + this.match(MySqlParser.KW_PRESERVE); + } + } + this.state = 2437; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 270, this.context)) { + case 1: + { + this.state = 2434; + this.match(MySqlParser.KW_RENAME); + this.state = 2435; + this.match(MySqlParser.KW_TO); + this.state = 2436; + localContext._new_event_name = this.fullId(); + } + break; + } + this.state = 2440; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 368 || _la === 375) { + { + this.state = 2439; + this.enableType(); + } + } + this.state = 2444; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 340) { + { + this.state = 2442; + this.match(MySqlParser.KW_COMMENT); + this.state = 2443; + this.match(MySqlParser.STRING_LITERAL); + } + } + this.state = 2448; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 273, this.context)) { + case 1: + { + this.state = 2446; + this.match(MySqlParser.KW_DO); + this.state = 2447; + this.routineBody(); + } + break; + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + alterFunction() { + let localContext = new AlterFunctionContext(this.context, this.state); + this.enterRule(localContext, 124, MySqlParser.RULE_alterFunction); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 2450; + this.match(MySqlParser.KW_ALTER); + this.state = 2451; + this.match(MySqlParser.KW_FUNCTION); + this.state = 2452; + this.functionName(); + this.state = 2456; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 47 || ((((_la - 112)) & ~0x1F) === 0 && ((1 << (_la - 112)) & 16777221) !== 0) || _la === 162 || _la === 340 || _la === 354 || _la === 444 || _la === 502) { + { + { + this.state = 2453; + this.routineOption(); + } + } + this.state = 2458; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + alterInstance() { + let localContext = new AlterInstanceContext(this.context, this.state); + this.enterRule(localContext, 126, MySqlParser.RULE_alterInstance); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 2459; + this.match(MySqlParser.KW_ALTER); + this.state = 2460; + this.match(MySqlParser.KW_INSTANCE); + this.state = 2461; + this.match(MySqlParser.KW_ROTATE); + this.state = 2462; + this.match(MySqlParser.KW_INNODB); + this.state = 2463; + this.match(MySqlParser.KW_MASTER); + this.state = 2464; + this.match(MySqlParser.KW_KEY); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + alterLogfileGroup() { + let localContext = new AlterLogfileGroupContext(this.context, this.state); + this.enterRule(localContext, 128, MySqlParser.RULE_alterLogfileGroup); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 2466; + this.match(MySqlParser.KW_ALTER); + this.state = 2467; + this.match(MySqlParser.KW_LOGFILE); + this.state = 2468; + this.match(MySqlParser.KW_GROUP); + this.state = 2469; + localContext._logfileGroupName = this.uid(); + this.state = 2470; + this.match(MySqlParser.KW_ADD); + this.state = 2471; + this.match(MySqlParser.KW_UNDOFILE); + this.state = 2472; + this.match(MySqlParser.STRING_LITERAL); + this.state = 2478; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 428) { + { + this.state = 2473; + this.match(MySqlParser.KW_INITIAL_SIZE); + this.state = 2475; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 2474; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 2477; + this.fileSizeLiteral(); + } + } + this.state = 2481; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 687) { + { + this.state = 2480; + this.match(MySqlParser.KW_WAIT); + } + } + this.state = 2483; + this.match(MySqlParser.KW_ENGINE); + this.state = 2485; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 2484; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 2487; + this.engineName(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + alterProcedure() { + let localContext = new AlterProcedureContext(this.context, this.state); + this.enterRule(localContext, 130, MySqlParser.RULE_alterProcedure); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 2489; + this.match(MySqlParser.KW_ALTER); + this.state = 2490; + this.match(MySqlParser.KW_PROCEDURE); + this.state = 2491; + localContext._proc_name = this.fullId(); + this.state = 2495; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 47 || ((((_la - 112)) & ~0x1F) === 0 && ((1 << (_la - 112)) & 16777221) !== 0) || _la === 162 || _la === 340 || _la === 354 || _la === 444 || _la === 502) { + { + { + this.state = 2492; + this.routineOption(); + } + } + this.state = 2497; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + alterServer() { + let localContext = new AlterServerContext(this.context, this.state); + this.enterRule(localContext, 132, MySqlParser.RULE_alterServer); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 2498; + this.match(MySqlParser.KW_ALTER); + this.state = 2499; + this.match(MySqlParser.KW_SERVER); + this.state = 2500; + localContext._serverName = this.uid(); + this.state = 2501; + this.match(MySqlParser.KW_OPTIONS); + this.state = 2502; + this.match(MySqlParser.LR_BRACKET); + this.state = 2503; + this.serverOption(); + this.state = 2508; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 2504; + this.match(MySqlParser.COMMA); + this.state = 2505; + this.serverOption(); + } + } + this.state = 2510; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 2511; + this.match(MySqlParser.RR_BRACKET); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + alterTable() { + let localContext = new AlterTableContext(this.context, this.state); + this.enterRule(localContext, 134, MySqlParser.RULE_alterTable); + let _la; + try { + let alternative; + this.enterOuterAlt(localContext, 1); + { + this.state = 2513; + this.match(MySqlParser.KW_ALTER); + this.state = 2514; + this.match(MySqlParser.KW_TABLE); + this.state = 2515; + this.tableName(); + this.state = 2524; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 282, this.context)) { + case 1: + { + this.state = 2516; + this.alterOption(); + this.state = 2521; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 2517; + this.match(MySqlParser.COMMA); + this.state = 2518; + this.alterOption(); + } + } + this.state = 2523; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + break; + } + this.state = 2533; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 284, this.context)) { + case 1: + { + this.state = 2526; + this.alterPartitionSpecification(); + this.state = 2530; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 283, this.context); + while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER) { + if (alternative === 1) { + { + { + this.state = 2527; + this.alterPartitionSpecification(); + } + } + } + this.state = 2532; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 283, this.context); + } + } + break; + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + alterTablespace() { + let localContext = new AlterTablespaceContext(this.context, this.state); + this.enterRule(localContext, 136, MySqlParser.RULE_alterTablespace); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 2535; + this.match(MySqlParser.KW_ALTER); + this.state = 2537; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 180) { + { + this.state = 2536; + this.match(MySqlParser.KW_UNDO); + } + } + this.state = 2539; + this.match(MySqlParser.KW_TABLESPACE); + this.state = 2540; + this.tablespaceName(); + this.state = 2541; + _la = this.tokenStream.LA(1); + if (!(_la === 6 || _la === 51)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 2542; + this.match(MySqlParser.KW_DATAFILE); + this.state = 2543; + this.match(MySqlParser.STRING_LITERAL); + this.state = 2549; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 428) { + { + this.state = 2544; + this.match(MySqlParser.KW_INITIAL_SIZE); + this.state = 2546; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 2545; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 2548; + this.fileSizeLiteral(); + } + } + this.state = 2552; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 687) { + { + this.state = 2551; + this.match(MySqlParser.KW_WAIT); + } + } + this.state = 2557; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 289, this.context)) { + case 1: + { + this.state = 2554; + this.match(MySqlParser.KW_RENAME); + this.state = 2555; + this.match(MySqlParser.KW_TO); + this.state = 2556; + this.tablespaceNameCreate(); + } + break; + } + this.state = 2564; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 314) { + { + this.state = 2559; + this.match(MySqlParser.KW_AUTOEXTEND_SIZE); + this.state = 2561; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 2560; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 2563; + this.fileSizeLiteral(); + } + } + this.state = 2568; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 292, this.context)) { + case 1: + { + this.state = 2566; + this.match(MySqlParser.KW_SET); + this.state = 2567; + _la = this.tokenStream.LA(1); + if (!(_la === 5 || _la === 81)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + break; + } + this.state = 2575; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 376) { + { + this.state = 2570; + this.match(MySqlParser.KW_ENCRYPTION); + this.state = 2572; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 2571; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 2574; + this.match(MySqlParser.STRING_LITERAL); + } + } + this.state = 2582; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 380) { + { + this.state = 2577; + this.match(MySqlParser.KW_ENGINE); + this.state = 2579; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 2578; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 2581; + this.engineName(); + } + } + this.state = 2589; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 825) { + { + this.state = 2584; + this.match(MySqlParser.KW_ENGINE_ATTRIBUTE); + this.state = 2586; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 2585; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 2588; + this.match(MySqlParser.STRING_LITERAL); + } + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + alterView() { + let localContext = new AlterViewContext(this.context, this.state); + this.enterRule(localContext, 138, MySqlParser.RULE_alterView); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 2591; + this.match(MySqlParser.KW_ALTER); + this.state = 2595; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 308) { + { + this.state = 2592; + this.match(MySqlParser.KW_ALGORITHM); + this.state = 2593; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 2594; + localContext._algType = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 486 || _la === 661 || _la === 670)) { + localContext._algType = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + this.state = 2598; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 364) { + { + this.state = 2597; + this.ownerStatement(); + } + } + this.state = 2603; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 162) { + { + this.state = 2600; + this.match(MySqlParser.KW_SQL); + this.state = 2601; + this.match(MySqlParser.KW_SECURITY); + this.state = 2602; + localContext._secContext = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 364 || _la === 436)) { + localContext._secContext = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + this.state = 2605; + this.match(MySqlParser.KW_VIEW); + this.state = 2606; + this.viewName(); + this.state = 2611; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 866) { + { + this.state = 2607; + this.match(MySqlParser.LR_BRACKET); + this.state = 2608; + this.columnNames(); + this.state = 2609; + this.match(MySqlParser.RR_BRACKET); + } + } + this.state = 2613; + this.match(MySqlParser.KW_AS); + this.state = 2614; + this.selectStatement(); + this.state = 2621; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 304, this.context)) { + case 1: + { + this.state = 2615; + this.match(MySqlParser.KW_WITH); + this.state = 2617; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 325 || _la === 450) { + { + this.state = 2616; + localContext._checkOpt = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 325 || _la === 450)) { + localContext._checkOpt = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + this.state = 2619; + this.match(MySqlParser.KW_CHECK); + this.state = 2620; + this.match(MySqlParser.KW_OPTION); + } + break; + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + alterOption() { + let localContext = new AlterOptionContext(this.context, this.state); + this.enterRule(localContext, 140, MySqlParser.RULE_alterOption); + let _la; + try { + let alternative; + this.state = 2887; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 348, this.context)) { + case 1: + localContext = new AlterByTableOptionContext(localContext); + this.enterOuterAlt(localContext, 1); + { + this.state = 2623; + this.tableOption(); + this.state = 2630; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 306, this.context); + while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER) { + if (alternative === 1) { + { + { + this.state = 2625; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 868) { + { + this.state = 2624; + this.match(MySqlParser.COMMA); + } + } + this.state = 2627; + this.tableOption(); + } + } + } + this.state = 2632; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 306, this.context); + } + } + break; + case 2: + localContext = new AlterByAddColumnContext(localContext); + this.enterOuterAlt(localContext, 2); + { + this.state = 2633; + this.match(MySqlParser.KW_ADD); + this.state = 2635; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 307, this.context)) { + case 1: + { + this.state = 2634; + this.match(MySqlParser.KW_COLUMN); + } + break; + } + this.state = 2637; + this.columnName(); + this.state = 2638; + this.columnDefinition(); + this.state = 2642; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_FIRST: + { + this.state = 2639; + this.match(MySqlParser.KW_FIRST); + } + break; + case MySqlParser.KW_AFTER: + { + this.state = 2640; + this.match(MySqlParser.KW_AFTER); + this.state = 2641; + this.columnName(); + } + break; + case MySqlParser.EOF: + case MySqlParser.KW_ADD: + case MySqlParser.KW_ALTER: + case MySqlParser.KW_ANALYZE: + case MySqlParser.KW_CALL: + case MySqlParser.KW_CHANGE: + case MySqlParser.KW_CHECK: + case MySqlParser.KW_CREATE: + case MySqlParser.KW_DELETE: + case MySqlParser.KW_DESC: + case MySqlParser.KW_DESCRIBE: + case MySqlParser.KW_DROP: + case MySqlParser.KW_EXPLAIN: + case MySqlParser.KW_GET: + case MySqlParser.KW_GRANT: + case MySqlParser.KW_INSERT: + case MySqlParser.KW_KILL: + case MySqlParser.KW_LOAD: + case MySqlParser.KW_LOCK: + case MySqlParser.KW_OPTIMIZE: + case MySqlParser.KW_PURGE: + case MySqlParser.KW_RELEASE: + case MySqlParser.KW_RENAME: + case MySqlParser.KW_REPLACE: + case MySqlParser.KW_RESIGNAL: + case MySqlParser.KW_REVOKE: + case MySqlParser.KW_SELECT: + case MySqlParser.KW_SET: + case MySqlParser.KW_SHOW: + case MySqlParser.KW_SIGNAL: + case MySqlParser.KW_TABLE: + case MySqlParser.KW_UNLOCK: + case MySqlParser.KW_UPDATE: + case MySqlParser.KW_USE: + case MySqlParser.KW_VALUES: + case MySqlParser.KW_WITH: + case MySqlParser.KW_BEGIN: + case MySqlParser.KW_BINLOG: + case MySqlParser.KW_CACHE: + case MySqlParser.KW_CHECKSUM: + case MySqlParser.KW_COALESCE: + case MySqlParser.KW_COMMIT: + case MySqlParser.KW_DEALLOCATE: + case MySqlParser.KW_DISCARD: + case MySqlParser.KW_DO: + case MySqlParser.KW_EXCHANGE: + case MySqlParser.KW_FLUSH: + case MySqlParser.KW_HANDLER: + case MySqlParser.KW_HELP: + case MySqlParser.KW_IMPORT: + case MySqlParser.KW_INSTALL: + case MySqlParser.KW_PREPARE: + case MySqlParser.KW_REBUILD: + case MySqlParser.KW_REMOVE: + case MySqlParser.KW_REORGANIZE: + case MySqlParser.KW_REPAIR: + case MySqlParser.KW_RESET: + case MySqlParser.KW_RESTART: + case MySqlParser.KW_ROLLBACK: + case MySqlParser.KW_SAVEPOINT: + case MySqlParser.KW_START: + case MySqlParser.KW_STOP: + case MySqlParser.KW_TRUNCATE: + case MySqlParser.KW_UNINSTALL: + case MySqlParser.KW_UPGRADE: + case MySqlParser.KW_XA: + case MySqlParser.KW_CLONE: + case MySqlParser.KW_EXECUTE: + case MySqlParser.KW_SHUTDOWN: + case MySqlParser.LR_BRACKET: + case MySqlParser.COMMA: + case MySqlParser.SEMI: + break; + default: + break; + } + } + break; + case 3: + localContext = new AlterByAddColumnsContext(localContext); + this.enterOuterAlt(localContext, 3); + { + this.state = 2644; + this.match(MySqlParser.KW_ADD); + this.state = 2646; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 29) { + { + this.state = 2645; + this.match(MySqlParser.KW_COLUMN); + } + } + this.state = 2648; + this.match(MySqlParser.LR_BRACKET); + this.state = 2649; + this.columnName(); + this.state = 2650; + this.columnDefinition(); + this.state = 2657; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 2651; + this.match(MySqlParser.COMMA); + this.state = 2652; + this.columnName(); + this.state = 2653; + this.columnDefinition(); + } + } + this.state = 2659; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 2660; + this.match(MySqlParser.RR_BRACKET); + } + break; + case 4: + localContext = new AlterByAddIndexContext(localContext); + this.enterOuterAlt(localContext, 4); + { + this.state = 2662; + this.match(MySqlParser.KW_ADD); + this.state = 2663; + _la = this.tokenStream.LA(1); + if (!(_la === 82 || _la === 92)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 2665; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if ((((_la) & ~0x1F) === 0 && ((1 << _la) & 1074302976) !== 0) || ((((_la - 36)) & ~0x1F) === 0 && ((1 << (_la - 36)) & 11014219) !== 0) || ((((_la - 74)) & ~0x1F) === 0 && ((1 << (_la - 74)) & 18878481) !== 0) || ((((_la - 117)) & ~0x1F) === 0 && ((1 << (_la - 117)) & 100679969) !== 0) || ((((_la - 150)) & ~0x1F) === 0 && ((1 << (_la - 150)) & 1049605) !== 0) || ((((_la - 219)) & ~0x1F) === 0 && ((1 << (_la - 219)) & 5374495) !== 0) || ((((_la - 253)) & ~0x1F) === 0 && ((1 << (_la - 253)) & 4294967295) !== 0) || ((((_la - 285)) & ~0x1F) === 0 && ((1 << (_la - 285)) & 4261412607) !== 0) || ((((_la - 317)) & ~0x1F) === 0 && ((1 << (_la - 317)) & 4160741375) !== 0) || ((((_la - 349)) & ~0x1F) === 0 && ((1 << (_la - 349)) & 4026531839) !== 0) || ((((_la - 381)) & ~0x1F) === 0 && ((1 << (_la - 381)) & 1055907839) !== 0) || ((((_la - 413)) & ~0x1F) === 0 && ((1 << (_la - 413)) & 4294885367) !== 0) || ((((_la - 445)) & ~0x1F) === 0 && ((1 << (_la - 445)) & 3757571071) !== 0) || ((((_la - 478)) & ~0x1F) === 0 && ((1 << (_la - 478)) & 3755999231) !== 0) || ((((_la - 510)) & ~0x1F) === 0 && ((1 << (_la - 510)) & 3751780349) !== 0) || ((((_la - 542)) & ~0x1F) === 0 && ((1 << (_la - 542)) & 2141183997) !== 0) || ((((_la - 575)) & ~0x1F) === 0 && ((1 << (_la - 575)) & 2147483629) !== 0) || ((((_la - 633)) & ~0x1F) === 0 && ((1 << (_la - 633)) & 4294934527) !== 0) || ((((_la - 665)) & ~0x1F) === 0 && ((1 << (_la - 665)) & 4278189053) !== 0) || ((((_la - 697)) & ~0x1F) === 0 && ((1 << (_la - 697)) & 1644099327) !== 0) || ((((_la - 729)) & ~0x1F) === 0 && ((1 << (_la - 729)) & 4294900735) !== 0) || ((((_la - 761)) & ~0x1F) === 0 && ((1 << (_la - 761)) & 4294967295) !== 0) || ((((_la - 793)) & ~0x1F) === 0 && ((1 << (_la - 793)) & 4288675839) !== 0) || ((((_la - 825)) & ~0x1F) === 0 && ((1 << (_la - 825)) & 2147527671) !== 0) || ((((_la - 879)) & ~0x1F) === 0 && ((1 << (_la - 879)) & 1033) !== 0)) { + { + this.state = 2664; + this.indexName(); + } + } + this.state = 2668; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 188) { + { + this.state = 2667; + this.indexType(); + } + } + this.state = 2670; + this.indexColumnNames(); + this.state = 2674; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 313, this.context); + while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER) { + if (alternative === 1) { + { + { + this.state = 2671; + this.indexOption(); + } + } + } + this.state = 2676; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 313, this.context); + } + } + break; + case 5: + localContext = new AlterByAddSpecialIndexContext(localContext); + this.enterOuterAlt(localContext, 5); + { + this.state = 2677; + this.match(MySqlParser.KW_ADD); + this.state = 2678; + _la = this.tokenStream.LA(1); + if (!(_la === 69 || _la === 161)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 2680; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 82 || _la === 92) { + { + this.state = 2679; + _la = this.tokenStream.LA(1); + if (!(_la === 82 || _la === 92)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + this.state = 2683; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if ((((_la) & ~0x1F) === 0 && ((1 << _la) & 1074302976) !== 0) || ((((_la - 36)) & ~0x1F) === 0 && ((1 << (_la - 36)) & 11014219) !== 0) || ((((_la - 74)) & ~0x1F) === 0 && ((1 << (_la - 74)) & 18878481) !== 0) || ((((_la - 117)) & ~0x1F) === 0 && ((1 << (_la - 117)) & 100679969) !== 0) || ((((_la - 150)) & ~0x1F) === 0 && ((1 << (_la - 150)) & 1049605) !== 0) || ((((_la - 219)) & ~0x1F) === 0 && ((1 << (_la - 219)) & 5374495) !== 0) || ((((_la - 253)) & ~0x1F) === 0 && ((1 << (_la - 253)) & 4294967295) !== 0) || ((((_la - 285)) & ~0x1F) === 0 && ((1 << (_la - 285)) & 4261412607) !== 0) || ((((_la - 317)) & ~0x1F) === 0 && ((1 << (_la - 317)) & 4160741375) !== 0) || ((((_la - 349)) & ~0x1F) === 0 && ((1 << (_la - 349)) & 4026531839) !== 0) || ((((_la - 381)) & ~0x1F) === 0 && ((1 << (_la - 381)) & 1055907839) !== 0) || ((((_la - 413)) & ~0x1F) === 0 && ((1 << (_la - 413)) & 4294885367) !== 0) || ((((_la - 445)) & ~0x1F) === 0 && ((1 << (_la - 445)) & 3757571071) !== 0) || ((((_la - 478)) & ~0x1F) === 0 && ((1 << (_la - 478)) & 3755999231) !== 0) || ((((_la - 510)) & ~0x1F) === 0 && ((1 << (_la - 510)) & 3751780349) !== 0) || ((((_la - 542)) & ~0x1F) === 0 && ((1 << (_la - 542)) & 2141183997) !== 0) || ((((_la - 575)) & ~0x1F) === 0 && ((1 << (_la - 575)) & 2147483629) !== 0) || ((((_la - 633)) & ~0x1F) === 0 && ((1 << (_la - 633)) & 4294934527) !== 0) || ((((_la - 665)) & ~0x1F) === 0 && ((1 << (_la - 665)) & 4278189053) !== 0) || ((((_la - 697)) & ~0x1F) === 0 && ((1 << (_la - 697)) & 1644099327) !== 0) || ((((_la - 729)) & ~0x1F) === 0 && ((1 << (_la - 729)) & 4294900735) !== 0) || ((((_la - 761)) & ~0x1F) === 0 && ((1 << (_la - 761)) & 4294967295) !== 0) || ((((_la - 793)) & ~0x1F) === 0 && ((1 << (_la - 793)) & 4288675839) !== 0) || ((((_la - 825)) & ~0x1F) === 0 && ((1 << (_la - 825)) & 2147527671) !== 0) || ((((_la - 879)) & ~0x1F) === 0 && ((1 << (_la - 879)) & 1033) !== 0)) { + { + this.state = 2682; + this.indexName(); + } + } + this.state = 2685; + this.indexColumnNames(); + this.state = 2689; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 316, this.context); + while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER) { + if (alternative === 1) { + { + { + this.state = 2686; + this.indexOption(); + } + } + } + this.state = 2691; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 316, this.context); + } + } + break; + case 6: + localContext = new AlterByAddPrimaryKeyContext(localContext); + this.enterOuterAlt(localContext, 6); + { + this.state = 2692; + this.match(MySqlParser.KW_ADD); + this.state = 2697; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 31) { + { + this.state = 2693; + this.match(MySqlParser.KW_CONSTRAINT); + this.state = 2695; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 317, this.context)) { + case 1: + { + this.state = 2694; + localContext._symbol_ = this.uid(); + } + break; + } + } + } + this.state = 2699; + this.match(MySqlParser.KW_PRIMARY); + this.state = 2700; + this.match(MySqlParser.KW_KEY); + this.state = 2702; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 188) { + { + this.state = 2701; + this.indexType(); + } + } + this.state = 2704; + this.indexColumnNames(); + this.state = 2708; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 320, this.context); + while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER) { + if (alternative === 1) { + { + { + this.state = 2705; + this.indexOption(); + } + } + } + this.state = 2710; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 320, this.context); + } + } + break; + case 7: + localContext = new AlterByAddUniqueKeyContext(localContext); + this.enterOuterAlt(localContext, 7); + { + this.state = 2711; + this.match(MySqlParser.KW_ADD); + this.state = 2716; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 31) { + { + this.state = 2712; + this.match(MySqlParser.KW_CONSTRAINT); + this.state = 2714; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if ((((_la) & ~0x1F) === 0 && ((1 << _la) & 1074302976) !== 0) || ((((_la - 36)) & ~0x1F) === 0 && ((1 << (_la - 36)) & 11014219) !== 0) || ((((_la - 74)) & ~0x1F) === 0 && ((1 << (_la - 74)) & 18878481) !== 0) || ((((_la - 117)) & ~0x1F) === 0 && ((1 << (_la - 117)) & 100679969) !== 0) || ((((_la - 150)) & ~0x1F) === 0 && ((1 << (_la - 150)) & 1049605) !== 0) || ((((_la - 219)) & ~0x1F) === 0 && ((1 << (_la - 219)) & 5374495) !== 0) || ((((_la - 253)) & ~0x1F) === 0 && ((1 << (_la - 253)) & 4294967295) !== 0) || ((((_la - 285)) & ~0x1F) === 0 && ((1 << (_la - 285)) & 4261412607) !== 0) || ((((_la - 317)) & ~0x1F) === 0 && ((1 << (_la - 317)) & 4160741375) !== 0) || ((((_la - 349)) & ~0x1F) === 0 && ((1 << (_la - 349)) & 4026531839) !== 0) || ((((_la - 381)) & ~0x1F) === 0 && ((1 << (_la - 381)) & 1055907839) !== 0) || ((((_la - 413)) & ~0x1F) === 0 && ((1 << (_la - 413)) & 4294885367) !== 0) || ((((_la - 445)) & ~0x1F) === 0 && ((1 << (_la - 445)) & 3757571071) !== 0) || ((((_la - 478)) & ~0x1F) === 0 && ((1 << (_la - 478)) & 3755999231) !== 0) || ((((_la - 510)) & ~0x1F) === 0 && ((1 << (_la - 510)) & 3751780349) !== 0) || ((((_la - 542)) & ~0x1F) === 0 && ((1 << (_la - 542)) & 2141183997) !== 0) || ((((_la - 575)) & ~0x1F) === 0 && ((1 << (_la - 575)) & 2147483629) !== 0) || ((((_la - 633)) & ~0x1F) === 0 && ((1 << (_la - 633)) & 4294934527) !== 0) || ((((_la - 665)) & ~0x1F) === 0 && ((1 << (_la - 665)) & 4278189053) !== 0) || ((((_la - 697)) & ~0x1F) === 0 && ((1 << (_la - 697)) & 1644099327) !== 0) || ((((_la - 729)) & ~0x1F) === 0 && ((1 << (_la - 729)) & 4294900735) !== 0) || ((((_la - 761)) & ~0x1F) === 0 && ((1 << (_la - 761)) & 4294967295) !== 0) || ((((_la - 793)) & ~0x1F) === 0 && ((1 << (_la - 793)) & 4288675839) !== 0) || ((((_la - 825)) & ~0x1F) === 0 && ((1 << (_la - 825)) & 2147527671) !== 0) || ((((_la - 879)) & ~0x1F) === 0 && ((1 << (_la - 879)) & 1033) !== 0)) { + { + this.state = 2713; + localContext._symbol_ = this.uid(); + } + } + } + } + this.state = 2718; + this.match(MySqlParser.KW_UNIQUE); + this.state = 2720; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 82 || _la === 92) { + { + this.state = 2719; + _la = this.tokenStream.LA(1); + if (!(_la === 82 || _la === 92)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + this.state = 2723; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if ((((_la) & ~0x1F) === 0 && ((1 << _la) & 1074302976) !== 0) || ((((_la - 36)) & ~0x1F) === 0 && ((1 << (_la - 36)) & 11014219) !== 0) || ((((_la - 74)) & ~0x1F) === 0 && ((1 << (_la - 74)) & 18878481) !== 0) || ((((_la - 117)) & ~0x1F) === 0 && ((1 << (_la - 117)) & 100679969) !== 0) || ((((_la - 150)) & ~0x1F) === 0 && ((1 << (_la - 150)) & 1049605) !== 0) || ((((_la - 219)) & ~0x1F) === 0 && ((1 << (_la - 219)) & 5374495) !== 0) || ((((_la - 253)) & ~0x1F) === 0 && ((1 << (_la - 253)) & 4294967295) !== 0) || ((((_la - 285)) & ~0x1F) === 0 && ((1 << (_la - 285)) & 4261412607) !== 0) || ((((_la - 317)) & ~0x1F) === 0 && ((1 << (_la - 317)) & 4160741375) !== 0) || ((((_la - 349)) & ~0x1F) === 0 && ((1 << (_la - 349)) & 4026531839) !== 0) || ((((_la - 381)) & ~0x1F) === 0 && ((1 << (_la - 381)) & 1055907839) !== 0) || ((((_la - 413)) & ~0x1F) === 0 && ((1 << (_la - 413)) & 4294885367) !== 0) || ((((_la - 445)) & ~0x1F) === 0 && ((1 << (_la - 445)) & 3757571071) !== 0) || ((((_la - 478)) & ~0x1F) === 0 && ((1 << (_la - 478)) & 3755999231) !== 0) || ((((_la - 510)) & ~0x1F) === 0 && ((1 << (_la - 510)) & 3751780349) !== 0) || ((((_la - 542)) & ~0x1F) === 0 && ((1 << (_la - 542)) & 2141183997) !== 0) || ((((_la - 575)) & ~0x1F) === 0 && ((1 << (_la - 575)) & 2147483629) !== 0) || ((((_la - 633)) & ~0x1F) === 0 && ((1 << (_la - 633)) & 4294934527) !== 0) || ((((_la - 665)) & ~0x1F) === 0 && ((1 << (_la - 665)) & 4278189053) !== 0) || ((((_la - 697)) & ~0x1F) === 0 && ((1 << (_la - 697)) & 1644099327) !== 0) || ((((_la - 729)) & ~0x1F) === 0 && ((1 << (_la - 729)) & 4294900735) !== 0) || ((((_la - 761)) & ~0x1F) === 0 && ((1 << (_la - 761)) & 4294967295) !== 0) || ((((_la - 793)) & ~0x1F) === 0 && ((1 << (_la - 793)) & 4288675839) !== 0) || ((((_la - 825)) & ~0x1F) === 0 && ((1 << (_la - 825)) & 2147527671) !== 0) || ((((_la - 879)) & ~0x1F) === 0 && ((1 << (_la - 879)) & 1033) !== 0)) { + { + this.state = 2722; + this.indexName(); + } + } + this.state = 2726; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 188) { + { + this.state = 2725; + this.indexType(); + } + } + this.state = 2728; + this.indexColumnNames(); + this.state = 2732; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 326, this.context); + while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER) { + if (alternative === 1) { + { + { + this.state = 2729; + this.indexOption(); + } + } + } + this.state = 2734; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 326, this.context); + } + } + break; + case 8: + localContext = new AlterByAddForeignKeyContext(localContext); + this.enterOuterAlt(localContext, 8); + { + this.state = 2735; + this.match(MySqlParser.KW_ADD); + this.state = 2740; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 31) { + { + this.state = 2736; + this.match(MySqlParser.KW_CONSTRAINT); + this.state = 2738; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if ((((_la) & ~0x1F) === 0 && ((1 << _la) & 1074302976) !== 0) || ((((_la - 36)) & ~0x1F) === 0 && ((1 << (_la - 36)) & 11014219) !== 0) || ((((_la - 74)) & ~0x1F) === 0 && ((1 << (_la - 74)) & 18878481) !== 0) || ((((_la - 117)) & ~0x1F) === 0 && ((1 << (_la - 117)) & 100679969) !== 0) || ((((_la - 150)) & ~0x1F) === 0 && ((1 << (_la - 150)) & 1049605) !== 0) || ((((_la - 219)) & ~0x1F) === 0 && ((1 << (_la - 219)) & 5374495) !== 0) || ((((_la - 253)) & ~0x1F) === 0 && ((1 << (_la - 253)) & 4294967295) !== 0) || ((((_la - 285)) & ~0x1F) === 0 && ((1 << (_la - 285)) & 4261412607) !== 0) || ((((_la - 317)) & ~0x1F) === 0 && ((1 << (_la - 317)) & 4160741375) !== 0) || ((((_la - 349)) & ~0x1F) === 0 && ((1 << (_la - 349)) & 4026531839) !== 0) || ((((_la - 381)) & ~0x1F) === 0 && ((1 << (_la - 381)) & 1055907839) !== 0) || ((((_la - 413)) & ~0x1F) === 0 && ((1 << (_la - 413)) & 4294885367) !== 0) || ((((_la - 445)) & ~0x1F) === 0 && ((1 << (_la - 445)) & 3757571071) !== 0) || ((((_la - 478)) & ~0x1F) === 0 && ((1 << (_la - 478)) & 3755999231) !== 0) || ((((_la - 510)) & ~0x1F) === 0 && ((1 << (_la - 510)) & 3751780349) !== 0) || ((((_la - 542)) & ~0x1F) === 0 && ((1 << (_la - 542)) & 2141183997) !== 0) || ((((_la - 575)) & ~0x1F) === 0 && ((1 << (_la - 575)) & 2147483629) !== 0) || ((((_la - 633)) & ~0x1F) === 0 && ((1 << (_la - 633)) & 4294934527) !== 0) || ((((_la - 665)) & ~0x1F) === 0 && ((1 << (_la - 665)) & 4278189053) !== 0) || ((((_la - 697)) & ~0x1F) === 0 && ((1 << (_la - 697)) & 1644099327) !== 0) || ((((_la - 729)) & ~0x1F) === 0 && ((1 << (_la - 729)) & 4294900735) !== 0) || ((((_la - 761)) & ~0x1F) === 0 && ((1 << (_la - 761)) & 4294967295) !== 0) || ((((_la - 793)) & ~0x1F) === 0 && ((1 << (_la - 793)) & 4288675839) !== 0) || ((((_la - 825)) & ~0x1F) === 0 && ((1 << (_la - 825)) & 2147527671) !== 0) || ((((_la - 879)) & ~0x1F) === 0 && ((1 << (_la - 879)) & 1033) !== 0)) { + { + this.state = 2737; + localContext._symbol_ = this.uid(); + } + } + } + } + this.state = 2742; + this.match(MySqlParser.KW_FOREIGN); + this.state = 2743; + this.match(MySqlParser.KW_KEY); + this.state = 2745; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if ((((_la) & ~0x1F) === 0 && ((1 << _la) & 1074302976) !== 0) || ((((_la - 36)) & ~0x1F) === 0 && ((1 << (_la - 36)) & 11014219) !== 0) || ((((_la - 74)) & ~0x1F) === 0 && ((1 << (_la - 74)) & 18878481) !== 0) || ((((_la - 117)) & ~0x1F) === 0 && ((1 << (_la - 117)) & 100679969) !== 0) || ((((_la - 150)) & ~0x1F) === 0 && ((1 << (_la - 150)) & 1049605) !== 0) || ((((_la - 219)) & ~0x1F) === 0 && ((1 << (_la - 219)) & 5374495) !== 0) || ((((_la - 253)) & ~0x1F) === 0 && ((1 << (_la - 253)) & 4294967295) !== 0) || ((((_la - 285)) & ~0x1F) === 0 && ((1 << (_la - 285)) & 4261412607) !== 0) || ((((_la - 317)) & ~0x1F) === 0 && ((1 << (_la - 317)) & 4160741375) !== 0) || ((((_la - 349)) & ~0x1F) === 0 && ((1 << (_la - 349)) & 4026531839) !== 0) || ((((_la - 381)) & ~0x1F) === 0 && ((1 << (_la - 381)) & 1055907839) !== 0) || ((((_la - 413)) & ~0x1F) === 0 && ((1 << (_la - 413)) & 4294885367) !== 0) || ((((_la - 445)) & ~0x1F) === 0 && ((1 << (_la - 445)) & 3757571071) !== 0) || ((((_la - 478)) & ~0x1F) === 0 && ((1 << (_la - 478)) & 3755999231) !== 0) || ((((_la - 510)) & ~0x1F) === 0 && ((1 << (_la - 510)) & 3751780349) !== 0) || ((((_la - 542)) & ~0x1F) === 0 && ((1 << (_la - 542)) & 2141183997) !== 0) || ((((_la - 575)) & ~0x1F) === 0 && ((1 << (_la - 575)) & 2147483629) !== 0) || ((((_la - 633)) & ~0x1F) === 0 && ((1 << (_la - 633)) & 4294934527) !== 0) || ((((_la - 665)) & ~0x1F) === 0 && ((1 << (_la - 665)) & 4278189053) !== 0) || ((((_la - 697)) & ~0x1F) === 0 && ((1 << (_la - 697)) & 1644099327) !== 0) || ((((_la - 729)) & ~0x1F) === 0 && ((1 << (_la - 729)) & 4294900735) !== 0) || ((((_la - 761)) & ~0x1F) === 0 && ((1 << (_la - 761)) & 4294967295) !== 0) || ((((_la - 793)) & ~0x1F) === 0 && ((1 << (_la - 793)) & 4288675839) !== 0) || ((((_la - 825)) & ~0x1F) === 0 && ((1 << (_la - 825)) & 2147527671) !== 0) || ((((_la - 879)) & ~0x1F) === 0 && ((1 << (_la - 879)) & 1033) !== 0)) { + { + this.state = 2744; + this.indexName(); + } + } + this.state = 2747; + this.indexColumnNames(); + this.state = 2748; + this.referenceDefinition(); + } + break; + case 9: + localContext = new AlterByAddCheckTableConstraintContext(localContext); + this.enterOuterAlt(localContext, 9); + { + this.state = 2750; + this.match(MySqlParser.KW_ADD); + this.state = 2752; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 330, this.context)) { + case 1: + { + this.state = 2751; + this.checkConstraintDefinition(); + } + break; + } + } + break; + case 10: + localContext = new AlterByDropConstraintCheckContext(localContext); + this.enterOuterAlt(localContext, 10); + { + this.state = 2754; + this.match(MySqlParser.KW_DROP); + this.state = 2755; + _la = this.tokenStream.LA(1); + if (!(_la === 27 || _la === 31)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 2756; + localContext._symbol_ = this.uid(); + } + break; + case 11: + localContext = new AlterByAlterCheckTableConstraintContext(localContext); + this.enterOuterAlt(localContext, 11); + { + this.state = 2757; + this.match(MySqlParser.KW_ALTER); + this.state = 2758; + _la = this.tokenStream.LA(1); + if (!(_la === 27 || _la === 31)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 2759; + localContext._symbol_ = this.uid(); + this.state = 2761; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 114) { + { + this.state = 2760; + this.match(MySqlParser.KW_NOT); + } + } + this.state = 2764; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 57) { + { + this.state = 2763; + this.match(MySqlParser.KW_ENFORCED); + } + } + } + break; + case 12: + localContext = new AlterBySetAlgorithmContext(localContext); + this.enterOuterAlt(localContext, 12); + { + this.state = 2766; + this.match(MySqlParser.KW_ALGORITHM); + this.state = 2768; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 2767; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 2770; + _la = this.tokenStream.LA(1); + if (!(_la === 42 || _la === 357 || _la === 430 || _la === 434)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + break; + case 13: + localContext = new AlterByAlterColumnDefaultContext(localContext); + this.enterOuterAlt(localContext, 13); + { + this.state = 2771; + this.match(MySqlParser.KW_ALTER); + this.state = 2773; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 334, this.context)) { + case 1: + { + this.state = 2772; + this.match(MySqlParser.KW_COLUMN); + } + break; + } + this.state = 2775; + this.columnName(); + this.state = 2783; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 335, this.context)) { + case 1: + { + this.state = 2776; + this.match(MySqlParser.KW_SET); + this.state = 2777; + this.match(MySqlParser.KW_DEFAULT); + this.state = 2778; + this.defaultValue(); + } + break; + case 2: + { + this.state = 2779; + this.match(MySqlParser.KW_SET); + this.state = 2780; + _la = this.tokenStream.LA(1); + if (!(_la === 435 || _la === 686)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + break; + case 3: + { + this.state = 2781; + this.match(MySqlParser.KW_DROP); + this.state = 2782; + this.match(MySqlParser.KW_DEFAULT); + } + break; + } + } + break; + case 14: + localContext = new AlterByAlterIndexVisibilityContext(localContext); + this.enterOuterAlt(localContext, 14); + { + this.state = 2785; + this.match(MySqlParser.KW_ALTER); + this.state = 2786; + this.match(MySqlParser.KW_INDEX); + this.state = 2787; + this.indexName(); + this.state = 2788; + _la = this.tokenStream.LA(1); + if (!(_la === 435 || _la === 686)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + break; + case 15: + localContext = new AlterByChangeColumnContext(localContext); + this.enterOuterAlt(localContext, 15); + { + this.state = 2790; + this.match(MySqlParser.KW_CHANGE); + this.state = 2792; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 336, this.context)) { + case 1: + { + this.state = 2791; + this.match(MySqlParser.KW_COLUMN); + } + break; + } + this.state = 2794; + localContext._oldColumn = this.columnName(); + this.state = 2795; + localContext._newColumn = this.columnNameCreate(); + this.state = 2796; + this.columnDefinition(); + this.state = 2800; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_FIRST: + { + this.state = 2797; + this.match(MySqlParser.KW_FIRST); + } + break; + case MySqlParser.KW_AFTER: + { + this.state = 2798; + this.match(MySqlParser.KW_AFTER); + this.state = 2799; + this.columnName(); + } + break; + case MySqlParser.EOF: + case MySqlParser.KW_ADD: + case MySqlParser.KW_ALTER: + case MySqlParser.KW_ANALYZE: + case MySqlParser.KW_CALL: + case MySqlParser.KW_CHANGE: + case MySqlParser.KW_CHECK: + case MySqlParser.KW_CREATE: + case MySqlParser.KW_DELETE: + case MySqlParser.KW_DESC: + case MySqlParser.KW_DESCRIBE: + case MySqlParser.KW_DROP: + case MySqlParser.KW_EXPLAIN: + case MySqlParser.KW_GET: + case MySqlParser.KW_GRANT: + case MySqlParser.KW_INSERT: + case MySqlParser.KW_KILL: + case MySqlParser.KW_LOAD: + case MySqlParser.KW_LOCK: + case MySqlParser.KW_OPTIMIZE: + case MySqlParser.KW_PURGE: + case MySqlParser.KW_RELEASE: + case MySqlParser.KW_RENAME: + case MySqlParser.KW_REPLACE: + case MySqlParser.KW_RESIGNAL: + case MySqlParser.KW_REVOKE: + case MySqlParser.KW_SELECT: + case MySqlParser.KW_SET: + case MySqlParser.KW_SHOW: + case MySqlParser.KW_SIGNAL: + case MySqlParser.KW_TABLE: + case MySqlParser.KW_UNLOCK: + case MySqlParser.KW_UPDATE: + case MySqlParser.KW_USE: + case MySqlParser.KW_VALUES: + case MySqlParser.KW_WITH: + case MySqlParser.KW_BEGIN: + case MySqlParser.KW_BINLOG: + case MySqlParser.KW_CACHE: + case MySqlParser.KW_CHECKSUM: + case MySqlParser.KW_COALESCE: + case MySqlParser.KW_COMMIT: + case MySqlParser.KW_DEALLOCATE: + case MySqlParser.KW_DISCARD: + case MySqlParser.KW_DO: + case MySqlParser.KW_EXCHANGE: + case MySqlParser.KW_FLUSH: + case MySqlParser.KW_HANDLER: + case MySqlParser.KW_HELP: + case MySqlParser.KW_IMPORT: + case MySqlParser.KW_INSTALL: + case MySqlParser.KW_PREPARE: + case MySqlParser.KW_REBUILD: + case MySqlParser.KW_REMOVE: + case MySqlParser.KW_REORGANIZE: + case MySqlParser.KW_REPAIR: + case MySqlParser.KW_RESET: + case MySqlParser.KW_RESTART: + case MySqlParser.KW_ROLLBACK: + case MySqlParser.KW_SAVEPOINT: + case MySqlParser.KW_START: + case MySqlParser.KW_STOP: + case MySqlParser.KW_TRUNCATE: + case MySqlParser.KW_UNINSTALL: + case MySqlParser.KW_UPGRADE: + case MySqlParser.KW_XA: + case MySqlParser.KW_CLONE: + case MySqlParser.KW_EXECUTE: + case MySqlParser.KW_SHUTDOWN: + case MySqlParser.LR_BRACKET: + case MySqlParser.COMMA: + case MySqlParser.SEMI: + break; + default: + break; + } + } + break; + case 16: + localContext = new AlterByDefaultCharsetContext(localContext); + this.enterOuterAlt(localContext, 16); + { + this.state = 2803; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 42) { + { + this.state = 2802; + this.match(MySqlParser.KW_DEFAULT); + } + } + this.state = 2805; + this.match(MySqlParser.KW_CHARACTER); + this.state = 2806; + this.match(MySqlParser.KW_SET); + this.state = 2807; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 2808; + this.charsetName(); + this.state = 2814; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 28) { + { + this.state = 2809; + this.match(MySqlParser.KW_COLLATE); + this.state = 2811; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 2810; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 2813; + this.collationName(); + } + } + } + break; + case 17: + localContext = new AlterByConvertCharsetContext(localContext); + this.enterOuterAlt(localContext, 17); + { + this.state = 2816; + this.match(MySqlParser.KW_CONVERT); + this.state = 2817; + this.match(MySqlParser.KW_TO); + this.state = 2821; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_CHARSET: + { + this.state = 2818; + this.match(MySqlParser.KW_CHARSET); + } + break; + case MySqlParser.KW_CHARACTER: + { + this.state = 2819; + this.match(MySqlParser.KW_CHARACTER); + this.state = 2820; + this.match(MySqlParser.KW_SET); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + this.state = 2823; + this.charsetName(); + this.state = 2826; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 28) { + { + this.state = 2824; + this.match(MySqlParser.KW_COLLATE); + this.state = 2825; + this.collationName(); + } + } + } + break; + case 18: + localContext = new AlterKeysContext(localContext); + this.enterOuterAlt(localContext, 18); + { + this.state = 2828; + _la = this.tokenStream.LA(1); + if (!(_la === 368 || _la === 375)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 2829; + this.match(MySqlParser.KW_KEYS); + } + break; + case 19: + localContext = new AlterTablespaceOptionContext(localContext); + this.enterOuterAlt(localContext, 19); + { + this.state = 2830; + _la = this.tokenStream.LA(1); + if (!(_la === 369 || _la === 425)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 2831; + this.match(MySqlParser.KW_TABLESPACE); + } + break; + case 20: + localContext = new AlterByDropColumnContext(localContext); + this.enterOuterAlt(localContext, 20); + { + this.state = 2832; + this.match(MySqlParser.KW_DROP); + this.state = 2834; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 343, this.context)) { + case 1: + { + this.state = 2833; + this.match(MySqlParser.KW_COLUMN); + } + break; + } + this.state = 2836; + this.columnName(); + } + break; + case 21: + localContext = new AlterByDropIndexContext(localContext); + this.enterOuterAlt(localContext, 21); + { + this.state = 2837; + this.match(MySqlParser.KW_DROP); + this.state = 2838; + _la = this.tokenStream.LA(1); + if (!(_la === 82 || _la === 92)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 2839; + this.indexName(); + } + break; + case 22: + localContext = new AlterByDropPrimaryKeyContext(localContext); + this.enterOuterAlt(localContext, 22); + { + this.state = 2840; + this.match(MySqlParser.KW_DROP); + this.state = 2841; + this.match(MySqlParser.KW_PRIMARY); + this.state = 2842; + this.match(MySqlParser.KW_KEY); + } + break; + case 23: + localContext = new AlterByDropForeignKeyContext(localContext); + this.enterOuterAlt(localContext, 23); + { + this.state = 2843; + this.match(MySqlParser.KW_DROP); + this.state = 2844; + this.match(MySqlParser.KW_FOREIGN); + this.state = 2845; + this.match(MySqlParser.KW_KEY); + this.state = 2846; + localContext._fk_symbol = this.uid(); + } + break; + case 24: + localContext = new AlterByForceContext(localContext); + this.enterOuterAlt(localContext, 24); + { + this.state = 2847; + this.match(MySqlParser.KW_FORCE); + } + break; + case 25: + localContext = new AlterByLockContext(localContext); + this.enterOuterAlt(localContext, 25); + { + this.state = 2848; + this.match(MySqlParser.KW_LOCK); + this.state = 2850; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 2849; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 2852; + localContext._lockType = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 42 || _la === 389 || _la === 505 || _la === 595)) { + localContext._lockType = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + break; + case 26: + localContext = new AlterByModifyColumnContext(localContext); + this.enterOuterAlt(localContext, 26); + { + this.state = 2853; + this.match(MySqlParser.KW_MODIFY); + this.state = 2855; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 345, this.context)) { + case 1: + { + this.state = 2854; + this.match(MySqlParser.KW_COLUMN); + } + break; + } + this.state = 2857; + this.columnName(); + this.state = 2858; + this.columnDefinition(); + this.state = 2862; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_FIRST: + { + this.state = 2859; + this.match(MySqlParser.KW_FIRST); + } + break; + case MySqlParser.KW_AFTER: + { + this.state = 2860; + this.match(MySqlParser.KW_AFTER); + this.state = 2861; + this.columnName(); + } + break; + case MySqlParser.EOF: + case MySqlParser.KW_ADD: + case MySqlParser.KW_ALTER: + case MySqlParser.KW_ANALYZE: + case MySqlParser.KW_CALL: + case MySqlParser.KW_CHANGE: + case MySqlParser.KW_CHECK: + case MySqlParser.KW_CREATE: + case MySqlParser.KW_DELETE: + case MySqlParser.KW_DESC: + case MySqlParser.KW_DESCRIBE: + case MySqlParser.KW_DROP: + case MySqlParser.KW_EXPLAIN: + case MySqlParser.KW_GET: + case MySqlParser.KW_GRANT: + case MySqlParser.KW_INSERT: + case MySqlParser.KW_KILL: + case MySqlParser.KW_LOAD: + case MySqlParser.KW_LOCK: + case MySqlParser.KW_OPTIMIZE: + case MySqlParser.KW_PURGE: + case MySqlParser.KW_RELEASE: + case MySqlParser.KW_RENAME: + case MySqlParser.KW_REPLACE: + case MySqlParser.KW_RESIGNAL: + case MySqlParser.KW_REVOKE: + case MySqlParser.KW_SELECT: + case MySqlParser.KW_SET: + case MySqlParser.KW_SHOW: + case MySqlParser.KW_SIGNAL: + case MySqlParser.KW_TABLE: + case MySqlParser.KW_UNLOCK: + case MySqlParser.KW_UPDATE: + case MySqlParser.KW_USE: + case MySqlParser.KW_VALUES: + case MySqlParser.KW_WITH: + case MySqlParser.KW_BEGIN: + case MySqlParser.KW_BINLOG: + case MySqlParser.KW_CACHE: + case MySqlParser.KW_CHECKSUM: + case MySqlParser.KW_COALESCE: + case MySqlParser.KW_COMMIT: + case MySqlParser.KW_DEALLOCATE: + case MySqlParser.KW_DISCARD: + case MySqlParser.KW_DO: + case MySqlParser.KW_EXCHANGE: + case MySqlParser.KW_FLUSH: + case MySqlParser.KW_HANDLER: + case MySqlParser.KW_HELP: + case MySqlParser.KW_IMPORT: + case MySqlParser.KW_INSTALL: + case MySqlParser.KW_PREPARE: + case MySqlParser.KW_REBUILD: + case MySqlParser.KW_REMOVE: + case MySqlParser.KW_REORGANIZE: + case MySqlParser.KW_REPAIR: + case MySqlParser.KW_RESET: + case MySqlParser.KW_RESTART: + case MySqlParser.KW_ROLLBACK: + case MySqlParser.KW_SAVEPOINT: + case MySqlParser.KW_START: + case MySqlParser.KW_STOP: + case MySqlParser.KW_TRUNCATE: + case MySqlParser.KW_UNINSTALL: + case MySqlParser.KW_UPGRADE: + case MySqlParser.KW_XA: + case MySqlParser.KW_CLONE: + case MySqlParser.KW_EXECUTE: + case MySqlParser.KW_SHUTDOWN: + case MySqlParser.LR_BRACKET: + case MySqlParser.COMMA: + case MySqlParser.SEMI: + break; + default: + break; + } + } + break; + case 27: + localContext = new AlterByOrderContext(localContext); + this.enterOuterAlt(localContext, 27); + { + this.state = 2864; + this.match(MySqlParser.KW_ORDER); + this.state = 2865; + this.match(MySqlParser.KW_BY); + this.state = 2866; + this.columnNames(); + } + break; + case 28: + localContext = new AlterByRenameColumnContext(localContext); + this.enterOuterAlt(localContext, 28); + { + this.state = 2867; + this.match(MySqlParser.KW_RENAME); + this.state = 2868; + this.match(MySqlParser.KW_COLUMN); + this.state = 2869; + localContext._olcdColumn = this.columnName(); + this.state = 2870; + this.match(MySqlParser.KW_TO); + this.state = 2871; + localContext._newColumn = this.columnNameCreate(); + } + break; + case 29: + localContext = new AlterByRenameIndexContext(localContext); + this.enterOuterAlt(localContext, 29); + { + this.state = 2873; + this.match(MySqlParser.KW_RENAME); + this.state = 2874; + localContext._indexFormat = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 82 || _la === 92)) { + localContext._indexFormat = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 2875; + this.indexName(); + this.state = 2876; + this.match(MySqlParser.KW_TO); + this.state = 2877; + this.indexNameCreate(); + } + break; + case 30: + localContext = new AlterByRenameContext(localContext); + this.enterOuterAlt(localContext, 30); + { + this.state = 2879; + this.match(MySqlParser.KW_RENAME); + this.state = 2881; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 13 || _la === 176) { + { + this.state = 2880; + localContext._renameFormat = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 13 || _la === 176)) { + localContext._renameFormat = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + this.state = 2883; + this.tableNameCreate(); + } + break; + case 31: + localContext = new AlterByValidateContext(localContext); + this.enterOuterAlt(localContext, 31); + { + this.state = 2884; + _la = this.tokenStream.LA(1); + if (!(_la === 194 || _la === 690)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 2885; + this.match(MySqlParser.KW_VALIDATION); + } + break; + case 32: + localContext = new AlterPartitionContext(localContext); + this.enterOuterAlt(localContext, 32); + { + this.state = 2886; + this.alterPartitionSpecification(); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + alterPartitionSpecification() { + let localContext = new AlterPartitionSpecificationContext(this.context, this.state); + this.enterRule(localContext, 142, MySqlParser.RULE_alterPartitionSpecification); + let _la; + try { + this.state = 2987; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_ADD: + localContext = new AlterByAddPartitionContext(localContext); + this.enterOuterAlt(localContext, 1); + { + this.state = 2889; + this.match(MySqlParser.KW_ADD); + this.state = 2890; + this.match(MySqlParser.KW_PARTITION); + this.state = 2891; + this.match(MySqlParser.LR_BRACKET); + this.state = 2892; + this.partitionDefinition(); + this.state = 2897; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 2893; + this.match(MySqlParser.COMMA); + this.state = 2894; + this.partitionDefinition(); + } + } + this.state = 2899; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 2900; + this.match(MySqlParser.RR_BRACKET); + } + break; + case MySqlParser.KW_DROP: + localContext = new AlterByDropPartitionContext(localContext); + this.enterOuterAlt(localContext, 2); + { + this.state = 2902; + this.match(MySqlParser.KW_DROP); + this.state = 2903; + this.match(MySqlParser.KW_PARTITION); + this.state = 2904; + this.partitionNames(); + } + break; + case MySqlParser.KW_DISCARD: + localContext = new AlterByDiscardPartitionContext(localContext); + this.enterOuterAlt(localContext, 3); + { + this.state = 2905; + this.match(MySqlParser.KW_DISCARD); + this.state = 2906; + this.match(MySqlParser.KW_PARTITION); + this.state = 2909; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_ARRAY: + case MySqlParser.KW_ATTRIBUTE: + case MySqlParser.KW_BUCKETS: + case MySqlParser.KW_CONDITION: + case MySqlParser.KW_CURRENT: + case MySqlParser.KW_CURRENT_USER: + case MySqlParser.KW_DATABASE: + case MySqlParser.KW_DEFAULT: + case MySqlParser.KW_DIAGNOSTICS: + case MySqlParser.KW_EMPTY: + case MySqlParser.KW_ENFORCED: + case MySqlParser.KW_EXCEPT: + case MySqlParser.KW_GROUP: + case MySqlParser.KW_IF: + case MySqlParser.KW_INSERT: + case MySqlParser.KW_LATERAL: + case MySqlParser.KW_LEFT: + case MySqlParser.KW_NUMBER: + case MySqlParser.KW_OPTIONAL: + case MySqlParser.KW_ORDER: + case MySqlParser.KW_PRIMARY: + case MySqlParser.KW_REPEAT: + case MySqlParser.KW_REPLACE: + case MySqlParser.KW_RIGHT: + case MySqlParser.KW_SCHEMA: + case MySqlParser.KW_SKIP_QUERY_REWRITE: + case MySqlParser.KW_STACKED: + case MySqlParser.KW_DATE: + case MySqlParser.KW_TIME: + case MySqlParser.KW_TIMESTAMP: + case MySqlParser.KW_DATETIME: + case MySqlParser.KW_YEAR: + case MySqlParser.KW_BINARY: + case MySqlParser.KW_TEXT: + case MySqlParser.KW_ENUM: + case MySqlParser.KW_SERIAL: + case MySqlParser.KW_JSON_TABLE: + case MySqlParser.KW_JSON_VALUE: + case MySqlParser.KW_NESTED: + case MySqlParser.KW_ORDINALITY: + case MySqlParser.KW_PATH: + case MySqlParser.KW_AVG: + case MySqlParser.KW_BIT_AND: + case MySqlParser.KW_BIT_OR: + case MySqlParser.KW_BIT_XOR: + case MySqlParser.KW_COUNT: + case MySqlParser.KW_CUME_DIST: + case MySqlParser.KW_DENSE_RANK: + case MySqlParser.KW_FIRST_VALUE: + case MySqlParser.KW_GROUP_CONCAT: + case MySqlParser.KW_LAG: + case MySqlParser.KW_LAST_VALUE: + case MySqlParser.KW_LEAD: + case MySqlParser.KW_MAX: + case MySqlParser.KW_MIN: + case MySqlParser.KW_NTILE: + case MySqlParser.KW_NTH_VALUE: + case MySqlParser.KW_PERCENT_RANK: + case MySqlParser.KW_RANK: + case MySqlParser.KW_ROW_NUMBER: + case MySqlParser.KW_STD: + case MySqlParser.KW_STDDEV: + case MySqlParser.KW_STDDEV_POP: + case MySqlParser.KW_STDDEV_SAMP: + case MySqlParser.KW_SUM: + case MySqlParser.KW_VAR_POP: + case MySqlParser.KW_VAR_SAMP: + case MySqlParser.KW_VARIANCE: + case MySqlParser.KW_CURRENT_DATE: + case MySqlParser.KW_CURRENT_TIME: + case MySqlParser.KW_CURRENT_TIMESTAMP: + case MySqlParser.KW_LOCALTIME: + case MySqlParser.KW_CURDATE: + case MySqlParser.KW_CURTIME: + case MySqlParser.KW_DATE_ADD: + case MySqlParser.KW_DATE_SUB: + case MySqlParser.KW_LOCALTIMESTAMP: + case MySqlParser.KW_NOW: + case MySqlParser.KW_POSITION: + case MySqlParser.KW_SUBSTR: + case MySqlParser.KW_SUBSTRING: + case MySqlParser.KW_SYSDATE: + case MySqlParser.KW_TRIM: + case MySqlParser.KW_UTC_DATE: + case MySqlParser.KW_UTC_TIME: + case MySqlParser.KW_UTC_TIMESTAMP: + case MySqlParser.KW_ACCOUNT: + case MySqlParser.KW_ACTION: + case MySqlParser.KW_AFTER: + case MySqlParser.KW_AGGREGATE: + case MySqlParser.KW_ALGORITHM: + case MySqlParser.KW_ANY: + case MySqlParser.KW_AT: + case MySqlParser.KW_AUTHORS: + case MySqlParser.KW_AUTOCOMMIT: + case MySqlParser.KW_AUTOEXTEND_SIZE: + case MySqlParser.KW_AUTO_INCREMENT: + case MySqlParser.KW_AVG_ROW_LENGTH: + case MySqlParser.KW_BEGIN: + case MySqlParser.KW_BINLOG: + case MySqlParser.KW_BIT: + case MySqlParser.KW_BLOCK: + case MySqlParser.KW_BOOL: + case MySqlParser.KW_BOOLEAN: + case MySqlParser.KW_BTREE: + case MySqlParser.KW_CACHE: + case MySqlParser.KW_CASCADED: + case MySqlParser.KW_CHAIN: + case MySqlParser.KW_CHANGED: + case MySqlParser.KW_CHANNEL: + case MySqlParser.KW_CHECKSUM: + case MySqlParser.KW_CIPHER: + case MySqlParser.KW_CLASS_ORIGIN: + case MySqlParser.KW_CLIENT: + case MySqlParser.KW_CLOSE: + case MySqlParser.KW_COALESCE: + case MySqlParser.KW_CODE: + case MySqlParser.KW_COLUMNS: + case MySqlParser.KW_COLUMN_FORMAT: + case MySqlParser.KW_COLUMN_NAME: + case MySqlParser.KW_COMMENT: + case MySqlParser.KW_COMMIT: + case MySqlParser.KW_COMPACT: + case MySqlParser.KW_COMPLETION: + case MySqlParser.KW_COMPRESSED: + case MySqlParser.KW_COMPRESSION: + case MySqlParser.KW_CONCURRENT: + case MySqlParser.KW_CONNECT: + case MySqlParser.KW_CONNECTION: + case MySqlParser.KW_CONSISTENT: + case MySqlParser.KW_CONSTRAINT_CATALOG: + case MySqlParser.KW_CONSTRAINT_SCHEMA: + case MySqlParser.KW_CONSTRAINT_NAME: + case MySqlParser.KW_CONTAINS: + case MySqlParser.KW_CONTEXT: + case MySqlParser.KW_CONTRIBUTORS: + case MySqlParser.KW_COPY: + case MySqlParser.KW_CPU: + case MySqlParser.KW_CURSOR_NAME: + case MySqlParser.KW_DATA: + case MySqlParser.KW_DATAFILE: + case MySqlParser.KW_DEALLOCATE: + case MySqlParser.KW_DEFAULT_AUTH: + case MySqlParser.KW_DEFINER: + case MySqlParser.KW_DELAY_KEY_WRITE: + case MySqlParser.KW_DES_KEY_FILE: + case MySqlParser.KW_DIRECTORY: + case MySqlParser.KW_DISABLE: + case MySqlParser.KW_DISCARD: + case MySqlParser.KW_DISK: + case MySqlParser.KW_DO: + case MySqlParser.KW_DUMPFILE: + case MySqlParser.KW_DUPLICATE: + case MySqlParser.KW_DYNAMIC: + case MySqlParser.KW_ENABLE: + case MySqlParser.KW_ENCRYPTION: + case MySqlParser.KW_END: + case MySqlParser.KW_ENDS: + case MySqlParser.KW_ENGINE: + case MySqlParser.KW_ENGINES: + case MySqlParser.KW_ERROR: + case MySqlParser.KW_ERRORS: + case MySqlParser.KW_ESCAPE: + case MySqlParser.KW_EVENT: + case MySqlParser.KW_EVENTS: + case MySqlParser.KW_EVERY: + case MySqlParser.KW_EXCHANGE: + case MySqlParser.KW_EXCLUSIVE: + case MySqlParser.KW_EXPIRE: + case MySqlParser.KW_EXPORT: + case MySqlParser.KW_EXTENDED: + case MySqlParser.KW_EXTENT_SIZE: + case MySqlParser.KW_FAILED_LOGIN_ATTEMPTS: + case MySqlParser.KW_FAST: + case MySqlParser.KW_FAULTS: + case MySqlParser.KW_FIELDS: + case MySqlParser.KW_FILE_BLOCK_SIZE: + case MySqlParser.KW_FILTER: + case MySqlParser.KW_FIRST: + case MySqlParser.KW_FIXED: + case MySqlParser.KW_FLUSH: + case MySqlParser.KW_FOLLOWS: + case MySqlParser.KW_FOUND: + case MySqlParser.KW_FULL: + case MySqlParser.KW_FUNCTION: + case MySqlParser.KW_GENERAL: + case MySqlParser.KW_GLOBAL: + case MySqlParser.KW_GRANTS: + case MySqlParser.KW_GROUP_REPLICATION: + case MySqlParser.KW_HANDLER: + case MySqlParser.KW_HASH: + case MySqlParser.KW_HELP: + case MySqlParser.KW_HISTORY: + case MySqlParser.KW_HOST: + case MySqlParser.KW_HOSTS: + case MySqlParser.KW_IDENTIFIED: + case MySqlParser.KW_IGNORE_SERVER_IDS: + case MySqlParser.KW_IMPORT: + case MySqlParser.KW_INDEXES: + case MySqlParser.KW_INITIAL_SIZE: + case MySqlParser.KW_INPLACE: + case MySqlParser.KW_INSERT_METHOD: + case MySqlParser.KW_INSTALL: + case MySqlParser.KW_INSTANCE: + case MySqlParser.KW_INSTANT: + case MySqlParser.KW_INVISIBLE: + case MySqlParser.KW_INVOKER: + case MySqlParser.KW_IO: + case MySqlParser.KW_IO_THREAD: + case MySqlParser.KW_IPC: + case MySqlParser.KW_ISOLATION: + case MySqlParser.KW_ISSUER: + case MySqlParser.KW_JSON: + case MySqlParser.KW_KEY_BLOCK_SIZE: + case MySqlParser.KW_LANGUAGE: + case MySqlParser.KW_LAST: + case MySqlParser.KW_LEAVES: + case MySqlParser.KW_LESS: + case MySqlParser.KW_LEVEL: + case MySqlParser.KW_LIST: + case MySqlParser.KW_LOCAL: + case MySqlParser.KW_LOGFILE: + case MySqlParser.KW_LOGS: + case MySqlParser.KW_MASTER: + case MySqlParser.KW_MASTER_AUTO_POSITION: + case MySqlParser.KW_MASTER_CONNECT_RETRY: + case MySqlParser.KW_MASTER_DELAY: + case MySqlParser.KW_MASTER_HEARTBEAT_PERIOD: + case MySqlParser.KW_MASTER_HOST: + case MySqlParser.KW_MASTER_LOG_FILE: + case MySqlParser.KW_MASTER_LOG_POS: + case MySqlParser.KW_MASTER_PASSWORD: + case MySqlParser.KW_MASTER_PORT: + case MySqlParser.KW_MASTER_RETRY_COUNT: + case MySqlParser.KW_MASTER_SSL: + case MySqlParser.KW_MASTER_SSL_CA: + case MySqlParser.KW_MASTER_SSL_CAPATH: + case MySqlParser.KW_MASTER_SSL_CERT: + case MySqlParser.KW_MASTER_SSL_CIPHER: + case MySqlParser.KW_MASTER_SSL_CRL: + case MySqlParser.KW_MASTER_SSL_CRLPATH: + case MySqlParser.KW_MASTER_SSL_KEY: + case MySqlParser.KW_MASTER_TLS_VERSION: + case MySqlParser.KW_MASTER_USER: + case MySqlParser.KW_MAX_CONNECTIONS_PER_HOUR: + case MySqlParser.KW_MAX_QUERIES_PER_HOUR: + case MySqlParser.KW_MAX_ROWS: + case MySqlParser.KW_MAX_SIZE: + case MySqlParser.KW_MAX_UPDATES_PER_HOUR: + case MySqlParser.KW_MAX_USER_CONNECTIONS: + case MySqlParser.KW_MEDIUM: + case MySqlParser.KW_MEMBER: + case MySqlParser.KW_MERGE: + case MySqlParser.KW_MESSAGE_TEXT: + case MySqlParser.KW_MID: + case MySqlParser.KW_MIGRATE: + case MySqlParser.KW_MIN_ROWS: + case MySqlParser.KW_MODE: + case MySqlParser.KW_MODIFY: + case MySqlParser.KW_MUTEX: + case MySqlParser.KW_MYSQL: + case MySqlParser.KW_MYSQL_ERRNO: + case MySqlParser.KW_NAME: + case MySqlParser.KW_NAMES: + case MySqlParser.KW_NCHAR: + case MySqlParser.KW_NEVER: + case MySqlParser.KW_NEXT: + case MySqlParser.KW_NO: + case MySqlParser.KW_NOWAIT: + case MySqlParser.KW_NODEGROUP: + case MySqlParser.KW_NONE: + case MySqlParser.KW_ODBC: + case MySqlParser.KW_OFFLINE: + case MySqlParser.KW_OFFSET: + case MySqlParser.KW_OF: + case MySqlParser.KW_OLD_PASSWORD: + case MySqlParser.KW_ONE: + case MySqlParser.KW_ONLINE: + case MySqlParser.KW_ONLY: + case MySqlParser.KW_OPEN: + case MySqlParser.KW_OPTIMIZER_COSTS: + case MySqlParser.KW_OPTIONS: + case MySqlParser.KW_OWNER: + case MySqlParser.KW_PACK_KEYS: + case MySqlParser.KW_PAGE: + case MySqlParser.KW_PAGE_CHECKSUM: + case MySqlParser.KW_PARSER: + case MySqlParser.KW_PARTIAL: + case MySqlParser.KW_PARTITIONING: + case MySqlParser.KW_PARTITIONS: + case MySqlParser.KW_PASSWORD: + case MySqlParser.KW_PASSWORD_LOCK_TIME: + case MySqlParser.KW_PHASE: + case MySqlParser.KW_PLUGIN: + case MySqlParser.KW_PLUGIN_DIR: + case MySqlParser.KW_PLUGINS: + case MySqlParser.KW_PORT: + case MySqlParser.KW_PRECEDES: + case MySqlParser.KW_PREPARE: + case MySqlParser.KW_PRESERVE: + case MySqlParser.KW_PREV: + case MySqlParser.KW_PROCESSLIST: + case MySqlParser.KW_PROFILE: + case MySqlParser.KW_PROFILES: + case MySqlParser.KW_PROXY: + case MySqlParser.KW_QUERY: + case MySqlParser.KW_QUICK: + case MySqlParser.KW_REBUILD: + case MySqlParser.KW_RECOVER: + case MySqlParser.KW_RECURSIVE: + case MySqlParser.KW_REDO_BUFFER_SIZE: + case MySqlParser.KW_REDUNDANT: + case MySqlParser.KW_RELAY: + case MySqlParser.KW_RELAY_LOG_FILE: + case MySqlParser.KW_RELAY_LOG_POS: + case MySqlParser.KW_RELAYLOG: + case MySqlParser.KW_REMOVE: + case MySqlParser.KW_REORGANIZE: + case MySqlParser.KW_REPAIR: + case MySqlParser.KW_REPLICATE_DO_DB: + case MySqlParser.KW_REPLICATE_DO_TABLE: + case MySqlParser.KW_REPLICATE_IGNORE_DB: + case MySqlParser.KW_REPLICATE_IGNORE_TABLE: + case MySqlParser.KW_REPLICATE_REWRITE_DB: + case MySqlParser.KW_REPLICATE_WILD_DO_TABLE: + case MySqlParser.KW_REPLICATE_WILD_IGNORE_TABLE: + case MySqlParser.KW_REPLICATION: + case MySqlParser.KW_RESET: + case MySqlParser.KW_RESUME: + case MySqlParser.KW_RETURNED_SQLSTATE: + case MySqlParser.KW_RETURNS: + case MySqlParser.KW_REUSE: + case MySqlParser.KW_ROLE: + case MySqlParser.KW_ROLLBACK: + case MySqlParser.KW_ROLLUP: + case MySqlParser.KW_ROTATE: + case MySqlParser.KW_ROW: + case MySqlParser.KW_ROWS: + case MySqlParser.KW_ROW_FORMAT: + case MySqlParser.KW_SAVEPOINT: + case MySqlParser.KW_SCHEDULE: + case MySqlParser.KW_SECURITY: + case MySqlParser.KW_SERVER: + case MySqlParser.KW_SESSION: + case MySqlParser.KW_SHARE: + case MySqlParser.KW_SHARED: + case MySqlParser.KW_SIGNED: + case MySqlParser.KW_SIMPLE: + case MySqlParser.KW_SLAVE: + case MySqlParser.KW_SLOW: + case MySqlParser.KW_SNAPSHOT: + case MySqlParser.KW_SOCKET: + case MySqlParser.KW_SOME: + case MySqlParser.KW_SONAME: + case MySqlParser.KW_SOUNDS: + case MySqlParser.KW_SOURCE: + case MySqlParser.KW_SQL_AFTER_GTIDS: + case MySqlParser.KW_SQL_AFTER_MTS_GAPS: + case MySqlParser.KW_SQL_BEFORE_GTIDS: + case MySqlParser.KW_SQL_BUFFER_RESULT: + case MySqlParser.KW_SQL_CACHE: + case MySqlParser.KW_SQL_NO_CACHE: + case MySqlParser.KW_SQL_THREAD: + case MySqlParser.KW_START: + case MySqlParser.KW_STARTS: + case MySqlParser.KW_STATS_AUTO_RECALC: + case MySqlParser.KW_STATS_PERSISTENT: + case MySqlParser.KW_STATS_SAMPLE_PAGES: + case MySqlParser.KW_STATUS: + case MySqlParser.KW_STOP: + case MySqlParser.KW_STORAGE: + case MySqlParser.KW_STRING: + case MySqlParser.KW_SUBCLASS_ORIGIN: + case MySqlParser.KW_SUBJECT: + case MySqlParser.KW_SUBPARTITION: + case MySqlParser.KW_SUBPARTITIONS: + case MySqlParser.KW_SUSPEND: + case MySqlParser.KW_SWAPS: + case MySqlParser.KW_SWITCHES: + case MySqlParser.KW_TABLE_NAME: + case MySqlParser.KW_TABLESPACE: + case MySqlParser.KW_TABLE_TYPE: + case MySqlParser.KW_TEMPORARY: + case MySqlParser.KW_TEMPTABLE: + case MySqlParser.KW_THAN: + case MySqlParser.KW_TRADITIONAL: + case MySqlParser.KW_TRANSACTION: + case MySqlParser.KW_TRANSACTIONAL: + case MySqlParser.KW_TRIGGERS: + case MySqlParser.KW_TRUNCATE: + case MySqlParser.KW_UNBOUNDED: + case MySqlParser.KW_UNDEFINED: + case MySqlParser.KW_UNDOFILE: + case MySqlParser.KW_UNDO_BUFFER_SIZE: + case MySqlParser.KW_UNINSTALL: + case MySqlParser.KW_UNKNOWN: + case MySqlParser.KW_UNTIL: + case MySqlParser.KW_UPGRADE: + case MySqlParser.KW_USER: + case MySqlParser.KW_USE_FRM: + case MySqlParser.KW_USER_RESOURCES: + case MySqlParser.KW_VALIDATION: + case MySqlParser.KW_VALUE: + case MySqlParser.KW_VARIABLES: + case MySqlParser.KW_VIEW: + case MySqlParser.KW_VIRTUAL: + case MySqlParser.KW_VISIBLE: + case MySqlParser.KW_WAIT: + case MySqlParser.KW_WARNINGS: + case MySqlParser.KW_WITHOUT: + case MySqlParser.KW_WORK: + case MySqlParser.KW_WRAPPER: + case MySqlParser.KW_X509: + case MySqlParser.KW_XA: + case MySqlParser.KW_XML: + case MySqlParser.KW_QUARTER: + case MySqlParser.KW_MONTH: + case MySqlParser.KW_DAY: + case MySqlParser.KW_HOUR: + case MySqlParser.KW_MINUTE: + case MySqlParser.KW_WEEK: + case MySqlParser.KW_SECOND: + case MySqlParser.KW_MICROSECOND: + case MySqlParser.KW_ADMIN: + case MySqlParser.KW_AUDIT_ABORT_EXEMPT: + case MySqlParser.KW_AUDIT_ADMIN: + case MySqlParser.KW_AUTHENTICATION_POLICY_ADMIN: + case MySqlParser.KW_BACKUP_ADMIN: + case MySqlParser.KW_BINLOG_ADMIN: + case MySqlParser.KW_BINLOG_ENCRYPTION_ADMIN: + case MySqlParser.KW_CLONE_ADMIN: + case MySqlParser.KW_CONNECTION_ADMIN: + case MySqlParser.KW_ENCRYPTION_KEY_ADMIN: + case MySqlParser.KW_EXECUTE: + case MySqlParser.KW_FILE: + case MySqlParser.KW_FIREWALL_ADMIN: + case MySqlParser.KW_FIREWALL_EXEMPT: + case MySqlParser.KW_FIREWALL_USER: + case MySqlParser.KW_GROUP_REPLICATION_ADMIN: + case MySqlParser.KW_INNODB_REDO_LOG_ARCHIVE: + case MySqlParser.KW_INVOKE: + case MySqlParser.KW_LAMBDA: + case MySqlParser.KW_NDB_STORED_USER: + case MySqlParser.KW_PASSWORDLESS_USER_ADMIN: + case MySqlParser.KW_PERSIST_RO_VARIABLES_ADMIN: + case MySqlParser.KW_PRIVILEGES: + case MySqlParser.KW_PROCESS: + case MySqlParser.KW_RELOAD: + case MySqlParser.KW_REPLICATION_APPLIER: + case MySqlParser.KW_REPLICATION_SLAVE_ADMIN: + case MySqlParser.KW_RESOURCE_GROUP_ADMIN: + case MySqlParser.KW_RESOURCE_GROUP_USER: + case MySqlParser.KW_ROLE_ADMIN: + case MySqlParser.KW_ROUTINE: + case MySqlParser.KW_S3: + case MySqlParser.KW_SESSION_VARIABLES_ADMIN: + case MySqlParser.KW_SET_USER_ID: + case MySqlParser.KW_SHOW_ROUTINE: + case MySqlParser.KW_SHUTDOWN: + case MySqlParser.KW_SUPER: + case MySqlParser.KW_SYSTEM_VARIABLES_ADMIN: + case MySqlParser.KW_TABLES: + case MySqlParser.KW_TABLE_ENCRYPTION_ADMIN: + case MySqlParser.KW_VERSION_TOKEN_ADMIN: + case MySqlParser.KW_XA_RECOVER_ADMIN: + case MySqlParser.KW_ARMSCII8: + case MySqlParser.KW_ASCII: + case MySqlParser.KW_BIG5: + case MySqlParser.KW_CP1250: + case MySqlParser.KW_CP1251: + case MySqlParser.KW_CP1256: + case MySqlParser.KW_CP1257: + case MySqlParser.KW_CP850: + case MySqlParser.KW_CP852: + case MySqlParser.KW_CP866: + case MySqlParser.KW_CP932: + case MySqlParser.KW_DEC8: + case MySqlParser.KW_EUCJPMS: + case MySqlParser.KW_EUCKR: + case MySqlParser.KW_GB18030: + case MySqlParser.KW_GB2312: + case MySqlParser.KW_GBK: + case MySqlParser.KW_GEOSTD8: + case MySqlParser.KW_GREEK: + case MySqlParser.KW_HEBREW: + case MySqlParser.KW_HP8: + case MySqlParser.KW_KEYBCS2: + case MySqlParser.KW_KOI8R: + case MySqlParser.KW_KOI8U: + case MySqlParser.KW_LATIN1: + case MySqlParser.KW_LATIN2: + case MySqlParser.KW_LATIN5: + case MySqlParser.KW_LATIN7: + case MySqlParser.KW_MACCE: + case MySqlParser.KW_MACROMAN: + case MySqlParser.KW_SJIS: + case MySqlParser.KW_SWE7: + case MySqlParser.KW_TIS620: + case MySqlParser.KW_UCS2: + case MySqlParser.KW_UJIS: + case MySqlParser.KW_UTF16: + case MySqlParser.KW_UTF16LE: + case MySqlParser.KW_UTF32: + case MySqlParser.KW_UTF8: + case MySqlParser.KW_UTF8MB3: + case MySqlParser.KW_UTF8MB4: + case MySqlParser.KW_ARCHIVE: + case MySqlParser.KW_BLACKHOLE: + case MySqlParser.KW_CSV: + case MySqlParser.KW_FEDERATED: + case MySqlParser.KW_INNODB: + case MySqlParser.KW_MEMORY: + case MySqlParser.KW_MRG_MYISAM: + case MySqlParser.KW_MYISAM: + case MySqlParser.KW_NDB: + case MySqlParser.KW_NDBCLUSTER: + case MySqlParser.KW_PERFORMANCE_SCHEMA: + case MySqlParser.KW_TOKUDB: + case MySqlParser.KW_REPEATABLE: + case MySqlParser.KW_COMMITTED: + case MySqlParser.KW_UNCOMMITTED: + case MySqlParser.KW_SERIALIZABLE: + case MySqlParser.KW_GEOMETRYCOLLECTION: + case MySqlParser.KW_LINESTRING: + case MySqlParser.KW_MULTILINESTRING: + case MySqlParser.KW_MULTIPOINT: + case MySqlParser.KW_MULTIPOLYGON: + case MySqlParser.KW_POINT: + case MySqlParser.KW_POLYGON: + case MySqlParser.KW_CATALOG_NAME: + case MySqlParser.KW_CHARSET: + case MySqlParser.KW_COLLATION: + case MySqlParser.KW_ENGINE_ATTRIBUTE: + case MySqlParser.KW_FORMAT: + case MySqlParser.KW_GET_FORMAT: + case MySqlParser.KW_RANDOM: + case MySqlParser.KW_REVERSE: + case MySqlParser.KW_ROW_COUNT: + case MySqlParser.KW_SCHEMA_NAME: + case MySqlParser.KW_SECONDARY_ENGINE_ATTRIBUTE: + case MySqlParser.KW_SRID: + case MySqlParser.KW_SYSTEM_USER: + case MySqlParser.KW_TP_CONNECTION_ADMIN: + case MySqlParser.KW_WEIGHT_STRING: + case MySqlParser.MOD: + case MySqlParser.CHARSET_REVERSE_QOUTE_STRING: + case MySqlParser.STRING_LITERAL: + case MySqlParser.ID: + { + this.state = 2907; + this.partitionNames(); + } + break; + case MySqlParser.KW_ALL: + { + this.state = 2908; + this.match(MySqlParser.KW_ALL); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + this.state = 2911; + this.match(MySqlParser.KW_TABLESPACE); + } + break; + case MySqlParser.KW_IMPORT: + localContext = new AlterByImportPartitionContext(localContext); + this.enterOuterAlt(localContext, 4); + { + this.state = 2912; + this.match(MySqlParser.KW_IMPORT); + this.state = 2913; + this.match(MySqlParser.KW_PARTITION); + this.state = 2916; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_ARRAY: + case MySqlParser.KW_ATTRIBUTE: + case MySqlParser.KW_BUCKETS: + case MySqlParser.KW_CONDITION: + case MySqlParser.KW_CURRENT: + case MySqlParser.KW_CURRENT_USER: + case MySqlParser.KW_DATABASE: + case MySqlParser.KW_DEFAULT: + case MySqlParser.KW_DIAGNOSTICS: + case MySqlParser.KW_EMPTY: + case MySqlParser.KW_ENFORCED: + case MySqlParser.KW_EXCEPT: + case MySqlParser.KW_GROUP: + case MySqlParser.KW_IF: + case MySqlParser.KW_INSERT: + case MySqlParser.KW_LATERAL: + case MySqlParser.KW_LEFT: + case MySqlParser.KW_NUMBER: + case MySqlParser.KW_OPTIONAL: + case MySqlParser.KW_ORDER: + case MySqlParser.KW_PRIMARY: + case MySqlParser.KW_REPEAT: + case MySqlParser.KW_REPLACE: + case MySqlParser.KW_RIGHT: + case MySqlParser.KW_SCHEMA: + case MySqlParser.KW_SKIP_QUERY_REWRITE: + case MySqlParser.KW_STACKED: + case MySqlParser.KW_DATE: + case MySqlParser.KW_TIME: + case MySqlParser.KW_TIMESTAMP: + case MySqlParser.KW_DATETIME: + case MySqlParser.KW_YEAR: + case MySqlParser.KW_BINARY: + case MySqlParser.KW_TEXT: + case MySqlParser.KW_ENUM: + case MySqlParser.KW_SERIAL: + case MySqlParser.KW_JSON_TABLE: + case MySqlParser.KW_JSON_VALUE: + case MySqlParser.KW_NESTED: + case MySqlParser.KW_ORDINALITY: + case MySqlParser.KW_PATH: + case MySqlParser.KW_AVG: + case MySqlParser.KW_BIT_AND: + case MySqlParser.KW_BIT_OR: + case MySqlParser.KW_BIT_XOR: + case MySqlParser.KW_COUNT: + case MySqlParser.KW_CUME_DIST: + case MySqlParser.KW_DENSE_RANK: + case MySqlParser.KW_FIRST_VALUE: + case MySqlParser.KW_GROUP_CONCAT: + case MySqlParser.KW_LAG: + case MySqlParser.KW_LAST_VALUE: + case MySqlParser.KW_LEAD: + case MySqlParser.KW_MAX: + case MySqlParser.KW_MIN: + case MySqlParser.KW_NTILE: + case MySqlParser.KW_NTH_VALUE: + case MySqlParser.KW_PERCENT_RANK: + case MySqlParser.KW_RANK: + case MySqlParser.KW_ROW_NUMBER: + case MySqlParser.KW_STD: + case MySqlParser.KW_STDDEV: + case MySqlParser.KW_STDDEV_POP: + case MySqlParser.KW_STDDEV_SAMP: + case MySqlParser.KW_SUM: + case MySqlParser.KW_VAR_POP: + case MySqlParser.KW_VAR_SAMP: + case MySqlParser.KW_VARIANCE: + case MySqlParser.KW_CURRENT_DATE: + case MySqlParser.KW_CURRENT_TIME: + case MySqlParser.KW_CURRENT_TIMESTAMP: + case MySqlParser.KW_LOCALTIME: + case MySqlParser.KW_CURDATE: + case MySqlParser.KW_CURTIME: + case MySqlParser.KW_DATE_ADD: + case MySqlParser.KW_DATE_SUB: + case MySqlParser.KW_LOCALTIMESTAMP: + case MySqlParser.KW_NOW: + case MySqlParser.KW_POSITION: + case MySqlParser.KW_SUBSTR: + case MySqlParser.KW_SUBSTRING: + case MySqlParser.KW_SYSDATE: + case MySqlParser.KW_TRIM: + case MySqlParser.KW_UTC_DATE: + case MySqlParser.KW_UTC_TIME: + case MySqlParser.KW_UTC_TIMESTAMP: + case MySqlParser.KW_ACCOUNT: + case MySqlParser.KW_ACTION: + case MySqlParser.KW_AFTER: + case MySqlParser.KW_AGGREGATE: + case MySqlParser.KW_ALGORITHM: + case MySqlParser.KW_ANY: + case MySqlParser.KW_AT: + case MySqlParser.KW_AUTHORS: + case MySqlParser.KW_AUTOCOMMIT: + case MySqlParser.KW_AUTOEXTEND_SIZE: + case MySqlParser.KW_AUTO_INCREMENT: + case MySqlParser.KW_AVG_ROW_LENGTH: + case MySqlParser.KW_BEGIN: + case MySqlParser.KW_BINLOG: + case MySqlParser.KW_BIT: + case MySqlParser.KW_BLOCK: + case MySqlParser.KW_BOOL: + case MySqlParser.KW_BOOLEAN: + case MySqlParser.KW_BTREE: + case MySqlParser.KW_CACHE: + case MySqlParser.KW_CASCADED: + case MySqlParser.KW_CHAIN: + case MySqlParser.KW_CHANGED: + case MySqlParser.KW_CHANNEL: + case MySqlParser.KW_CHECKSUM: + case MySqlParser.KW_CIPHER: + case MySqlParser.KW_CLASS_ORIGIN: + case MySqlParser.KW_CLIENT: + case MySqlParser.KW_CLOSE: + case MySqlParser.KW_COALESCE: + case MySqlParser.KW_CODE: + case MySqlParser.KW_COLUMNS: + case MySqlParser.KW_COLUMN_FORMAT: + case MySqlParser.KW_COLUMN_NAME: + case MySqlParser.KW_COMMENT: + case MySqlParser.KW_COMMIT: + case MySqlParser.KW_COMPACT: + case MySqlParser.KW_COMPLETION: + case MySqlParser.KW_COMPRESSED: + case MySqlParser.KW_COMPRESSION: + case MySqlParser.KW_CONCURRENT: + case MySqlParser.KW_CONNECT: + case MySqlParser.KW_CONNECTION: + case MySqlParser.KW_CONSISTENT: + case MySqlParser.KW_CONSTRAINT_CATALOG: + case MySqlParser.KW_CONSTRAINT_SCHEMA: + case MySqlParser.KW_CONSTRAINT_NAME: + case MySqlParser.KW_CONTAINS: + case MySqlParser.KW_CONTEXT: + case MySqlParser.KW_CONTRIBUTORS: + case MySqlParser.KW_COPY: + case MySqlParser.KW_CPU: + case MySqlParser.KW_CURSOR_NAME: + case MySqlParser.KW_DATA: + case MySqlParser.KW_DATAFILE: + case MySqlParser.KW_DEALLOCATE: + case MySqlParser.KW_DEFAULT_AUTH: + case MySqlParser.KW_DEFINER: + case MySqlParser.KW_DELAY_KEY_WRITE: + case MySqlParser.KW_DES_KEY_FILE: + case MySqlParser.KW_DIRECTORY: + case MySqlParser.KW_DISABLE: + case MySqlParser.KW_DISCARD: + case MySqlParser.KW_DISK: + case MySqlParser.KW_DO: + case MySqlParser.KW_DUMPFILE: + case MySqlParser.KW_DUPLICATE: + case MySqlParser.KW_DYNAMIC: + case MySqlParser.KW_ENABLE: + case MySqlParser.KW_ENCRYPTION: + case MySqlParser.KW_END: + case MySqlParser.KW_ENDS: + case MySqlParser.KW_ENGINE: + case MySqlParser.KW_ENGINES: + case MySqlParser.KW_ERROR: + case MySqlParser.KW_ERRORS: + case MySqlParser.KW_ESCAPE: + case MySqlParser.KW_EVENT: + case MySqlParser.KW_EVENTS: + case MySqlParser.KW_EVERY: + case MySqlParser.KW_EXCHANGE: + case MySqlParser.KW_EXCLUSIVE: + case MySqlParser.KW_EXPIRE: + case MySqlParser.KW_EXPORT: + case MySqlParser.KW_EXTENDED: + case MySqlParser.KW_EXTENT_SIZE: + case MySqlParser.KW_FAILED_LOGIN_ATTEMPTS: + case MySqlParser.KW_FAST: + case MySqlParser.KW_FAULTS: + case MySqlParser.KW_FIELDS: + case MySqlParser.KW_FILE_BLOCK_SIZE: + case MySqlParser.KW_FILTER: + case MySqlParser.KW_FIRST: + case MySqlParser.KW_FIXED: + case MySqlParser.KW_FLUSH: + case MySqlParser.KW_FOLLOWS: + case MySqlParser.KW_FOUND: + case MySqlParser.KW_FULL: + case MySqlParser.KW_FUNCTION: + case MySqlParser.KW_GENERAL: + case MySqlParser.KW_GLOBAL: + case MySqlParser.KW_GRANTS: + case MySqlParser.KW_GROUP_REPLICATION: + case MySqlParser.KW_HANDLER: + case MySqlParser.KW_HASH: + case MySqlParser.KW_HELP: + case MySqlParser.KW_HISTORY: + case MySqlParser.KW_HOST: + case MySqlParser.KW_HOSTS: + case MySqlParser.KW_IDENTIFIED: + case MySqlParser.KW_IGNORE_SERVER_IDS: + case MySqlParser.KW_IMPORT: + case MySqlParser.KW_INDEXES: + case MySqlParser.KW_INITIAL_SIZE: + case MySqlParser.KW_INPLACE: + case MySqlParser.KW_INSERT_METHOD: + case MySqlParser.KW_INSTALL: + case MySqlParser.KW_INSTANCE: + case MySqlParser.KW_INSTANT: + case MySqlParser.KW_INVISIBLE: + case MySqlParser.KW_INVOKER: + case MySqlParser.KW_IO: + case MySqlParser.KW_IO_THREAD: + case MySqlParser.KW_IPC: + case MySqlParser.KW_ISOLATION: + case MySqlParser.KW_ISSUER: + case MySqlParser.KW_JSON: + case MySqlParser.KW_KEY_BLOCK_SIZE: + case MySqlParser.KW_LANGUAGE: + case MySqlParser.KW_LAST: + case MySqlParser.KW_LEAVES: + case MySqlParser.KW_LESS: + case MySqlParser.KW_LEVEL: + case MySqlParser.KW_LIST: + case MySqlParser.KW_LOCAL: + case MySqlParser.KW_LOGFILE: + case MySqlParser.KW_LOGS: + case MySqlParser.KW_MASTER: + case MySqlParser.KW_MASTER_AUTO_POSITION: + case MySqlParser.KW_MASTER_CONNECT_RETRY: + case MySqlParser.KW_MASTER_DELAY: + case MySqlParser.KW_MASTER_HEARTBEAT_PERIOD: + case MySqlParser.KW_MASTER_HOST: + case MySqlParser.KW_MASTER_LOG_FILE: + case MySqlParser.KW_MASTER_LOG_POS: + case MySqlParser.KW_MASTER_PASSWORD: + case MySqlParser.KW_MASTER_PORT: + case MySqlParser.KW_MASTER_RETRY_COUNT: + case MySqlParser.KW_MASTER_SSL: + case MySqlParser.KW_MASTER_SSL_CA: + case MySqlParser.KW_MASTER_SSL_CAPATH: + case MySqlParser.KW_MASTER_SSL_CERT: + case MySqlParser.KW_MASTER_SSL_CIPHER: + case MySqlParser.KW_MASTER_SSL_CRL: + case MySqlParser.KW_MASTER_SSL_CRLPATH: + case MySqlParser.KW_MASTER_SSL_KEY: + case MySqlParser.KW_MASTER_TLS_VERSION: + case MySqlParser.KW_MASTER_USER: + case MySqlParser.KW_MAX_CONNECTIONS_PER_HOUR: + case MySqlParser.KW_MAX_QUERIES_PER_HOUR: + case MySqlParser.KW_MAX_ROWS: + case MySqlParser.KW_MAX_SIZE: + case MySqlParser.KW_MAX_UPDATES_PER_HOUR: + case MySqlParser.KW_MAX_USER_CONNECTIONS: + case MySqlParser.KW_MEDIUM: + case MySqlParser.KW_MEMBER: + case MySqlParser.KW_MERGE: + case MySqlParser.KW_MESSAGE_TEXT: + case MySqlParser.KW_MID: + case MySqlParser.KW_MIGRATE: + case MySqlParser.KW_MIN_ROWS: + case MySqlParser.KW_MODE: + case MySqlParser.KW_MODIFY: + case MySqlParser.KW_MUTEX: + case MySqlParser.KW_MYSQL: + case MySqlParser.KW_MYSQL_ERRNO: + case MySqlParser.KW_NAME: + case MySqlParser.KW_NAMES: + case MySqlParser.KW_NCHAR: + case MySqlParser.KW_NEVER: + case MySqlParser.KW_NEXT: + case MySqlParser.KW_NO: + case MySqlParser.KW_NOWAIT: + case MySqlParser.KW_NODEGROUP: + case MySqlParser.KW_NONE: + case MySqlParser.KW_ODBC: + case MySqlParser.KW_OFFLINE: + case MySqlParser.KW_OFFSET: + case MySqlParser.KW_OF: + case MySqlParser.KW_OLD_PASSWORD: + case MySqlParser.KW_ONE: + case MySqlParser.KW_ONLINE: + case MySqlParser.KW_ONLY: + case MySqlParser.KW_OPEN: + case MySqlParser.KW_OPTIMIZER_COSTS: + case MySqlParser.KW_OPTIONS: + case MySqlParser.KW_OWNER: + case MySqlParser.KW_PACK_KEYS: + case MySqlParser.KW_PAGE: + case MySqlParser.KW_PAGE_CHECKSUM: + case MySqlParser.KW_PARSER: + case MySqlParser.KW_PARTIAL: + case MySqlParser.KW_PARTITIONING: + case MySqlParser.KW_PARTITIONS: + case MySqlParser.KW_PASSWORD: + case MySqlParser.KW_PASSWORD_LOCK_TIME: + case MySqlParser.KW_PHASE: + case MySqlParser.KW_PLUGIN: + case MySqlParser.KW_PLUGIN_DIR: + case MySqlParser.KW_PLUGINS: + case MySqlParser.KW_PORT: + case MySqlParser.KW_PRECEDES: + case MySqlParser.KW_PREPARE: + case MySqlParser.KW_PRESERVE: + case MySqlParser.KW_PREV: + case MySqlParser.KW_PROCESSLIST: + case MySqlParser.KW_PROFILE: + case MySqlParser.KW_PROFILES: + case MySqlParser.KW_PROXY: + case MySqlParser.KW_QUERY: + case MySqlParser.KW_QUICK: + case MySqlParser.KW_REBUILD: + case MySqlParser.KW_RECOVER: + case MySqlParser.KW_RECURSIVE: + case MySqlParser.KW_REDO_BUFFER_SIZE: + case MySqlParser.KW_REDUNDANT: + case MySqlParser.KW_RELAY: + case MySqlParser.KW_RELAY_LOG_FILE: + case MySqlParser.KW_RELAY_LOG_POS: + case MySqlParser.KW_RELAYLOG: + case MySqlParser.KW_REMOVE: + case MySqlParser.KW_REORGANIZE: + case MySqlParser.KW_REPAIR: + case MySqlParser.KW_REPLICATE_DO_DB: + case MySqlParser.KW_REPLICATE_DO_TABLE: + case MySqlParser.KW_REPLICATE_IGNORE_DB: + case MySqlParser.KW_REPLICATE_IGNORE_TABLE: + case MySqlParser.KW_REPLICATE_REWRITE_DB: + case MySqlParser.KW_REPLICATE_WILD_DO_TABLE: + case MySqlParser.KW_REPLICATE_WILD_IGNORE_TABLE: + case MySqlParser.KW_REPLICATION: + case MySqlParser.KW_RESET: + case MySqlParser.KW_RESUME: + case MySqlParser.KW_RETURNED_SQLSTATE: + case MySqlParser.KW_RETURNS: + case MySqlParser.KW_REUSE: + case MySqlParser.KW_ROLE: + case MySqlParser.KW_ROLLBACK: + case MySqlParser.KW_ROLLUP: + case MySqlParser.KW_ROTATE: + case MySqlParser.KW_ROW: + case MySqlParser.KW_ROWS: + case MySqlParser.KW_ROW_FORMAT: + case MySqlParser.KW_SAVEPOINT: + case MySqlParser.KW_SCHEDULE: + case MySqlParser.KW_SECURITY: + case MySqlParser.KW_SERVER: + case MySqlParser.KW_SESSION: + case MySqlParser.KW_SHARE: + case MySqlParser.KW_SHARED: + case MySqlParser.KW_SIGNED: + case MySqlParser.KW_SIMPLE: + case MySqlParser.KW_SLAVE: + case MySqlParser.KW_SLOW: + case MySqlParser.KW_SNAPSHOT: + case MySqlParser.KW_SOCKET: + case MySqlParser.KW_SOME: + case MySqlParser.KW_SONAME: + case MySqlParser.KW_SOUNDS: + case MySqlParser.KW_SOURCE: + case MySqlParser.KW_SQL_AFTER_GTIDS: + case MySqlParser.KW_SQL_AFTER_MTS_GAPS: + case MySqlParser.KW_SQL_BEFORE_GTIDS: + case MySqlParser.KW_SQL_BUFFER_RESULT: + case MySqlParser.KW_SQL_CACHE: + case MySqlParser.KW_SQL_NO_CACHE: + case MySqlParser.KW_SQL_THREAD: + case MySqlParser.KW_START: + case MySqlParser.KW_STARTS: + case MySqlParser.KW_STATS_AUTO_RECALC: + case MySqlParser.KW_STATS_PERSISTENT: + case MySqlParser.KW_STATS_SAMPLE_PAGES: + case MySqlParser.KW_STATUS: + case MySqlParser.KW_STOP: + case MySqlParser.KW_STORAGE: + case MySqlParser.KW_STRING: + case MySqlParser.KW_SUBCLASS_ORIGIN: + case MySqlParser.KW_SUBJECT: + case MySqlParser.KW_SUBPARTITION: + case MySqlParser.KW_SUBPARTITIONS: + case MySqlParser.KW_SUSPEND: + case MySqlParser.KW_SWAPS: + case MySqlParser.KW_SWITCHES: + case MySqlParser.KW_TABLE_NAME: + case MySqlParser.KW_TABLESPACE: + case MySqlParser.KW_TABLE_TYPE: + case MySqlParser.KW_TEMPORARY: + case MySqlParser.KW_TEMPTABLE: + case MySqlParser.KW_THAN: + case MySqlParser.KW_TRADITIONAL: + case MySqlParser.KW_TRANSACTION: + case MySqlParser.KW_TRANSACTIONAL: + case MySqlParser.KW_TRIGGERS: + case MySqlParser.KW_TRUNCATE: + case MySqlParser.KW_UNBOUNDED: + case MySqlParser.KW_UNDEFINED: + case MySqlParser.KW_UNDOFILE: + case MySqlParser.KW_UNDO_BUFFER_SIZE: + case MySqlParser.KW_UNINSTALL: + case MySqlParser.KW_UNKNOWN: + case MySqlParser.KW_UNTIL: + case MySqlParser.KW_UPGRADE: + case MySqlParser.KW_USER: + case MySqlParser.KW_USE_FRM: + case MySqlParser.KW_USER_RESOURCES: + case MySqlParser.KW_VALIDATION: + case MySqlParser.KW_VALUE: + case MySqlParser.KW_VARIABLES: + case MySqlParser.KW_VIEW: + case MySqlParser.KW_VIRTUAL: + case MySqlParser.KW_VISIBLE: + case MySqlParser.KW_WAIT: + case MySqlParser.KW_WARNINGS: + case MySqlParser.KW_WITHOUT: + case MySqlParser.KW_WORK: + case MySqlParser.KW_WRAPPER: + case MySqlParser.KW_X509: + case MySqlParser.KW_XA: + case MySqlParser.KW_XML: + case MySqlParser.KW_QUARTER: + case MySqlParser.KW_MONTH: + case MySqlParser.KW_DAY: + case MySqlParser.KW_HOUR: + case MySqlParser.KW_MINUTE: + case MySqlParser.KW_WEEK: + case MySqlParser.KW_SECOND: + case MySqlParser.KW_MICROSECOND: + case MySqlParser.KW_ADMIN: + case MySqlParser.KW_AUDIT_ABORT_EXEMPT: + case MySqlParser.KW_AUDIT_ADMIN: + case MySqlParser.KW_AUTHENTICATION_POLICY_ADMIN: + case MySqlParser.KW_BACKUP_ADMIN: + case MySqlParser.KW_BINLOG_ADMIN: + case MySqlParser.KW_BINLOG_ENCRYPTION_ADMIN: + case MySqlParser.KW_CLONE_ADMIN: + case MySqlParser.KW_CONNECTION_ADMIN: + case MySqlParser.KW_ENCRYPTION_KEY_ADMIN: + case MySqlParser.KW_EXECUTE: + case MySqlParser.KW_FILE: + case MySqlParser.KW_FIREWALL_ADMIN: + case MySqlParser.KW_FIREWALL_EXEMPT: + case MySqlParser.KW_FIREWALL_USER: + case MySqlParser.KW_GROUP_REPLICATION_ADMIN: + case MySqlParser.KW_INNODB_REDO_LOG_ARCHIVE: + case MySqlParser.KW_INVOKE: + case MySqlParser.KW_LAMBDA: + case MySqlParser.KW_NDB_STORED_USER: + case MySqlParser.KW_PASSWORDLESS_USER_ADMIN: + case MySqlParser.KW_PERSIST_RO_VARIABLES_ADMIN: + case MySqlParser.KW_PRIVILEGES: + case MySqlParser.KW_PROCESS: + case MySqlParser.KW_RELOAD: + case MySqlParser.KW_REPLICATION_APPLIER: + case MySqlParser.KW_REPLICATION_SLAVE_ADMIN: + case MySqlParser.KW_RESOURCE_GROUP_ADMIN: + case MySqlParser.KW_RESOURCE_GROUP_USER: + case MySqlParser.KW_ROLE_ADMIN: + case MySqlParser.KW_ROUTINE: + case MySqlParser.KW_S3: + case MySqlParser.KW_SESSION_VARIABLES_ADMIN: + case MySqlParser.KW_SET_USER_ID: + case MySqlParser.KW_SHOW_ROUTINE: + case MySqlParser.KW_SHUTDOWN: + case MySqlParser.KW_SUPER: + case MySqlParser.KW_SYSTEM_VARIABLES_ADMIN: + case MySqlParser.KW_TABLES: + case MySqlParser.KW_TABLE_ENCRYPTION_ADMIN: + case MySqlParser.KW_VERSION_TOKEN_ADMIN: + case MySqlParser.KW_XA_RECOVER_ADMIN: + case MySqlParser.KW_ARMSCII8: + case MySqlParser.KW_ASCII: + case MySqlParser.KW_BIG5: + case MySqlParser.KW_CP1250: + case MySqlParser.KW_CP1251: + case MySqlParser.KW_CP1256: + case MySqlParser.KW_CP1257: + case MySqlParser.KW_CP850: + case MySqlParser.KW_CP852: + case MySqlParser.KW_CP866: + case MySqlParser.KW_CP932: + case MySqlParser.KW_DEC8: + case MySqlParser.KW_EUCJPMS: + case MySqlParser.KW_EUCKR: + case MySqlParser.KW_GB18030: + case MySqlParser.KW_GB2312: + case MySqlParser.KW_GBK: + case MySqlParser.KW_GEOSTD8: + case MySqlParser.KW_GREEK: + case MySqlParser.KW_HEBREW: + case MySqlParser.KW_HP8: + case MySqlParser.KW_KEYBCS2: + case MySqlParser.KW_KOI8R: + case MySqlParser.KW_KOI8U: + case MySqlParser.KW_LATIN1: + case MySqlParser.KW_LATIN2: + case MySqlParser.KW_LATIN5: + case MySqlParser.KW_LATIN7: + case MySqlParser.KW_MACCE: + case MySqlParser.KW_MACROMAN: + case MySqlParser.KW_SJIS: + case MySqlParser.KW_SWE7: + case MySqlParser.KW_TIS620: + case MySqlParser.KW_UCS2: + case MySqlParser.KW_UJIS: + case MySqlParser.KW_UTF16: + case MySqlParser.KW_UTF16LE: + case MySqlParser.KW_UTF32: + case MySqlParser.KW_UTF8: + case MySqlParser.KW_UTF8MB3: + case MySqlParser.KW_UTF8MB4: + case MySqlParser.KW_ARCHIVE: + case MySqlParser.KW_BLACKHOLE: + case MySqlParser.KW_CSV: + case MySqlParser.KW_FEDERATED: + case MySqlParser.KW_INNODB: + case MySqlParser.KW_MEMORY: + case MySqlParser.KW_MRG_MYISAM: + case MySqlParser.KW_MYISAM: + case MySqlParser.KW_NDB: + case MySqlParser.KW_NDBCLUSTER: + case MySqlParser.KW_PERFORMANCE_SCHEMA: + case MySqlParser.KW_TOKUDB: + case MySqlParser.KW_REPEATABLE: + case MySqlParser.KW_COMMITTED: + case MySqlParser.KW_UNCOMMITTED: + case MySqlParser.KW_SERIALIZABLE: + case MySqlParser.KW_GEOMETRYCOLLECTION: + case MySqlParser.KW_LINESTRING: + case MySqlParser.KW_MULTILINESTRING: + case MySqlParser.KW_MULTIPOINT: + case MySqlParser.KW_MULTIPOLYGON: + case MySqlParser.KW_POINT: + case MySqlParser.KW_POLYGON: + case MySqlParser.KW_CATALOG_NAME: + case MySqlParser.KW_CHARSET: + case MySqlParser.KW_COLLATION: + case MySqlParser.KW_ENGINE_ATTRIBUTE: + case MySqlParser.KW_FORMAT: + case MySqlParser.KW_GET_FORMAT: + case MySqlParser.KW_RANDOM: + case MySqlParser.KW_REVERSE: + case MySqlParser.KW_ROW_COUNT: + case MySqlParser.KW_SCHEMA_NAME: + case MySqlParser.KW_SECONDARY_ENGINE_ATTRIBUTE: + case MySqlParser.KW_SRID: + case MySqlParser.KW_SYSTEM_USER: + case MySqlParser.KW_TP_CONNECTION_ADMIN: + case MySqlParser.KW_WEIGHT_STRING: + case MySqlParser.MOD: + case MySqlParser.CHARSET_REVERSE_QOUTE_STRING: + case MySqlParser.STRING_LITERAL: + case MySqlParser.ID: + { + this.state = 2914; + this.partitionNames(); + } + break; + case MySqlParser.KW_ALL: + { + this.state = 2915; + this.match(MySqlParser.KW_ALL); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + this.state = 2918; + this.match(MySqlParser.KW_TABLESPACE); + } + break; + case MySqlParser.KW_TRUNCATE: + localContext = new AlterByTruncatePartitionContext(localContext); + this.enterOuterAlt(localContext, 5); + { + this.state = 2919; + this.match(MySqlParser.KW_TRUNCATE); + this.state = 2920; + this.match(MySqlParser.KW_PARTITION); + this.state = 2923; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_ARRAY: + case MySqlParser.KW_ATTRIBUTE: + case MySqlParser.KW_BUCKETS: + case MySqlParser.KW_CONDITION: + case MySqlParser.KW_CURRENT: + case MySqlParser.KW_CURRENT_USER: + case MySqlParser.KW_DATABASE: + case MySqlParser.KW_DEFAULT: + case MySqlParser.KW_DIAGNOSTICS: + case MySqlParser.KW_EMPTY: + case MySqlParser.KW_ENFORCED: + case MySqlParser.KW_EXCEPT: + case MySqlParser.KW_GROUP: + case MySqlParser.KW_IF: + case MySqlParser.KW_INSERT: + case MySqlParser.KW_LATERAL: + case MySqlParser.KW_LEFT: + case MySqlParser.KW_NUMBER: + case MySqlParser.KW_OPTIONAL: + case MySqlParser.KW_ORDER: + case MySqlParser.KW_PRIMARY: + case MySqlParser.KW_REPEAT: + case MySqlParser.KW_REPLACE: + case MySqlParser.KW_RIGHT: + case MySqlParser.KW_SCHEMA: + case MySqlParser.KW_SKIP_QUERY_REWRITE: + case MySqlParser.KW_STACKED: + case MySqlParser.KW_DATE: + case MySqlParser.KW_TIME: + case MySqlParser.KW_TIMESTAMP: + case MySqlParser.KW_DATETIME: + case MySqlParser.KW_YEAR: + case MySqlParser.KW_BINARY: + case MySqlParser.KW_TEXT: + case MySqlParser.KW_ENUM: + case MySqlParser.KW_SERIAL: + case MySqlParser.KW_JSON_TABLE: + case MySqlParser.KW_JSON_VALUE: + case MySqlParser.KW_NESTED: + case MySqlParser.KW_ORDINALITY: + case MySqlParser.KW_PATH: + case MySqlParser.KW_AVG: + case MySqlParser.KW_BIT_AND: + case MySqlParser.KW_BIT_OR: + case MySqlParser.KW_BIT_XOR: + case MySqlParser.KW_COUNT: + case MySqlParser.KW_CUME_DIST: + case MySqlParser.KW_DENSE_RANK: + case MySqlParser.KW_FIRST_VALUE: + case MySqlParser.KW_GROUP_CONCAT: + case MySqlParser.KW_LAG: + case MySqlParser.KW_LAST_VALUE: + case MySqlParser.KW_LEAD: + case MySqlParser.KW_MAX: + case MySqlParser.KW_MIN: + case MySqlParser.KW_NTILE: + case MySqlParser.KW_NTH_VALUE: + case MySqlParser.KW_PERCENT_RANK: + case MySqlParser.KW_RANK: + case MySqlParser.KW_ROW_NUMBER: + case MySqlParser.KW_STD: + case MySqlParser.KW_STDDEV: + case MySqlParser.KW_STDDEV_POP: + case MySqlParser.KW_STDDEV_SAMP: + case MySqlParser.KW_SUM: + case MySqlParser.KW_VAR_POP: + case MySqlParser.KW_VAR_SAMP: + case MySqlParser.KW_VARIANCE: + case MySqlParser.KW_CURRENT_DATE: + case MySqlParser.KW_CURRENT_TIME: + case MySqlParser.KW_CURRENT_TIMESTAMP: + case MySqlParser.KW_LOCALTIME: + case MySqlParser.KW_CURDATE: + case MySqlParser.KW_CURTIME: + case MySqlParser.KW_DATE_ADD: + case MySqlParser.KW_DATE_SUB: + case MySqlParser.KW_LOCALTIMESTAMP: + case MySqlParser.KW_NOW: + case MySqlParser.KW_POSITION: + case MySqlParser.KW_SUBSTR: + case MySqlParser.KW_SUBSTRING: + case MySqlParser.KW_SYSDATE: + case MySqlParser.KW_TRIM: + case MySqlParser.KW_UTC_DATE: + case MySqlParser.KW_UTC_TIME: + case MySqlParser.KW_UTC_TIMESTAMP: + case MySqlParser.KW_ACCOUNT: + case MySqlParser.KW_ACTION: + case MySqlParser.KW_AFTER: + case MySqlParser.KW_AGGREGATE: + case MySqlParser.KW_ALGORITHM: + case MySqlParser.KW_ANY: + case MySqlParser.KW_AT: + case MySqlParser.KW_AUTHORS: + case MySqlParser.KW_AUTOCOMMIT: + case MySqlParser.KW_AUTOEXTEND_SIZE: + case MySqlParser.KW_AUTO_INCREMENT: + case MySqlParser.KW_AVG_ROW_LENGTH: + case MySqlParser.KW_BEGIN: + case MySqlParser.KW_BINLOG: + case MySqlParser.KW_BIT: + case MySqlParser.KW_BLOCK: + case MySqlParser.KW_BOOL: + case MySqlParser.KW_BOOLEAN: + case MySqlParser.KW_BTREE: + case MySqlParser.KW_CACHE: + case MySqlParser.KW_CASCADED: + case MySqlParser.KW_CHAIN: + case MySqlParser.KW_CHANGED: + case MySqlParser.KW_CHANNEL: + case MySqlParser.KW_CHECKSUM: + case MySqlParser.KW_CIPHER: + case MySqlParser.KW_CLASS_ORIGIN: + case MySqlParser.KW_CLIENT: + case MySqlParser.KW_CLOSE: + case MySqlParser.KW_COALESCE: + case MySqlParser.KW_CODE: + case MySqlParser.KW_COLUMNS: + case MySqlParser.KW_COLUMN_FORMAT: + case MySqlParser.KW_COLUMN_NAME: + case MySqlParser.KW_COMMENT: + case MySqlParser.KW_COMMIT: + case MySqlParser.KW_COMPACT: + case MySqlParser.KW_COMPLETION: + case MySqlParser.KW_COMPRESSED: + case MySqlParser.KW_COMPRESSION: + case MySqlParser.KW_CONCURRENT: + case MySqlParser.KW_CONNECT: + case MySqlParser.KW_CONNECTION: + case MySqlParser.KW_CONSISTENT: + case MySqlParser.KW_CONSTRAINT_CATALOG: + case MySqlParser.KW_CONSTRAINT_SCHEMA: + case MySqlParser.KW_CONSTRAINT_NAME: + case MySqlParser.KW_CONTAINS: + case MySqlParser.KW_CONTEXT: + case MySqlParser.KW_CONTRIBUTORS: + case MySqlParser.KW_COPY: + case MySqlParser.KW_CPU: + case MySqlParser.KW_CURSOR_NAME: + case MySqlParser.KW_DATA: + case MySqlParser.KW_DATAFILE: + case MySqlParser.KW_DEALLOCATE: + case MySqlParser.KW_DEFAULT_AUTH: + case MySqlParser.KW_DEFINER: + case MySqlParser.KW_DELAY_KEY_WRITE: + case MySqlParser.KW_DES_KEY_FILE: + case MySqlParser.KW_DIRECTORY: + case MySqlParser.KW_DISABLE: + case MySqlParser.KW_DISCARD: + case MySqlParser.KW_DISK: + case MySqlParser.KW_DO: + case MySqlParser.KW_DUMPFILE: + case MySqlParser.KW_DUPLICATE: + case MySqlParser.KW_DYNAMIC: + case MySqlParser.KW_ENABLE: + case MySqlParser.KW_ENCRYPTION: + case MySqlParser.KW_END: + case MySqlParser.KW_ENDS: + case MySqlParser.KW_ENGINE: + case MySqlParser.KW_ENGINES: + case MySqlParser.KW_ERROR: + case MySqlParser.KW_ERRORS: + case MySqlParser.KW_ESCAPE: + case MySqlParser.KW_EVENT: + case MySqlParser.KW_EVENTS: + case MySqlParser.KW_EVERY: + case MySqlParser.KW_EXCHANGE: + case MySqlParser.KW_EXCLUSIVE: + case MySqlParser.KW_EXPIRE: + case MySqlParser.KW_EXPORT: + case MySqlParser.KW_EXTENDED: + case MySqlParser.KW_EXTENT_SIZE: + case MySqlParser.KW_FAILED_LOGIN_ATTEMPTS: + case MySqlParser.KW_FAST: + case MySqlParser.KW_FAULTS: + case MySqlParser.KW_FIELDS: + case MySqlParser.KW_FILE_BLOCK_SIZE: + case MySqlParser.KW_FILTER: + case MySqlParser.KW_FIRST: + case MySqlParser.KW_FIXED: + case MySqlParser.KW_FLUSH: + case MySqlParser.KW_FOLLOWS: + case MySqlParser.KW_FOUND: + case MySqlParser.KW_FULL: + case MySqlParser.KW_FUNCTION: + case MySqlParser.KW_GENERAL: + case MySqlParser.KW_GLOBAL: + case MySqlParser.KW_GRANTS: + case MySqlParser.KW_GROUP_REPLICATION: + case MySqlParser.KW_HANDLER: + case MySqlParser.KW_HASH: + case MySqlParser.KW_HELP: + case MySqlParser.KW_HISTORY: + case MySqlParser.KW_HOST: + case MySqlParser.KW_HOSTS: + case MySqlParser.KW_IDENTIFIED: + case MySqlParser.KW_IGNORE_SERVER_IDS: + case MySqlParser.KW_IMPORT: + case MySqlParser.KW_INDEXES: + case MySqlParser.KW_INITIAL_SIZE: + case MySqlParser.KW_INPLACE: + case MySqlParser.KW_INSERT_METHOD: + case MySqlParser.KW_INSTALL: + case MySqlParser.KW_INSTANCE: + case MySqlParser.KW_INSTANT: + case MySqlParser.KW_INVISIBLE: + case MySqlParser.KW_INVOKER: + case MySqlParser.KW_IO: + case MySqlParser.KW_IO_THREAD: + case MySqlParser.KW_IPC: + case MySqlParser.KW_ISOLATION: + case MySqlParser.KW_ISSUER: + case MySqlParser.KW_JSON: + case MySqlParser.KW_KEY_BLOCK_SIZE: + case MySqlParser.KW_LANGUAGE: + case MySqlParser.KW_LAST: + case MySqlParser.KW_LEAVES: + case MySqlParser.KW_LESS: + case MySqlParser.KW_LEVEL: + case MySqlParser.KW_LIST: + case MySqlParser.KW_LOCAL: + case MySqlParser.KW_LOGFILE: + case MySqlParser.KW_LOGS: + case MySqlParser.KW_MASTER: + case MySqlParser.KW_MASTER_AUTO_POSITION: + case MySqlParser.KW_MASTER_CONNECT_RETRY: + case MySqlParser.KW_MASTER_DELAY: + case MySqlParser.KW_MASTER_HEARTBEAT_PERIOD: + case MySqlParser.KW_MASTER_HOST: + case MySqlParser.KW_MASTER_LOG_FILE: + case MySqlParser.KW_MASTER_LOG_POS: + case MySqlParser.KW_MASTER_PASSWORD: + case MySqlParser.KW_MASTER_PORT: + case MySqlParser.KW_MASTER_RETRY_COUNT: + case MySqlParser.KW_MASTER_SSL: + case MySqlParser.KW_MASTER_SSL_CA: + case MySqlParser.KW_MASTER_SSL_CAPATH: + case MySqlParser.KW_MASTER_SSL_CERT: + case MySqlParser.KW_MASTER_SSL_CIPHER: + case MySqlParser.KW_MASTER_SSL_CRL: + case MySqlParser.KW_MASTER_SSL_CRLPATH: + case MySqlParser.KW_MASTER_SSL_KEY: + case MySqlParser.KW_MASTER_TLS_VERSION: + case MySqlParser.KW_MASTER_USER: + case MySqlParser.KW_MAX_CONNECTIONS_PER_HOUR: + case MySqlParser.KW_MAX_QUERIES_PER_HOUR: + case MySqlParser.KW_MAX_ROWS: + case MySqlParser.KW_MAX_SIZE: + case MySqlParser.KW_MAX_UPDATES_PER_HOUR: + case MySqlParser.KW_MAX_USER_CONNECTIONS: + case MySqlParser.KW_MEDIUM: + case MySqlParser.KW_MEMBER: + case MySqlParser.KW_MERGE: + case MySqlParser.KW_MESSAGE_TEXT: + case MySqlParser.KW_MID: + case MySqlParser.KW_MIGRATE: + case MySqlParser.KW_MIN_ROWS: + case MySqlParser.KW_MODE: + case MySqlParser.KW_MODIFY: + case MySqlParser.KW_MUTEX: + case MySqlParser.KW_MYSQL: + case MySqlParser.KW_MYSQL_ERRNO: + case MySqlParser.KW_NAME: + case MySqlParser.KW_NAMES: + case MySqlParser.KW_NCHAR: + case MySqlParser.KW_NEVER: + case MySqlParser.KW_NEXT: + case MySqlParser.KW_NO: + case MySqlParser.KW_NOWAIT: + case MySqlParser.KW_NODEGROUP: + case MySqlParser.KW_NONE: + case MySqlParser.KW_ODBC: + case MySqlParser.KW_OFFLINE: + case MySqlParser.KW_OFFSET: + case MySqlParser.KW_OF: + case MySqlParser.KW_OLD_PASSWORD: + case MySqlParser.KW_ONE: + case MySqlParser.KW_ONLINE: + case MySqlParser.KW_ONLY: + case MySqlParser.KW_OPEN: + case MySqlParser.KW_OPTIMIZER_COSTS: + case MySqlParser.KW_OPTIONS: + case MySqlParser.KW_OWNER: + case MySqlParser.KW_PACK_KEYS: + case MySqlParser.KW_PAGE: + case MySqlParser.KW_PAGE_CHECKSUM: + case MySqlParser.KW_PARSER: + case MySqlParser.KW_PARTIAL: + case MySqlParser.KW_PARTITIONING: + case MySqlParser.KW_PARTITIONS: + case MySqlParser.KW_PASSWORD: + case MySqlParser.KW_PASSWORD_LOCK_TIME: + case MySqlParser.KW_PHASE: + case MySqlParser.KW_PLUGIN: + case MySqlParser.KW_PLUGIN_DIR: + case MySqlParser.KW_PLUGINS: + case MySqlParser.KW_PORT: + case MySqlParser.KW_PRECEDES: + case MySqlParser.KW_PREPARE: + case MySqlParser.KW_PRESERVE: + case MySqlParser.KW_PREV: + case MySqlParser.KW_PROCESSLIST: + case MySqlParser.KW_PROFILE: + case MySqlParser.KW_PROFILES: + case MySqlParser.KW_PROXY: + case MySqlParser.KW_QUERY: + case MySqlParser.KW_QUICK: + case MySqlParser.KW_REBUILD: + case MySqlParser.KW_RECOVER: + case MySqlParser.KW_RECURSIVE: + case MySqlParser.KW_REDO_BUFFER_SIZE: + case MySqlParser.KW_REDUNDANT: + case MySqlParser.KW_RELAY: + case MySqlParser.KW_RELAY_LOG_FILE: + case MySqlParser.KW_RELAY_LOG_POS: + case MySqlParser.KW_RELAYLOG: + case MySqlParser.KW_REMOVE: + case MySqlParser.KW_REORGANIZE: + case MySqlParser.KW_REPAIR: + case MySqlParser.KW_REPLICATE_DO_DB: + case MySqlParser.KW_REPLICATE_DO_TABLE: + case MySqlParser.KW_REPLICATE_IGNORE_DB: + case MySqlParser.KW_REPLICATE_IGNORE_TABLE: + case MySqlParser.KW_REPLICATE_REWRITE_DB: + case MySqlParser.KW_REPLICATE_WILD_DO_TABLE: + case MySqlParser.KW_REPLICATE_WILD_IGNORE_TABLE: + case MySqlParser.KW_REPLICATION: + case MySqlParser.KW_RESET: + case MySqlParser.KW_RESUME: + case MySqlParser.KW_RETURNED_SQLSTATE: + case MySqlParser.KW_RETURNS: + case MySqlParser.KW_REUSE: + case MySqlParser.KW_ROLE: + case MySqlParser.KW_ROLLBACK: + case MySqlParser.KW_ROLLUP: + case MySqlParser.KW_ROTATE: + case MySqlParser.KW_ROW: + case MySqlParser.KW_ROWS: + case MySqlParser.KW_ROW_FORMAT: + case MySqlParser.KW_SAVEPOINT: + case MySqlParser.KW_SCHEDULE: + case MySqlParser.KW_SECURITY: + case MySqlParser.KW_SERVER: + case MySqlParser.KW_SESSION: + case MySqlParser.KW_SHARE: + case MySqlParser.KW_SHARED: + case MySqlParser.KW_SIGNED: + case MySqlParser.KW_SIMPLE: + case MySqlParser.KW_SLAVE: + case MySqlParser.KW_SLOW: + case MySqlParser.KW_SNAPSHOT: + case MySqlParser.KW_SOCKET: + case MySqlParser.KW_SOME: + case MySqlParser.KW_SONAME: + case MySqlParser.KW_SOUNDS: + case MySqlParser.KW_SOURCE: + case MySqlParser.KW_SQL_AFTER_GTIDS: + case MySqlParser.KW_SQL_AFTER_MTS_GAPS: + case MySqlParser.KW_SQL_BEFORE_GTIDS: + case MySqlParser.KW_SQL_BUFFER_RESULT: + case MySqlParser.KW_SQL_CACHE: + case MySqlParser.KW_SQL_NO_CACHE: + case MySqlParser.KW_SQL_THREAD: + case MySqlParser.KW_START: + case MySqlParser.KW_STARTS: + case MySqlParser.KW_STATS_AUTO_RECALC: + case MySqlParser.KW_STATS_PERSISTENT: + case MySqlParser.KW_STATS_SAMPLE_PAGES: + case MySqlParser.KW_STATUS: + case MySqlParser.KW_STOP: + case MySqlParser.KW_STORAGE: + case MySqlParser.KW_STRING: + case MySqlParser.KW_SUBCLASS_ORIGIN: + case MySqlParser.KW_SUBJECT: + case MySqlParser.KW_SUBPARTITION: + case MySqlParser.KW_SUBPARTITIONS: + case MySqlParser.KW_SUSPEND: + case MySqlParser.KW_SWAPS: + case MySqlParser.KW_SWITCHES: + case MySqlParser.KW_TABLE_NAME: + case MySqlParser.KW_TABLESPACE: + case MySqlParser.KW_TABLE_TYPE: + case MySqlParser.KW_TEMPORARY: + case MySqlParser.KW_TEMPTABLE: + case MySqlParser.KW_THAN: + case MySqlParser.KW_TRADITIONAL: + case MySqlParser.KW_TRANSACTION: + case MySqlParser.KW_TRANSACTIONAL: + case MySqlParser.KW_TRIGGERS: + case MySqlParser.KW_TRUNCATE: + case MySqlParser.KW_UNBOUNDED: + case MySqlParser.KW_UNDEFINED: + case MySqlParser.KW_UNDOFILE: + case MySqlParser.KW_UNDO_BUFFER_SIZE: + case MySqlParser.KW_UNINSTALL: + case MySqlParser.KW_UNKNOWN: + case MySqlParser.KW_UNTIL: + case MySqlParser.KW_UPGRADE: + case MySqlParser.KW_USER: + case MySqlParser.KW_USE_FRM: + case MySqlParser.KW_USER_RESOURCES: + case MySqlParser.KW_VALIDATION: + case MySqlParser.KW_VALUE: + case MySqlParser.KW_VARIABLES: + case MySqlParser.KW_VIEW: + case MySqlParser.KW_VIRTUAL: + case MySqlParser.KW_VISIBLE: + case MySqlParser.KW_WAIT: + case MySqlParser.KW_WARNINGS: + case MySqlParser.KW_WITHOUT: + case MySqlParser.KW_WORK: + case MySqlParser.KW_WRAPPER: + case MySqlParser.KW_X509: + case MySqlParser.KW_XA: + case MySqlParser.KW_XML: + case MySqlParser.KW_QUARTER: + case MySqlParser.KW_MONTH: + case MySqlParser.KW_DAY: + case MySqlParser.KW_HOUR: + case MySqlParser.KW_MINUTE: + case MySqlParser.KW_WEEK: + case MySqlParser.KW_SECOND: + case MySqlParser.KW_MICROSECOND: + case MySqlParser.KW_ADMIN: + case MySqlParser.KW_AUDIT_ABORT_EXEMPT: + case MySqlParser.KW_AUDIT_ADMIN: + case MySqlParser.KW_AUTHENTICATION_POLICY_ADMIN: + case MySqlParser.KW_BACKUP_ADMIN: + case MySqlParser.KW_BINLOG_ADMIN: + case MySqlParser.KW_BINLOG_ENCRYPTION_ADMIN: + case MySqlParser.KW_CLONE_ADMIN: + case MySqlParser.KW_CONNECTION_ADMIN: + case MySqlParser.KW_ENCRYPTION_KEY_ADMIN: + case MySqlParser.KW_EXECUTE: + case MySqlParser.KW_FILE: + case MySqlParser.KW_FIREWALL_ADMIN: + case MySqlParser.KW_FIREWALL_EXEMPT: + case MySqlParser.KW_FIREWALL_USER: + case MySqlParser.KW_GROUP_REPLICATION_ADMIN: + case MySqlParser.KW_INNODB_REDO_LOG_ARCHIVE: + case MySqlParser.KW_INVOKE: + case MySqlParser.KW_LAMBDA: + case MySqlParser.KW_NDB_STORED_USER: + case MySqlParser.KW_PASSWORDLESS_USER_ADMIN: + case MySqlParser.KW_PERSIST_RO_VARIABLES_ADMIN: + case MySqlParser.KW_PRIVILEGES: + case MySqlParser.KW_PROCESS: + case MySqlParser.KW_RELOAD: + case MySqlParser.KW_REPLICATION_APPLIER: + case MySqlParser.KW_REPLICATION_SLAVE_ADMIN: + case MySqlParser.KW_RESOURCE_GROUP_ADMIN: + case MySqlParser.KW_RESOURCE_GROUP_USER: + case MySqlParser.KW_ROLE_ADMIN: + case MySqlParser.KW_ROUTINE: + case MySqlParser.KW_S3: + case MySqlParser.KW_SESSION_VARIABLES_ADMIN: + case MySqlParser.KW_SET_USER_ID: + case MySqlParser.KW_SHOW_ROUTINE: + case MySqlParser.KW_SHUTDOWN: + case MySqlParser.KW_SUPER: + case MySqlParser.KW_SYSTEM_VARIABLES_ADMIN: + case MySqlParser.KW_TABLES: + case MySqlParser.KW_TABLE_ENCRYPTION_ADMIN: + case MySqlParser.KW_VERSION_TOKEN_ADMIN: + case MySqlParser.KW_XA_RECOVER_ADMIN: + case MySqlParser.KW_ARMSCII8: + case MySqlParser.KW_ASCII: + case MySqlParser.KW_BIG5: + case MySqlParser.KW_CP1250: + case MySqlParser.KW_CP1251: + case MySqlParser.KW_CP1256: + case MySqlParser.KW_CP1257: + case MySqlParser.KW_CP850: + case MySqlParser.KW_CP852: + case MySqlParser.KW_CP866: + case MySqlParser.KW_CP932: + case MySqlParser.KW_DEC8: + case MySqlParser.KW_EUCJPMS: + case MySqlParser.KW_EUCKR: + case MySqlParser.KW_GB18030: + case MySqlParser.KW_GB2312: + case MySqlParser.KW_GBK: + case MySqlParser.KW_GEOSTD8: + case MySqlParser.KW_GREEK: + case MySqlParser.KW_HEBREW: + case MySqlParser.KW_HP8: + case MySqlParser.KW_KEYBCS2: + case MySqlParser.KW_KOI8R: + case MySqlParser.KW_KOI8U: + case MySqlParser.KW_LATIN1: + case MySqlParser.KW_LATIN2: + case MySqlParser.KW_LATIN5: + case MySqlParser.KW_LATIN7: + case MySqlParser.KW_MACCE: + case MySqlParser.KW_MACROMAN: + case MySqlParser.KW_SJIS: + case MySqlParser.KW_SWE7: + case MySqlParser.KW_TIS620: + case MySqlParser.KW_UCS2: + case MySqlParser.KW_UJIS: + case MySqlParser.KW_UTF16: + case MySqlParser.KW_UTF16LE: + case MySqlParser.KW_UTF32: + case MySqlParser.KW_UTF8: + case MySqlParser.KW_UTF8MB3: + case MySqlParser.KW_UTF8MB4: + case MySqlParser.KW_ARCHIVE: + case MySqlParser.KW_BLACKHOLE: + case MySqlParser.KW_CSV: + case MySqlParser.KW_FEDERATED: + case MySqlParser.KW_INNODB: + case MySqlParser.KW_MEMORY: + case MySqlParser.KW_MRG_MYISAM: + case MySqlParser.KW_MYISAM: + case MySqlParser.KW_NDB: + case MySqlParser.KW_NDBCLUSTER: + case MySqlParser.KW_PERFORMANCE_SCHEMA: + case MySqlParser.KW_TOKUDB: + case MySqlParser.KW_REPEATABLE: + case MySqlParser.KW_COMMITTED: + case MySqlParser.KW_UNCOMMITTED: + case MySqlParser.KW_SERIALIZABLE: + case MySqlParser.KW_GEOMETRYCOLLECTION: + case MySqlParser.KW_LINESTRING: + case MySqlParser.KW_MULTILINESTRING: + case MySqlParser.KW_MULTIPOINT: + case MySqlParser.KW_MULTIPOLYGON: + case MySqlParser.KW_POINT: + case MySqlParser.KW_POLYGON: + case MySqlParser.KW_CATALOG_NAME: + case MySqlParser.KW_CHARSET: + case MySqlParser.KW_COLLATION: + case MySqlParser.KW_ENGINE_ATTRIBUTE: + case MySqlParser.KW_FORMAT: + case MySqlParser.KW_GET_FORMAT: + case MySqlParser.KW_RANDOM: + case MySqlParser.KW_REVERSE: + case MySqlParser.KW_ROW_COUNT: + case MySqlParser.KW_SCHEMA_NAME: + case MySqlParser.KW_SECONDARY_ENGINE_ATTRIBUTE: + case MySqlParser.KW_SRID: + case MySqlParser.KW_SYSTEM_USER: + case MySqlParser.KW_TP_CONNECTION_ADMIN: + case MySqlParser.KW_WEIGHT_STRING: + case MySqlParser.MOD: + case MySqlParser.CHARSET_REVERSE_QOUTE_STRING: + case MySqlParser.STRING_LITERAL: + case MySqlParser.ID: + { + this.state = 2921; + this.partitionNames(); + } + break; + case MySqlParser.KW_ALL: + { + this.state = 2922; + this.match(MySqlParser.KW_ALL); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + break; + case MySqlParser.KW_COALESCE: + localContext = new AlterByCoalescePartitionContext(localContext); + this.enterOuterAlt(localContext, 6); + { + this.state = 2925; + this.match(MySqlParser.KW_COALESCE); + this.state = 2926; + this.match(MySqlParser.KW_PARTITION); + this.state = 2927; + this.decimalLiteral(); + } + break; + case MySqlParser.KW_REORGANIZE: + localContext = new AlterByReorganizePartitionContext(localContext); + this.enterOuterAlt(localContext, 7); + { + this.state = 2928; + this.match(MySqlParser.KW_REORGANIZE); + this.state = 2929; + this.match(MySqlParser.KW_PARTITION); + this.state = 2930; + this.partitionNames(); + this.state = 2931; + this.match(MySqlParser.KW_INTO); + this.state = 2932; + this.match(MySqlParser.LR_BRACKET); + this.state = 2933; + this.partitionDefinition(); + this.state = 2938; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 2934; + this.match(MySqlParser.COMMA); + this.state = 2935; + this.partitionDefinition(); + } + } + this.state = 2940; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 2941; + this.match(MySqlParser.RR_BRACKET); + } + break; + case MySqlParser.KW_EXCHANGE: + localContext = new AlterByExchangePartitionContext(localContext); + this.enterOuterAlt(localContext, 8); + { + this.state = 2943; + this.match(MySqlParser.KW_EXCHANGE); + this.state = 2944; + this.match(MySqlParser.KW_PARTITION); + this.state = 2945; + this.partitionName(); + this.state = 2946; + this.match(MySqlParser.KW_WITH); + this.state = 2947; + this.match(MySqlParser.KW_TABLE); + this.state = 2948; + this.tableName(); + this.state = 2951; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 354, this.context)) { + case 1: + { + this.state = 2949; + localContext._validationFormat = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 194 || _la === 690)) { + localContext._validationFormat = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 2950; + this.match(MySqlParser.KW_VALIDATION); + } + break; + } + } + break; + case MySqlParser.KW_ANALYZE: + localContext = new AlterByAnalyzePartitionContext(localContext); + this.enterOuterAlt(localContext, 9); + { + this.state = 2953; + this.match(MySqlParser.KW_ANALYZE); + this.state = 2954; + this.match(MySqlParser.KW_PARTITION); + this.state = 2957; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_ARRAY: + case MySqlParser.KW_ATTRIBUTE: + case MySqlParser.KW_BUCKETS: + case MySqlParser.KW_CONDITION: + case MySqlParser.KW_CURRENT: + case MySqlParser.KW_CURRENT_USER: + case MySqlParser.KW_DATABASE: + case MySqlParser.KW_DEFAULT: + case MySqlParser.KW_DIAGNOSTICS: + case MySqlParser.KW_EMPTY: + case MySqlParser.KW_ENFORCED: + case MySqlParser.KW_EXCEPT: + case MySqlParser.KW_GROUP: + case MySqlParser.KW_IF: + case MySqlParser.KW_INSERT: + case MySqlParser.KW_LATERAL: + case MySqlParser.KW_LEFT: + case MySqlParser.KW_NUMBER: + case MySqlParser.KW_OPTIONAL: + case MySqlParser.KW_ORDER: + case MySqlParser.KW_PRIMARY: + case MySqlParser.KW_REPEAT: + case MySqlParser.KW_REPLACE: + case MySqlParser.KW_RIGHT: + case MySqlParser.KW_SCHEMA: + case MySqlParser.KW_SKIP_QUERY_REWRITE: + case MySqlParser.KW_STACKED: + case MySqlParser.KW_DATE: + case MySqlParser.KW_TIME: + case MySqlParser.KW_TIMESTAMP: + case MySqlParser.KW_DATETIME: + case MySqlParser.KW_YEAR: + case MySqlParser.KW_BINARY: + case MySqlParser.KW_TEXT: + case MySqlParser.KW_ENUM: + case MySqlParser.KW_SERIAL: + case MySqlParser.KW_JSON_TABLE: + case MySqlParser.KW_JSON_VALUE: + case MySqlParser.KW_NESTED: + case MySqlParser.KW_ORDINALITY: + case MySqlParser.KW_PATH: + case MySqlParser.KW_AVG: + case MySqlParser.KW_BIT_AND: + case MySqlParser.KW_BIT_OR: + case MySqlParser.KW_BIT_XOR: + case MySqlParser.KW_COUNT: + case MySqlParser.KW_CUME_DIST: + case MySqlParser.KW_DENSE_RANK: + case MySqlParser.KW_FIRST_VALUE: + case MySqlParser.KW_GROUP_CONCAT: + case MySqlParser.KW_LAG: + case MySqlParser.KW_LAST_VALUE: + case MySqlParser.KW_LEAD: + case MySqlParser.KW_MAX: + case MySqlParser.KW_MIN: + case MySqlParser.KW_NTILE: + case MySqlParser.KW_NTH_VALUE: + case MySqlParser.KW_PERCENT_RANK: + case MySqlParser.KW_RANK: + case MySqlParser.KW_ROW_NUMBER: + case MySqlParser.KW_STD: + case MySqlParser.KW_STDDEV: + case MySqlParser.KW_STDDEV_POP: + case MySqlParser.KW_STDDEV_SAMP: + case MySqlParser.KW_SUM: + case MySqlParser.KW_VAR_POP: + case MySqlParser.KW_VAR_SAMP: + case MySqlParser.KW_VARIANCE: + case MySqlParser.KW_CURRENT_DATE: + case MySqlParser.KW_CURRENT_TIME: + case MySqlParser.KW_CURRENT_TIMESTAMP: + case MySqlParser.KW_LOCALTIME: + case MySqlParser.KW_CURDATE: + case MySqlParser.KW_CURTIME: + case MySqlParser.KW_DATE_ADD: + case MySqlParser.KW_DATE_SUB: + case MySqlParser.KW_LOCALTIMESTAMP: + case MySqlParser.KW_NOW: + case MySqlParser.KW_POSITION: + case MySqlParser.KW_SUBSTR: + case MySqlParser.KW_SUBSTRING: + case MySqlParser.KW_SYSDATE: + case MySqlParser.KW_TRIM: + case MySqlParser.KW_UTC_DATE: + case MySqlParser.KW_UTC_TIME: + case MySqlParser.KW_UTC_TIMESTAMP: + case MySqlParser.KW_ACCOUNT: + case MySqlParser.KW_ACTION: + case MySqlParser.KW_AFTER: + case MySqlParser.KW_AGGREGATE: + case MySqlParser.KW_ALGORITHM: + case MySqlParser.KW_ANY: + case MySqlParser.KW_AT: + case MySqlParser.KW_AUTHORS: + case MySqlParser.KW_AUTOCOMMIT: + case MySqlParser.KW_AUTOEXTEND_SIZE: + case MySqlParser.KW_AUTO_INCREMENT: + case MySqlParser.KW_AVG_ROW_LENGTH: + case MySqlParser.KW_BEGIN: + case MySqlParser.KW_BINLOG: + case MySqlParser.KW_BIT: + case MySqlParser.KW_BLOCK: + case MySqlParser.KW_BOOL: + case MySqlParser.KW_BOOLEAN: + case MySqlParser.KW_BTREE: + case MySqlParser.KW_CACHE: + case MySqlParser.KW_CASCADED: + case MySqlParser.KW_CHAIN: + case MySqlParser.KW_CHANGED: + case MySqlParser.KW_CHANNEL: + case MySqlParser.KW_CHECKSUM: + case MySqlParser.KW_CIPHER: + case MySqlParser.KW_CLASS_ORIGIN: + case MySqlParser.KW_CLIENT: + case MySqlParser.KW_CLOSE: + case MySqlParser.KW_COALESCE: + case MySqlParser.KW_CODE: + case MySqlParser.KW_COLUMNS: + case MySqlParser.KW_COLUMN_FORMAT: + case MySqlParser.KW_COLUMN_NAME: + case MySqlParser.KW_COMMENT: + case MySqlParser.KW_COMMIT: + case MySqlParser.KW_COMPACT: + case MySqlParser.KW_COMPLETION: + case MySqlParser.KW_COMPRESSED: + case MySqlParser.KW_COMPRESSION: + case MySqlParser.KW_CONCURRENT: + case MySqlParser.KW_CONNECT: + case MySqlParser.KW_CONNECTION: + case MySqlParser.KW_CONSISTENT: + case MySqlParser.KW_CONSTRAINT_CATALOG: + case MySqlParser.KW_CONSTRAINT_SCHEMA: + case MySqlParser.KW_CONSTRAINT_NAME: + case MySqlParser.KW_CONTAINS: + case MySqlParser.KW_CONTEXT: + case MySqlParser.KW_CONTRIBUTORS: + case MySqlParser.KW_COPY: + case MySqlParser.KW_CPU: + case MySqlParser.KW_CURSOR_NAME: + case MySqlParser.KW_DATA: + case MySqlParser.KW_DATAFILE: + case MySqlParser.KW_DEALLOCATE: + case MySqlParser.KW_DEFAULT_AUTH: + case MySqlParser.KW_DEFINER: + case MySqlParser.KW_DELAY_KEY_WRITE: + case MySqlParser.KW_DES_KEY_FILE: + case MySqlParser.KW_DIRECTORY: + case MySqlParser.KW_DISABLE: + case MySqlParser.KW_DISCARD: + case MySqlParser.KW_DISK: + case MySqlParser.KW_DO: + case MySqlParser.KW_DUMPFILE: + case MySqlParser.KW_DUPLICATE: + case MySqlParser.KW_DYNAMIC: + case MySqlParser.KW_ENABLE: + case MySqlParser.KW_ENCRYPTION: + case MySqlParser.KW_END: + case MySqlParser.KW_ENDS: + case MySqlParser.KW_ENGINE: + case MySqlParser.KW_ENGINES: + case MySqlParser.KW_ERROR: + case MySqlParser.KW_ERRORS: + case MySqlParser.KW_ESCAPE: + case MySqlParser.KW_EVENT: + case MySqlParser.KW_EVENTS: + case MySqlParser.KW_EVERY: + case MySqlParser.KW_EXCHANGE: + case MySqlParser.KW_EXCLUSIVE: + case MySqlParser.KW_EXPIRE: + case MySqlParser.KW_EXPORT: + case MySqlParser.KW_EXTENDED: + case MySqlParser.KW_EXTENT_SIZE: + case MySqlParser.KW_FAILED_LOGIN_ATTEMPTS: + case MySqlParser.KW_FAST: + case MySqlParser.KW_FAULTS: + case MySqlParser.KW_FIELDS: + case MySqlParser.KW_FILE_BLOCK_SIZE: + case MySqlParser.KW_FILTER: + case MySqlParser.KW_FIRST: + case MySqlParser.KW_FIXED: + case MySqlParser.KW_FLUSH: + case MySqlParser.KW_FOLLOWS: + case MySqlParser.KW_FOUND: + case MySqlParser.KW_FULL: + case MySqlParser.KW_FUNCTION: + case MySqlParser.KW_GENERAL: + case MySqlParser.KW_GLOBAL: + case MySqlParser.KW_GRANTS: + case MySqlParser.KW_GROUP_REPLICATION: + case MySqlParser.KW_HANDLER: + case MySqlParser.KW_HASH: + case MySqlParser.KW_HELP: + case MySqlParser.KW_HISTORY: + case MySqlParser.KW_HOST: + case MySqlParser.KW_HOSTS: + case MySqlParser.KW_IDENTIFIED: + case MySqlParser.KW_IGNORE_SERVER_IDS: + case MySqlParser.KW_IMPORT: + case MySqlParser.KW_INDEXES: + case MySqlParser.KW_INITIAL_SIZE: + case MySqlParser.KW_INPLACE: + case MySqlParser.KW_INSERT_METHOD: + case MySqlParser.KW_INSTALL: + case MySqlParser.KW_INSTANCE: + case MySqlParser.KW_INSTANT: + case MySqlParser.KW_INVISIBLE: + case MySqlParser.KW_INVOKER: + case MySqlParser.KW_IO: + case MySqlParser.KW_IO_THREAD: + case MySqlParser.KW_IPC: + case MySqlParser.KW_ISOLATION: + case MySqlParser.KW_ISSUER: + case MySqlParser.KW_JSON: + case MySqlParser.KW_KEY_BLOCK_SIZE: + case MySqlParser.KW_LANGUAGE: + case MySqlParser.KW_LAST: + case MySqlParser.KW_LEAVES: + case MySqlParser.KW_LESS: + case MySqlParser.KW_LEVEL: + case MySqlParser.KW_LIST: + case MySqlParser.KW_LOCAL: + case MySqlParser.KW_LOGFILE: + case MySqlParser.KW_LOGS: + case MySqlParser.KW_MASTER: + case MySqlParser.KW_MASTER_AUTO_POSITION: + case MySqlParser.KW_MASTER_CONNECT_RETRY: + case MySqlParser.KW_MASTER_DELAY: + case MySqlParser.KW_MASTER_HEARTBEAT_PERIOD: + case MySqlParser.KW_MASTER_HOST: + case MySqlParser.KW_MASTER_LOG_FILE: + case MySqlParser.KW_MASTER_LOG_POS: + case MySqlParser.KW_MASTER_PASSWORD: + case MySqlParser.KW_MASTER_PORT: + case MySqlParser.KW_MASTER_RETRY_COUNT: + case MySqlParser.KW_MASTER_SSL: + case MySqlParser.KW_MASTER_SSL_CA: + case MySqlParser.KW_MASTER_SSL_CAPATH: + case MySqlParser.KW_MASTER_SSL_CERT: + case MySqlParser.KW_MASTER_SSL_CIPHER: + case MySqlParser.KW_MASTER_SSL_CRL: + case MySqlParser.KW_MASTER_SSL_CRLPATH: + case MySqlParser.KW_MASTER_SSL_KEY: + case MySqlParser.KW_MASTER_TLS_VERSION: + case MySqlParser.KW_MASTER_USER: + case MySqlParser.KW_MAX_CONNECTIONS_PER_HOUR: + case MySqlParser.KW_MAX_QUERIES_PER_HOUR: + case MySqlParser.KW_MAX_ROWS: + case MySqlParser.KW_MAX_SIZE: + case MySqlParser.KW_MAX_UPDATES_PER_HOUR: + case MySqlParser.KW_MAX_USER_CONNECTIONS: + case MySqlParser.KW_MEDIUM: + case MySqlParser.KW_MEMBER: + case MySqlParser.KW_MERGE: + case MySqlParser.KW_MESSAGE_TEXT: + case MySqlParser.KW_MID: + case MySqlParser.KW_MIGRATE: + case MySqlParser.KW_MIN_ROWS: + case MySqlParser.KW_MODE: + case MySqlParser.KW_MODIFY: + case MySqlParser.KW_MUTEX: + case MySqlParser.KW_MYSQL: + case MySqlParser.KW_MYSQL_ERRNO: + case MySqlParser.KW_NAME: + case MySqlParser.KW_NAMES: + case MySqlParser.KW_NCHAR: + case MySqlParser.KW_NEVER: + case MySqlParser.KW_NEXT: + case MySqlParser.KW_NO: + case MySqlParser.KW_NOWAIT: + case MySqlParser.KW_NODEGROUP: + case MySqlParser.KW_NONE: + case MySqlParser.KW_ODBC: + case MySqlParser.KW_OFFLINE: + case MySqlParser.KW_OFFSET: + case MySqlParser.KW_OF: + case MySqlParser.KW_OLD_PASSWORD: + case MySqlParser.KW_ONE: + case MySqlParser.KW_ONLINE: + case MySqlParser.KW_ONLY: + case MySqlParser.KW_OPEN: + case MySqlParser.KW_OPTIMIZER_COSTS: + case MySqlParser.KW_OPTIONS: + case MySqlParser.KW_OWNER: + case MySqlParser.KW_PACK_KEYS: + case MySqlParser.KW_PAGE: + case MySqlParser.KW_PAGE_CHECKSUM: + case MySqlParser.KW_PARSER: + case MySqlParser.KW_PARTIAL: + case MySqlParser.KW_PARTITIONING: + case MySqlParser.KW_PARTITIONS: + case MySqlParser.KW_PASSWORD: + case MySqlParser.KW_PASSWORD_LOCK_TIME: + case MySqlParser.KW_PHASE: + case MySqlParser.KW_PLUGIN: + case MySqlParser.KW_PLUGIN_DIR: + case MySqlParser.KW_PLUGINS: + case MySqlParser.KW_PORT: + case MySqlParser.KW_PRECEDES: + case MySqlParser.KW_PREPARE: + case MySqlParser.KW_PRESERVE: + case MySqlParser.KW_PREV: + case MySqlParser.KW_PROCESSLIST: + case MySqlParser.KW_PROFILE: + case MySqlParser.KW_PROFILES: + case MySqlParser.KW_PROXY: + case MySqlParser.KW_QUERY: + case MySqlParser.KW_QUICK: + case MySqlParser.KW_REBUILD: + case MySqlParser.KW_RECOVER: + case MySqlParser.KW_RECURSIVE: + case MySqlParser.KW_REDO_BUFFER_SIZE: + case MySqlParser.KW_REDUNDANT: + case MySqlParser.KW_RELAY: + case MySqlParser.KW_RELAY_LOG_FILE: + case MySqlParser.KW_RELAY_LOG_POS: + case MySqlParser.KW_RELAYLOG: + case MySqlParser.KW_REMOVE: + case MySqlParser.KW_REORGANIZE: + case MySqlParser.KW_REPAIR: + case MySqlParser.KW_REPLICATE_DO_DB: + case MySqlParser.KW_REPLICATE_DO_TABLE: + case MySqlParser.KW_REPLICATE_IGNORE_DB: + case MySqlParser.KW_REPLICATE_IGNORE_TABLE: + case MySqlParser.KW_REPLICATE_REWRITE_DB: + case MySqlParser.KW_REPLICATE_WILD_DO_TABLE: + case MySqlParser.KW_REPLICATE_WILD_IGNORE_TABLE: + case MySqlParser.KW_REPLICATION: + case MySqlParser.KW_RESET: + case MySqlParser.KW_RESUME: + case MySqlParser.KW_RETURNED_SQLSTATE: + case MySqlParser.KW_RETURNS: + case MySqlParser.KW_REUSE: + case MySqlParser.KW_ROLE: + case MySqlParser.KW_ROLLBACK: + case MySqlParser.KW_ROLLUP: + case MySqlParser.KW_ROTATE: + case MySqlParser.KW_ROW: + case MySqlParser.KW_ROWS: + case MySqlParser.KW_ROW_FORMAT: + case MySqlParser.KW_SAVEPOINT: + case MySqlParser.KW_SCHEDULE: + case MySqlParser.KW_SECURITY: + case MySqlParser.KW_SERVER: + case MySqlParser.KW_SESSION: + case MySqlParser.KW_SHARE: + case MySqlParser.KW_SHARED: + case MySqlParser.KW_SIGNED: + case MySqlParser.KW_SIMPLE: + case MySqlParser.KW_SLAVE: + case MySqlParser.KW_SLOW: + case MySqlParser.KW_SNAPSHOT: + case MySqlParser.KW_SOCKET: + case MySqlParser.KW_SOME: + case MySqlParser.KW_SONAME: + case MySqlParser.KW_SOUNDS: + case MySqlParser.KW_SOURCE: + case MySqlParser.KW_SQL_AFTER_GTIDS: + case MySqlParser.KW_SQL_AFTER_MTS_GAPS: + case MySqlParser.KW_SQL_BEFORE_GTIDS: + case MySqlParser.KW_SQL_BUFFER_RESULT: + case MySqlParser.KW_SQL_CACHE: + case MySqlParser.KW_SQL_NO_CACHE: + case MySqlParser.KW_SQL_THREAD: + case MySqlParser.KW_START: + case MySqlParser.KW_STARTS: + case MySqlParser.KW_STATS_AUTO_RECALC: + case MySqlParser.KW_STATS_PERSISTENT: + case MySqlParser.KW_STATS_SAMPLE_PAGES: + case MySqlParser.KW_STATUS: + case MySqlParser.KW_STOP: + case MySqlParser.KW_STORAGE: + case MySqlParser.KW_STRING: + case MySqlParser.KW_SUBCLASS_ORIGIN: + case MySqlParser.KW_SUBJECT: + case MySqlParser.KW_SUBPARTITION: + case MySqlParser.KW_SUBPARTITIONS: + case MySqlParser.KW_SUSPEND: + case MySqlParser.KW_SWAPS: + case MySqlParser.KW_SWITCHES: + case MySqlParser.KW_TABLE_NAME: + case MySqlParser.KW_TABLESPACE: + case MySqlParser.KW_TABLE_TYPE: + case MySqlParser.KW_TEMPORARY: + case MySqlParser.KW_TEMPTABLE: + case MySqlParser.KW_THAN: + case MySqlParser.KW_TRADITIONAL: + case MySqlParser.KW_TRANSACTION: + case MySqlParser.KW_TRANSACTIONAL: + case MySqlParser.KW_TRIGGERS: + case MySqlParser.KW_TRUNCATE: + case MySqlParser.KW_UNBOUNDED: + case MySqlParser.KW_UNDEFINED: + case MySqlParser.KW_UNDOFILE: + case MySqlParser.KW_UNDO_BUFFER_SIZE: + case MySqlParser.KW_UNINSTALL: + case MySqlParser.KW_UNKNOWN: + case MySqlParser.KW_UNTIL: + case MySqlParser.KW_UPGRADE: + case MySqlParser.KW_USER: + case MySqlParser.KW_USE_FRM: + case MySqlParser.KW_USER_RESOURCES: + case MySqlParser.KW_VALIDATION: + case MySqlParser.KW_VALUE: + case MySqlParser.KW_VARIABLES: + case MySqlParser.KW_VIEW: + case MySqlParser.KW_VIRTUAL: + case MySqlParser.KW_VISIBLE: + case MySqlParser.KW_WAIT: + case MySqlParser.KW_WARNINGS: + case MySqlParser.KW_WITHOUT: + case MySqlParser.KW_WORK: + case MySqlParser.KW_WRAPPER: + case MySqlParser.KW_X509: + case MySqlParser.KW_XA: + case MySqlParser.KW_XML: + case MySqlParser.KW_QUARTER: + case MySqlParser.KW_MONTH: + case MySqlParser.KW_DAY: + case MySqlParser.KW_HOUR: + case MySqlParser.KW_MINUTE: + case MySqlParser.KW_WEEK: + case MySqlParser.KW_SECOND: + case MySqlParser.KW_MICROSECOND: + case MySqlParser.KW_ADMIN: + case MySqlParser.KW_AUDIT_ABORT_EXEMPT: + case MySqlParser.KW_AUDIT_ADMIN: + case MySqlParser.KW_AUTHENTICATION_POLICY_ADMIN: + case MySqlParser.KW_BACKUP_ADMIN: + case MySqlParser.KW_BINLOG_ADMIN: + case MySqlParser.KW_BINLOG_ENCRYPTION_ADMIN: + case MySqlParser.KW_CLONE_ADMIN: + case MySqlParser.KW_CONNECTION_ADMIN: + case MySqlParser.KW_ENCRYPTION_KEY_ADMIN: + case MySqlParser.KW_EXECUTE: + case MySqlParser.KW_FILE: + case MySqlParser.KW_FIREWALL_ADMIN: + case MySqlParser.KW_FIREWALL_EXEMPT: + case MySqlParser.KW_FIREWALL_USER: + case MySqlParser.KW_GROUP_REPLICATION_ADMIN: + case MySqlParser.KW_INNODB_REDO_LOG_ARCHIVE: + case MySqlParser.KW_INVOKE: + case MySqlParser.KW_LAMBDA: + case MySqlParser.KW_NDB_STORED_USER: + case MySqlParser.KW_PASSWORDLESS_USER_ADMIN: + case MySqlParser.KW_PERSIST_RO_VARIABLES_ADMIN: + case MySqlParser.KW_PRIVILEGES: + case MySqlParser.KW_PROCESS: + case MySqlParser.KW_RELOAD: + case MySqlParser.KW_REPLICATION_APPLIER: + case MySqlParser.KW_REPLICATION_SLAVE_ADMIN: + case MySqlParser.KW_RESOURCE_GROUP_ADMIN: + case MySqlParser.KW_RESOURCE_GROUP_USER: + case MySqlParser.KW_ROLE_ADMIN: + case MySqlParser.KW_ROUTINE: + case MySqlParser.KW_S3: + case MySqlParser.KW_SESSION_VARIABLES_ADMIN: + case MySqlParser.KW_SET_USER_ID: + case MySqlParser.KW_SHOW_ROUTINE: + case MySqlParser.KW_SHUTDOWN: + case MySqlParser.KW_SUPER: + case MySqlParser.KW_SYSTEM_VARIABLES_ADMIN: + case MySqlParser.KW_TABLES: + case MySqlParser.KW_TABLE_ENCRYPTION_ADMIN: + case MySqlParser.KW_VERSION_TOKEN_ADMIN: + case MySqlParser.KW_XA_RECOVER_ADMIN: + case MySqlParser.KW_ARMSCII8: + case MySqlParser.KW_ASCII: + case MySqlParser.KW_BIG5: + case MySqlParser.KW_CP1250: + case MySqlParser.KW_CP1251: + case MySqlParser.KW_CP1256: + case MySqlParser.KW_CP1257: + case MySqlParser.KW_CP850: + case MySqlParser.KW_CP852: + case MySqlParser.KW_CP866: + case MySqlParser.KW_CP932: + case MySqlParser.KW_DEC8: + case MySqlParser.KW_EUCJPMS: + case MySqlParser.KW_EUCKR: + case MySqlParser.KW_GB18030: + case MySqlParser.KW_GB2312: + case MySqlParser.KW_GBK: + case MySqlParser.KW_GEOSTD8: + case MySqlParser.KW_GREEK: + case MySqlParser.KW_HEBREW: + case MySqlParser.KW_HP8: + case MySqlParser.KW_KEYBCS2: + case MySqlParser.KW_KOI8R: + case MySqlParser.KW_KOI8U: + case MySqlParser.KW_LATIN1: + case MySqlParser.KW_LATIN2: + case MySqlParser.KW_LATIN5: + case MySqlParser.KW_LATIN7: + case MySqlParser.KW_MACCE: + case MySqlParser.KW_MACROMAN: + case MySqlParser.KW_SJIS: + case MySqlParser.KW_SWE7: + case MySqlParser.KW_TIS620: + case MySqlParser.KW_UCS2: + case MySqlParser.KW_UJIS: + case MySqlParser.KW_UTF16: + case MySqlParser.KW_UTF16LE: + case MySqlParser.KW_UTF32: + case MySqlParser.KW_UTF8: + case MySqlParser.KW_UTF8MB3: + case MySqlParser.KW_UTF8MB4: + case MySqlParser.KW_ARCHIVE: + case MySqlParser.KW_BLACKHOLE: + case MySqlParser.KW_CSV: + case MySqlParser.KW_FEDERATED: + case MySqlParser.KW_INNODB: + case MySqlParser.KW_MEMORY: + case MySqlParser.KW_MRG_MYISAM: + case MySqlParser.KW_MYISAM: + case MySqlParser.KW_NDB: + case MySqlParser.KW_NDBCLUSTER: + case MySqlParser.KW_PERFORMANCE_SCHEMA: + case MySqlParser.KW_TOKUDB: + case MySqlParser.KW_REPEATABLE: + case MySqlParser.KW_COMMITTED: + case MySqlParser.KW_UNCOMMITTED: + case MySqlParser.KW_SERIALIZABLE: + case MySqlParser.KW_GEOMETRYCOLLECTION: + case MySqlParser.KW_LINESTRING: + case MySqlParser.KW_MULTILINESTRING: + case MySqlParser.KW_MULTIPOINT: + case MySqlParser.KW_MULTIPOLYGON: + case MySqlParser.KW_POINT: + case MySqlParser.KW_POLYGON: + case MySqlParser.KW_CATALOG_NAME: + case MySqlParser.KW_CHARSET: + case MySqlParser.KW_COLLATION: + case MySqlParser.KW_ENGINE_ATTRIBUTE: + case MySqlParser.KW_FORMAT: + case MySqlParser.KW_GET_FORMAT: + case MySqlParser.KW_RANDOM: + case MySqlParser.KW_REVERSE: + case MySqlParser.KW_ROW_COUNT: + case MySqlParser.KW_SCHEMA_NAME: + case MySqlParser.KW_SECONDARY_ENGINE_ATTRIBUTE: + case MySqlParser.KW_SRID: + case MySqlParser.KW_SYSTEM_USER: + case MySqlParser.KW_TP_CONNECTION_ADMIN: + case MySqlParser.KW_WEIGHT_STRING: + case MySqlParser.MOD: + case MySqlParser.CHARSET_REVERSE_QOUTE_STRING: + case MySqlParser.STRING_LITERAL: + case MySqlParser.ID: + { + this.state = 2955; + this.partitionNames(); + } + break; + case MySqlParser.KW_ALL: + { + this.state = 2956; + this.match(MySqlParser.KW_ALL); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + break; + case MySqlParser.KW_CHECK: + localContext = new AlterByCheckPartitionContext(localContext); + this.enterOuterAlt(localContext, 10); + { + this.state = 2959; + this.match(MySqlParser.KW_CHECK); + this.state = 2960; + this.match(MySqlParser.KW_PARTITION); + this.state = 2963; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_ARRAY: + case MySqlParser.KW_ATTRIBUTE: + case MySqlParser.KW_BUCKETS: + case MySqlParser.KW_CONDITION: + case MySqlParser.KW_CURRENT: + case MySqlParser.KW_CURRENT_USER: + case MySqlParser.KW_DATABASE: + case MySqlParser.KW_DEFAULT: + case MySqlParser.KW_DIAGNOSTICS: + case MySqlParser.KW_EMPTY: + case MySqlParser.KW_ENFORCED: + case MySqlParser.KW_EXCEPT: + case MySqlParser.KW_GROUP: + case MySqlParser.KW_IF: + case MySqlParser.KW_INSERT: + case MySqlParser.KW_LATERAL: + case MySqlParser.KW_LEFT: + case MySqlParser.KW_NUMBER: + case MySqlParser.KW_OPTIONAL: + case MySqlParser.KW_ORDER: + case MySqlParser.KW_PRIMARY: + case MySqlParser.KW_REPEAT: + case MySqlParser.KW_REPLACE: + case MySqlParser.KW_RIGHT: + case MySqlParser.KW_SCHEMA: + case MySqlParser.KW_SKIP_QUERY_REWRITE: + case MySqlParser.KW_STACKED: + case MySqlParser.KW_DATE: + case MySqlParser.KW_TIME: + case MySqlParser.KW_TIMESTAMP: + case MySqlParser.KW_DATETIME: + case MySqlParser.KW_YEAR: + case MySqlParser.KW_BINARY: + case MySqlParser.KW_TEXT: + case MySqlParser.KW_ENUM: + case MySqlParser.KW_SERIAL: + case MySqlParser.KW_JSON_TABLE: + case MySqlParser.KW_JSON_VALUE: + case MySqlParser.KW_NESTED: + case MySqlParser.KW_ORDINALITY: + case MySqlParser.KW_PATH: + case MySqlParser.KW_AVG: + case MySqlParser.KW_BIT_AND: + case MySqlParser.KW_BIT_OR: + case MySqlParser.KW_BIT_XOR: + case MySqlParser.KW_COUNT: + case MySqlParser.KW_CUME_DIST: + case MySqlParser.KW_DENSE_RANK: + case MySqlParser.KW_FIRST_VALUE: + case MySqlParser.KW_GROUP_CONCAT: + case MySqlParser.KW_LAG: + case MySqlParser.KW_LAST_VALUE: + case MySqlParser.KW_LEAD: + case MySqlParser.KW_MAX: + case MySqlParser.KW_MIN: + case MySqlParser.KW_NTILE: + case MySqlParser.KW_NTH_VALUE: + case MySqlParser.KW_PERCENT_RANK: + case MySqlParser.KW_RANK: + case MySqlParser.KW_ROW_NUMBER: + case MySqlParser.KW_STD: + case MySqlParser.KW_STDDEV: + case MySqlParser.KW_STDDEV_POP: + case MySqlParser.KW_STDDEV_SAMP: + case MySqlParser.KW_SUM: + case MySqlParser.KW_VAR_POP: + case MySqlParser.KW_VAR_SAMP: + case MySqlParser.KW_VARIANCE: + case MySqlParser.KW_CURRENT_DATE: + case MySqlParser.KW_CURRENT_TIME: + case MySqlParser.KW_CURRENT_TIMESTAMP: + case MySqlParser.KW_LOCALTIME: + case MySqlParser.KW_CURDATE: + case MySqlParser.KW_CURTIME: + case MySqlParser.KW_DATE_ADD: + case MySqlParser.KW_DATE_SUB: + case MySqlParser.KW_LOCALTIMESTAMP: + case MySqlParser.KW_NOW: + case MySqlParser.KW_POSITION: + case MySqlParser.KW_SUBSTR: + case MySqlParser.KW_SUBSTRING: + case MySqlParser.KW_SYSDATE: + case MySqlParser.KW_TRIM: + case MySqlParser.KW_UTC_DATE: + case MySqlParser.KW_UTC_TIME: + case MySqlParser.KW_UTC_TIMESTAMP: + case MySqlParser.KW_ACCOUNT: + case MySqlParser.KW_ACTION: + case MySqlParser.KW_AFTER: + case MySqlParser.KW_AGGREGATE: + case MySqlParser.KW_ALGORITHM: + case MySqlParser.KW_ANY: + case MySqlParser.KW_AT: + case MySqlParser.KW_AUTHORS: + case MySqlParser.KW_AUTOCOMMIT: + case MySqlParser.KW_AUTOEXTEND_SIZE: + case MySqlParser.KW_AUTO_INCREMENT: + case MySqlParser.KW_AVG_ROW_LENGTH: + case MySqlParser.KW_BEGIN: + case MySqlParser.KW_BINLOG: + case MySqlParser.KW_BIT: + case MySqlParser.KW_BLOCK: + case MySqlParser.KW_BOOL: + case MySqlParser.KW_BOOLEAN: + case MySqlParser.KW_BTREE: + case MySqlParser.KW_CACHE: + case MySqlParser.KW_CASCADED: + case MySqlParser.KW_CHAIN: + case MySqlParser.KW_CHANGED: + case MySqlParser.KW_CHANNEL: + case MySqlParser.KW_CHECKSUM: + case MySqlParser.KW_CIPHER: + case MySqlParser.KW_CLASS_ORIGIN: + case MySqlParser.KW_CLIENT: + case MySqlParser.KW_CLOSE: + case MySqlParser.KW_COALESCE: + case MySqlParser.KW_CODE: + case MySqlParser.KW_COLUMNS: + case MySqlParser.KW_COLUMN_FORMAT: + case MySqlParser.KW_COLUMN_NAME: + case MySqlParser.KW_COMMENT: + case MySqlParser.KW_COMMIT: + case MySqlParser.KW_COMPACT: + case MySqlParser.KW_COMPLETION: + case MySqlParser.KW_COMPRESSED: + case MySqlParser.KW_COMPRESSION: + case MySqlParser.KW_CONCURRENT: + case MySqlParser.KW_CONNECT: + case MySqlParser.KW_CONNECTION: + case MySqlParser.KW_CONSISTENT: + case MySqlParser.KW_CONSTRAINT_CATALOG: + case MySqlParser.KW_CONSTRAINT_SCHEMA: + case MySqlParser.KW_CONSTRAINT_NAME: + case MySqlParser.KW_CONTAINS: + case MySqlParser.KW_CONTEXT: + case MySqlParser.KW_CONTRIBUTORS: + case MySqlParser.KW_COPY: + case MySqlParser.KW_CPU: + case MySqlParser.KW_CURSOR_NAME: + case MySqlParser.KW_DATA: + case MySqlParser.KW_DATAFILE: + case MySqlParser.KW_DEALLOCATE: + case MySqlParser.KW_DEFAULT_AUTH: + case MySqlParser.KW_DEFINER: + case MySqlParser.KW_DELAY_KEY_WRITE: + case MySqlParser.KW_DES_KEY_FILE: + case MySqlParser.KW_DIRECTORY: + case MySqlParser.KW_DISABLE: + case MySqlParser.KW_DISCARD: + case MySqlParser.KW_DISK: + case MySqlParser.KW_DO: + case MySqlParser.KW_DUMPFILE: + case MySqlParser.KW_DUPLICATE: + case MySqlParser.KW_DYNAMIC: + case MySqlParser.KW_ENABLE: + case MySqlParser.KW_ENCRYPTION: + case MySqlParser.KW_END: + case MySqlParser.KW_ENDS: + case MySqlParser.KW_ENGINE: + case MySqlParser.KW_ENGINES: + case MySqlParser.KW_ERROR: + case MySqlParser.KW_ERRORS: + case MySqlParser.KW_ESCAPE: + case MySqlParser.KW_EVENT: + case MySqlParser.KW_EVENTS: + case MySqlParser.KW_EVERY: + case MySqlParser.KW_EXCHANGE: + case MySqlParser.KW_EXCLUSIVE: + case MySqlParser.KW_EXPIRE: + case MySqlParser.KW_EXPORT: + case MySqlParser.KW_EXTENDED: + case MySqlParser.KW_EXTENT_SIZE: + case MySqlParser.KW_FAILED_LOGIN_ATTEMPTS: + case MySqlParser.KW_FAST: + case MySqlParser.KW_FAULTS: + case MySqlParser.KW_FIELDS: + case MySqlParser.KW_FILE_BLOCK_SIZE: + case MySqlParser.KW_FILTER: + case MySqlParser.KW_FIRST: + case MySqlParser.KW_FIXED: + case MySqlParser.KW_FLUSH: + case MySqlParser.KW_FOLLOWS: + case MySqlParser.KW_FOUND: + case MySqlParser.KW_FULL: + case MySqlParser.KW_FUNCTION: + case MySqlParser.KW_GENERAL: + case MySqlParser.KW_GLOBAL: + case MySqlParser.KW_GRANTS: + case MySqlParser.KW_GROUP_REPLICATION: + case MySqlParser.KW_HANDLER: + case MySqlParser.KW_HASH: + case MySqlParser.KW_HELP: + case MySqlParser.KW_HISTORY: + case MySqlParser.KW_HOST: + case MySqlParser.KW_HOSTS: + case MySqlParser.KW_IDENTIFIED: + case MySqlParser.KW_IGNORE_SERVER_IDS: + case MySqlParser.KW_IMPORT: + case MySqlParser.KW_INDEXES: + case MySqlParser.KW_INITIAL_SIZE: + case MySqlParser.KW_INPLACE: + case MySqlParser.KW_INSERT_METHOD: + case MySqlParser.KW_INSTALL: + case MySqlParser.KW_INSTANCE: + case MySqlParser.KW_INSTANT: + case MySqlParser.KW_INVISIBLE: + case MySqlParser.KW_INVOKER: + case MySqlParser.KW_IO: + case MySqlParser.KW_IO_THREAD: + case MySqlParser.KW_IPC: + case MySqlParser.KW_ISOLATION: + case MySqlParser.KW_ISSUER: + case MySqlParser.KW_JSON: + case MySqlParser.KW_KEY_BLOCK_SIZE: + case MySqlParser.KW_LANGUAGE: + case MySqlParser.KW_LAST: + case MySqlParser.KW_LEAVES: + case MySqlParser.KW_LESS: + case MySqlParser.KW_LEVEL: + case MySqlParser.KW_LIST: + case MySqlParser.KW_LOCAL: + case MySqlParser.KW_LOGFILE: + case MySqlParser.KW_LOGS: + case MySqlParser.KW_MASTER: + case MySqlParser.KW_MASTER_AUTO_POSITION: + case MySqlParser.KW_MASTER_CONNECT_RETRY: + case MySqlParser.KW_MASTER_DELAY: + case MySqlParser.KW_MASTER_HEARTBEAT_PERIOD: + case MySqlParser.KW_MASTER_HOST: + case MySqlParser.KW_MASTER_LOG_FILE: + case MySqlParser.KW_MASTER_LOG_POS: + case MySqlParser.KW_MASTER_PASSWORD: + case MySqlParser.KW_MASTER_PORT: + case MySqlParser.KW_MASTER_RETRY_COUNT: + case MySqlParser.KW_MASTER_SSL: + case MySqlParser.KW_MASTER_SSL_CA: + case MySqlParser.KW_MASTER_SSL_CAPATH: + case MySqlParser.KW_MASTER_SSL_CERT: + case MySqlParser.KW_MASTER_SSL_CIPHER: + case MySqlParser.KW_MASTER_SSL_CRL: + case MySqlParser.KW_MASTER_SSL_CRLPATH: + case MySqlParser.KW_MASTER_SSL_KEY: + case MySqlParser.KW_MASTER_TLS_VERSION: + case MySqlParser.KW_MASTER_USER: + case MySqlParser.KW_MAX_CONNECTIONS_PER_HOUR: + case MySqlParser.KW_MAX_QUERIES_PER_HOUR: + case MySqlParser.KW_MAX_ROWS: + case MySqlParser.KW_MAX_SIZE: + case MySqlParser.KW_MAX_UPDATES_PER_HOUR: + case MySqlParser.KW_MAX_USER_CONNECTIONS: + case MySqlParser.KW_MEDIUM: + case MySqlParser.KW_MEMBER: + case MySqlParser.KW_MERGE: + case MySqlParser.KW_MESSAGE_TEXT: + case MySqlParser.KW_MID: + case MySqlParser.KW_MIGRATE: + case MySqlParser.KW_MIN_ROWS: + case MySqlParser.KW_MODE: + case MySqlParser.KW_MODIFY: + case MySqlParser.KW_MUTEX: + case MySqlParser.KW_MYSQL: + case MySqlParser.KW_MYSQL_ERRNO: + case MySqlParser.KW_NAME: + case MySqlParser.KW_NAMES: + case MySqlParser.KW_NCHAR: + case MySqlParser.KW_NEVER: + case MySqlParser.KW_NEXT: + case MySqlParser.KW_NO: + case MySqlParser.KW_NOWAIT: + case MySqlParser.KW_NODEGROUP: + case MySqlParser.KW_NONE: + case MySqlParser.KW_ODBC: + case MySqlParser.KW_OFFLINE: + case MySqlParser.KW_OFFSET: + case MySqlParser.KW_OF: + case MySqlParser.KW_OLD_PASSWORD: + case MySqlParser.KW_ONE: + case MySqlParser.KW_ONLINE: + case MySqlParser.KW_ONLY: + case MySqlParser.KW_OPEN: + case MySqlParser.KW_OPTIMIZER_COSTS: + case MySqlParser.KW_OPTIONS: + case MySqlParser.KW_OWNER: + case MySqlParser.KW_PACK_KEYS: + case MySqlParser.KW_PAGE: + case MySqlParser.KW_PAGE_CHECKSUM: + case MySqlParser.KW_PARSER: + case MySqlParser.KW_PARTIAL: + case MySqlParser.KW_PARTITIONING: + case MySqlParser.KW_PARTITIONS: + case MySqlParser.KW_PASSWORD: + case MySqlParser.KW_PASSWORD_LOCK_TIME: + case MySqlParser.KW_PHASE: + case MySqlParser.KW_PLUGIN: + case MySqlParser.KW_PLUGIN_DIR: + case MySqlParser.KW_PLUGINS: + case MySqlParser.KW_PORT: + case MySqlParser.KW_PRECEDES: + case MySqlParser.KW_PREPARE: + case MySqlParser.KW_PRESERVE: + case MySqlParser.KW_PREV: + case MySqlParser.KW_PROCESSLIST: + case MySqlParser.KW_PROFILE: + case MySqlParser.KW_PROFILES: + case MySqlParser.KW_PROXY: + case MySqlParser.KW_QUERY: + case MySqlParser.KW_QUICK: + case MySqlParser.KW_REBUILD: + case MySqlParser.KW_RECOVER: + case MySqlParser.KW_RECURSIVE: + case MySqlParser.KW_REDO_BUFFER_SIZE: + case MySqlParser.KW_REDUNDANT: + case MySqlParser.KW_RELAY: + case MySqlParser.KW_RELAY_LOG_FILE: + case MySqlParser.KW_RELAY_LOG_POS: + case MySqlParser.KW_RELAYLOG: + case MySqlParser.KW_REMOVE: + case MySqlParser.KW_REORGANIZE: + case MySqlParser.KW_REPAIR: + case MySqlParser.KW_REPLICATE_DO_DB: + case MySqlParser.KW_REPLICATE_DO_TABLE: + case MySqlParser.KW_REPLICATE_IGNORE_DB: + case MySqlParser.KW_REPLICATE_IGNORE_TABLE: + case MySqlParser.KW_REPLICATE_REWRITE_DB: + case MySqlParser.KW_REPLICATE_WILD_DO_TABLE: + case MySqlParser.KW_REPLICATE_WILD_IGNORE_TABLE: + case MySqlParser.KW_REPLICATION: + case MySqlParser.KW_RESET: + case MySqlParser.KW_RESUME: + case MySqlParser.KW_RETURNED_SQLSTATE: + case MySqlParser.KW_RETURNS: + case MySqlParser.KW_REUSE: + case MySqlParser.KW_ROLE: + case MySqlParser.KW_ROLLBACK: + case MySqlParser.KW_ROLLUP: + case MySqlParser.KW_ROTATE: + case MySqlParser.KW_ROW: + case MySqlParser.KW_ROWS: + case MySqlParser.KW_ROW_FORMAT: + case MySqlParser.KW_SAVEPOINT: + case MySqlParser.KW_SCHEDULE: + case MySqlParser.KW_SECURITY: + case MySqlParser.KW_SERVER: + case MySqlParser.KW_SESSION: + case MySqlParser.KW_SHARE: + case MySqlParser.KW_SHARED: + case MySqlParser.KW_SIGNED: + case MySqlParser.KW_SIMPLE: + case MySqlParser.KW_SLAVE: + case MySqlParser.KW_SLOW: + case MySqlParser.KW_SNAPSHOT: + case MySqlParser.KW_SOCKET: + case MySqlParser.KW_SOME: + case MySqlParser.KW_SONAME: + case MySqlParser.KW_SOUNDS: + case MySqlParser.KW_SOURCE: + case MySqlParser.KW_SQL_AFTER_GTIDS: + case MySqlParser.KW_SQL_AFTER_MTS_GAPS: + case MySqlParser.KW_SQL_BEFORE_GTIDS: + case MySqlParser.KW_SQL_BUFFER_RESULT: + case MySqlParser.KW_SQL_CACHE: + case MySqlParser.KW_SQL_NO_CACHE: + case MySqlParser.KW_SQL_THREAD: + case MySqlParser.KW_START: + case MySqlParser.KW_STARTS: + case MySqlParser.KW_STATS_AUTO_RECALC: + case MySqlParser.KW_STATS_PERSISTENT: + case MySqlParser.KW_STATS_SAMPLE_PAGES: + case MySqlParser.KW_STATUS: + case MySqlParser.KW_STOP: + case MySqlParser.KW_STORAGE: + case MySqlParser.KW_STRING: + case MySqlParser.KW_SUBCLASS_ORIGIN: + case MySqlParser.KW_SUBJECT: + case MySqlParser.KW_SUBPARTITION: + case MySqlParser.KW_SUBPARTITIONS: + case MySqlParser.KW_SUSPEND: + case MySqlParser.KW_SWAPS: + case MySqlParser.KW_SWITCHES: + case MySqlParser.KW_TABLE_NAME: + case MySqlParser.KW_TABLESPACE: + case MySqlParser.KW_TABLE_TYPE: + case MySqlParser.KW_TEMPORARY: + case MySqlParser.KW_TEMPTABLE: + case MySqlParser.KW_THAN: + case MySqlParser.KW_TRADITIONAL: + case MySqlParser.KW_TRANSACTION: + case MySqlParser.KW_TRANSACTIONAL: + case MySqlParser.KW_TRIGGERS: + case MySqlParser.KW_TRUNCATE: + case MySqlParser.KW_UNBOUNDED: + case MySqlParser.KW_UNDEFINED: + case MySqlParser.KW_UNDOFILE: + case MySqlParser.KW_UNDO_BUFFER_SIZE: + case MySqlParser.KW_UNINSTALL: + case MySqlParser.KW_UNKNOWN: + case MySqlParser.KW_UNTIL: + case MySqlParser.KW_UPGRADE: + case MySqlParser.KW_USER: + case MySqlParser.KW_USE_FRM: + case MySqlParser.KW_USER_RESOURCES: + case MySqlParser.KW_VALIDATION: + case MySqlParser.KW_VALUE: + case MySqlParser.KW_VARIABLES: + case MySqlParser.KW_VIEW: + case MySqlParser.KW_VIRTUAL: + case MySqlParser.KW_VISIBLE: + case MySqlParser.KW_WAIT: + case MySqlParser.KW_WARNINGS: + case MySqlParser.KW_WITHOUT: + case MySqlParser.KW_WORK: + case MySqlParser.KW_WRAPPER: + case MySqlParser.KW_X509: + case MySqlParser.KW_XA: + case MySqlParser.KW_XML: + case MySqlParser.KW_QUARTER: + case MySqlParser.KW_MONTH: + case MySqlParser.KW_DAY: + case MySqlParser.KW_HOUR: + case MySqlParser.KW_MINUTE: + case MySqlParser.KW_WEEK: + case MySqlParser.KW_SECOND: + case MySqlParser.KW_MICROSECOND: + case MySqlParser.KW_ADMIN: + case MySqlParser.KW_AUDIT_ABORT_EXEMPT: + case MySqlParser.KW_AUDIT_ADMIN: + case MySqlParser.KW_AUTHENTICATION_POLICY_ADMIN: + case MySqlParser.KW_BACKUP_ADMIN: + case MySqlParser.KW_BINLOG_ADMIN: + case MySqlParser.KW_BINLOG_ENCRYPTION_ADMIN: + case MySqlParser.KW_CLONE_ADMIN: + case MySqlParser.KW_CONNECTION_ADMIN: + case MySqlParser.KW_ENCRYPTION_KEY_ADMIN: + case MySqlParser.KW_EXECUTE: + case MySqlParser.KW_FILE: + case MySqlParser.KW_FIREWALL_ADMIN: + case MySqlParser.KW_FIREWALL_EXEMPT: + case MySqlParser.KW_FIREWALL_USER: + case MySqlParser.KW_GROUP_REPLICATION_ADMIN: + case MySqlParser.KW_INNODB_REDO_LOG_ARCHIVE: + case MySqlParser.KW_INVOKE: + case MySqlParser.KW_LAMBDA: + case MySqlParser.KW_NDB_STORED_USER: + case MySqlParser.KW_PASSWORDLESS_USER_ADMIN: + case MySqlParser.KW_PERSIST_RO_VARIABLES_ADMIN: + case MySqlParser.KW_PRIVILEGES: + case MySqlParser.KW_PROCESS: + case MySqlParser.KW_RELOAD: + case MySqlParser.KW_REPLICATION_APPLIER: + case MySqlParser.KW_REPLICATION_SLAVE_ADMIN: + case MySqlParser.KW_RESOURCE_GROUP_ADMIN: + case MySqlParser.KW_RESOURCE_GROUP_USER: + case MySqlParser.KW_ROLE_ADMIN: + case MySqlParser.KW_ROUTINE: + case MySqlParser.KW_S3: + case MySqlParser.KW_SESSION_VARIABLES_ADMIN: + case MySqlParser.KW_SET_USER_ID: + case MySqlParser.KW_SHOW_ROUTINE: + case MySqlParser.KW_SHUTDOWN: + case MySqlParser.KW_SUPER: + case MySqlParser.KW_SYSTEM_VARIABLES_ADMIN: + case MySqlParser.KW_TABLES: + case MySqlParser.KW_TABLE_ENCRYPTION_ADMIN: + case MySqlParser.KW_VERSION_TOKEN_ADMIN: + case MySqlParser.KW_XA_RECOVER_ADMIN: + case MySqlParser.KW_ARMSCII8: + case MySqlParser.KW_ASCII: + case MySqlParser.KW_BIG5: + case MySqlParser.KW_CP1250: + case MySqlParser.KW_CP1251: + case MySqlParser.KW_CP1256: + case MySqlParser.KW_CP1257: + case MySqlParser.KW_CP850: + case MySqlParser.KW_CP852: + case MySqlParser.KW_CP866: + case MySqlParser.KW_CP932: + case MySqlParser.KW_DEC8: + case MySqlParser.KW_EUCJPMS: + case MySqlParser.KW_EUCKR: + case MySqlParser.KW_GB18030: + case MySqlParser.KW_GB2312: + case MySqlParser.KW_GBK: + case MySqlParser.KW_GEOSTD8: + case MySqlParser.KW_GREEK: + case MySqlParser.KW_HEBREW: + case MySqlParser.KW_HP8: + case MySqlParser.KW_KEYBCS2: + case MySqlParser.KW_KOI8R: + case MySqlParser.KW_KOI8U: + case MySqlParser.KW_LATIN1: + case MySqlParser.KW_LATIN2: + case MySqlParser.KW_LATIN5: + case MySqlParser.KW_LATIN7: + case MySqlParser.KW_MACCE: + case MySqlParser.KW_MACROMAN: + case MySqlParser.KW_SJIS: + case MySqlParser.KW_SWE7: + case MySqlParser.KW_TIS620: + case MySqlParser.KW_UCS2: + case MySqlParser.KW_UJIS: + case MySqlParser.KW_UTF16: + case MySqlParser.KW_UTF16LE: + case MySqlParser.KW_UTF32: + case MySqlParser.KW_UTF8: + case MySqlParser.KW_UTF8MB3: + case MySqlParser.KW_UTF8MB4: + case MySqlParser.KW_ARCHIVE: + case MySqlParser.KW_BLACKHOLE: + case MySqlParser.KW_CSV: + case MySqlParser.KW_FEDERATED: + case MySqlParser.KW_INNODB: + case MySqlParser.KW_MEMORY: + case MySqlParser.KW_MRG_MYISAM: + case MySqlParser.KW_MYISAM: + case MySqlParser.KW_NDB: + case MySqlParser.KW_NDBCLUSTER: + case MySqlParser.KW_PERFORMANCE_SCHEMA: + case MySqlParser.KW_TOKUDB: + case MySqlParser.KW_REPEATABLE: + case MySqlParser.KW_COMMITTED: + case MySqlParser.KW_UNCOMMITTED: + case MySqlParser.KW_SERIALIZABLE: + case MySqlParser.KW_GEOMETRYCOLLECTION: + case MySqlParser.KW_LINESTRING: + case MySqlParser.KW_MULTILINESTRING: + case MySqlParser.KW_MULTIPOINT: + case MySqlParser.KW_MULTIPOLYGON: + case MySqlParser.KW_POINT: + case MySqlParser.KW_POLYGON: + case MySqlParser.KW_CATALOG_NAME: + case MySqlParser.KW_CHARSET: + case MySqlParser.KW_COLLATION: + case MySqlParser.KW_ENGINE_ATTRIBUTE: + case MySqlParser.KW_FORMAT: + case MySqlParser.KW_GET_FORMAT: + case MySqlParser.KW_RANDOM: + case MySqlParser.KW_REVERSE: + case MySqlParser.KW_ROW_COUNT: + case MySqlParser.KW_SCHEMA_NAME: + case MySqlParser.KW_SECONDARY_ENGINE_ATTRIBUTE: + case MySqlParser.KW_SRID: + case MySqlParser.KW_SYSTEM_USER: + case MySqlParser.KW_TP_CONNECTION_ADMIN: + case MySqlParser.KW_WEIGHT_STRING: + case MySqlParser.MOD: + case MySqlParser.CHARSET_REVERSE_QOUTE_STRING: + case MySqlParser.STRING_LITERAL: + case MySqlParser.ID: + { + this.state = 2961; + this.partitionNames(); + } + break; + case MySqlParser.KW_ALL: + { + this.state = 2962; + this.match(MySqlParser.KW_ALL); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + break; + case MySqlParser.KW_OPTIMIZE: + localContext = new AlterByOptimizePartitionContext(localContext); + this.enterOuterAlt(localContext, 11); + { + this.state = 2965; + this.match(MySqlParser.KW_OPTIMIZE); + this.state = 2966; + this.match(MySqlParser.KW_PARTITION); + this.state = 2969; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_ARRAY: + case MySqlParser.KW_ATTRIBUTE: + case MySqlParser.KW_BUCKETS: + case MySqlParser.KW_CONDITION: + case MySqlParser.KW_CURRENT: + case MySqlParser.KW_CURRENT_USER: + case MySqlParser.KW_DATABASE: + case MySqlParser.KW_DEFAULT: + case MySqlParser.KW_DIAGNOSTICS: + case MySqlParser.KW_EMPTY: + case MySqlParser.KW_ENFORCED: + case MySqlParser.KW_EXCEPT: + case MySqlParser.KW_GROUP: + case MySqlParser.KW_IF: + case MySqlParser.KW_INSERT: + case MySqlParser.KW_LATERAL: + case MySqlParser.KW_LEFT: + case MySqlParser.KW_NUMBER: + case MySqlParser.KW_OPTIONAL: + case MySqlParser.KW_ORDER: + case MySqlParser.KW_PRIMARY: + case MySqlParser.KW_REPEAT: + case MySqlParser.KW_REPLACE: + case MySqlParser.KW_RIGHT: + case MySqlParser.KW_SCHEMA: + case MySqlParser.KW_SKIP_QUERY_REWRITE: + case MySqlParser.KW_STACKED: + case MySqlParser.KW_DATE: + case MySqlParser.KW_TIME: + case MySqlParser.KW_TIMESTAMP: + case MySqlParser.KW_DATETIME: + case MySqlParser.KW_YEAR: + case MySqlParser.KW_BINARY: + case MySqlParser.KW_TEXT: + case MySqlParser.KW_ENUM: + case MySqlParser.KW_SERIAL: + case MySqlParser.KW_JSON_TABLE: + case MySqlParser.KW_JSON_VALUE: + case MySqlParser.KW_NESTED: + case MySqlParser.KW_ORDINALITY: + case MySqlParser.KW_PATH: + case MySqlParser.KW_AVG: + case MySqlParser.KW_BIT_AND: + case MySqlParser.KW_BIT_OR: + case MySqlParser.KW_BIT_XOR: + case MySqlParser.KW_COUNT: + case MySqlParser.KW_CUME_DIST: + case MySqlParser.KW_DENSE_RANK: + case MySqlParser.KW_FIRST_VALUE: + case MySqlParser.KW_GROUP_CONCAT: + case MySqlParser.KW_LAG: + case MySqlParser.KW_LAST_VALUE: + case MySqlParser.KW_LEAD: + case MySqlParser.KW_MAX: + case MySqlParser.KW_MIN: + case MySqlParser.KW_NTILE: + case MySqlParser.KW_NTH_VALUE: + case MySqlParser.KW_PERCENT_RANK: + case MySqlParser.KW_RANK: + case MySqlParser.KW_ROW_NUMBER: + case MySqlParser.KW_STD: + case MySqlParser.KW_STDDEV: + case MySqlParser.KW_STDDEV_POP: + case MySqlParser.KW_STDDEV_SAMP: + case MySqlParser.KW_SUM: + case MySqlParser.KW_VAR_POP: + case MySqlParser.KW_VAR_SAMP: + case MySqlParser.KW_VARIANCE: + case MySqlParser.KW_CURRENT_DATE: + case MySqlParser.KW_CURRENT_TIME: + case MySqlParser.KW_CURRENT_TIMESTAMP: + case MySqlParser.KW_LOCALTIME: + case MySqlParser.KW_CURDATE: + case MySqlParser.KW_CURTIME: + case MySqlParser.KW_DATE_ADD: + case MySqlParser.KW_DATE_SUB: + case MySqlParser.KW_LOCALTIMESTAMP: + case MySqlParser.KW_NOW: + case MySqlParser.KW_POSITION: + case MySqlParser.KW_SUBSTR: + case MySqlParser.KW_SUBSTRING: + case MySqlParser.KW_SYSDATE: + case MySqlParser.KW_TRIM: + case MySqlParser.KW_UTC_DATE: + case MySqlParser.KW_UTC_TIME: + case MySqlParser.KW_UTC_TIMESTAMP: + case MySqlParser.KW_ACCOUNT: + case MySqlParser.KW_ACTION: + case MySqlParser.KW_AFTER: + case MySqlParser.KW_AGGREGATE: + case MySqlParser.KW_ALGORITHM: + case MySqlParser.KW_ANY: + case MySqlParser.KW_AT: + case MySqlParser.KW_AUTHORS: + case MySqlParser.KW_AUTOCOMMIT: + case MySqlParser.KW_AUTOEXTEND_SIZE: + case MySqlParser.KW_AUTO_INCREMENT: + case MySqlParser.KW_AVG_ROW_LENGTH: + case MySqlParser.KW_BEGIN: + case MySqlParser.KW_BINLOG: + case MySqlParser.KW_BIT: + case MySqlParser.KW_BLOCK: + case MySqlParser.KW_BOOL: + case MySqlParser.KW_BOOLEAN: + case MySqlParser.KW_BTREE: + case MySqlParser.KW_CACHE: + case MySqlParser.KW_CASCADED: + case MySqlParser.KW_CHAIN: + case MySqlParser.KW_CHANGED: + case MySqlParser.KW_CHANNEL: + case MySqlParser.KW_CHECKSUM: + case MySqlParser.KW_CIPHER: + case MySqlParser.KW_CLASS_ORIGIN: + case MySqlParser.KW_CLIENT: + case MySqlParser.KW_CLOSE: + case MySqlParser.KW_COALESCE: + case MySqlParser.KW_CODE: + case MySqlParser.KW_COLUMNS: + case MySqlParser.KW_COLUMN_FORMAT: + case MySqlParser.KW_COLUMN_NAME: + case MySqlParser.KW_COMMENT: + case MySqlParser.KW_COMMIT: + case MySqlParser.KW_COMPACT: + case MySqlParser.KW_COMPLETION: + case MySqlParser.KW_COMPRESSED: + case MySqlParser.KW_COMPRESSION: + case MySqlParser.KW_CONCURRENT: + case MySqlParser.KW_CONNECT: + case MySqlParser.KW_CONNECTION: + case MySqlParser.KW_CONSISTENT: + case MySqlParser.KW_CONSTRAINT_CATALOG: + case MySqlParser.KW_CONSTRAINT_SCHEMA: + case MySqlParser.KW_CONSTRAINT_NAME: + case MySqlParser.KW_CONTAINS: + case MySqlParser.KW_CONTEXT: + case MySqlParser.KW_CONTRIBUTORS: + case MySqlParser.KW_COPY: + case MySqlParser.KW_CPU: + case MySqlParser.KW_CURSOR_NAME: + case MySqlParser.KW_DATA: + case MySqlParser.KW_DATAFILE: + case MySqlParser.KW_DEALLOCATE: + case MySqlParser.KW_DEFAULT_AUTH: + case MySqlParser.KW_DEFINER: + case MySqlParser.KW_DELAY_KEY_WRITE: + case MySqlParser.KW_DES_KEY_FILE: + case MySqlParser.KW_DIRECTORY: + case MySqlParser.KW_DISABLE: + case MySqlParser.KW_DISCARD: + case MySqlParser.KW_DISK: + case MySqlParser.KW_DO: + case MySqlParser.KW_DUMPFILE: + case MySqlParser.KW_DUPLICATE: + case MySqlParser.KW_DYNAMIC: + case MySqlParser.KW_ENABLE: + case MySqlParser.KW_ENCRYPTION: + case MySqlParser.KW_END: + case MySqlParser.KW_ENDS: + case MySqlParser.KW_ENGINE: + case MySqlParser.KW_ENGINES: + case MySqlParser.KW_ERROR: + case MySqlParser.KW_ERRORS: + case MySqlParser.KW_ESCAPE: + case MySqlParser.KW_EVENT: + case MySqlParser.KW_EVENTS: + case MySqlParser.KW_EVERY: + case MySqlParser.KW_EXCHANGE: + case MySqlParser.KW_EXCLUSIVE: + case MySqlParser.KW_EXPIRE: + case MySqlParser.KW_EXPORT: + case MySqlParser.KW_EXTENDED: + case MySqlParser.KW_EXTENT_SIZE: + case MySqlParser.KW_FAILED_LOGIN_ATTEMPTS: + case MySqlParser.KW_FAST: + case MySqlParser.KW_FAULTS: + case MySqlParser.KW_FIELDS: + case MySqlParser.KW_FILE_BLOCK_SIZE: + case MySqlParser.KW_FILTER: + case MySqlParser.KW_FIRST: + case MySqlParser.KW_FIXED: + case MySqlParser.KW_FLUSH: + case MySqlParser.KW_FOLLOWS: + case MySqlParser.KW_FOUND: + case MySqlParser.KW_FULL: + case MySqlParser.KW_FUNCTION: + case MySqlParser.KW_GENERAL: + case MySqlParser.KW_GLOBAL: + case MySqlParser.KW_GRANTS: + case MySqlParser.KW_GROUP_REPLICATION: + case MySqlParser.KW_HANDLER: + case MySqlParser.KW_HASH: + case MySqlParser.KW_HELP: + case MySqlParser.KW_HISTORY: + case MySqlParser.KW_HOST: + case MySqlParser.KW_HOSTS: + case MySqlParser.KW_IDENTIFIED: + case MySqlParser.KW_IGNORE_SERVER_IDS: + case MySqlParser.KW_IMPORT: + case MySqlParser.KW_INDEXES: + case MySqlParser.KW_INITIAL_SIZE: + case MySqlParser.KW_INPLACE: + case MySqlParser.KW_INSERT_METHOD: + case MySqlParser.KW_INSTALL: + case MySqlParser.KW_INSTANCE: + case MySqlParser.KW_INSTANT: + case MySqlParser.KW_INVISIBLE: + case MySqlParser.KW_INVOKER: + case MySqlParser.KW_IO: + case MySqlParser.KW_IO_THREAD: + case MySqlParser.KW_IPC: + case MySqlParser.KW_ISOLATION: + case MySqlParser.KW_ISSUER: + case MySqlParser.KW_JSON: + case MySqlParser.KW_KEY_BLOCK_SIZE: + case MySqlParser.KW_LANGUAGE: + case MySqlParser.KW_LAST: + case MySqlParser.KW_LEAVES: + case MySqlParser.KW_LESS: + case MySqlParser.KW_LEVEL: + case MySqlParser.KW_LIST: + case MySqlParser.KW_LOCAL: + case MySqlParser.KW_LOGFILE: + case MySqlParser.KW_LOGS: + case MySqlParser.KW_MASTER: + case MySqlParser.KW_MASTER_AUTO_POSITION: + case MySqlParser.KW_MASTER_CONNECT_RETRY: + case MySqlParser.KW_MASTER_DELAY: + case MySqlParser.KW_MASTER_HEARTBEAT_PERIOD: + case MySqlParser.KW_MASTER_HOST: + case MySqlParser.KW_MASTER_LOG_FILE: + case MySqlParser.KW_MASTER_LOG_POS: + case MySqlParser.KW_MASTER_PASSWORD: + case MySqlParser.KW_MASTER_PORT: + case MySqlParser.KW_MASTER_RETRY_COUNT: + case MySqlParser.KW_MASTER_SSL: + case MySqlParser.KW_MASTER_SSL_CA: + case MySqlParser.KW_MASTER_SSL_CAPATH: + case MySqlParser.KW_MASTER_SSL_CERT: + case MySqlParser.KW_MASTER_SSL_CIPHER: + case MySqlParser.KW_MASTER_SSL_CRL: + case MySqlParser.KW_MASTER_SSL_CRLPATH: + case MySqlParser.KW_MASTER_SSL_KEY: + case MySqlParser.KW_MASTER_TLS_VERSION: + case MySqlParser.KW_MASTER_USER: + case MySqlParser.KW_MAX_CONNECTIONS_PER_HOUR: + case MySqlParser.KW_MAX_QUERIES_PER_HOUR: + case MySqlParser.KW_MAX_ROWS: + case MySqlParser.KW_MAX_SIZE: + case MySqlParser.KW_MAX_UPDATES_PER_HOUR: + case MySqlParser.KW_MAX_USER_CONNECTIONS: + case MySqlParser.KW_MEDIUM: + case MySqlParser.KW_MEMBER: + case MySqlParser.KW_MERGE: + case MySqlParser.KW_MESSAGE_TEXT: + case MySqlParser.KW_MID: + case MySqlParser.KW_MIGRATE: + case MySqlParser.KW_MIN_ROWS: + case MySqlParser.KW_MODE: + case MySqlParser.KW_MODIFY: + case MySqlParser.KW_MUTEX: + case MySqlParser.KW_MYSQL: + case MySqlParser.KW_MYSQL_ERRNO: + case MySqlParser.KW_NAME: + case MySqlParser.KW_NAMES: + case MySqlParser.KW_NCHAR: + case MySqlParser.KW_NEVER: + case MySqlParser.KW_NEXT: + case MySqlParser.KW_NO: + case MySqlParser.KW_NOWAIT: + case MySqlParser.KW_NODEGROUP: + case MySqlParser.KW_NONE: + case MySqlParser.KW_ODBC: + case MySqlParser.KW_OFFLINE: + case MySqlParser.KW_OFFSET: + case MySqlParser.KW_OF: + case MySqlParser.KW_OLD_PASSWORD: + case MySqlParser.KW_ONE: + case MySqlParser.KW_ONLINE: + case MySqlParser.KW_ONLY: + case MySqlParser.KW_OPEN: + case MySqlParser.KW_OPTIMIZER_COSTS: + case MySqlParser.KW_OPTIONS: + case MySqlParser.KW_OWNER: + case MySqlParser.KW_PACK_KEYS: + case MySqlParser.KW_PAGE: + case MySqlParser.KW_PAGE_CHECKSUM: + case MySqlParser.KW_PARSER: + case MySqlParser.KW_PARTIAL: + case MySqlParser.KW_PARTITIONING: + case MySqlParser.KW_PARTITIONS: + case MySqlParser.KW_PASSWORD: + case MySqlParser.KW_PASSWORD_LOCK_TIME: + case MySqlParser.KW_PHASE: + case MySqlParser.KW_PLUGIN: + case MySqlParser.KW_PLUGIN_DIR: + case MySqlParser.KW_PLUGINS: + case MySqlParser.KW_PORT: + case MySqlParser.KW_PRECEDES: + case MySqlParser.KW_PREPARE: + case MySqlParser.KW_PRESERVE: + case MySqlParser.KW_PREV: + case MySqlParser.KW_PROCESSLIST: + case MySqlParser.KW_PROFILE: + case MySqlParser.KW_PROFILES: + case MySqlParser.KW_PROXY: + case MySqlParser.KW_QUERY: + case MySqlParser.KW_QUICK: + case MySqlParser.KW_REBUILD: + case MySqlParser.KW_RECOVER: + case MySqlParser.KW_RECURSIVE: + case MySqlParser.KW_REDO_BUFFER_SIZE: + case MySqlParser.KW_REDUNDANT: + case MySqlParser.KW_RELAY: + case MySqlParser.KW_RELAY_LOG_FILE: + case MySqlParser.KW_RELAY_LOG_POS: + case MySqlParser.KW_RELAYLOG: + case MySqlParser.KW_REMOVE: + case MySqlParser.KW_REORGANIZE: + case MySqlParser.KW_REPAIR: + case MySqlParser.KW_REPLICATE_DO_DB: + case MySqlParser.KW_REPLICATE_DO_TABLE: + case MySqlParser.KW_REPLICATE_IGNORE_DB: + case MySqlParser.KW_REPLICATE_IGNORE_TABLE: + case MySqlParser.KW_REPLICATE_REWRITE_DB: + case MySqlParser.KW_REPLICATE_WILD_DO_TABLE: + case MySqlParser.KW_REPLICATE_WILD_IGNORE_TABLE: + case MySqlParser.KW_REPLICATION: + case MySqlParser.KW_RESET: + case MySqlParser.KW_RESUME: + case MySqlParser.KW_RETURNED_SQLSTATE: + case MySqlParser.KW_RETURNS: + case MySqlParser.KW_REUSE: + case MySqlParser.KW_ROLE: + case MySqlParser.KW_ROLLBACK: + case MySqlParser.KW_ROLLUP: + case MySqlParser.KW_ROTATE: + case MySqlParser.KW_ROW: + case MySqlParser.KW_ROWS: + case MySqlParser.KW_ROW_FORMAT: + case MySqlParser.KW_SAVEPOINT: + case MySqlParser.KW_SCHEDULE: + case MySqlParser.KW_SECURITY: + case MySqlParser.KW_SERVER: + case MySqlParser.KW_SESSION: + case MySqlParser.KW_SHARE: + case MySqlParser.KW_SHARED: + case MySqlParser.KW_SIGNED: + case MySqlParser.KW_SIMPLE: + case MySqlParser.KW_SLAVE: + case MySqlParser.KW_SLOW: + case MySqlParser.KW_SNAPSHOT: + case MySqlParser.KW_SOCKET: + case MySqlParser.KW_SOME: + case MySqlParser.KW_SONAME: + case MySqlParser.KW_SOUNDS: + case MySqlParser.KW_SOURCE: + case MySqlParser.KW_SQL_AFTER_GTIDS: + case MySqlParser.KW_SQL_AFTER_MTS_GAPS: + case MySqlParser.KW_SQL_BEFORE_GTIDS: + case MySqlParser.KW_SQL_BUFFER_RESULT: + case MySqlParser.KW_SQL_CACHE: + case MySqlParser.KW_SQL_NO_CACHE: + case MySqlParser.KW_SQL_THREAD: + case MySqlParser.KW_START: + case MySqlParser.KW_STARTS: + case MySqlParser.KW_STATS_AUTO_RECALC: + case MySqlParser.KW_STATS_PERSISTENT: + case MySqlParser.KW_STATS_SAMPLE_PAGES: + case MySqlParser.KW_STATUS: + case MySqlParser.KW_STOP: + case MySqlParser.KW_STORAGE: + case MySqlParser.KW_STRING: + case MySqlParser.KW_SUBCLASS_ORIGIN: + case MySqlParser.KW_SUBJECT: + case MySqlParser.KW_SUBPARTITION: + case MySqlParser.KW_SUBPARTITIONS: + case MySqlParser.KW_SUSPEND: + case MySqlParser.KW_SWAPS: + case MySqlParser.KW_SWITCHES: + case MySqlParser.KW_TABLE_NAME: + case MySqlParser.KW_TABLESPACE: + case MySqlParser.KW_TABLE_TYPE: + case MySqlParser.KW_TEMPORARY: + case MySqlParser.KW_TEMPTABLE: + case MySqlParser.KW_THAN: + case MySqlParser.KW_TRADITIONAL: + case MySqlParser.KW_TRANSACTION: + case MySqlParser.KW_TRANSACTIONAL: + case MySqlParser.KW_TRIGGERS: + case MySqlParser.KW_TRUNCATE: + case MySqlParser.KW_UNBOUNDED: + case MySqlParser.KW_UNDEFINED: + case MySqlParser.KW_UNDOFILE: + case MySqlParser.KW_UNDO_BUFFER_SIZE: + case MySqlParser.KW_UNINSTALL: + case MySqlParser.KW_UNKNOWN: + case MySqlParser.KW_UNTIL: + case MySqlParser.KW_UPGRADE: + case MySqlParser.KW_USER: + case MySqlParser.KW_USE_FRM: + case MySqlParser.KW_USER_RESOURCES: + case MySqlParser.KW_VALIDATION: + case MySqlParser.KW_VALUE: + case MySqlParser.KW_VARIABLES: + case MySqlParser.KW_VIEW: + case MySqlParser.KW_VIRTUAL: + case MySqlParser.KW_VISIBLE: + case MySqlParser.KW_WAIT: + case MySqlParser.KW_WARNINGS: + case MySqlParser.KW_WITHOUT: + case MySqlParser.KW_WORK: + case MySqlParser.KW_WRAPPER: + case MySqlParser.KW_X509: + case MySqlParser.KW_XA: + case MySqlParser.KW_XML: + case MySqlParser.KW_QUARTER: + case MySqlParser.KW_MONTH: + case MySqlParser.KW_DAY: + case MySqlParser.KW_HOUR: + case MySqlParser.KW_MINUTE: + case MySqlParser.KW_WEEK: + case MySqlParser.KW_SECOND: + case MySqlParser.KW_MICROSECOND: + case MySqlParser.KW_ADMIN: + case MySqlParser.KW_AUDIT_ABORT_EXEMPT: + case MySqlParser.KW_AUDIT_ADMIN: + case MySqlParser.KW_AUTHENTICATION_POLICY_ADMIN: + case MySqlParser.KW_BACKUP_ADMIN: + case MySqlParser.KW_BINLOG_ADMIN: + case MySqlParser.KW_BINLOG_ENCRYPTION_ADMIN: + case MySqlParser.KW_CLONE_ADMIN: + case MySqlParser.KW_CONNECTION_ADMIN: + case MySqlParser.KW_ENCRYPTION_KEY_ADMIN: + case MySqlParser.KW_EXECUTE: + case MySqlParser.KW_FILE: + case MySqlParser.KW_FIREWALL_ADMIN: + case MySqlParser.KW_FIREWALL_EXEMPT: + case MySqlParser.KW_FIREWALL_USER: + case MySqlParser.KW_GROUP_REPLICATION_ADMIN: + case MySqlParser.KW_INNODB_REDO_LOG_ARCHIVE: + case MySqlParser.KW_INVOKE: + case MySqlParser.KW_LAMBDA: + case MySqlParser.KW_NDB_STORED_USER: + case MySqlParser.KW_PASSWORDLESS_USER_ADMIN: + case MySqlParser.KW_PERSIST_RO_VARIABLES_ADMIN: + case MySqlParser.KW_PRIVILEGES: + case MySqlParser.KW_PROCESS: + case MySqlParser.KW_RELOAD: + case MySqlParser.KW_REPLICATION_APPLIER: + case MySqlParser.KW_REPLICATION_SLAVE_ADMIN: + case MySqlParser.KW_RESOURCE_GROUP_ADMIN: + case MySqlParser.KW_RESOURCE_GROUP_USER: + case MySqlParser.KW_ROLE_ADMIN: + case MySqlParser.KW_ROUTINE: + case MySqlParser.KW_S3: + case MySqlParser.KW_SESSION_VARIABLES_ADMIN: + case MySqlParser.KW_SET_USER_ID: + case MySqlParser.KW_SHOW_ROUTINE: + case MySqlParser.KW_SHUTDOWN: + case MySqlParser.KW_SUPER: + case MySqlParser.KW_SYSTEM_VARIABLES_ADMIN: + case MySqlParser.KW_TABLES: + case MySqlParser.KW_TABLE_ENCRYPTION_ADMIN: + case MySqlParser.KW_VERSION_TOKEN_ADMIN: + case MySqlParser.KW_XA_RECOVER_ADMIN: + case MySqlParser.KW_ARMSCII8: + case MySqlParser.KW_ASCII: + case MySqlParser.KW_BIG5: + case MySqlParser.KW_CP1250: + case MySqlParser.KW_CP1251: + case MySqlParser.KW_CP1256: + case MySqlParser.KW_CP1257: + case MySqlParser.KW_CP850: + case MySqlParser.KW_CP852: + case MySqlParser.KW_CP866: + case MySqlParser.KW_CP932: + case MySqlParser.KW_DEC8: + case MySqlParser.KW_EUCJPMS: + case MySqlParser.KW_EUCKR: + case MySqlParser.KW_GB18030: + case MySqlParser.KW_GB2312: + case MySqlParser.KW_GBK: + case MySqlParser.KW_GEOSTD8: + case MySqlParser.KW_GREEK: + case MySqlParser.KW_HEBREW: + case MySqlParser.KW_HP8: + case MySqlParser.KW_KEYBCS2: + case MySqlParser.KW_KOI8R: + case MySqlParser.KW_KOI8U: + case MySqlParser.KW_LATIN1: + case MySqlParser.KW_LATIN2: + case MySqlParser.KW_LATIN5: + case MySqlParser.KW_LATIN7: + case MySqlParser.KW_MACCE: + case MySqlParser.KW_MACROMAN: + case MySqlParser.KW_SJIS: + case MySqlParser.KW_SWE7: + case MySqlParser.KW_TIS620: + case MySqlParser.KW_UCS2: + case MySqlParser.KW_UJIS: + case MySqlParser.KW_UTF16: + case MySqlParser.KW_UTF16LE: + case MySqlParser.KW_UTF32: + case MySqlParser.KW_UTF8: + case MySqlParser.KW_UTF8MB3: + case MySqlParser.KW_UTF8MB4: + case MySqlParser.KW_ARCHIVE: + case MySqlParser.KW_BLACKHOLE: + case MySqlParser.KW_CSV: + case MySqlParser.KW_FEDERATED: + case MySqlParser.KW_INNODB: + case MySqlParser.KW_MEMORY: + case MySqlParser.KW_MRG_MYISAM: + case MySqlParser.KW_MYISAM: + case MySqlParser.KW_NDB: + case MySqlParser.KW_NDBCLUSTER: + case MySqlParser.KW_PERFORMANCE_SCHEMA: + case MySqlParser.KW_TOKUDB: + case MySqlParser.KW_REPEATABLE: + case MySqlParser.KW_COMMITTED: + case MySqlParser.KW_UNCOMMITTED: + case MySqlParser.KW_SERIALIZABLE: + case MySqlParser.KW_GEOMETRYCOLLECTION: + case MySqlParser.KW_LINESTRING: + case MySqlParser.KW_MULTILINESTRING: + case MySqlParser.KW_MULTIPOINT: + case MySqlParser.KW_MULTIPOLYGON: + case MySqlParser.KW_POINT: + case MySqlParser.KW_POLYGON: + case MySqlParser.KW_CATALOG_NAME: + case MySqlParser.KW_CHARSET: + case MySqlParser.KW_COLLATION: + case MySqlParser.KW_ENGINE_ATTRIBUTE: + case MySqlParser.KW_FORMAT: + case MySqlParser.KW_GET_FORMAT: + case MySqlParser.KW_RANDOM: + case MySqlParser.KW_REVERSE: + case MySqlParser.KW_ROW_COUNT: + case MySqlParser.KW_SCHEMA_NAME: + case MySqlParser.KW_SECONDARY_ENGINE_ATTRIBUTE: + case MySqlParser.KW_SRID: + case MySqlParser.KW_SYSTEM_USER: + case MySqlParser.KW_TP_CONNECTION_ADMIN: + case MySqlParser.KW_WEIGHT_STRING: + case MySqlParser.MOD: + case MySqlParser.CHARSET_REVERSE_QOUTE_STRING: + case MySqlParser.STRING_LITERAL: + case MySqlParser.ID: + { + this.state = 2967; + this.partitionNames(); + } + break; + case MySqlParser.KW_ALL: + { + this.state = 2968; + this.match(MySqlParser.KW_ALL); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + break; + case MySqlParser.KW_REBUILD: + localContext = new AlterByRebuildPartitionContext(localContext); + this.enterOuterAlt(localContext, 12); + { + this.state = 2971; + this.match(MySqlParser.KW_REBUILD); + this.state = 2972; + this.match(MySqlParser.KW_PARTITION); + this.state = 2975; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_ARRAY: + case MySqlParser.KW_ATTRIBUTE: + case MySqlParser.KW_BUCKETS: + case MySqlParser.KW_CONDITION: + case MySqlParser.KW_CURRENT: + case MySqlParser.KW_CURRENT_USER: + case MySqlParser.KW_DATABASE: + case MySqlParser.KW_DEFAULT: + case MySqlParser.KW_DIAGNOSTICS: + case MySqlParser.KW_EMPTY: + case MySqlParser.KW_ENFORCED: + case MySqlParser.KW_EXCEPT: + case MySqlParser.KW_GROUP: + case MySqlParser.KW_IF: + case MySqlParser.KW_INSERT: + case MySqlParser.KW_LATERAL: + case MySqlParser.KW_LEFT: + case MySqlParser.KW_NUMBER: + case MySqlParser.KW_OPTIONAL: + case MySqlParser.KW_ORDER: + case MySqlParser.KW_PRIMARY: + case MySqlParser.KW_REPEAT: + case MySqlParser.KW_REPLACE: + case MySqlParser.KW_RIGHT: + case MySqlParser.KW_SCHEMA: + case MySqlParser.KW_SKIP_QUERY_REWRITE: + case MySqlParser.KW_STACKED: + case MySqlParser.KW_DATE: + case MySqlParser.KW_TIME: + case MySqlParser.KW_TIMESTAMP: + case MySqlParser.KW_DATETIME: + case MySqlParser.KW_YEAR: + case MySqlParser.KW_BINARY: + case MySqlParser.KW_TEXT: + case MySqlParser.KW_ENUM: + case MySqlParser.KW_SERIAL: + case MySqlParser.KW_JSON_TABLE: + case MySqlParser.KW_JSON_VALUE: + case MySqlParser.KW_NESTED: + case MySqlParser.KW_ORDINALITY: + case MySqlParser.KW_PATH: + case MySqlParser.KW_AVG: + case MySqlParser.KW_BIT_AND: + case MySqlParser.KW_BIT_OR: + case MySqlParser.KW_BIT_XOR: + case MySqlParser.KW_COUNT: + case MySqlParser.KW_CUME_DIST: + case MySqlParser.KW_DENSE_RANK: + case MySqlParser.KW_FIRST_VALUE: + case MySqlParser.KW_GROUP_CONCAT: + case MySqlParser.KW_LAG: + case MySqlParser.KW_LAST_VALUE: + case MySqlParser.KW_LEAD: + case MySqlParser.KW_MAX: + case MySqlParser.KW_MIN: + case MySqlParser.KW_NTILE: + case MySqlParser.KW_NTH_VALUE: + case MySqlParser.KW_PERCENT_RANK: + case MySqlParser.KW_RANK: + case MySqlParser.KW_ROW_NUMBER: + case MySqlParser.KW_STD: + case MySqlParser.KW_STDDEV: + case MySqlParser.KW_STDDEV_POP: + case MySqlParser.KW_STDDEV_SAMP: + case MySqlParser.KW_SUM: + case MySqlParser.KW_VAR_POP: + case MySqlParser.KW_VAR_SAMP: + case MySqlParser.KW_VARIANCE: + case MySqlParser.KW_CURRENT_DATE: + case MySqlParser.KW_CURRENT_TIME: + case MySqlParser.KW_CURRENT_TIMESTAMP: + case MySqlParser.KW_LOCALTIME: + case MySqlParser.KW_CURDATE: + case MySqlParser.KW_CURTIME: + case MySqlParser.KW_DATE_ADD: + case MySqlParser.KW_DATE_SUB: + case MySqlParser.KW_LOCALTIMESTAMP: + case MySqlParser.KW_NOW: + case MySqlParser.KW_POSITION: + case MySqlParser.KW_SUBSTR: + case MySqlParser.KW_SUBSTRING: + case MySqlParser.KW_SYSDATE: + case MySqlParser.KW_TRIM: + case MySqlParser.KW_UTC_DATE: + case MySqlParser.KW_UTC_TIME: + case MySqlParser.KW_UTC_TIMESTAMP: + case MySqlParser.KW_ACCOUNT: + case MySqlParser.KW_ACTION: + case MySqlParser.KW_AFTER: + case MySqlParser.KW_AGGREGATE: + case MySqlParser.KW_ALGORITHM: + case MySqlParser.KW_ANY: + case MySqlParser.KW_AT: + case MySqlParser.KW_AUTHORS: + case MySqlParser.KW_AUTOCOMMIT: + case MySqlParser.KW_AUTOEXTEND_SIZE: + case MySqlParser.KW_AUTO_INCREMENT: + case MySqlParser.KW_AVG_ROW_LENGTH: + case MySqlParser.KW_BEGIN: + case MySqlParser.KW_BINLOG: + case MySqlParser.KW_BIT: + case MySqlParser.KW_BLOCK: + case MySqlParser.KW_BOOL: + case MySqlParser.KW_BOOLEAN: + case MySqlParser.KW_BTREE: + case MySqlParser.KW_CACHE: + case MySqlParser.KW_CASCADED: + case MySqlParser.KW_CHAIN: + case MySqlParser.KW_CHANGED: + case MySqlParser.KW_CHANNEL: + case MySqlParser.KW_CHECKSUM: + case MySqlParser.KW_CIPHER: + case MySqlParser.KW_CLASS_ORIGIN: + case MySqlParser.KW_CLIENT: + case MySqlParser.KW_CLOSE: + case MySqlParser.KW_COALESCE: + case MySqlParser.KW_CODE: + case MySqlParser.KW_COLUMNS: + case MySqlParser.KW_COLUMN_FORMAT: + case MySqlParser.KW_COLUMN_NAME: + case MySqlParser.KW_COMMENT: + case MySqlParser.KW_COMMIT: + case MySqlParser.KW_COMPACT: + case MySqlParser.KW_COMPLETION: + case MySqlParser.KW_COMPRESSED: + case MySqlParser.KW_COMPRESSION: + case MySqlParser.KW_CONCURRENT: + case MySqlParser.KW_CONNECT: + case MySqlParser.KW_CONNECTION: + case MySqlParser.KW_CONSISTENT: + case MySqlParser.KW_CONSTRAINT_CATALOG: + case MySqlParser.KW_CONSTRAINT_SCHEMA: + case MySqlParser.KW_CONSTRAINT_NAME: + case MySqlParser.KW_CONTAINS: + case MySqlParser.KW_CONTEXT: + case MySqlParser.KW_CONTRIBUTORS: + case MySqlParser.KW_COPY: + case MySqlParser.KW_CPU: + case MySqlParser.KW_CURSOR_NAME: + case MySqlParser.KW_DATA: + case MySqlParser.KW_DATAFILE: + case MySqlParser.KW_DEALLOCATE: + case MySqlParser.KW_DEFAULT_AUTH: + case MySqlParser.KW_DEFINER: + case MySqlParser.KW_DELAY_KEY_WRITE: + case MySqlParser.KW_DES_KEY_FILE: + case MySqlParser.KW_DIRECTORY: + case MySqlParser.KW_DISABLE: + case MySqlParser.KW_DISCARD: + case MySqlParser.KW_DISK: + case MySqlParser.KW_DO: + case MySqlParser.KW_DUMPFILE: + case MySqlParser.KW_DUPLICATE: + case MySqlParser.KW_DYNAMIC: + case MySqlParser.KW_ENABLE: + case MySqlParser.KW_ENCRYPTION: + case MySqlParser.KW_END: + case MySqlParser.KW_ENDS: + case MySqlParser.KW_ENGINE: + case MySqlParser.KW_ENGINES: + case MySqlParser.KW_ERROR: + case MySqlParser.KW_ERRORS: + case MySqlParser.KW_ESCAPE: + case MySqlParser.KW_EVENT: + case MySqlParser.KW_EVENTS: + case MySqlParser.KW_EVERY: + case MySqlParser.KW_EXCHANGE: + case MySqlParser.KW_EXCLUSIVE: + case MySqlParser.KW_EXPIRE: + case MySqlParser.KW_EXPORT: + case MySqlParser.KW_EXTENDED: + case MySqlParser.KW_EXTENT_SIZE: + case MySqlParser.KW_FAILED_LOGIN_ATTEMPTS: + case MySqlParser.KW_FAST: + case MySqlParser.KW_FAULTS: + case MySqlParser.KW_FIELDS: + case MySqlParser.KW_FILE_BLOCK_SIZE: + case MySqlParser.KW_FILTER: + case MySqlParser.KW_FIRST: + case MySqlParser.KW_FIXED: + case MySqlParser.KW_FLUSH: + case MySqlParser.KW_FOLLOWS: + case MySqlParser.KW_FOUND: + case MySqlParser.KW_FULL: + case MySqlParser.KW_FUNCTION: + case MySqlParser.KW_GENERAL: + case MySqlParser.KW_GLOBAL: + case MySqlParser.KW_GRANTS: + case MySqlParser.KW_GROUP_REPLICATION: + case MySqlParser.KW_HANDLER: + case MySqlParser.KW_HASH: + case MySqlParser.KW_HELP: + case MySqlParser.KW_HISTORY: + case MySqlParser.KW_HOST: + case MySqlParser.KW_HOSTS: + case MySqlParser.KW_IDENTIFIED: + case MySqlParser.KW_IGNORE_SERVER_IDS: + case MySqlParser.KW_IMPORT: + case MySqlParser.KW_INDEXES: + case MySqlParser.KW_INITIAL_SIZE: + case MySqlParser.KW_INPLACE: + case MySqlParser.KW_INSERT_METHOD: + case MySqlParser.KW_INSTALL: + case MySqlParser.KW_INSTANCE: + case MySqlParser.KW_INSTANT: + case MySqlParser.KW_INVISIBLE: + case MySqlParser.KW_INVOKER: + case MySqlParser.KW_IO: + case MySqlParser.KW_IO_THREAD: + case MySqlParser.KW_IPC: + case MySqlParser.KW_ISOLATION: + case MySqlParser.KW_ISSUER: + case MySqlParser.KW_JSON: + case MySqlParser.KW_KEY_BLOCK_SIZE: + case MySqlParser.KW_LANGUAGE: + case MySqlParser.KW_LAST: + case MySqlParser.KW_LEAVES: + case MySqlParser.KW_LESS: + case MySqlParser.KW_LEVEL: + case MySqlParser.KW_LIST: + case MySqlParser.KW_LOCAL: + case MySqlParser.KW_LOGFILE: + case MySqlParser.KW_LOGS: + case MySqlParser.KW_MASTER: + case MySqlParser.KW_MASTER_AUTO_POSITION: + case MySqlParser.KW_MASTER_CONNECT_RETRY: + case MySqlParser.KW_MASTER_DELAY: + case MySqlParser.KW_MASTER_HEARTBEAT_PERIOD: + case MySqlParser.KW_MASTER_HOST: + case MySqlParser.KW_MASTER_LOG_FILE: + case MySqlParser.KW_MASTER_LOG_POS: + case MySqlParser.KW_MASTER_PASSWORD: + case MySqlParser.KW_MASTER_PORT: + case MySqlParser.KW_MASTER_RETRY_COUNT: + case MySqlParser.KW_MASTER_SSL: + case MySqlParser.KW_MASTER_SSL_CA: + case MySqlParser.KW_MASTER_SSL_CAPATH: + case MySqlParser.KW_MASTER_SSL_CERT: + case MySqlParser.KW_MASTER_SSL_CIPHER: + case MySqlParser.KW_MASTER_SSL_CRL: + case MySqlParser.KW_MASTER_SSL_CRLPATH: + case MySqlParser.KW_MASTER_SSL_KEY: + case MySqlParser.KW_MASTER_TLS_VERSION: + case MySqlParser.KW_MASTER_USER: + case MySqlParser.KW_MAX_CONNECTIONS_PER_HOUR: + case MySqlParser.KW_MAX_QUERIES_PER_HOUR: + case MySqlParser.KW_MAX_ROWS: + case MySqlParser.KW_MAX_SIZE: + case MySqlParser.KW_MAX_UPDATES_PER_HOUR: + case MySqlParser.KW_MAX_USER_CONNECTIONS: + case MySqlParser.KW_MEDIUM: + case MySqlParser.KW_MEMBER: + case MySqlParser.KW_MERGE: + case MySqlParser.KW_MESSAGE_TEXT: + case MySqlParser.KW_MID: + case MySqlParser.KW_MIGRATE: + case MySqlParser.KW_MIN_ROWS: + case MySqlParser.KW_MODE: + case MySqlParser.KW_MODIFY: + case MySqlParser.KW_MUTEX: + case MySqlParser.KW_MYSQL: + case MySqlParser.KW_MYSQL_ERRNO: + case MySqlParser.KW_NAME: + case MySqlParser.KW_NAMES: + case MySqlParser.KW_NCHAR: + case MySqlParser.KW_NEVER: + case MySqlParser.KW_NEXT: + case MySqlParser.KW_NO: + case MySqlParser.KW_NOWAIT: + case MySqlParser.KW_NODEGROUP: + case MySqlParser.KW_NONE: + case MySqlParser.KW_ODBC: + case MySqlParser.KW_OFFLINE: + case MySqlParser.KW_OFFSET: + case MySqlParser.KW_OF: + case MySqlParser.KW_OLD_PASSWORD: + case MySqlParser.KW_ONE: + case MySqlParser.KW_ONLINE: + case MySqlParser.KW_ONLY: + case MySqlParser.KW_OPEN: + case MySqlParser.KW_OPTIMIZER_COSTS: + case MySqlParser.KW_OPTIONS: + case MySqlParser.KW_OWNER: + case MySqlParser.KW_PACK_KEYS: + case MySqlParser.KW_PAGE: + case MySqlParser.KW_PAGE_CHECKSUM: + case MySqlParser.KW_PARSER: + case MySqlParser.KW_PARTIAL: + case MySqlParser.KW_PARTITIONING: + case MySqlParser.KW_PARTITIONS: + case MySqlParser.KW_PASSWORD: + case MySqlParser.KW_PASSWORD_LOCK_TIME: + case MySqlParser.KW_PHASE: + case MySqlParser.KW_PLUGIN: + case MySqlParser.KW_PLUGIN_DIR: + case MySqlParser.KW_PLUGINS: + case MySqlParser.KW_PORT: + case MySqlParser.KW_PRECEDES: + case MySqlParser.KW_PREPARE: + case MySqlParser.KW_PRESERVE: + case MySqlParser.KW_PREV: + case MySqlParser.KW_PROCESSLIST: + case MySqlParser.KW_PROFILE: + case MySqlParser.KW_PROFILES: + case MySqlParser.KW_PROXY: + case MySqlParser.KW_QUERY: + case MySqlParser.KW_QUICK: + case MySqlParser.KW_REBUILD: + case MySqlParser.KW_RECOVER: + case MySqlParser.KW_RECURSIVE: + case MySqlParser.KW_REDO_BUFFER_SIZE: + case MySqlParser.KW_REDUNDANT: + case MySqlParser.KW_RELAY: + case MySqlParser.KW_RELAY_LOG_FILE: + case MySqlParser.KW_RELAY_LOG_POS: + case MySqlParser.KW_RELAYLOG: + case MySqlParser.KW_REMOVE: + case MySqlParser.KW_REORGANIZE: + case MySqlParser.KW_REPAIR: + case MySqlParser.KW_REPLICATE_DO_DB: + case MySqlParser.KW_REPLICATE_DO_TABLE: + case MySqlParser.KW_REPLICATE_IGNORE_DB: + case MySqlParser.KW_REPLICATE_IGNORE_TABLE: + case MySqlParser.KW_REPLICATE_REWRITE_DB: + case MySqlParser.KW_REPLICATE_WILD_DO_TABLE: + case MySqlParser.KW_REPLICATE_WILD_IGNORE_TABLE: + case MySqlParser.KW_REPLICATION: + case MySqlParser.KW_RESET: + case MySqlParser.KW_RESUME: + case MySqlParser.KW_RETURNED_SQLSTATE: + case MySqlParser.KW_RETURNS: + case MySqlParser.KW_REUSE: + case MySqlParser.KW_ROLE: + case MySqlParser.KW_ROLLBACK: + case MySqlParser.KW_ROLLUP: + case MySqlParser.KW_ROTATE: + case MySqlParser.KW_ROW: + case MySqlParser.KW_ROWS: + case MySqlParser.KW_ROW_FORMAT: + case MySqlParser.KW_SAVEPOINT: + case MySqlParser.KW_SCHEDULE: + case MySqlParser.KW_SECURITY: + case MySqlParser.KW_SERVER: + case MySqlParser.KW_SESSION: + case MySqlParser.KW_SHARE: + case MySqlParser.KW_SHARED: + case MySqlParser.KW_SIGNED: + case MySqlParser.KW_SIMPLE: + case MySqlParser.KW_SLAVE: + case MySqlParser.KW_SLOW: + case MySqlParser.KW_SNAPSHOT: + case MySqlParser.KW_SOCKET: + case MySqlParser.KW_SOME: + case MySqlParser.KW_SONAME: + case MySqlParser.KW_SOUNDS: + case MySqlParser.KW_SOURCE: + case MySqlParser.KW_SQL_AFTER_GTIDS: + case MySqlParser.KW_SQL_AFTER_MTS_GAPS: + case MySqlParser.KW_SQL_BEFORE_GTIDS: + case MySqlParser.KW_SQL_BUFFER_RESULT: + case MySqlParser.KW_SQL_CACHE: + case MySqlParser.KW_SQL_NO_CACHE: + case MySqlParser.KW_SQL_THREAD: + case MySqlParser.KW_START: + case MySqlParser.KW_STARTS: + case MySqlParser.KW_STATS_AUTO_RECALC: + case MySqlParser.KW_STATS_PERSISTENT: + case MySqlParser.KW_STATS_SAMPLE_PAGES: + case MySqlParser.KW_STATUS: + case MySqlParser.KW_STOP: + case MySqlParser.KW_STORAGE: + case MySqlParser.KW_STRING: + case MySqlParser.KW_SUBCLASS_ORIGIN: + case MySqlParser.KW_SUBJECT: + case MySqlParser.KW_SUBPARTITION: + case MySqlParser.KW_SUBPARTITIONS: + case MySqlParser.KW_SUSPEND: + case MySqlParser.KW_SWAPS: + case MySqlParser.KW_SWITCHES: + case MySqlParser.KW_TABLE_NAME: + case MySqlParser.KW_TABLESPACE: + case MySqlParser.KW_TABLE_TYPE: + case MySqlParser.KW_TEMPORARY: + case MySqlParser.KW_TEMPTABLE: + case MySqlParser.KW_THAN: + case MySqlParser.KW_TRADITIONAL: + case MySqlParser.KW_TRANSACTION: + case MySqlParser.KW_TRANSACTIONAL: + case MySqlParser.KW_TRIGGERS: + case MySqlParser.KW_TRUNCATE: + case MySqlParser.KW_UNBOUNDED: + case MySqlParser.KW_UNDEFINED: + case MySqlParser.KW_UNDOFILE: + case MySqlParser.KW_UNDO_BUFFER_SIZE: + case MySqlParser.KW_UNINSTALL: + case MySqlParser.KW_UNKNOWN: + case MySqlParser.KW_UNTIL: + case MySqlParser.KW_UPGRADE: + case MySqlParser.KW_USER: + case MySqlParser.KW_USE_FRM: + case MySqlParser.KW_USER_RESOURCES: + case MySqlParser.KW_VALIDATION: + case MySqlParser.KW_VALUE: + case MySqlParser.KW_VARIABLES: + case MySqlParser.KW_VIEW: + case MySqlParser.KW_VIRTUAL: + case MySqlParser.KW_VISIBLE: + case MySqlParser.KW_WAIT: + case MySqlParser.KW_WARNINGS: + case MySqlParser.KW_WITHOUT: + case MySqlParser.KW_WORK: + case MySqlParser.KW_WRAPPER: + case MySqlParser.KW_X509: + case MySqlParser.KW_XA: + case MySqlParser.KW_XML: + case MySqlParser.KW_QUARTER: + case MySqlParser.KW_MONTH: + case MySqlParser.KW_DAY: + case MySqlParser.KW_HOUR: + case MySqlParser.KW_MINUTE: + case MySqlParser.KW_WEEK: + case MySqlParser.KW_SECOND: + case MySqlParser.KW_MICROSECOND: + case MySqlParser.KW_ADMIN: + case MySqlParser.KW_AUDIT_ABORT_EXEMPT: + case MySqlParser.KW_AUDIT_ADMIN: + case MySqlParser.KW_AUTHENTICATION_POLICY_ADMIN: + case MySqlParser.KW_BACKUP_ADMIN: + case MySqlParser.KW_BINLOG_ADMIN: + case MySqlParser.KW_BINLOG_ENCRYPTION_ADMIN: + case MySqlParser.KW_CLONE_ADMIN: + case MySqlParser.KW_CONNECTION_ADMIN: + case MySqlParser.KW_ENCRYPTION_KEY_ADMIN: + case MySqlParser.KW_EXECUTE: + case MySqlParser.KW_FILE: + case MySqlParser.KW_FIREWALL_ADMIN: + case MySqlParser.KW_FIREWALL_EXEMPT: + case MySqlParser.KW_FIREWALL_USER: + case MySqlParser.KW_GROUP_REPLICATION_ADMIN: + case MySqlParser.KW_INNODB_REDO_LOG_ARCHIVE: + case MySqlParser.KW_INVOKE: + case MySqlParser.KW_LAMBDA: + case MySqlParser.KW_NDB_STORED_USER: + case MySqlParser.KW_PASSWORDLESS_USER_ADMIN: + case MySqlParser.KW_PERSIST_RO_VARIABLES_ADMIN: + case MySqlParser.KW_PRIVILEGES: + case MySqlParser.KW_PROCESS: + case MySqlParser.KW_RELOAD: + case MySqlParser.KW_REPLICATION_APPLIER: + case MySqlParser.KW_REPLICATION_SLAVE_ADMIN: + case MySqlParser.KW_RESOURCE_GROUP_ADMIN: + case MySqlParser.KW_RESOURCE_GROUP_USER: + case MySqlParser.KW_ROLE_ADMIN: + case MySqlParser.KW_ROUTINE: + case MySqlParser.KW_S3: + case MySqlParser.KW_SESSION_VARIABLES_ADMIN: + case MySqlParser.KW_SET_USER_ID: + case MySqlParser.KW_SHOW_ROUTINE: + case MySqlParser.KW_SHUTDOWN: + case MySqlParser.KW_SUPER: + case MySqlParser.KW_SYSTEM_VARIABLES_ADMIN: + case MySqlParser.KW_TABLES: + case MySqlParser.KW_TABLE_ENCRYPTION_ADMIN: + case MySqlParser.KW_VERSION_TOKEN_ADMIN: + case MySqlParser.KW_XA_RECOVER_ADMIN: + case MySqlParser.KW_ARMSCII8: + case MySqlParser.KW_ASCII: + case MySqlParser.KW_BIG5: + case MySqlParser.KW_CP1250: + case MySqlParser.KW_CP1251: + case MySqlParser.KW_CP1256: + case MySqlParser.KW_CP1257: + case MySqlParser.KW_CP850: + case MySqlParser.KW_CP852: + case MySqlParser.KW_CP866: + case MySqlParser.KW_CP932: + case MySqlParser.KW_DEC8: + case MySqlParser.KW_EUCJPMS: + case MySqlParser.KW_EUCKR: + case MySqlParser.KW_GB18030: + case MySqlParser.KW_GB2312: + case MySqlParser.KW_GBK: + case MySqlParser.KW_GEOSTD8: + case MySqlParser.KW_GREEK: + case MySqlParser.KW_HEBREW: + case MySqlParser.KW_HP8: + case MySqlParser.KW_KEYBCS2: + case MySqlParser.KW_KOI8R: + case MySqlParser.KW_KOI8U: + case MySqlParser.KW_LATIN1: + case MySqlParser.KW_LATIN2: + case MySqlParser.KW_LATIN5: + case MySqlParser.KW_LATIN7: + case MySqlParser.KW_MACCE: + case MySqlParser.KW_MACROMAN: + case MySqlParser.KW_SJIS: + case MySqlParser.KW_SWE7: + case MySqlParser.KW_TIS620: + case MySqlParser.KW_UCS2: + case MySqlParser.KW_UJIS: + case MySqlParser.KW_UTF16: + case MySqlParser.KW_UTF16LE: + case MySqlParser.KW_UTF32: + case MySqlParser.KW_UTF8: + case MySqlParser.KW_UTF8MB3: + case MySqlParser.KW_UTF8MB4: + case MySqlParser.KW_ARCHIVE: + case MySqlParser.KW_BLACKHOLE: + case MySqlParser.KW_CSV: + case MySqlParser.KW_FEDERATED: + case MySqlParser.KW_INNODB: + case MySqlParser.KW_MEMORY: + case MySqlParser.KW_MRG_MYISAM: + case MySqlParser.KW_MYISAM: + case MySqlParser.KW_NDB: + case MySqlParser.KW_NDBCLUSTER: + case MySqlParser.KW_PERFORMANCE_SCHEMA: + case MySqlParser.KW_TOKUDB: + case MySqlParser.KW_REPEATABLE: + case MySqlParser.KW_COMMITTED: + case MySqlParser.KW_UNCOMMITTED: + case MySqlParser.KW_SERIALIZABLE: + case MySqlParser.KW_GEOMETRYCOLLECTION: + case MySqlParser.KW_LINESTRING: + case MySqlParser.KW_MULTILINESTRING: + case MySqlParser.KW_MULTIPOINT: + case MySqlParser.KW_MULTIPOLYGON: + case MySqlParser.KW_POINT: + case MySqlParser.KW_POLYGON: + case MySqlParser.KW_CATALOG_NAME: + case MySqlParser.KW_CHARSET: + case MySqlParser.KW_COLLATION: + case MySqlParser.KW_ENGINE_ATTRIBUTE: + case MySqlParser.KW_FORMAT: + case MySqlParser.KW_GET_FORMAT: + case MySqlParser.KW_RANDOM: + case MySqlParser.KW_REVERSE: + case MySqlParser.KW_ROW_COUNT: + case MySqlParser.KW_SCHEMA_NAME: + case MySqlParser.KW_SECONDARY_ENGINE_ATTRIBUTE: + case MySqlParser.KW_SRID: + case MySqlParser.KW_SYSTEM_USER: + case MySqlParser.KW_TP_CONNECTION_ADMIN: + case MySqlParser.KW_WEIGHT_STRING: + case MySqlParser.MOD: + case MySqlParser.CHARSET_REVERSE_QOUTE_STRING: + case MySqlParser.STRING_LITERAL: + case MySqlParser.ID: + { + this.state = 2973; + this.partitionNames(); + } + break; + case MySqlParser.KW_ALL: + { + this.state = 2974; + this.match(MySqlParser.KW_ALL); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + break; + case MySqlParser.KW_REPAIR: + localContext = new AlterByRepairPartitionContext(localContext); + this.enterOuterAlt(localContext, 13); + { + this.state = 2977; + this.match(MySqlParser.KW_REPAIR); + this.state = 2978; + this.match(MySqlParser.KW_PARTITION); + this.state = 2981; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_ARRAY: + case MySqlParser.KW_ATTRIBUTE: + case MySqlParser.KW_BUCKETS: + case MySqlParser.KW_CONDITION: + case MySqlParser.KW_CURRENT: + case MySqlParser.KW_CURRENT_USER: + case MySqlParser.KW_DATABASE: + case MySqlParser.KW_DEFAULT: + case MySqlParser.KW_DIAGNOSTICS: + case MySqlParser.KW_EMPTY: + case MySqlParser.KW_ENFORCED: + case MySqlParser.KW_EXCEPT: + case MySqlParser.KW_GROUP: + case MySqlParser.KW_IF: + case MySqlParser.KW_INSERT: + case MySqlParser.KW_LATERAL: + case MySqlParser.KW_LEFT: + case MySqlParser.KW_NUMBER: + case MySqlParser.KW_OPTIONAL: + case MySqlParser.KW_ORDER: + case MySqlParser.KW_PRIMARY: + case MySqlParser.KW_REPEAT: + case MySqlParser.KW_REPLACE: + case MySqlParser.KW_RIGHT: + case MySqlParser.KW_SCHEMA: + case MySqlParser.KW_SKIP_QUERY_REWRITE: + case MySqlParser.KW_STACKED: + case MySqlParser.KW_DATE: + case MySqlParser.KW_TIME: + case MySqlParser.KW_TIMESTAMP: + case MySqlParser.KW_DATETIME: + case MySqlParser.KW_YEAR: + case MySqlParser.KW_BINARY: + case MySqlParser.KW_TEXT: + case MySqlParser.KW_ENUM: + case MySqlParser.KW_SERIAL: + case MySqlParser.KW_JSON_TABLE: + case MySqlParser.KW_JSON_VALUE: + case MySqlParser.KW_NESTED: + case MySqlParser.KW_ORDINALITY: + case MySqlParser.KW_PATH: + case MySqlParser.KW_AVG: + case MySqlParser.KW_BIT_AND: + case MySqlParser.KW_BIT_OR: + case MySqlParser.KW_BIT_XOR: + case MySqlParser.KW_COUNT: + case MySqlParser.KW_CUME_DIST: + case MySqlParser.KW_DENSE_RANK: + case MySqlParser.KW_FIRST_VALUE: + case MySqlParser.KW_GROUP_CONCAT: + case MySqlParser.KW_LAG: + case MySqlParser.KW_LAST_VALUE: + case MySqlParser.KW_LEAD: + case MySqlParser.KW_MAX: + case MySqlParser.KW_MIN: + case MySqlParser.KW_NTILE: + case MySqlParser.KW_NTH_VALUE: + case MySqlParser.KW_PERCENT_RANK: + case MySqlParser.KW_RANK: + case MySqlParser.KW_ROW_NUMBER: + case MySqlParser.KW_STD: + case MySqlParser.KW_STDDEV: + case MySqlParser.KW_STDDEV_POP: + case MySqlParser.KW_STDDEV_SAMP: + case MySqlParser.KW_SUM: + case MySqlParser.KW_VAR_POP: + case MySqlParser.KW_VAR_SAMP: + case MySqlParser.KW_VARIANCE: + case MySqlParser.KW_CURRENT_DATE: + case MySqlParser.KW_CURRENT_TIME: + case MySqlParser.KW_CURRENT_TIMESTAMP: + case MySqlParser.KW_LOCALTIME: + case MySqlParser.KW_CURDATE: + case MySqlParser.KW_CURTIME: + case MySqlParser.KW_DATE_ADD: + case MySqlParser.KW_DATE_SUB: + case MySqlParser.KW_LOCALTIMESTAMP: + case MySqlParser.KW_NOW: + case MySqlParser.KW_POSITION: + case MySqlParser.KW_SUBSTR: + case MySqlParser.KW_SUBSTRING: + case MySqlParser.KW_SYSDATE: + case MySqlParser.KW_TRIM: + case MySqlParser.KW_UTC_DATE: + case MySqlParser.KW_UTC_TIME: + case MySqlParser.KW_UTC_TIMESTAMP: + case MySqlParser.KW_ACCOUNT: + case MySqlParser.KW_ACTION: + case MySqlParser.KW_AFTER: + case MySqlParser.KW_AGGREGATE: + case MySqlParser.KW_ALGORITHM: + case MySqlParser.KW_ANY: + case MySqlParser.KW_AT: + case MySqlParser.KW_AUTHORS: + case MySqlParser.KW_AUTOCOMMIT: + case MySqlParser.KW_AUTOEXTEND_SIZE: + case MySqlParser.KW_AUTO_INCREMENT: + case MySqlParser.KW_AVG_ROW_LENGTH: + case MySqlParser.KW_BEGIN: + case MySqlParser.KW_BINLOG: + case MySqlParser.KW_BIT: + case MySqlParser.KW_BLOCK: + case MySqlParser.KW_BOOL: + case MySqlParser.KW_BOOLEAN: + case MySqlParser.KW_BTREE: + case MySqlParser.KW_CACHE: + case MySqlParser.KW_CASCADED: + case MySqlParser.KW_CHAIN: + case MySqlParser.KW_CHANGED: + case MySqlParser.KW_CHANNEL: + case MySqlParser.KW_CHECKSUM: + case MySqlParser.KW_CIPHER: + case MySqlParser.KW_CLASS_ORIGIN: + case MySqlParser.KW_CLIENT: + case MySqlParser.KW_CLOSE: + case MySqlParser.KW_COALESCE: + case MySqlParser.KW_CODE: + case MySqlParser.KW_COLUMNS: + case MySqlParser.KW_COLUMN_FORMAT: + case MySqlParser.KW_COLUMN_NAME: + case MySqlParser.KW_COMMENT: + case MySqlParser.KW_COMMIT: + case MySqlParser.KW_COMPACT: + case MySqlParser.KW_COMPLETION: + case MySqlParser.KW_COMPRESSED: + case MySqlParser.KW_COMPRESSION: + case MySqlParser.KW_CONCURRENT: + case MySqlParser.KW_CONNECT: + case MySqlParser.KW_CONNECTION: + case MySqlParser.KW_CONSISTENT: + case MySqlParser.KW_CONSTRAINT_CATALOG: + case MySqlParser.KW_CONSTRAINT_SCHEMA: + case MySqlParser.KW_CONSTRAINT_NAME: + case MySqlParser.KW_CONTAINS: + case MySqlParser.KW_CONTEXT: + case MySqlParser.KW_CONTRIBUTORS: + case MySqlParser.KW_COPY: + case MySqlParser.KW_CPU: + case MySqlParser.KW_CURSOR_NAME: + case MySqlParser.KW_DATA: + case MySqlParser.KW_DATAFILE: + case MySqlParser.KW_DEALLOCATE: + case MySqlParser.KW_DEFAULT_AUTH: + case MySqlParser.KW_DEFINER: + case MySqlParser.KW_DELAY_KEY_WRITE: + case MySqlParser.KW_DES_KEY_FILE: + case MySqlParser.KW_DIRECTORY: + case MySqlParser.KW_DISABLE: + case MySqlParser.KW_DISCARD: + case MySqlParser.KW_DISK: + case MySqlParser.KW_DO: + case MySqlParser.KW_DUMPFILE: + case MySqlParser.KW_DUPLICATE: + case MySqlParser.KW_DYNAMIC: + case MySqlParser.KW_ENABLE: + case MySqlParser.KW_ENCRYPTION: + case MySqlParser.KW_END: + case MySqlParser.KW_ENDS: + case MySqlParser.KW_ENGINE: + case MySqlParser.KW_ENGINES: + case MySqlParser.KW_ERROR: + case MySqlParser.KW_ERRORS: + case MySqlParser.KW_ESCAPE: + case MySqlParser.KW_EVENT: + case MySqlParser.KW_EVENTS: + case MySqlParser.KW_EVERY: + case MySqlParser.KW_EXCHANGE: + case MySqlParser.KW_EXCLUSIVE: + case MySqlParser.KW_EXPIRE: + case MySqlParser.KW_EXPORT: + case MySqlParser.KW_EXTENDED: + case MySqlParser.KW_EXTENT_SIZE: + case MySqlParser.KW_FAILED_LOGIN_ATTEMPTS: + case MySqlParser.KW_FAST: + case MySqlParser.KW_FAULTS: + case MySqlParser.KW_FIELDS: + case MySqlParser.KW_FILE_BLOCK_SIZE: + case MySqlParser.KW_FILTER: + case MySqlParser.KW_FIRST: + case MySqlParser.KW_FIXED: + case MySqlParser.KW_FLUSH: + case MySqlParser.KW_FOLLOWS: + case MySqlParser.KW_FOUND: + case MySqlParser.KW_FULL: + case MySqlParser.KW_FUNCTION: + case MySqlParser.KW_GENERAL: + case MySqlParser.KW_GLOBAL: + case MySqlParser.KW_GRANTS: + case MySqlParser.KW_GROUP_REPLICATION: + case MySqlParser.KW_HANDLER: + case MySqlParser.KW_HASH: + case MySqlParser.KW_HELP: + case MySqlParser.KW_HISTORY: + case MySqlParser.KW_HOST: + case MySqlParser.KW_HOSTS: + case MySqlParser.KW_IDENTIFIED: + case MySqlParser.KW_IGNORE_SERVER_IDS: + case MySqlParser.KW_IMPORT: + case MySqlParser.KW_INDEXES: + case MySqlParser.KW_INITIAL_SIZE: + case MySqlParser.KW_INPLACE: + case MySqlParser.KW_INSERT_METHOD: + case MySqlParser.KW_INSTALL: + case MySqlParser.KW_INSTANCE: + case MySqlParser.KW_INSTANT: + case MySqlParser.KW_INVISIBLE: + case MySqlParser.KW_INVOKER: + case MySqlParser.KW_IO: + case MySqlParser.KW_IO_THREAD: + case MySqlParser.KW_IPC: + case MySqlParser.KW_ISOLATION: + case MySqlParser.KW_ISSUER: + case MySqlParser.KW_JSON: + case MySqlParser.KW_KEY_BLOCK_SIZE: + case MySqlParser.KW_LANGUAGE: + case MySqlParser.KW_LAST: + case MySqlParser.KW_LEAVES: + case MySqlParser.KW_LESS: + case MySqlParser.KW_LEVEL: + case MySqlParser.KW_LIST: + case MySqlParser.KW_LOCAL: + case MySqlParser.KW_LOGFILE: + case MySqlParser.KW_LOGS: + case MySqlParser.KW_MASTER: + case MySqlParser.KW_MASTER_AUTO_POSITION: + case MySqlParser.KW_MASTER_CONNECT_RETRY: + case MySqlParser.KW_MASTER_DELAY: + case MySqlParser.KW_MASTER_HEARTBEAT_PERIOD: + case MySqlParser.KW_MASTER_HOST: + case MySqlParser.KW_MASTER_LOG_FILE: + case MySqlParser.KW_MASTER_LOG_POS: + case MySqlParser.KW_MASTER_PASSWORD: + case MySqlParser.KW_MASTER_PORT: + case MySqlParser.KW_MASTER_RETRY_COUNT: + case MySqlParser.KW_MASTER_SSL: + case MySqlParser.KW_MASTER_SSL_CA: + case MySqlParser.KW_MASTER_SSL_CAPATH: + case MySqlParser.KW_MASTER_SSL_CERT: + case MySqlParser.KW_MASTER_SSL_CIPHER: + case MySqlParser.KW_MASTER_SSL_CRL: + case MySqlParser.KW_MASTER_SSL_CRLPATH: + case MySqlParser.KW_MASTER_SSL_KEY: + case MySqlParser.KW_MASTER_TLS_VERSION: + case MySqlParser.KW_MASTER_USER: + case MySqlParser.KW_MAX_CONNECTIONS_PER_HOUR: + case MySqlParser.KW_MAX_QUERIES_PER_HOUR: + case MySqlParser.KW_MAX_ROWS: + case MySqlParser.KW_MAX_SIZE: + case MySqlParser.KW_MAX_UPDATES_PER_HOUR: + case MySqlParser.KW_MAX_USER_CONNECTIONS: + case MySqlParser.KW_MEDIUM: + case MySqlParser.KW_MEMBER: + case MySqlParser.KW_MERGE: + case MySqlParser.KW_MESSAGE_TEXT: + case MySqlParser.KW_MID: + case MySqlParser.KW_MIGRATE: + case MySqlParser.KW_MIN_ROWS: + case MySqlParser.KW_MODE: + case MySqlParser.KW_MODIFY: + case MySqlParser.KW_MUTEX: + case MySqlParser.KW_MYSQL: + case MySqlParser.KW_MYSQL_ERRNO: + case MySqlParser.KW_NAME: + case MySqlParser.KW_NAMES: + case MySqlParser.KW_NCHAR: + case MySqlParser.KW_NEVER: + case MySqlParser.KW_NEXT: + case MySqlParser.KW_NO: + case MySqlParser.KW_NOWAIT: + case MySqlParser.KW_NODEGROUP: + case MySqlParser.KW_NONE: + case MySqlParser.KW_ODBC: + case MySqlParser.KW_OFFLINE: + case MySqlParser.KW_OFFSET: + case MySqlParser.KW_OF: + case MySqlParser.KW_OLD_PASSWORD: + case MySqlParser.KW_ONE: + case MySqlParser.KW_ONLINE: + case MySqlParser.KW_ONLY: + case MySqlParser.KW_OPEN: + case MySqlParser.KW_OPTIMIZER_COSTS: + case MySqlParser.KW_OPTIONS: + case MySqlParser.KW_OWNER: + case MySqlParser.KW_PACK_KEYS: + case MySqlParser.KW_PAGE: + case MySqlParser.KW_PAGE_CHECKSUM: + case MySqlParser.KW_PARSER: + case MySqlParser.KW_PARTIAL: + case MySqlParser.KW_PARTITIONING: + case MySqlParser.KW_PARTITIONS: + case MySqlParser.KW_PASSWORD: + case MySqlParser.KW_PASSWORD_LOCK_TIME: + case MySqlParser.KW_PHASE: + case MySqlParser.KW_PLUGIN: + case MySqlParser.KW_PLUGIN_DIR: + case MySqlParser.KW_PLUGINS: + case MySqlParser.KW_PORT: + case MySqlParser.KW_PRECEDES: + case MySqlParser.KW_PREPARE: + case MySqlParser.KW_PRESERVE: + case MySqlParser.KW_PREV: + case MySqlParser.KW_PROCESSLIST: + case MySqlParser.KW_PROFILE: + case MySqlParser.KW_PROFILES: + case MySqlParser.KW_PROXY: + case MySqlParser.KW_QUERY: + case MySqlParser.KW_QUICK: + case MySqlParser.KW_REBUILD: + case MySqlParser.KW_RECOVER: + case MySqlParser.KW_RECURSIVE: + case MySqlParser.KW_REDO_BUFFER_SIZE: + case MySqlParser.KW_REDUNDANT: + case MySqlParser.KW_RELAY: + case MySqlParser.KW_RELAY_LOG_FILE: + case MySqlParser.KW_RELAY_LOG_POS: + case MySqlParser.KW_RELAYLOG: + case MySqlParser.KW_REMOVE: + case MySqlParser.KW_REORGANIZE: + case MySqlParser.KW_REPAIR: + case MySqlParser.KW_REPLICATE_DO_DB: + case MySqlParser.KW_REPLICATE_DO_TABLE: + case MySqlParser.KW_REPLICATE_IGNORE_DB: + case MySqlParser.KW_REPLICATE_IGNORE_TABLE: + case MySqlParser.KW_REPLICATE_REWRITE_DB: + case MySqlParser.KW_REPLICATE_WILD_DO_TABLE: + case MySqlParser.KW_REPLICATE_WILD_IGNORE_TABLE: + case MySqlParser.KW_REPLICATION: + case MySqlParser.KW_RESET: + case MySqlParser.KW_RESUME: + case MySqlParser.KW_RETURNED_SQLSTATE: + case MySqlParser.KW_RETURNS: + case MySqlParser.KW_REUSE: + case MySqlParser.KW_ROLE: + case MySqlParser.KW_ROLLBACK: + case MySqlParser.KW_ROLLUP: + case MySqlParser.KW_ROTATE: + case MySqlParser.KW_ROW: + case MySqlParser.KW_ROWS: + case MySqlParser.KW_ROW_FORMAT: + case MySqlParser.KW_SAVEPOINT: + case MySqlParser.KW_SCHEDULE: + case MySqlParser.KW_SECURITY: + case MySqlParser.KW_SERVER: + case MySqlParser.KW_SESSION: + case MySqlParser.KW_SHARE: + case MySqlParser.KW_SHARED: + case MySqlParser.KW_SIGNED: + case MySqlParser.KW_SIMPLE: + case MySqlParser.KW_SLAVE: + case MySqlParser.KW_SLOW: + case MySqlParser.KW_SNAPSHOT: + case MySqlParser.KW_SOCKET: + case MySqlParser.KW_SOME: + case MySqlParser.KW_SONAME: + case MySqlParser.KW_SOUNDS: + case MySqlParser.KW_SOURCE: + case MySqlParser.KW_SQL_AFTER_GTIDS: + case MySqlParser.KW_SQL_AFTER_MTS_GAPS: + case MySqlParser.KW_SQL_BEFORE_GTIDS: + case MySqlParser.KW_SQL_BUFFER_RESULT: + case MySqlParser.KW_SQL_CACHE: + case MySqlParser.KW_SQL_NO_CACHE: + case MySqlParser.KW_SQL_THREAD: + case MySqlParser.KW_START: + case MySqlParser.KW_STARTS: + case MySqlParser.KW_STATS_AUTO_RECALC: + case MySqlParser.KW_STATS_PERSISTENT: + case MySqlParser.KW_STATS_SAMPLE_PAGES: + case MySqlParser.KW_STATUS: + case MySqlParser.KW_STOP: + case MySqlParser.KW_STORAGE: + case MySqlParser.KW_STRING: + case MySqlParser.KW_SUBCLASS_ORIGIN: + case MySqlParser.KW_SUBJECT: + case MySqlParser.KW_SUBPARTITION: + case MySqlParser.KW_SUBPARTITIONS: + case MySqlParser.KW_SUSPEND: + case MySqlParser.KW_SWAPS: + case MySqlParser.KW_SWITCHES: + case MySqlParser.KW_TABLE_NAME: + case MySqlParser.KW_TABLESPACE: + case MySqlParser.KW_TABLE_TYPE: + case MySqlParser.KW_TEMPORARY: + case MySqlParser.KW_TEMPTABLE: + case MySqlParser.KW_THAN: + case MySqlParser.KW_TRADITIONAL: + case MySqlParser.KW_TRANSACTION: + case MySqlParser.KW_TRANSACTIONAL: + case MySqlParser.KW_TRIGGERS: + case MySqlParser.KW_TRUNCATE: + case MySqlParser.KW_UNBOUNDED: + case MySqlParser.KW_UNDEFINED: + case MySqlParser.KW_UNDOFILE: + case MySqlParser.KW_UNDO_BUFFER_SIZE: + case MySqlParser.KW_UNINSTALL: + case MySqlParser.KW_UNKNOWN: + case MySqlParser.KW_UNTIL: + case MySqlParser.KW_UPGRADE: + case MySqlParser.KW_USER: + case MySqlParser.KW_USE_FRM: + case MySqlParser.KW_USER_RESOURCES: + case MySqlParser.KW_VALIDATION: + case MySqlParser.KW_VALUE: + case MySqlParser.KW_VARIABLES: + case MySqlParser.KW_VIEW: + case MySqlParser.KW_VIRTUAL: + case MySqlParser.KW_VISIBLE: + case MySqlParser.KW_WAIT: + case MySqlParser.KW_WARNINGS: + case MySqlParser.KW_WITHOUT: + case MySqlParser.KW_WORK: + case MySqlParser.KW_WRAPPER: + case MySqlParser.KW_X509: + case MySqlParser.KW_XA: + case MySqlParser.KW_XML: + case MySqlParser.KW_QUARTER: + case MySqlParser.KW_MONTH: + case MySqlParser.KW_DAY: + case MySqlParser.KW_HOUR: + case MySqlParser.KW_MINUTE: + case MySqlParser.KW_WEEK: + case MySqlParser.KW_SECOND: + case MySqlParser.KW_MICROSECOND: + case MySqlParser.KW_ADMIN: + case MySqlParser.KW_AUDIT_ABORT_EXEMPT: + case MySqlParser.KW_AUDIT_ADMIN: + case MySqlParser.KW_AUTHENTICATION_POLICY_ADMIN: + case MySqlParser.KW_BACKUP_ADMIN: + case MySqlParser.KW_BINLOG_ADMIN: + case MySqlParser.KW_BINLOG_ENCRYPTION_ADMIN: + case MySqlParser.KW_CLONE_ADMIN: + case MySqlParser.KW_CONNECTION_ADMIN: + case MySqlParser.KW_ENCRYPTION_KEY_ADMIN: + case MySqlParser.KW_EXECUTE: + case MySqlParser.KW_FILE: + case MySqlParser.KW_FIREWALL_ADMIN: + case MySqlParser.KW_FIREWALL_EXEMPT: + case MySqlParser.KW_FIREWALL_USER: + case MySqlParser.KW_GROUP_REPLICATION_ADMIN: + case MySqlParser.KW_INNODB_REDO_LOG_ARCHIVE: + case MySqlParser.KW_INVOKE: + case MySqlParser.KW_LAMBDA: + case MySqlParser.KW_NDB_STORED_USER: + case MySqlParser.KW_PASSWORDLESS_USER_ADMIN: + case MySqlParser.KW_PERSIST_RO_VARIABLES_ADMIN: + case MySqlParser.KW_PRIVILEGES: + case MySqlParser.KW_PROCESS: + case MySqlParser.KW_RELOAD: + case MySqlParser.KW_REPLICATION_APPLIER: + case MySqlParser.KW_REPLICATION_SLAVE_ADMIN: + case MySqlParser.KW_RESOURCE_GROUP_ADMIN: + case MySqlParser.KW_RESOURCE_GROUP_USER: + case MySqlParser.KW_ROLE_ADMIN: + case MySqlParser.KW_ROUTINE: + case MySqlParser.KW_S3: + case MySqlParser.KW_SESSION_VARIABLES_ADMIN: + case MySqlParser.KW_SET_USER_ID: + case MySqlParser.KW_SHOW_ROUTINE: + case MySqlParser.KW_SHUTDOWN: + case MySqlParser.KW_SUPER: + case MySqlParser.KW_SYSTEM_VARIABLES_ADMIN: + case MySqlParser.KW_TABLES: + case MySqlParser.KW_TABLE_ENCRYPTION_ADMIN: + case MySqlParser.KW_VERSION_TOKEN_ADMIN: + case MySqlParser.KW_XA_RECOVER_ADMIN: + case MySqlParser.KW_ARMSCII8: + case MySqlParser.KW_ASCII: + case MySqlParser.KW_BIG5: + case MySqlParser.KW_CP1250: + case MySqlParser.KW_CP1251: + case MySqlParser.KW_CP1256: + case MySqlParser.KW_CP1257: + case MySqlParser.KW_CP850: + case MySqlParser.KW_CP852: + case MySqlParser.KW_CP866: + case MySqlParser.KW_CP932: + case MySqlParser.KW_DEC8: + case MySqlParser.KW_EUCJPMS: + case MySqlParser.KW_EUCKR: + case MySqlParser.KW_GB18030: + case MySqlParser.KW_GB2312: + case MySqlParser.KW_GBK: + case MySqlParser.KW_GEOSTD8: + case MySqlParser.KW_GREEK: + case MySqlParser.KW_HEBREW: + case MySqlParser.KW_HP8: + case MySqlParser.KW_KEYBCS2: + case MySqlParser.KW_KOI8R: + case MySqlParser.KW_KOI8U: + case MySqlParser.KW_LATIN1: + case MySqlParser.KW_LATIN2: + case MySqlParser.KW_LATIN5: + case MySqlParser.KW_LATIN7: + case MySqlParser.KW_MACCE: + case MySqlParser.KW_MACROMAN: + case MySqlParser.KW_SJIS: + case MySqlParser.KW_SWE7: + case MySqlParser.KW_TIS620: + case MySqlParser.KW_UCS2: + case MySqlParser.KW_UJIS: + case MySqlParser.KW_UTF16: + case MySqlParser.KW_UTF16LE: + case MySqlParser.KW_UTF32: + case MySqlParser.KW_UTF8: + case MySqlParser.KW_UTF8MB3: + case MySqlParser.KW_UTF8MB4: + case MySqlParser.KW_ARCHIVE: + case MySqlParser.KW_BLACKHOLE: + case MySqlParser.KW_CSV: + case MySqlParser.KW_FEDERATED: + case MySqlParser.KW_INNODB: + case MySqlParser.KW_MEMORY: + case MySqlParser.KW_MRG_MYISAM: + case MySqlParser.KW_MYISAM: + case MySqlParser.KW_NDB: + case MySqlParser.KW_NDBCLUSTER: + case MySqlParser.KW_PERFORMANCE_SCHEMA: + case MySqlParser.KW_TOKUDB: + case MySqlParser.KW_REPEATABLE: + case MySqlParser.KW_COMMITTED: + case MySqlParser.KW_UNCOMMITTED: + case MySqlParser.KW_SERIALIZABLE: + case MySqlParser.KW_GEOMETRYCOLLECTION: + case MySqlParser.KW_LINESTRING: + case MySqlParser.KW_MULTILINESTRING: + case MySqlParser.KW_MULTIPOINT: + case MySqlParser.KW_MULTIPOLYGON: + case MySqlParser.KW_POINT: + case MySqlParser.KW_POLYGON: + case MySqlParser.KW_CATALOG_NAME: + case MySqlParser.KW_CHARSET: + case MySqlParser.KW_COLLATION: + case MySqlParser.KW_ENGINE_ATTRIBUTE: + case MySqlParser.KW_FORMAT: + case MySqlParser.KW_GET_FORMAT: + case MySqlParser.KW_RANDOM: + case MySqlParser.KW_REVERSE: + case MySqlParser.KW_ROW_COUNT: + case MySqlParser.KW_SCHEMA_NAME: + case MySqlParser.KW_SECONDARY_ENGINE_ATTRIBUTE: + case MySqlParser.KW_SRID: + case MySqlParser.KW_SYSTEM_USER: + case MySqlParser.KW_TP_CONNECTION_ADMIN: + case MySqlParser.KW_WEIGHT_STRING: + case MySqlParser.MOD: + case MySqlParser.CHARSET_REVERSE_QOUTE_STRING: + case MySqlParser.STRING_LITERAL: + case MySqlParser.ID: + { + this.state = 2979; + this.partitionNames(); + } + break; + case MySqlParser.KW_ALL: + { + this.state = 2980; + this.match(MySqlParser.KW_ALL); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + break; + case MySqlParser.KW_REMOVE: + localContext = new AlterByRemovePartitioningContext(localContext); + this.enterOuterAlt(localContext, 14); + { + this.state = 2983; + this.match(MySqlParser.KW_REMOVE); + this.state = 2984; + this.match(MySqlParser.KW_PARTITIONING); + } + break; + case MySqlParser.KW_UPGRADE: + localContext = new AlterByUpgradePartitioningContext(localContext); + this.enterOuterAlt(localContext, 15); + { + this.state = 2985; + this.match(MySqlParser.KW_UPGRADE); + this.state = 2986; + this.match(MySqlParser.KW_PARTITIONING); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + dropDatabase() { + let localContext = new DropDatabaseContext(this.context, this.state); + this.enterRule(localContext, 144, MySqlParser.RULE_dropDatabase); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 2989; + this.match(MySqlParser.KW_DROP); + this.state = 2990; + localContext._dbFormat = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 39 || _la === 152)) { + localContext._dbFormat = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 2992; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 361, this.context)) { + case 1: + { + this.state = 2991; + this.ifExists(); + } + break; + } + this.state = 2994; + this.databaseName(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + dropEvent() { + let localContext = new DropEventContext(this.context, this.state); + this.enterRule(localContext, 146, MySqlParser.RULE_dropEvent); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 2996; + this.match(MySqlParser.KW_DROP); + this.state = 2997; + this.match(MySqlParser.KW_EVENT); + this.state = 2999; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 362, this.context)) { + case 1: + { + this.state = 2998; + this.ifExists(); + } + break; + } + this.state = 3001; + localContext._event_name = this.fullId(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + dropIndex() { + let localContext = new DropIndexContext(this.context, this.state); + this.enterRule(localContext, 148, MySqlParser.RULE_dropIndex); + let _la; + try { + let alternative; + this.enterOuterAlt(localContext, 1); + { + this.state = 3003; + this.match(MySqlParser.KW_DROP); + this.state = 3004; + this.match(MySqlParser.KW_INDEX); + this.state = 3006; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 363, this.context)) { + case 1: + { + this.state = 3005; + localContext._intimeAction = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 508 || _la === 514)) { + localContext._intimeAction = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + break; + } + this.state = 3008; + this.indexName(); + this.state = 3009; + this.match(MySqlParser.KW_ON); + this.state = 3010; + this.tableName(); + this.state = 3023; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 367, this.context); + while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER) { + if (alternative === 1) { + { + this.state = 3021; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_ALGORITHM: + { + this.state = 3011; + this.match(MySqlParser.KW_ALGORITHM); + this.state = 3013; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 3012; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 3015; + localContext._algType = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 42 || _la === 357 || _la === 430)) { + localContext._algType = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + break; + case MySqlParser.KW_LOCK: + { + this.state = 3016; + this.match(MySqlParser.KW_LOCK); + this.state = 3018; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 3017; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 3020; + localContext._lockType = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 42 || _la === 389 || _la === 505 || _la === 595)) { + localContext._lockType = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + } + this.state = 3025; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 367, this.context); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + dropLogfileGroup() { + let localContext = new DropLogfileGroupContext(this.context, this.state); + this.enterRule(localContext, 150, MySqlParser.RULE_dropLogfileGroup); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 3026; + this.match(MySqlParser.KW_DROP); + this.state = 3027; + this.match(MySqlParser.KW_LOGFILE); + this.state = 3028; + this.match(MySqlParser.KW_GROUP); + this.state = 3029; + localContext._logfileGroupName = this.uid(); + this.state = 3030; + this.match(MySqlParser.KW_ENGINE); + this.state = 3032; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 3031; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 3034; + this.engineName(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + dropProcedure() { + let localContext = new DropProcedureContext(this.context, this.state); + this.enterRule(localContext, 152, MySqlParser.RULE_dropProcedure); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 3036; + this.match(MySqlParser.KW_DROP); + this.state = 3037; + this.match(MySqlParser.KW_PROCEDURE); + this.state = 3039; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 369, this.context)) { + case 1: + { + this.state = 3038; + this.ifExists(); + } + break; + } + this.state = 3041; + localContext._sp_name = this.fullId(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + dropFunction() { + let localContext = new DropFunctionContext(this.context, this.state); + this.enterRule(localContext, 154, MySqlParser.RULE_dropFunction); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 3043; + this.match(MySqlParser.KW_DROP); + this.state = 3044; + this.match(MySqlParser.KW_FUNCTION); + this.state = 3046; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 370, this.context)) { + case 1: + { + this.state = 3045; + this.ifExists(); + } + break; + } + this.state = 3048; + this.functionName(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + dropServer() { + let localContext = new DropServerContext(this.context, this.state); + this.enterRule(localContext, 156, MySqlParser.RULE_dropServer); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 3050; + this.match(MySqlParser.KW_DROP); + this.state = 3051; + this.match(MySqlParser.KW_SERVER); + this.state = 3053; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 371, this.context)) { + case 1: + { + this.state = 3052; + this.ifExists(); + } + break; + } + this.state = 3055; + localContext._serverName = this.uid(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + dropSpatial() { + let localContext = new DropSpatialContext(this.context, this.state); + this.enterRule(localContext, 158, MySqlParser.RULE_dropSpatial); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 3057; + this.match(MySqlParser.KW_DROP); + this.state = 3058; + this.match(MySqlParser.KW_SPATIAL); + this.state = 3059; + this.match(MySqlParser.KW_REFERENCE); + this.state = 3060; + this.match(MySqlParser.KW_SYSTEM); + this.state = 3062; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 78) { + { + this.state = 3061; + this.ifExists(); + } + } + this.state = 3064; + this.match(MySqlParser.DECIMAL_LITERAL); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + dropTable() { + let localContext = new DropTableContext(this.context, this.state); + this.enterRule(localContext, 160, MySqlParser.RULE_dropTable); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 3066; + this.match(MySqlParser.KW_DROP); + this.state = 3068; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 660) { + { + this.state = 3067; + this.match(MySqlParser.KW_TEMPORARY); + } + } + this.state = 3070; + this.match(MySqlParser.KW_TABLE); + this.state = 3072; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 374, this.context)) { + case 1: + { + this.state = 3071; + this.ifExists(); + } + break; + } + this.state = 3074; + this.tableNames(); + this.state = 3076; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 22 || _la === 146) { + { + this.state = 3075; + localContext._dropType = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 22 || _la === 146)) { + localContext._dropType = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + dropTablespace() { + let localContext = new DropTablespaceContext(this.context, this.state); + this.enterRule(localContext, 162, MySqlParser.RULE_dropTablespace); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 3078; + this.match(MySqlParser.KW_DROP); + this.state = 3080; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 180) { + { + this.state = 3079; + this.match(MySqlParser.KW_UNDO); + } + } + this.state = 3082; + this.match(MySqlParser.KW_TABLESPACE); + this.state = 3083; + this.tablespaceName(); + this.state = 3089; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 380) { + { + this.state = 3084; + this.match(MySqlParser.KW_ENGINE); + this.state = 3086; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 3085; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 3088; + this.engineName(); + } + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + dropTrigger() { + let localContext = new DropTriggerContext(this.context, this.state); + this.enterRule(localContext, 164, MySqlParser.RULE_dropTrigger); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 3091; + this.match(MySqlParser.KW_DROP); + this.state = 3092; + this.match(MySqlParser.KW_TRIGGER); + this.state = 3094; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 379, this.context)) { + case 1: + { + this.state = 3093; + this.ifExists(); + } + break; + } + this.state = 3096; + localContext._trigger_name = this.fullId(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + dropView() { + let localContext = new DropViewContext(this.context, this.state); + this.enterRule(localContext, 166, MySqlParser.RULE_dropView); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 3098; + this.match(MySqlParser.KW_DROP); + this.state = 3099; + this.match(MySqlParser.KW_VIEW); + this.state = 3101; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 380, this.context)) { + case 1: + { + this.state = 3100; + this.ifExists(); + } + break; + } + this.state = 3103; + this.viewName(); + this.state = 3108; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 3104; + this.match(MySqlParser.COMMA); + this.state = 3105; + this.viewName(); + } + } + this.state = 3110; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 3112; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 22 || _la === 146) { + { + this.state = 3111; + localContext._dropType = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 22 || _la === 146)) { + localContext._dropType = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + dropRole() { + let localContext = new DropRoleContext(this.context, this.state); + this.enterRule(localContext, 168, MySqlParser.RULE_dropRole); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 3114; + this.match(MySqlParser.KW_DROP); + this.state = 3115; + this.match(MySqlParser.KW_ROLE); + this.state = 3117; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 383, this.context)) { + case 1: + { + this.state = 3116; + this.ifExists(); + } + break; + } + this.state = 3119; + this.userOrRoleNames(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + setRole() { + let localContext = new SetRoleContext(this.context, this.state); + this.enterRule(localContext, 170, MySqlParser.RULE_setRole); + let _la; + try { + this.state = 3141; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 386, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 3121; + this.match(MySqlParser.KW_SET); + this.state = 3122; + this.match(MySqlParser.KW_DEFAULT); + this.state = 3123; + this.match(MySqlParser.KW_ROLE); + this.state = 3127; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 384, this.context)) { + case 1: + { + this.state = 3124; + this.match(MySqlParser.KW_NONE); + } + break; + case 2: + { + this.state = 3125; + this.match(MySqlParser.KW_ALL); + } + break; + case 3: + { + this.state = 3126; + this.userOrRoleNames(); + } + break; + } + this.state = 3129; + this.match(MySqlParser.KW_TO); + { + this.state = 3130; + this.userOrRoleName(); + } + this.state = 3135; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 3131; + this.match(MySqlParser.COMMA); + { + this.state = 3132; + this.userOrRoleName(); + } + } + } + this.state = 3137; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 3138; + this.match(MySqlParser.KW_SET); + this.state = 3139; + this.match(MySqlParser.KW_ROLE); + this.state = 3140; + this.roleOption(); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + renameTable() { + let localContext = new RenameTableContext(this.context, this.state); + this.enterRule(localContext, 172, MySqlParser.RULE_renameTable); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 3143; + this.match(MySqlParser.KW_RENAME); + this.state = 3144; + this.match(MySqlParser.KW_TABLE); + this.state = 3145; + this.renameTableClause(); + this.state = 3150; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 3146; + this.match(MySqlParser.COMMA); + this.state = 3147; + this.renameTableClause(); + } + } + this.state = 3152; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + renameTableClause() { + let localContext = new RenameTableClauseContext(this.context, this.state); + this.enterRule(localContext, 174, MySqlParser.RULE_renameTableClause); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 3153; + this.tableName(); + this.state = 3154; + this.match(MySqlParser.KW_TO); + this.state = 3155; + this.tableNameCreate(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + truncateTable() { + let localContext = new TruncateTableContext(this.context, this.state); + this.enterRule(localContext, 176, MySqlParser.RULE_truncateTable); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 3157; + this.match(MySqlParser.KW_TRUNCATE); + this.state = 3159; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 173) { + { + this.state = 3158; + this.match(MySqlParser.KW_TABLE); + } + } + this.state = 3161; + this.tableName(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + callStatement() { + let localContext = new CallStatementContext(this.context, this.state); + this.enterRule(localContext, 178, MySqlParser.RULE_callStatement); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 3163; + this.match(MySqlParser.KW_CALL); + this.state = 3164; + localContext._sp_name = this.fullId(); + this.state = 3171; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 390, this.context)) { + case 1: + { + this.state = 3165; + this.match(MySqlParser.LR_BRACKET); + this.state = 3168; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 389, this.context)) { + case 1: + { + this.state = 3166; + this.constants(); + } + break; + case 2: + { + this.state = 3167; + this.expressions(); + } + break; + } + this.state = 3170; + this.match(MySqlParser.RR_BRACKET); + } + break; + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + deleteStatement() { + let localContext = new DeleteStatementContext(this.context, this.state); + this.enterRule(localContext, 180, MySqlParser.RULE_deleteStatement); + try { + this.state = 3175; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 391, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 3173; + this.singleDeleteStatement(); + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 3174; + this.multipleDeleteStatement(); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + doStatement() { + let localContext = new DoStatementContext(this.context, this.state); + this.enterRule(localContext, 182, MySqlParser.RULE_doStatement); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 3177; + this.match(MySqlParser.KW_DO); + this.state = 3178; + this.expressions(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + handlerStatement() { + let localContext = new HandlerStatementContext(this.context, this.state); + this.enterRule(localContext, 184, MySqlParser.RULE_handlerStatement); + try { + this.state = 3184; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 392, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 3180; + this.handlerOpenStatement(); + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 3181; + this.handlerReadIndexStatement(); + } + break; + case 3: + this.enterOuterAlt(localContext, 3); + { + this.state = 3182; + this.handlerReadStatement(); + } + break; + case 4: + this.enterOuterAlt(localContext, 4); + { + this.state = 3183; + this.handlerCloseStatement(); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + insertStatement() { + let localContext = new InsertStatementContext(this.context, this.state); + this.enterRule(localContext, 186, MySqlParser.RULE_insertStatement); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 3186; + this.match(MySqlParser.KW_INSERT); + this.state = 3188; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 43 || _la === 76 || _la === 107) { + { + this.state = 3187; + localContext._priority = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 43 || _la === 76 || _la === 107)) { + localContext._priority = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + this.state = 3191; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 79) { + { + this.state = 3190; + this.match(MySqlParser.KW_IGNORE); + } + } + this.state = 3194; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 88) { + { + this.state = 3193; + this.match(MySqlParser.KW_INTO); + } + } + this.state = 3196; + this.tableName(); + this.state = 3203; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 130) { + { + this.state = 3197; + this.match(MySqlParser.KW_PARTITION); + this.state = 3198; + this.match(MySqlParser.LR_BRACKET); + this.state = 3200; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if ((((_la) & ~0x1F) === 0 && ((1 << _la) & 1074302976) !== 0) || ((((_la - 36)) & ~0x1F) === 0 && ((1 << (_la - 36)) & 11014219) !== 0) || ((((_la - 74)) & ~0x1F) === 0 && ((1 << (_la - 74)) & 18878481) !== 0) || ((((_la - 117)) & ~0x1F) === 0 && ((1 << (_la - 117)) & 100679969) !== 0) || ((((_la - 150)) & ~0x1F) === 0 && ((1 << (_la - 150)) & 1049605) !== 0) || ((((_la - 219)) & ~0x1F) === 0 && ((1 << (_la - 219)) & 5374495) !== 0) || ((((_la - 253)) & ~0x1F) === 0 && ((1 << (_la - 253)) & 4294967295) !== 0) || ((((_la - 285)) & ~0x1F) === 0 && ((1 << (_la - 285)) & 4261412607) !== 0) || ((((_la - 317)) & ~0x1F) === 0 && ((1 << (_la - 317)) & 4160741375) !== 0) || ((((_la - 349)) & ~0x1F) === 0 && ((1 << (_la - 349)) & 4026531839) !== 0) || ((((_la - 381)) & ~0x1F) === 0 && ((1 << (_la - 381)) & 1055907839) !== 0) || ((((_la - 413)) & ~0x1F) === 0 && ((1 << (_la - 413)) & 4294885367) !== 0) || ((((_la - 445)) & ~0x1F) === 0 && ((1 << (_la - 445)) & 3757571071) !== 0) || ((((_la - 478)) & ~0x1F) === 0 && ((1 << (_la - 478)) & 3755999231) !== 0) || ((((_la - 510)) & ~0x1F) === 0 && ((1 << (_la - 510)) & 3751780349) !== 0) || ((((_la - 542)) & ~0x1F) === 0 && ((1 << (_la - 542)) & 2141183997) !== 0) || ((((_la - 575)) & ~0x1F) === 0 && ((1 << (_la - 575)) & 2147483629) !== 0) || ((((_la - 633)) & ~0x1F) === 0 && ((1 << (_la - 633)) & 4294934527) !== 0) || ((((_la - 665)) & ~0x1F) === 0 && ((1 << (_la - 665)) & 4278189053) !== 0) || ((((_la - 697)) & ~0x1F) === 0 && ((1 << (_la - 697)) & 1644099327) !== 0) || ((((_la - 729)) & ~0x1F) === 0 && ((1 << (_la - 729)) & 4294900735) !== 0) || ((((_la - 761)) & ~0x1F) === 0 && ((1 << (_la - 761)) & 4294967295) !== 0) || ((((_la - 793)) & ~0x1F) === 0 && ((1 << (_la - 793)) & 4288675839) !== 0) || ((((_la - 825)) & ~0x1F) === 0 && ((1 << (_la - 825)) & 2147527671) !== 0) || ((((_la - 879)) & ~0x1F) === 0 && ((1 << (_la - 879)) & 1033) !== 0)) { + { + this.state = 3199; + this.partitionNames(); + } + } + this.state = 3202; + this.match(MySqlParser.RR_BRACKET); + } + } + this.state = 3216; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 401, this.context)) { + case 1: + { + this.state = 3206; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 398, this.context)) { + case 1: + { + this.state = 3205; + this.fullColumnNames(); + } + break; + } + this.state = 3210; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 399, this.context)) { + case 1: + { + this.state = 3208; + this.valuesOrValueList(); + } + break; + case 2: + { + this.state = 3209; + this.selectOrTableOrValues(); + } + break; + } + this.state = 3213; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 400, this.context)) { + case 1: + { + this.state = 3212; + this.asRowAlias(); + } + break; + } + } + break; + case 2: + { + this.state = 3215; + this.setAssignmentList(); + } + break; + } + this.state = 3219; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 13) { + { + this.state = 3218; + this.asRowAlias(); + } + } + this.state = 3233; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 119) { + { + this.state = 3221; + this.match(MySqlParser.KW_ON); + this.state = 3222; + this.match(MySqlParser.KW_DUPLICATE); + this.state = 3223; + this.match(MySqlParser.KW_KEY); + this.state = 3224; + this.match(MySqlParser.KW_UPDATE); + this.state = 3225; + localContext._duplicatedFirst = this.updatedElement(); + this.state = 3230; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 3226; + this.match(MySqlParser.COMMA); + this.state = 3227; + localContext._updatedElement = this.updatedElement(); + localContext._duplicatedElements.push(localContext._updatedElement); + } + } + this.state = 3232; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + asRowAlias() { + let localContext = new AsRowAliasContext(this.context, this.state); + this.enterRule(localContext, 188, MySqlParser.RULE_asRowAlias); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 3235; + this.match(MySqlParser.KW_AS); + this.state = 3236; + localContext._rowAlias = this.uid(); + this.state = 3238; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 405, this.context)) { + case 1: + { + this.state = 3237; + this.fullColumnNames(); + } + break; + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + selectOrTableOrValues() { + let localContext = new SelectOrTableOrValuesContext(this.context, this.state); + this.enterRule(localContext, 190, MySqlParser.RULE_selectOrTableOrValues); + try { + this.state = 3244; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_SELECT: + case MySqlParser.LR_BRACKET: + this.enterOuterAlt(localContext, 1); + { + this.state = 3240; + this.selectStatement(); + } + break; + case MySqlParser.KW_TABLE: + this.enterOuterAlt(localContext, 2); + { + this.state = 3241; + this.match(MySqlParser.KW_TABLE); + this.state = 3242; + this.tableName(); + } + break; + case MySqlParser.KW_VALUES: + this.enterOuterAlt(localContext, 3); + { + this.state = 3243; + this.rowValuesList(); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + interSectStatement() { + let localContext = new InterSectStatementContext(this.context, this.state); + this.enterRule(localContext, 192, MySqlParser.RULE_interSectStatement); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 3246; + this.interSectQuery(); + this.state = 3252; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + do { + { + { + this.state = 3247; + this.match(MySqlParser.KW_INTERSECT); + this.state = 3249; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 7 || _la === 49) { + { + this.state = 3248; + _la = this.tokenStream.LA(1); + if (!(_la === 7 || _la === 49)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + this.state = 3251; + this.interSectQuery(); + } + } + this.state = 3254; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } while (_la === 828); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + interSectQuery() { + let localContext = new InterSectQueryContext(this.context, this.state); + this.enterRule(localContext, 194, MySqlParser.RULE_interSectQuery); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 3257; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 866) { + { + this.state = 3256; + this.match(MySqlParser.LR_BRACKET); + } + } + this.state = 3259; + this.querySpecification(); + this.state = 3261; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 410, this.context)) { + case 1: + { + this.state = 3260; + this.match(MySqlParser.RR_BRACKET); + } + break; + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + loadDataStatement() { + let localContext = new LoadDataStatementContext(this.context, this.state); + this.enterRule(localContext, 196, MySqlParser.RULE_loadDataStatement); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 3263; + this.match(MySqlParser.KW_LOAD); + this.state = 3264; + this.match(MySqlParser.KW_DATA); + this.state = 3266; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 107 || _la === 347) { + { + this.state = 3265; + localContext._priority = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 107 || _la === 347)) { + localContext._priority = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + this.state = 3269; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 450) { + { + this.state = 3268; + this.match(MySqlParser.KW_LOCAL); + } + } + this.state = 3271; + this.match(MySqlParser.KW_INFILE); + this.state = 3272; + localContext._filename = this.match(MySqlParser.STRING_LITERAL); + this.state = 3274; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 79 || _la === 143) { + { + this.state = 3273; + localContext._violation = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 79 || _la === 143)) { + localContext._violation = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + this.state = 3276; + this.match(MySqlParser.KW_INTO); + this.state = 3277; + this.match(MySqlParser.KW_TABLE); + this.state = 3278; + this.tableName(); + this.state = 3284; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 130) { + { + this.state = 3279; + this.match(MySqlParser.KW_PARTITION); + this.state = 3280; + this.match(MySqlParser.LR_BRACKET); + this.state = 3281; + this.partitionNames(); + this.state = 3282; + this.match(MySqlParser.RR_BRACKET); + } + } + this.state = 3289; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 26) { + { + this.state = 3286; + this.match(MySqlParser.KW_CHARACTER); + this.state = 3287; + this.match(MySqlParser.KW_SET); + this.state = 3288; + localContext._charset = this.charsetName(); + } + } + this.state = 3297; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 337 || _la === 398) { + { + this.state = 3291; + localContext._fieldsFormat = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 337 || _la === 398)) { + localContext._fieldsFormat = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 3293; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + do { + { + { + this.state = 3292; + this.selectFieldsInto(); + } + } + this.state = 3295; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } while (_la === 56 || _la === 58 || _la === 123 || _la === 174); + } + } + this.state = 3305; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 102) { + { + this.state = 3299; + this.match(MySqlParser.KW_LINES); + this.state = 3301; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + do { + { + { + this.state = 3300; + this.selectLinesInto(); + } + } + this.state = 3303; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } while (_la === 171 || _la === 174); + } + } + this.state = 3311; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 79) { + { + this.state = 3307; + this.match(MySqlParser.KW_IGNORE); + this.state = 3308; + this.decimalLiteral(); + this.state = 3309; + localContext._linesFormat = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 102 || _la === 587)) { + localContext._linesFormat = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + this.state = 3324; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 422, this.context)) { + case 1: + { + this.state = 3313; + this.match(MySqlParser.LR_BRACKET); + this.state = 3314; + this.assignmentField(); + this.state = 3319; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 3315; + this.match(MySqlParser.COMMA); + this.state = 3316; + this.assignmentField(); + } + } + this.state = 3321; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 3322; + this.match(MySqlParser.RR_BRACKET); + } + break; + } + this.state = 3335; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 424, this.context)) { + case 1: + { + this.state = 3326; + this.match(MySqlParser.KW_SET); + this.state = 3327; + this.updatedElement(); + this.state = 3332; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 3328; + this.match(MySqlParser.COMMA); + this.state = 3329; + this.updatedElement(); + } + } + this.state = 3334; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + break; + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + loadXmlStatement() { + let localContext = new LoadXmlStatementContext(this.context, this.state); + this.enterRule(localContext, 198, MySqlParser.RULE_loadXmlStatement); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 3337; + this.match(MySqlParser.KW_LOAD); + this.state = 3338; + this.match(MySqlParser.KW_XML); + this.state = 3340; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 107 || _la === 347) { + { + this.state = 3339; + localContext._priority = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 107 || _la === 347)) { + localContext._priority = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + this.state = 3343; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 450) { + { + this.state = 3342; + this.match(MySqlParser.KW_LOCAL); + } + } + this.state = 3345; + this.match(MySqlParser.KW_INFILE); + this.state = 3346; + localContext._filename = this.match(MySqlParser.STRING_LITERAL); + this.state = 3348; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 79 || _la === 143) { + { + this.state = 3347; + localContext._violation = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 79 || _la === 143)) { + localContext._violation = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + this.state = 3350; + this.match(MySqlParser.KW_INTO); + this.state = 3351; + this.match(MySqlParser.KW_TABLE); + this.state = 3352; + this.tableName(); + this.state = 3356; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 26) { + { + this.state = 3353; + this.match(MySqlParser.KW_CHARACTER); + this.state = 3354; + this.match(MySqlParser.KW_SET); + this.state = 3355; + localContext._charset = this.charsetName(); + } + } + this.state = 3368; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 587) { + { + this.state = 3358; + this.match(MySqlParser.KW_ROWS); + this.state = 3359; + this.match(MySqlParser.KW_IDENTIFIED); + this.state = 3360; + this.match(MySqlParser.KW_BY); + this.state = 3362; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 859) { + { + this.state = 3361; + this.match(MySqlParser.LESS_SYMBOL); + } + } + this.state = 3364; + localContext._tag = this.match(MySqlParser.STRING_LITERAL); + this.state = 3366; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 858) { + { + this.state = 3365; + this.match(MySqlParser.GREATER_SYMBOL); + } + } + } + } + this.state = 3374; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 79) { + { + this.state = 3370; + this.match(MySqlParser.KW_IGNORE); + this.state = 3371; + this.decimalLiteral(); + this.state = 3372; + localContext._linesFormat = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 102 || _la === 587)) { + localContext._linesFormat = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + this.state = 3387; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 434, this.context)) { + case 1: + { + this.state = 3376; + this.match(MySqlParser.LR_BRACKET); + this.state = 3377; + this.assignmentField(); + this.state = 3382; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 3378; + this.match(MySqlParser.COMMA); + this.state = 3379; + this.assignmentField(); + } + } + this.state = 3384; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 3385; + this.match(MySqlParser.RR_BRACKET); + } + break; + } + this.state = 3398; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 436, this.context)) { + case 1: + { + this.state = 3389; + this.match(MySqlParser.KW_SET); + this.state = 3390; + this.updatedElement(); + this.state = 3395; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 3391; + this.match(MySqlParser.COMMA); + this.state = 3392; + this.updatedElement(); + } + } + this.state = 3397; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + break; + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + parenthesizedQuery() { + let localContext = new ParenthesizedQueryContext(this.context, this.state); + this.enterRule(localContext, 200, MySqlParser.RULE_parenthesizedQuery); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 3400; + this.match(MySqlParser.LR_BRACKET); + this.state = 3401; + this.parenthesizedQueryExpression(); + this.state = 3403; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 125) { + { + this.state = 3402; + this.orderByClause(); + } + } + this.state = 3406; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 100) { + { + this.state = 3405; + this.limitClause(); + } + } + this.state = 3408; + this.match(MySqlParser.RR_BRACKET); + this.state = 3410; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 125) { + { + this.state = 3409; + this.orderByClause(); + } + } + this.state = 3413; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 100) { + { + this.state = 3412; + this.limitClause(); + } + } + this.state = 3416; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 88) { + { + this.state = 3415; + this.intoClause(); + } + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + replaceStatement() { + let localContext = new ReplaceStatementContext(this.context, this.state); + this.enterRule(localContext, 202, MySqlParser.RULE_replaceStatement); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 3418; + this.match(MySqlParser.KW_REPLACE); + this.state = 3420; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 43 || _la === 107) { + { + this.state = 3419; + localContext._priority = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 43 || _la === 107)) { + localContext._priority = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + this.state = 3423; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 88) { + { + this.state = 3422; + this.match(MySqlParser.KW_INTO); + } + } + this.state = 3425; + this.tableName(); + this.state = 3431; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 130) { + { + this.state = 3426; + this.match(MySqlParser.KW_PARTITION); + this.state = 3427; + this.match(MySqlParser.LR_BRACKET); + this.state = 3428; + this.partitionNames(); + this.state = 3429; + this.match(MySqlParser.RR_BRACKET); + } + } + this.state = 3441; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_SELECT: + case MySqlParser.KW_TABLE: + case MySqlParser.KW_VALUES: + case MySqlParser.KW_VALUE: + case MySqlParser.LR_BRACKET: + { + this.state = 3437; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 445, this.context)) { + case 1: + { + this.state = 3433; + this.match(MySqlParser.LR_BRACKET); + this.state = 3434; + this.columnNames(); + this.state = 3435; + this.match(MySqlParser.RR_BRACKET); + } + break; + } + this.state = 3439; + this.replaceStatementValuesOrSelectOrTable(); + } + break; + case MySqlParser.KW_SET: + { + this.state = 3440; + this.setAssignmentList(); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + selectStatement() { + let localContext = new SelectStatementContext(this.context, this.state); + this.enterRule(localContext, 204, MySqlParser.RULE_selectStatement); + let _la; + try { + let alternative; + this.state = 3502; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_SELECT: + localContext = new UnionAndLateralSelectContext(localContext); + this.enterOuterAlt(localContext, 1); + { + this.state = 3443; + this.querySpecification(); + this.state = 3447; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 447, this.context); + while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER) { + if (alternative === 1) { + { + { + this.state = 3444; + this.unionStatement(); + } + } + } + this.state = 3449; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 447, this.context); + } + this.state = 3458; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 450, this.context)) { + case 1: + { + this.state = 3450; + this.match(MySqlParser.KW_UNION); + this.state = 3452; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 7 || _la === 49) { + { + this.state = 3451; + localContext._unionType = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 7 || _la === 49)) { + localContext._unionType = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + this.state = 3456; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_SELECT: + { + this.state = 3454; + this.querySpecification(); + } + break; + case MySqlParser.LR_BRACKET: + { + this.state = 3455; + this.queryExpression(); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + break; + } + this.state = 3464; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 451, this.context); + while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER) { + if (alternative === 1) { + { + { + this.state = 3460; + this.match(MySqlParser.COMMA); + this.state = 3461; + this.lateralStatement(); + } + } + } + this.state = 3466; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 451, this.context); + } + this.state = 3468; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 452, this.context)) { + case 1: + { + this.state = 3467; + this.orderByClause(); + } + break; + } + this.state = 3471; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 453, this.context)) { + case 1: + { + this.state = 3470; + this.limitClause(); + } + break; + } + this.state = 3474; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 454, this.context)) { + case 1: + { + this.state = 3473; + this.lockClause(); + } + break; + } + this.state = 3477; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 455, this.context)) { + case 1: + { + this.state = 3476; + this.intoClause(); + } + break; + } + } + break; + case MySqlParser.LR_BRACKET: + localContext = new SelectExpressionContext(localContext); + this.enterOuterAlt(localContext, 2); + { + this.state = 3479; + this.queryExpression(); + this.state = 3483; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 456, this.context); + while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER) { + if (alternative === 1) { + { + { + this.state = 3480; + this.unionStatement(); + } + } + } + this.state = 3485; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 456, this.context); + } + this.state = 3491; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 458, this.context)) { + case 1: + { + this.state = 3486; + this.match(MySqlParser.KW_UNION); + this.state = 3488; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 7 || _la === 49) { + { + this.state = 3487; + localContext._unionType = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 7 || _la === 49)) { + localContext._unionType = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + this.state = 3490; + this.queryExpression(); + } + break; + } + this.state = 3494; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 459, this.context)) { + case 1: + { + this.state = 3493; + this.orderByClause(); + } + break; + } + this.state = 3497; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 460, this.context)) { + case 1: + { + this.state = 3496; + this.limitClause(); + } + break; + } + this.state = 3500; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 461, this.context)) { + case 1: + { + this.state = 3499; + this.lockClause(); + } + break; + } + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + setOperations() { + let localContext = new SetOperationsContext(this.context, this.state); + this.enterRule(localContext, 206, MySqlParser.RULE_setOperations); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 3505; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 194) { + { + this.state = 3504; + this.withClause(); + } + } + this.state = 3507; + this.queryExpressionBody(0); + this.state = 3509; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 125) { + { + this.state = 3508; + this.orderByClause(); + } + } + this.state = 3512; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 100) { + { + this.state = 3511; + this.limitClause(); + } + } + this.state = 3515; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 88) { + { + this.state = 3514; + this.intoClause(); + } + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + queryExpressionBody(_p) { + if (_p === undefined) { + _p = 0; + } + let parentContext = this.context; + let parentState = this.state; + let localContext = new QueryExpressionBodyContext(this.context, parentState); + let previousContext = localContext; + let _startState = 208; + this.enterRecursionRule(localContext, 208, MySqlParser.RULE_queryExpressionBody, _p); + let _la; + try { + let alternative; + this.enterOuterAlt(localContext, 1); + { + { + this.state = 3518; + this.queryItem(0); + } + this.context.stop = this.tokenStream.LT(-1); + this.state = 3534; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 470, this.context); + while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER) { + if (alternative === 1) { + if (this._parseListeners != null) { + this.triggerExitRuleEvent(); + } + previousContext = localContext; + { + this.state = 3532; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 469, this.context)) { + case 1: + { + localContext = new QueryExpressionBodyContext(parentContext, parentState); + this.pushNewRecursionContext(localContext, _startState, MySqlParser.RULE_queryExpressionBody); + this.state = 3520; + if (!(this.precpred(this.context, 2))) { + throw this.createFailedPredicateException("this.precpred(this.context, 2)"); + } + this.state = 3521; + this.match(MySqlParser.KW_UNION); + this.state = 3523; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 7 || _la === 49) { + { + this.state = 3522; + _la = this.tokenStream.LA(1); + if (!(_la === 7 || _la === 49)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + this.state = 3525; + this.queryItem(0); + } + break; + case 2: + { + localContext = new QueryExpressionBodyContext(parentContext, parentState); + this.pushNewRecursionContext(localContext, _startState, MySqlParser.RULE_queryExpressionBody); + this.state = 3526; + if (!(this.precpred(this.context, 1))) { + throw this.createFailedPredicateException("this.precpred(this.context, 1)"); + } + this.state = 3527; + this.match(MySqlParser.KW_EXCEPT); + this.state = 3529; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 7 || _la === 49) { + { + this.state = 3528; + _la = this.tokenStream.LA(1); + if (!(_la === 7 || _la === 49)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + this.state = 3531; + this.queryItem(0); + } + break; + } + } + } + this.state = 3536; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 470, this.context); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.unrollRecursionContexts(parentContext); + } + return localContext; + } + queryItem(_p) { + if (_p === undefined) { + _p = 0; + } + let parentContext = this.context; + let parentState = this.state; + let localContext = new QueryItemContext(this.context, parentState); + let previousContext = localContext; + let _startState = 210; + this.enterRecursionRule(localContext, 210, MySqlParser.RULE_queryItem, _p); + let _la; + try { + let alternative; + this.enterOuterAlt(localContext, 1); + { + { + this.state = 3538; + this.queryPrimary(); + } + this.context.stop = this.tokenStream.LT(-1); + this.state = 3548; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 472, this.context); + while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER) { + if (alternative === 1) { + if (this._parseListeners != null) { + this.triggerExitRuleEvent(); + } + previousContext = localContext; + { + { + localContext = new QueryItemContext(parentContext, parentState); + this.pushNewRecursionContext(localContext, _startState, MySqlParser.RULE_queryItem); + this.state = 3540; + if (!(this.precpred(this.context, 1))) { + throw this.createFailedPredicateException("this.precpred(this.context, 1)"); + } + this.state = 3541; + this.match(MySqlParser.KW_INTERSECT); + this.state = 3543; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 7 || _la === 49) { + { + this.state = 3542; + _la = this.tokenStream.LA(1); + if (!(_la === 7 || _la === 49)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + this.state = 3545; + this.queryPrimary(); + } + } + } + this.state = 3550; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 472, this.context); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.unrollRecursionContexts(parentContext); + } + return localContext; + } + queryPrimary() { + let localContext = new QueryPrimaryContext(this.context, this.state); + this.enterRule(localContext, 212, MySqlParser.RULE_queryPrimary); + let _la; + try { + this.state = 3565; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 476, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 3551; + this.queryBlock(); + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 3552; + this.match(MySqlParser.LR_BRACKET); + this.state = 3553; + this.queryExpressionBody(0); + this.state = 3555; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 125) { + { + this.state = 3554; + this.orderByClause(); + } + } + this.state = 3558; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 100) { + { + this.state = 3557; + this.limitClause(); + } + } + this.state = 3561; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 88) { + { + this.state = 3560; + this.intoClause(); + } + } + this.state = 3563; + this.match(MySqlParser.RR_BRACKET); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + updateStatement() { + let localContext = new UpdateStatementContext(this.context, this.state); + this.enterRule(localContext, 214, MySqlParser.RULE_updateStatement); + try { + this.state = 3569; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 477, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 3567; + this.singleUpdateStatement(); + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 3568; + this.multipleUpdateStatement(); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + valuesStatement() { + let localContext = new ValuesStatementContext(this.context, this.state); + this.enterRule(localContext, 216, MySqlParser.RULE_valuesStatement); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 3571; + this.rowValuesList(); + this.state = 3575; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 478, this.context)) { + case 1: + { + this.state = 3572; + this.match(MySqlParser.KW_ORDER); + this.state = 3573; + this.match(MySqlParser.KW_BY); + this.state = 3574; + this.indexColumnName(); + } + break; + } + this.state = 3579; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 479, this.context)) { + case 1: + { + this.state = 3577; + this.match(MySqlParser.KW_LIMIT); + this.state = 3578; + this.limitClauseAtom(); + } + break; + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + parenthesizedQueryExpression() { + let localContext = new ParenthesizedQueryExpressionContext(this.context, this.state); + this.enterRule(localContext, 218, MySqlParser.RULE_parenthesizedQueryExpression); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 3581; + this.queryBlock(); + this.state = 3586; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 59 || _la === 181 || _la === 828) { + { + { + this.state = 3582; + _la = this.tokenStream.LA(1); + if (!(_la === 59 || _la === 181 || _la === 828)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 3583; + this.queryBlock(); + } + } + this.state = 3588; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 3590; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 481, this.context)) { + case 1: + { + this.state = 3589; + this.orderByClause(); + } + break; + } + this.state = 3593; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 482, this.context)) { + case 1: + { + this.state = 3592; + this.limitClause(); + } + break; + } + this.state = 3596; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 88) { + { + this.state = 3595; + this.intoClause(); + } + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + queryBlock() { + let localContext = new QueryBlockContext(this.context, this.state); + this.enterRule(localContext, 220, MySqlParser.RULE_queryBlock); + try { + this.state = 3601; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_SELECT: + case MySqlParser.LR_BRACKET: + this.enterOuterAlt(localContext, 1); + { + this.state = 3598; + this.selectStatement(); + } + break; + case MySqlParser.KW_TABLE: + this.enterOuterAlt(localContext, 2); + { + this.state = 3599; + this.tableStatement(); + } + break; + case MySqlParser.KW_VALUES: + this.enterOuterAlt(localContext, 3); + { + this.state = 3600; + this.valuesStatement(); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + replaceStatementValuesOrSelectOrTable() { + let localContext = new ReplaceStatementValuesOrSelectOrTableContext(this.context, this.state); + this.enterRule(localContext, 222, MySqlParser.RULE_replaceStatementValuesOrSelectOrTable); + try { + this.state = 3608; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 485, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 3603; + this.selectStatement(); + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 3604; + this.match(MySqlParser.KW_TABLE); + this.state = 3605; + this.tableName(); + } + break; + case 3: + this.enterOuterAlt(localContext, 3); + { + this.state = 3606; + this.valuesOrValueList(); + } + break; + case 4: + this.enterOuterAlt(localContext, 4); + { + this.state = 3607; + this.rowValuesList(); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + rowValuesList() { + let localContext = new RowValuesListContext(this.context, this.state); + this.enterRule(localContext, 224, MySqlParser.RULE_rowValuesList); + try { + let alternative; + this.enterOuterAlt(localContext, 1); + { + this.state = 3610; + this.match(MySqlParser.KW_VALUES); + this.state = 3611; + this.match(MySqlParser.KW_ROW); + this.state = 3612; + this.expressionsWithDefaults(); + this.state = 3618; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 486, this.context); + while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER) { + if (alternative === 1) { + { + { + this.state = 3613; + this.match(MySqlParser.COMMA); + this.state = 3614; + this.match(MySqlParser.KW_ROW); + this.state = 3615; + this.expressionsWithDefaults(); + } + } + } + this.state = 3620; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 486, this.context); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + setAssignmentList() { + let localContext = new SetAssignmentListContext(this.context, this.state); + this.enterRule(localContext, 226, MySqlParser.RULE_setAssignmentList); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 3621; + this.match(MySqlParser.KW_SET); + this.state = 3622; + localContext._setFirst = this.updatedElement(); + this.state = 3627; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 3623; + this.match(MySqlParser.COMMA); + this.state = 3624; + localContext._updatedElement = this.updatedElement(); + localContext._setElements.push(localContext._updatedElement); + } + } + this.state = 3629; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + updatedElement() { + let localContext = new UpdatedElementContext(this.context, this.state); + this.enterRule(localContext, 228, MySqlParser.RULE_updatedElement); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 3630; + this.columnName(); + this.state = 3631; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 3632; + this.expressionOrDefault(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + assignmentField() { + let localContext = new AssignmentFieldContext(this.context, this.state); + this.enterRule(localContext, 230, MySqlParser.RULE_assignmentField); + try { + this.state = 3636; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_ARRAY: + case MySqlParser.KW_ATTRIBUTE: + case MySqlParser.KW_BUCKETS: + case MySqlParser.KW_CONDITION: + case MySqlParser.KW_CURRENT: + case MySqlParser.KW_CURRENT_USER: + case MySqlParser.KW_DATABASE: + case MySqlParser.KW_DEFAULT: + case MySqlParser.KW_DIAGNOSTICS: + case MySqlParser.KW_EMPTY: + case MySqlParser.KW_ENFORCED: + case MySqlParser.KW_EXCEPT: + case MySqlParser.KW_GROUP: + case MySqlParser.KW_IF: + case MySqlParser.KW_INSERT: + case MySqlParser.KW_LATERAL: + case MySqlParser.KW_LEFT: + case MySqlParser.KW_NUMBER: + case MySqlParser.KW_OPTIONAL: + case MySqlParser.KW_ORDER: + case MySqlParser.KW_PRIMARY: + case MySqlParser.KW_REPEAT: + case MySqlParser.KW_REPLACE: + case MySqlParser.KW_RIGHT: + case MySqlParser.KW_SCHEMA: + case MySqlParser.KW_SKIP_QUERY_REWRITE: + case MySqlParser.KW_STACKED: + case MySqlParser.KW_DATE: + case MySqlParser.KW_TIME: + case MySqlParser.KW_TIMESTAMP: + case MySqlParser.KW_DATETIME: + case MySqlParser.KW_YEAR: + case MySqlParser.KW_BINARY: + case MySqlParser.KW_TEXT: + case MySqlParser.KW_ENUM: + case MySqlParser.KW_SERIAL: + case MySqlParser.KW_JSON_TABLE: + case MySqlParser.KW_JSON_VALUE: + case MySqlParser.KW_NESTED: + case MySqlParser.KW_ORDINALITY: + case MySqlParser.KW_PATH: + case MySqlParser.KW_AVG: + case MySqlParser.KW_BIT_AND: + case MySqlParser.KW_BIT_OR: + case MySqlParser.KW_BIT_XOR: + case MySqlParser.KW_COUNT: + case MySqlParser.KW_CUME_DIST: + case MySqlParser.KW_DENSE_RANK: + case MySqlParser.KW_FIRST_VALUE: + case MySqlParser.KW_GROUP_CONCAT: + case MySqlParser.KW_LAG: + case MySqlParser.KW_LAST_VALUE: + case MySqlParser.KW_LEAD: + case MySqlParser.KW_MAX: + case MySqlParser.KW_MIN: + case MySqlParser.KW_NTILE: + case MySqlParser.KW_NTH_VALUE: + case MySqlParser.KW_PERCENT_RANK: + case MySqlParser.KW_RANK: + case MySqlParser.KW_ROW_NUMBER: + case MySqlParser.KW_STD: + case MySqlParser.KW_STDDEV: + case MySqlParser.KW_STDDEV_POP: + case MySqlParser.KW_STDDEV_SAMP: + case MySqlParser.KW_SUM: + case MySqlParser.KW_VAR_POP: + case MySqlParser.KW_VAR_SAMP: + case MySqlParser.KW_VARIANCE: + case MySqlParser.KW_CURRENT_DATE: + case MySqlParser.KW_CURRENT_TIME: + case MySqlParser.KW_CURRENT_TIMESTAMP: + case MySqlParser.KW_LOCALTIME: + case MySqlParser.KW_CURDATE: + case MySqlParser.KW_CURTIME: + case MySqlParser.KW_DATE_ADD: + case MySqlParser.KW_DATE_SUB: + case MySqlParser.KW_LOCALTIMESTAMP: + case MySqlParser.KW_NOW: + case MySqlParser.KW_POSITION: + case MySqlParser.KW_SUBSTR: + case MySqlParser.KW_SUBSTRING: + case MySqlParser.KW_SYSDATE: + case MySqlParser.KW_TRIM: + case MySqlParser.KW_UTC_DATE: + case MySqlParser.KW_UTC_TIME: + case MySqlParser.KW_UTC_TIMESTAMP: + case MySqlParser.KW_ACCOUNT: + case MySqlParser.KW_ACTION: + case MySqlParser.KW_AFTER: + case MySqlParser.KW_AGGREGATE: + case MySqlParser.KW_ALGORITHM: + case MySqlParser.KW_ANY: + case MySqlParser.KW_AT: + case MySqlParser.KW_AUTHORS: + case MySqlParser.KW_AUTOCOMMIT: + case MySqlParser.KW_AUTOEXTEND_SIZE: + case MySqlParser.KW_AUTO_INCREMENT: + case MySqlParser.KW_AVG_ROW_LENGTH: + case MySqlParser.KW_BEGIN: + case MySqlParser.KW_BINLOG: + case MySqlParser.KW_BIT: + case MySqlParser.KW_BLOCK: + case MySqlParser.KW_BOOL: + case MySqlParser.KW_BOOLEAN: + case MySqlParser.KW_BTREE: + case MySqlParser.KW_CACHE: + case MySqlParser.KW_CASCADED: + case MySqlParser.KW_CHAIN: + case MySqlParser.KW_CHANGED: + case MySqlParser.KW_CHANNEL: + case MySqlParser.KW_CHECKSUM: + case MySqlParser.KW_CIPHER: + case MySqlParser.KW_CLASS_ORIGIN: + case MySqlParser.KW_CLIENT: + case MySqlParser.KW_CLOSE: + case MySqlParser.KW_COALESCE: + case MySqlParser.KW_CODE: + case MySqlParser.KW_COLUMNS: + case MySqlParser.KW_COLUMN_FORMAT: + case MySqlParser.KW_COLUMN_NAME: + case MySqlParser.KW_COMMENT: + case MySqlParser.KW_COMMIT: + case MySqlParser.KW_COMPACT: + case MySqlParser.KW_COMPLETION: + case MySqlParser.KW_COMPRESSED: + case MySqlParser.KW_COMPRESSION: + case MySqlParser.KW_CONCURRENT: + case MySqlParser.KW_CONNECT: + case MySqlParser.KW_CONNECTION: + case MySqlParser.KW_CONSISTENT: + case MySqlParser.KW_CONSTRAINT_CATALOG: + case MySqlParser.KW_CONSTRAINT_SCHEMA: + case MySqlParser.KW_CONSTRAINT_NAME: + case MySqlParser.KW_CONTAINS: + case MySqlParser.KW_CONTEXT: + case MySqlParser.KW_CONTRIBUTORS: + case MySqlParser.KW_COPY: + case MySqlParser.KW_CPU: + case MySqlParser.KW_CURSOR_NAME: + case MySqlParser.KW_DATA: + case MySqlParser.KW_DATAFILE: + case MySqlParser.KW_DEALLOCATE: + case MySqlParser.KW_DEFAULT_AUTH: + case MySqlParser.KW_DEFINER: + case MySqlParser.KW_DELAY_KEY_WRITE: + case MySqlParser.KW_DES_KEY_FILE: + case MySqlParser.KW_DIRECTORY: + case MySqlParser.KW_DISABLE: + case MySqlParser.KW_DISCARD: + case MySqlParser.KW_DISK: + case MySqlParser.KW_DO: + case MySqlParser.KW_DUMPFILE: + case MySqlParser.KW_DUPLICATE: + case MySqlParser.KW_DYNAMIC: + case MySqlParser.KW_ENABLE: + case MySqlParser.KW_ENCRYPTION: + case MySqlParser.KW_END: + case MySqlParser.KW_ENDS: + case MySqlParser.KW_ENGINE: + case MySqlParser.KW_ENGINES: + case MySqlParser.KW_ERROR: + case MySqlParser.KW_ERRORS: + case MySqlParser.KW_ESCAPE: + case MySqlParser.KW_EVENT: + case MySqlParser.KW_EVENTS: + case MySqlParser.KW_EVERY: + case MySqlParser.KW_EXCHANGE: + case MySqlParser.KW_EXCLUSIVE: + case MySqlParser.KW_EXPIRE: + case MySqlParser.KW_EXPORT: + case MySqlParser.KW_EXTENDED: + case MySqlParser.KW_EXTENT_SIZE: + case MySqlParser.KW_FAILED_LOGIN_ATTEMPTS: + case MySqlParser.KW_FAST: + case MySqlParser.KW_FAULTS: + case MySqlParser.KW_FIELDS: + case MySqlParser.KW_FILE_BLOCK_SIZE: + case MySqlParser.KW_FILTER: + case MySqlParser.KW_FIRST: + case MySqlParser.KW_FIXED: + case MySqlParser.KW_FLUSH: + case MySqlParser.KW_FOLLOWS: + case MySqlParser.KW_FOUND: + case MySqlParser.KW_FULL: + case MySqlParser.KW_FUNCTION: + case MySqlParser.KW_GENERAL: + case MySqlParser.KW_GLOBAL: + case MySqlParser.KW_GRANTS: + case MySqlParser.KW_GROUP_REPLICATION: + case MySqlParser.KW_HANDLER: + case MySqlParser.KW_HASH: + case MySqlParser.KW_HELP: + case MySqlParser.KW_HISTORY: + case MySqlParser.KW_HOST: + case MySqlParser.KW_HOSTS: + case MySqlParser.KW_IDENTIFIED: + case MySqlParser.KW_IGNORE_SERVER_IDS: + case MySqlParser.KW_IMPORT: + case MySqlParser.KW_INDEXES: + case MySqlParser.KW_INITIAL_SIZE: + case MySqlParser.KW_INPLACE: + case MySqlParser.KW_INSERT_METHOD: + case MySqlParser.KW_INSTALL: + case MySqlParser.KW_INSTANCE: + case MySqlParser.KW_INSTANT: + case MySqlParser.KW_INVISIBLE: + case MySqlParser.KW_INVOKER: + case MySqlParser.KW_IO: + case MySqlParser.KW_IO_THREAD: + case MySqlParser.KW_IPC: + case MySqlParser.KW_ISOLATION: + case MySqlParser.KW_ISSUER: + case MySqlParser.KW_JSON: + case MySqlParser.KW_KEY_BLOCK_SIZE: + case MySqlParser.KW_LANGUAGE: + case MySqlParser.KW_LAST: + case MySqlParser.KW_LEAVES: + case MySqlParser.KW_LESS: + case MySqlParser.KW_LEVEL: + case MySqlParser.KW_LIST: + case MySqlParser.KW_LOCAL: + case MySqlParser.KW_LOGFILE: + case MySqlParser.KW_LOGS: + case MySqlParser.KW_MASTER: + case MySqlParser.KW_MASTER_AUTO_POSITION: + case MySqlParser.KW_MASTER_CONNECT_RETRY: + case MySqlParser.KW_MASTER_DELAY: + case MySqlParser.KW_MASTER_HEARTBEAT_PERIOD: + case MySqlParser.KW_MASTER_HOST: + case MySqlParser.KW_MASTER_LOG_FILE: + case MySqlParser.KW_MASTER_LOG_POS: + case MySqlParser.KW_MASTER_PASSWORD: + case MySqlParser.KW_MASTER_PORT: + case MySqlParser.KW_MASTER_RETRY_COUNT: + case MySqlParser.KW_MASTER_SSL: + case MySqlParser.KW_MASTER_SSL_CA: + case MySqlParser.KW_MASTER_SSL_CAPATH: + case MySqlParser.KW_MASTER_SSL_CERT: + case MySqlParser.KW_MASTER_SSL_CIPHER: + case MySqlParser.KW_MASTER_SSL_CRL: + case MySqlParser.KW_MASTER_SSL_CRLPATH: + case MySqlParser.KW_MASTER_SSL_KEY: + case MySqlParser.KW_MASTER_TLS_VERSION: + case MySqlParser.KW_MASTER_USER: + case MySqlParser.KW_MAX_CONNECTIONS_PER_HOUR: + case MySqlParser.KW_MAX_QUERIES_PER_HOUR: + case MySqlParser.KW_MAX_ROWS: + case MySqlParser.KW_MAX_SIZE: + case MySqlParser.KW_MAX_UPDATES_PER_HOUR: + case MySqlParser.KW_MAX_USER_CONNECTIONS: + case MySqlParser.KW_MEDIUM: + case MySqlParser.KW_MEMBER: + case MySqlParser.KW_MERGE: + case MySqlParser.KW_MESSAGE_TEXT: + case MySqlParser.KW_MID: + case MySqlParser.KW_MIGRATE: + case MySqlParser.KW_MIN_ROWS: + case MySqlParser.KW_MODE: + case MySqlParser.KW_MODIFY: + case MySqlParser.KW_MUTEX: + case MySqlParser.KW_MYSQL: + case MySqlParser.KW_MYSQL_ERRNO: + case MySqlParser.KW_NAME: + case MySqlParser.KW_NAMES: + case MySqlParser.KW_NCHAR: + case MySqlParser.KW_NEVER: + case MySqlParser.KW_NEXT: + case MySqlParser.KW_NO: + case MySqlParser.KW_NOWAIT: + case MySqlParser.KW_NODEGROUP: + case MySqlParser.KW_NONE: + case MySqlParser.KW_ODBC: + case MySqlParser.KW_OFFLINE: + case MySqlParser.KW_OFFSET: + case MySqlParser.KW_OF: + case MySqlParser.KW_OLD_PASSWORD: + case MySqlParser.KW_ONE: + case MySqlParser.KW_ONLINE: + case MySqlParser.KW_ONLY: + case MySqlParser.KW_OPEN: + case MySqlParser.KW_OPTIMIZER_COSTS: + case MySqlParser.KW_OPTIONS: + case MySqlParser.KW_OWNER: + case MySqlParser.KW_PACK_KEYS: + case MySqlParser.KW_PAGE: + case MySqlParser.KW_PAGE_CHECKSUM: + case MySqlParser.KW_PARSER: + case MySqlParser.KW_PARTIAL: + case MySqlParser.KW_PARTITIONING: + case MySqlParser.KW_PARTITIONS: + case MySqlParser.KW_PASSWORD: + case MySqlParser.KW_PASSWORD_LOCK_TIME: + case MySqlParser.KW_PHASE: + case MySqlParser.KW_PLUGIN: + case MySqlParser.KW_PLUGIN_DIR: + case MySqlParser.KW_PLUGINS: + case MySqlParser.KW_PORT: + case MySqlParser.KW_PRECEDES: + case MySqlParser.KW_PREPARE: + case MySqlParser.KW_PRESERVE: + case MySqlParser.KW_PREV: + case MySqlParser.KW_PROCESSLIST: + case MySqlParser.KW_PROFILE: + case MySqlParser.KW_PROFILES: + case MySqlParser.KW_PROXY: + case MySqlParser.KW_QUERY: + case MySqlParser.KW_QUICK: + case MySqlParser.KW_REBUILD: + case MySqlParser.KW_RECOVER: + case MySqlParser.KW_RECURSIVE: + case MySqlParser.KW_REDO_BUFFER_SIZE: + case MySqlParser.KW_REDUNDANT: + case MySqlParser.KW_RELAY: + case MySqlParser.KW_RELAY_LOG_FILE: + case MySqlParser.KW_RELAY_LOG_POS: + case MySqlParser.KW_RELAYLOG: + case MySqlParser.KW_REMOVE: + case MySqlParser.KW_REORGANIZE: + case MySqlParser.KW_REPAIR: + case MySqlParser.KW_REPLICATE_DO_DB: + case MySqlParser.KW_REPLICATE_DO_TABLE: + case MySqlParser.KW_REPLICATE_IGNORE_DB: + case MySqlParser.KW_REPLICATE_IGNORE_TABLE: + case MySqlParser.KW_REPLICATE_REWRITE_DB: + case MySqlParser.KW_REPLICATE_WILD_DO_TABLE: + case MySqlParser.KW_REPLICATE_WILD_IGNORE_TABLE: + case MySqlParser.KW_REPLICATION: + case MySqlParser.KW_RESET: + case MySqlParser.KW_RESUME: + case MySqlParser.KW_RETURNED_SQLSTATE: + case MySqlParser.KW_RETURNS: + case MySqlParser.KW_REUSE: + case MySqlParser.KW_ROLE: + case MySqlParser.KW_ROLLBACK: + case MySqlParser.KW_ROLLUP: + case MySqlParser.KW_ROTATE: + case MySqlParser.KW_ROW: + case MySqlParser.KW_ROWS: + case MySqlParser.KW_ROW_FORMAT: + case MySqlParser.KW_SAVEPOINT: + case MySqlParser.KW_SCHEDULE: + case MySqlParser.KW_SECURITY: + case MySqlParser.KW_SERVER: + case MySqlParser.KW_SESSION: + case MySqlParser.KW_SHARE: + case MySqlParser.KW_SHARED: + case MySqlParser.KW_SIGNED: + case MySqlParser.KW_SIMPLE: + case MySqlParser.KW_SLAVE: + case MySqlParser.KW_SLOW: + case MySqlParser.KW_SNAPSHOT: + case MySqlParser.KW_SOCKET: + case MySqlParser.KW_SOME: + case MySqlParser.KW_SONAME: + case MySqlParser.KW_SOUNDS: + case MySqlParser.KW_SOURCE: + case MySqlParser.KW_SQL_AFTER_GTIDS: + case MySqlParser.KW_SQL_AFTER_MTS_GAPS: + case MySqlParser.KW_SQL_BEFORE_GTIDS: + case MySqlParser.KW_SQL_BUFFER_RESULT: + case MySqlParser.KW_SQL_CACHE: + case MySqlParser.KW_SQL_NO_CACHE: + case MySqlParser.KW_SQL_THREAD: + case MySqlParser.KW_START: + case MySqlParser.KW_STARTS: + case MySqlParser.KW_STATS_AUTO_RECALC: + case MySqlParser.KW_STATS_PERSISTENT: + case MySqlParser.KW_STATS_SAMPLE_PAGES: + case MySqlParser.KW_STATUS: + case MySqlParser.KW_STOP: + case MySqlParser.KW_STORAGE: + case MySqlParser.KW_STRING: + case MySqlParser.KW_SUBCLASS_ORIGIN: + case MySqlParser.KW_SUBJECT: + case MySqlParser.KW_SUBPARTITION: + case MySqlParser.KW_SUBPARTITIONS: + case MySqlParser.KW_SUSPEND: + case MySqlParser.KW_SWAPS: + case MySqlParser.KW_SWITCHES: + case MySqlParser.KW_TABLE_NAME: + case MySqlParser.KW_TABLESPACE: + case MySqlParser.KW_TABLE_TYPE: + case MySqlParser.KW_TEMPORARY: + case MySqlParser.KW_TEMPTABLE: + case MySqlParser.KW_THAN: + case MySqlParser.KW_TRADITIONAL: + case MySqlParser.KW_TRANSACTION: + case MySqlParser.KW_TRANSACTIONAL: + case MySqlParser.KW_TRIGGERS: + case MySqlParser.KW_TRUNCATE: + case MySqlParser.KW_UNBOUNDED: + case MySqlParser.KW_UNDEFINED: + case MySqlParser.KW_UNDOFILE: + case MySqlParser.KW_UNDO_BUFFER_SIZE: + case MySqlParser.KW_UNINSTALL: + case MySqlParser.KW_UNKNOWN: + case MySqlParser.KW_UNTIL: + case MySqlParser.KW_UPGRADE: + case MySqlParser.KW_USER: + case MySqlParser.KW_USE_FRM: + case MySqlParser.KW_USER_RESOURCES: + case MySqlParser.KW_VALIDATION: + case MySqlParser.KW_VALUE: + case MySqlParser.KW_VARIABLES: + case MySqlParser.KW_VIEW: + case MySqlParser.KW_VIRTUAL: + case MySqlParser.KW_VISIBLE: + case MySqlParser.KW_WAIT: + case MySqlParser.KW_WARNINGS: + case MySqlParser.KW_WITHOUT: + case MySqlParser.KW_WORK: + case MySqlParser.KW_WRAPPER: + case MySqlParser.KW_X509: + case MySqlParser.KW_XA: + case MySqlParser.KW_XML: + case MySqlParser.KW_QUARTER: + case MySqlParser.KW_MONTH: + case MySqlParser.KW_DAY: + case MySqlParser.KW_HOUR: + case MySqlParser.KW_MINUTE: + case MySqlParser.KW_WEEK: + case MySqlParser.KW_SECOND: + case MySqlParser.KW_MICROSECOND: + case MySqlParser.KW_ADMIN: + case MySqlParser.KW_AUDIT_ABORT_EXEMPT: + case MySqlParser.KW_AUDIT_ADMIN: + case MySqlParser.KW_AUTHENTICATION_POLICY_ADMIN: + case MySqlParser.KW_BACKUP_ADMIN: + case MySqlParser.KW_BINLOG_ADMIN: + case MySqlParser.KW_BINLOG_ENCRYPTION_ADMIN: + case MySqlParser.KW_CLONE_ADMIN: + case MySqlParser.KW_CONNECTION_ADMIN: + case MySqlParser.KW_ENCRYPTION_KEY_ADMIN: + case MySqlParser.KW_EXECUTE: + case MySqlParser.KW_FILE: + case MySqlParser.KW_FIREWALL_ADMIN: + case MySqlParser.KW_FIREWALL_EXEMPT: + case MySqlParser.KW_FIREWALL_USER: + case MySqlParser.KW_GROUP_REPLICATION_ADMIN: + case MySqlParser.KW_INNODB_REDO_LOG_ARCHIVE: + case MySqlParser.KW_INVOKE: + case MySqlParser.KW_LAMBDA: + case MySqlParser.KW_NDB_STORED_USER: + case MySqlParser.KW_PASSWORDLESS_USER_ADMIN: + case MySqlParser.KW_PERSIST_RO_VARIABLES_ADMIN: + case MySqlParser.KW_PRIVILEGES: + case MySqlParser.KW_PROCESS: + case MySqlParser.KW_RELOAD: + case MySqlParser.KW_REPLICATION_APPLIER: + case MySqlParser.KW_REPLICATION_SLAVE_ADMIN: + case MySqlParser.KW_RESOURCE_GROUP_ADMIN: + case MySqlParser.KW_RESOURCE_GROUP_USER: + case MySqlParser.KW_ROLE_ADMIN: + case MySqlParser.KW_ROUTINE: + case MySqlParser.KW_S3: + case MySqlParser.KW_SESSION_VARIABLES_ADMIN: + case MySqlParser.KW_SET_USER_ID: + case MySqlParser.KW_SHOW_ROUTINE: + case MySqlParser.KW_SHUTDOWN: + case MySqlParser.KW_SUPER: + case MySqlParser.KW_SYSTEM_VARIABLES_ADMIN: + case MySqlParser.KW_TABLES: + case MySqlParser.KW_TABLE_ENCRYPTION_ADMIN: + case MySqlParser.KW_VERSION_TOKEN_ADMIN: + case MySqlParser.KW_XA_RECOVER_ADMIN: + case MySqlParser.KW_ARMSCII8: + case MySqlParser.KW_ASCII: + case MySqlParser.KW_BIG5: + case MySqlParser.KW_CP1250: + case MySqlParser.KW_CP1251: + case MySqlParser.KW_CP1256: + case MySqlParser.KW_CP1257: + case MySqlParser.KW_CP850: + case MySqlParser.KW_CP852: + case MySqlParser.KW_CP866: + case MySqlParser.KW_CP932: + case MySqlParser.KW_DEC8: + case MySqlParser.KW_EUCJPMS: + case MySqlParser.KW_EUCKR: + case MySqlParser.KW_GB18030: + case MySqlParser.KW_GB2312: + case MySqlParser.KW_GBK: + case MySqlParser.KW_GEOSTD8: + case MySqlParser.KW_GREEK: + case MySqlParser.KW_HEBREW: + case MySqlParser.KW_HP8: + case MySqlParser.KW_KEYBCS2: + case MySqlParser.KW_KOI8R: + case MySqlParser.KW_KOI8U: + case MySqlParser.KW_LATIN1: + case MySqlParser.KW_LATIN2: + case MySqlParser.KW_LATIN5: + case MySqlParser.KW_LATIN7: + case MySqlParser.KW_MACCE: + case MySqlParser.KW_MACROMAN: + case MySqlParser.KW_SJIS: + case MySqlParser.KW_SWE7: + case MySqlParser.KW_TIS620: + case MySqlParser.KW_UCS2: + case MySqlParser.KW_UJIS: + case MySqlParser.KW_UTF16: + case MySqlParser.KW_UTF16LE: + case MySqlParser.KW_UTF32: + case MySqlParser.KW_UTF8: + case MySqlParser.KW_UTF8MB3: + case MySqlParser.KW_UTF8MB4: + case MySqlParser.KW_ARCHIVE: + case MySqlParser.KW_BLACKHOLE: + case MySqlParser.KW_CSV: + case MySqlParser.KW_FEDERATED: + case MySqlParser.KW_INNODB: + case MySqlParser.KW_MEMORY: + case MySqlParser.KW_MRG_MYISAM: + case MySqlParser.KW_MYISAM: + case MySqlParser.KW_NDB: + case MySqlParser.KW_NDBCLUSTER: + case MySqlParser.KW_PERFORMANCE_SCHEMA: + case MySqlParser.KW_TOKUDB: + case MySqlParser.KW_REPEATABLE: + case MySqlParser.KW_COMMITTED: + case MySqlParser.KW_UNCOMMITTED: + case MySqlParser.KW_SERIALIZABLE: + case MySqlParser.KW_GEOMETRYCOLLECTION: + case MySqlParser.KW_LINESTRING: + case MySqlParser.KW_MULTILINESTRING: + case MySqlParser.KW_MULTIPOINT: + case MySqlParser.KW_MULTIPOLYGON: + case MySqlParser.KW_POINT: + case MySqlParser.KW_POLYGON: + case MySqlParser.KW_CATALOG_NAME: + case MySqlParser.KW_CHARSET: + case MySqlParser.KW_COLLATION: + case MySqlParser.KW_ENGINE_ATTRIBUTE: + case MySqlParser.KW_FORMAT: + case MySqlParser.KW_GET_FORMAT: + case MySqlParser.KW_RANDOM: + case MySqlParser.KW_REVERSE: + case MySqlParser.KW_ROW_COUNT: + case MySqlParser.KW_SCHEMA_NAME: + case MySqlParser.KW_SECONDARY_ENGINE_ATTRIBUTE: + case MySqlParser.KW_SRID: + case MySqlParser.KW_SYSTEM_USER: + case MySqlParser.KW_TP_CONNECTION_ADMIN: + case MySqlParser.KW_WEIGHT_STRING: + case MySqlParser.MOD: + case MySqlParser.CHARSET_REVERSE_QOUTE_STRING: + case MySqlParser.STRING_LITERAL: + case MySqlParser.ID: + this.enterOuterAlt(localContext, 1); + { + this.state = 3634; + localContext._var_name = this.uid(); + } + break; + case MySqlParser.LOCAL_ID: + this.enterOuterAlt(localContext, 2); + { + this.state = 3635; + this.match(MySqlParser.LOCAL_ID); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + lockClause() { + let localContext = new LockClauseContext(this.context, this.state); + this.enterRule(localContext, 232, MySqlParser.RULE_lockClause); + let _la; + try { + let alternative; + this.state = 3659; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_FOR: + this.enterOuterAlt(localContext, 1); + { + this.state = 3638; + this.match(MySqlParser.KW_FOR); + this.state = 3639; + _la = this.tokenStream.LA(1); + if (!(_la === 185 || _la === 594)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 3649; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 490, this.context)) { + case 1: + { + this.state = 3640; + this.match(MySqlParser.KW_OF); + this.state = 3641; + this.tableName(); + this.state = 3646; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 489, this.context); + while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER) { + if (alternative === 1) { + { + { + this.state = 3642; + this.match(MySqlParser.COMMA); + this.state = 3643; + this.tableName(); + } + } + } + this.state = 3648; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 489, this.context); + } + } + break; + } + this.state = 3653; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 491, this.context)) { + case 1: + { + this.state = 3651; + _la = this.tokenStream.LA(1); + if (!(_la === 159 || _la === 503)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 3652; + this.match(MySqlParser.KW_LOCKED); + } + break; + } + } + break; + case MySqlParser.KW_LOCK: + this.enterOuterAlt(localContext, 2); + { + this.state = 3655; + this.match(MySqlParser.KW_LOCK); + this.state = 3656; + this.match(MySqlParser.KW_IN); + this.state = 3657; + this.match(MySqlParser.KW_SHARE); + this.state = 3658; + this.match(MySqlParser.KW_MODE); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + singleDeleteStatement() { + let localContext = new SingleDeleteStatementContext(this.context, this.state); + this.enterRule(localContext, 234, MySqlParser.RULE_singleDeleteStatement); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 3661; + this.match(MySqlParser.KW_DELETE); + this.state = 3663; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 107) { + { + this.state = 3662; + localContext._priority = this.match(MySqlParser.KW_LOW_PRIORITY); + } + } + this.state = 3666; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 549) { + { + this.state = 3665; + this.match(MySqlParser.KW_QUICK); + } + } + this.state = 3669; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 79) { + { + this.state = 3668; + this.match(MySqlParser.KW_IGNORE); + } + } + this.state = 3671; + this.match(MySqlParser.KW_FROM); + this.state = 3672; + this.tableName(); + this.state = 3677; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 497, this.context)) { + case 1: + { + this.state = 3674; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 13) { + { + this.state = 3673; + this.match(MySqlParser.KW_AS); + } + } + this.state = 3676; + localContext._table_alias = this.uid(); + } + break; + } + this.state = 3684; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 130) { + { + this.state = 3679; + this.match(MySqlParser.KW_PARTITION); + this.state = 3680; + this.match(MySqlParser.LR_BRACKET); + this.state = 3681; + this.partitionNames(); + this.state = 3682; + this.match(MySqlParser.RR_BRACKET); + } + } + this.state = 3688; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 192) { + { + this.state = 3686; + this.match(MySqlParser.KW_WHERE); + this.state = 3687; + this.expression(0); + } + } + this.state = 3691; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 125) { + { + this.state = 3690; + this.orderByClause(); + } + } + this.state = 3695; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 100) { + { + this.state = 3693; + this.match(MySqlParser.KW_LIMIT); + this.state = 3694; + this.limitClauseAtom(); + } + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + multipleDeleteStatement() { + let localContext = new MultipleDeleteStatementContext(this.context, this.state); + this.enterRule(localContext, 236, MySqlParser.RULE_multipleDeleteStatement); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 3697; + this.match(MySqlParser.KW_DELETE); + this.state = 3699; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 107) { + { + this.state = 3698; + localContext._priority = this.match(MySqlParser.KW_LOW_PRIORITY); + } + } + this.state = 3702; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 503, this.context)) { + case 1: + { + this.state = 3701; + this.match(MySqlParser.KW_QUICK); + } + break; + } + this.state = 3705; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 79) { + { + this.state = 3704; + this.match(MySqlParser.KW_IGNORE); + } + } + this.state = 3746; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_ARRAY: + case MySqlParser.KW_ATTRIBUTE: + case MySqlParser.KW_BUCKETS: + case MySqlParser.KW_CONDITION: + case MySqlParser.KW_CURRENT: + case MySqlParser.KW_CURRENT_USER: + case MySqlParser.KW_DATABASE: + case MySqlParser.KW_DEFAULT: + case MySqlParser.KW_DIAGNOSTICS: + case MySqlParser.KW_EMPTY: + case MySqlParser.KW_ENFORCED: + case MySqlParser.KW_EXCEPT: + case MySqlParser.KW_GROUP: + case MySqlParser.KW_IF: + case MySqlParser.KW_INSERT: + case MySqlParser.KW_LATERAL: + case MySqlParser.KW_LEFT: + case MySqlParser.KW_NUMBER: + case MySqlParser.KW_OPTIONAL: + case MySqlParser.KW_ORDER: + case MySqlParser.KW_PRIMARY: + case MySqlParser.KW_REPEAT: + case MySqlParser.KW_REPLACE: + case MySqlParser.KW_RIGHT: + case MySqlParser.KW_SCHEMA: + case MySqlParser.KW_SKIP_QUERY_REWRITE: + case MySqlParser.KW_STACKED: + case MySqlParser.KW_DATE: + case MySqlParser.KW_TIME: + case MySqlParser.KW_TIMESTAMP: + case MySqlParser.KW_DATETIME: + case MySqlParser.KW_YEAR: + case MySqlParser.KW_BINARY: + case MySqlParser.KW_TEXT: + case MySqlParser.KW_ENUM: + case MySqlParser.KW_SERIAL: + case MySqlParser.KW_JSON_TABLE: + case MySqlParser.KW_JSON_VALUE: + case MySqlParser.KW_NESTED: + case MySqlParser.KW_ORDINALITY: + case MySqlParser.KW_PATH: + case MySqlParser.KW_AVG: + case MySqlParser.KW_BIT_AND: + case MySqlParser.KW_BIT_OR: + case MySqlParser.KW_BIT_XOR: + case MySqlParser.KW_COUNT: + case MySqlParser.KW_CUME_DIST: + case MySqlParser.KW_DENSE_RANK: + case MySqlParser.KW_FIRST_VALUE: + case MySqlParser.KW_GROUP_CONCAT: + case MySqlParser.KW_LAG: + case MySqlParser.KW_LAST_VALUE: + case MySqlParser.KW_LEAD: + case MySqlParser.KW_MAX: + case MySqlParser.KW_MIN: + case MySqlParser.KW_NTILE: + case MySqlParser.KW_NTH_VALUE: + case MySqlParser.KW_PERCENT_RANK: + case MySqlParser.KW_RANK: + case MySqlParser.KW_ROW_NUMBER: + case MySqlParser.KW_STD: + case MySqlParser.KW_STDDEV: + case MySqlParser.KW_STDDEV_POP: + case MySqlParser.KW_STDDEV_SAMP: + case MySqlParser.KW_SUM: + case MySqlParser.KW_VAR_POP: + case MySqlParser.KW_VAR_SAMP: + case MySqlParser.KW_VARIANCE: + case MySqlParser.KW_CURRENT_DATE: + case MySqlParser.KW_CURRENT_TIME: + case MySqlParser.KW_CURRENT_TIMESTAMP: + case MySqlParser.KW_LOCALTIME: + case MySqlParser.KW_CURDATE: + case MySqlParser.KW_CURTIME: + case MySqlParser.KW_DATE_ADD: + case MySqlParser.KW_DATE_SUB: + case MySqlParser.KW_LOCALTIMESTAMP: + case MySqlParser.KW_NOW: + case MySqlParser.KW_POSITION: + case MySqlParser.KW_SUBSTR: + case MySqlParser.KW_SUBSTRING: + case MySqlParser.KW_SYSDATE: + case MySqlParser.KW_TRIM: + case MySqlParser.KW_UTC_DATE: + case MySqlParser.KW_UTC_TIME: + case MySqlParser.KW_UTC_TIMESTAMP: + case MySqlParser.KW_ACCOUNT: + case MySqlParser.KW_ACTION: + case MySqlParser.KW_AFTER: + case MySqlParser.KW_AGGREGATE: + case MySqlParser.KW_ALGORITHM: + case MySqlParser.KW_ANY: + case MySqlParser.KW_AT: + case MySqlParser.KW_AUTHORS: + case MySqlParser.KW_AUTOCOMMIT: + case MySqlParser.KW_AUTOEXTEND_SIZE: + case MySqlParser.KW_AUTO_INCREMENT: + case MySqlParser.KW_AVG_ROW_LENGTH: + case MySqlParser.KW_BEGIN: + case MySqlParser.KW_BINLOG: + case MySqlParser.KW_BIT: + case MySqlParser.KW_BLOCK: + case MySqlParser.KW_BOOL: + case MySqlParser.KW_BOOLEAN: + case MySqlParser.KW_BTREE: + case MySqlParser.KW_CACHE: + case MySqlParser.KW_CASCADED: + case MySqlParser.KW_CHAIN: + case MySqlParser.KW_CHANGED: + case MySqlParser.KW_CHANNEL: + case MySqlParser.KW_CHECKSUM: + case MySqlParser.KW_CIPHER: + case MySqlParser.KW_CLASS_ORIGIN: + case MySqlParser.KW_CLIENT: + case MySqlParser.KW_CLOSE: + case MySqlParser.KW_COALESCE: + case MySqlParser.KW_CODE: + case MySqlParser.KW_COLUMNS: + case MySqlParser.KW_COLUMN_FORMAT: + case MySqlParser.KW_COLUMN_NAME: + case MySqlParser.KW_COMMENT: + case MySqlParser.KW_COMMIT: + case MySqlParser.KW_COMPACT: + case MySqlParser.KW_COMPLETION: + case MySqlParser.KW_COMPRESSED: + case MySqlParser.KW_COMPRESSION: + case MySqlParser.KW_CONCURRENT: + case MySqlParser.KW_CONNECT: + case MySqlParser.KW_CONNECTION: + case MySqlParser.KW_CONSISTENT: + case MySqlParser.KW_CONSTRAINT_CATALOG: + case MySqlParser.KW_CONSTRAINT_SCHEMA: + case MySqlParser.KW_CONSTRAINT_NAME: + case MySqlParser.KW_CONTAINS: + case MySqlParser.KW_CONTEXT: + case MySqlParser.KW_CONTRIBUTORS: + case MySqlParser.KW_COPY: + case MySqlParser.KW_CPU: + case MySqlParser.KW_CURSOR_NAME: + case MySqlParser.KW_DATA: + case MySqlParser.KW_DATAFILE: + case MySqlParser.KW_DEALLOCATE: + case MySqlParser.KW_DEFAULT_AUTH: + case MySqlParser.KW_DEFINER: + case MySqlParser.KW_DELAY_KEY_WRITE: + case MySqlParser.KW_DES_KEY_FILE: + case MySqlParser.KW_DIRECTORY: + case MySqlParser.KW_DISABLE: + case MySqlParser.KW_DISCARD: + case MySqlParser.KW_DISK: + case MySqlParser.KW_DO: + case MySqlParser.KW_DUMPFILE: + case MySqlParser.KW_DUPLICATE: + case MySqlParser.KW_DYNAMIC: + case MySqlParser.KW_ENABLE: + case MySqlParser.KW_ENCRYPTION: + case MySqlParser.KW_END: + case MySqlParser.KW_ENDS: + case MySqlParser.KW_ENGINE: + case MySqlParser.KW_ENGINES: + case MySqlParser.KW_ERROR: + case MySqlParser.KW_ERRORS: + case MySqlParser.KW_ESCAPE: + case MySqlParser.KW_EVENT: + case MySqlParser.KW_EVENTS: + case MySqlParser.KW_EVERY: + case MySqlParser.KW_EXCHANGE: + case MySqlParser.KW_EXCLUSIVE: + case MySqlParser.KW_EXPIRE: + case MySqlParser.KW_EXPORT: + case MySqlParser.KW_EXTENDED: + case MySqlParser.KW_EXTENT_SIZE: + case MySqlParser.KW_FAILED_LOGIN_ATTEMPTS: + case MySqlParser.KW_FAST: + case MySqlParser.KW_FAULTS: + case MySqlParser.KW_FIELDS: + case MySqlParser.KW_FILE_BLOCK_SIZE: + case MySqlParser.KW_FILTER: + case MySqlParser.KW_FIRST: + case MySqlParser.KW_FIXED: + case MySqlParser.KW_FLUSH: + case MySqlParser.KW_FOLLOWS: + case MySqlParser.KW_FOUND: + case MySqlParser.KW_FULL: + case MySqlParser.KW_FUNCTION: + case MySqlParser.KW_GENERAL: + case MySqlParser.KW_GLOBAL: + case MySqlParser.KW_GRANTS: + case MySqlParser.KW_GROUP_REPLICATION: + case MySqlParser.KW_HANDLER: + case MySqlParser.KW_HASH: + case MySqlParser.KW_HELP: + case MySqlParser.KW_HISTORY: + case MySqlParser.KW_HOST: + case MySqlParser.KW_HOSTS: + case MySqlParser.KW_IDENTIFIED: + case MySqlParser.KW_IGNORE_SERVER_IDS: + case MySqlParser.KW_IMPORT: + case MySqlParser.KW_INDEXES: + case MySqlParser.KW_INITIAL_SIZE: + case MySqlParser.KW_INPLACE: + case MySqlParser.KW_INSERT_METHOD: + case MySqlParser.KW_INSTALL: + case MySqlParser.KW_INSTANCE: + case MySqlParser.KW_INSTANT: + case MySqlParser.KW_INVISIBLE: + case MySqlParser.KW_INVOKER: + case MySqlParser.KW_IO: + case MySqlParser.KW_IO_THREAD: + case MySqlParser.KW_IPC: + case MySqlParser.KW_ISOLATION: + case MySqlParser.KW_ISSUER: + case MySqlParser.KW_JSON: + case MySqlParser.KW_KEY_BLOCK_SIZE: + case MySqlParser.KW_LANGUAGE: + case MySqlParser.KW_LAST: + case MySqlParser.KW_LEAVES: + case MySqlParser.KW_LESS: + case MySqlParser.KW_LEVEL: + case MySqlParser.KW_LIST: + case MySqlParser.KW_LOCAL: + case MySqlParser.KW_LOGFILE: + case MySqlParser.KW_LOGS: + case MySqlParser.KW_MASTER: + case MySqlParser.KW_MASTER_AUTO_POSITION: + case MySqlParser.KW_MASTER_CONNECT_RETRY: + case MySqlParser.KW_MASTER_DELAY: + case MySqlParser.KW_MASTER_HEARTBEAT_PERIOD: + case MySqlParser.KW_MASTER_HOST: + case MySqlParser.KW_MASTER_LOG_FILE: + case MySqlParser.KW_MASTER_LOG_POS: + case MySqlParser.KW_MASTER_PASSWORD: + case MySqlParser.KW_MASTER_PORT: + case MySqlParser.KW_MASTER_RETRY_COUNT: + case MySqlParser.KW_MASTER_SSL: + case MySqlParser.KW_MASTER_SSL_CA: + case MySqlParser.KW_MASTER_SSL_CAPATH: + case MySqlParser.KW_MASTER_SSL_CERT: + case MySqlParser.KW_MASTER_SSL_CIPHER: + case MySqlParser.KW_MASTER_SSL_CRL: + case MySqlParser.KW_MASTER_SSL_CRLPATH: + case MySqlParser.KW_MASTER_SSL_KEY: + case MySqlParser.KW_MASTER_TLS_VERSION: + case MySqlParser.KW_MASTER_USER: + case MySqlParser.KW_MAX_CONNECTIONS_PER_HOUR: + case MySqlParser.KW_MAX_QUERIES_PER_HOUR: + case MySqlParser.KW_MAX_ROWS: + case MySqlParser.KW_MAX_SIZE: + case MySqlParser.KW_MAX_UPDATES_PER_HOUR: + case MySqlParser.KW_MAX_USER_CONNECTIONS: + case MySqlParser.KW_MEDIUM: + case MySqlParser.KW_MEMBER: + case MySqlParser.KW_MERGE: + case MySqlParser.KW_MESSAGE_TEXT: + case MySqlParser.KW_MID: + case MySqlParser.KW_MIGRATE: + case MySqlParser.KW_MIN_ROWS: + case MySqlParser.KW_MODE: + case MySqlParser.KW_MODIFY: + case MySqlParser.KW_MUTEX: + case MySqlParser.KW_MYSQL: + case MySqlParser.KW_MYSQL_ERRNO: + case MySqlParser.KW_NAME: + case MySqlParser.KW_NAMES: + case MySqlParser.KW_NCHAR: + case MySqlParser.KW_NEVER: + case MySqlParser.KW_NEXT: + case MySqlParser.KW_NO: + case MySqlParser.KW_NOWAIT: + case MySqlParser.KW_NODEGROUP: + case MySqlParser.KW_NONE: + case MySqlParser.KW_ODBC: + case MySqlParser.KW_OFFLINE: + case MySqlParser.KW_OFFSET: + case MySqlParser.KW_OF: + case MySqlParser.KW_OLD_PASSWORD: + case MySqlParser.KW_ONE: + case MySqlParser.KW_ONLINE: + case MySqlParser.KW_ONLY: + case MySqlParser.KW_OPEN: + case MySqlParser.KW_OPTIMIZER_COSTS: + case MySqlParser.KW_OPTIONS: + case MySqlParser.KW_OWNER: + case MySqlParser.KW_PACK_KEYS: + case MySqlParser.KW_PAGE: + case MySqlParser.KW_PAGE_CHECKSUM: + case MySqlParser.KW_PARSER: + case MySqlParser.KW_PARTIAL: + case MySqlParser.KW_PARTITIONING: + case MySqlParser.KW_PARTITIONS: + case MySqlParser.KW_PASSWORD: + case MySqlParser.KW_PASSWORD_LOCK_TIME: + case MySqlParser.KW_PHASE: + case MySqlParser.KW_PLUGIN: + case MySqlParser.KW_PLUGIN_DIR: + case MySqlParser.KW_PLUGINS: + case MySqlParser.KW_PORT: + case MySqlParser.KW_PRECEDES: + case MySqlParser.KW_PREPARE: + case MySqlParser.KW_PRESERVE: + case MySqlParser.KW_PREV: + case MySqlParser.KW_PROCESSLIST: + case MySqlParser.KW_PROFILE: + case MySqlParser.KW_PROFILES: + case MySqlParser.KW_PROXY: + case MySqlParser.KW_QUERY: + case MySqlParser.KW_QUICK: + case MySqlParser.KW_REBUILD: + case MySqlParser.KW_RECOVER: + case MySqlParser.KW_RECURSIVE: + case MySqlParser.KW_REDO_BUFFER_SIZE: + case MySqlParser.KW_REDUNDANT: + case MySqlParser.KW_RELAY: + case MySqlParser.KW_RELAY_LOG_FILE: + case MySqlParser.KW_RELAY_LOG_POS: + case MySqlParser.KW_RELAYLOG: + case MySqlParser.KW_REMOVE: + case MySqlParser.KW_REORGANIZE: + case MySqlParser.KW_REPAIR: + case MySqlParser.KW_REPLICATE_DO_DB: + case MySqlParser.KW_REPLICATE_DO_TABLE: + case MySqlParser.KW_REPLICATE_IGNORE_DB: + case MySqlParser.KW_REPLICATE_IGNORE_TABLE: + case MySqlParser.KW_REPLICATE_REWRITE_DB: + case MySqlParser.KW_REPLICATE_WILD_DO_TABLE: + case MySqlParser.KW_REPLICATE_WILD_IGNORE_TABLE: + case MySqlParser.KW_REPLICATION: + case MySqlParser.KW_RESET: + case MySqlParser.KW_RESUME: + case MySqlParser.KW_RETURNED_SQLSTATE: + case MySqlParser.KW_RETURNS: + case MySqlParser.KW_REUSE: + case MySqlParser.KW_ROLE: + case MySqlParser.KW_ROLLBACK: + case MySqlParser.KW_ROLLUP: + case MySqlParser.KW_ROTATE: + case MySqlParser.KW_ROW: + case MySqlParser.KW_ROWS: + case MySqlParser.KW_ROW_FORMAT: + case MySqlParser.KW_SAVEPOINT: + case MySqlParser.KW_SCHEDULE: + case MySqlParser.KW_SECURITY: + case MySqlParser.KW_SERVER: + case MySqlParser.KW_SESSION: + case MySqlParser.KW_SHARE: + case MySqlParser.KW_SHARED: + case MySqlParser.KW_SIGNED: + case MySqlParser.KW_SIMPLE: + case MySqlParser.KW_SLAVE: + case MySqlParser.KW_SLOW: + case MySqlParser.KW_SNAPSHOT: + case MySqlParser.KW_SOCKET: + case MySqlParser.KW_SOME: + case MySqlParser.KW_SONAME: + case MySqlParser.KW_SOUNDS: + case MySqlParser.KW_SOURCE: + case MySqlParser.KW_SQL_AFTER_GTIDS: + case MySqlParser.KW_SQL_AFTER_MTS_GAPS: + case MySqlParser.KW_SQL_BEFORE_GTIDS: + case MySqlParser.KW_SQL_BUFFER_RESULT: + case MySqlParser.KW_SQL_CACHE: + case MySqlParser.KW_SQL_NO_CACHE: + case MySqlParser.KW_SQL_THREAD: + case MySqlParser.KW_START: + case MySqlParser.KW_STARTS: + case MySqlParser.KW_STATS_AUTO_RECALC: + case MySqlParser.KW_STATS_PERSISTENT: + case MySqlParser.KW_STATS_SAMPLE_PAGES: + case MySqlParser.KW_STATUS: + case MySqlParser.KW_STOP: + case MySqlParser.KW_STORAGE: + case MySqlParser.KW_STRING: + case MySqlParser.KW_SUBCLASS_ORIGIN: + case MySqlParser.KW_SUBJECT: + case MySqlParser.KW_SUBPARTITION: + case MySqlParser.KW_SUBPARTITIONS: + case MySqlParser.KW_SUSPEND: + case MySqlParser.KW_SWAPS: + case MySqlParser.KW_SWITCHES: + case MySqlParser.KW_TABLE_NAME: + case MySqlParser.KW_TABLESPACE: + case MySqlParser.KW_TABLE_TYPE: + case MySqlParser.KW_TEMPORARY: + case MySqlParser.KW_TEMPTABLE: + case MySqlParser.KW_THAN: + case MySqlParser.KW_TRADITIONAL: + case MySqlParser.KW_TRANSACTION: + case MySqlParser.KW_TRANSACTIONAL: + case MySqlParser.KW_TRIGGERS: + case MySqlParser.KW_TRUNCATE: + case MySqlParser.KW_UNBOUNDED: + case MySqlParser.KW_UNDEFINED: + case MySqlParser.KW_UNDOFILE: + case MySqlParser.KW_UNDO_BUFFER_SIZE: + case MySqlParser.KW_UNINSTALL: + case MySqlParser.KW_UNKNOWN: + case MySqlParser.KW_UNTIL: + case MySqlParser.KW_UPGRADE: + case MySqlParser.KW_USER: + case MySqlParser.KW_USE_FRM: + case MySqlParser.KW_USER_RESOURCES: + case MySqlParser.KW_VALIDATION: + case MySqlParser.KW_VALUE: + case MySqlParser.KW_VARIABLES: + case MySqlParser.KW_VIEW: + case MySqlParser.KW_VIRTUAL: + case MySqlParser.KW_VISIBLE: + case MySqlParser.KW_WAIT: + case MySqlParser.KW_WARNINGS: + case MySqlParser.KW_WITHOUT: + case MySqlParser.KW_WORK: + case MySqlParser.KW_WRAPPER: + case MySqlParser.KW_X509: + case MySqlParser.KW_XA: + case MySqlParser.KW_XML: + case MySqlParser.KW_QUARTER: + case MySqlParser.KW_MONTH: + case MySqlParser.KW_DAY: + case MySqlParser.KW_HOUR: + case MySqlParser.KW_MINUTE: + case MySqlParser.KW_WEEK: + case MySqlParser.KW_SECOND: + case MySqlParser.KW_MICROSECOND: + case MySqlParser.KW_ADMIN: + case MySqlParser.KW_AUDIT_ABORT_EXEMPT: + case MySqlParser.KW_AUDIT_ADMIN: + case MySqlParser.KW_AUTHENTICATION_POLICY_ADMIN: + case MySqlParser.KW_BACKUP_ADMIN: + case MySqlParser.KW_BINLOG_ADMIN: + case MySqlParser.KW_BINLOG_ENCRYPTION_ADMIN: + case MySqlParser.KW_CLONE_ADMIN: + case MySqlParser.KW_CONNECTION_ADMIN: + case MySqlParser.KW_ENCRYPTION_KEY_ADMIN: + case MySqlParser.KW_EXECUTE: + case MySqlParser.KW_FILE: + case MySqlParser.KW_FIREWALL_ADMIN: + case MySqlParser.KW_FIREWALL_EXEMPT: + case MySqlParser.KW_FIREWALL_USER: + case MySqlParser.KW_GROUP_REPLICATION_ADMIN: + case MySqlParser.KW_INNODB_REDO_LOG_ARCHIVE: + case MySqlParser.KW_INVOKE: + case MySqlParser.KW_LAMBDA: + case MySqlParser.KW_NDB_STORED_USER: + case MySqlParser.KW_PASSWORDLESS_USER_ADMIN: + case MySqlParser.KW_PERSIST_RO_VARIABLES_ADMIN: + case MySqlParser.KW_PRIVILEGES: + case MySqlParser.KW_PROCESS: + case MySqlParser.KW_RELOAD: + case MySqlParser.KW_REPLICATION_APPLIER: + case MySqlParser.KW_REPLICATION_SLAVE_ADMIN: + case MySqlParser.KW_RESOURCE_GROUP_ADMIN: + case MySqlParser.KW_RESOURCE_GROUP_USER: + case MySqlParser.KW_ROLE_ADMIN: + case MySqlParser.KW_ROUTINE: + case MySqlParser.KW_S3: + case MySqlParser.KW_SESSION_VARIABLES_ADMIN: + case MySqlParser.KW_SET_USER_ID: + case MySqlParser.KW_SHOW_ROUTINE: + case MySqlParser.KW_SHUTDOWN: + case MySqlParser.KW_SUPER: + case MySqlParser.KW_SYSTEM_VARIABLES_ADMIN: + case MySqlParser.KW_TABLES: + case MySqlParser.KW_TABLE_ENCRYPTION_ADMIN: + case MySqlParser.KW_VERSION_TOKEN_ADMIN: + case MySqlParser.KW_XA_RECOVER_ADMIN: + case MySqlParser.KW_ARMSCII8: + case MySqlParser.KW_ASCII: + case MySqlParser.KW_BIG5: + case MySqlParser.KW_CP1250: + case MySqlParser.KW_CP1251: + case MySqlParser.KW_CP1256: + case MySqlParser.KW_CP1257: + case MySqlParser.KW_CP850: + case MySqlParser.KW_CP852: + case MySqlParser.KW_CP866: + case MySqlParser.KW_CP932: + case MySqlParser.KW_DEC8: + case MySqlParser.KW_EUCJPMS: + case MySqlParser.KW_EUCKR: + case MySqlParser.KW_GB18030: + case MySqlParser.KW_GB2312: + case MySqlParser.KW_GBK: + case MySqlParser.KW_GEOSTD8: + case MySqlParser.KW_GREEK: + case MySqlParser.KW_HEBREW: + case MySqlParser.KW_HP8: + case MySqlParser.KW_KEYBCS2: + case MySqlParser.KW_KOI8R: + case MySqlParser.KW_KOI8U: + case MySqlParser.KW_LATIN1: + case MySqlParser.KW_LATIN2: + case MySqlParser.KW_LATIN5: + case MySqlParser.KW_LATIN7: + case MySqlParser.KW_MACCE: + case MySqlParser.KW_MACROMAN: + case MySqlParser.KW_SJIS: + case MySqlParser.KW_SWE7: + case MySqlParser.KW_TIS620: + case MySqlParser.KW_UCS2: + case MySqlParser.KW_UJIS: + case MySqlParser.KW_UTF16: + case MySqlParser.KW_UTF16LE: + case MySqlParser.KW_UTF32: + case MySqlParser.KW_UTF8: + case MySqlParser.KW_UTF8MB3: + case MySqlParser.KW_UTF8MB4: + case MySqlParser.KW_ARCHIVE: + case MySqlParser.KW_BLACKHOLE: + case MySqlParser.KW_CSV: + case MySqlParser.KW_FEDERATED: + case MySqlParser.KW_INNODB: + case MySqlParser.KW_MEMORY: + case MySqlParser.KW_MRG_MYISAM: + case MySqlParser.KW_MYISAM: + case MySqlParser.KW_NDB: + case MySqlParser.KW_NDBCLUSTER: + case MySqlParser.KW_PERFORMANCE_SCHEMA: + case MySqlParser.KW_TOKUDB: + case MySqlParser.KW_REPEATABLE: + case MySqlParser.KW_COMMITTED: + case MySqlParser.KW_UNCOMMITTED: + case MySqlParser.KW_SERIALIZABLE: + case MySqlParser.KW_GEOMETRYCOLLECTION: + case MySqlParser.KW_LINESTRING: + case MySqlParser.KW_MULTILINESTRING: + case MySqlParser.KW_MULTIPOINT: + case MySqlParser.KW_MULTIPOLYGON: + case MySqlParser.KW_POINT: + case MySqlParser.KW_POLYGON: + case MySqlParser.KW_CATALOG_NAME: + case MySqlParser.KW_CHARSET: + case MySqlParser.KW_COLLATION: + case MySqlParser.KW_ENGINE_ATTRIBUTE: + case MySqlParser.KW_FORMAT: + case MySqlParser.KW_GET_FORMAT: + case MySqlParser.KW_RANDOM: + case MySqlParser.KW_REVERSE: + case MySqlParser.KW_ROW_COUNT: + case MySqlParser.KW_SCHEMA_NAME: + case MySqlParser.KW_SECONDARY_ENGINE_ATTRIBUTE: + case MySqlParser.KW_SRID: + case MySqlParser.KW_SYSTEM_USER: + case MySqlParser.KW_TP_CONNECTION_ADMIN: + case MySqlParser.KW_WEIGHT_STRING: + case MySqlParser.MOD: + case MySqlParser.CHARSET_REVERSE_QOUTE_STRING: + case MySqlParser.STRING_LITERAL: + case MySqlParser.ID: + { + this.state = 3707; + this.tableName(); + this.state = 3710; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 865) { + { + this.state = 3708; + this.match(MySqlParser.DOT); + this.state = 3709; + this.match(MySqlParser.STAR); + } + } + this.state = 3720; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 3712; + this.match(MySqlParser.COMMA); + this.state = 3713; + this.tableName(); + this.state = 3716; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 865) { + { + this.state = 3714; + this.match(MySqlParser.DOT); + this.state = 3715; + this.match(MySqlParser.STAR); + } + } + } + } + this.state = 3722; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 3723; + this.match(MySqlParser.KW_FROM); + this.state = 3724; + this.tableSources(); + } + break; + case MySqlParser.KW_FROM: + { + this.state = 3726; + this.match(MySqlParser.KW_FROM); + this.state = 3727; + this.tableName(); + this.state = 3730; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 865) { + { + this.state = 3728; + this.match(MySqlParser.DOT); + this.state = 3729; + this.match(MySqlParser.STAR); + } + } + this.state = 3740; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 3732; + this.match(MySqlParser.COMMA); + this.state = 3733; + this.tableName(); + this.state = 3736; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 865) { + { + this.state = 3734; + this.match(MySqlParser.DOT); + this.state = 3735; + this.match(MySqlParser.STAR); + } + } + } + } + this.state = 3742; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 3743; + this.match(MySqlParser.KW_USING); + this.state = 3744; + this.tableSources(); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + this.state = 3750; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 192) { + { + this.state = 3748; + this.match(MySqlParser.KW_WHERE); + this.state = 3749; + this.expression(0); + } + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + handlerOpenStatement() { + let localContext = new HandlerOpenStatementContext(this.context, this.state); + this.enterRule(localContext, 238, MySqlParser.RULE_handlerOpenStatement); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 3752; + this.match(MySqlParser.KW_HANDLER); + this.state = 3753; + this.tableName(); + this.state = 3754; + this.match(MySqlParser.KW_OPEN); + this.state = 3759; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 514, this.context)) { + case 1: + { + this.state = 3756; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 13) { + { + this.state = 3755; + this.match(MySqlParser.KW_AS); + } + } + this.state = 3758; + localContext._table_alias = this.uid(); + } + break; + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + handlerReadIndexStatement() { + let localContext = new HandlerReadIndexStatementContext(this.context, this.state); + this.enterRule(localContext, 240, MySqlParser.RULE_handlerReadIndexStatement); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 3761; + this.match(MySqlParser.KW_HANDLER); + this.state = 3762; + this.tableName(); + this.state = 3763; + this.match(MySqlParser.KW_READ); + this.state = 3764; + this.indexName(); + this.state = 3771; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.EQUAL_SYMBOL: + case MySqlParser.GREATER_SYMBOL: + case MySqlParser.LESS_SYMBOL: + { + this.state = 3765; + this.comparisonBase(); + this.state = 3766; + this.match(MySqlParser.LR_BRACKET); + this.state = 3767; + this.constants(); + this.state = 3768; + this.match(MySqlParser.RR_BRACKET); + } + break; + case MySqlParser.KW_FIRST: + case MySqlParser.KW_LAST: + case MySqlParser.KW_NEXT: + case MySqlParser.KW_PREV: + { + this.state = 3770; + localContext._moveOrder = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 402 || _la === 445 || _la === 501 || _la === 542)) { + localContext._moveOrder = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + break; + default: + throw new antlr.NoViableAltException(this); + } + this.state = 3775; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 192) { + { + this.state = 3773; + this.match(MySqlParser.KW_WHERE); + this.state = 3774; + this.expression(0); + } + } + this.state = 3779; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 100) { + { + this.state = 3777; + this.match(MySqlParser.KW_LIMIT); + this.state = 3778; + this.limitClauseAtom(); + } + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + handlerReadStatement() { + let localContext = new HandlerReadStatementContext(this.context, this.state); + this.enterRule(localContext, 242, MySqlParser.RULE_handlerReadStatement); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 3781; + this.match(MySqlParser.KW_HANDLER); + this.state = 3782; + this.tableName(); + this.state = 3783; + this.match(MySqlParser.KW_READ); + this.state = 3784; + localContext._moveOrder = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 402 || _la === 501)) { + localContext._moveOrder = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 3787; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 192) { + { + this.state = 3785; + this.match(MySqlParser.KW_WHERE); + this.state = 3786; + this.expression(0); + } + } + this.state = 3791; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 100) { + { + this.state = 3789; + this.match(MySqlParser.KW_LIMIT); + this.state = 3790; + this.limitClauseAtom(); + } + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + handlerCloseStatement() { + let localContext = new HandlerCloseStatementContext(this.context, this.state); + this.enterRule(localContext, 244, MySqlParser.RULE_handlerCloseStatement); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 3793; + this.match(MySqlParser.KW_HANDLER); + this.state = 3794; + this.tableName(); + this.state = 3795; + this.match(MySqlParser.KW_CLOSE); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + importTableStatement() { + let localContext = new ImportTableStatementContext(this.context, this.state); + this.enterRule(localContext, 246, MySqlParser.RULE_importTableStatement); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 3797; + this.match(MySqlParser.KW_IMPORT); + this.state = 3798; + this.match(MySqlParser.KW_TABLE); + this.state = 3799; + this.match(MySqlParser.KW_FROM); + this.state = 3800; + this.stringLiteral(); + this.state = 3805; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 3801; + this.match(MySqlParser.COMMA); + this.state = 3802; + this.stringLiteral(); + } + } + this.state = 3807; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + singleUpdateStatement() { + let localContext = new SingleUpdateStatementContext(this.context, this.state); + this.enterRule(localContext, 248, MySqlParser.RULE_singleUpdateStatement); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 3808; + this.match(MySqlParser.KW_UPDATE); + this.state = 3810; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 107) { + { + this.state = 3809; + localContext._priority = this.match(MySqlParser.KW_LOW_PRIORITY); + } + } + this.state = 3813; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 79) { + { + this.state = 3812; + this.match(MySqlParser.KW_IGNORE); + } + } + this.state = 3815; + this.tableName(); + this.state = 3820; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if ((((_la) & ~0x1F) === 0 && ((1 << _la) & 1074311168) !== 0) || ((((_la - 36)) & ~0x1F) === 0 && ((1 << (_la - 36)) & 11014219) !== 0) || ((((_la - 74)) & ~0x1F) === 0 && ((1 << (_la - 74)) & 18878481) !== 0) || ((((_la - 117)) & ~0x1F) === 0 && ((1 << (_la - 117)) & 100679969) !== 0) || ((((_la - 150)) & ~0x1F) === 0 && ((1 << (_la - 150)) & 1049605) !== 0) || ((((_la - 219)) & ~0x1F) === 0 && ((1 << (_la - 219)) & 5374495) !== 0) || ((((_la - 253)) & ~0x1F) === 0 && ((1 << (_la - 253)) & 4294967295) !== 0) || ((((_la - 285)) & ~0x1F) === 0 && ((1 << (_la - 285)) & 4261412607) !== 0) || ((((_la - 317)) & ~0x1F) === 0 && ((1 << (_la - 317)) & 4160741375) !== 0) || ((((_la - 349)) & ~0x1F) === 0 && ((1 << (_la - 349)) & 4026531839) !== 0) || ((((_la - 381)) & ~0x1F) === 0 && ((1 << (_la - 381)) & 1055907839) !== 0) || ((((_la - 413)) & ~0x1F) === 0 && ((1 << (_la - 413)) & 4294885367) !== 0) || ((((_la - 445)) & ~0x1F) === 0 && ((1 << (_la - 445)) & 3757571071) !== 0) || ((((_la - 478)) & ~0x1F) === 0 && ((1 << (_la - 478)) & 3755999231) !== 0) || ((((_la - 510)) & ~0x1F) === 0 && ((1 << (_la - 510)) & 3751780349) !== 0) || ((((_la - 542)) & ~0x1F) === 0 && ((1 << (_la - 542)) & 2141183997) !== 0) || ((((_la - 575)) & ~0x1F) === 0 && ((1 << (_la - 575)) & 2147483629) !== 0) || ((((_la - 633)) & ~0x1F) === 0 && ((1 << (_la - 633)) & 4294934527) !== 0) || ((((_la - 665)) & ~0x1F) === 0 && ((1 << (_la - 665)) & 4278189053) !== 0) || ((((_la - 697)) & ~0x1F) === 0 && ((1 << (_la - 697)) & 1644099327) !== 0) || ((((_la - 729)) & ~0x1F) === 0 && ((1 << (_la - 729)) & 4294900735) !== 0) || ((((_la - 761)) & ~0x1F) === 0 && ((1 << (_la - 761)) & 4294967295) !== 0) || ((((_la - 793)) & ~0x1F) === 0 && ((1 << (_la - 793)) & 4288675839) !== 0) || ((((_la - 825)) & ~0x1F) === 0 && ((1 << (_la - 825)) & 2147527671) !== 0) || ((((_la - 879)) & ~0x1F) === 0 && ((1 << (_la - 879)) & 1033) !== 0)) { + { + this.state = 3817; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 13) { + { + this.state = 3816; + this.match(MySqlParser.KW_AS); + } + } + this.state = 3819; + localContext._table_alias = this.uid(); + } + } + this.state = 3822; + this.match(MySqlParser.KW_SET); + this.state = 3823; + this.updatedElement(); + this.state = 3828; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 3824; + this.match(MySqlParser.COMMA); + this.state = 3825; + this.updatedElement(); + } + } + this.state = 3830; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 3833; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 192) { + { + this.state = 3831; + this.match(MySqlParser.KW_WHERE); + this.state = 3832; + this.expression(0); + } + } + this.state = 3836; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 125) { + { + this.state = 3835; + this.orderByClause(); + } + } + this.state = 3839; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 100) { + { + this.state = 3838; + this.limitClause(); + } + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + multipleUpdateStatement() { + let localContext = new MultipleUpdateStatementContext(this.context, this.state); + this.enterRule(localContext, 250, MySqlParser.RULE_multipleUpdateStatement); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 3841; + this.match(MySqlParser.KW_UPDATE); + this.state = 3843; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 107) { + { + this.state = 3842; + localContext._priority = this.match(MySqlParser.KW_LOW_PRIORITY); + } + } + this.state = 3846; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 79) { + { + this.state = 3845; + this.match(MySqlParser.KW_IGNORE); + } + } + this.state = 3848; + this.tableSources(); + this.state = 3849; + this.match(MySqlParser.KW_SET); + this.state = 3850; + this.updatedElement(); + this.state = 3855; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 3851; + this.match(MySqlParser.COMMA); + this.state = 3852; + this.updatedElement(); + } + } + this.state = 3857; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 3860; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 192) { + { + this.state = 3858; + this.match(MySqlParser.KW_WHERE); + this.state = 3859; + this.expression(0); + } + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + orderByClause() { + let localContext = new OrderByClauseContext(this.context, this.state); + this.enterRule(localContext, 252, MySqlParser.RULE_orderByClause); + try { + let alternative; + this.enterOuterAlt(localContext, 1); + { + this.state = 3862; + this.match(MySqlParser.KW_ORDER); + this.state = 3863; + this.match(MySqlParser.KW_BY); + this.state = 3864; + this.orderByExpression(); + this.state = 3869; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 533, this.context); + while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER) { + if (alternative === 1) { + { + { + this.state = 3865; + this.match(MySqlParser.COMMA); + this.state = 3866; + this.orderByExpression(); + } + } + } + this.state = 3871; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 533, this.context); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + orderByExpression() { + let localContext = new OrderByExpressionContext(this.context, this.state); + this.enterRule(localContext, 254, MySqlParser.RULE_orderByExpression); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 3872; + this.expression(0); + this.state = 3874; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 534, this.context)) { + case 1: + { + this.state = 3873; + localContext._order = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 14 || _la === 45)) { + localContext._order = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + break; + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + tableSources() { + let localContext = new TableSourcesContext(this.context, this.state); + this.enterRule(localContext, 256, MySqlParser.RULE_tableSources); + try { + let alternative; + this.enterOuterAlt(localContext, 1); + { + this.state = 3876; + this.tableSource(); + this.state = 3881; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 535, this.context); + while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER) { + if (alternative === 1) { + { + { + this.state = 3877; + this.match(MySqlParser.COMMA); + this.state = 3878; + this.tableSource(); + } + } + } + this.state = 3883; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 535, this.context); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + tableSource() { + let localContext = new TableSourceContext(this.context, this.state); + this.enterRule(localContext, 258, MySqlParser.RULE_tableSource); + let _la; + try { + let alternative; + this.state = 3902; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 538, this.context)) { + case 1: + localContext = new TableSourceBaseContext(localContext); + this.enterOuterAlt(localContext, 1); + { + this.state = 3884; + this.tableSourceItem(); + this.state = 3888; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 536, this.context); + while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER) { + if (alternative === 1) { + { + { + this.state = 3885; + this.joinPart(); + } + } + } + this.state = 3890; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 536, this.context); + } + } + break; + case 2: + localContext = new TableSourceNestedContext(localContext); + this.enterOuterAlt(localContext, 2); + { + this.state = 3891; + this.match(MySqlParser.LR_BRACKET); + this.state = 3892; + this.tableSourceItem(); + this.state = 3896; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 35 || ((((_la - 84)) & ~0x1F) === 0 && ((1 << (_la - 84)) & 536887425) !== 0) || _la === 150 || _la === 172) { + { + { + this.state = 3893; + this.joinPart(); + } + } + this.state = 3898; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 3899; + this.match(MySqlParser.RR_BRACKET); + } + break; + case 3: + localContext = new TableJsonContext(localContext); + this.enterOuterAlt(localContext, 3); + { + this.state = 3901; + this.jsonTable(); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + tableSourceItem() { + let localContext = new TableSourceItemContext(this.context, this.state); + this.enterRule(localContext, 260, MySqlParser.RULE_tableSourceItem); + let _la; + try { + let alternative; + this.state = 3949; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 548, this.context)) { + case 1: + localContext = new AtomTableItemContext(localContext); + this.enterOuterAlt(localContext, 1); + { + this.state = 3904; + this.tableName(); + this.state = 3910; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 539, this.context)) { + case 1: + { + this.state = 3905; + this.match(MySqlParser.KW_PARTITION); + this.state = 3906; + this.match(MySqlParser.LR_BRACKET); + this.state = 3907; + this.partitionNames(); + this.state = 3908; + this.match(MySqlParser.RR_BRACKET); + } + break; + } + this.state = 3916; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 541, this.context)) { + case 1: + { + this.state = 3913; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 13) { + { + this.state = 3912; + this.match(MySqlParser.KW_AS); + } + } + this.state = 3915; + localContext._alias = this.uid(); + } + break; + } + this.state = 3926; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 543, this.context)) { + case 1: + { + this.state = 3918; + this.indexHint(); + this.state = 3923; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 542, this.context); + while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER) { + if (alternative === 1) { + { + { + this.state = 3919; + this.match(MySqlParser.COMMA); + this.state = 3920; + this.indexHint(); + } + } + } + this.state = 3925; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 542, this.context); + } + } + break; + } + } + break; + case 2: + localContext = new SubqueryTableItemContext(localContext); + this.enterOuterAlt(localContext, 2); + { + this.state = 3929; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 95) { + { + this.state = 3928; + this.match(MySqlParser.KW_LATERAL); + } + } + this.state = 3936; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 545, this.context)) { + case 1: + { + this.state = 3931; + this.selectStatement(); + } + break; + case 2: + { + this.state = 3932; + this.match(MySqlParser.LR_BRACKET); + this.state = 3933; + localContext._parenthesisSubquery = this.selectStatement(); + this.state = 3934; + this.match(MySqlParser.RR_BRACKET); + } + break; + } + this.state = 3939; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 13) { + { + this.state = 3938; + this.match(MySqlParser.KW_AS); + } + } + this.state = 3941; + localContext._alias = this.uid(); + this.state = 3943; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 547, this.context)) { + case 1: + { + this.state = 3942; + this.fullColumnNames(); + } + break; + } + } + break; + case 3: + localContext = new TableSourcesItemContext(localContext); + this.enterOuterAlt(localContext, 3); + { + this.state = 3945; + this.match(MySqlParser.LR_BRACKET); + this.state = 3946; + this.tableSources(); + this.state = 3947; + this.match(MySqlParser.RR_BRACKET); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + fullColumnNames() { + let localContext = new FullColumnNamesContext(this.context, this.state); + this.enterRule(localContext, 262, MySqlParser.RULE_fullColumnNames); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 3951; + this.match(MySqlParser.LR_BRACKET); + this.state = 3952; + this.columnNames(); + this.state = 3953; + this.match(MySqlParser.RR_BRACKET); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + indexHint() { + let localContext = new IndexHintContext(this.context, this.state); + this.enterRule(localContext, 264, MySqlParser.RULE_indexHint); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 3955; + localContext._indexHintAction = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 66 || _la === 79 || _la === 187)) { + localContext._indexHintAction = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 3956; + localContext._keyFormat = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 82 || _la === 92)) { + localContext._keyFormat = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 3959; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 65) { + { + this.state = 3957; + this.match(MySqlParser.KW_FOR); + this.state = 3958; + this.indexHintType(); + } + } + this.state = 3961; + this.match(MySqlParser.LR_BRACKET); + this.state = 3963; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if ((((_la) & ~0x1F) === 0 && ((1 << _la) & 1074302976) !== 0) || ((((_la - 36)) & ~0x1F) === 0 && ((1 << (_la - 36)) & 11014219) !== 0) || ((((_la - 74)) & ~0x1F) === 0 && ((1 << (_la - 74)) & 18878481) !== 0) || ((((_la - 117)) & ~0x1F) === 0 && ((1 << (_la - 117)) & 100679969) !== 0) || ((((_la - 150)) & ~0x1F) === 0 && ((1 << (_la - 150)) & 1049605) !== 0) || ((((_la - 219)) & ~0x1F) === 0 && ((1 << (_la - 219)) & 5374495) !== 0) || ((((_la - 253)) & ~0x1F) === 0 && ((1 << (_la - 253)) & 4294967295) !== 0) || ((((_la - 285)) & ~0x1F) === 0 && ((1 << (_la - 285)) & 4261412607) !== 0) || ((((_la - 317)) & ~0x1F) === 0 && ((1 << (_la - 317)) & 4160741375) !== 0) || ((((_la - 349)) & ~0x1F) === 0 && ((1 << (_la - 349)) & 4026531839) !== 0) || ((((_la - 381)) & ~0x1F) === 0 && ((1 << (_la - 381)) & 1055907839) !== 0) || ((((_la - 413)) & ~0x1F) === 0 && ((1 << (_la - 413)) & 4294885367) !== 0) || ((((_la - 445)) & ~0x1F) === 0 && ((1 << (_la - 445)) & 3757571071) !== 0) || ((((_la - 478)) & ~0x1F) === 0 && ((1 << (_la - 478)) & 3755999231) !== 0) || ((((_la - 510)) & ~0x1F) === 0 && ((1 << (_la - 510)) & 3751780349) !== 0) || ((((_la - 542)) & ~0x1F) === 0 && ((1 << (_la - 542)) & 2141183997) !== 0) || ((((_la - 575)) & ~0x1F) === 0 && ((1 << (_la - 575)) & 2147483629) !== 0) || ((((_la - 633)) & ~0x1F) === 0 && ((1 << (_la - 633)) & 4294934527) !== 0) || ((((_la - 665)) & ~0x1F) === 0 && ((1 << (_la - 665)) & 4278189053) !== 0) || ((((_la - 697)) & ~0x1F) === 0 && ((1 << (_la - 697)) & 1644099327) !== 0) || ((((_la - 729)) & ~0x1F) === 0 && ((1 << (_la - 729)) & 4294900735) !== 0) || ((((_la - 761)) & ~0x1F) === 0 && ((1 << (_la - 761)) & 4294967295) !== 0) || ((((_la - 793)) & ~0x1F) === 0 && ((1 << (_la - 793)) & 4288675839) !== 0) || ((((_la - 825)) & ~0x1F) === 0 && ((1 << (_la - 825)) & 2147527671) !== 0) || ((((_la - 879)) & ~0x1F) === 0 && ((1 << (_la - 879)) & 1033) !== 0)) { + { + this.state = 3962; + this.indexNames(); + } + } + this.state = 3965; + this.match(MySqlParser.RR_BRACKET); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + indexHintType() { + let localContext = new IndexHintTypeContext(this.context, this.state); + this.enterRule(localContext, 266, MySqlParser.RULE_indexHintType); + try { + this.state = 3972; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_JOIN: + this.enterOuterAlt(localContext, 1); + { + this.state = 3967; + this.match(MySqlParser.KW_JOIN); + } + break; + case MySqlParser.KW_ORDER: + this.enterOuterAlt(localContext, 2); + { + this.state = 3968; + this.match(MySqlParser.KW_ORDER); + this.state = 3969; + this.match(MySqlParser.KW_BY); + } + break; + case MySqlParser.KW_GROUP: + this.enterOuterAlt(localContext, 3); + { + this.state = 3970; + this.match(MySqlParser.KW_GROUP); + this.state = 3971; + this.match(MySqlParser.KW_BY); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + joinPart() { + let localContext = new JoinPartContext(this.context, this.state); + this.enterRule(localContext, 268, MySqlParser.RULE_joinPart); + let _la; + try { + let alternative; + this.state = 4023; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_CROSS: + case MySqlParser.KW_INNER: + case MySqlParser.KW_JOIN: + localContext = new InnerJoinContext(localContext); + this.enterOuterAlt(localContext, 1); + { + this.state = 3975; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 35 || _la === 84) { + { + this.state = 3974; + _la = this.tokenStream.LA(1); + if (!(_la === 35 || _la === 84)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + this.state = 3977; + this.match(MySqlParser.KW_JOIN); + this.state = 3979; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 553, this.context)) { + case 1: + { + this.state = 3978; + this.match(MySqlParser.KW_LATERAL); + } + break; + } + this.state = 3981; + this.tableSourceItem(); + this.state = 3985; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 554, this.context); + while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER) { + if (alternative === 1) { + { + { + this.state = 3982; + this.joinSpec(); + } + } + } + this.state = 3987; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 554, this.context); + } + } + break; + case MySqlParser.KW_STRAIGHT_JOIN: + localContext = new StraightJoinContext(localContext); + this.enterOuterAlt(localContext, 2); + { + this.state = 3988; + this.match(MySqlParser.KW_STRAIGHT_JOIN); + this.state = 3989; + this.tableSourceItem(); + this.state = 3993; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 555, this.context); + while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER) { + if (alternative === 1) { + { + { + this.state = 3990; + this.joinSpec(); + } + } + } + this.state = 3995; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 555, this.context); + } + } + break; + case MySqlParser.KW_LEFT: + case MySqlParser.KW_RIGHT: + localContext = new OuterJoinContext(localContext); + this.enterOuterAlt(localContext, 3); + { + this.state = 3996; + _la = this.tokenStream.LA(1); + if (!(_la === 98 || _la === 150)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 3998; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 127) { + { + this.state = 3997; + this.match(MySqlParser.KW_OUTER); + } + } + this.state = 4000; + this.match(MySqlParser.KW_JOIN); + this.state = 4002; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 557, this.context)) { + case 1: + { + this.state = 4001; + this.match(MySqlParser.KW_LATERAL); + } + break; + } + this.state = 4004; + this.tableSourceItem(); + this.state = 4008; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 558, this.context); + while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER) { + if (alternative === 1) { + { + { + this.state = 4005; + this.joinSpec(); + } + } + } + this.state = 4010; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 558, this.context); + } + } + break; + case MySqlParser.KW_NATURAL: + localContext = new NaturalJoinContext(localContext); + this.enterOuterAlt(localContext, 4); + { + this.state = 4011; + this.match(MySqlParser.KW_NATURAL); + this.state = 4019; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 84 || _la === 98 || _la === 150) { + { + this.state = 4014; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_INNER: + { + this.state = 4012; + this.match(MySqlParser.KW_INNER); + } + break; + case MySqlParser.KW_LEFT: + case MySqlParser.KW_RIGHT: + { + this.state = 4013; + _la = this.tokenStream.LA(1); + if (!(_la === 98 || _la === 150)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + break; + default: + throw new antlr.NoViableAltException(this); + } + this.state = 4017; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 127) { + { + this.state = 4016; + this.match(MySqlParser.KW_OUTER); + } + } + } + } + this.state = 4021; + this.match(MySqlParser.KW_JOIN); + this.state = 4022; + this.tableSourceItem(); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + joinSpec() { + let localContext = new JoinSpecContext(this.context, this.state); + this.enterRule(localContext, 270, MySqlParser.RULE_joinSpec); + try { + this.state = 4032; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_ON: + this.enterOuterAlt(localContext, 1); + { + { + this.state = 4025; + this.match(MySqlParser.KW_ON); + this.state = 4026; + this.expression(0); + } + } + break; + case MySqlParser.KW_USING: + this.enterOuterAlt(localContext, 2); + { + this.state = 4027; + this.match(MySqlParser.KW_USING); + this.state = 4028; + this.match(MySqlParser.LR_BRACKET); + this.state = 4029; + this.columnNames(); + this.state = 4030; + this.match(MySqlParser.RR_BRACKET); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + queryExpression() { + let localContext = new QueryExpressionContext(this.context, this.state); + this.enterRule(localContext, 272, MySqlParser.RULE_queryExpression); + try { + this.state = 4042; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 564, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 4034; + this.match(MySqlParser.LR_BRACKET); + this.state = 4035; + this.querySpecification(); + this.state = 4036; + this.match(MySqlParser.RR_BRACKET); + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 4038; + this.match(MySqlParser.LR_BRACKET); + this.state = 4039; + this.queryExpression(); + this.state = 4040; + this.match(MySqlParser.RR_BRACKET); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + querySpecification() { + let localContext = new QuerySpecificationContext(this.context, this.state); + this.enterRule(localContext, 274, MySqlParser.RULE_querySpecification); + try { + let alternative; + this.enterOuterAlt(localContext, 1); + { + this.state = 4044; + this.match(MySqlParser.KW_SELECT); + this.state = 4048; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 565, this.context); + while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER) { + if (alternative === 1) { + { + { + this.state = 4045; + this.selectSpec(); + } + } + } + this.state = 4050; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 565, this.context); + } + this.state = 4051; + this.selectElements(); + this.state = 4053; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 566, this.context)) { + case 1: + { + this.state = 4052; + this.intoClause(); + } + break; + } + this.state = 4055; + this.fromClause(); + this.state = 4057; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 567, this.context)) { + case 1: + { + this.state = 4056; + this.groupByClause(); + } + break; + } + this.state = 4060; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 568, this.context)) { + case 1: + { + this.state = 4059; + this.havingClause(); + } + break; + } + this.state = 4063; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 569, this.context)) { + case 1: + { + this.state = 4062; + this.windowClause(); + } + break; + } + this.state = 4066; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 570, this.context)) { + case 1: + { + this.state = 4065; + this.orderByClause(); + } + break; + } + this.state = 4069; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 571, this.context)) { + case 1: + { + this.state = 4068; + this.limitClause(); + } + break; + } + this.state = 4072; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 572, this.context)) { + case 1: + { + this.state = 4071; + this.intoClause(); + } + break; + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + unionStatement() { + let localContext = new UnionStatementContext(this.context, this.state); + this.enterRule(localContext, 276, MySqlParser.RULE_unionStatement); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 4074; + this.match(MySqlParser.KW_UNION); + this.state = 4076; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 7 || _la === 49) { + { + this.state = 4075; + localContext._unionType = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 7 || _la === 49)) { + localContext._unionType = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + this.state = 4080; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_SELECT: + { + this.state = 4078; + this.querySpecification(); + } + break; + case MySqlParser.LR_BRACKET: + { + this.state = 4079; + this.queryExpression(); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + lateralStatement() { + let localContext = new LateralStatementContext(this.context, this.state); + this.enterRule(localContext, 278, MySqlParser.RULE_lateralStatement); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 4082; + this.match(MySqlParser.KW_LATERAL); + this.state = 4097; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 578, this.context)) { + case 1: + { + this.state = 4083; + this.querySpecification(); + } + break; + case 2: + { + this.state = 4084; + this.queryExpression(); + } + break; + case 3: + { + { + this.state = 4085; + this.match(MySqlParser.LR_BRACKET); + this.state = 4088; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_SELECT: + { + this.state = 4086; + this.querySpecification(); + } + break; + case MySqlParser.LR_BRACKET: + { + this.state = 4087; + this.queryExpression(); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + this.state = 4090; + this.match(MySqlParser.RR_BRACKET); + this.state = 4095; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 577, this.context)) { + case 1: + { + this.state = 4092; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 13) { + { + this.state = 4091; + this.match(MySqlParser.KW_AS); + } + } + this.state = 4094; + localContext._alias = this.uid(); + } + break; + } + } + } + break; + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + jsonTable() { + let localContext = new JsonTableContext(this.context, this.state); + this.enterRule(localContext, 280, MySqlParser.RULE_jsonTable); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 4099; + this.match(MySqlParser.KW_JSON_TABLE); + this.state = 4100; + this.match(MySqlParser.LR_BRACKET); + this.state = 4101; + this.match(MySqlParser.STRING_LITERAL); + this.state = 4102; + this.match(MySqlParser.COMMA); + this.state = 4103; + this.match(MySqlParser.STRING_LITERAL); + this.state = 4104; + this.match(MySqlParser.KW_COLUMNS); + this.state = 4105; + this.match(MySqlParser.LR_BRACKET); + this.state = 4106; + this.jsonColumnList(); + this.state = 4107; + this.match(MySqlParser.RR_BRACKET); + this.state = 4108; + this.match(MySqlParser.RR_BRACKET); + this.state = 4113; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 580, this.context)) { + case 1: + { + this.state = 4110; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 13) { + { + this.state = 4109; + this.match(MySqlParser.KW_AS); + } + } + this.state = 4112; + localContext._alias = this.uid(); + } + break; + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + jsonColumnList() { + let localContext = new JsonColumnListContext(this.context, this.state); + this.enterRule(localContext, 282, MySqlParser.RULE_jsonColumnList); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 4115; + this.jsonColumn(); + this.state = 4120; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 4116; + this.match(MySqlParser.COMMA); + this.state = 4117; + this.jsonColumn(); + } + } + this.state = 4122; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + jsonColumn() { + let localContext = new JsonColumnContext(this.context, this.state); + this.enterRule(localContext, 284, MySqlParser.RULE_jsonColumn); + let _la; + try { + this.state = 4152; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 587, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 4123; + this.columnName(); + this.state = 4140; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_FOR: + { + this.state = 4124; + this.match(MySqlParser.KW_FOR); + this.state = 4125; + this.match(MySqlParser.KW_ORDINALITY); + } + break; + case MySqlParser.KW_CHARACTER: + case MySqlParser.KW_SET: + case MySqlParser.KW_TINYINT: + case MySqlParser.KW_SMALLINT: + case MySqlParser.KW_MEDIUMINT: + case MySqlParser.KW_MIDDLEINT: + case MySqlParser.KW_INT: + case MySqlParser.KW_INT1: + case MySqlParser.KW_INT2: + case MySqlParser.KW_INT3: + case MySqlParser.KW_INT4: + case MySqlParser.KW_INT8: + case MySqlParser.KW_INTEGER: + case MySqlParser.KW_BIGINT: + case MySqlParser.KW_REAL: + case MySqlParser.KW_DOUBLE: + case MySqlParser.KW_FLOAT: + case MySqlParser.KW_FLOAT4: + case MySqlParser.KW_FLOAT8: + case MySqlParser.KW_DECIMAL: + case MySqlParser.KW_DEC: + case MySqlParser.KW_NUMERIC: + case MySqlParser.KW_DATE: + case MySqlParser.KW_TIME: + case MySqlParser.KW_TIMESTAMP: + case MySqlParser.KW_DATETIME: + case MySqlParser.KW_YEAR: + case MySqlParser.KW_CHAR: + case MySqlParser.KW_VARCHAR: + case MySqlParser.KW_NVARCHAR: + case MySqlParser.KW_NATIONAL: + case MySqlParser.KW_BINARY: + case MySqlParser.KW_VARBINARY: + case MySqlParser.KW_TINYBLOB: + case MySqlParser.KW_BLOB: + case MySqlParser.KW_MEDIUMBLOB: + case MySqlParser.KW_LONG: + case MySqlParser.KW_LONGBLOB: + case MySqlParser.KW_TINYTEXT: + case MySqlParser.KW_TEXT: + case MySqlParser.KW_MEDIUMTEXT: + case MySqlParser.KW_LONGTEXT: + case MySqlParser.KW_ENUM: + case MySqlParser.KW_SERIAL: + case MySqlParser.KW_BIT: + case MySqlParser.KW_BOOL: + case MySqlParser.KW_BOOLEAN: + case MySqlParser.KW_FIXED: + case MySqlParser.KW_JSON: + case MySqlParser.KW_NCHAR: + case MySqlParser.KW_GEOMETRYCOLLECTION: + case MySqlParser.KW_GEOMCOLLECTION: + case MySqlParser.KW_GEOMETRY: + case MySqlParser.KW_LINESTRING: + case MySqlParser.KW_MULTILINESTRING: + case MySqlParser.KW_MULTIPOINT: + case MySqlParser.KW_MULTIPOLYGON: + case MySqlParser.KW_POINT: + case MySqlParser.KW_POLYGON: + { + this.state = 4126; + this.dataType(); + this.state = 4138; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_PATH: + { + this.state = 4127; + this.match(MySqlParser.KW_PATH); + this.state = 4128; + this.match(MySqlParser.STRING_LITERAL); + this.state = 4130; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 582, this.context)) { + case 1: + { + this.state = 4129; + this.jsonOnEmpty(); + } + break; + } + this.state = 4133; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 42 || _la === 116 || _la === 382) { + { + this.state = 4132; + this.jsonOnError(); + } + } + } + break; + case MySqlParser.KW_EXISTS: + { + this.state = 4135; + this.match(MySqlParser.KW_EXISTS); + this.state = 4136; + this.match(MySqlParser.KW_PATH); + this.state = 4137; + this.match(MySqlParser.STRING_LITERAL); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 4142; + this.match(MySqlParser.KW_NESTED); + this.state = 4144; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 257) { + { + this.state = 4143; + this.match(MySqlParser.KW_PATH); + } + } + this.state = 4146; + this.match(MySqlParser.STRING_LITERAL); + this.state = 4147; + this.match(MySqlParser.KW_COLUMNS); + this.state = 4148; + this.match(MySqlParser.LR_BRACKET); + this.state = 4149; + this.jsonColumnList(); + this.state = 4150; + this.match(MySqlParser.RR_BRACKET); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + jsonOnEmpty() { + let localContext = new JsonOnEmptyContext(this.context, this.state); + this.enterRule(localContext, 286, MySqlParser.RULE_jsonOnEmpty); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 4158; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_NULL_LITERAL: + { + this.state = 4154; + this.match(MySqlParser.KW_NULL_LITERAL); + } + break; + case MySqlParser.KW_ERROR: + { + this.state = 4155; + this.match(MySqlParser.KW_ERROR); + } + break; + case MySqlParser.KW_DEFAULT: + { + this.state = 4156; + this.match(MySqlParser.KW_DEFAULT); + this.state = 4157; + this.defaultValue(); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + this.state = 4160; + this.match(MySqlParser.KW_ON); + this.state = 4161; + this.match(MySqlParser.KW_EMPTY); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + jsonOnError() { + let localContext = new JsonOnErrorContext(this.context, this.state); + this.enterRule(localContext, 288, MySqlParser.RULE_jsonOnError); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 4167; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_NULL_LITERAL: + { + this.state = 4163; + this.match(MySqlParser.KW_NULL_LITERAL); + } + break; + case MySqlParser.KW_ERROR: + { + this.state = 4164; + this.match(MySqlParser.KW_ERROR); + } + break; + case MySqlParser.KW_DEFAULT: + { + this.state = 4165; + this.match(MySqlParser.KW_DEFAULT); + this.state = 4166; + this.defaultValue(); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + this.state = 4169; + this.match(MySqlParser.KW_ON); + this.state = 4170; + this.match(MySqlParser.KW_ERROR); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + selectSpec() { + let localContext = new SelectSpecContext(this.context, this.state); + this.enterRule(localContext, 290, MySqlParser.RULE_selectSpec); + let _la; + try { + this.state = 4180; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_ALL: + case MySqlParser.KW_DISTINCT: + case MySqlParser.KW_DISTINCTROW: + this.enterOuterAlt(localContext, 1); + { + this.state = 4172; + _la = this.tokenStream.LA(1); + if (!(_la === 7 || _la === 49 || _la === 50)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + break; + case MySqlParser.KW_HIGH_PRIORITY: + this.enterOuterAlt(localContext, 2); + { + this.state = 4173; + this.match(MySqlParser.KW_HIGH_PRIORITY); + } + break; + case MySqlParser.KW_STRAIGHT_JOIN: + this.enterOuterAlt(localContext, 3); + { + this.state = 4174; + this.match(MySqlParser.KW_STRAIGHT_JOIN); + } + break; + case MySqlParser.KW_SQL_SMALL_RESULT: + this.enterOuterAlt(localContext, 4); + { + this.state = 4175; + this.match(MySqlParser.KW_SQL_SMALL_RESULT); + } + break; + case MySqlParser.KW_SQL_BIG_RESULT: + this.enterOuterAlt(localContext, 5); + { + this.state = 4176; + this.match(MySqlParser.KW_SQL_BIG_RESULT); + } + break; + case MySqlParser.KW_SQL_BUFFER_RESULT: + this.enterOuterAlt(localContext, 6); + { + this.state = 4177; + this.match(MySqlParser.KW_SQL_BUFFER_RESULT); + } + break; + case MySqlParser.KW_SQL_CACHE: + case MySqlParser.KW_SQL_NO_CACHE: + this.enterOuterAlt(localContext, 7); + { + this.state = 4178; + _la = this.tokenStream.LA(1); + if (!(_la === 637 || _la === 638)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + break; + case MySqlParser.KW_SQL_CALC_FOUND_ROWS: + this.enterOuterAlt(localContext, 8); + { + this.state = 4179; + this.match(MySqlParser.KW_SQL_CALC_FOUND_ROWS); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + selectElements() { + let localContext = new SelectElementsContext(this.context, this.state); + this.enterRule(localContext, 292, MySqlParser.RULE_selectElements); + try { + let alternative; + this.enterOuterAlt(localContext, 1); + { + this.state = 4184; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 591, this.context)) { + case 1: + { + this.state = 4182; + localContext._star = this.match(MySqlParser.STAR); + } + break; + case 2: + { + this.state = 4183; + this.selectElement(); + } + break; + } + this.state = 4190; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 592, this.context); + while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER) { + if (alternative === 1) { + { + { + this.state = 4186; + this.match(MySqlParser.COMMA); + this.state = 4187; + this.selectElement(); + } + } + } + this.state = 4192; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 592, this.context); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + selectElement() { + let localContext = new SelectElementContext(this.context, this.state); + this.enterRule(localContext, 294, MySqlParser.RULE_selectElement); + let _la; + try { + this.state = 4222; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 600, this.context)) { + case 1: + localContext = new SelectExpressionElementContext(localContext); + this.enterOuterAlt(localContext, 1); + { + this.state = 4195; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 593, this.context)) { + case 1: + { + this.state = 4193; + this.match(MySqlParser.LOCAL_ID); + this.state = 4194; + this.match(MySqlParser.VAR_ASSIGN); + } + break; + } + this.state = 4197; + this.expression(0); + this.state = 4202; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 595, this.context)) { + case 1: + { + this.state = 4199; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 13) { + { + this.state = 4198; + this.match(MySqlParser.KW_AS); + } + } + this.state = 4201; + localContext._alias = this.uid(); + } + break; + } + } + break; + case 2: + localContext = new SelectFunctionElementContext(localContext); + this.enterOuterAlt(localContext, 2); + { + this.state = 4204; + this.functionCall(); + this.state = 4209; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 597, this.context)) { + case 1: + { + this.state = 4206; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 13) { + { + this.state = 4205; + this.match(MySqlParser.KW_AS); + } + } + this.state = 4208; + localContext._alias = this.uid(); + } + break; + } + } + break; + case 3: + localContext = new SelectStarElementContext(localContext); + this.enterOuterAlt(localContext, 3); + { + this.state = 4211; + localContext._select_element = this.fullId(); + this.state = 4212; + this.match(MySqlParser.DOT); + this.state = 4213; + this.match(MySqlParser.STAR); + } + break; + case 4: + localContext = new SelectColumnElementContext(localContext); + this.enterOuterAlt(localContext, 4); + { + this.state = 4215; + this.columnName(); + this.state = 4220; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 599, this.context)) { + case 1: + { + this.state = 4217; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 13) { + { + this.state = 4216; + this.match(MySqlParser.KW_AS); + } + } + this.state = 4219; + localContext._alias = this.uid(); + } + break; + } + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + intoClause() { + let localContext = new IntoClauseContext(this.context, this.state); + this.enterRule(localContext, 296, MySqlParser.RULE_intoClause); + let _la; + try { + let alternative; + this.state = 4260; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 607, this.context)) { + case 1: + localContext = new SelectIntoVariablesContext(localContext); + this.enterOuterAlt(localContext, 1); + { + this.state = 4224; + this.match(MySqlParser.KW_INTO); + this.state = 4225; + this.assignmentField(); + this.state = 4230; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 601, this.context); + while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER) { + if (alternative === 1) { + { + { + this.state = 4226; + this.match(MySqlParser.COMMA); + this.state = 4227; + this.assignmentField(); + } + } + } + this.state = 4232; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 601, this.context); + } + } + break; + case 2: + localContext = new SelectIntoDumpFileContext(localContext); + this.enterOuterAlt(localContext, 2); + { + this.state = 4233; + this.match(MySqlParser.KW_INTO); + this.state = 4234; + this.match(MySqlParser.KW_DUMPFILE); + this.state = 4235; + this.match(MySqlParser.STRING_LITERAL); + } + break; + case 3: + localContext = new SelectIntoTextFileContext(localContext); + this.enterOuterAlt(localContext, 3); + { + { + this.state = 4236; + this.match(MySqlParser.KW_INTO); + this.state = 4237; + this.match(MySqlParser.KW_OUTFILE); + this.state = 4238; + localContext._filename = this.match(MySqlParser.STRING_LITERAL); + this.state = 4242; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 602, this.context)) { + case 1: + { + this.state = 4239; + this.match(MySqlParser.KW_CHARACTER); + this.state = 4240; + this.match(MySqlParser.KW_SET); + this.state = 4241; + localContext._charset = this.charsetName(); + } + break; + } + this.state = 4250; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 604, this.context)) { + case 1: + { + this.state = 4244; + localContext._fieldsFormat = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 337 || _la === 398)) { + localContext._fieldsFormat = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 4246; + this.errorHandler.sync(this); + alternative = 1; + do { + switch (alternative) { + case 1: + { + { + this.state = 4245; + this.selectFieldsInto(); + } + } + break; + default: + throw new antlr.NoViableAltException(this); + } + this.state = 4248; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 603, this.context); + } while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER); + } + break; + } + this.state = 4258; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 606, this.context)) { + case 1: + { + this.state = 4252; + this.match(MySqlParser.KW_LINES); + this.state = 4254; + this.errorHandler.sync(this); + alternative = 1; + do { + switch (alternative) { + case 1: + { + { + this.state = 4253; + this.selectLinesInto(); + } + } + break; + default: + throw new antlr.NoViableAltException(this); + } + this.state = 4256; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 605, this.context); + } while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER); + } + break; + } + } + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + selectFieldsInto() { + let localContext = new SelectFieldsIntoContext(this.context, this.state); + this.enterRule(localContext, 298, MySqlParser.RULE_selectFieldsInto); + let _la; + try { + this.state = 4274; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_TERMINATED: + this.enterOuterAlt(localContext, 1); + { + this.state = 4262; + this.match(MySqlParser.KW_TERMINATED); + this.state = 4263; + this.match(MySqlParser.KW_BY); + this.state = 4264; + localContext._terminationField = this.match(MySqlParser.STRING_LITERAL); + } + break; + case MySqlParser.KW_ENCLOSED: + case MySqlParser.KW_OPTIONALLY: + this.enterOuterAlt(localContext, 2); + { + this.state = 4266; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 123) { + { + this.state = 4265; + this.match(MySqlParser.KW_OPTIONALLY); + } + } + this.state = 4268; + this.match(MySqlParser.KW_ENCLOSED); + this.state = 4269; + this.match(MySqlParser.KW_BY); + this.state = 4270; + localContext._enclosion = this.match(MySqlParser.STRING_LITERAL); + } + break; + case MySqlParser.KW_ESCAPED: + this.enterOuterAlt(localContext, 3); + { + this.state = 4271; + this.match(MySqlParser.KW_ESCAPED); + this.state = 4272; + this.match(MySqlParser.KW_BY); + this.state = 4273; + localContext._escaping = this.match(MySqlParser.STRING_LITERAL); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + selectLinesInto() { + let localContext = new SelectLinesIntoContext(this.context, this.state); + this.enterRule(localContext, 300, MySqlParser.RULE_selectLinesInto); + try { + this.state = 4282; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_STARTING: + this.enterOuterAlt(localContext, 1); + { + this.state = 4276; + this.match(MySqlParser.KW_STARTING); + this.state = 4277; + this.match(MySqlParser.KW_BY); + this.state = 4278; + localContext._starting = this.match(MySqlParser.STRING_LITERAL); + } + break; + case MySqlParser.KW_TERMINATED: + this.enterOuterAlt(localContext, 2); + { + this.state = 4279; + this.match(MySqlParser.KW_TERMINATED); + this.state = 4280; + this.match(MySqlParser.KW_BY); + this.state = 4281; + localContext._terminationLine = this.match(MySqlParser.STRING_LITERAL); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + fromClause() { + let localContext = new FromClauseContext(this.context, this.state); + this.enterRule(localContext, 302, MySqlParser.RULE_fromClause); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 4286; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 611, this.context)) { + case 1: + { + this.state = 4284; + this.match(MySqlParser.KW_FROM); + this.state = 4285; + this.tableSources(); + } + break; + } + this.state = 4290; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 612, this.context)) { + case 1: + { + this.state = 4288; + this.match(MySqlParser.KW_WHERE); + this.state = 4289; + localContext._whereExpr = this.expression(0); + } + break; + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + groupByClause() { + let localContext = new GroupByClauseContext(this.context, this.state); + this.enterRule(localContext, 304, MySqlParser.RULE_groupByClause); + try { + let alternative; + this.enterOuterAlt(localContext, 1); + { + this.state = 4292; + this.match(MySqlParser.KW_GROUP); + this.state = 4293; + this.match(MySqlParser.KW_BY); + this.state = 4294; + this.groupByItem(); + this.state = 4299; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 613, this.context); + while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER) { + if (alternative === 1) { + { + { + this.state = 4295; + this.match(MySqlParser.COMMA); + this.state = 4296; + this.groupByItem(); + } + } + } + this.state = 4301; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 613, this.context); + } + this.state = 4304; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 614, this.context)) { + case 1: + { + this.state = 4302; + this.match(MySqlParser.KW_WITH); + this.state = 4303; + this.match(MySqlParser.KW_ROLLUP); + } + break; + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + havingClause() { + let localContext = new HavingClauseContext(this.context, this.state); + this.enterRule(localContext, 306, MySqlParser.RULE_havingClause); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 4306; + this.match(MySqlParser.KW_HAVING); + this.state = 4307; + localContext._havingExpr = this.expression(0); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + windowClause() { + let localContext = new WindowClauseContext(this.context, this.state); + this.enterRule(localContext, 308, MySqlParser.RULE_windowClause); + try { + let alternative; + this.enterOuterAlt(localContext, 1); + { + this.state = 4309; + this.match(MySqlParser.KW_WINDOW); + this.state = 4310; + this.windowName(); + this.state = 4311; + this.match(MySqlParser.KW_AS); + this.state = 4312; + this.match(MySqlParser.LR_BRACKET); + this.state = 4313; + this.windowSpec(); + this.state = 4314; + this.match(MySqlParser.RR_BRACKET); + this.state = 4324; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 615, this.context); + while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER) { + if (alternative === 1) { + { + { + this.state = 4315; + this.match(MySqlParser.COMMA); + this.state = 4316; + this.windowName(); + this.state = 4317; + this.match(MySqlParser.KW_AS); + this.state = 4318; + this.match(MySqlParser.LR_BRACKET); + this.state = 4319; + this.windowSpec(); + this.state = 4320; + this.match(MySqlParser.RR_BRACKET); + } + } + } + this.state = 4326; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 615, this.context); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + groupByItem() { + let localContext = new GroupByItemContext(this.context, this.state); + this.enterRule(localContext, 310, MySqlParser.RULE_groupByItem); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 4327; + this.expression(0); + this.state = 4329; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 616, this.context)) { + case 1: + { + this.state = 4328; + localContext._order = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 14 || _la === 45)) { + localContext._order = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + break; + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + limitClause() { + let localContext = new LimitClauseContext(this.context, this.state); + this.enterRule(localContext, 312, MySqlParser.RULE_limitClause); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 4331; + this.match(MySqlParser.KW_LIMIT); + this.state = 4342; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 618, this.context)) { + case 1: + { + this.state = 4335; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 617, this.context)) { + case 1: + { + this.state = 4332; + localContext._offset = this.limitClauseAtom(); + this.state = 4333; + this.match(MySqlParser.COMMA); + } + break; + } + this.state = 4337; + localContext._limit = this.limitClauseAtom(); + } + break; + case 2: + { + this.state = 4338; + localContext._limit = this.limitClauseAtom(); + this.state = 4339; + this.match(MySqlParser.KW_OFFSET); + this.state = 4340; + localContext._offset = this.limitClauseAtom(); + } + break; + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + limitClauseAtom() { + let localContext = new LimitClauseAtomContext(this.context, this.state); + this.enterRule(localContext, 314, MySqlParser.RULE_limitClauseAtom); + try { + this.state = 4347; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.ZERO_DECIMAL: + case MySqlParser.ONE_DECIMAL: + case MySqlParser.TWO_DECIMAL: + case MySqlParser.THREE_DECIMAL: + case MySqlParser.DECIMAL_LITERAL: + case MySqlParser.REAL_LITERAL: + this.enterOuterAlt(localContext, 1); + { + this.state = 4344; + this.decimalLiteral(); + } + break; + case MySqlParser.LOCAL_ID: + case MySqlParser.GLOBAL_ID: + this.enterOuterAlt(localContext, 2); + { + this.state = 4345; + this.mysqlVariable(); + } + break; + case MySqlParser.KW_ARRAY: + case MySqlParser.KW_ATTRIBUTE: + case MySqlParser.KW_BUCKETS: + case MySqlParser.KW_CONDITION: + case MySqlParser.KW_CURRENT: + case MySqlParser.KW_CURRENT_USER: + case MySqlParser.KW_DATABASE: + case MySqlParser.KW_DEFAULT: + case MySqlParser.KW_DIAGNOSTICS: + case MySqlParser.KW_EMPTY: + case MySqlParser.KW_ENFORCED: + case MySqlParser.KW_EXCEPT: + case MySqlParser.KW_GROUP: + case MySqlParser.KW_IF: + case MySqlParser.KW_INSERT: + case MySqlParser.KW_LATERAL: + case MySqlParser.KW_LEFT: + case MySqlParser.KW_NUMBER: + case MySqlParser.KW_OPTIONAL: + case MySqlParser.KW_ORDER: + case MySqlParser.KW_PRIMARY: + case MySqlParser.KW_REPEAT: + case MySqlParser.KW_REPLACE: + case MySqlParser.KW_RIGHT: + case MySqlParser.KW_SCHEMA: + case MySqlParser.KW_SKIP_QUERY_REWRITE: + case MySqlParser.KW_STACKED: + case MySqlParser.KW_DATE: + case MySqlParser.KW_TIME: + case MySqlParser.KW_TIMESTAMP: + case MySqlParser.KW_DATETIME: + case MySqlParser.KW_YEAR: + case MySqlParser.KW_BINARY: + case MySqlParser.KW_TEXT: + case MySqlParser.KW_ENUM: + case MySqlParser.KW_SERIAL: + case MySqlParser.KW_JSON_TABLE: + case MySqlParser.KW_JSON_VALUE: + case MySqlParser.KW_NESTED: + case MySqlParser.KW_ORDINALITY: + case MySqlParser.KW_PATH: + case MySqlParser.KW_AVG: + case MySqlParser.KW_BIT_AND: + case MySqlParser.KW_BIT_OR: + case MySqlParser.KW_BIT_XOR: + case MySqlParser.KW_COUNT: + case MySqlParser.KW_CUME_DIST: + case MySqlParser.KW_DENSE_RANK: + case MySqlParser.KW_FIRST_VALUE: + case MySqlParser.KW_GROUP_CONCAT: + case MySqlParser.KW_LAG: + case MySqlParser.KW_LAST_VALUE: + case MySqlParser.KW_LEAD: + case MySqlParser.KW_MAX: + case MySqlParser.KW_MIN: + case MySqlParser.KW_NTILE: + case MySqlParser.KW_NTH_VALUE: + case MySqlParser.KW_PERCENT_RANK: + case MySqlParser.KW_RANK: + case MySqlParser.KW_ROW_NUMBER: + case MySqlParser.KW_STD: + case MySqlParser.KW_STDDEV: + case MySqlParser.KW_STDDEV_POP: + case MySqlParser.KW_STDDEV_SAMP: + case MySqlParser.KW_SUM: + case MySqlParser.KW_VAR_POP: + case MySqlParser.KW_VAR_SAMP: + case MySqlParser.KW_VARIANCE: + case MySqlParser.KW_CURRENT_DATE: + case MySqlParser.KW_CURRENT_TIME: + case MySqlParser.KW_CURRENT_TIMESTAMP: + case MySqlParser.KW_LOCALTIME: + case MySqlParser.KW_CURDATE: + case MySqlParser.KW_CURTIME: + case MySqlParser.KW_DATE_ADD: + case MySqlParser.KW_DATE_SUB: + case MySqlParser.KW_LOCALTIMESTAMP: + case MySqlParser.KW_NOW: + case MySqlParser.KW_POSITION: + case MySqlParser.KW_SUBSTR: + case MySqlParser.KW_SUBSTRING: + case MySqlParser.KW_SYSDATE: + case MySqlParser.KW_TRIM: + case MySqlParser.KW_UTC_DATE: + case MySqlParser.KW_UTC_TIME: + case MySqlParser.KW_UTC_TIMESTAMP: + case MySqlParser.KW_ACCOUNT: + case MySqlParser.KW_ACTION: + case MySqlParser.KW_AFTER: + case MySqlParser.KW_AGGREGATE: + case MySqlParser.KW_ALGORITHM: + case MySqlParser.KW_ANY: + case MySqlParser.KW_AT: + case MySqlParser.KW_AUTHORS: + case MySqlParser.KW_AUTOCOMMIT: + case MySqlParser.KW_AUTOEXTEND_SIZE: + case MySqlParser.KW_AUTO_INCREMENT: + case MySqlParser.KW_AVG_ROW_LENGTH: + case MySqlParser.KW_BEGIN: + case MySqlParser.KW_BINLOG: + case MySqlParser.KW_BIT: + case MySqlParser.KW_BLOCK: + case MySqlParser.KW_BOOL: + case MySqlParser.KW_BOOLEAN: + case MySqlParser.KW_BTREE: + case MySqlParser.KW_CACHE: + case MySqlParser.KW_CASCADED: + case MySqlParser.KW_CHAIN: + case MySqlParser.KW_CHANGED: + case MySqlParser.KW_CHANNEL: + case MySqlParser.KW_CHECKSUM: + case MySqlParser.KW_CIPHER: + case MySqlParser.KW_CLASS_ORIGIN: + case MySqlParser.KW_CLIENT: + case MySqlParser.KW_CLOSE: + case MySqlParser.KW_COALESCE: + case MySqlParser.KW_CODE: + case MySqlParser.KW_COLUMNS: + case MySqlParser.KW_COLUMN_FORMAT: + case MySqlParser.KW_COLUMN_NAME: + case MySqlParser.KW_COMMENT: + case MySqlParser.KW_COMMIT: + case MySqlParser.KW_COMPACT: + case MySqlParser.KW_COMPLETION: + case MySqlParser.KW_COMPRESSED: + case MySqlParser.KW_COMPRESSION: + case MySqlParser.KW_CONCURRENT: + case MySqlParser.KW_CONNECT: + case MySqlParser.KW_CONNECTION: + case MySqlParser.KW_CONSISTENT: + case MySqlParser.KW_CONSTRAINT_CATALOG: + case MySqlParser.KW_CONSTRAINT_SCHEMA: + case MySqlParser.KW_CONSTRAINT_NAME: + case MySqlParser.KW_CONTAINS: + case MySqlParser.KW_CONTEXT: + case MySqlParser.KW_CONTRIBUTORS: + case MySqlParser.KW_COPY: + case MySqlParser.KW_CPU: + case MySqlParser.KW_CURSOR_NAME: + case MySqlParser.KW_DATA: + case MySqlParser.KW_DATAFILE: + case MySqlParser.KW_DEALLOCATE: + case MySqlParser.KW_DEFAULT_AUTH: + case MySqlParser.KW_DEFINER: + case MySqlParser.KW_DELAY_KEY_WRITE: + case MySqlParser.KW_DES_KEY_FILE: + case MySqlParser.KW_DIRECTORY: + case MySqlParser.KW_DISABLE: + case MySqlParser.KW_DISCARD: + case MySqlParser.KW_DISK: + case MySqlParser.KW_DO: + case MySqlParser.KW_DUMPFILE: + case MySqlParser.KW_DUPLICATE: + case MySqlParser.KW_DYNAMIC: + case MySqlParser.KW_ENABLE: + case MySqlParser.KW_ENCRYPTION: + case MySqlParser.KW_END: + case MySqlParser.KW_ENDS: + case MySqlParser.KW_ENGINE: + case MySqlParser.KW_ENGINES: + case MySqlParser.KW_ERROR: + case MySqlParser.KW_ERRORS: + case MySqlParser.KW_ESCAPE: + case MySqlParser.KW_EVENT: + case MySqlParser.KW_EVENTS: + case MySqlParser.KW_EVERY: + case MySqlParser.KW_EXCHANGE: + case MySqlParser.KW_EXCLUSIVE: + case MySqlParser.KW_EXPIRE: + case MySqlParser.KW_EXPORT: + case MySqlParser.KW_EXTENDED: + case MySqlParser.KW_EXTENT_SIZE: + case MySqlParser.KW_FAILED_LOGIN_ATTEMPTS: + case MySqlParser.KW_FAST: + case MySqlParser.KW_FAULTS: + case MySqlParser.KW_FIELDS: + case MySqlParser.KW_FILE_BLOCK_SIZE: + case MySqlParser.KW_FILTER: + case MySqlParser.KW_FIRST: + case MySqlParser.KW_FIXED: + case MySqlParser.KW_FLUSH: + case MySqlParser.KW_FOLLOWS: + case MySqlParser.KW_FOUND: + case MySqlParser.KW_FULL: + case MySqlParser.KW_FUNCTION: + case MySqlParser.KW_GENERAL: + case MySqlParser.KW_GLOBAL: + case MySqlParser.KW_GRANTS: + case MySqlParser.KW_GROUP_REPLICATION: + case MySqlParser.KW_HANDLER: + case MySqlParser.KW_HASH: + case MySqlParser.KW_HELP: + case MySqlParser.KW_HISTORY: + case MySqlParser.KW_HOST: + case MySqlParser.KW_HOSTS: + case MySqlParser.KW_IDENTIFIED: + case MySqlParser.KW_IGNORE_SERVER_IDS: + case MySqlParser.KW_IMPORT: + case MySqlParser.KW_INDEXES: + case MySqlParser.KW_INITIAL_SIZE: + case MySqlParser.KW_INPLACE: + case MySqlParser.KW_INSERT_METHOD: + case MySqlParser.KW_INSTALL: + case MySqlParser.KW_INSTANCE: + case MySqlParser.KW_INSTANT: + case MySqlParser.KW_INVISIBLE: + case MySqlParser.KW_INVOKER: + case MySqlParser.KW_IO: + case MySqlParser.KW_IO_THREAD: + case MySqlParser.KW_IPC: + case MySqlParser.KW_ISOLATION: + case MySqlParser.KW_ISSUER: + case MySqlParser.KW_JSON: + case MySqlParser.KW_KEY_BLOCK_SIZE: + case MySqlParser.KW_LANGUAGE: + case MySqlParser.KW_LAST: + case MySqlParser.KW_LEAVES: + case MySqlParser.KW_LESS: + case MySqlParser.KW_LEVEL: + case MySqlParser.KW_LIST: + case MySqlParser.KW_LOCAL: + case MySqlParser.KW_LOGFILE: + case MySqlParser.KW_LOGS: + case MySqlParser.KW_MASTER: + case MySqlParser.KW_MASTER_AUTO_POSITION: + case MySqlParser.KW_MASTER_CONNECT_RETRY: + case MySqlParser.KW_MASTER_DELAY: + case MySqlParser.KW_MASTER_HEARTBEAT_PERIOD: + case MySqlParser.KW_MASTER_HOST: + case MySqlParser.KW_MASTER_LOG_FILE: + case MySqlParser.KW_MASTER_LOG_POS: + case MySqlParser.KW_MASTER_PASSWORD: + case MySqlParser.KW_MASTER_PORT: + case MySqlParser.KW_MASTER_RETRY_COUNT: + case MySqlParser.KW_MASTER_SSL: + case MySqlParser.KW_MASTER_SSL_CA: + case MySqlParser.KW_MASTER_SSL_CAPATH: + case MySqlParser.KW_MASTER_SSL_CERT: + case MySqlParser.KW_MASTER_SSL_CIPHER: + case MySqlParser.KW_MASTER_SSL_CRL: + case MySqlParser.KW_MASTER_SSL_CRLPATH: + case MySqlParser.KW_MASTER_SSL_KEY: + case MySqlParser.KW_MASTER_TLS_VERSION: + case MySqlParser.KW_MASTER_USER: + case MySqlParser.KW_MAX_CONNECTIONS_PER_HOUR: + case MySqlParser.KW_MAX_QUERIES_PER_HOUR: + case MySqlParser.KW_MAX_ROWS: + case MySqlParser.KW_MAX_SIZE: + case MySqlParser.KW_MAX_UPDATES_PER_HOUR: + case MySqlParser.KW_MAX_USER_CONNECTIONS: + case MySqlParser.KW_MEDIUM: + case MySqlParser.KW_MEMBER: + case MySqlParser.KW_MERGE: + case MySqlParser.KW_MESSAGE_TEXT: + case MySqlParser.KW_MID: + case MySqlParser.KW_MIGRATE: + case MySqlParser.KW_MIN_ROWS: + case MySqlParser.KW_MODE: + case MySqlParser.KW_MODIFY: + case MySqlParser.KW_MUTEX: + case MySqlParser.KW_MYSQL: + case MySqlParser.KW_MYSQL_ERRNO: + case MySqlParser.KW_NAME: + case MySqlParser.KW_NAMES: + case MySqlParser.KW_NCHAR: + case MySqlParser.KW_NEVER: + case MySqlParser.KW_NEXT: + case MySqlParser.KW_NO: + case MySqlParser.KW_NOWAIT: + case MySqlParser.KW_NODEGROUP: + case MySqlParser.KW_NONE: + case MySqlParser.KW_ODBC: + case MySqlParser.KW_OFFLINE: + case MySqlParser.KW_OFFSET: + case MySqlParser.KW_OF: + case MySqlParser.KW_OLD_PASSWORD: + case MySqlParser.KW_ONE: + case MySqlParser.KW_ONLINE: + case MySqlParser.KW_ONLY: + case MySqlParser.KW_OPEN: + case MySqlParser.KW_OPTIMIZER_COSTS: + case MySqlParser.KW_OPTIONS: + case MySqlParser.KW_OWNER: + case MySqlParser.KW_PACK_KEYS: + case MySqlParser.KW_PAGE: + case MySqlParser.KW_PAGE_CHECKSUM: + case MySqlParser.KW_PARSER: + case MySqlParser.KW_PARTIAL: + case MySqlParser.KW_PARTITIONING: + case MySqlParser.KW_PARTITIONS: + case MySqlParser.KW_PASSWORD: + case MySqlParser.KW_PASSWORD_LOCK_TIME: + case MySqlParser.KW_PHASE: + case MySqlParser.KW_PLUGIN: + case MySqlParser.KW_PLUGIN_DIR: + case MySqlParser.KW_PLUGINS: + case MySqlParser.KW_PORT: + case MySqlParser.KW_PRECEDES: + case MySqlParser.KW_PREPARE: + case MySqlParser.KW_PRESERVE: + case MySqlParser.KW_PREV: + case MySqlParser.KW_PROCESSLIST: + case MySqlParser.KW_PROFILE: + case MySqlParser.KW_PROFILES: + case MySqlParser.KW_PROXY: + case MySqlParser.KW_QUERY: + case MySqlParser.KW_QUICK: + case MySqlParser.KW_REBUILD: + case MySqlParser.KW_RECOVER: + case MySqlParser.KW_RECURSIVE: + case MySqlParser.KW_REDO_BUFFER_SIZE: + case MySqlParser.KW_REDUNDANT: + case MySqlParser.KW_RELAY: + case MySqlParser.KW_RELAY_LOG_FILE: + case MySqlParser.KW_RELAY_LOG_POS: + case MySqlParser.KW_RELAYLOG: + case MySqlParser.KW_REMOVE: + case MySqlParser.KW_REORGANIZE: + case MySqlParser.KW_REPAIR: + case MySqlParser.KW_REPLICATE_DO_DB: + case MySqlParser.KW_REPLICATE_DO_TABLE: + case MySqlParser.KW_REPLICATE_IGNORE_DB: + case MySqlParser.KW_REPLICATE_IGNORE_TABLE: + case MySqlParser.KW_REPLICATE_REWRITE_DB: + case MySqlParser.KW_REPLICATE_WILD_DO_TABLE: + case MySqlParser.KW_REPLICATE_WILD_IGNORE_TABLE: + case MySqlParser.KW_REPLICATION: + case MySqlParser.KW_RESET: + case MySqlParser.KW_RESUME: + case MySqlParser.KW_RETURNED_SQLSTATE: + case MySqlParser.KW_RETURNS: + case MySqlParser.KW_REUSE: + case MySqlParser.KW_ROLE: + case MySqlParser.KW_ROLLBACK: + case MySqlParser.KW_ROLLUP: + case MySqlParser.KW_ROTATE: + case MySqlParser.KW_ROW: + case MySqlParser.KW_ROWS: + case MySqlParser.KW_ROW_FORMAT: + case MySqlParser.KW_SAVEPOINT: + case MySqlParser.KW_SCHEDULE: + case MySqlParser.KW_SECURITY: + case MySqlParser.KW_SERVER: + case MySqlParser.KW_SESSION: + case MySqlParser.KW_SHARE: + case MySqlParser.KW_SHARED: + case MySqlParser.KW_SIGNED: + case MySqlParser.KW_SIMPLE: + case MySqlParser.KW_SLAVE: + case MySqlParser.KW_SLOW: + case MySqlParser.KW_SNAPSHOT: + case MySqlParser.KW_SOCKET: + case MySqlParser.KW_SOME: + case MySqlParser.KW_SONAME: + case MySqlParser.KW_SOUNDS: + case MySqlParser.KW_SOURCE: + case MySqlParser.KW_SQL_AFTER_GTIDS: + case MySqlParser.KW_SQL_AFTER_MTS_GAPS: + case MySqlParser.KW_SQL_BEFORE_GTIDS: + case MySqlParser.KW_SQL_BUFFER_RESULT: + case MySqlParser.KW_SQL_CACHE: + case MySqlParser.KW_SQL_NO_CACHE: + case MySqlParser.KW_SQL_THREAD: + case MySqlParser.KW_START: + case MySqlParser.KW_STARTS: + case MySqlParser.KW_STATS_AUTO_RECALC: + case MySqlParser.KW_STATS_PERSISTENT: + case MySqlParser.KW_STATS_SAMPLE_PAGES: + case MySqlParser.KW_STATUS: + case MySqlParser.KW_STOP: + case MySqlParser.KW_STORAGE: + case MySqlParser.KW_STRING: + case MySqlParser.KW_SUBCLASS_ORIGIN: + case MySqlParser.KW_SUBJECT: + case MySqlParser.KW_SUBPARTITION: + case MySqlParser.KW_SUBPARTITIONS: + case MySqlParser.KW_SUSPEND: + case MySqlParser.KW_SWAPS: + case MySqlParser.KW_SWITCHES: + case MySqlParser.KW_TABLE_NAME: + case MySqlParser.KW_TABLESPACE: + case MySqlParser.KW_TABLE_TYPE: + case MySqlParser.KW_TEMPORARY: + case MySqlParser.KW_TEMPTABLE: + case MySqlParser.KW_THAN: + case MySqlParser.KW_TRADITIONAL: + case MySqlParser.KW_TRANSACTION: + case MySqlParser.KW_TRANSACTIONAL: + case MySqlParser.KW_TRIGGERS: + case MySqlParser.KW_TRUNCATE: + case MySqlParser.KW_UNBOUNDED: + case MySqlParser.KW_UNDEFINED: + case MySqlParser.KW_UNDOFILE: + case MySqlParser.KW_UNDO_BUFFER_SIZE: + case MySqlParser.KW_UNINSTALL: + case MySqlParser.KW_UNKNOWN: + case MySqlParser.KW_UNTIL: + case MySqlParser.KW_UPGRADE: + case MySqlParser.KW_USER: + case MySqlParser.KW_USE_FRM: + case MySqlParser.KW_USER_RESOURCES: + case MySqlParser.KW_VALIDATION: + case MySqlParser.KW_VALUE: + case MySqlParser.KW_VARIABLES: + case MySqlParser.KW_VIEW: + case MySqlParser.KW_VIRTUAL: + case MySqlParser.KW_VISIBLE: + case MySqlParser.KW_WAIT: + case MySqlParser.KW_WARNINGS: + case MySqlParser.KW_WITHOUT: + case MySqlParser.KW_WORK: + case MySqlParser.KW_WRAPPER: + case MySqlParser.KW_X509: + case MySqlParser.KW_XA: + case MySqlParser.KW_XML: + case MySqlParser.KW_QUARTER: + case MySqlParser.KW_MONTH: + case MySqlParser.KW_DAY: + case MySqlParser.KW_HOUR: + case MySqlParser.KW_MINUTE: + case MySqlParser.KW_WEEK: + case MySqlParser.KW_SECOND: + case MySqlParser.KW_MICROSECOND: + case MySqlParser.KW_ADMIN: + case MySqlParser.KW_AUDIT_ABORT_EXEMPT: + case MySqlParser.KW_AUDIT_ADMIN: + case MySqlParser.KW_AUTHENTICATION_POLICY_ADMIN: + case MySqlParser.KW_BACKUP_ADMIN: + case MySqlParser.KW_BINLOG_ADMIN: + case MySqlParser.KW_BINLOG_ENCRYPTION_ADMIN: + case MySqlParser.KW_CLONE_ADMIN: + case MySqlParser.KW_CONNECTION_ADMIN: + case MySqlParser.KW_ENCRYPTION_KEY_ADMIN: + case MySqlParser.KW_EXECUTE: + case MySqlParser.KW_FILE: + case MySqlParser.KW_FIREWALL_ADMIN: + case MySqlParser.KW_FIREWALL_EXEMPT: + case MySqlParser.KW_FIREWALL_USER: + case MySqlParser.KW_GROUP_REPLICATION_ADMIN: + case MySqlParser.KW_INNODB_REDO_LOG_ARCHIVE: + case MySqlParser.KW_INVOKE: + case MySqlParser.KW_LAMBDA: + case MySqlParser.KW_NDB_STORED_USER: + case MySqlParser.KW_PASSWORDLESS_USER_ADMIN: + case MySqlParser.KW_PERSIST_RO_VARIABLES_ADMIN: + case MySqlParser.KW_PRIVILEGES: + case MySqlParser.KW_PROCESS: + case MySqlParser.KW_RELOAD: + case MySqlParser.KW_REPLICATION_APPLIER: + case MySqlParser.KW_REPLICATION_SLAVE_ADMIN: + case MySqlParser.KW_RESOURCE_GROUP_ADMIN: + case MySqlParser.KW_RESOURCE_GROUP_USER: + case MySqlParser.KW_ROLE_ADMIN: + case MySqlParser.KW_ROUTINE: + case MySqlParser.KW_S3: + case MySqlParser.KW_SESSION_VARIABLES_ADMIN: + case MySqlParser.KW_SET_USER_ID: + case MySqlParser.KW_SHOW_ROUTINE: + case MySqlParser.KW_SHUTDOWN: + case MySqlParser.KW_SUPER: + case MySqlParser.KW_SYSTEM_VARIABLES_ADMIN: + case MySqlParser.KW_TABLES: + case MySqlParser.KW_TABLE_ENCRYPTION_ADMIN: + case MySqlParser.KW_VERSION_TOKEN_ADMIN: + case MySqlParser.KW_XA_RECOVER_ADMIN: + case MySqlParser.KW_ARMSCII8: + case MySqlParser.KW_ASCII: + case MySqlParser.KW_BIG5: + case MySqlParser.KW_CP1250: + case MySqlParser.KW_CP1251: + case MySqlParser.KW_CP1256: + case MySqlParser.KW_CP1257: + case MySqlParser.KW_CP850: + case MySqlParser.KW_CP852: + case MySqlParser.KW_CP866: + case MySqlParser.KW_CP932: + case MySqlParser.KW_DEC8: + case MySqlParser.KW_EUCJPMS: + case MySqlParser.KW_EUCKR: + case MySqlParser.KW_GB18030: + case MySqlParser.KW_GB2312: + case MySqlParser.KW_GBK: + case MySqlParser.KW_GEOSTD8: + case MySqlParser.KW_GREEK: + case MySqlParser.KW_HEBREW: + case MySqlParser.KW_HP8: + case MySqlParser.KW_KEYBCS2: + case MySqlParser.KW_KOI8R: + case MySqlParser.KW_KOI8U: + case MySqlParser.KW_LATIN1: + case MySqlParser.KW_LATIN2: + case MySqlParser.KW_LATIN5: + case MySqlParser.KW_LATIN7: + case MySqlParser.KW_MACCE: + case MySqlParser.KW_MACROMAN: + case MySqlParser.KW_SJIS: + case MySqlParser.KW_SWE7: + case MySqlParser.KW_TIS620: + case MySqlParser.KW_UCS2: + case MySqlParser.KW_UJIS: + case MySqlParser.KW_UTF16: + case MySqlParser.KW_UTF16LE: + case MySqlParser.KW_UTF32: + case MySqlParser.KW_UTF8: + case MySqlParser.KW_UTF8MB3: + case MySqlParser.KW_UTF8MB4: + case MySqlParser.KW_ARCHIVE: + case MySqlParser.KW_BLACKHOLE: + case MySqlParser.KW_CSV: + case MySqlParser.KW_FEDERATED: + case MySqlParser.KW_INNODB: + case MySqlParser.KW_MEMORY: + case MySqlParser.KW_MRG_MYISAM: + case MySqlParser.KW_MYISAM: + case MySqlParser.KW_NDB: + case MySqlParser.KW_NDBCLUSTER: + case MySqlParser.KW_PERFORMANCE_SCHEMA: + case MySqlParser.KW_TOKUDB: + case MySqlParser.KW_REPEATABLE: + case MySqlParser.KW_COMMITTED: + case MySqlParser.KW_UNCOMMITTED: + case MySqlParser.KW_SERIALIZABLE: + case MySqlParser.KW_GEOMETRYCOLLECTION: + case MySqlParser.KW_LINESTRING: + case MySqlParser.KW_MULTILINESTRING: + case MySqlParser.KW_MULTIPOINT: + case MySqlParser.KW_MULTIPOLYGON: + case MySqlParser.KW_POINT: + case MySqlParser.KW_POLYGON: + case MySqlParser.KW_CATALOG_NAME: + case MySqlParser.KW_CHARSET: + case MySqlParser.KW_COLLATION: + case MySqlParser.KW_ENGINE_ATTRIBUTE: + case MySqlParser.KW_FORMAT: + case MySqlParser.KW_GET_FORMAT: + case MySqlParser.KW_RANDOM: + case MySqlParser.KW_REVERSE: + case MySqlParser.KW_ROW_COUNT: + case MySqlParser.KW_SCHEMA_NAME: + case MySqlParser.KW_SECONDARY_ENGINE_ATTRIBUTE: + case MySqlParser.KW_SRID: + case MySqlParser.KW_SYSTEM_USER: + case MySqlParser.KW_TP_CONNECTION_ADMIN: + case MySqlParser.KW_WEIGHT_STRING: + case MySqlParser.MOD: + case MySqlParser.ID: + this.enterOuterAlt(localContext, 3); + { + this.state = 4346; + this.simpleId(); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + startTransaction() { + let localContext = new StartTransactionContext(this.context, this.state); + this.enterRule(localContext, 316, MySqlParser.RULE_startTransaction); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 4349; + this.match(MySqlParser.KW_START); + this.state = 4350; + this.match(MySqlParser.KW_TRANSACTION); + this.state = 4359; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 621, this.context)) { + case 1: + { + this.state = 4351; + this.transactionMode(); + this.state = 4356; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 4352; + this.match(MySqlParser.COMMA); + this.state = 4353; + this.transactionMode(); + } + } + this.state = 4358; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + break; + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + beginWork() { + let localContext = new BeginWorkContext(this.context, this.state); + this.enterRule(localContext, 318, MySqlParser.RULE_beginWork); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 4361; + this.match(MySqlParser.KW_BEGIN); + this.state = 4363; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 691) { + { + this.state = 4362; + this.match(MySqlParser.KW_WORK); + } + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + commitWork() { + let localContext = new CommitWorkContext(this.context, this.state); + this.enterRule(localContext, 320, MySqlParser.RULE_commitWork); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 4365; + this.match(MySqlParser.KW_COMMIT); + this.state = 4367; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 691) { + { + this.state = 4366; + this.match(MySqlParser.KW_WORK); + } + } + this.state = 4374; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 11) { + { + this.state = 4369; + this.match(MySqlParser.KW_AND); + this.state = 4371; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 502) { + { + this.state = 4370; + localContext._nochain = this.match(MySqlParser.KW_NO); + } + } + this.state = 4373; + this.match(MySqlParser.KW_CHAIN); + } + } + this.state = 4380; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 627, this.context)) { + case 1: + { + this.state = 4377; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 502) { + { + this.state = 4376; + localContext._norelease = this.match(MySqlParser.KW_NO); + } + } + this.state = 4379; + this.match(MySqlParser.KW_RELEASE); + } + break; + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + rollbackWork() { + let localContext = new RollbackWorkContext(this.context, this.state); + this.enterRule(localContext, 322, MySqlParser.RULE_rollbackWork); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 4382; + this.match(MySqlParser.KW_ROLLBACK); + this.state = 4384; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 691) { + { + this.state = 4383; + this.match(MySqlParser.KW_WORK); + } + } + this.state = 4391; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 11) { + { + this.state = 4386; + this.match(MySqlParser.KW_AND); + this.state = 4388; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 502) { + { + this.state = 4387; + localContext._nochain = this.match(MySqlParser.KW_NO); + } + } + this.state = 4390; + this.match(MySqlParser.KW_CHAIN); + } + } + this.state = 4397; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 632, this.context)) { + case 1: + { + this.state = 4394; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 502) { + { + this.state = 4393; + localContext._norelease = this.match(MySqlParser.KW_NO); + } + } + this.state = 4396; + this.match(MySqlParser.KW_RELEASE); + } + break; + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + savepointStatement() { + let localContext = new SavepointStatementContext(this.context, this.state); + this.enterRule(localContext, 324, MySqlParser.RULE_savepointStatement); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 4399; + this.match(MySqlParser.KW_SAVEPOINT); + this.state = 4400; + localContext._identifier = this.uid(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + rollbackStatement() { + let localContext = new RollbackStatementContext(this.context, this.state); + this.enterRule(localContext, 326, MySqlParser.RULE_rollbackStatement); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 4402; + this.match(MySqlParser.KW_ROLLBACK); + this.state = 4404; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 691) { + { + this.state = 4403; + this.match(MySqlParser.KW_WORK); + } + } + this.state = 4406; + this.match(MySqlParser.KW_TO); + this.state = 4408; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 634, this.context)) { + case 1: + { + this.state = 4407; + this.match(MySqlParser.KW_SAVEPOINT); + } + break; + } + this.state = 4410; + localContext._identifier = this.uid(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + releaseStatement() { + let localContext = new ReleaseStatementContext(this.context, this.state); + this.enterRule(localContext, 328, MySqlParser.RULE_releaseStatement); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 4412; + this.match(MySqlParser.KW_RELEASE); + this.state = 4413; + this.match(MySqlParser.KW_SAVEPOINT); + this.state = 4414; + localContext._identifier = this.uid(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + lockTables() { + let localContext = new LockTablesContext(this.context, this.state); + this.enterRule(localContext, 330, MySqlParser.RULE_lockTables); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 4416; + this.match(MySqlParser.KW_LOCK); + this.state = 4417; + _la = this.tokenStream.LA(1); + if (!(_la === 173 || _la === 752)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 4418; + this.lockTableElement(); + this.state = 4423; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 4419; + this.match(MySqlParser.COMMA); + this.state = 4420; + this.lockTableElement(); + } + } + this.state = 4425; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + unlockTables() { + let localContext = new UnlockTablesContext(this.context, this.state); + this.enterRule(localContext, 332, MySqlParser.RULE_unlockTables); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 4426; + this.match(MySqlParser.KW_UNLOCK); + this.state = 4427; + this.match(MySqlParser.KW_TABLES); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + setAutocommitStatement() { + let localContext = new SetAutocommitStatementContext(this.context, this.state); + this.enterRule(localContext, 334, MySqlParser.RULE_setAutocommitStatement); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 4429; + this.match(MySqlParser.KW_SET); + this.state = 4430; + this.match(MySqlParser.KW_AUTOCOMMIT); + this.state = 4431; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 4432; + localContext._autocommitValue = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 871 || _la === 872)) { + localContext._autocommitValue = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + setTransactionStatement() { + let localContext = new SetTransactionStatementContext(this.context, this.state); + this.enterRule(localContext, 336, MySqlParser.RULE_setTransactionStatement); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 4434; + this.match(MySqlParser.KW_SET); + this.state = 4436; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 413 || _la === 593) { + { + this.state = 4435; + localContext._transactionContext = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 413 || _la === 593)) { + localContext._transactionContext = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + this.state = 4438; + this.match(MySqlParser.KW_TRANSACTION); + this.state = 4439; + this.transactionOption(); + this.state = 4444; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 4440; + this.match(MySqlParser.COMMA); + this.state = 4441; + this.transactionOption(); + } + } + this.state = 4446; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + transactionMode() { + let localContext = new TransactionModeContext(this.context, this.state); + this.enterRule(localContext, 338, MySqlParser.RULE_transactionMode); + try { + this.state = 4454; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 638, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 4447; + this.match(MySqlParser.KW_WITH); + this.state = 4448; + this.match(MySqlParser.KW_CONSISTENT); + this.state = 4449; + this.match(MySqlParser.KW_SNAPSHOT); + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 4450; + this.match(MySqlParser.KW_READ); + this.state = 4451; + this.match(MySqlParser.KW_WRITE); + } + break; + case 3: + this.enterOuterAlt(localContext, 3); + { + this.state = 4452; + this.match(MySqlParser.KW_READ); + this.state = 4453; + this.match(MySqlParser.KW_ONLY); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + lockTableElement() { + let localContext = new LockTableElementContext(this.context, this.state); + this.enterRule(localContext, 340, MySqlParser.RULE_lockTableElement); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 4456; + this.tableName(); + this.state = 4461; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if ((((_la) & ~0x1F) === 0 && ((1 << _la) & 1074311168) !== 0) || ((((_la - 36)) & ~0x1F) === 0 && ((1 << (_la - 36)) & 11014219) !== 0) || ((((_la - 74)) & ~0x1F) === 0 && ((1 << (_la - 74)) & 18878481) !== 0) || ((((_la - 117)) & ~0x1F) === 0 && ((1 << (_la - 117)) & 100679969) !== 0) || ((((_la - 150)) & ~0x1F) === 0 && ((1 << (_la - 150)) & 1049605) !== 0) || ((((_la - 219)) & ~0x1F) === 0 && ((1 << (_la - 219)) & 5374495) !== 0) || ((((_la - 253)) & ~0x1F) === 0 && ((1 << (_la - 253)) & 4294967295) !== 0) || ((((_la - 285)) & ~0x1F) === 0 && ((1 << (_la - 285)) & 4261412607) !== 0) || ((((_la - 317)) & ~0x1F) === 0 && ((1 << (_la - 317)) & 4160741375) !== 0) || ((((_la - 349)) & ~0x1F) === 0 && ((1 << (_la - 349)) & 4026531839) !== 0) || ((((_la - 381)) & ~0x1F) === 0 && ((1 << (_la - 381)) & 1055907839) !== 0) || ((((_la - 413)) & ~0x1F) === 0 && ((1 << (_la - 413)) & 4294885367) !== 0) || ((((_la - 445)) & ~0x1F) === 0 && ((1 << (_la - 445)) & 3757571071) !== 0) || ((((_la - 478)) & ~0x1F) === 0 && ((1 << (_la - 478)) & 3755999231) !== 0) || ((((_la - 510)) & ~0x1F) === 0 && ((1 << (_la - 510)) & 3751780349) !== 0) || ((((_la - 542)) & ~0x1F) === 0 && ((1 << (_la - 542)) & 2141183997) !== 0) || ((((_la - 575)) & ~0x1F) === 0 && ((1 << (_la - 575)) & 2147483629) !== 0) || ((((_la - 633)) & ~0x1F) === 0 && ((1 << (_la - 633)) & 4294934527) !== 0) || ((((_la - 665)) & ~0x1F) === 0 && ((1 << (_la - 665)) & 4278189053) !== 0) || ((((_la - 697)) & ~0x1F) === 0 && ((1 << (_la - 697)) & 1644099327) !== 0) || ((((_la - 729)) & ~0x1F) === 0 && ((1 << (_la - 729)) & 4294900735) !== 0) || ((((_la - 761)) & ~0x1F) === 0 && ((1 << (_la - 761)) & 4294967295) !== 0) || ((((_la - 793)) & ~0x1F) === 0 && ((1 << (_la - 793)) & 4288675839) !== 0) || ((((_la - 825)) & ~0x1F) === 0 && ((1 << (_la - 825)) & 2147527671) !== 0) || ((((_la - 879)) & ~0x1F) === 0 && ((1 << (_la - 879)) & 1033) !== 0)) { + { + this.state = 4458; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 13) { + { + this.state = 4457; + this.match(MySqlParser.KW_AS); + } + } + this.state = 4460; + localContext._alias = this.uid(); + } + } + this.state = 4463; + this.lockAction(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + lockAction() { + let localContext = new LockActionContext(this.context, this.state); + this.enterRule(localContext, 342, MySqlParser.RULE_lockAction); + let _la; + try { + this.state = 4473; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_READ: + this.enterOuterAlt(localContext, 1); + { + this.state = 4465; + this.match(MySqlParser.KW_READ); + this.state = 4467; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 450) { + { + this.state = 4466; + this.match(MySqlParser.KW_LOCAL); + } + } + } + break; + case MySqlParser.KW_LOW_PRIORITY: + case MySqlParser.KW_WRITE: + this.enterOuterAlt(localContext, 2); + { + this.state = 4470; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 107) { + { + this.state = 4469; + this.match(MySqlParser.KW_LOW_PRIORITY); + } + } + this.state = 4472; + this.match(MySqlParser.KW_WRITE); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + transactionOption() { + let localContext = new TransactionOptionContext(this.context, this.state); + this.enterRule(localContext, 344, MySqlParser.RULE_transactionOption); + try { + this.state = 4482; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 644, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 4475; + this.match(MySqlParser.KW_ISOLATION); + this.state = 4476; + this.match(MySqlParser.KW_LEVEL); + this.state = 4477; + this.transactionLevel(); + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 4478; + this.match(MySqlParser.KW_READ); + this.state = 4479; + this.match(MySqlParser.KW_WRITE); + } + break; + case 3: + this.enterOuterAlt(localContext, 3); + { + this.state = 4480; + this.match(MySqlParser.KW_READ); + this.state = 4481; + this.match(MySqlParser.KW_ONLY); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + transactionLevel() { + let localContext = new TransactionLevelContext(this.context, this.state); + this.enterRule(localContext, 346, MySqlParser.RULE_transactionLevel); + try { + this.state = 4491; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 645, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 4484; + this.match(MySqlParser.KW_REPEATABLE); + this.state = 4485; + this.match(MySqlParser.KW_READ); + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 4486; + this.match(MySqlParser.KW_READ); + this.state = 4487; + this.match(MySqlParser.KW_COMMITTED); + } + break; + case 3: + this.enterOuterAlt(localContext, 3); + { + this.state = 4488; + this.match(MySqlParser.KW_READ); + this.state = 4489; + this.match(MySqlParser.KW_UNCOMMITTED); + } + break; + case 4: + this.enterOuterAlt(localContext, 4); + { + this.state = 4490; + this.match(MySqlParser.KW_SERIALIZABLE); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + changeMaster() { + let localContext = new ChangeMasterContext(this.context, this.state); + this.enterRule(localContext, 348, MySqlParser.RULE_changeMaster); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 4493; + this.match(MySqlParser.KW_CHANGE); + this.state = 4494; + this.match(MySqlParser.KW_MASTER); + this.state = 4495; + this.match(MySqlParser.KW_TO); + this.state = 4496; + this.masterOption(); + this.state = 4501; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 4497; + this.match(MySqlParser.COMMA); + this.state = 4498; + this.masterOption(); + } + } + this.state = 4503; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 4505; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 65) { + { + this.state = 4504; + this.channelOption(); + } + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + changeReplicationFilter() { + let localContext = new ChangeReplicationFilterContext(this.context, this.state); + this.enterRule(localContext, 350, MySqlParser.RULE_changeReplicationFilter); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 4507; + this.match(MySqlParser.KW_CHANGE); + this.state = 4508; + this.match(MySqlParser.KW_REPLICATION); + this.state = 4509; + this.match(MySqlParser.KW_FILTER); + this.state = 4510; + this.replicationFilter(); + this.state = 4515; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 4511; + this.match(MySqlParser.COMMA); + this.state = 4512; + this.replicationFilter(); + } + } + this.state = 4517; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 4519; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 65) { + { + this.state = 4518; + this.channelOption(); + } + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + changeReplicationSource() { + let localContext = new ChangeReplicationSourceContext(this.context, this.state); + this.enterRule(localContext, 352, MySqlParser.RULE_changeReplicationSource); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 4521; + this.match(MySqlParser.KW_CHANGE); + this.state = 4522; + this.match(MySqlParser.KW_REPLICATION); + this.state = 4523; + this.match(MySqlParser.KW_SOURCE); + this.state = 4524; + this.match(MySqlParser.KW_TO); + this.state = 4525; + this.replicationSourceOption(); + this.state = 4530; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 4526; + this.match(MySqlParser.COMMA); + this.state = 4527; + this.replicationSourceOption(); + } + } + this.state = 4532; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 4534; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 65) { + { + this.state = 4533; + this.channelOption(); + } + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + purgeBinaryLogs() { + let localContext = new PurgeBinaryLogsContext(this.context, this.state); + this.enterRule(localContext, 354, MySqlParser.RULE_purgeBinaryLogs); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 4536; + this.match(MySqlParser.KW_PURGE); + this.state = 4537; + localContext._purgeFormat = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 228 || _la === 453)) { + localContext._purgeFormat = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 4538; + this.match(MySqlParser.KW_LOGS); + this.state = 4543; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_TO: + { + this.state = 4539; + this.match(MySqlParser.KW_TO); + this.state = 4540; + localContext._fileName = this.match(MySqlParser.STRING_LITERAL); + } + break; + case MySqlParser.KW_BEFORE: + { + this.state = 4541; + this.match(MySqlParser.KW_BEFORE); + this.state = 4542; + localContext._timeValue = this.match(MySqlParser.STRING_LITERAL); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + startSlaveOrReplica() { + let localContext = new StartSlaveOrReplicaContext(this.context, this.state); + this.enterRule(localContext, 356, MySqlParser.RULE_startSlaveOrReplica); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 4545; + this.match(MySqlParser.KW_START); + this.state = 4546; + _la = this.tokenStream.LA(1); + if (!(_la === 563 || _la === 598)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 4555; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 438 || _la === 639) { + { + this.state = 4547; + this.threadType(); + this.state = 4552; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 4548; + this.match(MySqlParser.COMMA); + this.state = 4549; + this.threadType(); + } + } + this.state = 4554; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + } + this.state = 4559; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 676) { + { + this.state = 4557; + this.match(MySqlParser.KW_UNTIL); + this.state = 4558; + this.untilOption(); + } + } + this.state = 4564; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 363 || _la === 529 || _la === 535 || _la === 678) { + { + { + this.state = 4561; + this.connectionOptions(); + } + } + this.state = 4566; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 4568; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 65) { + { + this.state = 4567; + this.channelOption(); + } + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + stopSlaveOrReplica() { + let localContext = new StopSlaveOrReplicaContext(this.context, this.state); + this.enterRule(localContext, 358, MySqlParser.RULE_stopSlaveOrReplica); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 4570; + this.match(MySqlParser.KW_STOP); + this.state = 4571; + _la = this.tokenStream.LA(1); + if (!(_la === 563 || _la === 598)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 4580; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 438 || _la === 639) { + { + this.state = 4572; + this.threadType(); + this.state = 4577; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 4573; + this.match(MySqlParser.COMMA); + this.state = 4574; + this.threadType(); + } + } + this.state = 4579; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + } + this.state = 4583; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 65) { + { + this.state = 4582; + this.channelOption(); + } + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + startGroupReplication() { + let localContext = new StartGroupReplicationContext(this.context, this.state); + this.enterRule(localContext, 360, MySqlParser.RULE_startGroupReplication); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 4585; + this.match(MySqlParser.KW_START); + this.state = 4586; + this.match(MySqlParser.KW_GROUP_REPLICATION); + this.state = 4590; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 678) { + { + this.state = 4587; + this.match(MySqlParser.KW_USER); + this.state = 4588; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 4589; + this.match(MySqlParser.STRING_LITERAL); + } + } + this.state = 4596; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 662, this.context)) { + case 1: + { + this.state = 4592; + this.match(MySqlParser.COMMA); + this.state = 4593; + this.match(MySqlParser.KW_PASSWORD); + this.state = 4594; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 4595; + this.match(MySqlParser.STRING_LITERAL); + } + break; + } + this.state = 4602; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 868) { + { + this.state = 4598; + this.match(MySqlParser.COMMA); + this.state = 4599; + this.match(MySqlParser.KW_DEFAULT_AUTH); + this.state = 4600; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 4601; + this.match(MySqlParser.STRING_LITERAL); + } + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + stopGroupReplication() { + let localContext = new StopGroupReplicationContext(this.context, this.state); + this.enterRule(localContext, 362, MySqlParser.RULE_stopGroupReplication); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 4604; + this.match(MySqlParser.KW_STOP); + this.state = 4605; + this.match(MySqlParser.KW_GROUP_REPLICATION); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + masterOption() { + let localContext = new MasterOptionContext(this.context, this.state); + this.enterRule(localContext, 364, MySqlParser.RULE_masterOption); + let _la; + try { + this.state = 4634; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_MASTER_BIND: + case MySqlParser.KW_MASTER_COMPRESSION_ALGORITHMS: + case MySqlParser.KW_MASTER_HOST: + case MySqlParser.KW_MASTER_LOG_FILE: + case MySqlParser.KW_MASTER_PASSWORD: + case MySqlParser.KW_MASTER_PUBLIC_KEY_PATH: + case MySqlParser.KW_MASTER_SSL_CA: + case MySqlParser.KW_MASTER_SSL_CAPATH: + case MySqlParser.KW_MASTER_SSL_CERT: + case MySqlParser.KW_MASTER_SSL_CIPHER: + case MySqlParser.KW_MASTER_SSL_CRL: + case MySqlParser.KW_MASTER_SSL_CRLPATH: + case MySqlParser.KW_MASTER_SSL_KEY: + case MySqlParser.KW_MASTER_TLS_CIPHERSUITES: + case MySqlParser.KW_MASTER_TLS_VERSION: + case MySqlParser.KW_MASTER_USER: + case MySqlParser.KW_NETWORK_NAMESPACE: + case MySqlParser.KW_RELAY_LOG_FILE: + localContext = new MasterStringOptionContext(localContext); + this.enterOuterAlt(localContext, 1); + { + this.state = 4607; + this.stringMasterOption(); + this.state = 4608; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 4609; + this.match(MySqlParser.STRING_LITERAL); + } + break; + case MySqlParser.KW_MASTER_CONNECT_RETRY: + case MySqlParser.KW_MASTER_DELAY: + case MySqlParser.KW_MASTER_HEARTBEAT_PERIOD: + case MySqlParser.KW_MASTER_LOG_POS: + case MySqlParser.KW_MASTER_PORT: + case MySqlParser.KW_MASTER_RETRY_COUNT: + case MySqlParser.KW_MASTER_ZSTD_COMPRESSION_LEVEL: + case MySqlParser.KW_RELAY_LOG_POS: + localContext = new MasterDecimalOptionContext(localContext); + this.enterOuterAlt(localContext, 2); + { + this.state = 4611; + this.decimalMasterOption(); + this.state = 4612; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 4613; + this.decimalLiteral(); + } + break; + case MySqlParser.KW_MASTER_SSL_VERIFY_SERVER_CERT: + case MySqlParser.KW_GET_MASTER_PUBLIC_KEY: + case MySqlParser.KW_GTID_ONLY: + case MySqlParser.KW_MASTER_AUTO_POSITION: + case MySqlParser.KW_MASTER_SSL: + case MySqlParser.KW_REQUIRE_ROW_FORMAT: + case MySqlParser.KW_SOURCE_CONNECTION_AUTO_FAILOVER: + localContext = new MasterBoolOptionContext(localContext); + this.enterOuterAlt(localContext, 3); + { + this.state = 4615; + this.boolMasterOption(); + this.state = 4616; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 4617; + localContext._boolVal = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 871 || _la === 872)) { + localContext._boolVal = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + break; + case MySqlParser.KW_ASSIGN_GTIDS_TO_ANONYMOUS_TRANSACTIONS: + case MySqlParser.KW_PRIVILEGE_CHECKS_USER: + case MySqlParser.KW_REQUIRE_TABLE_PRIMARY_KEY_CHECK: + localContext = new V8AddMasterOptionContext(localContext); + this.enterOuterAlt(localContext, 4); + { + this.state = 4619; + this.v8NewMasterOption(); + } + break; + case MySqlParser.KW_IGNORE_SERVER_IDS: + localContext = new MasterUidListOptionContext(localContext); + this.enterOuterAlt(localContext, 5); + { + this.state = 4620; + this.match(MySqlParser.KW_IGNORE_SERVER_IDS); + this.state = 4621; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 4622; + this.match(MySqlParser.LR_BRACKET); + this.state = 4631; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if ((((_la) & ~0x1F) === 0 && ((1 << _la) & 1074302976) !== 0) || ((((_la - 36)) & ~0x1F) === 0 && ((1 << (_la - 36)) & 11014219) !== 0) || ((((_la - 74)) & ~0x1F) === 0 && ((1 << (_la - 74)) & 18878481) !== 0) || ((((_la - 117)) & ~0x1F) === 0 && ((1 << (_la - 117)) & 100679969) !== 0) || ((((_la - 150)) & ~0x1F) === 0 && ((1 << (_la - 150)) & 1049605) !== 0) || ((((_la - 219)) & ~0x1F) === 0 && ((1 << (_la - 219)) & 5374495) !== 0) || ((((_la - 253)) & ~0x1F) === 0 && ((1 << (_la - 253)) & 4294967295) !== 0) || ((((_la - 285)) & ~0x1F) === 0 && ((1 << (_la - 285)) & 4261412607) !== 0) || ((((_la - 317)) & ~0x1F) === 0 && ((1 << (_la - 317)) & 4160741375) !== 0) || ((((_la - 349)) & ~0x1F) === 0 && ((1 << (_la - 349)) & 4026531839) !== 0) || ((((_la - 381)) & ~0x1F) === 0 && ((1 << (_la - 381)) & 1055907839) !== 0) || ((((_la - 413)) & ~0x1F) === 0 && ((1 << (_la - 413)) & 4294885367) !== 0) || ((((_la - 445)) & ~0x1F) === 0 && ((1 << (_la - 445)) & 3757571071) !== 0) || ((((_la - 478)) & ~0x1F) === 0 && ((1 << (_la - 478)) & 3755999231) !== 0) || ((((_la - 510)) & ~0x1F) === 0 && ((1 << (_la - 510)) & 3751780349) !== 0) || ((((_la - 542)) & ~0x1F) === 0 && ((1 << (_la - 542)) & 2141183997) !== 0) || ((((_la - 575)) & ~0x1F) === 0 && ((1 << (_la - 575)) & 2147483629) !== 0) || ((((_la - 633)) & ~0x1F) === 0 && ((1 << (_la - 633)) & 4294934527) !== 0) || ((((_la - 665)) & ~0x1F) === 0 && ((1 << (_la - 665)) & 4278189053) !== 0) || ((((_la - 697)) & ~0x1F) === 0 && ((1 << (_la - 697)) & 1644099327) !== 0) || ((((_la - 729)) & ~0x1F) === 0 && ((1 << (_la - 729)) & 4294900735) !== 0) || ((((_la - 761)) & ~0x1F) === 0 && ((1 << (_la - 761)) & 4294967295) !== 0) || ((((_la - 793)) & ~0x1F) === 0 && ((1 << (_la - 793)) & 4288675839) !== 0) || ((((_la - 825)) & ~0x1F) === 0 && ((1 << (_la - 825)) & 2147527671) !== 0) || ((((_la - 879)) & ~0x1F) === 0 && ((1 << (_la - 879)) & 1033) !== 0)) { + { + this.state = 4623; + localContext._server_id = this.uid(); + this.state = 4628; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 4624; + this.match(MySqlParser.COMMA); + this.state = 4625; + localContext._server_id = this.uid(); + } + } + this.state = 4630; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + } + this.state = 4633; + this.match(MySqlParser.RR_BRACKET); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + stringMasterOption() { + let localContext = new StringMasterOptionContext(this.context, this.state); + this.enterRule(localContext, 366, MySqlParser.RULE_stringMasterOption); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 4636; + _la = this.tokenStream.LA(1); + if (!(_la === 108 || ((((_la - 455)) & ~0x1F) === 0 && ((1 << (_la - 455)) & 4190897) !== 0) || _la === 499 || _la === 557)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + decimalMasterOption() { + let localContext = new DecimalMasterOptionContext(this.context, this.state); + this.enterRule(localContext, 368, MySqlParser.RULE_decimalMasterOption); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 4638; + _la = this.tokenStream.LA(1); + if (!(((((_la - 456)) & ~0x1F) === 0 && ((1 << (_la - 456)) & 2097831) !== 0) || _la === 558)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + boolMasterOption() { + let localContext = new BoolMasterOptionContext(this.context, this.state); + this.enterRule(localContext, 370, MySqlParser.RULE_boolMasterOption); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 4640; + _la = this.tokenStream.LA(1); + if (!(_la === 109 || _la === 411 || _la === 416 || _la === 454 || _la === 466 || _la === 573 || _la === 617)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + v8NewMasterOption() { + let localContext = new V8NewMasterOptionContext(this.context, this.state); + this.enterRule(localContext, 372, MySqlParser.RULE_v8NewMasterOption); + let _la; + try { + this.state = 4655; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_PRIVILEGE_CHECKS_USER: + this.enterOuterAlt(localContext, 1); + { + this.state = 4642; + this.match(MySqlParser.KW_PRIVILEGE_CHECKS_USER); + this.state = 4643; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 4644; + _la = this.tokenStream.LA(1); + if (!(_la === 116 || _la === 882)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + break; + case MySqlParser.KW_REQUIRE_TABLE_PRIMARY_KEY_CHECK: + this.enterOuterAlt(localContext, 2); + { + this.state = 4645; + this.match(MySqlParser.KW_REQUIRE_TABLE_PRIMARY_KEY_CHECK); + this.state = 4646; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 4647; + _la = this.tokenStream.LA(1); + if (!(_la === 118 || _la === 119 || _la === 507)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + break; + case MySqlParser.KW_ASSIGN_GTIDS_TO_ANONYMOUS_TRANSACTIONS: + this.enterOuterAlt(localContext, 3); + { + this.state = 4648; + this.match(MySqlParser.KW_ASSIGN_GTIDS_TO_ANONYMOUS_TRANSACTIONS); + this.state = 4649; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 4653; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_OFF: + { + this.state = 4650; + this.match(MySqlParser.KW_OFF); + } + break; + case MySqlParser.KW_LOCAL: + { + this.state = 4651; + this.match(MySqlParser.KW_LOCAL); + } + break; + case MySqlParser.ZERO_DECIMAL: + case MySqlParser.ONE_DECIMAL: + case MySqlParser.TWO_DECIMAL: + case MySqlParser.THREE_DECIMAL: + case MySqlParser.STRING_LITERAL: + case MySqlParser.DECIMAL_LITERAL: + case MySqlParser.REAL_LITERAL: + { + this.state = 4652; + this.gtuidSet(); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + replicationSourceOption() { + let localContext = new ReplicationSourceOptionContext(this.context, this.state); + this.enterRule(localContext, 374, MySqlParser.RULE_replicationSourceOption); + let _la; + try { + this.state = 4684; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_NETWORK_NAMESPACE: + case MySqlParser.KW_RELAY_LOG_FILE: + case MySqlParser.KW_SOURCE_BIND: + case MySqlParser.KW_SOURCE_HOST: + case MySqlParser.KW_SOURCE_USER: + case MySqlParser.KW_SOURCE_PASSWORD: + case MySqlParser.KW_SOURCE_LOG_FILE: + case MySqlParser.KW_SOURCE_COMPRESSION_ALGORITHMS: + case MySqlParser.KW_SOURCE_SSL_CA: + case MySqlParser.KW_SOURCE_SSL_CAPATH: + case MySqlParser.KW_SOURCE_SSL_CERT: + case MySqlParser.KW_SOURCE_SSL_CRL: + case MySqlParser.KW_SOURCE_SSL_CRLPATH: + case MySqlParser.KW_SOURCE_SSL_KEY: + case MySqlParser.KW_SOURCE_SSL_CIPHER: + case MySqlParser.KW_SOURCE_TLS_VERSION: + case MySqlParser.KW_SOURCE_TLS_CIPHERSUITES: + case MySqlParser.KW_SOURCE_PUBLIC_KEY_PATH: + localContext = new SourceStringOptionContext(localContext); + this.enterOuterAlt(localContext, 1); + { + this.state = 4657; + this.stringSourceOption(); + this.state = 4658; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 4659; + this.match(MySqlParser.STRING_LITERAL); + } + break; + case MySqlParser.KW_RELAY_LOG_POS: + case MySqlParser.KW_SOURCE_PORT: + case MySqlParser.KW_SOURCE_LOG_POS: + case MySqlParser.KW_SOURCE_HEARTBEAT_PERIOD: + case MySqlParser.KW_SOURCE_CONNECT_RETRY: + case MySqlParser.KW_SOURCE_RETRY_COUNT: + case MySqlParser.KW_SOURCE_DELAY: + case MySqlParser.KW_SOURCE_ZSTD_COMPRESSION_LEVEL: + localContext = new SourceDecimalOptionContext(localContext); + this.enterOuterAlt(localContext, 2); + { + this.state = 4661; + this.decimalSourceOption(); + this.state = 4662; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 4663; + this.decimalLiteral(); + } + break; + case MySqlParser.KW_GET_SOURCE_PUBLIC_KEY: + case MySqlParser.KW_GTID_ONLY: + case MySqlParser.KW_REQUIRE_ROW_FORMAT: + case MySqlParser.KW_SOURCE_AUTO_POSITION: + case MySqlParser.KW_SOURCE_CONNECTION_AUTO_FAILOVER: + case MySqlParser.KW_SOURCE_SSL: + case MySqlParser.KW_SOURCE_SSL_VERIFY_SERVER_CERT: + localContext = new SourceBoolOptionContext(localContext); + this.enterOuterAlt(localContext, 3); + { + this.state = 4665; + this.boolSourceOption(); + this.state = 4666; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 4667; + localContext._boolVal = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 871 || _la === 872)) { + localContext._boolVal = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + break; + case MySqlParser.KW_ASSIGN_GTIDS_TO_ANONYMOUS_TRANSACTIONS: + case MySqlParser.KW_PRIVILEGE_CHECKS_USER: + case MySqlParser.KW_REQUIRE_TABLE_PRIMARY_KEY_CHECK: + localContext = new SourceOtherOptionContext(localContext); + this.enterOuterAlt(localContext, 4); + { + this.state = 4669; + this.otherSourceOption(); + } + break; + case MySqlParser.KW_IGNORE_SERVER_IDS: + localContext = new SourceUidListOptionContext(localContext); + this.enterOuterAlt(localContext, 5); + { + this.state = 4670; + this.match(MySqlParser.KW_IGNORE_SERVER_IDS); + this.state = 4671; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 4672; + this.match(MySqlParser.LR_BRACKET); + this.state = 4681; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if ((((_la) & ~0x1F) === 0 && ((1 << _la) & 1074302976) !== 0) || ((((_la - 36)) & ~0x1F) === 0 && ((1 << (_la - 36)) & 11014219) !== 0) || ((((_la - 74)) & ~0x1F) === 0 && ((1 << (_la - 74)) & 18878481) !== 0) || ((((_la - 117)) & ~0x1F) === 0 && ((1 << (_la - 117)) & 100679969) !== 0) || ((((_la - 150)) & ~0x1F) === 0 && ((1 << (_la - 150)) & 1049605) !== 0) || ((((_la - 219)) & ~0x1F) === 0 && ((1 << (_la - 219)) & 5374495) !== 0) || ((((_la - 253)) & ~0x1F) === 0 && ((1 << (_la - 253)) & 4294967295) !== 0) || ((((_la - 285)) & ~0x1F) === 0 && ((1 << (_la - 285)) & 4261412607) !== 0) || ((((_la - 317)) & ~0x1F) === 0 && ((1 << (_la - 317)) & 4160741375) !== 0) || ((((_la - 349)) & ~0x1F) === 0 && ((1 << (_la - 349)) & 4026531839) !== 0) || ((((_la - 381)) & ~0x1F) === 0 && ((1 << (_la - 381)) & 1055907839) !== 0) || ((((_la - 413)) & ~0x1F) === 0 && ((1 << (_la - 413)) & 4294885367) !== 0) || ((((_la - 445)) & ~0x1F) === 0 && ((1 << (_la - 445)) & 3757571071) !== 0) || ((((_la - 478)) & ~0x1F) === 0 && ((1 << (_la - 478)) & 3755999231) !== 0) || ((((_la - 510)) & ~0x1F) === 0 && ((1 << (_la - 510)) & 3751780349) !== 0) || ((((_la - 542)) & ~0x1F) === 0 && ((1 << (_la - 542)) & 2141183997) !== 0) || ((((_la - 575)) & ~0x1F) === 0 && ((1 << (_la - 575)) & 2147483629) !== 0) || ((((_la - 633)) & ~0x1F) === 0 && ((1 << (_la - 633)) & 4294934527) !== 0) || ((((_la - 665)) & ~0x1F) === 0 && ((1 << (_la - 665)) & 4278189053) !== 0) || ((((_la - 697)) & ~0x1F) === 0 && ((1 << (_la - 697)) & 1644099327) !== 0) || ((((_la - 729)) & ~0x1F) === 0 && ((1 << (_la - 729)) & 4294900735) !== 0) || ((((_la - 761)) & ~0x1F) === 0 && ((1 << (_la - 761)) & 4294967295) !== 0) || ((((_la - 793)) & ~0x1F) === 0 && ((1 << (_la - 793)) & 4288675839) !== 0) || ((((_la - 825)) & ~0x1F) === 0 && ((1 << (_la - 825)) & 2147527671) !== 0) || ((((_la - 879)) & ~0x1F) === 0 && ((1 << (_la - 879)) & 1033) !== 0)) { + { + this.state = 4673; + localContext._server_id = this.uid(); + this.state = 4678; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 4674; + this.match(MySqlParser.COMMA); + this.state = 4675; + localContext._server_id = this.uid(); + } + } + this.state = 4680; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + } + this.state = 4683; + this.match(MySqlParser.RR_BRACKET); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + stringSourceOption() { + let localContext = new StringSourceOptionContext(this.context, this.state); + this.enterRule(localContext, 376, MySqlParser.RULE_stringSourceOption); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 4686; + _la = this.tokenStream.LA(1); + if (!(_la === 499 || _la === 557 || ((((_la - 606)) & ~0x1F) === 0 && ((1 << (_la - 606)) & 125771823) !== 0))) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + decimalSourceOption() { + let localContext = new DecimalSourceOptionContext(this.context, this.state); + this.enterRule(localContext, 378, MySqlParser.RULE_decimalSourceOption); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 4688; + _la = this.tokenStream.LA(1); + if (!(_la === 558 || ((((_la - 610)) & ~0x1F) === 0 && ((1 << (_la - 610)) & 1397) !== 0))) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + boolSourceOption() { + let localContext = new BoolSourceOptionContext(this.context, this.state); + this.enterRule(localContext, 380, MySqlParser.RULE_boolSourceOption); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 4690; + _la = this.tokenStream.LA(1); + if (!(_la === 412 || _la === 416 || _la === 573 || ((((_la - 613)) & ~0x1F) === 0 && ((1 << (_la - 613)) & 65809) !== 0))) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + otherSourceOption() { + let localContext = new OtherSourceOptionContext(this.context, this.state); + this.enterRule(localContext, 382, MySqlParser.RULE_otherSourceOption); + let _la; + try { + this.state = 4705; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_PRIVILEGE_CHECKS_USER: + this.enterOuterAlt(localContext, 1); + { + this.state = 4692; + this.match(MySqlParser.KW_PRIVILEGE_CHECKS_USER); + this.state = 4693; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 4694; + _la = this.tokenStream.LA(1); + if (!(_la === 116 || _la === 882)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + break; + case MySqlParser.KW_REQUIRE_TABLE_PRIMARY_KEY_CHECK: + this.enterOuterAlt(localContext, 2); + { + this.state = 4695; + this.match(MySqlParser.KW_REQUIRE_TABLE_PRIMARY_KEY_CHECK); + this.state = 4696; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 4697; + _la = this.tokenStream.LA(1); + if (!(_la === 70 || _la === 118 || _la === 119 || _la === 507)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + break; + case MySqlParser.KW_ASSIGN_GTIDS_TO_ANONYMOUS_TRANSACTIONS: + this.enterOuterAlt(localContext, 3); + { + this.state = 4698; + this.match(MySqlParser.KW_ASSIGN_GTIDS_TO_ANONYMOUS_TRANSACTIONS); + this.state = 4699; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 4703; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_OFF: + { + this.state = 4700; + this.match(MySqlParser.KW_OFF); + } + break; + case MySqlParser.KW_LOCAL: + { + this.state = 4701; + this.match(MySqlParser.KW_LOCAL); + } + break; + case MySqlParser.ZERO_DECIMAL: + case MySqlParser.ONE_DECIMAL: + case MySqlParser.TWO_DECIMAL: + case MySqlParser.THREE_DECIMAL: + case MySqlParser.STRING_LITERAL: + case MySqlParser.DECIMAL_LITERAL: + case MySqlParser.REAL_LITERAL: + { + this.state = 4702; + this.gtuidSet(); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + channelOption() { + let localContext = new ChannelOptionContext(this.context, this.state); + this.enterRule(localContext, 384, MySqlParser.RULE_channelOption); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 4707; + this.match(MySqlParser.KW_FOR); + this.state = 4708; + this.match(MySqlParser.KW_CHANNEL); + this.state = 4709; + this.match(MySqlParser.STRING_LITERAL); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + replicationFilter() { + let localContext = new ReplicationFilterContext(this.context, this.state); + this.enterRule(localContext, 386, MySqlParser.RULE_replicationFilter); + let _la; + try { + this.state = 4774; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_REPLICATE_DO_DB: + localContext = new DoDbReplicationContext(localContext); + this.enterOuterAlt(localContext, 1); + { + this.state = 4711; + this.match(MySqlParser.KW_REPLICATE_DO_DB); + this.state = 4712; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 4713; + this.match(MySqlParser.LR_BRACKET); + this.state = 4714; + this.databaseName(); + this.state = 4719; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 4715; + this.match(MySqlParser.COMMA); + this.state = 4716; + this.databaseName(); + } + } + this.state = 4721; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 4722; + this.match(MySqlParser.RR_BRACKET); + } + break; + case MySqlParser.KW_REPLICATE_IGNORE_DB: + localContext = new IgnoreDbReplicationContext(localContext); + this.enterOuterAlt(localContext, 2); + { + this.state = 4724; + this.match(MySqlParser.KW_REPLICATE_IGNORE_DB); + this.state = 4725; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 4726; + this.match(MySqlParser.LR_BRACKET); + this.state = 4727; + this.databaseName(); + this.state = 4732; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 4728; + this.match(MySqlParser.COMMA); + this.state = 4729; + this.databaseName(); + } + } + this.state = 4734; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 4735; + this.match(MySqlParser.RR_BRACKET); + } + break; + case MySqlParser.KW_REPLICATE_DO_TABLE: + localContext = new DoTableReplicationContext(localContext); + this.enterOuterAlt(localContext, 3); + { + this.state = 4737; + this.match(MySqlParser.KW_REPLICATE_DO_TABLE); + this.state = 4738; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 4739; + this.match(MySqlParser.LR_BRACKET); + this.state = 4740; + this.tableNames(); + this.state = 4741; + this.match(MySqlParser.RR_BRACKET); + } + break; + case MySqlParser.KW_REPLICATE_IGNORE_TABLE: + localContext = new IgnoreTableReplicationContext(localContext); + this.enterOuterAlt(localContext, 4); + { + this.state = 4743; + this.match(MySqlParser.KW_REPLICATE_IGNORE_TABLE); + this.state = 4744; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 4745; + this.match(MySqlParser.LR_BRACKET); + this.state = 4746; + this.tableNames(); + this.state = 4747; + this.match(MySqlParser.RR_BRACKET); + } + break; + case MySqlParser.KW_REPLICATE_WILD_DO_TABLE: + localContext = new WildDoTableReplicationContext(localContext); + this.enterOuterAlt(localContext, 5); + { + this.state = 4749; + this.match(MySqlParser.KW_REPLICATE_WILD_DO_TABLE); + this.state = 4750; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 4751; + this.match(MySqlParser.LR_BRACKET); + this.state = 4752; + this.simpleStrings(); + this.state = 4753; + this.match(MySqlParser.RR_BRACKET); + } + break; + case MySqlParser.KW_REPLICATE_WILD_IGNORE_TABLE: + localContext = new WildIgnoreTableReplicationContext(localContext); + this.enterOuterAlt(localContext, 6); + { + this.state = 4755; + this.match(MySqlParser.KW_REPLICATE_WILD_IGNORE_TABLE); + this.state = 4756; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 4757; + this.match(MySqlParser.LR_BRACKET); + this.state = 4758; + this.simpleStrings(); + this.state = 4759; + this.match(MySqlParser.RR_BRACKET); + } + break; + case MySqlParser.KW_REPLICATE_REWRITE_DB: + localContext = new RewriteDbReplicationContext(localContext); + this.enterOuterAlt(localContext, 7); + { + this.state = 4761; + this.match(MySqlParser.KW_REPLICATE_REWRITE_DB); + this.state = 4762; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 4763; + this.match(MySqlParser.LR_BRACKET); + this.state = 4764; + this.tablePair(); + this.state = 4769; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 4765; + this.match(MySqlParser.COMMA); + this.state = 4766; + this.tablePair(); + } + } + this.state = 4771; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 4772; + this.match(MySqlParser.RR_BRACKET); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + tablePair() { + let localContext = new TablePairContext(this.context, this.state); + this.enterRule(localContext, 388, MySqlParser.RULE_tablePair); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 4776; + this.match(MySqlParser.LR_BRACKET); + this.state = 4777; + localContext._firstTable = this.tableName(); + this.state = 4778; + this.match(MySqlParser.COMMA); + this.state = 4779; + localContext._secondTable = this.tableName(); + this.state = 4780; + this.match(MySqlParser.RR_BRACKET); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + threadType() { + let localContext = new ThreadTypeContext(this.context, this.state); + this.enterRule(localContext, 390, MySqlParser.RULE_threadType); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 4782; + _la = this.tokenStream.LA(1); + if (!(_la === 438 || _la === 639)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + untilOption() { + let localContext = new UntilOptionContext(this.context, this.state); + this.enterRule(localContext, 392, MySqlParser.RULE_untilOption); + let _la; + try { + this.state = 4809; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_SQL_AFTER_GTIDS: + case MySqlParser.KW_SQL_BEFORE_GTIDS: + localContext = new GtidsUntilOptionContext(localContext); + this.enterOuterAlt(localContext, 1); + { + this.state = 4784; + localContext._gtids = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 633 || _la === 635)) { + localContext._gtids = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 4785; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 4786; + this.gtuidSet(); + } + break; + case MySqlParser.KW_MASTER_LOG_FILE: + localContext = new MasterLogUntilOptionContext(localContext); + this.enterOuterAlt(localContext, 2); + { + this.state = 4787; + this.match(MySqlParser.KW_MASTER_LOG_FILE); + this.state = 4788; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 4789; + this.match(MySqlParser.STRING_LITERAL); + this.state = 4790; + this.match(MySqlParser.COMMA); + this.state = 4791; + this.match(MySqlParser.KW_MASTER_LOG_POS); + this.state = 4792; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 4793; + this.decimalLiteral(); + } + break; + case MySqlParser.KW_SOURCE_LOG_FILE: + localContext = new SourceLogUntilOptionContext(localContext); + this.enterOuterAlt(localContext, 3); + { + this.state = 4794; + this.match(MySqlParser.KW_SOURCE_LOG_FILE); + this.state = 4795; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 4796; + this.match(MySqlParser.STRING_LITERAL); + this.state = 4797; + this.match(MySqlParser.COMMA); + this.state = 4798; + this.match(MySqlParser.KW_SOURCE_LOG_POS); + this.state = 4799; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 4800; + this.decimalLiteral(); + } + break; + case MySqlParser.KW_RELAY_LOG_FILE: + localContext = new RelayLogUntilOptionContext(localContext); + this.enterOuterAlt(localContext, 4); + { + this.state = 4801; + this.match(MySqlParser.KW_RELAY_LOG_FILE); + this.state = 4802; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 4803; + this.match(MySqlParser.STRING_LITERAL); + this.state = 4804; + this.match(MySqlParser.COMMA); + this.state = 4805; + this.match(MySqlParser.KW_RELAY_LOG_POS); + this.state = 4806; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 4807; + this.decimalLiteral(); + } + break; + case MySqlParser.KW_SQL_AFTER_MTS_GAPS: + localContext = new SqlGapsUntilOptionContext(localContext); + this.enterOuterAlt(localContext, 5); + { + this.state = 4808; + this.match(MySqlParser.KW_SQL_AFTER_MTS_GAPS); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + connectionOptions() { + let localContext = new ConnectionOptionsContext(this.context, this.state); + this.enterRule(localContext, 394, MySqlParser.RULE_connectionOptions); + try { + this.state = 4823; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_USER: + localContext = new UserConnectionOptionContext(localContext); + this.enterOuterAlt(localContext, 1); + { + this.state = 4811; + this.match(MySqlParser.KW_USER); + this.state = 4812; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 4813; + localContext._conOptUser = this.match(MySqlParser.STRING_LITERAL); + } + break; + case MySqlParser.KW_PASSWORD: + localContext = new PasswordConnectionOptionContext(localContext); + this.enterOuterAlt(localContext, 2); + { + this.state = 4814; + this.match(MySqlParser.KW_PASSWORD); + this.state = 4815; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 4816; + localContext._conOptPassword = this.match(MySqlParser.STRING_LITERAL); + } + break; + case MySqlParser.KW_DEFAULT_AUTH: + localContext = new DefaultAuthConnectionOptionContext(localContext); + this.enterOuterAlt(localContext, 3); + { + this.state = 4817; + this.match(MySqlParser.KW_DEFAULT_AUTH); + this.state = 4818; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 4819; + localContext._conOptDefAuth = this.match(MySqlParser.STRING_LITERAL); + } + break; + case MySqlParser.KW_PLUGIN_DIR: + localContext = new PluginDirConnectionOptionContext(localContext); + this.enterOuterAlt(localContext, 4); + { + this.state = 4820; + this.match(MySqlParser.KW_PLUGIN_DIR); + this.state = 4821; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 4822; + localContext._conOptPluginDir = this.match(MySqlParser.STRING_LITERAL); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + gtuidSet() { + let localContext = new GtuidSetContext(this.context, this.state); + this.enterRule(localContext, 396, MySqlParser.RULE_gtuidSet); + try { + let alternative; + this.state = 4834; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.ZERO_DECIMAL: + case MySqlParser.ONE_DECIMAL: + case MySqlParser.TWO_DECIMAL: + case MySqlParser.THREE_DECIMAL: + case MySqlParser.DECIMAL_LITERAL: + case MySqlParser.REAL_LITERAL: + this.enterOuterAlt(localContext, 1); + { + this.state = 4825; + this.uuidSet(); + this.state = 4830; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 680, this.context); + while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER) { + if (alternative === 1) { + { + { + this.state = 4826; + this.match(MySqlParser.COMMA); + this.state = 4827; + this.uuidSet(); + } + } + } + this.state = 4832; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 680, this.context); + } + } + break; + case MySqlParser.STRING_LITERAL: + this.enterOuterAlt(localContext, 2); + { + this.state = 4833; + this.match(MySqlParser.STRING_LITERAL); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + xaStartTransaction() { + let localContext = new XaStartTransactionContext(this.context, this.state); + this.enterRule(localContext, 398, MySqlParser.RULE_xaStartTransaction); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 4836; + this.match(MySqlParser.KW_XA); + this.state = 4837; + localContext._xaStart = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 317 || _la === 640)) { + localContext._xaStart = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 4838; + this.xid(); + this.state = 4840; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 91 || _la === 577) { + { + this.state = 4839; + localContext._xaAction = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 91 || _la === 577)) { + localContext._xaAction = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + xaEndTransaction() { + let localContext = new XaEndTransactionContext(this.context, this.state); + this.enterRule(localContext, 400, MySqlParser.RULE_xaEndTransaction); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 4842; + this.match(MySqlParser.KW_XA); + this.state = 4843; + this.match(MySqlParser.KW_END); + this.state = 4844; + this.xid(); + this.state = 4850; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 654) { + { + this.state = 4845; + this.match(MySqlParser.KW_SUSPEND); + this.state = 4848; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 65) { + { + this.state = 4846; + this.match(MySqlParser.KW_FOR); + this.state = 4847; + this.match(MySqlParser.KW_MIGRATE); + } + } + } + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + xaPrepareStatement() { + let localContext = new XaPrepareStatementContext(this.context, this.state); + this.enterRule(localContext, 402, MySqlParser.RULE_xaPrepareStatement); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 4852; + this.match(MySqlParser.KW_XA); + this.state = 4853; + this.match(MySqlParser.KW_PREPARE); + this.state = 4854; + this.xid(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + xaCommitWork() { + let localContext = new XaCommitWorkContext(this.context, this.state); + this.enterRule(localContext, 404, MySqlParser.RULE_xaCommitWork); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 4856; + this.match(MySqlParser.KW_XA); + this.state = 4857; + this.match(MySqlParser.KW_COMMIT); + this.state = 4858; + this.xid(); + this.state = 4861; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 513) { + { + this.state = 4859; + this.match(MySqlParser.KW_ONE); + this.state = 4860; + this.match(MySqlParser.KW_PHASE); + } + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + xaRollbackWork() { + let localContext = new XaRollbackWorkContext(this.context, this.state); + this.enterRule(localContext, 406, MySqlParser.RULE_xaRollbackWork); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 4863; + this.match(MySqlParser.KW_XA); + this.state = 4864; + this.match(MySqlParser.KW_ROLLBACK); + this.state = 4865; + this.xid(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + xaRecoverWork() { + let localContext = new XaRecoverWorkContext(this.context, this.state); + this.enterRule(localContext, 408, MySqlParser.RULE_xaRecoverWork); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 4867; + this.match(MySqlParser.KW_XA); + this.state = 4868; + this.match(MySqlParser.KW_RECOVER); + this.state = 4871; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 33) { + { + this.state = 4869; + this.match(MySqlParser.KW_CONVERT); + this.state = 4870; + this.xid(); + } + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + prepareStatement() { + let localContext = new PrepareStatementContext(this.context, this.state); + this.enterRule(localContext, 410, MySqlParser.RULE_prepareStatement); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 4873; + this.match(MySqlParser.KW_PREPARE); + this.state = 4874; + localContext._stmt_name = this.uid(); + this.state = 4875; + this.match(MySqlParser.KW_FROM); + this.state = 4878; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.STRING_LITERAL: + { + this.state = 4876; + localContext._query = this.match(MySqlParser.STRING_LITERAL); + } + break; + case MySqlParser.LOCAL_ID: + { + this.state = 4877; + localContext._variable = this.match(MySqlParser.LOCAL_ID); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + executeStatement() { + let localContext = new ExecuteStatementContext(this.context, this.state); + this.enterRule(localContext, 412, MySqlParser.RULE_executeStatement); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 4880; + this.match(MySqlParser.KW_EXECUTE); + this.state = 4881; + localContext._stmt_name = this.uid(); + this.state = 4884; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 188) { + { + this.state = 4882; + this.match(MySqlParser.KW_USING); + this.state = 4883; + this.userVariables(); + } + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + deallocatePrepare() { + let localContext = new DeallocatePrepareContext(this.context, this.state); + this.enterRule(localContext, 414, MySqlParser.RULE_deallocatePrepare); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 4886; + localContext._dropFormat = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 51 || _la === 362)) { + localContext._dropFormat = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 4887; + this.match(MySqlParser.KW_PREPARE); + this.state = 4888; + localContext._stmt_name = this.uid(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + routineBody() { + let localContext = new RoutineBodyContext(this.context, this.state); + this.enterRule(localContext, 416, MySqlParser.RULE_routineBody); + try { + this.state = 4892; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 689, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 4890; + this.blockStatement(); + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 4891; + this.sqlStatement(); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + blockStatement() { + let localContext = new BlockStatementContext(this.context, this.state); + this.enterRule(localContext, 418, MySqlParser.RULE_blockStatement); + let _la; + try { + let alternative; + this.enterOuterAlt(localContext, 1); + { + this.state = 4897; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 690, this.context)) { + case 1: + { + this.state = 4894; + localContext._begin = this.uid(); + this.state = 4895; + this.match(MySqlParser.COLON_SYMB); + } + break; + } + this.state = 4899; + this.match(MySqlParser.KW_BEGIN); + this.state = 4905; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 691, this.context); + while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER) { + if (alternative === 1) { + { + { + this.state = 4900; + this.declareVariable(); + this.state = 4901; + this.match(MySqlParser.SEMI); + } + } + } + this.state = 4907; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 691, this.context); + } + this.state = 4913; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 692, this.context); + while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER) { + if (alternative === 1) { + { + { + this.state = 4908; + this.declareCondition(); + this.state = 4909; + this.match(MySqlParser.SEMI); + } + } + } + this.state = 4915; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 692, this.context); + } + this.state = 4921; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 693, this.context); + while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER) { + if (alternative === 1) { + { + { + this.state = 4916; + this.declareCursor(); + this.state = 4917; + this.match(MySqlParser.SEMI); + } + } + } + this.state = 4923; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 693, this.context); + } + this.state = 4929; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 41) { + { + { + this.state = 4924; + this.declareHandler(); + this.state = 4925; + this.match(MySqlParser.SEMI); + } + } + this.state = 4931; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 4935; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 695, this.context); + while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER) { + if (alternative === 1) { + { + { + this.state = 4932; + this.procedureSqlStatement(); + } + } + } + this.state = 4937; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 695, this.context); + } + this.state = 4938; + this.match(MySqlParser.KW_END); + this.state = 4940; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 696, this.context)) { + case 1: + { + this.state = 4939; + localContext._end = this.uid(); + } + break; + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + caseStatement() { + let localContext = new CaseStatementContext(this.context, this.state); + this.enterRule(localContext, 420, MySqlParser.RULE_caseStatement); + let _la; + try { + let alternative; + this.enterOuterAlt(localContext, 1); + { + this.state = 4942; + this.match(MySqlParser.KW_CASE); + this.state = 4945; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 697, this.context)) { + case 1: + { + this.state = 4943; + localContext._case_value = this.uid(); + } + break; + case 2: + { + this.state = 4944; + this.expression(0); + } + break; + } + this.state = 4948; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + do { + { + { + this.state = 4947; + this.caseAlternative(); + } + } + this.state = 4950; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } while (_la === 191); + this.state = 4958; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 53) { + { + this.state = 4952; + this.match(MySqlParser.KW_ELSE); + this.state = 4954; + this.errorHandler.sync(this); + alternative = 1; + do { + switch (alternative) { + case 1: + { + { + this.state = 4953; + this.procedureSqlStatement(); + } + } + break; + default: + throw new antlr.NoViableAltException(this); + } + this.state = 4956; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 699, this.context); + } while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER); + } + } + this.state = 4960; + this.match(MySqlParser.KW_END); + this.state = 4961; + this.match(MySqlParser.KW_CASE); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + ifStatement() { + let localContext = new IfStatementContext(this.context, this.state); + this.enterRule(localContext, 422, MySqlParser.RULE_ifStatement); + let _la; + try { + let alternative; + this.enterOuterAlt(localContext, 1); + { + this.state = 4963; + this.match(MySqlParser.KW_IF); + this.state = 4964; + this.expression(0); + this.state = 4965; + this.match(MySqlParser.KW_THEN); + this.state = 4967; + this.errorHandler.sync(this); + alternative = 1; + do { + switch (alternative) { + case 1: + { + { + this.state = 4966; + localContext._procedureSqlStatement = this.procedureSqlStatement(); + localContext._thenStatements.push(localContext._procedureSqlStatement); + } + } + break; + default: + throw new antlr.NoViableAltException(this); + } + this.state = 4969; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 701, this.context); + } while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER); + this.state = 4974; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 54) { + { + { + this.state = 4971; + this.elifAlternative(); + } + } + this.state = 4976; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 4983; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 53) { + { + this.state = 4977; + this.match(MySqlParser.KW_ELSE); + this.state = 4979; + this.errorHandler.sync(this); + alternative = 1; + do { + switch (alternative) { + case 1: + { + { + this.state = 4978; + localContext._procedureSqlStatement = this.procedureSqlStatement(); + localContext._elseStatements.push(localContext._procedureSqlStatement); + } + } + break; + default: + throw new antlr.NoViableAltException(this); + } + this.state = 4981; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 703, this.context); + } while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER); + } + } + this.state = 4985; + this.match(MySqlParser.KW_END); + this.state = 4986; + this.match(MySqlParser.KW_IF); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + iterateStatement() { + let localContext = new IterateStatementContext(this.context, this.state); + this.enterRule(localContext, 424, MySqlParser.RULE_iterateStatement); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 4988; + this.match(MySqlParser.KW_ITERATE); + this.state = 4989; + localContext._label = this.uid(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + leaveStatement() { + let localContext = new LeaveStatementContext(this.context, this.state); + this.enterRule(localContext, 426, MySqlParser.RULE_leaveStatement); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 4991; + this.match(MySqlParser.KW_LEAVE); + this.state = 4992; + localContext._label = this.uid(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + loopStatement() { + let localContext = new LoopStatementContext(this.context, this.state); + this.enterRule(localContext, 428, MySqlParser.RULE_loopStatement); + let _la; + try { + let alternative; + this.enterOuterAlt(localContext, 1); + { + this.state = 4997; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if ((((_la) & ~0x1F) === 0 && ((1 << _la) & 1074302976) !== 0) || ((((_la - 36)) & ~0x1F) === 0 && ((1 << (_la - 36)) & 11014219) !== 0) || ((((_la - 74)) & ~0x1F) === 0 && ((1 << (_la - 74)) & 18878481) !== 0) || ((((_la - 117)) & ~0x1F) === 0 && ((1 << (_la - 117)) & 100679969) !== 0) || ((((_la - 150)) & ~0x1F) === 0 && ((1 << (_la - 150)) & 1049605) !== 0) || ((((_la - 219)) & ~0x1F) === 0 && ((1 << (_la - 219)) & 5374495) !== 0) || ((((_la - 253)) & ~0x1F) === 0 && ((1 << (_la - 253)) & 4294967295) !== 0) || ((((_la - 285)) & ~0x1F) === 0 && ((1 << (_la - 285)) & 4261412607) !== 0) || ((((_la - 317)) & ~0x1F) === 0 && ((1 << (_la - 317)) & 4160741375) !== 0) || ((((_la - 349)) & ~0x1F) === 0 && ((1 << (_la - 349)) & 4026531839) !== 0) || ((((_la - 381)) & ~0x1F) === 0 && ((1 << (_la - 381)) & 1055907839) !== 0) || ((((_la - 413)) & ~0x1F) === 0 && ((1 << (_la - 413)) & 4294885367) !== 0) || ((((_la - 445)) & ~0x1F) === 0 && ((1 << (_la - 445)) & 3757571071) !== 0) || ((((_la - 478)) & ~0x1F) === 0 && ((1 << (_la - 478)) & 3755999231) !== 0) || ((((_la - 510)) & ~0x1F) === 0 && ((1 << (_la - 510)) & 3751780349) !== 0) || ((((_la - 542)) & ~0x1F) === 0 && ((1 << (_la - 542)) & 2141183997) !== 0) || ((((_la - 575)) & ~0x1F) === 0 && ((1 << (_la - 575)) & 2147483629) !== 0) || ((((_la - 633)) & ~0x1F) === 0 && ((1 << (_la - 633)) & 4294934527) !== 0) || ((((_la - 665)) & ~0x1F) === 0 && ((1 << (_la - 665)) & 4278189053) !== 0) || ((((_la - 697)) & ~0x1F) === 0 && ((1 << (_la - 697)) & 1644099327) !== 0) || ((((_la - 729)) & ~0x1F) === 0 && ((1 << (_la - 729)) & 4294900735) !== 0) || ((((_la - 761)) & ~0x1F) === 0 && ((1 << (_la - 761)) & 4294967295) !== 0) || ((((_la - 793)) & ~0x1F) === 0 && ((1 << (_la - 793)) & 4288675839) !== 0) || ((((_la - 825)) & ~0x1F) === 0 && ((1 << (_la - 825)) & 2147527671) !== 0) || ((((_la - 879)) & ~0x1F) === 0 && ((1 << (_la - 879)) & 1033) !== 0)) { + { + this.state = 4994; + localContext._begin_label = this.uid(); + this.state = 4995; + this.match(MySqlParser.COLON_SYMB); + } + } + this.state = 4999; + this.match(MySqlParser.KW_LOOP); + this.state = 5001; + this.errorHandler.sync(this); + alternative = 1; + do { + switch (alternative) { + case 1: + { + { + this.state = 5000; + this.procedureSqlStatement(); + } + } + break; + default: + throw new antlr.NoViableAltException(this); + } + this.state = 5003; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 706, this.context); + } while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER); + this.state = 5005; + this.match(MySqlParser.KW_END); + this.state = 5006; + this.match(MySqlParser.KW_LOOP); + this.state = 5008; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if ((((_la) & ~0x1F) === 0 && ((1 << _la) & 1074302976) !== 0) || ((((_la - 36)) & ~0x1F) === 0 && ((1 << (_la - 36)) & 11014219) !== 0) || ((((_la - 74)) & ~0x1F) === 0 && ((1 << (_la - 74)) & 18878481) !== 0) || ((((_la - 117)) & ~0x1F) === 0 && ((1 << (_la - 117)) & 100679969) !== 0) || ((((_la - 150)) & ~0x1F) === 0 && ((1 << (_la - 150)) & 1049605) !== 0) || ((((_la - 219)) & ~0x1F) === 0 && ((1 << (_la - 219)) & 5374495) !== 0) || ((((_la - 253)) & ~0x1F) === 0 && ((1 << (_la - 253)) & 4294967295) !== 0) || ((((_la - 285)) & ~0x1F) === 0 && ((1 << (_la - 285)) & 4261412607) !== 0) || ((((_la - 317)) & ~0x1F) === 0 && ((1 << (_la - 317)) & 4160741375) !== 0) || ((((_la - 349)) & ~0x1F) === 0 && ((1 << (_la - 349)) & 4026531839) !== 0) || ((((_la - 381)) & ~0x1F) === 0 && ((1 << (_la - 381)) & 1055907839) !== 0) || ((((_la - 413)) & ~0x1F) === 0 && ((1 << (_la - 413)) & 4294885367) !== 0) || ((((_la - 445)) & ~0x1F) === 0 && ((1 << (_la - 445)) & 3757571071) !== 0) || ((((_la - 478)) & ~0x1F) === 0 && ((1 << (_la - 478)) & 3755999231) !== 0) || ((((_la - 510)) & ~0x1F) === 0 && ((1 << (_la - 510)) & 3751780349) !== 0) || ((((_la - 542)) & ~0x1F) === 0 && ((1 << (_la - 542)) & 2141183997) !== 0) || ((((_la - 575)) & ~0x1F) === 0 && ((1 << (_la - 575)) & 2147483629) !== 0) || ((((_la - 633)) & ~0x1F) === 0 && ((1 << (_la - 633)) & 4294934527) !== 0) || ((((_la - 665)) & ~0x1F) === 0 && ((1 << (_la - 665)) & 4278189053) !== 0) || ((((_la - 697)) & ~0x1F) === 0 && ((1 << (_la - 697)) & 1644099327) !== 0) || ((((_la - 729)) & ~0x1F) === 0 && ((1 << (_la - 729)) & 4294900735) !== 0) || ((((_la - 761)) & ~0x1F) === 0 && ((1 << (_la - 761)) & 4294967295) !== 0) || ((((_la - 793)) & ~0x1F) === 0 && ((1 << (_la - 793)) & 4288675839) !== 0) || ((((_la - 825)) & ~0x1F) === 0 && ((1 << (_la - 825)) & 2147527671) !== 0) || ((((_la - 879)) & ~0x1F) === 0 && ((1 << (_la - 879)) & 1033) !== 0)) { + { + this.state = 5007; + localContext._end_label = this.uid(); + } + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + repeatStatement() { + let localContext = new RepeatStatementContext(this.context, this.state); + this.enterRule(localContext, 430, MySqlParser.RULE_repeatStatement); + let _la; + try { + let alternative; + this.enterOuterAlt(localContext, 1); + { + this.state = 5013; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 708, this.context)) { + case 1: + { + this.state = 5010; + localContext._begin_label = this.uid(); + this.state = 5011; + this.match(MySqlParser.COLON_SYMB); + } + break; + } + this.state = 5015; + this.match(MySqlParser.KW_REPEAT); + this.state = 5017; + this.errorHandler.sync(this); + alternative = 1; + do { + switch (alternative) { + case 1: + { + { + this.state = 5016; + this.procedureSqlStatement(); + } + } + break; + default: + throw new antlr.NoViableAltException(this); + } + this.state = 5019; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 709, this.context); + } while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER); + this.state = 5021; + this.match(MySqlParser.KW_UNTIL); + this.state = 5022; + this.expression(0); + this.state = 5023; + this.match(MySqlParser.KW_END); + this.state = 5024; + this.match(MySqlParser.KW_REPEAT); + this.state = 5026; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if ((((_la) & ~0x1F) === 0 && ((1 << _la) & 1074302976) !== 0) || ((((_la - 36)) & ~0x1F) === 0 && ((1 << (_la - 36)) & 11014219) !== 0) || ((((_la - 74)) & ~0x1F) === 0 && ((1 << (_la - 74)) & 18878481) !== 0) || ((((_la - 117)) & ~0x1F) === 0 && ((1 << (_la - 117)) & 100679969) !== 0) || ((((_la - 150)) & ~0x1F) === 0 && ((1 << (_la - 150)) & 1049605) !== 0) || ((((_la - 219)) & ~0x1F) === 0 && ((1 << (_la - 219)) & 5374495) !== 0) || ((((_la - 253)) & ~0x1F) === 0 && ((1 << (_la - 253)) & 4294967295) !== 0) || ((((_la - 285)) & ~0x1F) === 0 && ((1 << (_la - 285)) & 4261412607) !== 0) || ((((_la - 317)) & ~0x1F) === 0 && ((1 << (_la - 317)) & 4160741375) !== 0) || ((((_la - 349)) & ~0x1F) === 0 && ((1 << (_la - 349)) & 4026531839) !== 0) || ((((_la - 381)) & ~0x1F) === 0 && ((1 << (_la - 381)) & 1055907839) !== 0) || ((((_la - 413)) & ~0x1F) === 0 && ((1 << (_la - 413)) & 4294885367) !== 0) || ((((_la - 445)) & ~0x1F) === 0 && ((1 << (_la - 445)) & 3757571071) !== 0) || ((((_la - 478)) & ~0x1F) === 0 && ((1 << (_la - 478)) & 3755999231) !== 0) || ((((_la - 510)) & ~0x1F) === 0 && ((1 << (_la - 510)) & 3751780349) !== 0) || ((((_la - 542)) & ~0x1F) === 0 && ((1 << (_la - 542)) & 2141183997) !== 0) || ((((_la - 575)) & ~0x1F) === 0 && ((1 << (_la - 575)) & 2147483629) !== 0) || ((((_la - 633)) & ~0x1F) === 0 && ((1 << (_la - 633)) & 4294934527) !== 0) || ((((_la - 665)) & ~0x1F) === 0 && ((1 << (_la - 665)) & 4278189053) !== 0) || ((((_la - 697)) & ~0x1F) === 0 && ((1 << (_la - 697)) & 1644099327) !== 0) || ((((_la - 729)) & ~0x1F) === 0 && ((1 << (_la - 729)) & 4294900735) !== 0) || ((((_la - 761)) & ~0x1F) === 0 && ((1 << (_la - 761)) & 4294967295) !== 0) || ((((_la - 793)) & ~0x1F) === 0 && ((1 << (_la - 793)) & 4288675839) !== 0) || ((((_la - 825)) & ~0x1F) === 0 && ((1 << (_la - 825)) & 2147527671) !== 0) || ((((_la - 879)) & ~0x1F) === 0 && ((1 << (_la - 879)) & 1033) !== 0)) { + { + this.state = 5025; + localContext._end_label = this.uid(); + } + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + returnStatement() { + let localContext = new ReturnStatementContext(this.context, this.state); + this.enterRule(localContext, 432, MySqlParser.RULE_returnStatement); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 5028; + this.match(MySqlParser.KW_RETURN); + this.state = 5029; + this.expression(0); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + whileStatement() { + let localContext = new WhileStatementContext(this.context, this.state); + this.enterRule(localContext, 434, MySqlParser.RULE_whileStatement); + let _la; + try { + let alternative; + this.enterOuterAlt(localContext, 1); + { + this.state = 5034; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if ((((_la) & ~0x1F) === 0 && ((1 << _la) & 1074302976) !== 0) || ((((_la - 36)) & ~0x1F) === 0 && ((1 << (_la - 36)) & 11014219) !== 0) || ((((_la - 74)) & ~0x1F) === 0 && ((1 << (_la - 74)) & 18878481) !== 0) || ((((_la - 117)) & ~0x1F) === 0 && ((1 << (_la - 117)) & 100679969) !== 0) || ((((_la - 150)) & ~0x1F) === 0 && ((1 << (_la - 150)) & 1049605) !== 0) || ((((_la - 219)) & ~0x1F) === 0 && ((1 << (_la - 219)) & 5374495) !== 0) || ((((_la - 253)) & ~0x1F) === 0 && ((1 << (_la - 253)) & 4294967295) !== 0) || ((((_la - 285)) & ~0x1F) === 0 && ((1 << (_la - 285)) & 4261412607) !== 0) || ((((_la - 317)) & ~0x1F) === 0 && ((1 << (_la - 317)) & 4160741375) !== 0) || ((((_la - 349)) & ~0x1F) === 0 && ((1 << (_la - 349)) & 4026531839) !== 0) || ((((_la - 381)) & ~0x1F) === 0 && ((1 << (_la - 381)) & 1055907839) !== 0) || ((((_la - 413)) & ~0x1F) === 0 && ((1 << (_la - 413)) & 4294885367) !== 0) || ((((_la - 445)) & ~0x1F) === 0 && ((1 << (_la - 445)) & 3757571071) !== 0) || ((((_la - 478)) & ~0x1F) === 0 && ((1 << (_la - 478)) & 3755999231) !== 0) || ((((_la - 510)) & ~0x1F) === 0 && ((1 << (_la - 510)) & 3751780349) !== 0) || ((((_la - 542)) & ~0x1F) === 0 && ((1 << (_la - 542)) & 2141183997) !== 0) || ((((_la - 575)) & ~0x1F) === 0 && ((1 << (_la - 575)) & 2147483629) !== 0) || ((((_la - 633)) & ~0x1F) === 0 && ((1 << (_la - 633)) & 4294934527) !== 0) || ((((_la - 665)) & ~0x1F) === 0 && ((1 << (_la - 665)) & 4278189053) !== 0) || ((((_la - 697)) & ~0x1F) === 0 && ((1 << (_la - 697)) & 1644099327) !== 0) || ((((_la - 729)) & ~0x1F) === 0 && ((1 << (_la - 729)) & 4294900735) !== 0) || ((((_la - 761)) & ~0x1F) === 0 && ((1 << (_la - 761)) & 4294967295) !== 0) || ((((_la - 793)) & ~0x1F) === 0 && ((1 << (_la - 793)) & 4288675839) !== 0) || ((((_la - 825)) & ~0x1F) === 0 && ((1 << (_la - 825)) & 2147527671) !== 0) || ((((_la - 879)) & ~0x1F) === 0 && ((1 << (_la - 879)) & 1033) !== 0)) { + { + this.state = 5031; + localContext._begin_label = this.uid(); + this.state = 5032; + this.match(MySqlParser.COLON_SYMB); + } + } + this.state = 5036; + this.match(MySqlParser.KW_WHILE); + this.state = 5037; + this.expression(0); + this.state = 5038; + this.match(MySqlParser.KW_DO); + this.state = 5040; + this.errorHandler.sync(this); + alternative = 1; + do { + switch (alternative) { + case 1: + { + { + this.state = 5039; + this.procedureSqlStatement(); + } + } + break; + default: + throw new antlr.NoViableAltException(this); + } + this.state = 5042; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 712, this.context); + } while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER); + this.state = 5044; + this.match(MySqlParser.KW_END); + this.state = 5045; + this.match(MySqlParser.KW_WHILE); + this.state = 5047; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if ((((_la) & ~0x1F) === 0 && ((1 << _la) & 1074302976) !== 0) || ((((_la - 36)) & ~0x1F) === 0 && ((1 << (_la - 36)) & 11014219) !== 0) || ((((_la - 74)) & ~0x1F) === 0 && ((1 << (_la - 74)) & 18878481) !== 0) || ((((_la - 117)) & ~0x1F) === 0 && ((1 << (_la - 117)) & 100679969) !== 0) || ((((_la - 150)) & ~0x1F) === 0 && ((1 << (_la - 150)) & 1049605) !== 0) || ((((_la - 219)) & ~0x1F) === 0 && ((1 << (_la - 219)) & 5374495) !== 0) || ((((_la - 253)) & ~0x1F) === 0 && ((1 << (_la - 253)) & 4294967295) !== 0) || ((((_la - 285)) & ~0x1F) === 0 && ((1 << (_la - 285)) & 4261412607) !== 0) || ((((_la - 317)) & ~0x1F) === 0 && ((1 << (_la - 317)) & 4160741375) !== 0) || ((((_la - 349)) & ~0x1F) === 0 && ((1 << (_la - 349)) & 4026531839) !== 0) || ((((_la - 381)) & ~0x1F) === 0 && ((1 << (_la - 381)) & 1055907839) !== 0) || ((((_la - 413)) & ~0x1F) === 0 && ((1 << (_la - 413)) & 4294885367) !== 0) || ((((_la - 445)) & ~0x1F) === 0 && ((1 << (_la - 445)) & 3757571071) !== 0) || ((((_la - 478)) & ~0x1F) === 0 && ((1 << (_la - 478)) & 3755999231) !== 0) || ((((_la - 510)) & ~0x1F) === 0 && ((1 << (_la - 510)) & 3751780349) !== 0) || ((((_la - 542)) & ~0x1F) === 0 && ((1 << (_la - 542)) & 2141183997) !== 0) || ((((_la - 575)) & ~0x1F) === 0 && ((1 << (_la - 575)) & 2147483629) !== 0) || ((((_la - 633)) & ~0x1F) === 0 && ((1 << (_la - 633)) & 4294934527) !== 0) || ((((_la - 665)) & ~0x1F) === 0 && ((1 << (_la - 665)) & 4278189053) !== 0) || ((((_la - 697)) & ~0x1F) === 0 && ((1 << (_la - 697)) & 1644099327) !== 0) || ((((_la - 729)) & ~0x1F) === 0 && ((1 << (_la - 729)) & 4294900735) !== 0) || ((((_la - 761)) & ~0x1F) === 0 && ((1 << (_la - 761)) & 4294967295) !== 0) || ((((_la - 793)) & ~0x1F) === 0 && ((1 << (_la - 793)) & 4288675839) !== 0) || ((((_la - 825)) & ~0x1F) === 0 && ((1 << (_la - 825)) & 2147527671) !== 0) || ((((_la - 879)) & ~0x1F) === 0 && ((1 << (_la - 879)) & 1033) !== 0)) { + { + this.state = 5046; + localContext._end_label = this.uid(); + } + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + cursorStatement() { + let localContext = new CursorStatementContext(this.context, this.state); + this.enterRule(localContext, 436, MySqlParser.RULE_cursorStatement); + let _la; + try { + this.state = 5064; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_CLOSE: + localContext = new CloseCursorContext(localContext); + this.enterOuterAlt(localContext, 1); + { + this.state = 5049; + this.match(MySqlParser.KW_CLOSE); + this.state = 5050; + localContext._cursor_name = this.uid(); + } + break; + case MySqlParser.KW_FETCH: + localContext = new FetchCursorContext(localContext); + this.enterOuterAlt(localContext, 2); + { + this.state = 5051; + this.match(MySqlParser.KW_FETCH); + this.state = 5056; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 715, this.context)) { + case 1: + { + this.state = 5053; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 501) { + { + this.state = 5052; + this.match(MySqlParser.KW_NEXT); + } + } + this.state = 5055; + this.match(MySqlParser.KW_FROM); + } + break; + } + this.state = 5058; + localContext._cursor_name = this.uid(); + this.state = 5059; + this.match(MySqlParser.KW_INTO); + this.state = 5060; + localContext._var_names = this.uidList(); + } + break; + case MySqlParser.KW_OPEN: + localContext = new OpenCursorContext(localContext); + this.enterOuterAlt(localContext, 3); + { + this.state = 5062; + this.match(MySqlParser.KW_OPEN); + this.state = 5063; + localContext._cursor_name = this.uid(); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + declareVariable() { + let localContext = new DeclareVariableContext(this.context, this.state); + this.enterRule(localContext, 438, MySqlParser.RULE_declareVariable); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 5066; + this.match(MySqlParser.KW_DECLARE); + this.state = 5067; + localContext._var_names = this.uidList(); + this.state = 5068; + this.dataType(); + this.state = 5071; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 42) { + { + this.state = 5069; + this.match(MySqlParser.KW_DEFAULT); + this.state = 5070; + this.expression(0); + } + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + declareCondition() { + let localContext = new DeclareConditionContext(this.context, this.state); + this.enterRule(localContext, 440, MySqlParser.RULE_declareCondition); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 5073; + this.match(MySqlParser.KW_DECLARE); + this.state = 5074; + localContext._condition_name = this.uid(); + this.state = 5075; + this.match(MySqlParser.KW_CONDITION); + this.state = 5076; + this.match(MySqlParser.KW_FOR); + this.state = 5083; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.ZERO_DECIMAL: + case MySqlParser.ONE_DECIMAL: + case MySqlParser.TWO_DECIMAL: + case MySqlParser.THREE_DECIMAL: + case MySqlParser.DECIMAL_LITERAL: + case MySqlParser.REAL_LITERAL: + { + this.state = 5077; + this.decimalLiteral(); + } + break; + case MySqlParser.KW_SQLSTATE: + { + this.state = 5078; + this.match(MySqlParser.KW_SQLSTATE); + this.state = 5080; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 682) { + { + this.state = 5079; + this.match(MySqlParser.KW_VALUE); + } + } + this.state = 5082; + this.match(MySqlParser.STRING_LITERAL); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + declareCursor() { + let localContext = new DeclareCursorContext(this.context, this.state); + this.enterRule(localContext, 442, MySqlParser.RULE_declareCursor); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 5085; + this.match(MySqlParser.KW_DECLARE); + this.state = 5086; + localContext._condition_name = this.uid(); + this.state = 5087; + this.match(MySqlParser.KW_CURSOR); + this.state = 5088; + this.match(MySqlParser.KW_FOR); + this.state = 5089; + this.selectStatement(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + declareHandler() { + let localContext = new DeclareHandlerContext(this.context, this.state); + this.enterRule(localContext, 444, MySqlParser.RULE_declareHandler); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 5091; + this.match(MySqlParser.KW_DECLARE); + this.state = 5092; + localContext._handlerAction = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 32 || _la === 61 || _la === 180)) { + localContext._handlerAction = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 5093; + this.match(MySqlParser.KW_HANDLER); + this.state = 5094; + this.match(MySqlParser.KW_FOR); + this.state = 5095; + this.handlerConditionValue(); + this.state = 5100; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 5096; + this.match(MySqlParser.COMMA); + this.state = 5097; + this.handlerConditionValue(); + } + } + this.state = 5102; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 5103; + this.routineBody(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + handlerConditionValue() { + let localContext = new HandlerConditionValueContext(this.context, this.state); + this.enterRule(localContext, 446, MySqlParser.RULE_handlerConditionValue); + let _la; + try { + this.state = 5116; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.ZERO_DECIMAL: + case MySqlParser.ONE_DECIMAL: + case MySqlParser.TWO_DECIMAL: + case MySqlParser.THREE_DECIMAL: + case MySqlParser.DECIMAL_LITERAL: + case MySqlParser.REAL_LITERAL: + localContext = new HandlerConditionCodeContext(localContext); + this.enterOuterAlt(localContext, 1); + { + this.state = 5105; + this.decimalLiteral(); + } + break; + case MySqlParser.KW_SQLSTATE: + localContext = new HandlerConditionStateContext(localContext); + this.enterOuterAlt(localContext, 2); + { + this.state = 5106; + this.match(MySqlParser.KW_SQLSTATE); + this.state = 5108; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 682) { + { + this.state = 5107; + this.match(MySqlParser.KW_VALUE); + } + } + this.state = 5110; + this.match(MySqlParser.STRING_LITERAL); + } + break; + case MySqlParser.KW_ARRAY: + case MySqlParser.KW_ATTRIBUTE: + case MySqlParser.KW_BUCKETS: + case MySqlParser.KW_CONDITION: + case MySqlParser.KW_CURRENT: + case MySqlParser.KW_CURRENT_USER: + case MySqlParser.KW_DATABASE: + case MySqlParser.KW_DEFAULT: + case MySqlParser.KW_DIAGNOSTICS: + case MySqlParser.KW_EMPTY: + case MySqlParser.KW_ENFORCED: + case MySqlParser.KW_EXCEPT: + case MySqlParser.KW_GROUP: + case MySqlParser.KW_IF: + case MySqlParser.KW_INSERT: + case MySqlParser.KW_LATERAL: + case MySqlParser.KW_LEFT: + case MySqlParser.KW_NUMBER: + case MySqlParser.KW_OPTIONAL: + case MySqlParser.KW_ORDER: + case MySqlParser.KW_PRIMARY: + case MySqlParser.KW_REPEAT: + case MySqlParser.KW_REPLACE: + case MySqlParser.KW_RIGHT: + case MySqlParser.KW_SCHEMA: + case MySqlParser.KW_SKIP_QUERY_REWRITE: + case MySqlParser.KW_STACKED: + case MySqlParser.KW_DATE: + case MySqlParser.KW_TIME: + case MySqlParser.KW_TIMESTAMP: + case MySqlParser.KW_DATETIME: + case MySqlParser.KW_YEAR: + case MySqlParser.KW_BINARY: + case MySqlParser.KW_TEXT: + case MySqlParser.KW_ENUM: + case MySqlParser.KW_SERIAL: + case MySqlParser.KW_JSON_TABLE: + case MySqlParser.KW_JSON_VALUE: + case MySqlParser.KW_NESTED: + case MySqlParser.KW_ORDINALITY: + case MySqlParser.KW_PATH: + case MySqlParser.KW_AVG: + case MySqlParser.KW_BIT_AND: + case MySqlParser.KW_BIT_OR: + case MySqlParser.KW_BIT_XOR: + case MySqlParser.KW_COUNT: + case MySqlParser.KW_CUME_DIST: + case MySqlParser.KW_DENSE_RANK: + case MySqlParser.KW_FIRST_VALUE: + case MySqlParser.KW_GROUP_CONCAT: + case MySqlParser.KW_LAG: + case MySqlParser.KW_LAST_VALUE: + case MySqlParser.KW_LEAD: + case MySqlParser.KW_MAX: + case MySqlParser.KW_MIN: + case MySqlParser.KW_NTILE: + case MySqlParser.KW_NTH_VALUE: + case MySqlParser.KW_PERCENT_RANK: + case MySqlParser.KW_RANK: + case MySqlParser.KW_ROW_NUMBER: + case MySqlParser.KW_STD: + case MySqlParser.KW_STDDEV: + case MySqlParser.KW_STDDEV_POP: + case MySqlParser.KW_STDDEV_SAMP: + case MySqlParser.KW_SUM: + case MySqlParser.KW_VAR_POP: + case MySqlParser.KW_VAR_SAMP: + case MySqlParser.KW_VARIANCE: + case MySqlParser.KW_CURRENT_DATE: + case MySqlParser.KW_CURRENT_TIME: + case MySqlParser.KW_CURRENT_TIMESTAMP: + case MySqlParser.KW_LOCALTIME: + case MySqlParser.KW_CURDATE: + case MySqlParser.KW_CURTIME: + case MySqlParser.KW_DATE_ADD: + case MySqlParser.KW_DATE_SUB: + case MySqlParser.KW_LOCALTIMESTAMP: + case MySqlParser.KW_NOW: + case MySqlParser.KW_POSITION: + case MySqlParser.KW_SUBSTR: + case MySqlParser.KW_SUBSTRING: + case MySqlParser.KW_SYSDATE: + case MySqlParser.KW_TRIM: + case MySqlParser.KW_UTC_DATE: + case MySqlParser.KW_UTC_TIME: + case MySqlParser.KW_UTC_TIMESTAMP: + case MySqlParser.KW_ACCOUNT: + case MySqlParser.KW_ACTION: + case MySqlParser.KW_AFTER: + case MySqlParser.KW_AGGREGATE: + case MySqlParser.KW_ALGORITHM: + case MySqlParser.KW_ANY: + case MySqlParser.KW_AT: + case MySqlParser.KW_AUTHORS: + case MySqlParser.KW_AUTOCOMMIT: + case MySqlParser.KW_AUTOEXTEND_SIZE: + case MySqlParser.KW_AUTO_INCREMENT: + case MySqlParser.KW_AVG_ROW_LENGTH: + case MySqlParser.KW_BEGIN: + case MySqlParser.KW_BINLOG: + case MySqlParser.KW_BIT: + case MySqlParser.KW_BLOCK: + case MySqlParser.KW_BOOL: + case MySqlParser.KW_BOOLEAN: + case MySqlParser.KW_BTREE: + case MySqlParser.KW_CACHE: + case MySqlParser.KW_CASCADED: + case MySqlParser.KW_CHAIN: + case MySqlParser.KW_CHANGED: + case MySqlParser.KW_CHANNEL: + case MySqlParser.KW_CHECKSUM: + case MySqlParser.KW_CIPHER: + case MySqlParser.KW_CLASS_ORIGIN: + case MySqlParser.KW_CLIENT: + case MySqlParser.KW_CLOSE: + case MySqlParser.KW_COALESCE: + case MySqlParser.KW_CODE: + case MySqlParser.KW_COLUMNS: + case MySqlParser.KW_COLUMN_FORMAT: + case MySqlParser.KW_COLUMN_NAME: + case MySqlParser.KW_COMMENT: + case MySqlParser.KW_COMMIT: + case MySqlParser.KW_COMPACT: + case MySqlParser.KW_COMPLETION: + case MySqlParser.KW_COMPRESSED: + case MySqlParser.KW_COMPRESSION: + case MySqlParser.KW_CONCURRENT: + case MySqlParser.KW_CONNECT: + case MySqlParser.KW_CONNECTION: + case MySqlParser.KW_CONSISTENT: + case MySqlParser.KW_CONSTRAINT_CATALOG: + case MySqlParser.KW_CONSTRAINT_SCHEMA: + case MySqlParser.KW_CONSTRAINT_NAME: + case MySqlParser.KW_CONTAINS: + case MySqlParser.KW_CONTEXT: + case MySqlParser.KW_CONTRIBUTORS: + case MySqlParser.KW_COPY: + case MySqlParser.KW_CPU: + case MySqlParser.KW_CURSOR_NAME: + case MySqlParser.KW_DATA: + case MySqlParser.KW_DATAFILE: + case MySqlParser.KW_DEALLOCATE: + case MySqlParser.KW_DEFAULT_AUTH: + case MySqlParser.KW_DEFINER: + case MySqlParser.KW_DELAY_KEY_WRITE: + case MySqlParser.KW_DES_KEY_FILE: + case MySqlParser.KW_DIRECTORY: + case MySqlParser.KW_DISABLE: + case MySqlParser.KW_DISCARD: + case MySqlParser.KW_DISK: + case MySqlParser.KW_DO: + case MySqlParser.KW_DUMPFILE: + case MySqlParser.KW_DUPLICATE: + case MySqlParser.KW_DYNAMIC: + case MySqlParser.KW_ENABLE: + case MySqlParser.KW_ENCRYPTION: + case MySqlParser.KW_END: + case MySqlParser.KW_ENDS: + case MySqlParser.KW_ENGINE: + case MySqlParser.KW_ENGINES: + case MySqlParser.KW_ERROR: + case MySqlParser.KW_ERRORS: + case MySqlParser.KW_ESCAPE: + case MySqlParser.KW_EVENT: + case MySqlParser.KW_EVENTS: + case MySqlParser.KW_EVERY: + case MySqlParser.KW_EXCHANGE: + case MySqlParser.KW_EXCLUSIVE: + case MySqlParser.KW_EXPIRE: + case MySqlParser.KW_EXPORT: + case MySqlParser.KW_EXTENDED: + case MySqlParser.KW_EXTENT_SIZE: + case MySqlParser.KW_FAILED_LOGIN_ATTEMPTS: + case MySqlParser.KW_FAST: + case MySqlParser.KW_FAULTS: + case MySqlParser.KW_FIELDS: + case MySqlParser.KW_FILE_BLOCK_SIZE: + case MySqlParser.KW_FILTER: + case MySqlParser.KW_FIRST: + case MySqlParser.KW_FIXED: + case MySqlParser.KW_FLUSH: + case MySqlParser.KW_FOLLOWS: + case MySqlParser.KW_FOUND: + case MySqlParser.KW_FULL: + case MySqlParser.KW_FUNCTION: + case MySqlParser.KW_GENERAL: + case MySqlParser.KW_GLOBAL: + case MySqlParser.KW_GRANTS: + case MySqlParser.KW_GROUP_REPLICATION: + case MySqlParser.KW_HANDLER: + case MySqlParser.KW_HASH: + case MySqlParser.KW_HELP: + case MySqlParser.KW_HISTORY: + case MySqlParser.KW_HOST: + case MySqlParser.KW_HOSTS: + case MySqlParser.KW_IDENTIFIED: + case MySqlParser.KW_IGNORE_SERVER_IDS: + case MySqlParser.KW_IMPORT: + case MySqlParser.KW_INDEXES: + case MySqlParser.KW_INITIAL_SIZE: + case MySqlParser.KW_INPLACE: + case MySqlParser.KW_INSERT_METHOD: + case MySqlParser.KW_INSTALL: + case MySqlParser.KW_INSTANCE: + case MySqlParser.KW_INSTANT: + case MySqlParser.KW_INVISIBLE: + case MySqlParser.KW_INVOKER: + case MySqlParser.KW_IO: + case MySqlParser.KW_IO_THREAD: + case MySqlParser.KW_IPC: + case MySqlParser.KW_ISOLATION: + case MySqlParser.KW_ISSUER: + case MySqlParser.KW_JSON: + case MySqlParser.KW_KEY_BLOCK_SIZE: + case MySqlParser.KW_LANGUAGE: + case MySqlParser.KW_LAST: + case MySqlParser.KW_LEAVES: + case MySqlParser.KW_LESS: + case MySqlParser.KW_LEVEL: + case MySqlParser.KW_LIST: + case MySqlParser.KW_LOCAL: + case MySqlParser.KW_LOGFILE: + case MySqlParser.KW_LOGS: + case MySqlParser.KW_MASTER: + case MySqlParser.KW_MASTER_AUTO_POSITION: + case MySqlParser.KW_MASTER_CONNECT_RETRY: + case MySqlParser.KW_MASTER_DELAY: + case MySqlParser.KW_MASTER_HEARTBEAT_PERIOD: + case MySqlParser.KW_MASTER_HOST: + case MySqlParser.KW_MASTER_LOG_FILE: + case MySqlParser.KW_MASTER_LOG_POS: + case MySqlParser.KW_MASTER_PASSWORD: + case MySqlParser.KW_MASTER_PORT: + case MySqlParser.KW_MASTER_RETRY_COUNT: + case MySqlParser.KW_MASTER_SSL: + case MySqlParser.KW_MASTER_SSL_CA: + case MySqlParser.KW_MASTER_SSL_CAPATH: + case MySqlParser.KW_MASTER_SSL_CERT: + case MySqlParser.KW_MASTER_SSL_CIPHER: + case MySqlParser.KW_MASTER_SSL_CRL: + case MySqlParser.KW_MASTER_SSL_CRLPATH: + case MySqlParser.KW_MASTER_SSL_KEY: + case MySqlParser.KW_MASTER_TLS_VERSION: + case MySqlParser.KW_MASTER_USER: + case MySqlParser.KW_MAX_CONNECTIONS_PER_HOUR: + case MySqlParser.KW_MAX_QUERIES_PER_HOUR: + case MySqlParser.KW_MAX_ROWS: + case MySqlParser.KW_MAX_SIZE: + case MySqlParser.KW_MAX_UPDATES_PER_HOUR: + case MySqlParser.KW_MAX_USER_CONNECTIONS: + case MySqlParser.KW_MEDIUM: + case MySqlParser.KW_MEMBER: + case MySqlParser.KW_MERGE: + case MySqlParser.KW_MESSAGE_TEXT: + case MySqlParser.KW_MID: + case MySqlParser.KW_MIGRATE: + case MySqlParser.KW_MIN_ROWS: + case MySqlParser.KW_MODE: + case MySqlParser.KW_MODIFY: + case MySqlParser.KW_MUTEX: + case MySqlParser.KW_MYSQL: + case MySqlParser.KW_MYSQL_ERRNO: + case MySqlParser.KW_NAME: + case MySqlParser.KW_NAMES: + case MySqlParser.KW_NCHAR: + case MySqlParser.KW_NEVER: + case MySqlParser.KW_NEXT: + case MySqlParser.KW_NO: + case MySqlParser.KW_NOWAIT: + case MySqlParser.KW_NODEGROUP: + case MySqlParser.KW_NONE: + case MySqlParser.KW_ODBC: + case MySqlParser.KW_OFFLINE: + case MySqlParser.KW_OFFSET: + case MySqlParser.KW_OF: + case MySqlParser.KW_OLD_PASSWORD: + case MySqlParser.KW_ONE: + case MySqlParser.KW_ONLINE: + case MySqlParser.KW_ONLY: + case MySqlParser.KW_OPEN: + case MySqlParser.KW_OPTIMIZER_COSTS: + case MySqlParser.KW_OPTIONS: + case MySqlParser.KW_OWNER: + case MySqlParser.KW_PACK_KEYS: + case MySqlParser.KW_PAGE: + case MySqlParser.KW_PAGE_CHECKSUM: + case MySqlParser.KW_PARSER: + case MySqlParser.KW_PARTIAL: + case MySqlParser.KW_PARTITIONING: + case MySqlParser.KW_PARTITIONS: + case MySqlParser.KW_PASSWORD: + case MySqlParser.KW_PASSWORD_LOCK_TIME: + case MySqlParser.KW_PHASE: + case MySqlParser.KW_PLUGIN: + case MySqlParser.KW_PLUGIN_DIR: + case MySqlParser.KW_PLUGINS: + case MySqlParser.KW_PORT: + case MySqlParser.KW_PRECEDES: + case MySqlParser.KW_PREPARE: + case MySqlParser.KW_PRESERVE: + case MySqlParser.KW_PREV: + case MySqlParser.KW_PROCESSLIST: + case MySqlParser.KW_PROFILE: + case MySqlParser.KW_PROFILES: + case MySqlParser.KW_PROXY: + case MySqlParser.KW_QUERY: + case MySqlParser.KW_QUICK: + case MySqlParser.KW_REBUILD: + case MySqlParser.KW_RECOVER: + case MySqlParser.KW_RECURSIVE: + case MySqlParser.KW_REDO_BUFFER_SIZE: + case MySqlParser.KW_REDUNDANT: + case MySqlParser.KW_RELAY: + case MySqlParser.KW_RELAY_LOG_FILE: + case MySqlParser.KW_RELAY_LOG_POS: + case MySqlParser.KW_RELAYLOG: + case MySqlParser.KW_REMOVE: + case MySqlParser.KW_REORGANIZE: + case MySqlParser.KW_REPAIR: + case MySqlParser.KW_REPLICATE_DO_DB: + case MySqlParser.KW_REPLICATE_DO_TABLE: + case MySqlParser.KW_REPLICATE_IGNORE_DB: + case MySqlParser.KW_REPLICATE_IGNORE_TABLE: + case MySqlParser.KW_REPLICATE_REWRITE_DB: + case MySqlParser.KW_REPLICATE_WILD_DO_TABLE: + case MySqlParser.KW_REPLICATE_WILD_IGNORE_TABLE: + case MySqlParser.KW_REPLICATION: + case MySqlParser.KW_RESET: + case MySqlParser.KW_RESUME: + case MySqlParser.KW_RETURNED_SQLSTATE: + case MySqlParser.KW_RETURNS: + case MySqlParser.KW_REUSE: + case MySqlParser.KW_ROLE: + case MySqlParser.KW_ROLLBACK: + case MySqlParser.KW_ROLLUP: + case MySqlParser.KW_ROTATE: + case MySqlParser.KW_ROW: + case MySqlParser.KW_ROWS: + case MySqlParser.KW_ROW_FORMAT: + case MySqlParser.KW_SAVEPOINT: + case MySqlParser.KW_SCHEDULE: + case MySqlParser.KW_SECURITY: + case MySqlParser.KW_SERVER: + case MySqlParser.KW_SESSION: + case MySqlParser.KW_SHARE: + case MySqlParser.KW_SHARED: + case MySqlParser.KW_SIGNED: + case MySqlParser.KW_SIMPLE: + case MySqlParser.KW_SLAVE: + case MySqlParser.KW_SLOW: + case MySqlParser.KW_SNAPSHOT: + case MySqlParser.KW_SOCKET: + case MySqlParser.KW_SOME: + case MySqlParser.KW_SONAME: + case MySqlParser.KW_SOUNDS: + case MySqlParser.KW_SOURCE: + case MySqlParser.KW_SQL_AFTER_GTIDS: + case MySqlParser.KW_SQL_AFTER_MTS_GAPS: + case MySqlParser.KW_SQL_BEFORE_GTIDS: + case MySqlParser.KW_SQL_BUFFER_RESULT: + case MySqlParser.KW_SQL_CACHE: + case MySqlParser.KW_SQL_NO_CACHE: + case MySqlParser.KW_SQL_THREAD: + case MySqlParser.KW_START: + case MySqlParser.KW_STARTS: + case MySqlParser.KW_STATS_AUTO_RECALC: + case MySqlParser.KW_STATS_PERSISTENT: + case MySqlParser.KW_STATS_SAMPLE_PAGES: + case MySqlParser.KW_STATUS: + case MySqlParser.KW_STOP: + case MySqlParser.KW_STORAGE: + case MySqlParser.KW_STRING: + case MySqlParser.KW_SUBCLASS_ORIGIN: + case MySqlParser.KW_SUBJECT: + case MySqlParser.KW_SUBPARTITION: + case MySqlParser.KW_SUBPARTITIONS: + case MySqlParser.KW_SUSPEND: + case MySqlParser.KW_SWAPS: + case MySqlParser.KW_SWITCHES: + case MySqlParser.KW_TABLE_NAME: + case MySqlParser.KW_TABLESPACE: + case MySqlParser.KW_TABLE_TYPE: + case MySqlParser.KW_TEMPORARY: + case MySqlParser.KW_TEMPTABLE: + case MySqlParser.KW_THAN: + case MySqlParser.KW_TRADITIONAL: + case MySqlParser.KW_TRANSACTION: + case MySqlParser.KW_TRANSACTIONAL: + case MySqlParser.KW_TRIGGERS: + case MySqlParser.KW_TRUNCATE: + case MySqlParser.KW_UNBOUNDED: + case MySqlParser.KW_UNDEFINED: + case MySqlParser.KW_UNDOFILE: + case MySqlParser.KW_UNDO_BUFFER_SIZE: + case MySqlParser.KW_UNINSTALL: + case MySqlParser.KW_UNKNOWN: + case MySqlParser.KW_UNTIL: + case MySqlParser.KW_UPGRADE: + case MySqlParser.KW_USER: + case MySqlParser.KW_USE_FRM: + case MySqlParser.KW_USER_RESOURCES: + case MySqlParser.KW_VALIDATION: + case MySqlParser.KW_VALUE: + case MySqlParser.KW_VARIABLES: + case MySqlParser.KW_VIEW: + case MySqlParser.KW_VIRTUAL: + case MySqlParser.KW_VISIBLE: + case MySqlParser.KW_WAIT: + case MySqlParser.KW_WARNINGS: + case MySqlParser.KW_WITHOUT: + case MySqlParser.KW_WORK: + case MySqlParser.KW_WRAPPER: + case MySqlParser.KW_X509: + case MySqlParser.KW_XA: + case MySqlParser.KW_XML: + case MySqlParser.KW_QUARTER: + case MySqlParser.KW_MONTH: + case MySqlParser.KW_DAY: + case MySqlParser.KW_HOUR: + case MySqlParser.KW_MINUTE: + case MySqlParser.KW_WEEK: + case MySqlParser.KW_SECOND: + case MySqlParser.KW_MICROSECOND: + case MySqlParser.KW_ADMIN: + case MySqlParser.KW_AUDIT_ABORT_EXEMPT: + case MySqlParser.KW_AUDIT_ADMIN: + case MySqlParser.KW_AUTHENTICATION_POLICY_ADMIN: + case MySqlParser.KW_BACKUP_ADMIN: + case MySqlParser.KW_BINLOG_ADMIN: + case MySqlParser.KW_BINLOG_ENCRYPTION_ADMIN: + case MySqlParser.KW_CLONE_ADMIN: + case MySqlParser.KW_CONNECTION_ADMIN: + case MySqlParser.KW_ENCRYPTION_KEY_ADMIN: + case MySqlParser.KW_EXECUTE: + case MySqlParser.KW_FILE: + case MySqlParser.KW_FIREWALL_ADMIN: + case MySqlParser.KW_FIREWALL_EXEMPT: + case MySqlParser.KW_FIREWALL_USER: + case MySqlParser.KW_GROUP_REPLICATION_ADMIN: + case MySqlParser.KW_INNODB_REDO_LOG_ARCHIVE: + case MySqlParser.KW_INVOKE: + case MySqlParser.KW_LAMBDA: + case MySqlParser.KW_NDB_STORED_USER: + case MySqlParser.KW_PASSWORDLESS_USER_ADMIN: + case MySqlParser.KW_PERSIST_RO_VARIABLES_ADMIN: + case MySqlParser.KW_PRIVILEGES: + case MySqlParser.KW_PROCESS: + case MySqlParser.KW_RELOAD: + case MySqlParser.KW_REPLICATION_APPLIER: + case MySqlParser.KW_REPLICATION_SLAVE_ADMIN: + case MySqlParser.KW_RESOURCE_GROUP_ADMIN: + case MySqlParser.KW_RESOURCE_GROUP_USER: + case MySqlParser.KW_ROLE_ADMIN: + case MySqlParser.KW_ROUTINE: + case MySqlParser.KW_S3: + case MySqlParser.KW_SESSION_VARIABLES_ADMIN: + case MySqlParser.KW_SET_USER_ID: + case MySqlParser.KW_SHOW_ROUTINE: + case MySqlParser.KW_SHUTDOWN: + case MySqlParser.KW_SUPER: + case MySqlParser.KW_SYSTEM_VARIABLES_ADMIN: + case MySqlParser.KW_TABLES: + case MySqlParser.KW_TABLE_ENCRYPTION_ADMIN: + case MySqlParser.KW_VERSION_TOKEN_ADMIN: + case MySqlParser.KW_XA_RECOVER_ADMIN: + case MySqlParser.KW_ARMSCII8: + case MySqlParser.KW_ASCII: + case MySqlParser.KW_BIG5: + case MySqlParser.KW_CP1250: + case MySqlParser.KW_CP1251: + case MySqlParser.KW_CP1256: + case MySqlParser.KW_CP1257: + case MySqlParser.KW_CP850: + case MySqlParser.KW_CP852: + case MySqlParser.KW_CP866: + case MySqlParser.KW_CP932: + case MySqlParser.KW_DEC8: + case MySqlParser.KW_EUCJPMS: + case MySqlParser.KW_EUCKR: + case MySqlParser.KW_GB18030: + case MySqlParser.KW_GB2312: + case MySqlParser.KW_GBK: + case MySqlParser.KW_GEOSTD8: + case MySqlParser.KW_GREEK: + case MySqlParser.KW_HEBREW: + case MySqlParser.KW_HP8: + case MySqlParser.KW_KEYBCS2: + case MySqlParser.KW_KOI8R: + case MySqlParser.KW_KOI8U: + case MySqlParser.KW_LATIN1: + case MySqlParser.KW_LATIN2: + case MySqlParser.KW_LATIN5: + case MySqlParser.KW_LATIN7: + case MySqlParser.KW_MACCE: + case MySqlParser.KW_MACROMAN: + case MySqlParser.KW_SJIS: + case MySqlParser.KW_SWE7: + case MySqlParser.KW_TIS620: + case MySqlParser.KW_UCS2: + case MySqlParser.KW_UJIS: + case MySqlParser.KW_UTF16: + case MySqlParser.KW_UTF16LE: + case MySqlParser.KW_UTF32: + case MySqlParser.KW_UTF8: + case MySqlParser.KW_UTF8MB3: + case MySqlParser.KW_UTF8MB4: + case MySqlParser.KW_ARCHIVE: + case MySqlParser.KW_BLACKHOLE: + case MySqlParser.KW_CSV: + case MySqlParser.KW_FEDERATED: + case MySqlParser.KW_INNODB: + case MySqlParser.KW_MEMORY: + case MySqlParser.KW_MRG_MYISAM: + case MySqlParser.KW_MYISAM: + case MySqlParser.KW_NDB: + case MySqlParser.KW_NDBCLUSTER: + case MySqlParser.KW_PERFORMANCE_SCHEMA: + case MySqlParser.KW_TOKUDB: + case MySqlParser.KW_REPEATABLE: + case MySqlParser.KW_COMMITTED: + case MySqlParser.KW_UNCOMMITTED: + case MySqlParser.KW_SERIALIZABLE: + case MySqlParser.KW_GEOMETRYCOLLECTION: + case MySqlParser.KW_LINESTRING: + case MySqlParser.KW_MULTILINESTRING: + case MySqlParser.KW_MULTIPOINT: + case MySqlParser.KW_MULTIPOLYGON: + case MySqlParser.KW_POINT: + case MySqlParser.KW_POLYGON: + case MySqlParser.KW_CATALOG_NAME: + case MySqlParser.KW_CHARSET: + case MySqlParser.KW_COLLATION: + case MySqlParser.KW_ENGINE_ATTRIBUTE: + case MySqlParser.KW_FORMAT: + case MySqlParser.KW_GET_FORMAT: + case MySqlParser.KW_RANDOM: + case MySqlParser.KW_REVERSE: + case MySqlParser.KW_ROW_COUNT: + case MySqlParser.KW_SCHEMA_NAME: + case MySqlParser.KW_SECONDARY_ENGINE_ATTRIBUTE: + case MySqlParser.KW_SRID: + case MySqlParser.KW_SYSTEM_USER: + case MySqlParser.KW_TP_CONNECTION_ADMIN: + case MySqlParser.KW_WEIGHT_STRING: + case MySqlParser.MOD: + case MySqlParser.CHARSET_REVERSE_QOUTE_STRING: + case MySqlParser.STRING_LITERAL: + case MySqlParser.ID: + localContext = new HandlerConditionNameContext(localContext); + this.enterOuterAlt(localContext, 3); + { + this.state = 5111; + localContext._condition_name = this.uid(); + } + break; + case MySqlParser.KW_SQLWARNING: + localContext = new HandlerConditionWarningContext(localContext); + this.enterOuterAlt(localContext, 4); + { + this.state = 5112; + this.match(MySqlParser.KW_SQLWARNING); + } + break; + case MySqlParser.KW_NOT: + localContext = new HandlerConditionNotfoundContext(localContext); + this.enterOuterAlt(localContext, 5); + { + this.state = 5113; + this.match(MySqlParser.KW_NOT); + this.state = 5114; + this.match(MySqlParser.KW_FOUND); + } + break; + case MySqlParser.KW_SQLEXCEPTION: + localContext = new HandlerConditionExceptionContext(localContext); + this.enterOuterAlt(localContext, 6); + { + this.state = 5115; + this.match(MySqlParser.KW_SQLEXCEPTION); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + procedureSqlStatement() { + let localContext = new ProcedureSqlStatementContext(this.context, this.state); + this.enterRule(localContext, 448, MySqlParser.RULE_procedureSqlStatement); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 5120; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 723, this.context)) { + case 1: + { + this.state = 5118; + this.compoundStatement(); + } + break; + case 2: + { + this.state = 5119; + this.sqlStatement(); + } + break; + } + this.state = 5122; + this.match(MySqlParser.SEMI); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + caseAlternative() { + let localContext = new CaseAlternativeContext(this.context, this.state); + this.enterRule(localContext, 450, MySqlParser.RULE_caseAlternative); + try { + let alternative; + this.enterOuterAlt(localContext, 1); + { + this.state = 5124; + this.match(MySqlParser.KW_WHEN); + this.state = 5127; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 724, this.context)) { + case 1: + { + this.state = 5125; + this.constant(); + } + break; + case 2: + { + this.state = 5126; + this.expression(0); + } + break; + } + this.state = 5129; + this.match(MySqlParser.KW_THEN); + this.state = 5131; + this.errorHandler.sync(this); + alternative = 1; + do { + switch (alternative) { + case 1: + { + { + this.state = 5130; + this.procedureSqlStatement(); + } + } + break; + default: + throw new antlr.NoViableAltException(this); + } + this.state = 5133; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 725, this.context); + } while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + elifAlternative() { + let localContext = new ElifAlternativeContext(this.context, this.state); + this.enterRule(localContext, 452, MySqlParser.RULE_elifAlternative); + try { + let alternative; + this.enterOuterAlt(localContext, 1); + { + this.state = 5135; + this.match(MySqlParser.KW_ELSEIF); + this.state = 5136; + this.expression(0); + this.state = 5137; + this.match(MySqlParser.KW_THEN); + this.state = 5139; + this.errorHandler.sync(this); + alternative = 1; + do { + switch (alternative) { + case 1: + { + { + this.state = 5138; + this.procedureSqlStatement(); + } + } + break; + default: + throw new antlr.NoViableAltException(this); + } + this.state = 5141; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 726, this.context); + } while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + alterUser() { + let localContext = new AlterUserContext(this.context, this.state); + this.enterRule(localContext, 454, MySqlParser.RULE_alterUser); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 5143; + this.match(MySqlParser.KW_ALTER); + this.state = 5144; + this.match(MySqlParser.KW_USER); + this.state = 5146; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 727, this.context)) { + case 1: + { + this.state = 5145; + this.ifExists(); + } + break; + } + this.state = 5204; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 739, this.context)) { + case 1: + { + { + this.state = 5148; + this.userSpecification(); + this.state = 5153; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 5149; + this.match(MySqlParser.COMMA); + this.state = 5150; + this.userSpecification(); + } + } + this.state = 5155; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + } + break; + case 2: + { + { + this.state = 5156; + this.alterUserAuthOption(); + this.state = 5161; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 5157; + this.match(MySqlParser.COMMA); + this.state = 5158; + this.alterUserAuthOption(); + } + } + this.state = 5163; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 5178; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 144) { + { + this.state = 5164; + this.match(MySqlParser.KW_REQUIRE); + this.state = 5176; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_NONE: + { + this.state = 5165; + this.match(MySqlParser.KW_NONE); + } + break; + case MySqlParser.KW_SSL: + case MySqlParser.KW_CIPHER: + case MySqlParser.KW_ISSUER: + case MySqlParser.KW_SUBJECT: + case MySqlParser.KW_X509: + { + this.state = 5166; + this.tlsOption(); + this.state = 5173; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 11 || _la === 169 || _la === 331 || _la === 441 || _la === 651 || _la === 693) { + { + { + this.state = 5168; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 11) { + { + this.state = 5167; + this.match(MySqlParser.KW_AND); + } + } + this.state = 5170; + this.tlsOption(); + } + } + this.state = 5175; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + } + this.state = 5186; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 735, this.context)) { + case 1: + { + this.state = 5180; + this.match(MySqlParser.KW_WITH); + this.state = 5182; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + do { + { + { + this.state = 5181; + this.userResourceOption(); + } + } + this.state = 5184; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } while (((((_la - 478)) & ~0x1F) === 0 && ((1 << (_la - 478)) & 51) !== 0)); + } + break; + } + this.state = 5192; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 304 || _la === 395 || _la === 529 || _la === 530) { + { + this.state = 5190; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_FAILED_LOGIN_ATTEMPTS: + case MySqlParser.KW_PASSWORD: + case MySqlParser.KW_PASSWORD_LOCK_TIME: + { + this.state = 5188; + this.userPasswordOption(); + } + break; + case MySqlParser.KW_ACCOUNT: + { + this.state = 5189; + this.userLockOption(); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + this.state = 5194; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 5197; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 15 || _la === 340) { + { + this.state = 5195; + _la = this.tokenStream.LA(1); + if (!(_la === 15 || _la === 340)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 5196; + this.match(MySqlParser.STRING_LITERAL); + } + } + } + } + break; + case 3: + { + { + { + this.state = 5199; + this.userOrRoleName(); + } + this.state = 5200; + this.match(MySqlParser.KW_DEFAULT); + this.state = 5201; + this.match(MySqlParser.KW_ROLE); + this.state = 5202; + this.roleOption(); + } + } + break; + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + createUser() { + let localContext = new CreateUserContext(this.context, this.state); + this.enterRule(localContext, 456, MySqlParser.RULE_createUser); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 5206; + this.match(MySqlParser.KW_CREATE); + this.state = 5207; + this.match(MySqlParser.KW_USER); + this.state = 5209; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 78) { + { + this.state = 5208; + this.ifNotExists(); + } + } + this.state = 5211; + this.userName(); + this.state = 5213; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 423) { + { + this.state = 5212; + this.createUserAuthOption(); + } + } + this.state = 5222; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 5215; + this.match(MySqlParser.COMMA); + this.state = 5216; + this.userName(); + this.state = 5218; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 423) { + { + this.state = 5217; + this.createUserAuthOption(); + } + } + } + } + this.state = 5224; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 5228; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 42) { + { + this.state = 5225; + this.match(MySqlParser.KW_DEFAULT); + this.state = 5226; + this.match(MySqlParser.KW_ROLE); + this.state = 5227; + this.roleOption(); + } + } + this.state = 5244; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 144) { + { + this.state = 5230; + this.match(MySqlParser.KW_REQUIRE); + this.state = 5242; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_NONE: + { + this.state = 5231; + this.match(MySqlParser.KW_NONE); + } + break; + case MySqlParser.KW_SSL: + case MySqlParser.KW_CIPHER: + case MySqlParser.KW_ISSUER: + case MySqlParser.KW_SUBJECT: + case MySqlParser.KW_X509: + { + this.state = 5232; + this.tlsOption(); + this.state = 5239; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 11 || _la === 169 || _la === 331 || _la === 441 || _la === 651 || _la === 693) { + { + { + this.state = 5234; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 11) { + { + this.state = 5233; + this.match(MySqlParser.KW_AND); + } + } + this.state = 5236; + this.tlsOption(); + } + } + this.state = 5241; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + } + this.state = 5252; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 750, this.context)) { + case 1: + { + this.state = 5246; + this.match(MySqlParser.KW_WITH); + this.state = 5248; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + do { + { + { + this.state = 5247; + this.userResourceOption(); + } + } + this.state = 5250; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } while (((((_la - 478)) & ~0x1F) === 0 && ((1 << (_la - 478)) & 51) !== 0)); + } + break; + } + this.state = 5258; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 304 || _la === 395 || _la === 529 || _la === 530) { + { + this.state = 5256; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_FAILED_LOGIN_ATTEMPTS: + case MySqlParser.KW_PASSWORD: + case MySqlParser.KW_PASSWORD_LOCK_TIME: + { + this.state = 5254; + this.userPasswordOption(); + } + break; + case MySqlParser.KW_ACCOUNT: + { + this.state = 5255; + this.userLockOption(); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + this.state = 5260; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 5263; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 15 || _la === 340) { + { + this.state = 5261; + _la = this.tokenStream.LA(1); + if (!(_la === 15 || _la === 340)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 5262; + this.match(MySqlParser.STRING_LITERAL); + } + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + dropUser() { + let localContext = new DropUserContext(this.context, this.state); + this.enterRule(localContext, 458, MySqlParser.RULE_dropUser); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 5265; + this.match(MySqlParser.KW_DROP); + this.state = 5266; + this.match(MySqlParser.KW_USER); + this.state = 5268; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 78) { + { + this.state = 5267; + this.ifExists(); + } + } + this.state = 5270; + this.userName(); + this.state = 5275; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 5271; + this.match(MySqlParser.COMMA); + this.state = 5272; + this.userName(); + } + } + this.state = 5277; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + grantStatement() { + let localContext = new GrantStatementContext(this.context, this.state); + this.enterRule(localContext, 460, MySqlParser.RULE_grantStatement); + let _la; + try { + let alternative; + this.state = 5367; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 773, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 5278; + this.match(MySqlParser.KW_GRANT); + this.state = 5279; + this.privelegeClause(); + this.state = 5284; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 5280; + this.match(MySqlParser.COMMA); + this.state = 5281; + this.privelegeClause(); + } + } + this.state = 5286; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 5287; + this.match(MySqlParser.KW_ON); + this.state = 5289; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 757, this.context)) { + case 1: + { + this.state = 5288; + this.privilegeObjectType(); + } + break; + } + this.state = 5291; + this.privilegeLevel(); + this.state = 5292; + this.match(MySqlParser.KW_TO); + this.state = 5302; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 759, this.context)) { + case 1: + { + { + this.state = 5293; + this.userAuthOption(); + this.state = 5298; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 5294; + this.match(MySqlParser.COMMA); + this.state = 5295; + this.userAuthOption(); + } + } + this.state = 5300; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + } + break; + case 2: + { + this.state = 5301; + this.userOrRoleNames(); + } + break; + } + this.state = 5318; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 144) { + { + this.state = 5304; + this.match(MySqlParser.KW_REQUIRE); + this.state = 5316; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_NONE: + { + this.state = 5305; + localContext._tlsNone = this.match(MySqlParser.KW_NONE); + } + break; + case MySqlParser.KW_SSL: + case MySqlParser.KW_CIPHER: + case MySqlParser.KW_ISSUER: + case MySqlParser.KW_SUBJECT: + case MySqlParser.KW_X509: + { + this.state = 5306; + this.tlsOption(); + this.state = 5313; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 11 || _la === 169 || _la === 331 || _la === 441 || _la === 651 || _la === 693) { + { + { + this.state = 5308; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 11) { + { + this.state = 5307; + this.match(MySqlParser.KW_AND); + } + } + this.state = 5310; + this.tlsOption(); + } + } + this.state = 5315; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + } + this.state = 5329; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 766, this.context)) { + case 1: + { + this.state = 5320; + this.match(MySqlParser.KW_WITH); + this.state = 5326; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 765, this.context); + while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER) { + if (alternative === 1) { + { + this.state = 5324; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_GRANT: + { + this.state = 5321; + this.match(MySqlParser.KW_GRANT); + this.state = 5322; + this.match(MySqlParser.KW_OPTION); + } + break; + case MySqlParser.KW_MAX_CONNECTIONS_PER_HOUR: + case MySqlParser.KW_MAX_QUERIES_PER_HOUR: + case MySqlParser.KW_MAX_UPDATES_PER_HOUR: + case MySqlParser.KW_MAX_USER_CONNECTIONS: + { + this.state = 5323; + this.userResourceOption(); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + } + this.state = 5328; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 765, this.context); + } + } + break; + } + this.state = 5338; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 13) { + { + this.state = 5331; + this.match(MySqlParser.KW_AS); + this.state = 5332; + this.userName(); + this.state = 5336; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 767, this.context)) { + case 1: + { + this.state = 5333; + this.match(MySqlParser.KW_WITH); + this.state = 5334; + this.match(MySqlParser.KW_ROLE); + this.state = 5335; + this.roleOption(); + } + break; + } + } + } + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 5340; + this.match(MySqlParser.KW_GRANT); + this.state = 5343; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 769, this.context)) { + case 1: + { + this.state = 5341; + this.match(MySqlParser.KW_PROXY); + this.state = 5342; + this.match(MySqlParser.KW_ON); + } + break; + } + { + this.state = 5345; + this.userOrRoleName(); + } + this.state = 5350; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 5346; + this.match(MySqlParser.COMMA); + { + this.state = 5347; + this.userOrRoleName(); + } + } + } + this.state = 5352; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 5353; + this.match(MySqlParser.KW_TO); + { + this.state = 5354; + this.userOrRoleName(); + } + this.state = 5359; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 5355; + this.match(MySqlParser.COMMA); + { + this.state = 5356; + this.userOrRoleName(); + } + } + } + this.state = 5361; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 5365; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 772, this.context)) { + case 1: + { + this.state = 5362; + this.match(MySqlParser.KW_WITH); + this.state = 5363; + this.match(MySqlParser.KW_ADMIN); + this.state = 5364; + this.match(MySqlParser.KW_OPTION); + } + break; + } + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + roleOption() { + let localContext = new RoleOptionContext(this.context, this.state); + this.enterRule(localContext, 462, MySqlParser.RULE_roleOption); + let _la; + try { + this.state = 5377; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 775, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 5369; + this.match(MySqlParser.KW_DEFAULT); + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 5370; + this.match(MySqlParser.KW_NONE); + } + break; + case 3: + this.enterOuterAlt(localContext, 3); + { + this.state = 5371; + this.match(MySqlParser.KW_ALL); + this.state = 5374; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 59) { + { + this.state = 5372; + this.match(MySqlParser.KW_EXCEPT); + this.state = 5373; + this.userOrRoleNames(); + } + } + } + break; + case 4: + this.enterOuterAlt(localContext, 4); + { + this.state = 5376; + this.userOrRoleNames(); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + grantProxy() { + let localContext = new GrantProxyContext(this.context, this.state); + this.enterRule(localContext, 464, MySqlParser.RULE_grantProxy); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 5379; + this.match(MySqlParser.KW_GRANT); + this.state = 5380; + this.match(MySqlParser.KW_PROXY); + this.state = 5381; + this.match(MySqlParser.KW_ON); + this.state = 5382; + localContext._fromFirst = this.userName(); + this.state = 5383; + this.match(MySqlParser.KW_TO); + this.state = 5384; + localContext._toFirst = this.userName(); + this.state = 5389; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 5385; + this.match(MySqlParser.COMMA); + this.state = 5386; + localContext._userName = this.userName(); + localContext._toOther.push(localContext._userName); + } + } + this.state = 5391; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 5395; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 777, this.context)) { + case 1: + { + this.state = 5392; + this.match(MySqlParser.KW_WITH); + this.state = 5393; + this.match(MySqlParser.KW_GRANT); + this.state = 5394; + this.match(MySqlParser.KW_OPTION); + } + break; + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + alterResourceGroup() { + let localContext = new AlterResourceGroupContext(this.context, this.state); + this.enterRule(localContext, 466, MySqlParser.RULE_alterResourceGroup); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 5397; + this.match(MySqlParser.KW_ALTER); + this.state = 5398; + this.match(MySqlParser.KW_RESOURCE); + this.state = 5399; + this.match(MySqlParser.KW_GROUP); + this.state = 5400; + this.groupName(); + this.state = 5406; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 190) { + { + this.state = 5401; + this.match(MySqlParser.KW_VCPU); + this.state = 5403; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 5402; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 5405; + this.resourceGroupVcpuSpec(); + } + } + this.state = 5413; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 837) { + { + this.state = 5408; + this.match(MySqlParser.KW_THREAD_PRIORITY); + this.state = 5410; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 5409; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 5412; + this.decimalLiteral(); + } + } + this.state = 5419; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 368 || _la === 375) { + { + this.state = 5415; + _la = this.tokenStream.LA(1); + if (!(_la === 368 || _la === 375)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 5417; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 66) { + { + this.state = 5416; + this.match(MySqlParser.KW_FORCE); + } + } + } + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + createResourceGroup() { + let localContext = new CreateResourceGroupContext(this.context, this.state); + this.enterRule(localContext, 468, MySqlParser.RULE_createResourceGroup); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 5421; + this.match(MySqlParser.KW_CREATE); + this.state = 5422; + this.match(MySqlParser.KW_RESOURCE); + this.state = 5423; + this.match(MySqlParser.KW_GROUP); + this.state = 5424; + this.groupNameCreate(); + this.state = 5425; + this.match(MySqlParser.KW_TYPE); + this.state = 5426; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 5427; + _la = this.tokenStream.LA(1); + if (!(_la === 678 || _la === 835)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 5433; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 190) { + { + this.state = 5428; + this.match(MySqlParser.KW_VCPU); + this.state = 5430; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 5429; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 5432; + this.resourceGroupVcpuSpec(); + } + } + this.state = 5440; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 837) { + { + this.state = 5435; + this.match(MySqlParser.KW_THREAD_PRIORITY); + this.state = 5437; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 5436; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 5439; + this.decimalLiteral(); + } + } + this.state = 5443; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 368 || _la === 375) { + { + this.state = 5442; + _la = this.tokenStream.LA(1); + if (!(_la === 368 || _la === 375)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + dropResourceGroup() { + let localContext = new DropResourceGroupContext(this.context, this.state); + this.enterRule(localContext, 470, MySqlParser.RULE_dropResourceGroup); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 5445; + this.match(MySqlParser.KW_DROP); + this.state = 5446; + this.match(MySqlParser.KW_RESOURCE); + this.state = 5447; + this.match(MySqlParser.KW_GROUP); + this.state = 5448; + this.groupName(); + this.state = 5450; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 66) { + { + this.state = 5449; + this.match(MySqlParser.KW_FORCE); + } + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + setResourceGroup() { + let localContext = new SetResourceGroupContext(this.context, this.state); + this.enterRule(localContext, 472, MySqlParser.RULE_setResourceGroup); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 5452; + this.match(MySqlParser.KW_SET); + this.state = 5453; + this.match(MySqlParser.KW_RESOURCE); + this.state = 5454; + this.match(MySqlParser.KW_GROUP); + this.state = 5455; + this.groupName(); + this.state = 5465; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 65) { + { + this.state = 5456; + this.match(MySqlParser.KW_FOR); + this.state = 5457; + this.decimalLiteral(); + this.state = 5462; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 5458; + this.match(MySqlParser.COMMA); + this.state = 5459; + this.decimalLiteral(); + } + } + this.state = 5464; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + resourceGroupVcpuSpec() { + let localContext = new ResourceGroupVcpuSpecContext(this.context, this.state); + this.enterRule(localContext, 474, MySqlParser.RULE_resourceGroupVcpuSpec); + try { + let alternative; + this.enterOuterAlt(localContext, 1); + { + this.state = 5472; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 792, this.context)) { + case 1: + { + this.state = 5467; + this.decimalLiteral(); + } + break; + case 2: + { + this.state = 5468; + this.decimalLiteral(); + this.state = 5469; + this.match(MySqlParser.MINUS); + this.state = 5470; + this.decimalLiteral(); + } + break; + } + this.state = 5478; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 793, this.context); + while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER) { + if (alternative === 1) { + { + { + this.state = 5474; + this.match(MySqlParser.COMMA); + this.state = 5475; + this.resourceGroupVcpuSpec(); + } + } + } + this.state = 5480; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 793, this.context); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + renameUser() { + let localContext = new RenameUserContext(this.context, this.state); + this.enterRule(localContext, 476, MySqlParser.RULE_renameUser); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 5481; + this.match(MySqlParser.KW_RENAME); + this.state = 5482; + this.match(MySqlParser.KW_USER); + this.state = 5483; + this.renameUserClause(); + this.state = 5488; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 5484; + this.match(MySqlParser.COMMA); + this.state = 5485; + this.renameUserClause(); + } + } + this.state = 5490; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + revokeStatement() { + let localContext = new RevokeStatementContext(this.context, this.state); + this.enterRule(localContext, 478, MySqlParser.RULE_revokeStatement); + let _la; + try { + this.state = 5543; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 805, this.context)) { + case 1: + localContext = new DetailRevokeContext(localContext); + this.enterOuterAlt(localContext, 1); + { + this.state = 5491; + this.match(MySqlParser.KW_REVOKE); + this.state = 5493; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 78) { + { + this.state = 5492; + this.ifExists(); + } + } + this.state = 5495; + this.privelegeClause(); + this.state = 5500; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 5496; + this.match(MySqlParser.COMMA); + this.state = 5497; + this.privelegeClause(); + } + } + this.state = 5502; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 5503; + this.match(MySqlParser.KW_ON); + this.state = 5505; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 797, this.context)) { + case 1: + { + this.state = 5504; + this.privilegeObjectType(); + } + break; + } + this.state = 5507; + this.privilegeLevel(); + this.state = 5508; + this.match(MySqlParser.KW_FROM); + this.state = 5509; + this.userOrRoleNames(); + this.state = 5511; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 79) { + { + this.state = 5510; + this.ignoreUnknownUser(); + } + } + } + break; + case 2: + localContext = new ShortRevokeContext(localContext); + this.enterOuterAlt(localContext, 2); + { + this.state = 5513; + this.match(MySqlParser.KW_REVOKE); + this.state = 5515; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 78) { + { + this.state = 5514; + this.ifExists(); + } + } + this.state = 5517; + this.match(MySqlParser.KW_ALL); + this.state = 5519; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 734) { + { + this.state = 5518; + this.match(MySqlParser.KW_PRIVILEGES); + } + } + this.state = 5521; + this.match(MySqlParser.COMMA); + this.state = 5522; + this.match(MySqlParser.KW_GRANT); + this.state = 5523; + this.match(MySqlParser.KW_OPTION); + this.state = 5524; + this.match(MySqlParser.KW_FROM); + this.state = 5525; + this.userOrRoleNames(); + this.state = 5527; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 79) { + { + this.state = 5526; + this.ignoreUnknownUser(); + } + } + } + break; + case 3: + localContext = new ProxyAndRoleRevokeContext(localContext); + this.enterOuterAlt(localContext, 3); + { + this.state = 5529; + this.match(MySqlParser.KW_REVOKE); + this.state = 5531; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 802, this.context)) { + case 1: + { + this.state = 5530; + this.ifExists(); + } + break; + } + this.state = 5535; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 803, this.context)) { + case 1: + { + this.state = 5533; + this.match(MySqlParser.KW_PROXY); + this.state = 5534; + this.match(MySqlParser.KW_ON); + } + break; + } + this.state = 5537; + this.userOrRoleNames(); + this.state = 5538; + this.match(MySqlParser.KW_FROM); + this.state = 5539; + this.userOrRoleNames(); + this.state = 5541; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 79) { + { + this.state = 5540; + this.ignoreUnknownUser(); + } + } + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + ignoreUnknownUser() { + let localContext = new IgnoreUnknownUserContext(this.context, this.state); + this.enterRule(localContext, 480, MySqlParser.RULE_ignoreUnknownUser); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 5545; + this.match(MySqlParser.KW_IGNORE); + this.state = 5546; + this.match(MySqlParser.KW_UNKNOWN); + this.state = 5547; + this.match(MySqlParser.KW_USER); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + privilegeObjectType() { + let localContext = new PrivilegeObjectTypeContext(this.context, this.state); + this.enterRule(localContext, 482, MySqlParser.RULE_privilegeObjectType); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 5549; + _la = this.tokenStream.LA(1); + if (!(_la === 132 || _la === 173 || _la === 409)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + setPasswordStatement() { + let localContext = new SetPasswordStatementContext(this.context, this.state); + this.enterRule(localContext, 484, MySqlParser.RULE_setPasswordStatement); + let _la; + try { + this.state = 5583; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 812, this.context)) { + case 1: + localContext = new V57Context(localContext); + this.enterOuterAlt(localContext, 1); + { + this.state = 5551; + this.match(MySqlParser.KW_SET); + this.state = 5552; + this.match(MySqlParser.KW_PASSWORD); + this.state = 5555; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 65) { + { + this.state = 5553; + this.match(MySqlParser.KW_FOR); + this.state = 5554; + this.userName(); + } + } + this.state = 5557; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 5560; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_OLD_PASSWORD: + case MySqlParser.KW_PASSWORD: + { + this.state = 5558; + this.passwordFunctionClause(); + } + break; + case MySqlParser.STRING_LITERAL: + { + this.state = 5559; + this.match(MySqlParser.STRING_LITERAL); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + break; + case 2: + localContext = new V80Context(localContext); + this.enterOuterAlt(localContext, 2); + { + this.state = 5562; + this.match(MySqlParser.KW_SET); + this.state = 5563; + this.match(MySqlParser.KW_PASSWORD); + this.state = 5566; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 65) { + { + this.state = 5564; + this.match(MySqlParser.KW_FOR); + this.state = 5565; + this.userName(); + } + } + this.state = 5572; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_TO: + { + this.state = 5568; + this.match(MySqlParser.KW_TO); + this.state = 5569; + this.match(MySqlParser.KW_RANDOM); + } + break; + case MySqlParser.EQUAL_SYMBOL: + { + this.state = 5570; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 5571; + this.match(MySqlParser.STRING_LITERAL); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + this.state = 5576; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 810, this.context)) { + case 1: + { + this.state = 5574; + this.match(MySqlParser.KW_REPLACE); + this.state = 5575; + this.match(MySqlParser.STRING_LITERAL); + } + break; + } + this.state = 5581; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 147) { + { + this.state = 5578; + this.match(MySqlParser.KW_RETAIN); + this.state = 5579; + this.match(MySqlParser.KW_CURRENT); + this.state = 5580; + this.match(MySqlParser.KW_PASSWORD); + } + } + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + userSpecification() { + let localContext = new UserSpecificationContext(this.context, this.state); + this.enterRule(localContext, 486, MySqlParser.RULE_userSpecification); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 5585; + this.userName(); + this.state = 5586; + this.userPasswordOption(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + alterUserAuthOption() { + let localContext = new AlterUserAuthOptionContext(this.context, this.state); + this.enterRule(localContext, 488, MySqlParser.RULE_alterUserAuthOption); + let _la; + try { + let alternative; + this.enterOuterAlt(localContext, 1); + { + this.state = 5588; + this.userName(); + this.state = 5614; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 815, this.context)) { + case 1: + { + this.state = 5589; + this.match(MySqlParser.KW_IDENTIFIED); + this.state = 5590; + this.match(MySqlParser.KW_BY); + this.state = 5591; + this.match(MySqlParser.STRING_LITERAL); + this.state = 5592; + this.authOptionClause(); + } + break; + case 2: + { + this.state = 5593; + this.match(MySqlParser.KW_IDENTIFIED); + this.state = 5594; + this.match(MySqlParser.KW_BY); + this.state = 5595; + this.match(MySqlParser.KW_RANDOM); + this.state = 5596; + this.match(MySqlParser.KW_PASSWORD); + this.state = 5597; + this.authOptionClause(); + } + break; + case 3: + { + this.state = 5598; + this.match(MySqlParser.KW_IDENTIFIED); + this.state = 5599; + this.match(MySqlParser.KW_WITH); + this.state = 5600; + this.authenticationRule(); + } + break; + case 4: + { + this.state = 5601; + this.match(MySqlParser.KW_DISCARD); + this.state = 5602; + this.match(MySqlParser.KW_OLD); + this.state = 5603; + this.match(MySqlParser.KW_PASSWORD); + } + break; + case 5: + { + this.state = 5609; + this.errorHandler.sync(this); + alternative = 1; + do { + switch (alternative) { + case 1: + { + { + this.state = 5604; + _la = this.tokenStream.LA(1); + if (!(_la === 6 || _la === 51 || _la === 492)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 5605; + this.factor(); + this.state = 5607; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 423) { + { + this.state = 5606; + this.factorAuthOption(); + } + } + } + } + break; + default: + throw new antlr.NoViableAltException(this); + } + this.state = 5611; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 814, this.context); + } while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER); + } + break; + case 6: + { + this.state = 5613; + this.registrationOption(); + } + break; + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + createUserAuthOption() { + let localContext = new CreateUserAuthOptionContext(this.context, this.state); + this.enterRule(localContext, 490, MySqlParser.RULE_createUserAuthOption); + let _la; + try { + this.state = 5652; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 822, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 5616; + this.match(MySqlParser.KW_IDENTIFIED); + this.state = 5617; + this.match(MySqlParser.KW_BY); + this.state = 5623; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.STRING_LITERAL: + { + this.state = 5618; + this.match(MySqlParser.STRING_LITERAL); + } + break; + case MySqlParser.KW_RANDOM: + { + { + this.state = 5619; + this.match(MySqlParser.KW_RANDOM); + this.state = 5620; + this.match(MySqlParser.KW_PASSWORD); + } + } + break; + case MySqlParser.KW_PASSWORD: + { + { + this.state = 5621; + this.match(MySqlParser.KW_PASSWORD); + this.state = 5622; + this.match(MySqlParser.STRING_LITERAL); + } + } + break; + default: + throw new antlr.NoViableAltException(this); + } + this.state = 5627; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 11) { + { + this.state = 5625; + this.match(MySqlParser.KW_AND); + this.state = 5626; + this.createUserAuthOption(); + } + } + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 5629; + this.match(MySqlParser.KW_IDENTIFIED); + this.state = 5630; + this.match(MySqlParser.KW_WITH); + this.state = 5631; + localContext._authPlugin = this.uid(); + this.state = 5640; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_BY: + { + { + this.state = 5632; + this.match(MySqlParser.KW_BY); + this.state = 5636; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.STRING_LITERAL: + { + this.state = 5633; + this.match(MySqlParser.STRING_LITERAL); + } + break; + case MySqlParser.KW_RANDOM: + { + { + this.state = 5634; + this.match(MySqlParser.KW_RANDOM); + this.state = 5635; + this.match(MySqlParser.KW_PASSWORD); + } + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + } + break; + case MySqlParser.KW_AS: + { + this.state = 5638; + this.match(MySqlParser.KW_AS); + this.state = 5639; + this.match(MySqlParser.STRING_LITERAL); + } + break; + case MySqlParser.EOF: + case MySqlParser.KW_ALTER: + case MySqlParser.KW_ANALYZE: + case MySqlParser.KW_AND: + case MySqlParser.KW_ATTRIBUTE: + case MySqlParser.KW_CALL: + case MySqlParser.KW_CHANGE: + case MySqlParser.KW_CHECK: + case MySqlParser.KW_CREATE: + case MySqlParser.KW_DEFAULT: + case MySqlParser.KW_DELETE: + case MySqlParser.KW_DESC: + case MySqlParser.KW_DESCRIBE: + case MySqlParser.KW_DROP: + case MySqlParser.KW_EXPLAIN: + case MySqlParser.KW_GET: + case MySqlParser.KW_GRANT: + case MySqlParser.KW_INSERT: + case MySqlParser.KW_KILL: + case MySqlParser.KW_LOAD: + case MySqlParser.KW_LOCK: + case MySqlParser.KW_OPTIMIZE: + case MySqlParser.KW_PURGE: + case MySqlParser.KW_RELEASE: + case MySqlParser.KW_RENAME: + case MySqlParser.KW_REPLACE: + case MySqlParser.KW_REQUIRE: + case MySqlParser.KW_RESIGNAL: + case MySqlParser.KW_REVOKE: + case MySqlParser.KW_SELECT: + case MySqlParser.KW_SET: + case MySqlParser.KW_SHOW: + case MySqlParser.KW_SIGNAL: + case MySqlParser.KW_TABLE: + case MySqlParser.KW_UNLOCK: + case MySqlParser.KW_UPDATE: + case MySqlParser.KW_USE: + case MySqlParser.KW_VALUES: + case MySqlParser.KW_WITH: + case MySqlParser.KW_ACCOUNT: + case MySqlParser.KW_BEGIN: + case MySqlParser.KW_BINLOG: + case MySqlParser.KW_CACHE: + case MySqlParser.KW_CHECKSUM: + case MySqlParser.KW_COMMENT: + case MySqlParser.KW_COMMIT: + case MySqlParser.KW_DEALLOCATE: + case MySqlParser.KW_DO: + case MySqlParser.KW_FAILED_LOGIN_ATTEMPTS: + case MySqlParser.KW_FLUSH: + case MySqlParser.KW_HANDLER: + case MySqlParser.KW_HELP: + case MySqlParser.KW_IMPORT: + case MySqlParser.KW_INSTALL: + case MySqlParser.KW_PASSWORD: + case MySqlParser.KW_PASSWORD_LOCK_TIME: + case MySqlParser.KW_PREPARE: + case MySqlParser.KW_REPAIR: + case MySqlParser.KW_RESET: + case MySqlParser.KW_RESTART: + case MySqlParser.KW_ROLLBACK: + case MySqlParser.KW_SAVEPOINT: + case MySqlParser.KW_START: + case MySqlParser.KW_STOP: + case MySqlParser.KW_TRUNCATE: + case MySqlParser.KW_UNINSTALL: + case MySqlParser.KW_XA: + case MySqlParser.KW_CLONE: + case MySqlParser.KW_EXECUTE: + case MySqlParser.KW_SHUTDOWN: + case MySqlParser.LR_BRACKET: + case MySqlParser.COMMA: + case MySqlParser.SEMI: + break; + default: + break; + } + this.state = 5644; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 11) { + { + this.state = 5642; + this.match(MySqlParser.KW_AND); + this.state = 5643; + this.createUserAuthOption(); + } + } + } + break; + case 3: + this.enterOuterAlt(localContext, 3); + { + this.state = 5646; + this.match(MySqlParser.KW_IDENTIFIED); + this.state = 5647; + this.match(MySqlParser.KW_WITH); + this.state = 5648; + localContext._authPlugin = this.uid(); + this.state = 5650; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 427) { + { + this.state = 5649; + this.createUserInitialAuthOption(); + } + } + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + createUserInitialAuthOption() { + let localContext = new CreateUserInitialAuthOptionContext(this.context, this.state); + this.enterRule(localContext, 492, MySqlParser.RULE_createUserInitialAuthOption); + try { + this.state = 5671; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 824, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 5654; + this.match(MySqlParser.KW_INITIAL); + this.state = 5655; + this.match(MySqlParser.KW_AUTHENTICATION); + this.state = 5656; + this.match(MySqlParser.KW_IDENTIFIED); + this.state = 5657; + this.match(MySqlParser.KW_BY); + this.state = 5661; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_RANDOM: + { + { + this.state = 5658; + this.match(MySqlParser.KW_RANDOM); + this.state = 5659; + this.match(MySqlParser.KW_PASSWORD); + } + } + break; + case MySqlParser.STRING_LITERAL: + { + this.state = 5660; + this.match(MySqlParser.STRING_LITERAL); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 5663; + this.match(MySqlParser.KW_INITIAL); + this.state = 5664; + this.match(MySqlParser.KW_AUTHENTICATION); + this.state = 5665; + this.match(MySqlParser.KW_IDENTIFIED); + this.state = 5666; + this.match(MySqlParser.KW_WITH); + this.state = 5667; + localContext._authPlugin = this.uid(); + this.state = 5668; + this.match(MySqlParser.KW_AS); + this.state = 5669; + this.match(MySqlParser.STRING_LITERAL); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + userAuthOption() { + let localContext = new UserAuthOptionContext(this.context, this.state); + this.enterRule(localContext, 494, MySqlParser.RULE_userAuthOption); + try { + this.state = 5698; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 825, this.context)) { + case 1: + localContext = new HashAuthOptionContext(localContext); + this.enterOuterAlt(localContext, 1); + { + this.state = 5673; + this.userName(); + this.state = 5674; + this.match(MySqlParser.KW_IDENTIFIED); + this.state = 5675; + this.match(MySqlParser.KW_BY); + this.state = 5676; + this.match(MySqlParser.KW_PASSWORD); + this.state = 5677; + localContext._hashed = this.match(MySqlParser.STRING_LITERAL); + } + break; + case 2: + localContext = new RandomAuthOptionContext(localContext); + this.enterOuterAlt(localContext, 2); + { + this.state = 5679; + this.userName(); + this.state = 5680; + this.match(MySqlParser.KW_IDENTIFIED); + this.state = 5681; + this.match(MySqlParser.KW_BY); + this.state = 5682; + this.match(MySqlParser.KW_RANDOM); + this.state = 5683; + this.match(MySqlParser.KW_PASSWORD); + this.state = 5684; + this.authOptionClause(); + } + break; + case 3: + localContext = new StringAuthOptionContext(localContext); + this.enterOuterAlt(localContext, 3); + { + this.state = 5686; + this.userName(); + this.state = 5687; + this.match(MySqlParser.KW_IDENTIFIED); + this.state = 5688; + this.match(MySqlParser.KW_BY); + this.state = 5689; + this.match(MySqlParser.STRING_LITERAL); + this.state = 5690; + this.authOptionClause(); + } + break; + case 4: + localContext = new ModuleAuthOptionContext(localContext); + this.enterOuterAlt(localContext, 4); + { + this.state = 5692; + this.userName(); + this.state = 5693; + this.match(MySqlParser.KW_IDENTIFIED); + this.state = 5694; + this.match(MySqlParser.KW_WITH); + this.state = 5695; + this.authenticationRule(); + } + break; + case 5: + localContext = new SimpleAuthOptionContext(localContext); + this.enterOuterAlt(localContext, 5); + { + this.state = 5697; + this.userName(); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + authOptionClause() { + let localContext = new AuthOptionClauseContext(this.context, this.state); + this.enterRule(localContext, 496, MySqlParser.RULE_authOptionClause); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 5702; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 826, this.context)) { + case 1: + { + this.state = 5700; + this.match(MySqlParser.KW_REPLACE); + this.state = 5701; + this.match(MySqlParser.STRING_LITERAL); + } + break; + } + this.state = 5707; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 147) { + { + this.state = 5704; + this.match(MySqlParser.KW_RETAIN); + this.state = 5705; + this.match(MySqlParser.KW_CURRENT); + this.state = 5706; + this.match(MySqlParser.KW_PASSWORD); + } + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + authenticationRule() { + let localContext = new AuthenticationRuleContext(this.context, this.state); + this.enterRule(localContext, 498, MySqlParser.RULE_authenticationRule); + let _la; + try { + this.state = 5723; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 830, this.context)) { + case 1: + localContext = new ModuleContext(localContext); + this.enterOuterAlt(localContext, 1); + { + this.state = 5709; + localContext._authPlugin = this.uid(); + this.state = 5717; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 829, this.context)) { + case 1: + { + this.state = 5710; + _la = this.tokenStream.LA(1); + if (!(_la === 13 || _la === 20 || _la === 188)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 5714; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.STRING_LITERAL: + { + this.state = 5711; + this.match(MySqlParser.STRING_LITERAL); + } + break; + case MySqlParser.KW_RANDOM: + { + this.state = 5712; + this.match(MySqlParser.KW_RANDOM); + this.state = 5713; + this.match(MySqlParser.KW_PASSWORD); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + this.state = 5716; + this.authOptionClause(); + } + break; + } + } + break; + case 2: + localContext = new PasswordModuleOptionContext(localContext); + this.enterOuterAlt(localContext, 2); + { + this.state = 5719; + localContext._authPlugin = this.uid(); + this.state = 5720; + this.match(MySqlParser.KW_USING); + this.state = 5721; + this.passwordFunctionClause(); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + tlsOption() { + let localContext = new TlsOptionContext(this.context, this.state); + this.enterRule(localContext, 500, MySqlParser.RULE_tlsOption); + try { + this.state = 5733; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_SSL: + this.enterOuterAlt(localContext, 1); + { + this.state = 5725; + this.match(MySqlParser.KW_SSL); + } + break; + case MySqlParser.KW_X509: + this.enterOuterAlt(localContext, 2); + { + this.state = 5726; + this.match(MySqlParser.KW_X509); + } + break; + case MySqlParser.KW_CIPHER: + this.enterOuterAlt(localContext, 3); + { + this.state = 5727; + this.match(MySqlParser.KW_CIPHER); + this.state = 5728; + this.match(MySqlParser.STRING_LITERAL); + } + break; + case MySqlParser.KW_ISSUER: + this.enterOuterAlt(localContext, 4); + { + this.state = 5729; + this.match(MySqlParser.KW_ISSUER); + this.state = 5730; + this.match(MySqlParser.STRING_LITERAL); + } + break; + case MySqlParser.KW_SUBJECT: + this.enterOuterAlt(localContext, 5); + { + this.state = 5731; + this.match(MySqlParser.KW_SUBJECT); + this.state = 5732; + this.match(MySqlParser.STRING_LITERAL); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + userResourceOption() { + let localContext = new UserResourceOptionContext(this.context, this.state); + this.enterRule(localContext, 502, MySqlParser.RULE_userResourceOption); + try { + this.state = 5743; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_MAX_QUERIES_PER_HOUR: + this.enterOuterAlt(localContext, 1); + { + this.state = 5735; + this.match(MySqlParser.KW_MAX_QUERIES_PER_HOUR); + this.state = 5736; + this.decimalLiteral(); + } + break; + case MySqlParser.KW_MAX_UPDATES_PER_HOUR: + this.enterOuterAlt(localContext, 2); + { + this.state = 5737; + this.match(MySqlParser.KW_MAX_UPDATES_PER_HOUR); + this.state = 5738; + this.decimalLiteral(); + } + break; + case MySqlParser.KW_MAX_CONNECTIONS_PER_HOUR: + this.enterOuterAlt(localContext, 3); + { + this.state = 5739; + this.match(MySqlParser.KW_MAX_CONNECTIONS_PER_HOUR); + this.state = 5740; + this.decimalLiteral(); + } + break; + case MySqlParser.KW_MAX_USER_CONNECTIONS: + this.enterOuterAlt(localContext, 4); + { + this.state = 5741; + this.match(MySqlParser.KW_MAX_USER_CONNECTIONS); + this.state = 5742; + this.decimalLiteral(); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + userPasswordOption() { + let localContext = new UserPasswordOptionContext(this.context, this.state); + this.enterRule(localContext, 504, MySqlParser.RULE_userPasswordOption); + let _la; + try { + this.state = 5783; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 838, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 5745; + this.match(MySqlParser.KW_PASSWORD); + this.state = 5746; + this.match(MySqlParser.KW_EXPIRE); + this.state = 5753; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_DEFAULT: + { + this.state = 5747; + localContext._expireType = this.match(MySqlParser.KW_DEFAULT); + } + break; + case MySqlParser.KW_NEVER: + { + this.state = 5748; + localContext._expireType = this.match(MySqlParser.KW_NEVER); + } + break; + case MySqlParser.KW_INTERVAL: + { + this.state = 5749; + localContext._expireType = this.match(MySqlParser.KW_INTERVAL); + this.state = 5750; + this.decimalLiteral(); + this.state = 5751; + this.match(MySqlParser.KW_DAY); + } + break; + case MySqlParser.EOF: + case MySqlParser.KW_ALTER: + case MySqlParser.KW_ANALYZE: + case MySqlParser.KW_ATTRIBUTE: + case MySqlParser.KW_CALL: + case MySqlParser.KW_CHANGE: + case MySqlParser.KW_CHECK: + case MySqlParser.KW_CREATE: + case MySqlParser.KW_DELETE: + case MySqlParser.KW_DESC: + case MySqlParser.KW_DESCRIBE: + case MySqlParser.KW_DROP: + case MySqlParser.KW_EXPLAIN: + case MySqlParser.KW_GET: + case MySqlParser.KW_GRANT: + case MySqlParser.KW_INSERT: + case MySqlParser.KW_KILL: + case MySqlParser.KW_LOAD: + case MySqlParser.KW_LOCK: + case MySqlParser.KW_OPTIMIZE: + case MySqlParser.KW_PURGE: + case MySqlParser.KW_RELEASE: + case MySqlParser.KW_RENAME: + case MySqlParser.KW_REPLACE: + case MySqlParser.KW_RESIGNAL: + case MySqlParser.KW_REVOKE: + case MySqlParser.KW_SELECT: + case MySqlParser.KW_SET: + case MySqlParser.KW_SHOW: + case MySqlParser.KW_SIGNAL: + case MySqlParser.KW_TABLE: + case MySqlParser.KW_UNLOCK: + case MySqlParser.KW_UPDATE: + case MySqlParser.KW_USE: + case MySqlParser.KW_VALUES: + case MySqlParser.KW_WITH: + case MySqlParser.KW_ACCOUNT: + case MySqlParser.KW_BEGIN: + case MySqlParser.KW_BINLOG: + case MySqlParser.KW_CACHE: + case MySqlParser.KW_CHECKSUM: + case MySqlParser.KW_COMMENT: + case MySqlParser.KW_COMMIT: + case MySqlParser.KW_DEALLOCATE: + case MySqlParser.KW_DO: + case MySqlParser.KW_FAILED_LOGIN_ATTEMPTS: + case MySqlParser.KW_FLUSH: + case MySqlParser.KW_HANDLER: + case MySqlParser.KW_HELP: + case MySqlParser.KW_IMPORT: + case MySqlParser.KW_INSTALL: + case MySqlParser.KW_PASSWORD: + case MySqlParser.KW_PASSWORD_LOCK_TIME: + case MySqlParser.KW_PREPARE: + case MySqlParser.KW_REPAIR: + case MySqlParser.KW_RESET: + case MySqlParser.KW_RESTART: + case MySqlParser.KW_ROLLBACK: + case MySqlParser.KW_SAVEPOINT: + case MySqlParser.KW_START: + case MySqlParser.KW_STOP: + case MySqlParser.KW_TRUNCATE: + case MySqlParser.KW_UNINSTALL: + case MySqlParser.KW_XA: + case MySqlParser.KW_CLONE: + case MySqlParser.KW_EXECUTE: + case MySqlParser.KW_SHUTDOWN: + case MySqlParser.LR_BRACKET: + case MySqlParser.COMMA: + case MySqlParser.SEMI: + break; + default: + break; + } + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 5755; + this.match(MySqlParser.KW_PASSWORD); + this.state = 5756; + this.match(MySqlParser.KW_HISTORY); + this.state = 5759; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_DEFAULT: + { + this.state = 5757; + this.match(MySqlParser.KW_DEFAULT); + } + break; + case MySqlParser.ZERO_DECIMAL: + case MySqlParser.ONE_DECIMAL: + case MySqlParser.TWO_DECIMAL: + case MySqlParser.THREE_DECIMAL: + case MySqlParser.DECIMAL_LITERAL: + case MySqlParser.REAL_LITERAL: + { + this.state = 5758; + this.decimalLiteral(); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + break; + case 3: + this.enterOuterAlt(localContext, 3); + { + this.state = 5761; + this.match(MySqlParser.KW_PASSWORD); + this.state = 5762; + this.match(MySqlParser.KW_REUSE); + this.state = 5763; + this.match(MySqlParser.KW_INTERVAL); + this.state = 5768; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_DEFAULT: + { + this.state = 5764; + this.match(MySqlParser.KW_DEFAULT); + } + break; + case MySqlParser.ZERO_DECIMAL: + case MySqlParser.ONE_DECIMAL: + case MySqlParser.TWO_DECIMAL: + case MySqlParser.THREE_DECIMAL: + case MySqlParser.DECIMAL_LITERAL: + case MySqlParser.REAL_LITERAL: + { + this.state = 5765; + this.decimalLiteral(); + this.state = 5766; + this.match(MySqlParser.KW_DAY); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + break; + case 4: + this.enterOuterAlt(localContext, 4); + { + this.state = 5770; + this.match(MySqlParser.KW_PASSWORD); + this.state = 5771; + this.match(MySqlParser.KW_REQUIRE); + this.state = 5772; + this.match(MySqlParser.KW_CURRENT); + this.state = 5774; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 42 || _la === 122) { + { + this.state = 5773; + _la = this.tokenStream.LA(1); + if (!(_la === 42 || _la === 122)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + } + break; + case 5: + this.enterOuterAlt(localContext, 5); + { + this.state = 5776; + this.match(MySqlParser.KW_FAILED_LOGIN_ATTEMPTS); + this.state = 5777; + this.decimalLiteral(); + } + break; + case 6: + this.enterOuterAlt(localContext, 6); + { + this.state = 5778; + this.match(MySqlParser.KW_PASSWORD_LOCK_TIME); + this.state = 5781; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.ZERO_DECIMAL: + case MySqlParser.ONE_DECIMAL: + case MySqlParser.TWO_DECIMAL: + case MySqlParser.THREE_DECIMAL: + case MySqlParser.DECIMAL_LITERAL: + case MySqlParser.REAL_LITERAL: + { + this.state = 5779; + this.decimalLiteral(); + } + break; + case MySqlParser.KW_UNBOUNDED: + { + this.state = 5780; + this.match(MySqlParser.KW_UNBOUNDED); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + userLockOption() { + let localContext = new UserLockOptionContext(this.context, this.state); + this.enterRule(localContext, 506, MySqlParser.RULE_userLockOption); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 5785; + this.match(MySqlParser.KW_ACCOUNT); + this.state = 5786; + localContext._lockType = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 104 || _la === 183)) { + localContext._lockType = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + factorAuthOption() { + let localContext = new FactorAuthOptionContext(this.context, this.state); + this.enterRule(localContext, 508, MySqlParser.RULE_factorAuthOption); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 5788; + this.match(MySqlParser.KW_IDENTIFIED); + this.state = 5791; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 194) { + { + this.state = 5789; + this.match(MySqlParser.KW_WITH); + this.state = 5790; + localContext._authPlugin = this.uid(); + } + } + this.state = 5801; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_BY: + { + { + this.state = 5793; + this.match(MySqlParser.KW_BY); + this.state = 5797; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.STRING_LITERAL: + { + this.state = 5794; + this.match(MySqlParser.STRING_LITERAL); + } + break; + case MySqlParser.KW_RANDOM: + { + { + this.state = 5795; + this.match(MySqlParser.KW_RANDOM); + this.state = 5796; + this.match(MySqlParser.KW_PASSWORD); + } + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + } + break; + case MySqlParser.KW_AS: + { + this.state = 5799; + this.match(MySqlParser.KW_AS); + this.state = 5800; + this.match(MySqlParser.STRING_LITERAL); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + registrationOption() { + let localContext = new RegistrationOptionContext(this.context, this.state); + this.enterRule(localContext, 510, MySqlParser.RULE_registrationOption); + try { + this.state = 5818; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 842, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 5803; + this.factor(); + this.state = 5804; + this.match(MySqlParser.KW_INITIATE); + this.state = 5805; + this.match(MySqlParser.KW_REGISTRATION); + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 5807; + this.factor(); + this.state = 5808; + this.match(MySqlParser.KW_FINISH); + this.state = 5809; + this.match(MySqlParser.KW_REGISTRATION); + this.state = 5810; + this.match(MySqlParser.KW_SET); + this.state = 5811; + this.match(MySqlParser.KW_CHALLENGE_RESPONSE); + this.state = 5812; + this.match(MySqlParser.KW_AS); + this.state = 5813; + this.match(MySqlParser.STRING_LITERAL); + } + break; + case 3: + this.enterOuterAlt(localContext, 3); + { + this.state = 5815; + this.factor(); + this.state = 5816; + this.match(MySqlParser.KW_UNREGISTER); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + factor() { + let localContext = new FactorContext(this.context, this.state); + this.enterRule(localContext, 512, MySqlParser.RULE_factor); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 5820; + _la = this.tokenStream.LA(1); + if (!(_la === 873 || _la === 874)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 5821; + this.match(MySqlParser.KW_FACTOR); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + privelegeClause() { + let localContext = new PrivelegeClauseContext(this.context, this.state); + this.enterRule(localContext, 514, MySqlParser.RULE_privelegeClause); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 5823; + this.privilege(); + this.state = 5828; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 866) { + { + this.state = 5824; + this.match(MySqlParser.LR_BRACKET); + this.state = 5825; + this.columnNames(); + this.state = 5826; + this.match(MySqlParser.RR_BRACKET); + } + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + privilege() { + let localContext = new PrivilegeContext(this.context, this.state); + this.enterRule(localContext, 516, MySqlParser.RULE_privilege); + let _la; + try { + this.state = 5923; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 848, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 5830; + this.match(MySqlParser.KW_ALL); + this.state = 5832; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 734) { + { + this.state = 5831; + this.match(MySqlParser.KW_PRIVILEGES); + } + } + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 5834; + this.match(MySqlParser.KW_ALTER); + this.state = 5836; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 743) { + { + this.state = 5835; + this.match(MySqlParser.KW_ROUTINE); + } + } + } + break; + case 3: + this.enterOuterAlt(localContext, 3); + { + this.state = 5838; + this.match(MySqlParser.KW_CREATE); + this.state = 5846; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_TEMPORARY: + { + this.state = 5839; + this.match(MySqlParser.KW_TEMPORARY); + this.state = 5840; + this.match(MySqlParser.KW_TABLES); + } + break; + case MySqlParser.KW_ROUTINE: + { + this.state = 5841; + this.match(MySqlParser.KW_ROUTINE); + } + break; + case MySqlParser.KW_VIEW: + { + this.state = 5842; + this.match(MySqlParser.KW_VIEW); + } + break; + case MySqlParser.KW_USER: + { + this.state = 5843; + this.match(MySqlParser.KW_USER); + } + break; + case MySqlParser.KW_TABLESPACE: + { + this.state = 5844; + this.match(MySqlParser.KW_TABLESPACE); + } + break; + case MySqlParser.KW_ROLE: + { + this.state = 5845; + this.match(MySqlParser.KW_ROLE); + } + break; + case MySqlParser.KW_ON: + case MySqlParser.LR_BRACKET: + case MySqlParser.COMMA: + break; + default: + break; + } + } + break; + case 4: + this.enterOuterAlt(localContext, 4); + { + this.state = 5848; + this.match(MySqlParser.KW_DELETE); + } + break; + case 5: + this.enterOuterAlt(localContext, 5); + { + this.state = 5849; + this.match(MySqlParser.KW_DROP); + this.state = 5851; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 582) { + { + this.state = 5850; + this.match(MySqlParser.KW_ROLE); + } + } + } + break; + case 6: + this.enterOuterAlt(localContext, 6); + { + this.state = 5853; + this.match(MySqlParser.KW_EVENT); + } + break; + case 7: + this.enterOuterAlt(localContext, 7); + { + this.state = 5854; + this.match(MySqlParser.KW_EXECUTE); + } + break; + case 8: + this.enterOuterAlt(localContext, 8); + { + this.state = 5855; + this.match(MySqlParser.KW_FILE); + } + break; + case 9: + this.enterOuterAlt(localContext, 9); + { + this.state = 5856; + this.match(MySqlParser.KW_GRANT); + this.state = 5857; + this.match(MySqlParser.KW_OPTION); + } + break; + case 10: + this.enterOuterAlt(localContext, 10); + { + this.state = 5858; + this.match(MySqlParser.KW_INDEX); + } + break; + case 11: + this.enterOuterAlt(localContext, 11); + { + this.state = 5859; + this.match(MySqlParser.KW_INSERT); + } + break; + case 12: + this.enterOuterAlt(localContext, 12); + { + this.state = 5860; + this.match(MySqlParser.KW_LOCK); + this.state = 5861; + this.match(MySqlParser.KW_TABLES); + } + break; + case 13: + this.enterOuterAlt(localContext, 13); + { + this.state = 5862; + this.match(MySqlParser.KW_PROCESS); + } + break; + case 14: + this.enterOuterAlt(localContext, 14); + { + this.state = 5863; + this.match(MySqlParser.KW_PROXY); + } + break; + case 15: + this.enterOuterAlt(localContext, 15); + { + this.state = 5864; + this.match(MySqlParser.KW_REFERENCES); + } + break; + case 16: + this.enterOuterAlt(localContext, 16); + { + this.state = 5865; + this.match(MySqlParser.KW_RELOAD); + } + break; + case 17: + this.enterOuterAlt(localContext, 17); + { + this.state = 5866; + this.match(MySqlParser.KW_REPLICATION); + this.state = 5867; + _la = this.tokenStream.LA(1); + if (!(_la === 333 || _la === 598)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + break; + case 18: + this.enterOuterAlt(localContext, 18); + { + this.state = 5868; + this.match(MySqlParser.KW_SELECT); + } + break; + case 19: + this.enterOuterAlt(localContext, 19); + { + this.state = 5869; + this.match(MySqlParser.KW_SHOW); + this.state = 5870; + _la = this.tokenStream.LA(1); + if (!(_la === 40 || _la === 684)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + break; + case 20: + this.enterOuterAlt(localContext, 20); + { + this.state = 5871; + this.match(MySqlParser.KW_SHUTDOWN); + } + break; + case 21: + this.enterOuterAlt(localContext, 21); + { + this.state = 5872; + this.match(MySqlParser.KW_SUPER); + } + break; + case 22: + this.enterOuterAlt(localContext, 22); + { + this.state = 5873; + this.match(MySqlParser.KW_TRIGGER); + } + break; + case 23: + this.enterOuterAlt(localContext, 23); + { + this.state = 5874; + this.match(MySqlParser.KW_UPDATE); + } + break; + case 24: + this.enterOuterAlt(localContext, 24); + { + this.state = 5875; + this.match(MySqlParser.KW_USAGE); + } + break; + case 25: + this.enterOuterAlt(localContext, 25); + { + this.state = 5876; + this.match(MySqlParser.KW_APPLICATION_PASSWORD_ADMIN); + } + break; + case 26: + this.enterOuterAlt(localContext, 26); + { + this.state = 5877; + this.match(MySqlParser.KW_AUDIT_ABORT_EXEMPT); + } + break; + case 27: + this.enterOuterAlt(localContext, 27); + { + this.state = 5878; + this.match(MySqlParser.KW_AUDIT_ADMIN); + } + break; + case 28: + this.enterOuterAlt(localContext, 28); + { + this.state = 5879; + this.match(MySqlParser.KW_AUTHENTICATION_POLICY_ADMIN); + } + break; + case 29: + this.enterOuterAlt(localContext, 29); + { + this.state = 5880; + this.match(MySqlParser.KW_BACKUP_ADMIN); + } + break; + case 30: + this.enterOuterAlt(localContext, 30); + { + this.state = 5881; + this.match(MySqlParser.KW_BINLOG_ADMIN); + } + break; + case 31: + this.enterOuterAlt(localContext, 31); + { + this.state = 5882; + this.match(MySqlParser.KW_BINLOG_ENCRYPTION_ADMIN); + } + break; + case 32: + this.enterOuterAlt(localContext, 32); + { + this.state = 5883; + this.match(MySqlParser.KW_CLONE_ADMIN); + } + break; + case 33: + this.enterOuterAlt(localContext, 33); + { + this.state = 5884; + this.match(MySqlParser.KW_CONNECTION_ADMIN); + } + break; + case 34: + this.enterOuterAlt(localContext, 34); + { + this.state = 5885; + this.match(MySqlParser.KW_ENCRYPTION_KEY_ADMIN); + } + break; + case 35: + this.enterOuterAlt(localContext, 35); + { + this.state = 5886; + this.match(MySqlParser.KW_FIREWALL_ADMIN); + } + break; + case 36: + this.enterOuterAlt(localContext, 36); + { + this.state = 5887; + this.match(MySqlParser.KW_FIREWALL_EXEMPT); + } + break; + case 37: + this.enterOuterAlt(localContext, 37); + { + this.state = 5888; + this.match(MySqlParser.KW_FIREWALL_USER); + } + break; + case 38: + this.enterOuterAlt(localContext, 38); + { + this.state = 5889; + this.match(MySqlParser.KW_FLUSH_OPTIMIZER_COSTS); + } + break; + case 39: + this.enterOuterAlt(localContext, 39); + { + this.state = 5890; + this.match(MySqlParser.KW_FLUSH_STATUS); + } + break; + case 40: + this.enterOuterAlt(localContext, 40); + { + this.state = 5891; + this.match(MySqlParser.KW_FLUSH_TABLES); + } + break; + case 41: + this.enterOuterAlt(localContext, 41); + { + this.state = 5892; + this.match(MySqlParser.KW_FLUSH_USER_RESOURCES); + } + break; + case 42: + this.enterOuterAlt(localContext, 42); + { + this.state = 5893; + this.match(MySqlParser.KW_GROUP_REPLICATION_ADMIN); + } + break; + case 43: + this.enterOuterAlt(localContext, 43); + { + this.state = 5894; + this.match(MySqlParser.KW_INNODB_REDO_LOG_ARCHIVE); + } + break; + case 44: + this.enterOuterAlt(localContext, 44); + { + this.state = 5895; + this.match(MySqlParser.KW_INNODB_REDO_LOG_ENABLE); + } + break; + case 45: + this.enterOuterAlt(localContext, 45); + { + this.state = 5896; + this.match(MySqlParser.KW_NDB_STORED_USER); + } + break; + case 46: + this.enterOuterAlt(localContext, 46); + { + this.state = 5897; + this.match(MySqlParser.KW_PASSWORDLESS_USER_ADMIN); + } + break; + case 47: + this.enterOuterAlt(localContext, 47); + { + this.state = 5898; + this.match(MySqlParser.KW_PERSIST_RO_VARIABLES_ADMIN); + } + break; + case 48: + this.enterOuterAlt(localContext, 48); + { + this.state = 5899; + this.match(MySqlParser.KW_REPLICATION_APPLIER); + } + break; + case 49: + this.enterOuterAlt(localContext, 49); + { + this.state = 5900; + this.match(MySqlParser.KW_REPLICATION_SLAVE_ADMIN); + } + break; + case 50: + this.enterOuterAlt(localContext, 50); + { + this.state = 5901; + this.match(MySqlParser.KW_RESOURCE_GROUP_ADMIN); + } + break; + case 51: + this.enterOuterAlt(localContext, 51); + { + this.state = 5902; + this.match(MySqlParser.KW_RESOURCE_GROUP_USER); + } + break; + case 52: + this.enterOuterAlt(localContext, 52); + { + this.state = 5903; + this.match(MySqlParser.KW_ROLE_ADMIN); + } + break; + case 53: + this.enterOuterAlt(localContext, 53); + { + this.state = 5904; + this.match(MySqlParser.KW_SERVICE_CONNECTION_ADMIN); + } + break; + case 54: + this.enterOuterAlt(localContext, 54); + { + this.state = 5905; + this.match(MySqlParser.KW_SESSION_VARIABLES_ADMIN); + } + break; + case 55: + this.enterOuterAlt(localContext, 55); + { + this.state = 5906; + this.match(MySqlParser.KW_SET_USER_ID); + } + break; + case 56: + this.enterOuterAlt(localContext, 56); + { + this.state = 5907; + this.match(MySqlParser.KW_SKIP_QUERY_REWRITE); + } + break; + case 57: + this.enterOuterAlt(localContext, 57); + { + this.state = 5908; + this.match(MySqlParser.KW_SHOW_ROUTINE); + } + break; + case 58: + this.enterOuterAlt(localContext, 58); + { + this.state = 5909; + this.match(MySqlParser.KW_SYSTEM_USER); + } + break; + case 59: + this.enterOuterAlt(localContext, 59); + { + this.state = 5910; + this.match(MySqlParser.KW_SYSTEM_VARIABLES_ADMIN); + } + break; + case 60: + this.enterOuterAlt(localContext, 60); + { + this.state = 5911; + this.match(MySqlParser.KW_TABLE_ENCRYPTION_ADMIN); + } + break; + case 61: + this.enterOuterAlt(localContext, 61); + { + this.state = 5912; + this.match(MySqlParser.KW_TP_CONNECTION_ADMIN); + } + break; + case 62: + this.enterOuterAlt(localContext, 62); + { + this.state = 5913; + this.match(MySqlParser.KW_VERSION_TOKEN_ADMIN); + } + break; + case 63: + this.enterOuterAlt(localContext, 63); + { + this.state = 5914; + this.match(MySqlParser.KW_XA_RECOVER_ADMIN); + } + break; + case 64: + this.enterOuterAlt(localContext, 64); + { + this.state = 5915; + this.match(MySqlParser.KW_LOAD); + this.state = 5916; + this.match(MySqlParser.KW_FROM); + this.state = 5917; + this.match(MySqlParser.KW_S3); + } + break; + case 65: + this.enterOuterAlt(localContext, 65); + { + this.state = 5918; + this.match(MySqlParser.KW_SELECT); + this.state = 5919; + this.match(MySqlParser.KW_INTO); + this.state = 5920; + this.match(MySqlParser.KW_S3); + } + break; + case 66: + this.enterOuterAlt(localContext, 66); + { + this.state = 5921; + this.match(MySqlParser.KW_INVOKE); + this.state = 5922; + this.match(MySqlParser.KW_LAMBDA); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + privilegeLevel() { + let localContext = new PrivilegeLevelContext(this.context, this.state); + this.enterRule(localContext, 518, MySqlParser.RULE_privilegeLevel); + try { + this.state = 5941; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 849, this.context)) { + case 1: + localContext = new CurrentSchemaPriviLevelContext(localContext); + this.enterOuterAlt(localContext, 1); + { + this.state = 5925; + this.match(MySqlParser.STAR); + } + break; + case 2: + localContext = new GlobalPrivLevelContext(localContext); + this.enterOuterAlt(localContext, 2); + { + this.state = 5926; + this.match(MySqlParser.STAR); + this.state = 5927; + this.match(MySqlParser.DOT); + this.state = 5928; + this.match(MySqlParser.STAR); + } + break; + case 3: + localContext = new DefiniteSchemaPrivLevelContext(localContext); + this.enterOuterAlt(localContext, 3); + { + this.state = 5929; + this.uid(); + this.state = 5930; + this.match(MySqlParser.DOT); + this.state = 5931; + this.match(MySqlParser.STAR); + } + break; + case 4: + localContext = new DefiniteFullTablePrivLevelContext(localContext); + this.enterOuterAlt(localContext, 4); + { + this.state = 5933; + this.uid(); + this.state = 5934; + this.match(MySqlParser.DOT); + this.state = 5935; + this.uid(); + } + break; + case 5: + localContext = new DefiniteFullTablePrivLevel2Context(localContext); + this.enterOuterAlt(localContext, 5); + { + this.state = 5937; + this.uid(); + this.state = 5938; + this.dottedId(); + } + break; + case 6: + localContext = new DefiniteTablePrivLevelContext(localContext); + this.enterOuterAlt(localContext, 6); + { + this.state = 5940; + this.uid(); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + renameUserClause() { + let localContext = new RenameUserClauseContext(this.context, this.state); + this.enterRule(localContext, 520, MySqlParser.RULE_renameUserClause); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 5943; + localContext._fromFirst = this.userName(); + this.state = 5944; + this.match(MySqlParser.KW_TO); + this.state = 5945; + localContext._toFirst = this.userName(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + analyzeTable() { + let localContext = new AnalyzeTableContext(this.context, this.state); + this.enterRule(localContext, 522, MySqlParser.RULE_analyzeTable); + let _la; + try { + this.state = 5995; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 856, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 5947; + this.match(MySqlParser.KW_ANALYZE); + this.state = 5949; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 115 || _la === 450) { + { + this.state = 5948; + this.tableActionOption(); + } + } + this.state = 5951; + this.match(MySqlParser.KW_TABLE); + this.state = 5952; + this.tableNames(); + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 5953; + this.match(MySqlParser.KW_ANALYZE); + this.state = 5955; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 115 || _la === 450) { + { + this.state = 5954; + this.tableActionOption(); + } + } + this.state = 5957; + this.match(MySqlParser.KW_TABLE); + this.state = 5958; + this.tableName(); + this.state = 5959; + this.match(MySqlParser.KW_UPDATE); + this.state = 5960; + this.match(MySqlParser.KW_HISTOGRAM); + this.state = 5961; + this.match(MySqlParser.KW_ON); + this.state = 5962; + this.columnNames(); + this.state = 5967; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 852, this.context)) { + case 1: + { + this.state = 5963; + this.match(MySqlParser.KW_WITH); + this.state = 5964; + this.decimalLiteral(); + this.state = 5965; + this.match(MySqlParser.KW_BUCKETS); + } + break; + } + } + break; + case 3: + this.enterOuterAlt(localContext, 3); + { + this.state = 5969; + this.match(MySqlParser.KW_ANALYZE); + this.state = 5971; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 115 || _la === 450) { + { + this.state = 5970; + this.tableActionOption(); + } + } + this.state = 5973; + this.match(MySqlParser.KW_TABLE); + this.state = 5974; + this.tableName(); + this.state = 5975; + this.match(MySqlParser.KW_UPDATE); + this.state = 5976; + this.match(MySqlParser.KW_HISTOGRAM); + this.state = 5977; + this.match(MySqlParser.KW_ON); + this.state = 5978; + this.columnName(); + this.state = 5982; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 188) { + { + this.state = 5979; + this.match(MySqlParser.KW_USING); + this.state = 5980; + this.match(MySqlParser.KW_DATA); + this.state = 5981; + this.match(MySqlParser.STRING_LITERAL); + } + } + } + break; + case 4: + this.enterOuterAlt(localContext, 4); + { + this.state = 5984; + this.match(MySqlParser.KW_ANALYZE); + this.state = 5986; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 115 || _la === 450) { + { + this.state = 5985; + this.tableActionOption(); + } + } + this.state = 5988; + this.match(MySqlParser.KW_TABLE); + this.state = 5989; + this.tableName(); + this.state = 5990; + this.match(MySqlParser.KW_DROP); + this.state = 5991; + this.match(MySqlParser.KW_HISTOGRAM); + this.state = 5992; + this.match(MySqlParser.KW_ON); + this.state = 5993; + this.columnNames(); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + checkTable() { + let localContext = new CheckTableContext(this.context, this.state); + this.enterRule(localContext, 524, MySqlParser.RULE_checkTable); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 5997; + this.match(MySqlParser.KW_CHECK); + this.state = 5998; + this.match(MySqlParser.KW_TABLE); + this.state = 5999; + this.tableNames(); + this.state = 6003; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 65 || _la === 327 || _la === 392 || _la === 396 || _la === 484 || _la === 549) { + { + { + this.state = 6000; + this.checkTableOption(); + } + } + this.state = 6005; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + checksumTable() { + let localContext = new ChecksumTableContext(this.context, this.state); + this.enterRule(localContext, 526, MySqlParser.RULE_checksumTable); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6006; + this.match(MySqlParser.KW_CHECKSUM); + this.state = 6007; + this.match(MySqlParser.KW_TABLE); + this.state = 6008; + this.tableNames(); + this.state = 6010; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 392 || _la === 549) { + { + this.state = 6009; + localContext._actionOption = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 392 || _la === 549)) { + localContext._actionOption = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + optimizeTable() { + let localContext = new OptimizeTableContext(this.context, this.state); + this.enterRule(localContext, 528, MySqlParser.RULE_optimizeTable); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6012; + this.match(MySqlParser.KW_OPTIMIZE); + this.state = 6014; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 115 || _la === 450) { + { + this.state = 6013; + this.tableActionOption(); + } + } + this.state = 6016; + _la = this.tokenStream.LA(1); + if (!(_la === 173 || _la === 752)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 6017; + this.tableNames(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + repairTable() { + let localContext = new RepairTableContext(this.context, this.state); + this.enterRule(localContext, 530, MySqlParser.RULE_repairTable); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6019; + this.match(MySqlParser.KW_REPAIR); + this.state = 6021; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 115 || _la === 450) { + { + this.state = 6020; + this.tableActionOption(); + } + } + this.state = 6023; + this.match(MySqlParser.KW_TABLE); + this.state = 6024; + this.tableNames(); + this.state = 6026; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 549) { + { + this.state = 6025; + this.match(MySqlParser.KW_QUICK); + } + } + this.state = 6029; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 392) { + { + this.state = 6028; + this.match(MySqlParser.KW_EXTENDED); + } + } + this.state = 6032; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 679) { + { + this.state = 6031; + this.match(MySqlParser.KW_USE_FRM); + } + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + tableActionOption() { + let localContext = new TableActionOptionContext(this.context, this.state); + this.enterRule(localContext, 532, MySqlParser.RULE_tableActionOption); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6034; + _la = this.tokenStream.LA(1); + if (!(_la === 115 || _la === 450)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + checkTableOption() { + let localContext = new CheckTableOptionContext(this.context, this.state); + this.enterRule(localContext, 534, MySqlParser.RULE_checkTableOption); + try { + this.state = 6043; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_FOR: + this.enterOuterAlt(localContext, 1); + { + this.state = 6036; + this.match(MySqlParser.KW_FOR); + this.state = 6037; + this.match(MySqlParser.KW_UPGRADE); + } + break; + case MySqlParser.KW_QUICK: + this.enterOuterAlt(localContext, 2); + { + this.state = 6038; + this.match(MySqlParser.KW_QUICK); + } + break; + case MySqlParser.KW_FAST: + this.enterOuterAlt(localContext, 3); + { + this.state = 6039; + this.match(MySqlParser.KW_FAST); + } + break; + case MySqlParser.KW_MEDIUM: + this.enterOuterAlt(localContext, 4); + { + this.state = 6040; + this.match(MySqlParser.KW_MEDIUM); + } + break; + case MySqlParser.KW_EXTENDED: + this.enterOuterAlt(localContext, 5); + { + this.state = 6041; + this.match(MySqlParser.KW_EXTENDED); + } + break; + case MySqlParser.KW_CHANGED: + this.enterOuterAlt(localContext, 6); + { + this.state = 6042; + this.match(MySqlParser.KW_CHANGED); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + createFunction() { + let localContext = new CreateFunctionContext(this.context, this.state); + this.enterRule(localContext, 536, MySqlParser.RULE_createFunction); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6045; + this.match(MySqlParser.KW_CREATE); + this.state = 6047; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 307) { + { + this.state = 6046; + this.match(MySqlParser.KW_AGGREGATE); + } + } + this.state = 6049; + this.match(MySqlParser.KW_FUNCTION); + this.state = 6051; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 866, this.context)) { + case 1: + { + this.state = 6050; + this.ifNotExists(); + } + break; + } + this.state = 6053; + this.functionNameCreate(); + this.state = 6054; + this.match(MySqlParser.KW_RETURNS); + this.state = 6055; + localContext._returnType = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(((((_la - 208)) & ~0x1F) === 0 && ((1 << (_la - 208)) & 261) !== 0) || _la === 649)) { + localContext._returnType = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 6056; + this.match(MySqlParser.KW_SONAME); + this.state = 6057; + this.match(MySqlParser.STRING_LITERAL); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + installComponent() { + let localContext = new InstallComponentContext(this.context, this.state); + this.enterRule(localContext, 538, MySqlParser.RULE_installComponent); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6059; + this.match(MySqlParser.KW_INSTALL); + this.state = 6060; + this.match(MySqlParser.KW_COMPONENT); + this.state = 6061; + localContext._component_name = this.uid(); + this.state = 6066; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 6062; + this.match(MySqlParser.COMMA); + this.state = 6063; + localContext._component_name = this.uid(); + } + } + this.state = 6068; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 6078; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 869, this.context)) { + case 1: + { + this.state = 6069; + this.match(MySqlParser.KW_SET); + this.state = 6070; + this.variableExpr(); + this.state = 6075; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 6071; + this.match(MySqlParser.COMMA); + this.state = 6072; + this.variableExpr(); + } + } + this.state = 6077; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + break; + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + variableExpr() { + let localContext = new VariableExprContext(this.context, this.state); + this.enterRule(localContext, 540, MySqlParser.RULE_variableExpr); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6080; + _la = this.tokenStream.LA(1); + if (!(_la === 413 || _la === 531 || _la === 893 || _la === 894)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 6081; + localContext._system_var_name = this.fullId(); + this.state = 6082; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 6083; + this.expression(0); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + uninstallComponent() { + let localContext = new UninstallComponentContext(this.context, this.state); + this.enterRule(localContext, 542, MySqlParser.RULE_uninstallComponent); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6085; + this.match(MySqlParser.KW_UNINSTALL); + this.state = 6086; + this.match(MySqlParser.KW_COMPONENT); + this.state = 6087; + localContext._component_name = this.uid(); + this.state = 6092; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 6088; + this.match(MySqlParser.COMMA); + this.state = 6089; + localContext._component_name = this.uid(); + } + } + this.state = 6094; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + installPlugin() { + let localContext = new InstallPluginContext(this.context, this.state); + this.enterRule(localContext, 544, MySqlParser.RULE_installPlugin); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6095; + this.match(MySqlParser.KW_INSTALL); + this.state = 6096; + this.match(MySqlParser.KW_PLUGIN); + this.state = 6097; + localContext._pluginName = this.uid(); + this.state = 6098; + this.match(MySqlParser.KW_SONAME); + this.state = 6099; + this.match(MySqlParser.STRING_LITERAL); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + uninstallPlugin() { + let localContext = new UninstallPluginContext(this.context, this.state); + this.enterRule(localContext, 546, MySqlParser.RULE_uninstallPlugin); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6101; + this.match(MySqlParser.KW_UNINSTALL); + this.state = 6102; + this.match(MySqlParser.KW_PLUGIN); + this.state = 6103; + localContext._pluginName = this.uid(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + cloneStatement() { + let localContext = new CloneStatementContext(this.context, this.state); + this.enterRule(localContext, 548, MySqlParser.RULE_cloneStatement); + let _la; + try { + this.state = 6135; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 876, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 6105; + this.match(MySqlParser.KW_CLONE); + this.state = 6106; + this.match(MySqlParser.KW_LOCAL); + this.state = 6107; + this.match(MySqlParser.KW_DATA); + this.state = 6108; + this.match(MySqlParser.KW_DIRECTORY); + this.state = 6110; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 6109; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 6112; + this.match(MySqlParser.STRING_LITERAL); + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 6113; + this.match(MySqlParser.KW_CLONE); + this.state = 6114; + this.match(MySqlParser.KW_INSTANCE); + this.state = 6115; + this.match(MySqlParser.KW_FROM); + this.state = 6116; + this.userHostPort(); + this.state = 6117; + this.match(MySqlParser.KW_IDENTIFIED); + this.state = 6118; + this.match(MySqlParser.KW_BY); + this.state = 6119; + this.match(MySqlParser.STRING_LITERAL); + this.state = 6126; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 360) { + { + this.state = 6120; + this.match(MySqlParser.KW_DATA); + this.state = 6121; + this.match(MySqlParser.KW_DIRECTORY); + this.state = 6123; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 6122; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 6125; + this.match(MySqlParser.STRING_LITERAL); + } + } + this.state = 6133; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 144) { + { + this.state = 6128; + this.match(MySqlParser.KW_REQUIRE); + this.state = 6130; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 502) { + { + this.state = 6129; + this.match(MySqlParser.KW_NO); + } + } + this.state = 6132; + this.match(MySqlParser.KW_SSL); + } + } + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + setStatement() { + let localContext = new SetStatementContext(this.context, this.state); + this.enterRule(localContext, 550, MySqlParser.RULE_setStatement); + let _la; + try { + this.state = 6189; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 884, this.context)) { + case 1: + localContext = new SetVariableContext(localContext); + this.enterOuterAlt(localContext, 1); + { + this.state = 6137; + this.match(MySqlParser.KW_SET); + this.state = 6138; + this.variableClause(); + this.state = 6139; + _la = this.tokenStream.LA(1); + if (!(_la === 841 || _la === 857)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 6142; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 877, this.context)) { + case 1: + { + this.state = 6140; + this.expression(0); + } + break; + case 2: + { + this.state = 6141; + this.match(MySqlParser.KW_ON); + } + break; + } + this.state = 6153; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 6144; + this.match(MySqlParser.COMMA); + this.state = 6145; + this.variableClause(); + this.state = 6146; + _la = this.tokenStream.LA(1); + if (!(_la === 841 || _la === 857)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 6149; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 878, this.context)) { + case 1: + { + this.state = 6147; + this.expression(0); + } + break; + case 2: + { + this.state = 6148; + this.match(MySqlParser.KW_ON); + } + break; + } + } + } + this.state = 6155; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + break; + case 2: + localContext = new SetCharsetContext(localContext); + this.enterOuterAlt(localContext, 2); + { + this.state = 6156; + this.match(MySqlParser.KW_SET); + this.state = 6157; + this.charSet(); + this.state = 6160; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_BINARY: + case MySqlParser.KW_ARMSCII8: + case MySqlParser.KW_ASCII: + case MySqlParser.KW_BIG5: + case MySqlParser.KW_CP1250: + case MySqlParser.KW_CP1251: + case MySqlParser.KW_CP1256: + case MySqlParser.KW_CP1257: + case MySqlParser.KW_CP850: + case MySqlParser.KW_CP852: + case MySqlParser.KW_CP866: + case MySqlParser.KW_CP932: + case MySqlParser.KW_DEC8: + case MySqlParser.KW_EUCJPMS: + case MySqlParser.KW_EUCKR: + case MySqlParser.KW_GB18030: + case MySqlParser.KW_GB2312: + case MySqlParser.KW_GBK: + case MySqlParser.KW_GEOSTD8: + case MySqlParser.KW_GREEK: + case MySqlParser.KW_HEBREW: + case MySqlParser.KW_HP8: + case MySqlParser.KW_KEYBCS2: + case MySqlParser.KW_KOI8R: + case MySqlParser.KW_KOI8U: + case MySqlParser.KW_LATIN1: + case MySqlParser.KW_LATIN2: + case MySqlParser.KW_LATIN5: + case MySqlParser.KW_LATIN7: + case MySqlParser.KW_MACCE: + case MySqlParser.KW_MACROMAN: + case MySqlParser.KW_SJIS: + case MySqlParser.KW_SWE7: + case MySqlParser.KW_TIS620: + case MySqlParser.KW_UCS2: + case MySqlParser.KW_UJIS: + case MySqlParser.KW_UTF16: + case MySqlParser.KW_UTF16LE: + case MySqlParser.KW_UTF32: + case MySqlParser.KW_UTF8: + case MySqlParser.KW_UTF8MB3: + case MySqlParser.KW_UTF8MB4: + case MySqlParser.CHARSET_REVERSE_QOUTE_STRING: + case MySqlParser.STRING_LITERAL: + { + this.state = 6158; + this.charsetName(); + } + break; + case MySqlParser.KW_DEFAULT: + { + this.state = 6159; + this.match(MySqlParser.KW_DEFAULT); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + break; + case 3: + localContext = new SetNamesContext(localContext); + this.enterOuterAlt(localContext, 3); + { + this.state = 6162; + this.match(MySqlParser.KW_SET); + this.state = 6163; + this.match(MySqlParser.KW_NAMES); + this.state = 6170; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_BINARY: + case MySqlParser.KW_ARMSCII8: + case MySqlParser.KW_ASCII: + case MySqlParser.KW_BIG5: + case MySqlParser.KW_CP1250: + case MySqlParser.KW_CP1251: + case MySqlParser.KW_CP1256: + case MySqlParser.KW_CP1257: + case MySqlParser.KW_CP850: + case MySqlParser.KW_CP852: + case MySqlParser.KW_CP866: + case MySqlParser.KW_CP932: + case MySqlParser.KW_DEC8: + case MySqlParser.KW_EUCJPMS: + case MySqlParser.KW_EUCKR: + case MySqlParser.KW_GB18030: + case MySqlParser.KW_GB2312: + case MySqlParser.KW_GBK: + case MySqlParser.KW_GEOSTD8: + case MySqlParser.KW_GREEK: + case MySqlParser.KW_HEBREW: + case MySqlParser.KW_HP8: + case MySqlParser.KW_KEYBCS2: + case MySqlParser.KW_KOI8R: + case MySqlParser.KW_KOI8U: + case MySqlParser.KW_LATIN1: + case MySqlParser.KW_LATIN2: + case MySqlParser.KW_LATIN5: + case MySqlParser.KW_LATIN7: + case MySqlParser.KW_MACCE: + case MySqlParser.KW_MACROMAN: + case MySqlParser.KW_SJIS: + case MySqlParser.KW_SWE7: + case MySqlParser.KW_TIS620: + case MySqlParser.KW_UCS2: + case MySqlParser.KW_UJIS: + case MySqlParser.KW_UTF16: + case MySqlParser.KW_UTF16LE: + case MySqlParser.KW_UTF32: + case MySqlParser.KW_UTF8: + case MySqlParser.KW_UTF8MB3: + case MySqlParser.KW_UTF8MB4: + case MySqlParser.CHARSET_REVERSE_QOUTE_STRING: + case MySqlParser.STRING_LITERAL: + { + this.state = 6164; + this.charsetName(); + this.state = 6167; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 28) { + { + this.state = 6165; + this.match(MySqlParser.KW_COLLATE); + this.state = 6166; + this.collationName(); + } + } + } + break; + case MySqlParser.KW_DEFAULT: + { + this.state = 6169; + this.match(MySqlParser.KW_DEFAULT); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + break; + case 4: + localContext = new SetPasswordContext(localContext); + this.enterOuterAlt(localContext, 4); + { + this.state = 6172; + this.setPasswordStatement(); + } + break; + case 5: + localContext = new SetTransactionContext(localContext); + this.enterOuterAlt(localContext, 5); + { + this.state = 6173; + this.setTransactionStatement(); + } + break; + case 6: + localContext = new SetAutocommitContext(localContext); + this.enterOuterAlt(localContext, 6); + { + this.state = 6174; + this.setAutocommitStatement(); + } + break; + case 7: + localContext = new SetNewValueInsideTriggerContext(localContext); + this.enterOuterAlt(localContext, 7); + { + this.state = 6175; + this.match(MySqlParser.KW_SET); + this.state = 6176; + localContext._system_var_name = this.fullId(); + this.state = 6177; + _la = this.tokenStream.LA(1); + if (!(_la === 841 || _la === 857)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 6178; + this.expression(0); + this.state = 6186; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 6179; + this.match(MySqlParser.COMMA); + this.state = 6180; + localContext._system_var_name = this.fullId(); + this.state = 6181; + _la = this.tokenStream.LA(1); + if (!(_la === 841 || _la === 857)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 6182; + this.expression(0); + } + } + this.state = 6188; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + showStatement() { + let localContext = new ShowStatementContext(this.context, this.state); + this.enterRule(localContext, 552, MySqlParser.RULE_showStatement); + let _la; + try { + this.state = 6375; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 913, this.context)) { + case 1: + localContext = new ShowMasterLogsContext(localContext); + this.enterOuterAlt(localContext, 1); + { + this.state = 6191; + this.match(MySqlParser.KW_SHOW); + this.state = 6192; + localContext._logFormat = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 228 || _la === 453)) { + localContext._logFormat = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 6193; + this.match(MySqlParser.KW_LOGS); + } + break; + case 2: + localContext = new ShowLogEventsContext(localContext); + this.enterOuterAlt(localContext, 2); + { + this.state = 6194; + this.match(MySqlParser.KW_SHOW); + this.state = 6195; + localContext._logFormat = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 318 || _la === 559)) { + localContext._logFormat = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 6196; + this.match(MySqlParser.KW_EVENTS); + this.state = 6199; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 80) { + { + this.state = 6197; + this.match(MySqlParser.KW_IN); + this.state = 6198; + localContext._filename = this.match(MySqlParser.STRING_LITERAL); + } + } + this.state = 6203; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 68) { + { + this.state = 6201; + this.match(MySqlParser.KW_FROM); + this.state = 6202; + localContext._fromPosition = this.decimalLiteral(); + } + } + this.state = 6212; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 100) { + { + this.state = 6205; + this.match(MySqlParser.KW_LIMIT); + this.state = 6209; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 887, this.context)) { + case 1: + { + this.state = 6206; + localContext._offset = this.decimalLiteral(); + this.state = 6207; + this.match(MySqlParser.COMMA); + } + break; + } + this.state = 6211; + localContext._rowCount = this.decimalLiteral(); + } + } + this.state = 6215; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 65) { + { + this.state = 6214; + this.channelOption(); + } + } + } + break; + case 3: + localContext = new ShowObjectFilterContext(localContext); + this.enterOuterAlt(localContext, 3); + { + this.state = 6217; + this.match(MySqlParser.KW_SHOW); + this.state = 6218; + this.showCommonEntity(); + this.state = 6220; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 99 || _la === 192) { + { + this.state = 6219; + this.showFilter(); + } + } + } + break; + case 4: + localContext = new ShowColumnsContext(localContext); + this.enterOuterAlt(localContext, 4); + { + this.state = 6222; + this.match(MySqlParser.KW_SHOW); + this.state = 6224; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 392) { + { + this.state = 6223; + this.match(MySqlParser.KW_EXTENDED); + } + } + this.state = 6227; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 408) { + { + this.state = 6226; + this.match(MySqlParser.KW_FULL); + } + } + this.state = 6229; + localContext._columnsFormat = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 337 || _la === 398)) { + localContext._columnsFormat = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 6230; + localContext._tableFormat = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 68 || _la === 80)) { + localContext._tableFormat = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 6231; + this.tableName(); + this.state = 6234; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 68 || _la === 80) { + { + this.state = 6232; + localContext._schemaFormat = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 68 || _la === 80)) { + localContext._schemaFormat = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 6233; + this.databaseName(); + } + } + this.state = 6237; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 99 || _la === 192) { + { + this.state = 6236; + this.showFilter(); + } + } + } + break; + case 5: + localContext = new ShowCreateDbContext(localContext); + this.enterOuterAlt(localContext, 5); + { + this.state = 6239; + this.match(MySqlParser.KW_SHOW); + this.state = 6240; + this.match(MySqlParser.KW_CREATE); + this.state = 6241; + _la = this.tokenStream.LA(1); + if (!(_la === 39 || _la === 152)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 6243; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 895, this.context)) { + case 1: + { + this.state = 6242; + this.ifNotExists(); + } + break; + } + this.state = 6245; + this.databaseName(); + } + break; + case 6: + localContext = new ShowCreateFullIdObjectContext(localContext); + this.enterOuterAlt(localContext, 6); + { + this.state = 6246; + this.match(MySqlParser.KW_SHOW); + this.state = 6247; + this.match(MySqlParser.KW_CREATE); + this.state = 6248; + _la = this.tokenStream.LA(1); + if (!(_la === 132 || _la === 178 || _la === 385)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 6249; + this.fullId(); + } + break; + case 7: + localContext = new ShowCreateFunctionContext(localContext); + this.enterOuterAlt(localContext, 7); + { + this.state = 6250; + this.match(MySqlParser.KW_SHOW); + this.state = 6251; + this.match(MySqlParser.KW_CREATE); + this.state = 6252; + this.match(MySqlParser.KW_FUNCTION); + this.state = 6253; + this.functionName(); + } + break; + case 8: + localContext = new ShowCreateViewContext(localContext); + this.enterOuterAlt(localContext, 8); + { + this.state = 6254; + this.match(MySqlParser.KW_SHOW); + this.state = 6255; + this.match(MySqlParser.KW_CREATE); + this.state = 6256; + this.match(MySqlParser.KW_VIEW); + this.state = 6257; + this.viewName(); + } + break; + case 9: + localContext = new ShowCreateTableContext(localContext); + this.enterOuterAlt(localContext, 9); + { + this.state = 6258; + this.match(MySqlParser.KW_SHOW); + this.state = 6259; + this.match(MySqlParser.KW_CREATE); + this.state = 6260; + this.match(MySqlParser.KW_TABLE); + this.state = 6261; + this.tableName(); + } + break; + case 10: + localContext = new ShowCreateUserContext(localContext); + this.enterOuterAlt(localContext, 10); + { + this.state = 6262; + this.match(MySqlParser.KW_SHOW); + this.state = 6263; + this.match(MySqlParser.KW_CREATE); + this.state = 6264; + this.match(MySqlParser.KW_USER); + this.state = 6265; + this.userName(); + } + break; + case 11: + localContext = new ShowEngineContext(localContext); + this.enterOuterAlt(localContext, 11); + { + this.state = 6266; + this.match(MySqlParser.KW_SHOW); + this.state = 6267; + this.match(MySqlParser.KW_ENGINE); + this.state = 6268; + this.engineName(); + this.state = 6269; + localContext._engineOption = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 493 || _la === 645)) { + localContext._engineOption = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + break; + case 12: + localContext = new ShowGlobalInfoContext(localContext); + this.enterOuterAlt(localContext, 12); + { + this.state = 6271; + this.match(MySqlParser.KW_SHOW); + this.state = 6272; + this.showGlobalInfoClause(); + } + break; + case 13: + localContext = new ShowErrorsContext(localContext); + this.enterOuterAlt(localContext, 13); + { + this.state = 6273; + this.match(MySqlParser.KW_SHOW); + this.state = 6274; + localContext._errorFormat = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 383 || _la === 688)) { + localContext._errorFormat = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 6282; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 100) { + { + this.state = 6275; + this.match(MySqlParser.KW_LIMIT); + this.state = 6279; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 896, this.context)) { + case 1: + { + this.state = 6276; + localContext._offset = this.decimalLiteral(); + this.state = 6277; + this.match(MySqlParser.COMMA); + } + break; + } + this.state = 6281; + localContext._rowCount = this.decimalLiteral(); + } + } + } + break; + case 14: + localContext = new ShowCountErrorsContext(localContext); + this.enterOuterAlt(localContext, 14); + { + this.state = 6284; + this.match(MySqlParser.KW_SHOW); + this.state = 6285; + this.match(MySqlParser.KW_COUNT); + this.state = 6286; + this.match(MySqlParser.LR_BRACKET); + this.state = 6287; + this.match(MySqlParser.STAR); + this.state = 6288; + this.match(MySqlParser.RR_BRACKET); + this.state = 6289; + localContext._errorFormat = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 383 || _la === 688)) { + localContext._errorFormat = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + break; + case 15: + localContext = new ShowSchemaFilterContext(localContext); + this.enterOuterAlt(localContext, 15); + { + this.state = 6290; + this.match(MySqlParser.KW_SHOW); + this.state = 6291; + this.showSchemaEntity(); + this.state = 6294; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 68 || _la === 80) { + { + this.state = 6292; + localContext._schemaFormat = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 68 || _la === 80)) { + localContext._schemaFormat = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 6293; + this.databaseName(); + } + } + this.state = 6297; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 99 || _la === 192) { + { + this.state = 6296; + this.showFilter(); + } + } + } + break; + case 16: + localContext = new ShowPercedureCodeContext(localContext); + this.enterOuterAlt(localContext, 16); + { + this.state = 6299; + this.match(MySqlParser.KW_SHOW); + this.state = 6300; + this.match(MySqlParser.KW_PROCEDURE); + this.state = 6301; + this.match(MySqlParser.KW_CODE); + this.state = 6302; + localContext._proc_name = this.fullId(); + } + break; + case 17: + localContext = new ShowFunctionCodeContext(localContext); + this.enterOuterAlt(localContext, 17); + { + this.state = 6303; + this.match(MySqlParser.KW_SHOW); + this.state = 6304; + this.match(MySqlParser.KW_FUNCTION); + this.state = 6305; + this.match(MySqlParser.KW_CODE); + this.state = 6306; + this.functionName(); + } + break; + case 18: + localContext = new ShowGrantsContext(localContext); + this.enterOuterAlt(localContext, 18); + { + this.state = 6307; + this.match(MySqlParser.KW_SHOW); + this.state = 6308; + this.match(MySqlParser.KW_GRANTS); + this.state = 6315; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 65) { + { + this.state = 6309; + this.match(MySqlParser.KW_FOR); + this.state = 6310; + this.userOrRoleName(); + this.state = 6313; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 188) { + { + this.state = 6311; + this.match(MySqlParser.KW_USING); + this.state = 6312; + this.userOrRoleNames(); + } + } + } + } + } + break; + case 19: + localContext = new ShowIndexesContext(localContext); + this.enterOuterAlt(localContext, 19); + { + this.state = 6317; + this.match(MySqlParser.KW_SHOW); + this.state = 6319; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 392) { + { + this.state = 6318; + this.match(MySqlParser.KW_EXTENDED); + } + } + this.state = 6321; + localContext._indexFormat = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 82 || _la === 93 || _la === 426)) { + localContext._indexFormat = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 6322; + localContext._tableFormat = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 68 || _la === 80)) { + localContext._tableFormat = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 6323; + this.tableName(); + this.state = 6326; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 68 || _la === 80) { + { + this.state = 6324; + localContext._schemaFormat = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 68 || _la === 80)) { + localContext._schemaFormat = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 6325; + this.databaseName(); + } + } + this.state = 6330; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 192) { + { + this.state = 6328; + this.match(MySqlParser.KW_WHERE); + this.state = 6329; + this.expression(0); + } + } + } + break; + case 20: + localContext = new ShowOpenTablesContext(localContext); + this.enterOuterAlt(localContext, 20); + { + this.state = 6332; + this.match(MySqlParser.KW_SHOW); + this.state = 6333; + this.match(MySqlParser.KW_OPEN); + this.state = 6334; + this.match(MySqlParser.KW_TABLES); + this.state = 6337; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 68 || _la === 80) { + { + this.state = 6335; + _la = this.tokenStream.LA(1); + if (!(_la === 68 || _la === 80)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 6336; + this.databaseName(); + } + } + this.state = 6340; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 99 || _la === 192) { + { + this.state = 6339; + this.showFilter(); + } + } + } + break; + case 21: + localContext = new ShowProfileContext(localContext); + this.enterOuterAlt(localContext, 21); + { + this.state = 6342; + this.match(MySqlParser.KW_SHOW); + this.state = 6343; + this.match(MySqlParser.KW_PROFILE); + this.state = 6352; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 7 || _la === 320 || _la === 355 || _la === 358 || _la === 439 || _la === 521 || _la === 605 || _la === 655 || _la === 802) { + { + this.state = 6344; + this.showProfileType(); + this.state = 6349; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 6345; + this.match(MySqlParser.COMMA); + this.state = 6346; + this.showProfileType(); + } + } + this.state = 6351; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + } + this.state = 6357; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 65) { + { + this.state = 6354; + this.match(MySqlParser.KW_FOR); + this.state = 6355; + this.match(MySqlParser.KW_QUERY); + this.state = 6356; + localContext._queryCount = this.decimalLiteral(); + } + } + this.state = 6365; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 100) { + { + this.state = 6359; + this.match(MySqlParser.KW_LIMIT); + this.state = 6360; + localContext._rowCount = this.decimalLiteral(); + this.state = 6363; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 509) { + { + this.state = 6361; + this.match(MySqlParser.KW_OFFSET); + this.state = 6362; + localContext._offset = this.decimalLiteral(); + } + } + } + } + } + break; + case 22: + localContext = new ShowSlaveStatusContext(localContext); + this.enterOuterAlt(localContext, 22); + { + this.state = 6367; + this.match(MySqlParser.KW_SHOW); + this.state = 6368; + _la = this.tokenStream.LA(1); + if (!(_la === 563 || _la === 598)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 6369; + this.match(MySqlParser.KW_STATUS); + this.state = 6371; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 65) { + { + this.state = 6370; + this.channelOption(); + } + } + } + break; + case 23: + localContext = new ShowReplicasContext(localContext); + this.enterOuterAlt(localContext, 23); + { + this.state = 6373; + this.match(MySqlParser.KW_SHOW); + this.state = 6374; + this.match(MySqlParser.KW_REPLICAS); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + variableClause() { + let localContext = new VariableClauseContext(this.context, this.state); + this.enterRule(localContext, 554, MySqlParser.RULE_variableClause); + let _la; + try { + this.state = 6387; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.LOCAL_ID: + this.enterOuterAlt(localContext, 1); + { + this.state = 6377; + this.match(MySqlParser.LOCAL_ID); + } + break; + case MySqlParser.GLOBAL_ID: + this.enterOuterAlt(localContext, 2); + { + this.state = 6378; + this.match(MySqlParser.GLOBAL_ID); + } + break; + case MySqlParser.KW_ARRAY: + case MySqlParser.KW_ATTRIBUTE: + case MySqlParser.KW_BUCKETS: + case MySqlParser.KW_CONDITION: + case MySqlParser.KW_CURRENT: + case MySqlParser.KW_CURRENT_USER: + case MySqlParser.KW_DATABASE: + case MySqlParser.KW_DEFAULT: + case MySqlParser.KW_DIAGNOSTICS: + case MySqlParser.KW_EMPTY: + case MySqlParser.KW_ENFORCED: + case MySqlParser.KW_EXCEPT: + case MySqlParser.KW_GROUP: + case MySqlParser.KW_IF: + case MySqlParser.KW_INSERT: + case MySqlParser.KW_LATERAL: + case MySqlParser.KW_LEFT: + case MySqlParser.KW_NUMBER: + case MySqlParser.KW_OPTIONAL: + case MySqlParser.KW_ORDER: + case MySqlParser.KW_PRIMARY: + case MySqlParser.KW_REPEAT: + case MySqlParser.KW_REPLACE: + case MySqlParser.KW_RIGHT: + case MySqlParser.KW_SCHEMA: + case MySqlParser.KW_SKIP_QUERY_REWRITE: + case MySqlParser.KW_STACKED: + case MySqlParser.KW_DATE: + case MySqlParser.KW_TIME: + case MySqlParser.KW_TIMESTAMP: + case MySqlParser.KW_DATETIME: + case MySqlParser.KW_YEAR: + case MySqlParser.KW_BINARY: + case MySqlParser.KW_TEXT: + case MySqlParser.KW_ENUM: + case MySqlParser.KW_SERIAL: + case MySqlParser.KW_JSON_TABLE: + case MySqlParser.KW_JSON_VALUE: + case MySqlParser.KW_NESTED: + case MySqlParser.KW_ORDINALITY: + case MySqlParser.KW_PATH: + case MySqlParser.KW_AVG: + case MySqlParser.KW_BIT_AND: + case MySqlParser.KW_BIT_OR: + case MySqlParser.KW_BIT_XOR: + case MySqlParser.KW_COUNT: + case MySqlParser.KW_CUME_DIST: + case MySqlParser.KW_DENSE_RANK: + case MySqlParser.KW_FIRST_VALUE: + case MySqlParser.KW_GROUP_CONCAT: + case MySqlParser.KW_LAG: + case MySqlParser.KW_LAST_VALUE: + case MySqlParser.KW_LEAD: + case MySqlParser.KW_MAX: + case MySqlParser.KW_MIN: + case MySqlParser.KW_NTILE: + case MySqlParser.KW_NTH_VALUE: + case MySqlParser.KW_PERCENT_RANK: + case MySqlParser.KW_RANK: + case MySqlParser.KW_ROW_NUMBER: + case MySqlParser.KW_STD: + case MySqlParser.KW_STDDEV: + case MySqlParser.KW_STDDEV_POP: + case MySqlParser.KW_STDDEV_SAMP: + case MySqlParser.KW_SUM: + case MySqlParser.KW_VAR_POP: + case MySqlParser.KW_VAR_SAMP: + case MySqlParser.KW_VARIANCE: + case MySqlParser.KW_CURRENT_DATE: + case MySqlParser.KW_CURRENT_TIME: + case MySqlParser.KW_CURRENT_TIMESTAMP: + case MySqlParser.KW_LOCALTIME: + case MySqlParser.KW_CURDATE: + case MySqlParser.KW_CURTIME: + case MySqlParser.KW_DATE_ADD: + case MySqlParser.KW_DATE_SUB: + case MySqlParser.KW_LOCALTIMESTAMP: + case MySqlParser.KW_NOW: + case MySqlParser.KW_POSITION: + case MySqlParser.KW_SUBSTR: + case MySqlParser.KW_SUBSTRING: + case MySqlParser.KW_SYSDATE: + case MySqlParser.KW_TRIM: + case MySqlParser.KW_UTC_DATE: + case MySqlParser.KW_UTC_TIME: + case MySqlParser.KW_UTC_TIMESTAMP: + case MySqlParser.KW_ACCOUNT: + case MySqlParser.KW_ACTION: + case MySqlParser.KW_AFTER: + case MySqlParser.KW_AGGREGATE: + case MySqlParser.KW_ALGORITHM: + case MySqlParser.KW_ANY: + case MySqlParser.KW_AT: + case MySqlParser.KW_AUTHORS: + case MySqlParser.KW_AUTOCOMMIT: + case MySqlParser.KW_AUTOEXTEND_SIZE: + case MySqlParser.KW_AUTO_INCREMENT: + case MySqlParser.KW_AVG_ROW_LENGTH: + case MySqlParser.KW_BEGIN: + case MySqlParser.KW_BINLOG: + case MySqlParser.KW_BIT: + case MySqlParser.KW_BLOCK: + case MySqlParser.KW_BOOL: + case MySqlParser.KW_BOOLEAN: + case MySqlParser.KW_BTREE: + case MySqlParser.KW_CACHE: + case MySqlParser.KW_CASCADED: + case MySqlParser.KW_CHAIN: + case MySqlParser.KW_CHANGED: + case MySqlParser.KW_CHANNEL: + case MySqlParser.KW_CHECKSUM: + case MySqlParser.KW_CIPHER: + case MySqlParser.KW_CLASS_ORIGIN: + case MySqlParser.KW_CLIENT: + case MySqlParser.KW_CLOSE: + case MySqlParser.KW_COALESCE: + case MySqlParser.KW_CODE: + case MySqlParser.KW_COLUMNS: + case MySqlParser.KW_COLUMN_FORMAT: + case MySqlParser.KW_COLUMN_NAME: + case MySqlParser.KW_COMMENT: + case MySqlParser.KW_COMMIT: + case MySqlParser.KW_COMPACT: + case MySqlParser.KW_COMPLETION: + case MySqlParser.KW_COMPRESSED: + case MySqlParser.KW_COMPRESSION: + case MySqlParser.KW_CONCURRENT: + case MySqlParser.KW_CONNECT: + case MySqlParser.KW_CONNECTION: + case MySqlParser.KW_CONSISTENT: + case MySqlParser.KW_CONSTRAINT_CATALOG: + case MySqlParser.KW_CONSTRAINT_SCHEMA: + case MySqlParser.KW_CONSTRAINT_NAME: + case MySqlParser.KW_CONTAINS: + case MySqlParser.KW_CONTEXT: + case MySqlParser.KW_CONTRIBUTORS: + case MySqlParser.KW_COPY: + case MySqlParser.KW_CPU: + case MySqlParser.KW_CURSOR_NAME: + case MySqlParser.KW_DATA: + case MySqlParser.KW_DATAFILE: + case MySqlParser.KW_DEALLOCATE: + case MySqlParser.KW_DEFAULT_AUTH: + case MySqlParser.KW_DEFINER: + case MySqlParser.KW_DELAY_KEY_WRITE: + case MySqlParser.KW_DES_KEY_FILE: + case MySqlParser.KW_DIRECTORY: + case MySqlParser.KW_DISABLE: + case MySqlParser.KW_DISCARD: + case MySqlParser.KW_DISK: + case MySqlParser.KW_DO: + case MySqlParser.KW_DUMPFILE: + case MySqlParser.KW_DUPLICATE: + case MySqlParser.KW_DYNAMIC: + case MySqlParser.KW_ENABLE: + case MySqlParser.KW_ENCRYPTION: + case MySqlParser.KW_END: + case MySqlParser.KW_ENDS: + case MySqlParser.KW_ENGINE: + case MySqlParser.KW_ENGINES: + case MySqlParser.KW_ERROR: + case MySqlParser.KW_ERRORS: + case MySqlParser.KW_ESCAPE: + case MySqlParser.KW_EVENT: + case MySqlParser.KW_EVENTS: + case MySqlParser.KW_EVERY: + case MySqlParser.KW_EXCHANGE: + case MySqlParser.KW_EXCLUSIVE: + case MySqlParser.KW_EXPIRE: + case MySqlParser.KW_EXPORT: + case MySqlParser.KW_EXTENDED: + case MySqlParser.KW_EXTENT_SIZE: + case MySqlParser.KW_FAILED_LOGIN_ATTEMPTS: + case MySqlParser.KW_FAST: + case MySqlParser.KW_FAULTS: + case MySqlParser.KW_FIELDS: + case MySqlParser.KW_FILE_BLOCK_SIZE: + case MySqlParser.KW_FILTER: + case MySqlParser.KW_FIRST: + case MySqlParser.KW_FIXED: + case MySqlParser.KW_FLUSH: + case MySqlParser.KW_FOLLOWS: + case MySqlParser.KW_FOUND: + case MySqlParser.KW_FULL: + case MySqlParser.KW_FUNCTION: + case MySqlParser.KW_GENERAL: + case MySqlParser.KW_GLOBAL: + case MySqlParser.KW_GRANTS: + case MySqlParser.KW_GROUP_REPLICATION: + case MySqlParser.KW_HANDLER: + case MySqlParser.KW_HASH: + case MySqlParser.KW_HELP: + case MySqlParser.KW_HISTORY: + case MySqlParser.KW_HOST: + case MySqlParser.KW_HOSTS: + case MySqlParser.KW_IDENTIFIED: + case MySqlParser.KW_IGNORE_SERVER_IDS: + case MySqlParser.KW_IMPORT: + case MySqlParser.KW_INDEXES: + case MySqlParser.KW_INITIAL_SIZE: + case MySqlParser.KW_INPLACE: + case MySqlParser.KW_INSERT_METHOD: + case MySqlParser.KW_INSTALL: + case MySqlParser.KW_INSTANCE: + case MySqlParser.KW_INSTANT: + case MySqlParser.KW_INVISIBLE: + case MySqlParser.KW_INVOKER: + case MySqlParser.KW_IO: + case MySqlParser.KW_IO_THREAD: + case MySqlParser.KW_IPC: + case MySqlParser.KW_ISOLATION: + case MySqlParser.KW_ISSUER: + case MySqlParser.KW_JSON: + case MySqlParser.KW_KEY_BLOCK_SIZE: + case MySqlParser.KW_LANGUAGE: + case MySqlParser.KW_LAST: + case MySqlParser.KW_LEAVES: + case MySqlParser.KW_LESS: + case MySqlParser.KW_LEVEL: + case MySqlParser.KW_LIST: + case MySqlParser.KW_LOCAL: + case MySqlParser.KW_LOGFILE: + case MySqlParser.KW_LOGS: + case MySqlParser.KW_MASTER: + case MySqlParser.KW_MASTER_AUTO_POSITION: + case MySqlParser.KW_MASTER_CONNECT_RETRY: + case MySqlParser.KW_MASTER_DELAY: + case MySqlParser.KW_MASTER_HEARTBEAT_PERIOD: + case MySqlParser.KW_MASTER_HOST: + case MySqlParser.KW_MASTER_LOG_FILE: + case MySqlParser.KW_MASTER_LOG_POS: + case MySqlParser.KW_MASTER_PASSWORD: + case MySqlParser.KW_MASTER_PORT: + case MySqlParser.KW_MASTER_RETRY_COUNT: + case MySqlParser.KW_MASTER_SSL: + case MySqlParser.KW_MASTER_SSL_CA: + case MySqlParser.KW_MASTER_SSL_CAPATH: + case MySqlParser.KW_MASTER_SSL_CERT: + case MySqlParser.KW_MASTER_SSL_CIPHER: + case MySqlParser.KW_MASTER_SSL_CRL: + case MySqlParser.KW_MASTER_SSL_CRLPATH: + case MySqlParser.KW_MASTER_SSL_KEY: + case MySqlParser.KW_MASTER_TLS_VERSION: + case MySqlParser.KW_MASTER_USER: + case MySqlParser.KW_MAX_CONNECTIONS_PER_HOUR: + case MySqlParser.KW_MAX_QUERIES_PER_HOUR: + case MySqlParser.KW_MAX_ROWS: + case MySqlParser.KW_MAX_SIZE: + case MySqlParser.KW_MAX_UPDATES_PER_HOUR: + case MySqlParser.KW_MAX_USER_CONNECTIONS: + case MySqlParser.KW_MEDIUM: + case MySqlParser.KW_MEMBER: + case MySqlParser.KW_MERGE: + case MySqlParser.KW_MESSAGE_TEXT: + case MySqlParser.KW_MID: + case MySqlParser.KW_MIGRATE: + case MySqlParser.KW_MIN_ROWS: + case MySqlParser.KW_MODE: + case MySqlParser.KW_MODIFY: + case MySqlParser.KW_MUTEX: + case MySqlParser.KW_MYSQL: + case MySqlParser.KW_MYSQL_ERRNO: + case MySqlParser.KW_NAME: + case MySqlParser.KW_NAMES: + case MySqlParser.KW_NCHAR: + case MySqlParser.KW_NEVER: + case MySqlParser.KW_NEXT: + case MySqlParser.KW_NO: + case MySqlParser.KW_NOWAIT: + case MySqlParser.KW_NODEGROUP: + case MySqlParser.KW_NONE: + case MySqlParser.KW_ODBC: + case MySqlParser.KW_OFFLINE: + case MySqlParser.KW_OFFSET: + case MySqlParser.KW_OF: + case MySqlParser.KW_OLD_PASSWORD: + case MySqlParser.KW_ONE: + case MySqlParser.KW_ONLINE: + case MySqlParser.KW_ONLY: + case MySqlParser.KW_OPEN: + case MySqlParser.KW_OPTIMIZER_COSTS: + case MySqlParser.KW_OPTIONS: + case MySqlParser.KW_OWNER: + case MySqlParser.KW_PACK_KEYS: + case MySqlParser.KW_PAGE: + case MySqlParser.KW_PAGE_CHECKSUM: + case MySqlParser.KW_PARSER: + case MySqlParser.KW_PARTIAL: + case MySqlParser.KW_PARTITIONING: + case MySqlParser.KW_PARTITIONS: + case MySqlParser.KW_PASSWORD: + case MySqlParser.KW_PASSWORD_LOCK_TIME: + case MySqlParser.KW_PERSIST: + case MySqlParser.KW_PERSIST_ONLY: + case MySqlParser.KW_PHASE: + case MySqlParser.KW_PLUGIN: + case MySqlParser.KW_PLUGIN_DIR: + case MySqlParser.KW_PLUGINS: + case MySqlParser.KW_PORT: + case MySqlParser.KW_PRECEDES: + case MySqlParser.KW_PREPARE: + case MySqlParser.KW_PRESERVE: + case MySqlParser.KW_PREV: + case MySqlParser.KW_PROCESSLIST: + case MySqlParser.KW_PROFILE: + case MySqlParser.KW_PROFILES: + case MySqlParser.KW_PROXY: + case MySqlParser.KW_QUERY: + case MySqlParser.KW_QUICK: + case MySqlParser.KW_REBUILD: + case MySqlParser.KW_RECOVER: + case MySqlParser.KW_RECURSIVE: + case MySqlParser.KW_REDO_BUFFER_SIZE: + case MySqlParser.KW_REDUNDANT: + case MySqlParser.KW_RELAY: + case MySqlParser.KW_RELAY_LOG_FILE: + case MySqlParser.KW_RELAY_LOG_POS: + case MySqlParser.KW_RELAYLOG: + case MySqlParser.KW_REMOVE: + case MySqlParser.KW_REORGANIZE: + case MySqlParser.KW_REPAIR: + case MySqlParser.KW_REPLICATE_DO_DB: + case MySqlParser.KW_REPLICATE_DO_TABLE: + case MySqlParser.KW_REPLICATE_IGNORE_DB: + case MySqlParser.KW_REPLICATE_IGNORE_TABLE: + case MySqlParser.KW_REPLICATE_REWRITE_DB: + case MySqlParser.KW_REPLICATE_WILD_DO_TABLE: + case MySqlParser.KW_REPLICATE_WILD_IGNORE_TABLE: + case MySqlParser.KW_REPLICATION: + case MySqlParser.KW_RESET: + case MySqlParser.KW_RESUME: + case MySqlParser.KW_RETURNED_SQLSTATE: + case MySqlParser.KW_RETURNS: + case MySqlParser.KW_REUSE: + case MySqlParser.KW_ROLE: + case MySqlParser.KW_ROLLBACK: + case MySqlParser.KW_ROLLUP: + case MySqlParser.KW_ROTATE: + case MySqlParser.KW_ROW: + case MySqlParser.KW_ROWS: + case MySqlParser.KW_ROW_FORMAT: + case MySqlParser.KW_SAVEPOINT: + case MySqlParser.KW_SCHEDULE: + case MySqlParser.KW_SECURITY: + case MySqlParser.KW_SERVER: + case MySqlParser.KW_SESSION: + case MySqlParser.KW_SHARE: + case MySqlParser.KW_SHARED: + case MySqlParser.KW_SIGNED: + case MySqlParser.KW_SIMPLE: + case MySqlParser.KW_SLAVE: + case MySqlParser.KW_SLOW: + case MySqlParser.KW_SNAPSHOT: + case MySqlParser.KW_SOCKET: + case MySqlParser.KW_SOME: + case MySqlParser.KW_SONAME: + case MySqlParser.KW_SOUNDS: + case MySqlParser.KW_SOURCE: + case MySqlParser.KW_SQL_AFTER_GTIDS: + case MySqlParser.KW_SQL_AFTER_MTS_GAPS: + case MySqlParser.KW_SQL_BEFORE_GTIDS: + case MySqlParser.KW_SQL_BUFFER_RESULT: + case MySqlParser.KW_SQL_CACHE: + case MySqlParser.KW_SQL_NO_CACHE: + case MySqlParser.KW_SQL_THREAD: + case MySqlParser.KW_START: + case MySqlParser.KW_STARTS: + case MySqlParser.KW_STATS_AUTO_RECALC: + case MySqlParser.KW_STATS_PERSISTENT: + case MySqlParser.KW_STATS_SAMPLE_PAGES: + case MySqlParser.KW_STATUS: + case MySqlParser.KW_STOP: + case MySqlParser.KW_STORAGE: + case MySqlParser.KW_STRING: + case MySqlParser.KW_SUBCLASS_ORIGIN: + case MySqlParser.KW_SUBJECT: + case MySqlParser.KW_SUBPARTITION: + case MySqlParser.KW_SUBPARTITIONS: + case MySqlParser.KW_SUSPEND: + case MySqlParser.KW_SWAPS: + case MySqlParser.KW_SWITCHES: + case MySqlParser.KW_TABLE_NAME: + case MySqlParser.KW_TABLESPACE: + case MySqlParser.KW_TABLE_TYPE: + case MySqlParser.KW_TEMPORARY: + case MySqlParser.KW_TEMPTABLE: + case MySqlParser.KW_THAN: + case MySqlParser.KW_TRADITIONAL: + case MySqlParser.KW_TRANSACTION: + case MySqlParser.KW_TRANSACTIONAL: + case MySqlParser.KW_TRIGGERS: + case MySqlParser.KW_TRUNCATE: + case MySqlParser.KW_UNBOUNDED: + case MySqlParser.KW_UNDEFINED: + case MySqlParser.KW_UNDOFILE: + case MySqlParser.KW_UNDO_BUFFER_SIZE: + case MySqlParser.KW_UNINSTALL: + case MySqlParser.KW_UNKNOWN: + case MySqlParser.KW_UNTIL: + case MySqlParser.KW_UPGRADE: + case MySqlParser.KW_USER: + case MySqlParser.KW_USE_FRM: + case MySqlParser.KW_USER_RESOURCES: + case MySqlParser.KW_VALIDATION: + case MySqlParser.KW_VALUE: + case MySqlParser.KW_VARIABLES: + case MySqlParser.KW_VIEW: + case MySqlParser.KW_VIRTUAL: + case MySqlParser.KW_VISIBLE: + case MySqlParser.KW_WAIT: + case MySqlParser.KW_WARNINGS: + case MySqlParser.KW_WITHOUT: + case MySqlParser.KW_WORK: + case MySqlParser.KW_WRAPPER: + case MySqlParser.KW_X509: + case MySqlParser.KW_XA: + case MySqlParser.KW_XML: + case MySqlParser.KW_QUARTER: + case MySqlParser.KW_MONTH: + case MySqlParser.KW_DAY: + case MySqlParser.KW_HOUR: + case MySqlParser.KW_MINUTE: + case MySqlParser.KW_WEEK: + case MySqlParser.KW_SECOND: + case MySqlParser.KW_MICROSECOND: + case MySqlParser.KW_ADMIN: + case MySqlParser.KW_AUDIT_ABORT_EXEMPT: + case MySqlParser.KW_AUDIT_ADMIN: + case MySqlParser.KW_AUTHENTICATION_POLICY_ADMIN: + case MySqlParser.KW_BACKUP_ADMIN: + case MySqlParser.KW_BINLOG_ADMIN: + case MySqlParser.KW_BINLOG_ENCRYPTION_ADMIN: + case MySqlParser.KW_CLONE_ADMIN: + case MySqlParser.KW_CONNECTION_ADMIN: + case MySqlParser.KW_ENCRYPTION_KEY_ADMIN: + case MySqlParser.KW_EXECUTE: + case MySqlParser.KW_FILE: + case MySqlParser.KW_FIREWALL_ADMIN: + case MySqlParser.KW_FIREWALL_EXEMPT: + case MySqlParser.KW_FIREWALL_USER: + case MySqlParser.KW_GROUP_REPLICATION_ADMIN: + case MySqlParser.KW_INNODB_REDO_LOG_ARCHIVE: + case MySqlParser.KW_INVOKE: + case MySqlParser.KW_LAMBDA: + case MySqlParser.KW_NDB_STORED_USER: + case MySqlParser.KW_PASSWORDLESS_USER_ADMIN: + case MySqlParser.KW_PERSIST_RO_VARIABLES_ADMIN: + case MySqlParser.KW_PRIVILEGES: + case MySqlParser.KW_PROCESS: + case MySqlParser.KW_RELOAD: + case MySqlParser.KW_REPLICATION_APPLIER: + case MySqlParser.KW_REPLICATION_SLAVE_ADMIN: + case MySqlParser.KW_RESOURCE_GROUP_ADMIN: + case MySqlParser.KW_RESOURCE_GROUP_USER: + case MySqlParser.KW_ROLE_ADMIN: + case MySqlParser.KW_ROUTINE: + case MySqlParser.KW_S3: + case MySqlParser.KW_SESSION_VARIABLES_ADMIN: + case MySqlParser.KW_SET_USER_ID: + case MySqlParser.KW_SHOW_ROUTINE: + case MySqlParser.KW_SHUTDOWN: + case MySqlParser.KW_SUPER: + case MySqlParser.KW_SYSTEM_VARIABLES_ADMIN: + case MySqlParser.KW_TABLES: + case MySqlParser.KW_TABLE_ENCRYPTION_ADMIN: + case MySqlParser.KW_VERSION_TOKEN_ADMIN: + case MySqlParser.KW_XA_RECOVER_ADMIN: + case MySqlParser.KW_ARMSCII8: + case MySqlParser.KW_ASCII: + case MySqlParser.KW_BIG5: + case MySqlParser.KW_CP1250: + case MySqlParser.KW_CP1251: + case MySqlParser.KW_CP1256: + case MySqlParser.KW_CP1257: + case MySqlParser.KW_CP850: + case MySqlParser.KW_CP852: + case MySqlParser.KW_CP866: + case MySqlParser.KW_CP932: + case MySqlParser.KW_DEC8: + case MySqlParser.KW_EUCJPMS: + case MySqlParser.KW_EUCKR: + case MySqlParser.KW_GB18030: + case MySqlParser.KW_GB2312: + case MySqlParser.KW_GBK: + case MySqlParser.KW_GEOSTD8: + case MySqlParser.KW_GREEK: + case MySqlParser.KW_HEBREW: + case MySqlParser.KW_HP8: + case MySqlParser.KW_KEYBCS2: + case MySqlParser.KW_KOI8R: + case MySqlParser.KW_KOI8U: + case MySqlParser.KW_LATIN1: + case MySqlParser.KW_LATIN2: + case MySqlParser.KW_LATIN5: + case MySqlParser.KW_LATIN7: + case MySqlParser.KW_MACCE: + case MySqlParser.KW_MACROMAN: + case MySqlParser.KW_SJIS: + case MySqlParser.KW_SWE7: + case MySqlParser.KW_TIS620: + case MySqlParser.KW_UCS2: + case MySqlParser.KW_UJIS: + case MySqlParser.KW_UTF16: + case MySqlParser.KW_UTF16LE: + case MySqlParser.KW_UTF32: + case MySqlParser.KW_UTF8: + case MySqlParser.KW_UTF8MB3: + case MySqlParser.KW_UTF8MB4: + case MySqlParser.KW_ARCHIVE: + case MySqlParser.KW_BLACKHOLE: + case MySqlParser.KW_CSV: + case MySqlParser.KW_FEDERATED: + case MySqlParser.KW_INNODB: + case MySqlParser.KW_MEMORY: + case MySqlParser.KW_MRG_MYISAM: + case MySqlParser.KW_MYISAM: + case MySqlParser.KW_NDB: + case MySqlParser.KW_NDBCLUSTER: + case MySqlParser.KW_PERFORMANCE_SCHEMA: + case MySqlParser.KW_TOKUDB: + case MySqlParser.KW_REPEATABLE: + case MySqlParser.KW_COMMITTED: + case MySqlParser.KW_UNCOMMITTED: + case MySqlParser.KW_SERIALIZABLE: + case MySqlParser.KW_GEOMETRYCOLLECTION: + case MySqlParser.KW_LINESTRING: + case MySqlParser.KW_MULTILINESTRING: + case MySqlParser.KW_MULTIPOINT: + case MySqlParser.KW_MULTIPOLYGON: + case MySqlParser.KW_POINT: + case MySqlParser.KW_POLYGON: + case MySqlParser.KW_CATALOG_NAME: + case MySqlParser.KW_CHARSET: + case MySqlParser.KW_COLLATION: + case MySqlParser.KW_ENGINE_ATTRIBUTE: + case MySqlParser.KW_FORMAT: + case MySqlParser.KW_GET_FORMAT: + case MySqlParser.KW_RANDOM: + case MySqlParser.KW_REVERSE: + case MySqlParser.KW_ROW_COUNT: + case MySqlParser.KW_SCHEMA_NAME: + case MySqlParser.KW_SECONDARY_ENGINE_ATTRIBUTE: + case MySqlParser.KW_SRID: + case MySqlParser.KW_SYSTEM_USER: + case MySqlParser.KW_TP_CONNECTION_ADMIN: + case MySqlParser.KW_WEIGHT_STRING: + case MySqlParser.MOD: + case MySqlParser.AT_SIGN: + case MySqlParser.CHARSET_REVERSE_QOUTE_STRING: + case MySqlParser.STRING_LITERAL: + case MySqlParser.ID: + this.enterOuterAlt(localContext, 3); + { + this.state = 6384; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 915, this.context)) { + case 1: + { + this.state = 6381; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 870) { + { + this.state = 6379; + this.match(MySqlParser.AT_SIGN); + this.state = 6380; + this.match(MySqlParser.AT_SIGN); + } + } + this.state = 6383; + _la = this.tokenStream.LA(1); + if (!(_la === 413 || _la === 450 || _la === 531 || _la === 532 || _la === 593)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + break; + } + this.state = 6386; + localContext._target = this.uid(); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + showCommonEntity() { + let localContext = new ShowCommonEntityContext(this.context, this.state); + this.enterRule(localContext, 556, MySqlParser.RULE_showCommonEntity); + let _la; + try { + this.state = 6403; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_CHARACTER: + this.enterOuterAlt(localContext, 1); + { + this.state = 6389; + this.match(MySqlParser.KW_CHARACTER); + this.state = 6390; + this.match(MySqlParser.KW_SET); + } + break; + case MySqlParser.KW_CHARSET: + this.enterOuterAlt(localContext, 2); + { + this.state = 6391; + this.match(MySqlParser.KW_CHARSET); + } + break; + case MySqlParser.KW_COLLATION: + this.enterOuterAlt(localContext, 3); + { + this.state = 6392; + this.match(MySqlParser.KW_COLLATION); + } + break; + case MySqlParser.KW_DATABASES: + this.enterOuterAlt(localContext, 4); + { + this.state = 6393; + this.match(MySqlParser.KW_DATABASES); + } + break; + case MySqlParser.KW_SCHEMAS: + this.enterOuterAlt(localContext, 5); + { + this.state = 6394; + this.match(MySqlParser.KW_SCHEMAS); + } + break; + case MySqlParser.KW_FUNCTION: + this.enterOuterAlt(localContext, 6); + { + this.state = 6395; + this.match(MySqlParser.KW_FUNCTION); + this.state = 6396; + this.match(MySqlParser.KW_STATUS); + } + break; + case MySqlParser.KW_PROCEDURE: + this.enterOuterAlt(localContext, 7); + { + this.state = 6397; + this.match(MySqlParser.KW_PROCEDURE); + this.state = 6398; + this.match(MySqlParser.KW_STATUS); + } + break; + case MySqlParser.KW_GLOBAL: + case MySqlParser.KW_SESSION: + case MySqlParser.KW_STATUS: + case MySqlParser.KW_VARIABLES: + this.enterOuterAlt(localContext, 8); + { + this.state = 6400; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 413 || _la === 593) { + { + this.state = 6399; + _la = this.tokenStream.LA(1); + if (!(_la === 413 || _la === 593)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + this.state = 6402; + _la = this.tokenStream.LA(1); + if (!(_la === 645 || _la === 683)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + showFilter() { + let localContext = new ShowFilterContext(this.context, this.state); + this.enterRule(localContext, 558, MySqlParser.RULE_showFilter); + try { + this.state = 6409; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_LIKE: + this.enterOuterAlt(localContext, 1); + { + this.state = 6405; + this.match(MySqlParser.KW_LIKE); + this.state = 6406; + this.match(MySqlParser.STRING_LITERAL); + } + break; + case MySqlParser.KW_WHERE: + this.enterOuterAlt(localContext, 2); + { + this.state = 6407; + this.match(MySqlParser.KW_WHERE); + this.state = 6408; + this.expression(0); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + showGlobalInfoClause() { + let localContext = new ShowGlobalInfoClauseContext(this.context, this.state); + this.enterRule(localContext, 560, MySqlParser.RULE_showGlobalInfoClause); + let _la; + try { + this.state = 6428; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_ENGINES: + case MySqlParser.KW_STORAGE: + this.enterOuterAlt(localContext, 1); + { + this.state = 6412; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 647) { + { + this.state = 6411; + this.match(MySqlParser.KW_STORAGE); + } + } + this.state = 6414; + this.match(MySqlParser.KW_ENGINES); + } + break; + case MySqlParser.KW_MASTER: + this.enterOuterAlt(localContext, 2); + { + this.state = 6415; + this.match(MySqlParser.KW_MASTER); + this.state = 6416; + this.match(MySqlParser.KW_STATUS); + } + break; + case MySqlParser.KW_PLUGINS: + this.enterOuterAlt(localContext, 3); + { + this.state = 6417; + this.match(MySqlParser.KW_PLUGINS); + } + break; + case MySqlParser.KW_PRIVILEGES: + this.enterOuterAlt(localContext, 4); + { + this.state = 6418; + this.match(MySqlParser.KW_PRIVILEGES); + } + break; + case MySqlParser.KW_FULL: + case MySqlParser.KW_PROCESSLIST: + this.enterOuterAlt(localContext, 5); + { + this.state = 6420; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 408) { + { + this.state = 6419; + this.match(MySqlParser.KW_FULL); + } + } + this.state = 6422; + this.match(MySqlParser.KW_PROCESSLIST); + } + break; + case MySqlParser.KW_PROFILES: + this.enterOuterAlt(localContext, 6); + { + this.state = 6423; + this.match(MySqlParser.KW_PROFILES); + } + break; + case MySqlParser.KW_SLAVE: + this.enterOuterAlt(localContext, 7); + { + this.state = 6424; + this.match(MySqlParser.KW_SLAVE); + this.state = 6425; + this.match(MySqlParser.KW_HOSTS); + } + break; + case MySqlParser.KW_AUTHORS: + this.enterOuterAlt(localContext, 8); + { + this.state = 6426; + this.match(MySqlParser.KW_AUTHORS); + } + break; + case MySqlParser.KW_CONTRIBUTORS: + this.enterOuterAlt(localContext, 9); + { + this.state = 6427; + this.match(MySqlParser.KW_CONTRIBUTORS); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + showSchemaEntity() { + let localContext = new ShowSchemaEntityContext(this.context, this.state); + this.enterRule(localContext, 562, MySqlParser.RULE_showSchemaEntity); + let _la; + try { + this.state = 6441; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_EVENTS: + this.enterOuterAlt(localContext, 1); + { + this.state = 6430; + this.match(MySqlParser.KW_EVENTS); + } + break; + case MySqlParser.KW_TABLE: + this.enterOuterAlt(localContext, 2); + { + this.state = 6431; + this.match(MySqlParser.KW_TABLE); + this.state = 6432; + this.match(MySqlParser.KW_STATUS); + } + break; + case MySqlParser.KW_EXTENDED: + case MySqlParser.KW_FULL: + case MySqlParser.KW_TABLES: + this.enterOuterAlt(localContext, 3); + { + this.state = 6434; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 392) { + { + this.state = 6433; + this.match(MySqlParser.KW_EXTENDED); + } + } + this.state = 6437; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 408) { + { + this.state = 6436; + this.match(MySqlParser.KW_FULL); + } + } + this.state = 6439; + this.match(MySqlParser.KW_TABLES); + } + break; + case MySqlParser.KW_TRIGGERS: + this.enterOuterAlt(localContext, 4); + { + this.state = 6440; + this.match(MySqlParser.KW_TRIGGERS); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + showProfileType() { + let localContext = new ShowProfileTypeContext(this.context, this.state); + this.enterRule(localContext, 564, MySqlParser.RULE_showProfileType); + try { + this.state = 6455; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_ALL: + this.enterOuterAlt(localContext, 1); + { + this.state = 6443; + this.match(MySqlParser.KW_ALL); + } + break; + case MySqlParser.KW_BLOCK: + this.enterOuterAlt(localContext, 2); + { + this.state = 6444; + this.match(MySqlParser.KW_BLOCK); + this.state = 6445; + this.match(MySqlParser.KW_IO); + } + break; + case MySqlParser.KW_CONTEXT: + this.enterOuterAlt(localContext, 3); + { + this.state = 6446; + this.match(MySqlParser.KW_CONTEXT); + this.state = 6447; + this.match(MySqlParser.KW_SWITCHES); + } + break; + case MySqlParser.KW_CPU: + this.enterOuterAlt(localContext, 4); + { + this.state = 6448; + this.match(MySqlParser.KW_CPU); + } + break; + case MySqlParser.KW_IPC: + this.enterOuterAlt(localContext, 5); + { + this.state = 6449; + this.match(MySqlParser.KW_IPC); + } + break; + case MySqlParser.KW_MEMORY: + this.enterOuterAlt(localContext, 6); + { + this.state = 6450; + this.match(MySqlParser.KW_MEMORY); + } + break; + case MySqlParser.KW_PAGE: + this.enterOuterAlt(localContext, 7); + { + this.state = 6451; + this.match(MySqlParser.KW_PAGE); + this.state = 6452; + this.match(MySqlParser.KW_FAULTS); + } + break; + case MySqlParser.KW_SOURCE: + this.enterOuterAlt(localContext, 8); + { + this.state = 6453; + this.match(MySqlParser.KW_SOURCE); + } + break; + case MySqlParser.KW_SWAPS: + this.enterOuterAlt(localContext, 9); + { + this.state = 6454; + this.match(MySqlParser.KW_SWAPS); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + binlogStatement() { + let localContext = new BinlogStatementContext(this.context, this.state); + this.enterRule(localContext, 566, MySqlParser.RULE_binlogStatement); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6457; + this.match(MySqlParser.KW_BINLOG); + this.state = 6458; + this.match(MySqlParser.STRING_LITERAL); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + cacheIndexStatement() { + let localContext = new CacheIndexStatementContext(this.context, this.state); + this.enterRule(localContext, 568, MySqlParser.RULE_cacheIndexStatement); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6460; + this.match(MySqlParser.KW_CACHE); + this.state = 6461; + this.match(MySqlParser.KW_INDEX); + this.state = 6479; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 929, this.context)) { + case 1: + { + this.state = 6462; + this.tableIndex(); + this.state = 6467; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 6463; + this.match(MySqlParser.COMMA); + this.state = 6464; + this.tableIndex(); + } + } + this.state = 6469; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + break; + case 2: + { + this.state = 6470; + this.tableName(); + this.state = 6471; + this.match(MySqlParser.KW_PARTITION); + this.state = 6472; + this.match(MySqlParser.LR_BRACKET); + this.state = 6475; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_ARRAY: + case MySqlParser.KW_ATTRIBUTE: + case MySqlParser.KW_BUCKETS: + case MySqlParser.KW_CONDITION: + case MySqlParser.KW_CURRENT: + case MySqlParser.KW_CURRENT_USER: + case MySqlParser.KW_DATABASE: + case MySqlParser.KW_DEFAULT: + case MySqlParser.KW_DIAGNOSTICS: + case MySqlParser.KW_EMPTY: + case MySqlParser.KW_ENFORCED: + case MySqlParser.KW_EXCEPT: + case MySqlParser.KW_GROUP: + case MySqlParser.KW_IF: + case MySqlParser.KW_INSERT: + case MySqlParser.KW_LATERAL: + case MySqlParser.KW_LEFT: + case MySqlParser.KW_NUMBER: + case MySqlParser.KW_OPTIONAL: + case MySqlParser.KW_ORDER: + case MySqlParser.KW_PRIMARY: + case MySqlParser.KW_REPEAT: + case MySqlParser.KW_REPLACE: + case MySqlParser.KW_RIGHT: + case MySqlParser.KW_SCHEMA: + case MySqlParser.KW_SKIP_QUERY_REWRITE: + case MySqlParser.KW_STACKED: + case MySqlParser.KW_DATE: + case MySqlParser.KW_TIME: + case MySqlParser.KW_TIMESTAMP: + case MySqlParser.KW_DATETIME: + case MySqlParser.KW_YEAR: + case MySqlParser.KW_BINARY: + case MySqlParser.KW_TEXT: + case MySqlParser.KW_ENUM: + case MySqlParser.KW_SERIAL: + case MySqlParser.KW_JSON_TABLE: + case MySqlParser.KW_JSON_VALUE: + case MySqlParser.KW_NESTED: + case MySqlParser.KW_ORDINALITY: + case MySqlParser.KW_PATH: + case MySqlParser.KW_AVG: + case MySqlParser.KW_BIT_AND: + case MySqlParser.KW_BIT_OR: + case MySqlParser.KW_BIT_XOR: + case MySqlParser.KW_COUNT: + case MySqlParser.KW_CUME_DIST: + case MySqlParser.KW_DENSE_RANK: + case MySqlParser.KW_FIRST_VALUE: + case MySqlParser.KW_GROUP_CONCAT: + case MySqlParser.KW_LAG: + case MySqlParser.KW_LAST_VALUE: + case MySqlParser.KW_LEAD: + case MySqlParser.KW_MAX: + case MySqlParser.KW_MIN: + case MySqlParser.KW_NTILE: + case MySqlParser.KW_NTH_VALUE: + case MySqlParser.KW_PERCENT_RANK: + case MySqlParser.KW_RANK: + case MySqlParser.KW_ROW_NUMBER: + case MySqlParser.KW_STD: + case MySqlParser.KW_STDDEV: + case MySqlParser.KW_STDDEV_POP: + case MySqlParser.KW_STDDEV_SAMP: + case MySqlParser.KW_SUM: + case MySqlParser.KW_VAR_POP: + case MySqlParser.KW_VAR_SAMP: + case MySqlParser.KW_VARIANCE: + case MySqlParser.KW_CURRENT_DATE: + case MySqlParser.KW_CURRENT_TIME: + case MySqlParser.KW_CURRENT_TIMESTAMP: + case MySqlParser.KW_LOCALTIME: + case MySqlParser.KW_CURDATE: + case MySqlParser.KW_CURTIME: + case MySqlParser.KW_DATE_ADD: + case MySqlParser.KW_DATE_SUB: + case MySqlParser.KW_LOCALTIMESTAMP: + case MySqlParser.KW_NOW: + case MySqlParser.KW_POSITION: + case MySqlParser.KW_SUBSTR: + case MySqlParser.KW_SUBSTRING: + case MySqlParser.KW_SYSDATE: + case MySqlParser.KW_TRIM: + case MySqlParser.KW_UTC_DATE: + case MySqlParser.KW_UTC_TIME: + case MySqlParser.KW_UTC_TIMESTAMP: + case MySqlParser.KW_ACCOUNT: + case MySqlParser.KW_ACTION: + case MySqlParser.KW_AFTER: + case MySqlParser.KW_AGGREGATE: + case MySqlParser.KW_ALGORITHM: + case MySqlParser.KW_ANY: + case MySqlParser.KW_AT: + case MySqlParser.KW_AUTHORS: + case MySqlParser.KW_AUTOCOMMIT: + case MySqlParser.KW_AUTOEXTEND_SIZE: + case MySqlParser.KW_AUTO_INCREMENT: + case MySqlParser.KW_AVG_ROW_LENGTH: + case MySqlParser.KW_BEGIN: + case MySqlParser.KW_BINLOG: + case MySqlParser.KW_BIT: + case MySqlParser.KW_BLOCK: + case MySqlParser.KW_BOOL: + case MySqlParser.KW_BOOLEAN: + case MySqlParser.KW_BTREE: + case MySqlParser.KW_CACHE: + case MySqlParser.KW_CASCADED: + case MySqlParser.KW_CHAIN: + case MySqlParser.KW_CHANGED: + case MySqlParser.KW_CHANNEL: + case MySqlParser.KW_CHECKSUM: + case MySqlParser.KW_CIPHER: + case MySqlParser.KW_CLASS_ORIGIN: + case MySqlParser.KW_CLIENT: + case MySqlParser.KW_CLOSE: + case MySqlParser.KW_COALESCE: + case MySqlParser.KW_CODE: + case MySqlParser.KW_COLUMNS: + case MySqlParser.KW_COLUMN_FORMAT: + case MySqlParser.KW_COLUMN_NAME: + case MySqlParser.KW_COMMENT: + case MySqlParser.KW_COMMIT: + case MySqlParser.KW_COMPACT: + case MySqlParser.KW_COMPLETION: + case MySqlParser.KW_COMPRESSED: + case MySqlParser.KW_COMPRESSION: + case MySqlParser.KW_CONCURRENT: + case MySqlParser.KW_CONNECT: + case MySqlParser.KW_CONNECTION: + case MySqlParser.KW_CONSISTENT: + case MySqlParser.KW_CONSTRAINT_CATALOG: + case MySqlParser.KW_CONSTRAINT_SCHEMA: + case MySqlParser.KW_CONSTRAINT_NAME: + case MySqlParser.KW_CONTAINS: + case MySqlParser.KW_CONTEXT: + case MySqlParser.KW_CONTRIBUTORS: + case MySqlParser.KW_COPY: + case MySqlParser.KW_CPU: + case MySqlParser.KW_CURSOR_NAME: + case MySqlParser.KW_DATA: + case MySqlParser.KW_DATAFILE: + case MySqlParser.KW_DEALLOCATE: + case MySqlParser.KW_DEFAULT_AUTH: + case MySqlParser.KW_DEFINER: + case MySqlParser.KW_DELAY_KEY_WRITE: + case MySqlParser.KW_DES_KEY_FILE: + case MySqlParser.KW_DIRECTORY: + case MySqlParser.KW_DISABLE: + case MySqlParser.KW_DISCARD: + case MySqlParser.KW_DISK: + case MySqlParser.KW_DO: + case MySqlParser.KW_DUMPFILE: + case MySqlParser.KW_DUPLICATE: + case MySqlParser.KW_DYNAMIC: + case MySqlParser.KW_ENABLE: + case MySqlParser.KW_ENCRYPTION: + case MySqlParser.KW_END: + case MySqlParser.KW_ENDS: + case MySqlParser.KW_ENGINE: + case MySqlParser.KW_ENGINES: + case MySqlParser.KW_ERROR: + case MySqlParser.KW_ERRORS: + case MySqlParser.KW_ESCAPE: + case MySqlParser.KW_EVENT: + case MySqlParser.KW_EVENTS: + case MySqlParser.KW_EVERY: + case MySqlParser.KW_EXCHANGE: + case MySqlParser.KW_EXCLUSIVE: + case MySqlParser.KW_EXPIRE: + case MySqlParser.KW_EXPORT: + case MySqlParser.KW_EXTENDED: + case MySqlParser.KW_EXTENT_SIZE: + case MySqlParser.KW_FAILED_LOGIN_ATTEMPTS: + case MySqlParser.KW_FAST: + case MySqlParser.KW_FAULTS: + case MySqlParser.KW_FIELDS: + case MySqlParser.KW_FILE_BLOCK_SIZE: + case MySqlParser.KW_FILTER: + case MySqlParser.KW_FIRST: + case MySqlParser.KW_FIXED: + case MySqlParser.KW_FLUSH: + case MySqlParser.KW_FOLLOWS: + case MySqlParser.KW_FOUND: + case MySqlParser.KW_FULL: + case MySqlParser.KW_FUNCTION: + case MySqlParser.KW_GENERAL: + case MySqlParser.KW_GLOBAL: + case MySqlParser.KW_GRANTS: + case MySqlParser.KW_GROUP_REPLICATION: + case MySqlParser.KW_HANDLER: + case MySqlParser.KW_HASH: + case MySqlParser.KW_HELP: + case MySqlParser.KW_HISTORY: + case MySqlParser.KW_HOST: + case MySqlParser.KW_HOSTS: + case MySqlParser.KW_IDENTIFIED: + case MySqlParser.KW_IGNORE_SERVER_IDS: + case MySqlParser.KW_IMPORT: + case MySqlParser.KW_INDEXES: + case MySqlParser.KW_INITIAL_SIZE: + case MySqlParser.KW_INPLACE: + case MySqlParser.KW_INSERT_METHOD: + case MySqlParser.KW_INSTALL: + case MySqlParser.KW_INSTANCE: + case MySqlParser.KW_INSTANT: + case MySqlParser.KW_INVISIBLE: + case MySqlParser.KW_INVOKER: + case MySqlParser.KW_IO: + case MySqlParser.KW_IO_THREAD: + case MySqlParser.KW_IPC: + case MySqlParser.KW_ISOLATION: + case MySqlParser.KW_ISSUER: + case MySqlParser.KW_JSON: + case MySqlParser.KW_KEY_BLOCK_SIZE: + case MySqlParser.KW_LANGUAGE: + case MySqlParser.KW_LAST: + case MySqlParser.KW_LEAVES: + case MySqlParser.KW_LESS: + case MySqlParser.KW_LEVEL: + case MySqlParser.KW_LIST: + case MySqlParser.KW_LOCAL: + case MySqlParser.KW_LOGFILE: + case MySqlParser.KW_LOGS: + case MySqlParser.KW_MASTER: + case MySqlParser.KW_MASTER_AUTO_POSITION: + case MySqlParser.KW_MASTER_CONNECT_RETRY: + case MySqlParser.KW_MASTER_DELAY: + case MySqlParser.KW_MASTER_HEARTBEAT_PERIOD: + case MySqlParser.KW_MASTER_HOST: + case MySqlParser.KW_MASTER_LOG_FILE: + case MySqlParser.KW_MASTER_LOG_POS: + case MySqlParser.KW_MASTER_PASSWORD: + case MySqlParser.KW_MASTER_PORT: + case MySqlParser.KW_MASTER_RETRY_COUNT: + case MySqlParser.KW_MASTER_SSL: + case MySqlParser.KW_MASTER_SSL_CA: + case MySqlParser.KW_MASTER_SSL_CAPATH: + case MySqlParser.KW_MASTER_SSL_CERT: + case MySqlParser.KW_MASTER_SSL_CIPHER: + case MySqlParser.KW_MASTER_SSL_CRL: + case MySqlParser.KW_MASTER_SSL_CRLPATH: + case MySqlParser.KW_MASTER_SSL_KEY: + case MySqlParser.KW_MASTER_TLS_VERSION: + case MySqlParser.KW_MASTER_USER: + case MySqlParser.KW_MAX_CONNECTIONS_PER_HOUR: + case MySqlParser.KW_MAX_QUERIES_PER_HOUR: + case MySqlParser.KW_MAX_ROWS: + case MySqlParser.KW_MAX_SIZE: + case MySqlParser.KW_MAX_UPDATES_PER_HOUR: + case MySqlParser.KW_MAX_USER_CONNECTIONS: + case MySqlParser.KW_MEDIUM: + case MySqlParser.KW_MEMBER: + case MySqlParser.KW_MERGE: + case MySqlParser.KW_MESSAGE_TEXT: + case MySqlParser.KW_MID: + case MySqlParser.KW_MIGRATE: + case MySqlParser.KW_MIN_ROWS: + case MySqlParser.KW_MODE: + case MySqlParser.KW_MODIFY: + case MySqlParser.KW_MUTEX: + case MySqlParser.KW_MYSQL: + case MySqlParser.KW_MYSQL_ERRNO: + case MySqlParser.KW_NAME: + case MySqlParser.KW_NAMES: + case MySqlParser.KW_NCHAR: + case MySqlParser.KW_NEVER: + case MySqlParser.KW_NEXT: + case MySqlParser.KW_NO: + case MySqlParser.KW_NOWAIT: + case MySqlParser.KW_NODEGROUP: + case MySqlParser.KW_NONE: + case MySqlParser.KW_ODBC: + case MySqlParser.KW_OFFLINE: + case MySqlParser.KW_OFFSET: + case MySqlParser.KW_OF: + case MySqlParser.KW_OLD_PASSWORD: + case MySqlParser.KW_ONE: + case MySqlParser.KW_ONLINE: + case MySqlParser.KW_ONLY: + case MySqlParser.KW_OPEN: + case MySqlParser.KW_OPTIMIZER_COSTS: + case MySqlParser.KW_OPTIONS: + case MySqlParser.KW_OWNER: + case MySqlParser.KW_PACK_KEYS: + case MySqlParser.KW_PAGE: + case MySqlParser.KW_PAGE_CHECKSUM: + case MySqlParser.KW_PARSER: + case MySqlParser.KW_PARTIAL: + case MySqlParser.KW_PARTITIONING: + case MySqlParser.KW_PARTITIONS: + case MySqlParser.KW_PASSWORD: + case MySqlParser.KW_PASSWORD_LOCK_TIME: + case MySqlParser.KW_PHASE: + case MySqlParser.KW_PLUGIN: + case MySqlParser.KW_PLUGIN_DIR: + case MySqlParser.KW_PLUGINS: + case MySqlParser.KW_PORT: + case MySqlParser.KW_PRECEDES: + case MySqlParser.KW_PREPARE: + case MySqlParser.KW_PRESERVE: + case MySqlParser.KW_PREV: + case MySqlParser.KW_PROCESSLIST: + case MySqlParser.KW_PROFILE: + case MySqlParser.KW_PROFILES: + case MySqlParser.KW_PROXY: + case MySqlParser.KW_QUERY: + case MySqlParser.KW_QUICK: + case MySqlParser.KW_REBUILD: + case MySqlParser.KW_RECOVER: + case MySqlParser.KW_RECURSIVE: + case MySqlParser.KW_REDO_BUFFER_SIZE: + case MySqlParser.KW_REDUNDANT: + case MySqlParser.KW_RELAY: + case MySqlParser.KW_RELAY_LOG_FILE: + case MySqlParser.KW_RELAY_LOG_POS: + case MySqlParser.KW_RELAYLOG: + case MySqlParser.KW_REMOVE: + case MySqlParser.KW_REORGANIZE: + case MySqlParser.KW_REPAIR: + case MySqlParser.KW_REPLICATE_DO_DB: + case MySqlParser.KW_REPLICATE_DO_TABLE: + case MySqlParser.KW_REPLICATE_IGNORE_DB: + case MySqlParser.KW_REPLICATE_IGNORE_TABLE: + case MySqlParser.KW_REPLICATE_REWRITE_DB: + case MySqlParser.KW_REPLICATE_WILD_DO_TABLE: + case MySqlParser.KW_REPLICATE_WILD_IGNORE_TABLE: + case MySqlParser.KW_REPLICATION: + case MySqlParser.KW_RESET: + case MySqlParser.KW_RESUME: + case MySqlParser.KW_RETURNED_SQLSTATE: + case MySqlParser.KW_RETURNS: + case MySqlParser.KW_REUSE: + case MySqlParser.KW_ROLE: + case MySqlParser.KW_ROLLBACK: + case MySqlParser.KW_ROLLUP: + case MySqlParser.KW_ROTATE: + case MySqlParser.KW_ROW: + case MySqlParser.KW_ROWS: + case MySqlParser.KW_ROW_FORMAT: + case MySqlParser.KW_SAVEPOINT: + case MySqlParser.KW_SCHEDULE: + case MySqlParser.KW_SECURITY: + case MySqlParser.KW_SERVER: + case MySqlParser.KW_SESSION: + case MySqlParser.KW_SHARE: + case MySqlParser.KW_SHARED: + case MySqlParser.KW_SIGNED: + case MySqlParser.KW_SIMPLE: + case MySqlParser.KW_SLAVE: + case MySqlParser.KW_SLOW: + case MySqlParser.KW_SNAPSHOT: + case MySqlParser.KW_SOCKET: + case MySqlParser.KW_SOME: + case MySqlParser.KW_SONAME: + case MySqlParser.KW_SOUNDS: + case MySqlParser.KW_SOURCE: + case MySqlParser.KW_SQL_AFTER_GTIDS: + case MySqlParser.KW_SQL_AFTER_MTS_GAPS: + case MySqlParser.KW_SQL_BEFORE_GTIDS: + case MySqlParser.KW_SQL_BUFFER_RESULT: + case MySqlParser.KW_SQL_CACHE: + case MySqlParser.KW_SQL_NO_CACHE: + case MySqlParser.KW_SQL_THREAD: + case MySqlParser.KW_START: + case MySqlParser.KW_STARTS: + case MySqlParser.KW_STATS_AUTO_RECALC: + case MySqlParser.KW_STATS_PERSISTENT: + case MySqlParser.KW_STATS_SAMPLE_PAGES: + case MySqlParser.KW_STATUS: + case MySqlParser.KW_STOP: + case MySqlParser.KW_STORAGE: + case MySqlParser.KW_STRING: + case MySqlParser.KW_SUBCLASS_ORIGIN: + case MySqlParser.KW_SUBJECT: + case MySqlParser.KW_SUBPARTITION: + case MySqlParser.KW_SUBPARTITIONS: + case MySqlParser.KW_SUSPEND: + case MySqlParser.KW_SWAPS: + case MySqlParser.KW_SWITCHES: + case MySqlParser.KW_TABLE_NAME: + case MySqlParser.KW_TABLESPACE: + case MySqlParser.KW_TABLE_TYPE: + case MySqlParser.KW_TEMPORARY: + case MySqlParser.KW_TEMPTABLE: + case MySqlParser.KW_THAN: + case MySqlParser.KW_TRADITIONAL: + case MySqlParser.KW_TRANSACTION: + case MySqlParser.KW_TRANSACTIONAL: + case MySqlParser.KW_TRIGGERS: + case MySqlParser.KW_TRUNCATE: + case MySqlParser.KW_UNBOUNDED: + case MySqlParser.KW_UNDEFINED: + case MySqlParser.KW_UNDOFILE: + case MySqlParser.KW_UNDO_BUFFER_SIZE: + case MySqlParser.KW_UNINSTALL: + case MySqlParser.KW_UNKNOWN: + case MySqlParser.KW_UNTIL: + case MySqlParser.KW_UPGRADE: + case MySqlParser.KW_USER: + case MySqlParser.KW_USE_FRM: + case MySqlParser.KW_USER_RESOURCES: + case MySqlParser.KW_VALIDATION: + case MySqlParser.KW_VALUE: + case MySqlParser.KW_VARIABLES: + case MySqlParser.KW_VIEW: + case MySqlParser.KW_VIRTUAL: + case MySqlParser.KW_VISIBLE: + case MySqlParser.KW_WAIT: + case MySqlParser.KW_WARNINGS: + case MySqlParser.KW_WITHOUT: + case MySqlParser.KW_WORK: + case MySqlParser.KW_WRAPPER: + case MySqlParser.KW_X509: + case MySqlParser.KW_XA: + case MySqlParser.KW_XML: + case MySqlParser.KW_QUARTER: + case MySqlParser.KW_MONTH: + case MySqlParser.KW_DAY: + case MySqlParser.KW_HOUR: + case MySqlParser.KW_MINUTE: + case MySqlParser.KW_WEEK: + case MySqlParser.KW_SECOND: + case MySqlParser.KW_MICROSECOND: + case MySqlParser.KW_ADMIN: + case MySqlParser.KW_AUDIT_ABORT_EXEMPT: + case MySqlParser.KW_AUDIT_ADMIN: + case MySqlParser.KW_AUTHENTICATION_POLICY_ADMIN: + case MySqlParser.KW_BACKUP_ADMIN: + case MySqlParser.KW_BINLOG_ADMIN: + case MySqlParser.KW_BINLOG_ENCRYPTION_ADMIN: + case MySqlParser.KW_CLONE_ADMIN: + case MySqlParser.KW_CONNECTION_ADMIN: + case MySqlParser.KW_ENCRYPTION_KEY_ADMIN: + case MySqlParser.KW_EXECUTE: + case MySqlParser.KW_FILE: + case MySqlParser.KW_FIREWALL_ADMIN: + case MySqlParser.KW_FIREWALL_EXEMPT: + case MySqlParser.KW_FIREWALL_USER: + case MySqlParser.KW_GROUP_REPLICATION_ADMIN: + case MySqlParser.KW_INNODB_REDO_LOG_ARCHIVE: + case MySqlParser.KW_INVOKE: + case MySqlParser.KW_LAMBDA: + case MySqlParser.KW_NDB_STORED_USER: + case MySqlParser.KW_PASSWORDLESS_USER_ADMIN: + case MySqlParser.KW_PERSIST_RO_VARIABLES_ADMIN: + case MySqlParser.KW_PRIVILEGES: + case MySqlParser.KW_PROCESS: + case MySqlParser.KW_RELOAD: + case MySqlParser.KW_REPLICATION_APPLIER: + case MySqlParser.KW_REPLICATION_SLAVE_ADMIN: + case MySqlParser.KW_RESOURCE_GROUP_ADMIN: + case MySqlParser.KW_RESOURCE_GROUP_USER: + case MySqlParser.KW_ROLE_ADMIN: + case MySqlParser.KW_ROUTINE: + case MySqlParser.KW_S3: + case MySqlParser.KW_SESSION_VARIABLES_ADMIN: + case MySqlParser.KW_SET_USER_ID: + case MySqlParser.KW_SHOW_ROUTINE: + case MySqlParser.KW_SHUTDOWN: + case MySqlParser.KW_SUPER: + case MySqlParser.KW_SYSTEM_VARIABLES_ADMIN: + case MySqlParser.KW_TABLES: + case MySqlParser.KW_TABLE_ENCRYPTION_ADMIN: + case MySqlParser.KW_VERSION_TOKEN_ADMIN: + case MySqlParser.KW_XA_RECOVER_ADMIN: + case MySqlParser.KW_ARMSCII8: + case MySqlParser.KW_ASCII: + case MySqlParser.KW_BIG5: + case MySqlParser.KW_CP1250: + case MySqlParser.KW_CP1251: + case MySqlParser.KW_CP1256: + case MySqlParser.KW_CP1257: + case MySqlParser.KW_CP850: + case MySqlParser.KW_CP852: + case MySqlParser.KW_CP866: + case MySqlParser.KW_CP932: + case MySqlParser.KW_DEC8: + case MySqlParser.KW_EUCJPMS: + case MySqlParser.KW_EUCKR: + case MySqlParser.KW_GB18030: + case MySqlParser.KW_GB2312: + case MySqlParser.KW_GBK: + case MySqlParser.KW_GEOSTD8: + case MySqlParser.KW_GREEK: + case MySqlParser.KW_HEBREW: + case MySqlParser.KW_HP8: + case MySqlParser.KW_KEYBCS2: + case MySqlParser.KW_KOI8R: + case MySqlParser.KW_KOI8U: + case MySqlParser.KW_LATIN1: + case MySqlParser.KW_LATIN2: + case MySqlParser.KW_LATIN5: + case MySqlParser.KW_LATIN7: + case MySqlParser.KW_MACCE: + case MySqlParser.KW_MACROMAN: + case MySqlParser.KW_SJIS: + case MySqlParser.KW_SWE7: + case MySqlParser.KW_TIS620: + case MySqlParser.KW_UCS2: + case MySqlParser.KW_UJIS: + case MySqlParser.KW_UTF16: + case MySqlParser.KW_UTF16LE: + case MySqlParser.KW_UTF32: + case MySqlParser.KW_UTF8: + case MySqlParser.KW_UTF8MB3: + case MySqlParser.KW_UTF8MB4: + case MySqlParser.KW_ARCHIVE: + case MySqlParser.KW_BLACKHOLE: + case MySqlParser.KW_CSV: + case MySqlParser.KW_FEDERATED: + case MySqlParser.KW_INNODB: + case MySqlParser.KW_MEMORY: + case MySqlParser.KW_MRG_MYISAM: + case MySqlParser.KW_MYISAM: + case MySqlParser.KW_NDB: + case MySqlParser.KW_NDBCLUSTER: + case MySqlParser.KW_PERFORMANCE_SCHEMA: + case MySqlParser.KW_TOKUDB: + case MySqlParser.KW_REPEATABLE: + case MySqlParser.KW_COMMITTED: + case MySqlParser.KW_UNCOMMITTED: + case MySqlParser.KW_SERIALIZABLE: + case MySqlParser.KW_GEOMETRYCOLLECTION: + case MySqlParser.KW_LINESTRING: + case MySqlParser.KW_MULTILINESTRING: + case MySqlParser.KW_MULTIPOINT: + case MySqlParser.KW_MULTIPOLYGON: + case MySqlParser.KW_POINT: + case MySqlParser.KW_POLYGON: + case MySqlParser.KW_CATALOG_NAME: + case MySqlParser.KW_CHARSET: + case MySqlParser.KW_COLLATION: + case MySqlParser.KW_ENGINE_ATTRIBUTE: + case MySqlParser.KW_FORMAT: + case MySqlParser.KW_GET_FORMAT: + case MySqlParser.KW_RANDOM: + case MySqlParser.KW_REVERSE: + case MySqlParser.KW_ROW_COUNT: + case MySqlParser.KW_SCHEMA_NAME: + case MySqlParser.KW_SECONDARY_ENGINE_ATTRIBUTE: + case MySqlParser.KW_SRID: + case MySqlParser.KW_SYSTEM_USER: + case MySqlParser.KW_TP_CONNECTION_ADMIN: + case MySqlParser.KW_WEIGHT_STRING: + case MySqlParser.MOD: + case MySqlParser.CHARSET_REVERSE_QOUTE_STRING: + case MySqlParser.STRING_LITERAL: + case MySqlParser.ID: + { + this.state = 6473; + this.partitionNames(); + } + break; + case MySqlParser.KW_ALL: + { + this.state = 6474; + this.match(MySqlParser.KW_ALL); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + this.state = 6477; + this.match(MySqlParser.RR_BRACKET); + } + break; + } + this.state = 6481; + this.match(MySqlParser.KW_IN); + this.state = 6482; + this.databaseName(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + flushStatement() { + let localContext = new FlushStatementContext(this.context, this.state); + this.enterRule(localContext, 570, MySqlParser.RULE_flushStatement); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6484; + this.match(MySqlParser.KW_FLUSH); + this.state = 6486; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 115 || _la === 450) { + { + this.state = 6485; + this.tableActionOption(); + } + } + this.state = 6488; + this.flushOption(); + this.state = 6493; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 6489; + this.match(MySqlParser.COMMA); + this.state = 6490; + this.flushOption(); + } + } + this.state = 6495; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + killStatement() { + let localContext = new KillStatementContext(this.context, this.state); + this.enterRule(localContext, 572, MySqlParser.RULE_killStatement); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6496; + this.match(MySqlParser.KW_KILL); + this.state = 6498; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 932, this.context)) { + case 1: + { + this.state = 6497; + localContext._connectionFormat = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 349 || _la === 548)) { + localContext._connectionFormat = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + break; + } + this.state = 6500; + this.expression(0); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + loadIndexIntoCache() { + let localContext = new LoadIndexIntoCacheContext(this.context, this.state); + this.enterRule(localContext, 574, MySqlParser.RULE_loadIndexIntoCache); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6502; + this.match(MySqlParser.KW_LOAD); + this.state = 6503; + this.match(MySqlParser.KW_INDEX); + this.state = 6504; + this.match(MySqlParser.KW_INTO); + this.state = 6505; + this.match(MySqlParser.KW_CACHE); + this.state = 6506; + this.loadedTableIndexes(); + this.state = 6511; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 6507; + this.match(MySqlParser.COMMA); + this.state = 6508; + this.loadedTableIndexes(); + } + } + this.state = 6513; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + resetStatement() { + let localContext = new ResetStatementContext(this.context, this.state); + this.enterRule(localContext, 576, MySqlParser.RULE_resetStatement); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6514; + this.match(MySqlParser.KW_RESET); + this.state = 6515; + this.resetOption(); + this.state = 6520; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 6516; + this.match(MySqlParser.COMMA); + this.state = 6517; + this.resetOption(); + } + } + this.state = 6522; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + resetOption() { + let localContext = new ResetOptionContext(this.context, this.state); + this.enterRule(localContext, 578, MySqlParser.RULE_resetOption); + try { + this.state = 6528; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_MASTER: + this.enterOuterAlt(localContext, 1); + { + this.state = 6523; + this.match(MySqlParser.KW_MASTER); + } + break; + case MySqlParser.KW_REPLICA: + this.enterOuterAlt(localContext, 2); + { + this.state = 6524; + this.match(MySqlParser.KW_REPLICA); + } + break; + case MySqlParser.KW_QUERY: + this.enterOuterAlt(localContext, 3); + { + this.state = 6525; + this.match(MySqlParser.KW_QUERY); + this.state = 6526; + this.match(MySqlParser.KW_CACHE); + } + break; + case MySqlParser.KW_SLAVE: + this.enterOuterAlt(localContext, 4); + { + this.state = 6527; + this.match(MySqlParser.KW_SLAVE); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + resetPersist() { + let localContext = new ResetPersistContext(this.context, this.state); + this.enterRule(localContext, 580, MySqlParser.RULE_resetPersist); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6530; + this.match(MySqlParser.KW_RESET); + this.state = 6531; + this.match(MySqlParser.KW_PERSIST); + this.state = 6536; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 937, this.context)) { + case 1: + { + this.state = 6533; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 936, this.context)) { + case 1: + { + this.state = 6532; + this.ifExists(); + } + break; + } + this.state = 6535; + localContext._system_var_name = this.uid(); + } + break; + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + resetAllChannel() { + let localContext = new ResetAllChannelContext(this.context, this.state); + this.enterRule(localContext, 582, MySqlParser.RULE_resetAllChannel); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6538; + this.match(MySqlParser.KW_RESET); + this.state = 6539; + _la = this.tokenStream.LA(1); + if (!(_la === 563 || _la === 598)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 6541; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 7) { + { + this.state = 6540; + this.match(MySqlParser.KW_ALL); + } + } + this.state = 6544; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 65) { + { + this.state = 6543; + this.channelOption(); + } + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + reStartStatement() { + let localContext = new ReStartStatementContext(this.context, this.state); + this.enterRule(localContext, 584, MySqlParser.RULE_reStartStatement); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6546; + this.match(MySqlParser.KW_RESTART); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + shutdownStatement() { + let localContext = new ShutdownStatementContext(this.context, this.state); + this.enterRule(localContext, 586, MySqlParser.RULE_shutdownStatement); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6548; + this.match(MySqlParser.KW_SHUTDOWN); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + tableIndex() { + let localContext = new TableIndexContext(this.context, this.state); + this.enterRule(localContext, 588, MySqlParser.RULE_tableIndex); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6550; + this.tableName(); + this.state = 6556; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 82 || _la === 92) { + { + this.state = 6551; + localContext._indexFormat = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 82 || _la === 92)) { + localContext._indexFormat = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 6552; + this.match(MySqlParser.LR_BRACKET); + this.state = 6553; + this.indexNames(); + this.state = 6554; + this.match(MySqlParser.RR_BRACKET); + } + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + flushOption() { + let localContext = new FlushOptionContext(this.context, this.state); + this.enterRule(localContext, 590, MySqlParser.RULE_flushOption); + let _la; + try { + this.state = 6590; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 947, this.context)) { + case 1: + localContext = new SimpleFlushOptionContext(localContext); + this.enterOuterAlt(localContext, 1); + { + this.state = 6576; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_DES_KEY_FILE: + { + this.state = 6558; + this.match(MySqlParser.KW_DES_KEY_FILE); + } + break; + case MySqlParser.KW_HOSTS: + { + this.state = 6559; + this.match(MySqlParser.KW_HOSTS); + } + break; + case MySqlParser.KW_BINARY: + case MySqlParser.KW_ENGINE: + case MySqlParser.KW_ERROR: + case MySqlParser.KW_GENERAL: + case MySqlParser.KW_LOGS: + case MySqlParser.KW_RELAY: + case MySqlParser.KW_SLOW: + { + this.state = 6561; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 228 || ((((_la - 380)) & ~0x1F) === 0 && ((1 << (_la - 380)) & 1073741829) !== 0) || _la === 556 || _la === 599) { + { + this.state = 6560; + _la = this.tokenStream.LA(1); + if (!(_la === 228 || ((((_la - 380)) & ~0x1F) === 0 && ((1 << (_la - 380)) & 1073741829) !== 0) || _la === 556 || _la === 599)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + this.state = 6563; + this.match(MySqlParser.KW_LOGS); + } + break; + case MySqlParser.KW_OPTIMIZER_COSTS: + { + this.state = 6564; + this.match(MySqlParser.KW_OPTIMIZER_COSTS); + } + break; + case MySqlParser.KW_PRIVILEGES: + { + this.state = 6565; + this.match(MySqlParser.KW_PRIVILEGES); + } + break; + case MySqlParser.KW_QUERY: + { + this.state = 6566; + this.match(MySqlParser.KW_QUERY); + this.state = 6567; + this.match(MySqlParser.KW_CACHE); + } + break; + case MySqlParser.KW_STATUS: + { + this.state = 6568; + this.match(MySqlParser.KW_STATUS); + } + break; + case MySqlParser.KW_USER_RESOURCES: + { + this.state = 6569; + this.match(MySqlParser.KW_USER_RESOURCES); + } + break; + case MySqlParser.KW_TABLES: + { + this.state = 6570; + this.match(MySqlParser.KW_TABLES); + this.state = 6574; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 942, this.context)) { + case 1: + { + this.state = 6571; + this.match(MySqlParser.KW_WITH); + this.state = 6572; + this.match(MySqlParser.KW_READ); + this.state = 6573; + this.match(MySqlParser.KW_LOCK); + } + break; + } + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + break; + case 2: + localContext = new ChannelFlushOptionContext(localContext); + this.enterOuterAlt(localContext, 2); + { + this.state = 6578; + this.match(MySqlParser.KW_RELAY); + this.state = 6579; + this.match(MySqlParser.KW_LOGS); + this.state = 6581; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 65) { + { + this.state = 6580; + this.channelOption(); + } + } + } + break; + case 3: + localContext = new TableFlushOptionContext(localContext); + this.enterOuterAlt(localContext, 3); + { + this.state = 6583; + _la = this.tokenStream.LA(1); + if (!(_la === 173 || _la === 752)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 6585; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 945, this.context)) { + case 1: + { + this.state = 6584; + this.tableNames(); + } + break; + } + this.state = 6588; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 946, this.context)) { + case 1: + { + this.state = 6587; + this.flushTableOption(); + } + break; + } + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + flushTableOption() { + let localContext = new FlushTableOptionContext(this.context, this.state); + this.enterRule(localContext, 592, MySqlParser.RULE_flushTableOption); + try { + this.state = 6597; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_WITH: + this.enterOuterAlt(localContext, 1); + { + this.state = 6592; + this.match(MySqlParser.KW_WITH); + this.state = 6593; + this.match(MySqlParser.KW_READ); + this.state = 6594; + this.match(MySqlParser.KW_LOCK); + } + break; + case MySqlParser.KW_FOR: + this.enterOuterAlt(localContext, 2); + { + this.state = 6595; + this.match(MySqlParser.KW_FOR); + this.state = 6596; + this.match(MySqlParser.KW_EXPORT); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + loadedTableIndexes() { + let localContext = new LoadedTableIndexesContext(this.context, this.state); + this.enterRule(localContext, 594, MySqlParser.RULE_loadedTableIndexes); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6599; + this.tableName(); + this.state = 6607; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 130) { + { + this.state = 6600; + this.match(MySqlParser.KW_PARTITION); + this.state = 6601; + this.match(MySqlParser.LR_BRACKET); + this.state = 6604; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_ARRAY: + case MySqlParser.KW_ATTRIBUTE: + case MySqlParser.KW_BUCKETS: + case MySqlParser.KW_CONDITION: + case MySqlParser.KW_CURRENT: + case MySqlParser.KW_CURRENT_USER: + case MySqlParser.KW_DATABASE: + case MySqlParser.KW_DEFAULT: + case MySqlParser.KW_DIAGNOSTICS: + case MySqlParser.KW_EMPTY: + case MySqlParser.KW_ENFORCED: + case MySqlParser.KW_EXCEPT: + case MySqlParser.KW_GROUP: + case MySqlParser.KW_IF: + case MySqlParser.KW_INSERT: + case MySqlParser.KW_LATERAL: + case MySqlParser.KW_LEFT: + case MySqlParser.KW_NUMBER: + case MySqlParser.KW_OPTIONAL: + case MySqlParser.KW_ORDER: + case MySqlParser.KW_PRIMARY: + case MySqlParser.KW_REPEAT: + case MySqlParser.KW_REPLACE: + case MySqlParser.KW_RIGHT: + case MySqlParser.KW_SCHEMA: + case MySqlParser.KW_SKIP_QUERY_REWRITE: + case MySqlParser.KW_STACKED: + case MySqlParser.KW_DATE: + case MySqlParser.KW_TIME: + case MySqlParser.KW_TIMESTAMP: + case MySqlParser.KW_DATETIME: + case MySqlParser.KW_YEAR: + case MySqlParser.KW_BINARY: + case MySqlParser.KW_TEXT: + case MySqlParser.KW_ENUM: + case MySqlParser.KW_SERIAL: + case MySqlParser.KW_JSON_TABLE: + case MySqlParser.KW_JSON_VALUE: + case MySqlParser.KW_NESTED: + case MySqlParser.KW_ORDINALITY: + case MySqlParser.KW_PATH: + case MySqlParser.KW_AVG: + case MySqlParser.KW_BIT_AND: + case MySqlParser.KW_BIT_OR: + case MySqlParser.KW_BIT_XOR: + case MySqlParser.KW_COUNT: + case MySqlParser.KW_CUME_DIST: + case MySqlParser.KW_DENSE_RANK: + case MySqlParser.KW_FIRST_VALUE: + case MySqlParser.KW_GROUP_CONCAT: + case MySqlParser.KW_LAG: + case MySqlParser.KW_LAST_VALUE: + case MySqlParser.KW_LEAD: + case MySqlParser.KW_MAX: + case MySqlParser.KW_MIN: + case MySqlParser.KW_NTILE: + case MySqlParser.KW_NTH_VALUE: + case MySqlParser.KW_PERCENT_RANK: + case MySqlParser.KW_RANK: + case MySqlParser.KW_ROW_NUMBER: + case MySqlParser.KW_STD: + case MySqlParser.KW_STDDEV: + case MySqlParser.KW_STDDEV_POP: + case MySqlParser.KW_STDDEV_SAMP: + case MySqlParser.KW_SUM: + case MySqlParser.KW_VAR_POP: + case MySqlParser.KW_VAR_SAMP: + case MySqlParser.KW_VARIANCE: + case MySqlParser.KW_CURRENT_DATE: + case MySqlParser.KW_CURRENT_TIME: + case MySqlParser.KW_CURRENT_TIMESTAMP: + case MySqlParser.KW_LOCALTIME: + case MySqlParser.KW_CURDATE: + case MySqlParser.KW_CURTIME: + case MySqlParser.KW_DATE_ADD: + case MySqlParser.KW_DATE_SUB: + case MySqlParser.KW_LOCALTIMESTAMP: + case MySqlParser.KW_NOW: + case MySqlParser.KW_POSITION: + case MySqlParser.KW_SUBSTR: + case MySqlParser.KW_SUBSTRING: + case MySqlParser.KW_SYSDATE: + case MySqlParser.KW_TRIM: + case MySqlParser.KW_UTC_DATE: + case MySqlParser.KW_UTC_TIME: + case MySqlParser.KW_UTC_TIMESTAMP: + case MySqlParser.KW_ACCOUNT: + case MySqlParser.KW_ACTION: + case MySqlParser.KW_AFTER: + case MySqlParser.KW_AGGREGATE: + case MySqlParser.KW_ALGORITHM: + case MySqlParser.KW_ANY: + case MySqlParser.KW_AT: + case MySqlParser.KW_AUTHORS: + case MySqlParser.KW_AUTOCOMMIT: + case MySqlParser.KW_AUTOEXTEND_SIZE: + case MySqlParser.KW_AUTO_INCREMENT: + case MySqlParser.KW_AVG_ROW_LENGTH: + case MySqlParser.KW_BEGIN: + case MySqlParser.KW_BINLOG: + case MySqlParser.KW_BIT: + case MySqlParser.KW_BLOCK: + case MySqlParser.KW_BOOL: + case MySqlParser.KW_BOOLEAN: + case MySqlParser.KW_BTREE: + case MySqlParser.KW_CACHE: + case MySqlParser.KW_CASCADED: + case MySqlParser.KW_CHAIN: + case MySqlParser.KW_CHANGED: + case MySqlParser.KW_CHANNEL: + case MySqlParser.KW_CHECKSUM: + case MySqlParser.KW_CIPHER: + case MySqlParser.KW_CLASS_ORIGIN: + case MySqlParser.KW_CLIENT: + case MySqlParser.KW_CLOSE: + case MySqlParser.KW_COALESCE: + case MySqlParser.KW_CODE: + case MySqlParser.KW_COLUMNS: + case MySqlParser.KW_COLUMN_FORMAT: + case MySqlParser.KW_COLUMN_NAME: + case MySqlParser.KW_COMMENT: + case MySqlParser.KW_COMMIT: + case MySqlParser.KW_COMPACT: + case MySqlParser.KW_COMPLETION: + case MySqlParser.KW_COMPRESSED: + case MySqlParser.KW_COMPRESSION: + case MySqlParser.KW_CONCURRENT: + case MySqlParser.KW_CONNECT: + case MySqlParser.KW_CONNECTION: + case MySqlParser.KW_CONSISTENT: + case MySqlParser.KW_CONSTRAINT_CATALOG: + case MySqlParser.KW_CONSTRAINT_SCHEMA: + case MySqlParser.KW_CONSTRAINT_NAME: + case MySqlParser.KW_CONTAINS: + case MySqlParser.KW_CONTEXT: + case MySqlParser.KW_CONTRIBUTORS: + case MySqlParser.KW_COPY: + case MySqlParser.KW_CPU: + case MySqlParser.KW_CURSOR_NAME: + case MySqlParser.KW_DATA: + case MySqlParser.KW_DATAFILE: + case MySqlParser.KW_DEALLOCATE: + case MySqlParser.KW_DEFAULT_AUTH: + case MySqlParser.KW_DEFINER: + case MySqlParser.KW_DELAY_KEY_WRITE: + case MySqlParser.KW_DES_KEY_FILE: + case MySqlParser.KW_DIRECTORY: + case MySqlParser.KW_DISABLE: + case MySqlParser.KW_DISCARD: + case MySqlParser.KW_DISK: + case MySqlParser.KW_DO: + case MySqlParser.KW_DUMPFILE: + case MySqlParser.KW_DUPLICATE: + case MySqlParser.KW_DYNAMIC: + case MySqlParser.KW_ENABLE: + case MySqlParser.KW_ENCRYPTION: + case MySqlParser.KW_END: + case MySqlParser.KW_ENDS: + case MySqlParser.KW_ENGINE: + case MySqlParser.KW_ENGINES: + case MySqlParser.KW_ERROR: + case MySqlParser.KW_ERRORS: + case MySqlParser.KW_ESCAPE: + case MySqlParser.KW_EVENT: + case MySqlParser.KW_EVENTS: + case MySqlParser.KW_EVERY: + case MySqlParser.KW_EXCHANGE: + case MySqlParser.KW_EXCLUSIVE: + case MySqlParser.KW_EXPIRE: + case MySqlParser.KW_EXPORT: + case MySqlParser.KW_EXTENDED: + case MySqlParser.KW_EXTENT_SIZE: + case MySqlParser.KW_FAILED_LOGIN_ATTEMPTS: + case MySqlParser.KW_FAST: + case MySqlParser.KW_FAULTS: + case MySqlParser.KW_FIELDS: + case MySqlParser.KW_FILE_BLOCK_SIZE: + case MySqlParser.KW_FILTER: + case MySqlParser.KW_FIRST: + case MySqlParser.KW_FIXED: + case MySqlParser.KW_FLUSH: + case MySqlParser.KW_FOLLOWS: + case MySqlParser.KW_FOUND: + case MySqlParser.KW_FULL: + case MySqlParser.KW_FUNCTION: + case MySqlParser.KW_GENERAL: + case MySqlParser.KW_GLOBAL: + case MySqlParser.KW_GRANTS: + case MySqlParser.KW_GROUP_REPLICATION: + case MySqlParser.KW_HANDLER: + case MySqlParser.KW_HASH: + case MySqlParser.KW_HELP: + case MySqlParser.KW_HISTORY: + case MySqlParser.KW_HOST: + case MySqlParser.KW_HOSTS: + case MySqlParser.KW_IDENTIFIED: + case MySqlParser.KW_IGNORE_SERVER_IDS: + case MySqlParser.KW_IMPORT: + case MySqlParser.KW_INDEXES: + case MySqlParser.KW_INITIAL_SIZE: + case MySqlParser.KW_INPLACE: + case MySqlParser.KW_INSERT_METHOD: + case MySqlParser.KW_INSTALL: + case MySqlParser.KW_INSTANCE: + case MySqlParser.KW_INSTANT: + case MySqlParser.KW_INVISIBLE: + case MySqlParser.KW_INVOKER: + case MySqlParser.KW_IO: + case MySqlParser.KW_IO_THREAD: + case MySqlParser.KW_IPC: + case MySqlParser.KW_ISOLATION: + case MySqlParser.KW_ISSUER: + case MySqlParser.KW_JSON: + case MySqlParser.KW_KEY_BLOCK_SIZE: + case MySqlParser.KW_LANGUAGE: + case MySqlParser.KW_LAST: + case MySqlParser.KW_LEAVES: + case MySqlParser.KW_LESS: + case MySqlParser.KW_LEVEL: + case MySqlParser.KW_LIST: + case MySqlParser.KW_LOCAL: + case MySqlParser.KW_LOGFILE: + case MySqlParser.KW_LOGS: + case MySqlParser.KW_MASTER: + case MySqlParser.KW_MASTER_AUTO_POSITION: + case MySqlParser.KW_MASTER_CONNECT_RETRY: + case MySqlParser.KW_MASTER_DELAY: + case MySqlParser.KW_MASTER_HEARTBEAT_PERIOD: + case MySqlParser.KW_MASTER_HOST: + case MySqlParser.KW_MASTER_LOG_FILE: + case MySqlParser.KW_MASTER_LOG_POS: + case MySqlParser.KW_MASTER_PASSWORD: + case MySqlParser.KW_MASTER_PORT: + case MySqlParser.KW_MASTER_RETRY_COUNT: + case MySqlParser.KW_MASTER_SSL: + case MySqlParser.KW_MASTER_SSL_CA: + case MySqlParser.KW_MASTER_SSL_CAPATH: + case MySqlParser.KW_MASTER_SSL_CERT: + case MySqlParser.KW_MASTER_SSL_CIPHER: + case MySqlParser.KW_MASTER_SSL_CRL: + case MySqlParser.KW_MASTER_SSL_CRLPATH: + case MySqlParser.KW_MASTER_SSL_KEY: + case MySqlParser.KW_MASTER_TLS_VERSION: + case MySqlParser.KW_MASTER_USER: + case MySqlParser.KW_MAX_CONNECTIONS_PER_HOUR: + case MySqlParser.KW_MAX_QUERIES_PER_HOUR: + case MySqlParser.KW_MAX_ROWS: + case MySqlParser.KW_MAX_SIZE: + case MySqlParser.KW_MAX_UPDATES_PER_HOUR: + case MySqlParser.KW_MAX_USER_CONNECTIONS: + case MySqlParser.KW_MEDIUM: + case MySqlParser.KW_MEMBER: + case MySqlParser.KW_MERGE: + case MySqlParser.KW_MESSAGE_TEXT: + case MySqlParser.KW_MID: + case MySqlParser.KW_MIGRATE: + case MySqlParser.KW_MIN_ROWS: + case MySqlParser.KW_MODE: + case MySqlParser.KW_MODIFY: + case MySqlParser.KW_MUTEX: + case MySqlParser.KW_MYSQL: + case MySqlParser.KW_MYSQL_ERRNO: + case MySqlParser.KW_NAME: + case MySqlParser.KW_NAMES: + case MySqlParser.KW_NCHAR: + case MySqlParser.KW_NEVER: + case MySqlParser.KW_NEXT: + case MySqlParser.KW_NO: + case MySqlParser.KW_NOWAIT: + case MySqlParser.KW_NODEGROUP: + case MySqlParser.KW_NONE: + case MySqlParser.KW_ODBC: + case MySqlParser.KW_OFFLINE: + case MySqlParser.KW_OFFSET: + case MySqlParser.KW_OF: + case MySqlParser.KW_OLD_PASSWORD: + case MySqlParser.KW_ONE: + case MySqlParser.KW_ONLINE: + case MySqlParser.KW_ONLY: + case MySqlParser.KW_OPEN: + case MySqlParser.KW_OPTIMIZER_COSTS: + case MySqlParser.KW_OPTIONS: + case MySqlParser.KW_OWNER: + case MySqlParser.KW_PACK_KEYS: + case MySqlParser.KW_PAGE: + case MySqlParser.KW_PAGE_CHECKSUM: + case MySqlParser.KW_PARSER: + case MySqlParser.KW_PARTIAL: + case MySqlParser.KW_PARTITIONING: + case MySqlParser.KW_PARTITIONS: + case MySqlParser.KW_PASSWORD: + case MySqlParser.KW_PASSWORD_LOCK_TIME: + case MySqlParser.KW_PHASE: + case MySqlParser.KW_PLUGIN: + case MySqlParser.KW_PLUGIN_DIR: + case MySqlParser.KW_PLUGINS: + case MySqlParser.KW_PORT: + case MySqlParser.KW_PRECEDES: + case MySqlParser.KW_PREPARE: + case MySqlParser.KW_PRESERVE: + case MySqlParser.KW_PREV: + case MySqlParser.KW_PROCESSLIST: + case MySqlParser.KW_PROFILE: + case MySqlParser.KW_PROFILES: + case MySqlParser.KW_PROXY: + case MySqlParser.KW_QUERY: + case MySqlParser.KW_QUICK: + case MySqlParser.KW_REBUILD: + case MySqlParser.KW_RECOVER: + case MySqlParser.KW_RECURSIVE: + case MySqlParser.KW_REDO_BUFFER_SIZE: + case MySqlParser.KW_REDUNDANT: + case MySqlParser.KW_RELAY: + case MySqlParser.KW_RELAY_LOG_FILE: + case MySqlParser.KW_RELAY_LOG_POS: + case MySqlParser.KW_RELAYLOG: + case MySqlParser.KW_REMOVE: + case MySqlParser.KW_REORGANIZE: + case MySqlParser.KW_REPAIR: + case MySqlParser.KW_REPLICATE_DO_DB: + case MySqlParser.KW_REPLICATE_DO_TABLE: + case MySqlParser.KW_REPLICATE_IGNORE_DB: + case MySqlParser.KW_REPLICATE_IGNORE_TABLE: + case MySqlParser.KW_REPLICATE_REWRITE_DB: + case MySqlParser.KW_REPLICATE_WILD_DO_TABLE: + case MySqlParser.KW_REPLICATE_WILD_IGNORE_TABLE: + case MySqlParser.KW_REPLICATION: + case MySqlParser.KW_RESET: + case MySqlParser.KW_RESUME: + case MySqlParser.KW_RETURNED_SQLSTATE: + case MySqlParser.KW_RETURNS: + case MySqlParser.KW_REUSE: + case MySqlParser.KW_ROLE: + case MySqlParser.KW_ROLLBACK: + case MySqlParser.KW_ROLLUP: + case MySqlParser.KW_ROTATE: + case MySqlParser.KW_ROW: + case MySqlParser.KW_ROWS: + case MySqlParser.KW_ROW_FORMAT: + case MySqlParser.KW_SAVEPOINT: + case MySqlParser.KW_SCHEDULE: + case MySqlParser.KW_SECURITY: + case MySqlParser.KW_SERVER: + case MySqlParser.KW_SESSION: + case MySqlParser.KW_SHARE: + case MySqlParser.KW_SHARED: + case MySqlParser.KW_SIGNED: + case MySqlParser.KW_SIMPLE: + case MySqlParser.KW_SLAVE: + case MySqlParser.KW_SLOW: + case MySqlParser.KW_SNAPSHOT: + case MySqlParser.KW_SOCKET: + case MySqlParser.KW_SOME: + case MySqlParser.KW_SONAME: + case MySqlParser.KW_SOUNDS: + case MySqlParser.KW_SOURCE: + case MySqlParser.KW_SQL_AFTER_GTIDS: + case MySqlParser.KW_SQL_AFTER_MTS_GAPS: + case MySqlParser.KW_SQL_BEFORE_GTIDS: + case MySqlParser.KW_SQL_BUFFER_RESULT: + case MySqlParser.KW_SQL_CACHE: + case MySqlParser.KW_SQL_NO_CACHE: + case MySqlParser.KW_SQL_THREAD: + case MySqlParser.KW_START: + case MySqlParser.KW_STARTS: + case MySqlParser.KW_STATS_AUTO_RECALC: + case MySqlParser.KW_STATS_PERSISTENT: + case MySqlParser.KW_STATS_SAMPLE_PAGES: + case MySqlParser.KW_STATUS: + case MySqlParser.KW_STOP: + case MySqlParser.KW_STORAGE: + case MySqlParser.KW_STRING: + case MySqlParser.KW_SUBCLASS_ORIGIN: + case MySqlParser.KW_SUBJECT: + case MySqlParser.KW_SUBPARTITION: + case MySqlParser.KW_SUBPARTITIONS: + case MySqlParser.KW_SUSPEND: + case MySqlParser.KW_SWAPS: + case MySqlParser.KW_SWITCHES: + case MySqlParser.KW_TABLE_NAME: + case MySqlParser.KW_TABLESPACE: + case MySqlParser.KW_TABLE_TYPE: + case MySqlParser.KW_TEMPORARY: + case MySqlParser.KW_TEMPTABLE: + case MySqlParser.KW_THAN: + case MySqlParser.KW_TRADITIONAL: + case MySqlParser.KW_TRANSACTION: + case MySqlParser.KW_TRANSACTIONAL: + case MySqlParser.KW_TRIGGERS: + case MySqlParser.KW_TRUNCATE: + case MySqlParser.KW_UNBOUNDED: + case MySqlParser.KW_UNDEFINED: + case MySqlParser.KW_UNDOFILE: + case MySqlParser.KW_UNDO_BUFFER_SIZE: + case MySqlParser.KW_UNINSTALL: + case MySqlParser.KW_UNKNOWN: + case MySqlParser.KW_UNTIL: + case MySqlParser.KW_UPGRADE: + case MySqlParser.KW_USER: + case MySqlParser.KW_USE_FRM: + case MySqlParser.KW_USER_RESOURCES: + case MySqlParser.KW_VALIDATION: + case MySqlParser.KW_VALUE: + case MySqlParser.KW_VARIABLES: + case MySqlParser.KW_VIEW: + case MySqlParser.KW_VIRTUAL: + case MySqlParser.KW_VISIBLE: + case MySqlParser.KW_WAIT: + case MySqlParser.KW_WARNINGS: + case MySqlParser.KW_WITHOUT: + case MySqlParser.KW_WORK: + case MySqlParser.KW_WRAPPER: + case MySqlParser.KW_X509: + case MySqlParser.KW_XA: + case MySqlParser.KW_XML: + case MySqlParser.KW_QUARTER: + case MySqlParser.KW_MONTH: + case MySqlParser.KW_DAY: + case MySqlParser.KW_HOUR: + case MySqlParser.KW_MINUTE: + case MySqlParser.KW_WEEK: + case MySqlParser.KW_SECOND: + case MySqlParser.KW_MICROSECOND: + case MySqlParser.KW_ADMIN: + case MySqlParser.KW_AUDIT_ABORT_EXEMPT: + case MySqlParser.KW_AUDIT_ADMIN: + case MySqlParser.KW_AUTHENTICATION_POLICY_ADMIN: + case MySqlParser.KW_BACKUP_ADMIN: + case MySqlParser.KW_BINLOG_ADMIN: + case MySqlParser.KW_BINLOG_ENCRYPTION_ADMIN: + case MySqlParser.KW_CLONE_ADMIN: + case MySqlParser.KW_CONNECTION_ADMIN: + case MySqlParser.KW_ENCRYPTION_KEY_ADMIN: + case MySqlParser.KW_EXECUTE: + case MySqlParser.KW_FILE: + case MySqlParser.KW_FIREWALL_ADMIN: + case MySqlParser.KW_FIREWALL_EXEMPT: + case MySqlParser.KW_FIREWALL_USER: + case MySqlParser.KW_GROUP_REPLICATION_ADMIN: + case MySqlParser.KW_INNODB_REDO_LOG_ARCHIVE: + case MySqlParser.KW_INVOKE: + case MySqlParser.KW_LAMBDA: + case MySqlParser.KW_NDB_STORED_USER: + case MySqlParser.KW_PASSWORDLESS_USER_ADMIN: + case MySqlParser.KW_PERSIST_RO_VARIABLES_ADMIN: + case MySqlParser.KW_PRIVILEGES: + case MySqlParser.KW_PROCESS: + case MySqlParser.KW_RELOAD: + case MySqlParser.KW_REPLICATION_APPLIER: + case MySqlParser.KW_REPLICATION_SLAVE_ADMIN: + case MySqlParser.KW_RESOURCE_GROUP_ADMIN: + case MySqlParser.KW_RESOURCE_GROUP_USER: + case MySqlParser.KW_ROLE_ADMIN: + case MySqlParser.KW_ROUTINE: + case MySqlParser.KW_S3: + case MySqlParser.KW_SESSION_VARIABLES_ADMIN: + case MySqlParser.KW_SET_USER_ID: + case MySqlParser.KW_SHOW_ROUTINE: + case MySqlParser.KW_SHUTDOWN: + case MySqlParser.KW_SUPER: + case MySqlParser.KW_SYSTEM_VARIABLES_ADMIN: + case MySqlParser.KW_TABLES: + case MySqlParser.KW_TABLE_ENCRYPTION_ADMIN: + case MySqlParser.KW_VERSION_TOKEN_ADMIN: + case MySqlParser.KW_XA_RECOVER_ADMIN: + case MySqlParser.KW_ARMSCII8: + case MySqlParser.KW_ASCII: + case MySqlParser.KW_BIG5: + case MySqlParser.KW_CP1250: + case MySqlParser.KW_CP1251: + case MySqlParser.KW_CP1256: + case MySqlParser.KW_CP1257: + case MySqlParser.KW_CP850: + case MySqlParser.KW_CP852: + case MySqlParser.KW_CP866: + case MySqlParser.KW_CP932: + case MySqlParser.KW_DEC8: + case MySqlParser.KW_EUCJPMS: + case MySqlParser.KW_EUCKR: + case MySqlParser.KW_GB18030: + case MySqlParser.KW_GB2312: + case MySqlParser.KW_GBK: + case MySqlParser.KW_GEOSTD8: + case MySqlParser.KW_GREEK: + case MySqlParser.KW_HEBREW: + case MySqlParser.KW_HP8: + case MySqlParser.KW_KEYBCS2: + case MySqlParser.KW_KOI8R: + case MySqlParser.KW_KOI8U: + case MySqlParser.KW_LATIN1: + case MySqlParser.KW_LATIN2: + case MySqlParser.KW_LATIN5: + case MySqlParser.KW_LATIN7: + case MySqlParser.KW_MACCE: + case MySqlParser.KW_MACROMAN: + case MySqlParser.KW_SJIS: + case MySqlParser.KW_SWE7: + case MySqlParser.KW_TIS620: + case MySqlParser.KW_UCS2: + case MySqlParser.KW_UJIS: + case MySqlParser.KW_UTF16: + case MySqlParser.KW_UTF16LE: + case MySqlParser.KW_UTF32: + case MySqlParser.KW_UTF8: + case MySqlParser.KW_UTF8MB3: + case MySqlParser.KW_UTF8MB4: + case MySqlParser.KW_ARCHIVE: + case MySqlParser.KW_BLACKHOLE: + case MySqlParser.KW_CSV: + case MySqlParser.KW_FEDERATED: + case MySqlParser.KW_INNODB: + case MySqlParser.KW_MEMORY: + case MySqlParser.KW_MRG_MYISAM: + case MySqlParser.KW_MYISAM: + case MySqlParser.KW_NDB: + case MySqlParser.KW_NDBCLUSTER: + case MySqlParser.KW_PERFORMANCE_SCHEMA: + case MySqlParser.KW_TOKUDB: + case MySqlParser.KW_REPEATABLE: + case MySqlParser.KW_COMMITTED: + case MySqlParser.KW_UNCOMMITTED: + case MySqlParser.KW_SERIALIZABLE: + case MySqlParser.KW_GEOMETRYCOLLECTION: + case MySqlParser.KW_LINESTRING: + case MySqlParser.KW_MULTILINESTRING: + case MySqlParser.KW_MULTIPOINT: + case MySqlParser.KW_MULTIPOLYGON: + case MySqlParser.KW_POINT: + case MySqlParser.KW_POLYGON: + case MySqlParser.KW_CATALOG_NAME: + case MySqlParser.KW_CHARSET: + case MySqlParser.KW_COLLATION: + case MySqlParser.KW_ENGINE_ATTRIBUTE: + case MySqlParser.KW_FORMAT: + case MySqlParser.KW_GET_FORMAT: + case MySqlParser.KW_RANDOM: + case MySqlParser.KW_REVERSE: + case MySqlParser.KW_ROW_COUNT: + case MySqlParser.KW_SCHEMA_NAME: + case MySqlParser.KW_SECONDARY_ENGINE_ATTRIBUTE: + case MySqlParser.KW_SRID: + case MySqlParser.KW_SYSTEM_USER: + case MySqlParser.KW_TP_CONNECTION_ADMIN: + case MySqlParser.KW_WEIGHT_STRING: + case MySqlParser.MOD: + case MySqlParser.CHARSET_REVERSE_QOUTE_STRING: + case MySqlParser.STRING_LITERAL: + case MySqlParser.ID: + { + this.state = 6602; + this.partitionNames(); + } + break; + case MySqlParser.KW_ALL: + { + this.state = 6603; + this.match(MySqlParser.KW_ALL); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + this.state = 6606; + this.match(MySqlParser.RR_BRACKET); + } + } + this.state = 6616; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 952, this.context)) { + case 1: + { + this.state = 6610; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 82 || _la === 92) { + { + this.state = 6609; + localContext._indexFormat = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 82 || _la === 92)) { + localContext._indexFormat = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + this.state = 6612; + this.match(MySqlParser.LR_BRACKET); + this.state = 6613; + this.indexNames(); + this.state = 6614; + this.match(MySqlParser.RR_BRACKET); + } + break; + } + this.state = 6620; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 79) { + { + this.state = 6618; + this.match(MySqlParser.KW_IGNORE); + this.state = 6619; + this.match(MySqlParser.KW_LEAVES); + } + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + simpleDescribeStatement() { + let localContext = new SimpleDescribeStatementContext(this.context, this.state); + this.enterRule(localContext, 596, MySqlParser.RULE_simpleDescribeStatement); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6622; + localContext._command = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(((((_la - 45)) & ~0x1F) === 0 && ((1 << (_la - 45)) & 131075) !== 0))) { + localContext._command = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 6623; + this.tableName(); + this.state = 6626; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 954, this.context)) { + case 1: + { + this.state = 6624; + localContext._column = this.columnName(); + } + break; + case 2: + { + this.state = 6625; + localContext._pattern = this.match(MySqlParser.STRING_LITERAL); + } + break; + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + fullDescribeStatement() { + let localContext = new FullDescribeStatementContext(this.context, this.state); + this.enterRule(localContext, 598, MySqlParser.RULE_fullDescribeStatement); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6628; + localContext._command = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(((((_la - 45)) & ~0x1F) === 0 && ((1 << (_la - 45)) & 131075) !== 0))) { + localContext._command = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 6634; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_EXTENDED: + { + this.state = 6629; + this.match(MySqlParser.KW_EXTENDED); + } + break; + case MySqlParser.KW_PARTITIONS: + { + this.state = 6630; + this.match(MySqlParser.KW_PARTITIONS); + } + break; + case MySqlParser.KW_FORMAT: + { + this.state = 6631; + this.match(MySqlParser.KW_FORMAT); + this.state = 6632; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 6633; + _la = this.tokenStream.LA(1); + if (!(_la === 442 || _la === 663 || _la === 666)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + break; + case MySqlParser.KW_DELETE: + case MySqlParser.KW_FOR: + case MySqlParser.KW_INSERT: + case MySqlParser.KW_REPLACE: + case MySqlParser.KW_SELECT: + case MySqlParser.KW_UPDATE: + case MySqlParser.LR_BRACKET: + break; + default: + break; + } + this.state = 6636; + this.describeObjectClause(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + analyzeDescribeStatement() { + let localContext = new AnalyzeDescribeStatementContext(this.context, this.state); + this.enterRule(localContext, 600, MySqlParser.RULE_analyzeDescribeStatement); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6638; + localContext._command = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(((((_la - 45)) & ~0x1F) === 0 && ((1 << (_la - 45)) & 131075) !== 0))) { + localContext._command = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 6639; + this.match(MySqlParser.KW_ANALYZE); + this.state = 6643; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 826) { + { + this.state = 6640; + this.match(MySqlParser.KW_FORMAT); + this.state = 6641; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 6642; + this.match(MySqlParser.KW_TREE); + } + } + this.state = 6645; + this.selectStatement(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + helpStatement() { + let localContext = new HelpStatementContext(this.context, this.state); + this.enterRule(localContext, 602, MySqlParser.RULE_helpStatement); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6647; + this.match(MySqlParser.KW_HELP); + this.state = 6648; + this.match(MySqlParser.STRING_LITERAL); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + useStatement() { + let localContext = new UseStatementContext(this.context, this.state); + this.enterRule(localContext, 604, MySqlParser.RULE_useStatement); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6650; + this.match(MySqlParser.KW_USE); + this.state = 6651; + this.databaseName(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + signalStatement() { + let localContext = new SignalStatementContext(this.context, this.state); + this.enterRule(localContext, 606, MySqlParser.RULE_signalStatement); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6653; + this.match(MySqlParser.KW_SIGNAL); + this.state = 6661; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_SQLSTATE: + { + { + this.state = 6654; + this.match(MySqlParser.KW_SQLSTATE); + this.state = 6656; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 682) { + { + this.state = 6655; + this.match(MySqlParser.KW_VALUE); + } + } + this.state = 6658; + this.stringLiteral(); + } + } + break; + case MySqlParser.ID: + { + this.state = 6659; + this.match(MySqlParser.ID); + } + break; + case MySqlParser.REVERSE_QUOTE_ID: + { + this.state = 6660; + this.match(MySqlParser.REVERSE_QUOTE_ID); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + this.state = 6672; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 960, this.context)) { + case 1: + { + this.state = 6663; + this.match(MySqlParser.KW_SET); + this.state = 6664; + this.signalConditionInformation(); + this.state = 6669; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 6665; + this.match(MySqlParser.COMMA); + this.state = 6666; + this.signalConditionInformation(); + } + } + this.state = 6671; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + break; + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + resignalStatement() { + let localContext = new ResignalStatementContext(this.context, this.state); + this.enterRule(localContext, 608, MySqlParser.RULE_resignalStatement); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6674; + this.match(MySqlParser.KW_RESIGNAL); + this.state = 6682; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_SQLSTATE: + { + { + this.state = 6675; + this.match(MySqlParser.KW_SQLSTATE); + this.state = 6677; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 682) { + { + this.state = 6676; + this.match(MySqlParser.KW_VALUE); + } + } + this.state = 6679; + this.stringLiteral(); + } + } + break; + case MySqlParser.ID: + { + this.state = 6680; + this.match(MySqlParser.ID); + } + break; + case MySqlParser.REVERSE_QUOTE_ID: + { + this.state = 6681; + this.match(MySqlParser.REVERSE_QUOTE_ID); + } + break; + case MySqlParser.EOF: + case MySqlParser.KW_ALTER: + case MySqlParser.KW_ANALYZE: + case MySqlParser.KW_CALL: + case MySqlParser.KW_CHANGE: + case MySqlParser.KW_CHECK: + case MySqlParser.KW_CREATE: + case MySqlParser.KW_DELETE: + case MySqlParser.KW_DESC: + case MySqlParser.KW_DESCRIBE: + case MySqlParser.KW_DROP: + case MySqlParser.KW_EXPLAIN: + case MySqlParser.KW_GET: + case MySqlParser.KW_GRANT: + case MySqlParser.KW_INSERT: + case MySqlParser.KW_KILL: + case MySqlParser.KW_LOAD: + case MySqlParser.KW_LOCK: + case MySqlParser.KW_OPTIMIZE: + case MySqlParser.KW_PURGE: + case MySqlParser.KW_RELEASE: + case MySqlParser.KW_RENAME: + case MySqlParser.KW_REPLACE: + case MySqlParser.KW_RESIGNAL: + case MySqlParser.KW_REVOKE: + case MySqlParser.KW_SELECT: + case MySqlParser.KW_SET: + case MySqlParser.KW_SHOW: + case MySqlParser.KW_SIGNAL: + case MySqlParser.KW_TABLE: + case MySqlParser.KW_UNLOCK: + case MySqlParser.KW_UPDATE: + case MySqlParser.KW_USE: + case MySqlParser.KW_VALUES: + case MySqlParser.KW_WITH: + case MySqlParser.KW_BEGIN: + case MySqlParser.KW_BINLOG: + case MySqlParser.KW_CACHE: + case MySqlParser.KW_CHECKSUM: + case MySqlParser.KW_COMMIT: + case MySqlParser.KW_DEALLOCATE: + case MySqlParser.KW_DO: + case MySqlParser.KW_FLUSH: + case MySqlParser.KW_HANDLER: + case MySqlParser.KW_HELP: + case MySqlParser.KW_IMPORT: + case MySqlParser.KW_INSTALL: + case MySqlParser.KW_PREPARE: + case MySqlParser.KW_REPAIR: + case MySqlParser.KW_RESET: + case MySqlParser.KW_RESTART: + case MySqlParser.KW_ROLLBACK: + case MySqlParser.KW_SAVEPOINT: + case MySqlParser.KW_START: + case MySqlParser.KW_STOP: + case MySqlParser.KW_TRUNCATE: + case MySqlParser.KW_UNINSTALL: + case MySqlParser.KW_XA: + case MySqlParser.KW_CLONE: + case MySqlParser.KW_EXECUTE: + case MySqlParser.KW_SHUTDOWN: + case MySqlParser.LR_BRACKET: + case MySqlParser.SEMI: + break; + default: + break; + } + this.state = 6693; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 964, this.context)) { + case 1: + { + this.state = 6684; + this.match(MySqlParser.KW_SET); + this.state = 6685; + this.signalConditionInformation(); + this.state = 6690; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 6686; + this.match(MySqlParser.COMMA); + this.state = 6687; + this.signalConditionInformation(); + } + } + this.state = 6692; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + break; + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + signalConditionInformation() { + let localContext = new SignalConditionInformationContext(this.context, this.state); + this.enterRule(localContext, 610, MySqlParser.RULE_signalConditionInformation); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6695; + _la = this.tokenStream.LA(1); + if (!(((((_la - 332)) & ~0x1F) === 0 && ((1 << (_la - 332)) & 137887873) !== 0) || _la === 487 || _la === 495 || _la === 650 || _la === 657 || _la === 822 || _la === 832)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 6696; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 6701; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.START_NATIONAL_STRING_LITERAL: + case MySqlParser.STRING_LITERAL: + case MySqlParser.STRING_CHARSET_NAME: + { + this.state = 6697; + this.stringLiteral(); + } + break; + case MySqlParser.DECIMAL_LITERAL: + { + this.state = 6698; + this.match(MySqlParser.DECIMAL_LITERAL); + } + break; + case MySqlParser.LOCAL_ID: + case MySqlParser.GLOBAL_ID: + { + this.state = 6699; + this.mysqlVariable(); + } + break; + case MySqlParser.KW_ARRAY: + case MySqlParser.KW_ATTRIBUTE: + case MySqlParser.KW_BUCKETS: + case MySqlParser.KW_CONDITION: + case MySqlParser.KW_CURRENT: + case MySqlParser.KW_CURRENT_USER: + case MySqlParser.KW_DATABASE: + case MySqlParser.KW_DEFAULT: + case MySqlParser.KW_DIAGNOSTICS: + case MySqlParser.KW_EMPTY: + case MySqlParser.KW_ENFORCED: + case MySqlParser.KW_EXCEPT: + case MySqlParser.KW_GROUP: + case MySqlParser.KW_IF: + case MySqlParser.KW_INSERT: + case MySqlParser.KW_LATERAL: + case MySqlParser.KW_LEFT: + case MySqlParser.KW_NUMBER: + case MySqlParser.KW_OPTIONAL: + case MySqlParser.KW_ORDER: + case MySqlParser.KW_PRIMARY: + case MySqlParser.KW_REPEAT: + case MySqlParser.KW_REPLACE: + case MySqlParser.KW_RIGHT: + case MySqlParser.KW_SCHEMA: + case MySqlParser.KW_SKIP_QUERY_REWRITE: + case MySqlParser.KW_STACKED: + case MySqlParser.KW_DATE: + case MySqlParser.KW_TIME: + case MySqlParser.KW_TIMESTAMP: + case MySqlParser.KW_DATETIME: + case MySqlParser.KW_YEAR: + case MySqlParser.KW_BINARY: + case MySqlParser.KW_TEXT: + case MySqlParser.KW_ENUM: + case MySqlParser.KW_SERIAL: + case MySqlParser.KW_JSON_TABLE: + case MySqlParser.KW_JSON_VALUE: + case MySqlParser.KW_NESTED: + case MySqlParser.KW_ORDINALITY: + case MySqlParser.KW_PATH: + case MySqlParser.KW_AVG: + case MySqlParser.KW_BIT_AND: + case MySqlParser.KW_BIT_OR: + case MySqlParser.KW_BIT_XOR: + case MySqlParser.KW_COUNT: + case MySqlParser.KW_CUME_DIST: + case MySqlParser.KW_DENSE_RANK: + case MySqlParser.KW_FIRST_VALUE: + case MySqlParser.KW_GROUP_CONCAT: + case MySqlParser.KW_LAG: + case MySqlParser.KW_LAST_VALUE: + case MySqlParser.KW_LEAD: + case MySqlParser.KW_MAX: + case MySqlParser.KW_MIN: + case MySqlParser.KW_NTILE: + case MySqlParser.KW_NTH_VALUE: + case MySqlParser.KW_PERCENT_RANK: + case MySqlParser.KW_RANK: + case MySqlParser.KW_ROW_NUMBER: + case MySqlParser.KW_STD: + case MySqlParser.KW_STDDEV: + case MySqlParser.KW_STDDEV_POP: + case MySqlParser.KW_STDDEV_SAMP: + case MySqlParser.KW_SUM: + case MySqlParser.KW_VAR_POP: + case MySqlParser.KW_VAR_SAMP: + case MySqlParser.KW_VARIANCE: + case MySqlParser.KW_CURRENT_DATE: + case MySqlParser.KW_CURRENT_TIME: + case MySqlParser.KW_CURRENT_TIMESTAMP: + case MySqlParser.KW_LOCALTIME: + case MySqlParser.KW_CURDATE: + case MySqlParser.KW_CURTIME: + case MySqlParser.KW_DATE_ADD: + case MySqlParser.KW_DATE_SUB: + case MySqlParser.KW_LOCALTIMESTAMP: + case MySqlParser.KW_NOW: + case MySqlParser.KW_POSITION: + case MySqlParser.KW_SUBSTR: + case MySqlParser.KW_SUBSTRING: + case MySqlParser.KW_SYSDATE: + case MySqlParser.KW_TRIM: + case MySqlParser.KW_UTC_DATE: + case MySqlParser.KW_UTC_TIME: + case MySqlParser.KW_UTC_TIMESTAMP: + case MySqlParser.KW_ACCOUNT: + case MySqlParser.KW_ACTION: + case MySqlParser.KW_AFTER: + case MySqlParser.KW_AGGREGATE: + case MySqlParser.KW_ALGORITHM: + case MySqlParser.KW_ANY: + case MySqlParser.KW_AT: + case MySqlParser.KW_AUTHORS: + case MySqlParser.KW_AUTOCOMMIT: + case MySqlParser.KW_AUTOEXTEND_SIZE: + case MySqlParser.KW_AUTO_INCREMENT: + case MySqlParser.KW_AVG_ROW_LENGTH: + case MySqlParser.KW_BEGIN: + case MySqlParser.KW_BINLOG: + case MySqlParser.KW_BIT: + case MySqlParser.KW_BLOCK: + case MySqlParser.KW_BOOL: + case MySqlParser.KW_BOOLEAN: + case MySqlParser.KW_BTREE: + case MySqlParser.KW_CACHE: + case MySqlParser.KW_CASCADED: + case MySqlParser.KW_CHAIN: + case MySqlParser.KW_CHANGED: + case MySqlParser.KW_CHANNEL: + case MySqlParser.KW_CHECKSUM: + case MySqlParser.KW_CIPHER: + case MySqlParser.KW_CLASS_ORIGIN: + case MySqlParser.KW_CLIENT: + case MySqlParser.KW_CLOSE: + case MySqlParser.KW_COALESCE: + case MySqlParser.KW_CODE: + case MySqlParser.KW_COLUMNS: + case MySqlParser.KW_COLUMN_FORMAT: + case MySqlParser.KW_COLUMN_NAME: + case MySqlParser.KW_COMMENT: + case MySqlParser.KW_COMMIT: + case MySqlParser.KW_COMPACT: + case MySqlParser.KW_COMPLETION: + case MySqlParser.KW_COMPRESSED: + case MySqlParser.KW_COMPRESSION: + case MySqlParser.KW_CONCURRENT: + case MySqlParser.KW_CONNECT: + case MySqlParser.KW_CONNECTION: + case MySqlParser.KW_CONSISTENT: + case MySqlParser.KW_CONSTRAINT_CATALOG: + case MySqlParser.KW_CONSTRAINT_SCHEMA: + case MySqlParser.KW_CONSTRAINT_NAME: + case MySqlParser.KW_CONTAINS: + case MySqlParser.KW_CONTEXT: + case MySqlParser.KW_CONTRIBUTORS: + case MySqlParser.KW_COPY: + case MySqlParser.KW_CPU: + case MySqlParser.KW_CURSOR_NAME: + case MySqlParser.KW_DATA: + case MySqlParser.KW_DATAFILE: + case MySqlParser.KW_DEALLOCATE: + case MySqlParser.KW_DEFAULT_AUTH: + case MySqlParser.KW_DEFINER: + case MySqlParser.KW_DELAY_KEY_WRITE: + case MySqlParser.KW_DES_KEY_FILE: + case MySqlParser.KW_DIRECTORY: + case MySqlParser.KW_DISABLE: + case MySqlParser.KW_DISCARD: + case MySqlParser.KW_DISK: + case MySqlParser.KW_DO: + case MySqlParser.KW_DUMPFILE: + case MySqlParser.KW_DUPLICATE: + case MySqlParser.KW_DYNAMIC: + case MySqlParser.KW_ENABLE: + case MySqlParser.KW_ENCRYPTION: + case MySqlParser.KW_END: + case MySqlParser.KW_ENDS: + case MySqlParser.KW_ENGINE: + case MySqlParser.KW_ENGINES: + case MySqlParser.KW_ERROR: + case MySqlParser.KW_ERRORS: + case MySqlParser.KW_ESCAPE: + case MySqlParser.KW_EVENT: + case MySqlParser.KW_EVENTS: + case MySqlParser.KW_EVERY: + case MySqlParser.KW_EXCHANGE: + case MySqlParser.KW_EXCLUSIVE: + case MySqlParser.KW_EXPIRE: + case MySqlParser.KW_EXPORT: + case MySqlParser.KW_EXTENDED: + case MySqlParser.KW_EXTENT_SIZE: + case MySqlParser.KW_FAILED_LOGIN_ATTEMPTS: + case MySqlParser.KW_FAST: + case MySqlParser.KW_FAULTS: + case MySqlParser.KW_FIELDS: + case MySqlParser.KW_FILE_BLOCK_SIZE: + case MySqlParser.KW_FILTER: + case MySqlParser.KW_FIRST: + case MySqlParser.KW_FIXED: + case MySqlParser.KW_FLUSH: + case MySqlParser.KW_FOLLOWS: + case MySqlParser.KW_FOUND: + case MySqlParser.KW_FULL: + case MySqlParser.KW_FUNCTION: + case MySqlParser.KW_GENERAL: + case MySqlParser.KW_GLOBAL: + case MySqlParser.KW_GRANTS: + case MySqlParser.KW_GROUP_REPLICATION: + case MySqlParser.KW_HANDLER: + case MySqlParser.KW_HASH: + case MySqlParser.KW_HELP: + case MySqlParser.KW_HISTORY: + case MySqlParser.KW_HOST: + case MySqlParser.KW_HOSTS: + case MySqlParser.KW_IDENTIFIED: + case MySqlParser.KW_IGNORE_SERVER_IDS: + case MySqlParser.KW_IMPORT: + case MySqlParser.KW_INDEXES: + case MySqlParser.KW_INITIAL_SIZE: + case MySqlParser.KW_INPLACE: + case MySqlParser.KW_INSERT_METHOD: + case MySqlParser.KW_INSTALL: + case MySqlParser.KW_INSTANCE: + case MySqlParser.KW_INSTANT: + case MySqlParser.KW_INVISIBLE: + case MySqlParser.KW_INVOKER: + case MySqlParser.KW_IO: + case MySqlParser.KW_IO_THREAD: + case MySqlParser.KW_IPC: + case MySqlParser.KW_ISOLATION: + case MySqlParser.KW_ISSUER: + case MySqlParser.KW_JSON: + case MySqlParser.KW_KEY_BLOCK_SIZE: + case MySqlParser.KW_LANGUAGE: + case MySqlParser.KW_LAST: + case MySqlParser.KW_LEAVES: + case MySqlParser.KW_LESS: + case MySqlParser.KW_LEVEL: + case MySqlParser.KW_LIST: + case MySqlParser.KW_LOCAL: + case MySqlParser.KW_LOGFILE: + case MySqlParser.KW_LOGS: + case MySqlParser.KW_MASTER: + case MySqlParser.KW_MASTER_AUTO_POSITION: + case MySqlParser.KW_MASTER_CONNECT_RETRY: + case MySqlParser.KW_MASTER_DELAY: + case MySqlParser.KW_MASTER_HEARTBEAT_PERIOD: + case MySqlParser.KW_MASTER_HOST: + case MySqlParser.KW_MASTER_LOG_FILE: + case MySqlParser.KW_MASTER_LOG_POS: + case MySqlParser.KW_MASTER_PASSWORD: + case MySqlParser.KW_MASTER_PORT: + case MySqlParser.KW_MASTER_RETRY_COUNT: + case MySqlParser.KW_MASTER_SSL: + case MySqlParser.KW_MASTER_SSL_CA: + case MySqlParser.KW_MASTER_SSL_CAPATH: + case MySqlParser.KW_MASTER_SSL_CERT: + case MySqlParser.KW_MASTER_SSL_CIPHER: + case MySqlParser.KW_MASTER_SSL_CRL: + case MySqlParser.KW_MASTER_SSL_CRLPATH: + case MySqlParser.KW_MASTER_SSL_KEY: + case MySqlParser.KW_MASTER_TLS_VERSION: + case MySqlParser.KW_MASTER_USER: + case MySqlParser.KW_MAX_CONNECTIONS_PER_HOUR: + case MySqlParser.KW_MAX_QUERIES_PER_HOUR: + case MySqlParser.KW_MAX_ROWS: + case MySqlParser.KW_MAX_SIZE: + case MySqlParser.KW_MAX_UPDATES_PER_HOUR: + case MySqlParser.KW_MAX_USER_CONNECTIONS: + case MySqlParser.KW_MEDIUM: + case MySqlParser.KW_MEMBER: + case MySqlParser.KW_MERGE: + case MySqlParser.KW_MESSAGE_TEXT: + case MySqlParser.KW_MID: + case MySqlParser.KW_MIGRATE: + case MySqlParser.KW_MIN_ROWS: + case MySqlParser.KW_MODE: + case MySqlParser.KW_MODIFY: + case MySqlParser.KW_MUTEX: + case MySqlParser.KW_MYSQL: + case MySqlParser.KW_MYSQL_ERRNO: + case MySqlParser.KW_NAME: + case MySqlParser.KW_NAMES: + case MySqlParser.KW_NCHAR: + case MySqlParser.KW_NEVER: + case MySqlParser.KW_NEXT: + case MySqlParser.KW_NO: + case MySqlParser.KW_NOWAIT: + case MySqlParser.KW_NODEGROUP: + case MySqlParser.KW_NONE: + case MySqlParser.KW_ODBC: + case MySqlParser.KW_OFFLINE: + case MySqlParser.KW_OFFSET: + case MySqlParser.KW_OF: + case MySqlParser.KW_OLD_PASSWORD: + case MySqlParser.KW_ONE: + case MySqlParser.KW_ONLINE: + case MySqlParser.KW_ONLY: + case MySqlParser.KW_OPEN: + case MySqlParser.KW_OPTIMIZER_COSTS: + case MySqlParser.KW_OPTIONS: + case MySqlParser.KW_OWNER: + case MySqlParser.KW_PACK_KEYS: + case MySqlParser.KW_PAGE: + case MySqlParser.KW_PAGE_CHECKSUM: + case MySqlParser.KW_PARSER: + case MySqlParser.KW_PARTIAL: + case MySqlParser.KW_PARTITIONING: + case MySqlParser.KW_PARTITIONS: + case MySqlParser.KW_PASSWORD: + case MySqlParser.KW_PASSWORD_LOCK_TIME: + case MySqlParser.KW_PHASE: + case MySqlParser.KW_PLUGIN: + case MySqlParser.KW_PLUGIN_DIR: + case MySqlParser.KW_PLUGINS: + case MySqlParser.KW_PORT: + case MySqlParser.KW_PRECEDES: + case MySqlParser.KW_PREPARE: + case MySqlParser.KW_PRESERVE: + case MySqlParser.KW_PREV: + case MySqlParser.KW_PROCESSLIST: + case MySqlParser.KW_PROFILE: + case MySqlParser.KW_PROFILES: + case MySqlParser.KW_PROXY: + case MySqlParser.KW_QUERY: + case MySqlParser.KW_QUICK: + case MySqlParser.KW_REBUILD: + case MySqlParser.KW_RECOVER: + case MySqlParser.KW_RECURSIVE: + case MySqlParser.KW_REDO_BUFFER_SIZE: + case MySqlParser.KW_REDUNDANT: + case MySqlParser.KW_RELAY: + case MySqlParser.KW_RELAY_LOG_FILE: + case MySqlParser.KW_RELAY_LOG_POS: + case MySqlParser.KW_RELAYLOG: + case MySqlParser.KW_REMOVE: + case MySqlParser.KW_REORGANIZE: + case MySqlParser.KW_REPAIR: + case MySqlParser.KW_REPLICATE_DO_DB: + case MySqlParser.KW_REPLICATE_DO_TABLE: + case MySqlParser.KW_REPLICATE_IGNORE_DB: + case MySqlParser.KW_REPLICATE_IGNORE_TABLE: + case MySqlParser.KW_REPLICATE_REWRITE_DB: + case MySqlParser.KW_REPLICATE_WILD_DO_TABLE: + case MySqlParser.KW_REPLICATE_WILD_IGNORE_TABLE: + case MySqlParser.KW_REPLICATION: + case MySqlParser.KW_RESET: + case MySqlParser.KW_RESUME: + case MySqlParser.KW_RETURNED_SQLSTATE: + case MySqlParser.KW_RETURNS: + case MySqlParser.KW_REUSE: + case MySqlParser.KW_ROLE: + case MySqlParser.KW_ROLLBACK: + case MySqlParser.KW_ROLLUP: + case MySqlParser.KW_ROTATE: + case MySqlParser.KW_ROW: + case MySqlParser.KW_ROWS: + case MySqlParser.KW_ROW_FORMAT: + case MySqlParser.KW_SAVEPOINT: + case MySqlParser.KW_SCHEDULE: + case MySqlParser.KW_SECURITY: + case MySqlParser.KW_SERVER: + case MySqlParser.KW_SESSION: + case MySqlParser.KW_SHARE: + case MySqlParser.KW_SHARED: + case MySqlParser.KW_SIGNED: + case MySqlParser.KW_SIMPLE: + case MySqlParser.KW_SLAVE: + case MySqlParser.KW_SLOW: + case MySqlParser.KW_SNAPSHOT: + case MySqlParser.KW_SOCKET: + case MySqlParser.KW_SOME: + case MySqlParser.KW_SONAME: + case MySqlParser.KW_SOUNDS: + case MySqlParser.KW_SOURCE: + case MySqlParser.KW_SQL_AFTER_GTIDS: + case MySqlParser.KW_SQL_AFTER_MTS_GAPS: + case MySqlParser.KW_SQL_BEFORE_GTIDS: + case MySqlParser.KW_SQL_BUFFER_RESULT: + case MySqlParser.KW_SQL_CACHE: + case MySqlParser.KW_SQL_NO_CACHE: + case MySqlParser.KW_SQL_THREAD: + case MySqlParser.KW_START: + case MySqlParser.KW_STARTS: + case MySqlParser.KW_STATS_AUTO_RECALC: + case MySqlParser.KW_STATS_PERSISTENT: + case MySqlParser.KW_STATS_SAMPLE_PAGES: + case MySqlParser.KW_STATUS: + case MySqlParser.KW_STOP: + case MySqlParser.KW_STORAGE: + case MySqlParser.KW_STRING: + case MySqlParser.KW_SUBCLASS_ORIGIN: + case MySqlParser.KW_SUBJECT: + case MySqlParser.KW_SUBPARTITION: + case MySqlParser.KW_SUBPARTITIONS: + case MySqlParser.KW_SUSPEND: + case MySqlParser.KW_SWAPS: + case MySqlParser.KW_SWITCHES: + case MySqlParser.KW_TABLE_NAME: + case MySqlParser.KW_TABLESPACE: + case MySqlParser.KW_TABLE_TYPE: + case MySqlParser.KW_TEMPORARY: + case MySqlParser.KW_TEMPTABLE: + case MySqlParser.KW_THAN: + case MySqlParser.KW_TRADITIONAL: + case MySqlParser.KW_TRANSACTION: + case MySqlParser.KW_TRANSACTIONAL: + case MySqlParser.KW_TRIGGERS: + case MySqlParser.KW_TRUNCATE: + case MySqlParser.KW_UNBOUNDED: + case MySqlParser.KW_UNDEFINED: + case MySqlParser.KW_UNDOFILE: + case MySqlParser.KW_UNDO_BUFFER_SIZE: + case MySqlParser.KW_UNINSTALL: + case MySqlParser.KW_UNKNOWN: + case MySqlParser.KW_UNTIL: + case MySqlParser.KW_UPGRADE: + case MySqlParser.KW_USER: + case MySqlParser.KW_USE_FRM: + case MySqlParser.KW_USER_RESOURCES: + case MySqlParser.KW_VALIDATION: + case MySqlParser.KW_VALUE: + case MySqlParser.KW_VARIABLES: + case MySqlParser.KW_VIEW: + case MySqlParser.KW_VIRTUAL: + case MySqlParser.KW_VISIBLE: + case MySqlParser.KW_WAIT: + case MySqlParser.KW_WARNINGS: + case MySqlParser.KW_WITHOUT: + case MySqlParser.KW_WORK: + case MySqlParser.KW_WRAPPER: + case MySqlParser.KW_X509: + case MySqlParser.KW_XA: + case MySqlParser.KW_XML: + case MySqlParser.KW_QUARTER: + case MySqlParser.KW_MONTH: + case MySqlParser.KW_DAY: + case MySqlParser.KW_HOUR: + case MySqlParser.KW_MINUTE: + case MySqlParser.KW_WEEK: + case MySqlParser.KW_SECOND: + case MySqlParser.KW_MICROSECOND: + case MySqlParser.KW_ADMIN: + case MySqlParser.KW_AUDIT_ABORT_EXEMPT: + case MySqlParser.KW_AUDIT_ADMIN: + case MySqlParser.KW_AUTHENTICATION_POLICY_ADMIN: + case MySqlParser.KW_BACKUP_ADMIN: + case MySqlParser.KW_BINLOG_ADMIN: + case MySqlParser.KW_BINLOG_ENCRYPTION_ADMIN: + case MySqlParser.KW_CLONE_ADMIN: + case MySqlParser.KW_CONNECTION_ADMIN: + case MySqlParser.KW_ENCRYPTION_KEY_ADMIN: + case MySqlParser.KW_EXECUTE: + case MySqlParser.KW_FILE: + case MySqlParser.KW_FIREWALL_ADMIN: + case MySqlParser.KW_FIREWALL_EXEMPT: + case MySqlParser.KW_FIREWALL_USER: + case MySqlParser.KW_GROUP_REPLICATION_ADMIN: + case MySqlParser.KW_INNODB_REDO_LOG_ARCHIVE: + case MySqlParser.KW_INVOKE: + case MySqlParser.KW_LAMBDA: + case MySqlParser.KW_NDB_STORED_USER: + case MySqlParser.KW_PASSWORDLESS_USER_ADMIN: + case MySqlParser.KW_PERSIST_RO_VARIABLES_ADMIN: + case MySqlParser.KW_PRIVILEGES: + case MySqlParser.KW_PROCESS: + case MySqlParser.KW_RELOAD: + case MySqlParser.KW_REPLICATION_APPLIER: + case MySqlParser.KW_REPLICATION_SLAVE_ADMIN: + case MySqlParser.KW_RESOURCE_GROUP_ADMIN: + case MySqlParser.KW_RESOURCE_GROUP_USER: + case MySqlParser.KW_ROLE_ADMIN: + case MySqlParser.KW_ROUTINE: + case MySqlParser.KW_S3: + case MySqlParser.KW_SESSION_VARIABLES_ADMIN: + case MySqlParser.KW_SET_USER_ID: + case MySqlParser.KW_SHOW_ROUTINE: + case MySqlParser.KW_SHUTDOWN: + case MySqlParser.KW_SUPER: + case MySqlParser.KW_SYSTEM_VARIABLES_ADMIN: + case MySqlParser.KW_TABLES: + case MySqlParser.KW_TABLE_ENCRYPTION_ADMIN: + case MySqlParser.KW_VERSION_TOKEN_ADMIN: + case MySqlParser.KW_XA_RECOVER_ADMIN: + case MySqlParser.KW_ARMSCII8: + case MySqlParser.KW_ASCII: + case MySqlParser.KW_BIG5: + case MySqlParser.KW_CP1250: + case MySqlParser.KW_CP1251: + case MySqlParser.KW_CP1256: + case MySqlParser.KW_CP1257: + case MySqlParser.KW_CP850: + case MySqlParser.KW_CP852: + case MySqlParser.KW_CP866: + case MySqlParser.KW_CP932: + case MySqlParser.KW_DEC8: + case MySqlParser.KW_EUCJPMS: + case MySqlParser.KW_EUCKR: + case MySqlParser.KW_GB18030: + case MySqlParser.KW_GB2312: + case MySqlParser.KW_GBK: + case MySqlParser.KW_GEOSTD8: + case MySqlParser.KW_GREEK: + case MySqlParser.KW_HEBREW: + case MySqlParser.KW_HP8: + case MySqlParser.KW_KEYBCS2: + case MySqlParser.KW_KOI8R: + case MySqlParser.KW_KOI8U: + case MySqlParser.KW_LATIN1: + case MySqlParser.KW_LATIN2: + case MySqlParser.KW_LATIN5: + case MySqlParser.KW_LATIN7: + case MySqlParser.KW_MACCE: + case MySqlParser.KW_MACROMAN: + case MySqlParser.KW_SJIS: + case MySqlParser.KW_SWE7: + case MySqlParser.KW_TIS620: + case MySqlParser.KW_UCS2: + case MySqlParser.KW_UJIS: + case MySqlParser.KW_UTF16: + case MySqlParser.KW_UTF16LE: + case MySqlParser.KW_UTF32: + case MySqlParser.KW_UTF8: + case MySqlParser.KW_UTF8MB3: + case MySqlParser.KW_UTF8MB4: + case MySqlParser.KW_ARCHIVE: + case MySqlParser.KW_BLACKHOLE: + case MySqlParser.KW_CSV: + case MySqlParser.KW_FEDERATED: + case MySqlParser.KW_INNODB: + case MySqlParser.KW_MEMORY: + case MySqlParser.KW_MRG_MYISAM: + case MySqlParser.KW_MYISAM: + case MySqlParser.KW_NDB: + case MySqlParser.KW_NDBCLUSTER: + case MySqlParser.KW_PERFORMANCE_SCHEMA: + case MySqlParser.KW_TOKUDB: + case MySqlParser.KW_REPEATABLE: + case MySqlParser.KW_COMMITTED: + case MySqlParser.KW_UNCOMMITTED: + case MySqlParser.KW_SERIALIZABLE: + case MySqlParser.KW_GEOMETRYCOLLECTION: + case MySqlParser.KW_LINESTRING: + case MySqlParser.KW_MULTILINESTRING: + case MySqlParser.KW_MULTIPOINT: + case MySqlParser.KW_MULTIPOLYGON: + case MySqlParser.KW_POINT: + case MySqlParser.KW_POLYGON: + case MySqlParser.KW_CATALOG_NAME: + case MySqlParser.KW_CHARSET: + case MySqlParser.KW_COLLATION: + case MySqlParser.KW_ENGINE_ATTRIBUTE: + case MySqlParser.KW_FORMAT: + case MySqlParser.KW_GET_FORMAT: + case MySqlParser.KW_RANDOM: + case MySqlParser.KW_REVERSE: + case MySqlParser.KW_ROW_COUNT: + case MySqlParser.KW_SCHEMA_NAME: + case MySqlParser.KW_SECONDARY_ENGINE_ATTRIBUTE: + case MySqlParser.KW_SRID: + case MySqlParser.KW_SYSTEM_USER: + case MySqlParser.KW_TP_CONNECTION_ADMIN: + case MySqlParser.KW_WEIGHT_STRING: + case MySqlParser.MOD: + case MySqlParser.ID: + { + this.state = 6700; + this.simpleId(); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + withStatement() { + let localContext = new WithStatementContext(this.context, this.state); + this.enterRule(localContext, 612, MySqlParser.RULE_withStatement); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6703; + this.match(MySqlParser.KW_WITH); + this.state = 6705; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 966, this.context)) { + case 1: + { + this.state = 6704; + this.match(MySqlParser.KW_RECURSIVE); + } + break; + } + this.state = 6707; + this.commonTableExpressions(); + this.state = 6712; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 6708; + this.match(MySqlParser.COMMA); + this.state = 6709; + this.commonTableExpressions(); + } + } + this.state = 6714; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + tableStatement() { + let localContext = new TableStatementContext(this.context, this.state); + this.enterRule(localContext, 614, MySqlParser.RULE_tableStatement); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6715; + this.match(MySqlParser.KW_TABLE); + this.state = 6716; + this.tableName(); + this.state = 6718; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 968, this.context)) { + case 1: + { + this.state = 6717; + this.orderByClause(); + } + break; + } + this.state = 6721; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 969, this.context)) { + case 1: + { + this.state = 6720; + this.limitClause(); + } + break; + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + diagnosticsStatement() { + let localContext = new DiagnosticsStatementContext(this.context, this.state); + this.enterRule(localContext, 616, MySqlParser.RULE_diagnosticsStatement); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6723; + this.match(MySqlParser.KW_GET); + this.state = 6725; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 36 || _la === 170) { + { + this.state = 6724; + _la = this.tokenStream.LA(1); + if (!(_la === 36 || _la === 170)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + this.state = 6727; + this.match(MySqlParser.KW_DIAGNOSTICS); + this.state = 6759; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 974, this.context)) { + case 1: + { + { + this.state = 6728; + this.variableClause(); + this.state = 6729; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 6730; + _la = this.tokenStream.LA(1); + if (!(_la === 117 || _la === 831)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 6738; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 6731; + this.match(MySqlParser.COMMA); + this.state = 6732; + this.variableClause(); + this.state = 6733; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 6734; + _la = this.tokenStream.LA(1); + if (!(_la === 117 || _la === 831)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + this.state = 6740; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + } + break; + case 2: + { + { + this.state = 6741; + this.match(MySqlParser.KW_CONDITION); + this.state = 6744; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.ZERO_DECIMAL: + case MySqlParser.ONE_DECIMAL: + case MySqlParser.TWO_DECIMAL: + case MySqlParser.THREE_DECIMAL: + case MySqlParser.DECIMAL_LITERAL: + case MySqlParser.REAL_LITERAL: + { + this.state = 6742; + this.decimalLiteral(); + } + break; + case MySqlParser.KW_ARRAY: + case MySqlParser.KW_ATTRIBUTE: + case MySqlParser.KW_BUCKETS: + case MySqlParser.KW_CONDITION: + case MySqlParser.KW_CURRENT: + case MySqlParser.KW_CURRENT_USER: + case MySqlParser.KW_DATABASE: + case MySqlParser.KW_DEFAULT: + case MySqlParser.KW_DIAGNOSTICS: + case MySqlParser.KW_EMPTY: + case MySqlParser.KW_ENFORCED: + case MySqlParser.KW_EXCEPT: + case MySqlParser.KW_GROUP: + case MySqlParser.KW_IF: + case MySqlParser.KW_INSERT: + case MySqlParser.KW_LATERAL: + case MySqlParser.KW_LEFT: + case MySqlParser.KW_NUMBER: + case MySqlParser.KW_OPTIONAL: + case MySqlParser.KW_ORDER: + case MySqlParser.KW_PRIMARY: + case MySqlParser.KW_REPEAT: + case MySqlParser.KW_REPLACE: + case MySqlParser.KW_RIGHT: + case MySqlParser.KW_SCHEMA: + case MySqlParser.KW_SKIP_QUERY_REWRITE: + case MySqlParser.KW_STACKED: + case MySqlParser.KW_DATE: + case MySqlParser.KW_TIME: + case MySqlParser.KW_TIMESTAMP: + case MySqlParser.KW_DATETIME: + case MySqlParser.KW_YEAR: + case MySqlParser.KW_BINARY: + case MySqlParser.KW_TEXT: + case MySqlParser.KW_ENUM: + case MySqlParser.KW_SERIAL: + case MySqlParser.KW_JSON_TABLE: + case MySqlParser.KW_JSON_VALUE: + case MySqlParser.KW_NESTED: + case MySqlParser.KW_ORDINALITY: + case MySqlParser.KW_PATH: + case MySqlParser.KW_AVG: + case MySqlParser.KW_BIT_AND: + case MySqlParser.KW_BIT_OR: + case MySqlParser.KW_BIT_XOR: + case MySqlParser.KW_COUNT: + case MySqlParser.KW_CUME_DIST: + case MySqlParser.KW_DENSE_RANK: + case MySqlParser.KW_FIRST_VALUE: + case MySqlParser.KW_GROUP_CONCAT: + case MySqlParser.KW_LAG: + case MySqlParser.KW_LAST_VALUE: + case MySqlParser.KW_LEAD: + case MySqlParser.KW_MAX: + case MySqlParser.KW_MIN: + case MySqlParser.KW_NTILE: + case MySqlParser.KW_NTH_VALUE: + case MySqlParser.KW_PERCENT_RANK: + case MySqlParser.KW_RANK: + case MySqlParser.KW_ROW_NUMBER: + case MySqlParser.KW_STD: + case MySqlParser.KW_STDDEV: + case MySqlParser.KW_STDDEV_POP: + case MySqlParser.KW_STDDEV_SAMP: + case MySqlParser.KW_SUM: + case MySqlParser.KW_VAR_POP: + case MySqlParser.KW_VAR_SAMP: + case MySqlParser.KW_VARIANCE: + case MySqlParser.KW_CURRENT_DATE: + case MySqlParser.KW_CURRENT_TIME: + case MySqlParser.KW_CURRENT_TIMESTAMP: + case MySqlParser.KW_LOCALTIME: + case MySqlParser.KW_CURDATE: + case MySqlParser.KW_CURTIME: + case MySqlParser.KW_DATE_ADD: + case MySqlParser.KW_DATE_SUB: + case MySqlParser.KW_LOCALTIMESTAMP: + case MySqlParser.KW_NOW: + case MySqlParser.KW_POSITION: + case MySqlParser.KW_SUBSTR: + case MySqlParser.KW_SUBSTRING: + case MySqlParser.KW_SYSDATE: + case MySqlParser.KW_TRIM: + case MySqlParser.KW_UTC_DATE: + case MySqlParser.KW_UTC_TIME: + case MySqlParser.KW_UTC_TIMESTAMP: + case MySqlParser.KW_ACCOUNT: + case MySqlParser.KW_ACTION: + case MySqlParser.KW_AFTER: + case MySqlParser.KW_AGGREGATE: + case MySqlParser.KW_ALGORITHM: + case MySqlParser.KW_ANY: + case MySqlParser.KW_AT: + case MySqlParser.KW_AUTHORS: + case MySqlParser.KW_AUTOCOMMIT: + case MySqlParser.KW_AUTOEXTEND_SIZE: + case MySqlParser.KW_AUTO_INCREMENT: + case MySqlParser.KW_AVG_ROW_LENGTH: + case MySqlParser.KW_BEGIN: + case MySqlParser.KW_BINLOG: + case MySqlParser.KW_BIT: + case MySqlParser.KW_BLOCK: + case MySqlParser.KW_BOOL: + case MySqlParser.KW_BOOLEAN: + case MySqlParser.KW_BTREE: + case MySqlParser.KW_CACHE: + case MySqlParser.KW_CASCADED: + case MySqlParser.KW_CHAIN: + case MySqlParser.KW_CHANGED: + case MySqlParser.KW_CHANNEL: + case MySqlParser.KW_CHECKSUM: + case MySqlParser.KW_CIPHER: + case MySqlParser.KW_CLASS_ORIGIN: + case MySqlParser.KW_CLIENT: + case MySqlParser.KW_CLOSE: + case MySqlParser.KW_COALESCE: + case MySqlParser.KW_CODE: + case MySqlParser.KW_COLUMNS: + case MySqlParser.KW_COLUMN_FORMAT: + case MySqlParser.KW_COLUMN_NAME: + case MySqlParser.KW_COMMENT: + case MySqlParser.KW_COMMIT: + case MySqlParser.KW_COMPACT: + case MySqlParser.KW_COMPLETION: + case MySqlParser.KW_COMPRESSED: + case MySqlParser.KW_COMPRESSION: + case MySqlParser.KW_CONCURRENT: + case MySqlParser.KW_CONNECT: + case MySqlParser.KW_CONNECTION: + case MySqlParser.KW_CONSISTENT: + case MySqlParser.KW_CONSTRAINT_CATALOG: + case MySqlParser.KW_CONSTRAINT_SCHEMA: + case MySqlParser.KW_CONSTRAINT_NAME: + case MySqlParser.KW_CONTAINS: + case MySqlParser.KW_CONTEXT: + case MySqlParser.KW_CONTRIBUTORS: + case MySqlParser.KW_COPY: + case MySqlParser.KW_CPU: + case MySqlParser.KW_CURSOR_NAME: + case MySqlParser.KW_DATA: + case MySqlParser.KW_DATAFILE: + case MySqlParser.KW_DEALLOCATE: + case MySqlParser.KW_DEFAULT_AUTH: + case MySqlParser.KW_DEFINER: + case MySqlParser.KW_DELAY_KEY_WRITE: + case MySqlParser.KW_DES_KEY_FILE: + case MySqlParser.KW_DIRECTORY: + case MySqlParser.KW_DISABLE: + case MySqlParser.KW_DISCARD: + case MySqlParser.KW_DISK: + case MySqlParser.KW_DO: + case MySqlParser.KW_DUMPFILE: + case MySqlParser.KW_DUPLICATE: + case MySqlParser.KW_DYNAMIC: + case MySqlParser.KW_ENABLE: + case MySqlParser.KW_ENCRYPTION: + case MySqlParser.KW_END: + case MySqlParser.KW_ENDS: + case MySqlParser.KW_ENGINE: + case MySqlParser.KW_ENGINES: + case MySqlParser.KW_ERROR: + case MySqlParser.KW_ERRORS: + case MySqlParser.KW_ESCAPE: + case MySqlParser.KW_EVENT: + case MySqlParser.KW_EVENTS: + case MySqlParser.KW_EVERY: + case MySqlParser.KW_EXCHANGE: + case MySqlParser.KW_EXCLUSIVE: + case MySqlParser.KW_EXPIRE: + case MySqlParser.KW_EXPORT: + case MySqlParser.KW_EXTENDED: + case MySqlParser.KW_EXTENT_SIZE: + case MySqlParser.KW_FAILED_LOGIN_ATTEMPTS: + case MySqlParser.KW_FAST: + case MySqlParser.KW_FAULTS: + case MySqlParser.KW_FIELDS: + case MySqlParser.KW_FILE_BLOCK_SIZE: + case MySqlParser.KW_FILTER: + case MySqlParser.KW_FIRST: + case MySqlParser.KW_FIXED: + case MySqlParser.KW_FLUSH: + case MySqlParser.KW_FOLLOWS: + case MySqlParser.KW_FOUND: + case MySqlParser.KW_FULL: + case MySqlParser.KW_FUNCTION: + case MySqlParser.KW_GENERAL: + case MySqlParser.KW_GLOBAL: + case MySqlParser.KW_GRANTS: + case MySqlParser.KW_GROUP_REPLICATION: + case MySqlParser.KW_HANDLER: + case MySqlParser.KW_HASH: + case MySqlParser.KW_HELP: + case MySqlParser.KW_HISTORY: + case MySqlParser.KW_HOST: + case MySqlParser.KW_HOSTS: + case MySqlParser.KW_IDENTIFIED: + case MySqlParser.KW_IGNORE_SERVER_IDS: + case MySqlParser.KW_IMPORT: + case MySqlParser.KW_INDEXES: + case MySqlParser.KW_INITIAL_SIZE: + case MySqlParser.KW_INPLACE: + case MySqlParser.KW_INSERT_METHOD: + case MySqlParser.KW_INSTALL: + case MySqlParser.KW_INSTANCE: + case MySqlParser.KW_INSTANT: + case MySqlParser.KW_INVISIBLE: + case MySqlParser.KW_INVOKER: + case MySqlParser.KW_IO: + case MySqlParser.KW_IO_THREAD: + case MySqlParser.KW_IPC: + case MySqlParser.KW_ISOLATION: + case MySqlParser.KW_ISSUER: + case MySqlParser.KW_JSON: + case MySqlParser.KW_KEY_BLOCK_SIZE: + case MySqlParser.KW_LANGUAGE: + case MySqlParser.KW_LAST: + case MySqlParser.KW_LEAVES: + case MySqlParser.KW_LESS: + case MySqlParser.KW_LEVEL: + case MySqlParser.KW_LIST: + case MySqlParser.KW_LOCAL: + case MySqlParser.KW_LOGFILE: + case MySqlParser.KW_LOGS: + case MySqlParser.KW_MASTER: + case MySqlParser.KW_MASTER_AUTO_POSITION: + case MySqlParser.KW_MASTER_CONNECT_RETRY: + case MySqlParser.KW_MASTER_DELAY: + case MySqlParser.KW_MASTER_HEARTBEAT_PERIOD: + case MySqlParser.KW_MASTER_HOST: + case MySqlParser.KW_MASTER_LOG_FILE: + case MySqlParser.KW_MASTER_LOG_POS: + case MySqlParser.KW_MASTER_PASSWORD: + case MySqlParser.KW_MASTER_PORT: + case MySqlParser.KW_MASTER_RETRY_COUNT: + case MySqlParser.KW_MASTER_SSL: + case MySqlParser.KW_MASTER_SSL_CA: + case MySqlParser.KW_MASTER_SSL_CAPATH: + case MySqlParser.KW_MASTER_SSL_CERT: + case MySqlParser.KW_MASTER_SSL_CIPHER: + case MySqlParser.KW_MASTER_SSL_CRL: + case MySqlParser.KW_MASTER_SSL_CRLPATH: + case MySqlParser.KW_MASTER_SSL_KEY: + case MySqlParser.KW_MASTER_TLS_VERSION: + case MySqlParser.KW_MASTER_USER: + case MySqlParser.KW_MAX_CONNECTIONS_PER_HOUR: + case MySqlParser.KW_MAX_QUERIES_PER_HOUR: + case MySqlParser.KW_MAX_ROWS: + case MySqlParser.KW_MAX_SIZE: + case MySqlParser.KW_MAX_UPDATES_PER_HOUR: + case MySqlParser.KW_MAX_USER_CONNECTIONS: + case MySqlParser.KW_MEDIUM: + case MySqlParser.KW_MEMBER: + case MySqlParser.KW_MERGE: + case MySqlParser.KW_MESSAGE_TEXT: + case MySqlParser.KW_MID: + case MySqlParser.KW_MIGRATE: + case MySqlParser.KW_MIN_ROWS: + case MySqlParser.KW_MODE: + case MySqlParser.KW_MODIFY: + case MySqlParser.KW_MUTEX: + case MySqlParser.KW_MYSQL: + case MySqlParser.KW_MYSQL_ERRNO: + case MySqlParser.KW_NAME: + case MySqlParser.KW_NAMES: + case MySqlParser.KW_NCHAR: + case MySqlParser.KW_NEVER: + case MySqlParser.KW_NEXT: + case MySqlParser.KW_NO: + case MySqlParser.KW_NOWAIT: + case MySqlParser.KW_NODEGROUP: + case MySqlParser.KW_NONE: + case MySqlParser.KW_ODBC: + case MySqlParser.KW_OFFLINE: + case MySqlParser.KW_OFFSET: + case MySqlParser.KW_OF: + case MySqlParser.KW_OLD_PASSWORD: + case MySqlParser.KW_ONE: + case MySqlParser.KW_ONLINE: + case MySqlParser.KW_ONLY: + case MySqlParser.KW_OPEN: + case MySqlParser.KW_OPTIMIZER_COSTS: + case MySqlParser.KW_OPTIONS: + case MySqlParser.KW_OWNER: + case MySqlParser.KW_PACK_KEYS: + case MySqlParser.KW_PAGE: + case MySqlParser.KW_PAGE_CHECKSUM: + case MySqlParser.KW_PARSER: + case MySqlParser.KW_PARTIAL: + case MySqlParser.KW_PARTITIONING: + case MySqlParser.KW_PARTITIONS: + case MySqlParser.KW_PASSWORD: + case MySqlParser.KW_PASSWORD_LOCK_TIME: + case MySqlParser.KW_PERSIST: + case MySqlParser.KW_PERSIST_ONLY: + case MySqlParser.KW_PHASE: + case MySqlParser.KW_PLUGIN: + case MySqlParser.KW_PLUGIN_DIR: + case MySqlParser.KW_PLUGINS: + case MySqlParser.KW_PORT: + case MySqlParser.KW_PRECEDES: + case MySqlParser.KW_PREPARE: + case MySqlParser.KW_PRESERVE: + case MySqlParser.KW_PREV: + case MySqlParser.KW_PROCESSLIST: + case MySqlParser.KW_PROFILE: + case MySqlParser.KW_PROFILES: + case MySqlParser.KW_PROXY: + case MySqlParser.KW_QUERY: + case MySqlParser.KW_QUICK: + case MySqlParser.KW_REBUILD: + case MySqlParser.KW_RECOVER: + case MySqlParser.KW_RECURSIVE: + case MySqlParser.KW_REDO_BUFFER_SIZE: + case MySqlParser.KW_REDUNDANT: + case MySqlParser.KW_RELAY: + case MySqlParser.KW_RELAY_LOG_FILE: + case MySqlParser.KW_RELAY_LOG_POS: + case MySqlParser.KW_RELAYLOG: + case MySqlParser.KW_REMOVE: + case MySqlParser.KW_REORGANIZE: + case MySqlParser.KW_REPAIR: + case MySqlParser.KW_REPLICATE_DO_DB: + case MySqlParser.KW_REPLICATE_DO_TABLE: + case MySqlParser.KW_REPLICATE_IGNORE_DB: + case MySqlParser.KW_REPLICATE_IGNORE_TABLE: + case MySqlParser.KW_REPLICATE_REWRITE_DB: + case MySqlParser.KW_REPLICATE_WILD_DO_TABLE: + case MySqlParser.KW_REPLICATE_WILD_IGNORE_TABLE: + case MySqlParser.KW_REPLICATION: + case MySqlParser.KW_RESET: + case MySqlParser.KW_RESUME: + case MySqlParser.KW_RETURNED_SQLSTATE: + case MySqlParser.KW_RETURNS: + case MySqlParser.KW_REUSE: + case MySqlParser.KW_ROLE: + case MySqlParser.KW_ROLLBACK: + case MySqlParser.KW_ROLLUP: + case MySqlParser.KW_ROTATE: + case MySqlParser.KW_ROW: + case MySqlParser.KW_ROWS: + case MySqlParser.KW_ROW_FORMAT: + case MySqlParser.KW_SAVEPOINT: + case MySqlParser.KW_SCHEDULE: + case MySqlParser.KW_SECURITY: + case MySqlParser.KW_SERVER: + case MySqlParser.KW_SESSION: + case MySqlParser.KW_SHARE: + case MySqlParser.KW_SHARED: + case MySqlParser.KW_SIGNED: + case MySqlParser.KW_SIMPLE: + case MySqlParser.KW_SLAVE: + case MySqlParser.KW_SLOW: + case MySqlParser.KW_SNAPSHOT: + case MySqlParser.KW_SOCKET: + case MySqlParser.KW_SOME: + case MySqlParser.KW_SONAME: + case MySqlParser.KW_SOUNDS: + case MySqlParser.KW_SOURCE: + case MySqlParser.KW_SQL_AFTER_GTIDS: + case MySqlParser.KW_SQL_AFTER_MTS_GAPS: + case MySqlParser.KW_SQL_BEFORE_GTIDS: + case MySqlParser.KW_SQL_BUFFER_RESULT: + case MySqlParser.KW_SQL_CACHE: + case MySqlParser.KW_SQL_NO_CACHE: + case MySqlParser.KW_SQL_THREAD: + case MySqlParser.KW_START: + case MySqlParser.KW_STARTS: + case MySqlParser.KW_STATS_AUTO_RECALC: + case MySqlParser.KW_STATS_PERSISTENT: + case MySqlParser.KW_STATS_SAMPLE_PAGES: + case MySqlParser.KW_STATUS: + case MySqlParser.KW_STOP: + case MySqlParser.KW_STORAGE: + case MySqlParser.KW_STRING: + case MySqlParser.KW_SUBCLASS_ORIGIN: + case MySqlParser.KW_SUBJECT: + case MySqlParser.KW_SUBPARTITION: + case MySqlParser.KW_SUBPARTITIONS: + case MySqlParser.KW_SUSPEND: + case MySqlParser.KW_SWAPS: + case MySqlParser.KW_SWITCHES: + case MySqlParser.KW_TABLE_NAME: + case MySqlParser.KW_TABLESPACE: + case MySqlParser.KW_TABLE_TYPE: + case MySqlParser.KW_TEMPORARY: + case MySqlParser.KW_TEMPTABLE: + case MySqlParser.KW_THAN: + case MySqlParser.KW_TRADITIONAL: + case MySqlParser.KW_TRANSACTION: + case MySqlParser.KW_TRANSACTIONAL: + case MySqlParser.KW_TRIGGERS: + case MySqlParser.KW_TRUNCATE: + case MySqlParser.KW_UNBOUNDED: + case MySqlParser.KW_UNDEFINED: + case MySqlParser.KW_UNDOFILE: + case MySqlParser.KW_UNDO_BUFFER_SIZE: + case MySqlParser.KW_UNINSTALL: + case MySqlParser.KW_UNKNOWN: + case MySqlParser.KW_UNTIL: + case MySqlParser.KW_UPGRADE: + case MySqlParser.KW_USER: + case MySqlParser.KW_USE_FRM: + case MySqlParser.KW_USER_RESOURCES: + case MySqlParser.KW_VALIDATION: + case MySqlParser.KW_VALUE: + case MySqlParser.KW_VARIABLES: + case MySqlParser.KW_VIEW: + case MySqlParser.KW_VIRTUAL: + case MySqlParser.KW_VISIBLE: + case MySqlParser.KW_WAIT: + case MySqlParser.KW_WARNINGS: + case MySqlParser.KW_WITHOUT: + case MySqlParser.KW_WORK: + case MySqlParser.KW_WRAPPER: + case MySqlParser.KW_X509: + case MySqlParser.KW_XA: + case MySqlParser.KW_XML: + case MySqlParser.KW_QUARTER: + case MySqlParser.KW_MONTH: + case MySqlParser.KW_DAY: + case MySqlParser.KW_HOUR: + case MySqlParser.KW_MINUTE: + case MySqlParser.KW_WEEK: + case MySqlParser.KW_SECOND: + case MySqlParser.KW_MICROSECOND: + case MySqlParser.KW_ADMIN: + case MySqlParser.KW_AUDIT_ABORT_EXEMPT: + case MySqlParser.KW_AUDIT_ADMIN: + case MySqlParser.KW_AUTHENTICATION_POLICY_ADMIN: + case MySqlParser.KW_BACKUP_ADMIN: + case MySqlParser.KW_BINLOG_ADMIN: + case MySqlParser.KW_BINLOG_ENCRYPTION_ADMIN: + case MySqlParser.KW_CLONE_ADMIN: + case MySqlParser.KW_CONNECTION_ADMIN: + case MySqlParser.KW_ENCRYPTION_KEY_ADMIN: + case MySqlParser.KW_EXECUTE: + case MySqlParser.KW_FILE: + case MySqlParser.KW_FIREWALL_ADMIN: + case MySqlParser.KW_FIREWALL_EXEMPT: + case MySqlParser.KW_FIREWALL_USER: + case MySqlParser.KW_GROUP_REPLICATION_ADMIN: + case MySqlParser.KW_INNODB_REDO_LOG_ARCHIVE: + case MySqlParser.KW_INVOKE: + case MySqlParser.KW_LAMBDA: + case MySqlParser.KW_NDB_STORED_USER: + case MySqlParser.KW_PASSWORDLESS_USER_ADMIN: + case MySqlParser.KW_PERSIST_RO_VARIABLES_ADMIN: + case MySqlParser.KW_PRIVILEGES: + case MySqlParser.KW_PROCESS: + case MySqlParser.KW_RELOAD: + case MySqlParser.KW_REPLICATION_APPLIER: + case MySqlParser.KW_REPLICATION_SLAVE_ADMIN: + case MySqlParser.KW_RESOURCE_GROUP_ADMIN: + case MySqlParser.KW_RESOURCE_GROUP_USER: + case MySqlParser.KW_ROLE_ADMIN: + case MySqlParser.KW_ROUTINE: + case MySqlParser.KW_S3: + case MySqlParser.KW_SESSION_VARIABLES_ADMIN: + case MySqlParser.KW_SET_USER_ID: + case MySqlParser.KW_SHOW_ROUTINE: + case MySqlParser.KW_SHUTDOWN: + case MySqlParser.KW_SUPER: + case MySqlParser.KW_SYSTEM_VARIABLES_ADMIN: + case MySqlParser.KW_TABLES: + case MySqlParser.KW_TABLE_ENCRYPTION_ADMIN: + case MySqlParser.KW_VERSION_TOKEN_ADMIN: + case MySqlParser.KW_XA_RECOVER_ADMIN: + case MySqlParser.KW_ARMSCII8: + case MySqlParser.KW_ASCII: + case MySqlParser.KW_BIG5: + case MySqlParser.KW_CP1250: + case MySqlParser.KW_CP1251: + case MySqlParser.KW_CP1256: + case MySqlParser.KW_CP1257: + case MySqlParser.KW_CP850: + case MySqlParser.KW_CP852: + case MySqlParser.KW_CP866: + case MySqlParser.KW_CP932: + case MySqlParser.KW_DEC8: + case MySqlParser.KW_EUCJPMS: + case MySqlParser.KW_EUCKR: + case MySqlParser.KW_GB18030: + case MySqlParser.KW_GB2312: + case MySqlParser.KW_GBK: + case MySqlParser.KW_GEOSTD8: + case MySqlParser.KW_GREEK: + case MySqlParser.KW_HEBREW: + case MySqlParser.KW_HP8: + case MySqlParser.KW_KEYBCS2: + case MySqlParser.KW_KOI8R: + case MySqlParser.KW_KOI8U: + case MySqlParser.KW_LATIN1: + case MySqlParser.KW_LATIN2: + case MySqlParser.KW_LATIN5: + case MySqlParser.KW_LATIN7: + case MySqlParser.KW_MACCE: + case MySqlParser.KW_MACROMAN: + case MySqlParser.KW_SJIS: + case MySqlParser.KW_SWE7: + case MySqlParser.KW_TIS620: + case MySqlParser.KW_UCS2: + case MySqlParser.KW_UJIS: + case MySqlParser.KW_UTF16: + case MySqlParser.KW_UTF16LE: + case MySqlParser.KW_UTF32: + case MySqlParser.KW_UTF8: + case MySqlParser.KW_UTF8MB3: + case MySqlParser.KW_UTF8MB4: + case MySqlParser.KW_ARCHIVE: + case MySqlParser.KW_BLACKHOLE: + case MySqlParser.KW_CSV: + case MySqlParser.KW_FEDERATED: + case MySqlParser.KW_INNODB: + case MySqlParser.KW_MEMORY: + case MySqlParser.KW_MRG_MYISAM: + case MySqlParser.KW_MYISAM: + case MySqlParser.KW_NDB: + case MySqlParser.KW_NDBCLUSTER: + case MySqlParser.KW_PERFORMANCE_SCHEMA: + case MySqlParser.KW_TOKUDB: + case MySqlParser.KW_REPEATABLE: + case MySqlParser.KW_COMMITTED: + case MySqlParser.KW_UNCOMMITTED: + case MySqlParser.KW_SERIALIZABLE: + case MySqlParser.KW_GEOMETRYCOLLECTION: + case MySqlParser.KW_LINESTRING: + case MySqlParser.KW_MULTILINESTRING: + case MySqlParser.KW_MULTIPOINT: + case MySqlParser.KW_MULTIPOLYGON: + case MySqlParser.KW_POINT: + case MySqlParser.KW_POLYGON: + case MySqlParser.KW_CATALOG_NAME: + case MySqlParser.KW_CHARSET: + case MySqlParser.KW_COLLATION: + case MySqlParser.KW_ENGINE_ATTRIBUTE: + case MySqlParser.KW_FORMAT: + case MySqlParser.KW_GET_FORMAT: + case MySqlParser.KW_RANDOM: + case MySqlParser.KW_REVERSE: + case MySqlParser.KW_ROW_COUNT: + case MySqlParser.KW_SCHEMA_NAME: + case MySqlParser.KW_SECONDARY_ENGINE_ATTRIBUTE: + case MySqlParser.KW_SRID: + case MySqlParser.KW_SYSTEM_USER: + case MySqlParser.KW_TP_CONNECTION_ADMIN: + case MySqlParser.KW_WEIGHT_STRING: + case MySqlParser.MOD: + case MySqlParser.AT_SIGN: + case MySqlParser.CHARSET_REVERSE_QOUTE_STRING: + case MySqlParser.STRING_LITERAL: + case MySqlParser.ID: + case MySqlParser.LOCAL_ID: + case MySqlParser.GLOBAL_ID: + { + this.state = 6743; + this.variableClause(); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + this.state = 6746; + this.variableClause(); + this.state = 6747; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 6748; + this.diagnosticsConditionInformationName(); + this.state = 6756; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 6749; + this.match(MySqlParser.COMMA); + this.state = 6750; + this.variableClause(); + this.state = 6751; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 6752; + this.diagnosticsConditionInformationName(); + } + } + this.state = 6758; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + } + break; + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + diagnosticsConditionInformationName() { + let localContext = new DiagnosticsConditionInformationNameContext(this.context, this.state); + this.enterRule(localContext, 618, MySqlParser.RULE_diagnosticsConditionInformationName); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6761; + _la = this.tokenStream.LA(1); + if (!(((((_la - 332)) & ~0x1F) === 0 && ((1 << (_la - 332)) & 137887873) !== 0) || _la === 487 || _la === 495 || _la === 578 || _la === 650 || _la === 657 || _la === 822 || _la === 832)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + describeObjectClause() { + let localContext = new DescribeObjectClauseContext(this.context, this.state); + this.enterRule(localContext, 620, MySqlParser.RULE_describeObjectClause); + try { + this.state = 6773; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_DELETE: + case MySqlParser.KW_INSERT: + case MySqlParser.KW_REPLACE: + case MySqlParser.KW_SELECT: + case MySqlParser.KW_UPDATE: + case MySqlParser.LR_BRACKET: + localContext = new DescribeStatementsContext(localContext); + this.enterOuterAlt(localContext, 1); + { + this.state = 6768; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_SELECT: + case MySqlParser.LR_BRACKET: + { + this.state = 6763; + this.selectStatement(); + } + break; + case MySqlParser.KW_DELETE: + { + this.state = 6764; + this.deleteStatement(); + } + break; + case MySqlParser.KW_INSERT: + { + this.state = 6765; + this.insertStatement(); + } + break; + case MySqlParser.KW_REPLACE: + { + this.state = 6766; + this.replaceStatement(); + } + break; + case MySqlParser.KW_UPDATE: + { + this.state = 6767; + this.updateStatement(); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + break; + case MySqlParser.KW_FOR: + localContext = new DescribeConnectionContext(localContext); + this.enterOuterAlt(localContext, 2); + { + this.state = 6770; + this.match(MySqlParser.KW_FOR); + this.state = 6771; + this.match(MySqlParser.KW_CONNECTION); + this.state = 6772; + localContext._connection_id = this.uid(); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + databaseNameCreate() { + let localContext = new DatabaseNameCreateContext(this.context, this.state); + this.enterRule(localContext, 622, MySqlParser.RULE_databaseNameCreate); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6775; + this.fullId(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + databaseName() { + let localContext = new DatabaseNameContext(this.context, this.state); + this.enterRule(localContext, 624, MySqlParser.RULE_databaseName); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6777; + this.fullId(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + functionNameCreate() { + let localContext = new FunctionNameCreateContext(this.context, this.state); + this.enterRule(localContext, 626, MySqlParser.RULE_functionNameCreate); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6779; + this.fullId(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + functionName() { + let localContext = new FunctionNameContext(this.context, this.state); + this.enterRule(localContext, 628, MySqlParser.RULE_functionName); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6781; + this.fullId(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + viewNameCreate() { + let localContext = new ViewNameCreateContext(this.context, this.state); + this.enterRule(localContext, 630, MySqlParser.RULE_viewNameCreate); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6783; + this.fullId(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + viewName() { + let localContext = new ViewNameContext(this.context, this.state); + this.enterRule(localContext, 632, MySqlParser.RULE_viewName); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6785; + this.fullId(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + indexNameCreate() { + let localContext = new IndexNameCreateContext(this.context, this.state); + this.enterRule(localContext, 634, MySqlParser.RULE_indexNameCreate); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6787; + this.uid(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + indexNames() { + let localContext = new IndexNamesContext(this.context, this.state); + this.enterRule(localContext, 636, MySqlParser.RULE_indexNames); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6789; + this.indexName(); + this.state = 6794; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 6790; + this.match(MySqlParser.COMMA); + this.state = 6791; + this.indexName(); + } + } + this.state = 6796; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + indexName() { + let localContext = new IndexNameContext(this.context, this.state); + this.enterRule(localContext, 638, MySqlParser.RULE_indexName); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6797; + this.uid(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + groupNameCreate() { + let localContext = new GroupNameCreateContext(this.context, this.state); + this.enterRule(localContext, 640, MySqlParser.RULE_groupNameCreate); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6799; + this.uid(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + groupName() { + let localContext = new GroupNameContext(this.context, this.state); + this.enterRule(localContext, 642, MySqlParser.RULE_groupName); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6801; + this.uid(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + tableNameCreate() { + let localContext = new TableNameCreateContext(this.context, this.state); + this.enterRule(localContext, 644, MySqlParser.RULE_tableNameCreate); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6803; + this.fullId(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + tableNames() { + let localContext = new TableNamesContext(this.context, this.state); + this.enterRule(localContext, 646, MySqlParser.RULE_tableNames); + try { + let alternative; + this.enterOuterAlt(localContext, 1); + { + this.state = 6805; + this.tableName(); + this.state = 6810; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 978, this.context); + while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER) { + if (alternative === 1) { + { + { + this.state = 6806; + this.match(MySqlParser.COMMA); + this.state = 6807; + this.tableName(); + } + } + } + this.state = 6812; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 978, this.context); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + tableName() { + let localContext = new TableNameContext(this.context, this.state); + this.enterRule(localContext, 648, MySqlParser.RULE_tableName); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6813; + this.fullId(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + userOrRoleNames() { + let localContext = new UserOrRoleNamesContext(this.context, this.state); + this.enterRule(localContext, 650, MySqlParser.RULE_userOrRoleNames); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6815; + this.userOrRoleName(); + this.state = 6820; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 6816; + this.match(MySqlParser.COMMA); + this.state = 6817; + this.userOrRoleName(); + } + } + this.state = 6822; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + userOrRoleName() { + let localContext = new UserOrRoleNameContext(this.context, this.state); + this.enterRule(localContext, 652, MySqlParser.RULE_userOrRoleName); + try { + this.state = 6825; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 980, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 6823; + this.userName(); + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 6824; + this.uid(); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + columnNameCreate() { + let localContext = new ColumnNameCreateContext(this.context, this.state); + this.enterRule(localContext, 654, MySqlParser.RULE_columnNameCreate); + let _la; + try { + this.state = 6841; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 985, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 6827; + this.uid(); + this.state = 6832; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 865) { + { + this.state = 6828; + this.dottedId(); + this.state = 6830; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 865) { + { + this.state = 6829; + this.dottedId(); + } + } + } + } + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 6835; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 983, this.context)) { + case 1: + { + this.state = 6834; + this.matchWildcard(); + } + break; + } + this.state = 6837; + this.dottedId(); + this.state = 6839; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 865) { + { + this.state = 6838; + this.dottedId(); + } + } + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + columnNames() { + let localContext = new ColumnNamesContext(this.context, this.state); + this.enterRule(localContext, 656, MySqlParser.RULE_columnNames); + try { + let alternative; + this.enterOuterAlt(localContext, 1); + { + this.state = 6843; + this.columnName(); + this.state = 6848; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 986, this.context); + while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER) { + if (alternative === 1) { + { + { + this.state = 6844; + this.match(MySqlParser.COMMA); + this.state = 6845; + this.columnName(); + } + } + } + this.state = 6850; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 986, this.context); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + columnName() { + let localContext = new ColumnNameContext(this.context, this.state); + this.enterRule(localContext, 658, MySqlParser.RULE_columnName); + try { + this.state = 6866; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 991, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 6851; + this.uid(); + this.state = 6856; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 988, this.context)) { + case 1: + { + this.state = 6852; + this.dottedId(); + this.state = 6854; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 987, this.context)) { + case 1: + { + this.state = 6853; + this.dottedId(); + } + break; + } + } + break; + } + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 6859; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 989, this.context)) { + case 1: + { + this.state = 6858; + this.matchWildcard(); + } + break; + } + this.state = 6861; + this.dottedId(); + this.state = 6863; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 990, this.context)) { + case 1: + { + this.state = 6862; + this.dottedId(); + } + break; + } + } + break; + case 3: + this.enterOuterAlt(localContext, 3); + { + this.state = 6865; + if (!(this.shouldMatchEmpty())) { + throw this.createFailedPredicateException("this.shouldMatchEmpty()"); + } + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + tablespaceNameCreate() { + let localContext = new TablespaceNameCreateContext(this.context, this.state); + this.enterRule(localContext, 660, MySqlParser.RULE_tablespaceNameCreate); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6868; + this.uid(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + tablespaceName() { + let localContext = new TablespaceNameContext(this.context, this.state); + this.enterRule(localContext, 662, MySqlParser.RULE_tablespaceName); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6870; + this.uid(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + partitionNameCreate() { + let localContext = new PartitionNameCreateContext(this.context, this.state); + this.enterRule(localContext, 664, MySqlParser.RULE_partitionNameCreate); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6872; + this.uid(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + partitionNames() { + let localContext = new PartitionNamesContext(this.context, this.state); + this.enterRule(localContext, 666, MySqlParser.RULE_partitionNames); + try { + let alternative; + this.enterOuterAlt(localContext, 1); + { + this.state = 6874; + this.partitionName(); + this.state = 6879; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 992, this.context); + while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER) { + if (alternative === 1) { + { + { + this.state = 6875; + this.match(MySqlParser.COMMA); + this.state = 6876; + this.partitionName(); + } + } + } + this.state = 6881; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 992, this.context); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + partitionName() { + let localContext = new PartitionNameContext(this.context, this.state); + this.enterRule(localContext, 668, MySqlParser.RULE_partitionName); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6882; + this.uid(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + indexColumnName() { + let localContext = new IndexColumnNameContext(this.context, this.state); + this.enterRule(localContext, 670, MySqlParser.RULE_indexColumnName); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6892; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 994, this.context)) { + case 1: + { + this.state = 6884; + this.uid(); + this.state = 6889; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 993, this.context)) { + case 1: + { + this.state = 6885; + this.match(MySqlParser.LR_BRACKET); + this.state = 6886; + this.decimalLiteral(); + this.state = 6887; + this.match(MySqlParser.RR_BRACKET); + } + break; + } + } + break; + case 2: + { + this.state = 6891; + this.expression(0); + } + break; + } + this.state = 6895; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 995, this.context)) { + case 1: + { + this.state = 6894; + localContext._sortType = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 14 || _la === 45)) { + localContext._sortType = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + break; + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + userHostPort() { + let localContext = new UserHostPortContext(this.context, this.state); + this.enterRule(localContext, 672, MySqlParser.RULE_userHostPort); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6897; + this.userAtHost(); + this.state = 6898; + this.match(MySqlParser.COLON_SYMB); + this.state = 6899; + this.decimalLiteral(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + userAtHost() { + let localContext = new UserAtHostContext(this.context, this.state); + this.enterRule(localContext, 674, MySqlParser.RULE_userAtHost); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6901; + this.simpleUserName(); + this.state = 6902; + this.match(MySqlParser.HOST_IP_ADDRESS); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + simpleUserName() { + let localContext = new SimpleUserNameContext(this.context, this.state); + this.enterRule(localContext, 676, MySqlParser.RULE_simpleUserName); + try { + this.state = 6908; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 996, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 6904; + this.match(MySqlParser.STRING_LITERAL); + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 6905; + this.match(MySqlParser.ID); + } + break; + case 3: + this.enterOuterAlt(localContext, 3); + { + this.state = 6906; + this.match(MySqlParser.KW_ADMIN); + } + break; + case 4: + this.enterOuterAlt(localContext, 4); + { + this.state = 6907; + this.keywordsCanBeId(); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + hostName() { + let localContext = new HostNameContext(this.context, this.state); + this.enterRule(localContext, 678, MySqlParser.RULE_hostName); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6910; + _la = this.tokenStream.LA(1); + if (!(((((_la - 870)) & ~0x1F) === 0 && ((1 << (_la - 870)) & 6291457) !== 0))) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + userName() { + let localContext = new UserNameContext(this.context, this.state); + this.enterRule(localContext, 680, MySqlParser.RULE_userName); + let _la; + try { + this.state = 6917; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 998, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 6912; + this.simpleUserName(); + this.state = 6914; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (((((_la - 870)) & ~0x1F) === 0 && ((1 << (_la - 870)) & 6291457) !== 0)) { + { + this.state = 6913; + this.hostName(); + } + } + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 6916; + this.currentUserExpression(); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + mysqlVariable() { + let localContext = new MysqlVariableContext(this.context, this.state); + this.enterRule(localContext, 682, MySqlParser.RULE_mysqlVariable); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6919; + _la = this.tokenStream.LA(1); + if (!(_la === 892 || _la === 893)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + charsetName() { + let localContext = new CharsetNameContext(this.context, this.state); + this.enterRule(localContext, 684, MySqlParser.RULE_charsetName); + try { + this.state = 6925; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 999, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 6921; + this.match(MySqlParser.KW_BINARY); + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 6922; + this.charsetNameBase(); + } + break; + case 3: + this.enterOuterAlt(localContext, 3); + { + this.state = 6923; + this.match(MySqlParser.STRING_LITERAL); + } + break; + case 4: + this.enterOuterAlt(localContext, 4); + { + this.state = 6924; + this.match(MySqlParser.CHARSET_REVERSE_QOUTE_STRING); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + collationName() { + let localContext = new CollationNameContext(this.context, this.state); + this.enterRule(localContext, 686, MySqlParser.RULE_collationName); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6927; + this.uid(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + engineName() { + let localContext = new EngineNameContext(this.context, this.state); + this.enterRule(localContext, 688, MySqlParser.RULE_engineName); + try { + this.state = 6932; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_CONNECT: + case MySqlParser.KW_ARCHIVE: + case MySqlParser.KW_BLACKHOLE: + case MySqlParser.KW_CSV: + case MySqlParser.KW_FEDERATED: + case MySqlParser.KW_INNODB: + case MySqlParser.KW_MEMORY: + case MySqlParser.KW_MRG_MYISAM: + case MySqlParser.KW_MYISAM: + case MySqlParser.KW_NDB: + case MySqlParser.KW_NDBCLUSTER: + case MySqlParser.KW_PERFORMANCE_SCHEMA: + case MySqlParser.KW_TOKUDB: + this.enterOuterAlt(localContext, 1); + { + this.state = 6929; + this.engineNameBase(); + } + break; + case MySqlParser.ID: + this.enterOuterAlt(localContext, 2); + { + this.state = 6930; + this.match(MySqlParser.ID); + } + break; + case MySqlParser.STRING_LITERAL: + this.enterOuterAlt(localContext, 3); + { + this.state = 6931; + this.match(MySqlParser.STRING_LITERAL); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + engineNameBase() { + let localContext = new EngineNameBaseContext(this.context, this.state); + this.enterRule(localContext, 690, MySqlParser.RULE_engineNameBase); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6934; + _la = this.tokenStream.LA(1); + if (!(_la === 348 || ((((_la - 797)) & ~0x1F) === 0 && ((1 << (_la - 797)) & 4095) !== 0))) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + uuidSet() { + let localContext = new UuidSetContext(this.context, this.state); + this.enterRule(localContext, 692, MySqlParser.RULE_uuidSet); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6936; + this.decimalLiteral(); + this.state = 6937; + this.match(MySqlParser.MINUS); + this.state = 6938; + this.decimalLiteral(); + this.state = 6939; + this.match(MySqlParser.MINUS); + this.state = 6940; + this.decimalLiteral(); + this.state = 6941; + this.match(MySqlParser.MINUS); + this.state = 6942; + this.decimalLiteral(); + this.state = 6943; + this.match(MySqlParser.MINUS); + this.state = 6944; + this.decimalLiteral(); + this.state = 6950; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + do { + { + { + this.state = 6945; + this.match(MySqlParser.COLON_SYMB); + this.state = 6946; + this.decimalLiteral(); + this.state = 6947; + this.match(MySqlParser.MINUS); + this.state = 6948; + this.decimalLiteral(); + } + } + this.state = 6952; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } while (_la === 878); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + xid() { + let localContext = new XidContext(this.context, this.state); + this.enterRule(localContext, 694, MySqlParser.RULE_xid); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6954; + localContext._globalTableUid = this.xuidStringId(); + this.state = 6961; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 868) { + { + this.state = 6955; + this.match(MySqlParser.COMMA); + this.state = 6956; + localContext._qualifier = this.xuidStringId(); + this.state = 6959; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 868) { + { + this.state = 6957; + this.match(MySqlParser.COMMA); + this.state = 6958; + localContext._idFormat = this.decimalLiteral(); + } + } + } + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + xuidStringId() { + let localContext = new XuidStringIdContext(this.context, this.state); + this.enterRule(localContext, 696, MySqlParser.RULE_xuidStringId); + let _la; + try { + this.state = 6970; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.STRING_LITERAL: + this.enterOuterAlt(localContext, 1); + { + this.state = 6963; + this.match(MySqlParser.STRING_LITERAL); + } + break; + case MySqlParser.BIT_STRING: + this.enterOuterAlt(localContext, 2); + { + this.state = 6964; + this.match(MySqlParser.BIT_STRING); + } + break; + case MySqlParser.HEXADECIMAL_LITERAL: + this.enterOuterAlt(localContext, 3); + { + this.state = 6966; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + do { + { + { + this.state = 6965; + this.match(MySqlParser.HEXADECIMAL_LITERAL); + } + } + this.state = 6968; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } while (_la === 884); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + fullId() { + let localContext = new FullIdContext(this.context, this.state); + this.enterRule(localContext, 698, MySqlParser.RULE_fullId); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6972; + this.uid(); + this.state = 6974; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1006, this.context)) { + case 1: + { + this.state = 6973; + this.dottedId(); + } + break; + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + uidList() { + let localContext = new UidListContext(this.context, this.state); + this.enterRule(localContext, 700, MySqlParser.RULE_uidList); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6976; + this.uid(); + this.state = 6981; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 6977; + this.match(MySqlParser.COMMA); + this.state = 6978; + this.uid(); + } + } + this.state = 6983; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + uid() { + let localContext = new UidContext(this.context, this.state); + this.enterRule(localContext, 702, MySqlParser.RULE_uid); + try { + this.state = 6987; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_ARRAY: + case MySqlParser.KW_ATTRIBUTE: + case MySqlParser.KW_BUCKETS: + case MySqlParser.KW_CONDITION: + case MySqlParser.KW_CURRENT: + case MySqlParser.KW_CURRENT_USER: + case MySqlParser.KW_DATABASE: + case MySqlParser.KW_DEFAULT: + case MySqlParser.KW_DIAGNOSTICS: + case MySqlParser.KW_EMPTY: + case MySqlParser.KW_ENFORCED: + case MySqlParser.KW_EXCEPT: + case MySqlParser.KW_GROUP: + case MySqlParser.KW_IF: + case MySqlParser.KW_INSERT: + case MySqlParser.KW_LATERAL: + case MySqlParser.KW_LEFT: + case MySqlParser.KW_NUMBER: + case MySqlParser.KW_OPTIONAL: + case MySqlParser.KW_ORDER: + case MySqlParser.KW_PRIMARY: + case MySqlParser.KW_REPEAT: + case MySqlParser.KW_REPLACE: + case MySqlParser.KW_RIGHT: + case MySqlParser.KW_SCHEMA: + case MySqlParser.KW_SKIP_QUERY_REWRITE: + case MySqlParser.KW_STACKED: + case MySqlParser.KW_DATE: + case MySqlParser.KW_TIME: + case MySqlParser.KW_TIMESTAMP: + case MySqlParser.KW_DATETIME: + case MySqlParser.KW_YEAR: + case MySqlParser.KW_BINARY: + case MySqlParser.KW_TEXT: + case MySqlParser.KW_ENUM: + case MySqlParser.KW_SERIAL: + case MySqlParser.KW_JSON_TABLE: + case MySqlParser.KW_JSON_VALUE: + case MySqlParser.KW_NESTED: + case MySqlParser.KW_ORDINALITY: + case MySqlParser.KW_PATH: + case MySqlParser.KW_AVG: + case MySqlParser.KW_BIT_AND: + case MySqlParser.KW_BIT_OR: + case MySqlParser.KW_BIT_XOR: + case MySqlParser.KW_COUNT: + case MySqlParser.KW_CUME_DIST: + case MySqlParser.KW_DENSE_RANK: + case MySqlParser.KW_FIRST_VALUE: + case MySqlParser.KW_GROUP_CONCAT: + case MySqlParser.KW_LAG: + case MySqlParser.KW_LAST_VALUE: + case MySqlParser.KW_LEAD: + case MySqlParser.KW_MAX: + case MySqlParser.KW_MIN: + case MySqlParser.KW_NTILE: + case MySqlParser.KW_NTH_VALUE: + case MySqlParser.KW_PERCENT_RANK: + case MySqlParser.KW_RANK: + case MySqlParser.KW_ROW_NUMBER: + case MySqlParser.KW_STD: + case MySqlParser.KW_STDDEV: + case MySqlParser.KW_STDDEV_POP: + case MySqlParser.KW_STDDEV_SAMP: + case MySqlParser.KW_SUM: + case MySqlParser.KW_VAR_POP: + case MySqlParser.KW_VAR_SAMP: + case MySqlParser.KW_VARIANCE: + case MySqlParser.KW_CURRENT_DATE: + case MySqlParser.KW_CURRENT_TIME: + case MySqlParser.KW_CURRENT_TIMESTAMP: + case MySqlParser.KW_LOCALTIME: + case MySqlParser.KW_CURDATE: + case MySqlParser.KW_CURTIME: + case MySqlParser.KW_DATE_ADD: + case MySqlParser.KW_DATE_SUB: + case MySqlParser.KW_LOCALTIMESTAMP: + case MySqlParser.KW_NOW: + case MySqlParser.KW_POSITION: + case MySqlParser.KW_SUBSTR: + case MySqlParser.KW_SUBSTRING: + case MySqlParser.KW_SYSDATE: + case MySqlParser.KW_TRIM: + case MySqlParser.KW_UTC_DATE: + case MySqlParser.KW_UTC_TIME: + case MySqlParser.KW_UTC_TIMESTAMP: + case MySqlParser.KW_ACCOUNT: + case MySqlParser.KW_ACTION: + case MySqlParser.KW_AFTER: + case MySqlParser.KW_AGGREGATE: + case MySqlParser.KW_ALGORITHM: + case MySqlParser.KW_ANY: + case MySqlParser.KW_AT: + case MySqlParser.KW_AUTHORS: + case MySqlParser.KW_AUTOCOMMIT: + case MySqlParser.KW_AUTOEXTEND_SIZE: + case MySqlParser.KW_AUTO_INCREMENT: + case MySqlParser.KW_AVG_ROW_LENGTH: + case MySqlParser.KW_BEGIN: + case MySqlParser.KW_BINLOG: + case MySqlParser.KW_BIT: + case MySqlParser.KW_BLOCK: + case MySqlParser.KW_BOOL: + case MySqlParser.KW_BOOLEAN: + case MySqlParser.KW_BTREE: + case MySqlParser.KW_CACHE: + case MySqlParser.KW_CASCADED: + case MySqlParser.KW_CHAIN: + case MySqlParser.KW_CHANGED: + case MySqlParser.KW_CHANNEL: + case MySqlParser.KW_CHECKSUM: + case MySqlParser.KW_CIPHER: + case MySqlParser.KW_CLASS_ORIGIN: + case MySqlParser.KW_CLIENT: + case MySqlParser.KW_CLOSE: + case MySqlParser.KW_COALESCE: + case MySqlParser.KW_CODE: + case MySqlParser.KW_COLUMNS: + case MySqlParser.KW_COLUMN_FORMAT: + case MySqlParser.KW_COLUMN_NAME: + case MySqlParser.KW_COMMENT: + case MySqlParser.KW_COMMIT: + case MySqlParser.KW_COMPACT: + case MySqlParser.KW_COMPLETION: + case MySqlParser.KW_COMPRESSED: + case MySqlParser.KW_COMPRESSION: + case MySqlParser.KW_CONCURRENT: + case MySqlParser.KW_CONNECT: + case MySqlParser.KW_CONNECTION: + case MySqlParser.KW_CONSISTENT: + case MySqlParser.KW_CONSTRAINT_CATALOG: + case MySqlParser.KW_CONSTRAINT_SCHEMA: + case MySqlParser.KW_CONSTRAINT_NAME: + case MySqlParser.KW_CONTAINS: + case MySqlParser.KW_CONTEXT: + case MySqlParser.KW_CONTRIBUTORS: + case MySqlParser.KW_COPY: + case MySqlParser.KW_CPU: + case MySqlParser.KW_CURSOR_NAME: + case MySqlParser.KW_DATA: + case MySqlParser.KW_DATAFILE: + case MySqlParser.KW_DEALLOCATE: + case MySqlParser.KW_DEFAULT_AUTH: + case MySqlParser.KW_DEFINER: + case MySqlParser.KW_DELAY_KEY_WRITE: + case MySqlParser.KW_DES_KEY_FILE: + case MySqlParser.KW_DIRECTORY: + case MySqlParser.KW_DISABLE: + case MySqlParser.KW_DISCARD: + case MySqlParser.KW_DISK: + case MySqlParser.KW_DO: + case MySqlParser.KW_DUMPFILE: + case MySqlParser.KW_DUPLICATE: + case MySqlParser.KW_DYNAMIC: + case MySqlParser.KW_ENABLE: + case MySqlParser.KW_ENCRYPTION: + case MySqlParser.KW_END: + case MySqlParser.KW_ENDS: + case MySqlParser.KW_ENGINE: + case MySqlParser.KW_ENGINES: + case MySqlParser.KW_ERROR: + case MySqlParser.KW_ERRORS: + case MySqlParser.KW_ESCAPE: + case MySqlParser.KW_EVENT: + case MySqlParser.KW_EVENTS: + case MySqlParser.KW_EVERY: + case MySqlParser.KW_EXCHANGE: + case MySqlParser.KW_EXCLUSIVE: + case MySqlParser.KW_EXPIRE: + case MySqlParser.KW_EXPORT: + case MySqlParser.KW_EXTENDED: + case MySqlParser.KW_EXTENT_SIZE: + case MySqlParser.KW_FAILED_LOGIN_ATTEMPTS: + case MySqlParser.KW_FAST: + case MySqlParser.KW_FAULTS: + case MySqlParser.KW_FIELDS: + case MySqlParser.KW_FILE_BLOCK_SIZE: + case MySqlParser.KW_FILTER: + case MySqlParser.KW_FIRST: + case MySqlParser.KW_FIXED: + case MySqlParser.KW_FLUSH: + case MySqlParser.KW_FOLLOWS: + case MySqlParser.KW_FOUND: + case MySqlParser.KW_FULL: + case MySqlParser.KW_FUNCTION: + case MySqlParser.KW_GENERAL: + case MySqlParser.KW_GLOBAL: + case MySqlParser.KW_GRANTS: + case MySqlParser.KW_GROUP_REPLICATION: + case MySqlParser.KW_HANDLER: + case MySqlParser.KW_HASH: + case MySqlParser.KW_HELP: + case MySqlParser.KW_HISTORY: + case MySqlParser.KW_HOST: + case MySqlParser.KW_HOSTS: + case MySqlParser.KW_IDENTIFIED: + case MySqlParser.KW_IGNORE_SERVER_IDS: + case MySqlParser.KW_IMPORT: + case MySqlParser.KW_INDEXES: + case MySqlParser.KW_INITIAL_SIZE: + case MySqlParser.KW_INPLACE: + case MySqlParser.KW_INSERT_METHOD: + case MySqlParser.KW_INSTALL: + case MySqlParser.KW_INSTANCE: + case MySqlParser.KW_INSTANT: + case MySqlParser.KW_INVISIBLE: + case MySqlParser.KW_INVOKER: + case MySqlParser.KW_IO: + case MySqlParser.KW_IO_THREAD: + case MySqlParser.KW_IPC: + case MySqlParser.KW_ISOLATION: + case MySqlParser.KW_ISSUER: + case MySqlParser.KW_JSON: + case MySqlParser.KW_KEY_BLOCK_SIZE: + case MySqlParser.KW_LANGUAGE: + case MySqlParser.KW_LAST: + case MySqlParser.KW_LEAVES: + case MySqlParser.KW_LESS: + case MySqlParser.KW_LEVEL: + case MySqlParser.KW_LIST: + case MySqlParser.KW_LOCAL: + case MySqlParser.KW_LOGFILE: + case MySqlParser.KW_LOGS: + case MySqlParser.KW_MASTER: + case MySqlParser.KW_MASTER_AUTO_POSITION: + case MySqlParser.KW_MASTER_CONNECT_RETRY: + case MySqlParser.KW_MASTER_DELAY: + case MySqlParser.KW_MASTER_HEARTBEAT_PERIOD: + case MySqlParser.KW_MASTER_HOST: + case MySqlParser.KW_MASTER_LOG_FILE: + case MySqlParser.KW_MASTER_LOG_POS: + case MySqlParser.KW_MASTER_PASSWORD: + case MySqlParser.KW_MASTER_PORT: + case MySqlParser.KW_MASTER_RETRY_COUNT: + case MySqlParser.KW_MASTER_SSL: + case MySqlParser.KW_MASTER_SSL_CA: + case MySqlParser.KW_MASTER_SSL_CAPATH: + case MySqlParser.KW_MASTER_SSL_CERT: + case MySqlParser.KW_MASTER_SSL_CIPHER: + case MySqlParser.KW_MASTER_SSL_CRL: + case MySqlParser.KW_MASTER_SSL_CRLPATH: + case MySqlParser.KW_MASTER_SSL_KEY: + case MySqlParser.KW_MASTER_TLS_VERSION: + case MySqlParser.KW_MASTER_USER: + case MySqlParser.KW_MAX_CONNECTIONS_PER_HOUR: + case MySqlParser.KW_MAX_QUERIES_PER_HOUR: + case MySqlParser.KW_MAX_ROWS: + case MySqlParser.KW_MAX_SIZE: + case MySqlParser.KW_MAX_UPDATES_PER_HOUR: + case MySqlParser.KW_MAX_USER_CONNECTIONS: + case MySqlParser.KW_MEDIUM: + case MySqlParser.KW_MEMBER: + case MySqlParser.KW_MERGE: + case MySqlParser.KW_MESSAGE_TEXT: + case MySqlParser.KW_MID: + case MySqlParser.KW_MIGRATE: + case MySqlParser.KW_MIN_ROWS: + case MySqlParser.KW_MODE: + case MySqlParser.KW_MODIFY: + case MySqlParser.KW_MUTEX: + case MySqlParser.KW_MYSQL: + case MySqlParser.KW_MYSQL_ERRNO: + case MySqlParser.KW_NAME: + case MySqlParser.KW_NAMES: + case MySqlParser.KW_NCHAR: + case MySqlParser.KW_NEVER: + case MySqlParser.KW_NEXT: + case MySqlParser.KW_NO: + case MySqlParser.KW_NOWAIT: + case MySqlParser.KW_NODEGROUP: + case MySqlParser.KW_NONE: + case MySqlParser.KW_ODBC: + case MySqlParser.KW_OFFLINE: + case MySqlParser.KW_OFFSET: + case MySqlParser.KW_OF: + case MySqlParser.KW_OLD_PASSWORD: + case MySqlParser.KW_ONE: + case MySqlParser.KW_ONLINE: + case MySqlParser.KW_ONLY: + case MySqlParser.KW_OPEN: + case MySqlParser.KW_OPTIMIZER_COSTS: + case MySqlParser.KW_OPTIONS: + case MySqlParser.KW_OWNER: + case MySqlParser.KW_PACK_KEYS: + case MySqlParser.KW_PAGE: + case MySqlParser.KW_PAGE_CHECKSUM: + case MySqlParser.KW_PARSER: + case MySqlParser.KW_PARTIAL: + case MySqlParser.KW_PARTITIONING: + case MySqlParser.KW_PARTITIONS: + case MySqlParser.KW_PASSWORD: + case MySqlParser.KW_PASSWORD_LOCK_TIME: + case MySqlParser.KW_PHASE: + case MySqlParser.KW_PLUGIN: + case MySqlParser.KW_PLUGIN_DIR: + case MySqlParser.KW_PLUGINS: + case MySqlParser.KW_PORT: + case MySqlParser.KW_PRECEDES: + case MySqlParser.KW_PREPARE: + case MySqlParser.KW_PRESERVE: + case MySqlParser.KW_PREV: + case MySqlParser.KW_PROCESSLIST: + case MySqlParser.KW_PROFILE: + case MySqlParser.KW_PROFILES: + case MySqlParser.KW_PROXY: + case MySqlParser.KW_QUERY: + case MySqlParser.KW_QUICK: + case MySqlParser.KW_REBUILD: + case MySqlParser.KW_RECOVER: + case MySqlParser.KW_RECURSIVE: + case MySqlParser.KW_REDO_BUFFER_SIZE: + case MySqlParser.KW_REDUNDANT: + case MySqlParser.KW_RELAY: + case MySqlParser.KW_RELAY_LOG_FILE: + case MySqlParser.KW_RELAY_LOG_POS: + case MySqlParser.KW_RELAYLOG: + case MySqlParser.KW_REMOVE: + case MySqlParser.KW_REORGANIZE: + case MySqlParser.KW_REPAIR: + case MySqlParser.KW_REPLICATE_DO_DB: + case MySqlParser.KW_REPLICATE_DO_TABLE: + case MySqlParser.KW_REPLICATE_IGNORE_DB: + case MySqlParser.KW_REPLICATE_IGNORE_TABLE: + case MySqlParser.KW_REPLICATE_REWRITE_DB: + case MySqlParser.KW_REPLICATE_WILD_DO_TABLE: + case MySqlParser.KW_REPLICATE_WILD_IGNORE_TABLE: + case MySqlParser.KW_REPLICATION: + case MySqlParser.KW_RESET: + case MySqlParser.KW_RESUME: + case MySqlParser.KW_RETURNED_SQLSTATE: + case MySqlParser.KW_RETURNS: + case MySqlParser.KW_REUSE: + case MySqlParser.KW_ROLE: + case MySqlParser.KW_ROLLBACK: + case MySqlParser.KW_ROLLUP: + case MySqlParser.KW_ROTATE: + case MySqlParser.KW_ROW: + case MySqlParser.KW_ROWS: + case MySqlParser.KW_ROW_FORMAT: + case MySqlParser.KW_SAVEPOINT: + case MySqlParser.KW_SCHEDULE: + case MySqlParser.KW_SECURITY: + case MySqlParser.KW_SERVER: + case MySqlParser.KW_SESSION: + case MySqlParser.KW_SHARE: + case MySqlParser.KW_SHARED: + case MySqlParser.KW_SIGNED: + case MySqlParser.KW_SIMPLE: + case MySqlParser.KW_SLAVE: + case MySqlParser.KW_SLOW: + case MySqlParser.KW_SNAPSHOT: + case MySqlParser.KW_SOCKET: + case MySqlParser.KW_SOME: + case MySqlParser.KW_SONAME: + case MySqlParser.KW_SOUNDS: + case MySqlParser.KW_SOURCE: + case MySqlParser.KW_SQL_AFTER_GTIDS: + case MySqlParser.KW_SQL_AFTER_MTS_GAPS: + case MySqlParser.KW_SQL_BEFORE_GTIDS: + case MySqlParser.KW_SQL_BUFFER_RESULT: + case MySqlParser.KW_SQL_CACHE: + case MySqlParser.KW_SQL_NO_CACHE: + case MySqlParser.KW_SQL_THREAD: + case MySqlParser.KW_START: + case MySqlParser.KW_STARTS: + case MySqlParser.KW_STATS_AUTO_RECALC: + case MySqlParser.KW_STATS_PERSISTENT: + case MySqlParser.KW_STATS_SAMPLE_PAGES: + case MySqlParser.KW_STATUS: + case MySqlParser.KW_STOP: + case MySqlParser.KW_STORAGE: + case MySqlParser.KW_STRING: + case MySqlParser.KW_SUBCLASS_ORIGIN: + case MySqlParser.KW_SUBJECT: + case MySqlParser.KW_SUBPARTITION: + case MySqlParser.KW_SUBPARTITIONS: + case MySqlParser.KW_SUSPEND: + case MySqlParser.KW_SWAPS: + case MySqlParser.KW_SWITCHES: + case MySqlParser.KW_TABLE_NAME: + case MySqlParser.KW_TABLESPACE: + case MySqlParser.KW_TABLE_TYPE: + case MySqlParser.KW_TEMPORARY: + case MySqlParser.KW_TEMPTABLE: + case MySqlParser.KW_THAN: + case MySqlParser.KW_TRADITIONAL: + case MySqlParser.KW_TRANSACTION: + case MySqlParser.KW_TRANSACTIONAL: + case MySqlParser.KW_TRIGGERS: + case MySqlParser.KW_TRUNCATE: + case MySqlParser.KW_UNBOUNDED: + case MySqlParser.KW_UNDEFINED: + case MySqlParser.KW_UNDOFILE: + case MySqlParser.KW_UNDO_BUFFER_SIZE: + case MySqlParser.KW_UNINSTALL: + case MySqlParser.KW_UNKNOWN: + case MySqlParser.KW_UNTIL: + case MySqlParser.KW_UPGRADE: + case MySqlParser.KW_USER: + case MySqlParser.KW_USE_FRM: + case MySqlParser.KW_USER_RESOURCES: + case MySqlParser.KW_VALIDATION: + case MySqlParser.KW_VALUE: + case MySqlParser.KW_VARIABLES: + case MySqlParser.KW_VIEW: + case MySqlParser.KW_VIRTUAL: + case MySqlParser.KW_VISIBLE: + case MySqlParser.KW_WAIT: + case MySqlParser.KW_WARNINGS: + case MySqlParser.KW_WITHOUT: + case MySqlParser.KW_WORK: + case MySqlParser.KW_WRAPPER: + case MySqlParser.KW_X509: + case MySqlParser.KW_XA: + case MySqlParser.KW_XML: + case MySqlParser.KW_QUARTER: + case MySqlParser.KW_MONTH: + case MySqlParser.KW_DAY: + case MySqlParser.KW_HOUR: + case MySqlParser.KW_MINUTE: + case MySqlParser.KW_WEEK: + case MySqlParser.KW_SECOND: + case MySqlParser.KW_MICROSECOND: + case MySqlParser.KW_ADMIN: + case MySqlParser.KW_AUDIT_ABORT_EXEMPT: + case MySqlParser.KW_AUDIT_ADMIN: + case MySqlParser.KW_AUTHENTICATION_POLICY_ADMIN: + case MySqlParser.KW_BACKUP_ADMIN: + case MySqlParser.KW_BINLOG_ADMIN: + case MySqlParser.KW_BINLOG_ENCRYPTION_ADMIN: + case MySqlParser.KW_CLONE_ADMIN: + case MySqlParser.KW_CONNECTION_ADMIN: + case MySqlParser.KW_ENCRYPTION_KEY_ADMIN: + case MySqlParser.KW_EXECUTE: + case MySqlParser.KW_FILE: + case MySqlParser.KW_FIREWALL_ADMIN: + case MySqlParser.KW_FIREWALL_EXEMPT: + case MySqlParser.KW_FIREWALL_USER: + case MySqlParser.KW_GROUP_REPLICATION_ADMIN: + case MySqlParser.KW_INNODB_REDO_LOG_ARCHIVE: + case MySqlParser.KW_INVOKE: + case MySqlParser.KW_LAMBDA: + case MySqlParser.KW_NDB_STORED_USER: + case MySqlParser.KW_PASSWORDLESS_USER_ADMIN: + case MySqlParser.KW_PERSIST_RO_VARIABLES_ADMIN: + case MySqlParser.KW_PRIVILEGES: + case MySqlParser.KW_PROCESS: + case MySqlParser.KW_RELOAD: + case MySqlParser.KW_REPLICATION_APPLIER: + case MySqlParser.KW_REPLICATION_SLAVE_ADMIN: + case MySqlParser.KW_RESOURCE_GROUP_ADMIN: + case MySqlParser.KW_RESOURCE_GROUP_USER: + case MySqlParser.KW_ROLE_ADMIN: + case MySqlParser.KW_ROUTINE: + case MySqlParser.KW_S3: + case MySqlParser.KW_SESSION_VARIABLES_ADMIN: + case MySqlParser.KW_SET_USER_ID: + case MySqlParser.KW_SHOW_ROUTINE: + case MySqlParser.KW_SHUTDOWN: + case MySqlParser.KW_SUPER: + case MySqlParser.KW_SYSTEM_VARIABLES_ADMIN: + case MySqlParser.KW_TABLES: + case MySqlParser.KW_TABLE_ENCRYPTION_ADMIN: + case MySqlParser.KW_VERSION_TOKEN_ADMIN: + case MySqlParser.KW_XA_RECOVER_ADMIN: + case MySqlParser.KW_ARMSCII8: + case MySqlParser.KW_ASCII: + case MySqlParser.KW_BIG5: + case MySqlParser.KW_CP1250: + case MySqlParser.KW_CP1251: + case MySqlParser.KW_CP1256: + case MySqlParser.KW_CP1257: + case MySqlParser.KW_CP850: + case MySqlParser.KW_CP852: + case MySqlParser.KW_CP866: + case MySqlParser.KW_CP932: + case MySqlParser.KW_DEC8: + case MySqlParser.KW_EUCJPMS: + case MySqlParser.KW_EUCKR: + case MySqlParser.KW_GB18030: + case MySqlParser.KW_GB2312: + case MySqlParser.KW_GBK: + case MySqlParser.KW_GEOSTD8: + case MySqlParser.KW_GREEK: + case MySqlParser.KW_HEBREW: + case MySqlParser.KW_HP8: + case MySqlParser.KW_KEYBCS2: + case MySqlParser.KW_KOI8R: + case MySqlParser.KW_KOI8U: + case MySqlParser.KW_LATIN1: + case MySqlParser.KW_LATIN2: + case MySqlParser.KW_LATIN5: + case MySqlParser.KW_LATIN7: + case MySqlParser.KW_MACCE: + case MySqlParser.KW_MACROMAN: + case MySqlParser.KW_SJIS: + case MySqlParser.KW_SWE7: + case MySqlParser.KW_TIS620: + case MySqlParser.KW_UCS2: + case MySqlParser.KW_UJIS: + case MySqlParser.KW_UTF16: + case MySqlParser.KW_UTF16LE: + case MySqlParser.KW_UTF32: + case MySqlParser.KW_UTF8: + case MySqlParser.KW_UTF8MB3: + case MySqlParser.KW_UTF8MB4: + case MySqlParser.KW_ARCHIVE: + case MySqlParser.KW_BLACKHOLE: + case MySqlParser.KW_CSV: + case MySqlParser.KW_FEDERATED: + case MySqlParser.KW_INNODB: + case MySqlParser.KW_MEMORY: + case MySqlParser.KW_MRG_MYISAM: + case MySqlParser.KW_MYISAM: + case MySqlParser.KW_NDB: + case MySqlParser.KW_NDBCLUSTER: + case MySqlParser.KW_PERFORMANCE_SCHEMA: + case MySqlParser.KW_TOKUDB: + case MySqlParser.KW_REPEATABLE: + case MySqlParser.KW_COMMITTED: + case MySqlParser.KW_UNCOMMITTED: + case MySqlParser.KW_SERIALIZABLE: + case MySqlParser.KW_GEOMETRYCOLLECTION: + case MySqlParser.KW_LINESTRING: + case MySqlParser.KW_MULTILINESTRING: + case MySqlParser.KW_MULTIPOINT: + case MySqlParser.KW_MULTIPOLYGON: + case MySqlParser.KW_POINT: + case MySqlParser.KW_POLYGON: + case MySqlParser.KW_CATALOG_NAME: + case MySqlParser.KW_CHARSET: + case MySqlParser.KW_COLLATION: + case MySqlParser.KW_ENGINE_ATTRIBUTE: + case MySqlParser.KW_FORMAT: + case MySqlParser.KW_GET_FORMAT: + case MySqlParser.KW_RANDOM: + case MySqlParser.KW_REVERSE: + case MySqlParser.KW_ROW_COUNT: + case MySqlParser.KW_SCHEMA_NAME: + case MySqlParser.KW_SECONDARY_ENGINE_ATTRIBUTE: + case MySqlParser.KW_SRID: + case MySqlParser.KW_SYSTEM_USER: + case MySqlParser.KW_TP_CONNECTION_ADMIN: + case MySqlParser.KW_WEIGHT_STRING: + case MySqlParser.MOD: + case MySqlParser.ID: + this.enterOuterAlt(localContext, 1); + { + this.state = 6984; + this.simpleId(); + } + break; + case MySqlParser.CHARSET_REVERSE_QOUTE_STRING: + this.enterOuterAlt(localContext, 2); + { + this.state = 6985; + this.match(MySqlParser.CHARSET_REVERSE_QOUTE_STRING); + } + break; + case MySqlParser.STRING_LITERAL: + this.enterOuterAlt(localContext, 3); + { + this.state = 6986; + this.match(MySqlParser.STRING_LITERAL); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + simpleId() { + let localContext = new SimpleIdContext(this.context, this.state); + this.enterRule(localContext, 704, MySqlParser.RULE_simpleId); + try { + this.state = 6998; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1009, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 6989; + this.match(MySqlParser.ID); + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 6990; + this.charsetNameBase(); + } + break; + case 3: + this.enterOuterAlt(localContext, 3); + { + this.state = 6991; + this.transactionLevelBase(); + } + break; + case 4: + this.enterOuterAlt(localContext, 4); + { + this.state = 6992; + this.engineNameBase(); + } + break; + case 5: + this.enterOuterAlt(localContext, 5); + { + this.state = 6993; + this.privilegesBase(); + } + break; + case 6: + this.enterOuterAlt(localContext, 6); + { + this.state = 6994; + this.intervalTypeBase(); + } + break; + case 7: + this.enterOuterAlt(localContext, 7); + { + this.state = 6995; + this.dataTypeBase(); + } + break; + case 8: + this.enterOuterAlt(localContext, 8); + { + this.state = 6996; + this.keywordsCanBeId(); + } + break; + case 9: + this.enterOuterAlt(localContext, 9); + { + this.state = 6997; + this.scalarFunctionName(); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + dottedId() { + let localContext = new DottedIdContext(this.context, this.state); + this.enterRule(localContext, 706, MySqlParser.RULE_dottedId); + try { + this.state = 7004; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1010, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 7000; + this.match(MySqlParser.DOT); + this.state = 7001; + this.match(MySqlParser.ID); + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 7002; + this.match(MySqlParser.DOT); + this.state = 7003; + this.uid(); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + decimalLiteral() { + let localContext = new DecimalLiteralContext(this.context, this.state); + this.enterRule(localContext, 708, MySqlParser.RULE_decimalLiteral); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 7006; + _la = this.tokenStream.LA(1); + if (!(((((_la - 871)) & ~0x1F) === 0 && ((1 << (_la - 871)) & 20495) !== 0))) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + fileSizeLiteral() { + let localContext = new FileSizeLiteralContext(this.context, this.state); + this.enterRule(localContext, 710, MySqlParser.RULE_fileSizeLiteral); + try { + this.state = 7010; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.FILESIZE_LITERAL: + this.enterOuterAlt(localContext, 1); + { + this.state = 7008; + this.match(MySqlParser.FILESIZE_LITERAL); + } + break; + case MySqlParser.ZERO_DECIMAL: + case MySqlParser.ONE_DECIMAL: + case MySqlParser.TWO_DECIMAL: + case MySqlParser.THREE_DECIMAL: + case MySqlParser.DECIMAL_LITERAL: + case MySqlParser.REAL_LITERAL: + this.enterOuterAlt(localContext, 2); + { + this.state = 7009; + this.decimalLiteral(); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + stringLiteral() { + let localContext = new StringLiteralContext(this.context, this.state); + this.enterRule(localContext, 712, MySqlParser.RULE_stringLiteral); + let _la; + try { + let alternative; + this.state = 7035; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1018, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 7017; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.STRING_LITERAL: + case MySqlParser.STRING_CHARSET_NAME: + { + this.state = 7013; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 888) { + { + this.state = 7012; + this.match(MySqlParser.STRING_CHARSET_NAME); + } + } + this.state = 7015; + this.match(MySqlParser.STRING_LITERAL); + } + break; + case MySqlParser.START_NATIONAL_STRING_LITERAL: + { + this.state = 7016; + this.match(MySqlParser.START_NATIONAL_STRING_LITERAL); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + this.state = 7020; + this.errorHandler.sync(this); + alternative = 1; + do { + switch (alternative) { + case 1: + { + { + this.state = 7019; + this.match(MySqlParser.STRING_LITERAL); + } + } + break; + default: + throw new antlr.NoViableAltException(this); + } + this.state = 7022; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 1014, this.context); + } while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER); + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 7029; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.STRING_LITERAL: + case MySqlParser.STRING_CHARSET_NAME: + { + this.state = 7025; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 888) { + { + this.state = 7024; + this.match(MySqlParser.STRING_CHARSET_NAME); + } + } + this.state = 7027; + this.match(MySqlParser.STRING_LITERAL); + } + break; + case MySqlParser.START_NATIONAL_STRING_LITERAL: + { + this.state = 7028; + this.match(MySqlParser.START_NATIONAL_STRING_LITERAL); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + this.state = 7033; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1017, this.context)) { + case 1: + { + this.state = 7031; + this.match(MySqlParser.KW_COLLATE); + this.state = 7032; + this.collationName(); + } + break; + } + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + booleanLiteral() { + let localContext = new BooleanLiteralContext(this.context, this.state); + this.enterRule(localContext, 714, MySqlParser.RULE_booleanLiteral); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 7037; + _la = this.tokenStream.LA(1); + if (!(_la === 63 || _la === 179)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + hexadecimalLiteral() { + let localContext = new HexadecimalLiteralContext(this.context, this.state); + this.enterRule(localContext, 716, MySqlParser.RULE_hexadecimalLiteral); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 7040; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 888) { + { + this.state = 7039; + this.match(MySqlParser.STRING_CHARSET_NAME); + } + } + this.state = 7042; + this.match(MySqlParser.HEXADECIMAL_LITERAL); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + nullNotnull() { + let localContext = new NullNotnullContext(this.context, this.state); + this.enterRule(localContext, 718, MySqlParser.RULE_nullNotnull); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 7045; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 114) { + { + this.state = 7044; + this.match(MySqlParser.KW_NOT); + } + } + this.state = 7047; + _la = this.tokenStream.LA(1); + if (!(_la === 116 || _la === 886)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + constant() { + let localContext = new ConstantContext(this.context, this.state); + this.enterRule(localContext, 720, MySqlParser.RULE_constant); + let _la; + try { + this.state = 7061; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1022, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 7049; + this.stringLiteral(); + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 7050; + this.decimalLiteral(); + } + break; + case 3: + this.enterOuterAlt(localContext, 3); + { + this.state = 7051; + this.match(MySqlParser.MINUS); + this.state = 7052; + this.decimalLiteral(); + } + break; + case 4: + this.enterOuterAlt(localContext, 4); + { + this.state = 7053; + this.hexadecimalLiteral(); + } + break; + case 5: + this.enterOuterAlt(localContext, 5); + { + this.state = 7054; + this.booleanLiteral(); + } + break; + case 6: + this.enterOuterAlt(localContext, 6); + { + this.state = 7055; + this.match(MySqlParser.REAL_LITERAL); + } + break; + case 7: + this.enterOuterAlt(localContext, 7); + { + this.state = 7056; + this.match(MySqlParser.BIT_STRING); + } + break; + case 8: + this.enterOuterAlt(localContext, 8); + { + this.state = 7058; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 114) { + { + this.state = 7057; + this.match(MySqlParser.KW_NOT); + } + } + this.state = 7060; + localContext._nullLiteral = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 116 || _la === 886)) { + localContext._nullLiteral = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + dataType() { + let localContext = new DataTypeContext(this.context, this.state); + this.enterRule(localContext, 722, MySqlParser.RULE_dataType); + let _la; + try { + this.state = 7189; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1051, this.context)) { + case 1: + localContext = new StringDataTypeContext(localContext); + this.enterOuterAlt(localContext, 1); + { + this.state = 7063; + localContext._typeName = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 26 || ((((_la - 224)) & ~0x1F) === 0 && ((1 << (_la - 224)) & 31239) !== 0) || _la === 498)) { + localContext._typeName = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 7065; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 240) { + { + this.state = 7064; + this.match(MySqlParser.KW_VARYING); + } + } + this.state = 7068; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1024, this.context)) { + case 1: + { + this.state = 7067; + this.lengthOneDimension(); + } + break; + } + this.state = 7071; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1025, this.context)) { + case 1: + { + this.state = 7070; + this.match(MySqlParser.KW_BINARY); + } + break; + } + this.state = 7076; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 26 || _la === 224 || _la === 823) { + { + this.state = 7073; + this.charSet(); + this.state = 7074; + this.charsetName(); + } + } + this.state = 7081; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1027, this.context)) { + case 1: + { + this.state = 7078; + this.match(MySqlParser.KW_COLLATE); + this.state = 7079; + this.collationName(); + } + break; + case 2: + { + this.state = 7080; + this.match(MySqlParser.KW_BINARY); + } + break; + } + } + break; + case 2: + localContext = new NationalVaryingStringDataTypeContext(localContext); + this.enterOuterAlt(localContext, 2); + { + this.state = 7083; + this.match(MySqlParser.KW_NATIONAL); + this.state = 7084; + localContext._typeName = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 26 || _la === 224)) { + localContext._typeName = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 7085; + this.match(MySqlParser.KW_VARYING); + this.state = 7087; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1028, this.context)) { + case 1: + { + this.state = 7086; + this.lengthOneDimension(); + } + break; + } + this.state = 7090; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 228) { + { + this.state = 7089; + this.match(MySqlParser.KW_BINARY); + } + } + } + break; + case 3: + localContext = new NationalStringDataTypeContext(localContext); + this.enterOuterAlt(localContext, 3); + { + this.state = 7092; + this.match(MySqlParser.KW_NATIONAL); + this.state = 7093; + localContext._typeName = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 26 || _la === 224 || _la === 225)) { + localContext._typeName = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 7095; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1030, this.context)) { + case 1: + { + this.state = 7094; + this.lengthOneDimension(); + } + break; + } + this.state = 7098; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 228) { + { + this.state = 7097; + this.match(MySqlParser.KW_BINARY); + } + } + } + break; + case 4: + localContext = new NationalStringDataTypeContext(localContext); + this.enterOuterAlt(localContext, 4); + { + this.state = 7100; + this.match(MySqlParser.KW_NCHAR); + this.state = 7101; + localContext._typeName = this.match(MySqlParser.KW_VARCHAR); + this.state = 7103; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1032, this.context)) { + case 1: + { + this.state = 7102; + this.lengthOneDimension(); + } + break; + } + this.state = 7106; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 228) { + { + this.state = 7105; + this.match(MySqlParser.KW_BINARY); + } + } + } + break; + case 5: + localContext = new DimensionDataTypeContext(localContext); + this.enterOuterAlt(localContext, 5); + { + this.state = 7108; + localContext._typeName = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(((((_la - 198)) & ~0x1F) === 0 && ((1 << (_la - 198)) & 4095) !== 0))) { + localContext._typeName = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 7110; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1034, this.context)) { + case 1: + { + this.state = 7109; + this.lengthOneDimension(); + } + break; + } + this.state = 7115; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 184 || _la === 197 || _la === 596) { + { + { + this.state = 7112; + _la = this.tokenStream.LA(1); + if (!(_la === 184 || _la === 197 || _la === 596)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + this.state = 7117; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + break; + case 6: + localContext = new DimensionDataTypeContext(localContext); + this.enterOuterAlt(localContext, 6); + { + this.state = 7118; + localContext._typeName = this.match(MySqlParser.KW_REAL); + this.state = 7120; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1036, this.context)) { + case 1: + { + this.state = 7119; + this.lengthTwoDimension(); + } + break; + } + this.state = 7125; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 184 || _la === 197 || _la === 596) { + { + { + this.state = 7122; + _la = this.tokenStream.LA(1); + if (!(_la === 184 || _la === 197 || _la === 596)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + this.state = 7127; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + break; + case 7: + localContext = new DimensionDataTypeContext(localContext); + this.enterOuterAlt(localContext, 7); + { + this.state = 7128; + localContext._typeName = this.match(MySqlParser.KW_DOUBLE); + this.state = 7130; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 212) { + { + this.state = 7129; + this.match(MySqlParser.KW_PRECISION); + } + } + this.state = 7133; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1039, this.context)) { + case 1: + { + this.state = 7132; + this.lengthTwoDimension(); + } + break; + } + this.state = 7138; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 184 || _la === 197 || _la === 596) { + { + { + this.state = 7135; + _la = this.tokenStream.LA(1); + if (!(_la === 184 || _la === 197 || _la === 596)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + this.state = 7140; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + break; + case 8: + localContext = new DimensionDataTypeContext(localContext); + this.enterOuterAlt(localContext, 8); + { + this.state = 7141; + localContext._typeName = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(((((_la - 213)) & ~0x1F) === 0 && ((1 << (_la - 213)) & 63) !== 0) || _la === 403)) { + localContext._typeName = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 7143; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1041, this.context)) { + case 1: + { + this.state = 7142; + this.lengthTwoOptionalDimension(); + } + break; + } + this.state = 7148; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 184 || _la === 197 || _la === 596) { + { + { + this.state = 7145; + _la = this.tokenStream.LA(1); + if (!(_la === 184 || _la === 197 || _la === 596)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + this.state = 7150; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + break; + case 9: + localContext = new SimpleDataTypeContext(localContext); + this.enterOuterAlt(localContext, 9); + { + this.state = 7151; + localContext._typeName = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(((((_la - 219)) & ~0x1F) === 0 && ((1 << (_la - 219)) & 4237313) !== 0) || _la === 321 || _la === 322)) { + localContext._typeName = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + break; + case 10: + localContext = new DimensionDataTypeContext(localContext); + this.enterOuterAlt(localContext, 10); + { + this.state = 7152; + localContext._typeName = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(((((_la - 220)) & ~0x1F) === 0 && ((1 << (_la - 220)) & 2831) !== 0) || _la === 319)) { + localContext._typeName = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 7154; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1043, this.context)) { + case 1: + { + this.state = 7153; + this.lengthOneDimension(); + } + break; + } + } + break; + case 11: + localContext = new CollectionDataTypeContext(localContext); + this.enterOuterAlt(localContext, 11); + { + this.state = 7156; + localContext._typeName = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 155 || _la === 239)) { + localContext._typeName = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 7157; + this.collectionOptions(); + this.state = 7159; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 228) { + { + this.state = 7158; + this.match(MySqlParser.KW_BINARY); + } + } + this.state = 7164; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 26 || _la === 224 || _la === 823) { + { + this.state = 7161; + this.charSet(); + this.state = 7162; + this.charsetName(); + } + } + } + break; + case 12: + localContext = new SpatialDataTypeContext(localContext); + this.enterOuterAlt(localContext, 12); + { + this.state = 7166; + localContext._typeName = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 442 || ((((_la - 813)) & ~0x1F) === 0 && ((1 << (_la - 813)) & 511) !== 0))) { + localContext._typeName = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 7169; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 834) { + { + this.state = 7167; + this.match(MySqlParser.KW_SRID); + this.state = 7168; + this.decimalLiteral(); + } + } + } + break; + case 13: + localContext = new LongVarcharDataTypeContext(localContext); + this.enterOuterAlt(localContext, 13); + { + this.state = 7171; + localContext._typeName = this.match(MySqlParser.KW_LONG); + this.state = 7173; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 225) { + { + this.state = 7172; + this.match(MySqlParser.KW_VARCHAR); + } + } + this.state = 7176; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 228) { + { + this.state = 7175; + this.match(MySqlParser.KW_BINARY); + } + } + this.state = 7181; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 26 || _la === 224 || _la === 823) { + { + this.state = 7178; + this.charSet(); + this.state = 7179; + this.charsetName(); + } + } + this.state = 7185; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1050, this.context)) { + case 1: + { + this.state = 7183; + this.match(MySqlParser.KW_COLLATE); + this.state = 7184; + this.collationName(); + } + break; + } + } + break; + case 14: + localContext = new LongVarbinaryDataTypeContext(localContext); + this.enterOuterAlt(localContext, 14); + { + this.state = 7187; + this.match(MySqlParser.KW_LONG); + this.state = 7188; + this.match(MySqlParser.KW_VARBINARY); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + collectionOptions() { + let localContext = new CollectionOptionsContext(this.context, this.state); + this.enterRule(localContext, 724, MySqlParser.RULE_collectionOptions); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 7191; + this.match(MySqlParser.LR_BRACKET); + this.state = 7192; + this.match(MySqlParser.STRING_LITERAL); + this.state = 7197; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 7193; + this.match(MySqlParser.COMMA); + this.state = 7194; + this.match(MySqlParser.STRING_LITERAL); + } + } + this.state = 7199; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 7200; + this.match(MySqlParser.RR_BRACKET); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + convertedDataType() { + let localContext = new ConvertedDataTypeContext(this.context, this.state); + this.enterRule(localContext, 726, MySqlParser.RULE_convertedDataType); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 7224; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_BINARY: + case MySqlParser.KW_NCHAR: + { + this.state = 7202; + localContext._typeName = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 228 || _la === 498)) { + localContext._typeName = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 7204; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 866) { + { + this.state = 7203; + this.lengthOneDimension(); + } + } + } + break; + case MySqlParser.KW_CHAR: + { + this.state = 7206; + localContext._typeName = this.match(MySqlParser.KW_CHAR); + this.state = 7208; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 866) { + { + this.state = 7207; + this.lengthOneDimension(); + } + } + this.state = 7213; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 26 || _la === 224 || _la === 823) { + { + this.state = 7210; + this.charSet(); + this.state = 7211; + this.charsetName(); + } + } + } + break; + case MySqlParser.KW_INT: + case MySqlParser.KW_INTEGER: + case MySqlParser.KW_DATE: + case MySqlParser.KW_TIME: + case MySqlParser.KW_DATETIME: + case MySqlParser.KW_JSON: + { + this.state = 7215; + localContext._typeName = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(((((_la - 202)) & ~0x1F) === 0 && ((1 << (_la - 202)) & 1441857) !== 0) || _la === 442)) { + localContext._typeName = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + break; + case MySqlParser.KW_DECIMAL: + case MySqlParser.KW_DEC: + { + this.state = 7216; + localContext._typeName = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 216 || _la === 217)) { + localContext._typeName = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 7218; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 866) { + { + this.state = 7217; + this.lengthTwoOptionalDimension(); + } + } + } + break; + case MySqlParser.KW_UNSIGNED: + case MySqlParser.KW_SIGNED: + { + this.state = 7220; + _la = this.tokenStream.LA(1); + if (!(_la === 184 || _la === 596)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 7222; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 202 || _la === 208) { + { + this.state = 7221; + _la = this.tokenStream.LA(1); + if (!(_la === 202 || _la === 208)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + } + break; + default: + throw new antlr.NoViableAltException(this); + } + this.state = 7227; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 12) { + { + this.state = 7226; + this.match(MySqlParser.KW_ARRAY); + } + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + lengthOneDimension() { + let localContext = new LengthOneDimensionContext(this.context, this.state); + this.enterRule(localContext, 728, MySqlParser.RULE_lengthOneDimension); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 7229; + this.match(MySqlParser.LR_BRACKET); + this.state = 7230; + this.decimalLiteral(); + this.state = 7231; + this.match(MySqlParser.RR_BRACKET); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + lengthTwoDimension() { + let localContext = new LengthTwoDimensionContext(this.context, this.state); + this.enterRule(localContext, 730, MySqlParser.RULE_lengthTwoDimension); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 7233; + this.match(MySqlParser.LR_BRACKET); + this.state = 7234; + this.decimalLiteral(); + this.state = 7235; + this.match(MySqlParser.COMMA); + this.state = 7236; + this.decimalLiteral(); + this.state = 7237; + this.match(MySqlParser.RR_BRACKET); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + lengthTwoOptionalDimension() { + let localContext = new LengthTwoOptionalDimensionContext(this.context, this.state); + this.enterRule(localContext, 732, MySqlParser.RULE_lengthTwoOptionalDimension); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 7239; + this.match(MySqlParser.LR_BRACKET); + this.state = 7240; + this.decimalLiteral(); + this.state = 7243; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 868) { + { + this.state = 7241; + this.match(MySqlParser.COMMA); + this.state = 7242; + this.decimalLiteral(); + } + } + this.state = 7245; + this.match(MySqlParser.RR_BRACKET); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + indexColumnNames() { + let localContext = new IndexColumnNamesContext(this.context, this.state); + this.enterRule(localContext, 734, MySqlParser.RULE_indexColumnNames); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 7247; + this.match(MySqlParser.LR_BRACKET); + this.state = 7248; + this.indexColumnName(); + this.state = 7253; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 7249; + this.match(MySqlParser.COMMA); + this.state = 7250; + this.indexColumnName(); + } + } + this.state = 7255; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 7256; + this.match(MySqlParser.RR_BRACKET); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + expressions() { + let localContext = new ExpressionsContext(this.context, this.state); + this.enterRule(localContext, 736, MySqlParser.RULE_expressions); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 7258; + this.expression(0); + this.state = 7263; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 7259; + this.match(MySqlParser.COMMA); + this.state = 7260; + this.expression(0); + } + } + this.state = 7265; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + valuesOrValueList() { + let localContext = new ValuesOrValueListContext(this.context, this.state); + this.enterRule(localContext, 738, MySqlParser.RULE_valuesOrValueList); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 7266; + _la = this.tokenStream.LA(1); + if (!(_la === 189 || _la === 682)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 7267; + this.expressionsWithDefaults(); + this.state = 7272; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 7268; + this.match(MySqlParser.COMMA); + this.state = 7269; + this.expressionsWithDefaults(); + } + } + this.state = 7274; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + expressionsWithDefaults() { + let localContext = new ExpressionsWithDefaultsContext(this.context, this.state); + this.enterRule(localContext, 740, MySqlParser.RULE_expressionsWithDefaults); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 7275; + this.match(MySqlParser.LR_BRACKET); + this.state = 7276; + this.expressionOrDefault(); + this.state = 7281; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 7277; + this.match(MySqlParser.COMMA); + this.state = 7278; + this.expressionOrDefault(); + } + } + this.state = 7283; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 7284; + this.match(MySqlParser.RR_BRACKET); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + expressionOrDefault() { + let localContext = new ExpressionOrDefaultContext(this.context, this.state); + this.enterRule(localContext, 742, MySqlParser.RULE_expressionOrDefault); + try { + this.state = 7288; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1065, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 7286; + this.expression(0); + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 7287; + this.match(MySqlParser.KW_DEFAULT); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + constants() { + let localContext = new ConstantsContext(this.context, this.state); + this.enterRule(localContext, 744, MySqlParser.RULE_constants); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 7290; + this.constant(); + this.state = 7295; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 7291; + this.match(MySqlParser.COMMA); + this.state = 7292; + this.constant(); + } + } + this.state = 7297; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + simpleStrings() { + let localContext = new SimpleStringsContext(this.context, this.state); + this.enterRule(localContext, 746, MySqlParser.RULE_simpleStrings); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 7298; + this.match(MySqlParser.STRING_LITERAL); + this.state = 7303; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 7299; + this.match(MySqlParser.COMMA); + this.state = 7300; + this.match(MySqlParser.STRING_LITERAL); + } + } + this.state = 7305; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + userVariables() { + let localContext = new UserVariablesContext(this.context, this.state); + this.enterRule(localContext, 748, MySqlParser.RULE_userVariables); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 7306; + this.match(MySqlParser.LOCAL_ID); + this.state = 7311; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 7307; + this.match(MySqlParser.COMMA); + this.state = 7308; + this.match(MySqlParser.LOCAL_ID); + } + } + this.state = 7313; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + defaultValue() { + let localContext = new DefaultValueContext(this.context, this.state); + this.enterRule(localContext, 750, MySqlParser.RULE_defaultValue); + try { + this.state = 7340; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1071, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 7314; + this.match(MySqlParser.KW_NULL_LITERAL); + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 7315; + this.match(MySqlParser.KW_CAST); + this.state = 7316; + this.match(MySqlParser.LR_BRACKET); + this.state = 7317; + this.expression(0); + this.state = 7318; + this.match(MySqlParser.KW_AS); + this.state = 7319; + this.convertedDataType(); + this.state = 7320; + this.match(MySqlParser.RR_BRACKET); + } + break; + case 3: + this.enterOuterAlt(localContext, 3); + { + this.state = 7323; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1069, this.context)) { + case 1: + { + this.state = 7322; + this.unaryOperator(); + } + break; + } + this.state = 7325; + this.constant(); + } + break; + case 4: + this.enterOuterAlt(localContext, 4); + { + this.state = 7326; + this.currentTimestamp(); + this.state = 7330; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1070, this.context)) { + case 1: + { + this.state = 7327; + this.match(MySqlParser.KW_ON); + this.state = 7328; + this.match(MySqlParser.KW_UPDATE); + this.state = 7329; + this.currentTimestamp(); + } + break; + } + } + break; + case 5: + this.enterOuterAlt(localContext, 5); + { + this.state = 7332; + this.match(MySqlParser.LR_BRACKET); + this.state = 7333; + this.expression(0); + this.state = 7334; + this.match(MySqlParser.RR_BRACKET); + } + break; + case 6: + this.enterOuterAlt(localContext, 6); + { + this.state = 7336; + this.match(MySqlParser.LR_BRACKET); + this.state = 7337; + this.fullId(); + this.state = 7338; + this.match(MySqlParser.RR_BRACKET); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + currentTimestamp() { + let localContext = new CurrentTimestampContext(this.context, this.state); + this.enterRule(localContext, 752, MySqlParser.RULE_currentTimestamp); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 7356; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_CURRENT_TIMESTAMP: + case MySqlParser.KW_LOCALTIME: + case MySqlParser.KW_LOCALTIMESTAMP: + { + this.state = 7342; + _la = this.tokenStream.LA(1); + if (!(((((_la - 287)) & ~0x1F) === 0 && ((1 << (_la - 287)) & 131) !== 0))) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 7348; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1073, this.context)) { + case 1: + { + this.state = 7343; + this.match(MySqlParser.LR_BRACKET); + this.state = 7345; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (((((_la - 871)) & ~0x1F) === 0 && ((1 << (_la - 871)) & 20495) !== 0)) { + { + this.state = 7344; + this.decimalLiteral(); + } + } + this.state = 7347; + this.match(MySqlParser.RR_BRACKET); + } + break; + } + } + break; + case MySqlParser.KW_NOW: + { + this.state = 7350; + this.match(MySqlParser.KW_NOW); + this.state = 7351; + this.match(MySqlParser.LR_BRACKET); + this.state = 7353; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (((((_la - 871)) & ~0x1F) === 0 && ((1 << (_la - 871)) & 20495) !== 0)) { + { + this.state = 7352; + this.decimalLiteral(); + } + } + this.state = 7355; + this.match(MySqlParser.RR_BRACKET); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + ifExists() { + let localContext = new IfExistsContext(this.context, this.state); + this.enterRule(localContext, 754, MySqlParser.RULE_ifExists); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 7358; + this.match(MySqlParser.KW_IF); + this.state = 7359; + this.match(MySqlParser.KW_EXISTS); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + ifNotExists() { + let localContext = new IfNotExistsContext(this.context, this.state); + this.enterRule(localContext, 756, MySqlParser.RULE_ifNotExists); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 7361; + this.match(MySqlParser.KW_IF); + this.state = 7362; + this.match(MySqlParser.KW_NOT); + this.state = 7363; + this.match(MySqlParser.KW_EXISTS); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + orReplace() { + let localContext = new OrReplaceContext(this.context, this.state); + this.enterRule(localContext, 758, MySqlParser.RULE_orReplace); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 7365; + this.match(MySqlParser.KW_OR); + this.state = 7366; + this.match(MySqlParser.KW_REPLACE); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + functionCall() { + let localContext = new FunctionCallContext(this.context, this.state); + this.enterRule(localContext, 760, MySqlParser.RULE_functionCall); + try { + this.state = 7390; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1078, this.context)) { + case 1: + localContext = new SpecificFunctionCallContext(localContext); + this.enterOuterAlt(localContext, 1); + { + this.state = 7368; + this.specificFunction(); + } + break; + case 2: + localContext = new AggregateFunctionCallContext(localContext); + this.enterOuterAlt(localContext, 2); + { + this.state = 7369; + this.aggregateWindowedFunction(); + } + break; + case 3: + localContext = new NonAggregateFunctionCallContext(localContext); + this.enterOuterAlt(localContext, 3); + { + this.state = 7370; + this.nonAggregateWindowedFunction(); + } + break; + case 4: + localContext = new ScalarFunctionCallContext(localContext); + this.enterOuterAlt(localContext, 4); + { + this.state = 7371; + this.scalarFunctionName(); + this.state = 7378; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1076, this.context)) { + case 1: + { + this.state = 7372; + this.match(MySqlParser.LR_BRACKET); + this.state = 7373; + this.match(MySqlParser.RR_BRACKET); + } + break; + case 2: + { + this.state = 7374; + this.match(MySqlParser.LR_BRACKET); + this.state = 7375; + this.functionArgs(); + this.state = 7376; + this.match(MySqlParser.RR_BRACKET); + } + break; + } + } + break; + case 5: + localContext = new UdfFunctionCallContext(localContext); + this.enterOuterAlt(localContext, 5); + { + this.state = 7380; + this.functionName(); + this.state = 7387; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1077, this.context)) { + case 1: + { + this.state = 7381; + this.match(MySqlParser.LR_BRACKET); + this.state = 7382; + this.match(MySqlParser.RR_BRACKET); + } + break; + case 2: + { + this.state = 7383; + this.match(MySqlParser.LR_BRACKET); + this.state = 7384; + this.functionArgs(); + this.state = 7385; + this.match(MySqlParser.RR_BRACKET); + } + break; + } + } + break; + case 6: + localContext = new PasswordFunctionCallContext(localContext); + this.enterOuterAlt(localContext, 6); + { + this.state = 7389; + this.passwordFunctionClause(); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + specificFunction() { + let localContext = new SpecificFunctionContext(this.context, this.state); + this.enterRule(localContext, 762, MySqlParser.RULE_specificFunction); + let _la; + try { + this.state = 7571; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1102, this.context)) { + case 1: + localContext = new SimpleFunctionCallContext(localContext); + this.enterOuterAlt(localContext, 1); + { + this.state = 7392; + _la = this.tokenStream.LA(1); + if (!(_la === 152 || ((((_la - 285)) & ~0x1F) === 0 && ((1 << (_la - 285)) & 262159) !== 0))) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 7395; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1079, this.context)) { + case 1: + { + this.state = 7393; + this.match(MySqlParser.LR_BRACKET); + this.state = 7394; + this.match(MySqlParser.RR_BRACKET); + } + break; + } + } + break; + case 2: + localContext = new CurrentUserContext(localContext); + this.enterOuterAlt(localContext, 2); + { + this.state = 7397; + this.currentUserExpression(); + } + break; + case 3: + localContext = new DataTypeFunctionCallContext(localContext); + this.enterOuterAlt(localContext, 3); + { + this.state = 7398; + this.match(MySqlParser.KW_CONVERT); + this.state = 7399; + this.match(MySqlParser.LR_BRACKET); + this.state = 7400; + this.expression(0); + this.state = 7401; + localContext._separator = this.match(MySqlParser.COMMA); + this.state = 7402; + this.convertedDataType(); + this.state = 7403; + this.match(MySqlParser.RR_BRACKET); + } + break; + case 4: + localContext = new DataTypeFunctionCallContext(localContext); + this.enterOuterAlt(localContext, 4); + { + this.state = 7405; + this.match(MySqlParser.KW_CONVERT); + this.state = 7406; + this.match(MySqlParser.LR_BRACKET); + this.state = 7407; + this.expression(0); + this.state = 7408; + this.match(MySqlParser.KW_USING); + this.state = 7409; + this.charsetName(); + this.state = 7410; + this.match(MySqlParser.RR_BRACKET); + } + break; + case 5: + localContext = new DataTypeFunctionCallContext(localContext); + this.enterOuterAlt(localContext, 5); + { + this.state = 7412; + this.match(MySqlParser.KW_CAST); + this.state = 7413; + this.match(MySqlParser.LR_BRACKET); + this.state = 7414; + this.expression(0); + this.state = 7415; + this.match(MySqlParser.KW_AS); + this.state = 7416; + this.convertedDataType(); + this.state = 7417; + this.match(MySqlParser.RR_BRACKET); + } + break; + case 6: + localContext = new ValuesFunctionCallContext(localContext); + this.enterOuterAlt(localContext, 6); + { + this.state = 7419; + this.match(MySqlParser.KW_VALUES); + this.state = 7420; + this.match(MySqlParser.LR_BRACKET); + this.state = 7421; + this.columnName(); + this.state = 7422; + this.match(MySqlParser.RR_BRACKET); + } + break; + case 7: + localContext = new CaseFunctionCallContext(localContext); + this.enterOuterAlt(localContext, 7); + { + this.state = 7424; + this.match(MySqlParser.KW_CASE); + this.state = 7426; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + do { + { + { + this.state = 7425; + this.caseFuncAlternative(); + } + } + this.state = 7428; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } while (_la === 191); + this.state = 7432; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 53) { + { + this.state = 7430; + this.match(MySqlParser.KW_ELSE); + this.state = 7431; + localContext._elseArg = this.functionArg(); + } + } + this.state = 7434; + this.match(MySqlParser.KW_END); + } + break; + case 8: + localContext = new CaseExpressionFunctionCallContext(localContext); + this.enterOuterAlt(localContext, 8); + { + this.state = 7436; + this.match(MySqlParser.KW_CASE); + this.state = 7437; + this.expression(0); + this.state = 7439; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + do { + { + { + this.state = 7438; + this.caseFuncAlternative(); + } + } + this.state = 7441; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } while (_la === 191); + this.state = 7445; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 53) { + { + this.state = 7443; + this.match(MySqlParser.KW_ELSE); + this.state = 7444; + localContext._elseArg = this.functionArg(); + } + } + this.state = 7447; + this.match(MySqlParser.KW_END); + } + break; + case 9: + localContext = new CharFunctionCallContext(localContext); + this.enterOuterAlt(localContext, 9); + { + this.state = 7449; + this.match(MySqlParser.KW_CHAR); + this.state = 7450; + this.match(MySqlParser.LR_BRACKET); + this.state = 7451; + this.functionArgs(); + this.state = 7454; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 188) { + { + this.state = 7452; + this.match(MySqlParser.KW_USING); + this.state = 7453; + this.charsetName(); + } + } + this.state = 7456; + this.match(MySqlParser.RR_BRACKET); + } + break; + case 10: + localContext = new PositionFunctionCallContext(localContext); + this.enterOuterAlt(localContext, 10); + { + this.state = 7458; + this.match(MySqlParser.KW_POSITION); + this.state = 7459; + this.match(MySqlParser.LR_BRACKET); + this.state = 7462; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1085, this.context)) { + case 1: + { + this.state = 7460; + localContext._positionString = this.stringLiteral(); + } + break; + case 2: + { + this.state = 7461; + localContext._positionExpression = this.expression(0); + } + break; + } + this.state = 7464; + this.match(MySqlParser.KW_IN); + this.state = 7467; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1086, this.context)) { + case 1: + { + this.state = 7465; + localContext._inString = this.stringLiteral(); + } + break; + case 2: + { + this.state = 7466; + localContext._inExpression = this.expression(0); + } + break; + } + this.state = 7469; + this.match(MySqlParser.RR_BRACKET); + } + break; + case 11: + localContext = new SubstrFunctionCallContext(localContext); + this.enterOuterAlt(localContext, 11); + { + this.state = 7471; + _la = this.tokenStream.LA(1); + if (!(_la === 297 || _la === 298)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 7472; + this.match(MySqlParser.LR_BRACKET); + this.state = 7475; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1087, this.context)) { + case 1: + { + this.state = 7473; + localContext._sourceString = this.stringLiteral(); + } + break; + case 2: + { + this.state = 7474; + localContext._sourceExpression = this.expression(0); + } + break; + } + this.state = 7477; + this.match(MySqlParser.KW_FROM); + this.state = 7480; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1088, this.context)) { + case 1: + { + this.state = 7478; + localContext._fromDecimal = this.decimalLiteral(); + } + break; + case 2: + { + this.state = 7479; + localContext._fromExpression = this.expression(0); + } + break; + } + this.state = 7487; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 65) { + { + this.state = 7482; + this.match(MySqlParser.KW_FOR); + this.state = 7485; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1089, this.context)) { + case 1: + { + this.state = 7483; + localContext._forDecimal = this.decimalLiteral(); + } + break; + case 2: + { + this.state = 7484; + localContext._forExpression = this.expression(0); + } + break; + } + } + } + this.state = 7489; + this.match(MySqlParser.RR_BRACKET); + } + break; + case 12: + localContext = new TrimFunctionCallContext(localContext); + this.enterOuterAlt(localContext, 12); + { + this.state = 7491; + this.match(MySqlParser.KW_TRIM); + this.state = 7492; + this.match(MySqlParser.LR_BRACKET); + this.state = 7493; + localContext._positioinForm = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 18 || _la === 96 || _la === 177)) { + localContext._positioinForm = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 7496; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1091, this.context)) { + case 1: + { + this.state = 7494; + localContext._sourceString = this.stringLiteral(); + } + break; + case 2: + { + this.state = 7495; + localContext._sourceExpression = this.expression(0); + } + break; + } + this.state = 7498; + this.match(MySqlParser.KW_FROM); + this.state = 7501; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1092, this.context)) { + case 1: + { + this.state = 7499; + localContext._fromString = this.stringLiteral(); + } + break; + case 2: + { + this.state = 7500; + localContext._fromExpression = this.expression(0); + } + break; + } + this.state = 7503; + this.match(MySqlParser.RR_BRACKET); + } + break; + case 13: + localContext = new TrimFunctionCallContext(localContext); + this.enterOuterAlt(localContext, 13); + { + this.state = 7505; + this.match(MySqlParser.KW_TRIM); + this.state = 7506; + this.match(MySqlParser.LR_BRACKET); + this.state = 7509; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1093, this.context)) { + case 1: + { + this.state = 7507; + localContext._sourceString = this.stringLiteral(); + } + break; + case 2: + { + this.state = 7508; + localContext._sourceExpression = this.expression(0); + } + break; + } + this.state = 7511; + this.match(MySqlParser.KW_FROM); + this.state = 7514; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1094, this.context)) { + case 1: + { + this.state = 7512; + localContext._fromString = this.stringLiteral(); + } + break; + case 2: + { + this.state = 7513; + localContext._fromExpression = this.expression(0); + } + break; + } + this.state = 7516; + this.match(MySqlParser.RR_BRACKET); + } + break; + case 14: + localContext = new WeightFunctionCallContext(localContext); + this.enterOuterAlt(localContext, 14); + { + this.state = 7518; + this.match(MySqlParser.KW_WEIGHT_STRING); + this.state = 7519; + this.match(MySqlParser.LR_BRACKET); + this.state = 7522; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1095, this.context)) { + case 1: + { + this.state = 7520; + this.stringLiteral(); + } + break; + case 2: + { + this.state = 7521; + this.expression(0); + } + break; + } + this.state = 7530; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 13) { + { + this.state = 7524; + this.match(MySqlParser.KW_AS); + this.state = 7525; + localContext._stringFormat = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 224 || _la === 228)) { + localContext._stringFormat = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 7526; + this.match(MySqlParser.LR_BRACKET); + this.state = 7527; + this.decimalLiteral(); + this.state = 7528; + this.match(MySqlParser.RR_BRACKET); + } + } + this.state = 7533; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 448) { + { + this.state = 7532; + this.levelsInWeightString(); + } + } + this.state = 7535; + this.match(MySqlParser.RR_BRACKET); + } + break; + case 15: + localContext = new ExtractFunctionCallContext(localContext); + this.enterOuterAlt(localContext, 15); + { + this.state = 7537; + this.match(MySqlParser.KW_EXTRACT); + this.state = 7538; + this.match(MySqlParser.LR_BRACKET); + this.state = 7539; + this.intervalType(); + this.state = 7540; + this.match(MySqlParser.KW_FROM); + this.state = 7543; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1098, this.context)) { + case 1: + { + this.state = 7541; + localContext._sourceString = this.stringLiteral(); + } + break; + case 2: + { + this.state = 7542; + localContext._sourceExpression = this.expression(0); + } + break; + } + this.state = 7545; + this.match(MySqlParser.RR_BRACKET); + } + break; + case 16: + localContext = new GetFormatFunctionCallContext(localContext); + this.enterOuterAlt(localContext, 16); + { + this.state = 7547; + this.match(MySqlParser.KW_GET_FORMAT); + this.state = 7548; + this.match(MySqlParser.LR_BRACKET); + this.state = 7549; + localContext._datetimeFormat = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(((((_la - 219)) & ~0x1F) === 0 && ((1 << (_la - 219)) & 11) !== 0))) { + localContext._datetimeFormat = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 7550; + this.match(MySqlParser.COMMA); + this.state = 7551; + this.stringLiteral(); + this.state = 7552; + this.match(MySqlParser.RR_BRACKET); + } + break; + case 17: + localContext = new JsonValueFunctionCallContext(localContext); + this.enterOuterAlt(localContext, 17); + { + this.state = 7554; + this.match(MySqlParser.KW_JSON_VALUE); + this.state = 7555; + this.match(MySqlParser.LR_BRACKET); + this.state = 7556; + this.expression(0); + this.state = 7557; + this.match(MySqlParser.COMMA); + this.state = 7558; + this.expression(0); + this.state = 7561; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 579) { + { + this.state = 7559; + this.match(MySqlParser.KW_RETURNING); + this.state = 7560; + this.convertedDataType(); + } + } + this.state = 7564; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1100, this.context)) { + case 1: + { + this.state = 7563; + this.jsonOnEmpty(); + } + break; + } + this.state = 7567; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 42 || _la === 116 || _la === 382) { + { + this.state = 7566; + this.jsonOnError(); + } + } + this.state = 7569; + this.match(MySqlParser.RR_BRACKET); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + caseFuncAlternative() { + let localContext = new CaseFuncAlternativeContext(this.context, this.state); + this.enterRule(localContext, 764, MySqlParser.RULE_caseFuncAlternative); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 7573; + this.match(MySqlParser.KW_WHEN); + this.state = 7574; + localContext._condition = this.functionArg(); + this.state = 7575; + this.match(MySqlParser.KW_THEN); + this.state = 7576; + localContext._consequent = this.functionArg(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + levelsInWeightString() { + let localContext = new LevelsInWeightStringContext(this.context, this.state); + this.enterRule(localContext, 766, MySqlParser.RULE_levelsInWeightString); + let _la; + try { + this.state = 7592; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1104, this.context)) { + case 1: + localContext = new LevelWeightListContext(localContext); + this.enterOuterAlt(localContext, 1); + { + this.state = 7578; + this.match(MySqlParser.KW_LEVEL); + this.state = 7579; + this.levelInWeightListElement(); + this.state = 7584; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 7580; + this.match(MySqlParser.COMMA); + this.state = 7581; + this.levelInWeightListElement(); + } + } + this.state = 7586; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + break; + case 2: + localContext = new LevelWeightRangeContext(localContext); + this.enterOuterAlt(localContext, 2); + { + this.state = 7587; + this.match(MySqlParser.KW_LEVEL); + this.state = 7588; + localContext._firstLevel = this.decimalLiteral(); + this.state = 7589; + this.match(MySqlParser.MINUS); + this.state = 7590; + localContext._lastLevel = this.decimalLiteral(); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + levelInWeightListElement() { + let localContext = new LevelInWeightListElementContext(this.context, this.state); + this.enterRule(localContext, 768, MySqlParser.RULE_levelInWeightListElement); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 7594; + this.decimalLiteral(); + this.state = 7596; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 14 || _la === 45 || _la === 830) { + { + this.state = 7595; + localContext._orderType = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 14 || _la === 45 || _la === 830)) { + localContext._orderType = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + aggregateWindowedFunction() { + let localContext = new AggregateWindowedFunctionContext(this.context, this.state); + this.enterRule(localContext, 770, MySqlParser.RULE_aggregateWindowedFunction); + let _la; + try { + this.state = 7657; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_AVG: + case MySqlParser.KW_MAX: + case MySqlParser.KW_MIN: + case MySqlParser.KW_SUM: + this.enterOuterAlt(localContext, 1); + { + this.state = 7598; + _la = this.tokenStream.LA(1); + if (!(((((_la - 258)) & ~0x1F) === 0 && ((1 << (_la - 258)) & 8400897) !== 0))) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 7599; + this.match(MySqlParser.LR_BRACKET); + this.state = 7601; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1106, this.context)) { + case 1: + { + this.state = 7600; + localContext._aggregator = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 7 || _la === 49)) { + localContext._aggregator = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + break; + } + this.state = 7603; + this.functionArg(); + this.state = 7604; + this.match(MySqlParser.RR_BRACKET); + this.state = 7606; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1107, this.context)) { + case 1: + { + this.state = 7605; + this.overClause(); + } + break; + } + } + break; + case MySqlParser.KW_COUNT: + this.enterOuterAlt(localContext, 2); + { + this.state = 7608; + this.match(MySqlParser.KW_COUNT); + this.state = 7609; + this.match(MySqlParser.LR_BRACKET); + this.state = 7617; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1109, this.context)) { + case 1: + { + this.state = 7610; + localContext._starArg = this.match(MySqlParser.STAR); + } + break; + case 2: + { + this.state = 7612; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1108, this.context)) { + case 1: + { + this.state = 7611; + localContext._aggregator = this.match(MySqlParser.KW_ALL); + } + break; + } + this.state = 7614; + this.functionArg(); + } + break; + case 3: + { + this.state = 7615; + localContext._aggregator = this.match(MySqlParser.KW_DISTINCT); + this.state = 7616; + this.functionArgs(); + } + break; + } + this.state = 7619; + this.match(MySqlParser.RR_BRACKET); + this.state = 7621; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1110, this.context)) { + case 1: + { + this.state = 7620; + this.overClause(); + } + break; + } + } + break; + case MySqlParser.KW_BIT_AND: + case MySqlParser.KW_BIT_OR: + case MySqlParser.KW_BIT_XOR: + case MySqlParser.KW_STD: + case MySqlParser.KW_STDDEV: + case MySqlParser.KW_STDDEV_POP: + case MySqlParser.KW_STDDEV_SAMP: + case MySqlParser.KW_VAR_POP: + case MySqlParser.KW_VAR_SAMP: + case MySqlParser.KW_VARIANCE: + this.enterOuterAlt(localContext, 3); + { + this.state = 7623; + _la = this.tokenStream.LA(1); + if (!(((((_la - 259)) & ~0x1F) === 0 && ((1 << (_la - 259)) & 62652423) !== 0))) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 7624; + this.match(MySqlParser.LR_BRACKET); + this.state = 7626; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1111, this.context)) { + case 1: + { + this.state = 7625; + localContext._aggregator = this.match(MySqlParser.KW_ALL); + } + break; + } + this.state = 7628; + this.functionArg(); + this.state = 7629; + this.match(MySqlParser.RR_BRACKET); + this.state = 7631; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1112, this.context)) { + case 1: + { + this.state = 7630; + this.overClause(); + } + break; + } + } + break; + case MySqlParser.KW_GROUP_CONCAT: + this.enterOuterAlt(localContext, 4); + { + this.state = 7633; + this.match(MySqlParser.KW_GROUP_CONCAT); + this.state = 7634; + this.match(MySqlParser.LR_BRACKET); + this.state = 7636; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1113, this.context)) { + case 1: + { + this.state = 7635; + localContext._aggregator = this.match(MySqlParser.KW_DISTINCT); + } + break; + } + this.state = 7638; + this.functionArgs(); + this.state = 7649; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 125) { + { + this.state = 7639; + this.match(MySqlParser.KW_ORDER); + this.state = 7640; + this.match(MySqlParser.KW_BY); + this.state = 7641; + this.orderByExpression(); + this.state = 7646; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 7642; + this.match(MySqlParser.COMMA); + this.state = 7643; + this.orderByExpression(); + } + } + this.state = 7648; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + } + this.state = 7653; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 156) { + { + this.state = 7651; + this.match(MySqlParser.KW_SEPARATOR); + this.state = 7652; + localContext._separator = this.match(MySqlParser.STRING_LITERAL); + } + } + this.state = 7655; + this.match(MySqlParser.RR_BRACKET); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + nonAggregateWindowedFunction() { + let localContext = new NonAggregateWindowedFunctionContext(this.context, this.state); + this.enterRule(localContext, 772, MySqlParser.RULE_nonAggregateWindowedFunction); + let _la; + try { + this.state = 7697; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_LAG: + case MySqlParser.KW_LEAD: + this.enterOuterAlt(localContext, 1); + { + this.state = 7659; + _la = this.tokenStream.LA(1); + if (!(_la === 267 || _la === 269)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 7660; + this.match(MySqlParser.LR_BRACKET); + this.state = 7661; + this.expression(0); + this.state = 7664; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1118, this.context)) { + case 1: + { + this.state = 7662; + this.match(MySqlParser.COMMA); + this.state = 7663; + this.decimalLiteral(); + } + break; + } + this.state = 7668; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 868) { + { + this.state = 7666; + this.match(MySqlParser.COMMA); + this.state = 7667; + this.decimalLiteral(); + } + } + this.state = 7670; + this.match(MySqlParser.RR_BRACKET); + this.state = 7671; + this.overClause(); + } + break; + case MySqlParser.KW_FIRST_VALUE: + case MySqlParser.KW_LAST_VALUE: + this.enterOuterAlt(localContext, 2); + { + this.state = 7673; + _la = this.tokenStream.LA(1); + if (!(_la === 265 || _la === 268)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 7674; + this.match(MySqlParser.LR_BRACKET); + this.state = 7675; + this.expression(0); + this.state = 7676; + this.match(MySqlParser.RR_BRACKET); + this.state = 7677; + this.overClause(); + } + break; + case MySqlParser.KW_CUME_DIST: + case MySqlParser.KW_DENSE_RANK: + case MySqlParser.KW_PERCENT_RANK: + case MySqlParser.KW_RANK: + case MySqlParser.KW_ROW_NUMBER: + this.enterOuterAlt(localContext, 3); + { + this.state = 7679; + _la = this.tokenStream.LA(1); + if (!(((((_la - 263)) & ~0x1F) === 0 && ((1 << (_la - 263)) & 14339) !== 0))) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 7680; + this.match(MySqlParser.LR_BRACKET); + this.state = 7681; + this.match(MySqlParser.RR_BRACKET); + this.state = 7682; + this.overClause(); + } + break; + case MySqlParser.KW_NTH_VALUE: + this.enterOuterAlt(localContext, 4); + { + this.state = 7683; + this.match(MySqlParser.KW_NTH_VALUE); + this.state = 7684; + this.match(MySqlParser.LR_BRACKET); + this.state = 7685; + this.expression(0); + this.state = 7686; + this.match(MySqlParser.COMMA); + this.state = 7687; + this.decimalLiteral(); + this.state = 7688; + this.match(MySqlParser.RR_BRACKET); + this.state = 7689; + this.overClause(); + } + break; + case MySqlParser.KW_NTILE: + this.enterOuterAlt(localContext, 5); + { + this.state = 7691; + this.match(MySqlParser.KW_NTILE); + this.state = 7692; + this.match(MySqlParser.LR_BRACKET); + this.state = 7693; + this.decimalLiteral(); + this.state = 7694; + this.match(MySqlParser.RR_BRACKET); + this.state = 7695; + this.overClause(); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + overClause() { + let localContext = new OverClauseContext(this.context, this.state); + this.enterRule(localContext, 774, MySqlParser.RULE_overClause); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 7699; + this.match(MySqlParser.KW_OVER); + this.state = 7705; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.LR_BRACKET: + { + this.state = 7700; + this.match(MySqlParser.LR_BRACKET); + this.state = 7701; + this.windowSpec(); + this.state = 7702; + this.match(MySqlParser.RR_BRACKET); + } + break; + case MySqlParser.KW_ARRAY: + case MySqlParser.KW_ATTRIBUTE: + case MySqlParser.KW_BUCKETS: + case MySqlParser.KW_CONDITION: + case MySqlParser.KW_CURRENT: + case MySqlParser.KW_CURRENT_USER: + case MySqlParser.KW_DATABASE: + case MySqlParser.KW_DEFAULT: + case MySqlParser.KW_DIAGNOSTICS: + case MySqlParser.KW_EMPTY: + case MySqlParser.KW_ENFORCED: + case MySqlParser.KW_EXCEPT: + case MySqlParser.KW_GROUP: + case MySqlParser.KW_IF: + case MySqlParser.KW_INSERT: + case MySqlParser.KW_LATERAL: + case MySqlParser.KW_LEFT: + case MySqlParser.KW_NUMBER: + case MySqlParser.KW_OPTIONAL: + case MySqlParser.KW_ORDER: + case MySqlParser.KW_PRIMARY: + case MySqlParser.KW_REPEAT: + case MySqlParser.KW_REPLACE: + case MySqlParser.KW_RIGHT: + case MySqlParser.KW_SCHEMA: + case MySqlParser.KW_SKIP_QUERY_REWRITE: + case MySqlParser.KW_STACKED: + case MySqlParser.KW_DATE: + case MySqlParser.KW_TIME: + case MySqlParser.KW_TIMESTAMP: + case MySqlParser.KW_DATETIME: + case MySqlParser.KW_YEAR: + case MySqlParser.KW_BINARY: + case MySqlParser.KW_TEXT: + case MySqlParser.KW_ENUM: + case MySqlParser.KW_SERIAL: + case MySqlParser.KW_JSON_TABLE: + case MySqlParser.KW_JSON_VALUE: + case MySqlParser.KW_NESTED: + case MySqlParser.KW_ORDINALITY: + case MySqlParser.KW_PATH: + case MySqlParser.KW_AVG: + case MySqlParser.KW_BIT_AND: + case MySqlParser.KW_BIT_OR: + case MySqlParser.KW_BIT_XOR: + case MySqlParser.KW_COUNT: + case MySqlParser.KW_CUME_DIST: + case MySqlParser.KW_DENSE_RANK: + case MySqlParser.KW_FIRST_VALUE: + case MySqlParser.KW_GROUP_CONCAT: + case MySqlParser.KW_LAG: + case MySqlParser.KW_LAST_VALUE: + case MySqlParser.KW_LEAD: + case MySqlParser.KW_MAX: + case MySqlParser.KW_MIN: + case MySqlParser.KW_NTILE: + case MySqlParser.KW_NTH_VALUE: + case MySqlParser.KW_PERCENT_RANK: + case MySqlParser.KW_RANK: + case MySqlParser.KW_ROW_NUMBER: + case MySqlParser.KW_STD: + case MySqlParser.KW_STDDEV: + case MySqlParser.KW_STDDEV_POP: + case MySqlParser.KW_STDDEV_SAMP: + case MySqlParser.KW_SUM: + case MySqlParser.KW_VAR_POP: + case MySqlParser.KW_VAR_SAMP: + case MySqlParser.KW_VARIANCE: + case MySqlParser.KW_CURRENT_DATE: + case MySqlParser.KW_CURRENT_TIME: + case MySqlParser.KW_CURRENT_TIMESTAMP: + case MySqlParser.KW_LOCALTIME: + case MySqlParser.KW_CURDATE: + case MySqlParser.KW_CURTIME: + case MySqlParser.KW_DATE_ADD: + case MySqlParser.KW_DATE_SUB: + case MySqlParser.KW_LOCALTIMESTAMP: + case MySqlParser.KW_NOW: + case MySqlParser.KW_POSITION: + case MySqlParser.KW_SUBSTR: + case MySqlParser.KW_SUBSTRING: + case MySqlParser.KW_SYSDATE: + case MySqlParser.KW_TRIM: + case MySqlParser.KW_UTC_DATE: + case MySqlParser.KW_UTC_TIME: + case MySqlParser.KW_UTC_TIMESTAMP: + case MySqlParser.KW_ACCOUNT: + case MySqlParser.KW_ACTION: + case MySqlParser.KW_AFTER: + case MySqlParser.KW_AGGREGATE: + case MySqlParser.KW_ALGORITHM: + case MySqlParser.KW_ANY: + case MySqlParser.KW_AT: + case MySqlParser.KW_AUTHORS: + case MySqlParser.KW_AUTOCOMMIT: + case MySqlParser.KW_AUTOEXTEND_SIZE: + case MySqlParser.KW_AUTO_INCREMENT: + case MySqlParser.KW_AVG_ROW_LENGTH: + case MySqlParser.KW_BEGIN: + case MySqlParser.KW_BINLOG: + case MySqlParser.KW_BIT: + case MySqlParser.KW_BLOCK: + case MySqlParser.KW_BOOL: + case MySqlParser.KW_BOOLEAN: + case MySqlParser.KW_BTREE: + case MySqlParser.KW_CACHE: + case MySqlParser.KW_CASCADED: + case MySqlParser.KW_CHAIN: + case MySqlParser.KW_CHANGED: + case MySqlParser.KW_CHANNEL: + case MySqlParser.KW_CHECKSUM: + case MySqlParser.KW_CIPHER: + case MySqlParser.KW_CLASS_ORIGIN: + case MySqlParser.KW_CLIENT: + case MySqlParser.KW_CLOSE: + case MySqlParser.KW_COALESCE: + case MySqlParser.KW_CODE: + case MySqlParser.KW_COLUMNS: + case MySqlParser.KW_COLUMN_FORMAT: + case MySqlParser.KW_COLUMN_NAME: + case MySqlParser.KW_COMMENT: + case MySqlParser.KW_COMMIT: + case MySqlParser.KW_COMPACT: + case MySqlParser.KW_COMPLETION: + case MySqlParser.KW_COMPRESSED: + case MySqlParser.KW_COMPRESSION: + case MySqlParser.KW_CONCURRENT: + case MySqlParser.KW_CONNECT: + case MySqlParser.KW_CONNECTION: + case MySqlParser.KW_CONSISTENT: + case MySqlParser.KW_CONSTRAINT_CATALOG: + case MySqlParser.KW_CONSTRAINT_SCHEMA: + case MySqlParser.KW_CONSTRAINT_NAME: + case MySqlParser.KW_CONTAINS: + case MySqlParser.KW_CONTEXT: + case MySqlParser.KW_CONTRIBUTORS: + case MySqlParser.KW_COPY: + case MySqlParser.KW_CPU: + case MySqlParser.KW_CURSOR_NAME: + case MySqlParser.KW_DATA: + case MySqlParser.KW_DATAFILE: + case MySqlParser.KW_DEALLOCATE: + case MySqlParser.KW_DEFAULT_AUTH: + case MySqlParser.KW_DEFINER: + case MySqlParser.KW_DELAY_KEY_WRITE: + case MySqlParser.KW_DES_KEY_FILE: + case MySqlParser.KW_DIRECTORY: + case MySqlParser.KW_DISABLE: + case MySqlParser.KW_DISCARD: + case MySqlParser.KW_DISK: + case MySqlParser.KW_DO: + case MySqlParser.KW_DUMPFILE: + case MySqlParser.KW_DUPLICATE: + case MySqlParser.KW_DYNAMIC: + case MySqlParser.KW_ENABLE: + case MySqlParser.KW_ENCRYPTION: + case MySqlParser.KW_END: + case MySqlParser.KW_ENDS: + case MySqlParser.KW_ENGINE: + case MySqlParser.KW_ENGINES: + case MySqlParser.KW_ERROR: + case MySqlParser.KW_ERRORS: + case MySqlParser.KW_ESCAPE: + case MySqlParser.KW_EVENT: + case MySqlParser.KW_EVENTS: + case MySqlParser.KW_EVERY: + case MySqlParser.KW_EXCHANGE: + case MySqlParser.KW_EXCLUSIVE: + case MySqlParser.KW_EXPIRE: + case MySqlParser.KW_EXPORT: + case MySqlParser.KW_EXTENDED: + case MySqlParser.KW_EXTENT_SIZE: + case MySqlParser.KW_FAILED_LOGIN_ATTEMPTS: + case MySqlParser.KW_FAST: + case MySqlParser.KW_FAULTS: + case MySqlParser.KW_FIELDS: + case MySqlParser.KW_FILE_BLOCK_SIZE: + case MySqlParser.KW_FILTER: + case MySqlParser.KW_FIRST: + case MySqlParser.KW_FIXED: + case MySqlParser.KW_FLUSH: + case MySqlParser.KW_FOLLOWS: + case MySqlParser.KW_FOUND: + case MySqlParser.KW_FULL: + case MySqlParser.KW_FUNCTION: + case MySqlParser.KW_GENERAL: + case MySqlParser.KW_GLOBAL: + case MySqlParser.KW_GRANTS: + case MySqlParser.KW_GROUP_REPLICATION: + case MySqlParser.KW_HANDLER: + case MySqlParser.KW_HASH: + case MySqlParser.KW_HELP: + case MySqlParser.KW_HISTORY: + case MySqlParser.KW_HOST: + case MySqlParser.KW_HOSTS: + case MySqlParser.KW_IDENTIFIED: + case MySqlParser.KW_IGNORE_SERVER_IDS: + case MySqlParser.KW_IMPORT: + case MySqlParser.KW_INDEXES: + case MySqlParser.KW_INITIAL_SIZE: + case MySqlParser.KW_INPLACE: + case MySqlParser.KW_INSERT_METHOD: + case MySqlParser.KW_INSTALL: + case MySqlParser.KW_INSTANCE: + case MySqlParser.KW_INSTANT: + case MySqlParser.KW_INVISIBLE: + case MySqlParser.KW_INVOKER: + case MySqlParser.KW_IO: + case MySqlParser.KW_IO_THREAD: + case MySqlParser.KW_IPC: + case MySqlParser.KW_ISOLATION: + case MySqlParser.KW_ISSUER: + case MySqlParser.KW_JSON: + case MySqlParser.KW_KEY_BLOCK_SIZE: + case MySqlParser.KW_LANGUAGE: + case MySqlParser.KW_LAST: + case MySqlParser.KW_LEAVES: + case MySqlParser.KW_LESS: + case MySqlParser.KW_LEVEL: + case MySqlParser.KW_LIST: + case MySqlParser.KW_LOCAL: + case MySqlParser.KW_LOGFILE: + case MySqlParser.KW_LOGS: + case MySqlParser.KW_MASTER: + case MySqlParser.KW_MASTER_AUTO_POSITION: + case MySqlParser.KW_MASTER_CONNECT_RETRY: + case MySqlParser.KW_MASTER_DELAY: + case MySqlParser.KW_MASTER_HEARTBEAT_PERIOD: + case MySqlParser.KW_MASTER_HOST: + case MySqlParser.KW_MASTER_LOG_FILE: + case MySqlParser.KW_MASTER_LOG_POS: + case MySqlParser.KW_MASTER_PASSWORD: + case MySqlParser.KW_MASTER_PORT: + case MySqlParser.KW_MASTER_RETRY_COUNT: + case MySqlParser.KW_MASTER_SSL: + case MySqlParser.KW_MASTER_SSL_CA: + case MySqlParser.KW_MASTER_SSL_CAPATH: + case MySqlParser.KW_MASTER_SSL_CERT: + case MySqlParser.KW_MASTER_SSL_CIPHER: + case MySqlParser.KW_MASTER_SSL_CRL: + case MySqlParser.KW_MASTER_SSL_CRLPATH: + case MySqlParser.KW_MASTER_SSL_KEY: + case MySqlParser.KW_MASTER_TLS_VERSION: + case MySqlParser.KW_MASTER_USER: + case MySqlParser.KW_MAX_CONNECTIONS_PER_HOUR: + case MySqlParser.KW_MAX_QUERIES_PER_HOUR: + case MySqlParser.KW_MAX_ROWS: + case MySqlParser.KW_MAX_SIZE: + case MySqlParser.KW_MAX_UPDATES_PER_HOUR: + case MySqlParser.KW_MAX_USER_CONNECTIONS: + case MySqlParser.KW_MEDIUM: + case MySqlParser.KW_MEMBER: + case MySqlParser.KW_MERGE: + case MySqlParser.KW_MESSAGE_TEXT: + case MySqlParser.KW_MID: + case MySqlParser.KW_MIGRATE: + case MySqlParser.KW_MIN_ROWS: + case MySqlParser.KW_MODE: + case MySqlParser.KW_MODIFY: + case MySqlParser.KW_MUTEX: + case MySqlParser.KW_MYSQL: + case MySqlParser.KW_MYSQL_ERRNO: + case MySqlParser.KW_NAME: + case MySqlParser.KW_NAMES: + case MySqlParser.KW_NCHAR: + case MySqlParser.KW_NEVER: + case MySqlParser.KW_NEXT: + case MySqlParser.KW_NO: + case MySqlParser.KW_NOWAIT: + case MySqlParser.KW_NODEGROUP: + case MySqlParser.KW_NONE: + case MySqlParser.KW_ODBC: + case MySqlParser.KW_OFFLINE: + case MySqlParser.KW_OFFSET: + case MySqlParser.KW_OF: + case MySqlParser.KW_OLD_PASSWORD: + case MySqlParser.KW_ONE: + case MySqlParser.KW_ONLINE: + case MySqlParser.KW_ONLY: + case MySqlParser.KW_OPEN: + case MySqlParser.KW_OPTIMIZER_COSTS: + case MySqlParser.KW_OPTIONS: + case MySqlParser.KW_OWNER: + case MySqlParser.KW_PACK_KEYS: + case MySqlParser.KW_PAGE: + case MySqlParser.KW_PAGE_CHECKSUM: + case MySqlParser.KW_PARSER: + case MySqlParser.KW_PARTIAL: + case MySqlParser.KW_PARTITIONING: + case MySqlParser.KW_PARTITIONS: + case MySqlParser.KW_PASSWORD: + case MySqlParser.KW_PASSWORD_LOCK_TIME: + case MySqlParser.KW_PHASE: + case MySqlParser.KW_PLUGIN: + case MySqlParser.KW_PLUGIN_DIR: + case MySqlParser.KW_PLUGINS: + case MySqlParser.KW_PORT: + case MySqlParser.KW_PRECEDES: + case MySqlParser.KW_PREPARE: + case MySqlParser.KW_PRESERVE: + case MySqlParser.KW_PREV: + case MySqlParser.KW_PROCESSLIST: + case MySqlParser.KW_PROFILE: + case MySqlParser.KW_PROFILES: + case MySqlParser.KW_PROXY: + case MySqlParser.KW_QUERY: + case MySqlParser.KW_QUICK: + case MySqlParser.KW_REBUILD: + case MySqlParser.KW_RECOVER: + case MySqlParser.KW_RECURSIVE: + case MySqlParser.KW_REDO_BUFFER_SIZE: + case MySqlParser.KW_REDUNDANT: + case MySqlParser.KW_RELAY: + case MySqlParser.KW_RELAY_LOG_FILE: + case MySqlParser.KW_RELAY_LOG_POS: + case MySqlParser.KW_RELAYLOG: + case MySqlParser.KW_REMOVE: + case MySqlParser.KW_REORGANIZE: + case MySqlParser.KW_REPAIR: + case MySqlParser.KW_REPLICATE_DO_DB: + case MySqlParser.KW_REPLICATE_DO_TABLE: + case MySqlParser.KW_REPLICATE_IGNORE_DB: + case MySqlParser.KW_REPLICATE_IGNORE_TABLE: + case MySqlParser.KW_REPLICATE_REWRITE_DB: + case MySqlParser.KW_REPLICATE_WILD_DO_TABLE: + case MySqlParser.KW_REPLICATE_WILD_IGNORE_TABLE: + case MySqlParser.KW_REPLICATION: + case MySqlParser.KW_RESET: + case MySqlParser.KW_RESUME: + case MySqlParser.KW_RETURNED_SQLSTATE: + case MySqlParser.KW_RETURNS: + case MySqlParser.KW_REUSE: + case MySqlParser.KW_ROLE: + case MySqlParser.KW_ROLLBACK: + case MySqlParser.KW_ROLLUP: + case MySqlParser.KW_ROTATE: + case MySqlParser.KW_ROW: + case MySqlParser.KW_ROWS: + case MySqlParser.KW_ROW_FORMAT: + case MySqlParser.KW_SAVEPOINT: + case MySqlParser.KW_SCHEDULE: + case MySqlParser.KW_SECURITY: + case MySqlParser.KW_SERVER: + case MySqlParser.KW_SESSION: + case MySqlParser.KW_SHARE: + case MySqlParser.KW_SHARED: + case MySqlParser.KW_SIGNED: + case MySqlParser.KW_SIMPLE: + case MySqlParser.KW_SLAVE: + case MySqlParser.KW_SLOW: + case MySqlParser.KW_SNAPSHOT: + case MySqlParser.KW_SOCKET: + case MySqlParser.KW_SOME: + case MySqlParser.KW_SONAME: + case MySqlParser.KW_SOUNDS: + case MySqlParser.KW_SOURCE: + case MySqlParser.KW_SQL_AFTER_GTIDS: + case MySqlParser.KW_SQL_AFTER_MTS_GAPS: + case MySqlParser.KW_SQL_BEFORE_GTIDS: + case MySqlParser.KW_SQL_BUFFER_RESULT: + case MySqlParser.KW_SQL_CACHE: + case MySqlParser.KW_SQL_NO_CACHE: + case MySqlParser.KW_SQL_THREAD: + case MySqlParser.KW_START: + case MySqlParser.KW_STARTS: + case MySqlParser.KW_STATS_AUTO_RECALC: + case MySqlParser.KW_STATS_PERSISTENT: + case MySqlParser.KW_STATS_SAMPLE_PAGES: + case MySqlParser.KW_STATUS: + case MySqlParser.KW_STOP: + case MySqlParser.KW_STORAGE: + case MySqlParser.KW_STRING: + case MySqlParser.KW_SUBCLASS_ORIGIN: + case MySqlParser.KW_SUBJECT: + case MySqlParser.KW_SUBPARTITION: + case MySqlParser.KW_SUBPARTITIONS: + case MySqlParser.KW_SUSPEND: + case MySqlParser.KW_SWAPS: + case MySqlParser.KW_SWITCHES: + case MySqlParser.KW_TABLE_NAME: + case MySqlParser.KW_TABLESPACE: + case MySqlParser.KW_TABLE_TYPE: + case MySqlParser.KW_TEMPORARY: + case MySqlParser.KW_TEMPTABLE: + case MySqlParser.KW_THAN: + case MySqlParser.KW_TRADITIONAL: + case MySqlParser.KW_TRANSACTION: + case MySqlParser.KW_TRANSACTIONAL: + case MySqlParser.KW_TRIGGERS: + case MySqlParser.KW_TRUNCATE: + case MySqlParser.KW_UNBOUNDED: + case MySqlParser.KW_UNDEFINED: + case MySqlParser.KW_UNDOFILE: + case MySqlParser.KW_UNDO_BUFFER_SIZE: + case MySqlParser.KW_UNINSTALL: + case MySqlParser.KW_UNKNOWN: + case MySqlParser.KW_UNTIL: + case MySqlParser.KW_UPGRADE: + case MySqlParser.KW_USER: + case MySqlParser.KW_USE_FRM: + case MySqlParser.KW_USER_RESOURCES: + case MySqlParser.KW_VALIDATION: + case MySqlParser.KW_VALUE: + case MySqlParser.KW_VARIABLES: + case MySqlParser.KW_VIEW: + case MySqlParser.KW_VIRTUAL: + case MySqlParser.KW_VISIBLE: + case MySqlParser.KW_WAIT: + case MySqlParser.KW_WARNINGS: + case MySqlParser.KW_WITHOUT: + case MySqlParser.KW_WORK: + case MySqlParser.KW_WRAPPER: + case MySqlParser.KW_X509: + case MySqlParser.KW_XA: + case MySqlParser.KW_XML: + case MySqlParser.KW_QUARTER: + case MySqlParser.KW_MONTH: + case MySqlParser.KW_DAY: + case MySqlParser.KW_HOUR: + case MySqlParser.KW_MINUTE: + case MySqlParser.KW_WEEK: + case MySqlParser.KW_SECOND: + case MySqlParser.KW_MICROSECOND: + case MySqlParser.KW_ADMIN: + case MySqlParser.KW_AUDIT_ABORT_EXEMPT: + case MySqlParser.KW_AUDIT_ADMIN: + case MySqlParser.KW_AUTHENTICATION_POLICY_ADMIN: + case MySqlParser.KW_BACKUP_ADMIN: + case MySqlParser.KW_BINLOG_ADMIN: + case MySqlParser.KW_BINLOG_ENCRYPTION_ADMIN: + case MySqlParser.KW_CLONE_ADMIN: + case MySqlParser.KW_CONNECTION_ADMIN: + case MySqlParser.KW_ENCRYPTION_KEY_ADMIN: + case MySqlParser.KW_EXECUTE: + case MySqlParser.KW_FILE: + case MySqlParser.KW_FIREWALL_ADMIN: + case MySqlParser.KW_FIREWALL_EXEMPT: + case MySqlParser.KW_FIREWALL_USER: + case MySqlParser.KW_GROUP_REPLICATION_ADMIN: + case MySqlParser.KW_INNODB_REDO_LOG_ARCHIVE: + case MySqlParser.KW_INVOKE: + case MySqlParser.KW_LAMBDA: + case MySqlParser.KW_NDB_STORED_USER: + case MySqlParser.KW_PASSWORDLESS_USER_ADMIN: + case MySqlParser.KW_PERSIST_RO_VARIABLES_ADMIN: + case MySqlParser.KW_PRIVILEGES: + case MySqlParser.KW_PROCESS: + case MySqlParser.KW_RELOAD: + case MySqlParser.KW_REPLICATION_APPLIER: + case MySqlParser.KW_REPLICATION_SLAVE_ADMIN: + case MySqlParser.KW_RESOURCE_GROUP_ADMIN: + case MySqlParser.KW_RESOURCE_GROUP_USER: + case MySqlParser.KW_ROLE_ADMIN: + case MySqlParser.KW_ROUTINE: + case MySqlParser.KW_S3: + case MySqlParser.KW_SESSION_VARIABLES_ADMIN: + case MySqlParser.KW_SET_USER_ID: + case MySqlParser.KW_SHOW_ROUTINE: + case MySqlParser.KW_SHUTDOWN: + case MySqlParser.KW_SUPER: + case MySqlParser.KW_SYSTEM_VARIABLES_ADMIN: + case MySqlParser.KW_TABLES: + case MySqlParser.KW_TABLE_ENCRYPTION_ADMIN: + case MySqlParser.KW_VERSION_TOKEN_ADMIN: + case MySqlParser.KW_XA_RECOVER_ADMIN: + case MySqlParser.KW_ARMSCII8: + case MySqlParser.KW_ASCII: + case MySqlParser.KW_BIG5: + case MySqlParser.KW_CP1250: + case MySqlParser.KW_CP1251: + case MySqlParser.KW_CP1256: + case MySqlParser.KW_CP1257: + case MySqlParser.KW_CP850: + case MySqlParser.KW_CP852: + case MySqlParser.KW_CP866: + case MySqlParser.KW_CP932: + case MySqlParser.KW_DEC8: + case MySqlParser.KW_EUCJPMS: + case MySqlParser.KW_EUCKR: + case MySqlParser.KW_GB18030: + case MySqlParser.KW_GB2312: + case MySqlParser.KW_GBK: + case MySqlParser.KW_GEOSTD8: + case MySqlParser.KW_GREEK: + case MySqlParser.KW_HEBREW: + case MySqlParser.KW_HP8: + case MySqlParser.KW_KEYBCS2: + case MySqlParser.KW_KOI8R: + case MySqlParser.KW_KOI8U: + case MySqlParser.KW_LATIN1: + case MySqlParser.KW_LATIN2: + case MySqlParser.KW_LATIN5: + case MySqlParser.KW_LATIN7: + case MySqlParser.KW_MACCE: + case MySqlParser.KW_MACROMAN: + case MySqlParser.KW_SJIS: + case MySqlParser.KW_SWE7: + case MySqlParser.KW_TIS620: + case MySqlParser.KW_UCS2: + case MySqlParser.KW_UJIS: + case MySqlParser.KW_UTF16: + case MySqlParser.KW_UTF16LE: + case MySqlParser.KW_UTF32: + case MySqlParser.KW_UTF8: + case MySqlParser.KW_UTF8MB3: + case MySqlParser.KW_UTF8MB4: + case MySqlParser.KW_ARCHIVE: + case MySqlParser.KW_BLACKHOLE: + case MySqlParser.KW_CSV: + case MySqlParser.KW_FEDERATED: + case MySqlParser.KW_INNODB: + case MySqlParser.KW_MEMORY: + case MySqlParser.KW_MRG_MYISAM: + case MySqlParser.KW_MYISAM: + case MySqlParser.KW_NDB: + case MySqlParser.KW_NDBCLUSTER: + case MySqlParser.KW_PERFORMANCE_SCHEMA: + case MySqlParser.KW_TOKUDB: + case MySqlParser.KW_REPEATABLE: + case MySqlParser.KW_COMMITTED: + case MySqlParser.KW_UNCOMMITTED: + case MySqlParser.KW_SERIALIZABLE: + case MySqlParser.KW_GEOMETRYCOLLECTION: + case MySqlParser.KW_LINESTRING: + case MySqlParser.KW_MULTILINESTRING: + case MySqlParser.KW_MULTIPOINT: + case MySqlParser.KW_MULTIPOLYGON: + case MySqlParser.KW_POINT: + case MySqlParser.KW_POLYGON: + case MySqlParser.KW_CATALOG_NAME: + case MySqlParser.KW_CHARSET: + case MySqlParser.KW_COLLATION: + case MySqlParser.KW_ENGINE_ATTRIBUTE: + case MySqlParser.KW_FORMAT: + case MySqlParser.KW_GET_FORMAT: + case MySqlParser.KW_RANDOM: + case MySqlParser.KW_REVERSE: + case MySqlParser.KW_ROW_COUNT: + case MySqlParser.KW_SCHEMA_NAME: + case MySqlParser.KW_SECONDARY_ENGINE_ATTRIBUTE: + case MySqlParser.KW_SRID: + case MySqlParser.KW_SYSTEM_USER: + case MySqlParser.KW_TP_CONNECTION_ADMIN: + case MySqlParser.KW_WEIGHT_STRING: + case MySqlParser.MOD: + case MySqlParser.CHARSET_REVERSE_QOUTE_STRING: + case MySqlParser.STRING_LITERAL: + case MySqlParser.ID: + { + this.state = 7704; + this.windowName(); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + windowSpec() { + let localContext = new WindowSpecContext(this.context, this.state); + this.enterRule(localContext, 776, MySqlParser.RULE_windowSpec); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 7708; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1122, this.context)) { + case 1: + { + this.state = 7707; + this.windowName(); + } + break; + } + this.state = 7711; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 130) { + { + this.state = 7710; + this.partitionClause(); + } + } + this.state = 7714; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 125) { + { + this.state = 7713; + this.orderByClause(); + } + } + this.state = 7717; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 134 || _la === 587) { + { + this.state = 7716; + this.frameClause(); + } + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + windowName() { + let localContext = new WindowNameContext(this.context, this.state); + this.enterRule(localContext, 778, MySqlParser.RULE_windowName); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 7719; + this.uid(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + frameClause() { + let localContext = new FrameClauseContext(this.context, this.state); + this.enterRule(localContext, 780, MySqlParser.RULE_frameClause); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 7721; + this.frameUnits(); + this.state = 7722; + this.frameExtent(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + frameUnits() { + let localContext = new FrameUnitsContext(this.context, this.state); + this.enterRule(localContext, 782, MySqlParser.RULE_frameUnits); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 7724; + _la = this.tokenStream.LA(1); + if (!(_la === 134 || _la === 587)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + frameExtent() { + let localContext = new FrameExtentContext(this.context, this.state); + this.enterRule(localContext, 784, MySqlParser.RULE_frameExtent); + try { + this.state = 7728; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1126, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 7726; + this.frameRange(); + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 7727; + this.frameBetween(); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + frameBetween() { + let localContext = new FrameBetweenContext(this.context, this.state); + this.enterRule(localContext, 786, MySqlParser.RULE_frameBetween); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 7730; + this.match(MySqlParser.KW_BETWEEN); + this.state = 7731; + this.frameRange(); + this.state = 7732; + this.match(MySqlParser.KW_AND); + this.state = 7733; + this.frameRange(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + frameRange() { + let localContext = new FrameRangeContext(this.context, this.state); + this.enterRule(localContext, 788, MySqlParser.RULE_frameRange); + let _la; + try { + this.state = 7742; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1127, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 7735; + this.match(MySqlParser.KW_CURRENT); + this.state = 7736; + this.match(MySqlParser.KW_ROW); + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 7737; + this.match(MySqlParser.KW_UNBOUNDED); + this.state = 7738; + _la = this.tokenStream.LA(1); + if (!(_la === 405 || _la === 539)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + break; + case 3: + this.enterOuterAlt(localContext, 3); + { + this.state = 7739; + this.expression(0); + this.state = 7740; + _la = this.tokenStream.LA(1); + if (!(_la === 405 || _la === 539)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + partitionClause() { + let localContext = new PartitionClauseContext(this.context, this.state); + this.enterRule(localContext, 790, MySqlParser.RULE_partitionClause); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 7744; + this.match(MySqlParser.KW_PARTITION); + this.state = 7745; + this.match(MySqlParser.KW_BY); + this.state = 7746; + this.expression(0); + this.state = 7751; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 7747; + this.match(MySqlParser.COMMA); + this.state = 7748; + this.expression(0); + } + } + this.state = 7753; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + scalarFunctionName() { + let localContext = new ScalarFunctionNameContext(this.context, this.state); + this.enterRule(localContext, 792, MySqlParser.RULE_scalarFunctionName); + try { + this.state = 7778; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_DATABASE: + case MySqlParser.KW_LEFT: + case MySqlParser.KW_RIGHT: + case MySqlParser.KW_SCHEMA: + case MySqlParser.KW_DATE: + case MySqlParser.KW_TIME: + case MySqlParser.KW_TIMESTAMP: + case MySqlParser.KW_YEAR: + case MySqlParser.KW_JSON_TABLE: + case MySqlParser.KW_JSON_VALUE: + case MySqlParser.KW_COUNT: + case MySqlParser.KW_CUME_DIST: + case MySqlParser.KW_DENSE_RANK: + case MySqlParser.KW_FIRST_VALUE: + case MySqlParser.KW_LAG: + case MySqlParser.KW_LAST_VALUE: + case MySqlParser.KW_LEAD: + case MySqlParser.KW_NTILE: + case MySqlParser.KW_NTH_VALUE: + case MySqlParser.KW_PERCENT_RANK: + case MySqlParser.KW_RANK: + case MySqlParser.KW_ROW_NUMBER: + case MySqlParser.KW_POSITION: + case MySqlParser.KW_INVISIBLE: + case MySqlParser.KW_VISIBLE: + case MySqlParser.KW_QUARTER: + case MySqlParser.KW_MONTH: + case MySqlParser.KW_DAY: + case MySqlParser.KW_HOUR: + case MySqlParser.KW_MINUTE: + case MySqlParser.KW_WEEK: + case MySqlParser.KW_SECOND: + case MySqlParser.KW_MICROSECOND: + case MySqlParser.KW_SESSION_VARIABLES_ADMIN: + case MySqlParser.KW_GEOMETRYCOLLECTION: + case MySqlParser.KW_LINESTRING: + case MySqlParser.KW_MULTILINESTRING: + case MySqlParser.KW_MULTIPOINT: + case MySqlParser.KW_MULTIPOLYGON: + case MySqlParser.KW_POINT: + case MySqlParser.KW_POLYGON: + case MySqlParser.KW_CHARSET: + case MySqlParser.KW_COLLATION: + case MySqlParser.KW_FORMAT: + case MySqlParser.KW_GET_FORMAT: + case MySqlParser.KW_RANDOM: + case MySqlParser.KW_REVERSE: + case MySqlParser.KW_ROW_COUNT: + case MySqlParser.KW_SRID: + case MySqlParser.KW_SYSTEM_USER: + case MySqlParser.KW_WEIGHT_STRING: + case MySqlParser.MOD: + this.enterOuterAlt(localContext, 1); + { + this.state = 7754; + this.functionNameBase(); + } + break; + case MySqlParser.KW_ASCII: + this.enterOuterAlt(localContext, 2); + { + this.state = 7755; + this.match(MySqlParser.KW_ASCII); + } + break; + case MySqlParser.KW_CURDATE: + this.enterOuterAlt(localContext, 3); + { + this.state = 7756; + this.match(MySqlParser.KW_CURDATE); + } + break; + case MySqlParser.KW_CURRENT_DATE: + this.enterOuterAlt(localContext, 4); + { + this.state = 7757; + this.match(MySqlParser.KW_CURRENT_DATE); + } + break; + case MySqlParser.KW_CURRENT_TIME: + this.enterOuterAlt(localContext, 5); + { + this.state = 7758; + this.match(MySqlParser.KW_CURRENT_TIME); + } + break; + case MySqlParser.KW_CURRENT_TIMESTAMP: + this.enterOuterAlt(localContext, 6); + { + this.state = 7759; + this.match(MySqlParser.KW_CURRENT_TIMESTAMP); + } + break; + case MySqlParser.KW_CURTIME: + this.enterOuterAlt(localContext, 7); + { + this.state = 7760; + this.match(MySqlParser.KW_CURTIME); + } + break; + case MySqlParser.KW_DATE_ADD: + this.enterOuterAlt(localContext, 8); + { + this.state = 7761; + this.match(MySqlParser.KW_DATE_ADD); + } + break; + case MySqlParser.KW_DATE_SUB: + this.enterOuterAlt(localContext, 9); + { + this.state = 7762; + this.match(MySqlParser.KW_DATE_SUB); + } + break; + case MySqlParser.KW_IF: + this.enterOuterAlt(localContext, 10); + { + this.state = 7763; + this.match(MySqlParser.KW_IF); + } + break; + case MySqlParser.KW_INSERT: + this.enterOuterAlt(localContext, 11); + { + this.state = 7764; + this.match(MySqlParser.KW_INSERT); + } + break; + case MySqlParser.KW_LOCALTIME: + this.enterOuterAlt(localContext, 12); + { + this.state = 7765; + this.match(MySqlParser.KW_LOCALTIME); + } + break; + case MySqlParser.KW_LOCALTIMESTAMP: + this.enterOuterAlt(localContext, 13); + { + this.state = 7766; + this.match(MySqlParser.KW_LOCALTIMESTAMP); + } + break; + case MySqlParser.KW_MID: + this.enterOuterAlt(localContext, 14); + { + this.state = 7767; + this.match(MySqlParser.KW_MID); + } + break; + case MySqlParser.KW_NOW: + this.enterOuterAlt(localContext, 15); + { + this.state = 7768; + this.match(MySqlParser.KW_NOW); + } + break; + case MySqlParser.KW_REPEAT: + this.enterOuterAlt(localContext, 16); + { + this.state = 7769; + this.match(MySqlParser.KW_REPEAT); + } + break; + case MySqlParser.KW_REPLACE: + this.enterOuterAlt(localContext, 17); + { + this.state = 7770; + this.match(MySqlParser.KW_REPLACE); + } + break; + case MySqlParser.KW_SUBSTR: + this.enterOuterAlt(localContext, 18); + { + this.state = 7771; + this.match(MySqlParser.KW_SUBSTR); + } + break; + case MySqlParser.KW_SUBSTRING: + this.enterOuterAlt(localContext, 19); + { + this.state = 7772; + this.match(MySqlParser.KW_SUBSTRING); + } + break; + case MySqlParser.KW_SYSDATE: + this.enterOuterAlt(localContext, 20); + { + this.state = 7773; + this.match(MySqlParser.KW_SYSDATE); + } + break; + case MySqlParser.KW_TRIM: + this.enterOuterAlt(localContext, 21); + { + this.state = 7774; + this.match(MySqlParser.KW_TRIM); + } + break; + case MySqlParser.KW_UTC_DATE: + this.enterOuterAlt(localContext, 22); + { + this.state = 7775; + this.match(MySqlParser.KW_UTC_DATE); + } + break; + case MySqlParser.KW_UTC_TIME: + this.enterOuterAlt(localContext, 23); + { + this.state = 7776; + this.match(MySqlParser.KW_UTC_TIME); + } + break; + case MySqlParser.KW_UTC_TIMESTAMP: + this.enterOuterAlt(localContext, 24); + { + this.state = 7777; + this.match(MySqlParser.KW_UTC_TIMESTAMP); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + passwordFunctionClause() { + let localContext = new PasswordFunctionClauseContext(this.context, this.state); + this.enterRule(localContext, 794, MySqlParser.RULE_passwordFunctionClause); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 7780; + _la = this.tokenStream.LA(1); + if (!(_la === 512 || _la === 529)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 7781; + this.match(MySqlParser.LR_BRACKET); + this.state = 7782; + this.functionArg(); + this.state = 7783; + this.match(MySqlParser.RR_BRACKET); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + functionArgs() { + let localContext = new FunctionArgsContext(this.context, this.state); + this.enterRule(localContext, 796, MySqlParser.RULE_functionArgs); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 7785; + this.functionArg(); + this.state = 7790; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 7786; + this.match(MySqlParser.COMMA); + this.state = 7787; + this.functionArg(); + } + } + this.state = 7792; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + functionArg() { + let localContext = new FunctionArgContext(this.context, this.state); + this.enterRule(localContext, 798, MySqlParser.RULE_functionArg); + try { + this.state = 7796; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1131, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 7793; + this.constant(); + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 7794; + this.functionCall(); + } + break; + case 3: + this.enterOuterAlt(localContext, 3); + { + this.state = 7795; + this.expression(0); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + expression(_p) { + if (_p === undefined) { + _p = 0; + } + let parentContext = this.context; + let parentState = this.state; + let localContext = new ExpressionContext(this.context, parentState); + let previousContext = localContext; + let _startState = 800; + this.enterRecursionRule(localContext, 800, MySqlParser.RULE_expression, _p); + let _la; + try { + let alternative; + this.enterOuterAlt(localContext, 1); + { + this.state = 7809; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1133, this.context)) { + case 1: + { + localContext = new NotExpressionContext(localContext); + this.context = localContext; + previousContext = localContext; + this.state = 7799; + localContext._notOperator = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 114 || _la === 860)) { + localContext._notOperator = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 7800; + this.expression(4); + } + break; + case 2: + { + localContext = new IsExpressionContext(localContext); + this.context = localContext; + previousContext = localContext; + this.state = 7801; + this.predicate(0); + this.state = 7802; + this.match(MySqlParser.KW_IS); + this.state = 7804; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 114) { + { + this.state = 7803; + this.match(MySqlParser.KW_NOT); + } + } + this.state = 7806; + localContext._testValue = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 63 || _la === 179 || _la === 674)) { + localContext._testValue = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + break; + case 3: + { + localContext = new PredicateExpressionContext(localContext); + this.context = localContext; + previousContext = localContext; + this.state = 7808; + this.predicate(0); + } + break; + } + this.context.stop = this.tokenStream.LT(-1); + this.state = 7817; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 1134, this.context); + while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER) { + if (alternative === 1) { + if (this._parseListeners != null) { + this.triggerExitRuleEvent(); + } + previousContext = localContext; + { + { + localContext = new LogicalExpressionContext(new ExpressionContext(parentContext, parentState)); + this.pushNewRecursionContext(localContext, _startState, MySqlParser.RULE_expression); + this.state = 7811; + if (!(this.precpred(this.context, 3))) { + throw this.createFailedPredicateException("this.precpred(this.context, 3)"); + } + this.state = 7812; + this.logicalOperator(); + this.state = 7813; + this.expression(4); + } + } + } + this.state = 7819; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 1134, this.context); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.unrollRecursionContexts(parentContext); + } + return localContext; + } + predicate(_p) { + if (_p === undefined) { + _p = 0; + } + let parentContext = this.context; + let parentState = this.state; + let localContext = new PredicateContext(this.context, parentState); + let previousContext = localContext; + let _startState = 802; + this.enterRecursionRule(localContext, 802, MySqlParser.RULE_predicate, _p); + let _la; + try { + let alternative; + this.enterOuterAlt(localContext, 1); + { + { + localContext = new ExpressionAtomPredicateContext(localContext); + this.context = localContext; + previousContext = localContext; + this.state = 7821; + this.expressionAtom(0); + } + this.context.stop = this.tokenStream.LT(-1); + this.state = 7886; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 1143, this.context); + while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER) { + if (alternative === 1) { + if (this._parseListeners != null) { + this.triggerExitRuleEvent(); + } + previousContext = localContext; + { + this.state = 7884; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1142, this.context)) { + case 1: + { + localContext = new BetweenPredicateContext(new PredicateContext(parentContext, parentState)); + this.pushNewRecursionContext(localContext, _startState, MySqlParser.RULE_predicate); + this.state = 7823; + if (!(this.precpred(this.context, 6))) { + throw this.createFailedPredicateException("this.precpred(this.context, 6)"); + } + this.state = 7825; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 114) { + { + this.state = 7824; + this.match(MySqlParser.KW_NOT); + } + } + this.state = 7827; + this.match(MySqlParser.KW_BETWEEN); + this.state = 7828; + this.predicate(0); + this.state = 7829; + this.match(MySqlParser.KW_AND); + this.state = 7830; + this.predicate(7); + } + break; + case 2: + { + localContext = new SoundsLikePredicateContext(new PredicateContext(parentContext, parentState)); + this.pushNewRecursionContext(localContext, _startState, MySqlParser.RULE_predicate); + this.state = 7832; + if (!(this.precpred(this.context, 5))) { + throw this.createFailedPredicateException("this.precpred(this.context, 5)"); + } + this.state = 7833; + this.match(MySqlParser.KW_SOUNDS); + this.state = 7834; + this.match(MySqlParser.KW_LIKE); + this.state = 7835; + this.predicate(6); + } + break; + case 3: + { + localContext = new RegexpPredicateContext(new PredicateContext(parentContext, parentState)); + this.pushNewRecursionContext(localContext, _startState, MySqlParser.RULE_predicate); + this.state = 7836; + if (!(this.precpred(this.context, 3))) { + throw this.createFailedPredicateException("this.precpred(this.context, 3)"); + } + this.state = 7838; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 114) { + { + this.state = 7837; + this.match(MySqlParser.KW_NOT); + } + } + this.state = 7840; + localContext._regex = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 139 || _la === 151)) { + localContext._regex = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 7841; + this.predicate(4); + } + break; + case 4: + { + localContext = new InPredicateContext(new PredicateContext(parentContext, parentState)); + this.pushNewRecursionContext(localContext, _startState, MySqlParser.RULE_predicate); + this.state = 7842; + if (!(this.precpred(this.context, 9))) { + throw this.createFailedPredicateException("this.precpred(this.context, 9)"); + } + this.state = 7844; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 114) { + { + this.state = 7843; + this.match(MySqlParser.KW_NOT); + } + } + this.state = 7846; + this.match(MySqlParser.KW_IN); + this.state = 7847; + this.match(MySqlParser.LR_BRACKET); + this.state = 7850; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1138, this.context)) { + case 1: + { + this.state = 7848; + this.selectStatement(); + } + break; + case 2: + { + this.state = 7849; + this.expressions(); + } + break; + } + this.state = 7852; + this.match(MySqlParser.RR_BRACKET); + } + break; + case 5: + { + localContext = new IsNullPredicateContext(new PredicateContext(parentContext, parentState)); + this.pushNewRecursionContext(localContext, _startState, MySqlParser.RULE_predicate); + this.state = 7854; + if (!(this.precpred(this.context, 8))) { + throw this.createFailedPredicateException("this.precpred(this.context, 8)"); + } + this.state = 7855; + this.match(MySqlParser.KW_IS); + this.state = 7856; + this.nullNotnull(); + } + break; + case 6: + { + localContext = new BinaryComparisonPredicateContext(new PredicateContext(parentContext, parentState)); + this.pushNewRecursionContext(localContext, _startState, MySqlParser.RULE_predicate); + this.state = 7857; + if (!(this.precpred(this.context, 7))) { + throw this.createFailedPredicateException("this.precpred(this.context, 7)"); + } + this.state = 7858; + this.comparisonOperator(); + this.state = 7865; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1139, this.context)) { + case 1: + { + this.state = 7859; + localContext._quantifier = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 7 || _la === 309 || _la === 602)) { + localContext._quantifier = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 7860; + this.match(MySqlParser.LR_BRACKET); + this.state = 7861; + localContext._subQuery = this.selectStatement(); + this.state = 7862; + this.match(MySqlParser.RR_BRACKET); + } + break; + case 2: + { + this.state = 7864; + localContext._right = this.predicate(0); + } + break; + } + } + break; + case 7: + { + localContext = new LikePredicateContext(new PredicateContext(parentContext, parentState)); + this.pushNewRecursionContext(localContext, _startState, MySqlParser.RULE_predicate); + this.state = 7867; + if (!(this.precpred(this.context, 4))) { + throw this.createFailedPredicateException("this.precpred(this.context, 4)"); + } + this.state = 7869; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 114) { + { + this.state = 7868; + this.match(MySqlParser.KW_NOT); + } + } + this.state = 7871; + this.match(MySqlParser.KW_LIKE); + this.state = 7872; + this.predicate(0); + this.state = 7875; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1141, this.context)) { + case 1: + { + this.state = 7873; + this.match(MySqlParser.KW_ESCAPE); + this.state = 7874; + this.match(MySqlParser.STRING_LITERAL); + } + break; + } + } + break; + case 8: + { + localContext = new JsonMemberOfPredicateContext(new PredicateContext(parentContext, parentState)); + this.pushNewRecursionContext(localContext, _startState, MySqlParser.RULE_predicate); + this.state = 7877; + if (!(this.precpred(this.context, 2))) { + throw this.createFailedPredicateException("this.precpred(this.context, 2)"); + } + this.state = 7878; + this.match(MySqlParser.KW_MEMBER); + this.state = 7879; + this.match(MySqlParser.KW_OF); + this.state = 7880; + this.match(MySqlParser.LR_BRACKET); + this.state = 7881; + this.predicate(0); + this.state = 7882; + this.match(MySqlParser.RR_BRACKET); + } + break; + } + } + } + this.state = 7888; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 1143, this.context); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.unrollRecursionContexts(parentContext); + } + return localContext; + } + expressionAtom(_p) { + if (_p === undefined) { + _p = 0; + } + let parentContext = this.context; + let parentState = this.state; + let localContext = new ExpressionAtomContext(this.context, parentState); + let previousContext = localContext; + let _startState = 804; + this.enterRecursionRule(localContext, 804, MySqlParser.RULE_expressionAtom, _p); + let _la; + try { + let alternative; + this.enterOuterAlt(localContext, 1); + { + this.state = 7937; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1146, this.context)) { + case 1: + { + localContext = new ConstantExpressionAtomContext(localContext); + this.context = localContext; + previousContext = localContext; + this.state = 7890; + this.constant(); + } + break; + case 2: + { + localContext = new FunctionCallExpressionAtomContext(localContext); + this.context = localContext; + previousContext = localContext; + this.state = 7891; + this.functionCall(); + } + break; + case 3: + { + localContext = new MysqlVariableExpressionAtomContext(localContext); + this.context = localContext; + previousContext = localContext; + this.state = 7892; + this.mysqlVariable(); + } + break; + case 4: + { + localContext = new UnaryExpressionAtomContext(localContext); + this.context = localContext; + previousContext = localContext; + this.state = 7893; + this.unaryOperator(); + this.state = 7894; + this.expressionAtom(12); + } + break; + case 5: + { + localContext = new BinaryExpressionAtomContext(localContext); + this.context = localContext; + previousContext = localContext; + this.state = 7896; + this.match(MySqlParser.KW_BINARY); + this.state = 7897; + this.expressionAtom(11); + } + break; + case 6: + { + localContext = new VariableAssignExpressionAtomContext(localContext); + this.context = localContext; + previousContext = localContext; + this.state = 7898; + this.match(MySqlParser.LOCAL_ID); + this.state = 7899; + this.match(MySqlParser.VAR_ASSIGN); + this.state = 7900; + this.expressionAtom(10); + } + break; + case 7: + { + localContext = new NestedExpressionAtomContext(localContext); + this.context = localContext; + previousContext = localContext; + this.state = 7901; + this.match(MySqlParser.LR_BRACKET); + this.state = 7902; + this.expression(0); + this.state = 7907; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 7903; + this.match(MySqlParser.COMMA); + this.state = 7904; + this.expression(0); + } + } + this.state = 7909; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 7910; + this.match(MySqlParser.RR_BRACKET); + } + break; + case 8: + { + localContext = new NestedRowExpressionAtomContext(localContext); + this.context = localContext; + previousContext = localContext; + this.state = 7912; + this.match(MySqlParser.KW_ROW); + this.state = 7913; + this.match(MySqlParser.LR_BRACKET); + this.state = 7914; + this.expression(0); + this.state = 7917; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + do { + { + { + this.state = 7915; + this.match(MySqlParser.COMMA); + this.state = 7916; + this.expression(0); + } + } + this.state = 7919; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } while (_la === 868); + this.state = 7921; + this.match(MySqlParser.RR_BRACKET); + } + break; + case 9: + { + localContext = new ExistsExpressionAtomContext(localContext); + this.context = localContext; + previousContext = localContext; + this.state = 7923; + this.match(MySqlParser.KW_EXISTS); + this.state = 7924; + this.match(MySqlParser.LR_BRACKET); + this.state = 7925; + this.selectStatement(); + this.state = 7926; + this.match(MySqlParser.RR_BRACKET); + } + break; + case 10: + { + localContext = new SubqueryExpressionAtomContext(localContext); + this.context = localContext; + previousContext = localContext; + this.state = 7928; + this.match(MySqlParser.LR_BRACKET); + this.state = 7929; + this.selectStatement(); + this.state = 7930; + this.match(MySqlParser.RR_BRACKET); + } + break; + case 11: + { + localContext = new IntervalExpressionAtomContext(localContext); + this.context = localContext; + previousContext = localContext; + this.state = 7932; + this.match(MySqlParser.KW_INTERVAL); + this.state = 7933; + this.expression(0); + this.state = 7934; + this.intervalType(); + } + break; + case 12: + { + localContext = new ColumnNameExpressionAtomContext(localContext); + this.context = localContext; + previousContext = localContext; + this.state = 7936; + this.columnName(); + } + break; + } + this.context.stop = this.tokenStream.LT(-1); + this.state = 7956; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 1148, this.context); + while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER) { + if (alternative === 1) { + if (this._parseListeners != null) { + this.triggerExitRuleEvent(); + } + previousContext = localContext; + { + this.state = 7954; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1147, this.context)) { + case 1: + { + localContext = new JsonExpressionAtomContext(new ExpressionAtomContext(parentContext, parentState)); + localContext._left = previousContext; + this.pushNewRecursionContext(localContext, _startState, MySqlParser.RULE_expressionAtom); + this.state = 7939; + if (!(this.precpred(this.context, 4))) { + throw this.createFailedPredicateException("this.precpred(this.context, 4)"); + } + this.state = 7940; + this.jsonOperator(); + this.state = 7941; + localContext._right = this.expressionAtom(5); + } + break; + case 2: + { + localContext = new BitExpressionAtomContext(new ExpressionAtomContext(parentContext, parentState)); + localContext._left = previousContext; + this.pushNewRecursionContext(localContext, _startState, MySqlParser.RULE_expressionAtom); + this.state = 7943; + if (!(this.precpred(this.context, 3))) { + throw this.createFailedPredicateException("this.precpred(this.context, 3)"); + } + this.state = 7944; + this.bitOperator(); + this.state = 7945; + localContext._right = this.expressionAtom(4); + } + break; + case 3: + { + localContext = new MathExpressionAtomContext(new ExpressionAtomContext(parentContext, parentState)); + localContext._left = previousContext; + this.pushNewRecursionContext(localContext, _startState, MySqlParser.RULE_expressionAtom); + this.state = 7947; + if (!(this.precpred(this.context, 2))) { + throw this.createFailedPredicateException("this.precpred(this.context, 2)"); + } + this.state = 7948; + this.mathOperator(); + this.state = 7949; + localContext._right = this.expressionAtom(3); + } + break; + case 4: + { + localContext = new CollateExpressionAtomContext(new ExpressionAtomContext(parentContext, parentState)); + this.pushNewRecursionContext(localContext, _startState, MySqlParser.RULE_expressionAtom); + this.state = 7951; + if (!(this.precpred(this.context, 14))) { + throw this.createFailedPredicateException("this.precpred(this.context, 14)"); + } + this.state = 7952; + this.match(MySqlParser.KW_COLLATE); + this.state = 7953; + this.collationName(); + } + break; + } + } + } + this.state = 7958; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 1148, this.context); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.unrollRecursionContexts(parentContext); + } + return localContext; + } + unaryOperator() { + let localContext = new UnaryOperatorContext(this.context, this.state); + this.enterRule(localContext, 806, MySqlParser.RULE_unaryOperator); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 7959; + _la = this.tokenStream.LA(1); + if (!(_la === 114 || ((((_la - 853)) & ~0x1F) === 0 && ((1 << (_la - 853)) & 387) !== 0))) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + comparisonOperator() { + let localContext = new ComparisonOperatorContext(this.context, this.state); + this.enterRule(localContext, 808, MySqlParser.RULE_comparisonOperator); + try { + this.state = 7969; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1149, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 7961; + this.match(MySqlParser.LESS_SYMBOL); + this.state = 7962; + this.match(MySqlParser.GREATER_SYMBOL); + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 7963; + this.match(MySqlParser.EXCLAMATION_SYMBOL); + this.state = 7964; + this.match(MySqlParser.EQUAL_SYMBOL); + } + break; + case 3: + this.enterOuterAlt(localContext, 3); + { + this.state = 7965; + this.match(MySqlParser.LESS_SYMBOL); + this.state = 7966; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 7967; + this.match(MySqlParser.GREATER_SYMBOL); + } + break; + case 4: + this.enterOuterAlt(localContext, 4); + { + this.state = 7968; + this.comparisonBase(); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + comparisonBase() { + let localContext = new ComparisonBaseContext(this.context, this.state); + this.enterRule(localContext, 810, MySqlParser.RULE_comparisonBase); + try { + this.state = 7978; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1150, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 7971; + this.match(MySqlParser.LESS_SYMBOL); + this.state = 7972; + this.match(MySqlParser.EQUAL_SYMBOL); + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 7973; + this.match(MySqlParser.GREATER_SYMBOL); + this.state = 7974; + this.match(MySqlParser.EQUAL_SYMBOL); + } + break; + case 3: + this.enterOuterAlt(localContext, 3); + { + this.state = 7975; + this.match(MySqlParser.EQUAL_SYMBOL); + } + break; + case 4: + this.enterOuterAlt(localContext, 4); + { + this.state = 7976; + this.match(MySqlParser.GREATER_SYMBOL); + } + break; + case 5: + this.enterOuterAlt(localContext, 5); + { + this.state = 7977; + this.match(MySqlParser.LESS_SYMBOL); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + logicalOperator() { + let localContext = new LogicalOperatorContext(this.context, this.state); + this.enterRule(localContext, 812, MySqlParser.RULE_logicalOperator); + try { + this.state = 7987; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_AND: + this.enterOuterAlt(localContext, 1); + { + this.state = 7980; + this.match(MySqlParser.KW_AND); + } + break; + case MySqlParser.BIT_AND_OP: + this.enterOuterAlt(localContext, 2); + { + this.state = 7981; + this.match(MySqlParser.BIT_AND_OP); + this.state = 7982; + this.match(MySqlParser.BIT_AND_OP); + } + break; + case MySqlParser.KW_XOR: + this.enterOuterAlt(localContext, 3); + { + this.state = 7983; + this.match(MySqlParser.KW_XOR); + } + break; + case MySqlParser.KW_OR: + this.enterOuterAlt(localContext, 4); + { + this.state = 7984; + this.match(MySqlParser.KW_OR); + } + break; + case MySqlParser.BIT_OR_OP: + this.enterOuterAlt(localContext, 5); + { + this.state = 7985; + this.match(MySqlParser.BIT_OR_OP); + this.state = 7986; + this.match(MySqlParser.BIT_OR_OP); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + bitOperator() { + let localContext = new BitOperatorContext(this.context, this.state); + this.enterRule(localContext, 814, MySqlParser.RULE_bitOperator); + try { + this.state = 7996; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.LESS_SYMBOL: + this.enterOuterAlt(localContext, 1); + { + this.state = 7989; + this.match(MySqlParser.LESS_SYMBOL); + this.state = 7990; + this.match(MySqlParser.LESS_SYMBOL); + } + break; + case MySqlParser.GREATER_SYMBOL: + this.enterOuterAlt(localContext, 2); + { + this.state = 7991; + this.match(MySqlParser.GREATER_SYMBOL); + this.state = 7992; + this.match(MySqlParser.GREATER_SYMBOL); + } + break; + case MySqlParser.BIT_AND_OP: + this.enterOuterAlt(localContext, 3); + { + this.state = 7993; + this.match(MySqlParser.BIT_AND_OP); + } + break; + case MySqlParser.BIT_XOR_OP: + this.enterOuterAlt(localContext, 4); + { + this.state = 7994; + this.match(MySqlParser.BIT_XOR_OP); + } + break; + case MySqlParser.BIT_OR_OP: + this.enterOuterAlt(localContext, 5); + { + this.state = 7995; + this.match(MySqlParser.BIT_OR_OP); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + mathOperator() { + let localContext = new MathOperatorContext(this.context, this.state); + this.enterRule(localContext, 816, MySqlParser.RULE_mathOperator); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 7998; + _la = this.tokenStream.LA(1); + if (!(((((_la - 850)) & ~0x1F) === 0 && ((1 << (_la - 850)) & 127) !== 0))) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + jsonOperator() { + let localContext = new JsonOperatorContext(this.context, this.state); + this.enterRule(localContext, 818, MySqlParser.RULE_jsonOperator); + try { + this.state = 8005; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1153, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 8000; + this.match(MySqlParser.MINUS); + this.state = 8001; + this.match(MySqlParser.GREATER_SYMBOL); + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 8002; + this.match(MySqlParser.MINUS); + this.state = 8003; + this.match(MySqlParser.GREATER_SYMBOL); + this.state = 8004; + this.match(MySqlParser.GREATER_SYMBOL); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + charsetNameBase() { + let localContext = new CharsetNameBaseContext(this.context, this.state); + this.enterRule(localContext, 820, MySqlParser.RULE_charsetNameBase); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 8007; + _la = this.tokenStream.LA(1); + if (!(_la === 228 || ((((_la - 756)) & ~0x1F) === 0 && ((1 << (_la - 756)) & 4294967295) !== 0) || ((((_la - 788)) & ~0x1F) === 0 && ((1 << (_la - 788)) & 511) !== 0))) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + transactionLevelBase() { + let localContext = new TransactionLevelBaseContext(this.context, this.state); + this.enterRule(localContext, 822, MySqlParser.RULE_transactionLevelBase); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 8009; + _la = this.tokenStream.LA(1); + if (!(((((_la - 809)) & ~0x1F) === 0 && ((1 << (_la - 809)) & 15) !== 0))) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + privilegesBase() { + let localContext = new PrivilegesBaseContext(this.context, this.state); + this.enterRule(localContext, 824, MySqlParser.RULE_privilegesBase); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 8011; + _la = this.tokenStream.LA(1); + if (!(((((_la - 717)) & ~0x1F) === 0 && ((1 << (_la - 717)) & 68026371) !== 0) || ((((_la - 749)) & ~0x1F) === 0 && ((1 << (_la - 749)) & 11) !== 0))) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + intervalTypeBase() { + let localContext = new IntervalTypeBaseContext(this.context, this.state); + this.enterRule(localContext, 826, MySqlParser.RULE_intervalTypeBase); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 8013; + _la = this.tokenStream.LA(1); + if (!(((((_la - 696)) & ~0x1F) === 0 && ((1 << (_la - 696)) & 255) !== 0))) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + dataTypeBase() { + let localContext = new DataTypeBaseContext(this.context, this.state); + this.enterRule(localContext, 828, MySqlParser.RULE_dataTypeBase); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 8015; + _la = this.tokenStream.LA(1); + if (!(((((_la - 219)) & ~0x1F) === 0 && ((1 << (_la - 219)) & 1179679) !== 0))) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + keywordsCanBeId() { + let localContext = new KeywordsCanBeIdContext(this.context, this.state); + this.enterRule(localContext, 830, MySqlParser.RULE_keywordsCanBeId); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 8017; + _la = this.tokenStream.LA(1); + if (!((((_la) & ~0x1F) === 0 && ((1 << _la) & 1074302976) !== 0) || ((((_la - 36)) & ~0x1F) === 0 && ((1 << (_la - 36)) & 11014211) !== 0) || _la === 74 || _la === 95 || ((((_la - 117)) & ~0x1F) === 0 && ((1 << (_la - 117)) & 16673) !== 0) || _la === 160 || _la === 170 || ((((_la - 241)) & ~0x1F) === 0 && ((1 << (_la - 241)) & 1648345089) !== 0) || ((((_la - 277)) & ~0x1F) === 0 && ((1 << (_la - 277)) & 4160749823) !== 0) || ((((_la - 309)) & ~0x1F) === 0 && ((1 << (_la - 309)) & 4292870141) !== 0) || ((((_la - 341)) & ~0x1F) === 0 && ((1 << (_la - 341)) & 4294967287) !== 0) || ((((_la - 373)) & ~0x1F) === 0 && ((1 << (_la - 373)) & 4024434671) !== 0) || ((((_la - 406)) & ~0x1F) === 0 && ((1 << (_la - 406)) & 3747609503) !== 0) || ((((_la - 438)) & ~0x1F) === 0 && ((1 << (_la - 438)) & 4227727359) !== 0) || ((((_la - 470)) & ~0x1F) === 0 && ((1 << (_la - 470)) & 3758096239) !== 0) || ((((_la - 502)) & ~0x1F) === 0 && ((1 << (_la - 502)) & 2678062559) !== 0) || ((((_la - 534)) & ~0x1F) === 0 && ((1 << (_la - 534)) & 2682256863) !== 0) || ((((_la - 566)) & ~0x1F) === 0 && ((1 << (_la - 566)) & 4294957695) !== 0) || ((((_la - 598)) & ~0x1F) === 0 && ((1 << (_la - 598)) & 255) !== 0) || ((((_la - 633)) & ~0x1F) === 0 && ((1 << (_la - 633)) & 4294934527) !== 0) || ((((_la - 665)) & ~0x1F) === 0 && ((1 << (_la - 665)) & 2128608253) !== 0) || ((((_la - 704)) & ~0x1F) === 0 && ((1 << (_la - 704)) & 1053007341) !== 0) || ((((_la - 737)) & ~0x1F) === 0 && ((1 << (_la - 737)) & 478907) !== 0) || ((((_la - 802)) & ~0x1F) === 0 && ((1 << (_la - 802)) & 3230662657) !== 0) || _la === 838)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + functionNameBase() { + let localContext = new FunctionNameBaseContext(this.context, this.state); + this.enterRule(localContext, 832, MySqlParser.RULE_functionNameBase); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 8019; + _la = this.tokenStream.LA(1); + if (!(_la === 39 || _la === 98 || _la === 150 || _la === 152 || ((((_la - 219)) & ~0x1F) === 0 && ((1 << (_la - 219)) & 23) !== 0) || ((((_la - 253)) & ~0x1F) === 0 && ((1 << (_la - 253)) & 16375299) !== 0) || _la === 296 || _la === 435 || ((((_la - 686)) & ~0x1F) === 0 && ((1 << (_la - 686)) & 261121) !== 0) || _la === 746 || ((((_la - 813)) & ~0x1F) === 0 && ((1 << (_la - 813)) & 145190393) !== 0) || _la === 856)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + sempred(localContext, ruleIndex, predIndex) { + switch (ruleIndex) { + case 104: + return this.queryExpressionBody_sempred(localContext, predIndex); + case 105: + return this.queryItem_sempred(localContext, predIndex); + case 329: + return this.columnName_sempred(localContext, predIndex); + case 400: + return this.expression_sempred(localContext, predIndex); + case 401: + return this.predicate_sempred(localContext, predIndex); + case 402: + return this.expressionAtom_sempred(localContext, predIndex); + } + return true; + } + queryExpressionBody_sempred(localContext, predIndex) { + switch (predIndex) { + case 0: + return this.precpred(this.context, 2); + case 1: + return this.precpred(this.context, 1); + } + return true; + } + queryItem_sempred(localContext, predIndex) { + switch (predIndex) { + case 2: + return this.precpred(this.context, 1); + } + return true; + } + columnName_sempred(localContext, predIndex) { + switch (predIndex) { + case 3: + return this.shouldMatchEmpty(); + } + return true; + } + expression_sempred(localContext, predIndex) { + switch (predIndex) { + case 4: + return this.precpred(this.context, 3); + } + return true; + } + predicate_sempred(localContext, predIndex) { + switch (predIndex) { + case 5: + return this.precpred(this.context, 6); + case 6: + return this.precpred(this.context, 5); + case 7: + return this.precpred(this.context, 3); + case 8: + return this.precpred(this.context, 9); + case 9: + return this.precpred(this.context, 8); + case 10: + return this.precpred(this.context, 7); + case 11: + return this.precpred(this.context, 4); + case 12: + return this.precpred(this.context, 2); + } + return true; + } + expressionAtom_sempred(localContext, predIndex) { + switch (predIndex) { + case 13: + return this.precpred(this.context, 4); + case 14: + return this.precpred(this.context, 3); + case 15: + return this.precpred(this.context, 2); + case 16: + return this.precpred(this.context, 14); + } + return true; + } + static get _ATN() { + if (!MySqlParser.__ATN) { + MySqlParser.__ATN = new antlr.ATNDeserializer().deserialize(MySqlParser._serializedATN); + } + return MySqlParser.__ATN; + } + get vocabulary() { + return MySqlParser.vocabulary; + } +} + +export { MySqlParser }; diff --git a/test/form/samples/object-tree-shaking-issue-5734/main.js b/test/form/samples/object-tree-shaking-issue-5734/main.js new file mode 100644 index 00000000000..314988654fc --- /dev/null +++ b/test/form/samples/object-tree-shaking-issue-5734/main.js @@ -0,0 +1 @@ +export { MySqlParser } from './module.js'; diff --git a/test/form/samples/object-tree-shaking-issue-5734/module.js b/test/form/samples/object-tree-shaking-issue-5734/module.js new file mode 100644 index 00000000000..7ce43fdb78e --- /dev/null +++ b/test/form/samples/object-tree-shaking-issue-5734/module.js @@ -0,0 +1,45586 @@ +class MySqlParser extends SQLParserBase { + get grammarFileName() { return "MySqlParser.g4"; } + get literalNames() { return MySqlParser.literalNames; } + get symbolicNames() { return MySqlParser.symbolicNames; } + get ruleNames() { return MySqlParser.ruleNames; } + get serializedATN() { return MySqlParser._serializedATN; } + createFailedPredicateException(predicate, message) { + return new antlr.FailedPredicateException(this, predicate, message); + } + constructor(input) { + super(input); + this.interpreter = new antlr.ParserATNSimulator(this, MySqlParser._ATN, MySqlParser.decisionsToDFA, new antlr.PredictionContextCache()); + } + program() { + let localContext = new ProgramContext(this.context, this.state); + this.enterRule(localContext, 0, MySqlParser.RULE_program); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 837; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while ((((_la) & ~0x1F) === 0 && ((1 << _la) & 169870592) !== 0) || ((((_la - 34)) & ~0x1F) === 0 && ((1 << (_la - 34)) & 268573697) !== 0) || ((((_la - 72)) & ~0x1F) === 0 && ((1 << (_la - 72)) & 2151694339) !== 0) || ((((_la - 104)) & ~0x1F) === 0 && ((1 << (_la - 104)) & 536936449) !== 0) || ((((_la - 140)) & ~0x1F) === 0 && ((1 << (_la - 140)) & 442923) !== 0) || ((((_la - 173)) & ~0x1F) === 0 && ((1 << (_la - 173)) & 2184193) !== 0) || ((((_la - 317)) & ~0x1F) === 0 && ((1 << (_la - 317)) & 16781443) !== 0) || _la === 362 || _la === 371 || ((((_la - 404)) & ~0x1F) === 0 && ((1 << (_la - 404)) & 270573569) !== 0) || _la === 540 || _la === 562 || ((((_la - 575)) & ~0x1F) === 0 && ((1 << (_la - 575)) & 16643) !== 0) || ((((_la - 640)) & ~0x1F) === 0 && ((1 << (_la - 640)) & 268435521) !== 0) || _la === 673 || _la === 694 || _la === 713 || _la === 717 || _la === 749 || _la === 866 || _la === 869) { + { + { + this.state = 834; + this.singleStatement(); + } + } + this.state = 839; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 840; + this.match(MySqlParser.EOF); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + singleStatement() { + let localContext = new SingleStatementContext(this.context, this.state); + this.enterRule(localContext, 2, MySqlParser.RULE_singleStatement); + try { + this.state = 847; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_ALTER: + case MySqlParser.KW_ANALYZE: + case MySqlParser.KW_CALL: + case MySqlParser.KW_CHANGE: + case MySqlParser.KW_CHECK: + case MySqlParser.KW_CREATE: + case MySqlParser.KW_DELETE: + case MySqlParser.KW_DESC: + case MySqlParser.KW_DESCRIBE: + case MySqlParser.KW_DROP: + case MySqlParser.KW_EXPLAIN: + case MySqlParser.KW_GET: + case MySqlParser.KW_GRANT: + case MySqlParser.KW_INSERT: + case MySqlParser.KW_KILL: + case MySqlParser.KW_LOAD: + case MySqlParser.KW_LOCK: + case MySqlParser.KW_OPTIMIZE: + case MySqlParser.KW_PURGE: + case MySqlParser.KW_RELEASE: + case MySqlParser.KW_RENAME: + case MySqlParser.KW_REPLACE: + case MySqlParser.KW_RESIGNAL: + case MySqlParser.KW_REVOKE: + case MySqlParser.KW_SELECT: + case MySqlParser.KW_SET: + case MySqlParser.KW_SHOW: + case MySqlParser.KW_SIGNAL: + case MySqlParser.KW_TABLE: + case MySqlParser.KW_UNLOCK: + case MySqlParser.KW_UPDATE: + case MySqlParser.KW_USE: + case MySqlParser.KW_VALUES: + case MySqlParser.KW_WITH: + case MySqlParser.KW_BEGIN: + case MySqlParser.KW_BINLOG: + case MySqlParser.KW_CACHE: + case MySqlParser.KW_CHECKSUM: + case MySqlParser.KW_COMMIT: + case MySqlParser.KW_DEALLOCATE: + case MySqlParser.KW_DO: + case MySqlParser.KW_FLUSH: + case MySqlParser.KW_HANDLER: + case MySqlParser.KW_HELP: + case MySqlParser.KW_IMPORT: + case MySqlParser.KW_INSTALL: + case MySqlParser.KW_PREPARE: + case MySqlParser.KW_REPAIR: + case MySqlParser.KW_RESET: + case MySqlParser.KW_RESTART: + case MySqlParser.KW_ROLLBACK: + case MySqlParser.KW_SAVEPOINT: + case MySqlParser.KW_START: + case MySqlParser.KW_STOP: + case MySqlParser.KW_TRUNCATE: + case MySqlParser.KW_UNINSTALL: + case MySqlParser.KW_XA: + case MySqlParser.KW_CLONE: + case MySqlParser.KW_EXECUTE: + case MySqlParser.KW_SHUTDOWN: + case MySqlParser.LR_BRACKET: + this.enterOuterAlt(localContext, 1); + { + this.state = 842; + this.sqlStatement(); + this.state = 844; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1, this.context)) { + case 1: + { + this.state = 843; + this.match(MySqlParser.SEMI); + } + break; + } + } + break; + case MySqlParser.SEMI: + this.enterOuterAlt(localContext, 2); + { + this.state = 846; + this.emptyStatement_(); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + sqlStatement() { + let localContext = new SqlStatementContext(this.context, this.state); + this.enterRule(localContext, 4, MySqlParser.RULE_sqlStatement); + try { + this.state = 856; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 3, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 849; + this.ddlStatement(); + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 850; + this.dmlStatement(); + } + break; + case 3: + this.enterOuterAlt(localContext, 3); + { + this.state = 851; + this.transactionStatement(); + } + break; + case 4: + this.enterOuterAlt(localContext, 4); + { + this.state = 852; + this.replicationStatement(); + } + break; + case 5: + this.enterOuterAlt(localContext, 5); + { + this.state = 853; + this.preparedStatement(); + } + break; + case 6: + this.enterOuterAlt(localContext, 6); + { + this.state = 854; + this.administrationStatement(); + } + break; + case 7: + this.enterOuterAlt(localContext, 7); + { + this.state = 855; + this.utilityStatement(); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + emptyStatement_() { + let localContext = new EmptyStatement_Context(this.context, this.state); + this.enterRule(localContext, 6, MySqlParser.RULE_emptyStatement_); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 858; + this.match(MySqlParser.SEMI); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + ddlStatement() { + let localContext = new DdlStatementContext(this.context, this.state); + this.enterRule(localContext, 8, MySqlParser.RULE_ddlStatement); + try { + this.state = 899; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 4, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 860; + this.createDatabase(); + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 861; + this.createEvent(); + } + break; + case 3: + this.enterOuterAlt(localContext, 3); + { + this.state = 862; + this.createIndex(); + } + break; + case 4: + this.enterOuterAlt(localContext, 4); + { + this.state = 863; + this.createLogfileGroup(); + } + break; + case 5: + this.enterOuterAlt(localContext, 5); + { + this.state = 864; + this.createProcedure(); + } + break; + case 6: + this.enterOuterAlt(localContext, 6); + { + this.state = 865; + this.createFunction(); + } + break; + case 7: + this.enterOuterAlt(localContext, 7); + { + this.state = 866; + this.createServer(); + } + break; + case 8: + this.enterOuterAlt(localContext, 8); + { + this.state = 867; + this.createTable(); + } + break; + case 9: + this.enterOuterAlt(localContext, 9); + { + this.state = 868; + this.createTablespaceInnodb(); + } + break; + case 10: + this.enterOuterAlt(localContext, 10); + { + this.state = 869; + this.createTablespaceNdb(); + } + break; + case 11: + this.enterOuterAlt(localContext, 11); + { + this.state = 870; + this.createTrigger(); + } + break; + case 12: + this.enterOuterAlt(localContext, 12); + { + this.state = 871; + this.createView(); + } + break; + case 13: + this.enterOuterAlt(localContext, 13); + { + this.state = 872; + this.createRole(); + } + break; + case 14: + this.enterOuterAlt(localContext, 14); + { + this.state = 873; + this.alterDatabase(); + } + break; + case 15: + this.enterOuterAlt(localContext, 15); + { + this.state = 874; + this.alterEvent(); + } + break; + case 16: + this.enterOuterAlt(localContext, 16); + { + this.state = 875; + this.alterFunction(); + } + break; + case 17: + this.enterOuterAlt(localContext, 17); + { + this.state = 876; + this.alterInstance(); + } + break; + case 18: + this.enterOuterAlt(localContext, 18); + { + this.state = 877; + this.alterLogfileGroup(); + } + break; + case 19: + this.enterOuterAlt(localContext, 19); + { + this.state = 878; + this.alterProcedure(); + } + break; + case 20: + this.enterOuterAlt(localContext, 20); + { + this.state = 879; + this.alterServer(); + } + break; + case 21: + this.enterOuterAlt(localContext, 21); + { + this.state = 880; + this.alterTable(); + } + break; + case 22: + this.enterOuterAlt(localContext, 22); + { + this.state = 881; + this.alterTablespace(); + } + break; + case 23: + this.enterOuterAlt(localContext, 23); + { + this.state = 882; + this.alterView(); + } + break; + case 24: + this.enterOuterAlt(localContext, 24); + { + this.state = 883; + this.dropDatabase(); + } + break; + case 25: + this.enterOuterAlt(localContext, 25); + { + this.state = 884; + this.dropEvent(); + } + break; + case 26: + this.enterOuterAlt(localContext, 26); + { + this.state = 885; + this.dropIndex(); + } + break; + case 27: + this.enterOuterAlt(localContext, 27); + { + this.state = 886; + this.dropLogfileGroup(); + } + break; + case 28: + this.enterOuterAlt(localContext, 28); + { + this.state = 887; + this.dropProcedure(); + } + break; + case 29: + this.enterOuterAlt(localContext, 29); + { + this.state = 888; + this.dropFunction(); + } + break; + case 30: + this.enterOuterAlt(localContext, 30); + { + this.state = 889; + this.dropServer(); + } + break; + case 31: + this.enterOuterAlt(localContext, 31); + { + this.state = 890; + this.dropSpatial(); + } + break; + case 32: + this.enterOuterAlt(localContext, 32); + { + this.state = 891; + this.dropTable(); + } + break; + case 33: + this.enterOuterAlt(localContext, 33); + { + this.state = 892; + this.dropTablespace(); + } + break; + case 34: + this.enterOuterAlt(localContext, 34); + { + this.state = 893; + this.dropTrigger(); + } + break; + case 35: + this.enterOuterAlt(localContext, 35); + { + this.state = 894; + this.dropView(); + } + break; + case 36: + this.enterOuterAlt(localContext, 36); + { + this.state = 895; + this.dropRole(); + } + break; + case 37: + this.enterOuterAlt(localContext, 37); + { + this.state = 896; + this.setRole(); + } + break; + case 38: + this.enterOuterAlt(localContext, 38); + { + this.state = 897; + this.renameTable(); + } + break; + case 39: + this.enterOuterAlt(localContext, 39); + { + this.state = 898; + this.truncateTable(); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + dmlStatement() { + let localContext = new DmlStatementContext(this.context, this.state); + this.enterRule(localContext, 10, MySqlParser.RULE_dmlStatement); + try { + this.state = 918; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 5, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 901; + this.selectStatement(); + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 902; + this.setOperations(); + } + break; + case 3: + this.enterOuterAlt(localContext, 3); + { + this.state = 903; + this.insertStatement(); + } + break; + case 4: + this.enterOuterAlt(localContext, 4); + { + this.state = 904; + this.updateStatement(); + } + break; + case 5: + this.enterOuterAlt(localContext, 5); + { + this.state = 905; + this.deleteStatement(); + } + break; + case 6: + this.enterOuterAlt(localContext, 6); + { + this.state = 906; + this.replaceStatement(); + } + break; + case 7: + this.enterOuterAlt(localContext, 7); + { + this.state = 907; + this.callStatement(); + } + break; + case 8: + this.enterOuterAlt(localContext, 8); + { + this.state = 908; + this.interSectStatement(); + } + break; + case 9: + this.enterOuterAlt(localContext, 9); + { + this.state = 909; + this.loadDataStatement(); + } + break; + case 10: + this.enterOuterAlt(localContext, 10); + { + this.state = 910; + this.loadXmlStatement(); + } + break; + case 11: + this.enterOuterAlt(localContext, 11); + { + this.state = 911; + this.parenthesizedQuery(); + } + break; + case 12: + this.enterOuterAlt(localContext, 12); + { + this.state = 912; + this.doStatement(); + } + break; + case 13: + this.enterOuterAlt(localContext, 13); + { + this.state = 913; + this.handlerStatement(); + } + break; + case 14: + this.enterOuterAlt(localContext, 14); + { + this.state = 914; + this.importTableStatement(); + } + break; + case 15: + this.enterOuterAlt(localContext, 15); + { + this.state = 915; + this.valuesStatement(); + } + break; + case 16: + this.enterOuterAlt(localContext, 16); + { + this.state = 916; + this.withStatement(); + } + break; + case 17: + this.enterOuterAlt(localContext, 17); + { + this.state = 917; + this.tableStatement(); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + transactionStatement() { + let localContext = new TransactionStatementContext(this.context, this.state); + this.enterRule(localContext, 12, MySqlParser.RULE_transactionStatement); + try { + this.state = 929; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 6, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 920; + this.startTransaction(); + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 921; + this.beginWork(); + } + break; + case 3: + this.enterOuterAlt(localContext, 3); + { + this.state = 922; + this.commitWork(); + } + break; + case 4: + this.enterOuterAlt(localContext, 4); + { + this.state = 923; + this.rollbackWork(); + } + break; + case 5: + this.enterOuterAlt(localContext, 5); + { + this.state = 924; + this.savepointStatement(); + } + break; + case 6: + this.enterOuterAlt(localContext, 6); + { + this.state = 925; + this.rollbackStatement(); + } + break; + case 7: + this.enterOuterAlt(localContext, 7); + { + this.state = 926; + this.releaseStatement(); + } + break; + case 8: + this.enterOuterAlt(localContext, 8); + { + this.state = 927; + this.lockTables(); + } + break; + case 9: + this.enterOuterAlt(localContext, 9); + { + this.state = 928; + this.unlockTables(); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + replicationStatement() { + let localContext = new ReplicationStatementContext(this.context, this.state); + this.enterRule(localContext, 14, MySqlParser.RULE_replicationStatement); + try { + this.state = 945; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 7, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 931; + this.changeMaster(); + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 932; + this.changeReplicationFilter(); + } + break; + case 3: + this.enterOuterAlt(localContext, 3); + { + this.state = 933; + this.changeReplicationSource(); + } + break; + case 4: + this.enterOuterAlt(localContext, 4); + { + this.state = 934; + this.purgeBinaryLogs(); + } + break; + case 5: + this.enterOuterAlt(localContext, 5); + { + this.state = 935; + this.startSlaveOrReplica(); + } + break; + case 6: + this.enterOuterAlt(localContext, 6); + { + this.state = 936; + this.stopSlaveOrReplica(); + } + break; + case 7: + this.enterOuterAlt(localContext, 7); + { + this.state = 937; + this.startGroupReplication(); + } + break; + case 8: + this.enterOuterAlt(localContext, 8); + { + this.state = 938; + this.stopGroupReplication(); + } + break; + case 9: + this.enterOuterAlt(localContext, 9); + { + this.state = 939; + this.xaStartTransaction(); + } + break; + case 10: + this.enterOuterAlt(localContext, 10); + { + this.state = 940; + this.xaEndTransaction(); + } + break; + case 11: + this.enterOuterAlt(localContext, 11); + { + this.state = 941; + this.xaPrepareStatement(); + } + break; + case 12: + this.enterOuterAlt(localContext, 12); + { + this.state = 942; + this.xaCommitWork(); + } + break; + case 13: + this.enterOuterAlt(localContext, 13); + { + this.state = 943; + this.xaRollbackWork(); + } + break; + case 14: + this.enterOuterAlt(localContext, 14); + { + this.state = 944; + this.xaRecoverWork(); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + preparedStatement() { + let localContext = new PreparedStatementContext(this.context, this.state); + this.enterRule(localContext, 16, MySqlParser.RULE_preparedStatement); + try { + this.state = 950; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_PREPARE: + this.enterOuterAlt(localContext, 1); + { + this.state = 947; + this.prepareStatement(); + } + break; + case MySqlParser.KW_EXECUTE: + this.enterOuterAlt(localContext, 2); + { + this.state = 948; + this.executeStatement(); + } + break; + case MySqlParser.KW_DROP: + case MySqlParser.KW_DEALLOCATE: + this.enterOuterAlt(localContext, 3); + { + this.state = 949; + this.deallocatePrepare(); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + compoundStatement() { + let localContext = new CompoundStatementContext(this.context, this.state); + this.enterRule(localContext, 18, MySqlParser.RULE_compoundStatement); + try { + this.state = 962; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 9, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 952; + this.blockStatement(); + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 953; + this.caseStatement(); + } + break; + case 3: + this.enterOuterAlt(localContext, 3); + { + this.state = 954; + this.ifStatement(); + } + break; + case 4: + this.enterOuterAlt(localContext, 4); + { + this.state = 955; + this.leaveStatement(); + } + break; + case 5: + this.enterOuterAlt(localContext, 5); + { + this.state = 956; + this.loopStatement(); + } + break; + case 6: + this.enterOuterAlt(localContext, 6); + { + this.state = 957; + this.repeatStatement(); + } + break; + case 7: + this.enterOuterAlt(localContext, 7); + { + this.state = 958; + this.whileStatement(); + } + break; + case 8: + this.enterOuterAlt(localContext, 8); + { + this.state = 959; + this.iterateStatement(); + } + break; + case 9: + this.enterOuterAlt(localContext, 9); + { + this.state = 960; + this.returnStatement(); + } + break; + case 10: + this.enterOuterAlt(localContext, 10); + { + this.state = 961; + this.cursorStatement(); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + administrationStatement() { + let localContext = new AdministrationStatementContext(this.context, this.state); + this.enterRule(localContext, 20, MySqlParser.RULE_administrationStatement); + try { + this.state = 997; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 10, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 964; + this.alterUser(); + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 965; + this.createUser(); + } + break; + case 3: + this.enterOuterAlt(localContext, 3); + { + this.state = 966; + this.dropUser(); + } + break; + case 4: + this.enterOuterAlt(localContext, 4); + { + this.state = 967; + this.grantStatement(); + } + break; + case 5: + this.enterOuterAlt(localContext, 5); + { + this.state = 968; + this.grantProxy(); + } + break; + case 6: + this.enterOuterAlt(localContext, 6); + { + this.state = 969; + this.renameUser(); + } + break; + case 7: + this.enterOuterAlt(localContext, 7); + { + this.state = 970; + this.revokeStatement(); + } + break; + case 8: + this.enterOuterAlt(localContext, 8); + { + this.state = 971; + this.alterResourceGroup(); + } + break; + case 9: + this.enterOuterAlt(localContext, 9); + { + this.state = 972; + this.createResourceGroup(); + } + break; + case 10: + this.enterOuterAlt(localContext, 10); + { + this.state = 973; + this.dropResourceGroup(); + } + break; + case 11: + this.enterOuterAlt(localContext, 11); + { + this.state = 974; + this.setResourceGroup(); + } + break; + case 12: + this.enterOuterAlt(localContext, 12); + { + this.state = 975; + this.analyzeTable(); + } + break; + case 13: + this.enterOuterAlt(localContext, 13); + { + this.state = 976; + this.checkTable(); + } + break; + case 14: + this.enterOuterAlt(localContext, 14); + { + this.state = 977; + this.checksumTable(); + } + break; + case 15: + this.enterOuterAlt(localContext, 15); + { + this.state = 978; + this.optimizeTable(); + } + break; + case 16: + this.enterOuterAlt(localContext, 16); + { + this.state = 979; + this.repairTable(); + } + break; + case 17: + this.enterOuterAlt(localContext, 17); + { + this.state = 980; + this.installComponent(); + } + break; + case 18: + this.enterOuterAlt(localContext, 18); + { + this.state = 981; + this.uninstallComponent(); + } + break; + case 19: + this.enterOuterAlt(localContext, 19); + { + this.state = 982; + this.installPlugin(); + } + break; + case 20: + this.enterOuterAlt(localContext, 20); + { + this.state = 983; + this.uninstallPlugin(); + } + break; + case 21: + this.enterOuterAlt(localContext, 21); + { + this.state = 984; + this.cloneStatement(); + } + break; + case 22: + this.enterOuterAlt(localContext, 22); + { + this.state = 985; + this.setStatement(); + } + break; + case 23: + this.enterOuterAlt(localContext, 23); + { + this.state = 986; + this.showStatement(); + } + break; + case 24: + this.enterOuterAlt(localContext, 24); + { + this.state = 987; + this.binlogStatement(); + } + break; + case 25: + this.enterOuterAlt(localContext, 25); + { + this.state = 988; + this.cacheIndexStatement(); + } + break; + case 26: + this.enterOuterAlt(localContext, 26); + { + this.state = 989; + this.flushStatement(); + } + break; + case 27: + this.enterOuterAlt(localContext, 27); + { + this.state = 990; + this.killStatement(); + } + break; + case 28: + this.enterOuterAlt(localContext, 28); + { + this.state = 991; + this.loadIndexIntoCache(); + } + break; + case 29: + this.enterOuterAlt(localContext, 29); + { + this.state = 992; + this.resetStatement(); + } + break; + case 30: + this.enterOuterAlt(localContext, 30); + { + this.state = 993; + this.resetPersist(); + } + break; + case 31: + this.enterOuterAlt(localContext, 31); + { + this.state = 994; + this.resetAllChannel(); + } + break; + case 32: + this.enterOuterAlt(localContext, 32); + { + this.state = 995; + this.reStartStatement(); + } + break; + case 33: + this.enterOuterAlt(localContext, 33); + { + this.state = 996; + this.shutdownStatement(); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + utilityStatement() { + let localContext = new UtilityStatementContext(this.context, this.state); + this.enterRule(localContext, 22, MySqlParser.RULE_utilityStatement); + try { + this.state = 1007; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 11, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 999; + this.fullDescribeStatement(); + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 1000; + this.simpleDescribeStatement(); + } + break; + case 3: + this.enterOuterAlt(localContext, 3); + { + this.state = 1001; + this.analyzeDescribeStatement(); + } + break; + case 4: + this.enterOuterAlt(localContext, 4); + { + this.state = 1002; + this.helpStatement(); + } + break; + case 5: + this.enterOuterAlt(localContext, 5); + { + this.state = 1003; + this.useStatement(); + } + break; + case 6: + this.enterOuterAlt(localContext, 6); + { + this.state = 1004; + this.signalStatement(); + } + break; + case 7: + this.enterOuterAlt(localContext, 7); + { + this.state = 1005; + this.resignalStatement(); + } + break; + case 8: + this.enterOuterAlt(localContext, 8); + { + this.state = 1006; + this.diagnosticsStatement(); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + createDatabase() { + let localContext = new CreateDatabaseContext(this.context, this.state); + this.enterRule(localContext, 24, MySqlParser.RULE_createDatabase); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 1009; + this.match(MySqlParser.KW_CREATE); + this.state = 1010; + localContext._dbFormat = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 39 || _la === 152)) { + localContext._dbFormat = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 1012; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 12, this.context)) { + case 1: + { + this.state = 1011; + this.ifNotExists(); + } + break; + } + this.state = 1014; + this.databaseNameCreate(); + this.state = 1018; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (((((_la - 26)) & ~0x1F) === 0 && ((1 << (_la - 26)) & 65541) !== 0) || _la === 135 || _la === 224 || _la === 376 || _la === 823) { + { + { + this.state = 1015; + this.createDatabaseOption(); + } + } + this.state = 1020; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + createEvent() { + let localContext = new CreateEventContext(this.context, this.state); + this.enterRule(localContext, 26, MySqlParser.RULE_createEvent); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 1021; + this.match(MySqlParser.KW_CREATE); + this.state = 1023; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 364) { + { + this.state = 1022; + this.ownerStatement(); + } + } + this.state = 1025; + this.match(MySqlParser.KW_EVENT); + this.state = 1027; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 15, this.context)) { + case 1: + { + this.state = 1026; + this.ifNotExists(); + } + break; + } + this.state = 1029; + localContext._event_name = this.fullId(); + this.state = 1030; + this.match(MySqlParser.KW_ON); + this.state = 1031; + this.match(MySqlParser.KW_SCHEDULE); + this.state = 1032; + this.scheduleExpression(); + this.state = 1039; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 119) { + { + this.state = 1033; + this.match(MySqlParser.KW_ON); + this.state = 1034; + this.match(MySqlParser.KW_COMPLETION); + this.state = 1036; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 114) { + { + this.state = 1035; + this.match(MySqlParser.KW_NOT); + } + } + this.state = 1038; + this.match(MySqlParser.KW_PRESERVE); + } + } + this.state = 1042; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 368 || _la === 375) { + { + this.state = 1041; + this.enableType(); + } + } + this.state = 1046; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 340) { + { + this.state = 1044; + this.match(MySqlParser.KW_COMMENT); + this.state = 1045; + this.match(MySqlParser.STRING_LITERAL); + } + } + this.state = 1048; + this.match(MySqlParser.KW_DO); + this.state = 1049; + this.routineBody(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + createIndex() { + let localContext = new CreateIndexContext(this.context, this.state); + this.enterRule(localContext, 28, MySqlParser.RULE_createIndex); + let _la; + try { + let alternative; + this.enterOuterAlt(localContext, 1); + { + this.state = 1051; + this.match(MySqlParser.KW_CREATE); + this.state = 1053; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 508 || _la === 514) { + { + this.state = 1052; + localContext._intimeAction = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 508 || _la === 514)) { + localContext._intimeAction = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + this.state = 1056; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 69 || _la === 161 || _la === 182) { + { + this.state = 1055; + localContext._indexCategory = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 69 || _la === 161 || _la === 182)) { + localContext._indexCategory = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + this.state = 1058; + this.match(MySqlParser.KW_INDEX); + this.state = 1059; + this.indexNameCreate(); + this.state = 1061; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 188) { + { + this.state = 1060; + this.indexType(); + } + } + this.state = 1063; + this.match(MySqlParser.KW_ON); + this.state = 1064; + this.tableName(); + this.state = 1065; + this.indexColumnNames(); + this.state = 1069; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 23, this.context); + while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER) { + if (alternative === 1) { + { + { + this.state = 1066; + this.indexOption(); + } + } + } + this.state = 1071; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 23, this.context); + } + this.state = 1084; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 27, this.context); + while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER) { + if (alternative === 1) { + { + this.state = 1082; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_ALGORITHM: + { + this.state = 1072; + this.match(MySqlParser.KW_ALGORITHM); + this.state = 1074; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 1073; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 1076; + localContext._algType = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 42 || _la === 357 || _la === 430)) { + localContext._algType = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + break; + case MySqlParser.KW_LOCK: + { + this.state = 1077; + this.match(MySqlParser.KW_LOCK); + this.state = 1079; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 1078; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 1081; + localContext._lockType = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 42 || _la === 389 || _la === 505 || _la === 595)) { + localContext._lockType = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + } + this.state = 1086; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 27, this.context); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + createLogfileGroup() { + let localContext = new CreateLogfileGroupContext(this.context, this.state); + this.enterRule(localContext, 30, MySqlParser.RULE_createLogfileGroup); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 1087; + this.match(MySqlParser.KW_CREATE); + this.state = 1088; + this.match(MySqlParser.KW_LOGFILE); + this.state = 1089; + this.match(MySqlParser.KW_GROUP); + this.state = 1090; + localContext._logfileGroupName = this.uid(); + this.state = 1091; + this.match(MySqlParser.KW_ADD); + this.state = 1092; + this.match(MySqlParser.KW_UNDOFILE); + this.state = 1093; + localContext._undoFile = this.match(MySqlParser.STRING_LITERAL); + this.state = 1099; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 428) { + { + this.state = 1094; + this.match(MySqlParser.KW_INITIAL_SIZE); + this.state = 1096; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 1095; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 1098; + localContext._initSize = this.fileSizeLiteral(); + } + } + this.state = 1106; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 672) { + { + this.state = 1101; + this.match(MySqlParser.KW_UNDO_BUFFER_SIZE); + this.state = 1103; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 1102; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 1105; + localContext._undoSize = this.fileSizeLiteral(); + } + } + this.state = 1113; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 553) { + { + this.state = 1108; + this.match(MySqlParser.KW_REDO_BUFFER_SIZE); + this.state = 1110; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 1109; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 1112; + localContext._redoSize = this.fileSizeLiteral(); + } + } + this.state = 1120; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 504) { + { + this.state = 1115; + this.match(MySqlParser.KW_NODEGROUP); + this.state = 1117; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 1116; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 1119; + localContext._nodegroup = this.uid(); + } + } + this.state = 1123; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 687) { + { + this.state = 1122; + this.match(MySqlParser.KW_WAIT); + } + } + this.state = 1130; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 340) { + { + this.state = 1125; + this.match(MySqlParser.KW_COMMENT); + this.state = 1127; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 1126; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 1129; + localContext._comment = this.match(MySqlParser.STRING_LITERAL); + } + } + this.state = 1132; + this.match(MySqlParser.KW_ENGINE); + this.state = 1134; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 1133; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 1136; + this.engineName(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + createProcedure() { + let localContext = new CreateProcedureContext(this.context, this.state); + this.enterRule(localContext, 32, MySqlParser.RULE_createProcedure); + let _la; + try { + let alternative; + this.enterOuterAlt(localContext, 1); + { + this.state = 1138; + this.match(MySqlParser.KW_CREATE); + this.state = 1140; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 364) { + { + this.state = 1139; + this.ownerStatement(); + } + } + this.state = 1142; + this.match(MySqlParser.KW_PROCEDURE); + this.state = 1144; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 41, this.context)) { + case 1: + { + this.state = 1143; + this.ifNotExists(); + } + break; + } + this.state = 1146; + localContext._sp_name = this.fullId(); + this.state = 1147; + this.match(MySqlParser.LR_BRACKET); + this.state = 1149; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if ((((_la) & ~0x1F) === 0 && ((1 << _la) & 1074302976) !== 0) || ((((_la - 36)) & ~0x1F) === 0 && ((1 << (_la - 36)) & 11014219) !== 0) || ((((_la - 74)) & ~0x1F) === 0 && ((1 << (_la - 74)) & 18880593) !== 0) || ((((_la - 117)) & ~0x1F) === 0 && ((1 << (_la - 117)) & 100680481) !== 0) || ((((_la - 150)) & ~0x1F) === 0 && ((1 << (_la - 150)) & 1049605) !== 0) || ((((_la - 219)) & ~0x1F) === 0 && ((1 << (_la - 219)) & 5374495) !== 0) || ((((_la - 253)) & ~0x1F) === 0 && ((1 << (_la - 253)) & 4294967295) !== 0) || ((((_la - 285)) & ~0x1F) === 0 && ((1 << (_la - 285)) & 4261412607) !== 0) || ((((_la - 317)) & ~0x1F) === 0 && ((1 << (_la - 317)) & 4160741375) !== 0) || ((((_la - 349)) & ~0x1F) === 0 && ((1 << (_la - 349)) & 4026531839) !== 0) || ((((_la - 381)) & ~0x1F) === 0 && ((1 << (_la - 381)) & 1055907839) !== 0) || ((((_la - 413)) & ~0x1F) === 0 && ((1 << (_la - 413)) & 4294885367) !== 0) || ((((_la - 445)) & ~0x1F) === 0 && ((1 << (_la - 445)) & 3757571071) !== 0) || ((((_la - 478)) & ~0x1F) === 0 && ((1 << (_la - 478)) & 3755999231) !== 0) || ((((_la - 510)) & ~0x1F) === 0 && ((1 << (_la - 510)) & 3751780349) !== 0) || ((((_la - 542)) & ~0x1F) === 0 && ((1 << (_la - 542)) & 2141183997) !== 0) || ((((_la - 575)) & ~0x1F) === 0 && ((1 << (_la - 575)) & 2147483629) !== 0) || ((((_la - 633)) & ~0x1F) === 0 && ((1 << (_la - 633)) & 4294934527) !== 0) || ((((_la - 665)) & ~0x1F) === 0 && ((1 << (_la - 665)) & 4278189053) !== 0) || ((((_la - 697)) & ~0x1F) === 0 && ((1 << (_la - 697)) & 1644099327) !== 0) || ((((_la - 729)) & ~0x1F) === 0 && ((1 << (_la - 729)) & 4294900735) !== 0) || ((((_la - 761)) & ~0x1F) === 0 && ((1 << (_la - 761)) & 4294967295) !== 0) || ((((_la - 793)) & ~0x1F) === 0 && ((1 << (_la - 793)) & 4288675839) !== 0) || ((((_la - 825)) & ~0x1F) === 0 && ((1 << (_la - 825)) & 2147527671) !== 0) || ((((_la - 879)) & ~0x1F) === 0 && ((1 << (_la - 879)) & 1033) !== 0)) { + { + this.state = 1148; + this.procedureParameter(); + } + } + this.state = 1155; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 1151; + this.match(MySqlParser.COMMA); + this.state = 1152; + this.procedureParameter(); + } + } + this.state = 1157; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 1158; + this.match(MySqlParser.RR_BRACKET); + this.state = 1162; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 44, this.context); + while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER) { + if (alternative === 1) { + { + { + this.state = 1159; + this.routineOption(); + } + } + } + this.state = 1164; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 44, this.context); + } + this.state = 1165; + this.routineBody(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + createRole() { + let localContext = new CreateRoleContext(this.context, this.state); + this.enterRule(localContext, 34, MySqlParser.RULE_createRole); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 1167; + this.match(MySqlParser.KW_CREATE); + this.state = 1168; + this.match(MySqlParser.KW_ROLE); + this.state = 1170; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 45, this.context)) { + case 1: + { + this.state = 1169; + this.ifNotExists(); + } + break; + } + this.state = 1172; + this.userOrRoleNames(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + createServer() { + let localContext = new CreateServerContext(this.context, this.state); + this.enterRule(localContext, 36, MySqlParser.RULE_createServer); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 1174; + this.match(MySqlParser.KW_CREATE); + this.state = 1175; + this.match(MySqlParser.KW_SERVER); + this.state = 1176; + localContext._servername = this.uid(); + this.state = 1177; + this.match(MySqlParser.KW_FOREIGN); + this.state = 1178; + this.match(MySqlParser.KW_DATA); + this.state = 1179; + this.match(MySqlParser.KW_WRAPPER); + this.state = 1180; + localContext._wrapperName = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 494 || _la === 882)) { + localContext._wrapperName = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 1181; + this.match(MySqlParser.KW_OPTIONS); + this.state = 1182; + this.match(MySqlParser.LR_BRACKET); + this.state = 1183; + this.serverOption(); + this.state = 1188; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 1184; + this.match(MySqlParser.COMMA); + this.state = 1185; + this.serverOption(); + } + } + this.state = 1190; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 1191; + this.match(MySqlParser.RR_BRACKET); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + createTable() { + let localContext = new CreateTableContext(this.context, this.state); + this.enterRule(localContext, 38, MySqlParser.RULE_createTable); + let _la; + try { + let alternative; + this.state = 1271; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 65, this.context)) { + case 1: + localContext = new QueryCreateTableContext(localContext); + this.enterOuterAlt(localContext, 1); + { + this.state = 1193; + this.match(MySqlParser.KW_CREATE); + this.state = 1195; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 660) { + { + this.state = 1194; + this.match(MySqlParser.KW_TEMPORARY); + } + } + this.state = 1197; + this.match(MySqlParser.KW_TABLE); + this.state = 1199; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 48, this.context)) { + case 1: + { + this.state = 1198; + this.ifNotExists(); + } + break; + } + this.state = 1201; + localContext._tb = this.tableNameCreate(); + this.state = 1203; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 49, this.context)) { + case 1: + { + this.state = 1202; + localContext._col = this.createDefinitions(); + } + break; + } + this.state = 1215; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (((((_la - 26)) & ~0x1F) === 0 && ((1 << (_la - 26)) & 65541) !== 0) || _la === 82 || _la === 181 || _la === 224 || ((((_la - 314)) & ~0x1F) === 0 && ((1 << (_la - 314)) & 67141639) !== 0) || ((((_la - 346)) & ~0x1F) === 0 && ((1 << (_la - 346)) & 3221766153) !== 0) || _la === 380 || _la === 431 || _la === 443 || _la === 480 || _la === 490 || ((((_la - 520)) & ~0x1F) === 0 && ((1 << (_la - 520)) & 541) !== 0) || _la === 588 || ((((_la - 640)) & ~0x1F) === 0 && ((1 << (_la - 640)) & 34341021) !== 0) || ((((_la - 823)) & ~0x1F) === 0 && ((1 << (_la - 823)) & 1029) !== 0) || _la === 882) { + { + this.state = 1205; + this.tableOption(); + this.state = 1212; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (((((_la - 26)) & ~0x1F) === 0 && ((1 << (_la - 26)) & 65541) !== 0) || _la === 82 || _la === 181 || _la === 224 || ((((_la - 314)) & ~0x1F) === 0 && ((1 << (_la - 314)) & 67141639) !== 0) || ((((_la - 346)) & ~0x1F) === 0 && ((1 << (_la - 346)) & 3221766153) !== 0) || _la === 380 || _la === 431 || _la === 443 || _la === 480 || _la === 490 || ((((_la - 520)) & ~0x1F) === 0 && ((1 << (_la - 520)) & 541) !== 0) || _la === 588 || ((((_la - 640)) & ~0x1F) === 0 && ((1 << (_la - 640)) & 34341021) !== 0) || ((((_la - 823)) & ~0x1F) === 0 && ((1 << (_la - 823)) & 1029) !== 0) || _la === 868 || _la === 882) { + { + { + this.state = 1207; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 868) { + { + this.state = 1206; + this.match(MySqlParser.COMMA); + } + } + this.state = 1209; + this.tableOption(); + } + } + this.state = 1214; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + } + this.state = 1218; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 130) { + { + this.state = 1217; + this.partitionDefinitions(); + } + } + this.state = 1221; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 79 || _la === 143) { + { + this.state = 1220; + _la = this.tokenStream.LA(1); + if (!(_la === 79 || _la === 143)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + this.state = 1224; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 13) { + { + this.state = 1223; + this.match(MySqlParser.KW_AS); + } + } + this.state = 1226; + this.selectStatement(); + } + break; + case 2: + localContext = new CopyCreateTableContext(localContext); + this.enterOuterAlt(localContext, 2); + { + this.state = 1228; + this.match(MySqlParser.KW_CREATE); + this.state = 1230; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 660) { + { + this.state = 1229; + this.match(MySqlParser.KW_TEMPORARY); + } + } + this.state = 1232; + this.match(MySqlParser.KW_TABLE); + this.state = 1234; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 57, this.context)) { + case 1: + { + this.state = 1233; + this.ifNotExists(); + } + break; + } + this.state = 1236; + this.tableNameCreate(); + this.state = 1244; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_LIKE: + { + this.state = 1237; + this.match(MySqlParser.KW_LIKE); + this.state = 1238; + this.tableName(); + } + break; + case MySqlParser.LR_BRACKET: + { + this.state = 1239; + this.match(MySqlParser.LR_BRACKET); + this.state = 1240; + this.match(MySqlParser.KW_LIKE); + this.state = 1241; + this.tableName(); + this.state = 1242; + this.match(MySqlParser.RR_BRACKET); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + break; + case 3: + localContext = new ColumnCreateTableContext(localContext); + this.enterOuterAlt(localContext, 3); + { + this.state = 1246; + this.match(MySqlParser.KW_CREATE); + this.state = 1248; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 660) { + { + this.state = 1247; + this.match(MySqlParser.KW_TEMPORARY); + } + } + this.state = 1250; + this.match(MySqlParser.KW_TABLE); + this.state = 1252; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 60, this.context)) { + case 1: + { + this.state = 1251; + this.ifNotExists(); + } + break; + } + this.state = 1254; + this.tableNameCreate(); + this.state = 1255; + this.createDefinitions(); + this.state = 1266; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 63, this.context)) { + case 1: + { + this.state = 1256; + this.tableOption(); + this.state = 1263; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 62, this.context); + while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER) { + if (alternative === 1) { + { + { + this.state = 1258; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 868) { + { + this.state = 1257; + this.match(MySqlParser.COMMA); + } + } + this.state = 1260; + this.tableOption(); + } + } + } + this.state = 1265; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 62, this.context); + } + } + break; + } + this.state = 1269; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 130) { + { + this.state = 1268; + this.partitionDefinitions(); + } + } + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + createTablespaceInnodb() { + let localContext = new CreateTablespaceInnodbContext(this.context, this.state); + this.enterRule(localContext, 40, MySqlParser.RULE_createTablespaceInnodb); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 1273; + this.match(MySqlParser.KW_CREATE); + this.state = 1275; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 180) { + { + this.state = 1274; + this.match(MySqlParser.KW_UNDO); + } + } + this.state = 1277; + this.match(MySqlParser.KW_TABLESPACE); + this.state = 1278; + this.tablespaceNameCreate(); + this.state = 1282; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 6) { + { + this.state = 1279; + this.match(MySqlParser.KW_ADD); + this.state = 1280; + this.match(MySqlParser.KW_DATAFILE); + this.state = 1281; + localContext._datafile = this.match(MySqlParser.STRING_LITERAL); + } + } + this.state = 1289; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 314) { + { + this.state = 1284; + this.match(MySqlParser.KW_AUTOEXTEND_SIZE); + this.state = 1286; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 1285; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 1288; + localContext._autoextendSize = this.fileSizeLiteral(); + } + } + this.state = 1294; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 399) { + { + this.state = 1291; + this.match(MySqlParser.KW_FILE_BLOCK_SIZE); + this.state = 1292; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 1293; + localContext._fileBlockSize = this.fileSizeLiteral(); + } + } + this.state = 1301; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 380) { + { + this.state = 1296; + this.match(MySqlParser.KW_ENGINE); + this.state = 1298; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 1297; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 1300; + this.engineName(); + } + } + this.state = 1308; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 825) { + { + this.state = 1303; + this.match(MySqlParser.KW_ENGINE_ATTRIBUTE); + this.state = 1305; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 1304; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 1307; + this.match(MySqlParser.STRING_LITERAL); + } + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + createTablespaceNdb() { + let localContext = new CreateTablespaceNdbContext(this.context, this.state); + this.enterRule(localContext, 42, MySqlParser.RULE_createTablespaceNdb); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 1310; + this.match(MySqlParser.KW_CREATE); + this.state = 1312; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 180) { + { + this.state = 1311; + this.match(MySqlParser.KW_UNDO); + } + } + this.state = 1314; + this.match(MySqlParser.KW_TABLESPACE); + this.state = 1315; + this.tablespaceNameCreate(); + this.state = 1316; + this.match(MySqlParser.KW_ADD); + this.state = 1317; + this.match(MySqlParser.KW_DATAFILE); + this.state = 1318; + localContext._datafile = this.match(MySqlParser.STRING_LITERAL); + this.state = 1319; + this.match(MySqlParser.KW_USE); + this.state = 1320; + this.match(MySqlParser.KW_LOGFILE); + this.state = 1321; + this.match(MySqlParser.KW_GROUP); + this.state = 1322; + localContext._logfileGroupName = this.uid(); + this.state = 1328; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 393) { + { + this.state = 1323; + this.match(MySqlParser.KW_EXTENT_SIZE); + this.state = 1325; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 1324; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 1327; + localContext._extentSize = this.fileSizeLiteral(); + } + } + this.state = 1335; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 428) { + { + this.state = 1330; + this.match(MySqlParser.KW_INITIAL_SIZE); + this.state = 1332; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 1331; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 1334; + localContext._initialSize = this.fileSizeLiteral(); + } + } + this.state = 1342; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 314) { + { + this.state = 1337; + this.match(MySqlParser.KW_AUTOEXTEND_SIZE); + this.state = 1339; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 1338; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 1341; + localContext._autoextendSize = this.fileSizeLiteral(); + } + } + this.state = 1349; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 481) { + { + this.state = 1344; + this.match(MySqlParser.KW_MAX_SIZE); + this.state = 1346; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 1345; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 1348; + localContext._maxSize = this.fileSizeLiteral(); + } + } + this.state = 1356; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 504) { + { + this.state = 1351; + this.match(MySqlParser.KW_NODEGROUP); + this.state = 1353; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 1352; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 1355; + localContext._nodegroup = this.uid(); + } + } + this.state = 1359; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 687) { + { + this.state = 1358; + this.match(MySqlParser.KW_WAIT); + } + } + this.state = 1366; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 340) { + { + this.state = 1361; + this.match(MySqlParser.KW_COMMENT); + this.state = 1363; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 1362; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 1365; + localContext._comment = this.match(MySqlParser.STRING_LITERAL); + } + } + this.state = 1368; + this.match(MySqlParser.KW_ENGINE); + this.state = 1370; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 1369; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 1372; + this.engineName(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + createTrigger() { + let localContext = new CreateTriggerContext(this.context, this.state); + this.enterRule(localContext, 44, MySqlParser.RULE_createTrigger); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 1374; + this.match(MySqlParser.KW_CREATE); + this.state = 1376; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 364) { + { + this.state = 1375; + this.ownerStatement(); + } + } + this.state = 1378; + this.match(MySqlParser.KW_TRIGGER); + this.state = 1380; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 91, this.context)) { + case 1: + { + this.state = 1379; + this.ifNotExists(); + } + break; + } + this.state = 1382; + localContext._trigger_name = this.fullId(); + this.state = 1383; + localContext._triggerTime = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 16 || _la === 306)) { + localContext._triggerTime = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 1384; + localContext._triggerEvent = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 44 || _la === 86 || _la === 185)) { + localContext._triggerEvent = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 1385; + this.match(MySqlParser.KW_ON); + this.state = 1386; + this.tableName(); + this.state = 1387; + this.match(MySqlParser.KW_FOR); + this.state = 1388; + this.match(MySqlParser.KW_EACH); + this.state = 1389; + this.match(MySqlParser.KW_ROW); + this.state = 1392; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 92, this.context)) { + case 1: + { + this.state = 1390; + localContext._triggerPlace = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 406 || _la === 538)) { + localContext._triggerPlace = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 1391; + localContext._other_trigger_name = this.fullId(); + } + break; + } + this.state = 1394; + this.routineBody(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + withClause() { + let localContext = new WithClauseContext(this.context, this.state); + this.enterRule(localContext, 46, MySqlParser.RULE_withClause); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 1396; + this.match(MySqlParser.KW_WITH); + this.state = 1398; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 93, this.context)) { + case 1: + { + this.state = 1397; + this.match(MySqlParser.KW_RECURSIVE); + } + break; + } + this.state = 1400; + this.commonTableExpressions(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + commonTableExpressions() { + let localContext = new CommonTableExpressionsContext(this.context, this.state); + this.enterRule(localContext, 48, MySqlParser.RULE_commonTableExpressions); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 1402; + localContext._cteName = this.uid(); + this.state = 1414; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 866) { + { + this.state = 1403; + this.match(MySqlParser.LR_BRACKET); + this.state = 1404; + localContext._cteColumnName = this.uid(); + this.state = 1409; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 1405; + this.match(MySqlParser.COMMA); + this.state = 1406; + localContext._cteColumnName = this.uid(); + } + } + this.state = 1411; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 1412; + this.match(MySqlParser.RR_BRACKET); + } + } + this.state = 1416; + this.match(MySqlParser.KW_AS); + this.state = 1417; + this.match(MySqlParser.LR_BRACKET); + this.state = 1418; + this.dmlStatement(); + this.state = 1419; + this.match(MySqlParser.RR_BRACKET); + this.state = 1422; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 96, this.context)) { + case 1: + { + this.state = 1420; + this.match(MySqlParser.COMMA); + this.state = 1421; + this.commonTableExpressions(); + } + break; + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + createView() { + let localContext = new CreateViewContext(this.context, this.state); + this.enterRule(localContext, 50, MySqlParser.RULE_createView); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 1424; + this.match(MySqlParser.KW_CREATE); + this.state = 1426; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 124) { + { + this.state = 1425; + this.orReplace(); + } + } + this.state = 1431; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 308) { + { + this.state = 1428; + this.match(MySqlParser.KW_ALGORITHM); + this.state = 1429; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 1430; + localContext._algType = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 486 || _la === 661 || _la === 670)) { + localContext._algType = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + this.state = 1434; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 364) { + { + this.state = 1433; + this.ownerStatement(); + } + } + this.state = 1439; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 162) { + { + this.state = 1436; + this.match(MySqlParser.KW_SQL); + this.state = 1437; + this.match(MySqlParser.KW_SECURITY); + this.state = 1438; + localContext._secContext = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 364 || _la === 436)) { + localContext._secContext = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + this.state = 1441; + this.match(MySqlParser.KW_VIEW); + this.state = 1442; + this.viewNameCreate(); + this.state = 1454; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 866) { + { + this.state = 1443; + this.match(MySqlParser.LR_BRACKET); + this.state = 1444; + this.columnNameCreate(); + this.state = 1449; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 1445; + this.match(MySqlParser.COMMA); + this.state = 1446; + this.columnNameCreate(); + } + } + this.state = 1451; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 1452; + this.match(MySqlParser.RR_BRACKET); + } + } + this.state = 1456; + this.match(MySqlParser.KW_AS); + this.state = 1476; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 107, this.context)) { + case 1: + { + this.state = 1457; + this.match(MySqlParser.LR_BRACKET); + this.state = 1459; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 194) { + { + this.state = 1458; + this.withClause(); + } + } + this.state = 1461; + this.selectStatement(); + this.state = 1462; + this.match(MySqlParser.RR_BRACKET); + } + break; + case 2: + { + this.state = 1465; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 194) { + { + this.state = 1464; + this.withClause(); + } + } + this.state = 1467; + this.selectStatement(); + this.state = 1474; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 106, this.context)) { + case 1: + { + this.state = 1468; + this.match(MySqlParser.KW_WITH); + this.state = 1470; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 325 || _la === 450) { + { + this.state = 1469; + localContext._checkOption = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 325 || _la === 450)) { + localContext._checkOption = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + this.state = 1472; + this.match(MySqlParser.KW_CHECK); + this.state = 1473; + this.match(MySqlParser.KW_OPTION); + } + break; + } + } + break; + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + createDatabaseOption() { + let localContext = new CreateDatabaseOptionContext(this.context, this.state); + this.enterRule(localContext, 52, MySqlParser.RULE_createDatabaseOption); + let _la; + try { + this.state = 1511; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 116, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 1479; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 42) { + { + this.state = 1478; + this.match(MySqlParser.KW_DEFAULT); + } + } + this.state = 1481; + this.charSet(); + this.state = 1483; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 1482; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 1487; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_BINARY: + case MySqlParser.KW_ARMSCII8: + case MySqlParser.KW_ASCII: + case MySqlParser.KW_BIG5: + case MySqlParser.KW_CP1250: + case MySqlParser.KW_CP1251: + case MySqlParser.KW_CP1256: + case MySqlParser.KW_CP1257: + case MySqlParser.KW_CP850: + case MySqlParser.KW_CP852: + case MySqlParser.KW_CP866: + case MySqlParser.KW_CP932: + case MySqlParser.KW_DEC8: + case MySqlParser.KW_EUCJPMS: + case MySqlParser.KW_EUCKR: + case MySqlParser.KW_GB18030: + case MySqlParser.KW_GB2312: + case MySqlParser.KW_GBK: + case MySqlParser.KW_GEOSTD8: + case MySqlParser.KW_GREEK: + case MySqlParser.KW_HEBREW: + case MySqlParser.KW_HP8: + case MySqlParser.KW_KEYBCS2: + case MySqlParser.KW_KOI8R: + case MySqlParser.KW_KOI8U: + case MySqlParser.KW_LATIN1: + case MySqlParser.KW_LATIN2: + case MySqlParser.KW_LATIN5: + case MySqlParser.KW_LATIN7: + case MySqlParser.KW_MACCE: + case MySqlParser.KW_MACROMAN: + case MySqlParser.KW_SJIS: + case MySqlParser.KW_SWE7: + case MySqlParser.KW_TIS620: + case MySqlParser.KW_UCS2: + case MySqlParser.KW_UJIS: + case MySqlParser.KW_UTF16: + case MySqlParser.KW_UTF16LE: + case MySqlParser.KW_UTF32: + case MySqlParser.KW_UTF8: + case MySqlParser.KW_UTF8MB3: + case MySqlParser.KW_UTF8MB4: + case MySqlParser.CHARSET_REVERSE_QOUTE_STRING: + case MySqlParser.STRING_LITERAL: + { + this.state = 1485; + this.charsetName(); + } + break; + case MySqlParser.KW_DEFAULT: + { + this.state = 1486; + this.match(MySqlParser.KW_DEFAULT); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 1490; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 42) { + { + this.state = 1489; + this.match(MySqlParser.KW_DEFAULT); + } + } + this.state = 1492; + this.match(MySqlParser.KW_COLLATE); + this.state = 1494; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 1493; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 1496; + this.collationName(); + } + break; + case 3: + this.enterOuterAlt(localContext, 3); + { + this.state = 1498; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 42) { + { + this.state = 1497; + this.match(MySqlParser.KW_DEFAULT); + } + } + this.state = 1500; + this.match(MySqlParser.KW_ENCRYPTION); + this.state = 1502; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 1501; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 1504; + this.match(MySqlParser.STRING_LITERAL); + } + break; + case 4: + this.enterOuterAlt(localContext, 4); + { + this.state = 1505; + this.match(MySqlParser.KW_READ); + this.state = 1506; + this.match(MySqlParser.KW_ONLY); + this.state = 1508; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 1507; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 1510; + _la = this.tokenStream.LA(1); + if (!(_la === 42 || _la === 871 || _la === 872)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + charSet() { + let localContext = new CharSetContext(this.context, this.state); + this.enterRule(localContext, 54, MySqlParser.RULE_charSet); + try { + this.state = 1518; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_CHARACTER: + this.enterOuterAlt(localContext, 1); + { + this.state = 1513; + this.match(MySqlParser.KW_CHARACTER); + this.state = 1514; + this.match(MySqlParser.KW_SET); + } + break; + case MySqlParser.KW_CHARSET: + this.enterOuterAlt(localContext, 2); + { + this.state = 1515; + this.match(MySqlParser.KW_CHARSET); + } + break; + case MySqlParser.KW_CHAR: + this.enterOuterAlt(localContext, 3); + { + this.state = 1516; + this.match(MySqlParser.KW_CHAR); + this.state = 1517; + this.match(MySqlParser.KW_SET); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + currentUserExpression() { + let localContext = new CurrentUserExpressionContext(this.context, this.state); + this.enterRule(localContext, 56, MySqlParser.RULE_currentUserExpression); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 1520; + _la = this.tokenStream.LA(1); + if (!(_la === 37 || _la === 678)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 1523; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 118, this.context)) { + case 1: + { + this.state = 1521; + this.match(MySqlParser.LR_BRACKET); + this.state = 1522; + this.match(MySqlParser.RR_BRACKET); + } + break; + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + ownerStatement() { + let localContext = new OwnerStatementContext(this.context, this.state); + this.enterRule(localContext, 58, MySqlParser.RULE_ownerStatement); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 1525; + this.match(MySqlParser.KW_DEFINER); + this.state = 1526; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 1529; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 119, this.context)) { + case 1: + { + this.state = 1527; + this.userName(); + } + break; + case 2: + { + this.state = 1528; + this.currentUserExpression(); + } + break; + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + scheduleExpression() { + let localContext = new ScheduleExpressionContext(this.context, this.state); + this.enterRule(localContext, 60, MySqlParser.RULE_scheduleExpression); + let _la; + try { + this.state = 1565; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_AT: + localContext = new PreciseScheduleContext(localContext); + this.enterOuterAlt(localContext, 1); + { + this.state = 1531; + this.match(MySqlParser.KW_AT); + this.state = 1532; + this.timestampValue(); + this.state = 1536; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 853) { + { + { + this.state = 1533; + this.intervalExpr(); + } + } + this.state = 1538; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + break; + case MySqlParser.KW_EVERY: + localContext = new IntervalScheduleContext(localContext); + this.enterOuterAlt(localContext, 2); + { + this.state = 1539; + this.match(MySqlParser.KW_EVERY); + this.state = 1542; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 121, this.context)) { + case 1: + { + this.state = 1540; + this.decimalLiteral(); + } + break; + case 2: + { + this.state = 1541; + this.expression(0); + } + break; + } + this.state = 1544; + this.intervalType(); + this.state = 1553; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 641) { + { + this.state = 1545; + this.match(MySqlParser.KW_STARTS); + this.state = 1546; + localContext._startTimestamp = this.timestampValue(); + this.state = 1550; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 853) { + { + { + this.state = 1547; + localContext._intervalExpr = this.intervalExpr(); + localContext._startIntervals.push(localContext._intervalExpr); + } + } + this.state = 1552; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + } + this.state = 1563; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 379) { + { + this.state = 1555; + this.match(MySqlParser.KW_ENDS); + this.state = 1556; + localContext._endTimestamp = this.timestampValue(); + this.state = 1560; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 853) { + { + { + this.state = 1557; + localContext._intervalExpr = this.intervalExpr(); + localContext._endIntervals.push(localContext._intervalExpr); + } + } + this.state = 1562; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + } + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + timestampValue() { + let localContext = new TimestampValueContext(this.context, this.state); + this.enterRule(localContext, 62, MySqlParser.RULE_timestampValue); + try { + this.state = 1571; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 127, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 1567; + this.match(MySqlParser.KW_CURRENT_TIMESTAMP); + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 1568; + this.stringLiteral(); + } + break; + case 3: + this.enterOuterAlt(localContext, 3); + { + this.state = 1569; + this.decimalLiteral(); + } + break; + case 4: + this.enterOuterAlt(localContext, 4); + { + this.state = 1570; + this.expression(0); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + intervalExpr() { + let localContext = new IntervalExprContext(this.context, this.state); + this.enterRule(localContext, 64, MySqlParser.RULE_intervalExpr); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 1573; + this.match(MySqlParser.PLUS); + this.state = 1574; + this.match(MySqlParser.KW_INTERVAL); + this.state = 1577; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 128, this.context)) { + case 1: + { + this.state = 1575; + this.decimalLiteral(); + } + break; + case 2: + { + this.state = 1576; + this.expression(0); + } + break; + } + this.state = 1579; + this.intervalType(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + intervalType() { + let localContext = new IntervalTypeContext(this.context, this.state); + this.enterRule(localContext, 66, MySqlParser.RULE_intervalType); + try { + this.state = 1594; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_QUARTER: + case MySqlParser.KW_MONTH: + case MySqlParser.KW_DAY: + case MySqlParser.KW_HOUR: + case MySqlParser.KW_MINUTE: + case MySqlParser.KW_WEEK: + case MySqlParser.KW_SECOND: + case MySqlParser.KW_MICROSECOND: + this.enterOuterAlt(localContext, 1); + { + this.state = 1581; + this.intervalTypeBase(); + } + break; + case MySqlParser.KW_YEAR: + this.enterOuterAlt(localContext, 2); + { + this.state = 1582; + this.match(MySqlParser.KW_YEAR); + } + break; + case MySqlParser.KW_YEAR_MONTH: + this.enterOuterAlt(localContext, 3); + { + this.state = 1583; + this.match(MySqlParser.KW_YEAR_MONTH); + } + break; + case MySqlParser.KW_DAY_HOUR: + this.enterOuterAlt(localContext, 4); + { + this.state = 1584; + this.match(MySqlParser.KW_DAY_HOUR); + } + break; + case MySqlParser.KW_DAY_MINUTE: + this.enterOuterAlt(localContext, 5); + { + this.state = 1585; + this.match(MySqlParser.KW_DAY_MINUTE); + } + break; + case MySqlParser.KW_DAY_SECOND: + this.enterOuterAlt(localContext, 6); + { + this.state = 1586; + this.match(MySqlParser.KW_DAY_SECOND); + } + break; + case MySqlParser.KW_HOUR_MINUTE: + this.enterOuterAlt(localContext, 7); + { + this.state = 1587; + this.match(MySqlParser.KW_HOUR_MINUTE); + } + break; + case MySqlParser.KW_HOUR_SECOND: + this.enterOuterAlt(localContext, 8); + { + this.state = 1588; + this.match(MySqlParser.KW_HOUR_SECOND); + } + break; + case MySqlParser.KW_MINUTE_SECOND: + this.enterOuterAlt(localContext, 9); + { + this.state = 1589; + this.match(MySqlParser.KW_MINUTE_SECOND); + } + break; + case MySqlParser.KW_SECOND_MICROSECOND: + this.enterOuterAlt(localContext, 10); + { + this.state = 1590; + this.match(MySqlParser.KW_SECOND_MICROSECOND); + } + break; + case MySqlParser.KW_MINUTE_MICROSECOND: + this.enterOuterAlt(localContext, 11); + { + this.state = 1591; + this.match(MySqlParser.KW_MINUTE_MICROSECOND); + } + break; + case MySqlParser.KW_HOUR_MICROSECOND: + this.enterOuterAlt(localContext, 12); + { + this.state = 1592; + this.match(MySqlParser.KW_HOUR_MICROSECOND); + } + break; + case MySqlParser.KW_DAY_MICROSECOND: + this.enterOuterAlt(localContext, 13); + { + this.state = 1593; + this.match(MySqlParser.KW_DAY_MICROSECOND); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + enableType() { + let localContext = new EnableTypeContext(this.context, this.state); + this.enterRule(localContext, 68, MySqlParser.RULE_enableType); + try { + this.state = 1601; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 130, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 1596; + this.match(MySqlParser.KW_ENABLE); + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 1597; + this.match(MySqlParser.KW_DISABLE); + } + break; + case 3: + this.enterOuterAlt(localContext, 3); + { + this.state = 1598; + this.match(MySqlParser.KW_DISABLE); + this.state = 1599; + this.match(MySqlParser.KW_ON); + this.state = 1600; + this.match(MySqlParser.KW_SLAVE); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + indexType() { + let localContext = new IndexTypeContext(this.context, this.state); + this.enterRule(localContext, 70, MySqlParser.RULE_indexType); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 1603; + this.match(MySqlParser.KW_USING); + this.state = 1604; + _la = this.tokenStream.LA(1); + if (!(_la === 323 || _la === 418)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + indexOption() { + let localContext = new IndexOptionContext(this.context, this.state); + this.enterRule(localContext, 72, MySqlParser.RULE_indexOption); + let _la; + try { + this.state = 1628; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_KEY_BLOCK_SIZE: + this.enterOuterAlt(localContext, 1); + { + this.state = 1606; + this.match(MySqlParser.KW_KEY_BLOCK_SIZE); + this.state = 1608; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 1607; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 1610; + this.fileSizeLiteral(); + } + break; + case MySqlParser.KW_USING: + this.enterOuterAlt(localContext, 2); + { + this.state = 1611; + this.indexType(); + } + break; + case MySqlParser.KW_WITH: + this.enterOuterAlt(localContext, 3); + { + this.state = 1612; + this.match(MySqlParser.KW_WITH); + this.state = 1613; + this.match(MySqlParser.KW_PARSER); + this.state = 1614; + localContext._parserName = this.uid(); + } + break; + case MySqlParser.KW_COMMENT: + this.enterOuterAlt(localContext, 4); + { + this.state = 1615; + this.match(MySqlParser.KW_COMMENT); + this.state = 1616; + this.match(MySqlParser.STRING_LITERAL); + } + break; + case MySqlParser.KW_INVISIBLE: + case MySqlParser.KW_VISIBLE: + this.enterOuterAlt(localContext, 5); + { + this.state = 1617; + _la = this.tokenStream.LA(1); + if (!(_la === 435 || _la === 686)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + break; + case MySqlParser.KW_ENGINE_ATTRIBUTE: + this.enterOuterAlt(localContext, 6); + { + this.state = 1618; + this.match(MySqlParser.KW_ENGINE_ATTRIBUTE); + this.state = 1620; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 1619; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 1622; + this.match(MySqlParser.STRING_LITERAL); + } + break; + case MySqlParser.KW_SECONDARY_ENGINE_ATTRIBUTE: + this.enterOuterAlt(localContext, 7); + { + this.state = 1623; + this.match(MySqlParser.KW_SECONDARY_ENGINE_ATTRIBUTE); + this.state = 1625; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 1624; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 1627; + this.match(MySqlParser.STRING_LITERAL); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + procedureParameter() { + let localContext = new ProcedureParameterContext(this.context, this.state); + this.enterRule(localContext, 74, MySqlParser.RULE_procedureParameter); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 1631; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 80 || _la === 85 || _la === 126) { + { + this.state = 1630; + localContext._direction = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 80 || _la === 85 || _la === 126)) { + localContext._direction = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + this.state = 1633; + localContext._paramName = this.uid(); + this.state = 1634; + this.dataType(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + routineOption() { + let localContext = new RoutineOptionContext(this.context, this.state); + this.enterRule(localContext, 76, MySqlParser.RULE_routineOption); + let _la; + try { + this.state = 1659; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_COMMENT: + localContext = new RoutineCommentContext(localContext); + this.enterOuterAlt(localContext, 1); + { + this.state = 1636; + this.match(MySqlParser.KW_COMMENT); + this.state = 1637; + this.match(MySqlParser.STRING_LITERAL); + } + break; + case MySqlParser.KW_LANGUAGE: + localContext = new RoutineLanguageContext(localContext); + this.enterOuterAlt(localContext, 2); + { + this.state = 1638; + this.match(MySqlParser.KW_LANGUAGE); + this.state = 1639; + this.match(MySqlParser.KW_SQL); + } + break; + case MySqlParser.KW_DETERMINISTIC: + case MySqlParser.KW_NOT: + localContext = new RoutineBehaviorContext(localContext); + this.enterOuterAlt(localContext, 3); + { + this.state = 1641; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 114) { + { + this.state = 1640; + this.match(MySqlParser.KW_NOT); + } + } + this.state = 1643; + this.match(MySqlParser.KW_DETERMINISTIC); + } + break; + case MySqlParser.KW_MODIFIES: + case MySqlParser.KW_READS: + case MySqlParser.KW_CONTAINS: + case MySqlParser.KW_NO: + localContext = new RoutineDataContext(localContext); + this.enterOuterAlt(localContext, 4); + { + this.state = 1654; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_CONTAINS: + { + this.state = 1644; + this.match(MySqlParser.KW_CONTAINS); + this.state = 1645; + this.match(MySqlParser.KW_SQL); + } + break; + case MySqlParser.KW_NO: + { + this.state = 1646; + this.match(MySqlParser.KW_NO); + this.state = 1647; + this.match(MySqlParser.KW_SQL); + } + break; + case MySqlParser.KW_READS: + { + this.state = 1648; + this.match(MySqlParser.KW_READS); + this.state = 1649; + this.match(MySqlParser.KW_SQL); + this.state = 1650; + this.match(MySqlParser.KW_DATA); + } + break; + case MySqlParser.KW_MODIFIES: + { + this.state = 1651; + this.match(MySqlParser.KW_MODIFIES); + this.state = 1652; + this.match(MySqlParser.KW_SQL); + this.state = 1653; + this.match(MySqlParser.KW_DATA); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + break; + case MySqlParser.KW_SQL: + localContext = new RoutineSecurityContext(localContext); + this.enterOuterAlt(localContext, 5); + { + this.state = 1656; + this.match(MySqlParser.KW_SQL); + this.state = 1657; + this.match(MySqlParser.KW_SECURITY); + this.state = 1658; + localContext._context = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 364 || _la === 436)) { + localContext._context = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + serverOption() { + let localContext = new ServerOptionContext(this.context, this.state); + this.enterRule(localContext, 78, MySqlParser.RULE_serverOption); + try { + this.state = 1675; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_HOST: + this.enterOuterAlt(localContext, 1); + { + this.state = 1661; + this.match(MySqlParser.KW_HOST); + this.state = 1662; + this.match(MySqlParser.STRING_LITERAL); + } + break; + case MySqlParser.KW_DATABASE: + this.enterOuterAlt(localContext, 2); + { + this.state = 1663; + this.match(MySqlParser.KW_DATABASE); + this.state = 1664; + this.match(MySqlParser.STRING_LITERAL); + } + break; + case MySqlParser.KW_USER: + this.enterOuterAlt(localContext, 3); + { + this.state = 1665; + this.match(MySqlParser.KW_USER); + this.state = 1666; + this.match(MySqlParser.STRING_LITERAL); + } + break; + case MySqlParser.KW_PASSWORD: + this.enterOuterAlt(localContext, 4); + { + this.state = 1667; + this.match(MySqlParser.KW_PASSWORD); + this.state = 1668; + this.match(MySqlParser.STRING_LITERAL); + } + break; + case MySqlParser.KW_SOCKET: + this.enterOuterAlt(localContext, 5); + { + this.state = 1669; + this.match(MySqlParser.KW_SOCKET); + this.state = 1670; + this.match(MySqlParser.STRING_LITERAL); + } + break; + case MySqlParser.KW_OWNER: + this.enterOuterAlt(localContext, 6); + { + this.state = 1671; + this.match(MySqlParser.KW_OWNER); + this.state = 1672; + this.match(MySqlParser.STRING_LITERAL); + } + break; + case MySqlParser.KW_PORT: + this.enterOuterAlt(localContext, 7); + { + this.state = 1673; + this.match(MySqlParser.KW_PORT); + this.state = 1674; + this.decimalLiteral(); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + createDefinitions() { + let localContext = new CreateDefinitionsContext(this.context, this.state); + this.enterRule(localContext, 80, MySqlParser.RULE_createDefinitions); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 1677; + this.match(MySqlParser.LR_BRACKET); + this.state = 1678; + this.createDefinition(); + this.state = 1683; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 1679; + this.match(MySqlParser.COMMA); + this.state = 1680; + this.createDefinition(); + } + } + this.state = 1685; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 1686; + this.match(MySqlParser.RR_BRACKET); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + createDefinition() { + let localContext = new CreateDefinitionContext(this.context, this.state); + this.enterRule(localContext, 82, MySqlParser.RULE_createDefinition); + let _la; + try { + this.state = 1771; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 157, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 1688; + this.columnNameCreate(); + this.state = 1689; + this.columnDefinition(); + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 1691; + _la = this.tokenStream.LA(1); + if (!(_la === 82 || _la === 92)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 1693; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if ((((_la) & ~0x1F) === 0 && ((1 << _la) & 1074302976) !== 0) || ((((_la - 36)) & ~0x1F) === 0 && ((1 << (_la - 36)) & 11014219) !== 0) || ((((_la - 74)) & ~0x1F) === 0 && ((1 << (_la - 74)) & 18878481) !== 0) || ((((_la - 117)) & ~0x1F) === 0 && ((1 << (_la - 117)) & 100679969) !== 0) || ((((_la - 150)) & ~0x1F) === 0 && ((1 << (_la - 150)) & 1049605) !== 0) || ((((_la - 219)) & ~0x1F) === 0 && ((1 << (_la - 219)) & 5374495) !== 0) || ((((_la - 253)) & ~0x1F) === 0 && ((1 << (_la - 253)) & 4294967295) !== 0) || ((((_la - 285)) & ~0x1F) === 0 && ((1 << (_la - 285)) & 4261412607) !== 0) || ((((_la - 317)) & ~0x1F) === 0 && ((1 << (_la - 317)) & 4160741375) !== 0) || ((((_la - 349)) & ~0x1F) === 0 && ((1 << (_la - 349)) & 4026531839) !== 0) || ((((_la - 381)) & ~0x1F) === 0 && ((1 << (_la - 381)) & 1055907839) !== 0) || ((((_la - 413)) & ~0x1F) === 0 && ((1 << (_la - 413)) & 4294885367) !== 0) || ((((_la - 445)) & ~0x1F) === 0 && ((1 << (_la - 445)) & 3757571071) !== 0) || ((((_la - 478)) & ~0x1F) === 0 && ((1 << (_la - 478)) & 3755999231) !== 0) || ((((_la - 510)) & ~0x1F) === 0 && ((1 << (_la - 510)) & 3751780349) !== 0) || ((((_la - 542)) & ~0x1F) === 0 && ((1 << (_la - 542)) & 2141183997) !== 0) || ((((_la - 575)) & ~0x1F) === 0 && ((1 << (_la - 575)) & 2147483629) !== 0) || ((((_la - 633)) & ~0x1F) === 0 && ((1 << (_la - 633)) & 4294934527) !== 0) || ((((_la - 665)) & ~0x1F) === 0 && ((1 << (_la - 665)) & 4278189053) !== 0) || ((((_la - 697)) & ~0x1F) === 0 && ((1 << (_la - 697)) & 1644099327) !== 0) || ((((_la - 729)) & ~0x1F) === 0 && ((1 << (_la - 729)) & 4294900735) !== 0) || ((((_la - 761)) & ~0x1F) === 0 && ((1 << (_la - 761)) & 4294967295) !== 0) || ((((_la - 793)) & ~0x1F) === 0 && ((1 << (_la - 793)) & 4288675839) !== 0) || ((((_la - 825)) & ~0x1F) === 0 && ((1 << (_la - 825)) & 2147527671) !== 0) || ((((_la - 879)) & ~0x1F) === 0 && ((1 << (_la - 879)) & 1033) !== 0)) { + { + this.state = 1692; + this.indexName(); + } + } + this.state = 1696; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 188) { + { + this.state = 1695; + this.indexType(); + } + } + this.state = 1698; + this.indexColumnNames(); + this.state = 1702; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 188 || _la === 194 || _la === 340 || _la === 435 || _la === 443 || _la === 686 || _la === 825 || _la === 833) { + { + { + this.state = 1699; + this.indexOption(); + } + } + this.state = 1704; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + break; + case 3: + this.enterOuterAlt(localContext, 3); + { + this.state = 1705; + _la = this.tokenStream.LA(1); + if (!(_la === 69 || _la === 161)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 1707; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 82 || _la === 92) { + { + this.state = 1706; + _la = this.tokenStream.LA(1); + if (!(_la === 82 || _la === 92)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + this.state = 1710; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if ((((_la) & ~0x1F) === 0 && ((1 << _la) & 1074302976) !== 0) || ((((_la - 36)) & ~0x1F) === 0 && ((1 << (_la - 36)) & 11014219) !== 0) || ((((_la - 74)) & ~0x1F) === 0 && ((1 << (_la - 74)) & 18878481) !== 0) || ((((_la - 117)) & ~0x1F) === 0 && ((1 << (_la - 117)) & 100679969) !== 0) || ((((_la - 150)) & ~0x1F) === 0 && ((1 << (_la - 150)) & 1049605) !== 0) || ((((_la - 219)) & ~0x1F) === 0 && ((1 << (_la - 219)) & 5374495) !== 0) || ((((_la - 253)) & ~0x1F) === 0 && ((1 << (_la - 253)) & 4294967295) !== 0) || ((((_la - 285)) & ~0x1F) === 0 && ((1 << (_la - 285)) & 4261412607) !== 0) || ((((_la - 317)) & ~0x1F) === 0 && ((1 << (_la - 317)) & 4160741375) !== 0) || ((((_la - 349)) & ~0x1F) === 0 && ((1 << (_la - 349)) & 4026531839) !== 0) || ((((_la - 381)) & ~0x1F) === 0 && ((1 << (_la - 381)) & 1055907839) !== 0) || ((((_la - 413)) & ~0x1F) === 0 && ((1 << (_la - 413)) & 4294885367) !== 0) || ((((_la - 445)) & ~0x1F) === 0 && ((1 << (_la - 445)) & 3757571071) !== 0) || ((((_la - 478)) & ~0x1F) === 0 && ((1 << (_la - 478)) & 3755999231) !== 0) || ((((_la - 510)) & ~0x1F) === 0 && ((1 << (_la - 510)) & 3751780349) !== 0) || ((((_la - 542)) & ~0x1F) === 0 && ((1 << (_la - 542)) & 2141183997) !== 0) || ((((_la - 575)) & ~0x1F) === 0 && ((1 << (_la - 575)) & 2147483629) !== 0) || ((((_la - 633)) & ~0x1F) === 0 && ((1 << (_la - 633)) & 4294934527) !== 0) || ((((_la - 665)) & ~0x1F) === 0 && ((1 << (_la - 665)) & 4278189053) !== 0) || ((((_la - 697)) & ~0x1F) === 0 && ((1 << (_la - 697)) & 1644099327) !== 0) || ((((_la - 729)) & ~0x1F) === 0 && ((1 << (_la - 729)) & 4294900735) !== 0) || ((((_la - 761)) & ~0x1F) === 0 && ((1 << (_la - 761)) & 4294967295) !== 0) || ((((_la - 793)) & ~0x1F) === 0 && ((1 << (_la - 793)) & 4288675839) !== 0) || ((((_la - 825)) & ~0x1F) === 0 && ((1 << (_la - 825)) & 2147527671) !== 0) || ((((_la - 879)) & ~0x1F) === 0 && ((1 << (_la - 879)) & 1033) !== 0)) { + { + this.state = 1709; + this.indexName(); + } + } + this.state = 1712; + this.indexColumnNames(); + this.state = 1716; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 188 || _la === 194 || _la === 340 || _la === 435 || _la === 443 || _la === 686 || _la === 825 || _la === 833) { + { + { + this.state = 1713; + this.indexOption(); + } + } + this.state = 1718; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + break; + case 4: + this.enterOuterAlt(localContext, 4); + { + this.state = 1720; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 31) { + { + this.state = 1719; + this.constraintSymbol(); + } + } + this.state = 1722; + this.match(MySqlParser.KW_PRIMARY); + this.state = 1723; + this.match(MySqlParser.KW_KEY); + this.state = 1725; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 188) { + { + this.state = 1724; + this.indexType(); + } + } + this.state = 1727; + this.indexColumnNames(); + this.state = 1731; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 188 || _la === 194 || _la === 340 || _la === 435 || _la === 443 || _la === 686 || _la === 825 || _la === 833) { + { + { + this.state = 1728; + this.indexOption(); + } + } + this.state = 1733; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + break; + case 5: + this.enterOuterAlt(localContext, 5); + { + this.state = 1735; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 31) { + { + this.state = 1734; + this.constraintSymbol(); + } + } + this.state = 1737; + this.match(MySqlParser.KW_UNIQUE); + this.state = 1739; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 82 || _la === 92) { + { + this.state = 1738; + _la = this.tokenStream.LA(1); + if (!(_la === 82 || _la === 92)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + this.state = 1742; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if ((((_la) & ~0x1F) === 0 && ((1 << _la) & 1074302976) !== 0) || ((((_la - 36)) & ~0x1F) === 0 && ((1 << (_la - 36)) & 11014219) !== 0) || ((((_la - 74)) & ~0x1F) === 0 && ((1 << (_la - 74)) & 18878481) !== 0) || ((((_la - 117)) & ~0x1F) === 0 && ((1 << (_la - 117)) & 100679969) !== 0) || ((((_la - 150)) & ~0x1F) === 0 && ((1 << (_la - 150)) & 1049605) !== 0) || ((((_la - 219)) & ~0x1F) === 0 && ((1 << (_la - 219)) & 5374495) !== 0) || ((((_la - 253)) & ~0x1F) === 0 && ((1 << (_la - 253)) & 4294967295) !== 0) || ((((_la - 285)) & ~0x1F) === 0 && ((1 << (_la - 285)) & 4261412607) !== 0) || ((((_la - 317)) & ~0x1F) === 0 && ((1 << (_la - 317)) & 4160741375) !== 0) || ((((_la - 349)) & ~0x1F) === 0 && ((1 << (_la - 349)) & 4026531839) !== 0) || ((((_la - 381)) & ~0x1F) === 0 && ((1 << (_la - 381)) & 1055907839) !== 0) || ((((_la - 413)) & ~0x1F) === 0 && ((1 << (_la - 413)) & 4294885367) !== 0) || ((((_la - 445)) & ~0x1F) === 0 && ((1 << (_la - 445)) & 3757571071) !== 0) || ((((_la - 478)) & ~0x1F) === 0 && ((1 << (_la - 478)) & 3755999231) !== 0) || ((((_la - 510)) & ~0x1F) === 0 && ((1 << (_la - 510)) & 3751780349) !== 0) || ((((_la - 542)) & ~0x1F) === 0 && ((1 << (_la - 542)) & 2141183997) !== 0) || ((((_la - 575)) & ~0x1F) === 0 && ((1 << (_la - 575)) & 2147483629) !== 0) || ((((_la - 633)) & ~0x1F) === 0 && ((1 << (_la - 633)) & 4294934527) !== 0) || ((((_la - 665)) & ~0x1F) === 0 && ((1 << (_la - 665)) & 4278189053) !== 0) || ((((_la - 697)) & ~0x1F) === 0 && ((1 << (_la - 697)) & 1644099327) !== 0) || ((((_la - 729)) & ~0x1F) === 0 && ((1 << (_la - 729)) & 4294900735) !== 0) || ((((_la - 761)) & ~0x1F) === 0 && ((1 << (_la - 761)) & 4294967295) !== 0) || ((((_la - 793)) & ~0x1F) === 0 && ((1 << (_la - 793)) & 4288675839) !== 0) || ((((_la - 825)) & ~0x1F) === 0 && ((1 << (_la - 825)) & 2147527671) !== 0) || ((((_la - 879)) & ~0x1F) === 0 && ((1 << (_la - 879)) & 1033) !== 0)) { + { + this.state = 1741; + this.indexName(); + } + } + this.state = 1745; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 188) { + { + this.state = 1744; + this.indexType(); + } + } + this.state = 1747; + this.indexColumnNames(); + this.state = 1751; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 188 || _la === 194 || _la === 340 || _la === 435 || _la === 443 || _la === 686 || _la === 825 || _la === 833) { + { + { + this.state = 1748; + this.indexOption(); + } + } + this.state = 1753; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + break; + case 6: + this.enterOuterAlt(localContext, 6); + { + this.state = 1755; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 31) { + { + this.state = 1754; + this.constraintSymbol(); + } + } + this.state = 1757; + this.match(MySqlParser.KW_FOREIGN); + this.state = 1758; + this.match(MySqlParser.KW_KEY); + this.state = 1760; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if ((((_la) & ~0x1F) === 0 && ((1 << _la) & 1074302976) !== 0) || ((((_la - 36)) & ~0x1F) === 0 && ((1 << (_la - 36)) & 11014219) !== 0) || ((((_la - 74)) & ~0x1F) === 0 && ((1 << (_la - 74)) & 18878481) !== 0) || ((((_la - 117)) & ~0x1F) === 0 && ((1 << (_la - 117)) & 100679969) !== 0) || ((((_la - 150)) & ~0x1F) === 0 && ((1 << (_la - 150)) & 1049605) !== 0) || ((((_la - 219)) & ~0x1F) === 0 && ((1 << (_la - 219)) & 5374495) !== 0) || ((((_la - 253)) & ~0x1F) === 0 && ((1 << (_la - 253)) & 4294967295) !== 0) || ((((_la - 285)) & ~0x1F) === 0 && ((1 << (_la - 285)) & 4261412607) !== 0) || ((((_la - 317)) & ~0x1F) === 0 && ((1 << (_la - 317)) & 4160741375) !== 0) || ((((_la - 349)) & ~0x1F) === 0 && ((1 << (_la - 349)) & 4026531839) !== 0) || ((((_la - 381)) & ~0x1F) === 0 && ((1 << (_la - 381)) & 1055907839) !== 0) || ((((_la - 413)) & ~0x1F) === 0 && ((1 << (_la - 413)) & 4294885367) !== 0) || ((((_la - 445)) & ~0x1F) === 0 && ((1 << (_la - 445)) & 3757571071) !== 0) || ((((_la - 478)) & ~0x1F) === 0 && ((1 << (_la - 478)) & 3755999231) !== 0) || ((((_la - 510)) & ~0x1F) === 0 && ((1 << (_la - 510)) & 3751780349) !== 0) || ((((_la - 542)) & ~0x1F) === 0 && ((1 << (_la - 542)) & 2141183997) !== 0) || ((((_la - 575)) & ~0x1F) === 0 && ((1 << (_la - 575)) & 2147483629) !== 0) || ((((_la - 633)) & ~0x1F) === 0 && ((1 << (_la - 633)) & 4294934527) !== 0) || ((((_la - 665)) & ~0x1F) === 0 && ((1 << (_la - 665)) & 4278189053) !== 0) || ((((_la - 697)) & ~0x1F) === 0 && ((1 << (_la - 697)) & 1644099327) !== 0) || ((((_la - 729)) & ~0x1F) === 0 && ((1 << (_la - 729)) & 4294900735) !== 0) || ((((_la - 761)) & ~0x1F) === 0 && ((1 << (_la - 761)) & 4294967295) !== 0) || ((((_la - 793)) & ~0x1F) === 0 && ((1 << (_la - 793)) & 4288675839) !== 0) || ((((_la - 825)) & ~0x1F) === 0 && ((1 << (_la - 825)) & 2147527671) !== 0) || ((((_la - 879)) & ~0x1F) === 0 && ((1 << (_la - 879)) & 1033) !== 0)) { + { + this.state = 1759; + this.indexName(); + } + } + this.state = 1762; + this.indexColumnNames(); + this.state = 1763; + this.referenceDefinition(); + } + break; + case 7: + this.enterOuterAlt(localContext, 7); + { + this.state = 1765; + this.match(MySqlParser.KW_CHECK); + this.state = 1766; + this.match(MySqlParser.LR_BRACKET); + this.state = 1767; + this.expression(0); + this.state = 1768; + this.match(MySqlParser.RR_BRACKET); + } + break; + case 8: + this.enterOuterAlt(localContext, 8); + { + this.state = 1770; + this.checkConstraintDefinition(); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + checkConstraintDefinition() { + let localContext = new CheckConstraintDefinitionContext(this.context, this.state); + this.enterRule(localContext, 84, MySqlParser.RULE_checkConstraintDefinition); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 1774; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 31) { + { + this.state = 1773; + this.constraintSymbol(); + } + } + this.state = 1776; + this.match(MySqlParser.KW_CHECK); + this.state = 1777; + this.match(MySqlParser.LR_BRACKET); + this.state = 1778; + this.expression(0); + this.state = 1779; + this.match(MySqlParser.RR_BRACKET); + this.state = 1784; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 160, this.context)) { + case 1: + { + this.state = 1781; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 114) { + { + this.state = 1780; + this.match(MySqlParser.KW_NOT); + } + } + this.state = 1783; + this.match(MySqlParser.KW_ENFORCED); + } + break; + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + constraintSymbol() { + let localContext = new ConstraintSymbolContext(this.context, this.state); + this.enterRule(localContext, 86, MySqlParser.RULE_constraintSymbol); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 1786; + this.match(MySqlParser.KW_CONSTRAINT); + this.state = 1788; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 161, this.context)) { + case 1: + { + this.state = 1787; + localContext._symbol_ = this.uid(); + } + break; + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + columnDefinition() { + let localContext = new ColumnDefinitionContext(this.context, this.state); + this.enterRule(localContext, 88, MySqlParser.RULE_columnDefinition); + try { + let alternative; + this.enterOuterAlt(localContext, 1); + { + this.state = 1790; + this.dataType(); + this.state = 1794; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 162, this.context); + while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER) { + if (alternative === 1) { + { + { + this.state = 1791; + this.columnConstraint(); + } + } + } + this.state = 1796; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 162, this.context); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + columnConstraint() { + let localContext = new ColumnConstraintContext(this.context, this.state); + this.enterRule(localContext, 90, MySqlParser.RULE_columnConstraint); + let _la; + try { + this.state = 1840; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_NOT: + case MySqlParser.KW_NULL_LITERAL: + case MySqlParser.NULL_SPEC_LITERAL: + localContext = new NullColumnConstraintContext(localContext); + this.enterOuterAlt(localContext, 1); + { + this.state = 1797; + this.nullNotnull(); + } + break; + case MySqlParser.KW_DEFAULT: + localContext = new DefaultColumnConstraintContext(localContext); + this.enterOuterAlt(localContext, 2); + { + this.state = 1798; + this.match(MySqlParser.KW_DEFAULT); + this.state = 1799; + this.defaultValue(); + } + break; + case MySqlParser.KW_VISIBLE: + localContext = new VisibilityColumnConstraintContext(localContext); + this.enterOuterAlt(localContext, 3); + { + this.state = 1800; + this.match(MySqlParser.KW_VISIBLE); + } + break; + case MySqlParser.KW_INVISIBLE: + localContext = new InvisibilityColumnConstraintContext(localContext); + this.enterOuterAlt(localContext, 4); + { + this.state = 1801; + this.match(MySqlParser.KW_INVISIBLE); + } + break; + case MySqlParser.KW_ON: + case MySqlParser.KW_AUTO_INCREMENT: + localContext = new AutoIncrementColumnConstraintContext(localContext); + this.enterOuterAlt(localContext, 5); + { + this.state = 1806; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_AUTO_INCREMENT: + { + this.state = 1802; + this.match(MySqlParser.KW_AUTO_INCREMENT); + } + break; + case MySqlParser.KW_ON: + { + this.state = 1803; + this.match(MySqlParser.KW_ON); + this.state = 1804; + this.match(MySqlParser.KW_UPDATE); + this.state = 1805; + this.currentTimestamp(); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + break; + case MySqlParser.KW_KEY: + case MySqlParser.KW_PRIMARY: + localContext = new PrimaryKeyColumnConstraintContext(localContext); + this.enterOuterAlt(localContext, 6); + { + this.state = 1809; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 131) { + { + this.state = 1808; + this.match(MySqlParser.KW_PRIMARY); + } + } + this.state = 1811; + this.match(MySqlParser.KW_KEY); + } + break; + case MySqlParser.KW_UNIQUE: + localContext = new UniqueKeyColumnConstraintContext(localContext); + this.enterOuterAlt(localContext, 7); + { + this.state = 1812; + this.match(MySqlParser.KW_UNIQUE); + this.state = 1814; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 165, this.context)) { + case 1: + { + this.state = 1813; + this.match(MySqlParser.KW_KEY); + } + break; + } + } + break; + case MySqlParser.KW_COMMENT: + localContext = new CommentColumnConstraintContext(localContext); + this.enterOuterAlt(localContext, 8); + { + this.state = 1816; + this.match(MySqlParser.KW_COMMENT); + this.state = 1817; + this.match(MySqlParser.STRING_LITERAL); + } + break; + case MySqlParser.KW_COLUMN_FORMAT: + localContext = new FormatColumnConstraintContext(localContext); + this.enterOuterAlt(localContext, 9); + { + this.state = 1818; + this.match(MySqlParser.KW_COLUMN_FORMAT); + this.state = 1819; + localContext._colformat = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 42 || _la === 374 || _la === 403)) { + localContext._colformat = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + break; + case MySqlParser.KW_STORAGE: + localContext = new StorageColumnConstraintContext(localContext); + this.enterOuterAlt(localContext, 10); + { + this.state = 1820; + this.match(MySqlParser.KW_STORAGE); + this.state = 1821; + localContext._storageval = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 42 || _la === 370 || _la === 802)) { + localContext._storageval = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + break; + case MySqlParser.KW_REFERENCES: + localContext = new ReferenceColumnConstraintContext(localContext); + this.enterOuterAlt(localContext, 11); + { + this.state = 1822; + this.referenceDefinition(); + } + break; + case MySqlParser.KW_COLLATE: + localContext = new CollateColumnConstraintContext(localContext); + this.enterOuterAlt(localContext, 12); + { + this.state = 1823; + this.match(MySqlParser.KW_COLLATE); + this.state = 1824; + this.collationName(); + } + break; + case MySqlParser.KW_AS: + case MySqlParser.KW_GENERATED: + localContext = new GeneratedColumnConstraintContext(localContext); + this.enterOuterAlt(localContext, 13); + { + this.state = 1827; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 71) { + { + this.state = 1825; + this.match(MySqlParser.KW_GENERATED); + this.state = 1826; + this.match(MySqlParser.KW_ALWAYS); + } + } + this.state = 1829; + this.match(MySqlParser.KW_AS); + this.state = 1830; + this.match(MySqlParser.LR_BRACKET); + this.state = 1831; + this.expression(0); + this.state = 1832; + this.match(MySqlParser.RR_BRACKET); + this.state = 1834; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 648 || _la === 685) { + { + this.state = 1833; + _la = this.tokenStream.LA(1); + if (!(_la === 648 || _la === 685)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + } + break; + case MySqlParser.KW_SERIAL: + localContext = new SerialDefaultColumnConstraintContext(localContext); + this.enterOuterAlt(localContext, 14); + { + this.state = 1836; + this.match(MySqlParser.KW_SERIAL); + this.state = 1837; + this.match(MySqlParser.KW_DEFAULT); + this.state = 1838; + this.match(MySqlParser.KW_VALUE); + } + break; + case MySqlParser.KW_CHECK: + case MySqlParser.KW_CONSTRAINT: + localContext = new CheckExprContext(localContext); + this.enterOuterAlt(localContext, 15); + { + this.state = 1839; + this.checkConstraintDefinition(); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + referenceDefinition() { + let localContext = new ReferenceDefinitionContext(this.context, this.state); + this.enterRule(localContext, 92, MySqlParser.RULE_referenceDefinition); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 1842; + this.match(MySqlParser.KW_REFERENCES); + this.state = 1843; + this.tableName(); + this.state = 1845; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 169, this.context)) { + case 1: + { + this.state = 1844; + this.indexColumnNames(); + } + break; + } + this.state = 1849; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 110) { + { + this.state = 1847; + this.match(MySqlParser.KW_MATCH); + this.state = 1848; + localContext._matchType = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 408 || _la === 526 || _la === 597)) { + localContext._matchType = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + this.state = 1852; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 171, this.context)) { + case 1: + { + this.state = 1851; + this.referenceAction(); + } + break; + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + referenceAction() { + let localContext = new ReferenceActionContext(this.context, this.state); + this.enterRule(localContext, 94, MySqlParser.RULE_referenceAction); + try { + this.state = 1870; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 174, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 1854; + this.match(MySqlParser.KW_ON); + this.state = 1855; + this.match(MySqlParser.KW_DELETE); + this.state = 1856; + localContext._onDelete = this.referenceControlType(); + this.state = 1860; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 172, this.context)) { + case 1: + { + this.state = 1857; + this.match(MySqlParser.KW_ON); + this.state = 1858; + this.match(MySqlParser.KW_UPDATE); + this.state = 1859; + localContext._onUpdate = this.referenceControlType(); + } + break; + } + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 1862; + this.match(MySqlParser.KW_ON); + this.state = 1863; + this.match(MySqlParser.KW_UPDATE); + this.state = 1864; + localContext._onUpdate = this.referenceControlType(); + this.state = 1868; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 173, this.context)) { + case 1: + { + this.state = 1865; + this.match(MySqlParser.KW_ON); + this.state = 1866; + this.match(MySqlParser.KW_DELETE); + this.state = 1867; + localContext._onDelete = this.referenceControlType(); + } + break; + } + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + referenceControlType() { + let localContext = new ReferenceControlTypeContext(this.context, this.state); + this.enterRule(localContext, 96, MySqlParser.RULE_referenceControlType); + try { + this.state = 1880; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 175, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 1872; + this.match(MySqlParser.KW_RESTRICT); + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 1873; + this.match(MySqlParser.KW_CASCADE); + } + break; + case 3: + this.enterOuterAlt(localContext, 3); + { + this.state = 1874; + this.match(MySqlParser.KW_SET); + this.state = 1875; + this.match(MySqlParser.KW_NULL_LITERAL); + } + break; + case 4: + this.enterOuterAlt(localContext, 4); + { + this.state = 1876; + this.match(MySqlParser.KW_NO); + this.state = 1877; + this.match(MySqlParser.KW_ACTION); + } + break; + case 5: + this.enterOuterAlt(localContext, 5); + { + this.state = 1878; + this.match(MySqlParser.KW_SET); + this.state = 1879; + this.match(MySqlParser.KW_DEFAULT); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + tableOption() { + let localContext = new TableOptionContext(this.context, this.state); + this.enterRule(localContext, 98, MySqlParser.RULE_tableOption); + let _la; + try { + this.state = 2067; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 213, this.context)) { + case 1: + localContext = new TableOptionEngineContext(localContext); + this.enterOuterAlt(localContext, 1); + { + this.state = 1882; + this.match(MySqlParser.KW_ENGINE); + this.state = 1884; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 1883; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 1887; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 177, this.context)) { + case 1: + { + this.state = 1886; + this.engineName(); + } + break; + } + } + break; + case 2: + localContext = new TableOptionEngineAttributeContext(localContext); + this.enterOuterAlt(localContext, 2); + { + this.state = 1889; + this.match(MySqlParser.KW_ENGINE_ATTRIBUTE); + this.state = 1891; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 1890; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 1893; + this.match(MySqlParser.STRING_LITERAL); + } + break; + case 3: + localContext = new TableOptionAutoextendSizeContext(localContext); + this.enterOuterAlt(localContext, 3); + { + this.state = 1894; + this.match(MySqlParser.KW_AUTOEXTEND_SIZE); + this.state = 1896; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 1895; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 1898; + this.decimalLiteral(); + } + break; + case 4: + localContext = new TableOptionAutoIncrementContext(localContext); + this.enterOuterAlt(localContext, 4); + { + this.state = 1899; + this.match(MySqlParser.KW_AUTO_INCREMENT); + this.state = 1901; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 1900; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 1903; + this.decimalLiteral(); + } + break; + case 5: + localContext = new TableOptionAverageContext(localContext); + this.enterOuterAlt(localContext, 5); + { + this.state = 1904; + this.match(MySqlParser.KW_AVG_ROW_LENGTH); + this.state = 1906; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 1905; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 1908; + this.decimalLiteral(); + } + break; + case 6: + localContext = new TableOptionCharsetContext(localContext); + this.enterOuterAlt(localContext, 6); + { + this.state = 1910; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 42) { + { + this.state = 1909; + this.match(MySqlParser.KW_DEFAULT); + } + } + this.state = 1912; + this.charSet(); + this.state = 1914; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 1913; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 1918; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_BINARY: + case MySqlParser.KW_ARMSCII8: + case MySqlParser.KW_ASCII: + case MySqlParser.KW_BIG5: + case MySqlParser.KW_CP1250: + case MySqlParser.KW_CP1251: + case MySqlParser.KW_CP1256: + case MySqlParser.KW_CP1257: + case MySqlParser.KW_CP850: + case MySqlParser.KW_CP852: + case MySqlParser.KW_CP866: + case MySqlParser.KW_CP932: + case MySqlParser.KW_DEC8: + case MySqlParser.KW_EUCJPMS: + case MySqlParser.KW_EUCKR: + case MySqlParser.KW_GB18030: + case MySqlParser.KW_GB2312: + case MySqlParser.KW_GBK: + case MySqlParser.KW_GEOSTD8: + case MySqlParser.KW_GREEK: + case MySqlParser.KW_HEBREW: + case MySqlParser.KW_HP8: + case MySqlParser.KW_KEYBCS2: + case MySqlParser.KW_KOI8R: + case MySqlParser.KW_KOI8U: + case MySqlParser.KW_LATIN1: + case MySqlParser.KW_LATIN2: + case MySqlParser.KW_LATIN5: + case MySqlParser.KW_LATIN7: + case MySqlParser.KW_MACCE: + case MySqlParser.KW_MACROMAN: + case MySqlParser.KW_SJIS: + case MySqlParser.KW_SWE7: + case MySqlParser.KW_TIS620: + case MySqlParser.KW_UCS2: + case MySqlParser.KW_UJIS: + case MySqlParser.KW_UTF16: + case MySqlParser.KW_UTF16LE: + case MySqlParser.KW_UTF32: + case MySqlParser.KW_UTF8: + case MySqlParser.KW_UTF8MB3: + case MySqlParser.KW_UTF8MB4: + case MySqlParser.CHARSET_REVERSE_QOUTE_STRING: + case MySqlParser.STRING_LITERAL: + { + this.state = 1916; + this.charsetName(); + } + break; + case MySqlParser.KW_DEFAULT: + { + this.state = 1917; + this.match(MySqlParser.KW_DEFAULT); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + break; + case 7: + localContext = new TableOptionChecksumContext(localContext); + this.enterOuterAlt(localContext, 7); + { + this.state = 1920; + _la = this.tokenStream.LA(1); + if (!(_la === 329 || _la === 522)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 1922; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 1921; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 1924; + localContext._boolValue = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 871 || _la === 872)) { + localContext._boolValue = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + break; + case 8: + localContext = new TableOptionCollateContext(localContext); + this.enterOuterAlt(localContext, 8); + { + this.state = 1926; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 42) { + { + this.state = 1925; + this.match(MySqlParser.KW_DEFAULT); + } + } + this.state = 1928; + this.match(MySqlParser.KW_COLLATE); + this.state = 1930; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 1929; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 1932; + this.collationName(); + } + break; + case 9: + localContext = new TableOptionCommentContext(localContext); + this.enterOuterAlt(localContext, 9); + { + this.state = 1933; + this.match(MySqlParser.KW_COMMENT); + this.state = 1935; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 1934; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 1937; + this.match(MySqlParser.STRING_LITERAL); + } + break; + case 10: + localContext = new TableOptionCompressionContext(localContext); + this.enterOuterAlt(localContext, 10); + { + this.state = 1938; + this.match(MySqlParser.KW_COMPRESSION); + this.state = 1940; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 1939; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 1942; + _la = this.tokenStream.LA(1); + if (!(_la === 882 || _la === 889)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + break; + case 11: + localContext = new TableOptionConnectionContext(localContext); + this.enterOuterAlt(localContext, 11); + { + this.state = 1943; + this.match(MySqlParser.KW_CONNECTION); + this.state = 1945; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 1944; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 1947; + this.match(MySqlParser.STRING_LITERAL); + } + break; + case 12: + localContext = new TableOptionDataDirectoryContext(localContext); + this.enterOuterAlt(localContext, 12); + { + this.state = 1948; + _la = this.tokenStream.LA(1); + if (!(_la === 82 || _la === 360)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 1949; + this.match(MySqlParser.KW_DIRECTORY); + this.state = 1951; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 1950; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 1953; + this.match(MySqlParser.STRING_LITERAL); + } + break; + case 13: + localContext = new TableOptionDelayContext(localContext); + this.enterOuterAlt(localContext, 13); + { + this.state = 1954; + this.match(MySqlParser.KW_DELAY_KEY_WRITE); + this.state = 1956; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 1955; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 1958; + localContext._boolValue = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 871 || _la === 872)) { + localContext._boolValue = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + break; + case 14: + localContext = new TableOptionEncryptionContext(localContext); + this.enterOuterAlt(localContext, 14); + { + this.state = 1959; + this.match(MySqlParser.KW_ENCRYPTION); + this.state = 1961; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 1960; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 1963; + this.match(MySqlParser.STRING_LITERAL); + } + break; + case 15: + localContext = new TableOptionPageCompressedContext(localContext); + this.enterOuterAlt(localContext, 15); + { + this.state = 1964; + _la = this.tokenStream.LA(1); + if (!(_la === 523 || _la === 882)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 1966; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 1965; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 1968; + _la = this.tokenStream.LA(1); + if (!(_la === 871 || _la === 872)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + break; + case 16: + localContext = new TableOptionPageCompressionLevelContext(localContext); + this.enterOuterAlt(localContext, 16); + { + this.state = 1969; + _la = this.tokenStream.LA(1); + if (!(_la === 524 || _la === 882)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 1971; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 1970; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 1973; + this.decimalLiteral(); + } + break; + case 17: + localContext = new TableOptionEncryptionKeyIdContext(localContext); + this.enterOuterAlt(localContext, 17); + { + this.state = 1974; + this.match(MySqlParser.KW_ENCRYPTION_KEY_ID); + this.state = 1976; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 1975; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 1978; + this.decimalLiteral(); + } + break; + case 18: + localContext = new TableOptionIndexDirectoryContext(localContext); + this.enterOuterAlt(localContext, 18); + { + this.state = 1979; + this.match(MySqlParser.KW_INDEX); + this.state = 1980; + this.match(MySqlParser.KW_DIRECTORY); + this.state = 1982; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 1981; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 1984; + this.match(MySqlParser.STRING_LITERAL); + } + break; + case 19: + localContext = new TableOptionInsertMethodContext(localContext); + this.enterOuterAlt(localContext, 19); + { + this.state = 1985; + this.match(MySqlParser.KW_INSERT_METHOD); + this.state = 1987; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 1986; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 1989; + localContext._insertMethod = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 402 || _la === 445 || _la === 502)) { + localContext._insertMethod = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + break; + case 20: + localContext = new TableOptionKeyBlockSizeContext(localContext); + this.enterOuterAlt(localContext, 20); + { + this.state = 1990; + this.match(MySqlParser.KW_KEY_BLOCK_SIZE); + this.state = 1992; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 1991; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 1994; + this.fileSizeLiteral(); + } + break; + case 21: + localContext = new TableOptionMaxRowsContext(localContext); + this.enterOuterAlt(localContext, 21); + { + this.state = 1995; + this.match(MySqlParser.KW_MAX_ROWS); + this.state = 1997; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 1996; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 1999; + this.decimalLiteral(); + } + break; + case 22: + localContext = new TableOptionMinRowsContext(localContext); + this.enterOuterAlt(localContext, 22); + { + this.state = 2000; + this.match(MySqlParser.KW_MIN_ROWS); + this.state = 2002; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 2001; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 2004; + this.decimalLiteral(); + } + break; + case 23: + localContext = new TableOptionPackKeysContext(localContext); + this.enterOuterAlt(localContext, 23); + { + this.state = 2005; + this.match(MySqlParser.KW_PACK_KEYS); + this.state = 2007; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 2006; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 2009; + localContext._extBoolValue = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 42 || _la === 871 || _la === 872)) { + localContext._extBoolValue = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + break; + case 24: + localContext = new TableOptionPasswordContext(localContext); + this.enterOuterAlt(localContext, 24); + { + this.state = 2010; + this.match(MySqlParser.KW_PASSWORD); + this.state = 2012; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 2011; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 2014; + this.match(MySqlParser.STRING_LITERAL); + } + break; + case 25: + localContext = new TableOptionRowFormatContext(localContext); + this.enterOuterAlt(localContext, 25); + { + this.state = 2015; + this.match(MySqlParser.KW_ROW_FORMAT); + this.state = 2017; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 2016; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 2019; + localContext._rowFormat = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 42 || _la === 342 || _la === 345 || _la === 374 || _la === 403 || _la === 554 || _la === 889)) { + localContext._rowFormat = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + break; + case 26: + localContext = new TableOptionStartTransactionContext(localContext); + this.enterOuterAlt(localContext, 26); + { + this.state = 2020; + this.match(MySqlParser.KW_START); + this.state = 2021; + this.match(MySqlParser.KW_TRANSACTION); + } + break; + case 27: + localContext = new TableOptionSecondaryEngineAttributeContext(localContext); + this.enterOuterAlt(localContext, 27); + { + this.state = 2022; + this.match(MySqlParser.KW_SECONDARY_ENGINE_ATTRIBUTE); + this.state = 2024; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 2023; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 2026; + this.match(MySqlParser.STRING_LITERAL); + } + break; + case 28: + localContext = new TableOptionRecalculationContext(localContext); + this.enterOuterAlt(localContext, 28); + { + this.state = 2027; + this.match(MySqlParser.KW_STATS_AUTO_RECALC); + this.state = 2029; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 2028; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 2031; + localContext._extBoolValue = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 42 || _la === 871 || _la === 872)) { + localContext._extBoolValue = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + break; + case 29: + localContext = new TableOptionPersistentContext(localContext); + this.enterOuterAlt(localContext, 29); + { + this.state = 2032; + this.match(MySqlParser.KW_STATS_PERSISTENT); + this.state = 2034; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 2033; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 2036; + localContext._extBoolValue = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 42 || _la === 871 || _la === 872)) { + localContext._extBoolValue = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + break; + case 30: + localContext = new TableOptionSamplePageContext(localContext); + this.enterOuterAlt(localContext, 30); + { + this.state = 2037; + this.match(MySqlParser.KW_STATS_SAMPLE_PAGES); + this.state = 2039; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 2038; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 2043; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_DEFAULT: + { + this.state = 2041; + this.match(MySqlParser.KW_DEFAULT); + } + break; + case MySqlParser.ZERO_DECIMAL: + case MySqlParser.ONE_DECIMAL: + case MySqlParser.TWO_DECIMAL: + case MySqlParser.THREE_DECIMAL: + case MySqlParser.DECIMAL_LITERAL: + case MySqlParser.REAL_LITERAL: + { + this.state = 2042; + this.decimalLiteral(); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + break; + case 31: + localContext = new TableOptionTablespaceContext(localContext); + this.enterOuterAlt(localContext, 31); + { + this.state = 2045; + this.match(MySqlParser.KW_TABLESPACE); + this.state = 2046; + this.tablespaceName(); + this.state = 2048; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 210, this.context)) { + case 1: + { + this.state = 2047; + this.tablespaceStorage(); + } + break; + } + } + break; + case 32: + localContext = new TableOptionTableTypeContext(localContext); + this.enterOuterAlt(localContext, 32); + { + this.state = 2050; + this.match(MySqlParser.KW_TABLE_TYPE); + this.state = 2051; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 2052; + this.tableType(); + } + break; + case 33: + localContext = new TableOptionTablespaceContext(localContext); + this.enterOuterAlt(localContext, 33); + { + this.state = 2053; + this.tablespaceStorage(); + } + break; + case 34: + localContext = new TableOptionTransactionalContext(localContext); + this.enterOuterAlt(localContext, 34); + { + this.state = 2054; + this.match(MySqlParser.KW_TRANSACTIONAL); + this.state = 2056; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 2055; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 2058; + _la = this.tokenStream.LA(1); + if (!(_la === 871 || _la === 872)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + break; + case 35: + localContext = new TableOptionUnionContext(localContext); + this.enterOuterAlt(localContext, 35); + { + this.state = 2059; + this.match(MySqlParser.KW_UNION); + this.state = 2061; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 2060; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 2063; + this.match(MySqlParser.LR_BRACKET); + this.state = 2064; + this.tableNames(); + this.state = 2065; + this.match(MySqlParser.RR_BRACKET); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + tableType() { + let localContext = new TableTypeContext(this.context, this.state); + this.enterRule(localContext, 100, MySqlParser.RULE_tableType); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 2069; + _la = this.tokenStream.LA(1); + if (!(_la === 494 || _la === 506)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + tablespaceStorage() { + let localContext = new TablespaceStorageContext(this.context, this.state); + this.enterRule(localContext, 102, MySqlParser.RULE_tablespaceStorage); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 2071; + this.match(MySqlParser.KW_STORAGE); + this.state = 2072; + _la = this.tokenStream.LA(1); + if (!(_la === 42 || _la === 370 || _la === 802)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + partitionDefinitions() { + let localContext = new PartitionDefinitionsContext(this.context, this.state); + this.enterRule(localContext, 104, MySqlParser.RULE_partitionDefinitions); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 2074; + this.match(MySqlParser.KW_PARTITION); + this.state = 2075; + this.match(MySqlParser.KW_BY); + this.state = 2076; + this.partitionFunctionDefinition(); + this.state = 2079; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 528) { + { + this.state = 2077; + this.match(MySqlParser.KW_PARTITIONS); + this.state = 2078; + localContext._count = this.decimalLiteral(); + } + } + this.state = 2088; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 652) { + { + this.state = 2081; + this.match(MySqlParser.KW_SUBPARTITION); + this.state = 2082; + this.match(MySqlParser.KW_BY); + this.state = 2083; + this.subpartitionFunctionDefinition(); + this.state = 2086; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 653) { + { + this.state = 2084; + this.match(MySqlParser.KW_SUBPARTITIONS); + this.state = 2085; + localContext._subCount = this.decimalLiteral(); + } + } + } + } + this.state = 2101; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 218, this.context)) { + case 1: + { + this.state = 2090; + this.match(MySqlParser.LR_BRACKET); + this.state = 2091; + this.partitionDefinition(); + this.state = 2096; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 2092; + this.match(MySqlParser.COMMA); + this.state = 2093; + this.partitionDefinition(); + } + } + this.state = 2098; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 2099; + this.match(MySqlParser.RR_BRACKET); + } + break; + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + partitionFunctionDefinition() { + let localContext = new PartitionFunctionDefinitionContext(this.context, this.state); + this.enterRule(localContext, 106, MySqlParser.RULE_partitionFunctionDefinition); + let _la; + try { + this.state = 2149; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 225, this.context)) { + case 1: + localContext = new PartitionFunctionHashContext(localContext); + this.enterOuterAlt(localContext, 1); + { + this.state = 2104; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 101) { + { + this.state = 2103; + this.match(MySqlParser.KW_LINEAR); + } + } + this.state = 2106; + this.match(MySqlParser.KW_HASH); + this.state = 2107; + this.match(MySqlParser.LR_BRACKET); + this.state = 2108; + this.expression(0); + this.state = 2109; + this.match(MySqlParser.RR_BRACKET); + } + break; + case 2: + localContext = new PartitionFunctionKeyContext(localContext); + this.enterOuterAlt(localContext, 2); + { + this.state = 2112; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 101) { + { + this.state = 2111; + this.match(MySqlParser.KW_LINEAR); + } + } + this.state = 2114; + this.match(MySqlParser.KW_KEY); + this.state = 2118; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 308) { + { + this.state = 2115; + this.match(MySqlParser.KW_ALGORITHM); + this.state = 2116; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 2117; + localContext._algType = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 872 || _la === 873)) { + localContext._algType = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + this.state = 2120; + this.match(MySqlParser.LR_BRACKET); + this.state = 2122; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 222, this.context)) { + case 1: + { + this.state = 2121; + this.columnNames(); + } + break; + } + this.state = 2124; + this.match(MySqlParser.RR_BRACKET); + } + break; + case 3: + localContext = new PartitionFunctionRangeContext(localContext); + this.enterOuterAlt(localContext, 3); + { + this.state = 2125; + this.match(MySqlParser.KW_RANGE); + this.state = 2135; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.LR_BRACKET: + { + this.state = 2126; + this.match(MySqlParser.LR_BRACKET); + this.state = 2127; + this.expression(0); + this.state = 2128; + this.match(MySqlParser.RR_BRACKET); + } + break; + case MySqlParser.KW_COLUMNS: + { + this.state = 2130; + this.match(MySqlParser.KW_COLUMNS); + this.state = 2131; + this.match(MySqlParser.LR_BRACKET); + this.state = 2132; + this.columnNames(); + this.state = 2133; + this.match(MySqlParser.RR_BRACKET); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + break; + case 4: + localContext = new PartitionFunctionListContext(localContext); + this.enterOuterAlt(localContext, 4); + { + this.state = 2137; + this.match(MySqlParser.KW_LIST); + this.state = 2147; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.LR_BRACKET: + { + this.state = 2138; + this.match(MySqlParser.LR_BRACKET); + this.state = 2139; + this.expression(0); + this.state = 2140; + this.match(MySqlParser.RR_BRACKET); + } + break; + case MySqlParser.KW_COLUMNS: + { + this.state = 2142; + this.match(MySqlParser.KW_COLUMNS); + this.state = 2143; + this.match(MySqlParser.LR_BRACKET); + this.state = 2144; + this.columnNames(); + this.state = 2145; + this.match(MySqlParser.RR_BRACKET); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + subpartitionFunctionDefinition() { + let localContext = new SubpartitionFunctionDefinitionContext(this.context, this.state); + this.enterRule(localContext, 108, MySqlParser.RULE_subpartitionFunctionDefinition); + let _la; + try { + this.state = 2172; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 229, this.context)) { + case 1: + localContext = new SubPartitionFunctionHashContext(localContext); + this.enterOuterAlt(localContext, 1); + { + this.state = 2152; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 101) { + { + this.state = 2151; + this.match(MySqlParser.KW_LINEAR); + } + } + this.state = 2154; + this.match(MySqlParser.KW_HASH); + this.state = 2155; + this.match(MySqlParser.LR_BRACKET); + this.state = 2156; + this.expression(0); + this.state = 2157; + this.match(MySqlParser.RR_BRACKET); + } + break; + case 2: + localContext = new SubPartitionFunctionKeyContext(localContext); + this.enterOuterAlt(localContext, 2); + { + this.state = 2160; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 101) { + { + this.state = 2159; + this.match(MySqlParser.KW_LINEAR); + } + } + this.state = 2162; + this.match(MySqlParser.KW_KEY); + this.state = 2166; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 308) { + { + this.state = 2163; + this.match(MySqlParser.KW_ALGORITHM); + this.state = 2164; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 2165; + localContext._algType = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 872 || _la === 873)) { + localContext._algType = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + this.state = 2168; + this.match(MySqlParser.LR_BRACKET); + this.state = 2169; + this.columnNames(); + this.state = 2170; + this.match(MySqlParser.RR_BRACKET); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + partitionDefinition() { + let localContext = new PartitionDefinitionContext(this.context, this.state); + this.enterRule(localContext, 110, MySqlParser.RULE_partitionDefinition); + let _la; + try { + this.state = 2320; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 248, this.context)) { + case 1: + localContext = new PartitionComparisonContext(localContext); + this.enterOuterAlt(localContext, 1); + { + this.state = 2174; + this.match(MySqlParser.KW_PARTITION); + this.state = 2175; + this.partitionName(); + this.state = 2176; + this.match(MySqlParser.KW_VALUES); + this.state = 2177; + this.match(MySqlParser.KW_LESS); + this.state = 2178; + this.match(MySqlParser.KW_THAN); + this.state = 2179; + this.match(MySqlParser.LR_BRACKET); + this.state = 2180; + this.partitionDefinerAtom(); + this.state = 2185; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 2181; + this.match(MySqlParser.COMMA); + this.state = 2182; + this.partitionDefinerAtom(); + } + } + this.state = 2187; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 2188; + this.match(MySqlParser.RR_BRACKET); + this.state = 2192; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 42 || _la === 82 || _la === 340 || _la === 360 || _la === 380 || ((((_la - 480)) & ~0x1F) === 0 && ((1 << (_la - 480)) & 16778241) !== 0) || _la === 647 || _la === 658) { + { + { + this.state = 2189; + this.partitionOption(); + } + } + this.state = 2194; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 2206; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 866) { + { + this.state = 2195; + this.match(MySqlParser.LR_BRACKET); + this.state = 2196; + this.subpartitionDefinition(); + this.state = 2201; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 2197; + this.match(MySqlParser.COMMA); + this.state = 2198; + this.subpartitionDefinition(); + } + } + this.state = 2203; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 2204; + this.match(MySqlParser.RR_BRACKET); + } + } + } + break; + case 2: + localContext = new PartitionComparisonContext(localContext); + this.enterOuterAlt(localContext, 2); + { + this.state = 2208; + this.match(MySqlParser.KW_PARTITION); + this.state = 2209; + this.partitionName(); + this.state = 2210; + this.match(MySqlParser.KW_VALUES); + this.state = 2211; + this.match(MySqlParser.KW_LESS); + this.state = 2212; + this.match(MySqlParser.KW_THAN); + this.state = 2213; + this.partitionDefinerAtom(); + this.state = 2217; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 42 || _la === 82 || _la === 340 || _la === 360 || _la === 380 || ((((_la - 480)) & ~0x1F) === 0 && ((1 << (_la - 480)) & 16778241) !== 0) || _la === 647 || _la === 658) { + { + { + this.state = 2214; + this.partitionOption(); + } + } + this.state = 2219; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 2231; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 866) { + { + this.state = 2220; + this.match(MySqlParser.LR_BRACKET); + this.state = 2221; + this.subpartitionDefinition(); + this.state = 2226; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 2222; + this.match(MySqlParser.COMMA); + this.state = 2223; + this.subpartitionDefinition(); + } + } + this.state = 2228; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 2229; + this.match(MySqlParser.RR_BRACKET); + } + } + } + break; + case 3: + localContext = new PartitionListAtomContext(localContext); + this.enterOuterAlt(localContext, 3); + { + this.state = 2233; + this.match(MySqlParser.KW_PARTITION); + this.state = 2234; + this.partitionName(); + this.state = 2235; + this.match(MySqlParser.KW_VALUES); + this.state = 2236; + this.match(MySqlParser.KW_IN); + this.state = 2237; + this.match(MySqlParser.LR_BRACKET); + this.state = 2238; + this.partitionDefinerAtom(); + this.state = 2243; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 2239; + this.match(MySqlParser.COMMA); + this.state = 2240; + this.partitionDefinerAtom(); + } + } + this.state = 2245; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 2246; + this.match(MySqlParser.RR_BRACKET); + this.state = 2250; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 42 || _la === 82 || _la === 340 || _la === 360 || _la === 380 || ((((_la - 480)) & ~0x1F) === 0 && ((1 << (_la - 480)) & 16778241) !== 0) || _la === 647 || _la === 658) { + { + { + this.state = 2247; + this.partitionOption(); + } + } + this.state = 2252; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 2264; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 866) { + { + this.state = 2253; + this.match(MySqlParser.LR_BRACKET); + this.state = 2254; + this.subpartitionDefinition(); + this.state = 2259; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 2255; + this.match(MySqlParser.COMMA); + this.state = 2256; + this.subpartitionDefinition(); + } + } + this.state = 2261; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 2262; + this.match(MySqlParser.RR_BRACKET); + } + } + } + break; + case 4: + localContext = new PartitionListVectorContext(localContext); + this.enterOuterAlt(localContext, 4); + { + this.state = 2266; + this.match(MySqlParser.KW_PARTITION); + this.state = 2267; + this.partitionName(); + this.state = 2268; + this.match(MySqlParser.KW_VALUES); + this.state = 2269; + this.match(MySqlParser.KW_IN); + this.state = 2270; + this.match(MySqlParser.LR_BRACKET); + this.state = 2271; + this.partitionDefinerVector(); + this.state = 2276; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 2272; + this.match(MySqlParser.COMMA); + this.state = 2273; + this.partitionDefinerVector(); + } + } + this.state = 2278; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 2279; + this.match(MySqlParser.RR_BRACKET); + this.state = 2283; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 42 || _la === 82 || _la === 340 || _la === 360 || _la === 380 || ((((_la - 480)) & ~0x1F) === 0 && ((1 << (_la - 480)) & 16778241) !== 0) || _la === 647 || _la === 658) { + { + { + this.state = 2280; + this.partitionOption(); + } + } + this.state = 2285; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 2297; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 866) { + { + this.state = 2286; + this.match(MySqlParser.LR_BRACKET); + this.state = 2287; + this.subpartitionDefinition(); + this.state = 2292; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 2288; + this.match(MySqlParser.COMMA); + this.state = 2289; + this.subpartitionDefinition(); + } + } + this.state = 2294; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 2295; + this.match(MySqlParser.RR_BRACKET); + } + } + } + break; + case 5: + localContext = new PartitionSimpleContext(localContext); + this.enterOuterAlt(localContext, 5); + { + this.state = 2299; + this.match(MySqlParser.KW_PARTITION); + this.state = 2300; + this.partitionName(); + this.state = 2304; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 42 || _la === 82 || _la === 340 || _la === 360 || _la === 380 || ((((_la - 480)) & ~0x1F) === 0 && ((1 << (_la - 480)) & 16778241) !== 0) || _la === 647 || _la === 658) { + { + { + this.state = 2301; + this.partitionOption(); + } + } + this.state = 2306; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 2318; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 866) { + { + this.state = 2307; + this.match(MySqlParser.LR_BRACKET); + this.state = 2308; + this.subpartitionDefinition(); + this.state = 2313; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 2309; + this.match(MySqlParser.COMMA); + this.state = 2310; + this.subpartitionDefinition(); + } + } + this.state = 2315; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 2316; + this.match(MySqlParser.RR_BRACKET); + } + } + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + partitionDefinerAtom() { + let localContext = new PartitionDefinerAtomContext(this.context, this.state); + this.enterRule(localContext, 112, MySqlParser.RULE_partitionDefinerAtom); + try { + this.state = 2325; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 249, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 2322; + this.constant(); + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 2323; + this.expression(0); + } + break; + case 3: + this.enterOuterAlt(localContext, 3); + { + this.state = 2324; + this.match(MySqlParser.KW_MAXVALUE); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + partitionDefinerVector() { + let localContext = new PartitionDefinerVectorContext(this.context, this.state); + this.enterRule(localContext, 114, MySqlParser.RULE_partitionDefinerVector); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 2327; + this.match(MySqlParser.LR_BRACKET); + this.state = 2328; + this.partitionDefinerAtom(); + this.state = 2331; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + do { + { + { + this.state = 2329; + this.match(MySqlParser.COMMA); + this.state = 2330; + this.partitionDefinerAtom(); + } + } + this.state = 2333; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } while (_la === 868); + this.state = 2335; + this.match(MySqlParser.RR_BRACKET); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + subpartitionDefinition() { + let localContext = new SubpartitionDefinitionContext(this.context, this.state); + this.enterRule(localContext, 116, MySqlParser.RULE_subpartitionDefinition); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 2337; + this.match(MySqlParser.KW_SUBPARTITION); + this.state = 2338; + localContext._logicalName = this.uid(); + this.state = 2342; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 42 || _la === 82 || _la === 340 || _la === 360 || _la === 380 || ((((_la - 480)) & ~0x1F) === 0 && ((1 << (_la - 480)) & 16778241) !== 0) || _la === 647 || _la === 658) { + { + { + this.state = 2339; + this.partitionOption(); + } + } + this.state = 2344; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + partitionOption() { + let localContext = new PartitionOptionContext(this.context, this.state); + this.enterRule(localContext, 118, MySqlParser.RULE_partitionOption); + let _la; + try { + this.state = 2393; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_DEFAULT: + case MySqlParser.KW_ENGINE: + case MySqlParser.KW_STORAGE: + localContext = new PartitionOptionEngineContext(localContext); + this.enterOuterAlt(localContext, 1); + { + this.state = 2346; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 42) { + { + this.state = 2345; + this.match(MySqlParser.KW_DEFAULT); + } + } + this.state = 2349; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 647) { + { + this.state = 2348; + this.match(MySqlParser.KW_STORAGE); + } + } + this.state = 2351; + this.match(MySqlParser.KW_ENGINE); + this.state = 2353; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 2352; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 2355; + this.engineName(); + } + break; + case MySqlParser.KW_COMMENT: + localContext = new PartitionOptionCommentContext(localContext); + this.enterOuterAlt(localContext, 2); + { + this.state = 2356; + this.match(MySqlParser.KW_COMMENT); + this.state = 2358; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 2357; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 2360; + localContext._comment = this.match(MySqlParser.STRING_LITERAL); + } + break; + case MySqlParser.KW_DATA: + localContext = new PartitionOptionDataDirectoryContext(localContext); + this.enterOuterAlt(localContext, 3); + { + this.state = 2361; + this.match(MySqlParser.KW_DATA); + this.state = 2362; + this.match(MySqlParser.KW_DIRECTORY); + this.state = 2364; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 2363; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 2366; + localContext._dataDirectory = this.match(MySqlParser.STRING_LITERAL); + } + break; + case MySqlParser.KW_INDEX: + localContext = new PartitionOptionIndexDirectoryContext(localContext); + this.enterOuterAlt(localContext, 4); + { + this.state = 2367; + this.match(MySqlParser.KW_INDEX); + this.state = 2368; + this.match(MySqlParser.KW_DIRECTORY); + this.state = 2370; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 2369; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 2372; + localContext._indexDirectory = this.match(MySqlParser.STRING_LITERAL); + } + break; + case MySqlParser.KW_MAX_ROWS: + localContext = new PartitionOptionMaxRowsContext(localContext); + this.enterOuterAlt(localContext, 5); + { + this.state = 2373; + this.match(MySqlParser.KW_MAX_ROWS); + this.state = 2375; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 2374; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 2377; + localContext._maxRows = this.decimalLiteral(); + } + break; + case MySqlParser.KW_MIN_ROWS: + localContext = new PartitionOptionMinRowsContext(localContext); + this.enterOuterAlt(localContext, 6); + { + this.state = 2378; + this.match(MySqlParser.KW_MIN_ROWS); + this.state = 2380; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 2379; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 2382; + localContext._minRows = this.decimalLiteral(); + } + break; + case MySqlParser.KW_TABLESPACE: + localContext = new PartitionOptionTablespaceContext(localContext); + this.enterOuterAlt(localContext, 7); + { + this.state = 2383; + this.match(MySqlParser.KW_TABLESPACE); + this.state = 2385; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 2384; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 2387; + this.tablespaceName(); + } + break; + case MySqlParser.KW_NODEGROUP: + localContext = new PartitionOptionNodeGroupContext(localContext); + this.enterOuterAlt(localContext, 8); + { + this.state = 2388; + this.match(MySqlParser.KW_NODEGROUP); + this.state = 2390; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 2389; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 2392; + localContext._nodegroup = this.uid(); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + alterDatabase() { + let localContext = new AlterDatabaseContext(this.context, this.state); + this.enterRule(localContext, 120, MySqlParser.RULE_alterDatabase); + let _la; + try { + this.state = 2413; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 265, this.context)) { + case 1: + localContext = new AlterSimpleDatabaseContext(localContext); + this.enterOuterAlt(localContext, 1); + { + this.state = 2395; + this.match(MySqlParser.KW_ALTER); + this.state = 2396; + localContext._dbFormat = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 39 || _la === 152)) { + localContext._dbFormat = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 2398; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 263, this.context)) { + case 1: + { + this.state = 2397; + this.databaseName(); + } + break; + } + this.state = 2401; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + do { + { + { + this.state = 2400; + this.createDatabaseOption(); + } + } + this.state = 2403; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } while (((((_la - 26)) & ~0x1F) === 0 && ((1 << (_la - 26)) & 65541) !== 0) || _la === 135 || _la === 224 || _la === 376 || _la === 823); + } + break; + case 2: + localContext = new AlterUpgradeNameContext(localContext); + this.enterOuterAlt(localContext, 2); + { + this.state = 2405; + this.match(MySqlParser.KW_ALTER); + this.state = 2406; + localContext._dbFormat = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 39 || _la === 152)) { + localContext._dbFormat = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 2407; + this.databaseName(); + this.state = 2408; + this.match(MySqlParser.KW_UPGRADE); + this.state = 2409; + this.match(MySqlParser.KW_DATA); + this.state = 2410; + this.match(MySqlParser.KW_DIRECTORY); + this.state = 2411; + this.match(MySqlParser.KW_NAME); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + alterEvent() { + let localContext = new AlterEventContext(this.context, this.state); + this.enterRule(localContext, 122, MySqlParser.RULE_alterEvent); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 2415; + this.match(MySqlParser.KW_ALTER); + this.state = 2417; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 364) { + { + this.state = 2416; + this.ownerStatement(); + } + } + this.state = 2419; + this.match(MySqlParser.KW_EVENT); + this.state = 2420; + localContext._event_name = this.fullId(); + this.state = 2424; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 267, this.context)) { + case 1: + { + this.state = 2421; + this.match(MySqlParser.KW_ON); + this.state = 2422; + this.match(MySqlParser.KW_SCHEDULE); + this.state = 2423; + this.scheduleExpression(); + } + break; + } + this.state = 2432; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 119) { + { + this.state = 2426; + this.match(MySqlParser.KW_ON); + this.state = 2427; + this.match(MySqlParser.KW_COMPLETION); + this.state = 2429; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 114) { + { + this.state = 2428; + this.match(MySqlParser.KW_NOT); + } + } + this.state = 2431; + this.match(MySqlParser.KW_PRESERVE); + } + } + this.state = 2437; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 270, this.context)) { + case 1: + { + this.state = 2434; + this.match(MySqlParser.KW_RENAME); + this.state = 2435; + this.match(MySqlParser.KW_TO); + this.state = 2436; + localContext._new_event_name = this.fullId(); + } + break; + } + this.state = 2440; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 368 || _la === 375) { + { + this.state = 2439; + this.enableType(); + } + } + this.state = 2444; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 340) { + { + this.state = 2442; + this.match(MySqlParser.KW_COMMENT); + this.state = 2443; + this.match(MySqlParser.STRING_LITERAL); + } + } + this.state = 2448; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 273, this.context)) { + case 1: + { + this.state = 2446; + this.match(MySqlParser.KW_DO); + this.state = 2447; + this.routineBody(); + } + break; + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + alterFunction() { + let localContext = new AlterFunctionContext(this.context, this.state); + this.enterRule(localContext, 124, MySqlParser.RULE_alterFunction); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 2450; + this.match(MySqlParser.KW_ALTER); + this.state = 2451; + this.match(MySqlParser.KW_FUNCTION); + this.state = 2452; + this.functionName(); + this.state = 2456; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 47 || ((((_la - 112)) & ~0x1F) === 0 && ((1 << (_la - 112)) & 16777221) !== 0) || _la === 162 || _la === 340 || _la === 354 || _la === 444 || _la === 502) { + { + { + this.state = 2453; + this.routineOption(); + } + } + this.state = 2458; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + alterInstance() { + let localContext = new AlterInstanceContext(this.context, this.state); + this.enterRule(localContext, 126, MySqlParser.RULE_alterInstance); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 2459; + this.match(MySqlParser.KW_ALTER); + this.state = 2460; + this.match(MySqlParser.KW_INSTANCE); + this.state = 2461; + this.match(MySqlParser.KW_ROTATE); + this.state = 2462; + this.match(MySqlParser.KW_INNODB); + this.state = 2463; + this.match(MySqlParser.KW_MASTER); + this.state = 2464; + this.match(MySqlParser.KW_KEY); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + alterLogfileGroup() { + let localContext = new AlterLogfileGroupContext(this.context, this.state); + this.enterRule(localContext, 128, MySqlParser.RULE_alterLogfileGroup); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 2466; + this.match(MySqlParser.KW_ALTER); + this.state = 2467; + this.match(MySqlParser.KW_LOGFILE); + this.state = 2468; + this.match(MySqlParser.KW_GROUP); + this.state = 2469; + localContext._logfileGroupName = this.uid(); + this.state = 2470; + this.match(MySqlParser.KW_ADD); + this.state = 2471; + this.match(MySqlParser.KW_UNDOFILE); + this.state = 2472; + this.match(MySqlParser.STRING_LITERAL); + this.state = 2478; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 428) { + { + this.state = 2473; + this.match(MySqlParser.KW_INITIAL_SIZE); + this.state = 2475; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 2474; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 2477; + this.fileSizeLiteral(); + } + } + this.state = 2481; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 687) { + { + this.state = 2480; + this.match(MySqlParser.KW_WAIT); + } + } + this.state = 2483; + this.match(MySqlParser.KW_ENGINE); + this.state = 2485; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 2484; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 2487; + this.engineName(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + alterProcedure() { + let localContext = new AlterProcedureContext(this.context, this.state); + this.enterRule(localContext, 130, MySqlParser.RULE_alterProcedure); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 2489; + this.match(MySqlParser.KW_ALTER); + this.state = 2490; + this.match(MySqlParser.KW_PROCEDURE); + this.state = 2491; + localContext._proc_name = this.fullId(); + this.state = 2495; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 47 || ((((_la - 112)) & ~0x1F) === 0 && ((1 << (_la - 112)) & 16777221) !== 0) || _la === 162 || _la === 340 || _la === 354 || _la === 444 || _la === 502) { + { + { + this.state = 2492; + this.routineOption(); + } + } + this.state = 2497; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + alterServer() { + let localContext = new AlterServerContext(this.context, this.state); + this.enterRule(localContext, 132, MySqlParser.RULE_alterServer); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 2498; + this.match(MySqlParser.KW_ALTER); + this.state = 2499; + this.match(MySqlParser.KW_SERVER); + this.state = 2500; + localContext._serverName = this.uid(); + this.state = 2501; + this.match(MySqlParser.KW_OPTIONS); + this.state = 2502; + this.match(MySqlParser.LR_BRACKET); + this.state = 2503; + this.serverOption(); + this.state = 2508; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 2504; + this.match(MySqlParser.COMMA); + this.state = 2505; + this.serverOption(); + } + } + this.state = 2510; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 2511; + this.match(MySqlParser.RR_BRACKET); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + alterTable() { + let localContext = new AlterTableContext(this.context, this.state); + this.enterRule(localContext, 134, MySqlParser.RULE_alterTable); + let _la; + try { + let alternative; + this.enterOuterAlt(localContext, 1); + { + this.state = 2513; + this.match(MySqlParser.KW_ALTER); + this.state = 2514; + this.match(MySqlParser.KW_TABLE); + this.state = 2515; + this.tableName(); + this.state = 2524; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 282, this.context)) { + case 1: + { + this.state = 2516; + this.alterOption(); + this.state = 2521; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 2517; + this.match(MySqlParser.COMMA); + this.state = 2518; + this.alterOption(); + } + } + this.state = 2523; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + break; + } + this.state = 2533; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 284, this.context)) { + case 1: + { + this.state = 2526; + this.alterPartitionSpecification(); + this.state = 2530; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 283, this.context); + while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER) { + if (alternative === 1) { + { + { + this.state = 2527; + this.alterPartitionSpecification(); + } + } + } + this.state = 2532; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 283, this.context); + } + } + break; + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + alterTablespace() { + let localContext = new AlterTablespaceContext(this.context, this.state); + this.enterRule(localContext, 136, MySqlParser.RULE_alterTablespace); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 2535; + this.match(MySqlParser.KW_ALTER); + this.state = 2537; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 180) { + { + this.state = 2536; + this.match(MySqlParser.KW_UNDO); + } + } + this.state = 2539; + this.match(MySqlParser.KW_TABLESPACE); + this.state = 2540; + this.tablespaceName(); + this.state = 2541; + _la = this.tokenStream.LA(1); + if (!(_la === 6 || _la === 51)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 2542; + this.match(MySqlParser.KW_DATAFILE); + this.state = 2543; + this.match(MySqlParser.STRING_LITERAL); + this.state = 2549; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 428) { + { + this.state = 2544; + this.match(MySqlParser.KW_INITIAL_SIZE); + this.state = 2546; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 2545; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 2548; + this.fileSizeLiteral(); + } + } + this.state = 2552; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 687) { + { + this.state = 2551; + this.match(MySqlParser.KW_WAIT); + } + } + this.state = 2557; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 289, this.context)) { + case 1: + { + this.state = 2554; + this.match(MySqlParser.KW_RENAME); + this.state = 2555; + this.match(MySqlParser.KW_TO); + this.state = 2556; + this.tablespaceNameCreate(); + } + break; + } + this.state = 2564; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 314) { + { + this.state = 2559; + this.match(MySqlParser.KW_AUTOEXTEND_SIZE); + this.state = 2561; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 2560; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 2563; + this.fileSizeLiteral(); + } + } + this.state = 2568; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 292, this.context)) { + case 1: + { + this.state = 2566; + this.match(MySqlParser.KW_SET); + this.state = 2567; + _la = this.tokenStream.LA(1); + if (!(_la === 5 || _la === 81)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + break; + } + this.state = 2575; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 376) { + { + this.state = 2570; + this.match(MySqlParser.KW_ENCRYPTION); + this.state = 2572; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 2571; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 2574; + this.match(MySqlParser.STRING_LITERAL); + } + } + this.state = 2582; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 380) { + { + this.state = 2577; + this.match(MySqlParser.KW_ENGINE); + this.state = 2579; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 2578; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 2581; + this.engineName(); + } + } + this.state = 2589; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 825) { + { + this.state = 2584; + this.match(MySqlParser.KW_ENGINE_ATTRIBUTE); + this.state = 2586; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 2585; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 2588; + this.match(MySqlParser.STRING_LITERAL); + } + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + alterView() { + let localContext = new AlterViewContext(this.context, this.state); + this.enterRule(localContext, 138, MySqlParser.RULE_alterView); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 2591; + this.match(MySqlParser.KW_ALTER); + this.state = 2595; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 308) { + { + this.state = 2592; + this.match(MySqlParser.KW_ALGORITHM); + this.state = 2593; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 2594; + localContext._algType = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 486 || _la === 661 || _la === 670)) { + localContext._algType = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + this.state = 2598; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 364) { + { + this.state = 2597; + this.ownerStatement(); + } + } + this.state = 2603; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 162) { + { + this.state = 2600; + this.match(MySqlParser.KW_SQL); + this.state = 2601; + this.match(MySqlParser.KW_SECURITY); + this.state = 2602; + localContext._secContext = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 364 || _la === 436)) { + localContext._secContext = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + this.state = 2605; + this.match(MySqlParser.KW_VIEW); + this.state = 2606; + this.viewName(); + this.state = 2611; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 866) { + { + this.state = 2607; + this.match(MySqlParser.LR_BRACKET); + this.state = 2608; + this.columnNames(); + this.state = 2609; + this.match(MySqlParser.RR_BRACKET); + } + } + this.state = 2613; + this.match(MySqlParser.KW_AS); + this.state = 2614; + this.selectStatement(); + this.state = 2621; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 304, this.context)) { + case 1: + { + this.state = 2615; + this.match(MySqlParser.KW_WITH); + this.state = 2617; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 325 || _la === 450) { + { + this.state = 2616; + localContext._checkOpt = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 325 || _la === 450)) { + localContext._checkOpt = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + this.state = 2619; + this.match(MySqlParser.KW_CHECK); + this.state = 2620; + this.match(MySqlParser.KW_OPTION); + } + break; + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + alterOption() { + let localContext = new AlterOptionContext(this.context, this.state); + this.enterRule(localContext, 140, MySqlParser.RULE_alterOption); + let _la; + try { + let alternative; + this.state = 2887; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 348, this.context)) { + case 1: + localContext = new AlterByTableOptionContext(localContext); + this.enterOuterAlt(localContext, 1); + { + this.state = 2623; + this.tableOption(); + this.state = 2630; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 306, this.context); + while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER) { + if (alternative === 1) { + { + { + this.state = 2625; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 868) { + { + this.state = 2624; + this.match(MySqlParser.COMMA); + } + } + this.state = 2627; + this.tableOption(); + } + } + } + this.state = 2632; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 306, this.context); + } + } + break; + case 2: + localContext = new AlterByAddColumnContext(localContext); + this.enterOuterAlt(localContext, 2); + { + this.state = 2633; + this.match(MySqlParser.KW_ADD); + this.state = 2635; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 307, this.context)) { + case 1: + { + this.state = 2634; + this.match(MySqlParser.KW_COLUMN); + } + break; + } + this.state = 2637; + this.columnName(); + this.state = 2638; + this.columnDefinition(); + this.state = 2642; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_FIRST: + { + this.state = 2639; + this.match(MySqlParser.KW_FIRST); + } + break; + case MySqlParser.KW_AFTER: + { + this.state = 2640; + this.match(MySqlParser.KW_AFTER); + this.state = 2641; + this.columnName(); + } + break; + case MySqlParser.EOF: + case MySqlParser.KW_ADD: + case MySqlParser.KW_ALTER: + case MySqlParser.KW_ANALYZE: + case MySqlParser.KW_CALL: + case MySqlParser.KW_CHANGE: + case MySqlParser.KW_CHECK: + case MySqlParser.KW_CREATE: + case MySqlParser.KW_DELETE: + case MySqlParser.KW_DESC: + case MySqlParser.KW_DESCRIBE: + case MySqlParser.KW_DROP: + case MySqlParser.KW_EXPLAIN: + case MySqlParser.KW_GET: + case MySqlParser.KW_GRANT: + case MySqlParser.KW_INSERT: + case MySqlParser.KW_KILL: + case MySqlParser.KW_LOAD: + case MySqlParser.KW_LOCK: + case MySqlParser.KW_OPTIMIZE: + case MySqlParser.KW_PURGE: + case MySqlParser.KW_RELEASE: + case MySqlParser.KW_RENAME: + case MySqlParser.KW_REPLACE: + case MySqlParser.KW_RESIGNAL: + case MySqlParser.KW_REVOKE: + case MySqlParser.KW_SELECT: + case MySqlParser.KW_SET: + case MySqlParser.KW_SHOW: + case MySqlParser.KW_SIGNAL: + case MySqlParser.KW_TABLE: + case MySqlParser.KW_UNLOCK: + case MySqlParser.KW_UPDATE: + case MySqlParser.KW_USE: + case MySqlParser.KW_VALUES: + case MySqlParser.KW_WITH: + case MySqlParser.KW_BEGIN: + case MySqlParser.KW_BINLOG: + case MySqlParser.KW_CACHE: + case MySqlParser.KW_CHECKSUM: + case MySqlParser.KW_COALESCE: + case MySqlParser.KW_COMMIT: + case MySqlParser.KW_DEALLOCATE: + case MySqlParser.KW_DISCARD: + case MySqlParser.KW_DO: + case MySqlParser.KW_EXCHANGE: + case MySqlParser.KW_FLUSH: + case MySqlParser.KW_HANDLER: + case MySqlParser.KW_HELP: + case MySqlParser.KW_IMPORT: + case MySqlParser.KW_INSTALL: + case MySqlParser.KW_PREPARE: + case MySqlParser.KW_REBUILD: + case MySqlParser.KW_REMOVE: + case MySqlParser.KW_REORGANIZE: + case MySqlParser.KW_REPAIR: + case MySqlParser.KW_RESET: + case MySqlParser.KW_RESTART: + case MySqlParser.KW_ROLLBACK: + case MySqlParser.KW_SAVEPOINT: + case MySqlParser.KW_START: + case MySqlParser.KW_STOP: + case MySqlParser.KW_TRUNCATE: + case MySqlParser.KW_UNINSTALL: + case MySqlParser.KW_UPGRADE: + case MySqlParser.KW_XA: + case MySqlParser.KW_CLONE: + case MySqlParser.KW_EXECUTE: + case MySqlParser.KW_SHUTDOWN: + case MySqlParser.LR_BRACKET: + case MySqlParser.COMMA: + case MySqlParser.SEMI: + break; + default: + break; + } + } + break; + case 3: + localContext = new AlterByAddColumnsContext(localContext); + this.enterOuterAlt(localContext, 3); + { + this.state = 2644; + this.match(MySqlParser.KW_ADD); + this.state = 2646; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 29) { + { + this.state = 2645; + this.match(MySqlParser.KW_COLUMN); + } + } + this.state = 2648; + this.match(MySqlParser.LR_BRACKET); + this.state = 2649; + this.columnName(); + this.state = 2650; + this.columnDefinition(); + this.state = 2657; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 2651; + this.match(MySqlParser.COMMA); + this.state = 2652; + this.columnName(); + this.state = 2653; + this.columnDefinition(); + } + } + this.state = 2659; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 2660; + this.match(MySqlParser.RR_BRACKET); + } + break; + case 4: + localContext = new AlterByAddIndexContext(localContext); + this.enterOuterAlt(localContext, 4); + { + this.state = 2662; + this.match(MySqlParser.KW_ADD); + this.state = 2663; + _la = this.tokenStream.LA(1); + if (!(_la === 82 || _la === 92)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 2665; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if ((((_la) & ~0x1F) === 0 && ((1 << _la) & 1074302976) !== 0) || ((((_la - 36)) & ~0x1F) === 0 && ((1 << (_la - 36)) & 11014219) !== 0) || ((((_la - 74)) & ~0x1F) === 0 && ((1 << (_la - 74)) & 18878481) !== 0) || ((((_la - 117)) & ~0x1F) === 0 && ((1 << (_la - 117)) & 100679969) !== 0) || ((((_la - 150)) & ~0x1F) === 0 && ((1 << (_la - 150)) & 1049605) !== 0) || ((((_la - 219)) & ~0x1F) === 0 && ((1 << (_la - 219)) & 5374495) !== 0) || ((((_la - 253)) & ~0x1F) === 0 && ((1 << (_la - 253)) & 4294967295) !== 0) || ((((_la - 285)) & ~0x1F) === 0 && ((1 << (_la - 285)) & 4261412607) !== 0) || ((((_la - 317)) & ~0x1F) === 0 && ((1 << (_la - 317)) & 4160741375) !== 0) || ((((_la - 349)) & ~0x1F) === 0 && ((1 << (_la - 349)) & 4026531839) !== 0) || ((((_la - 381)) & ~0x1F) === 0 && ((1 << (_la - 381)) & 1055907839) !== 0) || ((((_la - 413)) & ~0x1F) === 0 && ((1 << (_la - 413)) & 4294885367) !== 0) || ((((_la - 445)) & ~0x1F) === 0 && ((1 << (_la - 445)) & 3757571071) !== 0) || ((((_la - 478)) & ~0x1F) === 0 && ((1 << (_la - 478)) & 3755999231) !== 0) || ((((_la - 510)) & ~0x1F) === 0 && ((1 << (_la - 510)) & 3751780349) !== 0) || ((((_la - 542)) & ~0x1F) === 0 && ((1 << (_la - 542)) & 2141183997) !== 0) || ((((_la - 575)) & ~0x1F) === 0 && ((1 << (_la - 575)) & 2147483629) !== 0) || ((((_la - 633)) & ~0x1F) === 0 && ((1 << (_la - 633)) & 4294934527) !== 0) || ((((_la - 665)) & ~0x1F) === 0 && ((1 << (_la - 665)) & 4278189053) !== 0) || ((((_la - 697)) & ~0x1F) === 0 && ((1 << (_la - 697)) & 1644099327) !== 0) || ((((_la - 729)) & ~0x1F) === 0 && ((1 << (_la - 729)) & 4294900735) !== 0) || ((((_la - 761)) & ~0x1F) === 0 && ((1 << (_la - 761)) & 4294967295) !== 0) || ((((_la - 793)) & ~0x1F) === 0 && ((1 << (_la - 793)) & 4288675839) !== 0) || ((((_la - 825)) & ~0x1F) === 0 && ((1 << (_la - 825)) & 2147527671) !== 0) || ((((_la - 879)) & ~0x1F) === 0 && ((1 << (_la - 879)) & 1033) !== 0)) { + { + this.state = 2664; + this.indexName(); + } + } + this.state = 2668; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 188) { + { + this.state = 2667; + this.indexType(); + } + } + this.state = 2670; + this.indexColumnNames(); + this.state = 2674; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 313, this.context); + while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER) { + if (alternative === 1) { + { + { + this.state = 2671; + this.indexOption(); + } + } + } + this.state = 2676; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 313, this.context); + } + } + break; + case 5: + localContext = new AlterByAddSpecialIndexContext(localContext); + this.enterOuterAlt(localContext, 5); + { + this.state = 2677; + this.match(MySqlParser.KW_ADD); + this.state = 2678; + _la = this.tokenStream.LA(1); + if (!(_la === 69 || _la === 161)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 2680; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 82 || _la === 92) { + { + this.state = 2679; + _la = this.tokenStream.LA(1); + if (!(_la === 82 || _la === 92)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + this.state = 2683; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if ((((_la) & ~0x1F) === 0 && ((1 << _la) & 1074302976) !== 0) || ((((_la - 36)) & ~0x1F) === 0 && ((1 << (_la - 36)) & 11014219) !== 0) || ((((_la - 74)) & ~0x1F) === 0 && ((1 << (_la - 74)) & 18878481) !== 0) || ((((_la - 117)) & ~0x1F) === 0 && ((1 << (_la - 117)) & 100679969) !== 0) || ((((_la - 150)) & ~0x1F) === 0 && ((1 << (_la - 150)) & 1049605) !== 0) || ((((_la - 219)) & ~0x1F) === 0 && ((1 << (_la - 219)) & 5374495) !== 0) || ((((_la - 253)) & ~0x1F) === 0 && ((1 << (_la - 253)) & 4294967295) !== 0) || ((((_la - 285)) & ~0x1F) === 0 && ((1 << (_la - 285)) & 4261412607) !== 0) || ((((_la - 317)) & ~0x1F) === 0 && ((1 << (_la - 317)) & 4160741375) !== 0) || ((((_la - 349)) & ~0x1F) === 0 && ((1 << (_la - 349)) & 4026531839) !== 0) || ((((_la - 381)) & ~0x1F) === 0 && ((1 << (_la - 381)) & 1055907839) !== 0) || ((((_la - 413)) & ~0x1F) === 0 && ((1 << (_la - 413)) & 4294885367) !== 0) || ((((_la - 445)) & ~0x1F) === 0 && ((1 << (_la - 445)) & 3757571071) !== 0) || ((((_la - 478)) & ~0x1F) === 0 && ((1 << (_la - 478)) & 3755999231) !== 0) || ((((_la - 510)) & ~0x1F) === 0 && ((1 << (_la - 510)) & 3751780349) !== 0) || ((((_la - 542)) & ~0x1F) === 0 && ((1 << (_la - 542)) & 2141183997) !== 0) || ((((_la - 575)) & ~0x1F) === 0 && ((1 << (_la - 575)) & 2147483629) !== 0) || ((((_la - 633)) & ~0x1F) === 0 && ((1 << (_la - 633)) & 4294934527) !== 0) || ((((_la - 665)) & ~0x1F) === 0 && ((1 << (_la - 665)) & 4278189053) !== 0) || ((((_la - 697)) & ~0x1F) === 0 && ((1 << (_la - 697)) & 1644099327) !== 0) || ((((_la - 729)) & ~0x1F) === 0 && ((1 << (_la - 729)) & 4294900735) !== 0) || ((((_la - 761)) & ~0x1F) === 0 && ((1 << (_la - 761)) & 4294967295) !== 0) || ((((_la - 793)) & ~0x1F) === 0 && ((1 << (_la - 793)) & 4288675839) !== 0) || ((((_la - 825)) & ~0x1F) === 0 && ((1 << (_la - 825)) & 2147527671) !== 0) || ((((_la - 879)) & ~0x1F) === 0 && ((1 << (_la - 879)) & 1033) !== 0)) { + { + this.state = 2682; + this.indexName(); + } + } + this.state = 2685; + this.indexColumnNames(); + this.state = 2689; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 316, this.context); + while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER) { + if (alternative === 1) { + { + { + this.state = 2686; + this.indexOption(); + } + } + } + this.state = 2691; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 316, this.context); + } + } + break; + case 6: + localContext = new AlterByAddPrimaryKeyContext(localContext); + this.enterOuterAlt(localContext, 6); + { + this.state = 2692; + this.match(MySqlParser.KW_ADD); + this.state = 2697; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 31) { + { + this.state = 2693; + this.match(MySqlParser.KW_CONSTRAINT); + this.state = 2695; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 317, this.context)) { + case 1: + { + this.state = 2694; + localContext._symbol_ = this.uid(); + } + break; + } + } + } + this.state = 2699; + this.match(MySqlParser.KW_PRIMARY); + this.state = 2700; + this.match(MySqlParser.KW_KEY); + this.state = 2702; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 188) { + { + this.state = 2701; + this.indexType(); + } + } + this.state = 2704; + this.indexColumnNames(); + this.state = 2708; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 320, this.context); + while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER) { + if (alternative === 1) { + { + { + this.state = 2705; + this.indexOption(); + } + } + } + this.state = 2710; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 320, this.context); + } + } + break; + case 7: + localContext = new AlterByAddUniqueKeyContext(localContext); + this.enterOuterAlt(localContext, 7); + { + this.state = 2711; + this.match(MySqlParser.KW_ADD); + this.state = 2716; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 31) { + { + this.state = 2712; + this.match(MySqlParser.KW_CONSTRAINT); + this.state = 2714; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if ((((_la) & ~0x1F) === 0 && ((1 << _la) & 1074302976) !== 0) || ((((_la - 36)) & ~0x1F) === 0 && ((1 << (_la - 36)) & 11014219) !== 0) || ((((_la - 74)) & ~0x1F) === 0 && ((1 << (_la - 74)) & 18878481) !== 0) || ((((_la - 117)) & ~0x1F) === 0 && ((1 << (_la - 117)) & 100679969) !== 0) || ((((_la - 150)) & ~0x1F) === 0 && ((1 << (_la - 150)) & 1049605) !== 0) || ((((_la - 219)) & ~0x1F) === 0 && ((1 << (_la - 219)) & 5374495) !== 0) || ((((_la - 253)) & ~0x1F) === 0 && ((1 << (_la - 253)) & 4294967295) !== 0) || ((((_la - 285)) & ~0x1F) === 0 && ((1 << (_la - 285)) & 4261412607) !== 0) || ((((_la - 317)) & ~0x1F) === 0 && ((1 << (_la - 317)) & 4160741375) !== 0) || ((((_la - 349)) & ~0x1F) === 0 && ((1 << (_la - 349)) & 4026531839) !== 0) || ((((_la - 381)) & ~0x1F) === 0 && ((1 << (_la - 381)) & 1055907839) !== 0) || ((((_la - 413)) & ~0x1F) === 0 && ((1 << (_la - 413)) & 4294885367) !== 0) || ((((_la - 445)) & ~0x1F) === 0 && ((1 << (_la - 445)) & 3757571071) !== 0) || ((((_la - 478)) & ~0x1F) === 0 && ((1 << (_la - 478)) & 3755999231) !== 0) || ((((_la - 510)) & ~0x1F) === 0 && ((1 << (_la - 510)) & 3751780349) !== 0) || ((((_la - 542)) & ~0x1F) === 0 && ((1 << (_la - 542)) & 2141183997) !== 0) || ((((_la - 575)) & ~0x1F) === 0 && ((1 << (_la - 575)) & 2147483629) !== 0) || ((((_la - 633)) & ~0x1F) === 0 && ((1 << (_la - 633)) & 4294934527) !== 0) || ((((_la - 665)) & ~0x1F) === 0 && ((1 << (_la - 665)) & 4278189053) !== 0) || ((((_la - 697)) & ~0x1F) === 0 && ((1 << (_la - 697)) & 1644099327) !== 0) || ((((_la - 729)) & ~0x1F) === 0 && ((1 << (_la - 729)) & 4294900735) !== 0) || ((((_la - 761)) & ~0x1F) === 0 && ((1 << (_la - 761)) & 4294967295) !== 0) || ((((_la - 793)) & ~0x1F) === 0 && ((1 << (_la - 793)) & 4288675839) !== 0) || ((((_la - 825)) & ~0x1F) === 0 && ((1 << (_la - 825)) & 2147527671) !== 0) || ((((_la - 879)) & ~0x1F) === 0 && ((1 << (_la - 879)) & 1033) !== 0)) { + { + this.state = 2713; + localContext._symbol_ = this.uid(); + } + } + } + } + this.state = 2718; + this.match(MySqlParser.KW_UNIQUE); + this.state = 2720; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 82 || _la === 92) { + { + this.state = 2719; + _la = this.tokenStream.LA(1); + if (!(_la === 82 || _la === 92)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + this.state = 2723; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if ((((_la) & ~0x1F) === 0 && ((1 << _la) & 1074302976) !== 0) || ((((_la - 36)) & ~0x1F) === 0 && ((1 << (_la - 36)) & 11014219) !== 0) || ((((_la - 74)) & ~0x1F) === 0 && ((1 << (_la - 74)) & 18878481) !== 0) || ((((_la - 117)) & ~0x1F) === 0 && ((1 << (_la - 117)) & 100679969) !== 0) || ((((_la - 150)) & ~0x1F) === 0 && ((1 << (_la - 150)) & 1049605) !== 0) || ((((_la - 219)) & ~0x1F) === 0 && ((1 << (_la - 219)) & 5374495) !== 0) || ((((_la - 253)) & ~0x1F) === 0 && ((1 << (_la - 253)) & 4294967295) !== 0) || ((((_la - 285)) & ~0x1F) === 0 && ((1 << (_la - 285)) & 4261412607) !== 0) || ((((_la - 317)) & ~0x1F) === 0 && ((1 << (_la - 317)) & 4160741375) !== 0) || ((((_la - 349)) & ~0x1F) === 0 && ((1 << (_la - 349)) & 4026531839) !== 0) || ((((_la - 381)) & ~0x1F) === 0 && ((1 << (_la - 381)) & 1055907839) !== 0) || ((((_la - 413)) & ~0x1F) === 0 && ((1 << (_la - 413)) & 4294885367) !== 0) || ((((_la - 445)) & ~0x1F) === 0 && ((1 << (_la - 445)) & 3757571071) !== 0) || ((((_la - 478)) & ~0x1F) === 0 && ((1 << (_la - 478)) & 3755999231) !== 0) || ((((_la - 510)) & ~0x1F) === 0 && ((1 << (_la - 510)) & 3751780349) !== 0) || ((((_la - 542)) & ~0x1F) === 0 && ((1 << (_la - 542)) & 2141183997) !== 0) || ((((_la - 575)) & ~0x1F) === 0 && ((1 << (_la - 575)) & 2147483629) !== 0) || ((((_la - 633)) & ~0x1F) === 0 && ((1 << (_la - 633)) & 4294934527) !== 0) || ((((_la - 665)) & ~0x1F) === 0 && ((1 << (_la - 665)) & 4278189053) !== 0) || ((((_la - 697)) & ~0x1F) === 0 && ((1 << (_la - 697)) & 1644099327) !== 0) || ((((_la - 729)) & ~0x1F) === 0 && ((1 << (_la - 729)) & 4294900735) !== 0) || ((((_la - 761)) & ~0x1F) === 0 && ((1 << (_la - 761)) & 4294967295) !== 0) || ((((_la - 793)) & ~0x1F) === 0 && ((1 << (_la - 793)) & 4288675839) !== 0) || ((((_la - 825)) & ~0x1F) === 0 && ((1 << (_la - 825)) & 2147527671) !== 0) || ((((_la - 879)) & ~0x1F) === 0 && ((1 << (_la - 879)) & 1033) !== 0)) { + { + this.state = 2722; + this.indexName(); + } + } + this.state = 2726; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 188) { + { + this.state = 2725; + this.indexType(); + } + } + this.state = 2728; + this.indexColumnNames(); + this.state = 2732; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 326, this.context); + while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER) { + if (alternative === 1) { + { + { + this.state = 2729; + this.indexOption(); + } + } + } + this.state = 2734; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 326, this.context); + } + } + break; + case 8: + localContext = new AlterByAddForeignKeyContext(localContext); + this.enterOuterAlt(localContext, 8); + { + this.state = 2735; + this.match(MySqlParser.KW_ADD); + this.state = 2740; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 31) { + { + this.state = 2736; + this.match(MySqlParser.KW_CONSTRAINT); + this.state = 2738; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if ((((_la) & ~0x1F) === 0 && ((1 << _la) & 1074302976) !== 0) || ((((_la - 36)) & ~0x1F) === 0 && ((1 << (_la - 36)) & 11014219) !== 0) || ((((_la - 74)) & ~0x1F) === 0 && ((1 << (_la - 74)) & 18878481) !== 0) || ((((_la - 117)) & ~0x1F) === 0 && ((1 << (_la - 117)) & 100679969) !== 0) || ((((_la - 150)) & ~0x1F) === 0 && ((1 << (_la - 150)) & 1049605) !== 0) || ((((_la - 219)) & ~0x1F) === 0 && ((1 << (_la - 219)) & 5374495) !== 0) || ((((_la - 253)) & ~0x1F) === 0 && ((1 << (_la - 253)) & 4294967295) !== 0) || ((((_la - 285)) & ~0x1F) === 0 && ((1 << (_la - 285)) & 4261412607) !== 0) || ((((_la - 317)) & ~0x1F) === 0 && ((1 << (_la - 317)) & 4160741375) !== 0) || ((((_la - 349)) & ~0x1F) === 0 && ((1 << (_la - 349)) & 4026531839) !== 0) || ((((_la - 381)) & ~0x1F) === 0 && ((1 << (_la - 381)) & 1055907839) !== 0) || ((((_la - 413)) & ~0x1F) === 0 && ((1 << (_la - 413)) & 4294885367) !== 0) || ((((_la - 445)) & ~0x1F) === 0 && ((1 << (_la - 445)) & 3757571071) !== 0) || ((((_la - 478)) & ~0x1F) === 0 && ((1 << (_la - 478)) & 3755999231) !== 0) || ((((_la - 510)) & ~0x1F) === 0 && ((1 << (_la - 510)) & 3751780349) !== 0) || ((((_la - 542)) & ~0x1F) === 0 && ((1 << (_la - 542)) & 2141183997) !== 0) || ((((_la - 575)) & ~0x1F) === 0 && ((1 << (_la - 575)) & 2147483629) !== 0) || ((((_la - 633)) & ~0x1F) === 0 && ((1 << (_la - 633)) & 4294934527) !== 0) || ((((_la - 665)) & ~0x1F) === 0 && ((1 << (_la - 665)) & 4278189053) !== 0) || ((((_la - 697)) & ~0x1F) === 0 && ((1 << (_la - 697)) & 1644099327) !== 0) || ((((_la - 729)) & ~0x1F) === 0 && ((1 << (_la - 729)) & 4294900735) !== 0) || ((((_la - 761)) & ~0x1F) === 0 && ((1 << (_la - 761)) & 4294967295) !== 0) || ((((_la - 793)) & ~0x1F) === 0 && ((1 << (_la - 793)) & 4288675839) !== 0) || ((((_la - 825)) & ~0x1F) === 0 && ((1 << (_la - 825)) & 2147527671) !== 0) || ((((_la - 879)) & ~0x1F) === 0 && ((1 << (_la - 879)) & 1033) !== 0)) { + { + this.state = 2737; + localContext._symbol_ = this.uid(); + } + } + } + } + this.state = 2742; + this.match(MySqlParser.KW_FOREIGN); + this.state = 2743; + this.match(MySqlParser.KW_KEY); + this.state = 2745; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if ((((_la) & ~0x1F) === 0 && ((1 << _la) & 1074302976) !== 0) || ((((_la - 36)) & ~0x1F) === 0 && ((1 << (_la - 36)) & 11014219) !== 0) || ((((_la - 74)) & ~0x1F) === 0 && ((1 << (_la - 74)) & 18878481) !== 0) || ((((_la - 117)) & ~0x1F) === 0 && ((1 << (_la - 117)) & 100679969) !== 0) || ((((_la - 150)) & ~0x1F) === 0 && ((1 << (_la - 150)) & 1049605) !== 0) || ((((_la - 219)) & ~0x1F) === 0 && ((1 << (_la - 219)) & 5374495) !== 0) || ((((_la - 253)) & ~0x1F) === 0 && ((1 << (_la - 253)) & 4294967295) !== 0) || ((((_la - 285)) & ~0x1F) === 0 && ((1 << (_la - 285)) & 4261412607) !== 0) || ((((_la - 317)) & ~0x1F) === 0 && ((1 << (_la - 317)) & 4160741375) !== 0) || ((((_la - 349)) & ~0x1F) === 0 && ((1 << (_la - 349)) & 4026531839) !== 0) || ((((_la - 381)) & ~0x1F) === 0 && ((1 << (_la - 381)) & 1055907839) !== 0) || ((((_la - 413)) & ~0x1F) === 0 && ((1 << (_la - 413)) & 4294885367) !== 0) || ((((_la - 445)) & ~0x1F) === 0 && ((1 << (_la - 445)) & 3757571071) !== 0) || ((((_la - 478)) & ~0x1F) === 0 && ((1 << (_la - 478)) & 3755999231) !== 0) || ((((_la - 510)) & ~0x1F) === 0 && ((1 << (_la - 510)) & 3751780349) !== 0) || ((((_la - 542)) & ~0x1F) === 0 && ((1 << (_la - 542)) & 2141183997) !== 0) || ((((_la - 575)) & ~0x1F) === 0 && ((1 << (_la - 575)) & 2147483629) !== 0) || ((((_la - 633)) & ~0x1F) === 0 && ((1 << (_la - 633)) & 4294934527) !== 0) || ((((_la - 665)) & ~0x1F) === 0 && ((1 << (_la - 665)) & 4278189053) !== 0) || ((((_la - 697)) & ~0x1F) === 0 && ((1 << (_la - 697)) & 1644099327) !== 0) || ((((_la - 729)) & ~0x1F) === 0 && ((1 << (_la - 729)) & 4294900735) !== 0) || ((((_la - 761)) & ~0x1F) === 0 && ((1 << (_la - 761)) & 4294967295) !== 0) || ((((_la - 793)) & ~0x1F) === 0 && ((1 << (_la - 793)) & 4288675839) !== 0) || ((((_la - 825)) & ~0x1F) === 0 && ((1 << (_la - 825)) & 2147527671) !== 0) || ((((_la - 879)) & ~0x1F) === 0 && ((1 << (_la - 879)) & 1033) !== 0)) { + { + this.state = 2744; + this.indexName(); + } + } + this.state = 2747; + this.indexColumnNames(); + this.state = 2748; + this.referenceDefinition(); + } + break; + case 9: + localContext = new AlterByAddCheckTableConstraintContext(localContext); + this.enterOuterAlt(localContext, 9); + { + this.state = 2750; + this.match(MySqlParser.KW_ADD); + this.state = 2752; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 330, this.context)) { + case 1: + { + this.state = 2751; + this.checkConstraintDefinition(); + } + break; + } + } + break; + case 10: + localContext = new AlterByDropConstraintCheckContext(localContext); + this.enterOuterAlt(localContext, 10); + { + this.state = 2754; + this.match(MySqlParser.KW_DROP); + this.state = 2755; + _la = this.tokenStream.LA(1); + if (!(_la === 27 || _la === 31)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 2756; + localContext._symbol_ = this.uid(); + } + break; + case 11: + localContext = new AlterByAlterCheckTableConstraintContext(localContext); + this.enterOuterAlt(localContext, 11); + { + this.state = 2757; + this.match(MySqlParser.KW_ALTER); + this.state = 2758; + _la = this.tokenStream.LA(1); + if (!(_la === 27 || _la === 31)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 2759; + localContext._symbol_ = this.uid(); + this.state = 2761; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 114) { + { + this.state = 2760; + this.match(MySqlParser.KW_NOT); + } + } + this.state = 2764; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 57) { + { + this.state = 2763; + this.match(MySqlParser.KW_ENFORCED); + } + } + } + break; + case 12: + localContext = new AlterBySetAlgorithmContext(localContext); + this.enterOuterAlt(localContext, 12); + { + this.state = 2766; + this.match(MySqlParser.KW_ALGORITHM); + this.state = 2768; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 2767; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 2770; + _la = this.tokenStream.LA(1); + if (!(_la === 42 || _la === 357 || _la === 430 || _la === 434)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + break; + case 13: + localContext = new AlterByAlterColumnDefaultContext(localContext); + this.enterOuterAlt(localContext, 13); + { + this.state = 2771; + this.match(MySqlParser.KW_ALTER); + this.state = 2773; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 334, this.context)) { + case 1: + { + this.state = 2772; + this.match(MySqlParser.KW_COLUMN); + } + break; + } + this.state = 2775; + this.columnName(); + this.state = 2783; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 335, this.context)) { + case 1: + { + this.state = 2776; + this.match(MySqlParser.KW_SET); + this.state = 2777; + this.match(MySqlParser.KW_DEFAULT); + this.state = 2778; + this.defaultValue(); + } + break; + case 2: + { + this.state = 2779; + this.match(MySqlParser.KW_SET); + this.state = 2780; + _la = this.tokenStream.LA(1); + if (!(_la === 435 || _la === 686)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + break; + case 3: + { + this.state = 2781; + this.match(MySqlParser.KW_DROP); + this.state = 2782; + this.match(MySqlParser.KW_DEFAULT); + } + break; + } + } + break; + case 14: + localContext = new AlterByAlterIndexVisibilityContext(localContext); + this.enterOuterAlt(localContext, 14); + { + this.state = 2785; + this.match(MySqlParser.KW_ALTER); + this.state = 2786; + this.match(MySqlParser.KW_INDEX); + this.state = 2787; + this.indexName(); + this.state = 2788; + _la = this.tokenStream.LA(1); + if (!(_la === 435 || _la === 686)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + break; + case 15: + localContext = new AlterByChangeColumnContext(localContext); + this.enterOuterAlt(localContext, 15); + { + this.state = 2790; + this.match(MySqlParser.KW_CHANGE); + this.state = 2792; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 336, this.context)) { + case 1: + { + this.state = 2791; + this.match(MySqlParser.KW_COLUMN); + } + break; + } + this.state = 2794; + localContext._oldColumn = this.columnName(); + this.state = 2795; + localContext._newColumn = this.columnNameCreate(); + this.state = 2796; + this.columnDefinition(); + this.state = 2800; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_FIRST: + { + this.state = 2797; + this.match(MySqlParser.KW_FIRST); + } + break; + case MySqlParser.KW_AFTER: + { + this.state = 2798; + this.match(MySqlParser.KW_AFTER); + this.state = 2799; + this.columnName(); + } + break; + case MySqlParser.EOF: + case MySqlParser.KW_ADD: + case MySqlParser.KW_ALTER: + case MySqlParser.KW_ANALYZE: + case MySqlParser.KW_CALL: + case MySqlParser.KW_CHANGE: + case MySqlParser.KW_CHECK: + case MySqlParser.KW_CREATE: + case MySqlParser.KW_DELETE: + case MySqlParser.KW_DESC: + case MySqlParser.KW_DESCRIBE: + case MySqlParser.KW_DROP: + case MySqlParser.KW_EXPLAIN: + case MySqlParser.KW_GET: + case MySqlParser.KW_GRANT: + case MySqlParser.KW_INSERT: + case MySqlParser.KW_KILL: + case MySqlParser.KW_LOAD: + case MySqlParser.KW_LOCK: + case MySqlParser.KW_OPTIMIZE: + case MySqlParser.KW_PURGE: + case MySqlParser.KW_RELEASE: + case MySqlParser.KW_RENAME: + case MySqlParser.KW_REPLACE: + case MySqlParser.KW_RESIGNAL: + case MySqlParser.KW_REVOKE: + case MySqlParser.KW_SELECT: + case MySqlParser.KW_SET: + case MySqlParser.KW_SHOW: + case MySqlParser.KW_SIGNAL: + case MySqlParser.KW_TABLE: + case MySqlParser.KW_UNLOCK: + case MySqlParser.KW_UPDATE: + case MySqlParser.KW_USE: + case MySqlParser.KW_VALUES: + case MySqlParser.KW_WITH: + case MySqlParser.KW_BEGIN: + case MySqlParser.KW_BINLOG: + case MySqlParser.KW_CACHE: + case MySqlParser.KW_CHECKSUM: + case MySqlParser.KW_COALESCE: + case MySqlParser.KW_COMMIT: + case MySqlParser.KW_DEALLOCATE: + case MySqlParser.KW_DISCARD: + case MySqlParser.KW_DO: + case MySqlParser.KW_EXCHANGE: + case MySqlParser.KW_FLUSH: + case MySqlParser.KW_HANDLER: + case MySqlParser.KW_HELP: + case MySqlParser.KW_IMPORT: + case MySqlParser.KW_INSTALL: + case MySqlParser.KW_PREPARE: + case MySqlParser.KW_REBUILD: + case MySqlParser.KW_REMOVE: + case MySqlParser.KW_REORGANIZE: + case MySqlParser.KW_REPAIR: + case MySqlParser.KW_RESET: + case MySqlParser.KW_RESTART: + case MySqlParser.KW_ROLLBACK: + case MySqlParser.KW_SAVEPOINT: + case MySqlParser.KW_START: + case MySqlParser.KW_STOP: + case MySqlParser.KW_TRUNCATE: + case MySqlParser.KW_UNINSTALL: + case MySqlParser.KW_UPGRADE: + case MySqlParser.KW_XA: + case MySqlParser.KW_CLONE: + case MySqlParser.KW_EXECUTE: + case MySqlParser.KW_SHUTDOWN: + case MySqlParser.LR_BRACKET: + case MySqlParser.COMMA: + case MySqlParser.SEMI: + break; + default: + break; + } + } + break; + case 16: + localContext = new AlterByDefaultCharsetContext(localContext); + this.enterOuterAlt(localContext, 16); + { + this.state = 2803; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 42) { + { + this.state = 2802; + this.match(MySqlParser.KW_DEFAULT); + } + } + this.state = 2805; + this.match(MySqlParser.KW_CHARACTER); + this.state = 2806; + this.match(MySqlParser.KW_SET); + this.state = 2807; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 2808; + this.charsetName(); + this.state = 2814; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 28) { + { + this.state = 2809; + this.match(MySqlParser.KW_COLLATE); + this.state = 2811; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 2810; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 2813; + this.collationName(); + } + } + } + break; + case 17: + localContext = new AlterByConvertCharsetContext(localContext); + this.enterOuterAlt(localContext, 17); + { + this.state = 2816; + this.match(MySqlParser.KW_CONVERT); + this.state = 2817; + this.match(MySqlParser.KW_TO); + this.state = 2821; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_CHARSET: + { + this.state = 2818; + this.match(MySqlParser.KW_CHARSET); + } + break; + case MySqlParser.KW_CHARACTER: + { + this.state = 2819; + this.match(MySqlParser.KW_CHARACTER); + this.state = 2820; + this.match(MySqlParser.KW_SET); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + this.state = 2823; + this.charsetName(); + this.state = 2826; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 28) { + { + this.state = 2824; + this.match(MySqlParser.KW_COLLATE); + this.state = 2825; + this.collationName(); + } + } + } + break; + case 18: + localContext = new AlterKeysContext(localContext); + this.enterOuterAlt(localContext, 18); + { + this.state = 2828; + _la = this.tokenStream.LA(1); + if (!(_la === 368 || _la === 375)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 2829; + this.match(MySqlParser.KW_KEYS); + } + break; + case 19: + localContext = new AlterTablespaceOptionContext(localContext); + this.enterOuterAlt(localContext, 19); + { + this.state = 2830; + _la = this.tokenStream.LA(1); + if (!(_la === 369 || _la === 425)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 2831; + this.match(MySqlParser.KW_TABLESPACE); + } + break; + case 20: + localContext = new AlterByDropColumnContext(localContext); + this.enterOuterAlt(localContext, 20); + { + this.state = 2832; + this.match(MySqlParser.KW_DROP); + this.state = 2834; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 343, this.context)) { + case 1: + { + this.state = 2833; + this.match(MySqlParser.KW_COLUMN); + } + break; + } + this.state = 2836; + this.columnName(); + } + break; + case 21: + localContext = new AlterByDropIndexContext(localContext); + this.enterOuterAlt(localContext, 21); + { + this.state = 2837; + this.match(MySqlParser.KW_DROP); + this.state = 2838; + _la = this.tokenStream.LA(1); + if (!(_la === 82 || _la === 92)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 2839; + this.indexName(); + } + break; + case 22: + localContext = new AlterByDropPrimaryKeyContext(localContext); + this.enterOuterAlt(localContext, 22); + { + this.state = 2840; + this.match(MySqlParser.KW_DROP); + this.state = 2841; + this.match(MySqlParser.KW_PRIMARY); + this.state = 2842; + this.match(MySqlParser.KW_KEY); + } + break; + case 23: + localContext = new AlterByDropForeignKeyContext(localContext); + this.enterOuterAlt(localContext, 23); + { + this.state = 2843; + this.match(MySqlParser.KW_DROP); + this.state = 2844; + this.match(MySqlParser.KW_FOREIGN); + this.state = 2845; + this.match(MySqlParser.KW_KEY); + this.state = 2846; + localContext._fk_symbol = this.uid(); + } + break; + case 24: + localContext = new AlterByForceContext(localContext); + this.enterOuterAlt(localContext, 24); + { + this.state = 2847; + this.match(MySqlParser.KW_FORCE); + } + break; + case 25: + localContext = new AlterByLockContext(localContext); + this.enterOuterAlt(localContext, 25); + { + this.state = 2848; + this.match(MySqlParser.KW_LOCK); + this.state = 2850; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 2849; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 2852; + localContext._lockType = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 42 || _la === 389 || _la === 505 || _la === 595)) { + localContext._lockType = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + break; + case 26: + localContext = new AlterByModifyColumnContext(localContext); + this.enterOuterAlt(localContext, 26); + { + this.state = 2853; + this.match(MySqlParser.KW_MODIFY); + this.state = 2855; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 345, this.context)) { + case 1: + { + this.state = 2854; + this.match(MySqlParser.KW_COLUMN); + } + break; + } + this.state = 2857; + this.columnName(); + this.state = 2858; + this.columnDefinition(); + this.state = 2862; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_FIRST: + { + this.state = 2859; + this.match(MySqlParser.KW_FIRST); + } + break; + case MySqlParser.KW_AFTER: + { + this.state = 2860; + this.match(MySqlParser.KW_AFTER); + this.state = 2861; + this.columnName(); + } + break; + case MySqlParser.EOF: + case MySqlParser.KW_ADD: + case MySqlParser.KW_ALTER: + case MySqlParser.KW_ANALYZE: + case MySqlParser.KW_CALL: + case MySqlParser.KW_CHANGE: + case MySqlParser.KW_CHECK: + case MySqlParser.KW_CREATE: + case MySqlParser.KW_DELETE: + case MySqlParser.KW_DESC: + case MySqlParser.KW_DESCRIBE: + case MySqlParser.KW_DROP: + case MySqlParser.KW_EXPLAIN: + case MySqlParser.KW_GET: + case MySqlParser.KW_GRANT: + case MySqlParser.KW_INSERT: + case MySqlParser.KW_KILL: + case MySqlParser.KW_LOAD: + case MySqlParser.KW_LOCK: + case MySqlParser.KW_OPTIMIZE: + case MySqlParser.KW_PURGE: + case MySqlParser.KW_RELEASE: + case MySqlParser.KW_RENAME: + case MySqlParser.KW_REPLACE: + case MySqlParser.KW_RESIGNAL: + case MySqlParser.KW_REVOKE: + case MySqlParser.KW_SELECT: + case MySqlParser.KW_SET: + case MySqlParser.KW_SHOW: + case MySqlParser.KW_SIGNAL: + case MySqlParser.KW_TABLE: + case MySqlParser.KW_UNLOCK: + case MySqlParser.KW_UPDATE: + case MySqlParser.KW_USE: + case MySqlParser.KW_VALUES: + case MySqlParser.KW_WITH: + case MySqlParser.KW_BEGIN: + case MySqlParser.KW_BINLOG: + case MySqlParser.KW_CACHE: + case MySqlParser.KW_CHECKSUM: + case MySqlParser.KW_COALESCE: + case MySqlParser.KW_COMMIT: + case MySqlParser.KW_DEALLOCATE: + case MySqlParser.KW_DISCARD: + case MySqlParser.KW_DO: + case MySqlParser.KW_EXCHANGE: + case MySqlParser.KW_FLUSH: + case MySqlParser.KW_HANDLER: + case MySqlParser.KW_HELP: + case MySqlParser.KW_IMPORT: + case MySqlParser.KW_INSTALL: + case MySqlParser.KW_PREPARE: + case MySqlParser.KW_REBUILD: + case MySqlParser.KW_REMOVE: + case MySqlParser.KW_REORGANIZE: + case MySqlParser.KW_REPAIR: + case MySqlParser.KW_RESET: + case MySqlParser.KW_RESTART: + case MySqlParser.KW_ROLLBACK: + case MySqlParser.KW_SAVEPOINT: + case MySqlParser.KW_START: + case MySqlParser.KW_STOP: + case MySqlParser.KW_TRUNCATE: + case MySqlParser.KW_UNINSTALL: + case MySqlParser.KW_UPGRADE: + case MySqlParser.KW_XA: + case MySqlParser.KW_CLONE: + case MySqlParser.KW_EXECUTE: + case MySqlParser.KW_SHUTDOWN: + case MySqlParser.LR_BRACKET: + case MySqlParser.COMMA: + case MySqlParser.SEMI: + break; + default: + break; + } + } + break; + case 27: + localContext = new AlterByOrderContext(localContext); + this.enterOuterAlt(localContext, 27); + { + this.state = 2864; + this.match(MySqlParser.KW_ORDER); + this.state = 2865; + this.match(MySqlParser.KW_BY); + this.state = 2866; + this.columnNames(); + } + break; + case 28: + localContext = new AlterByRenameColumnContext(localContext); + this.enterOuterAlt(localContext, 28); + { + this.state = 2867; + this.match(MySqlParser.KW_RENAME); + this.state = 2868; + this.match(MySqlParser.KW_COLUMN); + this.state = 2869; + localContext._olcdColumn = this.columnName(); + this.state = 2870; + this.match(MySqlParser.KW_TO); + this.state = 2871; + localContext._newColumn = this.columnNameCreate(); + } + break; + case 29: + localContext = new AlterByRenameIndexContext(localContext); + this.enterOuterAlt(localContext, 29); + { + this.state = 2873; + this.match(MySqlParser.KW_RENAME); + this.state = 2874; + localContext._indexFormat = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 82 || _la === 92)) { + localContext._indexFormat = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 2875; + this.indexName(); + this.state = 2876; + this.match(MySqlParser.KW_TO); + this.state = 2877; + this.indexNameCreate(); + } + break; + case 30: + localContext = new AlterByRenameContext(localContext); + this.enterOuterAlt(localContext, 30); + { + this.state = 2879; + this.match(MySqlParser.KW_RENAME); + this.state = 2881; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 13 || _la === 176) { + { + this.state = 2880; + localContext._renameFormat = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 13 || _la === 176)) { + localContext._renameFormat = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + this.state = 2883; + this.tableNameCreate(); + } + break; + case 31: + localContext = new AlterByValidateContext(localContext); + this.enterOuterAlt(localContext, 31); + { + this.state = 2884; + _la = this.tokenStream.LA(1); + if (!(_la === 194 || _la === 690)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 2885; + this.match(MySqlParser.KW_VALIDATION); + } + break; + case 32: + localContext = new AlterPartitionContext(localContext); + this.enterOuterAlt(localContext, 32); + { + this.state = 2886; + this.alterPartitionSpecification(); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + alterPartitionSpecification() { + let localContext = new AlterPartitionSpecificationContext(this.context, this.state); + this.enterRule(localContext, 142, MySqlParser.RULE_alterPartitionSpecification); + let _la; + try { + this.state = 2987; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_ADD: + localContext = new AlterByAddPartitionContext(localContext); + this.enterOuterAlt(localContext, 1); + { + this.state = 2889; + this.match(MySqlParser.KW_ADD); + this.state = 2890; + this.match(MySqlParser.KW_PARTITION); + this.state = 2891; + this.match(MySqlParser.LR_BRACKET); + this.state = 2892; + this.partitionDefinition(); + this.state = 2897; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 2893; + this.match(MySqlParser.COMMA); + this.state = 2894; + this.partitionDefinition(); + } + } + this.state = 2899; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 2900; + this.match(MySqlParser.RR_BRACKET); + } + break; + case MySqlParser.KW_DROP: + localContext = new AlterByDropPartitionContext(localContext); + this.enterOuterAlt(localContext, 2); + { + this.state = 2902; + this.match(MySqlParser.KW_DROP); + this.state = 2903; + this.match(MySqlParser.KW_PARTITION); + this.state = 2904; + this.partitionNames(); + } + break; + case MySqlParser.KW_DISCARD: + localContext = new AlterByDiscardPartitionContext(localContext); + this.enterOuterAlt(localContext, 3); + { + this.state = 2905; + this.match(MySqlParser.KW_DISCARD); + this.state = 2906; + this.match(MySqlParser.KW_PARTITION); + this.state = 2909; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_ARRAY: + case MySqlParser.KW_ATTRIBUTE: + case MySqlParser.KW_BUCKETS: + case MySqlParser.KW_CONDITION: + case MySqlParser.KW_CURRENT: + case MySqlParser.KW_CURRENT_USER: + case MySqlParser.KW_DATABASE: + case MySqlParser.KW_DEFAULT: + case MySqlParser.KW_DIAGNOSTICS: + case MySqlParser.KW_EMPTY: + case MySqlParser.KW_ENFORCED: + case MySqlParser.KW_EXCEPT: + case MySqlParser.KW_GROUP: + case MySqlParser.KW_IF: + case MySqlParser.KW_INSERT: + case MySqlParser.KW_LATERAL: + case MySqlParser.KW_LEFT: + case MySqlParser.KW_NUMBER: + case MySqlParser.KW_OPTIONAL: + case MySqlParser.KW_ORDER: + case MySqlParser.KW_PRIMARY: + case MySqlParser.KW_REPEAT: + case MySqlParser.KW_REPLACE: + case MySqlParser.KW_RIGHT: + case MySqlParser.KW_SCHEMA: + case MySqlParser.KW_SKIP_QUERY_REWRITE: + case MySqlParser.KW_STACKED: + case MySqlParser.KW_DATE: + case MySqlParser.KW_TIME: + case MySqlParser.KW_TIMESTAMP: + case MySqlParser.KW_DATETIME: + case MySqlParser.KW_YEAR: + case MySqlParser.KW_BINARY: + case MySqlParser.KW_TEXT: + case MySqlParser.KW_ENUM: + case MySqlParser.KW_SERIAL: + case MySqlParser.KW_JSON_TABLE: + case MySqlParser.KW_JSON_VALUE: + case MySqlParser.KW_NESTED: + case MySqlParser.KW_ORDINALITY: + case MySqlParser.KW_PATH: + case MySqlParser.KW_AVG: + case MySqlParser.KW_BIT_AND: + case MySqlParser.KW_BIT_OR: + case MySqlParser.KW_BIT_XOR: + case MySqlParser.KW_COUNT: + case MySqlParser.KW_CUME_DIST: + case MySqlParser.KW_DENSE_RANK: + case MySqlParser.KW_FIRST_VALUE: + case MySqlParser.KW_GROUP_CONCAT: + case MySqlParser.KW_LAG: + case MySqlParser.KW_LAST_VALUE: + case MySqlParser.KW_LEAD: + case MySqlParser.KW_MAX: + case MySqlParser.KW_MIN: + case MySqlParser.KW_NTILE: + case MySqlParser.KW_NTH_VALUE: + case MySqlParser.KW_PERCENT_RANK: + case MySqlParser.KW_RANK: + case MySqlParser.KW_ROW_NUMBER: + case MySqlParser.KW_STD: + case MySqlParser.KW_STDDEV: + case MySqlParser.KW_STDDEV_POP: + case MySqlParser.KW_STDDEV_SAMP: + case MySqlParser.KW_SUM: + case MySqlParser.KW_VAR_POP: + case MySqlParser.KW_VAR_SAMP: + case MySqlParser.KW_VARIANCE: + case MySqlParser.KW_CURRENT_DATE: + case MySqlParser.KW_CURRENT_TIME: + case MySqlParser.KW_CURRENT_TIMESTAMP: + case MySqlParser.KW_LOCALTIME: + case MySqlParser.KW_CURDATE: + case MySqlParser.KW_CURTIME: + case MySqlParser.KW_DATE_ADD: + case MySqlParser.KW_DATE_SUB: + case MySqlParser.KW_LOCALTIMESTAMP: + case MySqlParser.KW_NOW: + case MySqlParser.KW_POSITION: + case MySqlParser.KW_SUBSTR: + case MySqlParser.KW_SUBSTRING: + case MySqlParser.KW_SYSDATE: + case MySqlParser.KW_TRIM: + case MySqlParser.KW_UTC_DATE: + case MySqlParser.KW_UTC_TIME: + case MySqlParser.KW_UTC_TIMESTAMP: + case MySqlParser.KW_ACCOUNT: + case MySqlParser.KW_ACTION: + case MySqlParser.KW_AFTER: + case MySqlParser.KW_AGGREGATE: + case MySqlParser.KW_ALGORITHM: + case MySqlParser.KW_ANY: + case MySqlParser.KW_AT: + case MySqlParser.KW_AUTHORS: + case MySqlParser.KW_AUTOCOMMIT: + case MySqlParser.KW_AUTOEXTEND_SIZE: + case MySqlParser.KW_AUTO_INCREMENT: + case MySqlParser.KW_AVG_ROW_LENGTH: + case MySqlParser.KW_BEGIN: + case MySqlParser.KW_BINLOG: + case MySqlParser.KW_BIT: + case MySqlParser.KW_BLOCK: + case MySqlParser.KW_BOOL: + case MySqlParser.KW_BOOLEAN: + case MySqlParser.KW_BTREE: + case MySqlParser.KW_CACHE: + case MySqlParser.KW_CASCADED: + case MySqlParser.KW_CHAIN: + case MySqlParser.KW_CHANGED: + case MySqlParser.KW_CHANNEL: + case MySqlParser.KW_CHECKSUM: + case MySqlParser.KW_CIPHER: + case MySqlParser.KW_CLASS_ORIGIN: + case MySqlParser.KW_CLIENT: + case MySqlParser.KW_CLOSE: + case MySqlParser.KW_COALESCE: + case MySqlParser.KW_CODE: + case MySqlParser.KW_COLUMNS: + case MySqlParser.KW_COLUMN_FORMAT: + case MySqlParser.KW_COLUMN_NAME: + case MySqlParser.KW_COMMENT: + case MySqlParser.KW_COMMIT: + case MySqlParser.KW_COMPACT: + case MySqlParser.KW_COMPLETION: + case MySqlParser.KW_COMPRESSED: + case MySqlParser.KW_COMPRESSION: + case MySqlParser.KW_CONCURRENT: + case MySqlParser.KW_CONNECT: + case MySqlParser.KW_CONNECTION: + case MySqlParser.KW_CONSISTENT: + case MySqlParser.KW_CONSTRAINT_CATALOG: + case MySqlParser.KW_CONSTRAINT_SCHEMA: + case MySqlParser.KW_CONSTRAINT_NAME: + case MySqlParser.KW_CONTAINS: + case MySqlParser.KW_CONTEXT: + case MySqlParser.KW_CONTRIBUTORS: + case MySqlParser.KW_COPY: + case MySqlParser.KW_CPU: + case MySqlParser.KW_CURSOR_NAME: + case MySqlParser.KW_DATA: + case MySqlParser.KW_DATAFILE: + case MySqlParser.KW_DEALLOCATE: + case MySqlParser.KW_DEFAULT_AUTH: + case MySqlParser.KW_DEFINER: + case MySqlParser.KW_DELAY_KEY_WRITE: + case MySqlParser.KW_DES_KEY_FILE: + case MySqlParser.KW_DIRECTORY: + case MySqlParser.KW_DISABLE: + case MySqlParser.KW_DISCARD: + case MySqlParser.KW_DISK: + case MySqlParser.KW_DO: + case MySqlParser.KW_DUMPFILE: + case MySqlParser.KW_DUPLICATE: + case MySqlParser.KW_DYNAMIC: + case MySqlParser.KW_ENABLE: + case MySqlParser.KW_ENCRYPTION: + case MySqlParser.KW_END: + case MySqlParser.KW_ENDS: + case MySqlParser.KW_ENGINE: + case MySqlParser.KW_ENGINES: + case MySqlParser.KW_ERROR: + case MySqlParser.KW_ERRORS: + case MySqlParser.KW_ESCAPE: + case MySqlParser.KW_EVENT: + case MySqlParser.KW_EVENTS: + case MySqlParser.KW_EVERY: + case MySqlParser.KW_EXCHANGE: + case MySqlParser.KW_EXCLUSIVE: + case MySqlParser.KW_EXPIRE: + case MySqlParser.KW_EXPORT: + case MySqlParser.KW_EXTENDED: + case MySqlParser.KW_EXTENT_SIZE: + case MySqlParser.KW_FAILED_LOGIN_ATTEMPTS: + case MySqlParser.KW_FAST: + case MySqlParser.KW_FAULTS: + case MySqlParser.KW_FIELDS: + case MySqlParser.KW_FILE_BLOCK_SIZE: + case MySqlParser.KW_FILTER: + case MySqlParser.KW_FIRST: + case MySqlParser.KW_FIXED: + case MySqlParser.KW_FLUSH: + case MySqlParser.KW_FOLLOWS: + case MySqlParser.KW_FOUND: + case MySqlParser.KW_FULL: + case MySqlParser.KW_FUNCTION: + case MySqlParser.KW_GENERAL: + case MySqlParser.KW_GLOBAL: + case MySqlParser.KW_GRANTS: + case MySqlParser.KW_GROUP_REPLICATION: + case MySqlParser.KW_HANDLER: + case MySqlParser.KW_HASH: + case MySqlParser.KW_HELP: + case MySqlParser.KW_HISTORY: + case MySqlParser.KW_HOST: + case MySqlParser.KW_HOSTS: + case MySqlParser.KW_IDENTIFIED: + case MySqlParser.KW_IGNORE_SERVER_IDS: + case MySqlParser.KW_IMPORT: + case MySqlParser.KW_INDEXES: + case MySqlParser.KW_INITIAL_SIZE: + case MySqlParser.KW_INPLACE: + case MySqlParser.KW_INSERT_METHOD: + case MySqlParser.KW_INSTALL: + case MySqlParser.KW_INSTANCE: + case MySqlParser.KW_INSTANT: + case MySqlParser.KW_INVISIBLE: + case MySqlParser.KW_INVOKER: + case MySqlParser.KW_IO: + case MySqlParser.KW_IO_THREAD: + case MySqlParser.KW_IPC: + case MySqlParser.KW_ISOLATION: + case MySqlParser.KW_ISSUER: + case MySqlParser.KW_JSON: + case MySqlParser.KW_KEY_BLOCK_SIZE: + case MySqlParser.KW_LANGUAGE: + case MySqlParser.KW_LAST: + case MySqlParser.KW_LEAVES: + case MySqlParser.KW_LESS: + case MySqlParser.KW_LEVEL: + case MySqlParser.KW_LIST: + case MySqlParser.KW_LOCAL: + case MySqlParser.KW_LOGFILE: + case MySqlParser.KW_LOGS: + case MySqlParser.KW_MASTER: + case MySqlParser.KW_MASTER_AUTO_POSITION: + case MySqlParser.KW_MASTER_CONNECT_RETRY: + case MySqlParser.KW_MASTER_DELAY: + case MySqlParser.KW_MASTER_HEARTBEAT_PERIOD: + case MySqlParser.KW_MASTER_HOST: + case MySqlParser.KW_MASTER_LOG_FILE: + case MySqlParser.KW_MASTER_LOG_POS: + case MySqlParser.KW_MASTER_PASSWORD: + case MySqlParser.KW_MASTER_PORT: + case MySqlParser.KW_MASTER_RETRY_COUNT: + case MySqlParser.KW_MASTER_SSL: + case MySqlParser.KW_MASTER_SSL_CA: + case MySqlParser.KW_MASTER_SSL_CAPATH: + case MySqlParser.KW_MASTER_SSL_CERT: + case MySqlParser.KW_MASTER_SSL_CIPHER: + case MySqlParser.KW_MASTER_SSL_CRL: + case MySqlParser.KW_MASTER_SSL_CRLPATH: + case MySqlParser.KW_MASTER_SSL_KEY: + case MySqlParser.KW_MASTER_TLS_VERSION: + case MySqlParser.KW_MASTER_USER: + case MySqlParser.KW_MAX_CONNECTIONS_PER_HOUR: + case MySqlParser.KW_MAX_QUERIES_PER_HOUR: + case MySqlParser.KW_MAX_ROWS: + case MySqlParser.KW_MAX_SIZE: + case MySqlParser.KW_MAX_UPDATES_PER_HOUR: + case MySqlParser.KW_MAX_USER_CONNECTIONS: + case MySqlParser.KW_MEDIUM: + case MySqlParser.KW_MEMBER: + case MySqlParser.KW_MERGE: + case MySqlParser.KW_MESSAGE_TEXT: + case MySqlParser.KW_MID: + case MySqlParser.KW_MIGRATE: + case MySqlParser.KW_MIN_ROWS: + case MySqlParser.KW_MODE: + case MySqlParser.KW_MODIFY: + case MySqlParser.KW_MUTEX: + case MySqlParser.KW_MYSQL: + case MySqlParser.KW_MYSQL_ERRNO: + case MySqlParser.KW_NAME: + case MySqlParser.KW_NAMES: + case MySqlParser.KW_NCHAR: + case MySqlParser.KW_NEVER: + case MySqlParser.KW_NEXT: + case MySqlParser.KW_NO: + case MySqlParser.KW_NOWAIT: + case MySqlParser.KW_NODEGROUP: + case MySqlParser.KW_NONE: + case MySqlParser.KW_ODBC: + case MySqlParser.KW_OFFLINE: + case MySqlParser.KW_OFFSET: + case MySqlParser.KW_OF: + case MySqlParser.KW_OLD_PASSWORD: + case MySqlParser.KW_ONE: + case MySqlParser.KW_ONLINE: + case MySqlParser.KW_ONLY: + case MySqlParser.KW_OPEN: + case MySqlParser.KW_OPTIMIZER_COSTS: + case MySqlParser.KW_OPTIONS: + case MySqlParser.KW_OWNER: + case MySqlParser.KW_PACK_KEYS: + case MySqlParser.KW_PAGE: + case MySqlParser.KW_PAGE_CHECKSUM: + case MySqlParser.KW_PARSER: + case MySqlParser.KW_PARTIAL: + case MySqlParser.KW_PARTITIONING: + case MySqlParser.KW_PARTITIONS: + case MySqlParser.KW_PASSWORD: + case MySqlParser.KW_PASSWORD_LOCK_TIME: + case MySqlParser.KW_PHASE: + case MySqlParser.KW_PLUGIN: + case MySqlParser.KW_PLUGIN_DIR: + case MySqlParser.KW_PLUGINS: + case MySqlParser.KW_PORT: + case MySqlParser.KW_PRECEDES: + case MySqlParser.KW_PREPARE: + case MySqlParser.KW_PRESERVE: + case MySqlParser.KW_PREV: + case MySqlParser.KW_PROCESSLIST: + case MySqlParser.KW_PROFILE: + case MySqlParser.KW_PROFILES: + case MySqlParser.KW_PROXY: + case MySqlParser.KW_QUERY: + case MySqlParser.KW_QUICK: + case MySqlParser.KW_REBUILD: + case MySqlParser.KW_RECOVER: + case MySqlParser.KW_RECURSIVE: + case MySqlParser.KW_REDO_BUFFER_SIZE: + case MySqlParser.KW_REDUNDANT: + case MySqlParser.KW_RELAY: + case MySqlParser.KW_RELAY_LOG_FILE: + case MySqlParser.KW_RELAY_LOG_POS: + case MySqlParser.KW_RELAYLOG: + case MySqlParser.KW_REMOVE: + case MySqlParser.KW_REORGANIZE: + case MySqlParser.KW_REPAIR: + case MySqlParser.KW_REPLICATE_DO_DB: + case MySqlParser.KW_REPLICATE_DO_TABLE: + case MySqlParser.KW_REPLICATE_IGNORE_DB: + case MySqlParser.KW_REPLICATE_IGNORE_TABLE: + case MySqlParser.KW_REPLICATE_REWRITE_DB: + case MySqlParser.KW_REPLICATE_WILD_DO_TABLE: + case MySqlParser.KW_REPLICATE_WILD_IGNORE_TABLE: + case MySqlParser.KW_REPLICATION: + case MySqlParser.KW_RESET: + case MySqlParser.KW_RESUME: + case MySqlParser.KW_RETURNED_SQLSTATE: + case MySqlParser.KW_RETURNS: + case MySqlParser.KW_REUSE: + case MySqlParser.KW_ROLE: + case MySqlParser.KW_ROLLBACK: + case MySqlParser.KW_ROLLUP: + case MySqlParser.KW_ROTATE: + case MySqlParser.KW_ROW: + case MySqlParser.KW_ROWS: + case MySqlParser.KW_ROW_FORMAT: + case MySqlParser.KW_SAVEPOINT: + case MySqlParser.KW_SCHEDULE: + case MySqlParser.KW_SECURITY: + case MySqlParser.KW_SERVER: + case MySqlParser.KW_SESSION: + case MySqlParser.KW_SHARE: + case MySqlParser.KW_SHARED: + case MySqlParser.KW_SIGNED: + case MySqlParser.KW_SIMPLE: + case MySqlParser.KW_SLAVE: + case MySqlParser.KW_SLOW: + case MySqlParser.KW_SNAPSHOT: + case MySqlParser.KW_SOCKET: + case MySqlParser.KW_SOME: + case MySqlParser.KW_SONAME: + case MySqlParser.KW_SOUNDS: + case MySqlParser.KW_SOURCE: + case MySqlParser.KW_SQL_AFTER_GTIDS: + case MySqlParser.KW_SQL_AFTER_MTS_GAPS: + case MySqlParser.KW_SQL_BEFORE_GTIDS: + case MySqlParser.KW_SQL_BUFFER_RESULT: + case MySqlParser.KW_SQL_CACHE: + case MySqlParser.KW_SQL_NO_CACHE: + case MySqlParser.KW_SQL_THREAD: + case MySqlParser.KW_START: + case MySqlParser.KW_STARTS: + case MySqlParser.KW_STATS_AUTO_RECALC: + case MySqlParser.KW_STATS_PERSISTENT: + case MySqlParser.KW_STATS_SAMPLE_PAGES: + case MySqlParser.KW_STATUS: + case MySqlParser.KW_STOP: + case MySqlParser.KW_STORAGE: + case MySqlParser.KW_STRING: + case MySqlParser.KW_SUBCLASS_ORIGIN: + case MySqlParser.KW_SUBJECT: + case MySqlParser.KW_SUBPARTITION: + case MySqlParser.KW_SUBPARTITIONS: + case MySqlParser.KW_SUSPEND: + case MySqlParser.KW_SWAPS: + case MySqlParser.KW_SWITCHES: + case MySqlParser.KW_TABLE_NAME: + case MySqlParser.KW_TABLESPACE: + case MySqlParser.KW_TABLE_TYPE: + case MySqlParser.KW_TEMPORARY: + case MySqlParser.KW_TEMPTABLE: + case MySqlParser.KW_THAN: + case MySqlParser.KW_TRADITIONAL: + case MySqlParser.KW_TRANSACTION: + case MySqlParser.KW_TRANSACTIONAL: + case MySqlParser.KW_TRIGGERS: + case MySqlParser.KW_TRUNCATE: + case MySqlParser.KW_UNBOUNDED: + case MySqlParser.KW_UNDEFINED: + case MySqlParser.KW_UNDOFILE: + case MySqlParser.KW_UNDO_BUFFER_SIZE: + case MySqlParser.KW_UNINSTALL: + case MySqlParser.KW_UNKNOWN: + case MySqlParser.KW_UNTIL: + case MySqlParser.KW_UPGRADE: + case MySqlParser.KW_USER: + case MySqlParser.KW_USE_FRM: + case MySqlParser.KW_USER_RESOURCES: + case MySqlParser.KW_VALIDATION: + case MySqlParser.KW_VALUE: + case MySqlParser.KW_VARIABLES: + case MySqlParser.KW_VIEW: + case MySqlParser.KW_VIRTUAL: + case MySqlParser.KW_VISIBLE: + case MySqlParser.KW_WAIT: + case MySqlParser.KW_WARNINGS: + case MySqlParser.KW_WITHOUT: + case MySqlParser.KW_WORK: + case MySqlParser.KW_WRAPPER: + case MySqlParser.KW_X509: + case MySqlParser.KW_XA: + case MySqlParser.KW_XML: + case MySqlParser.KW_QUARTER: + case MySqlParser.KW_MONTH: + case MySqlParser.KW_DAY: + case MySqlParser.KW_HOUR: + case MySqlParser.KW_MINUTE: + case MySqlParser.KW_WEEK: + case MySqlParser.KW_SECOND: + case MySqlParser.KW_MICROSECOND: + case MySqlParser.KW_ADMIN: + case MySqlParser.KW_AUDIT_ABORT_EXEMPT: + case MySqlParser.KW_AUDIT_ADMIN: + case MySqlParser.KW_AUTHENTICATION_POLICY_ADMIN: + case MySqlParser.KW_BACKUP_ADMIN: + case MySqlParser.KW_BINLOG_ADMIN: + case MySqlParser.KW_BINLOG_ENCRYPTION_ADMIN: + case MySqlParser.KW_CLONE_ADMIN: + case MySqlParser.KW_CONNECTION_ADMIN: + case MySqlParser.KW_ENCRYPTION_KEY_ADMIN: + case MySqlParser.KW_EXECUTE: + case MySqlParser.KW_FILE: + case MySqlParser.KW_FIREWALL_ADMIN: + case MySqlParser.KW_FIREWALL_EXEMPT: + case MySqlParser.KW_FIREWALL_USER: + case MySqlParser.KW_GROUP_REPLICATION_ADMIN: + case MySqlParser.KW_INNODB_REDO_LOG_ARCHIVE: + case MySqlParser.KW_INVOKE: + case MySqlParser.KW_LAMBDA: + case MySqlParser.KW_NDB_STORED_USER: + case MySqlParser.KW_PASSWORDLESS_USER_ADMIN: + case MySqlParser.KW_PERSIST_RO_VARIABLES_ADMIN: + case MySqlParser.KW_PRIVILEGES: + case MySqlParser.KW_PROCESS: + case MySqlParser.KW_RELOAD: + case MySqlParser.KW_REPLICATION_APPLIER: + case MySqlParser.KW_REPLICATION_SLAVE_ADMIN: + case MySqlParser.KW_RESOURCE_GROUP_ADMIN: + case MySqlParser.KW_RESOURCE_GROUP_USER: + case MySqlParser.KW_ROLE_ADMIN: + case MySqlParser.KW_ROUTINE: + case MySqlParser.KW_S3: + case MySqlParser.KW_SESSION_VARIABLES_ADMIN: + case MySqlParser.KW_SET_USER_ID: + case MySqlParser.KW_SHOW_ROUTINE: + case MySqlParser.KW_SHUTDOWN: + case MySqlParser.KW_SUPER: + case MySqlParser.KW_SYSTEM_VARIABLES_ADMIN: + case MySqlParser.KW_TABLES: + case MySqlParser.KW_TABLE_ENCRYPTION_ADMIN: + case MySqlParser.KW_VERSION_TOKEN_ADMIN: + case MySqlParser.KW_XA_RECOVER_ADMIN: + case MySqlParser.KW_ARMSCII8: + case MySqlParser.KW_ASCII: + case MySqlParser.KW_BIG5: + case MySqlParser.KW_CP1250: + case MySqlParser.KW_CP1251: + case MySqlParser.KW_CP1256: + case MySqlParser.KW_CP1257: + case MySqlParser.KW_CP850: + case MySqlParser.KW_CP852: + case MySqlParser.KW_CP866: + case MySqlParser.KW_CP932: + case MySqlParser.KW_DEC8: + case MySqlParser.KW_EUCJPMS: + case MySqlParser.KW_EUCKR: + case MySqlParser.KW_GB18030: + case MySqlParser.KW_GB2312: + case MySqlParser.KW_GBK: + case MySqlParser.KW_GEOSTD8: + case MySqlParser.KW_GREEK: + case MySqlParser.KW_HEBREW: + case MySqlParser.KW_HP8: + case MySqlParser.KW_KEYBCS2: + case MySqlParser.KW_KOI8R: + case MySqlParser.KW_KOI8U: + case MySqlParser.KW_LATIN1: + case MySqlParser.KW_LATIN2: + case MySqlParser.KW_LATIN5: + case MySqlParser.KW_LATIN7: + case MySqlParser.KW_MACCE: + case MySqlParser.KW_MACROMAN: + case MySqlParser.KW_SJIS: + case MySqlParser.KW_SWE7: + case MySqlParser.KW_TIS620: + case MySqlParser.KW_UCS2: + case MySqlParser.KW_UJIS: + case MySqlParser.KW_UTF16: + case MySqlParser.KW_UTF16LE: + case MySqlParser.KW_UTF32: + case MySqlParser.KW_UTF8: + case MySqlParser.KW_UTF8MB3: + case MySqlParser.KW_UTF8MB4: + case MySqlParser.KW_ARCHIVE: + case MySqlParser.KW_BLACKHOLE: + case MySqlParser.KW_CSV: + case MySqlParser.KW_FEDERATED: + case MySqlParser.KW_INNODB: + case MySqlParser.KW_MEMORY: + case MySqlParser.KW_MRG_MYISAM: + case MySqlParser.KW_MYISAM: + case MySqlParser.KW_NDB: + case MySqlParser.KW_NDBCLUSTER: + case MySqlParser.KW_PERFORMANCE_SCHEMA: + case MySqlParser.KW_TOKUDB: + case MySqlParser.KW_REPEATABLE: + case MySqlParser.KW_COMMITTED: + case MySqlParser.KW_UNCOMMITTED: + case MySqlParser.KW_SERIALIZABLE: + case MySqlParser.KW_GEOMETRYCOLLECTION: + case MySqlParser.KW_LINESTRING: + case MySqlParser.KW_MULTILINESTRING: + case MySqlParser.KW_MULTIPOINT: + case MySqlParser.KW_MULTIPOLYGON: + case MySqlParser.KW_POINT: + case MySqlParser.KW_POLYGON: + case MySqlParser.KW_CATALOG_NAME: + case MySqlParser.KW_CHARSET: + case MySqlParser.KW_COLLATION: + case MySqlParser.KW_ENGINE_ATTRIBUTE: + case MySqlParser.KW_FORMAT: + case MySqlParser.KW_GET_FORMAT: + case MySqlParser.KW_RANDOM: + case MySqlParser.KW_REVERSE: + case MySqlParser.KW_ROW_COUNT: + case MySqlParser.KW_SCHEMA_NAME: + case MySqlParser.KW_SECONDARY_ENGINE_ATTRIBUTE: + case MySqlParser.KW_SRID: + case MySqlParser.KW_SYSTEM_USER: + case MySqlParser.KW_TP_CONNECTION_ADMIN: + case MySqlParser.KW_WEIGHT_STRING: + case MySqlParser.MOD: + case MySqlParser.CHARSET_REVERSE_QOUTE_STRING: + case MySqlParser.STRING_LITERAL: + case MySqlParser.ID: + { + this.state = 2907; + this.partitionNames(); + } + break; + case MySqlParser.KW_ALL: + { + this.state = 2908; + this.match(MySqlParser.KW_ALL); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + this.state = 2911; + this.match(MySqlParser.KW_TABLESPACE); + } + break; + case MySqlParser.KW_IMPORT: + localContext = new AlterByImportPartitionContext(localContext); + this.enterOuterAlt(localContext, 4); + { + this.state = 2912; + this.match(MySqlParser.KW_IMPORT); + this.state = 2913; + this.match(MySqlParser.KW_PARTITION); + this.state = 2916; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_ARRAY: + case MySqlParser.KW_ATTRIBUTE: + case MySqlParser.KW_BUCKETS: + case MySqlParser.KW_CONDITION: + case MySqlParser.KW_CURRENT: + case MySqlParser.KW_CURRENT_USER: + case MySqlParser.KW_DATABASE: + case MySqlParser.KW_DEFAULT: + case MySqlParser.KW_DIAGNOSTICS: + case MySqlParser.KW_EMPTY: + case MySqlParser.KW_ENFORCED: + case MySqlParser.KW_EXCEPT: + case MySqlParser.KW_GROUP: + case MySqlParser.KW_IF: + case MySqlParser.KW_INSERT: + case MySqlParser.KW_LATERAL: + case MySqlParser.KW_LEFT: + case MySqlParser.KW_NUMBER: + case MySqlParser.KW_OPTIONAL: + case MySqlParser.KW_ORDER: + case MySqlParser.KW_PRIMARY: + case MySqlParser.KW_REPEAT: + case MySqlParser.KW_REPLACE: + case MySqlParser.KW_RIGHT: + case MySqlParser.KW_SCHEMA: + case MySqlParser.KW_SKIP_QUERY_REWRITE: + case MySqlParser.KW_STACKED: + case MySqlParser.KW_DATE: + case MySqlParser.KW_TIME: + case MySqlParser.KW_TIMESTAMP: + case MySqlParser.KW_DATETIME: + case MySqlParser.KW_YEAR: + case MySqlParser.KW_BINARY: + case MySqlParser.KW_TEXT: + case MySqlParser.KW_ENUM: + case MySqlParser.KW_SERIAL: + case MySqlParser.KW_JSON_TABLE: + case MySqlParser.KW_JSON_VALUE: + case MySqlParser.KW_NESTED: + case MySqlParser.KW_ORDINALITY: + case MySqlParser.KW_PATH: + case MySqlParser.KW_AVG: + case MySqlParser.KW_BIT_AND: + case MySqlParser.KW_BIT_OR: + case MySqlParser.KW_BIT_XOR: + case MySqlParser.KW_COUNT: + case MySqlParser.KW_CUME_DIST: + case MySqlParser.KW_DENSE_RANK: + case MySqlParser.KW_FIRST_VALUE: + case MySqlParser.KW_GROUP_CONCAT: + case MySqlParser.KW_LAG: + case MySqlParser.KW_LAST_VALUE: + case MySqlParser.KW_LEAD: + case MySqlParser.KW_MAX: + case MySqlParser.KW_MIN: + case MySqlParser.KW_NTILE: + case MySqlParser.KW_NTH_VALUE: + case MySqlParser.KW_PERCENT_RANK: + case MySqlParser.KW_RANK: + case MySqlParser.KW_ROW_NUMBER: + case MySqlParser.KW_STD: + case MySqlParser.KW_STDDEV: + case MySqlParser.KW_STDDEV_POP: + case MySqlParser.KW_STDDEV_SAMP: + case MySqlParser.KW_SUM: + case MySqlParser.KW_VAR_POP: + case MySqlParser.KW_VAR_SAMP: + case MySqlParser.KW_VARIANCE: + case MySqlParser.KW_CURRENT_DATE: + case MySqlParser.KW_CURRENT_TIME: + case MySqlParser.KW_CURRENT_TIMESTAMP: + case MySqlParser.KW_LOCALTIME: + case MySqlParser.KW_CURDATE: + case MySqlParser.KW_CURTIME: + case MySqlParser.KW_DATE_ADD: + case MySqlParser.KW_DATE_SUB: + case MySqlParser.KW_LOCALTIMESTAMP: + case MySqlParser.KW_NOW: + case MySqlParser.KW_POSITION: + case MySqlParser.KW_SUBSTR: + case MySqlParser.KW_SUBSTRING: + case MySqlParser.KW_SYSDATE: + case MySqlParser.KW_TRIM: + case MySqlParser.KW_UTC_DATE: + case MySqlParser.KW_UTC_TIME: + case MySqlParser.KW_UTC_TIMESTAMP: + case MySqlParser.KW_ACCOUNT: + case MySqlParser.KW_ACTION: + case MySqlParser.KW_AFTER: + case MySqlParser.KW_AGGREGATE: + case MySqlParser.KW_ALGORITHM: + case MySqlParser.KW_ANY: + case MySqlParser.KW_AT: + case MySqlParser.KW_AUTHORS: + case MySqlParser.KW_AUTOCOMMIT: + case MySqlParser.KW_AUTOEXTEND_SIZE: + case MySqlParser.KW_AUTO_INCREMENT: + case MySqlParser.KW_AVG_ROW_LENGTH: + case MySqlParser.KW_BEGIN: + case MySqlParser.KW_BINLOG: + case MySqlParser.KW_BIT: + case MySqlParser.KW_BLOCK: + case MySqlParser.KW_BOOL: + case MySqlParser.KW_BOOLEAN: + case MySqlParser.KW_BTREE: + case MySqlParser.KW_CACHE: + case MySqlParser.KW_CASCADED: + case MySqlParser.KW_CHAIN: + case MySqlParser.KW_CHANGED: + case MySqlParser.KW_CHANNEL: + case MySqlParser.KW_CHECKSUM: + case MySqlParser.KW_CIPHER: + case MySqlParser.KW_CLASS_ORIGIN: + case MySqlParser.KW_CLIENT: + case MySqlParser.KW_CLOSE: + case MySqlParser.KW_COALESCE: + case MySqlParser.KW_CODE: + case MySqlParser.KW_COLUMNS: + case MySqlParser.KW_COLUMN_FORMAT: + case MySqlParser.KW_COLUMN_NAME: + case MySqlParser.KW_COMMENT: + case MySqlParser.KW_COMMIT: + case MySqlParser.KW_COMPACT: + case MySqlParser.KW_COMPLETION: + case MySqlParser.KW_COMPRESSED: + case MySqlParser.KW_COMPRESSION: + case MySqlParser.KW_CONCURRENT: + case MySqlParser.KW_CONNECT: + case MySqlParser.KW_CONNECTION: + case MySqlParser.KW_CONSISTENT: + case MySqlParser.KW_CONSTRAINT_CATALOG: + case MySqlParser.KW_CONSTRAINT_SCHEMA: + case MySqlParser.KW_CONSTRAINT_NAME: + case MySqlParser.KW_CONTAINS: + case MySqlParser.KW_CONTEXT: + case MySqlParser.KW_CONTRIBUTORS: + case MySqlParser.KW_COPY: + case MySqlParser.KW_CPU: + case MySqlParser.KW_CURSOR_NAME: + case MySqlParser.KW_DATA: + case MySqlParser.KW_DATAFILE: + case MySqlParser.KW_DEALLOCATE: + case MySqlParser.KW_DEFAULT_AUTH: + case MySqlParser.KW_DEFINER: + case MySqlParser.KW_DELAY_KEY_WRITE: + case MySqlParser.KW_DES_KEY_FILE: + case MySqlParser.KW_DIRECTORY: + case MySqlParser.KW_DISABLE: + case MySqlParser.KW_DISCARD: + case MySqlParser.KW_DISK: + case MySqlParser.KW_DO: + case MySqlParser.KW_DUMPFILE: + case MySqlParser.KW_DUPLICATE: + case MySqlParser.KW_DYNAMIC: + case MySqlParser.KW_ENABLE: + case MySqlParser.KW_ENCRYPTION: + case MySqlParser.KW_END: + case MySqlParser.KW_ENDS: + case MySqlParser.KW_ENGINE: + case MySqlParser.KW_ENGINES: + case MySqlParser.KW_ERROR: + case MySqlParser.KW_ERRORS: + case MySqlParser.KW_ESCAPE: + case MySqlParser.KW_EVENT: + case MySqlParser.KW_EVENTS: + case MySqlParser.KW_EVERY: + case MySqlParser.KW_EXCHANGE: + case MySqlParser.KW_EXCLUSIVE: + case MySqlParser.KW_EXPIRE: + case MySqlParser.KW_EXPORT: + case MySqlParser.KW_EXTENDED: + case MySqlParser.KW_EXTENT_SIZE: + case MySqlParser.KW_FAILED_LOGIN_ATTEMPTS: + case MySqlParser.KW_FAST: + case MySqlParser.KW_FAULTS: + case MySqlParser.KW_FIELDS: + case MySqlParser.KW_FILE_BLOCK_SIZE: + case MySqlParser.KW_FILTER: + case MySqlParser.KW_FIRST: + case MySqlParser.KW_FIXED: + case MySqlParser.KW_FLUSH: + case MySqlParser.KW_FOLLOWS: + case MySqlParser.KW_FOUND: + case MySqlParser.KW_FULL: + case MySqlParser.KW_FUNCTION: + case MySqlParser.KW_GENERAL: + case MySqlParser.KW_GLOBAL: + case MySqlParser.KW_GRANTS: + case MySqlParser.KW_GROUP_REPLICATION: + case MySqlParser.KW_HANDLER: + case MySqlParser.KW_HASH: + case MySqlParser.KW_HELP: + case MySqlParser.KW_HISTORY: + case MySqlParser.KW_HOST: + case MySqlParser.KW_HOSTS: + case MySqlParser.KW_IDENTIFIED: + case MySqlParser.KW_IGNORE_SERVER_IDS: + case MySqlParser.KW_IMPORT: + case MySqlParser.KW_INDEXES: + case MySqlParser.KW_INITIAL_SIZE: + case MySqlParser.KW_INPLACE: + case MySqlParser.KW_INSERT_METHOD: + case MySqlParser.KW_INSTALL: + case MySqlParser.KW_INSTANCE: + case MySqlParser.KW_INSTANT: + case MySqlParser.KW_INVISIBLE: + case MySqlParser.KW_INVOKER: + case MySqlParser.KW_IO: + case MySqlParser.KW_IO_THREAD: + case MySqlParser.KW_IPC: + case MySqlParser.KW_ISOLATION: + case MySqlParser.KW_ISSUER: + case MySqlParser.KW_JSON: + case MySqlParser.KW_KEY_BLOCK_SIZE: + case MySqlParser.KW_LANGUAGE: + case MySqlParser.KW_LAST: + case MySqlParser.KW_LEAVES: + case MySqlParser.KW_LESS: + case MySqlParser.KW_LEVEL: + case MySqlParser.KW_LIST: + case MySqlParser.KW_LOCAL: + case MySqlParser.KW_LOGFILE: + case MySqlParser.KW_LOGS: + case MySqlParser.KW_MASTER: + case MySqlParser.KW_MASTER_AUTO_POSITION: + case MySqlParser.KW_MASTER_CONNECT_RETRY: + case MySqlParser.KW_MASTER_DELAY: + case MySqlParser.KW_MASTER_HEARTBEAT_PERIOD: + case MySqlParser.KW_MASTER_HOST: + case MySqlParser.KW_MASTER_LOG_FILE: + case MySqlParser.KW_MASTER_LOG_POS: + case MySqlParser.KW_MASTER_PASSWORD: + case MySqlParser.KW_MASTER_PORT: + case MySqlParser.KW_MASTER_RETRY_COUNT: + case MySqlParser.KW_MASTER_SSL: + case MySqlParser.KW_MASTER_SSL_CA: + case MySqlParser.KW_MASTER_SSL_CAPATH: + case MySqlParser.KW_MASTER_SSL_CERT: + case MySqlParser.KW_MASTER_SSL_CIPHER: + case MySqlParser.KW_MASTER_SSL_CRL: + case MySqlParser.KW_MASTER_SSL_CRLPATH: + case MySqlParser.KW_MASTER_SSL_KEY: + case MySqlParser.KW_MASTER_TLS_VERSION: + case MySqlParser.KW_MASTER_USER: + case MySqlParser.KW_MAX_CONNECTIONS_PER_HOUR: + case MySqlParser.KW_MAX_QUERIES_PER_HOUR: + case MySqlParser.KW_MAX_ROWS: + case MySqlParser.KW_MAX_SIZE: + case MySqlParser.KW_MAX_UPDATES_PER_HOUR: + case MySqlParser.KW_MAX_USER_CONNECTIONS: + case MySqlParser.KW_MEDIUM: + case MySqlParser.KW_MEMBER: + case MySqlParser.KW_MERGE: + case MySqlParser.KW_MESSAGE_TEXT: + case MySqlParser.KW_MID: + case MySqlParser.KW_MIGRATE: + case MySqlParser.KW_MIN_ROWS: + case MySqlParser.KW_MODE: + case MySqlParser.KW_MODIFY: + case MySqlParser.KW_MUTEX: + case MySqlParser.KW_MYSQL: + case MySqlParser.KW_MYSQL_ERRNO: + case MySqlParser.KW_NAME: + case MySqlParser.KW_NAMES: + case MySqlParser.KW_NCHAR: + case MySqlParser.KW_NEVER: + case MySqlParser.KW_NEXT: + case MySqlParser.KW_NO: + case MySqlParser.KW_NOWAIT: + case MySqlParser.KW_NODEGROUP: + case MySqlParser.KW_NONE: + case MySqlParser.KW_ODBC: + case MySqlParser.KW_OFFLINE: + case MySqlParser.KW_OFFSET: + case MySqlParser.KW_OF: + case MySqlParser.KW_OLD_PASSWORD: + case MySqlParser.KW_ONE: + case MySqlParser.KW_ONLINE: + case MySqlParser.KW_ONLY: + case MySqlParser.KW_OPEN: + case MySqlParser.KW_OPTIMIZER_COSTS: + case MySqlParser.KW_OPTIONS: + case MySqlParser.KW_OWNER: + case MySqlParser.KW_PACK_KEYS: + case MySqlParser.KW_PAGE: + case MySqlParser.KW_PAGE_CHECKSUM: + case MySqlParser.KW_PARSER: + case MySqlParser.KW_PARTIAL: + case MySqlParser.KW_PARTITIONING: + case MySqlParser.KW_PARTITIONS: + case MySqlParser.KW_PASSWORD: + case MySqlParser.KW_PASSWORD_LOCK_TIME: + case MySqlParser.KW_PHASE: + case MySqlParser.KW_PLUGIN: + case MySqlParser.KW_PLUGIN_DIR: + case MySqlParser.KW_PLUGINS: + case MySqlParser.KW_PORT: + case MySqlParser.KW_PRECEDES: + case MySqlParser.KW_PREPARE: + case MySqlParser.KW_PRESERVE: + case MySqlParser.KW_PREV: + case MySqlParser.KW_PROCESSLIST: + case MySqlParser.KW_PROFILE: + case MySqlParser.KW_PROFILES: + case MySqlParser.KW_PROXY: + case MySqlParser.KW_QUERY: + case MySqlParser.KW_QUICK: + case MySqlParser.KW_REBUILD: + case MySqlParser.KW_RECOVER: + case MySqlParser.KW_RECURSIVE: + case MySqlParser.KW_REDO_BUFFER_SIZE: + case MySqlParser.KW_REDUNDANT: + case MySqlParser.KW_RELAY: + case MySqlParser.KW_RELAY_LOG_FILE: + case MySqlParser.KW_RELAY_LOG_POS: + case MySqlParser.KW_RELAYLOG: + case MySqlParser.KW_REMOVE: + case MySqlParser.KW_REORGANIZE: + case MySqlParser.KW_REPAIR: + case MySqlParser.KW_REPLICATE_DO_DB: + case MySqlParser.KW_REPLICATE_DO_TABLE: + case MySqlParser.KW_REPLICATE_IGNORE_DB: + case MySqlParser.KW_REPLICATE_IGNORE_TABLE: + case MySqlParser.KW_REPLICATE_REWRITE_DB: + case MySqlParser.KW_REPLICATE_WILD_DO_TABLE: + case MySqlParser.KW_REPLICATE_WILD_IGNORE_TABLE: + case MySqlParser.KW_REPLICATION: + case MySqlParser.KW_RESET: + case MySqlParser.KW_RESUME: + case MySqlParser.KW_RETURNED_SQLSTATE: + case MySqlParser.KW_RETURNS: + case MySqlParser.KW_REUSE: + case MySqlParser.KW_ROLE: + case MySqlParser.KW_ROLLBACK: + case MySqlParser.KW_ROLLUP: + case MySqlParser.KW_ROTATE: + case MySqlParser.KW_ROW: + case MySqlParser.KW_ROWS: + case MySqlParser.KW_ROW_FORMAT: + case MySqlParser.KW_SAVEPOINT: + case MySqlParser.KW_SCHEDULE: + case MySqlParser.KW_SECURITY: + case MySqlParser.KW_SERVER: + case MySqlParser.KW_SESSION: + case MySqlParser.KW_SHARE: + case MySqlParser.KW_SHARED: + case MySqlParser.KW_SIGNED: + case MySqlParser.KW_SIMPLE: + case MySqlParser.KW_SLAVE: + case MySqlParser.KW_SLOW: + case MySqlParser.KW_SNAPSHOT: + case MySqlParser.KW_SOCKET: + case MySqlParser.KW_SOME: + case MySqlParser.KW_SONAME: + case MySqlParser.KW_SOUNDS: + case MySqlParser.KW_SOURCE: + case MySqlParser.KW_SQL_AFTER_GTIDS: + case MySqlParser.KW_SQL_AFTER_MTS_GAPS: + case MySqlParser.KW_SQL_BEFORE_GTIDS: + case MySqlParser.KW_SQL_BUFFER_RESULT: + case MySqlParser.KW_SQL_CACHE: + case MySqlParser.KW_SQL_NO_CACHE: + case MySqlParser.KW_SQL_THREAD: + case MySqlParser.KW_START: + case MySqlParser.KW_STARTS: + case MySqlParser.KW_STATS_AUTO_RECALC: + case MySqlParser.KW_STATS_PERSISTENT: + case MySqlParser.KW_STATS_SAMPLE_PAGES: + case MySqlParser.KW_STATUS: + case MySqlParser.KW_STOP: + case MySqlParser.KW_STORAGE: + case MySqlParser.KW_STRING: + case MySqlParser.KW_SUBCLASS_ORIGIN: + case MySqlParser.KW_SUBJECT: + case MySqlParser.KW_SUBPARTITION: + case MySqlParser.KW_SUBPARTITIONS: + case MySqlParser.KW_SUSPEND: + case MySqlParser.KW_SWAPS: + case MySqlParser.KW_SWITCHES: + case MySqlParser.KW_TABLE_NAME: + case MySqlParser.KW_TABLESPACE: + case MySqlParser.KW_TABLE_TYPE: + case MySqlParser.KW_TEMPORARY: + case MySqlParser.KW_TEMPTABLE: + case MySqlParser.KW_THAN: + case MySqlParser.KW_TRADITIONAL: + case MySqlParser.KW_TRANSACTION: + case MySqlParser.KW_TRANSACTIONAL: + case MySqlParser.KW_TRIGGERS: + case MySqlParser.KW_TRUNCATE: + case MySqlParser.KW_UNBOUNDED: + case MySqlParser.KW_UNDEFINED: + case MySqlParser.KW_UNDOFILE: + case MySqlParser.KW_UNDO_BUFFER_SIZE: + case MySqlParser.KW_UNINSTALL: + case MySqlParser.KW_UNKNOWN: + case MySqlParser.KW_UNTIL: + case MySqlParser.KW_UPGRADE: + case MySqlParser.KW_USER: + case MySqlParser.KW_USE_FRM: + case MySqlParser.KW_USER_RESOURCES: + case MySqlParser.KW_VALIDATION: + case MySqlParser.KW_VALUE: + case MySqlParser.KW_VARIABLES: + case MySqlParser.KW_VIEW: + case MySqlParser.KW_VIRTUAL: + case MySqlParser.KW_VISIBLE: + case MySqlParser.KW_WAIT: + case MySqlParser.KW_WARNINGS: + case MySqlParser.KW_WITHOUT: + case MySqlParser.KW_WORK: + case MySqlParser.KW_WRAPPER: + case MySqlParser.KW_X509: + case MySqlParser.KW_XA: + case MySqlParser.KW_XML: + case MySqlParser.KW_QUARTER: + case MySqlParser.KW_MONTH: + case MySqlParser.KW_DAY: + case MySqlParser.KW_HOUR: + case MySqlParser.KW_MINUTE: + case MySqlParser.KW_WEEK: + case MySqlParser.KW_SECOND: + case MySqlParser.KW_MICROSECOND: + case MySqlParser.KW_ADMIN: + case MySqlParser.KW_AUDIT_ABORT_EXEMPT: + case MySqlParser.KW_AUDIT_ADMIN: + case MySqlParser.KW_AUTHENTICATION_POLICY_ADMIN: + case MySqlParser.KW_BACKUP_ADMIN: + case MySqlParser.KW_BINLOG_ADMIN: + case MySqlParser.KW_BINLOG_ENCRYPTION_ADMIN: + case MySqlParser.KW_CLONE_ADMIN: + case MySqlParser.KW_CONNECTION_ADMIN: + case MySqlParser.KW_ENCRYPTION_KEY_ADMIN: + case MySqlParser.KW_EXECUTE: + case MySqlParser.KW_FILE: + case MySqlParser.KW_FIREWALL_ADMIN: + case MySqlParser.KW_FIREWALL_EXEMPT: + case MySqlParser.KW_FIREWALL_USER: + case MySqlParser.KW_GROUP_REPLICATION_ADMIN: + case MySqlParser.KW_INNODB_REDO_LOG_ARCHIVE: + case MySqlParser.KW_INVOKE: + case MySqlParser.KW_LAMBDA: + case MySqlParser.KW_NDB_STORED_USER: + case MySqlParser.KW_PASSWORDLESS_USER_ADMIN: + case MySqlParser.KW_PERSIST_RO_VARIABLES_ADMIN: + case MySqlParser.KW_PRIVILEGES: + case MySqlParser.KW_PROCESS: + case MySqlParser.KW_RELOAD: + case MySqlParser.KW_REPLICATION_APPLIER: + case MySqlParser.KW_REPLICATION_SLAVE_ADMIN: + case MySqlParser.KW_RESOURCE_GROUP_ADMIN: + case MySqlParser.KW_RESOURCE_GROUP_USER: + case MySqlParser.KW_ROLE_ADMIN: + case MySqlParser.KW_ROUTINE: + case MySqlParser.KW_S3: + case MySqlParser.KW_SESSION_VARIABLES_ADMIN: + case MySqlParser.KW_SET_USER_ID: + case MySqlParser.KW_SHOW_ROUTINE: + case MySqlParser.KW_SHUTDOWN: + case MySqlParser.KW_SUPER: + case MySqlParser.KW_SYSTEM_VARIABLES_ADMIN: + case MySqlParser.KW_TABLES: + case MySqlParser.KW_TABLE_ENCRYPTION_ADMIN: + case MySqlParser.KW_VERSION_TOKEN_ADMIN: + case MySqlParser.KW_XA_RECOVER_ADMIN: + case MySqlParser.KW_ARMSCII8: + case MySqlParser.KW_ASCII: + case MySqlParser.KW_BIG5: + case MySqlParser.KW_CP1250: + case MySqlParser.KW_CP1251: + case MySqlParser.KW_CP1256: + case MySqlParser.KW_CP1257: + case MySqlParser.KW_CP850: + case MySqlParser.KW_CP852: + case MySqlParser.KW_CP866: + case MySqlParser.KW_CP932: + case MySqlParser.KW_DEC8: + case MySqlParser.KW_EUCJPMS: + case MySqlParser.KW_EUCKR: + case MySqlParser.KW_GB18030: + case MySqlParser.KW_GB2312: + case MySqlParser.KW_GBK: + case MySqlParser.KW_GEOSTD8: + case MySqlParser.KW_GREEK: + case MySqlParser.KW_HEBREW: + case MySqlParser.KW_HP8: + case MySqlParser.KW_KEYBCS2: + case MySqlParser.KW_KOI8R: + case MySqlParser.KW_KOI8U: + case MySqlParser.KW_LATIN1: + case MySqlParser.KW_LATIN2: + case MySqlParser.KW_LATIN5: + case MySqlParser.KW_LATIN7: + case MySqlParser.KW_MACCE: + case MySqlParser.KW_MACROMAN: + case MySqlParser.KW_SJIS: + case MySqlParser.KW_SWE7: + case MySqlParser.KW_TIS620: + case MySqlParser.KW_UCS2: + case MySqlParser.KW_UJIS: + case MySqlParser.KW_UTF16: + case MySqlParser.KW_UTF16LE: + case MySqlParser.KW_UTF32: + case MySqlParser.KW_UTF8: + case MySqlParser.KW_UTF8MB3: + case MySqlParser.KW_UTF8MB4: + case MySqlParser.KW_ARCHIVE: + case MySqlParser.KW_BLACKHOLE: + case MySqlParser.KW_CSV: + case MySqlParser.KW_FEDERATED: + case MySqlParser.KW_INNODB: + case MySqlParser.KW_MEMORY: + case MySqlParser.KW_MRG_MYISAM: + case MySqlParser.KW_MYISAM: + case MySqlParser.KW_NDB: + case MySqlParser.KW_NDBCLUSTER: + case MySqlParser.KW_PERFORMANCE_SCHEMA: + case MySqlParser.KW_TOKUDB: + case MySqlParser.KW_REPEATABLE: + case MySqlParser.KW_COMMITTED: + case MySqlParser.KW_UNCOMMITTED: + case MySqlParser.KW_SERIALIZABLE: + case MySqlParser.KW_GEOMETRYCOLLECTION: + case MySqlParser.KW_LINESTRING: + case MySqlParser.KW_MULTILINESTRING: + case MySqlParser.KW_MULTIPOINT: + case MySqlParser.KW_MULTIPOLYGON: + case MySqlParser.KW_POINT: + case MySqlParser.KW_POLYGON: + case MySqlParser.KW_CATALOG_NAME: + case MySqlParser.KW_CHARSET: + case MySqlParser.KW_COLLATION: + case MySqlParser.KW_ENGINE_ATTRIBUTE: + case MySqlParser.KW_FORMAT: + case MySqlParser.KW_GET_FORMAT: + case MySqlParser.KW_RANDOM: + case MySqlParser.KW_REVERSE: + case MySqlParser.KW_ROW_COUNT: + case MySqlParser.KW_SCHEMA_NAME: + case MySqlParser.KW_SECONDARY_ENGINE_ATTRIBUTE: + case MySqlParser.KW_SRID: + case MySqlParser.KW_SYSTEM_USER: + case MySqlParser.KW_TP_CONNECTION_ADMIN: + case MySqlParser.KW_WEIGHT_STRING: + case MySqlParser.MOD: + case MySqlParser.CHARSET_REVERSE_QOUTE_STRING: + case MySqlParser.STRING_LITERAL: + case MySqlParser.ID: + { + this.state = 2914; + this.partitionNames(); + } + break; + case MySqlParser.KW_ALL: + { + this.state = 2915; + this.match(MySqlParser.KW_ALL); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + this.state = 2918; + this.match(MySqlParser.KW_TABLESPACE); + } + break; + case MySqlParser.KW_TRUNCATE: + localContext = new AlterByTruncatePartitionContext(localContext); + this.enterOuterAlt(localContext, 5); + { + this.state = 2919; + this.match(MySqlParser.KW_TRUNCATE); + this.state = 2920; + this.match(MySqlParser.KW_PARTITION); + this.state = 2923; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_ARRAY: + case MySqlParser.KW_ATTRIBUTE: + case MySqlParser.KW_BUCKETS: + case MySqlParser.KW_CONDITION: + case MySqlParser.KW_CURRENT: + case MySqlParser.KW_CURRENT_USER: + case MySqlParser.KW_DATABASE: + case MySqlParser.KW_DEFAULT: + case MySqlParser.KW_DIAGNOSTICS: + case MySqlParser.KW_EMPTY: + case MySqlParser.KW_ENFORCED: + case MySqlParser.KW_EXCEPT: + case MySqlParser.KW_GROUP: + case MySqlParser.KW_IF: + case MySqlParser.KW_INSERT: + case MySqlParser.KW_LATERAL: + case MySqlParser.KW_LEFT: + case MySqlParser.KW_NUMBER: + case MySqlParser.KW_OPTIONAL: + case MySqlParser.KW_ORDER: + case MySqlParser.KW_PRIMARY: + case MySqlParser.KW_REPEAT: + case MySqlParser.KW_REPLACE: + case MySqlParser.KW_RIGHT: + case MySqlParser.KW_SCHEMA: + case MySqlParser.KW_SKIP_QUERY_REWRITE: + case MySqlParser.KW_STACKED: + case MySqlParser.KW_DATE: + case MySqlParser.KW_TIME: + case MySqlParser.KW_TIMESTAMP: + case MySqlParser.KW_DATETIME: + case MySqlParser.KW_YEAR: + case MySqlParser.KW_BINARY: + case MySqlParser.KW_TEXT: + case MySqlParser.KW_ENUM: + case MySqlParser.KW_SERIAL: + case MySqlParser.KW_JSON_TABLE: + case MySqlParser.KW_JSON_VALUE: + case MySqlParser.KW_NESTED: + case MySqlParser.KW_ORDINALITY: + case MySqlParser.KW_PATH: + case MySqlParser.KW_AVG: + case MySqlParser.KW_BIT_AND: + case MySqlParser.KW_BIT_OR: + case MySqlParser.KW_BIT_XOR: + case MySqlParser.KW_COUNT: + case MySqlParser.KW_CUME_DIST: + case MySqlParser.KW_DENSE_RANK: + case MySqlParser.KW_FIRST_VALUE: + case MySqlParser.KW_GROUP_CONCAT: + case MySqlParser.KW_LAG: + case MySqlParser.KW_LAST_VALUE: + case MySqlParser.KW_LEAD: + case MySqlParser.KW_MAX: + case MySqlParser.KW_MIN: + case MySqlParser.KW_NTILE: + case MySqlParser.KW_NTH_VALUE: + case MySqlParser.KW_PERCENT_RANK: + case MySqlParser.KW_RANK: + case MySqlParser.KW_ROW_NUMBER: + case MySqlParser.KW_STD: + case MySqlParser.KW_STDDEV: + case MySqlParser.KW_STDDEV_POP: + case MySqlParser.KW_STDDEV_SAMP: + case MySqlParser.KW_SUM: + case MySqlParser.KW_VAR_POP: + case MySqlParser.KW_VAR_SAMP: + case MySqlParser.KW_VARIANCE: + case MySqlParser.KW_CURRENT_DATE: + case MySqlParser.KW_CURRENT_TIME: + case MySqlParser.KW_CURRENT_TIMESTAMP: + case MySqlParser.KW_LOCALTIME: + case MySqlParser.KW_CURDATE: + case MySqlParser.KW_CURTIME: + case MySqlParser.KW_DATE_ADD: + case MySqlParser.KW_DATE_SUB: + case MySqlParser.KW_LOCALTIMESTAMP: + case MySqlParser.KW_NOW: + case MySqlParser.KW_POSITION: + case MySqlParser.KW_SUBSTR: + case MySqlParser.KW_SUBSTRING: + case MySqlParser.KW_SYSDATE: + case MySqlParser.KW_TRIM: + case MySqlParser.KW_UTC_DATE: + case MySqlParser.KW_UTC_TIME: + case MySqlParser.KW_UTC_TIMESTAMP: + case MySqlParser.KW_ACCOUNT: + case MySqlParser.KW_ACTION: + case MySqlParser.KW_AFTER: + case MySqlParser.KW_AGGREGATE: + case MySqlParser.KW_ALGORITHM: + case MySqlParser.KW_ANY: + case MySqlParser.KW_AT: + case MySqlParser.KW_AUTHORS: + case MySqlParser.KW_AUTOCOMMIT: + case MySqlParser.KW_AUTOEXTEND_SIZE: + case MySqlParser.KW_AUTO_INCREMENT: + case MySqlParser.KW_AVG_ROW_LENGTH: + case MySqlParser.KW_BEGIN: + case MySqlParser.KW_BINLOG: + case MySqlParser.KW_BIT: + case MySqlParser.KW_BLOCK: + case MySqlParser.KW_BOOL: + case MySqlParser.KW_BOOLEAN: + case MySqlParser.KW_BTREE: + case MySqlParser.KW_CACHE: + case MySqlParser.KW_CASCADED: + case MySqlParser.KW_CHAIN: + case MySqlParser.KW_CHANGED: + case MySqlParser.KW_CHANNEL: + case MySqlParser.KW_CHECKSUM: + case MySqlParser.KW_CIPHER: + case MySqlParser.KW_CLASS_ORIGIN: + case MySqlParser.KW_CLIENT: + case MySqlParser.KW_CLOSE: + case MySqlParser.KW_COALESCE: + case MySqlParser.KW_CODE: + case MySqlParser.KW_COLUMNS: + case MySqlParser.KW_COLUMN_FORMAT: + case MySqlParser.KW_COLUMN_NAME: + case MySqlParser.KW_COMMENT: + case MySqlParser.KW_COMMIT: + case MySqlParser.KW_COMPACT: + case MySqlParser.KW_COMPLETION: + case MySqlParser.KW_COMPRESSED: + case MySqlParser.KW_COMPRESSION: + case MySqlParser.KW_CONCURRENT: + case MySqlParser.KW_CONNECT: + case MySqlParser.KW_CONNECTION: + case MySqlParser.KW_CONSISTENT: + case MySqlParser.KW_CONSTRAINT_CATALOG: + case MySqlParser.KW_CONSTRAINT_SCHEMA: + case MySqlParser.KW_CONSTRAINT_NAME: + case MySqlParser.KW_CONTAINS: + case MySqlParser.KW_CONTEXT: + case MySqlParser.KW_CONTRIBUTORS: + case MySqlParser.KW_COPY: + case MySqlParser.KW_CPU: + case MySqlParser.KW_CURSOR_NAME: + case MySqlParser.KW_DATA: + case MySqlParser.KW_DATAFILE: + case MySqlParser.KW_DEALLOCATE: + case MySqlParser.KW_DEFAULT_AUTH: + case MySqlParser.KW_DEFINER: + case MySqlParser.KW_DELAY_KEY_WRITE: + case MySqlParser.KW_DES_KEY_FILE: + case MySqlParser.KW_DIRECTORY: + case MySqlParser.KW_DISABLE: + case MySqlParser.KW_DISCARD: + case MySqlParser.KW_DISK: + case MySqlParser.KW_DO: + case MySqlParser.KW_DUMPFILE: + case MySqlParser.KW_DUPLICATE: + case MySqlParser.KW_DYNAMIC: + case MySqlParser.KW_ENABLE: + case MySqlParser.KW_ENCRYPTION: + case MySqlParser.KW_END: + case MySqlParser.KW_ENDS: + case MySqlParser.KW_ENGINE: + case MySqlParser.KW_ENGINES: + case MySqlParser.KW_ERROR: + case MySqlParser.KW_ERRORS: + case MySqlParser.KW_ESCAPE: + case MySqlParser.KW_EVENT: + case MySqlParser.KW_EVENTS: + case MySqlParser.KW_EVERY: + case MySqlParser.KW_EXCHANGE: + case MySqlParser.KW_EXCLUSIVE: + case MySqlParser.KW_EXPIRE: + case MySqlParser.KW_EXPORT: + case MySqlParser.KW_EXTENDED: + case MySqlParser.KW_EXTENT_SIZE: + case MySqlParser.KW_FAILED_LOGIN_ATTEMPTS: + case MySqlParser.KW_FAST: + case MySqlParser.KW_FAULTS: + case MySqlParser.KW_FIELDS: + case MySqlParser.KW_FILE_BLOCK_SIZE: + case MySqlParser.KW_FILTER: + case MySqlParser.KW_FIRST: + case MySqlParser.KW_FIXED: + case MySqlParser.KW_FLUSH: + case MySqlParser.KW_FOLLOWS: + case MySqlParser.KW_FOUND: + case MySqlParser.KW_FULL: + case MySqlParser.KW_FUNCTION: + case MySqlParser.KW_GENERAL: + case MySqlParser.KW_GLOBAL: + case MySqlParser.KW_GRANTS: + case MySqlParser.KW_GROUP_REPLICATION: + case MySqlParser.KW_HANDLER: + case MySqlParser.KW_HASH: + case MySqlParser.KW_HELP: + case MySqlParser.KW_HISTORY: + case MySqlParser.KW_HOST: + case MySqlParser.KW_HOSTS: + case MySqlParser.KW_IDENTIFIED: + case MySqlParser.KW_IGNORE_SERVER_IDS: + case MySqlParser.KW_IMPORT: + case MySqlParser.KW_INDEXES: + case MySqlParser.KW_INITIAL_SIZE: + case MySqlParser.KW_INPLACE: + case MySqlParser.KW_INSERT_METHOD: + case MySqlParser.KW_INSTALL: + case MySqlParser.KW_INSTANCE: + case MySqlParser.KW_INSTANT: + case MySqlParser.KW_INVISIBLE: + case MySqlParser.KW_INVOKER: + case MySqlParser.KW_IO: + case MySqlParser.KW_IO_THREAD: + case MySqlParser.KW_IPC: + case MySqlParser.KW_ISOLATION: + case MySqlParser.KW_ISSUER: + case MySqlParser.KW_JSON: + case MySqlParser.KW_KEY_BLOCK_SIZE: + case MySqlParser.KW_LANGUAGE: + case MySqlParser.KW_LAST: + case MySqlParser.KW_LEAVES: + case MySqlParser.KW_LESS: + case MySqlParser.KW_LEVEL: + case MySqlParser.KW_LIST: + case MySqlParser.KW_LOCAL: + case MySqlParser.KW_LOGFILE: + case MySqlParser.KW_LOGS: + case MySqlParser.KW_MASTER: + case MySqlParser.KW_MASTER_AUTO_POSITION: + case MySqlParser.KW_MASTER_CONNECT_RETRY: + case MySqlParser.KW_MASTER_DELAY: + case MySqlParser.KW_MASTER_HEARTBEAT_PERIOD: + case MySqlParser.KW_MASTER_HOST: + case MySqlParser.KW_MASTER_LOG_FILE: + case MySqlParser.KW_MASTER_LOG_POS: + case MySqlParser.KW_MASTER_PASSWORD: + case MySqlParser.KW_MASTER_PORT: + case MySqlParser.KW_MASTER_RETRY_COUNT: + case MySqlParser.KW_MASTER_SSL: + case MySqlParser.KW_MASTER_SSL_CA: + case MySqlParser.KW_MASTER_SSL_CAPATH: + case MySqlParser.KW_MASTER_SSL_CERT: + case MySqlParser.KW_MASTER_SSL_CIPHER: + case MySqlParser.KW_MASTER_SSL_CRL: + case MySqlParser.KW_MASTER_SSL_CRLPATH: + case MySqlParser.KW_MASTER_SSL_KEY: + case MySqlParser.KW_MASTER_TLS_VERSION: + case MySqlParser.KW_MASTER_USER: + case MySqlParser.KW_MAX_CONNECTIONS_PER_HOUR: + case MySqlParser.KW_MAX_QUERIES_PER_HOUR: + case MySqlParser.KW_MAX_ROWS: + case MySqlParser.KW_MAX_SIZE: + case MySqlParser.KW_MAX_UPDATES_PER_HOUR: + case MySqlParser.KW_MAX_USER_CONNECTIONS: + case MySqlParser.KW_MEDIUM: + case MySqlParser.KW_MEMBER: + case MySqlParser.KW_MERGE: + case MySqlParser.KW_MESSAGE_TEXT: + case MySqlParser.KW_MID: + case MySqlParser.KW_MIGRATE: + case MySqlParser.KW_MIN_ROWS: + case MySqlParser.KW_MODE: + case MySqlParser.KW_MODIFY: + case MySqlParser.KW_MUTEX: + case MySqlParser.KW_MYSQL: + case MySqlParser.KW_MYSQL_ERRNO: + case MySqlParser.KW_NAME: + case MySqlParser.KW_NAMES: + case MySqlParser.KW_NCHAR: + case MySqlParser.KW_NEVER: + case MySqlParser.KW_NEXT: + case MySqlParser.KW_NO: + case MySqlParser.KW_NOWAIT: + case MySqlParser.KW_NODEGROUP: + case MySqlParser.KW_NONE: + case MySqlParser.KW_ODBC: + case MySqlParser.KW_OFFLINE: + case MySqlParser.KW_OFFSET: + case MySqlParser.KW_OF: + case MySqlParser.KW_OLD_PASSWORD: + case MySqlParser.KW_ONE: + case MySqlParser.KW_ONLINE: + case MySqlParser.KW_ONLY: + case MySqlParser.KW_OPEN: + case MySqlParser.KW_OPTIMIZER_COSTS: + case MySqlParser.KW_OPTIONS: + case MySqlParser.KW_OWNER: + case MySqlParser.KW_PACK_KEYS: + case MySqlParser.KW_PAGE: + case MySqlParser.KW_PAGE_CHECKSUM: + case MySqlParser.KW_PARSER: + case MySqlParser.KW_PARTIAL: + case MySqlParser.KW_PARTITIONING: + case MySqlParser.KW_PARTITIONS: + case MySqlParser.KW_PASSWORD: + case MySqlParser.KW_PASSWORD_LOCK_TIME: + case MySqlParser.KW_PHASE: + case MySqlParser.KW_PLUGIN: + case MySqlParser.KW_PLUGIN_DIR: + case MySqlParser.KW_PLUGINS: + case MySqlParser.KW_PORT: + case MySqlParser.KW_PRECEDES: + case MySqlParser.KW_PREPARE: + case MySqlParser.KW_PRESERVE: + case MySqlParser.KW_PREV: + case MySqlParser.KW_PROCESSLIST: + case MySqlParser.KW_PROFILE: + case MySqlParser.KW_PROFILES: + case MySqlParser.KW_PROXY: + case MySqlParser.KW_QUERY: + case MySqlParser.KW_QUICK: + case MySqlParser.KW_REBUILD: + case MySqlParser.KW_RECOVER: + case MySqlParser.KW_RECURSIVE: + case MySqlParser.KW_REDO_BUFFER_SIZE: + case MySqlParser.KW_REDUNDANT: + case MySqlParser.KW_RELAY: + case MySqlParser.KW_RELAY_LOG_FILE: + case MySqlParser.KW_RELAY_LOG_POS: + case MySqlParser.KW_RELAYLOG: + case MySqlParser.KW_REMOVE: + case MySqlParser.KW_REORGANIZE: + case MySqlParser.KW_REPAIR: + case MySqlParser.KW_REPLICATE_DO_DB: + case MySqlParser.KW_REPLICATE_DO_TABLE: + case MySqlParser.KW_REPLICATE_IGNORE_DB: + case MySqlParser.KW_REPLICATE_IGNORE_TABLE: + case MySqlParser.KW_REPLICATE_REWRITE_DB: + case MySqlParser.KW_REPLICATE_WILD_DO_TABLE: + case MySqlParser.KW_REPLICATE_WILD_IGNORE_TABLE: + case MySqlParser.KW_REPLICATION: + case MySqlParser.KW_RESET: + case MySqlParser.KW_RESUME: + case MySqlParser.KW_RETURNED_SQLSTATE: + case MySqlParser.KW_RETURNS: + case MySqlParser.KW_REUSE: + case MySqlParser.KW_ROLE: + case MySqlParser.KW_ROLLBACK: + case MySqlParser.KW_ROLLUP: + case MySqlParser.KW_ROTATE: + case MySqlParser.KW_ROW: + case MySqlParser.KW_ROWS: + case MySqlParser.KW_ROW_FORMAT: + case MySqlParser.KW_SAVEPOINT: + case MySqlParser.KW_SCHEDULE: + case MySqlParser.KW_SECURITY: + case MySqlParser.KW_SERVER: + case MySqlParser.KW_SESSION: + case MySqlParser.KW_SHARE: + case MySqlParser.KW_SHARED: + case MySqlParser.KW_SIGNED: + case MySqlParser.KW_SIMPLE: + case MySqlParser.KW_SLAVE: + case MySqlParser.KW_SLOW: + case MySqlParser.KW_SNAPSHOT: + case MySqlParser.KW_SOCKET: + case MySqlParser.KW_SOME: + case MySqlParser.KW_SONAME: + case MySqlParser.KW_SOUNDS: + case MySqlParser.KW_SOURCE: + case MySqlParser.KW_SQL_AFTER_GTIDS: + case MySqlParser.KW_SQL_AFTER_MTS_GAPS: + case MySqlParser.KW_SQL_BEFORE_GTIDS: + case MySqlParser.KW_SQL_BUFFER_RESULT: + case MySqlParser.KW_SQL_CACHE: + case MySqlParser.KW_SQL_NO_CACHE: + case MySqlParser.KW_SQL_THREAD: + case MySqlParser.KW_START: + case MySqlParser.KW_STARTS: + case MySqlParser.KW_STATS_AUTO_RECALC: + case MySqlParser.KW_STATS_PERSISTENT: + case MySqlParser.KW_STATS_SAMPLE_PAGES: + case MySqlParser.KW_STATUS: + case MySqlParser.KW_STOP: + case MySqlParser.KW_STORAGE: + case MySqlParser.KW_STRING: + case MySqlParser.KW_SUBCLASS_ORIGIN: + case MySqlParser.KW_SUBJECT: + case MySqlParser.KW_SUBPARTITION: + case MySqlParser.KW_SUBPARTITIONS: + case MySqlParser.KW_SUSPEND: + case MySqlParser.KW_SWAPS: + case MySqlParser.KW_SWITCHES: + case MySqlParser.KW_TABLE_NAME: + case MySqlParser.KW_TABLESPACE: + case MySqlParser.KW_TABLE_TYPE: + case MySqlParser.KW_TEMPORARY: + case MySqlParser.KW_TEMPTABLE: + case MySqlParser.KW_THAN: + case MySqlParser.KW_TRADITIONAL: + case MySqlParser.KW_TRANSACTION: + case MySqlParser.KW_TRANSACTIONAL: + case MySqlParser.KW_TRIGGERS: + case MySqlParser.KW_TRUNCATE: + case MySqlParser.KW_UNBOUNDED: + case MySqlParser.KW_UNDEFINED: + case MySqlParser.KW_UNDOFILE: + case MySqlParser.KW_UNDO_BUFFER_SIZE: + case MySqlParser.KW_UNINSTALL: + case MySqlParser.KW_UNKNOWN: + case MySqlParser.KW_UNTIL: + case MySqlParser.KW_UPGRADE: + case MySqlParser.KW_USER: + case MySqlParser.KW_USE_FRM: + case MySqlParser.KW_USER_RESOURCES: + case MySqlParser.KW_VALIDATION: + case MySqlParser.KW_VALUE: + case MySqlParser.KW_VARIABLES: + case MySqlParser.KW_VIEW: + case MySqlParser.KW_VIRTUAL: + case MySqlParser.KW_VISIBLE: + case MySqlParser.KW_WAIT: + case MySqlParser.KW_WARNINGS: + case MySqlParser.KW_WITHOUT: + case MySqlParser.KW_WORK: + case MySqlParser.KW_WRAPPER: + case MySqlParser.KW_X509: + case MySqlParser.KW_XA: + case MySqlParser.KW_XML: + case MySqlParser.KW_QUARTER: + case MySqlParser.KW_MONTH: + case MySqlParser.KW_DAY: + case MySqlParser.KW_HOUR: + case MySqlParser.KW_MINUTE: + case MySqlParser.KW_WEEK: + case MySqlParser.KW_SECOND: + case MySqlParser.KW_MICROSECOND: + case MySqlParser.KW_ADMIN: + case MySqlParser.KW_AUDIT_ABORT_EXEMPT: + case MySqlParser.KW_AUDIT_ADMIN: + case MySqlParser.KW_AUTHENTICATION_POLICY_ADMIN: + case MySqlParser.KW_BACKUP_ADMIN: + case MySqlParser.KW_BINLOG_ADMIN: + case MySqlParser.KW_BINLOG_ENCRYPTION_ADMIN: + case MySqlParser.KW_CLONE_ADMIN: + case MySqlParser.KW_CONNECTION_ADMIN: + case MySqlParser.KW_ENCRYPTION_KEY_ADMIN: + case MySqlParser.KW_EXECUTE: + case MySqlParser.KW_FILE: + case MySqlParser.KW_FIREWALL_ADMIN: + case MySqlParser.KW_FIREWALL_EXEMPT: + case MySqlParser.KW_FIREWALL_USER: + case MySqlParser.KW_GROUP_REPLICATION_ADMIN: + case MySqlParser.KW_INNODB_REDO_LOG_ARCHIVE: + case MySqlParser.KW_INVOKE: + case MySqlParser.KW_LAMBDA: + case MySqlParser.KW_NDB_STORED_USER: + case MySqlParser.KW_PASSWORDLESS_USER_ADMIN: + case MySqlParser.KW_PERSIST_RO_VARIABLES_ADMIN: + case MySqlParser.KW_PRIVILEGES: + case MySqlParser.KW_PROCESS: + case MySqlParser.KW_RELOAD: + case MySqlParser.KW_REPLICATION_APPLIER: + case MySqlParser.KW_REPLICATION_SLAVE_ADMIN: + case MySqlParser.KW_RESOURCE_GROUP_ADMIN: + case MySqlParser.KW_RESOURCE_GROUP_USER: + case MySqlParser.KW_ROLE_ADMIN: + case MySqlParser.KW_ROUTINE: + case MySqlParser.KW_S3: + case MySqlParser.KW_SESSION_VARIABLES_ADMIN: + case MySqlParser.KW_SET_USER_ID: + case MySqlParser.KW_SHOW_ROUTINE: + case MySqlParser.KW_SHUTDOWN: + case MySqlParser.KW_SUPER: + case MySqlParser.KW_SYSTEM_VARIABLES_ADMIN: + case MySqlParser.KW_TABLES: + case MySqlParser.KW_TABLE_ENCRYPTION_ADMIN: + case MySqlParser.KW_VERSION_TOKEN_ADMIN: + case MySqlParser.KW_XA_RECOVER_ADMIN: + case MySqlParser.KW_ARMSCII8: + case MySqlParser.KW_ASCII: + case MySqlParser.KW_BIG5: + case MySqlParser.KW_CP1250: + case MySqlParser.KW_CP1251: + case MySqlParser.KW_CP1256: + case MySqlParser.KW_CP1257: + case MySqlParser.KW_CP850: + case MySqlParser.KW_CP852: + case MySqlParser.KW_CP866: + case MySqlParser.KW_CP932: + case MySqlParser.KW_DEC8: + case MySqlParser.KW_EUCJPMS: + case MySqlParser.KW_EUCKR: + case MySqlParser.KW_GB18030: + case MySqlParser.KW_GB2312: + case MySqlParser.KW_GBK: + case MySqlParser.KW_GEOSTD8: + case MySqlParser.KW_GREEK: + case MySqlParser.KW_HEBREW: + case MySqlParser.KW_HP8: + case MySqlParser.KW_KEYBCS2: + case MySqlParser.KW_KOI8R: + case MySqlParser.KW_KOI8U: + case MySqlParser.KW_LATIN1: + case MySqlParser.KW_LATIN2: + case MySqlParser.KW_LATIN5: + case MySqlParser.KW_LATIN7: + case MySqlParser.KW_MACCE: + case MySqlParser.KW_MACROMAN: + case MySqlParser.KW_SJIS: + case MySqlParser.KW_SWE7: + case MySqlParser.KW_TIS620: + case MySqlParser.KW_UCS2: + case MySqlParser.KW_UJIS: + case MySqlParser.KW_UTF16: + case MySqlParser.KW_UTF16LE: + case MySqlParser.KW_UTF32: + case MySqlParser.KW_UTF8: + case MySqlParser.KW_UTF8MB3: + case MySqlParser.KW_UTF8MB4: + case MySqlParser.KW_ARCHIVE: + case MySqlParser.KW_BLACKHOLE: + case MySqlParser.KW_CSV: + case MySqlParser.KW_FEDERATED: + case MySqlParser.KW_INNODB: + case MySqlParser.KW_MEMORY: + case MySqlParser.KW_MRG_MYISAM: + case MySqlParser.KW_MYISAM: + case MySqlParser.KW_NDB: + case MySqlParser.KW_NDBCLUSTER: + case MySqlParser.KW_PERFORMANCE_SCHEMA: + case MySqlParser.KW_TOKUDB: + case MySqlParser.KW_REPEATABLE: + case MySqlParser.KW_COMMITTED: + case MySqlParser.KW_UNCOMMITTED: + case MySqlParser.KW_SERIALIZABLE: + case MySqlParser.KW_GEOMETRYCOLLECTION: + case MySqlParser.KW_LINESTRING: + case MySqlParser.KW_MULTILINESTRING: + case MySqlParser.KW_MULTIPOINT: + case MySqlParser.KW_MULTIPOLYGON: + case MySqlParser.KW_POINT: + case MySqlParser.KW_POLYGON: + case MySqlParser.KW_CATALOG_NAME: + case MySqlParser.KW_CHARSET: + case MySqlParser.KW_COLLATION: + case MySqlParser.KW_ENGINE_ATTRIBUTE: + case MySqlParser.KW_FORMAT: + case MySqlParser.KW_GET_FORMAT: + case MySqlParser.KW_RANDOM: + case MySqlParser.KW_REVERSE: + case MySqlParser.KW_ROW_COUNT: + case MySqlParser.KW_SCHEMA_NAME: + case MySqlParser.KW_SECONDARY_ENGINE_ATTRIBUTE: + case MySqlParser.KW_SRID: + case MySqlParser.KW_SYSTEM_USER: + case MySqlParser.KW_TP_CONNECTION_ADMIN: + case MySqlParser.KW_WEIGHT_STRING: + case MySqlParser.MOD: + case MySqlParser.CHARSET_REVERSE_QOUTE_STRING: + case MySqlParser.STRING_LITERAL: + case MySqlParser.ID: + { + this.state = 2921; + this.partitionNames(); + } + break; + case MySqlParser.KW_ALL: + { + this.state = 2922; + this.match(MySqlParser.KW_ALL); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + break; + case MySqlParser.KW_COALESCE: + localContext = new AlterByCoalescePartitionContext(localContext); + this.enterOuterAlt(localContext, 6); + { + this.state = 2925; + this.match(MySqlParser.KW_COALESCE); + this.state = 2926; + this.match(MySqlParser.KW_PARTITION); + this.state = 2927; + this.decimalLiteral(); + } + break; + case MySqlParser.KW_REORGANIZE: + localContext = new AlterByReorganizePartitionContext(localContext); + this.enterOuterAlt(localContext, 7); + { + this.state = 2928; + this.match(MySqlParser.KW_REORGANIZE); + this.state = 2929; + this.match(MySqlParser.KW_PARTITION); + this.state = 2930; + this.partitionNames(); + this.state = 2931; + this.match(MySqlParser.KW_INTO); + this.state = 2932; + this.match(MySqlParser.LR_BRACKET); + this.state = 2933; + this.partitionDefinition(); + this.state = 2938; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 2934; + this.match(MySqlParser.COMMA); + this.state = 2935; + this.partitionDefinition(); + } + } + this.state = 2940; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 2941; + this.match(MySqlParser.RR_BRACKET); + } + break; + case MySqlParser.KW_EXCHANGE: + localContext = new AlterByExchangePartitionContext(localContext); + this.enterOuterAlt(localContext, 8); + { + this.state = 2943; + this.match(MySqlParser.KW_EXCHANGE); + this.state = 2944; + this.match(MySqlParser.KW_PARTITION); + this.state = 2945; + this.partitionName(); + this.state = 2946; + this.match(MySqlParser.KW_WITH); + this.state = 2947; + this.match(MySqlParser.KW_TABLE); + this.state = 2948; + this.tableName(); + this.state = 2951; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 354, this.context)) { + case 1: + { + this.state = 2949; + localContext._validationFormat = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 194 || _la === 690)) { + localContext._validationFormat = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 2950; + this.match(MySqlParser.KW_VALIDATION); + } + break; + } + } + break; + case MySqlParser.KW_ANALYZE: + localContext = new AlterByAnalyzePartitionContext(localContext); + this.enterOuterAlt(localContext, 9); + { + this.state = 2953; + this.match(MySqlParser.KW_ANALYZE); + this.state = 2954; + this.match(MySqlParser.KW_PARTITION); + this.state = 2957; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_ARRAY: + case MySqlParser.KW_ATTRIBUTE: + case MySqlParser.KW_BUCKETS: + case MySqlParser.KW_CONDITION: + case MySqlParser.KW_CURRENT: + case MySqlParser.KW_CURRENT_USER: + case MySqlParser.KW_DATABASE: + case MySqlParser.KW_DEFAULT: + case MySqlParser.KW_DIAGNOSTICS: + case MySqlParser.KW_EMPTY: + case MySqlParser.KW_ENFORCED: + case MySqlParser.KW_EXCEPT: + case MySqlParser.KW_GROUP: + case MySqlParser.KW_IF: + case MySqlParser.KW_INSERT: + case MySqlParser.KW_LATERAL: + case MySqlParser.KW_LEFT: + case MySqlParser.KW_NUMBER: + case MySqlParser.KW_OPTIONAL: + case MySqlParser.KW_ORDER: + case MySqlParser.KW_PRIMARY: + case MySqlParser.KW_REPEAT: + case MySqlParser.KW_REPLACE: + case MySqlParser.KW_RIGHT: + case MySqlParser.KW_SCHEMA: + case MySqlParser.KW_SKIP_QUERY_REWRITE: + case MySqlParser.KW_STACKED: + case MySqlParser.KW_DATE: + case MySqlParser.KW_TIME: + case MySqlParser.KW_TIMESTAMP: + case MySqlParser.KW_DATETIME: + case MySqlParser.KW_YEAR: + case MySqlParser.KW_BINARY: + case MySqlParser.KW_TEXT: + case MySqlParser.KW_ENUM: + case MySqlParser.KW_SERIAL: + case MySqlParser.KW_JSON_TABLE: + case MySqlParser.KW_JSON_VALUE: + case MySqlParser.KW_NESTED: + case MySqlParser.KW_ORDINALITY: + case MySqlParser.KW_PATH: + case MySqlParser.KW_AVG: + case MySqlParser.KW_BIT_AND: + case MySqlParser.KW_BIT_OR: + case MySqlParser.KW_BIT_XOR: + case MySqlParser.KW_COUNT: + case MySqlParser.KW_CUME_DIST: + case MySqlParser.KW_DENSE_RANK: + case MySqlParser.KW_FIRST_VALUE: + case MySqlParser.KW_GROUP_CONCAT: + case MySqlParser.KW_LAG: + case MySqlParser.KW_LAST_VALUE: + case MySqlParser.KW_LEAD: + case MySqlParser.KW_MAX: + case MySqlParser.KW_MIN: + case MySqlParser.KW_NTILE: + case MySqlParser.KW_NTH_VALUE: + case MySqlParser.KW_PERCENT_RANK: + case MySqlParser.KW_RANK: + case MySqlParser.KW_ROW_NUMBER: + case MySqlParser.KW_STD: + case MySqlParser.KW_STDDEV: + case MySqlParser.KW_STDDEV_POP: + case MySqlParser.KW_STDDEV_SAMP: + case MySqlParser.KW_SUM: + case MySqlParser.KW_VAR_POP: + case MySqlParser.KW_VAR_SAMP: + case MySqlParser.KW_VARIANCE: + case MySqlParser.KW_CURRENT_DATE: + case MySqlParser.KW_CURRENT_TIME: + case MySqlParser.KW_CURRENT_TIMESTAMP: + case MySqlParser.KW_LOCALTIME: + case MySqlParser.KW_CURDATE: + case MySqlParser.KW_CURTIME: + case MySqlParser.KW_DATE_ADD: + case MySqlParser.KW_DATE_SUB: + case MySqlParser.KW_LOCALTIMESTAMP: + case MySqlParser.KW_NOW: + case MySqlParser.KW_POSITION: + case MySqlParser.KW_SUBSTR: + case MySqlParser.KW_SUBSTRING: + case MySqlParser.KW_SYSDATE: + case MySqlParser.KW_TRIM: + case MySqlParser.KW_UTC_DATE: + case MySqlParser.KW_UTC_TIME: + case MySqlParser.KW_UTC_TIMESTAMP: + case MySqlParser.KW_ACCOUNT: + case MySqlParser.KW_ACTION: + case MySqlParser.KW_AFTER: + case MySqlParser.KW_AGGREGATE: + case MySqlParser.KW_ALGORITHM: + case MySqlParser.KW_ANY: + case MySqlParser.KW_AT: + case MySqlParser.KW_AUTHORS: + case MySqlParser.KW_AUTOCOMMIT: + case MySqlParser.KW_AUTOEXTEND_SIZE: + case MySqlParser.KW_AUTO_INCREMENT: + case MySqlParser.KW_AVG_ROW_LENGTH: + case MySqlParser.KW_BEGIN: + case MySqlParser.KW_BINLOG: + case MySqlParser.KW_BIT: + case MySqlParser.KW_BLOCK: + case MySqlParser.KW_BOOL: + case MySqlParser.KW_BOOLEAN: + case MySqlParser.KW_BTREE: + case MySqlParser.KW_CACHE: + case MySqlParser.KW_CASCADED: + case MySqlParser.KW_CHAIN: + case MySqlParser.KW_CHANGED: + case MySqlParser.KW_CHANNEL: + case MySqlParser.KW_CHECKSUM: + case MySqlParser.KW_CIPHER: + case MySqlParser.KW_CLASS_ORIGIN: + case MySqlParser.KW_CLIENT: + case MySqlParser.KW_CLOSE: + case MySqlParser.KW_COALESCE: + case MySqlParser.KW_CODE: + case MySqlParser.KW_COLUMNS: + case MySqlParser.KW_COLUMN_FORMAT: + case MySqlParser.KW_COLUMN_NAME: + case MySqlParser.KW_COMMENT: + case MySqlParser.KW_COMMIT: + case MySqlParser.KW_COMPACT: + case MySqlParser.KW_COMPLETION: + case MySqlParser.KW_COMPRESSED: + case MySqlParser.KW_COMPRESSION: + case MySqlParser.KW_CONCURRENT: + case MySqlParser.KW_CONNECT: + case MySqlParser.KW_CONNECTION: + case MySqlParser.KW_CONSISTENT: + case MySqlParser.KW_CONSTRAINT_CATALOG: + case MySqlParser.KW_CONSTRAINT_SCHEMA: + case MySqlParser.KW_CONSTRAINT_NAME: + case MySqlParser.KW_CONTAINS: + case MySqlParser.KW_CONTEXT: + case MySqlParser.KW_CONTRIBUTORS: + case MySqlParser.KW_COPY: + case MySqlParser.KW_CPU: + case MySqlParser.KW_CURSOR_NAME: + case MySqlParser.KW_DATA: + case MySqlParser.KW_DATAFILE: + case MySqlParser.KW_DEALLOCATE: + case MySqlParser.KW_DEFAULT_AUTH: + case MySqlParser.KW_DEFINER: + case MySqlParser.KW_DELAY_KEY_WRITE: + case MySqlParser.KW_DES_KEY_FILE: + case MySqlParser.KW_DIRECTORY: + case MySqlParser.KW_DISABLE: + case MySqlParser.KW_DISCARD: + case MySqlParser.KW_DISK: + case MySqlParser.KW_DO: + case MySqlParser.KW_DUMPFILE: + case MySqlParser.KW_DUPLICATE: + case MySqlParser.KW_DYNAMIC: + case MySqlParser.KW_ENABLE: + case MySqlParser.KW_ENCRYPTION: + case MySqlParser.KW_END: + case MySqlParser.KW_ENDS: + case MySqlParser.KW_ENGINE: + case MySqlParser.KW_ENGINES: + case MySqlParser.KW_ERROR: + case MySqlParser.KW_ERRORS: + case MySqlParser.KW_ESCAPE: + case MySqlParser.KW_EVENT: + case MySqlParser.KW_EVENTS: + case MySqlParser.KW_EVERY: + case MySqlParser.KW_EXCHANGE: + case MySqlParser.KW_EXCLUSIVE: + case MySqlParser.KW_EXPIRE: + case MySqlParser.KW_EXPORT: + case MySqlParser.KW_EXTENDED: + case MySqlParser.KW_EXTENT_SIZE: + case MySqlParser.KW_FAILED_LOGIN_ATTEMPTS: + case MySqlParser.KW_FAST: + case MySqlParser.KW_FAULTS: + case MySqlParser.KW_FIELDS: + case MySqlParser.KW_FILE_BLOCK_SIZE: + case MySqlParser.KW_FILTER: + case MySqlParser.KW_FIRST: + case MySqlParser.KW_FIXED: + case MySqlParser.KW_FLUSH: + case MySqlParser.KW_FOLLOWS: + case MySqlParser.KW_FOUND: + case MySqlParser.KW_FULL: + case MySqlParser.KW_FUNCTION: + case MySqlParser.KW_GENERAL: + case MySqlParser.KW_GLOBAL: + case MySqlParser.KW_GRANTS: + case MySqlParser.KW_GROUP_REPLICATION: + case MySqlParser.KW_HANDLER: + case MySqlParser.KW_HASH: + case MySqlParser.KW_HELP: + case MySqlParser.KW_HISTORY: + case MySqlParser.KW_HOST: + case MySqlParser.KW_HOSTS: + case MySqlParser.KW_IDENTIFIED: + case MySqlParser.KW_IGNORE_SERVER_IDS: + case MySqlParser.KW_IMPORT: + case MySqlParser.KW_INDEXES: + case MySqlParser.KW_INITIAL_SIZE: + case MySqlParser.KW_INPLACE: + case MySqlParser.KW_INSERT_METHOD: + case MySqlParser.KW_INSTALL: + case MySqlParser.KW_INSTANCE: + case MySqlParser.KW_INSTANT: + case MySqlParser.KW_INVISIBLE: + case MySqlParser.KW_INVOKER: + case MySqlParser.KW_IO: + case MySqlParser.KW_IO_THREAD: + case MySqlParser.KW_IPC: + case MySqlParser.KW_ISOLATION: + case MySqlParser.KW_ISSUER: + case MySqlParser.KW_JSON: + case MySqlParser.KW_KEY_BLOCK_SIZE: + case MySqlParser.KW_LANGUAGE: + case MySqlParser.KW_LAST: + case MySqlParser.KW_LEAVES: + case MySqlParser.KW_LESS: + case MySqlParser.KW_LEVEL: + case MySqlParser.KW_LIST: + case MySqlParser.KW_LOCAL: + case MySqlParser.KW_LOGFILE: + case MySqlParser.KW_LOGS: + case MySqlParser.KW_MASTER: + case MySqlParser.KW_MASTER_AUTO_POSITION: + case MySqlParser.KW_MASTER_CONNECT_RETRY: + case MySqlParser.KW_MASTER_DELAY: + case MySqlParser.KW_MASTER_HEARTBEAT_PERIOD: + case MySqlParser.KW_MASTER_HOST: + case MySqlParser.KW_MASTER_LOG_FILE: + case MySqlParser.KW_MASTER_LOG_POS: + case MySqlParser.KW_MASTER_PASSWORD: + case MySqlParser.KW_MASTER_PORT: + case MySqlParser.KW_MASTER_RETRY_COUNT: + case MySqlParser.KW_MASTER_SSL: + case MySqlParser.KW_MASTER_SSL_CA: + case MySqlParser.KW_MASTER_SSL_CAPATH: + case MySqlParser.KW_MASTER_SSL_CERT: + case MySqlParser.KW_MASTER_SSL_CIPHER: + case MySqlParser.KW_MASTER_SSL_CRL: + case MySqlParser.KW_MASTER_SSL_CRLPATH: + case MySqlParser.KW_MASTER_SSL_KEY: + case MySqlParser.KW_MASTER_TLS_VERSION: + case MySqlParser.KW_MASTER_USER: + case MySqlParser.KW_MAX_CONNECTIONS_PER_HOUR: + case MySqlParser.KW_MAX_QUERIES_PER_HOUR: + case MySqlParser.KW_MAX_ROWS: + case MySqlParser.KW_MAX_SIZE: + case MySqlParser.KW_MAX_UPDATES_PER_HOUR: + case MySqlParser.KW_MAX_USER_CONNECTIONS: + case MySqlParser.KW_MEDIUM: + case MySqlParser.KW_MEMBER: + case MySqlParser.KW_MERGE: + case MySqlParser.KW_MESSAGE_TEXT: + case MySqlParser.KW_MID: + case MySqlParser.KW_MIGRATE: + case MySqlParser.KW_MIN_ROWS: + case MySqlParser.KW_MODE: + case MySqlParser.KW_MODIFY: + case MySqlParser.KW_MUTEX: + case MySqlParser.KW_MYSQL: + case MySqlParser.KW_MYSQL_ERRNO: + case MySqlParser.KW_NAME: + case MySqlParser.KW_NAMES: + case MySqlParser.KW_NCHAR: + case MySqlParser.KW_NEVER: + case MySqlParser.KW_NEXT: + case MySqlParser.KW_NO: + case MySqlParser.KW_NOWAIT: + case MySqlParser.KW_NODEGROUP: + case MySqlParser.KW_NONE: + case MySqlParser.KW_ODBC: + case MySqlParser.KW_OFFLINE: + case MySqlParser.KW_OFFSET: + case MySqlParser.KW_OF: + case MySqlParser.KW_OLD_PASSWORD: + case MySqlParser.KW_ONE: + case MySqlParser.KW_ONLINE: + case MySqlParser.KW_ONLY: + case MySqlParser.KW_OPEN: + case MySqlParser.KW_OPTIMIZER_COSTS: + case MySqlParser.KW_OPTIONS: + case MySqlParser.KW_OWNER: + case MySqlParser.KW_PACK_KEYS: + case MySqlParser.KW_PAGE: + case MySqlParser.KW_PAGE_CHECKSUM: + case MySqlParser.KW_PARSER: + case MySqlParser.KW_PARTIAL: + case MySqlParser.KW_PARTITIONING: + case MySqlParser.KW_PARTITIONS: + case MySqlParser.KW_PASSWORD: + case MySqlParser.KW_PASSWORD_LOCK_TIME: + case MySqlParser.KW_PHASE: + case MySqlParser.KW_PLUGIN: + case MySqlParser.KW_PLUGIN_DIR: + case MySqlParser.KW_PLUGINS: + case MySqlParser.KW_PORT: + case MySqlParser.KW_PRECEDES: + case MySqlParser.KW_PREPARE: + case MySqlParser.KW_PRESERVE: + case MySqlParser.KW_PREV: + case MySqlParser.KW_PROCESSLIST: + case MySqlParser.KW_PROFILE: + case MySqlParser.KW_PROFILES: + case MySqlParser.KW_PROXY: + case MySqlParser.KW_QUERY: + case MySqlParser.KW_QUICK: + case MySqlParser.KW_REBUILD: + case MySqlParser.KW_RECOVER: + case MySqlParser.KW_RECURSIVE: + case MySqlParser.KW_REDO_BUFFER_SIZE: + case MySqlParser.KW_REDUNDANT: + case MySqlParser.KW_RELAY: + case MySqlParser.KW_RELAY_LOG_FILE: + case MySqlParser.KW_RELAY_LOG_POS: + case MySqlParser.KW_RELAYLOG: + case MySqlParser.KW_REMOVE: + case MySqlParser.KW_REORGANIZE: + case MySqlParser.KW_REPAIR: + case MySqlParser.KW_REPLICATE_DO_DB: + case MySqlParser.KW_REPLICATE_DO_TABLE: + case MySqlParser.KW_REPLICATE_IGNORE_DB: + case MySqlParser.KW_REPLICATE_IGNORE_TABLE: + case MySqlParser.KW_REPLICATE_REWRITE_DB: + case MySqlParser.KW_REPLICATE_WILD_DO_TABLE: + case MySqlParser.KW_REPLICATE_WILD_IGNORE_TABLE: + case MySqlParser.KW_REPLICATION: + case MySqlParser.KW_RESET: + case MySqlParser.KW_RESUME: + case MySqlParser.KW_RETURNED_SQLSTATE: + case MySqlParser.KW_RETURNS: + case MySqlParser.KW_REUSE: + case MySqlParser.KW_ROLE: + case MySqlParser.KW_ROLLBACK: + case MySqlParser.KW_ROLLUP: + case MySqlParser.KW_ROTATE: + case MySqlParser.KW_ROW: + case MySqlParser.KW_ROWS: + case MySqlParser.KW_ROW_FORMAT: + case MySqlParser.KW_SAVEPOINT: + case MySqlParser.KW_SCHEDULE: + case MySqlParser.KW_SECURITY: + case MySqlParser.KW_SERVER: + case MySqlParser.KW_SESSION: + case MySqlParser.KW_SHARE: + case MySqlParser.KW_SHARED: + case MySqlParser.KW_SIGNED: + case MySqlParser.KW_SIMPLE: + case MySqlParser.KW_SLAVE: + case MySqlParser.KW_SLOW: + case MySqlParser.KW_SNAPSHOT: + case MySqlParser.KW_SOCKET: + case MySqlParser.KW_SOME: + case MySqlParser.KW_SONAME: + case MySqlParser.KW_SOUNDS: + case MySqlParser.KW_SOURCE: + case MySqlParser.KW_SQL_AFTER_GTIDS: + case MySqlParser.KW_SQL_AFTER_MTS_GAPS: + case MySqlParser.KW_SQL_BEFORE_GTIDS: + case MySqlParser.KW_SQL_BUFFER_RESULT: + case MySqlParser.KW_SQL_CACHE: + case MySqlParser.KW_SQL_NO_CACHE: + case MySqlParser.KW_SQL_THREAD: + case MySqlParser.KW_START: + case MySqlParser.KW_STARTS: + case MySqlParser.KW_STATS_AUTO_RECALC: + case MySqlParser.KW_STATS_PERSISTENT: + case MySqlParser.KW_STATS_SAMPLE_PAGES: + case MySqlParser.KW_STATUS: + case MySqlParser.KW_STOP: + case MySqlParser.KW_STORAGE: + case MySqlParser.KW_STRING: + case MySqlParser.KW_SUBCLASS_ORIGIN: + case MySqlParser.KW_SUBJECT: + case MySqlParser.KW_SUBPARTITION: + case MySqlParser.KW_SUBPARTITIONS: + case MySqlParser.KW_SUSPEND: + case MySqlParser.KW_SWAPS: + case MySqlParser.KW_SWITCHES: + case MySqlParser.KW_TABLE_NAME: + case MySqlParser.KW_TABLESPACE: + case MySqlParser.KW_TABLE_TYPE: + case MySqlParser.KW_TEMPORARY: + case MySqlParser.KW_TEMPTABLE: + case MySqlParser.KW_THAN: + case MySqlParser.KW_TRADITIONAL: + case MySqlParser.KW_TRANSACTION: + case MySqlParser.KW_TRANSACTIONAL: + case MySqlParser.KW_TRIGGERS: + case MySqlParser.KW_TRUNCATE: + case MySqlParser.KW_UNBOUNDED: + case MySqlParser.KW_UNDEFINED: + case MySqlParser.KW_UNDOFILE: + case MySqlParser.KW_UNDO_BUFFER_SIZE: + case MySqlParser.KW_UNINSTALL: + case MySqlParser.KW_UNKNOWN: + case MySqlParser.KW_UNTIL: + case MySqlParser.KW_UPGRADE: + case MySqlParser.KW_USER: + case MySqlParser.KW_USE_FRM: + case MySqlParser.KW_USER_RESOURCES: + case MySqlParser.KW_VALIDATION: + case MySqlParser.KW_VALUE: + case MySqlParser.KW_VARIABLES: + case MySqlParser.KW_VIEW: + case MySqlParser.KW_VIRTUAL: + case MySqlParser.KW_VISIBLE: + case MySqlParser.KW_WAIT: + case MySqlParser.KW_WARNINGS: + case MySqlParser.KW_WITHOUT: + case MySqlParser.KW_WORK: + case MySqlParser.KW_WRAPPER: + case MySqlParser.KW_X509: + case MySqlParser.KW_XA: + case MySqlParser.KW_XML: + case MySqlParser.KW_QUARTER: + case MySqlParser.KW_MONTH: + case MySqlParser.KW_DAY: + case MySqlParser.KW_HOUR: + case MySqlParser.KW_MINUTE: + case MySqlParser.KW_WEEK: + case MySqlParser.KW_SECOND: + case MySqlParser.KW_MICROSECOND: + case MySqlParser.KW_ADMIN: + case MySqlParser.KW_AUDIT_ABORT_EXEMPT: + case MySqlParser.KW_AUDIT_ADMIN: + case MySqlParser.KW_AUTHENTICATION_POLICY_ADMIN: + case MySqlParser.KW_BACKUP_ADMIN: + case MySqlParser.KW_BINLOG_ADMIN: + case MySqlParser.KW_BINLOG_ENCRYPTION_ADMIN: + case MySqlParser.KW_CLONE_ADMIN: + case MySqlParser.KW_CONNECTION_ADMIN: + case MySqlParser.KW_ENCRYPTION_KEY_ADMIN: + case MySqlParser.KW_EXECUTE: + case MySqlParser.KW_FILE: + case MySqlParser.KW_FIREWALL_ADMIN: + case MySqlParser.KW_FIREWALL_EXEMPT: + case MySqlParser.KW_FIREWALL_USER: + case MySqlParser.KW_GROUP_REPLICATION_ADMIN: + case MySqlParser.KW_INNODB_REDO_LOG_ARCHIVE: + case MySqlParser.KW_INVOKE: + case MySqlParser.KW_LAMBDA: + case MySqlParser.KW_NDB_STORED_USER: + case MySqlParser.KW_PASSWORDLESS_USER_ADMIN: + case MySqlParser.KW_PERSIST_RO_VARIABLES_ADMIN: + case MySqlParser.KW_PRIVILEGES: + case MySqlParser.KW_PROCESS: + case MySqlParser.KW_RELOAD: + case MySqlParser.KW_REPLICATION_APPLIER: + case MySqlParser.KW_REPLICATION_SLAVE_ADMIN: + case MySqlParser.KW_RESOURCE_GROUP_ADMIN: + case MySqlParser.KW_RESOURCE_GROUP_USER: + case MySqlParser.KW_ROLE_ADMIN: + case MySqlParser.KW_ROUTINE: + case MySqlParser.KW_S3: + case MySqlParser.KW_SESSION_VARIABLES_ADMIN: + case MySqlParser.KW_SET_USER_ID: + case MySqlParser.KW_SHOW_ROUTINE: + case MySqlParser.KW_SHUTDOWN: + case MySqlParser.KW_SUPER: + case MySqlParser.KW_SYSTEM_VARIABLES_ADMIN: + case MySqlParser.KW_TABLES: + case MySqlParser.KW_TABLE_ENCRYPTION_ADMIN: + case MySqlParser.KW_VERSION_TOKEN_ADMIN: + case MySqlParser.KW_XA_RECOVER_ADMIN: + case MySqlParser.KW_ARMSCII8: + case MySqlParser.KW_ASCII: + case MySqlParser.KW_BIG5: + case MySqlParser.KW_CP1250: + case MySqlParser.KW_CP1251: + case MySqlParser.KW_CP1256: + case MySqlParser.KW_CP1257: + case MySqlParser.KW_CP850: + case MySqlParser.KW_CP852: + case MySqlParser.KW_CP866: + case MySqlParser.KW_CP932: + case MySqlParser.KW_DEC8: + case MySqlParser.KW_EUCJPMS: + case MySqlParser.KW_EUCKR: + case MySqlParser.KW_GB18030: + case MySqlParser.KW_GB2312: + case MySqlParser.KW_GBK: + case MySqlParser.KW_GEOSTD8: + case MySqlParser.KW_GREEK: + case MySqlParser.KW_HEBREW: + case MySqlParser.KW_HP8: + case MySqlParser.KW_KEYBCS2: + case MySqlParser.KW_KOI8R: + case MySqlParser.KW_KOI8U: + case MySqlParser.KW_LATIN1: + case MySqlParser.KW_LATIN2: + case MySqlParser.KW_LATIN5: + case MySqlParser.KW_LATIN7: + case MySqlParser.KW_MACCE: + case MySqlParser.KW_MACROMAN: + case MySqlParser.KW_SJIS: + case MySqlParser.KW_SWE7: + case MySqlParser.KW_TIS620: + case MySqlParser.KW_UCS2: + case MySqlParser.KW_UJIS: + case MySqlParser.KW_UTF16: + case MySqlParser.KW_UTF16LE: + case MySqlParser.KW_UTF32: + case MySqlParser.KW_UTF8: + case MySqlParser.KW_UTF8MB3: + case MySqlParser.KW_UTF8MB4: + case MySqlParser.KW_ARCHIVE: + case MySqlParser.KW_BLACKHOLE: + case MySqlParser.KW_CSV: + case MySqlParser.KW_FEDERATED: + case MySqlParser.KW_INNODB: + case MySqlParser.KW_MEMORY: + case MySqlParser.KW_MRG_MYISAM: + case MySqlParser.KW_MYISAM: + case MySqlParser.KW_NDB: + case MySqlParser.KW_NDBCLUSTER: + case MySqlParser.KW_PERFORMANCE_SCHEMA: + case MySqlParser.KW_TOKUDB: + case MySqlParser.KW_REPEATABLE: + case MySqlParser.KW_COMMITTED: + case MySqlParser.KW_UNCOMMITTED: + case MySqlParser.KW_SERIALIZABLE: + case MySqlParser.KW_GEOMETRYCOLLECTION: + case MySqlParser.KW_LINESTRING: + case MySqlParser.KW_MULTILINESTRING: + case MySqlParser.KW_MULTIPOINT: + case MySqlParser.KW_MULTIPOLYGON: + case MySqlParser.KW_POINT: + case MySqlParser.KW_POLYGON: + case MySqlParser.KW_CATALOG_NAME: + case MySqlParser.KW_CHARSET: + case MySqlParser.KW_COLLATION: + case MySqlParser.KW_ENGINE_ATTRIBUTE: + case MySqlParser.KW_FORMAT: + case MySqlParser.KW_GET_FORMAT: + case MySqlParser.KW_RANDOM: + case MySqlParser.KW_REVERSE: + case MySqlParser.KW_ROW_COUNT: + case MySqlParser.KW_SCHEMA_NAME: + case MySqlParser.KW_SECONDARY_ENGINE_ATTRIBUTE: + case MySqlParser.KW_SRID: + case MySqlParser.KW_SYSTEM_USER: + case MySqlParser.KW_TP_CONNECTION_ADMIN: + case MySqlParser.KW_WEIGHT_STRING: + case MySqlParser.MOD: + case MySqlParser.CHARSET_REVERSE_QOUTE_STRING: + case MySqlParser.STRING_LITERAL: + case MySqlParser.ID: + { + this.state = 2955; + this.partitionNames(); + } + break; + case MySqlParser.KW_ALL: + { + this.state = 2956; + this.match(MySqlParser.KW_ALL); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + break; + case MySqlParser.KW_CHECK: + localContext = new AlterByCheckPartitionContext(localContext); + this.enterOuterAlt(localContext, 10); + { + this.state = 2959; + this.match(MySqlParser.KW_CHECK); + this.state = 2960; + this.match(MySqlParser.KW_PARTITION); + this.state = 2963; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_ARRAY: + case MySqlParser.KW_ATTRIBUTE: + case MySqlParser.KW_BUCKETS: + case MySqlParser.KW_CONDITION: + case MySqlParser.KW_CURRENT: + case MySqlParser.KW_CURRENT_USER: + case MySqlParser.KW_DATABASE: + case MySqlParser.KW_DEFAULT: + case MySqlParser.KW_DIAGNOSTICS: + case MySqlParser.KW_EMPTY: + case MySqlParser.KW_ENFORCED: + case MySqlParser.KW_EXCEPT: + case MySqlParser.KW_GROUP: + case MySqlParser.KW_IF: + case MySqlParser.KW_INSERT: + case MySqlParser.KW_LATERAL: + case MySqlParser.KW_LEFT: + case MySqlParser.KW_NUMBER: + case MySqlParser.KW_OPTIONAL: + case MySqlParser.KW_ORDER: + case MySqlParser.KW_PRIMARY: + case MySqlParser.KW_REPEAT: + case MySqlParser.KW_REPLACE: + case MySqlParser.KW_RIGHT: + case MySqlParser.KW_SCHEMA: + case MySqlParser.KW_SKIP_QUERY_REWRITE: + case MySqlParser.KW_STACKED: + case MySqlParser.KW_DATE: + case MySqlParser.KW_TIME: + case MySqlParser.KW_TIMESTAMP: + case MySqlParser.KW_DATETIME: + case MySqlParser.KW_YEAR: + case MySqlParser.KW_BINARY: + case MySqlParser.KW_TEXT: + case MySqlParser.KW_ENUM: + case MySqlParser.KW_SERIAL: + case MySqlParser.KW_JSON_TABLE: + case MySqlParser.KW_JSON_VALUE: + case MySqlParser.KW_NESTED: + case MySqlParser.KW_ORDINALITY: + case MySqlParser.KW_PATH: + case MySqlParser.KW_AVG: + case MySqlParser.KW_BIT_AND: + case MySqlParser.KW_BIT_OR: + case MySqlParser.KW_BIT_XOR: + case MySqlParser.KW_COUNT: + case MySqlParser.KW_CUME_DIST: + case MySqlParser.KW_DENSE_RANK: + case MySqlParser.KW_FIRST_VALUE: + case MySqlParser.KW_GROUP_CONCAT: + case MySqlParser.KW_LAG: + case MySqlParser.KW_LAST_VALUE: + case MySqlParser.KW_LEAD: + case MySqlParser.KW_MAX: + case MySqlParser.KW_MIN: + case MySqlParser.KW_NTILE: + case MySqlParser.KW_NTH_VALUE: + case MySqlParser.KW_PERCENT_RANK: + case MySqlParser.KW_RANK: + case MySqlParser.KW_ROW_NUMBER: + case MySqlParser.KW_STD: + case MySqlParser.KW_STDDEV: + case MySqlParser.KW_STDDEV_POP: + case MySqlParser.KW_STDDEV_SAMP: + case MySqlParser.KW_SUM: + case MySqlParser.KW_VAR_POP: + case MySqlParser.KW_VAR_SAMP: + case MySqlParser.KW_VARIANCE: + case MySqlParser.KW_CURRENT_DATE: + case MySqlParser.KW_CURRENT_TIME: + case MySqlParser.KW_CURRENT_TIMESTAMP: + case MySqlParser.KW_LOCALTIME: + case MySqlParser.KW_CURDATE: + case MySqlParser.KW_CURTIME: + case MySqlParser.KW_DATE_ADD: + case MySqlParser.KW_DATE_SUB: + case MySqlParser.KW_LOCALTIMESTAMP: + case MySqlParser.KW_NOW: + case MySqlParser.KW_POSITION: + case MySqlParser.KW_SUBSTR: + case MySqlParser.KW_SUBSTRING: + case MySqlParser.KW_SYSDATE: + case MySqlParser.KW_TRIM: + case MySqlParser.KW_UTC_DATE: + case MySqlParser.KW_UTC_TIME: + case MySqlParser.KW_UTC_TIMESTAMP: + case MySqlParser.KW_ACCOUNT: + case MySqlParser.KW_ACTION: + case MySqlParser.KW_AFTER: + case MySqlParser.KW_AGGREGATE: + case MySqlParser.KW_ALGORITHM: + case MySqlParser.KW_ANY: + case MySqlParser.KW_AT: + case MySqlParser.KW_AUTHORS: + case MySqlParser.KW_AUTOCOMMIT: + case MySqlParser.KW_AUTOEXTEND_SIZE: + case MySqlParser.KW_AUTO_INCREMENT: + case MySqlParser.KW_AVG_ROW_LENGTH: + case MySqlParser.KW_BEGIN: + case MySqlParser.KW_BINLOG: + case MySqlParser.KW_BIT: + case MySqlParser.KW_BLOCK: + case MySqlParser.KW_BOOL: + case MySqlParser.KW_BOOLEAN: + case MySqlParser.KW_BTREE: + case MySqlParser.KW_CACHE: + case MySqlParser.KW_CASCADED: + case MySqlParser.KW_CHAIN: + case MySqlParser.KW_CHANGED: + case MySqlParser.KW_CHANNEL: + case MySqlParser.KW_CHECKSUM: + case MySqlParser.KW_CIPHER: + case MySqlParser.KW_CLASS_ORIGIN: + case MySqlParser.KW_CLIENT: + case MySqlParser.KW_CLOSE: + case MySqlParser.KW_COALESCE: + case MySqlParser.KW_CODE: + case MySqlParser.KW_COLUMNS: + case MySqlParser.KW_COLUMN_FORMAT: + case MySqlParser.KW_COLUMN_NAME: + case MySqlParser.KW_COMMENT: + case MySqlParser.KW_COMMIT: + case MySqlParser.KW_COMPACT: + case MySqlParser.KW_COMPLETION: + case MySqlParser.KW_COMPRESSED: + case MySqlParser.KW_COMPRESSION: + case MySqlParser.KW_CONCURRENT: + case MySqlParser.KW_CONNECT: + case MySqlParser.KW_CONNECTION: + case MySqlParser.KW_CONSISTENT: + case MySqlParser.KW_CONSTRAINT_CATALOG: + case MySqlParser.KW_CONSTRAINT_SCHEMA: + case MySqlParser.KW_CONSTRAINT_NAME: + case MySqlParser.KW_CONTAINS: + case MySqlParser.KW_CONTEXT: + case MySqlParser.KW_CONTRIBUTORS: + case MySqlParser.KW_COPY: + case MySqlParser.KW_CPU: + case MySqlParser.KW_CURSOR_NAME: + case MySqlParser.KW_DATA: + case MySqlParser.KW_DATAFILE: + case MySqlParser.KW_DEALLOCATE: + case MySqlParser.KW_DEFAULT_AUTH: + case MySqlParser.KW_DEFINER: + case MySqlParser.KW_DELAY_KEY_WRITE: + case MySqlParser.KW_DES_KEY_FILE: + case MySqlParser.KW_DIRECTORY: + case MySqlParser.KW_DISABLE: + case MySqlParser.KW_DISCARD: + case MySqlParser.KW_DISK: + case MySqlParser.KW_DO: + case MySqlParser.KW_DUMPFILE: + case MySqlParser.KW_DUPLICATE: + case MySqlParser.KW_DYNAMIC: + case MySqlParser.KW_ENABLE: + case MySqlParser.KW_ENCRYPTION: + case MySqlParser.KW_END: + case MySqlParser.KW_ENDS: + case MySqlParser.KW_ENGINE: + case MySqlParser.KW_ENGINES: + case MySqlParser.KW_ERROR: + case MySqlParser.KW_ERRORS: + case MySqlParser.KW_ESCAPE: + case MySqlParser.KW_EVENT: + case MySqlParser.KW_EVENTS: + case MySqlParser.KW_EVERY: + case MySqlParser.KW_EXCHANGE: + case MySqlParser.KW_EXCLUSIVE: + case MySqlParser.KW_EXPIRE: + case MySqlParser.KW_EXPORT: + case MySqlParser.KW_EXTENDED: + case MySqlParser.KW_EXTENT_SIZE: + case MySqlParser.KW_FAILED_LOGIN_ATTEMPTS: + case MySqlParser.KW_FAST: + case MySqlParser.KW_FAULTS: + case MySqlParser.KW_FIELDS: + case MySqlParser.KW_FILE_BLOCK_SIZE: + case MySqlParser.KW_FILTER: + case MySqlParser.KW_FIRST: + case MySqlParser.KW_FIXED: + case MySqlParser.KW_FLUSH: + case MySqlParser.KW_FOLLOWS: + case MySqlParser.KW_FOUND: + case MySqlParser.KW_FULL: + case MySqlParser.KW_FUNCTION: + case MySqlParser.KW_GENERAL: + case MySqlParser.KW_GLOBAL: + case MySqlParser.KW_GRANTS: + case MySqlParser.KW_GROUP_REPLICATION: + case MySqlParser.KW_HANDLER: + case MySqlParser.KW_HASH: + case MySqlParser.KW_HELP: + case MySqlParser.KW_HISTORY: + case MySqlParser.KW_HOST: + case MySqlParser.KW_HOSTS: + case MySqlParser.KW_IDENTIFIED: + case MySqlParser.KW_IGNORE_SERVER_IDS: + case MySqlParser.KW_IMPORT: + case MySqlParser.KW_INDEXES: + case MySqlParser.KW_INITIAL_SIZE: + case MySqlParser.KW_INPLACE: + case MySqlParser.KW_INSERT_METHOD: + case MySqlParser.KW_INSTALL: + case MySqlParser.KW_INSTANCE: + case MySqlParser.KW_INSTANT: + case MySqlParser.KW_INVISIBLE: + case MySqlParser.KW_INVOKER: + case MySqlParser.KW_IO: + case MySqlParser.KW_IO_THREAD: + case MySqlParser.KW_IPC: + case MySqlParser.KW_ISOLATION: + case MySqlParser.KW_ISSUER: + case MySqlParser.KW_JSON: + case MySqlParser.KW_KEY_BLOCK_SIZE: + case MySqlParser.KW_LANGUAGE: + case MySqlParser.KW_LAST: + case MySqlParser.KW_LEAVES: + case MySqlParser.KW_LESS: + case MySqlParser.KW_LEVEL: + case MySqlParser.KW_LIST: + case MySqlParser.KW_LOCAL: + case MySqlParser.KW_LOGFILE: + case MySqlParser.KW_LOGS: + case MySqlParser.KW_MASTER: + case MySqlParser.KW_MASTER_AUTO_POSITION: + case MySqlParser.KW_MASTER_CONNECT_RETRY: + case MySqlParser.KW_MASTER_DELAY: + case MySqlParser.KW_MASTER_HEARTBEAT_PERIOD: + case MySqlParser.KW_MASTER_HOST: + case MySqlParser.KW_MASTER_LOG_FILE: + case MySqlParser.KW_MASTER_LOG_POS: + case MySqlParser.KW_MASTER_PASSWORD: + case MySqlParser.KW_MASTER_PORT: + case MySqlParser.KW_MASTER_RETRY_COUNT: + case MySqlParser.KW_MASTER_SSL: + case MySqlParser.KW_MASTER_SSL_CA: + case MySqlParser.KW_MASTER_SSL_CAPATH: + case MySqlParser.KW_MASTER_SSL_CERT: + case MySqlParser.KW_MASTER_SSL_CIPHER: + case MySqlParser.KW_MASTER_SSL_CRL: + case MySqlParser.KW_MASTER_SSL_CRLPATH: + case MySqlParser.KW_MASTER_SSL_KEY: + case MySqlParser.KW_MASTER_TLS_VERSION: + case MySqlParser.KW_MASTER_USER: + case MySqlParser.KW_MAX_CONNECTIONS_PER_HOUR: + case MySqlParser.KW_MAX_QUERIES_PER_HOUR: + case MySqlParser.KW_MAX_ROWS: + case MySqlParser.KW_MAX_SIZE: + case MySqlParser.KW_MAX_UPDATES_PER_HOUR: + case MySqlParser.KW_MAX_USER_CONNECTIONS: + case MySqlParser.KW_MEDIUM: + case MySqlParser.KW_MEMBER: + case MySqlParser.KW_MERGE: + case MySqlParser.KW_MESSAGE_TEXT: + case MySqlParser.KW_MID: + case MySqlParser.KW_MIGRATE: + case MySqlParser.KW_MIN_ROWS: + case MySqlParser.KW_MODE: + case MySqlParser.KW_MODIFY: + case MySqlParser.KW_MUTEX: + case MySqlParser.KW_MYSQL: + case MySqlParser.KW_MYSQL_ERRNO: + case MySqlParser.KW_NAME: + case MySqlParser.KW_NAMES: + case MySqlParser.KW_NCHAR: + case MySqlParser.KW_NEVER: + case MySqlParser.KW_NEXT: + case MySqlParser.KW_NO: + case MySqlParser.KW_NOWAIT: + case MySqlParser.KW_NODEGROUP: + case MySqlParser.KW_NONE: + case MySqlParser.KW_ODBC: + case MySqlParser.KW_OFFLINE: + case MySqlParser.KW_OFFSET: + case MySqlParser.KW_OF: + case MySqlParser.KW_OLD_PASSWORD: + case MySqlParser.KW_ONE: + case MySqlParser.KW_ONLINE: + case MySqlParser.KW_ONLY: + case MySqlParser.KW_OPEN: + case MySqlParser.KW_OPTIMIZER_COSTS: + case MySqlParser.KW_OPTIONS: + case MySqlParser.KW_OWNER: + case MySqlParser.KW_PACK_KEYS: + case MySqlParser.KW_PAGE: + case MySqlParser.KW_PAGE_CHECKSUM: + case MySqlParser.KW_PARSER: + case MySqlParser.KW_PARTIAL: + case MySqlParser.KW_PARTITIONING: + case MySqlParser.KW_PARTITIONS: + case MySqlParser.KW_PASSWORD: + case MySqlParser.KW_PASSWORD_LOCK_TIME: + case MySqlParser.KW_PHASE: + case MySqlParser.KW_PLUGIN: + case MySqlParser.KW_PLUGIN_DIR: + case MySqlParser.KW_PLUGINS: + case MySqlParser.KW_PORT: + case MySqlParser.KW_PRECEDES: + case MySqlParser.KW_PREPARE: + case MySqlParser.KW_PRESERVE: + case MySqlParser.KW_PREV: + case MySqlParser.KW_PROCESSLIST: + case MySqlParser.KW_PROFILE: + case MySqlParser.KW_PROFILES: + case MySqlParser.KW_PROXY: + case MySqlParser.KW_QUERY: + case MySqlParser.KW_QUICK: + case MySqlParser.KW_REBUILD: + case MySqlParser.KW_RECOVER: + case MySqlParser.KW_RECURSIVE: + case MySqlParser.KW_REDO_BUFFER_SIZE: + case MySqlParser.KW_REDUNDANT: + case MySqlParser.KW_RELAY: + case MySqlParser.KW_RELAY_LOG_FILE: + case MySqlParser.KW_RELAY_LOG_POS: + case MySqlParser.KW_RELAYLOG: + case MySqlParser.KW_REMOVE: + case MySqlParser.KW_REORGANIZE: + case MySqlParser.KW_REPAIR: + case MySqlParser.KW_REPLICATE_DO_DB: + case MySqlParser.KW_REPLICATE_DO_TABLE: + case MySqlParser.KW_REPLICATE_IGNORE_DB: + case MySqlParser.KW_REPLICATE_IGNORE_TABLE: + case MySqlParser.KW_REPLICATE_REWRITE_DB: + case MySqlParser.KW_REPLICATE_WILD_DO_TABLE: + case MySqlParser.KW_REPLICATE_WILD_IGNORE_TABLE: + case MySqlParser.KW_REPLICATION: + case MySqlParser.KW_RESET: + case MySqlParser.KW_RESUME: + case MySqlParser.KW_RETURNED_SQLSTATE: + case MySqlParser.KW_RETURNS: + case MySqlParser.KW_REUSE: + case MySqlParser.KW_ROLE: + case MySqlParser.KW_ROLLBACK: + case MySqlParser.KW_ROLLUP: + case MySqlParser.KW_ROTATE: + case MySqlParser.KW_ROW: + case MySqlParser.KW_ROWS: + case MySqlParser.KW_ROW_FORMAT: + case MySqlParser.KW_SAVEPOINT: + case MySqlParser.KW_SCHEDULE: + case MySqlParser.KW_SECURITY: + case MySqlParser.KW_SERVER: + case MySqlParser.KW_SESSION: + case MySqlParser.KW_SHARE: + case MySqlParser.KW_SHARED: + case MySqlParser.KW_SIGNED: + case MySqlParser.KW_SIMPLE: + case MySqlParser.KW_SLAVE: + case MySqlParser.KW_SLOW: + case MySqlParser.KW_SNAPSHOT: + case MySqlParser.KW_SOCKET: + case MySqlParser.KW_SOME: + case MySqlParser.KW_SONAME: + case MySqlParser.KW_SOUNDS: + case MySqlParser.KW_SOURCE: + case MySqlParser.KW_SQL_AFTER_GTIDS: + case MySqlParser.KW_SQL_AFTER_MTS_GAPS: + case MySqlParser.KW_SQL_BEFORE_GTIDS: + case MySqlParser.KW_SQL_BUFFER_RESULT: + case MySqlParser.KW_SQL_CACHE: + case MySqlParser.KW_SQL_NO_CACHE: + case MySqlParser.KW_SQL_THREAD: + case MySqlParser.KW_START: + case MySqlParser.KW_STARTS: + case MySqlParser.KW_STATS_AUTO_RECALC: + case MySqlParser.KW_STATS_PERSISTENT: + case MySqlParser.KW_STATS_SAMPLE_PAGES: + case MySqlParser.KW_STATUS: + case MySqlParser.KW_STOP: + case MySqlParser.KW_STORAGE: + case MySqlParser.KW_STRING: + case MySqlParser.KW_SUBCLASS_ORIGIN: + case MySqlParser.KW_SUBJECT: + case MySqlParser.KW_SUBPARTITION: + case MySqlParser.KW_SUBPARTITIONS: + case MySqlParser.KW_SUSPEND: + case MySqlParser.KW_SWAPS: + case MySqlParser.KW_SWITCHES: + case MySqlParser.KW_TABLE_NAME: + case MySqlParser.KW_TABLESPACE: + case MySqlParser.KW_TABLE_TYPE: + case MySqlParser.KW_TEMPORARY: + case MySqlParser.KW_TEMPTABLE: + case MySqlParser.KW_THAN: + case MySqlParser.KW_TRADITIONAL: + case MySqlParser.KW_TRANSACTION: + case MySqlParser.KW_TRANSACTIONAL: + case MySqlParser.KW_TRIGGERS: + case MySqlParser.KW_TRUNCATE: + case MySqlParser.KW_UNBOUNDED: + case MySqlParser.KW_UNDEFINED: + case MySqlParser.KW_UNDOFILE: + case MySqlParser.KW_UNDO_BUFFER_SIZE: + case MySqlParser.KW_UNINSTALL: + case MySqlParser.KW_UNKNOWN: + case MySqlParser.KW_UNTIL: + case MySqlParser.KW_UPGRADE: + case MySqlParser.KW_USER: + case MySqlParser.KW_USE_FRM: + case MySqlParser.KW_USER_RESOURCES: + case MySqlParser.KW_VALIDATION: + case MySqlParser.KW_VALUE: + case MySqlParser.KW_VARIABLES: + case MySqlParser.KW_VIEW: + case MySqlParser.KW_VIRTUAL: + case MySqlParser.KW_VISIBLE: + case MySqlParser.KW_WAIT: + case MySqlParser.KW_WARNINGS: + case MySqlParser.KW_WITHOUT: + case MySqlParser.KW_WORK: + case MySqlParser.KW_WRAPPER: + case MySqlParser.KW_X509: + case MySqlParser.KW_XA: + case MySqlParser.KW_XML: + case MySqlParser.KW_QUARTER: + case MySqlParser.KW_MONTH: + case MySqlParser.KW_DAY: + case MySqlParser.KW_HOUR: + case MySqlParser.KW_MINUTE: + case MySqlParser.KW_WEEK: + case MySqlParser.KW_SECOND: + case MySqlParser.KW_MICROSECOND: + case MySqlParser.KW_ADMIN: + case MySqlParser.KW_AUDIT_ABORT_EXEMPT: + case MySqlParser.KW_AUDIT_ADMIN: + case MySqlParser.KW_AUTHENTICATION_POLICY_ADMIN: + case MySqlParser.KW_BACKUP_ADMIN: + case MySqlParser.KW_BINLOG_ADMIN: + case MySqlParser.KW_BINLOG_ENCRYPTION_ADMIN: + case MySqlParser.KW_CLONE_ADMIN: + case MySqlParser.KW_CONNECTION_ADMIN: + case MySqlParser.KW_ENCRYPTION_KEY_ADMIN: + case MySqlParser.KW_EXECUTE: + case MySqlParser.KW_FILE: + case MySqlParser.KW_FIREWALL_ADMIN: + case MySqlParser.KW_FIREWALL_EXEMPT: + case MySqlParser.KW_FIREWALL_USER: + case MySqlParser.KW_GROUP_REPLICATION_ADMIN: + case MySqlParser.KW_INNODB_REDO_LOG_ARCHIVE: + case MySqlParser.KW_INVOKE: + case MySqlParser.KW_LAMBDA: + case MySqlParser.KW_NDB_STORED_USER: + case MySqlParser.KW_PASSWORDLESS_USER_ADMIN: + case MySqlParser.KW_PERSIST_RO_VARIABLES_ADMIN: + case MySqlParser.KW_PRIVILEGES: + case MySqlParser.KW_PROCESS: + case MySqlParser.KW_RELOAD: + case MySqlParser.KW_REPLICATION_APPLIER: + case MySqlParser.KW_REPLICATION_SLAVE_ADMIN: + case MySqlParser.KW_RESOURCE_GROUP_ADMIN: + case MySqlParser.KW_RESOURCE_GROUP_USER: + case MySqlParser.KW_ROLE_ADMIN: + case MySqlParser.KW_ROUTINE: + case MySqlParser.KW_S3: + case MySqlParser.KW_SESSION_VARIABLES_ADMIN: + case MySqlParser.KW_SET_USER_ID: + case MySqlParser.KW_SHOW_ROUTINE: + case MySqlParser.KW_SHUTDOWN: + case MySqlParser.KW_SUPER: + case MySqlParser.KW_SYSTEM_VARIABLES_ADMIN: + case MySqlParser.KW_TABLES: + case MySqlParser.KW_TABLE_ENCRYPTION_ADMIN: + case MySqlParser.KW_VERSION_TOKEN_ADMIN: + case MySqlParser.KW_XA_RECOVER_ADMIN: + case MySqlParser.KW_ARMSCII8: + case MySqlParser.KW_ASCII: + case MySqlParser.KW_BIG5: + case MySqlParser.KW_CP1250: + case MySqlParser.KW_CP1251: + case MySqlParser.KW_CP1256: + case MySqlParser.KW_CP1257: + case MySqlParser.KW_CP850: + case MySqlParser.KW_CP852: + case MySqlParser.KW_CP866: + case MySqlParser.KW_CP932: + case MySqlParser.KW_DEC8: + case MySqlParser.KW_EUCJPMS: + case MySqlParser.KW_EUCKR: + case MySqlParser.KW_GB18030: + case MySqlParser.KW_GB2312: + case MySqlParser.KW_GBK: + case MySqlParser.KW_GEOSTD8: + case MySqlParser.KW_GREEK: + case MySqlParser.KW_HEBREW: + case MySqlParser.KW_HP8: + case MySqlParser.KW_KEYBCS2: + case MySqlParser.KW_KOI8R: + case MySqlParser.KW_KOI8U: + case MySqlParser.KW_LATIN1: + case MySqlParser.KW_LATIN2: + case MySqlParser.KW_LATIN5: + case MySqlParser.KW_LATIN7: + case MySqlParser.KW_MACCE: + case MySqlParser.KW_MACROMAN: + case MySqlParser.KW_SJIS: + case MySqlParser.KW_SWE7: + case MySqlParser.KW_TIS620: + case MySqlParser.KW_UCS2: + case MySqlParser.KW_UJIS: + case MySqlParser.KW_UTF16: + case MySqlParser.KW_UTF16LE: + case MySqlParser.KW_UTF32: + case MySqlParser.KW_UTF8: + case MySqlParser.KW_UTF8MB3: + case MySqlParser.KW_UTF8MB4: + case MySqlParser.KW_ARCHIVE: + case MySqlParser.KW_BLACKHOLE: + case MySqlParser.KW_CSV: + case MySqlParser.KW_FEDERATED: + case MySqlParser.KW_INNODB: + case MySqlParser.KW_MEMORY: + case MySqlParser.KW_MRG_MYISAM: + case MySqlParser.KW_MYISAM: + case MySqlParser.KW_NDB: + case MySqlParser.KW_NDBCLUSTER: + case MySqlParser.KW_PERFORMANCE_SCHEMA: + case MySqlParser.KW_TOKUDB: + case MySqlParser.KW_REPEATABLE: + case MySqlParser.KW_COMMITTED: + case MySqlParser.KW_UNCOMMITTED: + case MySqlParser.KW_SERIALIZABLE: + case MySqlParser.KW_GEOMETRYCOLLECTION: + case MySqlParser.KW_LINESTRING: + case MySqlParser.KW_MULTILINESTRING: + case MySqlParser.KW_MULTIPOINT: + case MySqlParser.KW_MULTIPOLYGON: + case MySqlParser.KW_POINT: + case MySqlParser.KW_POLYGON: + case MySqlParser.KW_CATALOG_NAME: + case MySqlParser.KW_CHARSET: + case MySqlParser.KW_COLLATION: + case MySqlParser.KW_ENGINE_ATTRIBUTE: + case MySqlParser.KW_FORMAT: + case MySqlParser.KW_GET_FORMAT: + case MySqlParser.KW_RANDOM: + case MySqlParser.KW_REVERSE: + case MySqlParser.KW_ROW_COUNT: + case MySqlParser.KW_SCHEMA_NAME: + case MySqlParser.KW_SECONDARY_ENGINE_ATTRIBUTE: + case MySqlParser.KW_SRID: + case MySqlParser.KW_SYSTEM_USER: + case MySqlParser.KW_TP_CONNECTION_ADMIN: + case MySqlParser.KW_WEIGHT_STRING: + case MySqlParser.MOD: + case MySqlParser.CHARSET_REVERSE_QOUTE_STRING: + case MySqlParser.STRING_LITERAL: + case MySqlParser.ID: + { + this.state = 2961; + this.partitionNames(); + } + break; + case MySqlParser.KW_ALL: + { + this.state = 2962; + this.match(MySqlParser.KW_ALL); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + break; + case MySqlParser.KW_OPTIMIZE: + localContext = new AlterByOptimizePartitionContext(localContext); + this.enterOuterAlt(localContext, 11); + { + this.state = 2965; + this.match(MySqlParser.KW_OPTIMIZE); + this.state = 2966; + this.match(MySqlParser.KW_PARTITION); + this.state = 2969; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_ARRAY: + case MySqlParser.KW_ATTRIBUTE: + case MySqlParser.KW_BUCKETS: + case MySqlParser.KW_CONDITION: + case MySqlParser.KW_CURRENT: + case MySqlParser.KW_CURRENT_USER: + case MySqlParser.KW_DATABASE: + case MySqlParser.KW_DEFAULT: + case MySqlParser.KW_DIAGNOSTICS: + case MySqlParser.KW_EMPTY: + case MySqlParser.KW_ENFORCED: + case MySqlParser.KW_EXCEPT: + case MySqlParser.KW_GROUP: + case MySqlParser.KW_IF: + case MySqlParser.KW_INSERT: + case MySqlParser.KW_LATERAL: + case MySqlParser.KW_LEFT: + case MySqlParser.KW_NUMBER: + case MySqlParser.KW_OPTIONAL: + case MySqlParser.KW_ORDER: + case MySqlParser.KW_PRIMARY: + case MySqlParser.KW_REPEAT: + case MySqlParser.KW_REPLACE: + case MySqlParser.KW_RIGHT: + case MySqlParser.KW_SCHEMA: + case MySqlParser.KW_SKIP_QUERY_REWRITE: + case MySqlParser.KW_STACKED: + case MySqlParser.KW_DATE: + case MySqlParser.KW_TIME: + case MySqlParser.KW_TIMESTAMP: + case MySqlParser.KW_DATETIME: + case MySqlParser.KW_YEAR: + case MySqlParser.KW_BINARY: + case MySqlParser.KW_TEXT: + case MySqlParser.KW_ENUM: + case MySqlParser.KW_SERIAL: + case MySqlParser.KW_JSON_TABLE: + case MySqlParser.KW_JSON_VALUE: + case MySqlParser.KW_NESTED: + case MySqlParser.KW_ORDINALITY: + case MySqlParser.KW_PATH: + case MySqlParser.KW_AVG: + case MySqlParser.KW_BIT_AND: + case MySqlParser.KW_BIT_OR: + case MySqlParser.KW_BIT_XOR: + case MySqlParser.KW_COUNT: + case MySqlParser.KW_CUME_DIST: + case MySqlParser.KW_DENSE_RANK: + case MySqlParser.KW_FIRST_VALUE: + case MySqlParser.KW_GROUP_CONCAT: + case MySqlParser.KW_LAG: + case MySqlParser.KW_LAST_VALUE: + case MySqlParser.KW_LEAD: + case MySqlParser.KW_MAX: + case MySqlParser.KW_MIN: + case MySqlParser.KW_NTILE: + case MySqlParser.KW_NTH_VALUE: + case MySqlParser.KW_PERCENT_RANK: + case MySqlParser.KW_RANK: + case MySqlParser.KW_ROW_NUMBER: + case MySqlParser.KW_STD: + case MySqlParser.KW_STDDEV: + case MySqlParser.KW_STDDEV_POP: + case MySqlParser.KW_STDDEV_SAMP: + case MySqlParser.KW_SUM: + case MySqlParser.KW_VAR_POP: + case MySqlParser.KW_VAR_SAMP: + case MySqlParser.KW_VARIANCE: + case MySqlParser.KW_CURRENT_DATE: + case MySqlParser.KW_CURRENT_TIME: + case MySqlParser.KW_CURRENT_TIMESTAMP: + case MySqlParser.KW_LOCALTIME: + case MySqlParser.KW_CURDATE: + case MySqlParser.KW_CURTIME: + case MySqlParser.KW_DATE_ADD: + case MySqlParser.KW_DATE_SUB: + case MySqlParser.KW_LOCALTIMESTAMP: + case MySqlParser.KW_NOW: + case MySqlParser.KW_POSITION: + case MySqlParser.KW_SUBSTR: + case MySqlParser.KW_SUBSTRING: + case MySqlParser.KW_SYSDATE: + case MySqlParser.KW_TRIM: + case MySqlParser.KW_UTC_DATE: + case MySqlParser.KW_UTC_TIME: + case MySqlParser.KW_UTC_TIMESTAMP: + case MySqlParser.KW_ACCOUNT: + case MySqlParser.KW_ACTION: + case MySqlParser.KW_AFTER: + case MySqlParser.KW_AGGREGATE: + case MySqlParser.KW_ALGORITHM: + case MySqlParser.KW_ANY: + case MySqlParser.KW_AT: + case MySqlParser.KW_AUTHORS: + case MySqlParser.KW_AUTOCOMMIT: + case MySqlParser.KW_AUTOEXTEND_SIZE: + case MySqlParser.KW_AUTO_INCREMENT: + case MySqlParser.KW_AVG_ROW_LENGTH: + case MySqlParser.KW_BEGIN: + case MySqlParser.KW_BINLOG: + case MySqlParser.KW_BIT: + case MySqlParser.KW_BLOCK: + case MySqlParser.KW_BOOL: + case MySqlParser.KW_BOOLEAN: + case MySqlParser.KW_BTREE: + case MySqlParser.KW_CACHE: + case MySqlParser.KW_CASCADED: + case MySqlParser.KW_CHAIN: + case MySqlParser.KW_CHANGED: + case MySqlParser.KW_CHANNEL: + case MySqlParser.KW_CHECKSUM: + case MySqlParser.KW_CIPHER: + case MySqlParser.KW_CLASS_ORIGIN: + case MySqlParser.KW_CLIENT: + case MySqlParser.KW_CLOSE: + case MySqlParser.KW_COALESCE: + case MySqlParser.KW_CODE: + case MySqlParser.KW_COLUMNS: + case MySqlParser.KW_COLUMN_FORMAT: + case MySqlParser.KW_COLUMN_NAME: + case MySqlParser.KW_COMMENT: + case MySqlParser.KW_COMMIT: + case MySqlParser.KW_COMPACT: + case MySqlParser.KW_COMPLETION: + case MySqlParser.KW_COMPRESSED: + case MySqlParser.KW_COMPRESSION: + case MySqlParser.KW_CONCURRENT: + case MySqlParser.KW_CONNECT: + case MySqlParser.KW_CONNECTION: + case MySqlParser.KW_CONSISTENT: + case MySqlParser.KW_CONSTRAINT_CATALOG: + case MySqlParser.KW_CONSTRAINT_SCHEMA: + case MySqlParser.KW_CONSTRAINT_NAME: + case MySqlParser.KW_CONTAINS: + case MySqlParser.KW_CONTEXT: + case MySqlParser.KW_CONTRIBUTORS: + case MySqlParser.KW_COPY: + case MySqlParser.KW_CPU: + case MySqlParser.KW_CURSOR_NAME: + case MySqlParser.KW_DATA: + case MySqlParser.KW_DATAFILE: + case MySqlParser.KW_DEALLOCATE: + case MySqlParser.KW_DEFAULT_AUTH: + case MySqlParser.KW_DEFINER: + case MySqlParser.KW_DELAY_KEY_WRITE: + case MySqlParser.KW_DES_KEY_FILE: + case MySqlParser.KW_DIRECTORY: + case MySqlParser.KW_DISABLE: + case MySqlParser.KW_DISCARD: + case MySqlParser.KW_DISK: + case MySqlParser.KW_DO: + case MySqlParser.KW_DUMPFILE: + case MySqlParser.KW_DUPLICATE: + case MySqlParser.KW_DYNAMIC: + case MySqlParser.KW_ENABLE: + case MySqlParser.KW_ENCRYPTION: + case MySqlParser.KW_END: + case MySqlParser.KW_ENDS: + case MySqlParser.KW_ENGINE: + case MySqlParser.KW_ENGINES: + case MySqlParser.KW_ERROR: + case MySqlParser.KW_ERRORS: + case MySqlParser.KW_ESCAPE: + case MySqlParser.KW_EVENT: + case MySqlParser.KW_EVENTS: + case MySqlParser.KW_EVERY: + case MySqlParser.KW_EXCHANGE: + case MySqlParser.KW_EXCLUSIVE: + case MySqlParser.KW_EXPIRE: + case MySqlParser.KW_EXPORT: + case MySqlParser.KW_EXTENDED: + case MySqlParser.KW_EXTENT_SIZE: + case MySqlParser.KW_FAILED_LOGIN_ATTEMPTS: + case MySqlParser.KW_FAST: + case MySqlParser.KW_FAULTS: + case MySqlParser.KW_FIELDS: + case MySqlParser.KW_FILE_BLOCK_SIZE: + case MySqlParser.KW_FILTER: + case MySqlParser.KW_FIRST: + case MySqlParser.KW_FIXED: + case MySqlParser.KW_FLUSH: + case MySqlParser.KW_FOLLOWS: + case MySqlParser.KW_FOUND: + case MySqlParser.KW_FULL: + case MySqlParser.KW_FUNCTION: + case MySqlParser.KW_GENERAL: + case MySqlParser.KW_GLOBAL: + case MySqlParser.KW_GRANTS: + case MySqlParser.KW_GROUP_REPLICATION: + case MySqlParser.KW_HANDLER: + case MySqlParser.KW_HASH: + case MySqlParser.KW_HELP: + case MySqlParser.KW_HISTORY: + case MySqlParser.KW_HOST: + case MySqlParser.KW_HOSTS: + case MySqlParser.KW_IDENTIFIED: + case MySqlParser.KW_IGNORE_SERVER_IDS: + case MySqlParser.KW_IMPORT: + case MySqlParser.KW_INDEXES: + case MySqlParser.KW_INITIAL_SIZE: + case MySqlParser.KW_INPLACE: + case MySqlParser.KW_INSERT_METHOD: + case MySqlParser.KW_INSTALL: + case MySqlParser.KW_INSTANCE: + case MySqlParser.KW_INSTANT: + case MySqlParser.KW_INVISIBLE: + case MySqlParser.KW_INVOKER: + case MySqlParser.KW_IO: + case MySqlParser.KW_IO_THREAD: + case MySqlParser.KW_IPC: + case MySqlParser.KW_ISOLATION: + case MySqlParser.KW_ISSUER: + case MySqlParser.KW_JSON: + case MySqlParser.KW_KEY_BLOCK_SIZE: + case MySqlParser.KW_LANGUAGE: + case MySqlParser.KW_LAST: + case MySqlParser.KW_LEAVES: + case MySqlParser.KW_LESS: + case MySqlParser.KW_LEVEL: + case MySqlParser.KW_LIST: + case MySqlParser.KW_LOCAL: + case MySqlParser.KW_LOGFILE: + case MySqlParser.KW_LOGS: + case MySqlParser.KW_MASTER: + case MySqlParser.KW_MASTER_AUTO_POSITION: + case MySqlParser.KW_MASTER_CONNECT_RETRY: + case MySqlParser.KW_MASTER_DELAY: + case MySqlParser.KW_MASTER_HEARTBEAT_PERIOD: + case MySqlParser.KW_MASTER_HOST: + case MySqlParser.KW_MASTER_LOG_FILE: + case MySqlParser.KW_MASTER_LOG_POS: + case MySqlParser.KW_MASTER_PASSWORD: + case MySqlParser.KW_MASTER_PORT: + case MySqlParser.KW_MASTER_RETRY_COUNT: + case MySqlParser.KW_MASTER_SSL: + case MySqlParser.KW_MASTER_SSL_CA: + case MySqlParser.KW_MASTER_SSL_CAPATH: + case MySqlParser.KW_MASTER_SSL_CERT: + case MySqlParser.KW_MASTER_SSL_CIPHER: + case MySqlParser.KW_MASTER_SSL_CRL: + case MySqlParser.KW_MASTER_SSL_CRLPATH: + case MySqlParser.KW_MASTER_SSL_KEY: + case MySqlParser.KW_MASTER_TLS_VERSION: + case MySqlParser.KW_MASTER_USER: + case MySqlParser.KW_MAX_CONNECTIONS_PER_HOUR: + case MySqlParser.KW_MAX_QUERIES_PER_HOUR: + case MySqlParser.KW_MAX_ROWS: + case MySqlParser.KW_MAX_SIZE: + case MySqlParser.KW_MAX_UPDATES_PER_HOUR: + case MySqlParser.KW_MAX_USER_CONNECTIONS: + case MySqlParser.KW_MEDIUM: + case MySqlParser.KW_MEMBER: + case MySqlParser.KW_MERGE: + case MySqlParser.KW_MESSAGE_TEXT: + case MySqlParser.KW_MID: + case MySqlParser.KW_MIGRATE: + case MySqlParser.KW_MIN_ROWS: + case MySqlParser.KW_MODE: + case MySqlParser.KW_MODIFY: + case MySqlParser.KW_MUTEX: + case MySqlParser.KW_MYSQL: + case MySqlParser.KW_MYSQL_ERRNO: + case MySqlParser.KW_NAME: + case MySqlParser.KW_NAMES: + case MySqlParser.KW_NCHAR: + case MySqlParser.KW_NEVER: + case MySqlParser.KW_NEXT: + case MySqlParser.KW_NO: + case MySqlParser.KW_NOWAIT: + case MySqlParser.KW_NODEGROUP: + case MySqlParser.KW_NONE: + case MySqlParser.KW_ODBC: + case MySqlParser.KW_OFFLINE: + case MySqlParser.KW_OFFSET: + case MySqlParser.KW_OF: + case MySqlParser.KW_OLD_PASSWORD: + case MySqlParser.KW_ONE: + case MySqlParser.KW_ONLINE: + case MySqlParser.KW_ONLY: + case MySqlParser.KW_OPEN: + case MySqlParser.KW_OPTIMIZER_COSTS: + case MySqlParser.KW_OPTIONS: + case MySqlParser.KW_OWNER: + case MySqlParser.KW_PACK_KEYS: + case MySqlParser.KW_PAGE: + case MySqlParser.KW_PAGE_CHECKSUM: + case MySqlParser.KW_PARSER: + case MySqlParser.KW_PARTIAL: + case MySqlParser.KW_PARTITIONING: + case MySqlParser.KW_PARTITIONS: + case MySqlParser.KW_PASSWORD: + case MySqlParser.KW_PASSWORD_LOCK_TIME: + case MySqlParser.KW_PHASE: + case MySqlParser.KW_PLUGIN: + case MySqlParser.KW_PLUGIN_DIR: + case MySqlParser.KW_PLUGINS: + case MySqlParser.KW_PORT: + case MySqlParser.KW_PRECEDES: + case MySqlParser.KW_PREPARE: + case MySqlParser.KW_PRESERVE: + case MySqlParser.KW_PREV: + case MySqlParser.KW_PROCESSLIST: + case MySqlParser.KW_PROFILE: + case MySqlParser.KW_PROFILES: + case MySqlParser.KW_PROXY: + case MySqlParser.KW_QUERY: + case MySqlParser.KW_QUICK: + case MySqlParser.KW_REBUILD: + case MySqlParser.KW_RECOVER: + case MySqlParser.KW_RECURSIVE: + case MySqlParser.KW_REDO_BUFFER_SIZE: + case MySqlParser.KW_REDUNDANT: + case MySqlParser.KW_RELAY: + case MySqlParser.KW_RELAY_LOG_FILE: + case MySqlParser.KW_RELAY_LOG_POS: + case MySqlParser.KW_RELAYLOG: + case MySqlParser.KW_REMOVE: + case MySqlParser.KW_REORGANIZE: + case MySqlParser.KW_REPAIR: + case MySqlParser.KW_REPLICATE_DO_DB: + case MySqlParser.KW_REPLICATE_DO_TABLE: + case MySqlParser.KW_REPLICATE_IGNORE_DB: + case MySqlParser.KW_REPLICATE_IGNORE_TABLE: + case MySqlParser.KW_REPLICATE_REWRITE_DB: + case MySqlParser.KW_REPLICATE_WILD_DO_TABLE: + case MySqlParser.KW_REPLICATE_WILD_IGNORE_TABLE: + case MySqlParser.KW_REPLICATION: + case MySqlParser.KW_RESET: + case MySqlParser.KW_RESUME: + case MySqlParser.KW_RETURNED_SQLSTATE: + case MySqlParser.KW_RETURNS: + case MySqlParser.KW_REUSE: + case MySqlParser.KW_ROLE: + case MySqlParser.KW_ROLLBACK: + case MySqlParser.KW_ROLLUP: + case MySqlParser.KW_ROTATE: + case MySqlParser.KW_ROW: + case MySqlParser.KW_ROWS: + case MySqlParser.KW_ROW_FORMAT: + case MySqlParser.KW_SAVEPOINT: + case MySqlParser.KW_SCHEDULE: + case MySqlParser.KW_SECURITY: + case MySqlParser.KW_SERVER: + case MySqlParser.KW_SESSION: + case MySqlParser.KW_SHARE: + case MySqlParser.KW_SHARED: + case MySqlParser.KW_SIGNED: + case MySqlParser.KW_SIMPLE: + case MySqlParser.KW_SLAVE: + case MySqlParser.KW_SLOW: + case MySqlParser.KW_SNAPSHOT: + case MySqlParser.KW_SOCKET: + case MySqlParser.KW_SOME: + case MySqlParser.KW_SONAME: + case MySqlParser.KW_SOUNDS: + case MySqlParser.KW_SOURCE: + case MySqlParser.KW_SQL_AFTER_GTIDS: + case MySqlParser.KW_SQL_AFTER_MTS_GAPS: + case MySqlParser.KW_SQL_BEFORE_GTIDS: + case MySqlParser.KW_SQL_BUFFER_RESULT: + case MySqlParser.KW_SQL_CACHE: + case MySqlParser.KW_SQL_NO_CACHE: + case MySqlParser.KW_SQL_THREAD: + case MySqlParser.KW_START: + case MySqlParser.KW_STARTS: + case MySqlParser.KW_STATS_AUTO_RECALC: + case MySqlParser.KW_STATS_PERSISTENT: + case MySqlParser.KW_STATS_SAMPLE_PAGES: + case MySqlParser.KW_STATUS: + case MySqlParser.KW_STOP: + case MySqlParser.KW_STORAGE: + case MySqlParser.KW_STRING: + case MySqlParser.KW_SUBCLASS_ORIGIN: + case MySqlParser.KW_SUBJECT: + case MySqlParser.KW_SUBPARTITION: + case MySqlParser.KW_SUBPARTITIONS: + case MySqlParser.KW_SUSPEND: + case MySqlParser.KW_SWAPS: + case MySqlParser.KW_SWITCHES: + case MySqlParser.KW_TABLE_NAME: + case MySqlParser.KW_TABLESPACE: + case MySqlParser.KW_TABLE_TYPE: + case MySqlParser.KW_TEMPORARY: + case MySqlParser.KW_TEMPTABLE: + case MySqlParser.KW_THAN: + case MySqlParser.KW_TRADITIONAL: + case MySqlParser.KW_TRANSACTION: + case MySqlParser.KW_TRANSACTIONAL: + case MySqlParser.KW_TRIGGERS: + case MySqlParser.KW_TRUNCATE: + case MySqlParser.KW_UNBOUNDED: + case MySqlParser.KW_UNDEFINED: + case MySqlParser.KW_UNDOFILE: + case MySqlParser.KW_UNDO_BUFFER_SIZE: + case MySqlParser.KW_UNINSTALL: + case MySqlParser.KW_UNKNOWN: + case MySqlParser.KW_UNTIL: + case MySqlParser.KW_UPGRADE: + case MySqlParser.KW_USER: + case MySqlParser.KW_USE_FRM: + case MySqlParser.KW_USER_RESOURCES: + case MySqlParser.KW_VALIDATION: + case MySqlParser.KW_VALUE: + case MySqlParser.KW_VARIABLES: + case MySqlParser.KW_VIEW: + case MySqlParser.KW_VIRTUAL: + case MySqlParser.KW_VISIBLE: + case MySqlParser.KW_WAIT: + case MySqlParser.KW_WARNINGS: + case MySqlParser.KW_WITHOUT: + case MySqlParser.KW_WORK: + case MySqlParser.KW_WRAPPER: + case MySqlParser.KW_X509: + case MySqlParser.KW_XA: + case MySqlParser.KW_XML: + case MySqlParser.KW_QUARTER: + case MySqlParser.KW_MONTH: + case MySqlParser.KW_DAY: + case MySqlParser.KW_HOUR: + case MySqlParser.KW_MINUTE: + case MySqlParser.KW_WEEK: + case MySqlParser.KW_SECOND: + case MySqlParser.KW_MICROSECOND: + case MySqlParser.KW_ADMIN: + case MySqlParser.KW_AUDIT_ABORT_EXEMPT: + case MySqlParser.KW_AUDIT_ADMIN: + case MySqlParser.KW_AUTHENTICATION_POLICY_ADMIN: + case MySqlParser.KW_BACKUP_ADMIN: + case MySqlParser.KW_BINLOG_ADMIN: + case MySqlParser.KW_BINLOG_ENCRYPTION_ADMIN: + case MySqlParser.KW_CLONE_ADMIN: + case MySqlParser.KW_CONNECTION_ADMIN: + case MySqlParser.KW_ENCRYPTION_KEY_ADMIN: + case MySqlParser.KW_EXECUTE: + case MySqlParser.KW_FILE: + case MySqlParser.KW_FIREWALL_ADMIN: + case MySqlParser.KW_FIREWALL_EXEMPT: + case MySqlParser.KW_FIREWALL_USER: + case MySqlParser.KW_GROUP_REPLICATION_ADMIN: + case MySqlParser.KW_INNODB_REDO_LOG_ARCHIVE: + case MySqlParser.KW_INVOKE: + case MySqlParser.KW_LAMBDA: + case MySqlParser.KW_NDB_STORED_USER: + case MySqlParser.KW_PASSWORDLESS_USER_ADMIN: + case MySqlParser.KW_PERSIST_RO_VARIABLES_ADMIN: + case MySqlParser.KW_PRIVILEGES: + case MySqlParser.KW_PROCESS: + case MySqlParser.KW_RELOAD: + case MySqlParser.KW_REPLICATION_APPLIER: + case MySqlParser.KW_REPLICATION_SLAVE_ADMIN: + case MySqlParser.KW_RESOURCE_GROUP_ADMIN: + case MySqlParser.KW_RESOURCE_GROUP_USER: + case MySqlParser.KW_ROLE_ADMIN: + case MySqlParser.KW_ROUTINE: + case MySqlParser.KW_S3: + case MySqlParser.KW_SESSION_VARIABLES_ADMIN: + case MySqlParser.KW_SET_USER_ID: + case MySqlParser.KW_SHOW_ROUTINE: + case MySqlParser.KW_SHUTDOWN: + case MySqlParser.KW_SUPER: + case MySqlParser.KW_SYSTEM_VARIABLES_ADMIN: + case MySqlParser.KW_TABLES: + case MySqlParser.KW_TABLE_ENCRYPTION_ADMIN: + case MySqlParser.KW_VERSION_TOKEN_ADMIN: + case MySqlParser.KW_XA_RECOVER_ADMIN: + case MySqlParser.KW_ARMSCII8: + case MySqlParser.KW_ASCII: + case MySqlParser.KW_BIG5: + case MySqlParser.KW_CP1250: + case MySqlParser.KW_CP1251: + case MySqlParser.KW_CP1256: + case MySqlParser.KW_CP1257: + case MySqlParser.KW_CP850: + case MySqlParser.KW_CP852: + case MySqlParser.KW_CP866: + case MySqlParser.KW_CP932: + case MySqlParser.KW_DEC8: + case MySqlParser.KW_EUCJPMS: + case MySqlParser.KW_EUCKR: + case MySqlParser.KW_GB18030: + case MySqlParser.KW_GB2312: + case MySqlParser.KW_GBK: + case MySqlParser.KW_GEOSTD8: + case MySqlParser.KW_GREEK: + case MySqlParser.KW_HEBREW: + case MySqlParser.KW_HP8: + case MySqlParser.KW_KEYBCS2: + case MySqlParser.KW_KOI8R: + case MySqlParser.KW_KOI8U: + case MySqlParser.KW_LATIN1: + case MySqlParser.KW_LATIN2: + case MySqlParser.KW_LATIN5: + case MySqlParser.KW_LATIN7: + case MySqlParser.KW_MACCE: + case MySqlParser.KW_MACROMAN: + case MySqlParser.KW_SJIS: + case MySqlParser.KW_SWE7: + case MySqlParser.KW_TIS620: + case MySqlParser.KW_UCS2: + case MySqlParser.KW_UJIS: + case MySqlParser.KW_UTF16: + case MySqlParser.KW_UTF16LE: + case MySqlParser.KW_UTF32: + case MySqlParser.KW_UTF8: + case MySqlParser.KW_UTF8MB3: + case MySqlParser.KW_UTF8MB4: + case MySqlParser.KW_ARCHIVE: + case MySqlParser.KW_BLACKHOLE: + case MySqlParser.KW_CSV: + case MySqlParser.KW_FEDERATED: + case MySqlParser.KW_INNODB: + case MySqlParser.KW_MEMORY: + case MySqlParser.KW_MRG_MYISAM: + case MySqlParser.KW_MYISAM: + case MySqlParser.KW_NDB: + case MySqlParser.KW_NDBCLUSTER: + case MySqlParser.KW_PERFORMANCE_SCHEMA: + case MySqlParser.KW_TOKUDB: + case MySqlParser.KW_REPEATABLE: + case MySqlParser.KW_COMMITTED: + case MySqlParser.KW_UNCOMMITTED: + case MySqlParser.KW_SERIALIZABLE: + case MySqlParser.KW_GEOMETRYCOLLECTION: + case MySqlParser.KW_LINESTRING: + case MySqlParser.KW_MULTILINESTRING: + case MySqlParser.KW_MULTIPOINT: + case MySqlParser.KW_MULTIPOLYGON: + case MySqlParser.KW_POINT: + case MySqlParser.KW_POLYGON: + case MySqlParser.KW_CATALOG_NAME: + case MySqlParser.KW_CHARSET: + case MySqlParser.KW_COLLATION: + case MySqlParser.KW_ENGINE_ATTRIBUTE: + case MySqlParser.KW_FORMAT: + case MySqlParser.KW_GET_FORMAT: + case MySqlParser.KW_RANDOM: + case MySqlParser.KW_REVERSE: + case MySqlParser.KW_ROW_COUNT: + case MySqlParser.KW_SCHEMA_NAME: + case MySqlParser.KW_SECONDARY_ENGINE_ATTRIBUTE: + case MySqlParser.KW_SRID: + case MySqlParser.KW_SYSTEM_USER: + case MySqlParser.KW_TP_CONNECTION_ADMIN: + case MySqlParser.KW_WEIGHT_STRING: + case MySqlParser.MOD: + case MySqlParser.CHARSET_REVERSE_QOUTE_STRING: + case MySqlParser.STRING_LITERAL: + case MySqlParser.ID: + { + this.state = 2967; + this.partitionNames(); + } + break; + case MySqlParser.KW_ALL: + { + this.state = 2968; + this.match(MySqlParser.KW_ALL); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + break; + case MySqlParser.KW_REBUILD: + localContext = new AlterByRebuildPartitionContext(localContext); + this.enterOuterAlt(localContext, 12); + { + this.state = 2971; + this.match(MySqlParser.KW_REBUILD); + this.state = 2972; + this.match(MySqlParser.KW_PARTITION); + this.state = 2975; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_ARRAY: + case MySqlParser.KW_ATTRIBUTE: + case MySqlParser.KW_BUCKETS: + case MySqlParser.KW_CONDITION: + case MySqlParser.KW_CURRENT: + case MySqlParser.KW_CURRENT_USER: + case MySqlParser.KW_DATABASE: + case MySqlParser.KW_DEFAULT: + case MySqlParser.KW_DIAGNOSTICS: + case MySqlParser.KW_EMPTY: + case MySqlParser.KW_ENFORCED: + case MySqlParser.KW_EXCEPT: + case MySqlParser.KW_GROUP: + case MySqlParser.KW_IF: + case MySqlParser.KW_INSERT: + case MySqlParser.KW_LATERAL: + case MySqlParser.KW_LEFT: + case MySqlParser.KW_NUMBER: + case MySqlParser.KW_OPTIONAL: + case MySqlParser.KW_ORDER: + case MySqlParser.KW_PRIMARY: + case MySqlParser.KW_REPEAT: + case MySqlParser.KW_REPLACE: + case MySqlParser.KW_RIGHT: + case MySqlParser.KW_SCHEMA: + case MySqlParser.KW_SKIP_QUERY_REWRITE: + case MySqlParser.KW_STACKED: + case MySqlParser.KW_DATE: + case MySqlParser.KW_TIME: + case MySqlParser.KW_TIMESTAMP: + case MySqlParser.KW_DATETIME: + case MySqlParser.KW_YEAR: + case MySqlParser.KW_BINARY: + case MySqlParser.KW_TEXT: + case MySqlParser.KW_ENUM: + case MySqlParser.KW_SERIAL: + case MySqlParser.KW_JSON_TABLE: + case MySqlParser.KW_JSON_VALUE: + case MySqlParser.KW_NESTED: + case MySqlParser.KW_ORDINALITY: + case MySqlParser.KW_PATH: + case MySqlParser.KW_AVG: + case MySqlParser.KW_BIT_AND: + case MySqlParser.KW_BIT_OR: + case MySqlParser.KW_BIT_XOR: + case MySqlParser.KW_COUNT: + case MySqlParser.KW_CUME_DIST: + case MySqlParser.KW_DENSE_RANK: + case MySqlParser.KW_FIRST_VALUE: + case MySqlParser.KW_GROUP_CONCAT: + case MySqlParser.KW_LAG: + case MySqlParser.KW_LAST_VALUE: + case MySqlParser.KW_LEAD: + case MySqlParser.KW_MAX: + case MySqlParser.KW_MIN: + case MySqlParser.KW_NTILE: + case MySqlParser.KW_NTH_VALUE: + case MySqlParser.KW_PERCENT_RANK: + case MySqlParser.KW_RANK: + case MySqlParser.KW_ROW_NUMBER: + case MySqlParser.KW_STD: + case MySqlParser.KW_STDDEV: + case MySqlParser.KW_STDDEV_POP: + case MySqlParser.KW_STDDEV_SAMP: + case MySqlParser.KW_SUM: + case MySqlParser.KW_VAR_POP: + case MySqlParser.KW_VAR_SAMP: + case MySqlParser.KW_VARIANCE: + case MySqlParser.KW_CURRENT_DATE: + case MySqlParser.KW_CURRENT_TIME: + case MySqlParser.KW_CURRENT_TIMESTAMP: + case MySqlParser.KW_LOCALTIME: + case MySqlParser.KW_CURDATE: + case MySqlParser.KW_CURTIME: + case MySqlParser.KW_DATE_ADD: + case MySqlParser.KW_DATE_SUB: + case MySqlParser.KW_LOCALTIMESTAMP: + case MySqlParser.KW_NOW: + case MySqlParser.KW_POSITION: + case MySqlParser.KW_SUBSTR: + case MySqlParser.KW_SUBSTRING: + case MySqlParser.KW_SYSDATE: + case MySqlParser.KW_TRIM: + case MySqlParser.KW_UTC_DATE: + case MySqlParser.KW_UTC_TIME: + case MySqlParser.KW_UTC_TIMESTAMP: + case MySqlParser.KW_ACCOUNT: + case MySqlParser.KW_ACTION: + case MySqlParser.KW_AFTER: + case MySqlParser.KW_AGGREGATE: + case MySqlParser.KW_ALGORITHM: + case MySqlParser.KW_ANY: + case MySqlParser.KW_AT: + case MySqlParser.KW_AUTHORS: + case MySqlParser.KW_AUTOCOMMIT: + case MySqlParser.KW_AUTOEXTEND_SIZE: + case MySqlParser.KW_AUTO_INCREMENT: + case MySqlParser.KW_AVG_ROW_LENGTH: + case MySqlParser.KW_BEGIN: + case MySqlParser.KW_BINLOG: + case MySqlParser.KW_BIT: + case MySqlParser.KW_BLOCK: + case MySqlParser.KW_BOOL: + case MySqlParser.KW_BOOLEAN: + case MySqlParser.KW_BTREE: + case MySqlParser.KW_CACHE: + case MySqlParser.KW_CASCADED: + case MySqlParser.KW_CHAIN: + case MySqlParser.KW_CHANGED: + case MySqlParser.KW_CHANNEL: + case MySqlParser.KW_CHECKSUM: + case MySqlParser.KW_CIPHER: + case MySqlParser.KW_CLASS_ORIGIN: + case MySqlParser.KW_CLIENT: + case MySqlParser.KW_CLOSE: + case MySqlParser.KW_COALESCE: + case MySqlParser.KW_CODE: + case MySqlParser.KW_COLUMNS: + case MySqlParser.KW_COLUMN_FORMAT: + case MySqlParser.KW_COLUMN_NAME: + case MySqlParser.KW_COMMENT: + case MySqlParser.KW_COMMIT: + case MySqlParser.KW_COMPACT: + case MySqlParser.KW_COMPLETION: + case MySqlParser.KW_COMPRESSED: + case MySqlParser.KW_COMPRESSION: + case MySqlParser.KW_CONCURRENT: + case MySqlParser.KW_CONNECT: + case MySqlParser.KW_CONNECTION: + case MySqlParser.KW_CONSISTENT: + case MySqlParser.KW_CONSTRAINT_CATALOG: + case MySqlParser.KW_CONSTRAINT_SCHEMA: + case MySqlParser.KW_CONSTRAINT_NAME: + case MySqlParser.KW_CONTAINS: + case MySqlParser.KW_CONTEXT: + case MySqlParser.KW_CONTRIBUTORS: + case MySqlParser.KW_COPY: + case MySqlParser.KW_CPU: + case MySqlParser.KW_CURSOR_NAME: + case MySqlParser.KW_DATA: + case MySqlParser.KW_DATAFILE: + case MySqlParser.KW_DEALLOCATE: + case MySqlParser.KW_DEFAULT_AUTH: + case MySqlParser.KW_DEFINER: + case MySqlParser.KW_DELAY_KEY_WRITE: + case MySqlParser.KW_DES_KEY_FILE: + case MySqlParser.KW_DIRECTORY: + case MySqlParser.KW_DISABLE: + case MySqlParser.KW_DISCARD: + case MySqlParser.KW_DISK: + case MySqlParser.KW_DO: + case MySqlParser.KW_DUMPFILE: + case MySqlParser.KW_DUPLICATE: + case MySqlParser.KW_DYNAMIC: + case MySqlParser.KW_ENABLE: + case MySqlParser.KW_ENCRYPTION: + case MySqlParser.KW_END: + case MySqlParser.KW_ENDS: + case MySqlParser.KW_ENGINE: + case MySqlParser.KW_ENGINES: + case MySqlParser.KW_ERROR: + case MySqlParser.KW_ERRORS: + case MySqlParser.KW_ESCAPE: + case MySqlParser.KW_EVENT: + case MySqlParser.KW_EVENTS: + case MySqlParser.KW_EVERY: + case MySqlParser.KW_EXCHANGE: + case MySqlParser.KW_EXCLUSIVE: + case MySqlParser.KW_EXPIRE: + case MySqlParser.KW_EXPORT: + case MySqlParser.KW_EXTENDED: + case MySqlParser.KW_EXTENT_SIZE: + case MySqlParser.KW_FAILED_LOGIN_ATTEMPTS: + case MySqlParser.KW_FAST: + case MySqlParser.KW_FAULTS: + case MySqlParser.KW_FIELDS: + case MySqlParser.KW_FILE_BLOCK_SIZE: + case MySqlParser.KW_FILTER: + case MySqlParser.KW_FIRST: + case MySqlParser.KW_FIXED: + case MySqlParser.KW_FLUSH: + case MySqlParser.KW_FOLLOWS: + case MySqlParser.KW_FOUND: + case MySqlParser.KW_FULL: + case MySqlParser.KW_FUNCTION: + case MySqlParser.KW_GENERAL: + case MySqlParser.KW_GLOBAL: + case MySqlParser.KW_GRANTS: + case MySqlParser.KW_GROUP_REPLICATION: + case MySqlParser.KW_HANDLER: + case MySqlParser.KW_HASH: + case MySqlParser.KW_HELP: + case MySqlParser.KW_HISTORY: + case MySqlParser.KW_HOST: + case MySqlParser.KW_HOSTS: + case MySqlParser.KW_IDENTIFIED: + case MySqlParser.KW_IGNORE_SERVER_IDS: + case MySqlParser.KW_IMPORT: + case MySqlParser.KW_INDEXES: + case MySqlParser.KW_INITIAL_SIZE: + case MySqlParser.KW_INPLACE: + case MySqlParser.KW_INSERT_METHOD: + case MySqlParser.KW_INSTALL: + case MySqlParser.KW_INSTANCE: + case MySqlParser.KW_INSTANT: + case MySqlParser.KW_INVISIBLE: + case MySqlParser.KW_INVOKER: + case MySqlParser.KW_IO: + case MySqlParser.KW_IO_THREAD: + case MySqlParser.KW_IPC: + case MySqlParser.KW_ISOLATION: + case MySqlParser.KW_ISSUER: + case MySqlParser.KW_JSON: + case MySqlParser.KW_KEY_BLOCK_SIZE: + case MySqlParser.KW_LANGUAGE: + case MySqlParser.KW_LAST: + case MySqlParser.KW_LEAVES: + case MySqlParser.KW_LESS: + case MySqlParser.KW_LEVEL: + case MySqlParser.KW_LIST: + case MySqlParser.KW_LOCAL: + case MySqlParser.KW_LOGFILE: + case MySqlParser.KW_LOGS: + case MySqlParser.KW_MASTER: + case MySqlParser.KW_MASTER_AUTO_POSITION: + case MySqlParser.KW_MASTER_CONNECT_RETRY: + case MySqlParser.KW_MASTER_DELAY: + case MySqlParser.KW_MASTER_HEARTBEAT_PERIOD: + case MySqlParser.KW_MASTER_HOST: + case MySqlParser.KW_MASTER_LOG_FILE: + case MySqlParser.KW_MASTER_LOG_POS: + case MySqlParser.KW_MASTER_PASSWORD: + case MySqlParser.KW_MASTER_PORT: + case MySqlParser.KW_MASTER_RETRY_COUNT: + case MySqlParser.KW_MASTER_SSL: + case MySqlParser.KW_MASTER_SSL_CA: + case MySqlParser.KW_MASTER_SSL_CAPATH: + case MySqlParser.KW_MASTER_SSL_CERT: + case MySqlParser.KW_MASTER_SSL_CIPHER: + case MySqlParser.KW_MASTER_SSL_CRL: + case MySqlParser.KW_MASTER_SSL_CRLPATH: + case MySqlParser.KW_MASTER_SSL_KEY: + case MySqlParser.KW_MASTER_TLS_VERSION: + case MySqlParser.KW_MASTER_USER: + case MySqlParser.KW_MAX_CONNECTIONS_PER_HOUR: + case MySqlParser.KW_MAX_QUERIES_PER_HOUR: + case MySqlParser.KW_MAX_ROWS: + case MySqlParser.KW_MAX_SIZE: + case MySqlParser.KW_MAX_UPDATES_PER_HOUR: + case MySqlParser.KW_MAX_USER_CONNECTIONS: + case MySqlParser.KW_MEDIUM: + case MySqlParser.KW_MEMBER: + case MySqlParser.KW_MERGE: + case MySqlParser.KW_MESSAGE_TEXT: + case MySqlParser.KW_MID: + case MySqlParser.KW_MIGRATE: + case MySqlParser.KW_MIN_ROWS: + case MySqlParser.KW_MODE: + case MySqlParser.KW_MODIFY: + case MySqlParser.KW_MUTEX: + case MySqlParser.KW_MYSQL: + case MySqlParser.KW_MYSQL_ERRNO: + case MySqlParser.KW_NAME: + case MySqlParser.KW_NAMES: + case MySqlParser.KW_NCHAR: + case MySqlParser.KW_NEVER: + case MySqlParser.KW_NEXT: + case MySqlParser.KW_NO: + case MySqlParser.KW_NOWAIT: + case MySqlParser.KW_NODEGROUP: + case MySqlParser.KW_NONE: + case MySqlParser.KW_ODBC: + case MySqlParser.KW_OFFLINE: + case MySqlParser.KW_OFFSET: + case MySqlParser.KW_OF: + case MySqlParser.KW_OLD_PASSWORD: + case MySqlParser.KW_ONE: + case MySqlParser.KW_ONLINE: + case MySqlParser.KW_ONLY: + case MySqlParser.KW_OPEN: + case MySqlParser.KW_OPTIMIZER_COSTS: + case MySqlParser.KW_OPTIONS: + case MySqlParser.KW_OWNER: + case MySqlParser.KW_PACK_KEYS: + case MySqlParser.KW_PAGE: + case MySqlParser.KW_PAGE_CHECKSUM: + case MySqlParser.KW_PARSER: + case MySqlParser.KW_PARTIAL: + case MySqlParser.KW_PARTITIONING: + case MySqlParser.KW_PARTITIONS: + case MySqlParser.KW_PASSWORD: + case MySqlParser.KW_PASSWORD_LOCK_TIME: + case MySqlParser.KW_PHASE: + case MySqlParser.KW_PLUGIN: + case MySqlParser.KW_PLUGIN_DIR: + case MySqlParser.KW_PLUGINS: + case MySqlParser.KW_PORT: + case MySqlParser.KW_PRECEDES: + case MySqlParser.KW_PREPARE: + case MySqlParser.KW_PRESERVE: + case MySqlParser.KW_PREV: + case MySqlParser.KW_PROCESSLIST: + case MySqlParser.KW_PROFILE: + case MySqlParser.KW_PROFILES: + case MySqlParser.KW_PROXY: + case MySqlParser.KW_QUERY: + case MySqlParser.KW_QUICK: + case MySqlParser.KW_REBUILD: + case MySqlParser.KW_RECOVER: + case MySqlParser.KW_RECURSIVE: + case MySqlParser.KW_REDO_BUFFER_SIZE: + case MySqlParser.KW_REDUNDANT: + case MySqlParser.KW_RELAY: + case MySqlParser.KW_RELAY_LOG_FILE: + case MySqlParser.KW_RELAY_LOG_POS: + case MySqlParser.KW_RELAYLOG: + case MySqlParser.KW_REMOVE: + case MySqlParser.KW_REORGANIZE: + case MySqlParser.KW_REPAIR: + case MySqlParser.KW_REPLICATE_DO_DB: + case MySqlParser.KW_REPLICATE_DO_TABLE: + case MySqlParser.KW_REPLICATE_IGNORE_DB: + case MySqlParser.KW_REPLICATE_IGNORE_TABLE: + case MySqlParser.KW_REPLICATE_REWRITE_DB: + case MySqlParser.KW_REPLICATE_WILD_DO_TABLE: + case MySqlParser.KW_REPLICATE_WILD_IGNORE_TABLE: + case MySqlParser.KW_REPLICATION: + case MySqlParser.KW_RESET: + case MySqlParser.KW_RESUME: + case MySqlParser.KW_RETURNED_SQLSTATE: + case MySqlParser.KW_RETURNS: + case MySqlParser.KW_REUSE: + case MySqlParser.KW_ROLE: + case MySqlParser.KW_ROLLBACK: + case MySqlParser.KW_ROLLUP: + case MySqlParser.KW_ROTATE: + case MySqlParser.KW_ROW: + case MySqlParser.KW_ROWS: + case MySqlParser.KW_ROW_FORMAT: + case MySqlParser.KW_SAVEPOINT: + case MySqlParser.KW_SCHEDULE: + case MySqlParser.KW_SECURITY: + case MySqlParser.KW_SERVER: + case MySqlParser.KW_SESSION: + case MySqlParser.KW_SHARE: + case MySqlParser.KW_SHARED: + case MySqlParser.KW_SIGNED: + case MySqlParser.KW_SIMPLE: + case MySqlParser.KW_SLAVE: + case MySqlParser.KW_SLOW: + case MySqlParser.KW_SNAPSHOT: + case MySqlParser.KW_SOCKET: + case MySqlParser.KW_SOME: + case MySqlParser.KW_SONAME: + case MySqlParser.KW_SOUNDS: + case MySqlParser.KW_SOURCE: + case MySqlParser.KW_SQL_AFTER_GTIDS: + case MySqlParser.KW_SQL_AFTER_MTS_GAPS: + case MySqlParser.KW_SQL_BEFORE_GTIDS: + case MySqlParser.KW_SQL_BUFFER_RESULT: + case MySqlParser.KW_SQL_CACHE: + case MySqlParser.KW_SQL_NO_CACHE: + case MySqlParser.KW_SQL_THREAD: + case MySqlParser.KW_START: + case MySqlParser.KW_STARTS: + case MySqlParser.KW_STATS_AUTO_RECALC: + case MySqlParser.KW_STATS_PERSISTENT: + case MySqlParser.KW_STATS_SAMPLE_PAGES: + case MySqlParser.KW_STATUS: + case MySqlParser.KW_STOP: + case MySqlParser.KW_STORAGE: + case MySqlParser.KW_STRING: + case MySqlParser.KW_SUBCLASS_ORIGIN: + case MySqlParser.KW_SUBJECT: + case MySqlParser.KW_SUBPARTITION: + case MySqlParser.KW_SUBPARTITIONS: + case MySqlParser.KW_SUSPEND: + case MySqlParser.KW_SWAPS: + case MySqlParser.KW_SWITCHES: + case MySqlParser.KW_TABLE_NAME: + case MySqlParser.KW_TABLESPACE: + case MySqlParser.KW_TABLE_TYPE: + case MySqlParser.KW_TEMPORARY: + case MySqlParser.KW_TEMPTABLE: + case MySqlParser.KW_THAN: + case MySqlParser.KW_TRADITIONAL: + case MySqlParser.KW_TRANSACTION: + case MySqlParser.KW_TRANSACTIONAL: + case MySqlParser.KW_TRIGGERS: + case MySqlParser.KW_TRUNCATE: + case MySqlParser.KW_UNBOUNDED: + case MySqlParser.KW_UNDEFINED: + case MySqlParser.KW_UNDOFILE: + case MySqlParser.KW_UNDO_BUFFER_SIZE: + case MySqlParser.KW_UNINSTALL: + case MySqlParser.KW_UNKNOWN: + case MySqlParser.KW_UNTIL: + case MySqlParser.KW_UPGRADE: + case MySqlParser.KW_USER: + case MySqlParser.KW_USE_FRM: + case MySqlParser.KW_USER_RESOURCES: + case MySqlParser.KW_VALIDATION: + case MySqlParser.KW_VALUE: + case MySqlParser.KW_VARIABLES: + case MySqlParser.KW_VIEW: + case MySqlParser.KW_VIRTUAL: + case MySqlParser.KW_VISIBLE: + case MySqlParser.KW_WAIT: + case MySqlParser.KW_WARNINGS: + case MySqlParser.KW_WITHOUT: + case MySqlParser.KW_WORK: + case MySqlParser.KW_WRAPPER: + case MySqlParser.KW_X509: + case MySqlParser.KW_XA: + case MySqlParser.KW_XML: + case MySqlParser.KW_QUARTER: + case MySqlParser.KW_MONTH: + case MySqlParser.KW_DAY: + case MySqlParser.KW_HOUR: + case MySqlParser.KW_MINUTE: + case MySqlParser.KW_WEEK: + case MySqlParser.KW_SECOND: + case MySqlParser.KW_MICROSECOND: + case MySqlParser.KW_ADMIN: + case MySqlParser.KW_AUDIT_ABORT_EXEMPT: + case MySqlParser.KW_AUDIT_ADMIN: + case MySqlParser.KW_AUTHENTICATION_POLICY_ADMIN: + case MySqlParser.KW_BACKUP_ADMIN: + case MySqlParser.KW_BINLOG_ADMIN: + case MySqlParser.KW_BINLOG_ENCRYPTION_ADMIN: + case MySqlParser.KW_CLONE_ADMIN: + case MySqlParser.KW_CONNECTION_ADMIN: + case MySqlParser.KW_ENCRYPTION_KEY_ADMIN: + case MySqlParser.KW_EXECUTE: + case MySqlParser.KW_FILE: + case MySqlParser.KW_FIREWALL_ADMIN: + case MySqlParser.KW_FIREWALL_EXEMPT: + case MySqlParser.KW_FIREWALL_USER: + case MySqlParser.KW_GROUP_REPLICATION_ADMIN: + case MySqlParser.KW_INNODB_REDO_LOG_ARCHIVE: + case MySqlParser.KW_INVOKE: + case MySqlParser.KW_LAMBDA: + case MySqlParser.KW_NDB_STORED_USER: + case MySqlParser.KW_PASSWORDLESS_USER_ADMIN: + case MySqlParser.KW_PERSIST_RO_VARIABLES_ADMIN: + case MySqlParser.KW_PRIVILEGES: + case MySqlParser.KW_PROCESS: + case MySqlParser.KW_RELOAD: + case MySqlParser.KW_REPLICATION_APPLIER: + case MySqlParser.KW_REPLICATION_SLAVE_ADMIN: + case MySqlParser.KW_RESOURCE_GROUP_ADMIN: + case MySqlParser.KW_RESOURCE_GROUP_USER: + case MySqlParser.KW_ROLE_ADMIN: + case MySqlParser.KW_ROUTINE: + case MySqlParser.KW_S3: + case MySqlParser.KW_SESSION_VARIABLES_ADMIN: + case MySqlParser.KW_SET_USER_ID: + case MySqlParser.KW_SHOW_ROUTINE: + case MySqlParser.KW_SHUTDOWN: + case MySqlParser.KW_SUPER: + case MySqlParser.KW_SYSTEM_VARIABLES_ADMIN: + case MySqlParser.KW_TABLES: + case MySqlParser.KW_TABLE_ENCRYPTION_ADMIN: + case MySqlParser.KW_VERSION_TOKEN_ADMIN: + case MySqlParser.KW_XA_RECOVER_ADMIN: + case MySqlParser.KW_ARMSCII8: + case MySqlParser.KW_ASCII: + case MySqlParser.KW_BIG5: + case MySqlParser.KW_CP1250: + case MySqlParser.KW_CP1251: + case MySqlParser.KW_CP1256: + case MySqlParser.KW_CP1257: + case MySqlParser.KW_CP850: + case MySqlParser.KW_CP852: + case MySqlParser.KW_CP866: + case MySqlParser.KW_CP932: + case MySqlParser.KW_DEC8: + case MySqlParser.KW_EUCJPMS: + case MySqlParser.KW_EUCKR: + case MySqlParser.KW_GB18030: + case MySqlParser.KW_GB2312: + case MySqlParser.KW_GBK: + case MySqlParser.KW_GEOSTD8: + case MySqlParser.KW_GREEK: + case MySqlParser.KW_HEBREW: + case MySqlParser.KW_HP8: + case MySqlParser.KW_KEYBCS2: + case MySqlParser.KW_KOI8R: + case MySqlParser.KW_KOI8U: + case MySqlParser.KW_LATIN1: + case MySqlParser.KW_LATIN2: + case MySqlParser.KW_LATIN5: + case MySqlParser.KW_LATIN7: + case MySqlParser.KW_MACCE: + case MySqlParser.KW_MACROMAN: + case MySqlParser.KW_SJIS: + case MySqlParser.KW_SWE7: + case MySqlParser.KW_TIS620: + case MySqlParser.KW_UCS2: + case MySqlParser.KW_UJIS: + case MySqlParser.KW_UTF16: + case MySqlParser.KW_UTF16LE: + case MySqlParser.KW_UTF32: + case MySqlParser.KW_UTF8: + case MySqlParser.KW_UTF8MB3: + case MySqlParser.KW_UTF8MB4: + case MySqlParser.KW_ARCHIVE: + case MySqlParser.KW_BLACKHOLE: + case MySqlParser.KW_CSV: + case MySqlParser.KW_FEDERATED: + case MySqlParser.KW_INNODB: + case MySqlParser.KW_MEMORY: + case MySqlParser.KW_MRG_MYISAM: + case MySqlParser.KW_MYISAM: + case MySqlParser.KW_NDB: + case MySqlParser.KW_NDBCLUSTER: + case MySqlParser.KW_PERFORMANCE_SCHEMA: + case MySqlParser.KW_TOKUDB: + case MySqlParser.KW_REPEATABLE: + case MySqlParser.KW_COMMITTED: + case MySqlParser.KW_UNCOMMITTED: + case MySqlParser.KW_SERIALIZABLE: + case MySqlParser.KW_GEOMETRYCOLLECTION: + case MySqlParser.KW_LINESTRING: + case MySqlParser.KW_MULTILINESTRING: + case MySqlParser.KW_MULTIPOINT: + case MySqlParser.KW_MULTIPOLYGON: + case MySqlParser.KW_POINT: + case MySqlParser.KW_POLYGON: + case MySqlParser.KW_CATALOG_NAME: + case MySqlParser.KW_CHARSET: + case MySqlParser.KW_COLLATION: + case MySqlParser.KW_ENGINE_ATTRIBUTE: + case MySqlParser.KW_FORMAT: + case MySqlParser.KW_GET_FORMAT: + case MySqlParser.KW_RANDOM: + case MySqlParser.KW_REVERSE: + case MySqlParser.KW_ROW_COUNT: + case MySqlParser.KW_SCHEMA_NAME: + case MySqlParser.KW_SECONDARY_ENGINE_ATTRIBUTE: + case MySqlParser.KW_SRID: + case MySqlParser.KW_SYSTEM_USER: + case MySqlParser.KW_TP_CONNECTION_ADMIN: + case MySqlParser.KW_WEIGHT_STRING: + case MySqlParser.MOD: + case MySqlParser.CHARSET_REVERSE_QOUTE_STRING: + case MySqlParser.STRING_LITERAL: + case MySqlParser.ID: + { + this.state = 2973; + this.partitionNames(); + } + break; + case MySqlParser.KW_ALL: + { + this.state = 2974; + this.match(MySqlParser.KW_ALL); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + break; + case MySqlParser.KW_REPAIR: + localContext = new AlterByRepairPartitionContext(localContext); + this.enterOuterAlt(localContext, 13); + { + this.state = 2977; + this.match(MySqlParser.KW_REPAIR); + this.state = 2978; + this.match(MySqlParser.KW_PARTITION); + this.state = 2981; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_ARRAY: + case MySqlParser.KW_ATTRIBUTE: + case MySqlParser.KW_BUCKETS: + case MySqlParser.KW_CONDITION: + case MySqlParser.KW_CURRENT: + case MySqlParser.KW_CURRENT_USER: + case MySqlParser.KW_DATABASE: + case MySqlParser.KW_DEFAULT: + case MySqlParser.KW_DIAGNOSTICS: + case MySqlParser.KW_EMPTY: + case MySqlParser.KW_ENFORCED: + case MySqlParser.KW_EXCEPT: + case MySqlParser.KW_GROUP: + case MySqlParser.KW_IF: + case MySqlParser.KW_INSERT: + case MySqlParser.KW_LATERAL: + case MySqlParser.KW_LEFT: + case MySqlParser.KW_NUMBER: + case MySqlParser.KW_OPTIONAL: + case MySqlParser.KW_ORDER: + case MySqlParser.KW_PRIMARY: + case MySqlParser.KW_REPEAT: + case MySqlParser.KW_REPLACE: + case MySqlParser.KW_RIGHT: + case MySqlParser.KW_SCHEMA: + case MySqlParser.KW_SKIP_QUERY_REWRITE: + case MySqlParser.KW_STACKED: + case MySqlParser.KW_DATE: + case MySqlParser.KW_TIME: + case MySqlParser.KW_TIMESTAMP: + case MySqlParser.KW_DATETIME: + case MySqlParser.KW_YEAR: + case MySqlParser.KW_BINARY: + case MySqlParser.KW_TEXT: + case MySqlParser.KW_ENUM: + case MySqlParser.KW_SERIAL: + case MySqlParser.KW_JSON_TABLE: + case MySqlParser.KW_JSON_VALUE: + case MySqlParser.KW_NESTED: + case MySqlParser.KW_ORDINALITY: + case MySqlParser.KW_PATH: + case MySqlParser.KW_AVG: + case MySqlParser.KW_BIT_AND: + case MySqlParser.KW_BIT_OR: + case MySqlParser.KW_BIT_XOR: + case MySqlParser.KW_COUNT: + case MySqlParser.KW_CUME_DIST: + case MySqlParser.KW_DENSE_RANK: + case MySqlParser.KW_FIRST_VALUE: + case MySqlParser.KW_GROUP_CONCAT: + case MySqlParser.KW_LAG: + case MySqlParser.KW_LAST_VALUE: + case MySqlParser.KW_LEAD: + case MySqlParser.KW_MAX: + case MySqlParser.KW_MIN: + case MySqlParser.KW_NTILE: + case MySqlParser.KW_NTH_VALUE: + case MySqlParser.KW_PERCENT_RANK: + case MySqlParser.KW_RANK: + case MySqlParser.KW_ROW_NUMBER: + case MySqlParser.KW_STD: + case MySqlParser.KW_STDDEV: + case MySqlParser.KW_STDDEV_POP: + case MySqlParser.KW_STDDEV_SAMP: + case MySqlParser.KW_SUM: + case MySqlParser.KW_VAR_POP: + case MySqlParser.KW_VAR_SAMP: + case MySqlParser.KW_VARIANCE: + case MySqlParser.KW_CURRENT_DATE: + case MySqlParser.KW_CURRENT_TIME: + case MySqlParser.KW_CURRENT_TIMESTAMP: + case MySqlParser.KW_LOCALTIME: + case MySqlParser.KW_CURDATE: + case MySqlParser.KW_CURTIME: + case MySqlParser.KW_DATE_ADD: + case MySqlParser.KW_DATE_SUB: + case MySqlParser.KW_LOCALTIMESTAMP: + case MySqlParser.KW_NOW: + case MySqlParser.KW_POSITION: + case MySqlParser.KW_SUBSTR: + case MySqlParser.KW_SUBSTRING: + case MySqlParser.KW_SYSDATE: + case MySqlParser.KW_TRIM: + case MySqlParser.KW_UTC_DATE: + case MySqlParser.KW_UTC_TIME: + case MySqlParser.KW_UTC_TIMESTAMP: + case MySqlParser.KW_ACCOUNT: + case MySqlParser.KW_ACTION: + case MySqlParser.KW_AFTER: + case MySqlParser.KW_AGGREGATE: + case MySqlParser.KW_ALGORITHM: + case MySqlParser.KW_ANY: + case MySqlParser.KW_AT: + case MySqlParser.KW_AUTHORS: + case MySqlParser.KW_AUTOCOMMIT: + case MySqlParser.KW_AUTOEXTEND_SIZE: + case MySqlParser.KW_AUTO_INCREMENT: + case MySqlParser.KW_AVG_ROW_LENGTH: + case MySqlParser.KW_BEGIN: + case MySqlParser.KW_BINLOG: + case MySqlParser.KW_BIT: + case MySqlParser.KW_BLOCK: + case MySqlParser.KW_BOOL: + case MySqlParser.KW_BOOLEAN: + case MySqlParser.KW_BTREE: + case MySqlParser.KW_CACHE: + case MySqlParser.KW_CASCADED: + case MySqlParser.KW_CHAIN: + case MySqlParser.KW_CHANGED: + case MySqlParser.KW_CHANNEL: + case MySqlParser.KW_CHECKSUM: + case MySqlParser.KW_CIPHER: + case MySqlParser.KW_CLASS_ORIGIN: + case MySqlParser.KW_CLIENT: + case MySqlParser.KW_CLOSE: + case MySqlParser.KW_COALESCE: + case MySqlParser.KW_CODE: + case MySqlParser.KW_COLUMNS: + case MySqlParser.KW_COLUMN_FORMAT: + case MySqlParser.KW_COLUMN_NAME: + case MySqlParser.KW_COMMENT: + case MySqlParser.KW_COMMIT: + case MySqlParser.KW_COMPACT: + case MySqlParser.KW_COMPLETION: + case MySqlParser.KW_COMPRESSED: + case MySqlParser.KW_COMPRESSION: + case MySqlParser.KW_CONCURRENT: + case MySqlParser.KW_CONNECT: + case MySqlParser.KW_CONNECTION: + case MySqlParser.KW_CONSISTENT: + case MySqlParser.KW_CONSTRAINT_CATALOG: + case MySqlParser.KW_CONSTRAINT_SCHEMA: + case MySqlParser.KW_CONSTRAINT_NAME: + case MySqlParser.KW_CONTAINS: + case MySqlParser.KW_CONTEXT: + case MySqlParser.KW_CONTRIBUTORS: + case MySqlParser.KW_COPY: + case MySqlParser.KW_CPU: + case MySqlParser.KW_CURSOR_NAME: + case MySqlParser.KW_DATA: + case MySqlParser.KW_DATAFILE: + case MySqlParser.KW_DEALLOCATE: + case MySqlParser.KW_DEFAULT_AUTH: + case MySqlParser.KW_DEFINER: + case MySqlParser.KW_DELAY_KEY_WRITE: + case MySqlParser.KW_DES_KEY_FILE: + case MySqlParser.KW_DIRECTORY: + case MySqlParser.KW_DISABLE: + case MySqlParser.KW_DISCARD: + case MySqlParser.KW_DISK: + case MySqlParser.KW_DO: + case MySqlParser.KW_DUMPFILE: + case MySqlParser.KW_DUPLICATE: + case MySqlParser.KW_DYNAMIC: + case MySqlParser.KW_ENABLE: + case MySqlParser.KW_ENCRYPTION: + case MySqlParser.KW_END: + case MySqlParser.KW_ENDS: + case MySqlParser.KW_ENGINE: + case MySqlParser.KW_ENGINES: + case MySqlParser.KW_ERROR: + case MySqlParser.KW_ERRORS: + case MySqlParser.KW_ESCAPE: + case MySqlParser.KW_EVENT: + case MySqlParser.KW_EVENTS: + case MySqlParser.KW_EVERY: + case MySqlParser.KW_EXCHANGE: + case MySqlParser.KW_EXCLUSIVE: + case MySqlParser.KW_EXPIRE: + case MySqlParser.KW_EXPORT: + case MySqlParser.KW_EXTENDED: + case MySqlParser.KW_EXTENT_SIZE: + case MySqlParser.KW_FAILED_LOGIN_ATTEMPTS: + case MySqlParser.KW_FAST: + case MySqlParser.KW_FAULTS: + case MySqlParser.KW_FIELDS: + case MySqlParser.KW_FILE_BLOCK_SIZE: + case MySqlParser.KW_FILTER: + case MySqlParser.KW_FIRST: + case MySqlParser.KW_FIXED: + case MySqlParser.KW_FLUSH: + case MySqlParser.KW_FOLLOWS: + case MySqlParser.KW_FOUND: + case MySqlParser.KW_FULL: + case MySqlParser.KW_FUNCTION: + case MySqlParser.KW_GENERAL: + case MySqlParser.KW_GLOBAL: + case MySqlParser.KW_GRANTS: + case MySqlParser.KW_GROUP_REPLICATION: + case MySqlParser.KW_HANDLER: + case MySqlParser.KW_HASH: + case MySqlParser.KW_HELP: + case MySqlParser.KW_HISTORY: + case MySqlParser.KW_HOST: + case MySqlParser.KW_HOSTS: + case MySqlParser.KW_IDENTIFIED: + case MySqlParser.KW_IGNORE_SERVER_IDS: + case MySqlParser.KW_IMPORT: + case MySqlParser.KW_INDEXES: + case MySqlParser.KW_INITIAL_SIZE: + case MySqlParser.KW_INPLACE: + case MySqlParser.KW_INSERT_METHOD: + case MySqlParser.KW_INSTALL: + case MySqlParser.KW_INSTANCE: + case MySqlParser.KW_INSTANT: + case MySqlParser.KW_INVISIBLE: + case MySqlParser.KW_INVOKER: + case MySqlParser.KW_IO: + case MySqlParser.KW_IO_THREAD: + case MySqlParser.KW_IPC: + case MySqlParser.KW_ISOLATION: + case MySqlParser.KW_ISSUER: + case MySqlParser.KW_JSON: + case MySqlParser.KW_KEY_BLOCK_SIZE: + case MySqlParser.KW_LANGUAGE: + case MySqlParser.KW_LAST: + case MySqlParser.KW_LEAVES: + case MySqlParser.KW_LESS: + case MySqlParser.KW_LEVEL: + case MySqlParser.KW_LIST: + case MySqlParser.KW_LOCAL: + case MySqlParser.KW_LOGFILE: + case MySqlParser.KW_LOGS: + case MySqlParser.KW_MASTER: + case MySqlParser.KW_MASTER_AUTO_POSITION: + case MySqlParser.KW_MASTER_CONNECT_RETRY: + case MySqlParser.KW_MASTER_DELAY: + case MySqlParser.KW_MASTER_HEARTBEAT_PERIOD: + case MySqlParser.KW_MASTER_HOST: + case MySqlParser.KW_MASTER_LOG_FILE: + case MySqlParser.KW_MASTER_LOG_POS: + case MySqlParser.KW_MASTER_PASSWORD: + case MySqlParser.KW_MASTER_PORT: + case MySqlParser.KW_MASTER_RETRY_COUNT: + case MySqlParser.KW_MASTER_SSL: + case MySqlParser.KW_MASTER_SSL_CA: + case MySqlParser.KW_MASTER_SSL_CAPATH: + case MySqlParser.KW_MASTER_SSL_CERT: + case MySqlParser.KW_MASTER_SSL_CIPHER: + case MySqlParser.KW_MASTER_SSL_CRL: + case MySqlParser.KW_MASTER_SSL_CRLPATH: + case MySqlParser.KW_MASTER_SSL_KEY: + case MySqlParser.KW_MASTER_TLS_VERSION: + case MySqlParser.KW_MASTER_USER: + case MySqlParser.KW_MAX_CONNECTIONS_PER_HOUR: + case MySqlParser.KW_MAX_QUERIES_PER_HOUR: + case MySqlParser.KW_MAX_ROWS: + case MySqlParser.KW_MAX_SIZE: + case MySqlParser.KW_MAX_UPDATES_PER_HOUR: + case MySqlParser.KW_MAX_USER_CONNECTIONS: + case MySqlParser.KW_MEDIUM: + case MySqlParser.KW_MEMBER: + case MySqlParser.KW_MERGE: + case MySqlParser.KW_MESSAGE_TEXT: + case MySqlParser.KW_MID: + case MySqlParser.KW_MIGRATE: + case MySqlParser.KW_MIN_ROWS: + case MySqlParser.KW_MODE: + case MySqlParser.KW_MODIFY: + case MySqlParser.KW_MUTEX: + case MySqlParser.KW_MYSQL: + case MySqlParser.KW_MYSQL_ERRNO: + case MySqlParser.KW_NAME: + case MySqlParser.KW_NAMES: + case MySqlParser.KW_NCHAR: + case MySqlParser.KW_NEVER: + case MySqlParser.KW_NEXT: + case MySqlParser.KW_NO: + case MySqlParser.KW_NOWAIT: + case MySqlParser.KW_NODEGROUP: + case MySqlParser.KW_NONE: + case MySqlParser.KW_ODBC: + case MySqlParser.KW_OFFLINE: + case MySqlParser.KW_OFFSET: + case MySqlParser.KW_OF: + case MySqlParser.KW_OLD_PASSWORD: + case MySqlParser.KW_ONE: + case MySqlParser.KW_ONLINE: + case MySqlParser.KW_ONLY: + case MySqlParser.KW_OPEN: + case MySqlParser.KW_OPTIMIZER_COSTS: + case MySqlParser.KW_OPTIONS: + case MySqlParser.KW_OWNER: + case MySqlParser.KW_PACK_KEYS: + case MySqlParser.KW_PAGE: + case MySqlParser.KW_PAGE_CHECKSUM: + case MySqlParser.KW_PARSER: + case MySqlParser.KW_PARTIAL: + case MySqlParser.KW_PARTITIONING: + case MySqlParser.KW_PARTITIONS: + case MySqlParser.KW_PASSWORD: + case MySqlParser.KW_PASSWORD_LOCK_TIME: + case MySqlParser.KW_PHASE: + case MySqlParser.KW_PLUGIN: + case MySqlParser.KW_PLUGIN_DIR: + case MySqlParser.KW_PLUGINS: + case MySqlParser.KW_PORT: + case MySqlParser.KW_PRECEDES: + case MySqlParser.KW_PREPARE: + case MySqlParser.KW_PRESERVE: + case MySqlParser.KW_PREV: + case MySqlParser.KW_PROCESSLIST: + case MySqlParser.KW_PROFILE: + case MySqlParser.KW_PROFILES: + case MySqlParser.KW_PROXY: + case MySqlParser.KW_QUERY: + case MySqlParser.KW_QUICK: + case MySqlParser.KW_REBUILD: + case MySqlParser.KW_RECOVER: + case MySqlParser.KW_RECURSIVE: + case MySqlParser.KW_REDO_BUFFER_SIZE: + case MySqlParser.KW_REDUNDANT: + case MySqlParser.KW_RELAY: + case MySqlParser.KW_RELAY_LOG_FILE: + case MySqlParser.KW_RELAY_LOG_POS: + case MySqlParser.KW_RELAYLOG: + case MySqlParser.KW_REMOVE: + case MySqlParser.KW_REORGANIZE: + case MySqlParser.KW_REPAIR: + case MySqlParser.KW_REPLICATE_DO_DB: + case MySqlParser.KW_REPLICATE_DO_TABLE: + case MySqlParser.KW_REPLICATE_IGNORE_DB: + case MySqlParser.KW_REPLICATE_IGNORE_TABLE: + case MySqlParser.KW_REPLICATE_REWRITE_DB: + case MySqlParser.KW_REPLICATE_WILD_DO_TABLE: + case MySqlParser.KW_REPLICATE_WILD_IGNORE_TABLE: + case MySqlParser.KW_REPLICATION: + case MySqlParser.KW_RESET: + case MySqlParser.KW_RESUME: + case MySqlParser.KW_RETURNED_SQLSTATE: + case MySqlParser.KW_RETURNS: + case MySqlParser.KW_REUSE: + case MySqlParser.KW_ROLE: + case MySqlParser.KW_ROLLBACK: + case MySqlParser.KW_ROLLUP: + case MySqlParser.KW_ROTATE: + case MySqlParser.KW_ROW: + case MySqlParser.KW_ROWS: + case MySqlParser.KW_ROW_FORMAT: + case MySqlParser.KW_SAVEPOINT: + case MySqlParser.KW_SCHEDULE: + case MySqlParser.KW_SECURITY: + case MySqlParser.KW_SERVER: + case MySqlParser.KW_SESSION: + case MySqlParser.KW_SHARE: + case MySqlParser.KW_SHARED: + case MySqlParser.KW_SIGNED: + case MySqlParser.KW_SIMPLE: + case MySqlParser.KW_SLAVE: + case MySqlParser.KW_SLOW: + case MySqlParser.KW_SNAPSHOT: + case MySqlParser.KW_SOCKET: + case MySqlParser.KW_SOME: + case MySqlParser.KW_SONAME: + case MySqlParser.KW_SOUNDS: + case MySqlParser.KW_SOURCE: + case MySqlParser.KW_SQL_AFTER_GTIDS: + case MySqlParser.KW_SQL_AFTER_MTS_GAPS: + case MySqlParser.KW_SQL_BEFORE_GTIDS: + case MySqlParser.KW_SQL_BUFFER_RESULT: + case MySqlParser.KW_SQL_CACHE: + case MySqlParser.KW_SQL_NO_CACHE: + case MySqlParser.KW_SQL_THREAD: + case MySqlParser.KW_START: + case MySqlParser.KW_STARTS: + case MySqlParser.KW_STATS_AUTO_RECALC: + case MySqlParser.KW_STATS_PERSISTENT: + case MySqlParser.KW_STATS_SAMPLE_PAGES: + case MySqlParser.KW_STATUS: + case MySqlParser.KW_STOP: + case MySqlParser.KW_STORAGE: + case MySqlParser.KW_STRING: + case MySqlParser.KW_SUBCLASS_ORIGIN: + case MySqlParser.KW_SUBJECT: + case MySqlParser.KW_SUBPARTITION: + case MySqlParser.KW_SUBPARTITIONS: + case MySqlParser.KW_SUSPEND: + case MySqlParser.KW_SWAPS: + case MySqlParser.KW_SWITCHES: + case MySqlParser.KW_TABLE_NAME: + case MySqlParser.KW_TABLESPACE: + case MySqlParser.KW_TABLE_TYPE: + case MySqlParser.KW_TEMPORARY: + case MySqlParser.KW_TEMPTABLE: + case MySqlParser.KW_THAN: + case MySqlParser.KW_TRADITIONAL: + case MySqlParser.KW_TRANSACTION: + case MySqlParser.KW_TRANSACTIONAL: + case MySqlParser.KW_TRIGGERS: + case MySqlParser.KW_TRUNCATE: + case MySqlParser.KW_UNBOUNDED: + case MySqlParser.KW_UNDEFINED: + case MySqlParser.KW_UNDOFILE: + case MySqlParser.KW_UNDO_BUFFER_SIZE: + case MySqlParser.KW_UNINSTALL: + case MySqlParser.KW_UNKNOWN: + case MySqlParser.KW_UNTIL: + case MySqlParser.KW_UPGRADE: + case MySqlParser.KW_USER: + case MySqlParser.KW_USE_FRM: + case MySqlParser.KW_USER_RESOURCES: + case MySqlParser.KW_VALIDATION: + case MySqlParser.KW_VALUE: + case MySqlParser.KW_VARIABLES: + case MySqlParser.KW_VIEW: + case MySqlParser.KW_VIRTUAL: + case MySqlParser.KW_VISIBLE: + case MySqlParser.KW_WAIT: + case MySqlParser.KW_WARNINGS: + case MySqlParser.KW_WITHOUT: + case MySqlParser.KW_WORK: + case MySqlParser.KW_WRAPPER: + case MySqlParser.KW_X509: + case MySqlParser.KW_XA: + case MySqlParser.KW_XML: + case MySqlParser.KW_QUARTER: + case MySqlParser.KW_MONTH: + case MySqlParser.KW_DAY: + case MySqlParser.KW_HOUR: + case MySqlParser.KW_MINUTE: + case MySqlParser.KW_WEEK: + case MySqlParser.KW_SECOND: + case MySqlParser.KW_MICROSECOND: + case MySqlParser.KW_ADMIN: + case MySqlParser.KW_AUDIT_ABORT_EXEMPT: + case MySqlParser.KW_AUDIT_ADMIN: + case MySqlParser.KW_AUTHENTICATION_POLICY_ADMIN: + case MySqlParser.KW_BACKUP_ADMIN: + case MySqlParser.KW_BINLOG_ADMIN: + case MySqlParser.KW_BINLOG_ENCRYPTION_ADMIN: + case MySqlParser.KW_CLONE_ADMIN: + case MySqlParser.KW_CONNECTION_ADMIN: + case MySqlParser.KW_ENCRYPTION_KEY_ADMIN: + case MySqlParser.KW_EXECUTE: + case MySqlParser.KW_FILE: + case MySqlParser.KW_FIREWALL_ADMIN: + case MySqlParser.KW_FIREWALL_EXEMPT: + case MySqlParser.KW_FIREWALL_USER: + case MySqlParser.KW_GROUP_REPLICATION_ADMIN: + case MySqlParser.KW_INNODB_REDO_LOG_ARCHIVE: + case MySqlParser.KW_INVOKE: + case MySqlParser.KW_LAMBDA: + case MySqlParser.KW_NDB_STORED_USER: + case MySqlParser.KW_PASSWORDLESS_USER_ADMIN: + case MySqlParser.KW_PERSIST_RO_VARIABLES_ADMIN: + case MySqlParser.KW_PRIVILEGES: + case MySqlParser.KW_PROCESS: + case MySqlParser.KW_RELOAD: + case MySqlParser.KW_REPLICATION_APPLIER: + case MySqlParser.KW_REPLICATION_SLAVE_ADMIN: + case MySqlParser.KW_RESOURCE_GROUP_ADMIN: + case MySqlParser.KW_RESOURCE_GROUP_USER: + case MySqlParser.KW_ROLE_ADMIN: + case MySqlParser.KW_ROUTINE: + case MySqlParser.KW_S3: + case MySqlParser.KW_SESSION_VARIABLES_ADMIN: + case MySqlParser.KW_SET_USER_ID: + case MySqlParser.KW_SHOW_ROUTINE: + case MySqlParser.KW_SHUTDOWN: + case MySqlParser.KW_SUPER: + case MySqlParser.KW_SYSTEM_VARIABLES_ADMIN: + case MySqlParser.KW_TABLES: + case MySqlParser.KW_TABLE_ENCRYPTION_ADMIN: + case MySqlParser.KW_VERSION_TOKEN_ADMIN: + case MySqlParser.KW_XA_RECOVER_ADMIN: + case MySqlParser.KW_ARMSCII8: + case MySqlParser.KW_ASCII: + case MySqlParser.KW_BIG5: + case MySqlParser.KW_CP1250: + case MySqlParser.KW_CP1251: + case MySqlParser.KW_CP1256: + case MySqlParser.KW_CP1257: + case MySqlParser.KW_CP850: + case MySqlParser.KW_CP852: + case MySqlParser.KW_CP866: + case MySqlParser.KW_CP932: + case MySqlParser.KW_DEC8: + case MySqlParser.KW_EUCJPMS: + case MySqlParser.KW_EUCKR: + case MySqlParser.KW_GB18030: + case MySqlParser.KW_GB2312: + case MySqlParser.KW_GBK: + case MySqlParser.KW_GEOSTD8: + case MySqlParser.KW_GREEK: + case MySqlParser.KW_HEBREW: + case MySqlParser.KW_HP8: + case MySqlParser.KW_KEYBCS2: + case MySqlParser.KW_KOI8R: + case MySqlParser.KW_KOI8U: + case MySqlParser.KW_LATIN1: + case MySqlParser.KW_LATIN2: + case MySqlParser.KW_LATIN5: + case MySqlParser.KW_LATIN7: + case MySqlParser.KW_MACCE: + case MySqlParser.KW_MACROMAN: + case MySqlParser.KW_SJIS: + case MySqlParser.KW_SWE7: + case MySqlParser.KW_TIS620: + case MySqlParser.KW_UCS2: + case MySqlParser.KW_UJIS: + case MySqlParser.KW_UTF16: + case MySqlParser.KW_UTF16LE: + case MySqlParser.KW_UTF32: + case MySqlParser.KW_UTF8: + case MySqlParser.KW_UTF8MB3: + case MySqlParser.KW_UTF8MB4: + case MySqlParser.KW_ARCHIVE: + case MySqlParser.KW_BLACKHOLE: + case MySqlParser.KW_CSV: + case MySqlParser.KW_FEDERATED: + case MySqlParser.KW_INNODB: + case MySqlParser.KW_MEMORY: + case MySqlParser.KW_MRG_MYISAM: + case MySqlParser.KW_MYISAM: + case MySqlParser.KW_NDB: + case MySqlParser.KW_NDBCLUSTER: + case MySqlParser.KW_PERFORMANCE_SCHEMA: + case MySqlParser.KW_TOKUDB: + case MySqlParser.KW_REPEATABLE: + case MySqlParser.KW_COMMITTED: + case MySqlParser.KW_UNCOMMITTED: + case MySqlParser.KW_SERIALIZABLE: + case MySqlParser.KW_GEOMETRYCOLLECTION: + case MySqlParser.KW_LINESTRING: + case MySqlParser.KW_MULTILINESTRING: + case MySqlParser.KW_MULTIPOINT: + case MySqlParser.KW_MULTIPOLYGON: + case MySqlParser.KW_POINT: + case MySqlParser.KW_POLYGON: + case MySqlParser.KW_CATALOG_NAME: + case MySqlParser.KW_CHARSET: + case MySqlParser.KW_COLLATION: + case MySqlParser.KW_ENGINE_ATTRIBUTE: + case MySqlParser.KW_FORMAT: + case MySqlParser.KW_GET_FORMAT: + case MySqlParser.KW_RANDOM: + case MySqlParser.KW_REVERSE: + case MySqlParser.KW_ROW_COUNT: + case MySqlParser.KW_SCHEMA_NAME: + case MySqlParser.KW_SECONDARY_ENGINE_ATTRIBUTE: + case MySqlParser.KW_SRID: + case MySqlParser.KW_SYSTEM_USER: + case MySqlParser.KW_TP_CONNECTION_ADMIN: + case MySqlParser.KW_WEIGHT_STRING: + case MySqlParser.MOD: + case MySqlParser.CHARSET_REVERSE_QOUTE_STRING: + case MySqlParser.STRING_LITERAL: + case MySqlParser.ID: + { + this.state = 2979; + this.partitionNames(); + } + break; + case MySqlParser.KW_ALL: + { + this.state = 2980; + this.match(MySqlParser.KW_ALL); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + break; + case MySqlParser.KW_REMOVE: + localContext = new AlterByRemovePartitioningContext(localContext); + this.enterOuterAlt(localContext, 14); + { + this.state = 2983; + this.match(MySqlParser.KW_REMOVE); + this.state = 2984; + this.match(MySqlParser.KW_PARTITIONING); + } + break; + case MySqlParser.KW_UPGRADE: + localContext = new AlterByUpgradePartitioningContext(localContext); + this.enterOuterAlt(localContext, 15); + { + this.state = 2985; + this.match(MySqlParser.KW_UPGRADE); + this.state = 2986; + this.match(MySqlParser.KW_PARTITIONING); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + dropDatabase() { + let localContext = new DropDatabaseContext(this.context, this.state); + this.enterRule(localContext, 144, MySqlParser.RULE_dropDatabase); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 2989; + this.match(MySqlParser.KW_DROP); + this.state = 2990; + localContext._dbFormat = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 39 || _la === 152)) { + localContext._dbFormat = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 2992; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 361, this.context)) { + case 1: + { + this.state = 2991; + this.ifExists(); + } + break; + } + this.state = 2994; + this.databaseName(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + dropEvent() { + let localContext = new DropEventContext(this.context, this.state); + this.enterRule(localContext, 146, MySqlParser.RULE_dropEvent); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 2996; + this.match(MySqlParser.KW_DROP); + this.state = 2997; + this.match(MySqlParser.KW_EVENT); + this.state = 2999; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 362, this.context)) { + case 1: + { + this.state = 2998; + this.ifExists(); + } + break; + } + this.state = 3001; + localContext._event_name = this.fullId(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + dropIndex() { + let localContext = new DropIndexContext(this.context, this.state); + this.enterRule(localContext, 148, MySqlParser.RULE_dropIndex); + let _la; + try { + let alternative; + this.enterOuterAlt(localContext, 1); + { + this.state = 3003; + this.match(MySqlParser.KW_DROP); + this.state = 3004; + this.match(MySqlParser.KW_INDEX); + this.state = 3006; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 363, this.context)) { + case 1: + { + this.state = 3005; + localContext._intimeAction = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 508 || _la === 514)) { + localContext._intimeAction = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + break; + } + this.state = 3008; + this.indexName(); + this.state = 3009; + this.match(MySqlParser.KW_ON); + this.state = 3010; + this.tableName(); + this.state = 3023; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 367, this.context); + while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER) { + if (alternative === 1) { + { + this.state = 3021; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_ALGORITHM: + { + this.state = 3011; + this.match(MySqlParser.KW_ALGORITHM); + this.state = 3013; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 3012; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 3015; + localContext._algType = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 42 || _la === 357 || _la === 430)) { + localContext._algType = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + break; + case MySqlParser.KW_LOCK: + { + this.state = 3016; + this.match(MySqlParser.KW_LOCK); + this.state = 3018; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 3017; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 3020; + localContext._lockType = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 42 || _la === 389 || _la === 505 || _la === 595)) { + localContext._lockType = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + } + this.state = 3025; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 367, this.context); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + dropLogfileGroup() { + let localContext = new DropLogfileGroupContext(this.context, this.state); + this.enterRule(localContext, 150, MySqlParser.RULE_dropLogfileGroup); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 3026; + this.match(MySqlParser.KW_DROP); + this.state = 3027; + this.match(MySqlParser.KW_LOGFILE); + this.state = 3028; + this.match(MySqlParser.KW_GROUP); + this.state = 3029; + localContext._logfileGroupName = this.uid(); + this.state = 3030; + this.match(MySqlParser.KW_ENGINE); + this.state = 3032; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 3031; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 3034; + this.engineName(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + dropProcedure() { + let localContext = new DropProcedureContext(this.context, this.state); + this.enterRule(localContext, 152, MySqlParser.RULE_dropProcedure); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 3036; + this.match(MySqlParser.KW_DROP); + this.state = 3037; + this.match(MySqlParser.KW_PROCEDURE); + this.state = 3039; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 369, this.context)) { + case 1: + { + this.state = 3038; + this.ifExists(); + } + break; + } + this.state = 3041; + localContext._sp_name = this.fullId(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + dropFunction() { + let localContext = new DropFunctionContext(this.context, this.state); + this.enterRule(localContext, 154, MySqlParser.RULE_dropFunction); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 3043; + this.match(MySqlParser.KW_DROP); + this.state = 3044; + this.match(MySqlParser.KW_FUNCTION); + this.state = 3046; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 370, this.context)) { + case 1: + { + this.state = 3045; + this.ifExists(); + } + break; + } + this.state = 3048; + this.functionName(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + dropServer() { + let localContext = new DropServerContext(this.context, this.state); + this.enterRule(localContext, 156, MySqlParser.RULE_dropServer); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 3050; + this.match(MySqlParser.KW_DROP); + this.state = 3051; + this.match(MySqlParser.KW_SERVER); + this.state = 3053; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 371, this.context)) { + case 1: + { + this.state = 3052; + this.ifExists(); + } + break; + } + this.state = 3055; + localContext._serverName = this.uid(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + dropSpatial() { + let localContext = new DropSpatialContext(this.context, this.state); + this.enterRule(localContext, 158, MySqlParser.RULE_dropSpatial); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 3057; + this.match(MySqlParser.KW_DROP); + this.state = 3058; + this.match(MySqlParser.KW_SPATIAL); + this.state = 3059; + this.match(MySqlParser.KW_REFERENCE); + this.state = 3060; + this.match(MySqlParser.KW_SYSTEM); + this.state = 3062; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 78) { + { + this.state = 3061; + this.ifExists(); + } + } + this.state = 3064; + this.match(MySqlParser.DECIMAL_LITERAL); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + dropTable() { + let localContext = new DropTableContext(this.context, this.state); + this.enterRule(localContext, 160, MySqlParser.RULE_dropTable); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 3066; + this.match(MySqlParser.KW_DROP); + this.state = 3068; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 660) { + { + this.state = 3067; + this.match(MySqlParser.KW_TEMPORARY); + } + } + this.state = 3070; + this.match(MySqlParser.KW_TABLE); + this.state = 3072; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 374, this.context)) { + case 1: + { + this.state = 3071; + this.ifExists(); + } + break; + } + this.state = 3074; + this.tableNames(); + this.state = 3076; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 22 || _la === 146) { + { + this.state = 3075; + localContext._dropType = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 22 || _la === 146)) { + localContext._dropType = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + dropTablespace() { + let localContext = new DropTablespaceContext(this.context, this.state); + this.enterRule(localContext, 162, MySqlParser.RULE_dropTablespace); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 3078; + this.match(MySqlParser.KW_DROP); + this.state = 3080; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 180) { + { + this.state = 3079; + this.match(MySqlParser.KW_UNDO); + } + } + this.state = 3082; + this.match(MySqlParser.KW_TABLESPACE); + this.state = 3083; + this.tablespaceName(); + this.state = 3089; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 380) { + { + this.state = 3084; + this.match(MySqlParser.KW_ENGINE); + this.state = 3086; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 3085; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 3088; + this.engineName(); + } + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + dropTrigger() { + let localContext = new DropTriggerContext(this.context, this.state); + this.enterRule(localContext, 164, MySqlParser.RULE_dropTrigger); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 3091; + this.match(MySqlParser.KW_DROP); + this.state = 3092; + this.match(MySqlParser.KW_TRIGGER); + this.state = 3094; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 379, this.context)) { + case 1: + { + this.state = 3093; + this.ifExists(); + } + break; + } + this.state = 3096; + localContext._trigger_name = this.fullId(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + dropView() { + let localContext = new DropViewContext(this.context, this.state); + this.enterRule(localContext, 166, MySqlParser.RULE_dropView); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 3098; + this.match(MySqlParser.KW_DROP); + this.state = 3099; + this.match(MySqlParser.KW_VIEW); + this.state = 3101; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 380, this.context)) { + case 1: + { + this.state = 3100; + this.ifExists(); + } + break; + } + this.state = 3103; + this.viewName(); + this.state = 3108; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 3104; + this.match(MySqlParser.COMMA); + this.state = 3105; + this.viewName(); + } + } + this.state = 3110; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 3112; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 22 || _la === 146) { + { + this.state = 3111; + localContext._dropType = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 22 || _la === 146)) { + localContext._dropType = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + dropRole() { + let localContext = new DropRoleContext(this.context, this.state); + this.enterRule(localContext, 168, MySqlParser.RULE_dropRole); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 3114; + this.match(MySqlParser.KW_DROP); + this.state = 3115; + this.match(MySqlParser.KW_ROLE); + this.state = 3117; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 383, this.context)) { + case 1: + { + this.state = 3116; + this.ifExists(); + } + break; + } + this.state = 3119; + this.userOrRoleNames(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + setRole() { + let localContext = new SetRoleContext(this.context, this.state); + this.enterRule(localContext, 170, MySqlParser.RULE_setRole); + let _la; + try { + this.state = 3141; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 386, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 3121; + this.match(MySqlParser.KW_SET); + this.state = 3122; + this.match(MySqlParser.KW_DEFAULT); + this.state = 3123; + this.match(MySqlParser.KW_ROLE); + this.state = 3127; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 384, this.context)) { + case 1: + { + this.state = 3124; + this.match(MySqlParser.KW_NONE); + } + break; + case 2: + { + this.state = 3125; + this.match(MySqlParser.KW_ALL); + } + break; + case 3: + { + this.state = 3126; + this.userOrRoleNames(); + } + break; + } + this.state = 3129; + this.match(MySqlParser.KW_TO); + { + this.state = 3130; + this.userOrRoleName(); + } + this.state = 3135; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 3131; + this.match(MySqlParser.COMMA); + { + this.state = 3132; + this.userOrRoleName(); + } + } + } + this.state = 3137; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 3138; + this.match(MySqlParser.KW_SET); + this.state = 3139; + this.match(MySqlParser.KW_ROLE); + this.state = 3140; + this.roleOption(); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + renameTable() { + let localContext = new RenameTableContext(this.context, this.state); + this.enterRule(localContext, 172, MySqlParser.RULE_renameTable); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 3143; + this.match(MySqlParser.KW_RENAME); + this.state = 3144; + this.match(MySqlParser.KW_TABLE); + this.state = 3145; + this.renameTableClause(); + this.state = 3150; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 3146; + this.match(MySqlParser.COMMA); + this.state = 3147; + this.renameTableClause(); + } + } + this.state = 3152; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + renameTableClause() { + let localContext = new RenameTableClauseContext(this.context, this.state); + this.enterRule(localContext, 174, MySqlParser.RULE_renameTableClause); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 3153; + this.tableName(); + this.state = 3154; + this.match(MySqlParser.KW_TO); + this.state = 3155; + this.tableNameCreate(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + truncateTable() { + let localContext = new TruncateTableContext(this.context, this.state); + this.enterRule(localContext, 176, MySqlParser.RULE_truncateTable); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 3157; + this.match(MySqlParser.KW_TRUNCATE); + this.state = 3159; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 173) { + { + this.state = 3158; + this.match(MySqlParser.KW_TABLE); + } + } + this.state = 3161; + this.tableName(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + callStatement() { + let localContext = new CallStatementContext(this.context, this.state); + this.enterRule(localContext, 178, MySqlParser.RULE_callStatement); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 3163; + this.match(MySqlParser.KW_CALL); + this.state = 3164; + localContext._sp_name = this.fullId(); + this.state = 3171; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 390, this.context)) { + case 1: + { + this.state = 3165; + this.match(MySqlParser.LR_BRACKET); + this.state = 3168; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 389, this.context)) { + case 1: + { + this.state = 3166; + this.constants(); + } + break; + case 2: + { + this.state = 3167; + this.expressions(); + } + break; + } + this.state = 3170; + this.match(MySqlParser.RR_BRACKET); + } + break; + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + deleteStatement() { + let localContext = new DeleteStatementContext(this.context, this.state); + this.enterRule(localContext, 180, MySqlParser.RULE_deleteStatement); + try { + this.state = 3175; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 391, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 3173; + this.singleDeleteStatement(); + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 3174; + this.multipleDeleteStatement(); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + doStatement() { + let localContext = new DoStatementContext(this.context, this.state); + this.enterRule(localContext, 182, MySqlParser.RULE_doStatement); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 3177; + this.match(MySqlParser.KW_DO); + this.state = 3178; + this.expressions(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + handlerStatement() { + let localContext = new HandlerStatementContext(this.context, this.state); + this.enterRule(localContext, 184, MySqlParser.RULE_handlerStatement); + try { + this.state = 3184; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 392, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 3180; + this.handlerOpenStatement(); + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 3181; + this.handlerReadIndexStatement(); + } + break; + case 3: + this.enterOuterAlt(localContext, 3); + { + this.state = 3182; + this.handlerReadStatement(); + } + break; + case 4: + this.enterOuterAlt(localContext, 4); + { + this.state = 3183; + this.handlerCloseStatement(); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + insertStatement() { + let localContext = new InsertStatementContext(this.context, this.state); + this.enterRule(localContext, 186, MySqlParser.RULE_insertStatement); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 3186; + this.match(MySqlParser.KW_INSERT); + this.state = 3188; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 43 || _la === 76 || _la === 107) { + { + this.state = 3187; + localContext._priority = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 43 || _la === 76 || _la === 107)) { + localContext._priority = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + this.state = 3191; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 79) { + { + this.state = 3190; + this.match(MySqlParser.KW_IGNORE); + } + } + this.state = 3194; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 88) { + { + this.state = 3193; + this.match(MySqlParser.KW_INTO); + } + } + this.state = 3196; + this.tableName(); + this.state = 3203; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 130) { + { + this.state = 3197; + this.match(MySqlParser.KW_PARTITION); + this.state = 3198; + this.match(MySqlParser.LR_BRACKET); + this.state = 3200; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if ((((_la) & ~0x1F) === 0 && ((1 << _la) & 1074302976) !== 0) || ((((_la - 36)) & ~0x1F) === 0 && ((1 << (_la - 36)) & 11014219) !== 0) || ((((_la - 74)) & ~0x1F) === 0 && ((1 << (_la - 74)) & 18878481) !== 0) || ((((_la - 117)) & ~0x1F) === 0 && ((1 << (_la - 117)) & 100679969) !== 0) || ((((_la - 150)) & ~0x1F) === 0 && ((1 << (_la - 150)) & 1049605) !== 0) || ((((_la - 219)) & ~0x1F) === 0 && ((1 << (_la - 219)) & 5374495) !== 0) || ((((_la - 253)) & ~0x1F) === 0 && ((1 << (_la - 253)) & 4294967295) !== 0) || ((((_la - 285)) & ~0x1F) === 0 && ((1 << (_la - 285)) & 4261412607) !== 0) || ((((_la - 317)) & ~0x1F) === 0 && ((1 << (_la - 317)) & 4160741375) !== 0) || ((((_la - 349)) & ~0x1F) === 0 && ((1 << (_la - 349)) & 4026531839) !== 0) || ((((_la - 381)) & ~0x1F) === 0 && ((1 << (_la - 381)) & 1055907839) !== 0) || ((((_la - 413)) & ~0x1F) === 0 && ((1 << (_la - 413)) & 4294885367) !== 0) || ((((_la - 445)) & ~0x1F) === 0 && ((1 << (_la - 445)) & 3757571071) !== 0) || ((((_la - 478)) & ~0x1F) === 0 && ((1 << (_la - 478)) & 3755999231) !== 0) || ((((_la - 510)) & ~0x1F) === 0 && ((1 << (_la - 510)) & 3751780349) !== 0) || ((((_la - 542)) & ~0x1F) === 0 && ((1 << (_la - 542)) & 2141183997) !== 0) || ((((_la - 575)) & ~0x1F) === 0 && ((1 << (_la - 575)) & 2147483629) !== 0) || ((((_la - 633)) & ~0x1F) === 0 && ((1 << (_la - 633)) & 4294934527) !== 0) || ((((_la - 665)) & ~0x1F) === 0 && ((1 << (_la - 665)) & 4278189053) !== 0) || ((((_la - 697)) & ~0x1F) === 0 && ((1 << (_la - 697)) & 1644099327) !== 0) || ((((_la - 729)) & ~0x1F) === 0 && ((1 << (_la - 729)) & 4294900735) !== 0) || ((((_la - 761)) & ~0x1F) === 0 && ((1 << (_la - 761)) & 4294967295) !== 0) || ((((_la - 793)) & ~0x1F) === 0 && ((1 << (_la - 793)) & 4288675839) !== 0) || ((((_la - 825)) & ~0x1F) === 0 && ((1 << (_la - 825)) & 2147527671) !== 0) || ((((_la - 879)) & ~0x1F) === 0 && ((1 << (_la - 879)) & 1033) !== 0)) { + { + this.state = 3199; + this.partitionNames(); + } + } + this.state = 3202; + this.match(MySqlParser.RR_BRACKET); + } + } + this.state = 3216; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 401, this.context)) { + case 1: + { + this.state = 3206; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 398, this.context)) { + case 1: + { + this.state = 3205; + this.fullColumnNames(); + } + break; + } + this.state = 3210; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 399, this.context)) { + case 1: + { + this.state = 3208; + this.valuesOrValueList(); + } + break; + case 2: + { + this.state = 3209; + this.selectOrTableOrValues(); + } + break; + } + this.state = 3213; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 400, this.context)) { + case 1: + { + this.state = 3212; + this.asRowAlias(); + } + break; + } + } + break; + case 2: + { + this.state = 3215; + this.setAssignmentList(); + } + break; + } + this.state = 3219; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 13) { + { + this.state = 3218; + this.asRowAlias(); + } + } + this.state = 3233; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 119) { + { + this.state = 3221; + this.match(MySqlParser.KW_ON); + this.state = 3222; + this.match(MySqlParser.KW_DUPLICATE); + this.state = 3223; + this.match(MySqlParser.KW_KEY); + this.state = 3224; + this.match(MySqlParser.KW_UPDATE); + this.state = 3225; + localContext._duplicatedFirst = this.updatedElement(); + this.state = 3230; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 3226; + this.match(MySqlParser.COMMA); + this.state = 3227; + localContext._updatedElement = this.updatedElement(); + localContext._duplicatedElements.push(localContext._updatedElement); + } + } + this.state = 3232; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + asRowAlias() { + let localContext = new AsRowAliasContext(this.context, this.state); + this.enterRule(localContext, 188, MySqlParser.RULE_asRowAlias); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 3235; + this.match(MySqlParser.KW_AS); + this.state = 3236; + localContext._rowAlias = this.uid(); + this.state = 3238; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 405, this.context)) { + case 1: + { + this.state = 3237; + this.fullColumnNames(); + } + break; + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + selectOrTableOrValues() { + let localContext = new SelectOrTableOrValuesContext(this.context, this.state); + this.enterRule(localContext, 190, MySqlParser.RULE_selectOrTableOrValues); + try { + this.state = 3244; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_SELECT: + case MySqlParser.LR_BRACKET: + this.enterOuterAlt(localContext, 1); + { + this.state = 3240; + this.selectStatement(); + } + break; + case MySqlParser.KW_TABLE: + this.enterOuterAlt(localContext, 2); + { + this.state = 3241; + this.match(MySqlParser.KW_TABLE); + this.state = 3242; + this.tableName(); + } + break; + case MySqlParser.KW_VALUES: + this.enterOuterAlt(localContext, 3); + { + this.state = 3243; + this.rowValuesList(); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + interSectStatement() { + let localContext = new InterSectStatementContext(this.context, this.state); + this.enterRule(localContext, 192, MySqlParser.RULE_interSectStatement); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 3246; + this.interSectQuery(); + this.state = 3252; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + do { + { + { + this.state = 3247; + this.match(MySqlParser.KW_INTERSECT); + this.state = 3249; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 7 || _la === 49) { + { + this.state = 3248; + _la = this.tokenStream.LA(1); + if (!(_la === 7 || _la === 49)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + this.state = 3251; + this.interSectQuery(); + } + } + this.state = 3254; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } while (_la === 828); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + interSectQuery() { + let localContext = new InterSectQueryContext(this.context, this.state); + this.enterRule(localContext, 194, MySqlParser.RULE_interSectQuery); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 3257; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 866) { + { + this.state = 3256; + this.match(MySqlParser.LR_BRACKET); + } + } + this.state = 3259; + this.querySpecification(); + this.state = 3261; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 410, this.context)) { + case 1: + { + this.state = 3260; + this.match(MySqlParser.RR_BRACKET); + } + break; + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + loadDataStatement() { + let localContext = new LoadDataStatementContext(this.context, this.state); + this.enterRule(localContext, 196, MySqlParser.RULE_loadDataStatement); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 3263; + this.match(MySqlParser.KW_LOAD); + this.state = 3264; + this.match(MySqlParser.KW_DATA); + this.state = 3266; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 107 || _la === 347) { + { + this.state = 3265; + localContext._priority = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 107 || _la === 347)) { + localContext._priority = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + this.state = 3269; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 450) { + { + this.state = 3268; + this.match(MySqlParser.KW_LOCAL); + } + } + this.state = 3271; + this.match(MySqlParser.KW_INFILE); + this.state = 3272; + localContext._filename = this.match(MySqlParser.STRING_LITERAL); + this.state = 3274; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 79 || _la === 143) { + { + this.state = 3273; + localContext._violation = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 79 || _la === 143)) { + localContext._violation = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + this.state = 3276; + this.match(MySqlParser.KW_INTO); + this.state = 3277; + this.match(MySqlParser.KW_TABLE); + this.state = 3278; + this.tableName(); + this.state = 3284; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 130) { + { + this.state = 3279; + this.match(MySqlParser.KW_PARTITION); + this.state = 3280; + this.match(MySqlParser.LR_BRACKET); + this.state = 3281; + this.partitionNames(); + this.state = 3282; + this.match(MySqlParser.RR_BRACKET); + } + } + this.state = 3289; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 26) { + { + this.state = 3286; + this.match(MySqlParser.KW_CHARACTER); + this.state = 3287; + this.match(MySqlParser.KW_SET); + this.state = 3288; + localContext._charset = this.charsetName(); + } + } + this.state = 3297; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 337 || _la === 398) { + { + this.state = 3291; + localContext._fieldsFormat = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 337 || _la === 398)) { + localContext._fieldsFormat = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 3293; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + do { + { + { + this.state = 3292; + this.selectFieldsInto(); + } + } + this.state = 3295; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } while (_la === 56 || _la === 58 || _la === 123 || _la === 174); + } + } + this.state = 3305; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 102) { + { + this.state = 3299; + this.match(MySqlParser.KW_LINES); + this.state = 3301; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + do { + { + { + this.state = 3300; + this.selectLinesInto(); + } + } + this.state = 3303; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } while (_la === 171 || _la === 174); + } + } + this.state = 3311; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 79) { + { + this.state = 3307; + this.match(MySqlParser.KW_IGNORE); + this.state = 3308; + this.decimalLiteral(); + this.state = 3309; + localContext._linesFormat = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 102 || _la === 587)) { + localContext._linesFormat = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + this.state = 3324; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 422, this.context)) { + case 1: + { + this.state = 3313; + this.match(MySqlParser.LR_BRACKET); + this.state = 3314; + this.assignmentField(); + this.state = 3319; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 3315; + this.match(MySqlParser.COMMA); + this.state = 3316; + this.assignmentField(); + } + } + this.state = 3321; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 3322; + this.match(MySqlParser.RR_BRACKET); + } + break; + } + this.state = 3335; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 424, this.context)) { + case 1: + { + this.state = 3326; + this.match(MySqlParser.KW_SET); + this.state = 3327; + this.updatedElement(); + this.state = 3332; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 3328; + this.match(MySqlParser.COMMA); + this.state = 3329; + this.updatedElement(); + } + } + this.state = 3334; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + break; + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + loadXmlStatement() { + let localContext = new LoadXmlStatementContext(this.context, this.state); + this.enterRule(localContext, 198, MySqlParser.RULE_loadXmlStatement); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 3337; + this.match(MySqlParser.KW_LOAD); + this.state = 3338; + this.match(MySqlParser.KW_XML); + this.state = 3340; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 107 || _la === 347) { + { + this.state = 3339; + localContext._priority = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 107 || _la === 347)) { + localContext._priority = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + this.state = 3343; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 450) { + { + this.state = 3342; + this.match(MySqlParser.KW_LOCAL); + } + } + this.state = 3345; + this.match(MySqlParser.KW_INFILE); + this.state = 3346; + localContext._filename = this.match(MySqlParser.STRING_LITERAL); + this.state = 3348; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 79 || _la === 143) { + { + this.state = 3347; + localContext._violation = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 79 || _la === 143)) { + localContext._violation = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + this.state = 3350; + this.match(MySqlParser.KW_INTO); + this.state = 3351; + this.match(MySqlParser.KW_TABLE); + this.state = 3352; + this.tableName(); + this.state = 3356; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 26) { + { + this.state = 3353; + this.match(MySqlParser.KW_CHARACTER); + this.state = 3354; + this.match(MySqlParser.KW_SET); + this.state = 3355; + localContext._charset = this.charsetName(); + } + } + this.state = 3368; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 587) { + { + this.state = 3358; + this.match(MySqlParser.KW_ROWS); + this.state = 3359; + this.match(MySqlParser.KW_IDENTIFIED); + this.state = 3360; + this.match(MySqlParser.KW_BY); + this.state = 3362; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 859) { + { + this.state = 3361; + this.match(MySqlParser.LESS_SYMBOL); + } + } + this.state = 3364; + localContext._tag = this.match(MySqlParser.STRING_LITERAL); + this.state = 3366; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 858) { + { + this.state = 3365; + this.match(MySqlParser.GREATER_SYMBOL); + } + } + } + } + this.state = 3374; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 79) { + { + this.state = 3370; + this.match(MySqlParser.KW_IGNORE); + this.state = 3371; + this.decimalLiteral(); + this.state = 3372; + localContext._linesFormat = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 102 || _la === 587)) { + localContext._linesFormat = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + this.state = 3387; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 434, this.context)) { + case 1: + { + this.state = 3376; + this.match(MySqlParser.LR_BRACKET); + this.state = 3377; + this.assignmentField(); + this.state = 3382; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 3378; + this.match(MySqlParser.COMMA); + this.state = 3379; + this.assignmentField(); + } + } + this.state = 3384; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 3385; + this.match(MySqlParser.RR_BRACKET); + } + break; + } + this.state = 3398; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 436, this.context)) { + case 1: + { + this.state = 3389; + this.match(MySqlParser.KW_SET); + this.state = 3390; + this.updatedElement(); + this.state = 3395; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 3391; + this.match(MySqlParser.COMMA); + this.state = 3392; + this.updatedElement(); + } + } + this.state = 3397; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + break; + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + parenthesizedQuery() { + let localContext = new ParenthesizedQueryContext(this.context, this.state); + this.enterRule(localContext, 200, MySqlParser.RULE_parenthesizedQuery); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 3400; + this.match(MySqlParser.LR_BRACKET); + this.state = 3401; + this.parenthesizedQueryExpression(); + this.state = 3403; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 125) { + { + this.state = 3402; + this.orderByClause(); + } + } + this.state = 3406; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 100) { + { + this.state = 3405; + this.limitClause(); + } + } + this.state = 3408; + this.match(MySqlParser.RR_BRACKET); + this.state = 3410; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 125) { + { + this.state = 3409; + this.orderByClause(); + } + } + this.state = 3413; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 100) { + { + this.state = 3412; + this.limitClause(); + } + } + this.state = 3416; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 88) { + { + this.state = 3415; + this.intoClause(); + } + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + replaceStatement() { + let localContext = new ReplaceStatementContext(this.context, this.state); + this.enterRule(localContext, 202, MySqlParser.RULE_replaceStatement); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 3418; + this.match(MySqlParser.KW_REPLACE); + this.state = 3420; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 43 || _la === 107) { + { + this.state = 3419; + localContext._priority = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 43 || _la === 107)) { + localContext._priority = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + this.state = 3423; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 88) { + { + this.state = 3422; + this.match(MySqlParser.KW_INTO); + } + } + this.state = 3425; + this.tableName(); + this.state = 3431; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 130) { + { + this.state = 3426; + this.match(MySqlParser.KW_PARTITION); + this.state = 3427; + this.match(MySqlParser.LR_BRACKET); + this.state = 3428; + this.partitionNames(); + this.state = 3429; + this.match(MySqlParser.RR_BRACKET); + } + } + this.state = 3441; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_SELECT: + case MySqlParser.KW_TABLE: + case MySqlParser.KW_VALUES: + case MySqlParser.KW_VALUE: + case MySqlParser.LR_BRACKET: + { + this.state = 3437; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 445, this.context)) { + case 1: + { + this.state = 3433; + this.match(MySqlParser.LR_BRACKET); + this.state = 3434; + this.columnNames(); + this.state = 3435; + this.match(MySqlParser.RR_BRACKET); + } + break; + } + this.state = 3439; + this.replaceStatementValuesOrSelectOrTable(); + } + break; + case MySqlParser.KW_SET: + { + this.state = 3440; + this.setAssignmentList(); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + selectStatement() { + let localContext = new SelectStatementContext(this.context, this.state); + this.enterRule(localContext, 204, MySqlParser.RULE_selectStatement); + let _la; + try { + let alternative; + this.state = 3502; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_SELECT: + localContext = new UnionAndLateralSelectContext(localContext); + this.enterOuterAlt(localContext, 1); + { + this.state = 3443; + this.querySpecification(); + this.state = 3447; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 447, this.context); + while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER) { + if (alternative === 1) { + { + { + this.state = 3444; + this.unionStatement(); + } + } + } + this.state = 3449; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 447, this.context); + } + this.state = 3458; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 450, this.context)) { + case 1: + { + this.state = 3450; + this.match(MySqlParser.KW_UNION); + this.state = 3452; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 7 || _la === 49) { + { + this.state = 3451; + localContext._unionType = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 7 || _la === 49)) { + localContext._unionType = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + this.state = 3456; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_SELECT: + { + this.state = 3454; + this.querySpecification(); + } + break; + case MySqlParser.LR_BRACKET: + { + this.state = 3455; + this.queryExpression(); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + break; + } + this.state = 3464; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 451, this.context); + while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER) { + if (alternative === 1) { + { + { + this.state = 3460; + this.match(MySqlParser.COMMA); + this.state = 3461; + this.lateralStatement(); + } + } + } + this.state = 3466; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 451, this.context); + } + this.state = 3468; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 452, this.context)) { + case 1: + { + this.state = 3467; + this.orderByClause(); + } + break; + } + this.state = 3471; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 453, this.context)) { + case 1: + { + this.state = 3470; + this.limitClause(); + } + break; + } + this.state = 3474; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 454, this.context)) { + case 1: + { + this.state = 3473; + this.lockClause(); + } + break; + } + this.state = 3477; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 455, this.context)) { + case 1: + { + this.state = 3476; + this.intoClause(); + } + break; + } + } + break; + case MySqlParser.LR_BRACKET: + localContext = new SelectExpressionContext(localContext); + this.enterOuterAlt(localContext, 2); + { + this.state = 3479; + this.queryExpression(); + this.state = 3483; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 456, this.context); + while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER) { + if (alternative === 1) { + { + { + this.state = 3480; + this.unionStatement(); + } + } + } + this.state = 3485; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 456, this.context); + } + this.state = 3491; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 458, this.context)) { + case 1: + { + this.state = 3486; + this.match(MySqlParser.KW_UNION); + this.state = 3488; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 7 || _la === 49) { + { + this.state = 3487; + localContext._unionType = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 7 || _la === 49)) { + localContext._unionType = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + this.state = 3490; + this.queryExpression(); + } + break; + } + this.state = 3494; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 459, this.context)) { + case 1: + { + this.state = 3493; + this.orderByClause(); + } + break; + } + this.state = 3497; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 460, this.context)) { + case 1: + { + this.state = 3496; + this.limitClause(); + } + break; + } + this.state = 3500; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 461, this.context)) { + case 1: + { + this.state = 3499; + this.lockClause(); + } + break; + } + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + setOperations() { + let localContext = new SetOperationsContext(this.context, this.state); + this.enterRule(localContext, 206, MySqlParser.RULE_setOperations); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 3505; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 194) { + { + this.state = 3504; + this.withClause(); + } + } + this.state = 3507; + this.queryExpressionBody(0); + this.state = 3509; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 125) { + { + this.state = 3508; + this.orderByClause(); + } + } + this.state = 3512; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 100) { + { + this.state = 3511; + this.limitClause(); + } + } + this.state = 3515; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 88) { + { + this.state = 3514; + this.intoClause(); + } + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + queryExpressionBody(_p) { + if (_p === undefined) { + _p = 0; + } + let parentContext = this.context; + let parentState = this.state; + let localContext = new QueryExpressionBodyContext(this.context, parentState); + let previousContext = localContext; + let _startState = 208; + this.enterRecursionRule(localContext, 208, MySqlParser.RULE_queryExpressionBody, _p); + let _la; + try { + let alternative; + this.enterOuterAlt(localContext, 1); + { + { + this.state = 3518; + this.queryItem(0); + } + this.context.stop = this.tokenStream.LT(-1); + this.state = 3534; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 470, this.context); + while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER) { + if (alternative === 1) { + if (this._parseListeners != null) { + this.triggerExitRuleEvent(); + } + previousContext = localContext; + { + this.state = 3532; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 469, this.context)) { + case 1: + { + localContext = new QueryExpressionBodyContext(parentContext, parentState); + this.pushNewRecursionContext(localContext, _startState, MySqlParser.RULE_queryExpressionBody); + this.state = 3520; + if (!(this.precpred(this.context, 2))) { + throw this.createFailedPredicateException("this.precpred(this.context, 2)"); + } + this.state = 3521; + this.match(MySqlParser.KW_UNION); + this.state = 3523; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 7 || _la === 49) { + { + this.state = 3522; + _la = this.tokenStream.LA(1); + if (!(_la === 7 || _la === 49)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + this.state = 3525; + this.queryItem(0); + } + break; + case 2: + { + localContext = new QueryExpressionBodyContext(parentContext, parentState); + this.pushNewRecursionContext(localContext, _startState, MySqlParser.RULE_queryExpressionBody); + this.state = 3526; + if (!(this.precpred(this.context, 1))) { + throw this.createFailedPredicateException("this.precpred(this.context, 1)"); + } + this.state = 3527; + this.match(MySqlParser.KW_EXCEPT); + this.state = 3529; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 7 || _la === 49) { + { + this.state = 3528; + _la = this.tokenStream.LA(1); + if (!(_la === 7 || _la === 49)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + this.state = 3531; + this.queryItem(0); + } + break; + } + } + } + this.state = 3536; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 470, this.context); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.unrollRecursionContexts(parentContext); + } + return localContext; + } + queryItem(_p) { + if (_p === undefined) { + _p = 0; + } + let parentContext = this.context; + let parentState = this.state; + let localContext = new QueryItemContext(this.context, parentState); + let previousContext = localContext; + let _startState = 210; + this.enterRecursionRule(localContext, 210, MySqlParser.RULE_queryItem, _p); + let _la; + try { + let alternative; + this.enterOuterAlt(localContext, 1); + { + { + this.state = 3538; + this.queryPrimary(); + } + this.context.stop = this.tokenStream.LT(-1); + this.state = 3548; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 472, this.context); + while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER) { + if (alternative === 1) { + if (this._parseListeners != null) { + this.triggerExitRuleEvent(); + } + previousContext = localContext; + { + { + localContext = new QueryItemContext(parentContext, parentState); + this.pushNewRecursionContext(localContext, _startState, MySqlParser.RULE_queryItem); + this.state = 3540; + if (!(this.precpred(this.context, 1))) { + throw this.createFailedPredicateException("this.precpred(this.context, 1)"); + } + this.state = 3541; + this.match(MySqlParser.KW_INTERSECT); + this.state = 3543; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 7 || _la === 49) { + { + this.state = 3542; + _la = this.tokenStream.LA(1); + if (!(_la === 7 || _la === 49)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + this.state = 3545; + this.queryPrimary(); + } + } + } + this.state = 3550; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 472, this.context); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.unrollRecursionContexts(parentContext); + } + return localContext; + } + queryPrimary() { + let localContext = new QueryPrimaryContext(this.context, this.state); + this.enterRule(localContext, 212, MySqlParser.RULE_queryPrimary); + let _la; + try { + this.state = 3565; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 476, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 3551; + this.queryBlock(); + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 3552; + this.match(MySqlParser.LR_BRACKET); + this.state = 3553; + this.queryExpressionBody(0); + this.state = 3555; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 125) { + { + this.state = 3554; + this.orderByClause(); + } + } + this.state = 3558; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 100) { + { + this.state = 3557; + this.limitClause(); + } + } + this.state = 3561; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 88) { + { + this.state = 3560; + this.intoClause(); + } + } + this.state = 3563; + this.match(MySqlParser.RR_BRACKET); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + updateStatement() { + let localContext = new UpdateStatementContext(this.context, this.state); + this.enterRule(localContext, 214, MySqlParser.RULE_updateStatement); + try { + this.state = 3569; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 477, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 3567; + this.singleUpdateStatement(); + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 3568; + this.multipleUpdateStatement(); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + valuesStatement() { + let localContext = new ValuesStatementContext(this.context, this.state); + this.enterRule(localContext, 216, MySqlParser.RULE_valuesStatement); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 3571; + this.rowValuesList(); + this.state = 3575; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 478, this.context)) { + case 1: + { + this.state = 3572; + this.match(MySqlParser.KW_ORDER); + this.state = 3573; + this.match(MySqlParser.KW_BY); + this.state = 3574; + this.indexColumnName(); + } + break; + } + this.state = 3579; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 479, this.context)) { + case 1: + { + this.state = 3577; + this.match(MySqlParser.KW_LIMIT); + this.state = 3578; + this.limitClauseAtom(); + } + break; + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + parenthesizedQueryExpression() { + let localContext = new ParenthesizedQueryExpressionContext(this.context, this.state); + this.enterRule(localContext, 218, MySqlParser.RULE_parenthesizedQueryExpression); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 3581; + this.queryBlock(); + this.state = 3586; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 59 || _la === 181 || _la === 828) { + { + { + this.state = 3582; + _la = this.tokenStream.LA(1); + if (!(_la === 59 || _la === 181 || _la === 828)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 3583; + this.queryBlock(); + } + } + this.state = 3588; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 3590; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 481, this.context)) { + case 1: + { + this.state = 3589; + this.orderByClause(); + } + break; + } + this.state = 3593; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 482, this.context)) { + case 1: + { + this.state = 3592; + this.limitClause(); + } + break; + } + this.state = 3596; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 88) { + { + this.state = 3595; + this.intoClause(); + } + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + queryBlock() { + let localContext = new QueryBlockContext(this.context, this.state); + this.enterRule(localContext, 220, MySqlParser.RULE_queryBlock); + try { + this.state = 3601; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_SELECT: + case MySqlParser.LR_BRACKET: + this.enterOuterAlt(localContext, 1); + { + this.state = 3598; + this.selectStatement(); + } + break; + case MySqlParser.KW_TABLE: + this.enterOuterAlt(localContext, 2); + { + this.state = 3599; + this.tableStatement(); + } + break; + case MySqlParser.KW_VALUES: + this.enterOuterAlt(localContext, 3); + { + this.state = 3600; + this.valuesStatement(); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + replaceStatementValuesOrSelectOrTable() { + let localContext = new ReplaceStatementValuesOrSelectOrTableContext(this.context, this.state); + this.enterRule(localContext, 222, MySqlParser.RULE_replaceStatementValuesOrSelectOrTable); + try { + this.state = 3608; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 485, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 3603; + this.selectStatement(); + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 3604; + this.match(MySqlParser.KW_TABLE); + this.state = 3605; + this.tableName(); + } + break; + case 3: + this.enterOuterAlt(localContext, 3); + { + this.state = 3606; + this.valuesOrValueList(); + } + break; + case 4: + this.enterOuterAlt(localContext, 4); + { + this.state = 3607; + this.rowValuesList(); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + rowValuesList() { + let localContext = new RowValuesListContext(this.context, this.state); + this.enterRule(localContext, 224, MySqlParser.RULE_rowValuesList); + try { + let alternative; + this.enterOuterAlt(localContext, 1); + { + this.state = 3610; + this.match(MySqlParser.KW_VALUES); + this.state = 3611; + this.match(MySqlParser.KW_ROW); + this.state = 3612; + this.expressionsWithDefaults(); + this.state = 3618; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 486, this.context); + while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER) { + if (alternative === 1) { + { + { + this.state = 3613; + this.match(MySqlParser.COMMA); + this.state = 3614; + this.match(MySqlParser.KW_ROW); + this.state = 3615; + this.expressionsWithDefaults(); + } + } + } + this.state = 3620; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 486, this.context); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + setAssignmentList() { + let localContext = new SetAssignmentListContext(this.context, this.state); + this.enterRule(localContext, 226, MySqlParser.RULE_setAssignmentList); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 3621; + this.match(MySqlParser.KW_SET); + this.state = 3622; + localContext._setFirst = this.updatedElement(); + this.state = 3627; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 3623; + this.match(MySqlParser.COMMA); + this.state = 3624; + localContext._updatedElement = this.updatedElement(); + localContext._setElements.push(localContext._updatedElement); + } + } + this.state = 3629; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + updatedElement() { + let localContext = new UpdatedElementContext(this.context, this.state); + this.enterRule(localContext, 228, MySqlParser.RULE_updatedElement); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 3630; + this.columnName(); + this.state = 3631; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 3632; + this.expressionOrDefault(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + assignmentField() { + let localContext = new AssignmentFieldContext(this.context, this.state); + this.enterRule(localContext, 230, MySqlParser.RULE_assignmentField); + try { + this.state = 3636; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_ARRAY: + case MySqlParser.KW_ATTRIBUTE: + case MySqlParser.KW_BUCKETS: + case MySqlParser.KW_CONDITION: + case MySqlParser.KW_CURRENT: + case MySqlParser.KW_CURRENT_USER: + case MySqlParser.KW_DATABASE: + case MySqlParser.KW_DEFAULT: + case MySqlParser.KW_DIAGNOSTICS: + case MySqlParser.KW_EMPTY: + case MySqlParser.KW_ENFORCED: + case MySqlParser.KW_EXCEPT: + case MySqlParser.KW_GROUP: + case MySqlParser.KW_IF: + case MySqlParser.KW_INSERT: + case MySqlParser.KW_LATERAL: + case MySqlParser.KW_LEFT: + case MySqlParser.KW_NUMBER: + case MySqlParser.KW_OPTIONAL: + case MySqlParser.KW_ORDER: + case MySqlParser.KW_PRIMARY: + case MySqlParser.KW_REPEAT: + case MySqlParser.KW_REPLACE: + case MySqlParser.KW_RIGHT: + case MySqlParser.KW_SCHEMA: + case MySqlParser.KW_SKIP_QUERY_REWRITE: + case MySqlParser.KW_STACKED: + case MySqlParser.KW_DATE: + case MySqlParser.KW_TIME: + case MySqlParser.KW_TIMESTAMP: + case MySqlParser.KW_DATETIME: + case MySqlParser.KW_YEAR: + case MySqlParser.KW_BINARY: + case MySqlParser.KW_TEXT: + case MySqlParser.KW_ENUM: + case MySqlParser.KW_SERIAL: + case MySqlParser.KW_JSON_TABLE: + case MySqlParser.KW_JSON_VALUE: + case MySqlParser.KW_NESTED: + case MySqlParser.KW_ORDINALITY: + case MySqlParser.KW_PATH: + case MySqlParser.KW_AVG: + case MySqlParser.KW_BIT_AND: + case MySqlParser.KW_BIT_OR: + case MySqlParser.KW_BIT_XOR: + case MySqlParser.KW_COUNT: + case MySqlParser.KW_CUME_DIST: + case MySqlParser.KW_DENSE_RANK: + case MySqlParser.KW_FIRST_VALUE: + case MySqlParser.KW_GROUP_CONCAT: + case MySqlParser.KW_LAG: + case MySqlParser.KW_LAST_VALUE: + case MySqlParser.KW_LEAD: + case MySqlParser.KW_MAX: + case MySqlParser.KW_MIN: + case MySqlParser.KW_NTILE: + case MySqlParser.KW_NTH_VALUE: + case MySqlParser.KW_PERCENT_RANK: + case MySqlParser.KW_RANK: + case MySqlParser.KW_ROW_NUMBER: + case MySqlParser.KW_STD: + case MySqlParser.KW_STDDEV: + case MySqlParser.KW_STDDEV_POP: + case MySqlParser.KW_STDDEV_SAMP: + case MySqlParser.KW_SUM: + case MySqlParser.KW_VAR_POP: + case MySqlParser.KW_VAR_SAMP: + case MySqlParser.KW_VARIANCE: + case MySqlParser.KW_CURRENT_DATE: + case MySqlParser.KW_CURRENT_TIME: + case MySqlParser.KW_CURRENT_TIMESTAMP: + case MySqlParser.KW_LOCALTIME: + case MySqlParser.KW_CURDATE: + case MySqlParser.KW_CURTIME: + case MySqlParser.KW_DATE_ADD: + case MySqlParser.KW_DATE_SUB: + case MySqlParser.KW_LOCALTIMESTAMP: + case MySqlParser.KW_NOW: + case MySqlParser.KW_POSITION: + case MySqlParser.KW_SUBSTR: + case MySqlParser.KW_SUBSTRING: + case MySqlParser.KW_SYSDATE: + case MySqlParser.KW_TRIM: + case MySqlParser.KW_UTC_DATE: + case MySqlParser.KW_UTC_TIME: + case MySqlParser.KW_UTC_TIMESTAMP: + case MySqlParser.KW_ACCOUNT: + case MySqlParser.KW_ACTION: + case MySqlParser.KW_AFTER: + case MySqlParser.KW_AGGREGATE: + case MySqlParser.KW_ALGORITHM: + case MySqlParser.KW_ANY: + case MySqlParser.KW_AT: + case MySqlParser.KW_AUTHORS: + case MySqlParser.KW_AUTOCOMMIT: + case MySqlParser.KW_AUTOEXTEND_SIZE: + case MySqlParser.KW_AUTO_INCREMENT: + case MySqlParser.KW_AVG_ROW_LENGTH: + case MySqlParser.KW_BEGIN: + case MySqlParser.KW_BINLOG: + case MySqlParser.KW_BIT: + case MySqlParser.KW_BLOCK: + case MySqlParser.KW_BOOL: + case MySqlParser.KW_BOOLEAN: + case MySqlParser.KW_BTREE: + case MySqlParser.KW_CACHE: + case MySqlParser.KW_CASCADED: + case MySqlParser.KW_CHAIN: + case MySqlParser.KW_CHANGED: + case MySqlParser.KW_CHANNEL: + case MySqlParser.KW_CHECKSUM: + case MySqlParser.KW_CIPHER: + case MySqlParser.KW_CLASS_ORIGIN: + case MySqlParser.KW_CLIENT: + case MySqlParser.KW_CLOSE: + case MySqlParser.KW_COALESCE: + case MySqlParser.KW_CODE: + case MySqlParser.KW_COLUMNS: + case MySqlParser.KW_COLUMN_FORMAT: + case MySqlParser.KW_COLUMN_NAME: + case MySqlParser.KW_COMMENT: + case MySqlParser.KW_COMMIT: + case MySqlParser.KW_COMPACT: + case MySqlParser.KW_COMPLETION: + case MySqlParser.KW_COMPRESSED: + case MySqlParser.KW_COMPRESSION: + case MySqlParser.KW_CONCURRENT: + case MySqlParser.KW_CONNECT: + case MySqlParser.KW_CONNECTION: + case MySqlParser.KW_CONSISTENT: + case MySqlParser.KW_CONSTRAINT_CATALOG: + case MySqlParser.KW_CONSTRAINT_SCHEMA: + case MySqlParser.KW_CONSTRAINT_NAME: + case MySqlParser.KW_CONTAINS: + case MySqlParser.KW_CONTEXT: + case MySqlParser.KW_CONTRIBUTORS: + case MySqlParser.KW_COPY: + case MySqlParser.KW_CPU: + case MySqlParser.KW_CURSOR_NAME: + case MySqlParser.KW_DATA: + case MySqlParser.KW_DATAFILE: + case MySqlParser.KW_DEALLOCATE: + case MySqlParser.KW_DEFAULT_AUTH: + case MySqlParser.KW_DEFINER: + case MySqlParser.KW_DELAY_KEY_WRITE: + case MySqlParser.KW_DES_KEY_FILE: + case MySqlParser.KW_DIRECTORY: + case MySqlParser.KW_DISABLE: + case MySqlParser.KW_DISCARD: + case MySqlParser.KW_DISK: + case MySqlParser.KW_DO: + case MySqlParser.KW_DUMPFILE: + case MySqlParser.KW_DUPLICATE: + case MySqlParser.KW_DYNAMIC: + case MySqlParser.KW_ENABLE: + case MySqlParser.KW_ENCRYPTION: + case MySqlParser.KW_END: + case MySqlParser.KW_ENDS: + case MySqlParser.KW_ENGINE: + case MySqlParser.KW_ENGINES: + case MySqlParser.KW_ERROR: + case MySqlParser.KW_ERRORS: + case MySqlParser.KW_ESCAPE: + case MySqlParser.KW_EVENT: + case MySqlParser.KW_EVENTS: + case MySqlParser.KW_EVERY: + case MySqlParser.KW_EXCHANGE: + case MySqlParser.KW_EXCLUSIVE: + case MySqlParser.KW_EXPIRE: + case MySqlParser.KW_EXPORT: + case MySqlParser.KW_EXTENDED: + case MySqlParser.KW_EXTENT_SIZE: + case MySqlParser.KW_FAILED_LOGIN_ATTEMPTS: + case MySqlParser.KW_FAST: + case MySqlParser.KW_FAULTS: + case MySqlParser.KW_FIELDS: + case MySqlParser.KW_FILE_BLOCK_SIZE: + case MySqlParser.KW_FILTER: + case MySqlParser.KW_FIRST: + case MySqlParser.KW_FIXED: + case MySqlParser.KW_FLUSH: + case MySqlParser.KW_FOLLOWS: + case MySqlParser.KW_FOUND: + case MySqlParser.KW_FULL: + case MySqlParser.KW_FUNCTION: + case MySqlParser.KW_GENERAL: + case MySqlParser.KW_GLOBAL: + case MySqlParser.KW_GRANTS: + case MySqlParser.KW_GROUP_REPLICATION: + case MySqlParser.KW_HANDLER: + case MySqlParser.KW_HASH: + case MySqlParser.KW_HELP: + case MySqlParser.KW_HISTORY: + case MySqlParser.KW_HOST: + case MySqlParser.KW_HOSTS: + case MySqlParser.KW_IDENTIFIED: + case MySqlParser.KW_IGNORE_SERVER_IDS: + case MySqlParser.KW_IMPORT: + case MySqlParser.KW_INDEXES: + case MySqlParser.KW_INITIAL_SIZE: + case MySqlParser.KW_INPLACE: + case MySqlParser.KW_INSERT_METHOD: + case MySqlParser.KW_INSTALL: + case MySqlParser.KW_INSTANCE: + case MySqlParser.KW_INSTANT: + case MySqlParser.KW_INVISIBLE: + case MySqlParser.KW_INVOKER: + case MySqlParser.KW_IO: + case MySqlParser.KW_IO_THREAD: + case MySqlParser.KW_IPC: + case MySqlParser.KW_ISOLATION: + case MySqlParser.KW_ISSUER: + case MySqlParser.KW_JSON: + case MySqlParser.KW_KEY_BLOCK_SIZE: + case MySqlParser.KW_LANGUAGE: + case MySqlParser.KW_LAST: + case MySqlParser.KW_LEAVES: + case MySqlParser.KW_LESS: + case MySqlParser.KW_LEVEL: + case MySqlParser.KW_LIST: + case MySqlParser.KW_LOCAL: + case MySqlParser.KW_LOGFILE: + case MySqlParser.KW_LOGS: + case MySqlParser.KW_MASTER: + case MySqlParser.KW_MASTER_AUTO_POSITION: + case MySqlParser.KW_MASTER_CONNECT_RETRY: + case MySqlParser.KW_MASTER_DELAY: + case MySqlParser.KW_MASTER_HEARTBEAT_PERIOD: + case MySqlParser.KW_MASTER_HOST: + case MySqlParser.KW_MASTER_LOG_FILE: + case MySqlParser.KW_MASTER_LOG_POS: + case MySqlParser.KW_MASTER_PASSWORD: + case MySqlParser.KW_MASTER_PORT: + case MySqlParser.KW_MASTER_RETRY_COUNT: + case MySqlParser.KW_MASTER_SSL: + case MySqlParser.KW_MASTER_SSL_CA: + case MySqlParser.KW_MASTER_SSL_CAPATH: + case MySqlParser.KW_MASTER_SSL_CERT: + case MySqlParser.KW_MASTER_SSL_CIPHER: + case MySqlParser.KW_MASTER_SSL_CRL: + case MySqlParser.KW_MASTER_SSL_CRLPATH: + case MySqlParser.KW_MASTER_SSL_KEY: + case MySqlParser.KW_MASTER_TLS_VERSION: + case MySqlParser.KW_MASTER_USER: + case MySqlParser.KW_MAX_CONNECTIONS_PER_HOUR: + case MySqlParser.KW_MAX_QUERIES_PER_HOUR: + case MySqlParser.KW_MAX_ROWS: + case MySqlParser.KW_MAX_SIZE: + case MySqlParser.KW_MAX_UPDATES_PER_HOUR: + case MySqlParser.KW_MAX_USER_CONNECTIONS: + case MySqlParser.KW_MEDIUM: + case MySqlParser.KW_MEMBER: + case MySqlParser.KW_MERGE: + case MySqlParser.KW_MESSAGE_TEXT: + case MySqlParser.KW_MID: + case MySqlParser.KW_MIGRATE: + case MySqlParser.KW_MIN_ROWS: + case MySqlParser.KW_MODE: + case MySqlParser.KW_MODIFY: + case MySqlParser.KW_MUTEX: + case MySqlParser.KW_MYSQL: + case MySqlParser.KW_MYSQL_ERRNO: + case MySqlParser.KW_NAME: + case MySqlParser.KW_NAMES: + case MySqlParser.KW_NCHAR: + case MySqlParser.KW_NEVER: + case MySqlParser.KW_NEXT: + case MySqlParser.KW_NO: + case MySqlParser.KW_NOWAIT: + case MySqlParser.KW_NODEGROUP: + case MySqlParser.KW_NONE: + case MySqlParser.KW_ODBC: + case MySqlParser.KW_OFFLINE: + case MySqlParser.KW_OFFSET: + case MySqlParser.KW_OF: + case MySqlParser.KW_OLD_PASSWORD: + case MySqlParser.KW_ONE: + case MySqlParser.KW_ONLINE: + case MySqlParser.KW_ONLY: + case MySqlParser.KW_OPEN: + case MySqlParser.KW_OPTIMIZER_COSTS: + case MySqlParser.KW_OPTIONS: + case MySqlParser.KW_OWNER: + case MySqlParser.KW_PACK_KEYS: + case MySqlParser.KW_PAGE: + case MySqlParser.KW_PAGE_CHECKSUM: + case MySqlParser.KW_PARSER: + case MySqlParser.KW_PARTIAL: + case MySqlParser.KW_PARTITIONING: + case MySqlParser.KW_PARTITIONS: + case MySqlParser.KW_PASSWORD: + case MySqlParser.KW_PASSWORD_LOCK_TIME: + case MySqlParser.KW_PHASE: + case MySqlParser.KW_PLUGIN: + case MySqlParser.KW_PLUGIN_DIR: + case MySqlParser.KW_PLUGINS: + case MySqlParser.KW_PORT: + case MySqlParser.KW_PRECEDES: + case MySqlParser.KW_PREPARE: + case MySqlParser.KW_PRESERVE: + case MySqlParser.KW_PREV: + case MySqlParser.KW_PROCESSLIST: + case MySqlParser.KW_PROFILE: + case MySqlParser.KW_PROFILES: + case MySqlParser.KW_PROXY: + case MySqlParser.KW_QUERY: + case MySqlParser.KW_QUICK: + case MySqlParser.KW_REBUILD: + case MySqlParser.KW_RECOVER: + case MySqlParser.KW_RECURSIVE: + case MySqlParser.KW_REDO_BUFFER_SIZE: + case MySqlParser.KW_REDUNDANT: + case MySqlParser.KW_RELAY: + case MySqlParser.KW_RELAY_LOG_FILE: + case MySqlParser.KW_RELAY_LOG_POS: + case MySqlParser.KW_RELAYLOG: + case MySqlParser.KW_REMOVE: + case MySqlParser.KW_REORGANIZE: + case MySqlParser.KW_REPAIR: + case MySqlParser.KW_REPLICATE_DO_DB: + case MySqlParser.KW_REPLICATE_DO_TABLE: + case MySqlParser.KW_REPLICATE_IGNORE_DB: + case MySqlParser.KW_REPLICATE_IGNORE_TABLE: + case MySqlParser.KW_REPLICATE_REWRITE_DB: + case MySqlParser.KW_REPLICATE_WILD_DO_TABLE: + case MySqlParser.KW_REPLICATE_WILD_IGNORE_TABLE: + case MySqlParser.KW_REPLICATION: + case MySqlParser.KW_RESET: + case MySqlParser.KW_RESUME: + case MySqlParser.KW_RETURNED_SQLSTATE: + case MySqlParser.KW_RETURNS: + case MySqlParser.KW_REUSE: + case MySqlParser.KW_ROLE: + case MySqlParser.KW_ROLLBACK: + case MySqlParser.KW_ROLLUP: + case MySqlParser.KW_ROTATE: + case MySqlParser.KW_ROW: + case MySqlParser.KW_ROWS: + case MySqlParser.KW_ROW_FORMAT: + case MySqlParser.KW_SAVEPOINT: + case MySqlParser.KW_SCHEDULE: + case MySqlParser.KW_SECURITY: + case MySqlParser.KW_SERVER: + case MySqlParser.KW_SESSION: + case MySqlParser.KW_SHARE: + case MySqlParser.KW_SHARED: + case MySqlParser.KW_SIGNED: + case MySqlParser.KW_SIMPLE: + case MySqlParser.KW_SLAVE: + case MySqlParser.KW_SLOW: + case MySqlParser.KW_SNAPSHOT: + case MySqlParser.KW_SOCKET: + case MySqlParser.KW_SOME: + case MySqlParser.KW_SONAME: + case MySqlParser.KW_SOUNDS: + case MySqlParser.KW_SOURCE: + case MySqlParser.KW_SQL_AFTER_GTIDS: + case MySqlParser.KW_SQL_AFTER_MTS_GAPS: + case MySqlParser.KW_SQL_BEFORE_GTIDS: + case MySqlParser.KW_SQL_BUFFER_RESULT: + case MySqlParser.KW_SQL_CACHE: + case MySqlParser.KW_SQL_NO_CACHE: + case MySqlParser.KW_SQL_THREAD: + case MySqlParser.KW_START: + case MySqlParser.KW_STARTS: + case MySqlParser.KW_STATS_AUTO_RECALC: + case MySqlParser.KW_STATS_PERSISTENT: + case MySqlParser.KW_STATS_SAMPLE_PAGES: + case MySqlParser.KW_STATUS: + case MySqlParser.KW_STOP: + case MySqlParser.KW_STORAGE: + case MySqlParser.KW_STRING: + case MySqlParser.KW_SUBCLASS_ORIGIN: + case MySqlParser.KW_SUBJECT: + case MySqlParser.KW_SUBPARTITION: + case MySqlParser.KW_SUBPARTITIONS: + case MySqlParser.KW_SUSPEND: + case MySqlParser.KW_SWAPS: + case MySqlParser.KW_SWITCHES: + case MySqlParser.KW_TABLE_NAME: + case MySqlParser.KW_TABLESPACE: + case MySqlParser.KW_TABLE_TYPE: + case MySqlParser.KW_TEMPORARY: + case MySqlParser.KW_TEMPTABLE: + case MySqlParser.KW_THAN: + case MySqlParser.KW_TRADITIONAL: + case MySqlParser.KW_TRANSACTION: + case MySqlParser.KW_TRANSACTIONAL: + case MySqlParser.KW_TRIGGERS: + case MySqlParser.KW_TRUNCATE: + case MySqlParser.KW_UNBOUNDED: + case MySqlParser.KW_UNDEFINED: + case MySqlParser.KW_UNDOFILE: + case MySqlParser.KW_UNDO_BUFFER_SIZE: + case MySqlParser.KW_UNINSTALL: + case MySqlParser.KW_UNKNOWN: + case MySqlParser.KW_UNTIL: + case MySqlParser.KW_UPGRADE: + case MySqlParser.KW_USER: + case MySqlParser.KW_USE_FRM: + case MySqlParser.KW_USER_RESOURCES: + case MySqlParser.KW_VALIDATION: + case MySqlParser.KW_VALUE: + case MySqlParser.KW_VARIABLES: + case MySqlParser.KW_VIEW: + case MySqlParser.KW_VIRTUAL: + case MySqlParser.KW_VISIBLE: + case MySqlParser.KW_WAIT: + case MySqlParser.KW_WARNINGS: + case MySqlParser.KW_WITHOUT: + case MySqlParser.KW_WORK: + case MySqlParser.KW_WRAPPER: + case MySqlParser.KW_X509: + case MySqlParser.KW_XA: + case MySqlParser.KW_XML: + case MySqlParser.KW_QUARTER: + case MySqlParser.KW_MONTH: + case MySqlParser.KW_DAY: + case MySqlParser.KW_HOUR: + case MySqlParser.KW_MINUTE: + case MySqlParser.KW_WEEK: + case MySqlParser.KW_SECOND: + case MySqlParser.KW_MICROSECOND: + case MySqlParser.KW_ADMIN: + case MySqlParser.KW_AUDIT_ABORT_EXEMPT: + case MySqlParser.KW_AUDIT_ADMIN: + case MySqlParser.KW_AUTHENTICATION_POLICY_ADMIN: + case MySqlParser.KW_BACKUP_ADMIN: + case MySqlParser.KW_BINLOG_ADMIN: + case MySqlParser.KW_BINLOG_ENCRYPTION_ADMIN: + case MySqlParser.KW_CLONE_ADMIN: + case MySqlParser.KW_CONNECTION_ADMIN: + case MySqlParser.KW_ENCRYPTION_KEY_ADMIN: + case MySqlParser.KW_EXECUTE: + case MySqlParser.KW_FILE: + case MySqlParser.KW_FIREWALL_ADMIN: + case MySqlParser.KW_FIREWALL_EXEMPT: + case MySqlParser.KW_FIREWALL_USER: + case MySqlParser.KW_GROUP_REPLICATION_ADMIN: + case MySqlParser.KW_INNODB_REDO_LOG_ARCHIVE: + case MySqlParser.KW_INVOKE: + case MySqlParser.KW_LAMBDA: + case MySqlParser.KW_NDB_STORED_USER: + case MySqlParser.KW_PASSWORDLESS_USER_ADMIN: + case MySqlParser.KW_PERSIST_RO_VARIABLES_ADMIN: + case MySqlParser.KW_PRIVILEGES: + case MySqlParser.KW_PROCESS: + case MySqlParser.KW_RELOAD: + case MySqlParser.KW_REPLICATION_APPLIER: + case MySqlParser.KW_REPLICATION_SLAVE_ADMIN: + case MySqlParser.KW_RESOURCE_GROUP_ADMIN: + case MySqlParser.KW_RESOURCE_GROUP_USER: + case MySqlParser.KW_ROLE_ADMIN: + case MySqlParser.KW_ROUTINE: + case MySqlParser.KW_S3: + case MySqlParser.KW_SESSION_VARIABLES_ADMIN: + case MySqlParser.KW_SET_USER_ID: + case MySqlParser.KW_SHOW_ROUTINE: + case MySqlParser.KW_SHUTDOWN: + case MySqlParser.KW_SUPER: + case MySqlParser.KW_SYSTEM_VARIABLES_ADMIN: + case MySqlParser.KW_TABLES: + case MySqlParser.KW_TABLE_ENCRYPTION_ADMIN: + case MySqlParser.KW_VERSION_TOKEN_ADMIN: + case MySqlParser.KW_XA_RECOVER_ADMIN: + case MySqlParser.KW_ARMSCII8: + case MySqlParser.KW_ASCII: + case MySqlParser.KW_BIG5: + case MySqlParser.KW_CP1250: + case MySqlParser.KW_CP1251: + case MySqlParser.KW_CP1256: + case MySqlParser.KW_CP1257: + case MySqlParser.KW_CP850: + case MySqlParser.KW_CP852: + case MySqlParser.KW_CP866: + case MySqlParser.KW_CP932: + case MySqlParser.KW_DEC8: + case MySqlParser.KW_EUCJPMS: + case MySqlParser.KW_EUCKR: + case MySqlParser.KW_GB18030: + case MySqlParser.KW_GB2312: + case MySqlParser.KW_GBK: + case MySqlParser.KW_GEOSTD8: + case MySqlParser.KW_GREEK: + case MySqlParser.KW_HEBREW: + case MySqlParser.KW_HP8: + case MySqlParser.KW_KEYBCS2: + case MySqlParser.KW_KOI8R: + case MySqlParser.KW_KOI8U: + case MySqlParser.KW_LATIN1: + case MySqlParser.KW_LATIN2: + case MySqlParser.KW_LATIN5: + case MySqlParser.KW_LATIN7: + case MySqlParser.KW_MACCE: + case MySqlParser.KW_MACROMAN: + case MySqlParser.KW_SJIS: + case MySqlParser.KW_SWE7: + case MySqlParser.KW_TIS620: + case MySqlParser.KW_UCS2: + case MySqlParser.KW_UJIS: + case MySqlParser.KW_UTF16: + case MySqlParser.KW_UTF16LE: + case MySqlParser.KW_UTF32: + case MySqlParser.KW_UTF8: + case MySqlParser.KW_UTF8MB3: + case MySqlParser.KW_UTF8MB4: + case MySqlParser.KW_ARCHIVE: + case MySqlParser.KW_BLACKHOLE: + case MySqlParser.KW_CSV: + case MySqlParser.KW_FEDERATED: + case MySqlParser.KW_INNODB: + case MySqlParser.KW_MEMORY: + case MySqlParser.KW_MRG_MYISAM: + case MySqlParser.KW_MYISAM: + case MySqlParser.KW_NDB: + case MySqlParser.KW_NDBCLUSTER: + case MySqlParser.KW_PERFORMANCE_SCHEMA: + case MySqlParser.KW_TOKUDB: + case MySqlParser.KW_REPEATABLE: + case MySqlParser.KW_COMMITTED: + case MySqlParser.KW_UNCOMMITTED: + case MySqlParser.KW_SERIALIZABLE: + case MySqlParser.KW_GEOMETRYCOLLECTION: + case MySqlParser.KW_LINESTRING: + case MySqlParser.KW_MULTILINESTRING: + case MySqlParser.KW_MULTIPOINT: + case MySqlParser.KW_MULTIPOLYGON: + case MySqlParser.KW_POINT: + case MySqlParser.KW_POLYGON: + case MySqlParser.KW_CATALOG_NAME: + case MySqlParser.KW_CHARSET: + case MySqlParser.KW_COLLATION: + case MySqlParser.KW_ENGINE_ATTRIBUTE: + case MySqlParser.KW_FORMAT: + case MySqlParser.KW_GET_FORMAT: + case MySqlParser.KW_RANDOM: + case MySqlParser.KW_REVERSE: + case MySqlParser.KW_ROW_COUNT: + case MySqlParser.KW_SCHEMA_NAME: + case MySqlParser.KW_SECONDARY_ENGINE_ATTRIBUTE: + case MySqlParser.KW_SRID: + case MySqlParser.KW_SYSTEM_USER: + case MySqlParser.KW_TP_CONNECTION_ADMIN: + case MySqlParser.KW_WEIGHT_STRING: + case MySqlParser.MOD: + case MySqlParser.CHARSET_REVERSE_QOUTE_STRING: + case MySqlParser.STRING_LITERAL: + case MySqlParser.ID: + this.enterOuterAlt(localContext, 1); + { + this.state = 3634; + localContext._var_name = this.uid(); + } + break; + case MySqlParser.LOCAL_ID: + this.enterOuterAlt(localContext, 2); + { + this.state = 3635; + this.match(MySqlParser.LOCAL_ID); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + lockClause() { + let localContext = new LockClauseContext(this.context, this.state); + this.enterRule(localContext, 232, MySqlParser.RULE_lockClause); + let _la; + try { + let alternative; + this.state = 3659; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_FOR: + this.enterOuterAlt(localContext, 1); + { + this.state = 3638; + this.match(MySqlParser.KW_FOR); + this.state = 3639; + _la = this.tokenStream.LA(1); + if (!(_la === 185 || _la === 594)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 3649; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 490, this.context)) { + case 1: + { + this.state = 3640; + this.match(MySqlParser.KW_OF); + this.state = 3641; + this.tableName(); + this.state = 3646; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 489, this.context); + while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER) { + if (alternative === 1) { + { + { + this.state = 3642; + this.match(MySqlParser.COMMA); + this.state = 3643; + this.tableName(); + } + } + } + this.state = 3648; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 489, this.context); + } + } + break; + } + this.state = 3653; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 491, this.context)) { + case 1: + { + this.state = 3651; + _la = this.tokenStream.LA(1); + if (!(_la === 159 || _la === 503)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 3652; + this.match(MySqlParser.KW_LOCKED); + } + break; + } + } + break; + case MySqlParser.KW_LOCK: + this.enterOuterAlt(localContext, 2); + { + this.state = 3655; + this.match(MySqlParser.KW_LOCK); + this.state = 3656; + this.match(MySqlParser.KW_IN); + this.state = 3657; + this.match(MySqlParser.KW_SHARE); + this.state = 3658; + this.match(MySqlParser.KW_MODE); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + singleDeleteStatement() { + let localContext = new SingleDeleteStatementContext(this.context, this.state); + this.enterRule(localContext, 234, MySqlParser.RULE_singleDeleteStatement); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 3661; + this.match(MySqlParser.KW_DELETE); + this.state = 3663; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 107) { + { + this.state = 3662; + localContext._priority = this.match(MySqlParser.KW_LOW_PRIORITY); + } + } + this.state = 3666; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 549) { + { + this.state = 3665; + this.match(MySqlParser.KW_QUICK); + } + } + this.state = 3669; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 79) { + { + this.state = 3668; + this.match(MySqlParser.KW_IGNORE); + } + } + this.state = 3671; + this.match(MySqlParser.KW_FROM); + this.state = 3672; + this.tableName(); + this.state = 3677; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 497, this.context)) { + case 1: + { + this.state = 3674; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 13) { + { + this.state = 3673; + this.match(MySqlParser.KW_AS); + } + } + this.state = 3676; + localContext._table_alias = this.uid(); + } + break; + } + this.state = 3684; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 130) { + { + this.state = 3679; + this.match(MySqlParser.KW_PARTITION); + this.state = 3680; + this.match(MySqlParser.LR_BRACKET); + this.state = 3681; + this.partitionNames(); + this.state = 3682; + this.match(MySqlParser.RR_BRACKET); + } + } + this.state = 3688; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 192) { + { + this.state = 3686; + this.match(MySqlParser.KW_WHERE); + this.state = 3687; + this.expression(0); + } + } + this.state = 3691; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 125) { + { + this.state = 3690; + this.orderByClause(); + } + } + this.state = 3695; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 100) { + { + this.state = 3693; + this.match(MySqlParser.KW_LIMIT); + this.state = 3694; + this.limitClauseAtom(); + } + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + multipleDeleteStatement() { + let localContext = new MultipleDeleteStatementContext(this.context, this.state); + this.enterRule(localContext, 236, MySqlParser.RULE_multipleDeleteStatement); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 3697; + this.match(MySqlParser.KW_DELETE); + this.state = 3699; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 107) { + { + this.state = 3698; + localContext._priority = this.match(MySqlParser.KW_LOW_PRIORITY); + } + } + this.state = 3702; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 503, this.context)) { + case 1: + { + this.state = 3701; + this.match(MySqlParser.KW_QUICK); + } + break; + } + this.state = 3705; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 79) { + { + this.state = 3704; + this.match(MySqlParser.KW_IGNORE); + } + } + this.state = 3746; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_ARRAY: + case MySqlParser.KW_ATTRIBUTE: + case MySqlParser.KW_BUCKETS: + case MySqlParser.KW_CONDITION: + case MySqlParser.KW_CURRENT: + case MySqlParser.KW_CURRENT_USER: + case MySqlParser.KW_DATABASE: + case MySqlParser.KW_DEFAULT: + case MySqlParser.KW_DIAGNOSTICS: + case MySqlParser.KW_EMPTY: + case MySqlParser.KW_ENFORCED: + case MySqlParser.KW_EXCEPT: + case MySqlParser.KW_GROUP: + case MySqlParser.KW_IF: + case MySqlParser.KW_INSERT: + case MySqlParser.KW_LATERAL: + case MySqlParser.KW_LEFT: + case MySqlParser.KW_NUMBER: + case MySqlParser.KW_OPTIONAL: + case MySqlParser.KW_ORDER: + case MySqlParser.KW_PRIMARY: + case MySqlParser.KW_REPEAT: + case MySqlParser.KW_REPLACE: + case MySqlParser.KW_RIGHT: + case MySqlParser.KW_SCHEMA: + case MySqlParser.KW_SKIP_QUERY_REWRITE: + case MySqlParser.KW_STACKED: + case MySqlParser.KW_DATE: + case MySqlParser.KW_TIME: + case MySqlParser.KW_TIMESTAMP: + case MySqlParser.KW_DATETIME: + case MySqlParser.KW_YEAR: + case MySqlParser.KW_BINARY: + case MySqlParser.KW_TEXT: + case MySqlParser.KW_ENUM: + case MySqlParser.KW_SERIAL: + case MySqlParser.KW_JSON_TABLE: + case MySqlParser.KW_JSON_VALUE: + case MySqlParser.KW_NESTED: + case MySqlParser.KW_ORDINALITY: + case MySqlParser.KW_PATH: + case MySqlParser.KW_AVG: + case MySqlParser.KW_BIT_AND: + case MySqlParser.KW_BIT_OR: + case MySqlParser.KW_BIT_XOR: + case MySqlParser.KW_COUNT: + case MySqlParser.KW_CUME_DIST: + case MySqlParser.KW_DENSE_RANK: + case MySqlParser.KW_FIRST_VALUE: + case MySqlParser.KW_GROUP_CONCAT: + case MySqlParser.KW_LAG: + case MySqlParser.KW_LAST_VALUE: + case MySqlParser.KW_LEAD: + case MySqlParser.KW_MAX: + case MySqlParser.KW_MIN: + case MySqlParser.KW_NTILE: + case MySqlParser.KW_NTH_VALUE: + case MySqlParser.KW_PERCENT_RANK: + case MySqlParser.KW_RANK: + case MySqlParser.KW_ROW_NUMBER: + case MySqlParser.KW_STD: + case MySqlParser.KW_STDDEV: + case MySqlParser.KW_STDDEV_POP: + case MySqlParser.KW_STDDEV_SAMP: + case MySqlParser.KW_SUM: + case MySqlParser.KW_VAR_POP: + case MySqlParser.KW_VAR_SAMP: + case MySqlParser.KW_VARIANCE: + case MySqlParser.KW_CURRENT_DATE: + case MySqlParser.KW_CURRENT_TIME: + case MySqlParser.KW_CURRENT_TIMESTAMP: + case MySqlParser.KW_LOCALTIME: + case MySqlParser.KW_CURDATE: + case MySqlParser.KW_CURTIME: + case MySqlParser.KW_DATE_ADD: + case MySqlParser.KW_DATE_SUB: + case MySqlParser.KW_LOCALTIMESTAMP: + case MySqlParser.KW_NOW: + case MySqlParser.KW_POSITION: + case MySqlParser.KW_SUBSTR: + case MySqlParser.KW_SUBSTRING: + case MySqlParser.KW_SYSDATE: + case MySqlParser.KW_TRIM: + case MySqlParser.KW_UTC_DATE: + case MySqlParser.KW_UTC_TIME: + case MySqlParser.KW_UTC_TIMESTAMP: + case MySqlParser.KW_ACCOUNT: + case MySqlParser.KW_ACTION: + case MySqlParser.KW_AFTER: + case MySqlParser.KW_AGGREGATE: + case MySqlParser.KW_ALGORITHM: + case MySqlParser.KW_ANY: + case MySqlParser.KW_AT: + case MySqlParser.KW_AUTHORS: + case MySqlParser.KW_AUTOCOMMIT: + case MySqlParser.KW_AUTOEXTEND_SIZE: + case MySqlParser.KW_AUTO_INCREMENT: + case MySqlParser.KW_AVG_ROW_LENGTH: + case MySqlParser.KW_BEGIN: + case MySqlParser.KW_BINLOG: + case MySqlParser.KW_BIT: + case MySqlParser.KW_BLOCK: + case MySqlParser.KW_BOOL: + case MySqlParser.KW_BOOLEAN: + case MySqlParser.KW_BTREE: + case MySqlParser.KW_CACHE: + case MySqlParser.KW_CASCADED: + case MySqlParser.KW_CHAIN: + case MySqlParser.KW_CHANGED: + case MySqlParser.KW_CHANNEL: + case MySqlParser.KW_CHECKSUM: + case MySqlParser.KW_CIPHER: + case MySqlParser.KW_CLASS_ORIGIN: + case MySqlParser.KW_CLIENT: + case MySqlParser.KW_CLOSE: + case MySqlParser.KW_COALESCE: + case MySqlParser.KW_CODE: + case MySqlParser.KW_COLUMNS: + case MySqlParser.KW_COLUMN_FORMAT: + case MySqlParser.KW_COLUMN_NAME: + case MySqlParser.KW_COMMENT: + case MySqlParser.KW_COMMIT: + case MySqlParser.KW_COMPACT: + case MySqlParser.KW_COMPLETION: + case MySqlParser.KW_COMPRESSED: + case MySqlParser.KW_COMPRESSION: + case MySqlParser.KW_CONCURRENT: + case MySqlParser.KW_CONNECT: + case MySqlParser.KW_CONNECTION: + case MySqlParser.KW_CONSISTENT: + case MySqlParser.KW_CONSTRAINT_CATALOG: + case MySqlParser.KW_CONSTRAINT_SCHEMA: + case MySqlParser.KW_CONSTRAINT_NAME: + case MySqlParser.KW_CONTAINS: + case MySqlParser.KW_CONTEXT: + case MySqlParser.KW_CONTRIBUTORS: + case MySqlParser.KW_COPY: + case MySqlParser.KW_CPU: + case MySqlParser.KW_CURSOR_NAME: + case MySqlParser.KW_DATA: + case MySqlParser.KW_DATAFILE: + case MySqlParser.KW_DEALLOCATE: + case MySqlParser.KW_DEFAULT_AUTH: + case MySqlParser.KW_DEFINER: + case MySqlParser.KW_DELAY_KEY_WRITE: + case MySqlParser.KW_DES_KEY_FILE: + case MySqlParser.KW_DIRECTORY: + case MySqlParser.KW_DISABLE: + case MySqlParser.KW_DISCARD: + case MySqlParser.KW_DISK: + case MySqlParser.KW_DO: + case MySqlParser.KW_DUMPFILE: + case MySqlParser.KW_DUPLICATE: + case MySqlParser.KW_DYNAMIC: + case MySqlParser.KW_ENABLE: + case MySqlParser.KW_ENCRYPTION: + case MySqlParser.KW_END: + case MySqlParser.KW_ENDS: + case MySqlParser.KW_ENGINE: + case MySqlParser.KW_ENGINES: + case MySqlParser.KW_ERROR: + case MySqlParser.KW_ERRORS: + case MySqlParser.KW_ESCAPE: + case MySqlParser.KW_EVENT: + case MySqlParser.KW_EVENTS: + case MySqlParser.KW_EVERY: + case MySqlParser.KW_EXCHANGE: + case MySqlParser.KW_EXCLUSIVE: + case MySqlParser.KW_EXPIRE: + case MySqlParser.KW_EXPORT: + case MySqlParser.KW_EXTENDED: + case MySqlParser.KW_EXTENT_SIZE: + case MySqlParser.KW_FAILED_LOGIN_ATTEMPTS: + case MySqlParser.KW_FAST: + case MySqlParser.KW_FAULTS: + case MySqlParser.KW_FIELDS: + case MySqlParser.KW_FILE_BLOCK_SIZE: + case MySqlParser.KW_FILTER: + case MySqlParser.KW_FIRST: + case MySqlParser.KW_FIXED: + case MySqlParser.KW_FLUSH: + case MySqlParser.KW_FOLLOWS: + case MySqlParser.KW_FOUND: + case MySqlParser.KW_FULL: + case MySqlParser.KW_FUNCTION: + case MySqlParser.KW_GENERAL: + case MySqlParser.KW_GLOBAL: + case MySqlParser.KW_GRANTS: + case MySqlParser.KW_GROUP_REPLICATION: + case MySqlParser.KW_HANDLER: + case MySqlParser.KW_HASH: + case MySqlParser.KW_HELP: + case MySqlParser.KW_HISTORY: + case MySqlParser.KW_HOST: + case MySqlParser.KW_HOSTS: + case MySqlParser.KW_IDENTIFIED: + case MySqlParser.KW_IGNORE_SERVER_IDS: + case MySqlParser.KW_IMPORT: + case MySqlParser.KW_INDEXES: + case MySqlParser.KW_INITIAL_SIZE: + case MySqlParser.KW_INPLACE: + case MySqlParser.KW_INSERT_METHOD: + case MySqlParser.KW_INSTALL: + case MySqlParser.KW_INSTANCE: + case MySqlParser.KW_INSTANT: + case MySqlParser.KW_INVISIBLE: + case MySqlParser.KW_INVOKER: + case MySqlParser.KW_IO: + case MySqlParser.KW_IO_THREAD: + case MySqlParser.KW_IPC: + case MySqlParser.KW_ISOLATION: + case MySqlParser.KW_ISSUER: + case MySqlParser.KW_JSON: + case MySqlParser.KW_KEY_BLOCK_SIZE: + case MySqlParser.KW_LANGUAGE: + case MySqlParser.KW_LAST: + case MySqlParser.KW_LEAVES: + case MySqlParser.KW_LESS: + case MySqlParser.KW_LEVEL: + case MySqlParser.KW_LIST: + case MySqlParser.KW_LOCAL: + case MySqlParser.KW_LOGFILE: + case MySqlParser.KW_LOGS: + case MySqlParser.KW_MASTER: + case MySqlParser.KW_MASTER_AUTO_POSITION: + case MySqlParser.KW_MASTER_CONNECT_RETRY: + case MySqlParser.KW_MASTER_DELAY: + case MySqlParser.KW_MASTER_HEARTBEAT_PERIOD: + case MySqlParser.KW_MASTER_HOST: + case MySqlParser.KW_MASTER_LOG_FILE: + case MySqlParser.KW_MASTER_LOG_POS: + case MySqlParser.KW_MASTER_PASSWORD: + case MySqlParser.KW_MASTER_PORT: + case MySqlParser.KW_MASTER_RETRY_COUNT: + case MySqlParser.KW_MASTER_SSL: + case MySqlParser.KW_MASTER_SSL_CA: + case MySqlParser.KW_MASTER_SSL_CAPATH: + case MySqlParser.KW_MASTER_SSL_CERT: + case MySqlParser.KW_MASTER_SSL_CIPHER: + case MySqlParser.KW_MASTER_SSL_CRL: + case MySqlParser.KW_MASTER_SSL_CRLPATH: + case MySqlParser.KW_MASTER_SSL_KEY: + case MySqlParser.KW_MASTER_TLS_VERSION: + case MySqlParser.KW_MASTER_USER: + case MySqlParser.KW_MAX_CONNECTIONS_PER_HOUR: + case MySqlParser.KW_MAX_QUERIES_PER_HOUR: + case MySqlParser.KW_MAX_ROWS: + case MySqlParser.KW_MAX_SIZE: + case MySqlParser.KW_MAX_UPDATES_PER_HOUR: + case MySqlParser.KW_MAX_USER_CONNECTIONS: + case MySqlParser.KW_MEDIUM: + case MySqlParser.KW_MEMBER: + case MySqlParser.KW_MERGE: + case MySqlParser.KW_MESSAGE_TEXT: + case MySqlParser.KW_MID: + case MySqlParser.KW_MIGRATE: + case MySqlParser.KW_MIN_ROWS: + case MySqlParser.KW_MODE: + case MySqlParser.KW_MODIFY: + case MySqlParser.KW_MUTEX: + case MySqlParser.KW_MYSQL: + case MySqlParser.KW_MYSQL_ERRNO: + case MySqlParser.KW_NAME: + case MySqlParser.KW_NAMES: + case MySqlParser.KW_NCHAR: + case MySqlParser.KW_NEVER: + case MySqlParser.KW_NEXT: + case MySqlParser.KW_NO: + case MySqlParser.KW_NOWAIT: + case MySqlParser.KW_NODEGROUP: + case MySqlParser.KW_NONE: + case MySqlParser.KW_ODBC: + case MySqlParser.KW_OFFLINE: + case MySqlParser.KW_OFFSET: + case MySqlParser.KW_OF: + case MySqlParser.KW_OLD_PASSWORD: + case MySqlParser.KW_ONE: + case MySqlParser.KW_ONLINE: + case MySqlParser.KW_ONLY: + case MySqlParser.KW_OPEN: + case MySqlParser.KW_OPTIMIZER_COSTS: + case MySqlParser.KW_OPTIONS: + case MySqlParser.KW_OWNER: + case MySqlParser.KW_PACK_KEYS: + case MySqlParser.KW_PAGE: + case MySqlParser.KW_PAGE_CHECKSUM: + case MySqlParser.KW_PARSER: + case MySqlParser.KW_PARTIAL: + case MySqlParser.KW_PARTITIONING: + case MySqlParser.KW_PARTITIONS: + case MySqlParser.KW_PASSWORD: + case MySqlParser.KW_PASSWORD_LOCK_TIME: + case MySqlParser.KW_PHASE: + case MySqlParser.KW_PLUGIN: + case MySqlParser.KW_PLUGIN_DIR: + case MySqlParser.KW_PLUGINS: + case MySqlParser.KW_PORT: + case MySqlParser.KW_PRECEDES: + case MySqlParser.KW_PREPARE: + case MySqlParser.KW_PRESERVE: + case MySqlParser.KW_PREV: + case MySqlParser.KW_PROCESSLIST: + case MySqlParser.KW_PROFILE: + case MySqlParser.KW_PROFILES: + case MySqlParser.KW_PROXY: + case MySqlParser.KW_QUERY: + case MySqlParser.KW_QUICK: + case MySqlParser.KW_REBUILD: + case MySqlParser.KW_RECOVER: + case MySqlParser.KW_RECURSIVE: + case MySqlParser.KW_REDO_BUFFER_SIZE: + case MySqlParser.KW_REDUNDANT: + case MySqlParser.KW_RELAY: + case MySqlParser.KW_RELAY_LOG_FILE: + case MySqlParser.KW_RELAY_LOG_POS: + case MySqlParser.KW_RELAYLOG: + case MySqlParser.KW_REMOVE: + case MySqlParser.KW_REORGANIZE: + case MySqlParser.KW_REPAIR: + case MySqlParser.KW_REPLICATE_DO_DB: + case MySqlParser.KW_REPLICATE_DO_TABLE: + case MySqlParser.KW_REPLICATE_IGNORE_DB: + case MySqlParser.KW_REPLICATE_IGNORE_TABLE: + case MySqlParser.KW_REPLICATE_REWRITE_DB: + case MySqlParser.KW_REPLICATE_WILD_DO_TABLE: + case MySqlParser.KW_REPLICATE_WILD_IGNORE_TABLE: + case MySqlParser.KW_REPLICATION: + case MySqlParser.KW_RESET: + case MySqlParser.KW_RESUME: + case MySqlParser.KW_RETURNED_SQLSTATE: + case MySqlParser.KW_RETURNS: + case MySqlParser.KW_REUSE: + case MySqlParser.KW_ROLE: + case MySqlParser.KW_ROLLBACK: + case MySqlParser.KW_ROLLUP: + case MySqlParser.KW_ROTATE: + case MySqlParser.KW_ROW: + case MySqlParser.KW_ROWS: + case MySqlParser.KW_ROW_FORMAT: + case MySqlParser.KW_SAVEPOINT: + case MySqlParser.KW_SCHEDULE: + case MySqlParser.KW_SECURITY: + case MySqlParser.KW_SERVER: + case MySqlParser.KW_SESSION: + case MySqlParser.KW_SHARE: + case MySqlParser.KW_SHARED: + case MySqlParser.KW_SIGNED: + case MySqlParser.KW_SIMPLE: + case MySqlParser.KW_SLAVE: + case MySqlParser.KW_SLOW: + case MySqlParser.KW_SNAPSHOT: + case MySqlParser.KW_SOCKET: + case MySqlParser.KW_SOME: + case MySqlParser.KW_SONAME: + case MySqlParser.KW_SOUNDS: + case MySqlParser.KW_SOURCE: + case MySqlParser.KW_SQL_AFTER_GTIDS: + case MySqlParser.KW_SQL_AFTER_MTS_GAPS: + case MySqlParser.KW_SQL_BEFORE_GTIDS: + case MySqlParser.KW_SQL_BUFFER_RESULT: + case MySqlParser.KW_SQL_CACHE: + case MySqlParser.KW_SQL_NO_CACHE: + case MySqlParser.KW_SQL_THREAD: + case MySqlParser.KW_START: + case MySqlParser.KW_STARTS: + case MySqlParser.KW_STATS_AUTO_RECALC: + case MySqlParser.KW_STATS_PERSISTENT: + case MySqlParser.KW_STATS_SAMPLE_PAGES: + case MySqlParser.KW_STATUS: + case MySqlParser.KW_STOP: + case MySqlParser.KW_STORAGE: + case MySqlParser.KW_STRING: + case MySqlParser.KW_SUBCLASS_ORIGIN: + case MySqlParser.KW_SUBJECT: + case MySqlParser.KW_SUBPARTITION: + case MySqlParser.KW_SUBPARTITIONS: + case MySqlParser.KW_SUSPEND: + case MySqlParser.KW_SWAPS: + case MySqlParser.KW_SWITCHES: + case MySqlParser.KW_TABLE_NAME: + case MySqlParser.KW_TABLESPACE: + case MySqlParser.KW_TABLE_TYPE: + case MySqlParser.KW_TEMPORARY: + case MySqlParser.KW_TEMPTABLE: + case MySqlParser.KW_THAN: + case MySqlParser.KW_TRADITIONAL: + case MySqlParser.KW_TRANSACTION: + case MySqlParser.KW_TRANSACTIONAL: + case MySqlParser.KW_TRIGGERS: + case MySqlParser.KW_TRUNCATE: + case MySqlParser.KW_UNBOUNDED: + case MySqlParser.KW_UNDEFINED: + case MySqlParser.KW_UNDOFILE: + case MySqlParser.KW_UNDO_BUFFER_SIZE: + case MySqlParser.KW_UNINSTALL: + case MySqlParser.KW_UNKNOWN: + case MySqlParser.KW_UNTIL: + case MySqlParser.KW_UPGRADE: + case MySqlParser.KW_USER: + case MySqlParser.KW_USE_FRM: + case MySqlParser.KW_USER_RESOURCES: + case MySqlParser.KW_VALIDATION: + case MySqlParser.KW_VALUE: + case MySqlParser.KW_VARIABLES: + case MySqlParser.KW_VIEW: + case MySqlParser.KW_VIRTUAL: + case MySqlParser.KW_VISIBLE: + case MySqlParser.KW_WAIT: + case MySqlParser.KW_WARNINGS: + case MySqlParser.KW_WITHOUT: + case MySqlParser.KW_WORK: + case MySqlParser.KW_WRAPPER: + case MySqlParser.KW_X509: + case MySqlParser.KW_XA: + case MySqlParser.KW_XML: + case MySqlParser.KW_QUARTER: + case MySqlParser.KW_MONTH: + case MySqlParser.KW_DAY: + case MySqlParser.KW_HOUR: + case MySqlParser.KW_MINUTE: + case MySqlParser.KW_WEEK: + case MySqlParser.KW_SECOND: + case MySqlParser.KW_MICROSECOND: + case MySqlParser.KW_ADMIN: + case MySqlParser.KW_AUDIT_ABORT_EXEMPT: + case MySqlParser.KW_AUDIT_ADMIN: + case MySqlParser.KW_AUTHENTICATION_POLICY_ADMIN: + case MySqlParser.KW_BACKUP_ADMIN: + case MySqlParser.KW_BINLOG_ADMIN: + case MySqlParser.KW_BINLOG_ENCRYPTION_ADMIN: + case MySqlParser.KW_CLONE_ADMIN: + case MySqlParser.KW_CONNECTION_ADMIN: + case MySqlParser.KW_ENCRYPTION_KEY_ADMIN: + case MySqlParser.KW_EXECUTE: + case MySqlParser.KW_FILE: + case MySqlParser.KW_FIREWALL_ADMIN: + case MySqlParser.KW_FIREWALL_EXEMPT: + case MySqlParser.KW_FIREWALL_USER: + case MySqlParser.KW_GROUP_REPLICATION_ADMIN: + case MySqlParser.KW_INNODB_REDO_LOG_ARCHIVE: + case MySqlParser.KW_INVOKE: + case MySqlParser.KW_LAMBDA: + case MySqlParser.KW_NDB_STORED_USER: + case MySqlParser.KW_PASSWORDLESS_USER_ADMIN: + case MySqlParser.KW_PERSIST_RO_VARIABLES_ADMIN: + case MySqlParser.KW_PRIVILEGES: + case MySqlParser.KW_PROCESS: + case MySqlParser.KW_RELOAD: + case MySqlParser.KW_REPLICATION_APPLIER: + case MySqlParser.KW_REPLICATION_SLAVE_ADMIN: + case MySqlParser.KW_RESOURCE_GROUP_ADMIN: + case MySqlParser.KW_RESOURCE_GROUP_USER: + case MySqlParser.KW_ROLE_ADMIN: + case MySqlParser.KW_ROUTINE: + case MySqlParser.KW_S3: + case MySqlParser.KW_SESSION_VARIABLES_ADMIN: + case MySqlParser.KW_SET_USER_ID: + case MySqlParser.KW_SHOW_ROUTINE: + case MySqlParser.KW_SHUTDOWN: + case MySqlParser.KW_SUPER: + case MySqlParser.KW_SYSTEM_VARIABLES_ADMIN: + case MySqlParser.KW_TABLES: + case MySqlParser.KW_TABLE_ENCRYPTION_ADMIN: + case MySqlParser.KW_VERSION_TOKEN_ADMIN: + case MySqlParser.KW_XA_RECOVER_ADMIN: + case MySqlParser.KW_ARMSCII8: + case MySqlParser.KW_ASCII: + case MySqlParser.KW_BIG5: + case MySqlParser.KW_CP1250: + case MySqlParser.KW_CP1251: + case MySqlParser.KW_CP1256: + case MySqlParser.KW_CP1257: + case MySqlParser.KW_CP850: + case MySqlParser.KW_CP852: + case MySqlParser.KW_CP866: + case MySqlParser.KW_CP932: + case MySqlParser.KW_DEC8: + case MySqlParser.KW_EUCJPMS: + case MySqlParser.KW_EUCKR: + case MySqlParser.KW_GB18030: + case MySqlParser.KW_GB2312: + case MySqlParser.KW_GBK: + case MySqlParser.KW_GEOSTD8: + case MySqlParser.KW_GREEK: + case MySqlParser.KW_HEBREW: + case MySqlParser.KW_HP8: + case MySqlParser.KW_KEYBCS2: + case MySqlParser.KW_KOI8R: + case MySqlParser.KW_KOI8U: + case MySqlParser.KW_LATIN1: + case MySqlParser.KW_LATIN2: + case MySqlParser.KW_LATIN5: + case MySqlParser.KW_LATIN7: + case MySqlParser.KW_MACCE: + case MySqlParser.KW_MACROMAN: + case MySqlParser.KW_SJIS: + case MySqlParser.KW_SWE7: + case MySqlParser.KW_TIS620: + case MySqlParser.KW_UCS2: + case MySqlParser.KW_UJIS: + case MySqlParser.KW_UTF16: + case MySqlParser.KW_UTF16LE: + case MySqlParser.KW_UTF32: + case MySqlParser.KW_UTF8: + case MySqlParser.KW_UTF8MB3: + case MySqlParser.KW_UTF8MB4: + case MySqlParser.KW_ARCHIVE: + case MySqlParser.KW_BLACKHOLE: + case MySqlParser.KW_CSV: + case MySqlParser.KW_FEDERATED: + case MySqlParser.KW_INNODB: + case MySqlParser.KW_MEMORY: + case MySqlParser.KW_MRG_MYISAM: + case MySqlParser.KW_MYISAM: + case MySqlParser.KW_NDB: + case MySqlParser.KW_NDBCLUSTER: + case MySqlParser.KW_PERFORMANCE_SCHEMA: + case MySqlParser.KW_TOKUDB: + case MySqlParser.KW_REPEATABLE: + case MySqlParser.KW_COMMITTED: + case MySqlParser.KW_UNCOMMITTED: + case MySqlParser.KW_SERIALIZABLE: + case MySqlParser.KW_GEOMETRYCOLLECTION: + case MySqlParser.KW_LINESTRING: + case MySqlParser.KW_MULTILINESTRING: + case MySqlParser.KW_MULTIPOINT: + case MySqlParser.KW_MULTIPOLYGON: + case MySqlParser.KW_POINT: + case MySqlParser.KW_POLYGON: + case MySqlParser.KW_CATALOG_NAME: + case MySqlParser.KW_CHARSET: + case MySqlParser.KW_COLLATION: + case MySqlParser.KW_ENGINE_ATTRIBUTE: + case MySqlParser.KW_FORMAT: + case MySqlParser.KW_GET_FORMAT: + case MySqlParser.KW_RANDOM: + case MySqlParser.KW_REVERSE: + case MySqlParser.KW_ROW_COUNT: + case MySqlParser.KW_SCHEMA_NAME: + case MySqlParser.KW_SECONDARY_ENGINE_ATTRIBUTE: + case MySqlParser.KW_SRID: + case MySqlParser.KW_SYSTEM_USER: + case MySqlParser.KW_TP_CONNECTION_ADMIN: + case MySqlParser.KW_WEIGHT_STRING: + case MySqlParser.MOD: + case MySqlParser.CHARSET_REVERSE_QOUTE_STRING: + case MySqlParser.STRING_LITERAL: + case MySqlParser.ID: + { + this.state = 3707; + this.tableName(); + this.state = 3710; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 865) { + { + this.state = 3708; + this.match(MySqlParser.DOT); + this.state = 3709; + this.match(MySqlParser.STAR); + } + } + this.state = 3720; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 3712; + this.match(MySqlParser.COMMA); + this.state = 3713; + this.tableName(); + this.state = 3716; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 865) { + { + this.state = 3714; + this.match(MySqlParser.DOT); + this.state = 3715; + this.match(MySqlParser.STAR); + } + } + } + } + this.state = 3722; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 3723; + this.match(MySqlParser.KW_FROM); + this.state = 3724; + this.tableSources(); + } + break; + case MySqlParser.KW_FROM: + { + this.state = 3726; + this.match(MySqlParser.KW_FROM); + this.state = 3727; + this.tableName(); + this.state = 3730; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 865) { + { + this.state = 3728; + this.match(MySqlParser.DOT); + this.state = 3729; + this.match(MySqlParser.STAR); + } + } + this.state = 3740; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 3732; + this.match(MySqlParser.COMMA); + this.state = 3733; + this.tableName(); + this.state = 3736; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 865) { + { + this.state = 3734; + this.match(MySqlParser.DOT); + this.state = 3735; + this.match(MySqlParser.STAR); + } + } + } + } + this.state = 3742; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 3743; + this.match(MySqlParser.KW_USING); + this.state = 3744; + this.tableSources(); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + this.state = 3750; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 192) { + { + this.state = 3748; + this.match(MySqlParser.KW_WHERE); + this.state = 3749; + this.expression(0); + } + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + handlerOpenStatement() { + let localContext = new HandlerOpenStatementContext(this.context, this.state); + this.enterRule(localContext, 238, MySqlParser.RULE_handlerOpenStatement); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 3752; + this.match(MySqlParser.KW_HANDLER); + this.state = 3753; + this.tableName(); + this.state = 3754; + this.match(MySqlParser.KW_OPEN); + this.state = 3759; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 514, this.context)) { + case 1: + { + this.state = 3756; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 13) { + { + this.state = 3755; + this.match(MySqlParser.KW_AS); + } + } + this.state = 3758; + localContext._table_alias = this.uid(); + } + break; + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + handlerReadIndexStatement() { + let localContext = new HandlerReadIndexStatementContext(this.context, this.state); + this.enterRule(localContext, 240, MySqlParser.RULE_handlerReadIndexStatement); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 3761; + this.match(MySqlParser.KW_HANDLER); + this.state = 3762; + this.tableName(); + this.state = 3763; + this.match(MySqlParser.KW_READ); + this.state = 3764; + this.indexName(); + this.state = 3771; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.EQUAL_SYMBOL: + case MySqlParser.GREATER_SYMBOL: + case MySqlParser.LESS_SYMBOL: + { + this.state = 3765; + this.comparisonBase(); + this.state = 3766; + this.match(MySqlParser.LR_BRACKET); + this.state = 3767; + this.constants(); + this.state = 3768; + this.match(MySqlParser.RR_BRACKET); + } + break; + case MySqlParser.KW_FIRST: + case MySqlParser.KW_LAST: + case MySqlParser.KW_NEXT: + case MySqlParser.KW_PREV: + { + this.state = 3770; + localContext._moveOrder = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 402 || _la === 445 || _la === 501 || _la === 542)) { + localContext._moveOrder = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + break; + default: + throw new antlr.NoViableAltException(this); + } + this.state = 3775; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 192) { + { + this.state = 3773; + this.match(MySqlParser.KW_WHERE); + this.state = 3774; + this.expression(0); + } + } + this.state = 3779; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 100) { + { + this.state = 3777; + this.match(MySqlParser.KW_LIMIT); + this.state = 3778; + this.limitClauseAtom(); + } + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + handlerReadStatement() { + let localContext = new HandlerReadStatementContext(this.context, this.state); + this.enterRule(localContext, 242, MySqlParser.RULE_handlerReadStatement); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 3781; + this.match(MySqlParser.KW_HANDLER); + this.state = 3782; + this.tableName(); + this.state = 3783; + this.match(MySqlParser.KW_READ); + this.state = 3784; + localContext._moveOrder = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 402 || _la === 501)) { + localContext._moveOrder = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 3787; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 192) { + { + this.state = 3785; + this.match(MySqlParser.KW_WHERE); + this.state = 3786; + this.expression(0); + } + } + this.state = 3791; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 100) { + { + this.state = 3789; + this.match(MySqlParser.KW_LIMIT); + this.state = 3790; + this.limitClauseAtom(); + } + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + handlerCloseStatement() { + let localContext = new HandlerCloseStatementContext(this.context, this.state); + this.enterRule(localContext, 244, MySqlParser.RULE_handlerCloseStatement); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 3793; + this.match(MySqlParser.KW_HANDLER); + this.state = 3794; + this.tableName(); + this.state = 3795; + this.match(MySqlParser.KW_CLOSE); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + importTableStatement() { + let localContext = new ImportTableStatementContext(this.context, this.state); + this.enterRule(localContext, 246, MySqlParser.RULE_importTableStatement); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 3797; + this.match(MySqlParser.KW_IMPORT); + this.state = 3798; + this.match(MySqlParser.KW_TABLE); + this.state = 3799; + this.match(MySqlParser.KW_FROM); + this.state = 3800; + this.stringLiteral(); + this.state = 3805; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 3801; + this.match(MySqlParser.COMMA); + this.state = 3802; + this.stringLiteral(); + } + } + this.state = 3807; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + singleUpdateStatement() { + let localContext = new SingleUpdateStatementContext(this.context, this.state); + this.enterRule(localContext, 248, MySqlParser.RULE_singleUpdateStatement); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 3808; + this.match(MySqlParser.KW_UPDATE); + this.state = 3810; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 107) { + { + this.state = 3809; + localContext._priority = this.match(MySqlParser.KW_LOW_PRIORITY); + } + } + this.state = 3813; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 79) { + { + this.state = 3812; + this.match(MySqlParser.KW_IGNORE); + } + } + this.state = 3815; + this.tableName(); + this.state = 3820; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if ((((_la) & ~0x1F) === 0 && ((1 << _la) & 1074311168) !== 0) || ((((_la - 36)) & ~0x1F) === 0 && ((1 << (_la - 36)) & 11014219) !== 0) || ((((_la - 74)) & ~0x1F) === 0 && ((1 << (_la - 74)) & 18878481) !== 0) || ((((_la - 117)) & ~0x1F) === 0 && ((1 << (_la - 117)) & 100679969) !== 0) || ((((_la - 150)) & ~0x1F) === 0 && ((1 << (_la - 150)) & 1049605) !== 0) || ((((_la - 219)) & ~0x1F) === 0 && ((1 << (_la - 219)) & 5374495) !== 0) || ((((_la - 253)) & ~0x1F) === 0 && ((1 << (_la - 253)) & 4294967295) !== 0) || ((((_la - 285)) & ~0x1F) === 0 && ((1 << (_la - 285)) & 4261412607) !== 0) || ((((_la - 317)) & ~0x1F) === 0 && ((1 << (_la - 317)) & 4160741375) !== 0) || ((((_la - 349)) & ~0x1F) === 0 && ((1 << (_la - 349)) & 4026531839) !== 0) || ((((_la - 381)) & ~0x1F) === 0 && ((1 << (_la - 381)) & 1055907839) !== 0) || ((((_la - 413)) & ~0x1F) === 0 && ((1 << (_la - 413)) & 4294885367) !== 0) || ((((_la - 445)) & ~0x1F) === 0 && ((1 << (_la - 445)) & 3757571071) !== 0) || ((((_la - 478)) & ~0x1F) === 0 && ((1 << (_la - 478)) & 3755999231) !== 0) || ((((_la - 510)) & ~0x1F) === 0 && ((1 << (_la - 510)) & 3751780349) !== 0) || ((((_la - 542)) & ~0x1F) === 0 && ((1 << (_la - 542)) & 2141183997) !== 0) || ((((_la - 575)) & ~0x1F) === 0 && ((1 << (_la - 575)) & 2147483629) !== 0) || ((((_la - 633)) & ~0x1F) === 0 && ((1 << (_la - 633)) & 4294934527) !== 0) || ((((_la - 665)) & ~0x1F) === 0 && ((1 << (_la - 665)) & 4278189053) !== 0) || ((((_la - 697)) & ~0x1F) === 0 && ((1 << (_la - 697)) & 1644099327) !== 0) || ((((_la - 729)) & ~0x1F) === 0 && ((1 << (_la - 729)) & 4294900735) !== 0) || ((((_la - 761)) & ~0x1F) === 0 && ((1 << (_la - 761)) & 4294967295) !== 0) || ((((_la - 793)) & ~0x1F) === 0 && ((1 << (_la - 793)) & 4288675839) !== 0) || ((((_la - 825)) & ~0x1F) === 0 && ((1 << (_la - 825)) & 2147527671) !== 0) || ((((_la - 879)) & ~0x1F) === 0 && ((1 << (_la - 879)) & 1033) !== 0)) { + { + this.state = 3817; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 13) { + { + this.state = 3816; + this.match(MySqlParser.KW_AS); + } + } + this.state = 3819; + localContext._table_alias = this.uid(); + } + } + this.state = 3822; + this.match(MySqlParser.KW_SET); + this.state = 3823; + this.updatedElement(); + this.state = 3828; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 3824; + this.match(MySqlParser.COMMA); + this.state = 3825; + this.updatedElement(); + } + } + this.state = 3830; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 3833; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 192) { + { + this.state = 3831; + this.match(MySqlParser.KW_WHERE); + this.state = 3832; + this.expression(0); + } + } + this.state = 3836; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 125) { + { + this.state = 3835; + this.orderByClause(); + } + } + this.state = 3839; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 100) { + { + this.state = 3838; + this.limitClause(); + } + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + multipleUpdateStatement() { + let localContext = new MultipleUpdateStatementContext(this.context, this.state); + this.enterRule(localContext, 250, MySqlParser.RULE_multipleUpdateStatement); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 3841; + this.match(MySqlParser.KW_UPDATE); + this.state = 3843; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 107) { + { + this.state = 3842; + localContext._priority = this.match(MySqlParser.KW_LOW_PRIORITY); + } + } + this.state = 3846; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 79) { + { + this.state = 3845; + this.match(MySqlParser.KW_IGNORE); + } + } + this.state = 3848; + this.tableSources(); + this.state = 3849; + this.match(MySqlParser.KW_SET); + this.state = 3850; + this.updatedElement(); + this.state = 3855; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 3851; + this.match(MySqlParser.COMMA); + this.state = 3852; + this.updatedElement(); + } + } + this.state = 3857; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 3860; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 192) { + { + this.state = 3858; + this.match(MySqlParser.KW_WHERE); + this.state = 3859; + this.expression(0); + } + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + orderByClause() { + let localContext = new OrderByClauseContext(this.context, this.state); + this.enterRule(localContext, 252, MySqlParser.RULE_orderByClause); + try { + let alternative; + this.enterOuterAlt(localContext, 1); + { + this.state = 3862; + this.match(MySqlParser.KW_ORDER); + this.state = 3863; + this.match(MySqlParser.KW_BY); + this.state = 3864; + this.orderByExpression(); + this.state = 3869; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 533, this.context); + while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER) { + if (alternative === 1) { + { + { + this.state = 3865; + this.match(MySqlParser.COMMA); + this.state = 3866; + this.orderByExpression(); + } + } + } + this.state = 3871; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 533, this.context); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + orderByExpression() { + let localContext = new OrderByExpressionContext(this.context, this.state); + this.enterRule(localContext, 254, MySqlParser.RULE_orderByExpression); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 3872; + this.expression(0); + this.state = 3874; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 534, this.context)) { + case 1: + { + this.state = 3873; + localContext._order = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 14 || _la === 45)) { + localContext._order = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + break; + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + tableSources() { + let localContext = new TableSourcesContext(this.context, this.state); + this.enterRule(localContext, 256, MySqlParser.RULE_tableSources); + try { + let alternative; + this.enterOuterAlt(localContext, 1); + { + this.state = 3876; + this.tableSource(); + this.state = 3881; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 535, this.context); + while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER) { + if (alternative === 1) { + { + { + this.state = 3877; + this.match(MySqlParser.COMMA); + this.state = 3878; + this.tableSource(); + } + } + } + this.state = 3883; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 535, this.context); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + tableSource() { + let localContext = new TableSourceContext(this.context, this.state); + this.enterRule(localContext, 258, MySqlParser.RULE_tableSource); + let _la; + try { + let alternative; + this.state = 3902; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 538, this.context)) { + case 1: + localContext = new TableSourceBaseContext(localContext); + this.enterOuterAlt(localContext, 1); + { + this.state = 3884; + this.tableSourceItem(); + this.state = 3888; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 536, this.context); + while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER) { + if (alternative === 1) { + { + { + this.state = 3885; + this.joinPart(); + } + } + } + this.state = 3890; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 536, this.context); + } + } + break; + case 2: + localContext = new TableSourceNestedContext(localContext); + this.enterOuterAlt(localContext, 2); + { + this.state = 3891; + this.match(MySqlParser.LR_BRACKET); + this.state = 3892; + this.tableSourceItem(); + this.state = 3896; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 35 || ((((_la - 84)) & ~0x1F) === 0 && ((1 << (_la - 84)) & 536887425) !== 0) || _la === 150 || _la === 172) { + { + { + this.state = 3893; + this.joinPart(); + } + } + this.state = 3898; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 3899; + this.match(MySqlParser.RR_BRACKET); + } + break; + case 3: + localContext = new TableJsonContext(localContext); + this.enterOuterAlt(localContext, 3); + { + this.state = 3901; + this.jsonTable(); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + tableSourceItem() { + let localContext = new TableSourceItemContext(this.context, this.state); + this.enterRule(localContext, 260, MySqlParser.RULE_tableSourceItem); + let _la; + try { + let alternative; + this.state = 3949; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 548, this.context)) { + case 1: + localContext = new AtomTableItemContext(localContext); + this.enterOuterAlt(localContext, 1); + { + this.state = 3904; + this.tableName(); + this.state = 3910; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 539, this.context)) { + case 1: + { + this.state = 3905; + this.match(MySqlParser.KW_PARTITION); + this.state = 3906; + this.match(MySqlParser.LR_BRACKET); + this.state = 3907; + this.partitionNames(); + this.state = 3908; + this.match(MySqlParser.RR_BRACKET); + } + break; + } + this.state = 3916; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 541, this.context)) { + case 1: + { + this.state = 3913; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 13) { + { + this.state = 3912; + this.match(MySqlParser.KW_AS); + } + } + this.state = 3915; + localContext._alias = this.uid(); + } + break; + } + this.state = 3926; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 543, this.context)) { + case 1: + { + this.state = 3918; + this.indexHint(); + this.state = 3923; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 542, this.context); + while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER) { + if (alternative === 1) { + { + { + this.state = 3919; + this.match(MySqlParser.COMMA); + this.state = 3920; + this.indexHint(); + } + } + } + this.state = 3925; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 542, this.context); + } + } + break; + } + } + break; + case 2: + localContext = new SubqueryTableItemContext(localContext); + this.enterOuterAlt(localContext, 2); + { + this.state = 3929; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 95) { + { + this.state = 3928; + this.match(MySqlParser.KW_LATERAL); + } + } + this.state = 3936; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 545, this.context)) { + case 1: + { + this.state = 3931; + this.selectStatement(); + } + break; + case 2: + { + this.state = 3932; + this.match(MySqlParser.LR_BRACKET); + this.state = 3933; + localContext._parenthesisSubquery = this.selectStatement(); + this.state = 3934; + this.match(MySqlParser.RR_BRACKET); + } + break; + } + this.state = 3939; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 13) { + { + this.state = 3938; + this.match(MySqlParser.KW_AS); + } + } + this.state = 3941; + localContext._alias = this.uid(); + this.state = 3943; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 547, this.context)) { + case 1: + { + this.state = 3942; + this.fullColumnNames(); + } + break; + } + } + break; + case 3: + localContext = new TableSourcesItemContext(localContext); + this.enterOuterAlt(localContext, 3); + { + this.state = 3945; + this.match(MySqlParser.LR_BRACKET); + this.state = 3946; + this.tableSources(); + this.state = 3947; + this.match(MySqlParser.RR_BRACKET); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + fullColumnNames() { + let localContext = new FullColumnNamesContext(this.context, this.state); + this.enterRule(localContext, 262, MySqlParser.RULE_fullColumnNames); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 3951; + this.match(MySqlParser.LR_BRACKET); + this.state = 3952; + this.columnNames(); + this.state = 3953; + this.match(MySqlParser.RR_BRACKET); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + indexHint() { + let localContext = new IndexHintContext(this.context, this.state); + this.enterRule(localContext, 264, MySqlParser.RULE_indexHint); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 3955; + localContext._indexHintAction = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 66 || _la === 79 || _la === 187)) { + localContext._indexHintAction = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 3956; + localContext._keyFormat = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 82 || _la === 92)) { + localContext._keyFormat = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 3959; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 65) { + { + this.state = 3957; + this.match(MySqlParser.KW_FOR); + this.state = 3958; + this.indexHintType(); + } + } + this.state = 3961; + this.match(MySqlParser.LR_BRACKET); + this.state = 3963; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if ((((_la) & ~0x1F) === 0 && ((1 << _la) & 1074302976) !== 0) || ((((_la - 36)) & ~0x1F) === 0 && ((1 << (_la - 36)) & 11014219) !== 0) || ((((_la - 74)) & ~0x1F) === 0 && ((1 << (_la - 74)) & 18878481) !== 0) || ((((_la - 117)) & ~0x1F) === 0 && ((1 << (_la - 117)) & 100679969) !== 0) || ((((_la - 150)) & ~0x1F) === 0 && ((1 << (_la - 150)) & 1049605) !== 0) || ((((_la - 219)) & ~0x1F) === 0 && ((1 << (_la - 219)) & 5374495) !== 0) || ((((_la - 253)) & ~0x1F) === 0 && ((1 << (_la - 253)) & 4294967295) !== 0) || ((((_la - 285)) & ~0x1F) === 0 && ((1 << (_la - 285)) & 4261412607) !== 0) || ((((_la - 317)) & ~0x1F) === 0 && ((1 << (_la - 317)) & 4160741375) !== 0) || ((((_la - 349)) & ~0x1F) === 0 && ((1 << (_la - 349)) & 4026531839) !== 0) || ((((_la - 381)) & ~0x1F) === 0 && ((1 << (_la - 381)) & 1055907839) !== 0) || ((((_la - 413)) & ~0x1F) === 0 && ((1 << (_la - 413)) & 4294885367) !== 0) || ((((_la - 445)) & ~0x1F) === 0 && ((1 << (_la - 445)) & 3757571071) !== 0) || ((((_la - 478)) & ~0x1F) === 0 && ((1 << (_la - 478)) & 3755999231) !== 0) || ((((_la - 510)) & ~0x1F) === 0 && ((1 << (_la - 510)) & 3751780349) !== 0) || ((((_la - 542)) & ~0x1F) === 0 && ((1 << (_la - 542)) & 2141183997) !== 0) || ((((_la - 575)) & ~0x1F) === 0 && ((1 << (_la - 575)) & 2147483629) !== 0) || ((((_la - 633)) & ~0x1F) === 0 && ((1 << (_la - 633)) & 4294934527) !== 0) || ((((_la - 665)) & ~0x1F) === 0 && ((1 << (_la - 665)) & 4278189053) !== 0) || ((((_la - 697)) & ~0x1F) === 0 && ((1 << (_la - 697)) & 1644099327) !== 0) || ((((_la - 729)) & ~0x1F) === 0 && ((1 << (_la - 729)) & 4294900735) !== 0) || ((((_la - 761)) & ~0x1F) === 0 && ((1 << (_la - 761)) & 4294967295) !== 0) || ((((_la - 793)) & ~0x1F) === 0 && ((1 << (_la - 793)) & 4288675839) !== 0) || ((((_la - 825)) & ~0x1F) === 0 && ((1 << (_la - 825)) & 2147527671) !== 0) || ((((_la - 879)) & ~0x1F) === 0 && ((1 << (_la - 879)) & 1033) !== 0)) { + { + this.state = 3962; + this.indexNames(); + } + } + this.state = 3965; + this.match(MySqlParser.RR_BRACKET); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + indexHintType() { + let localContext = new IndexHintTypeContext(this.context, this.state); + this.enterRule(localContext, 266, MySqlParser.RULE_indexHintType); + try { + this.state = 3972; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_JOIN: + this.enterOuterAlt(localContext, 1); + { + this.state = 3967; + this.match(MySqlParser.KW_JOIN); + } + break; + case MySqlParser.KW_ORDER: + this.enterOuterAlt(localContext, 2); + { + this.state = 3968; + this.match(MySqlParser.KW_ORDER); + this.state = 3969; + this.match(MySqlParser.KW_BY); + } + break; + case MySqlParser.KW_GROUP: + this.enterOuterAlt(localContext, 3); + { + this.state = 3970; + this.match(MySqlParser.KW_GROUP); + this.state = 3971; + this.match(MySqlParser.KW_BY); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + joinPart() { + let localContext = new JoinPartContext(this.context, this.state); + this.enterRule(localContext, 268, MySqlParser.RULE_joinPart); + let _la; + try { + let alternative; + this.state = 4023; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_CROSS: + case MySqlParser.KW_INNER: + case MySqlParser.KW_JOIN: + localContext = new InnerJoinContext(localContext); + this.enterOuterAlt(localContext, 1); + { + this.state = 3975; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 35 || _la === 84) { + { + this.state = 3974; + _la = this.tokenStream.LA(1); + if (!(_la === 35 || _la === 84)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + this.state = 3977; + this.match(MySqlParser.KW_JOIN); + this.state = 3979; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 553, this.context)) { + case 1: + { + this.state = 3978; + this.match(MySqlParser.KW_LATERAL); + } + break; + } + this.state = 3981; + this.tableSourceItem(); + this.state = 3985; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 554, this.context); + while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER) { + if (alternative === 1) { + { + { + this.state = 3982; + this.joinSpec(); + } + } + } + this.state = 3987; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 554, this.context); + } + } + break; + case MySqlParser.KW_STRAIGHT_JOIN: + localContext = new StraightJoinContext(localContext); + this.enterOuterAlt(localContext, 2); + { + this.state = 3988; + this.match(MySqlParser.KW_STRAIGHT_JOIN); + this.state = 3989; + this.tableSourceItem(); + this.state = 3993; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 555, this.context); + while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER) { + if (alternative === 1) { + { + { + this.state = 3990; + this.joinSpec(); + } + } + } + this.state = 3995; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 555, this.context); + } + } + break; + case MySqlParser.KW_LEFT: + case MySqlParser.KW_RIGHT: + localContext = new OuterJoinContext(localContext); + this.enterOuterAlt(localContext, 3); + { + this.state = 3996; + _la = this.tokenStream.LA(1); + if (!(_la === 98 || _la === 150)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 3998; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 127) { + { + this.state = 3997; + this.match(MySqlParser.KW_OUTER); + } + } + this.state = 4000; + this.match(MySqlParser.KW_JOIN); + this.state = 4002; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 557, this.context)) { + case 1: + { + this.state = 4001; + this.match(MySqlParser.KW_LATERAL); + } + break; + } + this.state = 4004; + this.tableSourceItem(); + this.state = 4008; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 558, this.context); + while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER) { + if (alternative === 1) { + { + { + this.state = 4005; + this.joinSpec(); + } + } + } + this.state = 4010; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 558, this.context); + } + } + break; + case MySqlParser.KW_NATURAL: + localContext = new NaturalJoinContext(localContext); + this.enterOuterAlt(localContext, 4); + { + this.state = 4011; + this.match(MySqlParser.KW_NATURAL); + this.state = 4019; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 84 || _la === 98 || _la === 150) { + { + this.state = 4014; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_INNER: + { + this.state = 4012; + this.match(MySqlParser.KW_INNER); + } + break; + case MySqlParser.KW_LEFT: + case MySqlParser.KW_RIGHT: + { + this.state = 4013; + _la = this.tokenStream.LA(1); + if (!(_la === 98 || _la === 150)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + break; + default: + throw new antlr.NoViableAltException(this); + } + this.state = 4017; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 127) { + { + this.state = 4016; + this.match(MySqlParser.KW_OUTER); + } + } + } + } + this.state = 4021; + this.match(MySqlParser.KW_JOIN); + this.state = 4022; + this.tableSourceItem(); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + joinSpec() { + let localContext = new JoinSpecContext(this.context, this.state); + this.enterRule(localContext, 270, MySqlParser.RULE_joinSpec); + try { + this.state = 4032; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_ON: + this.enterOuterAlt(localContext, 1); + { + { + this.state = 4025; + this.match(MySqlParser.KW_ON); + this.state = 4026; + this.expression(0); + } + } + break; + case MySqlParser.KW_USING: + this.enterOuterAlt(localContext, 2); + { + this.state = 4027; + this.match(MySqlParser.KW_USING); + this.state = 4028; + this.match(MySqlParser.LR_BRACKET); + this.state = 4029; + this.columnNames(); + this.state = 4030; + this.match(MySqlParser.RR_BRACKET); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + queryExpression() { + let localContext = new QueryExpressionContext(this.context, this.state); + this.enterRule(localContext, 272, MySqlParser.RULE_queryExpression); + try { + this.state = 4042; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 564, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 4034; + this.match(MySqlParser.LR_BRACKET); + this.state = 4035; + this.querySpecification(); + this.state = 4036; + this.match(MySqlParser.RR_BRACKET); + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 4038; + this.match(MySqlParser.LR_BRACKET); + this.state = 4039; + this.queryExpression(); + this.state = 4040; + this.match(MySqlParser.RR_BRACKET); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + querySpecification() { + let localContext = new QuerySpecificationContext(this.context, this.state); + this.enterRule(localContext, 274, MySqlParser.RULE_querySpecification); + try { + let alternative; + this.enterOuterAlt(localContext, 1); + { + this.state = 4044; + this.match(MySqlParser.KW_SELECT); + this.state = 4048; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 565, this.context); + while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER) { + if (alternative === 1) { + { + { + this.state = 4045; + this.selectSpec(); + } + } + } + this.state = 4050; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 565, this.context); + } + this.state = 4051; + this.selectElements(); + this.state = 4053; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 566, this.context)) { + case 1: + { + this.state = 4052; + this.intoClause(); + } + break; + } + this.state = 4055; + this.fromClause(); + this.state = 4057; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 567, this.context)) { + case 1: + { + this.state = 4056; + this.groupByClause(); + } + break; + } + this.state = 4060; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 568, this.context)) { + case 1: + { + this.state = 4059; + this.havingClause(); + } + break; + } + this.state = 4063; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 569, this.context)) { + case 1: + { + this.state = 4062; + this.windowClause(); + } + break; + } + this.state = 4066; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 570, this.context)) { + case 1: + { + this.state = 4065; + this.orderByClause(); + } + break; + } + this.state = 4069; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 571, this.context)) { + case 1: + { + this.state = 4068; + this.limitClause(); + } + break; + } + this.state = 4072; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 572, this.context)) { + case 1: + { + this.state = 4071; + this.intoClause(); + } + break; + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + unionStatement() { + let localContext = new UnionStatementContext(this.context, this.state); + this.enterRule(localContext, 276, MySqlParser.RULE_unionStatement); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 4074; + this.match(MySqlParser.KW_UNION); + this.state = 4076; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 7 || _la === 49) { + { + this.state = 4075; + localContext._unionType = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 7 || _la === 49)) { + localContext._unionType = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + this.state = 4080; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_SELECT: + { + this.state = 4078; + this.querySpecification(); + } + break; + case MySqlParser.LR_BRACKET: + { + this.state = 4079; + this.queryExpression(); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + lateralStatement() { + let localContext = new LateralStatementContext(this.context, this.state); + this.enterRule(localContext, 278, MySqlParser.RULE_lateralStatement); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 4082; + this.match(MySqlParser.KW_LATERAL); + this.state = 4097; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 578, this.context)) { + case 1: + { + this.state = 4083; + this.querySpecification(); + } + break; + case 2: + { + this.state = 4084; + this.queryExpression(); + } + break; + case 3: + { + { + this.state = 4085; + this.match(MySqlParser.LR_BRACKET); + this.state = 4088; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_SELECT: + { + this.state = 4086; + this.querySpecification(); + } + break; + case MySqlParser.LR_BRACKET: + { + this.state = 4087; + this.queryExpression(); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + this.state = 4090; + this.match(MySqlParser.RR_BRACKET); + this.state = 4095; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 577, this.context)) { + case 1: + { + this.state = 4092; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 13) { + { + this.state = 4091; + this.match(MySqlParser.KW_AS); + } + } + this.state = 4094; + localContext._alias = this.uid(); + } + break; + } + } + } + break; + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + jsonTable() { + let localContext = new JsonTableContext(this.context, this.state); + this.enterRule(localContext, 280, MySqlParser.RULE_jsonTable); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 4099; + this.match(MySqlParser.KW_JSON_TABLE); + this.state = 4100; + this.match(MySqlParser.LR_BRACKET); + this.state = 4101; + this.match(MySqlParser.STRING_LITERAL); + this.state = 4102; + this.match(MySqlParser.COMMA); + this.state = 4103; + this.match(MySqlParser.STRING_LITERAL); + this.state = 4104; + this.match(MySqlParser.KW_COLUMNS); + this.state = 4105; + this.match(MySqlParser.LR_BRACKET); + this.state = 4106; + this.jsonColumnList(); + this.state = 4107; + this.match(MySqlParser.RR_BRACKET); + this.state = 4108; + this.match(MySqlParser.RR_BRACKET); + this.state = 4113; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 580, this.context)) { + case 1: + { + this.state = 4110; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 13) { + { + this.state = 4109; + this.match(MySqlParser.KW_AS); + } + } + this.state = 4112; + localContext._alias = this.uid(); + } + break; + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + jsonColumnList() { + let localContext = new JsonColumnListContext(this.context, this.state); + this.enterRule(localContext, 282, MySqlParser.RULE_jsonColumnList); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 4115; + this.jsonColumn(); + this.state = 4120; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 4116; + this.match(MySqlParser.COMMA); + this.state = 4117; + this.jsonColumn(); + } + } + this.state = 4122; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + jsonColumn() { + let localContext = new JsonColumnContext(this.context, this.state); + this.enterRule(localContext, 284, MySqlParser.RULE_jsonColumn); + let _la; + try { + this.state = 4152; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 587, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 4123; + this.columnName(); + this.state = 4140; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_FOR: + { + this.state = 4124; + this.match(MySqlParser.KW_FOR); + this.state = 4125; + this.match(MySqlParser.KW_ORDINALITY); + } + break; + case MySqlParser.KW_CHARACTER: + case MySqlParser.KW_SET: + case MySqlParser.KW_TINYINT: + case MySqlParser.KW_SMALLINT: + case MySqlParser.KW_MEDIUMINT: + case MySqlParser.KW_MIDDLEINT: + case MySqlParser.KW_INT: + case MySqlParser.KW_INT1: + case MySqlParser.KW_INT2: + case MySqlParser.KW_INT3: + case MySqlParser.KW_INT4: + case MySqlParser.KW_INT8: + case MySqlParser.KW_INTEGER: + case MySqlParser.KW_BIGINT: + case MySqlParser.KW_REAL: + case MySqlParser.KW_DOUBLE: + case MySqlParser.KW_FLOAT: + case MySqlParser.KW_FLOAT4: + case MySqlParser.KW_FLOAT8: + case MySqlParser.KW_DECIMAL: + case MySqlParser.KW_DEC: + case MySqlParser.KW_NUMERIC: + case MySqlParser.KW_DATE: + case MySqlParser.KW_TIME: + case MySqlParser.KW_TIMESTAMP: + case MySqlParser.KW_DATETIME: + case MySqlParser.KW_YEAR: + case MySqlParser.KW_CHAR: + case MySqlParser.KW_VARCHAR: + case MySqlParser.KW_NVARCHAR: + case MySqlParser.KW_NATIONAL: + case MySqlParser.KW_BINARY: + case MySqlParser.KW_VARBINARY: + case MySqlParser.KW_TINYBLOB: + case MySqlParser.KW_BLOB: + case MySqlParser.KW_MEDIUMBLOB: + case MySqlParser.KW_LONG: + case MySqlParser.KW_LONGBLOB: + case MySqlParser.KW_TINYTEXT: + case MySqlParser.KW_TEXT: + case MySqlParser.KW_MEDIUMTEXT: + case MySqlParser.KW_LONGTEXT: + case MySqlParser.KW_ENUM: + case MySqlParser.KW_SERIAL: + case MySqlParser.KW_BIT: + case MySqlParser.KW_BOOL: + case MySqlParser.KW_BOOLEAN: + case MySqlParser.KW_FIXED: + case MySqlParser.KW_JSON: + case MySqlParser.KW_NCHAR: + case MySqlParser.KW_GEOMETRYCOLLECTION: + case MySqlParser.KW_GEOMCOLLECTION: + case MySqlParser.KW_GEOMETRY: + case MySqlParser.KW_LINESTRING: + case MySqlParser.KW_MULTILINESTRING: + case MySqlParser.KW_MULTIPOINT: + case MySqlParser.KW_MULTIPOLYGON: + case MySqlParser.KW_POINT: + case MySqlParser.KW_POLYGON: + { + this.state = 4126; + this.dataType(); + this.state = 4138; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_PATH: + { + this.state = 4127; + this.match(MySqlParser.KW_PATH); + this.state = 4128; + this.match(MySqlParser.STRING_LITERAL); + this.state = 4130; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 582, this.context)) { + case 1: + { + this.state = 4129; + this.jsonOnEmpty(); + } + break; + } + this.state = 4133; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 42 || _la === 116 || _la === 382) { + { + this.state = 4132; + this.jsonOnError(); + } + } + } + break; + case MySqlParser.KW_EXISTS: + { + this.state = 4135; + this.match(MySqlParser.KW_EXISTS); + this.state = 4136; + this.match(MySqlParser.KW_PATH); + this.state = 4137; + this.match(MySqlParser.STRING_LITERAL); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 4142; + this.match(MySqlParser.KW_NESTED); + this.state = 4144; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 257) { + { + this.state = 4143; + this.match(MySqlParser.KW_PATH); + } + } + this.state = 4146; + this.match(MySqlParser.STRING_LITERAL); + this.state = 4147; + this.match(MySqlParser.KW_COLUMNS); + this.state = 4148; + this.match(MySqlParser.LR_BRACKET); + this.state = 4149; + this.jsonColumnList(); + this.state = 4150; + this.match(MySqlParser.RR_BRACKET); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + jsonOnEmpty() { + let localContext = new JsonOnEmptyContext(this.context, this.state); + this.enterRule(localContext, 286, MySqlParser.RULE_jsonOnEmpty); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 4158; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_NULL_LITERAL: + { + this.state = 4154; + this.match(MySqlParser.KW_NULL_LITERAL); + } + break; + case MySqlParser.KW_ERROR: + { + this.state = 4155; + this.match(MySqlParser.KW_ERROR); + } + break; + case MySqlParser.KW_DEFAULT: + { + this.state = 4156; + this.match(MySqlParser.KW_DEFAULT); + this.state = 4157; + this.defaultValue(); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + this.state = 4160; + this.match(MySqlParser.KW_ON); + this.state = 4161; + this.match(MySqlParser.KW_EMPTY); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + jsonOnError() { + let localContext = new JsonOnErrorContext(this.context, this.state); + this.enterRule(localContext, 288, MySqlParser.RULE_jsonOnError); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 4167; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_NULL_LITERAL: + { + this.state = 4163; + this.match(MySqlParser.KW_NULL_LITERAL); + } + break; + case MySqlParser.KW_ERROR: + { + this.state = 4164; + this.match(MySqlParser.KW_ERROR); + } + break; + case MySqlParser.KW_DEFAULT: + { + this.state = 4165; + this.match(MySqlParser.KW_DEFAULT); + this.state = 4166; + this.defaultValue(); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + this.state = 4169; + this.match(MySqlParser.KW_ON); + this.state = 4170; + this.match(MySqlParser.KW_ERROR); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + selectSpec() { + let localContext = new SelectSpecContext(this.context, this.state); + this.enterRule(localContext, 290, MySqlParser.RULE_selectSpec); + let _la; + try { + this.state = 4180; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_ALL: + case MySqlParser.KW_DISTINCT: + case MySqlParser.KW_DISTINCTROW: + this.enterOuterAlt(localContext, 1); + { + this.state = 4172; + _la = this.tokenStream.LA(1); + if (!(_la === 7 || _la === 49 || _la === 50)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + break; + case MySqlParser.KW_HIGH_PRIORITY: + this.enterOuterAlt(localContext, 2); + { + this.state = 4173; + this.match(MySqlParser.KW_HIGH_PRIORITY); + } + break; + case MySqlParser.KW_STRAIGHT_JOIN: + this.enterOuterAlt(localContext, 3); + { + this.state = 4174; + this.match(MySqlParser.KW_STRAIGHT_JOIN); + } + break; + case MySqlParser.KW_SQL_SMALL_RESULT: + this.enterOuterAlt(localContext, 4); + { + this.state = 4175; + this.match(MySqlParser.KW_SQL_SMALL_RESULT); + } + break; + case MySqlParser.KW_SQL_BIG_RESULT: + this.enterOuterAlt(localContext, 5); + { + this.state = 4176; + this.match(MySqlParser.KW_SQL_BIG_RESULT); + } + break; + case MySqlParser.KW_SQL_BUFFER_RESULT: + this.enterOuterAlt(localContext, 6); + { + this.state = 4177; + this.match(MySqlParser.KW_SQL_BUFFER_RESULT); + } + break; + case MySqlParser.KW_SQL_CACHE: + case MySqlParser.KW_SQL_NO_CACHE: + this.enterOuterAlt(localContext, 7); + { + this.state = 4178; + _la = this.tokenStream.LA(1); + if (!(_la === 637 || _la === 638)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + break; + case MySqlParser.KW_SQL_CALC_FOUND_ROWS: + this.enterOuterAlt(localContext, 8); + { + this.state = 4179; + this.match(MySqlParser.KW_SQL_CALC_FOUND_ROWS); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + selectElements() { + let localContext = new SelectElementsContext(this.context, this.state); + this.enterRule(localContext, 292, MySqlParser.RULE_selectElements); + try { + let alternative; + this.enterOuterAlt(localContext, 1); + { + this.state = 4184; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 591, this.context)) { + case 1: + { + this.state = 4182; + localContext._star = this.match(MySqlParser.STAR); + } + break; + case 2: + { + this.state = 4183; + this.selectElement(); + } + break; + } + this.state = 4190; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 592, this.context); + while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER) { + if (alternative === 1) { + { + { + this.state = 4186; + this.match(MySqlParser.COMMA); + this.state = 4187; + this.selectElement(); + } + } + } + this.state = 4192; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 592, this.context); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + selectElement() { + let localContext = new SelectElementContext(this.context, this.state); + this.enterRule(localContext, 294, MySqlParser.RULE_selectElement); + let _la; + try { + this.state = 4222; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 600, this.context)) { + case 1: + localContext = new SelectExpressionElementContext(localContext); + this.enterOuterAlt(localContext, 1); + { + this.state = 4195; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 593, this.context)) { + case 1: + { + this.state = 4193; + this.match(MySqlParser.LOCAL_ID); + this.state = 4194; + this.match(MySqlParser.VAR_ASSIGN); + } + break; + } + this.state = 4197; + this.expression(0); + this.state = 4202; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 595, this.context)) { + case 1: + { + this.state = 4199; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 13) { + { + this.state = 4198; + this.match(MySqlParser.KW_AS); + } + } + this.state = 4201; + localContext._alias = this.uid(); + } + break; + } + } + break; + case 2: + localContext = new SelectFunctionElementContext(localContext); + this.enterOuterAlt(localContext, 2); + { + this.state = 4204; + this.functionCall(); + this.state = 4209; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 597, this.context)) { + case 1: + { + this.state = 4206; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 13) { + { + this.state = 4205; + this.match(MySqlParser.KW_AS); + } + } + this.state = 4208; + localContext._alias = this.uid(); + } + break; + } + } + break; + case 3: + localContext = new SelectStarElementContext(localContext); + this.enterOuterAlt(localContext, 3); + { + this.state = 4211; + localContext._select_element = this.fullId(); + this.state = 4212; + this.match(MySqlParser.DOT); + this.state = 4213; + this.match(MySqlParser.STAR); + } + break; + case 4: + localContext = new SelectColumnElementContext(localContext); + this.enterOuterAlt(localContext, 4); + { + this.state = 4215; + this.columnName(); + this.state = 4220; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 599, this.context)) { + case 1: + { + this.state = 4217; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 13) { + { + this.state = 4216; + this.match(MySqlParser.KW_AS); + } + } + this.state = 4219; + localContext._alias = this.uid(); + } + break; + } + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + intoClause() { + let localContext = new IntoClauseContext(this.context, this.state); + this.enterRule(localContext, 296, MySqlParser.RULE_intoClause); + let _la; + try { + let alternative; + this.state = 4260; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 607, this.context)) { + case 1: + localContext = new SelectIntoVariablesContext(localContext); + this.enterOuterAlt(localContext, 1); + { + this.state = 4224; + this.match(MySqlParser.KW_INTO); + this.state = 4225; + this.assignmentField(); + this.state = 4230; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 601, this.context); + while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER) { + if (alternative === 1) { + { + { + this.state = 4226; + this.match(MySqlParser.COMMA); + this.state = 4227; + this.assignmentField(); + } + } + } + this.state = 4232; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 601, this.context); + } + } + break; + case 2: + localContext = new SelectIntoDumpFileContext(localContext); + this.enterOuterAlt(localContext, 2); + { + this.state = 4233; + this.match(MySqlParser.KW_INTO); + this.state = 4234; + this.match(MySqlParser.KW_DUMPFILE); + this.state = 4235; + this.match(MySqlParser.STRING_LITERAL); + } + break; + case 3: + localContext = new SelectIntoTextFileContext(localContext); + this.enterOuterAlt(localContext, 3); + { + { + this.state = 4236; + this.match(MySqlParser.KW_INTO); + this.state = 4237; + this.match(MySqlParser.KW_OUTFILE); + this.state = 4238; + localContext._filename = this.match(MySqlParser.STRING_LITERAL); + this.state = 4242; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 602, this.context)) { + case 1: + { + this.state = 4239; + this.match(MySqlParser.KW_CHARACTER); + this.state = 4240; + this.match(MySqlParser.KW_SET); + this.state = 4241; + localContext._charset = this.charsetName(); + } + break; + } + this.state = 4250; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 604, this.context)) { + case 1: + { + this.state = 4244; + localContext._fieldsFormat = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 337 || _la === 398)) { + localContext._fieldsFormat = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 4246; + this.errorHandler.sync(this); + alternative = 1; + do { + switch (alternative) { + case 1: + { + { + this.state = 4245; + this.selectFieldsInto(); + } + } + break; + default: + throw new antlr.NoViableAltException(this); + } + this.state = 4248; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 603, this.context); + } while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER); + } + break; + } + this.state = 4258; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 606, this.context)) { + case 1: + { + this.state = 4252; + this.match(MySqlParser.KW_LINES); + this.state = 4254; + this.errorHandler.sync(this); + alternative = 1; + do { + switch (alternative) { + case 1: + { + { + this.state = 4253; + this.selectLinesInto(); + } + } + break; + default: + throw new antlr.NoViableAltException(this); + } + this.state = 4256; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 605, this.context); + } while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER); + } + break; + } + } + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + selectFieldsInto() { + let localContext = new SelectFieldsIntoContext(this.context, this.state); + this.enterRule(localContext, 298, MySqlParser.RULE_selectFieldsInto); + let _la; + try { + this.state = 4274; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_TERMINATED: + this.enterOuterAlt(localContext, 1); + { + this.state = 4262; + this.match(MySqlParser.KW_TERMINATED); + this.state = 4263; + this.match(MySqlParser.KW_BY); + this.state = 4264; + localContext._terminationField = this.match(MySqlParser.STRING_LITERAL); + } + break; + case MySqlParser.KW_ENCLOSED: + case MySqlParser.KW_OPTIONALLY: + this.enterOuterAlt(localContext, 2); + { + this.state = 4266; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 123) { + { + this.state = 4265; + this.match(MySqlParser.KW_OPTIONALLY); + } + } + this.state = 4268; + this.match(MySqlParser.KW_ENCLOSED); + this.state = 4269; + this.match(MySqlParser.KW_BY); + this.state = 4270; + localContext._enclosion = this.match(MySqlParser.STRING_LITERAL); + } + break; + case MySqlParser.KW_ESCAPED: + this.enterOuterAlt(localContext, 3); + { + this.state = 4271; + this.match(MySqlParser.KW_ESCAPED); + this.state = 4272; + this.match(MySqlParser.KW_BY); + this.state = 4273; + localContext._escaping = this.match(MySqlParser.STRING_LITERAL); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + selectLinesInto() { + let localContext = new SelectLinesIntoContext(this.context, this.state); + this.enterRule(localContext, 300, MySqlParser.RULE_selectLinesInto); + try { + this.state = 4282; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_STARTING: + this.enterOuterAlt(localContext, 1); + { + this.state = 4276; + this.match(MySqlParser.KW_STARTING); + this.state = 4277; + this.match(MySqlParser.KW_BY); + this.state = 4278; + localContext._starting = this.match(MySqlParser.STRING_LITERAL); + } + break; + case MySqlParser.KW_TERMINATED: + this.enterOuterAlt(localContext, 2); + { + this.state = 4279; + this.match(MySqlParser.KW_TERMINATED); + this.state = 4280; + this.match(MySqlParser.KW_BY); + this.state = 4281; + localContext._terminationLine = this.match(MySqlParser.STRING_LITERAL); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + fromClause() { + let localContext = new FromClauseContext(this.context, this.state); + this.enterRule(localContext, 302, MySqlParser.RULE_fromClause); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 4286; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 611, this.context)) { + case 1: + { + this.state = 4284; + this.match(MySqlParser.KW_FROM); + this.state = 4285; + this.tableSources(); + } + break; + } + this.state = 4290; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 612, this.context)) { + case 1: + { + this.state = 4288; + this.match(MySqlParser.KW_WHERE); + this.state = 4289; + localContext._whereExpr = this.expression(0); + } + break; + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + groupByClause() { + let localContext = new GroupByClauseContext(this.context, this.state); + this.enterRule(localContext, 304, MySqlParser.RULE_groupByClause); + try { + let alternative; + this.enterOuterAlt(localContext, 1); + { + this.state = 4292; + this.match(MySqlParser.KW_GROUP); + this.state = 4293; + this.match(MySqlParser.KW_BY); + this.state = 4294; + this.groupByItem(); + this.state = 4299; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 613, this.context); + while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER) { + if (alternative === 1) { + { + { + this.state = 4295; + this.match(MySqlParser.COMMA); + this.state = 4296; + this.groupByItem(); + } + } + } + this.state = 4301; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 613, this.context); + } + this.state = 4304; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 614, this.context)) { + case 1: + { + this.state = 4302; + this.match(MySqlParser.KW_WITH); + this.state = 4303; + this.match(MySqlParser.KW_ROLLUP); + } + break; + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + havingClause() { + let localContext = new HavingClauseContext(this.context, this.state); + this.enterRule(localContext, 306, MySqlParser.RULE_havingClause); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 4306; + this.match(MySqlParser.KW_HAVING); + this.state = 4307; + localContext._havingExpr = this.expression(0); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + windowClause() { + let localContext = new WindowClauseContext(this.context, this.state); + this.enterRule(localContext, 308, MySqlParser.RULE_windowClause); + try { + let alternative; + this.enterOuterAlt(localContext, 1); + { + this.state = 4309; + this.match(MySqlParser.KW_WINDOW); + this.state = 4310; + this.windowName(); + this.state = 4311; + this.match(MySqlParser.KW_AS); + this.state = 4312; + this.match(MySqlParser.LR_BRACKET); + this.state = 4313; + this.windowSpec(); + this.state = 4314; + this.match(MySqlParser.RR_BRACKET); + this.state = 4324; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 615, this.context); + while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER) { + if (alternative === 1) { + { + { + this.state = 4315; + this.match(MySqlParser.COMMA); + this.state = 4316; + this.windowName(); + this.state = 4317; + this.match(MySqlParser.KW_AS); + this.state = 4318; + this.match(MySqlParser.LR_BRACKET); + this.state = 4319; + this.windowSpec(); + this.state = 4320; + this.match(MySqlParser.RR_BRACKET); + } + } + } + this.state = 4326; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 615, this.context); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + groupByItem() { + let localContext = new GroupByItemContext(this.context, this.state); + this.enterRule(localContext, 310, MySqlParser.RULE_groupByItem); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 4327; + this.expression(0); + this.state = 4329; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 616, this.context)) { + case 1: + { + this.state = 4328; + localContext._order = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 14 || _la === 45)) { + localContext._order = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + break; + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + limitClause() { + let localContext = new LimitClauseContext(this.context, this.state); + this.enterRule(localContext, 312, MySqlParser.RULE_limitClause); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 4331; + this.match(MySqlParser.KW_LIMIT); + this.state = 4342; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 618, this.context)) { + case 1: + { + this.state = 4335; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 617, this.context)) { + case 1: + { + this.state = 4332; + localContext._offset = this.limitClauseAtom(); + this.state = 4333; + this.match(MySqlParser.COMMA); + } + break; + } + this.state = 4337; + localContext._limit = this.limitClauseAtom(); + } + break; + case 2: + { + this.state = 4338; + localContext._limit = this.limitClauseAtom(); + this.state = 4339; + this.match(MySqlParser.KW_OFFSET); + this.state = 4340; + localContext._offset = this.limitClauseAtom(); + } + break; + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + limitClauseAtom() { + let localContext = new LimitClauseAtomContext(this.context, this.state); + this.enterRule(localContext, 314, MySqlParser.RULE_limitClauseAtom); + try { + this.state = 4347; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.ZERO_DECIMAL: + case MySqlParser.ONE_DECIMAL: + case MySqlParser.TWO_DECIMAL: + case MySqlParser.THREE_DECIMAL: + case MySqlParser.DECIMAL_LITERAL: + case MySqlParser.REAL_LITERAL: + this.enterOuterAlt(localContext, 1); + { + this.state = 4344; + this.decimalLiteral(); + } + break; + case MySqlParser.LOCAL_ID: + case MySqlParser.GLOBAL_ID: + this.enterOuterAlt(localContext, 2); + { + this.state = 4345; + this.mysqlVariable(); + } + break; + case MySqlParser.KW_ARRAY: + case MySqlParser.KW_ATTRIBUTE: + case MySqlParser.KW_BUCKETS: + case MySqlParser.KW_CONDITION: + case MySqlParser.KW_CURRENT: + case MySqlParser.KW_CURRENT_USER: + case MySqlParser.KW_DATABASE: + case MySqlParser.KW_DEFAULT: + case MySqlParser.KW_DIAGNOSTICS: + case MySqlParser.KW_EMPTY: + case MySqlParser.KW_ENFORCED: + case MySqlParser.KW_EXCEPT: + case MySqlParser.KW_GROUP: + case MySqlParser.KW_IF: + case MySqlParser.KW_INSERT: + case MySqlParser.KW_LATERAL: + case MySqlParser.KW_LEFT: + case MySqlParser.KW_NUMBER: + case MySqlParser.KW_OPTIONAL: + case MySqlParser.KW_ORDER: + case MySqlParser.KW_PRIMARY: + case MySqlParser.KW_REPEAT: + case MySqlParser.KW_REPLACE: + case MySqlParser.KW_RIGHT: + case MySqlParser.KW_SCHEMA: + case MySqlParser.KW_SKIP_QUERY_REWRITE: + case MySqlParser.KW_STACKED: + case MySqlParser.KW_DATE: + case MySqlParser.KW_TIME: + case MySqlParser.KW_TIMESTAMP: + case MySqlParser.KW_DATETIME: + case MySqlParser.KW_YEAR: + case MySqlParser.KW_BINARY: + case MySqlParser.KW_TEXT: + case MySqlParser.KW_ENUM: + case MySqlParser.KW_SERIAL: + case MySqlParser.KW_JSON_TABLE: + case MySqlParser.KW_JSON_VALUE: + case MySqlParser.KW_NESTED: + case MySqlParser.KW_ORDINALITY: + case MySqlParser.KW_PATH: + case MySqlParser.KW_AVG: + case MySqlParser.KW_BIT_AND: + case MySqlParser.KW_BIT_OR: + case MySqlParser.KW_BIT_XOR: + case MySqlParser.KW_COUNT: + case MySqlParser.KW_CUME_DIST: + case MySqlParser.KW_DENSE_RANK: + case MySqlParser.KW_FIRST_VALUE: + case MySqlParser.KW_GROUP_CONCAT: + case MySqlParser.KW_LAG: + case MySqlParser.KW_LAST_VALUE: + case MySqlParser.KW_LEAD: + case MySqlParser.KW_MAX: + case MySqlParser.KW_MIN: + case MySqlParser.KW_NTILE: + case MySqlParser.KW_NTH_VALUE: + case MySqlParser.KW_PERCENT_RANK: + case MySqlParser.KW_RANK: + case MySqlParser.KW_ROW_NUMBER: + case MySqlParser.KW_STD: + case MySqlParser.KW_STDDEV: + case MySqlParser.KW_STDDEV_POP: + case MySqlParser.KW_STDDEV_SAMP: + case MySqlParser.KW_SUM: + case MySqlParser.KW_VAR_POP: + case MySqlParser.KW_VAR_SAMP: + case MySqlParser.KW_VARIANCE: + case MySqlParser.KW_CURRENT_DATE: + case MySqlParser.KW_CURRENT_TIME: + case MySqlParser.KW_CURRENT_TIMESTAMP: + case MySqlParser.KW_LOCALTIME: + case MySqlParser.KW_CURDATE: + case MySqlParser.KW_CURTIME: + case MySqlParser.KW_DATE_ADD: + case MySqlParser.KW_DATE_SUB: + case MySqlParser.KW_LOCALTIMESTAMP: + case MySqlParser.KW_NOW: + case MySqlParser.KW_POSITION: + case MySqlParser.KW_SUBSTR: + case MySqlParser.KW_SUBSTRING: + case MySqlParser.KW_SYSDATE: + case MySqlParser.KW_TRIM: + case MySqlParser.KW_UTC_DATE: + case MySqlParser.KW_UTC_TIME: + case MySqlParser.KW_UTC_TIMESTAMP: + case MySqlParser.KW_ACCOUNT: + case MySqlParser.KW_ACTION: + case MySqlParser.KW_AFTER: + case MySqlParser.KW_AGGREGATE: + case MySqlParser.KW_ALGORITHM: + case MySqlParser.KW_ANY: + case MySqlParser.KW_AT: + case MySqlParser.KW_AUTHORS: + case MySqlParser.KW_AUTOCOMMIT: + case MySqlParser.KW_AUTOEXTEND_SIZE: + case MySqlParser.KW_AUTO_INCREMENT: + case MySqlParser.KW_AVG_ROW_LENGTH: + case MySqlParser.KW_BEGIN: + case MySqlParser.KW_BINLOG: + case MySqlParser.KW_BIT: + case MySqlParser.KW_BLOCK: + case MySqlParser.KW_BOOL: + case MySqlParser.KW_BOOLEAN: + case MySqlParser.KW_BTREE: + case MySqlParser.KW_CACHE: + case MySqlParser.KW_CASCADED: + case MySqlParser.KW_CHAIN: + case MySqlParser.KW_CHANGED: + case MySqlParser.KW_CHANNEL: + case MySqlParser.KW_CHECKSUM: + case MySqlParser.KW_CIPHER: + case MySqlParser.KW_CLASS_ORIGIN: + case MySqlParser.KW_CLIENT: + case MySqlParser.KW_CLOSE: + case MySqlParser.KW_COALESCE: + case MySqlParser.KW_CODE: + case MySqlParser.KW_COLUMNS: + case MySqlParser.KW_COLUMN_FORMAT: + case MySqlParser.KW_COLUMN_NAME: + case MySqlParser.KW_COMMENT: + case MySqlParser.KW_COMMIT: + case MySqlParser.KW_COMPACT: + case MySqlParser.KW_COMPLETION: + case MySqlParser.KW_COMPRESSED: + case MySqlParser.KW_COMPRESSION: + case MySqlParser.KW_CONCURRENT: + case MySqlParser.KW_CONNECT: + case MySqlParser.KW_CONNECTION: + case MySqlParser.KW_CONSISTENT: + case MySqlParser.KW_CONSTRAINT_CATALOG: + case MySqlParser.KW_CONSTRAINT_SCHEMA: + case MySqlParser.KW_CONSTRAINT_NAME: + case MySqlParser.KW_CONTAINS: + case MySqlParser.KW_CONTEXT: + case MySqlParser.KW_CONTRIBUTORS: + case MySqlParser.KW_COPY: + case MySqlParser.KW_CPU: + case MySqlParser.KW_CURSOR_NAME: + case MySqlParser.KW_DATA: + case MySqlParser.KW_DATAFILE: + case MySqlParser.KW_DEALLOCATE: + case MySqlParser.KW_DEFAULT_AUTH: + case MySqlParser.KW_DEFINER: + case MySqlParser.KW_DELAY_KEY_WRITE: + case MySqlParser.KW_DES_KEY_FILE: + case MySqlParser.KW_DIRECTORY: + case MySqlParser.KW_DISABLE: + case MySqlParser.KW_DISCARD: + case MySqlParser.KW_DISK: + case MySqlParser.KW_DO: + case MySqlParser.KW_DUMPFILE: + case MySqlParser.KW_DUPLICATE: + case MySqlParser.KW_DYNAMIC: + case MySqlParser.KW_ENABLE: + case MySqlParser.KW_ENCRYPTION: + case MySqlParser.KW_END: + case MySqlParser.KW_ENDS: + case MySqlParser.KW_ENGINE: + case MySqlParser.KW_ENGINES: + case MySqlParser.KW_ERROR: + case MySqlParser.KW_ERRORS: + case MySqlParser.KW_ESCAPE: + case MySqlParser.KW_EVENT: + case MySqlParser.KW_EVENTS: + case MySqlParser.KW_EVERY: + case MySqlParser.KW_EXCHANGE: + case MySqlParser.KW_EXCLUSIVE: + case MySqlParser.KW_EXPIRE: + case MySqlParser.KW_EXPORT: + case MySqlParser.KW_EXTENDED: + case MySqlParser.KW_EXTENT_SIZE: + case MySqlParser.KW_FAILED_LOGIN_ATTEMPTS: + case MySqlParser.KW_FAST: + case MySqlParser.KW_FAULTS: + case MySqlParser.KW_FIELDS: + case MySqlParser.KW_FILE_BLOCK_SIZE: + case MySqlParser.KW_FILTER: + case MySqlParser.KW_FIRST: + case MySqlParser.KW_FIXED: + case MySqlParser.KW_FLUSH: + case MySqlParser.KW_FOLLOWS: + case MySqlParser.KW_FOUND: + case MySqlParser.KW_FULL: + case MySqlParser.KW_FUNCTION: + case MySqlParser.KW_GENERAL: + case MySqlParser.KW_GLOBAL: + case MySqlParser.KW_GRANTS: + case MySqlParser.KW_GROUP_REPLICATION: + case MySqlParser.KW_HANDLER: + case MySqlParser.KW_HASH: + case MySqlParser.KW_HELP: + case MySqlParser.KW_HISTORY: + case MySqlParser.KW_HOST: + case MySqlParser.KW_HOSTS: + case MySqlParser.KW_IDENTIFIED: + case MySqlParser.KW_IGNORE_SERVER_IDS: + case MySqlParser.KW_IMPORT: + case MySqlParser.KW_INDEXES: + case MySqlParser.KW_INITIAL_SIZE: + case MySqlParser.KW_INPLACE: + case MySqlParser.KW_INSERT_METHOD: + case MySqlParser.KW_INSTALL: + case MySqlParser.KW_INSTANCE: + case MySqlParser.KW_INSTANT: + case MySqlParser.KW_INVISIBLE: + case MySqlParser.KW_INVOKER: + case MySqlParser.KW_IO: + case MySqlParser.KW_IO_THREAD: + case MySqlParser.KW_IPC: + case MySqlParser.KW_ISOLATION: + case MySqlParser.KW_ISSUER: + case MySqlParser.KW_JSON: + case MySqlParser.KW_KEY_BLOCK_SIZE: + case MySqlParser.KW_LANGUAGE: + case MySqlParser.KW_LAST: + case MySqlParser.KW_LEAVES: + case MySqlParser.KW_LESS: + case MySqlParser.KW_LEVEL: + case MySqlParser.KW_LIST: + case MySqlParser.KW_LOCAL: + case MySqlParser.KW_LOGFILE: + case MySqlParser.KW_LOGS: + case MySqlParser.KW_MASTER: + case MySqlParser.KW_MASTER_AUTO_POSITION: + case MySqlParser.KW_MASTER_CONNECT_RETRY: + case MySqlParser.KW_MASTER_DELAY: + case MySqlParser.KW_MASTER_HEARTBEAT_PERIOD: + case MySqlParser.KW_MASTER_HOST: + case MySqlParser.KW_MASTER_LOG_FILE: + case MySqlParser.KW_MASTER_LOG_POS: + case MySqlParser.KW_MASTER_PASSWORD: + case MySqlParser.KW_MASTER_PORT: + case MySqlParser.KW_MASTER_RETRY_COUNT: + case MySqlParser.KW_MASTER_SSL: + case MySqlParser.KW_MASTER_SSL_CA: + case MySqlParser.KW_MASTER_SSL_CAPATH: + case MySqlParser.KW_MASTER_SSL_CERT: + case MySqlParser.KW_MASTER_SSL_CIPHER: + case MySqlParser.KW_MASTER_SSL_CRL: + case MySqlParser.KW_MASTER_SSL_CRLPATH: + case MySqlParser.KW_MASTER_SSL_KEY: + case MySqlParser.KW_MASTER_TLS_VERSION: + case MySqlParser.KW_MASTER_USER: + case MySqlParser.KW_MAX_CONNECTIONS_PER_HOUR: + case MySqlParser.KW_MAX_QUERIES_PER_HOUR: + case MySqlParser.KW_MAX_ROWS: + case MySqlParser.KW_MAX_SIZE: + case MySqlParser.KW_MAX_UPDATES_PER_HOUR: + case MySqlParser.KW_MAX_USER_CONNECTIONS: + case MySqlParser.KW_MEDIUM: + case MySqlParser.KW_MEMBER: + case MySqlParser.KW_MERGE: + case MySqlParser.KW_MESSAGE_TEXT: + case MySqlParser.KW_MID: + case MySqlParser.KW_MIGRATE: + case MySqlParser.KW_MIN_ROWS: + case MySqlParser.KW_MODE: + case MySqlParser.KW_MODIFY: + case MySqlParser.KW_MUTEX: + case MySqlParser.KW_MYSQL: + case MySqlParser.KW_MYSQL_ERRNO: + case MySqlParser.KW_NAME: + case MySqlParser.KW_NAMES: + case MySqlParser.KW_NCHAR: + case MySqlParser.KW_NEVER: + case MySqlParser.KW_NEXT: + case MySqlParser.KW_NO: + case MySqlParser.KW_NOWAIT: + case MySqlParser.KW_NODEGROUP: + case MySqlParser.KW_NONE: + case MySqlParser.KW_ODBC: + case MySqlParser.KW_OFFLINE: + case MySqlParser.KW_OFFSET: + case MySqlParser.KW_OF: + case MySqlParser.KW_OLD_PASSWORD: + case MySqlParser.KW_ONE: + case MySqlParser.KW_ONLINE: + case MySqlParser.KW_ONLY: + case MySqlParser.KW_OPEN: + case MySqlParser.KW_OPTIMIZER_COSTS: + case MySqlParser.KW_OPTIONS: + case MySqlParser.KW_OWNER: + case MySqlParser.KW_PACK_KEYS: + case MySqlParser.KW_PAGE: + case MySqlParser.KW_PAGE_CHECKSUM: + case MySqlParser.KW_PARSER: + case MySqlParser.KW_PARTIAL: + case MySqlParser.KW_PARTITIONING: + case MySqlParser.KW_PARTITIONS: + case MySqlParser.KW_PASSWORD: + case MySqlParser.KW_PASSWORD_LOCK_TIME: + case MySqlParser.KW_PHASE: + case MySqlParser.KW_PLUGIN: + case MySqlParser.KW_PLUGIN_DIR: + case MySqlParser.KW_PLUGINS: + case MySqlParser.KW_PORT: + case MySqlParser.KW_PRECEDES: + case MySqlParser.KW_PREPARE: + case MySqlParser.KW_PRESERVE: + case MySqlParser.KW_PREV: + case MySqlParser.KW_PROCESSLIST: + case MySqlParser.KW_PROFILE: + case MySqlParser.KW_PROFILES: + case MySqlParser.KW_PROXY: + case MySqlParser.KW_QUERY: + case MySqlParser.KW_QUICK: + case MySqlParser.KW_REBUILD: + case MySqlParser.KW_RECOVER: + case MySqlParser.KW_RECURSIVE: + case MySqlParser.KW_REDO_BUFFER_SIZE: + case MySqlParser.KW_REDUNDANT: + case MySqlParser.KW_RELAY: + case MySqlParser.KW_RELAY_LOG_FILE: + case MySqlParser.KW_RELAY_LOG_POS: + case MySqlParser.KW_RELAYLOG: + case MySqlParser.KW_REMOVE: + case MySqlParser.KW_REORGANIZE: + case MySqlParser.KW_REPAIR: + case MySqlParser.KW_REPLICATE_DO_DB: + case MySqlParser.KW_REPLICATE_DO_TABLE: + case MySqlParser.KW_REPLICATE_IGNORE_DB: + case MySqlParser.KW_REPLICATE_IGNORE_TABLE: + case MySqlParser.KW_REPLICATE_REWRITE_DB: + case MySqlParser.KW_REPLICATE_WILD_DO_TABLE: + case MySqlParser.KW_REPLICATE_WILD_IGNORE_TABLE: + case MySqlParser.KW_REPLICATION: + case MySqlParser.KW_RESET: + case MySqlParser.KW_RESUME: + case MySqlParser.KW_RETURNED_SQLSTATE: + case MySqlParser.KW_RETURNS: + case MySqlParser.KW_REUSE: + case MySqlParser.KW_ROLE: + case MySqlParser.KW_ROLLBACK: + case MySqlParser.KW_ROLLUP: + case MySqlParser.KW_ROTATE: + case MySqlParser.KW_ROW: + case MySqlParser.KW_ROWS: + case MySqlParser.KW_ROW_FORMAT: + case MySqlParser.KW_SAVEPOINT: + case MySqlParser.KW_SCHEDULE: + case MySqlParser.KW_SECURITY: + case MySqlParser.KW_SERVER: + case MySqlParser.KW_SESSION: + case MySqlParser.KW_SHARE: + case MySqlParser.KW_SHARED: + case MySqlParser.KW_SIGNED: + case MySqlParser.KW_SIMPLE: + case MySqlParser.KW_SLAVE: + case MySqlParser.KW_SLOW: + case MySqlParser.KW_SNAPSHOT: + case MySqlParser.KW_SOCKET: + case MySqlParser.KW_SOME: + case MySqlParser.KW_SONAME: + case MySqlParser.KW_SOUNDS: + case MySqlParser.KW_SOURCE: + case MySqlParser.KW_SQL_AFTER_GTIDS: + case MySqlParser.KW_SQL_AFTER_MTS_GAPS: + case MySqlParser.KW_SQL_BEFORE_GTIDS: + case MySqlParser.KW_SQL_BUFFER_RESULT: + case MySqlParser.KW_SQL_CACHE: + case MySqlParser.KW_SQL_NO_CACHE: + case MySqlParser.KW_SQL_THREAD: + case MySqlParser.KW_START: + case MySqlParser.KW_STARTS: + case MySqlParser.KW_STATS_AUTO_RECALC: + case MySqlParser.KW_STATS_PERSISTENT: + case MySqlParser.KW_STATS_SAMPLE_PAGES: + case MySqlParser.KW_STATUS: + case MySqlParser.KW_STOP: + case MySqlParser.KW_STORAGE: + case MySqlParser.KW_STRING: + case MySqlParser.KW_SUBCLASS_ORIGIN: + case MySqlParser.KW_SUBJECT: + case MySqlParser.KW_SUBPARTITION: + case MySqlParser.KW_SUBPARTITIONS: + case MySqlParser.KW_SUSPEND: + case MySqlParser.KW_SWAPS: + case MySqlParser.KW_SWITCHES: + case MySqlParser.KW_TABLE_NAME: + case MySqlParser.KW_TABLESPACE: + case MySqlParser.KW_TABLE_TYPE: + case MySqlParser.KW_TEMPORARY: + case MySqlParser.KW_TEMPTABLE: + case MySqlParser.KW_THAN: + case MySqlParser.KW_TRADITIONAL: + case MySqlParser.KW_TRANSACTION: + case MySqlParser.KW_TRANSACTIONAL: + case MySqlParser.KW_TRIGGERS: + case MySqlParser.KW_TRUNCATE: + case MySqlParser.KW_UNBOUNDED: + case MySqlParser.KW_UNDEFINED: + case MySqlParser.KW_UNDOFILE: + case MySqlParser.KW_UNDO_BUFFER_SIZE: + case MySqlParser.KW_UNINSTALL: + case MySqlParser.KW_UNKNOWN: + case MySqlParser.KW_UNTIL: + case MySqlParser.KW_UPGRADE: + case MySqlParser.KW_USER: + case MySqlParser.KW_USE_FRM: + case MySqlParser.KW_USER_RESOURCES: + case MySqlParser.KW_VALIDATION: + case MySqlParser.KW_VALUE: + case MySqlParser.KW_VARIABLES: + case MySqlParser.KW_VIEW: + case MySqlParser.KW_VIRTUAL: + case MySqlParser.KW_VISIBLE: + case MySqlParser.KW_WAIT: + case MySqlParser.KW_WARNINGS: + case MySqlParser.KW_WITHOUT: + case MySqlParser.KW_WORK: + case MySqlParser.KW_WRAPPER: + case MySqlParser.KW_X509: + case MySqlParser.KW_XA: + case MySqlParser.KW_XML: + case MySqlParser.KW_QUARTER: + case MySqlParser.KW_MONTH: + case MySqlParser.KW_DAY: + case MySqlParser.KW_HOUR: + case MySqlParser.KW_MINUTE: + case MySqlParser.KW_WEEK: + case MySqlParser.KW_SECOND: + case MySqlParser.KW_MICROSECOND: + case MySqlParser.KW_ADMIN: + case MySqlParser.KW_AUDIT_ABORT_EXEMPT: + case MySqlParser.KW_AUDIT_ADMIN: + case MySqlParser.KW_AUTHENTICATION_POLICY_ADMIN: + case MySqlParser.KW_BACKUP_ADMIN: + case MySqlParser.KW_BINLOG_ADMIN: + case MySqlParser.KW_BINLOG_ENCRYPTION_ADMIN: + case MySqlParser.KW_CLONE_ADMIN: + case MySqlParser.KW_CONNECTION_ADMIN: + case MySqlParser.KW_ENCRYPTION_KEY_ADMIN: + case MySqlParser.KW_EXECUTE: + case MySqlParser.KW_FILE: + case MySqlParser.KW_FIREWALL_ADMIN: + case MySqlParser.KW_FIREWALL_EXEMPT: + case MySqlParser.KW_FIREWALL_USER: + case MySqlParser.KW_GROUP_REPLICATION_ADMIN: + case MySqlParser.KW_INNODB_REDO_LOG_ARCHIVE: + case MySqlParser.KW_INVOKE: + case MySqlParser.KW_LAMBDA: + case MySqlParser.KW_NDB_STORED_USER: + case MySqlParser.KW_PASSWORDLESS_USER_ADMIN: + case MySqlParser.KW_PERSIST_RO_VARIABLES_ADMIN: + case MySqlParser.KW_PRIVILEGES: + case MySqlParser.KW_PROCESS: + case MySqlParser.KW_RELOAD: + case MySqlParser.KW_REPLICATION_APPLIER: + case MySqlParser.KW_REPLICATION_SLAVE_ADMIN: + case MySqlParser.KW_RESOURCE_GROUP_ADMIN: + case MySqlParser.KW_RESOURCE_GROUP_USER: + case MySqlParser.KW_ROLE_ADMIN: + case MySqlParser.KW_ROUTINE: + case MySqlParser.KW_S3: + case MySqlParser.KW_SESSION_VARIABLES_ADMIN: + case MySqlParser.KW_SET_USER_ID: + case MySqlParser.KW_SHOW_ROUTINE: + case MySqlParser.KW_SHUTDOWN: + case MySqlParser.KW_SUPER: + case MySqlParser.KW_SYSTEM_VARIABLES_ADMIN: + case MySqlParser.KW_TABLES: + case MySqlParser.KW_TABLE_ENCRYPTION_ADMIN: + case MySqlParser.KW_VERSION_TOKEN_ADMIN: + case MySqlParser.KW_XA_RECOVER_ADMIN: + case MySqlParser.KW_ARMSCII8: + case MySqlParser.KW_ASCII: + case MySqlParser.KW_BIG5: + case MySqlParser.KW_CP1250: + case MySqlParser.KW_CP1251: + case MySqlParser.KW_CP1256: + case MySqlParser.KW_CP1257: + case MySqlParser.KW_CP850: + case MySqlParser.KW_CP852: + case MySqlParser.KW_CP866: + case MySqlParser.KW_CP932: + case MySqlParser.KW_DEC8: + case MySqlParser.KW_EUCJPMS: + case MySqlParser.KW_EUCKR: + case MySqlParser.KW_GB18030: + case MySqlParser.KW_GB2312: + case MySqlParser.KW_GBK: + case MySqlParser.KW_GEOSTD8: + case MySqlParser.KW_GREEK: + case MySqlParser.KW_HEBREW: + case MySqlParser.KW_HP8: + case MySqlParser.KW_KEYBCS2: + case MySqlParser.KW_KOI8R: + case MySqlParser.KW_KOI8U: + case MySqlParser.KW_LATIN1: + case MySqlParser.KW_LATIN2: + case MySqlParser.KW_LATIN5: + case MySqlParser.KW_LATIN7: + case MySqlParser.KW_MACCE: + case MySqlParser.KW_MACROMAN: + case MySqlParser.KW_SJIS: + case MySqlParser.KW_SWE7: + case MySqlParser.KW_TIS620: + case MySqlParser.KW_UCS2: + case MySqlParser.KW_UJIS: + case MySqlParser.KW_UTF16: + case MySqlParser.KW_UTF16LE: + case MySqlParser.KW_UTF32: + case MySqlParser.KW_UTF8: + case MySqlParser.KW_UTF8MB3: + case MySqlParser.KW_UTF8MB4: + case MySqlParser.KW_ARCHIVE: + case MySqlParser.KW_BLACKHOLE: + case MySqlParser.KW_CSV: + case MySqlParser.KW_FEDERATED: + case MySqlParser.KW_INNODB: + case MySqlParser.KW_MEMORY: + case MySqlParser.KW_MRG_MYISAM: + case MySqlParser.KW_MYISAM: + case MySqlParser.KW_NDB: + case MySqlParser.KW_NDBCLUSTER: + case MySqlParser.KW_PERFORMANCE_SCHEMA: + case MySqlParser.KW_TOKUDB: + case MySqlParser.KW_REPEATABLE: + case MySqlParser.KW_COMMITTED: + case MySqlParser.KW_UNCOMMITTED: + case MySqlParser.KW_SERIALIZABLE: + case MySqlParser.KW_GEOMETRYCOLLECTION: + case MySqlParser.KW_LINESTRING: + case MySqlParser.KW_MULTILINESTRING: + case MySqlParser.KW_MULTIPOINT: + case MySqlParser.KW_MULTIPOLYGON: + case MySqlParser.KW_POINT: + case MySqlParser.KW_POLYGON: + case MySqlParser.KW_CATALOG_NAME: + case MySqlParser.KW_CHARSET: + case MySqlParser.KW_COLLATION: + case MySqlParser.KW_ENGINE_ATTRIBUTE: + case MySqlParser.KW_FORMAT: + case MySqlParser.KW_GET_FORMAT: + case MySqlParser.KW_RANDOM: + case MySqlParser.KW_REVERSE: + case MySqlParser.KW_ROW_COUNT: + case MySqlParser.KW_SCHEMA_NAME: + case MySqlParser.KW_SECONDARY_ENGINE_ATTRIBUTE: + case MySqlParser.KW_SRID: + case MySqlParser.KW_SYSTEM_USER: + case MySqlParser.KW_TP_CONNECTION_ADMIN: + case MySqlParser.KW_WEIGHT_STRING: + case MySqlParser.MOD: + case MySqlParser.ID: + this.enterOuterAlt(localContext, 3); + { + this.state = 4346; + this.simpleId(); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + startTransaction() { + let localContext = new StartTransactionContext(this.context, this.state); + this.enterRule(localContext, 316, MySqlParser.RULE_startTransaction); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 4349; + this.match(MySqlParser.KW_START); + this.state = 4350; + this.match(MySqlParser.KW_TRANSACTION); + this.state = 4359; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 621, this.context)) { + case 1: + { + this.state = 4351; + this.transactionMode(); + this.state = 4356; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 4352; + this.match(MySqlParser.COMMA); + this.state = 4353; + this.transactionMode(); + } + } + this.state = 4358; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + break; + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + beginWork() { + let localContext = new BeginWorkContext(this.context, this.state); + this.enterRule(localContext, 318, MySqlParser.RULE_beginWork); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 4361; + this.match(MySqlParser.KW_BEGIN); + this.state = 4363; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 691) { + { + this.state = 4362; + this.match(MySqlParser.KW_WORK); + } + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + commitWork() { + let localContext = new CommitWorkContext(this.context, this.state); + this.enterRule(localContext, 320, MySqlParser.RULE_commitWork); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 4365; + this.match(MySqlParser.KW_COMMIT); + this.state = 4367; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 691) { + { + this.state = 4366; + this.match(MySqlParser.KW_WORK); + } + } + this.state = 4374; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 11) { + { + this.state = 4369; + this.match(MySqlParser.KW_AND); + this.state = 4371; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 502) { + { + this.state = 4370; + localContext._nochain = this.match(MySqlParser.KW_NO); + } + } + this.state = 4373; + this.match(MySqlParser.KW_CHAIN); + } + } + this.state = 4380; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 627, this.context)) { + case 1: + { + this.state = 4377; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 502) { + { + this.state = 4376; + localContext._norelease = this.match(MySqlParser.KW_NO); + } + } + this.state = 4379; + this.match(MySqlParser.KW_RELEASE); + } + break; + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + rollbackWork() { + let localContext = new RollbackWorkContext(this.context, this.state); + this.enterRule(localContext, 322, MySqlParser.RULE_rollbackWork); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 4382; + this.match(MySqlParser.KW_ROLLBACK); + this.state = 4384; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 691) { + { + this.state = 4383; + this.match(MySqlParser.KW_WORK); + } + } + this.state = 4391; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 11) { + { + this.state = 4386; + this.match(MySqlParser.KW_AND); + this.state = 4388; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 502) { + { + this.state = 4387; + localContext._nochain = this.match(MySqlParser.KW_NO); + } + } + this.state = 4390; + this.match(MySqlParser.KW_CHAIN); + } + } + this.state = 4397; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 632, this.context)) { + case 1: + { + this.state = 4394; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 502) { + { + this.state = 4393; + localContext._norelease = this.match(MySqlParser.KW_NO); + } + } + this.state = 4396; + this.match(MySqlParser.KW_RELEASE); + } + break; + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + savepointStatement() { + let localContext = new SavepointStatementContext(this.context, this.state); + this.enterRule(localContext, 324, MySqlParser.RULE_savepointStatement); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 4399; + this.match(MySqlParser.KW_SAVEPOINT); + this.state = 4400; + localContext._identifier = this.uid(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + rollbackStatement() { + let localContext = new RollbackStatementContext(this.context, this.state); + this.enterRule(localContext, 326, MySqlParser.RULE_rollbackStatement); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 4402; + this.match(MySqlParser.KW_ROLLBACK); + this.state = 4404; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 691) { + { + this.state = 4403; + this.match(MySqlParser.KW_WORK); + } + } + this.state = 4406; + this.match(MySqlParser.KW_TO); + this.state = 4408; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 634, this.context)) { + case 1: + { + this.state = 4407; + this.match(MySqlParser.KW_SAVEPOINT); + } + break; + } + this.state = 4410; + localContext._identifier = this.uid(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + releaseStatement() { + let localContext = new ReleaseStatementContext(this.context, this.state); + this.enterRule(localContext, 328, MySqlParser.RULE_releaseStatement); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 4412; + this.match(MySqlParser.KW_RELEASE); + this.state = 4413; + this.match(MySqlParser.KW_SAVEPOINT); + this.state = 4414; + localContext._identifier = this.uid(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + lockTables() { + let localContext = new LockTablesContext(this.context, this.state); + this.enterRule(localContext, 330, MySqlParser.RULE_lockTables); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 4416; + this.match(MySqlParser.KW_LOCK); + this.state = 4417; + _la = this.tokenStream.LA(1); + if (!(_la === 173 || _la === 752)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 4418; + this.lockTableElement(); + this.state = 4423; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 4419; + this.match(MySqlParser.COMMA); + this.state = 4420; + this.lockTableElement(); + } + } + this.state = 4425; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + unlockTables() { + let localContext = new UnlockTablesContext(this.context, this.state); + this.enterRule(localContext, 332, MySqlParser.RULE_unlockTables); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 4426; + this.match(MySqlParser.KW_UNLOCK); + this.state = 4427; + this.match(MySqlParser.KW_TABLES); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + setAutocommitStatement() { + let localContext = new SetAutocommitStatementContext(this.context, this.state); + this.enterRule(localContext, 334, MySqlParser.RULE_setAutocommitStatement); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 4429; + this.match(MySqlParser.KW_SET); + this.state = 4430; + this.match(MySqlParser.KW_AUTOCOMMIT); + this.state = 4431; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 4432; + localContext._autocommitValue = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 871 || _la === 872)) { + localContext._autocommitValue = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + setTransactionStatement() { + let localContext = new SetTransactionStatementContext(this.context, this.state); + this.enterRule(localContext, 336, MySqlParser.RULE_setTransactionStatement); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 4434; + this.match(MySqlParser.KW_SET); + this.state = 4436; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 413 || _la === 593) { + { + this.state = 4435; + localContext._transactionContext = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 413 || _la === 593)) { + localContext._transactionContext = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + this.state = 4438; + this.match(MySqlParser.KW_TRANSACTION); + this.state = 4439; + this.transactionOption(); + this.state = 4444; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 4440; + this.match(MySqlParser.COMMA); + this.state = 4441; + this.transactionOption(); + } + } + this.state = 4446; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + transactionMode() { + let localContext = new TransactionModeContext(this.context, this.state); + this.enterRule(localContext, 338, MySqlParser.RULE_transactionMode); + try { + this.state = 4454; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 638, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 4447; + this.match(MySqlParser.KW_WITH); + this.state = 4448; + this.match(MySqlParser.KW_CONSISTENT); + this.state = 4449; + this.match(MySqlParser.KW_SNAPSHOT); + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 4450; + this.match(MySqlParser.KW_READ); + this.state = 4451; + this.match(MySqlParser.KW_WRITE); + } + break; + case 3: + this.enterOuterAlt(localContext, 3); + { + this.state = 4452; + this.match(MySqlParser.KW_READ); + this.state = 4453; + this.match(MySqlParser.KW_ONLY); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + lockTableElement() { + let localContext = new LockTableElementContext(this.context, this.state); + this.enterRule(localContext, 340, MySqlParser.RULE_lockTableElement); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 4456; + this.tableName(); + this.state = 4461; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if ((((_la) & ~0x1F) === 0 && ((1 << _la) & 1074311168) !== 0) || ((((_la - 36)) & ~0x1F) === 0 && ((1 << (_la - 36)) & 11014219) !== 0) || ((((_la - 74)) & ~0x1F) === 0 && ((1 << (_la - 74)) & 18878481) !== 0) || ((((_la - 117)) & ~0x1F) === 0 && ((1 << (_la - 117)) & 100679969) !== 0) || ((((_la - 150)) & ~0x1F) === 0 && ((1 << (_la - 150)) & 1049605) !== 0) || ((((_la - 219)) & ~0x1F) === 0 && ((1 << (_la - 219)) & 5374495) !== 0) || ((((_la - 253)) & ~0x1F) === 0 && ((1 << (_la - 253)) & 4294967295) !== 0) || ((((_la - 285)) & ~0x1F) === 0 && ((1 << (_la - 285)) & 4261412607) !== 0) || ((((_la - 317)) & ~0x1F) === 0 && ((1 << (_la - 317)) & 4160741375) !== 0) || ((((_la - 349)) & ~0x1F) === 0 && ((1 << (_la - 349)) & 4026531839) !== 0) || ((((_la - 381)) & ~0x1F) === 0 && ((1 << (_la - 381)) & 1055907839) !== 0) || ((((_la - 413)) & ~0x1F) === 0 && ((1 << (_la - 413)) & 4294885367) !== 0) || ((((_la - 445)) & ~0x1F) === 0 && ((1 << (_la - 445)) & 3757571071) !== 0) || ((((_la - 478)) & ~0x1F) === 0 && ((1 << (_la - 478)) & 3755999231) !== 0) || ((((_la - 510)) & ~0x1F) === 0 && ((1 << (_la - 510)) & 3751780349) !== 0) || ((((_la - 542)) & ~0x1F) === 0 && ((1 << (_la - 542)) & 2141183997) !== 0) || ((((_la - 575)) & ~0x1F) === 0 && ((1 << (_la - 575)) & 2147483629) !== 0) || ((((_la - 633)) & ~0x1F) === 0 && ((1 << (_la - 633)) & 4294934527) !== 0) || ((((_la - 665)) & ~0x1F) === 0 && ((1 << (_la - 665)) & 4278189053) !== 0) || ((((_la - 697)) & ~0x1F) === 0 && ((1 << (_la - 697)) & 1644099327) !== 0) || ((((_la - 729)) & ~0x1F) === 0 && ((1 << (_la - 729)) & 4294900735) !== 0) || ((((_la - 761)) & ~0x1F) === 0 && ((1 << (_la - 761)) & 4294967295) !== 0) || ((((_la - 793)) & ~0x1F) === 0 && ((1 << (_la - 793)) & 4288675839) !== 0) || ((((_la - 825)) & ~0x1F) === 0 && ((1 << (_la - 825)) & 2147527671) !== 0) || ((((_la - 879)) & ~0x1F) === 0 && ((1 << (_la - 879)) & 1033) !== 0)) { + { + this.state = 4458; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 13) { + { + this.state = 4457; + this.match(MySqlParser.KW_AS); + } + } + this.state = 4460; + localContext._alias = this.uid(); + } + } + this.state = 4463; + this.lockAction(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + lockAction() { + let localContext = new LockActionContext(this.context, this.state); + this.enterRule(localContext, 342, MySqlParser.RULE_lockAction); + let _la; + try { + this.state = 4473; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_READ: + this.enterOuterAlt(localContext, 1); + { + this.state = 4465; + this.match(MySqlParser.KW_READ); + this.state = 4467; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 450) { + { + this.state = 4466; + this.match(MySqlParser.KW_LOCAL); + } + } + } + break; + case MySqlParser.KW_LOW_PRIORITY: + case MySqlParser.KW_WRITE: + this.enterOuterAlt(localContext, 2); + { + this.state = 4470; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 107) { + { + this.state = 4469; + this.match(MySqlParser.KW_LOW_PRIORITY); + } + } + this.state = 4472; + this.match(MySqlParser.KW_WRITE); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + transactionOption() { + let localContext = new TransactionOptionContext(this.context, this.state); + this.enterRule(localContext, 344, MySqlParser.RULE_transactionOption); + try { + this.state = 4482; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 644, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 4475; + this.match(MySqlParser.KW_ISOLATION); + this.state = 4476; + this.match(MySqlParser.KW_LEVEL); + this.state = 4477; + this.transactionLevel(); + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 4478; + this.match(MySqlParser.KW_READ); + this.state = 4479; + this.match(MySqlParser.KW_WRITE); + } + break; + case 3: + this.enterOuterAlt(localContext, 3); + { + this.state = 4480; + this.match(MySqlParser.KW_READ); + this.state = 4481; + this.match(MySqlParser.KW_ONLY); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + transactionLevel() { + let localContext = new TransactionLevelContext(this.context, this.state); + this.enterRule(localContext, 346, MySqlParser.RULE_transactionLevel); + try { + this.state = 4491; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 645, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 4484; + this.match(MySqlParser.KW_REPEATABLE); + this.state = 4485; + this.match(MySqlParser.KW_READ); + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 4486; + this.match(MySqlParser.KW_READ); + this.state = 4487; + this.match(MySqlParser.KW_COMMITTED); + } + break; + case 3: + this.enterOuterAlt(localContext, 3); + { + this.state = 4488; + this.match(MySqlParser.KW_READ); + this.state = 4489; + this.match(MySqlParser.KW_UNCOMMITTED); + } + break; + case 4: + this.enterOuterAlt(localContext, 4); + { + this.state = 4490; + this.match(MySqlParser.KW_SERIALIZABLE); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + changeMaster() { + let localContext = new ChangeMasterContext(this.context, this.state); + this.enterRule(localContext, 348, MySqlParser.RULE_changeMaster); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 4493; + this.match(MySqlParser.KW_CHANGE); + this.state = 4494; + this.match(MySqlParser.KW_MASTER); + this.state = 4495; + this.match(MySqlParser.KW_TO); + this.state = 4496; + this.masterOption(); + this.state = 4501; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 4497; + this.match(MySqlParser.COMMA); + this.state = 4498; + this.masterOption(); + } + } + this.state = 4503; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 4505; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 65) { + { + this.state = 4504; + this.channelOption(); + } + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + changeReplicationFilter() { + let localContext = new ChangeReplicationFilterContext(this.context, this.state); + this.enterRule(localContext, 350, MySqlParser.RULE_changeReplicationFilter); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 4507; + this.match(MySqlParser.KW_CHANGE); + this.state = 4508; + this.match(MySqlParser.KW_REPLICATION); + this.state = 4509; + this.match(MySqlParser.KW_FILTER); + this.state = 4510; + this.replicationFilter(); + this.state = 4515; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 4511; + this.match(MySqlParser.COMMA); + this.state = 4512; + this.replicationFilter(); + } + } + this.state = 4517; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 4519; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 65) { + { + this.state = 4518; + this.channelOption(); + } + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + changeReplicationSource() { + let localContext = new ChangeReplicationSourceContext(this.context, this.state); + this.enterRule(localContext, 352, MySqlParser.RULE_changeReplicationSource); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 4521; + this.match(MySqlParser.KW_CHANGE); + this.state = 4522; + this.match(MySqlParser.KW_REPLICATION); + this.state = 4523; + this.match(MySqlParser.KW_SOURCE); + this.state = 4524; + this.match(MySqlParser.KW_TO); + this.state = 4525; + this.replicationSourceOption(); + this.state = 4530; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 4526; + this.match(MySqlParser.COMMA); + this.state = 4527; + this.replicationSourceOption(); + } + } + this.state = 4532; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 4534; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 65) { + { + this.state = 4533; + this.channelOption(); + } + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + purgeBinaryLogs() { + let localContext = new PurgeBinaryLogsContext(this.context, this.state); + this.enterRule(localContext, 354, MySqlParser.RULE_purgeBinaryLogs); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 4536; + this.match(MySqlParser.KW_PURGE); + this.state = 4537; + localContext._purgeFormat = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 228 || _la === 453)) { + localContext._purgeFormat = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 4538; + this.match(MySqlParser.KW_LOGS); + this.state = 4543; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_TO: + { + this.state = 4539; + this.match(MySqlParser.KW_TO); + this.state = 4540; + localContext._fileName = this.match(MySqlParser.STRING_LITERAL); + } + break; + case MySqlParser.KW_BEFORE: + { + this.state = 4541; + this.match(MySqlParser.KW_BEFORE); + this.state = 4542; + localContext._timeValue = this.match(MySqlParser.STRING_LITERAL); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + startSlaveOrReplica() { + let localContext = new StartSlaveOrReplicaContext(this.context, this.state); + this.enterRule(localContext, 356, MySqlParser.RULE_startSlaveOrReplica); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 4545; + this.match(MySqlParser.KW_START); + this.state = 4546; + _la = this.tokenStream.LA(1); + if (!(_la === 563 || _la === 598)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 4555; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 438 || _la === 639) { + { + this.state = 4547; + this.threadType(); + this.state = 4552; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 4548; + this.match(MySqlParser.COMMA); + this.state = 4549; + this.threadType(); + } + } + this.state = 4554; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + } + this.state = 4559; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 676) { + { + this.state = 4557; + this.match(MySqlParser.KW_UNTIL); + this.state = 4558; + this.untilOption(); + } + } + this.state = 4564; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 363 || _la === 529 || _la === 535 || _la === 678) { + { + { + this.state = 4561; + this.connectionOptions(); + } + } + this.state = 4566; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 4568; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 65) { + { + this.state = 4567; + this.channelOption(); + } + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + stopSlaveOrReplica() { + let localContext = new StopSlaveOrReplicaContext(this.context, this.state); + this.enterRule(localContext, 358, MySqlParser.RULE_stopSlaveOrReplica); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 4570; + this.match(MySqlParser.KW_STOP); + this.state = 4571; + _la = this.tokenStream.LA(1); + if (!(_la === 563 || _la === 598)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 4580; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 438 || _la === 639) { + { + this.state = 4572; + this.threadType(); + this.state = 4577; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 4573; + this.match(MySqlParser.COMMA); + this.state = 4574; + this.threadType(); + } + } + this.state = 4579; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + } + this.state = 4583; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 65) { + { + this.state = 4582; + this.channelOption(); + } + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + startGroupReplication() { + let localContext = new StartGroupReplicationContext(this.context, this.state); + this.enterRule(localContext, 360, MySqlParser.RULE_startGroupReplication); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 4585; + this.match(MySqlParser.KW_START); + this.state = 4586; + this.match(MySqlParser.KW_GROUP_REPLICATION); + this.state = 4590; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 678) { + { + this.state = 4587; + this.match(MySqlParser.KW_USER); + this.state = 4588; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 4589; + this.match(MySqlParser.STRING_LITERAL); + } + } + this.state = 4596; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 662, this.context)) { + case 1: + { + this.state = 4592; + this.match(MySqlParser.COMMA); + this.state = 4593; + this.match(MySqlParser.KW_PASSWORD); + this.state = 4594; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 4595; + this.match(MySqlParser.STRING_LITERAL); + } + break; + } + this.state = 4602; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 868) { + { + this.state = 4598; + this.match(MySqlParser.COMMA); + this.state = 4599; + this.match(MySqlParser.KW_DEFAULT_AUTH); + this.state = 4600; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 4601; + this.match(MySqlParser.STRING_LITERAL); + } + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + stopGroupReplication() { + let localContext = new StopGroupReplicationContext(this.context, this.state); + this.enterRule(localContext, 362, MySqlParser.RULE_stopGroupReplication); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 4604; + this.match(MySqlParser.KW_STOP); + this.state = 4605; + this.match(MySqlParser.KW_GROUP_REPLICATION); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + masterOption() { + let localContext = new MasterOptionContext(this.context, this.state); + this.enterRule(localContext, 364, MySqlParser.RULE_masterOption); + let _la; + try { + this.state = 4634; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_MASTER_BIND: + case MySqlParser.KW_MASTER_COMPRESSION_ALGORITHMS: + case MySqlParser.KW_MASTER_HOST: + case MySqlParser.KW_MASTER_LOG_FILE: + case MySqlParser.KW_MASTER_PASSWORD: + case MySqlParser.KW_MASTER_PUBLIC_KEY_PATH: + case MySqlParser.KW_MASTER_SSL_CA: + case MySqlParser.KW_MASTER_SSL_CAPATH: + case MySqlParser.KW_MASTER_SSL_CERT: + case MySqlParser.KW_MASTER_SSL_CIPHER: + case MySqlParser.KW_MASTER_SSL_CRL: + case MySqlParser.KW_MASTER_SSL_CRLPATH: + case MySqlParser.KW_MASTER_SSL_KEY: + case MySqlParser.KW_MASTER_TLS_CIPHERSUITES: + case MySqlParser.KW_MASTER_TLS_VERSION: + case MySqlParser.KW_MASTER_USER: + case MySqlParser.KW_NETWORK_NAMESPACE: + case MySqlParser.KW_RELAY_LOG_FILE: + localContext = new MasterStringOptionContext(localContext); + this.enterOuterAlt(localContext, 1); + { + this.state = 4607; + this.stringMasterOption(); + this.state = 4608; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 4609; + this.match(MySqlParser.STRING_LITERAL); + } + break; + case MySqlParser.KW_MASTER_CONNECT_RETRY: + case MySqlParser.KW_MASTER_DELAY: + case MySqlParser.KW_MASTER_HEARTBEAT_PERIOD: + case MySqlParser.KW_MASTER_LOG_POS: + case MySqlParser.KW_MASTER_PORT: + case MySqlParser.KW_MASTER_RETRY_COUNT: + case MySqlParser.KW_MASTER_ZSTD_COMPRESSION_LEVEL: + case MySqlParser.KW_RELAY_LOG_POS: + localContext = new MasterDecimalOptionContext(localContext); + this.enterOuterAlt(localContext, 2); + { + this.state = 4611; + this.decimalMasterOption(); + this.state = 4612; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 4613; + this.decimalLiteral(); + } + break; + case MySqlParser.KW_MASTER_SSL_VERIFY_SERVER_CERT: + case MySqlParser.KW_GET_MASTER_PUBLIC_KEY: + case MySqlParser.KW_GTID_ONLY: + case MySqlParser.KW_MASTER_AUTO_POSITION: + case MySqlParser.KW_MASTER_SSL: + case MySqlParser.KW_REQUIRE_ROW_FORMAT: + case MySqlParser.KW_SOURCE_CONNECTION_AUTO_FAILOVER: + localContext = new MasterBoolOptionContext(localContext); + this.enterOuterAlt(localContext, 3); + { + this.state = 4615; + this.boolMasterOption(); + this.state = 4616; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 4617; + localContext._boolVal = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 871 || _la === 872)) { + localContext._boolVal = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + break; + case MySqlParser.KW_ASSIGN_GTIDS_TO_ANONYMOUS_TRANSACTIONS: + case MySqlParser.KW_PRIVILEGE_CHECKS_USER: + case MySqlParser.KW_REQUIRE_TABLE_PRIMARY_KEY_CHECK: + localContext = new V8AddMasterOptionContext(localContext); + this.enterOuterAlt(localContext, 4); + { + this.state = 4619; + this.v8NewMasterOption(); + } + break; + case MySqlParser.KW_IGNORE_SERVER_IDS: + localContext = new MasterUidListOptionContext(localContext); + this.enterOuterAlt(localContext, 5); + { + this.state = 4620; + this.match(MySqlParser.KW_IGNORE_SERVER_IDS); + this.state = 4621; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 4622; + this.match(MySqlParser.LR_BRACKET); + this.state = 4631; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if ((((_la) & ~0x1F) === 0 && ((1 << _la) & 1074302976) !== 0) || ((((_la - 36)) & ~0x1F) === 0 && ((1 << (_la - 36)) & 11014219) !== 0) || ((((_la - 74)) & ~0x1F) === 0 && ((1 << (_la - 74)) & 18878481) !== 0) || ((((_la - 117)) & ~0x1F) === 0 && ((1 << (_la - 117)) & 100679969) !== 0) || ((((_la - 150)) & ~0x1F) === 0 && ((1 << (_la - 150)) & 1049605) !== 0) || ((((_la - 219)) & ~0x1F) === 0 && ((1 << (_la - 219)) & 5374495) !== 0) || ((((_la - 253)) & ~0x1F) === 0 && ((1 << (_la - 253)) & 4294967295) !== 0) || ((((_la - 285)) & ~0x1F) === 0 && ((1 << (_la - 285)) & 4261412607) !== 0) || ((((_la - 317)) & ~0x1F) === 0 && ((1 << (_la - 317)) & 4160741375) !== 0) || ((((_la - 349)) & ~0x1F) === 0 && ((1 << (_la - 349)) & 4026531839) !== 0) || ((((_la - 381)) & ~0x1F) === 0 && ((1 << (_la - 381)) & 1055907839) !== 0) || ((((_la - 413)) & ~0x1F) === 0 && ((1 << (_la - 413)) & 4294885367) !== 0) || ((((_la - 445)) & ~0x1F) === 0 && ((1 << (_la - 445)) & 3757571071) !== 0) || ((((_la - 478)) & ~0x1F) === 0 && ((1 << (_la - 478)) & 3755999231) !== 0) || ((((_la - 510)) & ~0x1F) === 0 && ((1 << (_la - 510)) & 3751780349) !== 0) || ((((_la - 542)) & ~0x1F) === 0 && ((1 << (_la - 542)) & 2141183997) !== 0) || ((((_la - 575)) & ~0x1F) === 0 && ((1 << (_la - 575)) & 2147483629) !== 0) || ((((_la - 633)) & ~0x1F) === 0 && ((1 << (_la - 633)) & 4294934527) !== 0) || ((((_la - 665)) & ~0x1F) === 0 && ((1 << (_la - 665)) & 4278189053) !== 0) || ((((_la - 697)) & ~0x1F) === 0 && ((1 << (_la - 697)) & 1644099327) !== 0) || ((((_la - 729)) & ~0x1F) === 0 && ((1 << (_la - 729)) & 4294900735) !== 0) || ((((_la - 761)) & ~0x1F) === 0 && ((1 << (_la - 761)) & 4294967295) !== 0) || ((((_la - 793)) & ~0x1F) === 0 && ((1 << (_la - 793)) & 4288675839) !== 0) || ((((_la - 825)) & ~0x1F) === 0 && ((1 << (_la - 825)) & 2147527671) !== 0) || ((((_la - 879)) & ~0x1F) === 0 && ((1 << (_la - 879)) & 1033) !== 0)) { + { + this.state = 4623; + localContext._server_id = this.uid(); + this.state = 4628; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 4624; + this.match(MySqlParser.COMMA); + this.state = 4625; + localContext._server_id = this.uid(); + } + } + this.state = 4630; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + } + this.state = 4633; + this.match(MySqlParser.RR_BRACKET); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + stringMasterOption() { + let localContext = new StringMasterOptionContext(this.context, this.state); + this.enterRule(localContext, 366, MySqlParser.RULE_stringMasterOption); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 4636; + _la = this.tokenStream.LA(1); + if (!(_la === 108 || ((((_la - 455)) & ~0x1F) === 0 && ((1 << (_la - 455)) & 4190897) !== 0) || _la === 499 || _la === 557)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + decimalMasterOption() { + let localContext = new DecimalMasterOptionContext(this.context, this.state); + this.enterRule(localContext, 368, MySqlParser.RULE_decimalMasterOption); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 4638; + _la = this.tokenStream.LA(1); + if (!(((((_la - 456)) & ~0x1F) === 0 && ((1 << (_la - 456)) & 2097831) !== 0) || _la === 558)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + boolMasterOption() { + let localContext = new BoolMasterOptionContext(this.context, this.state); + this.enterRule(localContext, 370, MySqlParser.RULE_boolMasterOption); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 4640; + _la = this.tokenStream.LA(1); + if (!(_la === 109 || _la === 411 || _la === 416 || _la === 454 || _la === 466 || _la === 573 || _la === 617)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + v8NewMasterOption() { + let localContext = new V8NewMasterOptionContext(this.context, this.state); + this.enterRule(localContext, 372, MySqlParser.RULE_v8NewMasterOption); + let _la; + try { + this.state = 4655; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_PRIVILEGE_CHECKS_USER: + this.enterOuterAlt(localContext, 1); + { + this.state = 4642; + this.match(MySqlParser.KW_PRIVILEGE_CHECKS_USER); + this.state = 4643; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 4644; + _la = this.tokenStream.LA(1); + if (!(_la === 116 || _la === 882)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + break; + case MySqlParser.KW_REQUIRE_TABLE_PRIMARY_KEY_CHECK: + this.enterOuterAlt(localContext, 2); + { + this.state = 4645; + this.match(MySqlParser.KW_REQUIRE_TABLE_PRIMARY_KEY_CHECK); + this.state = 4646; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 4647; + _la = this.tokenStream.LA(1); + if (!(_la === 118 || _la === 119 || _la === 507)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + break; + case MySqlParser.KW_ASSIGN_GTIDS_TO_ANONYMOUS_TRANSACTIONS: + this.enterOuterAlt(localContext, 3); + { + this.state = 4648; + this.match(MySqlParser.KW_ASSIGN_GTIDS_TO_ANONYMOUS_TRANSACTIONS); + this.state = 4649; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 4653; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_OFF: + { + this.state = 4650; + this.match(MySqlParser.KW_OFF); + } + break; + case MySqlParser.KW_LOCAL: + { + this.state = 4651; + this.match(MySqlParser.KW_LOCAL); + } + break; + case MySqlParser.ZERO_DECIMAL: + case MySqlParser.ONE_DECIMAL: + case MySqlParser.TWO_DECIMAL: + case MySqlParser.THREE_DECIMAL: + case MySqlParser.STRING_LITERAL: + case MySqlParser.DECIMAL_LITERAL: + case MySqlParser.REAL_LITERAL: + { + this.state = 4652; + this.gtuidSet(); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + replicationSourceOption() { + let localContext = new ReplicationSourceOptionContext(this.context, this.state); + this.enterRule(localContext, 374, MySqlParser.RULE_replicationSourceOption); + let _la; + try { + this.state = 4684; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_NETWORK_NAMESPACE: + case MySqlParser.KW_RELAY_LOG_FILE: + case MySqlParser.KW_SOURCE_BIND: + case MySqlParser.KW_SOURCE_HOST: + case MySqlParser.KW_SOURCE_USER: + case MySqlParser.KW_SOURCE_PASSWORD: + case MySqlParser.KW_SOURCE_LOG_FILE: + case MySqlParser.KW_SOURCE_COMPRESSION_ALGORITHMS: + case MySqlParser.KW_SOURCE_SSL_CA: + case MySqlParser.KW_SOURCE_SSL_CAPATH: + case MySqlParser.KW_SOURCE_SSL_CERT: + case MySqlParser.KW_SOURCE_SSL_CRL: + case MySqlParser.KW_SOURCE_SSL_CRLPATH: + case MySqlParser.KW_SOURCE_SSL_KEY: + case MySqlParser.KW_SOURCE_SSL_CIPHER: + case MySqlParser.KW_SOURCE_TLS_VERSION: + case MySqlParser.KW_SOURCE_TLS_CIPHERSUITES: + case MySqlParser.KW_SOURCE_PUBLIC_KEY_PATH: + localContext = new SourceStringOptionContext(localContext); + this.enterOuterAlt(localContext, 1); + { + this.state = 4657; + this.stringSourceOption(); + this.state = 4658; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 4659; + this.match(MySqlParser.STRING_LITERAL); + } + break; + case MySqlParser.KW_RELAY_LOG_POS: + case MySqlParser.KW_SOURCE_PORT: + case MySqlParser.KW_SOURCE_LOG_POS: + case MySqlParser.KW_SOURCE_HEARTBEAT_PERIOD: + case MySqlParser.KW_SOURCE_CONNECT_RETRY: + case MySqlParser.KW_SOURCE_RETRY_COUNT: + case MySqlParser.KW_SOURCE_DELAY: + case MySqlParser.KW_SOURCE_ZSTD_COMPRESSION_LEVEL: + localContext = new SourceDecimalOptionContext(localContext); + this.enterOuterAlt(localContext, 2); + { + this.state = 4661; + this.decimalSourceOption(); + this.state = 4662; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 4663; + this.decimalLiteral(); + } + break; + case MySqlParser.KW_GET_SOURCE_PUBLIC_KEY: + case MySqlParser.KW_GTID_ONLY: + case MySqlParser.KW_REQUIRE_ROW_FORMAT: + case MySqlParser.KW_SOURCE_AUTO_POSITION: + case MySqlParser.KW_SOURCE_CONNECTION_AUTO_FAILOVER: + case MySqlParser.KW_SOURCE_SSL: + case MySqlParser.KW_SOURCE_SSL_VERIFY_SERVER_CERT: + localContext = new SourceBoolOptionContext(localContext); + this.enterOuterAlt(localContext, 3); + { + this.state = 4665; + this.boolSourceOption(); + this.state = 4666; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 4667; + localContext._boolVal = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 871 || _la === 872)) { + localContext._boolVal = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + break; + case MySqlParser.KW_ASSIGN_GTIDS_TO_ANONYMOUS_TRANSACTIONS: + case MySqlParser.KW_PRIVILEGE_CHECKS_USER: + case MySqlParser.KW_REQUIRE_TABLE_PRIMARY_KEY_CHECK: + localContext = new SourceOtherOptionContext(localContext); + this.enterOuterAlt(localContext, 4); + { + this.state = 4669; + this.otherSourceOption(); + } + break; + case MySqlParser.KW_IGNORE_SERVER_IDS: + localContext = new SourceUidListOptionContext(localContext); + this.enterOuterAlt(localContext, 5); + { + this.state = 4670; + this.match(MySqlParser.KW_IGNORE_SERVER_IDS); + this.state = 4671; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 4672; + this.match(MySqlParser.LR_BRACKET); + this.state = 4681; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if ((((_la) & ~0x1F) === 0 && ((1 << _la) & 1074302976) !== 0) || ((((_la - 36)) & ~0x1F) === 0 && ((1 << (_la - 36)) & 11014219) !== 0) || ((((_la - 74)) & ~0x1F) === 0 && ((1 << (_la - 74)) & 18878481) !== 0) || ((((_la - 117)) & ~0x1F) === 0 && ((1 << (_la - 117)) & 100679969) !== 0) || ((((_la - 150)) & ~0x1F) === 0 && ((1 << (_la - 150)) & 1049605) !== 0) || ((((_la - 219)) & ~0x1F) === 0 && ((1 << (_la - 219)) & 5374495) !== 0) || ((((_la - 253)) & ~0x1F) === 0 && ((1 << (_la - 253)) & 4294967295) !== 0) || ((((_la - 285)) & ~0x1F) === 0 && ((1 << (_la - 285)) & 4261412607) !== 0) || ((((_la - 317)) & ~0x1F) === 0 && ((1 << (_la - 317)) & 4160741375) !== 0) || ((((_la - 349)) & ~0x1F) === 0 && ((1 << (_la - 349)) & 4026531839) !== 0) || ((((_la - 381)) & ~0x1F) === 0 && ((1 << (_la - 381)) & 1055907839) !== 0) || ((((_la - 413)) & ~0x1F) === 0 && ((1 << (_la - 413)) & 4294885367) !== 0) || ((((_la - 445)) & ~0x1F) === 0 && ((1 << (_la - 445)) & 3757571071) !== 0) || ((((_la - 478)) & ~0x1F) === 0 && ((1 << (_la - 478)) & 3755999231) !== 0) || ((((_la - 510)) & ~0x1F) === 0 && ((1 << (_la - 510)) & 3751780349) !== 0) || ((((_la - 542)) & ~0x1F) === 0 && ((1 << (_la - 542)) & 2141183997) !== 0) || ((((_la - 575)) & ~0x1F) === 0 && ((1 << (_la - 575)) & 2147483629) !== 0) || ((((_la - 633)) & ~0x1F) === 0 && ((1 << (_la - 633)) & 4294934527) !== 0) || ((((_la - 665)) & ~0x1F) === 0 && ((1 << (_la - 665)) & 4278189053) !== 0) || ((((_la - 697)) & ~0x1F) === 0 && ((1 << (_la - 697)) & 1644099327) !== 0) || ((((_la - 729)) & ~0x1F) === 0 && ((1 << (_la - 729)) & 4294900735) !== 0) || ((((_la - 761)) & ~0x1F) === 0 && ((1 << (_la - 761)) & 4294967295) !== 0) || ((((_la - 793)) & ~0x1F) === 0 && ((1 << (_la - 793)) & 4288675839) !== 0) || ((((_la - 825)) & ~0x1F) === 0 && ((1 << (_la - 825)) & 2147527671) !== 0) || ((((_la - 879)) & ~0x1F) === 0 && ((1 << (_la - 879)) & 1033) !== 0)) { + { + this.state = 4673; + localContext._server_id = this.uid(); + this.state = 4678; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 4674; + this.match(MySqlParser.COMMA); + this.state = 4675; + localContext._server_id = this.uid(); + } + } + this.state = 4680; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + } + this.state = 4683; + this.match(MySqlParser.RR_BRACKET); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + stringSourceOption() { + let localContext = new StringSourceOptionContext(this.context, this.state); + this.enterRule(localContext, 376, MySqlParser.RULE_stringSourceOption); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 4686; + _la = this.tokenStream.LA(1); + if (!(_la === 499 || _la === 557 || ((((_la - 606)) & ~0x1F) === 0 && ((1 << (_la - 606)) & 125771823) !== 0))) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + decimalSourceOption() { + let localContext = new DecimalSourceOptionContext(this.context, this.state); + this.enterRule(localContext, 378, MySqlParser.RULE_decimalSourceOption); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 4688; + _la = this.tokenStream.LA(1); + if (!(_la === 558 || ((((_la - 610)) & ~0x1F) === 0 && ((1 << (_la - 610)) & 1397) !== 0))) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + boolSourceOption() { + let localContext = new BoolSourceOptionContext(this.context, this.state); + this.enterRule(localContext, 380, MySqlParser.RULE_boolSourceOption); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 4690; + _la = this.tokenStream.LA(1); + if (!(_la === 412 || _la === 416 || _la === 573 || ((((_la - 613)) & ~0x1F) === 0 && ((1 << (_la - 613)) & 65809) !== 0))) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + otherSourceOption() { + let localContext = new OtherSourceOptionContext(this.context, this.state); + this.enterRule(localContext, 382, MySqlParser.RULE_otherSourceOption); + let _la; + try { + this.state = 4705; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_PRIVILEGE_CHECKS_USER: + this.enterOuterAlt(localContext, 1); + { + this.state = 4692; + this.match(MySqlParser.KW_PRIVILEGE_CHECKS_USER); + this.state = 4693; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 4694; + _la = this.tokenStream.LA(1); + if (!(_la === 116 || _la === 882)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + break; + case MySqlParser.KW_REQUIRE_TABLE_PRIMARY_KEY_CHECK: + this.enterOuterAlt(localContext, 2); + { + this.state = 4695; + this.match(MySqlParser.KW_REQUIRE_TABLE_PRIMARY_KEY_CHECK); + this.state = 4696; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 4697; + _la = this.tokenStream.LA(1); + if (!(_la === 70 || _la === 118 || _la === 119 || _la === 507)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + break; + case MySqlParser.KW_ASSIGN_GTIDS_TO_ANONYMOUS_TRANSACTIONS: + this.enterOuterAlt(localContext, 3); + { + this.state = 4698; + this.match(MySqlParser.KW_ASSIGN_GTIDS_TO_ANONYMOUS_TRANSACTIONS); + this.state = 4699; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 4703; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_OFF: + { + this.state = 4700; + this.match(MySqlParser.KW_OFF); + } + break; + case MySqlParser.KW_LOCAL: + { + this.state = 4701; + this.match(MySqlParser.KW_LOCAL); + } + break; + case MySqlParser.ZERO_DECIMAL: + case MySqlParser.ONE_DECIMAL: + case MySqlParser.TWO_DECIMAL: + case MySqlParser.THREE_DECIMAL: + case MySqlParser.STRING_LITERAL: + case MySqlParser.DECIMAL_LITERAL: + case MySqlParser.REAL_LITERAL: + { + this.state = 4702; + this.gtuidSet(); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + channelOption() { + let localContext = new ChannelOptionContext(this.context, this.state); + this.enterRule(localContext, 384, MySqlParser.RULE_channelOption); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 4707; + this.match(MySqlParser.KW_FOR); + this.state = 4708; + this.match(MySqlParser.KW_CHANNEL); + this.state = 4709; + this.match(MySqlParser.STRING_LITERAL); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + replicationFilter() { + let localContext = new ReplicationFilterContext(this.context, this.state); + this.enterRule(localContext, 386, MySqlParser.RULE_replicationFilter); + let _la; + try { + this.state = 4774; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_REPLICATE_DO_DB: + localContext = new DoDbReplicationContext(localContext); + this.enterOuterAlt(localContext, 1); + { + this.state = 4711; + this.match(MySqlParser.KW_REPLICATE_DO_DB); + this.state = 4712; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 4713; + this.match(MySqlParser.LR_BRACKET); + this.state = 4714; + this.databaseName(); + this.state = 4719; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 4715; + this.match(MySqlParser.COMMA); + this.state = 4716; + this.databaseName(); + } + } + this.state = 4721; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 4722; + this.match(MySqlParser.RR_BRACKET); + } + break; + case MySqlParser.KW_REPLICATE_IGNORE_DB: + localContext = new IgnoreDbReplicationContext(localContext); + this.enterOuterAlt(localContext, 2); + { + this.state = 4724; + this.match(MySqlParser.KW_REPLICATE_IGNORE_DB); + this.state = 4725; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 4726; + this.match(MySqlParser.LR_BRACKET); + this.state = 4727; + this.databaseName(); + this.state = 4732; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 4728; + this.match(MySqlParser.COMMA); + this.state = 4729; + this.databaseName(); + } + } + this.state = 4734; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 4735; + this.match(MySqlParser.RR_BRACKET); + } + break; + case MySqlParser.KW_REPLICATE_DO_TABLE: + localContext = new DoTableReplicationContext(localContext); + this.enterOuterAlt(localContext, 3); + { + this.state = 4737; + this.match(MySqlParser.KW_REPLICATE_DO_TABLE); + this.state = 4738; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 4739; + this.match(MySqlParser.LR_BRACKET); + this.state = 4740; + this.tableNames(); + this.state = 4741; + this.match(MySqlParser.RR_BRACKET); + } + break; + case MySqlParser.KW_REPLICATE_IGNORE_TABLE: + localContext = new IgnoreTableReplicationContext(localContext); + this.enterOuterAlt(localContext, 4); + { + this.state = 4743; + this.match(MySqlParser.KW_REPLICATE_IGNORE_TABLE); + this.state = 4744; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 4745; + this.match(MySqlParser.LR_BRACKET); + this.state = 4746; + this.tableNames(); + this.state = 4747; + this.match(MySqlParser.RR_BRACKET); + } + break; + case MySqlParser.KW_REPLICATE_WILD_DO_TABLE: + localContext = new WildDoTableReplicationContext(localContext); + this.enterOuterAlt(localContext, 5); + { + this.state = 4749; + this.match(MySqlParser.KW_REPLICATE_WILD_DO_TABLE); + this.state = 4750; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 4751; + this.match(MySqlParser.LR_BRACKET); + this.state = 4752; + this.simpleStrings(); + this.state = 4753; + this.match(MySqlParser.RR_BRACKET); + } + break; + case MySqlParser.KW_REPLICATE_WILD_IGNORE_TABLE: + localContext = new WildIgnoreTableReplicationContext(localContext); + this.enterOuterAlt(localContext, 6); + { + this.state = 4755; + this.match(MySqlParser.KW_REPLICATE_WILD_IGNORE_TABLE); + this.state = 4756; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 4757; + this.match(MySqlParser.LR_BRACKET); + this.state = 4758; + this.simpleStrings(); + this.state = 4759; + this.match(MySqlParser.RR_BRACKET); + } + break; + case MySqlParser.KW_REPLICATE_REWRITE_DB: + localContext = new RewriteDbReplicationContext(localContext); + this.enterOuterAlt(localContext, 7); + { + this.state = 4761; + this.match(MySqlParser.KW_REPLICATE_REWRITE_DB); + this.state = 4762; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 4763; + this.match(MySqlParser.LR_BRACKET); + this.state = 4764; + this.tablePair(); + this.state = 4769; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 4765; + this.match(MySqlParser.COMMA); + this.state = 4766; + this.tablePair(); + } + } + this.state = 4771; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 4772; + this.match(MySqlParser.RR_BRACKET); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + tablePair() { + let localContext = new TablePairContext(this.context, this.state); + this.enterRule(localContext, 388, MySqlParser.RULE_tablePair); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 4776; + this.match(MySqlParser.LR_BRACKET); + this.state = 4777; + localContext._firstTable = this.tableName(); + this.state = 4778; + this.match(MySqlParser.COMMA); + this.state = 4779; + localContext._secondTable = this.tableName(); + this.state = 4780; + this.match(MySqlParser.RR_BRACKET); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + threadType() { + let localContext = new ThreadTypeContext(this.context, this.state); + this.enterRule(localContext, 390, MySqlParser.RULE_threadType); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 4782; + _la = this.tokenStream.LA(1); + if (!(_la === 438 || _la === 639)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + untilOption() { + let localContext = new UntilOptionContext(this.context, this.state); + this.enterRule(localContext, 392, MySqlParser.RULE_untilOption); + let _la; + try { + this.state = 4809; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_SQL_AFTER_GTIDS: + case MySqlParser.KW_SQL_BEFORE_GTIDS: + localContext = new GtidsUntilOptionContext(localContext); + this.enterOuterAlt(localContext, 1); + { + this.state = 4784; + localContext._gtids = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 633 || _la === 635)) { + localContext._gtids = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 4785; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 4786; + this.gtuidSet(); + } + break; + case MySqlParser.KW_MASTER_LOG_FILE: + localContext = new MasterLogUntilOptionContext(localContext); + this.enterOuterAlt(localContext, 2); + { + this.state = 4787; + this.match(MySqlParser.KW_MASTER_LOG_FILE); + this.state = 4788; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 4789; + this.match(MySqlParser.STRING_LITERAL); + this.state = 4790; + this.match(MySqlParser.COMMA); + this.state = 4791; + this.match(MySqlParser.KW_MASTER_LOG_POS); + this.state = 4792; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 4793; + this.decimalLiteral(); + } + break; + case MySqlParser.KW_SOURCE_LOG_FILE: + localContext = new SourceLogUntilOptionContext(localContext); + this.enterOuterAlt(localContext, 3); + { + this.state = 4794; + this.match(MySqlParser.KW_SOURCE_LOG_FILE); + this.state = 4795; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 4796; + this.match(MySqlParser.STRING_LITERAL); + this.state = 4797; + this.match(MySqlParser.COMMA); + this.state = 4798; + this.match(MySqlParser.KW_SOURCE_LOG_POS); + this.state = 4799; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 4800; + this.decimalLiteral(); + } + break; + case MySqlParser.KW_RELAY_LOG_FILE: + localContext = new RelayLogUntilOptionContext(localContext); + this.enterOuterAlt(localContext, 4); + { + this.state = 4801; + this.match(MySqlParser.KW_RELAY_LOG_FILE); + this.state = 4802; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 4803; + this.match(MySqlParser.STRING_LITERAL); + this.state = 4804; + this.match(MySqlParser.COMMA); + this.state = 4805; + this.match(MySqlParser.KW_RELAY_LOG_POS); + this.state = 4806; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 4807; + this.decimalLiteral(); + } + break; + case MySqlParser.KW_SQL_AFTER_MTS_GAPS: + localContext = new SqlGapsUntilOptionContext(localContext); + this.enterOuterAlt(localContext, 5); + { + this.state = 4808; + this.match(MySqlParser.KW_SQL_AFTER_MTS_GAPS); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + connectionOptions() { + let localContext = new ConnectionOptionsContext(this.context, this.state); + this.enterRule(localContext, 394, MySqlParser.RULE_connectionOptions); + try { + this.state = 4823; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_USER: + localContext = new UserConnectionOptionContext(localContext); + this.enterOuterAlt(localContext, 1); + { + this.state = 4811; + this.match(MySqlParser.KW_USER); + this.state = 4812; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 4813; + localContext._conOptUser = this.match(MySqlParser.STRING_LITERAL); + } + break; + case MySqlParser.KW_PASSWORD: + localContext = new PasswordConnectionOptionContext(localContext); + this.enterOuterAlt(localContext, 2); + { + this.state = 4814; + this.match(MySqlParser.KW_PASSWORD); + this.state = 4815; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 4816; + localContext._conOptPassword = this.match(MySqlParser.STRING_LITERAL); + } + break; + case MySqlParser.KW_DEFAULT_AUTH: + localContext = new DefaultAuthConnectionOptionContext(localContext); + this.enterOuterAlt(localContext, 3); + { + this.state = 4817; + this.match(MySqlParser.KW_DEFAULT_AUTH); + this.state = 4818; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 4819; + localContext._conOptDefAuth = this.match(MySqlParser.STRING_LITERAL); + } + break; + case MySqlParser.KW_PLUGIN_DIR: + localContext = new PluginDirConnectionOptionContext(localContext); + this.enterOuterAlt(localContext, 4); + { + this.state = 4820; + this.match(MySqlParser.KW_PLUGIN_DIR); + this.state = 4821; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 4822; + localContext._conOptPluginDir = this.match(MySqlParser.STRING_LITERAL); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + gtuidSet() { + let localContext = new GtuidSetContext(this.context, this.state); + this.enterRule(localContext, 396, MySqlParser.RULE_gtuidSet); + try { + let alternative; + this.state = 4834; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.ZERO_DECIMAL: + case MySqlParser.ONE_DECIMAL: + case MySqlParser.TWO_DECIMAL: + case MySqlParser.THREE_DECIMAL: + case MySqlParser.DECIMAL_LITERAL: + case MySqlParser.REAL_LITERAL: + this.enterOuterAlt(localContext, 1); + { + this.state = 4825; + this.uuidSet(); + this.state = 4830; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 680, this.context); + while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER) { + if (alternative === 1) { + { + { + this.state = 4826; + this.match(MySqlParser.COMMA); + this.state = 4827; + this.uuidSet(); + } + } + } + this.state = 4832; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 680, this.context); + } + } + break; + case MySqlParser.STRING_LITERAL: + this.enterOuterAlt(localContext, 2); + { + this.state = 4833; + this.match(MySqlParser.STRING_LITERAL); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + xaStartTransaction() { + let localContext = new XaStartTransactionContext(this.context, this.state); + this.enterRule(localContext, 398, MySqlParser.RULE_xaStartTransaction); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 4836; + this.match(MySqlParser.KW_XA); + this.state = 4837; + localContext._xaStart = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 317 || _la === 640)) { + localContext._xaStart = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 4838; + this.xid(); + this.state = 4840; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 91 || _la === 577) { + { + this.state = 4839; + localContext._xaAction = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 91 || _la === 577)) { + localContext._xaAction = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + xaEndTransaction() { + let localContext = new XaEndTransactionContext(this.context, this.state); + this.enterRule(localContext, 400, MySqlParser.RULE_xaEndTransaction); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 4842; + this.match(MySqlParser.KW_XA); + this.state = 4843; + this.match(MySqlParser.KW_END); + this.state = 4844; + this.xid(); + this.state = 4850; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 654) { + { + this.state = 4845; + this.match(MySqlParser.KW_SUSPEND); + this.state = 4848; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 65) { + { + this.state = 4846; + this.match(MySqlParser.KW_FOR); + this.state = 4847; + this.match(MySqlParser.KW_MIGRATE); + } + } + } + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + xaPrepareStatement() { + let localContext = new XaPrepareStatementContext(this.context, this.state); + this.enterRule(localContext, 402, MySqlParser.RULE_xaPrepareStatement); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 4852; + this.match(MySqlParser.KW_XA); + this.state = 4853; + this.match(MySqlParser.KW_PREPARE); + this.state = 4854; + this.xid(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + xaCommitWork() { + let localContext = new XaCommitWorkContext(this.context, this.state); + this.enterRule(localContext, 404, MySqlParser.RULE_xaCommitWork); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 4856; + this.match(MySqlParser.KW_XA); + this.state = 4857; + this.match(MySqlParser.KW_COMMIT); + this.state = 4858; + this.xid(); + this.state = 4861; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 513) { + { + this.state = 4859; + this.match(MySqlParser.KW_ONE); + this.state = 4860; + this.match(MySqlParser.KW_PHASE); + } + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + xaRollbackWork() { + let localContext = new XaRollbackWorkContext(this.context, this.state); + this.enterRule(localContext, 406, MySqlParser.RULE_xaRollbackWork); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 4863; + this.match(MySqlParser.KW_XA); + this.state = 4864; + this.match(MySqlParser.KW_ROLLBACK); + this.state = 4865; + this.xid(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + xaRecoverWork() { + let localContext = new XaRecoverWorkContext(this.context, this.state); + this.enterRule(localContext, 408, MySqlParser.RULE_xaRecoverWork); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 4867; + this.match(MySqlParser.KW_XA); + this.state = 4868; + this.match(MySqlParser.KW_RECOVER); + this.state = 4871; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 33) { + { + this.state = 4869; + this.match(MySqlParser.KW_CONVERT); + this.state = 4870; + this.xid(); + } + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + prepareStatement() { + let localContext = new PrepareStatementContext(this.context, this.state); + this.enterRule(localContext, 410, MySqlParser.RULE_prepareStatement); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 4873; + this.match(MySqlParser.KW_PREPARE); + this.state = 4874; + localContext._stmt_name = this.uid(); + this.state = 4875; + this.match(MySqlParser.KW_FROM); + this.state = 4878; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.STRING_LITERAL: + { + this.state = 4876; + localContext._query = this.match(MySqlParser.STRING_LITERAL); + } + break; + case MySqlParser.LOCAL_ID: + { + this.state = 4877; + localContext._variable = this.match(MySqlParser.LOCAL_ID); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + executeStatement() { + let localContext = new ExecuteStatementContext(this.context, this.state); + this.enterRule(localContext, 412, MySqlParser.RULE_executeStatement); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 4880; + this.match(MySqlParser.KW_EXECUTE); + this.state = 4881; + localContext._stmt_name = this.uid(); + this.state = 4884; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 188) { + { + this.state = 4882; + this.match(MySqlParser.KW_USING); + this.state = 4883; + this.userVariables(); + } + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + deallocatePrepare() { + let localContext = new DeallocatePrepareContext(this.context, this.state); + this.enterRule(localContext, 414, MySqlParser.RULE_deallocatePrepare); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 4886; + localContext._dropFormat = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 51 || _la === 362)) { + localContext._dropFormat = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 4887; + this.match(MySqlParser.KW_PREPARE); + this.state = 4888; + localContext._stmt_name = this.uid(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + routineBody() { + let localContext = new RoutineBodyContext(this.context, this.state); + this.enterRule(localContext, 416, MySqlParser.RULE_routineBody); + try { + this.state = 4892; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 689, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 4890; + this.blockStatement(); + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 4891; + this.sqlStatement(); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + blockStatement() { + let localContext = new BlockStatementContext(this.context, this.state); + this.enterRule(localContext, 418, MySqlParser.RULE_blockStatement); + let _la; + try { + let alternative; + this.enterOuterAlt(localContext, 1); + { + this.state = 4897; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 690, this.context)) { + case 1: + { + this.state = 4894; + localContext._begin = this.uid(); + this.state = 4895; + this.match(MySqlParser.COLON_SYMB); + } + break; + } + this.state = 4899; + this.match(MySqlParser.KW_BEGIN); + this.state = 4905; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 691, this.context); + while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER) { + if (alternative === 1) { + { + { + this.state = 4900; + this.declareVariable(); + this.state = 4901; + this.match(MySqlParser.SEMI); + } + } + } + this.state = 4907; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 691, this.context); + } + this.state = 4913; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 692, this.context); + while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER) { + if (alternative === 1) { + { + { + this.state = 4908; + this.declareCondition(); + this.state = 4909; + this.match(MySqlParser.SEMI); + } + } + } + this.state = 4915; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 692, this.context); + } + this.state = 4921; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 693, this.context); + while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER) { + if (alternative === 1) { + { + { + this.state = 4916; + this.declareCursor(); + this.state = 4917; + this.match(MySqlParser.SEMI); + } + } + } + this.state = 4923; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 693, this.context); + } + this.state = 4929; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 41) { + { + { + this.state = 4924; + this.declareHandler(); + this.state = 4925; + this.match(MySqlParser.SEMI); + } + } + this.state = 4931; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 4935; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 695, this.context); + while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER) { + if (alternative === 1) { + { + { + this.state = 4932; + this.procedureSqlStatement(); + } + } + } + this.state = 4937; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 695, this.context); + } + this.state = 4938; + this.match(MySqlParser.KW_END); + this.state = 4940; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 696, this.context)) { + case 1: + { + this.state = 4939; + localContext._end = this.uid(); + } + break; + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + caseStatement() { + let localContext = new CaseStatementContext(this.context, this.state); + this.enterRule(localContext, 420, MySqlParser.RULE_caseStatement); + let _la; + try { + let alternative; + this.enterOuterAlt(localContext, 1); + { + this.state = 4942; + this.match(MySqlParser.KW_CASE); + this.state = 4945; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 697, this.context)) { + case 1: + { + this.state = 4943; + localContext._case_value = this.uid(); + } + break; + case 2: + { + this.state = 4944; + this.expression(0); + } + break; + } + this.state = 4948; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + do { + { + { + this.state = 4947; + this.caseAlternative(); + } + } + this.state = 4950; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } while (_la === 191); + this.state = 4958; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 53) { + { + this.state = 4952; + this.match(MySqlParser.KW_ELSE); + this.state = 4954; + this.errorHandler.sync(this); + alternative = 1; + do { + switch (alternative) { + case 1: + { + { + this.state = 4953; + this.procedureSqlStatement(); + } + } + break; + default: + throw new antlr.NoViableAltException(this); + } + this.state = 4956; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 699, this.context); + } while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER); + } + } + this.state = 4960; + this.match(MySqlParser.KW_END); + this.state = 4961; + this.match(MySqlParser.KW_CASE); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + ifStatement() { + let localContext = new IfStatementContext(this.context, this.state); + this.enterRule(localContext, 422, MySqlParser.RULE_ifStatement); + let _la; + try { + let alternative; + this.enterOuterAlt(localContext, 1); + { + this.state = 4963; + this.match(MySqlParser.KW_IF); + this.state = 4964; + this.expression(0); + this.state = 4965; + this.match(MySqlParser.KW_THEN); + this.state = 4967; + this.errorHandler.sync(this); + alternative = 1; + do { + switch (alternative) { + case 1: + { + { + this.state = 4966; + localContext._procedureSqlStatement = this.procedureSqlStatement(); + localContext._thenStatements.push(localContext._procedureSqlStatement); + } + } + break; + default: + throw new antlr.NoViableAltException(this); + } + this.state = 4969; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 701, this.context); + } while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER); + this.state = 4974; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 54) { + { + { + this.state = 4971; + this.elifAlternative(); + } + } + this.state = 4976; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 4983; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 53) { + { + this.state = 4977; + this.match(MySqlParser.KW_ELSE); + this.state = 4979; + this.errorHandler.sync(this); + alternative = 1; + do { + switch (alternative) { + case 1: + { + { + this.state = 4978; + localContext._procedureSqlStatement = this.procedureSqlStatement(); + localContext._elseStatements.push(localContext._procedureSqlStatement); + } + } + break; + default: + throw new antlr.NoViableAltException(this); + } + this.state = 4981; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 703, this.context); + } while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER); + } + } + this.state = 4985; + this.match(MySqlParser.KW_END); + this.state = 4986; + this.match(MySqlParser.KW_IF); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + iterateStatement() { + let localContext = new IterateStatementContext(this.context, this.state); + this.enterRule(localContext, 424, MySqlParser.RULE_iterateStatement); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 4988; + this.match(MySqlParser.KW_ITERATE); + this.state = 4989; + localContext._label = this.uid(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + leaveStatement() { + let localContext = new LeaveStatementContext(this.context, this.state); + this.enterRule(localContext, 426, MySqlParser.RULE_leaveStatement); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 4991; + this.match(MySqlParser.KW_LEAVE); + this.state = 4992; + localContext._label = this.uid(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + loopStatement() { + let localContext = new LoopStatementContext(this.context, this.state); + this.enterRule(localContext, 428, MySqlParser.RULE_loopStatement); + let _la; + try { + let alternative; + this.enterOuterAlt(localContext, 1); + { + this.state = 4997; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if ((((_la) & ~0x1F) === 0 && ((1 << _la) & 1074302976) !== 0) || ((((_la - 36)) & ~0x1F) === 0 && ((1 << (_la - 36)) & 11014219) !== 0) || ((((_la - 74)) & ~0x1F) === 0 && ((1 << (_la - 74)) & 18878481) !== 0) || ((((_la - 117)) & ~0x1F) === 0 && ((1 << (_la - 117)) & 100679969) !== 0) || ((((_la - 150)) & ~0x1F) === 0 && ((1 << (_la - 150)) & 1049605) !== 0) || ((((_la - 219)) & ~0x1F) === 0 && ((1 << (_la - 219)) & 5374495) !== 0) || ((((_la - 253)) & ~0x1F) === 0 && ((1 << (_la - 253)) & 4294967295) !== 0) || ((((_la - 285)) & ~0x1F) === 0 && ((1 << (_la - 285)) & 4261412607) !== 0) || ((((_la - 317)) & ~0x1F) === 0 && ((1 << (_la - 317)) & 4160741375) !== 0) || ((((_la - 349)) & ~0x1F) === 0 && ((1 << (_la - 349)) & 4026531839) !== 0) || ((((_la - 381)) & ~0x1F) === 0 && ((1 << (_la - 381)) & 1055907839) !== 0) || ((((_la - 413)) & ~0x1F) === 0 && ((1 << (_la - 413)) & 4294885367) !== 0) || ((((_la - 445)) & ~0x1F) === 0 && ((1 << (_la - 445)) & 3757571071) !== 0) || ((((_la - 478)) & ~0x1F) === 0 && ((1 << (_la - 478)) & 3755999231) !== 0) || ((((_la - 510)) & ~0x1F) === 0 && ((1 << (_la - 510)) & 3751780349) !== 0) || ((((_la - 542)) & ~0x1F) === 0 && ((1 << (_la - 542)) & 2141183997) !== 0) || ((((_la - 575)) & ~0x1F) === 0 && ((1 << (_la - 575)) & 2147483629) !== 0) || ((((_la - 633)) & ~0x1F) === 0 && ((1 << (_la - 633)) & 4294934527) !== 0) || ((((_la - 665)) & ~0x1F) === 0 && ((1 << (_la - 665)) & 4278189053) !== 0) || ((((_la - 697)) & ~0x1F) === 0 && ((1 << (_la - 697)) & 1644099327) !== 0) || ((((_la - 729)) & ~0x1F) === 0 && ((1 << (_la - 729)) & 4294900735) !== 0) || ((((_la - 761)) & ~0x1F) === 0 && ((1 << (_la - 761)) & 4294967295) !== 0) || ((((_la - 793)) & ~0x1F) === 0 && ((1 << (_la - 793)) & 4288675839) !== 0) || ((((_la - 825)) & ~0x1F) === 0 && ((1 << (_la - 825)) & 2147527671) !== 0) || ((((_la - 879)) & ~0x1F) === 0 && ((1 << (_la - 879)) & 1033) !== 0)) { + { + this.state = 4994; + localContext._begin_label = this.uid(); + this.state = 4995; + this.match(MySqlParser.COLON_SYMB); + } + } + this.state = 4999; + this.match(MySqlParser.KW_LOOP); + this.state = 5001; + this.errorHandler.sync(this); + alternative = 1; + do { + switch (alternative) { + case 1: + { + { + this.state = 5000; + this.procedureSqlStatement(); + } + } + break; + default: + throw new antlr.NoViableAltException(this); + } + this.state = 5003; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 706, this.context); + } while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER); + this.state = 5005; + this.match(MySqlParser.KW_END); + this.state = 5006; + this.match(MySqlParser.KW_LOOP); + this.state = 5008; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if ((((_la) & ~0x1F) === 0 && ((1 << _la) & 1074302976) !== 0) || ((((_la - 36)) & ~0x1F) === 0 && ((1 << (_la - 36)) & 11014219) !== 0) || ((((_la - 74)) & ~0x1F) === 0 && ((1 << (_la - 74)) & 18878481) !== 0) || ((((_la - 117)) & ~0x1F) === 0 && ((1 << (_la - 117)) & 100679969) !== 0) || ((((_la - 150)) & ~0x1F) === 0 && ((1 << (_la - 150)) & 1049605) !== 0) || ((((_la - 219)) & ~0x1F) === 0 && ((1 << (_la - 219)) & 5374495) !== 0) || ((((_la - 253)) & ~0x1F) === 0 && ((1 << (_la - 253)) & 4294967295) !== 0) || ((((_la - 285)) & ~0x1F) === 0 && ((1 << (_la - 285)) & 4261412607) !== 0) || ((((_la - 317)) & ~0x1F) === 0 && ((1 << (_la - 317)) & 4160741375) !== 0) || ((((_la - 349)) & ~0x1F) === 0 && ((1 << (_la - 349)) & 4026531839) !== 0) || ((((_la - 381)) & ~0x1F) === 0 && ((1 << (_la - 381)) & 1055907839) !== 0) || ((((_la - 413)) & ~0x1F) === 0 && ((1 << (_la - 413)) & 4294885367) !== 0) || ((((_la - 445)) & ~0x1F) === 0 && ((1 << (_la - 445)) & 3757571071) !== 0) || ((((_la - 478)) & ~0x1F) === 0 && ((1 << (_la - 478)) & 3755999231) !== 0) || ((((_la - 510)) & ~0x1F) === 0 && ((1 << (_la - 510)) & 3751780349) !== 0) || ((((_la - 542)) & ~0x1F) === 0 && ((1 << (_la - 542)) & 2141183997) !== 0) || ((((_la - 575)) & ~0x1F) === 0 && ((1 << (_la - 575)) & 2147483629) !== 0) || ((((_la - 633)) & ~0x1F) === 0 && ((1 << (_la - 633)) & 4294934527) !== 0) || ((((_la - 665)) & ~0x1F) === 0 && ((1 << (_la - 665)) & 4278189053) !== 0) || ((((_la - 697)) & ~0x1F) === 0 && ((1 << (_la - 697)) & 1644099327) !== 0) || ((((_la - 729)) & ~0x1F) === 0 && ((1 << (_la - 729)) & 4294900735) !== 0) || ((((_la - 761)) & ~0x1F) === 0 && ((1 << (_la - 761)) & 4294967295) !== 0) || ((((_la - 793)) & ~0x1F) === 0 && ((1 << (_la - 793)) & 4288675839) !== 0) || ((((_la - 825)) & ~0x1F) === 0 && ((1 << (_la - 825)) & 2147527671) !== 0) || ((((_la - 879)) & ~0x1F) === 0 && ((1 << (_la - 879)) & 1033) !== 0)) { + { + this.state = 5007; + localContext._end_label = this.uid(); + } + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + repeatStatement() { + let localContext = new RepeatStatementContext(this.context, this.state); + this.enterRule(localContext, 430, MySqlParser.RULE_repeatStatement); + let _la; + try { + let alternative; + this.enterOuterAlt(localContext, 1); + { + this.state = 5013; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 708, this.context)) { + case 1: + { + this.state = 5010; + localContext._begin_label = this.uid(); + this.state = 5011; + this.match(MySqlParser.COLON_SYMB); + } + break; + } + this.state = 5015; + this.match(MySqlParser.KW_REPEAT); + this.state = 5017; + this.errorHandler.sync(this); + alternative = 1; + do { + switch (alternative) { + case 1: + { + { + this.state = 5016; + this.procedureSqlStatement(); + } + } + break; + default: + throw new antlr.NoViableAltException(this); + } + this.state = 5019; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 709, this.context); + } while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER); + this.state = 5021; + this.match(MySqlParser.KW_UNTIL); + this.state = 5022; + this.expression(0); + this.state = 5023; + this.match(MySqlParser.KW_END); + this.state = 5024; + this.match(MySqlParser.KW_REPEAT); + this.state = 5026; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if ((((_la) & ~0x1F) === 0 && ((1 << _la) & 1074302976) !== 0) || ((((_la - 36)) & ~0x1F) === 0 && ((1 << (_la - 36)) & 11014219) !== 0) || ((((_la - 74)) & ~0x1F) === 0 && ((1 << (_la - 74)) & 18878481) !== 0) || ((((_la - 117)) & ~0x1F) === 0 && ((1 << (_la - 117)) & 100679969) !== 0) || ((((_la - 150)) & ~0x1F) === 0 && ((1 << (_la - 150)) & 1049605) !== 0) || ((((_la - 219)) & ~0x1F) === 0 && ((1 << (_la - 219)) & 5374495) !== 0) || ((((_la - 253)) & ~0x1F) === 0 && ((1 << (_la - 253)) & 4294967295) !== 0) || ((((_la - 285)) & ~0x1F) === 0 && ((1 << (_la - 285)) & 4261412607) !== 0) || ((((_la - 317)) & ~0x1F) === 0 && ((1 << (_la - 317)) & 4160741375) !== 0) || ((((_la - 349)) & ~0x1F) === 0 && ((1 << (_la - 349)) & 4026531839) !== 0) || ((((_la - 381)) & ~0x1F) === 0 && ((1 << (_la - 381)) & 1055907839) !== 0) || ((((_la - 413)) & ~0x1F) === 0 && ((1 << (_la - 413)) & 4294885367) !== 0) || ((((_la - 445)) & ~0x1F) === 0 && ((1 << (_la - 445)) & 3757571071) !== 0) || ((((_la - 478)) & ~0x1F) === 0 && ((1 << (_la - 478)) & 3755999231) !== 0) || ((((_la - 510)) & ~0x1F) === 0 && ((1 << (_la - 510)) & 3751780349) !== 0) || ((((_la - 542)) & ~0x1F) === 0 && ((1 << (_la - 542)) & 2141183997) !== 0) || ((((_la - 575)) & ~0x1F) === 0 && ((1 << (_la - 575)) & 2147483629) !== 0) || ((((_la - 633)) & ~0x1F) === 0 && ((1 << (_la - 633)) & 4294934527) !== 0) || ((((_la - 665)) & ~0x1F) === 0 && ((1 << (_la - 665)) & 4278189053) !== 0) || ((((_la - 697)) & ~0x1F) === 0 && ((1 << (_la - 697)) & 1644099327) !== 0) || ((((_la - 729)) & ~0x1F) === 0 && ((1 << (_la - 729)) & 4294900735) !== 0) || ((((_la - 761)) & ~0x1F) === 0 && ((1 << (_la - 761)) & 4294967295) !== 0) || ((((_la - 793)) & ~0x1F) === 0 && ((1 << (_la - 793)) & 4288675839) !== 0) || ((((_la - 825)) & ~0x1F) === 0 && ((1 << (_la - 825)) & 2147527671) !== 0) || ((((_la - 879)) & ~0x1F) === 0 && ((1 << (_la - 879)) & 1033) !== 0)) { + { + this.state = 5025; + localContext._end_label = this.uid(); + } + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + returnStatement() { + let localContext = new ReturnStatementContext(this.context, this.state); + this.enterRule(localContext, 432, MySqlParser.RULE_returnStatement); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 5028; + this.match(MySqlParser.KW_RETURN); + this.state = 5029; + this.expression(0); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + whileStatement() { + let localContext = new WhileStatementContext(this.context, this.state); + this.enterRule(localContext, 434, MySqlParser.RULE_whileStatement); + let _la; + try { + let alternative; + this.enterOuterAlt(localContext, 1); + { + this.state = 5034; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if ((((_la) & ~0x1F) === 0 && ((1 << _la) & 1074302976) !== 0) || ((((_la - 36)) & ~0x1F) === 0 && ((1 << (_la - 36)) & 11014219) !== 0) || ((((_la - 74)) & ~0x1F) === 0 && ((1 << (_la - 74)) & 18878481) !== 0) || ((((_la - 117)) & ~0x1F) === 0 && ((1 << (_la - 117)) & 100679969) !== 0) || ((((_la - 150)) & ~0x1F) === 0 && ((1 << (_la - 150)) & 1049605) !== 0) || ((((_la - 219)) & ~0x1F) === 0 && ((1 << (_la - 219)) & 5374495) !== 0) || ((((_la - 253)) & ~0x1F) === 0 && ((1 << (_la - 253)) & 4294967295) !== 0) || ((((_la - 285)) & ~0x1F) === 0 && ((1 << (_la - 285)) & 4261412607) !== 0) || ((((_la - 317)) & ~0x1F) === 0 && ((1 << (_la - 317)) & 4160741375) !== 0) || ((((_la - 349)) & ~0x1F) === 0 && ((1 << (_la - 349)) & 4026531839) !== 0) || ((((_la - 381)) & ~0x1F) === 0 && ((1 << (_la - 381)) & 1055907839) !== 0) || ((((_la - 413)) & ~0x1F) === 0 && ((1 << (_la - 413)) & 4294885367) !== 0) || ((((_la - 445)) & ~0x1F) === 0 && ((1 << (_la - 445)) & 3757571071) !== 0) || ((((_la - 478)) & ~0x1F) === 0 && ((1 << (_la - 478)) & 3755999231) !== 0) || ((((_la - 510)) & ~0x1F) === 0 && ((1 << (_la - 510)) & 3751780349) !== 0) || ((((_la - 542)) & ~0x1F) === 0 && ((1 << (_la - 542)) & 2141183997) !== 0) || ((((_la - 575)) & ~0x1F) === 0 && ((1 << (_la - 575)) & 2147483629) !== 0) || ((((_la - 633)) & ~0x1F) === 0 && ((1 << (_la - 633)) & 4294934527) !== 0) || ((((_la - 665)) & ~0x1F) === 0 && ((1 << (_la - 665)) & 4278189053) !== 0) || ((((_la - 697)) & ~0x1F) === 0 && ((1 << (_la - 697)) & 1644099327) !== 0) || ((((_la - 729)) & ~0x1F) === 0 && ((1 << (_la - 729)) & 4294900735) !== 0) || ((((_la - 761)) & ~0x1F) === 0 && ((1 << (_la - 761)) & 4294967295) !== 0) || ((((_la - 793)) & ~0x1F) === 0 && ((1 << (_la - 793)) & 4288675839) !== 0) || ((((_la - 825)) & ~0x1F) === 0 && ((1 << (_la - 825)) & 2147527671) !== 0) || ((((_la - 879)) & ~0x1F) === 0 && ((1 << (_la - 879)) & 1033) !== 0)) { + { + this.state = 5031; + localContext._begin_label = this.uid(); + this.state = 5032; + this.match(MySqlParser.COLON_SYMB); + } + } + this.state = 5036; + this.match(MySqlParser.KW_WHILE); + this.state = 5037; + this.expression(0); + this.state = 5038; + this.match(MySqlParser.KW_DO); + this.state = 5040; + this.errorHandler.sync(this); + alternative = 1; + do { + switch (alternative) { + case 1: + { + { + this.state = 5039; + this.procedureSqlStatement(); + } + } + break; + default: + throw new antlr.NoViableAltException(this); + } + this.state = 5042; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 712, this.context); + } while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER); + this.state = 5044; + this.match(MySqlParser.KW_END); + this.state = 5045; + this.match(MySqlParser.KW_WHILE); + this.state = 5047; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if ((((_la) & ~0x1F) === 0 && ((1 << _la) & 1074302976) !== 0) || ((((_la - 36)) & ~0x1F) === 0 && ((1 << (_la - 36)) & 11014219) !== 0) || ((((_la - 74)) & ~0x1F) === 0 && ((1 << (_la - 74)) & 18878481) !== 0) || ((((_la - 117)) & ~0x1F) === 0 && ((1 << (_la - 117)) & 100679969) !== 0) || ((((_la - 150)) & ~0x1F) === 0 && ((1 << (_la - 150)) & 1049605) !== 0) || ((((_la - 219)) & ~0x1F) === 0 && ((1 << (_la - 219)) & 5374495) !== 0) || ((((_la - 253)) & ~0x1F) === 0 && ((1 << (_la - 253)) & 4294967295) !== 0) || ((((_la - 285)) & ~0x1F) === 0 && ((1 << (_la - 285)) & 4261412607) !== 0) || ((((_la - 317)) & ~0x1F) === 0 && ((1 << (_la - 317)) & 4160741375) !== 0) || ((((_la - 349)) & ~0x1F) === 0 && ((1 << (_la - 349)) & 4026531839) !== 0) || ((((_la - 381)) & ~0x1F) === 0 && ((1 << (_la - 381)) & 1055907839) !== 0) || ((((_la - 413)) & ~0x1F) === 0 && ((1 << (_la - 413)) & 4294885367) !== 0) || ((((_la - 445)) & ~0x1F) === 0 && ((1 << (_la - 445)) & 3757571071) !== 0) || ((((_la - 478)) & ~0x1F) === 0 && ((1 << (_la - 478)) & 3755999231) !== 0) || ((((_la - 510)) & ~0x1F) === 0 && ((1 << (_la - 510)) & 3751780349) !== 0) || ((((_la - 542)) & ~0x1F) === 0 && ((1 << (_la - 542)) & 2141183997) !== 0) || ((((_la - 575)) & ~0x1F) === 0 && ((1 << (_la - 575)) & 2147483629) !== 0) || ((((_la - 633)) & ~0x1F) === 0 && ((1 << (_la - 633)) & 4294934527) !== 0) || ((((_la - 665)) & ~0x1F) === 0 && ((1 << (_la - 665)) & 4278189053) !== 0) || ((((_la - 697)) & ~0x1F) === 0 && ((1 << (_la - 697)) & 1644099327) !== 0) || ((((_la - 729)) & ~0x1F) === 0 && ((1 << (_la - 729)) & 4294900735) !== 0) || ((((_la - 761)) & ~0x1F) === 0 && ((1 << (_la - 761)) & 4294967295) !== 0) || ((((_la - 793)) & ~0x1F) === 0 && ((1 << (_la - 793)) & 4288675839) !== 0) || ((((_la - 825)) & ~0x1F) === 0 && ((1 << (_la - 825)) & 2147527671) !== 0) || ((((_la - 879)) & ~0x1F) === 0 && ((1 << (_la - 879)) & 1033) !== 0)) { + { + this.state = 5046; + localContext._end_label = this.uid(); + } + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + cursorStatement() { + let localContext = new CursorStatementContext(this.context, this.state); + this.enterRule(localContext, 436, MySqlParser.RULE_cursorStatement); + let _la; + try { + this.state = 5064; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_CLOSE: + localContext = new CloseCursorContext(localContext); + this.enterOuterAlt(localContext, 1); + { + this.state = 5049; + this.match(MySqlParser.KW_CLOSE); + this.state = 5050; + localContext._cursor_name = this.uid(); + } + break; + case MySqlParser.KW_FETCH: + localContext = new FetchCursorContext(localContext); + this.enterOuterAlt(localContext, 2); + { + this.state = 5051; + this.match(MySqlParser.KW_FETCH); + this.state = 5056; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 715, this.context)) { + case 1: + { + this.state = 5053; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 501) { + { + this.state = 5052; + this.match(MySqlParser.KW_NEXT); + } + } + this.state = 5055; + this.match(MySqlParser.KW_FROM); + } + break; + } + this.state = 5058; + localContext._cursor_name = this.uid(); + this.state = 5059; + this.match(MySqlParser.KW_INTO); + this.state = 5060; + localContext._var_names = this.uidList(); + } + break; + case MySqlParser.KW_OPEN: + localContext = new OpenCursorContext(localContext); + this.enterOuterAlt(localContext, 3); + { + this.state = 5062; + this.match(MySqlParser.KW_OPEN); + this.state = 5063; + localContext._cursor_name = this.uid(); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + declareVariable() { + let localContext = new DeclareVariableContext(this.context, this.state); + this.enterRule(localContext, 438, MySqlParser.RULE_declareVariable); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 5066; + this.match(MySqlParser.KW_DECLARE); + this.state = 5067; + localContext._var_names = this.uidList(); + this.state = 5068; + this.dataType(); + this.state = 5071; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 42) { + { + this.state = 5069; + this.match(MySqlParser.KW_DEFAULT); + this.state = 5070; + this.expression(0); + } + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + declareCondition() { + let localContext = new DeclareConditionContext(this.context, this.state); + this.enterRule(localContext, 440, MySqlParser.RULE_declareCondition); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 5073; + this.match(MySqlParser.KW_DECLARE); + this.state = 5074; + localContext._condition_name = this.uid(); + this.state = 5075; + this.match(MySqlParser.KW_CONDITION); + this.state = 5076; + this.match(MySqlParser.KW_FOR); + this.state = 5083; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.ZERO_DECIMAL: + case MySqlParser.ONE_DECIMAL: + case MySqlParser.TWO_DECIMAL: + case MySqlParser.THREE_DECIMAL: + case MySqlParser.DECIMAL_LITERAL: + case MySqlParser.REAL_LITERAL: + { + this.state = 5077; + this.decimalLiteral(); + } + break; + case MySqlParser.KW_SQLSTATE: + { + this.state = 5078; + this.match(MySqlParser.KW_SQLSTATE); + this.state = 5080; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 682) { + { + this.state = 5079; + this.match(MySqlParser.KW_VALUE); + } + } + this.state = 5082; + this.match(MySqlParser.STRING_LITERAL); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + declareCursor() { + let localContext = new DeclareCursorContext(this.context, this.state); + this.enterRule(localContext, 442, MySqlParser.RULE_declareCursor); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 5085; + this.match(MySqlParser.KW_DECLARE); + this.state = 5086; + localContext._condition_name = this.uid(); + this.state = 5087; + this.match(MySqlParser.KW_CURSOR); + this.state = 5088; + this.match(MySqlParser.KW_FOR); + this.state = 5089; + this.selectStatement(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + declareHandler() { + let localContext = new DeclareHandlerContext(this.context, this.state); + this.enterRule(localContext, 444, MySqlParser.RULE_declareHandler); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 5091; + this.match(MySqlParser.KW_DECLARE); + this.state = 5092; + localContext._handlerAction = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 32 || _la === 61 || _la === 180)) { + localContext._handlerAction = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 5093; + this.match(MySqlParser.KW_HANDLER); + this.state = 5094; + this.match(MySqlParser.KW_FOR); + this.state = 5095; + this.handlerConditionValue(); + this.state = 5100; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 5096; + this.match(MySqlParser.COMMA); + this.state = 5097; + this.handlerConditionValue(); + } + } + this.state = 5102; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 5103; + this.routineBody(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + handlerConditionValue() { + let localContext = new HandlerConditionValueContext(this.context, this.state); + this.enterRule(localContext, 446, MySqlParser.RULE_handlerConditionValue); + let _la; + try { + this.state = 5116; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.ZERO_DECIMAL: + case MySqlParser.ONE_DECIMAL: + case MySqlParser.TWO_DECIMAL: + case MySqlParser.THREE_DECIMAL: + case MySqlParser.DECIMAL_LITERAL: + case MySqlParser.REAL_LITERAL: + localContext = new HandlerConditionCodeContext(localContext); + this.enterOuterAlt(localContext, 1); + { + this.state = 5105; + this.decimalLiteral(); + } + break; + case MySqlParser.KW_SQLSTATE: + localContext = new HandlerConditionStateContext(localContext); + this.enterOuterAlt(localContext, 2); + { + this.state = 5106; + this.match(MySqlParser.KW_SQLSTATE); + this.state = 5108; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 682) { + { + this.state = 5107; + this.match(MySqlParser.KW_VALUE); + } + } + this.state = 5110; + this.match(MySqlParser.STRING_LITERAL); + } + break; + case MySqlParser.KW_ARRAY: + case MySqlParser.KW_ATTRIBUTE: + case MySqlParser.KW_BUCKETS: + case MySqlParser.KW_CONDITION: + case MySqlParser.KW_CURRENT: + case MySqlParser.KW_CURRENT_USER: + case MySqlParser.KW_DATABASE: + case MySqlParser.KW_DEFAULT: + case MySqlParser.KW_DIAGNOSTICS: + case MySqlParser.KW_EMPTY: + case MySqlParser.KW_ENFORCED: + case MySqlParser.KW_EXCEPT: + case MySqlParser.KW_GROUP: + case MySqlParser.KW_IF: + case MySqlParser.KW_INSERT: + case MySqlParser.KW_LATERAL: + case MySqlParser.KW_LEFT: + case MySqlParser.KW_NUMBER: + case MySqlParser.KW_OPTIONAL: + case MySqlParser.KW_ORDER: + case MySqlParser.KW_PRIMARY: + case MySqlParser.KW_REPEAT: + case MySqlParser.KW_REPLACE: + case MySqlParser.KW_RIGHT: + case MySqlParser.KW_SCHEMA: + case MySqlParser.KW_SKIP_QUERY_REWRITE: + case MySqlParser.KW_STACKED: + case MySqlParser.KW_DATE: + case MySqlParser.KW_TIME: + case MySqlParser.KW_TIMESTAMP: + case MySqlParser.KW_DATETIME: + case MySqlParser.KW_YEAR: + case MySqlParser.KW_BINARY: + case MySqlParser.KW_TEXT: + case MySqlParser.KW_ENUM: + case MySqlParser.KW_SERIAL: + case MySqlParser.KW_JSON_TABLE: + case MySqlParser.KW_JSON_VALUE: + case MySqlParser.KW_NESTED: + case MySqlParser.KW_ORDINALITY: + case MySqlParser.KW_PATH: + case MySqlParser.KW_AVG: + case MySqlParser.KW_BIT_AND: + case MySqlParser.KW_BIT_OR: + case MySqlParser.KW_BIT_XOR: + case MySqlParser.KW_COUNT: + case MySqlParser.KW_CUME_DIST: + case MySqlParser.KW_DENSE_RANK: + case MySqlParser.KW_FIRST_VALUE: + case MySqlParser.KW_GROUP_CONCAT: + case MySqlParser.KW_LAG: + case MySqlParser.KW_LAST_VALUE: + case MySqlParser.KW_LEAD: + case MySqlParser.KW_MAX: + case MySqlParser.KW_MIN: + case MySqlParser.KW_NTILE: + case MySqlParser.KW_NTH_VALUE: + case MySqlParser.KW_PERCENT_RANK: + case MySqlParser.KW_RANK: + case MySqlParser.KW_ROW_NUMBER: + case MySqlParser.KW_STD: + case MySqlParser.KW_STDDEV: + case MySqlParser.KW_STDDEV_POP: + case MySqlParser.KW_STDDEV_SAMP: + case MySqlParser.KW_SUM: + case MySqlParser.KW_VAR_POP: + case MySqlParser.KW_VAR_SAMP: + case MySqlParser.KW_VARIANCE: + case MySqlParser.KW_CURRENT_DATE: + case MySqlParser.KW_CURRENT_TIME: + case MySqlParser.KW_CURRENT_TIMESTAMP: + case MySqlParser.KW_LOCALTIME: + case MySqlParser.KW_CURDATE: + case MySqlParser.KW_CURTIME: + case MySqlParser.KW_DATE_ADD: + case MySqlParser.KW_DATE_SUB: + case MySqlParser.KW_LOCALTIMESTAMP: + case MySqlParser.KW_NOW: + case MySqlParser.KW_POSITION: + case MySqlParser.KW_SUBSTR: + case MySqlParser.KW_SUBSTRING: + case MySqlParser.KW_SYSDATE: + case MySqlParser.KW_TRIM: + case MySqlParser.KW_UTC_DATE: + case MySqlParser.KW_UTC_TIME: + case MySqlParser.KW_UTC_TIMESTAMP: + case MySqlParser.KW_ACCOUNT: + case MySqlParser.KW_ACTION: + case MySqlParser.KW_AFTER: + case MySqlParser.KW_AGGREGATE: + case MySqlParser.KW_ALGORITHM: + case MySqlParser.KW_ANY: + case MySqlParser.KW_AT: + case MySqlParser.KW_AUTHORS: + case MySqlParser.KW_AUTOCOMMIT: + case MySqlParser.KW_AUTOEXTEND_SIZE: + case MySqlParser.KW_AUTO_INCREMENT: + case MySqlParser.KW_AVG_ROW_LENGTH: + case MySqlParser.KW_BEGIN: + case MySqlParser.KW_BINLOG: + case MySqlParser.KW_BIT: + case MySqlParser.KW_BLOCK: + case MySqlParser.KW_BOOL: + case MySqlParser.KW_BOOLEAN: + case MySqlParser.KW_BTREE: + case MySqlParser.KW_CACHE: + case MySqlParser.KW_CASCADED: + case MySqlParser.KW_CHAIN: + case MySqlParser.KW_CHANGED: + case MySqlParser.KW_CHANNEL: + case MySqlParser.KW_CHECKSUM: + case MySqlParser.KW_CIPHER: + case MySqlParser.KW_CLASS_ORIGIN: + case MySqlParser.KW_CLIENT: + case MySqlParser.KW_CLOSE: + case MySqlParser.KW_COALESCE: + case MySqlParser.KW_CODE: + case MySqlParser.KW_COLUMNS: + case MySqlParser.KW_COLUMN_FORMAT: + case MySqlParser.KW_COLUMN_NAME: + case MySqlParser.KW_COMMENT: + case MySqlParser.KW_COMMIT: + case MySqlParser.KW_COMPACT: + case MySqlParser.KW_COMPLETION: + case MySqlParser.KW_COMPRESSED: + case MySqlParser.KW_COMPRESSION: + case MySqlParser.KW_CONCURRENT: + case MySqlParser.KW_CONNECT: + case MySqlParser.KW_CONNECTION: + case MySqlParser.KW_CONSISTENT: + case MySqlParser.KW_CONSTRAINT_CATALOG: + case MySqlParser.KW_CONSTRAINT_SCHEMA: + case MySqlParser.KW_CONSTRAINT_NAME: + case MySqlParser.KW_CONTAINS: + case MySqlParser.KW_CONTEXT: + case MySqlParser.KW_CONTRIBUTORS: + case MySqlParser.KW_COPY: + case MySqlParser.KW_CPU: + case MySqlParser.KW_CURSOR_NAME: + case MySqlParser.KW_DATA: + case MySqlParser.KW_DATAFILE: + case MySqlParser.KW_DEALLOCATE: + case MySqlParser.KW_DEFAULT_AUTH: + case MySqlParser.KW_DEFINER: + case MySqlParser.KW_DELAY_KEY_WRITE: + case MySqlParser.KW_DES_KEY_FILE: + case MySqlParser.KW_DIRECTORY: + case MySqlParser.KW_DISABLE: + case MySqlParser.KW_DISCARD: + case MySqlParser.KW_DISK: + case MySqlParser.KW_DO: + case MySqlParser.KW_DUMPFILE: + case MySqlParser.KW_DUPLICATE: + case MySqlParser.KW_DYNAMIC: + case MySqlParser.KW_ENABLE: + case MySqlParser.KW_ENCRYPTION: + case MySqlParser.KW_END: + case MySqlParser.KW_ENDS: + case MySqlParser.KW_ENGINE: + case MySqlParser.KW_ENGINES: + case MySqlParser.KW_ERROR: + case MySqlParser.KW_ERRORS: + case MySqlParser.KW_ESCAPE: + case MySqlParser.KW_EVENT: + case MySqlParser.KW_EVENTS: + case MySqlParser.KW_EVERY: + case MySqlParser.KW_EXCHANGE: + case MySqlParser.KW_EXCLUSIVE: + case MySqlParser.KW_EXPIRE: + case MySqlParser.KW_EXPORT: + case MySqlParser.KW_EXTENDED: + case MySqlParser.KW_EXTENT_SIZE: + case MySqlParser.KW_FAILED_LOGIN_ATTEMPTS: + case MySqlParser.KW_FAST: + case MySqlParser.KW_FAULTS: + case MySqlParser.KW_FIELDS: + case MySqlParser.KW_FILE_BLOCK_SIZE: + case MySqlParser.KW_FILTER: + case MySqlParser.KW_FIRST: + case MySqlParser.KW_FIXED: + case MySqlParser.KW_FLUSH: + case MySqlParser.KW_FOLLOWS: + case MySqlParser.KW_FOUND: + case MySqlParser.KW_FULL: + case MySqlParser.KW_FUNCTION: + case MySqlParser.KW_GENERAL: + case MySqlParser.KW_GLOBAL: + case MySqlParser.KW_GRANTS: + case MySqlParser.KW_GROUP_REPLICATION: + case MySqlParser.KW_HANDLER: + case MySqlParser.KW_HASH: + case MySqlParser.KW_HELP: + case MySqlParser.KW_HISTORY: + case MySqlParser.KW_HOST: + case MySqlParser.KW_HOSTS: + case MySqlParser.KW_IDENTIFIED: + case MySqlParser.KW_IGNORE_SERVER_IDS: + case MySqlParser.KW_IMPORT: + case MySqlParser.KW_INDEXES: + case MySqlParser.KW_INITIAL_SIZE: + case MySqlParser.KW_INPLACE: + case MySqlParser.KW_INSERT_METHOD: + case MySqlParser.KW_INSTALL: + case MySqlParser.KW_INSTANCE: + case MySqlParser.KW_INSTANT: + case MySqlParser.KW_INVISIBLE: + case MySqlParser.KW_INVOKER: + case MySqlParser.KW_IO: + case MySqlParser.KW_IO_THREAD: + case MySqlParser.KW_IPC: + case MySqlParser.KW_ISOLATION: + case MySqlParser.KW_ISSUER: + case MySqlParser.KW_JSON: + case MySqlParser.KW_KEY_BLOCK_SIZE: + case MySqlParser.KW_LANGUAGE: + case MySqlParser.KW_LAST: + case MySqlParser.KW_LEAVES: + case MySqlParser.KW_LESS: + case MySqlParser.KW_LEVEL: + case MySqlParser.KW_LIST: + case MySqlParser.KW_LOCAL: + case MySqlParser.KW_LOGFILE: + case MySqlParser.KW_LOGS: + case MySqlParser.KW_MASTER: + case MySqlParser.KW_MASTER_AUTO_POSITION: + case MySqlParser.KW_MASTER_CONNECT_RETRY: + case MySqlParser.KW_MASTER_DELAY: + case MySqlParser.KW_MASTER_HEARTBEAT_PERIOD: + case MySqlParser.KW_MASTER_HOST: + case MySqlParser.KW_MASTER_LOG_FILE: + case MySqlParser.KW_MASTER_LOG_POS: + case MySqlParser.KW_MASTER_PASSWORD: + case MySqlParser.KW_MASTER_PORT: + case MySqlParser.KW_MASTER_RETRY_COUNT: + case MySqlParser.KW_MASTER_SSL: + case MySqlParser.KW_MASTER_SSL_CA: + case MySqlParser.KW_MASTER_SSL_CAPATH: + case MySqlParser.KW_MASTER_SSL_CERT: + case MySqlParser.KW_MASTER_SSL_CIPHER: + case MySqlParser.KW_MASTER_SSL_CRL: + case MySqlParser.KW_MASTER_SSL_CRLPATH: + case MySqlParser.KW_MASTER_SSL_KEY: + case MySqlParser.KW_MASTER_TLS_VERSION: + case MySqlParser.KW_MASTER_USER: + case MySqlParser.KW_MAX_CONNECTIONS_PER_HOUR: + case MySqlParser.KW_MAX_QUERIES_PER_HOUR: + case MySqlParser.KW_MAX_ROWS: + case MySqlParser.KW_MAX_SIZE: + case MySqlParser.KW_MAX_UPDATES_PER_HOUR: + case MySqlParser.KW_MAX_USER_CONNECTIONS: + case MySqlParser.KW_MEDIUM: + case MySqlParser.KW_MEMBER: + case MySqlParser.KW_MERGE: + case MySqlParser.KW_MESSAGE_TEXT: + case MySqlParser.KW_MID: + case MySqlParser.KW_MIGRATE: + case MySqlParser.KW_MIN_ROWS: + case MySqlParser.KW_MODE: + case MySqlParser.KW_MODIFY: + case MySqlParser.KW_MUTEX: + case MySqlParser.KW_MYSQL: + case MySqlParser.KW_MYSQL_ERRNO: + case MySqlParser.KW_NAME: + case MySqlParser.KW_NAMES: + case MySqlParser.KW_NCHAR: + case MySqlParser.KW_NEVER: + case MySqlParser.KW_NEXT: + case MySqlParser.KW_NO: + case MySqlParser.KW_NOWAIT: + case MySqlParser.KW_NODEGROUP: + case MySqlParser.KW_NONE: + case MySqlParser.KW_ODBC: + case MySqlParser.KW_OFFLINE: + case MySqlParser.KW_OFFSET: + case MySqlParser.KW_OF: + case MySqlParser.KW_OLD_PASSWORD: + case MySqlParser.KW_ONE: + case MySqlParser.KW_ONLINE: + case MySqlParser.KW_ONLY: + case MySqlParser.KW_OPEN: + case MySqlParser.KW_OPTIMIZER_COSTS: + case MySqlParser.KW_OPTIONS: + case MySqlParser.KW_OWNER: + case MySqlParser.KW_PACK_KEYS: + case MySqlParser.KW_PAGE: + case MySqlParser.KW_PAGE_CHECKSUM: + case MySqlParser.KW_PARSER: + case MySqlParser.KW_PARTIAL: + case MySqlParser.KW_PARTITIONING: + case MySqlParser.KW_PARTITIONS: + case MySqlParser.KW_PASSWORD: + case MySqlParser.KW_PASSWORD_LOCK_TIME: + case MySqlParser.KW_PHASE: + case MySqlParser.KW_PLUGIN: + case MySqlParser.KW_PLUGIN_DIR: + case MySqlParser.KW_PLUGINS: + case MySqlParser.KW_PORT: + case MySqlParser.KW_PRECEDES: + case MySqlParser.KW_PREPARE: + case MySqlParser.KW_PRESERVE: + case MySqlParser.KW_PREV: + case MySqlParser.KW_PROCESSLIST: + case MySqlParser.KW_PROFILE: + case MySqlParser.KW_PROFILES: + case MySqlParser.KW_PROXY: + case MySqlParser.KW_QUERY: + case MySqlParser.KW_QUICK: + case MySqlParser.KW_REBUILD: + case MySqlParser.KW_RECOVER: + case MySqlParser.KW_RECURSIVE: + case MySqlParser.KW_REDO_BUFFER_SIZE: + case MySqlParser.KW_REDUNDANT: + case MySqlParser.KW_RELAY: + case MySqlParser.KW_RELAY_LOG_FILE: + case MySqlParser.KW_RELAY_LOG_POS: + case MySqlParser.KW_RELAYLOG: + case MySqlParser.KW_REMOVE: + case MySqlParser.KW_REORGANIZE: + case MySqlParser.KW_REPAIR: + case MySqlParser.KW_REPLICATE_DO_DB: + case MySqlParser.KW_REPLICATE_DO_TABLE: + case MySqlParser.KW_REPLICATE_IGNORE_DB: + case MySqlParser.KW_REPLICATE_IGNORE_TABLE: + case MySqlParser.KW_REPLICATE_REWRITE_DB: + case MySqlParser.KW_REPLICATE_WILD_DO_TABLE: + case MySqlParser.KW_REPLICATE_WILD_IGNORE_TABLE: + case MySqlParser.KW_REPLICATION: + case MySqlParser.KW_RESET: + case MySqlParser.KW_RESUME: + case MySqlParser.KW_RETURNED_SQLSTATE: + case MySqlParser.KW_RETURNS: + case MySqlParser.KW_REUSE: + case MySqlParser.KW_ROLE: + case MySqlParser.KW_ROLLBACK: + case MySqlParser.KW_ROLLUP: + case MySqlParser.KW_ROTATE: + case MySqlParser.KW_ROW: + case MySqlParser.KW_ROWS: + case MySqlParser.KW_ROW_FORMAT: + case MySqlParser.KW_SAVEPOINT: + case MySqlParser.KW_SCHEDULE: + case MySqlParser.KW_SECURITY: + case MySqlParser.KW_SERVER: + case MySqlParser.KW_SESSION: + case MySqlParser.KW_SHARE: + case MySqlParser.KW_SHARED: + case MySqlParser.KW_SIGNED: + case MySqlParser.KW_SIMPLE: + case MySqlParser.KW_SLAVE: + case MySqlParser.KW_SLOW: + case MySqlParser.KW_SNAPSHOT: + case MySqlParser.KW_SOCKET: + case MySqlParser.KW_SOME: + case MySqlParser.KW_SONAME: + case MySqlParser.KW_SOUNDS: + case MySqlParser.KW_SOURCE: + case MySqlParser.KW_SQL_AFTER_GTIDS: + case MySqlParser.KW_SQL_AFTER_MTS_GAPS: + case MySqlParser.KW_SQL_BEFORE_GTIDS: + case MySqlParser.KW_SQL_BUFFER_RESULT: + case MySqlParser.KW_SQL_CACHE: + case MySqlParser.KW_SQL_NO_CACHE: + case MySqlParser.KW_SQL_THREAD: + case MySqlParser.KW_START: + case MySqlParser.KW_STARTS: + case MySqlParser.KW_STATS_AUTO_RECALC: + case MySqlParser.KW_STATS_PERSISTENT: + case MySqlParser.KW_STATS_SAMPLE_PAGES: + case MySqlParser.KW_STATUS: + case MySqlParser.KW_STOP: + case MySqlParser.KW_STORAGE: + case MySqlParser.KW_STRING: + case MySqlParser.KW_SUBCLASS_ORIGIN: + case MySqlParser.KW_SUBJECT: + case MySqlParser.KW_SUBPARTITION: + case MySqlParser.KW_SUBPARTITIONS: + case MySqlParser.KW_SUSPEND: + case MySqlParser.KW_SWAPS: + case MySqlParser.KW_SWITCHES: + case MySqlParser.KW_TABLE_NAME: + case MySqlParser.KW_TABLESPACE: + case MySqlParser.KW_TABLE_TYPE: + case MySqlParser.KW_TEMPORARY: + case MySqlParser.KW_TEMPTABLE: + case MySqlParser.KW_THAN: + case MySqlParser.KW_TRADITIONAL: + case MySqlParser.KW_TRANSACTION: + case MySqlParser.KW_TRANSACTIONAL: + case MySqlParser.KW_TRIGGERS: + case MySqlParser.KW_TRUNCATE: + case MySqlParser.KW_UNBOUNDED: + case MySqlParser.KW_UNDEFINED: + case MySqlParser.KW_UNDOFILE: + case MySqlParser.KW_UNDO_BUFFER_SIZE: + case MySqlParser.KW_UNINSTALL: + case MySqlParser.KW_UNKNOWN: + case MySqlParser.KW_UNTIL: + case MySqlParser.KW_UPGRADE: + case MySqlParser.KW_USER: + case MySqlParser.KW_USE_FRM: + case MySqlParser.KW_USER_RESOURCES: + case MySqlParser.KW_VALIDATION: + case MySqlParser.KW_VALUE: + case MySqlParser.KW_VARIABLES: + case MySqlParser.KW_VIEW: + case MySqlParser.KW_VIRTUAL: + case MySqlParser.KW_VISIBLE: + case MySqlParser.KW_WAIT: + case MySqlParser.KW_WARNINGS: + case MySqlParser.KW_WITHOUT: + case MySqlParser.KW_WORK: + case MySqlParser.KW_WRAPPER: + case MySqlParser.KW_X509: + case MySqlParser.KW_XA: + case MySqlParser.KW_XML: + case MySqlParser.KW_QUARTER: + case MySqlParser.KW_MONTH: + case MySqlParser.KW_DAY: + case MySqlParser.KW_HOUR: + case MySqlParser.KW_MINUTE: + case MySqlParser.KW_WEEK: + case MySqlParser.KW_SECOND: + case MySqlParser.KW_MICROSECOND: + case MySqlParser.KW_ADMIN: + case MySqlParser.KW_AUDIT_ABORT_EXEMPT: + case MySqlParser.KW_AUDIT_ADMIN: + case MySqlParser.KW_AUTHENTICATION_POLICY_ADMIN: + case MySqlParser.KW_BACKUP_ADMIN: + case MySqlParser.KW_BINLOG_ADMIN: + case MySqlParser.KW_BINLOG_ENCRYPTION_ADMIN: + case MySqlParser.KW_CLONE_ADMIN: + case MySqlParser.KW_CONNECTION_ADMIN: + case MySqlParser.KW_ENCRYPTION_KEY_ADMIN: + case MySqlParser.KW_EXECUTE: + case MySqlParser.KW_FILE: + case MySqlParser.KW_FIREWALL_ADMIN: + case MySqlParser.KW_FIREWALL_EXEMPT: + case MySqlParser.KW_FIREWALL_USER: + case MySqlParser.KW_GROUP_REPLICATION_ADMIN: + case MySqlParser.KW_INNODB_REDO_LOG_ARCHIVE: + case MySqlParser.KW_INVOKE: + case MySqlParser.KW_LAMBDA: + case MySqlParser.KW_NDB_STORED_USER: + case MySqlParser.KW_PASSWORDLESS_USER_ADMIN: + case MySqlParser.KW_PERSIST_RO_VARIABLES_ADMIN: + case MySqlParser.KW_PRIVILEGES: + case MySqlParser.KW_PROCESS: + case MySqlParser.KW_RELOAD: + case MySqlParser.KW_REPLICATION_APPLIER: + case MySqlParser.KW_REPLICATION_SLAVE_ADMIN: + case MySqlParser.KW_RESOURCE_GROUP_ADMIN: + case MySqlParser.KW_RESOURCE_GROUP_USER: + case MySqlParser.KW_ROLE_ADMIN: + case MySqlParser.KW_ROUTINE: + case MySqlParser.KW_S3: + case MySqlParser.KW_SESSION_VARIABLES_ADMIN: + case MySqlParser.KW_SET_USER_ID: + case MySqlParser.KW_SHOW_ROUTINE: + case MySqlParser.KW_SHUTDOWN: + case MySqlParser.KW_SUPER: + case MySqlParser.KW_SYSTEM_VARIABLES_ADMIN: + case MySqlParser.KW_TABLES: + case MySqlParser.KW_TABLE_ENCRYPTION_ADMIN: + case MySqlParser.KW_VERSION_TOKEN_ADMIN: + case MySqlParser.KW_XA_RECOVER_ADMIN: + case MySqlParser.KW_ARMSCII8: + case MySqlParser.KW_ASCII: + case MySqlParser.KW_BIG5: + case MySqlParser.KW_CP1250: + case MySqlParser.KW_CP1251: + case MySqlParser.KW_CP1256: + case MySqlParser.KW_CP1257: + case MySqlParser.KW_CP850: + case MySqlParser.KW_CP852: + case MySqlParser.KW_CP866: + case MySqlParser.KW_CP932: + case MySqlParser.KW_DEC8: + case MySqlParser.KW_EUCJPMS: + case MySqlParser.KW_EUCKR: + case MySqlParser.KW_GB18030: + case MySqlParser.KW_GB2312: + case MySqlParser.KW_GBK: + case MySqlParser.KW_GEOSTD8: + case MySqlParser.KW_GREEK: + case MySqlParser.KW_HEBREW: + case MySqlParser.KW_HP8: + case MySqlParser.KW_KEYBCS2: + case MySqlParser.KW_KOI8R: + case MySqlParser.KW_KOI8U: + case MySqlParser.KW_LATIN1: + case MySqlParser.KW_LATIN2: + case MySqlParser.KW_LATIN5: + case MySqlParser.KW_LATIN7: + case MySqlParser.KW_MACCE: + case MySqlParser.KW_MACROMAN: + case MySqlParser.KW_SJIS: + case MySqlParser.KW_SWE7: + case MySqlParser.KW_TIS620: + case MySqlParser.KW_UCS2: + case MySqlParser.KW_UJIS: + case MySqlParser.KW_UTF16: + case MySqlParser.KW_UTF16LE: + case MySqlParser.KW_UTF32: + case MySqlParser.KW_UTF8: + case MySqlParser.KW_UTF8MB3: + case MySqlParser.KW_UTF8MB4: + case MySqlParser.KW_ARCHIVE: + case MySqlParser.KW_BLACKHOLE: + case MySqlParser.KW_CSV: + case MySqlParser.KW_FEDERATED: + case MySqlParser.KW_INNODB: + case MySqlParser.KW_MEMORY: + case MySqlParser.KW_MRG_MYISAM: + case MySqlParser.KW_MYISAM: + case MySqlParser.KW_NDB: + case MySqlParser.KW_NDBCLUSTER: + case MySqlParser.KW_PERFORMANCE_SCHEMA: + case MySqlParser.KW_TOKUDB: + case MySqlParser.KW_REPEATABLE: + case MySqlParser.KW_COMMITTED: + case MySqlParser.KW_UNCOMMITTED: + case MySqlParser.KW_SERIALIZABLE: + case MySqlParser.KW_GEOMETRYCOLLECTION: + case MySqlParser.KW_LINESTRING: + case MySqlParser.KW_MULTILINESTRING: + case MySqlParser.KW_MULTIPOINT: + case MySqlParser.KW_MULTIPOLYGON: + case MySqlParser.KW_POINT: + case MySqlParser.KW_POLYGON: + case MySqlParser.KW_CATALOG_NAME: + case MySqlParser.KW_CHARSET: + case MySqlParser.KW_COLLATION: + case MySqlParser.KW_ENGINE_ATTRIBUTE: + case MySqlParser.KW_FORMAT: + case MySqlParser.KW_GET_FORMAT: + case MySqlParser.KW_RANDOM: + case MySqlParser.KW_REVERSE: + case MySqlParser.KW_ROW_COUNT: + case MySqlParser.KW_SCHEMA_NAME: + case MySqlParser.KW_SECONDARY_ENGINE_ATTRIBUTE: + case MySqlParser.KW_SRID: + case MySqlParser.KW_SYSTEM_USER: + case MySqlParser.KW_TP_CONNECTION_ADMIN: + case MySqlParser.KW_WEIGHT_STRING: + case MySqlParser.MOD: + case MySqlParser.CHARSET_REVERSE_QOUTE_STRING: + case MySqlParser.STRING_LITERAL: + case MySqlParser.ID: + localContext = new HandlerConditionNameContext(localContext); + this.enterOuterAlt(localContext, 3); + { + this.state = 5111; + localContext._condition_name = this.uid(); + } + break; + case MySqlParser.KW_SQLWARNING: + localContext = new HandlerConditionWarningContext(localContext); + this.enterOuterAlt(localContext, 4); + { + this.state = 5112; + this.match(MySqlParser.KW_SQLWARNING); + } + break; + case MySqlParser.KW_NOT: + localContext = new HandlerConditionNotfoundContext(localContext); + this.enterOuterAlt(localContext, 5); + { + this.state = 5113; + this.match(MySqlParser.KW_NOT); + this.state = 5114; + this.match(MySqlParser.KW_FOUND); + } + break; + case MySqlParser.KW_SQLEXCEPTION: + localContext = new HandlerConditionExceptionContext(localContext); + this.enterOuterAlt(localContext, 6); + { + this.state = 5115; + this.match(MySqlParser.KW_SQLEXCEPTION); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + procedureSqlStatement() { + let localContext = new ProcedureSqlStatementContext(this.context, this.state); + this.enterRule(localContext, 448, MySqlParser.RULE_procedureSqlStatement); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 5120; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 723, this.context)) { + case 1: + { + this.state = 5118; + this.compoundStatement(); + } + break; + case 2: + { + this.state = 5119; + this.sqlStatement(); + } + break; + } + this.state = 5122; + this.match(MySqlParser.SEMI); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + caseAlternative() { + let localContext = new CaseAlternativeContext(this.context, this.state); + this.enterRule(localContext, 450, MySqlParser.RULE_caseAlternative); + try { + let alternative; + this.enterOuterAlt(localContext, 1); + { + this.state = 5124; + this.match(MySqlParser.KW_WHEN); + this.state = 5127; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 724, this.context)) { + case 1: + { + this.state = 5125; + this.constant(); + } + break; + case 2: + { + this.state = 5126; + this.expression(0); + } + break; + } + this.state = 5129; + this.match(MySqlParser.KW_THEN); + this.state = 5131; + this.errorHandler.sync(this); + alternative = 1; + do { + switch (alternative) { + case 1: + { + { + this.state = 5130; + this.procedureSqlStatement(); + } + } + break; + default: + throw new antlr.NoViableAltException(this); + } + this.state = 5133; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 725, this.context); + } while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + elifAlternative() { + let localContext = new ElifAlternativeContext(this.context, this.state); + this.enterRule(localContext, 452, MySqlParser.RULE_elifAlternative); + try { + let alternative; + this.enterOuterAlt(localContext, 1); + { + this.state = 5135; + this.match(MySqlParser.KW_ELSEIF); + this.state = 5136; + this.expression(0); + this.state = 5137; + this.match(MySqlParser.KW_THEN); + this.state = 5139; + this.errorHandler.sync(this); + alternative = 1; + do { + switch (alternative) { + case 1: + { + { + this.state = 5138; + this.procedureSqlStatement(); + } + } + break; + default: + throw new antlr.NoViableAltException(this); + } + this.state = 5141; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 726, this.context); + } while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + alterUser() { + let localContext = new AlterUserContext(this.context, this.state); + this.enterRule(localContext, 454, MySqlParser.RULE_alterUser); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 5143; + this.match(MySqlParser.KW_ALTER); + this.state = 5144; + this.match(MySqlParser.KW_USER); + this.state = 5146; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 727, this.context)) { + case 1: + { + this.state = 5145; + this.ifExists(); + } + break; + } + this.state = 5204; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 739, this.context)) { + case 1: + { + { + this.state = 5148; + this.userSpecification(); + this.state = 5153; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 5149; + this.match(MySqlParser.COMMA); + this.state = 5150; + this.userSpecification(); + } + } + this.state = 5155; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + } + break; + case 2: + { + { + this.state = 5156; + this.alterUserAuthOption(); + this.state = 5161; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 5157; + this.match(MySqlParser.COMMA); + this.state = 5158; + this.alterUserAuthOption(); + } + } + this.state = 5163; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 5178; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 144) { + { + this.state = 5164; + this.match(MySqlParser.KW_REQUIRE); + this.state = 5176; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_NONE: + { + this.state = 5165; + this.match(MySqlParser.KW_NONE); + } + break; + case MySqlParser.KW_SSL: + case MySqlParser.KW_CIPHER: + case MySqlParser.KW_ISSUER: + case MySqlParser.KW_SUBJECT: + case MySqlParser.KW_X509: + { + this.state = 5166; + this.tlsOption(); + this.state = 5173; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 11 || _la === 169 || _la === 331 || _la === 441 || _la === 651 || _la === 693) { + { + { + this.state = 5168; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 11) { + { + this.state = 5167; + this.match(MySqlParser.KW_AND); + } + } + this.state = 5170; + this.tlsOption(); + } + } + this.state = 5175; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + } + this.state = 5186; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 735, this.context)) { + case 1: + { + this.state = 5180; + this.match(MySqlParser.KW_WITH); + this.state = 5182; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + do { + { + { + this.state = 5181; + this.userResourceOption(); + } + } + this.state = 5184; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } while (((((_la - 478)) & ~0x1F) === 0 && ((1 << (_la - 478)) & 51) !== 0)); + } + break; + } + this.state = 5192; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 304 || _la === 395 || _la === 529 || _la === 530) { + { + this.state = 5190; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_FAILED_LOGIN_ATTEMPTS: + case MySqlParser.KW_PASSWORD: + case MySqlParser.KW_PASSWORD_LOCK_TIME: + { + this.state = 5188; + this.userPasswordOption(); + } + break; + case MySqlParser.KW_ACCOUNT: + { + this.state = 5189; + this.userLockOption(); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + this.state = 5194; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 5197; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 15 || _la === 340) { + { + this.state = 5195; + _la = this.tokenStream.LA(1); + if (!(_la === 15 || _la === 340)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 5196; + this.match(MySqlParser.STRING_LITERAL); + } + } + } + } + break; + case 3: + { + { + { + this.state = 5199; + this.userOrRoleName(); + } + this.state = 5200; + this.match(MySqlParser.KW_DEFAULT); + this.state = 5201; + this.match(MySqlParser.KW_ROLE); + this.state = 5202; + this.roleOption(); + } + } + break; + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + createUser() { + let localContext = new CreateUserContext(this.context, this.state); + this.enterRule(localContext, 456, MySqlParser.RULE_createUser); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 5206; + this.match(MySqlParser.KW_CREATE); + this.state = 5207; + this.match(MySqlParser.KW_USER); + this.state = 5209; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 78) { + { + this.state = 5208; + this.ifNotExists(); + } + } + this.state = 5211; + this.userName(); + this.state = 5213; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 423) { + { + this.state = 5212; + this.createUserAuthOption(); + } + } + this.state = 5222; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 5215; + this.match(MySqlParser.COMMA); + this.state = 5216; + this.userName(); + this.state = 5218; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 423) { + { + this.state = 5217; + this.createUserAuthOption(); + } + } + } + } + this.state = 5224; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 5228; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 42) { + { + this.state = 5225; + this.match(MySqlParser.KW_DEFAULT); + this.state = 5226; + this.match(MySqlParser.KW_ROLE); + this.state = 5227; + this.roleOption(); + } + } + this.state = 5244; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 144) { + { + this.state = 5230; + this.match(MySqlParser.KW_REQUIRE); + this.state = 5242; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_NONE: + { + this.state = 5231; + this.match(MySqlParser.KW_NONE); + } + break; + case MySqlParser.KW_SSL: + case MySqlParser.KW_CIPHER: + case MySqlParser.KW_ISSUER: + case MySqlParser.KW_SUBJECT: + case MySqlParser.KW_X509: + { + this.state = 5232; + this.tlsOption(); + this.state = 5239; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 11 || _la === 169 || _la === 331 || _la === 441 || _la === 651 || _la === 693) { + { + { + this.state = 5234; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 11) { + { + this.state = 5233; + this.match(MySqlParser.KW_AND); + } + } + this.state = 5236; + this.tlsOption(); + } + } + this.state = 5241; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + } + this.state = 5252; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 750, this.context)) { + case 1: + { + this.state = 5246; + this.match(MySqlParser.KW_WITH); + this.state = 5248; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + do { + { + { + this.state = 5247; + this.userResourceOption(); + } + } + this.state = 5250; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } while (((((_la - 478)) & ~0x1F) === 0 && ((1 << (_la - 478)) & 51) !== 0)); + } + break; + } + this.state = 5258; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 304 || _la === 395 || _la === 529 || _la === 530) { + { + this.state = 5256; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_FAILED_LOGIN_ATTEMPTS: + case MySqlParser.KW_PASSWORD: + case MySqlParser.KW_PASSWORD_LOCK_TIME: + { + this.state = 5254; + this.userPasswordOption(); + } + break; + case MySqlParser.KW_ACCOUNT: + { + this.state = 5255; + this.userLockOption(); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + this.state = 5260; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 5263; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 15 || _la === 340) { + { + this.state = 5261; + _la = this.tokenStream.LA(1); + if (!(_la === 15 || _la === 340)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 5262; + this.match(MySqlParser.STRING_LITERAL); + } + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + dropUser() { + let localContext = new DropUserContext(this.context, this.state); + this.enterRule(localContext, 458, MySqlParser.RULE_dropUser); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 5265; + this.match(MySqlParser.KW_DROP); + this.state = 5266; + this.match(MySqlParser.KW_USER); + this.state = 5268; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 78) { + { + this.state = 5267; + this.ifExists(); + } + } + this.state = 5270; + this.userName(); + this.state = 5275; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 5271; + this.match(MySqlParser.COMMA); + this.state = 5272; + this.userName(); + } + } + this.state = 5277; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + grantStatement() { + let localContext = new GrantStatementContext(this.context, this.state); + this.enterRule(localContext, 460, MySqlParser.RULE_grantStatement); + let _la; + try { + let alternative; + this.state = 5367; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 773, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 5278; + this.match(MySqlParser.KW_GRANT); + this.state = 5279; + this.privelegeClause(); + this.state = 5284; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 5280; + this.match(MySqlParser.COMMA); + this.state = 5281; + this.privelegeClause(); + } + } + this.state = 5286; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 5287; + this.match(MySqlParser.KW_ON); + this.state = 5289; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 757, this.context)) { + case 1: + { + this.state = 5288; + this.privilegeObjectType(); + } + break; + } + this.state = 5291; + this.privilegeLevel(); + this.state = 5292; + this.match(MySqlParser.KW_TO); + this.state = 5302; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 759, this.context)) { + case 1: + { + { + this.state = 5293; + this.userAuthOption(); + this.state = 5298; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 5294; + this.match(MySqlParser.COMMA); + this.state = 5295; + this.userAuthOption(); + } + } + this.state = 5300; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + } + break; + case 2: + { + this.state = 5301; + this.userOrRoleNames(); + } + break; + } + this.state = 5318; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 144) { + { + this.state = 5304; + this.match(MySqlParser.KW_REQUIRE); + this.state = 5316; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_NONE: + { + this.state = 5305; + localContext._tlsNone = this.match(MySqlParser.KW_NONE); + } + break; + case MySqlParser.KW_SSL: + case MySqlParser.KW_CIPHER: + case MySqlParser.KW_ISSUER: + case MySqlParser.KW_SUBJECT: + case MySqlParser.KW_X509: + { + this.state = 5306; + this.tlsOption(); + this.state = 5313; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 11 || _la === 169 || _la === 331 || _la === 441 || _la === 651 || _la === 693) { + { + { + this.state = 5308; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 11) { + { + this.state = 5307; + this.match(MySqlParser.KW_AND); + } + } + this.state = 5310; + this.tlsOption(); + } + } + this.state = 5315; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + } + this.state = 5329; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 766, this.context)) { + case 1: + { + this.state = 5320; + this.match(MySqlParser.KW_WITH); + this.state = 5326; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 765, this.context); + while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER) { + if (alternative === 1) { + { + this.state = 5324; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_GRANT: + { + this.state = 5321; + this.match(MySqlParser.KW_GRANT); + this.state = 5322; + this.match(MySqlParser.KW_OPTION); + } + break; + case MySqlParser.KW_MAX_CONNECTIONS_PER_HOUR: + case MySqlParser.KW_MAX_QUERIES_PER_HOUR: + case MySqlParser.KW_MAX_UPDATES_PER_HOUR: + case MySqlParser.KW_MAX_USER_CONNECTIONS: + { + this.state = 5323; + this.userResourceOption(); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + } + this.state = 5328; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 765, this.context); + } + } + break; + } + this.state = 5338; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 13) { + { + this.state = 5331; + this.match(MySqlParser.KW_AS); + this.state = 5332; + this.userName(); + this.state = 5336; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 767, this.context)) { + case 1: + { + this.state = 5333; + this.match(MySqlParser.KW_WITH); + this.state = 5334; + this.match(MySqlParser.KW_ROLE); + this.state = 5335; + this.roleOption(); + } + break; + } + } + } + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 5340; + this.match(MySqlParser.KW_GRANT); + this.state = 5343; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 769, this.context)) { + case 1: + { + this.state = 5341; + this.match(MySqlParser.KW_PROXY); + this.state = 5342; + this.match(MySqlParser.KW_ON); + } + break; + } + { + this.state = 5345; + this.userOrRoleName(); + } + this.state = 5350; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 5346; + this.match(MySqlParser.COMMA); + { + this.state = 5347; + this.userOrRoleName(); + } + } + } + this.state = 5352; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 5353; + this.match(MySqlParser.KW_TO); + { + this.state = 5354; + this.userOrRoleName(); + } + this.state = 5359; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 5355; + this.match(MySqlParser.COMMA); + { + this.state = 5356; + this.userOrRoleName(); + } + } + } + this.state = 5361; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 5365; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 772, this.context)) { + case 1: + { + this.state = 5362; + this.match(MySqlParser.KW_WITH); + this.state = 5363; + this.match(MySqlParser.KW_ADMIN); + this.state = 5364; + this.match(MySqlParser.KW_OPTION); + } + break; + } + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + roleOption() { + let localContext = new RoleOptionContext(this.context, this.state); + this.enterRule(localContext, 462, MySqlParser.RULE_roleOption); + let _la; + try { + this.state = 5377; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 775, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 5369; + this.match(MySqlParser.KW_DEFAULT); + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 5370; + this.match(MySqlParser.KW_NONE); + } + break; + case 3: + this.enterOuterAlt(localContext, 3); + { + this.state = 5371; + this.match(MySqlParser.KW_ALL); + this.state = 5374; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 59) { + { + this.state = 5372; + this.match(MySqlParser.KW_EXCEPT); + this.state = 5373; + this.userOrRoleNames(); + } + } + } + break; + case 4: + this.enterOuterAlt(localContext, 4); + { + this.state = 5376; + this.userOrRoleNames(); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + grantProxy() { + let localContext = new GrantProxyContext(this.context, this.state); + this.enterRule(localContext, 464, MySqlParser.RULE_grantProxy); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 5379; + this.match(MySqlParser.KW_GRANT); + this.state = 5380; + this.match(MySqlParser.KW_PROXY); + this.state = 5381; + this.match(MySqlParser.KW_ON); + this.state = 5382; + localContext._fromFirst = this.userName(); + this.state = 5383; + this.match(MySqlParser.KW_TO); + this.state = 5384; + localContext._toFirst = this.userName(); + this.state = 5389; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 5385; + this.match(MySqlParser.COMMA); + this.state = 5386; + localContext._userName = this.userName(); + localContext._toOther.push(localContext._userName); + } + } + this.state = 5391; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 5395; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 777, this.context)) { + case 1: + { + this.state = 5392; + this.match(MySqlParser.KW_WITH); + this.state = 5393; + this.match(MySqlParser.KW_GRANT); + this.state = 5394; + this.match(MySqlParser.KW_OPTION); + } + break; + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + alterResourceGroup() { + let localContext = new AlterResourceGroupContext(this.context, this.state); + this.enterRule(localContext, 466, MySqlParser.RULE_alterResourceGroup); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 5397; + this.match(MySqlParser.KW_ALTER); + this.state = 5398; + this.match(MySqlParser.KW_RESOURCE); + this.state = 5399; + this.match(MySqlParser.KW_GROUP); + this.state = 5400; + this.groupName(); + this.state = 5406; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 190) { + { + this.state = 5401; + this.match(MySqlParser.KW_VCPU); + this.state = 5403; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 5402; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 5405; + this.resourceGroupVcpuSpec(); + } + } + this.state = 5413; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 837) { + { + this.state = 5408; + this.match(MySqlParser.KW_THREAD_PRIORITY); + this.state = 5410; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 5409; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 5412; + this.decimalLiteral(); + } + } + this.state = 5419; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 368 || _la === 375) { + { + this.state = 5415; + _la = this.tokenStream.LA(1); + if (!(_la === 368 || _la === 375)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 5417; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 66) { + { + this.state = 5416; + this.match(MySqlParser.KW_FORCE); + } + } + } + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + createResourceGroup() { + let localContext = new CreateResourceGroupContext(this.context, this.state); + this.enterRule(localContext, 468, MySqlParser.RULE_createResourceGroup); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 5421; + this.match(MySqlParser.KW_CREATE); + this.state = 5422; + this.match(MySqlParser.KW_RESOURCE); + this.state = 5423; + this.match(MySqlParser.KW_GROUP); + this.state = 5424; + this.groupNameCreate(); + this.state = 5425; + this.match(MySqlParser.KW_TYPE); + this.state = 5426; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 5427; + _la = this.tokenStream.LA(1); + if (!(_la === 678 || _la === 835)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 5433; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 190) { + { + this.state = 5428; + this.match(MySqlParser.KW_VCPU); + this.state = 5430; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 5429; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 5432; + this.resourceGroupVcpuSpec(); + } + } + this.state = 5440; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 837) { + { + this.state = 5435; + this.match(MySqlParser.KW_THREAD_PRIORITY); + this.state = 5437; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 5436; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 5439; + this.decimalLiteral(); + } + } + this.state = 5443; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 368 || _la === 375) { + { + this.state = 5442; + _la = this.tokenStream.LA(1); + if (!(_la === 368 || _la === 375)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + dropResourceGroup() { + let localContext = new DropResourceGroupContext(this.context, this.state); + this.enterRule(localContext, 470, MySqlParser.RULE_dropResourceGroup); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 5445; + this.match(MySqlParser.KW_DROP); + this.state = 5446; + this.match(MySqlParser.KW_RESOURCE); + this.state = 5447; + this.match(MySqlParser.KW_GROUP); + this.state = 5448; + this.groupName(); + this.state = 5450; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 66) { + { + this.state = 5449; + this.match(MySqlParser.KW_FORCE); + } + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + setResourceGroup() { + let localContext = new SetResourceGroupContext(this.context, this.state); + this.enterRule(localContext, 472, MySqlParser.RULE_setResourceGroup); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 5452; + this.match(MySqlParser.KW_SET); + this.state = 5453; + this.match(MySqlParser.KW_RESOURCE); + this.state = 5454; + this.match(MySqlParser.KW_GROUP); + this.state = 5455; + this.groupName(); + this.state = 5465; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 65) { + { + this.state = 5456; + this.match(MySqlParser.KW_FOR); + this.state = 5457; + this.decimalLiteral(); + this.state = 5462; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 5458; + this.match(MySqlParser.COMMA); + this.state = 5459; + this.decimalLiteral(); + } + } + this.state = 5464; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + resourceGroupVcpuSpec() { + let localContext = new ResourceGroupVcpuSpecContext(this.context, this.state); + this.enterRule(localContext, 474, MySqlParser.RULE_resourceGroupVcpuSpec); + try { + let alternative; + this.enterOuterAlt(localContext, 1); + { + this.state = 5472; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 792, this.context)) { + case 1: + { + this.state = 5467; + this.decimalLiteral(); + } + break; + case 2: + { + this.state = 5468; + this.decimalLiteral(); + this.state = 5469; + this.match(MySqlParser.MINUS); + this.state = 5470; + this.decimalLiteral(); + } + break; + } + this.state = 5478; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 793, this.context); + while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER) { + if (alternative === 1) { + { + { + this.state = 5474; + this.match(MySqlParser.COMMA); + this.state = 5475; + this.resourceGroupVcpuSpec(); + } + } + } + this.state = 5480; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 793, this.context); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + renameUser() { + let localContext = new RenameUserContext(this.context, this.state); + this.enterRule(localContext, 476, MySqlParser.RULE_renameUser); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 5481; + this.match(MySqlParser.KW_RENAME); + this.state = 5482; + this.match(MySqlParser.KW_USER); + this.state = 5483; + this.renameUserClause(); + this.state = 5488; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 5484; + this.match(MySqlParser.COMMA); + this.state = 5485; + this.renameUserClause(); + } + } + this.state = 5490; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + revokeStatement() { + let localContext = new RevokeStatementContext(this.context, this.state); + this.enterRule(localContext, 478, MySqlParser.RULE_revokeStatement); + let _la; + try { + this.state = 5543; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 805, this.context)) { + case 1: + localContext = new DetailRevokeContext(localContext); + this.enterOuterAlt(localContext, 1); + { + this.state = 5491; + this.match(MySqlParser.KW_REVOKE); + this.state = 5493; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 78) { + { + this.state = 5492; + this.ifExists(); + } + } + this.state = 5495; + this.privelegeClause(); + this.state = 5500; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 5496; + this.match(MySqlParser.COMMA); + this.state = 5497; + this.privelegeClause(); + } + } + this.state = 5502; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 5503; + this.match(MySqlParser.KW_ON); + this.state = 5505; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 797, this.context)) { + case 1: + { + this.state = 5504; + this.privilegeObjectType(); + } + break; + } + this.state = 5507; + this.privilegeLevel(); + this.state = 5508; + this.match(MySqlParser.KW_FROM); + this.state = 5509; + this.userOrRoleNames(); + this.state = 5511; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 79) { + { + this.state = 5510; + this.ignoreUnknownUser(); + } + } + } + break; + case 2: + localContext = new ShortRevokeContext(localContext); + this.enterOuterAlt(localContext, 2); + { + this.state = 5513; + this.match(MySqlParser.KW_REVOKE); + this.state = 5515; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 78) { + { + this.state = 5514; + this.ifExists(); + } + } + this.state = 5517; + this.match(MySqlParser.KW_ALL); + this.state = 5519; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 734) { + { + this.state = 5518; + this.match(MySqlParser.KW_PRIVILEGES); + } + } + this.state = 5521; + this.match(MySqlParser.COMMA); + this.state = 5522; + this.match(MySqlParser.KW_GRANT); + this.state = 5523; + this.match(MySqlParser.KW_OPTION); + this.state = 5524; + this.match(MySqlParser.KW_FROM); + this.state = 5525; + this.userOrRoleNames(); + this.state = 5527; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 79) { + { + this.state = 5526; + this.ignoreUnknownUser(); + } + } + } + break; + case 3: + localContext = new ProxyAndRoleRevokeContext(localContext); + this.enterOuterAlt(localContext, 3); + { + this.state = 5529; + this.match(MySqlParser.KW_REVOKE); + this.state = 5531; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 802, this.context)) { + case 1: + { + this.state = 5530; + this.ifExists(); + } + break; + } + this.state = 5535; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 803, this.context)) { + case 1: + { + this.state = 5533; + this.match(MySqlParser.KW_PROXY); + this.state = 5534; + this.match(MySqlParser.KW_ON); + } + break; + } + this.state = 5537; + this.userOrRoleNames(); + this.state = 5538; + this.match(MySqlParser.KW_FROM); + this.state = 5539; + this.userOrRoleNames(); + this.state = 5541; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 79) { + { + this.state = 5540; + this.ignoreUnknownUser(); + } + } + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + ignoreUnknownUser() { + let localContext = new IgnoreUnknownUserContext(this.context, this.state); + this.enterRule(localContext, 480, MySqlParser.RULE_ignoreUnknownUser); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 5545; + this.match(MySqlParser.KW_IGNORE); + this.state = 5546; + this.match(MySqlParser.KW_UNKNOWN); + this.state = 5547; + this.match(MySqlParser.KW_USER); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + privilegeObjectType() { + let localContext = new PrivilegeObjectTypeContext(this.context, this.state); + this.enterRule(localContext, 482, MySqlParser.RULE_privilegeObjectType); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 5549; + _la = this.tokenStream.LA(1); + if (!(_la === 132 || _la === 173 || _la === 409)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + setPasswordStatement() { + let localContext = new SetPasswordStatementContext(this.context, this.state); + this.enterRule(localContext, 484, MySqlParser.RULE_setPasswordStatement); + let _la; + try { + this.state = 5583; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 812, this.context)) { + case 1: + localContext = new V57Context(localContext); + this.enterOuterAlt(localContext, 1); + { + this.state = 5551; + this.match(MySqlParser.KW_SET); + this.state = 5552; + this.match(MySqlParser.KW_PASSWORD); + this.state = 5555; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 65) { + { + this.state = 5553; + this.match(MySqlParser.KW_FOR); + this.state = 5554; + this.userName(); + } + } + this.state = 5557; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 5560; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_OLD_PASSWORD: + case MySqlParser.KW_PASSWORD: + { + this.state = 5558; + this.passwordFunctionClause(); + } + break; + case MySqlParser.STRING_LITERAL: + { + this.state = 5559; + this.match(MySqlParser.STRING_LITERAL); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + break; + case 2: + localContext = new V80Context(localContext); + this.enterOuterAlt(localContext, 2); + { + this.state = 5562; + this.match(MySqlParser.KW_SET); + this.state = 5563; + this.match(MySqlParser.KW_PASSWORD); + this.state = 5566; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 65) { + { + this.state = 5564; + this.match(MySqlParser.KW_FOR); + this.state = 5565; + this.userName(); + } + } + this.state = 5572; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_TO: + { + this.state = 5568; + this.match(MySqlParser.KW_TO); + this.state = 5569; + this.match(MySqlParser.KW_RANDOM); + } + break; + case MySqlParser.EQUAL_SYMBOL: + { + this.state = 5570; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 5571; + this.match(MySqlParser.STRING_LITERAL); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + this.state = 5576; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 810, this.context)) { + case 1: + { + this.state = 5574; + this.match(MySqlParser.KW_REPLACE); + this.state = 5575; + this.match(MySqlParser.STRING_LITERAL); + } + break; + } + this.state = 5581; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 147) { + { + this.state = 5578; + this.match(MySqlParser.KW_RETAIN); + this.state = 5579; + this.match(MySqlParser.KW_CURRENT); + this.state = 5580; + this.match(MySqlParser.KW_PASSWORD); + } + } + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + userSpecification() { + let localContext = new UserSpecificationContext(this.context, this.state); + this.enterRule(localContext, 486, MySqlParser.RULE_userSpecification); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 5585; + this.userName(); + this.state = 5586; + this.userPasswordOption(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + alterUserAuthOption() { + let localContext = new AlterUserAuthOptionContext(this.context, this.state); + this.enterRule(localContext, 488, MySqlParser.RULE_alterUserAuthOption); + let _la; + try { + let alternative; + this.enterOuterAlt(localContext, 1); + { + this.state = 5588; + this.userName(); + this.state = 5614; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 815, this.context)) { + case 1: + { + this.state = 5589; + this.match(MySqlParser.KW_IDENTIFIED); + this.state = 5590; + this.match(MySqlParser.KW_BY); + this.state = 5591; + this.match(MySqlParser.STRING_LITERAL); + this.state = 5592; + this.authOptionClause(); + } + break; + case 2: + { + this.state = 5593; + this.match(MySqlParser.KW_IDENTIFIED); + this.state = 5594; + this.match(MySqlParser.KW_BY); + this.state = 5595; + this.match(MySqlParser.KW_RANDOM); + this.state = 5596; + this.match(MySqlParser.KW_PASSWORD); + this.state = 5597; + this.authOptionClause(); + } + break; + case 3: + { + this.state = 5598; + this.match(MySqlParser.KW_IDENTIFIED); + this.state = 5599; + this.match(MySqlParser.KW_WITH); + this.state = 5600; + this.authenticationRule(); + } + break; + case 4: + { + this.state = 5601; + this.match(MySqlParser.KW_DISCARD); + this.state = 5602; + this.match(MySqlParser.KW_OLD); + this.state = 5603; + this.match(MySqlParser.KW_PASSWORD); + } + break; + case 5: + { + this.state = 5609; + this.errorHandler.sync(this); + alternative = 1; + do { + switch (alternative) { + case 1: + { + { + this.state = 5604; + _la = this.tokenStream.LA(1); + if (!(_la === 6 || _la === 51 || _la === 492)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 5605; + this.factor(); + this.state = 5607; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 423) { + { + this.state = 5606; + this.factorAuthOption(); + } + } + } + } + break; + default: + throw new antlr.NoViableAltException(this); + } + this.state = 5611; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 814, this.context); + } while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER); + } + break; + case 6: + { + this.state = 5613; + this.registrationOption(); + } + break; + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + createUserAuthOption() { + let localContext = new CreateUserAuthOptionContext(this.context, this.state); + this.enterRule(localContext, 490, MySqlParser.RULE_createUserAuthOption); + let _la; + try { + this.state = 5652; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 822, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 5616; + this.match(MySqlParser.KW_IDENTIFIED); + this.state = 5617; + this.match(MySqlParser.KW_BY); + this.state = 5623; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.STRING_LITERAL: + { + this.state = 5618; + this.match(MySqlParser.STRING_LITERAL); + } + break; + case MySqlParser.KW_RANDOM: + { + { + this.state = 5619; + this.match(MySqlParser.KW_RANDOM); + this.state = 5620; + this.match(MySqlParser.KW_PASSWORD); + } + } + break; + case MySqlParser.KW_PASSWORD: + { + { + this.state = 5621; + this.match(MySqlParser.KW_PASSWORD); + this.state = 5622; + this.match(MySqlParser.STRING_LITERAL); + } + } + break; + default: + throw new antlr.NoViableAltException(this); + } + this.state = 5627; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 11) { + { + this.state = 5625; + this.match(MySqlParser.KW_AND); + this.state = 5626; + this.createUserAuthOption(); + } + } + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 5629; + this.match(MySqlParser.KW_IDENTIFIED); + this.state = 5630; + this.match(MySqlParser.KW_WITH); + this.state = 5631; + localContext._authPlugin = this.uid(); + this.state = 5640; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_BY: + { + { + this.state = 5632; + this.match(MySqlParser.KW_BY); + this.state = 5636; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.STRING_LITERAL: + { + this.state = 5633; + this.match(MySqlParser.STRING_LITERAL); + } + break; + case MySqlParser.KW_RANDOM: + { + { + this.state = 5634; + this.match(MySqlParser.KW_RANDOM); + this.state = 5635; + this.match(MySqlParser.KW_PASSWORD); + } + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + } + break; + case MySqlParser.KW_AS: + { + this.state = 5638; + this.match(MySqlParser.KW_AS); + this.state = 5639; + this.match(MySqlParser.STRING_LITERAL); + } + break; + case MySqlParser.EOF: + case MySqlParser.KW_ALTER: + case MySqlParser.KW_ANALYZE: + case MySqlParser.KW_AND: + case MySqlParser.KW_ATTRIBUTE: + case MySqlParser.KW_CALL: + case MySqlParser.KW_CHANGE: + case MySqlParser.KW_CHECK: + case MySqlParser.KW_CREATE: + case MySqlParser.KW_DEFAULT: + case MySqlParser.KW_DELETE: + case MySqlParser.KW_DESC: + case MySqlParser.KW_DESCRIBE: + case MySqlParser.KW_DROP: + case MySqlParser.KW_EXPLAIN: + case MySqlParser.KW_GET: + case MySqlParser.KW_GRANT: + case MySqlParser.KW_INSERT: + case MySqlParser.KW_KILL: + case MySqlParser.KW_LOAD: + case MySqlParser.KW_LOCK: + case MySqlParser.KW_OPTIMIZE: + case MySqlParser.KW_PURGE: + case MySqlParser.KW_RELEASE: + case MySqlParser.KW_RENAME: + case MySqlParser.KW_REPLACE: + case MySqlParser.KW_REQUIRE: + case MySqlParser.KW_RESIGNAL: + case MySqlParser.KW_REVOKE: + case MySqlParser.KW_SELECT: + case MySqlParser.KW_SET: + case MySqlParser.KW_SHOW: + case MySqlParser.KW_SIGNAL: + case MySqlParser.KW_TABLE: + case MySqlParser.KW_UNLOCK: + case MySqlParser.KW_UPDATE: + case MySqlParser.KW_USE: + case MySqlParser.KW_VALUES: + case MySqlParser.KW_WITH: + case MySqlParser.KW_ACCOUNT: + case MySqlParser.KW_BEGIN: + case MySqlParser.KW_BINLOG: + case MySqlParser.KW_CACHE: + case MySqlParser.KW_CHECKSUM: + case MySqlParser.KW_COMMENT: + case MySqlParser.KW_COMMIT: + case MySqlParser.KW_DEALLOCATE: + case MySqlParser.KW_DO: + case MySqlParser.KW_FAILED_LOGIN_ATTEMPTS: + case MySqlParser.KW_FLUSH: + case MySqlParser.KW_HANDLER: + case MySqlParser.KW_HELP: + case MySqlParser.KW_IMPORT: + case MySqlParser.KW_INSTALL: + case MySqlParser.KW_PASSWORD: + case MySqlParser.KW_PASSWORD_LOCK_TIME: + case MySqlParser.KW_PREPARE: + case MySqlParser.KW_REPAIR: + case MySqlParser.KW_RESET: + case MySqlParser.KW_RESTART: + case MySqlParser.KW_ROLLBACK: + case MySqlParser.KW_SAVEPOINT: + case MySqlParser.KW_START: + case MySqlParser.KW_STOP: + case MySqlParser.KW_TRUNCATE: + case MySqlParser.KW_UNINSTALL: + case MySqlParser.KW_XA: + case MySqlParser.KW_CLONE: + case MySqlParser.KW_EXECUTE: + case MySqlParser.KW_SHUTDOWN: + case MySqlParser.LR_BRACKET: + case MySqlParser.COMMA: + case MySqlParser.SEMI: + break; + default: + break; + } + this.state = 5644; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 11) { + { + this.state = 5642; + this.match(MySqlParser.KW_AND); + this.state = 5643; + this.createUserAuthOption(); + } + } + } + break; + case 3: + this.enterOuterAlt(localContext, 3); + { + this.state = 5646; + this.match(MySqlParser.KW_IDENTIFIED); + this.state = 5647; + this.match(MySqlParser.KW_WITH); + this.state = 5648; + localContext._authPlugin = this.uid(); + this.state = 5650; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 427) { + { + this.state = 5649; + this.createUserInitialAuthOption(); + } + } + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + createUserInitialAuthOption() { + let localContext = new CreateUserInitialAuthOptionContext(this.context, this.state); + this.enterRule(localContext, 492, MySqlParser.RULE_createUserInitialAuthOption); + try { + this.state = 5671; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 824, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 5654; + this.match(MySqlParser.KW_INITIAL); + this.state = 5655; + this.match(MySqlParser.KW_AUTHENTICATION); + this.state = 5656; + this.match(MySqlParser.KW_IDENTIFIED); + this.state = 5657; + this.match(MySqlParser.KW_BY); + this.state = 5661; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_RANDOM: + { + { + this.state = 5658; + this.match(MySqlParser.KW_RANDOM); + this.state = 5659; + this.match(MySqlParser.KW_PASSWORD); + } + } + break; + case MySqlParser.STRING_LITERAL: + { + this.state = 5660; + this.match(MySqlParser.STRING_LITERAL); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 5663; + this.match(MySqlParser.KW_INITIAL); + this.state = 5664; + this.match(MySqlParser.KW_AUTHENTICATION); + this.state = 5665; + this.match(MySqlParser.KW_IDENTIFIED); + this.state = 5666; + this.match(MySqlParser.KW_WITH); + this.state = 5667; + localContext._authPlugin = this.uid(); + this.state = 5668; + this.match(MySqlParser.KW_AS); + this.state = 5669; + this.match(MySqlParser.STRING_LITERAL); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + userAuthOption() { + let localContext = new UserAuthOptionContext(this.context, this.state); + this.enterRule(localContext, 494, MySqlParser.RULE_userAuthOption); + try { + this.state = 5698; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 825, this.context)) { + case 1: + localContext = new HashAuthOptionContext(localContext); + this.enterOuterAlt(localContext, 1); + { + this.state = 5673; + this.userName(); + this.state = 5674; + this.match(MySqlParser.KW_IDENTIFIED); + this.state = 5675; + this.match(MySqlParser.KW_BY); + this.state = 5676; + this.match(MySqlParser.KW_PASSWORD); + this.state = 5677; + localContext._hashed = this.match(MySqlParser.STRING_LITERAL); + } + break; + case 2: + localContext = new RandomAuthOptionContext(localContext); + this.enterOuterAlt(localContext, 2); + { + this.state = 5679; + this.userName(); + this.state = 5680; + this.match(MySqlParser.KW_IDENTIFIED); + this.state = 5681; + this.match(MySqlParser.KW_BY); + this.state = 5682; + this.match(MySqlParser.KW_RANDOM); + this.state = 5683; + this.match(MySqlParser.KW_PASSWORD); + this.state = 5684; + this.authOptionClause(); + } + break; + case 3: + localContext = new StringAuthOptionContext(localContext); + this.enterOuterAlt(localContext, 3); + { + this.state = 5686; + this.userName(); + this.state = 5687; + this.match(MySqlParser.KW_IDENTIFIED); + this.state = 5688; + this.match(MySqlParser.KW_BY); + this.state = 5689; + this.match(MySqlParser.STRING_LITERAL); + this.state = 5690; + this.authOptionClause(); + } + break; + case 4: + localContext = new ModuleAuthOptionContext(localContext); + this.enterOuterAlt(localContext, 4); + { + this.state = 5692; + this.userName(); + this.state = 5693; + this.match(MySqlParser.KW_IDENTIFIED); + this.state = 5694; + this.match(MySqlParser.KW_WITH); + this.state = 5695; + this.authenticationRule(); + } + break; + case 5: + localContext = new SimpleAuthOptionContext(localContext); + this.enterOuterAlt(localContext, 5); + { + this.state = 5697; + this.userName(); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + authOptionClause() { + let localContext = new AuthOptionClauseContext(this.context, this.state); + this.enterRule(localContext, 496, MySqlParser.RULE_authOptionClause); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 5702; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 826, this.context)) { + case 1: + { + this.state = 5700; + this.match(MySqlParser.KW_REPLACE); + this.state = 5701; + this.match(MySqlParser.STRING_LITERAL); + } + break; + } + this.state = 5707; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 147) { + { + this.state = 5704; + this.match(MySqlParser.KW_RETAIN); + this.state = 5705; + this.match(MySqlParser.KW_CURRENT); + this.state = 5706; + this.match(MySqlParser.KW_PASSWORD); + } + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + authenticationRule() { + let localContext = new AuthenticationRuleContext(this.context, this.state); + this.enterRule(localContext, 498, MySqlParser.RULE_authenticationRule); + let _la; + try { + this.state = 5723; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 830, this.context)) { + case 1: + localContext = new ModuleContext(localContext); + this.enterOuterAlt(localContext, 1); + { + this.state = 5709; + localContext._authPlugin = this.uid(); + this.state = 5717; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 829, this.context)) { + case 1: + { + this.state = 5710; + _la = this.tokenStream.LA(1); + if (!(_la === 13 || _la === 20 || _la === 188)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 5714; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.STRING_LITERAL: + { + this.state = 5711; + this.match(MySqlParser.STRING_LITERAL); + } + break; + case MySqlParser.KW_RANDOM: + { + this.state = 5712; + this.match(MySqlParser.KW_RANDOM); + this.state = 5713; + this.match(MySqlParser.KW_PASSWORD); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + this.state = 5716; + this.authOptionClause(); + } + break; + } + } + break; + case 2: + localContext = new PasswordModuleOptionContext(localContext); + this.enterOuterAlt(localContext, 2); + { + this.state = 5719; + localContext._authPlugin = this.uid(); + this.state = 5720; + this.match(MySqlParser.KW_USING); + this.state = 5721; + this.passwordFunctionClause(); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + tlsOption() { + let localContext = new TlsOptionContext(this.context, this.state); + this.enterRule(localContext, 500, MySqlParser.RULE_tlsOption); + try { + this.state = 5733; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_SSL: + this.enterOuterAlt(localContext, 1); + { + this.state = 5725; + this.match(MySqlParser.KW_SSL); + } + break; + case MySqlParser.KW_X509: + this.enterOuterAlt(localContext, 2); + { + this.state = 5726; + this.match(MySqlParser.KW_X509); + } + break; + case MySqlParser.KW_CIPHER: + this.enterOuterAlt(localContext, 3); + { + this.state = 5727; + this.match(MySqlParser.KW_CIPHER); + this.state = 5728; + this.match(MySqlParser.STRING_LITERAL); + } + break; + case MySqlParser.KW_ISSUER: + this.enterOuterAlt(localContext, 4); + { + this.state = 5729; + this.match(MySqlParser.KW_ISSUER); + this.state = 5730; + this.match(MySqlParser.STRING_LITERAL); + } + break; + case MySqlParser.KW_SUBJECT: + this.enterOuterAlt(localContext, 5); + { + this.state = 5731; + this.match(MySqlParser.KW_SUBJECT); + this.state = 5732; + this.match(MySqlParser.STRING_LITERAL); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + userResourceOption() { + let localContext = new UserResourceOptionContext(this.context, this.state); + this.enterRule(localContext, 502, MySqlParser.RULE_userResourceOption); + try { + this.state = 5743; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_MAX_QUERIES_PER_HOUR: + this.enterOuterAlt(localContext, 1); + { + this.state = 5735; + this.match(MySqlParser.KW_MAX_QUERIES_PER_HOUR); + this.state = 5736; + this.decimalLiteral(); + } + break; + case MySqlParser.KW_MAX_UPDATES_PER_HOUR: + this.enterOuterAlt(localContext, 2); + { + this.state = 5737; + this.match(MySqlParser.KW_MAX_UPDATES_PER_HOUR); + this.state = 5738; + this.decimalLiteral(); + } + break; + case MySqlParser.KW_MAX_CONNECTIONS_PER_HOUR: + this.enterOuterAlt(localContext, 3); + { + this.state = 5739; + this.match(MySqlParser.KW_MAX_CONNECTIONS_PER_HOUR); + this.state = 5740; + this.decimalLiteral(); + } + break; + case MySqlParser.KW_MAX_USER_CONNECTIONS: + this.enterOuterAlt(localContext, 4); + { + this.state = 5741; + this.match(MySqlParser.KW_MAX_USER_CONNECTIONS); + this.state = 5742; + this.decimalLiteral(); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + userPasswordOption() { + let localContext = new UserPasswordOptionContext(this.context, this.state); + this.enterRule(localContext, 504, MySqlParser.RULE_userPasswordOption); + let _la; + try { + this.state = 5783; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 838, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 5745; + this.match(MySqlParser.KW_PASSWORD); + this.state = 5746; + this.match(MySqlParser.KW_EXPIRE); + this.state = 5753; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_DEFAULT: + { + this.state = 5747; + localContext._expireType = this.match(MySqlParser.KW_DEFAULT); + } + break; + case MySqlParser.KW_NEVER: + { + this.state = 5748; + localContext._expireType = this.match(MySqlParser.KW_NEVER); + } + break; + case MySqlParser.KW_INTERVAL: + { + this.state = 5749; + localContext._expireType = this.match(MySqlParser.KW_INTERVAL); + this.state = 5750; + this.decimalLiteral(); + this.state = 5751; + this.match(MySqlParser.KW_DAY); + } + break; + case MySqlParser.EOF: + case MySqlParser.KW_ALTER: + case MySqlParser.KW_ANALYZE: + case MySqlParser.KW_ATTRIBUTE: + case MySqlParser.KW_CALL: + case MySqlParser.KW_CHANGE: + case MySqlParser.KW_CHECK: + case MySqlParser.KW_CREATE: + case MySqlParser.KW_DELETE: + case MySqlParser.KW_DESC: + case MySqlParser.KW_DESCRIBE: + case MySqlParser.KW_DROP: + case MySqlParser.KW_EXPLAIN: + case MySqlParser.KW_GET: + case MySqlParser.KW_GRANT: + case MySqlParser.KW_INSERT: + case MySqlParser.KW_KILL: + case MySqlParser.KW_LOAD: + case MySqlParser.KW_LOCK: + case MySqlParser.KW_OPTIMIZE: + case MySqlParser.KW_PURGE: + case MySqlParser.KW_RELEASE: + case MySqlParser.KW_RENAME: + case MySqlParser.KW_REPLACE: + case MySqlParser.KW_RESIGNAL: + case MySqlParser.KW_REVOKE: + case MySqlParser.KW_SELECT: + case MySqlParser.KW_SET: + case MySqlParser.KW_SHOW: + case MySqlParser.KW_SIGNAL: + case MySqlParser.KW_TABLE: + case MySqlParser.KW_UNLOCK: + case MySqlParser.KW_UPDATE: + case MySqlParser.KW_USE: + case MySqlParser.KW_VALUES: + case MySqlParser.KW_WITH: + case MySqlParser.KW_ACCOUNT: + case MySqlParser.KW_BEGIN: + case MySqlParser.KW_BINLOG: + case MySqlParser.KW_CACHE: + case MySqlParser.KW_CHECKSUM: + case MySqlParser.KW_COMMENT: + case MySqlParser.KW_COMMIT: + case MySqlParser.KW_DEALLOCATE: + case MySqlParser.KW_DO: + case MySqlParser.KW_FAILED_LOGIN_ATTEMPTS: + case MySqlParser.KW_FLUSH: + case MySqlParser.KW_HANDLER: + case MySqlParser.KW_HELP: + case MySqlParser.KW_IMPORT: + case MySqlParser.KW_INSTALL: + case MySqlParser.KW_PASSWORD: + case MySqlParser.KW_PASSWORD_LOCK_TIME: + case MySqlParser.KW_PREPARE: + case MySqlParser.KW_REPAIR: + case MySqlParser.KW_RESET: + case MySqlParser.KW_RESTART: + case MySqlParser.KW_ROLLBACK: + case MySqlParser.KW_SAVEPOINT: + case MySqlParser.KW_START: + case MySqlParser.KW_STOP: + case MySqlParser.KW_TRUNCATE: + case MySqlParser.KW_UNINSTALL: + case MySqlParser.KW_XA: + case MySqlParser.KW_CLONE: + case MySqlParser.KW_EXECUTE: + case MySqlParser.KW_SHUTDOWN: + case MySqlParser.LR_BRACKET: + case MySqlParser.COMMA: + case MySqlParser.SEMI: + break; + default: + break; + } + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 5755; + this.match(MySqlParser.KW_PASSWORD); + this.state = 5756; + this.match(MySqlParser.KW_HISTORY); + this.state = 5759; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_DEFAULT: + { + this.state = 5757; + this.match(MySqlParser.KW_DEFAULT); + } + break; + case MySqlParser.ZERO_DECIMAL: + case MySqlParser.ONE_DECIMAL: + case MySqlParser.TWO_DECIMAL: + case MySqlParser.THREE_DECIMAL: + case MySqlParser.DECIMAL_LITERAL: + case MySqlParser.REAL_LITERAL: + { + this.state = 5758; + this.decimalLiteral(); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + break; + case 3: + this.enterOuterAlt(localContext, 3); + { + this.state = 5761; + this.match(MySqlParser.KW_PASSWORD); + this.state = 5762; + this.match(MySqlParser.KW_REUSE); + this.state = 5763; + this.match(MySqlParser.KW_INTERVAL); + this.state = 5768; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_DEFAULT: + { + this.state = 5764; + this.match(MySqlParser.KW_DEFAULT); + } + break; + case MySqlParser.ZERO_DECIMAL: + case MySqlParser.ONE_DECIMAL: + case MySqlParser.TWO_DECIMAL: + case MySqlParser.THREE_DECIMAL: + case MySqlParser.DECIMAL_LITERAL: + case MySqlParser.REAL_LITERAL: + { + this.state = 5765; + this.decimalLiteral(); + this.state = 5766; + this.match(MySqlParser.KW_DAY); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + break; + case 4: + this.enterOuterAlt(localContext, 4); + { + this.state = 5770; + this.match(MySqlParser.KW_PASSWORD); + this.state = 5771; + this.match(MySqlParser.KW_REQUIRE); + this.state = 5772; + this.match(MySqlParser.KW_CURRENT); + this.state = 5774; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 42 || _la === 122) { + { + this.state = 5773; + _la = this.tokenStream.LA(1); + if (!(_la === 42 || _la === 122)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + } + break; + case 5: + this.enterOuterAlt(localContext, 5); + { + this.state = 5776; + this.match(MySqlParser.KW_FAILED_LOGIN_ATTEMPTS); + this.state = 5777; + this.decimalLiteral(); + } + break; + case 6: + this.enterOuterAlt(localContext, 6); + { + this.state = 5778; + this.match(MySqlParser.KW_PASSWORD_LOCK_TIME); + this.state = 5781; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.ZERO_DECIMAL: + case MySqlParser.ONE_DECIMAL: + case MySqlParser.TWO_DECIMAL: + case MySqlParser.THREE_DECIMAL: + case MySqlParser.DECIMAL_LITERAL: + case MySqlParser.REAL_LITERAL: + { + this.state = 5779; + this.decimalLiteral(); + } + break; + case MySqlParser.KW_UNBOUNDED: + { + this.state = 5780; + this.match(MySqlParser.KW_UNBOUNDED); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + userLockOption() { + let localContext = new UserLockOptionContext(this.context, this.state); + this.enterRule(localContext, 506, MySqlParser.RULE_userLockOption); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 5785; + this.match(MySqlParser.KW_ACCOUNT); + this.state = 5786; + localContext._lockType = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 104 || _la === 183)) { + localContext._lockType = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + factorAuthOption() { + let localContext = new FactorAuthOptionContext(this.context, this.state); + this.enterRule(localContext, 508, MySqlParser.RULE_factorAuthOption); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 5788; + this.match(MySqlParser.KW_IDENTIFIED); + this.state = 5791; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 194) { + { + this.state = 5789; + this.match(MySqlParser.KW_WITH); + this.state = 5790; + localContext._authPlugin = this.uid(); + } + } + this.state = 5801; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_BY: + { + { + this.state = 5793; + this.match(MySqlParser.KW_BY); + this.state = 5797; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.STRING_LITERAL: + { + this.state = 5794; + this.match(MySqlParser.STRING_LITERAL); + } + break; + case MySqlParser.KW_RANDOM: + { + { + this.state = 5795; + this.match(MySqlParser.KW_RANDOM); + this.state = 5796; + this.match(MySqlParser.KW_PASSWORD); + } + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + } + break; + case MySqlParser.KW_AS: + { + this.state = 5799; + this.match(MySqlParser.KW_AS); + this.state = 5800; + this.match(MySqlParser.STRING_LITERAL); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + registrationOption() { + let localContext = new RegistrationOptionContext(this.context, this.state); + this.enterRule(localContext, 510, MySqlParser.RULE_registrationOption); + try { + this.state = 5818; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 842, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 5803; + this.factor(); + this.state = 5804; + this.match(MySqlParser.KW_INITIATE); + this.state = 5805; + this.match(MySqlParser.KW_REGISTRATION); + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 5807; + this.factor(); + this.state = 5808; + this.match(MySqlParser.KW_FINISH); + this.state = 5809; + this.match(MySqlParser.KW_REGISTRATION); + this.state = 5810; + this.match(MySqlParser.KW_SET); + this.state = 5811; + this.match(MySqlParser.KW_CHALLENGE_RESPONSE); + this.state = 5812; + this.match(MySqlParser.KW_AS); + this.state = 5813; + this.match(MySqlParser.STRING_LITERAL); + } + break; + case 3: + this.enterOuterAlt(localContext, 3); + { + this.state = 5815; + this.factor(); + this.state = 5816; + this.match(MySqlParser.KW_UNREGISTER); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + factor() { + let localContext = new FactorContext(this.context, this.state); + this.enterRule(localContext, 512, MySqlParser.RULE_factor); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 5820; + _la = this.tokenStream.LA(1); + if (!(_la === 873 || _la === 874)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 5821; + this.match(MySqlParser.KW_FACTOR); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + privelegeClause() { + let localContext = new PrivelegeClauseContext(this.context, this.state); + this.enterRule(localContext, 514, MySqlParser.RULE_privelegeClause); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 5823; + this.privilege(); + this.state = 5828; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 866) { + { + this.state = 5824; + this.match(MySqlParser.LR_BRACKET); + this.state = 5825; + this.columnNames(); + this.state = 5826; + this.match(MySqlParser.RR_BRACKET); + } + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + privilege() { + let localContext = new PrivilegeContext(this.context, this.state); + this.enterRule(localContext, 516, MySqlParser.RULE_privilege); + let _la; + try { + this.state = 5923; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 848, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 5830; + this.match(MySqlParser.KW_ALL); + this.state = 5832; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 734) { + { + this.state = 5831; + this.match(MySqlParser.KW_PRIVILEGES); + } + } + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 5834; + this.match(MySqlParser.KW_ALTER); + this.state = 5836; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 743) { + { + this.state = 5835; + this.match(MySqlParser.KW_ROUTINE); + } + } + } + break; + case 3: + this.enterOuterAlt(localContext, 3); + { + this.state = 5838; + this.match(MySqlParser.KW_CREATE); + this.state = 5846; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_TEMPORARY: + { + this.state = 5839; + this.match(MySqlParser.KW_TEMPORARY); + this.state = 5840; + this.match(MySqlParser.KW_TABLES); + } + break; + case MySqlParser.KW_ROUTINE: + { + this.state = 5841; + this.match(MySqlParser.KW_ROUTINE); + } + break; + case MySqlParser.KW_VIEW: + { + this.state = 5842; + this.match(MySqlParser.KW_VIEW); + } + break; + case MySqlParser.KW_USER: + { + this.state = 5843; + this.match(MySqlParser.KW_USER); + } + break; + case MySqlParser.KW_TABLESPACE: + { + this.state = 5844; + this.match(MySqlParser.KW_TABLESPACE); + } + break; + case MySqlParser.KW_ROLE: + { + this.state = 5845; + this.match(MySqlParser.KW_ROLE); + } + break; + case MySqlParser.KW_ON: + case MySqlParser.LR_BRACKET: + case MySqlParser.COMMA: + break; + default: + break; + } + } + break; + case 4: + this.enterOuterAlt(localContext, 4); + { + this.state = 5848; + this.match(MySqlParser.KW_DELETE); + } + break; + case 5: + this.enterOuterAlt(localContext, 5); + { + this.state = 5849; + this.match(MySqlParser.KW_DROP); + this.state = 5851; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 582) { + { + this.state = 5850; + this.match(MySqlParser.KW_ROLE); + } + } + } + break; + case 6: + this.enterOuterAlt(localContext, 6); + { + this.state = 5853; + this.match(MySqlParser.KW_EVENT); + } + break; + case 7: + this.enterOuterAlt(localContext, 7); + { + this.state = 5854; + this.match(MySqlParser.KW_EXECUTE); + } + break; + case 8: + this.enterOuterAlt(localContext, 8); + { + this.state = 5855; + this.match(MySqlParser.KW_FILE); + } + break; + case 9: + this.enterOuterAlt(localContext, 9); + { + this.state = 5856; + this.match(MySqlParser.KW_GRANT); + this.state = 5857; + this.match(MySqlParser.KW_OPTION); + } + break; + case 10: + this.enterOuterAlt(localContext, 10); + { + this.state = 5858; + this.match(MySqlParser.KW_INDEX); + } + break; + case 11: + this.enterOuterAlt(localContext, 11); + { + this.state = 5859; + this.match(MySqlParser.KW_INSERT); + } + break; + case 12: + this.enterOuterAlt(localContext, 12); + { + this.state = 5860; + this.match(MySqlParser.KW_LOCK); + this.state = 5861; + this.match(MySqlParser.KW_TABLES); + } + break; + case 13: + this.enterOuterAlt(localContext, 13); + { + this.state = 5862; + this.match(MySqlParser.KW_PROCESS); + } + break; + case 14: + this.enterOuterAlt(localContext, 14); + { + this.state = 5863; + this.match(MySqlParser.KW_PROXY); + } + break; + case 15: + this.enterOuterAlt(localContext, 15); + { + this.state = 5864; + this.match(MySqlParser.KW_REFERENCES); + } + break; + case 16: + this.enterOuterAlt(localContext, 16); + { + this.state = 5865; + this.match(MySqlParser.KW_RELOAD); + } + break; + case 17: + this.enterOuterAlt(localContext, 17); + { + this.state = 5866; + this.match(MySqlParser.KW_REPLICATION); + this.state = 5867; + _la = this.tokenStream.LA(1); + if (!(_la === 333 || _la === 598)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + break; + case 18: + this.enterOuterAlt(localContext, 18); + { + this.state = 5868; + this.match(MySqlParser.KW_SELECT); + } + break; + case 19: + this.enterOuterAlt(localContext, 19); + { + this.state = 5869; + this.match(MySqlParser.KW_SHOW); + this.state = 5870; + _la = this.tokenStream.LA(1); + if (!(_la === 40 || _la === 684)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + break; + case 20: + this.enterOuterAlt(localContext, 20); + { + this.state = 5871; + this.match(MySqlParser.KW_SHUTDOWN); + } + break; + case 21: + this.enterOuterAlt(localContext, 21); + { + this.state = 5872; + this.match(MySqlParser.KW_SUPER); + } + break; + case 22: + this.enterOuterAlt(localContext, 22); + { + this.state = 5873; + this.match(MySqlParser.KW_TRIGGER); + } + break; + case 23: + this.enterOuterAlt(localContext, 23); + { + this.state = 5874; + this.match(MySqlParser.KW_UPDATE); + } + break; + case 24: + this.enterOuterAlt(localContext, 24); + { + this.state = 5875; + this.match(MySqlParser.KW_USAGE); + } + break; + case 25: + this.enterOuterAlt(localContext, 25); + { + this.state = 5876; + this.match(MySqlParser.KW_APPLICATION_PASSWORD_ADMIN); + } + break; + case 26: + this.enterOuterAlt(localContext, 26); + { + this.state = 5877; + this.match(MySqlParser.KW_AUDIT_ABORT_EXEMPT); + } + break; + case 27: + this.enterOuterAlt(localContext, 27); + { + this.state = 5878; + this.match(MySqlParser.KW_AUDIT_ADMIN); + } + break; + case 28: + this.enterOuterAlt(localContext, 28); + { + this.state = 5879; + this.match(MySqlParser.KW_AUTHENTICATION_POLICY_ADMIN); + } + break; + case 29: + this.enterOuterAlt(localContext, 29); + { + this.state = 5880; + this.match(MySqlParser.KW_BACKUP_ADMIN); + } + break; + case 30: + this.enterOuterAlt(localContext, 30); + { + this.state = 5881; + this.match(MySqlParser.KW_BINLOG_ADMIN); + } + break; + case 31: + this.enterOuterAlt(localContext, 31); + { + this.state = 5882; + this.match(MySqlParser.KW_BINLOG_ENCRYPTION_ADMIN); + } + break; + case 32: + this.enterOuterAlt(localContext, 32); + { + this.state = 5883; + this.match(MySqlParser.KW_CLONE_ADMIN); + } + break; + case 33: + this.enterOuterAlt(localContext, 33); + { + this.state = 5884; + this.match(MySqlParser.KW_CONNECTION_ADMIN); + } + break; + case 34: + this.enterOuterAlt(localContext, 34); + { + this.state = 5885; + this.match(MySqlParser.KW_ENCRYPTION_KEY_ADMIN); + } + break; + case 35: + this.enterOuterAlt(localContext, 35); + { + this.state = 5886; + this.match(MySqlParser.KW_FIREWALL_ADMIN); + } + break; + case 36: + this.enterOuterAlt(localContext, 36); + { + this.state = 5887; + this.match(MySqlParser.KW_FIREWALL_EXEMPT); + } + break; + case 37: + this.enterOuterAlt(localContext, 37); + { + this.state = 5888; + this.match(MySqlParser.KW_FIREWALL_USER); + } + break; + case 38: + this.enterOuterAlt(localContext, 38); + { + this.state = 5889; + this.match(MySqlParser.KW_FLUSH_OPTIMIZER_COSTS); + } + break; + case 39: + this.enterOuterAlt(localContext, 39); + { + this.state = 5890; + this.match(MySqlParser.KW_FLUSH_STATUS); + } + break; + case 40: + this.enterOuterAlt(localContext, 40); + { + this.state = 5891; + this.match(MySqlParser.KW_FLUSH_TABLES); + } + break; + case 41: + this.enterOuterAlt(localContext, 41); + { + this.state = 5892; + this.match(MySqlParser.KW_FLUSH_USER_RESOURCES); + } + break; + case 42: + this.enterOuterAlt(localContext, 42); + { + this.state = 5893; + this.match(MySqlParser.KW_GROUP_REPLICATION_ADMIN); + } + break; + case 43: + this.enterOuterAlt(localContext, 43); + { + this.state = 5894; + this.match(MySqlParser.KW_INNODB_REDO_LOG_ARCHIVE); + } + break; + case 44: + this.enterOuterAlt(localContext, 44); + { + this.state = 5895; + this.match(MySqlParser.KW_INNODB_REDO_LOG_ENABLE); + } + break; + case 45: + this.enterOuterAlt(localContext, 45); + { + this.state = 5896; + this.match(MySqlParser.KW_NDB_STORED_USER); + } + break; + case 46: + this.enterOuterAlt(localContext, 46); + { + this.state = 5897; + this.match(MySqlParser.KW_PASSWORDLESS_USER_ADMIN); + } + break; + case 47: + this.enterOuterAlt(localContext, 47); + { + this.state = 5898; + this.match(MySqlParser.KW_PERSIST_RO_VARIABLES_ADMIN); + } + break; + case 48: + this.enterOuterAlt(localContext, 48); + { + this.state = 5899; + this.match(MySqlParser.KW_REPLICATION_APPLIER); + } + break; + case 49: + this.enterOuterAlt(localContext, 49); + { + this.state = 5900; + this.match(MySqlParser.KW_REPLICATION_SLAVE_ADMIN); + } + break; + case 50: + this.enterOuterAlt(localContext, 50); + { + this.state = 5901; + this.match(MySqlParser.KW_RESOURCE_GROUP_ADMIN); + } + break; + case 51: + this.enterOuterAlt(localContext, 51); + { + this.state = 5902; + this.match(MySqlParser.KW_RESOURCE_GROUP_USER); + } + break; + case 52: + this.enterOuterAlt(localContext, 52); + { + this.state = 5903; + this.match(MySqlParser.KW_ROLE_ADMIN); + } + break; + case 53: + this.enterOuterAlt(localContext, 53); + { + this.state = 5904; + this.match(MySqlParser.KW_SERVICE_CONNECTION_ADMIN); + } + break; + case 54: + this.enterOuterAlt(localContext, 54); + { + this.state = 5905; + this.match(MySqlParser.KW_SESSION_VARIABLES_ADMIN); + } + break; + case 55: + this.enterOuterAlt(localContext, 55); + { + this.state = 5906; + this.match(MySqlParser.KW_SET_USER_ID); + } + break; + case 56: + this.enterOuterAlt(localContext, 56); + { + this.state = 5907; + this.match(MySqlParser.KW_SKIP_QUERY_REWRITE); + } + break; + case 57: + this.enterOuterAlt(localContext, 57); + { + this.state = 5908; + this.match(MySqlParser.KW_SHOW_ROUTINE); + } + break; + case 58: + this.enterOuterAlt(localContext, 58); + { + this.state = 5909; + this.match(MySqlParser.KW_SYSTEM_USER); + } + break; + case 59: + this.enterOuterAlt(localContext, 59); + { + this.state = 5910; + this.match(MySqlParser.KW_SYSTEM_VARIABLES_ADMIN); + } + break; + case 60: + this.enterOuterAlt(localContext, 60); + { + this.state = 5911; + this.match(MySqlParser.KW_TABLE_ENCRYPTION_ADMIN); + } + break; + case 61: + this.enterOuterAlt(localContext, 61); + { + this.state = 5912; + this.match(MySqlParser.KW_TP_CONNECTION_ADMIN); + } + break; + case 62: + this.enterOuterAlt(localContext, 62); + { + this.state = 5913; + this.match(MySqlParser.KW_VERSION_TOKEN_ADMIN); + } + break; + case 63: + this.enterOuterAlt(localContext, 63); + { + this.state = 5914; + this.match(MySqlParser.KW_XA_RECOVER_ADMIN); + } + break; + case 64: + this.enterOuterAlt(localContext, 64); + { + this.state = 5915; + this.match(MySqlParser.KW_LOAD); + this.state = 5916; + this.match(MySqlParser.KW_FROM); + this.state = 5917; + this.match(MySqlParser.KW_S3); + } + break; + case 65: + this.enterOuterAlt(localContext, 65); + { + this.state = 5918; + this.match(MySqlParser.KW_SELECT); + this.state = 5919; + this.match(MySqlParser.KW_INTO); + this.state = 5920; + this.match(MySqlParser.KW_S3); + } + break; + case 66: + this.enterOuterAlt(localContext, 66); + { + this.state = 5921; + this.match(MySqlParser.KW_INVOKE); + this.state = 5922; + this.match(MySqlParser.KW_LAMBDA); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + privilegeLevel() { + let localContext = new PrivilegeLevelContext(this.context, this.state); + this.enterRule(localContext, 518, MySqlParser.RULE_privilegeLevel); + try { + this.state = 5941; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 849, this.context)) { + case 1: + localContext = new CurrentSchemaPriviLevelContext(localContext); + this.enterOuterAlt(localContext, 1); + { + this.state = 5925; + this.match(MySqlParser.STAR); + } + break; + case 2: + localContext = new GlobalPrivLevelContext(localContext); + this.enterOuterAlt(localContext, 2); + { + this.state = 5926; + this.match(MySqlParser.STAR); + this.state = 5927; + this.match(MySqlParser.DOT); + this.state = 5928; + this.match(MySqlParser.STAR); + } + break; + case 3: + localContext = new DefiniteSchemaPrivLevelContext(localContext); + this.enterOuterAlt(localContext, 3); + { + this.state = 5929; + this.uid(); + this.state = 5930; + this.match(MySqlParser.DOT); + this.state = 5931; + this.match(MySqlParser.STAR); + } + break; + case 4: + localContext = new DefiniteFullTablePrivLevelContext(localContext); + this.enterOuterAlt(localContext, 4); + { + this.state = 5933; + this.uid(); + this.state = 5934; + this.match(MySqlParser.DOT); + this.state = 5935; + this.uid(); + } + break; + case 5: + localContext = new DefiniteFullTablePrivLevel2Context(localContext); + this.enterOuterAlt(localContext, 5); + { + this.state = 5937; + this.uid(); + this.state = 5938; + this.dottedId(); + } + break; + case 6: + localContext = new DefiniteTablePrivLevelContext(localContext); + this.enterOuterAlt(localContext, 6); + { + this.state = 5940; + this.uid(); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + renameUserClause() { + let localContext = new RenameUserClauseContext(this.context, this.state); + this.enterRule(localContext, 520, MySqlParser.RULE_renameUserClause); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 5943; + localContext._fromFirst = this.userName(); + this.state = 5944; + this.match(MySqlParser.KW_TO); + this.state = 5945; + localContext._toFirst = this.userName(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + analyzeTable() { + let localContext = new AnalyzeTableContext(this.context, this.state); + this.enterRule(localContext, 522, MySqlParser.RULE_analyzeTable); + let _la; + try { + this.state = 5995; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 856, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 5947; + this.match(MySqlParser.KW_ANALYZE); + this.state = 5949; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 115 || _la === 450) { + { + this.state = 5948; + this.tableActionOption(); + } + } + this.state = 5951; + this.match(MySqlParser.KW_TABLE); + this.state = 5952; + this.tableNames(); + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 5953; + this.match(MySqlParser.KW_ANALYZE); + this.state = 5955; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 115 || _la === 450) { + { + this.state = 5954; + this.tableActionOption(); + } + } + this.state = 5957; + this.match(MySqlParser.KW_TABLE); + this.state = 5958; + this.tableName(); + this.state = 5959; + this.match(MySqlParser.KW_UPDATE); + this.state = 5960; + this.match(MySqlParser.KW_HISTOGRAM); + this.state = 5961; + this.match(MySqlParser.KW_ON); + this.state = 5962; + this.columnNames(); + this.state = 5967; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 852, this.context)) { + case 1: + { + this.state = 5963; + this.match(MySqlParser.KW_WITH); + this.state = 5964; + this.decimalLiteral(); + this.state = 5965; + this.match(MySqlParser.KW_BUCKETS); + } + break; + } + } + break; + case 3: + this.enterOuterAlt(localContext, 3); + { + this.state = 5969; + this.match(MySqlParser.KW_ANALYZE); + this.state = 5971; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 115 || _la === 450) { + { + this.state = 5970; + this.tableActionOption(); + } + } + this.state = 5973; + this.match(MySqlParser.KW_TABLE); + this.state = 5974; + this.tableName(); + this.state = 5975; + this.match(MySqlParser.KW_UPDATE); + this.state = 5976; + this.match(MySqlParser.KW_HISTOGRAM); + this.state = 5977; + this.match(MySqlParser.KW_ON); + this.state = 5978; + this.columnName(); + this.state = 5982; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 188) { + { + this.state = 5979; + this.match(MySqlParser.KW_USING); + this.state = 5980; + this.match(MySqlParser.KW_DATA); + this.state = 5981; + this.match(MySqlParser.STRING_LITERAL); + } + } + } + break; + case 4: + this.enterOuterAlt(localContext, 4); + { + this.state = 5984; + this.match(MySqlParser.KW_ANALYZE); + this.state = 5986; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 115 || _la === 450) { + { + this.state = 5985; + this.tableActionOption(); + } + } + this.state = 5988; + this.match(MySqlParser.KW_TABLE); + this.state = 5989; + this.tableName(); + this.state = 5990; + this.match(MySqlParser.KW_DROP); + this.state = 5991; + this.match(MySqlParser.KW_HISTOGRAM); + this.state = 5992; + this.match(MySqlParser.KW_ON); + this.state = 5993; + this.columnNames(); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + checkTable() { + let localContext = new CheckTableContext(this.context, this.state); + this.enterRule(localContext, 524, MySqlParser.RULE_checkTable); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 5997; + this.match(MySqlParser.KW_CHECK); + this.state = 5998; + this.match(MySqlParser.KW_TABLE); + this.state = 5999; + this.tableNames(); + this.state = 6003; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 65 || _la === 327 || _la === 392 || _la === 396 || _la === 484 || _la === 549) { + { + { + this.state = 6000; + this.checkTableOption(); + } + } + this.state = 6005; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + checksumTable() { + let localContext = new ChecksumTableContext(this.context, this.state); + this.enterRule(localContext, 526, MySqlParser.RULE_checksumTable); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6006; + this.match(MySqlParser.KW_CHECKSUM); + this.state = 6007; + this.match(MySqlParser.KW_TABLE); + this.state = 6008; + this.tableNames(); + this.state = 6010; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 392 || _la === 549) { + { + this.state = 6009; + localContext._actionOption = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 392 || _la === 549)) { + localContext._actionOption = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + optimizeTable() { + let localContext = new OptimizeTableContext(this.context, this.state); + this.enterRule(localContext, 528, MySqlParser.RULE_optimizeTable); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6012; + this.match(MySqlParser.KW_OPTIMIZE); + this.state = 6014; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 115 || _la === 450) { + { + this.state = 6013; + this.tableActionOption(); + } + } + this.state = 6016; + _la = this.tokenStream.LA(1); + if (!(_la === 173 || _la === 752)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 6017; + this.tableNames(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + repairTable() { + let localContext = new RepairTableContext(this.context, this.state); + this.enterRule(localContext, 530, MySqlParser.RULE_repairTable); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6019; + this.match(MySqlParser.KW_REPAIR); + this.state = 6021; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 115 || _la === 450) { + { + this.state = 6020; + this.tableActionOption(); + } + } + this.state = 6023; + this.match(MySqlParser.KW_TABLE); + this.state = 6024; + this.tableNames(); + this.state = 6026; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 549) { + { + this.state = 6025; + this.match(MySqlParser.KW_QUICK); + } + } + this.state = 6029; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 392) { + { + this.state = 6028; + this.match(MySqlParser.KW_EXTENDED); + } + } + this.state = 6032; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 679) { + { + this.state = 6031; + this.match(MySqlParser.KW_USE_FRM); + } + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + tableActionOption() { + let localContext = new TableActionOptionContext(this.context, this.state); + this.enterRule(localContext, 532, MySqlParser.RULE_tableActionOption); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6034; + _la = this.tokenStream.LA(1); + if (!(_la === 115 || _la === 450)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + checkTableOption() { + let localContext = new CheckTableOptionContext(this.context, this.state); + this.enterRule(localContext, 534, MySqlParser.RULE_checkTableOption); + try { + this.state = 6043; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_FOR: + this.enterOuterAlt(localContext, 1); + { + this.state = 6036; + this.match(MySqlParser.KW_FOR); + this.state = 6037; + this.match(MySqlParser.KW_UPGRADE); + } + break; + case MySqlParser.KW_QUICK: + this.enterOuterAlt(localContext, 2); + { + this.state = 6038; + this.match(MySqlParser.KW_QUICK); + } + break; + case MySqlParser.KW_FAST: + this.enterOuterAlt(localContext, 3); + { + this.state = 6039; + this.match(MySqlParser.KW_FAST); + } + break; + case MySqlParser.KW_MEDIUM: + this.enterOuterAlt(localContext, 4); + { + this.state = 6040; + this.match(MySqlParser.KW_MEDIUM); + } + break; + case MySqlParser.KW_EXTENDED: + this.enterOuterAlt(localContext, 5); + { + this.state = 6041; + this.match(MySqlParser.KW_EXTENDED); + } + break; + case MySqlParser.KW_CHANGED: + this.enterOuterAlt(localContext, 6); + { + this.state = 6042; + this.match(MySqlParser.KW_CHANGED); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + createFunction() { + let localContext = new CreateFunctionContext(this.context, this.state); + this.enterRule(localContext, 536, MySqlParser.RULE_createFunction); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6045; + this.match(MySqlParser.KW_CREATE); + this.state = 6047; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 307) { + { + this.state = 6046; + this.match(MySqlParser.KW_AGGREGATE); + } + } + this.state = 6049; + this.match(MySqlParser.KW_FUNCTION); + this.state = 6051; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 866, this.context)) { + case 1: + { + this.state = 6050; + this.ifNotExists(); + } + break; + } + this.state = 6053; + this.functionNameCreate(); + this.state = 6054; + this.match(MySqlParser.KW_RETURNS); + this.state = 6055; + localContext._returnType = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(((((_la - 208)) & ~0x1F) === 0 && ((1 << (_la - 208)) & 261) !== 0) || _la === 649)) { + localContext._returnType = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 6056; + this.match(MySqlParser.KW_SONAME); + this.state = 6057; + this.match(MySqlParser.STRING_LITERAL); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + installComponent() { + let localContext = new InstallComponentContext(this.context, this.state); + this.enterRule(localContext, 538, MySqlParser.RULE_installComponent); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6059; + this.match(MySqlParser.KW_INSTALL); + this.state = 6060; + this.match(MySqlParser.KW_COMPONENT); + this.state = 6061; + localContext._component_name = this.uid(); + this.state = 6066; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 6062; + this.match(MySqlParser.COMMA); + this.state = 6063; + localContext._component_name = this.uid(); + } + } + this.state = 6068; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 6078; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 869, this.context)) { + case 1: + { + this.state = 6069; + this.match(MySqlParser.KW_SET); + this.state = 6070; + this.variableExpr(); + this.state = 6075; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 6071; + this.match(MySqlParser.COMMA); + this.state = 6072; + this.variableExpr(); + } + } + this.state = 6077; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + break; + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + variableExpr() { + let localContext = new VariableExprContext(this.context, this.state); + this.enterRule(localContext, 540, MySqlParser.RULE_variableExpr); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6080; + _la = this.tokenStream.LA(1); + if (!(_la === 413 || _la === 531 || _la === 893 || _la === 894)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 6081; + localContext._system_var_name = this.fullId(); + this.state = 6082; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 6083; + this.expression(0); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + uninstallComponent() { + let localContext = new UninstallComponentContext(this.context, this.state); + this.enterRule(localContext, 542, MySqlParser.RULE_uninstallComponent); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6085; + this.match(MySqlParser.KW_UNINSTALL); + this.state = 6086; + this.match(MySqlParser.KW_COMPONENT); + this.state = 6087; + localContext._component_name = this.uid(); + this.state = 6092; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 6088; + this.match(MySqlParser.COMMA); + this.state = 6089; + localContext._component_name = this.uid(); + } + } + this.state = 6094; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + installPlugin() { + let localContext = new InstallPluginContext(this.context, this.state); + this.enterRule(localContext, 544, MySqlParser.RULE_installPlugin); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6095; + this.match(MySqlParser.KW_INSTALL); + this.state = 6096; + this.match(MySqlParser.KW_PLUGIN); + this.state = 6097; + localContext._pluginName = this.uid(); + this.state = 6098; + this.match(MySqlParser.KW_SONAME); + this.state = 6099; + this.match(MySqlParser.STRING_LITERAL); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + uninstallPlugin() { + let localContext = new UninstallPluginContext(this.context, this.state); + this.enterRule(localContext, 546, MySqlParser.RULE_uninstallPlugin); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6101; + this.match(MySqlParser.KW_UNINSTALL); + this.state = 6102; + this.match(MySqlParser.KW_PLUGIN); + this.state = 6103; + localContext._pluginName = this.uid(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + cloneStatement() { + let localContext = new CloneStatementContext(this.context, this.state); + this.enterRule(localContext, 548, MySqlParser.RULE_cloneStatement); + let _la; + try { + this.state = 6135; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 876, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 6105; + this.match(MySqlParser.KW_CLONE); + this.state = 6106; + this.match(MySqlParser.KW_LOCAL); + this.state = 6107; + this.match(MySqlParser.KW_DATA); + this.state = 6108; + this.match(MySqlParser.KW_DIRECTORY); + this.state = 6110; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 6109; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 6112; + this.match(MySqlParser.STRING_LITERAL); + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 6113; + this.match(MySqlParser.KW_CLONE); + this.state = 6114; + this.match(MySqlParser.KW_INSTANCE); + this.state = 6115; + this.match(MySqlParser.KW_FROM); + this.state = 6116; + this.userHostPort(); + this.state = 6117; + this.match(MySqlParser.KW_IDENTIFIED); + this.state = 6118; + this.match(MySqlParser.KW_BY); + this.state = 6119; + this.match(MySqlParser.STRING_LITERAL); + this.state = 6126; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 360) { + { + this.state = 6120; + this.match(MySqlParser.KW_DATA); + this.state = 6121; + this.match(MySqlParser.KW_DIRECTORY); + this.state = 6123; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 857) { + { + this.state = 6122; + this.match(MySqlParser.EQUAL_SYMBOL); + } + } + this.state = 6125; + this.match(MySqlParser.STRING_LITERAL); + } + } + this.state = 6133; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 144) { + { + this.state = 6128; + this.match(MySqlParser.KW_REQUIRE); + this.state = 6130; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 502) { + { + this.state = 6129; + this.match(MySqlParser.KW_NO); + } + } + this.state = 6132; + this.match(MySqlParser.KW_SSL); + } + } + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + setStatement() { + let localContext = new SetStatementContext(this.context, this.state); + this.enterRule(localContext, 550, MySqlParser.RULE_setStatement); + let _la; + try { + this.state = 6189; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 884, this.context)) { + case 1: + localContext = new SetVariableContext(localContext); + this.enterOuterAlt(localContext, 1); + { + this.state = 6137; + this.match(MySqlParser.KW_SET); + this.state = 6138; + this.variableClause(); + this.state = 6139; + _la = this.tokenStream.LA(1); + if (!(_la === 841 || _la === 857)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 6142; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 877, this.context)) { + case 1: + { + this.state = 6140; + this.expression(0); + } + break; + case 2: + { + this.state = 6141; + this.match(MySqlParser.KW_ON); + } + break; + } + this.state = 6153; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 6144; + this.match(MySqlParser.COMMA); + this.state = 6145; + this.variableClause(); + this.state = 6146; + _la = this.tokenStream.LA(1); + if (!(_la === 841 || _la === 857)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 6149; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 878, this.context)) { + case 1: + { + this.state = 6147; + this.expression(0); + } + break; + case 2: + { + this.state = 6148; + this.match(MySqlParser.KW_ON); + } + break; + } + } + } + this.state = 6155; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + break; + case 2: + localContext = new SetCharsetContext(localContext); + this.enterOuterAlt(localContext, 2); + { + this.state = 6156; + this.match(MySqlParser.KW_SET); + this.state = 6157; + this.charSet(); + this.state = 6160; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_BINARY: + case MySqlParser.KW_ARMSCII8: + case MySqlParser.KW_ASCII: + case MySqlParser.KW_BIG5: + case MySqlParser.KW_CP1250: + case MySqlParser.KW_CP1251: + case MySqlParser.KW_CP1256: + case MySqlParser.KW_CP1257: + case MySqlParser.KW_CP850: + case MySqlParser.KW_CP852: + case MySqlParser.KW_CP866: + case MySqlParser.KW_CP932: + case MySqlParser.KW_DEC8: + case MySqlParser.KW_EUCJPMS: + case MySqlParser.KW_EUCKR: + case MySqlParser.KW_GB18030: + case MySqlParser.KW_GB2312: + case MySqlParser.KW_GBK: + case MySqlParser.KW_GEOSTD8: + case MySqlParser.KW_GREEK: + case MySqlParser.KW_HEBREW: + case MySqlParser.KW_HP8: + case MySqlParser.KW_KEYBCS2: + case MySqlParser.KW_KOI8R: + case MySqlParser.KW_KOI8U: + case MySqlParser.KW_LATIN1: + case MySqlParser.KW_LATIN2: + case MySqlParser.KW_LATIN5: + case MySqlParser.KW_LATIN7: + case MySqlParser.KW_MACCE: + case MySqlParser.KW_MACROMAN: + case MySqlParser.KW_SJIS: + case MySqlParser.KW_SWE7: + case MySqlParser.KW_TIS620: + case MySqlParser.KW_UCS2: + case MySqlParser.KW_UJIS: + case MySqlParser.KW_UTF16: + case MySqlParser.KW_UTF16LE: + case MySqlParser.KW_UTF32: + case MySqlParser.KW_UTF8: + case MySqlParser.KW_UTF8MB3: + case MySqlParser.KW_UTF8MB4: + case MySqlParser.CHARSET_REVERSE_QOUTE_STRING: + case MySqlParser.STRING_LITERAL: + { + this.state = 6158; + this.charsetName(); + } + break; + case MySqlParser.KW_DEFAULT: + { + this.state = 6159; + this.match(MySqlParser.KW_DEFAULT); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + break; + case 3: + localContext = new SetNamesContext(localContext); + this.enterOuterAlt(localContext, 3); + { + this.state = 6162; + this.match(MySqlParser.KW_SET); + this.state = 6163; + this.match(MySqlParser.KW_NAMES); + this.state = 6170; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_BINARY: + case MySqlParser.KW_ARMSCII8: + case MySqlParser.KW_ASCII: + case MySqlParser.KW_BIG5: + case MySqlParser.KW_CP1250: + case MySqlParser.KW_CP1251: + case MySqlParser.KW_CP1256: + case MySqlParser.KW_CP1257: + case MySqlParser.KW_CP850: + case MySqlParser.KW_CP852: + case MySqlParser.KW_CP866: + case MySqlParser.KW_CP932: + case MySqlParser.KW_DEC8: + case MySqlParser.KW_EUCJPMS: + case MySqlParser.KW_EUCKR: + case MySqlParser.KW_GB18030: + case MySqlParser.KW_GB2312: + case MySqlParser.KW_GBK: + case MySqlParser.KW_GEOSTD8: + case MySqlParser.KW_GREEK: + case MySqlParser.KW_HEBREW: + case MySqlParser.KW_HP8: + case MySqlParser.KW_KEYBCS2: + case MySqlParser.KW_KOI8R: + case MySqlParser.KW_KOI8U: + case MySqlParser.KW_LATIN1: + case MySqlParser.KW_LATIN2: + case MySqlParser.KW_LATIN5: + case MySqlParser.KW_LATIN7: + case MySqlParser.KW_MACCE: + case MySqlParser.KW_MACROMAN: + case MySqlParser.KW_SJIS: + case MySqlParser.KW_SWE7: + case MySqlParser.KW_TIS620: + case MySqlParser.KW_UCS2: + case MySqlParser.KW_UJIS: + case MySqlParser.KW_UTF16: + case MySqlParser.KW_UTF16LE: + case MySqlParser.KW_UTF32: + case MySqlParser.KW_UTF8: + case MySqlParser.KW_UTF8MB3: + case MySqlParser.KW_UTF8MB4: + case MySqlParser.CHARSET_REVERSE_QOUTE_STRING: + case MySqlParser.STRING_LITERAL: + { + this.state = 6164; + this.charsetName(); + this.state = 6167; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 28) { + { + this.state = 6165; + this.match(MySqlParser.KW_COLLATE); + this.state = 6166; + this.collationName(); + } + } + } + break; + case MySqlParser.KW_DEFAULT: + { + this.state = 6169; + this.match(MySqlParser.KW_DEFAULT); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + break; + case 4: + localContext = new SetPasswordContext(localContext); + this.enterOuterAlt(localContext, 4); + { + this.state = 6172; + this.setPasswordStatement(); + } + break; + case 5: + localContext = new SetTransactionContext(localContext); + this.enterOuterAlt(localContext, 5); + { + this.state = 6173; + this.setTransactionStatement(); + } + break; + case 6: + localContext = new SetAutocommitContext(localContext); + this.enterOuterAlt(localContext, 6); + { + this.state = 6174; + this.setAutocommitStatement(); + } + break; + case 7: + localContext = new SetNewValueInsideTriggerContext(localContext); + this.enterOuterAlt(localContext, 7); + { + this.state = 6175; + this.match(MySqlParser.KW_SET); + this.state = 6176; + localContext._system_var_name = this.fullId(); + this.state = 6177; + _la = this.tokenStream.LA(1); + if (!(_la === 841 || _la === 857)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 6178; + this.expression(0); + this.state = 6186; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 6179; + this.match(MySqlParser.COMMA); + this.state = 6180; + localContext._system_var_name = this.fullId(); + this.state = 6181; + _la = this.tokenStream.LA(1); + if (!(_la === 841 || _la === 857)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 6182; + this.expression(0); + } + } + this.state = 6188; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + showStatement() { + let localContext = new ShowStatementContext(this.context, this.state); + this.enterRule(localContext, 552, MySqlParser.RULE_showStatement); + let _la; + try { + this.state = 6375; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 913, this.context)) { + case 1: + localContext = new ShowMasterLogsContext(localContext); + this.enterOuterAlt(localContext, 1); + { + this.state = 6191; + this.match(MySqlParser.KW_SHOW); + this.state = 6192; + localContext._logFormat = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 228 || _la === 453)) { + localContext._logFormat = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 6193; + this.match(MySqlParser.KW_LOGS); + } + break; + case 2: + localContext = new ShowLogEventsContext(localContext); + this.enterOuterAlt(localContext, 2); + { + this.state = 6194; + this.match(MySqlParser.KW_SHOW); + this.state = 6195; + localContext._logFormat = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 318 || _la === 559)) { + localContext._logFormat = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 6196; + this.match(MySqlParser.KW_EVENTS); + this.state = 6199; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 80) { + { + this.state = 6197; + this.match(MySqlParser.KW_IN); + this.state = 6198; + localContext._filename = this.match(MySqlParser.STRING_LITERAL); + } + } + this.state = 6203; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 68) { + { + this.state = 6201; + this.match(MySqlParser.KW_FROM); + this.state = 6202; + localContext._fromPosition = this.decimalLiteral(); + } + } + this.state = 6212; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 100) { + { + this.state = 6205; + this.match(MySqlParser.KW_LIMIT); + this.state = 6209; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 887, this.context)) { + case 1: + { + this.state = 6206; + localContext._offset = this.decimalLiteral(); + this.state = 6207; + this.match(MySqlParser.COMMA); + } + break; + } + this.state = 6211; + localContext._rowCount = this.decimalLiteral(); + } + } + this.state = 6215; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 65) { + { + this.state = 6214; + this.channelOption(); + } + } + } + break; + case 3: + localContext = new ShowObjectFilterContext(localContext); + this.enterOuterAlt(localContext, 3); + { + this.state = 6217; + this.match(MySqlParser.KW_SHOW); + this.state = 6218; + this.showCommonEntity(); + this.state = 6220; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 99 || _la === 192) { + { + this.state = 6219; + this.showFilter(); + } + } + } + break; + case 4: + localContext = new ShowColumnsContext(localContext); + this.enterOuterAlt(localContext, 4); + { + this.state = 6222; + this.match(MySqlParser.KW_SHOW); + this.state = 6224; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 392) { + { + this.state = 6223; + this.match(MySqlParser.KW_EXTENDED); + } + } + this.state = 6227; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 408) { + { + this.state = 6226; + this.match(MySqlParser.KW_FULL); + } + } + this.state = 6229; + localContext._columnsFormat = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 337 || _la === 398)) { + localContext._columnsFormat = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 6230; + localContext._tableFormat = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 68 || _la === 80)) { + localContext._tableFormat = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 6231; + this.tableName(); + this.state = 6234; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 68 || _la === 80) { + { + this.state = 6232; + localContext._schemaFormat = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 68 || _la === 80)) { + localContext._schemaFormat = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 6233; + this.databaseName(); + } + } + this.state = 6237; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 99 || _la === 192) { + { + this.state = 6236; + this.showFilter(); + } + } + } + break; + case 5: + localContext = new ShowCreateDbContext(localContext); + this.enterOuterAlt(localContext, 5); + { + this.state = 6239; + this.match(MySqlParser.KW_SHOW); + this.state = 6240; + this.match(MySqlParser.KW_CREATE); + this.state = 6241; + _la = this.tokenStream.LA(1); + if (!(_la === 39 || _la === 152)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 6243; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 895, this.context)) { + case 1: + { + this.state = 6242; + this.ifNotExists(); + } + break; + } + this.state = 6245; + this.databaseName(); + } + break; + case 6: + localContext = new ShowCreateFullIdObjectContext(localContext); + this.enterOuterAlt(localContext, 6); + { + this.state = 6246; + this.match(MySqlParser.KW_SHOW); + this.state = 6247; + this.match(MySqlParser.KW_CREATE); + this.state = 6248; + _la = this.tokenStream.LA(1); + if (!(_la === 132 || _la === 178 || _la === 385)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 6249; + this.fullId(); + } + break; + case 7: + localContext = new ShowCreateFunctionContext(localContext); + this.enterOuterAlt(localContext, 7); + { + this.state = 6250; + this.match(MySqlParser.KW_SHOW); + this.state = 6251; + this.match(MySqlParser.KW_CREATE); + this.state = 6252; + this.match(MySqlParser.KW_FUNCTION); + this.state = 6253; + this.functionName(); + } + break; + case 8: + localContext = new ShowCreateViewContext(localContext); + this.enterOuterAlt(localContext, 8); + { + this.state = 6254; + this.match(MySqlParser.KW_SHOW); + this.state = 6255; + this.match(MySqlParser.KW_CREATE); + this.state = 6256; + this.match(MySqlParser.KW_VIEW); + this.state = 6257; + this.viewName(); + } + break; + case 9: + localContext = new ShowCreateTableContext(localContext); + this.enterOuterAlt(localContext, 9); + { + this.state = 6258; + this.match(MySqlParser.KW_SHOW); + this.state = 6259; + this.match(MySqlParser.KW_CREATE); + this.state = 6260; + this.match(MySqlParser.KW_TABLE); + this.state = 6261; + this.tableName(); + } + break; + case 10: + localContext = new ShowCreateUserContext(localContext); + this.enterOuterAlt(localContext, 10); + { + this.state = 6262; + this.match(MySqlParser.KW_SHOW); + this.state = 6263; + this.match(MySqlParser.KW_CREATE); + this.state = 6264; + this.match(MySqlParser.KW_USER); + this.state = 6265; + this.userName(); + } + break; + case 11: + localContext = new ShowEngineContext(localContext); + this.enterOuterAlt(localContext, 11); + { + this.state = 6266; + this.match(MySqlParser.KW_SHOW); + this.state = 6267; + this.match(MySqlParser.KW_ENGINE); + this.state = 6268; + this.engineName(); + this.state = 6269; + localContext._engineOption = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 493 || _la === 645)) { + localContext._engineOption = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + break; + case 12: + localContext = new ShowGlobalInfoContext(localContext); + this.enterOuterAlt(localContext, 12); + { + this.state = 6271; + this.match(MySqlParser.KW_SHOW); + this.state = 6272; + this.showGlobalInfoClause(); + } + break; + case 13: + localContext = new ShowErrorsContext(localContext); + this.enterOuterAlt(localContext, 13); + { + this.state = 6273; + this.match(MySqlParser.KW_SHOW); + this.state = 6274; + localContext._errorFormat = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 383 || _la === 688)) { + localContext._errorFormat = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 6282; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 100) { + { + this.state = 6275; + this.match(MySqlParser.KW_LIMIT); + this.state = 6279; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 896, this.context)) { + case 1: + { + this.state = 6276; + localContext._offset = this.decimalLiteral(); + this.state = 6277; + this.match(MySqlParser.COMMA); + } + break; + } + this.state = 6281; + localContext._rowCount = this.decimalLiteral(); + } + } + } + break; + case 14: + localContext = new ShowCountErrorsContext(localContext); + this.enterOuterAlt(localContext, 14); + { + this.state = 6284; + this.match(MySqlParser.KW_SHOW); + this.state = 6285; + this.match(MySqlParser.KW_COUNT); + this.state = 6286; + this.match(MySqlParser.LR_BRACKET); + this.state = 6287; + this.match(MySqlParser.STAR); + this.state = 6288; + this.match(MySqlParser.RR_BRACKET); + this.state = 6289; + localContext._errorFormat = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 383 || _la === 688)) { + localContext._errorFormat = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + break; + case 15: + localContext = new ShowSchemaFilterContext(localContext); + this.enterOuterAlt(localContext, 15); + { + this.state = 6290; + this.match(MySqlParser.KW_SHOW); + this.state = 6291; + this.showSchemaEntity(); + this.state = 6294; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 68 || _la === 80) { + { + this.state = 6292; + localContext._schemaFormat = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 68 || _la === 80)) { + localContext._schemaFormat = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 6293; + this.databaseName(); + } + } + this.state = 6297; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 99 || _la === 192) { + { + this.state = 6296; + this.showFilter(); + } + } + } + break; + case 16: + localContext = new ShowPercedureCodeContext(localContext); + this.enterOuterAlt(localContext, 16); + { + this.state = 6299; + this.match(MySqlParser.KW_SHOW); + this.state = 6300; + this.match(MySqlParser.KW_PROCEDURE); + this.state = 6301; + this.match(MySqlParser.KW_CODE); + this.state = 6302; + localContext._proc_name = this.fullId(); + } + break; + case 17: + localContext = new ShowFunctionCodeContext(localContext); + this.enterOuterAlt(localContext, 17); + { + this.state = 6303; + this.match(MySqlParser.KW_SHOW); + this.state = 6304; + this.match(MySqlParser.KW_FUNCTION); + this.state = 6305; + this.match(MySqlParser.KW_CODE); + this.state = 6306; + this.functionName(); + } + break; + case 18: + localContext = new ShowGrantsContext(localContext); + this.enterOuterAlt(localContext, 18); + { + this.state = 6307; + this.match(MySqlParser.KW_SHOW); + this.state = 6308; + this.match(MySqlParser.KW_GRANTS); + this.state = 6315; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 65) { + { + this.state = 6309; + this.match(MySqlParser.KW_FOR); + this.state = 6310; + this.userOrRoleName(); + this.state = 6313; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 188) { + { + this.state = 6311; + this.match(MySqlParser.KW_USING); + this.state = 6312; + this.userOrRoleNames(); + } + } + } + } + } + break; + case 19: + localContext = new ShowIndexesContext(localContext); + this.enterOuterAlt(localContext, 19); + { + this.state = 6317; + this.match(MySqlParser.KW_SHOW); + this.state = 6319; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 392) { + { + this.state = 6318; + this.match(MySqlParser.KW_EXTENDED); + } + } + this.state = 6321; + localContext._indexFormat = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 82 || _la === 93 || _la === 426)) { + localContext._indexFormat = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 6322; + localContext._tableFormat = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 68 || _la === 80)) { + localContext._tableFormat = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 6323; + this.tableName(); + this.state = 6326; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 68 || _la === 80) { + { + this.state = 6324; + localContext._schemaFormat = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 68 || _la === 80)) { + localContext._schemaFormat = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 6325; + this.databaseName(); + } + } + this.state = 6330; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 192) { + { + this.state = 6328; + this.match(MySqlParser.KW_WHERE); + this.state = 6329; + this.expression(0); + } + } + } + break; + case 20: + localContext = new ShowOpenTablesContext(localContext); + this.enterOuterAlt(localContext, 20); + { + this.state = 6332; + this.match(MySqlParser.KW_SHOW); + this.state = 6333; + this.match(MySqlParser.KW_OPEN); + this.state = 6334; + this.match(MySqlParser.KW_TABLES); + this.state = 6337; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 68 || _la === 80) { + { + this.state = 6335; + _la = this.tokenStream.LA(1); + if (!(_la === 68 || _la === 80)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 6336; + this.databaseName(); + } + } + this.state = 6340; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 99 || _la === 192) { + { + this.state = 6339; + this.showFilter(); + } + } + } + break; + case 21: + localContext = new ShowProfileContext(localContext); + this.enterOuterAlt(localContext, 21); + { + this.state = 6342; + this.match(MySqlParser.KW_SHOW); + this.state = 6343; + this.match(MySqlParser.KW_PROFILE); + this.state = 6352; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 7 || _la === 320 || _la === 355 || _la === 358 || _la === 439 || _la === 521 || _la === 605 || _la === 655 || _la === 802) { + { + this.state = 6344; + this.showProfileType(); + this.state = 6349; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 6345; + this.match(MySqlParser.COMMA); + this.state = 6346; + this.showProfileType(); + } + } + this.state = 6351; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + } + this.state = 6357; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 65) { + { + this.state = 6354; + this.match(MySqlParser.KW_FOR); + this.state = 6355; + this.match(MySqlParser.KW_QUERY); + this.state = 6356; + localContext._queryCount = this.decimalLiteral(); + } + } + this.state = 6365; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 100) { + { + this.state = 6359; + this.match(MySqlParser.KW_LIMIT); + this.state = 6360; + localContext._rowCount = this.decimalLiteral(); + this.state = 6363; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 509) { + { + this.state = 6361; + this.match(MySqlParser.KW_OFFSET); + this.state = 6362; + localContext._offset = this.decimalLiteral(); + } + } + } + } + } + break; + case 22: + localContext = new ShowSlaveStatusContext(localContext); + this.enterOuterAlt(localContext, 22); + { + this.state = 6367; + this.match(MySqlParser.KW_SHOW); + this.state = 6368; + _la = this.tokenStream.LA(1); + if (!(_la === 563 || _la === 598)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 6369; + this.match(MySqlParser.KW_STATUS); + this.state = 6371; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 65) { + { + this.state = 6370; + this.channelOption(); + } + } + } + break; + case 23: + localContext = new ShowReplicasContext(localContext); + this.enterOuterAlt(localContext, 23); + { + this.state = 6373; + this.match(MySqlParser.KW_SHOW); + this.state = 6374; + this.match(MySqlParser.KW_REPLICAS); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + variableClause() { + let localContext = new VariableClauseContext(this.context, this.state); + this.enterRule(localContext, 554, MySqlParser.RULE_variableClause); + let _la; + try { + this.state = 6387; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.LOCAL_ID: + this.enterOuterAlt(localContext, 1); + { + this.state = 6377; + this.match(MySqlParser.LOCAL_ID); + } + break; + case MySqlParser.GLOBAL_ID: + this.enterOuterAlt(localContext, 2); + { + this.state = 6378; + this.match(MySqlParser.GLOBAL_ID); + } + break; + case MySqlParser.KW_ARRAY: + case MySqlParser.KW_ATTRIBUTE: + case MySqlParser.KW_BUCKETS: + case MySqlParser.KW_CONDITION: + case MySqlParser.KW_CURRENT: + case MySqlParser.KW_CURRENT_USER: + case MySqlParser.KW_DATABASE: + case MySqlParser.KW_DEFAULT: + case MySqlParser.KW_DIAGNOSTICS: + case MySqlParser.KW_EMPTY: + case MySqlParser.KW_ENFORCED: + case MySqlParser.KW_EXCEPT: + case MySqlParser.KW_GROUP: + case MySqlParser.KW_IF: + case MySqlParser.KW_INSERT: + case MySqlParser.KW_LATERAL: + case MySqlParser.KW_LEFT: + case MySqlParser.KW_NUMBER: + case MySqlParser.KW_OPTIONAL: + case MySqlParser.KW_ORDER: + case MySqlParser.KW_PRIMARY: + case MySqlParser.KW_REPEAT: + case MySqlParser.KW_REPLACE: + case MySqlParser.KW_RIGHT: + case MySqlParser.KW_SCHEMA: + case MySqlParser.KW_SKIP_QUERY_REWRITE: + case MySqlParser.KW_STACKED: + case MySqlParser.KW_DATE: + case MySqlParser.KW_TIME: + case MySqlParser.KW_TIMESTAMP: + case MySqlParser.KW_DATETIME: + case MySqlParser.KW_YEAR: + case MySqlParser.KW_BINARY: + case MySqlParser.KW_TEXT: + case MySqlParser.KW_ENUM: + case MySqlParser.KW_SERIAL: + case MySqlParser.KW_JSON_TABLE: + case MySqlParser.KW_JSON_VALUE: + case MySqlParser.KW_NESTED: + case MySqlParser.KW_ORDINALITY: + case MySqlParser.KW_PATH: + case MySqlParser.KW_AVG: + case MySqlParser.KW_BIT_AND: + case MySqlParser.KW_BIT_OR: + case MySqlParser.KW_BIT_XOR: + case MySqlParser.KW_COUNT: + case MySqlParser.KW_CUME_DIST: + case MySqlParser.KW_DENSE_RANK: + case MySqlParser.KW_FIRST_VALUE: + case MySqlParser.KW_GROUP_CONCAT: + case MySqlParser.KW_LAG: + case MySqlParser.KW_LAST_VALUE: + case MySqlParser.KW_LEAD: + case MySqlParser.KW_MAX: + case MySqlParser.KW_MIN: + case MySqlParser.KW_NTILE: + case MySqlParser.KW_NTH_VALUE: + case MySqlParser.KW_PERCENT_RANK: + case MySqlParser.KW_RANK: + case MySqlParser.KW_ROW_NUMBER: + case MySqlParser.KW_STD: + case MySqlParser.KW_STDDEV: + case MySqlParser.KW_STDDEV_POP: + case MySqlParser.KW_STDDEV_SAMP: + case MySqlParser.KW_SUM: + case MySqlParser.KW_VAR_POP: + case MySqlParser.KW_VAR_SAMP: + case MySqlParser.KW_VARIANCE: + case MySqlParser.KW_CURRENT_DATE: + case MySqlParser.KW_CURRENT_TIME: + case MySqlParser.KW_CURRENT_TIMESTAMP: + case MySqlParser.KW_LOCALTIME: + case MySqlParser.KW_CURDATE: + case MySqlParser.KW_CURTIME: + case MySqlParser.KW_DATE_ADD: + case MySqlParser.KW_DATE_SUB: + case MySqlParser.KW_LOCALTIMESTAMP: + case MySqlParser.KW_NOW: + case MySqlParser.KW_POSITION: + case MySqlParser.KW_SUBSTR: + case MySqlParser.KW_SUBSTRING: + case MySqlParser.KW_SYSDATE: + case MySqlParser.KW_TRIM: + case MySqlParser.KW_UTC_DATE: + case MySqlParser.KW_UTC_TIME: + case MySqlParser.KW_UTC_TIMESTAMP: + case MySqlParser.KW_ACCOUNT: + case MySqlParser.KW_ACTION: + case MySqlParser.KW_AFTER: + case MySqlParser.KW_AGGREGATE: + case MySqlParser.KW_ALGORITHM: + case MySqlParser.KW_ANY: + case MySqlParser.KW_AT: + case MySqlParser.KW_AUTHORS: + case MySqlParser.KW_AUTOCOMMIT: + case MySqlParser.KW_AUTOEXTEND_SIZE: + case MySqlParser.KW_AUTO_INCREMENT: + case MySqlParser.KW_AVG_ROW_LENGTH: + case MySqlParser.KW_BEGIN: + case MySqlParser.KW_BINLOG: + case MySqlParser.KW_BIT: + case MySqlParser.KW_BLOCK: + case MySqlParser.KW_BOOL: + case MySqlParser.KW_BOOLEAN: + case MySqlParser.KW_BTREE: + case MySqlParser.KW_CACHE: + case MySqlParser.KW_CASCADED: + case MySqlParser.KW_CHAIN: + case MySqlParser.KW_CHANGED: + case MySqlParser.KW_CHANNEL: + case MySqlParser.KW_CHECKSUM: + case MySqlParser.KW_CIPHER: + case MySqlParser.KW_CLASS_ORIGIN: + case MySqlParser.KW_CLIENT: + case MySqlParser.KW_CLOSE: + case MySqlParser.KW_COALESCE: + case MySqlParser.KW_CODE: + case MySqlParser.KW_COLUMNS: + case MySqlParser.KW_COLUMN_FORMAT: + case MySqlParser.KW_COLUMN_NAME: + case MySqlParser.KW_COMMENT: + case MySqlParser.KW_COMMIT: + case MySqlParser.KW_COMPACT: + case MySqlParser.KW_COMPLETION: + case MySqlParser.KW_COMPRESSED: + case MySqlParser.KW_COMPRESSION: + case MySqlParser.KW_CONCURRENT: + case MySqlParser.KW_CONNECT: + case MySqlParser.KW_CONNECTION: + case MySqlParser.KW_CONSISTENT: + case MySqlParser.KW_CONSTRAINT_CATALOG: + case MySqlParser.KW_CONSTRAINT_SCHEMA: + case MySqlParser.KW_CONSTRAINT_NAME: + case MySqlParser.KW_CONTAINS: + case MySqlParser.KW_CONTEXT: + case MySqlParser.KW_CONTRIBUTORS: + case MySqlParser.KW_COPY: + case MySqlParser.KW_CPU: + case MySqlParser.KW_CURSOR_NAME: + case MySqlParser.KW_DATA: + case MySqlParser.KW_DATAFILE: + case MySqlParser.KW_DEALLOCATE: + case MySqlParser.KW_DEFAULT_AUTH: + case MySqlParser.KW_DEFINER: + case MySqlParser.KW_DELAY_KEY_WRITE: + case MySqlParser.KW_DES_KEY_FILE: + case MySqlParser.KW_DIRECTORY: + case MySqlParser.KW_DISABLE: + case MySqlParser.KW_DISCARD: + case MySqlParser.KW_DISK: + case MySqlParser.KW_DO: + case MySqlParser.KW_DUMPFILE: + case MySqlParser.KW_DUPLICATE: + case MySqlParser.KW_DYNAMIC: + case MySqlParser.KW_ENABLE: + case MySqlParser.KW_ENCRYPTION: + case MySqlParser.KW_END: + case MySqlParser.KW_ENDS: + case MySqlParser.KW_ENGINE: + case MySqlParser.KW_ENGINES: + case MySqlParser.KW_ERROR: + case MySqlParser.KW_ERRORS: + case MySqlParser.KW_ESCAPE: + case MySqlParser.KW_EVENT: + case MySqlParser.KW_EVENTS: + case MySqlParser.KW_EVERY: + case MySqlParser.KW_EXCHANGE: + case MySqlParser.KW_EXCLUSIVE: + case MySqlParser.KW_EXPIRE: + case MySqlParser.KW_EXPORT: + case MySqlParser.KW_EXTENDED: + case MySqlParser.KW_EXTENT_SIZE: + case MySqlParser.KW_FAILED_LOGIN_ATTEMPTS: + case MySqlParser.KW_FAST: + case MySqlParser.KW_FAULTS: + case MySqlParser.KW_FIELDS: + case MySqlParser.KW_FILE_BLOCK_SIZE: + case MySqlParser.KW_FILTER: + case MySqlParser.KW_FIRST: + case MySqlParser.KW_FIXED: + case MySqlParser.KW_FLUSH: + case MySqlParser.KW_FOLLOWS: + case MySqlParser.KW_FOUND: + case MySqlParser.KW_FULL: + case MySqlParser.KW_FUNCTION: + case MySqlParser.KW_GENERAL: + case MySqlParser.KW_GLOBAL: + case MySqlParser.KW_GRANTS: + case MySqlParser.KW_GROUP_REPLICATION: + case MySqlParser.KW_HANDLER: + case MySqlParser.KW_HASH: + case MySqlParser.KW_HELP: + case MySqlParser.KW_HISTORY: + case MySqlParser.KW_HOST: + case MySqlParser.KW_HOSTS: + case MySqlParser.KW_IDENTIFIED: + case MySqlParser.KW_IGNORE_SERVER_IDS: + case MySqlParser.KW_IMPORT: + case MySqlParser.KW_INDEXES: + case MySqlParser.KW_INITIAL_SIZE: + case MySqlParser.KW_INPLACE: + case MySqlParser.KW_INSERT_METHOD: + case MySqlParser.KW_INSTALL: + case MySqlParser.KW_INSTANCE: + case MySqlParser.KW_INSTANT: + case MySqlParser.KW_INVISIBLE: + case MySqlParser.KW_INVOKER: + case MySqlParser.KW_IO: + case MySqlParser.KW_IO_THREAD: + case MySqlParser.KW_IPC: + case MySqlParser.KW_ISOLATION: + case MySqlParser.KW_ISSUER: + case MySqlParser.KW_JSON: + case MySqlParser.KW_KEY_BLOCK_SIZE: + case MySqlParser.KW_LANGUAGE: + case MySqlParser.KW_LAST: + case MySqlParser.KW_LEAVES: + case MySqlParser.KW_LESS: + case MySqlParser.KW_LEVEL: + case MySqlParser.KW_LIST: + case MySqlParser.KW_LOCAL: + case MySqlParser.KW_LOGFILE: + case MySqlParser.KW_LOGS: + case MySqlParser.KW_MASTER: + case MySqlParser.KW_MASTER_AUTO_POSITION: + case MySqlParser.KW_MASTER_CONNECT_RETRY: + case MySqlParser.KW_MASTER_DELAY: + case MySqlParser.KW_MASTER_HEARTBEAT_PERIOD: + case MySqlParser.KW_MASTER_HOST: + case MySqlParser.KW_MASTER_LOG_FILE: + case MySqlParser.KW_MASTER_LOG_POS: + case MySqlParser.KW_MASTER_PASSWORD: + case MySqlParser.KW_MASTER_PORT: + case MySqlParser.KW_MASTER_RETRY_COUNT: + case MySqlParser.KW_MASTER_SSL: + case MySqlParser.KW_MASTER_SSL_CA: + case MySqlParser.KW_MASTER_SSL_CAPATH: + case MySqlParser.KW_MASTER_SSL_CERT: + case MySqlParser.KW_MASTER_SSL_CIPHER: + case MySqlParser.KW_MASTER_SSL_CRL: + case MySqlParser.KW_MASTER_SSL_CRLPATH: + case MySqlParser.KW_MASTER_SSL_KEY: + case MySqlParser.KW_MASTER_TLS_VERSION: + case MySqlParser.KW_MASTER_USER: + case MySqlParser.KW_MAX_CONNECTIONS_PER_HOUR: + case MySqlParser.KW_MAX_QUERIES_PER_HOUR: + case MySqlParser.KW_MAX_ROWS: + case MySqlParser.KW_MAX_SIZE: + case MySqlParser.KW_MAX_UPDATES_PER_HOUR: + case MySqlParser.KW_MAX_USER_CONNECTIONS: + case MySqlParser.KW_MEDIUM: + case MySqlParser.KW_MEMBER: + case MySqlParser.KW_MERGE: + case MySqlParser.KW_MESSAGE_TEXT: + case MySqlParser.KW_MID: + case MySqlParser.KW_MIGRATE: + case MySqlParser.KW_MIN_ROWS: + case MySqlParser.KW_MODE: + case MySqlParser.KW_MODIFY: + case MySqlParser.KW_MUTEX: + case MySqlParser.KW_MYSQL: + case MySqlParser.KW_MYSQL_ERRNO: + case MySqlParser.KW_NAME: + case MySqlParser.KW_NAMES: + case MySqlParser.KW_NCHAR: + case MySqlParser.KW_NEVER: + case MySqlParser.KW_NEXT: + case MySqlParser.KW_NO: + case MySqlParser.KW_NOWAIT: + case MySqlParser.KW_NODEGROUP: + case MySqlParser.KW_NONE: + case MySqlParser.KW_ODBC: + case MySqlParser.KW_OFFLINE: + case MySqlParser.KW_OFFSET: + case MySqlParser.KW_OF: + case MySqlParser.KW_OLD_PASSWORD: + case MySqlParser.KW_ONE: + case MySqlParser.KW_ONLINE: + case MySqlParser.KW_ONLY: + case MySqlParser.KW_OPEN: + case MySqlParser.KW_OPTIMIZER_COSTS: + case MySqlParser.KW_OPTIONS: + case MySqlParser.KW_OWNER: + case MySqlParser.KW_PACK_KEYS: + case MySqlParser.KW_PAGE: + case MySqlParser.KW_PAGE_CHECKSUM: + case MySqlParser.KW_PARSER: + case MySqlParser.KW_PARTIAL: + case MySqlParser.KW_PARTITIONING: + case MySqlParser.KW_PARTITIONS: + case MySqlParser.KW_PASSWORD: + case MySqlParser.KW_PASSWORD_LOCK_TIME: + case MySqlParser.KW_PERSIST: + case MySqlParser.KW_PERSIST_ONLY: + case MySqlParser.KW_PHASE: + case MySqlParser.KW_PLUGIN: + case MySqlParser.KW_PLUGIN_DIR: + case MySqlParser.KW_PLUGINS: + case MySqlParser.KW_PORT: + case MySqlParser.KW_PRECEDES: + case MySqlParser.KW_PREPARE: + case MySqlParser.KW_PRESERVE: + case MySqlParser.KW_PREV: + case MySqlParser.KW_PROCESSLIST: + case MySqlParser.KW_PROFILE: + case MySqlParser.KW_PROFILES: + case MySqlParser.KW_PROXY: + case MySqlParser.KW_QUERY: + case MySqlParser.KW_QUICK: + case MySqlParser.KW_REBUILD: + case MySqlParser.KW_RECOVER: + case MySqlParser.KW_RECURSIVE: + case MySqlParser.KW_REDO_BUFFER_SIZE: + case MySqlParser.KW_REDUNDANT: + case MySqlParser.KW_RELAY: + case MySqlParser.KW_RELAY_LOG_FILE: + case MySqlParser.KW_RELAY_LOG_POS: + case MySqlParser.KW_RELAYLOG: + case MySqlParser.KW_REMOVE: + case MySqlParser.KW_REORGANIZE: + case MySqlParser.KW_REPAIR: + case MySqlParser.KW_REPLICATE_DO_DB: + case MySqlParser.KW_REPLICATE_DO_TABLE: + case MySqlParser.KW_REPLICATE_IGNORE_DB: + case MySqlParser.KW_REPLICATE_IGNORE_TABLE: + case MySqlParser.KW_REPLICATE_REWRITE_DB: + case MySqlParser.KW_REPLICATE_WILD_DO_TABLE: + case MySqlParser.KW_REPLICATE_WILD_IGNORE_TABLE: + case MySqlParser.KW_REPLICATION: + case MySqlParser.KW_RESET: + case MySqlParser.KW_RESUME: + case MySqlParser.KW_RETURNED_SQLSTATE: + case MySqlParser.KW_RETURNS: + case MySqlParser.KW_REUSE: + case MySqlParser.KW_ROLE: + case MySqlParser.KW_ROLLBACK: + case MySqlParser.KW_ROLLUP: + case MySqlParser.KW_ROTATE: + case MySqlParser.KW_ROW: + case MySqlParser.KW_ROWS: + case MySqlParser.KW_ROW_FORMAT: + case MySqlParser.KW_SAVEPOINT: + case MySqlParser.KW_SCHEDULE: + case MySqlParser.KW_SECURITY: + case MySqlParser.KW_SERVER: + case MySqlParser.KW_SESSION: + case MySqlParser.KW_SHARE: + case MySqlParser.KW_SHARED: + case MySqlParser.KW_SIGNED: + case MySqlParser.KW_SIMPLE: + case MySqlParser.KW_SLAVE: + case MySqlParser.KW_SLOW: + case MySqlParser.KW_SNAPSHOT: + case MySqlParser.KW_SOCKET: + case MySqlParser.KW_SOME: + case MySqlParser.KW_SONAME: + case MySqlParser.KW_SOUNDS: + case MySqlParser.KW_SOURCE: + case MySqlParser.KW_SQL_AFTER_GTIDS: + case MySqlParser.KW_SQL_AFTER_MTS_GAPS: + case MySqlParser.KW_SQL_BEFORE_GTIDS: + case MySqlParser.KW_SQL_BUFFER_RESULT: + case MySqlParser.KW_SQL_CACHE: + case MySqlParser.KW_SQL_NO_CACHE: + case MySqlParser.KW_SQL_THREAD: + case MySqlParser.KW_START: + case MySqlParser.KW_STARTS: + case MySqlParser.KW_STATS_AUTO_RECALC: + case MySqlParser.KW_STATS_PERSISTENT: + case MySqlParser.KW_STATS_SAMPLE_PAGES: + case MySqlParser.KW_STATUS: + case MySqlParser.KW_STOP: + case MySqlParser.KW_STORAGE: + case MySqlParser.KW_STRING: + case MySqlParser.KW_SUBCLASS_ORIGIN: + case MySqlParser.KW_SUBJECT: + case MySqlParser.KW_SUBPARTITION: + case MySqlParser.KW_SUBPARTITIONS: + case MySqlParser.KW_SUSPEND: + case MySqlParser.KW_SWAPS: + case MySqlParser.KW_SWITCHES: + case MySqlParser.KW_TABLE_NAME: + case MySqlParser.KW_TABLESPACE: + case MySqlParser.KW_TABLE_TYPE: + case MySqlParser.KW_TEMPORARY: + case MySqlParser.KW_TEMPTABLE: + case MySqlParser.KW_THAN: + case MySqlParser.KW_TRADITIONAL: + case MySqlParser.KW_TRANSACTION: + case MySqlParser.KW_TRANSACTIONAL: + case MySqlParser.KW_TRIGGERS: + case MySqlParser.KW_TRUNCATE: + case MySqlParser.KW_UNBOUNDED: + case MySqlParser.KW_UNDEFINED: + case MySqlParser.KW_UNDOFILE: + case MySqlParser.KW_UNDO_BUFFER_SIZE: + case MySqlParser.KW_UNINSTALL: + case MySqlParser.KW_UNKNOWN: + case MySqlParser.KW_UNTIL: + case MySqlParser.KW_UPGRADE: + case MySqlParser.KW_USER: + case MySqlParser.KW_USE_FRM: + case MySqlParser.KW_USER_RESOURCES: + case MySqlParser.KW_VALIDATION: + case MySqlParser.KW_VALUE: + case MySqlParser.KW_VARIABLES: + case MySqlParser.KW_VIEW: + case MySqlParser.KW_VIRTUAL: + case MySqlParser.KW_VISIBLE: + case MySqlParser.KW_WAIT: + case MySqlParser.KW_WARNINGS: + case MySqlParser.KW_WITHOUT: + case MySqlParser.KW_WORK: + case MySqlParser.KW_WRAPPER: + case MySqlParser.KW_X509: + case MySqlParser.KW_XA: + case MySqlParser.KW_XML: + case MySqlParser.KW_QUARTER: + case MySqlParser.KW_MONTH: + case MySqlParser.KW_DAY: + case MySqlParser.KW_HOUR: + case MySqlParser.KW_MINUTE: + case MySqlParser.KW_WEEK: + case MySqlParser.KW_SECOND: + case MySqlParser.KW_MICROSECOND: + case MySqlParser.KW_ADMIN: + case MySqlParser.KW_AUDIT_ABORT_EXEMPT: + case MySqlParser.KW_AUDIT_ADMIN: + case MySqlParser.KW_AUTHENTICATION_POLICY_ADMIN: + case MySqlParser.KW_BACKUP_ADMIN: + case MySqlParser.KW_BINLOG_ADMIN: + case MySqlParser.KW_BINLOG_ENCRYPTION_ADMIN: + case MySqlParser.KW_CLONE_ADMIN: + case MySqlParser.KW_CONNECTION_ADMIN: + case MySqlParser.KW_ENCRYPTION_KEY_ADMIN: + case MySqlParser.KW_EXECUTE: + case MySqlParser.KW_FILE: + case MySqlParser.KW_FIREWALL_ADMIN: + case MySqlParser.KW_FIREWALL_EXEMPT: + case MySqlParser.KW_FIREWALL_USER: + case MySqlParser.KW_GROUP_REPLICATION_ADMIN: + case MySqlParser.KW_INNODB_REDO_LOG_ARCHIVE: + case MySqlParser.KW_INVOKE: + case MySqlParser.KW_LAMBDA: + case MySqlParser.KW_NDB_STORED_USER: + case MySqlParser.KW_PASSWORDLESS_USER_ADMIN: + case MySqlParser.KW_PERSIST_RO_VARIABLES_ADMIN: + case MySqlParser.KW_PRIVILEGES: + case MySqlParser.KW_PROCESS: + case MySqlParser.KW_RELOAD: + case MySqlParser.KW_REPLICATION_APPLIER: + case MySqlParser.KW_REPLICATION_SLAVE_ADMIN: + case MySqlParser.KW_RESOURCE_GROUP_ADMIN: + case MySqlParser.KW_RESOURCE_GROUP_USER: + case MySqlParser.KW_ROLE_ADMIN: + case MySqlParser.KW_ROUTINE: + case MySqlParser.KW_S3: + case MySqlParser.KW_SESSION_VARIABLES_ADMIN: + case MySqlParser.KW_SET_USER_ID: + case MySqlParser.KW_SHOW_ROUTINE: + case MySqlParser.KW_SHUTDOWN: + case MySqlParser.KW_SUPER: + case MySqlParser.KW_SYSTEM_VARIABLES_ADMIN: + case MySqlParser.KW_TABLES: + case MySqlParser.KW_TABLE_ENCRYPTION_ADMIN: + case MySqlParser.KW_VERSION_TOKEN_ADMIN: + case MySqlParser.KW_XA_RECOVER_ADMIN: + case MySqlParser.KW_ARMSCII8: + case MySqlParser.KW_ASCII: + case MySqlParser.KW_BIG5: + case MySqlParser.KW_CP1250: + case MySqlParser.KW_CP1251: + case MySqlParser.KW_CP1256: + case MySqlParser.KW_CP1257: + case MySqlParser.KW_CP850: + case MySqlParser.KW_CP852: + case MySqlParser.KW_CP866: + case MySqlParser.KW_CP932: + case MySqlParser.KW_DEC8: + case MySqlParser.KW_EUCJPMS: + case MySqlParser.KW_EUCKR: + case MySqlParser.KW_GB18030: + case MySqlParser.KW_GB2312: + case MySqlParser.KW_GBK: + case MySqlParser.KW_GEOSTD8: + case MySqlParser.KW_GREEK: + case MySqlParser.KW_HEBREW: + case MySqlParser.KW_HP8: + case MySqlParser.KW_KEYBCS2: + case MySqlParser.KW_KOI8R: + case MySqlParser.KW_KOI8U: + case MySqlParser.KW_LATIN1: + case MySqlParser.KW_LATIN2: + case MySqlParser.KW_LATIN5: + case MySqlParser.KW_LATIN7: + case MySqlParser.KW_MACCE: + case MySqlParser.KW_MACROMAN: + case MySqlParser.KW_SJIS: + case MySqlParser.KW_SWE7: + case MySqlParser.KW_TIS620: + case MySqlParser.KW_UCS2: + case MySqlParser.KW_UJIS: + case MySqlParser.KW_UTF16: + case MySqlParser.KW_UTF16LE: + case MySqlParser.KW_UTF32: + case MySqlParser.KW_UTF8: + case MySqlParser.KW_UTF8MB3: + case MySqlParser.KW_UTF8MB4: + case MySqlParser.KW_ARCHIVE: + case MySqlParser.KW_BLACKHOLE: + case MySqlParser.KW_CSV: + case MySqlParser.KW_FEDERATED: + case MySqlParser.KW_INNODB: + case MySqlParser.KW_MEMORY: + case MySqlParser.KW_MRG_MYISAM: + case MySqlParser.KW_MYISAM: + case MySqlParser.KW_NDB: + case MySqlParser.KW_NDBCLUSTER: + case MySqlParser.KW_PERFORMANCE_SCHEMA: + case MySqlParser.KW_TOKUDB: + case MySqlParser.KW_REPEATABLE: + case MySqlParser.KW_COMMITTED: + case MySqlParser.KW_UNCOMMITTED: + case MySqlParser.KW_SERIALIZABLE: + case MySqlParser.KW_GEOMETRYCOLLECTION: + case MySqlParser.KW_LINESTRING: + case MySqlParser.KW_MULTILINESTRING: + case MySqlParser.KW_MULTIPOINT: + case MySqlParser.KW_MULTIPOLYGON: + case MySqlParser.KW_POINT: + case MySqlParser.KW_POLYGON: + case MySqlParser.KW_CATALOG_NAME: + case MySqlParser.KW_CHARSET: + case MySqlParser.KW_COLLATION: + case MySqlParser.KW_ENGINE_ATTRIBUTE: + case MySqlParser.KW_FORMAT: + case MySqlParser.KW_GET_FORMAT: + case MySqlParser.KW_RANDOM: + case MySqlParser.KW_REVERSE: + case MySqlParser.KW_ROW_COUNT: + case MySqlParser.KW_SCHEMA_NAME: + case MySqlParser.KW_SECONDARY_ENGINE_ATTRIBUTE: + case MySqlParser.KW_SRID: + case MySqlParser.KW_SYSTEM_USER: + case MySqlParser.KW_TP_CONNECTION_ADMIN: + case MySqlParser.KW_WEIGHT_STRING: + case MySqlParser.MOD: + case MySqlParser.AT_SIGN: + case MySqlParser.CHARSET_REVERSE_QOUTE_STRING: + case MySqlParser.STRING_LITERAL: + case MySqlParser.ID: + this.enterOuterAlt(localContext, 3); + { + this.state = 6384; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 915, this.context)) { + case 1: + { + this.state = 6381; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 870) { + { + this.state = 6379; + this.match(MySqlParser.AT_SIGN); + this.state = 6380; + this.match(MySqlParser.AT_SIGN); + } + } + this.state = 6383; + _la = this.tokenStream.LA(1); + if (!(_la === 413 || _la === 450 || _la === 531 || _la === 532 || _la === 593)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + break; + } + this.state = 6386; + localContext._target = this.uid(); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + showCommonEntity() { + let localContext = new ShowCommonEntityContext(this.context, this.state); + this.enterRule(localContext, 556, MySqlParser.RULE_showCommonEntity); + let _la; + try { + this.state = 6403; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_CHARACTER: + this.enterOuterAlt(localContext, 1); + { + this.state = 6389; + this.match(MySqlParser.KW_CHARACTER); + this.state = 6390; + this.match(MySqlParser.KW_SET); + } + break; + case MySqlParser.KW_CHARSET: + this.enterOuterAlt(localContext, 2); + { + this.state = 6391; + this.match(MySqlParser.KW_CHARSET); + } + break; + case MySqlParser.KW_COLLATION: + this.enterOuterAlt(localContext, 3); + { + this.state = 6392; + this.match(MySqlParser.KW_COLLATION); + } + break; + case MySqlParser.KW_DATABASES: + this.enterOuterAlt(localContext, 4); + { + this.state = 6393; + this.match(MySqlParser.KW_DATABASES); + } + break; + case MySqlParser.KW_SCHEMAS: + this.enterOuterAlt(localContext, 5); + { + this.state = 6394; + this.match(MySqlParser.KW_SCHEMAS); + } + break; + case MySqlParser.KW_FUNCTION: + this.enterOuterAlt(localContext, 6); + { + this.state = 6395; + this.match(MySqlParser.KW_FUNCTION); + this.state = 6396; + this.match(MySqlParser.KW_STATUS); + } + break; + case MySqlParser.KW_PROCEDURE: + this.enterOuterAlt(localContext, 7); + { + this.state = 6397; + this.match(MySqlParser.KW_PROCEDURE); + this.state = 6398; + this.match(MySqlParser.KW_STATUS); + } + break; + case MySqlParser.KW_GLOBAL: + case MySqlParser.KW_SESSION: + case MySqlParser.KW_STATUS: + case MySqlParser.KW_VARIABLES: + this.enterOuterAlt(localContext, 8); + { + this.state = 6400; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 413 || _la === 593) { + { + this.state = 6399; + _la = this.tokenStream.LA(1); + if (!(_la === 413 || _la === 593)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + this.state = 6402; + _la = this.tokenStream.LA(1); + if (!(_la === 645 || _la === 683)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + showFilter() { + let localContext = new ShowFilterContext(this.context, this.state); + this.enterRule(localContext, 558, MySqlParser.RULE_showFilter); + try { + this.state = 6409; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_LIKE: + this.enterOuterAlt(localContext, 1); + { + this.state = 6405; + this.match(MySqlParser.KW_LIKE); + this.state = 6406; + this.match(MySqlParser.STRING_LITERAL); + } + break; + case MySqlParser.KW_WHERE: + this.enterOuterAlt(localContext, 2); + { + this.state = 6407; + this.match(MySqlParser.KW_WHERE); + this.state = 6408; + this.expression(0); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + showGlobalInfoClause() { + let localContext = new ShowGlobalInfoClauseContext(this.context, this.state); + this.enterRule(localContext, 560, MySqlParser.RULE_showGlobalInfoClause); + let _la; + try { + this.state = 6428; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_ENGINES: + case MySqlParser.KW_STORAGE: + this.enterOuterAlt(localContext, 1); + { + this.state = 6412; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 647) { + { + this.state = 6411; + this.match(MySqlParser.KW_STORAGE); + } + } + this.state = 6414; + this.match(MySqlParser.KW_ENGINES); + } + break; + case MySqlParser.KW_MASTER: + this.enterOuterAlt(localContext, 2); + { + this.state = 6415; + this.match(MySqlParser.KW_MASTER); + this.state = 6416; + this.match(MySqlParser.KW_STATUS); + } + break; + case MySqlParser.KW_PLUGINS: + this.enterOuterAlt(localContext, 3); + { + this.state = 6417; + this.match(MySqlParser.KW_PLUGINS); + } + break; + case MySqlParser.KW_PRIVILEGES: + this.enterOuterAlt(localContext, 4); + { + this.state = 6418; + this.match(MySqlParser.KW_PRIVILEGES); + } + break; + case MySqlParser.KW_FULL: + case MySqlParser.KW_PROCESSLIST: + this.enterOuterAlt(localContext, 5); + { + this.state = 6420; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 408) { + { + this.state = 6419; + this.match(MySqlParser.KW_FULL); + } + } + this.state = 6422; + this.match(MySqlParser.KW_PROCESSLIST); + } + break; + case MySqlParser.KW_PROFILES: + this.enterOuterAlt(localContext, 6); + { + this.state = 6423; + this.match(MySqlParser.KW_PROFILES); + } + break; + case MySqlParser.KW_SLAVE: + this.enterOuterAlt(localContext, 7); + { + this.state = 6424; + this.match(MySqlParser.KW_SLAVE); + this.state = 6425; + this.match(MySqlParser.KW_HOSTS); + } + break; + case MySqlParser.KW_AUTHORS: + this.enterOuterAlt(localContext, 8); + { + this.state = 6426; + this.match(MySqlParser.KW_AUTHORS); + } + break; + case MySqlParser.KW_CONTRIBUTORS: + this.enterOuterAlt(localContext, 9); + { + this.state = 6427; + this.match(MySqlParser.KW_CONTRIBUTORS); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + showSchemaEntity() { + let localContext = new ShowSchemaEntityContext(this.context, this.state); + this.enterRule(localContext, 562, MySqlParser.RULE_showSchemaEntity); + let _la; + try { + this.state = 6441; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_EVENTS: + this.enterOuterAlt(localContext, 1); + { + this.state = 6430; + this.match(MySqlParser.KW_EVENTS); + } + break; + case MySqlParser.KW_TABLE: + this.enterOuterAlt(localContext, 2); + { + this.state = 6431; + this.match(MySqlParser.KW_TABLE); + this.state = 6432; + this.match(MySqlParser.KW_STATUS); + } + break; + case MySqlParser.KW_EXTENDED: + case MySqlParser.KW_FULL: + case MySqlParser.KW_TABLES: + this.enterOuterAlt(localContext, 3); + { + this.state = 6434; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 392) { + { + this.state = 6433; + this.match(MySqlParser.KW_EXTENDED); + } + } + this.state = 6437; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 408) { + { + this.state = 6436; + this.match(MySqlParser.KW_FULL); + } + } + this.state = 6439; + this.match(MySqlParser.KW_TABLES); + } + break; + case MySqlParser.KW_TRIGGERS: + this.enterOuterAlt(localContext, 4); + { + this.state = 6440; + this.match(MySqlParser.KW_TRIGGERS); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + showProfileType() { + let localContext = new ShowProfileTypeContext(this.context, this.state); + this.enterRule(localContext, 564, MySqlParser.RULE_showProfileType); + try { + this.state = 6455; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_ALL: + this.enterOuterAlt(localContext, 1); + { + this.state = 6443; + this.match(MySqlParser.KW_ALL); + } + break; + case MySqlParser.KW_BLOCK: + this.enterOuterAlt(localContext, 2); + { + this.state = 6444; + this.match(MySqlParser.KW_BLOCK); + this.state = 6445; + this.match(MySqlParser.KW_IO); + } + break; + case MySqlParser.KW_CONTEXT: + this.enterOuterAlt(localContext, 3); + { + this.state = 6446; + this.match(MySqlParser.KW_CONTEXT); + this.state = 6447; + this.match(MySqlParser.KW_SWITCHES); + } + break; + case MySqlParser.KW_CPU: + this.enterOuterAlt(localContext, 4); + { + this.state = 6448; + this.match(MySqlParser.KW_CPU); + } + break; + case MySqlParser.KW_IPC: + this.enterOuterAlt(localContext, 5); + { + this.state = 6449; + this.match(MySqlParser.KW_IPC); + } + break; + case MySqlParser.KW_MEMORY: + this.enterOuterAlt(localContext, 6); + { + this.state = 6450; + this.match(MySqlParser.KW_MEMORY); + } + break; + case MySqlParser.KW_PAGE: + this.enterOuterAlt(localContext, 7); + { + this.state = 6451; + this.match(MySqlParser.KW_PAGE); + this.state = 6452; + this.match(MySqlParser.KW_FAULTS); + } + break; + case MySqlParser.KW_SOURCE: + this.enterOuterAlt(localContext, 8); + { + this.state = 6453; + this.match(MySqlParser.KW_SOURCE); + } + break; + case MySqlParser.KW_SWAPS: + this.enterOuterAlt(localContext, 9); + { + this.state = 6454; + this.match(MySqlParser.KW_SWAPS); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + binlogStatement() { + let localContext = new BinlogStatementContext(this.context, this.state); + this.enterRule(localContext, 566, MySqlParser.RULE_binlogStatement); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6457; + this.match(MySqlParser.KW_BINLOG); + this.state = 6458; + this.match(MySqlParser.STRING_LITERAL); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + cacheIndexStatement() { + let localContext = new CacheIndexStatementContext(this.context, this.state); + this.enterRule(localContext, 568, MySqlParser.RULE_cacheIndexStatement); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6460; + this.match(MySqlParser.KW_CACHE); + this.state = 6461; + this.match(MySqlParser.KW_INDEX); + this.state = 6479; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 929, this.context)) { + case 1: + { + this.state = 6462; + this.tableIndex(); + this.state = 6467; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 6463; + this.match(MySqlParser.COMMA); + this.state = 6464; + this.tableIndex(); + } + } + this.state = 6469; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + break; + case 2: + { + this.state = 6470; + this.tableName(); + this.state = 6471; + this.match(MySqlParser.KW_PARTITION); + this.state = 6472; + this.match(MySqlParser.LR_BRACKET); + this.state = 6475; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_ARRAY: + case MySqlParser.KW_ATTRIBUTE: + case MySqlParser.KW_BUCKETS: + case MySqlParser.KW_CONDITION: + case MySqlParser.KW_CURRENT: + case MySqlParser.KW_CURRENT_USER: + case MySqlParser.KW_DATABASE: + case MySqlParser.KW_DEFAULT: + case MySqlParser.KW_DIAGNOSTICS: + case MySqlParser.KW_EMPTY: + case MySqlParser.KW_ENFORCED: + case MySqlParser.KW_EXCEPT: + case MySqlParser.KW_GROUP: + case MySqlParser.KW_IF: + case MySqlParser.KW_INSERT: + case MySqlParser.KW_LATERAL: + case MySqlParser.KW_LEFT: + case MySqlParser.KW_NUMBER: + case MySqlParser.KW_OPTIONAL: + case MySqlParser.KW_ORDER: + case MySqlParser.KW_PRIMARY: + case MySqlParser.KW_REPEAT: + case MySqlParser.KW_REPLACE: + case MySqlParser.KW_RIGHT: + case MySqlParser.KW_SCHEMA: + case MySqlParser.KW_SKIP_QUERY_REWRITE: + case MySqlParser.KW_STACKED: + case MySqlParser.KW_DATE: + case MySqlParser.KW_TIME: + case MySqlParser.KW_TIMESTAMP: + case MySqlParser.KW_DATETIME: + case MySqlParser.KW_YEAR: + case MySqlParser.KW_BINARY: + case MySqlParser.KW_TEXT: + case MySqlParser.KW_ENUM: + case MySqlParser.KW_SERIAL: + case MySqlParser.KW_JSON_TABLE: + case MySqlParser.KW_JSON_VALUE: + case MySqlParser.KW_NESTED: + case MySqlParser.KW_ORDINALITY: + case MySqlParser.KW_PATH: + case MySqlParser.KW_AVG: + case MySqlParser.KW_BIT_AND: + case MySqlParser.KW_BIT_OR: + case MySqlParser.KW_BIT_XOR: + case MySqlParser.KW_COUNT: + case MySqlParser.KW_CUME_DIST: + case MySqlParser.KW_DENSE_RANK: + case MySqlParser.KW_FIRST_VALUE: + case MySqlParser.KW_GROUP_CONCAT: + case MySqlParser.KW_LAG: + case MySqlParser.KW_LAST_VALUE: + case MySqlParser.KW_LEAD: + case MySqlParser.KW_MAX: + case MySqlParser.KW_MIN: + case MySqlParser.KW_NTILE: + case MySqlParser.KW_NTH_VALUE: + case MySqlParser.KW_PERCENT_RANK: + case MySqlParser.KW_RANK: + case MySqlParser.KW_ROW_NUMBER: + case MySqlParser.KW_STD: + case MySqlParser.KW_STDDEV: + case MySqlParser.KW_STDDEV_POP: + case MySqlParser.KW_STDDEV_SAMP: + case MySqlParser.KW_SUM: + case MySqlParser.KW_VAR_POP: + case MySqlParser.KW_VAR_SAMP: + case MySqlParser.KW_VARIANCE: + case MySqlParser.KW_CURRENT_DATE: + case MySqlParser.KW_CURRENT_TIME: + case MySqlParser.KW_CURRENT_TIMESTAMP: + case MySqlParser.KW_LOCALTIME: + case MySqlParser.KW_CURDATE: + case MySqlParser.KW_CURTIME: + case MySqlParser.KW_DATE_ADD: + case MySqlParser.KW_DATE_SUB: + case MySqlParser.KW_LOCALTIMESTAMP: + case MySqlParser.KW_NOW: + case MySqlParser.KW_POSITION: + case MySqlParser.KW_SUBSTR: + case MySqlParser.KW_SUBSTRING: + case MySqlParser.KW_SYSDATE: + case MySqlParser.KW_TRIM: + case MySqlParser.KW_UTC_DATE: + case MySqlParser.KW_UTC_TIME: + case MySqlParser.KW_UTC_TIMESTAMP: + case MySqlParser.KW_ACCOUNT: + case MySqlParser.KW_ACTION: + case MySqlParser.KW_AFTER: + case MySqlParser.KW_AGGREGATE: + case MySqlParser.KW_ALGORITHM: + case MySqlParser.KW_ANY: + case MySqlParser.KW_AT: + case MySqlParser.KW_AUTHORS: + case MySqlParser.KW_AUTOCOMMIT: + case MySqlParser.KW_AUTOEXTEND_SIZE: + case MySqlParser.KW_AUTO_INCREMENT: + case MySqlParser.KW_AVG_ROW_LENGTH: + case MySqlParser.KW_BEGIN: + case MySqlParser.KW_BINLOG: + case MySqlParser.KW_BIT: + case MySqlParser.KW_BLOCK: + case MySqlParser.KW_BOOL: + case MySqlParser.KW_BOOLEAN: + case MySqlParser.KW_BTREE: + case MySqlParser.KW_CACHE: + case MySqlParser.KW_CASCADED: + case MySqlParser.KW_CHAIN: + case MySqlParser.KW_CHANGED: + case MySqlParser.KW_CHANNEL: + case MySqlParser.KW_CHECKSUM: + case MySqlParser.KW_CIPHER: + case MySqlParser.KW_CLASS_ORIGIN: + case MySqlParser.KW_CLIENT: + case MySqlParser.KW_CLOSE: + case MySqlParser.KW_COALESCE: + case MySqlParser.KW_CODE: + case MySqlParser.KW_COLUMNS: + case MySqlParser.KW_COLUMN_FORMAT: + case MySqlParser.KW_COLUMN_NAME: + case MySqlParser.KW_COMMENT: + case MySqlParser.KW_COMMIT: + case MySqlParser.KW_COMPACT: + case MySqlParser.KW_COMPLETION: + case MySqlParser.KW_COMPRESSED: + case MySqlParser.KW_COMPRESSION: + case MySqlParser.KW_CONCURRENT: + case MySqlParser.KW_CONNECT: + case MySqlParser.KW_CONNECTION: + case MySqlParser.KW_CONSISTENT: + case MySqlParser.KW_CONSTRAINT_CATALOG: + case MySqlParser.KW_CONSTRAINT_SCHEMA: + case MySqlParser.KW_CONSTRAINT_NAME: + case MySqlParser.KW_CONTAINS: + case MySqlParser.KW_CONTEXT: + case MySqlParser.KW_CONTRIBUTORS: + case MySqlParser.KW_COPY: + case MySqlParser.KW_CPU: + case MySqlParser.KW_CURSOR_NAME: + case MySqlParser.KW_DATA: + case MySqlParser.KW_DATAFILE: + case MySqlParser.KW_DEALLOCATE: + case MySqlParser.KW_DEFAULT_AUTH: + case MySqlParser.KW_DEFINER: + case MySqlParser.KW_DELAY_KEY_WRITE: + case MySqlParser.KW_DES_KEY_FILE: + case MySqlParser.KW_DIRECTORY: + case MySqlParser.KW_DISABLE: + case MySqlParser.KW_DISCARD: + case MySqlParser.KW_DISK: + case MySqlParser.KW_DO: + case MySqlParser.KW_DUMPFILE: + case MySqlParser.KW_DUPLICATE: + case MySqlParser.KW_DYNAMIC: + case MySqlParser.KW_ENABLE: + case MySqlParser.KW_ENCRYPTION: + case MySqlParser.KW_END: + case MySqlParser.KW_ENDS: + case MySqlParser.KW_ENGINE: + case MySqlParser.KW_ENGINES: + case MySqlParser.KW_ERROR: + case MySqlParser.KW_ERRORS: + case MySqlParser.KW_ESCAPE: + case MySqlParser.KW_EVENT: + case MySqlParser.KW_EVENTS: + case MySqlParser.KW_EVERY: + case MySqlParser.KW_EXCHANGE: + case MySqlParser.KW_EXCLUSIVE: + case MySqlParser.KW_EXPIRE: + case MySqlParser.KW_EXPORT: + case MySqlParser.KW_EXTENDED: + case MySqlParser.KW_EXTENT_SIZE: + case MySqlParser.KW_FAILED_LOGIN_ATTEMPTS: + case MySqlParser.KW_FAST: + case MySqlParser.KW_FAULTS: + case MySqlParser.KW_FIELDS: + case MySqlParser.KW_FILE_BLOCK_SIZE: + case MySqlParser.KW_FILTER: + case MySqlParser.KW_FIRST: + case MySqlParser.KW_FIXED: + case MySqlParser.KW_FLUSH: + case MySqlParser.KW_FOLLOWS: + case MySqlParser.KW_FOUND: + case MySqlParser.KW_FULL: + case MySqlParser.KW_FUNCTION: + case MySqlParser.KW_GENERAL: + case MySqlParser.KW_GLOBAL: + case MySqlParser.KW_GRANTS: + case MySqlParser.KW_GROUP_REPLICATION: + case MySqlParser.KW_HANDLER: + case MySqlParser.KW_HASH: + case MySqlParser.KW_HELP: + case MySqlParser.KW_HISTORY: + case MySqlParser.KW_HOST: + case MySqlParser.KW_HOSTS: + case MySqlParser.KW_IDENTIFIED: + case MySqlParser.KW_IGNORE_SERVER_IDS: + case MySqlParser.KW_IMPORT: + case MySqlParser.KW_INDEXES: + case MySqlParser.KW_INITIAL_SIZE: + case MySqlParser.KW_INPLACE: + case MySqlParser.KW_INSERT_METHOD: + case MySqlParser.KW_INSTALL: + case MySqlParser.KW_INSTANCE: + case MySqlParser.KW_INSTANT: + case MySqlParser.KW_INVISIBLE: + case MySqlParser.KW_INVOKER: + case MySqlParser.KW_IO: + case MySqlParser.KW_IO_THREAD: + case MySqlParser.KW_IPC: + case MySqlParser.KW_ISOLATION: + case MySqlParser.KW_ISSUER: + case MySqlParser.KW_JSON: + case MySqlParser.KW_KEY_BLOCK_SIZE: + case MySqlParser.KW_LANGUAGE: + case MySqlParser.KW_LAST: + case MySqlParser.KW_LEAVES: + case MySqlParser.KW_LESS: + case MySqlParser.KW_LEVEL: + case MySqlParser.KW_LIST: + case MySqlParser.KW_LOCAL: + case MySqlParser.KW_LOGFILE: + case MySqlParser.KW_LOGS: + case MySqlParser.KW_MASTER: + case MySqlParser.KW_MASTER_AUTO_POSITION: + case MySqlParser.KW_MASTER_CONNECT_RETRY: + case MySqlParser.KW_MASTER_DELAY: + case MySqlParser.KW_MASTER_HEARTBEAT_PERIOD: + case MySqlParser.KW_MASTER_HOST: + case MySqlParser.KW_MASTER_LOG_FILE: + case MySqlParser.KW_MASTER_LOG_POS: + case MySqlParser.KW_MASTER_PASSWORD: + case MySqlParser.KW_MASTER_PORT: + case MySqlParser.KW_MASTER_RETRY_COUNT: + case MySqlParser.KW_MASTER_SSL: + case MySqlParser.KW_MASTER_SSL_CA: + case MySqlParser.KW_MASTER_SSL_CAPATH: + case MySqlParser.KW_MASTER_SSL_CERT: + case MySqlParser.KW_MASTER_SSL_CIPHER: + case MySqlParser.KW_MASTER_SSL_CRL: + case MySqlParser.KW_MASTER_SSL_CRLPATH: + case MySqlParser.KW_MASTER_SSL_KEY: + case MySqlParser.KW_MASTER_TLS_VERSION: + case MySqlParser.KW_MASTER_USER: + case MySqlParser.KW_MAX_CONNECTIONS_PER_HOUR: + case MySqlParser.KW_MAX_QUERIES_PER_HOUR: + case MySqlParser.KW_MAX_ROWS: + case MySqlParser.KW_MAX_SIZE: + case MySqlParser.KW_MAX_UPDATES_PER_HOUR: + case MySqlParser.KW_MAX_USER_CONNECTIONS: + case MySqlParser.KW_MEDIUM: + case MySqlParser.KW_MEMBER: + case MySqlParser.KW_MERGE: + case MySqlParser.KW_MESSAGE_TEXT: + case MySqlParser.KW_MID: + case MySqlParser.KW_MIGRATE: + case MySqlParser.KW_MIN_ROWS: + case MySqlParser.KW_MODE: + case MySqlParser.KW_MODIFY: + case MySqlParser.KW_MUTEX: + case MySqlParser.KW_MYSQL: + case MySqlParser.KW_MYSQL_ERRNO: + case MySqlParser.KW_NAME: + case MySqlParser.KW_NAMES: + case MySqlParser.KW_NCHAR: + case MySqlParser.KW_NEVER: + case MySqlParser.KW_NEXT: + case MySqlParser.KW_NO: + case MySqlParser.KW_NOWAIT: + case MySqlParser.KW_NODEGROUP: + case MySqlParser.KW_NONE: + case MySqlParser.KW_ODBC: + case MySqlParser.KW_OFFLINE: + case MySqlParser.KW_OFFSET: + case MySqlParser.KW_OF: + case MySqlParser.KW_OLD_PASSWORD: + case MySqlParser.KW_ONE: + case MySqlParser.KW_ONLINE: + case MySqlParser.KW_ONLY: + case MySqlParser.KW_OPEN: + case MySqlParser.KW_OPTIMIZER_COSTS: + case MySqlParser.KW_OPTIONS: + case MySqlParser.KW_OWNER: + case MySqlParser.KW_PACK_KEYS: + case MySqlParser.KW_PAGE: + case MySqlParser.KW_PAGE_CHECKSUM: + case MySqlParser.KW_PARSER: + case MySqlParser.KW_PARTIAL: + case MySqlParser.KW_PARTITIONING: + case MySqlParser.KW_PARTITIONS: + case MySqlParser.KW_PASSWORD: + case MySqlParser.KW_PASSWORD_LOCK_TIME: + case MySqlParser.KW_PHASE: + case MySqlParser.KW_PLUGIN: + case MySqlParser.KW_PLUGIN_DIR: + case MySqlParser.KW_PLUGINS: + case MySqlParser.KW_PORT: + case MySqlParser.KW_PRECEDES: + case MySqlParser.KW_PREPARE: + case MySqlParser.KW_PRESERVE: + case MySqlParser.KW_PREV: + case MySqlParser.KW_PROCESSLIST: + case MySqlParser.KW_PROFILE: + case MySqlParser.KW_PROFILES: + case MySqlParser.KW_PROXY: + case MySqlParser.KW_QUERY: + case MySqlParser.KW_QUICK: + case MySqlParser.KW_REBUILD: + case MySqlParser.KW_RECOVER: + case MySqlParser.KW_RECURSIVE: + case MySqlParser.KW_REDO_BUFFER_SIZE: + case MySqlParser.KW_REDUNDANT: + case MySqlParser.KW_RELAY: + case MySqlParser.KW_RELAY_LOG_FILE: + case MySqlParser.KW_RELAY_LOG_POS: + case MySqlParser.KW_RELAYLOG: + case MySqlParser.KW_REMOVE: + case MySqlParser.KW_REORGANIZE: + case MySqlParser.KW_REPAIR: + case MySqlParser.KW_REPLICATE_DO_DB: + case MySqlParser.KW_REPLICATE_DO_TABLE: + case MySqlParser.KW_REPLICATE_IGNORE_DB: + case MySqlParser.KW_REPLICATE_IGNORE_TABLE: + case MySqlParser.KW_REPLICATE_REWRITE_DB: + case MySqlParser.KW_REPLICATE_WILD_DO_TABLE: + case MySqlParser.KW_REPLICATE_WILD_IGNORE_TABLE: + case MySqlParser.KW_REPLICATION: + case MySqlParser.KW_RESET: + case MySqlParser.KW_RESUME: + case MySqlParser.KW_RETURNED_SQLSTATE: + case MySqlParser.KW_RETURNS: + case MySqlParser.KW_REUSE: + case MySqlParser.KW_ROLE: + case MySqlParser.KW_ROLLBACK: + case MySqlParser.KW_ROLLUP: + case MySqlParser.KW_ROTATE: + case MySqlParser.KW_ROW: + case MySqlParser.KW_ROWS: + case MySqlParser.KW_ROW_FORMAT: + case MySqlParser.KW_SAVEPOINT: + case MySqlParser.KW_SCHEDULE: + case MySqlParser.KW_SECURITY: + case MySqlParser.KW_SERVER: + case MySqlParser.KW_SESSION: + case MySqlParser.KW_SHARE: + case MySqlParser.KW_SHARED: + case MySqlParser.KW_SIGNED: + case MySqlParser.KW_SIMPLE: + case MySqlParser.KW_SLAVE: + case MySqlParser.KW_SLOW: + case MySqlParser.KW_SNAPSHOT: + case MySqlParser.KW_SOCKET: + case MySqlParser.KW_SOME: + case MySqlParser.KW_SONAME: + case MySqlParser.KW_SOUNDS: + case MySqlParser.KW_SOURCE: + case MySqlParser.KW_SQL_AFTER_GTIDS: + case MySqlParser.KW_SQL_AFTER_MTS_GAPS: + case MySqlParser.KW_SQL_BEFORE_GTIDS: + case MySqlParser.KW_SQL_BUFFER_RESULT: + case MySqlParser.KW_SQL_CACHE: + case MySqlParser.KW_SQL_NO_CACHE: + case MySqlParser.KW_SQL_THREAD: + case MySqlParser.KW_START: + case MySqlParser.KW_STARTS: + case MySqlParser.KW_STATS_AUTO_RECALC: + case MySqlParser.KW_STATS_PERSISTENT: + case MySqlParser.KW_STATS_SAMPLE_PAGES: + case MySqlParser.KW_STATUS: + case MySqlParser.KW_STOP: + case MySqlParser.KW_STORAGE: + case MySqlParser.KW_STRING: + case MySqlParser.KW_SUBCLASS_ORIGIN: + case MySqlParser.KW_SUBJECT: + case MySqlParser.KW_SUBPARTITION: + case MySqlParser.KW_SUBPARTITIONS: + case MySqlParser.KW_SUSPEND: + case MySqlParser.KW_SWAPS: + case MySqlParser.KW_SWITCHES: + case MySqlParser.KW_TABLE_NAME: + case MySqlParser.KW_TABLESPACE: + case MySqlParser.KW_TABLE_TYPE: + case MySqlParser.KW_TEMPORARY: + case MySqlParser.KW_TEMPTABLE: + case MySqlParser.KW_THAN: + case MySqlParser.KW_TRADITIONAL: + case MySqlParser.KW_TRANSACTION: + case MySqlParser.KW_TRANSACTIONAL: + case MySqlParser.KW_TRIGGERS: + case MySqlParser.KW_TRUNCATE: + case MySqlParser.KW_UNBOUNDED: + case MySqlParser.KW_UNDEFINED: + case MySqlParser.KW_UNDOFILE: + case MySqlParser.KW_UNDO_BUFFER_SIZE: + case MySqlParser.KW_UNINSTALL: + case MySqlParser.KW_UNKNOWN: + case MySqlParser.KW_UNTIL: + case MySqlParser.KW_UPGRADE: + case MySqlParser.KW_USER: + case MySqlParser.KW_USE_FRM: + case MySqlParser.KW_USER_RESOURCES: + case MySqlParser.KW_VALIDATION: + case MySqlParser.KW_VALUE: + case MySqlParser.KW_VARIABLES: + case MySqlParser.KW_VIEW: + case MySqlParser.KW_VIRTUAL: + case MySqlParser.KW_VISIBLE: + case MySqlParser.KW_WAIT: + case MySqlParser.KW_WARNINGS: + case MySqlParser.KW_WITHOUT: + case MySqlParser.KW_WORK: + case MySqlParser.KW_WRAPPER: + case MySqlParser.KW_X509: + case MySqlParser.KW_XA: + case MySqlParser.KW_XML: + case MySqlParser.KW_QUARTER: + case MySqlParser.KW_MONTH: + case MySqlParser.KW_DAY: + case MySqlParser.KW_HOUR: + case MySqlParser.KW_MINUTE: + case MySqlParser.KW_WEEK: + case MySqlParser.KW_SECOND: + case MySqlParser.KW_MICROSECOND: + case MySqlParser.KW_ADMIN: + case MySqlParser.KW_AUDIT_ABORT_EXEMPT: + case MySqlParser.KW_AUDIT_ADMIN: + case MySqlParser.KW_AUTHENTICATION_POLICY_ADMIN: + case MySqlParser.KW_BACKUP_ADMIN: + case MySqlParser.KW_BINLOG_ADMIN: + case MySqlParser.KW_BINLOG_ENCRYPTION_ADMIN: + case MySqlParser.KW_CLONE_ADMIN: + case MySqlParser.KW_CONNECTION_ADMIN: + case MySqlParser.KW_ENCRYPTION_KEY_ADMIN: + case MySqlParser.KW_EXECUTE: + case MySqlParser.KW_FILE: + case MySqlParser.KW_FIREWALL_ADMIN: + case MySqlParser.KW_FIREWALL_EXEMPT: + case MySqlParser.KW_FIREWALL_USER: + case MySqlParser.KW_GROUP_REPLICATION_ADMIN: + case MySqlParser.KW_INNODB_REDO_LOG_ARCHIVE: + case MySqlParser.KW_INVOKE: + case MySqlParser.KW_LAMBDA: + case MySqlParser.KW_NDB_STORED_USER: + case MySqlParser.KW_PASSWORDLESS_USER_ADMIN: + case MySqlParser.KW_PERSIST_RO_VARIABLES_ADMIN: + case MySqlParser.KW_PRIVILEGES: + case MySqlParser.KW_PROCESS: + case MySqlParser.KW_RELOAD: + case MySqlParser.KW_REPLICATION_APPLIER: + case MySqlParser.KW_REPLICATION_SLAVE_ADMIN: + case MySqlParser.KW_RESOURCE_GROUP_ADMIN: + case MySqlParser.KW_RESOURCE_GROUP_USER: + case MySqlParser.KW_ROLE_ADMIN: + case MySqlParser.KW_ROUTINE: + case MySqlParser.KW_S3: + case MySqlParser.KW_SESSION_VARIABLES_ADMIN: + case MySqlParser.KW_SET_USER_ID: + case MySqlParser.KW_SHOW_ROUTINE: + case MySqlParser.KW_SHUTDOWN: + case MySqlParser.KW_SUPER: + case MySqlParser.KW_SYSTEM_VARIABLES_ADMIN: + case MySqlParser.KW_TABLES: + case MySqlParser.KW_TABLE_ENCRYPTION_ADMIN: + case MySqlParser.KW_VERSION_TOKEN_ADMIN: + case MySqlParser.KW_XA_RECOVER_ADMIN: + case MySqlParser.KW_ARMSCII8: + case MySqlParser.KW_ASCII: + case MySqlParser.KW_BIG5: + case MySqlParser.KW_CP1250: + case MySqlParser.KW_CP1251: + case MySqlParser.KW_CP1256: + case MySqlParser.KW_CP1257: + case MySqlParser.KW_CP850: + case MySqlParser.KW_CP852: + case MySqlParser.KW_CP866: + case MySqlParser.KW_CP932: + case MySqlParser.KW_DEC8: + case MySqlParser.KW_EUCJPMS: + case MySqlParser.KW_EUCKR: + case MySqlParser.KW_GB18030: + case MySqlParser.KW_GB2312: + case MySqlParser.KW_GBK: + case MySqlParser.KW_GEOSTD8: + case MySqlParser.KW_GREEK: + case MySqlParser.KW_HEBREW: + case MySqlParser.KW_HP8: + case MySqlParser.KW_KEYBCS2: + case MySqlParser.KW_KOI8R: + case MySqlParser.KW_KOI8U: + case MySqlParser.KW_LATIN1: + case MySqlParser.KW_LATIN2: + case MySqlParser.KW_LATIN5: + case MySqlParser.KW_LATIN7: + case MySqlParser.KW_MACCE: + case MySqlParser.KW_MACROMAN: + case MySqlParser.KW_SJIS: + case MySqlParser.KW_SWE7: + case MySqlParser.KW_TIS620: + case MySqlParser.KW_UCS2: + case MySqlParser.KW_UJIS: + case MySqlParser.KW_UTF16: + case MySqlParser.KW_UTF16LE: + case MySqlParser.KW_UTF32: + case MySqlParser.KW_UTF8: + case MySqlParser.KW_UTF8MB3: + case MySqlParser.KW_UTF8MB4: + case MySqlParser.KW_ARCHIVE: + case MySqlParser.KW_BLACKHOLE: + case MySqlParser.KW_CSV: + case MySqlParser.KW_FEDERATED: + case MySqlParser.KW_INNODB: + case MySqlParser.KW_MEMORY: + case MySqlParser.KW_MRG_MYISAM: + case MySqlParser.KW_MYISAM: + case MySqlParser.KW_NDB: + case MySqlParser.KW_NDBCLUSTER: + case MySqlParser.KW_PERFORMANCE_SCHEMA: + case MySqlParser.KW_TOKUDB: + case MySqlParser.KW_REPEATABLE: + case MySqlParser.KW_COMMITTED: + case MySqlParser.KW_UNCOMMITTED: + case MySqlParser.KW_SERIALIZABLE: + case MySqlParser.KW_GEOMETRYCOLLECTION: + case MySqlParser.KW_LINESTRING: + case MySqlParser.KW_MULTILINESTRING: + case MySqlParser.KW_MULTIPOINT: + case MySqlParser.KW_MULTIPOLYGON: + case MySqlParser.KW_POINT: + case MySqlParser.KW_POLYGON: + case MySqlParser.KW_CATALOG_NAME: + case MySqlParser.KW_CHARSET: + case MySqlParser.KW_COLLATION: + case MySqlParser.KW_ENGINE_ATTRIBUTE: + case MySqlParser.KW_FORMAT: + case MySqlParser.KW_GET_FORMAT: + case MySqlParser.KW_RANDOM: + case MySqlParser.KW_REVERSE: + case MySqlParser.KW_ROW_COUNT: + case MySqlParser.KW_SCHEMA_NAME: + case MySqlParser.KW_SECONDARY_ENGINE_ATTRIBUTE: + case MySqlParser.KW_SRID: + case MySqlParser.KW_SYSTEM_USER: + case MySqlParser.KW_TP_CONNECTION_ADMIN: + case MySqlParser.KW_WEIGHT_STRING: + case MySqlParser.MOD: + case MySqlParser.CHARSET_REVERSE_QOUTE_STRING: + case MySqlParser.STRING_LITERAL: + case MySqlParser.ID: + { + this.state = 6473; + this.partitionNames(); + } + break; + case MySqlParser.KW_ALL: + { + this.state = 6474; + this.match(MySqlParser.KW_ALL); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + this.state = 6477; + this.match(MySqlParser.RR_BRACKET); + } + break; + } + this.state = 6481; + this.match(MySqlParser.KW_IN); + this.state = 6482; + this.databaseName(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + flushStatement() { + let localContext = new FlushStatementContext(this.context, this.state); + this.enterRule(localContext, 570, MySqlParser.RULE_flushStatement); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6484; + this.match(MySqlParser.KW_FLUSH); + this.state = 6486; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 115 || _la === 450) { + { + this.state = 6485; + this.tableActionOption(); + } + } + this.state = 6488; + this.flushOption(); + this.state = 6493; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 6489; + this.match(MySqlParser.COMMA); + this.state = 6490; + this.flushOption(); + } + } + this.state = 6495; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + killStatement() { + let localContext = new KillStatementContext(this.context, this.state); + this.enterRule(localContext, 572, MySqlParser.RULE_killStatement); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6496; + this.match(MySqlParser.KW_KILL); + this.state = 6498; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 932, this.context)) { + case 1: + { + this.state = 6497; + localContext._connectionFormat = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 349 || _la === 548)) { + localContext._connectionFormat = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + break; + } + this.state = 6500; + this.expression(0); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + loadIndexIntoCache() { + let localContext = new LoadIndexIntoCacheContext(this.context, this.state); + this.enterRule(localContext, 574, MySqlParser.RULE_loadIndexIntoCache); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6502; + this.match(MySqlParser.KW_LOAD); + this.state = 6503; + this.match(MySqlParser.KW_INDEX); + this.state = 6504; + this.match(MySqlParser.KW_INTO); + this.state = 6505; + this.match(MySqlParser.KW_CACHE); + this.state = 6506; + this.loadedTableIndexes(); + this.state = 6511; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 6507; + this.match(MySqlParser.COMMA); + this.state = 6508; + this.loadedTableIndexes(); + } + } + this.state = 6513; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + resetStatement() { + let localContext = new ResetStatementContext(this.context, this.state); + this.enterRule(localContext, 576, MySqlParser.RULE_resetStatement); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6514; + this.match(MySqlParser.KW_RESET); + this.state = 6515; + this.resetOption(); + this.state = 6520; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 6516; + this.match(MySqlParser.COMMA); + this.state = 6517; + this.resetOption(); + } + } + this.state = 6522; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + resetOption() { + let localContext = new ResetOptionContext(this.context, this.state); + this.enterRule(localContext, 578, MySqlParser.RULE_resetOption); + try { + this.state = 6528; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_MASTER: + this.enterOuterAlt(localContext, 1); + { + this.state = 6523; + this.match(MySqlParser.KW_MASTER); + } + break; + case MySqlParser.KW_REPLICA: + this.enterOuterAlt(localContext, 2); + { + this.state = 6524; + this.match(MySqlParser.KW_REPLICA); + } + break; + case MySqlParser.KW_QUERY: + this.enterOuterAlt(localContext, 3); + { + this.state = 6525; + this.match(MySqlParser.KW_QUERY); + this.state = 6526; + this.match(MySqlParser.KW_CACHE); + } + break; + case MySqlParser.KW_SLAVE: + this.enterOuterAlt(localContext, 4); + { + this.state = 6527; + this.match(MySqlParser.KW_SLAVE); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + resetPersist() { + let localContext = new ResetPersistContext(this.context, this.state); + this.enterRule(localContext, 580, MySqlParser.RULE_resetPersist); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6530; + this.match(MySqlParser.KW_RESET); + this.state = 6531; + this.match(MySqlParser.KW_PERSIST); + this.state = 6536; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 937, this.context)) { + case 1: + { + this.state = 6533; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 936, this.context)) { + case 1: + { + this.state = 6532; + this.ifExists(); + } + break; + } + this.state = 6535; + localContext._system_var_name = this.uid(); + } + break; + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + resetAllChannel() { + let localContext = new ResetAllChannelContext(this.context, this.state); + this.enterRule(localContext, 582, MySqlParser.RULE_resetAllChannel); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6538; + this.match(MySqlParser.KW_RESET); + this.state = 6539; + _la = this.tokenStream.LA(1); + if (!(_la === 563 || _la === 598)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 6541; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 7) { + { + this.state = 6540; + this.match(MySqlParser.KW_ALL); + } + } + this.state = 6544; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 65) { + { + this.state = 6543; + this.channelOption(); + } + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + reStartStatement() { + let localContext = new ReStartStatementContext(this.context, this.state); + this.enterRule(localContext, 584, MySqlParser.RULE_reStartStatement); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6546; + this.match(MySqlParser.KW_RESTART); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + shutdownStatement() { + let localContext = new ShutdownStatementContext(this.context, this.state); + this.enterRule(localContext, 586, MySqlParser.RULE_shutdownStatement); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6548; + this.match(MySqlParser.KW_SHUTDOWN); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + tableIndex() { + let localContext = new TableIndexContext(this.context, this.state); + this.enterRule(localContext, 588, MySqlParser.RULE_tableIndex); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6550; + this.tableName(); + this.state = 6556; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 82 || _la === 92) { + { + this.state = 6551; + localContext._indexFormat = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 82 || _la === 92)) { + localContext._indexFormat = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 6552; + this.match(MySqlParser.LR_BRACKET); + this.state = 6553; + this.indexNames(); + this.state = 6554; + this.match(MySqlParser.RR_BRACKET); + } + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + flushOption() { + let localContext = new FlushOptionContext(this.context, this.state); + this.enterRule(localContext, 590, MySqlParser.RULE_flushOption); + let _la; + try { + this.state = 6590; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 947, this.context)) { + case 1: + localContext = new SimpleFlushOptionContext(localContext); + this.enterOuterAlt(localContext, 1); + { + this.state = 6576; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_DES_KEY_FILE: + { + this.state = 6558; + this.match(MySqlParser.KW_DES_KEY_FILE); + } + break; + case MySqlParser.KW_HOSTS: + { + this.state = 6559; + this.match(MySqlParser.KW_HOSTS); + } + break; + case MySqlParser.KW_BINARY: + case MySqlParser.KW_ENGINE: + case MySqlParser.KW_ERROR: + case MySqlParser.KW_GENERAL: + case MySqlParser.KW_LOGS: + case MySqlParser.KW_RELAY: + case MySqlParser.KW_SLOW: + { + this.state = 6561; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 228 || ((((_la - 380)) & ~0x1F) === 0 && ((1 << (_la - 380)) & 1073741829) !== 0) || _la === 556 || _la === 599) { + { + this.state = 6560; + _la = this.tokenStream.LA(1); + if (!(_la === 228 || ((((_la - 380)) & ~0x1F) === 0 && ((1 << (_la - 380)) & 1073741829) !== 0) || _la === 556 || _la === 599)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + this.state = 6563; + this.match(MySqlParser.KW_LOGS); + } + break; + case MySqlParser.KW_OPTIMIZER_COSTS: + { + this.state = 6564; + this.match(MySqlParser.KW_OPTIMIZER_COSTS); + } + break; + case MySqlParser.KW_PRIVILEGES: + { + this.state = 6565; + this.match(MySqlParser.KW_PRIVILEGES); + } + break; + case MySqlParser.KW_QUERY: + { + this.state = 6566; + this.match(MySqlParser.KW_QUERY); + this.state = 6567; + this.match(MySqlParser.KW_CACHE); + } + break; + case MySqlParser.KW_STATUS: + { + this.state = 6568; + this.match(MySqlParser.KW_STATUS); + } + break; + case MySqlParser.KW_USER_RESOURCES: + { + this.state = 6569; + this.match(MySqlParser.KW_USER_RESOURCES); + } + break; + case MySqlParser.KW_TABLES: + { + this.state = 6570; + this.match(MySqlParser.KW_TABLES); + this.state = 6574; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 942, this.context)) { + case 1: + { + this.state = 6571; + this.match(MySqlParser.KW_WITH); + this.state = 6572; + this.match(MySqlParser.KW_READ); + this.state = 6573; + this.match(MySqlParser.KW_LOCK); + } + break; + } + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + break; + case 2: + localContext = new ChannelFlushOptionContext(localContext); + this.enterOuterAlt(localContext, 2); + { + this.state = 6578; + this.match(MySqlParser.KW_RELAY); + this.state = 6579; + this.match(MySqlParser.KW_LOGS); + this.state = 6581; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 65) { + { + this.state = 6580; + this.channelOption(); + } + } + } + break; + case 3: + localContext = new TableFlushOptionContext(localContext); + this.enterOuterAlt(localContext, 3); + { + this.state = 6583; + _la = this.tokenStream.LA(1); + if (!(_la === 173 || _la === 752)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 6585; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 945, this.context)) { + case 1: + { + this.state = 6584; + this.tableNames(); + } + break; + } + this.state = 6588; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 946, this.context)) { + case 1: + { + this.state = 6587; + this.flushTableOption(); + } + break; + } + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + flushTableOption() { + let localContext = new FlushTableOptionContext(this.context, this.state); + this.enterRule(localContext, 592, MySqlParser.RULE_flushTableOption); + try { + this.state = 6597; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_WITH: + this.enterOuterAlt(localContext, 1); + { + this.state = 6592; + this.match(MySqlParser.KW_WITH); + this.state = 6593; + this.match(MySqlParser.KW_READ); + this.state = 6594; + this.match(MySqlParser.KW_LOCK); + } + break; + case MySqlParser.KW_FOR: + this.enterOuterAlt(localContext, 2); + { + this.state = 6595; + this.match(MySqlParser.KW_FOR); + this.state = 6596; + this.match(MySqlParser.KW_EXPORT); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + loadedTableIndexes() { + let localContext = new LoadedTableIndexesContext(this.context, this.state); + this.enterRule(localContext, 594, MySqlParser.RULE_loadedTableIndexes); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6599; + this.tableName(); + this.state = 6607; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 130) { + { + this.state = 6600; + this.match(MySqlParser.KW_PARTITION); + this.state = 6601; + this.match(MySqlParser.LR_BRACKET); + this.state = 6604; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_ARRAY: + case MySqlParser.KW_ATTRIBUTE: + case MySqlParser.KW_BUCKETS: + case MySqlParser.KW_CONDITION: + case MySqlParser.KW_CURRENT: + case MySqlParser.KW_CURRENT_USER: + case MySqlParser.KW_DATABASE: + case MySqlParser.KW_DEFAULT: + case MySqlParser.KW_DIAGNOSTICS: + case MySqlParser.KW_EMPTY: + case MySqlParser.KW_ENFORCED: + case MySqlParser.KW_EXCEPT: + case MySqlParser.KW_GROUP: + case MySqlParser.KW_IF: + case MySqlParser.KW_INSERT: + case MySqlParser.KW_LATERAL: + case MySqlParser.KW_LEFT: + case MySqlParser.KW_NUMBER: + case MySqlParser.KW_OPTIONAL: + case MySqlParser.KW_ORDER: + case MySqlParser.KW_PRIMARY: + case MySqlParser.KW_REPEAT: + case MySqlParser.KW_REPLACE: + case MySqlParser.KW_RIGHT: + case MySqlParser.KW_SCHEMA: + case MySqlParser.KW_SKIP_QUERY_REWRITE: + case MySqlParser.KW_STACKED: + case MySqlParser.KW_DATE: + case MySqlParser.KW_TIME: + case MySqlParser.KW_TIMESTAMP: + case MySqlParser.KW_DATETIME: + case MySqlParser.KW_YEAR: + case MySqlParser.KW_BINARY: + case MySqlParser.KW_TEXT: + case MySqlParser.KW_ENUM: + case MySqlParser.KW_SERIAL: + case MySqlParser.KW_JSON_TABLE: + case MySqlParser.KW_JSON_VALUE: + case MySqlParser.KW_NESTED: + case MySqlParser.KW_ORDINALITY: + case MySqlParser.KW_PATH: + case MySqlParser.KW_AVG: + case MySqlParser.KW_BIT_AND: + case MySqlParser.KW_BIT_OR: + case MySqlParser.KW_BIT_XOR: + case MySqlParser.KW_COUNT: + case MySqlParser.KW_CUME_DIST: + case MySqlParser.KW_DENSE_RANK: + case MySqlParser.KW_FIRST_VALUE: + case MySqlParser.KW_GROUP_CONCAT: + case MySqlParser.KW_LAG: + case MySqlParser.KW_LAST_VALUE: + case MySqlParser.KW_LEAD: + case MySqlParser.KW_MAX: + case MySqlParser.KW_MIN: + case MySqlParser.KW_NTILE: + case MySqlParser.KW_NTH_VALUE: + case MySqlParser.KW_PERCENT_RANK: + case MySqlParser.KW_RANK: + case MySqlParser.KW_ROW_NUMBER: + case MySqlParser.KW_STD: + case MySqlParser.KW_STDDEV: + case MySqlParser.KW_STDDEV_POP: + case MySqlParser.KW_STDDEV_SAMP: + case MySqlParser.KW_SUM: + case MySqlParser.KW_VAR_POP: + case MySqlParser.KW_VAR_SAMP: + case MySqlParser.KW_VARIANCE: + case MySqlParser.KW_CURRENT_DATE: + case MySqlParser.KW_CURRENT_TIME: + case MySqlParser.KW_CURRENT_TIMESTAMP: + case MySqlParser.KW_LOCALTIME: + case MySqlParser.KW_CURDATE: + case MySqlParser.KW_CURTIME: + case MySqlParser.KW_DATE_ADD: + case MySqlParser.KW_DATE_SUB: + case MySqlParser.KW_LOCALTIMESTAMP: + case MySqlParser.KW_NOW: + case MySqlParser.KW_POSITION: + case MySqlParser.KW_SUBSTR: + case MySqlParser.KW_SUBSTRING: + case MySqlParser.KW_SYSDATE: + case MySqlParser.KW_TRIM: + case MySqlParser.KW_UTC_DATE: + case MySqlParser.KW_UTC_TIME: + case MySqlParser.KW_UTC_TIMESTAMP: + case MySqlParser.KW_ACCOUNT: + case MySqlParser.KW_ACTION: + case MySqlParser.KW_AFTER: + case MySqlParser.KW_AGGREGATE: + case MySqlParser.KW_ALGORITHM: + case MySqlParser.KW_ANY: + case MySqlParser.KW_AT: + case MySqlParser.KW_AUTHORS: + case MySqlParser.KW_AUTOCOMMIT: + case MySqlParser.KW_AUTOEXTEND_SIZE: + case MySqlParser.KW_AUTO_INCREMENT: + case MySqlParser.KW_AVG_ROW_LENGTH: + case MySqlParser.KW_BEGIN: + case MySqlParser.KW_BINLOG: + case MySqlParser.KW_BIT: + case MySqlParser.KW_BLOCK: + case MySqlParser.KW_BOOL: + case MySqlParser.KW_BOOLEAN: + case MySqlParser.KW_BTREE: + case MySqlParser.KW_CACHE: + case MySqlParser.KW_CASCADED: + case MySqlParser.KW_CHAIN: + case MySqlParser.KW_CHANGED: + case MySqlParser.KW_CHANNEL: + case MySqlParser.KW_CHECKSUM: + case MySqlParser.KW_CIPHER: + case MySqlParser.KW_CLASS_ORIGIN: + case MySqlParser.KW_CLIENT: + case MySqlParser.KW_CLOSE: + case MySqlParser.KW_COALESCE: + case MySqlParser.KW_CODE: + case MySqlParser.KW_COLUMNS: + case MySqlParser.KW_COLUMN_FORMAT: + case MySqlParser.KW_COLUMN_NAME: + case MySqlParser.KW_COMMENT: + case MySqlParser.KW_COMMIT: + case MySqlParser.KW_COMPACT: + case MySqlParser.KW_COMPLETION: + case MySqlParser.KW_COMPRESSED: + case MySqlParser.KW_COMPRESSION: + case MySqlParser.KW_CONCURRENT: + case MySqlParser.KW_CONNECT: + case MySqlParser.KW_CONNECTION: + case MySqlParser.KW_CONSISTENT: + case MySqlParser.KW_CONSTRAINT_CATALOG: + case MySqlParser.KW_CONSTRAINT_SCHEMA: + case MySqlParser.KW_CONSTRAINT_NAME: + case MySqlParser.KW_CONTAINS: + case MySqlParser.KW_CONTEXT: + case MySqlParser.KW_CONTRIBUTORS: + case MySqlParser.KW_COPY: + case MySqlParser.KW_CPU: + case MySqlParser.KW_CURSOR_NAME: + case MySqlParser.KW_DATA: + case MySqlParser.KW_DATAFILE: + case MySqlParser.KW_DEALLOCATE: + case MySqlParser.KW_DEFAULT_AUTH: + case MySqlParser.KW_DEFINER: + case MySqlParser.KW_DELAY_KEY_WRITE: + case MySqlParser.KW_DES_KEY_FILE: + case MySqlParser.KW_DIRECTORY: + case MySqlParser.KW_DISABLE: + case MySqlParser.KW_DISCARD: + case MySqlParser.KW_DISK: + case MySqlParser.KW_DO: + case MySqlParser.KW_DUMPFILE: + case MySqlParser.KW_DUPLICATE: + case MySqlParser.KW_DYNAMIC: + case MySqlParser.KW_ENABLE: + case MySqlParser.KW_ENCRYPTION: + case MySqlParser.KW_END: + case MySqlParser.KW_ENDS: + case MySqlParser.KW_ENGINE: + case MySqlParser.KW_ENGINES: + case MySqlParser.KW_ERROR: + case MySqlParser.KW_ERRORS: + case MySqlParser.KW_ESCAPE: + case MySqlParser.KW_EVENT: + case MySqlParser.KW_EVENTS: + case MySqlParser.KW_EVERY: + case MySqlParser.KW_EXCHANGE: + case MySqlParser.KW_EXCLUSIVE: + case MySqlParser.KW_EXPIRE: + case MySqlParser.KW_EXPORT: + case MySqlParser.KW_EXTENDED: + case MySqlParser.KW_EXTENT_SIZE: + case MySqlParser.KW_FAILED_LOGIN_ATTEMPTS: + case MySqlParser.KW_FAST: + case MySqlParser.KW_FAULTS: + case MySqlParser.KW_FIELDS: + case MySqlParser.KW_FILE_BLOCK_SIZE: + case MySqlParser.KW_FILTER: + case MySqlParser.KW_FIRST: + case MySqlParser.KW_FIXED: + case MySqlParser.KW_FLUSH: + case MySqlParser.KW_FOLLOWS: + case MySqlParser.KW_FOUND: + case MySqlParser.KW_FULL: + case MySqlParser.KW_FUNCTION: + case MySqlParser.KW_GENERAL: + case MySqlParser.KW_GLOBAL: + case MySqlParser.KW_GRANTS: + case MySqlParser.KW_GROUP_REPLICATION: + case MySqlParser.KW_HANDLER: + case MySqlParser.KW_HASH: + case MySqlParser.KW_HELP: + case MySqlParser.KW_HISTORY: + case MySqlParser.KW_HOST: + case MySqlParser.KW_HOSTS: + case MySqlParser.KW_IDENTIFIED: + case MySqlParser.KW_IGNORE_SERVER_IDS: + case MySqlParser.KW_IMPORT: + case MySqlParser.KW_INDEXES: + case MySqlParser.KW_INITIAL_SIZE: + case MySqlParser.KW_INPLACE: + case MySqlParser.KW_INSERT_METHOD: + case MySqlParser.KW_INSTALL: + case MySqlParser.KW_INSTANCE: + case MySqlParser.KW_INSTANT: + case MySqlParser.KW_INVISIBLE: + case MySqlParser.KW_INVOKER: + case MySqlParser.KW_IO: + case MySqlParser.KW_IO_THREAD: + case MySqlParser.KW_IPC: + case MySqlParser.KW_ISOLATION: + case MySqlParser.KW_ISSUER: + case MySqlParser.KW_JSON: + case MySqlParser.KW_KEY_BLOCK_SIZE: + case MySqlParser.KW_LANGUAGE: + case MySqlParser.KW_LAST: + case MySqlParser.KW_LEAVES: + case MySqlParser.KW_LESS: + case MySqlParser.KW_LEVEL: + case MySqlParser.KW_LIST: + case MySqlParser.KW_LOCAL: + case MySqlParser.KW_LOGFILE: + case MySqlParser.KW_LOGS: + case MySqlParser.KW_MASTER: + case MySqlParser.KW_MASTER_AUTO_POSITION: + case MySqlParser.KW_MASTER_CONNECT_RETRY: + case MySqlParser.KW_MASTER_DELAY: + case MySqlParser.KW_MASTER_HEARTBEAT_PERIOD: + case MySqlParser.KW_MASTER_HOST: + case MySqlParser.KW_MASTER_LOG_FILE: + case MySqlParser.KW_MASTER_LOG_POS: + case MySqlParser.KW_MASTER_PASSWORD: + case MySqlParser.KW_MASTER_PORT: + case MySqlParser.KW_MASTER_RETRY_COUNT: + case MySqlParser.KW_MASTER_SSL: + case MySqlParser.KW_MASTER_SSL_CA: + case MySqlParser.KW_MASTER_SSL_CAPATH: + case MySqlParser.KW_MASTER_SSL_CERT: + case MySqlParser.KW_MASTER_SSL_CIPHER: + case MySqlParser.KW_MASTER_SSL_CRL: + case MySqlParser.KW_MASTER_SSL_CRLPATH: + case MySqlParser.KW_MASTER_SSL_KEY: + case MySqlParser.KW_MASTER_TLS_VERSION: + case MySqlParser.KW_MASTER_USER: + case MySqlParser.KW_MAX_CONNECTIONS_PER_HOUR: + case MySqlParser.KW_MAX_QUERIES_PER_HOUR: + case MySqlParser.KW_MAX_ROWS: + case MySqlParser.KW_MAX_SIZE: + case MySqlParser.KW_MAX_UPDATES_PER_HOUR: + case MySqlParser.KW_MAX_USER_CONNECTIONS: + case MySqlParser.KW_MEDIUM: + case MySqlParser.KW_MEMBER: + case MySqlParser.KW_MERGE: + case MySqlParser.KW_MESSAGE_TEXT: + case MySqlParser.KW_MID: + case MySqlParser.KW_MIGRATE: + case MySqlParser.KW_MIN_ROWS: + case MySqlParser.KW_MODE: + case MySqlParser.KW_MODIFY: + case MySqlParser.KW_MUTEX: + case MySqlParser.KW_MYSQL: + case MySqlParser.KW_MYSQL_ERRNO: + case MySqlParser.KW_NAME: + case MySqlParser.KW_NAMES: + case MySqlParser.KW_NCHAR: + case MySqlParser.KW_NEVER: + case MySqlParser.KW_NEXT: + case MySqlParser.KW_NO: + case MySqlParser.KW_NOWAIT: + case MySqlParser.KW_NODEGROUP: + case MySqlParser.KW_NONE: + case MySqlParser.KW_ODBC: + case MySqlParser.KW_OFFLINE: + case MySqlParser.KW_OFFSET: + case MySqlParser.KW_OF: + case MySqlParser.KW_OLD_PASSWORD: + case MySqlParser.KW_ONE: + case MySqlParser.KW_ONLINE: + case MySqlParser.KW_ONLY: + case MySqlParser.KW_OPEN: + case MySqlParser.KW_OPTIMIZER_COSTS: + case MySqlParser.KW_OPTIONS: + case MySqlParser.KW_OWNER: + case MySqlParser.KW_PACK_KEYS: + case MySqlParser.KW_PAGE: + case MySqlParser.KW_PAGE_CHECKSUM: + case MySqlParser.KW_PARSER: + case MySqlParser.KW_PARTIAL: + case MySqlParser.KW_PARTITIONING: + case MySqlParser.KW_PARTITIONS: + case MySqlParser.KW_PASSWORD: + case MySqlParser.KW_PASSWORD_LOCK_TIME: + case MySqlParser.KW_PHASE: + case MySqlParser.KW_PLUGIN: + case MySqlParser.KW_PLUGIN_DIR: + case MySqlParser.KW_PLUGINS: + case MySqlParser.KW_PORT: + case MySqlParser.KW_PRECEDES: + case MySqlParser.KW_PREPARE: + case MySqlParser.KW_PRESERVE: + case MySqlParser.KW_PREV: + case MySqlParser.KW_PROCESSLIST: + case MySqlParser.KW_PROFILE: + case MySqlParser.KW_PROFILES: + case MySqlParser.KW_PROXY: + case MySqlParser.KW_QUERY: + case MySqlParser.KW_QUICK: + case MySqlParser.KW_REBUILD: + case MySqlParser.KW_RECOVER: + case MySqlParser.KW_RECURSIVE: + case MySqlParser.KW_REDO_BUFFER_SIZE: + case MySqlParser.KW_REDUNDANT: + case MySqlParser.KW_RELAY: + case MySqlParser.KW_RELAY_LOG_FILE: + case MySqlParser.KW_RELAY_LOG_POS: + case MySqlParser.KW_RELAYLOG: + case MySqlParser.KW_REMOVE: + case MySqlParser.KW_REORGANIZE: + case MySqlParser.KW_REPAIR: + case MySqlParser.KW_REPLICATE_DO_DB: + case MySqlParser.KW_REPLICATE_DO_TABLE: + case MySqlParser.KW_REPLICATE_IGNORE_DB: + case MySqlParser.KW_REPLICATE_IGNORE_TABLE: + case MySqlParser.KW_REPLICATE_REWRITE_DB: + case MySqlParser.KW_REPLICATE_WILD_DO_TABLE: + case MySqlParser.KW_REPLICATE_WILD_IGNORE_TABLE: + case MySqlParser.KW_REPLICATION: + case MySqlParser.KW_RESET: + case MySqlParser.KW_RESUME: + case MySqlParser.KW_RETURNED_SQLSTATE: + case MySqlParser.KW_RETURNS: + case MySqlParser.KW_REUSE: + case MySqlParser.KW_ROLE: + case MySqlParser.KW_ROLLBACK: + case MySqlParser.KW_ROLLUP: + case MySqlParser.KW_ROTATE: + case MySqlParser.KW_ROW: + case MySqlParser.KW_ROWS: + case MySqlParser.KW_ROW_FORMAT: + case MySqlParser.KW_SAVEPOINT: + case MySqlParser.KW_SCHEDULE: + case MySqlParser.KW_SECURITY: + case MySqlParser.KW_SERVER: + case MySqlParser.KW_SESSION: + case MySqlParser.KW_SHARE: + case MySqlParser.KW_SHARED: + case MySqlParser.KW_SIGNED: + case MySqlParser.KW_SIMPLE: + case MySqlParser.KW_SLAVE: + case MySqlParser.KW_SLOW: + case MySqlParser.KW_SNAPSHOT: + case MySqlParser.KW_SOCKET: + case MySqlParser.KW_SOME: + case MySqlParser.KW_SONAME: + case MySqlParser.KW_SOUNDS: + case MySqlParser.KW_SOURCE: + case MySqlParser.KW_SQL_AFTER_GTIDS: + case MySqlParser.KW_SQL_AFTER_MTS_GAPS: + case MySqlParser.KW_SQL_BEFORE_GTIDS: + case MySqlParser.KW_SQL_BUFFER_RESULT: + case MySqlParser.KW_SQL_CACHE: + case MySqlParser.KW_SQL_NO_CACHE: + case MySqlParser.KW_SQL_THREAD: + case MySqlParser.KW_START: + case MySqlParser.KW_STARTS: + case MySqlParser.KW_STATS_AUTO_RECALC: + case MySqlParser.KW_STATS_PERSISTENT: + case MySqlParser.KW_STATS_SAMPLE_PAGES: + case MySqlParser.KW_STATUS: + case MySqlParser.KW_STOP: + case MySqlParser.KW_STORAGE: + case MySqlParser.KW_STRING: + case MySqlParser.KW_SUBCLASS_ORIGIN: + case MySqlParser.KW_SUBJECT: + case MySqlParser.KW_SUBPARTITION: + case MySqlParser.KW_SUBPARTITIONS: + case MySqlParser.KW_SUSPEND: + case MySqlParser.KW_SWAPS: + case MySqlParser.KW_SWITCHES: + case MySqlParser.KW_TABLE_NAME: + case MySqlParser.KW_TABLESPACE: + case MySqlParser.KW_TABLE_TYPE: + case MySqlParser.KW_TEMPORARY: + case MySqlParser.KW_TEMPTABLE: + case MySqlParser.KW_THAN: + case MySqlParser.KW_TRADITIONAL: + case MySqlParser.KW_TRANSACTION: + case MySqlParser.KW_TRANSACTIONAL: + case MySqlParser.KW_TRIGGERS: + case MySqlParser.KW_TRUNCATE: + case MySqlParser.KW_UNBOUNDED: + case MySqlParser.KW_UNDEFINED: + case MySqlParser.KW_UNDOFILE: + case MySqlParser.KW_UNDO_BUFFER_SIZE: + case MySqlParser.KW_UNINSTALL: + case MySqlParser.KW_UNKNOWN: + case MySqlParser.KW_UNTIL: + case MySqlParser.KW_UPGRADE: + case MySqlParser.KW_USER: + case MySqlParser.KW_USE_FRM: + case MySqlParser.KW_USER_RESOURCES: + case MySqlParser.KW_VALIDATION: + case MySqlParser.KW_VALUE: + case MySqlParser.KW_VARIABLES: + case MySqlParser.KW_VIEW: + case MySqlParser.KW_VIRTUAL: + case MySqlParser.KW_VISIBLE: + case MySqlParser.KW_WAIT: + case MySqlParser.KW_WARNINGS: + case MySqlParser.KW_WITHOUT: + case MySqlParser.KW_WORK: + case MySqlParser.KW_WRAPPER: + case MySqlParser.KW_X509: + case MySqlParser.KW_XA: + case MySqlParser.KW_XML: + case MySqlParser.KW_QUARTER: + case MySqlParser.KW_MONTH: + case MySqlParser.KW_DAY: + case MySqlParser.KW_HOUR: + case MySqlParser.KW_MINUTE: + case MySqlParser.KW_WEEK: + case MySqlParser.KW_SECOND: + case MySqlParser.KW_MICROSECOND: + case MySqlParser.KW_ADMIN: + case MySqlParser.KW_AUDIT_ABORT_EXEMPT: + case MySqlParser.KW_AUDIT_ADMIN: + case MySqlParser.KW_AUTHENTICATION_POLICY_ADMIN: + case MySqlParser.KW_BACKUP_ADMIN: + case MySqlParser.KW_BINLOG_ADMIN: + case MySqlParser.KW_BINLOG_ENCRYPTION_ADMIN: + case MySqlParser.KW_CLONE_ADMIN: + case MySqlParser.KW_CONNECTION_ADMIN: + case MySqlParser.KW_ENCRYPTION_KEY_ADMIN: + case MySqlParser.KW_EXECUTE: + case MySqlParser.KW_FILE: + case MySqlParser.KW_FIREWALL_ADMIN: + case MySqlParser.KW_FIREWALL_EXEMPT: + case MySqlParser.KW_FIREWALL_USER: + case MySqlParser.KW_GROUP_REPLICATION_ADMIN: + case MySqlParser.KW_INNODB_REDO_LOG_ARCHIVE: + case MySqlParser.KW_INVOKE: + case MySqlParser.KW_LAMBDA: + case MySqlParser.KW_NDB_STORED_USER: + case MySqlParser.KW_PASSWORDLESS_USER_ADMIN: + case MySqlParser.KW_PERSIST_RO_VARIABLES_ADMIN: + case MySqlParser.KW_PRIVILEGES: + case MySqlParser.KW_PROCESS: + case MySqlParser.KW_RELOAD: + case MySqlParser.KW_REPLICATION_APPLIER: + case MySqlParser.KW_REPLICATION_SLAVE_ADMIN: + case MySqlParser.KW_RESOURCE_GROUP_ADMIN: + case MySqlParser.KW_RESOURCE_GROUP_USER: + case MySqlParser.KW_ROLE_ADMIN: + case MySqlParser.KW_ROUTINE: + case MySqlParser.KW_S3: + case MySqlParser.KW_SESSION_VARIABLES_ADMIN: + case MySqlParser.KW_SET_USER_ID: + case MySqlParser.KW_SHOW_ROUTINE: + case MySqlParser.KW_SHUTDOWN: + case MySqlParser.KW_SUPER: + case MySqlParser.KW_SYSTEM_VARIABLES_ADMIN: + case MySqlParser.KW_TABLES: + case MySqlParser.KW_TABLE_ENCRYPTION_ADMIN: + case MySqlParser.KW_VERSION_TOKEN_ADMIN: + case MySqlParser.KW_XA_RECOVER_ADMIN: + case MySqlParser.KW_ARMSCII8: + case MySqlParser.KW_ASCII: + case MySqlParser.KW_BIG5: + case MySqlParser.KW_CP1250: + case MySqlParser.KW_CP1251: + case MySqlParser.KW_CP1256: + case MySqlParser.KW_CP1257: + case MySqlParser.KW_CP850: + case MySqlParser.KW_CP852: + case MySqlParser.KW_CP866: + case MySqlParser.KW_CP932: + case MySqlParser.KW_DEC8: + case MySqlParser.KW_EUCJPMS: + case MySqlParser.KW_EUCKR: + case MySqlParser.KW_GB18030: + case MySqlParser.KW_GB2312: + case MySqlParser.KW_GBK: + case MySqlParser.KW_GEOSTD8: + case MySqlParser.KW_GREEK: + case MySqlParser.KW_HEBREW: + case MySqlParser.KW_HP8: + case MySqlParser.KW_KEYBCS2: + case MySqlParser.KW_KOI8R: + case MySqlParser.KW_KOI8U: + case MySqlParser.KW_LATIN1: + case MySqlParser.KW_LATIN2: + case MySqlParser.KW_LATIN5: + case MySqlParser.KW_LATIN7: + case MySqlParser.KW_MACCE: + case MySqlParser.KW_MACROMAN: + case MySqlParser.KW_SJIS: + case MySqlParser.KW_SWE7: + case MySqlParser.KW_TIS620: + case MySqlParser.KW_UCS2: + case MySqlParser.KW_UJIS: + case MySqlParser.KW_UTF16: + case MySqlParser.KW_UTF16LE: + case MySqlParser.KW_UTF32: + case MySqlParser.KW_UTF8: + case MySqlParser.KW_UTF8MB3: + case MySqlParser.KW_UTF8MB4: + case MySqlParser.KW_ARCHIVE: + case MySqlParser.KW_BLACKHOLE: + case MySqlParser.KW_CSV: + case MySqlParser.KW_FEDERATED: + case MySqlParser.KW_INNODB: + case MySqlParser.KW_MEMORY: + case MySqlParser.KW_MRG_MYISAM: + case MySqlParser.KW_MYISAM: + case MySqlParser.KW_NDB: + case MySqlParser.KW_NDBCLUSTER: + case MySqlParser.KW_PERFORMANCE_SCHEMA: + case MySqlParser.KW_TOKUDB: + case MySqlParser.KW_REPEATABLE: + case MySqlParser.KW_COMMITTED: + case MySqlParser.KW_UNCOMMITTED: + case MySqlParser.KW_SERIALIZABLE: + case MySqlParser.KW_GEOMETRYCOLLECTION: + case MySqlParser.KW_LINESTRING: + case MySqlParser.KW_MULTILINESTRING: + case MySqlParser.KW_MULTIPOINT: + case MySqlParser.KW_MULTIPOLYGON: + case MySqlParser.KW_POINT: + case MySqlParser.KW_POLYGON: + case MySqlParser.KW_CATALOG_NAME: + case MySqlParser.KW_CHARSET: + case MySqlParser.KW_COLLATION: + case MySqlParser.KW_ENGINE_ATTRIBUTE: + case MySqlParser.KW_FORMAT: + case MySqlParser.KW_GET_FORMAT: + case MySqlParser.KW_RANDOM: + case MySqlParser.KW_REVERSE: + case MySqlParser.KW_ROW_COUNT: + case MySqlParser.KW_SCHEMA_NAME: + case MySqlParser.KW_SECONDARY_ENGINE_ATTRIBUTE: + case MySqlParser.KW_SRID: + case MySqlParser.KW_SYSTEM_USER: + case MySqlParser.KW_TP_CONNECTION_ADMIN: + case MySqlParser.KW_WEIGHT_STRING: + case MySqlParser.MOD: + case MySqlParser.CHARSET_REVERSE_QOUTE_STRING: + case MySqlParser.STRING_LITERAL: + case MySqlParser.ID: + { + this.state = 6602; + this.partitionNames(); + } + break; + case MySqlParser.KW_ALL: + { + this.state = 6603; + this.match(MySqlParser.KW_ALL); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + this.state = 6606; + this.match(MySqlParser.RR_BRACKET); + } + } + this.state = 6616; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 952, this.context)) { + case 1: + { + this.state = 6610; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 82 || _la === 92) { + { + this.state = 6609; + localContext._indexFormat = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 82 || _la === 92)) { + localContext._indexFormat = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + this.state = 6612; + this.match(MySqlParser.LR_BRACKET); + this.state = 6613; + this.indexNames(); + this.state = 6614; + this.match(MySqlParser.RR_BRACKET); + } + break; + } + this.state = 6620; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 79) { + { + this.state = 6618; + this.match(MySqlParser.KW_IGNORE); + this.state = 6619; + this.match(MySqlParser.KW_LEAVES); + } + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + simpleDescribeStatement() { + let localContext = new SimpleDescribeStatementContext(this.context, this.state); + this.enterRule(localContext, 596, MySqlParser.RULE_simpleDescribeStatement); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6622; + localContext._command = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(((((_la - 45)) & ~0x1F) === 0 && ((1 << (_la - 45)) & 131075) !== 0))) { + localContext._command = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 6623; + this.tableName(); + this.state = 6626; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 954, this.context)) { + case 1: + { + this.state = 6624; + localContext._column = this.columnName(); + } + break; + case 2: + { + this.state = 6625; + localContext._pattern = this.match(MySqlParser.STRING_LITERAL); + } + break; + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + fullDescribeStatement() { + let localContext = new FullDescribeStatementContext(this.context, this.state); + this.enterRule(localContext, 598, MySqlParser.RULE_fullDescribeStatement); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6628; + localContext._command = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(((((_la - 45)) & ~0x1F) === 0 && ((1 << (_la - 45)) & 131075) !== 0))) { + localContext._command = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 6634; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_EXTENDED: + { + this.state = 6629; + this.match(MySqlParser.KW_EXTENDED); + } + break; + case MySqlParser.KW_PARTITIONS: + { + this.state = 6630; + this.match(MySqlParser.KW_PARTITIONS); + } + break; + case MySqlParser.KW_FORMAT: + { + this.state = 6631; + this.match(MySqlParser.KW_FORMAT); + this.state = 6632; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 6633; + _la = this.tokenStream.LA(1); + if (!(_la === 442 || _la === 663 || _la === 666)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + break; + case MySqlParser.KW_DELETE: + case MySqlParser.KW_FOR: + case MySqlParser.KW_INSERT: + case MySqlParser.KW_REPLACE: + case MySqlParser.KW_SELECT: + case MySqlParser.KW_UPDATE: + case MySqlParser.LR_BRACKET: + break; + default: + break; + } + this.state = 6636; + this.describeObjectClause(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + analyzeDescribeStatement() { + let localContext = new AnalyzeDescribeStatementContext(this.context, this.state); + this.enterRule(localContext, 600, MySqlParser.RULE_analyzeDescribeStatement); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6638; + localContext._command = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(((((_la - 45)) & ~0x1F) === 0 && ((1 << (_la - 45)) & 131075) !== 0))) { + localContext._command = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 6639; + this.match(MySqlParser.KW_ANALYZE); + this.state = 6643; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 826) { + { + this.state = 6640; + this.match(MySqlParser.KW_FORMAT); + this.state = 6641; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 6642; + this.match(MySqlParser.KW_TREE); + } + } + this.state = 6645; + this.selectStatement(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + helpStatement() { + let localContext = new HelpStatementContext(this.context, this.state); + this.enterRule(localContext, 602, MySqlParser.RULE_helpStatement); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6647; + this.match(MySqlParser.KW_HELP); + this.state = 6648; + this.match(MySqlParser.STRING_LITERAL); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + useStatement() { + let localContext = new UseStatementContext(this.context, this.state); + this.enterRule(localContext, 604, MySqlParser.RULE_useStatement); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6650; + this.match(MySqlParser.KW_USE); + this.state = 6651; + this.databaseName(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + signalStatement() { + let localContext = new SignalStatementContext(this.context, this.state); + this.enterRule(localContext, 606, MySqlParser.RULE_signalStatement); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6653; + this.match(MySqlParser.KW_SIGNAL); + this.state = 6661; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_SQLSTATE: + { + { + this.state = 6654; + this.match(MySqlParser.KW_SQLSTATE); + this.state = 6656; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 682) { + { + this.state = 6655; + this.match(MySqlParser.KW_VALUE); + } + } + this.state = 6658; + this.stringLiteral(); + } + } + break; + case MySqlParser.ID: + { + this.state = 6659; + this.match(MySqlParser.ID); + } + break; + case MySqlParser.REVERSE_QUOTE_ID: + { + this.state = 6660; + this.match(MySqlParser.REVERSE_QUOTE_ID); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + this.state = 6672; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 960, this.context)) { + case 1: + { + this.state = 6663; + this.match(MySqlParser.KW_SET); + this.state = 6664; + this.signalConditionInformation(); + this.state = 6669; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 6665; + this.match(MySqlParser.COMMA); + this.state = 6666; + this.signalConditionInformation(); + } + } + this.state = 6671; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + break; + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + resignalStatement() { + let localContext = new ResignalStatementContext(this.context, this.state); + this.enterRule(localContext, 608, MySqlParser.RULE_resignalStatement); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6674; + this.match(MySqlParser.KW_RESIGNAL); + this.state = 6682; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_SQLSTATE: + { + { + this.state = 6675; + this.match(MySqlParser.KW_SQLSTATE); + this.state = 6677; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 682) { + { + this.state = 6676; + this.match(MySqlParser.KW_VALUE); + } + } + this.state = 6679; + this.stringLiteral(); + } + } + break; + case MySqlParser.ID: + { + this.state = 6680; + this.match(MySqlParser.ID); + } + break; + case MySqlParser.REVERSE_QUOTE_ID: + { + this.state = 6681; + this.match(MySqlParser.REVERSE_QUOTE_ID); + } + break; + case MySqlParser.EOF: + case MySqlParser.KW_ALTER: + case MySqlParser.KW_ANALYZE: + case MySqlParser.KW_CALL: + case MySqlParser.KW_CHANGE: + case MySqlParser.KW_CHECK: + case MySqlParser.KW_CREATE: + case MySqlParser.KW_DELETE: + case MySqlParser.KW_DESC: + case MySqlParser.KW_DESCRIBE: + case MySqlParser.KW_DROP: + case MySqlParser.KW_EXPLAIN: + case MySqlParser.KW_GET: + case MySqlParser.KW_GRANT: + case MySqlParser.KW_INSERT: + case MySqlParser.KW_KILL: + case MySqlParser.KW_LOAD: + case MySqlParser.KW_LOCK: + case MySqlParser.KW_OPTIMIZE: + case MySqlParser.KW_PURGE: + case MySqlParser.KW_RELEASE: + case MySqlParser.KW_RENAME: + case MySqlParser.KW_REPLACE: + case MySqlParser.KW_RESIGNAL: + case MySqlParser.KW_REVOKE: + case MySqlParser.KW_SELECT: + case MySqlParser.KW_SET: + case MySqlParser.KW_SHOW: + case MySqlParser.KW_SIGNAL: + case MySqlParser.KW_TABLE: + case MySqlParser.KW_UNLOCK: + case MySqlParser.KW_UPDATE: + case MySqlParser.KW_USE: + case MySqlParser.KW_VALUES: + case MySqlParser.KW_WITH: + case MySqlParser.KW_BEGIN: + case MySqlParser.KW_BINLOG: + case MySqlParser.KW_CACHE: + case MySqlParser.KW_CHECKSUM: + case MySqlParser.KW_COMMIT: + case MySqlParser.KW_DEALLOCATE: + case MySqlParser.KW_DO: + case MySqlParser.KW_FLUSH: + case MySqlParser.KW_HANDLER: + case MySqlParser.KW_HELP: + case MySqlParser.KW_IMPORT: + case MySqlParser.KW_INSTALL: + case MySqlParser.KW_PREPARE: + case MySqlParser.KW_REPAIR: + case MySqlParser.KW_RESET: + case MySqlParser.KW_RESTART: + case MySqlParser.KW_ROLLBACK: + case MySqlParser.KW_SAVEPOINT: + case MySqlParser.KW_START: + case MySqlParser.KW_STOP: + case MySqlParser.KW_TRUNCATE: + case MySqlParser.KW_UNINSTALL: + case MySqlParser.KW_XA: + case MySqlParser.KW_CLONE: + case MySqlParser.KW_EXECUTE: + case MySqlParser.KW_SHUTDOWN: + case MySqlParser.LR_BRACKET: + case MySqlParser.SEMI: + break; + default: + break; + } + this.state = 6693; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 964, this.context)) { + case 1: + { + this.state = 6684; + this.match(MySqlParser.KW_SET); + this.state = 6685; + this.signalConditionInformation(); + this.state = 6690; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 6686; + this.match(MySqlParser.COMMA); + this.state = 6687; + this.signalConditionInformation(); + } + } + this.state = 6692; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + break; + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + signalConditionInformation() { + let localContext = new SignalConditionInformationContext(this.context, this.state); + this.enterRule(localContext, 610, MySqlParser.RULE_signalConditionInformation); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6695; + _la = this.tokenStream.LA(1); + if (!(((((_la - 332)) & ~0x1F) === 0 && ((1 << (_la - 332)) & 137887873) !== 0) || _la === 487 || _la === 495 || _la === 650 || _la === 657 || _la === 822 || _la === 832)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 6696; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 6701; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.START_NATIONAL_STRING_LITERAL: + case MySqlParser.STRING_LITERAL: + case MySqlParser.STRING_CHARSET_NAME: + { + this.state = 6697; + this.stringLiteral(); + } + break; + case MySqlParser.DECIMAL_LITERAL: + { + this.state = 6698; + this.match(MySqlParser.DECIMAL_LITERAL); + } + break; + case MySqlParser.LOCAL_ID: + case MySqlParser.GLOBAL_ID: + { + this.state = 6699; + this.mysqlVariable(); + } + break; + case MySqlParser.KW_ARRAY: + case MySqlParser.KW_ATTRIBUTE: + case MySqlParser.KW_BUCKETS: + case MySqlParser.KW_CONDITION: + case MySqlParser.KW_CURRENT: + case MySqlParser.KW_CURRENT_USER: + case MySqlParser.KW_DATABASE: + case MySqlParser.KW_DEFAULT: + case MySqlParser.KW_DIAGNOSTICS: + case MySqlParser.KW_EMPTY: + case MySqlParser.KW_ENFORCED: + case MySqlParser.KW_EXCEPT: + case MySqlParser.KW_GROUP: + case MySqlParser.KW_IF: + case MySqlParser.KW_INSERT: + case MySqlParser.KW_LATERAL: + case MySqlParser.KW_LEFT: + case MySqlParser.KW_NUMBER: + case MySqlParser.KW_OPTIONAL: + case MySqlParser.KW_ORDER: + case MySqlParser.KW_PRIMARY: + case MySqlParser.KW_REPEAT: + case MySqlParser.KW_REPLACE: + case MySqlParser.KW_RIGHT: + case MySqlParser.KW_SCHEMA: + case MySqlParser.KW_SKIP_QUERY_REWRITE: + case MySqlParser.KW_STACKED: + case MySqlParser.KW_DATE: + case MySqlParser.KW_TIME: + case MySqlParser.KW_TIMESTAMP: + case MySqlParser.KW_DATETIME: + case MySqlParser.KW_YEAR: + case MySqlParser.KW_BINARY: + case MySqlParser.KW_TEXT: + case MySqlParser.KW_ENUM: + case MySqlParser.KW_SERIAL: + case MySqlParser.KW_JSON_TABLE: + case MySqlParser.KW_JSON_VALUE: + case MySqlParser.KW_NESTED: + case MySqlParser.KW_ORDINALITY: + case MySqlParser.KW_PATH: + case MySqlParser.KW_AVG: + case MySqlParser.KW_BIT_AND: + case MySqlParser.KW_BIT_OR: + case MySqlParser.KW_BIT_XOR: + case MySqlParser.KW_COUNT: + case MySqlParser.KW_CUME_DIST: + case MySqlParser.KW_DENSE_RANK: + case MySqlParser.KW_FIRST_VALUE: + case MySqlParser.KW_GROUP_CONCAT: + case MySqlParser.KW_LAG: + case MySqlParser.KW_LAST_VALUE: + case MySqlParser.KW_LEAD: + case MySqlParser.KW_MAX: + case MySqlParser.KW_MIN: + case MySqlParser.KW_NTILE: + case MySqlParser.KW_NTH_VALUE: + case MySqlParser.KW_PERCENT_RANK: + case MySqlParser.KW_RANK: + case MySqlParser.KW_ROW_NUMBER: + case MySqlParser.KW_STD: + case MySqlParser.KW_STDDEV: + case MySqlParser.KW_STDDEV_POP: + case MySqlParser.KW_STDDEV_SAMP: + case MySqlParser.KW_SUM: + case MySqlParser.KW_VAR_POP: + case MySqlParser.KW_VAR_SAMP: + case MySqlParser.KW_VARIANCE: + case MySqlParser.KW_CURRENT_DATE: + case MySqlParser.KW_CURRENT_TIME: + case MySqlParser.KW_CURRENT_TIMESTAMP: + case MySqlParser.KW_LOCALTIME: + case MySqlParser.KW_CURDATE: + case MySqlParser.KW_CURTIME: + case MySqlParser.KW_DATE_ADD: + case MySqlParser.KW_DATE_SUB: + case MySqlParser.KW_LOCALTIMESTAMP: + case MySqlParser.KW_NOW: + case MySqlParser.KW_POSITION: + case MySqlParser.KW_SUBSTR: + case MySqlParser.KW_SUBSTRING: + case MySqlParser.KW_SYSDATE: + case MySqlParser.KW_TRIM: + case MySqlParser.KW_UTC_DATE: + case MySqlParser.KW_UTC_TIME: + case MySqlParser.KW_UTC_TIMESTAMP: + case MySqlParser.KW_ACCOUNT: + case MySqlParser.KW_ACTION: + case MySqlParser.KW_AFTER: + case MySqlParser.KW_AGGREGATE: + case MySqlParser.KW_ALGORITHM: + case MySqlParser.KW_ANY: + case MySqlParser.KW_AT: + case MySqlParser.KW_AUTHORS: + case MySqlParser.KW_AUTOCOMMIT: + case MySqlParser.KW_AUTOEXTEND_SIZE: + case MySqlParser.KW_AUTO_INCREMENT: + case MySqlParser.KW_AVG_ROW_LENGTH: + case MySqlParser.KW_BEGIN: + case MySqlParser.KW_BINLOG: + case MySqlParser.KW_BIT: + case MySqlParser.KW_BLOCK: + case MySqlParser.KW_BOOL: + case MySqlParser.KW_BOOLEAN: + case MySqlParser.KW_BTREE: + case MySqlParser.KW_CACHE: + case MySqlParser.KW_CASCADED: + case MySqlParser.KW_CHAIN: + case MySqlParser.KW_CHANGED: + case MySqlParser.KW_CHANNEL: + case MySqlParser.KW_CHECKSUM: + case MySqlParser.KW_CIPHER: + case MySqlParser.KW_CLASS_ORIGIN: + case MySqlParser.KW_CLIENT: + case MySqlParser.KW_CLOSE: + case MySqlParser.KW_COALESCE: + case MySqlParser.KW_CODE: + case MySqlParser.KW_COLUMNS: + case MySqlParser.KW_COLUMN_FORMAT: + case MySqlParser.KW_COLUMN_NAME: + case MySqlParser.KW_COMMENT: + case MySqlParser.KW_COMMIT: + case MySqlParser.KW_COMPACT: + case MySqlParser.KW_COMPLETION: + case MySqlParser.KW_COMPRESSED: + case MySqlParser.KW_COMPRESSION: + case MySqlParser.KW_CONCURRENT: + case MySqlParser.KW_CONNECT: + case MySqlParser.KW_CONNECTION: + case MySqlParser.KW_CONSISTENT: + case MySqlParser.KW_CONSTRAINT_CATALOG: + case MySqlParser.KW_CONSTRAINT_SCHEMA: + case MySqlParser.KW_CONSTRAINT_NAME: + case MySqlParser.KW_CONTAINS: + case MySqlParser.KW_CONTEXT: + case MySqlParser.KW_CONTRIBUTORS: + case MySqlParser.KW_COPY: + case MySqlParser.KW_CPU: + case MySqlParser.KW_CURSOR_NAME: + case MySqlParser.KW_DATA: + case MySqlParser.KW_DATAFILE: + case MySqlParser.KW_DEALLOCATE: + case MySqlParser.KW_DEFAULT_AUTH: + case MySqlParser.KW_DEFINER: + case MySqlParser.KW_DELAY_KEY_WRITE: + case MySqlParser.KW_DES_KEY_FILE: + case MySqlParser.KW_DIRECTORY: + case MySqlParser.KW_DISABLE: + case MySqlParser.KW_DISCARD: + case MySqlParser.KW_DISK: + case MySqlParser.KW_DO: + case MySqlParser.KW_DUMPFILE: + case MySqlParser.KW_DUPLICATE: + case MySqlParser.KW_DYNAMIC: + case MySqlParser.KW_ENABLE: + case MySqlParser.KW_ENCRYPTION: + case MySqlParser.KW_END: + case MySqlParser.KW_ENDS: + case MySqlParser.KW_ENGINE: + case MySqlParser.KW_ENGINES: + case MySqlParser.KW_ERROR: + case MySqlParser.KW_ERRORS: + case MySqlParser.KW_ESCAPE: + case MySqlParser.KW_EVENT: + case MySqlParser.KW_EVENTS: + case MySqlParser.KW_EVERY: + case MySqlParser.KW_EXCHANGE: + case MySqlParser.KW_EXCLUSIVE: + case MySqlParser.KW_EXPIRE: + case MySqlParser.KW_EXPORT: + case MySqlParser.KW_EXTENDED: + case MySqlParser.KW_EXTENT_SIZE: + case MySqlParser.KW_FAILED_LOGIN_ATTEMPTS: + case MySqlParser.KW_FAST: + case MySqlParser.KW_FAULTS: + case MySqlParser.KW_FIELDS: + case MySqlParser.KW_FILE_BLOCK_SIZE: + case MySqlParser.KW_FILTER: + case MySqlParser.KW_FIRST: + case MySqlParser.KW_FIXED: + case MySqlParser.KW_FLUSH: + case MySqlParser.KW_FOLLOWS: + case MySqlParser.KW_FOUND: + case MySqlParser.KW_FULL: + case MySqlParser.KW_FUNCTION: + case MySqlParser.KW_GENERAL: + case MySqlParser.KW_GLOBAL: + case MySqlParser.KW_GRANTS: + case MySqlParser.KW_GROUP_REPLICATION: + case MySqlParser.KW_HANDLER: + case MySqlParser.KW_HASH: + case MySqlParser.KW_HELP: + case MySqlParser.KW_HISTORY: + case MySqlParser.KW_HOST: + case MySqlParser.KW_HOSTS: + case MySqlParser.KW_IDENTIFIED: + case MySqlParser.KW_IGNORE_SERVER_IDS: + case MySqlParser.KW_IMPORT: + case MySqlParser.KW_INDEXES: + case MySqlParser.KW_INITIAL_SIZE: + case MySqlParser.KW_INPLACE: + case MySqlParser.KW_INSERT_METHOD: + case MySqlParser.KW_INSTALL: + case MySqlParser.KW_INSTANCE: + case MySqlParser.KW_INSTANT: + case MySqlParser.KW_INVISIBLE: + case MySqlParser.KW_INVOKER: + case MySqlParser.KW_IO: + case MySqlParser.KW_IO_THREAD: + case MySqlParser.KW_IPC: + case MySqlParser.KW_ISOLATION: + case MySqlParser.KW_ISSUER: + case MySqlParser.KW_JSON: + case MySqlParser.KW_KEY_BLOCK_SIZE: + case MySqlParser.KW_LANGUAGE: + case MySqlParser.KW_LAST: + case MySqlParser.KW_LEAVES: + case MySqlParser.KW_LESS: + case MySqlParser.KW_LEVEL: + case MySqlParser.KW_LIST: + case MySqlParser.KW_LOCAL: + case MySqlParser.KW_LOGFILE: + case MySqlParser.KW_LOGS: + case MySqlParser.KW_MASTER: + case MySqlParser.KW_MASTER_AUTO_POSITION: + case MySqlParser.KW_MASTER_CONNECT_RETRY: + case MySqlParser.KW_MASTER_DELAY: + case MySqlParser.KW_MASTER_HEARTBEAT_PERIOD: + case MySqlParser.KW_MASTER_HOST: + case MySqlParser.KW_MASTER_LOG_FILE: + case MySqlParser.KW_MASTER_LOG_POS: + case MySqlParser.KW_MASTER_PASSWORD: + case MySqlParser.KW_MASTER_PORT: + case MySqlParser.KW_MASTER_RETRY_COUNT: + case MySqlParser.KW_MASTER_SSL: + case MySqlParser.KW_MASTER_SSL_CA: + case MySqlParser.KW_MASTER_SSL_CAPATH: + case MySqlParser.KW_MASTER_SSL_CERT: + case MySqlParser.KW_MASTER_SSL_CIPHER: + case MySqlParser.KW_MASTER_SSL_CRL: + case MySqlParser.KW_MASTER_SSL_CRLPATH: + case MySqlParser.KW_MASTER_SSL_KEY: + case MySqlParser.KW_MASTER_TLS_VERSION: + case MySqlParser.KW_MASTER_USER: + case MySqlParser.KW_MAX_CONNECTIONS_PER_HOUR: + case MySqlParser.KW_MAX_QUERIES_PER_HOUR: + case MySqlParser.KW_MAX_ROWS: + case MySqlParser.KW_MAX_SIZE: + case MySqlParser.KW_MAX_UPDATES_PER_HOUR: + case MySqlParser.KW_MAX_USER_CONNECTIONS: + case MySqlParser.KW_MEDIUM: + case MySqlParser.KW_MEMBER: + case MySqlParser.KW_MERGE: + case MySqlParser.KW_MESSAGE_TEXT: + case MySqlParser.KW_MID: + case MySqlParser.KW_MIGRATE: + case MySqlParser.KW_MIN_ROWS: + case MySqlParser.KW_MODE: + case MySqlParser.KW_MODIFY: + case MySqlParser.KW_MUTEX: + case MySqlParser.KW_MYSQL: + case MySqlParser.KW_MYSQL_ERRNO: + case MySqlParser.KW_NAME: + case MySqlParser.KW_NAMES: + case MySqlParser.KW_NCHAR: + case MySqlParser.KW_NEVER: + case MySqlParser.KW_NEXT: + case MySqlParser.KW_NO: + case MySqlParser.KW_NOWAIT: + case MySqlParser.KW_NODEGROUP: + case MySqlParser.KW_NONE: + case MySqlParser.KW_ODBC: + case MySqlParser.KW_OFFLINE: + case MySqlParser.KW_OFFSET: + case MySqlParser.KW_OF: + case MySqlParser.KW_OLD_PASSWORD: + case MySqlParser.KW_ONE: + case MySqlParser.KW_ONLINE: + case MySqlParser.KW_ONLY: + case MySqlParser.KW_OPEN: + case MySqlParser.KW_OPTIMIZER_COSTS: + case MySqlParser.KW_OPTIONS: + case MySqlParser.KW_OWNER: + case MySqlParser.KW_PACK_KEYS: + case MySqlParser.KW_PAGE: + case MySqlParser.KW_PAGE_CHECKSUM: + case MySqlParser.KW_PARSER: + case MySqlParser.KW_PARTIAL: + case MySqlParser.KW_PARTITIONING: + case MySqlParser.KW_PARTITIONS: + case MySqlParser.KW_PASSWORD: + case MySqlParser.KW_PASSWORD_LOCK_TIME: + case MySqlParser.KW_PHASE: + case MySqlParser.KW_PLUGIN: + case MySqlParser.KW_PLUGIN_DIR: + case MySqlParser.KW_PLUGINS: + case MySqlParser.KW_PORT: + case MySqlParser.KW_PRECEDES: + case MySqlParser.KW_PREPARE: + case MySqlParser.KW_PRESERVE: + case MySqlParser.KW_PREV: + case MySqlParser.KW_PROCESSLIST: + case MySqlParser.KW_PROFILE: + case MySqlParser.KW_PROFILES: + case MySqlParser.KW_PROXY: + case MySqlParser.KW_QUERY: + case MySqlParser.KW_QUICK: + case MySqlParser.KW_REBUILD: + case MySqlParser.KW_RECOVER: + case MySqlParser.KW_RECURSIVE: + case MySqlParser.KW_REDO_BUFFER_SIZE: + case MySqlParser.KW_REDUNDANT: + case MySqlParser.KW_RELAY: + case MySqlParser.KW_RELAY_LOG_FILE: + case MySqlParser.KW_RELAY_LOG_POS: + case MySqlParser.KW_RELAYLOG: + case MySqlParser.KW_REMOVE: + case MySqlParser.KW_REORGANIZE: + case MySqlParser.KW_REPAIR: + case MySqlParser.KW_REPLICATE_DO_DB: + case MySqlParser.KW_REPLICATE_DO_TABLE: + case MySqlParser.KW_REPLICATE_IGNORE_DB: + case MySqlParser.KW_REPLICATE_IGNORE_TABLE: + case MySqlParser.KW_REPLICATE_REWRITE_DB: + case MySqlParser.KW_REPLICATE_WILD_DO_TABLE: + case MySqlParser.KW_REPLICATE_WILD_IGNORE_TABLE: + case MySqlParser.KW_REPLICATION: + case MySqlParser.KW_RESET: + case MySqlParser.KW_RESUME: + case MySqlParser.KW_RETURNED_SQLSTATE: + case MySqlParser.KW_RETURNS: + case MySqlParser.KW_REUSE: + case MySqlParser.KW_ROLE: + case MySqlParser.KW_ROLLBACK: + case MySqlParser.KW_ROLLUP: + case MySqlParser.KW_ROTATE: + case MySqlParser.KW_ROW: + case MySqlParser.KW_ROWS: + case MySqlParser.KW_ROW_FORMAT: + case MySqlParser.KW_SAVEPOINT: + case MySqlParser.KW_SCHEDULE: + case MySqlParser.KW_SECURITY: + case MySqlParser.KW_SERVER: + case MySqlParser.KW_SESSION: + case MySqlParser.KW_SHARE: + case MySqlParser.KW_SHARED: + case MySqlParser.KW_SIGNED: + case MySqlParser.KW_SIMPLE: + case MySqlParser.KW_SLAVE: + case MySqlParser.KW_SLOW: + case MySqlParser.KW_SNAPSHOT: + case MySqlParser.KW_SOCKET: + case MySqlParser.KW_SOME: + case MySqlParser.KW_SONAME: + case MySqlParser.KW_SOUNDS: + case MySqlParser.KW_SOURCE: + case MySqlParser.KW_SQL_AFTER_GTIDS: + case MySqlParser.KW_SQL_AFTER_MTS_GAPS: + case MySqlParser.KW_SQL_BEFORE_GTIDS: + case MySqlParser.KW_SQL_BUFFER_RESULT: + case MySqlParser.KW_SQL_CACHE: + case MySqlParser.KW_SQL_NO_CACHE: + case MySqlParser.KW_SQL_THREAD: + case MySqlParser.KW_START: + case MySqlParser.KW_STARTS: + case MySqlParser.KW_STATS_AUTO_RECALC: + case MySqlParser.KW_STATS_PERSISTENT: + case MySqlParser.KW_STATS_SAMPLE_PAGES: + case MySqlParser.KW_STATUS: + case MySqlParser.KW_STOP: + case MySqlParser.KW_STORAGE: + case MySqlParser.KW_STRING: + case MySqlParser.KW_SUBCLASS_ORIGIN: + case MySqlParser.KW_SUBJECT: + case MySqlParser.KW_SUBPARTITION: + case MySqlParser.KW_SUBPARTITIONS: + case MySqlParser.KW_SUSPEND: + case MySqlParser.KW_SWAPS: + case MySqlParser.KW_SWITCHES: + case MySqlParser.KW_TABLE_NAME: + case MySqlParser.KW_TABLESPACE: + case MySqlParser.KW_TABLE_TYPE: + case MySqlParser.KW_TEMPORARY: + case MySqlParser.KW_TEMPTABLE: + case MySqlParser.KW_THAN: + case MySqlParser.KW_TRADITIONAL: + case MySqlParser.KW_TRANSACTION: + case MySqlParser.KW_TRANSACTIONAL: + case MySqlParser.KW_TRIGGERS: + case MySqlParser.KW_TRUNCATE: + case MySqlParser.KW_UNBOUNDED: + case MySqlParser.KW_UNDEFINED: + case MySqlParser.KW_UNDOFILE: + case MySqlParser.KW_UNDO_BUFFER_SIZE: + case MySqlParser.KW_UNINSTALL: + case MySqlParser.KW_UNKNOWN: + case MySqlParser.KW_UNTIL: + case MySqlParser.KW_UPGRADE: + case MySqlParser.KW_USER: + case MySqlParser.KW_USE_FRM: + case MySqlParser.KW_USER_RESOURCES: + case MySqlParser.KW_VALIDATION: + case MySqlParser.KW_VALUE: + case MySqlParser.KW_VARIABLES: + case MySqlParser.KW_VIEW: + case MySqlParser.KW_VIRTUAL: + case MySqlParser.KW_VISIBLE: + case MySqlParser.KW_WAIT: + case MySqlParser.KW_WARNINGS: + case MySqlParser.KW_WITHOUT: + case MySqlParser.KW_WORK: + case MySqlParser.KW_WRAPPER: + case MySqlParser.KW_X509: + case MySqlParser.KW_XA: + case MySqlParser.KW_XML: + case MySqlParser.KW_QUARTER: + case MySqlParser.KW_MONTH: + case MySqlParser.KW_DAY: + case MySqlParser.KW_HOUR: + case MySqlParser.KW_MINUTE: + case MySqlParser.KW_WEEK: + case MySqlParser.KW_SECOND: + case MySqlParser.KW_MICROSECOND: + case MySqlParser.KW_ADMIN: + case MySqlParser.KW_AUDIT_ABORT_EXEMPT: + case MySqlParser.KW_AUDIT_ADMIN: + case MySqlParser.KW_AUTHENTICATION_POLICY_ADMIN: + case MySqlParser.KW_BACKUP_ADMIN: + case MySqlParser.KW_BINLOG_ADMIN: + case MySqlParser.KW_BINLOG_ENCRYPTION_ADMIN: + case MySqlParser.KW_CLONE_ADMIN: + case MySqlParser.KW_CONNECTION_ADMIN: + case MySqlParser.KW_ENCRYPTION_KEY_ADMIN: + case MySqlParser.KW_EXECUTE: + case MySqlParser.KW_FILE: + case MySqlParser.KW_FIREWALL_ADMIN: + case MySqlParser.KW_FIREWALL_EXEMPT: + case MySqlParser.KW_FIREWALL_USER: + case MySqlParser.KW_GROUP_REPLICATION_ADMIN: + case MySqlParser.KW_INNODB_REDO_LOG_ARCHIVE: + case MySqlParser.KW_INVOKE: + case MySqlParser.KW_LAMBDA: + case MySqlParser.KW_NDB_STORED_USER: + case MySqlParser.KW_PASSWORDLESS_USER_ADMIN: + case MySqlParser.KW_PERSIST_RO_VARIABLES_ADMIN: + case MySqlParser.KW_PRIVILEGES: + case MySqlParser.KW_PROCESS: + case MySqlParser.KW_RELOAD: + case MySqlParser.KW_REPLICATION_APPLIER: + case MySqlParser.KW_REPLICATION_SLAVE_ADMIN: + case MySqlParser.KW_RESOURCE_GROUP_ADMIN: + case MySqlParser.KW_RESOURCE_GROUP_USER: + case MySqlParser.KW_ROLE_ADMIN: + case MySqlParser.KW_ROUTINE: + case MySqlParser.KW_S3: + case MySqlParser.KW_SESSION_VARIABLES_ADMIN: + case MySqlParser.KW_SET_USER_ID: + case MySqlParser.KW_SHOW_ROUTINE: + case MySqlParser.KW_SHUTDOWN: + case MySqlParser.KW_SUPER: + case MySqlParser.KW_SYSTEM_VARIABLES_ADMIN: + case MySqlParser.KW_TABLES: + case MySqlParser.KW_TABLE_ENCRYPTION_ADMIN: + case MySqlParser.KW_VERSION_TOKEN_ADMIN: + case MySqlParser.KW_XA_RECOVER_ADMIN: + case MySqlParser.KW_ARMSCII8: + case MySqlParser.KW_ASCII: + case MySqlParser.KW_BIG5: + case MySqlParser.KW_CP1250: + case MySqlParser.KW_CP1251: + case MySqlParser.KW_CP1256: + case MySqlParser.KW_CP1257: + case MySqlParser.KW_CP850: + case MySqlParser.KW_CP852: + case MySqlParser.KW_CP866: + case MySqlParser.KW_CP932: + case MySqlParser.KW_DEC8: + case MySqlParser.KW_EUCJPMS: + case MySqlParser.KW_EUCKR: + case MySqlParser.KW_GB18030: + case MySqlParser.KW_GB2312: + case MySqlParser.KW_GBK: + case MySqlParser.KW_GEOSTD8: + case MySqlParser.KW_GREEK: + case MySqlParser.KW_HEBREW: + case MySqlParser.KW_HP8: + case MySqlParser.KW_KEYBCS2: + case MySqlParser.KW_KOI8R: + case MySqlParser.KW_KOI8U: + case MySqlParser.KW_LATIN1: + case MySqlParser.KW_LATIN2: + case MySqlParser.KW_LATIN5: + case MySqlParser.KW_LATIN7: + case MySqlParser.KW_MACCE: + case MySqlParser.KW_MACROMAN: + case MySqlParser.KW_SJIS: + case MySqlParser.KW_SWE7: + case MySqlParser.KW_TIS620: + case MySqlParser.KW_UCS2: + case MySqlParser.KW_UJIS: + case MySqlParser.KW_UTF16: + case MySqlParser.KW_UTF16LE: + case MySqlParser.KW_UTF32: + case MySqlParser.KW_UTF8: + case MySqlParser.KW_UTF8MB3: + case MySqlParser.KW_UTF8MB4: + case MySqlParser.KW_ARCHIVE: + case MySqlParser.KW_BLACKHOLE: + case MySqlParser.KW_CSV: + case MySqlParser.KW_FEDERATED: + case MySqlParser.KW_INNODB: + case MySqlParser.KW_MEMORY: + case MySqlParser.KW_MRG_MYISAM: + case MySqlParser.KW_MYISAM: + case MySqlParser.KW_NDB: + case MySqlParser.KW_NDBCLUSTER: + case MySqlParser.KW_PERFORMANCE_SCHEMA: + case MySqlParser.KW_TOKUDB: + case MySqlParser.KW_REPEATABLE: + case MySqlParser.KW_COMMITTED: + case MySqlParser.KW_UNCOMMITTED: + case MySqlParser.KW_SERIALIZABLE: + case MySqlParser.KW_GEOMETRYCOLLECTION: + case MySqlParser.KW_LINESTRING: + case MySqlParser.KW_MULTILINESTRING: + case MySqlParser.KW_MULTIPOINT: + case MySqlParser.KW_MULTIPOLYGON: + case MySqlParser.KW_POINT: + case MySqlParser.KW_POLYGON: + case MySqlParser.KW_CATALOG_NAME: + case MySqlParser.KW_CHARSET: + case MySqlParser.KW_COLLATION: + case MySqlParser.KW_ENGINE_ATTRIBUTE: + case MySqlParser.KW_FORMAT: + case MySqlParser.KW_GET_FORMAT: + case MySqlParser.KW_RANDOM: + case MySqlParser.KW_REVERSE: + case MySqlParser.KW_ROW_COUNT: + case MySqlParser.KW_SCHEMA_NAME: + case MySqlParser.KW_SECONDARY_ENGINE_ATTRIBUTE: + case MySqlParser.KW_SRID: + case MySqlParser.KW_SYSTEM_USER: + case MySqlParser.KW_TP_CONNECTION_ADMIN: + case MySqlParser.KW_WEIGHT_STRING: + case MySqlParser.MOD: + case MySqlParser.ID: + { + this.state = 6700; + this.simpleId(); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + withStatement() { + let localContext = new WithStatementContext(this.context, this.state); + this.enterRule(localContext, 612, MySqlParser.RULE_withStatement); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6703; + this.match(MySqlParser.KW_WITH); + this.state = 6705; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 966, this.context)) { + case 1: + { + this.state = 6704; + this.match(MySqlParser.KW_RECURSIVE); + } + break; + } + this.state = 6707; + this.commonTableExpressions(); + this.state = 6712; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 6708; + this.match(MySqlParser.COMMA); + this.state = 6709; + this.commonTableExpressions(); + } + } + this.state = 6714; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + tableStatement() { + let localContext = new TableStatementContext(this.context, this.state); + this.enterRule(localContext, 614, MySqlParser.RULE_tableStatement); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6715; + this.match(MySqlParser.KW_TABLE); + this.state = 6716; + this.tableName(); + this.state = 6718; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 968, this.context)) { + case 1: + { + this.state = 6717; + this.orderByClause(); + } + break; + } + this.state = 6721; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 969, this.context)) { + case 1: + { + this.state = 6720; + this.limitClause(); + } + break; + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + diagnosticsStatement() { + let localContext = new DiagnosticsStatementContext(this.context, this.state); + this.enterRule(localContext, 616, MySqlParser.RULE_diagnosticsStatement); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6723; + this.match(MySqlParser.KW_GET); + this.state = 6725; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 36 || _la === 170) { + { + this.state = 6724; + _la = this.tokenStream.LA(1); + if (!(_la === 36 || _la === 170)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + this.state = 6727; + this.match(MySqlParser.KW_DIAGNOSTICS); + this.state = 6759; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 974, this.context)) { + case 1: + { + { + this.state = 6728; + this.variableClause(); + this.state = 6729; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 6730; + _la = this.tokenStream.LA(1); + if (!(_la === 117 || _la === 831)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 6738; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 6731; + this.match(MySqlParser.COMMA); + this.state = 6732; + this.variableClause(); + this.state = 6733; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 6734; + _la = this.tokenStream.LA(1); + if (!(_la === 117 || _la === 831)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + this.state = 6740; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + } + break; + case 2: + { + { + this.state = 6741; + this.match(MySqlParser.KW_CONDITION); + this.state = 6744; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.ZERO_DECIMAL: + case MySqlParser.ONE_DECIMAL: + case MySqlParser.TWO_DECIMAL: + case MySqlParser.THREE_DECIMAL: + case MySqlParser.DECIMAL_LITERAL: + case MySqlParser.REAL_LITERAL: + { + this.state = 6742; + this.decimalLiteral(); + } + break; + case MySqlParser.KW_ARRAY: + case MySqlParser.KW_ATTRIBUTE: + case MySqlParser.KW_BUCKETS: + case MySqlParser.KW_CONDITION: + case MySqlParser.KW_CURRENT: + case MySqlParser.KW_CURRENT_USER: + case MySqlParser.KW_DATABASE: + case MySqlParser.KW_DEFAULT: + case MySqlParser.KW_DIAGNOSTICS: + case MySqlParser.KW_EMPTY: + case MySqlParser.KW_ENFORCED: + case MySqlParser.KW_EXCEPT: + case MySqlParser.KW_GROUP: + case MySqlParser.KW_IF: + case MySqlParser.KW_INSERT: + case MySqlParser.KW_LATERAL: + case MySqlParser.KW_LEFT: + case MySqlParser.KW_NUMBER: + case MySqlParser.KW_OPTIONAL: + case MySqlParser.KW_ORDER: + case MySqlParser.KW_PRIMARY: + case MySqlParser.KW_REPEAT: + case MySqlParser.KW_REPLACE: + case MySqlParser.KW_RIGHT: + case MySqlParser.KW_SCHEMA: + case MySqlParser.KW_SKIP_QUERY_REWRITE: + case MySqlParser.KW_STACKED: + case MySqlParser.KW_DATE: + case MySqlParser.KW_TIME: + case MySqlParser.KW_TIMESTAMP: + case MySqlParser.KW_DATETIME: + case MySqlParser.KW_YEAR: + case MySqlParser.KW_BINARY: + case MySqlParser.KW_TEXT: + case MySqlParser.KW_ENUM: + case MySqlParser.KW_SERIAL: + case MySqlParser.KW_JSON_TABLE: + case MySqlParser.KW_JSON_VALUE: + case MySqlParser.KW_NESTED: + case MySqlParser.KW_ORDINALITY: + case MySqlParser.KW_PATH: + case MySqlParser.KW_AVG: + case MySqlParser.KW_BIT_AND: + case MySqlParser.KW_BIT_OR: + case MySqlParser.KW_BIT_XOR: + case MySqlParser.KW_COUNT: + case MySqlParser.KW_CUME_DIST: + case MySqlParser.KW_DENSE_RANK: + case MySqlParser.KW_FIRST_VALUE: + case MySqlParser.KW_GROUP_CONCAT: + case MySqlParser.KW_LAG: + case MySqlParser.KW_LAST_VALUE: + case MySqlParser.KW_LEAD: + case MySqlParser.KW_MAX: + case MySqlParser.KW_MIN: + case MySqlParser.KW_NTILE: + case MySqlParser.KW_NTH_VALUE: + case MySqlParser.KW_PERCENT_RANK: + case MySqlParser.KW_RANK: + case MySqlParser.KW_ROW_NUMBER: + case MySqlParser.KW_STD: + case MySqlParser.KW_STDDEV: + case MySqlParser.KW_STDDEV_POP: + case MySqlParser.KW_STDDEV_SAMP: + case MySqlParser.KW_SUM: + case MySqlParser.KW_VAR_POP: + case MySqlParser.KW_VAR_SAMP: + case MySqlParser.KW_VARIANCE: + case MySqlParser.KW_CURRENT_DATE: + case MySqlParser.KW_CURRENT_TIME: + case MySqlParser.KW_CURRENT_TIMESTAMP: + case MySqlParser.KW_LOCALTIME: + case MySqlParser.KW_CURDATE: + case MySqlParser.KW_CURTIME: + case MySqlParser.KW_DATE_ADD: + case MySqlParser.KW_DATE_SUB: + case MySqlParser.KW_LOCALTIMESTAMP: + case MySqlParser.KW_NOW: + case MySqlParser.KW_POSITION: + case MySqlParser.KW_SUBSTR: + case MySqlParser.KW_SUBSTRING: + case MySqlParser.KW_SYSDATE: + case MySqlParser.KW_TRIM: + case MySqlParser.KW_UTC_DATE: + case MySqlParser.KW_UTC_TIME: + case MySqlParser.KW_UTC_TIMESTAMP: + case MySqlParser.KW_ACCOUNT: + case MySqlParser.KW_ACTION: + case MySqlParser.KW_AFTER: + case MySqlParser.KW_AGGREGATE: + case MySqlParser.KW_ALGORITHM: + case MySqlParser.KW_ANY: + case MySqlParser.KW_AT: + case MySqlParser.KW_AUTHORS: + case MySqlParser.KW_AUTOCOMMIT: + case MySqlParser.KW_AUTOEXTEND_SIZE: + case MySqlParser.KW_AUTO_INCREMENT: + case MySqlParser.KW_AVG_ROW_LENGTH: + case MySqlParser.KW_BEGIN: + case MySqlParser.KW_BINLOG: + case MySqlParser.KW_BIT: + case MySqlParser.KW_BLOCK: + case MySqlParser.KW_BOOL: + case MySqlParser.KW_BOOLEAN: + case MySqlParser.KW_BTREE: + case MySqlParser.KW_CACHE: + case MySqlParser.KW_CASCADED: + case MySqlParser.KW_CHAIN: + case MySqlParser.KW_CHANGED: + case MySqlParser.KW_CHANNEL: + case MySqlParser.KW_CHECKSUM: + case MySqlParser.KW_CIPHER: + case MySqlParser.KW_CLASS_ORIGIN: + case MySqlParser.KW_CLIENT: + case MySqlParser.KW_CLOSE: + case MySqlParser.KW_COALESCE: + case MySqlParser.KW_CODE: + case MySqlParser.KW_COLUMNS: + case MySqlParser.KW_COLUMN_FORMAT: + case MySqlParser.KW_COLUMN_NAME: + case MySqlParser.KW_COMMENT: + case MySqlParser.KW_COMMIT: + case MySqlParser.KW_COMPACT: + case MySqlParser.KW_COMPLETION: + case MySqlParser.KW_COMPRESSED: + case MySqlParser.KW_COMPRESSION: + case MySqlParser.KW_CONCURRENT: + case MySqlParser.KW_CONNECT: + case MySqlParser.KW_CONNECTION: + case MySqlParser.KW_CONSISTENT: + case MySqlParser.KW_CONSTRAINT_CATALOG: + case MySqlParser.KW_CONSTRAINT_SCHEMA: + case MySqlParser.KW_CONSTRAINT_NAME: + case MySqlParser.KW_CONTAINS: + case MySqlParser.KW_CONTEXT: + case MySqlParser.KW_CONTRIBUTORS: + case MySqlParser.KW_COPY: + case MySqlParser.KW_CPU: + case MySqlParser.KW_CURSOR_NAME: + case MySqlParser.KW_DATA: + case MySqlParser.KW_DATAFILE: + case MySqlParser.KW_DEALLOCATE: + case MySqlParser.KW_DEFAULT_AUTH: + case MySqlParser.KW_DEFINER: + case MySqlParser.KW_DELAY_KEY_WRITE: + case MySqlParser.KW_DES_KEY_FILE: + case MySqlParser.KW_DIRECTORY: + case MySqlParser.KW_DISABLE: + case MySqlParser.KW_DISCARD: + case MySqlParser.KW_DISK: + case MySqlParser.KW_DO: + case MySqlParser.KW_DUMPFILE: + case MySqlParser.KW_DUPLICATE: + case MySqlParser.KW_DYNAMIC: + case MySqlParser.KW_ENABLE: + case MySqlParser.KW_ENCRYPTION: + case MySqlParser.KW_END: + case MySqlParser.KW_ENDS: + case MySqlParser.KW_ENGINE: + case MySqlParser.KW_ENGINES: + case MySqlParser.KW_ERROR: + case MySqlParser.KW_ERRORS: + case MySqlParser.KW_ESCAPE: + case MySqlParser.KW_EVENT: + case MySqlParser.KW_EVENTS: + case MySqlParser.KW_EVERY: + case MySqlParser.KW_EXCHANGE: + case MySqlParser.KW_EXCLUSIVE: + case MySqlParser.KW_EXPIRE: + case MySqlParser.KW_EXPORT: + case MySqlParser.KW_EXTENDED: + case MySqlParser.KW_EXTENT_SIZE: + case MySqlParser.KW_FAILED_LOGIN_ATTEMPTS: + case MySqlParser.KW_FAST: + case MySqlParser.KW_FAULTS: + case MySqlParser.KW_FIELDS: + case MySqlParser.KW_FILE_BLOCK_SIZE: + case MySqlParser.KW_FILTER: + case MySqlParser.KW_FIRST: + case MySqlParser.KW_FIXED: + case MySqlParser.KW_FLUSH: + case MySqlParser.KW_FOLLOWS: + case MySqlParser.KW_FOUND: + case MySqlParser.KW_FULL: + case MySqlParser.KW_FUNCTION: + case MySqlParser.KW_GENERAL: + case MySqlParser.KW_GLOBAL: + case MySqlParser.KW_GRANTS: + case MySqlParser.KW_GROUP_REPLICATION: + case MySqlParser.KW_HANDLER: + case MySqlParser.KW_HASH: + case MySqlParser.KW_HELP: + case MySqlParser.KW_HISTORY: + case MySqlParser.KW_HOST: + case MySqlParser.KW_HOSTS: + case MySqlParser.KW_IDENTIFIED: + case MySqlParser.KW_IGNORE_SERVER_IDS: + case MySqlParser.KW_IMPORT: + case MySqlParser.KW_INDEXES: + case MySqlParser.KW_INITIAL_SIZE: + case MySqlParser.KW_INPLACE: + case MySqlParser.KW_INSERT_METHOD: + case MySqlParser.KW_INSTALL: + case MySqlParser.KW_INSTANCE: + case MySqlParser.KW_INSTANT: + case MySqlParser.KW_INVISIBLE: + case MySqlParser.KW_INVOKER: + case MySqlParser.KW_IO: + case MySqlParser.KW_IO_THREAD: + case MySqlParser.KW_IPC: + case MySqlParser.KW_ISOLATION: + case MySqlParser.KW_ISSUER: + case MySqlParser.KW_JSON: + case MySqlParser.KW_KEY_BLOCK_SIZE: + case MySqlParser.KW_LANGUAGE: + case MySqlParser.KW_LAST: + case MySqlParser.KW_LEAVES: + case MySqlParser.KW_LESS: + case MySqlParser.KW_LEVEL: + case MySqlParser.KW_LIST: + case MySqlParser.KW_LOCAL: + case MySqlParser.KW_LOGFILE: + case MySqlParser.KW_LOGS: + case MySqlParser.KW_MASTER: + case MySqlParser.KW_MASTER_AUTO_POSITION: + case MySqlParser.KW_MASTER_CONNECT_RETRY: + case MySqlParser.KW_MASTER_DELAY: + case MySqlParser.KW_MASTER_HEARTBEAT_PERIOD: + case MySqlParser.KW_MASTER_HOST: + case MySqlParser.KW_MASTER_LOG_FILE: + case MySqlParser.KW_MASTER_LOG_POS: + case MySqlParser.KW_MASTER_PASSWORD: + case MySqlParser.KW_MASTER_PORT: + case MySqlParser.KW_MASTER_RETRY_COUNT: + case MySqlParser.KW_MASTER_SSL: + case MySqlParser.KW_MASTER_SSL_CA: + case MySqlParser.KW_MASTER_SSL_CAPATH: + case MySqlParser.KW_MASTER_SSL_CERT: + case MySqlParser.KW_MASTER_SSL_CIPHER: + case MySqlParser.KW_MASTER_SSL_CRL: + case MySqlParser.KW_MASTER_SSL_CRLPATH: + case MySqlParser.KW_MASTER_SSL_KEY: + case MySqlParser.KW_MASTER_TLS_VERSION: + case MySqlParser.KW_MASTER_USER: + case MySqlParser.KW_MAX_CONNECTIONS_PER_HOUR: + case MySqlParser.KW_MAX_QUERIES_PER_HOUR: + case MySqlParser.KW_MAX_ROWS: + case MySqlParser.KW_MAX_SIZE: + case MySqlParser.KW_MAX_UPDATES_PER_HOUR: + case MySqlParser.KW_MAX_USER_CONNECTIONS: + case MySqlParser.KW_MEDIUM: + case MySqlParser.KW_MEMBER: + case MySqlParser.KW_MERGE: + case MySqlParser.KW_MESSAGE_TEXT: + case MySqlParser.KW_MID: + case MySqlParser.KW_MIGRATE: + case MySqlParser.KW_MIN_ROWS: + case MySqlParser.KW_MODE: + case MySqlParser.KW_MODIFY: + case MySqlParser.KW_MUTEX: + case MySqlParser.KW_MYSQL: + case MySqlParser.KW_MYSQL_ERRNO: + case MySqlParser.KW_NAME: + case MySqlParser.KW_NAMES: + case MySqlParser.KW_NCHAR: + case MySqlParser.KW_NEVER: + case MySqlParser.KW_NEXT: + case MySqlParser.KW_NO: + case MySqlParser.KW_NOWAIT: + case MySqlParser.KW_NODEGROUP: + case MySqlParser.KW_NONE: + case MySqlParser.KW_ODBC: + case MySqlParser.KW_OFFLINE: + case MySqlParser.KW_OFFSET: + case MySqlParser.KW_OF: + case MySqlParser.KW_OLD_PASSWORD: + case MySqlParser.KW_ONE: + case MySqlParser.KW_ONLINE: + case MySqlParser.KW_ONLY: + case MySqlParser.KW_OPEN: + case MySqlParser.KW_OPTIMIZER_COSTS: + case MySqlParser.KW_OPTIONS: + case MySqlParser.KW_OWNER: + case MySqlParser.KW_PACK_KEYS: + case MySqlParser.KW_PAGE: + case MySqlParser.KW_PAGE_CHECKSUM: + case MySqlParser.KW_PARSER: + case MySqlParser.KW_PARTIAL: + case MySqlParser.KW_PARTITIONING: + case MySqlParser.KW_PARTITIONS: + case MySqlParser.KW_PASSWORD: + case MySqlParser.KW_PASSWORD_LOCK_TIME: + case MySqlParser.KW_PERSIST: + case MySqlParser.KW_PERSIST_ONLY: + case MySqlParser.KW_PHASE: + case MySqlParser.KW_PLUGIN: + case MySqlParser.KW_PLUGIN_DIR: + case MySqlParser.KW_PLUGINS: + case MySqlParser.KW_PORT: + case MySqlParser.KW_PRECEDES: + case MySqlParser.KW_PREPARE: + case MySqlParser.KW_PRESERVE: + case MySqlParser.KW_PREV: + case MySqlParser.KW_PROCESSLIST: + case MySqlParser.KW_PROFILE: + case MySqlParser.KW_PROFILES: + case MySqlParser.KW_PROXY: + case MySqlParser.KW_QUERY: + case MySqlParser.KW_QUICK: + case MySqlParser.KW_REBUILD: + case MySqlParser.KW_RECOVER: + case MySqlParser.KW_RECURSIVE: + case MySqlParser.KW_REDO_BUFFER_SIZE: + case MySqlParser.KW_REDUNDANT: + case MySqlParser.KW_RELAY: + case MySqlParser.KW_RELAY_LOG_FILE: + case MySqlParser.KW_RELAY_LOG_POS: + case MySqlParser.KW_RELAYLOG: + case MySqlParser.KW_REMOVE: + case MySqlParser.KW_REORGANIZE: + case MySqlParser.KW_REPAIR: + case MySqlParser.KW_REPLICATE_DO_DB: + case MySqlParser.KW_REPLICATE_DO_TABLE: + case MySqlParser.KW_REPLICATE_IGNORE_DB: + case MySqlParser.KW_REPLICATE_IGNORE_TABLE: + case MySqlParser.KW_REPLICATE_REWRITE_DB: + case MySqlParser.KW_REPLICATE_WILD_DO_TABLE: + case MySqlParser.KW_REPLICATE_WILD_IGNORE_TABLE: + case MySqlParser.KW_REPLICATION: + case MySqlParser.KW_RESET: + case MySqlParser.KW_RESUME: + case MySqlParser.KW_RETURNED_SQLSTATE: + case MySqlParser.KW_RETURNS: + case MySqlParser.KW_REUSE: + case MySqlParser.KW_ROLE: + case MySqlParser.KW_ROLLBACK: + case MySqlParser.KW_ROLLUP: + case MySqlParser.KW_ROTATE: + case MySqlParser.KW_ROW: + case MySqlParser.KW_ROWS: + case MySqlParser.KW_ROW_FORMAT: + case MySqlParser.KW_SAVEPOINT: + case MySqlParser.KW_SCHEDULE: + case MySqlParser.KW_SECURITY: + case MySqlParser.KW_SERVER: + case MySqlParser.KW_SESSION: + case MySqlParser.KW_SHARE: + case MySqlParser.KW_SHARED: + case MySqlParser.KW_SIGNED: + case MySqlParser.KW_SIMPLE: + case MySqlParser.KW_SLAVE: + case MySqlParser.KW_SLOW: + case MySqlParser.KW_SNAPSHOT: + case MySqlParser.KW_SOCKET: + case MySqlParser.KW_SOME: + case MySqlParser.KW_SONAME: + case MySqlParser.KW_SOUNDS: + case MySqlParser.KW_SOURCE: + case MySqlParser.KW_SQL_AFTER_GTIDS: + case MySqlParser.KW_SQL_AFTER_MTS_GAPS: + case MySqlParser.KW_SQL_BEFORE_GTIDS: + case MySqlParser.KW_SQL_BUFFER_RESULT: + case MySqlParser.KW_SQL_CACHE: + case MySqlParser.KW_SQL_NO_CACHE: + case MySqlParser.KW_SQL_THREAD: + case MySqlParser.KW_START: + case MySqlParser.KW_STARTS: + case MySqlParser.KW_STATS_AUTO_RECALC: + case MySqlParser.KW_STATS_PERSISTENT: + case MySqlParser.KW_STATS_SAMPLE_PAGES: + case MySqlParser.KW_STATUS: + case MySqlParser.KW_STOP: + case MySqlParser.KW_STORAGE: + case MySqlParser.KW_STRING: + case MySqlParser.KW_SUBCLASS_ORIGIN: + case MySqlParser.KW_SUBJECT: + case MySqlParser.KW_SUBPARTITION: + case MySqlParser.KW_SUBPARTITIONS: + case MySqlParser.KW_SUSPEND: + case MySqlParser.KW_SWAPS: + case MySqlParser.KW_SWITCHES: + case MySqlParser.KW_TABLE_NAME: + case MySqlParser.KW_TABLESPACE: + case MySqlParser.KW_TABLE_TYPE: + case MySqlParser.KW_TEMPORARY: + case MySqlParser.KW_TEMPTABLE: + case MySqlParser.KW_THAN: + case MySqlParser.KW_TRADITIONAL: + case MySqlParser.KW_TRANSACTION: + case MySqlParser.KW_TRANSACTIONAL: + case MySqlParser.KW_TRIGGERS: + case MySqlParser.KW_TRUNCATE: + case MySqlParser.KW_UNBOUNDED: + case MySqlParser.KW_UNDEFINED: + case MySqlParser.KW_UNDOFILE: + case MySqlParser.KW_UNDO_BUFFER_SIZE: + case MySqlParser.KW_UNINSTALL: + case MySqlParser.KW_UNKNOWN: + case MySqlParser.KW_UNTIL: + case MySqlParser.KW_UPGRADE: + case MySqlParser.KW_USER: + case MySqlParser.KW_USE_FRM: + case MySqlParser.KW_USER_RESOURCES: + case MySqlParser.KW_VALIDATION: + case MySqlParser.KW_VALUE: + case MySqlParser.KW_VARIABLES: + case MySqlParser.KW_VIEW: + case MySqlParser.KW_VIRTUAL: + case MySqlParser.KW_VISIBLE: + case MySqlParser.KW_WAIT: + case MySqlParser.KW_WARNINGS: + case MySqlParser.KW_WITHOUT: + case MySqlParser.KW_WORK: + case MySqlParser.KW_WRAPPER: + case MySqlParser.KW_X509: + case MySqlParser.KW_XA: + case MySqlParser.KW_XML: + case MySqlParser.KW_QUARTER: + case MySqlParser.KW_MONTH: + case MySqlParser.KW_DAY: + case MySqlParser.KW_HOUR: + case MySqlParser.KW_MINUTE: + case MySqlParser.KW_WEEK: + case MySqlParser.KW_SECOND: + case MySqlParser.KW_MICROSECOND: + case MySqlParser.KW_ADMIN: + case MySqlParser.KW_AUDIT_ABORT_EXEMPT: + case MySqlParser.KW_AUDIT_ADMIN: + case MySqlParser.KW_AUTHENTICATION_POLICY_ADMIN: + case MySqlParser.KW_BACKUP_ADMIN: + case MySqlParser.KW_BINLOG_ADMIN: + case MySqlParser.KW_BINLOG_ENCRYPTION_ADMIN: + case MySqlParser.KW_CLONE_ADMIN: + case MySqlParser.KW_CONNECTION_ADMIN: + case MySqlParser.KW_ENCRYPTION_KEY_ADMIN: + case MySqlParser.KW_EXECUTE: + case MySqlParser.KW_FILE: + case MySqlParser.KW_FIREWALL_ADMIN: + case MySqlParser.KW_FIREWALL_EXEMPT: + case MySqlParser.KW_FIREWALL_USER: + case MySqlParser.KW_GROUP_REPLICATION_ADMIN: + case MySqlParser.KW_INNODB_REDO_LOG_ARCHIVE: + case MySqlParser.KW_INVOKE: + case MySqlParser.KW_LAMBDA: + case MySqlParser.KW_NDB_STORED_USER: + case MySqlParser.KW_PASSWORDLESS_USER_ADMIN: + case MySqlParser.KW_PERSIST_RO_VARIABLES_ADMIN: + case MySqlParser.KW_PRIVILEGES: + case MySqlParser.KW_PROCESS: + case MySqlParser.KW_RELOAD: + case MySqlParser.KW_REPLICATION_APPLIER: + case MySqlParser.KW_REPLICATION_SLAVE_ADMIN: + case MySqlParser.KW_RESOURCE_GROUP_ADMIN: + case MySqlParser.KW_RESOURCE_GROUP_USER: + case MySqlParser.KW_ROLE_ADMIN: + case MySqlParser.KW_ROUTINE: + case MySqlParser.KW_S3: + case MySqlParser.KW_SESSION_VARIABLES_ADMIN: + case MySqlParser.KW_SET_USER_ID: + case MySqlParser.KW_SHOW_ROUTINE: + case MySqlParser.KW_SHUTDOWN: + case MySqlParser.KW_SUPER: + case MySqlParser.KW_SYSTEM_VARIABLES_ADMIN: + case MySqlParser.KW_TABLES: + case MySqlParser.KW_TABLE_ENCRYPTION_ADMIN: + case MySqlParser.KW_VERSION_TOKEN_ADMIN: + case MySqlParser.KW_XA_RECOVER_ADMIN: + case MySqlParser.KW_ARMSCII8: + case MySqlParser.KW_ASCII: + case MySqlParser.KW_BIG5: + case MySqlParser.KW_CP1250: + case MySqlParser.KW_CP1251: + case MySqlParser.KW_CP1256: + case MySqlParser.KW_CP1257: + case MySqlParser.KW_CP850: + case MySqlParser.KW_CP852: + case MySqlParser.KW_CP866: + case MySqlParser.KW_CP932: + case MySqlParser.KW_DEC8: + case MySqlParser.KW_EUCJPMS: + case MySqlParser.KW_EUCKR: + case MySqlParser.KW_GB18030: + case MySqlParser.KW_GB2312: + case MySqlParser.KW_GBK: + case MySqlParser.KW_GEOSTD8: + case MySqlParser.KW_GREEK: + case MySqlParser.KW_HEBREW: + case MySqlParser.KW_HP8: + case MySqlParser.KW_KEYBCS2: + case MySqlParser.KW_KOI8R: + case MySqlParser.KW_KOI8U: + case MySqlParser.KW_LATIN1: + case MySqlParser.KW_LATIN2: + case MySqlParser.KW_LATIN5: + case MySqlParser.KW_LATIN7: + case MySqlParser.KW_MACCE: + case MySqlParser.KW_MACROMAN: + case MySqlParser.KW_SJIS: + case MySqlParser.KW_SWE7: + case MySqlParser.KW_TIS620: + case MySqlParser.KW_UCS2: + case MySqlParser.KW_UJIS: + case MySqlParser.KW_UTF16: + case MySqlParser.KW_UTF16LE: + case MySqlParser.KW_UTF32: + case MySqlParser.KW_UTF8: + case MySqlParser.KW_UTF8MB3: + case MySqlParser.KW_UTF8MB4: + case MySqlParser.KW_ARCHIVE: + case MySqlParser.KW_BLACKHOLE: + case MySqlParser.KW_CSV: + case MySqlParser.KW_FEDERATED: + case MySqlParser.KW_INNODB: + case MySqlParser.KW_MEMORY: + case MySqlParser.KW_MRG_MYISAM: + case MySqlParser.KW_MYISAM: + case MySqlParser.KW_NDB: + case MySqlParser.KW_NDBCLUSTER: + case MySqlParser.KW_PERFORMANCE_SCHEMA: + case MySqlParser.KW_TOKUDB: + case MySqlParser.KW_REPEATABLE: + case MySqlParser.KW_COMMITTED: + case MySqlParser.KW_UNCOMMITTED: + case MySqlParser.KW_SERIALIZABLE: + case MySqlParser.KW_GEOMETRYCOLLECTION: + case MySqlParser.KW_LINESTRING: + case MySqlParser.KW_MULTILINESTRING: + case MySqlParser.KW_MULTIPOINT: + case MySqlParser.KW_MULTIPOLYGON: + case MySqlParser.KW_POINT: + case MySqlParser.KW_POLYGON: + case MySqlParser.KW_CATALOG_NAME: + case MySqlParser.KW_CHARSET: + case MySqlParser.KW_COLLATION: + case MySqlParser.KW_ENGINE_ATTRIBUTE: + case MySqlParser.KW_FORMAT: + case MySqlParser.KW_GET_FORMAT: + case MySqlParser.KW_RANDOM: + case MySqlParser.KW_REVERSE: + case MySqlParser.KW_ROW_COUNT: + case MySqlParser.KW_SCHEMA_NAME: + case MySqlParser.KW_SECONDARY_ENGINE_ATTRIBUTE: + case MySqlParser.KW_SRID: + case MySqlParser.KW_SYSTEM_USER: + case MySqlParser.KW_TP_CONNECTION_ADMIN: + case MySqlParser.KW_WEIGHT_STRING: + case MySqlParser.MOD: + case MySqlParser.AT_SIGN: + case MySqlParser.CHARSET_REVERSE_QOUTE_STRING: + case MySqlParser.STRING_LITERAL: + case MySqlParser.ID: + case MySqlParser.LOCAL_ID: + case MySqlParser.GLOBAL_ID: + { + this.state = 6743; + this.variableClause(); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + this.state = 6746; + this.variableClause(); + this.state = 6747; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 6748; + this.diagnosticsConditionInformationName(); + this.state = 6756; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 6749; + this.match(MySqlParser.COMMA); + this.state = 6750; + this.variableClause(); + this.state = 6751; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 6752; + this.diagnosticsConditionInformationName(); + } + } + this.state = 6758; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + } + break; + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + diagnosticsConditionInformationName() { + let localContext = new DiagnosticsConditionInformationNameContext(this.context, this.state); + this.enterRule(localContext, 618, MySqlParser.RULE_diagnosticsConditionInformationName); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6761; + _la = this.tokenStream.LA(1); + if (!(((((_la - 332)) & ~0x1F) === 0 && ((1 << (_la - 332)) & 137887873) !== 0) || _la === 487 || _la === 495 || _la === 578 || _la === 650 || _la === 657 || _la === 822 || _la === 832)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + describeObjectClause() { + let localContext = new DescribeObjectClauseContext(this.context, this.state); + this.enterRule(localContext, 620, MySqlParser.RULE_describeObjectClause); + try { + this.state = 6773; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_DELETE: + case MySqlParser.KW_INSERT: + case MySqlParser.KW_REPLACE: + case MySqlParser.KW_SELECT: + case MySqlParser.KW_UPDATE: + case MySqlParser.LR_BRACKET: + localContext = new DescribeStatementsContext(localContext); + this.enterOuterAlt(localContext, 1); + { + this.state = 6768; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_SELECT: + case MySqlParser.LR_BRACKET: + { + this.state = 6763; + this.selectStatement(); + } + break; + case MySqlParser.KW_DELETE: + { + this.state = 6764; + this.deleteStatement(); + } + break; + case MySqlParser.KW_INSERT: + { + this.state = 6765; + this.insertStatement(); + } + break; + case MySqlParser.KW_REPLACE: + { + this.state = 6766; + this.replaceStatement(); + } + break; + case MySqlParser.KW_UPDATE: + { + this.state = 6767; + this.updateStatement(); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + break; + case MySqlParser.KW_FOR: + localContext = new DescribeConnectionContext(localContext); + this.enterOuterAlt(localContext, 2); + { + this.state = 6770; + this.match(MySqlParser.KW_FOR); + this.state = 6771; + this.match(MySqlParser.KW_CONNECTION); + this.state = 6772; + localContext._connection_id = this.uid(); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + databaseNameCreate() { + let localContext = new DatabaseNameCreateContext(this.context, this.state); + this.enterRule(localContext, 622, MySqlParser.RULE_databaseNameCreate); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6775; + this.fullId(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + databaseName() { + let localContext = new DatabaseNameContext(this.context, this.state); + this.enterRule(localContext, 624, MySqlParser.RULE_databaseName); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6777; + this.fullId(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + functionNameCreate() { + let localContext = new FunctionNameCreateContext(this.context, this.state); + this.enterRule(localContext, 626, MySqlParser.RULE_functionNameCreate); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6779; + this.fullId(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + functionName() { + let localContext = new FunctionNameContext(this.context, this.state); + this.enterRule(localContext, 628, MySqlParser.RULE_functionName); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6781; + this.fullId(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + viewNameCreate() { + let localContext = new ViewNameCreateContext(this.context, this.state); + this.enterRule(localContext, 630, MySqlParser.RULE_viewNameCreate); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6783; + this.fullId(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + viewName() { + let localContext = new ViewNameContext(this.context, this.state); + this.enterRule(localContext, 632, MySqlParser.RULE_viewName); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6785; + this.fullId(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + indexNameCreate() { + let localContext = new IndexNameCreateContext(this.context, this.state); + this.enterRule(localContext, 634, MySqlParser.RULE_indexNameCreate); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6787; + this.uid(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + indexNames() { + let localContext = new IndexNamesContext(this.context, this.state); + this.enterRule(localContext, 636, MySqlParser.RULE_indexNames); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6789; + this.indexName(); + this.state = 6794; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 6790; + this.match(MySqlParser.COMMA); + this.state = 6791; + this.indexName(); + } + } + this.state = 6796; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + indexName() { + let localContext = new IndexNameContext(this.context, this.state); + this.enterRule(localContext, 638, MySqlParser.RULE_indexName); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6797; + this.uid(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + groupNameCreate() { + let localContext = new GroupNameCreateContext(this.context, this.state); + this.enterRule(localContext, 640, MySqlParser.RULE_groupNameCreate); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6799; + this.uid(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + groupName() { + let localContext = new GroupNameContext(this.context, this.state); + this.enterRule(localContext, 642, MySqlParser.RULE_groupName); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6801; + this.uid(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + tableNameCreate() { + let localContext = new TableNameCreateContext(this.context, this.state); + this.enterRule(localContext, 644, MySqlParser.RULE_tableNameCreate); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6803; + this.fullId(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + tableNames() { + let localContext = new TableNamesContext(this.context, this.state); + this.enterRule(localContext, 646, MySqlParser.RULE_tableNames); + try { + let alternative; + this.enterOuterAlt(localContext, 1); + { + this.state = 6805; + this.tableName(); + this.state = 6810; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 978, this.context); + while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER) { + if (alternative === 1) { + { + { + this.state = 6806; + this.match(MySqlParser.COMMA); + this.state = 6807; + this.tableName(); + } + } + } + this.state = 6812; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 978, this.context); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + tableName() { + let localContext = new TableNameContext(this.context, this.state); + this.enterRule(localContext, 648, MySqlParser.RULE_tableName); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6813; + this.fullId(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + userOrRoleNames() { + let localContext = new UserOrRoleNamesContext(this.context, this.state); + this.enterRule(localContext, 650, MySqlParser.RULE_userOrRoleNames); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6815; + this.userOrRoleName(); + this.state = 6820; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 6816; + this.match(MySqlParser.COMMA); + this.state = 6817; + this.userOrRoleName(); + } + } + this.state = 6822; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + userOrRoleName() { + let localContext = new UserOrRoleNameContext(this.context, this.state); + this.enterRule(localContext, 652, MySqlParser.RULE_userOrRoleName); + try { + this.state = 6825; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 980, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 6823; + this.userName(); + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 6824; + this.uid(); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + columnNameCreate() { + let localContext = new ColumnNameCreateContext(this.context, this.state); + this.enterRule(localContext, 654, MySqlParser.RULE_columnNameCreate); + let _la; + try { + this.state = 6841; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 985, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 6827; + this.uid(); + this.state = 6832; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 865) { + { + this.state = 6828; + this.dottedId(); + this.state = 6830; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 865) { + { + this.state = 6829; + this.dottedId(); + } + } + } + } + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 6835; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 983, this.context)) { + case 1: + { + this.state = 6834; + this.matchWildcard(); + } + break; + } + this.state = 6837; + this.dottedId(); + this.state = 6839; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 865) { + { + this.state = 6838; + this.dottedId(); + } + } + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + columnNames() { + let localContext = new ColumnNamesContext(this.context, this.state); + this.enterRule(localContext, 656, MySqlParser.RULE_columnNames); + try { + let alternative; + this.enterOuterAlt(localContext, 1); + { + this.state = 6843; + this.columnName(); + this.state = 6848; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 986, this.context); + while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER) { + if (alternative === 1) { + { + { + this.state = 6844; + this.match(MySqlParser.COMMA); + this.state = 6845; + this.columnName(); + } + } + } + this.state = 6850; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 986, this.context); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + columnName() { + let localContext = new ColumnNameContext(this.context, this.state); + this.enterRule(localContext, 658, MySqlParser.RULE_columnName); + try { + this.state = 6866; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 991, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 6851; + this.uid(); + this.state = 6856; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 988, this.context)) { + case 1: + { + this.state = 6852; + this.dottedId(); + this.state = 6854; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 987, this.context)) { + case 1: + { + this.state = 6853; + this.dottedId(); + } + break; + } + } + break; + } + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 6859; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 989, this.context)) { + case 1: + { + this.state = 6858; + this.matchWildcard(); + } + break; + } + this.state = 6861; + this.dottedId(); + this.state = 6863; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 990, this.context)) { + case 1: + { + this.state = 6862; + this.dottedId(); + } + break; + } + } + break; + case 3: + this.enterOuterAlt(localContext, 3); + { + this.state = 6865; + if (!(this.shouldMatchEmpty())) { + throw this.createFailedPredicateException("this.shouldMatchEmpty()"); + } + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + tablespaceNameCreate() { + let localContext = new TablespaceNameCreateContext(this.context, this.state); + this.enterRule(localContext, 660, MySqlParser.RULE_tablespaceNameCreate); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6868; + this.uid(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + tablespaceName() { + let localContext = new TablespaceNameContext(this.context, this.state); + this.enterRule(localContext, 662, MySqlParser.RULE_tablespaceName); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6870; + this.uid(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + partitionNameCreate() { + let localContext = new PartitionNameCreateContext(this.context, this.state); + this.enterRule(localContext, 664, MySqlParser.RULE_partitionNameCreate); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6872; + this.uid(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + partitionNames() { + let localContext = new PartitionNamesContext(this.context, this.state); + this.enterRule(localContext, 666, MySqlParser.RULE_partitionNames); + try { + let alternative; + this.enterOuterAlt(localContext, 1); + { + this.state = 6874; + this.partitionName(); + this.state = 6879; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 992, this.context); + while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER) { + if (alternative === 1) { + { + { + this.state = 6875; + this.match(MySqlParser.COMMA); + this.state = 6876; + this.partitionName(); + } + } + } + this.state = 6881; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 992, this.context); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + partitionName() { + let localContext = new PartitionNameContext(this.context, this.state); + this.enterRule(localContext, 668, MySqlParser.RULE_partitionName); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6882; + this.uid(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + indexColumnName() { + let localContext = new IndexColumnNameContext(this.context, this.state); + this.enterRule(localContext, 670, MySqlParser.RULE_indexColumnName); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6892; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 994, this.context)) { + case 1: + { + this.state = 6884; + this.uid(); + this.state = 6889; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 993, this.context)) { + case 1: + { + this.state = 6885; + this.match(MySqlParser.LR_BRACKET); + this.state = 6886; + this.decimalLiteral(); + this.state = 6887; + this.match(MySqlParser.RR_BRACKET); + } + break; + } + } + break; + case 2: + { + this.state = 6891; + this.expression(0); + } + break; + } + this.state = 6895; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 995, this.context)) { + case 1: + { + this.state = 6894; + localContext._sortType = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 14 || _la === 45)) { + localContext._sortType = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + break; + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + userHostPort() { + let localContext = new UserHostPortContext(this.context, this.state); + this.enterRule(localContext, 672, MySqlParser.RULE_userHostPort); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6897; + this.userAtHost(); + this.state = 6898; + this.match(MySqlParser.COLON_SYMB); + this.state = 6899; + this.decimalLiteral(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + userAtHost() { + let localContext = new UserAtHostContext(this.context, this.state); + this.enterRule(localContext, 674, MySqlParser.RULE_userAtHost); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6901; + this.simpleUserName(); + this.state = 6902; + this.match(MySqlParser.HOST_IP_ADDRESS); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + simpleUserName() { + let localContext = new SimpleUserNameContext(this.context, this.state); + this.enterRule(localContext, 676, MySqlParser.RULE_simpleUserName); + try { + this.state = 6908; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 996, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 6904; + this.match(MySqlParser.STRING_LITERAL); + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 6905; + this.match(MySqlParser.ID); + } + break; + case 3: + this.enterOuterAlt(localContext, 3); + { + this.state = 6906; + this.match(MySqlParser.KW_ADMIN); + } + break; + case 4: + this.enterOuterAlt(localContext, 4); + { + this.state = 6907; + this.keywordsCanBeId(); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + hostName() { + let localContext = new HostNameContext(this.context, this.state); + this.enterRule(localContext, 678, MySqlParser.RULE_hostName); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6910; + _la = this.tokenStream.LA(1); + if (!(((((_la - 870)) & ~0x1F) === 0 && ((1 << (_la - 870)) & 6291457) !== 0))) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + userName() { + let localContext = new UserNameContext(this.context, this.state); + this.enterRule(localContext, 680, MySqlParser.RULE_userName); + let _la; + try { + this.state = 6917; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 998, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 6912; + this.simpleUserName(); + this.state = 6914; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (((((_la - 870)) & ~0x1F) === 0 && ((1 << (_la - 870)) & 6291457) !== 0)) { + { + this.state = 6913; + this.hostName(); + } + } + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 6916; + this.currentUserExpression(); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + mysqlVariable() { + let localContext = new MysqlVariableContext(this.context, this.state); + this.enterRule(localContext, 682, MySqlParser.RULE_mysqlVariable); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6919; + _la = this.tokenStream.LA(1); + if (!(_la === 892 || _la === 893)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + charsetName() { + let localContext = new CharsetNameContext(this.context, this.state); + this.enterRule(localContext, 684, MySqlParser.RULE_charsetName); + try { + this.state = 6925; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 999, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 6921; + this.match(MySqlParser.KW_BINARY); + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 6922; + this.charsetNameBase(); + } + break; + case 3: + this.enterOuterAlt(localContext, 3); + { + this.state = 6923; + this.match(MySqlParser.STRING_LITERAL); + } + break; + case 4: + this.enterOuterAlt(localContext, 4); + { + this.state = 6924; + this.match(MySqlParser.CHARSET_REVERSE_QOUTE_STRING); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + collationName() { + let localContext = new CollationNameContext(this.context, this.state); + this.enterRule(localContext, 686, MySqlParser.RULE_collationName); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6927; + this.uid(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + engineName() { + let localContext = new EngineNameContext(this.context, this.state); + this.enterRule(localContext, 688, MySqlParser.RULE_engineName); + try { + this.state = 6932; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_CONNECT: + case MySqlParser.KW_ARCHIVE: + case MySqlParser.KW_BLACKHOLE: + case MySqlParser.KW_CSV: + case MySqlParser.KW_FEDERATED: + case MySqlParser.KW_INNODB: + case MySqlParser.KW_MEMORY: + case MySqlParser.KW_MRG_MYISAM: + case MySqlParser.KW_MYISAM: + case MySqlParser.KW_NDB: + case MySqlParser.KW_NDBCLUSTER: + case MySqlParser.KW_PERFORMANCE_SCHEMA: + case MySqlParser.KW_TOKUDB: + this.enterOuterAlt(localContext, 1); + { + this.state = 6929; + this.engineNameBase(); + } + break; + case MySqlParser.ID: + this.enterOuterAlt(localContext, 2); + { + this.state = 6930; + this.match(MySqlParser.ID); + } + break; + case MySqlParser.STRING_LITERAL: + this.enterOuterAlt(localContext, 3); + { + this.state = 6931; + this.match(MySqlParser.STRING_LITERAL); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + engineNameBase() { + let localContext = new EngineNameBaseContext(this.context, this.state); + this.enterRule(localContext, 690, MySqlParser.RULE_engineNameBase); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6934; + _la = this.tokenStream.LA(1); + if (!(_la === 348 || ((((_la - 797)) & ~0x1F) === 0 && ((1 << (_la - 797)) & 4095) !== 0))) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + uuidSet() { + let localContext = new UuidSetContext(this.context, this.state); + this.enterRule(localContext, 692, MySqlParser.RULE_uuidSet); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6936; + this.decimalLiteral(); + this.state = 6937; + this.match(MySqlParser.MINUS); + this.state = 6938; + this.decimalLiteral(); + this.state = 6939; + this.match(MySqlParser.MINUS); + this.state = 6940; + this.decimalLiteral(); + this.state = 6941; + this.match(MySqlParser.MINUS); + this.state = 6942; + this.decimalLiteral(); + this.state = 6943; + this.match(MySqlParser.MINUS); + this.state = 6944; + this.decimalLiteral(); + this.state = 6950; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + do { + { + { + this.state = 6945; + this.match(MySqlParser.COLON_SYMB); + this.state = 6946; + this.decimalLiteral(); + this.state = 6947; + this.match(MySqlParser.MINUS); + this.state = 6948; + this.decimalLiteral(); + } + } + this.state = 6952; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } while (_la === 878); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + xid() { + let localContext = new XidContext(this.context, this.state); + this.enterRule(localContext, 694, MySqlParser.RULE_xid); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6954; + localContext._globalTableUid = this.xuidStringId(); + this.state = 6961; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 868) { + { + this.state = 6955; + this.match(MySqlParser.COMMA); + this.state = 6956; + localContext._qualifier = this.xuidStringId(); + this.state = 6959; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 868) { + { + this.state = 6957; + this.match(MySqlParser.COMMA); + this.state = 6958; + localContext._idFormat = this.decimalLiteral(); + } + } + } + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + xuidStringId() { + let localContext = new XuidStringIdContext(this.context, this.state); + this.enterRule(localContext, 696, MySqlParser.RULE_xuidStringId); + let _la; + try { + this.state = 6970; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.STRING_LITERAL: + this.enterOuterAlt(localContext, 1); + { + this.state = 6963; + this.match(MySqlParser.STRING_LITERAL); + } + break; + case MySqlParser.BIT_STRING: + this.enterOuterAlt(localContext, 2); + { + this.state = 6964; + this.match(MySqlParser.BIT_STRING); + } + break; + case MySqlParser.HEXADECIMAL_LITERAL: + this.enterOuterAlt(localContext, 3); + { + this.state = 6966; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + do { + { + { + this.state = 6965; + this.match(MySqlParser.HEXADECIMAL_LITERAL); + } + } + this.state = 6968; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } while (_la === 884); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + fullId() { + let localContext = new FullIdContext(this.context, this.state); + this.enterRule(localContext, 698, MySqlParser.RULE_fullId); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6972; + this.uid(); + this.state = 6974; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1006, this.context)) { + case 1: + { + this.state = 6973; + this.dottedId(); + } + break; + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + uidList() { + let localContext = new UidListContext(this.context, this.state); + this.enterRule(localContext, 700, MySqlParser.RULE_uidList); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 6976; + this.uid(); + this.state = 6981; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 6977; + this.match(MySqlParser.COMMA); + this.state = 6978; + this.uid(); + } + } + this.state = 6983; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + uid() { + let localContext = new UidContext(this.context, this.state); + this.enterRule(localContext, 702, MySqlParser.RULE_uid); + try { + this.state = 6987; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_ARRAY: + case MySqlParser.KW_ATTRIBUTE: + case MySqlParser.KW_BUCKETS: + case MySqlParser.KW_CONDITION: + case MySqlParser.KW_CURRENT: + case MySqlParser.KW_CURRENT_USER: + case MySqlParser.KW_DATABASE: + case MySqlParser.KW_DEFAULT: + case MySqlParser.KW_DIAGNOSTICS: + case MySqlParser.KW_EMPTY: + case MySqlParser.KW_ENFORCED: + case MySqlParser.KW_EXCEPT: + case MySqlParser.KW_GROUP: + case MySqlParser.KW_IF: + case MySqlParser.KW_INSERT: + case MySqlParser.KW_LATERAL: + case MySqlParser.KW_LEFT: + case MySqlParser.KW_NUMBER: + case MySqlParser.KW_OPTIONAL: + case MySqlParser.KW_ORDER: + case MySqlParser.KW_PRIMARY: + case MySqlParser.KW_REPEAT: + case MySqlParser.KW_REPLACE: + case MySqlParser.KW_RIGHT: + case MySqlParser.KW_SCHEMA: + case MySqlParser.KW_SKIP_QUERY_REWRITE: + case MySqlParser.KW_STACKED: + case MySqlParser.KW_DATE: + case MySqlParser.KW_TIME: + case MySqlParser.KW_TIMESTAMP: + case MySqlParser.KW_DATETIME: + case MySqlParser.KW_YEAR: + case MySqlParser.KW_BINARY: + case MySqlParser.KW_TEXT: + case MySqlParser.KW_ENUM: + case MySqlParser.KW_SERIAL: + case MySqlParser.KW_JSON_TABLE: + case MySqlParser.KW_JSON_VALUE: + case MySqlParser.KW_NESTED: + case MySqlParser.KW_ORDINALITY: + case MySqlParser.KW_PATH: + case MySqlParser.KW_AVG: + case MySqlParser.KW_BIT_AND: + case MySqlParser.KW_BIT_OR: + case MySqlParser.KW_BIT_XOR: + case MySqlParser.KW_COUNT: + case MySqlParser.KW_CUME_DIST: + case MySqlParser.KW_DENSE_RANK: + case MySqlParser.KW_FIRST_VALUE: + case MySqlParser.KW_GROUP_CONCAT: + case MySqlParser.KW_LAG: + case MySqlParser.KW_LAST_VALUE: + case MySqlParser.KW_LEAD: + case MySqlParser.KW_MAX: + case MySqlParser.KW_MIN: + case MySqlParser.KW_NTILE: + case MySqlParser.KW_NTH_VALUE: + case MySqlParser.KW_PERCENT_RANK: + case MySqlParser.KW_RANK: + case MySqlParser.KW_ROW_NUMBER: + case MySqlParser.KW_STD: + case MySqlParser.KW_STDDEV: + case MySqlParser.KW_STDDEV_POP: + case MySqlParser.KW_STDDEV_SAMP: + case MySqlParser.KW_SUM: + case MySqlParser.KW_VAR_POP: + case MySqlParser.KW_VAR_SAMP: + case MySqlParser.KW_VARIANCE: + case MySqlParser.KW_CURRENT_DATE: + case MySqlParser.KW_CURRENT_TIME: + case MySqlParser.KW_CURRENT_TIMESTAMP: + case MySqlParser.KW_LOCALTIME: + case MySqlParser.KW_CURDATE: + case MySqlParser.KW_CURTIME: + case MySqlParser.KW_DATE_ADD: + case MySqlParser.KW_DATE_SUB: + case MySqlParser.KW_LOCALTIMESTAMP: + case MySqlParser.KW_NOW: + case MySqlParser.KW_POSITION: + case MySqlParser.KW_SUBSTR: + case MySqlParser.KW_SUBSTRING: + case MySqlParser.KW_SYSDATE: + case MySqlParser.KW_TRIM: + case MySqlParser.KW_UTC_DATE: + case MySqlParser.KW_UTC_TIME: + case MySqlParser.KW_UTC_TIMESTAMP: + case MySqlParser.KW_ACCOUNT: + case MySqlParser.KW_ACTION: + case MySqlParser.KW_AFTER: + case MySqlParser.KW_AGGREGATE: + case MySqlParser.KW_ALGORITHM: + case MySqlParser.KW_ANY: + case MySqlParser.KW_AT: + case MySqlParser.KW_AUTHORS: + case MySqlParser.KW_AUTOCOMMIT: + case MySqlParser.KW_AUTOEXTEND_SIZE: + case MySqlParser.KW_AUTO_INCREMENT: + case MySqlParser.KW_AVG_ROW_LENGTH: + case MySqlParser.KW_BEGIN: + case MySqlParser.KW_BINLOG: + case MySqlParser.KW_BIT: + case MySqlParser.KW_BLOCK: + case MySqlParser.KW_BOOL: + case MySqlParser.KW_BOOLEAN: + case MySqlParser.KW_BTREE: + case MySqlParser.KW_CACHE: + case MySqlParser.KW_CASCADED: + case MySqlParser.KW_CHAIN: + case MySqlParser.KW_CHANGED: + case MySqlParser.KW_CHANNEL: + case MySqlParser.KW_CHECKSUM: + case MySqlParser.KW_CIPHER: + case MySqlParser.KW_CLASS_ORIGIN: + case MySqlParser.KW_CLIENT: + case MySqlParser.KW_CLOSE: + case MySqlParser.KW_COALESCE: + case MySqlParser.KW_CODE: + case MySqlParser.KW_COLUMNS: + case MySqlParser.KW_COLUMN_FORMAT: + case MySqlParser.KW_COLUMN_NAME: + case MySqlParser.KW_COMMENT: + case MySqlParser.KW_COMMIT: + case MySqlParser.KW_COMPACT: + case MySqlParser.KW_COMPLETION: + case MySqlParser.KW_COMPRESSED: + case MySqlParser.KW_COMPRESSION: + case MySqlParser.KW_CONCURRENT: + case MySqlParser.KW_CONNECT: + case MySqlParser.KW_CONNECTION: + case MySqlParser.KW_CONSISTENT: + case MySqlParser.KW_CONSTRAINT_CATALOG: + case MySqlParser.KW_CONSTRAINT_SCHEMA: + case MySqlParser.KW_CONSTRAINT_NAME: + case MySqlParser.KW_CONTAINS: + case MySqlParser.KW_CONTEXT: + case MySqlParser.KW_CONTRIBUTORS: + case MySqlParser.KW_COPY: + case MySqlParser.KW_CPU: + case MySqlParser.KW_CURSOR_NAME: + case MySqlParser.KW_DATA: + case MySqlParser.KW_DATAFILE: + case MySqlParser.KW_DEALLOCATE: + case MySqlParser.KW_DEFAULT_AUTH: + case MySqlParser.KW_DEFINER: + case MySqlParser.KW_DELAY_KEY_WRITE: + case MySqlParser.KW_DES_KEY_FILE: + case MySqlParser.KW_DIRECTORY: + case MySqlParser.KW_DISABLE: + case MySqlParser.KW_DISCARD: + case MySqlParser.KW_DISK: + case MySqlParser.KW_DO: + case MySqlParser.KW_DUMPFILE: + case MySqlParser.KW_DUPLICATE: + case MySqlParser.KW_DYNAMIC: + case MySqlParser.KW_ENABLE: + case MySqlParser.KW_ENCRYPTION: + case MySqlParser.KW_END: + case MySqlParser.KW_ENDS: + case MySqlParser.KW_ENGINE: + case MySqlParser.KW_ENGINES: + case MySqlParser.KW_ERROR: + case MySqlParser.KW_ERRORS: + case MySqlParser.KW_ESCAPE: + case MySqlParser.KW_EVENT: + case MySqlParser.KW_EVENTS: + case MySqlParser.KW_EVERY: + case MySqlParser.KW_EXCHANGE: + case MySqlParser.KW_EXCLUSIVE: + case MySqlParser.KW_EXPIRE: + case MySqlParser.KW_EXPORT: + case MySqlParser.KW_EXTENDED: + case MySqlParser.KW_EXTENT_SIZE: + case MySqlParser.KW_FAILED_LOGIN_ATTEMPTS: + case MySqlParser.KW_FAST: + case MySqlParser.KW_FAULTS: + case MySqlParser.KW_FIELDS: + case MySqlParser.KW_FILE_BLOCK_SIZE: + case MySqlParser.KW_FILTER: + case MySqlParser.KW_FIRST: + case MySqlParser.KW_FIXED: + case MySqlParser.KW_FLUSH: + case MySqlParser.KW_FOLLOWS: + case MySqlParser.KW_FOUND: + case MySqlParser.KW_FULL: + case MySqlParser.KW_FUNCTION: + case MySqlParser.KW_GENERAL: + case MySqlParser.KW_GLOBAL: + case MySqlParser.KW_GRANTS: + case MySqlParser.KW_GROUP_REPLICATION: + case MySqlParser.KW_HANDLER: + case MySqlParser.KW_HASH: + case MySqlParser.KW_HELP: + case MySqlParser.KW_HISTORY: + case MySqlParser.KW_HOST: + case MySqlParser.KW_HOSTS: + case MySqlParser.KW_IDENTIFIED: + case MySqlParser.KW_IGNORE_SERVER_IDS: + case MySqlParser.KW_IMPORT: + case MySqlParser.KW_INDEXES: + case MySqlParser.KW_INITIAL_SIZE: + case MySqlParser.KW_INPLACE: + case MySqlParser.KW_INSERT_METHOD: + case MySqlParser.KW_INSTALL: + case MySqlParser.KW_INSTANCE: + case MySqlParser.KW_INSTANT: + case MySqlParser.KW_INVISIBLE: + case MySqlParser.KW_INVOKER: + case MySqlParser.KW_IO: + case MySqlParser.KW_IO_THREAD: + case MySqlParser.KW_IPC: + case MySqlParser.KW_ISOLATION: + case MySqlParser.KW_ISSUER: + case MySqlParser.KW_JSON: + case MySqlParser.KW_KEY_BLOCK_SIZE: + case MySqlParser.KW_LANGUAGE: + case MySqlParser.KW_LAST: + case MySqlParser.KW_LEAVES: + case MySqlParser.KW_LESS: + case MySqlParser.KW_LEVEL: + case MySqlParser.KW_LIST: + case MySqlParser.KW_LOCAL: + case MySqlParser.KW_LOGFILE: + case MySqlParser.KW_LOGS: + case MySqlParser.KW_MASTER: + case MySqlParser.KW_MASTER_AUTO_POSITION: + case MySqlParser.KW_MASTER_CONNECT_RETRY: + case MySqlParser.KW_MASTER_DELAY: + case MySqlParser.KW_MASTER_HEARTBEAT_PERIOD: + case MySqlParser.KW_MASTER_HOST: + case MySqlParser.KW_MASTER_LOG_FILE: + case MySqlParser.KW_MASTER_LOG_POS: + case MySqlParser.KW_MASTER_PASSWORD: + case MySqlParser.KW_MASTER_PORT: + case MySqlParser.KW_MASTER_RETRY_COUNT: + case MySqlParser.KW_MASTER_SSL: + case MySqlParser.KW_MASTER_SSL_CA: + case MySqlParser.KW_MASTER_SSL_CAPATH: + case MySqlParser.KW_MASTER_SSL_CERT: + case MySqlParser.KW_MASTER_SSL_CIPHER: + case MySqlParser.KW_MASTER_SSL_CRL: + case MySqlParser.KW_MASTER_SSL_CRLPATH: + case MySqlParser.KW_MASTER_SSL_KEY: + case MySqlParser.KW_MASTER_TLS_VERSION: + case MySqlParser.KW_MASTER_USER: + case MySqlParser.KW_MAX_CONNECTIONS_PER_HOUR: + case MySqlParser.KW_MAX_QUERIES_PER_HOUR: + case MySqlParser.KW_MAX_ROWS: + case MySqlParser.KW_MAX_SIZE: + case MySqlParser.KW_MAX_UPDATES_PER_HOUR: + case MySqlParser.KW_MAX_USER_CONNECTIONS: + case MySqlParser.KW_MEDIUM: + case MySqlParser.KW_MEMBER: + case MySqlParser.KW_MERGE: + case MySqlParser.KW_MESSAGE_TEXT: + case MySqlParser.KW_MID: + case MySqlParser.KW_MIGRATE: + case MySqlParser.KW_MIN_ROWS: + case MySqlParser.KW_MODE: + case MySqlParser.KW_MODIFY: + case MySqlParser.KW_MUTEX: + case MySqlParser.KW_MYSQL: + case MySqlParser.KW_MYSQL_ERRNO: + case MySqlParser.KW_NAME: + case MySqlParser.KW_NAMES: + case MySqlParser.KW_NCHAR: + case MySqlParser.KW_NEVER: + case MySqlParser.KW_NEXT: + case MySqlParser.KW_NO: + case MySqlParser.KW_NOWAIT: + case MySqlParser.KW_NODEGROUP: + case MySqlParser.KW_NONE: + case MySqlParser.KW_ODBC: + case MySqlParser.KW_OFFLINE: + case MySqlParser.KW_OFFSET: + case MySqlParser.KW_OF: + case MySqlParser.KW_OLD_PASSWORD: + case MySqlParser.KW_ONE: + case MySqlParser.KW_ONLINE: + case MySqlParser.KW_ONLY: + case MySqlParser.KW_OPEN: + case MySqlParser.KW_OPTIMIZER_COSTS: + case MySqlParser.KW_OPTIONS: + case MySqlParser.KW_OWNER: + case MySqlParser.KW_PACK_KEYS: + case MySqlParser.KW_PAGE: + case MySqlParser.KW_PAGE_CHECKSUM: + case MySqlParser.KW_PARSER: + case MySqlParser.KW_PARTIAL: + case MySqlParser.KW_PARTITIONING: + case MySqlParser.KW_PARTITIONS: + case MySqlParser.KW_PASSWORD: + case MySqlParser.KW_PASSWORD_LOCK_TIME: + case MySqlParser.KW_PHASE: + case MySqlParser.KW_PLUGIN: + case MySqlParser.KW_PLUGIN_DIR: + case MySqlParser.KW_PLUGINS: + case MySqlParser.KW_PORT: + case MySqlParser.KW_PRECEDES: + case MySqlParser.KW_PREPARE: + case MySqlParser.KW_PRESERVE: + case MySqlParser.KW_PREV: + case MySqlParser.KW_PROCESSLIST: + case MySqlParser.KW_PROFILE: + case MySqlParser.KW_PROFILES: + case MySqlParser.KW_PROXY: + case MySqlParser.KW_QUERY: + case MySqlParser.KW_QUICK: + case MySqlParser.KW_REBUILD: + case MySqlParser.KW_RECOVER: + case MySqlParser.KW_RECURSIVE: + case MySqlParser.KW_REDO_BUFFER_SIZE: + case MySqlParser.KW_REDUNDANT: + case MySqlParser.KW_RELAY: + case MySqlParser.KW_RELAY_LOG_FILE: + case MySqlParser.KW_RELAY_LOG_POS: + case MySqlParser.KW_RELAYLOG: + case MySqlParser.KW_REMOVE: + case MySqlParser.KW_REORGANIZE: + case MySqlParser.KW_REPAIR: + case MySqlParser.KW_REPLICATE_DO_DB: + case MySqlParser.KW_REPLICATE_DO_TABLE: + case MySqlParser.KW_REPLICATE_IGNORE_DB: + case MySqlParser.KW_REPLICATE_IGNORE_TABLE: + case MySqlParser.KW_REPLICATE_REWRITE_DB: + case MySqlParser.KW_REPLICATE_WILD_DO_TABLE: + case MySqlParser.KW_REPLICATE_WILD_IGNORE_TABLE: + case MySqlParser.KW_REPLICATION: + case MySqlParser.KW_RESET: + case MySqlParser.KW_RESUME: + case MySqlParser.KW_RETURNED_SQLSTATE: + case MySqlParser.KW_RETURNS: + case MySqlParser.KW_REUSE: + case MySqlParser.KW_ROLE: + case MySqlParser.KW_ROLLBACK: + case MySqlParser.KW_ROLLUP: + case MySqlParser.KW_ROTATE: + case MySqlParser.KW_ROW: + case MySqlParser.KW_ROWS: + case MySqlParser.KW_ROW_FORMAT: + case MySqlParser.KW_SAVEPOINT: + case MySqlParser.KW_SCHEDULE: + case MySqlParser.KW_SECURITY: + case MySqlParser.KW_SERVER: + case MySqlParser.KW_SESSION: + case MySqlParser.KW_SHARE: + case MySqlParser.KW_SHARED: + case MySqlParser.KW_SIGNED: + case MySqlParser.KW_SIMPLE: + case MySqlParser.KW_SLAVE: + case MySqlParser.KW_SLOW: + case MySqlParser.KW_SNAPSHOT: + case MySqlParser.KW_SOCKET: + case MySqlParser.KW_SOME: + case MySqlParser.KW_SONAME: + case MySqlParser.KW_SOUNDS: + case MySqlParser.KW_SOURCE: + case MySqlParser.KW_SQL_AFTER_GTIDS: + case MySqlParser.KW_SQL_AFTER_MTS_GAPS: + case MySqlParser.KW_SQL_BEFORE_GTIDS: + case MySqlParser.KW_SQL_BUFFER_RESULT: + case MySqlParser.KW_SQL_CACHE: + case MySqlParser.KW_SQL_NO_CACHE: + case MySqlParser.KW_SQL_THREAD: + case MySqlParser.KW_START: + case MySqlParser.KW_STARTS: + case MySqlParser.KW_STATS_AUTO_RECALC: + case MySqlParser.KW_STATS_PERSISTENT: + case MySqlParser.KW_STATS_SAMPLE_PAGES: + case MySqlParser.KW_STATUS: + case MySqlParser.KW_STOP: + case MySqlParser.KW_STORAGE: + case MySqlParser.KW_STRING: + case MySqlParser.KW_SUBCLASS_ORIGIN: + case MySqlParser.KW_SUBJECT: + case MySqlParser.KW_SUBPARTITION: + case MySqlParser.KW_SUBPARTITIONS: + case MySqlParser.KW_SUSPEND: + case MySqlParser.KW_SWAPS: + case MySqlParser.KW_SWITCHES: + case MySqlParser.KW_TABLE_NAME: + case MySqlParser.KW_TABLESPACE: + case MySqlParser.KW_TABLE_TYPE: + case MySqlParser.KW_TEMPORARY: + case MySqlParser.KW_TEMPTABLE: + case MySqlParser.KW_THAN: + case MySqlParser.KW_TRADITIONAL: + case MySqlParser.KW_TRANSACTION: + case MySqlParser.KW_TRANSACTIONAL: + case MySqlParser.KW_TRIGGERS: + case MySqlParser.KW_TRUNCATE: + case MySqlParser.KW_UNBOUNDED: + case MySqlParser.KW_UNDEFINED: + case MySqlParser.KW_UNDOFILE: + case MySqlParser.KW_UNDO_BUFFER_SIZE: + case MySqlParser.KW_UNINSTALL: + case MySqlParser.KW_UNKNOWN: + case MySqlParser.KW_UNTIL: + case MySqlParser.KW_UPGRADE: + case MySqlParser.KW_USER: + case MySqlParser.KW_USE_FRM: + case MySqlParser.KW_USER_RESOURCES: + case MySqlParser.KW_VALIDATION: + case MySqlParser.KW_VALUE: + case MySqlParser.KW_VARIABLES: + case MySqlParser.KW_VIEW: + case MySqlParser.KW_VIRTUAL: + case MySqlParser.KW_VISIBLE: + case MySqlParser.KW_WAIT: + case MySqlParser.KW_WARNINGS: + case MySqlParser.KW_WITHOUT: + case MySqlParser.KW_WORK: + case MySqlParser.KW_WRAPPER: + case MySqlParser.KW_X509: + case MySqlParser.KW_XA: + case MySqlParser.KW_XML: + case MySqlParser.KW_QUARTER: + case MySqlParser.KW_MONTH: + case MySqlParser.KW_DAY: + case MySqlParser.KW_HOUR: + case MySqlParser.KW_MINUTE: + case MySqlParser.KW_WEEK: + case MySqlParser.KW_SECOND: + case MySqlParser.KW_MICROSECOND: + case MySqlParser.KW_ADMIN: + case MySqlParser.KW_AUDIT_ABORT_EXEMPT: + case MySqlParser.KW_AUDIT_ADMIN: + case MySqlParser.KW_AUTHENTICATION_POLICY_ADMIN: + case MySqlParser.KW_BACKUP_ADMIN: + case MySqlParser.KW_BINLOG_ADMIN: + case MySqlParser.KW_BINLOG_ENCRYPTION_ADMIN: + case MySqlParser.KW_CLONE_ADMIN: + case MySqlParser.KW_CONNECTION_ADMIN: + case MySqlParser.KW_ENCRYPTION_KEY_ADMIN: + case MySqlParser.KW_EXECUTE: + case MySqlParser.KW_FILE: + case MySqlParser.KW_FIREWALL_ADMIN: + case MySqlParser.KW_FIREWALL_EXEMPT: + case MySqlParser.KW_FIREWALL_USER: + case MySqlParser.KW_GROUP_REPLICATION_ADMIN: + case MySqlParser.KW_INNODB_REDO_LOG_ARCHIVE: + case MySqlParser.KW_INVOKE: + case MySqlParser.KW_LAMBDA: + case MySqlParser.KW_NDB_STORED_USER: + case MySqlParser.KW_PASSWORDLESS_USER_ADMIN: + case MySqlParser.KW_PERSIST_RO_VARIABLES_ADMIN: + case MySqlParser.KW_PRIVILEGES: + case MySqlParser.KW_PROCESS: + case MySqlParser.KW_RELOAD: + case MySqlParser.KW_REPLICATION_APPLIER: + case MySqlParser.KW_REPLICATION_SLAVE_ADMIN: + case MySqlParser.KW_RESOURCE_GROUP_ADMIN: + case MySqlParser.KW_RESOURCE_GROUP_USER: + case MySqlParser.KW_ROLE_ADMIN: + case MySqlParser.KW_ROUTINE: + case MySqlParser.KW_S3: + case MySqlParser.KW_SESSION_VARIABLES_ADMIN: + case MySqlParser.KW_SET_USER_ID: + case MySqlParser.KW_SHOW_ROUTINE: + case MySqlParser.KW_SHUTDOWN: + case MySqlParser.KW_SUPER: + case MySqlParser.KW_SYSTEM_VARIABLES_ADMIN: + case MySqlParser.KW_TABLES: + case MySqlParser.KW_TABLE_ENCRYPTION_ADMIN: + case MySqlParser.KW_VERSION_TOKEN_ADMIN: + case MySqlParser.KW_XA_RECOVER_ADMIN: + case MySqlParser.KW_ARMSCII8: + case MySqlParser.KW_ASCII: + case MySqlParser.KW_BIG5: + case MySqlParser.KW_CP1250: + case MySqlParser.KW_CP1251: + case MySqlParser.KW_CP1256: + case MySqlParser.KW_CP1257: + case MySqlParser.KW_CP850: + case MySqlParser.KW_CP852: + case MySqlParser.KW_CP866: + case MySqlParser.KW_CP932: + case MySqlParser.KW_DEC8: + case MySqlParser.KW_EUCJPMS: + case MySqlParser.KW_EUCKR: + case MySqlParser.KW_GB18030: + case MySqlParser.KW_GB2312: + case MySqlParser.KW_GBK: + case MySqlParser.KW_GEOSTD8: + case MySqlParser.KW_GREEK: + case MySqlParser.KW_HEBREW: + case MySqlParser.KW_HP8: + case MySqlParser.KW_KEYBCS2: + case MySqlParser.KW_KOI8R: + case MySqlParser.KW_KOI8U: + case MySqlParser.KW_LATIN1: + case MySqlParser.KW_LATIN2: + case MySqlParser.KW_LATIN5: + case MySqlParser.KW_LATIN7: + case MySqlParser.KW_MACCE: + case MySqlParser.KW_MACROMAN: + case MySqlParser.KW_SJIS: + case MySqlParser.KW_SWE7: + case MySqlParser.KW_TIS620: + case MySqlParser.KW_UCS2: + case MySqlParser.KW_UJIS: + case MySqlParser.KW_UTF16: + case MySqlParser.KW_UTF16LE: + case MySqlParser.KW_UTF32: + case MySqlParser.KW_UTF8: + case MySqlParser.KW_UTF8MB3: + case MySqlParser.KW_UTF8MB4: + case MySqlParser.KW_ARCHIVE: + case MySqlParser.KW_BLACKHOLE: + case MySqlParser.KW_CSV: + case MySqlParser.KW_FEDERATED: + case MySqlParser.KW_INNODB: + case MySqlParser.KW_MEMORY: + case MySqlParser.KW_MRG_MYISAM: + case MySqlParser.KW_MYISAM: + case MySqlParser.KW_NDB: + case MySqlParser.KW_NDBCLUSTER: + case MySqlParser.KW_PERFORMANCE_SCHEMA: + case MySqlParser.KW_TOKUDB: + case MySqlParser.KW_REPEATABLE: + case MySqlParser.KW_COMMITTED: + case MySqlParser.KW_UNCOMMITTED: + case MySqlParser.KW_SERIALIZABLE: + case MySqlParser.KW_GEOMETRYCOLLECTION: + case MySqlParser.KW_LINESTRING: + case MySqlParser.KW_MULTILINESTRING: + case MySqlParser.KW_MULTIPOINT: + case MySqlParser.KW_MULTIPOLYGON: + case MySqlParser.KW_POINT: + case MySqlParser.KW_POLYGON: + case MySqlParser.KW_CATALOG_NAME: + case MySqlParser.KW_CHARSET: + case MySqlParser.KW_COLLATION: + case MySqlParser.KW_ENGINE_ATTRIBUTE: + case MySqlParser.KW_FORMAT: + case MySqlParser.KW_GET_FORMAT: + case MySqlParser.KW_RANDOM: + case MySqlParser.KW_REVERSE: + case MySqlParser.KW_ROW_COUNT: + case MySqlParser.KW_SCHEMA_NAME: + case MySqlParser.KW_SECONDARY_ENGINE_ATTRIBUTE: + case MySqlParser.KW_SRID: + case MySqlParser.KW_SYSTEM_USER: + case MySqlParser.KW_TP_CONNECTION_ADMIN: + case MySqlParser.KW_WEIGHT_STRING: + case MySqlParser.MOD: + case MySqlParser.ID: + this.enterOuterAlt(localContext, 1); + { + this.state = 6984; + this.simpleId(); + } + break; + case MySqlParser.CHARSET_REVERSE_QOUTE_STRING: + this.enterOuterAlt(localContext, 2); + { + this.state = 6985; + this.match(MySqlParser.CHARSET_REVERSE_QOUTE_STRING); + } + break; + case MySqlParser.STRING_LITERAL: + this.enterOuterAlt(localContext, 3); + { + this.state = 6986; + this.match(MySqlParser.STRING_LITERAL); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + simpleId() { + let localContext = new SimpleIdContext(this.context, this.state); + this.enterRule(localContext, 704, MySqlParser.RULE_simpleId); + try { + this.state = 6998; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1009, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 6989; + this.match(MySqlParser.ID); + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 6990; + this.charsetNameBase(); + } + break; + case 3: + this.enterOuterAlt(localContext, 3); + { + this.state = 6991; + this.transactionLevelBase(); + } + break; + case 4: + this.enterOuterAlt(localContext, 4); + { + this.state = 6992; + this.engineNameBase(); + } + break; + case 5: + this.enterOuterAlt(localContext, 5); + { + this.state = 6993; + this.privilegesBase(); + } + break; + case 6: + this.enterOuterAlt(localContext, 6); + { + this.state = 6994; + this.intervalTypeBase(); + } + break; + case 7: + this.enterOuterAlt(localContext, 7); + { + this.state = 6995; + this.dataTypeBase(); + } + break; + case 8: + this.enterOuterAlt(localContext, 8); + { + this.state = 6996; + this.keywordsCanBeId(); + } + break; + case 9: + this.enterOuterAlt(localContext, 9); + { + this.state = 6997; + this.scalarFunctionName(); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + dottedId() { + let localContext = new DottedIdContext(this.context, this.state); + this.enterRule(localContext, 706, MySqlParser.RULE_dottedId); + try { + this.state = 7004; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1010, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 7000; + this.match(MySqlParser.DOT); + this.state = 7001; + this.match(MySqlParser.ID); + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 7002; + this.match(MySqlParser.DOT); + this.state = 7003; + this.uid(); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + decimalLiteral() { + let localContext = new DecimalLiteralContext(this.context, this.state); + this.enterRule(localContext, 708, MySqlParser.RULE_decimalLiteral); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 7006; + _la = this.tokenStream.LA(1); + if (!(((((_la - 871)) & ~0x1F) === 0 && ((1 << (_la - 871)) & 20495) !== 0))) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + fileSizeLiteral() { + let localContext = new FileSizeLiteralContext(this.context, this.state); + this.enterRule(localContext, 710, MySqlParser.RULE_fileSizeLiteral); + try { + this.state = 7010; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.FILESIZE_LITERAL: + this.enterOuterAlt(localContext, 1); + { + this.state = 7008; + this.match(MySqlParser.FILESIZE_LITERAL); + } + break; + case MySqlParser.ZERO_DECIMAL: + case MySqlParser.ONE_DECIMAL: + case MySqlParser.TWO_DECIMAL: + case MySqlParser.THREE_DECIMAL: + case MySqlParser.DECIMAL_LITERAL: + case MySqlParser.REAL_LITERAL: + this.enterOuterAlt(localContext, 2); + { + this.state = 7009; + this.decimalLiteral(); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + stringLiteral() { + let localContext = new StringLiteralContext(this.context, this.state); + this.enterRule(localContext, 712, MySqlParser.RULE_stringLiteral); + let _la; + try { + let alternative; + this.state = 7035; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1018, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 7017; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.STRING_LITERAL: + case MySqlParser.STRING_CHARSET_NAME: + { + this.state = 7013; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 888) { + { + this.state = 7012; + this.match(MySqlParser.STRING_CHARSET_NAME); + } + } + this.state = 7015; + this.match(MySqlParser.STRING_LITERAL); + } + break; + case MySqlParser.START_NATIONAL_STRING_LITERAL: + { + this.state = 7016; + this.match(MySqlParser.START_NATIONAL_STRING_LITERAL); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + this.state = 7020; + this.errorHandler.sync(this); + alternative = 1; + do { + switch (alternative) { + case 1: + { + { + this.state = 7019; + this.match(MySqlParser.STRING_LITERAL); + } + } + break; + default: + throw new antlr.NoViableAltException(this); + } + this.state = 7022; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 1014, this.context); + } while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER); + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 7029; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.STRING_LITERAL: + case MySqlParser.STRING_CHARSET_NAME: + { + this.state = 7025; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 888) { + { + this.state = 7024; + this.match(MySqlParser.STRING_CHARSET_NAME); + } + } + this.state = 7027; + this.match(MySqlParser.STRING_LITERAL); + } + break; + case MySqlParser.START_NATIONAL_STRING_LITERAL: + { + this.state = 7028; + this.match(MySqlParser.START_NATIONAL_STRING_LITERAL); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + this.state = 7033; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1017, this.context)) { + case 1: + { + this.state = 7031; + this.match(MySqlParser.KW_COLLATE); + this.state = 7032; + this.collationName(); + } + break; + } + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + booleanLiteral() { + let localContext = new BooleanLiteralContext(this.context, this.state); + this.enterRule(localContext, 714, MySqlParser.RULE_booleanLiteral); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 7037; + _la = this.tokenStream.LA(1); + if (!(_la === 63 || _la === 179)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + hexadecimalLiteral() { + let localContext = new HexadecimalLiteralContext(this.context, this.state); + this.enterRule(localContext, 716, MySqlParser.RULE_hexadecimalLiteral); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 7040; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 888) { + { + this.state = 7039; + this.match(MySqlParser.STRING_CHARSET_NAME); + } + } + this.state = 7042; + this.match(MySqlParser.HEXADECIMAL_LITERAL); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + nullNotnull() { + let localContext = new NullNotnullContext(this.context, this.state); + this.enterRule(localContext, 718, MySqlParser.RULE_nullNotnull); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 7045; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 114) { + { + this.state = 7044; + this.match(MySqlParser.KW_NOT); + } + } + this.state = 7047; + _la = this.tokenStream.LA(1); + if (!(_la === 116 || _la === 886)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + constant() { + let localContext = new ConstantContext(this.context, this.state); + this.enterRule(localContext, 720, MySqlParser.RULE_constant); + let _la; + try { + this.state = 7061; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1022, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 7049; + this.stringLiteral(); + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 7050; + this.decimalLiteral(); + } + break; + case 3: + this.enterOuterAlt(localContext, 3); + { + this.state = 7051; + this.match(MySqlParser.MINUS); + this.state = 7052; + this.decimalLiteral(); + } + break; + case 4: + this.enterOuterAlt(localContext, 4); + { + this.state = 7053; + this.hexadecimalLiteral(); + } + break; + case 5: + this.enterOuterAlt(localContext, 5); + { + this.state = 7054; + this.booleanLiteral(); + } + break; + case 6: + this.enterOuterAlt(localContext, 6); + { + this.state = 7055; + this.match(MySqlParser.REAL_LITERAL); + } + break; + case 7: + this.enterOuterAlt(localContext, 7); + { + this.state = 7056; + this.match(MySqlParser.BIT_STRING); + } + break; + case 8: + this.enterOuterAlt(localContext, 8); + { + this.state = 7058; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 114) { + { + this.state = 7057; + this.match(MySqlParser.KW_NOT); + } + } + this.state = 7060; + localContext._nullLiteral = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 116 || _la === 886)) { + localContext._nullLiteral = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + dataType() { + let localContext = new DataTypeContext(this.context, this.state); + this.enterRule(localContext, 722, MySqlParser.RULE_dataType); + let _la; + try { + this.state = 7189; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1051, this.context)) { + case 1: + localContext = new StringDataTypeContext(localContext); + this.enterOuterAlt(localContext, 1); + { + this.state = 7063; + localContext._typeName = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 26 || ((((_la - 224)) & ~0x1F) === 0 && ((1 << (_la - 224)) & 31239) !== 0) || _la === 498)) { + localContext._typeName = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 7065; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 240) { + { + this.state = 7064; + this.match(MySqlParser.KW_VARYING); + } + } + this.state = 7068; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1024, this.context)) { + case 1: + { + this.state = 7067; + this.lengthOneDimension(); + } + break; + } + this.state = 7071; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1025, this.context)) { + case 1: + { + this.state = 7070; + this.match(MySqlParser.KW_BINARY); + } + break; + } + this.state = 7076; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 26 || _la === 224 || _la === 823) { + { + this.state = 7073; + this.charSet(); + this.state = 7074; + this.charsetName(); + } + } + this.state = 7081; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1027, this.context)) { + case 1: + { + this.state = 7078; + this.match(MySqlParser.KW_COLLATE); + this.state = 7079; + this.collationName(); + } + break; + case 2: + { + this.state = 7080; + this.match(MySqlParser.KW_BINARY); + } + break; + } + } + break; + case 2: + localContext = new NationalVaryingStringDataTypeContext(localContext); + this.enterOuterAlt(localContext, 2); + { + this.state = 7083; + this.match(MySqlParser.KW_NATIONAL); + this.state = 7084; + localContext._typeName = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 26 || _la === 224)) { + localContext._typeName = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 7085; + this.match(MySqlParser.KW_VARYING); + this.state = 7087; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1028, this.context)) { + case 1: + { + this.state = 7086; + this.lengthOneDimension(); + } + break; + } + this.state = 7090; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 228) { + { + this.state = 7089; + this.match(MySqlParser.KW_BINARY); + } + } + } + break; + case 3: + localContext = new NationalStringDataTypeContext(localContext); + this.enterOuterAlt(localContext, 3); + { + this.state = 7092; + this.match(MySqlParser.KW_NATIONAL); + this.state = 7093; + localContext._typeName = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 26 || _la === 224 || _la === 225)) { + localContext._typeName = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 7095; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1030, this.context)) { + case 1: + { + this.state = 7094; + this.lengthOneDimension(); + } + break; + } + this.state = 7098; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 228) { + { + this.state = 7097; + this.match(MySqlParser.KW_BINARY); + } + } + } + break; + case 4: + localContext = new NationalStringDataTypeContext(localContext); + this.enterOuterAlt(localContext, 4); + { + this.state = 7100; + this.match(MySqlParser.KW_NCHAR); + this.state = 7101; + localContext._typeName = this.match(MySqlParser.KW_VARCHAR); + this.state = 7103; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1032, this.context)) { + case 1: + { + this.state = 7102; + this.lengthOneDimension(); + } + break; + } + this.state = 7106; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 228) { + { + this.state = 7105; + this.match(MySqlParser.KW_BINARY); + } + } + } + break; + case 5: + localContext = new DimensionDataTypeContext(localContext); + this.enterOuterAlt(localContext, 5); + { + this.state = 7108; + localContext._typeName = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(((((_la - 198)) & ~0x1F) === 0 && ((1 << (_la - 198)) & 4095) !== 0))) { + localContext._typeName = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 7110; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1034, this.context)) { + case 1: + { + this.state = 7109; + this.lengthOneDimension(); + } + break; + } + this.state = 7115; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 184 || _la === 197 || _la === 596) { + { + { + this.state = 7112; + _la = this.tokenStream.LA(1); + if (!(_la === 184 || _la === 197 || _la === 596)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + this.state = 7117; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + break; + case 6: + localContext = new DimensionDataTypeContext(localContext); + this.enterOuterAlt(localContext, 6); + { + this.state = 7118; + localContext._typeName = this.match(MySqlParser.KW_REAL); + this.state = 7120; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1036, this.context)) { + case 1: + { + this.state = 7119; + this.lengthTwoDimension(); + } + break; + } + this.state = 7125; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 184 || _la === 197 || _la === 596) { + { + { + this.state = 7122; + _la = this.tokenStream.LA(1); + if (!(_la === 184 || _la === 197 || _la === 596)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + this.state = 7127; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + break; + case 7: + localContext = new DimensionDataTypeContext(localContext); + this.enterOuterAlt(localContext, 7); + { + this.state = 7128; + localContext._typeName = this.match(MySqlParser.KW_DOUBLE); + this.state = 7130; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 212) { + { + this.state = 7129; + this.match(MySqlParser.KW_PRECISION); + } + } + this.state = 7133; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1039, this.context)) { + case 1: + { + this.state = 7132; + this.lengthTwoDimension(); + } + break; + } + this.state = 7138; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 184 || _la === 197 || _la === 596) { + { + { + this.state = 7135; + _la = this.tokenStream.LA(1); + if (!(_la === 184 || _la === 197 || _la === 596)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + this.state = 7140; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + break; + case 8: + localContext = new DimensionDataTypeContext(localContext); + this.enterOuterAlt(localContext, 8); + { + this.state = 7141; + localContext._typeName = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(((((_la - 213)) & ~0x1F) === 0 && ((1 << (_la - 213)) & 63) !== 0) || _la === 403)) { + localContext._typeName = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 7143; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1041, this.context)) { + case 1: + { + this.state = 7142; + this.lengthTwoOptionalDimension(); + } + break; + } + this.state = 7148; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 184 || _la === 197 || _la === 596) { + { + { + this.state = 7145; + _la = this.tokenStream.LA(1); + if (!(_la === 184 || _la === 197 || _la === 596)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + this.state = 7150; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + break; + case 9: + localContext = new SimpleDataTypeContext(localContext); + this.enterOuterAlt(localContext, 9); + { + this.state = 7151; + localContext._typeName = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(((((_la - 219)) & ~0x1F) === 0 && ((1 << (_la - 219)) & 4237313) !== 0) || _la === 321 || _la === 322)) { + localContext._typeName = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + break; + case 10: + localContext = new DimensionDataTypeContext(localContext); + this.enterOuterAlt(localContext, 10); + { + this.state = 7152; + localContext._typeName = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(((((_la - 220)) & ~0x1F) === 0 && ((1 << (_la - 220)) & 2831) !== 0) || _la === 319)) { + localContext._typeName = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 7154; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1043, this.context)) { + case 1: + { + this.state = 7153; + this.lengthOneDimension(); + } + break; + } + } + break; + case 11: + localContext = new CollectionDataTypeContext(localContext); + this.enterOuterAlt(localContext, 11); + { + this.state = 7156; + localContext._typeName = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 155 || _la === 239)) { + localContext._typeName = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 7157; + this.collectionOptions(); + this.state = 7159; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 228) { + { + this.state = 7158; + this.match(MySqlParser.KW_BINARY); + } + } + this.state = 7164; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 26 || _la === 224 || _la === 823) { + { + this.state = 7161; + this.charSet(); + this.state = 7162; + this.charsetName(); + } + } + } + break; + case 12: + localContext = new SpatialDataTypeContext(localContext); + this.enterOuterAlt(localContext, 12); + { + this.state = 7166; + localContext._typeName = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 442 || ((((_la - 813)) & ~0x1F) === 0 && ((1 << (_la - 813)) & 511) !== 0))) { + localContext._typeName = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 7169; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 834) { + { + this.state = 7167; + this.match(MySqlParser.KW_SRID); + this.state = 7168; + this.decimalLiteral(); + } + } + } + break; + case 13: + localContext = new LongVarcharDataTypeContext(localContext); + this.enterOuterAlt(localContext, 13); + { + this.state = 7171; + localContext._typeName = this.match(MySqlParser.KW_LONG); + this.state = 7173; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 225) { + { + this.state = 7172; + this.match(MySqlParser.KW_VARCHAR); + } + } + this.state = 7176; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 228) { + { + this.state = 7175; + this.match(MySqlParser.KW_BINARY); + } + } + this.state = 7181; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 26 || _la === 224 || _la === 823) { + { + this.state = 7178; + this.charSet(); + this.state = 7179; + this.charsetName(); + } + } + this.state = 7185; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1050, this.context)) { + case 1: + { + this.state = 7183; + this.match(MySqlParser.KW_COLLATE); + this.state = 7184; + this.collationName(); + } + break; + } + } + break; + case 14: + localContext = new LongVarbinaryDataTypeContext(localContext); + this.enterOuterAlt(localContext, 14); + { + this.state = 7187; + this.match(MySqlParser.KW_LONG); + this.state = 7188; + this.match(MySqlParser.KW_VARBINARY); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + collectionOptions() { + let localContext = new CollectionOptionsContext(this.context, this.state); + this.enterRule(localContext, 724, MySqlParser.RULE_collectionOptions); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 7191; + this.match(MySqlParser.LR_BRACKET); + this.state = 7192; + this.match(MySqlParser.STRING_LITERAL); + this.state = 7197; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 7193; + this.match(MySqlParser.COMMA); + this.state = 7194; + this.match(MySqlParser.STRING_LITERAL); + } + } + this.state = 7199; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 7200; + this.match(MySqlParser.RR_BRACKET); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + convertedDataType() { + let localContext = new ConvertedDataTypeContext(this.context, this.state); + this.enterRule(localContext, 726, MySqlParser.RULE_convertedDataType); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 7224; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_BINARY: + case MySqlParser.KW_NCHAR: + { + this.state = 7202; + localContext._typeName = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 228 || _la === 498)) { + localContext._typeName = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 7204; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 866) { + { + this.state = 7203; + this.lengthOneDimension(); + } + } + } + break; + case MySqlParser.KW_CHAR: + { + this.state = 7206; + localContext._typeName = this.match(MySqlParser.KW_CHAR); + this.state = 7208; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 866) { + { + this.state = 7207; + this.lengthOneDimension(); + } + } + this.state = 7213; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 26 || _la === 224 || _la === 823) { + { + this.state = 7210; + this.charSet(); + this.state = 7211; + this.charsetName(); + } + } + } + break; + case MySqlParser.KW_INT: + case MySqlParser.KW_INTEGER: + case MySqlParser.KW_DATE: + case MySqlParser.KW_TIME: + case MySqlParser.KW_DATETIME: + case MySqlParser.KW_JSON: + { + this.state = 7215; + localContext._typeName = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(((((_la - 202)) & ~0x1F) === 0 && ((1 << (_la - 202)) & 1441857) !== 0) || _la === 442)) { + localContext._typeName = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + break; + case MySqlParser.KW_DECIMAL: + case MySqlParser.KW_DEC: + { + this.state = 7216; + localContext._typeName = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 216 || _la === 217)) { + localContext._typeName = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 7218; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 866) { + { + this.state = 7217; + this.lengthTwoOptionalDimension(); + } + } + } + break; + case MySqlParser.KW_UNSIGNED: + case MySqlParser.KW_SIGNED: + { + this.state = 7220; + _la = this.tokenStream.LA(1); + if (!(_la === 184 || _la === 596)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 7222; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 202 || _la === 208) { + { + this.state = 7221; + _la = this.tokenStream.LA(1); + if (!(_la === 202 || _la === 208)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + } + break; + default: + throw new antlr.NoViableAltException(this); + } + this.state = 7227; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 12) { + { + this.state = 7226; + this.match(MySqlParser.KW_ARRAY); + } + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + lengthOneDimension() { + let localContext = new LengthOneDimensionContext(this.context, this.state); + this.enterRule(localContext, 728, MySqlParser.RULE_lengthOneDimension); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 7229; + this.match(MySqlParser.LR_BRACKET); + this.state = 7230; + this.decimalLiteral(); + this.state = 7231; + this.match(MySqlParser.RR_BRACKET); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + lengthTwoDimension() { + let localContext = new LengthTwoDimensionContext(this.context, this.state); + this.enterRule(localContext, 730, MySqlParser.RULE_lengthTwoDimension); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 7233; + this.match(MySqlParser.LR_BRACKET); + this.state = 7234; + this.decimalLiteral(); + this.state = 7235; + this.match(MySqlParser.COMMA); + this.state = 7236; + this.decimalLiteral(); + this.state = 7237; + this.match(MySqlParser.RR_BRACKET); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + lengthTwoOptionalDimension() { + let localContext = new LengthTwoOptionalDimensionContext(this.context, this.state); + this.enterRule(localContext, 732, MySqlParser.RULE_lengthTwoOptionalDimension); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 7239; + this.match(MySqlParser.LR_BRACKET); + this.state = 7240; + this.decimalLiteral(); + this.state = 7243; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 868) { + { + this.state = 7241; + this.match(MySqlParser.COMMA); + this.state = 7242; + this.decimalLiteral(); + } + } + this.state = 7245; + this.match(MySqlParser.RR_BRACKET); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + indexColumnNames() { + let localContext = new IndexColumnNamesContext(this.context, this.state); + this.enterRule(localContext, 734, MySqlParser.RULE_indexColumnNames); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 7247; + this.match(MySqlParser.LR_BRACKET); + this.state = 7248; + this.indexColumnName(); + this.state = 7253; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 7249; + this.match(MySqlParser.COMMA); + this.state = 7250; + this.indexColumnName(); + } + } + this.state = 7255; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 7256; + this.match(MySqlParser.RR_BRACKET); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + expressions() { + let localContext = new ExpressionsContext(this.context, this.state); + this.enterRule(localContext, 736, MySqlParser.RULE_expressions); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 7258; + this.expression(0); + this.state = 7263; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 7259; + this.match(MySqlParser.COMMA); + this.state = 7260; + this.expression(0); + } + } + this.state = 7265; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + valuesOrValueList() { + let localContext = new ValuesOrValueListContext(this.context, this.state); + this.enterRule(localContext, 738, MySqlParser.RULE_valuesOrValueList); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 7266; + _la = this.tokenStream.LA(1); + if (!(_la === 189 || _la === 682)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 7267; + this.expressionsWithDefaults(); + this.state = 7272; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 7268; + this.match(MySqlParser.COMMA); + this.state = 7269; + this.expressionsWithDefaults(); + } + } + this.state = 7274; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + expressionsWithDefaults() { + let localContext = new ExpressionsWithDefaultsContext(this.context, this.state); + this.enterRule(localContext, 740, MySqlParser.RULE_expressionsWithDefaults); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 7275; + this.match(MySqlParser.LR_BRACKET); + this.state = 7276; + this.expressionOrDefault(); + this.state = 7281; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 7277; + this.match(MySqlParser.COMMA); + this.state = 7278; + this.expressionOrDefault(); + } + } + this.state = 7283; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 7284; + this.match(MySqlParser.RR_BRACKET); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + expressionOrDefault() { + let localContext = new ExpressionOrDefaultContext(this.context, this.state); + this.enterRule(localContext, 742, MySqlParser.RULE_expressionOrDefault); + try { + this.state = 7288; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1065, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 7286; + this.expression(0); + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 7287; + this.match(MySqlParser.KW_DEFAULT); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + constants() { + let localContext = new ConstantsContext(this.context, this.state); + this.enterRule(localContext, 744, MySqlParser.RULE_constants); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 7290; + this.constant(); + this.state = 7295; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 7291; + this.match(MySqlParser.COMMA); + this.state = 7292; + this.constant(); + } + } + this.state = 7297; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + simpleStrings() { + let localContext = new SimpleStringsContext(this.context, this.state); + this.enterRule(localContext, 746, MySqlParser.RULE_simpleStrings); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 7298; + this.match(MySqlParser.STRING_LITERAL); + this.state = 7303; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 7299; + this.match(MySqlParser.COMMA); + this.state = 7300; + this.match(MySqlParser.STRING_LITERAL); + } + } + this.state = 7305; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + userVariables() { + let localContext = new UserVariablesContext(this.context, this.state); + this.enterRule(localContext, 748, MySqlParser.RULE_userVariables); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 7306; + this.match(MySqlParser.LOCAL_ID); + this.state = 7311; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 7307; + this.match(MySqlParser.COMMA); + this.state = 7308; + this.match(MySqlParser.LOCAL_ID); + } + } + this.state = 7313; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + defaultValue() { + let localContext = new DefaultValueContext(this.context, this.state); + this.enterRule(localContext, 750, MySqlParser.RULE_defaultValue); + try { + this.state = 7340; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1071, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 7314; + this.match(MySqlParser.KW_NULL_LITERAL); + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 7315; + this.match(MySqlParser.KW_CAST); + this.state = 7316; + this.match(MySqlParser.LR_BRACKET); + this.state = 7317; + this.expression(0); + this.state = 7318; + this.match(MySqlParser.KW_AS); + this.state = 7319; + this.convertedDataType(); + this.state = 7320; + this.match(MySqlParser.RR_BRACKET); + } + break; + case 3: + this.enterOuterAlt(localContext, 3); + { + this.state = 7323; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1069, this.context)) { + case 1: + { + this.state = 7322; + this.unaryOperator(); + } + break; + } + this.state = 7325; + this.constant(); + } + break; + case 4: + this.enterOuterAlt(localContext, 4); + { + this.state = 7326; + this.currentTimestamp(); + this.state = 7330; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1070, this.context)) { + case 1: + { + this.state = 7327; + this.match(MySqlParser.KW_ON); + this.state = 7328; + this.match(MySqlParser.KW_UPDATE); + this.state = 7329; + this.currentTimestamp(); + } + break; + } + } + break; + case 5: + this.enterOuterAlt(localContext, 5); + { + this.state = 7332; + this.match(MySqlParser.LR_BRACKET); + this.state = 7333; + this.expression(0); + this.state = 7334; + this.match(MySqlParser.RR_BRACKET); + } + break; + case 6: + this.enterOuterAlt(localContext, 6); + { + this.state = 7336; + this.match(MySqlParser.LR_BRACKET); + this.state = 7337; + this.fullId(); + this.state = 7338; + this.match(MySqlParser.RR_BRACKET); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + currentTimestamp() { + let localContext = new CurrentTimestampContext(this.context, this.state); + this.enterRule(localContext, 752, MySqlParser.RULE_currentTimestamp); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 7356; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_CURRENT_TIMESTAMP: + case MySqlParser.KW_LOCALTIME: + case MySqlParser.KW_LOCALTIMESTAMP: + { + this.state = 7342; + _la = this.tokenStream.LA(1); + if (!(((((_la - 287)) & ~0x1F) === 0 && ((1 << (_la - 287)) & 131) !== 0))) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 7348; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1073, this.context)) { + case 1: + { + this.state = 7343; + this.match(MySqlParser.LR_BRACKET); + this.state = 7345; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (((((_la - 871)) & ~0x1F) === 0 && ((1 << (_la - 871)) & 20495) !== 0)) { + { + this.state = 7344; + this.decimalLiteral(); + } + } + this.state = 7347; + this.match(MySqlParser.RR_BRACKET); + } + break; + } + } + break; + case MySqlParser.KW_NOW: + { + this.state = 7350; + this.match(MySqlParser.KW_NOW); + this.state = 7351; + this.match(MySqlParser.LR_BRACKET); + this.state = 7353; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (((((_la - 871)) & ~0x1F) === 0 && ((1 << (_la - 871)) & 20495) !== 0)) { + { + this.state = 7352; + this.decimalLiteral(); + } + } + this.state = 7355; + this.match(MySqlParser.RR_BRACKET); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + ifExists() { + let localContext = new IfExistsContext(this.context, this.state); + this.enterRule(localContext, 754, MySqlParser.RULE_ifExists); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 7358; + this.match(MySqlParser.KW_IF); + this.state = 7359; + this.match(MySqlParser.KW_EXISTS); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + ifNotExists() { + let localContext = new IfNotExistsContext(this.context, this.state); + this.enterRule(localContext, 756, MySqlParser.RULE_ifNotExists); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 7361; + this.match(MySqlParser.KW_IF); + this.state = 7362; + this.match(MySqlParser.KW_NOT); + this.state = 7363; + this.match(MySqlParser.KW_EXISTS); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + orReplace() { + let localContext = new OrReplaceContext(this.context, this.state); + this.enterRule(localContext, 758, MySqlParser.RULE_orReplace); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 7365; + this.match(MySqlParser.KW_OR); + this.state = 7366; + this.match(MySqlParser.KW_REPLACE); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + functionCall() { + let localContext = new FunctionCallContext(this.context, this.state); + this.enterRule(localContext, 760, MySqlParser.RULE_functionCall); + try { + this.state = 7390; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1078, this.context)) { + case 1: + localContext = new SpecificFunctionCallContext(localContext); + this.enterOuterAlt(localContext, 1); + { + this.state = 7368; + this.specificFunction(); + } + break; + case 2: + localContext = new AggregateFunctionCallContext(localContext); + this.enterOuterAlt(localContext, 2); + { + this.state = 7369; + this.aggregateWindowedFunction(); + } + break; + case 3: + localContext = new NonAggregateFunctionCallContext(localContext); + this.enterOuterAlt(localContext, 3); + { + this.state = 7370; + this.nonAggregateWindowedFunction(); + } + break; + case 4: + localContext = new ScalarFunctionCallContext(localContext); + this.enterOuterAlt(localContext, 4); + { + this.state = 7371; + this.scalarFunctionName(); + this.state = 7378; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1076, this.context)) { + case 1: + { + this.state = 7372; + this.match(MySqlParser.LR_BRACKET); + this.state = 7373; + this.match(MySqlParser.RR_BRACKET); + } + break; + case 2: + { + this.state = 7374; + this.match(MySqlParser.LR_BRACKET); + this.state = 7375; + this.functionArgs(); + this.state = 7376; + this.match(MySqlParser.RR_BRACKET); + } + break; + } + } + break; + case 5: + localContext = new UdfFunctionCallContext(localContext); + this.enterOuterAlt(localContext, 5); + { + this.state = 7380; + this.functionName(); + this.state = 7387; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1077, this.context)) { + case 1: + { + this.state = 7381; + this.match(MySqlParser.LR_BRACKET); + this.state = 7382; + this.match(MySqlParser.RR_BRACKET); + } + break; + case 2: + { + this.state = 7383; + this.match(MySqlParser.LR_BRACKET); + this.state = 7384; + this.functionArgs(); + this.state = 7385; + this.match(MySqlParser.RR_BRACKET); + } + break; + } + } + break; + case 6: + localContext = new PasswordFunctionCallContext(localContext); + this.enterOuterAlt(localContext, 6); + { + this.state = 7389; + this.passwordFunctionClause(); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + specificFunction() { + let localContext = new SpecificFunctionContext(this.context, this.state); + this.enterRule(localContext, 762, MySqlParser.RULE_specificFunction); + let _la; + try { + this.state = 7571; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1102, this.context)) { + case 1: + localContext = new SimpleFunctionCallContext(localContext); + this.enterOuterAlt(localContext, 1); + { + this.state = 7392; + _la = this.tokenStream.LA(1); + if (!(_la === 152 || ((((_la - 285)) & ~0x1F) === 0 && ((1 << (_la - 285)) & 262159) !== 0))) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 7395; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1079, this.context)) { + case 1: + { + this.state = 7393; + this.match(MySqlParser.LR_BRACKET); + this.state = 7394; + this.match(MySqlParser.RR_BRACKET); + } + break; + } + } + break; + case 2: + localContext = new CurrentUserContext(localContext); + this.enterOuterAlt(localContext, 2); + { + this.state = 7397; + this.currentUserExpression(); + } + break; + case 3: + localContext = new DataTypeFunctionCallContext(localContext); + this.enterOuterAlt(localContext, 3); + { + this.state = 7398; + this.match(MySqlParser.KW_CONVERT); + this.state = 7399; + this.match(MySqlParser.LR_BRACKET); + this.state = 7400; + this.expression(0); + this.state = 7401; + localContext._separator = this.match(MySqlParser.COMMA); + this.state = 7402; + this.convertedDataType(); + this.state = 7403; + this.match(MySqlParser.RR_BRACKET); + } + break; + case 4: + localContext = new DataTypeFunctionCallContext(localContext); + this.enterOuterAlt(localContext, 4); + { + this.state = 7405; + this.match(MySqlParser.KW_CONVERT); + this.state = 7406; + this.match(MySqlParser.LR_BRACKET); + this.state = 7407; + this.expression(0); + this.state = 7408; + this.match(MySqlParser.KW_USING); + this.state = 7409; + this.charsetName(); + this.state = 7410; + this.match(MySqlParser.RR_BRACKET); + } + break; + case 5: + localContext = new DataTypeFunctionCallContext(localContext); + this.enterOuterAlt(localContext, 5); + { + this.state = 7412; + this.match(MySqlParser.KW_CAST); + this.state = 7413; + this.match(MySqlParser.LR_BRACKET); + this.state = 7414; + this.expression(0); + this.state = 7415; + this.match(MySqlParser.KW_AS); + this.state = 7416; + this.convertedDataType(); + this.state = 7417; + this.match(MySqlParser.RR_BRACKET); + } + break; + case 6: + localContext = new ValuesFunctionCallContext(localContext); + this.enterOuterAlt(localContext, 6); + { + this.state = 7419; + this.match(MySqlParser.KW_VALUES); + this.state = 7420; + this.match(MySqlParser.LR_BRACKET); + this.state = 7421; + this.columnName(); + this.state = 7422; + this.match(MySqlParser.RR_BRACKET); + } + break; + case 7: + localContext = new CaseFunctionCallContext(localContext); + this.enterOuterAlt(localContext, 7); + { + this.state = 7424; + this.match(MySqlParser.KW_CASE); + this.state = 7426; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + do { + { + { + this.state = 7425; + this.caseFuncAlternative(); + } + } + this.state = 7428; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } while (_la === 191); + this.state = 7432; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 53) { + { + this.state = 7430; + this.match(MySqlParser.KW_ELSE); + this.state = 7431; + localContext._elseArg = this.functionArg(); + } + } + this.state = 7434; + this.match(MySqlParser.KW_END); + } + break; + case 8: + localContext = new CaseExpressionFunctionCallContext(localContext); + this.enterOuterAlt(localContext, 8); + { + this.state = 7436; + this.match(MySqlParser.KW_CASE); + this.state = 7437; + this.expression(0); + this.state = 7439; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + do { + { + { + this.state = 7438; + this.caseFuncAlternative(); + } + } + this.state = 7441; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } while (_la === 191); + this.state = 7445; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 53) { + { + this.state = 7443; + this.match(MySqlParser.KW_ELSE); + this.state = 7444; + localContext._elseArg = this.functionArg(); + } + } + this.state = 7447; + this.match(MySqlParser.KW_END); + } + break; + case 9: + localContext = new CharFunctionCallContext(localContext); + this.enterOuterAlt(localContext, 9); + { + this.state = 7449; + this.match(MySqlParser.KW_CHAR); + this.state = 7450; + this.match(MySqlParser.LR_BRACKET); + this.state = 7451; + this.functionArgs(); + this.state = 7454; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 188) { + { + this.state = 7452; + this.match(MySqlParser.KW_USING); + this.state = 7453; + this.charsetName(); + } + } + this.state = 7456; + this.match(MySqlParser.RR_BRACKET); + } + break; + case 10: + localContext = new PositionFunctionCallContext(localContext); + this.enterOuterAlt(localContext, 10); + { + this.state = 7458; + this.match(MySqlParser.KW_POSITION); + this.state = 7459; + this.match(MySqlParser.LR_BRACKET); + this.state = 7462; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1085, this.context)) { + case 1: + { + this.state = 7460; + localContext._positionString = this.stringLiteral(); + } + break; + case 2: + { + this.state = 7461; + localContext._positionExpression = this.expression(0); + } + break; + } + this.state = 7464; + this.match(MySqlParser.KW_IN); + this.state = 7467; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1086, this.context)) { + case 1: + { + this.state = 7465; + localContext._inString = this.stringLiteral(); + } + break; + case 2: + { + this.state = 7466; + localContext._inExpression = this.expression(0); + } + break; + } + this.state = 7469; + this.match(MySqlParser.RR_BRACKET); + } + break; + case 11: + localContext = new SubstrFunctionCallContext(localContext); + this.enterOuterAlt(localContext, 11); + { + this.state = 7471; + _la = this.tokenStream.LA(1); + if (!(_la === 297 || _la === 298)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 7472; + this.match(MySqlParser.LR_BRACKET); + this.state = 7475; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1087, this.context)) { + case 1: + { + this.state = 7473; + localContext._sourceString = this.stringLiteral(); + } + break; + case 2: + { + this.state = 7474; + localContext._sourceExpression = this.expression(0); + } + break; + } + this.state = 7477; + this.match(MySqlParser.KW_FROM); + this.state = 7480; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1088, this.context)) { + case 1: + { + this.state = 7478; + localContext._fromDecimal = this.decimalLiteral(); + } + break; + case 2: + { + this.state = 7479; + localContext._fromExpression = this.expression(0); + } + break; + } + this.state = 7487; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 65) { + { + this.state = 7482; + this.match(MySqlParser.KW_FOR); + this.state = 7485; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1089, this.context)) { + case 1: + { + this.state = 7483; + localContext._forDecimal = this.decimalLiteral(); + } + break; + case 2: + { + this.state = 7484; + localContext._forExpression = this.expression(0); + } + break; + } + } + } + this.state = 7489; + this.match(MySqlParser.RR_BRACKET); + } + break; + case 12: + localContext = new TrimFunctionCallContext(localContext); + this.enterOuterAlt(localContext, 12); + { + this.state = 7491; + this.match(MySqlParser.KW_TRIM); + this.state = 7492; + this.match(MySqlParser.LR_BRACKET); + this.state = 7493; + localContext._positioinForm = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 18 || _la === 96 || _la === 177)) { + localContext._positioinForm = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 7496; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1091, this.context)) { + case 1: + { + this.state = 7494; + localContext._sourceString = this.stringLiteral(); + } + break; + case 2: + { + this.state = 7495; + localContext._sourceExpression = this.expression(0); + } + break; + } + this.state = 7498; + this.match(MySqlParser.KW_FROM); + this.state = 7501; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1092, this.context)) { + case 1: + { + this.state = 7499; + localContext._fromString = this.stringLiteral(); + } + break; + case 2: + { + this.state = 7500; + localContext._fromExpression = this.expression(0); + } + break; + } + this.state = 7503; + this.match(MySqlParser.RR_BRACKET); + } + break; + case 13: + localContext = new TrimFunctionCallContext(localContext); + this.enterOuterAlt(localContext, 13); + { + this.state = 7505; + this.match(MySqlParser.KW_TRIM); + this.state = 7506; + this.match(MySqlParser.LR_BRACKET); + this.state = 7509; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1093, this.context)) { + case 1: + { + this.state = 7507; + localContext._sourceString = this.stringLiteral(); + } + break; + case 2: + { + this.state = 7508; + localContext._sourceExpression = this.expression(0); + } + break; + } + this.state = 7511; + this.match(MySqlParser.KW_FROM); + this.state = 7514; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1094, this.context)) { + case 1: + { + this.state = 7512; + localContext._fromString = this.stringLiteral(); + } + break; + case 2: + { + this.state = 7513; + localContext._fromExpression = this.expression(0); + } + break; + } + this.state = 7516; + this.match(MySqlParser.RR_BRACKET); + } + break; + case 14: + localContext = new WeightFunctionCallContext(localContext); + this.enterOuterAlt(localContext, 14); + { + this.state = 7518; + this.match(MySqlParser.KW_WEIGHT_STRING); + this.state = 7519; + this.match(MySqlParser.LR_BRACKET); + this.state = 7522; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1095, this.context)) { + case 1: + { + this.state = 7520; + this.stringLiteral(); + } + break; + case 2: + { + this.state = 7521; + this.expression(0); + } + break; + } + this.state = 7530; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 13) { + { + this.state = 7524; + this.match(MySqlParser.KW_AS); + this.state = 7525; + localContext._stringFormat = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 224 || _la === 228)) { + localContext._stringFormat = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 7526; + this.match(MySqlParser.LR_BRACKET); + this.state = 7527; + this.decimalLiteral(); + this.state = 7528; + this.match(MySqlParser.RR_BRACKET); + } + } + this.state = 7533; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 448) { + { + this.state = 7532; + this.levelsInWeightString(); + } + } + this.state = 7535; + this.match(MySqlParser.RR_BRACKET); + } + break; + case 15: + localContext = new ExtractFunctionCallContext(localContext); + this.enterOuterAlt(localContext, 15); + { + this.state = 7537; + this.match(MySqlParser.KW_EXTRACT); + this.state = 7538; + this.match(MySqlParser.LR_BRACKET); + this.state = 7539; + this.intervalType(); + this.state = 7540; + this.match(MySqlParser.KW_FROM); + this.state = 7543; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1098, this.context)) { + case 1: + { + this.state = 7541; + localContext._sourceString = this.stringLiteral(); + } + break; + case 2: + { + this.state = 7542; + localContext._sourceExpression = this.expression(0); + } + break; + } + this.state = 7545; + this.match(MySqlParser.RR_BRACKET); + } + break; + case 16: + localContext = new GetFormatFunctionCallContext(localContext); + this.enterOuterAlt(localContext, 16); + { + this.state = 7547; + this.match(MySqlParser.KW_GET_FORMAT); + this.state = 7548; + this.match(MySqlParser.LR_BRACKET); + this.state = 7549; + localContext._datetimeFormat = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(((((_la - 219)) & ~0x1F) === 0 && ((1 << (_la - 219)) & 11) !== 0))) { + localContext._datetimeFormat = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 7550; + this.match(MySqlParser.COMMA); + this.state = 7551; + this.stringLiteral(); + this.state = 7552; + this.match(MySqlParser.RR_BRACKET); + } + break; + case 17: + localContext = new JsonValueFunctionCallContext(localContext); + this.enterOuterAlt(localContext, 17); + { + this.state = 7554; + this.match(MySqlParser.KW_JSON_VALUE); + this.state = 7555; + this.match(MySqlParser.LR_BRACKET); + this.state = 7556; + this.expression(0); + this.state = 7557; + this.match(MySqlParser.COMMA); + this.state = 7558; + this.expression(0); + this.state = 7561; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 579) { + { + this.state = 7559; + this.match(MySqlParser.KW_RETURNING); + this.state = 7560; + this.convertedDataType(); + } + } + this.state = 7564; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1100, this.context)) { + case 1: + { + this.state = 7563; + this.jsonOnEmpty(); + } + break; + } + this.state = 7567; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 42 || _la === 116 || _la === 382) { + { + this.state = 7566; + this.jsonOnError(); + } + } + this.state = 7569; + this.match(MySqlParser.RR_BRACKET); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + caseFuncAlternative() { + let localContext = new CaseFuncAlternativeContext(this.context, this.state); + this.enterRule(localContext, 764, MySqlParser.RULE_caseFuncAlternative); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 7573; + this.match(MySqlParser.KW_WHEN); + this.state = 7574; + localContext._condition = this.functionArg(); + this.state = 7575; + this.match(MySqlParser.KW_THEN); + this.state = 7576; + localContext._consequent = this.functionArg(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + levelsInWeightString() { + let localContext = new LevelsInWeightStringContext(this.context, this.state); + this.enterRule(localContext, 766, MySqlParser.RULE_levelsInWeightString); + let _la; + try { + this.state = 7592; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1104, this.context)) { + case 1: + localContext = new LevelWeightListContext(localContext); + this.enterOuterAlt(localContext, 1); + { + this.state = 7578; + this.match(MySqlParser.KW_LEVEL); + this.state = 7579; + this.levelInWeightListElement(); + this.state = 7584; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 7580; + this.match(MySqlParser.COMMA); + this.state = 7581; + this.levelInWeightListElement(); + } + } + this.state = 7586; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + break; + case 2: + localContext = new LevelWeightRangeContext(localContext); + this.enterOuterAlt(localContext, 2); + { + this.state = 7587; + this.match(MySqlParser.KW_LEVEL); + this.state = 7588; + localContext._firstLevel = this.decimalLiteral(); + this.state = 7589; + this.match(MySqlParser.MINUS); + this.state = 7590; + localContext._lastLevel = this.decimalLiteral(); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + levelInWeightListElement() { + let localContext = new LevelInWeightListElementContext(this.context, this.state); + this.enterRule(localContext, 768, MySqlParser.RULE_levelInWeightListElement); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 7594; + this.decimalLiteral(); + this.state = 7596; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 14 || _la === 45 || _la === 830) { + { + this.state = 7595; + localContext._orderType = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 14 || _la === 45 || _la === 830)) { + localContext._orderType = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + aggregateWindowedFunction() { + let localContext = new AggregateWindowedFunctionContext(this.context, this.state); + this.enterRule(localContext, 770, MySqlParser.RULE_aggregateWindowedFunction); + let _la; + try { + this.state = 7657; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_AVG: + case MySqlParser.KW_MAX: + case MySqlParser.KW_MIN: + case MySqlParser.KW_SUM: + this.enterOuterAlt(localContext, 1); + { + this.state = 7598; + _la = this.tokenStream.LA(1); + if (!(((((_la - 258)) & ~0x1F) === 0 && ((1 << (_la - 258)) & 8400897) !== 0))) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 7599; + this.match(MySqlParser.LR_BRACKET); + this.state = 7601; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1106, this.context)) { + case 1: + { + this.state = 7600; + localContext._aggregator = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 7 || _la === 49)) { + localContext._aggregator = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + break; + } + this.state = 7603; + this.functionArg(); + this.state = 7604; + this.match(MySqlParser.RR_BRACKET); + this.state = 7606; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1107, this.context)) { + case 1: + { + this.state = 7605; + this.overClause(); + } + break; + } + } + break; + case MySqlParser.KW_COUNT: + this.enterOuterAlt(localContext, 2); + { + this.state = 7608; + this.match(MySqlParser.KW_COUNT); + this.state = 7609; + this.match(MySqlParser.LR_BRACKET); + this.state = 7617; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1109, this.context)) { + case 1: + { + this.state = 7610; + localContext._starArg = this.match(MySqlParser.STAR); + } + break; + case 2: + { + this.state = 7612; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1108, this.context)) { + case 1: + { + this.state = 7611; + localContext._aggregator = this.match(MySqlParser.KW_ALL); + } + break; + } + this.state = 7614; + this.functionArg(); + } + break; + case 3: + { + this.state = 7615; + localContext._aggregator = this.match(MySqlParser.KW_DISTINCT); + this.state = 7616; + this.functionArgs(); + } + break; + } + this.state = 7619; + this.match(MySqlParser.RR_BRACKET); + this.state = 7621; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1110, this.context)) { + case 1: + { + this.state = 7620; + this.overClause(); + } + break; + } + } + break; + case MySqlParser.KW_BIT_AND: + case MySqlParser.KW_BIT_OR: + case MySqlParser.KW_BIT_XOR: + case MySqlParser.KW_STD: + case MySqlParser.KW_STDDEV: + case MySqlParser.KW_STDDEV_POP: + case MySqlParser.KW_STDDEV_SAMP: + case MySqlParser.KW_VAR_POP: + case MySqlParser.KW_VAR_SAMP: + case MySqlParser.KW_VARIANCE: + this.enterOuterAlt(localContext, 3); + { + this.state = 7623; + _la = this.tokenStream.LA(1); + if (!(((((_la - 259)) & ~0x1F) === 0 && ((1 << (_la - 259)) & 62652423) !== 0))) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 7624; + this.match(MySqlParser.LR_BRACKET); + this.state = 7626; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1111, this.context)) { + case 1: + { + this.state = 7625; + localContext._aggregator = this.match(MySqlParser.KW_ALL); + } + break; + } + this.state = 7628; + this.functionArg(); + this.state = 7629; + this.match(MySqlParser.RR_BRACKET); + this.state = 7631; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1112, this.context)) { + case 1: + { + this.state = 7630; + this.overClause(); + } + break; + } + } + break; + case MySqlParser.KW_GROUP_CONCAT: + this.enterOuterAlt(localContext, 4); + { + this.state = 7633; + this.match(MySqlParser.KW_GROUP_CONCAT); + this.state = 7634; + this.match(MySqlParser.LR_BRACKET); + this.state = 7636; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1113, this.context)) { + case 1: + { + this.state = 7635; + localContext._aggregator = this.match(MySqlParser.KW_DISTINCT); + } + break; + } + this.state = 7638; + this.functionArgs(); + this.state = 7649; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 125) { + { + this.state = 7639; + this.match(MySqlParser.KW_ORDER); + this.state = 7640; + this.match(MySqlParser.KW_BY); + this.state = 7641; + this.orderByExpression(); + this.state = 7646; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 7642; + this.match(MySqlParser.COMMA); + this.state = 7643; + this.orderByExpression(); + } + } + this.state = 7648; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + } + this.state = 7653; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 156) { + { + this.state = 7651; + this.match(MySqlParser.KW_SEPARATOR); + this.state = 7652; + localContext._separator = this.match(MySqlParser.STRING_LITERAL); + } + } + this.state = 7655; + this.match(MySqlParser.RR_BRACKET); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + nonAggregateWindowedFunction() { + let localContext = new NonAggregateWindowedFunctionContext(this.context, this.state); + this.enterRule(localContext, 772, MySqlParser.RULE_nonAggregateWindowedFunction); + let _la; + try { + this.state = 7697; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_LAG: + case MySqlParser.KW_LEAD: + this.enterOuterAlt(localContext, 1); + { + this.state = 7659; + _la = this.tokenStream.LA(1); + if (!(_la === 267 || _la === 269)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 7660; + this.match(MySqlParser.LR_BRACKET); + this.state = 7661; + this.expression(0); + this.state = 7664; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1118, this.context)) { + case 1: + { + this.state = 7662; + this.match(MySqlParser.COMMA); + this.state = 7663; + this.decimalLiteral(); + } + break; + } + this.state = 7668; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 868) { + { + this.state = 7666; + this.match(MySqlParser.COMMA); + this.state = 7667; + this.decimalLiteral(); + } + } + this.state = 7670; + this.match(MySqlParser.RR_BRACKET); + this.state = 7671; + this.overClause(); + } + break; + case MySqlParser.KW_FIRST_VALUE: + case MySqlParser.KW_LAST_VALUE: + this.enterOuterAlt(localContext, 2); + { + this.state = 7673; + _la = this.tokenStream.LA(1); + if (!(_la === 265 || _la === 268)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 7674; + this.match(MySqlParser.LR_BRACKET); + this.state = 7675; + this.expression(0); + this.state = 7676; + this.match(MySqlParser.RR_BRACKET); + this.state = 7677; + this.overClause(); + } + break; + case MySqlParser.KW_CUME_DIST: + case MySqlParser.KW_DENSE_RANK: + case MySqlParser.KW_PERCENT_RANK: + case MySqlParser.KW_RANK: + case MySqlParser.KW_ROW_NUMBER: + this.enterOuterAlt(localContext, 3); + { + this.state = 7679; + _la = this.tokenStream.LA(1); + if (!(((((_la - 263)) & ~0x1F) === 0 && ((1 << (_la - 263)) & 14339) !== 0))) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 7680; + this.match(MySqlParser.LR_BRACKET); + this.state = 7681; + this.match(MySqlParser.RR_BRACKET); + this.state = 7682; + this.overClause(); + } + break; + case MySqlParser.KW_NTH_VALUE: + this.enterOuterAlt(localContext, 4); + { + this.state = 7683; + this.match(MySqlParser.KW_NTH_VALUE); + this.state = 7684; + this.match(MySqlParser.LR_BRACKET); + this.state = 7685; + this.expression(0); + this.state = 7686; + this.match(MySqlParser.COMMA); + this.state = 7687; + this.decimalLiteral(); + this.state = 7688; + this.match(MySqlParser.RR_BRACKET); + this.state = 7689; + this.overClause(); + } + break; + case MySqlParser.KW_NTILE: + this.enterOuterAlt(localContext, 5); + { + this.state = 7691; + this.match(MySqlParser.KW_NTILE); + this.state = 7692; + this.match(MySqlParser.LR_BRACKET); + this.state = 7693; + this.decimalLiteral(); + this.state = 7694; + this.match(MySqlParser.RR_BRACKET); + this.state = 7695; + this.overClause(); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + overClause() { + let localContext = new OverClauseContext(this.context, this.state); + this.enterRule(localContext, 774, MySqlParser.RULE_overClause); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 7699; + this.match(MySqlParser.KW_OVER); + this.state = 7705; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.LR_BRACKET: + { + this.state = 7700; + this.match(MySqlParser.LR_BRACKET); + this.state = 7701; + this.windowSpec(); + this.state = 7702; + this.match(MySqlParser.RR_BRACKET); + } + break; + case MySqlParser.KW_ARRAY: + case MySqlParser.KW_ATTRIBUTE: + case MySqlParser.KW_BUCKETS: + case MySqlParser.KW_CONDITION: + case MySqlParser.KW_CURRENT: + case MySqlParser.KW_CURRENT_USER: + case MySqlParser.KW_DATABASE: + case MySqlParser.KW_DEFAULT: + case MySqlParser.KW_DIAGNOSTICS: + case MySqlParser.KW_EMPTY: + case MySqlParser.KW_ENFORCED: + case MySqlParser.KW_EXCEPT: + case MySqlParser.KW_GROUP: + case MySqlParser.KW_IF: + case MySqlParser.KW_INSERT: + case MySqlParser.KW_LATERAL: + case MySqlParser.KW_LEFT: + case MySqlParser.KW_NUMBER: + case MySqlParser.KW_OPTIONAL: + case MySqlParser.KW_ORDER: + case MySqlParser.KW_PRIMARY: + case MySqlParser.KW_REPEAT: + case MySqlParser.KW_REPLACE: + case MySqlParser.KW_RIGHT: + case MySqlParser.KW_SCHEMA: + case MySqlParser.KW_SKIP_QUERY_REWRITE: + case MySqlParser.KW_STACKED: + case MySqlParser.KW_DATE: + case MySqlParser.KW_TIME: + case MySqlParser.KW_TIMESTAMP: + case MySqlParser.KW_DATETIME: + case MySqlParser.KW_YEAR: + case MySqlParser.KW_BINARY: + case MySqlParser.KW_TEXT: + case MySqlParser.KW_ENUM: + case MySqlParser.KW_SERIAL: + case MySqlParser.KW_JSON_TABLE: + case MySqlParser.KW_JSON_VALUE: + case MySqlParser.KW_NESTED: + case MySqlParser.KW_ORDINALITY: + case MySqlParser.KW_PATH: + case MySqlParser.KW_AVG: + case MySqlParser.KW_BIT_AND: + case MySqlParser.KW_BIT_OR: + case MySqlParser.KW_BIT_XOR: + case MySqlParser.KW_COUNT: + case MySqlParser.KW_CUME_DIST: + case MySqlParser.KW_DENSE_RANK: + case MySqlParser.KW_FIRST_VALUE: + case MySqlParser.KW_GROUP_CONCAT: + case MySqlParser.KW_LAG: + case MySqlParser.KW_LAST_VALUE: + case MySqlParser.KW_LEAD: + case MySqlParser.KW_MAX: + case MySqlParser.KW_MIN: + case MySqlParser.KW_NTILE: + case MySqlParser.KW_NTH_VALUE: + case MySqlParser.KW_PERCENT_RANK: + case MySqlParser.KW_RANK: + case MySqlParser.KW_ROW_NUMBER: + case MySqlParser.KW_STD: + case MySqlParser.KW_STDDEV: + case MySqlParser.KW_STDDEV_POP: + case MySqlParser.KW_STDDEV_SAMP: + case MySqlParser.KW_SUM: + case MySqlParser.KW_VAR_POP: + case MySqlParser.KW_VAR_SAMP: + case MySqlParser.KW_VARIANCE: + case MySqlParser.KW_CURRENT_DATE: + case MySqlParser.KW_CURRENT_TIME: + case MySqlParser.KW_CURRENT_TIMESTAMP: + case MySqlParser.KW_LOCALTIME: + case MySqlParser.KW_CURDATE: + case MySqlParser.KW_CURTIME: + case MySqlParser.KW_DATE_ADD: + case MySqlParser.KW_DATE_SUB: + case MySqlParser.KW_LOCALTIMESTAMP: + case MySqlParser.KW_NOW: + case MySqlParser.KW_POSITION: + case MySqlParser.KW_SUBSTR: + case MySqlParser.KW_SUBSTRING: + case MySqlParser.KW_SYSDATE: + case MySqlParser.KW_TRIM: + case MySqlParser.KW_UTC_DATE: + case MySqlParser.KW_UTC_TIME: + case MySqlParser.KW_UTC_TIMESTAMP: + case MySqlParser.KW_ACCOUNT: + case MySqlParser.KW_ACTION: + case MySqlParser.KW_AFTER: + case MySqlParser.KW_AGGREGATE: + case MySqlParser.KW_ALGORITHM: + case MySqlParser.KW_ANY: + case MySqlParser.KW_AT: + case MySqlParser.KW_AUTHORS: + case MySqlParser.KW_AUTOCOMMIT: + case MySqlParser.KW_AUTOEXTEND_SIZE: + case MySqlParser.KW_AUTO_INCREMENT: + case MySqlParser.KW_AVG_ROW_LENGTH: + case MySqlParser.KW_BEGIN: + case MySqlParser.KW_BINLOG: + case MySqlParser.KW_BIT: + case MySqlParser.KW_BLOCK: + case MySqlParser.KW_BOOL: + case MySqlParser.KW_BOOLEAN: + case MySqlParser.KW_BTREE: + case MySqlParser.KW_CACHE: + case MySqlParser.KW_CASCADED: + case MySqlParser.KW_CHAIN: + case MySqlParser.KW_CHANGED: + case MySqlParser.KW_CHANNEL: + case MySqlParser.KW_CHECKSUM: + case MySqlParser.KW_CIPHER: + case MySqlParser.KW_CLASS_ORIGIN: + case MySqlParser.KW_CLIENT: + case MySqlParser.KW_CLOSE: + case MySqlParser.KW_COALESCE: + case MySqlParser.KW_CODE: + case MySqlParser.KW_COLUMNS: + case MySqlParser.KW_COLUMN_FORMAT: + case MySqlParser.KW_COLUMN_NAME: + case MySqlParser.KW_COMMENT: + case MySqlParser.KW_COMMIT: + case MySqlParser.KW_COMPACT: + case MySqlParser.KW_COMPLETION: + case MySqlParser.KW_COMPRESSED: + case MySqlParser.KW_COMPRESSION: + case MySqlParser.KW_CONCURRENT: + case MySqlParser.KW_CONNECT: + case MySqlParser.KW_CONNECTION: + case MySqlParser.KW_CONSISTENT: + case MySqlParser.KW_CONSTRAINT_CATALOG: + case MySqlParser.KW_CONSTRAINT_SCHEMA: + case MySqlParser.KW_CONSTRAINT_NAME: + case MySqlParser.KW_CONTAINS: + case MySqlParser.KW_CONTEXT: + case MySqlParser.KW_CONTRIBUTORS: + case MySqlParser.KW_COPY: + case MySqlParser.KW_CPU: + case MySqlParser.KW_CURSOR_NAME: + case MySqlParser.KW_DATA: + case MySqlParser.KW_DATAFILE: + case MySqlParser.KW_DEALLOCATE: + case MySqlParser.KW_DEFAULT_AUTH: + case MySqlParser.KW_DEFINER: + case MySqlParser.KW_DELAY_KEY_WRITE: + case MySqlParser.KW_DES_KEY_FILE: + case MySqlParser.KW_DIRECTORY: + case MySqlParser.KW_DISABLE: + case MySqlParser.KW_DISCARD: + case MySqlParser.KW_DISK: + case MySqlParser.KW_DO: + case MySqlParser.KW_DUMPFILE: + case MySqlParser.KW_DUPLICATE: + case MySqlParser.KW_DYNAMIC: + case MySqlParser.KW_ENABLE: + case MySqlParser.KW_ENCRYPTION: + case MySqlParser.KW_END: + case MySqlParser.KW_ENDS: + case MySqlParser.KW_ENGINE: + case MySqlParser.KW_ENGINES: + case MySqlParser.KW_ERROR: + case MySqlParser.KW_ERRORS: + case MySqlParser.KW_ESCAPE: + case MySqlParser.KW_EVENT: + case MySqlParser.KW_EVENTS: + case MySqlParser.KW_EVERY: + case MySqlParser.KW_EXCHANGE: + case MySqlParser.KW_EXCLUSIVE: + case MySqlParser.KW_EXPIRE: + case MySqlParser.KW_EXPORT: + case MySqlParser.KW_EXTENDED: + case MySqlParser.KW_EXTENT_SIZE: + case MySqlParser.KW_FAILED_LOGIN_ATTEMPTS: + case MySqlParser.KW_FAST: + case MySqlParser.KW_FAULTS: + case MySqlParser.KW_FIELDS: + case MySqlParser.KW_FILE_BLOCK_SIZE: + case MySqlParser.KW_FILTER: + case MySqlParser.KW_FIRST: + case MySqlParser.KW_FIXED: + case MySqlParser.KW_FLUSH: + case MySqlParser.KW_FOLLOWS: + case MySqlParser.KW_FOUND: + case MySqlParser.KW_FULL: + case MySqlParser.KW_FUNCTION: + case MySqlParser.KW_GENERAL: + case MySqlParser.KW_GLOBAL: + case MySqlParser.KW_GRANTS: + case MySqlParser.KW_GROUP_REPLICATION: + case MySqlParser.KW_HANDLER: + case MySqlParser.KW_HASH: + case MySqlParser.KW_HELP: + case MySqlParser.KW_HISTORY: + case MySqlParser.KW_HOST: + case MySqlParser.KW_HOSTS: + case MySqlParser.KW_IDENTIFIED: + case MySqlParser.KW_IGNORE_SERVER_IDS: + case MySqlParser.KW_IMPORT: + case MySqlParser.KW_INDEXES: + case MySqlParser.KW_INITIAL_SIZE: + case MySqlParser.KW_INPLACE: + case MySqlParser.KW_INSERT_METHOD: + case MySqlParser.KW_INSTALL: + case MySqlParser.KW_INSTANCE: + case MySqlParser.KW_INSTANT: + case MySqlParser.KW_INVISIBLE: + case MySqlParser.KW_INVOKER: + case MySqlParser.KW_IO: + case MySqlParser.KW_IO_THREAD: + case MySqlParser.KW_IPC: + case MySqlParser.KW_ISOLATION: + case MySqlParser.KW_ISSUER: + case MySqlParser.KW_JSON: + case MySqlParser.KW_KEY_BLOCK_SIZE: + case MySqlParser.KW_LANGUAGE: + case MySqlParser.KW_LAST: + case MySqlParser.KW_LEAVES: + case MySqlParser.KW_LESS: + case MySqlParser.KW_LEVEL: + case MySqlParser.KW_LIST: + case MySqlParser.KW_LOCAL: + case MySqlParser.KW_LOGFILE: + case MySqlParser.KW_LOGS: + case MySqlParser.KW_MASTER: + case MySqlParser.KW_MASTER_AUTO_POSITION: + case MySqlParser.KW_MASTER_CONNECT_RETRY: + case MySqlParser.KW_MASTER_DELAY: + case MySqlParser.KW_MASTER_HEARTBEAT_PERIOD: + case MySqlParser.KW_MASTER_HOST: + case MySqlParser.KW_MASTER_LOG_FILE: + case MySqlParser.KW_MASTER_LOG_POS: + case MySqlParser.KW_MASTER_PASSWORD: + case MySqlParser.KW_MASTER_PORT: + case MySqlParser.KW_MASTER_RETRY_COUNT: + case MySqlParser.KW_MASTER_SSL: + case MySqlParser.KW_MASTER_SSL_CA: + case MySqlParser.KW_MASTER_SSL_CAPATH: + case MySqlParser.KW_MASTER_SSL_CERT: + case MySqlParser.KW_MASTER_SSL_CIPHER: + case MySqlParser.KW_MASTER_SSL_CRL: + case MySqlParser.KW_MASTER_SSL_CRLPATH: + case MySqlParser.KW_MASTER_SSL_KEY: + case MySqlParser.KW_MASTER_TLS_VERSION: + case MySqlParser.KW_MASTER_USER: + case MySqlParser.KW_MAX_CONNECTIONS_PER_HOUR: + case MySqlParser.KW_MAX_QUERIES_PER_HOUR: + case MySqlParser.KW_MAX_ROWS: + case MySqlParser.KW_MAX_SIZE: + case MySqlParser.KW_MAX_UPDATES_PER_HOUR: + case MySqlParser.KW_MAX_USER_CONNECTIONS: + case MySqlParser.KW_MEDIUM: + case MySqlParser.KW_MEMBER: + case MySqlParser.KW_MERGE: + case MySqlParser.KW_MESSAGE_TEXT: + case MySqlParser.KW_MID: + case MySqlParser.KW_MIGRATE: + case MySqlParser.KW_MIN_ROWS: + case MySqlParser.KW_MODE: + case MySqlParser.KW_MODIFY: + case MySqlParser.KW_MUTEX: + case MySqlParser.KW_MYSQL: + case MySqlParser.KW_MYSQL_ERRNO: + case MySqlParser.KW_NAME: + case MySqlParser.KW_NAMES: + case MySqlParser.KW_NCHAR: + case MySqlParser.KW_NEVER: + case MySqlParser.KW_NEXT: + case MySqlParser.KW_NO: + case MySqlParser.KW_NOWAIT: + case MySqlParser.KW_NODEGROUP: + case MySqlParser.KW_NONE: + case MySqlParser.KW_ODBC: + case MySqlParser.KW_OFFLINE: + case MySqlParser.KW_OFFSET: + case MySqlParser.KW_OF: + case MySqlParser.KW_OLD_PASSWORD: + case MySqlParser.KW_ONE: + case MySqlParser.KW_ONLINE: + case MySqlParser.KW_ONLY: + case MySqlParser.KW_OPEN: + case MySqlParser.KW_OPTIMIZER_COSTS: + case MySqlParser.KW_OPTIONS: + case MySqlParser.KW_OWNER: + case MySqlParser.KW_PACK_KEYS: + case MySqlParser.KW_PAGE: + case MySqlParser.KW_PAGE_CHECKSUM: + case MySqlParser.KW_PARSER: + case MySqlParser.KW_PARTIAL: + case MySqlParser.KW_PARTITIONING: + case MySqlParser.KW_PARTITIONS: + case MySqlParser.KW_PASSWORD: + case MySqlParser.KW_PASSWORD_LOCK_TIME: + case MySqlParser.KW_PHASE: + case MySqlParser.KW_PLUGIN: + case MySqlParser.KW_PLUGIN_DIR: + case MySqlParser.KW_PLUGINS: + case MySqlParser.KW_PORT: + case MySqlParser.KW_PRECEDES: + case MySqlParser.KW_PREPARE: + case MySqlParser.KW_PRESERVE: + case MySqlParser.KW_PREV: + case MySqlParser.KW_PROCESSLIST: + case MySqlParser.KW_PROFILE: + case MySqlParser.KW_PROFILES: + case MySqlParser.KW_PROXY: + case MySqlParser.KW_QUERY: + case MySqlParser.KW_QUICK: + case MySqlParser.KW_REBUILD: + case MySqlParser.KW_RECOVER: + case MySqlParser.KW_RECURSIVE: + case MySqlParser.KW_REDO_BUFFER_SIZE: + case MySqlParser.KW_REDUNDANT: + case MySqlParser.KW_RELAY: + case MySqlParser.KW_RELAY_LOG_FILE: + case MySqlParser.KW_RELAY_LOG_POS: + case MySqlParser.KW_RELAYLOG: + case MySqlParser.KW_REMOVE: + case MySqlParser.KW_REORGANIZE: + case MySqlParser.KW_REPAIR: + case MySqlParser.KW_REPLICATE_DO_DB: + case MySqlParser.KW_REPLICATE_DO_TABLE: + case MySqlParser.KW_REPLICATE_IGNORE_DB: + case MySqlParser.KW_REPLICATE_IGNORE_TABLE: + case MySqlParser.KW_REPLICATE_REWRITE_DB: + case MySqlParser.KW_REPLICATE_WILD_DO_TABLE: + case MySqlParser.KW_REPLICATE_WILD_IGNORE_TABLE: + case MySqlParser.KW_REPLICATION: + case MySqlParser.KW_RESET: + case MySqlParser.KW_RESUME: + case MySqlParser.KW_RETURNED_SQLSTATE: + case MySqlParser.KW_RETURNS: + case MySqlParser.KW_REUSE: + case MySqlParser.KW_ROLE: + case MySqlParser.KW_ROLLBACK: + case MySqlParser.KW_ROLLUP: + case MySqlParser.KW_ROTATE: + case MySqlParser.KW_ROW: + case MySqlParser.KW_ROWS: + case MySqlParser.KW_ROW_FORMAT: + case MySqlParser.KW_SAVEPOINT: + case MySqlParser.KW_SCHEDULE: + case MySqlParser.KW_SECURITY: + case MySqlParser.KW_SERVER: + case MySqlParser.KW_SESSION: + case MySqlParser.KW_SHARE: + case MySqlParser.KW_SHARED: + case MySqlParser.KW_SIGNED: + case MySqlParser.KW_SIMPLE: + case MySqlParser.KW_SLAVE: + case MySqlParser.KW_SLOW: + case MySqlParser.KW_SNAPSHOT: + case MySqlParser.KW_SOCKET: + case MySqlParser.KW_SOME: + case MySqlParser.KW_SONAME: + case MySqlParser.KW_SOUNDS: + case MySqlParser.KW_SOURCE: + case MySqlParser.KW_SQL_AFTER_GTIDS: + case MySqlParser.KW_SQL_AFTER_MTS_GAPS: + case MySqlParser.KW_SQL_BEFORE_GTIDS: + case MySqlParser.KW_SQL_BUFFER_RESULT: + case MySqlParser.KW_SQL_CACHE: + case MySqlParser.KW_SQL_NO_CACHE: + case MySqlParser.KW_SQL_THREAD: + case MySqlParser.KW_START: + case MySqlParser.KW_STARTS: + case MySqlParser.KW_STATS_AUTO_RECALC: + case MySqlParser.KW_STATS_PERSISTENT: + case MySqlParser.KW_STATS_SAMPLE_PAGES: + case MySqlParser.KW_STATUS: + case MySqlParser.KW_STOP: + case MySqlParser.KW_STORAGE: + case MySqlParser.KW_STRING: + case MySqlParser.KW_SUBCLASS_ORIGIN: + case MySqlParser.KW_SUBJECT: + case MySqlParser.KW_SUBPARTITION: + case MySqlParser.KW_SUBPARTITIONS: + case MySqlParser.KW_SUSPEND: + case MySqlParser.KW_SWAPS: + case MySqlParser.KW_SWITCHES: + case MySqlParser.KW_TABLE_NAME: + case MySqlParser.KW_TABLESPACE: + case MySqlParser.KW_TABLE_TYPE: + case MySqlParser.KW_TEMPORARY: + case MySqlParser.KW_TEMPTABLE: + case MySqlParser.KW_THAN: + case MySqlParser.KW_TRADITIONAL: + case MySqlParser.KW_TRANSACTION: + case MySqlParser.KW_TRANSACTIONAL: + case MySqlParser.KW_TRIGGERS: + case MySqlParser.KW_TRUNCATE: + case MySqlParser.KW_UNBOUNDED: + case MySqlParser.KW_UNDEFINED: + case MySqlParser.KW_UNDOFILE: + case MySqlParser.KW_UNDO_BUFFER_SIZE: + case MySqlParser.KW_UNINSTALL: + case MySqlParser.KW_UNKNOWN: + case MySqlParser.KW_UNTIL: + case MySqlParser.KW_UPGRADE: + case MySqlParser.KW_USER: + case MySqlParser.KW_USE_FRM: + case MySqlParser.KW_USER_RESOURCES: + case MySqlParser.KW_VALIDATION: + case MySqlParser.KW_VALUE: + case MySqlParser.KW_VARIABLES: + case MySqlParser.KW_VIEW: + case MySqlParser.KW_VIRTUAL: + case MySqlParser.KW_VISIBLE: + case MySqlParser.KW_WAIT: + case MySqlParser.KW_WARNINGS: + case MySqlParser.KW_WITHOUT: + case MySqlParser.KW_WORK: + case MySqlParser.KW_WRAPPER: + case MySqlParser.KW_X509: + case MySqlParser.KW_XA: + case MySqlParser.KW_XML: + case MySqlParser.KW_QUARTER: + case MySqlParser.KW_MONTH: + case MySqlParser.KW_DAY: + case MySqlParser.KW_HOUR: + case MySqlParser.KW_MINUTE: + case MySqlParser.KW_WEEK: + case MySqlParser.KW_SECOND: + case MySqlParser.KW_MICROSECOND: + case MySqlParser.KW_ADMIN: + case MySqlParser.KW_AUDIT_ABORT_EXEMPT: + case MySqlParser.KW_AUDIT_ADMIN: + case MySqlParser.KW_AUTHENTICATION_POLICY_ADMIN: + case MySqlParser.KW_BACKUP_ADMIN: + case MySqlParser.KW_BINLOG_ADMIN: + case MySqlParser.KW_BINLOG_ENCRYPTION_ADMIN: + case MySqlParser.KW_CLONE_ADMIN: + case MySqlParser.KW_CONNECTION_ADMIN: + case MySqlParser.KW_ENCRYPTION_KEY_ADMIN: + case MySqlParser.KW_EXECUTE: + case MySqlParser.KW_FILE: + case MySqlParser.KW_FIREWALL_ADMIN: + case MySqlParser.KW_FIREWALL_EXEMPT: + case MySqlParser.KW_FIREWALL_USER: + case MySqlParser.KW_GROUP_REPLICATION_ADMIN: + case MySqlParser.KW_INNODB_REDO_LOG_ARCHIVE: + case MySqlParser.KW_INVOKE: + case MySqlParser.KW_LAMBDA: + case MySqlParser.KW_NDB_STORED_USER: + case MySqlParser.KW_PASSWORDLESS_USER_ADMIN: + case MySqlParser.KW_PERSIST_RO_VARIABLES_ADMIN: + case MySqlParser.KW_PRIVILEGES: + case MySqlParser.KW_PROCESS: + case MySqlParser.KW_RELOAD: + case MySqlParser.KW_REPLICATION_APPLIER: + case MySqlParser.KW_REPLICATION_SLAVE_ADMIN: + case MySqlParser.KW_RESOURCE_GROUP_ADMIN: + case MySqlParser.KW_RESOURCE_GROUP_USER: + case MySqlParser.KW_ROLE_ADMIN: + case MySqlParser.KW_ROUTINE: + case MySqlParser.KW_S3: + case MySqlParser.KW_SESSION_VARIABLES_ADMIN: + case MySqlParser.KW_SET_USER_ID: + case MySqlParser.KW_SHOW_ROUTINE: + case MySqlParser.KW_SHUTDOWN: + case MySqlParser.KW_SUPER: + case MySqlParser.KW_SYSTEM_VARIABLES_ADMIN: + case MySqlParser.KW_TABLES: + case MySqlParser.KW_TABLE_ENCRYPTION_ADMIN: + case MySqlParser.KW_VERSION_TOKEN_ADMIN: + case MySqlParser.KW_XA_RECOVER_ADMIN: + case MySqlParser.KW_ARMSCII8: + case MySqlParser.KW_ASCII: + case MySqlParser.KW_BIG5: + case MySqlParser.KW_CP1250: + case MySqlParser.KW_CP1251: + case MySqlParser.KW_CP1256: + case MySqlParser.KW_CP1257: + case MySqlParser.KW_CP850: + case MySqlParser.KW_CP852: + case MySqlParser.KW_CP866: + case MySqlParser.KW_CP932: + case MySqlParser.KW_DEC8: + case MySqlParser.KW_EUCJPMS: + case MySqlParser.KW_EUCKR: + case MySqlParser.KW_GB18030: + case MySqlParser.KW_GB2312: + case MySqlParser.KW_GBK: + case MySqlParser.KW_GEOSTD8: + case MySqlParser.KW_GREEK: + case MySqlParser.KW_HEBREW: + case MySqlParser.KW_HP8: + case MySqlParser.KW_KEYBCS2: + case MySqlParser.KW_KOI8R: + case MySqlParser.KW_KOI8U: + case MySqlParser.KW_LATIN1: + case MySqlParser.KW_LATIN2: + case MySqlParser.KW_LATIN5: + case MySqlParser.KW_LATIN7: + case MySqlParser.KW_MACCE: + case MySqlParser.KW_MACROMAN: + case MySqlParser.KW_SJIS: + case MySqlParser.KW_SWE7: + case MySqlParser.KW_TIS620: + case MySqlParser.KW_UCS2: + case MySqlParser.KW_UJIS: + case MySqlParser.KW_UTF16: + case MySqlParser.KW_UTF16LE: + case MySqlParser.KW_UTF32: + case MySqlParser.KW_UTF8: + case MySqlParser.KW_UTF8MB3: + case MySqlParser.KW_UTF8MB4: + case MySqlParser.KW_ARCHIVE: + case MySqlParser.KW_BLACKHOLE: + case MySqlParser.KW_CSV: + case MySqlParser.KW_FEDERATED: + case MySqlParser.KW_INNODB: + case MySqlParser.KW_MEMORY: + case MySqlParser.KW_MRG_MYISAM: + case MySqlParser.KW_MYISAM: + case MySqlParser.KW_NDB: + case MySqlParser.KW_NDBCLUSTER: + case MySqlParser.KW_PERFORMANCE_SCHEMA: + case MySqlParser.KW_TOKUDB: + case MySqlParser.KW_REPEATABLE: + case MySqlParser.KW_COMMITTED: + case MySqlParser.KW_UNCOMMITTED: + case MySqlParser.KW_SERIALIZABLE: + case MySqlParser.KW_GEOMETRYCOLLECTION: + case MySqlParser.KW_LINESTRING: + case MySqlParser.KW_MULTILINESTRING: + case MySqlParser.KW_MULTIPOINT: + case MySqlParser.KW_MULTIPOLYGON: + case MySqlParser.KW_POINT: + case MySqlParser.KW_POLYGON: + case MySqlParser.KW_CATALOG_NAME: + case MySqlParser.KW_CHARSET: + case MySqlParser.KW_COLLATION: + case MySqlParser.KW_ENGINE_ATTRIBUTE: + case MySqlParser.KW_FORMAT: + case MySqlParser.KW_GET_FORMAT: + case MySqlParser.KW_RANDOM: + case MySqlParser.KW_REVERSE: + case MySqlParser.KW_ROW_COUNT: + case MySqlParser.KW_SCHEMA_NAME: + case MySqlParser.KW_SECONDARY_ENGINE_ATTRIBUTE: + case MySqlParser.KW_SRID: + case MySqlParser.KW_SYSTEM_USER: + case MySqlParser.KW_TP_CONNECTION_ADMIN: + case MySqlParser.KW_WEIGHT_STRING: + case MySqlParser.MOD: + case MySqlParser.CHARSET_REVERSE_QOUTE_STRING: + case MySqlParser.STRING_LITERAL: + case MySqlParser.ID: + { + this.state = 7704; + this.windowName(); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + windowSpec() { + let localContext = new WindowSpecContext(this.context, this.state); + this.enterRule(localContext, 776, MySqlParser.RULE_windowSpec); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 7708; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1122, this.context)) { + case 1: + { + this.state = 7707; + this.windowName(); + } + break; + } + this.state = 7711; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 130) { + { + this.state = 7710; + this.partitionClause(); + } + } + this.state = 7714; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 125) { + { + this.state = 7713; + this.orderByClause(); + } + } + this.state = 7717; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 134 || _la === 587) { + { + this.state = 7716; + this.frameClause(); + } + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + windowName() { + let localContext = new WindowNameContext(this.context, this.state); + this.enterRule(localContext, 778, MySqlParser.RULE_windowName); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 7719; + this.uid(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + frameClause() { + let localContext = new FrameClauseContext(this.context, this.state); + this.enterRule(localContext, 780, MySqlParser.RULE_frameClause); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 7721; + this.frameUnits(); + this.state = 7722; + this.frameExtent(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + frameUnits() { + let localContext = new FrameUnitsContext(this.context, this.state); + this.enterRule(localContext, 782, MySqlParser.RULE_frameUnits); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 7724; + _la = this.tokenStream.LA(1); + if (!(_la === 134 || _la === 587)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + frameExtent() { + let localContext = new FrameExtentContext(this.context, this.state); + this.enterRule(localContext, 784, MySqlParser.RULE_frameExtent); + try { + this.state = 7728; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1126, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 7726; + this.frameRange(); + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 7727; + this.frameBetween(); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + frameBetween() { + let localContext = new FrameBetweenContext(this.context, this.state); + this.enterRule(localContext, 786, MySqlParser.RULE_frameBetween); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 7730; + this.match(MySqlParser.KW_BETWEEN); + this.state = 7731; + this.frameRange(); + this.state = 7732; + this.match(MySqlParser.KW_AND); + this.state = 7733; + this.frameRange(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + frameRange() { + let localContext = new FrameRangeContext(this.context, this.state); + this.enterRule(localContext, 788, MySqlParser.RULE_frameRange); + let _la; + try { + this.state = 7742; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1127, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 7735; + this.match(MySqlParser.KW_CURRENT); + this.state = 7736; + this.match(MySqlParser.KW_ROW); + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 7737; + this.match(MySqlParser.KW_UNBOUNDED); + this.state = 7738; + _la = this.tokenStream.LA(1); + if (!(_la === 405 || _la === 539)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + break; + case 3: + this.enterOuterAlt(localContext, 3); + { + this.state = 7739; + this.expression(0); + this.state = 7740; + _la = this.tokenStream.LA(1); + if (!(_la === 405 || _la === 539)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + partitionClause() { + let localContext = new PartitionClauseContext(this.context, this.state); + this.enterRule(localContext, 790, MySqlParser.RULE_partitionClause); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 7744; + this.match(MySqlParser.KW_PARTITION); + this.state = 7745; + this.match(MySqlParser.KW_BY); + this.state = 7746; + this.expression(0); + this.state = 7751; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 7747; + this.match(MySqlParser.COMMA); + this.state = 7748; + this.expression(0); + } + } + this.state = 7753; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + scalarFunctionName() { + let localContext = new ScalarFunctionNameContext(this.context, this.state); + this.enterRule(localContext, 792, MySqlParser.RULE_scalarFunctionName); + try { + this.state = 7778; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_DATABASE: + case MySqlParser.KW_LEFT: + case MySqlParser.KW_RIGHT: + case MySqlParser.KW_SCHEMA: + case MySqlParser.KW_DATE: + case MySqlParser.KW_TIME: + case MySqlParser.KW_TIMESTAMP: + case MySqlParser.KW_YEAR: + case MySqlParser.KW_JSON_TABLE: + case MySqlParser.KW_JSON_VALUE: + case MySqlParser.KW_COUNT: + case MySqlParser.KW_CUME_DIST: + case MySqlParser.KW_DENSE_RANK: + case MySqlParser.KW_FIRST_VALUE: + case MySqlParser.KW_LAG: + case MySqlParser.KW_LAST_VALUE: + case MySqlParser.KW_LEAD: + case MySqlParser.KW_NTILE: + case MySqlParser.KW_NTH_VALUE: + case MySqlParser.KW_PERCENT_RANK: + case MySqlParser.KW_RANK: + case MySqlParser.KW_ROW_NUMBER: + case MySqlParser.KW_POSITION: + case MySqlParser.KW_INVISIBLE: + case MySqlParser.KW_VISIBLE: + case MySqlParser.KW_QUARTER: + case MySqlParser.KW_MONTH: + case MySqlParser.KW_DAY: + case MySqlParser.KW_HOUR: + case MySqlParser.KW_MINUTE: + case MySqlParser.KW_WEEK: + case MySqlParser.KW_SECOND: + case MySqlParser.KW_MICROSECOND: + case MySqlParser.KW_SESSION_VARIABLES_ADMIN: + case MySqlParser.KW_GEOMETRYCOLLECTION: + case MySqlParser.KW_LINESTRING: + case MySqlParser.KW_MULTILINESTRING: + case MySqlParser.KW_MULTIPOINT: + case MySqlParser.KW_MULTIPOLYGON: + case MySqlParser.KW_POINT: + case MySqlParser.KW_POLYGON: + case MySqlParser.KW_CHARSET: + case MySqlParser.KW_COLLATION: + case MySqlParser.KW_FORMAT: + case MySqlParser.KW_GET_FORMAT: + case MySqlParser.KW_RANDOM: + case MySqlParser.KW_REVERSE: + case MySqlParser.KW_ROW_COUNT: + case MySqlParser.KW_SRID: + case MySqlParser.KW_SYSTEM_USER: + case MySqlParser.KW_WEIGHT_STRING: + case MySqlParser.MOD: + this.enterOuterAlt(localContext, 1); + { + this.state = 7754; + this.functionNameBase(); + } + break; + case MySqlParser.KW_ASCII: + this.enterOuterAlt(localContext, 2); + { + this.state = 7755; + this.match(MySqlParser.KW_ASCII); + } + break; + case MySqlParser.KW_CURDATE: + this.enterOuterAlt(localContext, 3); + { + this.state = 7756; + this.match(MySqlParser.KW_CURDATE); + } + break; + case MySqlParser.KW_CURRENT_DATE: + this.enterOuterAlt(localContext, 4); + { + this.state = 7757; + this.match(MySqlParser.KW_CURRENT_DATE); + } + break; + case MySqlParser.KW_CURRENT_TIME: + this.enterOuterAlt(localContext, 5); + { + this.state = 7758; + this.match(MySqlParser.KW_CURRENT_TIME); + } + break; + case MySqlParser.KW_CURRENT_TIMESTAMP: + this.enterOuterAlt(localContext, 6); + { + this.state = 7759; + this.match(MySqlParser.KW_CURRENT_TIMESTAMP); + } + break; + case MySqlParser.KW_CURTIME: + this.enterOuterAlt(localContext, 7); + { + this.state = 7760; + this.match(MySqlParser.KW_CURTIME); + } + break; + case MySqlParser.KW_DATE_ADD: + this.enterOuterAlt(localContext, 8); + { + this.state = 7761; + this.match(MySqlParser.KW_DATE_ADD); + } + break; + case MySqlParser.KW_DATE_SUB: + this.enterOuterAlt(localContext, 9); + { + this.state = 7762; + this.match(MySqlParser.KW_DATE_SUB); + } + break; + case MySqlParser.KW_IF: + this.enterOuterAlt(localContext, 10); + { + this.state = 7763; + this.match(MySqlParser.KW_IF); + } + break; + case MySqlParser.KW_INSERT: + this.enterOuterAlt(localContext, 11); + { + this.state = 7764; + this.match(MySqlParser.KW_INSERT); + } + break; + case MySqlParser.KW_LOCALTIME: + this.enterOuterAlt(localContext, 12); + { + this.state = 7765; + this.match(MySqlParser.KW_LOCALTIME); + } + break; + case MySqlParser.KW_LOCALTIMESTAMP: + this.enterOuterAlt(localContext, 13); + { + this.state = 7766; + this.match(MySqlParser.KW_LOCALTIMESTAMP); + } + break; + case MySqlParser.KW_MID: + this.enterOuterAlt(localContext, 14); + { + this.state = 7767; + this.match(MySqlParser.KW_MID); + } + break; + case MySqlParser.KW_NOW: + this.enterOuterAlt(localContext, 15); + { + this.state = 7768; + this.match(MySqlParser.KW_NOW); + } + break; + case MySqlParser.KW_REPEAT: + this.enterOuterAlt(localContext, 16); + { + this.state = 7769; + this.match(MySqlParser.KW_REPEAT); + } + break; + case MySqlParser.KW_REPLACE: + this.enterOuterAlt(localContext, 17); + { + this.state = 7770; + this.match(MySqlParser.KW_REPLACE); + } + break; + case MySqlParser.KW_SUBSTR: + this.enterOuterAlt(localContext, 18); + { + this.state = 7771; + this.match(MySqlParser.KW_SUBSTR); + } + break; + case MySqlParser.KW_SUBSTRING: + this.enterOuterAlt(localContext, 19); + { + this.state = 7772; + this.match(MySqlParser.KW_SUBSTRING); + } + break; + case MySqlParser.KW_SYSDATE: + this.enterOuterAlt(localContext, 20); + { + this.state = 7773; + this.match(MySqlParser.KW_SYSDATE); + } + break; + case MySqlParser.KW_TRIM: + this.enterOuterAlt(localContext, 21); + { + this.state = 7774; + this.match(MySqlParser.KW_TRIM); + } + break; + case MySqlParser.KW_UTC_DATE: + this.enterOuterAlt(localContext, 22); + { + this.state = 7775; + this.match(MySqlParser.KW_UTC_DATE); + } + break; + case MySqlParser.KW_UTC_TIME: + this.enterOuterAlt(localContext, 23); + { + this.state = 7776; + this.match(MySqlParser.KW_UTC_TIME); + } + break; + case MySqlParser.KW_UTC_TIMESTAMP: + this.enterOuterAlt(localContext, 24); + { + this.state = 7777; + this.match(MySqlParser.KW_UTC_TIMESTAMP); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + passwordFunctionClause() { + let localContext = new PasswordFunctionClauseContext(this.context, this.state); + this.enterRule(localContext, 794, MySqlParser.RULE_passwordFunctionClause); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 7780; + _la = this.tokenStream.LA(1); + if (!(_la === 512 || _la === 529)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 7781; + this.match(MySqlParser.LR_BRACKET); + this.state = 7782; + this.functionArg(); + this.state = 7783; + this.match(MySqlParser.RR_BRACKET); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + functionArgs() { + let localContext = new FunctionArgsContext(this.context, this.state); + this.enterRule(localContext, 796, MySqlParser.RULE_functionArgs); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 7785; + this.functionArg(); + this.state = 7790; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 7786; + this.match(MySqlParser.COMMA); + this.state = 7787; + this.functionArg(); + } + } + this.state = 7792; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + functionArg() { + let localContext = new FunctionArgContext(this.context, this.state); + this.enterRule(localContext, 798, MySqlParser.RULE_functionArg); + try { + this.state = 7796; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1131, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 7793; + this.constant(); + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 7794; + this.functionCall(); + } + break; + case 3: + this.enterOuterAlt(localContext, 3); + { + this.state = 7795; + this.expression(0); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + expression(_p) { + if (_p === undefined) { + _p = 0; + } + let parentContext = this.context; + let parentState = this.state; + let localContext = new ExpressionContext(this.context, parentState); + let previousContext = localContext; + let _startState = 800; + this.enterRecursionRule(localContext, 800, MySqlParser.RULE_expression, _p); + let _la; + try { + let alternative; + this.enterOuterAlt(localContext, 1); + { + this.state = 7809; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1133, this.context)) { + case 1: + { + localContext = new NotExpressionContext(localContext); + this.context = localContext; + previousContext = localContext; + this.state = 7799; + localContext._notOperator = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 114 || _la === 860)) { + localContext._notOperator = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 7800; + this.expression(4); + } + break; + case 2: + { + localContext = new IsExpressionContext(localContext); + this.context = localContext; + previousContext = localContext; + this.state = 7801; + this.predicate(0); + this.state = 7802; + this.match(MySqlParser.KW_IS); + this.state = 7804; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 114) { + { + this.state = 7803; + this.match(MySqlParser.KW_NOT); + } + } + this.state = 7806; + localContext._testValue = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 63 || _la === 179 || _la === 674)) { + localContext._testValue = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + break; + case 3: + { + localContext = new PredicateExpressionContext(localContext); + this.context = localContext; + previousContext = localContext; + this.state = 7808; + this.predicate(0); + } + break; + } + this.context.stop = this.tokenStream.LT(-1); + this.state = 7817; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 1134, this.context); + while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER) { + if (alternative === 1) { + if (this._parseListeners != null) { + this.triggerExitRuleEvent(); + } + previousContext = localContext; + { + { + localContext = new LogicalExpressionContext(new ExpressionContext(parentContext, parentState)); + this.pushNewRecursionContext(localContext, _startState, MySqlParser.RULE_expression); + this.state = 7811; + if (!(this.precpred(this.context, 3))) { + throw this.createFailedPredicateException("this.precpred(this.context, 3)"); + } + this.state = 7812; + this.logicalOperator(); + this.state = 7813; + this.expression(4); + } + } + } + this.state = 7819; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 1134, this.context); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.unrollRecursionContexts(parentContext); + } + return localContext; + } + predicate(_p) { + if (_p === undefined) { + _p = 0; + } + let parentContext = this.context; + let parentState = this.state; + let localContext = new PredicateContext(this.context, parentState); + let previousContext = localContext; + let _startState = 802; + this.enterRecursionRule(localContext, 802, MySqlParser.RULE_predicate, _p); + let _la; + try { + let alternative; + this.enterOuterAlt(localContext, 1); + { + { + localContext = new ExpressionAtomPredicateContext(localContext); + this.context = localContext; + previousContext = localContext; + this.state = 7821; + this.expressionAtom(0); + } + this.context.stop = this.tokenStream.LT(-1); + this.state = 7886; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 1143, this.context); + while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER) { + if (alternative === 1) { + if (this._parseListeners != null) { + this.triggerExitRuleEvent(); + } + previousContext = localContext; + { + this.state = 7884; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1142, this.context)) { + case 1: + { + localContext = new BetweenPredicateContext(new PredicateContext(parentContext, parentState)); + this.pushNewRecursionContext(localContext, _startState, MySqlParser.RULE_predicate); + this.state = 7823; + if (!(this.precpred(this.context, 6))) { + throw this.createFailedPredicateException("this.precpred(this.context, 6)"); + } + this.state = 7825; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 114) { + { + this.state = 7824; + this.match(MySqlParser.KW_NOT); + } + } + this.state = 7827; + this.match(MySqlParser.KW_BETWEEN); + this.state = 7828; + this.predicate(0); + this.state = 7829; + this.match(MySqlParser.KW_AND); + this.state = 7830; + this.predicate(7); + } + break; + case 2: + { + localContext = new SoundsLikePredicateContext(new PredicateContext(parentContext, parentState)); + this.pushNewRecursionContext(localContext, _startState, MySqlParser.RULE_predicate); + this.state = 7832; + if (!(this.precpred(this.context, 5))) { + throw this.createFailedPredicateException("this.precpred(this.context, 5)"); + } + this.state = 7833; + this.match(MySqlParser.KW_SOUNDS); + this.state = 7834; + this.match(MySqlParser.KW_LIKE); + this.state = 7835; + this.predicate(6); + } + break; + case 3: + { + localContext = new RegexpPredicateContext(new PredicateContext(parentContext, parentState)); + this.pushNewRecursionContext(localContext, _startState, MySqlParser.RULE_predicate); + this.state = 7836; + if (!(this.precpred(this.context, 3))) { + throw this.createFailedPredicateException("this.precpred(this.context, 3)"); + } + this.state = 7838; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 114) { + { + this.state = 7837; + this.match(MySqlParser.KW_NOT); + } + } + this.state = 7840; + localContext._regex = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 139 || _la === 151)) { + localContext._regex = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 7841; + this.predicate(4); + } + break; + case 4: + { + localContext = new InPredicateContext(new PredicateContext(parentContext, parentState)); + this.pushNewRecursionContext(localContext, _startState, MySqlParser.RULE_predicate); + this.state = 7842; + if (!(this.precpred(this.context, 9))) { + throw this.createFailedPredicateException("this.precpred(this.context, 9)"); + } + this.state = 7844; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 114) { + { + this.state = 7843; + this.match(MySqlParser.KW_NOT); + } + } + this.state = 7846; + this.match(MySqlParser.KW_IN); + this.state = 7847; + this.match(MySqlParser.LR_BRACKET); + this.state = 7850; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1138, this.context)) { + case 1: + { + this.state = 7848; + this.selectStatement(); + } + break; + case 2: + { + this.state = 7849; + this.expressions(); + } + break; + } + this.state = 7852; + this.match(MySqlParser.RR_BRACKET); + } + break; + case 5: + { + localContext = new IsNullPredicateContext(new PredicateContext(parentContext, parentState)); + this.pushNewRecursionContext(localContext, _startState, MySqlParser.RULE_predicate); + this.state = 7854; + if (!(this.precpred(this.context, 8))) { + throw this.createFailedPredicateException("this.precpred(this.context, 8)"); + } + this.state = 7855; + this.match(MySqlParser.KW_IS); + this.state = 7856; + this.nullNotnull(); + } + break; + case 6: + { + localContext = new BinaryComparisonPredicateContext(new PredicateContext(parentContext, parentState)); + this.pushNewRecursionContext(localContext, _startState, MySqlParser.RULE_predicate); + this.state = 7857; + if (!(this.precpred(this.context, 7))) { + throw this.createFailedPredicateException("this.precpred(this.context, 7)"); + } + this.state = 7858; + this.comparisonOperator(); + this.state = 7865; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1139, this.context)) { + case 1: + { + this.state = 7859; + localContext._quantifier = this.tokenStream.LT(1); + _la = this.tokenStream.LA(1); + if (!(_la === 7 || _la === 309 || _la === 602)) { + localContext._quantifier = this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + this.state = 7860; + this.match(MySqlParser.LR_BRACKET); + this.state = 7861; + localContext._subQuery = this.selectStatement(); + this.state = 7862; + this.match(MySqlParser.RR_BRACKET); + } + break; + case 2: + { + this.state = 7864; + localContext._right = this.predicate(0); + } + break; + } + } + break; + case 7: + { + localContext = new LikePredicateContext(new PredicateContext(parentContext, parentState)); + this.pushNewRecursionContext(localContext, _startState, MySqlParser.RULE_predicate); + this.state = 7867; + if (!(this.precpred(this.context, 4))) { + throw this.createFailedPredicateException("this.precpred(this.context, 4)"); + } + this.state = 7869; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 114) { + { + this.state = 7868; + this.match(MySqlParser.KW_NOT); + } + } + this.state = 7871; + this.match(MySqlParser.KW_LIKE); + this.state = 7872; + this.predicate(0); + this.state = 7875; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1141, this.context)) { + case 1: + { + this.state = 7873; + this.match(MySqlParser.KW_ESCAPE); + this.state = 7874; + this.match(MySqlParser.STRING_LITERAL); + } + break; + } + } + break; + case 8: + { + localContext = new JsonMemberOfPredicateContext(new PredicateContext(parentContext, parentState)); + this.pushNewRecursionContext(localContext, _startState, MySqlParser.RULE_predicate); + this.state = 7877; + if (!(this.precpred(this.context, 2))) { + throw this.createFailedPredicateException("this.precpred(this.context, 2)"); + } + this.state = 7878; + this.match(MySqlParser.KW_MEMBER); + this.state = 7879; + this.match(MySqlParser.KW_OF); + this.state = 7880; + this.match(MySqlParser.LR_BRACKET); + this.state = 7881; + this.predicate(0); + this.state = 7882; + this.match(MySqlParser.RR_BRACKET); + } + break; + } + } + } + this.state = 7888; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 1143, this.context); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.unrollRecursionContexts(parentContext); + } + return localContext; + } + expressionAtom(_p) { + if (_p === undefined) { + _p = 0; + } + let parentContext = this.context; + let parentState = this.state; + let localContext = new ExpressionAtomContext(this.context, parentState); + let previousContext = localContext; + let _startState = 804; + this.enterRecursionRule(localContext, 804, MySqlParser.RULE_expressionAtom, _p); + let _la; + try { + let alternative; + this.enterOuterAlt(localContext, 1); + { + this.state = 7937; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1146, this.context)) { + case 1: + { + localContext = new ConstantExpressionAtomContext(localContext); + this.context = localContext; + previousContext = localContext; + this.state = 7890; + this.constant(); + } + break; + case 2: + { + localContext = new FunctionCallExpressionAtomContext(localContext); + this.context = localContext; + previousContext = localContext; + this.state = 7891; + this.functionCall(); + } + break; + case 3: + { + localContext = new MysqlVariableExpressionAtomContext(localContext); + this.context = localContext; + previousContext = localContext; + this.state = 7892; + this.mysqlVariable(); + } + break; + case 4: + { + localContext = new UnaryExpressionAtomContext(localContext); + this.context = localContext; + previousContext = localContext; + this.state = 7893; + this.unaryOperator(); + this.state = 7894; + this.expressionAtom(12); + } + break; + case 5: + { + localContext = new BinaryExpressionAtomContext(localContext); + this.context = localContext; + previousContext = localContext; + this.state = 7896; + this.match(MySqlParser.KW_BINARY); + this.state = 7897; + this.expressionAtom(11); + } + break; + case 6: + { + localContext = new VariableAssignExpressionAtomContext(localContext); + this.context = localContext; + previousContext = localContext; + this.state = 7898; + this.match(MySqlParser.LOCAL_ID); + this.state = 7899; + this.match(MySqlParser.VAR_ASSIGN); + this.state = 7900; + this.expressionAtom(10); + } + break; + case 7: + { + localContext = new NestedExpressionAtomContext(localContext); + this.context = localContext; + previousContext = localContext; + this.state = 7901; + this.match(MySqlParser.LR_BRACKET); + this.state = 7902; + this.expression(0); + this.state = 7907; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 868) { + { + { + this.state = 7903; + this.match(MySqlParser.COMMA); + this.state = 7904; + this.expression(0); + } + } + this.state = 7909; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 7910; + this.match(MySqlParser.RR_BRACKET); + } + break; + case 8: + { + localContext = new NestedRowExpressionAtomContext(localContext); + this.context = localContext; + previousContext = localContext; + this.state = 7912; + this.match(MySqlParser.KW_ROW); + this.state = 7913; + this.match(MySqlParser.LR_BRACKET); + this.state = 7914; + this.expression(0); + this.state = 7917; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + do { + { + { + this.state = 7915; + this.match(MySqlParser.COMMA); + this.state = 7916; + this.expression(0); + } + } + this.state = 7919; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } while (_la === 868); + this.state = 7921; + this.match(MySqlParser.RR_BRACKET); + } + break; + case 9: + { + localContext = new ExistsExpressionAtomContext(localContext); + this.context = localContext; + previousContext = localContext; + this.state = 7923; + this.match(MySqlParser.KW_EXISTS); + this.state = 7924; + this.match(MySqlParser.LR_BRACKET); + this.state = 7925; + this.selectStatement(); + this.state = 7926; + this.match(MySqlParser.RR_BRACKET); + } + break; + case 10: + { + localContext = new SubqueryExpressionAtomContext(localContext); + this.context = localContext; + previousContext = localContext; + this.state = 7928; + this.match(MySqlParser.LR_BRACKET); + this.state = 7929; + this.selectStatement(); + this.state = 7930; + this.match(MySqlParser.RR_BRACKET); + } + break; + case 11: + { + localContext = new IntervalExpressionAtomContext(localContext); + this.context = localContext; + previousContext = localContext; + this.state = 7932; + this.match(MySqlParser.KW_INTERVAL); + this.state = 7933; + this.expression(0); + this.state = 7934; + this.intervalType(); + } + break; + case 12: + { + localContext = new ColumnNameExpressionAtomContext(localContext); + this.context = localContext; + previousContext = localContext; + this.state = 7936; + this.columnName(); + } + break; + } + this.context.stop = this.tokenStream.LT(-1); + this.state = 7956; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 1148, this.context); + while (alternative !== 2 && alternative !== antlr.ATN.INVALID_ALT_NUMBER) { + if (alternative === 1) { + if (this._parseListeners != null) { + this.triggerExitRuleEvent(); + } + previousContext = localContext; + { + this.state = 7954; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1147, this.context)) { + case 1: + { + localContext = new JsonExpressionAtomContext(new ExpressionAtomContext(parentContext, parentState)); + localContext._left = previousContext; + this.pushNewRecursionContext(localContext, _startState, MySqlParser.RULE_expressionAtom); + this.state = 7939; + if (!(this.precpred(this.context, 4))) { + throw this.createFailedPredicateException("this.precpred(this.context, 4)"); + } + this.state = 7940; + this.jsonOperator(); + this.state = 7941; + localContext._right = this.expressionAtom(5); + } + break; + case 2: + { + localContext = new BitExpressionAtomContext(new ExpressionAtomContext(parentContext, parentState)); + localContext._left = previousContext; + this.pushNewRecursionContext(localContext, _startState, MySqlParser.RULE_expressionAtom); + this.state = 7943; + if (!(this.precpred(this.context, 3))) { + throw this.createFailedPredicateException("this.precpred(this.context, 3)"); + } + this.state = 7944; + this.bitOperator(); + this.state = 7945; + localContext._right = this.expressionAtom(4); + } + break; + case 3: + { + localContext = new MathExpressionAtomContext(new ExpressionAtomContext(parentContext, parentState)); + localContext._left = previousContext; + this.pushNewRecursionContext(localContext, _startState, MySqlParser.RULE_expressionAtom); + this.state = 7947; + if (!(this.precpred(this.context, 2))) { + throw this.createFailedPredicateException("this.precpred(this.context, 2)"); + } + this.state = 7948; + this.mathOperator(); + this.state = 7949; + localContext._right = this.expressionAtom(3); + } + break; + case 4: + { + localContext = new CollateExpressionAtomContext(new ExpressionAtomContext(parentContext, parentState)); + this.pushNewRecursionContext(localContext, _startState, MySqlParser.RULE_expressionAtom); + this.state = 7951; + if (!(this.precpred(this.context, 14))) { + throw this.createFailedPredicateException("this.precpred(this.context, 14)"); + } + this.state = 7952; + this.match(MySqlParser.KW_COLLATE); + this.state = 7953; + this.collationName(); + } + break; + } + } + } + this.state = 7958; + this.errorHandler.sync(this); + alternative = this.interpreter.adaptivePredict(this.tokenStream, 1148, this.context); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.unrollRecursionContexts(parentContext); + } + return localContext; + } + unaryOperator() { + let localContext = new UnaryOperatorContext(this.context, this.state); + this.enterRule(localContext, 806, MySqlParser.RULE_unaryOperator); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 7959; + _la = this.tokenStream.LA(1); + if (!(_la === 114 || ((((_la - 853)) & ~0x1F) === 0 && ((1 << (_la - 853)) & 387) !== 0))) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + comparisonOperator() { + let localContext = new ComparisonOperatorContext(this.context, this.state); + this.enterRule(localContext, 808, MySqlParser.RULE_comparisonOperator); + try { + this.state = 7969; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1149, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 7961; + this.match(MySqlParser.LESS_SYMBOL); + this.state = 7962; + this.match(MySqlParser.GREATER_SYMBOL); + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 7963; + this.match(MySqlParser.EXCLAMATION_SYMBOL); + this.state = 7964; + this.match(MySqlParser.EQUAL_SYMBOL); + } + break; + case 3: + this.enterOuterAlt(localContext, 3); + { + this.state = 7965; + this.match(MySqlParser.LESS_SYMBOL); + this.state = 7966; + this.match(MySqlParser.EQUAL_SYMBOL); + this.state = 7967; + this.match(MySqlParser.GREATER_SYMBOL); + } + break; + case 4: + this.enterOuterAlt(localContext, 4); + { + this.state = 7968; + this.comparisonBase(); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + comparisonBase() { + let localContext = new ComparisonBaseContext(this.context, this.state); + this.enterRule(localContext, 810, MySqlParser.RULE_comparisonBase); + try { + this.state = 7978; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1150, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 7971; + this.match(MySqlParser.LESS_SYMBOL); + this.state = 7972; + this.match(MySqlParser.EQUAL_SYMBOL); + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 7973; + this.match(MySqlParser.GREATER_SYMBOL); + this.state = 7974; + this.match(MySqlParser.EQUAL_SYMBOL); + } + break; + case 3: + this.enterOuterAlt(localContext, 3); + { + this.state = 7975; + this.match(MySqlParser.EQUAL_SYMBOL); + } + break; + case 4: + this.enterOuterAlt(localContext, 4); + { + this.state = 7976; + this.match(MySqlParser.GREATER_SYMBOL); + } + break; + case 5: + this.enterOuterAlt(localContext, 5); + { + this.state = 7977; + this.match(MySqlParser.LESS_SYMBOL); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + logicalOperator() { + let localContext = new LogicalOperatorContext(this.context, this.state); + this.enterRule(localContext, 812, MySqlParser.RULE_logicalOperator); + try { + this.state = 7987; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.KW_AND: + this.enterOuterAlt(localContext, 1); + { + this.state = 7980; + this.match(MySqlParser.KW_AND); + } + break; + case MySqlParser.BIT_AND_OP: + this.enterOuterAlt(localContext, 2); + { + this.state = 7981; + this.match(MySqlParser.BIT_AND_OP); + this.state = 7982; + this.match(MySqlParser.BIT_AND_OP); + } + break; + case MySqlParser.KW_XOR: + this.enterOuterAlt(localContext, 3); + { + this.state = 7983; + this.match(MySqlParser.KW_XOR); + } + break; + case MySqlParser.KW_OR: + this.enterOuterAlt(localContext, 4); + { + this.state = 7984; + this.match(MySqlParser.KW_OR); + } + break; + case MySqlParser.BIT_OR_OP: + this.enterOuterAlt(localContext, 5); + { + this.state = 7985; + this.match(MySqlParser.BIT_OR_OP); + this.state = 7986; + this.match(MySqlParser.BIT_OR_OP); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + bitOperator() { + let localContext = new BitOperatorContext(this.context, this.state); + this.enterRule(localContext, 814, MySqlParser.RULE_bitOperator); + try { + this.state = 7996; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case MySqlParser.LESS_SYMBOL: + this.enterOuterAlt(localContext, 1); + { + this.state = 7989; + this.match(MySqlParser.LESS_SYMBOL); + this.state = 7990; + this.match(MySqlParser.LESS_SYMBOL); + } + break; + case MySqlParser.GREATER_SYMBOL: + this.enterOuterAlt(localContext, 2); + { + this.state = 7991; + this.match(MySqlParser.GREATER_SYMBOL); + this.state = 7992; + this.match(MySqlParser.GREATER_SYMBOL); + } + break; + case MySqlParser.BIT_AND_OP: + this.enterOuterAlt(localContext, 3); + { + this.state = 7993; + this.match(MySqlParser.BIT_AND_OP); + } + break; + case MySqlParser.BIT_XOR_OP: + this.enterOuterAlt(localContext, 4); + { + this.state = 7994; + this.match(MySqlParser.BIT_XOR_OP); + } + break; + case MySqlParser.BIT_OR_OP: + this.enterOuterAlt(localContext, 5); + { + this.state = 7995; + this.match(MySqlParser.BIT_OR_OP); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + mathOperator() { + let localContext = new MathOperatorContext(this.context, this.state); + this.enterRule(localContext, 816, MySqlParser.RULE_mathOperator); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 7998; + _la = this.tokenStream.LA(1); + if (!(((((_la - 850)) & ~0x1F) === 0 && ((1 << (_la - 850)) & 127) !== 0))) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + jsonOperator() { + let localContext = new JsonOperatorContext(this.context, this.state); + this.enterRule(localContext, 818, MySqlParser.RULE_jsonOperator); + try { + this.state = 8005; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 1153, this.context)) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 8000; + this.match(MySqlParser.MINUS); + this.state = 8001; + this.match(MySqlParser.GREATER_SYMBOL); + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 8002; + this.match(MySqlParser.MINUS); + this.state = 8003; + this.match(MySqlParser.GREATER_SYMBOL); + this.state = 8004; + this.match(MySqlParser.GREATER_SYMBOL); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + charsetNameBase() { + let localContext = new CharsetNameBaseContext(this.context, this.state); + this.enterRule(localContext, 820, MySqlParser.RULE_charsetNameBase); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 8007; + _la = this.tokenStream.LA(1); + if (!(_la === 228 || ((((_la - 756)) & ~0x1F) === 0 && ((1 << (_la - 756)) & 4294967295) !== 0) || ((((_la - 788)) & ~0x1F) === 0 && ((1 << (_la - 788)) & 511) !== 0))) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + transactionLevelBase() { + let localContext = new TransactionLevelBaseContext(this.context, this.state); + this.enterRule(localContext, 822, MySqlParser.RULE_transactionLevelBase); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 8009; + _la = this.tokenStream.LA(1); + if (!(((((_la - 809)) & ~0x1F) === 0 && ((1 << (_la - 809)) & 15) !== 0))) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + privilegesBase() { + let localContext = new PrivilegesBaseContext(this.context, this.state); + this.enterRule(localContext, 824, MySqlParser.RULE_privilegesBase); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 8011; + _la = this.tokenStream.LA(1); + if (!(((((_la - 717)) & ~0x1F) === 0 && ((1 << (_la - 717)) & 68026371) !== 0) || ((((_la - 749)) & ~0x1F) === 0 && ((1 << (_la - 749)) & 11) !== 0))) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + intervalTypeBase() { + let localContext = new IntervalTypeBaseContext(this.context, this.state); + this.enterRule(localContext, 826, MySqlParser.RULE_intervalTypeBase); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 8013; + _la = this.tokenStream.LA(1); + if (!(((((_la - 696)) & ~0x1F) === 0 && ((1 << (_la - 696)) & 255) !== 0))) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + dataTypeBase() { + let localContext = new DataTypeBaseContext(this.context, this.state); + this.enterRule(localContext, 828, MySqlParser.RULE_dataTypeBase); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 8015; + _la = this.tokenStream.LA(1); + if (!(((((_la - 219)) & ~0x1F) === 0 && ((1 << (_la - 219)) & 1179679) !== 0))) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + keywordsCanBeId() { + let localContext = new KeywordsCanBeIdContext(this.context, this.state); + this.enterRule(localContext, 830, MySqlParser.RULE_keywordsCanBeId); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 8017; + _la = this.tokenStream.LA(1); + if (!((((_la) & ~0x1F) === 0 && ((1 << _la) & 1074302976) !== 0) || ((((_la - 36)) & ~0x1F) === 0 && ((1 << (_la - 36)) & 11014211) !== 0) || _la === 74 || _la === 95 || ((((_la - 117)) & ~0x1F) === 0 && ((1 << (_la - 117)) & 16673) !== 0) || _la === 160 || _la === 170 || ((((_la - 241)) & ~0x1F) === 0 && ((1 << (_la - 241)) & 1648345089) !== 0) || ((((_la - 277)) & ~0x1F) === 0 && ((1 << (_la - 277)) & 4160749823) !== 0) || ((((_la - 309)) & ~0x1F) === 0 && ((1 << (_la - 309)) & 4292870141) !== 0) || ((((_la - 341)) & ~0x1F) === 0 && ((1 << (_la - 341)) & 4294967287) !== 0) || ((((_la - 373)) & ~0x1F) === 0 && ((1 << (_la - 373)) & 4024434671) !== 0) || ((((_la - 406)) & ~0x1F) === 0 && ((1 << (_la - 406)) & 3747609503) !== 0) || ((((_la - 438)) & ~0x1F) === 0 && ((1 << (_la - 438)) & 4227727359) !== 0) || ((((_la - 470)) & ~0x1F) === 0 && ((1 << (_la - 470)) & 3758096239) !== 0) || ((((_la - 502)) & ~0x1F) === 0 && ((1 << (_la - 502)) & 2678062559) !== 0) || ((((_la - 534)) & ~0x1F) === 0 && ((1 << (_la - 534)) & 2682256863) !== 0) || ((((_la - 566)) & ~0x1F) === 0 && ((1 << (_la - 566)) & 4294957695) !== 0) || ((((_la - 598)) & ~0x1F) === 0 && ((1 << (_la - 598)) & 255) !== 0) || ((((_la - 633)) & ~0x1F) === 0 && ((1 << (_la - 633)) & 4294934527) !== 0) || ((((_la - 665)) & ~0x1F) === 0 && ((1 << (_la - 665)) & 2128608253) !== 0) || ((((_la - 704)) & ~0x1F) === 0 && ((1 << (_la - 704)) & 1053007341) !== 0) || ((((_la - 737)) & ~0x1F) === 0 && ((1 << (_la - 737)) & 478907) !== 0) || ((((_la - 802)) & ~0x1F) === 0 && ((1 << (_la - 802)) & 3230662657) !== 0) || _la === 838)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + functionNameBase() { + let localContext = new FunctionNameBaseContext(this.context, this.state); + this.enterRule(localContext, 832, MySqlParser.RULE_functionNameBase); + let _la; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 8019; + _la = this.tokenStream.LA(1); + if (!(_la === 39 || _la === 98 || _la === 150 || _la === 152 || ((((_la - 219)) & ~0x1F) === 0 && ((1 << (_la - 219)) & 23) !== 0) || ((((_la - 253)) & ~0x1F) === 0 && ((1 << (_la - 253)) & 16375299) !== 0) || _la === 296 || _la === 435 || ((((_la - 686)) & ~0x1F) === 0 && ((1 << (_la - 686)) & 261121) !== 0) || _la === 746 || ((((_la - 813)) & ~0x1F) === 0 && ((1 << (_la - 813)) & 145190393) !== 0) || _la === 856)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + localContext.exception = re; + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } + else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + sempred(localContext, ruleIndex, predIndex) { + switch (ruleIndex) { + case 104: + return this.queryExpressionBody_sempred(localContext, predIndex); + case 105: + return this.queryItem_sempred(localContext, predIndex); + case 329: + return this.columnName_sempred(localContext, predIndex); + case 400: + return this.expression_sempred(localContext, predIndex); + case 401: + return this.predicate_sempred(localContext, predIndex); + case 402: + return this.expressionAtom_sempred(localContext, predIndex); + } + return true; + } + queryExpressionBody_sempred(localContext, predIndex) { + switch (predIndex) { + case 0: + return this.precpred(this.context, 2); + case 1: + return this.precpred(this.context, 1); + } + return true; + } + queryItem_sempred(localContext, predIndex) { + switch (predIndex) { + case 2: + return this.precpred(this.context, 1); + } + return true; + } + columnName_sempred(localContext, predIndex) { + switch (predIndex) { + case 3: + return this.shouldMatchEmpty(); + } + return true; + } + expression_sempred(localContext, predIndex) { + switch (predIndex) { + case 4: + return this.precpred(this.context, 3); + } + return true; + } + predicate_sempred(localContext, predIndex) { + switch (predIndex) { + case 5: + return this.precpred(this.context, 6); + case 6: + return this.precpred(this.context, 5); + case 7: + return this.precpred(this.context, 3); + case 8: + return this.precpred(this.context, 9); + case 9: + return this.precpred(this.context, 8); + case 10: + return this.precpred(this.context, 7); + case 11: + return this.precpred(this.context, 4); + case 12: + return this.precpred(this.context, 2); + } + return true; + } + expressionAtom_sempred(localContext, predIndex) { + switch (predIndex) { + case 13: + return this.precpred(this.context, 4); + case 14: + return this.precpred(this.context, 3); + case 15: + return this.precpred(this.context, 2); + case 16: + return this.precpred(this.context, 14); + } + return true; + } + static get _ATN() { + if (!MySqlParser.__ATN) { + MySqlParser.__ATN = new antlr.ATNDeserializer().deserialize(MySqlParser._serializedATN); + } + return MySqlParser.__ATN; + } + get vocabulary() { + return MySqlParser.vocabulary; + } +} + +export { MySqlParser }; \ No newline at end of file diff --git a/test/form/samples/object-tree-shaking-with-this/_config.js b/test/form/samples/object-tree-shaking-with-this/_config.js new file mode 100644 index 00000000000..e1fe0364621 --- /dev/null +++ b/test/form/samples/object-tree-shaking-with-this/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'include the properties that accessed by this' +}); diff --git a/test/form/samples/object-tree-shaking-with-this/_expected.js b/test/form/samples/object-tree-shaking-with-this/_expected.js new file mode 100644 index 00000000000..e15dd4147f2 --- /dev/null +++ b/test/form/samples/object-tree-shaking-with-this/_expected.js @@ -0,0 +1,15 @@ +const config = { + recipients: { ALL: 'all'}, + + get recipientsList() { + return [ + { + value: this.recipients.ALL + } + ]; + } +}; + +var main = config.recipientsList; + +export { main as default }; diff --git a/test/form/samples/object-tree-shaking-with-this/main.js b/test/form/samples/object-tree-shaking-with-this/main.js new file mode 100644 index 00000000000..407f1c673e9 --- /dev/null +++ b/test/form/samples/object-tree-shaking-with-this/main.js @@ -0,0 +1,13 @@ +const config = { + recipients: { ALL: 'all', TEAM: 'team' }, + + get recipientsList() { + return [ + { + value: this.recipients.ALL + } + ]; + } +}; + +export default config.recipientsList; diff --git a/test/form/samples/optimization-in-operator/_config.js b/test/form/samples/optimization-in-operator/_config.js new file mode 100644 index 00000000000..8af6c86c0d4 --- /dev/null +++ b/test/form/samples/optimization-in-operator/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'keep foo structure' +}); diff --git a/test/form/samples/optimization-in-operator/_expected.js b/test/form/samples/optimization-in-operator/_expected.js new file mode 100644 index 00000000000..3972a98fbc9 --- /dev/null +++ b/test/form/samples/optimization-in-operator/_expected.js @@ -0,0 +1,11 @@ +var foo = { + a: 1, + b: 1 +}; + +function check(name) { + if (name in foo) return true; + return false; +} + +export { check as default }; diff --git a/test/form/samples/optimization-in-operator/foo.js b/test/form/samples/optimization-in-operator/foo.js new file mode 100644 index 00000000000..49e5cbbe0e9 --- /dev/null +++ b/test/form/samples/optimization-in-operator/foo.js @@ -0,0 +1,4 @@ +export default { + a: 1, + b: 1 +}; diff --git a/test/form/samples/optimization-in-operator/main.js b/test/form/samples/optimization-in-operator/main.js new file mode 100644 index 00000000000..5e30a2f4012 --- /dev/null +++ b/test/form/samples/optimization-in-operator/main.js @@ -0,0 +1,6 @@ +import foo from './foo'; + +export default function check(name) { + if (name in foo) return true; + return false; +} diff --git a/test/form/samples/optional-chaining-missing-properties/_config.js b/test/form/samples/optional-chaining-missing-properties/_config.js new file mode 100644 index 00000000000..7cf7fdda381 --- /dev/null +++ b/test/form/samples/optional-chaining-missing-properties/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'supports optional chaining for missing properties' +}); diff --git a/test/form/samples/optional-chaining-missing-properties/_expected.js b/test/form/samples/optional-chaining-missing-properties/_expected.js new file mode 100644 index 00000000000..e3a8b0c0f21 --- /dev/null +++ b/test/form/samples/optional-chaining-missing-properties/_expected.js @@ -0,0 +1,8 @@ +Object.defineProperty(Object.prototype, 'foo', { + get bar() { + console.log('effect'); + } +}); +const obj2 = {}; +obj2.foo?.bar; +obj2.foo?.(); diff --git a/test/form/samples/optional-chaining-missing-properties/main.js b/test/form/samples/optional-chaining-missing-properties/main.js new file mode 100644 index 00000000000..8486b9dc344 --- /dev/null +++ b/test/form/samples/optional-chaining-missing-properties/main.js @@ -0,0 +1,13 @@ +const obj = { __proto__: null }; +obj?.foo; +obj.foo?.bar; +obj.foo?.(); + +Object.defineProperty(Object.prototype, 'foo', { + get bar() { + console.log('effect'); + } +}); +const obj2 = {}; +obj2.foo?.bar; +obj2.foo?.(); diff --git a/test/form/samples/optional-chaining-namespace/_config.js b/test/form/samples/optional-chaining-namespace/_config.js new file mode 100644 index 00000000000..2d1ba8212d1 --- /dev/null +++ b/test/form/samples/optional-chaining-namespace/_config.js @@ -0,0 +1,4 @@ +module.exports = defineTest({ + description: 'supports optional chaining with namespace objects', + expectedWarnings: ['MISSING_EXPORT'] +}); diff --git a/test/form/samples/optional-chaining-namespace/_expected.js b/test/form/samples/optional-chaining-namespace/_expected.js new file mode 100644 index 00000000000..3a638fc2eee --- /dev/null +++ b/test/form/samples/optional-chaining-namespace/_expected.js @@ -0,0 +1,5 @@ +const foo = { }; + +foo?.x.x; // retained + +undefined.x; // retained diff --git a/test/form/samples/optional-chaining-namespace/main.js b/test/form/samples/optional-chaining-namespace/main.js new file mode 100644 index 00000000000..6a508f0889a --- /dev/null +++ b/test/form/samples/optional-chaining-namespace/main.js @@ -0,0 +1,32 @@ +import * as util from './util'; + +util.foo.x; // removed +util.foo.nullVal; // removed +util.foo.nullVal?.x; // removed +util.foo.nullVal?.x.y; // removed +util.foo.nullVal?.(); // removed +util.foo.nullVal?.().x(); // removed + +util.foo?.x.x; // retained + +util.x; // removed +util.x?.x; // removed +util.x?.x.y; // removed +util.x?.(); // removed +util.x?.().x(); // removed + +util?.x.x; // retained + +if ( + util.foo.nullVal || + util.foo.nullVal?.x || + util.foo.nullVal?.x.y || + util.foo.nullVal?.() || + util.foo.nullVal?.().x() +) { + console.log('removed'); +} + +if (util.x || util.x?.x || util.x?.x.y || util.x?.() || util.x?.().x()) { + console.log('removed'); +} diff --git a/test/form/samples/optional-chaining-namespace/util.js b/test/form/samples/optional-chaining-namespace/util.js new file mode 100644 index 00000000000..713a707aeba --- /dev/null +++ b/test/form/samples/optional-chaining-namespace/util.js @@ -0,0 +1 @@ +export const foo = { nullVal: null }; diff --git a/test/form/samples/optional-chaining-null-values/_config.js b/test/form/samples/optional-chaining-null-values/_config.js new file mode 100644 index 00000000000..0dab3beeee3 --- /dev/null +++ b/test/form/samples/optional-chaining-null-values/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'supports optional chaining for null values' +}); diff --git a/test/form/samples/optional-chaining-null-values/_expected.js b/test/form/samples/optional-chaining-null-values/_expected.js new file mode 100644 index 00000000000..6f84fbb138f --- /dev/null +++ b/test/form/samples/optional-chaining-null-values/_expected.js @@ -0,0 +1,12 @@ +const obj = { + nullValue: null, + undefinedValue: undefined, + method() { + return { nullValue: null }; + } +}; +obj?.nullValue.foo; // retained +obj?.nullValue(); // retained +obj?.nullValue(console.log('effect')); // retained +obj.method?.(console.log('effect')); // retained +obj?.method(console.log('effect')); // retained diff --git a/test/form/samples/optional-chaining-null-values/main.js b/test/form/samples/optional-chaining-null-values/main.js new file mode 100644 index 00000000000..b28de628fc1 --- /dev/null +++ b/test/form/samples/optional-chaining-null-values/main.js @@ -0,0 +1,24 @@ +const obj = { + nullValue: null, + undefinedValue: undefined, + method() { + return { nullValue: null }; + } +}; + +obj.nullValue?.foo; // removed +obj?.nullValue.foo; // retained +obj.nullValue?.(); // removed +obj.nullValue?.(console.log('effect')); // removed +obj?.nullValue(); // retained +obj?.nullValue(console.log('effect')); // retained +obj.method?.(); // removed +obj.method?.(console.log('effect')); // retained +obj?.method(); // removed +obj?.method(console.log('effect')); // retained +obj.method().nullValue?.foo; // removed +obj.method().nullValue?.(); // removed +obj.method().nullValue?.(console.log('effect')); // removed +(true && obj.nullValue)?.foo; // removed +(true && obj.nullValue)?.(); // removed +(true && obj.nullValue)?.(console.log('effect')); // removed diff --git a/test/form/samples/optional-chaining-with-smallest-treeshake/_config.js b/test/form/samples/optional-chaining-with-smallest-treeshake/_config.js new file mode 100644 index 00000000000..77e5235b771 --- /dev/null +++ b/test/form/samples/optional-chaining-with-smallest-treeshake/_config.js @@ -0,0 +1,6 @@ +module.exports = defineTest({ + description: 'preserve optional chaining with smallest treeshake', + options: { + treeshake: 'smallest' + } +}); diff --git a/test/form/samples/optional-chaining-with-smallest-treeshake/_expected.js b/test/form/samples/optional-chaining-with-smallest-treeshake/_expected.js new file mode 100644 index 00000000000..f16a8cdef24 --- /dev/null +++ b/test/form/samples/optional-chaining-with-smallest-treeshake/_expected.js @@ -0,0 +1,2 @@ +while (global[++i]?.key) {} //retained +while (global(++i)?.key) {} //retained diff --git a/test/form/samples/optional-chaining-with-smallest-treeshake/main.js b/test/form/samples/optional-chaining-with-smallest-treeshake/main.js new file mode 100644 index 00000000000..f16a8cdef24 --- /dev/null +++ b/test/form/samples/optional-chaining-with-smallest-treeshake/main.js @@ -0,0 +1,2 @@ +while (global[++i]?.key) {} //retained +while (global(++i)?.key) {} //retained diff --git a/test/form/samples/optional-chaining/_config.js b/test/form/samples/optional-chaining/_config.js deleted file mode 100644 index bce6f6fb4b3..00000000000 --- a/test/form/samples/optional-chaining/_config.js +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = { - description: 'supports optional chaining' -}; diff --git a/test/form/samples/optional-chaining/_expected.js b/test/form/samples/optional-chaining/_expected.js deleted file mode 100644 index 3f65cf02583..00000000000 --- a/test/form/samples/optional-chaining/_expected.js +++ /dev/null @@ -1,3 +0,0 @@ -const obj = {}; -obj.foo?.bar; -obj.foo?.(); diff --git a/test/form/samples/optional-chaining/main.js b/test/form/samples/optional-chaining/main.js deleted file mode 100644 index 4f6aab57e58..00000000000 --- a/test/form/samples/optional-chaining/main.js +++ /dev/null @@ -1,4 +0,0 @@ -const obj = {}; -obj?.foo -obj.foo?.bar; -obj.foo?.(); diff --git a/test/form/samples/output-named-library/_config.js b/test/form/samples/output-named-library/_config.js index 87c12fd58dd..4acdc45e007 100644 --- a/test/form/samples/output-named-library/_config.js +++ b/test/form/samples/output-named-library/_config.js @@ -1,8 +1,8 @@ -module.exports = { +module.exports = defineTest({ description: 'names bundles correctly', options: { output: { - name: 'libraryName', - }, + name: 'libraryName' + } } -}; +}); diff --git a/test/form/samples/output-named-library/_expected/amd.js b/test/form/samples/output-named-library/_expected/amd.js index 97d0f9e6b75..2d2b0559bd8 100644 --- a/test/form/samples/output-named-library/_expected/amd.js +++ b/test/form/samples/output-named-library/_expected/amd.js @@ -1,9 +1,7 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; const valueOnLib = 42; exports.valueOnLib = valueOnLib; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/form/samples/output-named-library/_expected/cjs.js b/test/form/samples/output-named-library/_expected/cjs.js index 9b595a69c87..45a2994456d 100644 --- a/test/form/samples/output-named-library/_expected/cjs.js +++ b/test/form/samples/output-named-library/_expected/cjs.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - const valueOnLib = 42; exports.valueOnLib = valueOnLib; diff --git a/test/form/samples/output-named-library/_expected/iife.js b/test/form/samples/output-named-library/_expected/iife.js index 27d919720ab..d1cd25a943f 100644 --- a/test/form/samples/output-named-library/_expected/iife.js +++ b/test/form/samples/output-named-library/_expected/iife.js @@ -5,8 +5,6 @@ var libraryName = (function (exports) { exports.valueOnLib = valueOnLib; - Object.defineProperty(exports, '__esModule', { value: true }); - return exports; -}({})); +})({}); diff --git a/test/form/samples/output-named-library/_expected/system.js b/test/form/samples/output-named-library/_expected/system.js index c4835fad6ef..b6ef0ccc282 100644 --- a/test/form/samples/output-named-library/_expected/system.js +++ b/test/form/samples/output-named-library/_expected/system.js @@ -1,10 +1,10 @@ -System.register('libraryName', [], function (exports) { +System.register('libraryName', [], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - const valueOnLib = exports('valueOnLib', 42); + const valueOnLib = exports("valueOnLib", 42); - } + }) }; -}); +})); diff --git a/test/form/samples/output-named-library/_expected/umd.js b/test/form/samples/output-named-library/_expected/umd.js index 1f51cad3cb7..144735e8bc0 100644 --- a/test/form/samples/output-named-library/_expected/umd.js +++ b/test/form/samples/output-named-library/_expected/umd.js @@ -2,12 +2,10 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.libraryName = {})); -}(this, (function (exports) { 'use strict'; +})(this, (function (exports) { 'use strict'; const valueOnLib = 42; exports.valueOnLib = valueOnLib; - Object.defineProperty(exports, '__esModule', { value: true }); - -}))); +})); diff --git a/test/form/samples/override-external-namespace/_config.js b/test/form/samples/override-external-namespace/_config.js index 9fcd9fb2c12..c33580bec8d 100644 --- a/test/form/samples/override-external-namespace/_config.js +++ b/test/form/samples/override-external-namespace/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'allows overriding imports of external namespace reexports', options: { external: 'external', @@ -7,4 +7,4 @@ module.exports = { globals: { external: 'external' } } } -}; +}); diff --git a/test/form/samples/override-external-namespace/_expected/amd.js b/test/form/samples/override-external-namespace/_expected/amd.js index 59cf2532751..0fd38830771 100644 --- a/test/form/samples/override-external-namespace/_expected/amd.js +++ b/test/form/samples/override-external-namespace/_expected/amd.js @@ -1,4 +1,4 @@ -define(['exports', 'external'], function (exports, external) { 'use strict'; +define(['exports', 'external'], (function (exports, external) { 'use strict'; const a = 'defined'; exports.b = void 0; @@ -9,14 +9,10 @@ define(['exports', 'external'], function (exports, external) { 'use strict'; exports.c = c; exports.reassign = reassign; Object.keys(external).forEach(function (k) { - if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, { + if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, { enumerable: true, - get: function () { - return external[k]; - } + get: function () { return external[k]; } }); }); - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/form/samples/override-external-namespace/_expected/cjs.js b/test/form/samples/override-external-namespace/_expected/cjs.js index 8d1e3ca2cea..4ad2f0ee1f1 100644 --- a/test/form/samples/override-external-namespace/_expected/cjs.js +++ b/test/form/samples/override-external-namespace/_expected/cjs.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - var external = require('external'); const a = 'defined'; @@ -13,10 +11,8 @@ exports.a = a; exports.c = c; exports.reassign = reassign; Object.keys(external).forEach(function (k) { - if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, { + if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, { enumerable: true, - get: function () { - return external[k]; - } + get: function () { return external[k]; } }); }); diff --git a/test/form/samples/override-external-namespace/_expected/iife.js b/test/form/samples/override-external-namespace/_expected/iife.js index 13f2f93e7f3..29afddfc137 100644 --- a/test/form/samples/override-external-namespace/_expected/iife.js +++ b/test/form/samples/override-external-namespace/_expected/iife.js @@ -10,16 +10,12 @@ var bundle = (function (exports, external) { exports.c = c; exports.reassign = reassign; Object.keys(external).forEach(function (k) { - if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, { + if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, { enumerable: true, - get: function () { - return external[k]; - } + get: function () { return external[k]; } }); }); - Object.defineProperty(exports, '__esModule', { value: true }); - return exports; -}({}, external)); +})({}, external); diff --git a/test/form/samples/override-external-namespace/_expected/system.js b/test/form/samples/override-external-namespace/_expected/system.js index 1ef69adff58..eae64e78971 100644 --- a/test/form/samples/override-external-namespace/_expected/system.js +++ b/test/form/samples/override-external-namespace/_expected/system.js @@ -1,26 +1,28 @@ -System.register('bundle', ['external'], function (exports) { +System.register('bundle', ['external'], (function (exports) { 'use strict'; - var _starExcludes = { a: 1, b: 1, c: 1, reassign: 1, default: 1 }; + var _starExcludes = { + __proto__: null, + a: 1, + b: 1, + c: 1, + reassign: 1, + default: 1 + }; return { setters: [function (module) { - var _setter = {}; - for (var _$p in module) { - if (!_starExcludes[_$p]) _setter[_$p] = module[_$p]; + var setter = { __proto__: null }; + for (var name in module) { + if (!_starExcludes[name]) setter[name] = module[name]; } - exports(_setter); + exports(setter); }], - execute: function () { - - exports({ - b: void 0, - c: void 0 - }); + execute: (function () { - const a = exports('a', 'defined'); - let b; - var c; - const reassign = exports('reassign', () => (b = exports('b', 'defined'))); + const a = exports("a", 'defined'); + let b; exports("b", b); + var c; exports("c", c); + const reassign = exports("reassign", () => (exports("b", b = 'defined'))); - } + }) }; -}); +})); diff --git a/test/form/samples/override-external-namespace/_expected/umd.js b/test/form/samples/override-external-namespace/_expected/umd.js index cf25f11641e..cc05b0d9f66 100644 --- a/test/form/samples/override-external-namespace/_expected/umd.js +++ b/test/form/samples/override-external-namespace/_expected/umd.js @@ -2,7 +2,7 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('external')) : typeof define === 'function' && define.amd ? define(['exports', 'external'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.bundle = {}, global.external)); -}(this, (function (exports, external) { 'use strict'; +})(this, (function (exports, external) { 'use strict'; const a = 'defined'; exports.b = void 0; @@ -13,14 +13,10 @@ exports.c = c; exports.reassign = reassign; Object.keys(external).forEach(function (k) { - if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, { + if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, { enumerable: true, - get: function () { - return external[k]; - } + get: function () { return external[k]; } }); }); - Object.defineProperty(exports, '__esModule', { value: true }); - -}))); +})); diff --git a/test/form/samples/paths-function/_config.js b/test/form/samples/paths-function/_config.js index 726db0d85e4..8774240954f 100644 --- a/test/form/samples/paths-function/_config.js +++ b/test/form/samples/paths-function/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'external paths (#754)', options: { external: ['foo'], @@ -7,4 +7,4 @@ module.exports = { paths: id => `https://unpkg.com/${id}` } } -}; +}); diff --git a/test/form/samples/paths-function/_expected/amd.js b/test/form/samples/paths-function/_expected/amd.js index ecf9c2e3193..66f042c62a6 100644 --- a/test/form/samples/paths-function/_expected/amd.js +++ b/test/form/samples/paths-function/_expected/amd.js @@ -1,9 +1,6 @@ -define(['require', 'https://unpkg.com/foo'], function (require, foo) { 'use strict'; +define(['require', 'https://unpkg.com/foo'], (function (require, foo) { 'use strict'; - function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } - - function _interopNamespace(e) { - if (e && e.__esModule) return e; + function _interopNamespaceDefault(e) { var n = Object.create(null); if (e) { Object.keys(e).forEach(function (k) { @@ -11,21 +8,17 @@ define(['require', 'https://unpkg.com/foo'], function (require, foo) { 'use stri var d = Object.getOwnPropertyDescriptor(e, k); Object.defineProperty(n, k, d.get ? d : { enumerable: true, - get: function () { - return e[k]; - } + get: function () { return e[k]; } }); } }); } - n['default'] = e; + n.default = e; return Object.freeze(n); } - var foo__default = /*#__PURE__*/_interopDefaultLegacy(foo); - - assert.equal(foo__default['default'], 42); + assert.equal(foo, 42); - new Promise(function (resolve, reject) { require(['https://unpkg.com/foo'], function (m) { resolve(/*#__PURE__*/_interopNamespace(m)); }, reject) }).then(({ default: foo }) => assert.equal(foo, 42)); + new Promise(function (resolve, reject) { require(['https://unpkg.com/foo'], function (m) { resolve(/*#__PURE__*/_interopNamespaceDefault(m)); }, reject); }).then(({ default: foo }) => assert.equal(foo, 42)); -}); +})); diff --git a/test/form/samples/paths-function/_expected/cjs.js b/test/form/samples/paths-function/_expected/cjs.js index abb7d87374c..7ea9f42d78d 100644 --- a/test/form/samples/paths-function/_expected/cjs.js +++ b/test/form/samples/paths-function/_expected/cjs.js @@ -2,30 +2,6 @@ var foo = require('https://unpkg.com/foo'); -function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } +assert.equal(foo, 42); -function _interopNamespace(e) { - if (e && e.__esModule) return e; - var n = Object.create(null); - if (e) { - Object.keys(e).forEach(function (k) { - if (k !== 'default') { - var d = Object.getOwnPropertyDescriptor(e, k); - Object.defineProperty(n, k, d.get ? d : { - enumerable: true, - get: function () { - return e[k]; - } - }); - } - }); - } - n['default'] = e; - return Object.freeze(n); -} - -var foo__default = /*#__PURE__*/_interopDefaultLegacy(foo); - -assert.equal(foo__default['default'], 42); - -Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('https://unpkg.com/foo')); }).then(({ default: foo }) => assert.equal(foo, 42)); +import('https://unpkg.com/foo').then(({ default: foo }) => assert.equal(foo, 42)); diff --git a/test/form/samples/paths-function/_expected/iife.js b/test/form/samples/paths-function/_expected/iife.js index dc653638eac..a2f93548c2f 100644 --- a/test/form/samples/paths-function/_expected/iife.js +++ b/test/form/samples/paths-function/_expected/iife.js @@ -1,12 +1,8 @@ (function (foo) { 'use strict'; - function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } - - var foo__default = /*#__PURE__*/_interopDefaultLegacy(foo); - - assert.equal(foo__default['default'], 42); + assert.equal(foo, 42); import('https://unpkg.com/foo').then(({ default: foo }) => assert.equal(foo, 42)); -}(foo)); +})(foo); diff --git a/test/form/samples/paths-function/_expected/system.js b/test/form/samples/paths-function/_expected/system.js index 29215974a2b..e4c1102d966 100644 --- a/test/form/samples/paths-function/_expected/system.js +++ b/test/form/samples/paths-function/_expected/system.js @@ -1,16 +1,16 @@ -System.register(['https://unpkg.com/foo'], function (exports, module) { +System.register(['https://unpkg.com/foo'], (function (exports, module) { 'use strict'; var foo; return { setters: [function (module) { foo = module.default; }], - execute: function () { + execute: (function () { assert.equal(foo, 42); module.import('https://unpkg.com/foo').then(({ default: foo }) => assert.equal(foo, 42)); - } + }) }; -}); +})); diff --git a/test/form/samples/paths-function/_expected/umd.js b/test/form/samples/paths-function/_expected/umd.js index b3a3b5217ff..91b7c727d08 100644 --- a/test/form/samples/paths-function/_expected/umd.js +++ b/test/form/samples/paths-function/_expected/umd.js @@ -2,14 +2,10 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('https://unpkg.com/foo')) : typeof define === 'function' && define.amd ? define(['https://unpkg.com/foo'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.foo)); -}(this, (function (foo) { 'use strict'; +})(this, (function (foo) { 'use strict'; - function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } - - var foo__default = /*#__PURE__*/_interopDefaultLegacy(foo); - - assert.equal(foo__default['default'], 42); + assert.equal(foo, 42); import('https://unpkg.com/foo').then(({ default: foo }) => assert.equal(foo, 42)); -}))); +})); diff --git a/test/form/samples/paths-relative/_config.js b/test/form/samples/paths-relative/_config.js index 90bc71c1f45..72205b1d5cc 100644 --- a/test/form/samples/paths-relative/_config.js +++ b/test/form/samples/paths-relative/_config.js @@ -1,8 +1,8 @@ -const { resolve } = require('path'); +const path = require('node:path'); -const resolved = resolve(__dirname, 'foo.js'); +const resolved = path.resolve(__dirname, 'foo.js'); -module.exports = { +module.exports = defineTest({ description: 'external paths (#754)', options: { external: [resolved], @@ -11,4 +11,4 @@ module.exports = { paths: { [resolved]: '../foo' } } } -}; +}); diff --git a/test/form/samples/paths-relative/_expected/amd.js b/test/form/samples/paths-relative/_expected/amd.js index d4ade45ac3a..08876ce9dff 100644 --- a/test/form/samples/paths-relative/_expected/amd.js +++ b/test/form/samples/paths-relative/_expected/amd.js @@ -1,9 +1,5 @@ -define(['../foo'], function (foo) { 'use strict'; +define(['../foo'], (function (foo) { 'use strict'; - function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } + assert.equal( foo, 42 ); - var foo__default = /*#__PURE__*/_interopDefaultLegacy(foo); - - assert.equal( foo__default['default'], 42 ); - -}); +})); diff --git a/test/form/samples/paths-relative/_expected/cjs.js b/test/form/samples/paths-relative/_expected/cjs.js index cee48cf4dd2..4aed31b14ac 100644 --- a/test/form/samples/paths-relative/_expected/cjs.js +++ b/test/form/samples/paths-relative/_expected/cjs.js @@ -2,8 +2,4 @@ var foo = require('../foo'); -function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } - -var foo__default = /*#__PURE__*/_interopDefaultLegacy(foo); - -assert.equal( foo__default['default'], 42 ); +assert.equal( foo, 42 ); diff --git a/test/form/samples/paths-relative/_expected/iife.js b/test/form/samples/paths-relative/_expected/iife.js index c88f5d27491..944073903ef 100644 --- a/test/form/samples/paths-relative/_expected/iife.js +++ b/test/form/samples/paths-relative/_expected/iife.js @@ -1,10 +1,6 @@ (function (foo) { 'use strict'; - function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } + assert.equal( foo, 42 ); - var foo__default = /*#__PURE__*/_interopDefaultLegacy(foo); - - assert.equal( foo__default['default'], 42 ); - -}(foo)); +})(foo); diff --git a/test/form/samples/paths-relative/_expected/system.js b/test/form/samples/paths-relative/_expected/system.js index 7c4aa9446e3..a21286ad551 100644 --- a/test/form/samples/paths-relative/_expected/system.js +++ b/test/form/samples/paths-relative/_expected/system.js @@ -1,14 +1,14 @@ -System.register(['../foo'], function () { +System.register(['../foo'], (function () { 'use strict'; var foo; return { setters: [function (module) { foo = module.default; }], - execute: function () { + execute: (function () { assert.equal( foo, 42 ); - } + }) }; -}); +})); diff --git a/test/form/samples/paths-relative/_expected/umd.js b/test/form/samples/paths-relative/_expected/umd.js index e05e0e73e1a..1257109fff6 100644 --- a/test/form/samples/paths-relative/_expected/umd.js +++ b/test/form/samples/paths-relative/_expected/umd.js @@ -2,12 +2,8 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../foo')) : typeof define === 'function' && define.amd ? define(['../foo'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.foo)); -}(this, (function (foo) { 'use strict'; +})(this, (function (foo) { 'use strict'; - function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } + assert.equal( foo, 42 ); - var foo__default = /*#__PURE__*/_interopDefaultLegacy(foo); - - assert.equal( foo__default['default'], 42 ); - -}))); +})); diff --git a/test/form/samples/paths/_config.js b/test/form/samples/paths/_config.js index ef23638a0ef..02fa7cf93cf 100644 --- a/test/form/samples/paths/_config.js +++ b/test/form/samples/paths/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'external paths (#754)', options: { external: ['foo'], @@ -7,4 +7,4 @@ module.exports = { paths: { foo: 'https://unpkg.com/foo' } } } -}; +}); diff --git a/test/form/samples/paths/_expected/amd.js b/test/form/samples/paths/_expected/amd.js index 0f7d22ca0b0..216804bd681 100644 --- a/test/form/samples/paths/_expected/amd.js +++ b/test/form/samples/paths/_expected/amd.js @@ -1,9 +1,5 @@ -define(['https://unpkg.com/foo'], function (foo) { 'use strict'; +define(['https://unpkg.com/foo'], (function (foo) { 'use strict'; - function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } + assert.equal( foo, 42 ); - var foo__default = /*#__PURE__*/_interopDefaultLegacy(foo); - - assert.equal( foo__default['default'], 42 ); - -}); +})); diff --git a/test/form/samples/paths/_expected/cjs.js b/test/form/samples/paths/_expected/cjs.js index bb32a0b4bf6..225b214b204 100644 --- a/test/form/samples/paths/_expected/cjs.js +++ b/test/form/samples/paths/_expected/cjs.js @@ -2,8 +2,4 @@ var foo = require('https://unpkg.com/foo'); -function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } - -var foo__default = /*#__PURE__*/_interopDefaultLegacy(foo); - -assert.equal( foo__default['default'], 42 ); +assert.equal( foo, 42 ); diff --git a/test/form/samples/paths/_expected/iife.js b/test/form/samples/paths/_expected/iife.js index c88f5d27491..944073903ef 100644 --- a/test/form/samples/paths/_expected/iife.js +++ b/test/form/samples/paths/_expected/iife.js @@ -1,10 +1,6 @@ (function (foo) { 'use strict'; - function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } + assert.equal( foo, 42 ); - var foo__default = /*#__PURE__*/_interopDefaultLegacy(foo); - - assert.equal( foo__default['default'], 42 ); - -}(foo)); +})(foo); diff --git a/test/form/samples/paths/_expected/system.js b/test/form/samples/paths/_expected/system.js index b2566c416a3..6fe29c157c7 100644 --- a/test/form/samples/paths/_expected/system.js +++ b/test/form/samples/paths/_expected/system.js @@ -1,14 +1,14 @@ -System.register(['https://unpkg.com/foo'], function () { +System.register(['https://unpkg.com/foo'], (function () { 'use strict'; var foo; return { setters: [function (module) { foo = module.default; }], - execute: function () { + execute: (function () { assert.equal( foo, 42 ); - } + }) }; -}); +})); diff --git a/test/form/samples/paths/_expected/umd.js b/test/form/samples/paths/_expected/umd.js index 4339fc9ada7..163e84dda72 100644 --- a/test/form/samples/paths/_expected/umd.js +++ b/test/form/samples/paths/_expected/umd.js @@ -2,12 +2,8 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('https://unpkg.com/foo')) : typeof define === 'function' && define.amd ? define(['https://unpkg.com/foo'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.foo)); -}(this, (function (foo) { 'use strict'; +})(this, (function (foo) { 'use strict'; - function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } + assert.equal( foo, 42 ); - var foo__default = /*#__PURE__*/_interopDefaultLegacy(foo); - - assert.equal( foo__default['default'], 42 ); - -}))); +})); diff --git a/test/form/samples/pattern-assignments/_config.js b/test/form/samples/pattern-assignments/_config.js index a884052961f..301549b66bd 100644 --- a/test/form/samples/pattern-assignments/_config.js +++ b/test/form/samples/pattern-assignments/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'Make sure side-effects are passed along destructuring assignments', options: { output: { name: 'bundle' } } -}; +}); diff --git a/test/form/samples/pattern-assignments/_expected/amd.js b/test/form/samples/pattern-assignments/_expected/amd.js index 4659b2dc578..8ab0b9501c5 100644 --- a/test/form/samples/pattern-assignments/_expected/amd.js +++ b/test/form/samples/pattern-assignments/_expected/amd.js @@ -1,4 +1,4 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; var effect = () => console.log( 'effect' ); @@ -39,6 +39,4 @@ define(['exports'], function (exports) { 'use strict'; exports.u = u; exports.v = v; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/form/samples/pattern-assignments/_expected/cjs.js b/test/form/samples/pattern-assignments/_expected/cjs.js index f663cfac812..4e1887b44fd 100644 --- a/test/form/samples/pattern-assignments/_expected/cjs.js +++ b/test/form/samples/pattern-assignments/_expected/cjs.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - var effect = () => console.log( 'effect' ); var { a } = { a: effect }; diff --git a/test/form/samples/pattern-assignments/_expected/iife.js b/test/form/samples/pattern-assignments/_expected/iife.js index ac6e218fa45..2c099588d58 100644 --- a/test/form/samples/pattern-assignments/_expected/iife.js +++ b/test/form/samples/pattern-assignments/_expected/iife.js @@ -40,8 +40,6 @@ var bundle = (function (exports) { exports.u = u; exports.v = v; - Object.defineProperty(exports, '__esModule', { value: true }); - return exports; -}({})); +})({}); diff --git a/test/form/samples/pattern-assignments/_expected/system.js b/test/form/samples/pattern-assignments/_expected/system.js index caae6eaa4fa..fd8b0961ff5 100644 --- a/test/form/samples/pattern-assignments/_expected/system.js +++ b/test/form/samples/pattern-assignments/_expected/system.js @@ -1,7 +1,7 @@ -System.register('bundle', [], function (exports) { +System.register('bundle', [], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { var effect = () => console.log( 'effect' ); @@ -11,11 +11,11 @@ System.register('bundle', [], function (exports) { var { x: b } = { x: effect }; b(); - const s = exports('s', {}); + const s = exports("s", {}); var { c } = { c: s }; c.foo = 1; - const t = exports('t', {}); + const t = exports("t", {}); var { x: d } = { x: t }; d.foo = 1; @@ -27,16 +27,16 @@ System.register('bundle', [], function (exports) { ({ x: f } = { x: effect }); f(); - const u = exports('u', {}); + const u = exports("u", {}); var g; ({ g } = { g: u }); g.foo = 1; - const v = exports('v', {}); + const v = exports("v", {}); var h; ({ x: h } = { x: v }); h.foo = 1; - } + }) }; -}); +})); diff --git a/test/form/samples/pattern-assignments/_expected/umd.js b/test/form/samples/pattern-assignments/_expected/umd.js index ec62ddb364b..1f35fee60c5 100644 --- a/test/form/samples/pattern-assignments/_expected/umd.js +++ b/test/form/samples/pattern-assignments/_expected/umd.js @@ -2,7 +2,7 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.bundle = {})); -}(this, (function (exports) { 'use strict'; +})(this, (function (exports) { 'use strict'; var effect = () => console.log( 'effect' ); @@ -43,6 +43,4 @@ exports.u = u; exports.v = v; - Object.defineProperty(exports, '__esModule', { value: true }); - -}))); +})); diff --git a/test/form/samples/pattern-member-expressions/_config.js b/test/form/samples/pattern-member-expressions/_config.js index aa93889f9e6..1125577d403 100644 --- a/test/form/samples/pattern-member-expressions/_config.js +++ b/test/form/samples/pattern-member-expressions/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'handles member expressions in patterns (#2750)' -}; +}); diff --git a/test/form/samples/per-output-plugins/_config.js b/test/form/samples/per-output-plugins/_config.js index 8045837e438..1f5aaee6f58 100644 --- a/test/form/samples/per-output-plugins/_config.js +++ b/test/form/samples/per-output-plugins/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'allows specifying per-output plugins', options: { output: { @@ -17,4 +17,4 @@ module.exports = { ] } } -}; +}); diff --git a/test/form/samples/per-output-plugins/_expected/amd.js b/test/form/samples/per-output-plugins/_expected/amd.js index a12305aff0d..24bc392cc59 100644 --- a/test/form/samples/per-output-plugins/_expected/amd.js +++ b/test/form/samples/per-output-plugins/_expected/amd.js @@ -1,5 +1,5 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; console.log('amd', '!amd!'); -}); +})); diff --git a/test/form/samples/per-output-plugins/_expected/iife.js b/test/form/samples/per-output-plugins/_expected/iife.js index 42c0f688f00..974dd8e4c8e 100644 --- a/test/form/samples/per-output-plugins/_expected/iife.js +++ b/test/form/samples/per-output-plugins/_expected/iife.js @@ -3,4 +3,4 @@ console.log('iife', '!iife!'); -}()); +})(); diff --git a/test/form/samples/per-output-plugins/_expected/system.js b/test/form/samples/per-output-plugins/_expected/system.js index 600f1bdfbd1..7649c00c5e1 100644 --- a/test/form/samples/per-output-plugins/_expected/system.js +++ b/test/form/samples/per-output-plugins/_expected/system.js @@ -1,10 +1,10 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { console.log('system', '!system!'); - } + }) }; -}); +})); diff --git a/test/form/samples/per-output-plugins/_expected/umd.js b/test/form/samples/per-output-plugins/_expected/umd.js index 0fddc9f20f8..53d8ad6d11d 100644 --- a/test/form/samples/per-output-plugins/_expected/umd.js +++ b/test/form/samples/per-output-plugins/_expected/umd.js @@ -1,8 +1,8 @@ (function (factory) { typeof define === 'function' && define.amd ? define(factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; console.log('umd', '!umd!'); -}))); +})); diff --git a/test/form/samples/prefer-const/_config.js b/test/form/samples/prefer-const/_config.js deleted file mode 100644 index 779baf78e63..00000000000 --- a/test/form/samples/prefer-const/_config.js +++ /dev/null @@ -1,11 +0,0 @@ -module.exports = { - description: 'uses const instead of var if specified (#653)', - options: { - external: ['other'], - output: { - globals: { other: 'other' }, - name: 'myBundle', - preferConst: true - } - } -}; diff --git a/test/form/samples/prefer-const/_expected/amd.js b/test/form/samples/prefer-const/_expected/amd.js deleted file mode 100644 index 0f423ee98cb..00000000000 --- a/test/form/samples/prefer-const/_expected/amd.js +++ /dev/null @@ -1,19 +0,0 @@ -define(['other'], function (other) { 'use strict'; - - const a = 1; - const b = 2; - - const namespace = /*#__PURE__*/Object.freeze({ - __proto__: null, - a: a, - b: b - }); - - console.log( Object.keys( namespace ) ); - console.log( other.name ); - - const main = 42; - - return main; - -}); diff --git a/test/form/samples/prefer-const/_expected/cjs.js b/test/form/samples/prefer-const/_expected/cjs.js deleted file mode 100644 index 01aa90d1548..00000000000 --- a/test/form/samples/prefer-const/_expected/cjs.js +++ /dev/null @@ -1,19 +0,0 @@ -'use strict'; - -const other = require('other'); - -const a = 1; -const b = 2; - -const namespace = /*#__PURE__*/Object.freeze({ - __proto__: null, - a: a, - b: b -}); - -console.log( Object.keys( namespace ) ); -console.log( other.name ); - -const main = 42; - -module.exports = main; diff --git a/test/form/samples/prefer-const/_expected/es.js b/test/form/samples/prefer-const/_expected/es.js deleted file mode 100644 index 24735286aa8..00000000000 --- a/test/form/samples/prefer-const/_expected/es.js +++ /dev/null @@ -1,17 +0,0 @@ -import { name } from 'other'; - -const a = 1; -const b = 2; - -const namespace = /*#__PURE__*/Object.freeze({ - __proto__: null, - a: a, - b: b -}); - -console.log( Object.keys( namespace ) ); -console.log( name ); - -const main = 42; - -export default main; diff --git a/test/form/samples/prefer-const/_expected/iife.js b/test/form/samples/prefer-const/_expected/iife.js deleted file mode 100644 index 72652cb62ef..00000000000 --- a/test/form/samples/prefer-const/_expected/iife.js +++ /dev/null @@ -1,20 +0,0 @@ -const myBundle = (function (other) { - 'use strict'; - - const a = 1; - const b = 2; - - const namespace = /*#__PURE__*/Object.freeze({ - __proto__: null, - a: a, - b: b - }); - - console.log( Object.keys( namespace ) ); - console.log( other.name ); - - const main = 42; - - return main; - -}(other)); diff --git a/test/form/samples/prefer-const/_expected/system.js b/test/form/samples/prefer-const/_expected/system.js deleted file mode 100644 index a0599b20df8..00000000000 --- a/test/form/samples/prefer-const/_expected/system.js +++ /dev/null @@ -1,26 +0,0 @@ -System.register('myBundle', ['other'], function (exports) { - 'use strict'; - var name; - return { - setters: [function (module) { - name = module.name; - }], - execute: function () { - - const a = 1; - const b = 2; - - const namespace = /*#__PURE__*/Object.freeze({ - __proto__: null, - a: a, - b: b - }); - - console.log( Object.keys( namespace ) ); - console.log( name ); - - const main = exports('default', 42); - - } - }; -}); diff --git a/test/form/samples/prefer-const/_expected/umd.js b/test/form/samples/prefer-const/_expected/umd.js deleted file mode 100644 index 9390abb4066..00000000000 --- a/test/form/samples/prefer-const/_expected/umd.js +++ /dev/null @@ -1,23 +0,0 @@ -(function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('other')) : - typeof define === 'function' && define.amd ? define(['other'], factory) : - (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.myBundle = factory(global.other)); -}(this, (function (other) { 'use strict'; - - const a = 1; - const b = 2; - - const namespace = /*#__PURE__*/Object.freeze({ - __proto__: null, - a: a, - b: b - }); - - console.log( Object.keys( namespace ) ); - console.log( other.name ); - - const main = 42; - - return main; - -}))); diff --git a/test/form/samples/prefer-const/main.js b/test/form/samples/prefer-const/main.js deleted file mode 100644 index 9686046988c..00000000000 --- a/test/form/samples/prefer-const/main.js +++ /dev/null @@ -1,7 +0,0 @@ -import { name } from 'other'; -import * as namespace from './namespace.js'; - -console.log( Object.keys( namespace ) ); -console.log( name ); - -export default 42; diff --git a/test/form/samples/prefer-const/namespace.js b/test/form/samples/prefer-const/namespace.js deleted file mode 100644 index 72ab60e17a2..00000000000 --- a/test/form/samples/prefer-const/namespace.js +++ /dev/null @@ -1,2 +0,0 @@ -export const a = 1; -export const b = 2; diff --git a/test/form/samples/preserve-asm-js/_config.js b/test/form/samples/preserve-asm-js/_config.js index af8fa8dd5ca..47b606014c8 100644 --- a/test/form/samples/preserve-asm-js/_config.js +++ b/test/form/samples/preserve-asm-js/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'Preserves asm.js code (#3360)' -}; +}); diff --git a/test/form/samples/preserve-debugger/_config.js b/test/form/samples/preserve-debugger/_config.js index 3e658157910..7cc40b3c70f 100644 --- a/test/form/samples/preserve-debugger/_config.js +++ b/test/form/samples/preserve-debugger/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'debugger statements are preserved (#664)' -}; +}); diff --git a/test/form/samples/preserve-debugger/_expected/amd.js b/test/form/samples/preserve-debugger/_expected/amd.js index be1ef136ce1..dcbb93a2243 100644 --- a/test/form/samples/preserve-debugger/_expected/amd.js +++ b/test/form/samples/preserve-debugger/_expected/amd.js @@ -1,7 +1,7 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; before(); debugger; after(); -}); +})); diff --git a/test/form/samples/preserve-debugger/_expected/iife.js b/test/form/samples/preserve-debugger/_expected/iife.js index b40a10005d2..f0a02c250dc 100644 --- a/test/form/samples/preserve-debugger/_expected/iife.js +++ b/test/form/samples/preserve-debugger/_expected/iife.js @@ -5,4 +5,4 @@ debugger; after(); -}()); +})(); diff --git a/test/form/samples/preserve-debugger/_expected/system.js b/test/form/samples/preserve-debugger/_expected/system.js index b49364f074c..33c02df385f 100644 --- a/test/form/samples/preserve-debugger/_expected/system.js +++ b/test/form/samples/preserve-debugger/_expected/system.js @@ -1,12 +1,12 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { before(); debugger; after(); - } + }) }; -}); +})); diff --git a/test/form/samples/preserve-debugger/_expected/umd.js b/test/form/samples/preserve-debugger/_expected/umd.js index ec1e8a7ad49..52994ec2ae5 100644 --- a/test/form/samples/preserve-debugger/_expected/umd.js +++ b/test/form/samples/preserve-debugger/_expected/umd.js @@ -1,10 +1,10 @@ (function (factory) { typeof define === 'function' && define.amd ? define(factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; before(); debugger; after(); -}))); +})); diff --git a/test/form/samples/preserves-comments-after-imports/_config.js b/test/form/samples/preserves-comments-after-imports/_config.js index 7b4cc9f7a57..92be92333a2 100644 --- a/test/form/samples/preserves-comments-after-imports/_config.js +++ b/test/form/samples/preserves-comments-after-imports/_config.js @@ -1,6 +1,6 @@ -module.exports = { +module.exports = defineTest({ description: 'preserves comments between imports and first statement', options: { output: { name: 'myBundle' } } -}; +}); // https://github.com/esperantojs/esperanto/issues/187 diff --git a/test/form/samples/preserves-comments-after-imports/_expected/amd.js b/test/form/samples/preserves-comments-after-imports/_expected/amd.js index 8271ac978d0..a923b337417 100644 --- a/test/form/samples/preserves-comments-after-imports/_expected/amd.js +++ b/test/form/samples/preserves-comments-after-imports/_expected/amd.js @@ -1,4 +1,4 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; /** A comment for a number */ var number = 5; @@ -8,6 +8,4 @@ define(['exports'], function (exports) { 'use strict'; exports.obj = obj; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/form/samples/preserves-comments-after-imports/_expected/cjs.js b/test/form/samples/preserves-comments-after-imports/_expected/cjs.js index 723b1cb3ec0..8b15cd1f241 100644 --- a/test/form/samples/preserves-comments-after-imports/_expected/cjs.js +++ b/test/form/samples/preserves-comments-after-imports/_expected/cjs.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - /** A comment for a number */ var number = 5; diff --git a/test/form/samples/preserves-comments-after-imports/_expected/iife.js b/test/form/samples/preserves-comments-after-imports/_expected/iife.js index 8825245def6..64982e6ee3e 100644 --- a/test/form/samples/preserves-comments-after-imports/_expected/iife.js +++ b/test/form/samples/preserves-comments-after-imports/_expected/iife.js @@ -9,8 +9,6 @@ var myBundle = (function (exports) { exports.obj = obj; - Object.defineProperty(exports, '__esModule', { value: true }); - return exports; -}({})); +})({}); diff --git a/test/form/samples/preserves-comments-after-imports/_expected/system.js b/test/form/samples/preserves-comments-after-imports/_expected/system.js index 7a62df55a8d..31c6318460e 100644 --- a/test/form/samples/preserves-comments-after-imports/_expected/system.js +++ b/test/form/samples/preserves-comments-after-imports/_expected/system.js @@ -1,14 +1,14 @@ -System.register('myBundle', [], function (exports) { +System.register('myBundle', [], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { /** A comment for a number */ var number = 5; /** A comment for obj */ - var obj = exports('obj', { number }); + var obj = exports("obj", { number }); - } + }) }; -}); +})); diff --git a/test/form/samples/preserves-comments-after-imports/_expected/umd.js b/test/form/samples/preserves-comments-after-imports/_expected/umd.js index 80df01b5468..6ebd8d6cbd3 100644 --- a/test/form/samples/preserves-comments-after-imports/_expected/umd.js +++ b/test/form/samples/preserves-comments-after-imports/_expected/umd.js @@ -2,7 +2,7 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.myBundle = {})); -}(this, (function (exports) { 'use strict'; +})(this, (function (exports) { 'use strict'; /** A comment for a number */ var number = 5; @@ -12,6 +12,4 @@ exports.obj = obj; - Object.defineProperty(exports, '__esModule', { value: true }); - -}))); +})); diff --git a/test/form/samples/probe-external-namespace/_config.js b/test/form/samples/probe-external-namespace/_config.js index d4034bec1c6..2c63e436def 100644 --- a/test/form/samples/probe-external-namespace/_config.js +++ b/test/form/samples/probe-external-namespace/_config.js @@ -1,6 +1,7 @@ -module.exports = { +module.exports = defineTest({ description: 'allow probing external namespaces without causing errors due to missing imports', options: { - external: 'external' + external: 'external', + output: { globals: { external: 'external' } } } -}; +}); diff --git a/test/form/samples/probe-external-namespace/_expected/amd.js b/test/form/samples/probe-external-namespace/_expected/amd.js index 59330b6d77f..0393b9db83f 100644 --- a/test/form/samples/probe-external-namespace/_expected/amd.js +++ b/test/form/samples/probe-external-namespace/_expected/amd.js @@ -1,7 +1,6 @@ -define(['external'], function (external) { 'use strict'; +define(['external'], (function (external) { 'use strict'; - function _interopNamespace(e) { - if (e && e.__esModule) return e; + function _interopNamespaceDefault(e) { var n = Object.create(null); if (e) { Object.keys(e).forEach(function (k) { @@ -9,19 +8,17 @@ define(['external'], function (external) { 'use strict'; var d = Object.getOwnPropertyDescriptor(e, k); Object.defineProperty(n, k, d.get ? d : { enumerable: true, - get: function () { - return e[k]; - } + get: function () { return e[k]; } }); } }); } - n['default'] = e; + n.default = e; return Object.freeze(n); } - var external__namespace = /*#__PURE__*/_interopNamespace(external); + var external__namespace = /*#__PURE__*/_interopNamespaceDefault(external); console.log(external__namespace.default, external__namespace.foo); -}); +})); diff --git a/test/form/samples/probe-external-namespace/_expected/cjs.js b/test/form/samples/probe-external-namespace/_expected/cjs.js index abd76ee914c..20d721ce273 100644 --- a/test/form/samples/probe-external-namespace/_expected/cjs.js +++ b/test/form/samples/probe-external-namespace/_expected/cjs.js @@ -2,8 +2,7 @@ var external = require('external'); -function _interopNamespace(e) { - if (e && e.__esModule) return e; +function _interopNamespaceDefault(e) { var n = Object.create(null); if (e) { Object.keys(e).forEach(function (k) { @@ -11,17 +10,15 @@ function _interopNamespace(e) { var d = Object.getOwnPropertyDescriptor(e, k); Object.defineProperty(n, k, d.get ? d : { enumerable: true, - get: function () { - return e[k]; - } + get: function () { return e[k]; } }); } }); } - n['default'] = e; + n.default = e; return Object.freeze(n); } -var external__namespace = /*#__PURE__*/_interopNamespace(external); +var external__namespace = /*#__PURE__*/_interopNamespaceDefault(external); console.log(external__namespace.default, external__namespace.foo); diff --git a/test/form/samples/probe-external-namespace/_expected/iife.js b/test/form/samples/probe-external-namespace/_expected/iife.js index 596259e1c97..e57dda8a159 100644 --- a/test/form/samples/probe-external-namespace/_expected/iife.js +++ b/test/form/samples/probe-external-namespace/_expected/iife.js @@ -1,8 +1,7 @@ (function (external) { 'use strict'; - function _interopNamespace(e) { - if (e && e.__esModule) return e; + function _interopNamespaceDefault(e) { var n = Object.create(null); if (e) { Object.keys(e).forEach(function (k) { @@ -10,19 +9,17 @@ var d = Object.getOwnPropertyDescriptor(e, k); Object.defineProperty(n, k, d.get ? d : { enumerable: true, - get: function () { - return e[k]; - } + get: function () { return e[k]; } }); } }); } - n['default'] = e; + n.default = e; return Object.freeze(n); } - var external__namespace = /*#__PURE__*/_interopNamespace(external); + var external__namespace = /*#__PURE__*/_interopNamespaceDefault(external); console.log(external__namespace.default, external__namespace.foo); -}(external)); +})(external); diff --git a/test/form/samples/probe-external-namespace/_expected/system.js b/test/form/samples/probe-external-namespace/_expected/system.js index c7e7526dfc0..51377ded700 100644 --- a/test/form/samples/probe-external-namespace/_expected/system.js +++ b/test/form/samples/probe-external-namespace/_expected/system.js @@ -1,14 +1,14 @@ -System.register(['external'], function () { +System.register(['external'], (function () { 'use strict'; var external; return { setters: [function (module) { external = module; }], - execute: function () { + execute: (function () { console.log(external.default, external.foo); - } + }) }; -}); +})); diff --git a/test/form/samples/probe-external-namespace/_expected/umd.js b/test/form/samples/probe-external-namespace/_expected/umd.js index 7ad9884a5bd..375181b3374 100644 --- a/test/form/samples/probe-external-namespace/_expected/umd.js +++ b/test/form/samples/probe-external-namespace/_expected/umd.js @@ -2,10 +2,9 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('external')) : typeof define === 'function' && define.amd ? define(['external'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.external)); -}(this, (function (external) { 'use strict'; +})(this, (function (external) { 'use strict'; - function _interopNamespace(e) { - if (e && e.__esModule) return e; + function _interopNamespaceDefault(e) { var n = Object.create(null); if (e) { Object.keys(e).forEach(function (k) { @@ -13,19 +12,17 @@ var d = Object.getOwnPropertyDescriptor(e, k); Object.defineProperty(n, k, d.get ? d : { enumerable: true, - get: function () { - return e[k]; - } + get: function () { return e[k]; } }); } }); } - n['default'] = e; + n.default = e; return Object.freeze(n); } - var external__namespace = /*#__PURE__*/_interopNamespace(external); + var external__namespace = /*#__PURE__*/_interopNamespaceDefault(external); console.log(external__namespace.default, external__namespace.foo); -}))); +})); diff --git a/test/form/samples/promises/_config.js b/test/form/samples/promises/_config.js index 5d746d2a93d..6de517042c0 100644 --- a/test/form/samples/promises/_config.js +++ b/test/form/samples/promises/_config.js @@ -1,4 +1,3 @@ -module.exports = { - description: 'do not remove promise creations', - options: { output: { name: 'bundle' } } -}; +module.exports = defineTest({ + description: 'do not remove promise creations' +}); diff --git a/test/form/samples/promises/_expected.js b/test/form/samples/promises/_expected.js new file mode 100644 index 00000000000..12b24ec5ee2 --- /dev/null +++ b/test/form/samples/promises/_expected.js @@ -0,0 +1,49 @@ +Promise.resolve({ + then() { + console.log(1); + } +}); + +Promise.resolve({ + get then() { + return () => console.log(2); + } +}); + +Promise.reject('should be kept for uncaught rejections'); + +Promise.all([ + { + then() { + console.log(3); + } + }, + null +]); + +Promise.all([ + null, + { + get then() { + return () => console.log(4); + } + } +]); + +Promise.race([ + { + then() { + console.log(5); + } + }, + null +]); + +Promise.race([ + null, + { + get then() { + return () => console.log(6); + } + } +]); diff --git a/test/form/samples/promises/_expected/amd.js b/test/form/samples/promises/_expected/amd.js deleted file mode 100644 index 3abe869be19..00000000000 --- a/test/form/samples/promises/_expected/amd.js +++ /dev/null @@ -1,21 +0,0 @@ -define(['exports'], function (exports) { 'use strict'; - - new Promise( () => { - console.log( 'fire & forget' ); - } ); - - const p2 = new Promise( () => { - console.info( 'forget me as well' ); - } ); - - const p3 = new Promise( () => { - console.info( 'and me too' ); - } ); - Promise.reject('should be kept for uncaught rejections'); - const allExported = Promise.all([p2, p3]); - - exports.allExported = allExported; - - Object.defineProperty(exports, '__esModule', { value: true }); - -}); diff --git a/test/form/samples/promises/_expected/cjs.js b/test/form/samples/promises/_expected/cjs.js deleted file mode 100644 index b6613199bbd..00000000000 --- a/test/form/samples/promises/_expected/cjs.js +++ /dev/null @@ -1,19 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { value: true }); - -new Promise( () => { - console.log( 'fire & forget' ); -} ); - -const p2 = new Promise( () => { - console.info( 'forget me as well' ); -} ); - -const p3 = new Promise( () => { - console.info( 'and me too' ); -} ); -Promise.reject('should be kept for uncaught rejections'); -const allExported = Promise.all([p2, p3]); - -exports.allExported = allExported; diff --git a/test/form/samples/promises/_expected/es.js b/test/form/samples/promises/_expected/es.js deleted file mode 100644 index 5b295ae61bc..00000000000 --- a/test/form/samples/promises/_expected/es.js +++ /dev/null @@ -1,15 +0,0 @@ -new Promise( () => { - console.log( 'fire & forget' ); -} ); - -const p2 = new Promise( () => { - console.info( 'forget me as well' ); -} ); - -const p3 = new Promise( () => { - console.info( 'and me too' ); -} ); -Promise.reject('should be kept for uncaught rejections'); -const allExported = Promise.all([p2, p3]); - -export { allExported }; diff --git a/test/form/samples/promises/_expected/iife.js b/test/form/samples/promises/_expected/iife.js deleted file mode 100644 index 66392a8ab0d..00000000000 --- a/test/form/samples/promises/_expected/iife.js +++ /dev/null @@ -1,24 +0,0 @@ -var bundle = (function (exports) { - 'use strict'; - - new Promise( () => { - console.log( 'fire & forget' ); - } ); - - const p2 = new Promise( () => { - console.info( 'forget me as well' ); - } ); - - const p3 = new Promise( () => { - console.info( 'and me too' ); - } ); - Promise.reject('should be kept for uncaught rejections'); - const allExported = Promise.all([p2, p3]); - - exports.allExported = allExported; - - Object.defineProperty(exports, '__esModule', { value: true }); - - return exports; - -}({})); diff --git a/test/form/samples/promises/_expected/system.js b/test/form/samples/promises/_expected/system.js deleted file mode 100644 index f77b8fa2796..00000000000 --- a/test/form/samples/promises/_expected/system.js +++ /dev/null @@ -1,22 +0,0 @@ -System.register('bundle', [], function (exports) { - 'use strict'; - return { - execute: function () { - - new Promise( () => { - console.log( 'fire & forget' ); - } ); - - const p2 = new Promise( () => { - console.info( 'forget me as well' ); - } ); - - const p3 = new Promise( () => { - console.info( 'and me too' ); - } ); - Promise.reject('should be kept for uncaught rejections'); - const allExported = exports('allExported', Promise.all([p2, p3])); - - } - }; -}); diff --git a/test/form/samples/promises/_expected/umd.js b/test/form/samples/promises/_expected/umd.js deleted file mode 100644 index 7d28fb7c257..00000000000 --- a/test/form/samples/promises/_expected/umd.js +++ /dev/null @@ -1,25 +0,0 @@ -(function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : - typeof define === 'function' && define.amd ? define(['exports'], factory) : - (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.bundle = {})); -}(this, (function (exports) { 'use strict'; - - new Promise( () => { - console.log( 'fire & forget' ); - } ); - - const p2 = new Promise( () => { - console.info( 'forget me as well' ); - } ); - - const p3 = new Promise( () => { - console.info( 'and me too' ); - } ); - Promise.reject('should be kept for uncaught rejections'); - const allExported = Promise.all([p2, p3]); - - exports.allExported = allExported; - - Object.defineProperty(exports, '__esModule', { value: true }); - -}))); diff --git a/test/form/samples/promises/main.js b/test/form/samples/promises/main.js index a42566cf26e..12b24ec5ee2 100644 --- a/test/form/samples/promises/main.js +++ b/test/form/samples/promises/main.js @@ -1,18 +1,49 @@ -const p1 = new Promise( () => { - console.log( 'fire & forget' ); -} ); +Promise.resolve({ + then() { + console.log(1); + } +}); -const p2 = new Promise( () => { - console.info( 'forget me as well' ); -} ); +Promise.resolve({ + get then() { + return () => console.log(2); + } +}); -const p3 = new Promise( () => { - console.info( 'and me too' ); -} ); +Promise.reject('should be kept for uncaught rejections'); -const p4 = Promise.resolve('no side effect'); -const p5 = Promise.reject('should be kept for uncaught rejections'); +Promise.all([ + { + then() { + console.log(3); + } + }, + null +]); -const all = Promise.all([p2, p3]); -export const allExported = Promise.all([p2, p3]); -const race = Promise.race([p2, p3]); +Promise.all([ + null, + { + get then() { + return () => console.log(4); + } + } +]); + +Promise.race([ + { + then() { + console.log(5); + } + }, + null +]); + +Promise.race([ + null, + { + get then() { + return () => console.log(6); + } + } +]); diff --git a/test/form/samples/proper-this-context/_config.js b/test/form/samples/proper-this-context/_config.js index 65fe62b2171..ac5bd4fe960 100644 --- a/test/form/samples/proper-this-context/_config.js +++ b/test/form/samples/proper-this-context/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'make sure "this" respects the context for arrow functions', expectedWarnings: ['THIS_IS_UNDEFINED'] -}; +}); diff --git a/test/form/samples/property-setters-and-getters/access-when-called-effect/_config.js b/test/form/samples/property-setters-and-getters/access-when-called-effect/_config.js index ae85f1ce6c6..e0bc1344b13 100644 --- a/test/form/samples/property-setters-and-getters/access-when-called-effect/_config.js +++ b/test/form/samples/property-setters-and-getters/access-when-called-effect/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'respects access side-effects when calling a getter' -}; +}); diff --git a/test/form/samples/property-setters-and-getters/early-access-getter-return/_config.js b/test/form/samples/property-setters-and-getters/early-access-getter-return/_config.js index bbfa47e1932..75c9558cad7 100644 --- a/test/form/samples/property-setters-and-getters/early-access-getter-return/_config.js +++ b/test/form/samples/property-setters-and-getters/early-access-getter-return/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'handles accessing the return expression of a getter before it has been bound' -}; +}); diff --git a/test/form/samples/property-setters-and-getters/early-access-getter-value/_config.js b/test/form/samples/property-setters-and-getters/early-access-getter-value/_config.js index e362145ba90..ec933e312db 100644 --- a/test/form/samples/property-setters-and-getters/early-access-getter-value/_config.js +++ b/test/form/samples/property-setters-and-getters/early-access-getter-value/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'handles accessing the value of a getter before it has been bound' -}; +}); diff --git a/test/form/samples/property-setters-and-getters/shadowed-setters/_config.js b/test/form/samples/property-setters-and-getters/shadowed-setters/_config.js new file mode 100644 index 00000000000..05a902af786 --- /dev/null +++ b/test/form/samples/property-setters-and-getters/shadowed-setters/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'handles setters shadowed by computed setters' +}); diff --git a/test/form/samples/property-setters-and-getters/shadowed-setters/_expected.js b/test/form/samples/property-setters-and-getters/shadowed-setters/_expected.js new file mode 100644 index 00000000000..2758779af18 --- /dev/null +++ b/test/form/samples/property-setters-and-getters/shadowed-setters/_expected.js @@ -0,0 +1,8 @@ +const objRetained = { + set value(v) {}, + set [globalThis.unknown](v) { + console.log('effect'); + } +}; + +objRetained.value = 'retained'; diff --git a/test/form/samples/property-setters-and-getters/shadowed-setters/main.js b/test/form/samples/property-setters-and-getters/shadowed-setters/main.js new file mode 100644 index 00000000000..e5b1a9baf01 --- /dev/null +++ b/test/form/samples/property-setters-and-getters/shadowed-setters/main.js @@ -0,0 +1,17 @@ +const objRemoved = { + set value(v) { + console.log('shadowed'); + }, + set value(v) {} +}; + +objRemoved.value = 'removed'; + +const objRetained = { + set value(v) {}, + set [globalThis.unknown](v) { + console.log('effect'); + } +}; + +objRetained.value = 'retained'; diff --git a/test/form/samples/protect-cjs-globals/_config.js b/test/form/samples/protect-cjs-globals/_config.js index 5d2d5ac0718..feb61230e93 100644 --- a/test/form/samples/protect-cjs-globals/_config.js +++ b/test/form/samples/protect-cjs-globals/_config.js @@ -1,6 +1,6 @@ -module.exports = { +module.exports = defineTest({ description: 'prevent conflicts with cjs module globals', options: { output: { name: 'bundle' } } -}; +}); diff --git a/test/form/samples/protect-cjs-globals/_expected/amd.js b/test/form/samples/protect-cjs-globals/_expected/amd.js index 9cd996e86ef..c2f0e0a9647 100644 --- a/test/form/samples/protect-cjs-globals/_expected/amd.js +++ b/test/form/samples/protect-cjs-globals/_expected/amd.js @@ -1,17 +1,15 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; const exports$1 = 1; - const require = 2; - const module = 3; - const __filename = 4; - const __dirname = 5; + const require$1 = 2; + const module$1 = 3; + const __filename$1 = 4; + const __dirname$1 = 5; - exports.__dirname = __dirname; - exports.__filename = __filename; + exports.__dirname = __dirname$1; + exports.__filename = __filename$1; exports.exports = exports$1; - exports.module = module; - exports.require = require; + exports.module = module$1; + exports.require = require$1; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/form/samples/protect-cjs-globals/_expected/cjs.js b/test/form/samples/protect-cjs-globals/_expected/cjs.js index 513260e0d7d..1303a625cb0 100644 --- a/test/form/samples/protect-cjs-globals/_expected/cjs.js +++ b/test/form/samples/protect-cjs-globals/_expected/cjs.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - const exports$1 = 1; const require$1 = 2; const module$1 = 3; diff --git a/test/form/samples/protect-cjs-globals/_expected/es.js b/test/form/samples/protect-cjs-globals/_expected/es.js index d45e878f597..2432479b82f 100644 --- a/test/form/samples/protect-cjs-globals/_expected/es.js +++ b/test/form/samples/protect-cjs-globals/_expected/es.js @@ -1,7 +1,7 @@ -const exports = 1; -const require = 2; -const module = 3; -const __filename = 4; -const __dirname = 5; +const exports$1 = 1; +const require$1 = 2; +const module$1 = 3; +const __filename$1 = 4; +const __dirname$1 = 5; -export { __dirname, __filename, exports, module, require }; +export { __dirname$1 as __dirname, __filename$1 as __filename, exports$1 as exports, module$1 as module, require$1 as require }; diff --git a/test/form/samples/protect-cjs-globals/_expected/iife.js b/test/form/samples/protect-cjs-globals/_expected/iife.js index e0e8f336677..927121f6054 100644 --- a/test/form/samples/protect-cjs-globals/_expected/iife.js +++ b/test/form/samples/protect-cjs-globals/_expected/iife.js @@ -2,19 +2,17 @@ var bundle = (function (exports) { 'use strict'; const exports$1 = 1; - const require = 2; - const module = 3; - const __filename = 4; - const __dirname = 5; + const require$1 = 2; + const module$1 = 3; + const __filename$1 = 4; + const __dirname$1 = 5; - exports.__dirname = __dirname; - exports.__filename = __filename; + exports.__dirname = __dirname$1; + exports.__filename = __filename$1; exports.exports = exports$1; - exports.module = module; - exports.require = require; - - Object.defineProperty(exports, '__esModule', { value: true }); + exports.module = module$1; + exports.require = require$1; return exports; -}({})); +})({}); diff --git a/test/form/samples/protect-cjs-globals/_expected/system.js b/test/form/samples/protect-cjs-globals/_expected/system.js index 55f2c5154f0..116adf3a87e 100644 --- a/test/form/samples/protect-cjs-globals/_expected/system.js +++ b/test/form/samples/protect-cjs-globals/_expected/system.js @@ -1,14 +1,14 @@ -System.register('bundle', [], function (exports) { +System.register('bundle', [], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - const exports$1 = exports('exports', 1); - const require = exports('require', 2); - const module$1 = exports('module', 3); - const __filename = exports('__filename', 4); - const __dirname = exports('__dirname', 5); + const exports$1 = exports("exports", 1); + const require$1 = exports("require", 2); + const module$1 = exports("module", 3); + const __filename$1 = exports("__filename", 4); + const __dirname$1 = exports("__dirname", 5); - } + }) }; -}); +})); diff --git a/test/form/samples/protect-cjs-globals/_expected/umd.js b/test/form/samples/protect-cjs-globals/_expected/umd.js index 933107790d0..cc94eb9cc0e 100644 --- a/test/form/samples/protect-cjs-globals/_expected/umd.js +++ b/test/form/samples/protect-cjs-globals/_expected/umd.js @@ -2,20 +2,18 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.bundle = {})); -}(this, (function (exports) { 'use strict'; +})(this, (function (exports) { 'use strict'; const exports$1 = 1; - const require = 2; - const module = 3; - const __filename = 4; - const __dirname = 5; + const require$1 = 2; + const module$1 = 3; + const __filename$1 = 4; + const __dirname$1 = 5; - exports.__dirname = __dirname; - exports.__filename = __filename; + exports.__dirname = __dirname$1; + exports.__filename = __filename$1; exports.exports = exports$1; - exports.module = module; - exports.require = require; + exports.module = module$1; + exports.require = require$1; - Object.defineProperty(exports, '__esModule', { value: true }); - -}))); +})); diff --git a/test/form/samples/proto-null/_config.js b/test/form/samples/proto-null/_config.js new file mode 100644 index 00000000000..795ccf6aa52 --- /dev/null +++ b/test/form/samples/proto-null/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'handles getters and setters on __proto__ properties' +}); diff --git a/test/form/samples/proto-null/_expected.js b/test/form/samples/proto-null/_expected.js new file mode 100644 index 00000000000..9f5b3e679a4 --- /dev/null +++ b/test/form/samples/proto-null/_expected.js @@ -0,0 +1,2 @@ +console.log('retained'); +console.log('retained'); diff --git a/test/form/samples/proto-null/main.js b/test/form/samples/proto-null/main.js new file mode 100644 index 00000000000..0fed2bf752b --- /dev/null +++ b/test/form/samples/proto-null/main.js @@ -0,0 +1,5 @@ +const a = { __proto__: null }; +if (a.hasOwnProperty) console.log('removed'); +else console.log('retained'); +if (a.foo) console.log('removed'); +else console.log('retained'); diff --git a/test/form/samples/prototype-functions/_config.js b/test/form/samples/prototype-functions/_config.js index 620b36d549c..e27b9eee8b4 100644 --- a/test/form/samples/prototype-functions/_config.js +++ b/test/form/samples/prototype-functions/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'properly includes prototype functions' -}; +}); diff --git a/test/form/samples/prune-pure-unused-import-array/_config.js b/test/form/samples/prune-pure-unused-import-array/_config.js index 4d9035fa705..92fd5a33f26 100644 --- a/test/form/samples/prune-pure-unused-import-array/_config.js +++ b/test/form/samples/prune-pure-unused-import-array/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'prunes pure unused external imports ([#1352])', options: { external: ['external', 'other'], @@ -7,4 +7,4 @@ module.exports = { globals: { other: 'other' } } } -}; +}); diff --git a/test/form/samples/prune-pure-unused-import-array/_expected/amd.js b/test/form/samples/prune-pure-unused-import-array/_expected/amd.js index f02c330d436..1115d7e625a 100644 --- a/test/form/samples/prune-pure-unused-import-array/_expected/amd.js +++ b/test/form/samples/prune-pure-unused-import-array/_expected/amd.js @@ -1,5 +1,5 @@ -define(['other'], function (other) { 'use strict'; +define(['other'], (function (other) { 'use strict'; -}); +})); diff --git a/test/form/samples/prune-pure-unused-import-array/_expected/iife.js b/test/form/samples/prune-pure-unused-import-array/_expected/iife.js index 43ef5426880..31dfeb95ed9 100644 --- a/test/form/samples/prune-pure-unused-import-array/_expected/iife.js +++ b/test/form/samples/prune-pure-unused-import-array/_expected/iife.js @@ -3,4 +3,4 @@ -}()); +})(); diff --git a/test/form/samples/prune-pure-unused-import-array/_expected/system.js b/test/form/samples/prune-pure-unused-import-array/_expected/system.js index 44f1ac2d34d..c8a51c260b2 100644 --- a/test/form/samples/prune-pure-unused-import-array/_expected/system.js +++ b/test/form/samples/prune-pure-unused-import-array/_expected/system.js @@ -1,11 +1,11 @@ -System.register(['other'], function () { +System.register(['other'], (function () { 'use strict'; return { - setters: [function () {}], - execute: function () { + setters: [null], + execute: (function () { - } + }) }; -}); +})); diff --git a/test/form/samples/prune-pure-unused-import-array/_expected/umd.js b/test/form/samples/prune-pure-unused-import-array/_expected/umd.js index 44508fbc372..f0ccb62ab6d 100644 --- a/test/form/samples/prune-pure-unused-import-array/_expected/umd.js +++ b/test/form/samples/prune-pure-unused-import-array/_expected/umd.js @@ -1,8 +1,8 @@ (function (factory) { typeof define === 'function' && define.amd ? define(['other'], factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; -}))); +})); diff --git a/test/form/samples/prune-pure-unused-import-function/_config.js b/test/form/samples/prune-pure-unused-import-function/_config.js index c682d7c9920..7b2e9251f9b 100644 --- a/test/form/samples/prune-pure-unused-import-function/_config.js +++ b/test/form/samples/prune-pure-unused-import-function/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'prunes pure unused external imports ([#1352])', expectedWarnings: ['EMPTY_BUNDLE'], options: { @@ -8,4 +8,4 @@ module.exports = { globals: { other: 'other' } } } -}; +}); diff --git a/test/form/samples/prune-pure-unused-import-function/_expected/amd.js b/test/form/samples/prune-pure-unused-import-function/_expected/amd.js index f02c330d436..1115d7e625a 100644 --- a/test/form/samples/prune-pure-unused-import-function/_expected/amd.js +++ b/test/form/samples/prune-pure-unused-import-function/_expected/amd.js @@ -1,5 +1,5 @@ -define(['other'], function (other) { 'use strict'; +define(['other'], (function (other) { 'use strict'; -}); +})); diff --git a/test/form/samples/prune-pure-unused-import-function/_expected/iife.js b/test/form/samples/prune-pure-unused-import-function/_expected/iife.js index 43ef5426880..31dfeb95ed9 100644 --- a/test/form/samples/prune-pure-unused-import-function/_expected/iife.js +++ b/test/form/samples/prune-pure-unused-import-function/_expected/iife.js @@ -3,4 +3,4 @@ -}()); +})(); diff --git a/test/form/samples/prune-pure-unused-import-function/_expected/system.js b/test/form/samples/prune-pure-unused-import-function/_expected/system.js index 44f1ac2d34d..c8a51c260b2 100644 --- a/test/form/samples/prune-pure-unused-import-function/_expected/system.js +++ b/test/form/samples/prune-pure-unused-import-function/_expected/system.js @@ -1,11 +1,11 @@ -System.register(['other'], function () { +System.register(['other'], (function () { 'use strict'; return { - setters: [function () {}], - execute: function () { + setters: [null], + execute: (function () { - } + }) }; -}); +})); diff --git a/test/form/samples/prune-pure-unused-import-function/_expected/umd.js b/test/form/samples/prune-pure-unused-import-function/_expected/umd.js index 44508fbc372..f0ccb62ab6d 100644 --- a/test/form/samples/prune-pure-unused-import-function/_expected/umd.js +++ b/test/form/samples/prune-pure-unused-import-function/_expected/umd.js @@ -1,8 +1,8 @@ (function (factory) { typeof define === 'function' && define.amd ? define(['other'], factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; -}))); +})); diff --git a/test/form/samples/prune-pure-unused-import/_config.js b/test/form/samples/prune-pure-unused-import/_config.js index a3236e50639..8b173901600 100644 --- a/test/form/samples/prune-pure-unused-import/_config.js +++ b/test/form/samples/prune-pure-unused-import/_config.js @@ -1,8 +1,8 @@ -module.exports = { +module.exports = defineTest({ description: 'prunes pure unused external imports ([#1352])', expectedWarnings: ['EMPTY_BUNDLE'], options: { external: ['external', 'other'], treeshake: { moduleSideEffects: 'no-external' } } -}; +}); diff --git a/test/form/samples/prune-pure-unused-import/_expected/amd.js b/test/form/samples/prune-pure-unused-import/_expected/amd.js index f9f8229aa40..a9e9419e212 100644 --- a/test/form/samples/prune-pure-unused-import/_expected/amd.js +++ b/test/form/samples/prune-pure-unused-import/_expected/amd.js @@ -1,5 +1,5 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; -}); +})); diff --git a/test/form/samples/prune-pure-unused-import/_expected/iife.js b/test/form/samples/prune-pure-unused-import/_expected/iife.js index 43ef5426880..31dfeb95ed9 100644 --- a/test/form/samples/prune-pure-unused-import/_expected/iife.js +++ b/test/form/samples/prune-pure-unused-import/_expected/iife.js @@ -3,4 +3,4 @@ -}()); +})(); diff --git a/test/form/samples/prune-pure-unused-import/_expected/system.js b/test/form/samples/prune-pure-unused-import/_expected/system.js index a702f2b06ef..343cc3a5100 100644 --- a/test/form/samples/prune-pure-unused-import/_expected/system.js +++ b/test/form/samples/prune-pure-unused-import/_expected/system.js @@ -1,10 +1,10 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { - } + }) }; -}); +})); diff --git a/test/form/samples/prune-pure-unused-import/_expected/umd.js b/test/form/samples/prune-pure-unused-import/_expected/umd.js index 8bf6301d469..a39fba4f3da 100644 --- a/test/form/samples/prune-pure-unused-import/_expected/umd.js +++ b/test/form/samples/prune-pure-unused-import/_expected/umd.js @@ -1,8 +1,8 @@ (function (factory) { typeof define === 'function' && define.amd ? define(factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; -}))); +})); diff --git a/test/form/samples/pure-class-field/_config.js b/test/form/samples/pure-class-field/_config.js index d2fd9bd5e0a..8f51cca1499 100644 --- a/test/form/samples/pure-class-field/_config.js +++ b/test/form/samples/pure-class-field/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'retains pure annotations in class fields' -}; +}); diff --git a/test/form/samples/pure-class-field/_expected.js b/test/form/samples/pure-class-field/_expected.js index b03c81c0cd0..fb9b18d9965 100644 --- a/test/form/samples/pure-class-field/_expected.js +++ b/test/form/samples/pure-class-field/_expected.js @@ -3,4 +3,4 @@ class main { static [/*#__PURE__*/ W()]; } -export default main; +export { main as default }; diff --git a/test/form/samples/pure-comment-line-break/_config.js b/test/form/samples/pure-comment-line-break/_config.js index 3a1351bf2fd..fc087cdd4da 100644 --- a/test/form/samples/pure-comment-line-break/_config.js +++ b/test/form/samples/pure-comment-line-break/_config.js @@ -1,3 +1,4 @@ -module.exports = { - description: 'adjust line-break handling when dealing with pure annotations' -}; +module.exports = defineTest({ + description: 'adjust line-break handling when dealing with pure annotations', + expectedWarnings: ['INVALID_ANNOTATION'] +}); diff --git a/test/form/samples/pure-comment-line-break/_expected.js b/test/form/samples/pure-comment-line-break/_expected.js index 2594544f535..45f13faa794 100644 --- a/test/form/samples/pure-comment-line-break/_expected.js +++ b/test/form/samples/pure-comment-line-break/_expected.js @@ -1,37 +1,56 @@ const x = 'code'; -console.log('should remain impure'); +console.log('code0'); -console.log('should remain impure'); +console.log('code1'); -console.log('code'); -console.log('should remain impure'); +console.log('code2'); -console.log('code'); -console.log('should remain impure'); -console.log('should remain impure'); +console.log('code3'); -console.log('code'); -console.log('should remain impure'); +console.log('code4'); -console.log('code'), -console.log('should remain impure'); +console.log('code5'); -console.log('code'), -console.log('should remain impure'); +console.log('code6'); -console.log('should remain impure'); +console.log('code7'); -console.log('code'); -console.log('should remain impure'); +console.log('code8'); -console.log('should remain impure'); +console.log('code9'); -console.log('should remain impure') ; +console.log('code10'), +console.log('code11'); -console.log('code'); -console.log('should remain impure', x); +console.log('code12'), +console.log('code13'); + +console.log('code14'); + +console.log('code15'); +console.log('code16'); + +console.log('code17'); + +console.log('code18') ; + +console.log('code19'); +console.log('code20', x); { - console.log('should remain impure'); + console.log('code21'); } +keep1() ; keep2(); +keep3() ; +keep4() ; /* other comment */ keep5(); +keep6() ; // other comment +keep7(); +keep8() && keep9(); + + Keep1() , Keep2(), +Keep3() , +Keep4() , /* other comment */ Keep5(), +Keep6() , // other comment +Keep7(), +Keep8() && Keep9(); diff --git a/test/form/samples/pure-comment-line-break/dep.js b/test/form/samples/pure-comment-line-break/dep.js index 724095977ba..86c31d2f783 100644 --- a/test/form/samples/pure-comment-line-break/dep.js +++ b/test/form/samples/pure-comment-line-break/dep.js @@ -1,3 +1,3 @@ const x = 'code';//@__PURE__ export default x; -console.log('should remain impure'); +console.log('code0'); diff --git a/test/form/samples/pure-comment-line-break/main.js b/test/form/samples/pure-comment-line-break/main.js index a3a6d9a181c..2484e4d827c 100644 --- a/test/form/samples/pure-comment-line-break/main.js +++ b/test/form/samples/pure-comment-line-break/main.js @@ -1,44 +1,82 @@ /*@__PURE__*/ (() => {})(); -console.log('should remain impure'); -console.log('code');//@__PURE__ +console.log('code1'); /*@__PURE__*/ +(() => {})(), /*@__PURE__*/(() => {})(); + +console.log('code2'); /*@__PURE__*/ +(() => {})() || /*@__PURE__*/(() => {})(); + +console.log('code3'); /*@__PURE__*/ +(() => {})() + /*@__PURE__*/(() => {})(); + +console.log('code4'); /*@__PURE__*/ +(() => {})() ? /*@__PURE__*/(() => {})() : /*@__PURE__*/(() => {})(); + +console.log('code5'); /*@__PURE__*/ +foo?.bar(); + +console.log('code6');//@__PURE__ (() => {})(); -console.log('should remain impure'); -console.log('code')/*@__PURE__*/; +console.log('code7')/*@__PURE__*/; (() => {})(); -console.log('should remain impure'); +console.log('code8'); (() => {})();//@__PURE__ (() => {})(); -console.log('should remain impure'); -console.log('code');/*@__PURE__*///@__PURE__ +console.log('code9');/*@__PURE__*///@__PURE__ /*@__PURE__*/ (() => {})(); -console.log('should remain impure'); -console.log('code'),//@__PURE__ -(() => {})(),console.log('should remain impure'); +console.log('code10'),//@__PURE__ +(() => {})(),console.log('code11'); -console.log('code')/*@__PURE__*/, -(() => {})(),console.log('should remain impure'); +console.log('code12')/*@__PURE__*/, +(() => {})(),console.log('code13'); (() => {})(),//@__PURE__ -(() => {})(),console.log('should remain impure'); +(() => {})(),console.log('code14'); -console.log('code');//@__PURE__ -;console.log('should remain impure'); +console.log('code15');//@__PURE__ +;console.log('code16'); -/*@__PURE__*/true && console.log('should remain impure'); +/*@__PURE__*/true && console.log('code17'); -/*@__PURE__*/true ? console.log('should remain impure') : console.log('code'); +/*@__PURE__*/true ? console.log('code18') : console.log('removed'); -console.log('code');//@__PURE__ +console.log('code19');//@__PURE__ import code from './dep.js'; -console.log('should remain impure', code); +console.log('code20', code); /*@__PURE__*/ if (true) { - console.log('should remain impure'); + console.log('code21'); } + +/*@__PURE__*/ drop1(); +/*@__PURE__*/ +drop2(); +keep1() /*@__PURE__*/ ; keep2(); +keep3() ; /*@__PURE__*/ +drop3(); +keep4() /*@__PURE__*/ ; /* other comment */ keep5(); +keep6() /*@__PURE__*/ ; // other comment +keep7(); +keep8() /*@__PURE__*/ && keep9(); + +/*@__PURE__*/ Drop1(), +/*@__PURE__*/ +Drop2(), +Keep1() /*@__PURE__*/ , Keep2(), +Keep3() , /*@__PURE__*/ +Drop3(), +Keep4() /*@__PURE__*/ , /* other comment */ Keep5(), +Keep6() /*@__PURE__*/ , // other comment +Keep7(), +Keep8() /*@__PURE__*/ && Keep9(); + +/*@__PURE__*/ Drop10(), +/*@__PURE__*/ Drop11(), +/*@__PURE__*/ Drop12(), +/*@__PURE__*/ Drop13(); diff --git a/test/form/samples/pure-comment-not-first/_config.js b/test/form/samples/pure-comment-not-first/_config.js new file mode 100644 index 00000000000..ce3eb6f60c8 --- /dev/null +++ b/test/form/samples/pure-comment-not-first/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'recognizes pure comments when there are other comments in between' +}); diff --git a/test/form/samples/pure-comment-not-first/_expected.js b/test/form/samples/pure-comment-not-first/_expected.js new file mode 100644 index 00000000000..f5c276d8f60 --- /dev/null +++ b/test/form/samples/pure-comment-not-first/_expected.js @@ -0,0 +1,3 @@ +const five = /* #__PURE__ */ /* foo */ add(2, 3); + +export { five }; diff --git a/test/form/samples/pure-comment-not-first/main.js b/test/form/samples/pure-comment-not-first/main.js new file mode 100644 index 00000000000..2c04a68e103 --- /dev/null +++ b/test/form/samples/pure-comment-not-first/main.js @@ -0,0 +1,2 @@ +const four = /* #__PURE__ */ /* foo */ add(2, 2); +export const five = /* #__PURE__ */ /* foo */ add(2, 3); diff --git a/test/form/samples/pure-comment-scenarios-complex/_config.js b/test/form/samples/pure-comment-scenarios-complex/_config.js index d045ae566bc..c3f85cff1c2 100644 --- a/test/form/samples/pure-comment-scenarios-complex/_config.js +++ b/test/form/samples/pure-comment-scenarios-complex/_config.js @@ -1,5 +1,6 @@ // tests compiled from https://github.com/mishoo/UglifyJS2/blob/bcebacbb9e7ddac7d9c0e4ca2c7e0faf0e0bca7c/test/compress/issue-1261.js -module.exports = { - description: 'correctly handles various advanced pure comment scenarios' -}; +module.exports = defineTest({ + description: 'correctly handles various advanced pure comment scenarios', + expectedWarnings: ['INVALID_ANNOTATION'] +}); diff --git a/test/form/samples/pure-comment-scenarios-complex/_expected.js b/test/form/samples/pure-comment-scenarios-complex/_expected.js index 32b4350eab2..c0b4e0e0943 100644 --- a/test/form/samples/pure-comment-scenarios-complex/_expected.js +++ b/test/form/samples/pure-comment-scenarios-complex/_expected.js @@ -1,5 +1,6 @@ // pure top-level IIFE will be dropped + // pure top-level IIFE assigned to unreferenced var will not be dropped global.iife1 = /*@__PURE__*/(function() { console.log("iife1"); @@ -7,15 +8,15 @@ global.iife1 = /*@__PURE__*/(function() { return iife1; })(); -// comment #__PURE__ comment -bar(), baz(), quux(); + +baz(), quux(); a.b(), f.g(); -/* @__PURE__ */(function(){})() || true ? foo() : bar(); foo() ; -/* @__PURE__ */(function(){})() && false ? foo() : bar(); +foo() ; +bar(); bar(); /* @__PURE__ */(function(){})() + "foo" ? bar() : baz(); "foo" + /* @__PURE__ */(function(){})() ? bar() : baz(); /* @__PURE__ */(function(){})() ? foo() : foo(); [/* @__PURE__ */(function(){})()] ? foo() : bar(); -!{ foo: /* @__PURE__ */(function(){})() } ? bar() : baz(); +!{ } ? bar() : baz(); diff --git a/test/form/samples/pure-comment-scenarios-simple/_config.js b/test/form/samples/pure-comment-scenarios-simple/_config.js index 71266b1bba0..9bf852418de 100644 --- a/test/form/samples/pure-comment-scenarios-simple/_config.js +++ b/test/form/samples/pure-comment-scenarios-simple/_config.js @@ -1,5 +1,6 @@ // tests compiled from https://github.com/mishoo/UglifyJS2/blob/88c8f4e363e0d585b33ea29df560243d3dc74ce1/test/compress/pure_funcs.js -module.exports = { - description: 'correctly handles various pure comment scenarios' -}; +module.exports = defineTest({ + description: 'correctly handles various pure comment scenarios', + expectedWarnings: ['INVALID_ANNOTATION'] +}); diff --git a/test/form/samples/pure-comment-scenarios-simple/_expected.js b/test/form/samples/pure-comment-scenarios-simple/_expected.js index 4ff2aeb3e3e..562d2bce098 100644 --- a/test/form/samples/pure-comment-scenarios-simple/_expected.js +++ b/test/form/samples/pure-comment-scenarios-simple/_expected.js @@ -1,36 +1,36 @@ // removed // can be simplified -(/*@__PURE__*/ x(), y()); -(/*@__PURE__*/ new x(), y()); +( y()); +( y()); (w(), y()); (w(), y()); /*@__PURE__*/(g() || h())(x(), y()); /*@__PURE__*/new (g() || h())(x(), y()); -(/*@__PURE__*/ (a() || b()))(c(), d()); -new (/*@__PURE__*/ (a() || b()))(c(), d()); +( (a() || b()))(c(), d()); +new ( (a() || b()))(c(), d()); [ /*@__PURE__*/ x(), y() ]; [ /*@__PURE__*/ new x(), y() ]; [ w(), /*@__PURE__*/ x(), y() ]; [ w(), /*@__PURE__*/ new x(), y() ]; // retained -(/*@__PURE__*/ a)(); -(/*@__PURE__*/ b)(1)(2)(3); +( a)(); +( b)(1)(2)(3); (/*@__PURE__*/ c(1))(2)(3); (/*@__PURE__*/ d(1)(2))(3); -(/*@__PURE__*/ e).x(1).y(2).z(3); -(/*@__PURE__*/ f.x)(1).y(2).z(3); +( e).x(1).y(2).z(3); +( f.x)(1).y(2).z(3); (/*@__PURE__*/ g.x(1)).y(2).z(3); (/*@__PURE__*/ h.x(1).y)(2).z(3); (/*@__PURE__*/ i.x(1).y(2)).z(3); (/*@__PURE__*/ j.x(1).y(2).z)(3); -new (/*@__PURE__*/ k)(); -new (/*@__PURE__*/ l)(1)(2)(3); +new ( k)(); +new ( l)(1)(2)(3); (/*@__PURE__*/ new m(1))(2)(3); (/*@__PURE__*/ new n(1)(2))(3); -new (/*@__PURE__*/ o).x(1).y(2).z(3); -/* */ new (/*@__PURE__*/ p.x)(1).y(2).z(3); +new ( o).x(1).y(2).z(3); +/* */ new ( p.x)(1).y(2).z(3); (/*@__PURE__*/ new q.x(1)).y(2).z(3); (/*@__PURE__*/ new r.x(1).y)(2).z(3); (/*@__PURE__*/ new s.x(1).y(2)).z(3); diff --git a/test/form/samples/pure-comment-scenarios-simple/main.js b/test/form/samples/pure-comment-scenarios-simple/main.js index 80d5a4443e0..8eb318f629a 100644 --- a/test/form/samples/pure-comment-scenarios-simple/main.js +++ b/test/form/samples/pure-comment-scenarios-simple/main.js @@ -17,6 +17,7 @@ (/*@__PURE__*/ p.x(1).y(2).z(3)); [ /*@__PURE__*/ q() ]; /*@__PURE__*/ new r(); +new /*@__PURE__*/ r(); /*@__PURE__*/ (new s()); (/*@__PURE__*/ new t()); /*@__PURE__*/ new u(1)(2)(3); diff --git a/test/form/samples/pure-comments-disabled/_config.js b/test/form/samples/pure-comments-disabled/_config.js index bd647a41ced..6964d13f7c1 100644 --- a/test/form/samples/pure-comments-disabled/_config.js +++ b/test/form/samples/pure-comments-disabled/_config.js @@ -1,8 +1,9 @@ -module.exports = { +module.exports = defineTest({ description: 'does not rely on pure annotations if they are disabled', options: { treeshake: { annotations: false } - } -}; + }, + expectedWarnings: ['INVALID_ANNOTATION'] +}); diff --git a/test/form/samples/pure-comments-disabled/_expected.js b/test/form/samples/pure-comments-disabled/_expected.js index dae6dbd4fa4..01d3844659d 100644 --- a/test/form/samples/pure-comments-disabled/_expected.js +++ b/test/form/samples/pure-comments-disabled/_expected.js @@ -4,3 +4,25 @@ console.log('code'); console.log('should remain impure'); + +/*@__PURE__*/ drop1(); +/*@__PURE__*/ +drop2(); +keep1() ; keep2(); +keep3() ; /*@__PURE__*/ +drop3(); +keep4() ; /* other comment */ keep5(); +keep6() ; // other comment +keep7(); +keep8() && keep9(); + +/*@__PURE__*/ Drop1(), +/*@__PURE__*/ +Drop2(), +Keep1() , Keep2(), +Keep3() , /*@__PURE__*/ +Drop3(), +Keep4() , /* other comment */ Keep5(), +Keep6() , // other comment +Keep7(), +Keep8() && Keep9(); diff --git a/test/form/samples/pure-comments-disabled/main.js b/test/form/samples/pure-comments-disabled/main.js index bafd2b7cba8..04c495a0f05 100644 --- a/test/form/samples/pure-comments-disabled/main.js +++ b/test/form/samples/pure-comments-disabled/main.js @@ -5,3 +5,25 @@ console.log('code')/*@__PURE__*/; /*@__PURE__*/(() => {})(); console.log('should remain impure'); + +/*@__PURE__*/ drop1(); +/*@__PURE__*/ +drop2(); +keep1() /*@__PURE__*/ ; keep2(); +keep3() ; /*@__PURE__*/ +drop3(); +keep4() /*@__PURE__*/ ; /* other comment */ keep5(); +keep6() /*@__PURE__*/ ; // other comment +keep7(); +keep8() /*@__PURE__*/ && keep9(); + +/*@__PURE__*/ Drop1(), +/*@__PURE__*/ +Drop2(), +Keep1() /*@__PURE__*/ , Keep2(), +Keep3() , /*@__PURE__*/ +Drop3(), +Keep4() /*@__PURE__*/ , /* other comment */ Keep5(), +Keep6() /*@__PURE__*/ , // other comment +Keep7(), +Keep8() /*@__PURE__*/ && Keep9(); diff --git a/test/form/samples/pure-comments-multiple/_config.js b/test/form/samples/pure-comments-multiple/_config.js index 3c29e89762d..4793b277007 100644 --- a/test/form/samples/pure-comments-multiple/_config.js +++ b/test/form/samples/pure-comments-multiple/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'does not associate multiple "pure" comments before a token with subsequent tokens' -}; +}); diff --git a/test/form/samples/quote-id/_config.js b/test/form/samples/quote-id/_config.js index e46f5b0a7d9..1ab581f9beb 100644 --- a/test/form/samples/quote-id/_config.js +++ b/test/form/samples/quote-id/_config.js @@ -1,15 +1,15 @@ -const path = require('path'); +const path = require('node:path'); const external1 = "quoted'\r\n\u2028\u2029external1"; const external2 = path.join(__dirname, "quoted'\r\n\u2028\u2029external2"); const external3 = 'C:\\File\\Path.js'; -module.exports = { +module.exports = defineTest({ description: 'handles escaping for external ids', options: { output: { paths: id => { - if (id.startsWith('C:')) return id; + if (id === external3) return id; return path.relative(__dirname, id); }, name: 'Q', @@ -21,7 +21,7 @@ module.exports = { }, plugins: [ { - resolveId(id, parent) { + resolveId(id) { if (id === 'external1') { return { id: external1, external: true }; } @@ -35,4 +35,4 @@ module.exports = { } ] } -}; +}); diff --git a/test/form/samples/quote-id/_expected/amd.js b/test/form/samples/quote-id/_expected/amd.js index aba63d8d282..1e1788b3070 100644 --- a/test/form/samples/quote-id/_expected/amd.js +++ b/test/form/samples/quote-id/_expected/amd.js @@ -1,7 +1,7 @@ define(['quoted\'\ \ -\
\
external1', './quoted\'\ \ -\
\
external2', './C:/File/Path'], function (quoted_____external1, quoted_____external2, Path_js) { 'use strict'; +\
\
external1', 'quoted\'\ \ +\
\
external2', 'C:\\File\\Path.js'], (function (quoted_____external1, quoted_____external2, Path_js) { 'use strict'; console.log(quoted_____external1.foo, quoted_____external2.bar, Path_js.baz); -}); +})); diff --git a/test/form/samples/quote-id/_expected/cjs.js b/test/form/samples/quote-id/_expected/cjs.js index 9468de1d0d0..be514723275 100644 --- a/test/form/samples/quote-id/_expected/cjs.js +++ b/test/form/samples/quote-id/_expected/cjs.js @@ -2,8 +2,8 @@ var quoted_____external1 = require('quoted\'\ \ \
\
external1'); -var quoted_____external2 = require('./quoted\'\ \ +var quoted_____external2 = require('quoted\'\ \ \
\
external2'); -var Path_js = require('./C:/File/Path.js'); +var Path_js = require('C:\\File\\Path.js'); console.log(quoted_____external1.foo, quoted_____external2.bar, Path_js.baz); diff --git a/test/form/samples/quote-id/_expected/es.js b/test/form/samples/quote-id/_expected/es.js index 182f5ee556a..cb0fe35580d 100644 --- a/test/form/samples/quote-id/_expected/es.js +++ b/test/form/samples/quote-id/_expected/es.js @@ -1,7 +1,7 @@ import { foo } from 'quoted\'\ \ \
\
external1'; -import { bar } from './quoted\'\ \ +import { bar } from 'quoted\'\ \ \
\
external2'; -import { baz } from './C:/File/Path.js'; +import { baz } from 'C:\\File\\Path.js'; console.log(foo, bar, baz); diff --git a/test/form/samples/quote-id/_expected/iife.js b/test/form/samples/quote-id/_expected/iife.js index 2ba4ceac1bf..497fa5304cb 100644 --- a/test/form/samples/quote-id/_expected/iife.js +++ b/test/form/samples/quote-id/_expected/iife.js @@ -3,4 +3,4 @@ console.log(quoted_____external1.foo, quoted_____external2.bar, Path_js.baz); -}(quotedExternal1, quotedExternal2, quotedExternal3)); +})(quotedExternal1, quotedExternal2, quotedExternal3); diff --git a/test/form/samples/quote-id/_expected/system.js b/test/form/samples/quote-id/_expected/system.js index 2043821f04c..f6906e3bc49 100644 --- a/test/form/samples/quote-id/_expected/system.js +++ b/test/form/samples/quote-id/_expected/system.js @@ -1,6 +1,6 @@ System.register('Q', ['quoted\'\ \ -\
\
external1', './quoted\'\ \ -\
\
external2', './C:/File/Path.js'], function () { +\
\
external1', 'quoted\'\ \ +\
\
external2', 'C:\\File\\Path.js'], (function () { 'use strict'; var foo, bar, baz; return { @@ -11,10 +11,10 @@ System.register('Q', ['quoted\'\ \ }, function (module) { baz = module.baz; }], - execute: function () { + execute: (function () { console.log(foo, bar, baz); - } + }) }; -}); +})); diff --git a/test/form/samples/quote-id/_expected/umd.js b/test/form/samples/quote-id/_expected/umd.js index f59f3c56cdd..5fcb5aa6501 100644 --- a/test/form/samples/quote-id/_expected/umd.js +++ b/test/form/samples/quote-id/_expected/umd.js @@ -1,13 +1,13 @@ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('quoted\'\ \ -\
\
external1'), require('./quoted\'\ \ -\
\
external2'), require('./C:/File/Path.js')) : +\
\
external1'), require('quoted\'\ \ +\
\
external2'), require('C:\\File\\Path.js')) : typeof define === 'function' && define.amd ? define(['quoted\'\ \ -\
\
external1', './quoted\'\ \ -\
\
external2', './C:/File/Path'], factory) : +\
\
external1', 'quoted\'\ \ +\
\
external2', 'C:\\File\\Path.js'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.quotedExternal1, global.quotedExternal2, global.quotedExternal3)); -}(this, (function (quoted_____external1, quoted_____external2, Path_js) { 'use strict'; +})(this, (function (quoted_____external1, quoted_____external2, Path_js) { 'use strict'; console.log(quoted_____external1.foo, quoted_____external2.bar, Path_js.baz); -}))); +})); diff --git a/test/form/samples/re-export-aliasing/_config.js b/test/form/samples/re-export-aliasing/_config.js index ae834c41d3e..ea6d8f7afa8 100644 --- a/test/form/samples/re-export-aliasing/_config.js +++ b/test/form/samples/re-export-aliasing/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'external re-exports aliasing', options: { output: { @@ -7,4 +7,4 @@ module.exports = { }, external: ['d'] } -}; +}); diff --git a/test/form/samples/re-export-aliasing/_expected/amd.js b/test/form/samples/re-export-aliasing/_expected/amd.js index 18490b4afd7..5415158201e 100644 --- a/test/form/samples/re-export-aliasing/_expected/amd.js +++ b/test/form/samples/re-export-aliasing/_expected/amd.js @@ -1,14 +1,10 @@ -define(['exports', 'd'], function (exports, d) { 'use strict'; +define(['exports', 'd'], (function (exports, d) { 'use strict'; - Object.defineProperty(exports, 'b', { + Object.defineProperty(exports, "b", { enumerable: true, - get: function () { - return d.d; - } + get: function () { return d.d; } }); - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/form/samples/re-export-aliasing/_expected/cjs.js b/test/form/samples/re-export-aliasing/_expected/cjs.js index a5824426066..f5b81b0e189 100644 --- a/test/form/samples/re-export-aliasing/_expected/cjs.js +++ b/test/form/samples/re-export-aliasing/_expected/cjs.js @@ -1,14 +1,10 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - var d = require('d'); -Object.defineProperty(exports, 'b', { +Object.defineProperty(exports, "b", { enumerable: true, - get: function () { - return d.d; - } + get: function () { return d.d; } }); diff --git a/test/form/samples/re-export-aliasing/_expected/iife.js b/test/form/samples/re-export-aliasing/_expected/iife.js index a18624c85e4..6b77bd15f13 100644 --- a/test/form/samples/re-export-aliasing/_expected/iife.js +++ b/test/form/samples/re-export-aliasing/_expected/iife.js @@ -3,15 +3,11 @@ var reexportsAliasingExternal = (function (exports, d) { - Object.defineProperty(exports, 'b', { + Object.defineProperty(exports, "b", { enumerable: true, - get: function () { - return d.d; - } + get: function () { return d.d; } }); - Object.defineProperty(exports, '__esModule', { value: true }); - return exports; -}({}, d)); +})({}, d); diff --git a/test/form/samples/re-export-aliasing/_expected/system.js b/test/form/samples/re-export-aliasing/_expected/system.js index 8e40d215211..50f04a38896 100644 --- a/test/form/samples/re-export-aliasing/_expected/system.js +++ b/test/form/samples/re-export-aliasing/_expected/system.js @@ -1,13 +1,13 @@ -System.register('reexportsAliasingExternal', ['d'], function (exports) { +System.register('reexportsAliasingExternal', ['d'], (function (exports) { 'use strict'; return { setters: [function (module) { - exports('b', module.d); + exports("b", module.d); }], - execute: function () { + execute: (function () { - } + }) }; -}); +})); diff --git a/test/form/samples/re-export-aliasing/_expected/umd.js b/test/form/samples/re-export-aliasing/_expected/umd.js index b3d0d902125..1fb6d31a4b6 100644 --- a/test/form/samples/re-export-aliasing/_expected/umd.js +++ b/test/form/samples/re-export-aliasing/_expected/umd.js @@ -2,15 +2,11 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('d')) : typeof define === 'function' && define.amd ? define(['exports', 'd'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.reexportsAliasingExternal = {}, global.d)); -}(this, (function (exports, d) { 'use strict'; +})(this, (function (exports, d) { 'use strict'; - Object.defineProperty(exports, 'b', { + Object.defineProperty(exports, "b", { enumerable: true, - get: function () { - return d.d; - } + get: function () { return d.d; } }); - Object.defineProperty(exports, '__esModule', { value: true }); - -}))); +})); diff --git a/test/form/samples/reassigned-exported-functions-and-classes/_config.js b/test/form/samples/reassigned-exported-functions-and-classes/_config.js index 3f84a3334e9..6e812b8c2b6 100644 --- a/test/form/samples/reassigned-exported-functions-and-classes/_config.js +++ b/test/form/samples/reassigned-exported-functions-and-classes/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'use legal names for exported functions and classed (#1943)', options: { output: { name: 'bundle' } } -}; +}); diff --git a/test/form/samples/reassigned-exported-functions-and-classes/_expected/amd.js b/test/form/samples/reassigned-exported-functions-and-classes/_expected/amd.js index 5daa7ae0d44..9b2fa64c035 100644 --- a/test/form/samples/reassigned-exported-functions-and-classes/_expected/amd.js +++ b/test/form/samples/reassigned-exported-functions-and-classes/_expected/amd.js @@ -1,4 +1,4 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; function foo () {} foo = 1; @@ -9,6 +9,4 @@ define(['exports'], function (exports) { 'use strict'; exports.bar = bar; exports.foo = foo; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/form/samples/reassigned-exported-functions-and-classes/_expected/cjs.js b/test/form/samples/reassigned-exported-functions-and-classes/_expected/cjs.js index 953927befc5..d9fbc579806 100644 --- a/test/form/samples/reassigned-exported-functions-and-classes/_expected/cjs.js +++ b/test/form/samples/reassigned-exported-functions-and-classes/_expected/cjs.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - function foo () {} foo = 1; diff --git a/test/form/samples/reassigned-exported-functions-and-classes/_expected/iife.js b/test/form/samples/reassigned-exported-functions-and-classes/_expected/iife.js index 7c826511a92..8ba9c38e0cf 100644 --- a/test/form/samples/reassigned-exported-functions-and-classes/_expected/iife.js +++ b/test/form/samples/reassigned-exported-functions-and-classes/_expected/iife.js @@ -10,8 +10,6 @@ var bundle = (function (exports) { exports.bar = bar; exports.foo = foo; - Object.defineProperty(exports, '__esModule', { value: true }); - return exports; -}({})); +})({}); diff --git a/test/form/samples/reassigned-exported-functions-and-classes/_expected/system.js b/test/form/samples/reassigned-exported-functions-and-classes/_expected/system.js index a1e5425461f..b90e7cbcd94 100644 --- a/test/form/samples/reassigned-exported-functions-and-classes/_expected/system.js +++ b/test/form/samples/reassigned-exported-functions-and-classes/_expected/system.js @@ -1,16 +1,16 @@ -System.register('bundle', [], function (exports) { +System.register('bundle', [], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - exports('foo', foo); + exports("foo", foo); function foo () {} - foo = exports('foo', 1); + exports("foo", foo = 1); - class bar {} exports('bar', bar); - bar = exports('bar', 1); + class bar {} exports("bar", bar); + exports("bar", bar = 1); - } + }) }; -}); +})); diff --git a/test/form/samples/reassigned-exported-functions-and-classes/_expected/umd.js b/test/form/samples/reassigned-exported-functions-and-classes/_expected/umd.js index e869a212530..e749c11030a 100644 --- a/test/form/samples/reassigned-exported-functions-and-classes/_expected/umd.js +++ b/test/form/samples/reassigned-exported-functions-and-classes/_expected/umd.js @@ -2,7 +2,7 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.bundle = {})); -}(this, (function (exports) { 'use strict'; +})(this, (function (exports) { 'use strict'; function foo () {} foo = 1; @@ -13,6 +13,4 @@ exports.bar = bar; exports.foo = foo; - Object.defineProperty(exports, '__esModule', { value: true }); - -}))); +})); diff --git a/test/form/samples/recursive-assignments/_config.js b/test/form/samples/recursive-assignments/_config.js index f14e7c21536..6ff9daff98b 100644 --- a/test/form/samples/recursive-assignments/_config.js +++ b/test/form/samples/recursive-assignments/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'do not fail for pathological recursive algorithms and circular structures' -}; +}); diff --git a/test/form/samples/recursive-calls/_config.js b/test/form/samples/recursive-calls/_config.js index 7258d5addec..436814b9b3c 100644 --- a/test/form/samples/recursive-calls/_config.js +++ b/test/form/samples/recursive-calls/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'do not fail for recursive calls' -}; +}); diff --git a/test/form/samples/recursive-calls/_expected.js b/test/form/samples/recursive-calls/_expected.js index 00f0e5d1be2..b5e78683edd 100644 --- a/test/form/samples/recursive-calls/_expected.js +++ b/test/form/samples/recursive-calls/_expected.js @@ -1,13 +1,3 @@ -const removed4 = () => globalThis.unknown ? removed4() : { x: () => {} }; -removed4().x(); - -const removed8 = { - get x () { - return globalThis.unknown ? removed8.x : { y: () => {} }; - } -}; -removed8.x.y(); - const retained1 = () => globalThis.unknown ? retained1() : console.log( 'effect' ); retained1(); diff --git a/test/form/samples/recursive-calls/main.js b/test/form/samples/recursive-calls/main.js index 89bae2a7738..306972ec96b 100644 --- a/test/form/samples/recursive-calls/main.js +++ b/test/form/samples/recursive-calls/main.js @@ -17,13 +17,6 @@ const removed5 = { }; removed5.x; -const removed6 = { - get x () { - return globalThis.unknown ? removed6.x : () => {}; - } -}; -removed6.x(); - const removed7 = { get x () { return globalThis.unknown ? removed7.x : {}; diff --git a/test/form/samples/recursive-computed-members/_config.js b/test/form/samples/recursive-computed-members/_config.js index acd88490a08..ecc9fdd967f 100644 --- a/test/form/samples/recursive-computed-members/_config.js +++ b/test/form/samples/recursive-computed-members/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'handle recursive computed member access' -}; +}); diff --git a/test/form/samples/recursive-destructuring/_config.js b/test/form/samples/recursive-destructuring/_config.js new file mode 100644 index 00000000000..36b2eac7831 --- /dev/null +++ b/test/form/samples/recursive-destructuring/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'does not fail for recursive variables declarations with destructuring' +}); diff --git a/test/form/samples/recursive-destructuring/_expected.js b/test/form/samples/recursive-destructuring/_expected.js new file mode 100644 index 00000000000..5e79f768e81 --- /dev/null +++ b/test/form/samples/recursive-destructuring/_expected.js @@ -0,0 +1 @@ +var { x } = x; // retained as this should throw diff --git a/test/form/samples/recursive-destructuring/main.js b/test/form/samples/recursive-destructuring/main.js new file mode 100644 index 00000000000..5e79f768e81 --- /dev/null +++ b/test/form/samples/recursive-destructuring/main.js @@ -0,0 +1 @@ +var { x } = x; // retained as this should throw diff --git a/test/form/samples/recursive-literal-values/_config.js b/test/form/samples/recursive-literal-values/_config.js index 490e29b384d..1115a0327ab 100644 --- a/test/form/samples/recursive-literal-values/_config.js +++ b/test/form/samples/recursive-literal-values/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'do not fail for literal values from recursive return values' -}; +}); diff --git a/test/form/samples/recursive-multi-expressions/_config.js b/test/form/samples/recursive-multi-expressions/_config.js index 44fd55b6d27..ca9d39b7ffb 100644 --- a/test/form/samples/recursive-multi-expressions/_config.js +++ b/test/form/samples/recursive-multi-expressions/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'handles recursive multi-expressions' -}; +}); diff --git a/test/form/samples/recursive-multi-expressions/_expected.js b/test/form/samples/recursive-multi-expressions/_expected.js index 7e29ee70457..0df267fb302 100644 --- a/test/form/samples/recursive-multi-expressions/_expected.js +++ b/test/form/samples/recursive-multi-expressions/_expected.js @@ -1,6 +1,7 @@ const unknown = globalThis.unknown; var logical1 = logical1 || (() => {}); +logical1(); logical1()(); logical1.x = 1; logical1().x = 1; @@ -10,6 +11,7 @@ var logical2 = logical2 || console.log; logical2(); var conditional1 = unknown ? conditional1 : () => {}; +conditional1(); conditional1()(); conditional1.x = 1; conditional1().x = 1; diff --git a/test/form/samples/recursive-multi-expressions/main.js b/test/form/samples/recursive-multi-expressions/main.js index 3b959d2d3b7..0df267fb302 100644 --- a/test/form/samples/recursive-multi-expressions/main.js +++ b/test/form/samples/recursive-multi-expressions/main.js @@ -1,7 +1,7 @@ const unknown = globalThis.unknown; var logical1 = logical1 || (() => {}); -logical1(); // removed +logical1(); logical1()(); logical1.x = 1; logical1().x = 1; @@ -11,7 +11,7 @@ var logical2 = logical2 || console.log; logical2(); var conditional1 = unknown ? conditional1 : () => {}; -conditional1(); // removed +conditional1(); conditional1()(); conditional1.x = 1; conditional1().x = 1; diff --git a/test/form/samples/recursive-property-access/_config.js b/test/form/samples/recursive-property-access/_config.js new file mode 100644 index 00000000000..8191c563d74 --- /dev/null +++ b/test/form/samples/recursive-property-access/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'does not fail for recursive variables declarations with property access' +}); diff --git a/test/form/samples/recursive-property-access/_expected.js b/test/form/samples/recursive-property-access/_expected.js new file mode 100644 index 00000000000..52c583f54b2 --- /dev/null +++ b/test/form/samples/recursive-property-access/_expected.js @@ -0,0 +1 @@ +var x = x.x; // retained as this should throw diff --git a/test/form/samples/recursive-property-access/main.js b/test/form/samples/recursive-property-access/main.js new file mode 100644 index 00000000000..52c583f54b2 --- /dev/null +++ b/test/form/samples/recursive-property-access/main.js @@ -0,0 +1 @@ +var x = x.x; // retained as this should throw diff --git a/test/form/samples/recursive-property-call/_config.js b/test/form/samples/recursive-property-call/_config.js deleted file mode 100644 index 99bde22fce9..00000000000 --- a/test/form/samples/recursive-property-call/_config.js +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = { - description: 'handles calls to properties of recursively defined variables' -}; diff --git a/test/form/samples/recursive-property-call/_expected.js b/test/form/samples/recursive-property-call/_expected.js deleted file mode 100644 index 37fff7100ad..00000000000 --- a/test/form/samples/recursive-property-call/_expected.js +++ /dev/null @@ -1,9 +0,0 @@ -var obj1 = obj1; -console.log(obj1.foo()); - -var obj2 = {foo: () => {}}; -var obj2 = {foo: log}; -obj2.foo(); - -var obj3 = {obj: obj3}; -obj3.obj.obj.obj.obj.obj.obj.obj.obj.obj.foo(); diff --git a/test/form/samples/recursive-property-call/main.js b/test/form/samples/recursive-property-call/main.js deleted file mode 100644 index 9337bc08b1d..00000000000 --- a/test/form/samples/recursive-property-call/main.js +++ /dev/null @@ -1,9 +0,0 @@ -var obj1 = obj1; -console.log(obj1.foo()); - -var obj2 = {foo: () => {}}; -var obj2 = {foo: log}; -obj2.foo(); - -var obj3 = {obj: obj3} -obj3.obj.obj.obj.obj.obj.obj.obj.obj.obj.foo() diff --git a/test/form/samples/recursive-return-value-assignments/_config.js b/test/form/samples/recursive-return-value-assignments/_config.js index 66c2c686fe9..89991001c8f 100644 --- a/test/form/samples/recursive-return-value-assignments/_config.js +++ b/test/form/samples/recursive-return-value-assignments/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'handle recursive reassignments of return values' -}; +}); diff --git a/test/form/samples/recursive-this-deoptimization/_config.js b/test/form/samples/recursive-this-deoptimization/_config.js new file mode 100644 index 00000000000..2d5312acb93 --- /dev/null +++ b/test/form/samples/recursive-this-deoptimization/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'handles recursive "this" deoptimizations (#4089)' +}); diff --git a/test/form/samples/recursive-this-deoptimization/_expected.js b/test/form/samples/recursive-this-deoptimization/_expected.js new file mode 100644 index 00000000000..7496f94ac56 --- /dev/null +++ b/test/form/samples/recursive-this-deoptimization/_expected.js @@ -0,0 +1,11 @@ +getObj().getThis().method(); +getObj().getThis().getThis().method(); + +function getObj() { + return { + getThis() { + return this; + }, + method() {}, + }; +} diff --git a/test/form/samples/recursive-this-deoptimization/main.js b/test/form/samples/recursive-this-deoptimization/main.js new file mode 100644 index 00000000000..7496f94ac56 --- /dev/null +++ b/test/form/samples/recursive-this-deoptimization/main.js @@ -0,0 +1,11 @@ +getObj().getThis().method(); +getObj().getThis().getThis().method(); + +function getObj() { + return { + getThis() { + return this; + }, + method() {}, + }; +} diff --git a/test/form/samples/recursive-values/_config.js b/test/form/samples/recursive-values/_config.js index f14e7c21536..6ff9daff98b 100644 --- a/test/form/samples/recursive-values/_config.js +++ b/test/form/samples/recursive-values/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'do not fail for pathological recursive algorithms and circular structures' -}; +}); diff --git a/test/form/samples/recursive-values/_expected.js b/test/form/samples/recursive-values/_expected.js index 64d545cf3ad..ef893559c23 100644 --- a/test/form/samples/recursive-values/_expected.js +++ b/test/form/samples/recursive-values/_expected.js @@ -1,6 +1,4 @@ -var x = x || true; - -x && console.log(1); +console.log(1); var y = {y}; diff --git a/test/form/samples/redeclarations/_config.js b/test/form/samples/redeclarations/_config.js index 17e93c970a1..ca8ad871c66 100644 --- a/test/form/samples/redeclarations/_config.js +++ b/test/form/samples/redeclarations/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'make sure re-declarations via var and function are linked properly' -}; +}); diff --git a/test/form/samples/reexport-external-default-and-name/_config.js b/test/form/samples/reexport-external-default-and-name/_config.js index 6e8c12c648f..855a14b84d1 100644 --- a/test/form/samples/reexport-external-default-and-name/_config.js +++ b/test/form/samples/reexport-external-default-and-name/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'reexports a an external default as a name and imports another name from that dependency', expectedWarnings: ['MIXED_EXPORTS'], @@ -9,4 +9,4 @@ module.exports = { name: 'bundle' } } -}; +}); diff --git a/test/form/samples/reexport-external-default-and-name/_expected/amd.js b/test/form/samples/reexport-external-default-and-name/_expected/amd.js index facbd23389d..d2d4e5a5285 100644 --- a/test/form/samples/reexport-external-default-and-name/_expected/amd.js +++ b/test/form/samples/reexport-external-default-and-name/_expected/amd.js @@ -1,19 +1,10 @@ -define(['exports', 'external'], function (exports, external) { 'use strict'; - - function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } - - var external__default = /*#__PURE__*/_interopDefaultLegacy(external); +define(['exports', 'external'], (function (exports, external) { 'use strict'; const value = 42; - Object.defineProperty(exports, 'default', { - enumerable: true, - get: function () { - return external__default['default']; - } - }); + exports.default = external; exports.value = value; Object.defineProperty(exports, '__esModule', { value: true }); -}); +})); diff --git a/test/form/samples/reexport-external-default-and-name/_expected/cjs.js b/test/form/samples/reexport-external-default-and-name/_expected/cjs.js index ea9f06c5d1a..d0527409c8c 100644 --- a/test/form/samples/reexport-external-default-and-name/_expected/cjs.js +++ b/test/form/samples/reexport-external-default-and-name/_expected/cjs.js @@ -4,16 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true }); var external = require('external'); -function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } - -var external__default = /*#__PURE__*/_interopDefaultLegacy(external); - const value = 42; -Object.defineProperty(exports, 'default', { - enumerable: true, - get: function () { - return external__default['default']; - } -}); +exports.default = external; exports.value = value; diff --git a/test/form/samples/reexport-external-default-and-name/_expected/iife.js b/test/form/samples/reexport-external-default-and-name/_expected/iife.js index 0208526b527..2f9d0738092 100644 --- a/test/form/samples/reexport-external-default-and-name/_expected/iife.js +++ b/test/form/samples/reexport-external-default-and-name/_expected/iife.js @@ -1,22 +1,13 @@ var bundle = (function (exports, external) { 'use strict'; - function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } - - var external__default = /*#__PURE__*/_interopDefaultLegacy(external); - const value = 42; - Object.defineProperty(exports, 'default', { - enumerable: true, - get: function () { - return external__default['default']; - } - }); + exports.default = external; exports.value = value; Object.defineProperty(exports, '__esModule', { value: true }); return exports; -}({}, external)); +})({}, external); diff --git a/test/form/samples/reexport-external-default-and-name/_expected/system.js b/test/form/samples/reexport-external-default-and-name/_expected/system.js index 8791e72c586..d6fe230f753 100644 --- a/test/form/samples/reexport-external-default-and-name/_expected/system.js +++ b/test/form/samples/reexport-external-default-and-name/_expected/system.js @@ -1,13 +1,13 @@ -System.register('bundle', ['external'], function (exports) { +System.register('bundle', ['external'], (function (exports) { 'use strict'; return { setters: [function (module) { - exports('default', module.default); + exports("default", module.default); }], - execute: function () { + execute: (function () { - const value = exports('value', 42); + const value = exports("value", 42); - } + }) }; -}); +})); diff --git a/test/form/samples/reexport-external-default-and-name/_expected/umd.js b/test/form/samples/reexport-external-default-and-name/_expected/umd.js index 9710b5858e4..cf28cf2fa92 100644 --- a/test/form/samples/reexport-external-default-and-name/_expected/umd.js +++ b/test/form/samples/reexport-external-default-and-name/_expected/umd.js @@ -2,22 +2,13 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('external')) : typeof define === 'function' && define.amd ? define(['exports', 'external'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.bundle = {}, global.external)); -}(this, (function (exports, external) { 'use strict'; - - function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } - - var external__default = /*#__PURE__*/_interopDefaultLegacy(external); +})(this, (function (exports, external) { 'use strict'; const value = 42; - Object.defineProperty(exports, 'default', { - enumerable: true, - get: function () { - return external__default['default']; - } - }); + exports.default = external; exports.value = value; Object.defineProperty(exports, '__esModule', { value: true }); -}))); +})); diff --git a/test/form/samples/reexport-external-default-and-namespace/_config.js b/test/form/samples/reexport-external-default-and-namespace/_config.js index 6af73286dd4..67438a5d09a 100644 --- a/test/form/samples/reexport-external-default-and-namespace/_config.js +++ b/test/form/samples/reexport-external-default-and-namespace/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'reexports a default external import as default export (when using named exports)', options: { output: { @@ -8,4 +8,4 @@ module.exports = { }, external: ['external'] } -}; +}); diff --git a/test/form/samples/reexport-external-default-and-namespace/_expected/amd.js b/test/form/samples/reexport-external-default-and-namespace/_expected/amd.js index 216558ef81a..c6a5c24d890 100644 --- a/test/form/samples/reexport-external-default-and-namespace/_expected/amd.js +++ b/test/form/samples/reexport-external-default-and-namespace/_expected/amd.js @@ -1,26 +1,15 @@ -define(['exports', 'external'], function (exports, external) { 'use strict'; +define(['exports', 'external'], (function (exports, external) { 'use strict'; - function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } - var external__default = /*#__PURE__*/_interopDefaultLegacy(external); - - - Object.defineProperty(exports, 'default', { - enumerable: true, - get: function () { - return external__default['default']; - } - }); + exports.default = external; Object.keys(external).forEach(function (k) { - if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, { + if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, { enumerable: true, - get: function () { - return external[k]; - } + get: function () { return external[k]; } }); }); Object.defineProperty(exports, '__esModule', { value: true }); -}); +})); diff --git a/test/form/samples/reexport-external-default-and-namespace/_expected/cjs.js b/test/form/samples/reexport-external-default-and-namespace/_expected/cjs.js index 2099b57d622..7186e412e38 100644 --- a/test/form/samples/reexport-external-default-and-namespace/_expected/cjs.js +++ b/test/form/samples/reexport-external-default-and-namespace/_expected/cjs.js @@ -4,23 +4,12 @@ Object.defineProperty(exports, '__esModule', { value: true }); var external = require('external'); -function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } -var external__default = /*#__PURE__*/_interopDefaultLegacy(external); - - -Object.defineProperty(exports, 'default', { - enumerable: true, - get: function () { - return external__default['default']; - } -}); +exports.default = external; Object.keys(external).forEach(function (k) { - if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, { + if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, { enumerable: true, - get: function () { - return external[k]; - } + get: function () { return external[k]; } }); }); diff --git a/test/form/samples/reexport-external-default-and-namespace/_expected/iife.js b/test/form/samples/reexport-external-default-and-namespace/_expected/iife.js index 58def2bf914..d901647e7c0 100644 --- a/test/form/samples/reexport-external-default-and-namespace/_expected/iife.js +++ b/test/form/samples/reexport-external-default-and-namespace/_expected/iife.js @@ -1,24 +1,13 @@ var bundle = (function (exports, external) { 'use strict'; - function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } - var external__default = /*#__PURE__*/_interopDefaultLegacy(external); - - - Object.defineProperty(exports, 'default', { - enumerable: true, - get: function () { - return external__default['default']; - } - }); + exports.default = external; Object.keys(external).forEach(function (k) { - if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, { + if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, { enumerable: true, - get: function () { - return external[k]; - } + get: function () { return external[k]; } }); }); @@ -26,4 +15,4 @@ var bundle = (function (exports, external) { return exports; -}({}, external)); +})({}, external); diff --git a/test/form/samples/reexport-external-default-and-namespace/_expected/system.js b/test/form/samples/reexport-external-default-and-namespace/_expected/system.js index 35e2ee4b4a8..198f3a53349 100644 --- a/test/form/samples/reexport-external-default-and-namespace/_expected/system.js +++ b/test/form/samples/reexport-external-default-and-namespace/_expected/system.js @@ -1,19 +1,21 @@ -System.register('bundle', ['external'], function (exports) { +System.register('bundle', ['external'], (function (exports) { 'use strict'; - var _starExcludes = { default: 1 }; + var _starExcludes = { + __proto__: null, + default: 1 + }; return { setters: [function (module) { - var _setter = {}; - for (var _$p in module) { - if (!_starExcludes[_$p]) _setter[_$p] = module[_$p]; + var setter = { __proto__: null, default: module.default }; + for (var name in module) { + if (!_starExcludes[name]) setter[name] = module[name]; } - _setter.default = module.default; - exports(_setter); + exports(setter); }], - execute: function () { + execute: (function () { - } + }) }; -}); +})); diff --git a/test/form/samples/reexport-external-default-and-namespace/_expected/umd.js b/test/form/samples/reexport-external-default-and-namespace/_expected/umd.js index 30244c5b778..cc41d653152 100644 --- a/test/form/samples/reexport-external-default-and-namespace/_expected/umd.js +++ b/test/form/samples/reexport-external-default-and-namespace/_expected/umd.js @@ -2,29 +2,16 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('external')) : typeof define === 'function' && define.amd ? define(['exports', 'external'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.bundle = {}, global.external)); -}(this, (function (exports, external) { 'use strict'; +})(this, (function (exports, external) { 'use strict'; - function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } - - var external__default = /*#__PURE__*/_interopDefaultLegacy(external); - - - - Object.defineProperty(exports, 'default', { - enumerable: true, - get: function () { - return external__default['default']; - } - }); + exports.default = external; Object.keys(external).forEach(function (k) { - if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, { + if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, { enumerable: true, - get: function () { - return external[k]; - } + get: function () { return external[k]; } }); }); Object.defineProperty(exports, '__esModule', { value: true }); -}))); +})); diff --git a/test/form/samples/reexport-external-default-as-name-and-name/_config.js b/test/form/samples/reexport-external-default-as-name-and-name/_config.js index 5ccfb6e52a1..9c8a78dbda9 100644 --- a/test/form/samples/reexport-external-default-as-name-and-name/_config.js +++ b/test/form/samples/reexport-external-default-as-name-and-name/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 're-exports a named external export as default', expectedWarnings: ['MIXED_EXPORTS'], options: { @@ -8,4 +8,4 @@ module.exports = { name: 'bundle' } } -}; +}); diff --git a/test/form/samples/reexport-external-default-as-name-and-name/_expected/amd.js b/test/form/samples/reexport-external-default-as-name-and-name/_expected/amd.js index b93f9e14956..0f081608f76 100644 --- a/test/form/samples/reexport-external-default-as-name-and-name/_expected/amd.js +++ b/test/form/samples/reexport-external-default-as-name-and-name/_expected/amd.js @@ -1,18 +1,7 @@ -define(['exports', 'external'], function (exports, external) { 'use strict'; - - function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } - - var external__default = /*#__PURE__*/_interopDefaultLegacy(external); +define(['exports', 'external'], (function (exports, external) { 'use strict'; console.log(external.value); - Object.defineProperty(exports, 'reexported', { - enumerable: true, - get: function () { - return external__default['default']; - } - }); - - Object.defineProperty(exports, '__esModule', { value: true }); + exports.reexported = external; -}); +})); diff --git a/test/form/samples/reexport-external-default-as-name-and-name/_expected/cjs.js b/test/form/samples/reexport-external-default-as-name-and-name/_expected/cjs.js index 85b68bffb19..5c131e7b0d0 100644 --- a/test/form/samples/reexport-external-default-as-name-and-name/_expected/cjs.js +++ b/test/form/samples/reexport-external-default-as-name-and-name/_expected/cjs.js @@ -1,18 +1,7 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - var external = require('external'); -function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } - -var external__default = /*#__PURE__*/_interopDefaultLegacy(external); - console.log(external.value); -Object.defineProperty(exports, 'reexported', { - enumerable: true, - get: function () { - return external__default['default']; - } -}); +exports.reexported = external; diff --git a/test/form/samples/reexport-external-default-as-name-and-name/_expected/iife.js b/test/form/samples/reexport-external-default-as-name-and-name/_expected/iife.js index 71585cd9ae0..4d449cf4fbc 100644 --- a/test/form/samples/reexport-external-default-as-name-and-name/_expected/iife.js +++ b/test/form/samples/reexport-external-default-as-name-and-name/_expected/iife.js @@ -1,21 +1,10 @@ var bundle = (function (exports, external) { 'use strict'; - function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } - - var external__default = /*#__PURE__*/_interopDefaultLegacy(external); - console.log(external.value); - Object.defineProperty(exports, 'reexported', { - enumerable: true, - get: function () { - return external__default['default']; - } - }); - - Object.defineProperty(exports, '__esModule', { value: true }); + exports.reexported = external; return exports; -}({}, external)); +})({}, external); diff --git a/test/form/samples/reexport-external-default-as-name-and-name/_expected/system.js b/test/form/samples/reexport-external-default-as-name-and-name/_expected/system.js index 1b3c4676de4..f0b1bacba82 100644 --- a/test/form/samples/reexport-external-default-as-name-and-name/_expected/system.js +++ b/test/form/samples/reexport-external-default-as-name-and-name/_expected/system.js @@ -1,15 +1,15 @@ -System.register('bundle', ['external'], function (exports) { +System.register('bundle', ['external'], (function (exports) { 'use strict'; var value; return { setters: [function (module) { value = module.value; - exports('reexported', module.default); + exports("reexported", module.default); }], - execute: function () { + execute: (function () { console.log(value); - } + }) }; -}); +})); diff --git a/test/form/samples/reexport-external-default-as-name-and-name/_expected/umd.js b/test/form/samples/reexport-external-default-as-name-and-name/_expected/umd.js index aded447b9b0..487302a71d7 100644 --- a/test/form/samples/reexport-external-default-as-name-and-name/_expected/umd.js +++ b/test/form/samples/reexport-external-default-as-name-and-name/_expected/umd.js @@ -2,21 +2,10 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('external')) : typeof define === 'function' && define.amd ? define(['exports', 'external'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.bundle = {}, global.external)); -}(this, (function (exports, external) { 'use strict'; - - function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } - - var external__default = /*#__PURE__*/_interopDefaultLegacy(external); +})(this, (function (exports, external) { 'use strict'; console.log(external.value); - Object.defineProperty(exports, 'reexported', { - enumerable: true, - get: function () { - return external__default['default']; - } - }); - - Object.defineProperty(exports, '__esModule', { value: true }); + exports.reexported = external; -}))); +})); diff --git a/test/form/samples/reexport-external-default/_config.js b/test/form/samples/reexport-external-default/_config.js index 17dee117ebb..47385d4a921 100644 --- a/test/form/samples/reexport-external-default/_config.js +++ b/test/form/samples/reexport-external-default/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'reexports an external default export', options: { external: ['external1', 'external2'], @@ -7,4 +7,4 @@ module.exports = { name: 'bundle' } } -}; +}); diff --git a/test/form/samples/reexport-external-default/_expected/amd.js b/test/form/samples/reexport-external-default/_expected/amd.js index 5f65595d5fb..df0a0fe358d 100644 --- a/test/form/samples/reexport-external-default/_expected/amd.js +++ b/test/form/samples/reexport-external-default/_expected/amd.js @@ -1,11 +1,7 @@ -define(['external1', 'external2'], function (external1, external2) { 'use strict'; - - function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } - - var external2__default = /*#__PURE__*/_interopDefaultLegacy(external2); +define(['external1', 'external2'], (function (external1, external2) { 'use strict'; console.log(external1.foo); - return external2__default['default']; + return external2; -}); +})); diff --git a/test/form/samples/reexport-external-default/_expected/cjs.js b/test/form/samples/reexport-external-default/_expected/cjs.js index 750215f9ace..f05bf510667 100644 --- a/test/form/samples/reexport-external-default/_expected/cjs.js +++ b/test/form/samples/reexport-external-default/_expected/cjs.js @@ -3,10 +3,6 @@ var external1 = require('external1'); var external2 = require('external2'); -function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } - -var external2__default = /*#__PURE__*/_interopDefaultLegacy(external2); - console.log(external1.foo); -module.exports = external2__default['default']; +module.exports = external2; diff --git a/test/form/samples/reexport-external-default/_expected/iife.js b/test/form/samples/reexport-external-default/_expected/iife.js index 792709f88e5..e6f3e1f291c 100644 --- a/test/form/samples/reexport-external-default/_expected/iife.js +++ b/test/form/samples/reexport-external-default/_expected/iife.js @@ -1,12 +1,8 @@ var bundle = (function (external1, external2) { 'use strict'; - function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } - - var external2__default = /*#__PURE__*/_interopDefaultLegacy(external2); - console.log(external1.foo); - return external2__default['default']; + return external2; -}(external1, external2)); +})(external1, external2); diff --git a/test/form/samples/reexport-external-default/_expected/system.js b/test/form/samples/reexport-external-default/_expected/system.js index 42d170c3da2..c3270706e4a 100644 --- a/test/form/samples/reexport-external-default/_expected/system.js +++ b/test/form/samples/reexport-external-default/_expected/system.js @@ -1,16 +1,16 @@ -System.register('bundle', ['external1', 'external2'], function (exports) { +System.register('bundle', ['external1', 'external2'], (function (exports) { 'use strict'; var foo; return { setters: [function (module) { foo = module.foo; }, function (module) { - exports('default', module.default); + exports("default", module.default); }], - execute: function () { + execute: (function () { console.log(foo); - } + }) }; -}); +})); diff --git a/test/form/samples/reexport-external-default/_expected/umd.js b/test/form/samples/reexport-external-default/_expected/umd.js index 3877fdf1f26..1546f7688bf 100644 --- a/test/form/samples/reexport-external-default/_expected/umd.js +++ b/test/form/samples/reexport-external-default/_expected/umd.js @@ -2,14 +2,10 @@ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('external1'), require('external2')) : typeof define === 'function' && define.amd ? define(['external1', 'external2'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.bundle = factory(global.external1, global.external2)); -}(this, (function (external1, external2) { 'use strict'; - - function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } - - var external2__default = /*#__PURE__*/_interopDefaultLegacy(external2); +})(this, (function (external1, external2) { 'use strict'; console.log(external1.foo); - return external2__default['default']; + return external2; -}))); +})); diff --git a/test/form/samples/reexport-external-name-as-default/_config.js b/test/form/samples/reexport-external-name-as-default/_config.js index 76bfd0844be..951b788645f 100644 --- a/test/form/samples/reexport-external-name-as-default/_config.js +++ b/test/form/samples/reexport-external-name-as-default/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 're-exports a named external export as default', options: { external: ['external'], @@ -7,4 +7,4 @@ module.exports = { name: 'bundle' } } -}; +}); diff --git a/test/form/samples/reexport-external-name-as-default/_expected/amd.js b/test/form/samples/reexport-external-name-as-default/_expected/amd.js index ccae8803919..8b3d2903c66 100644 --- a/test/form/samples/reexport-external-name-as-default/_expected/amd.js +++ b/test/form/samples/reexport-external-name-as-default/_expected/amd.js @@ -1,7 +1,7 @@ -define(['external'], function (external) { 'use strict'; +define(['external'], (function (external) { 'use strict'; return external.value; -}); +})); diff --git a/test/form/samples/reexport-external-name-as-default/_expected/iife.js b/test/form/samples/reexport-external-name-as-default/_expected/iife.js index fc92c34817f..9809edc5712 100644 --- a/test/form/samples/reexport-external-name-as-default/_expected/iife.js +++ b/test/form/samples/reexport-external-name-as-default/_expected/iife.js @@ -5,4 +5,4 @@ var bundle = (function (external) { return external.value; -}(external)); +})(external); diff --git a/test/form/samples/reexport-external-name-as-default/_expected/system.js b/test/form/samples/reexport-external-name-as-default/_expected/system.js index 3c99a21cd8d..df1f7f3f63a 100644 --- a/test/form/samples/reexport-external-name-as-default/_expected/system.js +++ b/test/form/samples/reexport-external-name-as-default/_expected/system.js @@ -1,13 +1,13 @@ -System.register('bundle', ['external'], function (exports) { +System.register('bundle', ['external'], (function (exports) { 'use strict'; return { setters: [function (module) { - exports('default', module.value); + exports("default", module.value); }], - execute: function () { + execute: (function () { - } + }) }; -}); +})); diff --git a/test/form/samples/reexport-external-name-as-default/_expected/umd.js b/test/form/samples/reexport-external-name-as-default/_expected/umd.js index 1523f34d4a2..59bd083e13d 100644 --- a/test/form/samples/reexport-external-name-as-default/_expected/umd.js +++ b/test/form/samples/reexport-external-name-as-default/_expected/umd.js @@ -2,8 +2,8 @@ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('external')) : typeof define === 'function' && define.amd ? define(['external'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.bundle = factory(global.external)); -}(this, (function (external) { 'use strict'; +})(this, (function (external) { 'use strict'; return external.value; -}))); +})); diff --git a/test/form/samples/reexport-external-name-as-default2/_config.js b/test/form/samples/reexport-external-name-as-default2/_config.js index ca3e78aa86f..ef807daf442 100644 --- a/test/form/samples/reexport-external-name-as-default2/_config.js +++ b/test/form/samples/reexport-external-name-as-default2/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 're-exports a named external export as default via another file', options: { external: ['external'], @@ -7,4 +7,4 @@ module.exports = { name: 'bundle' } } -}; +}); diff --git a/test/form/samples/reexport-external-name-as-default2/_expected/amd.js b/test/form/samples/reexport-external-name-as-default2/_expected/amd.js index 0e8dc344cb1..073ba059cc8 100644 --- a/test/form/samples/reexport-external-name-as-default2/_expected/amd.js +++ b/test/form/samples/reexport-external-name-as-default2/_expected/amd.js @@ -1,7 +1,7 @@ -define(['external'], function (external) { 'use strict'; +define(['external'], (function (external) { 'use strict'; return external.objAlias; -}); +})); diff --git a/test/form/samples/reexport-external-name-as-default2/_expected/iife.js b/test/form/samples/reexport-external-name-as-default2/_expected/iife.js index 10d6c813a61..c6248bf83a2 100644 --- a/test/form/samples/reexport-external-name-as-default2/_expected/iife.js +++ b/test/form/samples/reexport-external-name-as-default2/_expected/iife.js @@ -5,4 +5,4 @@ var bundle = (function (external) { return external.objAlias; -}(external)); +})(external); diff --git a/test/form/samples/reexport-external-name-as-default2/_expected/system.js b/test/form/samples/reexport-external-name-as-default2/_expected/system.js index 9b52f598eb2..3e720d84f54 100644 --- a/test/form/samples/reexport-external-name-as-default2/_expected/system.js +++ b/test/form/samples/reexport-external-name-as-default2/_expected/system.js @@ -1,13 +1,13 @@ -System.register('bundle', ['external'], function (exports) { +System.register('bundle', ['external'], (function (exports) { 'use strict'; return { setters: [function (module) { - exports('default', module.objAlias); + exports("default", module.objAlias); }], - execute: function () { + execute: (function () { - } + }) }; -}); +})); diff --git a/test/form/samples/reexport-external-name-as-default2/_expected/umd.js b/test/form/samples/reexport-external-name-as-default2/_expected/umd.js index 38e63b11442..ab53ac88b37 100644 --- a/test/form/samples/reexport-external-name-as-default2/_expected/umd.js +++ b/test/form/samples/reexport-external-name-as-default2/_expected/umd.js @@ -2,8 +2,8 @@ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('external')) : typeof define === 'function' && define.amd ? define(['external'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.bundle = factory(global.external)); -}(this, (function (external) { 'use strict'; +})(this, (function (external) { 'use strict'; return external.objAlias; -}))); +})); diff --git a/test/form/samples/reexport-external-name/_config.js b/test/form/samples/reexport-external-name/_config.js index e64e3c7b2c0..0541c9ae604 100644 --- a/test/form/samples/reexport-external-name/_config.js +++ b/test/form/samples/reexport-external-name/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 're-exports a named export from an external module', options: { external: ['external1', 'external2'], @@ -7,4 +7,4 @@ module.exports = { name: 'bundle' } } -}; +}); diff --git a/test/form/samples/reexport-external-name/_expected/amd.js b/test/form/samples/reexport-external-name/_expected/amd.js index 4f91cd0a717..880717a47e7 100644 --- a/test/form/samples/reexport-external-name/_expected/amd.js +++ b/test/form/samples/reexport-external-name/_expected/amd.js @@ -1,20 +1,14 @@ -define(['exports', 'external1', 'external2'], function (exports, external1, external2) { 'use strict'; +define(['exports', 'external1', 'external2'], (function (exports, external1, external2) { 'use strict'; - Object.defineProperty(exports, 'foo', { + Object.defineProperty(exports, "foo", { enumerable: true, - get: function () { - return external1.foo; - } + get: function () { return external1.foo; } }); - Object.defineProperty(exports, 'bar', { + Object.defineProperty(exports, "bar", { enumerable: true, - get: function () { - return external2.foo; - } + get: function () { return external2.foo; } }); - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/form/samples/reexport-external-name/_expected/cjs.js b/test/form/samples/reexport-external-name/_expected/cjs.js index 06061bbe91c..f6ca999180c 100644 --- a/test/form/samples/reexport-external-name/_expected/cjs.js +++ b/test/form/samples/reexport-external-name/_expected/cjs.js @@ -1,21 +1,15 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - var external1 = require('external1'); var external2 = require('external2'); -Object.defineProperty(exports, 'foo', { +Object.defineProperty(exports, "foo", { enumerable: true, - get: function () { - return external1.foo; - } + get: function () { return external1.foo; } }); -Object.defineProperty(exports, 'bar', { +Object.defineProperty(exports, "bar", { enumerable: true, - get: function () { - return external2.foo; - } + get: function () { return external2.foo; } }); diff --git a/test/form/samples/reexport-external-name/_expected/iife.js b/test/form/samples/reexport-external-name/_expected/iife.js index eb09e7a0823..b72c72be616 100644 --- a/test/form/samples/reexport-external-name/_expected/iife.js +++ b/test/form/samples/reexport-external-name/_expected/iife.js @@ -3,21 +3,15 @@ var bundle = (function (exports, external1, external2) { - Object.defineProperty(exports, 'foo', { + Object.defineProperty(exports, "foo", { enumerable: true, - get: function () { - return external1.foo; - } + get: function () { return external1.foo; } }); - Object.defineProperty(exports, 'bar', { + Object.defineProperty(exports, "bar", { enumerable: true, - get: function () { - return external2.foo; - } + get: function () { return external2.foo; } }); - Object.defineProperty(exports, '__esModule', { value: true }); - return exports; -}({}, external1, external2)); +})({}, external1, external2); diff --git a/test/form/samples/reexport-external-name/_expected/system.js b/test/form/samples/reexport-external-name/_expected/system.js index 73367c2fca4..fb2d43d8390 100644 --- a/test/form/samples/reexport-external-name/_expected/system.js +++ b/test/form/samples/reexport-external-name/_expected/system.js @@ -1,15 +1,15 @@ -System.register('bundle', ['external1', 'external2'], function (exports) { +System.register('bundle', ['external1', 'external2'], (function (exports) { 'use strict'; return { setters: [function (module) { - exports('foo', module.foo); + exports("foo", module.foo); }, function (module) { - exports('bar', module.foo); + exports("bar", module.foo); }], - execute: function () { + execute: (function () { - } + }) }; -}); +})); diff --git a/test/form/samples/reexport-external-name/_expected/umd.js b/test/form/samples/reexport-external-name/_expected/umd.js index e9747b3fdca..014b386e14d 100644 --- a/test/form/samples/reexport-external-name/_expected/umd.js +++ b/test/form/samples/reexport-external-name/_expected/umd.js @@ -2,21 +2,15 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('external1'), require('external2')) : typeof define === 'function' && define.amd ? define(['exports', 'external1', 'external2'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.bundle = {}, global.external1, global.external2)); -}(this, (function (exports, external1, external2) { 'use strict'; +})(this, (function (exports, external1, external2) { 'use strict'; - Object.defineProperty(exports, 'foo', { + Object.defineProperty(exports, "foo", { enumerable: true, - get: function () { - return external1.foo; - } + get: function () { return external1.foo; } }); - Object.defineProperty(exports, 'bar', { + Object.defineProperty(exports, "bar", { enumerable: true, - get: function () { - return external2.foo; - } + get: function () { return external2.foo; } }); - Object.defineProperty(exports, '__esModule', { value: true }); - -}))); +})); diff --git a/test/form/samples/reexport-external-namespace-as/_config.js b/test/form/samples/reexport-external-namespace-as/_config.js index e2705de62c3..b2f6b3ffe03 100644 --- a/test/form/samples/reexport-external-namespace-as/_config.js +++ b/test/form/samples/reexport-external-namespace-as/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'reexport external namespace as name', options: { external: 'external', @@ -7,4 +7,4 @@ module.exports = { globals: { external: 'external' } } } -}; +}); diff --git a/test/form/samples/reexport-external-namespace-as/_expected/amd.js b/test/form/samples/reexport-external-namespace-as/_expected/amd.js index aecab9ce3b0..a34c79682d0 100644 --- a/test/form/samples/reexport-external-namespace-as/_expected/amd.js +++ b/test/form/samples/reexport-external-namespace-as/_expected/amd.js @@ -1,7 +1,6 @@ -define(['exports', 'external'], function (exports, external) { 'use strict'; +define(['exports', 'external'], (function (exports, external) { 'use strict'; - function _interopNamespace(e) { - if (e && e.__esModule) return e; + function _interopNamespaceDefault(e) { var n = Object.create(null); if (e) { Object.keys(e).forEach(function (k) { @@ -9,24 +8,20 @@ define(['exports', 'external'], function (exports, external) { 'use strict'; var d = Object.getOwnPropertyDescriptor(e, k); Object.defineProperty(n, k, d.get ? d : { enumerable: true, - get: function () { - return e[k]; - } + get: function () { return e[k]; } }); } }); } - n['default'] = e; + n.default = e; return Object.freeze(n); } - var external__namespace = /*#__PURE__*/_interopNamespace(external); + var external__namespace = /*#__PURE__*/_interopNamespaceDefault(external); exports.external = external__namespace; exports.indirect = external__namespace; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/form/samples/reexport-external-namespace-as/_expected/cjs.js b/test/form/samples/reexport-external-namespace-as/_expected/cjs.js index 0a67fd34607..c32f787db01 100644 --- a/test/form/samples/reexport-external-namespace-as/_expected/cjs.js +++ b/test/form/samples/reexport-external-namespace-as/_expected/cjs.js @@ -1,11 +1,8 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - var external = require('external'); -function _interopNamespace(e) { - if (e && e.__esModule) return e; +function _interopNamespaceDefault(e) { var n = Object.create(null); if (e) { Object.keys(e).forEach(function (k) { @@ -13,18 +10,16 @@ function _interopNamespace(e) { var d = Object.getOwnPropertyDescriptor(e, k); Object.defineProperty(n, k, d.get ? d : { enumerable: true, - get: function () { - return e[k]; - } + get: function () { return e[k]; } }); } }); } - n['default'] = e; + n.default = e; return Object.freeze(n); } -var external__namespace = /*#__PURE__*/_interopNamespace(external); +var external__namespace = /*#__PURE__*/_interopNamespaceDefault(external); diff --git a/test/form/samples/reexport-external-namespace-as/_expected/iife.js b/test/form/samples/reexport-external-namespace-as/_expected/iife.js index 15e7f8e87da..3e5601fed23 100644 --- a/test/form/samples/reexport-external-namespace-as/_expected/iife.js +++ b/test/form/samples/reexport-external-namespace-as/_expected/iife.js @@ -1,8 +1,7 @@ var bundle = (function (exports, external) { 'use strict'; - function _interopNamespace(e) { - if (e && e.__esModule) return e; + function _interopNamespaceDefault(e) { var n = Object.create(null); if (e) { Object.keys(e).forEach(function (k) { @@ -10,26 +9,22 @@ var bundle = (function (exports, external) { var d = Object.getOwnPropertyDescriptor(e, k); Object.defineProperty(n, k, d.get ? d : { enumerable: true, - get: function () { - return e[k]; - } + get: function () { return e[k]; } }); } }); } - n['default'] = e; + n.default = e; return Object.freeze(n); } - var external__namespace = /*#__PURE__*/_interopNamespace(external); + var external__namespace = /*#__PURE__*/_interopNamespaceDefault(external); exports.external = external__namespace; exports.indirect = external__namespace; - Object.defineProperty(exports, '__esModule', { value: true }); - return exports; -}({}, external)); +})({}, external); diff --git a/test/form/samples/reexport-external-namespace-as/_expected/system.js b/test/form/samples/reexport-external-namespace-as/_expected/system.js index 7b2e8f3cd70..b54d0ef3edc 100644 --- a/test/form/samples/reexport-external-namespace-as/_expected/system.js +++ b/test/form/samples/reexport-external-namespace-as/_expected/system.js @@ -1,14 +1,13 @@ -System.register('bundle', ['external'], function (exports) { +System.register('bundle', ['external'], (function (exports) { 'use strict'; return { setters: [function (module) { - exports('external', module); - exports('indirect', module); + exports({ external: module, indirect: module }); }], - execute: function () { + execute: (function () { - } + }) }; -}); +})); diff --git a/test/form/samples/reexport-external-namespace-as/_expected/umd.js b/test/form/samples/reexport-external-namespace-as/_expected/umd.js index fb54e08e558..7c6d425494d 100644 --- a/test/form/samples/reexport-external-namespace-as/_expected/umd.js +++ b/test/form/samples/reexport-external-namespace-as/_expected/umd.js @@ -2,10 +2,9 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('external')) : typeof define === 'function' && define.amd ? define(['exports', 'external'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.bundle = {}, global.external)); -}(this, (function (exports, external) { 'use strict'; +})(this, (function (exports, external) { 'use strict'; - function _interopNamespace(e) { - if (e && e.__esModule) return e; + function _interopNamespaceDefault(e) { var n = Object.create(null); if (e) { Object.keys(e).forEach(function (k) { @@ -13,24 +12,20 @@ var d = Object.getOwnPropertyDescriptor(e, k); Object.defineProperty(n, k, d.get ? d : { enumerable: true, - get: function () { - return e[k]; - } + get: function () { return e[k]; } }); } }); } - n['default'] = e; + n.default = e; return Object.freeze(n); } - var external__namespace = /*#__PURE__*/_interopNamespace(external); + var external__namespace = /*#__PURE__*/_interopNamespaceDefault(external); exports.external = external__namespace; exports.indirect = external__namespace; - Object.defineProperty(exports, '__esModule', { value: true }); - -}))); +})); diff --git a/test/form/samples/reexport-external-namespace/_config.js b/test/form/samples/reexport-external-namespace/_config.js index 9ffdafe8b0f..9ed34a046f9 100644 --- a/test/form/samples/reexport-external-namespace/_config.js +++ b/test/form/samples/reexport-external-namespace/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 're-exports * from external module (#791)', options: { external: ['external'], @@ -7,4 +7,4 @@ module.exports = { name: 'bundle' } } -}; +}); diff --git a/test/form/samples/reexport-external-namespace/_expected/amd.js b/test/form/samples/reexport-external-namespace/_expected/amd.js index c093b8b7ffe..9b51c2b0d5c 100644 --- a/test/form/samples/reexport-external-namespace/_expected/amd.js +++ b/test/form/samples/reexport-external-namespace/_expected/amd.js @@ -1,16 +1,12 @@ -define(['exports', 'external'], function (exports, external) { 'use strict'; +define(['exports', 'external'], (function (exports, external) { 'use strict'; Object.keys(external).forEach(function (k) { - if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, { + if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, { enumerable: true, - get: function () { - return external[k]; - } + get: function () { return external[k]; } }); }); - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/form/samples/reexport-external-namespace/_expected/cjs.js b/test/form/samples/reexport-external-namespace/_expected/cjs.js index e2a1380e607..9fef33fc417 100644 --- a/test/form/samples/reexport-external-namespace/_expected/cjs.js +++ b/test/form/samples/reexport-external-namespace/_expected/cjs.js @@ -1,16 +1,12 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - var external = require('external'); Object.keys(external).forEach(function (k) { - if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, { + if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, { enumerable: true, - get: function () { - return external[k]; - } + get: function () { return external[k]; } }); }); diff --git a/test/form/samples/reexport-external-namespace/_expected/iife.js b/test/form/samples/reexport-external-namespace/_expected/iife.js index 2a5162801a5..ca384a6aac9 100644 --- a/test/form/samples/reexport-external-namespace/_expected/iife.js +++ b/test/form/samples/reexport-external-namespace/_expected/iife.js @@ -4,16 +4,12 @@ var bundle = (function (exports, external) { Object.keys(external).forEach(function (k) { - if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, { + if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, { enumerable: true, - get: function () { - return external[k]; - } + get: function () { return external[k]; } }); }); - Object.defineProperty(exports, '__esModule', { value: true }); - return exports; -}({}, external)); +})({}, external); diff --git a/test/form/samples/reexport-external-namespace/_expected/system.js b/test/form/samples/reexport-external-namespace/_expected/system.js index 5d92a82f4fe..47c114d26ba 100644 --- a/test/form/samples/reexport-external-namespace/_expected/system.js +++ b/test/form/samples/reexport-external-namespace/_expected/system.js @@ -1,18 +1,21 @@ -System.register('bundle', ['external'], function (exports) { +System.register('bundle', ['external'], (function (exports) { 'use strict'; - var _starExcludes = { default: 1 }; + var _starExcludes = { + __proto__: null, + default: 1 + }; return { setters: [function (module) { - var _setter = {}; - for (var _$p in module) { - if (!_starExcludes[_$p]) _setter[_$p] = module[_$p]; + var setter = { __proto__: null }; + for (var name in module) { + if (!_starExcludes[name]) setter[name] = module[name]; } - exports(_setter); + exports(setter); }], - execute: function () { + execute: (function () { - } + }) }; -}); +})); diff --git a/test/form/samples/reexport-external-namespace/_expected/umd.js b/test/form/samples/reexport-external-namespace/_expected/umd.js index f37aded3ae5..29cd611294e 100644 --- a/test/form/samples/reexport-external-namespace/_expected/umd.js +++ b/test/form/samples/reexport-external-namespace/_expected/umd.js @@ -2,17 +2,13 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('external')) : typeof define === 'function' && define.amd ? define(['exports', 'external'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.bundle = {}, global.external)); -}(this, (function (exports, external) { 'use strict'; +})(this, (function (exports, external) { 'use strict'; Object.keys(external).forEach(function (k) { - if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, { + if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, { enumerable: true, - get: function () { - return external[k]; - } + get: function () { return external[k]; } }); }); - Object.defineProperty(exports, '__esModule', { value: true }); - -}))); +})); diff --git a/test/form/samples/reexport-self/_config.js b/test/form/samples/reexport-self/_config.js index f979e6e90b0..a7c21e50714 100644 --- a/test/form/samples/reexport-self/_config.js +++ b/test/form/samples/reexport-self/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'handles recursions when a module reexports its own namespace', expectedWarnings: ['CIRCULAR_DEPENDENCY'] -}; +}); diff --git a/test/form/samples/reexport-star-deshadow/_config.js b/test/form/samples/reexport-star-deshadow/_config.js index 29ceb658128..98e18c6df0f 100644 --- a/test/form/samples/reexport-star-deshadow/_config.js +++ b/test/form/samples/reexport-star-deshadow/_config.js @@ -1,8 +1,8 @@ -module.exports = { +module.exports = defineTest({ description: 'Star reexports scope deshadowing', options: { output: { name: 'myBundle' } } -}; +}); diff --git a/test/form/samples/reexport-star-deshadow/_expected/amd.js b/test/form/samples/reexport-star-deshadow/_expected/amd.js index a33e579e64a..f8ac5f04361 100644 --- a/test/form/samples/reexport-star-deshadow/_expected/amd.js +++ b/test/form/samples/reexport-star-deshadow/_expected/amd.js @@ -1,4 +1,4 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; function foo() { return true; } @@ -8,4 +8,4 @@ define(function () { 'use strict'; console.log(baz()); -}); +})); diff --git a/test/form/samples/reexport-star-deshadow/_expected/iife.js b/test/form/samples/reexport-star-deshadow/_expected/iife.js index bff2fd8fc3d..61a08b0509e 100644 --- a/test/form/samples/reexport-star-deshadow/_expected/iife.js +++ b/test/form/samples/reexport-star-deshadow/_expected/iife.js @@ -9,4 +9,4 @@ console.log(baz()); -}()); +})(); diff --git a/test/form/samples/reexport-star-deshadow/_expected/system.js b/test/form/samples/reexport-star-deshadow/_expected/system.js index c74d1764326..1ec877ac52b 100644 --- a/test/form/samples/reexport-star-deshadow/_expected/system.js +++ b/test/form/samples/reexport-star-deshadow/_expected/system.js @@ -1,7 +1,7 @@ -System.register('myBundle', [], function () { +System.register('myBundle', [], (function () { 'use strict'; return { - execute: function () { + execute: (function () { function foo() { return true; } @@ -11,6 +11,6 @@ System.register('myBundle', [], function () { console.log(baz()); - } + }) }; -}); +})); diff --git a/test/form/samples/reexport-star-deshadow/_expected/umd.js b/test/form/samples/reexport-star-deshadow/_expected/umd.js index 79ad3097c04..a0894b85e63 100644 --- a/test/form/samples/reexport-star-deshadow/_expected/umd.js +++ b/test/form/samples/reexport-star-deshadow/_expected/umd.js @@ -1,7 +1,7 @@ (function (factory) { typeof define === 'function' && define.amd ? define(factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; function foo() { return true; } @@ -11,4 +11,4 @@ console.log(baz()); -}))); +})); diff --git a/test/form/samples/reexport-used-external-namespace-as/_config.js b/test/form/samples/reexport-used-external-namespace-as/_config.js index cd50e2c3816..275206bb261 100644 --- a/test/form/samples/reexport-used-external-namespace-as/_config.js +++ b/test/form/samples/reexport-used-external-namespace-as/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'reexport external namespace as name if the namespace is also used', options: { external: ['external1', 'external2'], @@ -10,4 +10,4 @@ module.exports = { } } } -}; +}); diff --git a/test/form/samples/reexport-used-external-namespace-as/_expected/amd.js b/test/form/samples/reexport-used-external-namespace-as/_expected/amd.js index 01cdc62c5c8..e707fe759d5 100644 --- a/test/form/samples/reexport-used-external-namespace-as/_expected/amd.js +++ b/test/form/samples/reexport-used-external-namespace-as/_expected/amd.js @@ -1,7 +1,6 @@ -define(['exports', 'external1', 'external2'], function (exports, imported1, external2) { 'use strict'; +define(['exports', 'external1', 'external2'], (function (exports, imported1, external2) { 'use strict'; - function _interopNamespace(e) { - if (e && e.__esModule) return e; + function _interopNamespaceDefault(e) { var n = Object.create(null); if (e) { Object.keys(e).forEach(function (k) { @@ -9,25 +8,21 @@ define(['exports', 'external1', 'external2'], function (exports, imported1, exte var d = Object.getOwnPropertyDescriptor(e, k); Object.defineProperty(n, k, d.get ? d : { enumerable: true, - get: function () { - return e[k]; - } + get: function () { return e[k]; } }); } }); } - n['default'] = e; + n.default = e; return Object.freeze(n); } - var imported1__namespace = /*#__PURE__*/_interopNamespace(imported1); - var external2__namespace = /*#__PURE__*/_interopNamespace(external2); + var imported1__namespace = /*#__PURE__*/_interopNamespaceDefault(imported1); + var external2__namespace = /*#__PURE__*/_interopNamespaceDefault(external2); console.log(imported1__namespace, external2.imported2); exports.external1 = imported1__namespace; exports.external2 = external2__namespace; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/form/samples/reexport-used-external-namespace-as/_expected/cjs.js b/test/form/samples/reexport-used-external-namespace-as/_expected/cjs.js index 518705f0bb8..8ad9c96cf65 100644 --- a/test/form/samples/reexport-used-external-namespace-as/_expected/cjs.js +++ b/test/form/samples/reexport-used-external-namespace-as/_expected/cjs.js @@ -1,12 +1,9 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - var imported1 = require('external1'); var external2 = require('external2'); -function _interopNamespace(e) { - if (e && e.__esModule) return e; +function _interopNamespaceDefault(e) { var n = Object.create(null); if (e) { Object.keys(e).forEach(function (k) { @@ -14,19 +11,17 @@ function _interopNamespace(e) { var d = Object.getOwnPropertyDescriptor(e, k); Object.defineProperty(n, k, d.get ? d : { enumerable: true, - get: function () { - return e[k]; - } + get: function () { return e[k]; } }); } }); } - n['default'] = e; + n.default = e; return Object.freeze(n); } -var imported1__namespace = /*#__PURE__*/_interopNamespace(imported1); -var external2__namespace = /*#__PURE__*/_interopNamespace(external2); +var imported1__namespace = /*#__PURE__*/_interopNamespaceDefault(imported1); +var external2__namespace = /*#__PURE__*/_interopNamespaceDefault(external2); console.log(imported1__namespace, external2.imported2); diff --git a/test/form/samples/reexport-used-external-namespace-as/_expected/iife.js b/test/form/samples/reexport-used-external-namespace-as/_expected/iife.js index 510289677b3..53940a08b7c 100644 --- a/test/form/samples/reexport-used-external-namespace-as/_expected/iife.js +++ b/test/form/samples/reexport-used-external-namespace-as/_expected/iife.js @@ -1,8 +1,7 @@ var bundle = (function (exports, imported1, external2) { 'use strict'; - function _interopNamespace(e) { - if (e && e.__esModule) return e; + function _interopNamespaceDefault(e) { var n = Object.create(null); if (e) { Object.keys(e).forEach(function (k) { @@ -10,27 +9,23 @@ var bundle = (function (exports, imported1, external2) { var d = Object.getOwnPropertyDescriptor(e, k); Object.defineProperty(n, k, d.get ? d : { enumerable: true, - get: function () { - return e[k]; - } + get: function () { return e[k]; } }); } }); } - n['default'] = e; + n.default = e; return Object.freeze(n); } - var imported1__namespace = /*#__PURE__*/_interopNamespace(imported1); - var external2__namespace = /*#__PURE__*/_interopNamespace(external2); + var imported1__namespace = /*#__PURE__*/_interopNamespaceDefault(imported1); + var external2__namespace = /*#__PURE__*/_interopNamespaceDefault(external2); console.log(imported1__namespace, external2.imported2); exports.external1 = imported1__namespace; exports.external2 = external2__namespace; - Object.defineProperty(exports, '__esModule', { value: true }); - return exports; -}({}, external1, external2)); +})({}, external1, external2); diff --git a/test/form/samples/reexport-used-external-namespace-as/_expected/system.js b/test/form/samples/reexport-used-external-namespace-as/_expected/system.js index 35f2fe86301..d7aeb7f870b 100644 --- a/test/form/samples/reexport-used-external-namespace-as/_expected/system.js +++ b/test/form/samples/reexport-used-external-namespace-as/_expected/system.js @@ -1,18 +1,18 @@ -System.register('bundle', ['external1', 'external2'], function (exports) { +System.register('bundle', ['external1', 'external2'], (function (exports) { 'use strict'; var imported1, imported2; return { setters: [function (module) { imported1 = module; - exports('external1', module); + exports("external1", module); }, function (module) { imported2 = module.imported2; - exports('external2', module); + exports("external2", module); }], - execute: function () { + execute: (function () { console.log(imported1, imported2); - } + }) }; -}); +})); diff --git a/test/form/samples/reexport-used-external-namespace-as/_expected/umd.js b/test/form/samples/reexport-used-external-namespace-as/_expected/umd.js index 89e3859e07e..5808e7786d4 100644 --- a/test/form/samples/reexport-used-external-namespace-as/_expected/umd.js +++ b/test/form/samples/reexport-used-external-namespace-as/_expected/umd.js @@ -2,10 +2,9 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('external1'), require('external2')) : typeof define === 'function' && define.amd ? define(['exports', 'external1', 'external2'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.bundle = {}, global.external1, global.external2)); -}(this, (function (exports, imported1, external2) { 'use strict'; +})(this, (function (exports, imported1, external2) { 'use strict'; - function _interopNamespace(e) { - if (e && e.__esModule) return e; + function _interopNamespaceDefault(e) { var n = Object.create(null); if (e) { Object.keys(e).forEach(function (k) { @@ -13,25 +12,21 @@ var d = Object.getOwnPropertyDescriptor(e, k); Object.defineProperty(n, k, d.get ? d : { enumerable: true, - get: function () { - return e[k]; - } + get: function () { return e[k]; } }); } }); } - n['default'] = e; + n.default = e; return Object.freeze(n); } - var imported1__namespace = /*#__PURE__*/_interopNamespace(imported1); - var external2__namespace = /*#__PURE__*/_interopNamespace(external2); + var imported1__namespace = /*#__PURE__*/_interopNamespaceDefault(imported1); + var external2__namespace = /*#__PURE__*/_interopNamespaceDefault(external2); console.log(imported1__namespace, external2.imported2); exports.external1 = imported1__namespace; exports.external2 = external2__namespace; - Object.defineProperty(exports, '__esModule', { value: true }); - -}))); +})); diff --git a/test/form/samples/relative-external-ids/_config.js b/test/form/samples/relative-external-ids/_config.js index e9a83810940..bee86d6102e 100644 --- a/test/form/samples/relative-external-ids/_config.js +++ b/test/form/samples/relative-external-ids/_config.js @@ -1,37 +1,49 @@ -const path = require('path'); +const path = require('node:path'); -module.exports = { +module.exports = defineTest({ description: 'relative external ids are absolutely resolved', options: { external(id) { switch (id) { - case './optionDirect.js': + case './optionDirect.js': { return true; - case './optionDirectNested.js': + } + case './optionDirectNested.js': { return true; - case path.resolve(__dirname, 'optionIndirect.js'): + } + case path.resolve(__dirname, 'optionIndirect.js'): { return true; - case path.resolve(__dirname, 'nested', 'optionIndirectNested.js'): + } + case path.resolve(__dirname, 'nested', 'optionIndirectNested.js'): { return true; - default: + } + default: { return false; + } } }, - plugins: { - resolveId(id) { - switch (id) { - case './hook.js': - return false; - case './hookNested.js': - return false; - case 'resolved': - return { id: './resolved.js', external: true }; - case 'resolvedNested': - return { id: './resolvedNested.js', external: true }; - default: - return null; + plugins: [ + { + resolveId(id) { + switch (id) { + case './hook.js': { + return false; + } + case './hookNested.js': { + return false; + } + case 'resolved': { + return { id: './resolved.js', external: true }; + } + case 'resolvedNested': { + return { id: './resolvedNested.js', external: true }; + } + default: { + return null; + } + } } } - } + ] } -}; +}); diff --git a/test/form/samples/relative-external-with-global/_config.js b/test/form/samples/relative-external-with-global/_config.js index a8a6b96a7a5..2f669821ac0 100644 --- a/test/form/samples/relative-external-with-global/_config.js +++ b/test/form/samples/relative-external-with-global/_config.js @@ -1,11 +1,11 @@ -const { resolve } = require('path'); +const path = require('node:path'); -const throttle = resolve(__dirname, 'lib/throttle.js'); +const throttle = path.resolve(__dirname, 'lib/throttle.js'); -module.exports = { +module.exports = defineTest({ description: 'applies globals to externalised relative imports', options: { external: [throttle], output: { globals: { [throttle]: 'Lib.throttle' } } } -}; +}); diff --git a/test/form/samples/relative-external-with-global/_expected/amd.js b/test/form/samples/relative-external-with-global/_expected/amd.js index dcd17ff183a..0efe40c013d 100644 --- a/test/form/samples/relative-external-with-global/_expected/amd.js +++ b/test/form/samples/relative-external-with-global/_expected/amd.js @@ -1,13 +1,9 @@ -define(['./lib/throttle'], function (throttle) { 'use strict'; +define(['./lib/throttle'], (function (throttle) { 'use strict'; - function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } - - var throttle__default = /*#__PURE__*/_interopDefaultLegacy(throttle); - - throttle__default['default']( () => { + throttle( () => { console.log( '.' ); }, 500 ); - window.addEventListener( 'mousemove', throttle__default['default'] ); + window.addEventListener( 'mousemove', throttle ); -}); +})); diff --git a/test/form/samples/relative-external-with-global/_expected/cjs.js b/test/form/samples/relative-external-with-global/_expected/cjs.js index c7b93337303..2e861b58a7b 100644 --- a/test/form/samples/relative-external-with-global/_expected/cjs.js +++ b/test/form/samples/relative-external-with-global/_expected/cjs.js @@ -2,12 +2,8 @@ var throttle = require('./lib/throttle.js'); -function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } - -var throttle__default = /*#__PURE__*/_interopDefaultLegacy(throttle); - -throttle__default['default']( () => { +throttle( () => { console.log( '.' ); }, 500 ); -window.addEventListener( 'mousemove', throttle__default['default'] ); +window.addEventListener( 'mousemove', throttle ); diff --git a/test/form/samples/relative-external-with-global/_expected/iife.js b/test/form/samples/relative-external-with-global/_expected/iife.js index 1465ec52de9..47aa0cd2a28 100644 --- a/test/form/samples/relative-external-with-global/_expected/iife.js +++ b/test/form/samples/relative-external-with-global/_expected/iife.js @@ -1,14 +1,10 @@ (function (throttle) { 'use strict'; - function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } - - var throttle__default = /*#__PURE__*/_interopDefaultLegacy(throttle); - - throttle__default['default']( () => { + throttle( () => { console.log( '.' ); }, 500 ); - window.addEventListener( 'mousemove', throttle__default['default'] ); + window.addEventListener( 'mousemove', throttle ); -}(Lib.throttle)); +})(Lib.throttle); diff --git a/test/form/samples/relative-external-with-global/_expected/system.js b/test/form/samples/relative-external-with-global/_expected/system.js index 02b5ce2cf8e..baa34a2fbe4 100644 --- a/test/form/samples/relative-external-with-global/_expected/system.js +++ b/test/form/samples/relative-external-with-global/_expected/system.js @@ -1,11 +1,11 @@ -System.register(['./lib/throttle.js'], function () { +System.register(['./lib/throttle.js'], (function () { 'use strict'; var throttle; return { setters: [function (module) { throttle = module.default; }], - execute: function () { + execute: (function () { throttle( () => { console.log( '.' ); @@ -13,6 +13,6 @@ System.register(['./lib/throttle.js'], function () { window.addEventListener( 'mousemove', throttle ); - } + }) }; -}); +})); diff --git a/test/form/samples/relative-external-with-global/_expected/umd.js b/test/form/samples/relative-external-with-global/_expected/umd.js index 7f505ef2f5d..89ef40b9479 100644 --- a/test/form/samples/relative-external-with-global/_expected/umd.js +++ b/test/form/samples/relative-external-with-global/_expected/umd.js @@ -2,16 +2,12 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('./lib/throttle.js')) : typeof define === 'function' && define.amd ? define(['./lib/throttle'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Lib.throttle)); -}(this, (function (throttle) { 'use strict'; +})(this, (function (throttle) { 'use strict'; - function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } - - var throttle__default = /*#__PURE__*/_interopDefaultLegacy(throttle); - - throttle__default['default']( () => { + throttle( () => { console.log( '.' ); }, 500 ); - window.addEventListener( 'mousemove', throttle__default['default'] ); + window.addEventListener( 'mousemove', throttle ); -}))); +})); diff --git a/test/form/samples/remove-invalid-pure-comments/_config.js b/test/form/samples/remove-invalid-pure-comments/_config.js new file mode 100644 index 00000000000..4e959ed7e85 --- /dev/null +++ b/test/form/samples/remove-invalid-pure-comments/_config.js @@ -0,0 +1,4 @@ +module.exports = defineTest({ + description: 'removes invalidly placed pure annotations', + expectedWarnings: ['INVALID_ANNOTATION'] +}); diff --git a/test/form/samples/remove-invalid-pure-comments/_expected.js b/test/form/samples/remove-invalid-pure-comments/_expected.js new file mode 100644 index 00000000000..606d9639510 --- /dev/null +++ b/test/form/samples/remove-invalid-pure-comments/_expected.js @@ -0,0 +1,5 @@ +const a = 3; +const b = 3; +const c = 3; + +export { a, b, c }; diff --git a/test/form/samples/remove-invalid-pure-comments/main.js b/test/form/samples/remove-invalid-pure-comments/main.js new file mode 100644 index 00000000000..7bd0f87aaf8 --- /dev/null +++ b/test/form/samples/remove-invalid-pure-comments/main.js @@ -0,0 +1,3 @@ +/*@__PURE__*/export const a = 3; +export /*@__PURE__*/const b = 3; +export const /*@__PURE__*/c = 3; diff --git a/test/form/samples/remove-no-side-effects-variable/_config.js b/test/form/samples/remove-no-side-effects-variable/_config.js new file mode 100644 index 00000000000..48a324a372b --- /dev/null +++ b/test/form/samples/remove-no-side-effects-variable/_config.js @@ -0,0 +1,4 @@ +module.exports = defineTest({ + description: + 'removes __NO_SIDE_EFFECTS__ annotation if the variable declaration is only removed partially' +}); diff --git a/test/form/samples/remove-no-side-effects-variable/_expected.js b/test/form/samples/remove-no-side-effects-variable/_expected.js new file mode 100644 index 00000000000..7203af1c1cc --- /dev/null +++ b/test/form/samples/remove-no-side-effects-variable/_expected.js @@ -0,0 +1,5 @@ +const bar = () => console.log(); + +// should be retained, but the annotation needs to be removed, otherwise it +// will appear to be side effect free for downstream consumers. +bar(); diff --git a/test/form/samples/remove-no-side-effects-variable/main.js b/test/form/samples/remove-no-side-effects-variable/main.js new file mode 100644 index 00000000000..d6cccd3819d --- /dev/null +++ b/test/form/samples/remove-no-side-effects-variable/main.js @@ -0,0 +1,9 @@ +/*@__NO_SIDE_EFFECTS__*/ +const foo = () => console.log(), bar = () => console.log(); + +// should be removed +foo(); + +// should be retained, but the annotation needs to be removed, otherwise it +// will appear to be side effect free for downstream consumers. +bar(); diff --git a/test/form/samples/remove-tree-shaken-pure-comments/_config.js b/test/form/samples/remove-tree-shaken-pure-comments/_config.js new file mode 100644 index 00000000000..64ffd0ec696 --- /dev/null +++ b/test/form/samples/remove-tree-shaken-pure-comments/_config.js @@ -0,0 +1,4 @@ +module.exports = defineTest({ + description: 'removes pure comments of tree-shaken nodes', + expectedWarnings: ['INVALID_ANNOTATION'] +}); diff --git a/test/form/samples/remove-tree-shaken-pure-comments/_expected.js b/test/form/samples/remove-tree-shaken-pure-comments/_expected.js new file mode 100644 index 00000000000..a00ec1cf2a3 --- /dev/null +++ b/test/form/samples/remove-tree-shaken-pure-comments/_expected.js @@ -0,0 +1,3 @@ +kept() ; + +kept() ; diff --git a/test/form/samples/remove-tree-shaken-pure-comments/main.js b/test/form/samples/remove-tree-shaken-pure-comments/main.js new file mode 100644 index 00000000000..81868238328 --- /dev/null +++ b/test/form/samples/remove-tree-shaken-pure-comments/main.js @@ -0,0 +1,3 @@ +/*@__PURE__*/(() => false)() /*@__PURE__*/ ? removed() /*@__PURE__*/ : kept() /*@__PURE__*/; + +/*@__PURE__*/(() => true)() /*@__PURE__*/ && kept() /*@__PURE__*/; diff --git a/test/form/samples/remove-treeshaken-banners/_config.js b/test/form/samples/remove-treeshaken-banners/_config.js index 4010568ad64..dc424e83deb 100644 --- a/test/form/samples/remove-treeshaken-banners/_config.js +++ b/test/form/samples/remove-treeshaken-banners/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'Also remove banner comments when completely tree-shaking files' -}; +}); diff --git a/test/form/samples/remove-treeshaken-banners/_expected.js b/test/form/samples/remove-treeshaken-banners/_expected.js index 054d5981ded..41986884c32 100644 --- a/test/form/samples/remove-treeshaken-banners/_expected.js +++ b/test/form/samples/remove-treeshaken-banners/_expected.js @@ -1,4 +1,5 @@ // dep included banner: included + console.log('dep included'); // dep included footer: included diff --git a/test/form/samples/remove-whitespace-of-logical-expression/_config.js b/test/form/samples/remove-whitespace-of-logical-expression/_config.js new file mode 100644 index 00000000000..a1fcd6a1918 --- /dev/null +++ b/test/form/samples/remove-whitespace-of-logical-expression/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'remove the white space of the removed part of LogicalExpression' +}); diff --git a/test/form/samples/remove-whitespace-of-logical-expression/_expected.js b/test/form/samples/remove-whitespace-of-logical-expression/_expected.js new file mode 100644 index 00000000000..c3d71f27ec9 --- /dev/null +++ b/test/form/samples/remove-whitespace-of-logical-expression/_expected.js @@ -0,0 +1 @@ +console.log(`abc ${((true))}`); diff --git a/test/form/samples/remove-whitespace-of-logical-expression/main.js b/test/form/samples/remove-whitespace-of-logical-expression/main.js new file mode 100644 index 00000000000..3b62b90d1da --- /dev/null +++ b/test/form/samples/remove-whitespace-of-logical-expression/main.js @@ -0,0 +1 @@ +console.log(`abc ${((true || 'red')) ?? ''}`); \ No newline at end of file diff --git a/test/form/samples/removes-existing-sourcemap-comments/_config.js b/test/form/samples/removes-existing-sourcemap-comments/_config.js index e1b917ab239..e8a5770fe33 100644 --- a/test/form/samples/removes-existing-sourcemap-comments/_config.js +++ b/test/form/samples/removes-existing-sourcemap-comments/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'removes existing sourcemap comments' -}; +}); diff --git a/test/form/samples/removes-existing-sourcemap-comments/_expected/amd.js b/test/form/samples/removes-existing-sourcemap-comments/_expected/amd.js index 10203946401..984bbad48e3 100644 --- a/test/form/samples/removes-existing-sourcemap-comments/_expected/amd.js +++ b/test/form/samples/removes-existing-sourcemap-comments/_expected/amd.js @@ -1,4 +1,4 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; function foo (x) { return x; @@ -10,4 +10,4 @@ define(function () { 'use strict'; console.log( foo(str) ); -}); +})); diff --git a/test/form/samples/removes-existing-sourcemap-comments/_expected/iife.js b/test/form/samples/removes-existing-sourcemap-comments/_expected/iife.js index 4ce1d3c6533..cb717ed468a 100644 --- a/test/form/samples/removes-existing-sourcemap-comments/_expected/iife.js +++ b/test/form/samples/removes-existing-sourcemap-comments/_expected/iife.js @@ -11,4 +11,4 @@ console.log( foo(str) ); -}()); +})(); diff --git a/test/form/samples/removes-existing-sourcemap-comments/_expected/system.js b/test/form/samples/removes-existing-sourcemap-comments/_expected/system.js index 6725a5b140a..e94ceff7e8b 100644 --- a/test/form/samples/removes-existing-sourcemap-comments/_expected/system.js +++ b/test/form/samples/removes-existing-sourcemap-comments/_expected/system.js @@ -1,7 +1,7 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { function foo (x) { return x; @@ -13,6 +13,6 @@ System.register([], function () { console.log( foo(str) ); - } + }) }; -}); +})); diff --git a/test/form/samples/removes-existing-sourcemap-comments/_expected/umd.js b/test/form/samples/removes-existing-sourcemap-comments/_expected/umd.js index 1dbb05058e5..eea161badd1 100644 --- a/test/form/samples/removes-existing-sourcemap-comments/_expected/umd.js +++ b/test/form/samples/removes-existing-sourcemap-comments/_expected/umd.js @@ -1,7 +1,7 @@ (function (factory) { typeof define === 'function' && define.amd ? define(factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; function foo (x) { return x; @@ -13,4 +13,4 @@ console.log( foo(str) ); -}))); +})); diff --git a/test/form/samples/removes-unused-babel-helpers/_config.js b/test/form/samples/removes-unused-babel-helpers/_config.js index c81966dc963..9238a4c6c4e 100644 --- a/test/form/samples/removes-unused-babel-helpers/_config.js +++ b/test/form/samples/removes-unused-babel-helpers/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'Removes unused babel helpers from the build (#1595)', expectedWarnings: ['EMPTY_BUNDLE'] -}; +}); diff --git a/test/form/samples/renamed-pattern-defaults/_config.js b/test/form/samples/renamed-pattern-defaults/_config.js index e9b8d2cf3ae..79ca1e51cf0 100644 --- a/test/form/samples/renamed-pattern-defaults/_config.js +++ b/test/form/samples/renamed-pattern-defaults/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'handles deconflicting of variables used as defaults in patterns (#2445)' -}; +}); diff --git a/test/form/samples/render-chunk-plugin-sourcemaps/_config.js b/test/form/samples/render-chunk-plugin-sourcemaps/_config.js index bcfbc1fc56a..08f42b02959 100644 --- a/test/form/samples/render-chunk-plugin-sourcemaps/_config.js +++ b/test/form/samples/render-chunk-plugin-sourcemaps/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'supports returning undefined source maps from render chunk hooks, when source maps are enabled', expectedWarnings: ['SOURCEMAP_BROKEN'], @@ -19,4 +19,4 @@ module.exports = { } ] } -}; +}); diff --git a/test/form/samples/render-chunk-plugin/_config.js b/test/form/samples/render-chunk-plugin/_config.js index ed31048f8bb..bfa6037806f 100644 --- a/test/form/samples/render-chunk-plugin/_config.js +++ b/test/form/samples/render-chunk-plugin/_config.js @@ -1,9 +1,9 @@ -module.exports = { +module.exports = defineTest({ description: 'allows plugins to hook render chunk', options: { plugins: [ { - renderChunk(code) { + renderChunk() { return '/* first plugin */'; } }, @@ -14,4 +14,4 @@ module.exports = { } ] } -}; +}); diff --git a/test/form/samples/render-declaration-semicolons/_config.js b/test/form/samples/render-declaration-semicolons/_config.js index 737c5f4a39d..e86b9074a87 100644 --- a/test/form/samples/render-declaration-semicolons/_config.js +++ b/test/form/samples/render-declaration-semicolons/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'properly inserts semi-colons after declarations (#1993)', options: { output: { name: 'bundle' } } -}; +}); diff --git a/test/form/samples/render-declaration-semicolons/_expected/amd.js b/test/form/samples/render-declaration-semicolons/_expected/amd.js index d7c3cba7857..d5bb2f96660 100644 --- a/test/form/samples/render-declaration-semicolons/_expected/amd.js +++ b/test/form/samples/render-declaration-semicolons/_expected/amd.js @@ -1,4 +1,4 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; var a, b; console.log(a, b); @@ -29,6 +29,4 @@ define(['exports'], function (exports) { 'use strict'; exports.o = o; exports.p = p; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/form/samples/render-declaration-semicolons/_expected/cjs.js b/test/form/samples/render-declaration-semicolons/_expected/cjs.js index c7e1b4cb0c7..21c4947ddaa 100644 --- a/test/form/samples/render-declaration-semicolons/_expected/cjs.js +++ b/test/form/samples/render-declaration-semicolons/_expected/cjs.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - var a, b; console.log(a, b); diff --git a/test/form/samples/render-declaration-semicolons/_expected/iife.js b/test/form/samples/render-declaration-semicolons/_expected/iife.js index dc1250b11bf..70af482ab1a 100644 --- a/test/form/samples/render-declaration-semicolons/_expected/iife.js +++ b/test/form/samples/render-declaration-semicolons/_expected/iife.js @@ -30,8 +30,6 @@ var bundle = (function (exports) { exports.o = o; exports.p = p; - Object.defineProperty(exports, '__esModule', { value: true }); - return exports; -}({})); +})({}); diff --git a/test/form/samples/render-declaration-semicolons/_expected/system.js b/test/form/samples/render-declaration-semicolons/_expected/system.js index a6cb60bd425..9cfc563a74c 100644 --- a/test/form/samples/render-declaration-semicolons/_expected/system.js +++ b/test/form/samples/render-declaration-semicolons/_expected/system.js @@ -1,14 +1,7 @@ -System.register('bundle', [], function (exports) { +System.register('bundle', [], (function (exports) { 'use strict'; return { - execute: function () { - - exports({ - i: void 0, - j: void 0, - k: void 0, - l: void 0 - }); + execute: (function () { var a, b; console.log(a, b); @@ -22,14 +15,14 @@ System.register('bundle', [], function (exports) { const g = 3, h = 4; console.log(g, h); - var i, j; + var i, j; exports({ i: i, j: j }); - var k, l; + var k, l; exports({ k: k, l: l }); - const m = exports('m', 1), n = exports('n', 2); + const m = 1, n = 2; exports({ m: m, n: n }); - const o = exports('o', 3), p = exports('p', 4); + const o = 3, p = 4; exports({ o: o, p: p }); - } + }) }; -}); +})); diff --git a/test/form/samples/render-declaration-semicolons/_expected/umd.js b/test/form/samples/render-declaration-semicolons/_expected/umd.js index 27261ddedf8..6f84eb14f44 100644 --- a/test/form/samples/render-declaration-semicolons/_expected/umd.js +++ b/test/form/samples/render-declaration-semicolons/_expected/umd.js @@ -2,7 +2,7 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.bundle = {})); -}(this, (function (exports) { 'use strict'; +})(this, (function (exports) { 'use strict'; var a, b; console.log(a, b); @@ -33,6 +33,4 @@ exports.o = o; exports.p = p; - Object.defineProperty(exports, '__esModule', { value: true }); - -}))); +})); diff --git a/test/form/samples/render-named-export-declarations/_config.js b/test/form/samples/render-named-export-declarations/_config.js index 91835f20a03..205f2617365 100644 --- a/test/form/samples/render-named-export-declarations/_config.js +++ b/test/form/samples/render-named-export-declarations/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'renders named export declarations', options: { output: { name: 'bundle' } } -}; +}); diff --git a/test/form/samples/render-named-export-declarations/_expected/amd.js b/test/form/samples/render-named-export-declarations/_expected/amd.js index cf8c0616726..613cc34c2e4 100644 --- a/test/form/samples/render-named-export-declarations/_expected/amd.js +++ b/test/form/samples/render-named-export-declarations/_expected/amd.js @@ -1,4 +1,4 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; var aFoo; exports.aBar = void 0; exports.aBar = 2; @@ -17,6 +17,4 @@ define(['exports'], function (exports) { 'use strict'; exports.cFoo = cFoo; exports.dBar = dBar; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/form/samples/render-named-export-declarations/_expected/cjs.js b/test/form/samples/render-named-export-declarations/_expected/cjs.js index f21aa19e750..9fb89410f31 100644 --- a/test/form/samples/render-named-export-declarations/_expected/cjs.js +++ b/test/form/samples/render-named-export-declarations/_expected/cjs.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - var aFoo; exports.aBar = void 0; exports.aBar = 2; diff --git a/test/form/samples/render-named-export-declarations/_expected/iife.js b/test/form/samples/render-named-export-declarations/_expected/iife.js index bdc716b73cf..34eab475362 100644 --- a/test/form/samples/render-named-export-declarations/_expected/iife.js +++ b/test/form/samples/render-named-export-declarations/_expected/iife.js @@ -18,8 +18,6 @@ var bundle = (function (exports) { exports.cFoo = cFoo; exports.dBar = dBar; - Object.defineProperty(exports, '__esModule', { value: true }); - return exports; -}({})); +})({}); diff --git a/test/form/samples/render-named-export-declarations/_expected/system.js b/test/form/samples/render-named-export-declarations/_expected/system.js index d47c490a381..73370674de5 100644 --- a/test/form/samples/render-named-export-declarations/_expected/system.js +++ b/test/form/samples/render-named-export-declarations/_expected/system.js @@ -1,29 +1,20 @@ -System.register('bundle', [], function (exports) { +System.register('bundle', [], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - exports({ - aBar: void 0, - aFoo: void 0, - bBar: void 0, - bFoo: void 0, - cFoo: void 0, - dBar: void 0 - }); + var aFoo, aBar; exports({ aFoo: aFoo, aBar: aBar }); + exports("aBar", aBar = 2); - var aFoo, aBar; - aBar = exports('aBar', 2); + var bFoo, bBar; exports({ bFoo: bFoo, bBar: bBar }); + exports("bFoo", bFoo = 2); - var bFoo, bBar; - bFoo = exports('bFoo', 2); + var cFoo, cBar = 1; exports({ cFoo: cFoo, cBar: cBar }); + exports("cBar", cBar = 2); - var cFoo, cBar = exports('cBar', 1); - cBar = exports('cBar', 2); + var dFoo = 1, dBar; exports({ dFoo: dFoo, dBar: dBar }); + exports("dFoo", dFoo = 2); - var dFoo = exports('dFoo', 1), dBar; - dFoo = exports('dFoo', 2); - - } + }) }; -}); +})); diff --git a/test/form/samples/render-named-export-declarations/_expected/umd.js b/test/form/samples/render-named-export-declarations/_expected/umd.js index 578818ce0c5..c889ff37651 100644 --- a/test/form/samples/render-named-export-declarations/_expected/umd.js +++ b/test/form/samples/render-named-export-declarations/_expected/umd.js @@ -2,7 +2,7 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.bundle = {})); -}(this, (function (exports) { 'use strict'; +})(this, (function (exports) { 'use strict'; var aFoo; exports.aBar = void 0; exports.aBar = 2; @@ -21,6 +21,4 @@ exports.cFoo = cFoo; exports.dBar = dBar; - Object.defineProperty(exports, '__esModule', { value: true }); - -}))); +})); diff --git a/test/form/samples/render-removed-declarations/_config.js b/test/form/samples/render-removed-declarations/_config.js index 36bcb953f3d..ed224fc9119 100644 --- a/test/form/samples/render-removed-declarations/_config.js +++ b/test/form/samples/render-removed-declarations/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'renders tree-shaken variable declarations' -}; +}); diff --git a/test/form/samples/render-removed-statements/_config.js b/test/form/samples/render-removed-statements/_config.js index 5c3fac4b9ef..0680fed75ec 100644 --- a/test/form/samples/render-removed-statements/_config.js +++ b/test/form/samples/render-removed-statements/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'make sure removed statements do no leave unwanted white-space' -}; +}); diff --git a/test/form/samples/render-removed-statements/_expected.js b/test/form/samples/render-removed-statements/_expected.js index 6f8e622701a..707551fa6aa 100644 --- a/test/form/samples/render-removed-statements/_expected.js +++ b/test/form/samples/render-removed-statements/_expected.js @@ -1,4 +1,5 @@ /* header retained */ + /* lead retained */ console.log(2); // trail retained console.log(2); // trail retained diff --git a/test/form/samples/request-tree-shaking-before-render/_config.js b/test/form/samples/request-tree-shaking-before-render/_config.js new file mode 100644 index 00000000000..00d3b4e069f --- /dev/null +++ b/test/form/samples/request-tree-shaking-before-render/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'a new tree-shaking is required so render will not fail' +}); diff --git a/test/form/samples/request-tree-shaking-before-render/_expected.js b/test/form/samples/request-tree-shaking-before-render/_expected.js new file mode 100644 index 00000000000..f026827564f --- /dev/null +++ b/test/form/samples/request-tree-shaking-before-render/_expected.js @@ -0,0 +1,16 @@ +function s(t) { + t(x); +} + +function f(b) { + return x.concat((b ? 1 : 0)) +} + +function w(b) { + f(b); +} + +w(1); +s(() => { + return w(0) +}); diff --git a/test/form/samples/request-tree-shaking-before-render/main.js b/test/form/samples/request-tree-shaking-before-render/main.js new file mode 100644 index 00000000000..85b8d493594 --- /dev/null +++ b/test/form/samples/request-tree-shaking-before-render/main.js @@ -0,0 +1,16 @@ +function s(t) { + t(x) +} + +function f(b) { + return x.concat((b ? 1 : 0)) +} + +function w(b) { + f(b) +} + +w(1) +s(() => { + return w(0) +}) diff --git a/test/form/samples/reserved-keywords-in-imports-exports/_config.js b/test/form/samples/reserved-keywords-in-imports-exports/_config.js new file mode 100644 index 00000000000..df20924adf0 --- /dev/null +++ b/test/form/samples/reserved-keywords-in-imports-exports/_config.js @@ -0,0 +1,11 @@ +module.exports = defineTest({ + description: 'correctly handles reserved keywords in exports/imports', + options: { + input: ['main'], + external: ['external'], + output: { + globals: { external: 'external' }, + name: 'reservedKeywords' + } + } +}); diff --git a/test/form/samples/reserved-keywords-in-imports-exports/_expected/amd.js b/test/form/samples/reserved-keywords-in-imports-exports/_expected/amd.js new file mode 100644 index 00000000000..df9a63d574f --- /dev/null +++ b/test/form/samples/reserved-keywords-in-imports-exports/_expected/amd.js @@ -0,0 +1,41 @@ +define(['exports', 'external'], (function (exports, external) { 'use strict'; + + function _interopNamespaceDefault(e) { + var n = Object.create(null); + if (e) { + Object.keys(e).forEach(function (k) { + if (k !== 'default') { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + } + n.default = e; + return Object.freeze(n); + } + + var external__namespace = /*#__PURE__*/_interopNamespaceDefault(external); + + console.log(external.finally, external.catch); // retain those local bindings + + const legal = 10; + + Object.defineProperty(exports, "const", { + enumerable: true, + get: function () { return external.const; } + }); + Object.defineProperty(exports, "in", { + enumerable: true, + get: function () { return external.for; } + }); + Object.defineProperty(exports, "return", { + enumerable: true, + get: function () { return external.bar; } + }); + exports.yield = external__namespace; + exports.await = legal; + +})); diff --git a/test/form/samples/reserved-keywords-in-imports-exports/_expected/cjs.js b/test/form/samples/reserved-keywords-in-imports-exports/_expected/cjs.js new file mode 100644 index 00000000000..703f3504dcb --- /dev/null +++ b/test/form/samples/reserved-keywords-in-imports-exports/_expected/cjs.js @@ -0,0 +1,41 @@ +'use strict'; + +var external = require('external'); + +function _interopNamespaceDefault(e) { + var n = Object.create(null); + if (e) { + Object.keys(e).forEach(function (k) { + if (k !== 'default') { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + } + n.default = e; + return Object.freeze(n); +} + +var external__namespace = /*#__PURE__*/_interopNamespaceDefault(external); + +console.log(external.finally, external.catch); // retain those local bindings + +const legal = 10; + +Object.defineProperty(exports, "const", { + enumerable: true, + get: function () { return external.const; } +}); +Object.defineProperty(exports, "in", { + enumerable: true, + get: function () { return external.for; } +}); +Object.defineProperty(exports, "return", { + enumerable: true, + get: function () { return external.bar; } +}); +exports.yield = external__namespace; +exports.await = legal; diff --git a/test/form/samples/reserved-keywords-in-imports-exports/_expected/es.js b/test/form/samples/reserved-keywords-in-imports-exports/_expected/es.js new file mode 100644 index 00000000000..d36b3a9c0f7 --- /dev/null +++ b/test/form/samples/reserved-keywords-in-imports-exports/_expected/es.js @@ -0,0 +1,10 @@ +import { finally as _finally, catch as _catch } from 'external'; +import * as external from 'external'; +export { external as yield }; +export { const, for as in, bar as return } from 'external'; + +console.log(_finally, _catch); // retain those local bindings + +const legal = 10; + +export { legal as await }; diff --git a/test/form/samples/reserved-keywords-in-imports-exports/_expected/iife.js b/test/form/samples/reserved-keywords-in-imports-exports/_expected/iife.js new file mode 100644 index 00000000000..72f900c60a5 --- /dev/null +++ b/test/form/samples/reserved-keywords-in-imports-exports/_expected/iife.js @@ -0,0 +1,44 @@ +var reservedKeywords = (function (exports, external) { + 'use strict'; + + function _interopNamespaceDefault(e) { + var n = Object.create(null); + if (e) { + Object.keys(e).forEach(function (k) { + if (k !== 'default') { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + } + n.default = e; + return Object.freeze(n); + } + + var external__namespace = /*#__PURE__*/_interopNamespaceDefault(external); + + console.log(external.finally, external.catch); // retain those local bindings + + const legal = 10; + + Object.defineProperty(exports, "const", { + enumerable: true, + get: function () { return external.const; } + }); + Object.defineProperty(exports, "in", { + enumerable: true, + get: function () { return external.for; } + }); + Object.defineProperty(exports, "return", { + enumerable: true, + get: function () { return external.bar; } + }); + exports.yield = external__namespace; + exports.await = legal; + + return exports; + +})({}, external); diff --git a/test/form/samples/reserved-keywords-in-imports-exports/_expected/system.js b/test/form/samples/reserved-keywords-in-imports-exports/_expected/system.js new file mode 100644 index 00000000000..2c1f9312358 --- /dev/null +++ b/test/form/samples/reserved-keywords-in-imports-exports/_expected/system.js @@ -0,0 +1,18 @@ +System.register('reservedKeywords', ['external'], (function (exports) { + 'use strict'; + var _finally, _catch; + return { + setters: [function (module) { + _finally = module.finally; + _catch = module.catch; + exports({ const: module.const, in: module.for, return: module.bar, yield: module }); + }], + execute: (function () { + + console.log(_finally, _catch); // retain those local bindings + + const legal = exports("await", 10); + + }) + }; +})); diff --git a/test/form/samples/reserved-keywords-in-imports-exports/_expected/umd.js b/test/form/samples/reserved-keywords-in-imports-exports/_expected/umd.js new file mode 100644 index 00000000000..ed3b20513c1 --- /dev/null +++ b/test/form/samples/reserved-keywords-in-imports-exports/_expected/umd.js @@ -0,0 +1,45 @@ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('external')) : + typeof define === 'function' && define.amd ? define(['exports', 'external'], factory) : + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.reservedKeywords = {}, global.external)); +})(this, (function (exports, external) { 'use strict'; + + function _interopNamespaceDefault(e) { + var n = Object.create(null); + if (e) { + Object.keys(e).forEach(function (k) { + if (k !== 'default') { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + } + n.default = e; + return Object.freeze(n); + } + + var external__namespace = /*#__PURE__*/_interopNamespaceDefault(external); + + console.log(external.finally, external.catch); // retain those local bindings + + const legal = 10; + + Object.defineProperty(exports, "const", { + enumerable: true, + get: function () { return external.const; } + }); + Object.defineProperty(exports, "in", { + enumerable: true, + get: function () { return external.for; } + }); + Object.defineProperty(exports, "return", { + enumerable: true, + get: function () { return external.bar; } + }); + exports.yield = external__namespace; + exports.await = legal; + +})); diff --git a/test/form/samples/reserved-keywords-in-imports-exports/main.js b/test/form/samples/reserved-keywords-in-imports-exports/main.js new file mode 100644 index 00000000000..e1720bba027 --- /dev/null +++ b/test/form/samples/reserved-keywords-in-imports-exports/main.js @@ -0,0 +1,11 @@ +import { finally as baz, catch as bazinga } from 'external'; +console.log(baz, bazinga); // retain those local bindings + +const legal = 10; + +export { legal as await }; + +export { bar as return, const, for as in } from 'external'; + +import * as lib from 'external'; +export { lib as yield }; diff --git a/test/form/samples/resolution-order/_config.js b/test/form/samples/resolution-order/_config.js index 44ee6d650f3..38eec40c2ce 100644 --- a/test/form/samples/resolution-order/_config.js +++ b/test/form/samples/resolution-order/_config.js @@ -1,12 +1,14 @@ -module.exports = { +module.exports = defineTest({ description: 'does not depend on the resolution order of modules for tree-shaking (#2753)', options: { - plugins: { - resolveId(id) { - if (id === './utcWeek') { - return new Promise(resolve => setTimeout(resolve, 0)); + plugins: [ + { + resolveId(id) { + if (id === './utcWeek') { + return new Promise(resolve => setTimeout(resolve, 0)); + } } } - } + ] } -}; +}); diff --git a/test/form/samples/resolve-external-dynamic-imports/_config.js b/test/form/samples/resolve-external-dynamic-imports/_config.js index abc5a1fa758..d8d18313ee4 100644 --- a/test/form/samples/resolve-external-dynamic-imports/_config.js +++ b/test/form/samples/resolve-external-dynamic-imports/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'does not resolve external dynamic imports via plugins (#2481)', options: { output: { @@ -18,4 +18,4 @@ module.exports = { } ] } -}; +}); diff --git a/test/form/samples/resolve-external-dynamic-imports/_expected/amd.js b/test/form/samples/resolve-external-dynamic-imports/_expected/amd.js index 309f17592f9..8e6ef4e1af5 100644 --- a/test/form/samples/resolve-external-dynamic-imports/_expected/amd.js +++ b/test/form/samples/resolve-external-dynamic-imports/_expected/amd.js @@ -1,9 +1,6 @@ -define(['require', 'exports', 'external'], function (require, exports, myExternal) { 'use strict'; +define(['require', 'exports', 'external'], (function (require, exports, myExternal) { 'use strict'; - function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } - - function _interopNamespace(e) { - if (e && e.__esModule) return e; + function _interopNamespaceDefault(e) { var n = Object.create(null); if (e) { Object.keys(e).forEach(function (k) { @@ -11,26 +8,20 @@ define(['require', 'exports', 'external'], function (require, exports, myExterna var d = Object.getOwnPropertyDescriptor(e, k); Object.defineProperty(n, k, d.get ? d : { enumerable: true, - get: function () { - return e[k]; - } + get: function () { return e[k]; } }); } }); } - n['default'] = e; + n.default = e; return Object.freeze(n); } - var myExternal__default = /*#__PURE__*/_interopDefaultLegacy(myExternal); - - const test = () => myExternal__default['default']; + const test = () => myExternal; - const someDynamicImport = () => new Promise(function (resolve, reject) { require(['external'], function (m) { resolve(/*#__PURE__*/_interopNamespace(m)); }, reject) }); + const someDynamicImport = () => new Promise(function (resolve, reject) { require(['external'], function (m) { resolve(/*#__PURE__*/_interopNamespaceDefault(m)); }, reject); }); exports.someDynamicImport = someDynamicImport; exports.test = test; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/form/samples/resolve-external-dynamic-imports/_expected/cjs.js b/test/form/samples/resolve-external-dynamic-imports/_expected/cjs.js index 2f71d692db3..f08412b5ddd 100644 --- a/test/form/samples/resolve-external-dynamic-imports/_expected/cjs.js +++ b/test/form/samples/resolve-external-dynamic-imports/_expected/cjs.js @@ -1,36 +1,10 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - var myExternal = require('external'); -function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } - -function _interopNamespace(e) { - if (e && e.__esModule) return e; - var n = Object.create(null); - if (e) { - Object.keys(e).forEach(function (k) { - if (k !== 'default') { - var d = Object.getOwnPropertyDescriptor(e, k); - Object.defineProperty(n, k, d.get ? d : { - enumerable: true, - get: function () { - return e[k]; - } - }); - } - }); - } - n['default'] = e; - return Object.freeze(n); -} - -var myExternal__default = /*#__PURE__*/_interopDefaultLegacy(myExternal); - -const test = () => myExternal__default['default']; +const test = () => myExternal; -const someDynamicImport = () => Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('external')); }); +const someDynamicImport = () => import('external'); exports.someDynamicImport = someDynamicImport; exports.test = test; diff --git a/test/form/samples/resolve-external-dynamic-imports/_expected/iife.js b/test/form/samples/resolve-external-dynamic-imports/_expected/iife.js index 8c97dd55eec..dd9cc63ac78 100644 --- a/test/form/samples/resolve-external-dynamic-imports/_expected/iife.js +++ b/test/form/samples/resolve-external-dynamic-imports/_expected/iife.js @@ -1,19 +1,13 @@ var bundle = (function (exports, myExternal) { 'use strict'; - function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } - - var myExternal__default = /*#__PURE__*/_interopDefaultLegacy(myExternal); - - const test = () => myExternal__default['default']; + const test = () => myExternal; const someDynamicImport = () => import('external'); exports.someDynamicImport = someDynamicImport; exports.test = test; - Object.defineProperty(exports, '__esModule', { value: true }); - return exports; -}({}, myExternal)); +})({}, myExternal); diff --git a/test/form/samples/resolve-external-dynamic-imports/_expected/system.js b/test/form/samples/resolve-external-dynamic-imports/_expected/system.js index a2559032d9f..cb1195d86f8 100644 --- a/test/form/samples/resolve-external-dynamic-imports/_expected/system.js +++ b/test/form/samples/resolve-external-dynamic-imports/_expected/system.js @@ -1,16 +1,16 @@ -System.register('bundle', ['external'], function (exports, module) { +System.register('bundle', ['external'], (function (exports, module) { 'use strict'; var myExternal; return { setters: [function (module) { myExternal = module.default; }], - execute: function () { + execute: (function () { - const test = exports('test', () => myExternal); + const test = exports("test", () => myExternal); - const someDynamicImport = exports('someDynamicImport', () => module.import('external')); + const someDynamicImport = exports("someDynamicImport", () => module.import('external')); - } + }) }; -}); +})); diff --git a/test/form/samples/resolve-external-dynamic-imports/_expected/umd.js b/test/form/samples/resolve-external-dynamic-imports/_expected/umd.js index 1b12d1b1d00..b66451582d9 100644 --- a/test/form/samples/resolve-external-dynamic-imports/_expected/umd.js +++ b/test/form/samples/resolve-external-dynamic-imports/_expected/umd.js @@ -2,19 +2,13 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('external')) : typeof define === 'function' && define.amd ? define(['exports', 'external'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.bundle = {}, global.myExternal)); -}(this, (function (exports, myExternal) { 'use strict'; +})(this, (function (exports, myExternal) { 'use strict'; - function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } - - var myExternal__default = /*#__PURE__*/_interopDefaultLegacy(myExternal); - - const test = () => myExternal__default['default']; + const test = () => myExternal; const someDynamicImport = () => import('external'); exports.someDynamicImport = someDynamicImport; exports.test = test; - Object.defineProperty(exports, '__esModule', { value: true }); - -}))); +})); diff --git a/test/form/samples/resolve-import-meta-url-export/_config.js b/test/form/samples/resolve-import-meta-url-export/_config.js index f6597fceb6b..d7b50c2e8cb 100644 --- a/test/form/samples/resolve-import-meta-url-export/_config.js +++ b/test/form/samples/resolve-import-meta-url-export/_config.js @@ -1,13 +1,13 @@ -module.exports = { +module.exports = defineTest({ description: 'correctly exports resolved import.meta.url', options: { plugins: [ { - resolveImportMeta(prop) { - return prop ? "'url'" : "'meta'"; + resolveImportMeta(property) { + return property ? "'url'" : "'meta'"; } } ], output: { name: 'bundle' } } -}; +}); diff --git a/test/form/samples/resolve-import-meta-url-export/_expected/amd.js b/test/form/samples/resolve-import-meta-url-export/_expected/amd.js index 66a5baffd26..f68ef1ec247 100644 --- a/test/form/samples/resolve-import-meta-url-export/_expected/amd.js +++ b/test/form/samples/resolve-import-meta-url-export/_expected/amd.js @@ -1,4 +1,4 @@ -define(['module', 'exports'], function (module, exports) { 'use strict'; +define(['module', 'exports'], (function (module, exports) { 'use strict'; const url = 'url'; const meta = 'meta'; @@ -6,6 +6,4 @@ define(['module', 'exports'], function (module, exports) { 'use strict'; exports.meta = meta; exports.url = url; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/form/samples/resolve-import-meta-url-export/_expected/cjs.js b/test/form/samples/resolve-import-meta-url-export/_expected/cjs.js index 13803f6f4ab..c99ee245fd6 100644 --- a/test/form/samples/resolve-import-meta-url-export/_expected/cjs.js +++ b/test/form/samples/resolve-import-meta-url-export/_expected/cjs.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - const url = 'url'; const meta = 'meta'; diff --git a/test/form/samples/resolve-import-meta-url-export/_expected/iife.js b/test/form/samples/resolve-import-meta-url-export/_expected/iife.js index b71a1ed44c1..0341d484e2c 100644 --- a/test/form/samples/resolve-import-meta-url-export/_expected/iife.js +++ b/test/form/samples/resolve-import-meta-url-export/_expected/iife.js @@ -7,8 +7,6 @@ var bundle = (function (exports) { exports.meta = meta; exports.url = url; - Object.defineProperty(exports, '__esModule', { value: true }); - return exports; -}({})); +})({}); diff --git a/test/form/samples/resolve-import-meta-url-export/_expected/system.js b/test/form/samples/resolve-import-meta-url-export/_expected/system.js index b7d753da474..84d242f87cb 100644 --- a/test/form/samples/resolve-import-meta-url-export/_expected/system.js +++ b/test/form/samples/resolve-import-meta-url-export/_expected/system.js @@ -1,11 +1,11 @@ -System.register('bundle', [], function (exports, module) { +System.register('bundle', [], (function (exports, module) { 'use strict'; return { - execute: function () { + execute: (function () { - const url = exports('url', 'url'); - const meta = exports('meta', 'meta'); + const url = exports("url", 'url'); + const meta = exports("meta", 'meta'); - } + }) }; -}); +})); diff --git a/test/form/samples/resolve-import-meta-url-export/_expected/umd.js b/test/form/samples/resolve-import-meta-url-export/_expected/umd.js index 25b8ae14548..1220e540a99 100644 --- a/test/form/samples/resolve-import-meta-url-export/_expected/umd.js +++ b/test/form/samples/resolve-import-meta-url-export/_expected/umd.js @@ -2,7 +2,7 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.bundle = {})); -}(this, (function (exports) { 'use strict'; +})(this, (function (exports) { 'use strict'; const url = 'url'; const meta = 'meta'; @@ -10,6 +10,4 @@ exports.meta = meta; exports.url = url; - Object.defineProperty(exports, '__esModule', { value: true }); - -}))); +})); diff --git a/test/form/samples/resolve-import-meta-url/_config.js b/test/form/samples/resolve-import-meta-url/_config.js index d0db2f15cc8..838644fff00 100644 --- a/test/form/samples/resolve-import-meta-url/_config.js +++ b/test/form/samples/resolve-import-meta-url/_config.js @@ -1,11 +1,11 @@ -module.exports = { +module.exports = defineTest({ description: 'allows to configure import.meta.url', options: { plugins: [ { - resolveImportMeta(prop, { chunkId, moduleId }) { + resolveImportMeta(property, { chunkId, moduleId }) { if (!moduleId.endsWith('resolved.js')) { - return `'${prop}=${chunkId}:${moduleId + return `'${property}=${chunkId}:${moduleId .replace(/\\/g, '/') .split('/') .slice(-2) @@ -15,7 +15,7 @@ module.exports = { } }, { - resolveImportMeta(prop, { moduleId }) { + resolveImportMeta(property, { moduleId }) { if (!moduleId.endsWith('unresolved.js')) { return `'resolved'`; } @@ -24,4 +24,4 @@ module.exports = { } ] } -}; +}); diff --git a/test/form/samples/resolve-import-meta-url/_expected/amd.js b/test/form/samples/resolve-import-meta-url/_expected/amd.js index f52e4df537e..13fa603d495 100644 --- a/test/form/samples/resolve-import-meta-url/_expected/amd.js +++ b/test/form/samples/resolve-import-meta-url/_expected/amd.js @@ -1,4 +1,4 @@ -define(['module'], function (module) { 'use strict'; +define(['module'], (function (module) { 'use strict'; console.log('resolved'); console.log('resolved'); @@ -12,4 +12,4 @@ define(['module'], function (module) { 'use strict'; console.log('privateProp=amd.js:resolve-import-meta-url/main.js'); console.log('null=amd.js:resolve-import-meta-url/main.js'); -}); +})); diff --git a/test/form/samples/resolve-import-meta-url/_expected/cjs.js b/test/form/samples/resolve-import-meta-url/_expected/cjs.js index 93c70aa21f6..17ad437ca9a 100644 --- a/test/form/samples/resolve-import-meta-url/_expected/cjs.js +++ b/test/form/samples/resolve-import-meta-url/_expected/cjs.js @@ -1,12 +1,13 @@ 'use strict'; +var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null; console.log('resolved'); console.log('resolved'); console.log('resolved'); -console.log((typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('cjs.js', document.baseURI).href))); +console.log((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cjs.js', document.baseURI).href))); console.log(undefined); -console.log(({ url: (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('cjs.js', document.baseURI).href)) })); +console.log(({ url: (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cjs.js', document.baseURI).href)) })); console.log('url=cjs.js:resolve-import-meta-url/main.js'); console.log('privateProp=cjs.js:resolve-import-meta-url/main.js'); diff --git a/test/form/samples/resolve-import-meta-url/_expected/iife.js b/test/form/samples/resolve-import-meta-url/_expected/iife.js index 251f18e4ab9..e1cfc0e5298 100644 --- a/test/form/samples/resolve-import-meta-url/_expected/iife.js +++ b/test/form/samples/resolve-import-meta-url/_expected/iife.js @@ -1,16 +1,17 @@ (function () { 'use strict'; + var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null; console.log('resolved'); console.log('resolved'); console.log('resolved'); - console.log((document.currentScript && document.currentScript.src || new URL('iife.js', document.baseURI).href)); + console.log((_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('iife.js', document.baseURI).href)); console.log(undefined); - console.log(({ url: (document.currentScript && document.currentScript.src || new URL('iife.js', document.baseURI).href) })); + console.log(({ url: (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('iife.js', document.baseURI).href) })); console.log('url=iife.js:resolve-import-meta-url/main.js'); console.log('privateProp=iife.js:resolve-import-meta-url/main.js'); console.log('null=iife.js:resolve-import-meta-url/main.js'); -}()); +})(); diff --git a/test/form/samples/resolve-import-meta-url/_expected/system.js b/test/form/samples/resolve-import-meta-url/_expected/system.js index cdd25b9c2cc..2284f2223ac 100644 --- a/test/form/samples/resolve-import-meta-url/_expected/system.js +++ b/test/form/samples/resolve-import-meta-url/_expected/system.js @@ -1,7 +1,7 @@ -System.register([], function (exports, module) { +System.register([], (function (exports, module) { 'use strict'; return { - execute: function () { + execute: (function () { console.log('resolved'); console.log('resolved'); @@ -15,6 +15,6 @@ System.register([], function (exports, module) { console.log('privateProp=system.js:resolve-import-meta-url/main.js'); console.log('null=system.js:resolve-import-meta-url/main.js'); - } + }) }; -}); +})); diff --git a/test/form/samples/resolve-import-meta-url/_expected/umd.js b/test/form/samples/resolve-import-meta-url/_expected/umd.js index 8e71385a96a..220d0d20124 100644 --- a/test/form/samples/resolve-import-meta-url/_expected/umd.js +++ b/test/form/samples/resolve-import-meta-url/_expected/umd.js @@ -1,18 +1,19 @@ (function (factory) { typeof define === 'function' && define.amd ? define(factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; + var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null; console.log('resolved'); console.log('resolved'); console.log('resolved'); - console.log((typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('umd.js', document.baseURI).href))); + console.log((typeof document === 'undefined' && typeof location === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : typeof document === 'undefined' ? location.href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('umd.js', document.baseURI).href))); console.log(undefined); - console.log(({ url: (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('umd.js', document.baseURI).href)) })); + console.log(({ url: (typeof document === 'undefined' && typeof location === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : typeof document === 'undefined' ? location.href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('umd.js', document.baseURI).href)) })); console.log('url=umd.js:resolve-import-meta-url/main.js'); console.log('privateProp=umd.js:resolve-import-meta-url/main.js'); console.log('null=umd.js:resolve-import-meta-url/main.js'); -}))); +})); diff --git a/test/form/samples/return-after-error/_config.js b/test/form/samples/return-after-error/_config.js new file mode 100644 index 00000000000..6726f51607b --- /dev/null +++ b/test/form/samples/return-after-error/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'tree-shakes entities referenced in a return statement after an error' +}); diff --git a/test/form/samples/return-after-error/_expected.js b/test/form/samples/return-after-error/_expected.js new file mode 100644 index 00000000000..fdf4b564e60 --- /dev/null +++ b/test/form/samples/return-after-error/_expected.js @@ -0,0 +1,7 @@ +function getInstance() { + throw new Error('error'); +} + +console.log(getInstance()); + +export { getInstance }; diff --git a/test/form/samples/return-after-error/main.js b/test/form/samples/return-after-error/main.js new file mode 100644 index 00000000000..eb43273f068 --- /dev/null +++ b/test/form/samples/return-after-error/main.js @@ -0,0 +1,8 @@ +class Removed {} + +export function getInstance() { + throw new Error('error'); + return new Removed(); +} + +console.log(getInstance()); diff --git a/test/form/samples/return-statement/missing-space/_config.js b/test/form/samples/return-statement/missing-space/_config.js index ab1265aacfe..11f544402bd 100644 --- a/test/form/samples/return-statement/missing-space/_config.js +++ b/test/form/samples/return-statement/missing-space/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'Inserts space when simplifying return statement without space' -}; +}); diff --git a/test/form/samples/return-value-access-in-conditional/_config.js b/test/form/samples/return-value-access-in-conditional/_config.js new file mode 100644 index 00000000000..1f10d19e90c --- /dev/null +++ b/test/form/samples/return-value-access-in-conditional/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'handles accessing funciton return values in deoptimized conditionals' +}); diff --git a/test/form/samples/return-value-access-in-conditional/_expected.js b/test/form/samples/return-value-access-in-conditional/_expected.js new file mode 100644 index 00000000000..87854dbd3de --- /dev/null +++ b/test/form/samples/return-value-access-in-conditional/_expected.js @@ -0,0 +1,3 @@ +console.log(true); + +console.log('retained'); diff --git a/test/form/samples/return-value-access-in-conditional/main.js b/test/form/samples/return-value-access-in-conditional/main.js new file mode 100644 index 00000000000..97b25c9ef67 --- /dev/null +++ b/test/form/samples/return-value-access-in-conditional/main.js @@ -0,0 +1,9 @@ +function foo() { + const result = false; + return result; +} + +console.log(foo() || true); + +if (foo() || true) console.log('retained'); +else console.log('removed'); diff --git a/test/form/samples/runs-output-plugins-last/_config.js b/test/form/samples/runs-output-plugins-last/_config.js new file mode 100644 index 00000000000..737f94719c3 --- /dev/null +++ b/test/form/samples/runs-output-plugins-last/_config.js @@ -0,0 +1,23 @@ +module.exports = defineTest({ + description: 'runs output plugins last', + options: { + plugins: [ + { + name: 'input', + renderChunk(code) { + return `/* input */\n${code}\n/* input */`; + } + } + ], + output: { + plugins: [ + { + name: 'output', + renderChunk(code) { + return `/* output */\n${code}\n/* output */`; + } + } + ] + } + } +}); diff --git a/test/form/samples/runs-output-plugins-last/_expected.js b/test/form/samples/runs-output-plugins-last/_expected.js new file mode 100644 index 00000000000..62059de4228 --- /dev/null +++ b/test/form/samples/runs-output-plugins-last/_expected.js @@ -0,0 +1,7 @@ +/* output */ +/* input */ +let foo = 'base'; + +export { foo }; +/* input */ +/* output */ diff --git a/test/form/samples/runs-output-plugins-last/main.js b/test/form/samples/runs-output-plugins-last/main.js new file mode 100644 index 00000000000..0f906e40da6 --- /dev/null +++ b/test/form/samples/runs-output-plugins-last/main.js @@ -0,0 +1 @@ +export let foo = 'base'; diff --git a/test/form/samples/self-calling-function-with-effects/_config.js b/test/form/samples/self-calling-function-with-effects/_config.js index d20f89b9526..1377b649263 100644 --- a/test/form/samples/self-calling-function-with-effects/_config.js +++ b/test/form/samples/self-calling-function-with-effects/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'discards a self-calling function with side-effects' -}; +}); diff --git a/test/form/samples/self-calling-function-with-effects/_expected/amd.js b/test/form/samples/self-calling-function-with-effects/_expected/amd.js index b70b6a4090f..b24966e1c74 100644 --- a/test/form/samples/self-calling-function-with-effects/_expected/amd.js +++ b/test/form/samples/self-calling-function-with-effects/_expected/amd.js @@ -1,4 +1,4 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; function foo ( x ) { effect( x ); @@ -17,4 +17,4 @@ define(function () { 'use strict'; foo( 10 ); bar( 10 ); -}); +})); diff --git a/test/form/samples/self-calling-function-with-effects/_expected/iife.js b/test/form/samples/self-calling-function-with-effects/_expected/iife.js index 822b1c81610..0950876969a 100644 --- a/test/form/samples/self-calling-function-with-effects/_expected/iife.js +++ b/test/form/samples/self-calling-function-with-effects/_expected/iife.js @@ -18,4 +18,4 @@ foo( 10 ); bar( 10 ); -}()); +})(); diff --git a/test/form/samples/self-calling-function-with-effects/_expected/system.js b/test/form/samples/self-calling-function-with-effects/_expected/system.js index 136d136277f..17a91bc6f34 100644 --- a/test/form/samples/self-calling-function-with-effects/_expected/system.js +++ b/test/form/samples/self-calling-function-with-effects/_expected/system.js @@ -1,7 +1,7 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { function foo ( x ) { effect( x ); @@ -20,6 +20,6 @@ System.register([], function () { foo( 10 ); bar( 10 ); - } + }) }; -}); +})); diff --git a/test/form/samples/self-calling-function-with-effects/_expected/umd.js b/test/form/samples/self-calling-function-with-effects/_expected/umd.js index 5aef257f080..0e21a11cec3 100644 --- a/test/form/samples/self-calling-function-with-effects/_expected/umd.js +++ b/test/form/samples/self-calling-function-with-effects/_expected/umd.js @@ -1,7 +1,7 @@ (function (factory) { typeof define === 'function' && define.amd ? define(factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; function foo ( x ) { effect( x ); @@ -20,4 +20,4 @@ foo( 10 ); bar( 10 ); -}))); +})); diff --git a/test/form/samples/self-calling-function/_config.js b/test/form/samples/self-calling-function/_config.js index 7629c502687..57c2b85a209 100644 --- a/test/form/samples/self-calling-function/_config.js +++ b/test/form/samples/self-calling-function/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'discards a self-calling function without side-effects', expectedWarnings: ['EMPTY_BUNDLE'] -}; +}); diff --git a/test/form/samples/self-calling-function/_expected/amd.js b/test/form/samples/self-calling-function/_expected/amd.js index f9f8229aa40..a9e9419e212 100644 --- a/test/form/samples/self-calling-function/_expected/amd.js +++ b/test/form/samples/self-calling-function/_expected/amd.js @@ -1,5 +1,5 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; -}); +})); diff --git a/test/form/samples/self-calling-function/_expected/iife.js b/test/form/samples/self-calling-function/_expected/iife.js index 43ef5426880..31dfeb95ed9 100644 --- a/test/form/samples/self-calling-function/_expected/iife.js +++ b/test/form/samples/self-calling-function/_expected/iife.js @@ -3,4 +3,4 @@ -}()); +})(); diff --git a/test/form/samples/self-calling-function/_expected/system.js b/test/form/samples/self-calling-function/_expected/system.js index a702f2b06ef..343cc3a5100 100644 --- a/test/form/samples/self-calling-function/_expected/system.js +++ b/test/form/samples/self-calling-function/_expected/system.js @@ -1,10 +1,10 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { - } + }) }; -}); +})); diff --git a/test/form/samples/self-calling-function/_expected/umd.js b/test/form/samples/self-calling-function/_expected/umd.js index 8bf6301d469..a39fba4f3da 100644 --- a/test/form/samples/self-calling-function/_expected/umd.js +++ b/test/form/samples/self-calling-function/_expected/umd.js @@ -1,8 +1,8 @@ (function (factory) { typeof define === 'function' && define.amd ? define(factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; -}))); +})); diff --git a/test/form/samples/self-contained-bundle/_config.js b/test/form/samples/self-contained-bundle/_config.js index 29f06f02379..c3ea85ff078 100644 --- a/test/form/samples/self-contained-bundle/_config.js +++ b/test/form/samples/self-contained-bundle/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'self-contained bundle' -}; +}); diff --git a/test/form/samples/self-contained-bundle/_expected/amd.js b/test/form/samples/self-contained-bundle/_expected/amd.js index a29d3995be5..09e80053da6 100644 --- a/test/form/samples/self-contained-bundle/_expected/amd.js +++ b/test/form/samples/self-contained-bundle/_expected/amd.js @@ -1,4 +1,4 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; function foo () { console.log( bar() ); @@ -15,4 +15,4 @@ define(function () { 'use strict'; foo(); console.log( 3 ); -}); +})); diff --git a/test/form/samples/self-contained-bundle/_expected/iife.js b/test/form/samples/self-contained-bundle/_expected/iife.js index d0b884ed6fa..5ee4b2f0020 100644 --- a/test/form/samples/self-contained-bundle/_expected/iife.js +++ b/test/form/samples/self-contained-bundle/_expected/iife.js @@ -16,4 +16,4 @@ foo(); console.log( 3 ); -}()); +})(); diff --git a/test/form/samples/self-contained-bundle/_expected/system.js b/test/form/samples/self-contained-bundle/_expected/system.js index 305cacd0c55..8269fe23172 100644 --- a/test/form/samples/self-contained-bundle/_expected/system.js +++ b/test/form/samples/self-contained-bundle/_expected/system.js @@ -1,7 +1,7 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { function foo () { console.log( bar() ); @@ -18,6 +18,6 @@ System.register([], function () { foo(); console.log( 3 ); - } + }) }; -}); +})); diff --git a/test/form/samples/self-contained-bundle/_expected/umd.js b/test/form/samples/self-contained-bundle/_expected/umd.js index a43eb511543..59672117122 100644 --- a/test/form/samples/self-contained-bundle/_expected/umd.js +++ b/test/form/samples/self-contained-bundle/_expected/umd.js @@ -1,7 +1,7 @@ (function (factory) { typeof define === 'function' && define.amd ? define(factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; function foo () { console.log( bar() ); @@ -18,4 +18,4 @@ foo(); console.log( 3 ); -}))); +})); diff --git a/test/form/samples/self-deoptimization/_config.js b/test/form/samples/self-deoptimization/_config.js index d86ca391dc4..4c3533bf807 100644 --- a/test/form/samples/self-deoptimization/_config.js +++ b/test/form/samples/self-deoptimization/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'handles situations where a member expression is deoptimized while being deoptimized' -}; +}); diff --git a/test/form/samples/sequence-expression/_config.js b/test/form/samples/sequence-expression/_config.js index 0b822def3d8..64800c3513a 100644 --- a/test/form/samples/sequence-expression/_config.js +++ b/test/form/samples/sequence-expression/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'only retain expressions with effects in sequence expressions (#1649)' -}; +}); diff --git a/test/form/samples/sequence-expression/_expected.js b/test/form/samples/sequence-expression/_expected.js index a79e3477a9e..5f4ef62db97 100644 --- a/test/form/samples/sequence-expression/_expected.js +++ b/test/form/samples/sequence-expression/_expected.js @@ -18,6 +18,6 @@ console.log(d); ((() => {console.log(foo$1());})(), 1); // should maintain this context -var module = {}; -module.bar = function () { console.log( 'bar' );}; -(0, module.bar)(); +var module$1 = {}; +module$1.bar = function () { console.log( 'bar' );}; +(0, module$1.bar)(); diff --git a/test/form/samples/shebang-1/_config.js b/test/form/samples/shebang-1/_config.js new file mode 100644 index 00000000000..6f262e6b6b1 --- /dev/null +++ b/test/form/samples/shebang-1/_config.js @@ -0,0 +1,19 @@ +const assert = require('node:assert'); + +module.exports = defineTest({ + description: 'preserve shebang in entry module for CJS and ESM outputs', + options: { + plugins: [ + { + generateBundle(options, outputBundle) { + const keys = Object.keys(outputBundle); + if (options.format === 'cjs' || options.format === 'es') { + assert.ok(outputBundle[keys[0]].code.startsWith('#!')); + } else { + assert.ok(!outputBundle[keys[0]].code.includes('#!')); + } + } + } + ] + } +}); diff --git a/test/form/samples/shebang-1/_expected/amd.js b/test/form/samples/shebang-1/_expected/amd.js new file mode 100644 index 00000000000..b479d32123b --- /dev/null +++ b/test/form/samples/shebang-1/_expected/amd.js @@ -0,0 +1,5 @@ +define((function () { 'use strict'; + + assert.ok('shebang'); + +})); diff --git a/test/form/samples/shebang-1/_expected/cjs.js b/test/form/samples/shebang-1/_expected/cjs.js new file mode 100644 index 00000000000..3e516269fd4 --- /dev/null +++ b/test/form/samples/shebang-1/_expected/cjs.js @@ -0,0 +1,4 @@ +#!/usr/bin/env node +'use strict'; + +assert.ok('shebang'); diff --git a/test/form/samples/shebang-1/_expected/es.js b/test/form/samples/shebang-1/_expected/es.js new file mode 100644 index 00000000000..26cf235f5c4 --- /dev/null +++ b/test/form/samples/shebang-1/_expected/es.js @@ -0,0 +1,2 @@ +#!/usr/bin/env node +assert.ok('shebang'); diff --git a/test/form/samples/shebang-1/_expected/iife.js b/test/form/samples/shebang-1/_expected/iife.js new file mode 100644 index 00000000000..6a482e48611 --- /dev/null +++ b/test/form/samples/shebang-1/_expected/iife.js @@ -0,0 +1,6 @@ +(function () { + 'use strict'; + + assert.ok('shebang'); + +})(); diff --git a/test/form/samples/shebang-1/_expected/system.js b/test/form/samples/shebang-1/_expected/system.js new file mode 100644 index 00000000000..4b84c65acd3 --- /dev/null +++ b/test/form/samples/shebang-1/_expected/system.js @@ -0,0 +1,10 @@ +System.register([], (function () { + 'use strict'; + return { + execute: (function () { + + assert.ok('shebang'); + + }) + }; +})); diff --git a/test/form/samples/shebang-1/_expected/umd.js b/test/form/samples/shebang-1/_expected/umd.js new file mode 100644 index 00000000000..ce034fde74c --- /dev/null +++ b/test/form/samples/shebang-1/_expected/umd.js @@ -0,0 +1,8 @@ +(function (factory) { + typeof define === 'function' && define.amd ? define(factory) : + factory(); +})((function () { 'use strict'; + + assert.ok('shebang'); + +})); diff --git a/test/form/samples/shebang-1/main.js b/test/form/samples/shebang-1/main.js new file mode 100644 index 00000000000..26cf235f5c4 --- /dev/null +++ b/test/form/samples/shebang-1/main.js @@ -0,0 +1,2 @@ +#!/usr/bin/env node +assert.ok('shebang'); diff --git a/test/form/samples/shebang-2/_config.js b/test/form/samples/shebang-2/_config.js new file mode 100644 index 00000000000..fc683128094 --- /dev/null +++ b/test/form/samples/shebang-2/_config.js @@ -0,0 +1,15 @@ +const assert = require('node:assert'); + +module.exports = defineTest({ + description: 'remove shebang in non-entry module for all format outputs', + options: { + plugins: [ + { + generateBundle(_, outputBundle) { + const keys = Object.keys(outputBundle); + assert.ok(!outputBundle[keys[0]].code.includes('#!')); + } + } + ] + } +}); diff --git a/test/form/samples/shebang-2/_expected/amd.js b/test/form/samples/shebang-2/_expected/amd.js new file mode 100644 index 00000000000..b479d32123b --- /dev/null +++ b/test/form/samples/shebang-2/_expected/amd.js @@ -0,0 +1,5 @@ +define((function () { 'use strict'; + + assert.ok('shebang'); + +})); diff --git a/test/form/samples/shebang-2/_expected/cjs.js b/test/form/samples/shebang-2/_expected/cjs.js new file mode 100644 index 00000000000..550b528f6f8 --- /dev/null +++ b/test/form/samples/shebang-2/_expected/cjs.js @@ -0,0 +1,3 @@ +'use strict'; + +assert.ok('shebang'); diff --git a/test/form/samples/shebang-2/_expected/es.js b/test/form/samples/shebang-2/_expected/es.js new file mode 100644 index 00000000000..27239e876c9 --- /dev/null +++ b/test/form/samples/shebang-2/_expected/es.js @@ -0,0 +1 @@ +assert.ok('shebang'); diff --git a/test/form/samples/shebang-2/_expected/iife.js b/test/form/samples/shebang-2/_expected/iife.js new file mode 100644 index 00000000000..6a482e48611 --- /dev/null +++ b/test/form/samples/shebang-2/_expected/iife.js @@ -0,0 +1,6 @@ +(function () { + 'use strict'; + + assert.ok('shebang'); + +})(); diff --git a/test/form/samples/shebang-2/_expected/system.js b/test/form/samples/shebang-2/_expected/system.js new file mode 100644 index 00000000000..4b84c65acd3 --- /dev/null +++ b/test/form/samples/shebang-2/_expected/system.js @@ -0,0 +1,10 @@ +System.register([], (function () { + 'use strict'; + return { + execute: (function () { + + assert.ok('shebang'); + + }) + }; +})); diff --git a/test/form/samples/shebang-2/_expected/umd.js b/test/form/samples/shebang-2/_expected/umd.js new file mode 100644 index 00000000000..ce034fde74c --- /dev/null +++ b/test/form/samples/shebang-2/_expected/umd.js @@ -0,0 +1,8 @@ +(function (factory) { + typeof define === 'function' && define.amd ? define(factory) : + factory(); +})((function () { 'use strict'; + + assert.ok('shebang'); + +})); diff --git a/test/form/samples/shebang-2/dep.js b/test/form/samples/shebang-2/dep.js new file mode 100644 index 00000000000..26cf235f5c4 --- /dev/null +++ b/test/form/samples/shebang-2/dep.js @@ -0,0 +1,2 @@ +#!/usr/bin/env node +assert.ok('shebang'); diff --git a/test/function/samples/deprecated/manual-chunks-conflict/main.js b/test/form/samples/shebang-2/main.js similarity index 100% rename from test/function/samples/deprecated/manual-chunks-conflict/main.js rename to test/form/samples/shebang-2/main.js diff --git a/test/form/samples/shebang-3/_config.js b/test/form/samples/shebang-3/_config.js new file mode 100644 index 00000000000..bf37319da11 --- /dev/null +++ b/test/form/samples/shebang-3/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'supports input files with leading shebang comment' +}); diff --git a/test/form/samples/shebang-3/_expected.js b/test/form/samples/shebang-3/_expected.js new file mode 100644 index 00000000000..2dcbbb30d62 --- /dev/null +++ b/test/form/samples/shebang-3/_expected.js @@ -0,0 +1,4 @@ +#!/usr/bin/env node +console.log('other'); + +console.log('main'); diff --git a/test/form/samples/shebang-3/main.js b/test/form/samples/shebang-3/main.js new file mode 100644 index 00000000000..243bdbbad4d --- /dev/null +++ b/test/form/samples/shebang-3/main.js @@ -0,0 +1,3 @@ +#!/usr/bin/env node +import './other'; +console.log('main'); diff --git a/test/form/samples/shebang-3/other.js b/test/form/samples/shebang-3/other.js new file mode 100644 index 00000000000..b25867312ac --- /dev/null +++ b/test/form/samples/shebang-3/other.js @@ -0,0 +1,2 @@ +#!/usr/bin/env node +console.log('other'); \ No newline at end of file diff --git a/test/form/samples/shorthand-properties/_config.js b/test/form/samples/shorthand-properties/_config.js index deb929d1baf..2a17113ab9f 100644 --- a/test/form/samples/shorthand-properties/_config.js +++ b/test/form/samples/shorthand-properties/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'expands shorthand properties as necessary (#61)' -}; +}); diff --git a/test/form/samples/shorthand-properties/_expected/amd.js b/test/form/samples/shorthand-properties/_expected/amd.js index deb0ca463b7..b6b1a99cdb6 100644 --- a/test/form/samples/shorthand-properties/_expected/amd.js +++ b/test/form/samples/shorthand-properties/_expected/amd.js @@ -1,4 +1,4 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; function x$2 () { return 'foo'; @@ -22,4 +22,4 @@ define(function () { 'use strict'; assert.equal( bar.x(), 'bar' ); assert.equal( baz.x(), 'baz' ); -}); +})); diff --git a/test/form/samples/shorthand-properties/_expected/iife.js b/test/form/samples/shorthand-properties/_expected/iife.js index 9055a4415c5..a9e1044a2e2 100644 --- a/test/form/samples/shorthand-properties/_expected/iife.js +++ b/test/form/samples/shorthand-properties/_expected/iife.js @@ -23,4 +23,4 @@ assert.equal( bar.x(), 'bar' ); assert.equal( baz.x(), 'baz' ); -}()); +})(); diff --git a/test/form/samples/shorthand-properties/_expected/system.js b/test/form/samples/shorthand-properties/_expected/system.js index 2747d3f6ff0..e9cb6eee2f7 100644 --- a/test/form/samples/shorthand-properties/_expected/system.js +++ b/test/form/samples/shorthand-properties/_expected/system.js @@ -1,7 +1,7 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { function x$2 () { return 'foo'; @@ -25,6 +25,6 @@ System.register([], function () { assert.equal( bar.x(), 'bar' ); assert.equal( baz.x(), 'baz' ); - } + }) }; -}); +})); diff --git a/test/form/samples/shorthand-properties/_expected/umd.js b/test/form/samples/shorthand-properties/_expected/umd.js index dc9ee9b8189..5e3ced8766c 100644 --- a/test/form/samples/shorthand-properties/_expected/umd.js +++ b/test/form/samples/shorthand-properties/_expected/umd.js @@ -1,7 +1,7 @@ (function (factory) { typeof define === 'function' && define.amd ? define(factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; function x$2 () { return 'foo'; @@ -25,4 +25,4 @@ assert.equal( bar.x(), 'bar' ); assert.equal( baz.x(), 'baz' ); -}))); +})); diff --git a/test/form/samples/side-effect-b/_config.js b/test/form/samples/side-effect-b/_config.js index e4f8f851539..c299b724837 100644 --- a/test/form/samples/side-effect-b/_config.js +++ b/test/form/samples/side-effect-b/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'discards IIFE with no side-effects', options: { output: { name: 'myBundle' } } -}; +}); diff --git a/test/form/samples/side-effect-b/_expected/amd.js b/test/form/samples/side-effect-b/_expected/amd.js index 37d25711e09..538fc7738a6 100644 --- a/test/form/samples/side-effect-b/_expected/amd.js +++ b/test/form/samples/side-effect-b/_expected/amd.js @@ -1,7 +1,7 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; var main = 42; return main; -}); +})); diff --git a/test/form/samples/side-effect-b/_expected/es.js b/test/form/samples/side-effect-b/_expected/es.js index d862de816a3..c3e30233192 100644 --- a/test/form/samples/side-effect-b/_expected/es.js +++ b/test/form/samples/side-effect-b/_expected/es.js @@ -1,3 +1,3 @@ var main = 42; -export default main; +export { main as default }; diff --git a/test/form/samples/side-effect-b/_expected/iife.js b/test/form/samples/side-effect-b/_expected/iife.js index 69d1387d37e..69055258fc3 100644 --- a/test/form/samples/side-effect-b/_expected/iife.js +++ b/test/form/samples/side-effect-b/_expected/iife.js @@ -5,4 +5,4 @@ var myBundle = (function () { return main; -}()); +})(); diff --git a/test/form/samples/side-effect-b/_expected/system.js b/test/form/samples/side-effect-b/_expected/system.js index 28ccfcd3c31..f655f84521b 100644 --- a/test/form/samples/side-effect-b/_expected/system.js +++ b/test/form/samples/side-effect-b/_expected/system.js @@ -1,10 +1,10 @@ -System.register('myBundle', [], function (exports) { +System.register('myBundle', [], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - var main = exports('default', 42); + var main = exports("default", 42); - } + }) }; -}); +})); diff --git a/test/form/samples/side-effect-b/_expected/umd.js b/test/form/samples/side-effect-b/_expected/umd.js index 6fa2ed81429..cd252572ff6 100644 --- a/test/form/samples/side-effect-b/_expected/umd.js +++ b/test/form/samples/side-effect-b/_expected/umd.js @@ -2,10 +2,10 @@ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.myBundle = factory()); -}(this, (function () { 'use strict'; +})(this, (function () { 'use strict'; var main = 42; return main; -}))); +})); diff --git a/test/form/samples/side-effect-c/_config.js b/test/form/samples/side-effect-c/_config.js index 714bb2229ec..5819c3f246d 100644 --- a/test/form/samples/side-effect-c/_config.js +++ b/test/form/samples/side-effect-c/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'discards function with no side-effects', options: { output: { name: 'myBundle' } } -}; +}); diff --git a/test/form/samples/side-effect-c/_expected/amd.js b/test/form/samples/side-effect-c/_expected/amd.js index 37d25711e09..538fc7738a6 100644 --- a/test/form/samples/side-effect-c/_expected/amd.js +++ b/test/form/samples/side-effect-c/_expected/amd.js @@ -1,7 +1,7 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; var main = 42; return main; -}); +})); diff --git a/test/form/samples/side-effect-c/_expected/es.js b/test/form/samples/side-effect-c/_expected/es.js index d862de816a3..c3e30233192 100644 --- a/test/form/samples/side-effect-c/_expected/es.js +++ b/test/form/samples/side-effect-c/_expected/es.js @@ -1,3 +1,3 @@ var main = 42; -export default main; +export { main as default }; diff --git a/test/form/samples/side-effect-c/_expected/iife.js b/test/form/samples/side-effect-c/_expected/iife.js index 69d1387d37e..69055258fc3 100644 --- a/test/form/samples/side-effect-c/_expected/iife.js +++ b/test/form/samples/side-effect-c/_expected/iife.js @@ -5,4 +5,4 @@ var myBundle = (function () { return main; -}()); +})(); diff --git a/test/form/samples/side-effect-c/_expected/system.js b/test/form/samples/side-effect-c/_expected/system.js index 28ccfcd3c31..f655f84521b 100644 --- a/test/form/samples/side-effect-c/_expected/system.js +++ b/test/form/samples/side-effect-c/_expected/system.js @@ -1,10 +1,10 @@ -System.register('myBundle', [], function (exports) { +System.register('myBundle', [], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - var main = exports('default', 42); + var main = exports("default", 42); - } + }) }; -}); +})); diff --git a/test/form/samples/side-effect-c/_expected/umd.js b/test/form/samples/side-effect-c/_expected/umd.js index 6fa2ed81429..cd252572ff6 100644 --- a/test/form/samples/side-effect-c/_expected/umd.js +++ b/test/form/samples/side-effect-c/_expected/umd.js @@ -2,10 +2,10 @@ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.myBundle = factory()); -}(this, (function () { 'use strict'; +})(this, (function () { 'use strict'; var main = 42; return main; -}))); +})); diff --git a/test/form/samples/side-effect-d/_config.js b/test/form/samples/side-effect-d/_config.js index 06becb0d14e..d2021a9d5bb 100644 --- a/test/form/samples/side-effect-d/_config.js +++ b/test/form/samples/side-effect-d/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'excludes functions that are known to be pure', options: { output: { name: 'myBundle' } } -}; +}); diff --git a/test/form/samples/side-effect-d/_expected/amd.js b/test/form/samples/side-effect-d/_expected/amd.js index 37d25711e09..538fc7738a6 100644 --- a/test/form/samples/side-effect-d/_expected/amd.js +++ b/test/form/samples/side-effect-d/_expected/amd.js @@ -1,7 +1,7 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; var main = 42; return main; -}); +})); diff --git a/test/form/samples/side-effect-d/_expected/es.js b/test/form/samples/side-effect-d/_expected/es.js index d862de816a3..c3e30233192 100644 --- a/test/form/samples/side-effect-d/_expected/es.js +++ b/test/form/samples/side-effect-d/_expected/es.js @@ -1,3 +1,3 @@ var main = 42; -export default main; +export { main as default }; diff --git a/test/form/samples/side-effect-d/_expected/iife.js b/test/form/samples/side-effect-d/_expected/iife.js index 69d1387d37e..69055258fc3 100644 --- a/test/form/samples/side-effect-d/_expected/iife.js +++ b/test/form/samples/side-effect-d/_expected/iife.js @@ -5,4 +5,4 @@ var myBundle = (function () { return main; -}()); +})(); diff --git a/test/form/samples/side-effect-d/_expected/system.js b/test/form/samples/side-effect-d/_expected/system.js index 28ccfcd3c31..f655f84521b 100644 --- a/test/form/samples/side-effect-d/_expected/system.js +++ b/test/form/samples/side-effect-d/_expected/system.js @@ -1,10 +1,10 @@ -System.register('myBundle', [], function (exports) { +System.register('myBundle', [], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - var main = exports('default', 42); + var main = exports("default", 42); - } + }) }; -}); +})); diff --git a/test/form/samples/side-effect-d/_expected/umd.js b/test/form/samples/side-effect-d/_expected/umd.js index 6fa2ed81429..cd252572ff6 100644 --- a/test/form/samples/side-effect-d/_expected/umd.js +++ b/test/form/samples/side-effect-d/_expected/umd.js @@ -2,10 +2,10 @@ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.myBundle = factory()); -}(this, (function () { 'use strict'; +})(this, (function () { 'use strict'; var main = 42; return main; -}))); +})); diff --git a/test/form/samples/side-effect-default-reexport/_config.js b/test/form/samples/side-effect-default-reexport/_config.js index 65e80f04d56..992be466ea4 100644 --- a/test/form/samples/side-effect-default-reexport/_config.js +++ b/test/form/samples/side-effect-default-reexport/_config.js @@ -1,7 +1,7 @@ -module.exports = { +module.exports = defineTest({ description: 'Observes side-effects in side-effect-free modules that contain a used default export that just reexports from another module', options: { treeshake: { moduleSideEffects: false } } -}; +}); diff --git a/test/form/samples/side-effect-default-reexport/_expected.js b/test/form/samples/side-effect-default-reexport/_expected.js index ae3ab580f02..4d9a62053eb 100644 --- a/test/form/samples/side-effect-default-reexport/_expected.js +++ b/test/form/samples/side-effect-default-reexport/_expected.js @@ -1,6 +1,5 @@ var Menu$1 = { - name: 'menu' -}; + }; var Item$2 = { name: 'item' @@ -13,8 +12,7 @@ Menu$1.Item1 = Item$2; Menu$1.Item2 = Item$2; var NamedExport = { - name: 'menu' -}; + }; var Item$1 = { name: 'item' @@ -43,4 +41,4 @@ Menu.Item2 = Item; console.log('test-package-default-export', Menu$1.Item); console.log('test-package-named-export', NamedExport.Item); -export default Menu; +export { Menu as default }; diff --git a/test/form/samples/side-effect-e/_config.js b/test/form/samples/side-effect-e/_config.js index b3dabc06992..4ed8d1511b3 100644 --- a/test/form/samples/side-effect-e/_config.js +++ b/test/form/samples/side-effect-e/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'accounts for local scopes when tested function purity', options: { output: { name: 'myBundle' } } -}; +}); diff --git a/test/form/samples/side-effect-e/_expected.js b/test/form/samples/side-effect-e/_expected.js new file mode 100644 index 00000000000..94df6848308 --- /dev/null +++ b/test/form/samples/side-effect-e/_expected.js @@ -0,0 +1,12 @@ +function foo () { + var Object = { + keys: function () { + console.log( 'side-effect' ); + } + }; + + var obj = { foo: 1, bar: 2 }; + Object.keys( obj ); +} + +foo(); diff --git a/test/form/samples/side-effect-e/_expected/amd.js b/test/form/samples/side-effect-e/_expected/amd.js deleted file mode 100644 index 0c10632c2a2..00000000000 --- a/test/form/samples/side-effect-e/_expected/amd.js +++ /dev/null @@ -1,20 +0,0 @@ -define(function () { 'use strict'; - - function foo () { - var Object = { - keys: function () { - console.log( 'side-effect' ); - } - }; - - var obj = { foo: 1, bar: 2 }; - Object.keys( obj ); - } - - foo(); - - var main = 42; - - return main; - -}); diff --git a/test/form/samples/side-effect-e/_expected/cjs.js b/test/form/samples/side-effect-e/_expected/cjs.js deleted file mode 100644 index 249b9936f03..00000000000 --- a/test/form/samples/side-effect-e/_expected/cjs.js +++ /dev/null @@ -1,18 +0,0 @@ -'use strict'; - -function foo () { - var Object = { - keys: function () { - console.log( 'side-effect' ); - } - }; - - var obj = { foo: 1, bar: 2 }; - Object.keys( obj ); -} - -foo(); - -var main = 42; - -module.exports = main; diff --git a/test/form/samples/side-effect-e/_expected/es.js b/test/form/samples/side-effect-e/_expected/es.js deleted file mode 100644 index c7e2fb24792..00000000000 --- a/test/form/samples/side-effect-e/_expected/es.js +++ /dev/null @@ -1,16 +0,0 @@ -function foo () { - var Object = { - keys: function () { - console.log( 'side-effect' ); - } - }; - - var obj = { foo: 1, bar: 2 }; - Object.keys( obj ); -} - -foo(); - -var main = 42; - -export default main; diff --git a/test/form/samples/side-effect-e/_expected/iife.js b/test/form/samples/side-effect-e/_expected/iife.js deleted file mode 100644 index c181ded348d..00000000000 --- a/test/form/samples/side-effect-e/_expected/iife.js +++ /dev/null @@ -1,21 +0,0 @@ -var myBundle = (function () { - 'use strict'; - - function foo () { - var Object = { - keys: function () { - console.log( 'side-effect' ); - } - }; - - var obj = { foo: 1, bar: 2 }; - Object.keys( obj ); - } - - foo(); - - var main = 42; - - return main; - -}()); diff --git a/test/form/samples/side-effect-e/_expected/system.js b/test/form/samples/side-effect-e/_expected/system.js deleted file mode 100644 index f547aaefa6d..00000000000 --- a/test/form/samples/side-effect-e/_expected/system.js +++ /dev/null @@ -1,23 +0,0 @@ -System.register('myBundle', [], function (exports) { - 'use strict'; - return { - execute: function () { - - function foo () { - var Object = { - keys: function () { - console.log( 'side-effect' ); - } - }; - - var obj = { foo: 1, bar: 2 }; - Object.keys( obj ); - } - - foo(); - - var main = exports('default', 42); - - } - }; -}); diff --git a/test/form/samples/side-effect-e/_expected/umd.js b/test/form/samples/side-effect-e/_expected/umd.js deleted file mode 100644 index 74d8daa5ec0..00000000000 --- a/test/form/samples/side-effect-e/_expected/umd.js +++ /dev/null @@ -1,24 +0,0 @@ -(function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : - typeof define === 'function' && define.amd ? define(factory) : - (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.myBundle = factory()); -}(this, (function () { 'use strict'; - - function foo () { - var Object = { - keys: function () { - console.log( 'side-effect' ); - } - }; - - var obj = { foo: 1, bar: 2 }; - Object.keys( obj ); - } - - foo(); - - var main = 42; - - return main; - -}))); diff --git a/test/form/samples/side-effect-e/main.js b/test/form/samples/side-effect-e/main.js index b96dfdf5d71..1ac85f8de9e 100644 --- a/test/form/samples/side-effect-e/main.js +++ b/test/form/samples/side-effect-e/main.js @@ -10,5 +10,3 @@ function foo () { } foo(); - -export default 42; diff --git a/test/form/samples/side-effect-es5-classes/_config.js b/test/form/samples/side-effect-es5-classes/_config.js index 1be04e395eb..e428008a049 100644 --- a/test/form/samples/side-effect-es5-classes/_config.js +++ b/test/form/samples/side-effect-es5-classes/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'omits ES5 classes which are pure (e.g. they only assign to `this`)', expectedWarnings: ['THIS_IS_UNDEFINED'] -}; +}); diff --git a/test/form/samples/side-effect-es5-classes/_expected.js b/test/form/samples/side-effect-es5-classes/_expected.js index 7afacc4061f..6070716eee1 100644 --- a/test/form/samples/side-effect-es5-classes/_expected.js +++ b/test/form/samples/side-effect-es5-classes/_expected.js @@ -22,7 +22,7 @@ var Arrow = ( x ) => { console.log( 'before' ); new Bar(5); new Baz(5); -new Qux(5); +new Qux(); Corge(5); new Arrow(5); diff --git a/test/form/samples/side-effect-f/_config.js b/test/form/samples/side-effect-f/_config.js index d2f7e3e35da..020ed7253c3 100644 --- a/test/form/samples/side-effect-f/_config.js +++ b/test/form/samples/side-effect-f/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'disregards side-effects that are contained within a function', options: { output: { name: 'myBundle' } } -}; +}); diff --git a/test/form/samples/side-effect-f/_expected/amd.js b/test/form/samples/side-effect-f/_expected/amd.js index 37d25711e09..538fc7738a6 100644 --- a/test/form/samples/side-effect-f/_expected/amd.js +++ b/test/form/samples/side-effect-f/_expected/amd.js @@ -1,7 +1,7 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; var main = 42; return main; -}); +})); diff --git a/test/form/samples/side-effect-f/_expected/es.js b/test/form/samples/side-effect-f/_expected/es.js index d862de816a3..c3e30233192 100644 --- a/test/form/samples/side-effect-f/_expected/es.js +++ b/test/form/samples/side-effect-f/_expected/es.js @@ -1,3 +1,3 @@ var main = 42; -export default main; +export { main as default }; diff --git a/test/form/samples/side-effect-f/_expected/iife.js b/test/form/samples/side-effect-f/_expected/iife.js index 69d1387d37e..69055258fc3 100644 --- a/test/form/samples/side-effect-f/_expected/iife.js +++ b/test/form/samples/side-effect-f/_expected/iife.js @@ -5,4 +5,4 @@ var myBundle = (function () { return main; -}()); +})(); diff --git a/test/form/samples/side-effect-f/_expected/system.js b/test/form/samples/side-effect-f/_expected/system.js index 28ccfcd3c31..f655f84521b 100644 --- a/test/form/samples/side-effect-f/_expected/system.js +++ b/test/form/samples/side-effect-f/_expected/system.js @@ -1,10 +1,10 @@ -System.register('myBundle', [], function (exports) { +System.register('myBundle', [], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - var main = exports('default', 42); + var main = exports("default", 42); - } + }) }; -}); +})); diff --git a/test/form/samples/side-effect-f/_expected/umd.js b/test/form/samples/side-effect-f/_expected/umd.js index 6fa2ed81429..cd252572ff6 100644 --- a/test/form/samples/side-effect-f/_expected/umd.js +++ b/test/form/samples/side-effect-f/_expected/umd.js @@ -2,10 +2,10 @@ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.myBundle = factory()); -}(this, (function () { 'use strict'; +})(this, (function () { 'use strict'; var main = 42; return main; -}))); +})); diff --git a/test/form/samples/side-effect-g/_config.js b/test/form/samples/side-effect-g/_config.js index 04e30755ac9..ec8e9697eb8 100644 --- a/test/form/samples/side-effect-g/_config.js +++ b/test/form/samples/side-effect-g/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'excludes constructors that are known to be pure', options: { output: { name: 'myBundle' } } -}; +}); diff --git a/test/form/samples/side-effect-g/_expected/amd.js b/test/form/samples/side-effect-g/_expected/amd.js index 37d25711e09..538fc7738a6 100644 --- a/test/form/samples/side-effect-g/_expected/amd.js +++ b/test/form/samples/side-effect-g/_expected/amd.js @@ -1,7 +1,7 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; var main = 42; return main; -}); +})); diff --git a/test/form/samples/side-effect-g/_expected/es.js b/test/form/samples/side-effect-g/_expected/es.js index d862de816a3..c3e30233192 100644 --- a/test/form/samples/side-effect-g/_expected/es.js +++ b/test/form/samples/side-effect-g/_expected/es.js @@ -1,3 +1,3 @@ var main = 42; -export default main; +export { main as default }; diff --git a/test/form/samples/side-effect-g/_expected/iife.js b/test/form/samples/side-effect-g/_expected/iife.js index 69d1387d37e..69055258fc3 100644 --- a/test/form/samples/side-effect-g/_expected/iife.js +++ b/test/form/samples/side-effect-g/_expected/iife.js @@ -5,4 +5,4 @@ var myBundle = (function () { return main; -}()); +})(); diff --git a/test/form/samples/side-effect-g/_expected/system.js b/test/form/samples/side-effect-g/_expected/system.js index 28ccfcd3c31..f655f84521b 100644 --- a/test/form/samples/side-effect-g/_expected/system.js +++ b/test/form/samples/side-effect-g/_expected/system.js @@ -1,10 +1,10 @@ -System.register('myBundle', [], function (exports) { +System.register('myBundle', [], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - var main = exports('default', 42); + var main = exports("default", 42); - } + }) }; -}); +})); diff --git a/test/form/samples/side-effect-g/_expected/umd.js b/test/form/samples/side-effect-g/_expected/umd.js index 6fa2ed81429..cd252572ff6 100644 --- a/test/form/samples/side-effect-g/_expected/umd.js +++ b/test/form/samples/side-effect-g/_expected/umd.js @@ -2,10 +2,10 @@ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.myBundle = factory()); -}(this, (function () { 'use strict'; +})(this, (function () { 'use strict'; var main = 42; return main; -}))); +})); diff --git a/test/form/samples/side-effect-h/_config.js b/test/form/samples/side-effect-h/_config.js index 7100614789f..d077ab8a9f9 100644 --- a/test/form/samples/side-effect-h/_config.js +++ b/test/form/samples/side-effect-h/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'includes throw statements', options: { output: { name: 'myBundle' } } -}; +}); diff --git a/test/form/samples/side-effect-h/_expected/amd.js b/test/form/samples/side-effect-h/_expected/amd.js index ab252ed73e1..e46b7cd7cb9 100644 --- a/test/form/samples/side-effect-h/_expected/amd.js +++ b/test/form/samples/side-effect-h/_expected/amd.js @@ -1,4 +1,4 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; function foo ( ok ) { if ( !ok ) { @@ -7,9 +7,10 @@ define(function () { 'use strict'; } foo(); + foo(true); var main = 42; return main; -}); +})); diff --git a/test/form/samples/side-effect-h/_expected/cjs.js b/test/form/samples/side-effect-h/_expected/cjs.js index 1d437295c93..4862e7aa0e7 100644 --- a/test/form/samples/side-effect-h/_expected/cjs.js +++ b/test/form/samples/side-effect-h/_expected/cjs.js @@ -7,6 +7,7 @@ function foo ( ok ) { } foo(); +foo(true); var main = 42; diff --git a/test/form/samples/side-effect-h/_expected/es.js b/test/form/samples/side-effect-h/_expected/es.js index 1462a922a75..39c215e330c 100644 --- a/test/form/samples/side-effect-h/_expected/es.js +++ b/test/form/samples/side-effect-h/_expected/es.js @@ -5,7 +5,8 @@ function foo ( ok ) { } foo(); +foo(true); var main = 42; -export default main; +export { main as default }; diff --git a/test/form/samples/side-effect-h/_expected/iife.js b/test/form/samples/side-effect-h/_expected/iife.js index 286de2ad6cb..b6fc61fb49b 100644 --- a/test/form/samples/side-effect-h/_expected/iife.js +++ b/test/form/samples/side-effect-h/_expected/iife.js @@ -8,9 +8,10 @@ var myBundle = (function () { } foo(); + foo(true); var main = 42; return main; -}()); +})(); diff --git a/test/form/samples/side-effect-h/_expected/system.js b/test/form/samples/side-effect-h/_expected/system.js index e30fa03b847..6ace3fb0f81 100644 --- a/test/form/samples/side-effect-h/_expected/system.js +++ b/test/form/samples/side-effect-h/_expected/system.js @@ -1,7 +1,7 @@ -System.register('myBundle', [], function (exports) { +System.register('myBundle', [], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { function foo ( ok ) { if ( !ok ) { @@ -10,9 +10,10 @@ System.register('myBundle', [], function (exports) { } foo(); + foo(true); - var main = exports('default', 42); + var main = exports("default", 42); - } + }) }; -}); +})); diff --git a/test/form/samples/side-effect-h/_expected/umd.js b/test/form/samples/side-effect-h/_expected/umd.js index b90a4d77292..f72ccce31f6 100644 --- a/test/form/samples/side-effect-h/_expected/umd.js +++ b/test/form/samples/side-effect-h/_expected/umd.js @@ -2,7 +2,7 @@ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.myBundle = factory()); -}(this, (function () { 'use strict'; +})(this, (function () { 'use strict'; function foo ( ok ) { if ( !ok ) { @@ -11,9 +11,10 @@ } foo(); + foo(true); var main = 42; return main; -}))); +})); diff --git a/test/form/samples/side-effect-h/main.js b/test/form/samples/side-effect-h/main.js index 16d73469124..b736c13f944 100644 --- a/test/form/samples/side-effect-h/main.js +++ b/test/form/samples/side-effect-h/main.js @@ -5,5 +5,6 @@ function foo ( ok ) { } foo(); +foo(true); export default 42; diff --git a/test/form/samples/side-effect-i/_config.js b/test/form/samples/side-effect-i/_config.js index ec18a4d3ecd..51e31b5ef93 100644 --- a/test/form/samples/side-effect-i/_config.js +++ b/test/form/samples/side-effect-i/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'includes top-level throw statements', options: { output: { name: 'myBundle' } } -}; +}); diff --git a/test/form/samples/side-effect-i/_expected/amd.js b/test/form/samples/side-effect-i/_expected/amd.js index 21c57f99882..a097011669a 100644 --- a/test/form/samples/side-effect-i/_expected/amd.js +++ b/test/form/samples/side-effect-i/_expected/amd.js @@ -1,4 +1,4 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; if ( !ok ) { throw new Error( 'this will be included' ); @@ -8,4 +8,4 @@ define(function () { 'use strict'; return main; -}); +})); diff --git a/test/form/samples/side-effect-i/_expected/es.js b/test/form/samples/side-effect-i/_expected/es.js index 32ac89e9576..b57755fc1f8 100644 --- a/test/form/samples/side-effect-i/_expected/es.js +++ b/test/form/samples/side-effect-i/_expected/es.js @@ -4,4 +4,4 @@ if ( !ok ) { var main = 42; -export default main; +export { main as default }; diff --git a/test/form/samples/side-effect-i/_expected/iife.js b/test/form/samples/side-effect-i/_expected/iife.js index 29825a5dedc..e05b659272e 100644 --- a/test/form/samples/side-effect-i/_expected/iife.js +++ b/test/form/samples/side-effect-i/_expected/iife.js @@ -9,4 +9,4 @@ var myBundle = (function () { return main; -}()); +})(); diff --git a/test/form/samples/side-effect-i/_expected/system.js b/test/form/samples/side-effect-i/_expected/system.js index 4ac8c0a2760..0990a5a7f1a 100644 --- a/test/form/samples/side-effect-i/_expected/system.js +++ b/test/form/samples/side-effect-i/_expected/system.js @@ -1,14 +1,14 @@ -System.register('myBundle', [], function (exports) { +System.register('myBundle', [], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { if ( !ok ) { throw new Error( 'this will be included' ); } - var main = exports('default', 42); + var main = exports("default", 42); - } + }) }; -}); +})); diff --git a/test/form/samples/side-effect-i/_expected/umd.js b/test/form/samples/side-effect-i/_expected/umd.js index 58c0e4ddc6d..c52ae2be9f9 100644 --- a/test/form/samples/side-effect-i/_expected/umd.js +++ b/test/form/samples/side-effect-i/_expected/umd.js @@ -2,7 +2,7 @@ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.myBundle = factory()); -}(this, (function () { 'use strict'; +})(this, (function () { 'use strict'; if ( !ok ) { throw new Error( 'this will be included' ); @@ -12,4 +12,4 @@ return main; -}))); +})); diff --git a/test/form/samples/side-effect-j/_config.js b/test/form/samples/side-effect-j/_config.js index adc9ac05c35..71c83c240de 100644 --- a/test/form/samples/side-effect-j/_config.js +++ b/test/form/samples/side-effect-j/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'includes late function declarations with side-effects', options: { output: { name: 'myBundle' } } -}; +}); diff --git a/test/form/samples/side-effect-j/_expected/amd.js b/test/form/samples/side-effect-j/_expected/amd.js index f65939a2d2a..97bf814bcee 100644 --- a/test/form/samples/side-effect-j/_expected/amd.js +++ b/test/form/samples/side-effect-j/_expected/amd.js @@ -1,4 +1,4 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; var augment; augment = y => y.augmented = true; @@ -8,4 +8,4 @@ define(function () { 'use strict'; return x; -}); +})); diff --git a/test/form/samples/side-effect-j/_expected/es.js b/test/form/samples/side-effect-j/_expected/es.js index 54e415f780b..2ae18abac12 100644 --- a/test/form/samples/side-effect-j/_expected/es.js +++ b/test/form/samples/side-effect-j/_expected/es.js @@ -4,4 +4,4 @@ augment = y => y.augmented = true; function x () {} augment( x ); -export default x; +export { x as default }; diff --git a/test/form/samples/side-effect-j/_expected/iife.js b/test/form/samples/side-effect-j/_expected/iife.js index d507fc7d950..ba26a10b432 100644 --- a/test/form/samples/side-effect-j/_expected/iife.js +++ b/test/form/samples/side-effect-j/_expected/iife.js @@ -9,4 +9,4 @@ var myBundle = (function () { return x; -}()); +})(); diff --git a/test/form/samples/side-effect-j/_expected/system.js b/test/form/samples/side-effect-j/_expected/system.js index c346c1112a4..6dcb83618e9 100644 --- a/test/form/samples/side-effect-j/_expected/system.js +++ b/test/form/samples/side-effect-j/_expected/system.js @@ -1,9 +1,9 @@ -System.register('myBundle', [], function (exports) { +System.register('myBundle', [], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - exports('default', x); + exports("default", x); var augment; augment = y => y.augmented = true; @@ -11,6 +11,6 @@ System.register('myBundle', [], function (exports) { function x () {} augment( x ); - } + }) }; -}); +})); diff --git a/test/form/samples/side-effect-j/_expected/umd.js b/test/form/samples/side-effect-j/_expected/umd.js index 3b9f0924b79..6ec6b839fa9 100644 --- a/test/form/samples/side-effect-j/_expected/umd.js +++ b/test/form/samples/side-effect-j/_expected/umd.js @@ -2,7 +2,7 @@ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.myBundle = factory()); -}(this, (function () { 'use strict'; +})(this, (function () { 'use strict'; var augment; augment = y => y.augmented = true; @@ -12,4 +12,4 @@ return x; -}))); +})); diff --git a/test/form/samples/side-effect-k/_config.js b/test/form/samples/side-effect-k/_config.js index 716b5410714..b0467b59b12 100644 --- a/test/form/samples/side-effect-k/_config.js +++ b/test/form/samples/side-effect-k/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'use of arguments is treated as a side-effect', options: { output: { name: 'myBundle' } } -}; +}); diff --git a/test/form/samples/side-effect-k/_expected/amd.js b/test/form/samples/side-effect-k/_expected/amd.js index abfcb9824c3..968aedcf722 100644 --- a/test/form/samples/side-effect-k/_expected/amd.js +++ b/test/form/samples/side-effect-k/_expected/amd.js @@ -1,4 +1,4 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; function augment ( x ) { var prop, source; @@ -25,4 +25,4 @@ define(function () { 'use strict'; return x; -}); +})); diff --git a/test/form/samples/side-effect-k/_expected/es.js b/test/form/samples/side-effect-k/_expected/es.js index 864798663d0..85fa8ade3ee 100644 --- a/test/form/samples/side-effect-k/_expected/es.js +++ b/test/form/samples/side-effect-k/_expected/es.js @@ -21,4 +21,4 @@ function augment ( x ) { function x () {} augment( x.prototype ); -export default x; +export { x as default }; diff --git a/test/form/samples/side-effect-k/_expected/iife.js b/test/form/samples/side-effect-k/_expected/iife.js index eeb57d44a4b..54942c4302c 100644 --- a/test/form/samples/side-effect-k/_expected/iife.js +++ b/test/form/samples/side-effect-k/_expected/iife.js @@ -26,4 +26,4 @@ var myBundle = (function () { return x; -}()); +})(); diff --git a/test/form/samples/side-effect-k/_expected/system.js b/test/form/samples/side-effect-k/_expected/system.js index 628b4b702c0..eec9f9e7e36 100644 --- a/test/form/samples/side-effect-k/_expected/system.js +++ b/test/form/samples/side-effect-k/_expected/system.js @@ -1,9 +1,9 @@ -System.register('myBundle', [], function (exports) { +System.register('myBundle', [], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - exports('default', x); + exports("default", x); function augment ( x ) { var prop, source; @@ -28,6 +28,6 @@ System.register('myBundle', [], function (exports) { function x () {} augment( x.prototype ); - } + }) }; -}); +})); diff --git a/test/form/samples/side-effect-k/_expected/umd.js b/test/form/samples/side-effect-k/_expected/umd.js index cedb4b602d7..0d34ce39125 100644 --- a/test/form/samples/side-effect-k/_expected/umd.js +++ b/test/form/samples/side-effect-k/_expected/umd.js @@ -2,7 +2,7 @@ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.myBundle = factory()); -}(this, (function () { 'use strict'; +})(this, (function () { 'use strict'; function augment ( x ) { var prop, source; @@ -29,4 +29,4 @@ return x; -}))); +})); diff --git a/test/form/samples/side-effect-l/_config.js b/test/form/samples/side-effect-l/_config.js index ec762ed9126..a957fbf5799 100644 --- a/test/form/samples/side-effect-l/_config.js +++ b/test/form/samples/side-effect-l/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'discards function with no side-effects in imported module', expectedWarnings: ['EMPTY_BUNDLE'] -}; +}); diff --git a/test/form/samples/side-effect-l/_expected/amd.js b/test/form/samples/side-effect-l/_expected/amd.js index f9f8229aa40..a9e9419e212 100644 --- a/test/form/samples/side-effect-l/_expected/amd.js +++ b/test/form/samples/side-effect-l/_expected/amd.js @@ -1,5 +1,5 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; -}); +})); diff --git a/test/form/samples/side-effect-l/_expected/iife.js b/test/form/samples/side-effect-l/_expected/iife.js index 43ef5426880..31dfeb95ed9 100644 --- a/test/form/samples/side-effect-l/_expected/iife.js +++ b/test/form/samples/side-effect-l/_expected/iife.js @@ -3,4 +3,4 @@ -}()); +})(); diff --git a/test/form/samples/side-effect-l/_expected/system.js b/test/form/samples/side-effect-l/_expected/system.js index a702f2b06ef..343cc3a5100 100644 --- a/test/form/samples/side-effect-l/_expected/system.js +++ b/test/form/samples/side-effect-l/_expected/system.js @@ -1,10 +1,10 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { - } + }) }; -}); +})); diff --git a/test/form/samples/side-effect-l/_expected/umd.js b/test/form/samples/side-effect-l/_expected/umd.js index 8bf6301d469..a39fba4f3da 100644 --- a/test/form/samples/side-effect-l/_expected/umd.js +++ b/test/form/samples/side-effect-l/_expected/umd.js @@ -1,8 +1,8 @@ (function (factory) { typeof define === 'function' && define.amd ? define(factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; -}))); +})); diff --git a/test/form/samples/side-effect-m/_config.js b/test/form/samples/side-effect-m/_config.js index 9f53058aca7..6c389ef661b 100644 --- a/test/form/samples/side-effect-m/_config.js +++ b/test/form/samples/side-effect-m/_config.js @@ -1,3 +1,4 @@ -module.exports = { +module.exports = defineTest({ + description: 'detects side-effects in circular function calls', expectedWarnings: ['CIRCULAR_DEPENDENCY'] -}; +}); diff --git a/test/form/samples/side-effect-n/_config.js b/test/form/samples/side-effect-n/_config.js index 9896c14d057..379a9723982 100644 --- a/test/form/samples/side-effect-n/_config.js +++ b/test/form/samples/side-effect-n/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'detects side-effects in complex call expressions' -}; +}); diff --git a/test/form/samples/side-effect-n/_expected/amd.js b/test/form/samples/side-effect-n/_expected/amd.js index 3aef0ed3bd5..75484c8a7b5 100644 --- a/test/form/samples/side-effect-n/_expected/amd.js +++ b/test/form/samples/side-effect-n/_expected/amd.js @@ -1,4 +1,4 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; function foo () { console.log( 'foo' ); @@ -10,4 +10,4 @@ define(function () { 'use strict'; ( Math.random() < 0.5 ? foo : bar )(); -}); +})); diff --git a/test/form/samples/side-effect-n/_expected/iife.js b/test/form/samples/side-effect-n/_expected/iife.js index 6358928bd7f..667e80ef960 100644 --- a/test/form/samples/side-effect-n/_expected/iife.js +++ b/test/form/samples/side-effect-n/_expected/iife.js @@ -11,4 +11,4 @@ ( Math.random() < 0.5 ? foo : bar )(); -}()); +})(); diff --git a/test/form/samples/side-effect-n/_expected/system.js b/test/form/samples/side-effect-n/_expected/system.js index 9a55c34654d..67b35d4b180 100644 --- a/test/form/samples/side-effect-n/_expected/system.js +++ b/test/form/samples/side-effect-n/_expected/system.js @@ -1,7 +1,7 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { function foo () { console.log( 'foo' ); @@ -13,6 +13,6 @@ System.register([], function () { ( Math.random() < 0.5 ? foo : bar )(); - } + }) }; -}); +})); diff --git a/test/form/samples/side-effect-n/_expected/umd.js b/test/form/samples/side-effect-n/_expected/umd.js index 1b4578fa701..af8c7c4b20d 100644 --- a/test/form/samples/side-effect-n/_expected/umd.js +++ b/test/form/samples/side-effect-n/_expected/umd.js @@ -1,7 +1,7 @@ (function (factory) { typeof define === 'function' && define.amd ? define(factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; function foo () { console.log( 'foo' ); @@ -13,4 +13,4 @@ ( Math.random() < 0.5 ? foo : bar )(); -}))); +})); diff --git a/test/form/samples/side-effect-o/_config.js b/test/form/samples/side-effect-o/_config.js index 9896c14d057..379a9723982 100644 --- a/test/form/samples/side-effect-o/_config.js +++ b/test/form/samples/side-effect-o/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'detects side-effects in complex call expressions' -}; +}); diff --git a/test/form/samples/side-effect-o/_expected/amd.js b/test/form/samples/side-effect-o/_expected/amd.js index 77451d5312d..5f8a7af3669 100644 --- a/test/form/samples/side-effect-o/_expected/amd.js +++ b/test/form/samples/side-effect-o/_expected/amd.js @@ -1,4 +1,4 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; function fn () { return Math.random() < 0.5 ? foo : bar; @@ -14,4 +14,4 @@ define(function () { 'use strict'; fn()(); -}); +})); diff --git a/test/form/samples/side-effect-o/_expected/iife.js b/test/form/samples/side-effect-o/_expected/iife.js index 0dad11b4d92..a1b566ba301 100644 --- a/test/form/samples/side-effect-o/_expected/iife.js +++ b/test/form/samples/side-effect-o/_expected/iife.js @@ -15,4 +15,4 @@ fn()(); -}()); +})(); diff --git a/test/form/samples/side-effect-o/_expected/system.js b/test/form/samples/side-effect-o/_expected/system.js index a9640953e43..955f4e02979 100644 --- a/test/form/samples/side-effect-o/_expected/system.js +++ b/test/form/samples/side-effect-o/_expected/system.js @@ -1,7 +1,7 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { function fn () { return Math.random() < 0.5 ? foo : bar; @@ -17,6 +17,6 @@ System.register([], function () { fn()(); - } + }) }; -}); +})); diff --git a/test/form/samples/side-effect-o/_expected/umd.js b/test/form/samples/side-effect-o/_expected/umd.js index ee51a0c5192..7ab003ebfd5 100644 --- a/test/form/samples/side-effect-o/_expected/umd.js +++ b/test/form/samples/side-effect-o/_expected/umd.js @@ -1,7 +1,7 @@ (function (factory) { typeof define === 'function' && define.amd ? define(factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; function fn () { return Math.random() < 0.5 ? foo : bar; @@ -17,4 +17,4 @@ fn()(); -}))); +})); diff --git a/test/form/samples/side-effect-p/_config.js b/test/form/samples/side-effect-p/_config.js index 7a8d84b4c1e..c425c26febd 100644 --- a/test/form/samples/side-effect-p/_config.js +++ b/test/form/samples/side-effect-p/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'detects mutation of globals' -}; +}); diff --git a/test/form/samples/side-effect-p/_expected/amd.js b/test/form/samples/side-effect-p/_expected/amd.js index 11f4daea984..3e8f960dd51 100644 --- a/test/form/samples/side-effect-p/_expected/amd.js +++ b/test/form/samples/side-effect-p/_expected/amd.js @@ -1,4 +1,4 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; const hs = document.documentElement.style; @@ -6,4 +6,4 @@ define(function () { 'use strict'; hs.color = "#222"; } -}); +})); diff --git a/test/form/samples/side-effect-p/_expected/iife.js b/test/form/samples/side-effect-p/_expected/iife.js index 66f50c67a17..f0943ed495e 100644 --- a/test/form/samples/side-effect-p/_expected/iife.js +++ b/test/form/samples/side-effect-p/_expected/iife.js @@ -7,4 +7,4 @@ hs.color = "#222"; } -}()); +})(); diff --git a/test/form/samples/side-effect-p/_expected/system.js b/test/form/samples/side-effect-p/_expected/system.js index 2a88bc1907b..fc5518ad06e 100644 --- a/test/form/samples/side-effect-p/_expected/system.js +++ b/test/form/samples/side-effect-p/_expected/system.js @@ -1,7 +1,7 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { const hs = document.documentElement.style; @@ -9,6 +9,6 @@ System.register([], function () { hs.color = "#222"; } - } + }) }; -}); +})); diff --git a/test/form/samples/side-effect-p/_expected/umd.js b/test/form/samples/side-effect-p/_expected/umd.js index 275c98fbefe..7f7b1a5d20a 100644 --- a/test/form/samples/side-effect-p/_expected/umd.js +++ b/test/form/samples/side-effect-p/_expected/umd.js @@ -1,7 +1,7 @@ (function (factory) { typeof define === 'function' && define.amd ? define(factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; const hs = document.documentElement.style; @@ -9,4 +9,4 @@ hs.color = "#222"; } -}))); +})); diff --git a/test/form/samples/side-effect-q/_config.js b/test/form/samples/side-effect-q/_config.js index 542135c0d96..b37abab4403 100644 --- a/test/form/samples/side-effect-q/_config.js +++ b/test/form/samples/side-effect-q/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'discards effects in conditional expressions with known test values', expectedWarnings: ['EMPTY_BUNDLE'] -}; +}); diff --git a/test/form/samples/side-effect-r/_config.js b/test/form/samples/side-effect-r/_config.js index 160946bb6a1..e00b8e41c79 100644 --- a/test/form/samples/side-effect-r/_config.js +++ b/test/form/samples/side-effect-r/_config.js @@ -1,5 +1,5 @@ -module.exports = { +module.exports = defineTest({ description: 'discards unused function expression assigned to a variable that calls itself and a global', expectedWarnings: ['EMPTY_BUNDLE'] -}; +}); diff --git a/test/form/samples/side-effect-s/_config.js b/test/form/samples/side-effect-s/_config.js index 83665339a11..00838aaea57 100644 --- a/test/form/samples/side-effect-s/_config.js +++ b/test/form/samples/side-effect-s/_config.js @@ -1,5 +1,5 @@ -module.exports = { +module.exports = defineTest({ description: 'discards unused function expression assigned to a variable that calls itself and has side effects', expectedWarnings: ['EMPTY_BUNDLE'] -}; +}); diff --git a/test/form/samples/side-effect-s/_expected/amd.js b/test/form/samples/side-effect-s/_expected/amd.js index f9f8229aa40..a9e9419e212 100644 --- a/test/form/samples/side-effect-s/_expected/amd.js +++ b/test/form/samples/side-effect-s/_expected/amd.js @@ -1,5 +1,5 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; -}); +})); diff --git a/test/form/samples/side-effect-s/_expected/iife.js b/test/form/samples/side-effect-s/_expected/iife.js index 43ef5426880..31dfeb95ed9 100644 --- a/test/form/samples/side-effect-s/_expected/iife.js +++ b/test/form/samples/side-effect-s/_expected/iife.js @@ -3,4 +3,4 @@ -}()); +})(); diff --git a/test/form/samples/side-effect-s/_expected/system.js b/test/form/samples/side-effect-s/_expected/system.js index a702f2b06ef..343cc3a5100 100644 --- a/test/form/samples/side-effect-s/_expected/system.js +++ b/test/form/samples/side-effect-s/_expected/system.js @@ -1,10 +1,10 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { - } + }) }; -}); +})); diff --git a/test/form/samples/side-effect-s/_expected/umd.js b/test/form/samples/side-effect-s/_expected/umd.js index 8bf6301d469..a39fba4f3da 100644 --- a/test/form/samples/side-effect-s/_expected/umd.js +++ b/test/form/samples/side-effect-s/_expected/umd.js @@ -1,8 +1,8 @@ (function (factory) { typeof define === 'function' && define.amd ? define(factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; -}))); +})); diff --git a/test/form/samples/side-effect-t/_config.js b/test/form/samples/side-effect-t/_config.js index 11092704b09..957236bbf3e 100644 --- a/test/form/samples/side-effect-t/_config.js +++ b/test/form/samples/side-effect-t/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'throw statement is a side effect', options: { output: { name: 'myBundle' } } -}; +}); diff --git a/test/form/samples/side-effect-t/_expected/amd.js b/test/form/samples/side-effect-t/_expected/amd.js index aeb4d723d2a..81b5d438940 100644 --- a/test/form/samples/side-effect-t/_expected/amd.js +++ b/test/form/samples/side-effect-t/_expected/amd.js @@ -1,4 +1,4 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; function foo () { throw new Error( 'throw side effect' ); @@ -6,4 +6,4 @@ define(function () { 'use strict'; foo(); -}); +})); diff --git a/test/form/samples/side-effect-t/_expected/iife.js b/test/form/samples/side-effect-t/_expected/iife.js index 79110d18355..c43d0eddda0 100644 --- a/test/form/samples/side-effect-t/_expected/iife.js +++ b/test/form/samples/side-effect-t/_expected/iife.js @@ -7,4 +7,4 @@ foo(); -}()); +})(); diff --git a/test/form/samples/side-effect-t/_expected/system.js b/test/form/samples/side-effect-t/_expected/system.js index 14ed53c895f..8e06bcb5404 100644 --- a/test/form/samples/side-effect-t/_expected/system.js +++ b/test/form/samples/side-effect-t/_expected/system.js @@ -1,7 +1,7 @@ -System.register('myBundle', [], function () { +System.register('myBundle', [], (function () { 'use strict'; return { - execute: function () { + execute: (function () { function foo () { throw new Error( 'throw side effect' ); @@ -9,6 +9,6 @@ System.register('myBundle', [], function () { foo(); - } + }) }; -}); +})); diff --git a/test/form/samples/side-effect-t/_expected/umd.js b/test/form/samples/side-effect-t/_expected/umd.js index 698c6927c09..b419769c4fa 100644 --- a/test/form/samples/side-effect-t/_expected/umd.js +++ b/test/form/samples/side-effect-t/_expected/umd.js @@ -1,7 +1,7 @@ (function (factory) { typeof define === 'function' && define.amd ? define(factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; function foo () { throw new Error( 'throw side effect' ); @@ -9,4 +9,4 @@ foo(); -}))); +})); diff --git a/test/form/samples/side-effect-with-plusplus-expression/_config.js b/test/form/samples/side-effect-with-plusplus-expression/_config.js index a1d93a75228..907cb2976a9 100644 --- a/test/form/samples/side-effect-with-plusplus-expression/_config.js +++ b/test/form/samples/side-effect-with-plusplus-expression/_config.js @@ -1,5 +1,5 @@ -module.exports = { +module.exports = defineTest({ description: 'correctly drop side-effect free statements in presence of update expression (#1564)', expectedWarnings: ['EMPTY_BUNDLE'] -}; +}); diff --git a/test/form/samples/side-effect/_config.js b/test/form/samples/side-effect/_config.js index 0431077dba2..59fa7fa5d05 100644 --- a/test/form/samples/side-effect/_config.js +++ b/test/form/samples/side-effect/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'side-effects to non-globals are not blindly included' -}; +}); diff --git a/test/form/samples/side-effect/_expected/amd.js b/test/form/samples/side-effect/_expected/amd.js index c82bf4fd279..153f3859ddd 100644 --- a/test/form/samples/side-effect/_expected/amd.js +++ b/test/form/samples/side-effect/_expected/amd.js @@ -1,7 +1,7 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; var foo = 42; assert.equal( foo, 42 ); -}); +})); diff --git a/test/form/samples/side-effect/_expected/iife.js b/test/form/samples/side-effect/_expected/iife.js index 5dbfbd5b06e..5c4006df4f9 100644 --- a/test/form/samples/side-effect/_expected/iife.js +++ b/test/form/samples/side-effect/_expected/iife.js @@ -5,4 +5,4 @@ assert.equal( foo, 42 ); -}()); +})(); diff --git a/test/form/samples/side-effect/_expected/system.js b/test/form/samples/side-effect/_expected/system.js index 8aa51d50450..05d901ebbc2 100644 --- a/test/form/samples/side-effect/_expected/system.js +++ b/test/form/samples/side-effect/_expected/system.js @@ -1,12 +1,12 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { var foo = 42; assert.equal( foo, 42 ); - } + }) }; -}); +})); diff --git a/test/form/samples/side-effect/_expected/umd.js b/test/form/samples/side-effect/_expected/umd.js index 759123f18ef..358e41eeb61 100644 --- a/test/form/samples/side-effect/_expected/umd.js +++ b/test/form/samples/side-effect/_expected/umd.js @@ -1,10 +1,10 @@ (function (factory) { typeof define === 'function' && define.amd ? define(factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; var foo = 42; assert.equal( foo, 42 ); -}))); +})); diff --git a/test/form/samples/side-effects-await/_config.js b/test/form/samples/side-effects-await/_config.js index 4f4ad0a1e63..4b01a385fc9 100644 --- a/test/form/samples/side-effects-await/_config.js +++ b/test/form/samples/side-effects-await/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'await statements should never be dropped if a function has other side-effects (#1584)' -}; +}); diff --git a/test/form/samples/side-effects-await/main.js b/test/form/samples/side-effects-await/main.js index 0641421d34a..623a857a000 100644 --- a/test/form/samples/side-effects-await/main.js +++ b/test/form/samples/side-effects-await/main.js @@ -11,9 +11,3 @@ async function hasEffects2 () { hasEffects2(); -async function isRemoved () { - await globalThis.unknown; -} - -isRemoved(); - diff --git a/test/form/samples/side-effects-break-statements/_config.js b/test/form/samples/side-effects-break-statements/_config.js index ba247f1280e..64acbca3c94 100644 --- a/test/form/samples/side-effects-break-statements/_config.js +++ b/test/form/samples/side-effects-break-statements/_config.js @@ -1,5 +1,5 @@ -module.exports = { +module.exports = defineTest({ description: 'break statements should always by included but not always cause their parents to have effects', options: { output: { name: 'myBundle' } } -}; +}); diff --git a/test/form/samples/side-effects-break-statements/_expected/amd.js b/test/form/samples/side-effects-break-statements/_expected/amd.js index fcb890626fe..1d230f1cc1d 100644 --- a/test/form/samples/side-effects-break-statements/_expected/amd.js +++ b/test/form/samples/side-effects-break-statements/_expected/amd.js @@ -1,4 +1,4 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; for ( let i = 0; i < 2; i++ ) { console.log( 'effect' ); @@ -25,4 +25,4 @@ define(function () { 'use strict'; break; } while ( true ); -}); +})); diff --git a/test/form/samples/side-effects-break-statements/_expected/iife.js b/test/form/samples/side-effects-break-statements/_expected/iife.js index 5977e667780..f6659b47bc0 100644 --- a/test/form/samples/side-effects-break-statements/_expected/iife.js +++ b/test/form/samples/side-effects-break-statements/_expected/iife.js @@ -26,4 +26,4 @@ break; } while ( true ); -}()); +})(); diff --git a/test/form/samples/side-effects-break-statements/_expected/system.js b/test/form/samples/side-effects-break-statements/_expected/system.js index 3bd9c2c8d1e..f3199167ae2 100644 --- a/test/form/samples/side-effects-break-statements/_expected/system.js +++ b/test/form/samples/side-effects-break-statements/_expected/system.js @@ -1,7 +1,7 @@ -System.register('myBundle', [], function () { +System.register('myBundle', [], (function () { 'use strict'; return { - execute: function () { + execute: (function () { for ( let i = 0; i < 2; i++ ) { console.log( 'effect' ); @@ -28,6 +28,6 @@ System.register('myBundle', [], function () { break; } while ( true ); - } + }) }; -}); +})); diff --git a/test/form/samples/side-effects-break-statements/_expected/umd.js b/test/form/samples/side-effects-break-statements/_expected/umd.js index 50433528f3d..a8527d3eb1c 100644 --- a/test/form/samples/side-effects-break-statements/_expected/umd.js +++ b/test/form/samples/side-effects-break-statements/_expected/umd.js @@ -1,7 +1,7 @@ (function (factory) { typeof define === 'function' && define.amd ? define(factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; for ( let i = 0; i < 2; i++ ) { console.log( 'effect' ); @@ -28,4 +28,4 @@ break; } while ( true ); -}))); +})); diff --git a/test/form/samples/side-effects-call-arguments/_config.js b/test/form/samples/side-effects-call-arguments/_config.js index d8ee57e3e6b..c8d9275427d 100644 --- a/test/form/samples/side-effects-call-arguments/_config.js +++ b/test/form/samples/side-effects-call-arguments/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'side-effects in call arguments should be included' -}; +}); diff --git a/test/form/samples/side-effects-class-getters-setters/_config.js b/test/form/samples/side-effects-class-getters-setters/_config.js new file mode 100644 index 00000000000..ecbdc429845 --- /dev/null +++ b/test/form/samples/side-effects-class-getters-setters/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'treat getters and setters on classes as function calls' +}); diff --git a/test/form/samples/side-effects-class-getters-setters/_expected.js b/test/form/samples/side-effects-class-getters-setters/_expected.js new file mode 100644 index 00000000000..997f18debfa --- /dev/null +++ b/test/form/samples/side-effects-class-getters-setters/_expected.js @@ -0,0 +1,43 @@ +class RetainedByGetter { + get a() { log(); } +} +RetainedByGetter.prototype.a; + +class RetainedBySetter { + set a(v) { log(); } +} +RetainedBySetter.prototype.a = 10; + +class RetainedByStaticGetter { + static get a() { log(); } +} +RetainedByStaticGetter.a; + +class RetainedByStaticSetter { + static set a(v) { log(); } +} +RetainedByStaticSetter.a = 10; + +class RetainedSuper { + static get a() { log(); } +} +class RetainedSub extends RetainedSuper {} +RetainedSub.a; + +// class fields are not part of the prototype +class RemovedProtoValue { + a = true; +} +if (!RemovedProtoValue.prototype.a) log(); + +class DeoptProto { + a = true; +} +globalThis.unknown(DeoptProto.prototype); +if (!DeoptProto.prototype.a) log(); + +class DeoptComputed { + static get a() {} + static get [globalThis.unknown]() { log(); } +} +DeoptComputed.a; diff --git a/test/form/samples/side-effects-class-getters-setters/main.js b/test/form/samples/side-effects-class-getters-setters/main.js new file mode 100644 index 00000000000..9a8c95b93cb --- /dev/null +++ b/test/form/samples/side-effects-class-getters-setters/main.js @@ -0,0 +1,78 @@ +class Removed { + get a() { log(); } + set a(v) { log(); } + static get a() { log(); } + static set a(v) { log(); } +} + +class RemovedNoEffect { + get a() {} + set a(v) {} + static get a() {} + static set a(v) {} +} +RemovedNoEffect.prototype.a; +RemovedNoEffect.prototype.a = 1; +RemovedNoEffect.a; +RemovedNoEffect.a = 1; + +class RetainedByGetter { + get a() { log(); } +} +RetainedByGetter.prototype.a; + +class RetainedBySetter { + set a(v) { log(); } +} +RetainedBySetter.prototype.a = 10; + +class RetainedByStaticGetter { + static get a() { log(); } +} +RetainedByStaticGetter.a; + +class RetainedByStaticSetter { + static set a(v) { log(); } +} +RetainedByStaticSetter.a = 10; + +class RemovedSetters { + set a(v) { log(); } + static set a(v) { log(); } +} +RemovedSetters.prototype.a; +RemovedSetters.a; + +class RemovedWrongProp { + get a() { log(); } + static get a() { log(); } +} +RemovedWrongProp.prototype.b +RemovedWrongProp.b + +class RetainedSuper { + static get a() { log(); } +} +class RetainedSub extends RetainedSuper {} +RetainedSub.a; + +class RemovedSub extends RetainedSuper {} +RemovedSub.b; + +// class fields are not part of the prototype +class RemovedProtoValue { + a = true; +} +if (!RemovedProtoValue.prototype.a) log(); + +class DeoptProto { + a = true; +} +globalThis.unknown(DeoptProto.prototype); +if (!DeoptProto.prototype.a) log(); + +class DeoptComputed { + static get a() {} + static get [globalThis.unknown]() { log(); } +} +DeoptComputed.a; diff --git a/test/form/samples/side-effects-computed-pattern-keys/_config.js b/test/form/samples/side-effects-computed-pattern-keys/_config.js index a2a2961f07f..daf32b338f5 100644 --- a/test/form/samples/side-effects-computed-pattern-keys/_config.js +++ b/test/form/samples/side-effects-computed-pattern-keys/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'side-effects in with computed pattern keys should not be ignored' -}; +}); diff --git a/test/form/samples/side-effects-delete/_config.js b/test/form/samples/side-effects-delete/_config.js index a5afb4f8c79..81cf46e2a83 100644 --- a/test/form/samples/side-effects-delete/_config.js +++ b/test/form/samples/side-effects-delete/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'delete is only a side-effect for included variables', options: { output: { name: 'myBundle' } } -}; +}); diff --git a/test/form/samples/side-effects-delete/_expected/amd.js b/test/form/samples/side-effects-delete/_expected/amd.js index 2c24744efd5..b7ea318adf5 100644 --- a/test/form/samples/side-effects-delete/_expected/amd.js +++ b/test/form/samples/side-effects-delete/_expected/amd.js @@ -1,4 +1,4 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; var x = {foo: 'bar'}; delete x.foo; @@ -7,6 +7,4 @@ define(['exports'], function (exports) { 'use strict'; exports.x = x; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/form/samples/side-effects-delete/_expected/cjs.js b/test/form/samples/side-effects-delete/_expected/cjs.js index cdaada5d697..e6921aece27 100644 --- a/test/form/samples/side-effects-delete/_expected/cjs.js +++ b/test/form/samples/side-effects-delete/_expected/cjs.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - var x = {foo: 'bar'}; delete x.foo; diff --git a/test/form/samples/side-effects-delete/_expected/iife.js b/test/form/samples/side-effects-delete/_expected/iife.js index 239b0edd91f..90c7a370402 100644 --- a/test/form/samples/side-effects-delete/_expected/iife.js +++ b/test/form/samples/side-effects-delete/_expected/iife.js @@ -8,8 +8,6 @@ var myBundle = (function (exports) { exports.x = x; - Object.defineProperty(exports, '__esModule', { value: true }); - return exports; -}({})); +})({}); diff --git a/test/form/samples/side-effects-delete/_expected/system.js b/test/form/samples/side-effects-delete/_expected/system.js index 7dcd588e1a5..27a2f772c02 100644 --- a/test/form/samples/side-effects-delete/_expected/system.js +++ b/test/form/samples/side-effects-delete/_expected/system.js @@ -1,13 +1,13 @@ -System.register('myBundle', [], function (exports) { +System.register('myBundle', [], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - var x = exports('x', {foo: 'bar'}); + var x = exports("x", {foo: 'bar'}); delete x.foo; delete globalThis.unknown.foo; - } + }) }; -}); +})); diff --git a/test/form/samples/side-effects-delete/_expected/umd.js b/test/form/samples/side-effects-delete/_expected/umd.js index 4c182ec1300..d91938bdd0c 100644 --- a/test/form/samples/side-effects-delete/_expected/umd.js +++ b/test/form/samples/side-effects-delete/_expected/umd.js @@ -2,7 +2,7 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.myBundle = {})); -}(this, (function (exports) { 'use strict'; +})(this, (function (exports) { 'use strict'; var x = {foo: 'bar'}; delete x.foo; @@ -11,6 +11,4 @@ exports.x = x; - Object.defineProperty(exports, '__esModule', { value: true }); - -}))); +})); diff --git a/test/form/samples/side-effects-es6-class-declarations/_config.js b/test/form/samples/side-effects-es6-class-declarations/_config.js index 29ad84ec965..e9206e022b7 100644 --- a/test/form/samples/side-effects-es6-class-declarations/_config.js +++ b/test/form/samples/side-effects-es6-class-declarations/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'determine side effects in ES6 class declarations' -}; +}); diff --git a/test/form/samples/side-effects-es6-class-expressions/_config.js b/test/form/samples/side-effects-es6-class-expressions/_config.js index 78ff5788610..0fb2fbf6a1c 100644 --- a/test/form/samples/side-effects-es6-class-expressions/_config.js +++ b/test/form/samples/side-effects-es6-class-expressions/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'determine side effects in ES6 class expressions' -}; +}); diff --git a/test/form/samples/side-effects-es6-super-classes/_config.js b/test/form/samples/side-effects-es6-super-classes/_config.js index 83e0fc4332b..99854ae798f 100644 --- a/test/form/samples/side-effects-es6-super-classes/_config.js +++ b/test/form/samples/side-effects-es6-super-classes/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'determine side effects in ES6 super classes' -}; +}); diff --git a/test/form/samples/side-effects-expressions-as-statements/_config.js b/test/form/samples/side-effects-expressions-as-statements/_config.js index cffa37c9628..8cfb080be2c 100644 --- a/test/form/samples/side-effects-expressions-as-statements/_config.js +++ b/test/form/samples/side-effects-expressions-as-statements/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'in order to keep certain getter calls, do not remove some expression statements' -}; +}); diff --git a/test/form/samples/side-effects-generators/_config.js b/test/form/samples/side-effects-generators/_config.js index cc50ee5553a..564cd639964 100644 --- a/test/form/samples/side-effects-generators/_config.js +++ b/test/form/samples/side-effects-generators/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'Properly detect side-effects in generator functions' -}; +}); diff --git a/test/form/samples/side-effects-getters-and-setters/_config.js b/test/form/samples/side-effects-getters-and-setters/_config.js index 2ac2ab26753..83bddd815c6 100644 --- a/test/form/samples/side-effects-getters-and-setters/_config.js +++ b/test/form/samples/side-effects-getters-and-setters/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'treat getters and setters as function calls' -}; +}); diff --git a/test/form/samples/side-effects-getters-and-setters/_expected.js b/test/form/samples/side-effects-getters-and-setters/_expected.js index 4100b6ca31b..31917077c8e 100644 --- a/test/form/samples/side-effects-getters-and-setters/_expected.js +++ b/test/form/samples/side-effects-getters-and-setters/_expected.js @@ -1,34 +1,36 @@ -const retained1a = { - get effect () { - console.log( 'effect' ); +const retained1 = { + get effect() { + console.log('effect'); }, - get noEffect () { + get noEffect() { const x = 1; return x; } }; -retained1a.effect; -retained1a[ 'eff' + 'ect' ]; + +//retained +retained1.effect; +retained1['eff' + 'ect']; const retained3 = { - set effect ( value ) { - console.log( value ); + set effect(value) { + console.log(value); } }; retained3.effect = 'retained'; const retained4 = { - set effect ( value ) { - console.log( value ); + set effect(value) { + console.log(value); } }; -retained4[ 'eff' + 'ect' ] = 'retained'; +retained4['eff' + 'ect'] = 'retained'; const retained7 = { foo: () => {}, - get foo () { + get foo() { return 1; } }; diff --git a/test/form/samples/side-effects-getters-and-setters/main.js b/test/form/samples/side-effects-getters-and-setters/main.js index b3ce3d4a9b6..66cb31f8451 100644 --- a/test/form/samples/side-effects-getters-and-setters/main.js +++ b/test/form/samples/side-effects-getters-and-setters/main.js @@ -1,68 +1,60 @@ -const retained1a = { - get effect () { - console.log( 'effect' ); +const retained1 = { + get effect() { + console.log('effect'); }, - get noEffect () { + get noEffect() { const x = 1; return x; } }; -const removed1 = retained1a.noEffect; -const retained1b = retained1a.effect; -const retained1c = retained1a[ 'eff' + 'ect' ]; +// removed +retained1.noEffect; -const removed2a = { - get shadowedEffect () { - console.log( 'effect' ); +//retained +retained1.effect; +retained1['eff' + 'ect']; + +const removed2 = { + get shadowedEffect() { + console.log('effect'); return 1; }, shadowedEffect: true, - set shadowedEffect ( value ) { - console.log( value ); + set shadowedEffect(value) { + console.log(value); } }; -const removed2b = removed2a.shadowedEffect; -const removed2c = removed2a.missingProp; +removed2.shadowedEffect; const retained3 = { - set effect ( value ) { - console.log( value ); + set effect(value) { + console.log(value); } }; retained3.effect = 'retained'; const retained4 = { - set effect ( value ) { - console.log( value ); + set effect(value) { + console.log(value); } }; -retained4[ 'eff' + 'ect' ] = 'retained'; +retained4['eff' + 'ect'] = 'retained'; const removed5 = { - set noEffect ( value ) { + set noEffect(value) { const x = value; } }; removed5.noEffect = 'removed'; -const removed6 = { - set shadowedEffect ( value ) { - console.log( value ); - }, - shadowedEffect: true -}; - -removed6.shadowedEffect = true; -removed6.missingProp = true; - const retained7 = { foo: () => {}, - get foo () { + get foo() { return 1; } }; diff --git a/test/form/samples/side-effects-in-template-literals/_config.js b/test/form/samples/side-effects-in-template-literals/_config.js index 61c8d75330d..742e31ed751 100644 --- a/test/form/samples/side-effects-in-template-literals/_config.js +++ b/test/form/samples/side-effects-in-template-literals/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'detects side-effects in template literals and tagged template expressions', options: { output: { name: 'myBundle' } } -}; +}); diff --git a/test/form/samples/side-effects-internal-modules/_config.js b/test/form/samples/side-effects-internal-modules/_config.js index aa9d774424c..091fe7d8cc7 100644 --- a/test/form/samples/side-effects-internal-modules/_config.js +++ b/test/form/samples/side-effects-internal-modules/_config.js @@ -1,7 +1,7 @@ -const assert = require('assert'); +const assert = require('node:assert'); const VIRTUAL_ID = '\0virtual'; -module.exports = { +module.exports = defineTest({ description: 'does not pass internal modules to moduleSideEffects', expectedWarnings: ['EMPTY_BUNDLE'], options: { @@ -11,18 +11,20 @@ module.exports = { return false; } }, - plugins: { - name: 'test-plugin', - resolveId(id) { - if (id === 'virtual') { - return VIRTUAL_ID; - } - }, - load(id) { - if (id === VIRTUAL_ID) { - return "console.log('effect')"; + plugins: [ + { + name: 'test-plugin', + resolveId(id) { + if (id === 'virtual') { + return VIRTUAL_ID; + } + }, + load(id) { + if (id === VIRTUAL_ID) { + return "console.log('effect')"; + } } } - } + ] } -}; +}); diff --git a/test/form/samples/side-effects-logical-expressions/_config.js b/test/form/samples/side-effects-logical-expressions/_config.js index c836fb6ccb7..d202cf8dc4b 100644 --- a/test/form/samples/side-effects-logical-expressions/_config.js +++ b/test/form/samples/side-effects-logical-expressions/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'only evaluate the second part of a logical expression if necessary' -}; +}); diff --git a/test/form/samples/side-effects-logical-expressions/_expected/amd.js b/test/form/samples/side-effects-logical-expressions/_expected/amd.js index 6065cf6e88a..fc94706a8e8 100644 --- a/test/form/samples/side-effects-logical-expressions/_expected/amd.js +++ b/test/form/samples/side-effects-logical-expressions/_expected/amd.js @@ -1,4 +1,4 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; // effect console.log( 'effect' ); @@ -9,9 +9,7 @@ define(function () { 'use strict'; const foo = { get effect () { console.log( 'effect' ); - }, - get noEffect () {} - }; + }}; // effect (foo).effect; @@ -22,15 +20,15 @@ define(function () { 'use strict'; (null).foo = 1; // effect - (true )(); - (false )(); + (true)(); + (false)(); ((() => console.log( 'effect' )))(); ((() => console.log( 'effect' )))(); // effect - (true )()(); - (false )()(); + (true)()(); + (false)()(); ((() => () => console.log( 'effect' )))()(); ((() => () => console.log( 'effect' )))()(); -}); +})); diff --git a/test/form/samples/side-effects-logical-expressions/_expected/cjs.js b/test/form/samples/side-effects-logical-expressions/_expected/cjs.js index f39a15cadc7..a607ca44b57 100644 --- a/test/form/samples/side-effects-logical-expressions/_expected/cjs.js +++ b/test/form/samples/side-effects-logical-expressions/_expected/cjs.js @@ -9,9 +9,7 @@ console.log( 'effect' ) && {}; const foo = { get effect () { console.log( 'effect' ); - }, - get noEffect () {} -}; + }}; // effect (foo).effect; @@ -22,13 +20,13 @@ const foo = { (null).foo = 1; // effect -(true )(); -(false )(); +(true)(); +(false)(); ((() => console.log( 'effect' )))(); ((() => console.log( 'effect' )))(); // effect -(true )()(); -(false )()(); +(true)()(); +(false)()(); ((() => () => console.log( 'effect' )))()(); ((() => () => console.log( 'effect' )))()(); diff --git a/test/form/samples/side-effects-logical-expressions/_expected/es.js b/test/form/samples/side-effects-logical-expressions/_expected/es.js index 9de928c8d83..cb958dd289e 100644 --- a/test/form/samples/side-effects-logical-expressions/_expected/es.js +++ b/test/form/samples/side-effects-logical-expressions/_expected/es.js @@ -7,9 +7,7 @@ console.log( 'effect' ) && {}; const foo = { get effect () { console.log( 'effect' ); - }, - get noEffect () {} -}; + }}; // effect (foo).effect; @@ -20,13 +18,13 @@ const foo = { (null).foo = 1; // effect -(true )(); -(false )(); +(true)(); +(false)(); ((() => console.log( 'effect' )))(); ((() => console.log( 'effect' )))(); // effect -(true )()(); -(false )()(); +(true)()(); +(false)()(); ((() => () => console.log( 'effect' )))()(); ((() => () => console.log( 'effect' )))()(); diff --git a/test/form/samples/side-effects-logical-expressions/_expected/iife.js b/test/form/samples/side-effects-logical-expressions/_expected/iife.js index 00fa987dc6b..173c1f306a7 100644 --- a/test/form/samples/side-effects-logical-expressions/_expected/iife.js +++ b/test/form/samples/side-effects-logical-expressions/_expected/iife.js @@ -10,9 +10,7 @@ const foo = { get effect () { console.log( 'effect' ); - }, - get noEffect () {} - }; + }}; // effect (foo).effect; @@ -23,15 +21,15 @@ (null).foo = 1; // effect - (true )(); - (false )(); + (true)(); + (false)(); ((() => console.log( 'effect' )))(); ((() => console.log( 'effect' )))(); // effect - (true )()(); - (false )()(); + (true)()(); + (false)()(); ((() => () => console.log( 'effect' )))()(); ((() => () => console.log( 'effect' )))()(); -}()); +})(); diff --git a/test/form/samples/side-effects-logical-expressions/_expected/system.js b/test/form/samples/side-effects-logical-expressions/_expected/system.js index 5a5da5a790d..c4b22d8ac26 100644 --- a/test/form/samples/side-effects-logical-expressions/_expected/system.js +++ b/test/form/samples/side-effects-logical-expressions/_expected/system.js @@ -1,7 +1,7 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { // effect console.log( 'effect' ); @@ -12,9 +12,7 @@ System.register([], function () { const foo = { get effect () { console.log( 'effect' ); - }, - get noEffect () {} - }; + }}; // effect (foo).effect; @@ -25,17 +23,17 @@ System.register([], function () { (null).foo = 1; // effect - (true )(); - (false )(); + (true)(); + (false)(); ((() => console.log( 'effect' )))(); ((() => console.log( 'effect' )))(); // effect - (true )()(); - (false )()(); + (true)()(); + (false)()(); ((() => () => console.log( 'effect' )))()(); ((() => () => console.log( 'effect' )))()(); - } + }) }; -}); +})); diff --git a/test/form/samples/side-effects-logical-expressions/_expected/umd.js b/test/form/samples/side-effects-logical-expressions/_expected/umd.js index 1ab69e5e23f..b9ceed374ce 100644 --- a/test/form/samples/side-effects-logical-expressions/_expected/umd.js +++ b/test/form/samples/side-effects-logical-expressions/_expected/umd.js @@ -1,7 +1,7 @@ (function (factory) { typeof define === 'function' && define.amd ? define(factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; // effect console.log( 'effect' ); @@ -12,9 +12,7 @@ const foo = { get effect () { console.log( 'effect' ); - }, - get noEffect () {} - }; + }}; // effect (foo).effect; @@ -25,15 +23,15 @@ (null).foo = 1; // effect - (true )(); - (false )(); + (true)(); + (false)(); ((() => console.log( 'effect' )))(); ((() => console.log( 'effect' )))(); // effect - (true )()(); - (false )()(); + (true)()(); + (false)()(); ((() => () => console.log( 'effect' )))()(); ((() => () => console.log( 'effect' )))()(); -}))); +})); diff --git a/test/form/samples/side-effects-object-literal-calls/_config.js b/test/form/samples/side-effects-object-literal-calls/_config.js index ffc52c259c1..6d13f637ae2 100644 --- a/test/form/samples/side-effects-object-literal-calls/_config.js +++ b/test/form/samples/side-effects-object-literal-calls/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'detects side-effects when mutating object literals' -}; +}); diff --git a/test/form/samples/side-effects-object-literal-mutation-misc/_config.js b/test/form/samples/side-effects-object-literal-mutation-misc/_config.js index d94d592cf65..2350348da73 100644 --- a/test/form/samples/side-effects-object-literal-mutation-misc/_config.js +++ b/test/form/samples/side-effects-object-literal-mutation-misc/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'detects side-effects when setting and/or calling properties on object literals', options: { output: { name: 'bundle' } } -}; +}); diff --git a/test/form/samples/side-effects-object-literal-mutation/_config.js b/test/form/samples/side-effects-object-literal-mutation/_config.js index 2eaf74d0b0b..6d13f637ae2 100644 --- a/test/form/samples/side-effects-object-literal-mutation/_config.js +++ b/test/form/samples/side-effects-object-literal-mutation/_config.js @@ -1,4 +1,3 @@ -module.exports = { - description: 'detects side-effects when mutating object literals', - options: { output: { name: 'bundle' } } -}; +module.exports = defineTest({ + description: 'detects side-effects when mutating object literals' +}); diff --git a/test/form/samples/side-effects-object-literal-mutation/_expected.js b/test/form/samples/side-effects-object-literal-mutation/_expected.js index f42a72e8a66..f2e8bbcc06f 100644 --- a/test/form/samples/side-effects-object-literal-mutation/_expected.js +++ b/test/form/samples/side-effects-object-literal-mutation/_expected.js @@ -2,7 +2,7 @@ const retained1 = { x: {} }; retained1.y = 1; retained1.x.y = 2; -const retained2 = { x: {} }; +const retained2 = { }; retained2.y.z = 1; const retained3 = { x: {} }; diff --git a/test/form/samples/side-effects-parameter-defaults/_config.js b/test/form/samples/side-effects-parameter-defaults/_config.js deleted file mode 100644 index 97ab2c92c92..00000000000 --- a/test/form/samples/side-effects-parameter-defaults/_config.js +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = { - description: 'side-effects in paramter defaults should not be ignored' -}; diff --git a/test/form/samples/side-effects-parameter-defaults/_expected/amd.js b/test/form/samples/side-effects-parameter-defaults/_expected/amd.js deleted file mode 100644 index 3ad4ce95b5f..00000000000 --- a/test/form/samples/side-effects-parameter-defaults/_expected/amd.js +++ /dev/null @@ -1,29 +0,0 @@ -define(function () { 'use strict'; - - const effect = () => console.log( 'effect' ); - - function aDecl ( x = effect() ) {} - aDecl(); - - const aExp = function ( x = effect() ) {}; - aExp(); - - const aArr = ( x = effect() ) => {}; - aArr(); - - function bDecl ( x = effect ) { - x(); - } - bDecl(); - - const bExp = function ( x = effect ) { - x(); - }; - bExp(); - - const bArr = ( x = effect ) => { - x(); - }; - bArr(); - -}); diff --git a/test/form/samples/side-effects-parameter-defaults/_expected/cjs.js b/test/form/samples/side-effects-parameter-defaults/_expected/cjs.js deleted file mode 100644 index db9e8b6e74e..00000000000 --- a/test/form/samples/side-effects-parameter-defaults/_expected/cjs.js +++ /dev/null @@ -1,27 +0,0 @@ -'use strict'; - -const effect = () => console.log( 'effect' ); - -function aDecl ( x = effect() ) {} -aDecl(); - -const aExp = function ( x = effect() ) {}; -aExp(); - -const aArr = ( x = effect() ) => {}; -aArr(); - -function bDecl ( x = effect ) { - x(); -} -bDecl(); - -const bExp = function ( x = effect ) { - x(); -}; -bExp(); - -const bArr = ( x = effect ) => { - x(); -}; -bArr(); diff --git a/test/form/samples/side-effects-parameter-defaults/_expected/es.js b/test/form/samples/side-effects-parameter-defaults/_expected/es.js deleted file mode 100644 index d8c68658ffd..00000000000 --- a/test/form/samples/side-effects-parameter-defaults/_expected/es.js +++ /dev/null @@ -1,25 +0,0 @@ -const effect = () => console.log( 'effect' ); - -function aDecl ( x = effect() ) {} -aDecl(); - -const aExp = function ( x = effect() ) {}; -aExp(); - -const aArr = ( x = effect() ) => {}; -aArr(); - -function bDecl ( x = effect ) { - x(); -} -bDecl(); - -const bExp = function ( x = effect ) { - x(); -}; -bExp(); - -const bArr = ( x = effect ) => { - x(); -}; -bArr(); diff --git a/test/form/samples/side-effects-parameter-defaults/_expected/iife.js b/test/form/samples/side-effects-parameter-defaults/_expected/iife.js deleted file mode 100644 index 9247ef783f0..00000000000 --- a/test/form/samples/side-effects-parameter-defaults/_expected/iife.js +++ /dev/null @@ -1,30 +0,0 @@ -(function () { - 'use strict'; - - const effect = () => console.log( 'effect' ); - - function aDecl ( x = effect() ) {} - aDecl(); - - const aExp = function ( x = effect() ) {}; - aExp(); - - const aArr = ( x = effect() ) => {}; - aArr(); - - function bDecl ( x = effect ) { - x(); - } - bDecl(); - - const bExp = function ( x = effect ) { - x(); - }; - bExp(); - - const bArr = ( x = effect ) => { - x(); - }; - bArr(); - -}()); diff --git a/test/form/samples/side-effects-parameter-defaults/_expected/system.js b/test/form/samples/side-effects-parameter-defaults/_expected/system.js deleted file mode 100644 index d4501ce0bed..00000000000 --- a/test/form/samples/side-effects-parameter-defaults/_expected/system.js +++ /dev/null @@ -1,34 +0,0 @@ -System.register([], function () { - 'use strict'; - return { - execute: function () { - - const effect = () => console.log( 'effect' ); - - function aDecl ( x = effect() ) {} - aDecl(); - - const aExp = function ( x = effect() ) {}; - aExp(); - - const aArr = ( x = effect() ) => {}; - aArr(); - - function bDecl ( x = effect ) { - x(); - } - bDecl(); - - const bExp = function ( x = effect ) { - x(); - }; - bExp(); - - const bArr = ( x = effect ) => { - x(); - }; - bArr(); - - } - }; -}); diff --git a/test/form/samples/side-effects-parameter-defaults/_expected/umd.js b/test/form/samples/side-effects-parameter-defaults/_expected/umd.js deleted file mode 100644 index 76d08d8badb..00000000000 --- a/test/form/samples/side-effects-parameter-defaults/_expected/umd.js +++ /dev/null @@ -1,32 +0,0 @@ -(function (factory) { - typeof define === 'function' && define.amd ? define(factory) : - factory(); -}((function () { 'use strict'; - - const effect = () => console.log( 'effect' ); - - function aDecl ( x = effect() ) {} - aDecl(); - - const aExp = function ( x = effect() ) {}; - aExp(); - - const aArr = ( x = effect() ) => {}; - aArr(); - - function bDecl ( x = effect ) { - x(); - } - bDecl(); - - const bExp = function ( x = effect ) { - x(); - }; - bExp(); - - const bArr = ( x = effect ) => { - x(); - }; - bArr(); - -}))); diff --git a/test/form/samples/side-effects-parameter-defaults/main.js b/test/form/samples/side-effects-parameter-defaults/main.js deleted file mode 100644 index d8c68658ffd..00000000000 --- a/test/form/samples/side-effects-parameter-defaults/main.js +++ /dev/null @@ -1,25 +0,0 @@ -const effect = () => console.log( 'effect' ); - -function aDecl ( x = effect() ) {} -aDecl(); - -const aExp = function ( x = effect() ) {}; -aExp(); - -const aArr = ( x = effect() ) => {}; -aArr(); - -function bDecl ( x = effect ) { - x(); -} -bDecl(); - -const bExp = function ( x = effect ) { - x(); -}; -bExp(); - -const bArr = ( x = effect ) => { - x(); -}; -bArr(); diff --git a/test/form/samples/side-effects-pattern-assignment/_config.js b/test/form/samples/side-effects-pattern-assignment/_config.js index da2ca598ba6..6741af48702 100644 --- a/test/form/samples/side-effects-pattern-assignment/_config.js +++ b/test/form/samples/side-effects-pattern-assignment/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'side-effects when mutating destructured variables should not be ignored' -}; +}); diff --git a/test/form/samples/side-effects-pattern-assignment/_expected.js b/test/form/samples/side-effects-pattern-assignment/_expected.js index 16c6cefd9c2..a86b215304b 100644 --- a/test/form/samples/side-effects-pattern-assignment/_expected.js +++ b/test/form/samples/side-effects-pattern-assignment/_expected.js @@ -1,3 +1,13 @@ +var a = {}; +({x: a} = globalThis.unknown); + +var b = {}; +({b} = globalThis.unknown); + +var {x: c} = globalThis.unknown; + +var {d} = globalThis.unknown; + var e = {}; ({x: e} = globalThis.unknown); e.foo = 1; @@ -12,6 +22,16 @@ g.foo = 1; var {h} = globalThis.unknown; h.foo = 1; +var i = {}; +[i] = globalThis.unknown; + +var [j] = globalThis.unknown; + +var k = {}; +[,...k] = globalThis.unknown; + +var [,...l] = globalThis.unknown; + var m = {}; [m] = globalThis.unknown; m.foo = 1; diff --git a/test/form/samples/side-effects-pattern-defaults/_config.js b/test/form/samples/side-effects-pattern-defaults/_config.js index 004103a15d9..0d651f9f4da 100644 --- a/test/form/samples/side-effects-pattern-defaults/_config.js +++ b/test/form/samples/side-effects-pattern-defaults/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'side-effects in pattern defaults should not be ignored' -}; +}); diff --git a/test/form/samples/side-effects-pattern-defaults/_expected/amd.js b/test/form/samples/side-effects-pattern-defaults/_expected/amd.js index 85339cc44da..0532ff1d0f5 100644 --- a/test/form/samples/side-effects-pattern-defaults/_expected/amd.js +++ b/test/form/samples/side-effects-pattern-defaults/_expected/amd.js @@ -1,4 +1,4 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; const effect = () => console.log( 'effect' ); var { x: a2 = effect() } = {}; @@ -28,4 +28,4 @@ define(function () { 'use strict'; [ d4 = effect ] = []; d4(); -}); +})); diff --git a/test/form/samples/side-effects-pattern-defaults/_expected/iife.js b/test/form/samples/side-effects-pattern-defaults/_expected/iife.js index 4ea4fb74c9c..b73704fb4db 100644 --- a/test/form/samples/side-effects-pattern-defaults/_expected/iife.js +++ b/test/form/samples/side-effects-pattern-defaults/_expected/iife.js @@ -29,4 +29,4 @@ [ d4 = effect ] = []; d4(); -}()); +})(); diff --git a/test/form/samples/side-effects-pattern-defaults/_expected/system.js b/test/form/samples/side-effects-pattern-defaults/_expected/system.js index 1780eb25d3a..f2a95997c06 100644 --- a/test/form/samples/side-effects-pattern-defaults/_expected/system.js +++ b/test/form/samples/side-effects-pattern-defaults/_expected/system.js @@ -1,7 +1,7 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { const effect = () => console.log( 'effect' ); var { x: a2 = effect() } = {}; @@ -31,6 +31,6 @@ System.register([], function () { [ d4 = effect ] = []; d4(); - } + }) }; -}); +})); diff --git a/test/form/samples/side-effects-pattern-defaults/_expected/umd.js b/test/form/samples/side-effects-pattern-defaults/_expected/umd.js index 87287b523cf..971c4e45f0c 100644 --- a/test/form/samples/side-effects-pattern-defaults/_expected/umd.js +++ b/test/form/samples/side-effects-pattern-defaults/_expected/umd.js @@ -1,7 +1,7 @@ (function (factory) { typeof define === 'function' && define.amd ? define(factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; const effect = () => console.log( 'effect' ); var { x: a2 = effect() } = {}; @@ -31,4 +31,4 @@ [ d4 = effect ] = []; d4(); -}))); +})); diff --git a/test/form/samples/side-effects-prototype-assignments/_config.js b/test/form/samples/side-effects-prototype-assignments/_config.js index b71c53dd0a2..e5fd32ec599 100644 --- a/test/form/samples/side-effects-prototype-assignments/_config.js +++ b/test/form/samples/side-effects-prototype-assignments/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'include side-effects with re-assigned prototypes (#953)' -}; +}); diff --git a/test/form/samples/side-effects-prototype-assignments/_expected/es.js b/test/form/samples/side-effects-prototype-assignments/_expected.js similarity index 100% rename from test/form/samples/side-effects-prototype-assignments/_expected/es.js rename to test/form/samples/side-effects-prototype-assignments/_expected.js diff --git a/test/form/samples/side-effects-prototype-assignments/_expected/amd.js b/test/form/samples/side-effects-prototype-assignments/_expected/amd.js deleted file mode 100644 index d1d09de5bb5..00000000000 --- a/test/form/samples/side-effects-prototype-assignments/_expected/amd.js +++ /dev/null @@ -1,14 +0,0 @@ -define(function () { 'use strict'; - - function V8Engine () {} - - V8Engine.prototype.toString = function () { return 'V8'; }; - - function V6Engine () {} - - V6Engine.prototype = V8Engine.prototype; - V6Engine.prototype.toString = function () { return 'V6'; }; - - console.log( new V8Engine().toString() ); - -}); diff --git a/test/form/samples/side-effects-prototype-assignments/_expected/cjs.js b/test/form/samples/side-effects-prototype-assignments/_expected/cjs.js deleted file mode 100644 index 47c19ab9df2..00000000000 --- a/test/form/samples/side-effects-prototype-assignments/_expected/cjs.js +++ /dev/null @@ -1,12 +0,0 @@ -'use strict'; - -function V8Engine () {} - -V8Engine.prototype.toString = function () { return 'V8'; }; - -function V6Engine () {} - -V6Engine.prototype = V8Engine.prototype; -V6Engine.prototype.toString = function () { return 'V6'; }; - -console.log( new V8Engine().toString() ); diff --git a/test/form/samples/side-effects-prototype-assignments/_expected/iife.js b/test/form/samples/side-effects-prototype-assignments/_expected/iife.js deleted file mode 100644 index de3d76004dd..00000000000 --- a/test/form/samples/side-effects-prototype-assignments/_expected/iife.js +++ /dev/null @@ -1,15 +0,0 @@ -(function () { - 'use strict'; - - function V8Engine () {} - - V8Engine.prototype.toString = function () { return 'V8'; }; - - function V6Engine () {} - - V6Engine.prototype = V8Engine.prototype; - V6Engine.prototype.toString = function () { return 'V6'; }; - - console.log( new V8Engine().toString() ); - -}()); diff --git a/test/form/samples/side-effects-prototype-assignments/_expected/system.js b/test/form/samples/side-effects-prototype-assignments/_expected/system.js deleted file mode 100644 index 7048215019d..00000000000 --- a/test/form/samples/side-effects-prototype-assignments/_expected/system.js +++ /dev/null @@ -1,19 +0,0 @@ -System.register([], function () { - 'use strict'; - return { - execute: function () { - - function V8Engine () {} - - V8Engine.prototype.toString = function () { return 'V8'; }; - - function V6Engine () {} - - V6Engine.prototype = V8Engine.prototype; - V6Engine.prototype.toString = function () { return 'V6'; }; - - console.log( new V8Engine().toString() ); - - } - }; -}); diff --git a/test/form/samples/side-effects-prototype-assignments/_expected/umd.js b/test/form/samples/side-effects-prototype-assignments/_expected/umd.js deleted file mode 100644 index bb823eb6f1e..00000000000 --- a/test/form/samples/side-effects-prototype-assignments/_expected/umd.js +++ /dev/null @@ -1,17 +0,0 @@ -(function (factory) { - typeof define === 'function' && define.amd ? define(factory) : - factory(); -}((function () { 'use strict'; - - function V8Engine () {} - - V8Engine.prototype.toString = function () { return 'V8'; }; - - function V6Engine () {} - - V6Engine.prototype = V8Engine.prototype; - V6Engine.prototype.toString = function () { return 'V6'; }; - - console.log( new V8Engine().toString() ); - -}))); diff --git a/test/form/samples/side-effects-prototype-assignments/main.js b/test/form/samples/side-effects-prototype-assignments/main.js index 39142a71ca9..f7dcc5162ec 100644 --- a/test/form/samples/side-effects-prototype-assignments/main.js +++ b/test/form/samples/side-effects-prototype-assignments/main.js @@ -10,6 +10,5 @@ V6Engine.prototype.toString = function () { return 'V6'; }; function IgnoredEngine () {} IgnoredEngine.prototype.toString = function () { return 'IGNORED'; }; -IgnoredEngine.prototype[ 'to' + 'String' ] = function () { return 'IGNORED'; }; console.log( new V8Engine().toString() ); diff --git a/test/form/samples/side-effects-reassignment/_config.js b/test/form/samples/side-effects-reassignment/_config.js index c1a20cb442e..5dd48c24692 100644 --- a/test/form/samples/side-effects-reassignment/_config.js +++ b/test/form/samples/side-effects-reassignment/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'when mutating/calling a reassigned variable, all assignments should be checked for side-effects' -}; +}); diff --git a/test/form/samples/side-effects-reassignment/_expected/amd.js b/test/form/samples/side-effects-reassignment/_expected/amd.js index 1056781e7d0..49decd83490 100644 --- a/test/form/samples/side-effects-reassignment/_expected/amd.js +++ b/test/form/samples/side-effects-reassignment/_expected/amd.js @@ -1,4 +1,4 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; var effect = function() { console.log('effect'); @@ -7,4 +7,4 @@ define(function () { 'use strict'; var alsoEffect = effect; alsoEffect(); -}); +})); diff --git a/test/form/samples/side-effects-reassignment/_expected/iife.js b/test/form/samples/side-effects-reassignment/_expected/iife.js index 2d21989b418..1679dbbf044 100644 --- a/test/form/samples/side-effects-reassignment/_expected/iife.js +++ b/test/form/samples/side-effects-reassignment/_expected/iife.js @@ -8,4 +8,4 @@ var alsoEffect = effect; alsoEffect(); -}()); +})(); diff --git a/test/form/samples/side-effects-reassignment/_expected/system.js b/test/form/samples/side-effects-reassignment/_expected/system.js index 8c7b33a508a..b10a824e25f 100644 --- a/test/form/samples/side-effects-reassignment/_expected/system.js +++ b/test/form/samples/side-effects-reassignment/_expected/system.js @@ -1,7 +1,7 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { var effect = function() { console.log('effect'); @@ -10,6 +10,6 @@ System.register([], function () { var alsoEffect = effect; alsoEffect(); - } + }) }; -}); +})); diff --git a/test/form/samples/side-effects-reassignment/_expected/umd.js b/test/form/samples/side-effects-reassignment/_expected/umd.js index 433c5241b24..3a4cffb245d 100644 --- a/test/form/samples/side-effects-reassignment/_expected/umd.js +++ b/test/form/samples/side-effects-reassignment/_expected/umd.js @@ -1,7 +1,7 @@ (function (factory) { typeof define === 'function' && define.amd ? define(factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; var effect = function() { console.log('effect'); @@ -10,4 +10,4 @@ var alsoEffect = effect; alsoEffect(); -}))); +})); diff --git a/test/form/samples/side-effects-return-statements/_config.js b/test/form/samples/side-effects-return-statements/_config.js index 3d428613c13..979336af10e 100644 --- a/test/form/samples/side-effects-return-statements/_config.js +++ b/test/form/samples/side-effects-return-statements/_config.js @@ -1,5 +1,5 @@ -module.exports = { +module.exports = defineTest({ description: 'return statements do not have side-effects but should be kept in certain cases (#1585)', options: { output: { name: 'myBundle' } } -}; +}); diff --git a/test/form/samples/side-effects-return-statements/_expected/amd.js b/test/form/samples/side-effects-return-statements/_expected/amd.js index d2f35ca8d8a..1633b0ab0e9 100644 --- a/test/form/samples/side-effects-return-statements/_expected/amd.js +++ b/test/form/samples/side-effects-return-statements/_expected/amd.js @@ -1,4 +1,4 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; function isUsed ( x ) { if ( x ) { @@ -8,5 +8,6 @@ define(function () { 'use strict'; } assert.equal( isUsed( true ), 2 ); + assert.equal( isUsed( false ), 1 ); -}); +})); diff --git a/test/form/samples/side-effects-return-statements/_expected/cjs.js b/test/form/samples/side-effects-return-statements/_expected/cjs.js index 7dd6e813034..93d4ccf36c7 100644 --- a/test/form/samples/side-effects-return-statements/_expected/cjs.js +++ b/test/form/samples/side-effects-return-statements/_expected/cjs.js @@ -8,3 +8,4 @@ function isUsed ( x ) { } assert.equal( isUsed( true ), 2 ); +assert.equal( isUsed( false ), 1 ); diff --git a/test/form/samples/side-effects-return-statements/_expected/es.js b/test/form/samples/side-effects-return-statements/_expected/es.js index 38f357c97fc..9898b0d0f8b 100644 --- a/test/form/samples/side-effects-return-statements/_expected/es.js +++ b/test/form/samples/side-effects-return-statements/_expected/es.js @@ -6,3 +6,4 @@ function isUsed ( x ) { } assert.equal( isUsed( true ), 2 ); +assert.equal( isUsed( false ), 1 ); diff --git a/test/form/samples/side-effects-return-statements/_expected/iife.js b/test/form/samples/side-effects-return-statements/_expected/iife.js index 12f8e3e2071..81b64ec8112 100644 --- a/test/form/samples/side-effects-return-statements/_expected/iife.js +++ b/test/form/samples/side-effects-return-statements/_expected/iife.js @@ -9,5 +9,6 @@ } assert.equal( isUsed( true ), 2 ); + assert.equal( isUsed( false ), 1 ); -}()); +})(); diff --git a/test/form/samples/side-effects-return-statements/_expected/system.js b/test/form/samples/side-effects-return-statements/_expected/system.js index 8883f155e33..096bcc73f08 100644 --- a/test/form/samples/side-effects-return-statements/_expected/system.js +++ b/test/form/samples/side-effects-return-statements/_expected/system.js @@ -1,7 +1,7 @@ -System.register('myBundle', [], function () { +System.register('myBundle', [], (function () { 'use strict'; return { - execute: function () { + execute: (function () { function isUsed ( x ) { if ( x ) { @@ -11,7 +11,8 @@ System.register('myBundle', [], function () { } assert.equal( isUsed( true ), 2 ); + assert.equal( isUsed( false ), 1 ); - } + }) }; -}); +})); diff --git a/test/form/samples/side-effects-return-statements/_expected/umd.js b/test/form/samples/side-effects-return-statements/_expected/umd.js index 255d0d9f31f..fc3ff304af8 100644 --- a/test/form/samples/side-effects-return-statements/_expected/umd.js +++ b/test/form/samples/side-effects-return-statements/_expected/umd.js @@ -1,7 +1,7 @@ (function (factory) { typeof define === 'function' && define.amd ? define(factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; function isUsed ( x ) { if ( x ) { @@ -11,5 +11,6 @@ } assert.equal( isUsed( true ), 2 ); + assert.equal( isUsed( false ), 1 ); -}))); +})); diff --git a/test/form/samples/side-effects-return-statements/main.js b/test/form/samples/side-effects-return-statements/main.js index 8e6b3b54f4f..a1e68e5d63f 100644 --- a/test/form/samples/side-effects-return-statements/main.js +++ b/test/form/samples/side-effects-return-statements/main.js @@ -15,3 +15,4 @@ function isUsed ( x ) { } assert.equal( isUsed( true ), 2 ); +assert.equal( isUsed( false ), 1 ); diff --git a/test/form/samples/side-effects-static-methods/_config.js b/test/form/samples/side-effects-static-methods/_config.js new file mode 100644 index 00000000000..b43c035c4b3 --- /dev/null +++ b/test/form/samples/side-effects-static-methods/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'allow calls to pure static methods to be tree-shaken' +}); diff --git a/test/form/samples/side-effects-static-methods/_expected.js b/test/form/samples/side-effects-static-methods/_expected.js new file mode 100644 index 00000000000..3b12efac3e3 --- /dev/null +++ b/test/form/samples/side-effects-static-methods/_expected.js @@ -0,0 +1,38 @@ +class Effect { + static a() { log(); } +} +Effect.a(); + +class DeoptComputed { + static a() {} + static [foo]() { log(); } +} +DeoptComputed.a(); + +class DeoptGetter { + static a() {} + static get a() {} +} +DeoptGetter.a(); + +class DeoptAssign { + static a() {} +} +DeoptAssign.a = log; +DeoptAssign.a(); + +class DeoptFully { + static a() {} +} +unknown(DeoptFully); +DeoptFully.a(); + +class DeepAssign { + static a = {} + a = {} +} +DeepAssign.a.b = 1; +DeepAssign.prototype.a.b = 1; + +class DynamicAssign {} +DynamicAssign[foo()] = 1; diff --git a/test/form/samples/side-effects-static-methods/main.js b/test/form/samples/side-effects-static-methods/main.js new file mode 100644 index 00000000000..f2d3e1036b4 --- /dev/null +++ b/test/form/samples/side-effects-static-methods/main.js @@ -0,0 +1,43 @@ +class NoEffect { + static a() {} +} +NoEffect.a(); + +class Effect { + static a() { log(); } +} +Effect.a(); + +class DeoptComputed { + static a() {} + static [foo]() { log(); } +} +DeoptComputed.a(); + +class DeoptGetter { + static a() {} + static get a() {} +} +DeoptGetter.a(); + +class DeoptAssign { + static a() {} +} +DeoptAssign.a = log; +DeoptAssign.a(); + +class DeoptFully { + static a() {} +} +unknown(DeoptFully); +DeoptFully.a(); + +class DeepAssign { + static a = {} + a = {} +} +DeepAssign.a.b = 1; +DeepAssign.prototype.a.b = 1; + +class DynamicAssign {} +DynamicAssign[foo()] = 1; diff --git a/test/form/samples/side-effects-switch-statements/_config.js b/test/form/samples/side-effects-switch-statements/_config.js index b35f375c5b6..d36aac38c82 100644 --- a/test/form/samples/side-effects-switch-statements/_config.js +++ b/test/form/samples/side-effects-switch-statements/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'switch statements should be correctly tree-shaken' -}; +}); diff --git a/test/form/samples/side-effects-this/_config.js b/test/form/samples/side-effects-this/_config.js new file mode 100644 index 00000000000..3c46475904f --- /dev/null +++ b/test/form/samples/side-effects-this/_config.js @@ -0,0 +1,4 @@ +module.exports = defineTest({ + description: + 'When a constructor is called with the new keyword, changing its this has no side effects' +}); diff --git a/test/form/samples/side-effects-this/_expected.js b/test/form/samples/side-effects-this/_expected.js new file mode 100644 index 00000000000..ce6ed12fc15 --- /dev/null +++ b/test/form/samples/side-effects-this/_expected.js @@ -0,0 +1,13 @@ +class Main { + constructor() { + this.a = 1; + } +} +const b = new Main(); +assert.ok(b); + +function Foo() { + this.a = 1; +} +const d = new Foo(); +assert.ok(d); diff --git a/test/form/samples/side-effects-this/main.js b/test/form/samples/side-effects-this/main.js new file mode 100644 index 00000000000..8eae66ed5a5 --- /dev/null +++ b/test/form/samples/side-effects-this/main.js @@ -0,0 +1,16 @@ +class Main { + constructor() { + this.a = 1; + } +} +const a = new Main(); // removed +const b = new Main(); +assert.ok(b); + +function Foo() { + this.a = 1; +} + +const c = new Foo(); // removed +const d = new Foo(); +assert.ok(d); diff --git a/test/form/samples/simplified-initializer/_config.js b/test/form/samples/simplified-initializer/_config.js new file mode 100644 index 00000000000..b8cba9c117f --- /dev/null +++ b/test/form/samples/simplified-initializer/_config.js @@ -0,0 +1,4 @@ +module.exports = defineTest({ + description: 'handles simplified variable initializers', + options: { output: { name: 'bundle' } } +}); diff --git a/test/form/samples/simplified-initializer/_expected/amd.js b/test/form/samples/simplified-initializer/_expected/amd.js new file mode 100644 index 00000000000..a1219a0a4d0 --- /dev/null +++ b/test/form/samples/simplified-initializer/_expected/amd.js @@ -0,0 +1,11 @@ +define(['exports'], (function (exports) { 'use strict'; + + const a = window.config ? 1 : 2; + const b = 1 ; + const c = 2; + + exports.a = a; + exports.b = b; + exports.c = c; + +})); diff --git a/test/form/samples/simplified-initializer/_expected/cjs.js b/test/form/samples/simplified-initializer/_expected/cjs.js new file mode 100644 index 00000000000..188f321a643 --- /dev/null +++ b/test/form/samples/simplified-initializer/_expected/cjs.js @@ -0,0 +1,9 @@ +'use strict'; + +const a = window.config ? 1 : 2; +const b = 1 ; +const c = 2; + +exports.a = a; +exports.b = b; +exports.c = c; diff --git a/test/form/samples/simplified-initializer/_expected/es.js b/test/form/samples/simplified-initializer/_expected/es.js new file mode 100644 index 00000000000..bc942821bc6 --- /dev/null +++ b/test/form/samples/simplified-initializer/_expected/es.js @@ -0,0 +1,5 @@ +const a = window.config ? 1 : 2; +const b = 1 ; +const c = 2; + +export { a, b, c }; diff --git a/test/form/samples/simplified-initializer/_expected/iife.js b/test/form/samples/simplified-initializer/_expected/iife.js new file mode 100644 index 00000000000..e89d9eba578 --- /dev/null +++ b/test/form/samples/simplified-initializer/_expected/iife.js @@ -0,0 +1,14 @@ +var bundle = (function (exports) { + 'use strict'; + + const a = window.config ? 1 : 2; + const b = 1 ; + const c = 2; + + exports.a = a; + exports.b = b; + exports.c = c; + + return exports; + +})({}); diff --git a/test/form/samples/simplified-initializer/_expected/system.js b/test/form/samples/simplified-initializer/_expected/system.js new file mode 100644 index 00000000000..b90987b0176 --- /dev/null +++ b/test/form/samples/simplified-initializer/_expected/system.js @@ -0,0 +1,12 @@ +System.register('bundle', [], (function (exports) { + 'use strict'; + return { + execute: (function () { + + const a = exports("a", window.config ? 1 : 2); + const b = exports("b", 1 ); + const c = exports("c", 2); + + }) + }; +})); diff --git a/test/form/samples/simplified-initializer/_expected/umd.js b/test/form/samples/simplified-initializer/_expected/umd.js new file mode 100644 index 00000000000..dc1af22f9d6 --- /dev/null +++ b/test/form/samples/simplified-initializer/_expected/umd.js @@ -0,0 +1,15 @@ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : + typeof define === 'function' && define.amd ? define(['exports'], factory) : + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.bundle = {})); +})(this, (function (exports) { 'use strict'; + + const a = window.config ? 1 : 2; + const b = 1 ; + const c = 2; + + exports.a = a; + exports.b = b; + exports.c = c; + +})); diff --git a/test/form/samples/simplified-initializer/main.js b/test/form/samples/simplified-initializer/main.js new file mode 100644 index 00000000000..bede70e3059 --- /dev/null +++ b/test/form/samples/simplified-initializer/main.js @@ -0,0 +1,3 @@ +export const a = window.config ? 1 : 2 +export const b = true ? 1 : 2 +export const c = false ? 1 : 2 diff --git a/test/form/samples/simplify-expression-annotations/_config.js b/test/form/samples/simplify-expression-annotations/_config.js index 8bc62f8c55b..a0d80d6975f 100644 --- a/test/form/samples/simplify-expression-annotations/_config.js +++ b/test/form/samples/simplify-expression-annotations/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'keeps correct annotations when simplifying expressinos' -}; +}); diff --git a/test/form/samples/simplify-return-expression/_config.js b/test/form/samples/simplify-return-expression/_config.js index b89cc66704f..2175ca52e5e 100644 --- a/test/form/samples/simplify-return-expression/_config.js +++ b/test/form/samples/simplify-return-expression/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'Simplifies conditionals in return expression' -}; +}); diff --git a/test/form/samples/simplify-return-expression/_expected.js b/test/form/samples/simplify-return-expression/_expected.js index 67a7fcbae5a..e8a6b185d81 100644 --- a/test/form/samples/simplify-return-expression/_expected.js +++ b/test/form/samples/simplify-return-expression/_expected.js @@ -4,11 +4,45 @@ const test = () => { }; const foo = () => { - return A ; + return 'A' ; }; const bar = () => { - return A ; + return 'A' ; }; -export { test }; +(function() { + const test = () => { + console.log(foo()); + console.log(bar()); + }; + + const foo = () => { + // optimized + return 'A' ; + }; + + const bar = () => { + // optimized + return 'A' ; + }; + + test(); +})(); + +const test2 = () => { + console.log(foo2()); + console.log(bar2()); +}; + +const foo2 = () => { + // optimized + return 'A' ; +}; + +const bar2 = () => { + // optimized + return 'A' ; +}; + +export { test, test2 }; diff --git a/test/form/samples/simplify-return-expression/main.js b/test/form/samples/simplify-return-expression/main.js index 854407b5114..796651eacad 100644 --- a/test/form/samples/simplify-return-expression/main.js +++ b/test/form/samples/simplify-return-expression/main.js @@ -4,13 +4,59 @@ export const test = () => { }; const foo = () => { - return BUILD ? A : B; + return BUILD ? 'A' : 'B'; }; const bar = () => { - return getBuild() ? A : B; + return getBuild() ? 'A' : 'B'; }; const getBuild = () => BUILD; const BUILD = true; + +(function() { + const test = () => { + console.log(foo()); + console.log(bar()); + }; + + const foo = () => { + // optimized + return BUILD ? 'A' : 'B'; + }; + + const bar = () => { + // optimized + return getBuild() ? 'A' : 'B'; + }; + + // optimized away + const getBuild = () => BUILD; + + // optimized away + const BUILD = true; + + test(); +})(); + +// optimized away +const BUILD2 = true; + +// optimized away +const getBuild2 = () => BUILD2; + +export const test2 = () => { + console.log(foo2()); + console.log(bar2()); +}; + +const foo2 = () => { + // optimized + return BUILD2 ? 'A' : 'B'; +}; + +const bar2 = () => { + // optimized + return getBuild2() ? 'A' : 'B'; +}; diff --git a/test/form/samples/skips-dead-branches-b/_config.js b/test/form/samples/skips-dead-branches-b/_config.js index 22c399cee0b..3c56489dd01 100644 --- a/test/form/samples/skips-dead-branches-b/_config.js +++ b/test/form/samples/skips-dead-branches-b/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'skips a dead branch (b)' -}; +}); diff --git a/test/form/samples/skips-dead-branches-b/_expected/amd.js b/test/form/samples/skips-dead-branches-b/_expected/amd.js index c192900373e..6c54aa2f553 100644 --- a/test/form/samples/skips-dead-branches-b/_expected/amd.js +++ b/test/form/samples/skips-dead-branches-b/_expected/amd.js @@ -1,4 +1,4 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; function bar () { console.log( 'this should be included' ); @@ -6,4 +6,4 @@ define(function () { 'use strict'; bar(); -}); +})); diff --git a/test/form/samples/skips-dead-branches-b/_expected/iife.js b/test/form/samples/skips-dead-branches-b/_expected/iife.js index 3b894d92a46..bb52449895d 100644 --- a/test/form/samples/skips-dead-branches-b/_expected/iife.js +++ b/test/form/samples/skips-dead-branches-b/_expected/iife.js @@ -7,4 +7,4 @@ bar(); -}()); +})(); diff --git a/test/form/samples/skips-dead-branches-b/_expected/system.js b/test/form/samples/skips-dead-branches-b/_expected/system.js index 606d00fb15e..5d704ace2f8 100644 --- a/test/form/samples/skips-dead-branches-b/_expected/system.js +++ b/test/form/samples/skips-dead-branches-b/_expected/system.js @@ -1,7 +1,7 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { function bar () { console.log( 'this should be included' ); @@ -9,6 +9,6 @@ System.register([], function () { bar(); - } + }) }; -}); +})); diff --git a/test/form/samples/skips-dead-branches-b/_expected/umd.js b/test/form/samples/skips-dead-branches-b/_expected/umd.js index 06df11106d6..aa3c876a378 100644 --- a/test/form/samples/skips-dead-branches-b/_expected/umd.js +++ b/test/form/samples/skips-dead-branches-b/_expected/umd.js @@ -1,7 +1,7 @@ (function (factory) { typeof define === 'function' && define.amd ? define(factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; function bar () { console.log( 'this should be included' ); @@ -9,4 +9,4 @@ bar(); -}))); +})); diff --git a/test/form/samples/skips-dead-branches-c/_config.js b/test/form/samples/skips-dead-branches-c/_config.js index 86741425441..e2ae889d8e7 100644 --- a/test/form/samples/skips-dead-branches-c/_config.js +++ b/test/form/samples/skips-dead-branches-c/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'skips a dead branch (c)' -}; +}); diff --git a/test/form/samples/skips-dead-branches-c/_expected/amd.js b/test/form/samples/skips-dead-branches-c/_expected/amd.js index ee0987c254d..0db41c4cd0b 100644 --- a/test/form/samples/skips-dead-branches-c/_expected/amd.js +++ b/test/form/samples/skips-dead-branches-c/_expected/amd.js @@ -1,8 +1,8 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; function bar () { console.log( 'this should be included' ); } bar(); -}); +})); diff --git a/test/form/samples/skips-dead-branches-c/_expected/iife.js b/test/form/samples/skips-dead-branches-c/_expected/iife.js index fe8653ab50d..3aeff6ca0e3 100644 --- a/test/form/samples/skips-dead-branches-c/_expected/iife.js +++ b/test/form/samples/skips-dead-branches-c/_expected/iife.js @@ -6,4 +6,4 @@ } bar(); -}()); +})(); diff --git a/test/form/samples/skips-dead-branches-c/_expected/system.js b/test/form/samples/skips-dead-branches-c/_expected/system.js index add436161ef..07b082ad15d 100644 --- a/test/form/samples/skips-dead-branches-c/_expected/system.js +++ b/test/form/samples/skips-dead-branches-c/_expected/system.js @@ -1,13 +1,13 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { function bar () { console.log( 'this should be included' ); } bar(); - } + }) }; -}); +})); diff --git a/test/form/samples/skips-dead-branches-c/_expected/umd.js b/test/form/samples/skips-dead-branches-c/_expected/umd.js index 0d014e6e523..de161b3248b 100644 --- a/test/form/samples/skips-dead-branches-c/_expected/umd.js +++ b/test/form/samples/skips-dead-branches-c/_expected/umd.js @@ -1,11 +1,11 @@ (function (factory) { typeof define === 'function' && define.amd ? define(factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; function bar () { console.log( 'this should be included' ); } bar(); -}))); +})); diff --git a/test/form/samples/skips-dead-branches-d/_config.js b/test/form/samples/skips-dead-branches-d/_config.js index 97791399bf1..e3822d75329 100644 --- a/test/form/samples/skips-dead-branches-d/_config.js +++ b/test/form/samples/skips-dead-branches-d/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'skips a dead branch (d)' -}; +}); diff --git a/test/form/samples/skips-dead-branches-d/_expected/amd.js b/test/form/samples/skips-dead-branches-d/_expected/amd.js index ee0987c254d..0db41c4cd0b 100644 --- a/test/form/samples/skips-dead-branches-d/_expected/amd.js +++ b/test/form/samples/skips-dead-branches-d/_expected/amd.js @@ -1,8 +1,8 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; function bar () { console.log( 'this should be included' ); } bar(); -}); +})); diff --git a/test/form/samples/skips-dead-branches-d/_expected/iife.js b/test/form/samples/skips-dead-branches-d/_expected/iife.js index fe8653ab50d..3aeff6ca0e3 100644 --- a/test/form/samples/skips-dead-branches-d/_expected/iife.js +++ b/test/form/samples/skips-dead-branches-d/_expected/iife.js @@ -6,4 +6,4 @@ } bar(); -}()); +})(); diff --git a/test/form/samples/skips-dead-branches-d/_expected/system.js b/test/form/samples/skips-dead-branches-d/_expected/system.js index add436161ef..07b082ad15d 100644 --- a/test/form/samples/skips-dead-branches-d/_expected/system.js +++ b/test/form/samples/skips-dead-branches-d/_expected/system.js @@ -1,13 +1,13 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { function bar () { console.log( 'this should be included' ); } bar(); - } + }) }; -}); +})); diff --git a/test/form/samples/skips-dead-branches-d/_expected/umd.js b/test/form/samples/skips-dead-branches-d/_expected/umd.js index 0d014e6e523..de161b3248b 100644 --- a/test/form/samples/skips-dead-branches-d/_expected/umd.js +++ b/test/form/samples/skips-dead-branches-d/_expected/umd.js @@ -1,11 +1,11 @@ (function (factory) { typeof define === 'function' && define.amd ? define(factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; function bar () { console.log( 'this should be included' ); } bar(); -}))); +})); diff --git a/test/form/samples/skips-dead-branches-e/_config.js b/test/form/samples/skips-dead-branches-e/_config.js index d290c80e60d..16d5c13d318 100644 --- a/test/form/samples/skips-dead-branches-e/_config.js +++ b/test/form/samples/skips-dead-branches-e/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'skips a dead branch (e)' -}; +}); diff --git a/test/form/samples/skips-dead-branches-e/_expected/amd.js b/test/form/samples/skips-dead-branches-e/_expected/amd.js index ee0987c254d..0db41c4cd0b 100644 --- a/test/form/samples/skips-dead-branches-e/_expected/amd.js +++ b/test/form/samples/skips-dead-branches-e/_expected/amd.js @@ -1,8 +1,8 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; function bar () { console.log( 'this should be included' ); } bar(); -}); +})); diff --git a/test/form/samples/skips-dead-branches-e/_expected/iife.js b/test/form/samples/skips-dead-branches-e/_expected/iife.js index fe8653ab50d..3aeff6ca0e3 100644 --- a/test/form/samples/skips-dead-branches-e/_expected/iife.js +++ b/test/form/samples/skips-dead-branches-e/_expected/iife.js @@ -6,4 +6,4 @@ } bar(); -}()); +})(); diff --git a/test/form/samples/skips-dead-branches-e/_expected/system.js b/test/form/samples/skips-dead-branches-e/_expected/system.js index add436161ef..07b082ad15d 100644 --- a/test/form/samples/skips-dead-branches-e/_expected/system.js +++ b/test/form/samples/skips-dead-branches-e/_expected/system.js @@ -1,13 +1,13 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { function bar () { console.log( 'this should be included' ); } bar(); - } + }) }; -}); +})); diff --git a/test/form/samples/skips-dead-branches-e/_expected/umd.js b/test/form/samples/skips-dead-branches-e/_expected/umd.js index 0d014e6e523..de161b3248b 100644 --- a/test/form/samples/skips-dead-branches-e/_expected/umd.js +++ b/test/form/samples/skips-dead-branches-e/_expected/umd.js @@ -1,11 +1,11 @@ (function (factory) { typeof define === 'function' && define.amd ? define(factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; function bar () { console.log( 'this should be included' ); } bar(); -}))); +})); diff --git a/test/form/samples/skips-dead-branches-f/_config.js b/test/form/samples/skips-dead-branches-f/_config.js index 9ac1d2340bf..dfecee64639 100644 --- a/test/form/samples/skips-dead-branches-f/_config.js +++ b/test/form/samples/skips-dead-branches-f/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'skips a dead branch (f)' -}; +}); diff --git a/test/form/samples/skips-dead-branches-f/_expected/amd.js b/test/form/samples/skips-dead-branches-f/_expected/amd.js index ee0987c254d..0db41c4cd0b 100644 --- a/test/form/samples/skips-dead-branches-f/_expected/amd.js +++ b/test/form/samples/skips-dead-branches-f/_expected/amd.js @@ -1,8 +1,8 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; function bar () { console.log( 'this should be included' ); } bar(); -}); +})); diff --git a/test/form/samples/skips-dead-branches-f/_expected/iife.js b/test/form/samples/skips-dead-branches-f/_expected/iife.js index fe8653ab50d..3aeff6ca0e3 100644 --- a/test/form/samples/skips-dead-branches-f/_expected/iife.js +++ b/test/form/samples/skips-dead-branches-f/_expected/iife.js @@ -6,4 +6,4 @@ } bar(); -}()); +})(); diff --git a/test/form/samples/skips-dead-branches-f/_expected/system.js b/test/form/samples/skips-dead-branches-f/_expected/system.js index add436161ef..07b082ad15d 100644 --- a/test/form/samples/skips-dead-branches-f/_expected/system.js +++ b/test/form/samples/skips-dead-branches-f/_expected/system.js @@ -1,13 +1,13 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { function bar () { console.log( 'this should be included' ); } bar(); - } + }) }; -}); +})); diff --git a/test/form/samples/skips-dead-branches-f/_expected/umd.js b/test/form/samples/skips-dead-branches-f/_expected/umd.js index 0d014e6e523..de161b3248b 100644 --- a/test/form/samples/skips-dead-branches-f/_expected/umd.js +++ b/test/form/samples/skips-dead-branches-f/_expected/umd.js @@ -1,11 +1,11 @@ (function (factory) { typeof define === 'function' && define.amd ? define(factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; function bar () { console.log( 'this should be included' ); } bar(); -}))); +})); diff --git a/test/form/samples/skips-dead-branches-g/_config.js b/test/form/samples/skips-dead-branches-g/_config.js index f592e056c93..5b007e4d08f 100644 --- a/test/form/samples/skips-dead-branches-g/_config.js +++ b/test/form/samples/skips-dead-branches-g/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'skips a dead conditional expression branch (g)' -}; +}); diff --git a/test/form/samples/skips-dead-branches-g/_expected/amd.js b/test/form/samples/skips-dead-branches-g/_expected/amd.js index 463cee0be03..7a8acfa9de1 100644 --- a/test/form/samples/skips-dead-branches-g/_expected/amd.js +++ b/test/form/samples/skips-dead-branches-g/_expected/amd.js @@ -1,4 +1,4 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; var a = 0; var b = 1; @@ -8,4 +8,4 @@ define(function () { 'use strict'; console.log( x + y ); -}); +})); diff --git a/test/form/samples/skips-dead-branches-g/_expected/iife.js b/test/form/samples/skips-dead-branches-g/_expected/iife.js index c5763647b5c..16813c0d073 100644 --- a/test/form/samples/skips-dead-branches-g/_expected/iife.js +++ b/test/form/samples/skips-dead-branches-g/_expected/iife.js @@ -9,4 +9,4 @@ console.log( x + y ); -}()); +})(); diff --git a/test/form/samples/skips-dead-branches-g/_expected/system.js b/test/form/samples/skips-dead-branches-g/_expected/system.js index 680a2b3c9c0..058775e1758 100644 --- a/test/form/samples/skips-dead-branches-g/_expected/system.js +++ b/test/form/samples/skips-dead-branches-g/_expected/system.js @@ -1,7 +1,7 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { var a = 0; var b = 1; @@ -11,6 +11,6 @@ System.register([], function () { console.log( x + y ); - } + }) }; -}); +})); diff --git a/test/form/samples/skips-dead-branches-g/_expected/umd.js b/test/form/samples/skips-dead-branches-g/_expected/umd.js index 23e965b5297..5aa413b63e7 100644 --- a/test/form/samples/skips-dead-branches-g/_expected/umd.js +++ b/test/form/samples/skips-dead-branches-g/_expected/umd.js @@ -1,7 +1,7 @@ (function (factory) { typeof define === 'function' && define.amd ? define(factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; var a = 0; var b = 1; @@ -11,4 +11,4 @@ console.log( x + y ); -}))); +})); diff --git a/test/form/samples/skips-dead-branches-h/_config.js b/test/form/samples/skips-dead-branches-h/_config.js index 85e8fbe2647..2f4da370fec 100644 --- a/test/form/samples/skips-dead-branches-h/_config.js +++ b/test/form/samples/skips-dead-branches-h/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'skips a dead branch (h)' -}; +}); diff --git a/test/form/samples/skips-dead-branches-h/_expected/amd.js b/test/form/samples/skips-dead-branches-h/_expected/amd.js index 6847fcb332d..00c37c45f20 100644 --- a/test/form/samples/skips-dead-branches-h/_expected/amd.js +++ b/test/form/samples/skips-dead-branches-h/_expected/amd.js @@ -1,8 +1,8 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; function baz() { console.log("baz"); } baz(); -}); +})); diff --git a/test/form/samples/skips-dead-branches-h/_expected/iife.js b/test/form/samples/skips-dead-branches-h/_expected/iife.js index 88532fd9b9a..a59b9e71535 100644 --- a/test/form/samples/skips-dead-branches-h/_expected/iife.js +++ b/test/form/samples/skips-dead-branches-h/_expected/iife.js @@ -6,4 +6,4 @@ } baz(); -}()); +})(); diff --git a/test/form/samples/skips-dead-branches-h/_expected/system.js b/test/form/samples/skips-dead-branches-h/_expected/system.js index b77aee1930b..0f0b193d49b 100644 --- a/test/form/samples/skips-dead-branches-h/_expected/system.js +++ b/test/form/samples/skips-dead-branches-h/_expected/system.js @@ -1,13 +1,13 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { function baz() { console.log("baz"); } baz(); - } + }) }; -}); +})); diff --git a/test/form/samples/skips-dead-branches-h/_expected/umd.js b/test/form/samples/skips-dead-branches-h/_expected/umd.js index 7f38695c83f..c56026e3c03 100644 --- a/test/form/samples/skips-dead-branches-h/_expected/umd.js +++ b/test/form/samples/skips-dead-branches-h/_expected/umd.js @@ -1,11 +1,11 @@ (function (factory) { typeof define === 'function' && define.amd ? define(factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; function baz() { console.log("baz"); } baz(); -}))); +})); diff --git a/test/form/samples/skips-dead-branches-i/_config.js b/test/form/samples/skips-dead-branches-i/_config.js index 95aa9425141..5410783733c 100644 --- a/test/form/samples/skips-dead-branches-i/_config.js +++ b/test/form/samples/skips-dead-branches-i/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'skips a dead branch (i)' -}; +}); diff --git a/test/form/samples/skips-dead-branches-i/_expected/amd.js b/test/form/samples/skips-dead-branches-i/_expected/amd.js index 6847fcb332d..00c37c45f20 100644 --- a/test/form/samples/skips-dead-branches-i/_expected/amd.js +++ b/test/form/samples/skips-dead-branches-i/_expected/amd.js @@ -1,8 +1,8 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; function baz() { console.log("baz"); } baz(); -}); +})); diff --git a/test/form/samples/skips-dead-branches-i/_expected/iife.js b/test/form/samples/skips-dead-branches-i/_expected/iife.js index 88532fd9b9a..a59b9e71535 100644 --- a/test/form/samples/skips-dead-branches-i/_expected/iife.js +++ b/test/form/samples/skips-dead-branches-i/_expected/iife.js @@ -6,4 +6,4 @@ } baz(); -}()); +})(); diff --git a/test/form/samples/skips-dead-branches-i/_expected/system.js b/test/form/samples/skips-dead-branches-i/_expected/system.js index b77aee1930b..0f0b193d49b 100644 --- a/test/form/samples/skips-dead-branches-i/_expected/system.js +++ b/test/form/samples/skips-dead-branches-i/_expected/system.js @@ -1,13 +1,13 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { function baz() { console.log("baz"); } baz(); - } + }) }; -}); +})); diff --git a/test/form/samples/skips-dead-branches-i/_expected/umd.js b/test/form/samples/skips-dead-branches-i/_expected/umd.js index 7f38695c83f..c56026e3c03 100644 --- a/test/form/samples/skips-dead-branches-i/_expected/umd.js +++ b/test/form/samples/skips-dead-branches-i/_expected/umd.js @@ -1,11 +1,11 @@ (function (factory) { typeof define === 'function' && define.amd ? define(factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; function baz() { console.log("baz"); } baz(); -}))); +})); diff --git a/test/form/samples/skips-dead-branches-j/_config.js b/test/form/samples/skips-dead-branches-j/_config.js index b9abe109dfa..8fedcb35ab4 100644 --- a/test/form/samples/skips-dead-branches-j/_config.js +++ b/test/form/samples/skips-dead-branches-j/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'skips a dead branch (j)' -}; +}); diff --git a/test/form/samples/skips-dead-branches-j/_expected/amd.js b/test/form/samples/skips-dead-branches-j/_expected/amd.js index 9ee95895978..fa6285acced 100644 --- a/test/form/samples/skips-dead-branches-j/_expected/amd.js +++ b/test/form/samples/skips-dead-branches-j/_expected/amd.js @@ -1,7 +1,7 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; { console.log( 'true' ); } -}); +})); diff --git a/test/form/samples/skips-dead-branches-j/_expected/iife.js b/test/form/samples/skips-dead-branches-j/_expected/iife.js index c506520e1fe..926618c9eeb 100644 --- a/test/form/samples/skips-dead-branches-j/_expected/iife.js +++ b/test/form/samples/skips-dead-branches-j/_expected/iife.js @@ -5,4 +5,4 @@ console.log( 'true' ); } -}()); +})(); diff --git a/test/form/samples/skips-dead-branches-j/_expected/system.js b/test/form/samples/skips-dead-branches-j/_expected/system.js index 4385dfef9fd..574815f3abd 100644 --- a/test/form/samples/skips-dead-branches-j/_expected/system.js +++ b/test/form/samples/skips-dead-branches-j/_expected/system.js @@ -1,12 +1,12 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { { console.log( 'true' ); } - } + }) }; -}); +})); diff --git a/test/form/samples/skips-dead-branches-j/_expected/umd.js b/test/form/samples/skips-dead-branches-j/_expected/umd.js index 7a91a0f6ee4..70fb1b0913b 100644 --- a/test/form/samples/skips-dead-branches-j/_expected/umd.js +++ b/test/form/samples/skips-dead-branches-j/_expected/umd.js @@ -1,10 +1,10 @@ (function (factory) { typeof define === 'function' && define.amd ? define(factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; { console.log( 'true' ); } -}))); +})); diff --git a/test/form/samples/skips-dead-branches/_config.js b/test/form/samples/skips-dead-branches/_config.js index 078856d2ef6..a2697cd97a1 100644 --- a/test/form/samples/skips-dead-branches/_config.js +++ b/test/form/samples/skips-dead-branches/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'skips a dead branch' -}; +}); diff --git a/test/form/samples/skips-dead-branches/_expected/es.js b/test/form/samples/skips-dead-branches/_expected.js similarity index 100% rename from test/form/samples/skips-dead-branches/_expected/es.js rename to test/form/samples/skips-dead-branches/_expected.js diff --git a/test/form/samples/skips-dead-branches/_expected/amd.js b/test/form/samples/skips-dead-branches/_expected/amd.js deleted file mode 100644 index c192900373e..00000000000 --- a/test/form/samples/skips-dead-branches/_expected/amd.js +++ /dev/null @@ -1,9 +0,0 @@ -define(function () { 'use strict'; - - function bar () { - console.log( 'this should be included' ); - } - - bar(); - -}); diff --git a/test/form/samples/skips-dead-branches/_expected/cjs.js b/test/form/samples/skips-dead-branches/_expected/cjs.js deleted file mode 100644 index b3e974bb4e6..00000000000 --- a/test/form/samples/skips-dead-branches/_expected/cjs.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -function bar () { - console.log( 'this should be included' ); -} - -bar(); diff --git a/test/form/samples/skips-dead-branches/_expected/iife.js b/test/form/samples/skips-dead-branches/_expected/iife.js deleted file mode 100644 index 3b894d92a46..00000000000 --- a/test/form/samples/skips-dead-branches/_expected/iife.js +++ /dev/null @@ -1,10 +0,0 @@ -(function () { - 'use strict'; - - function bar () { - console.log( 'this should be included' ); - } - - bar(); - -}()); diff --git a/test/form/samples/skips-dead-branches/_expected/system.js b/test/form/samples/skips-dead-branches/_expected/system.js deleted file mode 100644 index 606d00fb15e..00000000000 --- a/test/form/samples/skips-dead-branches/_expected/system.js +++ /dev/null @@ -1,14 +0,0 @@ -System.register([], function () { - 'use strict'; - return { - execute: function () { - - function bar () { - console.log( 'this should be included' ); - } - - bar(); - - } - }; -}); diff --git a/test/form/samples/skips-dead-branches/_expected/umd.js b/test/form/samples/skips-dead-branches/_expected/umd.js deleted file mode 100644 index 06df11106d6..00000000000 --- a/test/form/samples/skips-dead-branches/_expected/umd.js +++ /dev/null @@ -1,12 +0,0 @@ -(function (factory) { - typeof define === 'function' && define.amd ? define(factory) : - factory(); -}((function () { 'use strict'; - - function bar () { - console.log( 'this should be included' ); - } - - bar(); - -}))); diff --git a/test/form/samples/slash-in-function-parameters/_config.js b/test/form/samples/slash-in-function-parameters/_config.js index b4865638777..c4a5a575702 100644 --- a/test/form/samples/slash-in-function-parameters/_config.js +++ b/test/form/samples/slash-in-function-parameters/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'handles slashes in function parameters and correctly inserts missing ids' -}; +}); diff --git a/test/form/samples/slash-in-function-parameters/_expected/amd.js b/test/form/samples/slash-in-function-parameters/_expected/amd.js index 31fc3e2550a..645edb113cb 100644 --- a/test/form/samples/slash-in-function-parameters/_expected/amd.js +++ b/test/form/samples/slash-in-function-parameters/_expected/amd.js @@ -1,4 +1,4 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; class someClass {} @@ -6,4 +6,4 @@ define(function () { 'use strict'; console.log(someClass, someFunction); -}); +})); diff --git a/test/form/samples/slash-in-function-parameters/_expected/iife.js b/test/form/samples/slash-in-function-parameters/_expected/iife.js index 4e673f658e4..001447efc1b 100644 --- a/test/form/samples/slash-in-function-parameters/_expected/iife.js +++ b/test/form/samples/slash-in-function-parameters/_expected/iife.js @@ -7,4 +7,4 @@ console.log(someClass, someFunction); -}()); +})(); diff --git a/test/form/samples/slash-in-function-parameters/_expected/system.js b/test/form/samples/slash-in-function-parameters/_expected/system.js index 1c611a50fb7..ad1bb2ba30b 100644 --- a/test/form/samples/slash-in-function-parameters/_expected/system.js +++ b/test/form/samples/slash-in-function-parameters/_expected/system.js @@ -1,7 +1,7 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { class someClass {} @@ -9,6 +9,6 @@ System.register([], function () { console.log(someClass, someFunction); - } + }) }; -}); +})); diff --git a/test/form/samples/slash-in-function-parameters/_expected/umd.js b/test/form/samples/slash-in-function-parameters/_expected/umd.js index 2d20f9f4461..ae534f7d874 100644 --- a/test/form/samples/slash-in-function-parameters/_expected/umd.js +++ b/test/form/samples/slash-in-function-parameters/_expected/umd.js @@ -1,7 +1,7 @@ (function (factory) { typeof define === 'function' && define.amd ? define(factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; class someClass {} @@ -9,4 +9,4 @@ console.log(someClass, someFunction); -}))); +})); diff --git a/test/form/samples/sourcemaps-excludesources/_config.js b/test/form/samples/sourcemaps-excludesources/_config.js index 491a8fe6f95..fdfa88e6128 100644 --- a/test/form/samples/sourcemaps-excludesources/_config.js +++ b/test/form/samples/sourcemaps-excludesources/_config.js @@ -1,7 +1,7 @@ -module.exports = { +module.exports = defineTest({ description: 'correct sourcemaps are written (excluding sourceContent)', skipIfWindows: true, options: { output: { sourcemap: true, sourcemapExcludeSources: true } } -}; +}); diff --git a/test/form/samples/sourcemaps-excludesources/_expected/amd.js b/test/form/samples/sourcemaps-excludesources/_expected/amd.js index e142f3ab9fe..4a57bb0a1d7 100644 --- a/test/form/samples/sourcemaps-excludesources/_expected/amd.js +++ b/test/form/samples/sourcemaps-excludesources/_expected/amd.js @@ -1,4 +1,4 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; function foo () { console.log( 'hello from foo.js' ); @@ -13,5 +13,5 @@ define(function () { 'use strict'; foo(); bar(); -}); +})); //# sourceMappingURL=amd.js.map diff --git a/test/form/samples/sourcemaps-excludesources/_expected/amd.js.map b/test/form/samples/sourcemaps-excludesources/_expected/amd.js.map index 82d62c89122..5ae68106356 100644 --- a/test/form/samples/sourcemaps-excludesources/_expected/amd.js.map +++ b/test/form/samples/sourcemaps-excludesources/_expected/amd.js.map @@ -1 +1 @@ -{"version":3,"file":"amd.js","sources":["../foo.js","../bar.js","../main.js"],"sourcesContent":null,"names":[],"mappings":";;CAAe,SAAS,GAAG,IAAI;CAC/B,CAAC,OAAO,CAAC,GAAG,EAAE,mBAAmB,EAAE,CAAC;CACpC;;CCFe,SAAS,GAAG,IAAI;CAC/B,CAAC,OAAO,CAAC,GAAG,EAAE,mBAAmB,EAAE,CAAC;CACpC;;CCCA,OAAO,CAAC,GAAG,EAAE,oBAAoB,EAAE,CAAC;AACpC;CACA,GAAG,EAAE,CAAC;CACN,GAAG,EAAE;;;;;;"} \ No newline at end of file +{"version":3,"file":"amd.js","sources":["../foo.js","../bar.js","../main.js"],"names":[],"mappings":";;CAAe,SAAS,GAAG,IAAI;CAC/B,CAAC,OAAO,CAAC,GAAG,EAAE,mBAAmB,EAAE;CACnC;;CCFe,SAAS,GAAG,IAAI;CAC/B,CAAC,OAAO,CAAC,GAAG,EAAE,mBAAmB,EAAE;CACnC;;CCCA,OAAO,CAAC,GAAG,EAAE,oBAAoB,EAAE;;CAEnC,GAAG,EAAE;CACL,GAAG,EAAE;;;;;;"} \ No newline at end of file diff --git a/test/form/samples/sourcemaps-excludesources/_expected/cjs.js.map b/test/form/samples/sourcemaps-excludesources/_expected/cjs.js.map index 422019657b4..1a253120d79 100644 --- a/test/form/samples/sourcemaps-excludesources/_expected/cjs.js.map +++ b/test/form/samples/sourcemaps-excludesources/_expected/cjs.js.map @@ -1 +1 @@ -{"version":3,"file":"cjs.js","sources":["../foo.js","../bar.js","../main.js"],"sourcesContent":null,"names":[],"mappings":";;AAAe,SAAS,GAAG,IAAI;AAC/B,CAAC,OAAO,CAAC,GAAG,EAAE,mBAAmB,EAAE,CAAC;AACpC;;ACFe,SAAS,GAAG,IAAI;AAC/B,CAAC,OAAO,CAAC,GAAG,EAAE,mBAAmB,EAAE,CAAC;AACpC;;ACCA,OAAO,CAAC,GAAG,EAAE,oBAAoB,EAAE,CAAC;AACpC;AACA,GAAG,EAAE,CAAC;AACN,GAAG,EAAE;;"} \ No newline at end of file +{"version":3,"file":"cjs.js","sources":["../foo.js","../bar.js","../main.js"],"names":[],"mappings":";;AAAe,SAAS,GAAG,IAAI;AAC/B,CAAC,OAAO,CAAC,GAAG,EAAE,mBAAmB,EAAE;AACnC;;ACFe,SAAS,GAAG,IAAI;AAC/B,CAAC,OAAO,CAAC,GAAG,EAAE,mBAAmB,EAAE;AACnC;;ACCA,OAAO,CAAC,GAAG,EAAE,oBAAoB,EAAE;;AAEnC,GAAG,EAAE;AACL,GAAG,EAAE;;"} \ No newline at end of file diff --git a/test/form/samples/sourcemaps-excludesources/_expected/es.js.map b/test/form/samples/sourcemaps-excludesources/_expected/es.js.map index 03f955ea1be..9caa6997098 100644 --- a/test/form/samples/sourcemaps-excludesources/_expected/es.js.map +++ b/test/form/samples/sourcemaps-excludesources/_expected/es.js.map @@ -1 +1 @@ -{"version":3,"file":"es.js","sources":["../foo.js","../bar.js","../main.js"],"sourcesContent":null,"names":[],"mappings":"AAAe,SAAS,GAAG,IAAI;AAC/B,CAAC,OAAO,CAAC,GAAG,EAAE,mBAAmB,EAAE,CAAC;AACpC;;ACFe,SAAS,GAAG,IAAI;AAC/B,CAAC,OAAO,CAAC,GAAG,EAAE,mBAAmB,EAAE,CAAC;AACpC;;ACCA,OAAO,CAAC,GAAG,EAAE,oBAAoB,EAAE,CAAC;AACpC;AACA,GAAG,EAAE,CAAC;AACN,GAAG,EAAE"} \ No newline at end of file +{"version":3,"file":"es.js","sources":["../foo.js","../bar.js","../main.js"],"names":[],"mappings":"AAAe,SAAS,GAAG,IAAI;AAC/B,CAAC,OAAO,CAAC,GAAG,EAAE,mBAAmB,EAAE;AACnC;;ACFe,SAAS,GAAG,IAAI;AAC/B,CAAC,OAAO,CAAC,GAAG,EAAE,mBAAmB,EAAE;AACnC;;ACCA,OAAO,CAAC,GAAG,EAAE,oBAAoB,EAAE;;AAEnC,GAAG,EAAE;AACL,GAAG,EAAE"} \ No newline at end of file diff --git a/test/form/samples/sourcemaps-excludesources/_expected/iife.js b/test/form/samples/sourcemaps-excludesources/_expected/iife.js index 9d10bae7f14..26d1b3ca3c3 100644 --- a/test/form/samples/sourcemaps-excludesources/_expected/iife.js +++ b/test/form/samples/sourcemaps-excludesources/_expected/iife.js @@ -14,5 +14,5 @@ foo(); bar(); -}()); +})(); //# sourceMappingURL=iife.js.map diff --git a/test/form/samples/sourcemaps-excludesources/_expected/iife.js.map b/test/form/samples/sourcemaps-excludesources/_expected/iife.js.map index b6927b8dd04..e6ec51b80cd 100644 --- a/test/form/samples/sourcemaps-excludesources/_expected/iife.js.map +++ b/test/form/samples/sourcemaps-excludesources/_expected/iife.js.map @@ -1 +1 @@ -{"version":3,"file":"iife.js","sources":["../foo.js","../bar.js","../main.js"],"sourcesContent":null,"names":[],"mappings":";;;CAAe,SAAS,GAAG,IAAI;CAC/B,CAAC,OAAO,CAAC,GAAG,EAAE,mBAAmB,EAAE,CAAC;CACpC;;CCFe,SAAS,GAAG,IAAI;CAC/B,CAAC,OAAO,CAAC,GAAG,EAAE,mBAAmB,EAAE,CAAC;CACpC;;CCCA,OAAO,CAAC,GAAG,EAAE,oBAAoB,EAAE,CAAC;AACpC;CACA,GAAG,EAAE,CAAC;CACN,GAAG,EAAE;;;;;;"} \ No newline at end of file +{"version":3,"file":"iife.js","sources":["../foo.js","../bar.js","../main.js"],"names":[],"mappings":";;;CAAe,SAAS,GAAG,IAAI;CAC/B,CAAC,OAAO,CAAC,GAAG,EAAE,mBAAmB,EAAE;CACnC;;CCFe,SAAS,GAAG,IAAI;CAC/B,CAAC,OAAO,CAAC,GAAG,EAAE,mBAAmB,EAAE;CACnC;;CCCA,OAAO,CAAC,GAAG,EAAE,oBAAoB,EAAE;;CAEnC,GAAG,EAAE;CACL,GAAG,EAAE;;;;;;"} \ No newline at end of file diff --git a/test/form/samples/sourcemaps-excludesources/_expected/system.js b/test/form/samples/sourcemaps-excludesources/_expected/system.js index 0e5a1020f81..0d0d48d6acd 100644 --- a/test/form/samples/sourcemaps-excludesources/_expected/system.js +++ b/test/form/samples/sourcemaps-excludesources/_expected/system.js @@ -1,7 +1,7 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { function foo () { console.log( 'hello from foo.js' ); @@ -16,7 +16,7 @@ System.register([], function () { foo(); bar(); - } + }) }; -}); +})); //# sourceMappingURL=system.js.map diff --git a/test/form/samples/sourcemaps-excludesources/_expected/system.js.map b/test/form/samples/sourcemaps-excludesources/_expected/system.js.map index 71d46619b05..5ac4e1b115a 100644 --- a/test/form/samples/sourcemaps-excludesources/_expected/system.js.map +++ b/test/form/samples/sourcemaps-excludesources/_expected/system.js.map @@ -1 +1 @@ -{"version":3,"file":"system.js","sources":["../foo.js","../bar.js","../main.js"],"sourcesContent":null,"names":[],"mappings":";;;;;GAAe,SAAS,GAAG,IAAI;GAC/B,CAAC,OAAO,CAAC,GAAG,EAAE,mBAAmB,EAAE,CAAC;GACpC;;GCFe,SAAS,GAAG,IAAI;GAC/B,CAAC,OAAO,CAAC,GAAG,EAAE,mBAAmB,EAAE,CAAC;GACpC;;GCCA,OAAO,CAAC,GAAG,EAAE,oBAAoB,EAAE,CAAC;AACpC;GACA,GAAG,EAAE,CAAC;GACN,GAAG,EAAE;;;;;;"} \ No newline at end of file +{"version":3,"file":"system.js","sources":["../foo.js","../bar.js","../main.js"],"names":[],"mappings":";;;;;GAAe,SAAS,GAAG,IAAI;GAC/B,CAAC,OAAO,CAAC,GAAG,EAAE,mBAAmB,EAAE;GACnC;;GCFe,SAAS,GAAG,IAAI;GAC/B,CAAC,OAAO,CAAC,GAAG,EAAE,mBAAmB,EAAE;GACnC;;GCCA,OAAO,CAAC,GAAG,EAAE,oBAAoB,EAAE;;GAEnC,GAAG,EAAE;GACL,GAAG,EAAE;;;;;;;;"} \ No newline at end of file diff --git a/test/form/samples/sourcemaps-excludesources/_expected/umd.js b/test/form/samples/sourcemaps-excludesources/_expected/umd.js index 4e06d25f444..e83feed7206 100644 --- a/test/form/samples/sourcemaps-excludesources/_expected/umd.js +++ b/test/form/samples/sourcemaps-excludesources/_expected/umd.js @@ -1,7 +1,7 @@ (function (factory) { typeof define === 'function' && define.amd ? define(factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; function foo () { console.log( 'hello from foo.js' ); @@ -16,5 +16,5 @@ foo(); bar(); -}))); +})); //# sourceMappingURL=umd.js.map diff --git a/test/form/samples/sourcemaps-excludesources/_expected/umd.js.map b/test/form/samples/sourcemaps-excludesources/_expected/umd.js.map index d501410fe74..233db12bd7e 100644 --- a/test/form/samples/sourcemaps-excludesources/_expected/umd.js.map +++ b/test/form/samples/sourcemaps-excludesources/_expected/umd.js.map @@ -1 +1 @@ -{"version":3,"file":"umd.js","sources":["../foo.js","../bar.js","../main.js"],"sourcesContent":null,"names":[],"mappings":";;;;;CAAe,SAAS,GAAG,IAAI;CAC/B,CAAC,OAAO,CAAC,GAAG,EAAE,mBAAmB,EAAE,CAAC;CACpC;;CCFe,SAAS,GAAG,IAAI;CAC/B,CAAC,OAAO,CAAC,GAAG,EAAE,mBAAmB,EAAE,CAAC;CACpC;;CCCA,OAAO,CAAC,GAAG,EAAE,oBAAoB,EAAE,CAAC;AACpC;CACA,GAAG,EAAE,CAAC;CACN,GAAG,EAAE;;;;;;"} \ No newline at end of file +{"version":3,"file":"umd.js","sources":["../foo.js","../bar.js","../main.js"],"names":[],"mappings":";;;;;CAAe,SAAS,GAAG,IAAI;CAC/B,CAAC,OAAO,CAAC,GAAG,EAAE,mBAAmB,EAAE;CACnC;;CCFe,SAAS,GAAG,IAAI;CAC/B,CAAC,OAAO,CAAC,GAAG,EAAE,mBAAmB,EAAE;CACnC;;CCCA,OAAO,CAAC,GAAG,EAAE,oBAAoB,EAAE;;CAEnC,GAAG,EAAE;CACL,GAAG,EAAE;;;;;;"} \ No newline at end of file diff --git a/test/form/samples/sourcemaps-external/_config.js b/test/form/samples/sourcemaps-external/_config.js index 12501b32b43..d597d1ab64d 100644 --- a/test/form/samples/sourcemaps-external/_config.js +++ b/test/form/samples/sourcemaps-external/_config.js @@ -1,7 +1,7 @@ -module.exports = { +module.exports = defineTest({ description: 'correct sourcemaps are written (separate file)', skipIfWindows: true, options: { output: { sourcemap: true } } -}; +}); diff --git a/test/form/samples/sourcemaps-external/_expected/amd.js b/test/form/samples/sourcemaps-external/_expected/amd.js index e142f3ab9fe..4a57bb0a1d7 100644 --- a/test/form/samples/sourcemaps-external/_expected/amd.js +++ b/test/form/samples/sourcemaps-external/_expected/amd.js @@ -1,4 +1,4 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; function foo () { console.log( 'hello from foo.js' ); @@ -13,5 +13,5 @@ define(function () { 'use strict'; foo(); bar(); -}); +})); //# sourceMappingURL=amd.js.map diff --git a/test/form/samples/sourcemaps-external/_expected/amd.js.map b/test/form/samples/sourcemaps-external/_expected/amd.js.map index a648595809d..cfcc290b4bf 100644 --- a/test/form/samples/sourcemaps-external/_expected/amd.js.map +++ b/test/form/samples/sourcemaps-external/_expected/amd.js.map @@ -1 +1 @@ -{"version":3,"file":"amd.js","sources":["../foo.js","../bar.js","../main.js"],"sourcesContent":["export default function foo () {\n\tconsole.log( 'hello from foo.js' );\n}\n","export default function bar () {\n\tconsole.log( 'hello from bar.js' );\n}\n","import foo from './foo';\nimport bar from './bar';\n\nconsole.log( 'hello from main.js' );\n\nfoo();\nbar();\n"],"names":[],"mappings":";;CAAe,SAAS,GAAG,IAAI;CAC/B,CAAC,OAAO,CAAC,GAAG,EAAE,mBAAmB,EAAE,CAAC;CACpC;;CCFe,SAAS,GAAG,IAAI;CAC/B,CAAC,OAAO,CAAC,GAAG,EAAE,mBAAmB,EAAE,CAAC;CACpC;;CCCA,OAAO,CAAC,GAAG,EAAE,oBAAoB,EAAE,CAAC;AACpC;CACA,GAAG,EAAE,CAAC;CACN,GAAG,EAAE;;;;;;"} \ No newline at end of file +{"version":3,"file":"amd.js","sources":["../foo.js","../bar.js","../main.js"],"sourcesContent":["export default function foo () {\n\tconsole.log( 'hello from foo.js' );\n}\n","export default function bar () {\n\tconsole.log( 'hello from bar.js' );\n}\n","import foo from './foo';\nimport bar from './bar';\n\nconsole.log( 'hello from main.js' );\n\nfoo();\nbar();\n"],"names":[],"mappings":";;CAAe,SAAS,GAAG,IAAI;CAC/B,CAAC,OAAO,CAAC,GAAG,EAAE,mBAAmB,EAAE;CACnC;;CCFe,SAAS,GAAG,IAAI;CAC/B,CAAC,OAAO,CAAC,GAAG,EAAE,mBAAmB,EAAE;CACnC;;CCCA,OAAO,CAAC,GAAG,EAAE,oBAAoB,EAAE;;CAEnC,GAAG,EAAE;CACL,GAAG,EAAE;;;;;;"} \ No newline at end of file diff --git a/test/form/samples/sourcemaps-external/_expected/cjs.js.map b/test/form/samples/sourcemaps-external/_expected/cjs.js.map index 823ebc157dd..cae3342ee58 100644 --- a/test/form/samples/sourcemaps-external/_expected/cjs.js.map +++ b/test/form/samples/sourcemaps-external/_expected/cjs.js.map @@ -1 +1 @@ -{"version":3,"file":"cjs.js","sources":["../foo.js","../bar.js","../main.js"],"sourcesContent":["export default function foo () {\n\tconsole.log( 'hello from foo.js' );\n}\n","export default function bar () {\n\tconsole.log( 'hello from bar.js' );\n}\n","import foo from './foo';\nimport bar from './bar';\n\nconsole.log( 'hello from main.js' );\n\nfoo();\nbar();\n"],"names":[],"mappings":";;AAAe,SAAS,GAAG,IAAI;AAC/B,CAAC,OAAO,CAAC,GAAG,EAAE,mBAAmB,EAAE,CAAC;AACpC;;ACFe,SAAS,GAAG,IAAI;AAC/B,CAAC,OAAO,CAAC,GAAG,EAAE,mBAAmB,EAAE,CAAC;AACpC;;ACCA,OAAO,CAAC,GAAG,EAAE,oBAAoB,EAAE,CAAC;AACpC;AACA,GAAG,EAAE,CAAC;AACN,GAAG,EAAE;;"} \ No newline at end of file +{"version":3,"file":"cjs.js","sources":["../foo.js","../bar.js","../main.js"],"sourcesContent":["export default function foo () {\n\tconsole.log( 'hello from foo.js' );\n}\n","export default function bar () {\n\tconsole.log( 'hello from bar.js' );\n}\n","import foo from './foo';\nimport bar from './bar';\n\nconsole.log( 'hello from main.js' );\n\nfoo();\nbar();\n"],"names":[],"mappings":";;AAAe,SAAS,GAAG,IAAI;AAC/B,CAAC,OAAO,CAAC,GAAG,EAAE,mBAAmB,EAAE;AACnC;;ACFe,SAAS,GAAG,IAAI;AAC/B,CAAC,OAAO,CAAC,GAAG,EAAE,mBAAmB,EAAE;AACnC;;ACCA,OAAO,CAAC,GAAG,EAAE,oBAAoB,EAAE;;AAEnC,GAAG,EAAE;AACL,GAAG,EAAE;;"} \ No newline at end of file diff --git a/test/form/samples/sourcemaps-external/_expected/es.js.map b/test/form/samples/sourcemaps-external/_expected/es.js.map index 25b559ccdc6..eeced40c569 100644 --- a/test/form/samples/sourcemaps-external/_expected/es.js.map +++ b/test/form/samples/sourcemaps-external/_expected/es.js.map @@ -1 +1 @@ -{"version":3,"file":"es.js","sources":["../foo.js","../bar.js","../main.js"],"sourcesContent":["export default function foo () {\n\tconsole.log( 'hello from foo.js' );\n}\n","export default function bar () {\n\tconsole.log( 'hello from bar.js' );\n}\n","import foo from './foo';\nimport bar from './bar';\n\nconsole.log( 'hello from main.js' );\n\nfoo();\nbar();\n"],"names":[],"mappings":"AAAe,SAAS,GAAG,IAAI;AAC/B,CAAC,OAAO,CAAC,GAAG,EAAE,mBAAmB,EAAE,CAAC;AACpC;;ACFe,SAAS,GAAG,IAAI;AAC/B,CAAC,OAAO,CAAC,GAAG,EAAE,mBAAmB,EAAE,CAAC;AACpC;;ACCA,OAAO,CAAC,GAAG,EAAE,oBAAoB,EAAE,CAAC;AACpC;AACA,GAAG,EAAE,CAAC;AACN,GAAG,EAAE"} \ No newline at end of file +{"version":3,"file":"es.js","sources":["../foo.js","../bar.js","../main.js"],"sourcesContent":["export default function foo () {\n\tconsole.log( 'hello from foo.js' );\n}\n","export default function bar () {\n\tconsole.log( 'hello from bar.js' );\n}\n","import foo from './foo';\nimport bar from './bar';\n\nconsole.log( 'hello from main.js' );\n\nfoo();\nbar();\n"],"names":[],"mappings":"AAAe,SAAS,GAAG,IAAI;AAC/B,CAAC,OAAO,CAAC,GAAG,EAAE,mBAAmB,EAAE;AACnC;;ACFe,SAAS,GAAG,IAAI;AAC/B,CAAC,OAAO,CAAC,GAAG,EAAE,mBAAmB,EAAE;AACnC;;ACCA,OAAO,CAAC,GAAG,EAAE,oBAAoB,EAAE;;AAEnC,GAAG,EAAE;AACL,GAAG,EAAE"} \ No newline at end of file diff --git a/test/form/samples/sourcemaps-external/_expected/iife.js b/test/form/samples/sourcemaps-external/_expected/iife.js index 9d10bae7f14..26d1b3ca3c3 100644 --- a/test/form/samples/sourcemaps-external/_expected/iife.js +++ b/test/form/samples/sourcemaps-external/_expected/iife.js @@ -14,5 +14,5 @@ foo(); bar(); -}()); +})(); //# sourceMappingURL=iife.js.map diff --git a/test/form/samples/sourcemaps-external/_expected/iife.js.map b/test/form/samples/sourcemaps-external/_expected/iife.js.map index b4e5e2e642c..e1286283248 100644 --- a/test/form/samples/sourcemaps-external/_expected/iife.js.map +++ b/test/form/samples/sourcemaps-external/_expected/iife.js.map @@ -1 +1 @@ -{"version":3,"file":"iife.js","sources":["../foo.js","../bar.js","../main.js"],"sourcesContent":["export default function foo () {\n\tconsole.log( 'hello from foo.js' );\n}\n","export default function bar () {\n\tconsole.log( 'hello from bar.js' );\n}\n","import foo from './foo';\nimport bar from './bar';\n\nconsole.log( 'hello from main.js' );\n\nfoo();\nbar();\n"],"names":[],"mappings":";;;CAAe,SAAS,GAAG,IAAI;CAC/B,CAAC,OAAO,CAAC,GAAG,EAAE,mBAAmB,EAAE,CAAC;CACpC;;CCFe,SAAS,GAAG,IAAI;CAC/B,CAAC,OAAO,CAAC,GAAG,EAAE,mBAAmB,EAAE,CAAC;CACpC;;CCCA,OAAO,CAAC,GAAG,EAAE,oBAAoB,EAAE,CAAC;AACpC;CACA,GAAG,EAAE,CAAC;CACN,GAAG,EAAE;;;;;;"} \ No newline at end of file +{"version":3,"file":"iife.js","sources":["../foo.js","../bar.js","../main.js"],"sourcesContent":["export default function foo () {\n\tconsole.log( 'hello from foo.js' );\n}\n","export default function bar () {\n\tconsole.log( 'hello from bar.js' );\n}\n","import foo from './foo';\nimport bar from './bar';\n\nconsole.log( 'hello from main.js' );\n\nfoo();\nbar();\n"],"names":[],"mappings":";;;CAAe,SAAS,GAAG,IAAI;CAC/B,CAAC,OAAO,CAAC,GAAG,EAAE,mBAAmB,EAAE;CACnC;;CCFe,SAAS,GAAG,IAAI;CAC/B,CAAC,OAAO,CAAC,GAAG,EAAE,mBAAmB,EAAE;CACnC;;CCCA,OAAO,CAAC,GAAG,EAAE,oBAAoB,EAAE;;CAEnC,GAAG,EAAE;CACL,GAAG,EAAE;;;;;;"} \ No newline at end of file diff --git a/test/form/samples/sourcemaps-external/_expected/system.js b/test/form/samples/sourcemaps-external/_expected/system.js index 0e5a1020f81..0d0d48d6acd 100644 --- a/test/form/samples/sourcemaps-external/_expected/system.js +++ b/test/form/samples/sourcemaps-external/_expected/system.js @@ -1,7 +1,7 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { function foo () { console.log( 'hello from foo.js' ); @@ -16,7 +16,7 @@ System.register([], function () { foo(); bar(); - } + }) }; -}); +})); //# sourceMappingURL=system.js.map diff --git a/test/form/samples/sourcemaps-external/_expected/system.js.map b/test/form/samples/sourcemaps-external/_expected/system.js.map index 2d6df9a0038..527471639f8 100644 --- a/test/form/samples/sourcemaps-external/_expected/system.js.map +++ b/test/form/samples/sourcemaps-external/_expected/system.js.map @@ -1 +1 @@ -{"version":3,"file":"system.js","sources":["../foo.js","../bar.js","../main.js"],"sourcesContent":["export default function foo () {\n\tconsole.log( 'hello from foo.js' );\n}\n","export default function bar () {\n\tconsole.log( 'hello from bar.js' );\n}\n","import foo from './foo';\nimport bar from './bar';\n\nconsole.log( 'hello from main.js' );\n\nfoo();\nbar();\n"],"names":[],"mappings":";;;;;GAAe,SAAS,GAAG,IAAI;GAC/B,CAAC,OAAO,CAAC,GAAG,EAAE,mBAAmB,EAAE,CAAC;GACpC;;GCFe,SAAS,GAAG,IAAI;GAC/B,CAAC,OAAO,CAAC,GAAG,EAAE,mBAAmB,EAAE,CAAC;GACpC;;GCCA,OAAO,CAAC,GAAG,EAAE,oBAAoB,EAAE,CAAC;AACpC;GACA,GAAG,EAAE,CAAC;GACN,GAAG,EAAE;;;;;;"} \ No newline at end of file +{"version":3,"file":"system.js","sources":["../foo.js","../bar.js","../main.js"],"sourcesContent":["export default function foo () {\n\tconsole.log( 'hello from foo.js' );\n}\n","export default function bar () {\n\tconsole.log( 'hello from bar.js' );\n}\n","import foo from './foo';\nimport bar from './bar';\n\nconsole.log( 'hello from main.js' );\n\nfoo();\nbar();\n"],"names":[],"mappings":";;;;;GAAe,SAAS,GAAG,IAAI;GAC/B,CAAC,OAAO,CAAC,GAAG,EAAE,mBAAmB,EAAE;GACnC;;GCFe,SAAS,GAAG,IAAI;GAC/B,CAAC,OAAO,CAAC,GAAG,EAAE,mBAAmB,EAAE;GACnC;;GCCA,OAAO,CAAC,GAAG,EAAE,oBAAoB,EAAE;;GAEnC,GAAG,EAAE;GACL,GAAG,EAAE;;;;;;;;"} \ No newline at end of file diff --git a/test/form/samples/sourcemaps-external/_expected/umd.js b/test/form/samples/sourcemaps-external/_expected/umd.js index 4e06d25f444..e83feed7206 100644 --- a/test/form/samples/sourcemaps-external/_expected/umd.js +++ b/test/form/samples/sourcemaps-external/_expected/umd.js @@ -1,7 +1,7 @@ (function (factory) { typeof define === 'function' && define.amd ? define(factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; function foo () { console.log( 'hello from foo.js' ); @@ -16,5 +16,5 @@ foo(); bar(); -}))); +})); //# sourceMappingURL=umd.js.map diff --git a/test/form/samples/sourcemaps-external/_expected/umd.js.map b/test/form/samples/sourcemaps-external/_expected/umd.js.map index fc2be5fdd43..62ec82562b2 100644 --- a/test/form/samples/sourcemaps-external/_expected/umd.js.map +++ b/test/form/samples/sourcemaps-external/_expected/umd.js.map @@ -1 +1 @@ -{"version":3,"file":"umd.js","sources":["../foo.js","../bar.js","../main.js"],"sourcesContent":["export default function foo () {\n\tconsole.log( 'hello from foo.js' );\n}\n","export default function bar () {\n\tconsole.log( 'hello from bar.js' );\n}\n","import foo from './foo';\nimport bar from './bar';\n\nconsole.log( 'hello from main.js' );\n\nfoo();\nbar();\n"],"names":[],"mappings":";;;;;CAAe,SAAS,GAAG,IAAI;CAC/B,CAAC,OAAO,CAAC,GAAG,EAAE,mBAAmB,EAAE,CAAC;CACpC;;CCFe,SAAS,GAAG,IAAI;CAC/B,CAAC,OAAO,CAAC,GAAG,EAAE,mBAAmB,EAAE,CAAC;CACpC;;CCCA,OAAO,CAAC,GAAG,EAAE,oBAAoB,EAAE,CAAC;AACpC;CACA,GAAG,EAAE,CAAC;CACN,GAAG,EAAE;;;;;;"} \ No newline at end of file +{"version":3,"file":"umd.js","sources":["../foo.js","../bar.js","../main.js"],"sourcesContent":["export default function foo () {\n\tconsole.log( 'hello from foo.js' );\n}\n","export default function bar () {\n\tconsole.log( 'hello from bar.js' );\n}\n","import foo from './foo';\nimport bar from './bar';\n\nconsole.log( 'hello from main.js' );\n\nfoo();\nbar();\n"],"names":[],"mappings":";;;;;CAAe,SAAS,GAAG,IAAI;CAC/B,CAAC,OAAO,CAAC,GAAG,EAAE,mBAAmB,EAAE;CACnC;;CCFe,SAAS,GAAG,IAAI;CAC/B,CAAC,OAAO,CAAC,GAAG,EAAE,mBAAmB,EAAE;CACnC;;CCCA,OAAO,CAAC,GAAG,EAAE,oBAAoB,EAAE;;CAEnC,GAAG,EAAE;CACL,GAAG,EAAE;;;;;;"} \ No newline at end of file diff --git a/test/form/samples/sourcemaps-hidden/_config.js b/test/form/samples/sourcemaps-hidden/_config.js index 9aa83cd79dc..ed2ed256bb1 100644 --- a/test/form/samples/sourcemaps-hidden/_config.js +++ b/test/form/samples/sourcemaps-hidden/_config.js @@ -1,7 +1,7 @@ -module.exports = { +module.exports = defineTest({ description: 'correct sourcemaps are written (separate file) without comment', skipIfWindows: true, options: { output: { sourcemap: 'hidden' } } -}; +}); diff --git a/test/form/samples/sourcemaps-hidden/_expected/amd.js b/test/form/samples/sourcemaps-hidden/_expected/amd.js index da7dafc6803..cf7f78d4908 100644 --- a/test/form/samples/sourcemaps-hidden/_expected/amd.js +++ b/test/form/samples/sourcemaps-hidden/_expected/amd.js @@ -1,4 +1,4 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; function foo () { console.log( 'hello from foo.js' ); @@ -13,4 +13,4 @@ define(function () { 'use strict'; foo(); bar(); -}); +})); diff --git a/test/form/samples/sourcemaps-hidden/_expected/amd.js.map b/test/form/samples/sourcemaps-hidden/_expected/amd.js.map index a648595809d..cfcc290b4bf 100644 --- a/test/form/samples/sourcemaps-hidden/_expected/amd.js.map +++ b/test/form/samples/sourcemaps-hidden/_expected/amd.js.map @@ -1 +1 @@ -{"version":3,"file":"amd.js","sources":["../foo.js","../bar.js","../main.js"],"sourcesContent":["export default function foo () {\n\tconsole.log( 'hello from foo.js' );\n}\n","export default function bar () {\n\tconsole.log( 'hello from bar.js' );\n}\n","import foo from './foo';\nimport bar from './bar';\n\nconsole.log( 'hello from main.js' );\n\nfoo();\nbar();\n"],"names":[],"mappings":";;CAAe,SAAS,GAAG,IAAI;CAC/B,CAAC,OAAO,CAAC,GAAG,EAAE,mBAAmB,EAAE,CAAC;CACpC;;CCFe,SAAS,GAAG,IAAI;CAC/B,CAAC,OAAO,CAAC,GAAG,EAAE,mBAAmB,EAAE,CAAC;CACpC;;CCCA,OAAO,CAAC,GAAG,EAAE,oBAAoB,EAAE,CAAC;AACpC;CACA,GAAG,EAAE,CAAC;CACN,GAAG,EAAE;;;;;;"} \ No newline at end of file +{"version":3,"file":"amd.js","sources":["../foo.js","../bar.js","../main.js"],"sourcesContent":["export default function foo () {\n\tconsole.log( 'hello from foo.js' );\n}\n","export default function bar () {\n\tconsole.log( 'hello from bar.js' );\n}\n","import foo from './foo';\nimport bar from './bar';\n\nconsole.log( 'hello from main.js' );\n\nfoo();\nbar();\n"],"names":[],"mappings":";;CAAe,SAAS,GAAG,IAAI;CAC/B,CAAC,OAAO,CAAC,GAAG,EAAE,mBAAmB,EAAE;CACnC;;CCFe,SAAS,GAAG,IAAI;CAC/B,CAAC,OAAO,CAAC,GAAG,EAAE,mBAAmB,EAAE;CACnC;;CCCA,OAAO,CAAC,GAAG,EAAE,oBAAoB,EAAE;;CAEnC,GAAG,EAAE;CACL,GAAG,EAAE;;;;;;"} \ No newline at end of file diff --git a/test/form/samples/sourcemaps-hidden/_expected/cjs.js.map b/test/form/samples/sourcemaps-hidden/_expected/cjs.js.map index 823ebc157dd..cae3342ee58 100644 --- a/test/form/samples/sourcemaps-hidden/_expected/cjs.js.map +++ b/test/form/samples/sourcemaps-hidden/_expected/cjs.js.map @@ -1 +1 @@ -{"version":3,"file":"cjs.js","sources":["../foo.js","../bar.js","../main.js"],"sourcesContent":["export default function foo () {\n\tconsole.log( 'hello from foo.js' );\n}\n","export default function bar () {\n\tconsole.log( 'hello from bar.js' );\n}\n","import foo from './foo';\nimport bar from './bar';\n\nconsole.log( 'hello from main.js' );\n\nfoo();\nbar();\n"],"names":[],"mappings":";;AAAe,SAAS,GAAG,IAAI;AAC/B,CAAC,OAAO,CAAC,GAAG,EAAE,mBAAmB,EAAE,CAAC;AACpC;;ACFe,SAAS,GAAG,IAAI;AAC/B,CAAC,OAAO,CAAC,GAAG,EAAE,mBAAmB,EAAE,CAAC;AACpC;;ACCA,OAAO,CAAC,GAAG,EAAE,oBAAoB,EAAE,CAAC;AACpC;AACA,GAAG,EAAE,CAAC;AACN,GAAG,EAAE;;"} \ No newline at end of file +{"version":3,"file":"cjs.js","sources":["../foo.js","../bar.js","../main.js"],"sourcesContent":["export default function foo () {\n\tconsole.log( 'hello from foo.js' );\n}\n","export default function bar () {\n\tconsole.log( 'hello from bar.js' );\n}\n","import foo from './foo';\nimport bar from './bar';\n\nconsole.log( 'hello from main.js' );\n\nfoo();\nbar();\n"],"names":[],"mappings":";;AAAe,SAAS,GAAG,IAAI;AAC/B,CAAC,OAAO,CAAC,GAAG,EAAE,mBAAmB,EAAE;AACnC;;ACFe,SAAS,GAAG,IAAI;AAC/B,CAAC,OAAO,CAAC,GAAG,EAAE,mBAAmB,EAAE;AACnC;;ACCA,OAAO,CAAC,GAAG,EAAE,oBAAoB,EAAE;;AAEnC,GAAG,EAAE;AACL,GAAG,EAAE;;"} \ No newline at end of file diff --git a/test/form/samples/sourcemaps-hidden/_expected/es.js.map b/test/form/samples/sourcemaps-hidden/_expected/es.js.map index 25b559ccdc6..eeced40c569 100644 --- a/test/form/samples/sourcemaps-hidden/_expected/es.js.map +++ b/test/form/samples/sourcemaps-hidden/_expected/es.js.map @@ -1 +1 @@ -{"version":3,"file":"es.js","sources":["../foo.js","../bar.js","../main.js"],"sourcesContent":["export default function foo () {\n\tconsole.log( 'hello from foo.js' );\n}\n","export default function bar () {\n\tconsole.log( 'hello from bar.js' );\n}\n","import foo from './foo';\nimport bar from './bar';\n\nconsole.log( 'hello from main.js' );\n\nfoo();\nbar();\n"],"names":[],"mappings":"AAAe,SAAS,GAAG,IAAI;AAC/B,CAAC,OAAO,CAAC,GAAG,EAAE,mBAAmB,EAAE,CAAC;AACpC;;ACFe,SAAS,GAAG,IAAI;AAC/B,CAAC,OAAO,CAAC,GAAG,EAAE,mBAAmB,EAAE,CAAC;AACpC;;ACCA,OAAO,CAAC,GAAG,EAAE,oBAAoB,EAAE,CAAC;AACpC;AACA,GAAG,EAAE,CAAC;AACN,GAAG,EAAE"} \ No newline at end of file +{"version":3,"file":"es.js","sources":["../foo.js","../bar.js","../main.js"],"sourcesContent":["export default function foo () {\n\tconsole.log( 'hello from foo.js' );\n}\n","export default function bar () {\n\tconsole.log( 'hello from bar.js' );\n}\n","import foo from './foo';\nimport bar from './bar';\n\nconsole.log( 'hello from main.js' );\n\nfoo();\nbar();\n"],"names":[],"mappings":"AAAe,SAAS,GAAG,IAAI;AAC/B,CAAC,OAAO,CAAC,GAAG,EAAE,mBAAmB,EAAE;AACnC;;ACFe,SAAS,GAAG,IAAI;AAC/B,CAAC,OAAO,CAAC,GAAG,EAAE,mBAAmB,EAAE;AACnC;;ACCA,OAAO,CAAC,GAAG,EAAE,oBAAoB,EAAE;;AAEnC,GAAG,EAAE;AACL,GAAG,EAAE"} \ No newline at end of file diff --git a/test/form/samples/sourcemaps-hidden/_expected/iife.js b/test/form/samples/sourcemaps-hidden/_expected/iife.js index eceb9d3de37..b14e92b45ce 100644 --- a/test/form/samples/sourcemaps-hidden/_expected/iife.js +++ b/test/form/samples/sourcemaps-hidden/_expected/iife.js @@ -14,4 +14,4 @@ foo(); bar(); -}()); +})(); diff --git a/test/form/samples/sourcemaps-hidden/_expected/iife.js.map b/test/form/samples/sourcemaps-hidden/_expected/iife.js.map index b4e5e2e642c..e1286283248 100644 --- a/test/form/samples/sourcemaps-hidden/_expected/iife.js.map +++ b/test/form/samples/sourcemaps-hidden/_expected/iife.js.map @@ -1 +1 @@ -{"version":3,"file":"iife.js","sources":["../foo.js","../bar.js","../main.js"],"sourcesContent":["export default function foo () {\n\tconsole.log( 'hello from foo.js' );\n}\n","export default function bar () {\n\tconsole.log( 'hello from bar.js' );\n}\n","import foo from './foo';\nimport bar from './bar';\n\nconsole.log( 'hello from main.js' );\n\nfoo();\nbar();\n"],"names":[],"mappings":";;;CAAe,SAAS,GAAG,IAAI;CAC/B,CAAC,OAAO,CAAC,GAAG,EAAE,mBAAmB,EAAE,CAAC;CACpC;;CCFe,SAAS,GAAG,IAAI;CAC/B,CAAC,OAAO,CAAC,GAAG,EAAE,mBAAmB,EAAE,CAAC;CACpC;;CCCA,OAAO,CAAC,GAAG,EAAE,oBAAoB,EAAE,CAAC;AACpC;CACA,GAAG,EAAE,CAAC;CACN,GAAG,EAAE;;;;;;"} \ No newline at end of file +{"version":3,"file":"iife.js","sources":["../foo.js","../bar.js","../main.js"],"sourcesContent":["export default function foo () {\n\tconsole.log( 'hello from foo.js' );\n}\n","export default function bar () {\n\tconsole.log( 'hello from bar.js' );\n}\n","import foo from './foo';\nimport bar from './bar';\n\nconsole.log( 'hello from main.js' );\n\nfoo();\nbar();\n"],"names":[],"mappings":";;;CAAe,SAAS,GAAG,IAAI;CAC/B,CAAC,OAAO,CAAC,GAAG,EAAE,mBAAmB,EAAE;CACnC;;CCFe,SAAS,GAAG,IAAI;CAC/B,CAAC,OAAO,CAAC,GAAG,EAAE,mBAAmB,EAAE;CACnC;;CCCA,OAAO,CAAC,GAAG,EAAE,oBAAoB,EAAE;;CAEnC,GAAG,EAAE;CACL,GAAG,EAAE;;;;;;"} \ No newline at end of file diff --git a/test/form/samples/sourcemaps-hidden/_expected/system.js b/test/form/samples/sourcemaps-hidden/_expected/system.js index 698e34e6f11..9b5839e523d 100644 --- a/test/form/samples/sourcemaps-hidden/_expected/system.js +++ b/test/form/samples/sourcemaps-hidden/_expected/system.js @@ -1,7 +1,7 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { function foo () { console.log( 'hello from foo.js' ); @@ -16,6 +16,6 @@ System.register([], function () { foo(); bar(); - } + }) }; -}); +})); diff --git a/test/form/samples/sourcemaps-hidden/_expected/system.js.map b/test/form/samples/sourcemaps-hidden/_expected/system.js.map index 2d6df9a0038..527471639f8 100644 --- a/test/form/samples/sourcemaps-hidden/_expected/system.js.map +++ b/test/form/samples/sourcemaps-hidden/_expected/system.js.map @@ -1 +1 @@ -{"version":3,"file":"system.js","sources":["../foo.js","../bar.js","../main.js"],"sourcesContent":["export default function foo () {\n\tconsole.log( 'hello from foo.js' );\n}\n","export default function bar () {\n\tconsole.log( 'hello from bar.js' );\n}\n","import foo from './foo';\nimport bar from './bar';\n\nconsole.log( 'hello from main.js' );\n\nfoo();\nbar();\n"],"names":[],"mappings":";;;;;GAAe,SAAS,GAAG,IAAI;GAC/B,CAAC,OAAO,CAAC,GAAG,EAAE,mBAAmB,EAAE,CAAC;GACpC;;GCFe,SAAS,GAAG,IAAI;GAC/B,CAAC,OAAO,CAAC,GAAG,EAAE,mBAAmB,EAAE,CAAC;GACpC;;GCCA,OAAO,CAAC,GAAG,EAAE,oBAAoB,EAAE,CAAC;AACpC;GACA,GAAG,EAAE,CAAC;GACN,GAAG,EAAE;;;;;;"} \ No newline at end of file +{"version":3,"file":"system.js","sources":["../foo.js","../bar.js","../main.js"],"sourcesContent":["export default function foo () {\n\tconsole.log( 'hello from foo.js' );\n}\n","export default function bar () {\n\tconsole.log( 'hello from bar.js' );\n}\n","import foo from './foo';\nimport bar from './bar';\n\nconsole.log( 'hello from main.js' );\n\nfoo();\nbar();\n"],"names":[],"mappings":";;;;;GAAe,SAAS,GAAG,IAAI;GAC/B,CAAC,OAAO,CAAC,GAAG,EAAE,mBAAmB,EAAE;GACnC;;GCFe,SAAS,GAAG,IAAI;GAC/B,CAAC,OAAO,CAAC,GAAG,EAAE,mBAAmB,EAAE;GACnC;;GCCA,OAAO,CAAC,GAAG,EAAE,oBAAoB,EAAE;;GAEnC,GAAG,EAAE;GACL,GAAG,EAAE;;;;;;;;"} \ No newline at end of file diff --git a/test/form/samples/sourcemaps-hidden/_expected/umd.js b/test/form/samples/sourcemaps-hidden/_expected/umd.js index ec2fa48e65f..9030ec9df56 100644 --- a/test/form/samples/sourcemaps-hidden/_expected/umd.js +++ b/test/form/samples/sourcemaps-hidden/_expected/umd.js @@ -1,7 +1,7 @@ (function (factory) { typeof define === 'function' && define.amd ? define(factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; function foo () { console.log( 'hello from foo.js' ); @@ -16,4 +16,4 @@ foo(); bar(); -}))); +})); diff --git a/test/form/samples/sourcemaps-hidden/_expected/umd.js.map b/test/form/samples/sourcemaps-hidden/_expected/umd.js.map index fc2be5fdd43..62ec82562b2 100644 --- a/test/form/samples/sourcemaps-hidden/_expected/umd.js.map +++ b/test/form/samples/sourcemaps-hidden/_expected/umd.js.map @@ -1 +1 @@ -{"version":3,"file":"umd.js","sources":["../foo.js","../bar.js","../main.js"],"sourcesContent":["export default function foo () {\n\tconsole.log( 'hello from foo.js' );\n}\n","export default function bar () {\n\tconsole.log( 'hello from bar.js' );\n}\n","import foo from './foo';\nimport bar from './bar';\n\nconsole.log( 'hello from main.js' );\n\nfoo();\nbar();\n"],"names":[],"mappings":";;;;;CAAe,SAAS,GAAG,IAAI;CAC/B,CAAC,OAAO,CAAC,GAAG,EAAE,mBAAmB,EAAE,CAAC;CACpC;;CCFe,SAAS,GAAG,IAAI;CAC/B,CAAC,OAAO,CAAC,GAAG,EAAE,mBAAmB,EAAE,CAAC;CACpC;;CCCA,OAAO,CAAC,GAAG,EAAE,oBAAoB,EAAE,CAAC;AACpC;CACA,GAAG,EAAE,CAAC;CACN,GAAG,EAAE;;;;;;"} \ No newline at end of file +{"version":3,"file":"umd.js","sources":["../foo.js","../bar.js","../main.js"],"sourcesContent":["export default function foo () {\n\tconsole.log( 'hello from foo.js' );\n}\n","export default function bar () {\n\tconsole.log( 'hello from bar.js' );\n}\n","import foo from './foo';\nimport bar from './bar';\n\nconsole.log( 'hello from main.js' );\n\nfoo();\nbar();\n"],"names":[],"mappings":";;;;;CAAe,SAAS,GAAG,IAAI;CAC/B,CAAC,OAAO,CAAC,GAAG,EAAE,mBAAmB,EAAE;CACnC;;CCFe,SAAS,GAAG,IAAI;CAC/B,CAAC,OAAO,CAAC,GAAG,EAAE,mBAAmB,EAAE;CACnC;;CCCA,OAAO,CAAC,GAAG,EAAE,oBAAoB,EAAE;;CAEnC,GAAG,EAAE;CACL,GAAG,EAAE;;;;;;"} \ No newline at end of file diff --git a/test/form/samples/sourcemaps-inline/_config.js b/test/form/samples/sourcemaps-inline/_config.js index 29ce5550420..679182017a3 100644 --- a/test/form/samples/sourcemaps-inline/_config.js +++ b/test/form/samples/sourcemaps-inline/_config.js @@ -1,7 +1,7 @@ -module.exports = { +module.exports = defineTest({ description: 'correct sourcemaps are written (inline)', skipIfWindows: true, options: { - output: {sourcemap: 'inline'} + output: { sourcemap: 'inline' } } -}; +}); diff --git a/test/form/samples/sourcemaps-inline/_expected/amd.js b/test/form/samples/sourcemaps-inline/_expected/amd.js index 7f95f5174dd..a2582832363 100644 --- a/test/form/samples/sourcemaps-inline/_expected/amd.js +++ b/test/form/samples/sourcemaps-inline/_expected/amd.js @@ -1,4 +1,4 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; function foo () { console.log( 'hello from foo.js' ); @@ -13,5 +13,5 @@ define(function () { 'use strict'; foo(); bar(); -}); -//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYW1kLmpzIiwic291cmNlcyI6WyIuLi9mb28uanMiLCIuLi9iYXIuanMiLCIuLi9tYWluLmpzIl0sInNvdXJjZXNDb250ZW50IjpbImV4cG9ydCBkZWZhdWx0IGZ1bmN0aW9uIGZvbyAoKSB7XG5cdGNvbnNvbGUubG9nKCAnaGVsbG8gZnJvbSBmb28uanMnICk7XG59XG4iLCJleHBvcnQgZGVmYXVsdCBmdW5jdGlvbiBiYXIgKCkge1xuXHRjb25zb2xlLmxvZyggJ2hlbGxvIGZyb20gYmFyLmpzJyApO1xufVxuIiwiaW1wb3J0IGZvbyBmcm9tICcuL2Zvbyc7XG5pbXBvcnQgYmFyIGZyb20gJy4vYmFyJztcblxuY29uc29sZS5sb2coICdoZWxsbyBmcm9tIG1haW4uanMnICk7XG5cbmZvbygpO1xuYmFyKCk7XG4iXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Q0FBZSxTQUFTLEdBQUcsSUFBSTtDQUMvQixDQUFDLE9BQU8sQ0FBQyxHQUFHLEVBQUUsbUJBQW1CLEVBQUUsQ0FBQztDQUNwQzs7Q0NGZSxTQUFTLEdBQUcsSUFBSTtDQUMvQixDQUFDLE9BQU8sQ0FBQyxHQUFHLEVBQUUsbUJBQW1CLEVBQUUsQ0FBQztDQUNwQzs7Q0NDQSxPQUFPLENBQUMsR0FBRyxFQUFFLG9CQUFvQixFQUFFLENBQUM7QUFDcEM7Q0FDQSxHQUFHLEVBQUUsQ0FBQztDQUNOLEdBQUcsRUFBRTs7Ozs7OyJ9 +})); +//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYW1kLmpzIiwic291cmNlcyI6WyIuLi9mb28uanMiLCIuLi9iYXIuanMiLCIuLi9tYWluLmpzIl0sInNvdXJjZXNDb250ZW50IjpbImV4cG9ydCBkZWZhdWx0IGZ1bmN0aW9uIGZvbyAoKSB7XG5cdGNvbnNvbGUubG9nKCAnaGVsbG8gZnJvbSBmb28uanMnICk7XG59XG4iLCJleHBvcnQgZGVmYXVsdCBmdW5jdGlvbiBiYXIgKCkge1xuXHRjb25zb2xlLmxvZyggJ2hlbGxvIGZyb20gYmFyLmpzJyApO1xufVxuIiwiaW1wb3J0IGZvbyBmcm9tICcuL2Zvbyc7XG5pbXBvcnQgYmFyIGZyb20gJy4vYmFyJztcblxuY29uc29sZS5sb2coICdoZWxsbyBmcm9tIG1haW4uanMnICk7XG5cbmZvbygpO1xuYmFyKCk7XG4iXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Q0FBZSxTQUFTLEdBQUcsSUFBSTtDQUMvQixDQUFDLE9BQU8sQ0FBQyxHQUFHLEVBQUUsbUJBQW1CLEVBQUU7Q0FDbkM7O0NDRmUsU0FBUyxHQUFHLElBQUk7Q0FDL0IsQ0FBQyxPQUFPLENBQUMsR0FBRyxFQUFFLG1CQUFtQixFQUFFO0NBQ25DOztDQ0NBLE9BQU8sQ0FBQyxHQUFHLEVBQUUsb0JBQW9CLEVBQUU7O0NBRW5DLEdBQUcsRUFBRTtDQUNMLEdBQUcsRUFBRTs7Ozs7OyJ9 diff --git a/test/form/samples/sourcemaps-inline/_expected/cjs.js b/test/form/samples/sourcemaps-inline/_expected/cjs.js index 5438c333dce..0650e0d5d59 100644 --- a/test/form/samples/sourcemaps-inline/_expected/cjs.js +++ b/test/form/samples/sourcemaps-inline/_expected/cjs.js @@ -12,4 +12,4 @@ console.log( 'hello from main.js' ); foo(); bar(); -//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2pzLmpzIiwic291cmNlcyI6WyIuLi9mb28uanMiLCIuLi9iYXIuanMiLCIuLi9tYWluLmpzIl0sInNvdXJjZXNDb250ZW50IjpbImV4cG9ydCBkZWZhdWx0IGZ1bmN0aW9uIGZvbyAoKSB7XG5cdGNvbnNvbGUubG9nKCAnaGVsbG8gZnJvbSBmb28uanMnICk7XG59XG4iLCJleHBvcnQgZGVmYXVsdCBmdW5jdGlvbiBiYXIgKCkge1xuXHRjb25zb2xlLmxvZyggJ2hlbGxvIGZyb20gYmFyLmpzJyApO1xufVxuIiwiaW1wb3J0IGZvbyBmcm9tICcuL2Zvbyc7XG5pbXBvcnQgYmFyIGZyb20gJy4vYmFyJztcblxuY29uc29sZS5sb2coICdoZWxsbyBmcm9tIG1haW4uanMnICk7XG5cbmZvbygpO1xuYmFyKCk7XG4iXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFBZSxTQUFTLEdBQUcsSUFBSTtBQUMvQixDQUFDLE9BQU8sQ0FBQyxHQUFHLEVBQUUsbUJBQW1CLEVBQUUsQ0FBQztBQUNwQzs7QUNGZSxTQUFTLEdBQUcsSUFBSTtBQUMvQixDQUFDLE9BQU8sQ0FBQyxHQUFHLEVBQUUsbUJBQW1CLEVBQUUsQ0FBQztBQUNwQzs7QUNDQSxPQUFPLENBQUMsR0FBRyxFQUFFLG9CQUFvQixFQUFFLENBQUM7QUFDcEM7QUFDQSxHQUFHLEVBQUUsQ0FBQztBQUNOLEdBQUcsRUFBRTs7In0= +//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2pzLmpzIiwic291cmNlcyI6WyIuLi9mb28uanMiLCIuLi9iYXIuanMiLCIuLi9tYWluLmpzIl0sInNvdXJjZXNDb250ZW50IjpbImV4cG9ydCBkZWZhdWx0IGZ1bmN0aW9uIGZvbyAoKSB7XG5cdGNvbnNvbGUubG9nKCAnaGVsbG8gZnJvbSBmb28uanMnICk7XG59XG4iLCJleHBvcnQgZGVmYXVsdCBmdW5jdGlvbiBiYXIgKCkge1xuXHRjb25zb2xlLmxvZyggJ2hlbGxvIGZyb20gYmFyLmpzJyApO1xufVxuIiwiaW1wb3J0IGZvbyBmcm9tICcuL2Zvbyc7XG5pbXBvcnQgYmFyIGZyb20gJy4vYmFyJztcblxuY29uc29sZS5sb2coICdoZWxsbyBmcm9tIG1haW4uanMnICk7XG5cbmZvbygpO1xuYmFyKCk7XG4iXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFBZSxTQUFTLEdBQUcsSUFBSTtBQUMvQixDQUFDLE9BQU8sQ0FBQyxHQUFHLEVBQUUsbUJBQW1CLEVBQUU7QUFDbkM7O0FDRmUsU0FBUyxHQUFHLElBQUk7QUFDL0IsQ0FBQyxPQUFPLENBQUMsR0FBRyxFQUFFLG1CQUFtQixFQUFFO0FBQ25DOztBQ0NBLE9BQU8sQ0FBQyxHQUFHLEVBQUUsb0JBQW9CLEVBQUU7O0FBRW5DLEdBQUcsRUFBRTtBQUNMLEdBQUcsRUFBRTs7In0= diff --git a/test/form/samples/sourcemaps-inline/_expected/es.js b/test/form/samples/sourcemaps-inline/_expected/es.js index 62b89098af8..bd3f6208bb1 100644 --- a/test/form/samples/sourcemaps-inline/_expected/es.js +++ b/test/form/samples/sourcemaps-inline/_expected/es.js @@ -10,4 +10,4 @@ console.log( 'hello from main.js' ); foo(); bar(); -//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZXMuanMiLCJzb3VyY2VzIjpbIi4uL2Zvby5qcyIsIi4uL2Jhci5qcyIsIi4uL21haW4uanMiXSwic291cmNlc0NvbnRlbnQiOlsiZXhwb3J0IGRlZmF1bHQgZnVuY3Rpb24gZm9vICgpIHtcblx0Y29uc29sZS5sb2coICdoZWxsbyBmcm9tIGZvby5qcycgKTtcbn1cbiIsImV4cG9ydCBkZWZhdWx0IGZ1bmN0aW9uIGJhciAoKSB7XG5cdGNvbnNvbGUubG9nKCAnaGVsbG8gZnJvbSBiYXIuanMnICk7XG59XG4iLCJpbXBvcnQgZm9vIGZyb20gJy4vZm9vJztcbmltcG9ydCBiYXIgZnJvbSAnLi9iYXInO1xuXG5jb25zb2xlLmxvZyggJ2hlbGxvIGZyb20gbWFpbi5qcycgKTtcblxuZm9vKCk7XG5iYXIoKTtcbiJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBZSxTQUFTLEdBQUcsSUFBSTtBQUMvQixDQUFDLE9BQU8sQ0FBQyxHQUFHLEVBQUUsbUJBQW1CLEVBQUUsQ0FBQztBQUNwQzs7QUNGZSxTQUFTLEdBQUcsSUFBSTtBQUMvQixDQUFDLE9BQU8sQ0FBQyxHQUFHLEVBQUUsbUJBQW1CLEVBQUUsQ0FBQztBQUNwQzs7QUNDQSxPQUFPLENBQUMsR0FBRyxFQUFFLG9CQUFvQixFQUFFLENBQUM7QUFDcEM7QUFDQSxHQUFHLEVBQUUsQ0FBQztBQUNOLEdBQUcsRUFBRSJ9 +//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZXMuanMiLCJzb3VyY2VzIjpbIi4uL2Zvby5qcyIsIi4uL2Jhci5qcyIsIi4uL21haW4uanMiXSwic291cmNlc0NvbnRlbnQiOlsiZXhwb3J0IGRlZmF1bHQgZnVuY3Rpb24gZm9vICgpIHtcblx0Y29uc29sZS5sb2coICdoZWxsbyBmcm9tIGZvby5qcycgKTtcbn1cbiIsImV4cG9ydCBkZWZhdWx0IGZ1bmN0aW9uIGJhciAoKSB7XG5cdGNvbnNvbGUubG9nKCAnaGVsbG8gZnJvbSBiYXIuanMnICk7XG59XG4iLCJpbXBvcnQgZm9vIGZyb20gJy4vZm9vJztcbmltcG9ydCBiYXIgZnJvbSAnLi9iYXInO1xuXG5jb25zb2xlLmxvZyggJ2hlbGxvIGZyb20gbWFpbi5qcycgKTtcblxuZm9vKCk7XG5iYXIoKTtcbiJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBZSxTQUFTLEdBQUcsSUFBSTtBQUMvQixDQUFDLE9BQU8sQ0FBQyxHQUFHLEVBQUUsbUJBQW1CLEVBQUU7QUFDbkM7O0FDRmUsU0FBUyxHQUFHLElBQUk7QUFDL0IsQ0FBQyxPQUFPLENBQUMsR0FBRyxFQUFFLG1CQUFtQixFQUFFO0FBQ25DOztBQ0NBLE9BQU8sQ0FBQyxHQUFHLEVBQUUsb0JBQW9CLEVBQUU7O0FBRW5DLEdBQUcsRUFBRTtBQUNMLEdBQUcsRUFBRSJ9 diff --git a/test/form/samples/sourcemaps-inline/_expected/iife.js b/test/form/samples/sourcemaps-inline/_expected/iife.js index 32f46ae2d4b..979ca478be5 100644 --- a/test/form/samples/sourcemaps-inline/_expected/iife.js +++ b/test/form/samples/sourcemaps-inline/_expected/iife.js @@ -14,5 +14,5 @@ foo(); bar(); -}()); -//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaWlmZS5qcyIsInNvdXJjZXMiOlsiLi4vZm9vLmpzIiwiLi4vYmFyLmpzIiwiLi4vbWFpbi5qcyJdLCJzb3VyY2VzQ29udGVudCI6WyJleHBvcnQgZGVmYXVsdCBmdW5jdGlvbiBmb28gKCkge1xuXHRjb25zb2xlLmxvZyggJ2hlbGxvIGZyb20gZm9vLmpzJyApO1xufVxuIiwiZXhwb3J0IGRlZmF1bHQgZnVuY3Rpb24gYmFyICgpIHtcblx0Y29uc29sZS5sb2coICdoZWxsbyBmcm9tIGJhci5qcycgKTtcbn1cbiIsImltcG9ydCBmb28gZnJvbSAnLi9mb28nO1xuaW1wb3J0IGJhciBmcm9tICcuL2Jhcic7XG5cbmNvbnNvbGUubG9nKCAnaGVsbG8gZnJvbSBtYWluLmpzJyApO1xuXG5mb28oKTtcbmJhcigpO1xuIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztDQUFlLFNBQVMsR0FBRyxJQUFJO0NBQy9CLENBQUMsT0FBTyxDQUFDLEdBQUcsRUFBRSxtQkFBbUIsRUFBRSxDQUFDO0NBQ3BDOztDQ0ZlLFNBQVMsR0FBRyxJQUFJO0NBQy9CLENBQUMsT0FBTyxDQUFDLEdBQUcsRUFBRSxtQkFBbUIsRUFBRSxDQUFDO0NBQ3BDOztDQ0NBLE9BQU8sQ0FBQyxHQUFHLEVBQUUsb0JBQW9CLEVBQUUsQ0FBQztBQUNwQztDQUNBLEdBQUcsRUFBRSxDQUFDO0NBQ04sR0FBRyxFQUFFOzs7Ozs7In0= +})(); +//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaWlmZS5qcyIsInNvdXJjZXMiOlsiLi4vZm9vLmpzIiwiLi4vYmFyLmpzIiwiLi4vbWFpbi5qcyJdLCJzb3VyY2VzQ29udGVudCI6WyJleHBvcnQgZGVmYXVsdCBmdW5jdGlvbiBmb28gKCkge1xuXHRjb25zb2xlLmxvZyggJ2hlbGxvIGZyb20gZm9vLmpzJyApO1xufVxuIiwiZXhwb3J0IGRlZmF1bHQgZnVuY3Rpb24gYmFyICgpIHtcblx0Y29uc29sZS5sb2coICdoZWxsbyBmcm9tIGJhci5qcycgKTtcbn1cbiIsImltcG9ydCBmb28gZnJvbSAnLi9mb28nO1xuaW1wb3J0IGJhciBmcm9tICcuL2Jhcic7XG5cbmNvbnNvbGUubG9nKCAnaGVsbG8gZnJvbSBtYWluLmpzJyApO1xuXG5mb28oKTtcbmJhcigpO1xuIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztDQUFlLFNBQVMsR0FBRyxJQUFJO0NBQy9CLENBQUMsT0FBTyxDQUFDLEdBQUcsRUFBRSxtQkFBbUIsRUFBRTtDQUNuQzs7Q0NGZSxTQUFTLEdBQUcsSUFBSTtDQUMvQixDQUFDLE9BQU8sQ0FBQyxHQUFHLEVBQUUsbUJBQW1CLEVBQUU7Q0FDbkM7O0NDQ0EsT0FBTyxDQUFDLEdBQUcsRUFBRSxvQkFBb0IsRUFBRTs7Q0FFbkMsR0FBRyxFQUFFO0NBQ0wsR0FBRyxFQUFFOzs7Ozs7In0= diff --git a/test/form/samples/sourcemaps-inline/_expected/system.js b/test/form/samples/sourcemaps-inline/_expected/system.js index 2acd8bf26f0..81cb1b4f32e 100644 --- a/test/form/samples/sourcemaps-inline/_expected/system.js +++ b/test/form/samples/sourcemaps-inline/_expected/system.js @@ -1,7 +1,7 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { function foo () { console.log( 'hello from foo.js' ); @@ -16,7 +16,7 @@ System.register([], function () { foo(); bar(); - } + }) }; -}); -//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3lzdGVtLmpzIiwic291cmNlcyI6WyIuLi9mb28uanMiLCIuLi9iYXIuanMiLCIuLi9tYWluLmpzIl0sInNvdXJjZXNDb250ZW50IjpbImV4cG9ydCBkZWZhdWx0IGZ1bmN0aW9uIGZvbyAoKSB7XG5cdGNvbnNvbGUubG9nKCAnaGVsbG8gZnJvbSBmb28uanMnICk7XG59XG4iLCJleHBvcnQgZGVmYXVsdCBmdW5jdGlvbiBiYXIgKCkge1xuXHRjb25zb2xlLmxvZyggJ2hlbGxvIGZyb20gYmFyLmpzJyApO1xufVxuIiwiaW1wb3J0IGZvbyBmcm9tICcuL2Zvbyc7XG5pbXBvcnQgYmFyIGZyb20gJy4vYmFyJztcblxuY29uc29sZS5sb2coICdoZWxsbyBmcm9tIG1haW4uanMnICk7XG5cbmZvbygpO1xuYmFyKCk7XG4iXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7R0FBZSxTQUFTLEdBQUcsSUFBSTtHQUMvQixDQUFDLE9BQU8sQ0FBQyxHQUFHLEVBQUUsbUJBQW1CLEVBQUUsQ0FBQztHQUNwQzs7R0NGZSxTQUFTLEdBQUcsSUFBSTtHQUMvQixDQUFDLE9BQU8sQ0FBQyxHQUFHLEVBQUUsbUJBQW1CLEVBQUUsQ0FBQztHQUNwQzs7R0NDQSxPQUFPLENBQUMsR0FBRyxFQUFFLG9CQUFvQixFQUFFLENBQUM7QUFDcEM7R0FDQSxHQUFHLEVBQUUsQ0FBQztHQUNOLEdBQUcsRUFBRTs7Ozs7OyJ9 +})); +//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3lzdGVtLmpzIiwic291cmNlcyI6WyIuLi9mb28uanMiLCIuLi9iYXIuanMiLCIuLi9tYWluLmpzIl0sInNvdXJjZXNDb250ZW50IjpbImV4cG9ydCBkZWZhdWx0IGZ1bmN0aW9uIGZvbyAoKSB7XG5cdGNvbnNvbGUubG9nKCAnaGVsbG8gZnJvbSBmb28uanMnICk7XG59XG4iLCJleHBvcnQgZGVmYXVsdCBmdW5jdGlvbiBiYXIgKCkge1xuXHRjb25zb2xlLmxvZyggJ2hlbGxvIGZyb20gYmFyLmpzJyApO1xufVxuIiwiaW1wb3J0IGZvbyBmcm9tICcuL2Zvbyc7XG5pbXBvcnQgYmFyIGZyb20gJy4vYmFyJztcblxuY29uc29sZS5sb2coICdoZWxsbyBmcm9tIG1haW4uanMnICk7XG5cbmZvbygpO1xuYmFyKCk7XG4iXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7R0FBZSxTQUFTLEdBQUcsSUFBSTtHQUMvQixDQUFDLE9BQU8sQ0FBQyxHQUFHLEVBQUUsbUJBQW1CLEVBQUU7R0FDbkM7O0dDRmUsU0FBUyxHQUFHLElBQUk7R0FDL0IsQ0FBQyxPQUFPLENBQUMsR0FBRyxFQUFFLG1CQUFtQixFQUFFO0dBQ25DOztHQ0NBLE9BQU8sQ0FBQyxHQUFHLEVBQUUsb0JBQW9CLEVBQUU7O0dBRW5DLEdBQUcsRUFBRTtHQUNMLEdBQUcsRUFBRTs7Ozs7Ozs7In0= diff --git a/test/form/samples/sourcemaps-inline/_expected/umd.js b/test/form/samples/sourcemaps-inline/_expected/umd.js index 22a1ef277a1..28cc9ec6fbe 100644 --- a/test/form/samples/sourcemaps-inline/_expected/umd.js +++ b/test/form/samples/sourcemaps-inline/_expected/umd.js @@ -1,7 +1,7 @@ (function (factory) { typeof define === 'function' && define.amd ? define(factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; function foo () { console.log( 'hello from foo.js' ); @@ -16,5 +16,5 @@ foo(); bar(); -}))); -//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidW1kLmpzIiwic291cmNlcyI6WyIuLi9mb28uanMiLCIuLi9iYXIuanMiLCIuLi9tYWluLmpzIl0sInNvdXJjZXNDb250ZW50IjpbImV4cG9ydCBkZWZhdWx0IGZ1bmN0aW9uIGZvbyAoKSB7XG5cdGNvbnNvbGUubG9nKCAnaGVsbG8gZnJvbSBmb28uanMnICk7XG59XG4iLCJleHBvcnQgZGVmYXVsdCBmdW5jdGlvbiBiYXIgKCkge1xuXHRjb25zb2xlLmxvZyggJ2hlbGxvIGZyb20gYmFyLmpzJyApO1xufVxuIiwiaW1wb3J0IGZvbyBmcm9tICcuL2Zvbyc7XG5pbXBvcnQgYmFyIGZyb20gJy4vYmFyJztcblxuY29uc29sZS5sb2coICdoZWxsbyBmcm9tIG1haW4uanMnICk7XG5cbmZvbygpO1xuYmFyKCk7XG4iXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Q0FBZSxTQUFTLEdBQUcsSUFBSTtDQUMvQixDQUFDLE9BQU8sQ0FBQyxHQUFHLEVBQUUsbUJBQW1CLEVBQUUsQ0FBQztDQUNwQzs7Q0NGZSxTQUFTLEdBQUcsSUFBSTtDQUMvQixDQUFDLE9BQU8sQ0FBQyxHQUFHLEVBQUUsbUJBQW1CLEVBQUUsQ0FBQztDQUNwQzs7Q0NDQSxPQUFPLENBQUMsR0FBRyxFQUFFLG9CQUFvQixFQUFFLENBQUM7QUFDcEM7Q0FDQSxHQUFHLEVBQUUsQ0FBQztDQUNOLEdBQUcsRUFBRTs7Ozs7OyJ9 +})); +//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidW1kLmpzIiwic291cmNlcyI6WyIuLi9mb28uanMiLCIuLi9iYXIuanMiLCIuLi9tYWluLmpzIl0sInNvdXJjZXNDb250ZW50IjpbImV4cG9ydCBkZWZhdWx0IGZ1bmN0aW9uIGZvbyAoKSB7XG5cdGNvbnNvbGUubG9nKCAnaGVsbG8gZnJvbSBmb28uanMnICk7XG59XG4iLCJleHBvcnQgZGVmYXVsdCBmdW5jdGlvbiBiYXIgKCkge1xuXHRjb25zb2xlLmxvZyggJ2hlbGxvIGZyb20gYmFyLmpzJyApO1xufVxuIiwiaW1wb3J0IGZvbyBmcm9tICcuL2Zvbyc7XG5pbXBvcnQgYmFyIGZyb20gJy4vYmFyJztcblxuY29uc29sZS5sb2coICdoZWxsbyBmcm9tIG1haW4uanMnICk7XG5cbmZvbygpO1xuYmFyKCk7XG4iXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Q0FBZSxTQUFTLEdBQUcsSUFBSTtDQUMvQixDQUFDLE9BQU8sQ0FBQyxHQUFHLEVBQUUsbUJBQW1CLEVBQUU7Q0FDbkM7O0NDRmUsU0FBUyxHQUFHLElBQUk7Q0FDL0IsQ0FBQyxPQUFPLENBQUMsR0FBRyxFQUFFLG1CQUFtQixFQUFFO0NBQ25DOztDQ0NBLE9BQU8sQ0FBQyxHQUFHLEVBQUUsb0JBQW9CLEVBQUU7O0NBRW5DLEdBQUcsRUFBRTtDQUNMLEdBQUcsRUFBRTs7Ozs7OyJ9 diff --git a/test/form/samples/spacing-after-function-with-semicolon/_config.js b/test/form/samples/spacing-after-function-with-semicolon/_config.js index 316c69d3613..2288a9c6c80 100644 --- a/test/form/samples/spacing-after-function-with-semicolon/_config.js +++ b/test/form/samples/spacing-after-function-with-semicolon/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'handles superfluous semicolons' -}; +}); diff --git a/test/form/samples/spacing-after-function-with-semicolon/_expected/amd.js b/test/form/samples/spacing-after-function-with-semicolon/_expected/amd.js index 382aff4862f..5e0b890fb4e 100644 --- a/test/form/samples/spacing-after-function-with-semicolon/_expected/amd.js +++ b/test/form/samples/spacing-after-function-with-semicolon/_expected/amd.js @@ -1,6 +1,6 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; function x () { return 'x' } assert.equal( x(), 'x' ); -}); +})); diff --git a/test/form/samples/spacing-after-function-with-semicolon/_expected/iife.js b/test/form/samples/spacing-after-function-with-semicolon/_expected/iife.js index 662b2220277..627d0202446 100644 --- a/test/form/samples/spacing-after-function-with-semicolon/_expected/iife.js +++ b/test/form/samples/spacing-after-function-with-semicolon/_expected/iife.js @@ -4,4 +4,4 @@ function x () { return 'x' } assert.equal( x(), 'x' ); -}()); +})(); diff --git a/test/form/samples/spacing-after-function-with-semicolon/_expected/system.js b/test/form/samples/spacing-after-function-with-semicolon/_expected/system.js index 6aaf80d1aca..3af6ff7cef8 100644 --- a/test/form/samples/spacing-after-function-with-semicolon/_expected/system.js +++ b/test/form/samples/spacing-after-function-with-semicolon/_expected/system.js @@ -1,11 +1,11 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { function x () { return 'x' } assert.equal( x(), 'x' ); - } + }) }; -}); +})); diff --git a/test/form/samples/spacing-after-function-with-semicolon/_expected/umd.js b/test/form/samples/spacing-after-function-with-semicolon/_expected/umd.js index 5e97fddc678..c5ad1a351fb 100644 --- a/test/form/samples/spacing-after-function-with-semicolon/_expected/umd.js +++ b/test/form/samples/spacing-after-function-with-semicolon/_expected/umd.js @@ -1,9 +1,9 @@ (function (factory) { typeof define === 'function' && define.amd ? define(factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; function x () { return 'x' } assert.equal( x(), 'x' ); -}))); +})); diff --git a/test/form/samples/static-block-render/_config.js b/test/form/samples/static-block-render/_config.js new file mode 100644 index 00000000000..980aefe230f --- /dev/null +++ b/test/form/samples/static-block-render/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'Correctly render treeshaked inline static blocks' +}); diff --git a/test/form/samples/static-block-render/_expected.js b/test/form/samples/static-block-render/_expected.js new file mode 100644 index 00000000000..f4994541b3c --- /dev/null +++ b/test/form/samples/static-block-render/_expected.js @@ -0,0 +1,9 @@ +class Foo { + static /* { */ {} +} + +class Bar { + static {} +} + +export { Bar, Foo }; diff --git a/test/form/samples/static-block-render/main.js b/test/form/samples/static-block-render/main.js new file mode 100644 index 00000000000..1b45a390542 --- /dev/null +++ b/test/form/samples/static-block-render/main.js @@ -0,0 +1,7 @@ +export class Foo { + static /* { */ {/** 1 */1} +} + +export class Bar { + static {1} +} diff --git a/test/form/samples/static-class-property-calls/_config.js b/test/form/samples/static-class-property-calls/_config.js new file mode 100644 index 00000000000..e509c2ff68e --- /dev/null +++ b/test/form/samples/static-class-property-calls/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'handles effects when calling static class properties' +}); diff --git a/test/form/samples/static-class-property-calls/_expected.js b/test/form/samples/static-class-property-calls/_expected.js new file mode 100644 index 00000000000..e2589637c16 --- /dev/null +++ b/test/form/samples/static-class-property-calls/_expected.js @@ -0,0 +1,21 @@ +class Foo { + static isTrue = () => true; + static noEffect = () => {}; + static effect = () => console.log('effect'); + static missing; +} + +console.log('retained'); +Foo.effect(); +Foo.missing(); + +class Bar { + static flag = false + static mutate = function() { + this.flag = true; + } +} + +Bar.mutate(); +if (Bar.flag) console.log('retained'); +else console.log('unimportant'); diff --git a/test/form/samples/static-class-property-calls/main.js b/test/form/samples/static-class-property-calls/main.js new file mode 100644 index 00000000000..4259adcdb71 --- /dev/null +++ b/test/form/samples/static-class-property-calls/main.js @@ -0,0 +1,23 @@ +class Foo { + static isTrue = () => true; + static noEffect = () => {}; + static effect = () => console.log('effect'); + static missing; +} + +if (Foo.isTrue()) console.log('retained'); +else console.log('removed'); +Foo.noEffect(); +Foo.effect(); +Foo.missing(); + +class Bar { + static flag = false + static mutate = function() { + this.flag = true; + } +} + +Bar.mutate(); +if (Bar.flag) console.log('retained'); +else console.log('unimportant'); diff --git a/test/form/samples/static-method-deoptimization/_config.js b/test/form/samples/static-method-deoptimization/_config.js new file mode 100644 index 00000000000..39cfe865b77 --- /dev/null +++ b/test/form/samples/static-method-deoptimization/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'avoids infinite recursions when deoptimizing "this" context' +}); diff --git a/test/form/samples/static-method-deoptimization/_expected.js b/test/form/samples/static-method-deoptimization/_expected.js new file mode 100644 index 00000000000..e3db19a59fe --- /dev/null +++ b/test/form/samples/static-method-deoptimization/_expected.js @@ -0,0 +1,13 @@ +class Foo { + static echo(message) { + this.prototype.echo(message); + } + echo(message) { + console.log(message); + } +} + +class Bar extends Foo {} + +global.baz = 'PASS'; +Bar.echo(baz); diff --git a/test/form/samples/static-method-deoptimization/main.js b/test/form/samples/static-method-deoptimization/main.js new file mode 100644 index 00000000000..e3db19a59fe --- /dev/null +++ b/test/form/samples/static-method-deoptimization/main.js @@ -0,0 +1,13 @@ +class Foo { + static echo(message) { + this.prototype.echo(message); + } + echo(message) { + console.log(message); + } +} + +class Bar extends Foo {} + +global.baz = 'PASS'; +Bar.echo(baz); diff --git a/test/form/samples/strict-false/_config.js b/test/form/samples/strict-false/_config.js index dac5b866925..25e1e8f0445 100644 --- a/test/form/samples/strict-false/_config.js +++ b/test/form/samples/strict-false/_config.js @@ -1,8 +1,8 @@ -module.exports = { +module.exports = defineTest({ description: 'use strict should not be present', options: { output: { strict: false } } -}; +}); diff --git a/test/form/samples/strict-false/_expected/amd.js b/test/form/samples/strict-false/_expected/amd.js index 374a89b69eb..f7252f408df 100644 --- a/test/form/samples/strict-false/_expected/amd.js +++ b/test/form/samples/strict-false/_expected/amd.js @@ -1,4 +1,4 @@ -define(function () { +define((function () { const localVariable = 'local'; @@ -10,4 +10,4 @@ define(function () { Function("g", "globalVariable = g")(localVariable); } -}); +})); diff --git a/test/form/samples/strict-false/_expected/iife.js b/test/form/samples/strict-false/_expected/iife.js index ccbe45b59ad..f52fafa60de 100644 --- a/test/form/samples/strict-false/_expected/iife.js +++ b/test/form/samples/strict-false/_expected/iife.js @@ -10,4 +10,4 @@ Function("g", "globalVariable = g")(localVariable); } -}()); +})(); diff --git a/test/form/samples/strict-false/_expected/system.js b/test/form/samples/strict-false/_expected/system.js index 2ed282add3d..f490bc06aa5 100644 --- a/test/form/samples/strict-false/_expected/system.js +++ b/test/form/samples/strict-false/_expected/system.js @@ -1,7 +1,7 @@ -System.register([], function () { +System.register([], (function () { return { - execute: function () { + execute: (function () { const localVariable = 'local'; @@ -13,6 +13,6 @@ System.register([], function () { Function("g", "globalVariable = g")(localVariable); } - } + }) }; -}); +})); diff --git a/test/form/samples/strict-false/_expected/umd.js b/test/form/samples/strict-false/_expected/umd.js index 769abec87ec..5182de030f1 100644 --- a/test/form/samples/strict-false/_expected/umd.js +++ b/test/form/samples/strict-false/_expected/umd.js @@ -1,7 +1,7 @@ (function (factory) { typeof define === 'function' && define.amd ? define(factory) : factory(); -}((function () { +})((function () { const localVariable = 'local'; try { @@ -12,4 +12,4 @@ Function("g", "globalVariable = g")(localVariable); } -}))); +})); diff --git a/test/form/samples/string-indentation-b/_config.js b/test/form/samples/string-indentation-b/_config.js index f6c6cbeb903..14c82d9a93b 100644 --- a/test/form/samples/string-indentation-b/_config.js +++ b/test/form/samples/string-indentation-b/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'handles multiple var declarations inited to strings (#166)', options: { output: { name: 'myBundle' } } -}; +}); diff --git a/test/form/samples/string-indentation-b/_expected/amd.js b/test/form/samples/string-indentation-b/_expected/amd.js index 2daf4553a67..88dfbdc1a18 100644 --- a/test/form/samples/string-indentation-b/_expected/amd.js +++ b/test/form/samples/string-indentation-b/_expected/amd.js @@ -1,4 +1,4 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; var a = 'a', b = 'b'; @@ -6,4 +6,4 @@ define(function () { 'use strict'; assert.equal( a, 'a' ); assert.equal( b, 'b' ); -}); +})); diff --git a/test/form/samples/string-indentation-b/_expected/iife.js b/test/form/samples/string-indentation-b/_expected/iife.js index 4261ea90ab2..cd2ffb8ed70 100644 --- a/test/form/samples/string-indentation-b/_expected/iife.js +++ b/test/form/samples/string-indentation-b/_expected/iife.js @@ -7,4 +7,4 @@ assert.equal( a, 'a' ); assert.equal( b, 'b' ); -}()); +})(); diff --git a/test/form/samples/string-indentation-b/_expected/system.js b/test/form/samples/string-indentation-b/_expected/system.js index 89acd2e8859..627e93f6f95 100644 --- a/test/form/samples/string-indentation-b/_expected/system.js +++ b/test/form/samples/string-indentation-b/_expected/system.js @@ -1,7 +1,7 @@ -System.register('myBundle', [], function () { +System.register('myBundle', [], (function () { 'use strict'; return { - execute: function () { + execute: (function () { var a = 'a', b = 'b'; @@ -9,6 +9,6 @@ System.register('myBundle', [], function () { assert.equal( a, 'a' ); assert.equal( b, 'b' ); - } + }) }; -}); +})); diff --git a/test/form/samples/string-indentation-b/_expected/umd.js b/test/form/samples/string-indentation-b/_expected/umd.js index 49eee3e6de0..414138112bf 100644 --- a/test/form/samples/string-indentation-b/_expected/umd.js +++ b/test/form/samples/string-indentation-b/_expected/umd.js @@ -1,7 +1,7 @@ (function (factory) { typeof define === 'function' && define.amd ? define(factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; var a = 'a', b = 'b'; @@ -9,4 +9,4 @@ assert.equal( a, 'a' ); assert.equal( b, 'b' ); -}))); +})); diff --git a/test/form/samples/string-indentation/_config.js b/test/form/samples/string-indentation/_config.js index 1aebe39f9ae..e3a4270ff75 100644 --- a/test/form/samples/string-indentation/_config.js +++ b/test/form/samples/string-indentation/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'indentation is preserved in multi-line strings' -}; +}); diff --git a/test/form/samples/string-indentation/_expected/amd.js b/test/form/samples/string-indentation/_expected/amd.js index ef51dfa436f..194334076d3 100644 --- a/test/form/samples/string-indentation/_expected/amd.js +++ b/test/form/samples/string-indentation/_expected/amd.js @@ -1,4 +1,4 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; var a = '1\ 2'; @@ -17,4 +17,4 @@ define(function () { 'use strict'; assert.equal( c, '1\n 2' ); assert.equal( d, '1\n\t2' ); -}); +})); diff --git a/test/form/samples/string-indentation/_expected/iife.js b/test/form/samples/string-indentation/_expected/iife.js index c2426fa7dee..180f703840f 100644 --- a/test/form/samples/string-indentation/_expected/iife.js +++ b/test/form/samples/string-indentation/_expected/iife.js @@ -18,4 +18,4 @@ assert.equal( c, '1\n 2' ); assert.equal( d, '1\n\t2' ); -}()); +})(); diff --git a/test/form/samples/string-indentation/_expected/system.js b/test/form/samples/string-indentation/_expected/system.js index 7985b867682..537436a270f 100644 --- a/test/form/samples/string-indentation/_expected/system.js +++ b/test/form/samples/string-indentation/_expected/system.js @@ -1,7 +1,7 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { var a = '1\ 2'; @@ -20,6 +20,6 @@ System.register([], function () { assert.equal( c, '1\n 2' ); assert.equal( d, '1\n\t2' ); - } + }) }; -}); +})); diff --git a/test/form/samples/string-indentation/_expected/umd.js b/test/form/samples/string-indentation/_expected/umd.js index bf521300b55..50d1c7bd89f 100644 --- a/test/form/samples/string-indentation/_expected/umd.js +++ b/test/form/samples/string-indentation/_expected/umd.js @@ -1,7 +1,7 @@ (function (factory) { typeof define === 'function' && define.amd ? define(factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; var a = '1\ 2'; @@ -20,4 +20,4 @@ assert.equal( c, '1\n 2' ); assert.equal( d, '1\n\t2' ); -}))); +})); diff --git a/test/form/samples/string-replace-side-effects/_config.js b/test/form/samples/string-replace-side-effects/_config.js new file mode 100644 index 00000000000..6aff9cab951 --- /dev/null +++ b/test/form/samples/string-replace-side-effects/_config.js @@ -0,0 +1,4 @@ +module.exports = defineTest({ + description: + 'does not assume string.replace has side effects when called with a string as second argument' +}); diff --git a/test/form/samples/string-replace-side-effects/_expected.js b/test/form/samples/string-replace-side-effects/_expected.js new file mode 100644 index 00000000000..9a15559a7ab --- /dev/null +++ b/test/form/samples/string-replace-side-effects/_expected.js @@ -0,0 +1,8 @@ +'foo'.replace('o', () => { + console.log('retained'); + return '_'; +}); +'foo'.replaceAll('o', () => { + console.log('retained'); + return '_'; +}); diff --git a/test/form/samples/string-replace-side-effects/main.js b/test/form/samples/string-replace-side-effects/main.js new file mode 100644 index 00000000000..543d9be73c6 --- /dev/null +++ b/test/form/samples/string-replace-side-effects/main.js @@ -0,0 +1,13 @@ +'foo'.replace('o', 'removed'); +'foo'.replace('o', () => 'removed'); +'foo'.replace('o', () => { + console.log('retained'); + return '_'; +}); + +'foo'.replaceAll('o', 'removed'); +'foo'.replaceAll('o', () => 'removed'); +'foo'.replaceAll('o', () => { + console.log('retained'); + return '_'; +}); diff --git a/test/form/samples/super-class-no-side-effects/_config.js b/test/form/samples/super-class-no-side-effects/_config.js new file mode 100644 index 00000000000..17c0fea9b99 --- /dev/null +++ b/test/form/samples/super-class-no-side-effects/_config.js @@ -0,0 +1,5 @@ +module.exports = defineTest({ + description: + 'Does not wrongly attribute side effects when the super class of an unused class is in a file without side effects (#4808)', + options: { treeshake: { moduleSideEffects: false } } +}); diff --git a/test/form/samples/super-class-no-side-effects/_expected.js b/test/form/samples/super-class-no-side-effects/_expected.js new file mode 100644 index 00000000000..c0b933d7b56 --- /dev/null +++ b/test/form/samples/super-class-no-side-effects/_expected.js @@ -0,0 +1 @@ +console.log('main'); diff --git a/test/form/samples/super-class-no-side-effects/main.js b/test/form/samples/super-class-no-side-effects/main.js new file mode 100644 index 00000000000..6c6ebe16312 --- /dev/null +++ b/test/form/samples/super-class-no-side-effects/main.js @@ -0,0 +1,10 @@ +import { ExternalElement } from './other.js'; + +class MyClass extends ExternalElement { + constructor() { + super(); + console.log('MyClassExtendsExternalClass'); + } +} + +console.log('main'); diff --git a/test/form/samples/super-class-no-side-effects/other.js b/test/form/samples/super-class-no-side-effects/other.js new file mode 100644 index 00000000000..58c8ab48310 --- /dev/null +++ b/test/form/samples/super-class-no-side-effects/other.js @@ -0,0 +1,2 @@ +const win = typeof window !== 'undefined' ? window : {}; +export const ExternalElement = win.HTMLElement || class {}; diff --git a/test/form/samples/super-classes/super-class-prototype-access/_config.js b/test/form/samples/super-classes/super-class-prototype-access/_config.js new file mode 100644 index 00000000000..7f105452427 --- /dev/null +++ b/test/form/samples/super-classes/super-class-prototype-access/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'correctly resolves the prototype of the super class when accessing properties' +}); diff --git a/test/form/samples/super-classes/super-class-prototype-access/_expected.js b/test/form/samples/super-classes/super-class-prototype-access/_expected.js new file mode 100644 index 00000000000..b6203e675ca --- /dev/null +++ b/test/form/samples/super-classes/super-class-prototype-access/_expected.js @@ -0,0 +1,7 @@ +class SuperAccess { + prop = {}; + method() {} +} +class Access extends SuperAccess {} +Access.prototype.doesNoExist.throws; +Access.prototype.prop.throws; diff --git a/test/form/samples/super-classes/super-class-prototype-access/main.js b/test/form/samples/super-classes/super-class-prototype-access/main.js new file mode 100644 index 00000000000..240e4365a28 --- /dev/null +++ b/test/form/samples/super-classes/super-class-prototype-access/main.js @@ -0,0 +1,9 @@ +class SuperAccess { + prop = {}; + method() {} +} +class Access extends SuperAccess {} + +Access.prototype.doesNoExist; +Access.prototype.doesNoExist.throws; +Access.prototype.prop.throws; diff --git a/test/form/samples/super-classes/super-class-prototype-assignment/_config.js b/test/form/samples/super-classes/super-class-prototype-assignment/_config.js new file mode 100644 index 00000000000..3f32e053f7b --- /dev/null +++ b/test/form/samples/super-classes/super-class-prototype-assignment/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'correctly resolves the prototype of the super class when assigning properites' +}); diff --git a/test/form/samples/super-classes/super-class-prototype-assignment/_expected.js b/test/form/samples/super-classes/super-class-prototype-assignment/_expected.js new file mode 100644 index 00000000000..840f9a4d6c1 --- /dev/null +++ b/test/form/samples/super-classes/super-class-prototype-assignment/_expected.js @@ -0,0 +1,31 @@ +class SuperUsedAssign { + method() {} +} +class UsedAssign extends SuperUsedAssign {} +UsedAssign.prototype.doesNotExist = 1; +UsedAssign.prototype.method.doesNotExist = 1; +console.log(UsedAssign); + +class SuperAssign1 {} +class Assign1 extends SuperAssign1 {} +Assign1.prototype.doesNotExist.throws = 1; + +class SuperAssign2 { + prop = {}; +} +class Assign2 extends SuperAssign2 {} +Assign2.prototype.prop.throws = 1; + +class SuperAssign3 { + method() {} +} +class Assign3 extends SuperAssign3 {} +Assign3.prototype.method.doesNotExist.throws = 1; + +class SuperAssign4 { + set prop(v) { + console.log('effect', v); + } +} +class Assign4 extends SuperAssign4 {} +Assign4.prototype.prop = 1; diff --git a/test/form/samples/super-classes/super-class-prototype-assignment/main.js b/test/form/samples/super-classes/super-class-prototype-assignment/main.js new file mode 100644 index 00000000000..06ef7c3d692 --- /dev/null +++ b/test/form/samples/super-classes/super-class-prototype-assignment/main.js @@ -0,0 +1,38 @@ +class SuperRemovedAssign { + set prop(v) {} +} +class RemovedAssign extends SuperRemovedAssign {} +RemovedAssign.prototype.doesNotExist = 1; +RemovedAssign.prototype.prop = 1; + +class SuperUsedAssign { + method() {} +} +class UsedAssign extends SuperUsedAssign {} +UsedAssign.prototype.doesNotExist = 1; +UsedAssign.prototype.method.doesNotExist = 1; +console.log(UsedAssign); + +class SuperAssign1 {} +class Assign1 extends SuperAssign1 {} +Assign1.prototype.doesNotExist.throws = 1; + +class SuperAssign2 { + prop = {}; +} +class Assign2 extends SuperAssign2 {} +Assign2.prototype.prop.throws = 1; + +class SuperAssign3 { + method() {} +} +class Assign3 extends SuperAssign3 {} +Assign3.prototype.method.doesNotExist.throws = 1; + +class SuperAssign4 { + set prop(v) { + console.log('effect', v); + } +} +class Assign4 extends SuperAssign4 {} +Assign4.prototype.prop = 1; diff --git a/test/form/samples/super-classes/super-class-prototype-calls/_config.js b/test/form/samples/super-classes/super-class-prototype-calls/_config.js new file mode 100644 index 00000000000..1d6db9af630 --- /dev/null +++ b/test/form/samples/super-classes/super-class-prototype-calls/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'correctly resolves the prototype of the super class when calling properties' +}); diff --git a/test/form/samples/super-classes/super-class-prototype-calls/_expected.js b/test/form/samples/super-classes/super-class-prototype-calls/_expected.js new file mode 100644 index 00000000000..9f4197f314d --- /dev/null +++ b/test/form/samples/super-classes/super-class-prototype-calls/_expected.js @@ -0,0 +1,20 @@ +class SuperValues { + get prop() { + return { + effect(used) { + console.log('effect', used); + }, + + }; + } + effect(used) { + console.log('effect', used); + } + isTrue() { + return true; + } +} +class Values extends SuperValues {} +console.log('retained'); +Values.prototype.effect(); +Values.prototype.prop.effect(); diff --git a/test/form/samples/super-classes/super-class-prototype-calls/main.js b/test/form/samples/super-classes/super-class-prototype-calls/main.js new file mode 100644 index 00000000000..2a66d55579a --- /dev/null +++ b/test/form/samples/super-classes/super-class-prototype-calls/main.js @@ -0,0 +1,21 @@ +class SuperValues { + get prop() { + return { + effect(used) { + console.log('effect', used); + }, + + }; + } + effect(used) { + console.log('effect', used); + } + isTrue() { + return true; + } +} +class Values extends SuperValues {} +if (Values.prototype.isTrue()) console.log('retained'); +else console.log('removed'); +Values.prototype.effect(); +Values.prototype.prop.effect(); diff --git a/test/form/samples/super-classes/super-class-prototype-values/_config.js b/test/form/samples/super-classes/super-class-prototype-values/_config.js new file mode 100644 index 00000000000..bad728fa423 --- /dev/null +++ b/test/form/samples/super-classes/super-class-prototype-values/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'correctly resolves the prototype of the super class when reading property values' +}); diff --git a/test/form/samples/super-classes/super-class-prototype-values/_expected.js b/test/form/samples/super-classes/super-class-prototype-values/_expected.js new file mode 100644 index 00000000000..4002b3a03aa --- /dev/null +++ b/test/form/samples/super-classes/super-class-prototype-values/_expected.js @@ -0,0 +1,12 @@ +console.log('retained'); + +const prop = { isTrue: true }; +class SuperDeopt { + get prop() { + return prop; + } +} +class Deopt extends SuperDeopt {} +Deopt.prototype.prop.isTrue = false; +if (Deopt.prototype.prop.isTrue) console.log('unimportant'); +else console.log('retained'); diff --git a/test/form/samples/super-classes/super-class-prototype-values/main.js b/test/form/samples/super-classes/super-class-prototype-values/main.js new file mode 100644 index 00000000000..12003a915de --- /dev/null +++ b/test/form/samples/super-classes/super-class-prototype-values/main.js @@ -0,0 +1,22 @@ +class SuperValues { + get isTrue() { + return true; + } + get prop() { + return { isTrue: true }; + } +} +class Values extends SuperValues {} +if (Values.prototype.isTrue) console.log('retained'); +else console.log('removed'); + +const prop = { isTrue: true }; +class SuperDeopt { + get prop() { + return prop; + } +} +class Deopt extends SuperDeopt {} +Deopt.prototype.prop.isTrue = false; +if (Deopt.prototype.prop.isTrue) console.log('unimportant'); +else console.log('retained'); diff --git a/test/form/samples/support-decorators-after-export/_config.js b/test/form/samples/support-decorators-after-export/_config.js new file mode 100644 index 00000000000..474fa9f9bff --- /dev/null +++ b/test/form/samples/support-decorators-after-export/_config.js @@ -0,0 +1,4 @@ +module.exports = defineTest({ + description: 'support decorators after export', + verifyAst: false +}); diff --git a/test/form/samples/support-decorators-after-export/_expected.js b/test/form/samples/support-decorators-after-export/_expected.js new file mode 100644 index 00000000000..b07a41170ae --- /dev/null +++ b/test/form/samples/support-decorators-after-export/_expected.js @@ -0,0 +1,8 @@ +@decorator +@decorator2 +class AfterExport {} + +@decorator +class AfterDefaultExport {} + +export { AfterExport, AfterDefaultExport as default }; diff --git a/test/form/samples/support-decorators-after-export/main.js b/test/form/samples/support-decorators-after-export/main.js new file mode 100644 index 00000000000..c6e3b0e6fa9 --- /dev/null +++ b/test/form/samples/support-decorators-after-export/main.js @@ -0,0 +1,8 @@ +export +@decorator +@decorator2 +class AfterExport {} + +export default +@decorator +class AfterDefaultExport {} diff --git a/test/form/samples/support-decorators-before-export/_config.js b/test/form/samples/support-decorators-before-export/_config.js new file mode 100644 index 00000000000..e35aef136db --- /dev/null +++ b/test/form/samples/support-decorators-before-export/_config.js @@ -0,0 +1,4 @@ +module.exports = defineTest({ + description: 'support decorators before export', + verifyAst: false +}); diff --git a/test/form/samples/support-decorators-before-export/_expected.js b/test/form/samples/support-decorators-before-export/_expected.js new file mode 100644 index 00000000000..92c5b391c85 --- /dev/null +++ b/test/form/samples/support-decorators-before-export/_expected.js @@ -0,0 +1,8 @@ +@decorator +class BeforeExport {} + +@decorator +@decorator2 +class BeforeDefaultExport {} + +export { BeforeExport, BeforeDefaultExport as default }; diff --git a/test/form/samples/support-decorators-before-export/main.js b/test/form/samples/support-decorators-before-export/main.js new file mode 100644 index 00000000000..f141c824b12 --- /dev/null +++ b/test/form/samples/support-decorators-before-export/main.js @@ -0,0 +1,6 @@ +@decorator +export class BeforeExport {} + +@decorator +@decorator2 +export default class BeforeDefaultExport {} diff --git a/test/form/samples/support-using-keyword/_config.js b/test/form/samples/support-using-keyword/_config.js new file mode 100644 index 00000000000..8aa7547295a --- /dev/null +++ b/test/form/samples/support-using-keyword/_config.js @@ -0,0 +1,4 @@ +module.exports = defineTest({ + description: 'Support `using` keyword', + verifyAst: false +}); diff --git a/test/form/samples/support-using-keyword/_expected.js b/test/form/samples/support-using-keyword/_expected.js new file mode 100644 index 00000000000..59844d04d04 --- /dev/null +++ b/test/form/samples/support-using-keyword/_expected.js @@ -0,0 +1,24 @@ +const logClean = function () { + return { + [Symbol.dispose]() { + console.log('clean in sync'); + }, + [Symbol.asyncDispose]() { + console.log('clean in async'); + } + }; +}; + +async function foo() { + using a = logClean(); + + await using b = logClean(); + + for (using a of [logClean(), logClean()]) { + } + + for (await using a of [logClean(), logClean()]) { + } +} + +foo(); diff --git a/test/form/samples/support-using-keyword/main.js b/test/form/samples/support-using-keyword/main.js new file mode 100644 index 00000000000..8ad41bdd3e5 --- /dev/null +++ b/test/form/samples/support-using-keyword/main.js @@ -0,0 +1,25 @@ +const logClean = function () { + return { + [Symbol.dispose]() { + console.log('clean in sync'); + }, + [Symbol.asyncDispose]() { + console.log('clean in async'); + } + }; +}; + +async function foo() { + using a = logClean(); + const aa = a; + + await using b = logClean(); + + for (using a of [logClean(), logClean()]) { + } + + for (await using a of [logClean(), logClean()]) { + } +} + +foo(); diff --git a/test/form/samples/supports-core-js/_config.js b/test/form/samples/supports-core-js/_config.js index ffbfcc0adea..070775017f3 100644 --- a/test/form/samples/supports-core-js/_config.js +++ b/test/form/samples/supports-core-js/_config.js @@ -1,5 +1,6 @@ -module.exports = { +module.exports = defineTest({ description: 'supports core-js', + verifyAst: false, options: { // check against tree-shake: false when updating the polyfill treeshake: true, @@ -8,4 +9,4 @@ module.exports = { require('@rollup/plugin-commonjs')() ] } -}; +}); diff --git a/test/form/samples/supports-core-js/_expected.js b/test/form/samples/supports-core-js/_expected.js index 4ce8dbd8e9d..235efe8ce52 100644 --- a/test/form/samples/supports-core-js/_expected.js +++ b/test/form/samples/supports-core-js/_expected.js @@ -1,13732 +1,29443 @@ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; -var check = function (it) { - return it && it.Math == Math && it; -}; - -// https://github.com/zloirock/core-js/issues/86#issuecomment-115759028 -var global$L = - // eslint-disable-next-line no-undef - check(typeof globalThis == 'object' && globalThis) || - check(typeof window == 'object' && window) || - check(typeof self == 'object' && self) || - check(typeof commonjsGlobal == 'object' && commonjsGlobal) || - // eslint-disable-next-line no-new-func - (function () { return this; })() || Function('return this')(); +var es_symbol = {}; + +var es_symbol_constructor = {}; + +var globalThis_1; +var hasRequiredGlobalThis; + +function requireGlobalThis () { + if (hasRequiredGlobalThis) return globalThis_1; + hasRequiredGlobalThis = 1; + var check = function (it) { + return it && it.Math === Math && it; + }; + + // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028 + globalThis_1 = + // eslint-disable-next-line es/no-global-this -- safe + check(typeof globalThis == 'object' && globalThis) || + check(typeof window == 'object' && window) || + // eslint-disable-next-line no-restricted-globals -- safe + check(typeof self == 'object' && self) || + check(typeof commonjsGlobal == 'object' && commonjsGlobal) || + check(typeof globalThis_1 == 'object' && globalThis_1) || + // eslint-disable-next-line no-new-func -- fallback + (function () { return this; })() || Function('return this')(); + return globalThis_1; +} var objectGetOwnPropertyDescriptor = {}; -var fails$Y = function (exec) { - try { - return !!exec(); - } catch (error) { - return true; - } -}; +var fails; +var hasRequiredFails; + +function requireFails () { + if (hasRequiredFails) return fails; + hasRequiredFails = 1; + fails = function (exec) { + try { + return !!exec(); + } catch (error) { + return true; + } + }; + return fails; +} + +var descriptors; +var hasRequiredDescriptors; + +function requireDescriptors () { + if (hasRequiredDescriptors) return descriptors; + hasRequiredDescriptors = 1; + var fails = requireFails(); + + // Detect IE8's incomplete defineProperty implementation + descriptors = !fails(function () { + // eslint-disable-next-line es/no-object-defineproperty -- required for testing + return Object.defineProperty({}, 1, { get: function () { return 7; } })[1] !== 7; + }); + return descriptors; +} + +var functionBindNative; +var hasRequiredFunctionBindNative; + +function requireFunctionBindNative () { + if (hasRequiredFunctionBindNative) return functionBindNative; + hasRequiredFunctionBindNative = 1; + var fails = requireFails(); + + functionBindNative = !fails(function () { + // eslint-disable-next-line es/no-function-prototype-bind -- safe + var test = (function () { /* empty */ }).bind(); + // eslint-disable-next-line no-prototype-builtins -- safe + return typeof test != 'function' || test.hasOwnProperty('prototype'); + }); + return functionBindNative; +} + +var functionCall; +var hasRequiredFunctionCall; + +function requireFunctionCall () { + if (hasRequiredFunctionCall) return functionCall; + hasRequiredFunctionCall = 1; + var NATIVE_BIND = requireFunctionBindNative(); -var fails$X = fails$Y; + var call = Function.prototype.call; -// Detect IE8's incomplete defineProperty implementation -var descriptors = !fails$X(function () { - return Object.defineProperty({}, 1, { get: function () { return 7; } })[1] != 7; -}); + functionCall = NATIVE_BIND ? call.bind(call) : function () { + return call.apply(call, arguments); + }; + return functionCall; +} var objectPropertyIsEnumerable = {}; -var nativePropertyIsEnumerable$1 = {}.propertyIsEnumerable; -var getOwnPropertyDescriptor$8 = Object.getOwnPropertyDescriptor; - -// Nashorn ~ JDK8 bug -var NASHORN_BUG = getOwnPropertyDescriptor$8 && !nativePropertyIsEnumerable$1.call({ 1: 2 }, 1); - -// `Object.prototype.propertyIsEnumerable` method implementation -// https://tc39.es/ecma262/#sec-object.prototype.propertyisenumerable -objectPropertyIsEnumerable.f = NASHORN_BUG ? function propertyIsEnumerable(V) { - var descriptor = getOwnPropertyDescriptor$8(this, V); - return !!descriptor && descriptor.enumerable; -} : nativePropertyIsEnumerable$1; - -var createPropertyDescriptor$9 = function (bitmap, value) { - return { - enumerable: !(bitmap & 1), - configurable: !(bitmap & 2), - writable: !(bitmap & 4), - value: value - }; -}; - -var toString$2 = {}.toString; - -var classofRaw$1 = function (it) { - return toString$2.call(it).slice(8, -1); -}; - -var fails$W = fails$Y; -var classof$d = classofRaw$1; - -var split = ''.split; - -// fallback for non-array-like ES3 and non-enumerable old V8 strings -var indexedObject = fails$W(function () { - // throws an error in rhino, see https://github.com/mozilla/rhino/issues/346 - // eslint-disable-next-line no-prototype-builtins - return !Object('z').propertyIsEnumerable(0); -}) ? function (it) { - return classof$d(it) == 'String' ? split.call(it, '') : Object(it); -} : Object; - -// `RequireObjectCoercible` abstract operation -// https://tc39.es/ecma262/#sec-requireobjectcoercible -var requireObjectCoercible$h = function (it) { - if (it == undefined) throw TypeError("Can't call method on " + it); - return it; -}; - -// toObject with fallback for non-array-like ES3 strings -var IndexedObject$4 = indexedObject; -var requireObjectCoercible$g = requireObjectCoercible$h; - -var toIndexedObject$d = function (it) { - return IndexedObject$4(requireObjectCoercible$g(it)); -}; - -var isObject$B = function (it) { - return typeof it === 'object' ? it !== null : typeof it === 'function'; -}; - -var isObject$A = isObject$B; - -// `ToPrimitive` abstract operation -// https://tc39.es/ecma262/#sec-toprimitive -// instead of the ES6 spec version, we didn't implement @@toPrimitive case -// and the second argument - flag - preferred type is a string -var toPrimitive$b = function (input, PREFERRED_STRING) { - if (!isObject$A(input)) return input; - var fn, val; - if (PREFERRED_STRING && typeof (fn = input.toString) == 'function' && !isObject$A(val = fn.call(input))) return val; - if (typeof (fn = input.valueOf) == 'function' && !isObject$A(val = fn.call(input))) return val; - if (!PREFERRED_STRING && typeof (fn = input.toString) == 'function' && !isObject$A(val = fn.call(input))) return val; - throw TypeError("Can't convert object to primitive value"); -}; - -var hasOwnProperty = {}.hasOwnProperty; - -var has$o = function (it, key) { - return hasOwnProperty.call(it, key); -}; - -var global$K = global$L; -var isObject$z = isObject$B; - -var document$3 = global$K.document; -// typeof document.createElement is 'object' in old IE -var EXISTS = isObject$z(document$3) && isObject$z(document$3.createElement); - -var documentCreateElement$1 = function (it) { - return EXISTS ? document$3.createElement(it) : {}; -}; - -var DESCRIPTORS$z = descriptors; -var fails$V = fails$Y; -var createElement$1 = documentCreateElement$1; - -// Thank's IE8 for his funny defineProperty -var ie8DomDefine = !DESCRIPTORS$z && !fails$V(function () { - return Object.defineProperty(createElement$1('div'), 'a', { - get: function () { return 7; } - }).a != 7; -}); - -var DESCRIPTORS$y = descriptors; -var propertyIsEnumerableModule$2 = objectPropertyIsEnumerable; -var createPropertyDescriptor$8 = createPropertyDescriptor$9; -var toIndexedObject$c = toIndexedObject$d; -var toPrimitive$a = toPrimitive$b; -var has$n = has$o; -var IE8_DOM_DEFINE$1 = ie8DomDefine; - -var nativeGetOwnPropertyDescriptor$3 = Object.getOwnPropertyDescriptor; - -// `Object.getOwnPropertyDescriptor` method -// https://tc39.es/ecma262/#sec-object.getownpropertydescriptor -objectGetOwnPropertyDescriptor.f = DESCRIPTORS$y ? nativeGetOwnPropertyDescriptor$3 : function getOwnPropertyDescriptor(O, P) { - O = toIndexedObject$c(O); - P = toPrimitive$a(P, true); - if (IE8_DOM_DEFINE$1) try { - return nativeGetOwnPropertyDescriptor$3(O, P); - } catch (error) { /* empty */ } - if (has$n(O, P)) return createPropertyDescriptor$8(!propertyIsEnumerableModule$2.f.call(O, P), O[P]); -}; +var hasRequiredObjectPropertyIsEnumerable; + +function requireObjectPropertyIsEnumerable () { + if (hasRequiredObjectPropertyIsEnumerable) return objectPropertyIsEnumerable; + hasRequiredObjectPropertyIsEnumerable = 1; + var $propertyIsEnumerable = {}.propertyIsEnumerable; + // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe + var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; + + // Nashorn ~ JDK8 bug + var NASHORN_BUG = getOwnPropertyDescriptor && !$propertyIsEnumerable.call({ 1: 2 }, 1); + + // `Object.prototype.propertyIsEnumerable` method implementation + // https://tc39.es/ecma262/#sec-object.prototype.propertyisenumerable + objectPropertyIsEnumerable.f = NASHORN_BUG ? function propertyIsEnumerable(V) { + var descriptor = getOwnPropertyDescriptor(this, V); + return !!descriptor && descriptor.enumerable; + } : $propertyIsEnumerable; + return objectPropertyIsEnumerable; +} + +var createPropertyDescriptor; +var hasRequiredCreatePropertyDescriptor; + +function requireCreatePropertyDescriptor () { + if (hasRequiredCreatePropertyDescriptor) return createPropertyDescriptor; + hasRequiredCreatePropertyDescriptor = 1; + createPropertyDescriptor = function (bitmap, value) { + return { + enumerable: !(bitmap & 1), + configurable: !(bitmap & 2), + writable: !(bitmap & 4), + value: value + }; + }; + return createPropertyDescriptor; +} + +var functionUncurryThis; +var hasRequiredFunctionUncurryThis; + +function requireFunctionUncurryThis () { + if (hasRequiredFunctionUncurryThis) return functionUncurryThis; + hasRequiredFunctionUncurryThis = 1; + var NATIVE_BIND = requireFunctionBindNative(); + + var FunctionPrototype = Function.prototype; + var call = FunctionPrototype.call; + var uncurryThisWithBind = NATIVE_BIND && FunctionPrototype.bind.bind(call, call); + + functionUncurryThis = NATIVE_BIND ? uncurryThisWithBind : function (fn) { + return function () { + return call.apply(fn, arguments); + }; + }; + return functionUncurryThis; +} + +var classofRaw; +var hasRequiredClassofRaw; + +function requireClassofRaw () { + if (hasRequiredClassofRaw) return classofRaw; + hasRequiredClassofRaw = 1; + var uncurryThis = requireFunctionUncurryThis(); + + var toString = uncurryThis({}.toString); + var stringSlice = uncurryThis(''.slice); + + classofRaw = function (it) { + return stringSlice(toString(it), 8, -1); + }; + return classofRaw; +} + +var indexedObject; +var hasRequiredIndexedObject; + +function requireIndexedObject () { + if (hasRequiredIndexedObject) return indexedObject; + hasRequiredIndexedObject = 1; + var uncurryThis = requireFunctionUncurryThis(); + var fails = requireFails(); + var classof = requireClassofRaw(); + + var $Object = Object; + var split = uncurryThis(''.split); + + // fallback for non-array-like ES3 and non-enumerable old V8 strings + indexedObject = fails(function () { + // throws an error in rhino, see https://github.com/mozilla/rhino/issues/346 + // eslint-disable-next-line no-prototype-builtins -- safe + return !$Object('z').propertyIsEnumerable(0); + }) ? function (it) { + return classof(it) === 'String' ? split(it, '') : $Object(it); + } : $Object; + return indexedObject; +} + +var isNullOrUndefined; +var hasRequiredIsNullOrUndefined; + +function requireIsNullOrUndefined () { + if (hasRequiredIsNullOrUndefined) return isNullOrUndefined; + hasRequiredIsNullOrUndefined = 1; + // we can't use just `it == null` since of `document.all` special case + // https://tc39.es/ecma262/#sec-IsHTMLDDA-internal-slot-aec + isNullOrUndefined = function (it) { + return it === null || it === undefined; + }; + return isNullOrUndefined; +} + +var requireObjectCoercible; +var hasRequiredRequireObjectCoercible; + +function requireRequireObjectCoercible () { + if (hasRequiredRequireObjectCoercible) return requireObjectCoercible; + hasRequiredRequireObjectCoercible = 1; + var isNullOrUndefined = requireIsNullOrUndefined(); + + var $TypeError = TypeError; + + // `RequireObjectCoercible` abstract operation + // https://tc39.es/ecma262/#sec-requireobjectcoercible + requireObjectCoercible = function (it) { + if (isNullOrUndefined(it)) throw new $TypeError("Can't call method on " + it); + return it; + }; + return requireObjectCoercible; +} + +var toIndexedObject; +var hasRequiredToIndexedObject; + +function requireToIndexedObject () { + if (hasRequiredToIndexedObject) return toIndexedObject; + hasRequiredToIndexedObject = 1; + // toObject with fallback for non-array-like ES3 strings + var IndexedObject = requireIndexedObject(); + var requireObjectCoercible = requireRequireObjectCoercible(); + + toIndexedObject = function (it) { + return IndexedObject(requireObjectCoercible(it)); + }; + return toIndexedObject; +} + +var isCallable; +var hasRequiredIsCallable; + +function requireIsCallable () { + if (hasRequiredIsCallable) return isCallable; + hasRequiredIsCallable = 1; + // https://tc39.es/ecma262/#sec-IsHTMLDDA-internal-slot + var documentAll = typeof document == 'object' && document.all; + + // `IsCallable` abstract operation + // https://tc39.es/ecma262/#sec-iscallable + // eslint-disable-next-line unicorn/no-typeof-undefined -- required for testing + isCallable = typeof documentAll == 'undefined' && documentAll !== undefined ? function (argument) { + return typeof argument == 'function' || argument === documentAll; + } : function (argument) { + return typeof argument == 'function'; + }; + return isCallable; +} + +var isObject; +var hasRequiredIsObject; + +function requireIsObject () { + if (hasRequiredIsObject) return isObject; + hasRequiredIsObject = 1; + var isCallable = requireIsCallable(); + + isObject = function (it) { + return typeof it == 'object' ? it !== null : isCallable(it); + }; + return isObject; +} + +var getBuiltIn; +var hasRequiredGetBuiltIn; + +function requireGetBuiltIn () { + if (hasRequiredGetBuiltIn) return getBuiltIn; + hasRequiredGetBuiltIn = 1; + var globalThis = requireGlobalThis(); + var isCallable = requireIsCallable(); + + var aFunction = function (argument) { + return isCallable(argument) ? argument : undefined; + }; + + getBuiltIn = function (namespace, method) { + return arguments.length < 2 ? aFunction(globalThis[namespace]) : globalThis[namespace] && globalThis[namespace][method]; + }; + return getBuiltIn; +} + +var objectIsPrototypeOf; +var hasRequiredObjectIsPrototypeOf; + +function requireObjectIsPrototypeOf () { + if (hasRequiredObjectIsPrototypeOf) return objectIsPrototypeOf; + hasRequiredObjectIsPrototypeOf = 1; + var uncurryThis = requireFunctionUncurryThis(); + + objectIsPrototypeOf = uncurryThis({}.isPrototypeOf); + return objectIsPrototypeOf; +} + +var environmentUserAgent; +var hasRequiredEnvironmentUserAgent; + +function requireEnvironmentUserAgent () { + if (hasRequiredEnvironmentUserAgent) return environmentUserAgent; + hasRequiredEnvironmentUserAgent = 1; + var globalThis = requireGlobalThis(); + + var navigator = globalThis.navigator; + var userAgent = navigator && navigator.userAgent; + + environmentUserAgent = userAgent ? String(userAgent) : ''; + return environmentUserAgent; +} + +var environmentV8Version; +var hasRequiredEnvironmentV8Version; + +function requireEnvironmentV8Version () { + if (hasRequiredEnvironmentV8Version) return environmentV8Version; + hasRequiredEnvironmentV8Version = 1; + var globalThis = requireGlobalThis(); + var userAgent = requireEnvironmentUserAgent(); + + var process = globalThis.process; + var Deno = globalThis.Deno; + var versions = process && process.versions || Deno && Deno.version; + var v8 = versions && versions.v8; + var match, version; + + if (v8) { + match = v8.split('.'); + // in old Chrome, versions of V8 isn't V8 = Chrome / 10 + // but their correct versions are not interesting for us + version = match[0] > 0 && match[0] < 4 ? 1 : +(match[0] + match[1]); + } + + // BrowserFS NodeJS `process` polyfill incorrectly set `.v8` to `0.0` + // so check `userAgent` even if `.v8` exists, but 0 + if (!version && userAgent) { + match = userAgent.match(/Edge\/(\d+)/); + if (!match || match[1] >= 74) { + match = userAgent.match(/Chrome\/(\d+)/); + if (match) version = +match[1]; + } + } + + environmentV8Version = version; + return environmentV8Version; +} + +var symbolConstructorDetection; +var hasRequiredSymbolConstructorDetection; + +function requireSymbolConstructorDetection () { + if (hasRequiredSymbolConstructorDetection) return symbolConstructorDetection; + hasRequiredSymbolConstructorDetection = 1; + /* eslint-disable es/no-symbol -- required for testing */ + var V8_VERSION = requireEnvironmentV8Version(); + var fails = requireFails(); + var globalThis = requireGlobalThis(); + + var $String = globalThis.String; + + // eslint-disable-next-line es/no-object-getownpropertysymbols -- required for testing + symbolConstructorDetection = !!Object.getOwnPropertySymbols && !fails(function () { + var symbol = Symbol('symbol detection'); + // Chrome 38 Symbol has incorrect toString conversion + // `get-own-property-symbols` polyfill symbols converted to object are not Symbol instances + // nb: Do not call `String` directly to avoid this being optimized out to `symbol+''` which will, + // of course, fail. + return !$String(symbol) || !(Object(symbol) instanceof Symbol) || + // Chrome 38-40 symbols are not inherited from DOM collections prototypes to instances + !Symbol.sham && V8_VERSION && V8_VERSION < 41; + }); + return symbolConstructorDetection; +} + +var useSymbolAsUid; +var hasRequiredUseSymbolAsUid; + +function requireUseSymbolAsUid () { + if (hasRequiredUseSymbolAsUid) return useSymbolAsUid; + hasRequiredUseSymbolAsUid = 1; + /* eslint-disable es/no-symbol -- required for testing */ + var NATIVE_SYMBOL = requireSymbolConstructorDetection(); + + useSymbolAsUid = NATIVE_SYMBOL + && !Symbol.sham + && typeof Symbol.iterator == 'symbol'; + return useSymbolAsUid; +} + +var isSymbol; +var hasRequiredIsSymbol; + +function requireIsSymbol () { + if (hasRequiredIsSymbol) return isSymbol; + hasRequiredIsSymbol = 1; + var getBuiltIn = requireGetBuiltIn(); + var isCallable = requireIsCallable(); + var isPrototypeOf = requireObjectIsPrototypeOf(); + var USE_SYMBOL_AS_UID = requireUseSymbolAsUid(); + + var $Object = Object; + + isSymbol = USE_SYMBOL_AS_UID ? function (it) { + return typeof it == 'symbol'; + } : function (it) { + var $Symbol = getBuiltIn('Symbol'); + return isCallable($Symbol) && isPrototypeOf($Symbol.prototype, $Object(it)); + }; + return isSymbol; +} + +var tryToString; +var hasRequiredTryToString; + +function requireTryToString () { + if (hasRequiredTryToString) return tryToString; + hasRequiredTryToString = 1; + var $String = String; + + tryToString = function (argument) { + try { + return $String(argument); + } catch (error) { + return 'Object'; + } + }; + return tryToString; +} + +var aCallable; +var hasRequiredACallable; + +function requireACallable () { + if (hasRequiredACallable) return aCallable; + hasRequiredACallable = 1; + var isCallable = requireIsCallable(); + var tryToString = requireTryToString(); + + var $TypeError = TypeError; + + // `Assert: IsCallable(argument) is true` + aCallable = function (argument) { + if (isCallable(argument)) return argument; + throw new $TypeError(tryToString(argument) + ' is not a function'); + }; + return aCallable; +} + +var getMethod; +var hasRequiredGetMethod; + +function requireGetMethod () { + if (hasRequiredGetMethod) return getMethod; + hasRequiredGetMethod = 1; + var aCallable = requireACallable(); + var isNullOrUndefined = requireIsNullOrUndefined(); + + // `GetMethod` abstract operation + // https://tc39.es/ecma262/#sec-getmethod + getMethod = function (V, P) { + var func = V[P]; + return isNullOrUndefined(func) ? undefined : aCallable(func); + }; + return getMethod; +} + +var ordinaryToPrimitive; +var hasRequiredOrdinaryToPrimitive; + +function requireOrdinaryToPrimitive () { + if (hasRequiredOrdinaryToPrimitive) return ordinaryToPrimitive; + hasRequiredOrdinaryToPrimitive = 1; + var call = requireFunctionCall(); + var isCallable = requireIsCallable(); + var isObject = requireIsObject(); + + var $TypeError = TypeError; + + // `OrdinaryToPrimitive` abstract operation + // https://tc39.es/ecma262/#sec-ordinarytoprimitive + ordinaryToPrimitive = function (input, pref) { + var fn, val; + if (pref === 'string' && isCallable(fn = input.toString) && !isObject(val = call(fn, input))) return val; + if (isCallable(fn = input.valueOf) && !isObject(val = call(fn, input))) return val; + if (pref !== 'string' && isCallable(fn = input.toString) && !isObject(val = call(fn, input))) return val; + throw new $TypeError("Can't convert object to primitive value"); + }; + return ordinaryToPrimitive; +} + +var sharedStore = {exports: {}}; + +var isPure; +var hasRequiredIsPure; + +function requireIsPure () { + if (hasRequiredIsPure) return isPure; + hasRequiredIsPure = 1; + isPure = false; + return isPure; +} + +var defineGlobalProperty; +var hasRequiredDefineGlobalProperty; + +function requireDefineGlobalProperty () { + if (hasRequiredDefineGlobalProperty) return defineGlobalProperty; + hasRequiredDefineGlobalProperty = 1; + var globalThis = requireGlobalThis(); + + // eslint-disable-next-line es/no-object-defineproperty -- safe + var defineProperty = Object.defineProperty; + + defineGlobalProperty = function (key, value) { + try { + defineProperty(globalThis, key, { value: value, configurable: true, writable: true }); + } catch (error) { + globalThis[key] = value; + } return value; + }; + return defineGlobalProperty; +} + +var hasRequiredSharedStore; + +function requireSharedStore () { + if (hasRequiredSharedStore) return sharedStore.exports; + hasRequiredSharedStore = 1; + var IS_PURE = requireIsPure(); + var globalThis = requireGlobalThis(); + var defineGlobalProperty = requireDefineGlobalProperty(); + + var SHARED = '__core-js_shared__'; + var store = sharedStore.exports = globalThis[SHARED] || defineGlobalProperty(SHARED, {}); + + (store.versions || (store.versions = [])).push({ + version: '3.38.1', + mode: IS_PURE ? 'pure' : 'global', + copyright: '© 2014-2024 Denis Pushkarev (zloirock.ru)', + license: 'https://github.com/zloirock/core-js/blob/v3.38.1/LICENSE', + source: 'https://github.com/zloirock/core-js' + }); + return sharedStore.exports; +} + +var shared; +var hasRequiredShared; + +function requireShared () { + if (hasRequiredShared) return shared; + hasRequiredShared = 1; + var store = requireSharedStore(); + + shared = function (key, value) { + return store[key] || (store[key] = value || {}); + }; + return shared; +} + +var toObject; +var hasRequiredToObject; + +function requireToObject () { + if (hasRequiredToObject) return toObject; + hasRequiredToObject = 1; + var requireObjectCoercible = requireRequireObjectCoercible(); + + var $Object = Object; + + // `ToObject` abstract operation + // https://tc39.es/ecma262/#sec-toobject + toObject = function (argument) { + return $Object(requireObjectCoercible(argument)); + }; + return toObject; +} + +var hasOwnProperty_1; +var hasRequiredHasOwnProperty; + +function requireHasOwnProperty () { + if (hasRequiredHasOwnProperty) return hasOwnProperty_1; + hasRequiredHasOwnProperty = 1; + var uncurryThis = requireFunctionUncurryThis(); + var toObject = requireToObject(); + + var hasOwnProperty = uncurryThis({}.hasOwnProperty); + + // `HasOwnProperty` abstract operation + // https://tc39.es/ecma262/#sec-hasownproperty + // eslint-disable-next-line es/no-object-hasown -- safe + hasOwnProperty_1 = Object.hasOwn || function hasOwn(it, key) { + return hasOwnProperty(toObject(it), key); + }; + return hasOwnProperty_1; +} + +var uid; +var hasRequiredUid; + +function requireUid () { + if (hasRequiredUid) return uid; + hasRequiredUid = 1; + var uncurryThis = requireFunctionUncurryThis(); + + var id = 0; + var postfix = Math.random(); + var toString = uncurryThis(1.0.toString); + + uid = function (key) { + return 'Symbol(' + (key === undefined ? '' : key) + ')_' + toString(++id + postfix, 36); + }; + return uid; +} + +var wellKnownSymbol; +var hasRequiredWellKnownSymbol; + +function requireWellKnownSymbol () { + if (hasRequiredWellKnownSymbol) return wellKnownSymbol; + hasRequiredWellKnownSymbol = 1; + var globalThis = requireGlobalThis(); + var shared = requireShared(); + var hasOwn = requireHasOwnProperty(); + var uid = requireUid(); + var NATIVE_SYMBOL = requireSymbolConstructorDetection(); + var USE_SYMBOL_AS_UID = requireUseSymbolAsUid(); + + var Symbol = globalThis.Symbol; + var WellKnownSymbolsStore = shared('wks'); + var createWellKnownSymbol = USE_SYMBOL_AS_UID ? Symbol['for'] || Symbol : Symbol && Symbol.withoutSetter || uid; + + wellKnownSymbol = function (name) { + if (!hasOwn(WellKnownSymbolsStore, name)) { + WellKnownSymbolsStore[name] = NATIVE_SYMBOL && hasOwn(Symbol, name) + ? Symbol[name] + : createWellKnownSymbol('Symbol.' + name); + } return WellKnownSymbolsStore[name]; + }; + return wellKnownSymbol; +} + +var toPrimitive; +var hasRequiredToPrimitive; + +function requireToPrimitive () { + if (hasRequiredToPrimitive) return toPrimitive; + hasRequiredToPrimitive = 1; + var call = requireFunctionCall(); + var isObject = requireIsObject(); + var isSymbol = requireIsSymbol(); + var getMethod = requireGetMethod(); + var ordinaryToPrimitive = requireOrdinaryToPrimitive(); + var wellKnownSymbol = requireWellKnownSymbol(); + + var $TypeError = TypeError; + var TO_PRIMITIVE = wellKnownSymbol('toPrimitive'); + + // `ToPrimitive` abstract operation + // https://tc39.es/ecma262/#sec-toprimitive + toPrimitive = function (input, pref) { + if (!isObject(input) || isSymbol(input)) return input; + var exoticToPrim = getMethod(input, TO_PRIMITIVE); + var result; + if (exoticToPrim) { + if (pref === undefined) pref = 'default'; + result = call(exoticToPrim, input, pref); + if (!isObject(result) || isSymbol(result)) return result; + throw new $TypeError("Can't convert object to primitive value"); + } + if (pref === undefined) pref = 'number'; + return ordinaryToPrimitive(input, pref); + }; + return toPrimitive; +} + +var toPropertyKey; +var hasRequiredToPropertyKey; + +function requireToPropertyKey () { + if (hasRequiredToPropertyKey) return toPropertyKey; + hasRequiredToPropertyKey = 1; + var toPrimitive = requireToPrimitive(); + var isSymbol = requireIsSymbol(); + + // `ToPropertyKey` abstract operation + // https://tc39.es/ecma262/#sec-topropertykey + toPropertyKey = function (argument) { + var key = toPrimitive(argument, 'string'); + return isSymbol(key) ? key : key + ''; + }; + return toPropertyKey; +} + +var documentCreateElement; +var hasRequiredDocumentCreateElement; + +function requireDocumentCreateElement () { + if (hasRequiredDocumentCreateElement) return documentCreateElement; + hasRequiredDocumentCreateElement = 1; + var globalThis = requireGlobalThis(); + var isObject = requireIsObject(); + + var document = globalThis.document; + // typeof document.createElement is 'object' in old IE + var EXISTS = isObject(document) && isObject(document.createElement); + + documentCreateElement = function (it) { + return EXISTS ? document.createElement(it) : {}; + }; + return documentCreateElement; +} + +var ie8DomDefine; +var hasRequiredIe8DomDefine; + +function requireIe8DomDefine () { + if (hasRequiredIe8DomDefine) return ie8DomDefine; + hasRequiredIe8DomDefine = 1; + var DESCRIPTORS = requireDescriptors(); + var fails = requireFails(); + var createElement = requireDocumentCreateElement(); + + // Thanks to IE8 for its funny defineProperty + ie8DomDefine = !DESCRIPTORS && !fails(function () { + // eslint-disable-next-line es/no-object-defineproperty -- required for testing + return Object.defineProperty(createElement('div'), 'a', { + get: function () { return 7; } + }).a !== 7; + }); + return ie8DomDefine; +} + +var hasRequiredObjectGetOwnPropertyDescriptor; + +function requireObjectGetOwnPropertyDescriptor () { + if (hasRequiredObjectGetOwnPropertyDescriptor) return objectGetOwnPropertyDescriptor; + hasRequiredObjectGetOwnPropertyDescriptor = 1; + var DESCRIPTORS = requireDescriptors(); + var call = requireFunctionCall(); + var propertyIsEnumerableModule = requireObjectPropertyIsEnumerable(); + var createPropertyDescriptor = requireCreatePropertyDescriptor(); + var toIndexedObject = requireToIndexedObject(); + var toPropertyKey = requireToPropertyKey(); + var hasOwn = requireHasOwnProperty(); + var IE8_DOM_DEFINE = requireIe8DomDefine(); + + // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe + var $getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; + + // `Object.getOwnPropertyDescriptor` method + // https://tc39.es/ecma262/#sec-object.getownpropertydescriptor + objectGetOwnPropertyDescriptor.f = DESCRIPTORS ? $getOwnPropertyDescriptor : function getOwnPropertyDescriptor(O, P) { + O = toIndexedObject(O); + P = toPropertyKey(P); + if (IE8_DOM_DEFINE) try { + return $getOwnPropertyDescriptor(O, P); + } catch (error) { /* empty */ } + if (hasOwn(O, P)) return createPropertyDescriptor(!call(propertyIsEnumerableModule.f, O, P), O[P]); + }; + return objectGetOwnPropertyDescriptor; +} var objectDefineProperty = {}; -var isObject$y = isObject$B; +var v8PrototypeDefineBug; +var hasRequiredV8PrototypeDefineBug; + +function requireV8PrototypeDefineBug () { + if (hasRequiredV8PrototypeDefineBug) return v8PrototypeDefineBug; + hasRequiredV8PrototypeDefineBug = 1; + var DESCRIPTORS = requireDescriptors(); + var fails = requireFails(); + + // V8 ~ Chrome 36- + // https://bugs.chromium.org/p/v8/issues/detail?id=3334 + v8PrototypeDefineBug = DESCRIPTORS && fails(function () { + // eslint-disable-next-line es/no-object-defineproperty -- required for testing + return Object.defineProperty(function () { /* empty */ }, 'prototype', { + value: 42, + writable: false + }).prototype !== 42; + }); + return v8PrototypeDefineBug; +} + +var anObject; +var hasRequiredAnObject; + +function requireAnObject () { + if (hasRequiredAnObject) return anObject; + hasRequiredAnObject = 1; + var isObject = requireIsObject(); + + var $String = String; + var $TypeError = TypeError; + + // `Assert: Type(argument) is Object` + anObject = function (argument) { + if (isObject(argument)) return argument; + throw new $TypeError($String(argument) + ' is not an object'); + }; + return anObject; +} + +var hasRequiredObjectDefineProperty; + +function requireObjectDefineProperty () { + if (hasRequiredObjectDefineProperty) return objectDefineProperty; + hasRequiredObjectDefineProperty = 1; + var DESCRIPTORS = requireDescriptors(); + var IE8_DOM_DEFINE = requireIe8DomDefine(); + var V8_PROTOTYPE_DEFINE_BUG = requireV8PrototypeDefineBug(); + var anObject = requireAnObject(); + var toPropertyKey = requireToPropertyKey(); + + var $TypeError = TypeError; + // eslint-disable-next-line es/no-object-defineproperty -- safe + var $defineProperty = Object.defineProperty; + // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe + var $getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; + var ENUMERABLE = 'enumerable'; + var CONFIGURABLE = 'configurable'; + var WRITABLE = 'writable'; + + // `Object.defineProperty` method + // https://tc39.es/ecma262/#sec-object.defineproperty + objectDefineProperty.f = DESCRIPTORS ? V8_PROTOTYPE_DEFINE_BUG ? function defineProperty(O, P, Attributes) { + anObject(O); + P = toPropertyKey(P); + anObject(Attributes); + if (typeof O === 'function' && P === 'prototype' && 'value' in Attributes && WRITABLE in Attributes && !Attributes[WRITABLE]) { + var current = $getOwnPropertyDescriptor(O, P); + if (current && current[WRITABLE]) { + O[P] = Attributes.value; + Attributes = { + configurable: CONFIGURABLE in Attributes ? Attributes[CONFIGURABLE] : current[CONFIGURABLE], + enumerable: ENUMERABLE in Attributes ? Attributes[ENUMERABLE] : current[ENUMERABLE], + writable: false + }; + } + } return $defineProperty(O, P, Attributes); + } : $defineProperty : function defineProperty(O, P, Attributes) { + anObject(O); + P = toPropertyKey(P); + anObject(Attributes); + if (IE8_DOM_DEFINE) try { + return $defineProperty(O, P, Attributes); + } catch (error) { /* empty */ } + if ('get' in Attributes || 'set' in Attributes) throw new $TypeError('Accessors not supported'); + if ('value' in Attributes) O[P] = Attributes.value; + return O; + }; + return objectDefineProperty; +} + +var createNonEnumerableProperty; +var hasRequiredCreateNonEnumerableProperty; + +function requireCreateNonEnumerableProperty () { + if (hasRequiredCreateNonEnumerableProperty) return createNonEnumerableProperty; + hasRequiredCreateNonEnumerableProperty = 1; + var DESCRIPTORS = requireDescriptors(); + var definePropertyModule = requireObjectDefineProperty(); + var createPropertyDescriptor = requireCreatePropertyDescriptor(); + + createNonEnumerableProperty = DESCRIPTORS ? function (object, key, value) { + return definePropertyModule.f(object, key, createPropertyDescriptor(1, value)); + } : function (object, key, value) { + object[key] = value; + return object; + }; + return createNonEnumerableProperty; +} + +var makeBuiltIn = {exports: {}}; + +var functionName; +var hasRequiredFunctionName; + +function requireFunctionName () { + if (hasRequiredFunctionName) return functionName; + hasRequiredFunctionName = 1; + var DESCRIPTORS = requireDescriptors(); + var hasOwn = requireHasOwnProperty(); + + var FunctionPrototype = Function.prototype; + // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe + var getDescriptor = DESCRIPTORS && Object.getOwnPropertyDescriptor; + + var EXISTS = hasOwn(FunctionPrototype, 'name'); + // additional protection from minified / mangled / dropped function names + var PROPER = EXISTS && (function something() { /* empty */ }).name === 'something'; + var CONFIGURABLE = EXISTS && (!DESCRIPTORS || (DESCRIPTORS && getDescriptor(FunctionPrototype, 'name').configurable)); + + functionName = { + EXISTS: EXISTS, + PROPER: PROPER, + CONFIGURABLE: CONFIGURABLE + }; + return functionName; +} + +var inspectSource; +var hasRequiredInspectSource; + +function requireInspectSource () { + if (hasRequiredInspectSource) return inspectSource; + hasRequiredInspectSource = 1; + var uncurryThis = requireFunctionUncurryThis(); + var isCallable = requireIsCallable(); + var store = requireSharedStore(); + + var functionToString = uncurryThis(Function.toString); + + // this helper broken in `core-js@3.4.1-3.4.4`, so we can't use `shared` helper + if (!isCallable(store.inspectSource)) { + store.inspectSource = function (it) { + return functionToString(it); + }; + } + + inspectSource = store.inspectSource; + return inspectSource; +} + +var weakMapBasicDetection; +var hasRequiredWeakMapBasicDetection; -var anObject$1z = function (it) { - if (!isObject$y(it)) { - throw TypeError(String(it) + ' is not an object'); - } return it; -}; +function requireWeakMapBasicDetection () { + if (hasRequiredWeakMapBasicDetection) return weakMapBasicDetection; + hasRequiredWeakMapBasicDetection = 1; + var globalThis = requireGlobalThis(); + var isCallable = requireIsCallable(); -var DESCRIPTORS$x = descriptors; -var IE8_DOM_DEFINE = ie8DomDefine; -var anObject$1y = anObject$1z; -var toPrimitive$9 = toPrimitive$b; + var WeakMap = globalThis.WeakMap; -var nativeDefineProperty$2 = Object.defineProperty; + weakMapBasicDetection = isCallable(WeakMap) && /native code/.test(String(WeakMap)); + return weakMapBasicDetection; +} + +var sharedKey; +var hasRequiredSharedKey; + +function requireSharedKey () { + if (hasRequiredSharedKey) return sharedKey; + hasRequiredSharedKey = 1; + var shared = requireShared(); + var uid = requireUid(); + + var keys = shared('keys'); -// `Object.defineProperty` method -// https://tc39.es/ecma262/#sec-object.defineproperty -objectDefineProperty.f = DESCRIPTORS$x ? nativeDefineProperty$2 : function defineProperty(O, P, Attributes) { - anObject$1y(O); - P = toPrimitive$9(P, true); - anObject$1y(Attributes); - if (IE8_DOM_DEFINE) try { - return nativeDefineProperty$2(O, P, Attributes); - } catch (error) { /* empty */ } - if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported'); - if ('value' in Attributes) O[P] = Attributes.value; - return O; -}; + sharedKey = function (key) { + return keys[key] || (keys[key] = uid(key)); + }; + return sharedKey; +} -var DESCRIPTORS$w = descriptors; -var definePropertyModule$c = objectDefineProperty; -var createPropertyDescriptor$7 = createPropertyDescriptor$9; +var hiddenKeys; +var hasRequiredHiddenKeys; -var createNonEnumerableProperty$m = DESCRIPTORS$w ? function (object, key, value) { - return definePropertyModule$c.f(object, key, createPropertyDescriptor$7(1, value)); -} : function (object, key, value) { - object[key] = value; - return object; -}; +function requireHiddenKeys () { + if (hasRequiredHiddenKeys) return hiddenKeys; + hasRequiredHiddenKeys = 1; + hiddenKeys = {}; + return hiddenKeys; +} -var redefine$g = {exports: {}}; +var internalState; +var hasRequiredInternalState; + +function requireInternalState () { + if (hasRequiredInternalState) return internalState; + hasRequiredInternalState = 1; + var NATIVE_WEAK_MAP = requireWeakMapBasicDetection(); + var globalThis = requireGlobalThis(); + var isObject = requireIsObject(); + var createNonEnumerableProperty = requireCreateNonEnumerableProperty(); + var hasOwn = requireHasOwnProperty(); + var shared = requireSharedStore(); + var sharedKey = requireSharedKey(); + var hiddenKeys = requireHiddenKeys(); + + var OBJECT_ALREADY_INITIALIZED = 'Object already initialized'; + var TypeError = globalThis.TypeError; + var WeakMap = globalThis.WeakMap; + var set, get, has; + + var enforce = function (it) { + return has(it) ? get(it) : set(it, {}); + }; + + var getterFor = function (TYPE) { + return function (it) { + var state; + if (!isObject(it) || (state = get(it)).type !== TYPE) { + throw new TypeError('Incompatible receiver, ' + TYPE + ' required'); + } return state; + }; + }; + + if (NATIVE_WEAK_MAP || shared.state) { + var store = shared.state || (shared.state = new WeakMap()); + /* eslint-disable no-self-assign -- prototype methods protection */ + store.get = store.get; + store.has = store.has; + store.set = store.set; + /* eslint-enable no-self-assign -- prototype methods protection */ + set = function (it, metadata) { + if (store.has(it)) throw new TypeError(OBJECT_ALREADY_INITIALIZED); + metadata.facade = it; + store.set(it, metadata); + return metadata; + }; + get = function (it) { + return store.get(it) || {}; + }; + has = function (it) { + return store.has(it); + }; + } else { + var STATE = sharedKey('state'); + hiddenKeys[STATE] = true; + set = function (it, metadata) { + if (hasOwn(it, STATE)) throw new TypeError(OBJECT_ALREADY_INITIALIZED); + metadata.facade = it; + createNonEnumerableProperty(it, STATE, metadata); + return metadata; + }; + get = function (it) { + return hasOwn(it, STATE) ? it[STATE] : {}; + }; + has = function (it) { + return hasOwn(it, STATE); + }; + } + + internalState = { + set: set, + get: get, + has: has, + enforce: enforce, + getterFor: getterFor + }; + return internalState; +} -var global$J = global$L; -var createNonEnumerableProperty$l = createNonEnumerableProperty$m; +var hasRequiredMakeBuiltIn; + +function requireMakeBuiltIn () { + if (hasRequiredMakeBuiltIn) return makeBuiltIn.exports; + hasRequiredMakeBuiltIn = 1; + var uncurryThis = requireFunctionUncurryThis(); + var fails = requireFails(); + var isCallable = requireIsCallable(); + var hasOwn = requireHasOwnProperty(); + var DESCRIPTORS = requireDescriptors(); + var CONFIGURABLE_FUNCTION_NAME = requireFunctionName().CONFIGURABLE; + var inspectSource = requireInspectSource(); + var InternalStateModule = requireInternalState(); + + var enforceInternalState = InternalStateModule.enforce; + var getInternalState = InternalStateModule.get; + var $String = String; + // eslint-disable-next-line es/no-object-defineproperty -- safe + var defineProperty = Object.defineProperty; + var stringSlice = uncurryThis(''.slice); + var replace = uncurryThis(''.replace); + var join = uncurryThis([].join); + + var CONFIGURABLE_LENGTH = DESCRIPTORS && !fails(function () { + return defineProperty(function () { /* empty */ }, 'length', { value: 8 }).length !== 8; + }); + + var TEMPLATE = String(String).split('String'); + + var makeBuiltIn$1 = makeBuiltIn.exports = function (value, name, options) { + if (stringSlice($String(name), 0, 7) === 'Symbol(') { + name = '[' + replace($String(name), /^Symbol\(([^)]*)\).*$/, '$1') + ']'; + } + if (options && options.getter) name = 'get ' + name; + if (options && options.setter) name = 'set ' + name; + if (!hasOwn(value, 'name') || (CONFIGURABLE_FUNCTION_NAME && value.name !== name)) { + if (DESCRIPTORS) defineProperty(value, 'name', { value: name, configurable: true }); + else value.name = name; + } + if (CONFIGURABLE_LENGTH && options && hasOwn(options, 'arity') && value.length !== options.arity) { + defineProperty(value, 'length', { value: options.arity }); + } + try { + if (options && hasOwn(options, 'constructor') && options.constructor) { + if (DESCRIPTORS) defineProperty(value, 'prototype', { writable: false }); + // in V8 ~ Chrome 53, prototypes of some methods, like `Array.prototype.values`, are non-writable + } else if (value.prototype) value.prototype = undefined; + } catch (error) { /* empty */ } + var state = enforceInternalState(value); + if (!hasOwn(state, 'source')) { + state.source = join(TEMPLATE, typeof name == 'string' ? name : ''); + } return value; + }; + + // add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative + // eslint-disable-next-line no-extend-native -- required + Function.prototype.toString = makeBuiltIn$1(function toString() { + return isCallable(this) && getInternalState(this).source || inspectSource(this); + }, 'toString'); + return makeBuiltIn.exports; +} -var setGlobal$3 = function (key, value) { - try { - createNonEnumerableProperty$l(global$J, key, value); - } catch (error) { - global$J[key] = value; - } return value; -}; - -var global$I = global$L; -var setGlobal$2 = setGlobal$3; - -var SHARED = '__core-js_shared__'; -var store$5 = global$I[SHARED] || setGlobal$2(SHARED, {}); - -var sharedStore = store$5; - -var store$4 = sharedStore; - -var functionToString = Function.toString; - -// this helper broken in `3.4.1-3.4.4`, so we can't use `shared` helper -if (typeof store$4.inspectSource != 'function') { - store$4.inspectSource = function (it) { - return functionToString.call(it); - }; -} - -var inspectSource$3 = store$4.inspectSource; - -var global$H = global$L; -var inspectSource$2 = inspectSource$3; - -var WeakMap$3 = global$H.WeakMap; - -var nativeWeakMap = typeof WeakMap$3 === 'function' && /native code/.test(inspectSource$2(WeakMap$3)); - -var shared$6 = {exports: {}}; - -var isPure = false; - -var store$3 = sharedStore; - -(shared$6.exports = function (key, value) { - return store$3[key] || (store$3[key] = value !== undefined ? value : {}); -})('versions', []).push({ - version: '3.8.3', - mode: 'global', - copyright: '© 2021 Denis Pushkarev (zloirock.ru)' -}); - -var id$2 = 0; -var postfix = Math.random(); - -var uid$5 = function (key) { - return 'Symbol(' + String(key === undefined ? '' : key) + ')_' + (++id$2 + postfix).toString(36); -}; - -var shared$5 = shared$6.exports; -var uid$4 = uid$5; - -var keys$3 = shared$5('keys'); - -var sharedKey$4 = function (key) { - return keys$3[key] || (keys$3[key] = uid$4(key)); -}; - -var hiddenKeys$6 = {}; - -var NATIVE_WEAK_MAP$1 = nativeWeakMap; -var global$G = global$L; -var isObject$x = isObject$B; -var createNonEnumerableProperty$k = createNonEnumerableProperty$m; -var objectHas = has$o; -var shared$4 = sharedStore; -var sharedKey$3 = sharedKey$4; -var hiddenKeys$5 = hiddenKeys$6; - -var WeakMap$2 = global$G.WeakMap; -var set$3, get$2, has$m; - -var enforce = function (it) { - return has$m(it) ? get$2(it) : set$3(it, {}); -}; - -var getterFor = function (TYPE) { - return function (it) { - var state; - if (!isObject$x(it) || (state = get$2(it)).type !== TYPE) { - throw TypeError('Incompatible receiver, ' + TYPE + ' required'); - } return state; - }; -}; - -if (NATIVE_WEAK_MAP$1) { - var store$2 = shared$4.state || (shared$4.state = new WeakMap$2()); - var wmget = store$2.get; - var wmhas = store$2.has; - var wmset = store$2.set; - set$3 = function (it, metadata) { - metadata.facade = it; - wmset.call(store$2, it, metadata); - return metadata; - }; - get$2 = function (it) { - return wmget.call(store$2, it) || {}; - }; - has$m = function (it) { - return wmhas.call(store$2, it); - }; -} else { - var STATE = sharedKey$3('state'); - hiddenKeys$5[STATE] = true; - set$3 = function (it, metadata) { - metadata.facade = it; - createNonEnumerableProperty$k(it, STATE, metadata); - return metadata; - }; - get$2 = function (it) { - return objectHas(it, STATE) ? it[STATE] : {}; - }; - has$m = function (it) { - return objectHas(it, STATE); - }; -} - -var internalState = { - set: set$3, - get: get$2, - has: has$m, - enforce: enforce, - getterFor: getterFor -}; - -var global$F = global$L; -var createNonEnumerableProperty$j = createNonEnumerableProperty$m; -var has$l = has$o; -var setGlobal$1 = setGlobal$3; -var inspectSource$1 = inspectSource$3; -var InternalStateModule$i = internalState; - -var getInternalState$f = InternalStateModule$i.get; -var enforceInternalState = InternalStateModule$i.enforce; -var TEMPLATE = String(String).split('String'); - -(redefine$g.exports = function (O, key, value, options) { - var unsafe = options ? !!options.unsafe : false; - var simple = options ? !!options.enumerable : false; - var noTargetGet = options ? !!options.noTargetGet : false; - var state; - if (typeof value == 'function') { - if (typeof key == 'string' && !has$l(value, 'name')) { - createNonEnumerableProperty$j(value, 'name', key); - } - state = enforceInternalState(value); - if (!state.source) { - state.source = TEMPLATE.join(typeof key == 'string' ? key : ''); - } - } - if (O === global$F) { - if (simple) O[key] = value; - else setGlobal$1(key, value); - return; - } else if (!unsafe) { - delete O[key]; - } else if (!noTargetGet && O[key]) { - simple = true; - } - if (simple) O[key] = value; - else createNonEnumerableProperty$j(O, key, value); -// add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative -})(Function.prototype, 'toString', function toString() { - return typeof this == 'function' && getInternalState$f(this).source || inspectSource$1(this); -}); - -var global$E = global$L; - -var path$6 = global$E; - -var path$5 = path$6; -var global$D = global$L; - -var aFunction$S = function (variable) { - return typeof variable == 'function' ? variable : undefined; -}; - -var getBuiltIn$t = function (namespace, method) { - return arguments.length < 2 ? aFunction$S(path$5[namespace]) || aFunction$S(global$D[namespace]) - : path$5[namespace] && path$5[namespace][method] || global$D[namespace] && global$D[namespace][method]; -}; +var defineBuiltIn; +var hasRequiredDefineBuiltIn; + +function requireDefineBuiltIn () { + if (hasRequiredDefineBuiltIn) return defineBuiltIn; + hasRequiredDefineBuiltIn = 1; + var isCallable = requireIsCallable(); + var definePropertyModule = requireObjectDefineProperty(); + var makeBuiltIn = requireMakeBuiltIn(); + var defineGlobalProperty = requireDefineGlobalProperty(); + + defineBuiltIn = function (O, key, value, options) { + if (!options) options = {}; + var simple = options.enumerable; + var name = options.name !== undefined ? options.name : key; + if (isCallable(value)) makeBuiltIn(value, name, options); + if (options.global) { + if (simple) O[key] = value; + else defineGlobalProperty(key, value); + } else { + try { + if (!options.unsafe) delete O[key]; + else if (O[key]) simple = true; + } catch (error) { /* empty */ } + if (simple) O[key] = value; + else definePropertyModule.f(O, key, { + value: value, + enumerable: false, + configurable: !options.nonConfigurable, + writable: !options.nonWritable + }); + } return O; + }; + return defineBuiltIn; +} var objectGetOwnPropertyNames = {}; -var ceil$2 = Math.ceil; -var floor$9 = Math.floor; - -// `ToInteger` abstract operation -// https://tc39.es/ecma262/#sec-tointeger -var toInteger$f = function (argument) { - return isNaN(argument = +argument) ? 0 : (argument > 0 ? floor$9 : ceil$2)(argument); -}; - -var toInteger$e = toInteger$f; - -var min$9 = Math.min; - -// `ToLength` abstract operation -// https://tc39.es/ecma262/#sec-tolength -var toLength$y = function (argument) { - return argument > 0 ? min$9(toInteger$e(argument), 0x1FFFFFFFFFFFFF) : 0; // 2 ** 53 - 1 == 9007199254740991 -}; - -var toInteger$d = toInteger$f; - -var max$5 = Math.max; -var min$8 = Math.min; - -// Helper for a popular repeating case of the spec: -// Let integer be ? ToInteger(index). -// If integer < 0, let result be max((length + integer), 0); else let result be min(integer, length). -var toAbsoluteIndex$8 = function (index, length) { - var integer = toInteger$d(index); - return integer < 0 ? max$5(integer + length, 0) : min$8(integer, length); -}; - -var toIndexedObject$b = toIndexedObject$d; -var toLength$x = toLength$y; -var toAbsoluteIndex$7 = toAbsoluteIndex$8; - -// `Array.prototype.{ indexOf, includes }` methods implementation -var createMethod$7 = function (IS_INCLUDES) { - return function ($this, el, fromIndex) { - var O = toIndexedObject$b($this); - var length = toLength$x(O.length); - var index = toAbsoluteIndex$7(fromIndex, length); - var value; - // Array#includes uses SameValueZero equality algorithm - // eslint-disable-next-line no-self-compare - if (IS_INCLUDES && el != el) while (length > index) { - value = O[index++]; - // eslint-disable-next-line no-self-compare - if (value != value) return true; - // Array#indexOf ignores holes, Array#includes - not - } else for (;length > index; index++) { - if ((IS_INCLUDES || index in O) && O[index] === el) return IS_INCLUDES || index || 0; - } return !IS_INCLUDES && -1; - }; -}; - -var arrayIncludes = { - // `Array.prototype.includes` method - // https://tc39.es/ecma262/#sec-array.prototype.includes - includes: createMethod$7(true), - // `Array.prototype.indexOf` method - // https://tc39.es/ecma262/#sec-array.prototype.indexof - indexOf: createMethod$7(false) -}; - -var has$k = has$o; -var toIndexedObject$a = toIndexedObject$d; -var indexOf = arrayIncludes.indexOf; -var hiddenKeys$4 = hiddenKeys$6; - -var objectKeysInternal = function (object, names) { - var O = toIndexedObject$a(object); - var i = 0; - var result = []; - var key; - for (key in O) !has$k(hiddenKeys$4, key) && has$k(O, key) && result.push(key); - // Don't enum bug & hidden keys - while (names.length > i) if (has$k(O, key = names[i++])) { - ~indexOf(result, key) || result.push(key); - } - return result; -}; - -// IE8- don't enum bug keys -var enumBugKeys$3 = [ - 'constructor', - 'hasOwnProperty', - 'isPrototypeOf', - 'propertyIsEnumerable', - 'toLocaleString', - 'toString', - 'valueOf' -]; - -var internalObjectKeys$1 = objectKeysInternal; -var enumBugKeys$2 = enumBugKeys$3; - -var hiddenKeys$3 = enumBugKeys$2.concat('length', 'prototype'); - -// `Object.getOwnPropertyNames` method -// https://tc39.es/ecma262/#sec-object.getownpropertynames -objectGetOwnPropertyNames.f = Object.getOwnPropertyNames || function getOwnPropertyNames(O) { - return internalObjectKeys$1(O, hiddenKeys$3); -}; +var mathTrunc; +var hasRequiredMathTrunc; + +function requireMathTrunc () { + if (hasRequiredMathTrunc) return mathTrunc; + hasRequiredMathTrunc = 1; + var ceil = Math.ceil; + var floor = Math.floor; + + // `Math.trunc` method + // https://tc39.es/ecma262/#sec-math.trunc + // eslint-disable-next-line es/no-math-trunc -- safe + mathTrunc = Math.trunc || function trunc(x) { + var n = +x; + return (n > 0 ? floor : ceil)(n); + }; + return mathTrunc; +} + +var toIntegerOrInfinity; +var hasRequiredToIntegerOrInfinity; + +function requireToIntegerOrInfinity () { + if (hasRequiredToIntegerOrInfinity) return toIntegerOrInfinity; + hasRequiredToIntegerOrInfinity = 1; + var trunc = requireMathTrunc(); + + // `ToIntegerOrInfinity` abstract operation + // https://tc39.es/ecma262/#sec-tointegerorinfinity + toIntegerOrInfinity = function (argument) { + var number = +argument; + // eslint-disable-next-line no-self-compare -- NaN check + return number !== number || number === 0 ? 0 : trunc(number); + }; + return toIntegerOrInfinity; +} + +var toAbsoluteIndex; +var hasRequiredToAbsoluteIndex; + +function requireToAbsoluteIndex () { + if (hasRequiredToAbsoluteIndex) return toAbsoluteIndex; + hasRequiredToAbsoluteIndex = 1; + var toIntegerOrInfinity = requireToIntegerOrInfinity(); + + var max = Math.max; + var min = Math.min; + + // Helper for a popular repeating case of the spec: + // Let integer be ? ToInteger(index). + // If integer < 0, let result be max((length + integer), 0); else let result be min(integer, length). + toAbsoluteIndex = function (index, length) { + var integer = toIntegerOrInfinity(index); + return integer < 0 ? max(integer + length, 0) : min(integer, length); + }; + return toAbsoluteIndex; +} + +var toLength; +var hasRequiredToLength; + +function requireToLength () { + if (hasRequiredToLength) return toLength; + hasRequiredToLength = 1; + var toIntegerOrInfinity = requireToIntegerOrInfinity(); + + var min = Math.min; + + // `ToLength` abstract operation + // https://tc39.es/ecma262/#sec-tolength + toLength = function (argument) { + var len = toIntegerOrInfinity(argument); + return len > 0 ? min(len, 0x1FFFFFFFFFFFFF) : 0; // 2 ** 53 - 1 == 9007199254740991 + }; + return toLength; +} + +var lengthOfArrayLike; +var hasRequiredLengthOfArrayLike; + +function requireLengthOfArrayLike () { + if (hasRequiredLengthOfArrayLike) return lengthOfArrayLike; + hasRequiredLengthOfArrayLike = 1; + var toLength = requireToLength(); + + // `LengthOfArrayLike` abstract operation + // https://tc39.es/ecma262/#sec-lengthofarraylike + lengthOfArrayLike = function (obj) { + return toLength(obj.length); + }; + return lengthOfArrayLike; +} + +var arrayIncludes; +var hasRequiredArrayIncludes; + +function requireArrayIncludes () { + if (hasRequiredArrayIncludes) return arrayIncludes; + hasRequiredArrayIncludes = 1; + var toIndexedObject = requireToIndexedObject(); + var toAbsoluteIndex = requireToAbsoluteIndex(); + var lengthOfArrayLike = requireLengthOfArrayLike(); + + // `Array.prototype.{ indexOf, includes }` methods implementation + var createMethod = function (IS_INCLUDES) { + return function ($this, el, fromIndex) { + var O = toIndexedObject($this); + var length = lengthOfArrayLike(O); + if (length === 0) return !IS_INCLUDES && -1; + var index = toAbsoluteIndex(fromIndex, length); + var value; + // Array#includes uses SameValueZero equality algorithm + // eslint-disable-next-line no-self-compare -- NaN check + if (IS_INCLUDES && el !== el) while (length > index) { + value = O[index++]; + // eslint-disable-next-line no-self-compare -- NaN check + if (value !== value) return true; + // Array#indexOf ignores holes, Array#includes - not + } else for (;length > index; index++) { + if ((IS_INCLUDES || index in O) && O[index] === el) return IS_INCLUDES || index || 0; + } return !IS_INCLUDES && -1; + }; + }; + + arrayIncludes = { + // `Array.prototype.includes` method + // https://tc39.es/ecma262/#sec-array.prototype.includes + includes: createMethod(true), + // `Array.prototype.indexOf` method + // https://tc39.es/ecma262/#sec-array.prototype.indexof + indexOf: createMethod(false) + }; + return arrayIncludes; +} + +var objectKeysInternal; +var hasRequiredObjectKeysInternal; + +function requireObjectKeysInternal () { + if (hasRequiredObjectKeysInternal) return objectKeysInternal; + hasRequiredObjectKeysInternal = 1; + var uncurryThis = requireFunctionUncurryThis(); + var hasOwn = requireHasOwnProperty(); + var toIndexedObject = requireToIndexedObject(); + var indexOf = requireArrayIncludes().indexOf; + var hiddenKeys = requireHiddenKeys(); + + var push = uncurryThis([].push); + + objectKeysInternal = function (object, names) { + var O = toIndexedObject(object); + var i = 0; + var result = []; + var key; + for (key in O) !hasOwn(hiddenKeys, key) && hasOwn(O, key) && push(result, key); + // Don't enum bug & hidden keys + while (names.length > i) if (hasOwn(O, key = names[i++])) { + ~indexOf(result, key) || push(result, key); + } + return result; + }; + return objectKeysInternal; +} + +var enumBugKeys; +var hasRequiredEnumBugKeys; + +function requireEnumBugKeys () { + if (hasRequiredEnumBugKeys) return enumBugKeys; + hasRequiredEnumBugKeys = 1; + // IE8- don't enum bug keys + enumBugKeys = [ + 'constructor', + 'hasOwnProperty', + 'isPrototypeOf', + 'propertyIsEnumerable', + 'toLocaleString', + 'toString', + 'valueOf' + ]; + return enumBugKeys; +} + +var hasRequiredObjectGetOwnPropertyNames; + +function requireObjectGetOwnPropertyNames () { + if (hasRequiredObjectGetOwnPropertyNames) return objectGetOwnPropertyNames; + hasRequiredObjectGetOwnPropertyNames = 1; + var internalObjectKeys = requireObjectKeysInternal(); + var enumBugKeys = requireEnumBugKeys(); + + var hiddenKeys = enumBugKeys.concat('length', 'prototype'); + + // `Object.getOwnPropertyNames` method + // https://tc39.es/ecma262/#sec-object.getownpropertynames + // eslint-disable-next-line es/no-object-getownpropertynames -- safe + objectGetOwnPropertyNames.f = Object.getOwnPropertyNames || function getOwnPropertyNames(O) { + return internalObjectKeys(O, hiddenKeys); + }; + return objectGetOwnPropertyNames; +} var objectGetOwnPropertySymbols = {}; -objectGetOwnPropertySymbols.f = Object.getOwnPropertySymbols; - -var getBuiltIn$s = getBuiltIn$t; -var getOwnPropertyNamesModule$1 = objectGetOwnPropertyNames; -var getOwnPropertySymbolsModule$2 = objectGetOwnPropertySymbols; -var anObject$1x = anObject$1z; - -// all object keys, includes non-enumerable and symbols -var ownKeys$3 = getBuiltIn$s('Reflect', 'ownKeys') || function ownKeys(it) { - var keys = getOwnPropertyNamesModule$1.f(anObject$1x(it)); - var getOwnPropertySymbols = getOwnPropertySymbolsModule$2.f; - return getOwnPropertySymbols ? keys.concat(getOwnPropertySymbols(it)) : keys; -}; - -var has$j = has$o; -var ownKeys$2 = ownKeys$3; -var getOwnPropertyDescriptorModule$6 = objectGetOwnPropertyDescriptor; -var definePropertyModule$b = objectDefineProperty; - -var copyConstructorProperties$2 = function (target, source) { - var keys = ownKeys$2(source); - var defineProperty = definePropertyModule$b.f; - var getOwnPropertyDescriptor = getOwnPropertyDescriptorModule$6.f; - for (var i = 0; i < keys.length; i++) { - var key = keys[i]; - if (!has$j(target, key)) defineProperty(target, key, getOwnPropertyDescriptor(source, key)); - } -}; - -var fails$U = fails$Y; - -var replacement = /#|\.prototype\./; - -var isForced$5 = function (feature, detection) { - var value = data[normalize(feature)]; - return value == POLYFILL ? true - : value == NATIVE ? false - : typeof detection == 'function' ? fails$U(detection) - : !!detection; -}; - -var normalize = isForced$5.normalize = function (string) { - return String(string).replace(replacement, '.').toLowerCase(); -}; - -var data = isForced$5.data = {}; -var NATIVE = isForced$5.NATIVE = 'N'; -var POLYFILL = isForced$5.POLYFILL = 'P'; - -var isForced_1 = isForced$5; - -var global$C = global$L; -var getOwnPropertyDescriptor$7 = objectGetOwnPropertyDescriptor.f; -var createNonEnumerableProperty$i = createNonEnumerableProperty$m; -var redefine$f = redefine$g.exports; -var setGlobal = setGlobal$3; -var copyConstructorProperties$1 = copyConstructorProperties$2; -var isForced$4 = isForced_1; - -/* - options.target - name of the target object - options.global - target is the global object - options.stat - export as static methods of target - options.proto - export as prototype methods of target - options.real - real prototype method for the `pure` version - options.forced - export even if the native feature is available - options.bind - bind methods to the target, required for the `pure` version - options.wrap - wrap constructors to preventing global pollution, required for the `pure` version - options.unsafe - use the simple assignment of property instead of delete + defineProperty - options.sham - add a flag to not completely full polyfills - options.enumerable - export as enumerable property - options.noTargetGet - prevent calling a getter on target -*/ -var _export = function (options, source) { - var TARGET = options.target; - var GLOBAL = options.global; - var STATIC = options.stat; - var FORCED, target, key, targetProperty, sourceProperty, descriptor; - if (GLOBAL) { - target = global$C; - } else if (STATIC) { - target = global$C[TARGET] || setGlobal(TARGET, {}); - } else { - target = (global$C[TARGET] || {}).prototype; - } - if (target) for (key in source) { - sourceProperty = source[key]; - if (options.noTargetGet) { - descriptor = getOwnPropertyDescriptor$7(target, key); - targetProperty = descriptor && descriptor.value; - } else targetProperty = target[key]; - FORCED = isForced$4(GLOBAL ? key : TARGET + (STATIC ? '.' : '#') + key, options.forced); - // contained in target - if (!FORCED && targetProperty !== undefined) { - if (typeof sourceProperty === typeof targetProperty) continue; - copyConstructorProperties$1(sourceProperty, targetProperty); - } - // add a flag to not completely full polyfills - if (options.sham || (targetProperty && targetProperty.sham)) { - createNonEnumerableProperty$i(sourceProperty, 'sham', true); - } - // extend global - redefine$f(target, key, sourceProperty, options); - } -}; - -var fails$T = fails$Y; - -var nativeSymbol = !!Object.getOwnPropertySymbols && !fails$T(function () { - // Chrome 38 Symbol has incorrect toString conversion - // eslint-disable-next-line no-undef - return !String(Symbol()); -}); - -var NATIVE_SYMBOL$2 = nativeSymbol; - -var useSymbolAsUid = NATIVE_SYMBOL$2 - // eslint-disable-next-line no-undef - && !Symbol.sham - // eslint-disable-next-line no-undef - && typeof Symbol.iterator == 'symbol'; - -var classof$c = classofRaw$1; - -// `IsArray` abstract operation -// https://tc39.es/ecma262/#sec-isarray -var isArray$8 = Array.isArray || function isArray(arg) { - return classof$c(arg) == 'Array'; -}; - -var requireObjectCoercible$f = requireObjectCoercible$h; - -// `ToObject` abstract operation -// https://tc39.es/ecma262/#sec-toobject -var toObject$u = function (argument) { - return Object(requireObjectCoercible$f(argument)); -}; - -var internalObjectKeys = objectKeysInternal; -var enumBugKeys$1 = enumBugKeys$3; - -// `Object.keys` method -// https://tc39.es/ecma262/#sec-object.keys -var objectKeys$5 = Object.keys || function keys(O) { - return internalObjectKeys(O, enumBugKeys$1); -}; - -var DESCRIPTORS$v = descriptors; -var definePropertyModule$a = objectDefineProperty; -var anObject$1w = anObject$1z; -var objectKeys$4 = objectKeys$5; - -// `Object.defineProperties` method -// https://tc39.es/ecma262/#sec-object.defineproperties -var objectDefineProperties = DESCRIPTORS$v ? Object.defineProperties : function defineProperties(O, Properties) { - anObject$1w(O); - var keys = objectKeys$4(Properties); - var length = keys.length; - var index = 0; - var key; - while (length > index) definePropertyModule$a.f(O, key = keys[index++], Properties[key]); - return O; -}; - -var getBuiltIn$r = getBuiltIn$t; - -var html$2 = getBuiltIn$r('document', 'documentElement'); - -var anObject$1v = anObject$1z; -var defineProperties$3 = objectDefineProperties; -var enumBugKeys = enumBugKeys$3; -var hiddenKeys$2 = hiddenKeys$6; -var html$1 = html$2; -var documentCreateElement = documentCreateElement$1; -var sharedKey$2 = sharedKey$4; - -var GT = '>'; -var LT = '<'; -var PROTOTYPE$2 = 'prototype'; -var SCRIPT = 'script'; -var IE_PROTO$1 = sharedKey$2('IE_PROTO'); - -var EmptyConstructor = function () { /* empty */ }; - -var scriptTag = function (content) { - return LT + SCRIPT + GT + content + LT + '/' + SCRIPT + GT; -}; - -// Create object with fake `null` prototype: use ActiveX Object with cleared prototype -var NullProtoObjectViaActiveX = function (activeXDocument) { - activeXDocument.write(scriptTag('')); - activeXDocument.close(); - var temp = activeXDocument.parentWindow.Object; - activeXDocument = null; // avoid memory leak - return temp; -}; - -// Create object with fake `null` prototype: use iframe Object with cleared prototype -var NullProtoObjectViaIFrame = function () { - // Thrash, waste and sodomy: IE GC bug - var iframe = documentCreateElement('iframe'); - var JS = 'java' + SCRIPT + ':'; - var iframeDocument; - iframe.style.display = 'none'; - html$1.appendChild(iframe); - // https://github.com/zloirock/core-js/issues/475 - iframe.src = String(JS); - iframeDocument = iframe.contentWindow.document; - iframeDocument.open(); - iframeDocument.write(scriptTag('document.F=Object')); - iframeDocument.close(); - return iframeDocument.F; -}; - -// Check for document.domain and active x support -// No need to use active x approach when document.domain is not set -// see https://github.com/es-shims/es5-shim/issues/150 -// variation of https://github.com/kitcambridge/es5-shim/commit/4f738ac066346 -// avoid IE GC bug -var activeXDocument; -var NullProtoObject = function () { - try { - /* global ActiveXObject */ - activeXDocument = document.domain && new ActiveXObject('htmlfile'); - } catch (error) { /* ignore */ } - NullProtoObject = activeXDocument ? NullProtoObjectViaActiveX(activeXDocument) : NullProtoObjectViaIFrame(); - var length = enumBugKeys.length; - while (length--) delete NullProtoObject[PROTOTYPE$2][enumBugKeys[length]]; - return NullProtoObject(); -}; - -hiddenKeys$2[IE_PROTO$1] = true; - -// `Object.create` method -// https://tc39.es/ecma262/#sec-object.create -var objectCreate = Object.create || function create(O, Properties) { - var result; - if (O !== null) { - EmptyConstructor[PROTOTYPE$2] = anObject$1v(O); - result = new EmptyConstructor(); - EmptyConstructor[PROTOTYPE$2] = null; - // add "__proto__" for Object.getPrototypeOf polyfill - result[IE_PROTO$1] = O; - } else result = NullProtoObject(); - return Properties === undefined ? result : defineProperties$3(result, Properties); -}; +var hasRequiredObjectGetOwnPropertySymbols; + +function requireObjectGetOwnPropertySymbols () { + if (hasRequiredObjectGetOwnPropertySymbols) return objectGetOwnPropertySymbols; + hasRequiredObjectGetOwnPropertySymbols = 1; + // eslint-disable-next-line es/no-object-getownpropertysymbols -- safe + objectGetOwnPropertySymbols.f = Object.getOwnPropertySymbols; + return objectGetOwnPropertySymbols; +} + +var ownKeys; +var hasRequiredOwnKeys; + +function requireOwnKeys () { + if (hasRequiredOwnKeys) return ownKeys; + hasRequiredOwnKeys = 1; + var getBuiltIn = requireGetBuiltIn(); + var uncurryThis = requireFunctionUncurryThis(); + var getOwnPropertyNamesModule = requireObjectGetOwnPropertyNames(); + var getOwnPropertySymbolsModule = requireObjectGetOwnPropertySymbols(); + var anObject = requireAnObject(); + + var concat = uncurryThis([].concat); + + // all object keys, includes non-enumerable and symbols + ownKeys = getBuiltIn('Reflect', 'ownKeys') || function ownKeys(it) { + var keys = getOwnPropertyNamesModule.f(anObject(it)); + var getOwnPropertySymbols = getOwnPropertySymbolsModule.f; + return getOwnPropertySymbols ? concat(keys, getOwnPropertySymbols(it)) : keys; + }; + return ownKeys; +} + +var copyConstructorProperties; +var hasRequiredCopyConstructorProperties; + +function requireCopyConstructorProperties () { + if (hasRequiredCopyConstructorProperties) return copyConstructorProperties; + hasRequiredCopyConstructorProperties = 1; + var hasOwn = requireHasOwnProperty(); + var ownKeys = requireOwnKeys(); + var getOwnPropertyDescriptorModule = requireObjectGetOwnPropertyDescriptor(); + var definePropertyModule = requireObjectDefineProperty(); + + copyConstructorProperties = function (target, source, exceptions) { + var keys = ownKeys(source); + var defineProperty = definePropertyModule.f; + var getOwnPropertyDescriptor = getOwnPropertyDescriptorModule.f; + for (var i = 0; i < keys.length; i++) { + var key = keys[i]; + if (!hasOwn(target, key) && !(exceptions && hasOwn(exceptions, key))) { + defineProperty(target, key, getOwnPropertyDescriptor(source, key)); + } + } + }; + return copyConstructorProperties; +} + +var isForced_1; +var hasRequiredIsForced; + +function requireIsForced () { + if (hasRequiredIsForced) return isForced_1; + hasRequiredIsForced = 1; + var fails = requireFails(); + var isCallable = requireIsCallable(); + + var replacement = /#|\.prototype\./; + + var isForced = function (feature, detection) { + var value = data[normalize(feature)]; + return value === POLYFILL ? true + : value === NATIVE ? false + : isCallable(detection) ? fails(detection) + : !!detection; + }; + + var normalize = isForced.normalize = function (string) { + return String(string).replace(replacement, '.').toLowerCase(); + }; + + var data = isForced.data = {}; + var NATIVE = isForced.NATIVE = 'N'; + var POLYFILL = isForced.POLYFILL = 'P'; + + isForced_1 = isForced; + return isForced_1; +} + +var _export; +var hasRequired_export; + +function require_export () { + if (hasRequired_export) return _export; + hasRequired_export = 1; + var globalThis = requireGlobalThis(); + var getOwnPropertyDescriptor = requireObjectGetOwnPropertyDescriptor().f; + var createNonEnumerableProperty = requireCreateNonEnumerableProperty(); + var defineBuiltIn = requireDefineBuiltIn(); + var defineGlobalProperty = requireDefineGlobalProperty(); + var copyConstructorProperties = requireCopyConstructorProperties(); + var isForced = requireIsForced(); + + /* + options.target - name of the target object + options.global - target is the global object + options.stat - export as static methods of target + options.proto - export as prototype methods of target + options.real - real prototype method for the `pure` version + options.forced - export even if the native feature is available + options.bind - bind methods to the target, required for the `pure` version + options.wrap - wrap constructors to preventing global pollution, required for the `pure` version + options.unsafe - use the simple assignment of property instead of delete + defineProperty + options.sham - add a flag to not completely full polyfills + options.enumerable - export as enumerable property + options.dontCallGetSet - prevent calling a getter on target + options.name - the .name of the function if it does not match the key + */ + _export = function (options, source) { + var TARGET = options.target; + var GLOBAL = options.global; + var STATIC = options.stat; + var FORCED, target, key, targetProperty, sourceProperty, descriptor; + if (GLOBAL) { + target = globalThis; + } else if (STATIC) { + target = globalThis[TARGET] || defineGlobalProperty(TARGET, {}); + } else { + target = globalThis[TARGET] && globalThis[TARGET].prototype; + } + if (target) for (key in source) { + sourceProperty = source[key]; + if (options.dontCallGetSet) { + descriptor = getOwnPropertyDescriptor(target, key); + targetProperty = descriptor && descriptor.value; + } else targetProperty = target[key]; + FORCED = isForced(GLOBAL ? key : TARGET + (STATIC ? '.' : '#') + key, options.forced); + // contained in target + if (!FORCED && targetProperty !== undefined) { + if (typeof sourceProperty == typeof targetProperty) continue; + copyConstructorProperties(sourceProperty, targetProperty); + } + // add a flag to not completely full polyfills + if (options.sham || (targetProperty && targetProperty.sham)) { + createNonEnumerableProperty(sourceProperty, 'sham', true); + } + defineBuiltIn(target, key, sourceProperty, options); + } + }; + return _export; +} + +var toStringTagSupport; +var hasRequiredToStringTagSupport; + +function requireToStringTagSupport () { + if (hasRequiredToStringTagSupport) return toStringTagSupport; + hasRequiredToStringTagSupport = 1; + var wellKnownSymbol = requireWellKnownSymbol(); + + var TO_STRING_TAG = wellKnownSymbol('toStringTag'); + var test = {}; + + test[TO_STRING_TAG] = 'z'; + + toStringTagSupport = String(test) === '[object z]'; + return toStringTagSupport; +} + +var classof; +var hasRequiredClassof; + +function requireClassof () { + if (hasRequiredClassof) return classof; + hasRequiredClassof = 1; + var TO_STRING_TAG_SUPPORT = requireToStringTagSupport(); + var isCallable = requireIsCallable(); + var classofRaw = requireClassofRaw(); + var wellKnownSymbol = requireWellKnownSymbol(); + + var TO_STRING_TAG = wellKnownSymbol('toStringTag'); + var $Object = Object; + + // ES3 wrong here + var CORRECT_ARGUMENTS = classofRaw(function () { return arguments; }()) === 'Arguments'; + + // fallback for IE11 Script Access Denied error + var tryGet = function (it, key) { + try { + return it[key]; + } catch (error) { /* empty */ } + }; + + // getting tag from ES6+ `Object.prototype.toString` + classof = TO_STRING_TAG_SUPPORT ? classofRaw : function (it) { + var O, tag, result; + return it === undefined ? 'Undefined' : it === null ? 'Null' + // @@toStringTag case + : typeof (tag = tryGet(O = $Object(it), TO_STRING_TAG)) == 'string' ? tag + // builtinTag case + : CORRECT_ARGUMENTS ? classofRaw(O) + // ES3 arguments fallback + : (result = classofRaw(O)) === 'Object' && isCallable(O.callee) ? 'Arguments' : result; + }; + return classof; +} + +var toString; +var hasRequiredToString; + +function requireToString () { + if (hasRequiredToString) return toString; + hasRequiredToString = 1; + var classof = requireClassof(); + + var $String = String; + + toString = function (argument) { + if (classof(argument) === 'Symbol') throw new TypeError('Cannot convert a Symbol value to a string'); + return $String(argument); + }; + return toString; +} + +var objectDefineProperties = {}; + +var objectKeys; +var hasRequiredObjectKeys; + +function requireObjectKeys () { + if (hasRequiredObjectKeys) return objectKeys; + hasRequiredObjectKeys = 1; + var internalObjectKeys = requireObjectKeysInternal(); + var enumBugKeys = requireEnumBugKeys(); + + // `Object.keys` method + // https://tc39.es/ecma262/#sec-object.keys + // eslint-disable-next-line es/no-object-keys -- safe + objectKeys = Object.keys || function keys(O) { + return internalObjectKeys(O, enumBugKeys); + }; + return objectKeys; +} + +var hasRequiredObjectDefineProperties; + +function requireObjectDefineProperties () { + if (hasRequiredObjectDefineProperties) return objectDefineProperties; + hasRequiredObjectDefineProperties = 1; + var DESCRIPTORS = requireDescriptors(); + var V8_PROTOTYPE_DEFINE_BUG = requireV8PrototypeDefineBug(); + var definePropertyModule = requireObjectDefineProperty(); + var anObject = requireAnObject(); + var toIndexedObject = requireToIndexedObject(); + var objectKeys = requireObjectKeys(); + + // `Object.defineProperties` method + // https://tc39.es/ecma262/#sec-object.defineproperties + // eslint-disable-next-line es/no-object-defineproperties -- safe + objectDefineProperties.f = DESCRIPTORS && !V8_PROTOTYPE_DEFINE_BUG ? Object.defineProperties : function defineProperties(O, Properties) { + anObject(O); + var props = toIndexedObject(Properties); + var keys = objectKeys(Properties); + var length = keys.length; + var index = 0; + var key; + while (length > index) definePropertyModule.f(O, key = keys[index++], props[key]); + return O; + }; + return objectDefineProperties; +} + +var html; +var hasRequiredHtml; + +function requireHtml () { + if (hasRequiredHtml) return html; + hasRequiredHtml = 1; + var getBuiltIn = requireGetBuiltIn(); + + html = getBuiltIn('document', 'documentElement'); + return html; +} + +var objectCreate; +var hasRequiredObjectCreate; + +function requireObjectCreate () { + if (hasRequiredObjectCreate) return objectCreate; + hasRequiredObjectCreate = 1; + /* global ActiveXObject -- old IE, WSH */ + var anObject = requireAnObject(); + var definePropertiesModule = requireObjectDefineProperties(); + var enumBugKeys = requireEnumBugKeys(); + var hiddenKeys = requireHiddenKeys(); + var html = requireHtml(); + var documentCreateElement = requireDocumentCreateElement(); + var sharedKey = requireSharedKey(); + + var GT = '>'; + var LT = '<'; + var PROTOTYPE = 'prototype'; + var SCRIPT = 'script'; + var IE_PROTO = sharedKey('IE_PROTO'); + + var EmptyConstructor = function () { /* empty */ }; + + var scriptTag = function (content) { + return LT + SCRIPT + GT + content + LT + '/' + SCRIPT + GT; + }; + + // Create object with fake `null` prototype: use ActiveX Object with cleared prototype + var NullProtoObjectViaActiveX = function (activeXDocument) { + activeXDocument.write(scriptTag('')); + activeXDocument.close(); + var temp = activeXDocument.parentWindow.Object; + // eslint-disable-next-line no-useless-assignment -- avoid memory leak + activeXDocument = null; + return temp; + }; + + // Create object with fake `null` prototype: use iframe Object with cleared prototype + var NullProtoObjectViaIFrame = function () { + // Thrash, waste and sodomy: IE GC bug + var iframe = documentCreateElement('iframe'); + var JS = 'java' + SCRIPT + ':'; + var iframeDocument; + iframe.style.display = 'none'; + html.appendChild(iframe); + // https://github.com/zloirock/core-js/issues/475 + iframe.src = String(JS); + iframeDocument = iframe.contentWindow.document; + iframeDocument.open(); + iframeDocument.write(scriptTag('document.F=Object')); + iframeDocument.close(); + return iframeDocument.F; + }; + + // Check for document.domain and active x support + // No need to use active x approach when document.domain is not set + // see https://github.com/es-shims/es5-shim/issues/150 + // variation of https://github.com/kitcambridge/es5-shim/commit/4f738ac066346 + // avoid IE GC bug + var activeXDocument; + var NullProtoObject = function () { + try { + activeXDocument = new ActiveXObject('htmlfile'); + } catch (error) { /* ignore */ } + NullProtoObject = typeof document != 'undefined' + ? document.domain && activeXDocument + ? NullProtoObjectViaActiveX(activeXDocument) // old IE + : NullProtoObjectViaIFrame() + : NullProtoObjectViaActiveX(activeXDocument); // WSH + var length = enumBugKeys.length; + while (length--) delete NullProtoObject[PROTOTYPE][enumBugKeys[length]]; + return NullProtoObject(); + }; + + hiddenKeys[IE_PROTO] = true; + + // `Object.create` method + // https://tc39.es/ecma262/#sec-object.create + // eslint-disable-next-line es/no-object-create -- safe + objectCreate = Object.create || function create(O, Properties) { + var result; + if (O !== null) { + EmptyConstructor[PROTOTYPE] = anObject(O); + result = new EmptyConstructor(); + EmptyConstructor[PROTOTYPE] = null; + // add "__proto__" for Object.getPrototypeOf polyfill + result[IE_PROTO] = O; + } else result = NullProtoObject(); + return Properties === undefined ? result : definePropertiesModule.f(result, Properties); + }; + return objectCreate; +} var objectGetOwnPropertyNamesExternal = {}; -var toIndexedObject$9 = toIndexedObject$d; -var nativeGetOwnPropertyNames$2 = objectGetOwnPropertyNames.f; - -var toString$1 = {}.toString; - -var windowNames = typeof window == 'object' && window && Object.getOwnPropertyNames - ? Object.getOwnPropertyNames(window) : []; - -var getWindowNames = function (it) { - try { - return nativeGetOwnPropertyNames$2(it); - } catch (error) { - return windowNames.slice(); - } -}; - -// fallback for IE11 buggy Object.getOwnPropertyNames with iframe and window -objectGetOwnPropertyNamesExternal.f = function getOwnPropertyNames(it) { - return windowNames && toString$1.call(it) == '[object Window]' - ? getWindowNames(it) - : nativeGetOwnPropertyNames$2(toIndexedObject$9(it)); -}; - -var global$B = global$L; -var shared$3 = shared$6.exports; -var has$i = has$o; -var uid$3 = uid$5; -var NATIVE_SYMBOL$1 = nativeSymbol; -var USE_SYMBOL_AS_UID$1 = useSymbolAsUid; - -var WellKnownSymbolsStore$1 = shared$3('wks'); -var Symbol$1 = global$B.Symbol; -var createWellKnownSymbol = USE_SYMBOL_AS_UID$1 ? Symbol$1 : Symbol$1 && Symbol$1.withoutSetter || uid$3; - -var wellKnownSymbol$C = function (name) { - if (!has$i(WellKnownSymbolsStore$1, name)) { - if (NATIVE_SYMBOL$1 && has$i(Symbol$1, name)) WellKnownSymbolsStore$1[name] = Symbol$1[name]; - else WellKnownSymbolsStore$1[name] = createWellKnownSymbol('Symbol.' + name); - } return WellKnownSymbolsStore$1[name]; -}; +var arraySlice; +var hasRequiredArraySlice; + +function requireArraySlice () { + if (hasRequiredArraySlice) return arraySlice; + hasRequiredArraySlice = 1; + var uncurryThis = requireFunctionUncurryThis(); + + arraySlice = uncurryThis([].slice); + return arraySlice; +} + +var hasRequiredObjectGetOwnPropertyNamesExternal; + +function requireObjectGetOwnPropertyNamesExternal () { + if (hasRequiredObjectGetOwnPropertyNamesExternal) return objectGetOwnPropertyNamesExternal; + hasRequiredObjectGetOwnPropertyNamesExternal = 1; + /* eslint-disable es/no-object-getownpropertynames -- safe */ + var classof = requireClassofRaw(); + var toIndexedObject = requireToIndexedObject(); + var $getOwnPropertyNames = requireObjectGetOwnPropertyNames().f; + var arraySlice = requireArraySlice(); + + var windowNames = typeof window == 'object' && window && Object.getOwnPropertyNames + ? Object.getOwnPropertyNames(window) : []; + + var getWindowNames = function (it) { + try { + return $getOwnPropertyNames(it); + } catch (error) { + return arraySlice(windowNames); + } + }; + + // fallback for IE11 buggy Object.getOwnPropertyNames with iframe and window + objectGetOwnPropertyNamesExternal.f = function getOwnPropertyNames(it) { + return windowNames && classof(it) === 'Window' + ? getWindowNames(it) + : $getOwnPropertyNames(toIndexedObject(it)); + }; + return objectGetOwnPropertyNamesExternal; +} + +var defineBuiltInAccessor; +var hasRequiredDefineBuiltInAccessor; + +function requireDefineBuiltInAccessor () { + if (hasRequiredDefineBuiltInAccessor) return defineBuiltInAccessor; + hasRequiredDefineBuiltInAccessor = 1; + var makeBuiltIn = requireMakeBuiltIn(); + var defineProperty = requireObjectDefineProperty(); + + defineBuiltInAccessor = function (target, name, descriptor) { + if (descriptor.get) makeBuiltIn(descriptor.get, name, { getter: true }); + if (descriptor.set) makeBuiltIn(descriptor.set, name, { setter: true }); + return defineProperty.f(target, name, descriptor); + }; + return defineBuiltInAccessor; +} var wellKnownSymbolWrapped = {}; -var wellKnownSymbol$B = wellKnownSymbol$C; - -wellKnownSymbolWrapped.f = wellKnownSymbol$B; - -var path$4 = path$6; -var has$h = has$o; -var wrappedWellKnownSymbolModule$1 = wellKnownSymbolWrapped; -var defineProperty$f = objectDefineProperty.f; - -var defineWellKnownSymbol$j = function (NAME) { - var Symbol = path$4.Symbol || (path$4.Symbol = {}); - if (!has$h(Symbol, NAME)) defineProperty$f(Symbol, NAME, { - value: wrappedWellKnownSymbolModule$1.f(NAME) - }); -}; - -var defineProperty$e = objectDefineProperty.f; -var has$g = has$o; -var wellKnownSymbol$A = wellKnownSymbol$C; - -var TO_STRING_TAG$8 = wellKnownSymbol$A('toStringTag'); - -var setToStringTag$b = function (it, TAG, STATIC) { - if (it && !has$g(it = STATIC ? it : it.prototype, TO_STRING_TAG$8)) { - defineProperty$e(it, TO_STRING_TAG$8, { configurable: true, value: TAG }); - } -}; - -var aFunction$R = function (it) { - if (typeof it != 'function') { - throw TypeError(String(it) + ' is not a function'); - } return it; -}; - -var aFunction$Q = aFunction$R; - -// optional / simple context binding -var functionBindContext = function (fn, that, length) { - aFunction$Q(fn); - if (that === undefined) return fn; - switch (length) { - case 0: return function () { - return fn.call(that); - }; - case 1: return function (a) { - return fn.call(that, a); - }; - case 2: return function (a, b) { - return fn.call(that, a, b); - }; - case 3: return function (a, b, c) { - return fn.call(that, a, b, c); - }; - } - return function (/* ...args */) { - return fn.apply(that, arguments); - }; -}; - -var isObject$w = isObject$B; -var isArray$7 = isArray$8; -var wellKnownSymbol$z = wellKnownSymbol$C; - -var SPECIES$6 = wellKnownSymbol$z('species'); - -// `ArraySpeciesCreate` abstract operation -// https://tc39.es/ecma262/#sec-arrayspeciescreate -var arraySpeciesCreate$6 = function (originalArray, length) { - var C; - if (isArray$7(originalArray)) { - C = originalArray.constructor; - // cross-realm fallback - if (typeof C == 'function' && (C === Array || isArray$7(C.prototype))) C = undefined; - else if (isObject$w(C)) { - C = C[SPECIES$6]; - if (C === null) C = undefined; - } - } return new (C === undefined ? Array : C)(length === 0 ? 0 : length); -}; - -var bind$n = functionBindContext; -var IndexedObject$3 = indexedObject; -var toObject$t = toObject$u; -var toLength$w = toLength$y; -var arraySpeciesCreate$5 = arraySpeciesCreate$6; - -var push$3 = [].push; - -// `Array.prototype.{ forEach, map, filter, some, every, find, findIndex, filterOut }` methods implementation -var createMethod$6 = function (TYPE) { - var IS_MAP = TYPE == 1; - var IS_FILTER = TYPE == 2; - var IS_SOME = TYPE == 3; - var IS_EVERY = TYPE == 4; - var IS_FIND_INDEX = TYPE == 6; - var IS_FILTER_OUT = TYPE == 7; - var NO_HOLES = TYPE == 5 || IS_FIND_INDEX; - return function ($this, callbackfn, that, specificCreate) { - var O = toObject$t($this); - var self = IndexedObject$3(O); - var boundFunction = bind$n(callbackfn, that, 3); - var length = toLength$w(self.length); - var index = 0; - var create = specificCreate || arraySpeciesCreate$5; - var target = IS_MAP ? create($this, length) : IS_FILTER || IS_FILTER_OUT ? create($this, 0) : undefined; - var value, result; - for (;length > index; index++) if (NO_HOLES || index in self) { - value = self[index]; - result = boundFunction(value, index, O); - if (TYPE) { - if (IS_MAP) target[index] = result; // map - else if (result) switch (TYPE) { - case 3: return true; // some - case 5: return value; // find - case 6: return index; // findIndex - case 2: push$3.call(target, value); // filter - } else switch (TYPE) { - case 4: return false; // every - case 7: push$3.call(target, value); // filterOut - } - } - } - return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : target; - }; -}; - -var arrayIteration = { - // `Array.prototype.forEach` method - // https://tc39.es/ecma262/#sec-array.prototype.foreach - forEach: createMethod$6(0), - // `Array.prototype.map` method - // https://tc39.es/ecma262/#sec-array.prototype.map - map: createMethod$6(1), - // `Array.prototype.filter` method - // https://tc39.es/ecma262/#sec-array.prototype.filter - filter: createMethod$6(2), - // `Array.prototype.some` method - // https://tc39.es/ecma262/#sec-array.prototype.some - some: createMethod$6(3), - // `Array.prototype.every` method - // https://tc39.es/ecma262/#sec-array.prototype.every - every: createMethod$6(4), - // `Array.prototype.find` method - // https://tc39.es/ecma262/#sec-array.prototype.find - find: createMethod$6(5), - // `Array.prototype.findIndex` method - // https://tc39.es/ecma262/#sec-array.prototype.findIndex - findIndex: createMethod$6(6), - // `Array.prototype.filterOut` method - // https://github.com/tc39/proposal-array-filtering - filterOut: createMethod$6(7) -}; - -var $$44 = _export; -var global$A = global$L; -var getBuiltIn$q = getBuiltIn$t; -var DESCRIPTORS$u = descriptors; -var NATIVE_SYMBOL = nativeSymbol; -var USE_SYMBOL_AS_UID = useSymbolAsUid; -var fails$S = fails$Y; -var has$f = has$o; -var isArray$6 = isArray$8; -var isObject$v = isObject$B; -var anObject$1u = anObject$1z; -var toObject$s = toObject$u; -var toIndexedObject$8 = toIndexedObject$d; -var toPrimitive$8 = toPrimitive$b; -var createPropertyDescriptor$6 = createPropertyDescriptor$9; -var nativeObjectCreate = objectCreate; -var objectKeys$3 = objectKeys$5; -var getOwnPropertyNamesModule = objectGetOwnPropertyNames; -var getOwnPropertyNamesExternal = objectGetOwnPropertyNamesExternal; -var getOwnPropertySymbolsModule$1 = objectGetOwnPropertySymbols; -var getOwnPropertyDescriptorModule$5 = objectGetOwnPropertyDescriptor; -var definePropertyModule$9 = objectDefineProperty; -var propertyIsEnumerableModule$1 = objectPropertyIsEnumerable; -var createNonEnumerableProperty$h = createNonEnumerableProperty$m; -var redefine$e = redefine$g.exports; -var shared$2 = shared$6.exports; -var sharedKey$1 = sharedKey$4; -var hiddenKeys$1 = hiddenKeys$6; -var uid$2 = uid$5; -var wellKnownSymbol$y = wellKnownSymbol$C; -var wrappedWellKnownSymbolModule = wellKnownSymbolWrapped; -var defineWellKnownSymbol$i = defineWellKnownSymbol$j; -var setToStringTag$a = setToStringTag$b; -var InternalStateModule$h = internalState; -var $forEach$3 = arrayIteration.forEach; - -var HIDDEN = sharedKey$1('hidden'); -var SYMBOL = 'Symbol'; -var PROTOTYPE$1 = 'prototype'; -var TO_PRIMITIVE$1 = wellKnownSymbol$y('toPrimitive'); -var setInternalState$i = InternalStateModule$h.set; -var getInternalState$e = InternalStateModule$h.getterFor(SYMBOL); -var ObjectPrototype$3 = Object[PROTOTYPE$1]; -var $Symbol = global$A.Symbol; -var $stringify$1 = getBuiltIn$q('JSON', 'stringify'); -var nativeGetOwnPropertyDescriptor$2 = getOwnPropertyDescriptorModule$5.f; -var nativeDefineProperty$1 = definePropertyModule$9.f; -var nativeGetOwnPropertyNames$1 = getOwnPropertyNamesExternal.f; -var nativePropertyIsEnumerable = propertyIsEnumerableModule$1.f; -var AllSymbols = shared$2('symbols'); -var ObjectPrototypeSymbols = shared$2('op-symbols'); -var StringToSymbolRegistry = shared$2('string-to-symbol-registry'); -var SymbolToStringRegistry = shared$2('symbol-to-string-registry'); -var WellKnownSymbolsStore = shared$2('wks'); -var QObject = global$A.QObject; -// Don't use setters in Qt Script, https://github.com/zloirock/core-js/issues/173 -var USE_SETTER = !QObject || !QObject[PROTOTYPE$1] || !QObject[PROTOTYPE$1].findChild; - -// fallback for old Android, https://code.google.com/p/v8/issues/detail?id=687 -var setSymbolDescriptor = DESCRIPTORS$u && fails$S(function () { - return nativeObjectCreate(nativeDefineProperty$1({}, 'a', { - get: function () { return nativeDefineProperty$1(this, 'a', { value: 7 }).a; } - })).a != 7; -}) ? function (O, P, Attributes) { - var ObjectPrototypeDescriptor = nativeGetOwnPropertyDescriptor$2(ObjectPrototype$3, P); - if (ObjectPrototypeDescriptor) delete ObjectPrototype$3[P]; - nativeDefineProperty$1(O, P, Attributes); - if (ObjectPrototypeDescriptor && O !== ObjectPrototype$3) { - nativeDefineProperty$1(ObjectPrototype$3, P, ObjectPrototypeDescriptor); - } -} : nativeDefineProperty$1; - -var wrap$1 = function (tag, description) { - var symbol = AllSymbols[tag] = nativeObjectCreate($Symbol[PROTOTYPE$1]); - setInternalState$i(symbol, { - type: SYMBOL, - tag: tag, - description: description - }); - if (!DESCRIPTORS$u) symbol.description = description; - return symbol; -}; - -var isSymbol = USE_SYMBOL_AS_UID ? function (it) { - return typeof it == 'symbol'; -} : function (it) { - return Object(it) instanceof $Symbol; -}; - -var $defineProperty = function defineProperty(O, P, Attributes) { - if (O === ObjectPrototype$3) $defineProperty(ObjectPrototypeSymbols, P, Attributes); - anObject$1u(O); - var key = toPrimitive$8(P, true); - anObject$1u(Attributes); - if (has$f(AllSymbols, key)) { - if (!Attributes.enumerable) { - if (!has$f(O, HIDDEN)) nativeDefineProperty$1(O, HIDDEN, createPropertyDescriptor$6(1, {})); - O[HIDDEN][key] = true; - } else { - if (has$f(O, HIDDEN) && O[HIDDEN][key]) O[HIDDEN][key] = false; - Attributes = nativeObjectCreate(Attributes, { enumerable: createPropertyDescriptor$6(0, false) }); - } return setSymbolDescriptor(O, key, Attributes); - } return nativeDefineProperty$1(O, key, Attributes); -}; - -var $defineProperties = function defineProperties(O, Properties) { - anObject$1u(O); - var properties = toIndexedObject$8(Properties); - var keys = objectKeys$3(properties).concat($getOwnPropertySymbols(properties)); - $forEach$3(keys, function (key) { - if (!DESCRIPTORS$u || $propertyIsEnumerable.call(properties, key)) $defineProperty(O, key, properties[key]); - }); - return O; -}; - -var $create = function create(O, Properties) { - return Properties === undefined ? nativeObjectCreate(O) : $defineProperties(nativeObjectCreate(O), Properties); -}; - -var $propertyIsEnumerable = function propertyIsEnumerable(V) { - var P = toPrimitive$8(V, true); - var enumerable = nativePropertyIsEnumerable.call(this, P); - if (this === ObjectPrototype$3 && has$f(AllSymbols, P) && !has$f(ObjectPrototypeSymbols, P)) return false; - return enumerable || !has$f(this, P) || !has$f(AllSymbols, P) || has$f(this, HIDDEN) && this[HIDDEN][P] ? enumerable : true; -}; - -var $getOwnPropertyDescriptor = function getOwnPropertyDescriptor(O, P) { - var it = toIndexedObject$8(O); - var key = toPrimitive$8(P, true); - if (it === ObjectPrototype$3 && has$f(AllSymbols, key) && !has$f(ObjectPrototypeSymbols, key)) return; - var descriptor = nativeGetOwnPropertyDescriptor$2(it, key); - if (descriptor && has$f(AllSymbols, key) && !(has$f(it, HIDDEN) && it[HIDDEN][key])) { - descriptor.enumerable = true; - } - return descriptor; -}; - -var $getOwnPropertyNames = function getOwnPropertyNames(O) { - var names = nativeGetOwnPropertyNames$1(toIndexedObject$8(O)); - var result = []; - $forEach$3(names, function (key) { - if (!has$f(AllSymbols, key) && !has$f(hiddenKeys$1, key)) result.push(key); - }); - return result; -}; - -var $getOwnPropertySymbols = function getOwnPropertySymbols(O) { - var IS_OBJECT_PROTOTYPE = O === ObjectPrototype$3; - var names = nativeGetOwnPropertyNames$1(IS_OBJECT_PROTOTYPE ? ObjectPrototypeSymbols : toIndexedObject$8(O)); - var result = []; - $forEach$3(names, function (key) { - if (has$f(AllSymbols, key) && (!IS_OBJECT_PROTOTYPE || has$f(ObjectPrototype$3, key))) { - result.push(AllSymbols[key]); - } - }); - return result; -}; - -// `Symbol` constructor -// https://tc39.es/ecma262/#sec-symbol-constructor -if (!NATIVE_SYMBOL) { - $Symbol = function Symbol() { - if (this instanceof $Symbol) throw TypeError('Symbol is not a constructor'); - var description = !arguments.length || arguments[0] === undefined ? undefined : String(arguments[0]); - var tag = uid$2(description); - var setter = function (value) { - if (this === ObjectPrototype$3) setter.call(ObjectPrototypeSymbols, value); - if (has$f(this, HIDDEN) && has$f(this[HIDDEN], tag)) this[HIDDEN][tag] = false; - setSymbolDescriptor(this, tag, createPropertyDescriptor$6(1, value)); - }; - if (DESCRIPTORS$u && USE_SETTER) setSymbolDescriptor(ObjectPrototype$3, tag, { configurable: true, set: setter }); - return wrap$1(tag, description); - }; - - redefine$e($Symbol[PROTOTYPE$1], 'toString', function toString() { - return getInternalState$e(this).tag; - }); - - redefine$e($Symbol, 'withoutSetter', function (description) { - return wrap$1(uid$2(description), description); - }); - - propertyIsEnumerableModule$1.f = $propertyIsEnumerable; - definePropertyModule$9.f = $defineProperty; - getOwnPropertyDescriptorModule$5.f = $getOwnPropertyDescriptor; - getOwnPropertyNamesModule.f = getOwnPropertyNamesExternal.f = $getOwnPropertyNames; - getOwnPropertySymbolsModule$1.f = $getOwnPropertySymbols; - - wrappedWellKnownSymbolModule.f = function (name) { - return wrap$1(wellKnownSymbol$y(name), name); - }; - - if (DESCRIPTORS$u) { - // https://github.com/tc39/proposal-Symbol-description - nativeDefineProperty$1($Symbol[PROTOTYPE$1], 'description', { - configurable: true, - get: function description() { - return getInternalState$e(this).description; - } - }); - { - redefine$e(ObjectPrototype$3, 'propertyIsEnumerable', $propertyIsEnumerable, { unsafe: true }); - } - } -} - -$$44({ global: true, wrap: true, forced: !NATIVE_SYMBOL, sham: !NATIVE_SYMBOL }, { - Symbol: $Symbol -}); - -$forEach$3(objectKeys$3(WellKnownSymbolsStore), function (name) { - defineWellKnownSymbol$i(name); -}); - -$$44({ target: SYMBOL, stat: true, forced: !NATIVE_SYMBOL }, { - // `Symbol.for` method - // https://tc39.es/ecma262/#sec-symbol.for - 'for': function (key) { - var string = String(key); - if (has$f(StringToSymbolRegistry, string)) return StringToSymbolRegistry[string]; - var symbol = $Symbol(string); - StringToSymbolRegistry[string] = symbol; - SymbolToStringRegistry[symbol] = string; - return symbol; - }, - // `Symbol.keyFor` method - // https://tc39.es/ecma262/#sec-symbol.keyfor - keyFor: function keyFor(sym) { - if (!isSymbol(sym)) throw TypeError(sym + ' is not a symbol'); - if (has$f(SymbolToStringRegistry, sym)) return SymbolToStringRegistry[sym]; - }, - useSetter: function () { USE_SETTER = true; }, - useSimple: function () { USE_SETTER = false; } -}); - -$$44({ target: 'Object', stat: true, forced: !NATIVE_SYMBOL, sham: !DESCRIPTORS$u }, { - // `Object.create` method - // https://tc39.es/ecma262/#sec-object.create - create: $create, - // `Object.defineProperty` method - // https://tc39.es/ecma262/#sec-object.defineproperty - defineProperty: $defineProperty, - // `Object.defineProperties` method - // https://tc39.es/ecma262/#sec-object.defineproperties - defineProperties: $defineProperties, - // `Object.getOwnPropertyDescriptor` method - // https://tc39.es/ecma262/#sec-object.getownpropertydescriptors - getOwnPropertyDescriptor: $getOwnPropertyDescriptor -}); - -$$44({ target: 'Object', stat: true, forced: !NATIVE_SYMBOL }, { - // `Object.getOwnPropertyNames` method - // https://tc39.es/ecma262/#sec-object.getownpropertynames - getOwnPropertyNames: $getOwnPropertyNames, - // `Object.getOwnPropertySymbols` method - // https://tc39.es/ecma262/#sec-object.getownpropertysymbols - getOwnPropertySymbols: $getOwnPropertySymbols -}); - -// Chrome 38 and 39 `Object.getOwnPropertySymbols` fails on primitives -// https://bugs.chromium.org/p/v8/issues/detail?id=3443 -$$44({ target: 'Object', stat: true, forced: fails$S(function () { getOwnPropertySymbolsModule$1.f(1); }) }, { - getOwnPropertySymbols: function getOwnPropertySymbols(it) { - return getOwnPropertySymbolsModule$1.f(toObject$s(it)); - } -}); - -// `JSON.stringify` method behavior with symbols -// https://tc39.es/ecma262/#sec-json.stringify -if ($stringify$1) { - var FORCED_JSON_STRINGIFY = !NATIVE_SYMBOL || fails$S(function () { - var symbol = $Symbol(); - // MS Edge converts symbol values to JSON as {} - return $stringify$1([symbol]) != '[null]' - // WebKit converts symbol values to JSON as null - || $stringify$1({ a: symbol }) != '{}' - // V8 throws on boxed symbols - || $stringify$1(Object(symbol)) != '{}'; - }); - - $$44({ target: 'JSON', stat: true, forced: FORCED_JSON_STRINGIFY }, { - // eslint-disable-next-line no-unused-vars - stringify: function stringify(it, replacer, space) { - var args = [it]; - var index = 1; - var $replacer; - while (arguments.length > index) args.push(arguments[index++]); - $replacer = replacer; - if (!isObject$v(replacer) && it === undefined || isSymbol(it)) return; // IE8 returns string on undefined - if (!isArray$6(replacer)) replacer = function (key, value) { - if (typeof $replacer == 'function') value = $replacer.call(this, key, value); - if (!isSymbol(value)) return value; - }; - args[1] = replacer; - return $stringify$1.apply(null, args); - } - }); -} - -// `Symbol.prototype[@@toPrimitive]` method -// https://tc39.es/ecma262/#sec-symbol.prototype-@@toprimitive -if (!$Symbol[PROTOTYPE$1][TO_PRIMITIVE$1]) { - createNonEnumerableProperty$h($Symbol[PROTOTYPE$1], TO_PRIMITIVE$1, $Symbol[PROTOTYPE$1].valueOf); -} -// `Symbol.prototype[@@toStringTag]` property -// https://tc39.es/ecma262/#sec-symbol.prototype-@@tostringtag -setToStringTag$a($Symbol, SYMBOL); - -hiddenKeys$1[HIDDEN] = true; - -var defineWellKnownSymbol$h = defineWellKnownSymbol$j; - -// `Symbol.asyncIterator` well-known symbol -// https://tc39.es/ecma262/#sec-symbol.asynciterator -defineWellKnownSymbol$h('asyncIterator'); - -var $$43 = _export; -var DESCRIPTORS$t = descriptors; -var global$z = global$L; -var has$e = has$o; -var isObject$u = isObject$B; -var defineProperty$d = objectDefineProperty.f; -var copyConstructorProperties = copyConstructorProperties$2; - -var NativeSymbol = global$z.Symbol; - -if (DESCRIPTORS$t && typeof NativeSymbol == 'function' && (!('description' in NativeSymbol.prototype) || - // Safari 12 bug - NativeSymbol().description !== undefined -)) { - var EmptyStringDescriptionStore = {}; - // wrap Symbol constructor for correct work with undefined description - var SymbolWrapper = function Symbol() { - var description = arguments.length < 1 || arguments[0] === undefined ? undefined : String(arguments[0]); - var result = this instanceof SymbolWrapper - ? new NativeSymbol(description) - // in Edge 13, String(Symbol(undefined)) === 'Symbol(undefined)' - : description === undefined ? NativeSymbol() : NativeSymbol(description); - if (description === '') EmptyStringDescriptionStore[result] = true; - return result; - }; - copyConstructorProperties(SymbolWrapper, NativeSymbol); - var symbolPrototype = SymbolWrapper.prototype = NativeSymbol.prototype; - symbolPrototype.constructor = SymbolWrapper; - - var symbolToString = symbolPrototype.toString; - var native = String(NativeSymbol('test')) == 'Symbol(test)'; - var regexp = /^Symbol\((.*)\)[^)]+$/; - defineProperty$d(symbolPrototype, 'description', { - configurable: true, - get: function description() { - var symbol = isObject$u(this) ? this.valueOf() : this; - var string = symbolToString.call(symbol); - if (has$e(EmptyStringDescriptionStore, symbol)) return ''; - var desc = native ? string.slice(7, -1) : string.replace(regexp, '$1'); - return desc === '' ? undefined : desc; - } - }); - - $$43({ global: true, forced: true }, { - Symbol: SymbolWrapper - }); -} - -var defineWellKnownSymbol$g = defineWellKnownSymbol$j; - -// `Symbol.hasInstance` well-known symbol -// https://tc39.es/ecma262/#sec-symbol.hasinstance -defineWellKnownSymbol$g('hasInstance'); - -var defineWellKnownSymbol$f = defineWellKnownSymbol$j; - -// `Symbol.isConcatSpreadable` well-known symbol -// https://tc39.es/ecma262/#sec-symbol.isconcatspreadable -defineWellKnownSymbol$f('isConcatSpreadable'); - -var defineWellKnownSymbol$e = defineWellKnownSymbol$j; - -// `Symbol.iterator` well-known symbol -// https://tc39.es/ecma262/#sec-symbol.iterator -defineWellKnownSymbol$e('iterator'); - -var defineWellKnownSymbol$d = defineWellKnownSymbol$j; - -// `Symbol.match` well-known symbol -// https://tc39.es/ecma262/#sec-symbol.match -defineWellKnownSymbol$d('match'); - -var defineWellKnownSymbol$c = defineWellKnownSymbol$j; - -// `Symbol.matchAll` well-known symbol -// https://tc39.es/ecma262/#sec-symbol.matchall -defineWellKnownSymbol$c('matchAll'); - -var defineWellKnownSymbol$b = defineWellKnownSymbol$j; - -// `Symbol.replace` well-known symbol -// https://tc39.es/ecma262/#sec-symbol.replace -defineWellKnownSymbol$b('replace'); - -var defineWellKnownSymbol$a = defineWellKnownSymbol$j; - -// `Symbol.search` well-known symbol -// https://tc39.es/ecma262/#sec-symbol.search -defineWellKnownSymbol$a('search'); - -var defineWellKnownSymbol$9 = defineWellKnownSymbol$j; - -// `Symbol.species` well-known symbol -// https://tc39.es/ecma262/#sec-symbol.species -defineWellKnownSymbol$9('species'); - -var defineWellKnownSymbol$8 = defineWellKnownSymbol$j; - -// `Symbol.split` well-known symbol -// https://tc39.es/ecma262/#sec-symbol.split -defineWellKnownSymbol$8('split'); - -var defineWellKnownSymbol$7 = defineWellKnownSymbol$j; - -// `Symbol.toPrimitive` well-known symbol -// https://tc39.es/ecma262/#sec-symbol.toprimitive -defineWellKnownSymbol$7('toPrimitive'); - -var defineWellKnownSymbol$6 = defineWellKnownSymbol$j; - -// `Symbol.toStringTag` well-known symbol -// https://tc39.es/ecma262/#sec-symbol.tostringtag -defineWellKnownSymbol$6('toStringTag'); - -var defineWellKnownSymbol$5 = defineWellKnownSymbol$j; - -// `Symbol.unscopables` well-known symbol -// https://tc39.es/ecma262/#sec-symbol.unscopables -defineWellKnownSymbol$5('unscopables'); - -var fails$R = fails$Y; - -var correctPrototypeGetter = !fails$R(function () { - function F() { /* empty */ } - F.prototype.constructor = null; - return Object.getPrototypeOf(new F()) !== F.prototype; -}); - -var has$d = has$o; -var toObject$r = toObject$u; -var sharedKey = sharedKey$4; -var CORRECT_PROTOTYPE_GETTER$2 = correctPrototypeGetter; - -var IE_PROTO = sharedKey('IE_PROTO'); -var ObjectPrototype$2 = Object.prototype; +var hasRequiredWellKnownSymbolWrapped; -// `Object.getPrototypeOf` method -// https://tc39.es/ecma262/#sec-object.getprototypeof -var objectGetPrototypeOf$1 = CORRECT_PROTOTYPE_GETTER$2 ? Object.getPrototypeOf : function (O) { - O = toObject$r(O); - if (has$d(O, IE_PROTO)) return O[IE_PROTO]; - if (typeof O.constructor == 'function' && O instanceof O.constructor) { - return O.constructor.prototype; - } return O instanceof Object ? ObjectPrototype$2 : null; -}; +function requireWellKnownSymbolWrapped () { + if (hasRequiredWellKnownSymbolWrapped) return wellKnownSymbolWrapped; + hasRequiredWellKnownSymbolWrapped = 1; + var wellKnownSymbol = requireWellKnownSymbol(); -var isObject$t = isObject$B; + wellKnownSymbolWrapped.f = wellKnownSymbol; + return wellKnownSymbolWrapped; +} -var aPossiblePrototype$2 = function (it) { - if (!isObject$t(it) && it !== null) { - throw TypeError("Can't set " + String(it) + ' as a prototype'); - } return it; -}; - -var anObject$1t = anObject$1z; -var aPossiblePrototype$1 = aPossiblePrototype$2; - -// `Object.setPrototypeOf` method -// https://tc39.es/ecma262/#sec-object.setprototypeof -// Works with __proto__ only. Old v8 can't work with null proto objects. -/* eslint-disable no-proto */ -var objectSetPrototypeOf$1 = Object.setPrototypeOf || ('__proto__' in {} ? function () { - var CORRECT_SETTER = false; - var test = {}; - var setter; - try { - setter = Object.getOwnPropertyDescriptor(Object.prototype, '__proto__').set; - setter.call(test, []); - CORRECT_SETTER = test instanceof Array; - } catch (error) { /* empty */ } - return function setPrototypeOf(O, proto) { - anObject$1t(O); - aPossiblePrototype$1(proto); - if (CORRECT_SETTER) setter.call(O, proto); - else O.__proto__ = proto; - return O; - }; -}() : undefined); - -var iterators = {}; - -var wellKnownSymbol$x = wellKnownSymbol$C; -var Iterators$4 = iterators; - -var ITERATOR$8 = wellKnownSymbol$x('iterator'); -var ArrayPrototype$1 = Array.prototype; - -// check on default Array iterator -var isArrayIteratorMethod$3 = function (it) { - return it !== undefined && (Iterators$4.Array === it || ArrayPrototype$1[ITERATOR$8] === it); -}; - -var wellKnownSymbol$w = wellKnownSymbol$C; - -var TO_STRING_TAG$7 = wellKnownSymbol$w('toStringTag'); -var test$2 = {}; - -test$2[TO_STRING_TAG$7] = 'z'; - -var toStringTagSupport = String(test$2) === '[object z]'; - -var TO_STRING_TAG_SUPPORT$2 = toStringTagSupport; -var classofRaw = classofRaw$1; -var wellKnownSymbol$v = wellKnownSymbol$C; - -var TO_STRING_TAG$6 = wellKnownSymbol$v('toStringTag'); -// ES3 wrong here -var CORRECT_ARGUMENTS = classofRaw(function () { return arguments; }()) == 'Arguments'; - -// fallback for IE11 Script Access Denied error -var tryGet = function (it, key) { - try { - return it[key]; - } catch (error) { /* empty */ } -}; - -// getting tag from ES6+ `Object.prototype.toString` -var classof$b = TO_STRING_TAG_SUPPORT$2 ? classofRaw : function (it) { - var O, tag, result; - return it === undefined ? 'Undefined' : it === null ? 'Null' - // @@toStringTag case - : typeof (tag = tryGet(O = Object(it), TO_STRING_TAG$6)) == 'string' ? tag - // builtinTag case - : CORRECT_ARGUMENTS ? classofRaw(O) - // ES3 arguments fallback - : (result = classofRaw(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : result; -}; - -var classof$a = classof$b; -var Iterators$3 = iterators; -var wellKnownSymbol$u = wellKnownSymbol$C; - -var ITERATOR$7 = wellKnownSymbol$u('iterator'); - -var getIteratorMethod$8 = function (it) { - if (it != undefined) return it[ITERATOR$7] - || it['@@iterator'] - || Iterators$3[classof$a(it)]; -}; - -var anObject$1s = anObject$1z; - -var iteratorClose$4 = function (iterator) { - var returnMethod = iterator['return']; - if (returnMethod !== undefined) { - return anObject$1s(returnMethod.call(iterator)).value; - } -}; - -var anObject$1r = anObject$1z; -var isArrayIteratorMethod$2 = isArrayIteratorMethod$3; -var toLength$v = toLength$y; -var bind$m = functionBindContext; -var getIteratorMethod$7 = getIteratorMethod$8; -var iteratorClose$3 = iteratorClose$4; - -var Result = function (stopped, result) { - this.stopped = stopped; - this.result = result; -}; - -var iterate$I = function (iterable, unboundFunction, options) { - var that = options && options.that; - var AS_ENTRIES = !!(options && options.AS_ENTRIES); - var IS_ITERATOR = !!(options && options.IS_ITERATOR); - var INTERRUPTED = !!(options && options.INTERRUPTED); - var fn = bind$m(unboundFunction, that, 1 + AS_ENTRIES + INTERRUPTED); - var iterator, iterFn, index, length, result, next, step; - - var stop = function (condition) { - if (iterator) iteratorClose$3(iterator); - return new Result(true, condition); - }; - - var callFn = function (value) { - if (AS_ENTRIES) { - anObject$1r(value); - return INTERRUPTED ? fn(value[0], value[1], stop) : fn(value[0], value[1]); - } return INTERRUPTED ? fn(value, stop) : fn(value); - }; - - if (IS_ITERATOR) { - iterator = iterable; - } else { - iterFn = getIteratorMethod$7(iterable); - if (typeof iterFn != 'function') throw TypeError('Target is not iterable'); - // optimisation for array iterators - if (isArrayIteratorMethod$2(iterFn)) { - for (index = 0, length = toLength$v(iterable.length); length > index; index++) { - result = callFn(iterable[index]); - if (result && result instanceof Result) return result; - } return new Result(false); - } - iterator = iterFn.call(iterable); - } - - next = iterator.next; - while (!(step = next.call(iterator)).done) { - try { - result = callFn(step.value); - } catch (error) { - iteratorClose$3(iterator); - throw error; - } - if (typeof result == 'object' && result && result instanceof Result) return result; - } return new Result(false); -}; - -var $$42 = _export; -var getPrototypeOf$d = objectGetPrototypeOf$1; -var setPrototypeOf$6 = objectSetPrototypeOf$1; -var create$c = objectCreate; -var createNonEnumerableProperty$g = createNonEnumerableProperty$m; -var createPropertyDescriptor$5 = createPropertyDescriptor$9; -var iterate$H = iterate$I; - -var $AggregateError = function AggregateError(errors, message) { - var that = this; - if (!(that instanceof $AggregateError)) return new $AggregateError(errors, message); - if (setPrototypeOf$6) { - // eslint-disable-next-line unicorn/error-message - that = setPrototypeOf$6(new Error(undefined), getPrototypeOf$d(that)); - } - if (message !== undefined) createNonEnumerableProperty$g(that, 'message', String(message)); - var errorsArray = []; - iterate$H(errors, errorsArray.push, { that: errorsArray }); - createNonEnumerableProperty$g(that, 'errors', errorsArray); - return that; -}; - -$AggregateError.prototype = create$c(Error.prototype, { - constructor: createPropertyDescriptor$5(5, $AggregateError), - message: createPropertyDescriptor$5(5, ''), - name: createPropertyDescriptor$5(5, 'AggregateError') -}); - -// `AggregateError` constructor -// https://tc39.es/ecma262/#sec-aggregate-error-constructor -$$42({ global: true }, { - AggregateError: $AggregateError -}); - -var anObject$1q = anObject$1z; -var iteratorClose$2 = iteratorClose$4; - -// call something on iterator step with safe closing on error -var callWithSafeIterationClosing$3 = function (iterator, fn, value, ENTRIES) { - try { - return ENTRIES ? fn(anObject$1q(value)[0], value[1]) : fn(value); - // 7.4.6 IteratorClose(iterator, completion) - } catch (error) { - iteratorClose$2(iterator); - throw error; - } -}; - -var toPrimitive$7 = toPrimitive$b; -var definePropertyModule$8 = objectDefineProperty; -var createPropertyDescriptor$4 = createPropertyDescriptor$9; - -var createProperty$7 = function (object, key, value) { - var propertyKey = toPrimitive$7(key); - if (propertyKey in object) definePropertyModule$8.f(object, propertyKey, createPropertyDescriptor$4(0, value)); - else object[propertyKey] = value; -}; - -var bind$l = functionBindContext; -var toObject$q = toObject$u; -var callWithSafeIterationClosing$2 = callWithSafeIterationClosing$3; -var isArrayIteratorMethod$1 = isArrayIteratorMethod$3; -var toLength$u = toLength$y; -var createProperty$6 = createProperty$7; -var getIteratorMethod$6 = getIteratorMethod$8; - -// `Array.from` method implementation -// https://tc39.es/ecma262/#sec-array.from -var arrayFrom$1 = function from(arrayLike /* , mapfn = undefined, thisArg = undefined */) { - var O = toObject$q(arrayLike); - var C = typeof this == 'function' ? this : Array; - var argumentsLength = arguments.length; - var mapfn = argumentsLength > 1 ? arguments[1] : undefined; - var mapping = mapfn !== undefined; - var iteratorMethod = getIteratorMethod$6(O); - var index = 0; - var length, result, step, iterator, next, value; - if (mapping) mapfn = bind$l(mapfn, argumentsLength > 2 ? arguments[2] : undefined, 2); - // if the target is not iterable or it's an array with the default iterator - use a simple case - if (iteratorMethod != undefined && !(C == Array && isArrayIteratorMethod$1(iteratorMethod))) { - iterator = iteratorMethod.call(O); - next = iterator.next; - result = new C(); - for (;!(step = next.call(iterator)).done; index++) { - value = mapping ? callWithSafeIterationClosing$2(iterator, mapfn, [step.value, index], true) : step.value; - createProperty$6(result, index, value); - } - } else { - length = toLength$u(O.length); - result = new C(length); - for (;length > index; index++) { - value = mapping ? mapfn(O[index], index) : O[index]; - createProperty$6(result, index, value); - } - } - result.length = index; - return result; -}; - -var wellKnownSymbol$t = wellKnownSymbol$C; - -var ITERATOR$6 = wellKnownSymbol$t('iterator'); -var SAFE_CLOSING = false; - -try { - var called = 0; - var iteratorWithReturn = { - next: function () { - return { done: !!called++ }; - }, - 'return': function () { - SAFE_CLOSING = true; - } - }; - iteratorWithReturn[ITERATOR$6] = function () { - return this; - }; - // eslint-disable-next-line no-throw-literal - Array.from(iteratorWithReturn, function () { throw 2; }); -} catch (error) { /* empty */ } - -var checkCorrectnessOfIteration$4 = function (exec, SKIP_CLOSING) { - if (!SKIP_CLOSING && !SAFE_CLOSING) return false; - var ITERATION_SUPPORT = false; - try { - var object = {}; - object[ITERATOR$6] = function () { - return { - next: function () { - return { done: ITERATION_SUPPORT = true }; - } - }; - }; - exec(object); - } catch (error) { /* empty */ } - return ITERATION_SUPPORT; -}; - -var $$41 = _export; -var from$5 = arrayFrom$1; -var checkCorrectnessOfIteration$3 = checkCorrectnessOfIteration$4; - -var INCORRECT_ITERATION$1 = !checkCorrectnessOfIteration$3(function (iterable) { - Array.from(iterable); -}); - -// `Array.from` method -// https://tc39.es/ecma262/#sec-array.from -$$41({ target: 'Array', stat: true, forced: INCORRECT_ITERATION$1 }, { - from: from$5 -}); - -var $$40 = _export; -var isArray$5 = isArray$8; - -// `Array.isArray` method -// https://tc39.es/ecma262/#sec-array.isarray -$$40({ target: 'Array', stat: true }, { - isArray: isArray$5 -}); - -var $$3$ = _export; -var fails$Q = fails$Y; -var createProperty$5 = createProperty$7; - -var ISNT_GENERIC = fails$Q(function () { - function F() { /* empty */ } - return !(Array.of.call(F) instanceof F); -}); - -// `Array.of` method -// https://tc39.es/ecma262/#sec-array.of -// WebKit Array.of isn't generic -$$3$({ target: 'Array', stat: true, forced: ISNT_GENERIC }, { - of: function of(/* ...args */) { - var index = 0; - var argumentsLength = arguments.length; - var result = new (typeof this == 'function' ? this : Array)(argumentsLength); - while (argumentsLength > index) createProperty$5(result, index, arguments[index++]); - result.length = argumentsLength; - return result; - } -}); - -var getBuiltIn$p = getBuiltIn$t; - -var engineUserAgent = getBuiltIn$p('navigator', 'userAgent') || ''; - -var global$y = global$L; -var userAgent$4 = engineUserAgent; - -var process$4 = global$y.process; -var versions = process$4 && process$4.versions; -var v8 = versions && versions.v8; -var match, version; - -if (v8) { - match = v8.split('.'); - version = match[0] + match[1]; -} else if (userAgent$4) { - match = userAgent$4.match(/Edge\/(\d+)/); - if (!match || match[1] >= 74) { - match = userAgent$4.match(/Chrome\/(\d+)/); - if (match) version = match[1]; - } -} - -var engineV8Version = version && +version; - -var fails$P = fails$Y; -var wellKnownSymbol$s = wellKnownSymbol$C; -var V8_VERSION$2 = engineV8Version; - -var SPECIES$5 = wellKnownSymbol$s('species'); - -var arrayMethodHasSpeciesSupport$5 = function (METHOD_NAME) { - // We can't use this feature detection in V8 since it causes - // deoptimization and serious performance degradation - // https://github.com/zloirock/core-js/issues/677 - return V8_VERSION$2 >= 51 || !fails$P(function () { - var array = []; - var constructor = array.constructor = {}; - constructor[SPECIES$5] = function () { - return { foo: 1 }; - }; - return array[METHOD_NAME](Boolean).foo !== 1; - }); -}; - -var $$3_ = _export; -var fails$O = fails$Y; -var isArray$4 = isArray$8; -var isObject$s = isObject$B; -var toObject$p = toObject$u; -var toLength$t = toLength$y; -var createProperty$4 = createProperty$7; -var arraySpeciesCreate$4 = arraySpeciesCreate$6; -var arrayMethodHasSpeciesSupport$4 = arrayMethodHasSpeciesSupport$5; -var wellKnownSymbol$r = wellKnownSymbol$C; -var V8_VERSION$1 = engineV8Version; - -var IS_CONCAT_SPREADABLE = wellKnownSymbol$r('isConcatSpreadable'); -var MAX_SAFE_INTEGER$1 = 0x1FFFFFFFFFFFFF; -var MAXIMUM_ALLOWED_INDEX_EXCEEDED = 'Maximum allowed index exceeded'; - -// We can't use this feature detection in V8 since it causes -// deoptimization and serious performance degradation -// https://github.com/zloirock/core-js/issues/679 -var IS_CONCAT_SPREADABLE_SUPPORT = V8_VERSION$1 >= 51 || !fails$O(function () { - var array = []; - array[IS_CONCAT_SPREADABLE] = false; - return array.concat()[0] !== array; -}); - -var SPECIES_SUPPORT = arrayMethodHasSpeciesSupport$4('concat'); - -var isConcatSpreadable = function (O) { - if (!isObject$s(O)) return false; - var spreadable = O[IS_CONCAT_SPREADABLE]; - return spreadable !== undefined ? !!spreadable : isArray$4(O); -}; - -var FORCED$r = !IS_CONCAT_SPREADABLE_SUPPORT || !SPECIES_SUPPORT; - -// `Array.prototype.concat` method -// https://tc39.es/ecma262/#sec-array.prototype.concat -// with adding support of @@isConcatSpreadable and @@species -$$3_({ target: 'Array', proto: true, forced: FORCED$r }, { - concat: function concat(arg) { // eslint-disable-line no-unused-vars - var O = toObject$p(this); - var A = arraySpeciesCreate$4(O, 0); - var n = 0; - var i, k, length, len, E; - for (i = -1, length = arguments.length; i < length; i++) { - E = i === -1 ? O : arguments[i]; - if (isConcatSpreadable(E)) { - len = toLength$t(E.length); - if (n + len > MAX_SAFE_INTEGER$1) throw TypeError(MAXIMUM_ALLOWED_INDEX_EXCEEDED); - for (k = 0; k < len; k++, n++) if (k in E) createProperty$4(A, n, E[k]); - } else { - if (n >= MAX_SAFE_INTEGER$1) throw TypeError(MAXIMUM_ALLOWED_INDEX_EXCEEDED); - createProperty$4(A, n++, E); - } - } - A.length = n; - return A; - } -}); - -var toObject$o = toObject$u; -var toAbsoluteIndex$6 = toAbsoluteIndex$8; -var toLength$s = toLength$y; - -var min$7 = Math.min; - -// `Array.prototype.copyWithin` method implementation -// https://tc39.es/ecma262/#sec-array.prototype.copywithin -var arrayCopyWithin = [].copyWithin || function copyWithin(target /* = 0 */, start /* = 0, end = @length */) { - var O = toObject$o(this); - var len = toLength$s(O.length); - var to = toAbsoluteIndex$6(target, len); - var from = toAbsoluteIndex$6(start, len); - var end = arguments.length > 2 ? arguments[2] : undefined; - var count = min$7((end === undefined ? len : toAbsoluteIndex$6(end, len)) - from, len - to); - var inc = 1; - if (from < to && to < from + count) { - inc = -1; - from += count - 1; - to += count - 1; - } - while (count-- > 0) { - if (from in O) O[to] = O[from]; - else delete O[to]; - to += inc; - from += inc; - } return O; -}; - -var wellKnownSymbol$q = wellKnownSymbol$C; -var create$b = objectCreate; -var definePropertyModule$7 = objectDefineProperty; - -var UNSCOPABLES = wellKnownSymbol$q('unscopables'); -var ArrayPrototype = Array.prototype; - -// Array.prototype[@@unscopables] -// https://tc39.es/ecma262/#sec-array.prototype-@@unscopables -if (ArrayPrototype[UNSCOPABLES] == undefined) { - definePropertyModule$7.f(ArrayPrototype, UNSCOPABLES, { - configurable: true, - value: create$b(null) - }); -} - -// add a key to Array.prototype[@@unscopables] -var addToUnscopables$d = function (key) { - ArrayPrototype[UNSCOPABLES][key] = true; -}; - -var $$3Z = _export; -var copyWithin = arrayCopyWithin; -var addToUnscopables$c = addToUnscopables$d; - -// `Array.prototype.copyWithin` method -// https://tc39.es/ecma262/#sec-array.prototype.copywithin -$$3Z({ target: 'Array', proto: true }, { - copyWithin: copyWithin -}); - -// https://tc39.es/ecma262/#sec-array.prototype-@@unscopables -addToUnscopables$c('copyWithin'); - -var fails$N = fails$Y; - -var arrayMethodIsStrict$9 = function (METHOD_NAME, argument) { - var method = [][METHOD_NAME]; - return !!method && fails$N(function () { - // eslint-disable-next-line no-useless-call,no-throw-literal - method.call(null, argument || function () { throw 1; }, 1); - }); -}; - -var DESCRIPTORS$s = descriptors; -var fails$M = fails$Y; -var has$c = has$o; - -var defineProperty$c = Object.defineProperty; -var cache = {}; - -var thrower = function (it) { throw it; }; - -var arrayMethodUsesToLength$e = function (METHOD_NAME, options) { - if (has$c(cache, METHOD_NAME)) return cache[METHOD_NAME]; - if (!options) options = {}; - var method = [][METHOD_NAME]; - var ACCESSORS = has$c(options, 'ACCESSORS') ? options.ACCESSORS : false; - var argument0 = has$c(options, 0) ? options[0] : thrower; - var argument1 = has$c(options, 1) ? options[1] : undefined; - - return cache[METHOD_NAME] = !!method && !fails$M(function () { - if (ACCESSORS && !DESCRIPTORS$s) return true; - var O = { length: -1 }; - - if (ACCESSORS) defineProperty$c(O, 1, { enumerable: true, get: thrower }); - else O[1] = 1; - - method.call(O, argument0, argument1); - }); -}; - -var $$3Y = _export; -var $every$2 = arrayIteration.every; -var arrayMethodIsStrict$8 = arrayMethodIsStrict$9; -var arrayMethodUsesToLength$d = arrayMethodUsesToLength$e; - -var STRICT_METHOD$8 = arrayMethodIsStrict$8('every'); -var USES_TO_LENGTH$d = arrayMethodUsesToLength$d('every'); - -// `Array.prototype.every` method -// https://tc39.es/ecma262/#sec-array.prototype.every -$$3Y({ target: 'Array', proto: true, forced: !STRICT_METHOD$8 || !USES_TO_LENGTH$d }, { - every: function every(callbackfn /* , thisArg */) { - return $every$2(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined); - } -}); - -var toObject$n = toObject$u; -var toAbsoluteIndex$5 = toAbsoluteIndex$8; -var toLength$r = toLength$y; - -// `Array.prototype.fill` method implementation -// https://tc39.es/ecma262/#sec-array.prototype.fill -var arrayFill$1 = function fill(value /* , start = 0, end = @length */) { - var O = toObject$n(this); - var length = toLength$r(O.length); - var argumentsLength = arguments.length; - var index = toAbsoluteIndex$5(argumentsLength > 1 ? arguments[1] : undefined, length); - var end = argumentsLength > 2 ? arguments[2] : undefined; - var endPos = end === undefined ? length : toAbsoluteIndex$5(end, length); - while (endPos > index) O[index++] = value; - return O; -}; - -var $$3X = _export; -var fill = arrayFill$1; -var addToUnscopables$b = addToUnscopables$d; - -// `Array.prototype.fill` method -// https://tc39.es/ecma262/#sec-array.prototype.fill -$$3X({ target: 'Array', proto: true }, { - fill: fill -}); - -// https://tc39.es/ecma262/#sec-array.prototype-@@unscopables -addToUnscopables$b('fill'); - -var $$3W = _export; -var $filter$1 = arrayIteration.filter; -var arrayMethodHasSpeciesSupport$3 = arrayMethodHasSpeciesSupport$5; -var arrayMethodUsesToLength$c = arrayMethodUsesToLength$e; - -var HAS_SPECIES_SUPPORT$3 = arrayMethodHasSpeciesSupport$3('filter'); -// Edge 14- issue -var USES_TO_LENGTH$c = arrayMethodUsesToLength$c('filter'); - -// `Array.prototype.filter` method -// https://tc39.es/ecma262/#sec-array.prototype.filter -// with adding support of @@species -$$3W({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT$3 || !USES_TO_LENGTH$c }, { - filter: function filter(callbackfn /* , thisArg */) { - return $filter$1(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined); - } -}); - -var $$3V = _export; -var $find$2 = arrayIteration.find; -var addToUnscopables$a = addToUnscopables$d; -var arrayMethodUsesToLength$b = arrayMethodUsesToLength$e; - -var FIND = 'find'; -var SKIPS_HOLES$1 = true; - -var USES_TO_LENGTH$b = arrayMethodUsesToLength$b(FIND); - -// Shouldn't skip holes -if (FIND in []) Array(1)[FIND](function () { SKIPS_HOLES$1 = false; }); - -// `Array.prototype.find` method -// https://tc39.es/ecma262/#sec-array.prototype.find -$$3V({ target: 'Array', proto: true, forced: SKIPS_HOLES$1 || !USES_TO_LENGTH$b }, { - find: function find(callbackfn /* , that = undefined */) { - return $find$2(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined); - } -}); - -// https://tc39.es/ecma262/#sec-array.prototype-@@unscopables -addToUnscopables$a(FIND); - -var $$3U = _export; -var $findIndex$1 = arrayIteration.findIndex; -var addToUnscopables$9 = addToUnscopables$d; -var arrayMethodUsesToLength$a = arrayMethodUsesToLength$e; - -var FIND_INDEX = 'findIndex'; -var SKIPS_HOLES = true; - -var USES_TO_LENGTH$a = arrayMethodUsesToLength$a(FIND_INDEX); - -// Shouldn't skip holes -if (FIND_INDEX in []) Array(1)[FIND_INDEX](function () { SKIPS_HOLES = false; }); - -// `Array.prototype.findIndex` method -// https://tc39.es/ecma262/#sec-array.prototype.findindex -$$3U({ target: 'Array', proto: true, forced: SKIPS_HOLES || !USES_TO_LENGTH$a }, { - findIndex: function findIndex(callbackfn /* , that = undefined */) { - return $findIndex$1(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined); - } -}); - -// https://tc39.es/ecma262/#sec-array.prototype-@@unscopables -addToUnscopables$9(FIND_INDEX); - -var isArray$3 = isArray$8; -var toLength$q = toLength$y; -var bind$k = functionBindContext; - -// `FlattenIntoArray` abstract operation -// https://tc39.github.io/proposal-flatMap/#sec-FlattenIntoArray -var flattenIntoArray$2 = function (target, original, source, sourceLen, start, depth, mapper, thisArg) { - var targetIndex = start; - var sourceIndex = 0; - var mapFn = mapper ? bind$k(mapper, thisArg, 3) : false; - var element; - - while (sourceIndex < sourceLen) { - if (sourceIndex in source) { - element = mapFn ? mapFn(source[sourceIndex], sourceIndex, original) : source[sourceIndex]; - - if (depth > 0 && isArray$3(element)) { - targetIndex = flattenIntoArray$2(target, original, element, toLength$q(element.length), targetIndex, depth - 1) - 1; - } else { - if (targetIndex >= 0x1FFFFFFFFFFFFF) throw TypeError('Exceed the acceptable array length'); - target[targetIndex] = element; - } - - targetIndex++; - } - sourceIndex++; - } - return targetIndex; -}; - -var flattenIntoArray_1 = flattenIntoArray$2; - -var $$3T = _export; -var flattenIntoArray$1 = flattenIntoArray_1; -var toObject$m = toObject$u; -var toLength$p = toLength$y; -var toInteger$c = toInteger$f; -var arraySpeciesCreate$3 = arraySpeciesCreate$6; - -// `Array.prototype.flat` method -// https://tc39.es/ecma262/#sec-array.prototype.flat -$$3T({ target: 'Array', proto: true }, { - flat: function flat(/* depthArg = 1 */) { - var depthArg = arguments.length ? arguments[0] : undefined; - var O = toObject$m(this); - var sourceLen = toLength$p(O.length); - var A = arraySpeciesCreate$3(O, 0); - A.length = flattenIntoArray$1(A, O, O, sourceLen, 0, depthArg === undefined ? 1 : toInteger$c(depthArg)); - return A; - } -}); - -var $$3S = _export; -var flattenIntoArray = flattenIntoArray_1; -var toObject$l = toObject$u; -var toLength$o = toLength$y; -var aFunction$P = aFunction$R; -var arraySpeciesCreate$2 = arraySpeciesCreate$6; - -// `Array.prototype.flatMap` method -// https://tc39.es/ecma262/#sec-array.prototype.flatmap -$$3S({ target: 'Array', proto: true }, { - flatMap: function flatMap(callbackfn /* , thisArg */) { - var O = toObject$l(this); - var sourceLen = toLength$o(O.length); - var A; - aFunction$P(callbackfn); - A = arraySpeciesCreate$2(O, 0); - A.length = flattenIntoArray(A, O, O, sourceLen, 0, 1, callbackfn, arguments.length > 1 ? arguments[1] : undefined); - return A; - } -}); - -var $forEach$2 = arrayIteration.forEach; -var arrayMethodIsStrict$7 = arrayMethodIsStrict$9; -var arrayMethodUsesToLength$9 = arrayMethodUsesToLength$e; - -var STRICT_METHOD$7 = arrayMethodIsStrict$7('forEach'); -var USES_TO_LENGTH$9 = arrayMethodUsesToLength$9('forEach'); - -// `Array.prototype.forEach` method implementation -// https://tc39.es/ecma262/#sec-array.prototype.foreach -var arrayForEach = (!STRICT_METHOD$7 || !USES_TO_LENGTH$9) ? function forEach(callbackfn /* , thisArg */) { - return $forEach$2(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined); -} : [].forEach; - -var $$3R = _export; -var forEach$2 = arrayForEach; - -// `Array.prototype.forEach` method -// https://tc39.es/ecma262/#sec-array.prototype.foreach -$$3R({ target: 'Array', proto: true, forced: [].forEach != forEach$2 }, { - forEach: forEach$2 -}); - -var $$3Q = _export; -var $includes$1 = arrayIncludes.includes; -var addToUnscopables$8 = addToUnscopables$d; -var arrayMethodUsesToLength$8 = arrayMethodUsesToLength$e; - -var USES_TO_LENGTH$8 = arrayMethodUsesToLength$8('indexOf', { ACCESSORS: true, 1: 0 }); - -// `Array.prototype.includes` method -// https://tc39.es/ecma262/#sec-array.prototype.includes -$$3Q({ target: 'Array', proto: true, forced: !USES_TO_LENGTH$8 }, { - includes: function includes(el /* , fromIndex = 0 */) { - return $includes$1(this, el, arguments.length > 1 ? arguments[1] : undefined); - } -}); - -// https://tc39.es/ecma262/#sec-array.prototype-@@unscopables -addToUnscopables$8('includes'); - -var $$3P = _export; -var $indexOf$1 = arrayIncludes.indexOf; -var arrayMethodIsStrict$6 = arrayMethodIsStrict$9; -var arrayMethodUsesToLength$7 = arrayMethodUsesToLength$e; - -var nativeIndexOf = [].indexOf; - -var NEGATIVE_ZERO$1 = !!nativeIndexOf && 1 / [1].indexOf(1, -0) < 0; -var STRICT_METHOD$6 = arrayMethodIsStrict$6('indexOf'); -var USES_TO_LENGTH$7 = arrayMethodUsesToLength$7('indexOf', { ACCESSORS: true, 1: 0 }); - -// `Array.prototype.indexOf` method -// https://tc39.es/ecma262/#sec-array.prototype.indexof -$$3P({ target: 'Array', proto: true, forced: NEGATIVE_ZERO$1 || !STRICT_METHOD$6 || !USES_TO_LENGTH$7 }, { - indexOf: function indexOf(searchElement /* , fromIndex = 0 */) { - return NEGATIVE_ZERO$1 - // convert -0 to +0 - ? nativeIndexOf.apply(this, arguments) || 0 - : $indexOf$1(this, searchElement, arguments.length > 1 ? arguments[1] : undefined); - } -}); - -var $$3O = _export; -var IndexedObject$2 = indexedObject; -var toIndexedObject$7 = toIndexedObject$d; -var arrayMethodIsStrict$5 = arrayMethodIsStrict$9; - -var nativeJoin = [].join; - -var ES3_STRINGS = IndexedObject$2 != Object; -var STRICT_METHOD$5 = arrayMethodIsStrict$5('join', ','); - -// `Array.prototype.join` method -// https://tc39.es/ecma262/#sec-array.prototype.join -$$3O({ target: 'Array', proto: true, forced: ES3_STRINGS || !STRICT_METHOD$5 }, { - join: function join(separator) { - return nativeJoin.call(toIndexedObject$7(this), separator === undefined ? ',' : separator); - } -}); - -var toIndexedObject$6 = toIndexedObject$d; -var toInteger$b = toInteger$f; -var toLength$n = toLength$y; -var arrayMethodIsStrict$4 = arrayMethodIsStrict$9; -var arrayMethodUsesToLength$6 = arrayMethodUsesToLength$e; - -var min$6 = Math.min; -var nativeLastIndexOf = [].lastIndexOf; -var NEGATIVE_ZERO = !!nativeLastIndexOf && 1 / [1].lastIndexOf(1, -0) < 0; -var STRICT_METHOD$4 = arrayMethodIsStrict$4('lastIndexOf'); -// For preventing possible almost infinite loop in non-standard implementations, test the forward version of the method -var USES_TO_LENGTH$6 = arrayMethodUsesToLength$6('indexOf', { ACCESSORS: true, 1: 0 }); -var FORCED$q = NEGATIVE_ZERO || !STRICT_METHOD$4 || !USES_TO_LENGTH$6; - -// `Array.prototype.lastIndexOf` method implementation -// https://tc39.es/ecma262/#sec-array.prototype.lastindexof -var arrayLastIndexOf = FORCED$q ? function lastIndexOf(searchElement /* , fromIndex = @[*-1] */) { - // convert -0 to +0 - if (NEGATIVE_ZERO) return nativeLastIndexOf.apply(this, arguments) || 0; - var O = toIndexedObject$6(this); - var length = toLength$n(O.length); - var index = length - 1; - if (arguments.length > 1) index = min$6(index, toInteger$b(arguments[1])); - if (index < 0) index = length + index; - for (;index >= 0; index--) if (index in O && O[index] === searchElement) return index || 0; - return -1; -} : nativeLastIndexOf; - -var $$3N = _export; -var lastIndexOf = arrayLastIndexOf; - -// `Array.prototype.lastIndexOf` method -// https://tc39.es/ecma262/#sec-array.prototype.lastindexof -$$3N({ target: 'Array', proto: true, forced: lastIndexOf !== [].lastIndexOf }, { - lastIndexOf: lastIndexOf -}); - -var $$3M = _export; -var $map$1 = arrayIteration.map; -var arrayMethodHasSpeciesSupport$2 = arrayMethodHasSpeciesSupport$5; -var arrayMethodUsesToLength$5 = arrayMethodUsesToLength$e; - -var HAS_SPECIES_SUPPORT$2 = arrayMethodHasSpeciesSupport$2('map'); -// FF49- issue -var USES_TO_LENGTH$5 = arrayMethodUsesToLength$5('map'); - -// `Array.prototype.map` method -// https://tc39.es/ecma262/#sec-array.prototype.map -// with adding support of @@species -$$3M({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT$2 || !USES_TO_LENGTH$5 }, { - map: function map(callbackfn /* , thisArg */) { - return $map$1(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined); - } -}); - -var aFunction$O = aFunction$R; -var toObject$k = toObject$u; -var IndexedObject$1 = indexedObject; -var toLength$m = toLength$y; - -// `Array.prototype.{ reduce, reduceRight }` methods implementation -var createMethod$5 = function (IS_RIGHT) { - return function (that, callbackfn, argumentsLength, memo) { - aFunction$O(callbackfn); - var O = toObject$k(that); - var self = IndexedObject$1(O); - var length = toLength$m(O.length); - var index = IS_RIGHT ? length - 1 : 0; - var i = IS_RIGHT ? -1 : 1; - if (argumentsLength < 2) while (true) { - if (index in self) { - memo = self[index]; - index += i; - break; - } - index += i; - if (IS_RIGHT ? index < 0 : length <= index) { - throw TypeError('Reduce of empty array with no initial value'); - } - } - for (;IS_RIGHT ? index >= 0 : length > index; index += i) if (index in self) { - memo = callbackfn(memo, self[index], index, O); - } - return memo; - }; -}; - -var arrayReduce = { - // `Array.prototype.reduce` method - // https://tc39.es/ecma262/#sec-array.prototype.reduce - left: createMethod$5(false), - // `Array.prototype.reduceRight` method - // https://tc39.es/ecma262/#sec-array.prototype.reduceright - right: createMethod$5(true) -}; - -var classof$9 = classofRaw$1; -var global$x = global$L; - -var engineIsNode = classof$9(global$x.process) == 'process'; - -var $$3L = _export; -var $reduce$1 = arrayReduce.left; -var arrayMethodIsStrict$3 = arrayMethodIsStrict$9; -var arrayMethodUsesToLength$4 = arrayMethodUsesToLength$e; -var CHROME_VERSION$1 = engineV8Version; -var IS_NODE$5 = engineIsNode; - -var STRICT_METHOD$3 = arrayMethodIsStrict$3('reduce'); -var USES_TO_LENGTH$4 = arrayMethodUsesToLength$4('reduce', { 1: 0 }); -// Chrome 80-82 has a critical bug -// https://bugs.chromium.org/p/chromium/issues/detail?id=1049982 -var CHROME_BUG$1 = !IS_NODE$5 && CHROME_VERSION$1 > 79 && CHROME_VERSION$1 < 83; - -// `Array.prototype.reduce` method -// https://tc39.es/ecma262/#sec-array.prototype.reduce -$$3L({ target: 'Array', proto: true, forced: !STRICT_METHOD$3 || !USES_TO_LENGTH$4 || CHROME_BUG$1 }, { - reduce: function reduce(callbackfn /* , initialValue */) { - return $reduce$1(this, callbackfn, arguments.length, arguments.length > 1 ? arguments[1] : undefined); - } -}); - -var $$3K = _export; -var $reduceRight$1 = arrayReduce.right; -var arrayMethodIsStrict$2 = arrayMethodIsStrict$9; -var arrayMethodUsesToLength$3 = arrayMethodUsesToLength$e; -var CHROME_VERSION = engineV8Version; -var IS_NODE$4 = engineIsNode; - -var STRICT_METHOD$2 = arrayMethodIsStrict$2('reduceRight'); -// For preventing possible almost infinite loop in non-standard implementations, test the forward version of the method -var USES_TO_LENGTH$3 = arrayMethodUsesToLength$3('reduce', { 1: 0 }); -// Chrome 80-82 has a critical bug -// https://bugs.chromium.org/p/chromium/issues/detail?id=1049982 -var CHROME_BUG = !IS_NODE$4 && CHROME_VERSION > 79 && CHROME_VERSION < 83; - -// `Array.prototype.reduceRight` method -// https://tc39.es/ecma262/#sec-array.prototype.reduceright -$$3K({ target: 'Array', proto: true, forced: !STRICT_METHOD$2 || !USES_TO_LENGTH$3 || CHROME_BUG }, { - reduceRight: function reduceRight(callbackfn /* , initialValue */) { - return $reduceRight$1(this, callbackfn, arguments.length, arguments.length > 1 ? arguments[1] : undefined); - } -}); - -var $$3J = _export; -var isArray$2 = isArray$8; - -var nativeReverse = [].reverse; -var test$1 = [1, 2]; - -// `Array.prototype.reverse` method -// https://tc39.es/ecma262/#sec-array.prototype.reverse -// fix for Safari 12.0 bug -// https://bugs.webkit.org/show_bug.cgi?id=188794 -$$3J({ target: 'Array', proto: true, forced: String(test$1) === String(test$1.reverse()) }, { - reverse: function reverse() { - // eslint-disable-next-line no-self-assign - if (isArray$2(this)) this.length = this.length; - return nativeReverse.call(this); - } -}); - -var $$3I = _export; -var isObject$r = isObject$B; -var isArray$1 = isArray$8; -var toAbsoluteIndex$4 = toAbsoluteIndex$8; -var toLength$l = toLength$y; -var toIndexedObject$5 = toIndexedObject$d; -var createProperty$3 = createProperty$7; -var wellKnownSymbol$p = wellKnownSymbol$C; -var arrayMethodHasSpeciesSupport$1 = arrayMethodHasSpeciesSupport$5; -var arrayMethodUsesToLength$2 = arrayMethodUsesToLength$e; - -var HAS_SPECIES_SUPPORT$1 = arrayMethodHasSpeciesSupport$1('slice'); -var USES_TO_LENGTH$2 = arrayMethodUsesToLength$2('slice', { ACCESSORS: true, 0: 0, 1: 2 }); - -var SPECIES$4 = wellKnownSymbol$p('species'); -var nativeSlice = [].slice; -var max$4 = Math.max; - -// `Array.prototype.slice` method -// https://tc39.es/ecma262/#sec-array.prototype.slice -// fallback for not array-like ES3 strings and DOM objects -$$3I({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT$1 || !USES_TO_LENGTH$2 }, { - slice: function slice(start, end) { - var O = toIndexedObject$5(this); - var length = toLength$l(O.length); - var k = toAbsoluteIndex$4(start, length); - var fin = toAbsoluteIndex$4(end === undefined ? length : end, length); - // inline `ArraySpeciesCreate` for usage native `Array#slice` where it's possible - var Constructor, result, n; - if (isArray$1(O)) { - Constructor = O.constructor; - // cross-realm fallback - if (typeof Constructor == 'function' && (Constructor === Array || isArray$1(Constructor.prototype))) { - Constructor = undefined; - } else if (isObject$r(Constructor)) { - Constructor = Constructor[SPECIES$4]; - if (Constructor === null) Constructor = undefined; - } - if (Constructor === Array || Constructor === undefined) { - return nativeSlice.call(O, k, fin); - } - } - result = new (Constructor === undefined ? Array : Constructor)(max$4(fin - k, 0)); - for (n = 0; k < fin; k++, n++) if (k in O) createProperty$3(result, n, O[k]); - result.length = n; - return result; - } -}); - -var $$3H = _export; -var $some$2 = arrayIteration.some; -var arrayMethodIsStrict$1 = arrayMethodIsStrict$9; -var arrayMethodUsesToLength$1 = arrayMethodUsesToLength$e; - -var STRICT_METHOD$1 = arrayMethodIsStrict$1('some'); -var USES_TO_LENGTH$1 = arrayMethodUsesToLength$1('some'); - -// `Array.prototype.some` method -// https://tc39.es/ecma262/#sec-array.prototype.some -$$3H({ target: 'Array', proto: true, forced: !STRICT_METHOD$1 || !USES_TO_LENGTH$1 }, { - some: function some(callbackfn /* , thisArg */) { - return $some$2(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined); - } -}); - -var $$3G = _export; -var aFunction$N = aFunction$R; -var toObject$j = toObject$u; -var fails$L = fails$Y; -var arrayMethodIsStrict = arrayMethodIsStrict$9; - -var test = []; -var nativeSort = test.sort; - -// IE8- -var FAILS_ON_UNDEFINED = fails$L(function () { - test.sort(undefined); -}); -// V8 bug -var FAILS_ON_NULL = fails$L(function () { - test.sort(null); -}); -// Old WebKit -var STRICT_METHOD = arrayMethodIsStrict('sort'); - -var FORCED$p = FAILS_ON_UNDEFINED || !FAILS_ON_NULL || !STRICT_METHOD; - -// `Array.prototype.sort` method -// https://tc39.es/ecma262/#sec-array.prototype.sort -$$3G({ target: 'Array', proto: true, forced: FORCED$p }, { - sort: function sort(comparefn) { - return comparefn === undefined - ? nativeSort.call(toObject$j(this)) - : nativeSort.call(toObject$j(this), aFunction$N(comparefn)); - } -}); - -var $$3F = _export; -var toAbsoluteIndex$3 = toAbsoluteIndex$8; -var toInteger$a = toInteger$f; -var toLength$k = toLength$y; -var toObject$i = toObject$u; -var arraySpeciesCreate$1 = arraySpeciesCreate$6; -var createProperty$2 = createProperty$7; -var arrayMethodHasSpeciesSupport = arrayMethodHasSpeciesSupport$5; -var arrayMethodUsesToLength = arrayMethodUsesToLength$e; - -var HAS_SPECIES_SUPPORT = arrayMethodHasSpeciesSupport('splice'); -var USES_TO_LENGTH = arrayMethodUsesToLength('splice', { ACCESSORS: true, 0: 0, 1: 2 }); - -var max$3 = Math.max; -var min$5 = Math.min; -var MAX_SAFE_INTEGER = 0x1FFFFFFFFFFFFF; -var MAXIMUM_ALLOWED_LENGTH_EXCEEDED = 'Maximum allowed length exceeded'; - -// `Array.prototype.splice` method -// https://tc39.es/ecma262/#sec-array.prototype.splice -// with adding support of @@species -$$3F({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT || !USES_TO_LENGTH }, { - splice: function splice(start, deleteCount /* , ...items */) { - var O = toObject$i(this); - var len = toLength$k(O.length); - var actualStart = toAbsoluteIndex$3(start, len); - var argumentsLength = arguments.length; - var insertCount, actualDeleteCount, A, k, from, to; - if (argumentsLength === 0) { - insertCount = actualDeleteCount = 0; - } else if (argumentsLength === 1) { - insertCount = 0; - actualDeleteCount = len - actualStart; - } else { - insertCount = argumentsLength - 2; - actualDeleteCount = min$5(max$3(toInteger$a(deleteCount), 0), len - actualStart); - } - if (len + insertCount - actualDeleteCount > MAX_SAFE_INTEGER) { - throw TypeError(MAXIMUM_ALLOWED_LENGTH_EXCEEDED); - } - A = arraySpeciesCreate$1(O, actualDeleteCount); - for (k = 0; k < actualDeleteCount; k++) { - from = actualStart + k; - if (from in O) createProperty$2(A, k, O[from]); - } - A.length = actualDeleteCount; - if (insertCount < actualDeleteCount) { - for (k = actualStart; k < len - actualDeleteCount; k++) { - from = k + actualDeleteCount; - to = k + insertCount; - if (from in O) O[to] = O[from]; - else delete O[to]; - } - for (k = len; k > len - actualDeleteCount + insertCount; k--) delete O[k - 1]; - } else if (insertCount > actualDeleteCount) { - for (k = len - actualDeleteCount; k > actualStart; k--) { - from = k + actualDeleteCount - 1; - to = k + insertCount - 1; - if (from in O) O[to] = O[from]; - else delete O[to]; - } - } - for (k = 0; k < insertCount; k++) { - O[k + actualStart] = arguments[k + 2]; - } - O.length = len - actualDeleteCount + insertCount; - return A; - } -}); - -var getBuiltIn$o = getBuiltIn$t; -var definePropertyModule$6 = objectDefineProperty; -var wellKnownSymbol$o = wellKnownSymbol$C; -var DESCRIPTORS$r = descriptors; - -var SPECIES$3 = wellKnownSymbol$o('species'); - -var setSpecies$7 = function (CONSTRUCTOR_NAME) { - var Constructor = getBuiltIn$o(CONSTRUCTOR_NAME); - var defineProperty = definePropertyModule$6.f; - - if (DESCRIPTORS$r && Constructor && !Constructor[SPECIES$3]) { - defineProperty(Constructor, SPECIES$3, { - configurable: true, - get: function () { return this; } - }); - } -}; - -var setSpecies$6 = setSpecies$7; - -// `Array[@@species]` getter -// https://tc39.es/ecma262/#sec-get-array-@@species -setSpecies$6('Array'); - -// this method was added to unscopables after implementation -// in popular engines, so it's moved to a separate module -var addToUnscopables$7 = addToUnscopables$d; - -// https://tc39.es/ecma262/#sec-array.prototype-@@unscopables -addToUnscopables$7('flat'); - -// this method was added to unscopables after implementation -// in popular engines, so it's moved to a separate module -var addToUnscopables$6 = addToUnscopables$d; - -// https://tc39.es/ecma262/#sec-array.prototype-@@unscopables -addToUnscopables$6('flatMap'); - -var fails$K = fails$Y; -var getPrototypeOf$c = objectGetPrototypeOf$1; -var createNonEnumerableProperty$f = createNonEnumerableProperty$m; -var has$b = has$o; -var wellKnownSymbol$n = wellKnownSymbol$C; - -var ITERATOR$5 = wellKnownSymbol$n('iterator'); -var BUGGY_SAFARI_ITERATORS$1 = false; - -var returnThis$2 = function () { return this; }; - -// `%IteratorPrototype%` object -// https://tc39.es/ecma262/#sec-%iteratorprototype%-object -var IteratorPrototype$3, PrototypeOfArrayIteratorPrototype, arrayIterator; - -if ([].keys) { - arrayIterator = [].keys(); - // Safari 8 has buggy iterators w/o `next` - if (!('next' in arrayIterator)) BUGGY_SAFARI_ITERATORS$1 = true; - else { - PrototypeOfArrayIteratorPrototype = getPrototypeOf$c(getPrototypeOf$c(arrayIterator)); - if (PrototypeOfArrayIteratorPrototype !== Object.prototype) IteratorPrototype$3 = PrototypeOfArrayIteratorPrototype; - } -} - -var NEW_ITERATOR_PROTOTYPE = IteratorPrototype$3 == undefined || fails$K(function () { - var test = {}; - // FF44- legacy iterators case - return IteratorPrototype$3[ITERATOR$5].call(test) !== test; -}); - -if (NEW_ITERATOR_PROTOTYPE) IteratorPrototype$3 = {}; - -// 25.1.2.1.1 %IteratorPrototype%[@@iterator]() -if (!has$b(IteratorPrototype$3, ITERATOR$5)) { - createNonEnumerableProperty$f(IteratorPrototype$3, ITERATOR$5, returnThis$2); -} - -var iteratorsCore = { - IteratorPrototype: IteratorPrototype$3, - BUGGY_SAFARI_ITERATORS: BUGGY_SAFARI_ITERATORS$1 -}; - -var IteratorPrototype$2 = iteratorsCore.IteratorPrototype; -var create$a = objectCreate; -var createPropertyDescriptor$3 = createPropertyDescriptor$9; -var setToStringTag$9 = setToStringTag$b; -var Iterators$2 = iterators; - -var returnThis$1 = function () { return this; }; - -var createIteratorConstructor$7 = function (IteratorConstructor, NAME, next) { - var TO_STRING_TAG = NAME + ' Iterator'; - IteratorConstructor.prototype = create$a(IteratorPrototype$2, { next: createPropertyDescriptor$3(1, next) }); - setToStringTag$9(IteratorConstructor, TO_STRING_TAG, false); - Iterators$2[TO_STRING_TAG] = returnThis$1; - return IteratorConstructor; -}; - -var $$3E = _export; -var createIteratorConstructor$6 = createIteratorConstructor$7; -var getPrototypeOf$b = objectGetPrototypeOf$1; -var setPrototypeOf$5 = objectSetPrototypeOf$1; -var setToStringTag$8 = setToStringTag$b; -var createNonEnumerableProperty$e = createNonEnumerableProperty$m; -var redefine$d = redefine$g.exports; -var wellKnownSymbol$m = wellKnownSymbol$C; -var Iterators$1 = iterators; -var IteratorsCore = iteratorsCore; - -var IteratorPrototype$1 = IteratorsCore.IteratorPrototype; -var BUGGY_SAFARI_ITERATORS = IteratorsCore.BUGGY_SAFARI_ITERATORS; -var ITERATOR$4 = wellKnownSymbol$m('iterator'); -var KEYS = 'keys'; -var VALUES = 'values'; -var ENTRIES = 'entries'; - -var returnThis = function () { return this; }; - -var defineIterator$3 = function (Iterable, NAME, IteratorConstructor, next, DEFAULT, IS_SET, FORCED) { - createIteratorConstructor$6(IteratorConstructor, NAME, next); - - var getIterationMethod = function (KIND) { - if (KIND === DEFAULT && defaultIterator) return defaultIterator; - if (!BUGGY_SAFARI_ITERATORS && KIND in IterablePrototype) return IterablePrototype[KIND]; - switch (KIND) { - case KEYS: return function keys() { return new IteratorConstructor(this, KIND); }; - case VALUES: return function values() { return new IteratorConstructor(this, KIND); }; - case ENTRIES: return function entries() { return new IteratorConstructor(this, KIND); }; - } return function () { return new IteratorConstructor(this); }; - }; - - var TO_STRING_TAG = NAME + ' Iterator'; - var INCORRECT_VALUES_NAME = false; - var IterablePrototype = Iterable.prototype; - var nativeIterator = IterablePrototype[ITERATOR$4] - || IterablePrototype['@@iterator'] - || DEFAULT && IterablePrototype[DEFAULT]; - var defaultIterator = !BUGGY_SAFARI_ITERATORS && nativeIterator || getIterationMethod(DEFAULT); - var anyNativeIterator = NAME == 'Array' ? IterablePrototype.entries || nativeIterator : nativeIterator; - var CurrentIteratorPrototype, methods, KEY; - - // fix native - if (anyNativeIterator) { - CurrentIteratorPrototype = getPrototypeOf$b(anyNativeIterator.call(new Iterable())); - if (IteratorPrototype$1 !== Object.prototype && CurrentIteratorPrototype.next) { - if (getPrototypeOf$b(CurrentIteratorPrototype) !== IteratorPrototype$1) { - if (setPrototypeOf$5) { - setPrototypeOf$5(CurrentIteratorPrototype, IteratorPrototype$1); - } else if (typeof CurrentIteratorPrototype[ITERATOR$4] != 'function') { - createNonEnumerableProperty$e(CurrentIteratorPrototype, ITERATOR$4, returnThis); - } - } - // Set @@toStringTag to native iterators - setToStringTag$8(CurrentIteratorPrototype, TO_STRING_TAG, true); - } - } - - // fix Array#{values, @@iterator}.name in V8 / FF - if (DEFAULT == VALUES && nativeIterator && nativeIterator.name !== VALUES) { - INCORRECT_VALUES_NAME = true; - defaultIterator = function values() { return nativeIterator.call(this); }; - } - - // define iterator - if (IterablePrototype[ITERATOR$4] !== defaultIterator) { - createNonEnumerableProperty$e(IterablePrototype, ITERATOR$4, defaultIterator); - } - Iterators$1[NAME] = defaultIterator; - - // export additional methods - if (DEFAULT) { - methods = { - values: getIterationMethod(VALUES), - keys: IS_SET ? defaultIterator : getIterationMethod(KEYS), - entries: getIterationMethod(ENTRIES) - }; - if (FORCED) for (KEY in methods) { - if (BUGGY_SAFARI_ITERATORS || INCORRECT_VALUES_NAME || !(KEY in IterablePrototype)) { - redefine$d(IterablePrototype, KEY, methods[KEY]); - } - } else $$3E({ target: NAME, proto: true, forced: BUGGY_SAFARI_ITERATORS || INCORRECT_VALUES_NAME }, methods); - } - - return methods; -}; - -var toIndexedObject$4 = toIndexedObject$d; -var addToUnscopables$5 = addToUnscopables$d; -var Iterators = iterators; -var InternalStateModule$g = internalState; -var defineIterator$2 = defineIterator$3; - -var ARRAY_ITERATOR = 'Array Iterator'; -var setInternalState$h = InternalStateModule$g.set; -var getInternalState$d = InternalStateModule$g.getterFor(ARRAY_ITERATOR); - -// `Array.prototype.entries` method -// https://tc39.es/ecma262/#sec-array.prototype.entries -// `Array.prototype.keys` method -// https://tc39.es/ecma262/#sec-array.prototype.keys -// `Array.prototype.values` method -// https://tc39.es/ecma262/#sec-array.prototype.values -// `Array.prototype[@@iterator]` method -// https://tc39.es/ecma262/#sec-array.prototype-@@iterator -// `CreateArrayIterator` internal method -// https://tc39.es/ecma262/#sec-createarrayiterator -var es_array_iterator = defineIterator$2(Array, 'Array', function (iterated, kind) { - setInternalState$h(this, { - type: ARRAY_ITERATOR, - target: toIndexedObject$4(iterated), // target - index: 0, // next index - kind: kind // kind - }); -// `%ArrayIteratorPrototype%.next` method -// https://tc39.es/ecma262/#sec-%arrayiteratorprototype%.next -}, function () { - var state = getInternalState$d(this); - var target = state.target; - var kind = state.kind; - var index = state.index++; - if (!target || index >= target.length) { - state.target = undefined; - return { value: undefined, done: true }; - } - if (kind == 'keys') return { value: index, done: false }; - if (kind == 'values') return { value: target[index], done: false }; - return { value: [index, target[index]], done: false }; -}, 'values'); - -// argumentsList[@@iterator] is %ArrayProto_values% -// https://tc39.es/ecma262/#sec-createunmappedargumentsobject -// https://tc39.es/ecma262/#sec-createmappedargumentsobject -Iterators.Arguments = Iterators.Array; - -// https://tc39.es/ecma262/#sec-array.prototype-@@unscopables -addToUnscopables$5('keys'); -addToUnscopables$5('values'); -addToUnscopables$5('entries'); - -var aFunction$M = aFunction$R; -var isObject$q = isObject$B; - -var slice$1 = [].slice; -var factories = {}; - -var construct = function (C, argsLength, args) { - if (!(argsLength in factories)) { - for (var list = [], i = 0; i < argsLength; i++) list[i] = 'a[' + i + ']'; - // eslint-disable-next-line no-new-func - factories[argsLength] = Function('C,a', 'return new C(' + list.join(',') + ')'); - } return factories[argsLength](C, args); -}; - -// `Function.prototype.bind` method implementation -// https://tc39.es/ecma262/#sec-function.prototype.bind -var functionBind = Function.bind || function bind(that /* , ...args */) { - var fn = aFunction$M(this); - var partArgs = slice$1.call(arguments, 1); - var boundFunction = function bound(/* args... */) { - var args = partArgs.concat(slice$1.call(arguments)); - return this instanceof boundFunction ? construct(fn, args.length, args) : fn.apply(that, args); - }; - if (isObject$q(fn.prototype)) boundFunction.prototype = fn.prototype; - return boundFunction; -}; - -var $$3D = _export; -var bind$j = functionBind; - -// `Function.prototype.bind` method -// https://tc39.es/ecma262/#sec-function.prototype.bind -$$3D({ target: 'Function', proto: true }, { - bind: bind$j -}); - -var DESCRIPTORS$q = descriptors; -var defineProperty$b = objectDefineProperty.f; - -var FunctionPrototype$1 = Function.prototype; -var FunctionPrototypeToString = FunctionPrototype$1.toString; -var nameRE = /^\s*function ([^ (]*)/; -var NAME$1 = 'name'; - -// Function instances `.name` property -// https://tc39.es/ecma262/#sec-function-instances-name -if (DESCRIPTORS$q && !(NAME$1 in FunctionPrototype$1)) { - defineProperty$b(FunctionPrototype$1, NAME$1, { - configurable: true, - get: function () { - try { - return FunctionPrototypeToString.call(this).match(nameRE)[1]; - } catch (error) { - return ''; - } - } - }); -} - -var isObject$p = isObject$B; -var definePropertyModule$5 = objectDefineProperty; -var getPrototypeOf$a = objectGetPrototypeOf$1; -var wellKnownSymbol$l = wellKnownSymbol$C; - -var HAS_INSTANCE = wellKnownSymbol$l('hasInstance'); -var FunctionPrototype = Function.prototype; - -// `Function.prototype[@@hasInstance]` method -// https://tc39.es/ecma262/#sec-function.prototype-@@hasinstance -if (!(HAS_INSTANCE in FunctionPrototype)) { - definePropertyModule$5.f(FunctionPrototype, HAS_INSTANCE, { value: function (O) { - if (typeof this != 'function' || !isObject$p(O)) return false; - if (!isObject$p(this.prototype)) return O instanceof this; - // for environment w/o native `@@hasInstance` logic enough `instanceof`, but add this: - while (O = getPrototypeOf$a(O)) if (this.prototype === O) return true; - return false; - } }); -} - -var $$3C = _export; -var global$w = global$L; - -// `globalThis` object -// https://tc39.es/ecma262/#sec-globalthis -$$3C({ global: true }, { - globalThis: global$w -}); - -var DESCRIPTORS$p = descriptors; -var fails$J = fails$Y; -var objectKeys$2 = objectKeys$5; -var getOwnPropertySymbolsModule = objectGetOwnPropertySymbols; -var propertyIsEnumerableModule = objectPropertyIsEnumerable; -var toObject$h = toObject$u; -var IndexedObject = indexedObject; - -var nativeAssign = Object.assign; -var defineProperty$a = Object.defineProperty; - -// `Object.assign` method -// https://tc39.es/ecma262/#sec-object.assign -var objectAssign = !nativeAssign || fails$J(function () { - // should have correct order of operations (Edge bug) - if (DESCRIPTORS$p && nativeAssign({ b: 1 }, nativeAssign(defineProperty$a({}, 'a', { - enumerable: true, - get: function () { - defineProperty$a(this, 'b', { - value: 3, - enumerable: false - }); - } - }), { b: 2 })).b !== 1) return true; - // should work with symbols and should have deterministic property order (V8 bug) - var A = {}; - var B = {}; - // eslint-disable-next-line no-undef - var symbol = Symbol(); - var alphabet = 'abcdefghijklmnopqrst'; - A[symbol] = 7; - alphabet.split('').forEach(function (chr) { B[chr] = chr; }); - return nativeAssign({}, A)[symbol] != 7 || objectKeys$2(nativeAssign({}, B)).join('') != alphabet; -}) ? function assign(target, source) { // eslint-disable-line no-unused-vars - var T = toObject$h(target); - var argumentsLength = arguments.length; - var index = 1; - var getOwnPropertySymbols = getOwnPropertySymbolsModule.f; - var propertyIsEnumerable = propertyIsEnumerableModule.f; - while (argumentsLength > index) { - var S = IndexedObject(arguments[index++]); - var keys = getOwnPropertySymbols ? objectKeys$2(S).concat(getOwnPropertySymbols(S)) : objectKeys$2(S); - var length = keys.length; - var j = 0; - var key; - while (length > j) { - key = keys[j++]; - if (!DESCRIPTORS$p || propertyIsEnumerable.call(S, key)) T[key] = S[key]; - } - } return T; -} : nativeAssign; - -var $$3B = _export; -var assign$1 = objectAssign; - -// `Object.assign` method -// https://tc39.es/ecma262/#sec-object.assign -$$3B({ target: 'Object', stat: true, forced: Object.assign !== assign$1 }, { - assign: assign$1 -}); - -var $$3A = _export; -var DESCRIPTORS$o = descriptors; -var create$9 = objectCreate; - -// `Object.create` method -// https://tc39.es/ecma262/#sec-object.create -$$3A({ target: 'Object', stat: true, sham: !DESCRIPTORS$o }, { - create: create$9 -}); - -var $$3z = _export; -var DESCRIPTORS$n = descriptors; -var objectDefinePropertyModile = objectDefineProperty; - -// `Object.defineProperty` method -// https://tc39.es/ecma262/#sec-object.defineproperty -$$3z({ target: 'Object', stat: true, forced: !DESCRIPTORS$n, sham: !DESCRIPTORS$n }, { - defineProperty: objectDefinePropertyModile.f -}); - -var $$3y = _export; -var DESCRIPTORS$m = descriptors; -var defineProperties$2 = objectDefineProperties; - -// `Object.defineProperties` method -// https://tc39.es/ecma262/#sec-object.defineproperties -$$3y({ target: 'Object', stat: true, forced: !DESCRIPTORS$m, sham: !DESCRIPTORS$m }, { - defineProperties: defineProperties$2 -}); - -var DESCRIPTORS$l = descriptors; -var objectKeys$1 = objectKeys$5; -var toIndexedObject$3 = toIndexedObject$d; -var propertyIsEnumerable = objectPropertyIsEnumerable.f; - -// `Object.{ entries, values }` methods implementation -var createMethod$4 = function (TO_ENTRIES) { - return function (it) { - var O = toIndexedObject$3(it); - var keys = objectKeys$1(O); - var length = keys.length; - var i = 0; - var result = []; - var key; - while (length > i) { - key = keys[i++]; - if (!DESCRIPTORS$l || propertyIsEnumerable.call(O, key)) { - result.push(TO_ENTRIES ? [key, O[key]] : O[key]); - } - } - return result; - }; -}; - -var objectToArray = { - // `Object.entries` method - // https://tc39.es/ecma262/#sec-object.entries - entries: createMethod$4(true), - // `Object.values` method - // https://tc39.es/ecma262/#sec-object.values - values: createMethod$4(false) -}; - -var $$3x = _export; -var $entries = objectToArray.entries; - -// `Object.entries` method -// https://tc39.es/ecma262/#sec-object.entries -$$3x({ target: 'Object', stat: true }, { - entries: function entries(O) { - return $entries(O); - } -}); - -var fails$I = fails$Y; - -var freezing = !fails$I(function () { - return Object.isExtensible(Object.preventExtensions({})); -}); +var path; +var hasRequiredPath; -var internalMetadata = {exports: {}}; +function requirePath () { + if (hasRequiredPath) return path; + hasRequiredPath = 1; + var globalThis = requireGlobalThis(); -var hiddenKeys = hiddenKeys$6; -var isObject$o = isObject$B; -var has$a = has$o; -var defineProperty$9 = objectDefineProperty.f; -var uid$1 = uid$5; -var FREEZING$4 = freezing; - -var METADATA = uid$1('meta'); -var id$1 = 0; - -var isExtensible$1 = Object.isExtensible || function () { - return true; -}; - -var setMetadata = function (it) { - defineProperty$9(it, METADATA, { value: { - objectID: 'O' + ++id$1, // object ID - weakData: {} // weak collections IDs - } }); -}; - -var fastKey$1 = function (it, create) { - // return a primitive with prefix - if (!isObject$o(it)) return typeof it == 'symbol' ? it : (typeof it == 'string' ? 'S' : 'P') + it; - if (!has$a(it, METADATA)) { - // can't set metadata to uncaught frozen object - if (!isExtensible$1(it)) return 'F'; - // not necessary to add metadata - if (!create) return 'E'; - // add missing metadata - setMetadata(it); - // return object ID - } return it[METADATA].objectID; -}; - -var getWeakData$1 = function (it, create) { - if (!has$a(it, METADATA)) { - // can't set metadata to uncaught frozen object - if (!isExtensible$1(it)) return true; - // not necessary to add metadata - if (!create) return false; - // add missing metadata - setMetadata(it); - // return the store of weak collections IDs - } return it[METADATA].weakData; -}; - -// add metadata on freeze-family methods calling -var onFreeze$3 = function (it) { - if (FREEZING$4 && meta.REQUIRED && isExtensible$1(it) && !has$a(it, METADATA)) setMetadata(it); - return it; -}; - -var meta = internalMetadata.exports = { - REQUIRED: false, - fastKey: fastKey$1, - getWeakData: getWeakData$1, - onFreeze: onFreeze$3 -}; - -hiddenKeys[METADATA] = true; - -var $$3w = _export; -var FREEZING$3 = freezing; -var fails$H = fails$Y; -var isObject$n = isObject$B; -var onFreeze$2 = internalMetadata.exports.onFreeze; - -var nativeFreeze = Object.freeze; -var FAILS_ON_PRIMITIVES$9 = fails$H(function () { nativeFreeze(1); }); - -// `Object.freeze` method -// https://tc39.es/ecma262/#sec-object.freeze -$$3w({ target: 'Object', stat: true, forced: FAILS_ON_PRIMITIVES$9, sham: !FREEZING$3 }, { - freeze: function freeze(it) { - return nativeFreeze && isObject$n(it) ? nativeFreeze(onFreeze$2(it)) : it; - } -}); - -var $$3v = _export; -var iterate$G = iterate$I; -var createProperty$1 = createProperty$7; - -// `Object.fromEntries` method -// https://github.com/tc39/proposal-object-from-entries -$$3v({ target: 'Object', stat: true }, { - fromEntries: function fromEntries(iterable) { - var obj = {}; - iterate$G(iterable, function (k, v) { - createProperty$1(obj, k, v); - }, { AS_ENTRIES: true }); - return obj; - } -}); - -var $$3u = _export; -var fails$G = fails$Y; -var toIndexedObject$2 = toIndexedObject$d; -var nativeGetOwnPropertyDescriptor$1 = objectGetOwnPropertyDescriptor.f; -var DESCRIPTORS$k = descriptors; - -var FAILS_ON_PRIMITIVES$8 = fails$G(function () { nativeGetOwnPropertyDescriptor$1(1); }); -var FORCED$o = !DESCRIPTORS$k || FAILS_ON_PRIMITIVES$8; - -// `Object.getOwnPropertyDescriptor` method -// https://tc39.es/ecma262/#sec-object.getownpropertydescriptor -$$3u({ target: 'Object', stat: true, forced: FORCED$o, sham: !DESCRIPTORS$k }, { - getOwnPropertyDescriptor: function getOwnPropertyDescriptor(it, key) { - return nativeGetOwnPropertyDescriptor$1(toIndexedObject$2(it), key); - } -}); - -var $$3t = _export; -var DESCRIPTORS$j = descriptors; -var ownKeys$1 = ownKeys$3; -var toIndexedObject$1 = toIndexedObject$d; -var getOwnPropertyDescriptorModule$4 = objectGetOwnPropertyDescriptor; -var createProperty = createProperty$7; - -// `Object.getOwnPropertyDescriptors` method -// https://tc39.es/ecma262/#sec-object.getownpropertydescriptors -$$3t({ target: 'Object', stat: true, sham: !DESCRIPTORS$j }, { - getOwnPropertyDescriptors: function getOwnPropertyDescriptors(object) { - var O = toIndexedObject$1(object); - var getOwnPropertyDescriptor = getOwnPropertyDescriptorModule$4.f; - var keys = ownKeys$1(O); - var result = {}; - var index = 0; - var key, descriptor; - while (keys.length > index) { - descriptor = getOwnPropertyDescriptor(O, key = keys[index++]); - if (descriptor !== undefined) createProperty(result, key, descriptor); - } - return result; - } -}); - -var $$3s = _export; -var fails$F = fails$Y; -var nativeGetOwnPropertyNames = objectGetOwnPropertyNamesExternal.f; - -var FAILS_ON_PRIMITIVES$7 = fails$F(function () { return !Object.getOwnPropertyNames(1); }); - -// `Object.getOwnPropertyNames` method -// https://tc39.es/ecma262/#sec-object.getownpropertynames -$$3s({ target: 'Object', stat: true, forced: FAILS_ON_PRIMITIVES$7 }, { - getOwnPropertyNames: nativeGetOwnPropertyNames -}); - -var $$3r = _export; -var fails$E = fails$Y; -var toObject$g = toObject$u; -var nativeGetPrototypeOf = objectGetPrototypeOf$1; -var CORRECT_PROTOTYPE_GETTER$1 = correctPrototypeGetter; - -var FAILS_ON_PRIMITIVES$6 = fails$E(function () { nativeGetPrototypeOf(1); }); - -// `Object.getPrototypeOf` method -// https://tc39.es/ecma262/#sec-object.getprototypeof -$$3r({ target: 'Object', stat: true, forced: FAILS_ON_PRIMITIVES$6, sham: !CORRECT_PROTOTYPE_GETTER$1 }, { - getPrototypeOf: function getPrototypeOf(it) { - return nativeGetPrototypeOf(toObject$g(it)); - } -}); - -// `SameValue` abstract operation -// https://tc39.es/ecma262/#sec-samevalue -var sameValue$1 = Object.is || function is(x, y) { - // eslint-disable-next-line no-self-compare - return x === y ? x !== 0 || 1 / x === 1 / y : x != x && y != y; -}; - -var $$3q = _export; -var is = sameValue$1; - -// `Object.is` method -// https://tc39.es/ecma262/#sec-object.is -$$3q({ target: 'Object', stat: true }, { - is: is -}); - -var $$3p = _export; -var fails$D = fails$Y; -var isObject$m = isObject$B; - -var nativeIsExtensible = Object.isExtensible; -var FAILS_ON_PRIMITIVES$5 = fails$D(function () { nativeIsExtensible(1); }); - -// `Object.isExtensible` method -// https://tc39.es/ecma262/#sec-object.isextensible -$$3p({ target: 'Object', stat: true, forced: FAILS_ON_PRIMITIVES$5 }, { - isExtensible: function isExtensible(it) { - return isObject$m(it) ? nativeIsExtensible ? nativeIsExtensible(it) : true : false; - } -}); - -var $$3o = _export; -var fails$C = fails$Y; -var isObject$l = isObject$B; - -var nativeIsFrozen = Object.isFrozen; -var FAILS_ON_PRIMITIVES$4 = fails$C(function () { nativeIsFrozen(1); }); - -// `Object.isFrozen` method -// https://tc39.es/ecma262/#sec-object.isfrozen -$$3o({ target: 'Object', stat: true, forced: FAILS_ON_PRIMITIVES$4 }, { - isFrozen: function isFrozen(it) { - return isObject$l(it) ? nativeIsFrozen ? nativeIsFrozen(it) : false : true; - } -}); - -var $$3n = _export; -var fails$B = fails$Y; -var isObject$k = isObject$B; - -var nativeIsSealed = Object.isSealed; -var FAILS_ON_PRIMITIVES$3 = fails$B(function () { nativeIsSealed(1); }); - -// `Object.isSealed` method -// https://tc39.es/ecma262/#sec-object.issealed -$$3n({ target: 'Object', stat: true, forced: FAILS_ON_PRIMITIVES$3 }, { - isSealed: function isSealed(it) { - return isObject$k(it) ? nativeIsSealed ? nativeIsSealed(it) : false : true; - } -}); - -var $$3m = _export; -var toObject$f = toObject$u; -var nativeKeys = objectKeys$5; -var fails$A = fails$Y; - -var FAILS_ON_PRIMITIVES$2 = fails$A(function () { nativeKeys(1); }); - -// `Object.keys` method -// https://tc39.es/ecma262/#sec-object.keys -$$3m({ target: 'Object', stat: true, forced: FAILS_ON_PRIMITIVES$2 }, { - keys: function keys(it) { - return nativeKeys(toObject$f(it)); - } -}); - -var $$3l = _export; -var isObject$j = isObject$B; -var onFreeze$1 = internalMetadata.exports.onFreeze; -var FREEZING$2 = freezing; -var fails$z = fails$Y; - -var nativePreventExtensions = Object.preventExtensions; -var FAILS_ON_PRIMITIVES$1 = fails$z(function () { nativePreventExtensions(1); }); - -// `Object.preventExtensions` method -// https://tc39.es/ecma262/#sec-object.preventextensions -$$3l({ target: 'Object', stat: true, forced: FAILS_ON_PRIMITIVES$1, sham: !FREEZING$2 }, { - preventExtensions: function preventExtensions(it) { - return nativePreventExtensions && isObject$j(it) ? nativePreventExtensions(onFreeze$1(it)) : it; - } -}); - -var $$3k = _export; -var isObject$i = isObject$B; -var onFreeze = internalMetadata.exports.onFreeze; -var FREEZING$1 = freezing; -var fails$y = fails$Y; - -var nativeSeal = Object.seal; -var FAILS_ON_PRIMITIVES = fails$y(function () { nativeSeal(1); }); - -// `Object.seal` method -// https://tc39.es/ecma262/#sec-object.seal -$$3k({ target: 'Object', stat: true, forced: FAILS_ON_PRIMITIVES, sham: !FREEZING$1 }, { - seal: function seal(it) { - return nativeSeal && isObject$i(it) ? nativeSeal(onFreeze(it)) : it; - } -}); - -var $$3j = _export; -var setPrototypeOf$4 = objectSetPrototypeOf$1; - -// `Object.setPrototypeOf` method -// https://tc39.es/ecma262/#sec-object.setprototypeof -$$3j({ target: 'Object', stat: true }, { - setPrototypeOf: setPrototypeOf$4 -}); - -var $$3i = _export; -var $values = objectToArray.values; - -// `Object.values` method -// https://tc39.es/ecma262/#sec-object.values -$$3i({ target: 'Object', stat: true }, { - values: function values(O) { - return $values(O); - } -}); - -var TO_STRING_TAG_SUPPORT$1 = toStringTagSupport; -var classof$8 = classof$b; - -// `Object.prototype.toString` method implementation -// https://tc39.es/ecma262/#sec-object.prototype.tostring -var objectToString = TO_STRING_TAG_SUPPORT$1 ? {}.toString : function toString() { - return '[object ' + classof$8(this) + ']'; -}; - -var TO_STRING_TAG_SUPPORT = toStringTagSupport; -var redefine$c = redefine$g.exports; -var toString = objectToString; - -// `Object.prototype.toString` method -// https://tc39.es/ecma262/#sec-object.prototype.tostring -if (!TO_STRING_TAG_SUPPORT) { - redefine$c(Object.prototype, 'toString', toString, { unsafe: true }); -} - -var global$v = global$L; -var fails$x = fails$Y; - -// Forced replacement object prototype accessors methods -var objectPrototypeAccessorsForced = !fails$x(function () { - var key = Math.random(); - // In FF throws only define methods - // eslint-disable-next-line no-undef, no-useless-call - __defineSetter__.call(null, key, function () { /* empty */ }); - delete global$v[key]; -}); - -var $$3h = _export; -var DESCRIPTORS$i = descriptors; -var FORCED$n = objectPrototypeAccessorsForced; -var toObject$e = toObject$u; -var aFunction$L = aFunction$R; -var definePropertyModule$4 = objectDefineProperty; - -// `Object.prototype.__defineGetter__` method -// https://tc39.es/ecma262/#sec-object.prototype.__defineGetter__ -if (DESCRIPTORS$i) { - $$3h({ target: 'Object', proto: true, forced: FORCED$n }, { - __defineGetter__: function __defineGetter__(P, getter) { - definePropertyModule$4.f(toObject$e(this), P, { get: aFunction$L(getter), enumerable: true, configurable: true }); - } - }); -} - -var $$3g = _export; -var DESCRIPTORS$h = descriptors; -var FORCED$m = objectPrototypeAccessorsForced; -var toObject$d = toObject$u; -var aFunction$K = aFunction$R; -var definePropertyModule$3 = objectDefineProperty; - -// `Object.prototype.__defineSetter__` method -// https://tc39.es/ecma262/#sec-object.prototype.__defineSetter__ -if (DESCRIPTORS$h) { - $$3g({ target: 'Object', proto: true, forced: FORCED$m }, { - __defineSetter__: function __defineSetter__(P, setter) { - definePropertyModule$3.f(toObject$d(this), P, { set: aFunction$K(setter), enumerable: true, configurable: true }); - } - }); -} - -var $$3f = _export; -var DESCRIPTORS$g = descriptors; -var FORCED$l = objectPrototypeAccessorsForced; -var toObject$c = toObject$u; -var toPrimitive$6 = toPrimitive$b; -var getPrototypeOf$9 = objectGetPrototypeOf$1; -var getOwnPropertyDescriptor$6 = objectGetOwnPropertyDescriptor.f; - -// `Object.prototype.__lookupGetter__` method -// https://tc39.es/ecma262/#sec-object.prototype.__lookupGetter__ -if (DESCRIPTORS$g) { - $$3f({ target: 'Object', proto: true, forced: FORCED$l }, { - __lookupGetter__: function __lookupGetter__(P) { - var O = toObject$c(this); - var key = toPrimitive$6(P, true); - var desc; - do { - if (desc = getOwnPropertyDescriptor$6(O, key)) return desc.get; - } while (O = getPrototypeOf$9(O)); - } - }); -} - -var $$3e = _export; -var DESCRIPTORS$f = descriptors; -var FORCED$k = objectPrototypeAccessorsForced; -var toObject$b = toObject$u; -var toPrimitive$5 = toPrimitive$b; -var getPrototypeOf$8 = objectGetPrototypeOf$1; -var getOwnPropertyDescriptor$5 = objectGetOwnPropertyDescriptor.f; - -// `Object.prototype.__lookupSetter__` method -// https://tc39.es/ecma262/#sec-object.prototype.__lookupSetter__ -if (DESCRIPTORS$f) { - $$3e({ target: 'Object', proto: true, forced: FORCED$k }, { - __lookupSetter__: function __lookupSetter__(P) { - var O = toObject$b(this); - var key = toPrimitive$5(P, true); - var desc; - do { - if (desc = getOwnPropertyDescriptor$5(O, key)) return desc.set; - } while (O = getPrototypeOf$8(O)); - } - }); -} - -var $$3d = _export; -var toAbsoluteIndex$2 = toAbsoluteIndex$8; - -var fromCharCode = String.fromCharCode; -var nativeFromCodePoint = String.fromCodePoint; - -// length should be 1, old FF problem -var INCORRECT_LENGTH = !!nativeFromCodePoint && nativeFromCodePoint.length != 1; - -// `String.fromCodePoint` method -// https://tc39.es/ecma262/#sec-string.fromcodepoint -$$3d({ target: 'String', stat: true, forced: INCORRECT_LENGTH }, { - fromCodePoint: function fromCodePoint(x) { // eslint-disable-line no-unused-vars - var elements = []; - var length = arguments.length; - var i = 0; - var code; - while (length > i) { - code = +arguments[i++]; - if (toAbsoluteIndex$2(code, 0x10FFFF) !== code) throw RangeError(code + ' is not a valid code point'); - elements.push(code < 0x10000 - ? fromCharCode(code) - : fromCharCode(((code -= 0x10000) >> 10) + 0xD800, code % 0x400 + 0xDC00) - ); - } return elements.join(''); - } -}); - -var $$3c = _export; -var toIndexedObject = toIndexedObject$d; -var toLength$j = toLength$y; - -// `String.raw` method -// https://tc39.es/ecma262/#sec-string.raw -$$3c({ target: 'String', stat: true }, { - raw: function raw(template) { - var rawTemplate = toIndexedObject(template.raw); - var literalSegments = toLength$j(rawTemplate.length); - var argumentsLength = arguments.length; - var elements = []; - var i = 0; - while (literalSegments > i) { - elements.push(String(rawTemplate[i++])); - if (i < argumentsLength) elements.push(String(arguments[i])); - } return elements.join(''); - } -}); - -var toInteger$9 = toInteger$f; -var requireObjectCoercible$e = requireObjectCoercible$h; - -// `String.prototype.{ codePointAt, at }` methods implementation -var createMethod$3 = function (CONVERT_TO_STRING) { - return function ($this, pos) { - var S = String(requireObjectCoercible$e($this)); - var position = toInteger$9(pos); - var size = S.length; - var first, second; - if (position < 0 || position >= size) return CONVERT_TO_STRING ? '' : undefined; - first = S.charCodeAt(position); - return first < 0xD800 || first > 0xDBFF || position + 1 === size - || (second = S.charCodeAt(position + 1)) < 0xDC00 || second > 0xDFFF - ? CONVERT_TO_STRING ? S.charAt(position) : first - : CONVERT_TO_STRING ? S.slice(position, position + 2) : (first - 0xD800 << 10) + (second - 0xDC00) + 0x10000; - }; -}; - -var stringMultibyte = { - // `String.prototype.codePointAt` method - // https://tc39.es/ecma262/#sec-string.prototype.codepointat - codeAt: createMethod$3(false), - // `String.prototype.at` method - // https://github.com/mathiasbynens/String.prototype.at - charAt: createMethod$3(true) -}; - -var $$3b = _export; -var codeAt$2 = stringMultibyte.codeAt; - -// `String.prototype.codePointAt` method -// https://tc39.es/ecma262/#sec-string.prototype.codepointat -$$3b({ target: 'String', proto: true }, { - codePointAt: function codePointAt(pos) { - return codeAt$2(this, pos); - } -}); - -var isObject$h = isObject$B; -var classof$7 = classofRaw$1; -var wellKnownSymbol$k = wellKnownSymbol$C; - -var MATCH$2 = wellKnownSymbol$k('match'); - -// `IsRegExp` abstract operation -// https://tc39.es/ecma262/#sec-isregexp -var isRegexp = function (it) { - var isRegExp; - return isObject$h(it) && ((isRegExp = it[MATCH$2]) !== undefined ? !!isRegExp : classof$7(it) == 'RegExp'); -}; - -var isRegExp$4 = isRegexp; - -var notARegexp = function (it) { - if (isRegExp$4(it)) { - throw TypeError("The method doesn't accept regular expressions"); - } return it; -}; - -var wellKnownSymbol$j = wellKnownSymbol$C; - -var MATCH$1 = wellKnownSymbol$j('match'); - -var correctIsRegexpLogic = function (METHOD_NAME) { - var regexp = /./; - try { - '/./'[METHOD_NAME](regexp); - } catch (error1) { - try { - regexp[MATCH$1] = false; - return '/./'[METHOD_NAME](regexp); - } catch (error2) { /* empty */ } - } return false; -}; - -var $$3a = _export; -var getOwnPropertyDescriptor$4 = objectGetOwnPropertyDescriptor.f; -var toLength$i = toLength$y; -var notARegExp$2 = notARegexp; -var requireObjectCoercible$d = requireObjectCoercible$h; -var correctIsRegExpLogic$2 = correctIsRegexpLogic; - -var nativeEndsWith = ''.endsWith; -var min$4 = Math.min; - -var CORRECT_IS_REGEXP_LOGIC$1 = correctIsRegExpLogic$2('endsWith'); -// https://github.com/zloirock/core-js/pull/702 -var MDN_POLYFILL_BUG$1 = !CORRECT_IS_REGEXP_LOGIC$1 && !!function () { - var descriptor = getOwnPropertyDescriptor$4(String.prototype, 'endsWith'); - return descriptor && !descriptor.writable; -}(); - -// `String.prototype.endsWith` method -// https://tc39.es/ecma262/#sec-string.prototype.endswith -$$3a({ target: 'String', proto: true, forced: !MDN_POLYFILL_BUG$1 && !CORRECT_IS_REGEXP_LOGIC$1 }, { - endsWith: function endsWith(searchString /* , endPosition = @length */) { - var that = String(requireObjectCoercible$d(this)); - notARegExp$2(searchString); - var endPosition = arguments.length > 1 ? arguments[1] : undefined; - var len = toLength$i(that.length); - var end = endPosition === undefined ? len : min$4(toLength$i(endPosition), len); - var search = String(searchString); - return nativeEndsWith - ? nativeEndsWith.call(that, search, end) - : that.slice(end - search.length, end) === search; - } -}); - -var $$39 = _export; -var notARegExp$1 = notARegexp; -var requireObjectCoercible$c = requireObjectCoercible$h; -var correctIsRegExpLogic$1 = correctIsRegexpLogic; - -// `String.prototype.includes` method -// https://tc39.es/ecma262/#sec-string.prototype.includes -$$39({ target: 'String', proto: true, forced: !correctIsRegExpLogic$1('includes') }, { - includes: function includes(searchString /* , position = 0 */) { - return !!~String(requireObjectCoercible$c(this)) - .indexOf(notARegExp$1(searchString), arguments.length > 1 ? arguments[1] : undefined); - } -}); - -var anObject$1p = anObject$1z; - -// `RegExp.prototype.flags` getter implementation -// https://tc39.es/ecma262/#sec-get-regexp.prototype.flags -var regexpFlags$1 = function () { - var that = anObject$1p(this); - var result = ''; - if (that.global) result += 'g'; - if (that.ignoreCase) result += 'i'; - if (that.multiline) result += 'm'; - if (that.dotAll) result += 's'; - if (that.unicode) result += 'u'; - if (that.sticky) result += 'y'; - return result; -}; - -var regexpStickyHelpers = {}; - -var fails$w = fails$Y; - -// babel-minify transpiles RegExp('a', 'y') -> /a/y and it causes SyntaxError, -// so we use an intermediate function. -function RE(s, f) { - return RegExp(s, f); -} - -regexpStickyHelpers.UNSUPPORTED_Y = fails$w(function () { - // babel-minify transpiles RegExp('a', 'y') -> /a/y and it causes SyntaxError - var re = RE('a', 'y'); - re.lastIndex = 2; - return re.exec('abcd') != null; -}); - -regexpStickyHelpers.BROKEN_CARET = fails$w(function () { - // https://bugzilla.mozilla.org/show_bug.cgi?id=773687 - var re = RE('^r', 'gy'); - re.lastIndex = 2; - return re.exec('str') != null; -}); - -var regexpFlags = regexpFlags$1; -var stickyHelpers$1 = regexpStickyHelpers; - -var nativeExec = RegExp.prototype.exec; -// This always refers to the native implementation, because the -// String#replace polyfill uses ./fix-regexp-well-known-symbol-logic.js, -// which loads this file before patching the method. -var nativeReplace = String.prototype.replace; - -var patchedExec = nativeExec; - -var UPDATES_LAST_INDEX_WRONG = (function () { - var re1 = /a/; - var re2 = /b*/g; - nativeExec.call(re1, 'a'); - nativeExec.call(re2, 'a'); - return re1.lastIndex !== 0 || re2.lastIndex !== 0; -})(); - -var UNSUPPORTED_Y$3 = stickyHelpers$1.UNSUPPORTED_Y || stickyHelpers$1.BROKEN_CARET; - -// nonparticipating capturing group, copied from es5-shim's String#split patch. -var NPCG_INCLUDED = /()??/.exec('')[1] !== undefined; - -var PATCH = UPDATES_LAST_INDEX_WRONG || NPCG_INCLUDED || UNSUPPORTED_Y$3; - -if (PATCH) { - patchedExec = function exec(str) { - var re = this; - var lastIndex, reCopy, match, i; - var sticky = UNSUPPORTED_Y$3 && re.sticky; - var flags = regexpFlags.call(re); - var source = re.source; - var charsAdded = 0; - var strCopy = str; - - if (sticky) { - flags = flags.replace('y', ''); - if (flags.indexOf('g') === -1) { - flags += 'g'; - } - - strCopy = String(str).slice(re.lastIndex); - // Support anchored sticky behavior. - if (re.lastIndex > 0 && (!re.multiline || re.multiline && str[re.lastIndex - 1] !== '\n')) { - source = '(?: ' + source + ')'; - strCopy = ' ' + strCopy; - charsAdded++; - } - // ^(? + rx + ) is needed, in combination with some str slicing, to - // simulate the 'y' flag. - reCopy = new RegExp('^(?:' + source + ')', flags); - } - - if (NPCG_INCLUDED) { - reCopy = new RegExp('^' + source + '$(?!\\s)', flags); - } - if (UPDATES_LAST_INDEX_WRONG) lastIndex = re.lastIndex; - - match = nativeExec.call(sticky ? reCopy : re, strCopy); - - if (sticky) { - if (match) { - match.input = match.input.slice(charsAdded); - match[0] = match[0].slice(charsAdded); - match.index = re.lastIndex; - re.lastIndex += match[0].length; - } else re.lastIndex = 0; - } else if (UPDATES_LAST_INDEX_WRONG && match) { - re.lastIndex = re.global ? match.index + match[0].length : lastIndex; - } - if (NPCG_INCLUDED && match && match.length > 1) { - // Fix browsers whose `exec` methods don't consistently return `undefined` - // for NPCG, like IE8. NOTE: This doesn' work for /(.?)?/ - nativeReplace.call(match[0], reCopy, function () { - for (i = 1; i < arguments.length - 2; i++) { - if (arguments[i] === undefined) match[i] = undefined; - } - }); - } - - return match; - }; -} - -var regexpExec$3 = patchedExec; - -var $$38 = _export; -var exec = regexpExec$3; - -// `RegExp.prototype.exec` method -// https://tc39.es/ecma262/#sec-regexp.prototype.exec -$$38({ target: 'RegExp', proto: true, forced: /./.exec !== exec }, { - exec: exec -}); - -// TODO: Remove from `core-js@4` since it's moved to entry points - -var redefine$b = redefine$g.exports; -var fails$v = fails$Y; -var wellKnownSymbol$i = wellKnownSymbol$C; -var regexpExec$2 = regexpExec$3; -var createNonEnumerableProperty$d = createNonEnumerableProperty$m; - -var SPECIES$2 = wellKnownSymbol$i('species'); - -var REPLACE_SUPPORTS_NAMED_GROUPS = !fails$v(function () { - // #replace needs built-in support for named groups. - // #match works fine because it just return the exec results, even if it has - // a "grops" property. - var re = /./; - re.exec = function () { - var result = []; - result.groups = { a: '7' }; - return result; - }; - return ''.replace(re, '$
') !== '7'; -}); - -// IE <= 11 replaces $0 with the whole match, as if it was $& -// https://stackoverflow.com/questions/6024666/getting-ie-to-replace-a-regex-with-the-literal-string-0 -var REPLACE_KEEPS_$0 = (function () { - return 'a'.replace(/./, '$0') === '$0'; -})(); - -var REPLACE$1 = wellKnownSymbol$i('replace'); -// Safari <= 13.0.3(?) substitutes nth capture where n>m with an empty string -var REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE = (function () { - if (/./[REPLACE$1]) { - return /./[REPLACE$1]('a', '$0') === ''; - } - return false; -})(); - -// Chrome 51 has a buggy "split" implementation when RegExp#exec !== nativeExec -// Weex JS has frozen built-in prototypes, so use try / catch wrapper -var SPLIT_WORKS_WITH_OVERWRITTEN_EXEC = !fails$v(function () { - var re = /(?:)/; - var originalExec = re.exec; - re.exec = function () { return originalExec.apply(this, arguments); }; - var result = 'ab'.split(re); - return result.length !== 2 || result[0] !== 'a' || result[1] !== 'b'; -}); - -var fixRegexpWellKnownSymbolLogic = function (KEY, length, exec, sham) { - var SYMBOL = wellKnownSymbol$i(KEY); - - var DELEGATES_TO_SYMBOL = !fails$v(function () { - // String methods call symbol-named RegEp methods - var O = {}; - O[SYMBOL] = function () { return 7; }; - return ''[KEY](O) != 7; - }); - - var DELEGATES_TO_EXEC = DELEGATES_TO_SYMBOL && !fails$v(function () { - // Symbol-named RegExp methods call .exec - var execCalled = false; - var re = /a/; - - if (KEY === 'split') { - // We can't use real regex here since it causes deoptimization - // and serious performance degradation in V8 - // https://github.com/zloirock/core-js/issues/306 - re = {}; - // RegExp[@@split] doesn't call the regex's exec method, but first creates - // a new one. We need to return the patched regex when creating the new one. - re.constructor = {}; - re.constructor[SPECIES$2] = function () { return re; }; - re.flags = ''; - re[SYMBOL] = /./[SYMBOL]; - } - - re.exec = function () { execCalled = true; return null; }; - - re[SYMBOL](''); - return !execCalled; - }); - - if ( - !DELEGATES_TO_SYMBOL || - !DELEGATES_TO_EXEC || - (KEY === 'replace' && !( - REPLACE_SUPPORTS_NAMED_GROUPS && - REPLACE_KEEPS_$0 && - !REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE - )) || - (KEY === 'split' && !SPLIT_WORKS_WITH_OVERWRITTEN_EXEC) - ) { - var nativeRegExpMethod = /./[SYMBOL]; - var methods = exec(SYMBOL, ''[KEY], function (nativeMethod, regexp, str, arg2, forceStringMethod) { - if (regexp.exec === regexpExec$2) { - if (DELEGATES_TO_SYMBOL && !forceStringMethod) { - // The native String method already delegates to @@method (this - // polyfilled function), leasing to infinite recursion. - // We avoid it by directly calling the native @@method method. - return { done: true, value: nativeRegExpMethod.call(regexp, str, arg2) }; - } - return { done: true, value: nativeMethod.call(str, regexp, arg2) }; - } - return { done: false }; - }, { - REPLACE_KEEPS_$0: REPLACE_KEEPS_$0, - REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE: REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE - }); - var stringMethod = methods[0]; - var regexMethod = methods[1]; - - redefine$b(String.prototype, KEY, stringMethod); - redefine$b(RegExp.prototype, SYMBOL, length == 2 - // 21.2.5.8 RegExp.prototype[@@replace](string, replaceValue) - // 21.2.5.11 RegExp.prototype[@@split](string, limit) - ? function (string, arg) { return regexMethod.call(string, this, arg); } - // 21.2.5.6 RegExp.prototype[@@match](string) - // 21.2.5.9 RegExp.prototype[@@search](string) - : function (string) { return regexMethod.call(string, this); } - ); - } - - if (sham) createNonEnumerableProperty$d(RegExp.prototype[SYMBOL], 'sham', true); -}; - -var charAt$3 = stringMultibyte.charAt; - -// `AdvanceStringIndex` abstract operation -// https://tc39.es/ecma262/#sec-advancestringindex -var advanceStringIndex$4 = function (S, index, unicode) { - return index + (unicode ? charAt$3(S, index).length : 1); -}; - -var classof$6 = classofRaw$1; -var regexpExec$1 = regexpExec$3; - -// `RegExpExec` abstract operation -// https://tc39.es/ecma262/#sec-regexpexec -var regexpExecAbstract = function (R, S) { - var exec = R.exec; - if (typeof exec === 'function') { - var result = exec.call(R, S); - if (typeof result !== 'object') { - throw TypeError('RegExp exec method returned something other than an Object or null'); - } - return result; - } - - if (classof$6(R) !== 'RegExp') { - throw TypeError('RegExp#exec called on incompatible receiver'); - } - - return regexpExec$1.call(R, S); -}; - -var fixRegExpWellKnownSymbolLogic$3 = fixRegexpWellKnownSymbolLogic; -var anObject$1o = anObject$1z; -var toLength$h = toLength$y; -var requireObjectCoercible$b = requireObjectCoercible$h; -var advanceStringIndex$3 = advanceStringIndex$4; -var regExpExec$3 = regexpExecAbstract; - -// @@match logic -fixRegExpWellKnownSymbolLogic$3('match', 1, function (MATCH, nativeMatch, maybeCallNative) { - return [ - // `String.prototype.match` method - // https://tc39.es/ecma262/#sec-string.prototype.match - function match(regexp) { - var O = requireObjectCoercible$b(this); - var matcher = regexp == undefined ? undefined : regexp[MATCH]; - return matcher !== undefined ? matcher.call(regexp, O) : new RegExp(regexp)[MATCH](String(O)); - }, - // `RegExp.prototype[@@match]` method - // https://tc39.es/ecma262/#sec-regexp.prototype-@@match - function (regexp) { - var res = maybeCallNative(nativeMatch, regexp, this); - if (res.done) return res.value; - - var rx = anObject$1o(regexp); - var S = String(this); - - if (!rx.global) return regExpExec$3(rx, S); - - var fullUnicode = rx.unicode; - rx.lastIndex = 0; - var A = []; - var n = 0; - var result; - while ((result = regExpExec$3(rx, S)) !== null) { - var matchStr = String(result[0]); - A[n] = matchStr; - if (matchStr === '') rx.lastIndex = advanceStringIndex$3(S, toLength$h(rx.lastIndex), fullUnicode); - n++; - } - return n === 0 ? null : A; - } - ]; -}); - -var anObject$1n = anObject$1z; -var aFunction$J = aFunction$R; -var wellKnownSymbol$h = wellKnownSymbol$C; - -var SPECIES$1 = wellKnownSymbol$h('species'); - -// `SpeciesConstructor` abstract operation -// https://tc39.es/ecma262/#sec-speciesconstructor -var speciesConstructor$j = function (O, defaultConstructor) { - var C = anObject$1n(O).constructor; - var S; - return C === undefined || (S = anObject$1n(C)[SPECIES$1]) == undefined ? defaultConstructor : aFunction$J(S); -}; - -var $$37 = _export; -var createIteratorConstructor$5 = createIteratorConstructor$7; -var requireObjectCoercible$a = requireObjectCoercible$h; -var toLength$g = toLength$y; -var aFunction$I = aFunction$R; -var anObject$1m = anObject$1z; -var classof$5 = classofRaw$1; -var isRegExp$3 = isRegexp; -var getRegExpFlags$1 = regexpFlags$1; -var createNonEnumerableProperty$c = createNonEnumerableProperty$m; -var fails$u = fails$Y; -var wellKnownSymbol$g = wellKnownSymbol$C; -var speciesConstructor$i = speciesConstructor$j; -var advanceStringIndex$2 = advanceStringIndex$4; -var InternalStateModule$f = internalState; -var IS_PURE$D = isPure; - -var MATCH_ALL = wellKnownSymbol$g('matchAll'); -var REGEXP_STRING = 'RegExp String'; -var REGEXP_STRING_ITERATOR = REGEXP_STRING + ' Iterator'; -var setInternalState$g = InternalStateModule$f.set; -var getInternalState$c = InternalStateModule$f.getterFor(REGEXP_STRING_ITERATOR); -var RegExpPrototype$4 = RegExp.prototype; -var regExpBuiltinExec = RegExpPrototype$4.exec; -var nativeMatchAll = ''.matchAll; - -var WORKS_WITH_NON_GLOBAL_REGEX = !!nativeMatchAll && !fails$u(function () { - 'a'.matchAll(/./); -}); - -var regExpExec$2 = function (R, S) { - var exec = R.exec; - var result; - if (typeof exec == 'function') { - result = exec.call(R, S); - if (typeof result != 'object') throw TypeError('Incorrect exec result'); - return result; - } return regExpBuiltinExec.call(R, S); -}; - -// eslint-disable-next-line max-len -var $RegExpStringIterator = createIteratorConstructor$5(function RegExpStringIterator(regexp, string, global, fullUnicode) { - setInternalState$g(this, { - type: REGEXP_STRING_ITERATOR, - regexp: regexp, - string: string, - global: global, - unicode: fullUnicode, - done: false - }); -}, REGEXP_STRING, function next() { - var state = getInternalState$c(this); - if (state.done) return { value: undefined, done: true }; - var R = state.regexp; - var S = state.string; - var match = regExpExec$2(R, S); - if (match === null) return { value: undefined, done: state.done = true }; - if (state.global) { - if (String(match[0]) == '') R.lastIndex = advanceStringIndex$2(S, toLength$g(R.lastIndex), state.unicode); - return { value: match, done: false }; - } - state.done = true; - return { value: match, done: false }; -}); - -var $matchAll = function (string) { - var R = anObject$1m(this); - var S = String(string); - var C, flagsValue, flags, matcher, global, fullUnicode; - C = speciesConstructor$i(R, RegExp); - flagsValue = R.flags; - if (flagsValue === undefined && R instanceof RegExp && !('flags' in RegExpPrototype$4)) { - flagsValue = getRegExpFlags$1.call(R); - } - flags = flagsValue === undefined ? '' : String(flagsValue); - matcher = new C(C === RegExp ? R.source : R, flags); - global = !!~flags.indexOf('g'); - fullUnicode = !!~flags.indexOf('u'); - matcher.lastIndex = toLength$g(R.lastIndex); - return new $RegExpStringIterator(matcher, S, global, fullUnicode); -}; - -// `String.prototype.matchAll` method -// https://tc39.es/ecma262/#sec-string.prototype.matchall -$$37({ target: 'String', proto: true, forced: WORKS_WITH_NON_GLOBAL_REGEX }, { - matchAll: function matchAll(regexp) { - var O = requireObjectCoercible$a(this); - var flags, S, matcher, rx; - if (regexp != null) { - if (isRegExp$3(regexp)) { - flags = String(requireObjectCoercible$a('flags' in RegExpPrototype$4 - ? regexp.flags - : getRegExpFlags$1.call(regexp) - )); - if (!~flags.indexOf('g')) throw TypeError('`.matchAll` does not allow non-global regexes'); - } - if (WORKS_WITH_NON_GLOBAL_REGEX) return nativeMatchAll.apply(O, arguments); - matcher = regexp[MATCH_ALL]; - if (matcher === undefined && IS_PURE$D && classof$5(regexp) == 'RegExp') matcher = $matchAll; - if (matcher != null) return aFunction$I(matcher).call(regexp, O); - } else if (WORKS_WITH_NON_GLOBAL_REGEX) return nativeMatchAll.apply(O, arguments); - S = String(O); - rx = new RegExp(regexp, 'g'); - return rx[MATCH_ALL](S); - } -}); - -MATCH_ALL in RegExpPrototype$4 || createNonEnumerableProperty$c(RegExpPrototype$4, MATCH_ALL, $matchAll); - -var toInteger$8 = toInteger$f; -var requireObjectCoercible$9 = requireObjectCoercible$h; - -// `String.prototype.repeat` method implementation -// https://tc39.es/ecma262/#sec-string.prototype.repeat -var stringRepeat = ''.repeat || function repeat(count) { - var str = String(requireObjectCoercible$9(this)); - var result = ''; - var n = toInteger$8(count); - if (n < 0 || n == Infinity) throw RangeError('Wrong number of repetitions'); - for (;n > 0; (n >>>= 1) && (str += str)) if (n & 1) result += str; - return result; -}; - -// https://github.com/tc39/proposal-string-pad-start-end -var toLength$f = toLength$y; -var repeat$2 = stringRepeat; -var requireObjectCoercible$8 = requireObjectCoercible$h; - -var ceil$1 = Math.ceil; - -// `String.prototype.{ padStart, padEnd }` methods implementation -var createMethod$2 = function (IS_END) { - return function ($this, maxLength, fillString) { - var S = String(requireObjectCoercible$8($this)); - var stringLength = S.length; - var fillStr = fillString === undefined ? ' ' : String(fillString); - var intMaxLength = toLength$f(maxLength); - var fillLen, stringFiller; - if (intMaxLength <= stringLength || fillStr == '') return S; - fillLen = intMaxLength - stringLength; - stringFiller = repeat$2.call(fillStr, ceil$1(fillLen / fillStr.length)); - if (stringFiller.length > fillLen) stringFiller = stringFiller.slice(0, fillLen); - return IS_END ? S + stringFiller : stringFiller + S; - }; -}; - -var stringPad = { - // `String.prototype.padStart` method - // https://tc39.es/ecma262/#sec-string.prototype.padstart - start: createMethod$2(false), - // `String.prototype.padEnd` method - // https://tc39.es/ecma262/#sec-string.prototype.padend - end: createMethod$2(true) -}; - -// https://github.com/zloirock/core-js/issues/280 -var userAgent$3 = engineUserAgent; - -// eslint-disable-next-line unicorn/no-unsafe-regex -var stringPadWebkitBug = /Version\/10\.\d+(\.\d+)?( Mobile\/\w+)? Safari\//.test(userAgent$3); - -var $$36 = _export; -var $padEnd = stringPad.end; -var WEBKIT_BUG$1 = stringPadWebkitBug; - -// `String.prototype.padEnd` method -// https://tc39.es/ecma262/#sec-string.prototype.padend -$$36({ target: 'String', proto: true, forced: WEBKIT_BUG$1 }, { - padEnd: function padEnd(maxLength /* , fillString = ' ' */) { - return $padEnd(this, maxLength, arguments.length > 1 ? arguments[1] : undefined); - } -}); - -var $$35 = _export; -var $padStart = stringPad.start; -var WEBKIT_BUG = stringPadWebkitBug; - -// `String.prototype.padStart` method -// https://tc39.es/ecma262/#sec-string.prototype.padstart -$$35({ target: 'String', proto: true, forced: WEBKIT_BUG }, { - padStart: function padStart(maxLength /* , fillString = ' ' */) { - return $padStart(this, maxLength, arguments.length > 1 ? arguments[1] : undefined); - } -}); - -var $$34 = _export; -var repeat$1 = stringRepeat; - -// `String.prototype.repeat` method -// https://tc39.es/ecma262/#sec-string.prototype.repeat -$$34({ target: 'String', proto: true }, { - repeat: repeat$1 -}); - -var toObject$a = toObject$u; - -var floor$8 = Math.floor; -var replace$1 = ''.replace; -var SUBSTITUTION_SYMBOLS = /\$([$&'`]|\d\d?|<[^>]*>)/g; -var SUBSTITUTION_SYMBOLS_NO_NAMED = /\$([$&'`]|\d\d?)/g; - -// https://tc39.es/ecma262/#sec-getsubstitution -var getSubstitution$2 = function (matched, str, position, captures, namedCaptures, replacement) { - var tailPos = position + matched.length; - var m = captures.length; - var symbols = SUBSTITUTION_SYMBOLS_NO_NAMED; - if (namedCaptures !== undefined) { - namedCaptures = toObject$a(namedCaptures); - symbols = SUBSTITUTION_SYMBOLS; - } - return replace$1.call(replacement, symbols, function (match, ch) { - var capture; - switch (ch.charAt(0)) { - case '$': return '$'; - case '&': return matched; - case '`': return str.slice(0, position); - case "'": return str.slice(tailPos); - case '<': - capture = namedCaptures[ch.slice(1, -1)]; - break; - default: // \d\d? - var n = +ch; - if (n === 0) return match; - if (n > m) { - var f = floor$8(n / 10); - if (f === 0) return match; - if (f <= m) return captures[f - 1] === undefined ? ch.charAt(1) : captures[f - 1] + ch.charAt(1); - return match; - } - capture = captures[n - 1]; - } - return capture === undefined ? '' : capture; - }); -}; - -var fixRegExpWellKnownSymbolLogic$2 = fixRegexpWellKnownSymbolLogic; -var anObject$1l = anObject$1z; -var toLength$e = toLength$y; -var toInteger$7 = toInteger$f; -var requireObjectCoercible$7 = requireObjectCoercible$h; -var advanceStringIndex$1 = advanceStringIndex$4; -var getSubstitution$1 = getSubstitution$2; -var regExpExec$1 = regexpExecAbstract; - -var max$2 = Math.max; -var min$3 = Math.min; - -var maybeToString = function (it) { - return it === undefined ? it : String(it); -}; - -// @@replace logic -fixRegExpWellKnownSymbolLogic$2('replace', 2, function (REPLACE, nativeReplace, maybeCallNative, reason) { - var REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE = reason.REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE; - var REPLACE_KEEPS_$0 = reason.REPLACE_KEEPS_$0; - var UNSAFE_SUBSTITUTE = REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE ? '$' : '$0'; - - return [ - // `String.prototype.replace` method - // https://tc39.es/ecma262/#sec-string.prototype.replace - function replace(searchValue, replaceValue) { - var O = requireObjectCoercible$7(this); - var replacer = searchValue == undefined ? undefined : searchValue[REPLACE]; - return replacer !== undefined - ? replacer.call(searchValue, O, replaceValue) - : nativeReplace.call(String(O), searchValue, replaceValue); - }, - // `RegExp.prototype[@@replace]` method - // https://tc39.es/ecma262/#sec-regexp.prototype-@@replace - function (regexp, replaceValue) { - if ( - (!REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE && REPLACE_KEEPS_$0) || - (typeof replaceValue === 'string' && replaceValue.indexOf(UNSAFE_SUBSTITUTE) === -1) - ) { - var res = maybeCallNative(nativeReplace, regexp, this, replaceValue); - if (res.done) return res.value; - } - - var rx = anObject$1l(regexp); - var S = String(this); - - var functionalReplace = typeof replaceValue === 'function'; - if (!functionalReplace) replaceValue = String(replaceValue); - - var global = rx.global; - if (global) { - var fullUnicode = rx.unicode; - rx.lastIndex = 0; - } - var results = []; - while (true) { - var result = regExpExec$1(rx, S); - if (result === null) break; - - results.push(result); - if (!global) break; - - var matchStr = String(result[0]); - if (matchStr === '') rx.lastIndex = advanceStringIndex$1(S, toLength$e(rx.lastIndex), fullUnicode); - } - - var accumulatedResult = ''; - var nextSourcePosition = 0; - for (var i = 0; i < results.length; i++) { - result = results[i]; - - var matched = String(result[0]); - var position = max$2(min$3(toInteger$7(result.index), S.length), 0); - var captures = []; - // NOTE: This is equivalent to - // captures = result.slice(1).map(maybeToString) - // but for some reason `nativeSlice.call(result, 1, result.length)` (called in - // the slice polyfill when slicing native arrays) "doesn't work" in safari 9 and - // causes a crash (https://pastebin.com/N21QzeQA) when trying to debug it. - for (var j = 1; j < result.length; j++) captures.push(maybeToString(result[j])); - var namedCaptures = result.groups; - if (functionalReplace) { - var replacerArgs = [matched].concat(captures, position, S); - if (namedCaptures !== undefined) replacerArgs.push(namedCaptures); - var replacement = String(replaceValue.apply(undefined, replacerArgs)); - } else { - replacement = getSubstitution$1(matched, S, position, captures, namedCaptures, replaceValue); - } - if (position >= nextSourcePosition) { - accumulatedResult += S.slice(nextSourcePosition, position) + replacement; - nextSourcePosition = position + matched.length; - } - } - return accumulatedResult + S.slice(nextSourcePosition); - } - ]; -}); - -var fixRegExpWellKnownSymbolLogic$1 = fixRegexpWellKnownSymbolLogic; -var anObject$1k = anObject$1z; -var requireObjectCoercible$6 = requireObjectCoercible$h; -var sameValue = sameValue$1; -var regExpExec = regexpExecAbstract; - -// @@search logic -fixRegExpWellKnownSymbolLogic$1('search', 1, function (SEARCH, nativeSearch, maybeCallNative) { - return [ - // `String.prototype.search` method - // https://tc39.es/ecma262/#sec-string.prototype.search - function search(regexp) { - var O = requireObjectCoercible$6(this); - var searcher = regexp == undefined ? undefined : regexp[SEARCH]; - return searcher !== undefined ? searcher.call(regexp, O) : new RegExp(regexp)[SEARCH](String(O)); - }, - // `RegExp.prototype[@@search]` method - // https://tc39.es/ecma262/#sec-regexp.prototype-@@search - function (regexp) { - var res = maybeCallNative(nativeSearch, regexp, this); - if (res.done) return res.value; - - var rx = anObject$1k(regexp); - var S = String(this); - - var previousLastIndex = rx.lastIndex; - if (!sameValue(previousLastIndex, 0)) rx.lastIndex = 0; - var result = regExpExec(rx, S); - if (!sameValue(rx.lastIndex, previousLastIndex)) rx.lastIndex = previousLastIndex; - return result === null ? -1 : result.index; - } - ]; -}); - -var fixRegExpWellKnownSymbolLogic = fixRegexpWellKnownSymbolLogic; -var isRegExp$2 = isRegexp; -var anObject$1j = anObject$1z; -var requireObjectCoercible$5 = requireObjectCoercible$h; -var speciesConstructor$h = speciesConstructor$j; -var advanceStringIndex = advanceStringIndex$4; -var toLength$d = toLength$y; -var callRegExpExec = regexpExecAbstract; -var regexpExec = regexpExec$3; -var fails$t = fails$Y; - -var arrayPush = [].push; -var min$2 = Math.min; -var MAX_UINT32 = 0xFFFFFFFF; - -// babel-minify transpiles RegExp('x', 'y') -> /x/y and it causes SyntaxError -var SUPPORTS_Y = !fails$t(function () { return !RegExp(MAX_UINT32, 'y'); }); - -// @@split logic -fixRegExpWellKnownSymbolLogic('split', 2, function (SPLIT, nativeSplit, maybeCallNative) { - var internalSplit; - if ( - 'abbc'.split(/(b)*/)[1] == 'c' || - 'test'.split(/(?:)/, -1).length != 4 || - 'ab'.split(/(?:ab)*/).length != 2 || - '.'.split(/(.?)(.?)/).length != 4 || - '.'.split(/()()/).length > 1 || - ''.split(/.?/).length - ) { - // based on es5-shim implementation, need to rework it - internalSplit = function (separator, limit) { - var string = String(requireObjectCoercible$5(this)); - var lim = limit === undefined ? MAX_UINT32 : limit >>> 0; - if (lim === 0) return []; - if (separator === undefined) return [string]; - // If `separator` is not a regex, use native split - if (!isRegExp$2(separator)) { - return nativeSplit.call(string, separator, lim); - } - var output = []; - var flags = (separator.ignoreCase ? 'i' : '') + - (separator.multiline ? 'm' : '') + - (separator.unicode ? 'u' : '') + - (separator.sticky ? 'y' : ''); - var lastLastIndex = 0; - // Make `global` and avoid `lastIndex` issues by working with a copy - var separatorCopy = new RegExp(separator.source, flags + 'g'); - var match, lastIndex, lastLength; - while (match = regexpExec.call(separatorCopy, string)) { - lastIndex = separatorCopy.lastIndex; - if (lastIndex > lastLastIndex) { - output.push(string.slice(lastLastIndex, match.index)); - if (match.length > 1 && match.index < string.length) arrayPush.apply(output, match.slice(1)); - lastLength = match[0].length; - lastLastIndex = lastIndex; - if (output.length >= lim) break; - } - if (separatorCopy.lastIndex === match.index) separatorCopy.lastIndex++; // Avoid an infinite loop - } - if (lastLastIndex === string.length) { - if (lastLength || !separatorCopy.test('')) output.push(''); - } else output.push(string.slice(lastLastIndex)); - return output.length > lim ? output.slice(0, lim) : output; - }; - // Chakra, V8 - } else if ('0'.split(undefined, 0).length) { - internalSplit = function (separator, limit) { - return separator === undefined && limit === 0 ? [] : nativeSplit.call(this, separator, limit); - }; - } else internalSplit = nativeSplit; - - return [ - // `String.prototype.split` method - // https://tc39.es/ecma262/#sec-string.prototype.split - function split(separator, limit) { - var O = requireObjectCoercible$5(this); - var splitter = separator == undefined ? undefined : separator[SPLIT]; - return splitter !== undefined - ? splitter.call(separator, O, limit) - : internalSplit.call(String(O), separator, limit); - }, - // `RegExp.prototype[@@split]` method - // https://tc39.es/ecma262/#sec-regexp.prototype-@@split - // - // NOTE: This cannot be properly polyfilled in engines that don't support - // the 'y' flag. - function (regexp, limit) { - var res = maybeCallNative(internalSplit, regexp, this, limit, internalSplit !== nativeSplit); - if (res.done) return res.value; - - var rx = anObject$1j(regexp); - var S = String(this); - var C = speciesConstructor$h(rx, RegExp); - - var unicodeMatching = rx.unicode; - var flags = (rx.ignoreCase ? 'i' : '') + - (rx.multiline ? 'm' : '') + - (rx.unicode ? 'u' : '') + - (SUPPORTS_Y ? 'y' : 'g'); - - // ^(? + rx + ) is needed, in combination with some S slicing, to - // simulate the 'y' flag. - var splitter = new C(SUPPORTS_Y ? rx : '^(?:' + rx.source + ')', flags); - var lim = limit === undefined ? MAX_UINT32 : limit >>> 0; - if (lim === 0) return []; - if (S.length === 0) return callRegExpExec(splitter, S) === null ? [S] : []; - var p = 0; - var q = 0; - var A = []; - while (q < S.length) { - splitter.lastIndex = SUPPORTS_Y ? q : 0; - var z = callRegExpExec(splitter, SUPPORTS_Y ? S : S.slice(q)); - var e; - if ( - z === null || - (e = min$2(toLength$d(splitter.lastIndex + (SUPPORTS_Y ? 0 : q)), S.length)) === p - ) { - q = advanceStringIndex(S, q, unicodeMatching); - } else { - A.push(S.slice(p, q)); - if (A.length === lim) return A; - for (var i = 1; i <= z.length - 1; i++) { - A.push(z[i]); - if (A.length === lim) return A; - } - q = p = e; - } - } - A.push(S.slice(p)); - return A; - } - ]; -}, !SUPPORTS_Y); - -var $$33 = _export; -var getOwnPropertyDescriptor$3 = objectGetOwnPropertyDescriptor.f; -var toLength$c = toLength$y; -var notARegExp = notARegexp; -var requireObjectCoercible$4 = requireObjectCoercible$h; -var correctIsRegExpLogic = correctIsRegexpLogic; - -var nativeStartsWith = ''.startsWith; -var min$1 = Math.min; - -var CORRECT_IS_REGEXP_LOGIC = correctIsRegExpLogic('startsWith'); -// https://github.com/zloirock/core-js/pull/702 -var MDN_POLYFILL_BUG = !CORRECT_IS_REGEXP_LOGIC && !!function () { - var descriptor = getOwnPropertyDescriptor$3(String.prototype, 'startsWith'); - return descriptor && !descriptor.writable; -}(); - -// `String.prototype.startsWith` method -// https://tc39.es/ecma262/#sec-string.prototype.startswith -$$33({ target: 'String', proto: true, forced: !MDN_POLYFILL_BUG && !CORRECT_IS_REGEXP_LOGIC }, { - startsWith: function startsWith(searchString /* , position = 0 */) { - var that = String(requireObjectCoercible$4(this)); - notARegExp(searchString); - var index = toLength$c(min$1(arguments.length > 1 ? arguments[1] : undefined, that.length)); - var search = String(searchString); - return nativeStartsWith - ? nativeStartsWith.call(that, search, index) - : that.slice(index, index + search.length) === search; - } -}); - -// a string of all valid unicode whitespaces -// eslint-disable-next-line max-len -var whitespaces$4 = '\u0009\u000A\u000B\u000C\u000D\u0020\u00A0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF'; - -var requireObjectCoercible$3 = requireObjectCoercible$h; -var whitespaces$3 = whitespaces$4; - -var whitespace = '[' + whitespaces$3 + ']'; -var ltrim = RegExp('^' + whitespace + whitespace + '*'); -var rtrim = RegExp(whitespace + whitespace + '*$'); - -// `String.prototype.{ trim, trimStart, trimEnd, trimLeft, trimRight }` methods implementation -var createMethod$1 = function (TYPE) { - return function ($this) { - var string = String(requireObjectCoercible$3($this)); - if (TYPE & 1) string = string.replace(ltrim, ''); - if (TYPE & 2) string = string.replace(rtrim, ''); - return string; - }; -}; - -var stringTrim = { - // `String.prototype.{ trimLeft, trimStart }` methods - // https://tc39.es/ecma262/#sec-string.prototype.trimstart - start: createMethod$1(1), - // `String.prototype.{ trimRight, trimEnd }` methods - // https://tc39.es/ecma262/#sec-string.prototype.trimend - end: createMethod$1(2), - // `String.prototype.trim` method - // https://tc39.es/ecma262/#sec-string.prototype.trim - trim: createMethod$1(3) -}; - -var fails$s = fails$Y; -var whitespaces$2 = whitespaces$4; - -var non = '\u200B\u0085\u180E'; - -// check that a method works with the correct list -// of whitespaces and has a correct name -var stringTrimForced = function (METHOD_NAME) { - return fails$s(function () { - return !!whitespaces$2[METHOD_NAME]() || non[METHOD_NAME]() != non || whitespaces$2[METHOD_NAME].name !== METHOD_NAME; - }); -}; - -var $$32 = _export; -var $trim = stringTrim.trim; -var forcedStringTrimMethod$2 = stringTrimForced; - -// `String.prototype.trim` method -// https://tc39.es/ecma262/#sec-string.prototype.trim -$$32({ target: 'String', proto: true, forced: forcedStringTrimMethod$2('trim') }, { - trim: function trim() { - return $trim(this); - } -}); - -var $$31 = _export; -var $trimStart = stringTrim.start; -var forcedStringTrimMethod$1 = stringTrimForced; - -var FORCED$j = forcedStringTrimMethod$1('trimStart'); - -var trimStart = FORCED$j ? function trimStart() { - return $trimStart(this); -} : ''.trimStart; - -// `String.prototype.{ trimStart, trimLeft }` methods -// https://tc39.es/ecma262/#sec-string.prototype.trimstart -// https://tc39.es/ecma262/#String.prototype.trimleft -$$31({ target: 'String', proto: true, forced: FORCED$j }, { - trimStart: trimStart, - trimLeft: trimStart -}); - -var $$30 = _export; -var $trimEnd = stringTrim.end; -var forcedStringTrimMethod = stringTrimForced; - -var FORCED$i = forcedStringTrimMethod('trimEnd'); - -var trimEnd = FORCED$i ? function trimEnd() { - return $trimEnd(this); -} : ''.trimEnd; - -// `String.prototype.{ trimEnd, trimRight }` methods -// https://tc39.es/ecma262/#sec-string.prototype.trimend -// https://tc39.es/ecma262/#String.prototype.trimright -$$30({ target: 'String', proto: true, forced: FORCED$i }, { - trimEnd: trimEnd, - trimRight: trimEnd -}); - -var charAt$2 = stringMultibyte.charAt; -var InternalStateModule$e = internalState; -var defineIterator$1 = defineIterator$3; - -var STRING_ITERATOR$1 = 'String Iterator'; -var setInternalState$f = InternalStateModule$e.set; -var getInternalState$b = InternalStateModule$e.getterFor(STRING_ITERATOR$1); - -// `String.prototype[@@iterator]` method -// https://tc39.es/ecma262/#sec-string.prototype-@@iterator -defineIterator$1(String, 'String', function (iterated) { - setInternalState$f(this, { - type: STRING_ITERATOR$1, - string: String(iterated), - index: 0 - }); -// `%StringIteratorPrototype%.next` method -// https://tc39.es/ecma262/#sec-%stringiteratorprototype%.next -}, function next() { - var state = getInternalState$b(this); - var string = state.string; - var index = state.index; - var point; - if (index >= string.length) return { value: undefined, done: true }; - point = charAt$2(string, index); - state.index += point.length; - return { value: point, done: false }; -}); - -var requireObjectCoercible$2 = requireObjectCoercible$h; - -var quot = /"/g; - -// B.2.3.2.1 CreateHTML(string, tag, attribute, value) -// https://tc39.es/ecma262/#sec-createhtml -var createHtml = function (string, tag, attribute, value) { - var S = String(requireObjectCoercible$2(string)); - var p1 = '<' + tag; - if (attribute !== '') p1 += ' ' + attribute + '="' + String(value).replace(quot, '"') + '"'; - return p1 + '>' + S + ''; -}; - -var fails$r = fails$Y; - -// check the existence of a method, lowercase -// of a tag and escaping quotes in arguments -var stringHtmlForced = function (METHOD_NAME) { - return fails$r(function () { - var test = ''[METHOD_NAME]('"'); - return test !== test.toLowerCase() || test.split('"').length > 3; - }); -}; - -var $$2$ = _export; -var createHTML$c = createHtml; -var forcedStringHTMLMethod$c = stringHtmlForced; - -// `String.prototype.anchor` method -// https://tc39.es/ecma262/#sec-string.prototype.anchor -$$2$({ target: 'String', proto: true, forced: forcedStringHTMLMethod$c('anchor') }, { - anchor: function anchor(name) { - return createHTML$c(this, 'a', 'name', name); - } -}); - -var $$2_ = _export; -var createHTML$b = createHtml; -var forcedStringHTMLMethod$b = stringHtmlForced; - -// `String.prototype.big` method -// https://tc39.es/ecma262/#sec-string.prototype.big -$$2_({ target: 'String', proto: true, forced: forcedStringHTMLMethod$b('big') }, { - big: function big() { - return createHTML$b(this, 'big', '', ''); - } -}); - -var $$2Z = _export; -var createHTML$a = createHtml; -var forcedStringHTMLMethod$a = stringHtmlForced; - -// `String.prototype.blink` method -// https://tc39.es/ecma262/#sec-string.prototype.blink -$$2Z({ target: 'String', proto: true, forced: forcedStringHTMLMethod$a('blink') }, { - blink: function blink() { - return createHTML$a(this, 'blink', '', ''); - } -}); - -var $$2Y = _export; -var createHTML$9 = createHtml; -var forcedStringHTMLMethod$9 = stringHtmlForced; - -// `String.prototype.bold` method -// https://tc39.es/ecma262/#sec-string.prototype.bold -$$2Y({ target: 'String', proto: true, forced: forcedStringHTMLMethod$9('bold') }, { - bold: function bold() { - return createHTML$9(this, 'b', '', ''); - } -}); - -var $$2X = _export; -var createHTML$8 = createHtml; -var forcedStringHTMLMethod$8 = stringHtmlForced; - -// `String.prototype.fixed` method -// https://tc39.es/ecma262/#sec-string.prototype.fixed -$$2X({ target: 'String', proto: true, forced: forcedStringHTMLMethod$8('fixed') }, { - fixed: function fixed() { - return createHTML$8(this, 'tt', '', ''); - } -}); - -var $$2W = _export; -var createHTML$7 = createHtml; -var forcedStringHTMLMethod$7 = stringHtmlForced; - -// `String.prototype.fontcolor` method -// https://tc39.es/ecma262/#sec-string.prototype.fontcolor -$$2W({ target: 'String', proto: true, forced: forcedStringHTMLMethod$7('fontcolor') }, { - fontcolor: function fontcolor(color) { - return createHTML$7(this, 'font', 'color', color); - } -}); - -var $$2V = _export; -var createHTML$6 = createHtml; -var forcedStringHTMLMethod$6 = stringHtmlForced; - -// `String.prototype.fontsize` method -// https://tc39.es/ecma262/#sec-string.prototype.fontsize -$$2V({ target: 'String', proto: true, forced: forcedStringHTMLMethod$6('fontsize') }, { - fontsize: function fontsize(size) { - return createHTML$6(this, 'font', 'size', size); - } -}); - -var $$2U = _export; -var createHTML$5 = createHtml; -var forcedStringHTMLMethod$5 = stringHtmlForced; - -// `String.prototype.italics` method -// https://tc39.es/ecma262/#sec-string.prototype.italics -$$2U({ target: 'String', proto: true, forced: forcedStringHTMLMethod$5('italics') }, { - italics: function italics() { - return createHTML$5(this, 'i', '', ''); - } -}); - -var $$2T = _export; -var createHTML$4 = createHtml; -var forcedStringHTMLMethod$4 = stringHtmlForced; - -// `String.prototype.link` method -// https://tc39.es/ecma262/#sec-string.prototype.link -$$2T({ target: 'String', proto: true, forced: forcedStringHTMLMethod$4('link') }, { - link: function link(url) { - return createHTML$4(this, 'a', 'href', url); - } -}); - -var $$2S = _export; -var createHTML$3 = createHtml; -var forcedStringHTMLMethod$3 = stringHtmlForced; - -// `String.prototype.small` method -// https://tc39.es/ecma262/#sec-string.prototype.small -$$2S({ target: 'String', proto: true, forced: forcedStringHTMLMethod$3('small') }, { - small: function small() { - return createHTML$3(this, 'small', '', ''); - } -}); - -var $$2R = _export; -var createHTML$2 = createHtml; -var forcedStringHTMLMethod$2 = stringHtmlForced; - -// `String.prototype.strike` method -// https://tc39.es/ecma262/#sec-string.prototype.strike -$$2R({ target: 'String', proto: true, forced: forcedStringHTMLMethod$2('strike') }, { - strike: function strike() { - return createHTML$2(this, 'strike', '', ''); - } -}); - -var $$2Q = _export; -var createHTML$1 = createHtml; -var forcedStringHTMLMethod$1 = stringHtmlForced; - -// `String.prototype.sub` method -// https://tc39.es/ecma262/#sec-string.prototype.sub -$$2Q({ target: 'String', proto: true, forced: forcedStringHTMLMethod$1('sub') }, { - sub: function sub() { - return createHTML$1(this, 'sub', '', ''); - } -}); - -var $$2P = _export; -var createHTML = createHtml; -var forcedStringHTMLMethod = stringHtmlForced; - -// `String.prototype.sup` method -// https://tc39.es/ecma262/#sec-string.prototype.sup -$$2P({ target: 'String', proto: true, forced: forcedStringHTMLMethod('sup') }, { - sup: function sup() { - return createHTML(this, 'sup', '', ''); - } -}); - -var $$2O = _export; -var requireObjectCoercible$1 = requireObjectCoercible$h; -var isRegExp$1 = isRegexp; -var getRegExpFlags = regexpFlags$1; -var getSubstitution = getSubstitution$2; -var wellKnownSymbol$f = wellKnownSymbol$C; - -var REPLACE = wellKnownSymbol$f('replace'); -var RegExpPrototype$3 = RegExp.prototype; -var max$1 = Math.max; - -var stringIndexOf = function (string, searchValue, fromIndex) { - if (fromIndex > string.length) return -1; - if (searchValue === '') return fromIndex; - return string.indexOf(searchValue, fromIndex); -}; - -// `String.prototype.replaceAll` method -// https://tc39.es/ecma262/#sec-string.prototype.replaceall -$$2O({ target: 'String', proto: true }, { - replaceAll: function replaceAll(searchValue, replaceValue) { - var O = requireObjectCoercible$1(this); - var IS_REG_EXP, flags, replacer, string, searchString, functionalReplace, searchLength, advanceBy, replacement; - var position = 0; - var endOfLastMatch = 0; - var result = ''; - if (searchValue != null) { - IS_REG_EXP = isRegExp$1(searchValue); - if (IS_REG_EXP) { - flags = String(requireObjectCoercible$1('flags' in RegExpPrototype$3 - ? searchValue.flags - : getRegExpFlags.call(searchValue) - )); - if (!~flags.indexOf('g')) throw TypeError('`.replaceAll` does not allow non-global regexes'); - } - replacer = searchValue[REPLACE]; - if (replacer !== undefined) { - return replacer.call(searchValue, O, replaceValue); - } - } - string = String(O); - searchString = String(searchValue); - functionalReplace = typeof replaceValue === 'function'; - if (!functionalReplace) replaceValue = String(replaceValue); - searchLength = searchString.length; - advanceBy = max$1(1, searchLength); - position = stringIndexOf(string, searchString, 0); - while (position !== -1) { - if (functionalReplace) { - replacement = String(replaceValue(searchString, position, string)); - } else { - replacement = getSubstitution(searchString, string, position, [], undefined, replaceValue); - } - result += string.slice(endOfLastMatch, position) + replacement; - endOfLastMatch = position + searchLength; - position = stringIndexOf(string, searchString, position + advanceBy); - } - if (endOfLastMatch < string.length) { - result += string.slice(endOfLastMatch); - } - return result; - } -}); - -var isObject$g = isObject$B; -var setPrototypeOf$3 = objectSetPrototypeOf$1; - -// makes subclassing work correct for wrapped built-ins -var inheritIfRequired$4 = function ($this, dummy, Wrapper) { - var NewTarget, NewTargetPrototype; - if ( - // it can work only with native `setPrototypeOf` - setPrototypeOf$3 && - // we haven't completely correct pre-ES6 way for getting `new.target`, so use this - typeof (NewTarget = dummy.constructor) == 'function' && - NewTarget !== Wrapper && - isObject$g(NewTargetPrototype = NewTarget.prototype) && - NewTargetPrototype !== Wrapper.prototype - ) setPrototypeOf$3($this, NewTargetPrototype); - return $this; -}; - -var DESCRIPTORS$e = descriptors; -var global$u = global$L; -var isForced$3 = isForced_1; -var inheritIfRequired$3 = inheritIfRequired$4; -var defineProperty$8 = objectDefineProperty.f; -var getOwnPropertyNames$3 = objectGetOwnPropertyNames.f; -var isRegExp = isRegexp; -var getFlags = regexpFlags$1; -var stickyHelpers = regexpStickyHelpers; -var redefine$a = redefine$g.exports; -var fails$q = fails$Y; -var setInternalState$e = internalState.set; -var setSpecies$5 = setSpecies$7; -var wellKnownSymbol$e = wellKnownSymbol$C; - -var MATCH = wellKnownSymbol$e('match'); -var NativeRegExp = global$u.RegExp; -var RegExpPrototype$2 = NativeRegExp.prototype; -var re1 = /a/g; -var re2 = /a/g; - -// "new" should create a new object, old webkit bug -var CORRECT_NEW = new NativeRegExp(re1) !== re1; - -var UNSUPPORTED_Y$2 = stickyHelpers.UNSUPPORTED_Y; - -var FORCED$h = DESCRIPTORS$e && isForced$3('RegExp', (!CORRECT_NEW || UNSUPPORTED_Y$2 || fails$q(function () { - re2[MATCH] = false; - // RegExp constructor can alter flags and IsRegExp works correct with @@match - return NativeRegExp(re1) != re1 || NativeRegExp(re2) == re2 || NativeRegExp(re1, 'i') != '/a/i'; -}))); - -// `RegExp` constructor -// https://tc39.es/ecma262/#sec-regexp-constructor -if (FORCED$h) { - var RegExpWrapper = function RegExp(pattern, flags) { - var thisIsRegExp = this instanceof RegExpWrapper; - var patternIsRegExp = isRegExp(pattern); - var flagsAreUndefined = flags === undefined; - var sticky; - - if (!thisIsRegExp && patternIsRegExp && pattern.constructor === RegExpWrapper && flagsAreUndefined) { - return pattern; - } - - if (CORRECT_NEW) { - if (patternIsRegExp && !flagsAreUndefined) pattern = pattern.source; - } else if (pattern instanceof RegExpWrapper) { - if (flagsAreUndefined) flags = getFlags.call(pattern); - pattern = pattern.source; - } - - if (UNSUPPORTED_Y$2) { - sticky = !!flags && flags.indexOf('y') > -1; - if (sticky) flags = flags.replace(/y/g, ''); - } - - var result = inheritIfRequired$3( - CORRECT_NEW ? new NativeRegExp(pattern, flags) : NativeRegExp(pattern, flags), - thisIsRegExp ? this : RegExpPrototype$2, - RegExpWrapper - ); - - if (UNSUPPORTED_Y$2 && sticky) setInternalState$e(result, { sticky: sticky }); - - return result; - }; - var proxy = function (key) { - key in RegExpWrapper || defineProperty$8(RegExpWrapper, key, { - configurable: true, - get: function () { return NativeRegExp[key]; }, - set: function (it) { NativeRegExp[key] = it; } - }); - }; - var keys$2 = getOwnPropertyNames$3(NativeRegExp); - var index = 0; - while (keys$2.length > index) proxy(keys$2[index++]); - RegExpPrototype$2.constructor = RegExpWrapper; - RegExpWrapper.prototype = RegExpPrototype$2; - redefine$a(global$u, 'RegExp', RegExpWrapper); -} - -// https://tc39.es/ecma262/#sec-get-regexp-@@species -setSpecies$5('RegExp'); - -var DESCRIPTORS$d = descriptors; -var objectDefinePropertyModule = objectDefineProperty; -var regExpFlags = regexpFlags$1; -var UNSUPPORTED_Y$1 = regexpStickyHelpers.UNSUPPORTED_Y; - -// `RegExp.prototype.flags` getter -// https://tc39.es/ecma262/#sec-get-regexp.prototype.flags -if (DESCRIPTORS$d && (/./g.flags != 'g' || UNSUPPORTED_Y$1)) { - objectDefinePropertyModule.f(RegExp.prototype, 'flags', { - configurable: true, - get: regExpFlags - }); -} - -var DESCRIPTORS$c = descriptors; -var UNSUPPORTED_Y = regexpStickyHelpers.UNSUPPORTED_Y; -var defineProperty$7 = objectDefineProperty.f; -var getInternalState$a = internalState.get; -var RegExpPrototype$1 = RegExp.prototype; - -// `RegExp.prototype.sticky` getter -// https://tc39.es/ecma262/#sec-get-regexp.prototype.sticky -if (DESCRIPTORS$c && UNSUPPORTED_Y) { - defineProperty$7(RegExp.prototype, 'sticky', { - configurable: true, - get: function () { - if (this === RegExpPrototype$1) return undefined; - // We can't use InternalStateModule.getterFor because - // we don't add metadata for regexps created by a literal. - if (this instanceof RegExp) { - return !!getInternalState$a(this).sticky; - } - throw TypeError('Incompatible receiver, RegExp required'); - } - }); -} - -// TODO: Remove from `core-js@4` since it's moved to entry points - -var $$2N = _export; -var isObject$f = isObject$B; - -var DELEGATES_TO_EXEC = function () { - var execCalled = false; - var re = /[ac]/; - re.exec = function () { - execCalled = true; - return /./.exec.apply(this, arguments); - }; - return re.test('abc') === true && execCalled; -}(); - -var nativeTest = /./.test; - -// `RegExp.prototype.test` method -// https://tc39.es/ecma262/#sec-regexp.prototype.test -$$2N({ target: 'RegExp', proto: true, forced: !DELEGATES_TO_EXEC }, { - test: function (str) { - if (typeof this.exec !== 'function') { - return nativeTest.call(this, str); - } - var result = this.exec(str); - if (result !== null && !isObject$f(result)) { - throw new Error('RegExp exec method returned something other than an Object or null'); - } - return !!result; - } -}); - -var redefine$9 = redefine$g.exports; -var anObject$1i = anObject$1z; -var fails$p = fails$Y; -var flags = regexpFlags$1; - -var TO_STRING$1 = 'toString'; -var RegExpPrototype = RegExp.prototype; -var nativeToString = RegExpPrototype[TO_STRING$1]; - -var NOT_GENERIC = fails$p(function () { return nativeToString.call({ source: 'a', flags: 'b' }) != '/a/b'; }); -// FF44- RegExp#toString has a wrong name -var INCORRECT_NAME = nativeToString.name != TO_STRING$1; - -// `RegExp.prototype.toString` method -// https://tc39.es/ecma262/#sec-regexp.prototype.tostring -if (NOT_GENERIC || INCORRECT_NAME) { - redefine$9(RegExp.prototype, TO_STRING$1, function toString() { - var R = anObject$1i(this); - var p = String(R.source); - var rf = R.flags; - var f = String(rf === undefined && R instanceof RegExp && !('flags' in RegExpPrototype) ? flags.call(R) : rf); - return '/' + p + '/' + f; - }, { unsafe: true }); -} - -var global$t = global$L; -var trim$2 = stringTrim.trim; -var whitespaces$1 = whitespaces$4; - -var $parseInt = global$t.parseInt; -var hex = /^[+-]?0[Xx]/; -var FORCED$g = $parseInt(whitespaces$1 + '08') !== 8 || $parseInt(whitespaces$1 + '0x16') !== 22; - -// `parseInt` method -// https://tc39.es/ecma262/#sec-parseint-string-radix -var numberParseInt = FORCED$g ? function parseInt(string, radix) { - var S = trim$2(String(string)); - return $parseInt(S, (radix >>> 0) || (hex.test(S) ? 16 : 10)); -} : $parseInt; - -var $$2M = _export; -var parseIntImplementation = numberParseInt; - -// `parseInt` method -// https://tc39.es/ecma262/#sec-parseint-string-radix -$$2M({ global: true, forced: parseInt != parseIntImplementation }, { - parseInt: parseIntImplementation -}); - -var global$s = global$L; -var trim$1 = stringTrim.trim; -var whitespaces = whitespaces$4; - -var $parseFloat = global$s.parseFloat; -var FORCED$f = 1 / $parseFloat(whitespaces + '-0') !== -Infinity; - -// `parseFloat` method -// https://tc39.es/ecma262/#sec-parsefloat-string -var numberParseFloat = FORCED$f ? function parseFloat(string) { - var trimmedString = trim$1(String(string)); - var result = $parseFloat(trimmedString); - return result === 0 && trimmedString.charAt(0) == '-' ? -0 : result; -} : $parseFloat; - -var $$2L = _export; -var parseFloatImplementation = numberParseFloat; - -// `parseFloat` method -// https://tc39.es/ecma262/#sec-parsefloat-string -$$2L({ global: true, forced: parseFloat != parseFloatImplementation }, { - parseFloat: parseFloatImplementation -}); - -var DESCRIPTORS$b = descriptors; -var global$r = global$L; -var isForced$2 = isForced_1; -var redefine$8 = redefine$g.exports; -var has$9 = has$o; -var classof$4 = classofRaw$1; -var inheritIfRequired$2 = inheritIfRequired$4; -var toPrimitive$4 = toPrimitive$b; -var fails$o = fails$Y; -var create$8 = objectCreate; -var getOwnPropertyNames$2 = objectGetOwnPropertyNames.f; -var getOwnPropertyDescriptor$2 = objectGetOwnPropertyDescriptor.f; -var defineProperty$6 = objectDefineProperty.f; -var trim = stringTrim.trim; - -var NUMBER = 'Number'; -var NativeNumber = global$r[NUMBER]; -var NumberPrototype = NativeNumber.prototype; - -// Opera ~12 has broken Object#toString -var BROKEN_CLASSOF = classof$4(create$8(NumberPrototype)) == NUMBER; - -// `ToNumber` abstract operation -// https://tc39.es/ecma262/#sec-tonumber -var toNumber = function (argument) { - var it = toPrimitive$4(argument, false); - var first, third, radix, maxCode, digits, length, index, code; - if (typeof it == 'string' && it.length > 2) { - it = trim(it); - first = it.charCodeAt(0); - if (first === 43 || first === 45) { - third = it.charCodeAt(2); - if (third === 88 || third === 120) return NaN; // Number('+0x1') should be NaN, old V8 fix - } else if (first === 48) { - switch (it.charCodeAt(1)) { - case 66: case 98: radix = 2; maxCode = 49; break; // fast equal of /^0b[01]+$/i - case 79: case 111: radix = 8; maxCode = 55; break; // fast equal of /^0o[0-7]+$/i - default: return +it; - } - digits = it.slice(2); - length = digits.length; - for (index = 0; index < length; index++) { - code = digits.charCodeAt(index); - // parseInt parses a string to a first unavailable symbol - // but ToNumber should return NaN if a string contains unavailable symbols - if (code < 48 || code > maxCode) return NaN; - } return parseInt(digits, radix); - } - } return +it; -}; - -// `Number` constructor -// https://tc39.es/ecma262/#sec-number-constructor -if (isForced$2(NUMBER, !NativeNumber(' 0o1') || !NativeNumber('0b1') || NativeNumber('+0x1'))) { - var NumberWrapper = function Number(value) { - var it = arguments.length < 1 ? 0 : value; - var dummy = this; - return dummy instanceof NumberWrapper - // check on 1..constructor(foo) case - && (BROKEN_CLASSOF ? fails$o(function () { NumberPrototype.valueOf.call(dummy); }) : classof$4(dummy) != NUMBER) - ? inheritIfRequired$2(new NativeNumber(toNumber(it)), dummy, NumberWrapper) : toNumber(it); - }; - for (var keys$1 = DESCRIPTORS$b ? getOwnPropertyNames$2(NativeNumber) : ( - // ES3: - 'MAX_VALUE,MIN_VALUE,NaN,NEGATIVE_INFINITY,POSITIVE_INFINITY,' + - // ES2015 (in case, if modules with ES2015 Number statics required before): - 'EPSILON,isFinite,isInteger,isNaN,isSafeInteger,MAX_SAFE_INTEGER,' + - 'MIN_SAFE_INTEGER,parseFloat,parseInt,isInteger,' + - // ESNext - 'fromString,range' - ).split(','), j$1 = 0, key$1; keys$1.length > j$1; j$1++) { - if (has$9(NativeNumber, key$1 = keys$1[j$1]) && !has$9(NumberWrapper, key$1)) { - defineProperty$6(NumberWrapper, key$1, getOwnPropertyDescriptor$2(NativeNumber, key$1)); - } - } - NumberWrapper.prototype = NumberPrototype; - NumberPrototype.constructor = NumberWrapper; - redefine$8(global$r, NUMBER, NumberWrapper); -} - -var $$2K = _export; - -// `Number.EPSILON` constant -// https://tc39.es/ecma262/#sec-number.epsilon -$$2K({ target: 'Number', stat: true }, { - EPSILON: Math.pow(2, -52) -}); - -var global$q = global$L; - -var globalIsFinite = global$q.isFinite; - -// `Number.isFinite` method -// https://tc39.es/ecma262/#sec-number.isfinite -var numberIsFinite$2 = Number.isFinite || function isFinite(it) { - return typeof it == 'number' && globalIsFinite(it); -}; - -var $$2J = _export; -var numberIsFinite$1 = numberIsFinite$2; - -// `Number.isFinite` method -// https://tc39.es/ecma262/#sec-number.isfinite -$$2J({ target: 'Number', stat: true }, { isFinite: numberIsFinite$1 }); - -var isObject$e = isObject$B; - -var floor$7 = Math.floor; - -// `Number.isInteger` method implementation -// https://tc39.es/ecma262/#sec-number.isinteger -var isInteger$2 = function isInteger(it) { - return !isObject$e(it) && isFinite(it) && floor$7(it) === it; -}; - -var $$2I = _export; -var isInteger$1 = isInteger$2; - -// `Number.isInteger` method -// https://tc39.es/ecma262/#sec-number.isinteger -$$2I({ target: 'Number', stat: true }, { - isInteger: isInteger$1 -}); - -var $$2H = _export; - -// `Number.isNaN` method -// https://tc39.es/ecma262/#sec-number.isnan -$$2H({ target: 'Number', stat: true }, { - isNaN: function isNaN(number) { - // eslint-disable-next-line no-self-compare - return number != number; - } -}); - -var $$2G = _export; -var isInteger = isInteger$2; - -var abs$7 = Math.abs; - -// `Number.isSafeInteger` method -// https://tc39.es/ecma262/#sec-number.issafeinteger -$$2G({ target: 'Number', stat: true }, { - isSafeInteger: function isSafeInteger(number) { - return isInteger(number) && abs$7(number) <= 0x1FFFFFFFFFFFFF; - } -}); - -var $$2F = _export; - -// `Number.MAX_SAFE_INTEGER` constant -// https://tc39.es/ecma262/#sec-number.max_safe_integer -$$2F({ target: 'Number', stat: true }, { - MAX_SAFE_INTEGER: 0x1FFFFFFFFFFFFF -}); - -var $$2E = _export; - -// `Number.MIN_SAFE_INTEGER` constant -// https://tc39.es/ecma262/#sec-number.min_safe_integer -$$2E({ target: 'Number', stat: true }, { - MIN_SAFE_INTEGER: -0x1FFFFFFFFFFFFF -}); - -var $$2D = _export; -var parseFloat$1 = numberParseFloat; - -// `Number.parseFloat` method -// https://tc39.es/ecma262/#sec-number.parseFloat -$$2D({ target: 'Number', stat: true, forced: Number.parseFloat != parseFloat$1 }, { - parseFloat: parseFloat$1 -}); - -var $$2C = _export; -var parseInt$2 = numberParseInt; - -// `Number.parseInt` method -// https://tc39.es/ecma262/#sec-number.parseint -$$2C({ target: 'Number', stat: true, forced: Number.parseInt != parseInt$2 }, { - parseInt: parseInt$2 -}); - -var classof$3 = classofRaw$1; - -// `thisNumberValue` abstract operation -// https://tc39.es/ecma262/#sec-thisnumbervalue -var thisNumberValue$2 = function (value) { - if (typeof value != 'number' && classof$3(value) != 'Number') { - throw TypeError('Incorrect invocation'); - } - return +value; -}; - -var $$2B = _export; -var toInteger$6 = toInteger$f; -var thisNumberValue$1 = thisNumberValue$2; -var repeat = stringRepeat; -var fails$n = fails$Y; - -var nativeToFixed = 1.0.toFixed; -var floor$6 = Math.floor; - -var pow$4 = function (x, n, acc) { - return n === 0 ? acc : n % 2 === 1 ? pow$4(x, n - 1, acc * x) : pow$4(x * x, n / 2, acc); -}; - -var log$8 = function (x) { - var n = 0; - var x2 = x; - while (x2 >= 4096) { - n += 12; - x2 /= 4096; - } - while (x2 >= 2) { - n += 1; - x2 /= 2; - } return n; -}; - -var FORCED$e = nativeToFixed && ( - 0.00008.toFixed(3) !== '0.000' || - 0.9.toFixed(0) !== '1' || - 1.255.toFixed(2) !== '1.25' || - 1000000000000000128.0.toFixed(0) !== '1000000000000000128' -) || !fails$n(function () { - // V8 ~ Android 4.3- - nativeToFixed.call({}); -}); - -// `Number.prototype.toFixed` method -// https://tc39.es/ecma262/#sec-number.prototype.tofixed -$$2B({ target: 'Number', proto: true, forced: FORCED$e }, { - // eslint-disable-next-line max-statements - toFixed: function toFixed(fractionDigits) { - var number = thisNumberValue$1(this); - var fractDigits = toInteger$6(fractionDigits); - var data = [0, 0, 0, 0, 0, 0]; - var sign = ''; - var result = '0'; - var e, z, j, k; - - var multiply = function (n, c) { - var index = -1; - var c2 = c; - while (++index < 6) { - c2 += n * data[index]; - data[index] = c2 % 1e7; - c2 = floor$6(c2 / 1e7); - } - }; - - var divide = function (n) { - var index = 6; - var c = 0; - while (--index >= 0) { - c += data[index]; - data[index] = floor$6(c / n); - c = (c % n) * 1e7; - } - }; - - var dataToString = function () { - var index = 6; - var s = ''; - while (--index >= 0) { - if (s !== '' || index === 0 || data[index] !== 0) { - var t = String(data[index]); - s = s === '' ? t : s + repeat.call('0', 7 - t.length) + t; - } - } return s; - }; - - if (fractDigits < 0 || fractDigits > 20) throw RangeError('Incorrect fraction digits'); - // eslint-disable-next-line no-self-compare - if (number != number) return 'NaN'; - if (number <= -1e21 || number >= 1e21) return String(number); - if (number < 0) { - sign = '-'; - number = -number; - } - if (number > 1e-21) { - e = log$8(number * pow$4(2, 69, 1)) - 69; - z = e < 0 ? number * pow$4(2, -e, 1) : number / pow$4(2, e, 1); - z *= 0x10000000000000; - e = 52 - e; - if (e > 0) { - multiply(0, z); - j = fractDigits; - while (j >= 7) { - multiply(1e7, 0); - j -= 7; - } - multiply(pow$4(10, j, 1), 0); - j = e - 1; - while (j >= 23) { - divide(1 << 23); - j -= 23; - } - divide(1 << j); - multiply(1, 1); - divide(2); - result = dataToString(); - } else { - multiply(0, z); - multiply(1 << -e, 0); - result = dataToString() + repeat.call('0', fractDigits); - } - } - if (fractDigits > 0) { - k = result.length; - result = sign + (k <= fractDigits - ? '0.' + repeat.call('0', fractDigits - k) + result - : result.slice(0, k - fractDigits) + '.' + result.slice(k - fractDigits)); - } else { - result = sign + result; - } return result; - } -}); - -var $$2A = _export; -var fails$m = fails$Y; -var thisNumberValue = thisNumberValue$2; - -var nativeToPrecision = 1.0.toPrecision; - -var FORCED$d = fails$m(function () { - // IE7- - return nativeToPrecision.call(1, undefined) !== '1'; -}) || !fails$m(function () { - // V8 ~ Android 4.3- - nativeToPrecision.call({}); -}); - -// `Number.prototype.toPrecision` method -// https://tc39.es/ecma262/#sec-number.prototype.toprecision -$$2A({ target: 'Number', proto: true, forced: FORCED$d }, { - toPrecision: function toPrecision(precision) { - return precision === undefined - ? nativeToPrecision.call(thisNumberValue(this)) - : nativeToPrecision.call(thisNumberValue(this), precision); - } -}); - -var log$7 = Math.log; - -// `Math.log1p` method implementation -// https://tc39.es/ecma262/#sec-math.log1p -var mathLog1p = Math.log1p || function log1p(x) { - return (x = +x) > -1e-8 && x < 1e-8 ? x - x * x / 2 : log$7(1 + x); -}; - -var $$2z = _export; -var log1p$1 = mathLog1p; - -var nativeAcosh = Math.acosh; -var log$6 = Math.log; -var sqrt$2 = Math.sqrt; -var LN2$2 = Math.LN2; - -var FORCED$c = !nativeAcosh - // V8 bug: https://code.google.com/p/v8/issues/detail?id=3509 - || Math.floor(nativeAcosh(Number.MAX_VALUE)) != 710 - // Tor Browser bug: Math.acosh(Infinity) -> NaN - || nativeAcosh(Infinity) != Infinity; - -// `Math.acosh` method -// https://tc39.es/ecma262/#sec-math.acosh -$$2z({ target: 'Math', stat: true, forced: FORCED$c }, { - acosh: function acosh(x) { - return (x = +x) < 1 ? NaN : x > 94906265.62425156 - ? log$6(x) + LN2$2 - : log1p$1(x - 1 + sqrt$2(x - 1) * sqrt$2(x + 1)); - } -}); - -var $$2y = _export; - -var nativeAsinh = Math.asinh; -var log$5 = Math.log; -var sqrt$1 = Math.sqrt; - -function asinh(x) { - return !isFinite(x = +x) || x == 0 ? x : x < 0 ? -asinh(-x) : log$5(x + sqrt$1(x * x + 1)); -} - -// `Math.asinh` method -// https://tc39.es/ecma262/#sec-math.asinh -// Tor Browser bug: Math.asinh(0) -> -0 -$$2y({ target: 'Math', stat: true, forced: !(nativeAsinh && 1 / nativeAsinh(0) > 0) }, { - asinh: asinh -}); - -var $$2x = _export; - -var nativeAtanh = Math.atanh; -var log$4 = Math.log; - -// `Math.atanh` method -// https://tc39.es/ecma262/#sec-math.atanh -// Tor Browser bug: Math.atanh(-0) -> 0 -$$2x({ target: 'Math', stat: true, forced: !(nativeAtanh && 1 / nativeAtanh(-0) < 0) }, { - atanh: function atanh(x) { - return (x = +x) == 0 ? x : log$4((1 + x) / (1 - x)) / 2; - } -}); - -// `Math.sign` method implementation -// https://tc39.es/ecma262/#sec-math.sign -var mathSign = Math.sign || function sign(x) { - // eslint-disable-next-line no-self-compare - return (x = +x) == 0 || x != x ? x : x < 0 ? -1 : 1; -}; - -var $$2w = _export; -var sign$2 = mathSign; - -var abs$6 = Math.abs; -var pow$3 = Math.pow; - -// `Math.cbrt` method -// https://tc39.es/ecma262/#sec-math.cbrt -$$2w({ target: 'Math', stat: true }, { - cbrt: function cbrt(x) { - return sign$2(x = +x) * pow$3(abs$6(x), 1 / 3); - } -}); - -var $$2v = _export; - -var floor$5 = Math.floor; -var log$3 = Math.log; -var LOG2E = Math.LOG2E; - -// `Math.clz32` method -// https://tc39.es/ecma262/#sec-math.clz32 -$$2v({ target: 'Math', stat: true }, { - clz32: function clz32(x) { - return (x >>>= 0) ? 31 - floor$5(log$3(x + 0.5) * LOG2E) : 32; - } -}); - -var nativeExpm1 = Math.expm1; -var exp$2 = Math.exp; - -// `Math.expm1` method implementation -// https://tc39.es/ecma262/#sec-math.expm1 -var mathExpm1 = (!nativeExpm1 - // Old FF bug - || nativeExpm1(10) > 22025.465794806719 || nativeExpm1(10) < 22025.4657948067165168 - // Tor Browser bug - || nativeExpm1(-2e-17) != -2e-17 -) ? function expm1(x) { - return (x = +x) == 0 ? x : x > -1e-6 && x < 1e-6 ? x + x * x / 2 : exp$2(x) - 1; -} : nativeExpm1; - -var $$2u = _export; -var expm1$3 = mathExpm1; - -var nativeCosh = Math.cosh; -var abs$5 = Math.abs; -var E$1 = Math.E; - -// `Math.cosh` method -// https://tc39.es/ecma262/#sec-math.cosh -$$2u({ target: 'Math', stat: true, forced: !nativeCosh || nativeCosh(710) === Infinity }, { - cosh: function cosh(x) { - var t = expm1$3(abs$5(x) - 1) + 1; - return (t + 1 / (t * E$1 * E$1)) * (E$1 / 2); - } -}); - -var $$2t = _export; -var expm1$2 = mathExpm1; - -// `Math.expm1` method -// https://tc39.es/ecma262/#sec-math.expm1 -$$2t({ target: 'Math', stat: true, forced: expm1$2 != Math.expm1 }, { expm1: expm1$2 }); - -var sign$1 = mathSign; - -var abs$4 = Math.abs; -var pow$2 = Math.pow; -var EPSILON = pow$2(2, -52); -var EPSILON32 = pow$2(2, -23); -var MAX32 = pow$2(2, 127) * (2 - EPSILON32); -var MIN32 = pow$2(2, -126); - -var roundTiesToEven = function (n) { - return n + 1 / EPSILON - 1 / EPSILON; -}; - -// `Math.fround` method implementation -// https://tc39.es/ecma262/#sec-math.fround -var mathFround = Math.fround || function fround(x) { - var $abs = abs$4(x); - var $sign = sign$1(x); - var a, result; - if ($abs < MIN32) return $sign * roundTiesToEven($abs / MIN32 / EPSILON32) * MIN32 * EPSILON32; - a = (1 + EPSILON32 / EPSILON) * $abs; - result = a - (a - $abs); - // eslint-disable-next-line no-self-compare - if (result > MAX32 || result != result) return $sign * Infinity; - return $sign * result; -}; - -var $$2s = _export; -var fround$1 = mathFround; - -// `Math.fround` method -// https://tc39.es/ecma262/#sec-math.fround -$$2s({ target: 'Math', stat: true }, { fround: fround$1 }); - -var $$2r = _export; - -var $hypot = Math.hypot; -var abs$3 = Math.abs; -var sqrt = Math.sqrt; - -// Chrome 77 bug -// https://bugs.chromium.org/p/v8/issues/detail?id=9546 -var BUGGY = !!$hypot && $hypot(Infinity, NaN) !== Infinity; - -// `Math.hypot` method -// https://tc39.es/ecma262/#sec-math.hypot -$$2r({ target: 'Math', stat: true, forced: BUGGY }, { - hypot: function hypot(value1, value2) { // eslint-disable-line no-unused-vars - var sum = 0; - var i = 0; - var aLen = arguments.length; - var larg = 0; - var arg, div; - while (i < aLen) { - arg = abs$3(arguments[i++]); - if (larg < arg) { - div = larg / arg; - sum = sum * div * div + 1; - larg = arg; - } else if (arg > 0) { - div = arg / larg; - sum += div * div; - } else sum += arg; - } - return larg === Infinity ? Infinity : larg * sqrt(sum); - } -}); - -var $$2q = _export; -var fails$l = fails$Y; - -var nativeImul = Math.imul; - -var FORCED$b = fails$l(function () { - return nativeImul(0xFFFFFFFF, 5) != -5 || nativeImul.length != 2; -}); - -// `Math.imul` method -// https://tc39.es/ecma262/#sec-math.imul -// some WebKit versions fails with big numbers, some has wrong arity -$$2q({ target: 'Math', stat: true, forced: FORCED$b }, { - imul: function imul(x, y) { - var UINT16 = 0xFFFF; - var xn = +x; - var yn = +y; - var xl = UINT16 & xn; - var yl = UINT16 & yn; - return 0 | xl * yl + ((UINT16 & xn >>> 16) * yl + xl * (UINT16 & yn >>> 16) << 16 >>> 0); - } -}); - -var $$2p = _export; - -var log$2 = Math.log; -var LOG10E = Math.LOG10E; - -// `Math.log10` method -// https://tc39.es/ecma262/#sec-math.log10 -$$2p({ target: 'Math', stat: true }, { - log10: function log10(x) { - return log$2(x) * LOG10E; - } -}); - -var $$2o = _export; -var log1p = mathLog1p; - -// `Math.log1p` method -// https://tc39.es/ecma262/#sec-math.log1p -$$2o({ target: 'Math', stat: true }, { log1p: log1p }); - -var $$2n = _export; - -var log$1 = Math.log; -var LN2$1 = Math.LN2; - -// `Math.log2` method -// https://tc39.es/ecma262/#sec-math.log2 -$$2n({ target: 'Math', stat: true }, { - log2: function log2(x) { - return log$1(x) / LN2$1; - } -}); - -var $$2m = _export; -var sign = mathSign; - -// `Math.sign` method -// https://tc39.es/ecma262/#sec-math.sign -$$2m({ target: 'Math', stat: true }, { - sign: sign -}); - -var $$2l = _export; -var fails$k = fails$Y; -var expm1$1 = mathExpm1; - -var abs$2 = Math.abs; -var exp$1 = Math.exp; -var E = Math.E; - -var FORCED$a = fails$k(function () { - return Math.sinh(-2e-17) != -2e-17; -}); - -// `Math.sinh` method -// https://tc39.es/ecma262/#sec-math.sinh -// V8 near Chromium 38 has a problem with very small numbers -$$2l({ target: 'Math', stat: true, forced: FORCED$a }, { - sinh: function sinh(x) { - return abs$2(x = +x) < 1 ? (expm1$1(x) - expm1$1(-x)) / 2 : (exp$1(x - 1) - exp$1(-x - 1)) * (E / 2); - } -}); - -var $$2k = _export; -var expm1 = mathExpm1; - -var exp = Math.exp; - -// `Math.tanh` method -// https://tc39.es/ecma262/#sec-math.tanh -$$2k({ target: 'Math', stat: true }, { - tanh: function tanh(x) { - var a = expm1(x = +x); - var b = expm1(-x); - return a == Infinity ? 1 : b == Infinity ? -1 : (a - b) / (exp(x) + exp(-x)); - } -}); - -var setToStringTag$7 = setToStringTag$b; - -// Math[@@toStringTag] property -// https://tc39.es/ecma262/#sec-math-@@tostringtag -setToStringTag$7(Math, 'Math', true); - -var $$2j = _export; - -var ceil = Math.ceil; -var floor$4 = Math.floor; - -// `Math.trunc` method -// https://tc39.es/ecma262/#sec-math.trunc -$$2j({ target: 'Math', stat: true }, { - trunc: function trunc(it) { - return (it > 0 ? floor$4 : ceil)(it); - } -}); - -var $$2i = _export; - -// `Date.now` method -// https://tc39.es/ecma262/#sec-date.now -$$2i({ target: 'Date', stat: true }, { - now: function now() { - return new Date().getTime(); - } -}); - -var $$2h = _export; -var fails$j = fails$Y; -var toObject$9 = toObject$u; -var toPrimitive$3 = toPrimitive$b; - -var FORCED$9 = fails$j(function () { - return new Date(NaN).toJSON() !== null - || Date.prototype.toJSON.call({ toISOString: function () { return 1; } }) !== 1; -}); - -// `Date.prototype.toJSON` method -// https://tc39.es/ecma262/#sec-date.prototype.tojson -$$2h({ target: 'Date', proto: true, forced: FORCED$9 }, { - // eslint-disable-next-line no-unused-vars - toJSON: function toJSON(key) { - var O = toObject$9(this); - var pv = toPrimitive$3(O); - return typeof pv == 'number' && !isFinite(pv) ? null : O.toISOString(); - } -}); - -var fails$i = fails$Y; -var padStart = stringPad.start; - -var abs$1 = Math.abs; -var DatePrototype$2 = Date.prototype; -var getTime$1 = DatePrototype$2.getTime; -var nativeDateToISOString = DatePrototype$2.toISOString; - -// `Date.prototype.toISOString` method implementation -// https://tc39.es/ecma262/#sec-date.prototype.toisostring -// PhantomJS / old WebKit fails here: -var dateToIsoString = (fails$i(function () { - return nativeDateToISOString.call(new Date(-5e13 - 1)) != '0385-07-25T07:06:39.999Z'; -}) || !fails$i(function () { - nativeDateToISOString.call(new Date(NaN)); -})) ? function toISOString() { - if (!isFinite(getTime$1.call(this))) throw RangeError('Invalid time value'); - var date = this; - var year = date.getUTCFullYear(); - var milliseconds = date.getUTCMilliseconds(); - var sign = year < 0 ? '-' : year > 9999 ? '+' : ''; - return sign + padStart(abs$1(year), sign ? 6 : 4, 0) + - '-' + padStart(date.getUTCMonth() + 1, 2, 0) + - '-' + padStart(date.getUTCDate(), 2, 0) + - 'T' + padStart(date.getUTCHours(), 2, 0) + - ':' + padStart(date.getUTCMinutes(), 2, 0) + - ':' + padStart(date.getUTCSeconds(), 2, 0) + - '.' + padStart(milliseconds, 3, 0) + - 'Z'; -} : nativeDateToISOString; - -var $$2g = _export; -var toISOString = dateToIsoString; - -// `Date.prototype.toISOString` method -// https://tc39.es/ecma262/#sec-date.prototype.toisostring -// PhantomJS / old WebKit has a broken implementations -$$2g({ target: 'Date', proto: true, forced: Date.prototype.toISOString !== toISOString }, { - toISOString: toISOString -}); - -var redefine$7 = redefine$g.exports; - -var DatePrototype$1 = Date.prototype; -var INVALID_DATE = 'Invalid Date'; -var TO_STRING = 'toString'; -var nativeDateToString = DatePrototype$1[TO_STRING]; -var getTime = DatePrototype$1.getTime; - -// `Date.prototype.toString` method -// https://tc39.es/ecma262/#sec-date.prototype.tostring -if (new Date(NaN) + '' != INVALID_DATE) { - redefine$7(DatePrototype$1, TO_STRING, function toString() { - var value = getTime.call(this); - // eslint-disable-next-line no-self-compare - return value === value ? nativeDateToString.call(this) : INVALID_DATE; - }); -} - -var anObject$1h = anObject$1z; -var toPrimitive$2 = toPrimitive$b; - -var dateToPrimitive$1 = function (hint) { - if (hint !== 'string' && hint !== 'number' && hint !== 'default') { - throw TypeError('Incorrect hint'); - } return toPrimitive$2(anObject$1h(this), hint !== 'number'); -}; - -var createNonEnumerableProperty$b = createNonEnumerableProperty$m; -var dateToPrimitive = dateToPrimitive$1; -var wellKnownSymbol$d = wellKnownSymbol$C; - -var TO_PRIMITIVE = wellKnownSymbol$d('toPrimitive'); -var DatePrototype = Date.prototype; - -// `Date.prototype[@@toPrimitive]` method -// https://tc39.es/ecma262/#sec-date.prototype-@@toprimitive -if (!(TO_PRIMITIVE in DatePrototype)) { - createNonEnumerableProperty$b(DatePrototype, TO_PRIMITIVE, dateToPrimitive); -} - -var $$2f = _export; -var getBuiltIn$n = getBuiltIn$t; -var fails$h = fails$Y; - -var $stringify = getBuiltIn$n('JSON', 'stringify'); -var re = /[\uD800-\uDFFF]/g; -var low = /^[\uD800-\uDBFF]$/; -var hi = /^[\uDC00-\uDFFF]$/; - -var fix = function (match, offset, string) { - var prev = string.charAt(offset - 1); - var next = string.charAt(offset + 1); - if ((low.test(match) && !hi.test(next)) || (hi.test(match) && !low.test(prev))) { - return '\\u' + match.charCodeAt(0).toString(16); - } return match; -}; - -var FORCED$8 = fails$h(function () { - return $stringify('\uDF06\uD834') !== '"\\udf06\\ud834"' - || $stringify('\uDEAD') !== '"\\udead"'; -}); - -if ($stringify) { - // `JSON.stringify` method - // https://tc39.es/ecma262/#sec-json.stringify - // https://github.com/tc39/proposal-well-formed-stringify - $$2f({ target: 'JSON', stat: true, forced: FORCED$8 }, { - // eslint-disable-next-line no-unused-vars - stringify: function stringify(it, replacer, space) { - var result = $stringify.apply(null, arguments); - return typeof result == 'string' ? result.replace(re, fix) : result; - } - }); -} - -var global$p = global$L; -var setToStringTag$6 = setToStringTag$b; - -// JSON[@@toStringTag] property -// https://tc39.es/ecma262/#sec-json-@@tostringtag -setToStringTag$6(global$p.JSON, 'JSON', true); - -var global$o = global$L; - -var nativePromiseConstructor = global$o.Promise; - -var redefine$6 = redefine$g.exports; - -var redefineAll$9 = function (target, src, options) { - for (var key in src) redefine$6(target, key, src[key], options); - return target; -}; - -var anInstance$b = function (it, Constructor, name) { - if (!(it instanceof Constructor)) { - throw TypeError('Incorrect ' + (name ? name + ' ' : '') + 'invocation'); - } return it; -}; - -var userAgent$2 = engineUserAgent; - -var engineIsIos = /(iphone|ipod|ipad).*applewebkit/i.test(userAgent$2); - -var global$n = global$L; -var fails$g = fails$Y; -var bind$i = functionBindContext; -var html = html$2; -var createElement = documentCreateElement$1; -var IS_IOS$1 = engineIsIos; -var IS_NODE$3 = engineIsNode; - -var location = global$n.location; -var set$2 = global$n.setImmediate; -var clear = global$n.clearImmediate; -var process$3 = global$n.process; -var MessageChannel = global$n.MessageChannel; -var Dispatch = global$n.Dispatch; -var counter = 0; -var queue = {}; -var ONREADYSTATECHANGE = 'onreadystatechange'; -var defer, channel, port; - -var run = function (id) { - // eslint-disable-next-line no-prototype-builtins - if (queue.hasOwnProperty(id)) { - var fn = queue[id]; - delete queue[id]; - fn(); - } -}; - -var runner = function (id) { - return function () { - run(id); - }; -}; - -var listener = function (event) { - run(event.data); -}; - -var post = function (id) { - // old engines have not location.origin - global$n.postMessage(id + '', location.protocol + '//' + location.host); -}; - -// Node.js 0.9+ & IE10+ has setImmediate, otherwise: -if (!set$2 || !clear) { - set$2 = function setImmediate(fn) { - var args = []; - var i = 1; - while (arguments.length > i) args.push(arguments[i++]); - queue[++counter] = function () { - // eslint-disable-next-line no-new-func - (typeof fn == 'function' ? fn : Function(fn)).apply(undefined, args); - }; - defer(counter); - return counter; - }; - clear = function clearImmediate(id) { - delete queue[id]; - }; - // Node.js 0.8- - if (IS_NODE$3) { - defer = function (id) { - process$3.nextTick(runner(id)); - }; - // Sphere (JS game engine) Dispatch API - } else if (Dispatch && Dispatch.now) { - defer = function (id) { - Dispatch.now(runner(id)); - }; - // Browsers with MessageChannel, includes WebWorkers - // except iOS - https://github.com/zloirock/core-js/issues/624 - } else if (MessageChannel && !IS_IOS$1) { - channel = new MessageChannel(); - port = channel.port2; - channel.port1.onmessage = listener; - defer = bind$i(port.postMessage, port, 1); - // Browsers with postMessage, skip WebWorkers - // IE8 has postMessage, but it's sync & typeof its postMessage is 'object' - } else if ( - global$n.addEventListener && - typeof postMessage == 'function' && - !global$n.importScripts && - location && location.protocol !== 'file:' && - !fails$g(post) - ) { - defer = post; - global$n.addEventListener('message', listener, false); - // IE8- - } else if (ONREADYSTATECHANGE in createElement('script')) { - defer = function (id) { - html.appendChild(createElement('script'))[ONREADYSTATECHANGE] = function () { - html.removeChild(this); - run(id); - }; - }; - // Rest old browsers - } else { - defer = function (id) { - setTimeout(runner(id), 0); - }; - } -} - -var task$2 = { - set: set$2, - clear: clear -}; - -var userAgent$1 = engineUserAgent; - -var engineIsWebosWebkit = /web0s(?!.*chrome)/i.test(userAgent$1); - -var global$m = global$L; -var getOwnPropertyDescriptor$1 = objectGetOwnPropertyDescriptor.f; -var macrotask = task$2.set; -var IS_IOS = engineIsIos; -var IS_WEBOS_WEBKIT = engineIsWebosWebkit; -var IS_NODE$2 = engineIsNode; - -var MutationObserver = global$m.MutationObserver || global$m.WebKitMutationObserver; -var document$2 = global$m.document; -var process$2 = global$m.process; -var Promise$4 = global$m.Promise; -// Node.js 11 shows ExperimentalWarning on getting `queueMicrotask` -var queueMicrotaskDescriptor = getOwnPropertyDescriptor$1(global$m, 'queueMicrotask'); -var queueMicrotask = queueMicrotaskDescriptor && queueMicrotaskDescriptor.value; - -var flush, head, last, notify$1, toggle, node, promise, then; - -// modern engines have queueMicrotask method -if (!queueMicrotask) { - flush = function () { - var parent, fn; - if (IS_NODE$2 && (parent = process$2.domain)) parent.exit(); - while (head) { - fn = head.fn; - head = head.next; - try { - fn(); - } catch (error) { - if (head) notify$1(); - else last = undefined; - throw error; - } - } last = undefined; - if (parent) parent.enter(); - }; - - // browsers with MutationObserver, except iOS - https://github.com/zloirock/core-js/issues/339 - // also except WebOS Webkit https://github.com/zloirock/core-js/issues/898 - if (!IS_IOS && !IS_NODE$2 && !IS_WEBOS_WEBKIT && MutationObserver && document$2) { - toggle = true; - node = document$2.createTextNode(''); - new MutationObserver(flush).observe(node, { characterData: true }); - notify$1 = function () { - node.data = toggle = !toggle; - }; - // environments with maybe non-completely correct, but existent Promise - } else if (Promise$4 && Promise$4.resolve) { - // Promise.resolve without an argument throws an error in LG WebOS 2 - promise = Promise$4.resolve(undefined); - then = promise.then; - notify$1 = function () { - then.call(promise, flush); - }; - // Node.js without promises - } else if (IS_NODE$2) { - notify$1 = function () { - process$2.nextTick(flush); - }; - // for other environments - macrotask based on: - // - setImmediate - // - MessageChannel - // - window.postMessag - // - onreadystatechange - // - setTimeout - } else { - notify$1 = function () { - // strange IE + webpack dev server bug - use .call(global) - macrotask.call(global$m, flush); - }; - } -} - -var microtask$2 = queueMicrotask || function (fn) { - var task = { fn: fn, next: undefined }; - if (last) last.next = task; - if (!head) { - head = task; - notify$1(); - } last = task; -}; - -var newPromiseCapability$2 = {}; - -var aFunction$H = aFunction$R; - -var PromiseCapability = function (C) { - var resolve, reject; - this.promise = new C(function ($$resolve, $$reject) { - if (resolve !== undefined || reject !== undefined) throw TypeError('Bad Promise constructor'); - resolve = $$resolve; - reject = $$reject; - }); - this.resolve = aFunction$H(resolve); - this.reject = aFunction$H(reject); -}; - -// 25.4.1.5 NewPromiseCapability(C) -newPromiseCapability$2.f = function (C) { - return new PromiseCapability(C); -}; - -var anObject$1g = anObject$1z; -var isObject$d = isObject$B; -var newPromiseCapability$1 = newPromiseCapability$2; - -var promiseResolve$2 = function (C, x) { - anObject$1g(C); - if (isObject$d(x) && x.constructor === C) return x; - var promiseCapability = newPromiseCapability$1.f(C); - var resolve = promiseCapability.resolve; - resolve(x); - return promiseCapability.promise; -}; - -var global$l = global$L; - -var hostReportErrors$2 = function (a, b) { - var console = global$l.console; - if (console && console.error) { - arguments.length === 1 ? console.error(a) : console.error(a, b); - } -}; - -var perform$4 = function (exec) { - try { - return { error: false, value: exec() }; - } catch (error) { - return { error: true, value: error }; - } -}; - -var $$2e = _export; -var global$k = global$L; -var getBuiltIn$m = getBuiltIn$t; -var NativePromise$1 = nativePromiseConstructor; -var redefine$5 = redefine$g.exports; -var redefineAll$8 = redefineAll$9; -var setToStringTag$5 = setToStringTag$b; -var setSpecies$4 = setSpecies$7; -var isObject$c = isObject$B; -var aFunction$G = aFunction$R; -var anInstance$a = anInstance$b; -var inspectSource = inspectSource$3; -var iterate$F = iterate$I; -var checkCorrectnessOfIteration$2 = checkCorrectnessOfIteration$4; -var speciesConstructor$g = speciesConstructor$j; -var task$1 = task$2.set; -var microtask$1 = microtask$2; -var promiseResolve$1 = promiseResolve$2; -var hostReportErrors$1 = hostReportErrors$2; -var newPromiseCapabilityModule$3 = newPromiseCapability$2; -var perform$3 = perform$4; -var InternalStateModule$d = internalState; -var isForced$1 = isForced_1; -var wellKnownSymbol$c = wellKnownSymbol$C; -var IS_NODE$1 = engineIsNode; -var V8_VERSION = engineV8Version; - -var SPECIES = wellKnownSymbol$c('species'); -var PROMISE = 'Promise'; -var getInternalState$9 = InternalStateModule$d.get; -var setInternalState$d = InternalStateModule$d.set; -var getInternalPromiseState = InternalStateModule$d.getterFor(PROMISE); -var PromiseConstructor = NativePromise$1; -var TypeError$1 = global$k.TypeError; -var document$1 = global$k.document; -var process$1 = global$k.process; -var $fetch$1 = getBuiltIn$m('fetch'); -var newPromiseCapability = newPromiseCapabilityModule$3.f; -var newGenericPromiseCapability = newPromiseCapability; -var DISPATCH_EVENT = !!(document$1 && document$1.createEvent && global$k.dispatchEvent); -var NATIVE_REJECTION_EVENT = typeof PromiseRejectionEvent == 'function'; -var UNHANDLED_REJECTION = 'unhandledrejection'; -var REJECTION_HANDLED = 'rejectionhandled'; -var PENDING = 0; -var FULFILLED = 1; -var REJECTED = 2; -var HANDLED = 1; -var UNHANDLED = 2; -var Internal, OwnPromiseCapability, PromiseWrapper, nativeThen; - -var FORCED$7 = isForced$1(PROMISE, function () { - var GLOBAL_CORE_JS_PROMISE = inspectSource(PromiseConstructor) !== String(PromiseConstructor); - if (!GLOBAL_CORE_JS_PROMISE) { - // V8 6.6 (Node 10 and Chrome 66) have a bug with resolving custom thenables - // https://bugs.chromium.org/p/chromium/issues/detail?id=830565 - // We can't detect it synchronously, so just check versions - if (V8_VERSION === 66) return true; - // Unhandled rejections tracking support, NodeJS Promise without it fails @@species test - if (!IS_NODE$1 && !NATIVE_REJECTION_EVENT) return true; - } - // We can't use @@species feature detection in V8 since it causes - // deoptimization and performance degradation - // https://github.com/zloirock/core-js/issues/679 - if (V8_VERSION >= 51 && /native code/.test(PromiseConstructor)) return false; - // Detect correctness of subclassing with @@species support - var promise = PromiseConstructor.resolve(1); - var FakePromise = function (exec) { - exec(function () { /* empty */ }, function () { /* empty */ }); - }; - var constructor = promise.constructor = {}; - constructor[SPECIES] = FakePromise; - return !(promise.then(function () { /* empty */ }) instanceof FakePromise); -}); - -var INCORRECT_ITERATION = FORCED$7 || !checkCorrectnessOfIteration$2(function (iterable) { - PromiseConstructor.all(iterable)['catch'](function () { /* empty */ }); -}); - -// helpers -var isThenable = function (it) { - var then; - return isObject$c(it) && typeof (then = it.then) == 'function' ? then : false; -}; - -var notify = function (state, isReject) { - if (state.notified) return; - state.notified = true; - var chain = state.reactions; - microtask$1(function () { - var value = state.value; - var ok = state.state == FULFILLED; - var index = 0; - // variable length - can't use forEach - while (chain.length > index) { - var reaction = chain[index++]; - var handler = ok ? reaction.ok : reaction.fail; - var resolve = reaction.resolve; - var reject = reaction.reject; - var domain = reaction.domain; - var result, then, exited; - try { - if (handler) { - if (!ok) { - if (state.rejection === UNHANDLED) onHandleUnhandled(state); - state.rejection = HANDLED; - } - if (handler === true) result = value; - else { - if (domain) domain.enter(); - result = handler(value); // can throw - if (domain) { - domain.exit(); - exited = true; - } - } - if (result === reaction.promise) { - reject(TypeError$1('Promise-chain cycle')); - } else if (then = isThenable(result)) { - then.call(result, resolve, reject); - } else resolve(result); - } else reject(value); - } catch (error) { - if (domain && !exited) domain.exit(); - reject(error); - } - } - state.reactions = []; - state.notified = false; - if (isReject && !state.rejection) onUnhandled(state); - }); -}; - -var dispatchEvent = function (name, promise, reason) { - var event, handler; - if (DISPATCH_EVENT) { - event = document$1.createEvent('Event'); - event.promise = promise; - event.reason = reason; - event.initEvent(name, false, true); - global$k.dispatchEvent(event); - } else event = { promise: promise, reason: reason }; - if (!NATIVE_REJECTION_EVENT && (handler = global$k['on' + name])) handler(event); - else if (name === UNHANDLED_REJECTION) hostReportErrors$1('Unhandled promise rejection', reason); -}; - -var onUnhandled = function (state) { - task$1.call(global$k, function () { - var promise = state.facade; - var value = state.value; - var IS_UNHANDLED = isUnhandled(state); - var result; - if (IS_UNHANDLED) { - result = perform$3(function () { - if (IS_NODE$1) { - process$1.emit('unhandledRejection', value, promise); - } else dispatchEvent(UNHANDLED_REJECTION, promise, value); - }); - // Browsers should not trigger `rejectionHandled` event if it was handled here, NodeJS - should - state.rejection = IS_NODE$1 || isUnhandled(state) ? UNHANDLED : HANDLED; - if (result.error) throw result.value; - } - }); -}; - -var isUnhandled = function (state) { - return state.rejection !== HANDLED && !state.parent; -}; - -var onHandleUnhandled = function (state) { - task$1.call(global$k, function () { - var promise = state.facade; - if (IS_NODE$1) { - process$1.emit('rejectionHandled', promise); - } else dispatchEvent(REJECTION_HANDLED, promise, state.value); - }); -}; - -var bind$h = function (fn, state, unwrap) { - return function (value) { - fn(state, value, unwrap); - }; -}; - -var internalReject = function (state, value, unwrap) { - if (state.done) return; - state.done = true; - if (unwrap) state = unwrap; - state.value = value; - state.state = REJECTED; - notify(state, true); -}; - -var internalResolve = function (state, value, unwrap) { - if (state.done) return; - state.done = true; - if (unwrap) state = unwrap; - try { - if (state.facade === value) throw TypeError$1("Promise can't be resolved itself"); - var then = isThenable(value); - if (then) { - microtask$1(function () { - var wrapper = { done: false }; - try { - then.call(value, - bind$h(internalResolve, wrapper, state), - bind$h(internalReject, wrapper, state) - ); - } catch (error) { - internalReject(wrapper, error, state); - } - }); - } else { - state.value = value; - state.state = FULFILLED; - notify(state, false); - } - } catch (error) { - internalReject({ done: false }, error, state); - } -}; - -// constructor polyfill -if (FORCED$7) { - // 25.4.3.1 Promise(executor) - PromiseConstructor = function Promise(executor) { - anInstance$a(this, PromiseConstructor, PROMISE); - aFunction$G(executor); - Internal.call(this); - var state = getInternalState$9(this); - try { - executor(bind$h(internalResolve, state), bind$h(internalReject, state)); - } catch (error) { - internalReject(state, error); - } - }; - // eslint-disable-next-line no-unused-vars - Internal = function Promise(executor) { - setInternalState$d(this, { - type: PROMISE, - done: false, - notified: false, - parent: false, - reactions: [], - rejection: false, - state: PENDING, - value: undefined - }); - }; - Internal.prototype = redefineAll$8(PromiseConstructor.prototype, { - // `Promise.prototype.then` method - // https://tc39.es/ecma262/#sec-promise.prototype.then - then: function then(onFulfilled, onRejected) { - var state = getInternalPromiseState(this); - var reaction = newPromiseCapability(speciesConstructor$g(this, PromiseConstructor)); - reaction.ok = typeof onFulfilled == 'function' ? onFulfilled : true; - reaction.fail = typeof onRejected == 'function' && onRejected; - reaction.domain = IS_NODE$1 ? process$1.domain : undefined; - state.parent = true; - state.reactions.push(reaction); - if (state.state != PENDING) notify(state, false); - return reaction.promise; - }, - // `Promise.prototype.catch` method - // https://tc39.es/ecma262/#sec-promise.prototype.catch - 'catch': function (onRejected) { - return this.then(undefined, onRejected); - } - }); - OwnPromiseCapability = function () { - var promise = new Internal(); - var state = getInternalState$9(promise); - this.promise = promise; - this.resolve = bind$h(internalResolve, state); - this.reject = bind$h(internalReject, state); - }; - newPromiseCapabilityModule$3.f = newPromiseCapability = function (C) { - return C === PromiseConstructor || C === PromiseWrapper - ? new OwnPromiseCapability(C) - : newGenericPromiseCapability(C); - }; - - if (typeof NativePromise$1 == 'function') { - nativeThen = NativePromise$1.prototype.then; - - // wrap native Promise#then for native async functions - redefine$5(NativePromise$1.prototype, 'then', function then(onFulfilled, onRejected) { - var that = this; - return new PromiseConstructor(function (resolve, reject) { - nativeThen.call(that, resolve, reject); - }).then(onFulfilled, onRejected); - // https://github.com/zloirock/core-js/issues/640 - }, { unsafe: true }); - - // wrap fetch result - if (typeof $fetch$1 == 'function') $$2e({ global: true, enumerable: true, forced: true }, { - // eslint-disable-next-line no-unused-vars - fetch: function fetch(input /* , init */) { - return promiseResolve$1(PromiseConstructor, $fetch$1.apply(global$k, arguments)); - } - }); - } -} - -$$2e({ global: true, wrap: true, forced: FORCED$7 }, { - Promise: PromiseConstructor -}); - -setToStringTag$5(PromiseConstructor, PROMISE, false); -setSpecies$4(PROMISE); - -PromiseWrapper = getBuiltIn$m(PROMISE); - -// statics -$$2e({ target: PROMISE, stat: true, forced: FORCED$7 }, { - // `Promise.reject` method - // https://tc39.es/ecma262/#sec-promise.reject - reject: function reject(r) { - var capability = newPromiseCapability(this); - capability.reject.call(undefined, r); - return capability.promise; - } -}); - -$$2e({ target: PROMISE, stat: true, forced: FORCED$7 }, { - // `Promise.resolve` method - // https://tc39.es/ecma262/#sec-promise.resolve - resolve: function resolve(x) { - return promiseResolve$1(this, x); - } -}); - -$$2e({ target: PROMISE, stat: true, forced: INCORRECT_ITERATION }, { - // `Promise.all` method - // https://tc39.es/ecma262/#sec-promise.all - all: function all(iterable) { - var C = this; - var capability = newPromiseCapability(C); - var resolve = capability.resolve; - var reject = capability.reject; - var result = perform$3(function () { - var $promiseResolve = aFunction$G(C.resolve); - var values = []; - var counter = 0; - var remaining = 1; - iterate$F(iterable, function (promise) { - var index = counter++; - var alreadyCalled = false; - values.push(undefined); - remaining++; - $promiseResolve.call(C, promise).then(function (value) { - if (alreadyCalled) return; - alreadyCalled = true; - values[index] = value; - --remaining || resolve(values); - }, reject); - }); - --remaining || resolve(values); - }); - if (result.error) reject(result.value); - return capability.promise; - }, - // `Promise.race` method - // https://tc39.es/ecma262/#sec-promise.race - race: function race(iterable) { - var C = this; - var capability = newPromiseCapability(C); - var reject = capability.reject; - var result = perform$3(function () { - var $promiseResolve = aFunction$G(C.resolve); - iterate$F(iterable, function (promise) { - $promiseResolve.call(C, promise).then(capability.resolve, reject); - }); - }); - if (result.error) reject(result.value); - return capability.promise; - } -}); - -var $$2d = _export; -var aFunction$F = aFunction$R; -var newPromiseCapabilityModule$2 = newPromiseCapability$2; -var perform$2 = perform$4; -var iterate$E = iterate$I; - -// `Promise.allSettled` method -// https://tc39.es/ecma262/#sec-promise.allsettled -$$2d({ target: 'Promise', stat: true }, { - allSettled: function allSettled(iterable) { - var C = this; - var capability = newPromiseCapabilityModule$2.f(C); - var resolve = capability.resolve; - var reject = capability.reject; - var result = perform$2(function () { - var promiseResolve = aFunction$F(C.resolve); - var values = []; - var counter = 0; - var remaining = 1; - iterate$E(iterable, function (promise) { - var index = counter++; - var alreadyCalled = false; - values.push(undefined); - remaining++; - promiseResolve.call(C, promise).then(function (value) { - if (alreadyCalled) return; - alreadyCalled = true; - values[index] = { status: 'fulfilled', value: value }; - --remaining || resolve(values); - }, function (error) { - if (alreadyCalled) return; - alreadyCalled = true; - values[index] = { status: 'rejected', reason: error }; - --remaining || resolve(values); - }); - }); - --remaining || resolve(values); - }); - if (result.error) reject(result.value); - return capability.promise; - } -}); - -var $$2c = _export; -var aFunction$E = aFunction$R; -var getBuiltIn$l = getBuiltIn$t; -var newPromiseCapabilityModule$1 = newPromiseCapability$2; -var perform$1 = perform$4; -var iterate$D = iterate$I; - -var PROMISE_ANY_ERROR = 'No one promise resolved'; - -// `Promise.any` method -// https://tc39.es/ecma262/#sec-promise.any -$$2c({ target: 'Promise', stat: true }, { - any: function any(iterable) { - var C = this; - var capability = newPromiseCapabilityModule$1.f(C); - var resolve = capability.resolve; - var reject = capability.reject; - var result = perform$1(function () { - var promiseResolve = aFunction$E(C.resolve); - var errors = []; - var counter = 0; - var remaining = 1; - var alreadyResolved = false; - iterate$D(iterable, function (promise) { - var index = counter++; - var alreadyRejected = false; - errors.push(undefined); - remaining++; - promiseResolve.call(C, promise).then(function (value) { - if (alreadyRejected || alreadyResolved) return; - alreadyResolved = true; - resolve(value); - }, function (error) { - if (alreadyRejected || alreadyResolved) return; - alreadyRejected = true; - errors[index] = error; - --remaining || reject(new (getBuiltIn$l('AggregateError'))(errors, PROMISE_ANY_ERROR)); - }); - }); - --remaining || reject(new (getBuiltIn$l('AggregateError'))(errors, PROMISE_ANY_ERROR)); - }); - if (result.error) reject(result.value); - return capability.promise; - } -}); - -var $$2b = _export; -var NativePromise = nativePromiseConstructor; -var fails$f = fails$Y; -var getBuiltIn$k = getBuiltIn$t; -var speciesConstructor$f = speciesConstructor$j; -var promiseResolve = promiseResolve$2; -var redefine$4 = redefine$g.exports; - -// Safari bug https://bugs.webkit.org/show_bug.cgi?id=200829 -var NON_GENERIC = !!NativePromise && fails$f(function () { - NativePromise.prototype['finally'].call({ then: function () { /* empty */ } }, function () { /* empty */ }); -}); - -// `Promise.prototype.finally` method -// https://tc39.es/ecma262/#sec-promise.prototype.finally -$$2b({ target: 'Promise', proto: true, real: true, forced: NON_GENERIC }, { - 'finally': function (onFinally) { - var C = speciesConstructor$f(this, getBuiltIn$k('Promise')); - var isFunction = typeof onFinally == 'function'; - return this.then( - isFunction ? function (x) { - return promiseResolve(C, onFinally()).then(function () { return x; }); - } : onFinally, - isFunction ? function (e) { - return promiseResolve(C, onFinally()).then(function () { throw e; }); - } : onFinally - ); - } -}); - -// patch native Promise.prototype for native async functions -if (typeof NativePromise == 'function' && !NativePromise.prototype['finally']) { - redefine$4(NativePromise.prototype, 'finally', getBuiltIn$k('Promise').prototype['finally']); -} - -var $$2a = _export; -var global$j = global$L; -var isForced = isForced_1; -var redefine$3 = redefine$g.exports; -var InternalMetadataModule$1 = internalMetadata.exports; -var iterate$C = iterate$I; -var anInstance$9 = anInstance$b; -var isObject$b = isObject$B; -var fails$e = fails$Y; -var checkCorrectnessOfIteration$1 = checkCorrectnessOfIteration$4; -var setToStringTag$4 = setToStringTag$b; -var inheritIfRequired$1 = inheritIfRequired$4; - -var collection$4 = function (CONSTRUCTOR_NAME, wrapper, common) { - var IS_MAP = CONSTRUCTOR_NAME.indexOf('Map') !== -1; - var IS_WEAK = CONSTRUCTOR_NAME.indexOf('Weak') !== -1; - var ADDER = IS_MAP ? 'set' : 'add'; - var NativeConstructor = global$j[CONSTRUCTOR_NAME]; - var NativePrototype = NativeConstructor && NativeConstructor.prototype; - var Constructor = NativeConstructor; - var exported = {}; - - var fixMethod = function (KEY) { - var nativeMethod = NativePrototype[KEY]; - redefine$3(NativePrototype, KEY, - KEY == 'add' ? function add(value) { - nativeMethod.call(this, value === 0 ? 0 : value); - return this; - } : KEY == 'delete' ? function (key) { - return IS_WEAK && !isObject$b(key) ? false : nativeMethod.call(this, key === 0 ? 0 : key); - } : KEY == 'get' ? function get(key) { - return IS_WEAK && !isObject$b(key) ? undefined : nativeMethod.call(this, key === 0 ? 0 : key); - } : KEY == 'has' ? function has(key) { - return IS_WEAK && !isObject$b(key) ? false : nativeMethod.call(this, key === 0 ? 0 : key); - } : function set(key, value) { - nativeMethod.call(this, key === 0 ? 0 : key, value); - return this; - } - ); - }; - - // eslint-disable-next-line max-len - if (isForced(CONSTRUCTOR_NAME, typeof NativeConstructor != 'function' || !(IS_WEAK || NativePrototype.forEach && !fails$e(function () { - new NativeConstructor().entries().next(); - })))) { - // create collection constructor - Constructor = common.getConstructor(wrapper, CONSTRUCTOR_NAME, IS_MAP, ADDER); - InternalMetadataModule$1.REQUIRED = true; - } else if (isForced(CONSTRUCTOR_NAME, true)) { - var instance = new Constructor(); - // early implementations not supports chaining - var HASNT_CHAINING = instance[ADDER](IS_WEAK ? {} : -0, 1) != instance; - // V8 ~ Chromium 40- weak-collections throws on primitives, but should return false - var THROWS_ON_PRIMITIVES = fails$e(function () { instance.has(1); }); - // most early implementations doesn't supports iterables, most modern - not close it correctly - // eslint-disable-next-line no-new - var ACCEPT_ITERABLES = checkCorrectnessOfIteration$1(function (iterable) { new NativeConstructor(iterable); }); - // for early implementations -0 and +0 not the same - var BUGGY_ZERO = !IS_WEAK && fails$e(function () { - // V8 ~ Chromium 42- fails only with 5+ elements - var $instance = new NativeConstructor(); - var index = 5; - while (index--) $instance[ADDER](index, index); - return !$instance.has(-0); - }); - - if (!ACCEPT_ITERABLES) { - Constructor = wrapper(function (dummy, iterable) { - anInstance$9(dummy, Constructor, CONSTRUCTOR_NAME); - var that = inheritIfRequired$1(new NativeConstructor(), dummy, Constructor); - if (iterable != undefined) iterate$C(iterable, that[ADDER], { that: that, AS_ENTRIES: IS_MAP }); - return that; - }); - Constructor.prototype = NativePrototype; - NativePrototype.constructor = Constructor; - } - - if (THROWS_ON_PRIMITIVES || BUGGY_ZERO) { - fixMethod('delete'); - fixMethod('has'); - IS_MAP && fixMethod('get'); - } - - if (BUGGY_ZERO || HASNT_CHAINING) fixMethod(ADDER); - - // weak collections should not contains .clear method - if (IS_WEAK && NativePrototype.clear) delete NativePrototype.clear; - } - - exported[CONSTRUCTOR_NAME] = Constructor; - $$2a({ global: true, forced: Constructor != NativeConstructor }, exported); - - setToStringTag$4(Constructor, CONSTRUCTOR_NAME); - - if (!IS_WEAK) common.setStrong(Constructor, CONSTRUCTOR_NAME, IS_MAP); - - return Constructor; -}; - -var defineProperty$5 = objectDefineProperty.f; -var create$7 = objectCreate; -var redefineAll$7 = redefineAll$9; -var bind$g = functionBindContext; -var anInstance$8 = anInstance$b; -var iterate$B = iterate$I; -var defineIterator = defineIterator$3; -var setSpecies$3 = setSpecies$7; -var DESCRIPTORS$a = descriptors; -var fastKey = internalMetadata.exports.fastKey; -var InternalStateModule$c = internalState; - -var setInternalState$c = InternalStateModule$c.set; -var internalStateGetterFor$1 = InternalStateModule$c.getterFor; - -var collectionStrong$2 = { - getConstructor: function (wrapper, CONSTRUCTOR_NAME, IS_MAP, ADDER) { - var C = wrapper(function (that, iterable) { - anInstance$8(that, C, CONSTRUCTOR_NAME); - setInternalState$c(that, { - type: CONSTRUCTOR_NAME, - index: create$7(null), - first: undefined, - last: undefined, - size: 0 - }); - if (!DESCRIPTORS$a) that.size = 0; - if (iterable != undefined) iterate$B(iterable, that[ADDER], { that: that, AS_ENTRIES: IS_MAP }); - }); - - var getInternalState = internalStateGetterFor$1(CONSTRUCTOR_NAME); - - var define = function (that, key, value) { - var state = getInternalState(that); - var entry = getEntry(that, key); - var previous, index; - // change existing entry - if (entry) { - entry.value = value; - // create new entry - } else { - state.last = entry = { - index: index = fastKey(key, true), - key: key, - value: value, - previous: previous = state.last, - next: undefined, - removed: false - }; - if (!state.first) state.first = entry; - if (previous) previous.next = entry; - if (DESCRIPTORS$a) state.size++; - else that.size++; - // add to index - if (index !== 'F') state.index[index] = entry; - } return that; - }; - - var getEntry = function (that, key) { - var state = getInternalState(that); - // fast case - var index = fastKey(key); - var entry; - if (index !== 'F') return state.index[index]; - // frozen object case - for (entry = state.first; entry; entry = entry.next) { - if (entry.key == key) return entry; - } - }; - - redefineAll$7(C.prototype, { - // 23.1.3.1 Map.prototype.clear() - // 23.2.3.2 Set.prototype.clear() - clear: function clear() { - var that = this; - var state = getInternalState(that); - var data = state.index; - var entry = state.first; - while (entry) { - entry.removed = true; - if (entry.previous) entry.previous = entry.previous.next = undefined; - delete data[entry.index]; - entry = entry.next; - } - state.first = state.last = undefined; - if (DESCRIPTORS$a) state.size = 0; - else that.size = 0; - }, - // 23.1.3.3 Map.prototype.delete(key) - // 23.2.3.4 Set.prototype.delete(value) - 'delete': function (key) { - var that = this; - var state = getInternalState(that); - var entry = getEntry(that, key); - if (entry) { - var next = entry.next; - var prev = entry.previous; - delete state.index[entry.index]; - entry.removed = true; - if (prev) prev.next = next; - if (next) next.previous = prev; - if (state.first == entry) state.first = next; - if (state.last == entry) state.last = prev; - if (DESCRIPTORS$a) state.size--; - else that.size--; - } return !!entry; - }, - // 23.2.3.6 Set.prototype.forEach(callbackfn, thisArg = undefined) - // 23.1.3.5 Map.prototype.forEach(callbackfn, thisArg = undefined) - forEach: function forEach(callbackfn /* , that = undefined */) { - var state = getInternalState(this); - var boundFunction = bind$g(callbackfn, arguments.length > 1 ? arguments[1] : undefined, 3); - var entry; - while (entry = entry ? entry.next : state.first) { - boundFunction(entry.value, entry.key, this); - // revert to the last existing entry - while (entry && entry.removed) entry = entry.previous; - } - }, - // 23.1.3.7 Map.prototype.has(key) - // 23.2.3.7 Set.prototype.has(value) - has: function has(key) { - return !!getEntry(this, key); - } - }); - - redefineAll$7(C.prototype, IS_MAP ? { - // 23.1.3.6 Map.prototype.get(key) - get: function get(key) { - var entry = getEntry(this, key); - return entry && entry.value; - }, - // 23.1.3.9 Map.prototype.set(key, value) - set: function set(key, value) { - return define(this, key === 0 ? 0 : key, value); - } - } : { - // 23.2.3.1 Set.prototype.add(value) - add: function add(value) { - return define(this, value = value === 0 ? 0 : value, value); - } - }); - if (DESCRIPTORS$a) defineProperty$5(C.prototype, 'size', { - get: function () { - return getInternalState(this).size; - } - }); - return C; - }, - setStrong: function (C, CONSTRUCTOR_NAME, IS_MAP) { - var ITERATOR_NAME = CONSTRUCTOR_NAME + ' Iterator'; - var getInternalCollectionState = internalStateGetterFor$1(CONSTRUCTOR_NAME); - var getInternalIteratorState = internalStateGetterFor$1(ITERATOR_NAME); - // add .keys, .values, .entries, [@@iterator] - // 23.1.3.4, 23.1.3.8, 23.1.3.11, 23.1.3.12, 23.2.3.5, 23.2.3.8, 23.2.3.10, 23.2.3.11 - defineIterator(C, CONSTRUCTOR_NAME, function (iterated, kind) { - setInternalState$c(this, { - type: ITERATOR_NAME, - target: iterated, - state: getInternalCollectionState(iterated), - kind: kind, - last: undefined - }); - }, function () { - var state = getInternalIteratorState(this); - var kind = state.kind; - var entry = state.last; - // revert to the last existing entry - while (entry && entry.removed) entry = entry.previous; - // get next entry - if (!state.target || !(state.last = entry = entry ? entry.next : state.state.first)) { - // or finish the iteration - state.target = undefined; - return { value: undefined, done: true }; - } - // return step by kind - if (kind == 'keys') return { value: entry.key, done: false }; - if (kind == 'values') return { value: entry.value, done: false }; - return { value: [entry.key, entry.value], done: false }; - }, IS_MAP ? 'entries' : 'values', !IS_MAP, true); - - // add [@@species], 23.1.2.2, 23.2.2.2 - setSpecies$3(CONSTRUCTOR_NAME); - } -}; - -var collection$3 = collection$4; -var collectionStrong$1 = collectionStrong$2; - -// `Map` constructor -// https://tc39.es/ecma262/#sec-map-objects -var es_map = collection$3('Map', function (init) { - return function Map() { return init(this, arguments.length ? arguments[0] : undefined); }; -}, collectionStrong$1); - -var collection$2 = collection$4; -var collectionStrong = collectionStrong$2; - -// `Set` constructor -// https://tc39.es/ecma262/#sec-set-objects -var es_set = collection$2('Set', function (init) { - return function Set() { return init(this, arguments.length ? arguments[0] : undefined); }; -}, collectionStrong); - -var es_weakMap = {exports: {}}; - -var redefineAll$6 = redefineAll$9; -var getWeakData = internalMetadata.exports.getWeakData; -var anObject$1f = anObject$1z; -var isObject$a = isObject$B; -var anInstance$7 = anInstance$b; -var iterate$A = iterate$I; -var ArrayIterationModule = arrayIteration; -var $has = has$o; -var InternalStateModule$b = internalState; - -var setInternalState$b = InternalStateModule$b.set; -var internalStateGetterFor = InternalStateModule$b.getterFor; -var find$1 = ArrayIterationModule.find; -var findIndex = ArrayIterationModule.findIndex; -var id = 0; - -// fallback for uncaught frozen keys -var uncaughtFrozenStore = function (store) { - return store.frozen || (store.frozen = new UncaughtFrozenStore()); -}; - -var UncaughtFrozenStore = function () { - this.entries = []; -}; - -var findUncaughtFrozen = function (store, key) { - return find$1(store.entries, function (it) { - return it[0] === key; - }); -}; - -UncaughtFrozenStore.prototype = { - get: function (key) { - var entry = findUncaughtFrozen(this, key); - if (entry) return entry[1]; - }, - has: function (key) { - return !!findUncaughtFrozen(this, key); - }, - set: function (key, value) { - var entry = findUncaughtFrozen(this, key); - if (entry) entry[1] = value; - else this.entries.push([key, value]); - }, - 'delete': function (key) { - var index = findIndex(this.entries, function (it) { - return it[0] === key; - }); - if (~index) this.entries.splice(index, 1); - return !!~index; - } -}; - -var collectionWeak$2 = { - getConstructor: function (wrapper, CONSTRUCTOR_NAME, IS_MAP, ADDER) { - var C = wrapper(function (that, iterable) { - anInstance$7(that, C, CONSTRUCTOR_NAME); - setInternalState$b(that, { - type: CONSTRUCTOR_NAME, - id: id++, - frozen: undefined - }); - if (iterable != undefined) iterate$A(iterable, that[ADDER], { that: that, AS_ENTRIES: IS_MAP }); - }); - - var getInternalState = internalStateGetterFor(CONSTRUCTOR_NAME); - - var define = function (that, key, value) { - var state = getInternalState(that); - var data = getWeakData(anObject$1f(key), true); - if (data === true) uncaughtFrozenStore(state).set(key, value); - else data[state.id] = value; - return that; - }; - - redefineAll$6(C.prototype, { - // 23.3.3.2 WeakMap.prototype.delete(key) - // 23.4.3.3 WeakSet.prototype.delete(value) - 'delete': function (key) { - var state = getInternalState(this); - if (!isObject$a(key)) return false; - var data = getWeakData(key); - if (data === true) return uncaughtFrozenStore(state)['delete'](key); - return data && $has(data, state.id) && delete data[state.id]; - }, - // 23.3.3.4 WeakMap.prototype.has(key) - // 23.4.3.4 WeakSet.prototype.has(value) - has: function has(key) { - var state = getInternalState(this); - if (!isObject$a(key)) return false; - var data = getWeakData(key); - if (data === true) return uncaughtFrozenStore(state).has(key); - return data && $has(data, state.id); - } - }); - - redefineAll$6(C.prototype, IS_MAP ? { - // 23.3.3.3 WeakMap.prototype.get(key) - get: function get(key) { - var state = getInternalState(this); - if (isObject$a(key)) { - var data = getWeakData(key); - if (data === true) return uncaughtFrozenStore(state).get(key); - return data ? data[state.id] : undefined; - } - }, - // 23.3.3.5 WeakMap.prototype.set(key, value) - set: function set(key, value) { - return define(this, key, value); - } - } : { - // 23.4.3.1 WeakSet.prototype.add(value) - add: function add(value) { - return define(this, value, true); - } - }); - - return C; - } -}; - -var global$i = global$L; -var redefineAll$5 = redefineAll$9; -var InternalMetadataModule = internalMetadata.exports; -var collection$1 = collection$4; -var collectionWeak$1 = collectionWeak$2; -var isObject$9 = isObject$B; -var enforceIternalState = internalState.enforce; -var NATIVE_WEAK_MAP = nativeWeakMap; - -var IS_IE11 = !global$i.ActiveXObject && 'ActiveXObject' in global$i; -var isExtensible = Object.isExtensible; -var InternalWeakMap; - -var wrapper = function (init) { - return function WeakMap() { - return init(this, arguments.length ? arguments[0] : undefined); - }; -}; - -// `WeakMap` constructor -// https://tc39.es/ecma262/#sec-weakmap-constructor -var $WeakMap = es_weakMap.exports = collection$1('WeakMap', wrapper, collectionWeak$1); - -// IE11 WeakMap frozen keys fix -// We can't use feature detection because it crash some old IE builds -// https://github.com/zloirock/core-js/issues/485 -if (NATIVE_WEAK_MAP && IS_IE11) { - InternalWeakMap = collectionWeak$1.getConstructor(wrapper, 'WeakMap', true); - InternalMetadataModule.REQUIRED = true; - var WeakMapPrototype = $WeakMap.prototype; - var nativeDelete = WeakMapPrototype['delete']; - var nativeHas = WeakMapPrototype.has; - var nativeGet = WeakMapPrototype.get; - var nativeSet = WeakMapPrototype.set; - redefineAll$5(WeakMapPrototype, { - 'delete': function (key) { - if (isObject$9(key) && !isExtensible(key)) { - var state = enforceIternalState(this); - if (!state.frozen) state.frozen = new InternalWeakMap(); - return nativeDelete.call(this, key) || state.frozen['delete'](key); - } return nativeDelete.call(this, key); - }, - has: function has(key) { - if (isObject$9(key) && !isExtensible(key)) { - var state = enforceIternalState(this); - if (!state.frozen) state.frozen = new InternalWeakMap(); - return nativeHas.call(this, key) || state.frozen.has(key); - } return nativeHas.call(this, key); - }, - get: function get(key) { - if (isObject$9(key) && !isExtensible(key)) { - var state = enforceIternalState(this); - if (!state.frozen) state.frozen = new InternalWeakMap(); - return nativeHas.call(this, key) ? nativeGet.call(this, key) : state.frozen.get(key); - } return nativeGet.call(this, key); - }, - set: function set(key, value) { - if (isObject$9(key) && !isExtensible(key)) { - var state = enforceIternalState(this); - if (!state.frozen) state.frozen = new InternalWeakMap(); - nativeHas.call(this, key) ? nativeSet.call(this, key, value) : state.frozen.set(key, value); - } else nativeSet.call(this, key, value); - return this; - } - }); -} - -var collection = collection$4; -var collectionWeak = collectionWeak$2; - -// `WeakSet` constructor -// https://tc39.es/ecma262/#sec-weakset-constructor -collection('WeakSet', function (init) { - return function WeakSet() { return init(this, arguments.length ? arguments[0] : undefined); }; -}, collectionWeak); - -var arrayBufferNative = typeof ArrayBuffer !== 'undefined' && typeof DataView !== 'undefined'; - -var toInteger$5 = toInteger$f; -var toLength$b = toLength$y; - -// `ToIndex` abstract operation -// https://tc39.es/ecma262/#sec-toindex -var toIndex$2 = function (it) { - if (it === undefined) return 0; - var number = toInteger$5(it); - var length = toLength$b(number); - if (number !== length) throw RangeError('Wrong length or index'); - return length; -}; - -// IEEE754 conversions based on https://github.com/feross/ieee754 -// eslint-disable-next-line no-shadow-restricted-names -var Infinity$1 = 1 / 0; -var abs = Math.abs; -var pow$1 = Math.pow; -var floor$3 = Math.floor; -var log = Math.log; -var LN2 = Math.LN2; - -var pack = function (number, mantissaLength, bytes) { - var buffer = new Array(bytes); - var exponentLength = bytes * 8 - mantissaLength - 1; - var eMax = (1 << exponentLength) - 1; - var eBias = eMax >> 1; - var rt = mantissaLength === 23 ? pow$1(2, -24) - pow$1(2, -77) : 0; - var sign = number < 0 || number === 0 && 1 / number < 0 ? 1 : 0; - var index = 0; - var exponent, mantissa, c; - number = abs(number); - // eslint-disable-next-line no-self-compare - if (number != number || number === Infinity$1) { - // eslint-disable-next-line no-self-compare - mantissa = number != number ? 1 : 0; - exponent = eMax; - } else { - exponent = floor$3(log(number) / LN2); - if (number * (c = pow$1(2, -exponent)) < 1) { - exponent--; - c *= 2; - } - if (exponent + eBias >= 1) { - number += rt / c; - } else { - number += rt * pow$1(2, 1 - eBias); - } - if (number * c >= 2) { - exponent++; - c /= 2; - } - if (exponent + eBias >= eMax) { - mantissa = 0; - exponent = eMax; - } else if (exponent + eBias >= 1) { - mantissa = (number * c - 1) * pow$1(2, mantissaLength); - exponent = exponent + eBias; - } else { - mantissa = number * pow$1(2, eBias - 1) * pow$1(2, mantissaLength); - exponent = 0; - } - } - for (; mantissaLength >= 8; buffer[index++] = mantissa & 255, mantissa /= 256, mantissaLength -= 8); - exponent = exponent << mantissaLength | mantissa; - exponentLength += mantissaLength; - for (; exponentLength > 0; buffer[index++] = exponent & 255, exponent /= 256, exponentLength -= 8); - buffer[--index] |= sign * 128; - return buffer; -}; - -var unpack = function (buffer, mantissaLength) { - var bytes = buffer.length; - var exponentLength = bytes * 8 - mantissaLength - 1; - var eMax = (1 << exponentLength) - 1; - var eBias = eMax >> 1; - var nBits = exponentLength - 7; - var index = bytes - 1; - var sign = buffer[index--]; - var exponent = sign & 127; - var mantissa; - sign >>= 7; - for (; nBits > 0; exponent = exponent * 256 + buffer[index], index--, nBits -= 8); - mantissa = exponent & (1 << -nBits) - 1; - exponent >>= -nBits; - nBits += mantissaLength; - for (; nBits > 0; mantissa = mantissa * 256 + buffer[index], index--, nBits -= 8); - if (exponent === 0) { - exponent = 1 - eBias; - } else if (exponent === eMax) { - return mantissa ? NaN : sign ? -Infinity$1 : Infinity$1; - } else { - mantissa = mantissa + pow$1(2, mantissaLength); - exponent = exponent - eBias; - } return (sign ? -1 : 1) * mantissa * pow$1(2, exponent - mantissaLength); -}; - -var ieee754 = { - pack: pack, - unpack: unpack -}; - -var global$h = global$L; -var DESCRIPTORS$9 = descriptors; -var NATIVE_ARRAY_BUFFER$2 = arrayBufferNative; -var createNonEnumerableProperty$a = createNonEnumerableProperty$m; -var redefineAll$4 = redefineAll$9; -var fails$d = fails$Y; -var anInstance$6 = anInstance$b; -var toInteger$4 = toInteger$f; -var toLength$a = toLength$y; -var toIndex$1 = toIndex$2; -var IEEE754 = ieee754; -var getPrototypeOf$7 = objectGetPrototypeOf$1; -var setPrototypeOf$2 = objectSetPrototypeOf$1; -var getOwnPropertyNames$1 = objectGetOwnPropertyNames.f; -var defineProperty$4 = objectDefineProperty.f; -var arrayFill = arrayFill$1; -var setToStringTag$3 = setToStringTag$b; -var InternalStateModule$a = internalState; - -var getInternalState$8 = InternalStateModule$a.get; -var setInternalState$a = InternalStateModule$a.set; -var ARRAY_BUFFER$1 = 'ArrayBuffer'; -var DATA_VIEW = 'DataView'; -var PROTOTYPE = 'prototype'; -var WRONG_LENGTH$1 = 'Wrong length'; -var WRONG_INDEX = 'Wrong index'; -var NativeArrayBuffer$1 = global$h[ARRAY_BUFFER$1]; -var $ArrayBuffer = NativeArrayBuffer$1; -var $DataView = global$h[DATA_VIEW]; -var $DataViewPrototype = $DataView && $DataView[PROTOTYPE]; -var ObjectPrototype$1 = Object.prototype; -var RangeError$2 = global$h.RangeError; - -var packIEEE754 = IEEE754.pack; -var unpackIEEE754 = IEEE754.unpack; - -var packInt8 = function (number) { - return [number & 0xFF]; -}; - -var packInt16 = function (number) { - return [number & 0xFF, number >> 8 & 0xFF]; -}; - -var packInt32 = function (number) { - return [number & 0xFF, number >> 8 & 0xFF, number >> 16 & 0xFF, number >> 24 & 0xFF]; -}; - -var unpackInt32 = function (buffer) { - return buffer[3] << 24 | buffer[2] << 16 | buffer[1] << 8 | buffer[0]; -}; - -var packFloat32 = function (number) { - return packIEEE754(number, 23, 4); -}; - -var packFloat64 = function (number) { - return packIEEE754(number, 52, 8); -}; - -var addGetter$1 = function (Constructor, key) { - defineProperty$4(Constructor[PROTOTYPE], key, { get: function () { return getInternalState$8(this)[key]; } }); -}; - -var get$1 = function (view, count, index, isLittleEndian) { - var intIndex = toIndex$1(index); - var store = getInternalState$8(view); - if (intIndex + count > store.byteLength) throw RangeError$2(WRONG_INDEX); - var bytes = getInternalState$8(store.buffer).bytes; - var start = intIndex + store.byteOffset; - var pack = bytes.slice(start, start + count); - return isLittleEndian ? pack : pack.reverse(); -}; - -var set$1 = function (view, count, index, conversion, value, isLittleEndian) { - var intIndex = toIndex$1(index); - var store = getInternalState$8(view); - if (intIndex + count > store.byteLength) throw RangeError$2(WRONG_INDEX); - var bytes = getInternalState$8(store.buffer).bytes; - var start = intIndex + store.byteOffset; - var pack = conversion(+value); - for (var i = 0; i < count; i++) bytes[start + i] = pack[isLittleEndian ? i : count - i - 1]; -}; - -if (!NATIVE_ARRAY_BUFFER$2) { - $ArrayBuffer = function ArrayBuffer(length) { - anInstance$6(this, $ArrayBuffer, ARRAY_BUFFER$1); - var byteLength = toIndex$1(length); - setInternalState$a(this, { - bytes: arrayFill.call(new Array(byteLength), 0), - byteLength: byteLength - }); - if (!DESCRIPTORS$9) this.byteLength = byteLength; - }; - - $DataView = function DataView(buffer, byteOffset, byteLength) { - anInstance$6(this, $DataView, DATA_VIEW); - anInstance$6(buffer, $ArrayBuffer, DATA_VIEW); - var bufferLength = getInternalState$8(buffer).byteLength; - var offset = toInteger$4(byteOffset); - if (offset < 0 || offset > bufferLength) throw RangeError$2('Wrong offset'); - byteLength = byteLength === undefined ? bufferLength - offset : toLength$a(byteLength); - if (offset + byteLength > bufferLength) throw RangeError$2(WRONG_LENGTH$1); - setInternalState$a(this, { - buffer: buffer, - byteLength: byteLength, - byteOffset: offset - }); - if (!DESCRIPTORS$9) { - this.buffer = buffer; - this.byteLength = byteLength; - this.byteOffset = offset; - } - }; - - if (DESCRIPTORS$9) { - addGetter$1($ArrayBuffer, 'byteLength'); - addGetter$1($DataView, 'buffer'); - addGetter$1($DataView, 'byteLength'); - addGetter$1($DataView, 'byteOffset'); - } - - redefineAll$4($DataView[PROTOTYPE], { - getInt8: function getInt8(byteOffset) { - return get$1(this, 1, byteOffset)[0] << 24 >> 24; - }, - getUint8: function getUint8(byteOffset) { - return get$1(this, 1, byteOffset)[0]; - }, - getInt16: function getInt16(byteOffset /* , littleEndian */) { - var bytes = get$1(this, 2, byteOffset, arguments.length > 1 ? arguments[1] : undefined); - return (bytes[1] << 8 | bytes[0]) << 16 >> 16; - }, - getUint16: function getUint16(byteOffset /* , littleEndian */) { - var bytes = get$1(this, 2, byteOffset, arguments.length > 1 ? arguments[1] : undefined); - return bytes[1] << 8 | bytes[0]; - }, - getInt32: function getInt32(byteOffset /* , littleEndian */) { - return unpackInt32(get$1(this, 4, byteOffset, arguments.length > 1 ? arguments[1] : undefined)); - }, - getUint32: function getUint32(byteOffset /* , littleEndian */) { - return unpackInt32(get$1(this, 4, byteOffset, arguments.length > 1 ? arguments[1] : undefined)) >>> 0; - }, - getFloat32: function getFloat32(byteOffset /* , littleEndian */) { - return unpackIEEE754(get$1(this, 4, byteOffset, arguments.length > 1 ? arguments[1] : undefined), 23); - }, - getFloat64: function getFloat64(byteOffset /* , littleEndian */) { - return unpackIEEE754(get$1(this, 8, byteOffset, arguments.length > 1 ? arguments[1] : undefined), 52); - }, - setInt8: function setInt8(byteOffset, value) { - set$1(this, 1, byteOffset, packInt8, value); - }, - setUint8: function setUint8(byteOffset, value) { - set$1(this, 1, byteOffset, packInt8, value); - }, - setInt16: function setInt16(byteOffset, value /* , littleEndian */) { - set$1(this, 2, byteOffset, packInt16, value, arguments.length > 2 ? arguments[2] : undefined); - }, - setUint16: function setUint16(byteOffset, value /* , littleEndian */) { - set$1(this, 2, byteOffset, packInt16, value, arguments.length > 2 ? arguments[2] : undefined); - }, - setInt32: function setInt32(byteOffset, value /* , littleEndian */) { - set$1(this, 4, byteOffset, packInt32, value, arguments.length > 2 ? arguments[2] : undefined); - }, - setUint32: function setUint32(byteOffset, value /* , littleEndian */) { - set$1(this, 4, byteOffset, packInt32, value, arguments.length > 2 ? arguments[2] : undefined); - }, - setFloat32: function setFloat32(byteOffset, value /* , littleEndian */) { - set$1(this, 4, byteOffset, packFloat32, value, arguments.length > 2 ? arguments[2] : undefined); - }, - setFloat64: function setFloat64(byteOffset, value /* , littleEndian */) { - set$1(this, 8, byteOffset, packFloat64, value, arguments.length > 2 ? arguments[2] : undefined); - } - }); -} else { - if (!fails$d(function () { - NativeArrayBuffer$1(1); - }) || !fails$d(function () { - new NativeArrayBuffer$1(-1); // eslint-disable-line no-new - }) || fails$d(function () { - new NativeArrayBuffer$1(); // eslint-disable-line no-new - new NativeArrayBuffer$1(1.5); // eslint-disable-line no-new - new NativeArrayBuffer$1(NaN); // eslint-disable-line no-new - return NativeArrayBuffer$1.name != ARRAY_BUFFER$1; - })) { - $ArrayBuffer = function ArrayBuffer(length) { - anInstance$6(this, $ArrayBuffer); - return new NativeArrayBuffer$1(toIndex$1(length)); - }; - var ArrayBufferPrototype = $ArrayBuffer[PROTOTYPE] = NativeArrayBuffer$1[PROTOTYPE]; - for (var keys = getOwnPropertyNames$1(NativeArrayBuffer$1), j = 0, key; keys.length > j;) { - if (!((key = keys[j++]) in $ArrayBuffer)) { - createNonEnumerableProperty$a($ArrayBuffer, key, NativeArrayBuffer$1[key]); - } - } - ArrayBufferPrototype.constructor = $ArrayBuffer; - } - - // WebKit bug - the same parent prototype for typed arrays and data view - if (setPrototypeOf$2 && getPrototypeOf$7($DataViewPrototype) !== ObjectPrototype$1) { - setPrototypeOf$2($DataViewPrototype, ObjectPrototype$1); - } - - // iOS Safari 7.x bug - var testView = new $DataView(new $ArrayBuffer(2)); - var nativeSetInt8 = $DataViewPrototype.setInt8; - testView.setInt8(0, 2147483648); - testView.setInt8(1, 2147483649); - if (testView.getInt8(0) || !testView.getInt8(1)) redefineAll$4($DataViewPrototype, { - setInt8: function setInt8(byteOffset, value) { - nativeSetInt8.call(this, byteOffset, value << 24 >> 24); - }, - setUint8: function setUint8(byteOffset, value) { - nativeSetInt8.call(this, byteOffset, value << 24 >> 24); - } - }, { unsafe: true }); -} - -setToStringTag$3($ArrayBuffer, ARRAY_BUFFER$1); -setToStringTag$3($DataView, DATA_VIEW); - -var arrayBuffer = { - ArrayBuffer: $ArrayBuffer, - DataView: $DataView -}; - -var $$29 = _export; -var global$g = global$L; -var arrayBufferModule = arrayBuffer; -var setSpecies$2 = setSpecies$7; - -var ARRAY_BUFFER = 'ArrayBuffer'; -var ArrayBuffer$4 = arrayBufferModule[ARRAY_BUFFER]; -var NativeArrayBuffer = global$g[ARRAY_BUFFER]; - -// `ArrayBuffer` constructor -// https://tc39.es/ecma262/#sec-arraybuffer-constructor -$$29({ global: true, forced: NativeArrayBuffer !== ArrayBuffer$4 }, { - ArrayBuffer: ArrayBuffer$4 -}); - -setSpecies$2(ARRAY_BUFFER); - -var NATIVE_ARRAY_BUFFER$1 = arrayBufferNative; -var DESCRIPTORS$8 = descriptors; -var global$f = global$L; -var isObject$8 = isObject$B; -var has$8 = has$o; -var classof$2 = classof$b; -var createNonEnumerableProperty$9 = createNonEnumerableProperty$m; -var redefine$2 = redefine$g.exports; -var defineProperty$3 = objectDefineProperty.f; -var getPrototypeOf$6 = objectGetPrototypeOf$1; -var setPrototypeOf$1 = objectSetPrototypeOf$1; -var wellKnownSymbol$b = wellKnownSymbol$C; -var uid = uid$5; - -var Int8Array$3 = global$f.Int8Array; -var Int8ArrayPrototype = Int8Array$3 && Int8Array$3.prototype; -var Uint8ClampedArray = global$f.Uint8ClampedArray; -var Uint8ClampedArrayPrototype = Uint8ClampedArray && Uint8ClampedArray.prototype; -var TypedArray$1 = Int8Array$3 && getPrototypeOf$6(Int8Array$3); -var TypedArrayPrototype$1 = Int8ArrayPrototype && getPrototypeOf$6(Int8ArrayPrototype); -var ObjectPrototype = Object.prototype; -var isPrototypeOf = ObjectPrototype.isPrototypeOf; - -var TO_STRING_TAG$5 = wellKnownSymbol$b('toStringTag'); -var TYPED_ARRAY_TAG$1 = uid('TYPED_ARRAY_TAG'); -// Fixing native typed arrays in Opera Presto crashes the browser, see #595 -var NATIVE_ARRAY_BUFFER_VIEWS$3 = NATIVE_ARRAY_BUFFER$1 && !!setPrototypeOf$1 && classof$2(global$f.opera) !== 'Opera'; -var TYPED_ARRAY_TAG_REQIRED = false; -var NAME; - -var TypedArrayConstructorsList = { - Int8Array: 1, - Uint8Array: 1, - Uint8ClampedArray: 1, - Int16Array: 2, - Uint16Array: 2, - Int32Array: 4, - Uint32Array: 4, - Float32Array: 4, - Float64Array: 8 -}; - -var BigIntArrayConstructorsList = { - BigInt64Array: 8, - BigUint64Array: 8 -}; - -var isView = function isView(it) { - if (!isObject$8(it)) return false; - var klass = classof$2(it); - return klass === 'DataView' - || has$8(TypedArrayConstructorsList, klass) - || has$8(BigIntArrayConstructorsList, klass); -}; - -var isTypedArray$1 = function (it) { - if (!isObject$8(it)) return false; - var klass = classof$2(it); - return has$8(TypedArrayConstructorsList, klass) - || has$8(BigIntArrayConstructorsList, klass); -}; - -var aTypedArray$o = function (it) { - if (isTypedArray$1(it)) return it; - throw TypeError('Target is not a typed array'); -}; - -var aTypedArrayConstructor$7 = function (C) { - if (setPrototypeOf$1) { - if (isPrototypeOf.call(TypedArray$1, C)) return C; - } else for (var ARRAY in TypedArrayConstructorsList) if (has$8(TypedArrayConstructorsList, NAME)) { - var TypedArrayConstructor = global$f[ARRAY]; - if (TypedArrayConstructor && (C === TypedArrayConstructor || isPrototypeOf.call(TypedArrayConstructor, C))) { - return C; - } - } throw TypeError('Target is not a typed array constructor'); -}; - -var exportTypedArrayMethod$p = function (KEY, property, forced) { - if (!DESCRIPTORS$8) return; - if (forced) for (var ARRAY in TypedArrayConstructorsList) { - var TypedArrayConstructor = global$f[ARRAY]; - if (TypedArrayConstructor && has$8(TypedArrayConstructor.prototype, KEY)) { - delete TypedArrayConstructor.prototype[KEY]; - } - } - if (!TypedArrayPrototype$1[KEY] || forced) { - redefine$2(TypedArrayPrototype$1, KEY, forced ? property - : NATIVE_ARRAY_BUFFER_VIEWS$3 && Int8ArrayPrototype[KEY] || property); - } -}; - -var exportTypedArrayStaticMethod$2 = function (KEY, property, forced) { - var ARRAY, TypedArrayConstructor; - if (!DESCRIPTORS$8) return; - if (setPrototypeOf$1) { - if (forced) for (ARRAY in TypedArrayConstructorsList) { - TypedArrayConstructor = global$f[ARRAY]; - if (TypedArrayConstructor && has$8(TypedArrayConstructor, KEY)) { - delete TypedArrayConstructor[KEY]; - } - } - if (!TypedArray$1[KEY] || forced) { - // V8 ~ Chrome 49-50 `%TypedArray%` methods are non-writable non-configurable - try { - return redefine$2(TypedArray$1, KEY, forced ? property : NATIVE_ARRAY_BUFFER_VIEWS$3 && Int8Array$3[KEY] || property); - } catch (error) { /* empty */ } - } else return; - } - for (ARRAY in TypedArrayConstructorsList) { - TypedArrayConstructor = global$f[ARRAY]; - if (TypedArrayConstructor && (!TypedArrayConstructor[KEY] || forced)) { - redefine$2(TypedArrayConstructor, KEY, property); - } - } -}; - -for (NAME in TypedArrayConstructorsList) { - if (!global$f[NAME]) NATIVE_ARRAY_BUFFER_VIEWS$3 = false; -} - -// WebKit bug - typed arrays constructors prototype is Object.prototype -if (!NATIVE_ARRAY_BUFFER_VIEWS$3 || typeof TypedArray$1 != 'function' || TypedArray$1 === Function.prototype) { - // eslint-disable-next-line no-shadow - TypedArray$1 = function TypedArray() { - throw TypeError('Incorrect invocation'); - }; - if (NATIVE_ARRAY_BUFFER_VIEWS$3) for (NAME in TypedArrayConstructorsList) { - if (global$f[NAME]) setPrototypeOf$1(global$f[NAME], TypedArray$1); - } -} - -if (!NATIVE_ARRAY_BUFFER_VIEWS$3 || !TypedArrayPrototype$1 || TypedArrayPrototype$1 === ObjectPrototype) { - TypedArrayPrototype$1 = TypedArray$1.prototype; - if (NATIVE_ARRAY_BUFFER_VIEWS$3) for (NAME in TypedArrayConstructorsList) { - if (global$f[NAME]) setPrototypeOf$1(global$f[NAME].prototype, TypedArrayPrototype$1); - } -} - -// WebKit bug - one more object in Uint8ClampedArray prototype chain -if (NATIVE_ARRAY_BUFFER_VIEWS$3 && getPrototypeOf$6(Uint8ClampedArrayPrototype) !== TypedArrayPrototype$1) { - setPrototypeOf$1(Uint8ClampedArrayPrototype, TypedArrayPrototype$1); -} - -if (DESCRIPTORS$8 && !has$8(TypedArrayPrototype$1, TO_STRING_TAG$5)) { - TYPED_ARRAY_TAG_REQIRED = true; - defineProperty$3(TypedArrayPrototype$1, TO_STRING_TAG$5, { get: function () { - return isObject$8(this) ? this[TYPED_ARRAY_TAG$1] : undefined; - } }); - for (NAME in TypedArrayConstructorsList) if (global$f[NAME]) { - createNonEnumerableProperty$9(global$f[NAME], TYPED_ARRAY_TAG$1, NAME); - } -} - -var arrayBufferViewCore = { - NATIVE_ARRAY_BUFFER_VIEWS: NATIVE_ARRAY_BUFFER_VIEWS$3, - TYPED_ARRAY_TAG: TYPED_ARRAY_TAG_REQIRED && TYPED_ARRAY_TAG$1, - aTypedArray: aTypedArray$o, - aTypedArrayConstructor: aTypedArrayConstructor$7, - exportTypedArrayMethod: exportTypedArrayMethod$p, - exportTypedArrayStaticMethod: exportTypedArrayStaticMethod$2, - isView: isView, - isTypedArray: isTypedArray$1, - TypedArray: TypedArray$1, - TypedArrayPrototype: TypedArrayPrototype$1 -}; - -var $$28 = _export; -var ArrayBufferViewCore$q = arrayBufferViewCore; - -var NATIVE_ARRAY_BUFFER_VIEWS$2 = ArrayBufferViewCore$q.NATIVE_ARRAY_BUFFER_VIEWS; - -// `ArrayBuffer.isView` method -// https://tc39.es/ecma262/#sec-arraybuffer.isview -$$28({ target: 'ArrayBuffer', stat: true, forced: !NATIVE_ARRAY_BUFFER_VIEWS$2 }, { - isView: ArrayBufferViewCore$q.isView -}); - -var $$27 = _export; -var fails$c = fails$Y; -var ArrayBufferModule$2 = arrayBuffer; -var anObject$1e = anObject$1z; -var toAbsoluteIndex$1 = toAbsoluteIndex$8; -var toLength$9 = toLength$y; -var speciesConstructor$e = speciesConstructor$j; - -var ArrayBuffer$3 = ArrayBufferModule$2.ArrayBuffer; -var DataView$2 = ArrayBufferModule$2.DataView; -var nativeArrayBufferSlice = ArrayBuffer$3.prototype.slice; - -var INCORRECT_SLICE = fails$c(function () { - return !new ArrayBuffer$3(2).slice(1, undefined).byteLength; -}); - -// `ArrayBuffer.prototype.slice` method -// https://tc39.es/ecma262/#sec-arraybuffer.prototype.slice -$$27({ target: 'ArrayBuffer', proto: true, unsafe: true, forced: INCORRECT_SLICE }, { - slice: function slice(start, end) { - if (nativeArrayBufferSlice !== undefined && end === undefined) { - return nativeArrayBufferSlice.call(anObject$1e(this), start); // FF fix - } - var length = anObject$1e(this).byteLength; - var first = toAbsoluteIndex$1(start, length); - var fin = toAbsoluteIndex$1(end === undefined ? length : end, length); - var result = new (speciesConstructor$e(this, ArrayBuffer$3))(toLength$9(fin - first)); - var viewSource = new DataView$2(this); - var viewTarget = new DataView$2(result); - var index = 0; - while (first < fin) { - viewTarget.setUint8(index++, viewSource.getUint8(first++)); - } return result; - } -}); - -var $$26 = _export; -var ArrayBufferModule$1 = arrayBuffer; -var NATIVE_ARRAY_BUFFER = arrayBufferNative; - -// `DataView` constructor -// https://tc39.es/ecma262/#sec-dataview-constructor -$$26({ global: true, forced: !NATIVE_ARRAY_BUFFER }, { - DataView: ArrayBufferModule$1.DataView -}); + path = globalThis; + return path; +} -var typedArrayConstructor = {exports: {}}; +var wellKnownSymbolDefine; +var hasRequiredWellKnownSymbolDefine; + +function requireWellKnownSymbolDefine () { + if (hasRequiredWellKnownSymbolDefine) return wellKnownSymbolDefine; + hasRequiredWellKnownSymbolDefine = 1; + var path = requirePath(); + var hasOwn = requireHasOwnProperty(); + var wrappedWellKnownSymbolModule = requireWellKnownSymbolWrapped(); + var defineProperty = requireObjectDefineProperty().f; + + wellKnownSymbolDefine = function (NAME) { + var Symbol = path.Symbol || (path.Symbol = {}); + if (!hasOwn(Symbol, NAME)) defineProperty(Symbol, NAME, { + value: wrappedWellKnownSymbolModule.f(NAME) + }); + }; + return wellKnownSymbolDefine; +} + +var symbolDefineToPrimitive; +var hasRequiredSymbolDefineToPrimitive; + +function requireSymbolDefineToPrimitive () { + if (hasRequiredSymbolDefineToPrimitive) return symbolDefineToPrimitive; + hasRequiredSymbolDefineToPrimitive = 1; + var call = requireFunctionCall(); + var getBuiltIn = requireGetBuiltIn(); + var wellKnownSymbol = requireWellKnownSymbol(); + var defineBuiltIn = requireDefineBuiltIn(); + + symbolDefineToPrimitive = function () { + var Symbol = getBuiltIn('Symbol'); + var SymbolPrototype = Symbol && Symbol.prototype; + var valueOf = SymbolPrototype && SymbolPrototype.valueOf; + var TO_PRIMITIVE = wellKnownSymbol('toPrimitive'); + + if (SymbolPrototype && !SymbolPrototype[TO_PRIMITIVE]) { + // `Symbol.prototype[@@toPrimitive]` method + // https://tc39.es/ecma262/#sec-symbol.prototype-@@toprimitive + // eslint-disable-next-line no-unused-vars -- required for .length + defineBuiltIn(SymbolPrototype, TO_PRIMITIVE, function (hint) { + return call(valueOf, this); + }, { arity: 1 }); + } + }; + return symbolDefineToPrimitive; +} + +var setToStringTag; +var hasRequiredSetToStringTag; + +function requireSetToStringTag () { + if (hasRequiredSetToStringTag) return setToStringTag; + hasRequiredSetToStringTag = 1; + var defineProperty = requireObjectDefineProperty().f; + var hasOwn = requireHasOwnProperty(); + var wellKnownSymbol = requireWellKnownSymbol(); + + var TO_STRING_TAG = wellKnownSymbol('toStringTag'); + + setToStringTag = function (target, TAG, STATIC) { + if (target && !STATIC) target = target.prototype; + if (target && !hasOwn(target, TO_STRING_TAG)) { + defineProperty(target, TO_STRING_TAG, { configurable: true, value: TAG }); + } + }; + return setToStringTag; +} + +var functionUncurryThisClause; +var hasRequiredFunctionUncurryThisClause; + +function requireFunctionUncurryThisClause () { + if (hasRequiredFunctionUncurryThisClause) return functionUncurryThisClause; + hasRequiredFunctionUncurryThisClause = 1; + var classofRaw = requireClassofRaw(); + var uncurryThis = requireFunctionUncurryThis(); + + functionUncurryThisClause = function (fn) { + // Nashorn bug: + // https://github.com/zloirock/core-js/issues/1128 + // https://github.com/zloirock/core-js/issues/1130 + if (classofRaw(fn) === 'Function') return uncurryThis(fn); + }; + return functionUncurryThisClause; +} + +var functionBindContext; +var hasRequiredFunctionBindContext; + +function requireFunctionBindContext () { + if (hasRequiredFunctionBindContext) return functionBindContext; + hasRequiredFunctionBindContext = 1; + var uncurryThis = requireFunctionUncurryThisClause(); + var aCallable = requireACallable(); + var NATIVE_BIND = requireFunctionBindNative(); + + var bind = uncurryThis(uncurryThis.bind); + + // optional / simple context binding + functionBindContext = function (fn, that) { + aCallable(fn); + return that === undefined ? fn : NATIVE_BIND ? bind(fn, that) : function (/* ...args */) { + return fn.apply(that, arguments); + }; + }; + return functionBindContext; +} + +var isArray; +var hasRequiredIsArray; + +function requireIsArray () { + if (hasRequiredIsArray) return isArray; + hasRequiredIsArray = 1; + var classof = requireClassofRaw(); + + // `IsArray` abstract operation + // https://tc39.es/ecma262/#sec-isarray + // eslint-disable-next-line es/no-array-isarray -- safe + isArray = Array.isArray || function isArray(argument) { + return classof(argument) === 'Array'; + }; + return isArray; +} + +var isConstructor; +var hasRequiredIsConstructor; + +function requireIsConstructor () { + if (hasRequiredIsConstructor) return isConstructor; + hasRequiredIsConstructor = 1; + var uncurryThis = requireFunctionUncurryThis(); + var fails = requireFails(); + var isCallable = requireIsCallable(); + var classof = requireClassof(); + var getBuiltIn = requireGetBuiltIn(); + var inspectSource = requireInspectSource(); + + var noop = function () { /* empty */ }; + var construct = getBuiltIn('Reflect', 'construct'); + var constructorRegExp = /^\s*(?:class|function)\b/; + var exec = uncurryThis(constructorRegExp.exec); + var INCORRECT_TO_STRING = !constructorRegExp.test(noop); + + var isConstructorModern = function isConstructor(argument) { + if (!isCallable(argument)) return false; + try { + construct(noop, [], argument); + return true; + } catch (error) { + return false; + } + }; + + var isConstructorLegacy = function isConstructor(argument) { + if (!isCallable(argument)) return false; + switch (classof(argument)) { + case 'AsyncFunction': + case 'GeneratorFunction': + case 'AsyncGeneratorFunction': return false; + } + try { + // we can't check .prototype since constructors produced by .bind haven't it + // `Function#toString` throws on some built-it function in some legacy engines + // (for example, `DOMQuad` and similar in FF41-) + return INCORRECT_TO_STRING || !!exec(constructorRegExp, inspectSource(argument)); + } catch (error) { + return true; + } + }; + + isConstructorLegacy.sham = true; + + // `IsConstructor` abstract operation + // https://tc39.es/ecma262/#sec-isconstructor + isConstructor = !construct || fails(function () { + var called; + return isConstructorModern(isConstructorModern.call) + || !isConstructorModern(Object) + || !isConstructorModern(function () { called = true; }) + || called; + }) ? isConstructorLegacy : isConstructorModern; + return isConstructor; +} + +var arraySpeciesConstructor; +var hasRequiredArraySpeciesConstructor; + +function requireArraySpeciesConstructor () { + if (hasRequiredArraySpeciesConstructor) return arraySpeciesConstructor; + hasRequiredArraySpeciesConstructor = 1; + var isArray = requireIsArray(); + var isConstructor = requireIsConstructor(); + var isObject = requireIsObject(); + var wellKnownSymbol = requireWellKnownSymbol(); + + var SPECIES = wellKnownSymbol('species'); + var $Array = Array; + + // a part of `ArraySpeciesCreate` abstract operation + // https://tc39.es/ecma262/#sec-arrayspeciescreate + arraySpeciesConstructor = function (originalArray) { + var C; + if (isArray(originalArray)) { + C = originalArray.constructor; + // cross-realm fallback + if (isConstructor(C) && (C === $Array || isArray(C.prototype))) C = undefined; + else if (isObject(C)) { + C = C[SPECIES]; + if (C === null) C = undefined; + } + } return C === undefined ? $Array : C; + }; + return arraySpeciesConstructor; +} + +var arraySpeciesCreate; +var hasRequiredArraySpeciesCreate; + +function requireArraySpeciesCreate () { + if (hasRequiredArraySpeciesCreate) return arraySpeciesCreate; + hasRequiredArraySpeciesCreate = 1; + var arraySpeciesConstructor = requireArraySpeciesConstructor(); + + // `ArraySpeciesCreate` abstract operation + // https://tc39.es/ecma262/#sec-arrayspeciescreate + arraySpeciesCreate = function (originalArray, length) { + return new (arraySpeciesConstructor(originalArray))(length === 0 ? 0 : length); + }; + return arraySpeciesCreate; +} + +var arrayIteration; +var hasRequiredArrayIteration; + +function requireArrayIteration () { + if (hasRequiredArrayIteration) return arrayIteration; + hasRequiredArrayIteration = 1; + var bind = requireFunctionBindContext(); + var uncurryThis = requireFunctionUncurryThis(); + var IndexedObject = requireIndexedObject(); + var toObject = requireToObject(); + var lengthOfArrayLike = requireLengthOfArrayLike(); + var arraySpeciesCreate = requireArraySpeciesCreate(); + + var push = uncurryThis([].push); + + // `Array.prototype.{ forEach, map, filter, some, every, find, findIndex, filterReject }` methods implementation + var createMethod = function (TYPE) { + var IS_MAP = TYPE === 1; + var IS_FILTER = TYPE === 2; + var IS_SOME = TYPE === 3; + var IS_EVERY = TYPE === 4; + var IS_FIND_INDEX = TYPE === 6; + var IS_FILTER_REJECT = TYPE === 7; + var NO_HOLES = TYPE === 5 || IS_FIND_INDEX; + return function ($this, callbackfn, that, specificCreate) { + var O = toObject($this); + var self = IndexedObject(O); + var length = lengthOfArrayLike(self); + var boundFunction = bind(callbackfn, that); + var index = 0; + var create = specificCreate || arraySpeciesCreate; + var target = IS_MAP ? create($this, length) : IS_FILTER || IS_FILTER_REJECT ? create($this, 0) : undefined; + var value, result; + for (;length > index; index++) if (NO_HOLES || index in self) { + value = self[index]; + result = boundFunction(value, index, O); + if (TYPE) { + if (IS_MAP) target[index] = result; // map + else if (result) switch (TYPE) { + case 3: return true; // some + case 5: return value; // find + case 6: return index; // findIndex + case 2: push(target, value); // filter + } else switch (TYPE) { + case 4: return false; // every + case 7: push(target, value); // filterReject + } + } + } + return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : target; + }; + }; + + arrayIteration = { + // `Array.prototype.forEach` method + // https://tc39.es/ecma262/#sec-array.prototype.foreach + forEach: createMethod(0), + // `Array.prototype.map` method + // https://tc39.es/ecma262/#sec-array.prototype.map + map: createMethod(1), + // `Array.prototype.filter` method + // https://tc39.es/ecma262/#sec-array.prototype.filter + filter: createMethod(2), + // `Array.prototype.some` method + // https://tc39.es/ecma262/#sec-array.prototype.some + some: createMethod(3), + // `Array.prototype.every` method + // https://tc39.es/ecma262/#sec-array.prototype.every + every: createMethod(4), + // `Array.prototype.find` method + // https://tc39.es/ecma262/#sec-array.prototype.find + find: createMethod(5), + // `Array.prototype.findIndex` method + // https://tc39.es/ecma262/#sec-array.prototype.findIndex + findIndex: createMethod(6), + // `Array.prototype.filterReject` method + // https://github.com/tc39/proposal-array-filtering + filterReject: createMethod(7) + }; + return arrayIteration; +} + +var hasRequiredEs_symbol_constructor; + +function requireEs_symbol_constructor () { + if (hasRequiredEs_symbol_constructor) return es_symbol_constructor; + hasRequiredEs_symbol_constructor = 1; + var $ = require_export(); + var globalThis = requireGlobalThis(); + var call = requireFunctionCall(); + var uncurryThis = requireFunctionUncurryThis(); + var IS_PURE = requireIsPure(); + var DESCRIPTORS = requireDescriptors(); + var NATIVE_SYMBOL = requireSymbolConstructorDetection(); + var fails = requireFails(); + var hasOwn = requireHasOwnProperty(); + var isPrototypeOf = requireObjectIsPrototypeOf(); + var anObject = requireAnObject(); + var toIndexedObject = requireToIndexedObject(); + var toPropertyKey = requireToPropertyKey(); + var $toString = requireToString(); + var createPropertyDescriptor = requireCreatePropertyDescriptor(); + var nativeObjectCreate = requireObjectCreate(); + var objectKeys = requireObjectKeys(); + var getOwnPropertyNamesModule = requireObjectGetOwnPropertyNames(); + var getOwnPropertyNamesExternal = requireObjectGetOwnPropertyNamesExternal(); + var getOwnPropertySymbolsModule = requireObjectGetOwnPropertySymbols(); + var getOwnPropertyDescriptorModule = requireObjectGetOwnPropertyDescriptor(); + var definePropertyModule = requireObjectDefineProperty(); + var definePropertiesModule = requireObjectDefineProperties(); + var propertyIsEnumerableModule = requireObjectPropertyIsEnumerable(); + var defineBuiltIn = requireDefineBuiltIn(); + var defineBuiltInAccessor = requireDefineBuiltInAccessor(); + var shared = requireShared(); + var sharedKey = requireSharedKey(); + var hiddenKeys = requireHiddenKeys(); + var uid = requireUid(); + var wellKnownSymbol = requireWellKnownSymbol(); + var wrappedWellKnownSymbolModule = requireWellKnownSymbolWrapped(); + var defineWellKnownSymbol = requireWellKnownSymbolDefine(); + var defineSymbolToPrimitive = requireSymbolDefineToPrimitive(); + var setToStringTag = requireSetToStringTag(); + var InternalStateModule = requireInternalState(); + var $forEach = requireArrayIteration().forEach; + + var HIDDEN = sharedKey('hidden'); + var SYMBOL = 'Symbol'; + var PROTOTYPE = 'prototype'; + + var setInternalState = InternalStateModule.set; + var getInternalState = InternalStateModule.getterFor(SYMBOL); + + var ObjectPrototype = Object[PROTOTYPE]; + var $Symbol = globalThis.Symbol; + var SymbolPrototype = $Symbol && $Symbol[PROTOTYPE]; + var RangeError = globalThis.RangeError; + var TypeError = globalThis.TypeError; + var QObject = globalThis.QObject; + var nativeGetOwnPropertyDescriptor = getOwnPropertyDescriptorModule.f; + var nativeDefineProperty = definePropertyModule.f; + var nativeGetOwnPropertyNames = getOwnPropertyNamesExternal.f; + var nativePropertyIsEnumerable = propertyIsEnumerableModule.f; + var push = uncurryThis([].push); + + var AllSymbols = shared('symbols'); + var ObjectPrototypeSymbols = shared('op-symbols'); + var WellKnownSymbolsStore = shared('wks'); + + // Don't use setters in Qt Script, https://github.com/zloirock/core-js/issues/173 + var USE_SETTER = !QObject || !QObject[PROTOTYPE] || !QObject[PROTOTYPE].findChild; + + // fallback for old Android, https://code.google.com/p/v8/issues/detail?id=687 + var fallbackDefineProperty = function (O, P, Attributes) { + var ObjectPrototypeDescriptor = nativeGetOwnPropertyDescriptor(ObjectPrototype, P); + if (ObjectPrototypeDescriptor) delete ObjectPrototype[P]; + nativeDefineProperty(O, P, Attributes); + if (ObjectPrototypeDescriptor && O !== ObjectPrototype) { + nativeDefineProperty(ObjectPrototype, P, ObjectPrototypeDescriptor); + } + }; + + var setSymbolDescriptor = DESCRIPTORS && fails(function () { + return nativeObjectCreate(nativeDefineProperty({}, 'a', { + get: function () { return nativeDefineProperty(this, 'a', { value: 7 }).a; } + })).a !== 7; + }) ? fallbackDefineProperty : nativeDefineProperty; + + var wrap = function (tag, description) { + var symbol = AllSymbols[tag] = nativeObjectCreate(SymbolPrototype); + setInternalState(symbol, { + type: SYMBOL, + tag: tag, + description: description + }); + if (!DESCRIPTORS) symbol.description = description; + return symbol; + }; + + var $defineProperty = function defineProperty(O, P, Attributes) { + if (O === ObjectPrototype) $defineProperty(ObjectPrototypeSymbols, P, Attributes); + anObject(O); + var key = toPropertyKey(P); + anObject(Attributes); + if (hasOwn(AllSymbols, key)) { + if (!Attributes.enumerable) { + if (!hasOwn(O, HIDDEN)) nativeDefineProperty(O, HIDDEN, createPropertyDescriptor(1, nativeObjectCreate(null))); + O[HIDDEN][key] = true; + } else { + if (hasOwn(O, HIDDEN) && O[HIDDEN][key]) O[HIDDEN][key] = false; + Attributes = nativeObjectCreate(Attributes, { enumerable: createPropertyDescriptor(0, false) }); + } return setSymbolDescriptor(O, key, Attributes); + } return nativeDefineProperty(O, key, Attributes); + }; + + var $defineProperties = function defineProperties(O, Properties) { + anObject(O); + var properties = toIndexedObject(Properties); + var keys = objectKeys(properties).concat($getOwnPropertySymbols(properties)); + $forEach(keys, function (key) { + if (!DESCRIPTORS || call($propertyIsEnumerable, properties, key)) $defineProperty(O, key, properties[key]); + }); + return O; + }; + + var $create = function create(O, Properties) { + return Properties === undefined ? nativeObjectCreate(O) : $defineProperties(nativeObjectCreate(O), Properties); + }; + + var $propertyIsEnumerable = function propertyIsEnumerable(V) { + var P = toPropertyKey(V); + var enumerable = call(nativePropertyIsEnumerable, this, P); + if (this === ObjectPrototype && hasOwn(AllSymbols, P) && !hasOwn(ObjectPrototypeSymbols, P)) return false; + return enumerable || !hasOwn(this, P) || !hasOwn(AllSymbols, P) || hasOwn(this, HIDDEN) && this[HIDDEN][P] + ? enumerable : true; + }; + + var $getOwnPropertyDescriptor = function getOwnPropertyDescriptor(O, P) { + var it = toIndexedObject(O); + var key = toPropertyKey(P); + if (it === ObjectPrototype && hasOwn(AllSymbols, key) && !hasOwn(ObjectPrototypeSymbols, key)) return; + var descriptor = nativeGetOwnPropertyDescriptor(it, key); + if (descriptor && hasOwn(AllSymbols, key) && !(hasOwn(it, HIDDEN) && it[HIDDEN][key])) { + descriptor.enumerable = true; + } + return descriptor; + }; + + var $getOwnPropertyNames = function getOwnPropertyNames(O) { + var names = nativeGetOwnPropertyNames(toIndexedObject(O)); + var result = []; + $forEach(names, function (key) { + if (!hasOwn(AllSymbols, key) && !hasOwn(hiddenKeys, key)) push(result, key); + }); + return result; + }; + + var $getOwnPropertySymbols = function (O) { + var IS_OBJECT_PROTOTYPE = O === ObjectPrototype; + var names = nativeGetOwnPropertyNames(IS_OBJECT_PROTOTYPE ? ObjectPrototypeSymbols : toIndexedObject(O)); + var result = []; + $forEach(names, function (key) { + if (hasOwn(AllSymbols, key) && (!IS_OBJECT_PROTOTYPE || hasOwn(ObjectPrototype, key))) { + push(result, AllSymbols[key]); + } + }); + return result; + }; + + // `Symbol` constructor + // https://tc39.es/ecma262/#sec-symbol-constructor + if (!NATIVE_SYMBOL) { + $Symbol = function Symbol() { + if (isPrototypeOf(SymbolPrototype, this)) throw new TypeError('Symbol is not a constructor'); + var description = !arguments.length || arguments[0] === undefined ? undefined : $toString(arguments[0]); + var tag = uid(description); + var setter = function (value) { + var $this = this === undefined ? globalThis : this; + if ($this === ObjectPrototype) call(setter, ObjectPrototypeSymbols, value); + if (hasOwn($this, HIDDEN) && hasOwn($this[HIDDEN], tag)) $this[HIDDEN][tag] = false; + var descriptor = createPropertyDescriptor(1, value); + try { + setSymbolDescriptor($this, tag, descriptor); + } catch (error) { + if (!(error instanceof RangeError)) throw error; + fallbackDefineProperty($this, tag, descriptor); + } + }; + if (DESCRIPTORS && USE_SETTER) setSymbolDescriptor(ObjectPrototype, tag, { configurable: true, set: setter }); + return wrap(tag, description); + }; + + SymbolPrototype = $Symbol[PROTOTYPE]; + + defineBuiltIn(SymbolPrototype, 'toString', function toString() { + return getInternalState(this).tag; + }); + + defineBuiltIn($Symbol, 'withoutSetter', function (description) { + return wrap(uid(description), description); + }); + + propertyIsEnumerableModule.f = $propertyIsEnumerable; + definePropertyModule.f = $defineProperty; + definePropertiesModule.f = $defineProperties; + getOwnPropertyDescriptorModule.f = $getOwnPropertyDescriptor; + getOwnPropertyNamesModule.f = getOwnPropertyNamesExternal.f = $getOwnPropertyNames; + getOwnPropertySymbolsModule.f = $getOwnPropertySymbols; + + wrappedWellKnownSymbolModule.f = function (name) { + return wrap(wellKnownSymbol(name), name); + }; + + if (DESCRIPTORS) { + // https://github.com/tc39/proposal-Symbol-description + defineBuiltInAccessor(SymbolPrototype, 'description', { + configurable: true, + get: function description() { + return getInternalState(this).description; + } + }); + if (!IS_PURE) { + defineBuiltIn(ObjectPrototype, 'propertyIsEnumerable', $propertyIsEnumerable, { unsafe: true }); + } + } + } + + $({ global: true, constructor: true, wrap: true, forced: !NATIVE_SYMBOL, sham: !NATIVE_SYMBOL }, { + Symbol: $Symbol + }); + + $forEach(objectKeys(WellKnownSymbolsStore), function (name) { + defineWellKnownSymbol(name); + }); + + $({ target: SYMBOL, stat: true, forced: !NATIVE_SYMBOL }, { + useSetter: function () { USE_SETTER = true; }, + useSimple: function () { USE_SETTER = false; } + }); + + $({ target: 'Object', stat: true, forced: !NATIVE_SYMBOL, sham: !DESCRIPTORS }, { + // `Object.create` method + // https://tc39.es/ecma262/#sec-object.create + create: $create, + // `Object.defineProperty` method + // https://tc39.es/ecma262/#sec-object.defineproperty + defineProperty: $defineProperty, + // `Object.defineProperties` method + // https://tc39.es/ecma262/#sec-object.defineproperties + defineProperties: $defineProperties, + // `Object.getOwnPropertyDescriptor` method + // https://tc39.es/ecma262/#sec-object.getownpropertydescriptors + getOwnPropertyDescriptor: $getOwnPropertyDescriptor + }); + + $({ target: 'Object', stat: true, forced: !NATIVE_SYMBOL }, { + // `Object.getOwnPropertyNames` method + // https://tc39.es/ecma262/#sec-object.getownpropertynames + getOwnPropertyNames: $getOwnPropertyNames + }); + + // `Symbol.prototype[@@toPrimitive]` method + // https://tc39.es/ecma262/#sec-symbol.prototype-@@toprimitive + defineSymbolToPrimitive(); + + // `Symbol.prototype[@@toStringTag]` property + // https://tc39.es/ecma262/#sec-symbol.prototype-@@tostringtag + setToStringTag($Symbol, SYMBOL); + + hiddenKeys[HIDDEN] = true; + return es_symbol_constructor; +} + +var es_symbol_for = {}; + +var symbolRegistryDetection; +var hasRequiredSymbolRegistryDetection; + +function requireSymbolRegistryDetection () { + if (hasRequiredSymbolRegistryDetection) return symbolRegistryDetection; + hasRequiredSymbolRegistryDetection = 1; + var NATIVE_SYMBOL = requireSymbolConstructorDetection(); + + /* eslint-disable es/no-symbol -- safe */ + symbolRegistryDetection = NATIVE_SYMBOL && !!Symbol['for'] && !!Symbol.keyFor; + return symbolRegistryDetection; +} + +var hasRequiredEs_symbol_for; + +function requireEs_symbol_for () { + if (hasRequiredEs_symbol_for) return es_symbol_for; + hasRequiredEs_symbol_for = 1; + var $ = require_export(); + var getBuiltIn = requireGetBuiltIn(); + var hasOwn = requireHasOwnProperty(); + var toString = requireToString(); + var shared = requireShared(); + var NATIVE_SYMBOL_REGISTRY = requireSymbolRegistryDetection(); + + var StringToSymbolRegistry = shared('string-to-symbol-registry'); + var SymbolToStringRegistry = shared('symbol-to-string-registry'); + + // `Symbol.for` method + // https://tc39.es/ecma262/#sec-symbol.for + $({ target: 'Symbol', stat: true, forced: !NATIVE_SYMBOL_REGISTRY }, { + 'for': function (key) { + var string = toString(key); + if (hasOwn(StringToSymbolRegistry, string)) return StringToSymbolRegistry[string]; + var symbol = getBuiltIn('Symbol')(string); + StringToSymbolRegistry[string] = symbol; + SymbolToStringRegistry[symbol] = string; + return symbol; + } + }); + return es_symbol_for; +} + +var es_symbol_keyFor = {}; + +var hasRequiredEs_symbol_keyFor; + +function requireEs_symbol_keyFor () { + if (hasRequiredEs_symbol_keyFor) return es_symbol_keyFor; + hasRequiredEs_symbol_keyFor = 1; + var $ = require_export(); + var hasOwn = requireHasOwnProperty(); + var isSymbol = requireIsSymbol(); + var tryToString = requireTryToString(); + var shared = requireShared(); + var NATIVE_SYMBOL_REGISTRY = requireSymbolRegistryDetection(); + + var SymbolToStringRegistry = shared('symbol-to-string-registry'); + + // `Symbol.keyFor` method + // https://tc39.es/ecma262/#sec-symbol.keyfor + $({ target: 'Symbol', stat: true, forced: !NATIVE_SYMBOL_REGISTRY }, { + keyFor: function keyFor(sym) { + if (!isSymbol(sym)) throw new TypeError(tryToString(sym) + ' is not a symbol'); + if (hasOwn(SymbolToStringRegistry, sym)) return SymbolToStringRegistry[sym]; + } + }); + return es_symbol_keyFor; +} + +var es_json_stringify = {}; + +var functionApply; +var hasRequiredFunctionApply; + +function requireFunctionApply () { + if (hasRequiredFunctionApply) return functionApply; + hasRequiredFunctionApply = 1; + var NATIVE_BIND = requireFunctionBindNative(); + + var FunctionPrototype = Function.prototype; + var apply = FunctionPrototype.apply; + var call = FunctionPrototype.call; + + // eslint-disable-next-line es/no-reflect -- safe + functionApply = typeof Reflect == 'object' && Reflect.apply || (NATIVE_BIND ? call.bind(apply) : function () { + return call.apply(apply, arguments); + }); + return functionApply; +} + +var getJsonReplacerFunction; +var hasRequiredGetJsonReplacerFunction; + +function requireGetJsonReplacerFunction () { + if (hasRequiredGetJsonReplacerFunction) return getJsonReplacerFunction; + hasRequiredGetJsonReplacerFunction = 1; + var uncurryThis = requireFunctionUncurryThis(); + var isArray = requireIsArray(); + var isCallable = requireIsCallable(); + var classof = requireClassofRaw(); + var toString = requireToString(); + + var push = uncurryThis([].push); + + getJsonReplacerFunction = function (replacer) { + if (isCallable(replacer)) return replacer; + if (!isArray(replacer)) return; + var rawLength = replacer.length; + var keys = []; + for (var i = 0; i < rawLength; i++) { + var element = replacer[i]; + if (typeof element == 'string') push(keys, element); + else if (typeof element == 'number' || classof(element) === 'Number' || classof(element) === 'String') push(keys, toString(element)); + } + var keysLength = keys.length; + var root = true; + return function (key, value) { + if (root) { + root = false; + return value; + } + if (isArray(this)) return value; + for (var j = 0; j < keysLength; j++) if (keys[j] === key) return value; + }; + }; + return getJsonReplacerFunction; +} + +var hasRequiredEs_json_stringify; + +function requireEs_json_stringify () { + if (hasRequiredEs_json_stringify) return es_json_stringify; + hasRequiredEs_json_stringify = 1; + var $ = require_export(); + var getBuiltIn = requireGetBuiltIn(); + var apply = requireFunctionApply(); + var call = requireFunctionCall(); + var uncurryThis = requireFunctionUncurryThis(); + var fails = requireFails(); + var isCallable = requireIsCallable(); + var isSymbol = requireIsSymbol(); + var arraySlice = requireArraySlice(); + var getReplacerFunction = requireGetJsonReplacerFunction(); + var NATIVE_SYMBOL = requireSymbolConstructorDetection(); + + var $String = String; + var $stringify = getBuiltIn('JSON', 'stringify'); + var exec = uncurryThis(/./.exec); + var charAt = uncurryThis(''.charAt); + var charCodeAt = uncurryThis(''.charCodeAt); + var replace = uncurryThis(''.replace); + var numberToString = uncurryThis(1.0.toString); + + var tester = /[\uD800-\uDFFF]/g; + var low = /^[\uD800-\uDBFF]$/; + var hi = /^[\uDC00-\uDFFF]$/; + + var WRONG_SYMBOLS_CONVERSION = !NATIVE_SYMBOL || fails(function () { + var symbol = getBuiltIn('Symbol')('stringify detection'); + // MS Edge converts symbol values to JSON as {} + return $stringify([symbol]) !== '[null]' + // WebKit converts symbol values to JSON as null + || $stringify({ a: symbol }) !== '{}' + // V8 throws on boxed symbols + || $stringify(Object(symbol)) !== '{}'; + }); + + // https://github.com/tc39/proposal-well-formed-stringify + var ILL_FORMED_UNICODE = fails(function () { + return $stringify('\uDF06\uD834') !== '"\\udf06\\ud834"' + || $stringify('\uDEAD') !== '"\\udead"'; + }); + + var stringifyWithSymbolsFix = function (it, replacer) { + var args = arraySlice(arguments); + var $replacer = getReplacerFunction(replacer); + if (!isCallable($replacer) && (it === undefined || isSymbol(it))) return; // IE8 returns string on undefined + args[1] = function (key, value) { + // some old implementations (like WebKit) could pass numbers as keys + if (isCallable($replacer)) value = call($replacer, this, $String(key), value); + if (!isSymbol(value)) return value; + }; + return apply($stringify, null, args); + }; + + var fixIllFormed = function (match, offset, string) { + var prev = charAt(string, offset - 1); + var next = charAt(string, offset + 1); + if ((exec(low, match) && !exec(hi, next)) || (exec(hi, match) && !exec(low, prev))) { + return '\\u' + numberToString(charCodeAt(match, 0), 16); + } return match; + }; + + if ($stringify) { + // `JSON.stringify` method + // https://tc39.es/ecma262/#sec-json.stringify + $({ target: 'JSON', stat: true, arity: 3, forced: WRONG_SYMBOLS_CONVERSION || ILL_FORMED_UNICODE }, { + // eslint-disable-next-line no-unused-vars -- required for `.length` + stringify: function stringify(it, replacer, space) { + var args = arraySlice(arguments); + var result = apply(WRONG_SYMBOLS_CONVERSION ? stringifyWithSymbolsFix : $stringify, null, args); + return ILL_FORMED_UNICODE && typeof result == 'string' ? replace(result, tester, fixIllFormed) : result; + } + }); + } + return es_json_stringify; +} + +var es_object_getOwnPropertySymbols = {}; + +var hasRequiredEs_object_getOwnPropertySymbols; + +function requireEs_object_getOwnPropertySymbols () { + if (hasRequiredEs_object_getOwnPropertySymbols) return es_object_getOwnPropertySymbols; + hasRequiredEs_object_getOwnPropertySymbols = 1; + var $ = require_export(); + var NATIVE_SYMBOL = requireSymbolConstructorDetection(); + var fails = requireFails(); + var getOwnPropertySymbolsModule = requireObjectGetOwnPropertySymbols(); + var toObject = requireToObject(); + + // V8 ~ Chrome 38 and 39 `Object.getOwnPropertySymbols` fails on primitives + // https://bugs.chromium.org/p/v8/issues/detail?id=3443 + var FORCED = !NATIVE_SYMBOL || fails(function () { getOwnPropertySymbolsModule.f(1); }); + + // `Object.getOwnPropertySymbols` method + // https://tc39.es/ecma262/#sec-object.getownpropertysymbols + $({ target: 'Object', stat: true, forced: FORCED }, { + getOwnPropertySymbols: function getOwnPropertySymbols(it) { + var $getOwnPropertySymbols = getOwnPropertySymbolsModule.f; + return $getOwnPropertySymbols ? $getOwnPropertySymbols(toObject(it)) : []; + } + }); + return es_object_getOwnPropertySymbols; +} + +var hasRequiredEs_symbol; + +function requireEs_symbol () { + if (hasRequiredEs_symbol) return es_symbol; + hasRequiredEs_symbol = 1; + // TODO: Remove this module from `core-js@4` since it's split to modules listed below + requireEs_symbol_constructor(); + requireEs_symbol_for(); + requireEs_symbol_keyFor(); + requireEs_json_stringify(); + requireEs_object_getOwnPropertySymbols(); + return es_symbol; +} + +var es_symbol_description = {}; + +var hasRequiredEs_symbol_description; + +function requireEs_symbol_description () { + if (hasRequiredEs_symbol_description) return es_symbol_description; + hasRequiredEs_symbol_description = 1; + var $ = require_export(); + var DESCRIPTORS = requireDescriptors(); + var globalThis = requireGlobalThis(); + var uncurryThis = requireFunctionUncurryThis(); + var hasOwn = requireHasOwnProperty(); + var isCallable = requireIsCallable(); + var isPrototypeOf = requireObjectIsPrototypeOf(); + var toString = requireToString(); + var defineBuiltInAccessor = requireDefineBuiltInAccessor(); + var copyConstructorProperties = requireCopyConstructorProperties(); + + var NativeSymbol = globalThis.Symbol; + var SymbolPrototype = NativeSymbol && NativeSymbol.prototype; + + if (DESCRIPTORS && isCallable(NativeSymbol) && (!('description' in SymbolPrototype) || + // Safari 12 bug + NativeSymbol().description !== undefined + )) { + var EmptyStringDescriptionStore = {}; + // wrap Symbol constructor for correct work with undefined description + var SymbolWrapper = function Symbol() { + var description = arguments.length < 1 || arguments[0] === undefined ? undefined : toString(arguments[0]); + var result = isPrototypeOf(SymbolPrototype, this) + // eslint-disable-next-line sonar/inconsistent-function-call -- ok + ? new NativeSymbol(description) + // in Edge 13, String(Symbol(undefined)) === 'Symbol(undefined)' + : description === undefined ? NativeSymbol() : NativeSymbol(description); + if (description === '') EmptyStringDescriptionStore[result] = true; + return result; + }; + + copyConstructorProperties(SymbolWrapper, NativeSymbol); + SymbolWrapper.prototype = SymbolPrototype; + SymbolPrototype.constructor = SymbolWrapper; + + var NATIVE_SYMBOL = String(NativeSymbol('description detection')) === 'Symbol(description detection)'; + var thisSymbolValue = uncurryThis(SymbolPrototype.valueOf); + var symbolDescriptiveString = uncurryThis(SymbolPrototype.toString); + var regexp = /^Symbol\((.*)\)[^)]+$/; + var replace = uncurryThis(''.replace); + var stringSlice = uncurryThis(''.slice); + + defineBuiltInAccessor(SymbolPrototype, 'description', { + configurable: true, + get: function description() { + var symbol = thisSymbolValue(this); + if (hasOwn(EmptyStringDescriptionStore, symbol)) return ''; + var string = symbolDescriptiveString(symbol); + var desc = NATIVE_SYMBOL ? stringSlice(string, 7, -1) : replace(string, regexp, '$1'); + return desc === '' ? undefined : desc; + } + }); + + $({ global: true, constructor: true, forced: true }, { + Symbol: SymbolWrapper + }); + } + return es_symbol_description; +} + +var es_symbol_asyncIterator = {}; + +var hasRequiredEs_symbol_asyncIterator; + +function requireEs_symbol_asyncIterator () { + if (hasRequiredEs_symbol_asyncIterator) return es_symbol_asyncIterator; + hasRequiredEs_symbol_asyncIterator = 1; + var defineWellKnownSymbol = requireWellKnownSymbolDefine(); + + // `Symbol.asyncIterator` well-known symbol + // https://tc39.es/ecma262/#sec-symbol.asynciterator + defineWellKnownSymbol('asyncIterator'); + return es_symbol_asyncIterator; +} + +var es_symbol_hasInstance = {}; + +var hasRequiredEs_symbol_hasInstance; + +function requireEs_symbol_hasInstance () { + if (hasRequiredEs_symbol_hasInstance) return es_symbol_hasInstance; + hasRequiredEs_symbol_hasInstance = 1; + var defineWellKnownSymbol = requireWellKnownSymbolDefine(); + + // `Symbol.hasInstance` well-known symbol + // https://tc39.es/ecma262/#sec-symbol.hasinstance + defineWellKnownSymbol('hasInstance'); + return es_symbol_hasInstance; +} + +var es_symbol_isConcatSpreadable = {}; + +var hasRequiredEs_symbol_isConcatSpreadable; + +function requireEs_symbol_isConcatSpreadable () { + if (hasRequiredEs_symbol_isConcatSpreadable) return es_symbol_isConcatSpreadable; + hasRequiredEs_symbol_isConcatSpreadable = 1; + var defineWellKnownSymbol = requireWellKnownSymbolDefine(); + + // `Symbol.isConcatSpreadable` well-known symbol + // https://tc39.es/ecma262/#sec-symbol.isconcatspreadable + defineWellKnownSymbol('isConcatSpreadable'); + return es_symbol_isConcatSpreadable; +} + +var es_symbol_iterator = {}; + +var hasRequiredEs_symbol_iterator; + +function requireEs_symbol_iterator () { + if (hasRequiredEs_symbol_iterator) return es_symbol_iterator; + hasRequiredEs_symbol_iterator = 1; + var defineWellKnownSymbol = requireWellKnownSymbolDefine(); + + // `Symbol.iterator` well-known symbol + // https://tc39.es/ecma262/#sec-symbol.iterator + defineWellKnownSymbol('iterator'); + return es_symbol_iterator; +} + +var es_symbol_match = {}; + +var hasRequiredEs_symbol_match; + +function requireEs_symbol_match () { + if (hasRequiredEs_symbol_match) return es_symbol_match; + hasRequiredEs_symbol_match = 1; + var defineWellKnownSymbol = requireWellKnownSymbolDefine(); + + // `Symbol.match` well-known symbol + // https://tc39.es/ecma262/#sec-symbol.match + defineWellKnownSymbol('match'); + return es_symbol_match; +} + +var es_symbol_matchAll = {}; + +var hasRequiredEs_symbol_matchAll; + +function requireEs_symbol_matchAll () { + if (hasRequiredEs_symbol_matchAll) return es_symbol_matchAll; + hasRequiredEs_symbol_matchAll = 1; + var defineWellKnownSymbol = requireWellKnownSymbolDefine(); + + // `Symbol.matchAll` well-known symbol + // https://tc39.es/ecma262/#sec-symbol.matchall + defineWellKnownSymbol('matchAll'); + return es_symbol_matchAll; +} + +var es_symbol_replace = {}; + +var hasRequiredEs_symbol_replace; + +function requireEs_symbol_replace () { + if (hasRequiredEs_symbol_replace) return es_symbol_replace; + hasRequiredEs_symbol_replace = 1; + var defineWellKnownSymbol = requireWellKnownSymbolDefine(); + + // `Symbol.replace` well-known symbol + // https://tc39.es/ecma262/#sec-symbol.replace + defineWellKnownSymbol('replace'); + return es_symbol_replace; +} + +var es_symbol_search = {}; + +var hasRequiredEs_symbol_search; + +function requireEs_symbol_search () { + if (hasRequiredEs_symbol_search) return es_symbol_search; + hasRequiredEs_symbol_search = 1; + var defineWellKnownSymbol = requireWellKnownSymbolDefine(); + + // `Symbol.search` well-known symbol + // https://tc39.es/ecma262/#sec-symbol.search + defineWellKnownSymbol('search'); + return es_symbol_search; +} + +var es_symbol_species = {}; + +var hasRequiredEs_symbol_species; + +function requireEs_symbol_species () { + if (hasRequiredEs_symbol_species) return es_symbol_species; + hasRequiredEs_symbol_species = 1; + var defineWellKnownSymbol = requireWellKnownSymbolDefine(); + + // `Symbol.species` well-known symbol + // https://tc39.es/ecma262/#sec-symbol.species + defineWellKnownSymbol('species'); + return es_symbol_species; +} + +var es_symbol_split = {}; + +var hasRequiredEs_symbol_split; + +function requireEs_symbol_split () { + if (hasRequiredEs_symbol_split) return es_symbol_split; + hasRequiredEs_symbol_split = 1; + var defineWellKnownSymbol = requireWellKnownSymbolDefine(); + + // `Symbol.split` well-known symbol + // https://tc39.es/ecma262/#sec-symbol.split + defineWellKnownSymbol('split'); + return es_symbol_split; +} + +var es_symbol_toPrimitive = {}; + +var hasRequiredEs_symbol_toPrimitive; + +function requireEs_symbol_toPrimitive () { + if (hasRequiredEs_symbol_toPrimitive) return es_symbol_toPrimitive; + hasRequiredEs_symbol_toPrimitive = 1; + var defineWellKnownSymbol = requireWellKnownSymbolDefine(); + var defineSymbolToPrimitive = requireSymbolDefineToPrimitive(); + + // `Symbol.toPrimitive` well-known symbol + // https://tc39.es/ecma262/#sec-symbol.toprimitive + defineWellKnownSymbol('toPrimitive'); + + // `Symbol.prototype[@@toPrimitive]` method + // https://tc39.es/ecma262/#sec-symbol.prototype-@@toprimitive + defineSymbolToPrimitive(); + return es_symbol_toPrimitive; +} + +var es_symbol_toStringTag = {}; + +var hasRequiredEs_symbol_toStringTag; + +function requireEs_symbol_toStringTag () { + if (hasRequiredEs_symbol_toStringTag) return es_symbol_toStringTag; + hasRequiredEs_symbol_toStringTag = 1; + var getBuiltIn = requireGetBuiltIn(); + var defineWellKnownSymbol = requireWellKnownSymbolDefine(); + var setToStringTag = requireSetToStringTag(); + + // `Symbol.toStringTag` well-known symbol + // https://tc39.es/ecma262/#sec-symbol.tostringtag + defineWellKnownSymbol('toStringTag'); + + // `Symbol.prototype[@@toStringTag]` property + // https://tc39.es/ecma262/#sec-symbol.prototype-@@tostringtag + setToStringTag(getBuiltIn('Symbol'), 'Symbol'); + return es_symbol_toStringTag; +} + +var es_symbol_unscopables = {}; + +var hasRequiredEs_symbol_unscopables; + +function requireEs_symbol_unscopables () { + if (hasRequiredEs_symbol_unscopables) return es_symbol_unscopables; + hasRequiredEs_symbol_unscopables = 1; + var defineWellKnownSymbol = requireWellKnownSymbolDefine(); + + // `Symbol.unscopables` well-known symbol + // https://tc39.es/ecma262/#sec-symbol.unscopables + defineWellKnownSymbol('unscopables'); + return es_symbol_unscopables; +} + +var es_error_cause = {}; + +var functionUncurryThisAccessor; +var hasRequiredFunctionUncurryThisAccessor; + +function requireFunctionUncurryThisAccessor () { + if (hasRequiredFunctionUncurryThisAccessor) return functionUncurryThisAccessor; + hasRequiredFunctionUncurryThisAccessor = 1; + var uncurryThis = requireFunctionUncurryThis(); + var aCallable = requireACallable(); + + functionUncurryThisAccessor = function (object, key, method) { + try { + // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe + return uncurryThis(aCallable(Object.getOwnPropertyDescriptor(object, key)[method])); + } catch (error) { /* empty */ } + }; + return functionUncurryThisAccessor; +} + +var isPossiblePrototype; +var hasRequiredIsPossiblePrototype; + +function requireIsPossiblePrototype () { + if (hasRequiredIsPossiblePrototype) return isPossiblePrototype; + hasRequiredIsPossiblePrototype = 1; + var isObject = requireIsObject(); + + isPossiblePrototype = function (argument) { + return isObject(argument) || argument === null; + }; + return isPossiblePrototype; +} + +var aPossiblePrototype; +var hasRequiredAPossiblePrototype; + +function requireAPossiblePrototype () { + if (hasRequiredAPossiblePrototype) return aPossiblePrototype; + hasRequiredAPossiblePrototype = 1; + var isPossiblePrototype = requireIsPossiblePrototype(); + + var $String = String; + var $TypeError = TypeError; + + aPossiblePrototype = function (argument) { + if (isPossiblePrototype(argument)) return argument; + throw new $TypeError("Can't set " + $String(argument) + ' as a prototype'); + }; + return aPossiblePrototype; +} + +var objectSetPrototypeOf; +var hasRequiredObjectSetPrototypeOf; + +function requireObjectSetPrototypeOf () { + if (hasRequiredObjectSetPrototypeOf) return objectSetPrototypeOf; + hasRequiredObjectSetPrototypeOf = 1; + /* eslint-disable no-proto -- safe */ + var uncurryThisAccessor = requireFunctionUncurryThisAccessor(); + var isObject = requireIsObject(); + var requireObjectCoercible = requireRequireObjectCoercible(); + var aPossiblePrototype = requireAPossiblePrototype(); + + // `Object.setPrototypeOf` method + // https://tc39.es/ecma262/#sec-object.setprototypeof + // Works with __proto__ only. Old v8 can't work with null proto objects. + // eslint-disable-next-line es/no-object-setprototypeof -- safe + objectSetPrototypeOf = Object.setPrototypeOf || ('__proto__' in {} ? function () { + var CORRECT_SETTER = false; + var test = {}; + var setter; + try { + setter = uncurryThisAccessor(Object.prototype, '__proto__', 'set'); + setter(test, []); + CORRECT_SETTER = test instanceof Array; + } catch (error) { /* empty */ } + return function setPrototypeOf(O, proto) { + requireObjectCoercible(O); + aPossiblePrototype(proto); + if (!isObject(O)) return O; + if (CORRECT_SETTER) setter(O, proto); + else O.__proto__ = proto; + return O; + }; + }() : undefined); + return objectSetPrototypeOf; +} + +var proxyAccessor; +var hasRequiredProxyAccessor; + +function requireProxyAccessor () { + if (hasRequiredProxyAccessor) return proxyAccessor; + hasRequiredProxyAccessor = 1; + var defineProperty = requireObjectDefineProperty().f; + + proxyAccessor = function (Target, Source, key) { + key in Target || defineProperty(Target, key, { + configurable: true, + get: function () { return Source[key]; }, + set: function (it) { Source[key] = it; } + }); + }; + return proxyAccessor; +} + +var inheritIfRequired; +var hasRequiredInheritIfRequired; + +function requireInheritIfRequired () { + if (hasRequiredInheritIfRequired) return inheritIfRequired; + hasRequiredInheritIfRequired = 1; + var isCallable = requireIsCallable(); + var isObject = requireIsObject(); + var setPrototypeOf = requireObjectSetPrototypeOf(); + + // makes subclassing work correct for wrapped built-ins + inheritIfRequired = function ($this, dummy, Wrapper) { + var NewTarget, NewTargetPrototype; + if ( + // it can work only with native `setPrototypeOf` + setPrototypeOf && + // we haven't completely correct pre-ES6 way for getting `new.target`, so use this + isCallable(NewTarget = dummy.constructor) && + NewTarget !== Wrapper && + isObject(NewTargetPrototype = NewTarget.prototype) && + NewTargetPrototype !== Wrapper.prototype + ) setPrototypeOf($this, NewTargetPrototype); + return $this; + }; + return inheritIfRequired; +} + +var normalizeStringArgument; +var hasRequiredNormalizeStringArgument; + +function requireNormalizeStringArgument () { + if (hasRequiredNormalizeStringArgument) return normalizeStringArgument; + hasRequiredNormalizeStringArgument = 1; + var toString = requireToString(); + + normalizeStringArgument = function (argument, $default) { + return argument === undefined ? arguments.length < 2 ? '' : $default : toString(argument); + }; + return normalizeStringArgument; +} + +var installErrorCause; +var hasRequiredInstallErrorCause; + +function requireInstallErrorCause () { + if (hasRequiredInstallErrorCause) return installErrorCause; + hasRequiredInstallErrorCause = 1; + var isObject = requireIsObject(); + var createNonEnumerableProperty = requireCreateNonEnumerableProperty(); + + // `InstallErrorCause` abstract operation + // https://tc39.es/proposal-error-cause/#sec-errorobjects-install-error-cause + installErrorCause = function (O, options) { + if (isObject(options) && 'cause' in options) { + createNonEnumerableProperty(O, 'cause', options.cause); + } + }; + return installErrorCause; +} + +var errorStackClear; +var hasRequiredErrorStackClear; + +function requireErrorStackClear () { + if (hasRequiredErrorStackClear) return errorStackClear; + hasRequiredErrorStackClear = 1; + var uncurryThis = requireFunctionUncurryThis(); + + var $Error = Error; + var replace = uncurryThis(''.replace); + + var TEST = (function (arg) { return String(new $Error(arg).stack); })('zxcasd'); + // eslint-disable-next-line redos/no-vulnerable -- safe + var V8_OR_CHAKRA_STACK_ENTRY = /\n\s*at [^:]*:[^\n]*/; + var IS_V8_OR_CHAKRA_STACK = V8_OR_CHAKRA_STACK_ENTRY.test(TEST); + + errorStackClear = function (stack, dropEntries) { + if (IS_V8_OR_CHAKRA_STACK && typeof stack == 'string' && !$Error.prepareStackTrace) { + while (dropEntries--) stack = replace(stack, V8_OR_CHAKRA_STACK_ENTRY, ''); + } return stack; + }; + return errorStackClear; +} + +var errorStackInstallable; +var hasRequiredErrorStackInstallable; + +function requireErrorStackInstallable () { + if (hasRequiredErrorStackInstallable) return errorStackInstallable; + hasRequiredErrorStackInstallable = 1; + var fails = requireFails(); + var createPropertyDescriptor = requireCreatePropertyDescriptor(); + + errorStackInstallable = !fails(function () { + var error = new Error('a'); + if (!('stack' in error)) return true; + // eslint-disable-next-line es/no-object-defineproperty -- safe + Object.defineProperty(error, 'stack', createPropertyDescriptor(1, 7)); + return error.stack !== 7; + }); + return errorStackInstallable; +} + +var errorStackInstall; +var hasRequiredErrorStackInstall; + +function requireErrorStackInstall () { + if (hasRequiredErrorStackInstall) return errorStackInstall; + hasRequiredErrorStackInstall = 1; + var createNonEnumerableProperty = requireCreateNonEnumerableProperty(); + var clearErrorStack = requireErrorStackClear(); + var ERROR_STACK_INSTALLABLE = requireErrorStackInstallable(); + + // non-standard V8 + var captureStackTrace = Error.captureStackTrace; + + errorStackInstall = function (error, C, stack, dropEntries) { + if (ERROR_STACK_INSTALLABLE) { + if (captureStackTrace) captureStackTrace(error, C); + else createNonEnumerableProperty(error, 'stack', clearErrorStack(stack, dropEntries)); + } + }; + return errorStackInstall; +} + +var wrapErrorConstructorWithCause; +var hasRequiredWrapErrorConstructorWithCause; + +function requireWrapErrorConstructorWithCause () { + if (hasRequiredWrapErrorConstructorWithCause) return wrapErrorConstructorWithCause; + hasRequiredWrapErrorConstructorWithCause = 1; + var getBuiltIn = requireGetBuiltIn(); + var hasOwn = requireHasOwnProperty(); + var createNonEnumerableProperty = requireCreateNonEnumerableProperty(); + var isPrototypeOf = requireObjectIsPrototypeOf(); + var setPrototypeOf = requireObjectSetPrototypeOf(); + var copyConstructorProperties = requireCopyConstructorProperties(); + var proxyAccessor = requireProxyAccessor(); + var inheritIfRequired = requireInheritIfRequired(); + var normalizeStringArgument = requireNormalizeStringArgument(); + var installErrorCause = requireInstallErrorCause(); + var installErrorStack = requireErrorStackInstall(); + var DESCRIPTORS = requireDescriptors(); + var IS_PURE = requireIsPure(); + + wrapErrorConstructorWithCause = function (FULL_NAME, wrapper, FORCED, IS_AGGREGATE_ERROR) { + var STACK_TRACE_LIMIT = 'stackTraceLimit'; + var OPTIONS_POSITION = IS_AGGREGATE_ERROR ? 2 : 1; + var path = FULL_NAME.split('.'); + var ERROR_NAME = path[path.length - 1]; + var OriginalError = getBuiltIn.apply(null, path); + + if (!OriginalError) return; + + var OriginalErrorPrototype = OriginalError.prototype; + + // V8 9.3- bug https://bugs.chromium.org/p/v8/issues/detail?id=12006 + if (!IS_PURE && hasOwn(OriginalErrorPrototype, 'cause')) delete OriginalErrorPrototype.cause; + + if (!FORCED) return OriginalError; + + var BaseError = getBuiltIn('Error'); + + var WrappedError = wrapper(function (a, b) { + var message = normalizeStringArgument(IS_AGGREGATE_ERROR ? b : a, undefined); + var result = IS_AGGREGATE_ERROR ? new OriginalError(a) : new OriginalError(); + if (message !== undefined) createNonEnumerableProperty(result, 'message', message); + installErrorStack(result, WrappedError, result.stack, 2); + if (this && isPrototypeOf(OriginalErrorPrototype, this)) inheritIfRequired(result, this, WrappedError); + if (arguments.length > OPTIONS_POSITION) installErrorCause(result, arguments[OPTIONS_POSITION]); + return result; + }); + + WrappedError.prototype = OriginalErrorPrototype; + + if (ERROR_NAME !== 'Error') { + if (setPrototypeOf) setPrototypeOf(WrappedError, BaseError); + else copyConstructorProperties(WrappedError, BaseError, { name: true }); + } else if (DESCRIPTORS && STACK_TRACE_LIMIT in OriginalError) { + proxyAccessor(WrappedError, OriginalError, STACK_TRACE_LIMIT); + proxyAccessor(WrappedError, OriginalError, 'prepareStackTrace'); + } + + copyConstructorProperties(WrappedError, OriginalError); + + if (!IS_PURE) try { + // Safari 13- bug: WebAssembly errors does not have a proper `.name` + if (OriginalErrorPrototype.name !== ERROR_NAME) { + createNonEnumerableProperty(OriginalErrorPrototype, 'name', ERROR_NAME); + } + OriginalErrorPrototype.constructor = WrappedError; + } catch (error) { /* empty */ } + + return WrappedError; + }; + return wrapErrorConstructorWithCause; +} + +var hasRequiredEs_error_cause; + +function requireEs_error_cause () { + if (hasRequiredEs_error_cause) return es_error_cause; + hasRequiredEs_error_cause = 1; + /* eslint-disable no-unused-vars -- required for functions `.length` */ + var $ = require_export(); + var globalThis = requireGlobalThis(); + var apply = requireFunctionApply(); + var wrapErrorConstructorWithCause = requireWrapErrorConstructorWithCause(); + + var WEB_ASSEMBLY = 'WebAssembly'; + var WebAssembly = globalThis[WEB_ASSEMBLY]; + + // eslint-disable-next-line es/no-error-cause -- feature detection + var FORCED = new Error('e', { cause: 7 }).cause !== 7; + + var exportGlobalErrorCauseWrapper = function (ERROR_NAME, wrapper) { + var O = {}; + O[ERROR_NAME] = wrapErrorConstructorWithCause(ERROR_NAME, wrapper, FORCED); + $({ global: true, constructor: true, arity: 1, forced: FORCED }, O); + }; + + var exportWebAssemblyErrorCauseWrapper = function (ERROR_NAME, wrapper) { + if (WebAssembly && WebAssembly[ERROR_NAME]) { + var O = {}; + O[ERROR_NAME] = wrapErrorConstructorWithCause(WEB_ASSEMBLY + '.' + ERROR_NAME, wrapper, FORCED); + $({ target: WEB_ASSEMBLY, stat: true, constructor: true, arity: 1, forced: FORCED }, O); + } + }; + + // https://tc39.es/ecma262/#sec-nativeerror + exportGlobalErrorCauseWrapper('Error', function (init) { + return function Error(message) { return apply(init, this, arguments); }; + }); + exportGlobalErrorCauseWrapper('EvalError', function (init) { + return function EvalError(message) { return apply(init, this, arguments); }; + }); + exportGlobalErrorCauseWrapper('RangeError', function (init) { + return function RangeError(message) { return apply(init, this, arguments); }; + }); + exportGlobalErrorCauseWrapper('ReferenceError', function (init) { + return function ReferenceError(message) { return apply(init, this, arguments); }; + }); + exportGlobalErrorCauseWrapper('SyntaxError', function (init) { + return function SyntaxError(message) { return apply(init, this, arguments); }; + }); + exportGlobalErrorCauseWrapper('TypeError', function (init) { + return function TypeError(message) { return apply(init, this, arguments); }; + }); + exportGlobalErrorCauseWrapper('URIError', function (init) { + return function URIError(message) { return apply(init, this, arguments); }; + }); + exportWebAssemblyErrorCauseWrapper('CompileError', function (init) { + return function CompileError(message) { return apply(init, this, arguments); }; + }); + exportWebAssemblyErrorCauseWrapper('LinkError', function (init) { + return function LinkError(message) { return apply(init, this, arguments); }; + }); + exportWebAssemblyErrorCauseWrapper('RuntimeError', function (init) { + return function RuntimeError(message) { return apply(init, this, arguments); }; + }); + return es_error_cause; +} + +var es_error_toString = {}; + +var errorToString; +var hasRequiredErrorToString; + +function requireErrorToString () { + if (hasRequiredErrorToString) return errorToString; + hasRequiredErrorToString = 1; + var DESCRIPTORS = requireDescriptors(); + var fails = requireFails(); + var anObject = requireAnObject(); + var normalizeStringArgument = requireNormalizeStringArgument(); + + var nativeErrorToString = Error.prototype.toString; + + var INCORRECT_TO_STRING = fails(function () { + if (DESCRIPTORS) { + // Chrome 32- incorrectly call accessor + // eslint-disable-next-line es/no-object-create, es/no-object-defineproperty -- safe + var object = Object.create(Object.defineProperty({}, 'name', { get: function () { + return this === object; + } })); + if (nativeErrorToString.call(object) !== 'true') return true; + } + // FF10- does not properly handle non-strings + return nativeErrorToString.call({ message: 1, name: 2 }) !== '2: 1' + // IE8 does not properly handle defaults + || nativeErrorToString.call({}) !== 'Error'; + }); + + errorToString = INCORRECT_TO_STRING ? function toString() { + var O = anObject(this); + var name = normalizeStringArgument(O.name, 'Error'); + var message = normalizeStringArgument(O.message); + return !name ? message : !message ? name : name + ': ' + message; + } : nativeErrorToString; + return errorToString; +} + +var hasRequiredEs_error_toString; + +function requireEs_error_toString () { + if (hasRequiredEs_error_toString) return es_error_toString; + hasRequiredEs_error_toString = 1; + var defineBuiltIn = requireDefineBuiltIn(); + var errorToString = requireErrorToString(); + + var ErrorPrototype = Error.prototype; + + // `Error.prototype.toString` method fix + // https://tc39.es/ecma262/#sec-error.prototype.tostring + if (ErrorPrototype.toString !== errorToString) { + defineBuiltIn(ErrorPrototype, 'toString', errorToString); + } + return es_error_toString; +} + +var es_aggregateError = {}; + +var es_aggregateError_constructor = {}; + +var correctPrototypeGetter; +var hasRequiredCorrectPrototypeGetter; + +function requireCorrectPrototypeGetter () { + if (hasRequiredCorrectPrototypeGetter) return correctPrototypeGetter; + hasRequiredCorrectPrototypeGetter = 1; + var fails = requireFails(); + + correctPrototypeGetter = !fails(function () { + function F() { /* empty */ } + F.prototype.constructor = null; + // eslint-disable-next-line es/no-object-getprototypeof -- required for testing + return Object.getPrototypeOf(new F()) !== F.prototype; + }); + return correctPrototypeGetter; +} + +var objectGetPrototypeOf; +var hasRequiredObjectGetPrototypeOf; + +function requireObjectGetPrototypeOf () { + if (hasRequiredObjectGetPrototypeOf) return objectGetPrototypeOf; + hasRequiredObjectGetPrototypeOf = 1; + var hasOwn = requireHasOwnProperty(); + var isCallable = requireIsCallable(); + var toObject = requireToObject(); + var sharedKey = requireSharedKey(); + var CORRECT_PROTOTYPE_GETTER = requireCorrectPrototypeGetter(); + + var IE_PROTO = sharedKey('IE_PROTO'); + var $Object = Object; + var ObjectPrototype = $Object.prototype; + + // `Object.getPrototypeOf` method + // https://tc39.es/ecma262/#sec-object.getprototypeof + // eslint-disable-next-line es/no-object-getprototypeof -- safe + objectGetPrototypeOf = CORRECT_PROTOTYPE_GETTER ? $Object.getPrototypeOf : function (O) { + var object = toObject(O); + if (hasOwn(object, IE_PROTO)) return object[IE_PROTO]; + var constructor = object.constructor; + if (isCallable(constructor) && object instanceof constructor) { + return constructor.prototype; + } return object instanceof $Object ? ObjectPrototype : null; + }; + return objectGetPrototypeOf; +} + +var iterators; +var hasRequiredIterators; + +function requireIterators () { + if (hasRequiredIterators) return iterators; + hasRequiredIterators = 1; + iterators = {}; + return iterators; +} + +var isArrayIteratorMethod; +var hasRequiredIsArrayIteratorMethod; + +function requireIsArrayIteratorMethod () { + if (hasRequiredIsArrayIteratorMethod) return isArrayIteratorMethod; + hasRequiredIsArrayIteratorMethod = 1; + var wellKnownSymbol = requireWellKnownSymbol(); + var Iterators = requireIterators(); + + var ITERATOR = wellKnownSymbol('iterator'); + var ArrayPrototype = Array.prototype; + + // check on default Array iterator + isArrayIteratorMethod = function (it) { + return it !== undefined && (Iterators.Array === it || ArrayPrototype[ITERATOR] === it); + }; + return isArrayIteratorMethod; +} + +var getIteratorMethod; +var hasRequiredGetIteratorMethod; + +function requireGetIteratorMethod () { + if (hasRequiredGetIteratorMethod) return getIteratorMethod; + hasRequiredGetIteratorMethod = 1; + var classof = requireClassof(); + var getMethod = requireGetMethod(); + var isNullOrUndefined = requireIsNullOrUndefined(); + var Iterators = requireIterators(); + var wellKnownSymbol = requireWellKnownSymbol(); + + var ITERATOR = wellKnownSymbol('iterator'); + + getIteratorMethod = function (it) { + if (!isNullOrUndefined(it)) return getMethod(it, ITERATOR) + || getMethod(it, '@@iterator') + || Iterators[classof(it)]; + }; + return getIteratorMethod; +} + +var getIterator; +var hasRequiredGetIterator; + +function requireGetIterator () { + if (hasRequiredGetIterator) return getIterator; + hasRequiredGetIterator = 1; + var call = requireFunctionCall(); + var aCallable = requireACallable(); + var anObject = requireAnObject(); + var tryToString = requireTryToString(); + var getIteratorMethod = requireGetIteratorMethod(); + + var $TypeError = TypeError; + + getIterator = function (argument, usingIterator) { + var iteratorMethod = arguments.length < 2 ? getIteratorMethod(argument) : usingIterator; + if (aCallable(iteratorMethod)) return anObject(call(iteratorMethod, argument)); + throw new $TypeError(tryToString(argument) + ' is not iterable'); + }; + return getIterator; +} + +var iteratorClose; +var hasRequiredIteratorClose; + +function requireIteratorClose () { + if (hasRequiredIteratorClose) return iteratorClose; + hasRequiredIteratorClose = 1; + var call = requireFunctionCall(); + var anObject = requireAnObject(); + var getMethod = requireGetMethod(); + + iteratorClose = function (iterator, kind, value) { + var innerResult, innerError; + anObject(iterator); + try { + innerResult = getMethod(iterator, 'return'); + if (!innerResult) { + if (kind === 'throw') throw value; + return value; + } + innerResult = call(innerResult, iterator); + } catch (error) { + innerError = true; + innerResult = error; + } + if (kind === 'throw') throw value; + if (innerError) throw innerResult; + anObject(innerResult); + return value; + }; + return iteratorClose; +} + +var iterate; +var hasRequiredIterate; + +function requireIterate () { + if (hasRequiredIterate) return iterate; + hasRequiredIterate = 1; + var bind = requireFunctionBindContext(); + var call = requireFunctionCall(); + var anObject = requireAnObject(); + var tryToString = requireTryToString(); + var isArrayIteratorMethod = requireIsArrayIteratorMethod(); + var lengthOfArrayLike = requireLengthOfArrayLike(); + var isPrototypeOf = requireObjectIsPrototypeOf(); + var getIterator = requireGetIterator(); + var getIteratorMethod = requireGetIteratorMethod(); + var iteratorClose = requireIteratorClose(); + + var $TypeError = TypeError; + + var Result = function (stopped, result) { + this.stopped = stopped; + this.result = result; + }; + + var ResultPrototype = Result.prototype; + + iterate = function (iterable, unboundFunction, options) { + var that = options && options.that; + var AS_ENTRIES = !!(options && options.AS_ENTRIES); + var IS_RECORD = !!(options && options.IS_RECORD); + var IS_ITERATOR = !!(options && options.IS_ITERATOR); + var INTERRUPTED = !!(options && options.INTERRUPTED); + var fn = bind(unboundFunction, that); + var iterator, iterFn, index, length, result, next, step; + + var stop = function (condition) { + if (iterator) iteratorClose(iterator, 'normal', condition); + return new Result(true, condition); + }; + + var callFn = function (value) { + if (AS_ENTRIES) { + anObject(value); + return INTERRUPTED ? fn(value[0], value[1], stop) : fn(value[0], value[1]); + } return INTERRUPTED ? fn(value, stop) : fn(value); + }; + + if (IS_RECORD) { + iterator = iterable.iterator; + } else if (IS_ITERATOR) { + iterator = iterable; + } else { + iterFn = getIteratorMethod(iterable); + if (!iterFn) throw new $TypeError(tryToString(iterable) + ' is not iterable'); + // optimisation for array iterators + if (isArrayIteratorMethod(iterFn)) { + for (index = 0, length = lengthOfArrayLike(iterable); length > index; index++) { + result = callFn(iterable[index]); + if (result && isPrototypeOf(ResultPrototype, result)) return result; + } return new Result(false); + } + iterator = getIterator(iterable, iterFn); + } + + next = IS_RECORD ? iterable.next : iterator.next; + while (!(step = call(next, iterator)).done) { + try { + result = callFn(step.value); + } catch (error) { + iteratorClose(iterator, 'throw', error); + } + if (typeof result == 'object' && result && isPrototypeOf(ResultPrototype, result)) return result; + } return new Result(false); + }; + return iterate; +} + +var hasRequiredEs_aggregateError_constructor; + +function requireEs_aggregateError_constructor () { + if (hasRequiredEs_aggregateError_constructor) return es_aggregateError_constructor; + hasRequiredEs_aggregateError_constructor = 1; + var $ = require_export(); + var isPrototypeOf = requireObjectIsPrototypeOf(); + var getPrototypeOf = requireObjectGetPrototypeOf(); + var setPrototypeOf = requireObjectSetPrototypeOf(); + var copyConstructorProperties = requireCopyConstructorProperties(); + var create = requireObjectCreate(); + var createNonEnumerableProperty = requireCreateNonEnumerableProperty(); + var createPropertyDescriptor = requireCreatePropertyDescriptor(); + var installErrorCause = requireInstallErrorCause(); + var installErrorStack = requireErrorStackInstall(); + var iterate = requireIterate(); + var normalizeStringArgument = requireNormalizeStringArgument(); + var wellKnownSymbol = requireWellKnownSymbol(); + + var TO_STRING_TAG = wellKnownSymbol('toStringTag'); + var $Error = Error; + var push = [].push; + + var $AggregateError = function AggregateError(errors, message /* , options */) { + var isInstance = isPrototypeOf(AggregateErrorPrototype, this); + var that; + if (setPrototypeOf) { + that = setPrototypeOf(new $Error(), isInstance ? getPrototypeOf(this) : AggregateErrorPrototype); + } else { + that = isInstance ? this : create(AggregateErrorPrototype); + createNonEnumerableProperty(that, TO_STRING_TAG, 'Error'); + } + if (message !== undefined) createNonEnumerableProperty(that, 'message', normalizeStringArgument(message)); + installErrorStack(that, $AggregateError, that.stack, 1); + if (arguments.length > 2) installErrorCause(that, arguments[2]); + var errorsArray = []; + iterate(errors, push, { that: errorsArray }); + createNonEnumerableProperty(that, 'errors', errorsArray); + return that; + }; + + if (setPrototypeOf) setPrototypeOf($AggregateError, $Error); + else copyConstructorProperties($AggregateError, $Error, { name: true }); + + var AggregateErrorPrototype = $AggregateError.prototype = create($Error.prototype, { + constructor: createPropertyDescriptor(1, $AggregateError), + message: createPropertyDescriptor(1, ''), + name: createPropertyDescriptor(1, 'AggregateError') + }); + + // `AggregateError` constructor + // https://tc39.es/ecma262/#sec-aggregate-error-constructor + $({ global: true, constructor: true, arity: 2 }, { + AggregateError: $AggregateError + }); + return es_aggregateError_constructor; +} + +var hasRequiredEs_aggregateError; + +function requireEs_aggregateError () { + if (hasRequiredEs_aggregateError) return es_aggregateError; + hasRequiredEs_aggregateError = 1; + // TODO: Remove this module from `core-js@4` since it's replaced to module below + requireEs_aggregateError_constructor(); + return es_aggregateError; +} + +var es_aggregateError_cause = {}; + +var hasRequiredEs_aggregateError_cause; + +function requireEs_aggregateError_cause () { + if (hasRequiredEs_aggregateError_cause) return es_aggregateError_cause; + hasRequiredEs_aggregateError_cause = 1; + var $ = require_export(); + var getBuiltIn = requireGetBuiltIn(); + var apply = requireFunctionApply(); + var fails = requireFails(); + var wrapErrorConstructorWithCause = requireWrapErrorConstructorWithCause(); + + var AGGREGATE_ERROR = 'AggregateError'; + var $AggregateError = getBuiltIn(AGGREGATE_ERROR); + + var FORCED = !fails(function () { + return $AggregateError([1]).errors[0] !== 1; + }) && fails(function () { + return $AggregateError([1], AGGREGATE_ERROR, { cause: 7 }).cause !== 7; + }); + + // https://tc39.es/ecma262/#sec-aggregate-error + $({ global: true, constructor: true, arity: 2, forced: FORCED }, { + AggregateError: wrapErrorConstructorWithCause(AGGREGATE_ERROR, function (init) { + // eslint-disable-next-line no-unused-vars -- required for functions `.length` + return function AggregateError(errors, message) { return apply(init, this, arguments); }; + }, FORCED, true) + }); + return es_aggregateError_cause; +} + +var es_array_at = {}; + +var addToUnscopables; +var hasRequiredAddToUnscopables; + +function requireAddToUnscopables () { + if (hasRequiredAddToUnscopables) return addToUnscopables; + hasRequiredAddToUnscopables = 1; + var wellKnownSymbol = requireWellKnownSymbol(); + var create = requireObjectCreate(); + var defineProperty = requireObjectDefineProperty().f; + + var UNSCOPABLES = wellKnownSymbol('unscopables'); + var ArrayPrototype = Array.prototype; + + // Array.prototype[@@unscopables] + // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables + if (ArrayPrototype[UNSCOPABLES] === undefined) { + defineProperty(ArrayPrototype, UNSCOPABLES, { + configurable: true, + value: create(null) + }); + } + + // add a key to Array.prototype[@@unscopables] + addToUnscopables = function (key) { + ArrayPrototype[UNSCOPABLES][key] = true; + }; + return addToUnscopables; +} + +var hasRequiredEs_array_at; + +function requireEs_array_at () { + if (hasRequiredEs_array_at) return es_array_at; + hasRequiredEs_array_at = 1; + var $ = require_export(); + var toObject = requireToObject(); + var lengthOfArrayLike = requireLengthOfArrayLike(); + var toIntegerOrInfinity = requireToIntegerOrInfinity(); + var addToUnscopables = requireAddToUnscopables(); + + // `Array.prototype.at` method + // https://tc39.es/ecma262/#sec-array.prototype.at + $({ target: 'Array', proto: true }, { + at: function at(index) { + var O = toObject(this); + var len = lengthOfArrayLike(O); + var relativeIndex = toIntegerOrInfinity(index); + var k = relativeIndex >= 0 ? relativeIndex : len + relativeIndex; + return (k < 0 || k >= len) ? undefined : O[k]; + } + }); + + addToUnscopables('at'); + return es_array_at; +} + +var es_array_concat = {}; + +var doesNotExceedSafeInteger; +var hasRequiredDoesNotExceedSafeInteger; + +function requireDoesNotExceedSafeInteger () { + if (hasRequiredDoesNotExceedSafeInteger) return doesNotExceedSafeInteger; + hasRequiredDoesNotExceedSafeInteger = 1; + var $TypeError = TypeError; + var MAX_SAFE_INTEGER = 0x1FFFFFFFFFFFFF; // 2 ** 53 - 1 == 9007199254740991 + + doesNotExceedSafeInteger = function (it) { + if (it > MAX_SAFE_INTEGER) throw $TypeError('Maximum allowed index exceeded'); + return it; + }; + return doesNotExceedSafeInteger; +} + +var createProperty; +var hasRequiredCreateProperty; + +function requireCreateProperty () { + if (hasRequiredCreateProperty) return createProperty; + hasRequiredCreateProperty = 1; + var DESCRIPTORS = requireDescriptors(); + var definePropertyModule = requireObjectDefineProperty(); + var createPropertyDescriptor = requireCreatePropertyDescriptor(); + + createProperty = function (object, key, value) { + if (DESCRIPTORS) definePropertyModule.f(object, key, createPropertyDescriptor(0, value)); + else object[key] = value; + }; + return createProperty; +} + +var arrayMethodHasSpeciesSupport; +var hasRequiredArrayMethodHasSpeciesSupport; + +function requireArrayMethodHasSpeciesSupport () { + if (hasRequiredArrayMethodHasSpeciesSupport) return arrayMethodHasSpeciesSupport; + hasRequiredArrayMethodHasSpeciesSupport = 1; + var fails = requireFails(); + var wellKnownSymbol = requireWellKnownSymbol(); + var V8_VERSION = requireEnvironmentV8Version(); + + var SPECIES = wellKnownSymbol('species'); + + arrayMethodHasSpeciesSupport = function (METHOD_NAME) { + // We can't use this feature detection in V8 since it causes + // deoptimization and serious performance degradation + // https://github.com/zloirock/core-js/issues/677 + return V8_VERSION >= 51 || !fails(function () { + var array = []; + var constructor = array.constructor = {}; + constructor[SPECIES] = function () { + return { foo: 1 }; + }; + return array[METHOD_NAME](Boolean).foo !== 1; + }); + }; + return arrayMethodHasSpeciesSupport; +} + +var hasRequiredEs_array_concat; + +function requireEs_array_concat () { + if (hasRequiredEs_array_concat) return es_array_concat; + hasRequiredEs_array_concat = 1; + var $ = require_export(); + var fails = requireFails(); + var isArray = requireIsArray(); + var isObject = requireIsObject(); + var toObject = requireToObject(); + var lengthOfArrayLike = requireLengthOfArrayLike(); + var doesNotExceedSafeInteger = requireDoesNotExceedSafeInteger(); + var createProperty = requireCreateProperty(); + var arraySpeciesCreate = requireArraySpeciesCreate(); + var arrayMethodHasSpeciesSupport = requireArrayMethodHasSpeciesSupport(); + var wellKnownSymbol = requireWellKnownSymbol(); + var V8_VERSION = requireEnvironmentV8Version(); + + var IS_CONCAT_SPREADABLE = wellKnownSymbol('isConcatSpreadable'); + + // We can't use this feature detection in V8 since it causes + // deoptimization and serious performance degradation + // https://github.com/zloirock/core-js/issues/679 + var IS_CONCAT_SPREADABLE_SUPPORT = V8_VERSION >= 51 || !fails(function () { + var array = []; + array[IS_CONCAT_SPREADABLE] = false; + return array.concat()[0] !== array; + }); + + var isConcatSpreadable = function (O) { + if (!isObject(O)) return false; + var spreadable = O[IS_CONCAT_SPREADABLE]; + return spreadable !== undefined ? !!spreadable : isArray(O); + }; + + var FORCED = !IS_CONCAT_SPREADABLE_SUPPORT || !arrayMethodHasSpeciesSupport('concat'); + + // `Array.prototype.concat` method + // https://tc39.es/ecma262/#sec-array.prototype.concat + // with adding support of @@isConcatSpreadable and @@species + $({ target: 'Array', proto: true, arity: 1, forced: FORCED }, { + // eslint-disable-next-line no-unused-vars -- required for `.length` + concat: function concat(arg) { + var O = toObject(this); + var A = arraySpeciesCreate(O, 0); + var n = 0; + var i, k, length, len, E; + for (i = -1, length = arguments.length; i < length; i++) { + E = i === -1 ? O : arguments[i]; + if (isConcatSpreadable(E)) { + len = lengthOfArrayLike(E); + doesNotExceedSafeInteger(n + len); + for (k = 0; k < len; k++, n++) if (k in E) createProperty(A, n, E[k]); + } else { + doesNotExceedSafeInteger(n + 1); + createProperty(A, n++, E); + } + } + A.length = n; + return A; + } + }); + return es_array_concat; +} + +var es_array_copyWithin = {}; + +var deletePropertyOrThrow; +var hasRequiredDeletePropertyOrThrow; + +function requireDeletePropertyOrThrow () { + if (hasRequiredDeletePropertyOrThrow) return deletePropertyOrThrow; + hasRequiredDeletePropertyOrThrow = 1; + var tryToString = requireTryToString(); + + var $TypeError = TypeError; + + deletePropertyOrThrow = function (O, P) { + if (!delete O[P]) throw new $TypeError('Cannot delete property ' + tryToString(P) + ' of ' + tryToString(O)); + }; + return deletePropertyOrThrow; +} + +var arrayCopyWithin; +var hasRequiredArrayCopyWithin; + +function requireArrayCopyWithin () { + if (hasRequiredArrayCopyWithin) return arrayCopyWithin; + hasRequiredArrayCopyWithin = 1; + var toObject = requireToObject(); + var toAbsoluteIndex = requireToAbsoluteIndex(); + var lengthOfArrayLike = requireLengthOfArrayLike(); + var deletePropertyOrThrow = requireDeletePropertyOrThrow(); + + var min = Math.min; + + // `Array.prototype.copyWithin` method implementation + // https://tc39.es/ecma262/#sec-array.prototype.copywithin + // eslint-disable-next-line es/no-array-prototype-copywithin -- safe + arrayCopyWithin = [].copyWithin || function copyWithin(target /* = 0 */, start /* = 0, end = @length */) { + var O = toObject(this); + var len = lengthOfArrayLike(O); + var to = toAbsoluteIndex(target, len); + var from = toAbsoluteIndex(start, len); + var end = arguments.length > 2 ? arguments[2] : undefined; + var count = min((end === undefined ? len : toAbsoluteIndex(end, len)) - from, len - to); + var inc = 1; + if (from < to && to < from + count) { + inc = -1; + from += count - 1; + to += count - 1; + } + while (count-- > 0) { + if (from in O) O[to] = O[from]; + else deletePropertyOrThrow(O, to); + to += inc; + from += inc; + } return O; + }; + return arrayCopyWithin; +} + +var hasRequiredEs_array_copyWithin; + +function requireEs_array_copyWithin () { + if (hasRequiredEs_array_copyWithin) return es_array_copyWithin; + hasRequiredEs_array_copyWithin = 1; + var $ = require_export(); + var copyWithin = requireArrayCopyWithin(); + var addToUnscopables = requireAddToUnscopables(); + + // `Array.prototype.copyWithin` method + // https://tc39.es/ecma262/#sec-array.prototype.copywithin + $({ target: 'Array', proto: true }, { + copyWithin: copyWithin + }); + + // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables + addToUnscopables('copyWithin'); + return es_array_copyWithin; +} + +var es_array_every = {}; + +var arrayMethodIsStrict; +var hasRequiredArrayMethodIsStrict; + +function requireArrayMethodIsStrict () { + if (hasRequiredArrayMethodIsStrict) return arrayMethodIsStrict; + hasRequiredArrayMethodIsStrict = 1; + var fails = requireFails(); + + arrayMethodIsStrict = function (METHOD_NAME, argument) { + var method = [][METHOD_NAME]; + return !!method && fails(function () { + // eslint-disable-next-line no-useless-call -- required for testing + method.call(null, argument || function () { return 1; }, 1); + }); + }; + return arrayMethodIsStrict; +} + +var hasRequiredEs_array_every; + +function requireEs_array_every () { + if (hasRequiredEs_array_every) return es_array_every; + hasRequiredEs_array_every = 1; + var $ = require_export(); + var $every = requireArrayIteration().every; + var arrayMethodIsStrict = requireArrayMethodIsStrict(); + + var STRICT_METHOD = arrayMethodIsStrict('every'); + + // `Array.prototype.every` method + // https://tc39.es/ecma262/#sec-array.prototype.every + $({ target: 'Array', proto: true, forced: !STRICT_METHOD }, { + every: function every(callbackfn /* , thisArg */) { + return $every(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined); + } + }); + return es_array_every; +} + +var es_array_fill = {}; + +var arrayFill; +var hasRequiredArrayFill; + +function requireArrayFill () { + if (hasRequiredArrayFill) return arrayFill; + hasRequiredArrayFill = 1; + var toObject = requireToObject(); + var toAbsoluteIndex = requireToAbsoluteIndex(); + var lengthOfArrayLike = requireLengthOfArrayLike(); + + // `Array.prototype.fill` method implementation + // https://tc39.es/ecma262/#sec-array.prototype.fill + arrayFill = function fill(value /* , start = 0, end = @length */) { + var O = toObject(this); + var length = lengthOfArrayLike(O); + var argumentsLength = arguments.length; + var index = toAbsoluteIndex(argumentsLength > 1 ? arguments[1] : undefined, length); + var end = argumentsLength > 2 ? arguments[2] : undefined; + var endPos = end === undefined ? length : toAbsoluteIndex(end, length); + while (endPos > index) O[index++] = value; + return O; + }; + return arrayFill; +} + +var hasRequiredEs_array_fill; + +function requireEs_array_fill () { + if (hasRequiredEs_array_fill) return es_array_fill; + hasRequiredEs_array_fill = 1; + var $ = require_export(); + var fill = requireArrayFill(); + var addToUnscopables = requireAddToUnscopables(); + + // `Array.prototype.fill` method + // https://tc39.es/ecma262/#sec-array.prototype.fill + $({ target: 'Array', proto: true }, { + fill: fill + }); + + // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables + addToUnscopables('fill'); + return es_array_fill; +} + +var es_array_filter = {}; + +var hasRequiredEs_array_filter; + +function requireEs_array_filter () { + if (hasRequiredEs_array_filter) return es_array_filter; + hasRequiredEs_array_filter = 1; + var $ = require_export(); + var $filter = requireArrayIteration().filter; + var arrayMethodHasSpeciesSupport = requireArrayMethodHasSpeciesSupport(); + + var HAS_SPECIES_SUPPORT = arrayMethodHasSpeciesSupport('filter'); + + // `Array.prototype.filter` method + // https://tc39.es/ecma262/#sec-array.prototype.filter + // with adding support of @@species + $({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT }, { + filter: function filter(callbackfn /* , thisArg */) { + return $filter(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined); + } + }); + return es_array_filter; +} + +var es_array_find = {}; + +var hasRequiredEs_array_find; + +function requireEs_array_find () { + if (hasRequiredEs_array_find) return es_array_find; + hasRequiredEs_array_find = 1; + var $ = require_export(); + var $find = requireArrayIteration().find; + var addToUnscopables = requireAddToUnscopables(); + + var FIND = 'find'; + var SKIPS_HOLES = true; + + // Shouldn't skip holes + // eslint-disable-next-line es/no-array-prototype-find -- testing + if (FIND in []) Array(1)[FIND](function () { SKIPS_HOLES = false; }); + + // `Array.prototype.find` method + // https://tc39.es/ecma262/#sec-array.prototype.find + $({ target: 'Array', proto: true, forced: SKIPS_HOLES }, { + find: function find(callbackfn /* , that = undefined */) { + return $find(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined); + } + }); + + // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables + addToUnscopables(FIND); + return es_array_find; +} + +var es_array_findIndex = {}; + +var hasRequiredEs_array_findIndex; + +function requireEs_array_findIndex () { + if (hasRequiredEs_array_findIndex) return es_array_findIndex; + hasRequiredEs_array_findIndex = 1; + var $ = require_export(); + var $findIndex = requireArrayIteration().findIndex; + var addToUnscopables = requireAddToUnscopables(); + + var FIND_INDEX = 'findIndex'; + var SKIPS_HOLES = true; + + // Shouldn't skip holes + // eslint-disable-next-line es/no-array-prototype-findindex -- testing + if (FIND_INDEX in []) Array(1)[FIND_INDEX](function () { SKIPS_HOLES = false; }); + + // `Array.prototype.findIndex` method + // https://tc39.es/ecma262/#sec-array.prototype.findindex + $({ target: 'Array', proto: true, forced: SKIPS_HOLES }, { + findIndex: function findIndex(callbackfn /* , that = undefined */) { + return $findIndex(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined); + } + }); + + // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables + addToUnscopables(FIND_INDEX); + return es_array_findIndex; +} + +var es_array_findLast = {}; + +var arrayIterationFromLast; +var hasRequiredArrayIterationFromLast; + +function requireArrayIterationFromLast () { + if (hasRequiredArrayIterationFromLast) return arrayIterationFromLast; + hasRequiredArrayIterationFromLast = 1; + var bind = requireFunctionBindContext(); + var IndexedObject = requireIndexedObject(); + var toObject = requireToObject(); + var lengthOfArrayLike = requireLengthOfArrayLike(); + + // `Array.prototype.{ findLast, findLastIndex }` methods implementation + var createMethod = function (TYPE) { + var IS_FIND_LAST_INDEX = TYPE === 1; + return function ($this, callbackfn, that) { + var O = toObject($this); + var self = IndexedObject(O); + var index = lengthOfArrayLike(self); + var boundFunction = bind(callbackfn, that); + var value, result; + while (index-- > 0) { + value = self[index]; + result = boundFunction(value, index, O); + if (result) switch (TYPE) { + case 0: return value; // findLast + case 1: return index; // findLastIndex + } + } + return IS_FIND_LAST_INDEX ? -1 : undefined; + }; + }; + + arrayIterationFromLast = { + // `Array.prototype.findLast` method + // https://github.com/tc39/proposal-array-find-from-last + findLast: createMethod(0), + // `Array.prototype.findLastIndex` method + // https://github.com/tc39/proposal-array-find-from-last + findLastIndex: createMethod(1) + }; + return arrayIterationFromLast; +} + +var hasRequiredEs_array_findLast; + +function requireEs_array_findLast () { + if (hasRequiredEs_array_findLast) return es_array_findLast; + hasRequiredEs_array_findLast = 1; + var $ = require_export(); + var $findLast = requireArrayIterationFromLast().findLast; + var addToUnscopables = requireAddToUnscopables(); + + // `Array.prototype.findLast` method + // https://tc39.es/ecma262/#sec-array.prototype.findlast + $({ target: 'Array', proto: true }, { + findLast: function findLast(callbackfn /* , that = undefined */) { + return $findLast(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined); + } + }); + + addToUnscopables('findLast'); + return es_array_findLast; +} + +var es_array_findLastIndex = {}; + +var hasRequiredEs_array_findLastIndex; + +function requireEs_array_findLastIndex () { + if (hasRequiredEs_array_findLastIndex) return es_array_findLastIndex; + hasRequiredEs_array_findLastIndex = 1; + var $ = require_export(); + var $findLastIndex = requireArrayIterationFromLast().findLastIndex; + var addToUnscopables = requireAddToUnscopables(); + + // `Array.prototype.findLastIndex` method + // https://tc39.es/ecma262/#sec-array.prototype.findlastindex + $({ target: 'Array', proto: true }, { + findLastIndex: function findLastIndex(callbackfn /* , that = undefined */) { + return $findLastIndex(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined); + } + }); + + addToUnscopables('findLastIndex'); + return es_array_findLastIndex; +} + +var es_array_flat = {}; + +var flattenIntoArray_1; +var hasRequiredFlattenIntoArray; + +function requireFlattenIntoArray () { + if (hasRequiredFlattenIntoArray) return flattenIntoArray_1; + hasRequiredFlattenIntoArray = 1; + var isArray = requireIsArray(); + var lengthOfArrayLike = requireLengthOfArrayLike(); + var doesNotExceedSafeInteger = requireDoesNotExceedSafeInteger(); + var bind = requireFunctionBindContext(); + + // `FlattenIntoArray` abstract operation + // https://tc39.github.io/proposal-flatMap/#sec-FlattenIntoArray + var flattenIntoArray = function (target, original, source, sourceLen, start, depth, mapper, thisArg) { + var targetIndex = start; + var sourceIndex = 0; + var mapFn = mapper ? bind(mapper, thisArg) : false; + var element, elementLen; + + while (sourceIndex < sourceLen) { + if (sourceIndex in source) { + element = mapFn ? mapFn(source[sourceIndex], sourceIndex, original) : source[sourceIndex]; + + if (depth > 0 && isArray(element)) { + elementLen = lengthOfArrayLike(element); + targetIndex = flattenIntoArray(target, original, element, elementLen, targetIndex, depth - 1) - 1; + } else { + doesNotExceedSafeInteger(targetIndex + 1); + target[targetIndex] = element; + } + + targetIndex++; + } + sourceIndex++; + } + return targetIndex; + }; + + flattenIntoArray_1 = flattenIntoArray; + return flattenIntoArray_1; +} + +var hasRequiredEs_array_flat; + +function requireEs_array_flat () { + if (hasRequiredEs_array_flat) return es_array_flat; + hasRequiredEs_array_flat = 1; + var $ = require_export(); + var flattenIntoArray = requireFlattenIntoArray(); + var toObject = requireToObject(); + var lengthOfArrayLike = requireLengthOfArrayLike(); + var toIntegerOrInfinity = requireToIntegerOrInfinity(); + var arraySpeciesCreate = requireArraySpeciesCreate(); + + // `Array.prototype.flat` method + // https://tc39.es/ecma262/#sec-array.prototype.flat + $({ target: 'Array', proto: true }, { + flat: function flat(/* depthArg = 1 */) { + var depthArg = arguments.length ? arguments[0] : undefined; + var O = toObject(this); + var sourceLen = lengthOfArrayLike(O); + var A = arraySpeciesCreate(O, 0); + A.length = flattenIntoArray(A, O, O, sourceLen, 0, depthArg === undefined ? 1 : toIntegerOrInfinity(depthArg)); + return A; + } + }); + return es_array_flat; +} + +var es_array_flatMap = {}; + +var hasRequiredEs_array_flatMap; + +function requireEs_array_flatMap () { + if (hasRequiredEs_array_flatMap) return es_array_flatMap; + hasRequiredEs_array_flatMap = 1; + var $ = require_export(); + var flattenIntoArray = requireFlattenIntoArray(); + var aCallable = requireACallable(); + var toObject = requireToObject(); + var lengthOfArrayLike = requireLengthOfArrayLike(); + var arraySpeciesCreate = requireArraySpeciesCreate(); + + // `Array.prototype.flatMap` method + // https://tc39.es/ecma262/#sec-array.prototype.flatmap + $({ target: 'Array', proto: true }, { + flatMap: function flatMap(callbackfn /* , thisArg */) { + var O = toObject(this); + var sourceLen = lengthOfArrayLike(O); + var A; + aCallable(callbackfn); + A = arraySpeciesCreate(O, 0); + A.length = flattenIntoArray(A, O, O, sourceLen, 0, 1, callbackfn, arguments.length > 1 ? arguments[1] : undefined); + return A; + } + }); + return es_array_flatMap; +} + +var es_array_forEach = {}; + +var arrayForEach; +var hasRequiredArrayForEach; + +function requireArrayForEach () { + if (hasRequiredArrayForEach) return arrayForEach; + hasRequiredArrayForEach = 1; + var $forEach = requireArrayIteration().forEach; + var arrayMethodIsStrict = requireArrayMethodIsStrict(); + + var STRICT_METHOD = arrayMethodIsStrict('forEach'); + + // `Array.prototype.forEach` method implementation + // https://tc39.es/ecma262/#sec-array.prototype.foreach + arrayForEach = !STRICT_METHOD ? function forEach(callbackfn /* , thisArg */) { + return $forEach(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined); + // eslint-disable-next-line es/no-array-prototype-foreach -- safe + } : [].forEach; + return arrayForEach; +} + +var hasRequiredEs_array_forEach; + +function requireEs_array_forEach () { + if (hasRequiredEs_array_forEach) return es_array_forEach; + hasRequiredEs_array_forEach = 1; + var $ = require_export(); + var forEach = requireArrayForEach(); + + // `Array.prototype.forEach` method + // https://tc39.es/ecma262/#sec-array.prototype.foreach + // eslint-disable-next-line es/no-array-prototype-foreach -- safe + $({ target: 'Array', proto: true, forced: [].forEach !== forEach }, { + forEach: forEach + }); + return es_array_forEach; +} + +var es_array_from = {}; + +var callWithSafeIterationClosing; +var hasRequiredCallWithSafeIterationClosing; + +function requireCallWithSafeIterationClosing () { + if (hasRequiredCallWithSafeIterationClosing) return callWithSafeIterationClosing; + hasRequiredCallWithSafeIterationClosing = 1; + var anObject = requireAnObject(); + var iteratorClose = requireIteratorClose(); + + // call something on iterator step with safe closing on error + callWithSafeIterationClosing = function (iterator, fn, value, ENTRIES) { + try { + return ENTRIES ? fn(anObject(value)[0], value[1]) : fn(value); + } catch (error) { + iteratorClose(iterator, 'throw', error); + } + }; + return callWithSafeIterationClosing; +} + +var arrayFrom; +var hasRequiredArrayFrom; + +function requireArrayFrom () { + if (hasRequiredArrayFrom) return arrayFrom; + hasRequiredArrayFrom = 1; + var bind = requireFunctionBindContext(); + var call = requireFunctionCall(); + var toObject = requireToObject(); + var callWithSafeIterationClosing = requireCallWithSafeIterationClosing(); + var isArrayIteratorMethod = requireIsArrayIteratorMethod(); + var isConstructor = requireIsConstructor(); + var lengthOfArrayLike = requireLengthOfArrayLike(); + var createProperty = requireCreateProperty(); + var getIterator = requireGetIterator(); + var getIteratorMethod = requireGetIteratorMethod(); + + var $Array = Array; + + // `Array.from` method implementation + // https://tc39.es/ecma262/#sec-array.from + arrayFrom = function from(arrayLike /* , mapfn = undefined, thisArg = undefined */) { + var O = toObject(arrayLike); + var IS_CONSTRUCTOR = isConstructor(this); + var argumentsLength = arguments.length; + var mapfn = argumentsLength > 1 ? arguments[1] : undefined; + var mapping = mapfn !== undefined; + if (mapping) mapfn = bind(mapfn, argumentsLength > 2 ? arguments[2] : undefined); + var iteratorMethod = getIteratorMethod(O); + var index = 0; + var length, result, step, iterator, next, value; + // if the target is not iterable or it's an array with the default iterator - use a simple case + if (iteratorMethod && !(this === $Array && isArrayIteratorMethod(iteratorMethod))) { + result = IS_CONSTRUCTOR ? new this() : []; + iterator = getIterator(O, iteratorMethod); + next = iterator.next; + for (;!(step = call(next, iterator)).done; index++) { + value = mapping ? callWithSafeIterationClosing(iterator, mapfn, [step.value, index], true) : step.value; + createProperty(result, index, value); + } + } else { + length = lengthOfArrayLike(O); + result = IS_CONSTRUCTOR ? new this(length) : $Array(length); + for (;length > index; index++) { + value = mapping ? mapfn(O[index], index) : O[index]; + createProperty(result, index, value); + } + } + result.length = index; + return result; + }; + return arrayFrom; +} + +var checkCorrectnessOfIteration; +var hasRequiredCheckCorrectnessOfIteration; + +function requireCheckCorrectnessOfIteration () { + if (hasRequiredCheckCorrectnessOfIteration) return checkCorrectnessOfIteration; + hasRequiredCheckCorrectnessOfIteration = 1; + var wellKnownSymbol = requireWellKnownSymbol(); + + var ITERATOR = wellKnownSymbol('iterator'); + var SAFE_CLOSING = false; + + try { + var called = 0; + var iteratorWithReturn = { + next: function () { + return { done: !!called++ }; + }, + 'return': function () { + SAFE_CLOSING = true; + } + }; + iteratorWithReturn[ITERATOR] = function () { + return this; + }; + // eslint-disable-next-line es/no-array-from, no-throw-literal -- required for testing + Array.from(iteratorWithReturn, function () { throw 2; }); + } catch (error) { /* empty */ } + + checkCorrectnessOfIteration = function (exec, SKIP_CLOSING) { + try { + if (!SKIP_CLOSING && !SAFE_CLOSING) return false; + } catch (error) { return false; } // workaround of old WebKit + `eval` bug + var ITERATION_SUPPORT = false; + try { + var object = {}; + object[ITERATOR] = function () { + return { + next: function () { + return { done: ITERATION_SUPPORT = true }; + } + }; + }; + exec(object); + } catch (error) { /* empty */ } + return ITERATION_SUPPORT; + }; + return checkCorrectnessOfIteration; +} + +var hasRequiredEs_array_from; + +function requireEs_array_from () { + if (hasRequiredEs_array_from) return es_array_from; + hasRequiredEs_array_from = 1; + var $ = require_export(); + var from = requireArrayFrom(); + var checkCorrectnessOfIteration = requireCheckCorrectnessOfIteration(); + + var INCORRECT_ITERATION = !checkCorrectnessOfIteration(function (iterable) { + // eslint-disable-next-line es/no-array-from -- required for testing + Array.from(iterable); + }); + + // `Array.from` method + // https://tc39.es/ecma262/#sec-array.from + $({ target: 'Array', stat: true, forced: INCORRECT_ITERATION }, { + from: from + }); + return es_array_from; +} + +var es_array_includes = {}; + +var hasRequiredEs_array_includes; + +function requireEs_array_includes () { + if (hasRequiredEs_array_includes) return es_array_includes; + hasRequiredEs_array_includes = 1; + var $ = require_export(); + var $includes = requireArrayIncludes().includes; + var fails = requireFails(); + var addToUnscopables = requireAddToUnscopables(); + + // FF99+ bug + var BROKEN_ON_SPARSE = fails(function () { + // eslint-disable-next-line es/no-array-prototype-includes -- detection + return !Array(1).includes(); + }); + + // `Array.prototype.includes` method + // https://tc39.es/ecma262/#sec-array.prototype.includes + $({ target: 'Array', proto: true, forced: BROKEN_ON_SPARSE }, { + includes: function includes(el /* , fromIndex = 0 */) { + return $includes(this, el, arguments.length > 1 ? arguments[1] : undefined); + } + }); + + // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables + addToUnscopables('includes'); + return es_array_includes; +} + +var es_array_indexOf = {}; + +var hasRequiredEs_array_indexOf; + +function requireEs_array_indexOf () { + if (hasRequiredEs_array_indexOf) return es_array_indexOf; + hasRequiredEs_array_indexOf = 1; + /* eslint-disable es/no-array-prototype-indexof -- required for testing */ + var $ = require_export(); + var uncurryThis = requireFunctionUncurryThisClause(); + var $indexOf = requireArrayIncludes().indexOf; + var arrayMethodIsStrict = requireArrayMethodIsStrict(); + + var nativeIndexOf = uncurryThis([].indexOf); + + var NEGATIVE_ZERO = !!nativeIndexOf && 1 / nativeIndexOf([1], 1, -0) < 0; + var FORCED = NEGATIVE_ZERO || !arrayMethodIsStrict('indexOf'); + + // `Array.prototype.indexOf` method + // https://tc39.es/ecma262/#sec-array.prototype.indexof + $({ target: 'Array', proto: true, forced: FORCED }, { + indexOf: function indexOf(searchElement /* , fromIndex = 0 */) { + var fromIndex = arguments.length > 1 ? arguments[1] : undefined; + return NEGATIVE_ZERO + // convert -0 to +0 + ? nativeIndexOf(this, searchElement, fromIndex) || 0 + : $indexOf(this, searchElement, fromIndex); + } + }); + return es_array_indexOf; +} + +var es_array_isArray = {}; + +var hasRequiredEs_array_isArray; + +function requireEs_array_isArray () { + if (hasRequiredEs_array_isArray) return es_array_isArray; + hasRequiredEs_array_isArray = 1; + var $ = require_export(); + var isArray = requireIsArray(); + + // `Array.isArray` method + // https://tc39.es/ecma262/#sec-array.isarray + $({ target: 'Array', stat: true }, { + isArray: isArray + }); + return es_array_isArray; +} + +var iteratorsCore; +var hasRequiredIteratorsCore; + +function requireIteratorsCore () { + if (hasRequiredIteratorsCore) return iteratorsCore; + hasRequiredIteratorsCore = 1; + var fails = requireFails(); + var isCallable = requireIsCallable(); + var isObject = requireIsObject(); + var create = requireObjectCreate(); + var getPrototypeOf = requireObjectGetPrototypeOf(); + var defineBuiltIn = requireDefineBuiltIn(); + var wellKnownSymbol = requireWellKnownSymbol(); + var IS_PURE = requireIsPure(); + + var ITERATOR = wellKnownSymbol('iterator'); + var BUGGY_SAFARI_ITERATORS = false; + + // `%IteratorPrototype%` object + // https://tc39.es/ecma262/#sec-%iteratorprototype%-object + var IteratorPrototype, PrototypeOfArrayIteratorPrototype, arrayIterator; + + /* eslint-disable es/no-array-prototype-keys -- safe */ + if ([].keys) { + arrayIterator = [].keys(); + // Safari 8 has buggy iterators w/o `next` + if (!('next' in arrayIterator)) BUGGY_SAFARI_ITERATORS = true; + else { + PrototypeOfArrayIteratorPrototype = getPrototypeOf(getPrototypeOf(arrayIterator)); + if (PrototypeOfArrayIteratorPrototype !== Object.prototype) IteratorPrototype = PrototypeOfArrayIteratorPrototype; + } + } + + var NEW_ITERATOR_PROTOTYPE = !isObject(IteratorPrototype) || fails(function () { + var test = {}; + // FF44- legacy iterators case + return IteratorPrototype[ITERATOR].call(test) !== test; + }); + + if (NEW_ITERATOR_PROTOTYPE) IteratorPrototype = {}; + else if (IS_PURE) IteratorPrototype = create(IteratorPrototype); + + // `%IteratorPrototype%[@@iterator]()` method + // https://tc39.es/ecma262/#sec-%iteratorprototype%-@@iterator + if (!isCallable(IteratorPrototype[ITERATOR])) { + defineBuiltIn(IteratorPrototype, ITERATOR, function () { + return this; + }); + } + + iteratorsCore = { + IteratorPrototype: IteratorPrototype, + BUGGY_SAFARI_ITERATORS: BUGGY_SAFARI_ITERATORS + }; + return iteratorsCore; +} + +var iteratorCreateConstructor; +var hasRequiredIteratorCreateConstructor; + +function requireIteratorCreateConstructor () { + if (hasRequiredIteratorCreateConstructor) return iteratorCreateConstructor; + hasRequiredIteratorCreateConstructor = 1; + var IteratorPrototype = requireIteratorsCore().IteratorPrototype; + var create = requireObjectCreate(); + var createPropertyDescriptor = requireCreatePropertyDescriptor(); + var setToStringTag = requireSetToStringTag(); + var Iterators = requireIterators(); + + var returnThis = function () { return this; }; + + iteratorCreateConstructor = function (IteratorConstructor, NAME, next, ENUMERABLE_NEXT) { + var TO_STRING_TAG = NAME + ' Iterator'; + IteratorConstructor.prototype = create(IteratorPrototype, { next: createPropertyDescriptor(+!ENUMERABLE_NEXT, next) }); + setToStringTag(IteratorConstructor, TO_STRING_TAG, false, true); + Iterators[TO_STRING_TAG] = returnThis; + return IteratorConstructor; + }; + return iteratorCreateConstructor; +} + +var iteratorDefine; +var hasRequiredIteratorDefine; + +function requireIteratorDefine () { + if (hasRequiredIteratorDefine) return iteratorDefine; + hasRequiredIteratorDefine = 1; + var $ = require_export(); + var call = requireFunctionCall(); + var IS_PURE = requireIsPure(); + var FunctionName = requireFunctionName(); + var isCallable = requireIsCallable(); + var createIteratorConstructor = requireIteratorCreateConstructor(); + var getPrototypeOf = requireObjectGetPrototypeOf(); + var setPrototypeOf = requireObjectSetPrototypeOf(); + var setToStringTag = requireSetToStringTag(); + var createNonEnumerableProperty = requireCreateNonEnumerableProperty(); + var defineBuiltIn = requireDefineBuiltIn(); + var wellKnownSymbol = requireWellKnownSymbol(); + var Iterators = requireIterators(); + var IteratorsCore = requireIteratorsCore(); + + var PROPER_FUNCTION_NAME = FunctionName.PROPER; + var CONFIGURABLE_FUNCTION_NAME = FunctionName.CONFIGURABLE; + var IteratorPrototype = IteratorsCore.IteratorPrototype; + var BUGGY_SAFARI_ITERATORS = IteratorsCore.BUGGY_SAFARI_ITERATORS; + var ITERATOR = wellKnownSymbol('iterator'); + var KEYS = 'keys'; + var VALUES = 'values'; + var ENTRIES = 'entries'; + + var returnThis = function () { return this; }; + + iteratorDefine = function (Iterable, NAME, IteratorConstructor, next, DEFAULT, IS_SET, FORCED) { + createIteratorConstructor(IteratorConstructor, NAME, next); + + var getIterationMethod = function (KIND) { + if (KIND === DEFAULT && defaultIterator) return defaultIterator; + if (!BUGGY_SAFARI_ITERATORS && KIND && KIND in IterablePrototype) return IterablePrototype[KIND]; + + switch (KIND) { + case KEYS: return function keys() { return new IteratorConstructor(this, KIND); }; + case VALUES: return function values() { return new IteratorConstructor(this, KIND); }; + case ENTRIES: return function entries() { return new IteratorConstructor(this, KIND); }; + } + + return function () { return new IteratorConstructor(this); }; + }; + + var TO_STRING_TAG = NAME + ' Iterator'; + var INCORRECT_VALUES_NAME = false; + var IterablePrototype = Iterable.prototype; + var nativeIterator = IterablePrototype[ITERATOR] + || IterablePrototype['@@iterator'] + || DEFAULT && IterablePrototype[DEFAULT]; + var defaultIterator = !BUGGY_SAFARI_ITERATORS && nativeIterator || getIterationMethod(DEFAULT); + var anyNativeIterator = NAME === 'Array' ? IterablePrototype.entries || nativeIterator : nativeIterator; + var CurrentIteratorPrototype, methods, KEY; + + // fix native + if (anyNativeIterator) { + CurrentIteratorPrototype = getPrototypeOf(anyNativeIterator.call(new Iterable())); + if (CurrentIteratorPrototype !== Object.prototype && CurrentIteratorPrototype.next) { + if (!IS_PURE && getPrototypeOf(CurrentIteratorPrototype) !== IteratorPrototype) { + if (setPrototypeOf) { + setPrototypeOf(CurrentIteratorPrototype, IteratorPrototype); + } else if (!isCallable(CurrentIteratorPrototype[ITERATOR])) { + defineBuiltIn(CurrentIteratorPrototype, ITERATOR, returnThis); + } + } + // Set @@toStringTag to native iterators + setToStringTag(CurrentIteratorPrototype, TO_STRING_TAG, true, true); + if (IS_PURE) Iterators[TO_STRING_TAG] = returnThis; + } + } + + // fix Array.prototype.{ values, @@iterator }.name in V8 / FF + if (PROPER_FUNCTION_NAME && DEFAULT === VALUES && nativeIterator && nativeIterator.name !== VALUES) { + if (!IS_PURE && CONFIGURABLE_FUNCTION_NAME) { + createNonEnumerableProperty(IterablePrototype, 'name', VALUES); + } else { + INCORRECT_VALUES_NAME = true; + defaultIterator = function values() { return call(nativeIterator, this); }; + } + } + + // export additional methods + if (DEFAULT) { + methods = { + values: getIterationMethod(VALUES), + keys: IS_SET ? defaultIterator : getIterationMethod(KEYS), + entries: getIterationMethod(ENTRIES) + }; + if (FORCED) for (KEY in methods) { + if (BUGGY_SAFARI_ITERATORS || INCORRECT_VALUES_NAME || !(KEY in IterablePrototype)) { + defineBuiltIn(IterablePrototype, KEY, methods[KEY]); + } + } else $({ target: NAME, proto: true, forced: BUGGY_SAFARI_ITERATORS || INCORRECT_VALUES_NAME }, methods); + } + + // define iterator + if ((!IS_PURE || FORCED) && IterablePrototype[ITERATOR] !== defaultIterator) { + defineBuiltIn(IterablePrototype, ITERATOR, defaultIterator, { name: DEFAULT }); + } + Iterators[NAME] = defaultIterator; + + return methods; + }; + return iteratorDefine; +} + +var createIterResultObject; +var hasRequiredCreateIterResultObject; + +function requireCreateIterResultObject () { + if (hasRequiredCreateIterResultObject) return createIterResultObject; + hasRequiredCreateIterResultObject = 1; + // `CreateIterResultObject` abstract operation + // https://tc39.es/ecma262/#sec-createiterresultobject + createIterResultObject = function (value, done) { + return { value: value, done: done }; + }; + return createIterResultObject; +} + +var es_array_iterator; +var hasRequiredEs_array_iterator; + +function requireEs_array_iterator () { + if (hasRequiredEs_array_iterator) return es_array_iterator; + hasRequiredEs_array_iterator = 1; + var toIndexedObject = requireToIndexedObject(); + var addToUnscopables = requireAddToUnscopables(); + var Iterators = requireIterators(); + var InternalStateModule = requireInternalState(); + var defineProperty = requireObjectDefineProperty().f; + var defineIterator = requireIteratorDefine(); + var createIterResultObject = requireCreateIterResultObject(); + var IS_PURE = requireIsPure(); + var DESCRIPTORS = requireDescriptors(); + + var ARRAY_ITERATOR = 'Array Iterator'; + var setInternalState = InternalStateModule.set; + var getInternalState = InternalStateModule.getterFor(ARRAY_ITERATOR); + + // `Array.prototype.entries` method + // https://tc39.es/ecma262/#sec-array.prototype.entries + // `Array.prototype.keys` method + // https://tc39.es/ecma262/#sec-array.prototype.keys + // `Array.prototype.values` method + // https://tc39.es/ecma262/#sec-array.prototype.values + // `Array.prototype[@@iterator]` method + // https://tc39.es/ecma262/#sec-array.prototype-@@iterator + // `CreateArrayIterator` internal method + // https://tc39.es/ecma262/#sec-createarrayiterator + es_array_iterator = defineIterator(Array, 'Array', function (iterated, kind) { + setInternalState(this, { + type: ARRAY_ITERATOR, + target: toIndexedObject(iterated), // target + index: 0, // next index + kind: kind // kind + }); + // `%ArrayIteratorPrototype%.next` method + // https://tc39.es/ecma262/#sec-%arrayiteratorprototype%.next + }, function () { + var state = getInternalState(this); + var target = state.target; + var index = state.index++; + if (!target || index >= target.length) { + state.target = null; + return createIterResultObject(undefined, true); + } + switch (state.kind) { + case 'keys': return createIterResultObject(index, false); + case 'values': return createIterResultObject(target[index], false); + } return createIterResultObject([index, target[index]], false); + }, 'values'); + + // argumentsList[@@iterator] is %ArrayProto_values% + // https://tc39.es/ecma262/#sec-createunmappedargumentsobject + // https://tc39.es/ecma262/#sec-createmappedargumentsobject + var values = Iterators.Arguments = Iterators.Array; + + // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables + addToUnscopables('keys'); + addToUnscopables('values'); + addToUnscopables('entries'); + + // V8 ~ Chrome 45- bug + if (!IS_PURE && DESCRIPTORS && values.name !== 'values') try { + defineProperty(values, 'name', { value: 'values' }); + } catch (error) { /* empty */ } + return es_array_iterator; +} + +var es_array_join = {}; + +var hasRequiredEs_array_join; + +function requireEs_array_join () { + if (hasRequiredEs_array_join) return es_array_join; + hasRequiredEs_array_join = 1; + var $ = require_export(); + var uncurryThis = requireFunctionUncurryThis(); + var IndexedObject = requireIndexedObject(); + var toIndexedObject = requireToIndexedObject(); + var arrayMethodIsStrict = requireArrayMethodIsStrict(); + + var nativeJoin = uncurryThis([].join); + + var ES3_STRINGS = IndexedObject !== Object; + var FORCED = ES3_STRINGS || !arrayMethodIsStrict('join', ','); + + // `Array.prototype.join` method + // https://tc39.es/ecma262/#sec-array.prototype.join + $({ target: 'Array', proto: true, forced: FORCED }, { + join: function join(separator) { + return nativeJoin(toIndexedObject(this), separator === undefined ? ',' : separator); + } + }); + return es_array_join; +} + +var es_array_lastIndexOf = {}; + +var arrayLastIndexOf; +var hasRequiredArrayLastIndexOf; + +function requireArrayLastIndexOf () { + if (hasRequiredArrayLastIndexOf) return arrayLastIndexOf; + hasRequiredArrayLastIndexOf = 1; + /* eslint-disable es/no-array-prototype-lastindexof -- safe */ + var apply = requireFunctionApply(); + var toIndexedObject = requireToIndexedObject(); + var toIntegerOrInfinity = requireToIntegerOrInfinity(); + var lengthOfArrayLike = requireLengthOfArrayLike(); + var arrayMethodIsStrict = requireArrayMethodIsStrict(); + + var min = Math.min; + var $lastIndexOf = [].lastIndexOf; + var NEGATIVE_ZERO = !!$lastIndexOf && 1 / [1].lastIndexOf(1, -0) < 0; + var STRICT_METHOD = arrayMethodIsStrict('lastIndexOf'); + var FORCED = NEGATIVE_ZERO || !STRICT_METHOD; + + // `Array.prototype.lastIndexOf` method implementation + // https://tc39.es/ecma262/#sec-array.prototype.lastindexof + arrayLastIndexOf = FORCED ? function lastIndexOf(searchElement /* , fromIndex = @[*-1] */) { + // convert -0 to +0 + if (NEGATIVE_ZERO) return apply($lastIndexOf, this, arguments) || 0; + var O = toIndexedObject(this); + var length = lengthOfArrayLike(O); + if (length === 0) return -1; + var index = length - 1; + if (arguments.length > 1) index = min(index, toIntegerOrInfinity(arguments[1])); + if (index < 0) index = length + index; + for (;index >= 0; index--) if (index in O && O[index] === searchElement) return index || 0; + return -1; + } : $lastIndexOf; + return arrayLastIndexOf; +} + +var hasRequiredEs_array_lastIndexOf; + +function requireEs_array_lastIndexOf () { + if (hasRequiredEs_array_lastIndexOf) return es_array_lastIndexOf; + hasRequiredEs_array_lastIndexOf = 1; + var $ = require_export(); + var lastIndexOf = requireArrayLastIndexOf(); + + // `Array.prototype.lastIndexOf` method + // https://tc39.es/ecma262/#sec-array.prototype.lastindexof + // eslint-disable-next-line es/no-array-prototype-lastindexof -- required for testing + $({ target: 'Array', proto: true, forced: lastIndexOf !== [].lastIndexOf }, { + lastIndexOf: lastIndexOf + }); + return es_array_lastIndexOf; +} + +var es_array_map = {}; + +var hasRequiredEs_array_map; + +function requireEs_array_map () { + if (hasRequiredEs_array_map) return es_array_map; + hasRequiredEs_array_map = 1; + var $ = require_export(); + var $map = requireArrayIteration().map; + var arrayMethodHasSpeciesSupport = requireArrayMethodHasSpeciesSupport(); + + var HAS_SPECIES_SUPPORT = arrayMethodHasSpeciesSupport('map'); + + // `Array.prototype.map` method + // https://tc39.es/ecma262/#sec-array.prototype.map + // with adding support of @@species + $({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT }, { + map: function map(callbackfn /* , thisArg */) { + return $map(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined); + } + }); + return es_array_map; +} + +var es_array_of = {}; + +var hasRequiredEs_array_of; + +function requireEs_array_of () { + if (hasRequiredEs_array_of) return es_array_of; + hasRequiredEs_array_of = 1; + var $ = require_export(); + var fails = requireFails(); + var isConstructor = requireIsConstructor(); + var createProperty = requireCreateProperty(); + + var $Array = Array; + + var ISNT_GENERIC = fails(function () { + function F() { /* empty */ } + // eslint-disable-next-line es/no-array-of -- safe + return !($Array.of.call(F) instanceof F); + }); + + // `Array.of` method + // https://tc39.es/ecma262/#sec-array.of + // WebKit Array.of isn't generic + $({ target: 'Array', stat: true, forced: ISNT_GENERIC }, { + of: function of(/* ...args */) { + var index = 0; + var argumentsLength = arguments.length; + var result = new (isConstructor(this) ? this : $Array)(argumentsLength); + while (argumentsLength > index) createProperty(result, index, arguments[index++]); + result.length = argumentsLength; + return result; + } + }); + return es_array_of; +} + +var es_array_push = {}; + +var arraySetLength; +var hasRequiredArraySetLength; + +function requireArraySetLength () { + if (hasRequiredArraySetLength) return arraySetLength; + hasRequiredArraySetLength = 1; + var DESCRIPTORS = requireDescriptors(); + var isArray = requireIsArray(); + + var $TypeError = TypeError; + // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe + var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; + + // Safari < 13 does not throw an error in this case + var SILENT_ON_NON_WRITABLE_LENGTH_SET = DESCRIPTORS && !function () { + // makes no sense without proper strict mode support + if (this !== undefined) return true; + try { + // eslint-disable-next-line es/no-object-defineproperty -- safe + Object.defineProperty([], 'length', { writable: false }).length = 1; + } catch (error) { + return error instanceof TypeError; + } + }(); + + arraySetLength = SILENT_ON_NON_WRITABLE_LENGTH_SET ? function (O, length) { + if (isArray(O) && !getOwnPropertyDescriptor(O, 'length').writable) { + throw new $TypeError('Cannot set read only .length'); + } return O.length = length; + } : function (O, length) { + return O.length = length; + }; + return arraySetLength; +} + +var hasRequiredEs_array_push; + +function requireEs_array_push () { + if (hasRequiredEs_array_push) return es_array_push; + hasRequiredEs_array_push = 1; + var $ = require_export(); + var toObject = requireToObject(); + var lengthOfArrayLike = requireLengthOfArrayLike(); + var setArrayLength = requireArraySetLength(); + var doesNotExceedSafeInteger = requireDoesNotExceedSafeInteger(); + var fails = requireFails(); + + var INCORRECT_TO_LENGTH = fails(function () { + return [].push.call({ length: 0x100000000 }, 1) !== 4294967297; + }); + + // V8 <= 121 and Safari <= 15.4; FF < 23 throws InternalError + // https://bugs.chromium.org/p/v8/issues/detail?id=12681 + var properErrorOnNonWritableLength = function () { + try { + // eslint-disable-next-line es/no-object-defineproperty -- safe + Object.defineProperty([], 'length', { writable: false }).push(); + } catch (error) { + return error instanceof TypeError; + } + }; + + var FORCED = INCORRECT_TO_LENGTH || !properErrorOnNonWritableLength(); + + // `Array.prototype.push` method + // https://tc39.es/ecma262/#sec-array.prototype.push + $({ target: 'Array', proto: true, arity: 1, forced: FORCED }, { + // eslint-disable-next-line no-unused-vars -- required for `.length` + push: function push(item) { + var O = toObject(this); + var len = lengthOfArrayLike(O); + var argCount = arguments.length; + doesNotExceedSafeInteger(len + argCount); + for (var i = 0; i < argCount; i++) { + O[len] = arguments[i]; + len++; + } + setArrayLength(O, len); + return len; + } + }); + return es_array_push; +} + +var es_array_reduce = {}; + +var arrayReduce; +var hasRequiredArrayReduce; + +function requireArrayReduce () { + if (hasRequiredArrayReduce) return arrayReduce; + hasRequiredArrayReduce = 1; + var aCallable = requireACallable(); + var toObject = requireToObject(); + var IndexedObject = requireIndexedObject(); + var lengthOfArrayLike = requireLengthOfArrayLike(); + + var $TypeError = TypeError; + + var REDUCE_EMPTY = 'Reduce of empty array with no initial value'; + + // `Array.prototype.{ reduce, reduceRight }` methods implementation + var createMethod = function (IS_RIGHT) { + return function (that, callbackfn, argumentsLength, memo) { + var O = toObject(that); + var self = IndexedObject(O); + var length = lengthOfArrayLike(O); + aCallable(callbackfn); + if (length === 0 && argumentsLength < 2) throw new $TypeError(REDUCE_EMPTY); + var index = IS_RIGHT ? length - 1 : 0; + var i = IS_RIGHT ? -1 : 1; + if (argumentsLength < 2) while (true) { + if (index in self) { + memo = self[index]; + index += i; + break; + } + index += i; + if (IS_RIGHT ? index < 0 : length <= index) { + throw new $TypeError(REDUCE_EMPTY); + } + } + for (;IS_RIGHT ? index >= 0 : length > index; index += i) if (index in self) { + memo = callbackfn(memo, self[index], index, O); + } + return memo; + }; + }; + + arrayReduce = { + // `Array.prototype.reduce` method + // https://tc39.es/ecma262/#sec-array.prototype.reduce + left: createMethod(false), + // `Array.prototype.reduceRight` method + // https://tc39.es/ecma262/#sec-array.prototype.reduceright + right: createMethod(true) + }; + return arrayReduce; +} + +var environment; +var hasRequiredEnvironment; + +function requireEnvironment () { + if (hasRequiredEnvironment) return environment; + hasRequiredEnvironment = 1; + /* global Bun, Deno -- detection */ + var globalThis = requireGlobalThis(); + var userAgent = requireEnvironmentUserAgent(); + var classof = requireClassofRaw(); + + var userAgentStartsWith = function (string) { + return userAgent.slice(0, string.length) === string; + }; + + environment = (function () { + if (userAgentStartsWith('Bun/')) return 'BUN'; + if (userAgentStartsWith('Cloudflare-Workers')) return 'CLOUDFLARE'; + if (userAgentStartsWith('Deno/')) return 'DENO'; + if (userAgentStartsWith('Node.js/')) return 'NODE'; + if (globalThis.Bun && typeof Bun.version == 'string') return 'BUN'; + if (globalThis.Deno && typeof Deno.version == 'object') return 'DENO'; + if (classof(globalThis.process) === 'process') return 'NODE'; + if (globalThis.window && globalThis.document) return 'BROWSER'; + return 'REST'; + })(); + return environment; +} + +var environmentIsNode; +var hasRequiredEnvironmentIsNode; + +function requireEnvironmentIsNode () { + if (hasRequiredEnvironmentIsNode) return environmentIsNode; + hasRequiredEnvironmentIsNode = 1; + var ENVIRONMENT = requireEnvironment(); + + environmentIsNode = ENVIRONMENT === 'NODE'; + return environmentIsNode; +} + +var hasRequiredEs_array_reduce; + +function requireEs_array_reduce () { + if (hasRequiredEs_array_reduce) return es_array_reduce; + hasRequiredEs_array_reduce = 1; + var $ = require_export(); + var $reduce = requireArrayReduce().left; + var arrayMethodIsStrict = requireArrayMethodIsStrict(); + var CHROME_VERSION = requireEnvironmentV8Version(); + var IS_NODE = requireEnvironmentIsNode(); + + // Chrome 80-82 has a critical bug + // https://bugs.chromium.org/p/chromium/issues/detail?id=1049982 + var CHROME_BUG = !IS_NODE && CHROME_VERSION > 79 && CHROME_VERSION < 83; + var FORCED = CHROME_BUG || !arrayMethodIsStrict('reduce'); + + // `Array.prototype.reduce` method + // https://tc39.es/ecma262/#sec-array.prototype.reduce + $({ target: 'Array', proto: true, forced: FORCED }, { + reduce: function reduce(callbackfn /* , initialValue */) { + var length = arguments.length; + return $reduce(this, callbackfn, length, length > 1 ? arguments[1] : undefined); + } + }); + return es_array_reduce; +} + +var es_array_reduceRight = {}; + +var hasRequiredEs_array_reduceRight; + +function requireEs_array_reduceRight () { + if (hasRequiredEs_array_reduceRight) return es_array_reduceRight; + hasRequiredEs_array_reduceRight = 1; + var $ = require_export(); + var $reduceRight = requireArrayReduce().right; + var arrayMethodIsStrict = requireArrayMethodIsStrict(); + var CHROME_VERSION = requireEnvironmentV8Version(); + var IS_NODE = requireEnvironmentIsNode(); + + // Chrome 80-82 has a critical bug + // https://bugs.chromium.org/p/chromium/issues/detail?id=1049982 + var CHROME_BUG = !IS_NODE && CHROME_VERSION > 79 && CHROME_VERSION < 83; + var FORCED = CHROME_BUG || !arrayMethodIsStrict('reduceRight'); + + // `Array.prototype.reduceRight` method + // https://tc39.es/ecma262/#sec-array.prototype.reduceright + $({ target: 'Array', proto: true, forced: FORCED }, { + reduceRight: function reduceRight(callbackfn /* , initialValue */) { + return $reduceRight(this, callbackfn, arguments.length, arguments.length > 1 ? arguments[1] : undefined); + } + }); + return es_array_reduceRight; +} + +var es_array_reverse = {}; + +var hasRequiredEs_array_reverse; + +function requireEs_array_reverse () { + if (hasRequiredEs_array_reverse) return es_array_reverse; + hasRequiredEs_array_reverse = 1; + var $ = require_export(); + var uncurryThis = requireFunctionUncurryThis(); + var isArray = requireIsArray(); + + var nativeReverse = uncurryThis([].reverse); + var test = [1, 2]; + + // `Array.prototype.reverse` method + // https://tc39.es/ecma262/#sec-array.prototype.reverse + // fix for Safari 12.0 bug + // https://bugs.webkit.org/show_bug.cgi?id=188794 + $({ target: 'Array', proto: true, forced: String(test) === String(test.reverse()) }, { + reverse: function reverse() { + // eslint-disable-next-line no-self-assign -- dirty hack + if (isArray(this)) this.length = this.length; + return nativeReverse(this); + } + }); + return es_array_reverse; +} + +var es_array_slice = {}; + +var hasRequiredEs_array_slice; + +function requireEs_array_slice () { + if (hasRequiredEs_array_slice) return es_array_slice; + hasRequiredEs_array_slice = 1; + var $ = require_export(); + var isArray = requireIsArray(); + var isConstructor = requireIsConstructor(); + var isObject = requireIsObject(); + var toAbsoluteIndex = requireToAbsoluteIndex(); + var lengthOfArrayLike = requireLengthOfArrayLike(); + var toIndexedObject = requireToIndexedObject(); + var createProperty = requireCreateProperty(); + var wellKnownSymbol = requireWellKnownSymbol(); + var arrayMethodHasSpeciesSupport = requireArrayMethodHasSpeciesSupport(); + var nativeSlice = requireArraySlice(); + + var HAS_SPECIES_SUPPORT = arrayMethodHasSpeciesSupport('slice'); + + var SPECIES = wellKnownSymbol('species'); + var $Array = Array; + var max = Math.max; + + // `Array.prototype.slice` method + // https://tc39.es/ecma262/#sec-array.prototype.slice + // fallback for not array-like ES3 strings and DOM objects + $({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT }, { + slice: function slice(start, end) { + var O = toIndexedObject(this); + var length = lengthOfArrayLike(O); + var k = toAbsoluteIndex(start, length); + var fin = toAbsoluteIndex(end === undefined ? length : end, length); + // inline `ArraySpeciesCreate` for usage native `Array#slice` where it's possible + var Constructor, result, n; + if (isArray(O)) { + Constructor = O.constructor; + // cross-realm fallback + if (isConstructor(Constructor) && (Constructor === $Array || isArray(Constructor.prototype))) { + Constructor = undefined; + } else if (isObject(Constructor)) { + Constructor = Constructor[SPECIES]; + if (Constructor === null) Constructor = undefined; + } + if (Constructor === $Array || Constructor === undefined) { + return nativeSlice(O, k, fin); + } + } + result = new (Constructor === undefined ? $Array : Constructor)(max(fin - k, 0)); + for (n = 0; k < fin; k++, n++) if (k in O) createProperty(result, n, O[k]); + result.length = n; + return result; + } + }); + return es_array_slice; +} + +var es_array_some = {}; + +var hasRequiredEs_array_some; + +function requireEs_array_some () { + if (hasRequiredEs_array_some) return es_array_some; + hasRequiredEs_array_some = 1; + var $ = require_export(); + var $some = requireArrayIteration().some; + var arrayMethodIsStrict = requireArrayMethodIsStrict(); + + var STRICT_METHOD = arrayMethodIsStrict('some'); + + // `Array.prototype.some` method + // https://tc39.es/ecma262/#sec-array.prototype.some + $({ target: 'Array', proto: true, forced: !STRICT_METHOD }, { + some: function some(callbackfn /* , thisArg */) { + return $some(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined); + } + }); + return es_array_some; +} + +var es_array_sort = {}; + +var arraySort; +var hasRequiredArraySort; + +function requireArraySort () { + if (hasRequiredArraySort) return arraySort; + hasRequiredArraySort = 1; + var arraySlice = requireArraySlice(); + + var floor = Math.floor; + + var sort = function (array, comparefn) { + var length = array.length; + + if (length < 8) { + // insertion sort + var i = 1; + var element, j; + + while (i < length) { + j = i; + element = array[i]; + while (j && comparefn(array[j - 1], element) > 0) { + array[j] = array[--j]; + } + if (j !== i++) array[j] = element; + } + } else { + // merge sort + var middle = floor(length / 2); + var left = sort(arraySlice(array, 0, middle), comparefn); + var right = sort(arraySlice(array, middle), comparefn); + var llength = left.length; + var rlength = right.length; + var lindex = 0; + var rindex = 0; + + while (lindex < llength || rindex < rlength) { + array[lindex + rindex] = (lindex < llength && rindex < rlength) + ? comparefn(left[lindex], right[rindex]) <= 0 ? left[lindex++] : right[rindex++] + : lindex < llength ? left[lindex++] : right[rindex++]; + } + } + + return array; + }; + + arraySort = sort; + return arraySort; +} + +var environmentFfVersion; +var hasRequiredEnvironmentFfVersion; + +function requireEnvironmentFfVersion () { + if (hasRequiredEnvironmentFfVersion) return environmentFfVersion; + hasRequiredEnvironmentFfVersion = 1; + var userAgent = requireEnvironmentUserAgent(); + + var firefox = userAgent.match(/firefox\/(\d+)/i); + + environmentFfVersion = !!firefox && +firefox[1]; + return environmentFfVersion; +} + +var environmentIsIeOrEdge; +var hasRequiredEnvironmentIsIeOrEdge; + +function requireEnvironmentIsIeOrEdge () { + if (hasRequiredEnvironmentIsIeOrEdge) return environmentIsIeOrEdge; + hasRequiredEnvironmentIsIeOrEdge = 1; + var UA = requireEnvironmentUserAgent(); + + environmentIsIeOrEdge = /MSIE|Trident/.test(UA); + return environmentIsIeOrEdge; +} + +var environmentWebkitVersion; +var hasRequiredEnvironmentWebkitVersion; + +function requireEnvironmentWebkitVersion () { + if (hasRequiredEnvironmentWebkitVersion) return environmentWebkitVersion; + hasRequiredEnvironmentWebkitVersion = 1; + var userAgent = requireEnvironmentUserAgent(); + + var webkit = userAgent.match(/AppleWebKit\/(\d+)\./); + + environmentWebkitVersion = !!webkit && +webkit[1]; + return environmentWebkitVersion; +} + +var hasRequiredEs_array_sort; + +function requireEs_array_sort () { + if (hasRequiredEs_array_sort) return es_array_sort; + hasRequiredEs_array_sort = 1; + var $ = require_export(); + var uncurryThis = requireFunctionUncurryThis(); + var aCallable = requireACallable(); + var toObject = requireToObject(); + var lengthOfArrayLike = requireLengthOfArrayLike(); + var deletePropertyOrThrow = requireDeletePropertyOrThrow(); + var toString = requireToString(); + var fails = requireFails(); + var internalSort = requireArraySort(); + var arrayMethodIsStrict = requireArrayMethodIsStrict(); + var FF = requireEnvironmentFfVersion(); + var IE_OR_EDGE = requireEnvironmentIsIeOrEdge(); + var V8 = requireEnvironmentV8Version(); + var WEBKIT = requireEnvironmentWebkitVersion(); + + var test = []; + var nativeSort = uncurryThis(test.sort); + var push = uncurryThis(test.push); + + // IE8- + var FAILS_ON_UNDEFINED = fails(function () { + test.sort(undefined); + }); + // V8 bug + var FAILS_ON_NULL = fails(function () { + test.sort(null); + }); + // Old WebKit + var STRICT_METHOD = arrayMethodIsStrict('sort'); + + var STABLE_SORT = !fails(function () { + // feature detection can be too slow, so check engines versions + if (V8) return V8 < 70; + if (FF && FF > 3) return; + if (IE_OR_EDGE) return true; + if (WEBKIT) return WEBKIT < 603; + + var result = ''; + var code, chr, value, index; + + // generate an array with more 512 elements (Chakra and old V8 fails only in this case) + for (code = 65; code < 76; code++) { + chr = String.fromCharCode(code); + + switch (code) { + case 66: case 69: case 70: case 72: value = 3; break; + case 68: case 71: value = 4; break; + default: value = 2; + } + + for (index = 0; index < 47; index++) { + test.push({ k: chr + index, v: value }); + } + } + + test.sort(function (a, b) { return b.v - a.v; }); + + for (index = 0; index < test.length; index++) { + chr = test[index].k.charAt(0); + if (result.charAt(result.length - 1) !== chr) result += chr; + } + + return result !== 'DGBEFHACIJK'; + }); + + var FORCED = FAILS_ON_UNDEFINED || !FAILS_ON_NULL || !STRICT_METHOD || !STABLE_SORT; + + var getSortCompare = function (comparefn) { + return function (x, y) { + if (y === undefined) return -1; + if (x === undefined) return 1; + if (comparefn !== undefined) return +comparefn(x, y) || 0; + return toString(x) > toString(y) ? 1 : -1; + }; + }; + + // `Array.prototype.sort` method + // https://tc39.es/ecma262/#sec-array.prototype.sort + $({ target: 'Array', proto: true, forced: FORCED }, { + sort: function sort(comparefn) { + if (comparefn !== undefined) aCallable(comparefn); + + var array = toObject(this); + + if (STABLE_SORT) return comparefn === undefined ? nativeSort(array) : nativeSort(array, comparefn); + + var items = []; + var arrayLength = lengthOfArrayLike(array); + var itemsLength, index; + + for (index = 0; index < arrayLength; index++) { + if (index in array) push(items, array[index]); + } + + internalSort(items, getSortCompare(comparefn)); + + itemsLength = lengthOfArrayLike(items); + index = 0; + + while (index < itemsLength) array[index] = items[index++]; + while (index < arrayLength) deletePropertyOrThrow(array, index++); + + return array; + } + }); + return es_array_sort; +} + +var es_array_species = {}; + +var setSpecies; +var hasRequiredSetSpecies; + +function requireSetSpecies () { + if (hasRequiredSetSpecies) return setSpecies; + hasRequiredSetSpecies = 1; + var getBuiltIn = requireGetBuiltIn(); + var defineBuiltInAccessor = requireDefineBuiltInAccessor(); + var wellKnownSymbol = requireWellKnownSymbol(); + var DESCRIPTORS = requireDescriptors(); + + var SPECIES = wellKnownSymbol('species'); + + setSpecies = function (CONSTRUCTOR_NAME) { + var Constructor = getBuiltIn(CONSTRUCTOR_NAME); + + if (DESCRIPTORS && Constructor && !Constructor[SPECIES]) { + defineBuiltInAccessor(Constructor, SPECIES, { + configurable: true, + get: function () { return this; } + }); + } + }; + return setSpecies; +} + +var hasRequiredEs_array_species; + +function requireEs_array_species () { + if (hasRequiredEs_array_species) return es_array_species; + hasRequiredEs_array_species = 1; + var setSpecies = requireSetSpecies(); + + // `Array[@@species]` getter + // https://tc39.es/ecma262/#sec-get-array-@@species + setSpecies('Array'); + return es_array_species; +} + +var es_array_splice = {}; + +var hasRequiredEs_array_splice; + +function requireEs_array_splice () { + if (hasRequiredEs_array_splice) return es_array_splice; + hasRequiredEs_array_splice = 1; + var $ = require_export(); + var toObject = requireToObject(); + var toAbsoluteIndex = requireToAbsoluteIndex(); + var toIntegerOrInfinity = requireToIntegerOrInfinity(); + var lengthOfArrayLike = requireLengthOfArrayLike(); + var setArrayLength = requireArraySetLength(); + var doesNotExceedSafeInteger = requireDoesNotExceedSafeInteger(); + var arraySpeciesCreate = requireArraySpeciesCreate(); + var createProperty = requireCreateProperty(); + var deletePropertyOrThrow = requireDeletePropertyOrThrow(); + var arrayMethodHasSpeciesSupport = requireArrayMethodHasSpeciesSupport(); + + var HAS_SPECIES_SUPPORT = arrayMethodHasSpeciesSupport('splice'); + + var max = Math.max; + var min = Math.min; + + // `Array.prototype.splice` method + // https://tc39.es/ecma262/#sec-array.prototype.splice + // with adding support of @@species + $({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT }, { + splice: function splice(start, deleteCount /* , ...items */) { + var O = toObject(this); + var len = lengthOfArrayLike(O); + var actualStart = toAbsoluteIndex(start, len); + var argumentsLength = arguments.length; + var insertCount, actualDeleteCount, A, k, from, to; + if (argumentsLength === 0) { + insertCount = actualDeleteCount = 0; + } else if (argumentsLength === 1) { + insertCount = 0; + actualDeleteCount = len - actualStart; + } else { + insertCount = argumentsLength - 2; + actualDeleteCount = min(max(toIntegerOrInfinity(deleteCount), 0), len - actualStart); + } + doesNotExceedSafeInteger(len + insertCount - actualDeleteCount); + A = arraySpeciesCreate(O, actualDeleteCount); + for (k = 0; k < actualDeleteCount; k++) { + from = actualStart + k; + if (from in O) createProperty(A, k, O[from]); + } + A.length = actualDeleteCount; + if (insertCount < actualDeleteCount) { + for (k = actualStart; k < len - actualDeleteCount; k++) { + from = k + actualDeleteCount; + to = k + insertCount; + if (from in O) O[to] = O[from]; + else deletePropertyOrThrow(O, to); + } + for (k = len; k > len - actualDeleteCount + insertCount; k--) deletePropertyOrThrow(O, k - 1); + } else if (insertCount > actualDeleteCount) { + for (k = len - actualDeleteCount; k > actualStart; k--) { + from = k + actualDeleteCount - 1; + to = k + insertCount - 1; + if (from in O) O[to] = O[from]; + else deletePropertyOrThrow(O, to); + } + } + for (k = 0; k < insertCount; k++) { + O[k + actualStart] = arguments[k + 2]; + } + setArrayLength(O, len - actualDeleteCount + insertCount); + return A; + } + }); + return es_array_splice; +} + +var es_array_toReversed = {}; + +var arrayToReversed; +var hasRequiredArrayToReversed; + +function requireArrayToReversed () { + if (hasRequiredArrayToReversed) return arrayToReversed; + hasRequiredArrayToReversed = 1; + var lengthOfArrayLike = requireLengthOfArrayLike(); + + // https://tc39.es/proposal-change-array-by-copy/#sec-array.prototype.toReversed + // https://tc39.es/proposal-change-array-by-copy/#sec-%typedarray%.prototype.toReversed + arrayToReversed = function (O, C) { + var len = lengthOfArrayLike(O); + var A = new C(len); + var k = 0; + for (; k < len; k++) A[k] = O[len - k - 1]; + return A; + }; + return arrayToReversed; +} + +var hasRequiredEs_array_toReversed; + +function requireEs_array_toReversed () { + if (hasRequiredEs_array_toReversed) return es_array_toReversed; + hasRequiredEs_array_toReversed = 1; + var $ = require_export(); + var arrayToReversed = requireArrayToReversed(); + var toIndexedObject = requireToIndexedObject(); + var addToUnscopables = requireAddToUnscopables(); + + var $Array = Array; + + // `Array.prototype.toReversed` method + // https://tc39.es/ecma262/#sec-array.prototype.toreversed + $({ target: 'Array', proto: true }, { + toReversed: function toReversed() { + return arrayToReversed(toIndexedObject(this), $Array); + } + }); + + addToUnscopables('toReversed'); + return es_array_toReversed; +} + +var es_array_toSorted = {}; + +var arrayFromConstructorAndList; +var hasRequiredArrayFromConstructorAndList; + +function requireArrayFromConstructorAndList () { + if (hasRequiredArrayFromConstructorAndList) return arrayFromConstructorAndList; + hasRequiredArrayFromConstructorAndList = 1; + var lengthOfArrayLike = requireLengthOfArrayLike(); + + arrayFromConstructorAndList = function (Constructor, list, $length) { + var index = 0; + var length = arguments.length > 2 ? $length : lengthOfArrayLike(list); + var result = new Constructor(length); + while (length > index) result[index] = list[index++]; + return result; + }; + return arrayFromConstructorAndList; +} + +var getBuiltInPrototypeMethod; +var hasRequiredGetBuiltInPrototypeMethod; + +function requireGetBuiltInPrototypeMethod () { + if (hasRequiredGetBuiltInPrototypeMethod) return getBuiltInPrototypeMethod; + hasRequiredGetBuiltInPrototypeMethod = 1; + var globalThis = requireGlobalThis(); + + getBuiltInPrototypeMethod = function (CONSTRUCTOR, METHOD) { + var Constructor = globalThis[CONSTRUCTOR]; + var Prototype = Constructor && Constructor.prototype; + return Prototype && Prototype[METHOD]; + }; + return getBuiltInPrototypeMethod; +} + +var hasRequiredEs_array_toSorted; + +function requireEs_array_toSorted () { + if (hasRequiredEs_array_toSorted) return es_array_toSorted; + hasRequiredEs_array_toSorted = 1; + var $ = require_export(); + var uncurryThis = requireFunctionUncurryThis(); + var aCallable = requireACallable(); + var toIndexedObject = requireToIndexedObject(); + var arrayFromConstructorAndList = requireArrayFromConstructorAndList(); + var getBuiltInPrototypeMethod = requireGetBuiltInPrototypeMethod(); + var addToUnscopables = requireAddToUnscopables(); + + var $Array = Array; + var sort = uncurryThis(getBuiltInPrototypeMethod('Array', 'sort')); + + // `Array.prototype.toSorted` method + // https://tc39.es/ecma262/#sec-array.prototype.tosorted + $({ target: 'Array', proto: true }, { + toSorted: function toSorted(compareFn) { + if (compareFn !== undefined) aCallable(compareFn); + var O = toIndexedObject(this); + var A = arrayFromConstructorAndList($Array, O); + return sort(A, compareFn); + } + }); + + addToUnscopables('toSorted'); + return es_array_toSorted; +} + +var es_array_toSpliced = {}; + +var hasRequiredEs_array_toSpliced; + +function requireEs_array_toSpliced () { + if (hasRequiredEs_array_toSpliced) return es_array_toSpliced; + hasRequiredEs_array_toSpliced = 1; + var $ = require_export(); + var addToUnscopables = requireAddToUnscopables(); + var doesNotExceedSafeInteger = requireDoesNotExceedSafeInteger(); + var lengthOfArrayLike = requireLengthOfArrayLike(); + var toAbsoluteIndex = requireToAbsoluteIndex(); + var toIndexedObject = requireToIndexedObject(); + var toIntegerOrInfinity = requireToIntegerOrInfinity(); + + var $Array = Array; + var max = Math.max; + var min = Math.min; + + // `Array.prototype.toSpliced` method + // https://tc39.es/ecma262/#sec-array.prototype.tospliced + $({ target: 'Array', proto: true }, { + toSpliced: function toSpliced(start, deleteCount /* , ...items */) { + var O = toIndexedObject(this); + var len = lengthOfArrayLike(O); + var actualStart = toAbsoluteIndex(start, len); + var argumentsLength = arguments.length; + var k = 0; + var insertCount, actualDeleteCount, newLen, A; + if (argumentsLength === 0) { + insertCount = actualDeleteCount = 0; + } else if (argumentsLength === 1) { + insertCount = 0; + actualDeleteCount = len - actualStart; + } else { + insertCount = argumentsLength - 2; + actualDeleteCount = min(max(toIntegerOrInfinity(deleteCount), 0), len - actualStart); + } + newLen = doesNotExceedSafeInteger(len + insertCount - actualDeleteCount); + A = $Array(newLen); + + for (; k < actualStart; k++) A[k] = O[k]; + for (; k < actualStart + insertCount; k++) A[k] = arguments[k - actualStart + 2]; + for (; k < newLen; k++) A[k] = O[k + actualDeleteCount - insertCount]; + + return A; + } + }); + + addToUnscopables('toSpliced'); + return es_array_toSpliced; +} + +var es_array_unscopables_flat = {}; + +var hasRequiredEs_array_unscopables_flat; + +function requireEs_array_unscopables_flat () { + if (hasRequiredEs_array_unscopables_flat) return es_array_unscopables_flat; + hasRequiredEs_array_unscopables_flat = 1; + // this method was added to unscopables after implementation + // in popular engines, so it's moved to a separate module + var addToUnscopables = requireAddToUnscopables(); + + // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables + addToUnscopables('flat'); + return es_array_unscopables_flat; +} + +var es_array_unscopables_flatMap = {}; + +var hasRequiredEs_array_unscopables_flatMap; + +function requireEs_array_unscopables_flatMap () { + if (hasRequiredEs_array_unscopables_flatMap) return es_array_unscopables_flatMap; + hasRequiredEs_array_unscopables_flatMap = 1; + // this method was added to unscopables after implementation + // in popular engines, so it's moved to a separate module + var addToUnscopables = requireAddToUnscopables(); + + // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables + addToUnscopables('flatMap'); + return es_array_unscopables_flatMap; +} + +var es_array_unshift = {}; + +var hasRequiredEs_array_unshift; + +function requireEs_array_unshift () { + if (hasRequiredEs_array_unshift) return es_array_unshift; + hasRequiredEs_array_unshift = 1; + var $ = require_export(); + var toObject = requireToObject(); + var lengthOfArrayLike = requireLengthOfArrayLike(); + var setArrayLength = requireArraySetLength(); + var deletePropertyOrThrow = requireDeletePropertyOrThrow(); + var doesNotExceedSafeInteger = requireDoesNotExceedSafeInteger(); + + // IE8- + var INCORRECT_RESULT = [].unshift(0) !== 1; + + // V8 ~ Chrome < 71 and Safari <= 15.4, FF < 23 throws InternalError + var properErrorOnNonWritableLength = function () { + try { + // eslint-disable-next-line es/no-object-defineproperty -- safe + Object.defineProperty([], 'length', { writable: false }).unshift(); + } catch (error) { + return error instanceof TypeError; + } + }; + + var FORCED = INCORRECT_RESULT || !properErrorOnNonWritableLength(); + + // `Array.prototype.unshift` method + // https://tc39.es/ecma262/#sec-array.prototype.unshift + $({ target: 'Array', proto: true, arity: 1, forced: FORCED }, { + // eslint-disable-next-line no-unused-vars -- required for `.length` + unshift: function unshift(item) { + var O = toObject(this); + var len = lengthOfArrayLike(O); + var argCount = arguments.length; + if (argCount) { + doesNotExceedSafeInteger(len + argCount); + var k = len; + while (k--) { + var to = k + argCount; + if (k in O) O[to] = O[k]; + else deletePropertyOrThrow(O, to); + } + for (var j = 0; j < argCount; j++) { + O[j] = arguments[j]; + } + } return setArrayLength(O, len + argCount); + } + }); + return es_array_unshift; +} + +var es_array_with = {}; + +var arrayWith; +var hasRequiredArrayWith; + +function requireArrayWith () { + if (hasRequiredArrayWith) return arrayWith; + hasRequiredArrayWith = 1; + var lengthOfArrayLike = requireLengthOfArrayLike(); + var toIntegerOrInfinity = requireToIntegerOrInfinity(); + + var $RangeError = RangeError; + + // https://tc39.es/proposal-change-array-by-copy/#sec-array.prototype.with + // https://tc39.es/proposal-change-array-by-copy/#sec-%typedarray%.prototype.with + arrayWith = function (O, C, index, value) { + var len = lengthOfArrayLike(O); + var relativeIndex = toIntegerOrInfinity(index); + var actualIndex = relativeIndex < 0 ? len + relativeIndex : relativeIndex; + if (actualIndex >= len || actualIndex < 0) throw new $RangeError('Incorrect index'); + var A = new C(len); + var k = 0; + for (; k < len; k++) A[k] = k === actualIndex ? value : O[k]; + return A; + }; + return arrayWith; +} + +var hasRequiredEs_array_with; + +function requireEs_array_with () { + if (hasRequiredEs_array_with) return es_array_with; + hasRequiredEs_array_with = 1; + var $ = require_export(); + var arrayWith = requireArrayWith(); + var toIndexedObject = requireToIndexedObject(); + + var $Array = Array; + + // `Array.prototype.with` method + // https://tc39.es/ecma262/#sec-array.prototype.with + $({ target: 'Array', proto: true }, { + 'with': function (index, value) { + return arrayWith(toIndexedObject(this), $Array, index, value); + } + }); + return es_array_with; +} + +var es_arrayBuffer_constructor = {}; + +var arrayBufferBasicDetection; +var hasRequiredArrayBufferBasicDetection; + +function requireArrayBufferBasicDetection () { + if (hasRequiredArrayBufferBasicDetection) return arrayBufferBasicDetection; + hasRequiredArrayBufferBasicDetection = 1; + // eslint-disable-next-line es/no-typed-arrays -- safe + arrayBufferBasicDetection = typeof ArrayBuffer != 'undefined' && typeof DataView != 'undefined'; + return arrayBufferBasicDetection; +} + +var defineBuiltIns; +var hasRequiredDefineBuiltIns; + +function requireDefineBuiltIns () { + if (hasRequiredDefineBuiltIns) return defineBuiltIns; + hasRequiredDefineBuiltIns = 1; + var defineBuiltIn = requireDefineBuiltIn(); + + defineBuiltIns = function (target, src, options) { + for (var key in src) defineBuiltIn(target, key, src[key], options); + return target; + }; + return defineBuiltIns; +} + +var anInstance; +var hasRequiredAnInstance; + +function requireAnInstance () { + if (hasRequiredAnInstance) return anInstance; + hasRequiredAnInstance = 1; + var isPrototypeOf = requireObjectIsPrototypeOf(); + + var $TypeError = TypeError; + + anInstance = function (it, Prototype) { + if (isPrototypeOf(Prototype, it)) return it; + throw new $TypeError('Incorrect invocation'); + }; + return anInstance; +} + +var toIndex; +var hasRequiredToIndex; + +function requireToIndex () { + if (hasRequiredToIndex) return toIndex; + hasRequiredToIndex = 1; + var toIntegerOrInfinity = requireToIntegerOrInfinity(); + var toLength = requireToLength(); + + var $RangeError = RangeError; + + // `ToIndex` abstract operation + // https://tc39.es/ecma262/#sec-toindex + toIndex = function (it) { + if (it === undefined) return 0; + var number = toIntegerOrInfinity(it); + var length = toLength(number); + if (number !== length) throw new $RangeError('Wrong length or index'); + return length; + }; + return toIndex; +} + +var mathSign; +var hasRequiredMathSign; + +function requireMathSign () { + if (hasRequiredMathSign) return mathSign; + hasRequiredMathSign = 1; + // `Math.sign` method implementation + // https://tc39.es/ecma262/#sec-math.sign + // eslint-disable-next-line es/no-math-sign -- safe + mathSign = Math.sign || function sign(x) { + var n = +x; + // eslint-disable-next-line no-self-compare -- NaN check + return n === 0 || n !== n ? n : n < 0 ? -1 : 1; + }; + return mathSign; +} + +var mathFloatRound; +var hasRequiredMathFloatRound; + +function requireMathFloatRound () { + if (hasRequiredMathFloatRound) return mathFloatRound; + hasRequiredMathFloatRound = 1; + var sign = requireMathSign(); + + var abs = Math.abs; + + var EPSILON = 2.220446049250313e-16; // Number.EPSILON + var INVERSE_EPSILON = 1 / EPSILON; + + var roundTiesToEven = function (n) { + return n + INVERSE_EPSILON - INVERSE_EPSILON; + }; + + mathFloatRound = function (x, FLOAT_EPSILON, FLOAT_MAX_VALUE, FLOAT_MIN_VALUE) { + var n = +x; + var absolute = abs(n); + var s = sign(n); + if (absolute < FLOAT_MIN_VALUE) return s * roundTiesToEven(absolute / FLOAT_MIN_VALUE / FLOAT_EPSILON) * FLOAT_MIN_VALUE * FLOAT_EPSILON; + var a = (1 + FLOAT_EPSILON / EPSILON) * absolute; + var result = a - (a - absolute); + // eslint-disable-next-line no-self-compare -- NaN check + if (result > FLOAT_MAX_VALUE || result !== result) return s * Infinity; + return s * result; + }; + return mathFloatRound; +} + +var mathFround; +var hasRequiredMathFround; + +function requireMathFround () { + if (hasRequiredMathFround) return mathFround; + hasRequiredMathFround = 1; + var floatRound = requireMathFloatRound(); + + var FLOAT32_EPSILON = 1.1920928955078125e-7; // 2 ** -23; + var FLOAT32_MAX_VALUE = 3.4028234663852886e+38; // 2 ** 128 - 2 ** 104 + var FLOAT32_MIN_VALUE = 1.1754943508222875e-38; // 2 ** -126; + + // `Math.fround` method implementation + // https://tc39.es/ecma262/#sec-math.fround + // eslint-disable-next-line es/no-math-fround -- safe + mathFround = Math.fround || function fround(x) { + return floatRound(x, FLOAT32_EPSILON, FLOAT32_MAX_VALUE, FLOAT32_MIN_VALUE); + }; + return mathFround; +} + +var ieee754; +var hasRequiredIeee754; + +function requireIeee754 () { + if (hasRequiredIeee754) return ieee754; + hasRequiredIeee754 = 1; + // IEEE754 conversions based on https://github.com/feross/ieee754 + var $Array = Array; + var abs = Math.abs; + var pow = Math.pow; + var floor = Math.floor; + var log = Math.log; + var LN2 = Math.LN2; + + var pack = function (number, mantissaLength, bytes) { + var buffer = $Array(bytes); + var exponentLength = bytes * 8 - mantissaLength - 1; + var eMax = (1 << exponentLength) - 1; + var eBias = eMax >> 1; + var rt = mantissaLength === 23 ? pow(2, -24) - pow(2, -77) : 0; + var sign = number < 0 || number === 0 && 1 / number < 0 ? 1 : 0; + var index = 0; + var exponent, mantissa, c; + number = abs(number); + // eslint-disable-next-line no-self-compare -- NaN check + if (number !== number || number === Infinity) { + // eslint-disable-next-line no-self-compare -- NaN check + mantissa = number !== number ? 1 : 0; + exponent = eMax; + } else { + exponent = floor(log(number) / LN2); + c = pow(2, -exponent); + if (number * c < 1) { + exponent--; + c *= 2; + } + if (exponent + eBias >= 1) { + number += rt / c; + } else { + number += rt * pow(2, 1 - eBias); + } + if (number * c >= 2) { + exponent++; + c /= 2; + } + if (exponent + eBias >= eMax) { + mantissa = 0; + exponent = eMax; + } else if (exponent + eBias >= 1) { + mantissa = (number * c - 1) * pow(2, mantissaLength); + exponent += eBias; + } else { + mantissa = number * pow(2, eBias - 1) * pow(2, mantissaLength); + exponent = 0; + } + } + while (mantissaLength >= 8) { + buffer[index++] = mantissa & 255; + mantissa /= 256; + mantissaLength -= 8; + } + exponent = exponent << mantissaLength | mantissa; + exponentLength += mantissaLength; + while (exponentLength > 0) { + buffer[index++] = exponent & 255; + exponent /= 256; + exponentLength -= 8; + } + buffer[index - 1] |= sign * 128; + return buffer; + }; + + var unpack = function (buffer, mantissaLength) { + var bytes = buffer.length; + var exponentLength = bytes * 8 - mantissaLength - 1; + var eMax = (1 << exponentLength) - 1; + var eBias = eMax >> 1; + var nBits = exponentLength - 7; + var index = bytes - 1; + var sign = buffer[index--]; + var exponent = sign & 127; + var mantissa; + sign >>= 7; + while (nBits > 0) { + exponent = exponent * 256 + buffer[index--]; + nBits -= 8; + } + mantissa = exponent & (1 << -nBits) - 1; + exponent >>= -nBits; + nBits += mantissaLength; + while (nBits > 0) { + mantissa = mantissa * 256 + buffer[index--]; + nBits -= 8; + } + if (exponent === 0) { + exponent = 1 - eBias; + } else if (exponent === eMax) { + return mantissa ? NaN : sign ? -Infinity : Infinity; + } else { + mantissa += pow(2, mantissaLength); + exponent -= eBias; + } return (sign ? -1 : 1) * mantissa * pow(2, exponent - mantissaLength); + }; + + ieee754 = { + pack: pack, + unpack: unpack + }; + return ieee754; +} + +var arrayBuffer; +var hasRequiredArrayBuffer; + +function requireArrayBuffer () { + if (hasRequiredArrayBuffer) return arrayBuffer; + hasRequiredArrayBuffer = 1; + var globalThis = requireGlobalThis(); + var uncurryThis = requireFunctionUncurryThis(); + var DESCRIPTORS = requireDescriptors(); + var NATIVE_ARRAY_BUFFER = requireArrayBufferBasicDetection(); + var FunctionName = requireFunctionName(); + var createNonEnumerableProperty = requireCreateNonEnumerableProperty(); + var defineBuiltInAccessor = requireDefineBuiltInAccessor(); + var defineBuiltIns = requireDefineBuiltIns(); + var fails = requireFails(); + var anInstance = requireAnInstance(); + var toIntegerOrInfinity = requireToIntegerOrInfinity(); + var toLength = requireToLength(); + var toIndex = requireToIndex(); + var fround = requireMathFround(); + var IEEE754 = requireIeee754(); + var getPrototypeOf = requireObjectGetPrototypeOf(); + var setPrototypeOf = requireObjectSetPrototypeOf(); + var arrayFill = requireArrayFill(); + var arraySlice = requireArraySlice(); + var inheritIfRequired = requireInheritIfRequired(); + var copyConstructorProperties = requireCopyConstructorProperties(); + var setToStringTag = requireSetToStringTag(); + var InternalStateModule = requireInternalState(); + + var PROPER_FUNCTION_NAME = FunctionName.PROPER; + var CONFIGURABLE_FUNCTION_NAME = FunctionName.CONFIGURABLE; + var ARRAY_BUFFER = 'ArrayBuffer'; + var DATA_VIEW = 'DataView'; + var PROTOTYPE = 'prototype'; + var WRONG_LENGTH = 'Wrong length'; + var WRONG_INDEX = 'Wrong index'; + var getInternalArrayBufferState = InternalStateModule.getterFor(ARRAY_BUFFER); + var getInternalDataViewState = InternalStateModule.getterFor(DATA_VIEW); + var setInternalState = InternalStateModule.set; + var NativeArrayBuffer = globalThis[ARRAY_BUFFER]; + var $ArrayBuffer = NativeArrayBuffer; + var ArrayBufferPrototype = $ArrayBuffer && $ArrayBuffer[PROTOTYPE]; + var $DataView = globalThis[DATA_VIEW]; + var DataViewPrototype = $DataView && $DataView[PROTOTYPE]; + var ObjectPrototype = Object.prototype; + var Array = globalThis.Array; + var RangeError = globalThis.RangeError; + var fill = uncurryThis(arrayFill); + var reverse = uncurryThis([].reverse); + + var packIEEE754 = IEEE754.pack; + var unpackIEEE754 = IEEE754.unpack; + + var packInt8 = function (number) { + return [number & 0xFF]; + }; + + var packInt16 = function (number) { + return [number & 0xFF, number >> 8 & 0xFF]; + }; + + var packInt32 = function (number) { + return [number & 0xFF, number >> 8 & 0xFF, number >> 16 & 0xFF, number >> 24 & 0xFF]; + }; + + var unpackInt32 = function (buffer) { + return buffer[3] << 24 | buffer[2] << 16 | buffer[1] << 8 | buffer[0]; + }; + + var packFloat32 = function (number) { + return packIEEE754(fround(number), 23, 4); + }; + + var packFloat64 = function (number) { + return packIEEE754(number, 52, 8); + }; + + var addGetter = function (Constructor, key, getInternalState) { + defineBuiltInAccessor(Constructor[PROTOTYPE], key, { + configurable: true, + get: function () { + return getInternalState(this)[key]; + } + }); + }; + + var get = function (view, count, index, isLittleEndian) { + var store = getInternalDataViewState(view); + var intIndex = toIndex(index); + var boolIsLittleEndian = !!isLittleEndian; + if (intIndex + count > store.byteLength) throw new RangeError(WRONG_INDEX); + var bytes = store.bytes; + var start = intIndex + store.byteOffset; + var pack = arraySlice(bytes, start, start + count); + return boolIsLittleEndian ? pack : reverse(pack); + }; + + var set = function (view, count, index, conversion, value, isLittleEndian) { + var store = getInternalDataViewState(view); + var intIndex = toIndex(index); + var pack = conversion(+value); + var boolIsLittleEndian = !!isLittleEndian; + if (intIndex + count > store.byteLength) throw new RangeError(WRONG_INDEX); + var bytes = store.bytes; + var start = intIndex + store.byteOffset; + for (var i = 0; i < count; i++) bytes[start + i] = pack[boolIsLittleEndian ? i : count - i - 1]; + }; + + if (!NATIVE_ARRAY_BUFFER) { + $ArrayBuffer = function ArrayBuffer(length) { + anInstance(this, ArrayBufferPrototype); + var byteLength = toIndex(length); + setInternalState(this, { + type: ARRAY_BUFFER, + bytes: fill(Array(byteLength), 0), + byteLength: byteLength + }); + if (!DESCRIPTORS) { + this.byteLength = byteLength; + this.detached = false; + } + }; + + ArrayBufferPrototype = $ArrayBuffer[PROTOTYPE]; + + $DataView = function DataView(buffer, byteOffset, byteLength) { + anInstance(this, DataViewPrototype); + anInstance(buffer, ArrayBufferPrototype); + var bufferState = getInternalArrayBufferState(buffer); + var bufferLength = bufferState.byteLength; + var offset = toIntegerOrInfinity(byteOffset); + if (offset < 0 || offset > bufferLength) throw new RangeError('Wrong offset'); + byteLength = byteLength === undefined ? bufferLength - offset : toLength(byteLength); + if (offset + byteLength > bufferLength) throw new RangeError(WRONG_LENGTH); + setInternalState(this, { + type: DATA_VIEW, + buffer: buffer, + byteLength: byteLength, + byteOffset: offset, + bytes: bufferState.bytes + }); + if (!DESCRIPTORS) { + this.buffer = buffer; + this.byteLength = byteLength; + this.byteOffset = offset; + } + }; + + DataViewPrototype = $DataView[PROTOTYPE]; + + if (DESCRIPTORS) { + addGetter($ArrayBuffer, 'byteLength', getInternalArrayBufferState); + addGetter($DataView, 'buffer', getInternalDataViewState); + addGetter($DataView, 'byteLength', getInternalDataViewState); + addGetter($DataView, 'byteOffset', getInternalDataViewState); + } + + defineBuiltIns(DataViewPrototype, { + getInt8: function getInt8(byteOffset) { + return get(this, 1, byteOffset)[0] << 24 >> 24; + }, + getUint8: function getUint8(byteOffset) { + return get(this, 1, byteOffset)[0]; + }, + getInt16: function getInt16(byteOffset /* , littleEndian */) { + var bytes = get(this, 2, byteOffset, arguments.length > 1 ? arguments[1] : false); + return (bytes[1] << 8 | bytes[0]) << 16 >> 16; + }, + getUint16: function getUint16(byteOffset /* , littleEndian */) { + var bytes = get(this, 2, byteOffset, arguments.length > 1 ? arguments[1] : false); + return bytes[1] << 8 | bytes[0]; + }, + getInt32: function getInt32(byteOffset /* , littleEndian */) { + return unpackInt32(get(this, 4, byteOffset, arguments.length > 1 ? arguments[1] : false)); + }, + getUint32: function getUint32(byteOffset /* , littleEndian */) { + return unpackInt32(get(this, 4, byteOffset, arguments.length > 1 ? arguments[1] : false)) >>> 0; + }, + getFloat32: function getFloat32(byteOffset /* , littleEndian */) { + return unpackIEEE754(get(this, 4, byteOffset, arguments.length > 1 ? arguments[1] : false), 23); + }, + getFloat64: function getFloat64(byteOffset /* , littleEndian */) { + return unpackIEEE754(get(this, 8, byteOffset, arguments.length > 1 ? arguments[1] : false), 52); + }, + setInt8: function setInt8(byteOffset, value) { + set(this, 1, byteOffset, packInt8, value); + }, + setUint8: function setUint8(byteOffset, value) { + set(this, 1, byteOffset, packInt8, value); + }, + setInt16: function setInt16(byteOffset, value /* , littleEndian */) { + set(this, 2, byteOffset, packInt16, value, arguments.length > 2 ? arguments[2] : false); + }, + setUint16: function setUint16(byteOffset, value /* , littleEndian */) { + set(this, 2, byteOffset, packInt16, value, arguments.length > 2 ? arguments[2] : false); + }, + setInt32: function setInt32(byteOffset, value /* , littleEndian */) { + set(this, 4, byteOffset, packInt32, value, arguments.length > 2 ? arguments[2] : false); + }, + setUint32: function setUint32(byteOffset, value /* , littleEndian */) { + set(this, 4, byteOffset, packInt32, value, arguments.length > 2 ? arguments[2] : false); + }, + setFloat32: function setFloat32(byteOffset, value /* , littleEndian */) { + set(this, 4, byteOffset, packFloat32, value, arguments.length > 2 ? arguments[2] : false); + }, + setFloat64: function setFloat64(byteOffset, value /* , littleEndian */) { + set(this, 8, byteOffset, packFloat64, value, arguments.length > 2 ? arguments[2] : false); + } + }); + } else { + var INCORRECT_ARRAY_BUFFER_NAME = PROPER_FUNCTION_NAME && NativeArrayBuffer.name !== ARRAY_BUFFER; + /* eslint-disable no-new, sonar/inconsistent-function-call -- required for testing */ + if (!fails(function () { + NativeArrayBuffer(1); + }) || !fails(function () { + new NativeArrayBuffer(-1); + }) || fails(function () { + new NativeArrayBuffer(); + new NativeArrayBuffer(1.5); + new NativeArrayBuffer(NaN); + return NativeArrayBuffer.length !== 1 || INCORRECT_ARRAY_BUFFER_NAME && !CONFIGURABLE_FUNCTION_NAME; + })) { + /* eslint-enable no-new, sonar/inconsistent-function-call -- required for testing */ + $ArrayBuffer = function ArrayBuffer(length) { + anInstance(this, ArrayBufferPrototype); + return inheritIfRequired(new NativeArrayBuffer(toIndex(length)), this, $ArrayBuffer); + }; + + $ArrayBuffer[PROTOTYPE] = ArrayBufferPrototype; + + ArrayBufferPrototype.constructor = $ArrayBuffer; + + copyConstructorProperties($ArrayBuffer, NativeArrayBuffer); + } else if (INCORRECT_ARRAY_BUFFER_NAME && CONFIGURABLE_FUNCTION_NAME) { + createNonEnumerableProperty(NativeArrayBuffer, 'name', ARRAY_BUFFER); + } + + // WebKit bug - the same parent prototype for typed arrays and data view + if (setPrototypeOf && getPrototypeOf(DataViewPrototype) !== ObjectPrototype) { + setPrototypeOf(DataViewPrototype, ObjectPrototype); + } + + // iOS Safari 7.x bug + var testView = new $DataView(new $ArrayBuffer(2)); + var $setInt8 = uncurryThis(DataViewPrototype.setInt8); + testView.setInt8(0, 2147483648); + testView.setInt8(1, 2147483649); + if (testView.getInt8(0) || !testView.getInt8(1)) defineBuiltIns(DataViewPrototype, { + setInt8: function setInt8(byteOffset, value) { + $setInt8(this, byteOffset, value << 24 >> 24); + }, + setUint8: function setUint8(byteOffset, value) { + $setInt8(this, byteOffset, value << 24 >> 24); + } + }, { unsafe: true }); + } + + setToStringTag($ArrayBuffer, ARRAY_BUFFER); + setToStringTag($DataView, DATA_VIEW); + + arrayBuffer = { + ArrayBuffer: $ArrayBuffer, + DataView: $DataView + }; + return arrayBuffer; +} + +var hasRequiredEs_arrayBuffer_constructor; + +function requireEs_arrayBuffer_constructor () { + if (hasRequiredEs_arrayBuffer_constructor) return es_arrayBuffer_constructor; + hasRequiredEs_arrayBuffer_constructor = 1; + var $ = require_export(); + var globalThis = requireGlobalThis(); + var arrayBufferModule = requireArrayBuffer(); + var setSpecies = requireSetSpecies(); + + var ARRAY_BUFFER = 'ArrayBuffer'; + var ArrayBuffer = arrayBufferModule[ARRAY_BUFFER]; + var NativeArrayBuffer = globalThis[ARRAY_BUFFER]; + + // `ArrayBuffer` constructor + // https://tc39.es/ecma262/#sec-arraybuffer-constructor + $({ global: true, constructor: true, forced: NativeArrayBuffer !== ArrayBuffer }, { + ArrayBuffer: ArrayBuffer + }); + + setSpecies(ARRAY_BUFFER); + return es_arrayBuffer_constructor; +} + +var es_arrayBuffer_isView = {}; + +var arrayBufferViewCore; +var hasRequiredArrayBufferViewCore; + +function requireArrayBufferViewCore () { + if (hasRequiredArrayBufferViewCore) return arrayBufferViewCore; + hasRequiredArrayBufferViewCore = 1; + var NATIVE_ARRAY_BUFFER = requireArrayBufferBasicDetection(); + var DESCRIPTORS = requireDescriptors(); + var globalThis = requireGlobalThis(); + var isCallable = requireIsCallable(); + var isObject = requireIsObject(); + var hasOwn = requireHasOwnProperty(); + var classof = requireClassof(); + var tryToString = requireTryToString(); + var createNonEnumerableProperty = requireCreateNonEnumerableProperty(); + var defineBuiltIn = requireDefineBuiltIn(); + var defineBuiltInAccessor = requireDefineBuiltInAccessor(); + var isPrototypeOf = requireObjectIsPrototypeOf(); + var getPrototypeOf = requireObjectGetPrototypeOf(); + var setPrototypeOf = requireObjectSetPrototypeOf(); + var wellKnownSymbol = requireWellKnownSymbol(); + var uid = requireUid(); + var InternalStateModule = requireInternalState(); + + var enforceInternalState = InternalStateModule.enforce; + var getInternalState = InternalStateModule.get; + var Int8Array = globalThis.Int8Array; + var Int8ArrayPrototype = Int8Array && Int8Array.prototype; + var Uint8ClampedArray = globalThis.Uint8ClampedArray; + var Uint8ClampedArrayPrototype = Uint8ClampedArray && Uint8ClampedArray.prototype; + var TypedArray = Int8Array && getPrototypeOf(Int8Array); + var TypedArrayPrototype = Int8ArrayPrototype && getPrototypeOf(Int8ArrayPrototype); + var ObjectPrototype = Object.prototype; + var TypeError = globalThis.TypeError; + + var TO_STRING_TAG = wellKnownSymbol('toStringTag'); + var TYPED_ARRAY_TAG = uid('TYPED_ARRAY_TAG'); + var TYPED_ARRAY_CONSTRUCTOR = 'TypedArrayConstructor'; + // Fixing native typed arrays in Opera Presto crashes the browser, see #595 + var NATIVE_ARRAY_BUFFER_VIEWS = NATIVE_ARRAY_BUFFER && !!setPrototypeOf && classof(globalThis.opera) !== 'Opera'; + var TYPED_ARRAY_TAG_REQUIRED = false; + var NAME, Constructor, Prototype; + + var TypedArrayConstructorsList = { + Int8Array: 1, + Uint8Array: 1, + Uint8ClampedArray: 1, + Int16Array: 2, + Uint16Array: 2, + Int32Array: 4, + Uint32Array: 4, + Float32Array: 4, + Float64Array: 8 + }; + + var BigIntArrayConstructorsList = { + BigInt64Array: 8, + BigUint64Array: 8 + }; + + var isView = function isView(it) { + if (!isObject(it)) return false; + var klass = classof(it); + return klass === 'DataView' + || hasOwn(TypedArrayConstructorsList, klass) + || hasOwn(BigIntArrayConstructorsList, klass); + }; + + var getTypedArrayConstructor = function (it) { + var proto = getPrototypeOf(it); + if (!isObject(proto)) return; + var state = getInternalState(proto); + return (state && hasOwn(state, TYPED_ARRAY_CONSTRUCTOR)) ? state[TYPED_ARRAY_CONSTRUCTOR] : getTypedArrayConstructor(proto); + }; + + var isTypedArray = function (it) { + if (!isObject(it)) return false; + var klass = classof(it); + return hasOwn(TypedArrayConstructorsList, klass) + || hasOwn(BigIntArrayConstructorsList, klass); + }; + + var aTypedArray = function (it) { + if (isTypedArray(it)) return it; + throw new TypeError('Target is not a typed array'); + }; + + var aTypedArrayConstructor = function (C) { + if (isCallable(C) && (!setPrototypeOf || isPrototypeOf(TypedArray, C))) return C; + throw new TypeError(tryToString(C) + ' is not a typed array constructor'); + }; + + var exportTypedArrayMethod = function (KEY, property, forced, options) { + if (!DESCRIPTORS) return; + if (forced) for (var ARRAY in TypedArrayConstructorsList) { + var TypedArrayConstructor = globalThis[ARRAY]; + if (TypedArrayConstructor && hasOwn(TypedArrayConstructor.prototype, KEY)) try { + delete TypedArrayConstructor.prototype[KEY]; + } catch (error) { + // old WebKit bug - some methods are non-configurable + try { + TypedArrayConstructor.prototype[KEY] = property; + } catch (error2) { /* empty */ } + } + } + if (!TypedArrayPrototype[KEY] || forced) { + defineBuiltIn(TypedArrayPrototype, KEY, forced ? property + : NATIVE_ARRAY_BUFFER_VIEWS && Int8ArrayPrototype[KEY] || property, options); + } + }; + + var exportTypedArrayStaticMethod = function (KEY, property, forced) { + var ARRAY, TypedArrayConstructor; + if (!DESCRIPTORS) return; + if (setPrototypeOf) { + if (forced) for (ARRAY in TypedArrayConstructorsList) { + TypedArrayConstructor = globalThis[ARRAY]; + if (TypedArrayConstructor && hasOwn(TypedArrayConstructor, KEY)) try { + delete TypedArrayConstructor[KEY]; + } catch (error) { /* empty */ } + } + if (!TypedArray[KEY] || forced) { + // V8 ~ Chrome 49-50 `%TypedArray%` methods are non-writable non-configurable + try { + return defineBuiltIn(TypedArray, KEY, forced ? property : NATIVE_ARRAY_BUFFER_VIEWS && TypedArray[KEY] || property); + } catch (error) { /* empty */ } + } else return; + } + for (ARRAY in TypedArrayConstructorsList) { + TypedArrayConstructor = globalThis[ARRAY]; + if (TypedArrayConstructor && (!TypedArrayConstructor[KEY] || forced)) { + defineBuiltIn(TypedArrayConstructor, KEY, property); + } + } + }; + + for (NAME in TypedArrayConstructorsList) { + Constructor = globalThis[NAME]; + Prototype = Constructor && Constructor.prototype; + if (Prototype) enforceInternalState(Prototype)[TYPED_ARRAY_CONSTRUCTOR] = Constructor; + else NATIVE_ARRAY_BUFFER_VIEWS = false; + } + + for (NAME in BigIntArrayConstructorsList) { + Constructor = globalThis[NAME]; + Prototype = Constructor && Constructor.prototype; + if (Prototype) enforceInternalState(Prototype)[TYPED_ARRAY_CONSTRUCTOR] = Constructor; + } + + // WebKit bug - typed arrays constructors prototype is Object.prototype + if (!NATIVE_ARRAY_BUFFER_VIEWS || !isCallable(TypedArray) || TypedArray === Function.prototype) { + // eslint-disable-next-line no-shadow -- safe + TypedArray = function TypedArray() { + throw new TypeError('Incorrect invocation'); + }; + if (NATIVE_ARRAY_BUFFER_VIEWS) for (NAME in TypedArrayConstructorsList) { + if (globalThis[NAME]) setPrototypeOf(globalThis[NAME], TypedArray); + } + } + + if (!NATIVE_ARRAY_BUFFER_VIEWS || !TypedArrayPrototype || TypedArrayPrototype === ObjectPrototype) { + TypedArrayPrototype = TypedArray.prototype; + if (NATIVE_ARRAY_BUFFER_VIEWS) for (NAME in TypedArrayConstructorsList) { + if (globalThis[NAME]) setPrototypeOf(globalThis[NAME].prototype, TypedArrayPrototype); + } + } + + // WebKit bug - one more object in Uint8ClampedArray prototype chain + if (NATIVE_ARRAY_BUFFER_VIEWS && getPrototypeOf(Uint8ClampedArrayPrototype) !== TypedArrayPrototype) { + setPrototypeOf(Uint8ClampedArrayPrototype, TypedArrayPrototype); + } + + if (DESCRIPTORS && !hasOwn(TypedArrayPrototype, TO_STRING_TAG)) { + TYPED_ARRAY_TAG_REQUIRED = true; + defineBuiltInAccessor(TypedArrayPrototype, TO_STRING_TAG, { + configurable: true, + get: function () { + return isObject(this) ? this[TYPED_ARRAY_TAG] : undefined; + } + }); + for (NAME in TypedArrayConstructorsList) if (globalThis[NAME]) { + createNonEnumerableProperty(globalThis[NAME], TYPED_ARRAY_TAG, NAME); + } + } + + arrayBufferViewCore = { + NATIVE_ARRAY_BUFFER_VIEWS: NATIVE_ARRAY_BUFFER_VIEWS, + TYPED_ARRAY_TAG: TYPED_ARRAY_TAG_REQUIRED && TYPED_ARRAY_TAG, + aTypedArray: aTypedArray, + aTypedArrayConstructor: aTypedArrayConstructor, + exportTypedArrayMethod: exportTypedArrayMethod, + exportTypedArrayStaticMethod: exportTypedArrayStaticMethod, + getTypedArrayConstructor: getTypedArrayConstructor, + isView: isView, + isTypedArray: isTypedArray, + TypedArray: TypedArray, + TypedArrayPrototype: TypedArrayPrototype + }; + return arrayBufferViewCore; +} + +var hasRequiredEs_arrayBuffer_isView; + +function requireEs_arrayBuffer_isView () { + if (hasRequiredEs_arrayBuffer_isView) return es_arrayBuffer_isView; + hasRequiredEs_arrayBuffer_isView = 1; + var $ = require_export(); + var ArrayBufferViewCore = requireArrayBufferViewCore(); + + var NATIVE_ARRAY_BUFFER_VIEWS = ArrayBufferViewCore.NATIVE_ARRAY_BUFFER_VIEWS; + + // `ArrayBuffer.isView` method + // https://tc39.es/ecma262/#sec-arraybuffer.isview + $({ target: 'ArrayBuffer', stat: true, forced: !NATIVE_ARRAY_BUFFER_VIEWS }, { + isView: ArrayBufferViewCore.isView + }); + return es_arrayBuffer_isView; +} + +var es_arrayBuffer_slice = {}; + +var aConstructor; +var hasRequiredAConstructor; + +function requireAConstructor () { + if (hasRequiredAConstructor) return aConstructor; + hasRequiredAConstructor = 1; + var isConstructor = requireIsConstructor(); + var tryToString = requireTryToString(); + + var $TypeError = TypeError; + + // `Assert: IsConstructor(argument) is true` + aConstructor = function (argument) { + if (isConstructor(argument)) return argument; + throw new $TypeError(tryToString(argument) + ' is not a constructor'); + }; + return aConstructor; +} + +var speciesConstructor; +var hasRequiredSpeciesConstructor; + +function requireSpeciesConstructor () { + if (hasRequiredSpeciesConstructor) return speciesConstructor; + hasRequiredSpeciesConstructor = 1; + var anObject = requireAnObject(); + var aConstructor = requireAConstructor(); + var isNullOrUndefined = requireIsNullOrUndefined(); + var wellKnownSymbol = requireWellKnownSymbol(); + + var SPECIES = wellKnownSymbol('species'); + + // `SpeciesConstructor` abstract operation + // https://tc39.es/ecma262/#sec-speciesconstructor + speciesConstructor = function (O, defaultConstructor) { + var C = anObject(O).constructor; + var S; + return C === undefined || isNullOrUndefined(S = anObject(C)[SPECIES]) ? defaultConstructor : aConstructor(S); + }; + return speciesConstructor; +} + +var hasRequiredEs_arrayBuffer_slice; + +function requireEs_arrayBuffer_slice () { + if (hasRequiredEs_arrayBuffer_slice) return es_arrayBuffer_slice; + hasRequiredEs_arrayBuffer_slice = 1; + var $ = require_export(); + var uncurryThis = requireFunctionUncurryThisClause(); + var fails = requireFails(); + var ArrayBufferModule = requireArrayBuffer(); + var anObject = requireAnObject(); + var toAbsoluteIndex = requireToAbsoluteIndex(); + var toLength = requireToLength(); + var speciesConstructor = requireSpeciesConstructor(); + + var ArrayBuffer = ArrayBufferModule.ArrayBuffer; + var DataView = ArrayBufferModule.DataView; + var DataViewPrototype = DataView.prototype; + var nativeArrayBufferSlice = uncurryThis(ArrayBuffer.prototype.slice); + var getUint8 = uncurryThis(DataViewPrototype.getUint8); + var setUint8 = uncurryThis(DataViewPrototype.setUint8); + + var INCORRECT_SLICE = fails(function () { + return !new ArrayBuffer(2).slice(1, undefined).byteLength; + }); + + // `ArrayBuffer.prototype.slice` method + // https://tc39.es/ecma262/#sec-arraybuffer.prototype.slice + $({ target: 'ArrayBuffer', proto: true, unsafe: true, forced: INCORRECT_SLICE }, { + slice: function slice(start, end) { + if (nativeArrayBufferSlice && end === undefined) { + return nativeArrayBufferSlice(anObject(this), start); // FF fix + } + var length = anObject(this).byteLength; + var first = toAbsoluteIndex(start, length); + var fin = toAbsoluteIndex(end === undefined ? length : end, length); + var result = new (speciesConstructor(this, ArrayBuffer))(toLength(fin - first)); + var viewSource = new DataView(this); + var viewTarget = new DataView(result); + var index = 0; + while (first < fin) { + setUint8(viewTarget, index++, getUint8(viewSource, first++)); + } return result; + } + }); + return es_arrayBuffer_slice; +} + +var es_dataView = {}; + +var es_dataView_constructor = {}; + +var hasRequiredEs_dataView_constructor; + +function requireEs_dataView_constructor () { + if (hasRequiredEs_dataView_constructor) return es_dataView_constructor; + hasRequiredEs_dataView_constructor = 1; + var $ = require_export(); + var ArrayBufferModule = requireArrayBuffer(); + var NATIVE_ARRAY_BUFFER = requireArrayBufferBasicDetection(); + + // `DataView` constructor + // https://tc39.es/ecma262/#sec-dataview-constructor + $({ global: true, constructor: true, forced: !NATIVE_ARRAY_BUFFER }, { + DataView: ArrayBufferModule.DataView + }); + return es_dataView_constructor; +} + +var hasRequiredEs_dataView; + +function requireEs_dataView () { + if (hasRequiredEs_dataView) return es_dataView; + hasRequiredEs_dataView = 1; + // TODO: Remove this module from `core-js@4` since it's replaced to module below + requireEs_dataView_constructor(); + return es_dataView; +} + +var es_arrayBuffer_detached = {}; + +var arrayBufferByteLength; +var hasRequiredArrayBufferByteLength; + +function requireArrayBufferByteLength () { + if (hasRequiredArrayBufferByteLength) return arrayBufferByteLength; + hasRequiredArrayBufferByteLength = 1; + var globalThis = requireGlobalThis(); + var uncurryThisAccessor = requireFunctionUncurryThisAccessor(); + var classof = requireClassofRaw(); + + var ArrayBuffer = globalThis.ArrayBuffer; + var TypeError = globalThis.TypeError; + + // Includes + // - Perform ? RequireInternalSlot(O, [[ArrayBufferData]]). + // - If IsSharedArrayBuffer(O) is true, throw a TypeError exception. + arrayBufferByteLength = ArrayBuffer && uncurryThisAccessor(ArrayBuffer.prototype, 'byteLength', 'get') || function (O) { + if (classof(O) !== 'ArrayBuffer') throw new TypeError('ArrayBuffer expected'); + return O.byteLength; + }; + return arrayBufferByteLength; +} + +var arrayBufferIsDetached; +var hasRequiredArrayBufferIsDetached; + +function requireArrayBufferIsDetached () { + if (hasRequiredArrayBufferIsDetached) return arrayBufferIsDetached; + hasRequiredArrayBufferIsDetached = 1; + var globalThis = requireGlobalThis(); + var uncurryThis = requireFunctionUncurryThisClause(); + var arrayBufferByteLength = requireArrayBufferByteLength(); + + var ArrayBuffer = globalThis.ArrayBuffer; + var ArrayBufferPrototype = ArrayBuffer && ArrayBuffer.prototype; + var slice = ArrayBufferPrototype && uncurryThis(ArrayBufferPrototype.slice); + + arrayBufferIsDetached = function (O) { + if (arrayBufferByteLength(O) !== 0) return false; + if (!slice) return false; + try { + slice(O, 0, 0); + return false; + } catch (error) { + return true; + } + }; + return arrayBufferIsDetached; +} + +var hasRequiredEs_arrayBuffer_detached; + +function requireEs_arrayBuffer_detached () { + if (hasRequiredEs_arrayBuffer_detached) return es_arrayBuffer_detached; + hasRequiredEs_arrayBuffer_detached = 1; + var DESCRIPTORS = requireDescriptors(); + var defineBuiltInAccessor = requireDefineBuiltInAccessor(); + var isDetached = requireArrayBufferIsDetached(); + + var ArrayBufferPrototype = ArrayBuffer.prototype; + + if (DESCRIPTORS && !('detached' in ArrayBufferPrototype)) { + defineBuiltInAccessor(ArrayBufferPrototype, 'detached', { + configurable: true, + get: function detached() { + return isDetached(this); + } + }); + } + return es_arrayBuffer_detached; +} + +var es_arrayBuffer_transfer = {}; + +var arrayBufferNotDetached; +var hasRequiredArrayBufferNotDetached; + +function requireArrayBufferNotDetached () { + if (hasRequiredArrayBufferNotDetached) return arrayBufferNotDetached; + hasRequiredArrayBufferNotDetached = 1; + var isDetached = requireArrayBufferIsDetached(); + + var $TypeError = TypeError; + + arrayBufferNotDetached = function (it) { + if (isDetached(it)) throw new $TypeError('ArrayBuffer is detached'); + return it; + }; + return arrayBufferNotDetached; +} + +var getBuiltInNodeModule; +var hasRequiredGetBuiltInNodeModule; + +function requireGetBuiltInNodeModule () { + if (hasRequiredGetBuiltInNodeModule) return getBuiltInNodeModule; + hasRequiredGetBuiltInNodeModule = 1; + var globalThis = requireGlobalThis(); + var IS_NODE = requireEnvironmentIsNode(); + + getBuiltInNodeModule = function (name) { + if (IS_NODE) { + try { + return globalThis.process.getBuiltinModule(name); + } catch (error) { /* empty */ } + try { + // eslint-disable-next-line no-new-func -- safe + return Function('return require("' + name + '")')(); + } catch (error) { /* empty */ } + } + }; + return getBuiltInNodeModule; +} + +var structuredCloneProperTransfer; +var hasRequiredStructuredCloneProperTransfer; + +function requireStructuredCloneProperTransfer () { + if (hasRequiredStructuredCloneProperTransfer) return structuredCloneProperTransfer; + hasRequiredStructuredCloneProperTransfer = 1; + var globalThis = requireGlobalThis(); + var fails = requireFails(); + var V8 = requireEnvironmentV8Version(); + var ENVIRONMENT = requireEnvironment(); + + var structuredClone = globalThis.structuredClone; + + structuredCloneProperTransfer = !!structuredClone && !fails(function () { + // prevent V8 ArrayBufferDetaching protector cell invalidation and performance degradation + // https://github.com/zloirock/core-js/issues/679 + if ((ENVIRONMENT === 'DENO' && V8 > 92) || (ENVIRONMENT === 'NODE' && V8 > 94) || (ENVIRONMENT === 'BROWSER' && V8 > 97)) return false; + var buffer = new ArrayBuffer(8); + var clone = structuredClone(buffer, { transfer: [buffer] }); + return buffer.byteLength !== 0 || clone.byteLength !== 8; + }); + return structuredCloneProperTransfer; +} + +var detachTransferable; +var hasRequiredDetachTransferable; + +function requireDetachTransferable () { + if (hasRequiredDetachTransferable) return detachTransferable; + hasRequiredDetachTransferable = 1; + var globalThis = requireGlobalThis(); + var getBuiltInNodeModule = requireGetBuiltInNodeModule(); + var PROPER_STRUCTURED_CLONE_TRANSFER = requireStructuredCloneProperTransfer(); + + var structuredClone = globalThis.structuredClone; + var $ArrayBuffer = globalThis.ArrayBuffer; + var $MessageChannel = globalThis.MessageChannel; + var detach = false; + var WorkerThreads, channel, buffer, $detach; + + if (PROPER_STRUCTURED_CLONE_TRANSFER) { + detach = function (transferable) { + structuredClone(transferable, { transfer: [transferable] }); + }; + } else if ($ArrayBuffer) try { + if (!$MessageChannel) { + WorkerThreads = getBuiltInNodeModule('worker_threads'); + if (WorkerThreads) $MessageChannel = WorkerThreads.MessageChannel; + } + + if ($MessageChannel) { + channel = new $MessageChannel(); + buffer = new $ArrayBuffer(2); + + $detach = function (transferable) { + channel.port1.postMessage(null, [transferable]); + }; + + if (buffer.byteLength === 2) { + $detach(buffer); + if (buffer.byteLength === 0) detach = $detach; + } + } + } catch (error) { /* empty */ } + + detachTransferable = detach; + return detachTransferable; +} + +var arrayBufferTransfer; +var hasRequiredArrayBufferTransfer; + +function requireArrayBufferTransfer () { + if (hasRequiredArrayBufferTransfer) return arrayBufferTransfer; + hasRequiredArrayBufferTransfer = 1; + var globalThis = requireGlobalThis(); + var uncurryThis = requireFunctionUncurryThis(); + var uncurryThisAccessor = requireFunctionUncurryThisAccessor(); + var toIndex = requireToIndex(); + var notDetached = requireArrayBufferNotDetached(); + var arrayBufferByteLength = requireArrayBufferByteLength(); + var detachTransferable = requireDetachTransferable(); + var PROPER_STRUCTURED_CLONE_TRANSFER = requireStructuredCloneProperTransfer(); + + var structuredClone = globalThis.structuredClone; + var ArrayBuffer = globalThis.ArrayBuffer; + var DataView = globalThis.DataView; + var min = Math.min; + var ArrayBufferPrototype = ArrayBuffer.prototype; + var DataViewPrototype = DataView.prototype; + var slice = uncurryThis(ArrayBufferPrototype.slice); + var isResizable = uncurryThisAccessor(ArrayBufferPrototype, 'resizable', 'get'); + var maxByteLength = uncurryThisAccessor(ArrayBufferPrototype, 'maxByteLength', 'get'); + var getInt8 = uncurryThis(DataViewPrototype.getInt8); + var setInt8 = uncurryThis(DataViewPrototype.setInt8); + + arrayBufferTransfer = (PROPER_STRUCTURED_CLONE_TRANSFER || detachTransferable) && function (arrayBuffer, newLength, preserveResizability) { + var byteLength = arrayBufferByteLength(arrayBuffer); + var newByteLength = newLength === undefined ? byteLength : toIndex(newLength); + var fixedLength = !isResizable || !isResizable(arrayBuffer); + var newBuffer; + notDetached(arrayBuffer); + if (PROPER_STRUCTURED_CLONE_TRANSFER) { + arrayBuffer = structuredClone(arrayBuffer, { transfer: [arrayBuffer] }); + if (byteLength === newByteLength && (preserveResizability || fixedLength)) return arrayBuffer; + } + if (byteLength >= newByteLength && (!preserveResizability || fixedLength)) { + newBuffer = slice(arrayBuffer, 0, newByteLength); + } else { + var options = preserveResizability && !fixedLength && maxByteLength ? { maxByteLength: maxByteLength(arrayBuffer) } : undefined; + newBuffer = new ArrayBuffer(newByteLength, options); + var a = new DataView(arrayBuffer); + var b = new DataView(newBuffer); + var copyLength = min(newByteLength, byteLength); + for (var i = 0; i < copyLength; i++) setInt8(b, i, getInt8(a, i)); + } + if (!PROPER_STRUCTURED_CLONE_TRANSFER) detachTransferable(arrayBuffer); + return newBuffer; + }; + return arrayBufferTransfer; +} + +var hasRequiredEs_arrayBuffer_transfer; + +function requireEs_arrayBuffer_transfer () { + if (hasRequiredEs_arrayBuffer_transfer) return es_arrayBuffer_transfer; + hasRequiredEs_arrayBuffer_transfer = 1; + var $ = require_export(); + var $transfer = requireArrayBufferTransfer(); + + // `ArrayBuffer.prototype.transfer` method + // https://tc39.es/proposal-arraybuffer-transfer/#sec-arraybuffer.prototype.transfer + if ($transfer) $({ target: 'ArrayBuffer', proto: true }, { + transfer: function transfer() { + return $transfer(this, arguments.length ? arguments[0] : undefined, true); + } + }); + return es_arrayBuffer_transfer; +} + +var es_arrayBuffer_transferToFixedLength = {}; + +var hasRequiredEs_arrayBuffer_transferToFixedLength; + +function requireEs_arrayBuffer_transferToFixedLength () { + if (hasRequiredEs_arrayBuffer_transferToFixedLength) return es_arrayBuffer_transferToFixedLength; + hasRequiredEs_arrayBuffer_transferToFixedLength = 1; + var $ = require_export(); + var $transfer = requireArrayBufferTransfer(); + + // `ArrayBuffer.prototype.transferToFixedLength` method + // https://tc39.es/proposal-arraybuffer-transfer/#sec-arraybuffer.prototype.transfertofixedlength + if ($transfer) $({ target: 'ArrayBuffer', proto: true }, { + transferToFixedLength: function transferToFixedLength() { + return $transfer(this, arguments.length ? arguments[0] : undefined, false); + } + }); + return es_arrayBuffer_transferToFixedLength; +} + +var es_date_getYear = {}; + +var hasRequiredEs_date_getYear; + +function requireEs_date_getYear () { + if (hasRequiredEs_date_getYear) return es_date_getYear; + hasRequiredEs_date_getYear = 1; + var $ = require_export(); + var uncurryThis = requireFunctionUncurryThis(); + var fails = requireFails(); + + // IE8- non-standard case + var FORCED = fails(function () { + // eslint-disable-next-line es/no-date-prototype-getyear-setyear -- detection + return new Date(16e11).getYear() !== 120; + }); + + var getFullYear = uncurryThis(Date.prototype.getFullYear); + + // `Date.prototype.getYear` method + // https://tc39.es/ecma262/#sec-date.prototype.getyear + $({ target: 'Date', proto: true, forced: FORCED }, { + getYear: function getYear() { + return getFullYear(this) - 1900; + } + }); + return es_date_getYear; +} + +var es_date_now = {}; + +var hasRequiredEs_date_now; + +function requireEs_date_now () { + if (hasRequiredEs_date_now) return es_date_now; + hasRequiredEs_date_now = 1; + // TODO: Remove from `core-js@4` + var $ = require_export(); + var uncurryThis = requireFunctionUncurryThis(); + + var $Date = Date; + var thisTimeValue = uncurryThis($Date.prototype.getTime); + + // `Date.now` method + // https://tc39.es/ecma262/#sec-date.now + $({ target: 'Date', stat: true }, { + now: function now() { + return thisTimeValue(new $Date()); + } + }); + return es_date_now; +} + +var es_date_setYear = {}; + +var hasRequiredEs_date_setYear; + +function requireEs_date_setYear () { + if (hasRequiredEs_date_setYear) return es_date_setYear; + hasRequiredEs_date_setYear = 1; + var $ = require_export(); + var uncurryThis = requireFunctionUncurryThis(); + var toIntegerOrInfinity = requireToIntegerOrInfinity(); + + var DatePrototype = Date.prototype; + var thisTimeValue = uncurryThis(DatePrototype.getTime); + var setFullYear = uncurryThis(DatePrototype.setFullYear); + + // `Date.prototype.setYear` method + // https://tc39.es/ecma262/#sec-date.prototype.setyear + $({ target: 'Date', proto: true }, { + setYear: function setYear(year) { + // validate + thisTimeValue(this); + var yi = toIntegerOrInfinity(year); + var yyyy = yi >= 0 && yi <= 99 ? yi + 1900 : yi; + return setFullYear(this, yyyy); + } + }); + return es_date_setYear; +} + +var es_date_toGmtString = {}; + +var hasRequiredEs_date_toGmtString; + +function requireEs_date_toGmtString () { + if (hasRequiredEs_date_toGmtString) return es_date_toGmtString; + hasRequiredEs_date_toGmtString = 1; + var $ = require_export(); + + // `Date.prototype.toGMTString` method + // https://tc39.es/ecma262/#sec-date.prototype.togmtstring + $({ target: 'Date', proto: true }, { + toGMTString: Date.prototype.toUTCString + }); + return es_date_toGmtString; +} + +var es_date_toIsoString = {}; + +var stringRepeat; +var hasRequiredStringRepeat; + +function requireStringRepeat () { + if (hasRequiredStringRepeat) return stringRepeat; + hasRequiredStringRepeat = 1; + var toIntegerOrInfinity = requireToIntegerOrInfinity(); + var toString = requireToString(); + var requireObjectCoercible = requireRequireObjectCoercible(); + + var $RangeError = RangeError; + + // `String.prototype.repeat` method implementation + // https://tc39.es/ecma262/#sec-string.prototype.repeat + stringRepeat = function repeat(count) { + var str = toString(requireObjectCoercible(this)); + var result = ''; + var n = toIntegerOrInfinity(count); + if (n < 0 || n === Infinity) throw new $RangeError('Wrong number of repetitions'); + for (;n > 0; (n >>>= 1) && (str += str)) if (n & 1) result += str; + return result; + }; + return stringRepeat; +} + +var stringPad; +var hasRequiredStringPad; + +function requireStringPad () { + if (hasRequiredStringPad) return stringPad; + hasRequiredStringPad = 1; + // https://github.com/tc39/proposal-string-pad-start-end + var uncurryThis = requireFunctionUncurryThis(); + var toLength = requireToLength(); + var toString = requireToString(); + var $repeat = requireStringRepeat(); + var requireObjectCoercible = requireRequireObjectCoercible(); + + var repeat = uncurryThis($repeat); + var stringSlice = uncurryThis(''.slice); + var ceil = Math.ceil; + + // `String.prototype.{ padStart, padEnd }` methods implementation + var createMethod = function (IS_END) { + return function ($this, maxLength, fillString) { + var S = toString(requireObjectCoercible($this)); + var intMaxLength = toLength(maxLength); + var stringLength = S.length; + var fillStr = fillString === undefined ? ' ' : toString(fillString); + var fillLen, stringFiller; + if (intMaxLength <= stringLength || fillStr === '') return S; + fillLen = intMaxLength - stringLength; + stringFiller = repeat(fillStr, ceil(fillLen / fillStr.length)); + if (stringFiller.length > fillLen) stringFiller = stringSlice(stringFiller, 0, fillLen); + return IS_END ? S + stringFiller : stringFiller + S; + }; + }; + + stringPad = { + // `String.prototype.padStart` method + // https://tc39.es/ecma262/#sec-string.prototype.padstart + start: createMethod(false), + // `String.prototype.padEnd` method + // https://tc39.es/ecma262/#sec-string.prototype.padend + end: createMethod(true) + }; + return stringPad; +} + +var dateToIsoString; +var hasRequiredDateToIsoString; + +function requireDateToIsoString () { + if (hasRequiredDateToIsoString) return dateToIsoString; + hasRequiredDateToIsoString = 1; + var uncurryThis = requireFunctionUncurryThis(); + var fails = requireFails(); + var padStart = requireStringPad().start; + + var $RangeError = RangeError; + var $isFinite = isFinite; + var abs = Math.abs; + var DatePrototype = Date.prototype; + var nativeDateToISOString = DatePrototype.toISOString; + var thisTimeValue = uncurryThis(DatePrototype.getTime); + var getUTCDate = uncurryThis(DatePrototype.getUTCDate); + var getUTCFullYear = uncurryThis(DatePrototype.getUTCFullYear); + var getUTCHours = uncurryThis(DatePrototype.getUTCHours); + var getUTCMilliseconds = uncurryThis(DatePrototype.getUTCMilliseconds); + var getUTCMinutes = uncurryThis(DatePrototype.getUTCMinutes); + var getUTCMonth = uncurryThis(DatePrototype.getUTCMonth); + var getUTCSeconds = uncurryThis(DatePrototype.getUTCSeconds); + + // `Date.prototype.toISOString` method implementation + // https://tc39.es/ecma262/#sec-date.prototype.toisostring + // PhantomJS / old WebKit fails here: + dateToIsoString = (fails(function () { + return nativeDateToISOString.call(new Date(-5e13 - 1)) !== '0385-07-25T07:06:39.999Z'; + }) || !fails(function () { + nativeDateToISOString.call(new Date(NaN)); + })) ? function toISOString() { + if (!$isFinite(thisTimeValue(this))) throw new $RangeError('Invalid time value'); + var date = this; + var year = getUTCFullYear(date); + var milliseconds = getUTCMilliseconds(date); + var sign = year < 0 ? '-' : year > 9999 ? '+' : ''; + return sign + padStart(abs(year), sign ? 6 : 4, 0) + + '-' + padStart(getUTCMonth(date) + 1, 2, 0) + + '-' + padStart(getUTCDate(date), 2, 0) + + 'T' + padStart(getUTCHours(date), 2, 0) + + ':' + padStart(getUTCMinutes(date), 2, 0) + + ':' + padStart(getUTCSeconds(date), 2, 0) + + '.' + padStart(milliseconds, 3, 0) + + 'Z'; + } : nativeDateToISOString; + return dateToIsoString; +} + +var hasRequiredEs_date_toIsoString; + +function requireEs_date_toIsoString () { + if (hasRequiredEs_date_toIsoString) return es_date_toIsoString; + hasRequiredEs_date_toIsoString = 1; + var $ = require_export(); + var toISOString = requireDateToIsoString(); + + // `Date.prototype.toISOString` method + // https://tc39.es/ecma262/#sec-date.prototype.toisostring + // PhantomJS / old WebKit has a broken implementations + $({ target: 'Date', proto: true, forced: Date.prototype.toISOString !== toISOString }, { + toISOString: toISOString + }); + return es_date_toIsoString; +} + +var es_date_toJson = {}; + +var hasRequiredEs_date_toJson; + +function requireEs_date_toJson () { + if (hasRequiredEs_date_toJson) return es_date_toJson; + hasRequiredEs_date_toJson = 1; + var $ = require_export(); + var fails = requireFails(); + var toObject = requireToObject(); + var toPrimitive = requireToPrimitive(); + + var FORCED = fails(function () { + return new Date(NaN).toJSON() !== null + || Date.prototype.toJSON.call({ toISOString: function () { return 1; } }) !== 1; + }); + + // `Date.prototype.toJSON` method + // https://tc39.es/ecma262/#sec-date.prototype.tojson + $({ target: 'Date', proto: true, arity: 1, forced: FORCED }, { + // eslint-disable-next-line no-unused-vars -- required for `.length` + toJSON: function toJSON(key) { + var O = toObject(this); + var pv = toPrimitive(O, 'number'); + return typeof pv == 'number' && !isFinite(pv) ? null : O.toISOString(); + } + }); + return es_date_toJson; +} + +var es_date_toPrimitive = {}; + +var dateToPrimitive; +var hasRequiredDateToPrimitive; + +function requireDateToPrimitive () { + if (hasRequiredDateToPrimitive) return dateToPrimitive; + hasRequiredDateToPrimitive = 1; + var anObject = requireAnObject(); + var ordinaryToPrimitive = requireOrdinaryToPrimitive(); + + var $TypeError = TypeError; + + // `Date.prototype[@@toPrimitive](hint)` method implementation + // https://tc39.es/ecma262/#sec-date.prototype-@@toprimitive + dateToPrimitive = function (hint) { + anObject(this); + if (hint === 'string' || hint === 'default') hint = 'string'; + else if (hint !== 'number') throw new $TypeError('Incorrect hint'); + return ordinaryToPrimitive(this, hint); + }; + return dateToPrimitive; +} + +var hasRequiredEs_date_toPrimitive; + +function requireEs_date_toPrimitive () { + if (hasRequiredEs_date_toPrimitive) return es_date_toPrimitive; + hasRequiredEs_date_toPrimitive = 1; + var hasOwn = requireHasOwnProperty(); + var defineBuiltIn = requireDefineBuiltIn(); + var dateToPrimitive = requireDateToPrimitive(); + var wellKnownSymbol = requireWellKnownSymbol(); + + var TO_PRIMITIVE = wellKnownSymbol('toPrimitive'); + var DatePrototype = Date.prototype; + + // `Date.prototype[@@toPrimitive]` method + // https://tc39.es/ecma262/#sec-date.prototype-@@toprimitive + if (!hasOwn(DatePrototype, TO_PRIMITIVE)) { + defineBuiltIn(DatePrototype, TO_PRIMITIVE, dateToPrimitive); + } + return es_date_toPrimitive; +} + +var es_date_toString = {}; + +var hasRequiredEs_date_toString; + +function requireEs_date_toString () { + if (hasRequiredEs_date_toString) return es_date_toString; + hasRequiredEs_date_toString = 1; + // TODO: Remove from `core-js@4` + var uncurryThis = requireFunctionUncurryThis(); + var defineBuiltIn = requireDefineBuiltIn(); + + var DatePrototype = Date.prototype; + var INVALID_DATE = 'Invalid Date'; + var TO_STRING = 'toString'; + var nativeDateToString = uncurryThis(DatePrototype[TO_STRING]); + var thisTimeValue = uncurryThis(DatePrototype.getTime); + + // `Date.prototype.toString` method + // https://tc39.es/ecma262/#sec-date.prototype.tostring + if (String(new Date(NaN)) !== INVALID_DATE) { + defineBuiltIn(DatePrototype, TO_STRING, function toString() { + var value = thisTimeValue(this); + // eslint-disable-next-line no-self-compare -- NaN check + return value === value ? nativeDateToString(this) : INVALID_DATE; + }); + } + return es_date_toString; +} + +var es_escape = {}; + +var hasRequiredEs_escape; + +function requireEs_escape () { + if (hasRequiredEs_escape) return es_escape; + hasRequiredEs_escape = 1; + var $ = require_export(); + var uncurryThis = requireFunctionUncurryThis(); + var toString = requireToString(); + + var charAt = uncurryThis(''.charAt); + var charCodeAt = uncurryThis(''.charCodeAt); + var exec = uncurryThis(/./.exec); + var numberToString = uncurryThis(1.0.toString); + var toUpperCase = uncurryThis(''.toUpperCase); + + var raw = /[\w*+\-./@]/; + + var hex = function (code, length) { + var result = numberToString(code, 16); + while (result.length < length) result = '0' + result; + return result; + }; + + // `escape` method + // https://tc39.es/ecma262/#sec-escape-string + $({ global: true }, { + escape: function escape(string) { + var str = toString(string); + var result = ''; + var length = str.length; + var index = 0; + var chr, code; + while (index < length) { + chr = charAt(str, index++); + if (exec(raw, chr)) { + result += chr; + } else { + code = charCodeAt(chr, 0); + if (code < 256) { + result += '%' + hex(code, 2); + } else { + result += '%u' + toUpperCase(hex(code, 4)); + } + } + } return result; + } + }); + return es_escape; +} + +var es_function_bind = {}; + +var functionBind; +var hasRequiredFunctionBind; + +function requireFunctionBind () { + if (hasRequiredFunctionBind) return functionBind; + hasRequiredFunctionBind = 1; + var uncurryThis = requireFunctionUncurryThis(); + var aCallable = requireACallable(); + var isObject = requireIsObject(); + var hasOwn = requireHasOwnProperty(); + var arraySlice = requireArraySlice(); + var NATIVE_BIND = requireFunctionBindNative(); + + var $Function = Function; + var concat = uncurryThis([].concat); + var join = uncurryThis([].join); + var factories = {}; + + var construct = function (C, argsLength, args) { + if (!hasOwn(factories, argsLength)) { + var list = []; + var i = 0; + for (; i < argsLength; i++) list[i] = 'a[' + i + ']'; + factories[argsLength] = $Function('C,a', 'return new C(' + join(list, ',') + ')'); + } return factories[argsLength](C, args); + }; + + // `Function.prototype.bind` method implementation + // https://tc39.es/ecma262/#sec-function.prototype.bind + // eslint-disable-next-line es/no-function-prototype-bind -- detection + functionBind = NATIVE_BIND ? $Function.bind : function bind(that /* , ...args */) { + var F = aCallable(this); + var Prototype = F.prototype; + var partArgs = arraySlice(arguments, 1); + var boundFunction = function bound(/* args... */) { + var args = concat(partArgs, arraySlice(arguments)); + return this instanceof boundFunction ? construct(F, args.length, args) : F.apply(that, args); + }; + if (isObject(Prototype)) boundFunction.prototype = Prototype; + return boundFunction; + }; + return functionBind; +} + +var hasRequiredEs_function_bind; + +function requireEs_function_bind () { + if (hasRequiredEs_function_bind) return es_function_bind; + hasRequiredEs_function_bind = 1; + // TODO: Remove from `core-js@4` + var $ = require_export(); + var bind = requireFunctionBind(); + + // `Function.prototype.bind` method + // https://tc39.es/ecma262/#sec-function.prototype.bind + // eslint-disable-next-line es/no-function-prototype-bind -- detection + $({ target: 'Function', proto: true, forced: Function.bind !== bind }, { + bind: bind + }); + return es_function_bind; +} + +var es_function_hasInstance = {}; + +var hasRequiredEs_function_hasInstance; + +function requireEs_function_hasInstance () { + if (hasRequiredEs_function_hasInstance) return es_function_hasInstance; + hasRequiredEs_function_hasInstance = 1; + var isCallable = requireIsCallable(); + var isObject = requireIsObject(); + var definePropertyModule = requireObjectDefineProperty(); + var isPrototypeOf = requireObjectIsPrototypeOf(); + var wellKnownSymbol = requireWellKnownSymbol(); + var makeBuiltIn = requireMakeBuiltIn(); + + var HAS_INSTANCE = wellKnownSymbol('hasInstance'); + var FunctionPrototype = Function.prototype; + + // `Function.prototype[@@hasInstance]` method + // https://tc39.es/ecma262/#sec-function.prototype-@@hasinstance + if (!(HAS_INSTANCE in FunctionPrototype)) { + definePropertyModule.f(FunctionPrototype, HAS_INSTANCE, { value: makeBuiltIn(function (O) { + if (!isCallable(this) || !isObject(O)) return false; + var P = this.prototype; + return isObject(P) ? isPrototypeOf(P, O) : O instanceof this; + }, HAS_INSTANCE) }); + } + return es_function_hasInstance; +} + +var es_function_name = {}; + +var hasRequiredEs_function_name; + +function requireEs_function_name () { + if (hasRequiredEs_function_name) return es_function_name; + hasRequiredEs_function_name = 1; + var DESCRIPTORS = requireDescriptors(); + var FUNCTION_NAME_EXISTS = requireFunctionName().EXISTS; + var uncurryThis = requireFunctionUncurryThis(); + var defineBuiltInAccessor = requireDefineBuiltInAccessor(); + + var FunctionPrototype = Function.prototype; + var functionToString = uncurryThis(FunctionPrototype.toString); + var nameRE = /function\b(?:\s|\/\*[\S\s]*?\*\/|\/\/[^\n\r]*[\n\r]+)*([^\s(/]*)/; + var regExpExec = uncurryThis(nameRE.exec); + var NAME = 'name'; + + // Function instances `.name` property + // https://tc39.es/ecma262/#sec-function-instances-name + if (DESCRIPTORS && !FUNCTION_NAME_EXISTS) { + defineBuiltInAccessor(FunctionPrototype, NAME, { + configurable: true, + get: function () { + try { + return regExpExec(nameRE, functionToString(this))[1]; + } catch (error) { + return ''; + } + } + }); + } + return es_function_name; +} + +var es_globalThis = {}; + +var hasRequiredEs_globalThis; + +function requireEs_globalThis () { + if (hasRequiredEs_globalThis) return es_globalThis; + hasRequiredEs_globalThis = 1; + var $ = require_export(); + var globalThis = requireGlobalThis(); + + // `globalThis` object + // https://tc39.es/ecma262/#sec-globalthis + $({ global: true, forced: globalThis.globalThis !== globalThis }, { + globalThis: globalThis + }); + return es_globalThis; +} + +var es_json_toStringTag = {}; + +var hasRequiredEs_json_toStringTag; + +function requireEs_json_toStringTag () { + if (hasRequiredEs_json_toStringTag) return es_json_toStringTag; + hasRequiredEs_json_toStringTag = 1; + var globalThis = requireGlobalThis(); + var setToStringTag = requireSetToStringTag(); + + // JSON[@@toStringTag] property + // https://tc39.es/ecma262/#sec-json-@@tostringtag + setToStringTag(globalThis.JSON, 'JSON', true); + return es_json_toStringTag; +} + +var es_map = {}; + +var es_map_constructor = {}; + +var internalMetadata = {exports: {}}; + +var arrayBufferNonExtensible; +var hasRequiredArrayBufferNonExtensible; + +function requireArrayBufferNonExtensible () { + if (hasRequiredArrayBufferNonExtensible) return arrayBufferNonExtensible; + hasRequiredArrayBufferNonExtensible = 1; + // FF26- bug: ArrayBuffers are non-extensible, but Object.isExtensible does not report it + var fails = requireFails(); + + arrayBufferNonExtensible = fails(function () { + if (typeof ArrayBuffer == 'function') { + var buffer = new ArrayBuffer(8); + // eslint-disable-next-line es/no-object-isextensible, es/no-object-defineproperty -- safe + if (Object.isExtensible(buffer)) Object.defineProperty(buffer, 'a', { value: 8 }); + } + }); + return arrayBufferNonExtensible; +} + +var objectIsExtensible; +var hasRequiredObjectIsExtensible; + +function requireObjectIsExtensible () { + if (hasRequiredObjectIsExtensible) return objectIsExtensible; + hasRequiredObjectIsExtensible = 1; + var fails = requireFails(); + var isObject = requireIsObject(); + var classof = requireClassofRaw(); + var ARRAY_BUFFER_NON_EXTENSIBLE = requireArrayBufferNonExtensible(); + + // eslint-disable-next-line es/no-object-isextensible -- safe + var $isExtensible = Object.isExtensible; + var FAILS_ON_PRIMITIVES = fails(function () { }); + + // `Object.isExtensible` method + // https://tc39.es/ecma262/#sec-object.isextensible + objectIsExtensible = (FAILS_ON_PRIMITIVES || ARRAY_BUFFER_NON_EXTENSIBLE) ? function isExtensible(it) { + if (!isObject(it)) return false; + if (ARRAY_BUFFER_NON_EXTENSIBLE && classof(it) === 'ArrayBuffer') return false; + return $isExtensible ? $isExtensible(it) : true; + } : $isExtensible; + return objectIsExtensible; +} + +var freezing; +var hasRequiredFreezing; + +function requireFreezing () { + if (hasRequiredFreezing) return freezing; + hasRequiredFreezing = 1; + var fails = requireFails(); + + freezing = !fails(function () { + // eslint-disable-next-line es/no-object-isextensible, es/no-object-preventextensions -- required for testing + return Object.isExtensible(Object.preventExtensions({})); + }); + return freezing; +} + +var hasRequiredInternalMetadata; + +function requireInternalMetadata () { + if (hasRequiredInternalMetadata) return internalMetadata.exports; + hasRequiredInternalMetadata = 1; + var $ = require_export(); + var uncurryThis = requireFunctionUncurryThis(); + var hiddenKeys = requireHiddenKeys(); + var isObject = requireIsObject(); + var hasOwn = requireHasOwnProperty(); + var defineProperty = requireObjectDefineProperty().f; + var getOwnPropertyNamesModule = requireObjectGetOwnPropertyNames(); + var getOwnPropertyNamesExternalModule = requireObjectGetOwnPropertyNamesExternal(); + var isExtensible = requireObjectIsExtensible(); + var uid = requireUid(); + var FREEZING = requireFreezing(); + + var REQUIRED = false; + var METADATA = uid('meta'); + var id = 0; + + var setMetadata = function (it) { + defineProperty(it, METADATA, { value: { + objectID: 'O' + id++, // object ID + weakData: {} // weak collections IDs + } }); + }; + + var fastKey = function (it, create) { + // return a primitive with prefix + if (!isObject(it)) return typeof it == 'symbol' ? it : (typeof it == 'string' ? 'S' : 'P') + it; + if (!hasOwn(it, METADATA)) { + // can't set metadata to uncaught frozen object + if (!isExtensible(it)) return 'F'; + // not necessary to add metadata + if (!create) return 'E'; + // add missing metadata + setMetadata(it); + // return object ID + } return it[METADATA].objectID; + }; + + var getWeakData = function (it, create) { + if (!hasOwn(it, METADATA)) { + // can't set metadata to uncaught frozen object + if (!isExtensible(it)) return true; + // not necessary to add metadata + if (!create) return false; + // add missing metadata + setMetadata(it); + // return the store of weak collections IDs + } return it[METADATA].weakData; + }; + + // add metadata on freeze-family methods calling + var onFreeze = function (it) { + if (FREEZING && REQUIRED && isExtensible(it) && !hasOwn(it, METADATA)) setMetadata(it); + return it; + }; + + var enable = function () { + meta.enable = function () { /* empty */ }; + REQUIRED = true; + var getOwnPropertyNames = getOwnPropertyNamesModule.f; + var splice = uncurryThis([].splice); + var test = {}; + test[METADATA] = 1; + + // prevent exposing of metadata key + if (getOwnPropertyNames(test).length) { + getOwnPropertyNamesModule.f = function (it) { + var result = getOwnPropertyNames(it); + for (var i = 0, length = result.length; i < length; i++) { + if (result[i] === METADATA) { + splice(result, i, 1); + break; + } + } return result; + }; + + $({ target: 'Object', stat: true, forced: true }, { + getOwnPropertyNames: getOwnPropertyNamesExternalModule.f + }); + } + }; + + var meta = internalMetadata.exports = { + enable: enable, + fastKey: fastKey, + getWeakData: getWeakData, + onFreeze: onFreeze + }; + + hiddenKeys[METADATA] = true; + return internalMetadata.exports; +} + +var collection; +var hasRequiredCollection; + +function requireCollection () { + if (hasRequiredCollection) return collection; + hasRequiredCollection = 1; + var $ = require_export(); + var globalThis = requireGlobalThis(); + var uncurryThis = requireFunctionUncurryThis(); + var isForced = requireIsForced(); + var defineBuiltIn = requireDefineBuiltIn(); + var InternalMetadataModule = requireInternalMetadata(); + var iterate = requireIterate(); + var anInstance = requireAnInstance(); + var isCallable = requireIsCallable(); + var isNullOrUndefined = requireIsNullOrUndefined(); + var isObject = requireIsObject(); + var fails = requireFails(); + var checkCorrectnessOfIteration = requireCheckCorrectnessOfIteration(); + var setToStringTag = requireSetToStringTag(); + var inheritIfRequired = requireInheritIfRequired(); + + collection = function (CONSTRUCTOR_NAME, wrapper, common) { + var IS_MAP = CONSTRUCTOR_NAME.indexOf('Map') !== -1; + var IS_WEAK = CONSTRUCTOR_NAME.indexOf('Weak') !== -1; + var ADDER = IS_MAP ? 'set' : 'add'; + var NativeConstructor = globalThis[CONSTRUCTOR_NAME]; + var NativePrototype = NativeConstructor && NativeConstructor.prototype; + var Constructor = NativeConstructor; + var exported = {}; + + var fixMethod = function (KEY) { + var uncurriedNativeMethod = uncurryThis(NativePrototype[KEY]); + defineBuiltIn(NativePrototype, KEY, + KEY === 'add' ? function add(value) { + uncurriedNativeMethod(this, value === 0 ? 0 : value); + return this; + } : KEY === 'delete' ? function (key) { + return IS_WEAK && !isObject(key) ? false : uncurriedNativeMethod(this, key === 0 ? 0 : key); + } : KEY === 'get' ? function get(key) { + return IS_WEAK && !isObject(key) ? undefined : uncurriedNativeMethod(this, key === 0 ? 0 : key); + } : KEY === 'has' ? function has(key) { + return IS_WEAK && !isObject(key) ? false : uncurriedNativeMethod(this, key === 0 ? 0 : key); + } : function set(key, value) { + uncurriedNativeMethod(this, key === 0 ? 0 : key, value); + return this; + } + ); + }; + + var REPLACE = isForced( + CONSTRUCTOR_NAME, + !isCallable(NativeConstructor) || !(IS_WEAK || NativePrototype.forEach && !fails(function () { + new NativeConstructor().entries().next(); + })) + ); + + if (REPLACE) { + // create collection constructor + Constructor = common.getConstructor(wrapper, CONSTRUCTOR_NAME, IS_MAP, ADDER); + InternalMetadataModule.enable(); + } else if (isForced(CONSTRUCTOR_NAME, true)) { + var instance = new Constructor(); + // early implementations not supports chaining + var HASNT_CHAINING = instance[ADDER](IS_WEAK ? {} : -0, 1) !== instance; + // V8 ~ Chromium 40- weak-collections throws on primitives, but should return false + var THROWS_ON_PRIMITIVES = fails(function () { instance.has(1); }); + // most early implementations doesn't supports iterables, most modern - not close it correctly + // eslint-disable-next-line no-new -- required for testing + var ACCEPT_ITERABLES = checkCorrectnessOfIteration(function (iterable) { new NativeConstructor(iterable); }); + // for early implementations -0 and +0 not the same + var BUGGY_ZERO = !IS_WEAK && fails(function () { + // V8 ~ Chromium 42- fails only with 5+ elements + var $instance = new NativeConstructor(); + var index = 5; + while (index--) $instance[ADDER](index, index); + return !$instance.has(-0); + }); + + if (!ACCEPT_ITERABLES) { + Constructor = wrapper(function (dummy, iterable) { + anInstance(dummy, NativePrototype); + var that = inheritIfRequired(new NativeConstructor(), dummy, Constructor); + if (!isNullOrUndefined(iterable)) iterate(iterable, that[ADDER], { that: that, AS_ENTRIES: IS_MAP }); + return that; + }); + Constructor.prototype = NativePrototype; + NativePrototype.constructor = Constructor; + } + + if (THROWS_ON_PRIMITIVES || BUGGY_ZERO) { + fixMethod('delete'); + fixMethod('has'); + IS_MAP && fixMethod('get'); + } + + if (BUGGY_ZERO || HASNT_CHAINING) fixMethod(ADDER); + + // weak collections should not contains .clear method + if (IS_WEAK && NativePrototype.clear) delete NativePrototype.clear; + } + + exported[CONSTRUCTOR_NAME] = Constructor; + $({ global: true, constructor: true, forced: Constructor !== NativeConstructor }, exported); + + setToStringTag(Constructor, CONSTRUCTOR_NAME); + + if (!IS_WEAK) common.setStrong(Constructor, CONSTRUCTOR_NAME, IS_MAP); + + return Constructor; + }; + return collection; +} + +var collectionStrong; +var hasRequiredCollectionStrong; + +function requireCollectionStrong () { + if (hasRequiredCollectionStrong) return collectionStrong; + hasRequiredCollectionStrong = 1; + var create = requireObjectCreate(); + var defineBuiltInAccessor = requireDefineBuiltInAccessor(); + var defineBuiltIns = requireDefineBuiltIns(); + var bind = requireFunctionBindContext(); + var anInstance = requireAnInstance(); + var isNullOrUndefined = requireIsNullOrUndefined(); + var iterate = requireIterate(); + var defineIterator = requireIteratorDefine(); + var createIterResultObject = requireCreateIterResultObject(); + var setSpecies = requireSetSpecies(); + var DESCRIPTORS = requireDescriptors(); + var fastKey = requireInternalMetadata().fastKey; + var InternalStateModule = requireInternalState(); + + var setInternalState = InternalStateModule.set; + var internalStateGetterFor = InternalStateModule.getterFor; + + collectionStrong = { + getConstructor: function (wrapper, CONSTRUCTOR_NAME, IS_MAP, ADDER) { + var Constructor = wrapper(function (that, iterable) { + anInstance(that, Prototype); + setInternalState(that, { + type: CONSTRUCTOR_NAME, + index: create(null), + first: null, + last: null, + size: 0 + }); + if (!DESCRIPTORS) that.size = 0; + if (!isNullOrUndefined(iterable)) iterate(iterable, that[ADDER], { that: that, AS_ENTRIES: IS_MAP }); + }); + + var Prototype = Constructor.prototype; + + var getInternalState = internalStateGetterFor(CONSTRUCTOR_NAME); + + var define = function (that, key, value) { + var state = getInternalState(that); + var entry = getEntry(that, key); + var previous, index; + // change existing entry + if (entry) { + entry.value = value; + // create new entry + } else { + state.last = entry = { + index: index = fastKey(key, true), + key: key, + value: value, + previous: previous = state.last, + next: null, + removed: false + }; + if (!state.first) state.first = entry; + if (previous) previous.next = entry; + if (DESCRIPTORS) state.size++; + else that.size++; + // add to index + if (index !== 'F') state.index[index] = entry; + } return that; + }; + + var getEntry = function (that, key) { + var state = getInternalState(that); + // fast case + var index = fastKey(key); + var entry; + if (index !== 'F') return state.index[index]; + // frozen object case + for (entry = state.first; entry; entry = entry.next) { + if (entry.key === key) return entry; + } + }; + + defineBuiltIns(Prototype, { + // `{ Map, Set }.prototype.clear()` methods + // https://tc39.es/ecma262/#sec-map.prototype.clear + // https://tc39.es/ecma262/#sec-set.prototype.clear + clear: function clear() { + var that = this; + var state = getInternalState(that); + var entry = state.first; + while (entry) { + entry.removed = true; + if (entry.previous) entry.previous = entry.previous.next = null; + entry = entry.next; + } + state.first = state.last = null; + state.index = create(null); + if (DESCRIPTORS) state.size = 0; + else that.size = 0; + }, + // `{ Map, Set }.prototype.delete(key)` methods + // https://tc39.es/ecma262/#sec-map.prototype.delete + // https://tc39.es/ecma262/#sec-set.prototype.delete + 'delete': function (key) { + var that = this; + var state = getInternalState(that); + var entry = getEntry(that, key); + if (entry) { + var next = entry.next; + var prev = entry.previous; + delete state.index[entry.index]; + entry.removed = true; + if (prev) prev.next = next; + if (next) next.previous = prev; + if (state.first === entry) state.first = next; + if (state.last === entry) state.last = prev; + if (DESCRIPTORS) state.size--; + else that.size--; + } return !!entry; + }, + // `{ Map, Set }.prototype.forEach(callbackfn, thisArg = undefined)` methods + // https://tc39.es/ecma262/#sec-map.prototype.foreach + // https://tc39.es/ecma262/#sec-set.prototype.foreach + forEach: function forEach(callbackfn /* , that = undefined */) { + var state = getInternalState(this); + var boundFunction = bind(callbackfn, arguments.length > 1 ? arguments[1] : undefined); + var entry; + while (entry = entry ? entry.next : state.first) { + boundFunction(entry.value, entry.key, this); + // revert to the last existing entry + while (entry && entry.removed) entry = entry.previous; + } + }, + // `{ Map, Set}.prototype.has(key)` methods + // https://tc39.es/ecma262/#sec-map.prototype.has + // https://tc39.es/ecma262/#sec-set.prototype.has + has: function has(key) { + return !!getEntry(this, key); + } + }); + + defineBuiltIns(Prototype, IS_MAP ? { + // `Map.prototype.get(key)` method + // https://tc39.es/ecma262/#sec-map.prototype.get + get: function get(key) { + var entry = getEntry(this, key); + return entry && entry.value; + }, + // `Map.prototype.set(key, value)` method + // https://tc39.es/ecma262/#sec-map.prototype.set + set: function set(key, value) { + return define(this, key === 0 ? 0 : key, value); + } + } : { + // `Set.prototype.add(value)` method + // https://tc39.es/ecma262/#sec-set.prototype.add + add: function add(value) { + return define(this, value = value === 0 ? 0 : value, value); + } + }); + if (DESCRIPTORS) defineBuiltInAccessor(Prototype, 'size', { + configurable: true, + get: function () { + return getInternalState(this).size; + } + }); + return Constructor; + }, + setStrong: function (Constructor, CONSTRUCTOR_NAME, IS_MAP) { + var ITERATOR_NAME = CONSTRUCTOR_NAME + ' Iterator'; + var getInternalCollectionState = internalStateGetterFor(CONSTRUCTOR_NAME); + var getInternalIteratorState = internalStateGetterFor(ITERATOR_NAME); + // `{ Map, Set }.prototype.{ keys, values, entries, @@iterator }()` methods + // https://tc39.es/ecma262/#sec-map.prototype.entries + // https://tc39.es/ecma262/#sec-map.prototype.keys + // https://tc39.es/ecma262/#sec-map.prototype.values + // https://tc39.es/ecma262/#sec-map.prototype-@@iterator + // https://tc39.es/ecma262/#sec-set.prototype.entries + // https://tc39.es/ecma262/#sec-set.prototype.keys + // https://tc39.es/ecma262/#sec-set.prototype.values + // https://tc39.es/ecma262/#sec-set.prototype-@@iterator + defineIterator(Constructor, CONSTRUCTOR_NAME, function (iterated, kind) { + setInternalState(this, { + type: ITERATOR_NAME, + target: iterated, + state: getInternalCollectionState(iterated), + kind: kind, + last: null + }); + }, function () { + var state = getInternalIteratorState(this); + var kind = state.kind; + var entry = state.last; + // revert to the last existing entry + while (entry && entry.removed) entry = entry.previous; + // get next entry + if (!state.target || !(state.last = entry = entry ? entry.next : state.state.first)) { + // or finish the iteration + state.target = null; + return createIterResultObject(undefined, true); + } + // return step by kind + if (kind === 'keys') return createIterResultObject(entry.key, false); + if (kind === 'values') return createIterResultObject(entry.value, false); + return createIterResultObject([entry.key, entry.value], false); + }, IS_MAP ? 'entries' : 'values', !IS_MAP, true); + + // `{ Map, Set }.prototype[@@species]` accessors + // https://tc39.es/ecma262/#sec-get-map-@@species + // https://tc39.es/ecma262/#sec-get-set-@@species + setSpecies(CONSTRUCTOR_NAME); + } + }; + return collectionStrong; +} + +var hasRequiredEs_map_constructor; + +function requireEs_map_constructor () { + if (hasRequiredEs_map_constructor) return es_map_constructor; + hasRequiredEs_map_constructor = 1; + var collection = requireCollection(); + var collectionStrong = requireCollectionStrong(); + + // `Map` constructor + // https://tc39.es/ecma262/#sec-map-objects + collection('Map', function (init) { + return function Map() { return init(this, arguments.length ? arguments[0] : undefined); }; + }, collectionStrong); + return es_map_constructor; +} + +var hasRequiredEs_map; + +function requireEs_map () { + if (hasRequiredEs_map) return es_map; + hasRequiredEs_map = 1; + // TODO: Remove this module from `core-js@4` since it's replaced to module below + requireEs_map_constructor(); + return es_map; +} + +var es_map_groupBy = {}; + +var mapHelpers; +var hasRequiredMapHelpers; + +function requireMapHelpers () { + if (hasRequiredMapHelpers) return mapHelpers; + hasRequiredMapHelpers = 1; + var uncurryThis = requireFunctionUncurryThis(); + + // eslint-disable-next-line es/no-map -- safe + var MapPrototype = Map.prototype; + + mapHelpers = { + // eslint-disable-next-line es/no-map -- safe + Map: Map, + set: uncurryThis(MapPrototype.set), + get: uncurryThis(MapPrototype.get), + has: uncurryThis(MapPrototype.has), + remove: uncurryThis(MapPrototype['delete']), + proto: MapPrototype + }; + return mapHelpers; +} + +var hasRequiredEs_map_groupBy; + +function requireEs_map_groupBy () { + if (hasRequiredEs_map_groupBy) return es_map_groupBy; + hasRequiredEs_map_groupBy = 1; + var $ = require_export(); + var uncurryThis = requireFunctionUncurryThis(); + var aCallable = requireACallable(); + var requireObjectCoercible = requireRequireObjectCoercible(); + var iterate = requireIterate(); + var MapHelpers = requireMapHelpers(); + var IS_PURE = requireIsPure(); + var fails = requireFails(); + + var Map = MapHelpers.Map; + var has = MapHelpers.has; + var get = MapHelpers.get; + var set = MapHelpers.set; + var push = uncurryThis([].push); + + var DOES_NOT_WORK_WITH_PRIMITIVES = IS_PURE || fails(function () { + return Map.groupBy('ab', function (it) { + return it; + }).get('a').length !== 1; + }); + + // `Map.groupBy` method + // https://github.com/tc39/proposal-array-grouping + $({ target: 'Map', stat: true, forced: IS_PURE || DOES_NOT_WORK_WITH_PRIMITIVES }, { + groupBy: function groupBy(items, callbackfn) { + requireObjectCoercible(items); + aCallable(callbackfn); + var map = new Map(); + var k = 0; + iterate(items, function (value) { + var key = callbackfn(value, k++); + if (!has(map, key)) set(map, key, [value]); + else push(get(map, key), value); + }); + return map; + } + }); + return es_map_groupBy; +} + +var es_math_acosh = {}; + +var mathLog1p; +var hasRequiredMathLog1p; + +function requireMathLog1p () { + if (hasRequiredMathLog1p) return mathLog1p; + hasRequiredMathLog1p = 1; + var log = Math.log; + + // `Math.log1p` method implementation + // https://tc39.es/ecma262/#sec-math.log1p + // eslint-disable-next-line es/no-math-log1p -- safe + mathLog1p = Math.log1p || function log1p(x) { + var n = +x; + return n > -1e-8 && n < 1e-8 ? n - n * n / 2 : log(1 + n); + }; + return mathLog1p; +} + +var hasRequiredEs_math_acosh; + +function requireEs_math_acosh () { + if (hasRequiredEs_math_acosh) return es_math_acosh; + hasRequiredEs_math_acosh = 1; + var $ = require_export(); + var log1p = requireMathLog1p(); + + // eslint-disable-next-line es/no-math-acosh -- required for testing + var $acosh = Math.acosh; + var log = Math.log; + var sqrt = Math.sqrt; + var LN2 = Math.LN2; + + var FORCED = !$acosh + // V8 bug: https://code.google.com/p/v8/issues/detail?id=3509 + || Math.floor($acosh(Number.MAX_VALUE)) !== 710 + // Tor Browser bug: Math.acosh(Infinity) -> NaN + || $acosh(Infinity) !== Infinity; + + // `Math.acosh` method + // https://tc39.es/ecma262/#sec-math.acosh + $({ target: 'Math', stat: true, forced: FORCED }, { + acosh: function acosh(x) { + var n = +x; + return n < 1 ? NaN : n > 94906265.62425156 + ? log(n) + LN2 + : log1p(n - 1 + sqrt(n - 1) * sqrt(n + 1)); + } + }); + return es_math_acosh; +} + +var es_math_asinh = {}; + +var hasRequiredEs_math_asinh; + +function requireEs_math_asinh () { + if (hasRequiredEs_math_asinh) return es_math_asinh; + hasRequiredEs_math_asinh = 1; + var $ = require_export(); + + // eslint-disable-next-line es/no-math-asinh -- required for testing + var $asinh = Math.asinh; + var log = Math.log; + var sqrt = Math.sqrt; + + function asinh(x) { + var n = +x; + return !isFinite(n) || n === 0 ? n : n < 0 ? -asinh(-n) : log(n + sqrt(n * n + 1)); + } + + var FORCED = !($asinh && 1 / $asinh(0) > 0); + + // `Math.asinh` method + // https://tc39.es/ecma262/#sec-math.asinh + // Tor Browser bug: Math.asinh(0) -> -0 + $({ target: 'Math', stat: true, forced: FORCED }, { + asinh: asinh + }); + return es_math_asinh; +} + +var es_math_atanh = {}; + +var hasRequiredEs_math_atanh; + +function requireEs_math_atanh () { + if (hasRequiredEs_math_atanh) return es_math_atanh; + hasRequiredEs_math_atanh = 1; + var $ = require_export(); + + // eslint-disable-next-line es/no-math-atanh -- required for testing + var $atanh = Math.atanh; + var log = Math.log; + + var FORCED = !($atanh && 1 / $atanh(-0) < 0); + + // `Math.atanh` method + // https://tc39.es/ecma262/#sec-math.atanh + // Tor Browser bug: Math.atanh(-0) -> 0 + $({ target: 'Math', stat: true, forced: FORCED }, { + atanh: function atanh(x) { + var n = +x; + return n === 0 ? n : log((1 + n) / (1 - n)) / 2; + } + }); + return es_math_atanh; +} + +var es_math_cbrt = {}; + +var hasRequiredEs_math_cbrt; + +function requireEs_math_cbrt () { + if (hasRequiredEs_math_cbrt) return es_math_cbrt; + hasRequiredEs_math_cbrt = 1; + var $ = require_export(); + var sign = requireMathSign(); + + var abs = Math.abs; + var pow = Math.pow; + + // `Math.cbrt` method + // https://tc39.es/ecma262/#sec-math.cbrt + $({ target: 'Math', stat: true }, { + cbrt: function cbrt(x) { + var n = +x; + return sign(n) * pow(abs(n), 1 / 3); + } + }); + return es_math_cbrt; +} + +var es_math_clz32 = {}; + +var hasRequiredEs_math_clz32; + +function requireEs_math_clz32 () { + if (hasRequiredEs_math_clz32) return es_math_clz32; + hasRequiredEs_math_clz32 = 1; + var $ = require_export(); + + var floor = Math.floor; + var log = Math.log; + var LOG2E = Math.LOG2E; + + // `Math.clz32` method + // https://tc39.es/ecma262/#sec-math.clz32 + $({ target: 'Math', stat: true }, { + clz32: function clz32(x) { + var n = x >>> 0; + return n ? 31 - floor(log(n + 0.5) * LOG2E) : 32; + } + }); + return es_math_clz32; +} + +var es_math_cosh = {}; + +var mathExpm1; +var hasRequiredMathExpm1; + +function requireMathExpm1 () { + if (hasRequiredMathExpm1) return mathExpm1; + hasRequiredMathExpm1 = 1; + // eslint-disable-next-line es/no-math-expm1 -- safe + var $expm1 = Math.expm1; + var exp = Math.exp; + + // `Math.expm1` method implementation + // https://tc39.es/ecma262/#sec-math.expm1 + mathExpm1 = (!$expm1 + // Old FF bug + // eslint-disable-next-line no-loss-of-precision -- required for old engines + || $expm1(10) > 22025.465794806719 || $expm1(10) < 22025.4657948067165168 + // Tor Browser bug + || $expm1(-2e-17) !== -2e-17 + ) ? function expm1(x) { + var n = +x; + return n === 0 ? n : n > -1e-6 && n < 1e-6 ? n + n * n / 2 : exp(n) - 1; + } : $expm1; + return mathExpm1; +} + +var hasRequiredEs_math_cosh; + +function requireEs_math_cosh () { + if (hasRequiredEs_math_cosh) return es_math_cosh; + hasRequiredEs_math_cosh = 1; + var $ = require_export(); + var expm1 = requireMathExpm1(); + + // eslint-disable-next-line es/no-math-cosh -- required for testing + var $cosh = Math.cosh; + var abs = Math.abs; + var E = Math.E; + + var FORCED = !$cosh || $cosh(710) === Infinity; + + // `Math.cosh` method + // https://tc39.es/ecma262/#sec-math.cosh + $({ target: 'Math', stat: true, forced: FORCED }, { + cosh: function cosh(x) { + var t = expm1(abs(x) - 1) + 1; + return (t + 1 / (t * E * E)) * (E / 2); + } + }); + return es_math_cosh; +} + +var es_math_expm1 = {}; + +var hasRequiredEs_math_expm1; + +function requireEs_math_expm1 () { + if (hasRequiredEs_math_expm1) return es_math_expm1; + hasRequiredEs_math_expm1 = 1; + var $ = require_export(); + var expm1 = requireMathExpm1(); + + // `Math.expm1` method + // https://tc39.es/ecma262/#sec-math.expm1 + // eslint-disable-next-line es/no-math-expm1 -- required for testing + $({ target: 'Math', stat: true, forced: expm1 !== Math.expm1 }, { expm1: expm1 }); + return es_math_expm1; +} + +var es_math_fround = {}; + +var hasRequiredEs_math_fround; + +function requireEs_math_fround () { + if (hasRequiredEs_math_fround) return es_math_fround; + hasRequiredEs_math_fround = 1; + var $ = require_export(); + var fround = requireMathFround(); + + // `Math.fround` method + // https://tc39.es/ecma262/#sec-math.fround + $({ target: 'Math', stat: true }, { fround: fround }); + return es_math_fround; +} + +var es_math_hypot = {}; + +var hasRequiredEs_math_hypot; + +function requireEs_math_hypot () { + if (hasRequiredEs_math_hypot) return es_math_hypot; + hasRequiredEs_math_hypot = 1; + var $ = require_export(); + + // eslint-disable-next-line es/no-math-hypot -- required for testing + var $hypot = Math.hypot; + var abs = Math.abs; + var sqrt = Math.sqrt; + + // Chrome 77 bug + // https://bugs.chromium.org/p/v8/issues/detail?id=9546 + var FORCED = !!$hypot && $hypot(Infinity, NaN) !== Infinity; + + // `Math.hypot` method + // https://tc39.es/ecma262/#sec-math.hypot + $({ target: 'Math', stat: true, arity: 2, forced: FORCED }, { + // eslint-disable-next-line no-unused-vars -- required for `.length` + hypot: function hypot(value1, value2) { + var sum = 0; + var i = 0; + var aLen = arguments.length; + var larg = 0; + var arg, div; + while (i < aLen) { + arg = abs(arguments[i++]); + if (larg < arg) { + div = larg / arg; + sum = sum * div * div + 1; + larg = arg; + } else if (arg > 0) { + div = arg / larg; + sum += div * div; + } else sum += arg; + } + return larg === Infinity ? Infinity : larg * sqrt(sum); + } + }); + return es_math_hypot; +} + +var es_math_imul = {}; + +var hasRequiredEs_math_imul; + +function requireEs_math_imul () { + if (hasRequiredEs_math_imul) return es_math_imul; + hasRequiredEs_math_imul = 1; + var $ = require_export(); + var fails = requireFails(); + + // eslint-disable-next-line es/no-math-imul -- required for testing + var $imul = Math.imul; + + var FORCED = fails(function () { + return $imul(0xFFFFFFFF, 5) !== -5 || $imul.length !== 2; + }); + + // `Math.imul` method + // https://tc39.es/ecma262/#sec-math.imul + // some WebKit versions fails with big numbers, some has wrong arity + $({ target: 'Math', stat: true, forced: FORCED }, { + imul: function imul(x, y) { + var UINT16 = 0xFFFF; + var xn = +x; + var yn = +y; + var xl = UINT16 & xn; + var yl = UINT16 & yn; + return 0 | xl * yl + ((UINT16 & xn >>> 16) * yl + xl * (UINT16 & yn >>> 16) << 16 >>> 0); + } + }); + return es_math_imul; +} + +var es_math_log10 = {}; + +var mathLog10; +var hasRequiredMathLog10; + +function requireMathLog10 () { + if (hasRequiredMathLog10) return mathLog10; + hasRequiredMathLog10 = 1; + var log = Math.log; + var LOG10E = Math.LOG10E; + + // eslint-disable-next-line es/no-math-log10 -- safe + mathLog10 = Math.log10 || function log10(x) { + return log(x) * LOG10E; + }; + return mathLog10; +} + +var hasRequiredEs_math_log10; + +function requireEs_math_log10 () { + if (hasRequiredEs_math_log10) return es_math_log10; + hasRequiredEs_math_log10 = 1; + var $ = require_export(); + var log10 = requireMathLog10(); + + // `Math.log10` method + // https://tc39.es/ecma262/#sec-math.log10 + $({ target: 'Math', stat: true }, { + log10: log10 + }); + return es_math_log10; +} + +var es_math_log1p = {}; + +var hasRequiredEs_math_log1p; + +function requireEs_math_log1p () { + if (hasRequiredEs_math_log1p) return es_math_log1p; + hasRequiredEs_math_log1p = 1; + var $ = require_export(); + var log1p = requireMathLog1p(); + + // `Math.log1p` method + // https://tc39.es/ecma262/#sec-math.log1p + $({ target: 'Math', stat: true }, { log1p: log1p }); + return es_math_log1p; +} + +var es_math_log2 = {}; + +var hasRequiredEs_math_log2; + +function requireEs_math_log2 () { + if (hasRequiredEs_math_log2) return es_math_log2; + hasRequiredEs_math_log2 = 1; + var $ = require_export(); + + var log = Math.log; + var LN2 = Math.LN2; + + // `Math.log2` method + // https://tc39.es/ecma262/#sec-math.log2 + $({ target: 'Math', stat: true }, { + log2: function log2(x) { + return log(x) / LN2; + } + }); + return es_math_log2; +} + +var es_math_sign = {}; + +var hasRequiredEs_math_sign; + +function requireEs_math_sign () { + if (hasRequiredEs_math_sign) return es_math_sign; + hasRequiredEs_math_sign = 1; + var $ = require_export(); + var sign = requireMathSign(); + + // `Math.sign` method + // https://tc39.es/ecma262/#sec-math.sign + $({ target: 'Math', stat: true }, { + sign: sign + }); + return es_math_sign; +} + +var es_math_sinh = {}; + +var hasRequiredEs_math_sinh; + +function requireEs_math_sinh () { + if (hasRequiredEs_math_sinh) return es_math_sinh; + hasRequiredEs_math_sinh = 1; + var $ = require_export(); + var fails = requireFails(); + var expm1 = requireMathExpm1(); + + var abs = Math.abs; + var exp = Math.exp; + var E = Math.E; + + var FORCED = fails(function () { + // eslint-disable-next-line es/no-math-sinh -- required for testing + return Math.sinh(-2e-17) !== -2e-17; + }); + + // `Math.sinh` method + // https://tc39.es/ecma262/#sec-math.sinh + // V8 near Chromium 38 has a problem with very small numbers + $({ target: 'Math', stat: true, forced: FORCED }, { + sinh: function sinh(x) { + var n = +x; + return abs(n) < 1 ? (expm1(n) - expm1(-n)) / 2 : (exp(n - 1) - exp(-n - 1)) * (E / 2); + } + }); + return es_math_sinh; +} + +var es_math_tanh = {}; + +var hasRequiredEs_math_tanh; + +function requireEs_math_tanh () { + if (hasRequiredEs_math_tanh) return es_math_tanh; + hasRequiredEs_math_tanh = 1; + var $ = require_export(); + var expm1 = requireMathExpm1(); + + var exp = Math.exp; + + // `Math.tanh` method + // https://tc39.es/ecma262/#sec-math.tanh + $({ target: 'Math', stat: true }, { + tanh: function tanh(x) { + var n = +x; + var a = expm1(n); + var b = expm1(-n); + return a === Infinity ? 1 : b === Infinity ? -1 : (a - b) / (exp(n) + exp(-n)); + } + }); + return es_math_tanh; +} + +var es_math_toStringTag = {}; + +var hasRequiredEs_math_toStringTag; + +function requireEs_math_toStringTag () { + if (hasRequiredEs_math_toStringTag) return es_math_toStringTag; + hasRequiredEs_math_toStringTag = 1; + var setToStringTag = requireSetToStringTag(); + + // Math[@@toStringTag] property + // https://tc39.es/ecma262/#sec-math-@@tostringtag + setToStringTag(Math, 'Math', true); + return es_math_toStringTag; +} + +var es_math_trunc = {}; + +var hasRequiredEs_math_trunc; + +function requireEs_math_trunc () { + if (hasRequiredEs_math_trunc) return es_math_trunc; + hasRequiredEs_math_trunc = 1; + var $ = require_export(); + var trunc = requireMathTrunc(); + + // `Math.trunc` method + // https://tc39.es/ecma262/#sec-math.trunc + $({ target: 'Math', stat: true }, { + trunc: trunc + }); + return es_math_trunc; +} + +var es_number_constructor = {}; + +var thisNumberValue; +var hasRequiredThisNumberValue; + +function requireThisNumberValue () { + if (hasRequiredThisNumberValue) return thisNumberValue; + hasRequiredThisNumberValue = 1; + var uncurryThis = requireFunctionUncurryThis(); + + // `thisNumberValue` abstract operation + // https://tc39.es/ecma262/#sec-thisnumbervalue + thisNumberValue = uncurryThis(1.0.valueOf); + return thisNumberValue; +} + +var whitespaces; +var hasRequiredWhitespaces; + +function requireWhitespaces () { + if (hasRequiredWhitespaces) return whitespaces; + hasRequiredWhitespaces = 1; + // a string of all valid unicode whitespaces + whitespaces = '\u0009\u000A\u000B\u000C\u000D\u0020\u00A0\u1680\u2000\u2001\u2002' + + '\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF'; + return whitespaces; +} + +var stringTrim; +var hasRequiredStringTrim; + +function requireStringTrim () { + if (hasRequiredStringTrim) return stringTrim; + hasRequiredStringTrim = 1; + var uncurryThis = requireFunctionUncurryThis(); + var requireObjectCoercible = requireRequireObjectCoercible(); + var toString = requireToString(); + var whitespaces = requireWhitespaces(); + + var replace = uncurryThis(''.replace); + var ltrim = RegExp('^[' + whitespaces + ']+'); + var rtrim = RegExp('(^|[^' + whitespaces + '])[' + whitespaces + ']+$'); + + // `String.prototype.{ trim, trimStart, trimEnd, trimLeft, trimRight }` methods implementation + var createMethod = function (TYPE) { + return function ($this) { + var string = toString(requireObjectCoercible($this)); + if (TYPE & 1) string = replace(string, ltrim, ''); + if (TYPE & 2) string = replace(string, rtrim, '$1'); + return string; + }; + }; + + stringTrim = { + // `String.prototype.{ trimLeft, trimStart }` methods + // https://tc39.es/ecma262/#sec-string.prototype.trimstart + start: createMethod(1), + // `String.prototype.{ trimRight, trimEnd }` methods + // https://tc39.es/ecma262/#sec-string.prototype.trimend + end: createMethod(2), + // `String.prototype.trim` method + // https://tc39.es/ecma262/#sec-string.prototype.trim + trim: createMethod(3) + }; + return stringTrim; +} + +var hasRequiredEs_number_constructor; + +function requireEs_number_constructor () { + if (hasRequiredEs_number_constructor) return es_number_constructor; + hasRequiredEs_number_constructor = 1; + var $ = require_export(); + var IS_PURE = requireIsPure(); + var DESCRIPTORS = requireDescriptors(); + var globalThis = requireGlobalThis(); + var path = requirePath(); + var uncurryThis = requireFunctionUncurryThis(); + var isForced = requireIsForced(); + var hasOwn = requireHasOwnProperty(); + var inheritIfRequired = requireInheritIfRequired(); + var isPrototypeOf = requireObjectIsPrototypeOf(); + var isSymbol = requireIsSymbol(); + var toPrimitive = requireToPrimitive(); + var fails = requireFails(); + var getOwnPropertyNames = requireObjectGetOwnPropertyNames().f; + var getOwnPropertyDescriptor = requireObjectGetOwnPropertyDescriptor().f; + var defineProperty = requireObjectDefineProperty().f; + var thisNumberValue = requireThisNumberValue(); + var trim = requireStringTrim().trim; + + var NUMBER = 'Number'; + var NativeNumber = globalThis[NUMBER]; + var PureNumberNamespace = path[NUMBER]; + var NumberPrototype = NativeNumber.prototype; + var TypeError = globalThis.TypeError; + var stringSlice = uncurryThis(''.slice); + var charCodeAt = uncurryThis(''.charCodeAt); + + // `ToNumeric` abstract operation + // https://tc39.es/ecma262/#sec-tonumeric + var toNumeric = function (value) { + var primValue = toPrimitive(value, 'number'); + return typeof primValue == 'bigint' ? primValue : toNumber(primValue); + }; + + // `ToNumber` abstract operation + // https://tc39.es/ecma262/#sec-tonumber + var toNumber = function (argument) { + var it = toPrimitive(argument, 'number'); + var first, third, radix, maxCode, digits, length, index, code; + if (isSymbol(it)) throw new TypeError('Cannot convert a Symbol value to a number'); + if (typeof it == 'string' && it.length > 2) { + it = trim(it); + first = charCodeAt(it, 0); + if (first === 43 || first === 45) { + third = charCodeAt(it, 2); + if (third === 88 || third === 120) return NaN; // Number('+0x1') should be NaN, old V8 fix + } else if (first === 48) { + switch (charCodeAt(it, 1)) { + // fast equal of /^0b[01]+$/i + case 66: + case 98: + radix = 2; + maxCode = 49; + break; + // fast equal of /^0o[0-7]+$/i + case 79: + case 111: + radix = 8; + maxCode = 55; + break; + default: + return +it; + } + digits = stringSlice(it, 2); + length = digits.length; + for (index = 0; index < length; index++) { + code = charCodeAt(digits, index); + // parseInt parses a string to a first unavailable symbol + // but ToNumber should return NaN if a string contains unavailable symbols + if (code < 48 || code > maxCode) return NaN; + } return parseInt(digits, radix); + } + } return +it; + }; + + var FORCED = isForced(NUMBER, !NativeNumber(' 0o1') || !NativeNumber('0b1') || NativeNumber('+0x1')); + + var calledWithNew = function (dummy) { + // includes check on 1..constructor(foo) case + return isPrototypeOf(NumberPrototype, dummy) && fails(function () { thisNumberValue(dummy); }); + }; + + // `Number` constructor + // https://tc39.es/ecma262/#sec-number-constructor + var NumberWrapper = function Number(value) { + var n = arguments.length < 1 ? 0 : NativeNumber(toNumeric(value)); + return calledWithNew(this) ? inheritIfRequired(Object(n), this, NumberWrapper) : n; + }; + + NumberWrapper.prototype = NumberPrototype; + if (FORCED && !IS_PURE) NumberPrototype.constructor = NumberWrapper; + + $({ global: true, constructor: true, wrap: true, forced: FORCED }, { + Number: NumberWrapper + }); + + // Use `internal/copy-constructor-properties` helper in `core-js@4` + var copyConstructorProperties = function (target, source) { + for (var keys = DESCRIPTORS ? getOwnPropertyNames(source) : ( + // ES3: + 'MAX_VALUE,MIN_VALUE,NaN,NEGATIVE_INFINITY,POSITIVE_INFINITY,' + + // ES2015 (in case, if modules with ES2015 Number statics required before): + 'EPSILON,MAX_SAFE_INTEGER,MIN_SAFE_INTEGER,isFinite,isInteger,isNaN,isSafeInteger,parseFloat,parseInt,' + + // ESNext + 'fromString,range' + ).split(','), j = 0, key; keys.length > j; j++) { + if (hasOwn(source, key = keys[j]) && !hasOwn(target, key)) { + defineProperty(target, key, getOwnPropertyDescriptor(source, key)); + } + } + }; + + if (IS_PURE && PureNumberNamespace) copyConstructorProperties(path[NUMBER], PureNumberNamespace); + if (FORCED || IS_PURE) copyConstructorProperties(path[NUMBER], NativeNumber); + return es_number_constructor; +} + +var es_number_epsilon = {}; + +var hasRequiredEs_number_epsilon; + +function requireEs_number_epsilon () { + if (hasRequiredEs_number_epsilon) return es_number_epsilon; + hasRequiredEs_number_epsilon = 1; + var $ = require_export(); + + // `Number.EPSILON` constant + // https://tc39.es/ecma262/#sec-number.epsilon + $({ target: 'Number', stat: true, nonConfigurable: true, nonWritable: true }, { + EPSILON: Math.pow(2, -52) + }); + return es_number_epsilon; +} + +var es_number_isFinite = {}; + +var numberIsFinite; +var hasRequiredNumberIsFinite; + +function requireNumberIsFinite () { + if (hasRequiredNumberIsFinite) return numberIsFinite; + hasRequiredNumberIsFinite = 1; + var globalThis = requireGlobalThis(); + + var globalIsFinite = globalThis.isFinite; + + // `Number.isFinite` method + // https://tc39.es/ecma262/#sec-number.isfinite + // eslint-disable-next-line es/no-number-isfinite -- safe + numberIsFinite = Number.isFinite || function isFinite(it) { + return typeof it == 'number' && globalIsFinite(it); + }; + return numberIsFinite; +} + +var hasRequiredEs_number_isFinite; + +function requireEs_number_isFinite () { + if (hasRequiredEs_number_isFinite) return es_number_isFinite; + hasRequiredEs_number_isFinite = 1; + var $ = require_export(); + var numberIsFinite = requireNumberIsFinite(); + + // `Number.isFinite` method + // https://tc39.es/ecma262/#sec-number.isfinite + $({ target: 'Number', stat: true }, { isFinite: numberIsFinite }); + return es_number_isFinite; +} + +var es_number_isInteger = {}; + +var isIntegralNumber; +var hasRequiredIsIntegralNumber; + +function requireIsIntegralNumber () { + if (hasRequiredIsIntegralNumber) return isIntegralNumber; + hasRequiredIsIntegralNumber = 1; + var isObject = requireIsObject(); + + var floor = Math.floor; + + // `IsIntegralNumber` abstract operation + // https://tc39.es/ecma262/#sec-isintegralnumber + // eslint-disable-next-line es/no-number-isinteger -- safe + isIntegralNumber = Number.isInteger || function isInteger(it) { + return !isObject(it) && isFinite(it) && floor(it) === it; + }; + return isIntegralNumber; +} + +var hasRequiredEs_number_isInteger; + +function requireEs_number_isInteger () { + if (hasRequiredEs_number_isInteger) return es_number_isInteger; + hasRequiredEs_number_isInteger = 1; + var $ = require_export(); + var isIntegralNumber = requireIsIntegralNumber(); + + // `Number.isInteger` method + // https://tc39.es/ecma262/#sec-number.isinteger + $({ target: 'Number', stat: true }, { + isInteger: isIntegralNumber + }); + return es_number_isInteger; +} + +var es_number_isNan = {}; + +var hasRequiredEs_number_isNan; + +function requireEs_number_isNan () { + if (hasRequiredEs_number_isNan) return es_number_isNan; + hasRequiredEs_number_isNan = 1; + var $ = require_export(); + + // `Number.isNaN` method + // https://tc39.es/ecma262/#sec-number.isnan + $({ target: 'Number', stat: true }, { + isNaN: function isNaN(number) { + // eslint-disable-next-line no-self-compare -- NaN check + return number !== number; + } + }); + return es_number_isNan; +} + +var es_number_isSafeInteger = {}; + +var hasRequiredEs_number_isSafeInteger; + +function requireEs_number_isSafeInteger () { + if (hasRequiredEs_number_isSafeInteger) return es_number_isSafeInteger; + hasRequiredEs_number_isSafeInteger = 1; + var $ = require_export(); + var isIntegralNumber = requireIsIntegralNumber(); + + var abs = Math.abs; + + // `Number.isSafeInteger` method + // https://tc39.es/ecma262/#sec-number.issafeinteger + $({ target: 'Number', stat: true }, { + isSafeInteger: function isSafeInteger(number) { + return isIntegralNumber(number) && abs(number) <= 0x1FFFFFFFFFFFFF; + } + }); + return es_number_isSafeInteger; +} + +var es_number_maxSafeInteger = {}; + +var hasRequiredEs_number_maxSafeInteger; + +function requireEs_number_maxSafeInteger () { + if (hasRequiredEs_number_maxSafeInteger) return es_number_maxSafeInteger; + hasRequiredEs_number_maxSafeInteger = 1; + var $ = require_export(); + + // `Number.MAX_SAFE_INTEGER` constant + // https://tc39.es/ecma262/#sec-number.max_safe_integer + $({ target: 'Number', stat: true, nonConfigurable: true, nonWritable: true }, { + MAX_SAFE_INTEGER: 0x1FFFFFFFFFFFFF + }); + return es_number_maxSafeInteger; +} + +var es_number_minSafeInteger = {}; + +var hasRequiredEs_number_minSafeInteger; + +function requireEs_number_minSafeInteger () { + if (hasRequiredEs_number_minSafeInteger) return es_number_minSafeInteger; + hasRequiredEs_number_minSafeInteger = 1; + var $ = require_export(); + + // `Number.MIN_SAFE_INTEGER` constant + // https://tc39.es/ecma262/#sec-number.min_safe_integer + $({ target: 'Number', stat: true, nonConfigurable: true, nonWritable: true }, { + MIN_SAFE_INTEGER: -9007199254740991 + }); + return es_number_minSafeInteger; +} + +var es_number_parseFloat = {}; + +var numberParseFloat; +var hasRequiredNumberParseFloat; + +function requireNumberParseFloat () { + if (hasRequiredNumberParseFloat) return numberParseFloat; + hasRequiredNumberParseFloat = 1; + var globalThis = requireGlobalThis(); + var fails = requireFails(); + var uncurryThis = requireFunctionUncurryThis(); + var toString = requireToString(); + var trim = requireStringTrim().trim; + var whitespaces = requireWhitespaces(); + + var charAt = uncurryThis(''.charAt); + var $parseFloat = globalThis.parseFloat; + var Symbol = globalThis.Symbol; + var ITERATOR = Symbol && Symbol.iterator; + var FORCED = 1 / $parseFloat(whitespaces + '-0') !== -Infinity + // MS Edge 18- broken with boxed symbols + || (ITERATOR && !fails(function () { $parseFloat(Object(ITERATOR)); })); + + // `parseFloat` method + // https://tc39.es/ecma262/#sec-parsefloat-string + numberParseFloat = FORCED ? function parseFloat(string) { + var trimmedString = trim(toString(string)); + var result = $parseFloat(trimmedString); + return result === 0 && charAt(trimmedString, 0) === '-' ? -0 : result; + } : $parseFloat; + return numberParseFloat; +} + +var hasRequiredEs_number_parseFloat; + +function requireEs_number_parseFloat () { + if (hasRequiredEs_number_parseFloat) return es_number_parseFloat; + hasRequiredEs_number_parseFloat = 1; + var $ = require_export(); + var parseFloat = requireNumberParseFloat(); + + // `Number.parseFloat` method + // https://tc39.es/ecma262/#sec-number.parseFloat + // eslint-disable-next-line es/no-number-parsefloat -- required for testing + $({ target: 'Number', stat: true, forced: Number.parseFloat !== parseFloat }, { + parseFloat: parseFloat + }); + return es_number_parseFloat; +} + +var es_number_parseInt = {}; + +var numberParseInt; +var hasRequiredNumberParseInt; + +function requireNumberParseInt () { + if (hasRequiredNumberParseInt) return numberParseInt; + hasRequiredNumberParseInt = 1; + var globalThis = requireGlobalThis(); + var fails = requireFails(); + var uncurryThis = requireFunctionUncurryThis(); + var toString = requireToString(); + var trim = requireStringTrim().trim; + var whitespaces = requireWhitespaces(); + + var $parseInt = globalThis.parseInt; + var Symbol = globalThis.Symbol; + var ITERATOR = Symbol && Symbol.iterator; + var hex = /^[+-]?0x/i; + var exec = uncurryThis(hex.exec); + var FORCED = $parseInt(whitespaces + '08') !== 8 || $parseInt(whitespaces + '0x16') !== 22 + // MS Edge 18- broken with boxed symbols + || (ITERATOR && !fails(function () { $parseInt(Object(ITERATOR)); })); + + // `parseInt` method + // https://tc39.es/ecma262/#sec-parseint-string-radix + numberParseInt = FORCED ? function parseInt(string, radix) { + var S = trim(toString(string)); + return $parseInt(S, (radix >>> 0) || (exec(hex, S) ? 16 : 10)); + } : $parseInt; + return numberParseInt; +} + +var hasRequiredEs_number_parseInt; + +function requireEs_number_parseInt () { + if (hasRequiredEs_number_parseInt) return es_number_parseInt; + hasRequiredEs_number_parseInt = 1; + var $ = require_export(); + var parseInt = requireNumberParseInt(); + + // `Number.parseInt` method + // https://tc39.es/ecma262/#sec-number.parseint + // eslint-disable-next-line es/no-number-parseint -- required for testing + $({ target: 'Number', stat: true, forced: Number.parseInt !== parseInt }, { + parseInt: parseInt + }); + return es_number_parseInt; +} + +var es_number_toExponential = {}; + +var hasRequiredEs_number_toExponential; + +function requireEs_number_toExponential () { + if (hasRequiredEs_number_toExponential) return es_number_toExponential; + hasRequiredEs_number_toExponential = 1; + var $ = require_export(); + var uncurryThis = requireFunctionUncurryThis(); + var toIntegerOrInfinity = requireToIntegerOrInfinity(); + var thisNumberValue = requireThisNumberValue(); + var $repeat = requireStringRepeat(); + var log10 = requireMathLog10(); + var fails = requireFails(); + + var $RangeError = RangeError; + var $String = String; + var $isFinite = isFinite; + var abs = Math.abs; + var floor = Math.floor; + var pow = Math.pow; + var round = Math.round; + var nativeToExponential = uncurryThis(1.0.toExponential); + var repeat = uncurryThis($repeat); + var stringSlice = uncurryThis(''.slice); + + // Edge 17- + var ROUNDS_PROPERLY = nativeToExponential(-69e-12, 4) === '-6.9000e-11' + // IE11- && Edge 14- + && nativeToExponential(1.255, 2) === '1.25e+0' + // FF86-, V8 ~ Chrome 49-50 + && nativeToExponential(12345, 3) === '1.235e+4' + // FF86-, V8 ~ Chrome 49-50 + && nativeToExponential(25, 0) === '3e+1'; + + // IE8- + var throwsOnInfinityFraction = function () { + return fails(function () { + nativeToExponential(1, Infinity); + }) && fails(function () { + nativeToExponential(1, -Infinity); + }); + }; + + // Safari <11 && FF <50 + var properNonFiniteThisCheck = function () { + return !fails(function () { + nativeToExponential(Infinity, Infinity); + nativeToExponential(NaN, Infinity); + }); + }; + + var FORCED = !ROUNDS_PROPERLY || !throwsOnInfinityFraction() || !properNonFiniteThisCheck(); + + // `Number.prototype.toExponential` method + // https://tc39.es/ecma262/#sec-number.prototype.toexponential + $({ target: 'Number', proto: true, forced: FORCED }, { + toExponential: function toExponential(fractionDigits) { + var x = thisNumberValue(this); + if (fractionDigits === undefined) return nativeToExponential(x); + var f = toIntegerOrInfinity(fractionDigits); + if (!$isFinite(x)) return String(x); + // TODO: ES2018 increased the maximum number of fraction digits to 100, need to improve the implementation + if (f < 0 || f > 20) throw new $RangeError('Incorrect fraction digits'); + if (ROUNDS_PROPERLY) return nativeToExponential(x, f); + var s = ''; + var m, e, c, d; + if (x < 0) { + s = '-'; + x = -x; + } + if (x === 0) { + e = 0; + m = repeat('0', f + 1); + } else { + // this block is based on https://gist.github.com/SheetJSDev/1100ad56b9f856c95299ed0e068eea08 + // TODO: improve accuracy with big fraction digits + var l = log10(x); + e = floor(l); + var w = pow(10, e - f); + var n = round(x / w); + if (2 * x >= (2 * n + 1) * w) { + n += 1; + } + if (n >= pow(10, f + 1)) { + n /= 10; + e += 1; + } + m = $String(n); + } + if (f !== 0) { + m = stringSlice(m, 0, 1) + '.' + stringSlice(m, 1); + } + if (e === 0) { + c = '+'; + d = '0'; + } else { + c = e > 0 ? '+' : '-'; + d = $String(abs(e)); + } + m += 'e' + c + d; + return s + m; + } + }); + return es_number_toExponential; +} + +var es_number_toFixed = {}; + +var hasRequiredEs_number_toFixed; + +function requireEs_number_toFixed () { + if (hasRequiredEs_number_toFixed) return es_number_toFixed; + hasRequiredEs_number_toFixed = 1; + var $ = require_export(); + var uncurryThis = requireFunctionUncurryThis(); + var toIntegerOrInfinity = requireToIntegerOrInfinity(); + var thisNumberValue = requireThisNumberValue(); + var $repeat = requireStringRepeat(); + var fails = requireFails(); + + var $RangeError = RangeError; + var $String = String; + var floor = Math.floor; + var repeat = uncurryThis($repeat); + var stringSlice = uncurryThis(''.slice); + var nativeToFixed = uncurryThis(1.0.toFixed); + + var pow = function (x, n, acc) { + return n === 0 ? acc : n % 2 === 1 ? pow(x, n - 1, acc * x) : pow(x * x, n / 2, acc); + }; + + var log = function (x) { + var n = 0; + var x2 = x; + while (x2 >= 4096) { + n += 12; + x2 /= 4096; + } + while (x2 >= 2) { + n += 1; + x2 /= 2; + } return n; + }; + + var multiply = function (data, n, c) { + var index = -1; + var c2 = c; + while (++index < 6) { + c2 += n * data[index]; + data[index] = c2 % 1e7; + c2 = floor(c2 / 1e7); + } + }; + + var divide = function (data, n) { + var index = 6; + var c = 0; + while (--index >= 0) { + c += data[index]; + data[index] = floor(c / n); + c = (c % n) * 1e7; + } + }; + + var dataToString = function (data) { + var index = 6; + var s = ''; + while (--index >= 0) { + if (s !== '' || index === 0 || data[index] !== 0) { + var t = $String(data[index]); + s = s === '' ? t : s + repeat('0', 7 - t.length) + t; + } + } return s; + }; + + var FORCED = fails(function () { + return nativeToFixed(0.00008, 3) !== '0.000' || + nativeToFixed(0.9, 0) !== '1' || + nativeToFixed(1.255, 2) !== '1.25' || + nativeToFixed(1000000000000000128.0, 0) !== '1000000000000000128'; + }) || !fails(function () { + // V8 ~ Android 4.3- + nativeToFixed({}); + }); + + // `Number.prototype.toFixed` method + // https://tc39.es/ecma262/#sec-number.prototype.tofixed + $({ target: 'Number', proto: true, forced: FORCED }, { + toFixed: function toFixed(fractionDigits) { + var number = thisNumberValue(this); + var fractDigits = toIntegerOrInfinity(fractionDigits); + var data = [0, 0, 0, 0, 0, 0]; + var sign = ''; + var result = '0'; + var e, z, j, k; + + // TODO: ES2018 increased the maximum number of fraction digits to 100, need to improve the implementation + if (fractDigits < 0 || fractDigits > 20) throw new $RangeError('Incorrect fraction digits'); + // eslint-disable-next-line no-self-compare -- NaN check + if (number !== number) return 'NaN'; + if (number <= -1e21 || number >= 1e21) return $String(number); + if (number < 0) { + sign = '-'; + number = -number; + } + if (number > 1e-21) { + e = log(number * pow(2, 69, 1)) - 69; + z = e < 0 ? number * pow(2, -e, 1) : number / pow(2, e, 1); + z *= 0x10000000000000; + e = 52 - e; + if (e > 0) { + multiply(data, 0, z); + j = fractDigits; + while (j >= 7) { + multiply(data, 1e7, 0); + j -= 7; + } + multiply(data, pow(10, j, 1), 0); + j = e - 1; + while (j >= 23) { + divide(data, 1 << 23); + j -= 23; + } + divide(data, 1 << j); + multiply(data, 1, 1); + divide(data, 2); + result = dataToString(data); + } else { + multiply(data, 0, z); + multiply(data, 1 << -e, 0); + result = dataToString(data) + repeat('0', fractDigits); + } + } + if (fractDigits > 0) { + k = result.length; + result = sign + (k <= fractDigits + ? '0.' + repeat('0', fractDigits - k) + result + : stringSlice(result, 0, k - fractDigits) + '.' + stringSlice(result, k - fractDigits)); + } else { + result = sign + result; + } return result; + } + }); + return es_number_toFixed; +} + +var es_number_toPrecision = {}; + +var hasRequiredEs_number_toPrecision; + +function requireEs_number_toPrecision () { + if (hasRequiredEs_number_toPrecision) return es_number_toPrecision; + hasRequiredEs_number_toPrecision = 1; + var $ = require_export(); + var uncurryThis = requireFunctionUncurryThis(); + var fails = requireFails(); + var thisNumberValue = requireThisNumberValue(); + + var nativeToPrecision = uncurryThis(1.0.toPrecision); + + var FORCED = fails(function () { + // IE7- + return nativeToPrecision(1, undefined) !== '1'; + }) || !fails(function () { + // V8 ~ Android 4.3- + nativeToPrecision({}); + }); + + // `Number.prototype.toPrecision` method + // https://tc39.es/ecma262/#sec-number.prototype.toprecision + $({ target: 'Number', proto: true, forced: FORCED }, { + toPrecision: function toPrecision(precision) { + return precision === undefined + ? nativeToPrecision(thisNumberValue(this)) + : nativeToPrecision(thisNumberValue(this), precision); + } + }); + return es_number_toPrecision; +} + +var es_object_assign = {}; + +var objectAssign; +var hasRequiredObjectAssign; + +function requireObjectAssign () { + if (hasRequiredObjectAssign) return objectAssign; + hasRequiredObjectAssign = 1; + var DESCRIPTORS = requireDescriptors(); + var uncurryThis = requireFunctionUncurryThis(); + var call = requireFunctionCall(); + var fails = requireFails(); + var objectKeys = requireObjectKeys(); + var getOwnPropertySymbolsModule = requireObjectGetOwnPropertySymbols(); + var propertyIsEnumerableModule = requireObjectPropertyIsEnumerable(); + var toObject = requireToObject(); + var IndexedObject = requireIndexedObject(); + + // eslint-disable-next-line es/no-object-assign -- safe + var $assign = Object.assign; + // eslint-disable-next-line es/no-object-defineproperty -- required for testing + var defineProperty = Object.defineProperty; + var concat = uncurryThis([].concat); + + // `Object.assign` method + // https://tc39.es/ecma262/#sec-object.assign + objectAssign = !$assign || fails(function () { + // should have correct order of operations (Edge bug) + if (DESCRIPTORS && $assign({ b: 1 }, $assign(defineProperty({}, 'a', { + enumerable: true, + get: function () { + defineProperty(this, 'b', { + value: 3, + enumerable: false + }); + } + }), { b: 2 })).b !== 1) return true; + // should work with symbols and should have deterministic property order (V8 bug) + var A = {}; + var B = {}; + // eslint-disable-next-line es/no-symbol -- safe + var symbol = Symbol('assign detection'); + var alphabet = 'abcdefghijklmnopqrst'; + A[symbol] = 7; + alphabet.split('').forEach(function (chr) { B[chr] = chr; }); + return $assign({}, A)[symbol] !== 7 || objectKeys($assign({}, B)).join('') !== alphabet; + }) ? function assign(target, source) { // eslint-disable-line no-unused-vars -- required for `.length` + var T = toObject(target); + var argumentsLength = arguments.length; + var index = 1; + var getOwnPropertySymbols = getOwnPropertySymbolsModule.f; + var propertyIsEnumerable = propertyIsEnumerableModule.f; + while (argumentsLength > index) { + var S = IndexedObject(arguments[index++]); + var keys = getOwnPropertySymbols ? concat(objectKeys(S), getOwnPropertySymbols(S)) : objectKeys(S); + var length = keys.length; + var j = 0; + var key; + while (length > j) { + key = keys[j++]; + if (!DESCRIPTORS || call(propertyIsEnumerable, S, key)) T[key] = S[key]; + } + } return T; + } : $assign; + return objectAssign; +} + +var hasRequiredEs_object_assign; + +function requireEs_object_assign () { + if (hasRequiredEs_object_assign) return es_object_assign; + hasRequiredEs_object_assign = 1; + var $ = require_export(); + var assign = requireObjectAssign(); + + // `Object.assign` method + // https://tc39.es/ecma262/#sec-object.assign + // eslint-disable-next-line es/no-object-assign -- required for testing + $({ target: 'Object', stat: true, arity: 2, forced: Object.assign !== assign }, { + assign: assign + }); + return es_object_assign; +} + +var es_object_create = {}; + +var hasRequiredEs_object_create; + +function requireEs_object_create () { + if (hasRequiredEs_object_create) return es_object_create; + hasRequiredEs_object_create = 1; + // TODO: Remove from `core-js@4` + var $ = require_export(); + var DESCRIPTORS = requireDescriptors(); + var create = requireObjectCreate(); + + // `Object.create` method + // https://tc39.es/ecma262/#sec-object.create + $({ target: 'Object', stat: true, sham: !DESCRIPTORS }, { + create: create + }); + return es_object_create; +} + +var es_object_defineGetter = {}; + +var objectPrototypeAccessorsForced; +var hasRequiredObjectPrototypeAccessorsForced; + +function requireObjectPrototypeAccessorsForced () { + if (hasRequiredObjectPrototypeAccessorsForced) return objectPrototypeAccessorsForced; + hasRequiredObjectPrototypeAccessorsForced = 1; + /* eslint-disable no-undef, no-useless-call, sonar/no-reference-error -- required for testing */ + /* eslint-disable es/no-legacy-object-prototype-accessor-methods -- required for testing */ + var IS_PURE = requireIsPure(); + var globalThis = requireGlobalThis(); + var fails = requireFails(); + var WEBKIT = requireEnvironmentWebkitVersion(); + + // Forced replacement object prototype accessors methods + objectPrototypeAccessorsForced = IS_PURE || !fails(function () { + // This feature detection crashes old WebKit + // https://github.com/zloirock/core-js/issues/232 + if (WEBKIT && WEBKIT < 535) return; + var key = Math.random(); + // In FF throws only define methods + __defineSetter__.call(null, key, function () { /* empty */ }); + delete globalThis[key]; + }); + return objectPrototypeAccessorsForced; +} + +var hasRequiredEs_object_defineGetter; + +function requireEs_object_defineGetter () { + if (hasRequiredEs_object_defineGetter) return es_object_defineGetter; + hasRequiredEs_object_defineGetter = 1; + var $ = require_export(); + var DESCRIPTORS = requireDescriptors(); + var FORCED = requireObjectPrototypeAccessorsForced(); + var aCallable = requireACallable(); + var toObject = requireToObject(); + var definePropertyModule = requireObjectDefineProperty(); + + // `Object.prototype.__defineGetter__` method + // https://tc39.es/ecma262/#sec-object.prototype.__defineGetter__ + if (DESCRIPTORS) { + $({ target: 'Object', proto: true, forced: FORCED }, { + __defineGetter__: function __defineGetter__(P, getter) { + definePropertyModule.f(toObject(this), P, { get: aCallable(getter), enumerable: true, configurable: true }); + } + }); + } + return es_object_defineGetter; +} + +var es_object_defineProperties = {}; + +var hasRequiredEs_object_defineProperties; + +function requireEs_object_defineProperties () { + if (hasRequiredEs_object_defineProperties) return es_object_defineProperties; + hasRequiredEs_object_defineProperties = 1; + var $ = require_export(); + var DESCRIPTORS = requireDescriptors(); + var defineProperties = requireObjectDefineProperties().f; + + // `Object.defineProperties` method + // https://tc39.es/ecma262/#sec-object.defineproperties + // eslint-disable-next-line es/no-object-defineproperties -- safe + $({ target: 'Object', stat: true, forced: Object.defineProperties !== defineProperties, sham: !DESCRIPTORS }, { + defineProperties: defineProperties + }); + return es_object_defineProperties; +} + +var es_object_defineProperty = {}; + +var hasRequiredEs_object_defineProperty; + +function requireEs_object_defineProperty () { + if (hasRequiredEs_object_defineProperty) return es_object_defineProperty; + hasRequiredEs_object_defineProperty = 1; + var $ = require_export(); + var DESCRIPTORS = requireDescriptors(); + var defineProperty = requireObjectDefineProperty().f; + + // `Object.defineProperty` method + // https://tc39.es/ecma262/#sec-object.defineproperty + // eslint-disable-next-line es/no-object-defineproperty -- safe + $({ target: 'Object', stat: true, forced: Object.defineProperty !== defineProperty, sham: !DESCRIPTORS }, { + defineProperty: defineProperty + }); + return es_object_defineProperty; +} + +var es_object_defineSetter = {}; + +var hasRequiredEs_object_defineSetter; + +function requireEs_object_defineSetter () { + if (hasRequiredEs_object_defineSetter) return es_object_defineSetter; + hasRequiredEs_object_defineSetter = 1; + var $ = require_export(); + var DESCRIPTORS = requireDescriptors(); + var FORCED = requireObjectPrototypeAccessorsForced(); + var aCallable = requireACallable(); + var toObject = requireToObject(); + var definePropertyModule = requireObjectDefineProperty(); + + // `Object.prototype.__defineSetter__` method + // https://tc39.es/ecma262/#sec-object.prototype.__defineSetter__ + if (DESCRIPTORS) { + $({ target: 'Object', proto: true, forced: FORCED }, { + __defineSetter__: function __defineSetter__(P, setter) { + definePropertyModule.f(toObject(this), P, { set: aCallable(setter), enumerable: true, configurable: true }); + } + }); + } + return es_object_defineSetter; +} + +var es_object_entries = {}; + +var objectToArray; +var hasRequiredObjectToArray; + +function requireObjectToArray () { + if (hasRequiredObjectToArray) return objectToArray; + hasRequiredObjectToArray = 1; + var DESCRIPTORS = requireDescriptors(); + var fails = requireFails(); + var uncurryThis = requireFunctionUncurryThis(); + var objectGetPrototypeOf = requireObjectGetPrototypeOf(); + var objectKeys = requireObjectKeys(); + var toIndexedObject = requireToIndexedObject(); + var $propertyIsEnumerable = requireObjectPropertyIsEnumerable().f; + + var propertyIsEnumerable = uncurryThis($propertyIsEnumerable); + var push = uncurryThis([].push); + + // in some IE versions, `propertyIsEnumerable` returns incorrect result on integer keys + // of `null` prototype objects + var IE_BUG = DESCRIPTORS && fails(function () { + // eslint-disable-next-line es/no-object-create -- safe + var O = Object.create(null); + O[2] = 2; + return !propertyIsEnumerable(O, 2); + }); + + // `Object.{ entries, values }` methods implementation + var createMethod = function (TO_ENTRIES) { + return function (it) { + var O = toIndexedObject(it); + var keys = objectKeys(O); + var IE_WORKAROUND = IE_BUG && objectGetPrototypeOf(O) === null; + var length = keys.length; + var i = 0; + var result = []; + var key; + while (length > i) { + key = keys[i++]; + if (!DESCRIPTORS || (IE_WORKAROUND ? key in O : propertyIsEnumerable(O, key))) { + push(result, TO_ENTRIES ? [key, O[key]] : O[key]); + } + } + return result; + }; + }; + + objectToArray = { + // `Object.entries` method + // https://tc39.es/ecma262/#sec-object.entries + entries: createMethod(true), + // `Object.values` method + // https://tc39.es/ecma262/#sec-object.values + values: createMethod(false) + }; + return objectToArray; +} + +var hasRequiredEs_object_entries; + +function requireEs_object_entries () { + if (hasRequiredEs_object_entries) return es_object_entries; + hasRequiredEs_object_entries = 1; + var $ = require_export(); + var $entries = requireObjectToArray().entries; + + // `Object.entries` method + // https://tc39.es/ecma262/#sec-object.entries + $({ target: 'Object', stat: true }, { + entries: function entries(O) { + return $entries(O); + } + }); + return es_object_entries; +} + +var es_object_freeze = {}; + +var hasRequiredEs_object_freeze; + +function requireEs_object_freeze () { + if (hasRequiredEs_object_freeze) return es_object_freeze; + hasRequiredEs_object_freeze = 1; + var $ = require_export(); + var FREEZING = requireFreezing(); + var fails = requireFails(); + var isObject = requireIsObject(); + var onFreeze = requireInternalMetadata().onFreeze; + + // eslint-disable-next-line es/no-object-freeze -- safe + var $freeze = Object.freeze; + var FAILS_ON_PRIMITIVES = fails(function () { $freeze(1); }); + + // `Object.freeze` method + // https://tc39.es/ecma262/#sec-object.freeze + $({ target: 'Object', stat: true, forced: FAILS_ON_PRIMITIVES, sham: !FREEZING }, { + freeze: function freeze(it) { + return $freeze && isObject(it) ? $freeze(onFreeze(it)) : it; + } + }); + return es_object_freeze; +} + +var es_object_fromEntries = {}; + +var hasRequiredEs_object_fromEntries; + +function requireEs_object_fromEntries () { + if (hasRequiredEs_object_fromEntries) return es_object_fromEntries; + hasRequiredEs_object_fromEntries = 1; + var $ = require_export(); + var iterate = requireIterate(); + var createProperty = requireCreateProperty(); + + // `Object.fromEntries` method + // https://github.com/tc39/proposal-object-from-entries + $({ target: 'Object', stat: true }, { + fromEntries: function fromEntries(iterable) { + var obj = {}; + iterate(iterable, function (k, v) { + createProperty(obj, k, v); + }, { AS_ENTRIES: true }); + return obj; + } + }); + return es_object_fromEntries; +} + +var es_object_getOwnPropertyDescriptor = {}; + +var hasRequiredEs_object_getOwnPropertyDescriptor; + +function requireEs_object_getOwnPropertyDescriptor () { + if (hasRequiredEs_object_getOwnPropertyDescriptor) return es_object_getOwnPropertyDescriptor; + hasRequiredEs_object_getOwnPropertyDescriptor = 1; + var $ = require_export(); + var fails = requireFails(); + var toIndexedObject = requireToIndexedObject(); + var nativeGetOwnPropertyDescriptor = requireObjectGetOwnPropertyDescriptor().f; + var DESCRIPTORS = requireDescriptors(); + + var FORCED = !DESCRIPTORS || fails(function () { nativeGetOwnPropertyDescriptor(1); }); + + // `Object.getOwnPropertyDescriptor` method + // https://tc39.es/ecma262/#sec-object.getownpropertydescriptor + $({ target: 'Object', stat: true, forced: FORCED, sham: !DESCRIPTORS }, { + getOwnPropertyDescriptor: function getOwnPropertyDescriptor(it, key) { + return nativeGetOwnPropertyDescriptor(toIndexedObject(it), key); + } + }); + return es_object_getOwnPropertyDescriptor; +} + +var es_object_getOwnPropertyDescriptors = {}; + +var hasRequiredEs_object_getOwnPropertyDescriptors; + +function requireEs_object_getOwnPropertyDescriptors () { + if (hasRequiredEs_object_getOwnPropertyDescriptors) return es_object_getOwnPropertyDescriptors; + hasRequiredEs_object_getOwnPropertyDescriptors = 1; + var $ = require_export(); + var DESCRIPTORS = requireDescriptors(); + var ownKeys = requireOwnKeys(); + var toIndexedObject = requireToIndexedObject(); + var getOwnPropertyDescriptorModule = requireObjectGetOwnPropertyDescriptor(); + var createProperty = requireCreateProperty(); + + // `Object.getOwnPropertyDescriptors` method + // https://tc39.es/ecma262/#sec-object.getownpropertydescriptors + $({ target: 'Object', stat: true, sham: !DESCRIPTORS }, { + getOwnPropertyDescriptors: function getOwnPropertyDescriptors(object) { + var O = toIndexedObject(object); + var getOwnPropertyDescriptor = getOwnPropertyDescriptorModule.f; + var keys = ownKeys(O); + var result = {}; + var index = 0; + var key, descriptor; + while (keys.length > index) { + descriptor = getOwnPropertyDescriptor(O, key = keys[index++]); + if (descriptor !== undefined) createProperty(result, key, descriptor); + } + return result; + } + }); + return es_object_getOwnPropertyDescriptors; +} + +var es_object_getOwnPropertyNames = {}; + +var hasRequiredEs_object_getOwnPropertyNames; + +function requireEs_object_getOwnPropertyNames () { + if (hasRequiredEs_object_getOwnPropertyNames) return es_object_getOwnPropertyNames; + hasRequiredEs_object_getOwnPropertyNames = 1; + var $ = require_export(); + var fails = requireFails(); + var getOwnPropertyNames = requireObjectGetOwnPropertyNamesExternal().f; + + // eslint-disable-next-line es/no-object-getownpropertynames -- required for testing + var FAILS_ON_PRIMITIVES = fails(function () { return !Object.getOwnPropertyNames(1); }); + + // `Object.getOwnPropertyNames` method + // https://tc39.es/ecma262/#sec-object.getownpropertynames + $({ target: 'Object', stat: true, forced: FAILS_ON_PRIMITIVES }, { + getOwnPropertyNames: getOwnPropertyNames + }); + return es_object_getOwnPropertyNames; +} + +var es_object_getPrototypeOf = {}; + +var hasRequiredEs_object_getPrototypeOf; + +function requireEs_object_getPrototypeOf () { + if (hasRequiredEs_object_getPrototypeOf) return es_object_getPrototypeOf; + hasRequiredEs_object_getPrototypeOf = 1; + var $ = require_export(); + var fails = requireFails(); + var toObject = requireToObject(); + var nativeGetPrototypeOf = requireObjectGetPrototypeOf(); + var CORRECT_PROTOTYPE_GETTER = requireCorrectPrototypeGetter(); + + var FAILS_ON_PRIMITIVES = fails(function () { nativeGetPrototypeOf(1); }); + + // `Object.getPrototypeOf` method + // https://tc39.es/ecma262/#sec-object.getprototypeof + $({ target: 'Object', stat: true, forced: FAILS_ON_PRIMITIVES, sham: !CORRECT_PROTOTYPE_GETTER }, { + getPrototypeOf: function getPrototypeOf(it) { + return nativeGetPrototypeOf(toObject(it)); + } + }); + return es_object_getPrototypeOf; +} + +var es_object_groupBy = {}; + +var hasRequiredEs_object_groupBy; + +function requireEs_object_groupBy () { + if (hasRequiredEs_object_groupBy) return es_object_groupBy; + hasRequiredEs_object_groupBy = 1; + var $ = require_export(); + var getBuiltIn = requireGetBuiltIn(); + var uncurryThis = requireFunctionUncurryThis(); + var aCallable = requireACallable(); + var requireObjectCoercible = requireRequireObjectCoercible(); + var toPropertyKey = requireToPropertyKey(); + var iterate = requireIterate(); + var fails = requireFails(); + + // eslint-disable-next-line es/no-object-groupby -- testing + var nativeGroupBy = Object.groupBy; + var create = getBuiltIn('Object', 'create'); + var push = uncurryThis([].push); + + var DOES_NOT_WORK_WITH_PRIMITIVES = !nativeGroupBy || fails(function () { + return nativeGroupBy('ab', function (it) { + return it; + }).a.length !== 1; + }); + + // `Object.groupBy` method + // https://github.com/tc39/proposal-array-grouping + $({ target: 'Object', stat: true, forced: DOES_NOT_WORK_WITH_PRIMITIVES }, { + groupBy: function groupBy(items, callbackfn) { + requireObjectCoercible(items); + aCallable(callbackfn); + var obj = create(null); + var k = 0; + iterate(items, function (value) { + var key = toPropertyKey(callbackfn(value, k++)); + // in some IE versions, `hasOwnProperty` returns incorrect result on integer keys + // but since it's a `null` prototype object, we can safely use `in` + if (key in obj) push(obj[key], value); + else obj[key] = [value]; + }); + return obj; + } + }); + return es_object_groupBy; +} + +var es_object_hasOwn = {}; + +var hasRequiredEs_object_hasOwn; + +function requireEs_object_hasOwn () { + if (hasRequiredEs_object_hasOwn) return es_object_hasOwn; + hasRequiredEs_object_hasOwn = 1; + var $ = require_export(); + var hasOwn = requireHasOwnProperty(); + + // `Object.hasOwn` method + // https://tc39.es/ecma262/#sec-object.hasown + $({ target: 'Object', stat: true }, { + hasOwn: hasOwn + }); + return es_object_hasOwn; +} + +var es_object_is = {}; + +var sameValue; +var hasRequiredSameValue; + +function requireSameValue () { + if (hasRequiredSameValue) return sameValue; + hasRequiredSameValue = 1; + // `SameValue` abstract operation + // https://tc39.es/ecma262/#sec-samevalue + // eslint-disable-next-line es/no-object-is -- safe + sameValue = Object.is || function is(x, y) { + // eslint-disable-next-line no-self-compare -- NaN check + return x === y ? x !== 0 || 1 / x === 1 / y : x !== x && y !== y; + }; + return sameValue; +} + +var hasRequiredEs_object_is; + +function requireEs_object_is () { + if (hasRequiredEs_object_is) return es_object_is; + hasRequiredEs_object_is = 1; + var $ = require_export(); + var is = requireSameValue(); + + // `Object.is` method + // https://tc39.es/ecma262/#sec-object.is + $({ target: 'Object', stat: true }, { + is: is + }); + return es_object_is; +} + +var es_object_isExtensible = {}; + +var hasRequiredEs_object_isExtensible; + +function requireEs_object_isExtensible () { + if (hasRequiredEs_object_isExtensible) return es_object_isExtensible; + hasRequiredEs_object_isExtensible = 1; + var $ = require_export(); + var $isExtensible = requireObjectIsExtensible(); + + // `Object.isExtensible` method + // https://tc39.es/ecma262/#sec-object.isextensible + // eslint-disable-next-line es/no-object-isextensible -- safe + $({ target: 'Object', stat: true, forced: Object.isExtensible !== $isExtensible }, { + isExtensible: $isExtensible + }); + return es_object_isExtensible; +} + +var es_object_isFrozen = {}; + +var hasRequiredEs_object_isFrozen; + +function requireEs_object_isFrozen () { + if (hasRequiredEs_object_isFrozen) return es_object_isFrozen; + hasRequiredEs_object_isFrozen = 1; + var $ = require_export(); + var fails = requireFails(); + var isObject = requireIsObject(); + var classof = requireClassofRaw(); + var ARRAY_BUFFER_NON_EXTENSIBLE = requireArrayBufferNonExtensible(); + + // eslint-disable-next-line es/no-object-isfrozen -- safe + var $isFrozen = Object.isFrozen; + + var FORCED = ARRAY_BUFFER_NON_EXTENSIBLE || fails(function () { }); + + // `Object.isFrozen` method + // https://tc39.es/ecma262/#sec-object.isfrozen + $({ target: 'Object', stat: true, forced: FORCED }, { + isFrozen: function isFrozen(it) { + if (!isObject(it)) return true; + if (ARRAY_BUFFER_NON_EXTENSIBLE && classof(it) === 'ArrayBuffer') return true; + return $isFrozen ? $isFrozen(it) : false; + } + }); + return es_object_isFrozen; +} + +var es_object_isSealed = {}; + +var hasRequiredEs_object_isSealed; + +function requireEs_object_isSealed () { + if (hasRequiredEs_object_isSealed) return es_object_isSealed; + hasRequiredEs_object_isSealed = 1; + var $ = require_export(); + var fails = requireFails(); + var isObject = requireIsObject(); + var classof = requireClassofRaw(); + var ARRAY_BUFFER_NON_EXTENSIBLE = requireArrayBufferNonExtensible(); + + // eslint-disable-next-line es/no-object-issealed -- safe + var $isSealed = Object.isSealed; + + var FORCED = ARRAY_BUFFER_NON_EXTENSIBLE || fails(function () { }); + + // `Object.isSealed` method + // https://tc39.es/ecma262/#sec-object.issealed + $({ target: 'Object', stat: true, forced: FORCED }, { + isSealed: function isSealed(it) { + if (!isObject(it)) return true; + if (ARRAY_BUFFER_NON_EXTENSIBLE && classof(it) === 'ArrayBuffer') return true; + return $isSealed ? $isSealed(it) : false; + } + }); + return es_object_isSealed; +} + +var es_object_keys = {}; + +var hasRequiredEs_object_keys; + +function requireEs_object_keys () { + if (hasRequiredEs_object_keys) return es_object_keys; + hasRequiredEs_object_keys = 1; + var $ = require_export(); + var toObject = requireToObject(); + var nativeKeys = requireObjectKeys(); + var fails = requireFails(); + + var FAILS_ON_PRIMITIVES = fails(function () { nativeKeys(1); }); + + // `Object.keys` method + // https://tc39.es/ecma262/#sec-object.keys + $({ target: 'Object', stat: true, forced: FAILS_ON_PRIMITIVES }, { + keys: function keys(it) { + return nativeKeys(toObject(it)); + } + }); + return es_object_keys; +} + +var es_object_lookupGetter = {}; + +var hasRequiredEs_object_lookupGetter; + +function requireEs_object_lookupGetter () { + if (hasRequiredEs_object_lookupGetter) return es_object_lookupGetter; + hasRequiredEs_object_lookupGetter = 1; + var $ = require_export(); + var DESCRIPTORS = requireDescriptors(); + var FORCED = requireObjectPrototypeAccessorsForced(); + var toObject = requireToObject(); + var toPropertyKey = requireToPropertyKey(); + var getPrototypeOf = requireObjectGetPrototypeOf(); + var getOwnPropertyDescriptor = requireObjectGetOwnPropertyDescriptor().f; + + // `Object.prototype.__lookupGetter__` method + // https://tc39.es/ecma262/#sec-object.prototype.__lookupGetter__ + if (DESCRIPTORS) { + $({ target: 'Object', proto: true, forced: FORCED }, { + __lookupGetter__: function __lookupGetter__(P) { + var O = toObject(this); + var key = toPropertyKey(P); + var desc; + do { + if (desc = getOwnPropertyDescriptor(O, key)) return desc.get; + } while (O = getPrototypeOf(O)); + } + }); + } + return es_object_lookupGetter; +} + +var es_object_lookupSetter = {}; + +var hasRequiredEs_object_lookupSetter; + +function requireEs_object_lookupSetter () { + if (hasRequiredEs_object_lookupSetter) return es_object_lookupSetter; + hasRequiredEs_object_lookupSetter = 1; + var $ = require_export(); + var DESCRIPTORS = requireDescriptors(); + var FORCED = requireObjectPrototypeAccessorsForced(); + var toObject = requireToObject(); + var toPropertyKey = requireToPropertyKey(); + var getPrototypeOf = requireObjectGetPrototypeOf(); + var getOwnPropertyDescriptor = requireObjectGetOwnPropertyDescriptor().f; + + // `Object.prototype.__lookupSetter__` method + // https://tc39.es/ecma262/#sec-object.prototype.__lookupSetter__ + if (DESCRIPTORS) { + $({ target: 'Object', proto: true, forced: FORCED }, { + __lookupSetter__: function __lookupSetter__(P) { + var O = toObject(this); + var key = toPropertyKey(P); + var desc; + do { + if (desc = getOwnPropertyDescriptor(O, key)) return desc.set; + } while (O = getPrototypeOf(O)); + } + }); + } + return es_object_lookupSetter; +} + +var es_object_preventExtensions = {}; + +var hasRequiredEs_object_preventExtensions; + +function requireEs_object_preventExtensions () { + if (hasRequiredEs_object_preventExtensions) return es_object_preventExtensions; + hasRequiredEs_object_preventExtensions = 1; + var $ = require_export(); + var isObject = requireIsObject(); + var onFreeze = requireInternalMetadata().onFreeze; + var FREEZING = requireFreezing(); + var fails = requireFails(); + + // eslint-disable-next-line es/no-object-preventextensions -- safe + var $preventExtensions = Object.preventExtensions; + var FAILS_ON_PRIMITIVES = fails(function () { $preventExtensions(1); }); + + // `Object.preventExtensions` method + // https://tc39.es/ecma262/#sec-object.preventextensions + $({ target: 'Object', stat: true, forced: FAILS_ON_PRIMITIVES, sham: !FREEZING }, { + preventExtensions: function preventExtensions(it) { + return $preventExtensions && isObject(it) ? $preventExtensions(onFreeze(it)) : it; + } + }); + return es_object_preventExtensions; +} + +var es_object_proto = {}; + +var hasRequiredEs_object_proto; + +function requireEs_object_proto () { + if (hasRequiredEs_object_proto) return es_object_proto; + hasRequiredEs_object_proto = 1; + var DESCRIPTORS = requireDescriptors(); + var defineBuiltInAccessor = requireDefineBuiltInAccessor(); + var isObject = requireIsObject(); + var isPossiblePrototype = requireIsPossiblePrototype(); + var toObject = requireToObject(); + var requireObjectCoercible = requireRequireObjectCoercible(); + + // eslint-disable-next-line es/no-object-getprototypeof -- safe + var getPrototypeOf = Object.getPrototypeOf; + // eslint-disable-next-line es/no-object-setprototypeof -- safe + var setPrototypeOf = Object.setPrototypeOf; + var ObjectPrototype = Object.prototype; + var PROTO = '__proto__'; + + // `Object.prototype.__proto__` accessor + // https://tc39.es/ecma262/#sec-object.prototype.__proto__ + if (DESCRIPTORS && getPrototypeOf && setPrototypeOf && !(PROTO in ObjectPrototype)) try { + defineBuiltInAccessor(ObjectPrototype, PROTO, { + configurable: true, + get: function __proto__() { + return getPrototypeOf(toObject(this)); + }, + set: function __proto__(proto) { + var O = requireObjectCoercible(this); + if (isPossiblePrototype(proto) && isObject(O)) { + setPrototypeOf(O, proto); + } + } + }); + } catch (error) { /* empty */ } + return es_object_proto; +} + +var es_object_seal = {}; + +var hasRequiredEs_object_seal; + +function requireEs_object_seal () { + if (hasRequiredEs_object_seal) return es_object_seal; + hasRequiredEs_object_seal = 1; + var $ = require_export(); + var isObject = requireIsObject(); + var onFreeze = requireInternalMetadata().onFreeze; + var FREEZING = requireFreezing(); + var fails = requireFails(); + + // eslint-disable-next-line es/no-object-seal -- safe + var $seal = Object.seal; + var FAILS_ON_PRIMITIVES = fails(function () { $seal(1); }); + + // `Object.seal` method + // https://tc39.es/ecma262/#sec-object.seal + $({ target: 'Object', stat: true, forced: FAILS_ON_PRIMITIVES, sham: !FREEZING }, { + seal: function seal(it) { + return $seal && isObject(it) ? $seal(onFreeze(it)) : it; + } + }); + return es_object_seal; +} + +var es_object_setPrototypeOf = {}; + +var hasRequiredEs_object_setPrototypeOf; + +function requireEs_object_setPrototypeOf () { + if (hasRequiredEs_object_setPrototypeOf) return es_object_setPrototypeOf; + hasRequiredEs_object_setPrototypeOf = 1; + var $ = require_export(); + var setPrototypeOf = requireObjectSetPrototypeOf(); + + // `Object.setPrototypeOf` method + // https://tc39.es/ecma262/#sec-object.setprototypeof + $({ target: 'Object', stat: true }, { + setPrototypeOf: setPrototypeOf + }); + return es_object_setPrototypeOf; +} + +var es_object_toString = {}; + +var objectToString; +var hasRequiredObjectToString; + +function requireObjectToString () { + if (hasRequiredObjectToString) return objectToString; + hasRequiredObjectToString = 1; + var TO_STRING_TAG_SUPPORT = requireToStringTagSupport(); + var classof = requireClassof(); + + // `Object.prototype.toString` method implementation + // https://tc39.es/ecma262/#sec-object.prototype.tostring + objectToString = TO_STRING_TAG_SUPPORT ? {}.toString : function toString() { + return '[object ' + classof(this) + ']'; + }; + return objectToString; +} + +var hasRequiredEs_object_toString; + +function requireEs_object_toString () { + if (hasRequiredEs_object_toString) return es_object_toString; + hasRequiredEs_object_toString = 1; + var TO_STRING_TAG_SUPPORT = requireToStringTagSupport(); + var defineBuiltIn = requireDefineBuiltIn(); + var toString = requireObjectToString(); + + // `Object.prototype.toString` method + // https://tc39.es/ecma262/#sec-object.prototype.tostring + if (!TO_STRING_TAG_SUPPORT) { + defineBuiltIn(Object.prototype, 'toString', toString, { unsafe: true }); + } + return es_object_toString; +} + +var es_object_values = {}; + +var hasRequiredEs_object_values; + +function requireEs_object_values () { + if (hasRequiredEs_object_values) return es_object_values; + hasRequiredEs_object_values = 1; + var $ = require_export(); + var $values = requireObjectToArray().values; + + // `Object.values` method + // https://tc39.es/ecma262/#sec-object.values + $({ target: 'Object', stat: true }, { + values: function values(O) { + return $values(O); + } + }); + return es_object_values; +} + +var es_parseFloat = {}; + +var hasRequiredEs_parseFloat; + +function requireEs_parseFloat () { + if (hasRequiredEs_parseFloat) return es_parseFloat; + hasRequiredEs_parseFloat = 1; + var $ = require_export(); + var $parseFloat = requireNumberParseFloat(); + + // `parseFloat` method + // https://tc39.es/ecma262/#sec-parsefloat-string + $({ global: true, forced: parseFloat !== $parseFloat }, { + parseFloat: $parseFloat + }); + return es_parseFloat; +} + +var es_parseInt = {}; + +var hasRequiredEs_parseInt; + +function requireEs_parseInt () { + if (hasRequiredEs_parseInt) return es_parseInt; + hasRequiredEs_parseInt = 1; + var $ = require_export(); + var $parseInt = requireNumberParseInt(); + + // `parseInt` method + // https://tc39.es/ecma262/#sec-parseint-string-radix + $({ global: true, forced: parseInt !== $parseInt }, { + parseInt: $parseInt + }); + return es_parseInt; +} + +var es_promise = {}; + +var es_promise_constructor = {}; + +var validateArgumentsLength; +var hasRequiredValidateArgumentsLength; + +function requireValidateArgumentsLength () { + if (hasRequiredValidateArgumentsLength) return validateArgumentsLength; + hasRequiredValidateArgumentsLength = 1; + var $TypeError = TypeError; + + validateArgumentsLength = function (passed, required) { + if (passed < required) throw new $TypeError('Not enough arguments'); + return passed; + }; + return validateArgumentsLength; +} + +var environmentIsIos; +var hasRequiredEnvironmentIsIos; + +function requireEnvironmentIsIos () { + if (hasRequiredEnvironmentIsIos) return environmentIsIos; + hasRequiredEnvironmentIsIos = 1; + var userAgent = requireEnvironmentUserAgent(); + + // eslint-disable-next-line redos/no-vulnerable -- safe + environmentIsIos = /(?:ipad|iphone|ipod).*applewebkit/i.test(userAgent); + return environmentIsIos; +} + +var task; +var hasRequiredTask; + +function requireTask () { + if (hasRequiredTask) return task; + hasRequiredTask = 1; + var globalThis = requireGlobalThis(); + var apply = requireFunctionApply(); + var bind = requireFunctionBindContext(); + var isCallable = requireIsCallable(); + var hasOwn = requireHasOwnProperty(); + var fails = requireFails(); + var html = requireHtml(); + var arraySlice = requireArraySlice(); + var createElement = requireDocumentCreateElement(); + var validateArgumentsLength = requireValidateArgumentsLength(); + var IS_IOS = requireEnvironmentIsIos(); + var IS_NODE = requireEnvironmentIsNode(); + + var set = globalThis.setImmediate; + var clear = globalThis.clearImmediate; + var process = globalThis.process; + var Dispatch = globalThis.Dispatch; + var Function = globalThis.Function; + var MessageChannel = globalThis.MessageChannel; + var String = globalThis.String; + var counter = 0; + var queue = {}; + var ONREADYSTATECHANGE = 'onreadystatechange'; + var $location, defer, channel, port; + + fails(function () { + // Deno throws a ReferenceError on `location` access without `--location` flag + $location = globalThis.location; + }); + + var run = function (id) { + if (hasOwn(queue, id)) { + var fn = queue[id]; + delete queue[id]; + fn(); + } + }; + + var runner = function (id) { + return function () { + run(id); + }; + }; + + var eventListener = function (event) { + run(event.data); + }; + + var globalPostMessageDefer = function (id) { + // old engines have not location.origin + globalThis.postMessage(String(id), $location.protocol + '//' + $location.host); + }; + + // Node.js 0.9+ & IE10+ has setImmediate, otherwise: + if (!set || !clear) { + set = function setImmediate(handler) { + validateArgumentsLength(arguments.length, 1); + var fn = isCallable(handler) ? handler : Function(handler); + var args = arraySlice(arguments, 1); + queue[++counter] = function () { + apply(fn, undefined, args); + }; + defer(counter); + return counter; + }; + clear = function clearImmediate(id) { + delete queue[id]; + }; + // Node.js 0.8- + if (IS_NODE) { + defer = function (id) { + process.nextTick(runner(id)); + }; + // Sphere (JS game engine) Dispatch API + } else if (Dispatch && Dispatch.now) { + defer = function (id) { + Dispatch.now(runner(id)); + }; + // Browsers with MessageChannel, includes WebWorkers + // except iOS - https://github.com/zloirock/core-js/issues/624 + } else if (MessageChannel && !IS_IOS) { + channel = new MessageChannel(); + port = channel.port2; + channel.port1.onmessage = eventListener; + defer = bind(port.postMessage, port); + // Browsers with postMessage, skip WebWorkers + // IE8 has postMessage, but it's sync & typeof its postMessage is 'object' + } else if ( + globalThis.addEventListener && + isCallable(globalThis.postMessage) && + !globalThis.importScripts && + $location && $location.protocol !== 'file:' && + !fails(globalPostMessageDefer) + ) { + defer = globalPostMessageDefer; + globalThis.addEventListener('message', eventListener, false); + // IE8- + } else if (ONREADYSTATECHANGE in createElement('script')) { + defer = function (id) { + html.appendChild(createElement('script'))[ONREADYSTATECHANGE] = function () { + html.removeChild(this); + run(id); + }; + }; + // Rest old browsers + } else { + defer = function (id) { + setTimeout(runner(id), 0); + }; + } + } + + task = { + set: set, + clear: clear + }; + return task; +} + +var safeGetBuiltIn; +var hasRequiredSafeGetBuiltIn; + +function requireSafeGetBuiltIn () { + if (hasRequiredSafeGetBuiltIn) return safeGetBuiltIn; + hasRequiredSafeGetBuiltIn = 1; + var globalThis = requireGlobalThis(); + var DESCRIPTORS = requireDescriptors(); + + // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe + var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; + + // Avoid NodeJS experimental warning + safeGetBuiltIn = function (name) { + if (!DESCRIPTORS) return globalThis[name]; + var descriptor = getOwnPropertyDescriptor(globalThis, name); + return descriptor && descriptor.value; + }; + return safeGetBuiltIn; +} + +var queue; +var hasRequiredQueue; + +function requireQueue () { + if (hasRequiredQueue) return queue; + hasRequiredQueue = 1; + var Queue = function () { + this.head = null; + this.tail = null; + }; + + Queue.prototype = { + add: function (item) { + var entry = { item: item, next: null }; + var tail = this.tail; + if (tail) tail.next = entry; + else this.head = entry; + this.tail = entry; + }, + get: function () { + var entry = this.head; + if (entry) { + var next = this.head = entry.next; + if (next === null) this.tail = null; + return entry.item; + } + } + }; + + queue = Queue; + return queue; +} + +var environmentIsIosPebble; +var hasRequiredEnvironmentIsIosPebble; + +function requireEnvironmentIsIosPebble () { + if (hasRequiredEnvironmentIsIosPebble) return environmentIsIosPebble; + hasRequiredEnvironmentIsIosPebble = 1; + var userAgent = requireEnvironmentUserAgent(); + + environmentIsIosPebble = /ipad|iphone|ipod/i.test(userAgent) && typeof Pebble != 'undefined'; + return environmentIsIosPebble; +} + +var environmentIsWebosWebkit; +var hasRequiredEnvironmentIsWebosWebkit; + +function requireEnvironmentIsWebosWebkit () { + if (hasRequiredEnvironmentIsWebosWebkit) return environmentIsWebosWebkit; + hasRequiredEnvironmentIsWebosWebkit = 1; + var userAgent = requireEnvironmentUserAgent(); + + environmentIsWebosWebkit = /web0s(?!.*chrome)/i.test(userAgent); + return environmentIsWebosWebkit; +} + +var microtask_1; +var hasRequiredMicrotask; + +function requireMicrotask () { + if (hasRequiredMicrotask) return microtask_1; + hasRequiredMicrotask = 1; + var globalThis = requireGlobalThis(); + var safeGetBuiltIn = requireSafeGetBuiltIn(); + var bind = requireFunctionBindContext(); + var macrotask = requireTask().set; + var Queue = requireQueue(); + var IS_IOS = requireEnvironmentIsIos(); + var IS_IOS_PEBBLE = requireEnvironmentIsIosPebble(); + var IS_WEBOS_WEBKIT = requireEnvironmentIsWebosWebkit(); + var IS_NODE = requireEnvironmentIsNode(); + + var MutationObserver = globalThis.MutationObserver || globalThis.WebKitMutationObserver; + var document = globalThis.document; + var process = globalThis.process; + var Promise = globalThis.Promise; + var microtask = safeGetBuiltIn('queueMicrotask'); + var notify, toggle, node, promise, then; + + // modern engines have queueMicrotask method + if (!microtask) { + var queue = new Queue(); + + var flush = function () { + var parent, fn; + if (IS_NODE && (parent = process.domain)) parent.exit(); + while (fn = queue.get()) try { + fn(); + } catch (error) { + if (queue.head) notify(); + throw error; + } + if (parent) parent.enter(); + }; + + // browsers with MutationObserver, except iOS - https://github.com/zloirock/core-js/issues/339 + // also except WebOS Webkit https://github.com/zloirock/core-js/issues/898 + if (!IS_IOS && !IS_NODE && !IS_WEBOS_WEBKIT && MutationObserver && document) { + toggle = true; + node = document.createTextNode(''); + new MutationObserver(flush).observe(node, { characterData: true }); + notify = function () { + node.data = toggle = !toggle; + }; + // environments with maybe non-completely correct, but existent Promise + } else if (!IS_IOS_PEBBLE && Promise && Promise.resolve) { + // Promise.resolve without an argument throws an error in LG WebOS 2 + promise = Promise.resolve(undefined); + // workaround of WebKit ~ iOS Safari 10.1 bug + promise.constructor = Promise; + then = bind(promise.then, promise); + notify = function () { + then(flush); + }; + // Node.js without promises + } else if (IS_NODE) { + notify = function () { + process.nextTick(flush); + }; + // for other environments - macrotask based on: + // - setImmediate + // - MessageChannel + // - window.postMessage + // - onreadystatechange + // - setTimeout + } else { + // `webpack` dev server bug on IE global methods - use bind(fn, global) + macrotask = bind(macrotask, globalThis); + notify = function () { + macrotask(flush); + }; + } + + microtask = function (fn) { + if (!queue.head) notify(); + queue.add(fn); + }; + } + + microtask_1 = microtask; + return microtask_1; +} + +var hostReportErrors; +var hasRequiredHostReportErrors; + +function requireHostReportErrors () { + if (hasRequiredHostReportErrors) return hostReportErrors; + hasRequiredHostReportErrors = 1; + hostReportErrors = function (a, b) { + try { + // eslint-disable-next-line no-console -- safe + arguments.length === 1 ? console.error(a) : console.error(a, b); + } catch (error) { /* empty */ } + }; + return hostReportErrors; +} + +var perform; +var hasRequiredPerform; + +function requirePerform () { + if (hasRequiredPerform) return perform; + hasRequiredPerform = 1; + perform = function (exec) { + try { + return { error: false, value: exec() }; + } catch (error) { + return { error: true, value: error }; + } + }; + return perform; +} + +var promiseNativeConstructor; +var hasRequiredPromiseNativeConstructor; + +function requirePromiseNativeConstructor () { + if (hasRequiredPromiseNativeConstructor) return promiseNativeConstructor; + hasRequiredPromiseNativeConstructor = 1; + var globalThis = requireGlobalThis(); + + promiseNativeConstructor = globalThis.Promise; + return promiseNativeConstructor; +} + +var promiseConstructorDetection; +var hasRequiredPromiseConstructorDetection; + +function requirePromiseConstructorDetection () { + if (hasRequiredPromiseConstructorDetection) return promiseConstructorDetection; + hasRequiredPromiseConstructorDetection = 1; + var globalThis = requireGlobalThis(); + var NativePromiseConstructor = requirePromiseNativeConstructor(); + var isCallable = requireIsCallable(); + var isForced = requireIsForced(); + var inspectSource = requireInspectSource(); + var wellKnownSymbol = requireWellKnownSymbol(); + var ENVIRONMENT = requireEnvironment(); + var IS_PURE = requireIsPure(); + var V8_VERSION = requireEnvironmentV8Version(); + + var NativePromisePrototype = NativePromiseConstructor && NativePromiseConstructor.prototype; + var SPECIES = wellKnownSymbol('species'); + var SUBCLASSING = false; + var NATIVE_PROMISE_REJECTION_EVENT = isCallable(globalThis.PromiseRejectionEvent); + + var FORCED_PROMISE_CONSTRUCTOR = isForced('Promise', function () { + var PROMISE_CONSTRUCTOR_SOURCE = inspectSource(NativePromiseConstructor); + var GLOBAL_CORE_JS_PROMISE = PROMISE_CONSTRUCTOR_SOURCE !== String(NativePromiseConstructor); + // V8 6.6 (Node 10 and Chrome 66) have a bug with resolving custom thenables + // https://bugs.chromium.org/p/chromium/issues/detail?id=830565 + // We can't detect it synchronously, so just check versions + if (!GLOBAL_CORE_JS_PROMISE && V8_VERSION === 66) return true; + // We need Promise#{ catch, finally } in the pure version for preventing prototype pollution + if (IS_PURE && !(NativePromisePrototype['catch'] && NativePromisePrototype['finally'])) return true; + // We can't use @@species feature detection in V8 since it causes + // deoptimization and performance degradation + // https://github.com/zloirock/core-js/issues/679 + if (!V8_VERSION || V8_VERSION < 51 || !/native code/.test(PROMISE_CONSTRUCTOR_SOURCE)) { + // Detect correctness of subclassing with @@species support + var promise = new NativePromiseConstructor(function (resolve) { resolve(1); }); + var FakePromise = function (exec) { + exec(function () { /* empty */ }, function () { /* empty */ }); + }; + var constructor = promise.constructor = {}; + constructor[SPECIES] = FakePromise; + SUBCLASSING = promise.then(function () { /* empty */ }) instanceof FakePromise; + if (!SUBCLASSING) return true; + // Unhandled rejections tracking support, NodeJS Promise without it fails @@species test + } return !GLOBAL_CORE_JS_PROMISE && (ENVIRONMENT === 'BROWSER' || ENVIRONMENT === 'DENO') && !NATIVE_PROMISE_REJECTION_EVENT; + }); + + promiseConstructorDetection = { + CONSTRUCTOR: FORCED_PROMISE_CONSTRUCTOR, + REJECTION_EVENT: NATIVE_PROMISE_REJECTION_EVENT, + SUBCLASSING: SUBCLASSING + }; + return promiseConstructorDetection; +} + +var newPromiseCapability = {}; + +var hasRequiredNewPromiseCapability; + +function requireNewPromiseCapability () { + if (hasRequiredNewPromiseCapability) return newPromiseCapability; + hasRequiredNewPromiseCapability = 1; + var aCallable = requireACallable(); + + var $TypeError = TypeError; + + var PromiseCapability = function (C) { + var resolve, reject; + this.promise = new C(function ($$resolve, $$reject) { + if (resolve !== undefined || reject !== undefined) throw new $TypeError('Bad Promise constructor'); + resolve = $$resolve; + reject = $$reject; + }); + this.resolve = aCallable(resolve); + this.reject = aCallable(reject); + }; + + // `NewPromiseCapability` abstract operation + // https://tc39.es/ecma262/#sec-newpromisecapability + newPromiseCapability.f = function (C) { + return new PromiseCapability(C); + }; + return newPromiseCapability; +} + +var hasRequiredEs_promise_constructor; + +function requireEs_promise_constructor () { + if (hasRequiredEs_promise_constructor) return es_promise_constructor; + hasRequiredEs_promise_constructor = 1; + var $ = require_export(); + var IS_PURE = requireIsPure(); + var IS_NODE = requireEnvironmentIsNode(); + var globalThis = requireGlobalThis(); + var call = requireFunctionCall(); + var defineBuiltIn = requireDefineBuiltIn(); + var setPrototypeOf = requireObjectSetPrototypeOf(); + var setToStringTag = requireSetToStringTag(); + var setSpecies = requireSetSpecies(); + var aCallable = requireACallable(); + var isCallable = requireIsCallable(); + var isObject = requireIsObject(); + var anInstance = requireAnInstance(); + var speciesConstructor = requireSpeciesConstructor(); + var task = requireTask().set; + var microtask = requireMicrotask(); + var hostReportErrors = requireHostReportErrors(); + var perform = requirePerform(); + var Queue = requireQueue(); + var InternalStateModule = requireInternalState(); + var NativePromiseConstructor = requirePromiseNativeConstructor(); + var PromiseConstructorDetection = requirePromiseConstructorDetection(); + var newPromiseCapabilityModule = requireNewPromiseCapability(); + + var PROMISE = 'Promise'; + var FORCED_PROMISE_CONSTRUCTOR = PromiseConstructorDetection.CONSTRUCTOR; + var NATIVE_PROMISE_REJECTION_EVENT = PromiseConstructorDetection.REJECTION_EVENT; + var NATIVE_PROMISE_SUBCLASSING = PromiseConstructorDetection.SUBCLASSING; + var getInternalPromiseState = InternalStateModule.getterFor(PROMISE); + var setInternalState = InternalStateModule.set; + var NativePromisePrototype = NativePromiseConstructor && NativePromiseConstructor.prototype; + var PromiseConstructor = NativePromiseConstructor; + var PromisePrototype = NativePromisePrototype; + var TypeError = globalThis.TypeError; + var document = globalThis.document; + var process = globalThis.process; + var newPromiseCapability = newPromiseCapabilityModule.f; + var newGenericPromiseCapability = newPromiseCapability; + + var DISPATCH_EVENT = !!(document && document.createEvent && globalThis.dispatchEvent); + var UNHANDLED_REJECTION = 'unhandledrejection'; + var REJECTION_HANDLED = 'rejectionhandled'; + var PENDING = 0; + var FULFILLED = 1; + var REJECTED = 2; + var HANDLED = 1; + var UNHANDLED = 2; + + var Internal, OwnPromiseCapability, PromiseWrapper, nativeThen; + + // helpers + var isThenable = function (it) { + var then; + return isObject(it) && isCallable(then = it.then) ? then : false; + }; + + var callReaction = function (reaction, state) { + var value = state.value; + var ok = state.state === FULFILLED; + var handler = ok ? reaction.ok : reaction.fail; + var resolve = reaction.resolve; + var reject = reaction.reject; + var domain = reaction.domain; + var result, then, exited; + try { + if (handler) { + if (!ok) { + if (state.rejection === UNHANDLED) onHandleUnhandled(state); + state.rejection = HANDLED; + } + if (handler === true) result = value; + else { + if (domain) domain.enter(); + result = handler(value); // can throw + if (domain) { + domain.exit(); + exited = true; + } + } + if (result === reaction.promise) { + reject(new TypeError('Promise-chain cycle')); + } else if (then = isThenable(result)) { + call(then, result, resolve, reject); + } else resolve(result); + } else reject(value); + } catch (error) { + if (domain && !exited) domain.exit(); + reject(error); + } + }; + + var notify = function (state, isReject) { + if (state.notified) return; + state.notified = true; + microtask(function () { + var reactions = state.reactions; + var reaction; + while (reaction = reactions.get()) { + callReaction(reaction, state); + } + state.notified = false; + if (isReject && !state.rejection) onUnhandled(state); + }); + }; + + var dispatchEvent = function (name, promise, reason) { + var event, handler; + if (DISPATCH_EVENT) { + event = document.createEvent('Event'); + event.promise = promise; + event.reason = reason; + event.initEvent(name, false, true); + globalThis.dispatchEvent(event); + } else event = { promise: promise, reason: reason }; + if (!NATIVE_PROMISE_REJECTION_EVENT && (handler = globalThis['on' + name])) handler(event); + else if (name === UNHANDLED_REJECTION) hostReportErrors('Unhandled promise rejection', reason); + }; + + var onUnhandled = function (state) { + call(task, globalThis, function () { + var promise = state.facade; + var value = state.value; + var IS_UNHANDLED = isUnhandled(state); + var result; + if (IS_UNHANDLED) { + result = perform(function () { + if (IS_NODE) { + process.emit('unhandledRejection', value, promise); + } else dispatchEvent(UNHANDLED_REJECTION, promise, value); + }); + // Browsers should not trigger `rejectionHandled` event if it was handled here, NodeJS - should + state.rejection = IS_NODE || isUnhandled(state) ? UNHANDLED : HANDLED; + if (result.error) throw result.value; + } + }); + }; + + var isUnhandled = function (state) { + return state.rejection !== HANDLED && !state.parent; + }; + + var onHandleUnhandled = function (state) { + call(task, globalThis, function () { + var promise = state.facade; + if (IS_NODE) { + process.emit('rejectionHandled', promise); + } else dispatchEvent(REJECTION_HANDLED, promise, state.value); + }); + }; + + var bind = function (fn, state, unwrap) { + return function (value) { + fn(state, value, unwrap); + }; + }; + + var internalReject = function (state, value, unwrap) { + if (state.done) return; + state.done = true; + if (unwrap) state = unwrap; + state.value = value; + state.state = REJECTED; + notify(state, true); + }; + + var internalResolve = function (state, value, unwrap) { + if (state.done) return; + state.done = true; + if (unwrap) state = unwrap; + try { + if (state.facade === value) throw new TypeError("Promise can't be resolved itself"); + var then = isThenable(value); + if (then) { + microtask(function () { + var wrapper = { done: false }; + try { + call(then, value, + bind(internalResolve, wrapper, state), + bind(internalReject, wrapper, state) + ); + } catch (error) { + internalReject(wrapper, error, state); + } + }); + } else { + state.value = value; + state.state = FULFILLED; + notify(state, false); + } + } catch (error) { + internalReject({ done: false }, error, state); + } + }; + + // constructor polyfill + if (FORCED_PROMISE_CONSTRUCTOR) { + // 25.4.3.1 Promise(executor) + PromiseConstructor = function Promise(executor) { + anInstance(this, PromisePrototype); + aCallable(executor); + call(Internal, this); + var state = getInternalPromiseState(this); + try { + executor(bind(internalResolve, state), bind(internalReject, state)); + } catch (error) { + internalReject(state, error); + } + }; + + PromisePrototype = PromiseConstructor.prototype; + + // eslint-disable-next-line no-unused-vars -- required for `.length` + Internal = function Promise(executor) { + setInternalState(this, { + type: PROMISE, + done: false, + notified: false, + parent: false, + reactions: new Queue(), + rejection: false, + state: PENDING, + value: null + }); + }; + + // `Promise.prototype.then` method + // https://tc39.es/ecma262/#sec-promise.prototype.then + Internal.prototype = defineBuiltIn(PromisePrototype, 'then', function then(onFulfilled, onRejected) { + var state = getInternalPromiseState(this); + var reaction = newPromiseCapability(speciesConstructor(this, PromiseConstructor)); + state.parent = true; + reaction.ok = isCallable(onFulfilled) ? onFulfilled : true; + reaction.fail = isCallable(onRejected) && onRejected; + reaction.domain = IS_NODE ? process.domain : undefined; + if (state.state === PENDING) state.reactions.add(reaction); + else microtask(function () { + callReaction(reaction, state); + }); + return reaction.promise; + }); + + OwnPromiseCapability = function () { + var promise = new Internal(); + var state = getInternalPromiseState(promise); + this.promise = promise; + this.resolve = bind(internalResolve, state); + this.reject = bind(internalReject, state); + }; + + newPromiseCapabilityModule.f = newPromiseCapability = function (C) { + return C === PromiseConstructor || C === PromiseWrapper + ? new OwnPromiseCapability(C) + : newGenericPromiseCapability(C); + }; + + if (!IS_PURE && isCallable(NativePromiseConstructor) && NativePromisePrototype !== Object.prototype) { + nativeThen = NativePromisePrototype.then; + + if (!NATIVE_PROMISE_SUBCLASSING) { + // make `Promise#then` return a polyfilled `Promise` for native promise-based APIs + defineBuiltIn(NativePromisePrototype, 'then', function then(onFulfilled, onRejected) { + var that = this; + return new PromiseConstructor(function (resolve, reject) { + call(nativeThen, that, resolve, reject); + }).then(onFulfilled, onRejected); + // https://github.com/zloirock/core-js/issues/640 + }, { unsafe: true }); + } + + // make `.constructor === Promise` work for native promise-based APIs + try { + delete NativePromisePrototype.constructor; + } catch (error) { /* empty */ } + + // make `instanceof Promise` work for native promise-based APIs + if (setPrototypeOf) { + setPrototypeOf(NativePromisePrototype, PromisePrototype); + } + } + } + + $({ global: true, constructor: true, wrap: true, forced: FORCED_PROMISE_CONSTRUCTOR }, { + Promise: PromiseConstructor + }); + + setToStringTag(PromiseConstructor, PROMISE, false, true); + setSpecies(PROMISE); + return es_promise_constructor; +} + +var es_promise_all = {}; + +var promiseStaticsIncorrectIteration; +var hasRequiredPromiseStaticsIncorrectIteration; + +function requirePromiseStaticsIncorrectIteration () { + if (hasRequiredPromiseStaticsIncorrectIteration) return promiseStaticsIncorrectIteration; + hasRequiredPromiseStaticsIncorrectIteration = 1; + var NativePromiseConstructor = requirePromiseNativeConstructor(); + var checkCorrectnessOfIteration = requireCheckCorrectnessOfIteration(); + var FORCED_PROMISE_CONSTRUCTOR = requirePromiseConstructorDetection().CONSTRUCTOR; + + promiseStaticsIncorrectIteration = FORCED_PROMISE_CONSTRUCTOR || !checkCorrectnessOfIteration(function (iterable) { + NativePromiseConstructor.all(iterable).then(undefined, function () { /* empty */ }); + }); + return promiseStaticsIncorrectIteration; +} + +var hasRequiredEs_promise_all; + +function requireEs_promise_all () { + if (hasRequiredEs_promise_all) return es_promise_all; + hasRequiredEs_promise_all = 1; + var $ = require_export(); + var call = requireFunctionCall(); + var aCallable = requireACallable(); + var newPromiseCapabilityModule = requireNewPromiseCapability(); + var perform = requirePerform(); + var iterate = requireIterate(); + var PROMISE_STATICS_INCORRECT_ITERATION = requirePromiseStaticsIncorrectIteration(); + + // `Promise.all` method + // https://tc39.es/ecma262/#sec-promise.all + $({ target: 'Promise', stat: true, forced: PROMISE_STATICS_INCORRECT_ITERATION }, { + all: function all(iterable) { + var C = this; + var capability = newPromiseCapabilityModule.f(C); + var resolve = capability.resolve; + var reject = capability.reject; + var result = perform(function () { + var $promiseResolve = aCallable(C.resolve); + var values = []; + var counter = 0; + var remaining = 1; + iterate(iterable, function (promise) { + var index = counter++; + var alreadyCalled = false; + remaining++; + call($promiseResolve, C, promise).then(function (value) { + if (alreadyCalled) return; + alreadyCalled = true; + values[index] = value; + --remaining || resolve(values); + }, reject); + }); + --remaining || resolve(values); + }); + if (result.error) reject(result.value); + return capability.promise; + } + }); + return es_promise_all; +} + +var es_promise_catch = {}; + +var hasRequiredEs_promise_catch; + +function requireEs_promise_catch () { + if (hasRequiredEs_promise_catch) return es_promise_catch; + hasRequiredEs_promise_catch = 1; + var $ = require_export(); + var IS_PURE = requireIsPure(); + var FORCED_PROMISE_CONSTRUCTOR = requirePromiseConstructorDetection().CONSTRUCTOR; + var NativePromiseConstructor = requirePromiseNativeConstructor(); + var getBuiltIn = requireGetBuiltIn(); + var isCallable = requireIsCallable(); + var defineBuiltIn = requireDefineBuiltIn(); + + var NativePromisePrototype = NativePromiseConstructor && NativePromiseConstructor.prototype; + + // `Promise.prototype.catch` method + // https://tc39.es/ecma262/#sec-promise.prototype.catch + $({ target: 'Promise', proto: true, forced: FORCED_PROMISE_CONSTRUCTOR, real: true }, { + 'catch': function (onRejected) { + return this.then(undefined, onRejected); + } + }); + + // makes sure that native promise-based APIs `Promise#catch` properly works with patched `Promise#then` + if (!IS_PURE && isCallable(NativePromiseConstructor)) { + var method = getBuiltIn('Promise').prototype['catch']; + if (NativePromisePrototype['catch'] !== method) { + defineBuiltIn(NativePromisePrototype, 'catch', method, { unsafe: true }); + } + } + return es_promise_catch; +} + +var es_promise_race = {}; + +var hasRequiredEs_promise_race; + +function requireEs_promise_race () { + if (hasRequiredEs_promise_race) return es_promise_race; + hasRequiredEs_promise_race = 1; + var $ = require_export(); + var call = requireFunctionCall(); + var aCallable = requireACallable(); + var newPromiseCapabilityModule = requireNewPromiseCapability(); + var perform = requirePerform(); + var iterate = requireIterate(); + var PROMISE_STATICS_INCORRECT_ITERATION = requirePromiseStaticsIncorrectIteration(); + + // `Promise.race` method + // https://tc39.es/ecma262/#sec-promise.race + $({ target: 'Promise', stat: true, forced: PROMISE_STATICS_INCORRECT_ITERATION }, { + race: function race(iterable) { + var C = this; + var capability = newPromiseCapabilityModule.f(C); + var reject = capability.reject; + var result = perform(function () { + var $promiseResolve = aCallable(C.resolve); + iterate(iterable, function (promise) { + call($promiseResolve, C, promise).then(capability.resolve, reject); + }); + }); + if (result.error) reject(result.value); + return capability.promise; + } + }); + return es_promise_race; +} + +var es_promise_reject = {}; + +var hasRequiredEs_promise_reject; + +function requireEs_promise_reject () { + if (hasRequiredEs_promise_reject) return es_promise_reject; + hasRequiredEs_promise_reject = 1; + var $ = require_export(); + var newPromiseCapabilityModule = requireNewPromiseCapability(); + var FORCED_PROMISE_CONSTRUCTOR = requirePromiseConstructorDetection().CONSTRUCTOR; + + // `Promise.reject` method + // https://tc39.es/ecma262/#sec-promise.reject + $({ target: 'Promise', stat: true, forced: FORCED_PROMISE_CONSTRUCTOR }, { + reject: function reject(r) { + var capability = newPromiseCapabilityModule.f(this); + var capabilityReject = capability.reject; + capabilityReject(r); + return capability.promise; + } + }); + return es_promise_reject; +} + +var es_promise_resolve = {}; + +var promiseResolve; +var hasRequiredPromiseResolve; + +function requirePromiseResolve () { + if (hasRequiredPromiseResolve) return promiseResolve; + hasRequiredPromiseResolve = 1; + var anObject = requireAnObject(); + var isObject = requireIsObject(); + var newPromiseCapability = requireNewPromiseCapability(); + + promiseResolve = function (C, x) { + anObject(C); + if (isObject(x) && x.constructor === C) return x; + var promiseCapability = newPromiseCapability.f(C); + var resolve = promiseCapability.resolve; + resolve(x); + return promiseCapability.promise; + }; + return promiseResolve; +} + +var hasRequiredEs_promise_resolve; + +function requireEs_promise_resolve () { + if (hasRequiredEs_promise_resolve) return es_promise_resolve; + hasRequiredEs_promise_resolve = 1; + var $ = require_export(); + var getBuiltIn = requireGetBuiltIn(); + var IS_PURE = requireIsPure(); + var NativePromiseConstructor = requirePromiseNativeConstructor(); + var FORCED_PROMISE_CONSTRUCTOR = requirePromiseConstructorDetection().CONSTRUCTOR; + var promiseResolve = requirePromiseResolve(); + + var PromiseConstructorWrapper = getBuiltIn('Promise'); + var CHECK_WRAPPER = IS_PURE && !FORCED_PROMISE_CONSTRUCTOR; + + // `Promise.resolve` method + // https://tc39.es/ecma262/#sec-promise.resolve + $({ target: 'Promise', stat: true, forced: IS_PURE || FORCED_PROMISE_CONSTRUCTOR }, { + resolve: function resolve(x) { + return promiseResolve(CHECK_WRAPPER && this === PromiseConstructorWrapper ? NativePromiseConstructor : this, x); + } + }); + return es_promise_resolve; +} + +var hasRequiredEs_promise; + +function requireEs_promise () { + if (hasRequiredEs_promise) return es_promise; + hasRequiredEs_promise = 1; + // TODO: Remove this module from `core-js@4` since it's split to modules listed below + requireEs_promise_constructor(); + requireEs_promise_all(); + requireEs_promise_catch(); + requireEs_promise_race(); + requireEs_promise_reject(); + requireEs_promise_resolve(); + return es_promise; +} + +var es_promise_allSettled = {}; + +var hasRequiredEs_promise_allSettled; + +function requireEs_promise_allSettled () { + if (hasRequiredEs_promise_allSettled) return es_promise_allSettled; + hasRequiredEs_promise_allSettled = 1; + var $ = require_export(); + var call = requireFunctionCall(); + var aCallable = requireACallable(); + var newPromiseCapabilityModule = requireNewPromiseCapability(); + var perform = requirePerform(); + var iterate = requireIterate(); + var PROMISE_STATICS_INCORRECT_ITERATION = requirePromiseStaticsIncorrectIteration(); + + // `Promise.allSettled` method + // https://tc39.es/ecma262/#sec-promise.allsettled + $({ target: 'Promise', stat: true, forced: PROMISE_STATICS_INCORRECT_ITERATION }, { + allSettled: function allSettled(iterable) { + var C = this; + var capability = newPromiseCapabilityModule.f(C); + var resolve = capability.resolve; + var reject = capability.reject; + var result = perform(function () { + var promiseResolve = aCallable(C.resolve); + var values = []; + var counter = 0; + var remaining = 1; + iterate(iterable, function (promise) { + var index = counter++; + var alreadyCalled = false; + remaining++; + call(promiseResolve, C, promise).then(function (value) { + if (alreadyCalled) return; + alreadyCalled = true; + values[index] = { status: 'fulfilled', value: value }; + --remaining || resolve(values); + }, function (error) { + if (alreadyCalled) return; + alreadyCalled = true; + values[index] = { status: 'rejected', reason: error }; + --remaining || resolve(values); + }); + }); + --remaining || resolve(values); + }); + if (result.error) reject(result.value); + return capability.promise; + } + }); + return es_promise_allSettled; +} + +var es_promise_any = {}; + +var hasRequiredEs_promise_any; + +function requireEs_promise_any () { + if (hasRequiredEs_promise_any) return es_promise_any; + hasRequiredEs_promise_any = 1; + var $ = require_export(); + var call = requireFunctionCall(); + var aCallable = requireACallable(); + var getBuiltIn = requireGetBuiltIn(); + var newPromiseCapabilityModule = requireNewPromiseCapability(); + var perform = requirePerform(); + var iterate = requireIterate(); + var PROMISE_STATICS_INCORRECT_ITERATION = requirePromiseStaticsIncorrectIteration(); + + var PROMISE_ANY_ERROR = 'No one promise resolved'; + + // `Promise.any` method + // https://tc39.es/ecma262/#sec-promise.any + $({ target: 'Promise', stat: true, forced: PROMISE_STATICS_INCORRECT_ITERATION }, { + any: function any(iterable) { + var C = this; + var AggregateError = getBuiltIn('AggregateError'); + var capability = newPromiseCapabilityModule.f(C); + var resolve = capability.resolve; + var reject = capability.reject; + var result = perform(function () { + var promiseResolve = aCallable(C.resolve); + var errors = []; + var counter = 0; + var remaining = 1; + var alreadyResolved = false; + iterate(iterable, function (promise) { + var index = counter++; + var alreadyRejected = false; + remaining++; + call(promiseResolve, C, promise).then(function (value) { + if (alreadyRejected || alreadyResolved) return; + alreadyResolved = true; + resolve(value); + }, function (error) { + if (alreadyRejected || alreadyResolved) return; + alreadyRejected = true; + errors[index] = error; + --remaining || reject(new AggregateError(errors, PROMISE_ANY_ERROR)); + }); + }); + --remaining || reject(new AggregateError(errors, PROMISE_ANY_ERROR)); + }); + if (result.error) reject(result.value); + return capability.promise; + } + }); + return es_promise_any; +} + +var es_promise_finally = {}; + +var hasRequiredEs_promise_finally; + +function requireEs_promise_finally () { + if (hasRequiredEs_promise_finally) return es_promise_finally; + hasRequiredEs_promise_finally = 1; + var $ = require_export(); + var IS_PURE = requireIsPure(); + var NativePromiseConstructor = requirePromiseNativeConstructor(); + var fails = requireFails(); + var getBuiltIn = requireGetBuiltIn(); + var isCallable = requireIsCallable(); + var speciesConstructor = requireSpeciesConstructor(); + var promiseResolve = requirePromiseResolve(); + var defineBuiltIn = requireDefineBuiltIn(); + + var NativePromisePrototype = NativePromiseConstructor && NativePromiseConstructor.prototype; + + // Safari bug https://bugs.webkit.org/show_bug.cgi?id=200829 + var NON_GENERIC = !!NativePromiseConstructor && fails(function () { + // eslint-disable-next-line unicorn/no-thenable -- required for testing + NativePromisePrototype['finally'].call({ then: function () { /* empty */ } }, function () { /* empty */ }); + }); + + // `Promise.prototype.finally` method + // https://tc39.es/ecma262/#sec-promise.prototype.finally + $({ target: 'Promise', proto: true, real: true, forced: NON_GENERIC }, { + 'finally': function (onFinally) { + var C = speciesConstructor(this, getBuiltIn('Promise')); + var isFunction = isCallable(onFinally); + return this.then( + isFunction ? function (x) { + return promiseResolve(C, onFinally()).then(function () { return x; }); + } : onFinally, + isFunction ? function (e) { + return promiseResolve(C, onFinally()).then(function () { throw e; }); + } : onFinally + ); + } + }); + + // makes sure that native promise-based APIs `Promise#finally` properly works with patched `Promise#then` + if (!IS_PURE && isCallable(NativePromiseConstructor)) { + var method = getBuiltIn('Promise').prototype['finally']; + if (NativePromisePrototype['finally'] !== method) { + defineBuiltIn(NativePromisePrototype, 'finally', method, { unsafe: true }); + } + } + return es_promise_finally; +} + +var es_promise_withResolvers = {}; + +var hasRequiredEs_promise_withResolvers; + +function requireEs_promise_withResolvers () { + if (hasRequiredEs_promise_withResolvers) return es_promise_withResolvers; + hasRequiredEs_promise_withResolvers = 1; + var $ = require_export(); + var newPromiseCapabilityModule = requireNewPromiseCapability(); + + // `Promise.withResolvers` method + // https://github.com/tc39/proposal-promise-with-resolvers + $({ target: 'Promise', stat: true }, { + withResolvers: function withResolvers() { + var promiseCapability = newPromiseCapabilityModule.f(this); + return { + promise: promiseCapability.promise, + resolve: promiseCapability.resolve, + reject: promiseCapability.reject + }; + } + }); + return es_promise_withResolvers; +} + +var es_reflect_apply = {}; + +var hasRequiredEs_reflect_apply; + +function requireEs_reflect_apply () { + if (hasRequiredEs_reflect_apply) return es_reflect_apply; + hasRequiredEs_reflect_apply = 1; + var $ = require_export(); + var functionApply = requireFunctionApply(); + var aCallable = requireACallable(); + var anObject = requireAnObject(); + var fails = requireFails(); + + // MS Edge argumentsList argument is optional + var OPTIONAL_ARGUMENTS_LIST = !fails(function () { + // eslint-disable-next-line es/no-reflect -- required for testing + Reflect.apply(function () { /* empty */ }); + }); + + // `Reflect.apply` method + // https://tc39.es/ecma262/#sec-reflect.apply + $({ target: 'Reflect', stat: true, forced: OPTIONAL_ARGUMENTS_LIST }, { + apply: function apply(target, thisArgument, argumentsList) { + return functionApply(aCallable(target), thisArgument, anObject(argumentsList)); + } + }); + return es_reflect_apply; +} + +var es_reflect_construct = {}; + +var hasRequiredEs_reflect_construct; + +function requireEs_reflect_construct () { + if (hasRequiredEs_reflect_construct) return es_reflect_construct; + hasRequiredEs_reflect_construct = 1; + var $ = require_export(); + var getBuiltIn = requireGetBuiltIn(); + var apply = requireFunctionApply(); + var bind = requireFunctionBind(); + var aConstructor = requireAConstructor(); + var anObject = requireAnObject(); + var isObject = requireIsObject(); + var create = requireObjectCreate(); + var fails = requireFails(); + + var nativeConstruct = getBuiltIn('Reflect', 'construct'); + var ObjectPrototype = Object.prototype; + var push = [].push; + + // `Reflect.construct` method + // https://tc39.es/ecma262/#sec-reflect.construct + // MS Edge supports only 2 arguments and argumentsList argument is optional + // FF Nightly sets third argument as `new.target`, but does not create `this` from it + var NEW_TARGET_BUG = fails(function () { + function F() { /* empty */ } + return !(nativeConstruct(function () { /* empty */ }, [], F) instanceof F); + }); + + var ARGS_BUG = !fails(function () { + nativeConstruct(function () { /* empty */ }); + }); + + var FORCED = NEW_TARGET_BUG || ARGS_BUG; + + $({ target: 'Reflect', stat: true, forced: FORCED, sham: FORCED }, { + construct: function construct(Target, args /* , newTarget */) { + aConstructor(Target); + anObject(args); + var newTarget = arguments.length < 3 ? Target : aConstructor(arguments[2]); + if (ARGS_BUG && !NEW_TARGET_BUG) return nativeConstruct(Target, args, newTarget); + if (Target === newTarget) { + // w/o altered newTarget, optimization for 0-4 arguments + switch (args.length) { + case 0: return new Target(); + case 1: return new Target(args[0]); + case 2: return new Target(args[0], args[1]); + case 3: return new Target(args[0], args[1], args[2]); + case 4: return new Target(args[0], args[1], args[2], args[3]); + } + // w/o altered newTarget, lot of arguments case + var $args = [null]; + apply(push, $args, args); + return new (apply(bind, Target, $args))(); + } + // with altered newTarget, not support built-in constructors + var proto = newTarget.prototype; + var instance = create(isObject(proto) ? proto : ObjectPrototype); + var result = apply(Target, instance, args); + return isObject(result) ? result : instance; + } + }); + return es_reflect_construct; +} + +var es_reflect_defineProperty = {}; + +var hasRequiredEs_reflect_defineProperty; + +function requireEs_reflect_defineProperty () { + if (hasRequiredEs_reflect_defineProperty) return es_reflect_defineProperty; + hasRequiredEs_reflect_defineProperty = 1; + var $ = require_export(); + var DESCRIPTORS = requireDescriptors(); + var anObject = requireAnObject(); + var toPropertyKey = requireToPropertyKey(); + var definePropertyModule = requireObjectDefineProperty(); + var fails = requireFails(); + + // MS Edge has broken Reflect.defineProperty - throwing instead of returning false + var ERROR_INSTEAD_OF_FALSE = fails(function () { + // eslint-disable-next-line es/no-reflect -- required for testing + Reflect.defineProperty(definePropertyModule.f({}, 1, { value: 1 }), 1, { value: 2 }); + }); + + // `Reflect.defineProperty` method + // https://tc39.es/ecma262/#sec-reflect.defineproperty + $({ target: 'Reflect', stat: true, forced: ERROR_INSTEAD_OF_FALSE, sham: !DESCRIPTORS }, { + defineProperty: function defineProperty(target, propertyKey, attributes) { + anObject(target); + var key = toPropertyKey(propertyKey); + anObject(attributes); + try { + definePropertyModule.f(target, key, attributes); + return true; + } catch (error) { + return false; + } + } + }); + return es_reflect_defineProperty; +} + +var es_reflect_deleteProperty = {}; + +var hasRequiredEs_reflect_deleteProperty; + +function requireEs_reflect_deleteProperty () { + if (hasRequiredEs_reflect_deleteProperty) return es_reflect_deleteProperty; + hasRequiredEs_reflect_deleteProperty = 1; + var $ = require_export(); + var anObject = requireAnObject(); + var getOwnPropertyDescriptor = requireObjectGetOwnPropertyDescriptor().f; + + // `Reflect.deleteProperty` method + // https://tc39.es/ecma262/#sec-reflect.deleteproperty + $({ target: 'Reflect', stat: true }, { + deleteProperty: function deleteProperty(target, propertyKey) { + var descriptor = getOwnPropertyDescriptor(anObject(target), propertyKey); + return descriptor && !descriptor.configurable ? false : delete target[propertyKey]; + } + }); + return es_reflect_deleteProperty; +} + +var es_reflect_get = {}; + +var isDataDescriptor; +var hasRequiredIsDataDescriptor; + +function requireIsDataDescriptor () { + if (hasRequiredIsDataDescriptor) return isDataDescriptor; + hasRequiredIsDataDescriptor = 1; + var hasOwn = requireHasOwnProperty(); + + isDataDescriptor = function (descriptor) { + return descriptor !== undefined && (hasOwn(descriptor, 'value') || hasOwn(descriptor, 'writable')); + }; + return isDataDescriptor; +} + +var hasRequiredEs_reflect_get; + +function requireEs_reflect_get () { + if (hasRequiredEs_reflect_get) return es_reflect_get; + hasRequiredEs_reflect_get = 1; + var $ = require_export(); + var call = requireFunctionCall(); + var isObject = requireIsObject(); + var anObject = requireAnObject(); + var isDataDescriptor = requireIsDataDescriptor(); + var getOwnPropertyDescriptorModule = requireObjectGetOwnPropertyDescriptor(); + var getPrototypeOf = requireObjectGetPrototypeOf(); + + // `Reflect.get` method + // https://tc39.es/ecma262/#sec-reflect.get + function get(target, propertyKey /* , receiver */) { + var receiver = arguments.length < 3 ? target : arguments[2]; + var descriptor, prototype; + if (anObject(target) === receiver) return target[propertyKey]; + descriptor = getOwnPropertyDescriptorModule.f(target, propertyKey); + if (descriptor) return isDataDescriptor(descriptor) + ? descriptor.value + : descriptor.get === undefined ? undefined : call(descriptor.get, receiver); + if (isObject(prototype = getPrototypeOf(target))) return get(prototype, propertyKey, receiver); + } + + $({ target: 'Reflect', stat: true }, { + get: get + }); + return es_reflect_get; +} + +var es_reflect_getOwnPropertyDescriptor = {}; + +var hasRequiredEs_reflect_getOwnPropertyDescriptor; + +function requireEs_reflect_getOwnPropertyDescriptor () { + if (hasRequiredEs_reflect_getOwnPropertyDescriptor) return es_reflect_getOwnPropertyDescriptor; + hasRequiredEs_reflect_getOwnPropertyDescriptor = 1; + var $ = require_export(); + var DESCRIPTORS = requireDescriptors(); + var anObject = requireAnObject(); + var getOwnPropertyDescriptorModule = requireObjectGetOwnPropertyDescriptor(); + + // `Reflect.getOwnPropertyDescriptor` method + // https://tc39.es/ecma262/#sec-reflect.getownpropertydescriptor + $({ target: 'Reflect', stat: true, sham: !DESCRIPTORS }, { + getOwnPropertyDescriptor: function getOwnPropertyDescriptor(target, propertyKey) { + return getOwnPropertyDescriptorModule.f(anObject(target), propertyKey); + } + }); + return es_reflect_getOwnPropertyDescriptor; +} + +var es_reflect_getPrototypeOf = {}; + +var hasRequiredEs_reflect_getPrototypeOf; + +function requireEs_reflect_getPrototypeOf () { + if (hasRequiredEs_reflect_getPrototypeOf) return es_reflect_getPrototypeOf; + hasRequiredEs_reflect_getPrototypeOf = 1; + var $ = require_export(); + var anObject = requireAnObject(); + var objectGetPrototypeOf = requireObjectGetPrototypeOf(); + var CORRECT_PROTOTYPE_GETTER = requireCorrectPrototypeGetter(); + + // `Reflect.getPrototypeOf` method + // https://tc39.es/ecma262/#sec-reflect.getprototypeof + $({ target: 'Reflect', stat: true, sham: !CORRECT_PROTOTYPE_GETTER }, { + getPrototypeOf: function getPrototypeOf(target) { + return objectGetPrototypeOf(anObject(target)); + } + }); + return es_reflect_getPrototypeOf; +} + +var es_reflect_has = {}; + +var hasRequiredEs_reflect_has; + +function requireEs_reflect_has () { + if (hasRequiredEs_reflect_has) return es_reflect_has; + hasRequiredEs_reflect_has = 1; + var $ = require_export(); + + // `Reflect.has` method + // https://tc39.es/ecma262/#sec-reflect.has + $({ target: 'Reflect', stat: true }, { + has: function has(target, propertyKey) { + return propertyKey in target; + } + }); + return es_reflect_has; +} + +var es_reflect_isExtensible = {}; + +var hasRequiredEs_reflect_isExtensible; + +function requireEs_reflect_isExtensible () { + if (hasRequiredEs_reflect_isExtensible) return es_reflect_isExtensible; + hasRequiredEs_reflect_isExtensible = 1; + var $ = require_export(); + var anObject = requireAnObject(); + var $isExtensible = requireObjectIsExtensible(); + + // `Reflect.isExtensible` method + // https://tc39.es/ecma262/#sec-reflect.isextensible + $({ target: 'Reflect', stat: true }, { + isExtensible: function isExtensible(target) { + anObject(target); + return $isExtensible(target); + } + }); + return es_reflect_isExtensible; +} + +var es_reflect_ownKeys = {}; + +var hasRequiredEs_reflect_ownKeys; + +function requireEs_reflect_ownKeys () { + if (hasRequiredEs_reflect_ownKeys) return es_reflect_ownKeys; + hasRequiredEs_reflect_ownKeys = 1; + var $ = require_export(); + var ownKeys = requireOwnKeys(); + + // `Reflect.ownKeys` method + // https://tc39.es/ecma262/#sec-reflect.ownkeys + $({ target: 'Reflect', stat: true }, { + ownKeys: ownKeys + }); + return es_reflect_ownKeys; +} + +var es_reflect_preventExtensions = {}; + +var hasRequiredEs_reflect_preventExtensions; + +function requireEs_reflect_preventExtensions () { + if (hasRequiredEs_reflect_preventExtensions) return es_reflect_preventExtensions; + hasRequiredEs_reflect_preventExtensions = 1; + var $ = require_export(); + var getBuiltIn = requireGetBuiltIn(); + var anObject = requireAnObject(); + var FREEZING = requireFreezing(); + + // `Reflect.preventExtensions` method + // https://tc39.es/ecma262/#sec-reflect.preventextensions + $({ target: 'Reflect', stat: true, sham: !FREEZING }, { + preventExtensions: function preventExtensions(target) { + anObject(target); + try { + var objectPreventExtensions = getBuiltIn('Object', 'preventExtensions'); + if (objectPreventExtensions) objectPreventExtensions(target); + return true; + } catch (error) { + return false; + } + } + }); + return es_reflect_preventExtensions; +} + +var es_reflect_set = {}; + +var hasRequiredEs_reflect_set; + +function requireEs_reflect_set () { + if (hasRequiredEs_reflect_set) return es_reflect_set; + hasRequiredEs_reflect_set = 1; + var $ = require_export(); + var call = requireFunctionCall(); + var anObject = requireAnObject(); + var isObject = requireIsObject(); + var isDataDescriptor = requireIsDataDescriptor(); + var fails = requireFails(); + var definePropertyModule = requireObjectDefineProperty(); + var getOwnPropertyDescriptorModule = requireObjectGetOwnPropertyDescriptor(); + var getPrototypeOf = requireObjectGetPrototypeOf(); + var createPropertyDescriptor = requireCreatePropertyDescriptor(); + + // `Reflect.set` method + // https://tc39.es/ecma262/#sec-reflect.set + function set(target, propertyKey, V /* , receiver */) { + var receiver = arguments.length < 4 ? target : arguments[3]; + var ownDescriptor = getOwnPropertyDescriptorModule.f(anObject(target), propertyKey); + var existingDescriptor, prototype, setter; + if (!ownDescriptor) { + if (isObject(prototype = getPrototypeOf(target))) { + return set(prototype, propertyKey, V, receiver); + } + ownDescriptor = createPropertyDescriptor(0); + } + if (isDataDescriptor(ownDescriptor)) { + if (ownDescriptor.writable === false || !isObject(receiver)) return false; + if (existingDescriptor = getOwnPropertyDescriptorModule.f(receiver, propertyKey)) { + if (existingDescriptor.get || existingDescriptor.set || existingDescriptor.writable === false) return false; + existingDescriptor.value = V; + definePropertyModule.f(receiver, propertyKey, existingDescriptor); + } else definePropertyModule.f(receiver, propertyKey, createPropertyDescriptor(0, V)); + } else { + setter = ownDescriptor.set; + if (setter === undefined) return false; + call(setter, receiver, V); + } return true; + } + + // MS Edge 17-18 Reflect.set allows setting the property to object + // with non-writable property on the prototype + var MS_EDGE_BUG = fails(function () { + var Constructor = function () { /* empty */ }; + var object = definePropertyModule.f(new Constructor(), 'a', { configurable: true }); + // eslint-disable-next-line es/no-reflect -- required for testing + return Reflect.set(Constructor.prototype, 'a', 1, object) !== false; + }); + + $({ target: 'Reflect', stat: true, forced: MS_EDGE_BUG }, { + set: set + }); + return es_reflect_set; +} + +var es_reflect_setPrototypeOf = {}; + +var hasRequiredEs_reflect_setPrototypeOf; + +function requireEs_reflect_setPrototypeOf () { + if (hasRequiredEs_reflect_setPrototypeOf) return es_reflect_setPrototypeOf; + hasRequiredEs_reflect_setPrototypeOf = 1; + var $ = require_export(); + var anObject = requireAnObject(); + var aPossiblePrototype = requireAPossiblePrototype(); + var objectSetPrototypeOf = requireObjectSetPrototypeOf(); + + // `Reflect.setPrototypeOf` method + // https://tc39.es/ecma262/#sec-reflect.setprototypeof + if (objectSetPrototypeOf) $({ target: 'Reflect', stat: true }, { + setPrototypeOf: function setPrototypeOf(target, proto) { + anObject(target); + aPossiblePrototype(proto); + try { + objectSetPrototypeOf(target, proto); + return true; + } catch (error) { + return false; + } + } + }); + return es_reflect_setPrototypeOf; +} + +var es_reflect_toStringTag = {}; + +var hasRequiredEs_reflect_toStringTag; + +function requireEs_reflect_toStringTag () { + if (hasRequiredEs_reflect_toStringTag) return es_reflect_toStringTag; + hasRequiredEs_reflect_toStringTag = 1; + var $ = require_export(); + var globalThis = requireGlobalThis(); + var setToStringTag = requireSetToStringTag(); + + $({ global: true }, { Reflect: {} }); + + // Reflect[@@toStringTag] property + // https://tc39.es/ecma262/#sec-reflect-@@tostringtag + setToStringTag(globalThis.Reflect, 'Reflect', true); + return es_reflect_toStringTag; +} + +var es_regexp_constructor = {}; + +var isRegexp; +var hasRequiredIsRegexp; + +function requireIsRegexp () { + if (hasRequiredIsRegexp) return isRegexp; + hasRequiredIsRegexp = 1; + var isObject = requireIsObject(); + var classof = requireClassofRaw(); + var wellKnownSymbol = requireWellKnownSymbol(); + + var MATCH = wellKnownSymbol('match'); + + // `IsRegExp` abstract operation + // https://tc39.es/ecma262/#sec-isregexp + isRegexp = function (it) { + var isRegExp; + return isObject(it) && ((isRegExp = it[MATCH]) !== undefined ? !!isRegExp : classof(it) === 'RegExp'); + }; + return isRegexp; +} + +var regexpFlags; +var hasRequiredRegexpFlags; + +function requireRegexpFlags () { + if (hasRequiredRegexpFlags) return regexpFlags; + hasRequiredRegexpFlags = 1; + var anObject = requireAnObject(); + + // `RegExp.prototype.flags` getter implementation + // https://tc39.es/ecma262/#sec-get-regexp.prototype.flags + regexpFlags = function () { + var that = anObject(this); + var result = ''; + if (that.hasIndices) result += 'd'; + if (that.global) result += 'g'; + if (that.ignoreCase) result += 'i'; + if (that.multiline) result += 'm'; + if (that.dotAll) result += 's'; + if (that.unicode) result += 'u'; + if (that.unicodeSets) result += 'v'; + if (that.sticky) result += 'y'; + return result; + }; + return regexpFlags; +} + +var regexpGetFlags; +var hasRequiredRegexpGetFlags; + +function requireRegexpGetFlags () { + if (hasRequiredRegexpGetFlags) return regexpGetFlags; + hasRequiredRegexpGetFlags = 1; + var call = requireFunctionCall(); + var hasOwn = requireHasOwnProperty(); + var isPrototypeOf = requireObjectIsPrototypeOf(); + var regExpFlags = requireRegexpFlags(); + + var RegExpPrototype = RegExp.prototype; + + regexpGetFlags = function (R) { + var flags = R.flags; + return flags === undefined && !('flags' in RegExpPrototype) && !hasOwn(R, 'flags') && isPrototypeOf(RegExpPrototype, R) + ? call(regExpFlags, R) : flags; + }; + return regexpGetFlags; +} + +var regexpStickyHelpers; +var hasRequiredRegexpStickyHelpers; + +function requireRegexpStickyHelpers () { + if (hasRequiredRegexpStickyHelpers) return regexpStickyHelpers; + hasRequiredRegexpStickyHelpers = 1; + var fails = requireFails(); + var globalThis = requireGlobalThis(); + + // babel-minify and Closure Compiler transpiles RegExp('a', 'y') -> /a/y and it causes SyntaxError + var $RegExp = globalThis.RegExp; + + var UNSUPPORTED_Y = fails(function () { + var re = $RegExp('a', 'y'); + re.lastIndex = 2; + return re.exec('abcd') !== null; + }); + + // UC Browser bug + // https://github.com/zloirock/core-js/issues/1008 + var MISSED_STICKY = UNSUPPORTED_Y || fails(function () { + return !$RegExp('a', 'y').sticky; + }); + + var BROKEN_CARET = UNSUPPORTED_Y || fails(function () { + // https://bugzilla.mozilla.org/show_bug.cgi?id=773687 + var re = $RegExp('^r', 'gy'); + re.lastIndex = 2; + return re.exec('str') !== null; + }); + + regexpStickyHelpers = { + BROKEN_CARET: BROKEN_CARET, + MISSED_STICKY: MISSED_STICKY, + UNSUPPORTED_Y: UNSUPPORTED_Y + }; + return regexpStickyHelpers; +} + +var regexpUnsupportedDotAll; +var hasRequiredRegexpUnsupportedDotAll; + +function requireRegexpUnsupportedDotAll () { + if (hasRequiredRegexpUnsupportedDotAll) return regexpUnsupportedDotAll; + hasRequiredRegexpUnsupportedDotAll = 1; + var fails = requireFails(); + var globalThis = requireGlobalThis(); + + // babel-minify and Closure Compiler transpiles RegExp('.', 's') -> /./s and it causes SyntaxError + var $RegExp = globalThis.RegExp; + + regexpUnsupportedDotAll = fails(function () { + var re = $RegExp('.', 's'); + return !(re.dotAll && re.test('\n') && re.flags === 's'); + }); + return regexpUnsupportedDotAll; +} + +var regexpUnsupportedNcg; +var hasRequiredRegexpUnsupportedNcg; + +function requireRegexpUnsupportedNcg () { + if (hasRequiredRegexpUnsupportedNcg) return regexpUnsupportedNcg; + hasRequiredRegexpUnsupportedNcg = 1; + var fails = requireFails(); + var globalThis = requireGlobalThis(); + + // babel-minify and Closure Compiler transpiles RegExp('(?b)', 'g') -> /(?b)/g and it causes SyntaxError + var $RegExp = globalThis.RegExp; + + regexpUnsupportedNcg = fails(function () { + var re = $RegExp('(?b)', 'g'); + return re.exec('b').groups.a !== 'b' || + 'b'.replace(re, '$c') !== 'bc'; + }); + return regexpUnsupportedNcg; +} + +var hasRequiredEs_regexp_constructor; + +function requireEs_regexp_constructor () { + if (hasRequiredEs_regexp_constructor) return es_regexp_constructor; + hasRequiredEs_regexp_constructor = 1; + var DESCRIPTORS = requireDescriptors(); + var globalThis = requireGlobalThis(); + var uncurryThis = requireFunctionUncurryThis(); + var isForced = requireIsForced(); + var inheritIfRequired = requireInheritIfRequired(); + var createNonEnumerableProperty = requireCreateNonEnumerableProperty(); + var create = requireObjectCreate(); + var getOwnPropertyNames = requireObjectGetOwnPropertyNames().f; + var isPrototypeOf = requireObjectIsPrototypeOf(); + var isRegExp = requireIsRegexp(); + var toString = requireToString(); + var getRegExpFlags = requireRegexpGetFlags(); + var stickyHelpers = requireRegexpStickyHelpers(); + var proxyAccessor = requireProxyAccessor(); + var defineBuiltIn = requireDefineBuiltIn(); + var fails = requireFails(); + var hasOwn = requireHasOwnProperty(); + var enforceInternalState = requireInternalState().enforce; + var setSpecies = requireSetSpecies(); + var wellKnownSymbol = requireWellKnownSymbol(); + var UNSUPPORTED_DOT_ALL = requireRegexpUnsupportedDotAll(); + var UNSUPPORTED_NCG = requireRegexpUnsupportedNcg(); + + var MATCH = wellKnownSymbol('match'); + var NativeRegExp = globalThis.RegExp; + var RegExpPrototype = NativeRegExp.prototype; + var SyntaxError = globalThis.SyntaxError; + var exec = uncurryThis(RegExpPrototype.exec); + var charAt = uncurryThis(''.charAt); + var replace = uncurryThis(''.replace); + var stringIndexOf = uncurryThis(''.indexOf); + var stringSlice = uncurryThis(''.slice); + // TODO: Use only proper RegExpIdentifierName + var IS_NCG = /^\?<[^\s\d!#%&*+<=>@^][^\s!#%&*+<=>@^]*>/; + var re1 = /a/g; + var re2 = /a/g; + + // "new" should create a new object, old webkit bug + var CORRECT_NEW = new NativeRegExp(re1) !== re1; + + var MISSED_STICKY = stickyHelpers.MISSED_STICKY; + var UNSUPPORTED_Y = stickyHelpers.UNSUPPORTED_Y; + + var BASE_FORCED = DESCRIPTORS && + (!CORRECT_NEW || MISSED_STICKY || UNSUPPORTED_DOT_ALL || UNSUPPORTED_NCG || fails(function () { + re2[MATCH] = false; + // RegExp constructor can alter flags and IsRegExp works correct with @@match + // eslint-disable-next-line sonar/inconsistent-function-call -- required for testing + return NativeRegExp(re1) !== re1 || NativeRegExp(re2) === re2 || String(NativeRegExp(re1, 'i')) !== '/a/i'; + })); + + var handleDotAll = function (string) { + var length = string.length; + var index = 0; + var result = ''; + var brackets = false; + var chr; + for (; index <= length; index++) { + chr = charAt(string, index); + if (chr === '\\') { + result += chr + charAt(string, ++index); + continue; + } + if (!brackets && chr === '.') { + result += '[\\s\\S]'; + } else { + if (chr === '[') { + brackets = true; + } else if (chr === ']') { + brackets = false; + } result += chr; + } + } return result; + }; + + var handleNCG = function (string) { + var length = string.length; + var index = 0; + var result = ''; + var named = []; + var names = create(null); + var brackets = false; + var ncg = false; + var groupid = 0; + var groupname = ''; + var chr; + for (; index <= length; index++) { + chr = charAt(string, index); + if (chr === '\\') { + chr += charAt(string, ++index); + } else if (chr === ']') { + brackets = false; + } else if (!brackets) switch (true) { + case chr === '[': + brackets = true; + break; + case chr === '(': + result += chr; + // ignore non-capturing groups + if (stringSlice(string, index + 1, index + 3) === '?:') { + continue; + } + if (exec(IS_NCG, stringSlice(string, index + 1))) { + index += 2; + ncg = true; + } + groupid++; + continue; + case chr === '>' && ncg: + if (groupname === '' || hasOwn(names, groupname)) { + throw new SyntaxError('Invalid capture group name'); + } + names[groupname] = true; + named[named.length] = [groupname, groupid]; + ncg = false; + groupname = ''; + continue; + } + if (ncg) groupname += chr; + else result += chr; + } return [result, named]; + }; + + // `RegExp` constructor + // https://tc39.es/ecma262/#sec-regexp-constructor + if (isForced('RegExp', BASE_FORCED)) { + var RegExpWrapper = function RegExp(pattern, flags) { + var thisIsRegExp = isPrototypeOf(RegExpPrototype, this); + var patternIsRegExp = isRegExp(pattern); + var flagsAreUndefined = flags === undefined; + var groups = []; + var rawPattern = pattern; + var rawFlags, dotAll, sticky, handled, result, state; + + if (!thisIsRegExp && patternIsRegExp && flagsAreUndefined && pattern.constructor === RegExpWrapper) { + return pattern; + } + + if (patternIsRegExp || isPrototypeOf(RegExpPrototype, pattern)) { + pattern = pattern.source; + if (flagsAreUndefined) flags = getRegExpFlags(rawPattern); + } + + pattern = pattern === undefined ? '' : toString(pattern); + flags = flags === undefined ? '' : toString(flags); + rawPattern = pattern; + + if (UNSUPPORTED_DOT_ALL && 'dotAll' in re1) { + dotAll = !!flags && stringIndexOf(flags, 's') > -1; + if (dotAll) flags = replace(flags, /s/g, ''); + } + + rawFlags = flags; + + if (MISSED_STICKY && 'sticky' in re1) { + sticky = !!flags && stringIndexOf(flags, 'y') > -1; + if (sticky && UNSUPPORTED_Y) flags = replace(flags, /y/g, ''); + } + + if (UNSUPPORTED_NCG) { + handled = handleNCG(pattern); + pattern = handled[0]; + groups = handled[1]; + } + + result = inheritIfRequired(NativeRegExp(pattern, flags), thisIsRegExp ? this : RegExpPrototype, RegExpWrapper); + + if (dotAll || sticky || groups.length) { + state = enforceInternalState(result); + if (dotAll) { + state.dotAll = true; + state.raw = RegExpWrapper(handleDotAll(pattern), rawFlags); + } + if (sticky) state.sticky = true; + if (groups.length) state.groups = groups; + } + + if (pattern !== rawPattern) try { + // fails in old engines, but we have no alternatives for unsupported regex syntax + createNonEnumerableProperty(result, 'source', rawPattern === '' ? '(?:)' : rawPattern); + } catch (error) { /* empty */ } + + return result; + }; + + for (var keys = getOwnPropertyNames(NativeRegExp), index = 0; keys.length > index;) { + proxyAccessor(RegExpWrapper, NativeRegExp, keys[index++]); + } + + RegExpPrototype.constructor = RegExpWrapper; + RegExpWrapper.prototype = RegExpPrototype; + defineBuiltIn(globalThis, 'RegExp', RegExpWrapper, { constructor: true }); + } + + // https://tc39.es/ecma262/#sec-get-regexp-@@species + setSpecies('RegExp'); + return es_regexp_constructor; +} + +var es_regexp_dotAll = {}; + +var hasRequiredEs_regexp_dotAll; + +function requireEs_regexp_dotAll () { + if (hasRequiredEs_regexp_dotAll) return es_regexp_dotAll; + hasRequiredEs_regexp_dotAll = 1; + var DESCRIPTORS = requireDescriptors(); + var UNSUPPORTED_DOT_ALL = requireRegexpUnsupportedDotAll(); + var classof = requireClassofRaw(); + var defineBuiltInAccessor = requireDefineBuiltInAccessor(); + var getInternalState = requireInternalState().get; + + var RegExpPrototype = RegExp.prototype; + var $TypeError = TypeError; + + // `RegExp.prototype.dotAll` getter + // https://tc39.es/ecma262/#sec-get-regexp.prototype.dotall + if (DESCRIPTORS && UNSUPPORTED_DOT_ALL) { + defineBuiltInAccessor(RegExpPrototype, 'dotAll', { + configurable: true, + get: function dotAll() { + if (this === RegExpPrototype) return; + // We can't use InternalStateModule.getterFor because + // we don't add metadata for regexps created by a literal. + if (classof(this) === 'RegExp') { + return !!getInternalState(this).dotAll; + } + throw new $TypeError('Incompatible receiver, RegExp required'); + } + }); + } + return es_regexp_dotAll; +} + +var es_regexp_exec = {}; + +var regexpExec; +var hasRequiredRegexpExec; + +function requireRegexpExec () { + if (hasRequiredRegexpExec) return regexpExec; + hasRequiredRegexpExec = 1; + /* eslint-disable regexp/no-empty-capturing-group, regexp/no-empty-group, regexp/no-lazy-ends -- testing */ + /* eslint-disable regexp/no-useless-quantifier -- testing */ + var call = requireFunctionCall(); + var uncurryThis = requireFunctionUncurryThis(); + var toString = requireToString(); + var regexpFlags = requireRegexpFlags(); + var stickyHelpers = requireRegexpStickyHelpers(); + var shared = requireShared(); + var create = requireObjectCreate(); + var getInternalState = requireInternalState().get; + var UNSUPPORTED_DOT_ALL = requireRegexpUnsupportedDotAll(); + var UNSUPPORTED_NCG = requireRegexpUnsupportedNcg(); + + var nativeReplace = shared('native-string-replace', String.prototype.replace); + var nativeExec = RegExp.prototype.exec; + var patchedExec = nativeExec; + var charAt = uncurryThis(''.charAt); + var indexOf = uncurryThis(''.indexOf); + var replace = uncurryThis(''.replace); + var stringSlice = uncurryThis(''.slice); + + var UPDATES_LAST_INDEX_WRONG = (function () { + var re1 = /a/; + var re2 = /b*/g; + call(nativeExec, re1, 'a'); + call(nativeExec, re2, 'a'); + return re1.lastIndex !== 0 || re2.lastIndex !== 0; + })(); + + var UNSUPPORTED_Y = stickyHelpers.BROKEN_CARET; + + // nonparticipating capturing group, copied from es5-shim's String#split patch. + var NPCG_INCLUDED = /()??/.exec('')[1] !== undefined; + + var PATCH = UPDATES_LAST_INDEX_WRONG || NPCG_INCLUDED || UNSUPPORTED_Y || UNSUPPORTED_DOT_ALL || UNSUPPORTED_NCG; + + if (PATCH) { + patchedExec = function exec(string) { + var re = this; + var state = getInternalState(re); + var str = toString(string); + var raw = state.raw; + var result, reCopy, lastIndex, match, i, object, group; + + if (raw) { + raw.lastIndex = re.lastIndex; + result = call(patchedExec, raw, str); + re.lastIndex = raw.lastIndex; + return result; + } + + var groups = state.groups; + var sticky = UNSUPPORTED_Y && re.sticky; + var flags = call(regexpFlags, re); + var source = re.source; + var charsAdded = 0; + var strCopy = str; + + if (sticky) { + flags = replace(flags, 'y', ''); + if (indexOf(flags, 'g') === -1) { + flags += 'g'; + } + + strCopy = stringSlice(str, re.lastIndex); + // Support anchored sticky behavior. + if (re.lastIndex > 0 && (!re.multiline || re.multiline && charAt(str, re.lastIndex - 1) !== '\n')) { + source = '(?: ' + source + ')'; + strCopy = ' ' + strCopy; + charsAdded++; + } + // ^(? + rx + ) is needed, in combination with some str slicing, to + // simulate the 'y' flag. + reCopy = new RegExp('^(?:' + source + ')', flags); + } + + if (NPCG_INCLUDED) { + reCopy = new RegExp('^' + source + '$(?!\\s)', flags); + } + if (UPDATES_LAST_INDEX_WRONG) lastIndex = re.lastIndex; + + match = call(nativeExec, sticky ? reCopy : re, strCopy); + + if (sticky) { + if (match) { + match.input = stringSlice(match.input, charsAdded); + match[0] = stringSlice(match[0], charsAdded); + match.index = re.lastIndex; + re.lastIndex += match[0].length; + } else re.lastIndex = 0; + } else if (UPDATES_LAST_INDEX_WRONG && match) { + re.lastIndex = re.global ? match.index + match[0].length : lastIndex; + } + if (NPCG_INCLUDED && match && match.length > 1) { + // Fix browsers whose `exec` methods don't consistently return `undefined` + // for NPCG, like IE8. NOTE: This doesn't work for /(.?)?/ + call(nativeReplace, match[0], reCopy, function () { + for (i = 1; i < arguments.length - 2; i++) { + if (arguments[i] === undefined) match[i] = undefined; + } + }); + } + + if (match && groups) { + match.groups = object = create(null); + for (i = 0; i < groups.length; i++) { + group = groups[i]; + object[group[0]] = match[group[1]]; + } + } + + return match; + }; + } + + regexpExec = patchedExec; + return regexpExec; +} + +var hasRequiredEs_regexp_exec; + +function requireEs_regexp_exec () { + if (hasRequiredEs_regexp_exec) return es_regexp_exec; + hasRequiredEs_regexp_exec = 1; + var $ = require_export(); + var exec = requireRegexpExec(); + + // `RegExp.prototype.exec` method + // https://tc39.es/ecma262/#sec-regexp.prototype.exec + $({ target: 'RegExp', proto: true, forced: /./.exec !== exec }, { + exec: exec + }); + return es_regexp_exec; +} + +var es_regexp_flags = {}; + +var hasRequiredEs_regexp_flags; + +function requireEs_regexp_flags () { + if (hasRequiredEs_regexp_flags) return es_regexp_flags; + hasRequiredEs_regexp_flags = 1; + var globalThis = requireGlobalThis(); + var DESCRIPTORS = requireDescriptors(); + var defineBuiltInAccessor = requireDefineBuiltInAccessor(); + var regExpFlags = requireRegexpFlags(); + var fails = requireFails(); + + // babel-minify and Closure Compiler transpiles RegExp('.', 'd') -> /./d and it causes SyntaxError + var RegExp = globalThis.RegExp; + var RegExpPrototype = RegExp.prototype; + + var FORCED = DESCRIPTORS && fails(function () { + var INDICES_SUPPORT = true; + try { + RegExp('.', 'd'); + } catch (error) { + INDICES_SUPPORT = false; + } + + var O = {}; + // modern V8 bug + var calls = ''; + var expected = INDICES_SUPPORT ? 'dgimsy' : 'gimsy'; + + var addGetter = function (key, chr) { + // eslint-disable-next-line es/no-object-defineproperty -- safe + Object.defineProperty(O, key, { get: function () { + calls += chr; + return true; + } }); + }; + + var pairs = { + dotAll: 's', + global: 'g', + ignoreCase: 'i', + multiline: 'm', + sticky: 'y' + }; + + if (INDICES_SUPPORT) pairs.hasIndices = 'd'; + + for (var key in pairs) addGetter(key, pairs[key]); + + // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe + var result = Object.getOwnPropertyDescriptor(RegExpPrototype, 'flags').get.call(O); + + return result !== expected || calls !== expected; + }); + + // `RegExp.prototype.flags` getter + // https://tc39.es/ecma262/#sec-get-regexp.prototype.flags + if (FORCED) defineBuiltInAccessor(RegExpPrototype, 'flags', { + configurable: true, + get: regExpFlags + }); + return es_regexp_flags; +} + +var es_regexp_sticky = {}; + +var hasRequiredEs_regexp_sticky; + +function requireEs_regexp_sticky () { + if (hasRequiredEs_regexp_sticky) return es_regexp_sticky; + hasRequiredEs_regexp_sticky = 1; + var DESCRIPTORS = requireDescriptors(); + var MISSED_STICKY = requireRegexpStickyHelpers().MISSED_STICKY; + var classof = requireClassofRaw(); + var defineBuiltInAccessor = requireDefineBuiltInAccessor(); + var getInternalState = requireInternalState().get; + + var RegExpPrototype = RegExp.prototype; + var $TypeError = TypeError; + + // `RegExp.prototype.sticky` getter + // https://tc39.es/ecma262/#sec-get-regexp.prototype.sticky + if (DESCRIPTORS && MISSED_STICKY) { + defineBuiltInAccessor(RegExpPrototype, 'sticky', { + configurable: true, + get: function sticky() { + if (this === RegExpPrototype) return; + // We can't use InternalStateModule.getterFor because + // we don't add metadata for regexps created by a literal. + if (classof(this) === 'RegExp') { + return !!getInternalState(this).sticky; + } + throw new $TypeError('Incompatible receiver, RegExp required'); + } + }); + } + return es_regexp_sticky; +} + +var es_regexp_test = {}; + +var hasRequiredEs_regexp_test; + +function requireEs_regexp_test () { + if (hasRequiredEs_regexp_test) return es_regexp_test; + hasRequiredEs_regexp_test = 1; + // TODO: Remove from `core-js@4` since it's moved to entry points + requireEs_regexp_exec(); + var $ = require_export(); + var call = requireFunctionCall(); + var isCallable = requireIsCallable(); + var anObject = requireAnObject(); + var toString = requireToString(); + + var DELEGATES_TO_EXEC = function () { + var execCalled = false; + var re = /[ac]/; + re.exec = function () { + execCalled = true; + return /./.exec.apply(this, arguments); + }; + return re.test('abc') === true && execCalled; + }(); + + var nativeTest = /./.test; + + // `RegExp.prototype.test` method + // https://tc39.es/ecma262/#sec-regexp.prototype.test + $({ target: 'RegExp', proto: true, forced: !DELEGATES_TO_EXEC }, { + test: function (S) { + var R = anObject(this); + var string = toString(S); + var exec = R.exec; + if (!isCallable(exec)) return call(nativeTest, R, string); + var result = call(exec, R, string); + if (result === null) return false; + anObject(result); + return true; + } + }); + return es_regexp_test; +} + +var es_regexp_toString = {}; + +var hasRequiredEs_regexp_toString; + +function requireEs_regexp_toString () { + if (hasRequiredEs_regexp_toString) return es_regexp_toString; + hasRequiredEs_regexp_toString = 1; + var PROPER_FUNCTION_NAME = requireFunctionName().PROPER; + var defineBuiltIn = requireDefineBuiltIn(); + var anObject = requireAnObject(); + var $toString = requireToString(); + var fails = requireFails(); + var getRegExpFlags = requireRegexpGetFlags(); + + var TO_STRING = 'toString'; + var RegExpPrototype = RegExp.prototype; + var nativeToString = RegExpPrototype[TO_STRING]; + + var NOT_GENERIC = fails(function () { return nativeToString.call({ source: 'a', flags: 'b' }) !== '/a/b'; }); + // FF44- RegExp#toString has a wrong name + var INCORRECT_NAME = PROPER_FUNCTION_NAME && nativeToString.name !== TO_STRING; + + // `RegExp.prototype.toString` method + // https://tc39.es/ecma262/#sec-regexp.prototype.tostring + if (NOT_GENERIC || INCORRECT_NAME) { + defineBuiltIn(RegExpPrototype, TO_STRING, function toString() { + var R = anObject(this); + var pattern = $toString(R.source); + var flags = $toString(getRegExpFlags(R)); + return '/' + pattern + '/' + flags; + }, { unsafe: true }); + } + return es_regexp_toString; +} + +var es_set = {}; + +var es_set_constructor = {}; + +var hasRequiredEs_set_constructor; + +function requireEs_set_constructor () { + if (hasRequiredEs_set_constructor) return es_set_constructor; + hasRequiredEs_set_constructor = 1; + var collection = requireCollection(); + var collectionStrong = requireCollectionStrong(); + + // `Set` constructor + // https://tc39.es/ecma262/#sec-set-objects + collection('Set', function (init) { + return function Set() { return init(this, arguments.length ? arguments[0] : undefined); }; + }, collectionStrong); + return es_set_constructor; +} + +var hasRequiredEs_set; + +function requireEs_set () { + if (hasRequiredEs_set) return es_set; + hasRequiredEs_set = 1; + // TODO: Remove this module from `core-js@4` since it's replaced to module below + requireEs_set_constructor(); + return es_set; +} + +var es_set_difference_v2 = {}; + +var setHelpers; +var hasRequiredSetHelpers; + +function requireSetHelpers () { + if (hasRequiredSetHelpers) return setHelpers; + hasRequiredSetHelpers = 1; + var uncurryThis = requireFunctionUncurryThis(); + + // eslint-disable-next-line es/no-set -- safe + var SetPrototype = Set.prototype; + + setHelpers = { + // eslint-disable-next-line es/no-set -- safe + Set: Set, + add: uncurryThis(SetPrototype.add), + has: uncurryThis(SetPrototype.has), + remove: uncurryThis(SetPrototype['delete']), + proto: SetPrototype + }; + return setHelpers; +} + +var aSet; +var hasRequiredASet; + +function requireASet () { + if (hasRequiredASet) return aSet; + hasRequiredASet = 1; + var has = requireSetHelpers().has; + + // Perform ? RequireInternalSlot(M, [[SetData]]) + aSet = function (it) { + has(it); + return it; + }; + return aSet; +} + +var iterateSimple; +var hasRequiredIterateSimple; + +function requireIterateSimple () { + if (hasRequiredIterateSimple) return iterateSimple; + hasRequiredIterateSimple = 1; + var call = requireFunctionCall(); + + iterateSimple = function (record, fn, ITERATOR_INSTEAD_OF_RECORD) { + var iterator = ITERATOR_INSTEAD_OF_RECORD ? record : record.iterator; + var next = record.next; + var step, result; + while (!(step = call(next, iterator)).done) { + result = fn(step.value); + if (result !== undefined) return result; + } + }; + return iterateSimple; +} + +var setIterate; +var hasRequiredSetIterate; + +function requireSetIterate () { + if (hasRequiredSetIterate) return setIterate; + hasRequiredSetIterate = 1; + var uncurryThis = requireFunctionUncurryThis(); + var iterateSimple = requireIterateSimple(); + var SetHelpers = requireSetHelpers(); + + var Set = SetHelpers.Set; + var SetPrototype = SetHelpers.proto; + var forEach = uncurryThis(SetPrototype.forEach); + var keys = uncurryThis(SetPrototype.keys); + var next = keys(new Set()).next; + + setIterate = function (set, fn, interruptible) { + return interruptible ? iterateSimple({ iterator: keys(set), next: next }, fn) : forEach(set, fn); + }; + return setIterate; +} + +var setClone; +var hasRequiredSetClone; + +function requireSetClone () { + if (hasRequiredSetClone) return setClone; + hasRequiredSetClone = 1; + var SetHelpers = requireSetHelpers(); + var iterate = requireSetIterate(); + + var Set = SetHelpers.Set; + var add = SetHelpers.add; + + setClone = function (set) { + var result = new Set(); + iterate(set, function (it) { + add(result, it); + }); + return result; + }; + return setClone; +} + +var setSize; +var hasRequiredSetSize; + +function requireSetSize () { + if (hasRequiredSetSize) return setSize; + hasRequiredSetSize = 1; + var uncurryThisAccessor = requireFunctionUncurryThisAccessor(); + var SetHelpers = requireSetHelpers(); + + setSize = uncurryThisAccessor(SetHelpers.proto, 'size', 'get') || function (set) { + return set.size; + }; + return setSize; +} + +var getIteratorDirect; +var hasRequiredGetIteratorDirect; + +function requireGetIteratorDirect () { + if (hasRequiredGetIteratorDirect) return getIteratorDirect; + hasRequiredGetIteratorDirect = 1; + // `GetIteratorDirect(obj)` abstract operation + // https://tc39.es/proposal-iterator-helpers/#sec-getiteratordirect + getIteratorDirect = function (obj) { + return { + iterator: obj, + next: obj.next, + done: false + }; + }; + return getIteratorDirect; +} + +var getSetRecord; +var hasRequiredGetSetRecord; + +function requireGetSetRecord () { + if (hasRequiredGetSetRecord) return getSetRecord; + hasRequiredGetSetRecord = 1; + var aCallable = requireACallable(); + var anObject = requireAnObject(); + var call = requireFunctionCall(); + var toIntegerOrInfinity = requireToIntegerOrInfinity(); + var getIteratorDirect = requireGetIteratorDirect(); + + var INVALID_SIZE = 'Invalid size'; + var $RangeError = RangeError; + var $TypeError = TypeError; + var max = Math.max; + + var SetRecord = function (set, intSize) { + this.set = set; + this.size = max(intSize, 0); + this.has = aCallable(set.has); + this.keys = aCallable(set.keys); + }; + + SetRecord.prototype = { + getIterator: function () { + return getIteratorDirect(anObject(call(this.keys, this.set))); + }, + includes: function (it) { + return call(this.has, this.set, it); + } + }; + + // `GetSetRecord` abstract operation + // https://tc39.es/proposal-set-methods/#sec-getsetrecord + getSetRecord = function (obj) { + anObject(obj); + var numSize = +obj.size; + // NOTE: If size is undefined, then numSize will be NaN + // eslint-disable-next-line no-self-compare -- NaN check + if (numSize !== numSize) throw new $TypeError(INVALID_SIZE); + var intSize = toIntegerOrInfinity(numSize); + if (intSize < 0) throw new $RangeError(INVALID_SIZE); + return new SetRecord(obj, intSize); + }; + return getSetRecord; +} + +var setDifference; +var hasRequiredSetDifference; + +function requireSetDifference () { + if (hasRequiredSetDifference) return setDifference; + hasRequiredSetDifference = 1; + var aSet = requireASet(); + var SetHelpers = requireSetHelpers(); + var clone = requireSetClone(); + var size = requireSetSize(); + var getSetRecord = requireGetSetRecord(); + var iterateSet = requireSetIterate(); + var iterateSimple = requireIterateSimple(); + + var has = SetHelpers.has; + var remove = SetHelpers.remove; + + // `Set.prototype.difference` method + // https://github.com/tc39/proposal-set-methods + setDifference = function difference(other) { + var O = aSet(this); + var otherRec = getSetRecord(other); + var result = clone(O); + if (size(O) <= otherRec.size) iterateSet(O, function (e) { + if (otherRec.includes(e)) remove(result, e); + }); + else iterateSimple(otherRec.getIterator(), function (e) { + if (has(O, e)) remove(result, e); + }); + return result; + }; + return setDifference; +} + +var setMethodAcceptSetLike; +var hasRequiredSetMethodAcceptSetLike; + +function requireSetMethodAcceptSetLike () { + if (hasRequiredSetMethodAcceptSetLike) return setMethodAcceptSetLike; + hasRequiredSetMethodAcceptSetLike = 1; + var getBuiltIn = requireGetBuiltIn(); + + var createSetLike = function (size) { + return { + size: size, + has: function () { + return false; + }, + keys: function () { + return { + next: function () { + return { done: true }; + } + }; + } + }; + }; + + setMethodAcceptSetLike = function (name) { + var Set = getBuiltIn('Set'); + try { + new Set()[name](createSetLike(0)); + try { + // late spec change, early WebKit ~ Safari 17.0 beta implementation does not pass it + // https://github.com/tc39/proposal-set-methods/pull/88 + new Set()[name](createSetLike(-1)); + return false; + } catch (error2) { + return true; + } + } catch (error) { + return false; + } + }; + return setMethodAcceptSetLike; +} + +var hasRequiredEs_set_difference_v2; + +function requireEs_set_difference_v2 () { + if (hasRequiredEs_set_difference_v2) return es_set_difference_v2; + hasRequiredEs_set_difference_v2 = 1; + var $ = require_export(); + var difference = requireSetDifference(); + var setMethodAcceptSetLike = requireSetMethodAcceptSetLike(); + + // `Set.prototype.difference` method + // https://github.com/tc39/proposal-set-methods + $({ target: 'Set', proto: true, real: true, forced: !setMethodAcceptSetLike('difference') }, { + difference: difference + }); + return es_set_difference_v2; +} + +var es_set_intersection_v2 = {}; + +var setIntersection; +var hasRequiredSetIntersection; + +function requireSetIntersection () { + if (hasRequiredSetIntersection) return setIntersection; + hasRequiredSetIntersection = 1; + var aSet = requireASet(); + var SetHelpers = requireSetHelpers(); + var size = requireSetSize(); + var getSetRecord = requireGetSetRecord(); + var iterateSet = requireSetIterate(); + var iterateSimple = requireIterateSimple(); + + var Set = SetHelpers.Set; + var add = SetHelpers.add; + var has = SetHelpers.has; + + // `Set.prototype.intersection` method + // https://github.com/tc39/proposal-set-methods + setIntersection = function intersection(other) { + var O = aSet(this); + var otherRec = getSetRecord(other); + var result = new Set(); + + if (size(O) > otherRec.size) { + iterateSimple(otherRec.getIterator(), function (e) { + if (has(O, e)) add(result, e); + }); + } else { + iterateSet(O, function (e) { + if (otherRec.includes(e)) add(result, e); + }); + } + + return result; + }; + return setIntersection; +} + +var hasRequiredEs_set_intersection_v2; + +function requireEs_set_intersection_v2 () { + if (hasRequiredEs_set_intersection_v2) return es_set_intersection_v2; + hasRequiredEs_set_intersection_v2 = 1; + var $ = require_export(); + var fails = requireFails(); + var intersection = requireSetIntersection(); + var setMethodAcceptSetLike = requireSetMethodAcceptSetLike(); + + var INCORRECT = !setMethodAcceptSetLike('intersection') || fails(function () { + // eslint-disable-next-line es/no-array-from, es/no-set -- testing + return String(Array.from(new Set([1, 2, 3]).intersection(new Set([3, 2])))) !== '3,2'; + }); + + // `Set.prototype.intersection` method + // https://github.com/tc39/proposal-set-methods + $({ target: 'Set', proto: true, real: true, forced: INCORRECT }, { + intersection: intersection + }); + return es_set_intersection_v2; +} + +var es_set_isDisjointFrom_v2 = {}; + +var setIsDisjointFrom; +var hasRequiredSetIsDisjointFrom; + +function requireSetIsDisjointFrom () { + if (hasRequiredSetIsDisjointFrom) return setIsDisjointFrom; + hasRequiredSetIsDisjointFrom = 1; + var aSet = requireASet(); + var has = requireSetHelpers().has; + var size = requireSetSize(); + var getSetRecord = requireGetSetRecord(); + var iterateSet = requireSetIterate(); + var iterateSimple = requireIterateSimple(); + var iteratorClose = requireIteratorClose(); + + // `Set.prototype.isDisjointFrom` method + // https://tc39.github.io/proposal-set-methods/#Set.prototype.isDisjointFrom + setIsDisjointFrom = function isDisjointFrom(other) { + var O = aSet(this); + var otherRec = getSetRecord(other); + if (size(O) <= otherRec.size) return iterateSet(O, function (e) { + if (otherRec.includes(e)) return false; + }, true) !== false; + var iterator = otherRec.getIterator(); + return iterateSimple(iterator, function (e) { + if (has(O, e)) return iteratorClose(iterator, 'normal', false); + }) !== false; + }; + return setIsDisjointFrom; +} + +var hasRequiredEs_set_isDisjointFrom_v2; + +function requireEs_set_isDisjointFrom_v2 () { + if (hasRequiredEs_set_isDisjointFrom_v2) return es_set_isDisjointFrom_v2; + hasRequiredEs_set_isDisjointFrom_v2 = 1; + var $ = require_export(); + var isDisjointFrom = requireSetIsDisjointFrom(); + var setMethodAcceptSetLike = requireSetMethodAcceptSetLike(); + + // `Set.prototype.isDisjointFrom` method + // https://github.com/tc39/proposal-set-methods + $({ target: 'Set', proto: true, real: true, forced: !setMethodAcceptSetLike('isDisjointFrom') }, { + isDisjointFrom: isDisjointFrom + }); + return es_set_isDisjointFrom_v2; +} + +var es_set_isSubsetOf_v2 = {}; + +var setIsSubsetOf; +var hasRequiredSetIsSubsetOf; + +function requireSetIsSubsetOf () { + if (hasRequiredSetIsSubsetOf) return setIsSubsetOf; + hasRequiredSetIsSubsetOf = 1; + var aSet = requireASet(); + var size = requireSetSize(); + var iterate = requireSetIterate(); + var getSetRecord = requireGetSetRecord(); + + // `Set.prototype.isSubsetOf` method + // https://tc39.github.io/proposal-set-methods/#Set.prototype.isSubsetOf + setIsSubsetOf = function isSubsetOf(other) { + var O = aSet(this); + var otherRec = getSetRecord(other); + if (size(O) > otherRec.size) return false; + return iterate(O, function (e) { + if (!otherRec.includes(e)) return false; + }, true) !== false; + }; + return setIsSubsetOf; +} + +var hasRequiredEs_set_isSubsetOf_v2; + +function requireEs_set_isSubsetOf_v2 () { + if (hasRequiredEs_set_isSubsetOf_v2) return es_set_isSubsetOf_v2; + hasRequiredEs_set_isSubsetOf_v2 = 1; + var $ = require_export(); + var isSubsetOf = requireSetIsSubsetOf(); + var setMethodAcceptSetLike = requireSetMethodAcceptSetLike(); + + // `Set.prototype.isSubsetOf` method + // https://github.com/tc39/proposal-set-methods + $({ target: 'Set', proto: true, real: true, forced: !setMethodAcceptSetLike('isSubsetOf') }, { + isSubsetOf: isSubsetOf + }); + return es_set_isSubsetOf_v2; +} + +var es_set_isSupersetOf_v2 = {}; + +var setIsSupersetOf; +var hasRequiredSetIsSupersetOf; + +function requireSetIsSupersetOf () { + if (hasRequiredSetIsSupersetOf) return setIsSupersetOf; + hasRequiredSetIsSupersetOf = 1; + var aSet = requireASet(); + var has = requireSetHelpers().has; + var size = requireSetSize(); + var getSetRecord = requireGetSetRecord(); + var iterateSimple = requireIterateSimple(); + var iteratorClose = requireIteratorClose(); + + // `Set.prototype.isSupersetOf` method + // https://tc39.github.io/proposal-set-methods/#Set.prototype.isSupersetOf + setIsSupersetOf = function isSupersetOf(other) { + var O = aSet(this); + var otherRec = getSetRecord(other); + if (size(O) < otherRec.size) return false; + var iterator = otherRec.getIterator(); + return iterateSimple(iterator, function (e) { + if (!has(O, e)) return iteratorClose(iterator, 'normal', false); + }) !== false; + }; + return setIsSupersetOf; +} + +var hasRequiredEs_set_isSupersetOf_v2; + +function requireEs_set_isSupersetOf_v2 () { + if (hasRequiredEs_set_isSupersetOf_v2) return es_set_isSupersetOf_v2; + hasRequiredEs_set_isSupersetOf_v2 = 1; + var $ = require_export(); + var isSupersetOf = requireSetIsSupersetOf(); + var setMethodAcceptSetLike = requireSetMethodAcceptSetLike(); + + // `Set.prototype.isSupersetOf` method + // https://github.com/tc39/proposal-set-methods + $({ target: 'Set', proto: true, real: true, forced: !setMethodAcceptSetLike('isSupersetOf') }, { + isSupersetOf: isSupersetOf + }); + return es_set_isSupersetOf_v2; +} + +var es_set_symmetricDifference_v2 = {}; + +var setSymmetricDifference; +var hasRequiredSetSymmetricDifference; + +function requireSetSymmetricDifference () { + if (hasRequiredSetSymmetricDifference) return setSymmetricDifference; + hasRequiredSetSymmetricDifference = 1; + var aSet = requireASet(); + var SetHelpers = requireSetHelpers(); + var clone = requireSetClone(); + var getSetRecord = requireGetSetRecord(); + var iterateSimple = requireIterateSimple(); + + var add = SetHelpers.add; + var has = SetHelpers.has; + var remove = SetHelpers.remove; + + // `Set.prototype.symmetricDifference` method + // https://github.com/tc39/proposal-set-methods + setSymmetricDifference = function symmetricDifference(other) { + var O = aSet(this); + var keysIter = getSetRecord(other).getIterator(); + var result = clone(O); + iterateSimple(keysIter, function (e) { + if (has(O, e)) remove(result, e); + else add(result, e); + }); + return result; + }; + return setSymmetricDifference; +} + +var hasRequiredEs_set_symmetricDifference_v2; + +function requireEs_set_symmetricDifference_v2 () { + if (hasRequiredEs_set_symmetricDifference_v2) return es_set_symmetricDifference_v2; + hasRequiredEs_set_symmetricDifference_v2 = 1; + var $ = require_export(); + var symmetricDifference = requireSetSymmetricDifference(); + var setMethodAcceptSetLike = requireSetMethodAcceptSetLike(); + + // `Set.prototype.symmetricDifference` method + // https://github.com/tc39/proposal-set-methods + $({ target: 'Set', proto: true, real: true, forced: !setMethodAcceptSetLike('symmetricDifference') }, { + symmetricDifference: symmetricDifference + }); + return es_set_symmetricDifference_v2; +} + +var es_set_union_v2 = {}; + +var setUnion; +var hasRequiredSetUnion; + +function requireSetUnion () { + if (hasRequiredSetUnion) return setUnion; + hasRequiredSetUnion = 1; + var aSet = requireASet(); + var add = requireSetHelpers().add; + var clone = requireSetClone(); + var getSetRecord = requireGetSetRecord(); + var iterateSimple = requireIterateSimple(); + + // `Set.prototype.union` method + // https://github.com/tc39/proposal-set-methods + setUnion = function union(other) { + var O = aSet(this); + var keysIter = getSetRecord(other).getIterator(); + var result = clone(O); + iterateSimple(keysIter, function (it) { + add(result, it); + }); + return result; + }; + return setUnion; +} + +var hasRequiredEs_set_union_v2; + +function requireEs_set_union_v2 () { + if (hasRequiredEs_set_union_v2) return es_set_union_v2; + hasRequiredEs_set_union_v2 = 1; + var $ = require_export(); + var union = requireSetUnion(); + var setMethodAcceptSetLike = requireSetMethodAcceptSetLike(); + + // `Set.prototype.union` method + // https://github.com/tc39/proposal-set-methods + $({ target: 'Set', proto: true, real: true, forced: !setMethodAcceptSetLike('union') }, { + union: union + }); + return es_set_union_v2; +} + +var es_string_atAlternative = {}; + +var hasRequiredEs_string_atAlternative; + +function requireEs_string_atAlternative () { + if (hasRequiredEs_string_atAlternative) return es_string_atAlternative; + hasRequiredEs_string_atAlternative = 1; + var $ = require_export(); + var uncurryThis = requireFunctionUncurryThis(); + var requireObjectCoercible = requireRequireObjectCoercible(); + var toIntegerOrInfinity = requireToIntegerOrInfinity(); + var toString = requireToString(); + var fails = requireFails(); + + var charAt = uncurryThis(''.charAt); + + var FORCED = fails(function () { + // eslint-disable-next-line es/no-string-prototype-at -- safe + return '𠮷'.at(-2) !== '\uD842'; + }); + + // `String.prototype.at` method + // https://tc39.es/ecma262/#sec-string.prototype.at + $({ target: 'String', proto: true, forced: FORCED }, { + at: function at(index) { + var S = toString(requireObjectCoercible(this)); + var len = S.length; + var relativeIndex = toIntegerOrInfinity(index); + var k = relativeIndex >= 0 ? relativeIndex : len + relativeIndex; + return (k < 0 || k >= len) ? undefined : charAt(S, k); + } + }); + return es_string_atAlternative; +} + +var es_string_codePointAt = {}; + +var stringMultibyte; +var hasRequiredStringMultibyte; + +function requireStringMultibyte () { + if (hasRequiredStringMultibyte) return stringMultibyte; + hasRequiredStringMultibyte = 1; + var uncurryThis = requireFunctionUncurryThis(); + var toIntegerOrInfinity = requireToIntegerOrInfinity(); + var toString = requireToString(); + var requireObjectCoercible = requireRequireObjectCoercible(); + + var charAt = uncurryThis(''.charAt); + var charCodeAt = uncurryThis(''.charCodeAt); + var stringSlice = uncurryThis(''.slice); + + var createMethod = function (CONVERT_TO_STRING) { + return function ($this, pos) { + var S = toString(requireObjectCoercible($this)); + var position = toIntegerOrInfinity(pos); + var size = S.length; + var first, second; + if (position < 0 || position >= size) return CONVERT_TO_STRING ? '' : undefined; + first = charCodeAt(S, position); + return first < 0xD800 || first > 0xDBFF || position + 1 === size + || (second = charCodeAt(S, position + 1)) < 0xDC00 || second > 0xDFFF + ? CONVERT_TO_STRING + ? charAt(S, position) + : first + : CONVERT_TO_STRING + ? stringSlice(S, position, position + 2) + : (first - 0xD800 << 10) + (second - 0xDC00) + 0x10000; + }; + }; + + stringMultibyte = { + // `String.prototype.codePointAt` method + // https://tc39.es/ecma262/#sec-string.prototype.codepointat + codeAt: createMethod(false), + // `String.prototype.at` method + // https://github.com/mathiasbynens/String.prototype.at + charAt: createMethod(true) + }; + return stringMultibyte; +} + +var hasRequiredEs_string_codePointAt; + +function requireEs_string_codePointAt () { + if (hasRequiredEs_string_codePointAt) return es_string_codePointAt; + hasRequiredEs_string_codePointAt = 1; + var $ = require_export(); + var codeAt = requireStringMultibyte().codeAt; + + // `String.prototype.codePointAt` method + // https://tc39.es/ecma262/#sec-string.prototype.codepointat + $({ target: 'String', proto: true }, { + codePointAt: function codePointAt(pos) { + return codeAt(this, pos); + } + }); + return es_string_codePointAt; +} + +var es_string_endsWith = {}; + +var notARegexp; +var hasRequiredNotARegexp; + +function requireNotARegexp () { + if (hasRequiredNotARegexp) return notARegexp; + hasRequiredNotARegexp = 1; + var isRegExp = requireIsRegexp(); + + var $TypeError = TypeError; + + notARegexp = function (it) { + if (isRegExp(it)) { + throw new $TypeError("The method doesn't accept regular expressions"); + } return it; + }; + return notARegexp; +} + +var correctIsRegexpLogic; +var hasRequiredCorrectIsRegexpLogic; + +function requireCorrectIsRegexpLogic () { + if (hasRequiredCorrectIsRegexpLogic) return correctIsRegexpLogic; + hasRequiredCorrectIsRegexpLogic = 1; + var wellKnownSymbol = requireWellKnownSymbol(); + + var MATCH = wellKnownSymbol('match'); + + correctIsRegexpLogic = function (METHOD_NAME) { + var regexp = /./; + try { + '/./'[METHOD_NAME](regexp); + } catch (error1) { + try { + regexp[MATCH] = false; + return '/./'[METHOD_NAME](regexp); + } catch (error2) { /* empty */ } + } return false; + }; + return correctIsRegexpLogic; +} + +var hasRequiredEs_string_endsWith; + +function requireEs_string_endsWith () { + if (hasRequiredEs_string_endsWith) return es_string_endsWith; + hasRequiredEs_string_endsWith = 1; + var $ = require_export(); + var uncurryThis = requireFunctionUncurryThisClause(); + var getOwnPropertyDescriptor = requireObjectGetOwnPropertyDescriptor().f; + var toLength = requireToLength(); + var toString = requireToString(); + var notARegExp = requireNotARegexp(); + var requireObjectCoercible = requireRequireObjectCoercible(); + var correctIsRegExpLogic = requireCorrectIsRegexpLogic(); + var IS_PURE = requireIsPure(); + + var slice = uncurryThis(''.slice); + var min = Math.min; + + var CORRECT_IS_REGEXP_LOGIC = correctIsRegExpLogic('endsWith'); + // https://github.com/zloirock/core-js/pull/702 + var MDN_POLYFILL_BUG = !IS_PURE && !CORRECT_IS_REGEXP_LOGIC && !!function () { + var descriptor = getOwnPropertyDescriptor(String.prototype, 'endsWith'); + return descriptor && !descriptor.writable; + }(); + + // `String.prototype.endsWith` method + // https://tc39.es/ecma262/#sec-string.prototype.endswith + $({ target: 'String', proto: true, forced: !MDN_POLYFILL_BUG && !CORRECT_IS_REGEXP_LOGIC }, { + endsWith: function endsWith(searchString /* , endPosition = @length */) { + var that = toString(requireObjectCoercible(this)); + notARegExp(searchString); + var endPosition = arguments.length > 1 ? arguments[1] : undefined; + var len = that.length; + var end = endPosition === undefined ? len : min(toLength(endPosition), len); + var search = toString(searchString); + return slice(that, end - search.length, end) === search; + } + }); + return es_string_endsWith; +} + +var es_string_fromCodePoint = {}; + +var hasRequiredEs_string_fromCodePoint; + +function requireEs_string_fromCodePoint () { + if (hasRequiredEs_string_fromCodePoint) return es_string_fromCodePoint; + hasRequiredEs_string_fromCodePoint = 1; + var $ = require_export(); + var uncurryThis = requireFunctionUncurryThis(); + var toAbsoluteIndex = requireToAbsoluteIndex(); + + var $RangeError = RangeError; + var fromCharCode = String.fromCharCode; + // eslint-disable-next-line es/no-string-fromcodepoint -- required for testing + var $fromCodePoint = String.fromCodePoint; + var join = uncurryThis([].join); + + // length should be 1, old FF problem + var INCORRECT_LENGTH = !!$fromCodePoint && $fromCodePoint.length !== 1; + + // `String.fromCodePoint` method + // https://tc39.es/ecma262/#sec-string.fromcodepoint + $({ target: 'String', stat: true, arity: 1, forced: INCORRECT_LENGTH }, { + // eslint-disable-next-line no-unused-vars -- required for `.length` + fromCodePoint: function fromCodePoint(x) { + var elements = []; + var length = arguments.length; + var i = 0; + var code; + while (length > i) { + code = +arguments[i++]; + if (toAbsoluteIndex(code, 0x10FFFF) !== code) throw new $RangeError(code + ' is not a valid code point'); + elements[i] = code < 0x10000 + ? fromCharCode(code) + : fromCharCode(((code -= 0x10000) >> 10) + 0xD800, code % 0x400 + 0xDC00); + } return join(elements, ''); + } + }); + return es_string_fromCodePoint; +} + +var es_string_includes = {}; + +var hasRequiredEs_string_includes; + +function requireEs_string_includes () { + if (hasRequiredEs_string_includes) return es_string_includes; + hasRequiredEs_string_includes = 1; + var $ = require_export(); + var uncurryThis = requireFunctionUncurryThis(); + var notARegExp = requireNotARegexp(); + var requireObjectCoercible = requireRequireObjectCoercible(); + var toString = requireToString(); + var correctIsRegExpLogic = requireCorrectIsRegexpLogic(); + + var stringIndexOf = uncurryThis(''.indexOf); + + // `String.prototype.includes` method + // https://tc39.es/ecma262/#sec-string.prototype.includes + $({ target: 'String', proto: true, forced: !correctIsRegExpLogic('includes') }, { + includes: function includes(searchString /* , position = 0 */) { + return !!~stringIndexOf( + toString(requireObjectCoercible(this)), + toString(notARegExp(searchString)), + arguments.length > 1 ? arguments[1] : undefined + ); + } + }); + return es_string_includes; +} + +var es_string_isWellFormed = {}; + +var hasRequiredEs_string_isWellFormed; + +function requireEs_string_isWellFormed () { + if (hasRequiredEs_string_isWellFormed) return es_string_isWellFormed; + hasRequiredEs_string_isWellFormed = 1; + var $ = require_export(); + var uncurryThis = requireFunctionUncurryThis(); + var requireObjectCoercible = requireRequireObjectCoercible(); + var toString = requireToString(); + + var charCodeAt = uncurryThis(''.charCodeAt); + + // `String.prototype.isWellFormed` method + // https://github.com/tc39/proposal-is-usv-string + $({ target: 'String', proto: true }, { + isWellFormed: function isWellFormed() { + var S = toString(requireObjectCoercible(this)); + var length = S.length; + for (var i = 0; i < length; i++) { + var charCode = charCodeAt(S, i); + // single UTF-16 code unit + if ((charCode & 0xF800) !== 0xD800) continue; + // unpaired surrogate + if (charCode >= 0xDC00 || ++i >= length || (charCodeAt(S, i) & 0xFC00) !== 0xDC00) return false; + } return true; + } + }); + return es_string_isWellFormed; +} + +var es_string_iterator = {}; + +var hasRequiredEs_string_iterator; + +function requireEs_string_iterator () { + if (hasRequiredEs_string_iterator) return es_string_iterator; + hasRequiredEs_string_iterator = 1; + var charAt = requireStringMultibyte().charAt; + var toString = requireToString(); + var InternalStateModule = requireInternalState(); + var defineIterator = requireIteratorDefine(); + var createIterResultObject = requireCreateIterResultObject(); + + var STRING_ITERATOR = 'String Iterator'; + var setInternalState = InternalStateModule.set; + var getInternalState = InternalStateModule.getterFor(STRING_ITERATOR); + + // `String.prototype[@@iterator]` method + // https://tc39.es/ecma262/#sec-string.prototype-@@iterator + defineIterator(String, 'String', function (iterated) { + setInternalState(this, { + type: STRING_ITERATOR, + string: toString(iterated), + index: 0 + }); + // `%StringIteratorPrototype%.next` method + // https://tc39.es/ecma262/#sec-%stringiteratorprototype%.next + }, function next() { + var state = getInternalState(this); + var string = state.string; + var index = state.index; + var point; + if (index >= string.length) return createIterResultObject(undefined, true); + point = charAt(string, index); + state.index += point.length; + return createIterResultObject(point, false); + }); + return es_string_iterator; +} + +var es_string_match = {}; + +var fixRegexpWellKnownSymbolLogic; +var hasRequiredFixRegexpWellKnownSymbolLogic; + +function requireFixRegexpWellKnownSymbolLogic () { + if (hasRequiredFixRegexpWellKnownSymbolLogic) return fixRegexpWellKnownSymbolLogic; + hasRequiredFixRegexpWellKnownSymbolLogic = 1; + // TODO: Remove from `core-js@4` since it's moved to entry points + requireEs_regexp_exec(); + var call = requireFunctionCall(); + var defineBuiltIn = requireDefineBuiltIn(); + var regexpExec = requireRegexpExec(); + var fails = requireFails(); + var wellKnownSymbol = requireWellKnownSymbol(); + var createNonEnumerableProperty = requireCreateNonEnumerableProperty(); + + var SPECIES = wellKnownSymbol('species'); + var RegExpPrototype = RegExp.prototype; + + fixRegexpWellKnownSymbolLogic = function (KEY, exec, FORCED, SHAM) { + var SYMBOL = wellKnownSymbol(KEY); + + var DELEGATES_TO_SYMBOL = !fails(function () { + // String methods call symbol-named RegExp methods + var O = {}; + O[SYMBOL] = function () { return 7; }; + return ''[KEY](O) !== 7; + }); + + var DELEGATES_TO_EXEC = DELEGATES_TO_SYMBOL && !fails(function () { + // Symbol-named RegExp methods call .exec + var execCalled = false; + var re = /a/; + + if (KEY === 'split') { + // We can't use real regex here since it causes deoptimization + // and serious performance degradation in V8 + // https://github.com/zloirock/core-js/issues/306 + re = {}; + // RegExp[@@split] doesn't call the regex's exec method, but first creates + // a new one. We need to return the patched regex when creating the new one. + re.constructor = {}; + re.constructor[SPECIES] = function () { return re; }; + re.flags = ''; + re[SYMBOL] = /./[SYMBOL]; + } + + re.exec = function () { + execCalled = true; + return null; + }; + + re[SYMBOL](''); + return !execCalled; + }); + + if ( + !DELEGATES_TO_SYMBOL || + !DELEGATES_TO_EXEC || + FORCED + ) { + var nativeRegExpMethod = /./[SYMBOL]; + var methods = exec(SYMBOL, ''[KEY], function (nativeMethod, regexp, str, arg2, forceStringMethod) { + var $exec = regexp.exec; + if ($exec === regexpExec || $exec === RegExpPrototype.exec) { + if (DELEGATES_TO_SYMBOL && !forceStringMethod) { + // The native String method already delegates to @@method (this + // polyfilled function), leasing to infinite recursion. + // We avoid it by directly calling the native @@method method. + return { done: true, value: call(nativeRegExpMethod, regexp, str, arg2) }; + } + return { done: true, value: call(nativeMethod, str, regexp, arg2) }; + } + return { done: false }; + }); + + defineBuiltIn(String.prototype, KEY, methods[0]); + defineBuiltIn(RegExpPrototype, SYMBOL, methods[1]); + } + + if (SHAM) createNonEnumerableProperty(RegExpPrototype[SYMBOL], 'sham', true); + }; + return fixRegexpWellKnownSymbolLogic; +} + +var advanceStringIndex; +var hasRequiredAdvanceStringIndex; + +function requireAdvanceStringIndex () { + if (hasRequiredAdvanceStringIndex) return advanceStringIndex; + hasRequiredAdvanceStringIndex = 1; + var charAt = requireStringMultibyte().charAt; + + // `AdvanceStringIndex` abstract operation + // https://tc39.es/ecma262/#sec-advancestringindex + advanceStringIndex = function (S, index, unicode) { + return index + (unicode ? charAt(S, index).length : 1); + }; + return advanceStringIndex; +} + +var regexpExecAbstract; +var hasRequiredRegexpExecAbstract; + +function requireRegexpExecAbstract () { + if (hasRequiredRegexpExecAbstract) return regexpExecAbstract; + hasRequiredRegexpExecAbstract = 1; + var call = requireFunctionCall(); + var anObject = requireAnObject(); + var isCallable = requireIsCallable(); + var classof = requireClassofRaw(); + var regexpExec = requireRegexpExec(); + + var $TypeError = TypeError; + + // `RegExpExec` abstract operation + // https://tc39.es/ecma262/#sec-regexpexec + regexpExecAbstract = function (R, S) { + var exec = R.exec; + if (isCallable(exec)) { + var result = call(exec, R, S); + if (result !== null) anObject(result); + return result; + } + if (classof(R) === 'RegExp') return call(regexpExec, R, S); + throw new $TypeError('RegExp#exec called on incompatible receiver'); + }; + return regexpExecAbstract; +} + +var hasRequiredEs_string_match; + +function requireEs_string_match () { + if (hasRequiredEs_string_match) return es_string_match; + hasRequiredEs_string_match = 1; + var call = requireFunctionCall(); + var fixRegExpWellKnownSymbolLogic = requireFixRegexpWellKnownSymbolLogic(); + var anObject = requireAnObject(); + var isNullOrUndefined = requireIsNullOrUndefined(); + var toLength = requireToLength(); + var toString = requireToString(); + var requireObjectCoercible = requireRequireObjectCoercible(); + var getMethod = requireGetMethod(); + var advanceStringIndex = requireAdvanceStringIndex(); + var regExpExec = requireRegexpExecAbstract(); + + // @@match logic + fixRegExpWellKnownSymbolLogic('match', function (MATCH, nativeMatch, maybeCallNative) { + return [ + // `String.prototype.match` method + // https://tc39.es/ecma262/#sec-string.prototype.match + function match(regexp) { + var O = requireObjectCoercible(this); + var matcher = isNullOrUndefined(regexp) ? undefined : getMethod(regexp, MATCH); + return matcher ? call(matcher, regexp, O) : new RegExp(regexp)[MATCH](toString(O)); + }, + // `RegExp.prototype[@@match]` method + // https://tc39.es/ecma262/#sec-regexp.prototype-@@match + function (string) { + var rx = anObject(this); + var S = toString(string); + var res = maybeCallNative(nativeMatch, rx, S); + + if (res.done) return res.value; + + if (!rx.global) return regExpExec(rx, S); + + var fullUnicode = rx.unicode; + rx.lastIndex = 0; + var A = []; + var n = 0; + var result; + while ((result = regExpExec(rx, S)) !== null) { + var matchStr = toString(result[0]); + A[n] = matchStr; + if (matchStr === '') rx.lastIndex = advanceStringIndex(S, toLength(rx.lastIndex), fullUnicode); + n++; + } + return n === 0 ? null : A; + } + ]; + }); + return es_string_match; +} + +var es_string_matchAll = {}; + +var hasRequiredEs_string_matchAll; + +function requireEs_string_matchAll () { + if (hasRequiredEs_string_matchAll) return es_string_matchAll; + hasRequiredEs_string_matchAll = 1; + /* eslint-disable es/no-string-prototype-matchall -- safe */ + var $ = require_export(); + var call = requireFunctionCall(); + var uncurryThis = requireFunctionUncurryThisClause(); + var createIteratorConstructor = requireIteratorCreateConstructor(); + var createIterResultObject = requireCreateIterResultObject(); + var requireObjectCoercible = requireRequireObjectCoercible(); + var toLength = requireToLength(); + var toString = requireToString(); + var anObject = requireAnObject(); + var isNullOrUndefined = requireIsNullOrUndefined(); + var classof = requireClassofRaw(); + var isRegExp = requireIsRegexp(); + var getRegExpFlags = requireRegexpGetFlags(); + var getMethod = requireGetMethod(); + var defineBuiltIn = requireDefineBuiltIn(); + var fails = requireFails(); + var wellKnownSymbol = requireWellKnownSymbol(); + var speciesConstructor = requireSpeciesConstructor(); + var advanceStringIndex = requireAdvanceStringIndex(); + var regExpExec = requireRegexpExecAbstract(); + var InternalStateModule = requireInternalState(); + var IS_PURE = requireIsPure(); + + var MATCH_ALL = wellKnownSymbol('matchAll'); + var REGEXP_STRING = 'RegExp String'; + var REGEXP_STRING_ITERATOR = REGEXP_STRING + ' Iterator'; + var setInternalState = InternalStateModule.set; + var getInternalState = InternalStateModule.getterFor(REGEXP_STRING_ITERATOR); + var RegExpPrototype = RegExp.prototype; + var $TypeError = TypeError; + var stringIndexOf = uncurryThis(''.indexOf); + var nativeMatchAll = uncurryThis(''.matchAll); + + var WORKS_WITH_NON_GLOBAL_REGEX = !!nativeMatchAll && !fails(function () { + nativeMatchAll('a', /./); + }); + + var $RegExpStringIterator = createIteratorConstructor(function RegExpStringIterator(regexp, string, $global, fullUnicode) { + setInternalState(this, { + type: REGEXP_STRING_ITERATOR, + regexp: regexp, + string: string, + global: $global, + unicode: fullUnicode, + done: false + }); + }, REGEXP_STRING, function next() { + var state = getInternalState(this); + if (state.done) return createIterResultObject(undefined, true); + var R = state.regexp; + var S = state.string; + var match = regExpExec(R, S); + if (match === null) { + state.done = true; + return createIterResultObject(undefined, true); + } + if (state.global) { + if (toString(match[0]) === '') R.lastIndex = advanceStringIndex(S, toLength(R.lastIndex), state.unicode); + return createIterResultObject(match, false); + } + state.done = true; + return createIterResultObject(match, false); + }); + + var $matchAll = function (string) { + var R = anObject(this); + var S = toString(string); + var C = speciesConstructor(R, RegExp); + var flags = toString(getRegExpFlags(R)); + var matcher, $global, fullUnicode; + matcher = new C(C === RegExp ? R.source : R, flags); + $global = !!~stringIndexOf(flags, 'g'); + fullUnicode = !!~stringIndexOf(flags, 'u'); + matcher.lastIndex = toLength(R.lastIndex); + return new $RegExpStringIterator(matcher, S, $global, fullUnicode); + }; + + // `String.prototype.matchAll` method + // https://tc39.es/ecma262/#sec-string.prototype.matchall + $({ target: 'String', proto: true, forced: WORKS_WITH_NON_GLOBAL_REGEX }, { + matchAll: function matchAll(regexp) { + var O = requireObjectCoercible(this); + var flags, S, matcher, rx; + if (!isNullOrUndefined(regexp)) { + if (isRegExp(regexp)) { + flags = toString(requireObjectCoercible(getRegExpFlags(regexp))); + if (!~stringIndexOf(flags, 'g')) throw new $TypeError('`.matchAll` does not allow non-global regexes'); + } + if (WORKS_WITH_NON_GLOBAL_REGEX) return nativeMatchAll(O, regexp); + matcher = getMethod(regexp, MATCH_ALL); + if (matcher === undefined && IS_PURE && classof(regexp) === 'RegExp') matcher = $matchAll; + if (matcher) return call(matcher, regexp, O); + } else if (WORKS_WITH_NON_GLOBAL_REGEX) return nativeMatchAll(O, regexp); + S = toString(O); + rx = new RegExp(regexp, 'g'); + return IS_PURE ? call($matchAll, rx, S) : rx[MATCH_ALL](S); + } + }); + + IS_PURE || MATCH_ALL in RegExpPrototype || defineBuiltIn(RegExpPrototype, MATCH_ALL, $matchAll); + return es_string_matchAll; +} + +var es_string_padEnd = {}; + +var stringPadWebkitBug; +var hasRequiredStringPadWebkitBug; + +function requireStringPadWebkitBug () { + if (hasRequiredStringPadWebkitBug) return stringPadWebkitBug; + hasRequiredStringPadWebkitBug = 1; + // https://github.com/zloirock/core-js/issues/280 + var userAgent = requireEnvironmentUserAgent(); + + stringPadWebkitBug = /Version\/10(?:\.\d+){1,2}(?: [\w./]+)?(?: Mobile\/\w+)? Safari\//.test(userAgent); + return stringPadWebkitBug; +} + +var hasRequiredEs_string_padEnd; + +function requireEs_string_padEnd () { + if (hasRequiredEs_string_padEnd) return es_string_padEnd; + hasRequiredEs_string_padEnd = 1; + var $ = require_export(); + var $padEnd = requireStringPad().end; + var WEBKIT_BUG = requireStringPadWebkitBug(); + + // `String.prototype.padEnd` method + // https://tc39.es/ecma262/#sec-string.prototype.padend + $({ target: 'String', proto: true, forced: WEBKIT_BUG }, { + padEnd: function padEnd(maxLength /* , fillString = ' ' */) { + return $padEnd(this, maxLength, arguments.length > 1 ? arguments[1] : undefined); + } + }); + return es_string_padEnd; +} + +var es_string_padStart = {}; + +var hasRequiredEs_string_padStart; + +function requireEs_string_padStart () { + if (hasRequiredEs_string_padStart) return es_string_padStart; + hasRequiredEs_string_padStart = 1; + var $ = require_export(); + var $padStart = requireStringPad().start; + var WEBKIT_BUG = requireStringPadWebkitBug(); + + // `String.prototype.padStart` method + // https://tc39.es/ecma262/#sec-string.prototype.padstart + $({ target: 'String', proto: true, forced: WEBKIT_BUG }, { + padStart: function padStart(maxLength /* , fillString = ' ' */) { + return $padStart(this, maxLength, arguments.length > 1 ? arguments[1] : undefined); + } + }); + return es_string_padStart; +} + +var es_string_raw = {}; + +var hasRequiredEs_string_raw; + +function requireEs_string_raw () { + if (hasRequiredEs_string_raw) return es_string_raw; + hasRequiredEs_string_raw = 1; + var $ = require_export(); + var uncurryThis = requireFunctionUncurryThis(); + var toIndexedObject = requireToIndexedObject(); + var toObject = requireToObject(); + var toString = requireToString(); + var lengthOfArrayLike = requireLengthOfArrayLike(); + + var push = uncurryThis([].push); + var join = uncurryThis([].join); + + // `String.raw` method + // https://tc39.es/ecma262/#sec-string.raw + $({ target: 'String', stat: true }, { + raw: function raw(template) { + var rawTemplate = toIndexedObject(toObject(template).raw); + var literalSegments = lengthOfArrayLike(rawTemplate); + if (!literalSegments) return ''; + var argumentsLength = arguments.length; + var elements = []; + var i = 0; + while (true) { + push(elements, toString(rawTemplate[i++])); + if (i === literalSegments) return join(elements, ''); + if (i < argumentsLength) push(elements, toString(arguments[i])); + } + } + }); + return es_string_raw; +} + +var es_string_repeat = {}; + +var hasRequiredEs_string_repeat; + +function requireEs_string_repeat () { + if (hasRequiredEs_string_repeat) return es_string_repeat; + hasRequiredEs_string_repeat = 1; + var $ = require_export(); + var repeat = requireStringRepeat(); + + // `String.prototype.repeat` method + // https://tc39.es/ecma262/#sec-string.prototype.repeat + $({ target: 'String', proto: true }, { + repeat: repeat + }); + return es_string_repeat; +} + +var es_string_replace = {}; + +var getSubstitution; +var hasRequiredGetSubstitution; + +function requireGetSubstitution () { + if (hasRequiredGetSubstitution) return getSubstitution; + hasRequiredGetSubstitution = 1; + var uncurryThis = requireFunctionUncurryThis(); + var toObject = requireToObject(); + + var floor = Math.floor; + var charAt = uncurryThis(''.charAt); + var replace = uncurryThis(''.replace); + var stringSlice = uncurryThis(''.slice); + // eslint-disable-next-line redos/no-vulnerable -- safe + var SUBSTITUTION_SYMBOLS = /\$([$&'`]|\d{1,2}|<[^>]*>)/g; + var SUBSTITUTION_SYMBOLS_NO_NAMED = /\$([$&'`]|\d{1,2})/g; + + // `GetSubstitution` abstract operation + // https://tc39.es/ecma262/#sec-getsubstitution + getSubstitution = function (matched, str, position, captures, namedCaptures, replacement) { + var tailPos = position + matched.length; + var m = captures.length; + var symbols = SUBSTITUTION_SYMBOLS_NO_NAMED; + if (namedCaptures !== undefined) { + namedCaptures = toObject(namedCaptures); + symbols = SUBSTITUTION_SYMBOLS; + } + return replace(replacement, symbols, function (match, ch) { + var capture; + switch (charAt(ch, 0)) { + case '$': return '$'; + case '&': return matched; + case '`': return stringSlice(str, 0, position); + case "'": return stringSlice(str, tailPos); + case '<': + capture = namedCaptures[stringSlice(ch, 1, -1)]; + break; + default: // \d\d? + var n = +ch; + if (n === 0) return match; + if (n > m) { + var f = floor(n / 10); + if (f === 0) return match; + if (f <= m) return captures[f - 1] === undefined ? charAt(ch, 1) : captures[f - 1] + charAt(ch, 1); + return match; + } + capture = captures[n - 1]; + } + return capture === undefined ? '' : capture; + }); + }; + return getSubstitution; +} + +var hasRequiredEs_string_replace; + +function requireEs_string_replace () { + if (hasRequiredEs_string_replace) return es_string_replace; + hasRequiredEs_string_replace = 1; + var apply = requireFunctionApply(); + var call = requireFunctionCall(); + var uncurryThis = requireFunctionUncurryThis(); + var fixRegExpWellKnownSymbolLogic = requireFixRegexpWellKnownSymbolLogic(); + var fails = requireFails(); + var anObject = requireAnObject(); + var isCallable = requireIsCallable(); + var isNullOrUndefined = requireIsNullOrUndefined(); + var toIntegerOrInfinity = requireToIntegerOrInfinity(); + var toLength = requireToLength(); + var toString = requireToString(); + var requireObjectCoercible = requireRequireObjectCoercible(); + var advanceStringIndex = requireAdvanceStringIndex(); + var getMethod = requireGetMethod(); + var getSubstitution = requireGetSubstitution(); + var regExpExec = requireRegexpExecAbstract(); + var wellKnownSymbol = requireWellKnownSymbol(); + + var REPLACE = wellKnownSymbol('replace'); + var max = Math.max; + var min = Math.min; + var concat = uncurryThis([].concat); + var push = uncurryThis([].push); + var stringIndexOf = uncurryThis(''.indexOf); + var stringSlice = uncurryThis(''.slice); + + var maybeToString = function (it) { + return it === undefined ? it : String(it); + }; + + // IE <= 11 replaces $0 with the whole match, as if it was $& + // https://stackoverflow.com/questions/6024666/getting-ie-to-replace-a-regex-with-the-literal-string-0 + var REPLACE_KEEPS_$0 = (function () { + // eslint-disable-next-line regexp/prefer-escape-replacement-dollar-char -- required for testing + return 'a'.replace(/./, '$0') === '$0'; + })(); + + // Safari <= 13.0.3(?) substitutes nth capture where n>m with an empty string + var REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE = (function () { + if (/./[REPLACE]) { + return /./[REPLACE]('a', '$0') === ''; + } + return false; + })(); + + var REPLACE_SUPPORTS_NAMED_GROUPS = !fails(function () { + var re = /./; + re.exec = function () { + var result = []; + result.groups = { a: '7' }; + return result; + }; + // eslint-disable-next-line regexp/no-useless-dollar-replacements -- false positive + return ''.replace(re, '$') !== '7'; + }); + + // @@replace logic + fixRegExpWellKnownSymbolLogic('replace', function (_, nativeReplace, maybeCallNative) { + var UNSAFE_SUBSTITUTE = REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE ? '$' : '$0'; + + return [ + // `String.prototype.replace` method + // https://tc39.es/ecma262/#sec-string.prototype.replace + function replace(searchValue, replaceValue) { + var O = requireObjectCoercible(this); + var replacer = isNullOrUndefined(searchValue) ? undefined : getMethod(searchValue, REPLACE); + return replacer + ? call(replacer, searchValue, O, replaceValue) + : call(nativeReplace, toString(O), searchValue, replaceValue); + }, + // `RegExp.prototype[@@replace]` method + // https://tc39.es/ecma262/#sec-regexp.prototype-@@replace + function (string, replaceValue) { + var rx = anObject(this); + var S = toString(string); + + if ( + typeof replaceValue == 'string' && + stringIndexOf(replaceValue, UNSAFE_SUBSTITUTE) === -1 && + stringIndexOf(replaceValue, '$<') === -1 + ) { + var res = maybeCallNative(nativeReplace, rx, S, replaceValue); + if (res.done) return res.value; + } + + var functionalReplace = isCallable(replaceValue); + if (!functionalReplace) replaceValue = toString(replaceValue); + + var global = rx.global; + var fullUnicode; + if (global) { + fullUnicode = rx.unicode; + rx.lastIndex = 0; + } + + var results = []; + var result; + while (true) { + result = regExpExec(rx, S); + if (result === null) break; + + push(results, result); + if (!global) break; + + var matchStr = toString(result[0]); + if (matchStr === '') rx.lastIndex = advanceStringIndex(S, toLength(rx.lastIndex), fullUnicode); + } + + var accumulatedResult = ''; + var nextSourcePosition = 0; + for (var i = 0; i < results.length; i++) { + result = results[i]; + + var matched = toString(result[0]); + var position = max(min(toIntegerOrInfinity(result.index), S.length), 0); + var captures = []; + var replacement; + // NOTE: This is equivalent to + // captures = result.slice(1).map(maybeToString) + // but for some reason `nativeSlice.call(result, 1, result.length)` (called in + // the slice polyfill when slicing native arrays) "doesn't work" in safari 9 and + // causes a crash (https://pastebin.com/N21QzeQA) when trying to debug it. + for (var j = 1; j < result.length; j++) push(captures, maybeToString(result[j])); + var namedCaptures = result.groups; + if (functionalReplace) { + var replacerArgs = concat([matched], captures, position, S); + if (namedCaptures !== undefined) push(replacerArgs, namedCaptures); + replacement = toString(apply(replaceValue, undefined, replacerArgs)); + } else { + replacement = getSubstitution(matched, S, position, captures, namedCaptures, replaceValue); + } + if (position >= nextSourcePosition) { + accumulatedResult += stringSlice(S, nextSourcePosition, position) + replacement; + nextSourcePosition = position + matched.length; + } + } + + return accumulatedResult + stringSlice(S, nextSourcePosition); + } + ]; + }, !REPLACE_SUPPORTS_NAMED_GROUPS || !REPLACE_KEEPS_$0 || REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE); + return es_string_replace; +} + +var es_string_replaceAll = {}; + +var hasRequiredEs_string_replaceAll; + +function requireEs_string_replaceAll () { + if (hasRequiredEs_string_replaceAll) return es_string_replaceAll; + hasRequiredEs_string_replaceAll = 1; + var $ = require_export(); + var call = requireFunctionCall(); + var uncurryThis = requireFunctionUncurryThis(); + var requireObjectCoercible = requireRequireObjectCoercible(); + var isCallable = requireIsCallable(); + var isNullOrUndefined = requireIsNullOrUndefined(); + var isRegExp = requireIsRegexp(); + var toString = requireToString(); + var getMethod = requireGetMethod(); + var getRegExpFlags = requireRegexpGetFlags(); + var getSubstitution = requireGetSubstitution(); + var wellKnownSymbol = requireWellKnownSymbol(); + var IS_PURE = requireIsPure(); + + var REPLACE = wellKnownSymbol('replace'); + var $TypeError = TypeError; + var indexOf = uncurryThis(''.indexOf); + var replace = uncurryThis(''.replace); + var stringSlice = uncurryThis(''.slice); + var max = Math.max; + + // `String.prototype.replaceAll` method + // https://tc39.es/ecma262/#sec-string.prototype.replaceall + $({ target: 'String', proto: true }, { + replaceAll: function replaceAll(searchValue, replaceValue) { + var O = requireObjectCoercible(this); + var IS_REG_EXP, flags, replacer, string, searchString, functionalReplace, searchLength, advanceBy, position, replacement; + var endOfLastMatch = 0; + var result = ''; + if (!isNullOrUndefined(searchValue)) { + IS_REG_EXP = isRegExp(searchValue); + if (IS_REG_EXP) { + flags = toString(requireObjectCoercible(getRegExpFlags(searchValue))); + if (!~indexOf(flags, 'g')) throw new $TypeError('`.replaceAll` does not allow non-global regexes'); + } + replacer = getMethod(searchValue, REPLACE); + if (replacer) return call(replacer, searchValue, O, replaceValue); + if (IS_PURE && IS_REG_EXP) return replace(toString(O), searchValue, replaceValue); + } + string = toString(O); + searchString = toString(searchValue); + functionalReplace = isCallable(replaceValue); + if (!functionalReplace) replaceValue = toString(replaceValue); + searchLength = searchString.length; + advanceBy = max(1, searchLength); + position = indexOf(string, searchString); + while (position !== -1) { + replacement = functionalReplace + ? toString(replaceValue(searchString, position, string)) + : getSubstitution(searchString, string, position, [], undefined, replaceValue); + result += stringSlice(string, endOfLastMatch, position) + replacement; + endOfLastMatch = position + searchLength; + position = position + advanceBy > string.length ? -1 : indexOf(string, searchString, position + advanceBy); + } + if (endOfLastMatch < string.length) { + result += stringSlice(string, endOfLastMatch); + } + return result; + } + }); + return es_string_replaceAll; +} + +var es_string_search = {}; + +var hasRequiredEs_string_search; + +function requireEs_string_search () { + if (hasRequiredEs_string_search) return es_string_search; + hasRequiredEs_string_search = 1; + var call = requireFunctionCall(); + var fixRegExpWellKnownSymbolLogic = requireFixRegexpWellKnownSymbolLogic(); + var anObject = requireAnObject(); + var isNullOrUndefined = requireIsNullOrUndefined(); + var requireObjectCoercible = requireRequireObjectCoercible(); + var sameValue = requireSameValue(); + var toString = requireToString(); + var getMethod = requireGetMethod(); + var regExpExec = requireRegexpExecAbstract(); + + // @@search logic + fixRegExpWellKnownSymbolLogic('search', function (SEARCH, nativeSearch, maybeCallNative) { + return [ + // `String.prototype.search` method + // https://tc39.es/ecma262/#sec-string.prototype.search + function search(regexp) { + var O = requireObjectCoercible(this); + var searcher = isNullOrUndefined(regexp) ? undefined : getMethod(regexp, SEARCH); + return searcher ? call(searcher, regexp, O) : new RegExp(regexp)[SEARCH](toString(O)); + }, + // `RegExp.prototype[@@search]` method + // https://tc39.es/ecma262/#sec-regexp.prototype-@@search + function (string) { + var rx = anObject(this); + var S = toString(string); + var res = maybeCallNative(nativeSearch, rx, S); + + if (res.done) return res.value; + + var previousLastIndex = rx.lastIndex; + if (!sameValue(previousLastIndex, 0)) rx.lastIndex = 0; + var result = regExpExec(rx, S); + if (!sameValue(rx.lastIndex, previousLastIndex)) rx.lastIndex = previousLastIndex; + return result === null ? -1 : result.index; + } + ]; + }); + return es_string_search; +} + +var es_string_split = {}; + +var hasRequiredEs_string_split; + +function requireEs_string_split () { + if (hasRequiredEs_string_split) return es_string_split; + hasRequiredEs_string_split = 1; + var call = requireFunctionCall(); + var uncurryThis = requireFunctionUncurryThis(); + var fixRegExpWellKnownSymbolLogic = requireFixRegexpWellKnownSymbolLogic(); + var anObject = requireAnObject(); + var isNullOrUndefined = requireIsNullOrUndefined(); + var requireObjectCoercible = requireRequireObjectCoercible(); + var speciesConstructor = requireSpeciesConstructor(); + var advanceStringIndex = requireAdvanceStringIndex(); + var toLength = requireToLength(); + var toString = requireToString(); + var getMethod = requireGetMethod(); + var regExpExec = requireRegexpExecAbstract(); + var stickyHelpers = requireRegexpStickyHelpers(); + var fails = requireFails(); + + var UNSUPPORTED_Y = stickyHelpers.UNSUPPORTED_Y; + var MAX_UINT32 = 0xFFFFFFFF; + var min = Math.min; + var push = uncurryThis([].push); + var stringSlice = uncurryThis(''.slice); + + // Chrome 51 has a buggy "split" implementation when RegExp#exec !== nativeExec + // Weex JS has frozen built-in prototypes, so use try / catch wrapper + var SPLIT_WORKS_WITH_OVERWRITTEN_EXEC = !fails(function () { + // eslint-disable-next-line regexp/no-empty-group -- required for testing + var re = /(?:)/; + var originalExec = re.exec; + re.exec = function () { return originalExec.apply(this, arguments); }; + var result = 'ab'.split(re); + return result.length !== 2 || result[0] !== 'a' || result[1] !== 'b'; + }); + + var BUGGY = 'abbc'.split(/(b)*/)[1] === 'c' || + // eslint-disable-next-line regexp/no-empty-group -- required for testing + 'test'.split(/(?:)/, -1).length !== 4 || + 'ab'.split(/(?:ab)*/).length !== 2 || + '.'.split(/(.?)(.?)/).length !== 4 || + // eslint-disable-next-line regexp/no-empty-capturing-group, regexp/no-empty-group -- required for testing + '.'.split(/()()/).length > 1 || + ''.split(/.?/).length; + + // @@split logic + fixRegExpWellKnownSymbolLogic('split', function (SPLIT, nativeSplit, maybeCallNative) { + var internalSplit = '0'.split(undefined, 0).length ? function (separator, limit) { + return separator === undefined && limit === 0 ? [] : call(nativeSplit, this, separator, limit); + } : nativeSplit; + + return [ + // `String.prototype.split` method + // https://tc39.es/ecma262/#sec-string.prototype.split + function split(separator, limit) { + var O = requireObjectCoercible(this); + var splitter = isNullOrUndefined(separator) ? undefined : getMethod(separator, SPLIT); + return splitter + ? call(splitter, separator, O, limit) + : call(internalSplit, toString(O), separator, limit); + }, + // `RegExp.prototype[@@split]` method + // https://tc39.es/ecma262/#sec-regexp.prototype-@@split + // + // NOTE: This cannot be properly polyfilled in engines that don't support + // the 'y' flag. + function (string, limit) { + var rx = anObject(this); + var S = toString(string); + + if (!BUGGY) { + var res = maybeCallNative(internalSplit, rx, S, limit, internalSplit !== nativeSplit); + if (res.done) return res.value; + } + + var C = speciesConstructor(rx, RegExp); + var unicodeMatching = rx.unicode; + var flags = (rx.ignoreCase ? 'i' : '') + + (rx.multiline ? 'm' : '') + + (rx.unicode ? 'u' : '') + + (UNSUPPORTED_Y ? 'g' : 'y'); + // ^(? + rx + ) is needed, in combination with some S slicing, to + // simulate the 'y' flag. + var splitter = new C(UNSUPPORTED_Y ? '^(?:' + rx.source + ')' : rx, flags); + var lim = limit === undefined ? MAX_UINT32 : limit >>> 0; + if (lim === 0) return []; + if (S.length === 0) return regExpExec(splitter, S) === null ? [S] : []; + var p = 0; + var q = 0; + var A = []; + while (q < S.length) { + splitter.lastIndex = UNSUPPORTED_Y ? 0 : q; + var z = regExpExec(splitter, UNSUPPORTED_Y ? stringSlice(S, q) : S); + var e; + if ( + z === null || + (e = min(toLength(splitter.lastIndex + (UNSUPPORTED_Y ? q : 0)), S.length)) === p + ) { + q = advanceStringIndex(S, q, unicodeMatching); + } else { + push(A, stringSlice(S, p, q)); + if (A.length === lim) return A; + for (var i = 1; i <= z.length - 1; i++) { + push(A, z[i]); + if (A.length === lim) return A; + } + q = p = e; + } + } + push(A, stringSlice(S, p)); + return A; + } + ]; + }, BUGGY || !SPLIT_WORKS_WITH_OVERWRITTEN_EXEC, UNSUPPORTED_Y); + return es_string_split; +} + +var es_string_startsWith = {}; + +var hasRequiredEs_string_startsWith; + +function requireEs_string_startsWith () { + if (hasRequiredEs_string_startsWith) return es_string_startsWith; + hasRequiredEs_string_startsWith = 1; + var $ = require_export(); + var uncurryThis = requireFunctionUncurryThisClause(); + var getOwnPropertyDescriptor = requireObjectGetOwnPropertyDescriptor().f; + var toLength = requireToLength(); + var toString = requireToString(); + var notARegExp = requireNotARegexp(); + var requireObjectCoercible = requireRequireObjectCoercible(); + var correctIsRegExpLogic = requireCorrectIsRegexpLogic(); + var IS_PURE = requireIsPure(); + + var stringSlice = uncurryThis(''.slice); + var min = Math.min; + + var CORRECT_IS_REGEXP_LOGIC = correctIsRegExpLogic('startsWith'); + // https://github.com/zloirock/core-js/pull/702 + var MDN_POLYFILL_BUG = !IS_PURE && !CORRECT_IS_REGEXP_LOGIC && !!function () { + var descriptor = getOwnPropertyDescriptor(String.prototype, 'startsWith'); + return descriptor && !descriptor.writable; + }(); + + // `String.prototype.startsWith` method + // https://tc39.es/ecma262/#sec-string.prototype.startswith + $({ target: 'String', proto: true, forced: !MDN_POLYFILL_BUG && !CORRECT_IS_REGEXP_LOGIC }, { + startsWith: function startsWith(searchString /* , position = 0 */) { + var that = toString(requireObjectCoercible(this)); + notARegExp(searchString); + var index = toLength(min(arguments.length > 1 ? arguments[1] : undefined, that.length)); + var search = toString(searchString); + return stringSlice(that, index, index + search.length) === search; + } + }); + return es_string_startsWith; +} + +var es_string_substr = {}; + +var hasRequiredEs_string_substr; + +function requireEs_string_substr () { + if (hasRequiredEs_string_substr) return es_string_substr; + hasRequiredEs_string_substr = 1; + var $ = require_export(); + var uncurryThis = requireFunctionUncurryThis(); + var requireObjectCoercible = requireRequireObjectCoercible(); + var toIntegerOrInfinity = requireToIntegerOrInfinity(); + var toString = requireToString(); + + var stringSlice = uncurryThis(''.slice); + var max = Math.max; + var min = Math.min; + + // eslint-disable-next-line unicorn/prefer-string-slice -- required for testing + var FORCED = !''.substr || 'ab'.substr(-1) !== 'b'; + + // `String.prototype.substr` method + // https://tc39.es/ecma262/#sec-string.prototype.substr + $({ target: 'String', proto: true, forced: FORCED }, { + substr: function substr(start, length) { + var that = toString(requireObjectCoercible(this)); + var size = that.length; + var intStart = toIntegerOrInfinity(start); + var intLength, intEnd; + if (intStart === Infinity) intStart = 0; + if (intStart < 0) intStart = max(size + intStart, 0); + intLength = length === undefined ? size : toIntegerOrInfinity(length); + if (intLength <= 0 || intLength === Infinity) return ''; + intEnd = min(intStart + intLength, size); + return intStart >= intEnd ? '' : stringSlice(that, intStart, intEnd); + } + }); + return es_string_substr; +} + +var es_string_toWellFormed = {}; + +var hasRequiredEs_string_toWellFormed; + +function requireEs_string_toWellFormed () { + if (hasRequiredEs_string_toWellFormed) return es_string_toWellFormed; + hasRequiredEs_string_toWellFormed = 1; + var $ = require_export(); + var call = requireFunctionCall(); + var uncurryThis = requireFunctionUncurryThis(); + var requireObjectCoercible = requireRequireObjectCoercible(); + var toString = requireToString(); + var fails = requireFails(); + + var $Array = Array; + var charAt = uncurryThis(''.charAt); + var charCodeAt = uncurryThis(''.charCodeAt); + var join = uncurryThis([].join); + // eslint-disable-next-line es/no-string-prototype-towellformed -- safe + var $toWellFormed = ''.toWellFormed; + var REPLACEMENT_CHARACTER = '\uFFFD'; + + // Safari bug + var TO_STRING_CONVERSION_BUG = $toWellFormed && fails(function () { + return call($toWellFormed, 1) !== '1'; + }); + + // `String.prototype.toWellFormed` method + // https://github.com/tc39/proposal-is-usv-string + $({ target: 'String', proto: true, forced: TO_STRING_CONVERSION_BUG }, { + toWellFormed: function toWellFormed() { + var S = toString(requireObjectCoercible(this)); + if (TO_STRING_CONVERSION_BUG) return call($toWellFormed, S); + var length = S.length; + var result = $Array(length); + for (var i = 0; i < length; i++) { + var charCode = charCodeAt(S, i); + // single UTF-16 code unit + if ((charCode & 0xF800) !== 0xD800) result[i] = charAt(S, i); + // unpaired surrogate + else if (charCode >= 0xDC00 || i + 1 >= length || (charCodeAt(S, i + 1) & 0xFC00) !== 0xDC00) result[i] = REPLACEMENT_CHARACTER; + // surrogate pair + else { + result[i] = charAt(S, i); + result[++i] = charAt(S, i); + } + } return join(result, ''); + } + }); + return es_string_toWellFormed; +} + +var es_string_trim = {}; + +var stringTrimForced; +var hasRequiredStringTrimForced; + +function requireStringTrimForced () { + if (hasRequiredStringTrimForced) return stringTrimForced; + hasRequiredStringTrimForced = 1; + var PROPER_FUNCTION_NAME = requireFunctionName().PROPER; + var fails = requireFails(); + var whitespaces = requireWhitespaces(); + + var non = '\u200B\u0085\u180E'; + + // check that a method works with the correct list + // of whitespaces and has a correct name + stringTrimForced = function (METHOD_NAME) { + return fails(function () { + return !!whitespaces[METHOD_NAME]() + || non[METHOD_NAME]() !== non + || (PROPER_FUNCTION_NAME && whitespaces[METHOD_NAME].name !== METHOD_NAME); + }); + }; + return stringTrimForced; +} + +var hasRequiredEs_string_trim; + +function requireEs_string_trim () { + if (hasRequiredEs_string_trim) return es_string_trim; + hasRequiredEs_string_trim = 1; + var $ = require_export(); + var $trim = requireStringTrim().trim; + var forcedStringTrimMethod = requireStringTrimForced(); + + // `String.prototype.trim` method + // https://tc39.es/ecma262/#sec-string.prototype.trim + $({ target: 'String', proto: true, forced: forcedStringTrimMethod('trim') }, { + trim: function trim() { + return $trim(this); + } + }); + return es_string_trim; +} + +var es_string_trimEnd = {}; + +var es_string_trimRight = {}; + +var stringTrimEnd; +var hasRequiredStringTrimEnd; + +function requireStringTrimEnd () { + if (hasRequiredStringTrimEnd) return stringTrimEnd; + hasRequiredStringTrimEnd = 1; + var $trimEnd = requireStringTrim().end; + var forcedStringTrimMethod = requireStringTrimForced(); + + // `String.prototype.{ trimEnd, trimRight }` method + // https://tc39.es/ecma262/#sec-string.prototype.trimend + // https://tc39.es/ecma262/#String.prototype.trimright + stringTrimEnd = forcedStringTrimMethod('trimEnd') ? function trimEnd() { + return $trimEnd(this); + // eslint-disable-next-line es/no-string-prototype-trimstart-trimend -- safe + } : ''.trimEnd; + return stringTrimEnd; +} + +var hasRequiredEs_string_trimRight; + +function requireEs_string_trimRight () { + if (hasRequiredEs_string_trimRight) return es_string_trimRight; + hasRequiredEs_string_trimRight = 1; + var $ = require_export(); + var trimEnd = requireStringTrimEnd(); + + // `String.prototype.trimRight` method + // https://tc39.es/ecma262/#sec-string.prototype.trimend + // eslint-disable-next-line es/no-string-prototype-trimleft-trimright -- safe + $({ target: 'String', proto: true, name: 'trimEnd', forced: ''.trimRight !== trimEnd }, { + trimRight: trimEnd + }); + return es_string_trimRight; +} + +var hasRequiredEs_string_trimEnd; + +function requireEs_string_trimEnd () { + if (hasRequiredEs_string_trimEnd) return es_string_trimEnd; + hasRequiredEs_string_trimEnd = 1; + // TODO: Remove this line from `core-js@4` + requireEs_string_trimRight(); + var $ = require_export(); + var trimEnd = requireStringTrimEnd(); + + // `String.prototype.trimEnd` method + // https://tc39.es/ecma262/#sec-string.prototype.trimend + // eslint-disable-next-line es/no-string-prototype-trimstart-trimend -- safe + $({ target: 'String', proto: true, name: 'trimEnd', forced: ''.trimEnd !== trimEnd }, { + trimEnd: trimEnd + }); + return es_string_trimEnd; +} + +var es_string_trimStart = {}; + +var es_string_trimLeft = {}; + +var stringTrimStart; +var hasRequiredStringTrimStart; + +function requireStringTrimStart () { + if (hasRequiredStringTrimStart) return stringTrimStart; + hasRequiredStringTrimStart = 1; + var $trimStart = requireStringTrim().start; + var forcedStringTrimMethod = requireStringTrimForced(); + + // `String.prototype.{ trimStart, trimLeft }` method + // https://tc39.es/ecma262/#sec-string.prototype.trimstart + // https://tc39.es/ecma262/#String.prototype.trimleft + stringTrimStart = forcedStringTrimMethod('trimStart') ? function trimStart() { + return $trimStart(this); + // eslint-disable-next-line es/no-string-prototype-trimstart-trimend -- safe + } : ''.trimStart; + return stringTrimStart; +} + +var hasRequiredEs_string_trimLeft; + +function requireEs_string_trimLeft () { + if (hasRequiredEs_string_trimLeft) return es_string_trimLeft; + hasRequiredEs_string_trimLeft = 1; + var $ = require_export(); + var trimStart = requireStringTrimStart(); + + // `String.prototype.trimLeft` method + // https://tc39.es/ecma262/#sec-string.prototype.trimleft + // eslint-disable-next-line es/no-string-prototype-trimleft-trimright -- safe + $({ target: 'String', proto: true, name: 'trimStart', forced: ''.trimLeft !== trimStart }, { + trimLeft: trimStart + }); + return es_string_trimLeft; +} + +var hasRequiredEs_string_trimStart; + +function requireEs_string_trimStart () { + if (hasRequiredEs_string_trimStart) return es_string_trimStart; + hasRequiredEs_string_trimStart = 1; + // TODO: Remove this line from `core-js@4` + requireEs_string_trimLeft(); + var $ = require_export(); + var trimStart = requireStringTrimStart(); + + // `String.prototype.trimStart` method + // https://tc39.es/ecma262/#sec-string.prototype.trimstart + // eslint-disable-next-line es/no-string-prototype-trimstart-trimend -- safe + $({ target: 'String', proto: true, name: 'trimStart', forced: ''.trimStart !== trimStart }, { + trimStart: trimStart + }); + return es_string_trimStart; +} + +var es_string_anchor = {}; + +var createHtml; +var hasRequiredCreateHtml; + +function requireCreateHtml () { + if (hasRequiredCreateHtml) return createHtml; + hasRequiredCreateHtml = 1; + var uncurryThis = requireFunctionUncurryThis(); + var requireObjectCoercible = requireRequireObjectCoercible(); + var toString = requireToString(); + + var quot = /"/g; + var replace = uncurryThis(''.replace); + + // `CreateHTML` abstract operation + // https://tc39.es/ecma262/#sec-createhtml + createHtml = function (string, tag, attribute, value) { + var S = toString(requireObjectCoercible(string)); + var p1 = '<' + tag; + if (attribute !== '') p1 += ' ' + attribute + '="' + replace(toString(value), quot, '"') + '"'; + return p1 + '>' + S + ''; + }; + return createHtml; +} + +var stringHtmlForced; +var hasRequiredStringHtmlForced; + +function requireStringHtmlForced () { + if (hasRequiredStringHtmlForced) return stringHtmlForced; + hasRequiredStringHtmlForced = 1; + var fails = requireFails(); + + // check the existence of a method, lowercase + // of a tag and escaping quotes in arguments + stringHtmlForced = function (METHOD_NAME) { + return fails(function () { + var test = ''[METHOD_NAME]('"'); + return test !== test.toLowerCase() || test.split('"').length > 3; + }); + }; + return stringHtmlForced; +} + +var hasRequiredEs_string_anchor; + +function requireEs_string_anchor () { + if (hasRequiredEs_string_anchor) return es_string_anchor; + hasRequiredEs_string_anchor = 1; + var $ = require_export(); + var createHTML = requireCreateHtml(); + var forcedStringHTMLMethod = requireStringHtmlForced(); + + // `String.prototype.anchor` method + // https://tc39.es/ecma262/#sec-string.prototype.anchor + $({ target: 'String', proto: true, forced: forcedStringHTMLMethod('anchor') }, { + anchor: function anchor(name) { + return createHTML(this, 'a', 'name', name); + } + }); + return es_string_anchor; +} + +var es_string_big = {}; + +var hasRequiredEs_string_big; + +function requireEs_string_big () { + if (hasRequiredEs_string_big) return es_string_big; + hasRequiredEs_string_big = 1; + var $ = require_export(); + var createHTML = requireCreateHtml(); + var forcedStringHTMLMethod = requireStringHtmlForced(); + + // `String.prototype.big` method + // https://tc39.es/ecma262/#sec-string.prototype.big + $({ target: 'String', proto: true, forced: forcedStringHTMLMethod('big') }, { + big: function big() { + return createHTML(this, 'big', '', ''); + } + }); + return es_string_big; +} + +var es_string_blink = {}; + +var hasRequiredEs_string_blink; + +function requireEs_string_blink () { + if (hasRequiredEs_string_blink) return es_string_blink; + hasRequiredEs_string_blink = 1; + var $ = require_export(); + var createHTML = requireCreateHtml(); + var forcedStringHTMLMethod = requireStringHtmlForced(); + + // `String.prototype.blink` method + // https://tc39.es/ecma262/#sec-string.prototype.blink + $({ target: 'String', proto: true, forced: forcedStringHTMLMethod('blink') }, { + blink: function blink() { + return createHTML(this, 'blink', '', ''); + } + }); + return es_string_blink; +} + +var es_string_bold = {}; + +var hasRequiredEs_string_bold; + +function requireEs_string_bold () { + if (hasRequiredEs_string_bold) return es_string_bold; + hasRequiredEs_string_bold = 1; + var $ = require_export(); + var createHTML = requireCreateHtml(); + var forcedStringHTMLMethod = requireStringHtmlForced(); + + // `String.prototype.bold` method + // https://tc39.es/ecma262/#sec-string.prototype.bold + $({ target: 'String', proto: true, forced: forcedStringHTMLMethod('bold') }, { + bold: function bold() { + return createHTML(this, 'b', '', ''); + } + }); + return es_string_bold; +} + +var es_string_fixed = {}; + +var hasRequiredEs_string_fixed; + +function requireEs_string_fixed () { + if (hasRequiredEs_string_fixed) return es_string_fixed; + hasRequiredEs_string_fixed = 1; + var $ = require_export(); + var createHTML = requireCreateHtml(); + var forcedStringHTMLMethod = requireStringHtmlForced(); + + // `String.prototype.fixed` method + // https://tc39.es/ecma262/#sec-string.prototype.fixed + $({ target: 'String', proto: true, forced: forcedStringHTMLMethod('fixed') }, { + fixed: function fixed() { + return createHTML(this, 'tt', '', ''); + } + }); + return es_string_fixed; +} + +var es_string_fontcolor = {}; + +var hasRequiredEs_string_fontcolor; + +function requireEs_string_fontcolor () { + if (hasRequiredEs_string_fontcolor) return es_string_fontcolor; + hasRequiredEs_string_fontcolor = 1; + var $ = require_export(); + var createHTML = requireCreateHtml(); + var forcedStringHTMLMethod = requireStringHtmlForced(); + + // `String.prototype.fontcolor` method + // https://tc39.es/ecma262/#sec-string.prototype.fontcolor + $({ target: 'String', proto: true, forced: forcedStringHTMLMethod('fontcolor') }, { + fontcolor: function fontcolor(color) { + return createHTML(this, 'font', 'color', color); + } + }); + return es_string_fontcolor; +} + +var es_string_fontsize = {}; + +var hasRequiredEs_string_fontsize; + +function requireEs_string_fontsize () { + if (hasRequiredEs_string_fontsize) return es_string_fontsize; + hasRequiredEs_string_fontsize = 1; + var $ = require_export(); + var createHTML = requireCreateHtml(); + var forcedStringHTMLMethod = requireStringHtmlForced(); + + // `String.prototype.fontsize` method + // https://tc39.es/ecma262/#sec-string.prototype.fontsize + $({ target: 'String', proto: true, forced: forcedStringHTMLMethod('fontsize') }, { + fontsize: function fontsize(size) { + return createHTML(this, 'font', 'size', size); + } + }); + return es_string_fontsize; +} + +var es_string_italics = {}; + +var hasRequiredEs_string_italics; + +function requireEs_string_italics () { + if (hasRequiredEs_string_italics) return es_string_italics; + hasRequiredEs_string_italics = 1; + var $ = require_export(); + var createHTML = requireCreateHtml(); + var forcedStringHTMLMethod = requireStringHtmlForced(); + + // `String.prototype.italics` method + // https://tc39.es/ecma262/#sec-string.prototype.italics + $({ target: 'String', proto: true, forced: forcedStringHTMLMethod('italics') }, { + italics: function italics() { + return createHTML(this, 'i', '', ''); + } + }); + return es_string_italics; +} + +var es_string_link = {}; + +var hasRequiredEs_string_link; + +function requireEs_string_link () { + if (hasRequiredEs_string_link) return es_string_link; + hasRequiredEs_string_link = 1; + var $ = require_export(); + var createHTML = requireCreateHtml(); + var forcedStringHTMLMethod = requireStringHtmlForced(); + + // `String.prototype.link` method + // https://tc39.es/ecma262/#sec-string.prototype.link + $({ target: 'String', proto: true, forced: forcedStringHTMLMethod('link') }, { + link: function link(url) { + return createHTML(this, 'a', 'href', url); + } + }); + return es_string_link; +} + +var es_string_small = {}; + +var hasRequiredEs_string_small; + +function requireEs_string_small () { + if (hasRequiredEs_string_small) return es_string_small; + hasRequiredEs_string_small = 1; + var $ = require_export(); + var createHTML = requireCreateHtml(); + var forcedStringHTMLMethod = requireStringHtmlForced(); + + // `String.prototype.small` method + // https://tc39.es/ecma262/#sec-string.prototype.small + $({ target: 'String', proto: true, forced: forcedStringHTMLMethod('small') }, { + small: function small() { + return createHTML(this, 'small', '', ''); + } + }); + return es_string_small; +} + +var es_string_strike = {}; + +var hasRequiredEs_string_strike; + +function requireEs_string_strike () { + if (hasRequiredEs_string_strike) return es_string_strike; + hasRequiredEs_string_strike = 1; + var $ = require_export(); + var createHTML = requireCreateHtml(); + var forcedStringHTMLMethod = requireStringHtmlForced(); + + // `String.prototype.strike` method + // https://tc39.es/ecma262/#sec-string.prototype.strike + $({ target: 'String', proto: true, forced: forcedStringHTMLMethod('strike') }, { + strike: function strike() { + return createHTML(this, 'strike', '', ''); + } + }); + return es_string_strike; +} + +var es_string_sub = {}; + +var hasRequiredEs_string_sub; + +function requireEs_string_sub () { + if (hasRequiredEs_string_sub) return es_string_sub; + hasRequiredEs_string_sub = 1; + var $ = require_export(); + var createHTML = requireCreateHtml(); + var forcedStringHTMLMethod = requireStringHtmlForced(); + + // `String.prototype.sub` method + // https://tc39.es/ecma262/#sec-string.prototype.sub + $({ target: 'String', proto: true, forced: forcedStringHTMLMethod('sub') }, { + sub: function sub() { + return createHTML(this, 'sub', '', ''); + } + }); + return es_string_sub; +} + +var es_string_sup = {}; + +var hasRequiredEs_string_sup; + +function requireEs_string_sup () { + if (hasRequiredEs_string_sup) return es_string_sup; + hasRequiredEs_string_sup = 1; + var $ = require_export(); + var createHTML = requireCreateHtml(); + var forcedStringHTMLMethod = requireStringHtmlForced(); + + // `String.prototype.sup` method + // https://tc39.es/ecma262/#sec-string.prototype.sup + $({ target: 'String', proto: true, forced: forcedStringHTMLMethod('sup') }, { + sup: function sup() { + return createHTML(this, 'sup', '', ''); + } + }); + return es_string_sup; +} + +var es_typedArray_float32Array = {}; + +var typedArrayConstructor = {exports: {}}; + +var typedArrayConstructorsRequireWrappers; +var hasRequiredTypedArrayConstructorsRequireWrappers; + +function requireTypedArrayConstructorsRequireWrappers () { + if (hasRequiredTypedArrayConstructorsRequireWrappers) return typedArrayConstructorsRequireWrappers; + hasRequiredTypedArrayConstructorsRequireWrappers = 1; + /* eslint-disable no-new, sonar/inconsistent-function-call -- required for testing */ + var globalThis = requireGlobalThis(); + var fails = requireFails(); + var checkCorrectnessOfIteration = requireCheckCorrectnessOfIteration(); + var NATIVE_ARRAY_BUFFER_VIEWS = requireArrayBufferViewCore().NATIVE_ARRAY_BUFFER_VIEWS; + + var ArrayBuffer = globalThis.ArrayBuffer; + var Int8Array = globalThis.Int8Array; + + typedArrayConstructorsRequireWrappers = !NATIVE_ARRAY_BUFFER_VIEWS || !fails(function () { + Int8Array(1); + }) || !fails(function () { + new Int8Array(-1); + }) || !checkCorrectnessOfIteration(function (iterable) { + new Int8Array(); + new Int8Array(null); + new Int8Array(1.5); + new Int8Array(iterable); + }, true) || fails(function () { + // Safari (11+) bug - a reason why even Safari 13 should load a typed array polyfill + return new Int8Array(new ArrayBuffer(2), 1, undefined).length !== 1; + }); + return typedArrayConstructorsRequireWrappers; +} + +var toPositiveInteger; +var hasRequiredToPositiveInteger; + +function requireToPositiveInteger () { + if (hasRequiredToPositiveInteger) return toPositiveInteger; + hasRequiredToPositiveInteger = 1; + var toIntegerOrInfinity = requireToIntegerOrInfinity(); + + var $RangeError = RangeError; + + toPositiveInteger = function (it) { + var result = toIntegerOrInfinity(it); + if (result < 0) throw new $RangeError("The argument can't be less than 0"); + return result; + }; + return toPositiveInteger; +} + +var toOffset; +var hasRequiredToOffset; + +function requireToOffset () { + if (hasRequiredToOffset) return toOffset; + hasRequiredToOffset = 1; + var toPositiveInteger = requireToPositiveInteger(); + + var $RangeError = RangeError; + + toOffset = function (it, BYTES) { + var offset = toPositiveInteger(it); + if (offset % BYTES) throw new $RangeError('Wrong offset'); + return offset; + }; + return toOffset; +} + +var toUint8Clamped; +var hasRequiredToUint8Clamped; + +function requireToUint8Clamped () { + if (hasRequiredToUint8Clamped) return toUint8Clamped; + hasRequiredToUint8Clamped = 1; + var round = Math.round; + + toUint8Clamped = function (it) { + var value = round(it); + return value < 0 ? 0 : value > 0xFF ? 0xFF : value & 0xFF; + }; + return toUint8Clamped; +} + +var isBigIntArray; +var hasRequiredIsBigIntArray; + +function requireIsBigIntArray () { + if (hasRequiredIsBigIntArray) return isBigIntArray; + hasRequiredIsBigIntArray = 1; + var classof = requireClassof(); + + isBigIntArray = function (it) { + var klass = classof(it); + return klass === 'BigInt64Array' || klass === 'BigUint64Array'; + }; + return isBigIntArray; +} + +var toBigInt; +var hasRequiredToBigInt; + +function requireToBigInt () { + if (hasRequiredToBigInt) return toBigInt; + hasRequiredToBigInt = 1; + var toPrimitive = requireToPrimitive(); + + var $TypeError = TypeError; + + // `ToBigInt` abstract operation + // https://tc39.es/ecma262/#sec-tobigint + toBigInt = function (argument) { + var prim = toPrimitive(argument, 'number'); + if (typeof prim == 'number') throw new $TypeError("Can't convert number to bigint"); + // eslint-disable-next-line es/no-bigint -- safe + return BigInt(prim); + }; + return toBigInt; +} + +var typedArrayFrom; +var hasRequiredTypedArrayFrom; + +function requireTypedArrayFrom () { + if (hasRequiredTypedArrayFrom) return typedArrayFrom; + hasRequiredTypedArrayFrom = 1; + var bind = requireFunctionBindContext(); + var call = requireFunctionCall(); + var aConstructor = requireAConstructor(); + var toObject = requireToObject(); + var lengthOfArrayLike = requireLengthOfArrayLike(); + var getIterator = requireGetIterator(); + var getIteratorMethod = requireGetIteratorMethod(); + var isArrayIteratorMethod = requireIsArrayIteratorMethod(); + var isBigIntArray = requireIsBigIntArray(); + var aTypedArrayConstructor = requireArrayBufferViewCore().aTypedArrayConstructor; + var toBigInt = requireToBigInt(); + + typedArrayFrom = function from(source /* , mapfn, thisArg */) { + var C = aConstructor(this); + var O = toObject(source); + var argumentsLength = arguments.length; + var mapfn = argumentsLength > 1 ? arguments[1] : undefined; + var mapping = mapfn !== undefined; + var iteratorMethod = getIteratorMethod(O); + var i, length, result, thisIsBigIntArray, value, step, iterator, next; + if (iteratorMethod && !isArrayIteratorMethod(iteratorMethod)) { + iterator = getIterator(O, iteratorMethod); + next = iterator.next; + O = []; + while (!(step = call(next, iterator)).done) { + O.push(step.value); + } + } + if (mapping && argumentsLength > 2) { + mapfn = bind(mapfn, arguments[2]); + } + length = lengthOfArrayLike(O); + result = new (aTypedArrayConstructor(C))(length); + thisIsBigIntArray = isBigIntArray(result); + for (i = 0; length > i; i++) { + value = mapping ? mapfn(O[i], i) : O[i]; + // FF30- typed arrays doesn't properly convert objects to typed array values + result[i] = thisIsBigIntArray ? toBigInt(value) : +value; + } + return result; + }; + return typedArrayFrom; +} + +var hasRequiredTypedArrayConstructor; + +function requireTypedArrayConstructor () { + if (hasRequiredTypedArrayConstructor) return typedArrayConstructor.exports; + hasRequiredTypedArrayConstructor = 1; + var $ = require_export(); + var globalThis = requireGlobalThis(); + var call = requireFunctionCall(); + var DESCRIPTORS = requireDescriptors(); + var TYPED_ARRAYS_CONSTRUCTORS_REQUIRES_WRAPPERS = requireTypedArrayConstructorsRequireWrappers(); + var ArrayBufferViewCore = requireArrayBufferViewCore(); + var ArrayBufferModule = requireArrayBuffer(); + var anInstance = requireAnInstance(); + var createPropertyDescriptor = requireCreatePropertyDescriptor(); + var createNonEnumerableProperty = requireCreateNonEnumerableProperty(); + var isIntegralNumber = requireIsIntegralNumber(); + var toLength = requireToLength(); + var toIndex = requireToIndex(); + var toOffset = requireToOffset(); + var toUint8Clamped = requireToUint8Clamped(); + var toPropertyKey = requireToPropertyKey(); + var hasOwn = requireHasOwnProperty(); + var classof = requireClassof(); + var isObject = requireIsObject(); + var isSymbol = requireIsSymbol(); + var create = requireObjectCreate(); + var isPrototypeOf = requireObjectIsPrototypeOf(); + var setPrototypeOf = requireObjectSetPrototypeOf(); + var getOwnPropertyNames = requireObjectGetOwnPropertyNames().f; + var typedArrayFrom = requireTypedArrayFrom(); + var forEach = requireArrayIteration().forEach; + var setSpecies = requireSetSpecies(); + var defineBuiltInAccessor = requireDefineBuiltInAccessor(); + var definePropertyModule = requireObjectDefineProperty(); + var getOwnPropertyDescriptorModule = requireObjectGetOwnPropertyDescriptor(); + var arrayFromConstructorAndList = requireArrayFromConstructorAndList(); + var InternalStateModule = requireInternalState(); + var inheritIfRequired = requireInheritIfRequired(); + + var getInternalState = InternalStateModule.get; + var setInternalState = InternalStateModule.set; + var enforceInternalState = InternalStateModule.enforce; + var nativeDefineProperty = definePropertyModule.f; + var nativeGetOwnPropertyDescriptor = getOwnPropertyDescriptorModule.f; + var RangeError = globalThis.RangeError; + var ArrayBuffer = ArrayBufferModule.ArrayBuffer; + var ArrayBufferPrototype = ArrayBuffer.prototype; + var DataView = ArrayBufferModule.DataView; + var NATIVE_ARRAY_BUFFER_VIEWS = ArrayBufferViewCore.NATIVE_ARRAY_BUFFER_VIEWS; + var TYPED_ARRAY_TAG = ArrayBufferViewCore.TYPED_ARRAY_TAG; + var TypedArray = ArrayBufferViewCore.TypedArray; + var TypedArrayPrototype = ArrayBufferViewCore.TypedArrayPrototype; + var isTypedArray = ArrayBufferViewCore.isTypedArray; + var BYTES_PER_ELEMENT = 'BYTES_PER_ELEMENT'; + var WRONG_LENGTH = 'Wrong length'; + + var addGetter = function (it, key) { + defineBuiltInAccessor(it, key, { + configurable: true, + get: function () { + return getInternalState(this)[key]; + } + }); + }; + + var isArrayBuffer = function (it) { + var klass; + return isPrototypeOf(ArrayBufferPrototype, it) || (klass = classof(it)) === 'ArrayBuffer' || klass === 'SharedArrayBuffer'; + }; + + var isTypedArrayIndex = function (target, key) { + return isTypedArray(target) + && !isSymbol(key) + && key in target + && isIntegralNumber(+key) + && key >= 0; + }; + + var wrappedGetOwnPropertyDescriptor = function getOwnPropertyDescriptor(target, key) { + key = toPropertyKey(key); + return isTypedArrayIndex(target, key) + ? createPropertyDescriptor(2, target[key]) + : nativeGetOwnPropertyDescriptor(target, key); + }; + + var wrappedDefineProperty = function defineProperty(target, key, descriptor) { + key = toPropertyKey(key); + if (isTypedArrayIndex(target, key) + && isObject(descriptor) + && hasOwn(descriptor, 'value') + && !hasOwn(descriptor, 'get') + && !hasOwn(descriptor, 'set') + // TODO: add validation descriptor w/o calling accessors + && !descriptor.configurable + && (!hasOwn(descriptor, 'writable') || descriptor.writable) + && (!hasOwn(descriptor, 'enumerable') || descriptor.enumerable) + ) { + target[key] = descriptor.value; + return target; + } return nativeDefineProperty(target, key, descriptor); + }; + + if (DESCRIPTORS) { + if (!NATIVE_ARRAY_BUFFER_VIEWS) { + getOwnPropertyDescriptorModule.f = wrappedGetOwnPropertyDescriptor; + definePropertyModule.f = wrappedDefineProperty; + addGetter(TypedArrayPrototype, 'buffer'); + addGetter(TypedArrayPrototype, 'byteOffset'); + addGetter(TypedArrayPrototype, 'byteLength'); + addGetter(TypedArrayPrototype, 'length'); + } + + $({ target: 'Object', stat: true, forced: !NATIVE_ARRAY_BUFFER_VIEWS }, { + getOwnPropertyDescriptor: wrappedGetOwnPropertyDescriptor, + defineProperty: wrappedDefineProperty + }); + + typedArrayConstructor.exports = function (TYPE, wrapper, CLAMPED) { + var BYTES = TYPE.match(/\d+/)[0] / 8; + var CONSTRUCTOR_NAME = TYPE + (CLAMPED ? 'Clamped' : '') + 'Array'; + var GETTER = 'get' + TYPE; + var SETTER = 'set' + TYPE; + var NativeTypedArrayConstructor = globalThis[CONSTRUCTOR_NAME]; + var TypedArrayConstructor = NativeTypedArrayConstructor; + var TypedArrayConstructorPrototype = TypedArrayConstructor && TypedArrayConstructor.prototype; + var exported = {}; + + var getter = function (that, index) { + var data = getInternalState(that); + return data.view[GETTER](index * BYTES + data.byteOffset, true); + }; + + var setter = function (that, index, value) { + var data = getInternalState(that); + data.view[SETTER](index * BYTES + data.byteOffset, CLAMPED ? toUint8Clamped(value) : value, true); + }; + + var addElement = function (that, index) { + nativeDefineProperty(that, index, { + get: function () { + return getter(this, index); + }, + set: function (value) { + return setter(this, index, value); + }, + enumerable: true + }); + }; + + if (!NATIVE_ARRAY_BUFFER_VIEWS) { + TypedArrayConstructor = wrapper(function (that, data, offset, $length) { + anInstance(that, TypedArrayConstructorPrototype); + var index = 0; + var byteOffset = 0; + var buffer, byteLength, length; + if (!isObject(data)) { + length = toIndex(data); + byteLength = length * BYTES; + buffer = new ArrayBuffer(byteLength); + } else if (isArrayBuffer(data)) { + buffer = data; + byteOffset = toOffset(offset, BYTES); + var $len = data.byteLength; + if ($length === undefined) { + if ($len % BYTES) throw new RangeError(WRONG_LENGTH); + byteLength = $len - byteOffset; + if (byteLength < 0) throw new RangeError(WRONG_LENGTH); + } else { + byteLength = toLength($length) * BYTES; + if (byteLength + byteOffset > $len) throw new RangeError(WRONG_LENGTH); + } + length = byteLength / BYTES; + } else if (isTypedArray(data)) { + return arrayFromConstructorAndList(TypedArrayConstructor, data); + } else { + return call(typedArrayFrom, TypedArrayConstructor, data); + } + setInternalState(that, { + buffer: buffer, + byteOffset: byteOffset, + byteLength: byteLength, + length: length, + view: new DataView(buffer) + }); + while (index < length) addElement(that, index++); + }); + + if (setPrototypeOf) setPrototypeOf(TypedArrayConstructor, TypedArray); + TypedArrayConstructorPrototype = TypedArrayConstructor.prototype = create(TypedArrayPrototype); + } else if (TYPED_ARRAYS_CONSTRUCTORS_REQUIRES_WRAPPERS) { + TypedArrayConstructor = wrapper(function (dummy, data, typedArrayOffset, $length) { + anInstance(dummy, TypedArrayConstructorPrototype); + return inheritIfRequired(function () { + if (!isObject(data)) return new NativeTypedArrayConstructor(toIndex(data)); + if (isArrayBuffer(data)) return $length !== undefined + ? new NativeTypedArrayConstructor(data, toOffset(typedArrayOffset, BYTES), $length) + : typedArrayOffset !== undefined + ? new NativeTypedArrayConstructor(data, toOffset(typedArrayOffset, BYTES)) + : new NativeTypedArrayConstructor(data); + if (isTypedArray(data)) return arrayFromConstructorAndList(TypedArrayConstructor, data); + return call(typedArrayFrom, TypedArrayConstructor, data); + }(), dummy, TypedArrayConstructor); + }); + + if (setPrototypeOf) setPrototypeOf(TypedArrayConstructor, TypedArray); + forEach(getOwnPropertyNames(NativeTypedArrayConstructor), function (key) { + if (!(key in TypedArrayConstructor)) { + createNonEnumerableProperty(TypedArrayConstructor, key, NativeTypedArrayConstructor[key]); + } + }); + TypedArrayConstructor.prototype = TypedArrayConstructorPrototype; + } + + if (TypedArrayConstructorPrototype.constructor !== TypedArrayConstructor) { + createNonEnumerableProperty(TypedArrayConstructorPrototype, 'constructor', TypedArrayConstructor); + } + + enforceInternalState(TypedArrayConstructorPrototype).TypedArrayConstructor = TypedArrayConstructor; + + if (TYPED_ARRAY_TAG) { + createNonEnumerableProperty(TypedArrayConstructorPrototype, TYPED_ARRAY_TAG, CONSTRUCTOR_NAME); + } + + var FORCED = TypedArrayConstructor !== NativeTypedArrayConstructor; + + exported[CONSTRUCTOR_NAME] = TypedArrayConstructor; + + $({ global: true, constructor: true, forced: FORCED, sham: !NATIVE_ARRAY_BUFFER_VIEWS }, exported); + + if (!(BYTES_PER_ELEMENT in TypedArrayConstructor)) { + createNonEnumerableProperty(TypedArrayConstructor, BYTES_PER_ELEMENT, BYTES); + } + + if (!(BYTES_PER_ELEMENT in TypedArrayConstructorPrototype)) { + createNonEnumerableProperty(TypedArrayConstructorPrototype, BYTES_PER_ELEMENT, BYTES); + } + + setSpecies(CONSTRUCTOR_NAME); + }; + } else typedArrayConstructor.exports = function () { /* empty */ }; + return typedArrayConstructor.exports; +} + +var hasRequiredEs_typedArray_float32Array; + +function requireEs_typedArray_float32Array () { + if (hasRequiredEs_typedArray_float32Array) return es_typedArray_float32Array; + hasRequiredEs_typedArray_float32Array = 1; + var createTypedArrayConstructor = requireTypedArrayConstructor(); + + // `Float32Array` constructor + // https://tc39.es/ecma262/#sec-typedarray-objects + createTypedArrayConstructor('Float32', function (init) { + return function Float32Array(data, byteOffset, length) { + return init(this, data, byteOffset, length); + }; + }); + return es_typedArray_float32Array; +} + +var es_typedArray_float64Array = {}; + +var hasRequiredEs_typedArray_float64Array; + +function requireEs_typedArray_float64Array () { + if (hasRequiredEs_typedArray_float64Array) return es_typedArray_float64Array; + hasRequiredEs_typedArray_float64Array = 1; + var createTypedArrayConstructor = requireTypedArrayConstructor(); + + // `Float64Array` constructor + // https://tc39.es/ecma262/#sec-typedarray-objects + createTypedArrayConstructor('Float64', function (init) { + return function Float64Array(data, byteOffset, length) { + return init(this, data, byteOffset, length); + }; + }); + return es_typedArray_float64Array; +} + +var es_typedArray_int8Array = {}; + +var hasRequiredEs_typedArray_int8Array; + +function requireEs_typedArray_int8Array () { + if (hasRequiredEs_typedArray_int8Array) return es_typedArray_int8Array; + hasRequiredEs_typedArray_int8Array = 1; + var createTypedArrayConstructor = requireTypedArrayConstructor(); + + // `Int8Array` constructor + // https://tc39.es/ecma262/#sec-typedarray-objects + createTypedArrayConstructor('Int8', function (init) { + return function Int8Array(data, byteOffset, length) { + return init(this, data, byteOffset, length); + }; + }); + return es_typedArray_int8Array; +} + +var es_typedArray_int16Array = {}; + +var hasRequiredEs_typedArray_int16Array; + +function requireEs_typedArray_int16Array () { + if (hasRequiredEs_typedArray_int16Array) return es_typedArray_int16Array; + hasRequiredEs_typedArray_int16Array = 1; + var createTypedArrayConstructor = requireTypedArrayConstructor(); + + // `Int16Array` constructor + // https://tc39.es/ecma262/#sec-typedarray-objects + createTypedArrayConstructor('Int16', function (init) { + return function Int16Array(data, byteOffset, length) { + return init(this, data, byteOffset, length); + }; + }); + return es_typedArray_int16Array; +} + +var es_typedArray_int32Array = {}; + +var hasRequiredEs_typedArray_int32Array; + +function requireEs_typedArray_int32Array () { + if (hasRequiredEs_typedArray_int32Array) return es_typedArray_int32Array; + hasRequiredEs_typedArray_int32Array = 1; + var createTypedArrayConstructor = requireTypedArrayConstructor(); + + // `Int32Array` constructor + // https://tc39.es/ecma262/#sec-typedarray-objects + createTypedArrayConstructor('Int32', function (init) { + return function Int32Array(data, byteOffset, length) { + return init(this, data, byteOffset, length); + }; + }); + return es_typedArray_int32Array; +} + +var es_typedArray_uint8Array = {}; + +var hasRequiredEs_typedArray_uint8Array; + +function requireEs_typedArray_uint8Array () { + if (hasRequiredEs_typedArray_uint8Array) return es_typedArray_uint8Array; + hasRequiredEs_typedArray_uint8Array = 1; + var createTypedArrayConstructor = requireTypedArrayConstructor(); + + // `Uint8Array` constructor + // https://tc39.es/ecma262/#sec-typedarray-objects + createTypedArrayConstructor('Uint8', function (init) { + return function Uint8Array(data, byteOffset, length) { + return init(this, data, byteOffset, length); + }; + }); + return es_typedArray_uint8Array; +} + +var es_typedArray_uint8ClampedArray = {}; + +var hasRequiredEs_typedArray_uint8ClampedArray; + +function requireEs_typedArray_uint8ClampedArray () { + if (hasRequiredEs_typedArray_uint8ClampedArray) return es_typedArray_uint8ClampedArray; + hasRequiredEs_typedArray_uint8ClampedArray = 1; + var createTypedArrayConstructor = requireTypedArrayConstructor(); + + // `Uint8ClampedArray` constructor + // https://tc39.es/ecma262/#sec-typedarray-objects + createTypedArrayConstructor('Uint8', function (init) { + return function Uint8ClampedArray(data, byteOffset, length) { + return init(this, data, byteOffset, length); + }; + }, true); + return es_typedArray_uint8ClampedArray; +} + +var es_typedArray_uint16Array = {}; + +var hasRequiredEs_typedArray_uint16Array; + +function requireEs_typedArray_uint16Array () { + if (hasRequiredEs_typedArray_uint16Array) return es_typedArray_uint16Array; + hasRequiredEs_typedArray_uint16Array = 1; + var createTypedArrayConstructor = requireTypedArrayConstructor(); + + // `Uint16Array` constructor + // https://tc39.es/ecma262/#sec-typedarray-objects + createTypedArrayConstructor('Uint16', function (init) { + return function Uint16Array(data, byteOffset, length) { + return init(this, data, byteOffset, length); + }; + }); + return es_typedArray_uint16Array; +} + +var es_typedArray_uint32Array = {}; + +var hasRequiredEs_typedArray_uint32Array; + +function requireEs_typedArray_uint32Array () { + if (hasRequiredEs_typedArray_uint32Array) return es_typedArray_uint32Array; + hasRequiredEs_typedArray_uint32Array = 1; + var createTypedArrayConstructor = requireTypedArrayConstructor(); + + // `Uint32Array` constructor + // https://tc39.es/ecma262/#sec-typedarray-objects + createTypedArrayConstructor('Uint32', function (init) { + return function Uint32Array(data, byteOffset, length) { + return init(this, data, byteOffset, length); + }; + }); + return es_typedArray_uint32Array; +} + +var es_typedArray_at = {}; + +var hasRequiredEs_typedArray_at; + +function requireEs_typedArray_at () { + if (hasRequiredEs_typedArray_at) return es_typedArray_at; + hasRequiredEs_typedArray_at = 1; + var ArrayBufferViewCore = requireArrayBufferViewCore(); + var lengthOfArrayLike = requireLengthOfArrayLike(); + var toIntegerOrInfinity = requireToIntegerOrInfinity(); + + var aTypedArray = ArrayBufferViewCore.aTypedArray; + var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod; + + // `%TypedArray%.prototype.at` method + // https://tc39.es/ecma262/#sec-%typedarray%.prototype.at + exportTypedArrayMethod('at', function at(index) { + var O = aTypedArray(this); + var len = lengthOfArrayLike(O); + var relativeIndex = toIntegerOrInfinity(index); + var k = relativeIndex >= 0 ? relativeIndex : len + relativeIndex; + return (k < 0 || k >= len) ? undefined : O[k]; + }); + return es_typedArray_at; +} + +var es_typedArray_copyWithin = {}; + +var hasRequiredEs_typedArray_copyWithin; + +function requireEs_typedArray_copyWithin () { + if (hasRequiredEs_typedArray_copyWithin) return es_typedArray_copyWithin; + hasRequiredEs_typedArray_copyWithin = 1; + var uncurryThis = requireFunctionUncurryThis(); + var ArrayBufferViewCore = requireArrayBufferViewCore(); + var $ArrayCopyWithin = requireArrayCopyWithin(); + + var u$ArrayCopyWithin = uncurryThis($ArrayCopyWithin); + var aTypedArray = ArrayBufferViewCore.aTypedArray; + var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod; + + // `%TypedArray%.prototype.copyWithin` method + // https://tc39.es/ecma262/#sec-%typedarray%.prototype.copywithin + exportTypedArrayMethod('copyWithin', function copyWithin(target, start /* , end */) { + return u$ArrayCopyWithin(aTypedArray(this), target, start, arguments.length > 2 ? arguments[2] : undefined); + }); + return es_typedArray_copyWithin; +} + +var es_typedArray_every = {}; + +var hasRequiredEs_typedArray_every; + +function requireEs_typedArray_every () { + if (hasRequiredEs_typedArray_every) return es_typedArray_every; + hasRequiredEs_typedArray_every = 1; + var ArrayBufferViewCore = requireArrayBufferViewCore(); + var $every = requireArrayIteration().every; + + var aTypedArray = ArrayBufferViewCore.aTypedArray; + var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod; + + // `%TypedArray%.prototype.every` method + // https://tc39.es/ecma262/#sec-%typedarray%.prototype.every + exportTypedArrayMethod('every', function every(callbackfn /* , thisArg */) { + return $every(aTypedArray(this), callbackfn, arguments.length > 1 ? arguments[1] : undefined); + }); + return es_typedArray_every; +} + +var es_typedArray_fill = {}; + +var hasRequiredEs_typedArray_fill; + +function requireEs_typedArray_fill () { + if (hasRequiredEs_typedArray_fill) return es_typedArray_fill; + hasRequiredEs_typedArray_fill = 1; + var ArrayBufferViewCore = requireArrayBufferViewCore(); + var $fill = requireArrayFill(); + var toBigInt = requireToBigInt(); + var classof = requireClassof(); + var call = requireFunctionCall(); + var uncurryThis = requireFunctionUncurryThis(); + var fails = requireFails(); + + var aTypedArray = ArrayBufferViewCore.aTypedArray; + var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod; + var slice = uncurryThis(''.slice); + + // V8 ~ Chrome < 59, Safari < 14.1, FF < 55, Edge <=18 + var CONVERSION_BUG = fails(function () { + var count = 0; + // eslint-disable-next-line es/no-typed-arrays -- safe + new Int8Array(2).fill({ valueOf: function () { return count++; } }); + return count !== 1; + }); + + // `%TypedArray%.prototype.fill` method + // https://tc39.es/ecma262/#sec-%typedarray%.prototype.fill + exportTypedArrayMethod('fill', function fill(value /* , start, end */) { + var length = arguments.length; + aTypedArray(this); + var actualValue = slice(classof(this), 0, 3) === 'Big' ? toBigInt(value) : +value; + return call($fill, this, actualValue, length > 1 ? arguments[1] : undefined, length > 2 ? arguments[2] : undefined); + }, CONVERSION_BUG); + return es_typedArray_fill; +} + +var es_typedArray_filter = {}; + +var typedArraySpeciesConstructor; +var hasRequiredTypedArraySpeciesConstructor; + +function requireTypedArraySpeciesConstructor () { + if (hasRequiredTypedArraySpeciesConstructor) return typedArraySpeciesConstructor; + hasRequiredTypedArraySpeciesConstructor = 1; + var ArrayBufferViewCore = requireArrayBufferViewCore(); + var speciesConstructor = requireSpeciesConstructor(); + + var aTypedArrayConstructor = ArrayBufferViewCore.aTypedArrayConstructor; + var getTypedArrayConstructor = ArrayBufferViewCore.getTypedArrayConstructor; + + // a part of `TypedArraySpeciesCreate` abstract operation + // https://tc39.es/ecma262/#typedarray-species-create + typedArraySpeciesConstructor = function (originalArray) { + return aTypedArrayConstructor(speciesConstructor(originalArray, getTypedArrayConstructor(originalArray))); + }; + return typedArraySpeciesConstructor; +} + +var typedArrayFromSpeciesAndList; +var hasRequiredTypedArrayFromSpeciesAndList; + +function requireTypedArrayFromSpeciesAndList () { + if (hasRequiredTypedArrayFromSpeciesAndList) return typedArrayFromSpeciesAndList; + hasRequiredTypedArrayFromSpeciesAndList = 1; + var arrayFromConstructorAndList = requireArrayFromConstructorAndList(); + var typedArraySpeciesConstructor = requireTypedArraySpeciesConstructor(); + + typedArrayFromSpeciesAndList = function (instance, list) { + return arrayFromConstructorAndList(typedArraySpeciesConstructor(instance), list); + }; + return typedArrayFromSpeciesAndList; +} + +var hasRequiredEs_typedArray_filter; + +function requireEs_typedArray_filter () { + if (hasRequiredEs_typedArray_filter) return es_typedArray_filter; + hasRequiredEs_typedArray_filter = 1; + var ArrayBufferViewCore = requireArrayBufferViewCore(); + var $filter = requireArrayIteration().filter; + var fromSpeciesAndList = requireTypedArrayFromSpeciesAndList(); + + var aTypedArray = ArrayBufferViewCore.aTypedArray; + var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod; + + // `%TypedArray%.prototype.filter` method + // https://tc39.es/ecma262/#sec-%typedarray%.prototype.filter + exportTypedArrayMethod('filter', function filter(callbackfn /* , thisArg */) { + var list = $filter(aTypedArray(this), callbackfn, arguments.length > 1 ? arguments[1] : undefined); + return fromSpeciesAndList(this, list); + }); + return es_typedArray_filter; +} + +var es_typedArray_find = {}; + +var hasRequiredEs_typedArray_find; + +function requireEs_typedArray_find () { + if (hasRequiredEs_typedArray_find) return es_typedArray_find; + hasRequiredEs_typedArray_find = 1; + var ArrayBufferViewCore = requireArrayBufferViewCore(); + var $find = requireArrayIteration().find; + + var aTypedArray = ArrayBufferViewCore.aTypedArray; + var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod; + + // `%TypedArray%.prototype.find` method + // https://tc39.es/ecma262/#sec-%typedarray%.prototype.find + exportTypedArrayMethod('find', function find(predicate /* , thisArg */) { + return $find(aTypedArray(this), predicate, arguments.length > 1 ? arguments[1] : undefined); + }); + return es_typedArray_find; +} + +var es_typedArray_findIndex = {}; + +var hasRequiredEs_typedArray_findIndex; + +function requireEs_typedArray_findIndex () { + if (hasRequiredEs_typedArray_findIndex) return es_typedArray_findIndex; + hasRequiredEs_typedArray_findIndex = 1; + var ArrayBufferViewCore = requireArrayBufferViewCore(); + var $findIndex = requireArrayIteration().findIndex; + + var aTypedArray = ArrayBufferViewCore.aTypedArray; + var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod; + + // `%TypedArray%.prototype.findIndex` method + // https://tc39.es/ecma262/#sec-%typedarray%.prototype.findindex + exportTypedArrayMethod('findIndex', function findIndex(predicate /* , thisArg */) { + return $findIndex(aTypedArray(this), predicate, arguments.length > 1 ? arguments[1] : undefined); + }); + return es_typedArray_findIndex; +} + +var es_typedArray_findLast = {}; + +var hasRequiredEs_typedArray_findLast; + +function requireEs_typedArray_findLast () { + if (hasRequiredEs_typedArray_findLast) return es_typedArray_findLast; + hasRequiredEs_typedArray_findLast = 1; + var ArrayBufferViewCore = requireArrayBufferViewCore(); + var $findLast = requireArrayIterationFromLast().findLast; + + var aTypedArray = ArrayBufferViewCore.aTypedArray; + var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod; + + // `%TypedArray%.prototype.findLast` method + // https://tc39.es/ecma262/#sec-%typedarray%.prototype.findlast + exportTypedArrayMethod('findLast', function findLast(predicate /* , thisArg */) { + return $findLast(aTypedArray(this), predicate, arguments.length > 1 ? arguments[1] : undefined); + }); + return es_typedArray_findLast; +} + +var es_typedArray_findLastIndex = {}; + +var hasRequiredEs_typedArray_findLastIndex; + +function requireEs_typedArray_findLastIndex () { + if (hasRequiredEs_typedArray_findLastIndex) return es_typedArray_findLastIndex; + hasRequiredEs_typedArray_findLastIndex = 1; + var ArrayBufferViewCore = requireArrayBufferViewCore(); + var $findLastIndex = requireArrayIterationFromLast().findLastIndex; + + var aTypedArray = ArrayBufferViewCore.aTypedArray; + var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod; + + // `%TypedArray%.prototype.findLastIndex` method + // https://tc39.es/ecma262/#sec-%typedarray%.prototype.findlastindex + exportTypedArrayMethod('findLastIndex', function findLastIndex(predicate /* , thisArg */) { + return $findLastIndex(aTypedArray(this), predicate, arguments.length > 1 ? arguments[1] : undefined); + }); + return es_typedArray_findLastIndex; +} + +var es_typedArray_forEach = {}; + +var hasRequiredEs_typedArray_forEach; + +function requireEs_typedArray_forEach () { + if (hasRequiredEs_typedArray_forEach) return es_typedArray_forEach; + hasRequiredEs_typedArray_forEach = 1; + var ArrayBufferViewCore = requireArrayBufferViewCore(); + var $forEach = requireArrayIteration().forEach; + + var aTypedArray = ArrayBufferViewCore.aTypedArray; + var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod; + + // `%TypedArray%.prototype.forEach` method + // https://tc39.es/ecma262/#sec-%typedarray%.prototype.foreach + exportTypedArrayMethod('forEach', function forEach(callbackfn /* , thisArg */) { + $forEach(aTypedArray(this), callbackfn, arguments.length > 1 ? arguments[1] : undefined); + }); + return es_typedArray_forEach; +} + +var es_typedArray_from = {}; + +var hasRequiredEs_typedArray_from; + +function requireEs_typedArray_from () { + if (hasRequiredEs_typedArray_from) return es_typedArray_from; + hasRequiredEs_typedArray_from = 1; + var TYPED_ARRAYS_CONSTRUCTORS_REQUIRES_WRAPPERS = requireTypedArrayConstructorsRequireWrappers(); + var exportTypedArrayStaticMethod = requireArrayBufferViewCore().exportTypedArrayStaticMethod; + var typedArrayFrom = requireTypedArrayFrom(); + + // `%TypedArray%.from` method + // https://tc39.es/ecma262/#sec-%typedarray%.from + exportTypedArrayStaticMethod('from', typedArrayFrom, TYPED_ARRAYS_CONSTRUCTORS_REQUIRES_WRAPPERS); + return es_typedArray_from; +} + +var es_typedArray_includes = {}; + +var hasRequiredEs_typedArray_includes; + +function requireEs_typedArray_includes () { + if (hasRequiredEs_typedArray_includes) return es_typedArray_includes; + hasRequiredEs_typedArray_includes = 1; + var ArrayBufferViewCore = requireArrayBufferViewCore(); + var $includes = requireArrayIncludes().includes; + + var aTypedArray = ArrayBufferViewCore.aTypedArray; + var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod; + + // `%TypedArray%.prototype.includes` method + // https://tc39.es/ecma262/#sec-%typedarray%.prototype.includes + exportTypedArrayMethod('includes', function includes(searchElement /* , fromIndex */) { + return $includes(aTypedArray(this), searchElement, arguments.length > 1 ? arguments[1] : undefined); + }); + return es_typedArray_includes; +} + +var es_typedArray_indexOf = {}; + +var hasRequiredEs_typedArray_indexOf; + +function requireEs_typedArray_indexOf () { + if (hasRequiredEs_typedArray_indexOf) return es_typedArray_indexOf; + hasRequiredEs_typedArray_indexOf = 1; + var ArrayBufferViewCore = requireArrayBufferViewCore(); + var $indexOf = requireArrayIncludes().indexOf; + + var aTypedArray = ArrayBufferViewCore.aTypedArray; + var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod; + + // `%TypedArray%.prototype.indexOf` method + // https://tc39.es/ecma262/#sec-%typedarray%.prototype.indexof + exportTypedArrayMethod('indexOf', function indexOf(searchElement /* , fromIndex */) { + return $indexOf(aTypedArray(this), searchElement, arguments.length > 1 ? arguments[1] : undefined); + }); + return es_typedArray_indexOf; +} + +var es_typedArray_iterator = {}; + +var hasRequiredEs_typedArray_iterator; + +function requireEs_typedArray_iterator () { + if (hasRequiredEs_typedArray_iterator) return es_typedArray_iterator; + hasRequiredEs_typedArray_iterator = 1; + var globalThis = requireGlobalThis(); + var fails = requireFails(); + var uncurryThis = requireFunctionUncurryThis(); + var ArrayBufferViewCore = requireArrayBufferViewCore(); + var ArrayIterators = requireEs_array_iterator(); + var wellKnownSymbol = requireWellKnownSymbol(); + + var ITERATOR = wellKnownSymbol('iterator'); + var Uint8Array = globalThis.Uint8Array; + var arrayValues = uncurryThis(ArrayIterators.values); + var arrayKeys = uncurryThis(ArrayIterators.keys); + var arrayEntries = uncurryThis(ArrayIterators.entries); + var aTypedArray = ArrayBufferViewCore.aTypedArray; + var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod; + var TypedArrayPrototype = Uint8Array && Uint8Array.prototype; + + var GENERIC = !fails(function () { + TypedArrayPrototype[ITERATOR].call([1]); + }); + + var ITERATOR_IS_VALUES = !!TypedArrayPrototype + && TypedArrayPrototype.values + && TypedArrayPrototype[ITERATOR] === TypedArrayPrototype.values + && TypedArrayPrototype.values.name === 'values'; + + var typedArrayValues = function values() { + return arrayValues(aTypedArray(this)); + }; + + // `%TypedArray%.prototype.entries` method + // https://tc39.es/ecma262/#sec-%typedarray%.prototype.entries + exportTypedArrayMethod('entries', function entries() { + return arrayEntries(aTypedArray(this)); + }, GENERIC); + // `%TypedArray%.prototype.keys` method + // https://tc39.es/ecma262/#sec-%typedarray%.prototype.keys + exportTypedArrayMethod('keys', function keys() { + return arrayKeys(aTypedArray(this)); + }, GENERIC); + // `%TypedArray%.prototype.values` method + // https://tc39.es/ecma262/#sec-%typedarray%.prototype.values + exportTypedArrayMethod('values', typedArrayValues, GENERIC || !ITERATOR_IS_VALUES, { name: 'values' }); + // `%TypedArray%.prototype[@@iterator]` method + // https://tc39.es/ecma262/#sec-%typedarray%.prototype-@@iterator + exportTypedArrayMethod(ITERATOR, typedArrayValues, GENERIC || !ITERATOR_IS_VALUES, { name: 'values' }); + return es_typedArray_iterator; +} + +var es_typedArray_join = {}; + +var hasRequiredEs_typedArray_join; + +function requireEs_typedArray_join () { + if (hasRequiredEs_typedArray_join) return es_typedArray_join; + hasRequiredEs_typedArray_join = 1; + var ArrayBufferViewCore = requireArrayBufferViewCore(); + var uncurryThis = requireFunctionUncurryThis(); + + var aTypedArray = ArrayBufferViewCore.aTypedArray; + var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod; + var $join = uncurryThis([].join); + + // `%TypedArray%.prototype.join` method + // https://tc39.es/ecma262/#sec-%typedarray%.prototype.join + exportTypedArrayMethod('join', function join(separator) { + return $join(aTypedArray(this), separator); + }); + return es_typedArray_join; +} + +var es_typedArray_lastIndexOf = {}; + +var hasRequiredEs_typedArray_lastIndexOf; + +function requireEs_typedArray_lastIndexOf () { + if (hasRequiredEs_typedArray_lastIndexOf) return es_typedArray_lastIndexOf; + hasRequiredEs_typedArray_lastIndexOf = 1; + var ArrayBufferViewCore = requireArrayBufferViewCore(); + var apply = requireFunctionApply(); + var $lastIndexOf = requireArrayLastIndexOf(); + + var aTypedArray = ArrayBufferViewCore.aTypedArray; + var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod; + + // `%TypedArray%.prototype.lastIndexOf` method + // https://tc39.es/ecma262/#sec-%typedarray%.prototype.lastindexof + exportTypedArrayMethod('lastIndexOf', function lastIndexOf(searchElement /* , fromIndex */) { + var length = arguments.length; + return apply($lastIndexOf, aTypedArray(this), length > 1 ? [searchElement, arguments[1]] : [searchElement]); + }); + return es_typedArray_lastIndexOf; +} + +var es_typedArray_map = {}; + +var hasRequiredEs_typedArray_map; + +function requireEs_typedArray_map () { + if (hasRequiredEs_typedArray_map) return es_typedArray_map; + hasRequiredEs_typedArray_map = 1; + var ArrayBufferViewCore = requireArrayBufferViewCore(); + var $map = requireArrayIteration().map; + var typedArraySpeciesConstructor = requireTypedArraySpeciesConstructor(); + + var aTypedArray = ArrayBufferViewCore.aTypedArray; + var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod; + + // `%TypedArray%.prototype.map` method + // https://tc39.es/ecma262/#sec-%typedarray%.prototype.map + exportTypedArrayMethod('map', function map(mapfn /* , thisArg */) { + return $map(aTypedArray(this), mapfn, arguments.length > 1 ? arguments[1] : undefined, function (O, length) { + return new (typedArraySpeciesConstructor(O))(length); + }); + }); + return es_typedArray_map; +} + +var es_typedArray_of = {}; + +var hasRequiredEs_typedArray_of; + +function requireEs_typedArray_of () { + if (hasRequiredEs_typedArray_of) return es_typedArray_of; + hasRequiredEs_typedArray_of = 1; + var ArrayBufferViewCore = requireArrayBufferViewCore(); + var TYPED_ARRAYS_CONSTRUCTORS_REQUIRES_WRAPPERS = requireTypedArrayConstructorsRequireWrappers(); + + var aTypedArrayConstructor = ArrayBufferViewCore.aTypedArrayConstructor; + var exportTypedArrayStaticMethod = ArrayBufferViewCore.exportTypedArrayStaticMethod; + + // `%TypedArray%.of` method + // https://tc39.es/ecma262/#sec-%typedarray%.of + exportTypedArrayStaticMethod('of', function of(/* ...items */) { + var index = 0; + var length = arguments.length; + var result = new (aTypedArrayConstructor(this))(length); + while (length > index) result[index] = arguments[index++]; + return result; + }, TYPED_ARRAYS_CONSTRUCTORS_REQUIRES_WRAPPERS); + return es_typedArray_of; +} + +var es_typedArray_reduce = {}; + +var hasRequiredEs_typedArray_reduce; + +function requireEs_typedArray_reduce () { + if (hasRequiredEs_typedArray_reduce) return es_typedArray_reduce; + hasRequiredEs_typedArray_reduce = 1; + var ArrayBufferViewCore = requireArrayBufferViewCore(); + var $reduce = requireArrayReduce().left; + + var aTypedArray = ArrayBufferViewCore.aTypedArray; + var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod; + + // `%TypedArray%.prototype.reduce` method + // https://tc39.es/ecma262/#sec-%typedarray%.prototype.reduce + exportTypedArrayMethod('reduce', function reduce(callbackfn /* , initialValue */) { + var length = arguments.length; + return $reduce(aTypedArray(this), callbackfn, length, length > 1 ? arguments[1] : undefined); + }); + return es_typedArray_reduce; +} + +var es_typedArray_reduceRight = {}; + +var hasRequiredEs_typedArray_reduceRight; + +function requireEs_typedArray_reduceRight () { + if (hasRequiredEs_typedArray_reduceRight) return es_typedArray_reduceRight; + hasRequiredEs_typedArray_reduceRight = 1; + var ArrayBufferViewCore = requireArrayBufferViewCore(); + var $reduceRight = requireArrayReduce().right; + + var aTypedArray = ArrayBufferViewCore.aTypedArray; + var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod; + + // `%TypedArray%.prototype.reduceRight` method + // https://tc39.es/ecma262/#sec-%typedarray%.prototype.reduceright + exportTypedArrayMethod('reduceRight', function reduceRight(callbackfn /* , initialValue */) { + var length = arguments.length; + return $reduceRight(aTypedArray(this), callbackfn, length, length > 1 ? arguments[1] : undefined); + }); + return es_typedArray_reduceRight; +} + +var es_typedArray_reverse = {}; + +var hasRequiredEs_typedArray_reverse; + +function requireEs_typedArray_reverse () { + if (hasRequiredEs_typedArray_reverse) return es_typedArray_reverse; + hasRequiredEs_typedArray_reverse = 1; + var ArrayBufferViewCore = requireArrayBufferViewCore(); + + var aTypedArray = ArrayBufferViewCore.aTypedArray; + var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod; + var floor = Math.floor; + + // `%TypedArray%.prototype.reverse` method + // https://tc39.es/ecma262/#sec-%typedarray%.prototype.reverse + exportTypedArrayMethod('reverse', function reverse() { + var that = this; + var length = aTypedArray(that).length; + var middle = floor(length / 2); + var index = 0; + var value; + while (index < middle) { + value = that[index]; + that[index++] = that[--length]; + that[length] = value; + } return that; + }); + return es_typedArray_reverse; +} + +var es_typedArray_set = {}; + +var hasRequiredEs_typedArray_set; + +function requireEs_typedArray_set () { + if (hasRequiredEs_typedArray_set) return es_typedArray_set; + hasRequiredEs_typedArray_set = 1; + var globalThis = requireGlobalThis(); + var call = requireFunctionCall(); + var ArrayBufferViewCore = requireArrayBufferViewCore(); + var lengthOfArrayLike = requireLengthOfArrayLike(); + var toOffset = requireToOffset(); + var toIndexedObject = requireToObject(); + var fails = requireFails(); + + var RangeError = globalThis.RangeError; + var Int8Array = globalThis.Int8Array; + var Int8ArrayPrototype = Int8Array && Int8Array.prototype; + var $set = Int8ArrayPrototype && Int8ArrayPrototype.set; + var aTypedArray = ArrayBufferViewCore.aTypedArray; + var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod; + + var WORKS_WITH_OBJECTS_AND_GENERIC_ON_TYPED_ARRAYS = !fails(function () { + // eslint-disable-next-line es/no-typed-arrays -- required for testing + var array = new Uint8ClampedArray(2); + call($set, array, { length: 1, 0: 3 }, 1); + return array[1] !== 3; + }); + + // https://bugs.chromium.org/p/v8/issues/detail?id=11294 and other + var TO_OBJECT_BUG = WORKS_WITH_OBJECTS_AND_GENERIC_ON_TYPED_ARRAYS && ArrayBufferViewCore.NATIVE_ARRAY_BUFFER_VIEWS && fails(function () { + var array = new Int8Array(2); + array.set(1); + array.set('2', 1); + return array[0] !== 0 || array[1] !== 2; + }); + + // `%TypedArray%.prototype.set` method + // https://tc39.es/ecma262/#sec-%typedarray%.prototype.set + exportTypedArrayMethod('set', function set(arrayLike /* , offset */) { + aTypedArray(this); + var offset = toOffset(arguments.length > 1 ? arguments[1] : undefined, 1); + var src = toIndexedObject(arrayLike); + if (WORKS_WITH_OBJECTS_AND_GENERIC_ON_TYPED_ARRAYS) return call($set, this, src, offset); + var length = this.length; + var len = lengthOfArrayLike(src); + var index = 0; + if (len + offset > length) throw new RangeError('Wrong length'); + while (index < len) this[offset + index] = src[index++]; + }, !WORKS_WITH_OBJECTS_AND_GENERIC_ON_TYPED_ARRAYS || TO_OBJECT_BUG); + return es_typedArray_set; +} + +var es_typedArray_slice = {}; + +var hasRequiredEs_typedArray_slice; + +function requireEs_typedArray_slice () { + if (hasRequiredEs_typedArray_slice) return es_typedArray_slice; + hasRequiredEs_typedArray_slice = 1; + var ArrayBufferViewCore = requireArrayBufferViewCore(); + var typedArraySpeciesConstructor = requireTypedArraySpeciesConstructor(); + var fails = requireFails(); + var arraySlice = requireArraySlice(); + + var aTypedArray = ArrayBufferViewCore.aTypedArray; + var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod; + + var FORCED = fails(function () { + // eslint-disable-next-line es/no-typed-arrays -- required for testing + new Int8Array(1).slice(); + }); + + // `%TypedArray%.prototype.slice` method + // https://tc39.es/ecma262/#sec-%typedarray%.prototype.slice + exportTypedArrayMethod('slice', function slice(start, end) { + var list = arraySlice(aTypedArray(this), start, end); + var C = typedArraySpeciesConstructor(this); + var index = 0; + var length = list.length; + var result = new C(length); + while (length > index) result[index] = list[index++]; + return result; + }, FORCED); + return es_typedArray_slice; +} + +var es_typedArray_some = {}; + +var hasRequiredEs_typedArray_some; + +function requireEs_typedArray_some () { + if (hasRequiredEs_typedArray_some) return es_typedArray_some; + hasRequiredEs_typedArray_some = 1; + var ArrayBufferViewCore = requireArrayBufferViewCore(); + var $some = requireArrayIteration().some; + + var aTypedArray = ArrayBufferViewCore.aTypedArray; + var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod; + + // `%TypedArray%.prototype.some` method + // https://tc39.es/ecma262/#sec-%typedarray%.prototype.some + exportTypedArrayMethod('some', function some(callbackfn /* , thisArg */) { + return $some(aTypedArray(this), callbackfn, arguments.length > 1 ? arguments[1] : undefined); + }); + return es_typedArray_some; +} + +var es_typedArray_sort = {}; + +var hasRequiredEs_typedArray_sort; + +function requireEs_typedArray_sort () { + if (hasRequiredEs_typedArray_sort) return es_typedArray_sort; + hasRequiredEs_typedArray_sort = 1; + var globalThis = requireGlobalThis(); + var uncurryThis = requireFunctionUncurryThisClause(); + var fails = requireFails(); + var aCallable = requireACallable(); + var internalSort = requireArraySort(); + var ArrayBufferViewCore = requireArrayBufferViewCore(); + var FF = requireEnvironmentFfVersion(); + var IE_OR_EDGE = requireEnvironmentIsIeOrEdge(); + var V8 = requireEnvironmentV8Version(); + var WEBKIT = requireEnvironmentWebkitVersion(); + + var aTypedArray = ArrayBufferViewCore.aTypedArray; + var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod; + var Uint16Array = globalThis.Uint16Array; + var nativeSort = Uint16Array && uncurryThis(Uint16Array.prototype.sort); + + // WebKit + var ACCEPT_INCORRECT_ARGUMENTS = !!nativeSort && !(fails(function () { + nativeSort(new Uint16Array(2), null); + }) && fails(function () { + nativeSort(new Uint16Array(2), {}); + })); + + var STABLE_SORT = !!nativeSort && !fails(function () { + // feature detection can be too slow, so check engines versions + if (V8) return V8 < 74; + if (FF) return FF < 67; + if (IE_OR_EDGE) return true; + if (WEBKIT) return WEBKIT < 602; + + var array = new Uint16Array(516); + var expected = Array(516); + var index, mod; + + for (index = 0; index < 516; index++) { + mod = index % 4; + array[index] = 515 - index; + expected[index] = index - 2 * mod + 3; + } + + nativeSort(array, function (a, b) { + return (a / 4 | 0) - (b / 4 | 0); + }); + + for (index = 0; index < 516; index++) { + if (array[index] !== expected[index]) return true; + } + }); + + var getSortCompare = function (comparefn) { + return function (x, y) { + if (comparefn !== undefined) return +comparefn(x, y) || 0; + // eslint-disable-next-line no-self-compare -- NaN check + if (y !== y) return -1; + // eslint-disable-next-line no-self-compare -- NaN check + if (x !== x) return 1; + if (x === 0 && y === 0) return 1 / x > 0 && 1 / y < 0 ? 1 : -1; + return x > y; + }; + }; + + // `%TypedArray%.prototype.sort` method + // https://tc39.es/ecma262/#sec-%typedarray%.prototype.sort + exportTypedArrayMethod('sort', function sort(comparefn) { + if (comparefn !== undefined) aCallable(comparefn); + if (STABLE_SORT) return nativeSort(this, comparefn); + + return internalSort(aTypedArray(this), getSortCompare(comparefn)); + }, !STABLE_SORT || ACCEPT_INCORRECT_ARGUMENTS); + return es_typedArray_sort; +} + +var es_typedArray_subarray = {}; + +var hasRequiredEs_typedArray_subarray; + +function requireEs_typedArray_subarray () { + if (hasRequiredEs_typedArray_subarray) return es_typedArray_subarray; + hasRequiredEs_typedArray_subarray = 1; + var ArrayBufferViewCore = requireArrayBufferViewCore(); + var toLength = requireToLength(); + var toAbsoluteIndex = requireToAbsoluteIndex(); + var typedArraySpeciesConstructor = requireTypedArraySpeciesConstructor(); + + var aTypedArray = ArrayBufferViewCore.aTypedArray; + var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod; + + // `%TypedArray%.prototype.subarray` method + // https://tc39.es/ecma262/#sec-%typedarray%.prototype.subarray + exportTypedArrayMethod('subarray', function subarray(begin, end) { + var O = aTypedArray(this); + var length = O.length; + var beginIndex = toAbsoluteIndex(begin, length); + var C = typedArraySpeciesConstructor(O); + return new C( + O.buffer, + O.byteOffset + beginIndex * O.BYTES_PER_ELEMENT, + toLength((end === undefined ? length : toAbsoluteIndex(end, length)) - beginIndex) + ); + }); + return es_typedArray_subarray; +} + +var es_typedArray_toLocaleString = {}; + +var hasRequiredEs_typedArray_toLocaleString; + +function requireEs_typedArray_toLocaleString () { + if (hasRequiredEs_typedArray_toLocaleString) return es_typedArray_toLocaleString; + hasRequiredEs_typedArray_toLocaleString = 1; + var globalThis = requireGlobalThis(); + var apply = requireFunctionApply(); + var ArrayBufferViewCore = requireArrayBufferViewCore(); + var fails = requireFails(); + var arraySlice = requireArraySlice(); + + var Int8Array = globalThis.Int8Array; + var aTypedArray = ArrayBufferViewCore.aTypedArray; + var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod; + var $toLocaleString = [].toLocaleString; + + // iOS Safari 6.x fails here + var TO_LOCALE_STRING_BUG = !!Int8Array && fails(function () { + $toLocaleString.call(new Int8Array(1)); + }); + + var FORCED = fails(function () { + return [1, 2].toLocaleString() !== new Int8Array([1, 2]).toLocaleString(); + }) || !fails(function () { + Int8Array.prototype.toLocaleString.call([1, 2]); + }); + + // `%TypedArray%.prototype.toLocaleString` method + // https://tc39.es/ecma262/#sec-%typedarray%.prototype.tolocalestring + exportTypedArrayMethod('toLocaleString', function toLocaleString() { + return apply( + $toLocaleString, + TO_LOCALE_STRING_BUG ? arraySlice(aTypedArray(this)) : aTypedArray(this), + arraySlice(arguments) + ); + }, FORCED); + return es_typedArray_toLocaleString; +} + +var es_typedArray_toReversed = {}; + +var hasRequiredEs_typedArray_toReversed; + +function requireEs_typedArray_toReversed () { + if (hasRequiredEs_typedArray_toReversed) return es_typedArray_toReversed; + hasRequiredEs_typedArray_toReversed = 1; + var arrayToReversed = requireArrayToReversed(); + var ArrayBufferViewCore = requireArrayBufferViewCore(); + + var aTypedArray = ArrayBufferViewCore.aTypedArray; + var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod; + var getTypedArrayConstructor = ArrayBufferViewCore.getTypedArrayConstructor; + + // `%TypedArray%.prototype.toReversed` method + // https://tc39.es/ecma262/#sec-%typedarray%.prototype.toreversed + exportTypedArrayMethod('toReversed', function toReversed() { + return arrayToReversed(aTypedArray(this), getTypedArrayConstructor(this)); + }); + return es_typedArray_toReversed; +} + +var es_typedArray_toSorted = {}; + +var hasRequiredEs_typedArray_toSorted; + +function requireEs_typedArray_toSorted () { + if (hasRequiredEs_typedArray_toSorted) return es_typedArray_toSorted; + hasRequiredEs_typedArray_toSorted = 1; + var ArrayBufferViewCore = requireArrayBufferViewCore(); + var uncurryThis = requireFunctionUncurryThis(); + var aCallable = requireACallable(); + var arrayFromConstructorAndList = requireArrayFromConstructorAndList(); + + var aTypedArray = ArrayBufferViewCore.aTypedArray; + var getTypedArrayConstructor = ArrayBufferViewCore.getTypedArrayConstructor; + var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod; + var sort = uncurryThis(ArrayBufferViewCore.TypedArrayPrototype.sort); + + // `%TypedArray%.prototype.toSorted` method + // https://tc39.es/ecma262/#sec-%typedarray%.prototype.tosorted + exportTypedArrayMethod('toSorted', function toSorted(compareFn) { + if (compareFn !== undefined) aCallable(compareFn); + var O = aTypedArray(this); + var A = arrayFromConstructorAndList(getTypedArrayConstructor(O), O); + return sort(A, compareFn); + }); + return es_typedArray_toSorted; +} + +var es_typedArray_toString = {}; + +var hasRequiredEs_typedArray_toString; + +function requireEs_typedArray_toString () { + if (hasRequiredEs_typedArray_toString) return es_typedArray_toString; + hasRequiredEs_typedArray_toString = 1; + var exportTypedArrayMethod = requireArrayBufferViewCore().exportTypedArrayMethod; + var fails = requireFails(); + var globalThis = requireGlobalThis(); + var uncurryThis = requireFunctionUncurryThis(); + + var Uint8Array = globalThis.Uint8Array; + var Uint8ArrayPrototype = Uint8Array && Uint8Array.prototype || {}; + var arrayToString = [].toString; + var join = uncurryThis([].join); + + if (fails(function () { arrayToString.call({}); })) { + arrayToString = function toString() { + return join(this); + }; + } + + var IS_NOT_ARRAY_METHOD = Uint8ArrayPrototype.toString !== arrayToString; + + // `%TypedArray%.prototype.toString` method + // https://tc39.es/ecma262/#sec-%typedarray%.prototype.tostring + exportTypedArrayMethod('toString', arrayToString, IS_NOT_ARRAY_METHOD); + return es_typedArray_toString; +} + +var es_typedArray_with = {}; + +var hasRequiredEs_typedArray_with; + +function requireEs_typedArray_with () { + if (hasRequiredEs_typedArray_with) return es_typedArray_with; + hasRequiredEs_typedArray_with = 1; + var arrayWith = requireArrayWith(); + var ArrayBufferViewCore = requireArrayBufferViewCore(); + var isBigIntArray = requireIsBigIntArray(); + var toIntegerOrInfinity = requireToIntegerOrInfinity(); + var toBigInt = requireToBigInt(); + + var aTypedArray = ArrayBufferViewCore.aTypedArray; + var getTypedArrayConstructor = ArrayBufferViewCore.getTypedArrayConstructor; + var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod; + + var PROPER_ORDER = !!function () { + try { + // eslint-disable-next-line no-throw-literal, es/no-typed-arrays, es/no-array-prototype-with -- required for testing + new Int8Array(1)['with'](2, { valueOf: function () { throw 8; } }); + } catch (error) { + // some early implementations, like WebKit, does not follow the final semantic + // https://github.com/tc39/proposal-change-array-by-copy/pull/86 + return error === 8; + } + }(); + + // `%TypedArray%.prototype.with` method + // https://tc39.es/ecma262/#sec-%typedarray%.prototype.with + exportTypedArrayMethod('with', { 'with': function (index, value) { + var O = aTypedArray(this); + var relativeIndex = toIntegerOrInfinity(index); + var actualValue = isBigIntArray(O) ? toBigInt(value) : +value; + return arrayWith(O, getTypedArrayConstructor(O), relativeIndex, actualValue); + } }['with'], !PROPER_ORDER); + return es_typedArray_with; +} + +var es_unescape = {}; + +var hasRequiredEs_unescape; + +function requireEs_unescape () { + if (hasRequiredEs_unescape) return es_unescape; + hasRequiredEs_unescape = 1; + var $ = require_export(); + var uncurryThis = requireFunctionUncurryThis(); + var toString = requireToString(); + + var fromCharCode = String.fromCharCode; + var charAt = uncurryThis(''.charAt); + var exec = uncurryThis(/./.exec); + var stringSlice = uncurryThis(''.slice); + + var hex2 = /^[\da-f]{2}$/i; + var hex4 = /^[\da-f]{4}$/i; + + // `unescape` method + // https://tc39.es/ecma262/#sec-unescape-string + $({ global: true }, { + unescape: function unescape(string) { + var str = toString(string); + var result = ''; + var length = str.length; + var index = 0; + var chr, part; + while (index < length) { + chr = charAt(str, index++); + if (chr === '%') { + if (charAt(str, index) === 'u') { + part = stringSlice(str, index + 1, index + 5); + if (exec(hex4, part)) { + result += fromCharCode(parseInt(part, 16)); + index += 5; + continue; + } + } else { + part = stringSlice(str, index, index + 2); + if (exec(hex2, part)) { + result += fromCharCode(parseInt(part, 16)); + index += 2; + continue; + } + } + } + result += chr; + } return result; + } + }); + return es_unescape; +} + +var es_weakMap = {}; + +var es_weakMap_constructor = {}; + +var collectionWeak; +var hasRequiredCollectionWeak; + +function requireCollectionWeak () { + if (hasRequiredCollectionWeak) return collectionWeak; + hasRequiredCollectionWeak = 1; + var uncurryThis = requireFunctionUncurryThis(); + var defineBuiltIns = requireDefineBuiltIns(); + var getWeakData = requireInternalMetadata().getWeakData; + var anInstance = requireAnInstance(); + var anObject = requireAnObject(); + var isNullOrUndefined = requireIsNullOrUndefined(); + var isObject = requireIsObject(); + var iterate = requireIterate(); + var ArrayIterationModule = requireArrayIteration(); + var hasOwn = requireHasOwnProperty(); + var InternalStateModule = requireInternalState(); + + var setInternalState = InternalStateModule.set; + var internalStateGetterFor = InternalStateModule.getterFor; + var find = ArrayIterationModule.find; + var findIndex = ArrayIterationModule.findIndex; + var splice = uncurryThis([].splice); + var id = 0; + + // fallback for uncaught frozen keys + var uncaughtFrozenStore = function (state) { + return state.frozen || (state.frozen = new UncaughtFrozenStore()); + }; + + var UncaughtFrozenStore = function () { + this.entries = []; + }; + + var findUncaughtFrozen = function (store, key) { + return find(store.entries, function (it) { + return it[0] === key; + }); + }; + + UncaughtFrozenStore.prototype = { + get: function (key) { + var entry = findUncaughtFrozen(this, key); + if (entry) return entry[1]; + }, + has: function (key) { + return !!findUncaughtFrozen(this, key); + }, + set: function (key, value) { + var entry = findUncaughtFrozen(this, key); + if (entry) entry[1] = value; + else this.entries.push([key, value]); + }, + 'delete': function (key) { + var index = findIndex(this.entries, function (it) { + return it[0] === key; + }); + if (~index) splice(this.entries, index, 1); + return !!~index; + } + }; + + collectionWeak = { + getConstructor: function (wrapper, CONSTRUCTOR_NAME, IS_MAP, ADDER) { + var Constructor = wrapper(function (that, iterable) { + anInstance(that, Prototype); + setInternalState(that, { + type: CONSTRUCTOR_NAME, + id: id++, + frozen: null + }); + if (!isNullOrUndefined(iterable)) iterate(iterable, that[ADDER], { that: that, AS_ENTRIES: IS_MAP }); + }); + + var Prototype = Constructor.prototype; + + var getInternalState = internalStateGetterFor(CONSTRUCTOR_NAME); + + var define = function (that, key, value) { + var state = getInternalState(that); + var data = getWeakData(anObject(key), true); + if (data === true) uncaughtFrozenStore(state).set(key, value); + else data[state.id] = value; + return that; + }; + + defineBuiltIns(Prototype, { + // `{ WeakMap, WeakSet }.prototype.delete(key)` methods + // https://tc39.es/ecma262/#sec-weakmap.prototype.delete + // https://tc39.es/ecma262/#sec-weakset.prototype.delete + 'delete': function (key) { + var state = getInternalState(this); + if (!isObject(key)) return false; + var data = getWeakData(key); + if (data === true) return uncaughtFrozenStore(state)['delete'](key); + return data && hasOwn(data, state.id) && delete data[state.id]; + }, + // `{ WeakMap, WeakSet }.prototype.has(key)` methods + // https://tc39.es/ecma262/#sec-weakmap.prototype.has + // https://tc39.es/ecma262/#sec-weakset.prototype.has + has: function has(key) { + var state = getInternalState(this); + if (!isObject(key)) return false; + var data = getWeakData(key); + if (data === true) return uncaughtFrozenStore(state).has(key); + return data && hasOwn(data, state.id); + } + }); + + defineBuiltIns(Prototype, IS_MAP ? { + // `WeakMap.prototype.get(key)` method + // https://tc39.es/ecma262/#sec-weakmap.prototype.get + get: function get(key) { + var state = getInternalState(this); + if (isObject(key)) { + var data = getWeakData(key); + if (data === true) return uncaughtFrozenStore(state).get(key); + if (data) return data[state.id]; + } + }, + // `WeakMap.prototype.set(key, value)` method + // https://tc39.es/ecma262/#sec-weakmap.prototype.set + set: function set(key, value) { + return define(this, key, value); + } + } : { + // `WeakSet.prototype.add(value)` method + // https://tc39.es/ecma262/#sec-weakset.prototype.add + add: function add(value) { + return define(this, value, true); + } + }); + + return Constructor; + } + }; + return collectionWeak; +} + +var hasRequiredEs_weakMap_constructor; + +function requireEs_weakMap_constructor () { + if (hasRequiredEs_weakMap_constructor) return es_weakMap_constructor; + hasRequiredEs_weakMap_constructor = 1; + var FREEZING = requireFreezing(); + var globalThis = requireGlobalThis(); + var uncurryThis = requireFunctionUncurryThis(); + var defineBuiltIns = requireDefineBuiltIns(); + var InternalMetadataModule = requireInternalMetadata(); + var collection = requireCollection(); + var collectionWeak = requireCollectionWeak(); + var isObject = requireIsObject(); + var enforceInternalState = requireInternalState().enforce; + var fails = requireFails(); + var NATIVE_WEAK_MAP = requireWeakMapBasicDetection(); + + var $Object = Object; + // eslint-disable-next-line es/no-array-isarray -- safe + var isArray = Array.isArray; + // eslint-disable-next-line es/no-object-isextensible -- safe + var isExtensible = $Object.isExtensible; + // eslint-disable-next-line es/no-object-isfrozen -- safe + var isFrozen = $Object.isFrozen; + // eslint-disable-next-line es/no-object-issealed -- safe + var isSealed = $Object.isSealed; + // eslint-disable-next-line es/no-object-freeze -- safe + var freeze = $Object.freeze; + // eslint-disable-next-line es/no-object-seal -- safe + var seal = $Object.seal; + + var IS_IE11 = !globalThis.ActiveXObject && 'ActiveXObject' in globalThis; + var InternalWeakMap; + + var wrapper = function (init) { + return function WeakMap() { + return init(this, arguments.length ? arguments[0] : undefined); + }; + }; + + // `WeakMap` constructor + // https://tc39.es/ecma262/#sec-weakmap-constructor + var $WeakMap = collection('WeakMap', wrapper, collectionWeak); + var WeakMapPrototype = $WeakMap.prototype; + var nativeSet = uncurryThis(WeakMapPrototype.set); + + // Chakra Edge bug: adding frozen arrays to WeakMap unfreeze them + var hasMSEdgeFreezingBug = function () { + return FREEZING && fails(function () { + var frozenArray = freeze([]); + nativeSet(new $WeakMap(), frozenArray, 1); + return !isFrozen(frozenArray); + }); + }; + + // IE11 WeakMap frozen keys fix + // We can't use feature detection because it crash some old IE builds + // https://github.com/zloirock/core-js/issues/485 + if (NATIVE_WEAK_MAP) if (IS_IE11) { + InternalWeakMap = collectionWeak.getConstructor(wrapper, 'WeakMap', true); + InternalMetadataModule.enable(); + var nativeDelete = uncurryThis(WeakMapPrototype['delete']); + var nativeHas = uncurryThis(WeakMapPrototype.has); + var nativeGet = uncurryThis(WeakMapPrototype.get); + defineBuiltIns(WeakMapPrototype, { + 'delete': function (key) { + if (isObject(key) && !isExtensible(key)) { + var state = enforceInternalState(this); + if (!state.frozen) state.frozen = new InternalWeakMap(); + return nativeDelete(this, key) || state.frozen['delete'](key); + } return nativeDelete(this, key); + }, + has: function has(key) { + if (isObject(key) && !isExtensible(key)) { + var state = enforceInternalState(this); + if (!state.frozen) state.frozen = new InternalWeakMap(); + return nativeHas(this, key) || state.frozen.has(key); + } return nativeHas(this, key); + }, + get: function get(key) { + if (isObject(key) && !isExtensible(key)) { + var state = enforceInternalState(this); + if (!state.frozen) state.frozen = new InternalWeakMap(); + return nativeHas(this, key) ? nativeGet(this, key) : state.frozen.get(key); + } return nativeGet(this, key); + }, + set: function set(key, value) { + if (isObject(key) && !isExtensible(key)) { + var state = enforceInternalState(this); + if (!state.frozen) state.frozen = new InternalWeakMap(); + nativeHas(this, key) ? nativeSet(this, key, value) : state.frozen.set(key, value); + } else nativeSet(this, key, value); + return this; + } + }); + // Chakra Edge frozen keys fix + } else if (hasMSEdgeFreezingBug()) { + defineBuiltIns(WeakMapPrototype, { + set: function set(key, value) { + var arrayIntegrityLevel; + if (isArray(key)) { + if (isFrozen(key)) arrayIntegrityLevel = freeze; + else if (isSealed(key)) arrayIntegrityLevel = seal; + } + nativeSet(this, key, value); + if (arrayIntegrityLevel) arrayIntegrityLevel(key); + return this; + } + }); + } + return es_weakMap_constructor; +} + +var hasRequiredEs_weakMap; + +function requireEs_weakMap () { + if (hasRequiredEs_weakMap) return es_weakMap; + hasRequiredEs_weakMap = 1; + // TODO: Remove this module from `core-js@4` since it's replaced to module below + requireEs_weakMap_constructor(); + return es_weakMap; +} + +var es_weakSet = {}; + +var es_weakSet_constructor = {}; + +var hasRequiredEs_weakSet_constructor; + +function requireEs_weakSet_constructor () { + if (hasRequiredEs_weakSet_constructor) return es_weakSet_constructor; + hasRequiredEs_weakSet_constructor = 1; + var collection = requireCollection(); + var collectionWeak = requireCollectionWeak(); + + // `WeakSet` constructor + // https://tc39.es/ecma262/#sec-weakset-constructor + collection('WeakSet', function (init) { + return function WeakSet() { return init(this, arguments.length ? arguments[0] : undefined); }; + }, collectionWeak); + return es_weakSet_constructor; +} + +var hasRequiredEs_weakSet; + +function requireEs_weakSet () { + if (hasRequiredEs_weakSet) return es_weakSet; + hasRequiredEs_weakSet = 1; + // TODO: Remove this module from `core-js@4` since it's replaced to module below + requireEs_weakSet_constructor(); + return es_weakSet; +} + +var esnext_aggregateError = {}; + +var hasRequiredEsnext_aggregateError; + +function requireEsnext_aggregateError () { + if (hasRequiredEsnext_aggregateError) return esnext_aggregateError; + hasRequiredEsnext_aggregateError = 1; + // TODO: Remove from `core-js@4` + requireEs_aggregateError(); + return esnext_aggregateError; +} + +var esnext_suppressedError_constructor = {}; + +var hasRequiredEsnext_suppressedError_constructor; + +function requireEsnext_suppressedError_constructor () { + if (hasRequiredEsnext_suppressedError_constructor) return esnext_suppressedError_constructor; + hasRequiredEsnext_suppressedError_constructor = 1; + var $ = require_export(); + var globalThis = requireGlobalThis(); + var isPrototypeOf = requireObjectIsPrototypeOf(); + var getPrototypeOf = requireObjectGetPrototypeOf(); + var setPrototypeOf = requireObjectSetPrototypeOf(); + var copyConstructorProperties = requireCopyConstructorProperties(); + var create = requireObjectCreate(); + var createNonEnumerableProperty = requireCreateNonEnumerableProperty(); + var createPropertyDescriptor = requireCreatePropertyDescriptor(); + var installErrorStack = requireErrorStackInstall(); + var normalizeStringArgument = requireNormalizeStringArgument(); + var wellKnownSymbol = requireWellKnownSymbol(); + var fails = requireFails(); + var IS_PURE = requireIsPure(); + + var NativeSuppressedError = globalThis.SuppressedError; + var TO_STRING_TAG = wellKnownSymbol('toStringTag'); + var $Error = Error; + + // https://github.com/oven-sh/bun/issues/9282 + var WRONG_ARITY = !!NativeSuppressedError && NativeSuppressedError.length !== 3; + + // https://github.com/oven-sh/bun/issues/9283 + var EXTRA_ARGS_SUPPORT = !!NativeSuppressedError && fails(function () { + return new NativeSuppressedError(1, 2, 3, { cause: 4 }).cause === 4; + }); + + var PATCH = WRONG_ARITY || EXTRA_ARGS_SUPPORT; + + var $SuppressedError = function SuppressedError(error, suppressed, message) { + var isInstance = isPrototypeOf(SuppressedErrorPrototype, this); + var that; + if (setPrototypeOf) { + that = PATCH && (!isInstance || getPrototypeOf(this) === SuppressedErrorPrototype) + ? new NativeSuppressedError() + : setPrototypeOf(new $Error(), isInstance ? getPrototypeOf(this) : SuppressedErrorPrototype); + } else { + that = isInstance ? this : create(SuppressedErrorPrototype); + createNonEnumerableProperty(that, TO_STRING_TAG, 'Error'); + } + if (message !== undefined) createNonEnumerableProperty(that, 'message', normalizeStringArgument(message)); + installErrorStack(that, $SuppressedError, that.stack, 1); + createNonEnumerableProperty(that, 'error', error); + createNonEnumerableProperty(that, 'suppressed', suppressed); + return that; + }; + + if (setPrototypeOf) setPrototypeOf($SuppressedError, $Error); + else copyConstructorProperties($SuppressedError, $Error, { name: true }); + + var SuppressedErrorPrototype = $SuppressedError.prototype = PATCH ? NativeSuppressedError.prototype : create($Error.prototype, { + constructor: createPropertyDescriptor(1, $SuppressedError), + message: createPropertyDescriptor(1, ''), + name: createPropertyDescriptor(1, 'SuppressedError') + }); + + if (PATCH && !IS_PURE) SuppressedErrorPrototype.constructor = $SuppressedError; + + // `SuppressedError` constructor + // https://github.com/tc39/proposal-explicit-resource-management + $({ global: true, constructor: true, arity: 3, forced: PATCH }, { + SuppressedError: $SuppressedError + }); + return esnext_suppressedError_constructor; +} + +var esnext_array_fromAsync = {}; + +var asyncIteratorPrototype; +var hasRequiredAsyncIteratorPrototype; + +function requireAsyncIteratorPrototype () { + if (hasRequiredAsyncIteratorPrototype) return asyncIteratorPrototype; + hasRequiredAsyncIteratorPrototype = 1; + var globalThis = requireGlobalThis(); + var shared = requireSharedStore(); + var isCallable = requireIsCallable(); + var create = requireObjectCreate(); + var getPrototypeOf = requireObjectGetPrototypeOf(); + var defineBuiltIn = requireDefineBuiltIn(); + var wellKnownSymbol = requireWellKnownSymbol(); + var IS_PURE = requireIsPure(); + + var USE_FUNCTION_CONSTRUCTOR = 'USE_FUNCTION_CONSTRUCTOR'; + var ASYNC_ITERATOR = wellKnownSymbol('asyncIterator'); + var AsyncIterator = globalThis.AsyncIterator; + var PassedAsyncIteratorPrototype = shared.AsyncIteratorPrototype; + var AsyncIteratorPrototype, prototype; + + if (PassedAsyncIteratorPrototype) { + AsyncIteratorPrototype = PassedAsyncIteratorPrototype; + } else if (isCallable(AsyncIterator)) { + AsyncIteratorPrototype = AsyncIterator.prototype; + } else if (shared[USE_FUNCTION_CONSTRUCTOR] || globalThis[USE_FUNCTION_CONSTRUCTOR]) { + try { + // eslint-disable-next-line no-new-func -- we have no alternatives without usage of modern syntax + prototype = getPrototypeOf(getPrototypeOf(getPrototypeOf(Function('return async function*(){}()')()))); + if (getPrototypeOf(prototype) === Object.prototype) AsyncIteratorPrototype = prototype; + } catch (error) { /* empty */ } + } + + if (!AsyncIteratorPrototype) AsyncIteratorPrototype = {}; + else if (IS_PURE) AsyncIteratorPrototype = create(AsyncIteratorPrototype); + + if (!isCallable(AsyncIteratorPrototype[ASYNC_ITERATOR])) { + defineBuiltIn(AsyncIteratorPrototype, ASYNC_ITERATOR, function () { + return this; + }); + } + + asyncIteratorPrototype = AsyncIteratorPrototype; + return asyncIteratorPrototype; +} + +var asyncFromSyncIterator; +var hasRequiredAsyncFromSyncIterator; + +function requireAsyncFromSyncIterator () { + if (hasRequiredAsyncFromSyncIterator) return asyncFromSyncIterator; + hasRequiredAsyncFromSyncIterator = 1; + var call = requireFunctionCall(); + var anObject = requireAnObject(); + var create = requireObjectCreate(); + var getMethod = requireGetMethod(); + var defineBuiltIns = requireDefineBuiltIns(); + var InternalStateModule = requireInternalState(); + var getBuiltIn = requireGetBuiltIn(); + var AsyncIteratorPrototype = requireAsyncIteratorPrototype(); + var createIterResultObject = requireCreateIterResultObject(); + + var Promise = getBuiltIn('Promise'); + + var ASYNC_FROM_SYNC_ITERATOR = 'AsyncFromSyncIterator'; + var setInternalState = InternalStateModule.set; + var getInternalState = InternalStateModule.getterFor(ASYNC_FROM_SYNC_ITERATOR); + + var asyncFromSyncIteratorContinuation = function (result, resolve, reject) { + var done = result.done; + Promise.resolve(result.value).then(function (value) { + resolve(createIterResultObject(value, done)); + }, reject); + }; + + var AsyncFromSyncIterator = function AsyncIterator(iteratorRecord) { + iteratorRecord.type = ASYNC_FROM_SYNC_ITERATOR; + setInternalState(this, iteratorRecord); + }; + + AsyncFromSyncIterator.prototype = defineBuiltIns(create(AsyncIteratorPrototype), { + next: function next() { + var state = getInternalState(this); + return new Promise(function (resolve, reject) { + var result = anObject(call(state.next, state.iterator)); + asyncFromSyncIteratorContinuation(result, resolve, reject); + }); + }, + 'return': function () { + var iterator = getInternalState(this).iterator; + return new Promise(function (resolve, reject) { + var $return = getMethod(iterator, 'return'); + if ($return === undefined) return resolve(createIterResultObject(undefined, true)); + var result = anObject(call($return, iterator)); + asyncFromSyncIteratorContinuation(result, resolve, reject); + }); + } + }); + + asyncFromSyncIterator = AsyncFromSyncIterator; + return asyncFromSyncIterator; +} + +var getAsyncIterator; +var hasRequiredGetAsyncIterator; + +function requireGetAsyncIterator () { + if (hasRequiredGetAsyncIterator) return getAsyncIterator; + hasRequiredGetAsyncIterator = 1; + var call = requireFunctionCall(); + var AsyncFromSyncIterator = requireAsyncFromSyncIterator(); + var anObject = requireAnObject(); + var getIterator = requireGetIterator(); + var getIteratorDirect = requireGetIteratorDirect(); + var getMethod = requireGetMethod(); + var wellKnownSymbol = requireWellKnownSymbol(); + + var ASYNC_ITERATOR = wellKnownSymbol('asyncIterator'); + + getAsyncIterator = function (it, usingIterator) { + var method = arguments.length < 2 ? getMethod(it, ASYNC_ITERATOR) : usingIterator; + return method ? anObject(call(method, it)) : new AsyncFromSyncIterator(getIteratorDirect(getIterator(it))); + }; + return getAsyncIterator; +} + +var asyncIteratorClose; +var hasRequiredAsyncIteratorClose; + +function requireAsyncIteratorClose () { + if (hasRequiredAsyncIteratorClose) return asyncIteratorClose; + hasRequiredAsyncIteratorClose = 1; + var call = requireFunctionCall(); + var getBuiltIn = requireGetBuiltIn(); + var getMethod = requireGetMethod(); + + asyncIteratorClose = function (iterator, method, argument, reject) { + try { + var returnMethod = getMethod(iterator, 'return'); + if (returnMethod) { + return getBuiltIn('Promise').resolve(call(returnMethod, iterator)).then(function () { + method(argument); + }, function (error) { + reject(error); + }); + } + } catch (error2) { + return reject(error2); + } method(argument); + }; + return asyncIteratorClose; +} + +var asyncIteratorIteration; +var hasRequiredAsyncIteratorIteration; + +function requireAsyncIteratorIteration () { + if (hasRequiredAsyncIteratorIteration) return asyncIteratorIteration; + hasRequiredAsyncIteratorIteration = 1; + // https://github.com/tc39/proposal-iterator-helpers + // https://github.com/tc39/proposal-array-from-async + var call = requireFunctionCall(); + var aCallable = requireACallable(); + var anObject = requireAnObject(); + var isObject = requireIsObject(); + var doesNotExceedSafeInteger = requireDoesNotExceedSafeInteger(); + var getBuiltIn = requireGetBuiltIn(); + var getIteratorDirect = requireGetIteratorDirect(); + var closeAsyncIteration = requireAsyncIteratorClose(); + + var createMethod = function (TYPE) { + var IS_TO_ARRAY = TYPE === 0; + var IS_FOR_EACH = TYPE === 1; + var IS_EVERY = TYPE === 2; + var IS_SOME = TYPE === 3; + return function (object, fn, target) { + anObject(object); + var MAPPING = fn !== undefined; + if (MAPPING || !IS_TO_ARRAY) aCallable(fn); + var record = getIteratorDirect(object); + var Promise = getBuiltIn('Promise'); + var iterator = record.iterator; + var next = record.next; + var counter = 0; + + return new Promise(function (resolve, reject) { + var ifAbruptCloseAsyncIterator = function (error) { + closeAsyncIteration(iterator, reject, error, reject); + }; + + var loop = function () { + try { + if (MAPPING) try { + doesNotExceedSafeInteger(counter); + } catch (error5) { ifAbruptCloseAsyncIterator(error5); } + Promise.resolve(anObject(call(next, iterator))).then(function (step) { + try { + if (anObject(step).done) { + if (IS_TO_ARRAY) { + target.length = counter; + resolve(target); + } else resolve(IS_SOME ? false : IS_EVERY || undefined); + } else { + var value = step.value; + try { + if (MAPPING) { + var result = fn(value, counter); + + var handler = function ($result) { + if (IS_FOR_EACH) { + loop(); + } else if (IS_EVERY) { + $result ? loop() : closeAsyncIteration(iterator, resolve, false, reject); + } else if (IS_TO_ARRAY) { + try { + target[counter++] = $result; + loop(); + } catch (error4) { ifAbruptCloseAsyncIterator(error4); } + } else { + $result ? closeAsyncIteration(iterator, resolve, IS_SOME || value, reject) : loop(); + } + }; + + if (isObject(result)) Promise.resolve(result).then(handler, ifAbruptCloseAsyncIterator); + else handler(result); + } else { + target[counter++] = value; + loop(); + } + } catch (error3) { ifAbruptCloseAsyncIterator(error3); } + } + } catch (error2) { reject(error2); } + }, reject); + } catch (error) { reject(error); } + }; + + loop(); + }); + }; + }; + + asyncIteratorIteration = { + toArray: createMethod(0), + forEach: createMethod(1), + every: createMethod(2), + some: createMethod(3), + find: createMethod(4) + }; + return asyncIteratorIteration; +} + +var arrayFromAsync; +var hasRequiredArrayFromAsync; + +function requireArrayFromAsync () { + if (hasRequiredArrayFromAsync) return arrayFromAsync; + hasRequiredArrayFromAsync = 1; + var bind = requireFunctionBindContext(); + var uncurryThis = requireFunctionUncurryThis(); + var toObject = requireToObject(); + var isConstructor = requireIsConstructor(); + var getAsyncIterator = requireGetAsyncIterator(); + var getIterator = requireGetIterator(); + var getIteratorDirect = requireGetIteratorDirect(); + var getIteratorMethod = requireGetIteratorMethod(); + var getMethod = requireGetMethod(); + var getBuiltIn = requireGetBuiltIn(); + var getBuiltInPrototypeMethod = requireGetBuiltInPrototypeMethod(); + var wellKnownSymbol = requireWellKnownSymbol(); + var AsyncFromSyncIterator = requireAsyncFromSyncIterator(); + var toArray = requireAsyncIteratorIteration().toArray; + + var ASYNC_ITERATOR = wellKnownSymbol('asyncIterator'); + var arrayIterator = uncurryThis(getBuiltInPrototypeMethod('Array', 'values')); + var arrayIteratorNext = uncurryThis(arrayIterator([]).next); + + var safeArrayIterator = function () { + return new SafeArrayIterator(this); + }; + + var SafeArrayIterator = function (O) { + this.iterator = arrayIterator(O); + }; + + SafeArrayIterator.prototype.next = function () { + return arrayIteratorNext(this.iterator); + }; + + // `Array.fromAsync` method implementation + // https://github.com/tc39/proposal-array-from-async + arrayFromAsync = function fromAsync(asyncItems /* , mapfn = undefined, thisArg = undefined */) { + var C = this; + var argumentsLength = arguments.length; + var mapfn = argumentsLength > 1 ? arguments[1] : undefined; + var thisArg = argumentsLength > 2 ? arguments[2] : undefined; + return new (getBuiltIn('Promise'))(function (resolve) { + var O = toObject(asyncItems); + if (mapfn !== undefined) mapfn = bind(mapfn, thisArg); + var usingAsyncIterator = getMethod(O, ASYNC_ITERATOR); + var usingSyncIterator = usingAsyncIterator ? undefined : getIteratorMethod(O) || safeArrayIterator; + var A = isConstructor(C) ? new C() : []; + var iterator = usingAsyncIterator + ? getAsyncIterator(O, usingAsyncIterator) + : new AsyncFromSyncIterator(getIteratorDirect(getIterator(O, usingSyncIterator))); + resolve(toArray(iterator, mapfn, A)); + }); + }; + return arrayFromAsync; +} + +var hasRequiredEsnext_array_fromAsync; + +function requireEsnext_array_fromAsync () { + if (hasRequiredEsnext_array_fromAsync) return esnext_array_fromAsync; + hasRequiredEsnext_array_fromAsync = 1; + var $ = require_export(); + var fromAsync = requireArrayFromAsync(); + var fails = requireFails(); + + var nativeFromAsync = Array.fromAsync; + // https://bugs.webkit.org/show_bug.cgi?id=271703 + var INCORRECT_CONSTRUCTURING = !nativeFromAsync || fails(function () { + var counter = 0; + nativeFromAsync.call(function () { + counter++; + return []; + }, { length: 0 }); + return counter !== 1; + }); + + // `Array.fromAsync` method + // https://github.com/tc39/proposal-array-from-async + $({ target: 'Array', stat: true, forced: INCORRECT_CONSTRUCTURING }, { + fromAsync: fromAsync + }); + return esnext_array_fromAsync; +} + +var esnext_array_at = {}; + +var hasRequiredEsnext_array_at; + +function requireEsnext_array_at () { + if (hasRequiredEsnext_array_at) return esnext_array_at; + hasRequiredEsnext_array_at = 1; + // TODO: Remove from `core-js@4` + requireEs_array_at(); + return esnext_array_at; +} + +var esnext_array_filterOut = {}; + +var hasRequiredEsnext_array_filterOut; + +function requireEsnext_array_filterOut () { + if (hasRequiredEsnext_array_filterOut) return esnext_array_filterOut; + hasRequiredEsnext_array_filterOut = 1; + // TODO: remove from `core-js@4` + var $ = require_export(); + var $filterReject = requireArrayIteration().filterReject; + var addToUnscopables = requireAddToUnscopables(); + + // `Array.prototype.filterOut` method + // https://github.com/tc39/proposal-array-filtering + $({ target: 'Array', proto: true, forced: true }, { + filterOut: function filterOut(callbackfn /* , thisArg */) { + return $filterReject(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined); + } + }); + + addToUnscopables('filterOut'); + return esnext_array_filterOut; +} + +var esnext_array_filterReject = {}; + +var hasRequiredEsnext_array_filterReject; + +function requireEsnext_array_filterReject () { + if (hasRequiredEsnext_array_filterReject) return esnext_array_filterReject; + hasRequiredEsnext_array_filterReject = 1; + var $ = require_export(); + var $filterReject = requireArrayIteration().filterReject; + var addToUnscopables = requireAddToUnscopables(); + + // `Array.prototype.filterReject` method + // https://github.com/tc39/proposal-array-filtering + $({ target: 'Array', proto: true, forced: true }, { + filterReject: function filterReject(callbackfn /* , thisArg */) { + return $filterReject(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined); + } + }); + + addToUnscopables('filterReject'); + return esnext_array_filterReject; +} + +var esnext_array_findLast = {}; + +var hasRequiredEsnext_array_findLast; + +function requireEsnext_array_findLast () { + if (hasRequiredEsnext_array_findLast) return esnext_array_findLast; + hasRequiredEsnext_array_findLast = 1; + // TODO: Remove from `core-js@4` + requireEs_array_findLast(); + return esnext_array_findLast; +} + +var esnext_array_findLastIndex = {}; + +var hasRequiredEsnext_array_findLastIndex; + +function requireEsnext_array_findLastIndex () { + if (hasRequiredEsnext_array_findLastIndex) return esnext_array_findLastIndex; + hasRequiredEsnext_array_findLastIndex = 1; + // TODO: Remove from `core-js@4` + requireEs_array_findLastIndex(); + return esnext_array_findLastIndex; +} + +var esnext_array_group = {}; + +var arrayGroup; +var hasRequiredArrayGroup; + +function requireArrayGroup () { + if (hasRequiredArrayGroup) return arrayGroup; + hasRequiredArrayGroup = 1; + var bind = requireFunctionBindContext(); + var uncurryThis = requireFunctionUncurryThis(); + var IndexedObject = requireIndexedObject(); + var toObject = requireToObject(); + var toPropertyKey = requireToPropertyKey(); + var lengthOfArrayLike = requireLengthOfArrayLike(); + var objectCreate = requireObjectCreate(); + var arrayFromConstructorAndList = requireArrayFromConstructorAndList(); + + var $Array = Array; + var push = uncurryThis([].push); + + arrayGroup = function ($this, callbackfn, that, specificConstructor) { + var O = toObject($this); + var self = IndexedObject(O); + var boundFunction = bind(callbackfn, that); + var target = objectCreate(null); + var length = lengthOfArrayLike(self); + var index = 0; + var Constructor, key, value; + for (;length > index; index++) { + value = self[index]; + key = toPropertyKey(boundFunction(value, index, O)); + // in some IE versions, `hasOwnProperty` returns incorrect result on integer keys + // but since it's a `null` prototype object, we can safely use `in` + if (key in target) push(target[key], value); + else target[key] = [value]; + } + // TODO: Remove this block from `core-js@4` + if (specificConstructor) { + Constructor = specificConstructor(O); + if (Constructor !== $Array) { + for (key in target) target[key] = arrayFromConstructorAndList(Constructor, target[key]); + } + } return target; + }; + return arrayGroup; +} + +var hasRequiredEsnext_array_group; + +function requireEsnext_array_group () { + if (hasRequiredEsnext_array_group) return esnext_array_group; + hasRequiredEsnext_array_group = 1; + var $ = require_export(); + var $group = requireArrayGroup(); + var addToUnscopables = requireAddToUnscopables(); + + // `Array.prototype.group` method + // https://github.com/tc39/proposal-array-grouping + $({ target: 'Array', proto: true }, { + group: function group(callbackfn /* , thisArg */) { + var thisArg = arguments.length > 1 ? arguments[1] : undefined; + return $group(this, callbackfn, thisArg); + } + }); + + addToUnscopables('group'); + return esnext_array_group; +} + +var esnext_array_groupBy = {}; + +var hasRequiredEsnext_array_groupBy; + +function requireEsnext_array_groupBy () { + if (hasRequiredEsnext_array_groupBy) return esnext_array_groupBy; + hasRequiredEsnext_array_groupBy = 1; + // TODO: Remove from `core-js@4` + var $ = require_export(); + var $group = requireArrayGroup(); + var arrayMethodIsStrict = requireArrayMethodIsStrict(); + var addToUnscopables = requireAddToUnscopables(); + + // `Array.prototype.groupBy` method + // https://github.com/tc39/proposal-array-grouping + // https://bugs.webkit.org/show_bug.cgi?id=236541 + $({ target: 'Array', proto: true, forced: !arrayMethodIsStrict('groupBy') }, { + groupBy: function groupBy(callbackfn /* , thisArg */) { + var thisArg = arguments.length > 1 ? arguments[1] : undefined; + return $group(this, callbackfn, thisArg); + } + }); + + addToUnscopables('groupBy'); + return esnext_array_groupBy; +} + +var esnext_array_groupByToMap = {}; + +var arrayGroupToMap; +var hasRequiredArrayGroupToMap; + +function requireArrayGroupToMap () { + if (hasRequiredArrayGroupToMap) return arrayGroupToMap; + hasRequiredArrayGroupToMap = 1; + var bind = requireFunctionBindContext(); + var uncurryThis = requireFunctionUncurryThis(); + var IndexedObject = requireIndexedObject(); + var toObject = requireToObject(); + var lengthOfArrayLike = requireLengthOfArrayLike(); + var MapHelpers = requireMapHelpers(); + + var Map = MapHelpers.Map; + var mapGet = MapHelpers.get; + var mapHas = MapHelpers.has; + var mapSet = MapHelpers.set; + var push = uncurryThis([].push); + + // `Array.prototype.groupToMap` method + // https://github.com/tc39/proposal-array-grouping + arrayGroupToMap = function groupToMap(callbackfn /* , thisArg */) { + var O = toObject(this); + var self = IndexedObject(O); + var boundFunction = bind(callbackfn, arguments.length > 1 ? arguments[1] : undefined); + var map = new Map(); + var length = lengthOfArrayLike(self); + var index = 0; + var key, value; + for (;length > index; index++) { + value = self[index]; + key = boundFunction(value, index, O); + if (mapHas(map, key)) push(mapGet(map, key), value); + else mapSet(map, key, [value]); + } return map; + }; + return arrayGroupToMap; +} + +var hasRequiredEsnext_array_groupByToMap; + +function requireEsnext_array_groupByToMap () { + if (hasRequiredEsnext_array_groupByToMap) return esnext_array_groupByToMap; + hasRequiredEsnext_array_groupByToMap = 1; + // TODO: Remove from `core-js@4` + var $ = require_export(); + var arrayMethodIsStrict = requireArrayMethodIsStrict(); + var addToUnscopables = requireAddToUnscopables(); + var $groupToMap = requireArrayGroupToMap(); + var IS_PURE = requireIsPure(); + + // `Array.prototype.groupByToMap` method + // https://github.com/tc39/proposal-array-grouping + // https://bugs.webkit.org/show_bug.cgi?id=236541 + $({ target: 'Array', proto: true, name: 'groupToMap', forced: IS_PURE || !arrayMethodIsStrict('groupByToMap') }, { + groupByToMap: $groupToMap + }); + + addToUnscopables('groupByToMap'); + return esnext_array_groupByToMap; +} + +var esnext_array_groupToMap = {}; + +var hasRequiredEsnext_array_groupToMap; + +function requireEsnext_array_groupToMap () { + if (hasRequiredEsnext_array_groupToMap) return esnext_array_groupToMap; + hasRequiredEsnext_array_groupToMap = 1; + var $ = require_export(); + var addToUnscopables = requireAddToUnscopables(); + var $groupToMap = requireArrayGroupToMap(); + var IS_PURE = requireIsPure(); + + // `Array.prototype.groupToMap` method + // https://github.com/tc39/proposal-array-grouping + $({ target: 'Array', proto: true, forced: IS_PURE }, { + groupToMap: $groupToMap + }); + + addToUnscopables('groupToMap'); + return esnext_array_groupToMap; +} + +var esnext_array_isTemplateObject = {}; + +var hasRequiredEsnext_array_isTemplateObject; + +function requireEsnext_array_isTemplateObject () { + if (hasRequiredEsnext_array_isTemplateObject) return esnext_array_isTemplateObject; + hasRequiredEsnext_array_isTemplateObject = 1; + var $ = require_export(); + var isArray = requireIsArray(); + + // eslint-disable-next-line es/no-object-isfrozen -- safe + var isFrozen = Object.isFrozen; + + var isFrozenStringArray = function (array, allowUndefined) { + if (!isFrozen || !isArray(array) || !isFrozen(array)) return false; + var index = 0; + var length = array.length; + var element; + while (index < length) { + element = array[index++]; + if (!(typeof element == 'string' || (allowUndefined && element === undefined))) { + return false; + } + } return length !== 0; + }; + + // `Array.isTemplateObject` method + // https://github.com/tc39/proposal-array-is-template-object + $({ target: 'Array', stat: true, sham: true, forced: true }, { + isTemplateObject: function isTemplateObject(value) { + if (!isFrozenStringArray(value, true)) return false; + var raw = value.raw; + return raw.length === value.length && isFrozenStringArray(raw, false); + } + }); + return esnext_array_isTemplateObject; +} + +var esnext_array_lastIndex = {}; + +var hasRequiredEsnext_array_lastIndex; + +function requireEsnext_array_lastIndex () { + if (hasRequiredEsnext_array_lastIndex) return esnext_array_lastIndex; + hasRequiredEsnext_array_lastIndex = 1; + // TODO: Remove from `core-js@4` + var DESCRIPTORS = requireDescriptors(); + var addToUnscopables = requireAddToUnscopables(); + var toObject = requireToObject(); + var lengthOfArrayLike = requireLengthOfArrayLike(); + var defineBuiltInAccessor = requireDefineBuiltInAccessor(); + + // `Array.prototype.lastIndex` getter + // https://github.com/keithamus/proposal-array-last + if (DESCRIPTORS) { + defineBuiltInAccessor(Array.prototype, 'lastIndex', { + configurable: true, + get: function lastIndex() { + var O = toObject(this); + var len = lengthOfArrayLike(O); + return len === 0 ? 0 : len - 1; + } + }); + + addToUnscopables('lastIndex'); + } + return esnext_array_lastIndex; +} + +var esnext_array_lastItem = {}; + +var hasRequiredEsnext_array_lastItem; + +function requireEsnext_array_lastItem () { + if (hasRequiredEsnext_array_lastItem) return esnext_array_lastItem; + hasRequiredEsnext_array_lastItem = 1; + // TODO: Remove from `core-js@4` + var DESCRIPTORS = requireDescriptors(); + var addToUnscopables = requireAddToUnscopables(); + var toObject = requireToObject(); + var lengthOfArrayLike = requireLengthOfArrayLike(); + var defineBuiltInAccessor = requireDefineBuiltInAccessor(); + + // `Array.prototype.lastIndex` accessor + // https://github.com/keithamus/proposal-array-last + if (DESCRIPTORS) { + defineBuiltInAccessor(Array.prototype, 'lastItem', { + configurable: true, + get: function lastItem() { + var O = toObject(this); + var len = lengthOfArrayLike(O); + return len === 0 ? undefined : O[len - 1]; + }, + set: function lastItem(value) { + var O = toObject(this); + var len = lengthOfArrayLike(O); + return O[len === 0 ? 0 : len - 1] = value; + } + }); + + addToUnscopables('lastItem'); + } + return esnext_array_lastItem; +} + +var esnext_array_toReversed = {}; + +var hasRequiredEsnext_array_toReversed; + +function requireEsnext_array_toReversed () { + if (hasRequiredEsnext_array_toReversed) return esnext_array_toReversed; + hasRequiredEsnext_array_toReversed = 1; + // TODO: Remove from `core-js@4` + requireEs_array_toReversed(); + return esnext_array_toReversed; +} + +var esnext_array_toSorted = {}; + +var hasRequiredEsnext_array_toSorted; + +function requireEsnext_array_toSorted () { + if (hasRequiredEsnext_array_toSorted) return esnext_array_toSorted; + hasRequiredEsnext_array_toSorted = 1; + // TODO: Remove from `core-js@4` + requireEs_array_toSorted(); + return esnext_array_toSorted; +} + +var esnext_array_toSpliced = {}; + +var hasRequiredEsnext_array_toSpliced; + +function requireEsnext_array_toSpliced () { + if (hasRequiredEsnext_array_toSpliced) return esnext_array_toSpliced; + hasRequiredEsnext_array_toSpliced = 1; + // TODO: Remove from `core-js@4` + requireEs_array_toSpliced(); + return esnext_array_toSpliced; +} + +var esnext_array_uniqueBy = {}; + +var mapIterate; +var hasRequiredMapIterate; + +function requireMapIterate () { + if (hasRequiredMapIterate) return mapIterate; + hasRequiredMapIterate = 1; + var uncurryThis = requireFunctionUncurryThis(); + var iterateSimple = requireIterateSimple(); + var MapHelpers = requireMapHelpers(); + + var Map = MapHelpers.Map; + var MapPrototype = MapHelpers.proto; + var forEach = uncurryThis(MapPrototype.forEach); + var entries = uncurryThis(MapPrototype.entries); + var next = entries(new Map()).next; + + mapIterate = function (map, fn, interruptible) { + return interruptible ? iterateSimple({ iterator: entries(map), next: next }, function (entry) { + return fn(entry[1], entry[0]); + }) : forEach(map, fn); + }; + return mapIterate; +} + +var arrayUniqueBy; +var hasRequiredArrayUniqueBy; + +function requireArrayUniqueBy () { + if (hasRequiredArrayUniqueBy) return arrayUniqueBy; + hasRequiredArrayUniqueBy = 1; + var uncurryThis = requireFunctionUncurryThis(); + var aCallable = requireACallable(); + var isNullOrUndefined = requireIsNullOrUndefined(); + var lengthOfArrayLike = requireLengthOfArrayLike(); + var toObject = requireToObject(); + var MapHelpers = requireMapHelpers(); + var iterate = requireMapIterate(); + + var Map = MapHelpers.Map; + var mapHas = MapHelpers.has; + var mapSet = MapHelpers.set; + var push = uncurryThis([].push); + + // `Array.prototype.uniqueBy` method + // https://github.com/tc39/proposal-array-unique + arrayUniqueBy = function uniqueBy(resolver) { + var that = toObject(this); + var length = lengthOfArrayLike(that); + var result = []; + var map = new Map(); + var resolverFunction = !isNullOrUndefined(resolver) ? aCallable(resolver) : function (value) { + return value; + }; + var index, item, key; + for (index = 0; index < length; index++) { + item = that[index]; + key = resolverFunction(item); + if (!mapHas(map, key)) mapSet(map, key, item); + } + iterate(map, function (value) { + push(result, value); + }); + return result; + }; + return arrayUniqueBy; +} + +var hasRequiredEsnext_array_uniqueBy; + +function requireEsnext_array_uniqueBy () { + if (hasRequiredEsnext_array_uniqueBy) return esnext_array_uniqueBy; + hasRequiredEsnext_array_uniqueBy = 1; + var $ = require_export(); + var addToUnscopables = requireAddToUnscopables(); + var uniqueBy = requireArrayUniqueBy(); + + // `Array.prototype.uniqueBy` method + // https://github.com/tc39/proposal-array-unique + $({ target: 'Array', proto: true, forced: true }, { + uniqueBy: uniqueBy + }); + + addToUnscopables('uniqueBy'); + return esnext_array_uniqueBy; +} + +var esnext_array_with = {}; + +var hasRequiredEsnext_array_with; + +function requireEsnext_array_with () { + if (hasRequiredEsnext_array_with) return esnext_array_with; + hasRequiredEsnext_array_with = 1; + // TODO: Remove from `core-js@4` + requireEs_array_with(); + return esnext_array_with; +} + +var esnext_arrayBuffer_detached = {}; + +var hasRequiredEsnext_arrayBuffer_detached; + +function requireEsnext_arrayBuffer_detached () { + if (hasRequiredEsnext_arrayBuffer_detached) return esnext_arrayBuffer_detached; + hasRequiredEsnext_arrayBuffer_detached = 1; + // TODO: Remove from `core-js@4` + requireEs_arrayBuffer_detached(); + return esnext_arrayBuffer_detached; +} + +var esnext_arrayBuffer_transfer = {}; + +var hasRequiredEsnext_arrayBuffer_transfer; + +function requireEsnext_arrayBuffer_transfer () { + if (hasRequiredEsnext_arrayBuffer_transfer) return esnext_arrayBuffer_transfer; + hasRequiredEsnext_arrayBuffer_transfer = 1; + // TODO: Remove from `core-js@4` + requireEs_arrayBuffer_transfer(); + return esnext_arrayBuffer_transfer; +} + +var esnext_arrayBuffer_transferToFixedLength = {}; + +var hasRequiredEsnext_arrayBuffer_transferToFixedLength; + +function requireEsnext_arrayBuffer_transferToFixedLength () { + if (hasRequiredEsnext_arrayBuffer_transferToFixedLength) return esnext_arrayBuffer_transferToFixedLength; + hasRequiredEsnext_arrayBuffer_transferToFixedLength = 1; + // TODO: Remove from `core-js@4` + requireEs_arrayBuffer_transferToFixedLength(); + return esnext_arrayBuffer_transferToFixedLength; +} + +var esnext_asyncDisposableStack_constructor = {}; + +var addDisposableResource; +var hasRequiredAddDisposableResource; + +function requireAddDisposableResource () { + if (hasRequiredAddDisposableResource) return addDisposableResource; + hasRequiredAddDisposableResource = 1; + var call = requireFunctionCall(); + var uncurryThis = requireFunctionUncurryThis(); + var bind = requireFunctionBindContext(); + var anObject = requireAnObject(); + var aCallable = requireACallable(); + var isNullOrUndefined = requireIsNullOrUndefined(); + var getMethod = requireGetMethod(); + var wellKnownSymbol = requireWellKnownSymbol(); + + var ASYNC_DISPOSE = wellKnownSymbol('asyncDispose'); + var DISPOSE = wellKnownSymbol('dispose'); + + var push = uncurryThis([].push); + + // `GetDisposeMethod` abstract operation + // https://tc39.es/proposal-explicit-resource-management/#sec-getdisposemethod + var getDisposeMethod = function (V, hint) { + if (hint === 'async-dispose') { + var method = getMethod(V, ASYNC_DISPOSE); + if (method !== undefined) return method; + method = getMethod(V, DISPOSE); + if (method === undefined) return method; + return function () { + call(method, this); + }; + } return getMethod(V, DISPOSE); + }; + + // `CreateDisposableResource` abstract operation + // https://tc39.es/proposal-explicit-resource-management/#sec-createdisposableresource + var createDisposableResource = function (V, hint, method) { + if (arguments.length < 3 && !isNullOrUndefined(V)) { + method = aCallable(getDisposeMethod(anObject(V), hint)); + } + + return method === undefined ? function () { + return undefined; + } : bind(method, V); + }; + + // `AddDisposableResource` abstract operation + // https://tc39.es/proposal-explicit-resource-management/#sec-adddisposableresource + addDisposableResource = function (disposable, V, hint, method) { + var resource; + if (arguments.length < 4) { + // When `V`` is either `null` or `undefined` and hint is `async-dispose`, + // we record that the resource was evaluated to ensure we will still perform an `Await` when resources are later disposed. + if (isNullOrUndefined(V) && hint === 'sync-dispose') return; + resource = createDisposableResource(V, hint); + } else { + resource = createDisposableResource(undefined, hint, method); + } + + push(disposable.stack, resource); + }; + return addDisposableResource; +} + +var hasRequiredEsnext_asyncDisposableStack_constructor; + +function requireEsnext_asyncDisposableStack_constructor () { + if (hasRequiredEsnext_asyncDisposableStack_constructor) return esnext_asyncDisposableStack_constructor; + hasRequiredEsnext_asyncDisposableStack_constructor = 1; + // https://github.com/tc39/proposal-async-explicit-resource-management + var $ = require_export(); + var DESCRIPTORS = requireDescriptors(); + var getBuiltIn = requireGetBuiltIn(); + var aCallable = requireACallable(); + var anInstance = requireAnInstance(); + var defineBuiltIn = requireDefineBuiltIn(); + var defineBuiltIns = requireDefineBuiltIns(); + var defineBuiltInAccessor = requireDefineBuiltInAccessor(); + var wellKnownSymbol = requireWellKnownSymbol(); + var InternalStateModule = requireInternalState(); + var addDisposableResource = requireAddDisposableResource(); + + var Promise = getBuiltIn('Promise'); + var SuppressedError = getBuiltIn('SuppressedError'); + var $ReferenceError = ReferenceError; + + var ASYNC_DISPOSE = wellKnownSymbol('asyncDispose'); + var TO_STRING_TAG = wellKnownSymbol('toStringTag'); + + var ASYNC_DISPOSABLE_STACK = 'AsyncDisposableStack'; + var setInternalState = InternalStateModule.set; + var getAsyncDisposableStackInternalState = InternalStateModule.getterFor(ASYNC_DISPOSABLE_STACK); + + var HINT = 'async-dispose'; + var DISPOSED = 'disposed'; + var PENDING = 'pending'; + + var getPendingAsyncDisposableStackInternalState = function (stack) { + var internalState = getAsyncDisposableStackInternalState(stack); + if (internalState.state === DISPOSED) throw new $ReferenceError(ASYNC_DISPOSABLE_STACK + ' already disposed'); + return internalState; + }; + + var $AsyncDisposableStack = function AsyncDisposableStack() { + setInternalState(anInstance(this, AsyncDisposableStackPrototype), { + type: ASYNC_DISPOSABLE_STACK, + state: PENDING, + stack: [] + }); + + if (!DESCRIPTORS) this.disposed = false; + }; + + var AsyncDisposableStackPrototype = $AsyncDisposableStack.prototype; + + defineBuiltIns(AsyncDisposableStackPrototype, { + disposeAsync: function disposeAsync() { + var asyncDisposableStack = this; + return new Promise(function (resolve, reject) { + var internalState = getAsyncDisposableStackInternalState(asyncDisposableStack); + if (internalState.state === DISPOSED) return resolve(undefined); + internalState.state = DISPOSED; + if (!DESCRIPTORS) asyncDisposableStack.disposed = true; + var stack = internalState.stack; + var i = stack.length; + var thrown = false; + var suppressed; + + var handleError = function (result) { + if (thrown) { + suppressed = new SuppressedError(result, suppressed); + } else { + thrown = true; + suppressed = result; + } + + loop(); + }; + + var loop = function () { + if (i) { + var disposeMethod = stack[--i]; + stack[i] = null; + try { + Promise.resolve(disposeMethod()).then(loop, handleError); + } catch (error) { + handleError(error); + } + } else { + internalState.stack = null; + thrown ? reject(suppressed) : resolve(undefined); + } + }; + + loop(); + }); + }, + use: function use(value) { + addDisposableResource(getPendingAsyncDisposableStackInternalState(this), value, HINT); + return value; + }, + adopt: function adopt(value, onDispose) { + var internalState = getPendingAsyncDisposableStackInternalState(this); + aCallable(onDispose); + addDisposableResource(internalState, undefined, HINT, function () { + return onDispose(value); + }); + return value; + }, + defer: function defer(onDispose) { + var internalState = getPendingAsyncDisposableStackInternalState(this); + aCallable(onDispose); + addDisposableResource(internalState, undefined, HINT, onDispose); + }, + move: function move() { + var internalState = getPendingAsyncDisposableStackInternalState(this); + var newAsyncDisposableStack = new $AsyncDisposableStack(); + getAsyncDisposableStackInternalState(newAsyncDisposableStack).stack = internalState.stack; + internalState.stack = []; + internalState.state = DISPOSED; + if (!DESCRIPTORS) this.disposed = true; + return newAsyncDisposableStack; + } + }); + + if (DESCRIPTORS) defineBuiltInAccessor(AsyncDisposableStackPrototype, 'disposed', { + configurable: true, + get: function disposed() { + return getAsyncDisposableStackInternalState(this).state === DISPOSED; + } + }); + + defineBuiltIn(AsyncDisposableStackPrototype, ASYNC_DISPOSE, AsyncDisposableStackPrototype.disposeAsync, { name: 'disposeAsync' }); + defineBuiltIn(AsyncDisposableStackPrototype, TO_STRING_TAG, ASYNC_DISPOSABLE_STACK, { nonWritable: true }); + + $({ global: true, constructor: true }, { + AsyncDisposableStack: $AsyncDisposableStack + }); + return esnext_asyncDisposableStack_constructor; +} + +var esnext_asyncIterator_constructor = {}; + +var hasRequiredEsnext_asyncIterator_constructor; + +function requireEsnext_asyncIterator_constructor () { + if (hasRequiredEsnext_asyncIterator_constructor) return esnext_asyncIterator_constructor; + hasRequiredEsnext_asyncIterator_constructor = 1; + var $ = require_export(); + var anInstance = requireAnInstance(); + var getPrototypeOf = requireObjectGetPrototypeOf(); + var createNonEnumerableProperty = requireCreateNonEnumerableProperty(); + var hasOwn = requireHasOwnProperty(); + var wellKnownSymbol = requireWellKnownSymbol(); + var AsyncIteratorPrototype = requireAsyncIteratorPrototype(); + var IS_PURE = requireIsPure(); + + var TO_STRING_TAG = wellKnownSymbol('toStringTag'); + + var $TypeError = TypeError; + + var AsyncIteratorConstructor = function AsyncIterator() { + anInstance(this, AsyncIteratorPrototype); + if (getPrototypeOf(this) === AsyncIteratorPrototype) throw new $TypeError('Abstract class AsyncIterator not directly constructable'); + }; + + AsyncIteratorConstructor.prototype = AsyncIteratorPrototype; + + if (!hasOwn(AsyncIteratorPrototype, TO_STRING_TAG)) { + createNonEnumerableProperty(AsyncIteratorPrototype, TO_STRING_TAG, 'AsyncIterator'); + } + + if (IS_PURE || !hasOwn(AsyncIteratorPrototype, 'constructor') || AsyncIteratorPrototype.constructor === Object) { + createNonEnumerableProperty(AsyncIteratorPrototype, 'constructor', AsyncIteratorConstructor); + } + + // `AsyncIterator` constructor + // https://github.com/tc39/proposal-async-iterator-helpers + $({ global: true, constructor: true, forced: IS_PURE }, { + AsyncIterator: AsyncIteratorConstructor + }); + return esnext_asyncIterator_constructor; +} + +var esnext_asyncIterator_asIndexedPairs = {}; + +var asyncIteratorCreateProxy; +var hasRequiredAsyncIteratorCreateProxy; + +function requireAsyncIteratorCreateProxy () { + if (hasRequiredAsyncIteratorCreateProxy) return asyncIteratorCreateProxy; + hasRequiredAsyncIteratorCreateProxy = 1; + var call = requireFunctionCall(); + var perform = requirePerform(); + var anObject = requireAnObject(); + var create = requireObjectCreate(); + var createNonEnumerableProperty = requireCreateNonEnumerableProperty(); + var defineBuiltIns = requireDefineBuiltIns(); + var wellKnownSymbol = requireWellKnownSymbol(); + var InternalStateModule = requireInternalState(); + var getBuiltIn = requireGetBuiltIn(); + var getMethod = requireGetMethod(); + var AsyncIteratorPrototype = requireAsyncIteratorPrototype(); + var createIterResultObject = requireCreateIterResultObject(); + var iteratorClose = requireIteratorClose(); + + var Promise = getBuiltIn('Promise'); + + var TO_STRING_TAG = wellKnownSymbol('toStringTag'); + var ASYNC_ITERATOR_HELPER = 'AsyncIteratorHelper'; + var WRAP_FOR_VALID_ASYNC_ITERATOR = 'WrapForValidAsyncIterator'; + var setInternalState = InternalStateModule.set; + + var createAsyncIteratorProxyPrototype = function (IS_ITERATOR) { + var IS_GENERATOR = !IS_ITERATOR; + var getInternalState = InternalStateModule.getterFor(IS_ITERATOR ? WRAP_FOR_VALID_ASYNC_ITERATOR : ASYNC_ITERATOR_HELPER); + + var getStateOrEarlyExit = function (that) { + var stateCompletion = perform(function () { + return getInternalState(that); + }); + + var stateError = stateCompletion.error; + var state = stateCompletion.value; + + if (stateError || (IS_GENERATOR && state.done)) { + return { exit: true, value: stateError ? Promise.reject(state) : Promise.resolve(createIterResultObject(undefined, true)) }; + } return { exit: false, value: state }; + }; + + return defineBuiltIns(create(AsyncIteratorPrototype), { + next: function next() { + var stateCompletion = getStateOrEarlyExit(this); + var state = stateCompletion.value; + if (stateCompletion.exit) return state; + var handlerCompletion = perform(function () { + return anObject(state.nextHandler(Promise)); + }); + var handlerError = handlerCompletion.error; + var value = handlerCompletion.value; + if (handlerError) state.done = true; + return handlerError ? Promise.reject(value) : Promise.resolve(value); + }, + 'return': function () { + var stateCompletion = getStateOrEarlyExit(this); + var state = stateCompletion.value; + if (stateCompletion.exit) return state; + state.done = true; + var iterator = state.iterator; + var returnMethod, result; + var completion = perform(function () { + if (state.inner) try { + iteratorClose(state.inner.iterator, 'normal'); + } catch (error) { + return iteratorClose(iterator, 'throw', error); + } + return getMethod(iterator, 'return'); + }); + returnMethod = result = completion.value; + if (completion.error) return Promise.reject(result); + if (returnMethod === undefined) return Promise.resolve(createIterResultObject(undefined, true)); + completion = perform(function () { + return call(returnMethod, iterator); + }); + result = completion.value; + if (completion.error) return Promise.reject(result); + return IS_ITERATOR ? Promise.resolve(result) : Promise.resolve(result).then(function (resolved) { + anObject(resolved); + return createIterResultObject(undefined, true); + }); + } + }); + }; + + var WrapForValidAsyncIteratorPrototype = createAsyncIteratorProxyPrototype(true); + var AsyncIteratorHelperPrototype = createAsyncIteratorProxyPrototype(false); + + createNonEnumerableProperty(AsyncIteratorHelperPrototype, TO_STRING_TAG, 'Async Iterator Helper'); + + asyncIteratorCreateProxy = function (nextHandler, IS_ITERATOR) { + var AsyncIteratorProxy = function AsyncIterator(record, state) { + if (state) { + state.iterator = record.iterator; + state.next = record.next; + } else state = record; + state.type = IS_ITERATOR ? WRAP_FOR_VALID_ASYNC_ITERATOR : ASYNC_ITERATOR_HELPER; + state.nextHandler = nextHandler; + state.counter = 0; + state.done = false; + setInternalState(this, state); + }; + + AsyncIteratorProxy.prototype = IS_ITERATOR ? WrapForValidAsyncIteratorPrototype : AsyncIteratorHelperPrototype; + + return AsyncIteratorProxy; + }; + return asyncIteratorCreateProxy; +} + +var asyncIteratorMap; +var hasRequiredAsyncIteratorMap; + +function requireAsyncIteratorMap () { + if (hasRequiredAsyncIteratorMap) return asyncIteratorMap; + hasRequiredAsyncIteratorMap = 1; + var call = requireFunctionCall(); + var aCallable = requireACallable(); + var anObject = requireAnObject(); + var isObject = requireIsObject(); + var getIteratorDirect = requireGetIteratorDirect(); + var createAsyncIteratorProxy = requireAsyncIteratorCreateProxy(); + var createIterResultObject = requireCreateIterResultObject(); + var closeAsyncIteration = requireAsyncIteratorClose(); + + var AsyncIteratorProxy = createAsyncIteratorProxy(function (Promise) { + var state = this; + var iterator = state.iterator; + var mapper = state.mapper; + + return new Promise(function (resolve, reject) { + var doneAndReject = function (error) { + state.done = true; + reject(error); + }; + + var ifAbruptCloseAsyncIterator = function (error) { + closeAsyncIteration(iterator, doneAndReject, error, doneAndReject); + }; + + Promise.resolve(anObject(call(state.next, iterator))).then(function (step) { + try { + if (anObject(step).done) { + state.done = true; + resolve(createIterResultObject(undefined, true)); + } else { + var value = step.value; + try { + var result = mapper(value, state.counter++); + + var handler = function (mapped) { + resolve(createIterResultObject(mapped, false)); + }; + + if (isObject(result)) Promise.resolve(result).then(handler, ifAbruptCloseAsyncIterator); + else handler(result); + } catch (error2) { ifAbruptCloseAsyncIterator(error2); } + } + } catch (error) { doneAndReject(error); } + }, doneAndReject); + }); + }); + + // `AsyncIterator.prototype.map` method + // https://github.com/tc39/proposal-iterator-helpers + asyncIteratorMap = function map(mapper) { + anObject(this); + aCallable(mapper); + return new AsyncIteratorProxy(getIteratorDirect(this), { + mapper: mapper + }); + }; + return asyncIteratorMap; +} + +var asyncIteratorIndexed; +var hasRequiredAsyncIteratorIndexed; + +function requireAsyncIteratorIndexed () { + if (hasRequiredAsyncIteratorIndexed) return asyncIteratorIndexed; + hasRequiredAsyncIteratorIndexed = 1; + var call = requireFunctionCall(); + var map = requireAsyncIteratorMap(); + + var callback = function (value, counter) { + return [counter, value]; + }; + + // `AsyncIterator.prototype.indexed` method + // https://github.com/tc39/proposal-iterator-helpers + asyncIteratorIndexed = function indexed() { + return call(map, this, callback); + }; + return asyncIteratorIndexed; +} + +var hasRequiredEsnext_asyncIterator_asIndexedPairs; + +function requireEsnext_asyncIterator_asIndexedPairs () { + if (hasRequiredEsnext_asyncIterator_asIndexedPairs) return esnext_asyncIterator_asIndexedPairs; + hasRequiredEsnext_asyncIterator_asIndexedPairs = 1; + // TODO: Remove from `core-js@4` + var $ = require_export(); + var indexed = requireAsyncIteratorIndexed(); + + // `AsyncIterator.prototype.asIndexedPairs` method + // https://github.com/tc39/proposal-iterator-helpers + $({ target: 'AsyncIterator', name: 'indexed', proto: true, real: true, forced: true }, { + asIndexedPairs: indexed + }); + return esnext_asyncIterator_asIndexedPairs; +} + +var esnext_asyncIterator_asyncDispose = {}; + +var hasRequiredEsnext_asyncIterator_asyncDispose; + +function requireEsnext_asyncIterator_asyncDispose () { + if (hasRequiredEsnext_asyncIterator_asyncDispose) return esnext_asyncIterator_asyncDispose; + hasRequiredEsnext_asyncIterator_asyncDispose = 1; + // https://github.com/tc39/proposal-async-explicit-resource-management + var call = requireFunctionCall(); + var defineBuiltIn = requireDefineBuiltIn(); + var getBuiltIn = requireGetBuiltIn(); + var getMethod = requireGetMethod(); + var hasOwn = requireHasOwnProperty(); + var wellKnownSymbol = requireWellKnownSymbol(); + var AsyncIteratorPrototype = requireAsyncIteratorPrototype(); + + var ASYNC_DISPOSE = wellKnownSymbol('asyncDispose'); + var Promise = getBuiltIn('Promise'); + + if (!hasOwn(AsyncIteratorPrototype, ASYNC_DISPOSE)) { + defineBuiltIn(AsyncIteratorPrototype, ASYNC_DISPOSE, function () { + var O = this; + return new Promise(function (resolve, reject) { + var $return = getMethod(O, 'return'); + if ($return) { + Promise.resolve(call($return, O)).then(function () { + resolve(undefined); + }, reject); + } else resolve(undefined); + }); + }); + } + return esnext_asyncIterator_asyncDispose; +} + +var esnext_asyncIterator_drop = {}; + +var notANan; +var hasRequiredNotANan; + +function requireNotANan () { + if (hasRequiredNotANan) return notANan; + hasRequiredNotANan = 1; + var $RangeError = RangeError; + + notANan = function (it) { + // eslint-disable-next-line no-self-compare -- NaN check + if (it === it) return it; + throw new $RangeError('NaN is not allowed'); + }; + return notANan; +} + +var hasRequiredEsnext_asyncIterator_drop; + +function requireEsnext_asyncIterator_drop () { + if (hasRequiredEsnext_asyncIterator_drop) return esnext_asyncIterator_drop; + hasRequiredEsnext_asyncIterator_drop = 1; + var $ = require_export(); + var call = requireFunctionCall(); + var anObject = requireAnObject(); + var getIteratorDirect = requireGetIteratorDirect(); + var notANaN = requireNotANan(); + var toPositiveInteger = requireToPositiveInteger(); + var createAsyncIteratorProxy = requireAsyncIteratorCreateProxy(); + var createIterResultObject = requireCreateIterResultObject(); + var IS_PURE = requireIsPure(); + + var AsyncIteratorProxy = createAsyncIteratorProxy(function (Promise) { + var state = this; + + return new Promise(function (resolve, reject) { + var doneAndReject = function (error) { + state.done = true; + reject(error); + }; + + var loop = function () { + try { + Promise.resolve(anObject(call(state.next, state.iterator))).then(function (step) { + try { + if (anObject(step).done) { + state.done = true; + resolve(createIterResultObject(undefined, true)); + } else if (state.remaining) { + state.remaining--; + loop(); + } else resolve(createIterResultObject(step.value, false)); + } catch (err) { doneAndReject(err); } + }, doneAndReject); + } catch (error) { doneAndReject(error); } + }; + + loop(); + }); + }); + + // `AsyncIterator.prototype.drop` method + // https://github.com/tc39/proposal-async-iterator-helpers + $({ target: 'AsyncIterator', proto: true, real: true, forced: IS_PURE }, { + drop: function drop(limit) { + anObject(this); + var remaining = toPositiveInteger(notANaN(+limit)); + return new AsyncIteratorProxy(getIteratorDirect(this), { + remaining: remaining + }); + } + }); + return esnext_asyncIterator_drop; +} + +var esnext_asyncIterator_every = {}; + +var hasRequiredEsnext_asyncIterator_every; + +function requireEsnext_asyncIterator_every () { + if (hasRequiredEsnext_asyncIterator_every) return esnext_asyncIterator_every; + hasRequiredEsnext_asyncIterator_every = 1; + var $ = require_export(); + var $every = requireAsyncIteratorIteration().every; + + // `AsyncIterator.prototype.every` method + // https://github.com/tc39/proposal-async-iterator-helpers + $({ target: 'AsyncIterator', proto: true, real: true }, { + every: function every(predicate) { + return $every(this, predicate); + } + }); + return esnext_asyncIterator_every; +} + +var esnext_asyncIterator_filter = {}; + +var hasRequiredEsnext_asyncIterator_filter; + +function requireEsnext_asyncIterator_filter () { + if (hasRequiredEsnext_asyncIterator_filter) return esnext_asyncIterator_filter; + hasRequiredEsnext_asyncIterator_filter = 1; + var $ = require_export(); + var call = requireFunctionCall(); + var aCallable = requireACallable(); + var anObject = requireAnObject(); + var isObject = requireIsObject(); + var getIteratorDirect = requireGetIteratorDirect(); + var createAsyncIteratorProxy = requireAsyncIteratorCreateProxy(); + var createIterResultObject = requireCreateIterResultObject(); + var closeAsyncIteration = requireAsyncIteratorClose(); + var IS_PURE = requireIsPure(); + + var AsyncIteratorProxy = createAsyncIteratorProxy(function (Promise) { + var state = this; + var iterator = state.iterator; + var predicate = state.predicate; + + return new Promise(function (resolve, reject) { + var doneAndReject = function (error) { + state.done = true; + reject(error); + }; + + var ifAbruptCloseAsyncIterator = function (error) { + closeAsyncIteration(iterator, doneAndReject, error, doneAndReject); + }; + + var loop = function () { + try { + Promise.resolve(anObject(call(state.next, iterator))).then(function (step) { + try { + if (anObject(step).done) { + state.done = true; + resolve(createIterResultObject(undefined, true)); + } else { + var value = step.value; + try { + var result = predicate(value, state.counter++); + + var handler = function (selected) { + selected ? resolve(createIterResultObject(value, false)) : loop(); + }; + + if (isObject(result)) Promise.resolve(result).then(handler, ifAbruptCloseAsyncIterator); + else handler(result); + } catch (error3) { ifAbruptCloseAsyncIterator(error3); } + } + } catch (error2) { doneAndReject(error2); } + }, doneAndReject); + } catch (error) { doneAndReject(error); } + }; + + loop(); + }); + }); + + // `AsyncIterator.prototype.filter` method + // https://github.com/tc39/proposal-async-iterator-helpers + $({ target: 'AsyncIterator', proto: true, real: true, forced: IS_PURE }, { + filter: function filter(predicate) { + anObject(this); + aCallable(predicate); + return new AsyncIteratorProxy(getIteratorDirect(this), { + predicate: predicate + }); + } + }); + return esnext_asyncIterator_filter; +} + +var esnext_asyncIterator_find = {}; + +var hasRequiredEsnext_asyncIterator_find; + +function requireEsnext_asyncIterator_find () { + if (hasRequiredEsnext_asyncIterator_find) return esnext_asyncIterator_find; + hasRequiredEsnext_asyncIterator_find = 1; + var $ = require_export(); + var $find = requireAsyncIteratorIteration().find; + + // `AsyncIterator.prototype.find` method + // https://github.com/tc39/proposal-async-iterator-helpers + $({ target: 'AsyncIterator', proto: true, real: true }, { + find: function find(predicate) { + return $find(this, predicate); + } + }); + return esnext_asyncIterator_find; +} + +var esnext_asyncIterator_flatMap = {}; + +var getAsyncIteratorFlattenable; +var hasRequiredGetAsyncIteratorFlattenable; + +function requireGetAsyncIteratorFlattenable () { + if (hasRequiredGetAsyncIteratorFlattenable) return getAsyncIteratorFlattenable; + hasRequiredGetAsyncIteratorFlattenable = 1; + var call = requireFunctionCall(); + var isCallable = requireIsCallable(); + var anObject = requireAnObject(); + var getIteratorDirect = requireGetIteratorDirect(); + var getIteratorMethod = requireGetIteratorMethod(); + var getMethod = requireGetMethod(); + var wellKnownSymbol = requireWellKnownSymbol(); + var AsyncFromSyncIterator = requireAsyncFromSyncIterator(); + + var ASYNC_ITERATOR = wellKnownSymbol('asyncIterator'); + + getAsyncIteratorFlattenable = function (obj) { + var object = anObject(obj); + var alreadyAsync = true; + var method = getMethod(object, ASYNC_ITERATOR); + var iterator; + if (!isCallable(method)) { + method = getIteratorMethod(object); + alreadyAsync = false; + } + if (method !== undefined) { + iterator = call(method, object); + } else { + iterator = object; + alreadyAsync = true; + } + anObject(iterator); + return getIteratorDirect(alreadyAsync ? iterator : new AsyncFromSyncIterator(getIteratorDirect(iterator))); + }; + return getAsyncIteratorFlattenable; +} + +var hasRequiredEsnext_asyncIterator_flatMap; + +function requireEsnext_asyncIterator_flatMap () { + if (hasRequiredEsnext_asyncIterator_flatMap) return esnext_asyncIterator_flatMap; + hasRequiredEsnext_asyncIterator_flatMap = 1; + var $ = require_export(); + var call = requireFunctionCall(); + var aCallable = requireACallable(); + var anObject = requireAnObject(); + var isObject = requireIsObject(); + var getIteratorDirect = requireGetIteratorDirect(); + var createAsyncIteratorProxy = requireAsyncIteratorCreateProxy(); + var createIterResultObject = requireCreateIterResultObject(); + var getAsyncIteratorFlattenable = requireGetAsyncIteratorFlattenable(); + var closeAsyncIteration = requireAsyncIteratorClose(); + var IS_PURE = requireIsPure(); + + var AsyncIteratorProxy = createAsyncIteratorProxy(function (Promise) { + var state = this; + var iterator = state.iterator; + var mapper = state.mapper; + + return new Promise(function (resolve, reject) { + var doneAndReject = function (error) { + state.done = true; + reject(error); + }; + + var ifAbruptCloseAsyncIterator = function (error) { + closeAsyncIteration(iterator, doneAndReject, error, doneAndReject); + }; + + var outerLoop = function () { + try { + Promise.resolve(anObject(call(state.next, iterator))).then(function (step) { + try { + if (anObject(step).done) { + state.done = true; + resolve(createIterResultObject(undefined, true)); + } else { + var value = step.value; + try { + var result = mapper(value, state.counter++); + + var handler = function (mapped) { + try { + state.inner = getAsyncIteratorFlattenable(mapped); + innerLoop(); + } catch (error4) { ifAbruptCloseAsyncIterator(error4); } + }; + + if (isObject(result)) Promise.resolve(result).then(handler, ifAbruptCloseAsyncIterator); + else handler(result); + } catch (error3) { ifAbruptCloseAsyncIterator(error3); } + } + } catch (error2) { doneAndReject(error2); } + }, doneAndReject); + } catch (error) { doneAndReject(error); } + }; + + var innerLoop = function () { + var inner = state.inner; + if (inner) { + try { + Promise.resolve(anObject(call(inner.next, inner.iterator))).then(function (result) { + try { + if (anObject(result).done) { + state.inner = null; + outerLoop(); + } else resolve(createIterResultObject(result.value, false)); + } catch (error1) { ifAbruptCloseAsyncIterator(error1); } + }, ifAbruptCloseAsyncIterator); + } catch (error) { ifAbruptCloseAsyncIterator(error); } + } else outerLoop(); + }; + + innerLoop(); + }); + }); + + // `AsyncIterator.prototype.flaMap` method + // https://github.com/tc39/proposal-async-iterator-helpers + $({ target: 'AsyncIterator', proto: true, real: true, forced: IS_PURE }, { + flatMap: function flatMap(mapper) { + anObject(this); + aCallable(mapper); + return new AsyncIteratorProxy(getIteratorDirect(this), { + mapper: mapper, + inner: null + }); + } + }); + return esnext_asyncIterator_flatMap; +} + +var esnext_asyncIterator_forEach = {}; + +var hasRequiredEsnext_asyncIterator_forEach; + +function requireEsnext_asyncIterator_forEach () { + if (hasRequiredEsnext_asyncIterator_forEach) return esnext_asyncIterator_forEach; + hasRequiredEsnext_asyncIterator_forEach = 1; + var $ = require_export(); + var $forEach = requireAsyncIteratorIteration().forEach; + + // `AsyncIterator.prototype.forEach` method + // https://github.com/tc39/proposal-async-iterator-helpers + $({ target: 'AsyncIterator', proto: true, real: true }, { + forEach: function forEach(fn) { + return $forEach(this, fn); + } + }); + return esnext_asyncIterator_forEach; +} + +var esnext_asyncIterator_from = {}; + +var asyncIteratorWrap; +var hasRequiredAsyncIteratorWrap; + +function requireAsyncIteratorWrap () { + if (hasRequiredAsyncIteratorWrap) return asyncIteratorWrap; + hasRequiredAsyncIteratorWrap = 1; + var call = requireFunctionCall(); + var createAsyncIteratorProxy = requireAsyncIteratorCreateProxy(); + + asyncIteratorWrap = createAsyncIteratorProxy(function () { + return call(this.next, this.iterator); + }, true); + return asyncIteratorWrap; +} + +var hasRequiredEsnext_asyncIterator_from; + +function requireEsnext_asyncIterator_from () { + if (hasRequiredEsnext_asyncIterator_from) return esnext_asyncIterator_from; + hasRequiredEsnext_asyncIterator_from = 1; + var $ = require_export(); + var toObject = requireToObject(); + var isPrototypeOf = requireObjectIsPrototypeOf(); + var getAsyncIteratorFlattenable = requireGetAsyncIteratorFlattenable(); + var AsyncIteratorPrototype = requireAsyncIteratorPrototype(); + var WrapAsyncIterator = requireAsyncIteratorWrap(); + var IS_PURE = requireIsPure(); + + // `AsyncIterator.from` method + // https://github.com/tc39/proposal-async-iterator-helpers + $({ target: 'AsyncIterator', stat: true, forced: IS_PURE }, { + from: function from(O) { + var iteratorRecord = getAsyncIteratorFlattenable(typeof O == 'string' ? toObject(O) : O); + return isPrototypeOf(AsyncIteratorPrototype, iteratorRecord.iterator) + ? iteratorRecord.iterator + : new WrapAsyncIterator(iteratorRecord); + } + }); + return esnext_asyncIterator_from; +} + +var esnext_asyncIterator_indexed = {}; + +var hasRequiredEsnext_asyncIterator_indexed; + +function requireEsnext_asyncIterator_indexed () { + if (hasRequiredEsnext_asyncIterator_indexed) return esnext_asyncIterator_indexed; + hasRequiredEsnext_asyncIterator_indexed = 1; + // TODO: Remove from `core-js@4` + var $ = require_export(); + var indexed = requireAsyncIteratorIndexed(); + + // `AsyncIterator.prototype.indexed` method + // https://github.com/tc39/proposal-iterator-helpers + $({ target: 'AsyncIterator', proto: true, real: true, forced: true }, { + indexed: indexed + }); + return esnext_asyncIterator_indexed; +} + +var esnext_asyncIterator_map = {}; + +var hasRequiredEsnext_asyncIterator_map; + +function requireEsnext_asyncIterator_map () { + if (hasRequiredEsnext_asyncIterator_map) return esnext_asyncIterator_map; + hasRequiredEsnext_asyncIterator_map = 1; + var $ = require_export(); + var map = requireAsyncIteratorMap(); + var IS_PURE = requireIsPure(); + + // `AsyncIterator.prototype.map` method + // https://github.com/tc39/proposal-async-iterator-helpers + $({ target: 'AsyncIterator', proto: true, real: true, forced: IS_PURE }, { + map: map + }); + return esnext_asyncIterator_map; +} + +var esnext_asyncIterator_reduce = {}; + +var hasRequiredEsnext_asyncIterator_reduce; + +function requireEsnext_asyncIterator_reduce () { + if (hasRequiredEsnext_asyncIterator_reduce) return esnext_asyncIterator_reduce; + hasRequiredEsnext_asyncIterator_reduce = 1; + var $ = require_export(); + var call = requireFunctionCall(); + var aCallable = requireACallable(); + var anObject = requireAnObject(); + var isObject = requireIsObject(); + var getBuiltIn = requireGetBuiltIn(); + var getIteratorDirect = requireGetIteratorDirect(); + var closeAsyncIteration = requireAsyncIteratorClose(); + + var Promise = getBuiltIn('Promise'); + var $TypeError = TypeError; + + // `AsyncIterator.prototype.reduce` method + // https://github.com/tc39/proposal-async-iterator-helpers + $({ target: 'AsyncIterator', proto: true, real: true }, { + reduce: function reduce(reducer /* , initialValue */) { + anObject(this); + aCallable(reducer); + var record = getIteratorDirect(this); + var iterator = record.iterator; + var next = record.next; + var noInitial = arguments.length < 2; + var accumulator = noInitial ? undefined : arguments[1]; + var counter = 0; + + return new Promise(function (resolve, reject) { + var ifAbruptCloseAsyncIterator = function (error) { + closeAsyncIteration(iterator, reject, error, reject); + }; + + var loop = function () { + try { + Promise.resolve(anObject(call(next, iterator))).then(function (step) { + try { + if (anObject(step).done) { + noInitial ? reject(new $TypeError('Reduce of empty iterator with no initial value')) : resolve(accumulator); + } else { + var value = step.value; + if (noInitial) { + noInitial = false; + accumulator = value; + loop(); + } else try { + var result = reducer(accumulator, value, counter); + + var handler = function ($result) { + accumulator = $result; + loop(); + }; + + if (isObject(result)) Promise.resolve(result).then(handler, ifAbruptCloseAsyncIterator); + else handler(result); + } catch (error3) { ifAbruptCloseAsyncIterator(error3); } + } + counter++; + } catch (error2) { reject(error2); } + }, reject); + } catch (error) { reject(error); } + }; + + loop(); + }); + } + }); + return esnext_asyncIterator_reduce; +} + +var esnext_asyncIterator_some = {}; + +var hasRequiredEsnext_asyncIterator_some; + +function requireEsnext_asyncIterator_some () { + if (hasRequiredEsnext_asyncIterator_some) return esnext_asyncIterator_some; + hasRequiredEsnext_asyncIterator_some = 1; + var $ = require_export(); + var $some = requireAsyncIteratorIteration().some; + + // `AsyncIterator.prototype.some` method + // https://github.com/tc39/proposal-async-iterator-helpers + $({ target: 'AsyncIterator', proto: true, real: true }, { + some: function some(predicate) { + return $some(this, predicate); + } + }); + return esnext_asyncIterator_some; +} + +var esnext_asyncIterator_take = {}; + +var hasRequiredEsnext_asyncIterator_take; + +function requireEsnext_asyncIterator_take () { + if (hasRequiredEsnext_asyncIterator_take) return esnext_asyncIterator_take; + hasRequiredEsnext_asyncIterator_take = 1; + var $ = require_export(); + var call = requireFunctionCall(); + var anObject = requireAnObject(); + var getIteratorDirect = requireGetIteratorDirect(); + var notANaN = requireNotANan(); + var toPositiveInteger = requireToPositiveInteger(); + var createAsyncIteratorProxy = requireAsyncIteratorCreateProxy(); + var createIterResultObject = requireCreateIterResultObject(); + var IS_PURE = requireIsPure(); + + var AsyncIteratorProxy = createAsyncIteratorProxy(function (Promise) { + var state = this; + var iterator = state.iterator; + var returnMethod; + + if (!state.remaining--) { + var resultDone = createIterResultObject(undefined, true); + state.done = true; + returnMethod = iterator['return']; + if (returnMethod !== undefined) { + return Promise.resolve(call(returnMethod, iterator, undefined)).then(function () { + return resultDone; + }); + } + return resultDone; + } return Promise.resolve(call(state.next, iterator)).then(function (step) { + if (anObject(step).done) { + state.done = true; + return createIterResultObject(undefined, true); + } return createIterResultObject(step.value, false); + }).then(null, function (error) { + state.done = true; + throw error; + }); + }); + + // `AsyncIterator.prototype.take` method + // https://github.com/tc39/proposal-async-iterator-helpers + $({ target: 'AsyncIterator', proto: true, real: true, forced: IS_PURE }, { + take: function take(limit) { + anObject(this); + var remaining = toPositiveInteger(notANaN(+limit)); + return new AsyncIteratorProxy(getIteratorDirect(this), { + remaining: remaining + }); + } + }); + return esnext_asyncIterator_take; +} + +var esnext_asyncIterator_toArray = {}; + +var hasRequiredEsnext_asyncIterator_toArray; + +function requireEsnext_asyncIterator_toArray () { + if (hasRequiredEsnext_asyncIterator_toArray) return esnext_asyncIterator_toArray; + hasRequiredEsnext_asyncIterator_toArray = 1; + var $ = require_export(); + var $toArray = requireAsyncIteratorIteration().toArray; + + // `AsyncIterator.prototype.toArray` method + // https://github.com/tc39/proposal-async-iterator-helpers + $({ target: 'AsyncIterator', proto: true, real: true }, { + toArray: function toArray() { + return $toArray(this, undefined, []); + } + }); + return esnext_asyncIterator_toArray; +} + +var esnext_bigint_range = {}; + +var numericRangeIterator; +var hasRequiredNumericRangeIterator; + +function requireNumericRangeIterator () { + if (hasRequiredNumericRangeIterator) return numericRangeIterator; + hasRequiredNumericRangeIterator = 1; + var InternalStateModule = requireInternalState(); + var createIteratorConstructor = requireIteratorCreateConstructor(); + var createIterResultObject = requireCreateIterResultObject(); + var isNullOrUndefined = requireIsNullOrUndefined(); + var isObject = requireIsObject(); + var defineBuiltInAccessor = requireDefineBuiltInAccessor(); + var DESCRIPTORS = requireDescriptors(); + + var INCORRECT_RANGE = 'Incorrect Iterator.range arguments'; + var NUMERIC_RANGE_ITERATOR = 'NumericRangeIterator'; + + var setInternalState = InternalStateModule.set; + var getInternalState = InternalStateModule.getterFor(NUMERIC_RANGE_ITERATOR); + + var $RangeError = RangeError; + var $TypeError = TypeError; + + var $RangeIterator = createIteratorConstructor(function NumericRangeIterator(start, end, option, type, zero, one) { + // TODO: Drop the first `typeof` check after removing legacy methods in `core-js@4` + if (typeof start != type || (end !== Infinity && end !== -Infinity && typeof end != type)) { + throw new $TypeError(INCORRECT_RANGE); + } + if (start === Infinity || start === -Infinity) { + throw new $RangeError(INCORRECT_RANGE); + } + var ifIncrease = end > start; + var inclusiveEnd = false; + var step; + if (option === undefined) { + step = undefined; + } else if (isObject(option)) { + step = option.step; + inclusiveEnd = !!option.inclusive; + } else if (typeof option == type) { + step = option; + } else { + throw new $TypeError(INCORRECT_RANGE); + } + if (isNullOrUndefined(step)) { + step = ifIncrease ? one : -one; + } + if (typeof step != type) { + throw new $TypeError(INCORRECT_RANGE); + } + if (step === Infinity || step === -Infinity || (step === zero && start !== end)) { + throw new $RangeError(INCORRECT_RANGE); + } + // eslint-disable-next-line no-self-compare -- NaN check + var hitsEnd = start !== start || end !== end || step !== step || (end > start) !== (step > zero); + setInternalState(this, { + type: NUMERIC_RANGE_ITERATOR, + start: start, + end: end, + step: step, + inclusive: inclusiveEnd, + hitsEnd: hitsEnd, + currentCount: zero, + zero: zero + }); + if (!DESCRIPTORS) { + this.start = start; + this.end = end; + this.step = step; + this.inclusive = inclusiveEnd; + } + }, NUMERIC_RANGE_ITERATOR, function next() { + var state = getInternalState(this); + if (state.hitsEnd) return createIterResultObject(undefined, true); + var start = state.start; + var end = state.end; + var step = state.step; + var currentYieldingValue = start + (step * state.currentCount++); + if (currentYieldingValue === end) state.hitsEnd = true; + var inclusiveEnd = state.inclusive; + var endCondition; + if (end > start) { + endCondition = inclusiveEnd ? currentYieldingValue > end : currentYieldingValue >= end; + } else { + endCondition = inclusiveEnd ? end > currentYieldingValue : end >= currentYieldingValue; + } + if (endCondition) { + state.hitsEnd = true; + return createIterResultObject(undefined, true); + } return createIterResultObject(currentYieldingValue, false); + }); + + var addGetter = function (key) { + defineBuiltInAccessor($RangeIterator.prototype, key, { + get: function () { + return getInternalState(this)[key]; + }, + set: function () { /* empty */ }, + configurable: true, + enumerable: false + }); + }; + + if (DESCRIPTORS) { + addGetter('start'); + addGetter('end'); + addGetter('inclusive'); + addGetter('step'); + } + + numericRangeIterator = $RangeIterator; + return numericRangeIterator; +} + +var hasRequiredEsnext_bigint_range; + +function requireEsnext_bigint_range () { + if (hasRequiredEsnext_bigint_range) return esnext_bigint_range; + hasRequiredEsnext_bigint_range = 1; + /* eslint-disable es/no-bigint -- safe */ + var $ = require_export(); + var NumericRangeIterator = requireNumericRangeIterator(); + + // `BigInt.range` method + // https://github.com/tc39/proposal-Number.range + // TODO: Remove from `core-js@4` + if (typeof BigInt == 'function') { + $({ target: 'BigInt', stat: true, forced: true }, { + range: function range(start, end, option) { + return new NumericRangeIterator(start, end, option, 'bigint', BigInt(0), BigInt(1)); + } + }); + } + return esnext_bigint_range; +} + +var esnext_compositeKey = {}; + +var compositeKey; +var hasRequiredCompositeKey; + +function requireCompositeKey () { + if (hasRequiredCompositeKey) return compositeKey; + hasRequiredCompositeKey = 1; + // TODO: in core-js@4, move /modules/ dependencies to public entries for better optimization by tools like `preset-env` + requireEs_map(); + requireEs_weakMap(); + var getBuiltIn = requireGetBuiltIn(); + var create = requireObjectCreate(); + var isObject = requireIsObject(); + + var $Object = Object; + var $TypeError = TypeError; + var Map = getBuiltIn('Map'); + var WeakMap = getBuiltIn('WeakMap'); + + var Node = function () { + // keys + this.object = null; + this.symbol = null; + // child nodes + this.primitives = null; + this.objectsByIndex = create(null); + }; + + Node.prototype.get = function (key, initializer) { + return this[key] || (this[key] = initializer()); + }; + + Node.prototype.next = function (i, it, IS_OBJECT) { + var store = IS_OBJECT + ? this.objectsByIndex[i] || (this.objectsByIndex[i] = new WeakMap()) + : this.primitives || (this.primitives = new Map()); + var entry = store.get(it); + if (!entry) store.set(it, entry = new Node()); + return entry; + }; + + var root = new Node(); + + compositeKey = function () { + var active = root; + var length = arguments.length; + var i, it; + // for prevent leaking, start from objects + for (i = 0; i < length; i++) { + if (isObject(it = arguments[i])) active = active.next(i, it, true); + } + if (this === $Object && active === root) throw new $TypeError('Composite keys must contain a non-primitive component'); + for (i = 0; i < length; i++) { + if (!isObject(it = arguments[i])) active = active.next(i, it, false); + } return active; + }; + return compositeKey; +} + +var hasRequiredEsnext_compositeKey; + +function requireEsnext_compositeKey () { + if (hasRequiredEsnext_compositeKey) return esnext_compositeKey; + hasRequiredEsnext_compositeKey = 1; + var $ = require_export(); + var apply = requireFunctionApply(); + var getCompositeKeyNode = requireCompositeKey(); + var getBuiltIn = requireGetBuiltIn(); + var create = requireObjectCreate(); + + var $Object = Object; + + var initializer = function () { + var freeze = getBuiltIn('Object', 'freeze'); + return freeze ? freeze(create(null)) : create(null); + }; + + // https://github.com/tc39/proposal-richer-keys/tree/master/compositeKey + $({ global: true, forced: true }, { + compositeKey: function compositeKey() { + return apply(getCompositeKeyNode, $Object, arguments).get('object', initializer); + } + }); + return esnext_compositeKey; +} + +var esnext_compositeSymbol = {}; + +var hasRequiredEsnext_compositeSymbol; + +function requireEsnext_compositeSymbol () { + if (hasRequiredEsnext_compositeSymbol) return esnext_compositeSymbol; + hasRequiredEsnext_compositeSymbol = 1; + var $ = require_export(); + var getCompositeKeyNode = requireCompositeKey(); + var getBuiltIn = requireGetBuiltIn(); + var apply = requireFunctionApply(); + + // https://github.com/tc39/proposal-richer-keys/tree/master/compositeKey + $({ global: true, forced: true }, { + compositeSymbol: function compositeSymbol() { + if (arguments.length === 1 && typeof arguments[0] == 'string') return getBuiltIn('Symbol')['for'](arguments[0]); + return apply(getCompositeKeyNode, null, arguments).get('symbol', getBuiltIn('Symbol')); + } + }); + return esnext_compositeSymbol; +} + +var esnext_dataView_getFloat16 = {}; + +var hasRequiredEsnext_dataView_getFloat16; + +function requireEsnext_dataView_getFloat16 () { + if (hasRequiredEsnext_dataView_getFloat16) return esnext_dataView_getFloat16; + hasRequiredEsnext_dataView_getFloat16 = 1; + var $ = require_export(); + var uncurryThis = requireFunctionUncurryThis(); + var unpackIEEE754 = requireIeee754().unpack; + + // eslint-disable-next-line es/no-typed-arrays -- safe + var getUint16 = uncurryThis(DataView.prototype.getUint16); + + // `DataView.prototype.getFloat16` method + // https://github.com/tc39/proposal-float16array + $({ target: 'DataView', proto: true }, { + getFloat16: function getFloat16(byteOffset /* , littleEndian */) { + var uint16 = getUint16(this, byteOffset, arguments.length > 1 ? arguments[1] : false); + return unpackIEEE754([uint16 & 0xFF, uint16 >> 8 & 0xFF], 10); + } + }); + return esnext_dataView_getFloat16; +} + +var esnext_dataView_getUint8Clamped = {}; + +var hasRequiredEsnext_dataView_getUint8Clamped; + +function requireEsnext_dataView_getUint8Clamped () { + if (hasRequiredEsnext_dataView_getUint8Clamped) return esnext_dataView_getUint8Clamped; + hasRequiredEsnext_dataView_getUint8Clamped = 1; + var $ = require_export(); + var uncurryThis = requireFunctionUncurryThis(); + + // eslint-disable-next-line es/no-typed-arrays -- safe + var getUint8 = uncurryThis(DataView.prototype.getUint8); + + // `DataView.prototype.getUint8Clamped` method + // https://github.com/tc39/proposal-dataview-get-set-uint8clamped + $({ target: 'DataView', proto: true, forced: true }, { + getUint8Clamped: function getUint8Clamped(byteOffset) { + return getUint8(this, byteOffset); + } + }); + return esnext_dataView_getUint8Clamped; +} + +var esnext_dataView_setFloat16 = {}; + +var aDataView; +var hasRequiredADataView; + +function requireADataView () { + if (hasRequiredADataView) return aDataView; + hasRequiredADataView = 1; + var classof = requireClassof(); + + var $TypeError = TypeError; + + aDataView = function (argument) { + if (classof(argument) === 'DataView') return argument; + throw new $TypeError('Argument is not a DataView'); + }; + return aDataView; +} + +var mathF16round; +var hasRequiredMathF16round; + +function requireMathF16round () { + if (hasRequiredMathF16round) return mathF16round; + hasRequiredMathF16round = 1; + var floatRound = requireMathFloatRound(); + + var FLOAT16_EPSILON = 0.0009765625; + var FLOAT16_MAX_VALUE = 65504; + var FLOAT16_MIN_VALUE = 6.103515625e-05; + + // `Math.f16round` method implementation + // https://github.com/tc39/proposal-float16array + mathF16round = Math.f16round || function f16round(x) { + return floatRound(x, FLOAT16_EPSILON, FLOAT16_MAX_VALUE, FLOAT16_MIN_VALUE); + }; + return mathF16round; +} + +var hasRequiredEsnext_dataView_setFloat16; + +function requireEsnext_dataView_setFloat16 () { + if (hasRequiredEsnext_dataView_setFloat16) return esnext_dataView_setFloat16; + hasRequiredEsnext_dataView_setFloat16 = 1; + var $ = require_export(); + var uncurryThis = requireFunctionUncurryThis(); + var aDataView = requireADataView(); + var toIndex = requireToIndex(); + var packIEEE754 = requireIeee754().pack; + var f16round = requireMathF16round(); + + // eslint-disable-next-line es/no-typed-arrays -- safe + var setUint16 = uncurryThis(DataView.prototype.setUint16); + + // `DataView.prototype.setFloat16` method + // https://github.com/tc39/proposal-float16array + $({ target: 'DataView', proto: true }, { + setFloat16: function setFloat16(byteOffset, value /* , littleEndian */) { + aDataView(this); + var offset = toIndex(byteOffset); + var bytes = packIEEE754(f16round(value), 10, 2); + return setUint16(this, offset, bytes[1] << 8 | bytes[0], arguments.length > 2 ? arguments[2] : false); + } + }); + return esnext_dataView_setFloat16; +} + +var esnext_dataView_setUint8Clamped = {}; + +var hasRequiredEsnext_dataView_setUint8Clamped; + +function requireEsnext_dataView_setUint8Clamped () { + if (hasRequiredEsnext_dataView_setUint8Clamped) return esnext_dataView_setUint8Clamped; + hasRequiredEsnext_dataView_setUint8Clamped = 1; + var $ = require_export(); + var uncurryThis = requireFunctionUncurryThis(); + var aDataView = requireADataView(); + var toIndex = requireToIndex(); + var toUint8Clamped = requireToUint8Clamped(); + + // eslint-disable-next-line es/no-typed-arrays -- safe + var setUint8 = uncurryThis(DataView.prototype.setUint8); + + // `DataView.prototype.setUint8Clamped` method + // https://github.com/tc39/proposal-dataview-get-set-uint8clamped + $({ target: 'DataView', proto: true, forced: true }, { + setUint8Clamped: function setUint8Clamped(byteOffset, value) { + aDataView(this); + var offset = toIndex(byteOffset); + return setUint8(this, offset, toUint8Clamped(value)); + } + }); + return esnext_dataView_setUint8Clamped; +} + +var esnext_disposableStack_constructor = {}; + +var hasRequiredEsnext_disposableStack_constructor; + +function requireEsnext_disposableStack_constructor () { + if (hasRequiredEsnext_disposableStack_constructor) return esnext_disposableStack_constructor; + hasRequiredEsnext_disposableStack_constructor = 1; + // https://github.com/tc39/proposal-explicit-resource-management + var $ = require_export(); + var DESCRIPTORS = requireDescriptors(); + var getBuiltIn = requireGetBuiltIn(); + var aCallable = requireACallable(); + var anInstance = requireAnInstance(); + var defineBuiltIn = requireDefineBuiltIn(); + var defineBuiltIns = requireDefineBuiltIns(); + var defineBuiltInAccessor = requireDefineBuiltInAccessor(); + var wellKnownSymbol = requireWellKnownSymbol(); + var InternalStateModule = requireInternalState(); + var addDisposableResource = requireAddDisposableResource(); + + var SuppressedError = getBuiltIn('SuppressedError'); + var $ReferenceError = ReferenceError; + + var DISPOSE = wellKnownSymbol('dispose'); + var TO_STRING_TAG = wellKnownSymbol('toStringTag'); + + var DISPOSABLE_STACK = 'DisposableStack'; + var setInternalState = InternalStateModule.set; + var getDisposableStackInternalState = InternalStateModule.getterFor(DISPOSABLE_STACK); + + var HINT = 'sync-dispose'; + var DISPOSED = 'disposed'; + var PENDING = 'pending'; + + var getPendingDisposableStackInternalState = function (stack) { + var internalState = getDisposableStackInternalState(stack); + if (internalState.state === DISPOSED) throw new $ReferenceError(DISPOSABLE_STACK + ' already disposed'); + return internalState; + }; + + var $DisposableStack = function DisposableStack() { + setInternalState(anInstance(this, DisposableStackPrototype), { + type: DISPOSABLE_STACK, + state: PENDING, + stack: [] + }); + + if (!DESCRIPTORS) this.disposed = false; + }; + + var DisposableStackPrototype = $DisposableStack.prototype; + + defineBuiltIns(DisposableStackPrototype, { + dispose: function dispose() { + var internalState = getDisposableStackInternalState(this); + if (internalState.state === DISPOSED) return; + internalState.state = DISPOSED; + if (!DESCRIPTORS) this.disposed = true; + var stack = internalState.stack; + var i = stack.length; + var thrown = false; + var suppressed; + while (i) { + var disposeMethod = stack[--i]; + stack[i] = null; + try { + disposeMethod(); + } catch (errorResult) { + if (thrown) { + suppressed = new SuppressedError(errorResult, suppressed); + } else { + thrown = true; + suppressed = errorResult; + } + } + } + internalState.stack = null; + if (thrown) throw suppressed; + }, + use: function use(value) { + addDisposableResource(getPendingDisposableStackInternalState(this), value, HINT); + return value; + }, + adopt: function adopt(value, onDispose) { + var internalState = getPendingDisposableStackInternalState(this); + aCallable(onDispose); + addDisposableResource(internalState, undefined, HINT, function () { + onDispose(value); + }); + return value; + }, + defer: function defer(onDispose) { + var internalState = getPendingDisposableStackInternalState(this); + aCallable(onDispose); + addDisposableResource(internalState, undefined, HINT, onDispose); + }, + move: function move() { + var internalState = getPendingDisposableStackInternalState(this); + var newDisposableStack = new $DisposableStack(); + getDisposableStackInternalState(newDisposableStack).stack = internalState.stack; + internalState.stack = []; + internalState.state = DISPOSED; + if (!DESCRIPTORS) this.disposed = true; + return newDisposableStack; + } + }); + + if (DESCRIPTORS) defineBuiltInAccessor(DisposableStackPrototype, 'disposed', { + configurable: true, + get: function disposed() { + return getDisposableStackInternalState(this).state === DISPOSED; + } + }); + + defineBuiltIn(DisposableStackPrototype, DISPOSE, DisposableStackPrototype.dispose, { name: 'dispose' }); + defineBuiltIn(DisposableStackPrototype, TO_STRING_TAG, DISPOSABLE_STACK, { nonWritable: true }); + + $({ global: true, constructor: true }, { + DisposableStack: $DisposableStack + }); + return esnext_disposableStack_constructor; +} + +var esnext_function_demethodize = {}; + +var functionDemethodize; +var hasRequiredFunctionDemethodize; + +function requireFunctionDemethodize () { + if (hasRequiredFunctionDemethodize) return functionDemethodize; + hasRequiredFunctionDemethodize = 1; + var uncurryThis = requireFunctionUncurryThis(); + var aCallable = requireACallable(); + + functionDemethodize = function demethodize() { + return uncurryThis(aCallable(this)); + }; + return functionDemethodize; +} + +var hasRequiredEsnext_function_demethodize; + +function requireEsnext_function_demethodize () { + if (hasRequiredEsnext_function_demethodize) return esnext_function_demethodize; + hasRequiredEsnext_function_demethodize = 1; + var $ = require_export(); + var demethodize = requireFunctionDemethodize(); + + // `Function.prototype.demethodize` method + // https://github.com/js-choi/proposal-function-demethodize + $({ target: 'Function', proto: true, forced: true }, { + demethodize: demethodize + }); + return esnext_function_demethodize; +} + +var esnext_function_isCallable = {}; + +var hasRequiredEsnext_function_isCallable; + +function requireEsnext_function_isCallable () { + if (hasRequiredEsnext_function_isCallable) return esnext_function_isCallable; + hasRequiredEsnext_function_isCallable = 1; + var $ = require_export(); + var uncurryThis = requireFunctionUncurryThis(); + var $isCallable = requireIsCallable(); + var inspectSource = requireInspectSource(); + var hasOwn = requireHasOwnProperty(); + var DESCRIPTORS = requireDescriptors(); + + // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe + var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; + var classRegExp = /^\s*class\b/; + var exec = uncurryThis(classRegExp.exec); + + var isClassConstructor = function (argument) { + try { + // `Function#toString` throws on some built-it function in some legacy engines + // (for example, `DOMQuad` and similar in FF41-) + if (!DESCRIPTORS || !exec(classRegExp, inspectSource(argument))) return false; + } catch (error) { /* empty */ } + var prototype = getOwnPropertyDescriptor(argument, 'prototype'); + return !!prototype && hasOwn(prototype, 'writable') && !prototype.writable; + }; + + // `Function.isCallable` method + // https://github.com/caitp/TC39-Proposals/blob/trunk/tc39-reflect-isconstructor-iscallable.md + $({ target: 'Function', stat: true, sham: true, forced: true }, { + isCallable: function isCallable(argument) { + return $isCallable(argument) && !isClassConstructor(argument); + } + }); + return esnext_function_isCallable; +} + +var esnext_function_isConstructor = {}; + +var hasRequiredEsnext_function_isConstructor; + +function requireEsnext_function_isConstructor () { + if (hasRequiredEsnext_function_isConstructor) return esnext_function_isConstructor; + hasRequiredEsnext_function_isConstructor = 1; + var $ = require_export(); + var isConstructor = requireIsConstructor(); + + // `Function.isConstructor` method + // https://github.com/caitp/TC39-Proposals/blob/trunk/tc39-reflect-isconstructor-iscallable.md + $({ target: 'Function', stat: true, forced: true }, { + isConstructor: isConstructor + }); + return esnext_function_isConstructor; +} + +var esnext_function_metadata = {}; + +var hasRequiredEsnext_function_metadata; + +function requireEsnext_function_metadata () { + if (hasRequiredEsnext_function_metadata) return esnext_function_metadata; + hasRequiredEsnext_function_metadata = 1; + var wellKnownSymbol = requireWellKnownSymbol(); + var defineProperty = requireObjectDefineProperty().f; + + var METADATA = wellKnownSymbol('metadata'); + var FunctionPrototype = Function.prototype; + + // Function.prototype[@@metadata] + // https://github.com/tc39/proposal-decorator-metadata + if (FunctionPrototype[METADATA] === undefined) { + defineProperty(FunctionPrototype, METADATA, { + value: null + }); + } + return esnext_function_metadata; +} + +var esnext_function_unThis = {}; + +var hasRequiredEsnext_function_unThis; + +function requireEsnext_function_unThis () { + if (hasRequiredEsnext_function_unThis) return esnext_function_unThis; + hasRequiredEsnext_function_unThis = 1; + var $ = require_export(); + var demethodize = requireFunctionDemethodize(); + + // `Function.prototype.unThis` method + // https://github.com/js-choi/proposal-function-demethodize + // TODO: Remove from `core-js@4` + $({ target: 'Function', proto: true, forced: true, name: 'demethodize' }, { + unThis: demethodize + }); + return esnext_function_unThis; +} + +var esnext_globalThis = {}; + +var hasRequiredEsnext_globalThis; + +function requireEsnext_globalThis () { + if (hasRequiredEsnext_globalThis) return esnext_globalThis; + hasRequiredEsnext_globalThis = 1; + // TODO: Remove from `core-js@4` + requireEs_globalThis(); + return esnext_globalThis; +} + +var esnext_iterator_constructor = {}; + +var hasRequiredEsnext_iterator_constructor; + +function requireEsnext_iterator_constructor () { + if (hasRequiredEsnext_iterator_constructor) return esnext_iterator_constructor; + hasRequiredEsnext_iterator_constructor = 1; + var $ = require_export(); + var globalThis = requireGlobalThis(); + var anInstance = requireAnInstance(); + var anObject = requireAnObject(); + var isCallable = requireIsCallable(); + var getPrototypeOf = requireObjectGetPrototypeOf(); + var defineBuiltInAccessor = requireDefineBuiltInAccessor(); + var createProperty = requireCreateProperty(); + var fails = requireFails(); + var hasOwn = requireHasOwnProperty(); + var wellKnownSymbol = requireWellKnownSymbol(); + var IteratorPrototype = requireIteratorsCore().IteratorPrototype; + var DESCRIPTORS = requireDescriptors(); + var IS_PURE = requireIsPure(); + + var CONSTRUCTOR = 'constructor'; + var ITERATOR = 'Iterator'; + var TO_STRING_TAG = wellKnownSymbol('toStringTag'); + + var $TypeError = TypeError; + var NativeIterator = globalThis[ITERATOR]; + + // FF56- have non-standard global helper `Iterator` + var FORCED = IS_PURE + || !isCallable(NativeIterator) + || NativeIterator.prototype !== IteratorPrototype + // FF44- non-standard `Iterator` passes previous tests + || !fails(function () { NativeIterator({}); }); + + var IteratorConstructor = function Iterator() { + anInstance(this, IteratorPrototype); + if (getPrototypeOf(this) === IteratorPrototype) throw new $TypeError('Abstract class Iterator not directly constructable'); + }; + + var defineIteratorPrototypeAccessor = function (key, value) { + if (DESCRIPTORS) { + defineBuiltInAccessor(IteratorPrototype, key, { + configurable: true, + get: function () { + return value; + }, + set: function (replacement) { + anObject(this); + if (this === IteratorPrototype) throw new $TypeError("You can't redefine this property"); + if (hasOwn(this, key)) this[key] = replacement; + else createProperty(this, key, replacement); + } + }); + } else IteratorPrototype[key] = value; + }; + + if (!hasOwn(IteratorPrototype, TO_STRING_TAG)) defineIteratorPrototypeAccessor(TO_STRING_TAG, ITERATOR); + + if (FORCED || !hasOwn(IteratorPrototype, CONSTRUCTOR) || IteratorPrototype[CONSTRUCTOR] === Object) { + defineIteratorPrototypeAccessor(CONSTRUCTOR, IteratorConstructor); + } + + IteratorConstructor.prototype = IteratorPrototype; + + // `Iterator` constructor + // https://github.com/tc39/proposal-iterator-helpers + $({ global: true, constructor: true, forced: FORCED }, { + Iterator: IteratorConstructor + }); + return esnext_iterator_constructor; +} + +var esnext_iterator_asIndexedPairs = {}; + +var iteratorCreateProxy; +var hasRequiredIteratorCreateProxy; + +function requireIteratorCreateProxy () { + if (hasRequiredIteratorCreateProxy) return iteratorCreateProxy; + hasRequiredIteratorCreateProxy = 1; + var call = requireFunctionCall(); + var create = requireObjectCreate(); + var createNonEnumerableProperty = requireCreateNonEnumerableProperty(); + var defineBuiltIns = requireDefineBuiltIns(); + var wellKnownSymbol = requireWellKnownSymbol(); + var InternalStateModule = requireInternalState(); + var getMethod = requireGetMethod(); + var IteratorPrototype = requireIteratorsCore().IteratorPrototype; + var createIterResultObject = requireCreateIterResultObject(); + var iteratorClose = requireIteratorClose(); + + var TO_STRING_TAG = wellKnownSymbol('toStringTag'); + var ITERATOR_HELPER = 'IteratorHelper'; + var WRAP_FOR_VALID_ITERATOR = 'WrapForValidIterator'; + var setInternalState = InternalStateModule.set; + + var createIteratorProxyPrototype = function (IS_ITERATOR) { + var getInternalState = InternalStateModule.getterFor(IS_ITERATOR ? WRAP_FOR_VALID_ITERATOR : ITERATOR_HELPER); + + return defineBuiltIns(create(IteratorPrototype), { + next: function next() { + var state = getInternalState(this); + // for simplification: + // for `%WrapForValidIteratorPrototype%.next` our `nextHandler` returns `IterResultObject` + // for `%IteratorHelperPrototype%.next` - just a value + if (IS_ITERATOR) return state.nextHandler(); + try { + var result = state.done ? undefined : state.nextHandler(); + return createIterResultObject(result, state.done); + } catch (error) { + state.done = true; + throw error; + } + }, + 'return': function () { + var state = getInternalState(this); + var iterator = state.iterator; + state.done = true; + if (IS_ITERATOR) { + var returnMethod = getMethod(iterator, 'return'); + return returnMethod ? call(returnMethod, iterator) : createIterResultObject(undefined, true); + } + if (state.inner) try { + iteratorClose(state.inner.iterator, 'normal'); + } catch (error) { + return iteratorClose(iterator, 'throw', error); + } + iteratorClose(iterator, 'normal'); + return createIterResultObject(undefined, true); + } + }); + }; + + var WrapForValidIteratorPrototype = createIteratorProxyPrototype(true); + var IteratorHelperPrototype = createIteratorProxyPrototype(false); + + createNonEnumerableProperty(IteratorHelperPrototype, TO_STRING_TAG, 'Iterator Helper'); + + iteratorCreateProxy = function (nextHandler, IS_ITERATOR) { + var IteratorProxy = function Iterator(record, state) { + if (state) { + state.iterator = record.iterator; + state.next = record.next; + } else state = record; + state.type = IS_ITERATOR ? WRAP_FOR_VALID_ITERATOR : ITERATOR_HELPER; + state.nextHandler = nextHandler; + state.counter = 0; + state.done = false; + setInternalState(this, state); + }; + + IteratorProxy.prototype = IS_ITERATOR ? WrapForValidIteratorPrototype : IteratorHelperPrototype; + + return IteratorProxy; + }; + return iteratorCreateProxy; +} + +var iteratorMap; +var hasRequiredIteratorMap; + +function requireIteratorMap () { + if (hasRequiredIteratorMap) return iteratorMap; + hasRequiredIteratorMap = 1; + var call = requireFunctionCall(); + var aCallable = requireACallable(); + var anObject = requireAnObject(); + var getIteratorDirect = requireGetIteratorDirect(); + var createIteratorProxy = requireIteratorCreateProxy(); + var callWithSafeIterationClosing = requireCallWithSafeIterationClosing(); + + var IteratorProxy = createIteratorProxy(function () { + var iterator = this.iterator; + var result = anObject(call(this.next, iterator)); + var done = this.done = !!result.done; + if (!done) return callWithSafeIterationClosing(iterator, this.mapper, [result.value, this.counter++], true); + }); + + // `Iterator.prototype.map` method + // https://github.com/tc39/proposal-iterator-helpers + iteratorMap = function map(mapper) { + anObject(this); + aCallable(mapper); + return new IteratorProxy(getIteratorDirect(this), { + mapper: mapper + }); + }; + return iteratorMap; +} + +var iteratorIndexed; +var hasRequiredIteratorIndexed; + +function requireIteratorIndexed () { + if (hasRequiredIteratorIndexed) return iteratorIndexed; + hasRequiredIteratorIndexed = 1; + var call = requireFunctionCall(); + var map = requireIteratorMap(); + + var callback = function (value, counter) { + return [counter, value]; + }; + + // `Iterator.prototype.indexed` method + // https://github.com/tc39/proposal-iterator-helpers + iteratorIndexed = function indexed() { + return call(map, this, callback); + }; + return iteratorIndexed; +} + +var hasRequiredEsnext_iterator_asIndexedPairs; + +function requireEsnext_iterator_asIndexedPairs () { + if (hasRequiredEsnext_iterator_asIndexedPairs) return esnext_iterator_asIndexedPairs; + hasRequiredEsnext_iterator_asIndexedPairs = 1; + // TODO: Remove from `core-js@4` + var $ = require_export(); + var indexed = requireIteratorIndexed(); + + // `Iterator.prototype.asIndexedPairs` method + // https://github.com/tc39/proposal-iterator-helpers + $({ target: 'Iterator', name: 'indexed', proto: true, real: true, forced: true }, { + asIndexedPairs: indexed + }); + return esnext_iterator_asIndexedPairs; +} + +var esnext_iterator_dispose = {}; + +var hasRequiredEsnext_iterator_dispose; + +function requireEsnext_iterator_dispose () { + if (hasRequiredEsnext_iterator_dispose) return esnext_iterator_dispose; + hasRequiredEsnext_iterator_dispose = 1; + // https://github.com/tc39/proposal-explicit-resource-management + var call = requireFunctionCall(); + var defineBuiltIn = requireDefineBuiltIn(); + var getMethod = requireGetMethod(); + var hasOwn = requireHasOwnProperty(); + var wellKnownSymbol = requireWellKnownSymbol(); + var IteratorPrototype = requireIteratorsCore().IteratorPrototype; + + var DISPOSE = wellKnownSymbol('dispose'); + + if (!hasOwn(IteratorPrototype, DISPOSE)) { + defineBuiltIn(IteratorPrototype, DISPOSE, function () { + var $return = getMethod(this, 'return'); + if ($return) call($return, this); + }); + } + return esnext_iterator_dispose; +} + +var esnext_iterator_drop = {}; + +var hasRequiredEsnext_iterator_drop; + +function requireEsnext_iterator_drop () { + if (hasRequiredEsnext_iterator_drop) return esnext_iterator_drop; + hasRequiredEsnext_iterator_drop = 1; + var $ = require_export(); + var call = requireFunctionCall(); + var anObject = requireAnObject(); + var getIteratorDirect = requireGetIteratorDirect(); + var notANaN = requireNotANan(); + var toPositiveInteger = requireToPositiveInteger(); + var createIteratorProxy = requireIteratorCreateProxy(); + var IS_PURE = requireIsPure(); + + var IteratorProxy = createIteratorProxy(function () { + var iterator = this.iterator; + var next = this.next; + var result, done; + while (this.remaining) { + this.remaining--; + result = anObject(call(next, iterator)); + done = this.done = !!result.done; + if (done) return; + } + result = anObject(call(next, iterator)); + done = this.done = !!result.done; + if (!done) return result.value; + }); + + // `Iterator.prototype.drop` method + // https://github.com/tc39/proposal-iterator-helpers + $({ target: 'Iterator', proto: true, real: true, forced: IS_PURE }, { + drop: function drop(limit) { + anObject(this); + var remaining = toPositiveInteger(notANaN(+limit)); + return new IteratorProxy(getIteratorDirect(this), { + remaining: remaining + }); + } + }); + return esnext_iterator_drop; +} + +var esnext_iterator_every = {}; + +var hasRequiredEsnext_iterator_every; + +function requireEsnext_iterator_every () { + if (hasRequiredEsnext_iterator_every) return esnext_iterator_every; + hasRequiredEsnext_iterator_every = 1; + var $ = require_export(); + var iterate = requireIterate(); + var aCallable = requireACallable(); + var anObject = requireAnObject(); + var getIteratorDirect = requireGetIteratorDirect(); + + // `Iterator.prototype.every` method + // https://github.com/tc39/proposal-iterator-helpers + $({ target: 'Iterator', proto: true, real: true }, { + every: function every(predicate) { + anObject(this); + aCallable(predicate); + var record = getIteratorDirect(this); + var counter = 0; + return !iterate(record, function (value, stop) { + if (!predicate(value, counter++)) return stop(); + }, { IS_RECORD: true, INTERRUPTED: true }).stopped; + } + }); + return esnext_iterator_every; +} + +var esnext_iterator_filter = {}; + +var hasRequiredEsnext_iterator_filter; + +function requireEsnext_iterator_filter () { + if (hasRequiredEsnext_iterator_filter) return esnext_iterator_filter; + hasRequiredEsnext_iterator_filter = 1; + var $ = require_export(); + var call = requireFunctionCall(); + var aCallable = requireACallable(); + var anObject = requireAnObject(); + var getIteratorDirect = requireGetIteratorDirect(); + var createIteratorProxy = requireIteratorCreateProxy(); + var callWithSafeIterationClosing = requireCallWithSafeIterationClosing(); + var IS_PURE = requireIsPure(); + + var IteratorProxy = createIteratorProxy(function () { + var iterator = this.iterator; + var predicate = this.predicate; + var next = this.next; + var result, done, value; + while (true) { + result = anObject(call(next, iterator)); + done = this.done = !!result.done; + if (done) return; + value = result.value; + if (callWithSafeIterationClosing(iterator, predicate, [value, this.counter++], true)) return value; + } + }); + + // `Iterator.prototype.filter` method + // https://github.com/tc39/proposal-iterator-helpers + $({ target: 'Iterator', proto: true, real: true, forced: IS_PURE }, { + filter: function filter(predicate) { + anObject(this); + aCallable(predicate); + return new IteratorProxy(getIteratorDirect(this), { + predicate: predicate + }); + } + }); + return esnext_iterator_filter; +} + +var esnext_iterator_find = {}; + +var hasRequiredEsnext_iterator_find; + +function requireEsnext_iterator_find () { + if (hasRequiredEsnext_iterator_find) return esnext_iterator_find; + hasRequiredEsnext_iterator_find = 1; + var $ = require_export(); + var iterate = requireIterate(); + var aCallable = requireACallable(); + var anObject = requireAnObject(); + var getIteratorDirect = requireGetIteratorDirect(); + + // `Iterator.prototype.find` method + // https://github.com/tc39/proposal-iterator-helpers + $({ target: 'Iterator', proto: true, real: true }, { + find: function find(predicate) { + anObject(this); + aCallable(predicate); + var record = getIteratorDirect(this); + var counter = 0; + return iterate(record, function (value, stop) { + if (predicate(value, counter++)) return stop(value); + }, { IS_RECORD: true, INTERRUPTED: true }).result; + } + }); + return esnext_iterator_find; +} + +var esnext_iterator_flatMap = {}; + +var getIteratorFlattenable; +var hasRequiredGetIteratorFlattenable; + +function requireGetIteratorFlattenable () { + if (hasRequiredGetIteratorFlattenable) return getIteratorFlattenable; + hasRequiredGetIteratorFlattenable = 1; + var call = requireFunctionCall(); + var anObject = requireAnObject(); + var getIteratorDirect = requireGetIteratorDirect(); + var getIteratorMethod = requireGetIteratorMethod(); + + getIteratorFlattenable = function (obj, stringHandling) { + if (!stringHandling || typeof obj !== 'string') anObject(obj); + var method = getIteratorMethod(obj); + return getIteratorDirect(anObject(method !== undefined ? call(method, obj) : obj)); + }; + return getIteratorFlattenable; +} + +var hasRequiredEsnext_iterator_flatMap; + +function requireEsnext_iterator_flatMap () { + if (hasRequiredEsnext_iterator_flatMap) return esnext_iterator_flatMap; + hasRequiredEsnext_iterator_flatMap = 1; + var $ = require_export(); + var call = requireFunctionCall(); + var aCallable = requireACallable(); + var anObject = requireAnObject(); + var getIteratorDirect = requireGetIteratorDirect(); + var getIteratorFlattenable = requireGetIteratorFlattenable(); + var createIteratorProxy = requireIteratorCreateProxy(); + var iteratorClose = requireIteratorClose(); + var IS_PURE = requireIsPure(); + + var IteratorProxy = createIteratorProxy(function () { + var iterator = this.iterator; + var mapper = this.mapper; + var result, inner; + + while (true) { + if (inner = this.inner) try { + result = anObject(call(inner.next, inner.iterator)); + if (!result.done) return result.value; + this.inner = null; + } catch (error) { iteratorClose(iterator, 'throw', error); } + + result = anObject(call(this.next, iterator)); + + if (this.done = !!result.done) return; + + try { + this.inner = getIteratorFlattenable(mapper(result.value, this.counter++), false); + } catch (error) { iteratorClose(iterator, 'throw', error); } + } + }); + + // `Iterator.prototype.flatMap` method + // https://github.com/tc39/proposal-iterator-helpers + $({ target: 'Iterator', proto: true, real: true, forced: IS_PURE }, { + flatMap: function flatMap(mapper) { + anObject(this); + aCallable(mapper); + return new IteratorProxy(getIteratorDirect(this), { + mapper: mapper, + inner: null + }); + } + }); + return esnext_iterator_flatMap; +} + +var esnext_iterator_forEach = {}; + +var hasRequiredEsnext_iterator_forEach; + +function requireEsnext_iterator_forEach () { + if (hasRequiredEsnext_iterator_forEach) return esnext_iterator_forEach; + hasRequiredEsnext_iterator_forEach = 1; + var $ = require_export(); + var iterate = requireIterate(); + var aCallable = requireACallable(); + var anObject = requireAnObject(); + var getIteratorDirect = requireGetIteratorDirect(); + + // `Iterator.prototype.forEach` method + // https://github.com/tc39/proposal-iterator-helpers + $({ target: 'Iterator', proto: true, real: true }, { + forEach: function forEach(fn) { + anObject(this); + aCallable(fn); + var record = getIteratorDirect(this); + var counter = 0; + iterate(record, function (value) { + fn(value, counter++); + }, { IS_RECORD: true }); + } + }); + return esnext_iterator_forEach; +} + +var esnext_iterator_from = {}; + +var hasRequiredEsnext_iterator_from; + +function requireEsnext_iterator_from () { + if (hasRequiredEsnext_iterator_from) return esnext_iterator_from; + hasRequiredEsnext_iterator_from = 1; + var $ = require_export(); + var call = requireFunctionCall(); + var toObject = requireToObject(); + var isPrototypeOf = requireObjectIsPrototypeOf(); + var IteratorPrototype = requireIteratorsCore().IteratorPrototype; + var createIteratorProxy = requireIteratorCreateProxy(); + var getIteratorFlattenable = requireGetIteratorFlattenable(); + var IS_PURE = requireIsPure(); + + var IteratorProxy = createIteratorProxy(function () { + return call(this.next, this.iterator); + }, true); + + // `Iterator.from` method + // https://github.com/tc39/proposal-iterator-helpers + $({ target: 'Iterator', stat: true, forced: IS_PURE }, { + from: function from(O) { + var iteratorRecord = getIteratorFlattenable(typeof O == 'string' ? toObject(O) : O, true); + return isPrototypeOf(IteratorPrototype, iteratorRecord.iterator) + ? iteratorRecord.iterator + : new IteratorProxy(iteratorRecord); + } + }); + return esnext_iterator_from; +} + +var esnext_iterator_indexed = {}; + +var hasRequiredEsnext_iterator_indexed; + +function requireEsnext_iterator_indexed () { + if (hasRequiredEsnext_iterator_indexed) return esnext_iterator_indexed; + hasRequiredEsnext_iterator_indexed = 1; + // TODO: Remove from `core-js@4` + var $ = require_export(); + var indexed = requireIteratorIndexed(); + + // `Iterator.prototype.indexed` method + // https://github.com/tc39/proposal-iterator-helpers + $({ target: 'Iterator', proto: true, real: true, forced: true }, { + indexed: indexed + }); + return esnext_iterator_indexed; +} + +var esnext_iterator_map = {}; + +var hasRequiredEsnext_iterator_map; + +function requireEsnext_iterator_map () { + if (hasRequiredEsnext_iterator_map) return esnext_iterator_map; + hasRequiredEsnext_iterator_map = 1; + var $ = require_export(); + var map = requireIteratorMap(); + var IS_PURE = requireIsPure(); + + // `Iterator.prototype.map` method + // https://github.com/tc39/proposal-iterator-helpers + $({ target: 'Iterator', proto: true, real: true, forced: IS_PURE }, { + map: map + }); + return esnext_iterator_map; +} + +var esnext_iterator_range = {}; + +var hasRequiredEsnext_iterator_range; + +function requireEsnext_iterator_range () { + if (hasRequiredEsnext_iterator_range) return esnext_iterator_range; + hasRequiredEsnext_iterator_range = 1; + /* eslint-disable es/no-bigint -- safe */ + var $ = require_export(); + var NumericRangeIterator = requireNumericRangeIterator(); + + var $TypeError = TypeError; + + // `Iterator.range` method + // https://github.com/tc39/proposal-Number.range + $({ target: 'Iterator', stat: true, forced: true }, { + range: function range(start, end, option) { + if (typeof start == 'number') return new NumericRangeIterator(start, end, option, 'number', 0, 1); + if (typeof start == 'bigint') return new NumericRangeIterator(start, end, option, 'bigint', BigInt(0), BigInt(1)); + throw new $TypeError('Incorrect Iterator.range arguments'); + } + }); + return esnext_iterator_range; +} + +var esnext_iterator_reduce = {}; + +var hasRequiredEsnext_iterator_reduce; + +function requireEsnext_iterator_reduce () { + if (hasRequiredEsnext_iterator_reduce) return esnext_iterator_reduce; + hasRequiredEsnext_iterator_reduce = 1; + var $ = require_export(); + var iterate = requireIterate(); + var aCallable = requireACallable(); + var anObject = requireAnObject(); + var getIteratorDirect = requireGetIteratorDirect(); + + var $TypeError = TypeError; + + // `Iterator.prototype.reduce` method + // https://github.com/tc39/proposal-iterator-helpers + $({ target: 'Iterator', proto: true, real: true }, { + reduce: function reduce(reducer /* , initialValue */) { + anObject(this); + aCallable(reducer); + var record = getIteratorDirect(this); + var noInitial = arguments.length < 2; + var accumulator = noInitial ? undefined : arguments[1]; + var counter = 0; + iterate(record, function (value) { + if (noInitial) { + noInitial = false; + accumulator = value; + } else { + accumulator = reducer(accumulator, value, counter); + } + counter++; + }, { IS_RECORD: true }); + if (noInitial) throw new $TypeError('Reduce of empty iterator with no initial value'); + return accumulator; + } + }); + return esnext_iterator_reduce; +} + +var esnext_iterator_some = {}; + +var hasRequiredEsnext_iterator_some; + +function requireEsnext_iterator_some () { + if (hasRequiredEsnext_iterator_some) return esnext_iterator_some; + hasRequiredEsnext_iterator_some = 1; + var $ = require_export(); + var iterate = requireIterate(); + var aCallable = requireACallable(); + var anObject = requireAnObject(); + var getIteratorDirect = requireGetIteratorDirect(); + + // `Iterator.prototype.some` method + // https://github.com/tc39/proposal-iterator-helpers + $({ target: 'Iterator', proto: true, real: true }, { + some: function some(predicate) { + anObject(this); + aCallable(predicate); + var record = getIteratorDirect(this); + var counter = 0; + return iterate(record, function (value, stop) { + if (predicate(value, counter++)) return stop(); + }, { IS_RECORD: true, INTERRUPTED: true }).stopped; + } + }); + return esnext_iterator_some; +} + +var esnext_iterator_take = {}; + +var hasRequiredEsnext_iterator_take; + +function requireEsnext_iterator_take () { + if (hasRequiredEsnext_iterator_take) return esnext_iterator_take; + hasRequiredEsnext_iterator_take = 1; + var $ = require_export(); + var call = requireFunctionCall(); + var anObject = requireAnObject(); + var getIteratorDirect = requireGetIteratorDirect(); + var notANaN = requireNotANan(); + var toPositiveInteger = requireToPositiveInteger(); + var createIteratorProxy = requireIteratorCreateProxy(); + var iteratorClose = requireIteratorClose(); + var IS_PURE = requireIsPure(); + + var IteratorProxy = createIteratorProxy(function () { + var iterator = this.iterator; + if (!this.remaining--) { + this.done = true; + return iteratorClose(iterator, 'normal', undefined); + } + var result = anObject(call(this.next, iterator)); + var done = this.done = !!result.done; + if (!done) return result.value; + }); + + // `Iterator.prototype.take` method + // https://github.com/tc39/proposal-iterator-helpers + $({ target: 'Iterator', proto: true, real: true, forced: IS_PURE }, { + take: function take(limit) { + anObject(this); + var remaining = toPositiveInteger(notANaN(+limit)); + return new IteratorProxy(getIteratorDirect(this), { + remaining: remaining + }); + } + }); + return esnext_iterator_take; +} + +var esnext_iterator_toArray = {}; + +var hasRequiredEsnext_iterator_toArray; + +function requireEsnext_iterator_toArray () { + if (hasRequiredEsnext_iterator_toArray) return esnext_iterator_toArray; + hasRequiredEsnext_iterator_toArray = 1; + var $ = require_export(); + var anObject = requireAnObject(); + var iterate = requireIterate(); + var getIteratorDirect = requireGetIteratorDirect(); + + var push = [].push; + + // `Iterator.prototype.toArray` method + // https://github.com/tc39/proposal-iterator-helpers + $({ target: 'Iterator', proto: true, real: true }, { + toArray: function toArray() { + var result = []; + iterate(getIteratorDirect(anObject(this)), push, { that: result, IS_RECORD: true }); + return result; + } + }); + return esnext_iterator_toArray; +} + +var esnext_iterator_toAsync = {}; + +var hasRequiredEsnext_iterator_toAsync; + +function requireEsnext_iterator_toAsync () { + if (hasRequiredEsnext_iterator_toAsync) return esnext_iterator_toAsync; + hasRequiredEsnext_iterator_toAsync = 1; + var $ = require_export(); + var anObject = requireAnObject(); + var AsyncFromSyncIterator = requireAsyncFromSyncIterator(); + var WrapAsyncIterator = requireAsyncIteratorWrap(); + var getIteratorDirect = requireGetIteratorDirect(); + var IS_PURE = requireIsPure(); + + // `Iterator.prototype.toAsync` method + // https://github.com/tc39/proposal-async-iterator-helpers + $({ target: 'Iterator', proto: true, real: true, forced: IS_PURE }, { + toAsync: function toAsync() { + return new WrapAsyncIterator(getIteratorDirect(new AsyncFromSyncIterator(getIteratorDirect(anObject(this))))); + } + }); + return esnext_iterator_toAsync; +} + +var esnext_json_isRawJson = {}; + +var nativeRawJson; +var hasRequiredNativeRawJson; + +function requireNativeRawJson () { + if (hasRequiredNativeRawJson) return nativeRawJson; + hasRequiredNativeRawJson = 1; + /* eslint-disable es/no-json -- safe */ + var fails = requireFails(); + + nativeRawJson = !fails(function () { + var unsafeInt = '9007199254740993'; + var raw = JSON.rawJSON(unsafeInt); + return !JSON.isRawJSON(raw) || JSON.stringify(raw) !== unsafeInt; + }); + return nativeRawJson; +} + +var isRawJson; +var hasRequiredIsRawJson; + +function requireIsRawJson () { + if (hasRequiredIsRawJson) return isRawJson; + hasRequiredIsRawJson = 1; + var isObject = requireIsObject(); + var getInternalState = requireInternalState().get; + + isRawJson = function isRawJSON(O) { + if (!isObject(O)) return false; + var state = getInternalState(O); + return !!state && state.type === 'RawJSON'; + }; + return isRawJson; +} + +var hasRequiredEsnext_json_isRawJson; + +function requireEsnext_json_isRawJson () { + if (hasRequiredEsnext_json_isRawJson) return esnext_json_isRawJson; + hasRequiredEsnext_json_isRawJson = 1; + var $ = require_export(); + var NATIVE_RAW_JSON = requireNativeRawJson(); + var isRawJSON = requireIsRawJson(); + + // `JSON.parse` method + // https://tc39.es/proposal-json-parse-with-source/#sec-json.israwjson + // https://github.com/tc39/proposal-json-parse-with-source + $({ target: 'JSON', stat: true, forced: !NATIVE_RAW_JSON }, { + isRawJSON: isRawJSON + }); + return esnext_json_isRawJson; +} + +var esnext_json_parse = {}; + +var parseJsonString; +var hasRequiredParseJsonString; + +function requireParseJsonString () { + if (hasRequiredParseJsonString) return parseJsonString; + hasRequiredParseJsonString = 1; + var uncurryThis = requireFunctionUncurryThis(); + var hasOwn = requireHasOwnProperty(); + + var $SyntaxError = SyntaxError; + var $parseInt = parseInt; + var fromCharCode = String.fromCharCode; + var at = uncurryThis(''.charAt); + var slice = uncurryThis(''.slice); + var exec = uncurryThis(/./.exec); + + var codePoints = { + '\\"': '"', + '\\\\': '\\', + '\\/': '/', + '\\b': '\b', + '\\f': '\f', + '\\n': '\n', + '\\r': '\r', + '\\t': '\t' + }; + + var IS_4_HEX_DIGITS = /^[\da-f]{4}$/i; + // eslint-disable-next-line regexp/no-control-character -- safe + var IS_C0_CONTROL_CODE = /^[\u0000-\u001F]$/; + + parseJsonString = function (source, i) { + var unterminated = true; + var value = ''; + while (i < source.length) { + var chr = at(source, i); + if (chr === '\\') { + var twoChars = slice(source, i, i + 2); + if (hasOwn(codePoints, twoChars)) { + value += codePoints[twoChars]; + i += 2; + } else if (twoChars === '\\u') { + i += 2; + var fourHexDigits = slice(source, i, i + 4); + if (!exec(IS_4_HEX_DIGITS, fourHexDigits)) throw new $SyntaxError('Bad Unicode escape at: ' + i); + value += fromCharCode($parseInt(fourHexDigits, 16)); + i += 4; + } else throw new $SyntaxError('Unknown escape sequence: "' + twoChars + '"'); + } else if (chr === '"') { + unterminated = false; + i++; + break; + } else { + if (exec(IS_C0_CONTROL_CODE, chr)) throw new $SyntaxError('Bad control character in string literal at: ' + i); + value += chr; + i++; + } + } + if (unterminated) throw new $SyntaxError('Unterminated string at: ' + i); + return { value: value, end: i }; + }; + return parseJsonString; +} + +var hasRequiredEsnext_json_parse; + +function requireEsnext_json_parse () { + if (hasRequiredEsnext_json_parse) return esnext_json_parse; + hasRequiredEsnext_json_parse = 1; + var $ = require_export(); + var DESCRIPTORS = requireDescriptors(); + var globalThis = requireGlobalThis(); + var getBuiltIn = requireGetBuiltIn(); + var uncurryThis = requireFunctionUncurryThis(); + var call = requireFunctionCall(); + var isCallable = requireIsCallable(); + var isObject = requireIsObject(); + var isArray = requireIsArray(); + var hasOwn = requireHasOwnProperty(); + var toString = requireToString(); + var lengthOfArrayLike = requireLengthOfArrayLike(); + var createProperty = requireCreateProperty(); + var fails = requireFails(); + var parseJSONString = requireParseJsonString(); + var NATIVE_SYMBOL = requireSymbolConstructorDetection(); + + var JSON = globalThis.JSON; + var Number = globalThis.Number; + var SyntaxError = globalThis.SyntaxError; + var nativeParse = JSON && JSON.parse; + var enumerableOwnProperties = getBuiltIn('Object', 'keys'); + // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe + var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; + var at = uncurryThis(''.charAt); + var slice = uncurryThis(''.slice); + var exec = uncurryThis(/./.exec); + var push = uncurryThis([].push); + + var IS_DIGIT = /^\d$/; + var IS_NON_ZERO_DIGIT = /^[1-9]$/; + var IS_NUMBER_START = /^[\d-]$/; + var IS_WHITESPACE = /^[\t\n\r ]$/; + + var PRIMITIVE = 0; + var OBJECT = 1; + + var $parse = function (source, reviver) { + source = toString(source); + var context = new Context(source, 0); + var root = context.parse(); + var value = root.value; + var endIndex = context.skip(IS_WHITESPACE, root.end); + if (endIndex < source.length) { + throw new SyntaxError('Unexpected extra character: "' + at(source, endIndex) + '" after the parsed data at: ' + endIndex); + } + return isCallable(reviver) ? internalize({ '': value }, '', reviver, root) : value; + }; + + var internalize = function (holder, name, reviver, node) { + var val = holder[name]; + var unmodified = node && val === node.value; + var context = unmodified && typeof node.source == 'string' ? { source: node.source } : {}; + var elementRecordsLen, keys, len, i, P; + if (isObject(val)) { + var nodeIsArray = isArray(val); + var nodes = unmodified ? node.nodes : nodeIsArray ? [] : {}; + if (nodeIsArray) { + elementRecordsLen = nodes.length; + len = lengthOfArrayLike(val); + for (i = 0; i < len; i++) { + internalizeProperty(val, i, internalize(val, '' + i, reviver, i < elementRecordsLen ? nodes[i] : undefined)); + } + } else { + keys = enumerableOwnProperties(val); + len = lengthOfArrayLike(keys); + for (i = 0; i < len; i++) { + P = keys[i]; + internalizeProperty(val, P, internalize(val, P, reviver, hasOwn(nodes, P) ? nodes[P] : undefined)); + } + } + } + return call(reviver, holder, name, val, context); + }; + + var internalizeProperty = function (object, key, value) { + if (DESCRIPTORS) { + var descriptor = getOwnPropertyDescriptor(object, key); + if (descriptor && !descriptor.configurable) return; + } + if (value === undefined) delete object[key]; + else createProperty(object, key, value); + }; + + var Node = function (value, end, source, nodes) { + this.value = value; + this.end = end; + this.source = source; + this.nodes = nodes; + }; + + var Context = function (source, index) { + this.source = source; + this.index = index; + }; + + // https://www.json.org/json-en.html + Context.prototype = { + fork: function (nextIndex) { + return new Context(this.source, nextIndex); + }, + parse: function () { + var source = this.source; + var i = this.skip(IS_WHITESPACE, this.index); + var fork = this.fork(i); + var chr = at(source, i); + if (exec(IS_NUMBER_START, chr)) return fork.number(); + switch (chr) { + case '{': + return fork.object(); + case '[': + return fork.array(); + case '"': + return fork.string(); + case 't': + return fork.keyword(true); + case 'f': + return fork.keyword(false); + case 'n': + return fork.keyword(null); + } throw new SyntaxError('Unexpected character: "' + chr + '" at: ' + i); + }, + node: function (type, value, start, end, nodes) { + return new Node(value, end, type ? null : slice(this.source, start, end), nodes); + }, + object: function () { + var source = this.source; + var i = this.index + 1; + var expectKeypair = false; + var object = {}; + var nodes = {}; + while (i < source.length) { + i = this.until(['"', '}'], i); + if (at(source, i) === '}' && !expectKeypair) { + i++; + break; + } + // Parsing the key + var result = this.fork(i).string(); + var key = result.value; + i = result.end; + i = this.until([':'], i) + 1; + // Parsing value + i = this.skip(IS_WHITESPACE, i); + result = this.fork(i).parse(); + createProperty(nodes, key, result); + createProperty(object, key, result.value); + i = this.until([',', '}'], result.end); + var chr = at(source, i); + if (chr === ',') { + expectKeypair = true; + i++; + } else if (chr === '}') { + i++; + break; + } + } + return this.node(OBJECT, object, this.index, i, nodes); + }, + array: function () { + var source = this.source; + var i = this.index + 1; + var expectElement = false; + var array = []; + var nodes = []; + while (i < source.length) { + i = this.skip(IS_WHITESPACE, i); + if (at(source, i) === ']' && !expectElement) { + i++; + break; + } + var result = this.fork(i).parse(); + push(nodes, result); + push(array, result.value); + i = this.until([',', ']'], result.end); + if (at(source, i) === ',') { + expectElement = true; + i++; + } else if (at(source, i) === ']') { + i++; + break; + } + } + return this.node(OBJECT, array, this.index, i, nodes); + }, + string: function () { + var index = this.index; + var parsed = parseJSONString(this.source, this.index + 1); + return this.node(PRIMITIVE, parsed.value, index, parsed.end); + }, + number: function () { + var source = this.source; + var startIndex = this.index; + var i = startIndex; + if (at(source, i) === '-') i++; + if (at(source, i) === '0') i++; + else if (exec(IS_NON_ZERO_DIGIT, at(source, i))) i = this.skip(IS_DIGIT, i + 1); + else throw new SyntaxError('Failed to parse number at: ' + i); + if (at(source, i) === '.') i = this.skip(IS_DIGIT, i + 1); + if (at(source, i) === 'e' || at(source, i) === 'E') { + i++; + if (at(source, i) === '+' || at(source, i) === '-') i++; + var exponentStartIndex = i; + i = this.skip(IS_DIGIT, i); + if (exponentStartIndex === i) throw new SyntaxError("Failed to parse number's exponent value at: " + i); + } + return this.node(PRIMITIVE, Number(slice(source, startIndex, i)), startIndex, i); + }, + keyword: function (value) { + var keyword = '' + value; + var index = this.index; + var endIndex = index + keyword.length; + if (slice(this.source, index, endIndex) !== keyword) throw new SyntaxError('Failed to parse value at: ' + index); + return this.node(PRIMITIVE, value, index, endIndex); + }, + skip: function (regex, i) { + var source = this.source; + for (; i < source.length; i++) if (!exec(regex, at(source, i))) break; + return i; + }, + until: function (array, i) { + i = this.skip(IS_WHITESPACE, i); + var chr = at(this.source, i); + for (var j = 0; j < array.length; j++) if (array[j] === chr) return i; + throw new SyntaxError('Unexpected character: "' + chr + '" at: ' + i); + } + }; + + var NO_SOURCE_SUPPORT = fails(function () { + var unsafeInt = '9007199254740993'; + var source; + nativeParse(unsafeInt, function (key, value, context) { + source = context.source; + }); + return source !== unsafeInt; + }); + + var PROPER_BASE_PARSE = NATIVE_SYMBOL && !fails(function () { + // Safari 9 bug + return 1 / nativeParse('-0 \t') !== -Infinity; + }); + + // `JSON.parse` method + // https://tc39.es/ecma262/#sec-json.parse + // https://github.com/tc39/proposal-json-parse-with-source + $({ target: 'JSON', stat: true, forced: NO_SOURCE_SUPPORT }, { + parse: function parse(text, reviver) { + return PROPER_BASE_PARSE && !isCallable(reviver) ? nativeParse(text) : $parse(text, reviver); + } + }); + return esnext_json_parse; +} + +var esnext_json_rawJson = {}; + +var hasRequiredEsnext_json_rawJson; + +function requireEsnext_json_rawJson () { + if (hasRequiredEsnext_json_rawJson) return esnext_json_rawJson; + hasRequiredEsnext_json_rawJson = 1; + var $ = require_export(); + var FREEZING = requireFreezing(); + var NATIVE_RAW_JSON = requireNativeRawJson(); + var getBuiltIn = requireGetBuiltIn(); + var call = requireFunctionCall(); + var uncurryThis = requireFunctionUncurryThis(); + var isCallable = requireIsCallable(); + var isRawJSON = requireIsRawJson(); + var toString = requireToString(); + var createProperty = requireCreateProperty(); + var parseJSONString = requireParseJsonString(); + var getReplacerFunction = requireGetJsonReplacerFunction(); + var uid = requireUid(); + var setInternalState = requireInternalState().set; + + var $String = String; + var $SyntaxError = SyntaxError; + var parse = getBuiltIn('JSON', 'parse'); + var $stringify = getBuiltIn('JSON', 'stringify'); + var create = getBuiltIn('Object', 'create'); + var freeze = getBuiltIn('Object', 'freeze'); + var at = uncurryThis(''.charAt); + var slice = uncurryThis(''.slice); + var push = uncurryThis([].push); + + var MARK = uid(); + var MARK_LENGTH = MARK.length; + var ERROR_MESSAGE = 'Unacceptable as raw JSON'; + + var isWhitespace = function (it) { + return it === ' ' || it === '\t' || it === '\n' || it === '\r'; + }; + + // `JSON.parse` method + // https://tc39.es/proposal-json-parse-with-source/#sec-json.israwjson + // https://github.com/tc39/proposal-json-parse-with-source + $({ target: 'JSON', stat: true, forced: !NATIVE_RAW_JSON }, { + rawJSON: function rawJSON(text) { + var jsonString = toString(text); + if (jsonString === '' || isWhitespace(at(jsonString, 0)) || isWhitespace(at(jsonString, jsonString.length - 1))) { + throw new $SyntaxError(ERROR_MESSAGE); + } + var parsed = parse(jsonString); + if (typeof parsed == 'object' && parsed !== null) throw new $SyntaxError(ERROR_MESSAGE); + var obj = create(null); + setInternalState(obj, { type: 'RawJSON' }); + createProperty(obj, 'rawJSON', jsonString); + return FREEZING ? freeze(obj) : obj; + } + }); + + // `JSON.stringify` method + // https://tc39.es/ecma262/#sec-json.stringify + // https://github.com/tc39/proposal-json-parse-with-source + if ($stringify) $({ target: 'JSON', stat: true, arity: 3, forced: !NATIVE_RAW_JSON }, { + stringify: function stringify(text, replacer, space) { + var replacerFunction = getReplacerFunction(replacer); + var rawStrings = []; + + var json = $stringify(text, function (key, value) { + // some old implementations (like WebKit) could pass numbers as keys + var v = isCallable(replacerFunction) ? call(replacerFunction, this, $String(key), value) : value; + return isRawJSON(v) ? MARK + (push(rawStrings, v.rawJSON) - 1) : v; + }, space); + + if (typeof json != 'string') return json; + + var result = ''; + var length = json.length; + + for (var i = 0; i < length; i++) { + var chr = at(json, i); + if (chr === '"') { + var end = parseJSONString(json, ++i).end - 1; + var string = slice(json, i, end); + result += slice(string, 0, MARK_LENGTH) === MARK + ? rawStrings[slice(string, MARK_LENGTH)] + : '"' + string + '"'; + i = end; + } else result += chr; + } + + return result; + } + }); + return esnext_json_rawJson; +} + +var esnext_map_deleteAll = {}; + +var aMap; +var hasRequiredAMap; + +function requireAMap () { + if (hasRequiredAMap) return aMap; + hasRequiredAMap = 1; + var has = requireMapHelpers().has; + + // Perform ? RequireInternalSlot(M, [[MapData]]) + aMap = function (it) { + has(it); + return it; + }; + return aMap; +} + +var hasRequiredEsnext_map_deleteAll; + +function requireEsnext_map_deleteAll () { + if (hasRequiredEsnext_map_deleteAll) return esnext_map_deleteAll; + hasRequiredEsnext_map_deleteAll = 1; + var $ = require_export(); + var aMap = requireAMap(); + var remove = requireMapHelpers().remove; + + // `Map.prototype.deleteAll` method + // https://github.com/tc39/proposal-collection-methods + $({ target: 'Map', proto: true, real: true, forced: true }, { + deleteAll: function deleteAll(/* ...elements */) { + var collection = aMap(this); + var allDeleted = true; + var wasDeleted; + for (var k = 0, len = arguments.length; k < len; k++) { + wasDeleted = remove(collection, arguments[k]); + allDeleted = allDeleted && wasDeleted; + } return !!allDeleted; + } + }); + return esnext_map_deleteAll; +} + +var esnext_map_emplace = {}; + +var hasRequiredEsnext_map_emplace; + +function requireEsnext_map_emplace () { + if (hasRequiredEsnext_map_emplace) return esnext_map_emplace; + hasRequiredEsnext_map_emplace = 1; + var $ = require_export(); + var aMap = requireAMap(); + var MapHelpers = requireMapHelpers(); + + var get = MapHelpers.get; + var has = MapHelpers.has; + var set = MapHelpers.set; + + // `Map.prototype.emplace` method + // https://github.com/tc39/proposal-upsert + $({ target: 'Map', proto: true, real: true, forced: true }, { + emplace: function emplace(key, handler) { + var map = aMap(this); + var value, inserted; + if (has(map, key)) { + value = get(map, key); + if ('update' in handler) { + value = handler.update(value, key, map); + set(map, key, value); + } return value; + } + inserted = handler.insert(key, map); + set(map, key, inserted); + return inserted; + } + }); + return esnext_map_emplace; +} + +var esnext_map_every = {}; + +var hasRequiredEsnext_map_every; + +function requireEsnext_map_every () { + if (hasRequiredEsnext_map_every) return esnext_map_every; + hasRequiredEsnext_map_every = 1; + var $ = require_export(); + var bind = requireFunctionBindContext(); + var aMap = requireAMap(); + var iterate = requireMapIterate(); + + // `Map.prototype.every` method + // https://github.com/tc39/proposal-collection-methods + $({ target: 'Map', proto: true, real: true, forced: true }, { + every: function every(callbackfn /* , thisArg */) { + var map = aMap(this); + var boundFunction = bind(callbackfn, arguments.length > 1 ? arguments[1] : undefined); + return iterate(map, function (value, key) { + if (!boundFunction(value, key, map)) return false; + }, true) !== false; + } + }); + return esnext_map_every; +} + +var esnext_map_filter = {}; + +var hasRequiredEsnext_map_filter; + +function requireEsnext_map_filter () { + if (hasRequiredEsnext_map_filter) return esnext_map_filter; + hasRequiredEsnext_map_filter = 1; + var $ = require_export(); + var bind = requireFunctionBindContext(); + var aMap = requireAMap(); + var MapHelpers = requireMapHelpers(); + var iterate = requireMapIterate(); + + var Map = MapHelpers.Map; + var set = MapHelpers.set; + + // `Map.prototype.filter` method + // https://github.com/tc39/proposal-collection-methods + $({ target: 'Map', proto: true, real: true, forced: true }, { + filter: function filter(callbackfn /* , thisArg */) { + var map = aMap(this); + var boundFunction = bind(callbackfn, arguments.length > 1 ? arguments[1] : undefined); + var newMap = new Map(); + iterate(map, function (value, key) { + if (boundFunction(value, key, map)) set(newMap, key, value); + }); + return newMap; + } + }); + return esnext_map_filter; +} + +var esnext_map_find = {}; + +var hasRequiredEsnext_map_find; + +function requireEsnext_map_find () { + if (hasRequiredEsnext_map_find) return esnext_map_find; + hasRequiredEsnext_map_find = 1; + var $ = require_export(); + var bind = requireFunctionBindContext(); + var aMap = requireAMap(); + var iterate = requireMapIterate(); + + // `Map.prototype.find` method + // https://github.com/tc39/proposal-collection-methods + $({ target: 'Map', proto: true, real: true, forced: true }, { + find: function find(callbackfn /* , thisArg */) { + var map = aMap(this); + var boundFunction = bind(callbackfn, arguments.length > 1 ? arguments[1] : undefined); + var result = iterate(map, function (value, key) { + if (boundFunction(value, key, map)) return { value: value }; + }, true); + return result && result.value; + } + }); + return esnext_map_find; +} + +var esnext_map_findKey = {}; + +var hasRequiredEsnext_map_findKey; + +function requireEsnext_map_findKey () { + if (hasRequiredEsnext_map_findKey) return esnext_map_findKey; + hasRequiredEsnext_map_findKey = 1; + var $ = require_export(); + var bind = requireFunctionBindContext(); + var aMap = requireAMap(); + var iterate = requireMapIterate(); + + // `Map.prototype.findKey` method + // https://github.com/tc39/proposal-collection-methods + $({ target: 'Map', proto: true, real: true, forced: true }, { + findKey: function findKey(callbackfn /* , thisArg */) { + var map = aMap(this); + var boundFunction = bind(callbackfn, arguments.length > 1 ? arguments[1] : undefined); + var result = iterate(map, function (value, key) { + if (boundFunction(value, key, map)) return { key: key }; + }, true); + return result && result.key; + } + }); + return esnext_map_findKey; +} + +var esnext_map_from = {}; + +var collectionFrom; +var hasRequiredCollectionFrom; + +function requireCollectionFrom () { + if (hasRequiredCollectionFrom) return collectionFrom; + hasRequiredCollectionFrom = 1; + // https://tc39.github.io/proposal-setmap-offrom/ + var bind = requireFunctionBindContext(); + var anObject = requireAnObject(); + var toObject = requireToObject(); + var iterate = requireIterate(); + + collectionFrom = function (C, adder, ENTRY) { + return function from(source /* , mapFn, thisArg */) { + var O = toObject(source); + var length = arguments.length; + var mapFn = length > 1 ? arguments[1] : undefined; + var mapping = mapFn !== undefined; + var boundFunction = mapping ? bind(mapFn, length > 2 ? arguments[2] : undefined) : undefined; + var result = new C(); + var n = 0; + iterate(O, function (nextItem) { + var entry = mapping ? boundFunction(nextItem, n++) : nextItem; + if (ENTRY) adder(result, anObject(entry)[0], entry[1]); + else adder(result, entry); + }); + return result; + }; + }; + return collectionFrom; +} + +var hasRequiredEsnext_map_from; + +function requireEsnext_map_from () { + if (hasRequiredEsnext_map_from) return esnext_map_from; + hasRequiredEsnext_map_from = 1; + var $ = require_export(); + var MapHelpers = requireMapHelpers(); + var createCollectionFrom = requireCollectionFrom(); + + // `Map.from` method + // https://tc39.github.io/proposal-setmap-offrom/#sec-map.from + $({ target: 'Map', stat: true, forced: true }, { + from: createCollectionFrom(MapHelpers.Map, MapHelpers.set, true) + }); + return esnext_map_from; +} + +var esnext_map_groupBy = {}; + +var hasRequiredEsnext_map_groupBy; + +function requireEsnext_map_groupBy () { + if (hasRequiredEsnext_map_groupBy) return esnext_map_groupBy; + hasRequiredEsnext_map_groupBy = 1; + // TODO: Remove from `core-js@4` + requireEs_map_groupBy(); + return esnext_map_groupBy; +} + +var esnext_map_includes = {}; + +var sameValueZero; +var hasRequiredSameValueZero; + +function requireSameValueZero () { + if (hasRequiredSameValueZero) return sameValueZero; + hasRequiredSameValueZero = 1; + // `SameValueZero` abstract operation + // https://tc39.es/ecma262/#sec-samevaluezero + sameValueZero = function (x, y) { + // eslint-disable-next-line no-self-compare -- NaN check + return x === y || x !== x && y !== y; + }; + return sameValueZero; +} + +var hasRequiredEsnext_map_includes; + +function requireEsnext_map_includes () { + if (hasRequiredEsnext_map_includes) return esnext_map_includes; + hasRequiredEsnext_map_includes = 1; + var $ = require_export(); + var sameValueZero = requireSameValueZero(); + var aMap = requireAMap(); + var iterate = requireMapIterate(); + + // `Map.prototype.includes` method + // https://github.com/tc39/proposal-collection-methods + $({ target: 'Map', proto: true, real: true, forced: true }, { + includes: function includes(searchElement) { + return iterate(aMap(this), function (value) { + if (sameValueZero(value, searchElement)) return true; + }, true) === true; + } + }); + return esnext_map_includes; +} + +var esnext_map_keyBy = {}; + +var hasRequiredEsnext_map_keyBy; + +function requireEsnext_map_keyBy () { + if (hasRequiredEsnext_map_keyBy) return esnext_map_keyBy; + hasRequiredEsnext_map_keyBy = 1; + var $ = require_export(); + var call = requireFunctionCall(); + var iterate = requireIterate(); + var isCallable = requireIsCallable(); + var aCallable = requireACallable(); + var Map = requireMapHelpers().Map; + + // `Map.keyBy` method + // https://github.com/tc39/proposal-collection-methods + $({ target: 'Map', stat: true, forced: true }, { + keyBy: function keyBy(iterable, keyDerivative) { + var C = isCallable(this) ? this : Map; + var newMap = new C(); + aCallable(keyDerivative); + var setter = aCallable(newMap.set); + iterate(iterable, function (element) { + call(setter, newMap, keyDerivative(element), element); + }); + return newMap; + } + }); + return esnext_map_keyBy; +} + +var esnext_map_keyOf = {}; + +var hasRequiredEsnext_map_keyOf; + +function requireEsnext_map_keyOf () { + if (hasRequiredEsnext_map_keyOf) return esnext_map_keyOf; + hasRequiredEsnext_map_keyOf = 1; + var $ = require_export(); + var aMap = requireAMap(); + var iterate = requireMapIterate(); + + // `Map.prototype.keyOf` method + // https://github.com/tc39/proposal-collection-methods + $({ target: 'Map', proto: true, real: true, forced: true }, { + keyOf: function keyOf(searchElement) { + var result = iterate(aMap(this), function (value, key) { + if (value === searchElement) return { key: key }; + }, true); + return result && result.key; + } + }); + return esnext_map_keyOf; +} + +var esnext_map_mapKeys = {}; + +var hasRequiredEsnext_map_mapKeys; + +function requireEsnext_map_mapKeys () { + if (hasRequiredEsnext_map_mapKeys) return esnext_map_mapKeys; + hasRequiredEsnext_map_mapKeys = 1; + var $ = require_export(); + var bind = requireFunctionBindContext(); + var aMap = requireAMap(); + var MapHelpers = requireMapHelpers(); + var iterate = requireMapIterate(); + + var Map = MapHelpers.Map; + var set = MapHelpers.set; + + // `Map.prototype.mapKeys` method + // https://github.com/tc39/proposal-collection-methods + $({ target: 'Map', proto: true, real: true, forced: true }, { + mapKeys: function mapKeys(callbackfn /* , thisArg */) { + var map = aMap(this); + var boundFunction = bind(callbackfn, arguments.length > 1 ? arguments[1] : undefined); + var newMap = new Map(); + iterate(map, function (value, key) { + set(newMap, boundFunction(value, key, map), value); + }); + return newMap; + } + }); + return esnext_map_mapKeys; +} + +var esnext_map_mapValues = {}; + +var hasRequiredEsnext_map_mapValues; + +function requireEsnext_map_mapValues () { + if (hasRequiredEsnext_map_mapValues) return esnext_map_mapValues; + hasRequiredEsnext_map_mapValues = 1; + var $ = require_export(); + var bind = requireFunctionBindContext(); + var aMap = requireAMap(); + var MapHelpers = requireMapHelpers(); + var iterate = requireMapIterate(); + + var Map = MapHelpers.Map; + var set = MapHelpers.set; + + // `Map.prototype.mapValues` method + // https://github.com/tc39/proposal-collection-methods + $({ target: 'Map', proto: true, real: true, forced: true }, { + mapValues: function mapValues(callbackfn /* , thisArg */) { + var map = aMap(this); + var boundFunction = bind(callbackfn, arguments.length > 1 ? arguments[1] : undefined); + var newMap = new Map(); + iterate(map, function (value, key) { + set(newMap, key, boundFunction(value, key, map)); + }); + return newMap; + } + }); + return esnext_map_mapValues; +} + +var esnext_map_merge = {}; + +var hasRequiredEsnext_map_merge; + +function requireEsnext_map_merge () { + if (hasRequiredEsnext_map_merge) return esnext_map_merge; + hasRequiredEsnext_map_merge = 1; + var $ = require_export(); + var aMap = requireAMap(); + var iterate = requireIterate(); + var set = requireMapHelpers().set; + + // `Map.prototype.merge` method + // https://github.com/tc39/proposal-collection-methods + $({ target: 'Map', proto: true, real: true, arity: 1, forced: true }, { + // eslint-disable-next-line no-unused-vars -- required for `.length` + merge: function merge(iterable /* ...iterables */) { + var map = aMap(this); + var argumentsLength = arguments.length; + var i = 0; + while (i < argumentsLength) { + iterate(arguments[i++], function (key, value) { + set(map, key, value); + }, { AS_ENTRIES: true }); + } + return map; + } + }); + return esnext_map_merge; +} + +var esnext_map_of = {}; + +var collectionOf; +var hasRequiredCollectionOf; + +function requireCollectionOf () { + if (hasRequiredCollectionOf) return collectionOf; + hasRequiredCollectionOf = 1; + var anObject = requireAnObject(); + + // https://tc39.github.io/proposal-setmap-offrom/ + collectionOf = function (C, adder, ENTRY) { + return function of() { + var result = new C(); + var length = arguments.length; + for (var index = 0; index < length; index++) { + var entry = arguments[index]; + if (ENTRY) adder(result, anObject(entry)[0], entry[1]); + else adder(result, entry); + } return result; + }; + }; + return collectionOf; +} + +var hasRequiredEsnext_map_of; + +function requireEsnext_map_of () { + if (hasRequiredEsnext_map_of) return esnext_map_of; + hasRequiredEsnext_map_of = 1; + var $ = require_export(); + var MapHelpers = requireMapHelpers(); + var createCollectionOf = requireCollectionOf(); + + // `Map.of` method + // https://tc39.github.io/proposal-setmap-offrom/#sec-map.of + $({ target: 'Map', stat: true, forced: true }, { + of: createCollectionOf(MapHelpers.Map, MapHelpers.set, true) + }); + return esnext_map_of; +} + +var esnext_map_reduce = {}; + +var hasRequiredEsnext_map_reduce; + +function requireEsnext_map_reduce () { + if (hasRequiredEsnext_map_reduce) return esnext_map_reduce; + hasRequiredEsnext_map_reduce = 1; + var $ = require_export(); + var aCallable = requireACallable(); + var aMap = requireAMap(); + var iterate = requireMapIterate(); + + var $TypeError = TypeError; + + // `Map.prototype.reduce` method + // https://github.com/tc39/proposal-collection-methods + $({ target: 'Map', proto: true, real: true, forced: true }, { + reduce: function reduce(callbackfn /* , initialValue */) { + var map = aMap(this); + var noInitial = arguments.length < 2; + var accumulator = noInitial ? undefined : arguments[1]; + aCallable(callbackfn); + iterate(map, function (value, key) { + if (noInitial) { + noInitial = false; + accumulator = value; + } else { + accumulator = callbackfn(accumulator, value, key, map); + } + }); + if (noInitial) throw new $TypeError('Reduce of empty map with no initial value'); + return accumulator; + } + }); + return esnext_map_reduce; +} + +var esnext_map_some = {}; + +var hasRequiredEsnext_map_some; + +function requireEsnext_map_some () { + if (hasRequiredEsnext_map_some) return esnext_map_some; + hasRequiredEsnext_map_some = 1; + var $ = require_export(); + var bind = requireFunctionBindContext(); + var aMap = requireAMap(); + var iterate = requireMapIterate(); + + // `Map.prototype.some` method + // https://github.com/tc39/proposal-collection-methods + $({ target: 'Map', proto: true, real: true, forced: true }, { + some: function some(callbackfn /* , thisArg */) { + var map = aMap(this); + var boundFunction = bind(callbackfn, arguments.length > 1 ? arguments[1] : undefined); + return iterate(map, function (value, key) { + if (boundFunction(value, key, map)) return true; + }, true) === true; + } + }); + return esnext_map_some; +} + +var esnext_map_update = {}; + +var hasRequiredEsnext_map_update; + +function requireEsnext_map_update () { + if (hasRequiredEsnext_map_update) return esnext_map_update; + hasRequiredEsnext_map_update = 1; + var $ = require_export(); + var aCallable = requireACallable(); + var aMap = requireAMap(); + var MapHelpers = requireMapHelpers(); + + var $TypeError = TypeError; + var get = MapHelpers.get; + var has = MapHelpers.has; + var set = MapHelpers.set; + + // `Map.prototype.update` method + // https://github.com/tc39/proposal-collection-methods + $({ target: 'Map', proto: true, real: true, forced: true }, { + update: function update(key, callback /* , thunk */) { + var map = aMap(this); + var length = arguments.length; + aCallable(callback); + var isPresentInMap = has(map, key); + if (!isPresentInMap && length < 3) { + throw new $TypeError('Updating absent value'); + } + var value = isPresentInMap ? get(map, key) : aCallable(length > 2 ? arguments[2] : undefined)(key, map); + set(map, key, callback(value, key, map)); + return map; + } + }); + return esnext_map_update; +} + +var esnext_map_updateOrInsert = {}; + +var mapUpsert; +var hasRequiredMapUpsert; + +function requireMapUpsert () { + if (hasRequiredMapUpsert) return mapUpsert; + hasRequiredMapUpsert = 1; + var call = requireFunctionCall(); + var aCallable = requireACallable(); + var isCallable = requireIsCallable(); + var anObject = requireAnObject(); + + var $TypeError = TypeError; + + // `Map.prototype.upsert` method + // https://github.com/tc39/proposal-upsert + mapUpsert = function upsert(key, updateFn /* , insertFn */) { + var map = anObject(this); + var get = aCallable(map.get); + var has = aCallable(map.has); + var set = aCallable(map.set); + var insertFn = arguments.length > 2 ? arguments[2] : undefined; + var value; + if (!isCallable(updateFn) && !isCallable(insertFn)) { + throw new $TypeError('At least one callback required'); + } + if (call(has, map, key)) { + value = call(get, map, key); + if (isCallable(updateFn)) { + value = updateFn(value); + call(set, map, key, value); + } + } else if (isCallable(insertFn)) { + value = insertFn(); + call(set, map, key, value); + } return value; + }; + return mapUpsert; +} + +var hasRequiredEsnext_map_updateOrInsert; + +function requireEsnext_map_updateOrInsert () { + if (hasRequiredEsnext_map_updateOrInsert) return esnext_map_updateOrInsert; + hasRequiredEsnext_map_updateOrInsert = 1; + // TODO: remove from `core-js@4` + var $ = require_export(); + var upsert = requireMapUpsert(); + + // `Map.prototype.updateOrInsert` method (replaced by `Map.prototype.emplace`) + // https://github.com/thumbsupep/proposal-upsert + $({ target: 'Map', proto: true, real: true, name: 'upsert', forced: true }, { + updateOrInsert: upsert + }); + return esnext_map_updateOrInsert; +} + +var esnext_map_upsert = {}; + +var hasRequiredEsnext_map_upsert; + +function requireEsnext_map_upsert () { + if (hasRequiredEsnext_map_upsert) return esnext_map_upsert; + hasRequiredEsnext_map_upsert = 1; + // TODO: remove from `core-js@4` + var $ = require_export(); + var upsert = requireMapUpsert(); + + // `Map.prototype.upsert` method (replaced by `Map.prototype.emplace`) + // https://github.com/thumbsupep/proposal-upsert + $({ target: 'Map', proto: true, real: true, forced: true }, { + upsert: upsert + }); + return esnext_map_upsert; +} + +var esnext_math_clamp = {}; + +var hasRequiredEsnext_math_clamp; + +function requireEsnext_math_clamp () { + if (hasRequiredEsnext_math_clamp) return esnext_math_clamp; + hasRequiredEsnext_math_clamp = 1; + var $ = require_export(); + + var min = Math.min; + var max = Math.max; + + // `Math.clamp` method + // https://rwaldron.github.io/proposal-math-extensions/ + $({ target: 'Math', stat: true, forced: true }, { + clamp: function clamp(x, lower, upper) { + return min(upper, max(lower, x)); + } + }); + return esnext_math_clamp; +} + +var esnext_math_degPerRad = {}; + +var hasRequiredEsnext_math_degPerRad; + +function requireEsnext_math_degPerRad () { + if (hasRequiredEsnext_math_degPerRad) return esnext_math_degPerRad; + hasRequiredEsnext_math_degPerRad = 1; + var $ = require_export(); + + // `Math.DEG_PER_RAD` constant + // https://rwaldron.github.io/proposal-math-extensions/ + $({ target: 'Math', stat: true, nonConfigurable: true, nonWritable: true }, { + DEG_PER_RAD: Math.PI / 180 + }); + return esnext_math_degPerRad; +} + +var esnext_math_degrees = {}; + +var hasRequiredEsnext_math_degrees; + +function requireEsnext_math_degrees () { + if (hasRequiredEsnext_math_degrees) return esnext_math_degrees; + hasRequiredEsnext_math_degrees = 1; + var $ = require_export(); + + var RAD_PER_DEG = 180 / Math.PI; + + // `Math.degrees` method + // https://rwaldron.github.io/proposal-math-extensions/ + $({ target: 'Math', stat: true, forced: true }, { + degrees: function degrees(radians) { + return radians * RAD_PER_DEG; + } + }); + return esnext_math_degrees; +} + +var esnext_math_fscale = {}; + +var mathScale; +var hasRequiredMathScale; + +function requireMathScale () { + if (hasRequiredMathScale) return mathScale; + hasRequiredMathScale = 1; + // `Math.scale` method implementation + // https://rwaldron.github.io/proposal-math-extensions/ + mathScale = Math.scale || function scale(x, inLow, inHigh, outLow, outHigh) { + var nx = +x; + var nInLow = +inLow; + var nInHigh = +inHigh; + var nOutLow = +outLow; + var nOutHigh = +outHigh; + // eslint-disable-next-line no-self-compare -- NaN check + if (nx !== nx || nInLow !== nInLow || nInHigh !== nInHigh || nOutLow !== nOutLow || nOutHigh !== nOutHigh) return NaN; + if (nx === Infinity || nx === -Infinity) return nx; + return (nx - nInLow) * (nOutHigh - nOutLow) / (nInHigh - nInLow) + nOutLow; + }; + return mathScale; +} + +var hasRequiredEsnext_math_fscale; + +function requireEsnext_math_fscale () { + if (hasRequiredEsnext_math_fscale) return esnext_math_fscale; + hasRequiredEsnext_math_fscale = 1; + var $ = require_export(); + + var scale = requireMathScale(); + var fround = requireMathFround(); + + // `Math.fscale` method + // https://rwaldron.github.io/proposal-math-extensions/ + $({ target: 'Math', stat: true, forced: true }, { + fscale: function fscale(x, inLow, inHigh, outLow, outHigh) { + return fround(scale(x, inLow, inHigh, outLow, outHigh)); + } + }); + return esnext_math_fscale; +} + +var esnext_math_f16round = {}; + +var hasRequiredEsnext_math_f16round; + +function requireEsnext_math_f16round () { + if (hasRequiredEsnext_math_f16round) return esnext_math_f16round; + hasRequiredEsnext_math_f16round = 1; + var $ = require_export(); + var f16round = requireMathF16round(); + + // `Math.f16round` method + // https://github.com/tc39/proposal-float16array + $({ target: 'Math', stat: true }, { f16round: f16round }); + return esnext_math_f16round; +} + +var esnext_math_iaddh = {}; + +var hasRequiredEsnext_math_iaddh; + +function requireEsnext_math_iaddh () { + if (hasRequiredEsnext_math_iaddh) return esnext_math_iaddh; + hasRequiredEsnext_math_iaddh = 1; + var $ = require_export(); + + // `Math.iaddh` method + // https://gist.github.com/BrendanEich/4294d5c212a6d2254703 + // TODO: Remove from `core-js@4` + $({ target: 'Math', stat: true, forced: true }, { + iaddh: function iaddh(x0, x1, y0, y1) { + var $x0 = x0 >>> 0; + var $x1 = x1 >>> 0; + var $y0 = y0 >>> 0; + return $x1 + (y1 >>> 0) + (($x0 & $y0 | ($x0 | $y0) & ~($x0 + $y0 >>> 0)) >>> 31) | 0; + } + }); + return esnext_math_iaddh; +} + +var esnext_math_imulh = {}; + +var hasRequiredEsnext_math_imulh; + +function requireEsnext_math_imulh () { + if (hasRequiredEsnext_math_imulh) return esnext_math_imulh; + hasRequiredEsnext_math_imulh = 1; + var $ = require_export(); + + // `Math.imulh` method + // https://gist.github.com/BrendanEich/4294d5c212a6d2254703 + // TODO: Remove from `core-js@4` + $({ target: 'Math', stat: true, forced: true }, { + imulh: function imulh(u, v) { + var UINT16 = 0xFFFF; + var $u = +u; + var $v = +v; + var u0 = $u & UINT16; + var v0 = $v & UINT16; + var u1 = $u >> 16; + var v1 = $v >> 16; + var t = (u1 * v0 >>> 0) + (u0 * v0 >>> 16); + return u1 * v1 + (t >> 16) + ((u0 * v1 >>> 0) + (t & UINT16) >> 16); + } + }); + return esnext_math_imulh; +} + +var esnext_math_isubh = {}; + +var hasRequiredEsnext_math_isubh; + +function requireEsnext_math_isubh () { + if (hasRequiredEsnext_math_isubh) return esnext_math_isubh; + hasRequiredEsnext_math_isubh = 1; + var $ = require_export(); + + // `Math.isubh` method + // https://gist.github.com/BrendanEich/4294d5c212a6d2254703 + // TODO: Remove from `core-js@4` + $({ target: 'Math', stat: true, forced: true }, { + isubh: function isubh(x0, x1, y0, y1) { + var $x0 = x0 >>> 0; + var $x1 = x1 >>> 0; + var $y0 = y0 >>> 0; + return $x1 - (y1 >>> 0) - ((~$x0 & $y0 | ~($x0 ^ $y0) & $x0 - $y0 >>> 0) >>> 31) | 0; + } + }); + return esnext_math_isubh; +} + +var esnext_math_radPerDeg = {}; + +var hasRequiredEsnext_math_radPerDeg; + +function requireEsnext_math_radPerDeg () { + if (hasRequiredEsnext_math_radPerDeg) return esnext_math_radPerDeg; + hasRequiredEsnext_math_radPerDeg = 1; + var $ = require_export(); + + // `Math.RAD_PER_DEG` constant + // https://rwaldron.github.io/proposal-math-extensions/ + $({ target: 'Math', stat: true, nonConfigurable: true, nonWritable: true }, { + RAD_PER_DEG: 180 / Math.PI + }); + return esnext_math_radPerDeg; +} + +var esnext_math_radians = {}; + +var hasRequiredEsnext_math_radians; + +function requireEsnext_math_radians () { + if (hasRequiredEsnext_math_radians) return esnext_math_radians; + hasRequiredEsnext_math_radians = 1; + var $ = require_export(); + + var DEG_PER_RAD = Math.PI / 180; + + // `Math.radians` method + // https://rwaldron.github.io/proposal-math-extensions/ + $({ target: 'Math', stat: true, forced: true }, { + radians: function radians(degrees) { + return degrees * DEG_PER_RAD; + } + }); + return esnext_math_radians; +} + +var esnext_math_scale = {}; + +var hasRequiredEsnext_math_scale; + +function requireEsnext_math_scale () { + if (hasRequiredEsnext_math_scale) return esnext_math_scale; + hasRequiredEsnext_math_scale = 1; + var $ = require_export(); + var scale = requireMathScale(); + + // `Math.scale` method + // https://rwaldron.github.io/proposal-math-extensions/ + $({ target: 'Math', stat: true, forced: true }, { + scale: scale + }); + return esnext_math_scale; +} + +var esnext_math_seededPrng = {}; + +var hasRequiredEsnext_math_seededPrng; + +function requireEsnext_math_seededPrng () { + if (hasRequiredEsnext_math_seededPrng) return esnext_math_seededPrng; + hasRequiredEsnext_math_seededPrng = 1; + var $ = require_export(); + var anObject = requireAnObject(); + var numberIsFinite = requireNumberIsFinite(); + var createIteratorConstructor = requireIteratorCreateConstructor(); + var createIterResultObject = requireCreateIterResultObject(); + var InternalStateModule = requireInternalState(); + + var SEEDED_RANDOM = 'Seeded Random'; + var SEEDED_RANDOM_GENERATOR = SEEDED_RANDOM + ' Generator'; + var SEED_TYPE_ERROR = 'Math.seededPRNG() argument should have a "seed" field with a finite value.'; + var setInternalState = InternalStateModule.set; + var getInternalState = InternalStateModule.getterFor(SEEDED_RANDOM_GENERATOR); + var $TypeError = TypeError; + + var $SeededRandomGenerator = createIteratorConstructor(function SeededRandomGenerator(seed) { + setInternalState(this, { + type: SEEDED_RANDOM_GENERATOR, + seed: seed % 2147483647 + }); + }, SEEDED_RANDOM, function next() { + var state = getInternalState(this); + var seed = state.seed = (state.seed * 1103515245 + 12345) % 2147483647; + return createIterResultObject((seed & 1073741823) / 1073741823, false); + }); + + // `Math.seededPRNG` method + // https://github.com/tc39/proposal-seeded-random + // based on https://github.com/tc39/proposal-seeded-random/blob/78b8258835b57fc2100d076151ab506bc3202ae6/demo.html + $({ target: 'Math', stat: true, forced: true }, { + seededPRNG: function seededPRNG(it) { + var seed = anObject(it).seed; + if (!numberIsFinite(seed)) throw new $TypeError(SEED_TYPE_ERROR); + return new $SeededRandomGenerator(seed); + } + }); + return esnext_math_seededPrng; +} + +var esnext_math_signbit = {}; + +var hasRequiredEsnext_math_signbit; + +function requireEsnext_math_signbit () { + if (hasRequiredEsnext_math_signbit) return esnext_math_signbit; + hasRequiredEsnext_math_signbit = 1; + var $ = require_export(); + + // `Math.signbit` method + // https://github.com/tc39/proposal-Math.signbit + $({ target: 'Math', stat: true, forced: true }, { + signbit: function signbit(x) { + var n = +x; + // eslint-disable-next-line no-self-compare -- NaN check + return n === n && n === 0 ? 1 / n === -Infinity : n < 0; + } + }); + return esnext_math_signbit; +} + +var esnext_math_sumPrecise = {}; + +var hasRequiredEsnext_math_sumPrecise; + +function requireEsnext_math_sumPrecise () { + if (hasRequiredEsnext_math_sumPrecise) return esnext_math_sumPrecise; + hasRequiredEsnext_math_sumPrecise = 1; + // based on Shewchuk's algorithm for exactly floating point addition + // adapted from https://github.com/tc39/proposal-math-sum/blob/3513d58323a1ae25560e8700aa5294500c6c9287/polyfill/polyfill.mjs + var $ = require_export(); + var uncurryThis = requireFunctionUncurryThis(); + var iterate = requireIterate(); + + var $RangeError = RangeError; + var $TypeError = TypeError; + var $Infinity = Infinity; + var $NaN = NaN; + var abs = Math.abs; + var pow = Math.pow; + var push = uncurryThis([].push); + + var POW_2_1023 = pow(2, 1023); + var MAX_SAFE_INTEGER = pow(2, 53) - 1; // 2 ** 53 - 1 === 9007199254740992 + var MAX_DOUBLE = Number.MAX_VALUE; // 2 ** 1024 - 2 ** (1023 - 52) === 1.79769313486231570815e+308 + var MAX_ULP = pow(2, 971); // 2 ** (1023 - 52) === 1.99584030953471981166e+292 + + var NOT_A_NUMBER = {}; + var MINUS_INFINITY = {}; + var PLUS_INFINITY = {}; + var MINUS_ZERO = {}; + var FINITE = {}; + + // prerequisite: abs(x) >= abs(y) + var twosum = function (x, y) { + var hi = x + y; + var lo = y - (hi - x); + return { hi: hi, lo: lo }; + }; + + // `Math.sumPrecise` method + // https://github.com/tc39/proposal-math-sum + $({ target: 'Math', stat: true, forced: true }, { + // eslint-disable-next-line max-statements -- ok + sumPrecise: function sumPrecise(items) { + var numbers = []; + var count = 0; + var state = MINUS_ZERO; + + iterate(items, function (n) { + if (++count >= MAX_SAFE_INTEGER) throw new $RangeError('Maximum allowed index exceeded'); + if (typeof n != 'number') throw new $TypeError('Value is not a number'); + if (state !== NOT_A_NUMBER) { + // eslint-disable-next-line no-self-compare -- NaN check + if (n !== n) state = NOT_A_NUMBER; + else if (n === $Infinity) state = state === MINUS_INFINITY ? NOT_A_NUMBER : PLUS_INFINITY; + else if (n === -$Infinity) state = state === PLUS_INFINITY ? NOT_A_NUMBER : MINUS_INFINITY; + else if ((n !== 0 || (1 / n) === $Infinity) && (state === MINUS_ZERO || state === FINITE)) { + state = FINITE; + push(numbers, n); + } + } + }); + + switch (state) { + case NOT_A_NUMBER: return $NaN; + case MINUS_INFINITY: return -$Infinity; + case PLUS_INFINITY: return $Infinity; + case MINUS_ZERO: return -0; + } + + var partials = []; + var overflow = 0; // conceptually 2 ** 1024 times this value; the final partial is biased by this amount + var x, y, sum, hi, lo, tmp; + + for (var i = 0; i < numbers.length; i++) { + x = numbers[i]; + var actuallyUsedPartials = 0; + for (var j = 0; j < partials.length; j++) { + y = partials[j]; + if (abs(x) < abs(y)) { + tmp = x; + x = y; + y = tmp; + } + sum = twosum(x, y); + hi = sum.hi; + lo = sum.lo; + if (abs(hi) === $Infinity) { + var sign = hi === $Infinity ? 1 : -1; + overflow += sign; + + x = (x - (sign * POW_2_1023)) - (sign * POW_2_1023); + if (abs(x) < abs(y)) { + tmp = x; + x = y; + y = tmp; + } + sum = twosum(x, y); + hi = sum.hi; + lo = sum.lo; + } + if (lo !== 0) partials[actuallyUsedPartials++] = lo; + x = hi; + } + partials.length = actuallyUsedPartials; + if (x !== 0) push(partials, x); + } + + // compute the exact sum of partials, stopping once we lose precision + var n = partials.length - 1; + hi = 0; + lo = 0; + + if (overflow !== 0) { + var next = n >= 0 ? partials[n] : 0; + n--; + if (abs(overflow) > 1 || (overflow > 0 && next > 0) || (overflow < 0 && next < 0)) { + return overflow > 0 ? $Infinity : -$Infinity; + } + // here we actually have to do the arithmetic + // drop a factor of 2 so we can do it without overflow + // assert(abs(overflow) === 1) + sum = twosum(overflow * POW_2_1023, next / 2); + hi = sum.hi; + lo = sum.lo; + lo *= 2; + if (abs(2 * hi) === $Infinity) { + // rounding to the maximum value + if (hi > 0) { + return (hi === POW_2_1023 && lo === -(MAX_ULP / 2) && n >= 0 && partials[n] < 0) ? MAX_DOUBLE : $Infinity; + } return (hi === -POW_2_1023 && lo === (MAX_ULP / 2) && n >= 0 && partials[n] > 0) ? -MAX_DOUBLE : -$Infinity; + } + + if (lo !== 0) { + partials[++n] = lo; + lo = 0; + } + + hi *= 2; + } + + while (n >= 0) { + sum = twosum(hi, partials[n--]); + hi = sum.hi; + lo = sum.lo; + if (lo !== 0) break; + } + + if (n >= 0 && ((lo < 0 && partials[n] < 0) || (lo > 0 && partials[n] > 0))) { + y = lo * 2; + x = hi + y; + if (y === x - hi) hi = x; + } + + return hi; + } + }); + return esnext_math_sumPrecise; +} + +var esnext_math_umulh = {}; + +var hasRequiredEsnext_math_umulh; + +function requireEsnext_math_umulh () { + if (hasRequiredEsnext_math_umulh) return esnext_math_umulh; + hasRequiredEsnext_math_umulh = 1; + var $ = require_export(); + + // `Math.umulh` method + // https://gist.github.com/BrendanEich/4294d5c212a6d2254703 + // TODO: Remove from `core-js@4` + $({ target: 'Math', stat: true, forced: true }, { + umulh: function umulh(u, v) { + var UINT16 = 0xFFFF; + var $u = +u; + var $v = +v; + var u0 = $u & UINT16; + var v0 = $v & UINT16; + var u1 = $u >>> 16; + var v1 = $v >>> 16; + var t = (u1 * v0 >>> 0) + (u0 * v0 >>> 16); + return u1 * v1 + (t >>> 16) + ((u0 * v1 >>> 0) + (t & UINT16) >>> 16); + } + }); + return esnext_math_umulh; +} + +var esnext_number_fromString = {}; + +var hasRequiredEsnext_number_fromString; + +function requireEsnext_number_fromString () { + if (hasRequiredEsnext_number_fromString) return esnext_number_fromString; + hasRequiredEsnext_number_fromString = 1; + var $ = require_export(); + var uncurryThis = requireFunctionUncurryThis(); + var toIntegerOrInfinity = requireToIntegerOrInfinity(); + + var INVALID_NUMBER_REPRESENTATION = 'Invalid number representation'; + var INVALID_RADIX = 'Invalid radix'; + var $RangeError = RangeError; + var $SyntaxError = SyntaxError; + var $TypeError = TypeError; + var $parseInt = parseInt; + var pow = Math.pow; + var valid = /^[\d.a-z]+$/; + var charAt = uncurryThis(''.charAt); + var exec = uncurryThis(valid.exec); + var numberToString = uncurryThis(1.0.toString); + var stringSlice = uncurryThis(''.slice); + var split = uncurryThis(''.split); + + // `Number.fromString` method + // https://github.com/tc39/proposal-number-fromstring + $({ target: 'Number', stat: true, forced: true }, { + fromString: function fromString(string, radix) { + var sign = 1; + if (typeof string != 'string') throw new $TypeError(INVALID_NUMBER_REPRESENTATION); + if (!string.length) throw new $SyntaxError(INVALID_NUMBER_REPRESENTATION); + if (charAt(string, 0) === '-') { + sign = -1; + string = stringSlice(string, 1); + if (!string.length) throw new $SyntaxError(INVALID_NUMBER_REPRESENTATION); + } + var R = radix === undefined ? 10 : toIntegerOrInfinity(radix); + if (R < 2 || R > 36) throw new $RangeError(INVALID_RADIX); + if (!exec(valid, string)) throw new $SyntaxError(INVALID_NUMBER_REPRESENTATION); + var parts = split(string, '.'); + var mathNum = $parseInt(parts[0], R); + if (parts.length > 1) mathNum += $parseInt(parts[1], R) / pow(R, parts[1].length); + if (R === 10 && numberToString(mathNum, R) !== string) throw new $SyntaxError(INVALID_NUMBER_REPRESENTATION); + return sign * mathNum; + } + }); + return esnext_number_fromString; +} + +var esnext_number_range = {}; + +var hasRequiredEsnext_number_range; + +function requireEsnext_number_range () { + if (hasRequiredEsnext_number_range) return esnext_number_range; + hasRequiredEsnext_number_range = 1; + var $ = require_export(); + var NumericRangeIterator = requireNumericRangeIterator(); + + // `Number.range` method + // https://github.com/tc39/proposal-Number.range + // TODO: Remove from `core-js@4` + $({ target: 'Number', stat: true, forced: true }, { + range: function range(start, end, option) { + return new NumericRangeIterator(start, end, option, 'number', 0, 1); + } + }); + return esnext_number_range; +} + +var esnext_object_hasOwn = {}; + +var hasRequiredEsnext_object_hasOwn; + +function requireEsnext_object_hasOwn () { + if (hasRequiredEsnext_object_hasOwn) return esnext_object_hasOwn; + hasRequiredEsnext_object_hasOwn = 1; + // TODO: Remove from `core-js@4` + requireEs_object_hasOwn(); + return esnext_object_hasOwn; +} + +var esnext_object_iterateEntries = {}; + +var objectIterator; +var hasRequiredObjectIterator; + +function requireObjectIterator () { + if (hasRequiredObjectIterator) return objectIterator; + hasRequiredObjectIterator = 1; + var InternalStateModule = requireInternalState(); + var createIteratorConstructor = requireIteratorCreateConstructor(); + var createIterResultObject = requireCreateIterResultObject(); + var hasOwn = requireHasOwnProperty(); + var objectKeys = requireObjectKeys(); + var toObject = requireToObject(); + + var OBJECT_ITERATOR = 'Object Iterator'; + var setInternalState = InternalStateModule.set; + var getInternalState = InternalStateModule.getterFor(OBJECT_ITERATOR); + + objectIterator = createIteratorConstructor(function ObjectIterator(source, mode) { + var object = toObject(source); + setInternalState(this, { + type: OBJECT_ITERATOR, + mode: mode, + object: object, + keys: objectKeys(object), + index: 0 + }); + }, 'Object', function next() { + var state = getInternalState(this); + var keys = state.keys; + while (true) { + if (keys === null || state.index >= keys.length) { + state.object = state.keys = null; + return createIterResultObject(undefined, true); + } + var key = keys[state.index++]; + var object = state.object; + if (!hasOwn(object, key)) continue; + switch (state.mode) { + case 'keys': return createIterResultObject(key, false); + case 'values': return createIterResultObject(object[key], false); + } /* entries */ return createIterResultObject([key, object[key]], false); + } + }); + return objectIterator; +} + +var hasRequiredEsnext_object_iterateEntries; + +function requireEsnext_object_iterateEntries () { + if (hasRequiredEsnext_object_iterateEntries) return esnext_object_iterateEntries; + hasRequiredEsnext_object_iterateEntries = 1; + // TODO: Remove from `core-js@4` + var $ = require_export(); + var ObjectIterator = requireObjectIterator(); + + // `Object.iterateEntries` method + // https://github.com/tc39/proposal-object-iteration + $({ target: 'Object', stat: true, forced: true }, { + iterateEntries: function iterateEntries(object) { + return new ObjectIterator(object, 'entries'); + } + }); + return esnext_object_iterateEntries; +} + +var esnext_object_iterateKeys = {}; + +var hasRequiredEsnext_object_iterateKeys; + +function requireEsnext_object_iterateKeys () { + if (hasRequiredEsnext_object_iterateKeys) return esnext_object_iterateKeys; + hasRequiredEsnext_object_iterateKeys = 1; + // TODO: Remove from `core-js@4` + var $ = require_export(); + var ObjectIterator = requireObjectIterator(); + + // `Object.iterateKeys` method + // https://github.com/tc39/proposal-object-iteration + $({ target: 'Object', stat: true, forced: true }, { + iterateKeys: function iterateKeys(object) { + return new ObjectIterator(object, 'keys'); + } + }); + return esnext_object_iterateKeys; +} + +var esnext_object_iterateValues = {}; + +var hasRequiredEsnext_object_iterateValues; + +function requireEsnext_object_iterateValues () { + if (hasRequiredEsnext_object_iterateValues) return esnext_object_iterateValues; + hasRequiredEsnext_object_iterateValues = 1; + // TODO: Remove from `core-js@4` + var $ = require_export(); + var ObjectIterator = requireObjectIterator(); + + // `Object.iterateValues` method + // https://github.com/tc39/proposal-object-iteration + $({ target: 'Object', stat: true, forced: true }, { + iterateValues: function iterateValues(object) { + return new ObjectIterator(object, 'values'); + } + }); + return esnext_object_iterateValues; +} + +var esnext_object_groupBy = {}; + +var hasRequiredEsnext_object_groupBy; + +function requireEsnext_object_groupBy () { + if (hasRequiredEsnext_object_groupBy) return esnext_object_groupBy; + hasRequiredEsnext_object_groupBy = 1; + // TODO: Remove from `core-js@4` + requireEs_object_groupBy(); + return esnext_object_groupBy; +} + +var esnext_observable = {}; + +var esnext_observable_constructor = {}; + +var hasRequiredEsnext_observable_constructor; + +function requireEsnext_observable_constructor () { + if (hasRequiredEsnext_observable_constructor) return esnext_observable_constructor; + hasRequiredEsnext_observable_constructor = 1; + // https://github.com/tc39/proposal-observable + var $ = require_export(); + var call = requireFunctionCall(); + var DESCRIPTORS = requireDescriptors(); + var setSpecies = requireSetSpecies(); + var aCallable = requireACallable(); + var anObject = requireAnObject(); + var anInstance = requireAnInstance(); + var isCallable = requireIsCallable(); + var isNullOrUndefined = requireIsNullOrUndefined(); + var isObject = requireIsObject(); + var getMethod = requireGetMethod(); + var defineBuiltIn = requireDefineBuiltIn(); + var defineBuiltIns = requireDefineBuiltIns(); + var defineBuiltInAccessor = requireDefineBuiltInAccessor(); + var hostReportErrors = requireHostReportErrors(); + var wellKnownSymbol = requireWellKnownSymbol(); + var InternalStateModule = requireInternalState(); + + var $$OBSERVABLE = wellKnownSymbol('observable'); + var OBSERVABLE = 'Observable'; + var SUBSCRIPTION = 'Subscription'; + var SUBSCRIPTION_OBSERVER = 'SubscriptionObserver'; + var getterFor = InternalStateModule.getterFor; + var setInternalState = InternalStateModule.set; + var getObservableInternalState = getterFor(OBSERVABLE); + var getSubscriptionInternalState = getterFor(SUBSCRIPTION); + var getSubscriptionObserverInternalState = getterFor(SUBSCRIPTION_OBSERVER); + + var SubscriptionState = function (observer) { + this.observer = anObject(observer); + this.cleanup = null; + this.subscriptionObserver = null; + }; + + SubscriptionState.prototype = { + type: SUBSCRIPTION, + clean: function () { + var cleanup = this.cleanup; + if (cleanup) { + this.cleanup = null; + try { + cleanup(); + } catch (error) { + hostReportErrors(error); + } + } + }, + close: function () { + if (!DESCRIPTORS) { + var subscription = this.facade; + var subscriptionObserver = this.subscriptionObserver; + subscription.closed = true; + if (subscriptionObserver) subscriptionObserver.closed = true; + } this.observer = null; + }, + isClosed: function () { + return this.observer === null; + } + }; + + var Subscription = function (observer, subscriber) { + var subscriptionState = setInternalState(this, new SubscriptionState(observer)); + var start; + if (!DESCRIPTORS) this.closed = false; + try { + if (start = getMethod(observer, 'start')) call(start, observer, this); + } catch (error) { + hostReportErrors(error); + } + if (subscriptionState.isClosed()) return; + var subscriptionObserver = subscriptionState.subscriptionObserver = new SubscriptionObserver(subscriptionState); + try { + var cleanup = subscriber(subscriptionObserver); + var subscription = cleanup; + if (!isNullOrUndefined(cleanup)) subscriptionState.cleanup = isCallable(cleanup.unsubscribe) + ? function () { subscription.unsubscribe(); } + : aCallable(cleanup); + } catch (error) { + subscriptionObserver.error(error); + return; + } if (subscriptionState.isClosed()) subscriptionState.clean(); + }; + + Subscription.prototype = defineBuiltIns({}, { + unsubscribe: function unsubscribe() { + var subscriptionState = getSubscriptionInternalState(this); + if (!subscriptionState.isClosed()) { + subscriptionState.close(); + subscriptionState.clean(); + } + } + }); + + if (DESCRIPTORS) defineBuiltInAccessor(Subscription.prototype, 'closed', { + configurable: true, + get: function closed() { + return getSubscriptionInternalState(this).isClosed(); + } + }); + + var SubscriptionObserver = function (subscriptionState) { + setInternalState(this, { + type: SUBSCRIPTION_OBSERVER, + subscriptionState: subscriptionState + }); + if (!DESCRIPTORS) this.closed = false; + }; + + SubscriptionObserver.prototype = defineBuiltIns({}, { + next: function next(value) { + var subscriptionState = getSubscriptionObserverInternalState(this).subscriptionState; + if (!subscriptionState.isClosed()) { + var observer = subscriptionState.observer; + try { + var nextMethod = getMethod(observer, 'next'); + if (nextMethod) call(nextMethod, observer, value); + } catch (error) { + hostReportErrors(error); + } + } + }, + error: function error(value) { + var subscriptionState = getSubscriptionObserverInternalState(this).subscriptionState; + if (!subscriptionState.isClosed()) { + var observer = subscriptionState.observer; + subscriptionState.close(); + try { + var errorMethod = getMethod(observer, 'error'); + if (errorMethod) call(errorMethod, observer, value); + else hostReportErrors(value); + } catch (err) { + hostReportErrors(err); + } subscriptionState.clean(); + } + }, + complete: function complete() { + var subscriptionState = getSubscriptionObserverInternalState(this).subscriptionState; + if (!subscriptionState.isClosed()) { + var observer = subscriptionState.observer; + subscriptionState.close(); + try { + var completeMethod = getMethod(observer, 'complete'); + if (completeMethod) call(completeMethod, observer); + } catch (error) { + hostReportErrors(error); + } subscriptionState.clean(); + } + } + }); + + if (DESCRIPTORS) defineBuiltInAccessor(SubscriptionObserver.prototype, 'closed', { + configurable: true, + get: function closed() { + return getSubscriptionObserverInternalState(this).subscriptionState.isClosed(); + } + }); + + var $Observable = function Observable(subscriber) { + anInstance(this, ObservablePrototype); + setInternalState(this, { + type: OBSERVABLE, + subscriber: aCallable(subscriber) + }); + }; + + var ObservablePrototype = $Observable.prototype; + + defineBuiltIns(ObservablePrototype, { + subscribe: function subscribe(observer) { + var length = arguments.length; + return new Subscription(isCallable(observer) ? { + next: observer, + error: length > 1 ? arguments[1] : undefined, + complete: length > 2 ? arguments[2] : undefined + } : isObject(observer) ? observer : {}, getObservableInternalState(this).subscriber); + } + }); + + defineBuiltIn(ObservablePrototype, $$OBSERVABLE, function () { return this; }); + + $({ global: true, constructor: true, forced: true }, { + Observable: $Observable + }); + + setSpecies(OBSERVABLE); + return esnext_observable_constructor; +} + +var esnext_observable_from = {}; + +var hasRequiredEsnext_observable_from; + +function requireEsnext_observable_from () { + if (hasRequiredEsnext_observable_from) return esnext_observable_from; + hasRequiredEsnext_observable_from = 1; + var $ = require_export(); + var getBuiltIn = requireGetBuiltIn(); + var call = requireFunctionCall(); + var anObject = requireAnObject(); + var isConstructor = requireIsConstructor(); + var getIterator = requireGetIterator(); + var getMethod = requireGetMethod(); + var iterate = requireIterate(); + var wellKnownSymbol = requireWellKnownSymbol(); + + var $$OBSERVABLE = wellKnownSymbol('observable'); + + // `Observable.from` method + // https://github.com/tc39/proposal-observable + $({ target: 'Observable', stat: true, forced: true }, { + from: function from(x) { + var C = isConstructor(this) ? this : getBuiltIn('Observable'); + var observableMethod = getMethod(anObject(x), $$OBSERVABLE); + if (observableMethod) { + var observable = anObject(call(observableMethod, x)); + return observable.constructor === C ? observable : new C(function (observer) { + return observable.subscribe(observer); + }); + } + var iterator = getIterator(x); + return new C(function (observer) { + iterate(iterator, function (it, stop) { + observer.next(it); + if (observer.closed) return stop(); + }, { IS_ITERATOR: true, INTERRUPTED: true }); + observer.complete(); + }); + } + }); + return esnext_observable_from; +} + +var esnext_observable_of = {}; + +var hasRequiredEsnext_observable_of; + +function requireEsnext_observable_of () { + if (hasRequiredEsnext_observable_of) return esnext_observable_of; + hasRequiredEsnext_observable_of = 1; + var $ = require_export(); + var getBuiltIn = requireGetBuiltIn(); + var isConstructor = requireIsConstructor(); + + var Array = getBuiltIn('Array'); + + // `Observable.of` method + // https://github.com/tc39/proposal-observable + $({ target: 'Observable', stat: true, forced: true }, { + of: function of() { + var C = isConstructor(this) ? this : getBuiltIn('Observable'); + var length = arguments.length; + var items = Array(length); + var index = 0; + while (index < length) items[index] = arguments[index++]; + return new C(function (observer) { + for (var i = 0; i < length; i++) { + observer.next(items[i]); + if (observer.closed) return; + } observer.complete(); + }); + } + }); + return esnext_observable_of; +} + +var hasRequiredEsnext_observable; + +function requireEsnext_observable () { + if (hasRequiredEsnext_observable) return esnext_observable; + hasRequiredEsnext_observable = 1; + // TODO: Remove this module from `core-js@4` since it's split to modules listed below + requireEsnext_observable_constructor(); + requireEsnext_observable_from(); + requireEsnext_observable_of(); + return esnext_observable; +} + +var esnext_promise_allSettled = {}; + +var hasRequiredEsnext_promise_allSettled; + +function requireEsnext_promise_allSettled () { + if (hasRequiredEsnext_promise_allSettled) return esnext_promise_allSettled; + hasRequiredEsnext_promise_allSettled = 1; + // TODO: Remove from `core-js@4` + requireEs_promise_allSettled(); + return esnext_promise_allSettled; +} + +var esnext_promise_any = {}; + +var hasRequiredEsnext_promise_any; + +function requireEsnext_promise_any () { + if (hasRequiredEsnext_promise_any) return esnext_promise_any; + hasRequiredEsnext_promise_any = 1; + // TODO: Remove from `core-js@4` + requireEs_promise_any(); + return esnext_promise_any; +} + +var esnext_promise_try = {}; + +var hasRequiredEsnext_promise_try; + +function requireEsnext_promise_try () { + if (hasRequiredEsnext_promise_try) return esnext_promise_try; + hasRequiredEsnext_promise_try = 1; + var $ = require_export(); + var globalThis = requireGlobalThis(); + var apply = requireFunctionApply(); + var slice = requireArraySlice(); + var newPromiseCapabilityModule = requireNewPromiseCapability(); + var aCallable = requireACallable(); + var perform = requirePerform(); + + var Promise = globalThis.Promise; + + var ACCEPT_ARGUMENTS = false; + // Avoiding the use of polyfills of the previous iteration of this proposal + // that does not accept arguments of the callback + var FORCED = !Promise || !Promise['try'] || perform(function () { + Promise['try'](function (argument) { + ACCEPT_ARGUMENTS = argument === 8; + }, 8); + }).error || !ACCEPT_ARGUMENTS; + + // `Promise.try` method + // https://github.com/tc39/proposal-promise-try + $({ target: 'Promise', stat: true, forced: FORCED }, { + 'try': function (callbackfn /* , ...args */) { + var args = arguments.length > 1 ? slice(arguments, 1) : []; + var promiseCapability = newPromiseCapabilityModule.f(this); + var result = perform(function () { + return apply(aCallable(callbackfn), undefined, args); + }); + (result.error ? promiseCapability.reject : promiseCapability.resolve)(result.value); + return promiseCapability.promise; + } + }); + return esnext_promise_try; +} + +var esnext_promise_withResolvers = {}; + +var hasRequiredEsnext_promise_withResolvers; + +function requireEsnext_promise_withResolvers () { + if (hasRequiredEsnext_promise_withResolvers) return esnext_promise_withResolvers; + hasRequiredEsnext_promise_withResolvers = 1; + // TODO: Remove from `core-js@4` + requireEs_promise_withResolvers(); + return esnext_promise_withResolvers; +} + +var esnext_reflect_defineMetadata = {}; + +var reflectMetadata; +var hasRequiredReflectMetadata; + +function requireReflectMetadata () { + if (hasRequiredReflectMetadata) return reflectMetadata; + hasRequiredReflectMetadata = 1; + // TODO: in core-js@4, move /modules/ dependencies to public entries for better optimization by tools like `preset-env` + requireEs_map(); + requireEs_weakMap(); + var getBuiltIn = requireGetBuiltIn(); + var uncurryThis = requireFunctionUncurryThis(); + var shared = requireShared(); + + var Map = getBuiltIn('Map'); + var WeakMap = getBuiltIn('WeakMap'); + var push = uncurryThis([].push); + + var metadata = shared('metadata'); + var store = metadata.store || (metadata.store = new WeakMap()); + + var getOrCreateMetadataMap = function (target, targetKey, create) { + var targetMetadata = store.get(target); + if (!targetMetadata) { + if (!create) return; + store.set(target, targetMetadata = new Map()); + } + var keyMetadata = targetMetadata.get(targetKey); + if (!keyMetadata) { + if (!create) return; + targetMetadata.set(targetKey, keyMetadata = new Map()); + } return keyMetadata; + }; + + var ordinaryHasOwnMetadata = function (MetadataKey, O, P) { + var metadataMap = getOrCreateMetadataMap(O, P, false); + return metadataMap === undefined ? false : metadataMap.has(MetadataKey); + }; + + var ordinaryGetOwnMetadata = function (MetadataKey, O, P) { + var metadataMap = getOrCreateMetadataMap(O, P, false); + return metadataMap === undefined ? undefined : metadataMap.get(MetadataKey); + }; + + var ordinaryDefineOwnMetadata = function (MetadataKey, MetadataValue, O, P) { + getOrCreateMetadataMap(O, P, true).set(MetadataKey, MetadataValue); + }; + + var ordinaryOwnMetadataKeys = function (target, targetKey) { + var metadataMap = getOrCreateMetadataMap(target, targetKey, false); + var keys = []; + if (metadataMap) metadataMap.forEach(function (_, key) { push(keys, key); }); + return keys; + }; + + var toMetadataKey = function (it) { + return it === undefined || typeof it == 'symbol' ? it : String(it); + }; + + reflectMetadata = { + store: store, + getMap: getOrCreateMetadataMap, + has: ordinaryHasOwnMetadata, + get: ordinaryGetOwnMetadata, + set: ordinaryDefineOwnMetadata, + keys: ordinaryOwnMetadataKeys, + toKey: toMetadataKey + }; + return reflectMetadata; +} + +var hasRequiredEsnext_reflect_defineMetadata; + +function requireEsnext_reflect_defineMetadata () { + if (hasRequiredEsnext_reflect_defineMetadata) return esnext_reflect_defineMetadata; + hasRequiredEsnext_reflect_defineMetadata = 1; + // TODO: Remove from `core-js@4` + var $ = require_export(); + var ReflectMetadataModule = requireReflectMetadata(); + var anObject = requireAnObject(); + + var toMetadataKey = ReflectMetadataModule.toKey; + var ordinaryDefineOwnMetadata = ReflectMetadataModule.set; + + // `Reflect.defineMetadata` method + // https://github.com/rbuckton/reflect-metadata + $({ target: 'Reflect', stat: true }, { + defineMetadata: function defineMetadata(metadataKey, metadataValue, target /* , targetKey */) { + var targetKey = arguments.length < 4 ? undefined : toMetadataKey(arguments[3]); + ordinaryDefineOwnMetadata(metadataKey, metadataValue, anObject(target), targetKey); + } + }); + return esnext_reflect_defineMetadata; +} + +var esnext_reflect_deleteMetadata = {}; + +var hasRequiredEsnext_reflect_deleteMetadata; + +function requireEsnext_reflect_deleteMetadata () { + if (hasRequiredEsnext_reflect_deleteMetadata) return esnext_reflect_deleteMetadata; + hasRequiredEsnext_reflect_deleteMetadata = 1; + var $ = require_export(); + var ReflectMetadataModule = requireReflectMetadata(); + var anObject = requireAnObject(); + + var toMetadataKey = ReflectMetadataModule.toKey; + var getOrCreateMetadataMap = ReflectMetadataModule.getMap; + var store = ReflectMetadataModule.store; + + // `Reflect.deleteMetadata` method + // https://github.com/rbuckton/reflect-metadata + $({ target: 'Reflect', stat: true }, { + deleteMetadata: function deleteMetadata(metadataKey, target /* , targetKey */) { + var targetKey = arguments.length < 3 ? undefined : toMetadataKey(arguments[2]); + var metadataMap = getOrCreateMetadataMap(anObject(target), targetKey, false); + if (metadataMap === undefined || !metadataMap['delete'](metadataKey)) return false; + if (metadataMap.size) return true; + var targetMetadata = store.get(target); + targetMetadata['delete'](targetKey); + return !!targetMetadata.size || store['delete'](target); + } + }); + return esnext_reflect_deleteMetadata; +} + +var esnext_reflect_getMetadata = {}; + +var hasRequiredEsnext_reflect_getMetadata; + +function requireEsnext_reflect_getMetadata () { + if (hasRequiredEsnext_reflect_getMetadata) return esnext_reflect_getMetadata; + hasRequiredEsnext_reflect_getMetadata = 1; + // TODO: Remove from `core-js@4` + var $ = require_export(); + var ReflectMetadataModule = requireReflectMetadata(); + var anObject = requireAnObject(); + var getPrototypeOf = requireObjectGetPrototypeOf(); + + var ordinaryHasOwnMetadata = ReflectMetadataModule.has; + var ordinaryGetOwnMetadata = ReflectMetadataModule.get; + var toMetadataKey = ReflectMetadataModule.toKey; + + var ordinaryGetMetadata = function (MetadataKey, O, P) { + var hasOwn = ordinaryHasOwnMetadata(MetadataKey, O, P); + if (hasOwn) return ordinaryGetOwnMetadata(MetadataKey, O, P); + var parent = getPrototypeOf(O); + return parent !== null ? ordinaryGetMetadata(MetadataKey, parent, P) : undefined; + }; + + // `Reflect.getMetadata` method + // https://github.com/rbuckton/reflect-metadata + $({ target: 'Reflect', stat: true }, { + getMetadata: function getMetadata(metadataKey, target /* , targetKey */) { + var targetKey = arguments.length < 3 ? undefined : toMetadataKey(arguments[2]); + return ordinaryGetMetadata(metadataKey, anObject(target), targetKey); + } + }); + return esnext_reflect_getMetadata; +} + +var esnext_reflect_getMetadataKeys = {}; + +var hasRequiredEsnext_reflect_getMetadataKeys; + +function requireEsnext_reflect_getMetadataKeys () { + if (hasRequiredEsnext_reflect_getMetadataKeys) return esnext_reflect_getMetadataKeys; + hasRequiredEsnext_reflect_getMetadataKeys = 1; + // TODO: Remove from `core-js@4` + var $ = require_export(); + var uncurryThis = requireFunctionUncurryThis(); + var ReflectMetadataModule = requireReflectMetadata(); + var anObject = requireAnObject(); + var getPrototypeOf = requireObjectGetPrototypeOf(); + var $arrayUniqueBy = requireArrayUniqueBy(); + + var arrayUniqueBy = uncurryThis($arrayUniqueBy); + var concat = uncurryThis([].concat); + var ordinaryOwnMetadataKeys = ReflectMetadataModule.keys; + var toMetadataKey = ReflectMetadataModule.toKey; + + var ordinaryMetadataKeys = function (O, P) { + var oKeys = ordinaryOwnMetadataKeys(O, P); + var parent = getPrototypeOf(O); + if (parent === null) return oKeys; + var pKeys = ordinaryMetadataKeys(parent, P); + return pKeys.length ? oKeys.length ? arrayUniqueBy(concat(oKeys, pKeys)) : pKeys : oKeys; + }; + + // `Reflect.getMetadataKeys` method + // https://github.com/rbuckton/reflect-metadata + $({ target: 'Reflect', stat: true }, { + getMetadataKeys: function getMetadataKeys(target /* , targetKey */) { + var targetKey = arguments.length < 2 ? undefined : toMetadataKey(arguments[1]); + return ordinaryMetadataKeys(anObject(target), targetKey); + } + }); + return esnext_reflect_getMetadataKeys; +} + +var esnext_reflect_getOwnMetadata = {}; + +var hasRequiredEsnext_reflect_getOwnMetadata; + +function requireEsnext_reflect_getOwnMetadata () { + if (hasRequiredEsnext_reflect_getOwnMetadata) return esnext_reflect_getOwnMetadata; + hasRequiredEsnext_reflect_getOwnMetadata = 1; + // TODO: Remove from `core-js@4` + var $ = require_export(); + var ReflectMetadataModule = requireReflectMetadata(); + var anObject = requireAnObject(); + + var ordinaryGetOwnMetadata = ReflectMetadataModule.get; + var toMetadataKey = ReflectMetadataModule.toKey; + + // `Reflect.getOwnMetadata` method + // https://github.com/rbuckton/reflect-metadata + $({ target: 'Reflect', stat: true }, { + getOwnMetadata: function getOwnMetadata(metadataKey, target /* , targetKey */) { + var targetKey = arguments.length < 3 ? undefined : toMetadataKey(arguments[2]); + return ordinaryGetOwnMetadata(metadataKey, anObject(target), targetKey); + } + }); + return esnext_reflect_getOwnMetadata; +} + +var esnext_reflect_getOwnMetadataKeys = {}; + +var hasRequiredEsnext_reflect_getOwnMetadataKeys; + +function requireEsnext_reflect_getOwnMetadataKeys () { + if (hasRequiredEsnext_reflect_getOwnMetadataKeys) return esnext_reflect_getOwnMetadataKeys; + hasRequiredEsnext_reflect_getOwnMetadataKeys = 1; + // TODO: Remove from `core-js@4` + var $ = require_export(); + var ReflectMetadataModule = requireReflectMetadata(); + var anObject = requireAnObject(); + + var ordinaryOwnMetadataKeys = ReflectMetadataModule.keys; + var toMetadataKey = ReflectMetadataModule.toKey; + + // `Reflect.getOwnMetadataKeys` method + // https://github.com/rbuckton/reflect-metadata + $({ target: 'Reflect', stat: true }, { + getOwnMetadataKeys: function getOwnMetadataKeys(target /* , targetKey */) { + var targetKey = arguments.length < 2 ? undefined : toMetadataKey(arguments[1]); + return ordinaryOwnMetadataKeys(anObject(target), targetKey); + } + }); + return esnext_reflect_getOwnMetadataKeys; +} + +var esnext_reflect_hasMetadata = {}; + +var hasRequiredEsnext_reflect_hasMetadata; + +function requireEsnext_reflect_hasMetadata () { + if (hasRequiredEsnext_reflect_hasMetadata) return esnext_reflect_hasMetadata; + hasRequiredEsnext_reflect_hasMetadata = 1; + // TODO: Remove from `core-js@4` + var $ = require_export(); + var ReflectMetadataModule = requireReflectMetadata(); + var anObject = requireAnObject(); + var getPrototypeOf = requireObjectGetPrototypeOf(); + + var ordinaryHasOwnMetadata = ReflectMetadataModule.has; + var toMetadataKey = ReflectMetadataModule.toKey; + + var ordinaryHasMetadata = function (MetadataKey, O, P) { + var hasOwn = ordinaryHasOwnMetadata(MetadataKey, O, P); + if (hasOwn) return true; + var parent = getPrototypeOf(O); + return parent !== null ? ordinaryHasMetadata(MetadataKey, parent, P) : false; + }; + + // `Reflect.hasMetadata` method + // https://github.com/rbuckton/reflect-metadata + $({ target: 'Reflect', stat: true }, { + hasMetadata: function hasMetadata(metadataKey, target /* , targetKey */) { + var targetKey = arguments.length < 3 ? undefined : toMetadataKey(arguments[2]); + return ordinaryHasMetadata(metadataKey, anObject(target), targetKey); + } + }); + return esnext_reflect_hasMetadata; +} + +var esnext_reflect_hasOwnMetadata = {}; + +var hasRequiredEsnext_reflect_hasOwnMetadata; + +function requireEsnext_reflect_hasOwnMetadata () { + if (hasRequiredEsnext_reflect_hasOwnMetadata) return esnext_reflect_hasOwnMetadata; + hasRequiredEsnext_reflect_hasOwnMetadata = 1; + // TODO: Remove from `core-js@4` + var $ = require_export(); + var ReflectMetadataModule = requireReflectMetadata(); + var anObject = requireAnObject(); + + var ordinaryHasOwnMetadata = ReflectMetadataModule.has; + var toMetadataKey = ReflectMetadataModule.toKey; + + // `Reflect.hasOwnMetadata` method + // https://github.com/rbuckton/reflect-metadata + $({ target: 'Reflect', stat: true }, { + hasOwnMetadata: function hasOwnMetadata(metadataKey, target /* , targetKey */) { + var targetKey = arguments.length < 3 ? undefined : toMetadataKey(arguments[2]); + return ordinaryHasOwnMetadata(metadataKey, anObject(target), targetKey); + } + }); + return esnext_reflect_hasOwnMetadata; +} + +var esnext_reflect_metadata = {}; + +var hasRequiredEsnext_reflect_metadata; + +function requireEsnext_reflect_metadata () { + if (hasRequiredEsnext_reflect_metadata) return esnext_reflect_metadata; + hasRequiredEsnext_reflect_metadata = 1; + var $ = require_export(); + var ReflectMetadataModule = requireReflectMetadata(); + var anObject = requireAnObject(); + + var toMetadataKey = ReflectMetadataModule.toKey; + var ordinaryDefineOwnMetadata = ReflectMetadataModule.set; + + // `Reflect.metadata` method + // https://github.com/rbuckton/reflect-metadata + $({ target: 'Reflect', stat: true }, { + metadata: function metadata(metadataKey, metadataValue) { + return function decorator(target, key) { + ordinaryDefineOwnMetadata(metadataKey, metadataValue, anObject(target), toMetadataKey(key)); + }; + } + }); + return esnext_reflect_metadata; +} + +var esnext_regexp_escape = {}; + +var aString; +var hasRequiredAString; + +function requireAString () { + if (hasRequiredAString) return aString; + hasRequiredAString = 1; + var $TypeError = TypeError; + + aString = function (argument) { + if (typeof argument == 'string') return argument; + throw new $TypeError('Argument is not a string'); + }; + return aString; +} + +var hasRequiredEsnext_regexp_escape; + +function requireEsnext_regexp_escape () { + if (hasRequiredEsnext_regexp_escape) return esnext_regexp_escape; + hasRequiredEsnext_regexp_escape = 1; + var $ = require_export(); + var uncurryThis = requireFunctionUncurryThis(); + var aString = requireAString(); + var hasOwn = requireHasOwnProperty(); + var padStart = requireStringPad().start; + var WHITESPACES = requireWhitespaces(); + + var $Array = Array; + var $escape = RegExp.escape; + var charAt = uncurryThis(''.charAt); + var charCodeAt = uncurryThis(''.charCodeAt); + var numberToString = uncurryThis(1.1.toString); + var join = uncurryThis([].join); + var FIRST_DIGIT_OR_ASCII = /^[0-9a-z]/i; + var SYNTAX_SOLIDUS = /^[$()*+./?[\\\]^{|}]/; + var OTHER_PUNCTUATORS_AND_WHITESPACES = RegExp('^[!"#%&\',\\-:;<=>@`~' + WHITESPACES + ']'); + var exec = uncurryThis(FIRST_DIGIT_OR_ASCII.exec); + + var ControlEscape = { + '\u0009': 't', + '\u000A': 'n', + '\u000B': 'v', + '\u000C': 'f', + '\u000D': 'r' + }; + + var escapeChar = function (chr) { + var hex = numberToString(charCodeAt(chr, 0), 16); + return hex.length < 3 ? '\\x' + padStart(hex, 2, '0') : '\\u' + padStart(hex, 4, '0'); + }; + + // Avoiding the use of polyfills of the previous iteration of this proposal + var FORCED = !$escape || $escape('ab') !== '\\x61b'; + + // `RegExp.escape` method + // https://github.com/tc39/proposal-regex-escaping + $({ target: 'RegExp', stat: true, forced: FORCED }, { + escape: function escape(S) { + aString(S); + var length = S.length; + var result = $Array(length); + + for (var i = 0; i < length; i++) { + var chr = charAt(S, i); + if (i === 0 && exec(FIRST_DIGIT_OR_ASCII, chr)) { + result[i] = escapeChar(chr); + } else if (hasOwn(ControlEscape, chr)) { + result[i] = '\\' + ControlEscape[chr]; + } else if (exec(SYNTAX_SOLIDUS, chr)) { + result[i] = '\\' + chr; + } else if (exec(OTHER_PUNCTUATORS_AND_WHITESPACES, chr)) { + result[i] = escapeChar(chr); + } else { + var charCode = charCodeAt(chr, 0); + // single UTF-16 code unit + if ((charCode & 0xF800) !== 0xD800) result[i] = chr; + // unpaired surrogate + else if (charCode >= 0xDC00 || i + 1 >= length || (charCodeAt(S, i + 1) & 0xFC00) !== 0xDC00) result[i] = escapeChar(chr); + // surrogate pair + else { + result[i] = chr; + result[++i] = charAt(S, i); + } + } + } + + return join(result, ''); + } + }); + return esnext_regexp_escape; +} + +var esnext_set_addAll = {}; + +var hasRequiredEsnext_set_addAll; + +function requireEsnext_set_addAll () { + if (hasRequiredEsnext_set_addAll) return esnext_set_addAll; + hasRequiredEsnext_set_addAll = 1; + var $ = require_export(); + var aSet = requireASet(); + var add = requireSetHelpers().add; + + // `Set.prototype.addAll` method + // https://github.com/tc39/proposal-collection-methods + $({ target: 'Set', proto: true, real: true, forced: true }, { + addAll: function addAll(/* ...elements */) { + var set = aSet(this); + for (var k = 0, len = arguments.length; k < len; k++) { + add(set, arguments[k]); + } return set; + } + }); + return esnext_set_addAll; +} + +var esnext_set_deleteAll = {}; + +var hasRequiredEsnext_set_deleteAll; + +function requireEsnext_set_deleteAll () { + if (hasRequiredEsnext_set_deleteAll) return esnext_set_deleteAll; + hasRequiredEsnext_set_deleteAll = 1; + var $ = require_export(); + var aSet = requireASet(); + var remove = requireSetHelpers().remove; + + // `Set.prototype.deleteAll` method + // https://github.com/tc39/proposal-collection-methods + $({ target: 'Set', proto: true, real: true, forced: true }, { + deleteAll: function deleteAll(/* ...elements */) { + var collection = aSet(this); + var allDeleted = true; + var wasDeleted; + for (var k = 0, len = arguments.length; k < len; k++) { + wasDeleted = remove(collection, arguments[k]); + allDeleted = allDeleted && wasDeleted; + } return !!allDeleted; + } + }); + return esnext_set_deleteAll; +} + +var esnext_set_difference_v2 = {}; + +var hasRequiredEsnext_set_difference_v2; + +function requireEsnext_set_difference_v2 () { + if (hasRequiredEsnext_set_difference_v2) return esnext_set_difference_v2; + hasRequiredEsnext_set_difference_v2 = 1; + // TODO: Remove from `core-js@4` + requireEs_set_difference_v2(); + return esnext_set_difference_v2; +} + +var esnext_set_difference = {}; + +var isIterable; +var hasRequiredIsIterable; + +function requireIsIterable () { + if (hasRequiredIsIterable) return isIterable; + hasRequiredIsIterable = 1; + var classof = requireClassof(); + var hasOwn = requireHasOwnProperty(); + var isNullOrUndefined = requireIsNullOrUndefined(); + var wellKnownSymbol = requireWellKnownSymbol(); + var Iterators = requireIterators(); + + var ITERATOR = wellKnownSymbol('iterator'); + var $Object = Object; + + isIterable = function (it) { + if (isNullOrUndefined(it)) return false; + var O = $Object(it); + return O[ITERATOR] !== undefined + || '@@iterator' in O + || hasOwn(Iterators, classof(O)); + }; + return isIterable; +} + +var toSetLike; +var hasRequiredToSetLike; + +function requireToSetLike () { + if (hasRequiredToSetLike) return toSetLike; + hasRequiredToSetLike = 1; + var getBuiltIn = requireGetBuiltIn(); + var isCallable = requireIsCallable(); + var isIterable = requireIsIterable(); + var isObject = requireIsObject(); + + var Set = getBuiltIn('Set'); + + var isSetLike = function (it) { + return isObject(it) + && typeof it.size == 'number' + && isCallable(it.has) + && isCallable(it.keys); + }; + + // fallback old -> new set methods proposal arguments + toSetLike = function (it) { + if (isSetLike(it)) return it; + return isIterable(it) ? new Set(it) : it; + }; + return toSetLike; +} + +var hasRequiredEsnext_set_difference; + +function requireEsnext_set_difference () { + if (hasRequiredEsnext_set_difference) return esnext_set_difference; + hasRequiredEsnext_set_difference = 1; + var $ = require_export(); + var call = requireFunctionCall(); + var toSetLike = requireToSetLike(); + var $difference = requireSetDifference(); + + // `Set.prototype.difference` method + // https://github.com/tc39/proposal-set-methods + // TODO: Obsolete version, remove from `core-js@4` + $({ target: 'Set', proto: true, real: true, forced: true }, { + difference: function difference(other) { + return call($difference, this, toSetLike(other)); + } + }); + return esnext_set_difference; +} + +var esnext_set_every = {}; + +var hasRequiredEsnext_set_every; + +function requireEsnext_set_every () { + if (hasRequiredEsnext_set_every) return esnext_set_every; + hasRequiredEsnext_set_every = 1; + var $ = require_export(); + var bind = requireFunctionBindContext(); + var aSet = requireASet(); + var iterate = requireSetIterate(); + + // `Set.prototype.every` method + // https://github.com/tc39/proposal-collection-methods + $({ target: 'Set', proto: true, real: true, forced: true }, { + every: function every(callbackfn /* , thisArg */) { + var set = aSet(this); + var boundFunction = bind(callbackfn, arguments.length > 1 ? arguments[1] : undefined); + return iterate(set, function (value) { + if (!boundFunction(value, value, set)) return false; + }, true) !== false; + } + }); + return esnext_set_every; +} + +var esnext_set_filter = {}; + +var hasRequiredEsnext_set_filter; + +function requireEsnext_set_filter () { + if (hasRequiredEsnext_set_filter) return esnext_set_filter; + hasRequiredEsnext_set_filter = 1; + var $ = require_export(); + var bind = requireFunctionBindContext(); + var aSet = requireASet(); + var SetHelpers = requireSetHelpers(); + var iterate = requireSetIterate(); + + var Set = SetHelpers.Set; + var add = SetHelpers.add; + + // `Set.prototype.filter` method + // https://github.com/tc39/proposal-collection-methods + $({ target: 'Set', proto: true, real: true, forced: true }, { + filter: function filter(callbackfn /* , thisArg */) { + var set = aSet(this); + var boundFunction = bind(callbackfn, arguments.length > 1 ? arguments[1] : undefined); + var newSet = new Set(); + iterate(set, function (value) { + if (boundFunction(value, value, set)) add(newSet, value); + }); + return newSet; + } + }); + return esnext_set_filter; +} + +var esnext_set_find = {}; + +var hasRequiredEsnext_set_find; + +function requireEsnext_set_find () { + if (hasRequiredEsnext_set_find) return esnext_set_find; + hasRequiredEsnext_set_find = 1; + var $ = require_export(); + var bind = requireFunctionBindContext(); + var aSet = requireASet(); + var iterate = requireSetIterate(); + + // `Set.prototype.find` method + // https://github.com/tc39/proposal-collection-methods + $({ target: 'Set', proto: true, real: true, forced: true }, { + find: function find(callbackfn /* , thisArg */) { + var set = aSet(this); + var boundFunction = bind(callbackfn, arguments.length > 1 ? arguments[1] : undefined); + var result = iterate(set, function (value) { + if (boundFunction(value, value, set)) return { value: value }; + }, true); + return result && result.value; + } + }); + return esnext_set_find; +} + +var esnext_set_from = {}; + +var hasRequiredEsnext_set_from; + +function requireEsnext_set_from () { + if (hasRequiredEsnext_set_from) return esnext_set_from; + hasRequiredEsnext_set_from = 1; + var $ = require_export(); + var SetHelpers = requireSetHelpers(); + var createCollectionFrom = requireCollectionFrom(); + + // `Set.from` method + // https://tc39.github.io/proposal-setmap-offrom/#sec-set.from + $({ target: 'Set', stat: true, forced: true }, { + from: createCollectionFrom(SetHelpers.Set, SetHelpers.add, false) + }); + return esnext_set_from; +} + +var esnext_set_intersection_v2 = {}; + +var hasRequiredEsnext_set_intersection_v2; + +function requireEsnext_set_intersection_v2 () { + if (hasRequiredEsnext_set_intersection_v2) return esnext_set_intersection_v2; + hasRequiredEsnext_set_intersection_v2 = 1; + // TODO: Remove from `core-js@4` + requireEs_set_intersection_v2(); + return esnext_set_intersection_v2; +} + +var esnext_set_intersection = {}; + +var hasRequiredEsnext_set_intersection; + +function requireEsnext_set_intersection () { + if (hasRequiredEsnext_set_intersection) return esnext_set_intersection; + hasRequiredEsnext_set_intersection = 1; + var $ = require_export(); + var call = requireFunctionCall(); + var toSetLike = requireToSetLike(); + var $intersection = requireSetIntersection(); + + // `Set.prototype.intersection` method + // https://github.com/tc39/proposal-set-methods + // TODO: Obsolete version, remove from `core-js@4` + $({ target: 'Set', proto: true, real: true, forced: true }, { + intersection: function intersection(other) { + return call($intersection, this, toSetLike(other)); + } + }); + return esnext_set_intersection; +} + +var esnext_set_isDisjointFrom_v2 = {}; + +var hasRequiredEsnext_set_isDisjointFrom_v2; + +function requireEsnext_set_isDisjointFrom_v2 () { + if (hasRequiredEsnext_set_isDisjointFrom_v2) return esnext_set_isDisjointFrom_v2; + hasRequiredEsnext_set_isDisjointFrom_v2 = 1; + // TODO: Remove from `core-js@4` + requireEs_set_isDisjointFrom_v2(); + return esnext_set_isDisjointFrom_v2; +} + +var esnext_set_isDisjointFrom = {}; + +var hasRequiredEsnext_set_isDisjointFrom; + +function requireEsnext_set_isDisjointFrom () { + if (hasRequiredEsnext_set_isDisjointFrom) return esnext_set_isDisjointFrom; + hasRequiredEsnext_set_isDisjointFrom = 1; + var $ = require_export(); + var call = requireFunctionCall(); + var toSetLike = requireToSetLike(); + var $isDisjointFrom = requireSetIsDisjointFrom(); + + // `Set.prototype.isDisjointFrom` method + // https://github.com/tc39/proposal-set-methods + // TODO: Obsolete version, remove from `core-js@4` + $({ target: 'Set', proto: true, real: true, forced: true }, { + isDisjointFrom: function isDisjointFrom(other) { + return call($isDisjointFrom, this, toSetLike(other)); + } + }); + return esnext_set_isDisjointFrom; +} + +var esnext_set_isSubsetOf_v2 = {}; + +var hasRequiredEsnext_set_isSubsetOf_v2; + +function requireEsnext_set_isSubsetOf_v2 () { + if (hasRequiredEsnext_set_isSubsetOf_v2) return esnext_set_isSubsetOf_v2; + hasRequiredEsnext_set_isSubsetOf_v2 = 1; + // TODO: Remove from `core-js@4` + requireEs_set_isSubsetOf_v2(); + return esnext_set_isSubsetOf_v2; +} + +var esnext_set_isSubsetOf = {}; + +var hasRequiredEsnext_set_isSubsetOf; + +function requireEsnext_set_isSubsetOf () { + if (hasRequiredEsnext_set_isSubsetOf) return esnext_set_isSubsetOf; + hasRequiredEsnext_set_isSubsetOf = 1; + var $ = require_export(); + var call = requireFunctionCall(); + var toSetLike = requireToSetLike(); + var $isSubsetOf = requireSetIsSubsetOf(); + + // `Set.prototype.isSubsetOf` method + // https://github.com/tc39/proposal-set-methods + // TODO: Obsolete version, remove from `core-js@4` + $({ target: 'Set', proto: true, real: true, forced: true }, { + isSubsetOf: function isSubsetOf(other) { + return call($isSubsetOf, this, toSetLike(other)); + } + }); + return esnext_set_isSubsetOf; +} + +var esnext_set_isSupersetOf_v2 = {}; + +var hasRequiredEsnext_set_isSupersetOf_v2; + +function requireEsnext_set_isSupersetOf_v2 () { + if (hasRequiredEsnext_set_isSupersetOf_v2) return esnext_set_isSupersetOf_v2; + hasRequiredEsnext_set_isSupersetOf_v2 = 1; + // TODO: Remove from `core-js@4` + requireEs_set_isSupersetOf_v2(); + return esnext_set_isSupersetOf_v2; +} + +var esnext_set_isSupersetOf = {}; + +var hasRequiredEsnext_set_isSupersetOf; + +function requireEsnext_set_isSupersetOf () { + if (hasRequiredEsnext_set_isSupersetOf) return esnext_set_isSupersetOf; + hasRequiredEsnext_set_isSupersetOf = 1; + var $ = require_export(); + var call = requireFunctionCall(); + var toSetLike = requireToSetLike(); + var $isSupersetOf = requireSetIsSupersetOf(); + + // `Set.prototype.isSupersetOf` method + // https://github.com/tc39/proposal-set-methods + // TODO: Obsolete version, remove from `core-js@4` + $({ target: 'Set', proto: true, real: true, forced: true }, { + isSupersetOf: function isSupersetOf(other) { + return call($isSupersetOf, this, toSetLike(other)); + } + }); + return esnext_set_isSupersetOf; +} + +var esnext_set_join = {}; + +var hasRequiredEsnext_set_join; + +function requireEsnext_set_join () { + if (hasRequiredEsnext_set_join) return esnext_set_join; + hasRequiredEsnext_set_join = 1; + var $ = require_export(); + var uncurryThis = requireFunctionUncurryThis(); + var aSet = requireASet(); + var iterate = requireSetIterate(); + var toString = requireToString(); + + var arrayJoin = uncurryThis([].join); + var push = uncurryThis([].push); + + // `Set.prototype.join` method + // https://github.com/tc39/proposal-collection-methods + $({ target: 'Set', proto: true, real: true, forced: true }, { + join: function join(separator) { + var set = aSet(this); + var sep = separator === undefined ? ',' : toString(separator); + var array = []; + iterate(set, function (value) { + push(array, value); + }); + return arrayJoin(array, sep); + } + }); + return esnext_set_join; +} + +var esnext_set_map = {}; + +var hasRequiredEsnext_set_map; + +function requireEsnext_set_map () { + if (hasRequiredEsnext_set_map) return esnext_set_map; + hasRequiredEsnext_set_map = 1; + var $ = require_export(); + var bind = requireFunctionBindContext(); + var aSet = requireASet(); + var SetHelpers = requireSetHelpers(); + var iterate = requireSetIterate(); + + var Set = SetHelpers.Set; + var add = SetHelpers.add; + + // `Set.prototype.map` method + // https://github.com/tc39/proposal-collection-methods + $({ target: 'Set', proto: true, real: true, forced: true }, { + map: function map(callbackfn /* , thisArg */) { + var set = aSet(this); + var boundFunction = bind(callbackfn, arguments.length > 1 ? arguments[1] : undefined); + var newSet = new Set(); + iterate(set, function (value) { + add(newSet, boundFunction(value, value, set)); + }); + return newSet; + } + }); + return esnext_set_map; +} + +var esnext_set_of = {}; + +var hasRequiredEsnext_set_of; + +function requireEsnext_set_of () { + if (hasRequiredEsnext_set_of) return esnext_set_of; + hasRequiredEsnext_set_of = 1; + var $ = require_export(); + var SetHelpers = requireSetHelpers(); + var createCollectionOf = requireCollectionOf(); + + // `Set.of` method + // https://tc39.github.io/proposal-setmap-offrom/#sec-set.of + $({ target: 'Set', stat: true, forced: true }, { + of: createCollectionOf(SetHelpers.Set, SetHelpers.add, false) + }); + return esnext_set_of; +} + +var esnext_set_reduce = {}; + +var hasRequiredEsnext_set_reduce; + +function requireEsnext_set_reduce () { + if (hasRequiredEsnext_set_reduce) return esnext_set_reduce; + hasRequiredEsnext_set_reduce = 1; + var $ = require_export(); + var aCallable = requireACallable(); + var aSet = requireASet(); + var iterate = requireSetIterate(); + + var $TypeError = TypeError; + + // `Set.prototype.reduce` method + // https://github.com/tc39/proposal-collection-methods + $({ target: 'Set', proto: true, real: true, forced: true }, { + reduce: function reduce(callbackfn /* , initialValue */) { + var set = aSet(this); + var noInitial = arguments.length < 2; + var accumulator = noInitial ? undefined : arguments[1]; + aCallable(callbackfn); + iterate(set, function (value) { + if (noInitial) { + noInitial = false; + accumulator = value; + } else { + accumulator = callbackfn(accumulator, value, value, set); + } + }); + if (noInitial) throw new $TypeError('Reduce of empty set with no initial value'); + return accumulator; + } + }); + return esnext_set_reduce; +} + +var esnext_set_some = {}; + +var hasRequiredEsnext_set_some; + +function requireEsnext_set_some () { + if (hasRequiredEsnext_set_some) return esnext_set_some; + hasRequiredEsnext_set_some = 1; + var $ = require_export(); + var bind = requireFunctionBindContext(); + var aSet = requireASet(); + var iterate = requireSetIterate(); + + // `Set.prototype.some` method + // https://github.com/tc39/proposal-collection-methods + $({ target: 'Set', proto: true, real: true, forced: true }, { + some: function some(callbackfn /* , thisArg */) { + var set = aSet(this); + var boundFunction = bind(callbackfn, arguments.length > 1 ? arguments[1] : undefined); + return iterate(set, function (value) { + if (boundFunction(value, value, set)) return true; + }, true) === true; + } + }); + return esnext_set_some; +} + +var esnext_set_symmetricDifference_v2 = {}; + +var hasRequiredEsnext_set_symmetricDifference_v2; + +function requireEsnext_set_symmetricDifference_v2 () { + if (hasRequiredEsnext_set_symmetricDifference_v2) return esnext_set_symmetricDifference_v2; + hasRequiredEsnext_set_symmetricDifference_v2 = 1; + // TODO: Remove from `core-js@4` + requireEs_set_symmetricDifference_v2(); + return esnext_set_symmetricDifference_v2; +} + +var esnext_set_symmetricDifference = {}; + +var hasRequiredEsnext_set_symmetricDifference; + +function requireEsnext_set_symmetricDifference () { + if (hasRequiredEsnext_set_symmetricDifference) return esnext_set_symmetricDifference; + hasRequiredEsnext_set_symmetricDifference = 1; + var $ = require_export(); + var call = requireFunctionCall(); + var toSetLike = requireToSetLike(); + var $symmetricDifference = requireSetSymmetricDifference(); + + // `Set.prototype.symmetricDifference` method + // https://github.com/tc39/proposal-set-methods + // TODO: Obsolete version, remove from `core-js@4` + $({ target: 'Set', proto: true, real: true, forced: true }, { + symmetricDifference: function symmetricDifference(other) { + return call($symmetricDifference, this, toSetLike(other)); + } + }); + return esnext_set_symmetricDifference; +} + +var esnext_set_union_v2 = {}; + +var hasRequiredEsnext_set_union_v2; + +function requireEsnext_set_union_v2 () { + if (hasRequiredEsnext_set_union_v2) return esnext_set_union_v2; + hasRequiredEsnext_set_union_v2 = 1; + // TODO: Remove from `core-js@4` + requireEs_set_union_v2(); + return esnext_set_union_v2; +} + +var esnext_set_union = {}; + +var hasRequiredEsnext_set_union; + +function requireEsnext_set_union () { + if (hasRequiredEsnext_set_union) return esnext_set_union; + hasRequiredEsnext_set_union = 1; + var $ = require_export(); + var call = requireFunctionCall(); + var toSetLike = requireToSetLike(); + var $union = requireSetUnion(); + + // `Set.prototype.union` method + // https://github.com/tc39/proposal-set-methods + // TODO: Obsolete version, remove from `core-js@4` + $({ target: 'Set', proto: true, real: true, forced: true }, { + union: function union(other) { + return call($union, this, toSetLike(other)); + } + }); + return esnext_set_union; +} + +var esnext_string_at = {}; + +var hasRequiredEsnext_string_at; + +function requireEsnext_string_at () { + if (hasRequiredEsnext_string_at) return esnext_string_at; + hasRequiredEsnext_string_at = 1; + // TODO: Remove from `core-js@4` + var $ = require_export(); + var charAt = requireStringMultibyte().charAt; + var requireObjectCoercible = requireRequireObjectCoercible(); + var toIntegerOrInfinity = requireToIntegerOrInfinity(); + var toString = requireToString(); + + // `String.prototype.at` method + // https://github.com/mathiasbynens/String.prototype.at + $({ target: 'String', proto: true, forced: true }, { + at: function at(index) { + var S = toString(requireObjectCoercible(this)); + var len = S.length; + var relativeIndex = toIntegerOrInfinity(index); + var k = relativeIndex >= 0 ? relativeIndex : len + relativeIndex; + return (k < 0 || k >= len) ? undefined : charAt(S, k); + } + }); + return esnext_string_at; +} + +var esnext_string_cooked = {}; + +var stringCooked; +var hasRequiredStringCooked; + +function requireStringCooked () { + if (hasRequiredStringCooked) return stringCooked; + hasRequiredStringCooked = 1; + var uncurryThis = requireFunctionUncurryThis(); + var toIndexedObject = requireToIndexedObject(); + var toString = requireToString(); + var lengthOfArrayLike = requireLengthOfArrayLike(); + + var $TypeError = TypeError; + var push = uncurryThis([].push); + var join = uncurryThis([].join); + + // `String.cooked` method + // https://tc39.es/proposal-string-cooked/ + stringCooked = function cooked(template /* , ...substitutions */) { + var cookedTemplate = toIndexedObject(template); + var literalSegments = lengthOfArrayLike(cookedTemplate); + if (!literalSegments) return ''; + var argumentsLength = arguments.length; + var elements = []; + var i = 0; + while (true) { + var nextVal = cookedTemplate[i++]; + if (nextVal === undefined) throw new $TypeError('Incorrect template'); + push(elements, toString(nextVal)); + if (i === literalSegments) return join(elements, ''); + if (i < argumentsLength) push(elements, toString(arguments[i])); + } + }; + return stringCooked; +} + +var hasRequiredEsnext_string_cooked; + +function requireEsnext_string_cooked () { + if (hasRequiredEsnext_string_cooked) return esnext_string_cooked; + hasRequiredEsnext_string_cooked = 1; + var $ = require_export(); + var cooked = requireStringCooked(); + + // `String.cooked` method + // https://github.com/tc39/proposal-string-cooked + $({ target: 'String', stat: true, forced: true }, { + cooked: cooked + }); + return esnext_string_cooked; +} + +var esnext_string_codePoints = {}; + +var hasRequiredEsnext_string_codePoints; + +function requireEsnext_string_codePoints () { + if (hasRequiredEsnext_string_codePoints) return esnext_string_codePoints; + hasRequiredEsnext_string_codePoints = 1; + var $ = require_export(); + var createIteratorConstructor = requireIteratorCreateConstructor(); + var createIterResultObject = requireCreateIterResultObject(); + var requireObjectCoercible = requireRequireObjectCoercible(); + var toString = requireToString(); + var InternalStateModule = requireInternalState(); + var StringMultibyteModule = requireStringMultibyte(); + + var codeAt = StringMultibyteModule.codeAt; + var charAt = StringMultibyteModule.charAt; + var STRING_ITERATOR = 'String Iterator'; + var setInternalState = InternalStateModule.set; + var getInternalState = InternalStateModule.getterFor(STRING_ITERATOR); + + // TODO: unify with String#@@iterator + var $StringIterator = createIteratorConstructor(function StringIterator(string) { + setInternalState(this, { + type: STRING_ITERATOR, + string: string, + index: 0 + }); + }, 'String', function next() { + var state = getInternalState(this); + var string = state.string; + var index = state.index; + var point; + if (index >= string.length) return createIterResultObject(undefined, true); + point = charAt(string, index); + state.index += point.length; + return createIterResultObject({ codePoint: codeAt(point, 0), position: index }, false); + }); + + // `String.prototype.codePoints` method + // https://github.com/tc39/proposal-string-prototype-codepoints + $({ target: 'String', proto: true, forced: true }, { + codePoints: function codePoints() { + return new $StringIterator(toString(requireObjectCoercible(this))); + } + }); + return esnext_string_codePoints; +} + +var esnext_string_dedent = {}; + +var weakMapHelpers; +var hasRequiredWeakMapHelpers; + +function requireWeakMapHelpers () { + if (hasRequiredWeakMapHelpers) return weakMapHelpers; + hasRequiredWeakMapHelpers = 1; + var uncurryThis = requireFunctionUncurryThis(); + + // eslint-disable-next-line es/no-weak-map -- safe + var WeakMapPrototype = WeakMap.prototype; + + weakMapHelpers = { + // eslint-disable-next-line es/no-weak-map -- safe + WeakMap: WeakMap, + set: uncurryThis(WeakMapPrototype.set), + get: uncurryThis(WeakMapPrototype.get), + has: uncurryThis(WeakMapPrototype.has), + remove: uncurryThis(WeakMapPrototype['delete']) + }; + return weakMapHelpers; +} + +var stringParse; +var hasRequiredStringParse; + +function requireStringParse () { + if (hasRequiredStringParse) return stringParse; + hasRequiredStringParse = 1; + // adapted from https://github.com/jridgewell/string-dedent + var getBuiltIn = requireGetBuiltIn(); + var uncurryThis = requireFunctionUncurryThis(); + + var fromCharCode = String.fromCharCode; + var fromCodePoint = getBuiltIn('String', 'fromCodePoint'); + var charAt = uncurryThis(''.charAt); + var charCodeAt = uncurryThis(''.charCodeAt); + var stringIndexOf = uncurryThis(''.indexOf); + var stringSlice = uncurryThis(''.slice); + + var ZERO_CODE = 48; + var NINE_CODE = 57; + var LOWER_A_CODE = 97; + var LOWER_F_CODE = 102; + var UPPER_A_CODE = 65; + var UPPER_F_CODE = 70; + + var isDigit = function (str, index) { + var c = charCodeAt(str, index); + return c >= ZERO_CODE && c <= NINE_CODE; + }; + + var parseHex = function (str, index, end) { + if (end >= str.length) return -1; + var n = 0; + for (; index < end; index++) { + var c = hexToInt(charCodeAt(str, index)); + if (c === -1) return -1; + n = n * 16 + c; + } + return n; + }; + + var hexToInt = function (c) { + if (c >= ZERO_CODE && c <= NINE_CODE) return c - ZERO_CODE; + if (c >= LOWER_A_CODE && c <= LOWER_F_CODE) return c - LOWER_A_CODE + 10; + if (c >= UPPER_A_CODE && c <= UPPER_F_CODE) return c - UPPER_A_CODE + 10; + return -1; + }; + + stringParse = function (raw) { + var out = ''; + var start = 0; + // We need to find every backslash escape sequence, and cook the escape into a real char. + var i = 0; + var n; + while ((i = stringIndexOf(raw, '\\', i)) > -1) { + out += stringSlice(raw, start, i); + // If the backslash is the last char of the string, then it was an invalid sequence. + // This can't actually happen in a tagged template literal, but could happen if you manually + // invoked the tag with an array. + if (++i === raw.length) return; + var next = charAt(raw, i++); + switch (next) { + // Escaped control codes need to be individually processed. + case 'b': + out += '\b'; + break; + case 't': + out += '\t'; + break; + case 'n': + out += '\n'; + break; + case 'v': + out += '\v'; + break; + case 'f': + out += '\f'; + break; + case 'r': + out += '\r'; + break; + // Escaped line terminators just skip the char. + case '\r': + // Treat `\r\n` as a single terminator. + if (i < raw.length && charAt(raw, i) === '\n') ++i; + // break omitted + case '\n': + case '\u2028': + case '\u2029': + break; + // `\0` is a null control char, but `\0` followed by another digit is an illegal octal escape. + case '0': + if (isDigit(raw, i)) return; + out += '\0'; + break; + // Hex escapes must contain 2 hex chars. + case 'x': + n = parseHex(raw, i, i + 2); + if (n === -1) return; + i += 2; + out += fromCharCode(n); + break; + // Unicode escapes contain either 4 chars, or an unlimited number between `{` and `}`. + // The hex value must not overflow 0x10FFFF. + case 'u': + if (i < raw.length && charAt(raw, i) === '{') { + var end = stringIndexOf(raw, '}', ++i); + if (end === -1) return; + n = parseHex(raw, i, end); + i = end + 1; + } else { + n = parseHex(raw, i, i + 4); + i += 4; + } + if (n === -1 || n > 0x10FFFF) return; + out += fromCodePoint(n); + break; + default: + if (isDigit(next, 0)) return; + out += next; + } + start = i; + } + return out + stringSlice(raw, start); + }; + return stringParse; +} + +var hasRequiredEsnext_string_dedent; + +function requireEsnext_string_dedent () { + if (hasRequiredEsnext_string_dedent) return esnext_string_dedent; + hasRequiredEsnext_string_dedent = 1; + var FREEZING = requireFreezing(); + var $ = require_export(); + var makeBuiltIn = requireMakeBuiltIn(); + var uncurryThis = requireFunctionUncurryThis(); + var apply = requireFunctionApply(); + var anObject = requireAnObject(); + var toObject = requireToObject(); + var isCallable = requireIsCallable(); + var lengthOfArrayLike = requireLengthOfArrayLike(); + var defineProperty = requireObjectDefineProperty().f; + var createArrayFromList = requireArraySlice(); + var WeakMapHelpers = requireWeakMapHelpers(); + var cooked = requireStringCooked(); + var parse = requireStringParse(); + var whitespaces = requireWhitespaces(); + + var DedentMap = new WeakMapHelpers.WeakMap(); + var weakMapGet = WeakMapHelpers.get; + var weakMapHas = WeakMapHelpers.has; + var weakMapSet = WeakMapHelpers.set; + + var $Array = Array; + var $TypeError = TypeError; + // eslint-disable-next-line es/no-object-freeze -- safe + var freeze = Object.freeze || Object; + // eslint-disable-next-line es/no-object-isfrozen -- safe + var isFrozen = Object.isFrozen; + var min = Math.min; + var charAt = uncurryThis(''.charAt); + var stringSlice = uncurryThis(''.slice); + var split = uncurryThis(''.split); + var exec = uncurryThis(/./.exec); + + var NEW_LINE = /([\n\u2028\u2029]|\r\n?)/g; + var LEADING_WHITESPACE = RegExp('^[' + whitespaces + ']*'); + var NON_WHITESPACE = RegExp('[^' + whitespaces + ']'); + var INVALID_TAG = 'Invalid tag'; + var INVALID_OPENING_LINE = 'Invalid opening line'; + var INVALID_CLOSING_LINE = 'Invalid closing line'; + + var dedentTemplateStringsArray = function (template) { + var rawInput = template.raw; + // https://github.com/tc39/proposal-string-dedent/issues/75 + if (FREEZING && !isFrozen(rawInput)) throw new $TypeError('Raw template should be frozen'); + if (weakMapHas(DedentMap, rawInput)) return weakMapGet(DedentMap, rawInput); + var raw = dedentStringsArray(rawInput); + var cookedArr = cookStrings(raw); + defineProperty(cookedArr, 'raw', { + value: freeze(raw) + }); + freeze(cookedArr); + weakMapSet(DedentMap, rawInput, cookedArr); + return cookedArr; + }; + + var dedentStringsArray = function (template) { + var t = toObject(template); + var length = lengthOfArrayLike(t); + var blocks = $Array(length); + var dedented = $Array(length); + var i = 0; + var lines, common, quasi, k; + + if (!length) throw new $TypeError(INVALID_TAG); + + for (; i < length; i++) { + var element = t[i]; + if (typeof element == 'string') blocks[i] = split(element, NEW_LINE); + else throw new $TypeError(INVALID_TAG); + } + + for (i = 0; i < length; i++) { + var lastSplit = i + 1 === length; + lines = blocks[i]; + if (i === 0) { + if (lines.length === 1 || lines[0].length > 0) { + throw new $TypeError(INVALID_OPENING_LINE); + } + lines[1] = ''; + } + if (lastSplit) { + if (lines.length === 1 || exec(NON_WHITESPACE, lines[lines.length - 1])) { + throw new $TypeError(INVALID_CLOSING_LINE); + } + lines[lines.length - 2] = ''; + lines[lines.length - 1] = ''; + } + // eslint-disable-next-line sonar/no-redundant-assignments -- false positive, https://github.com/SonarSource/SonarJS/issues/4767 + for (var j = 2; j < lines.length; j += 2) { + var text = lines[j]; + var lineContainsTemplateExpression = j + 1 === lines.length && !lastSplit; + var leading = exec(LEADING_WHITESPACE, text)[0]; + if (!lineContainsTemplateExpression && leading.length === text.length) { + lines[j] = ''; + continue; + } + common = commonLeadingIndentation(leading, common); + } + } + + var count = common ? common.length : 0; + + for (i = 0; i < length; i++) { + lines = blocks[i]; + quasi = lines[0]; + k = 1; + for (; k < lines.length; k += 2) { + quasi += lines[k] + stringSlice(lines[k + 1], count); + } + dedented[i] = quasi; + } + + return dedented; + }; + + var commonLeadingIndentation = function (a, b) { + if (b === undefined || a === b) return a; + var i = 0; + for (var len = min(a.length, b.length); i < len; i++) { + if (charAt(a, i) !== charAt(b, i)) break; + } + return stringSlice(a, 0, i); + }; + + var cookStrings = function (raw) { + var i = 0; + var length = raw.length; + var result = $Array(length); + for (; i < length; i++) { + result[i] = parse(raw[i]); + } return result; + }; + + var makeDedentTag = function (tag) { + return makeBuiltIn(function (template /* , ...substitutions */) { + var args = createArrayFromList(arguments); + args[0] = dedentTemplateStringsArray(anObject(template)); + return apply(tag, this, args); + }, ''); + }; + + var cookedDedentTag = makeDedentTag(cooked); + + // `String.dedent` method + // https://github.com/tc39/proposal-string-dedent + $({ target: 'String', stat: true, forced: true }, { + dedent: function dedent(templateOrFn /* , ...substitutions */) { + anObject(templateOrFn); + if (isCallable(templateOrFn)) return makeDedentTag(templateOrFn); + return apply(cookedDedentTag, this, arguments); + } + }); + return esnext_string_dedent; +} + +var esnext_string_isWellFormed = {}; + +var hasRequiredEsnext_string_isWellFormed; + +function requireEsnext_string_isWellFormed () { + if (hasRequiredEsnext_string_isWellFormed) return esnext_string_isWellFormed; + hasRequiredEsnext_string_isWellFormed = 1; + // TODO: Remove from `core-js@4` + requireEs_string_isWellFormed(); + return esnext_string_isWellFormed; +} + +var esnext_string_matchAll = {}; + +var hasRequiredEsnext_string_matchAll; + +function requireEsnext_string_matchAll () { + if (hasRequiredEsnext_string_matchAll) return esnext_string_matchAll; + hasRequiredEsnext_string_matchAll = 1; + // TODO: Remove from `core-js@4` + requireEs_string_matchAll(); + return esnext_string_matchAll; +} + +var esnext_string_replaceAll = {}; + +var hasRequiredEsnext_string_replaceAll; + +function requireEsnext_string_replaceAll () { + if (hasRequiredEsnext_string_replaceAll) return esnext_string_replaceAll; + hasRequiredEsnext_string_replaceAll = 1; + // TODO: Remove from `core-js@4` + requireEs_string_replaceAll(); + return esnext_string_replaceAll; +} + +var esnext_string_toWellFormed = {}; + +var hasRequiredEsnext_string_toWellFormed; + +function requireEsnext_string_toWellFormed () { + if (hasRequiredEsnext_string_toWellFormed) return esnext_string_toWellFormed; + hasRequiredEsnext_string_toWellFormed = 1; + // TODO: Remove from `core-js@4` + requireEs_string_toWellFormed(); + return esnext_string_toWellFormed; +} + +var esnext_symbol_asyncDispose = {}; + +var hasRequiredEsnext_symbol_asyncDispose; + +function requireEsnext_symbol_asyncDispose () { + if (hasRequiredEsnext_symbol_asyncDispose) return esnext_symbol_asyncDispose; + hasRequiredEsnext_symbol_asyncDispose = 1; + var globalThis = requireGlobalThis(); + var defineWellKnownSymbol = requireWellKnownSymbolDefine(); + var defineProperty = requireObjectDefineProperty().f; + var getOwnPropertyDescriptor = requireObjectGetOwnPropertyDescriptor().f; + + var Symbol = globalThis.Symbol; + + // `Symbol.asyncDispose` well-known symbol + // https://github.com/tc39/proposal-async-explicit-resource-management + defineWellKnownSymbol('asyncDispose'); + + if (Symbol) { + var descriptor = getOwnPropertyDescriptor(Symbol, 'asyncDispose'); + // workaround of NodeJS 20.4 bug + // https://github.com/nodejs/node/issues/48699 + // and incorrect descriptor from some transpilers and userland helpers + if (descriptor.enumerable && descriptor.configurable && descriptor.writable) { + defineProperty(Symbol, 'asyncDispose', { value: descriptor.value, enumerable: false, configurable: false, writable: false }); + } + } + return esnext_symbol_asyncDispose; +} + +var esnext_symbol_customMatcher = {}; + +var hasRequiredEsnext_symbol_customMatcher; + +function requireEsnext_symbol_customMatcher () { + if (hasRequiredEsnext_symbol_customMatcher) return esnext_symbol_customMatcher; + hasRequiredEsnext_symbol_customMatcher = 1; + var defineWellKnownSymbol = requireWellKnownSymbolDefine(); + + // `Symbol.customMatcher` well-known symbol + // https://github.com/tc39/proposal-pattern-matching + defineWellKnownSymbol('customMatcher'); + return esnext_symbol_customMatcher; +} + +var esnext_symbol_dispose = {}; + +var hasRequiredEsnext_symbol_dispose; + +function requireEsnext_symbol_dispose () { + if (hasRequiredEsnext_symbol_dispose) return esnext_symbol_dispose; + hasRequiredEsnext_symbol_dispose = 1; + var globalThis = requireGlobalThis(); + var defineWellKnownSymbol = requireWellKnownSymbolDefine(); + var defineProperty = requireObjectDefineProperty().f; + var getOwnPropertyDescriptor = requireObjectGetOwnPropertyDescriptor().f; + + var Symbol = globalThis.Symbol; + + // `Symbol.dispose` well-known symbol + // https://github.com/tc39/proposal-explicit-resource-management + defineWellKnownSymbol('dispose'); + + if (Symbol) { + var descriptor = getOwnPropertyDescriptor(Symbol, 'dispose'); + // workaround of NodeJS 20.4 bug + // https://github.com/nodejs/node/issues/48699 + // and incorrect descriptor from some transpilers and userland helpers + if (descriptor.enumerable && descriptor.configurable && descriptor.writable) { + defineProperty(Symbol, 'dispose', { value: descriptor.value, enumerable: false, configurable: false, writable: false }); + } + } + return esnext_symbol_dispose; +} + +var esnext_symbol_isRegisteredSymbol = {}; + +var symbolIsRegistered; +var hasRequiredSymbolIsRegistered; + +function requireSymbolIsRegistered () { + if (hasRequiredSymbolIsRegistered) return symbolIsRegistered; + hasRequiredSymbolIsRegistered = 1; + var getBuiltIn = requireGetBuiltIn(); + var uncurryThis = requireFunctionUncurryThis(); + + var Symbol = getBuiltIn('Symbol'); + var keyFor = Symbol.keyFor; + var thisSymbolValue = uncurryThis(Symbol.prototype.valueOf); + + // `Symbol.isRegisteredSymbol` method + // https://tc39.es/proposal-symbol-predicates/#sec-symbol-isregisteredsymbol + symbolIsRegistered = Symbol.isRegisteredSymbol || function isRegisteredSymbol(value) { + try { + return keyFor(thisSymbolValue(value)) !== undefined; + } catch (error) { + return false; + } + }; + return symbolIsRegistered; +} + +var hasRequiredEsnext_symbol_isRegisteredSymbol; + +function requireEsnext_symbol_isRegisteredSymbol () { + if (hasRequiredEsnext_symbol_isRegisteredSymbol) return esnext_symbol_isRegisteredSymbol; + hasRequiredEsnext_symbol_isRegisteredSymbol = 1; + var $ = require_export(); + var isRegisteredSymbol = requireSymbolIsRegistered(); + + // `Symbol.isRegisteredSymbol` method + // https://tc39.es/proposal-symbol-predicates/#sec-symbol-isregisteredsymbol + $({ target: 'Symbol', stat: true }, { + isRegisteredSymbol: isRegisteredSymbol + }); + return esnext_symbol_isRegisteredSymbol; +} + +var esnext_symbol_isRegistered = {}; + +var hasRequiredEsnext_symbol_isRegistered; + +function requireEsnext_symbol_isRegistered () { + if (hasRequiredEsnext_symbol_isRegistered) return esnext_symbol_isRegistered; + hasRequiredEsnext_symbol_isRegistered = 1; + var $ = require_export(); + var isRegisteredSymbol = requireSymbolIsRegistered(); + + // `Symbol.isRegistered` method + // obsolete version of https://tc39.es/proposal-symbol-predicates/#sec-symbol-isregisteredsymbol + $({ target: 'Symbol', stat: true, name: 'isRegisteredSymbol' }, { + isRegistered: isRegisteredSymbol + }); + return esnext_symbol_isRegistered; +} + +var esnext_symbol_isWellKnownSymbol = {}; + +var symbolIsWellKnown; +var hasRequiredSymbolIsWellKnown; + +function requireSymbolIsWellKnown () { + if (hasRequiredSymbolIsWellKnown) return symbolIsWellKnown; + hasRequiredSymbolIsWellKnown = 1; + var shared = requireShared(); + var getBuiltIn = requireGetBuiltIn(); + var uncurryThis = requireFunctionUncurryThis(); + var isSymbol = requireIsSymbol(); + var wellKnownSymbol = requireWellKnownSymbol(); + + var Symbol = getBuiltIn('Symbol'); + var $isWellKnownSymbol = Symbol.isWellKnownSymbol; + var getOwnPropertyNames = getBuiltIn('Object', 'getOwnPropertyNames'); + var thisSymbolValue = uncurryThis(Symbol.prototype.valueOf); + var WellKnownSymbolsStore = shared('wks'); + + for (var i = 0, symbolKeys = getOwnPropertyNames(Symbol), symbolKeysLength = symbolKeys.length; i < symbolKeysLength; i++) { + // some old engines throws on access to some keys like `arguments` or `caller` + try { + var symbolKey = symbolKeys[i]; + if (isSymbol(Symbol[symbolKey])) wellKnownSymbol(symbolKey); + } catch (error) { /* empty */ } + } + + // `Symbol.isWellKnownSymbol` method + // https://tc39.es/proposal-symbol-predicates/#sec-symbol-iswellknownsymbol + // We should patch it for newly added well-known symbols. If it's not required, this module just will not be injected + symbolIsWellKnown = function isWellKnownSymbol(value) { + if ($isWellKnownSymbol && $isWellKnownSymbol(value)) return true; + try { + var symbol = thisSymbolValue(value); + for (var j = 0, keys = getOwnPropertyNames(WellKnownSymbolsStore), keysLength = keys.length; j < keysLength; j++) { + // eslint-disable-next-line eqeqeq -- polyfilled symbols case + if (WellKnownSymbolsStore[keys[j]] == symbol) return true; + } + } catch (error) { /* empty */ } + return false; + }; + return symbolIsWellKnown; +} + +var hasRequiredEsnext_symbol_isWellKnownSymbol; + +function requireEsnext_symbol_isWellKnownSymbol () { + if (hasRequiredEsnext_symbol_isWellKnownSymbol) return esnext_symbol_isWellKnownSymbol; + hasRequiredEsnext_symbol_isWellKnownSymbol = 1; + var $ = require_export(); + var isWellKnownSymbol = requireSymbolIsWellKnown(); + + // `Symbol.isWellKnownSymbol` method + // https://tc39.es/proposal-symbol-predicates/#sec-symbol-iswellknownsymbol + // We should patch it for newly added well-known symbols. If it's not required, this module just will not be injected + $({ target: 'Symbol', stat: true, forced: true }, { + isWellKnownSymbol: isWellKnownSymbol + }); + return esnext_symbol_isWellKnownSymbol; +} + +var esnext_symbol_isWellKnown = {}; + +var hasRequiredEsnext_symbol_isWellKnown; + +function requireEsnext_symbol_isWellKnown () { + if (hasRequiredEsnext_symbol_isWellKnown) return esnext_symbol_isWellKnown; + hasRequiredEsnext_symbol_isWellKnown = 1; + var $ = require_export(); + var isWellKnownSymbol = requireSymbolIsWellKnown(); + + // `Symbol.isWellKnown` method + // obsolete version of https://tc39.es/proposal-symbol-predicates/#sec-symbol-iswellknownsymbol + // We should patch it for newly added well-known symbols. If it's not required, this module just will not be injected + $({ target: 'Symbol', stat: true, name: 'isWellKnownSymbol', forced: true }, { + isWellKnown: isWellKnownSymbol + }); + return esnext_symbol_isWellKnown; +} + +var esnext_symbol_matcher = {}; + +var hasRequiredEsnext_symbol_matcher; + +function requireEsnext_symbol_matcher () { + if (hasRequiredEsnext_symbol_matcher) return esnext_symbol_matcher; + hasRequiredEsnext_symbol_matcher = 1; + var defineWellKnownSymbol = requireWellKnownSymbolDefine(); + + // `Symbol.matcher` well-known symbol + // https://github.com/tc39/proposal-pattern-matching + defineWellKnownSymbol('matcher'); + return esnext_symbol_matcher; +} + +var esnext_symbol_metadata = {}; + +var hasRequiredEsnext_symbol_metadata; + +function requireEsnext_symbol_metadata () { + if (hasRequiredEsnext_symbol_metadata) return esnext_symbol_metadata; + hasRequiredEsnext_symbol_metadata = 1; + var defineWellKnownSymbol = requireWellKnownSymbolDefine(); + + // `Symbol.metadata` well-known symbol + // https://github.com/tc39/proposal-decorators + defineWellKnownSymbol('metadata'); + return esnext_symbol_metadata; +} + +var esnext_symbol_metadataKey = {}; + +var hasRequiredEsnext_symbol_metadataKey; + +function requireEsnext_symbol_metadataKey () { + if (hasRequiredEsnext_symbol_metadataKey) return esnext_symbol_metadataKey; + hasRequiredEsnext_symbol_metadataKey = 1; + // TODO: Remove from `core-js@4` + var defineWellKnownSymbol = requireWellKnownSymbolDefine(); + + // `Symbol.metadataKey` well-known symbol + // https://github.com/tc39/proposal-decorator-metadata + defineWellKnownSymbol('metadataKey'); + return esnext_symbol_metadataKey; +} + +var esnext_symbol_observable = {}; + +var hasRequiredEsnext_symbol_observable; + +function requireEsnext_symbol_observable () { + if (hasRequiredEsnext_symbol_observable) return esnext_symbol_observable; + hasRequiredEsnext_symbol_observable = 1; + var defineWellKnownSymbol = requireWellKnownSymbolDefine(); + + // `Symbol.observable` well-known symbol + // https://github.com/tc39/proposal-observable + defineWellKnownSymbol('observable'); + return esnext_symbol_observable; +} + +var esnext_symbol_patternMatch = {}; + +var hasRequiredEsnext_symbol_patternMatch; + +function requireEsnext_symbol_patternMatch () { + if (hasRequiredEsnext_symbol_patternMatch) return esnext_symbol_patternMatch; + hasRequiredEsnext_symbol_patternMatch = 1; + // TODO: remove from `core-js@4` + var defineWellKnownSymbol = requireWellKnownSymbolDefine(); + + // `Symbol.patternMatch` well-known symbol + // https://github.com/tc39/proposal-pattern-matching + defineWellKnownSymbol('patternMatch'); + return esnext_symbol_patternMatch; +} + +var esnext_symbol_replaceAll = {}; + +var hasRequiredEsnext_symbol_replaceAll; + +function requireEsnext_symbol_replaceAll () { + if (hasRequiredEsnext_symbol_replaceAll) return esnext_symbol_replaceAll; + hasRequiredEsnext_symbol_replaceAll = 1; + // TODO: remove from `core-js@4` + var defineWellKnownSymbol = requireWellKnownSymbolDefine(); + + defineWellKnownSymbol('replaceAll'); + return esnext_symbol_replaceAll; +} + +var esnext_typedArray_fromAsync = {}; + +var hasRequiredEsnext_typedArray_fromAsync; + +function requireEsnext_typedArray_fromAsync () { + if (hasRequiredEsnext_typedArray_fromAsync) return esnext_typedArray_fromAsync; + hasRequiredEsnext_typedArray_fromAsync = 1; + // TODO: Remove from `core-js@4` + var getBuiltIn = requireGetBuiltIn(); + var aConstructor = requireAConstructor(); + var arrayFromAsync = requireArrayFromAsync(); + var ArrayBufferViewCore = requireArrayBufferViewCore(); + var arrayFromConstructorAndList = requireArrayFromConstructorAndList(); + + var aTypedArrayConstructor = ArrayBufferViewCore.aTypedArrayConstructor; + var exportTypedArrayStaticMethod = ArrayBufferViewCore.exportTypedArrayStaticMethod; + + // `%TypedArray%.fromAsync` method + // https://github.com/tc39/proposal-array-from-async + exportTypedArrayStaticMethod('fromAsync', function fromAsync(asyncItems /* , mapfn = undefined, thisArg = undefined */) { + var C = this; + var argumentsLength = arguments.length; + var mapfn = argumentsLength > 1 ? arguments[1] : undefined; + var thisArg = argumentsLength > 2 ? arguments[2] : undefined; + return new (getBuiltIn('Promise'))(function (resolve) { + aConstructor(C); + resolve(arrayFromAsync(asyncItems, mapfn, thisArg)); + }).then(function (list) { + return arrayFromConstructorAndList(aTypedArrayConstructor(C), list); + }); + }, true); + return esnext_typedArray_fromAsync; +} + +var esnext_typedArray_at = {}; + +var hasRequiredEsnext_typedArray_at; + +function requireEsnext_typedArray_at () { + if (hasRequiredEsnext_typedArray_at) return esnext_typedArray_at; + hasRequiredEsnext_typedArray_at = 1; + // TODO: Remove from `core-js@4` + requireEs_typedArray_at(); + return esnext_typedArray_at; +} + +var esnext_typedArray_filterOut = {}; + +var hasRequiredEsnext_typedArray_filterOut; + +function requireEsnext_typedArray_filterOut () { + if (hasRequiredEsnext_typedArray_filterOut) return esnext_typedArray_filterOut; + hasRequiredEsnext_typedArray_filterOut = 1; + // TODO: Remove from `core-js@4` + var ArrayBufferViewCore = requireArrayBufferViewCore(); + var $filterReject = requireArrayIteration().filterReject; + var fromSpeciesAndList = requireTypedArrayFromSpeciesAndList(); + + var aTypedArray = ArrayBufferViewCore.aTypedArray; + var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod; + + // `%TypedArray%.prototype.filterOut` method + // https://github.com/tc39/proposal-array-filtering + exportTypedArrayMethod('filterOut', function filterOut(callbackfn /* , thisArg */) { + var list = $filterReject(aTypedArray(this), callbackfn, arguments.length > 1 ? arguments[1] : undefined); + return fromSpeciesAndList(this, list); + }, true); + return esnext_typedArray_filterOut; +} + +var esnext_typedArray_filterReject = {}; + +var hasRequiredEsnext_typedArray_filterReject; + +function requireEsnext_typedArray_filterReject () { + if (hasRequiredEsnext_typedArray_filterReject) return esnext_typedArray_filterReject; + hasRequiredEsnext_typedArray_filterReject = 1; + var ArrayBufferViewCore = requireArrayBufferViewCore(); + var $filterReject = requireArrayIteration().filterReject; + var fromSpeciesAndList = requireTypedArrayFromSpeciesAndList(); + + var aTypedArray = ArrayBufferViewCore.aTypedArray; + var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod; + + // `%TypedArray%.prototype.filterReject` method + // https://github.com/tc39/proposal-array-filtering + exportTypedArrayMethod('filterReject', function filterReject(callbackfn /* , thisArg */) { + var list = $filterReject(aTypedArray(this), callbackfn, arguments.length > 1 ? arguments[1] : undefined); + return fromSpeciesAndList(this, list); + }, true); + return esnext_typedArray_filterReject; +} + +var esnext_typedArray_findLast = {}; + +var hasRequiredEsnext_typedArray_findLast; + +function requireEsnext_typedArray_findLast () { + if (hasRequiredEsnext_typedArray_findLast) return esnext_typedArray_findLast; + hasRequiredEsnext_typedArray_findLast = 1; + // TODO: Remove from `core-js@4` + requireEs_typedArray_findLast(); + return esnext_typedArray_findLast; +} + +var esnext_typedArray_findLastIndex = {}; + +var hasRequiredEsnext_typedArray_findLastIndex; + +function requireEsnext_typedArray_findLastIndex () { + if (hasRequiredEsnext_typedArray_findLastIndex) return esnext_typedArray_findLastIndex; + hasRequiredEsnext_typedArray_findLastIndex = 1; + // TODO: Remove from `core-js@4` + requireEs_typedArray_findLastIndex(); + return esnext_typedArray_findLastIndex; +} + +var esnext_typedArray_groupBy = {}; + +var hasRequiredEsnext_typedArray_groupBy; + +function requireEsnext_typedArray_groupBy () { + if (hasRequiredEsnext_typedArray_groupBy) return esnext_typedArray_groupBy; + hasRequiredEsnext_typedArray_groupBy = 1; + // TODO: Remove from `core-js@4` + var ArrayBufferViewCore = requireArrayBufferViewCore(); + var $group = requireArrayGroup(); + var typedArraySpeciesConstructor = requireTypedArraySpeciesConstructor(); + + var aTypedArray = ArrayBufferViewCore.aTypedArray; + var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod; + + // `%TypedArray%.prototype.groupBy` method + // https://github.com/tc39/proposal-array-grouping + exportTypedArrayMethod('groupBy', function groupBy(callbackfn /* , thisArg */) { + var thisArg = arguments.length > 1 ? arguments[1] : undefined; + return $group(aTypedArray(this), callbackfn, thisArg, typedArraySpeciesConstructor); + }, true); + return esnext_typedArray_groupBy; +} + +var esnext_typedArray_toReversed = {}; + +var hasRequiredEsnext_typedArray_toReversed; + +function requireEsnext_typedArray_toReversed () { + if (hasRequiredEsnext_typedArray_toReversed) return esnext_typedArray_toReversed; + hasRequiredEsnext_typedArray_toReversed = 1; + // TODO: Remove from `core-js@4` + requireEs_typedArray_toReversed(); + return esnext_typedArray_toReversed; +} + +var esnext_typedArray_toSorted = {}; + +var hasRequiredEsnext_typedArray_toSorted; + +function requireEsnext_typedArray_toSorted () { + if (hasRequiredEsnext_typedArray_toSorted) return esnext_typedArray_toSorted; + hasRequiredEsnext_typedArray_toSorted = 1; + // TODO: Remove from `core-js@4` + requireEs_typedArray_toSorted(); + return esnext_typedArray_toSorted; +} + +var esnext_typedArray_toSpliced = {}; + +var hasRequiredEsnext_typedArray_toSpliced; + +function requireEsnext_typedArray_toSpliced () { + if (hasRequiredEsnext_typedArray_toSpliced) return esnext_typedArray_toSpliced; + hasRequiredEsnext_typedArray_toSpliced = 1; + // TODO: Remove from `core-js@4` + var ArrayBufferViewCore = requireArrayBufferViewCore(); + var lengthOfArrayLike = requireLengthOfArrayLike(); + var isBigIntArray = requireIsBigIntArray(); + var toAbsoluteIndex = requireToAbsoluteIndex(); + var toBigInt = requireToBigInt(); + var toIntegerOrInfinity = requireToIntegerOrInfinity(); + var fails = requireFails(); + + var aTypedArray = ArrayBufferViewCore.aTypedArray; + var getTypedArrayConstructor = ArrayBufferViewCore.getTypedArrayConstructor; + var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod; + var max = Math.max; + var min = Math.min; + + // some early implementations, like WebKit, does not follow the final semantic + var PROPER_ORDER = !fails(function () { + // eslint-disable-next-line es/no-typed-arrays -- required for testing + var array = new Int8Array([1]); + + var spliced = array.toSpliced(1, 0, { + valueOf: function () { + array[0] = 2; + return 3; + } + }); + + return spliced[0] !== 2 || spliced[1] !== 3; + }); + + // `%TypedArray%.prototype.toSpliced` method + // https://tc39.es/proposal-change-array-by-copy/#sec-%typedarray%.prototype.toSpliced + exportTypedArrayMethod('toSpliced', function toSpliced(start, deleteCount /* , ...items */) { + var O = aTypedArray(this); + var C = getTypedArrayConstructor(O); + var len = lengthOfArrayLike(O); + var actualStart = toAbsoluteIndex(start, len); + var argumentsLength = arguments.length; + var k = 0; + var insertCount, actualDeleteCount, thisIsBigIntArray, convertedItems, value, newLen, A; + if (argumentsLength === 0) { + insertCount = actualDeleteCount = 0; + } else if (argumentsLength === 1) { + insertCount = 0; + actualDeleteCount = len - actualStart; + } else { + actualDeleteCount = min(max(toIntegerOrInfinity(deleteCount), 0), len - actualStart); + insertCount = argumentsLength - 2; + if (insertCount) { + convertedItems = new C(insertCount); + thisIsBigIntArray = isBigIntArray(convertedItems); + for (var i = 2; i < argumentsLength; i++) { + value = arguments[i]; + // FF30- typed arrays doesn't properly convert objects to typed array values + convertedItems[i - 2] = thisIsBigIntArray ? toBigInt(value) : +value; + } + } + } + newLen = len + insertCount - actualDeleteCount; + A = new C(newLen); + + for (; k < actualStart; k++) A[k] = O[k]; + for (; k < actualStart + insertCount; k++) A[k] = convertedItems[k - actualStart]; + for (; k < newLen; k++) A[k] = O[k + actualDeleteCount - insertCount]; + + return A; + }, !PROPER_ORDER); + return esnext_typedArray_toSpliced; +} + +var esnext_typedArray_uniqueBy = {}; + +var hasRequiredEsnext_typedArray_uniqueBy; + +function requireEsnext_typedArray_uniqueBy () { + if (hasRequiredEsnext_typedArray_uniqueBy) return esnext_typedArray_uniqueBy; + hasRequiredEsnext_typedArray_uniqueBy = 1; + var uncurryThis = requireFunctionUncurryThis(); + var ArrayBufferViewCore = requireArrayBufferViewCore(); + var arrayFromConstructorAndList = requireArrayFromConstructorAndList(); + var $arrayUniqueBy = requireArrayUniqueBy(); + + var aTypedArray = ArrayBufferViewCore.aTypedArray; + var getTypedArrayConstructor = ArrayBufferViewCore.getTypedArrayConstructor; + var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod; + var arrayUniqueBy = uncurryThis($arrayUniqueBy); + + // `%TypedArray%.prototype.uniqueBy` method + // https://github.com/tc39/proposal-array-unique + exportTypedArrayMethod('uniqueBy', function uniqueBy(resolver) { + aTypedArray(this); + return arrayFromConstructorAndList(getTypedArrayConstructor(this), arrayUniqueBy(this, resolver)); + }, true); + return esnext_typedArray_uniqueBy; +} + +var esnext_typedArray_with = {}; + +var hasRequiredEsnext_typedArray_with; + +function requireEsnext_typedArray_with () { + if (hasRequiredEsnext_typedArray_with) return esnext_typedArray_with; + hasRequiredEsnext_typedArray_with = 1; + // TODO: Remove from `core-js@4` + requireEs_typedArray_with(); + return esnext_typedArray_with; +} + +var esnext_uint8Array_fromBase64 = {}; + +var anObjectOrUndefined; +var hasRequiredAnObjectOrUndefined; + +function requireAnObjectOrUndefined () { + if (hasRequiredAnObjectOrUndefined) return anObjectOrUndefined; + hasRequiredAnObjectOrUndefined = 1; + var isObject = requireIsObject(); + + var $String = String; + var $TypeError = TypeError; + + anObjectOrUndefined = function (argument) { + if (argument === undefined || isObject(argument)) return argument; + throw new $TypeError($String(argument) + ' is not an object or undefined'); + }; + return anObjectOrUndefined; +} + +var base64Map; +var hasRequiredBase64Map; + +function requireBase64Map () { + if (hasRequiredBase64Map) return base64Map; + hasRequiredBase64Map = 1; + var commonAlphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; + var base64Alphabet = commonAlphabet + '+/'; + var base64UrlAlphabet = commonAlphabet + '-_'; + + var inverse = function (characters) { + // TODO: use `Object.create(null)` in `core-js@4` + var result = {}; + var index = 0; + for (; index < 64; index++) result[characters.charAt(index)] = index; + return result; + }; + + base64Map = { + i2c: base64Alphabet, + c2i: inverse(base64Alphabet), + i2cUrl: base64UrlAlphabet, + c2iUrl: inverse(base64UrlAlphabet) + }; + return base64Map; +} + +var getAlphabetOption; +var hasRequiredGetAlphabetOption; + +function requireGetAlphabetOption () { + if (hasRequiredGetAlphabetOption) return getAlphabetOption; + hasRequiredGetAlphabetOption = 1; + var $TypeError = TypeError; + + getAlphabetOption = function (options) { + var alphabet = options && options.alphabet; + if (alphabet === undefined || alphabet === 'base64' || alphabet === 'base64url') return alphabet || 'base64'; + throw new $TypeError('Incorrect `alphabet` option'); + }; + return getAlphabetOption; +} + +var uint8FromBase64; +var hasRequiredUint8FromBase64; + +function requireUint8FromBase64 () { + if (hasRequiredUint8FromBase64) return uint8FromBase64; + hasRequiredUint8FromBase64 = 1; + var globalThis = requireGlobalThis(); + var uncurryThis = requireFunctionUncurryThis(); + var anObjectOrUndefined = requireAnObjectOrUndefined(); + var aString = requireAString(); + var hasOwn = requireHasOwnProperty(); + var base64Map = requireBase64Map(); + var getAlphabetOption = requireGetAlphabetOption(); + var notDetached = requireArrayBufferNotDetached(); + + var base64Alphabet = base64Map.c2i; + var base64UrlAlphabet = base64Map.c2iUrl; + + var SyntaxError = globalThis.SyntaxError; + var TypeError = globalThis.TypeError; + var at = uncurryThis(''.charAt); + + var skipAsciiWhitespace = function (string, index) { + var length = string.length; + for (;index < length; index++) { + var chr = at(string, index); + if (chr !== ' ' && chr !== '\t' && chr !== '\n' && chr !== '\f' && chr !== '\r') break; + } return index; + }; + + var decodeBase64Chunk = function (chunk, alphabet, throwOnExtraBits) { + var chunkLength = chunk.length; + + if (chunkLength < 4) { + chunk += chunkLength === 2 ? 'AA' : 'A'; + } + + var triplet = (alphabet[at(chunk, 0)] << 18) + + (alphabet[at(chunk, 1)] << 12) + + (alphabet[at(chunk, 2)] << 6) + + alphabet[at(chunk, 3)]; + + var chunkBytes = [ + (triplet >> 16) & 255, + (triplet >> 8) & 255, + triplet & 255 + ]; + + if (chunkLength === 2) { + if (throwOnExtraBits && chunkBytes[1] !== 0) { + throw new SyntaxError('Extra bits'); + } + return [chunkBytes[0]]; + } + + if (chunkLength === 3) { + if (throwOnExtraBits && chunkBytes[2] !== 0) { + throw new SyntaxError('Extra bits'); + } + return [chunkBytes[0], chunkBytes[1]]; + } + + return chunkBytes; + }; + + var writeBytes = function (bytes, elements, written) { + var elementsLength = elements.length; + for (var index = 0; index < elementsLength; index++) { + bytes[written + index] = elements[index]; + } + return written + elementsLength; + }; + + /* eslint-disable max-statements, max-depth -- TODO */ + uint8FromBase64 = function (string, options, into, maxLength) { + aString(string); + anObjectOrUndefined(options); + var alphabet = getAlphabetOption(options) === 'base64' ? base64Alphabet : base64UrlAlphabet; + var lastChunkHandling = options ? options.lastChunkHandling : undefined; + + if (lastChunkHandling === undefined) lastChunkHandling = 'loose'; + + if (lastChunkHandling !== 'loose' && lastChunkHandling !== 'strict' && lastChunkHandling !== 'stop-before-partial') { + throw new TypeError('Incorrect `lastChunkHandling` option'); + } + + if (into) notDetached(into.buffer); + + var bytes = into || []; + var written = 0; + var read = 0; + var chunk = ''; + var index = 0; + + if (maxLength) while (true) { + index = skipAsciiWhitespace(string, index); + if (index === string.length) { + if (chunk.length > 0) { + if (lastChunkHandling === 'stop-before-partial') { + break; + } + if (lastChunkHandling === 'loose') { + if (chunk.length === 1) { + throw new SyntaxError('Malformed padding: exactly one additional character'); + } + written = writeBytes(bytes, decodeBase64Chunk(chunk, alphabet, false), written); + } else { + throw new SyntaxError('Missing padding'); + } + } + read = string.length; + break; + } + var chr = at(string, index); + ++index; + if (chr === '=') { + if (chunk.length < 2) { + throw new SyntaxError('Padding is too early'); + } + index = skipAsciiWhitespace(string, index); + if (chunk.length === 2) { + if (index === string.length) { + if (lastChunkHandling === 'stop-before-partial') { + break; + } + throw new SyntaxError('Malformed padding: only one ='); + } + if (at(string, index) === '=') { + ++index; + index = skipAsciiWhitespace(string, index); + } + } + if (index < string.length) { + throw new SyntaxError('Unexpected character after padding'); + } + written = writeBytes(bytes, decodeBase64Chunk(chunk, alphabet, lastChunkHandling === 'strict'), written); + read = string.length; + break; + } + if (!hasOwn(alphabet, chr)) { + throw new SyntaxError('Unexpected character'); + } + var remainingBytes = maxLength - written; + if (remainingBytes === 1 && chunk.length === 2 || remainingBytes === 2 && chunk.length === 3) { + // special case: we can fit exactly the number of bytes currently represented by chunk, so we were just checking for `=` + break; + } + + chunk += chr; + if (chunk.length === 4) { + written = writeBytes(bytes, decodeBase64Chunk(chunk, alphabet, false), written); + chunk = ''; + read = index; + if (written === maxLength) { + break; + } + } + } + + return { bytes: bytes, read: read, written: written }; + }; + return uint8FromBase64; +} + +var hasRequiredEsnext_uint8Array_fromBase64; + +function requireEsnext_uint8Array_fromBase64 () { + if (hasRequiredEsnext_uint8Array_fromBase64) return esnext_uint8Array_fromBase64; + hasRequiredEsnext_uint8Array_fromBase64 = 1; + var $ = require_export(); + var globalThis = requireGlobalThis(); + var arrayFromConstructorAndList = requireArrayFromConstructorAndList(); + var $fromBase64 = requireUint8FromBase64(); + + var Uint8Array = globalThis.Uint8Array; + + // `Uint8Array.fromBase64` method + // https://github.com/tc39/proposal-arraybuffer-base64 + if (Uint8Array) $({ target: 'Uint8Array', stat: true }, { + fromBase64: function fromBase64(string /* , options */) { + var result = $fromBase64(string, arguments.length > 1 ? arguments[1] : undefined, null, 0x1FFFFFFFFFFFFF); + return arrayFromConstructorAndList(Uint8Array, result.bytes); + } + }); + return esnext_uint8Array_fromBase64; +} + +var esnext_uint8Array_fromHex = {}; + +var uint8FromHex; +var hasRequiredUint8FromHex; + +function requireUint8FromHex () { + if (hasRequiredUint8FromHex) return uint8FromHex; + hasRequiredUint8FromHex = 1; + var globalThis = requireGlobalThis(); + var uncurryThis = requireFunctionUncurryThis(); + + var Uint8Array = globalThis.Uint8Array; + var SyntaxError = globalThis.SyntaxError; + var parseInt = globalThis.parseInt; + var min = Math.min; + var NOT_HEX = /[^\da-f]/i; + var exec = uncurryThis(NOT_HEX.exec); + var stringSlice = uncurryThis(''.slice); + + uint8FromHex = function (string, into) { + var stringLength = string.length; + if (stringLength % 2 !== 0) throw new SyntaxError('String should be an even number of characters'); + var maxLength = into ? min(into.length, stringLength / 2) : stringLength / 2; + var bytes = into || new Uint8Array(maxLength); + var read = 0; + var written = 0; + while (written < maxLength) { + var hexits = stringSlice(string, read, read += 2); + if (exec(NOT_HEX, hexits)) throw new SyntaxError('String should only contain hex characters'); + bytes[written++] = parseInt(hexits, 16); + } + return { bytes: bytes, read: read }; + }; + return uint8FromHex; +} + +var hasRequiredEsnext_uint8Array_fromHex; + +function requireEsnext_uint8Array_fromHex () { + if (hasRequiredEsnext_uint8Array_fromHex) return esnext_uint8Array_fromHex; + hasRequiredEsnext_uint8Array_fromHex = 1; + var $ = require_export(); + var globalThis = requireGlobalThis(); + var aString = requireAString(); + var $fromHex = requireUint8FromHex(); + + // `Uint8Array.fromHex` method + // https://github.com/tc39/proposal-arraybuffer-base64 + if (globalThis.Uint8Array) $({ target: 'Uint8Array', stat: true }, { + fromHex: function fromHex(string) { + return $fromHex(aString(string)).bytes; + } + }); + return esnext_uint8Array_fromHex; +} + +var esnext_uint8Array_setFromBase64 = {}; + +var anUint8Array; +var hasRequiredAnUint8Array; + +function requireAnUint8Array () { + if (hasRequiredAnUint8Array) return anUint8Array; + hasRequiredAnUint8Array = 1; + var classof = requireClassof(); + + var $TypeError = TypeError; + + // Perform ? RequireInternalSlot(argument, [[TypedArrayName]]) + // If argument.[[TypedArrayName]] is not "Uint8Array", throw a TypeError exception + anUint8Array = function (argument) { + if (classof(argument) === 'Uint8Array') return argument; + throw new $TypeError('Argument is not an Uint8Array'); + }; + return anUint8Array; +} + +var hasRequiredEsnext_uint8Array_setFromBase64; + +function requireEsnext_uint8Array_setFromBase64 () { + if (hasRequiredEsnext_uint8Array_setFromBase64) return esnext_uint8Array_setFromBase64; + hasRequiredEsnext_uint8Array_setFromBase64 = 1; + var $ = require_export(); + var globalThis = requireGlobalThis(); + var $fromBase64 = requireUint8FromBase64(); + var anUint8Array = requireAnUint8Array(); + + var Uint8Array = globalThis.Uint8Array; + + // `Uint8Array.prototype.setFromBase64` method + // https://github.com/tc39/proposal-arraybuffer-base64 + if (Uint8Array) $({ target: 'Uint8Array', proto: true }, { + setFromBase64: function setFromBase64(string /* , options */) { + anUint8Array(this); + + var result = $fromBase64(string, arguments.length > 1 ? arguments[1] : undefined, this, this.length); + + return { read: result.read, written: result.written }; + } + }); + return esnext_uint8Array_setFromBase64; +} + +var esnext_uint8Array_setFromHex = {}; + +var hasRequiredEsnext_uint8Array_setFromHex; + +function requireEsnext_uint8Array_setFromHex () { + if (hasRequiredEsnext_uint8Array_setFromHex) return esnext_uint8Array_setFromHex; + hasRequiredEsnext_uint8Array_setFromHex = 1; + var $ = require_export(); + var globalThis = requireGlobalThis(); + var aString = requireAString(); + var anUint8Array = requireAnUint8Array(); + var notDetached = requireArrayBufferNotDetached(); + var $fromHex = requireUint8FromHex(); + + // `Uint8Array.prototype.setFromHex` method + // https://github.com/tc39/proposal-arraybuffer-base64 + if (globalThis.Uint8Array) $({ target: 'Uint8Array', proto: true }, { + setFromHex: function setFromHex(string) { + anUint8Array(this); + aString(string); + notDetached(this.buffer); + var read = $fromHex(string, this).read; + return { read: read, written: read / 2 }; + } + }); + return esnext_uint8Array_setFromHex; +} + +var esnext_uint8Array_toBase64 = {}; + +var hasRequiredEsnext_uint8Array_toBase64; + +function requireEsnext_uint8Array_toBase64 () { + if (hasRequiredEsnext_uint8Array_toBase64) return esnext_uint8Array_toBase64; + hasRequiredEsnext_uint8Array_toBase64 = 1; + var $ = require_export(); + var globalThis = requireGlobalThis(); + var uncurryThis = requireFunctionUncurryThis(); + var anObjectOrUndefined = requireAnObjectOrUndefined(); + var anUint8Array = requireAnUint8Array(); + var notDetached = requireArrayBufferNotDetached(); + var base64Map = requireBase64Map(); + var getAlphabetOption = requireGetAlphabetOption(); + + var base64Alphabet = base64Map.i2c; + var base64UrlAlphabet = base64Map.i2cUrl; + + var charAt = uncurryThis(''.charAt); + + // `Uint8Array.prototype.toBase64` method + // https://github.com/tc39/proposal-arraybuffer-base64 + if (globalThis.Uint8Array) $({ target: 'Uint8Array', proto: true }, { + toBase64: function toBase64(/* options */) { + var array = anUint8Array(this); + var options = arguments.length ? anObjectOrUndefined(arguments[0]) : undefined; + var alphabet = getAlphabetOption(options) === 'base64' ? base64Alphabet : base64UrlAlphabet; + var omitPadding = !!options && !!options.omitPadding; + notDetached(this.buffer); + + var result = ''; + var i = 0; + var length = array.length; + var triplet; + + var at = function (shift) { + return charAt(alphabet, (triplet >> (6 * shift)) & 63); + }; + + for (; i + 2 < length; i += 3) { + triplet = (array[i] << 16) + (array[i + 1] << 8) + array[i + 2]; + result += at(3) + at(2) + at(1) + at(0); + } + if (i + 2 === length) { + triplet = (array[i] << 16) + (array[i + 1] << 8); + result += at(3) + at(2) + at(1) + (omitPadding ? '' : '='); + } else if (i + 1 === length) { + triplet = array[i] << 16; + result += at(3) + at(2) + (omitPadding ? '' : '=='); + } + + return result; + } + }); + return esnext_uint8Array_toBase64; +} + +var esnext_uint8Array_toHex = {}; + +var hasRequiredEsnext_uint8Array_toHex; + +function requireEsnext_uint8Array_toHex () { + if (hasRequiredEsnext_uint8Array_toHex) return esnext_uint8Array_toHex; + hasRequiredEsnext_uint8Array_toHex = 1; + var $ = require_export(); + var globalThis = requireGlobalThis(); + var uncurryThis = requireFunctionUncurryThis(); + var anUint8Array = requireAnUint8Array(); + var notDetached = requireArrayBufferNotDetached(); + + var numberToString = uncurryThis(1.0.toString); + + // `Uint8Array.prototype.toHex` method + // https://github.com/tc39/proposal-arraybuffer-base64 + if (globalThis.Uint8Array) $({ target: 'Uint8Array', proto: true }, { + toHex: function toHex() { + anUint8Array(this); + notDetached(this.buffer); + var result = ''; + for (var i = 0, length = this.length; i < length; i++) { + var hex = numberToString(this[i], 16); + result += hex.length === 1 ? '0' + hex : hex; + } + return result; + } + }); + return esnext_uint8Array_toHex; +} + +var esnext_weakMap_deleteAll = {}; + +var aWeakMap; +var hasRequiredAWeakMap; + +function requireAWeakMap () { + if (hasRequiredAWeakMap) return aWeakMap; + hasRequiredAWeakMap = 1; + var has = requireWeakMapHelpers().has; + + // Perform ? RequireInternalSlot(M, [[WeakMapData]]) + aWeakMap = function (it) { + has(it); + return it; + }; + return aWeakMap; +} + +var hasRequiredEsnext_weakMap_deleteAll; + +function requireEsnext_weakMap_deleteAll () { + if (hasRequiredEsnext_weakMap_deleteAll) return esnext_weakMap_deleteAll; + hasRequiredEsnext_weakMap_deleteAll = 1; + var $ = require_export(); + var aWeakMap = requireAWeakMap(); + var remove = requireWeakMapHelpers().remove; + + // `WeakMap.prototype.deleteAll` method + // https://github.com/tc39/proposal-collection-methods + $({ target: 'WeakMap', proto: true, real: true, forced: true }, { + deleteAll: function deleteAll(/* ...elements */) { + var collection = aWeakMap(this); + var allDeleted = true; + var wasDeleted; + for (var k = 0, len = arguments.length; k < len; k++) { + wasDeleted = remove(collection, arguments[k]); + allDeleted = allDeleted && wasDeleted; + } return !!allDeleted; + } + }); + return esnext_weakMap_deleteAll; +} + +var esnext_weakMap_from = {}; + +var hasRequiredEsnext_weakMap_from; + +function requireEsnext_weakMap_from () { + if (hasRequiredEsnext_weakMap_from) return esnext_weakMap_from; + hasRequiredEsnext_weakMap_from = 1; + var $ = require_export(); + var WeakMapHelpers = requireWeakMapHelpers(); + var createCollectionFrom = requireCollectionFrom(); + + // `WeakMap.from` method + // https://tc39.github.io/proposal-setmap-offrom/#sec-weakmap.from + $({ target: 'WeakMap', stat: true, forced: true }, { + from: createCollectionFrom(WeakMapHelpers.WeakMap, WeakMapHelpers.set, true) + }); + return esnext_weakMap_from; +} + +var esnext_weakMap_of = {}; + +var hasRequiredEsnext_weakMap_of; + +function requireEsnext_weakMap_of () { + if (hasRequiredEsnext_weakMap_of) return esnext_weakMap_of; + hasRequiredEsnext_weakMap_of = 1; + var $ = require_export(); + var WeakMapHelpers = requireWeakMapHelpers(); + var createCollectionOf = requireCollectionOf(); + + // `WeakMap.of` method + // https://tc39.github.io/proposal-setmap-offrom/#sec-weakmap.of + $({ target: 'WeakMap', stat: true, forced: true }, { + of: createCollectionOf(WeakMapHelpers.WeakMap, WeakMapHelpers.set, true) + }); + return esnext_weakMap_of; +} + +var esnext_weakMap_emplace = {}; + +var hasRequiredEsnext_weakMap_emplace; + +function requireEsnext_weakMap_emplace () { + if (hasRequiredEsnext_weakMap_emplace) return esnext_weakMap_emplace; + hasRequiredEsnext_weakMap_emplace = 1; + var $ = require_export(); + var aWeakMap = requireAWeakMap(); + var WeakMapHelpers = requireWeakMapHelpers(); + + var get = WeakMapHelpers.get; + var has = WeakMapHelpers.has; + var set = WeakMapHelpers.set; + + // `WeakMap.prototype.emplace` method + // https://github.com/tc39/proposal-upsert + $({ target: 'WeakMap', proto: true, real: true, forced: true }, { + emplace: function emplace(key, handler) { + var map = aWeakMap(this); + var value, inserted; + if (has(map, key)) { + value = get(map, key); + if ('update' in handler) { + value = handler.update(value, key, map); + set(map, key, value); + } return value; + } + inserted = handler.insert(key, map); + set(map, key, inserted); + return inserted; + } + }); + return esnext_weakMap_emplace; +} + +var esnext_weakMap_upsert = {}; + +var hasRequiredEsnext_weakMap_upsert; + +function requireEsnext_weakMap_upsert () { + if (hasRequiredEsnext_weakMap_upsert) return esnext_weakMap_upsert; + hasRequiredEsnext_weakMap_upsert = 1; + // TODO: remove from `core-js@4` + var $ = require_export(); + var upsert = requireMapUpsert(); + + // `WeakMap.prototype.upsert` method (replaced by `WeakMap.prototype.emplace`) + // https://github.com/tc39/proposal-upsert + $({ target: 'WeakMap', proto: true, real: true, forced: true }, { + upsert: upsert + }); + return esnext_weakMap_upsert; +} + +var esnext_weakSet_addAll = {}; + +var weakSetHelpers; +var hasRequiredWeakSetHelpers; + +function requireWeakSetHelpers () { + if (hasRequiredWeakSetHelpers) return weakSetHelpers; + hasRequiredWeakSetHelpers = 1; + var uncurryThis = requireFunctionUncurryThis(); + + // eslint-disable-next-line es/no-weak-set -- safe + var WeakSetPrototype = WeakSet.prototype; + + weakSetHelpers = { + // eslint-disable-next-line es/no-weak-set -- safe + WeakSet: WeakSet, + add: uncurryThis(WeakSetPrototype.add), + has: uncurryThis(WeakSetPrototype.has), + remove: uncurryThis(WeakSetPrototype['delete']) + }; + return weakSetHelpers; +} + +var aWeakSet; +var hasRequiredAWeakSet; + +function requireAWeakSet () { + if (hasRequiredAWeakSet) return aWeakSet; + hasRequiredAWeakSet = 1; + var has = requireWeakSetHelpers().has; + + // Perform ? RequireInternalSlot(M, [[WeakSetData]]) + aWeakSet = function (it) { + has(it); + return it; + }; + return aWeakSet; +} + +var hasRequiredEsnext_weakSet_addAll; + +function requireEsnext_weakSet_addAll () { + if (hasRequiredEsnext_weakSet_addAll) return esnext_weakSet_addAll; + hasRequiredEsnext_weakSet_addAll = 1; + var $ = require_export(); + var aWeakSet = requireAWeakSet(); + var add = requireWeakSetHelpers().add; + + // `WeakSet.prototype.addAll` method + // https://github.com/tc39/proposal-collection-methods + $({ target: 'WeakSet', proto: true, real: true, forced: true }, { + addAll: function addAll(/* ...elements */) { + var set = aWeakSet(this); + for (var k = 0, len = arguments.length; k < len; k++) { + add(set, arguments[k]); + } return set; + } + }); + return esnext_weakSet_addAll; +} + +var esnext_weakSet_deleteAll = {}; + +var hasRequiredEsnext_weakSet_deleteAll; + +function requireEsnext_weakSet_deleteAll () { + if (hasRequiredEsnext_weakSet_deleteAll) return esnext_weakSet_deleteAll; + hasRequiredEsnext_weakSet_deleteAll = 1; + var $ = require_export(); + var aWeakSet = requireAWeakSet(); + var remove = requireWeakSetHelpers().remove; + + // `WeakSet.prototype.deleteAll` method + // https://github.com/tc39/proposal-collection-methods + $({ target: 'WeakSet', proto: true, real: true, forced: true }, { + deleteAll: function deleteAll(/* ...elements */) { + var collection = aWeakSet(this); + var allDeleted = true; + var wasDeleted; + for (var k = 0, len = arguments.length; k < len; k++) { + wasDeleted = remove(collection, arguments[k]); + allDeleted = allDeleted && wasDeleted; + } return !!allDeleted; + } + }); + return esnext_weakSet_deleteAll; +} + +var esnext_weakSet_from = {}; + +var hasRequiredEsnext_weakSet_from; + +function requireEsnext_weakSet_from () { + if (hasRequiredEsnext_weakSet_from) return esnext_weakSet_from; + hasRequiredEsnext_weakSet_from = 1; + var $ = require_export(); + var WeakSetHelpers = requireWeakSetHelpers(); + var createCollectionFrom = requireCollectionFrom(); + + // `WeakSet.from` method + // https://tc39.github.io/proposal-setmap-offrom/#sec-weakset.from + $({ target: 'WeakSet', stat: true, forced: true }, { + from: createCollectionFrom(WeakSetHelpers.WeakSet, WeakSetHelpers.add, false) + }); + return esnext_weakSet_from; +} + +var esnext_weakSet_of = {}; + +var hasRequiredEsnext_weakSet_of; + +function requireEsnext_weakSet_of () { + if (hasRequiredEsnext_weakSet_of) return esnext_weakSet_of; + hasRequiredEsnext_weakSet_of = 1; + var $ = require_export(); + var WeakSetHelpers = requireWeakSetHelpers(); + var createCollectionOf = requireCollectionOf(); + + // `WeakSet.of` method + // https://tc39.github.io/proposal-setmap-offrom/#sec-weakset.of + $({ target: 'WeakSet', stat: true, forced: true }, { + of: createCollectionOf(WeakSetHelpers.WeakSet, WeakSetHelpers.add, false) + }); + return esnext_weakSet_of; +} + +var web_atob = {}; + +var hasRequiredWeb_atob; + +function requireWeb_atob () { + if (hasRequiredWeb_atob) return web_atob; + hasRequiredWeb_atob = 1; + var $ = require_export(); + var globalThis = requireGlobalThis(); + var getBuiltIn = requireGetBuiltIn(); + var uncurryThis = requireFunctionUncurryThis(); + var call = requireFunctionCall(); + var fails = requireFails(); + var toString = requireToString(); + var validateArgumentsLength = requireValidateArgumentsLength(); + var c2i = requireBase64Map().c2i; + + var disallowed = /[^\d+/a-z]/i; + var whitespaces = /[\t\n\f\r ]+/g; + var finalEq = /[=]{1,2}$/; + + var $atob = getBuiltIn('atob'); + var fromCharCode = String.fromCharCode; + var charAt = uncurryThis(''.charAt); + var replace = uncurryThis(''.replace); + var exec = uncurryThis(disallowed.exec); + + var BASIC = !!$atob && !fails(function () { + return $atob('aGk=') !== 'hi'; + }); + + var NO_SPACES_IGNORE = BASIC && fails(function () { + return $atob(' ') !== ''; + }); + + var NO_ENCODING_CHECK = BASIC && !fails(function () { + $atob('a'); + }); + + var NO_ARG_RECEIVING_CHECK = BASIC && !fails(function () { + $atob(); + }); + + var WRONG_ARITY = BASIC && $atob.length !== 1; + + var FORCED = !BASIC || NO_SPACES_IGNORE || NO_ENCODING_CHECK || NO_ARG_RECEIVING_CHECK || WRONG_ARITY; + + // `atob` method + // https://html.spec.whatwg.org/multipage/webappapis.html#dom-atob + $({ global: true, bind: true, enumerable: true, forced: FORCED }, { + atob: function atob(data) { + validateArgumentsLength(arguments.length, 1); + // `webpack` dev server bug on IE global methods - use call(fn, global, ...) + if (BASIC && !NO_SPACES_IGNORE && !NO_ENCODING_CHECK) return call($atob, globalThis, data); + var string = replace(toString(data), whitespaces, ''); + var output = ''; + var position = 0; + var bc = 0; + var length, chr, bs; + if (string.length % 4 === 0) { + string = replace(string, finalEq, ''); + } + length = string.length; + if (length % 4 === 1 || exec(disallowed, string)) { + throw new (getBuiltIn('DOMException'))('The string is not correctly encoded', 'InvalidCharacterError'); + } + while (position < length) { + chr = charAt(string, position++); + bs = bc % 4 ? bs * 64 + c2i[chr] : c2i[chr]; + if (bc++ % 4) output += fromCharCode(255 & bs >> (-2 * bc & 6)); + } return output; + } + }); + return web_atob; +} + +var web_btoa = {}; + +var hasRequiredWeb_btoa; + +function requireWeb_btoa () { + if (hasRequiredWeb_btoa) return web_btoa; + hasRequiredWeb_btoa = 1; + var $ = require_export(); + var globalThis = requireGlobalThis(); + var getBuiltIn = requireGetBuiltIn(); + var uncurryThis = requireFunctionUncurryThis(); + var call = requireFunctionCall(); + var fails = requireFails(); + var toString = requireToString(); + var validateArgumentsLength = requireValidateArgumentsLength(); + var i2c = requireBase64Map().i2c; + + var $btoa = getBuiltIn('btoa'); + var charAt = uncurryThis(''.charAt); + var charCodeAt = uncurryThis(''.charCodeAt); + + var BASIC = !!$btoa && !fails(function () { + return $btoa('hi') !== 'aGk='; + }); + + var NO_ARG_RECEIVING_CHECK = BASIC && !fails(function () { + $btoa(); + }); + + var WRONG_ARG_CONVERSION = BASIC && fails(function () { + return $btoa(null) !== 'bnVsbA=='; + }); + + var WRONG_ARITY = BASIC && $btoa.length !== 1; + + // `btoa` method + // https://html.spec.whatwg.org/multipage/webappapis.html#dom-btoa + $({ global: true, bind: true, enumerable: true, forced: !BASIC || NO_ARG_RECEIVING_CHECK || WRONG_ARG_CONVERSION || WRONG_ARITY }, { + btoa: function btoa(data) { + validateArgumentsLength(arguments.length, 1); + // `webpack` dev server bug on IE global methods - use call(fn, global, ...) + if (BASIC) return call($btoa, globalThis, toString(data)); + var string = toString(data); + var output = ''; + var position = 0; + var map = i2c; + var block, charCode; + while (charAt(string, position) || (map = '=', position % 1)) { + charCode = charCodeAt(string, position += 3 / 4); + if (charCode > 0xFF) { + throw new (getBuiltIn('DOMException'))('The string contains characters outside of the Latin1 range', 'InvalidCharacterError'); + } + block = block << 8 | charCode; + output += charAt(map, 63 & block >> 8 - position % 1 * 8); + } return output; + } + }); + return web_btoa; +} + +var web_domCollections_forEach = {}; + +var domIterables; +var hasRequiredDomIterables; + +function requireDomIterables () { + if (hasRequiredDomIterables) return domIterables; + hasRequiredDomIterables = 1; + // iterable DOM collections + // flag - `iterable` interface - 'entries', 'keys', 'values', 'forEach' methods + domIterables = { + CSSRuleList: 0, + CSSStyleDeclaration: 0, + CSSValueList: 0, + ClientRectList: 0, + DOMRectList: 0, + DOMStringList: 0, + DOMTokenList: 1, + DataTransferItemList: 0, + FileList: 0, + HTMLAllCollection: 0, + HTMLCollection: 0, + HTMLFormElement: 0, + HTMLSelectElement: 0, + MediaList: 0, + MimeTypeArray: 0, + NamedNodeMap: 0, + NodeList: 1, + PaintRequestList: 0, + Plugin: 0, + PluginArray: 0, + SVGLengthList: 0, + SVGNumberList: 0, + SVGPathSegList: 0, + SVGPointList: 0, + SVGStringList: 0, + SVGTransformList: 0, + SourceBufferList: 0, + StyleSheetList: 0, + TextTrackCueList: 0, + TextTrackList: 0, + TouchList: 0 + }; + return domIterables; +} + +var domTokenListPrototype; +var hasRequiredDomTokenListPrototype; + +function requireDomTokenListPrototype () { + if (hasRequiredDomTokenListPrototype) return domTokenListPrototype; + hasRequiredDomTokenListPrototype = 1; + // in old WebKit versions, `element.classList` is not an instance of global `DOMTokenList` + var documentCreateElement = requireDocumentCreateElement(); + + var classList = documentCreateElement('span').classList; + var DOMTokenListPrototype = classList && classList.constructor && classList.constructor.prototype; + + domTokenListPrototype = DOMTokenListPrototype === Object.prototype ? undefined : DOMTokenListPrototype; + return domTokenListPrototype; +} + +var hasRequiredWeb_domCollections_forEach; + +function requireWeb_domCollections_forEach () { + if (hasRequiredWeb_domCollections_forEach) return web_domCollections_forEach; + hasRequiredWeb_domCollections_forEach = 1; + var globalThis = requireGlobalThis(); + var DOMIterables = requireDomIterables(); + var DOMTokenListPrototype = requireDomTokenListPrototype(); + var forEach = requireArrayForEach(); + var createNonEnumerableProperty = requireCreateNonEnumerableProperty(); + + var handlePrototype = function (CollectionPrototype) { + // some Chrome versions have non-configurable methods on DOMTokenList + if (CollectionPrototype && CollectionPrototype.forEach !== forEach) try { + createNonEnumerableProperty(CollectionPrototype, 'forEach', forEach); + } catch (error) { + CollectionPrototype.forEach = forEach; + } + }; + + for (var COLLECTION_NAME in DOMIterables) { + if (DOMIterables[COLLECTION_NAME]) { + handlePrototype(globalThis[COLLECTION_NAME] && globalThis[COLLECTION_NAME].prototype); + } + } + + handlePrototype(DOMTokenListPrototype); + return web_domCollections_forEach; +} + +var web_domCollections_iterator = {}; + +var hasRequiredWeb_domCollections_iterator; + +function requireWeb_domCollections_iterator () { + if (hasRequiredWeb_domCollections_iterator) return web_domCollections_iterator; + hasRequiredWeb_domCollections_iterator = 1; + var globalThis = requireGlobalThis(); + var DOMIterables = requireDomIterables(); + var DOMTokenListPrototype = requireDomTokenListPrototype(); + var ArrayIteratorMethods = requireEs_array_iterator(); + var createNonEnumerableProperty = requireCreateNonEnumerableProperty(); + var setToStringTag = requireSetToStringTag(); + var wellKnownSymbol = requireWellKnownSymbol(); + + var ITERATOR = wellKnownSymbol('iterator'); + var ArrayValues = ArrayIteratorMethods.values; + + var handlePrototype = function (CollectionPrototype, COLLECTION_NAME) { + if (CollectionPrototype) { + // some Chrome versions have non-configurable methods on DOMTokenList + if (CollectionPrototype[ITERATOR] !== ArrayValues) try { + createNonEnumerableProperty(CollectionPrototype, ITERATOR, ArrayValues); + } catch (error) { + CollectionPrototype[ITERATOR] = ArrayValues; + } + setToStringTag(CollectionPrototype, COLLECTION_NAME, true); + if (DOMIterables[COLLECTION_NAME]) for (var METHOD_NAME in ArrayIteratorMethods) { + // some Chrome versions have non-configurable methods on DOMTokenList + if (CollectionPrototype[METHOD_NAME] !== ArrayIteratorMethods[METHOD_NAME]) try { + createNonEnumerableProperty(CollectionPrototype, METHOD_NAME, ArrayIteratorMethods[METHOD_NAME]); + } catch (error) { + CollectionPrototype[METHOD_NAME] = ArrayIteratorMethods[METHOD_NAME]; + } + } + } + }; + + for (var COLLECTION_NAME in DOMIterables) { + handlePrototype(globalThis[COLLECTION_NAME] && globalThis[COLLECTION_NAME].prototype, COLLECTION_NAME); + } + + handlePrototype(DOMTokenListPrototype, 'DOMTokenList'); + return web_domCollections_iterator; +} + +var web_domException_constructor = {}; + +var domExceptionConstants; +var hasRequiredDomExceptionConstants; + +function requireDomExceptionConstants () { + if (hasRequiredDomExceptionConstants) return domExceptionConstants; + hasRequiredDomExceptionConstants = 1; + domExceptionConstants = { + IndexSizeError: { s: 'INDEX_SIZE_ERR', c: 1, m: 1 }, + DOMStringSizeError: { s: 'DOMSTRING_SIZE_ERR', c: 2, m: 0 }, + HierarchyRequestError: { s: 'HIERARCHY_REQUEST_ERR', c: 3, m: 1 }, + WrongDocumentError: { s: 'WRONG_DOCUMENT_ERR', c: 4, m: 1 }, + InvalidCharacterError: { s: 'INVALID_CHARACTER_ERR', c: 5, m: 1 }, + NoDataAllowedError: { s: 'NO_DATA_ALLOWED_ERR', c: 6, m: 0 }, + NoModificationAllowedError: { s: 'NO_MODIFICATION_ALLOWED_ERR', c: 7, m: 1 }, + NotFoundError: { s: 'NOT_FOUND_ERR', c: 8, m: 1 }, + NotSupportedError: { s: 'NOT_SUPPORTED_ERR', c: 9, m: 1 }, + InUseAttributeError: { s: 'INUSE_ATTRIBUTE_ERR', c: 10, m: 1 }, + InvalidStateError: { s: 'INVALID_STATE_ERR', c: 11, m: 1 }, + SyntaxError: { s: 'SYNTAX_ERR', c: 12, m: 1 }, + InvalidModificationError: { s: 'INVALID_MODIFICATION_ERR', c: 13, m: 1 }, + NamespaceError: { s: 'NAMESPACE_ERR', c: 14, m: 1 }, + InvalidAccessError: { s: 'INVALID_ACCESS_ERR', c: 15, m: 1 }, + ValidationError: { s: 'VALIDATION_ERR', c: 16, m: 0 }, + TypeMismatchError: { s: 'TYPE_MISMATCH_ERR', c: 17, m: 1 }, + SecurityError: { s: 'SECURITY_ERR', c: 18, m: 1 }, + NetworkError: { s: 'NETWORK_ERR', c: 19, m: 1 }, + AbortError: { s: 'ABORT_ERR', c: 20, m: 1 }, + URLMismatchError: { s: 'URL_MISMATCH_ERR', c: 21, m: 1 }, + QuotaExceededError: { s: 'QUOTA_EXCEEDED_ERR', c: 22, m: 1 }, + TimeoutError: { s: 'TIMEOUT_ERR', c: 23, m: 1 }, + InvalidNodeTypeError: { s: 'INVALID_NODE_TYPE_ERR', c: 24, m: 1 }, + DataCloneError: { s: 'DATA_CLONE_ERR', c: 25, m: 1 } + }; + return domExceptionConstants; +} + +var hasRequiredWeb_domException_constructor; + +function requireWeb_domException_constructor () { + if (hasRequiredWeb_domException_constructor) return web_domException_constructor; + hasRequiredWeb_domException_constructor = 1; + var $ = require_export(); + var getBuiltIn = requireGetBuiltIn(); + var getBuiltInNodeModule = requireGetBuiltInNodeModule(); + var fails = requireFails(); + var create = requireObjectCreate(); + var createPropertyDescriptor = requireCreatePropertyDescriptor(); + var defineProperty = requireObjectDefineProperty().f; + var defineBuiltIn = requireDefineBuiltIn(); + var defineBuiltInAccessor = requireDefineBuiltInAccessor(); + var hasOwn = requireHasOwnProperty(); + var anInstance = requireAnInstance(); + var anObject = requireAnObject(); + var errorToString = requireErrorToString(); + var normalizeStringArgument = requireNormalizeStringArgument(); + var DOMExceptionConstants = requireDomExceptionConstants(); + var clearErrorStack = requireErrorStackClear(); + var InternalStateModule = requireInternalState(); + var DESCRIPTORS = requireDescriptors(); + var IS_PURE = requireIsPure(); + + var DOM_EXCEPTION = 'DOMException'; + var DATA_CLONE_ERR = 'DATA_CLONE_ERR'; + var Error = getBuiltIn('Error'); + // NodeJS < 17.0 does not expose `DOMException` to global + var NativeDOMException = getBuiltIn(DOM_EXCEPTION) || (function () { + try { + // NodeJS < 15.0 does not expose `MessageChannel` to global + var MessageChannel = getBuiltIn('MessageChannel') || getBuiltInNodeModule('worker_threads').MessageChannel; + // eslint-disable-next-line es/no-weak-map, unicorn/require-post-message-target-origin -- safe + new MessageChannel().port1.postMessage(new WeakMap()); + } catch (error) { + if (error.name === DATA_CLONE_ERR && error.code === 25) return error.constructor; + } + })(); + var NativeDOMExceptionPrototype = NativeDOMException && NativeDOMException.prototype; + var ErrorPrototype = Error.prototype; + var setInternalState = InternalStateModule.set; + var getInternalState = InternalStateModule.getterFor(DOM_EXCEPTION); + var HAS_STACK = 'stack' in new Error(DOM_EXCEPTION); + + var codeFor = function (name) { + return hasOwn(DOMExceptionConstants, name) && DOMExceptionConstants[name].m ? DOMExceptionConstants[name].c : 0; + }; + + var $DOMException = function DOMException() { + anInstance(this, DOMExceptionPrototype); + var argumentsLength = arguments.length; + var message = normalizeStringArgument(argumentsLength < 1 ? undefined : arguments[0]); + var name = normalizeStringArgument(argumentsLength < 2 ? undefined : arguments[1], 'Error'); + var code = codeFor(name); + setInternalState(this, { + type: DOM_EXCEPTION, + name: name, + message: message, + code: code + }); + if (!DESCRIPTORS) { + this.name = name; + this.message = message; + this.code = code; + } + if (HAS_STACK) { + var error = new Error(message); + error.name = DOM_EXCEPTION; + defineProperty(this, 'stack', createPropertyDescriptor(1, clearErrorStack(error.stack, 1))); + } + }; + + var DOMExceptionPrototype = $DOMException.prototype = create(ErrorPrototype); + + var createGetterDescriptor = function (get) { + return { enumerable: true, configurable: true, get: get }; + }; + + var getterFor = function (key) { + return createGetterDescriptor(function () { + return getInternalState(this)[key]; + }); + }; + + if (DESCRIPTORS) { + // `DOMException.prototype.code` getter + defineBuiltInAccessor(DOMExceptionPrototype, 'code', getterFor('code')); + // `DOMException.prototype.message` getter + defineBuiltInAccessor(DOMExceptionPrototype, 'message', getterFor('message')); + // `DOMException.prototype.name` getter + defineBuiltInAccessor(DOMExceptionPrototype, 'name', getterFor('name')); + } + + defineProperty(DOMExceptionPrototype, 'constructor', createPropertyDescriptor(1, $DOMException)); + + // FF36- DOMException is a function, but can't be constructed + var INCORRECT_CONSTRUCTOR = fails(function () { + return !(new NativeDOMException() instanceof Error); + }); + + // Safari 10.1 / Chrome 32- / IE8- DOMException.prototype.toString bugs + var INCORRECT_TO_STRING = INCORRECT_CONSTRUCTOR || fails(function () { + return ErrorPrototype.toString !== errorToString || String(new NativeDOMException(1, 2)) !== '2: 1'; + }); + + // Deno 1.6.3- DOMException.prototype.code just missed + var INCORRECT_CODE = INCORRECT_CONSTRUCTOR || fails(function () { + return new NativeDOMException(1, 'DataCloneError').code !== 25; + }); + + // Deno 1.6.3- DOMException constants just missed + var MISSED_CONSTANTS = INCORRECT_CONSTRUCTOR + || NativeDOMException[DATA_CLONE_ERR] !== 25 + || NativeDOMExceptionPrototype[DATA_CLONE_ERR] !== 25; + + var FORCED_CONSTRUCTOR = IS_PURE ? INCORRECT_TO_STRING || INCORRECT_CODE || MISSED_CONSTANTS : INCORRECT_CONSTRUCTOR; + + // `DOMException` constructor + // https://webidl.spec.whatwg.org/#idl-DOMException + $({ global: true, constructor: true, forced: FORCED_CONSTRUCTOR }, { + DOMException: FORCED_CONSTRUCTOR ? $DOMException : NativeDOMException + }); + + var PolyfilledDOMException = getBuiltIn(DOM_EXCEPTION); + var PolyfilledDOMExceptionPrototype = PolyfilledDOMException.prototype; + + if (INCORRECT_TO_STRING && (IS_PURE || NativeDOMException === PolyfilledDOMException)) { + defineBuiltIn(PolyfilledDOMExceptionPrototype, 'toString', errorToString); + } + + if (INCORRECT_CODE && DESCRIPTORS && NativeDOMException === PolyfilledDOMException) { + defineBuiltInAccessor(PolyfilledDOMExceptionPrototype, 'code', createGetterDescriptor(function () { + return codeFor(anObject(this).name); + })); + } + + // `DOMException` constants + for (var key in DOMExceptionConstants) if (hasOwn(DOMExceptionConstants, key)) { + var constant = DOMExceptionConstants[key]; + var constantName = constant.s; + var descriptor = createPropertyDescriptor(6, constant.c); + if (!hasOwn(PolyfilledDOMException, constantName)) { + defineProperty(PolyfilledDOMException, constantName, descriptor); + } + if (!hasOwn(PolyfilledDOMExceptionPrototype, constantName)) { + defineProperty(PolyfilledDOMExceptionPrototype, constantName, descriptor); + } + } + return web_domException_constructor; +} + +var web_domException_stack = {}; + +var hasRequiredWeb_domException_stack; + +function requireWeb_domException_stack () { + if (hasRequiredWeb_domException_stack) return web_domException_stack; + hasRequiredWeb_domException_stack = 1; + var $ = require_export(); + var globalThis = requireGlobalThis(); + var getBuiltIn = requireGetBuiltIn(); + var createPropertyDescriptor = requireCreatePropertyDescriptor(); + var defineProperty = requireObjectDefineProperty().f; + var hasOwn = requireHasOwnProperty(); + var anInstance = requireAnInstance(); + var inheritIfRequired = requireInheritIfRequired(); + var normalizeStringArgument = requireNormalizeStringArgument(); + var DOMExceptionConstants = requireDomExceptionConstants(); + var clearErrorStack = requireErrorStackClear(); + var DESCRIPTORS = requireDescriptors(); + var IS_PURE = requireIsPure(); + + var DOM_EXCEPTION = 'DOMException'; + var Error = getBuiltIn('Error'); + var NativeDOMException = getBuiltIn(DOM_EXCEPTION); + + var $DOMException = function DOMException() { + anInstance(this, DOMExceptionPrototype); + var argumentsLength = arguments.length; + var message = normalizeStringArgument(argumentsLength < 1 ? undefined : arguments[0]); + var name = normalizeStringArgument(argumentsLength < 2 ? undefined : arguments[1], 'Error'); + var that = new NativeDOMException(message, name); + var error = new Error(message); + error.name = DOM_EXCEPTION; + defineProperty(that, 'stack', createPropertyDescriptor(1, clearErrorStack(error.stack, 1))); + inheritIfRequired(that, this, $DOMException); + return that; + }; + + var DOMExceptionPrototype = $DOMException.prototype = NativeDOMException.prototype; + + var ERROR_HAS_STACK = 'stack' in new Error(DOM_EXCEPTION); + var DOM_EXCEPTION_HAS_STACK = 'stack' in new NativeDOMException(1, 2); + + // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe + var descriptor = NativeDOMException && DESCRIPTORS && Object.getOwnPropertyDescriptor(globalThis, DOM_EXCEPTION); + + // Bun ~ 0.1.1 DOMException have incorrect descriptor and we can't redefine it + // https://github.com/Jarred-Sumner/bun/issues/399 + var BUGGY_DESCRIPTOR = !!descriptor && !(descriptor.writable && descriptor.configurable); + + var FORCED_CONSTRUCTOR = ERROR_HAS_STACK && !BUGGY_DESCRIPTOR && !DOM_EXCEPTION_HAS_STACK; + + // `DOMException` constructor patch for `.stack` where it's required + // https://webidl.spec.whatwg.org/#es-DOMException-specialness + $({ global: true, constructor: true, forced: IS_PURE || FORCED_CONSTRUCTOR }, { // TODO: fix export logic + DOMException: FORCED_CONSTRUCTOR ? $DOMException : NativeDOMException + }); + + var PolyfilledDOMException = getBuiltIn(DOM_EXCEPTION); + var PolyfilledDOMExceptionPrototype = PolyfilledDOMException.prototype; + + if (PolyfilledDOMExceptionPrototype.constructor !== PolyfilledDOMException) { + if (!IS_PURE) { + defineProperty(PolyfilledDOMExceptionPrototype, 'constructor', createPropertyDescriptor(1, PolyfilledDOMException)); + } + + for (var key in DOMExceptionConstants) if (hasOwn(DOMExceptionConstants, key)) { + var constant = DOMExceptionConstants[key]; + var constantName = constant.s; + if (!hasOwn(PolyfilledDOMException, constantName)) { + defineProperty(PolyfilledDOMException, constantName, createPropertyDescriptor(6, constant.c)); + } + } + } + return web_domException_stack; +} + +var web_domException_toStringTag = {}; + +var hasRequiredWeb_domException_toStringTag; + +function requireWeb_domException_toStringTag () { + if (hasRequiredWeb_domException_toStringTag) return web_domException_toStringTag; + hasRequiredWeb_domException_toStringTag = 1; + var getBuiltIn = requireGetBuiltIn(); + var setToStringTag = requireSetToStringTag(); + + var DOM_EXCEPTION = 'DOMException'; + + // `DOMException.prototype[@@toStringTag]` property + setToStringTag(getBuiltIn(DOM_EXCEPTION), DOM_EXCEPTION); + return web_domException_toStringTag; +} + +var web_immediate = {}; + +var web_clearImmediate = {}; + +var hasRequiredWeb_clearImmediate; + +function requireWeb_clearImmediate () { + if (hasRequiredWeb_clearImmediate) return web_clearImmediate; + hasRequiredWeb_clearImmediate = 1; + var $ = require_export(); + var globalThis = requireGlobalThis(); + var clearImmediate = requireTask().clear; + + // `clearImmediate` method + // http://w3c.github.io/setImmediate/#si-clearImmediate + $({ global: true, bind: true, enumerable: true, forced: globalThis.clearImmediate !== clearImmediate }, { + clearImmediate: clearImmediate + }); + return web_clearImmediate; +} + +var web_setImmediate = {}; + +var schedulersFix; +var hasRequiredSchedulersFix; + +function requireSchedulersFix () { + if (hasRequiredSchedulersFix) return schedulersFix; + hasRequiredSchedulersFix = 1; + var globalThis = requireGlobalThis(); + var apply = requireFunctionApply(); + var isCallable = requireIsCallable(); + var ENVIRONMENT = requireEnvironment(); + var USER_AGENT = requireEnvironmentUserAgent(); + var arraySlice = requireArraySlice(); + var validateArgumentsLength = requireValidateArgumentsLength(); + + var Function = globalThis.Function; + // dirty IE9- and Bun 0.3.0- checks + var WRAP = /MSIE .\./.test(USER_AGENT) || ENVIRONMENT === 'BUN' && (function () { + var version = globalThis.Bun.version.split('.'); + return version.length < 3 || version[0] === '0' && (version[1] < 3 || version[1] === '3' && version[2] === '0'); + })(); + + // IE9- / Bun 0.3.0- setTimeout / setInterval / setImmediate additional parameters fix + // https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#timers + // https://github.com/oven-sh/bun/issues/1633 + schedulersFix = function (scheduler, hasTimeArg) { + var firstParamIndex = hasTimeArg ? 2 : 1; + return WRAP ? function (handler, timeout /* , ...arguments */) { + var boundArgs = validateArgumentsLength(arguments.length, 1) > firstParamIndex; + var fn = isCallable(handler) ? handler : Function(handler); + var params = boundArgs ? arraySlice(arguments, firstParamIndex) : []; + var callback = boundArgs ? function () { + apply(fn, this, params); + } : fn; + return hasTimeArg ? scheduler(callback, timeout) : scheduler(callback); + } : scheduler; + }; + return schedulersFix; +} + +var hasRequiredWeb_setImmediate; + +function requireWeb_setImmediate () { + if (hasRequiredWeb_setImmediate) return web_setImmediate; + hasRequiredWeb_setImmediate = 1; + var $ = require_export(); + var globalThis = requireGlobalThis(); + var setTask = requireTask().set; + var schedulersFix = requireSchedulersFix(); + + // https://github.com/oven-sh/bun/issues/1633 + var setImmediate = globalThis.setImmediate ? schedulersFix(setTask, false) : setTask; + + // `setImmediate` method + // http://w3c.github.io/setImmediate/#si-setImmediate + $({ global: true, bind: true, enumerable: true, forced: globalThis.setImmediate !== setImmediate }, { + setImmediate: setImmediate + }); + return web_setImmediate; +} + +var hasRequiredWeb_immediate; + +function requireWeb_immediate () { + if (hasRequiredWeb_immediate) return web_immediate; + hasRequiredWeb_immediate = 1; + // TODO: Remove this module from `core-js@4` since it's split to modules listed below + requireWeb_clearImmediate(); + requireWeb_setImmediate(); + return web_immediate; +} + +var web_queueMicrotask = {}; + +var hasRequiredWeb_queueMicrotask; + +function requireWeb_queueMicrotask () { + if (hasRequiredWeb_queueMicrotask) return web_queueMicrotask; + hasRequiredWeb_queueMicrotask = 1; + var $ = require_export(); + var globalThis = requireGlobalThis(); + var microtask = requireMicrotask(); + var aCallable = requireACallable(); + var validateArgumentsLength = requireValidateArgumentsLength(); + var fails = requireFails(); + var DESCRIPTORS = requireDescriptors(); + + // Bun ~ 1.0.30 bug + // https://github.com/oven-sh/bun/issues/9249 + var WRONG_ARITY = fails(function () { + // getOwnPropertyDescriptor for prevent experimental warning in Node 11 + // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe + return DESCRIPTORS && Object.getOwnPropertyDescriptor(globalThis, 'queueMicrotask').value.length !== 1; + }); + + // `queueMicrotask` method + // https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#dom-queuemicrotask + $({ global: true, enumerable: true, dontCallGetSet: true, forced: WRONG_ARITY }, { + queueMicrotask: function queueMicrotask(fn) { + validateArgumentsLength(arguments.length, 1); + microtask(aCallable(fn)); + } + }); + return web_queueMicrotask; +} + +var web_self = {}; + +var hasRequiredWeb_self; + +function requireWeb_self () { + if (hasRequiredWeb_self) return web_self; + hasRequiredWeb_self = 1; + var $ = require_export(); + var globalThis = requireGlobalThis(); + var defineBuiltInAccessor = requireDefineBuiltInAccessor(); + var DESCRIPTORS = requireDescriptors(); + + var $TypeError = TypeError; + // eslint-disable-next-line es/no-object-defineproperty -- safe + var defineProperty = Object.defineProperty; + var INCORRECT_VALUE = globalThis.self !== globalThis; + + // `self` getter + // https://html.spec.whatwg.org/multipage/window-object.html#dom-self + try { + if (DESCRIPTORS) { + // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe + var descriptor = Object.getOwnPropertyDescriptor(globalThis, 'self'); + // some engines have `self`, but with incorrect descriptor + // https://github.com/denoland/deno/issues/15765 + if (INCORRECT_VALUE || !descriptor || !descriptor.get || !descriptor.enumerable) { + defineBuiltInAccessor(globalThis, 'self', { + get: function self() { + return globalThis; + }, + set: function self(value) { + if (this !== globalThis) throw new $TypeError('Illegal invocation'); + defineProperty(globalThis, 'self', { + value: value, + writable: true, + configurable: true, + enumerable: true + }); + }, + configurable: true, + enumerable: true + }); + } + } else $({ global: true, simple: true, forced: INCORRECT_VALUE }, { + self: globalThis + }); + } catch (error) { /* empty */ } + return web_self; +} + +var web_structuredClone = {}; + +var hasRequiredWeb_structuredClone; + +function requireWeb_structuredClone () { + if (hasRequiredWeb_structuredClone) return web_structuredClone; + hasRequiredWeb_structuredClone = 1; + var IS_PURE = requireIsPure(); + var $ = require_export(); + var globalThis = requireGlobalThis(); + var getBuiltIn = requireGetBuiltIn(); + var uncurryThis = requireFunctionUncurryThis(); + var fails = requireFails(); + var uid = requireUid(); + var isCallable = requireIsCallable(); + var isConstructor = requireIsConstructor(); + var isNullOrUndefined = requireIsNullOrUndefined(); + var isObject = requireIsObject(); + var isSymbol = requireIsSymbol(); + var iterate = requireIterate(); + var anObject = requireAnObject(); + var classof = requireClassof(); + var hasOwn = requireHasOwnProperty(); + var createProperty = requireCreateProperty(); + var createNonEnumerableProperty = requireCreateNonEnumerableProperty(); + var lengthOfArrayLike = requireLengthOfArrayLike(); + var validateArgumentsLength = requireValidateArgumentsLength(); + var getRegExpFlags = requireRegexpGetFlags(); + var MapHelpers = requireMapHelpers(); + var SetHelpers = requireSetHelpers(); + var setIterate = requireSetIterate(); + var detachTransferable = requireDetachTransferable(); + var ERROR_STACK_INSTALLABLE = requireErrorStackInstallable(); + var PROPER_STRUCTURED_CLONE_TRANSFER = requireStructuredCloneProperTransfer(); + + var Object = globalThis.Object; + var Array = globalThis.Array; + var Date = globalThis.Date; + var Error = globalThis.Error; + var TypeError = globalThis.TypeError; + var PerformanceMark = globalThis.PerformanceMark; + var DOMException = getBuiltIn('DOMException'); + var Map = MapHelpers.Map; + var mapHas = MapHelpers.has; + var mapGet = MapHelpers.get; + var mapSet = MapHelpers.set; + var Set = SetHelpers.Set; + var setAdd = SetHelpers.add; + var setHas = SetHelpers.has; + var objectKeys = getBuiltIn('Object', 'keys'); + var push = uncurryThis([].push); + var thisBooleanValue = uncurryThis(true.valueOf); + var thisNumberValue = uncurryThis(1.0.valueOf); + var thisStringValue = uncurryThis(''.valueOf); + var thisTimeValue = uncurryThis(Date.prototype.getTime); + var PERFORMANCE_MARK = uid('structuredClone'); + var DATA_CLONE_ERROR = 'DataCloneError'; + var TRANSFERRING = 'Transferring'; + + var checkBasicSemantic = function (structuredCloneImplementation) { + return !fails(function () { + var set1 = new globalThis.Set([7]); + var set2 = structuredCloneImplementation(set1); + var number = structuredCloneImplementation(Object(7)); + return set2 === set1 || !set2.has(7) || !isObject(number) || +number !== 7; + }) && structuredCloneImplementation; + }; + + var checkErrorsCloning = function (structuredCloneImplementation, $Error) { + return !fails(function () { + var error = new $Error(); + var test = structuredCloneImplementation({ a: error, b: error }); + return !(test && test.a === test.b && test.a instanceof $Error && test.a.stack === error.stack); + }); + }; + + // https://github.com/whatwg/html/pull/5749 + var checkNewErrorsCloningSemantic = function (structuredCloneImplementation) { + return !fails(function () { + var test = structuredCloneImplementation(new globalThis.AggregateError([1], PERFORMANCE_MARK, { cause: 3 })); + return test.name !== 'AggregateError' || test.errors[0] !== 1 || test.message !== PERFORMANCE_MARK || test.cause !== 3; + }); + }; + + // FF94+, Safari 15.4+, Chrome 98+, NodeJS 17.0+, Deno 1.13+ + // FF<103 and Safari implementations can't clone errors + // https://bugzilla.mozilla.org/show_bug.cgi?id=1556604 + // FF103 can clone errors, but `.stack` of clone is an empty string + // https://bugzilla.mozilla.org/show_bug.cgi?id=1778762 + // FF104+ fixed it on usual errors, but not on DOMExceptions + // https://bugzilla.mozilla.org/show_bug.cgi?id=1777321 + // Chrome <102 returns `null` if cloned object contains multiple references to one error + // https://bugs.chromium.org/p/v8/issues/detail?id=12542 + // NodeJS implementation can't clone DOMExceptions + // https://github.com/nodejs/node/issues/41038 + // only FF103+ supports new (html/5749) error cloning semantic + var nativeStructuredClone = globalThis.structuredClone; + + var FORCED_REPLACEMENT = IS_PURE + || !checkErrorsCloning(nativeStructuredClone, Error) + || !checkErrorsCloning(nativeStructuredClone, DOMException) + || !checkNewErrorsCloningSemantic(nativeStructuredClone); + + // Chrome 82+, Safari 14.1+, Deno 1.11+ + // Chrome 78-81 implementation swaps `.name` and `.message` of cloned `DOMException` + // Chrome returns `null` if cloned object contains multiple references to one error + // Safari 14.1 implementation doesn't clone some `RegExp` flags, so requires a workaround + // Safari implementation can't clone errors + // Deno 1.2-1.10 implementations too naive + // NodeJS 16.0+ does not have `PerformanceMark` constructor + // NodeJS <17.2 structured cloning implementation from `performance.mark` is too naive + // and can't clone, for example, `RegExp` or some boxed primitives + // https://github.com/nodejs/node/issues/40840 + // no one of those implementations supports new (html/5749) error cloning semantic + var structuredCloneFromMark = !nativeStructuredClone && checkBasicSemantic(function (value) { + return new PerformanceMark(PERFORMANCE_MARK, { detail: value }).detail; + }); + + var nativeRestrictedStructuredClone = checkBasicSemantic(nativeStructuredClone) || structuredCloneFromMark; + + var throwUncloneable = function (type) { + throw new DOMException('Uncloneable type: ' + type, DATA_CLONE_ERROR); + }; + + var throwUnpolyfillable = function (type, action) { + throw new DOMException((action || 'Cloning') + ' of ' + type + ' cannot be properly polyfilled in this engine', DATA_CLONE_ERROR); + }; + + var tryNativeRestrictedStructuredClone = function (value, type) { + if (!nativeRestrictedStructuredClone) throwUnpolyfillable(type); + return nativeRestrictedStructuredClone(value); + }; + + var createDataTransfer = function () { + var dataTransfer; + try { + dataTransfer = new globalThis.DataTransfer(); + } catch (error) { + try { + dataTransfer = new globalThis.ClipboardEvent('').clipboardData; + } catch (error2) { /* empty */ } + } + return dataTransfer && dataTransfer.items && dataTransfer.files ? dataTransfer : null; + }; + + var cloneBuffer = function (value, map, $type) { + if (mapHas(map, value)) return mapGet(map, value); + + var type = $type || classof(value); + var clone, length, options, source, target, i; + + if (type === 'SharedArrayBuffer') { + if (nativeRestrictedStructuredClone) clone = nativeRestrictedStructuredClone(value); + // SharedArrayBuffer should use shared memory, we can't polyfill it, so return the original + else clone = value; + } else { + var DataView = globalThis.DataView; + + // `ArrayBuffer#slice` is not available in IE10 + // `ArrayBuffer#slice` and `DataView` are not available in old FF + if (!DataView && !isCallable(value.slice)) throwUnpolyfillable('ArrayBuffer'); + // detached buffers throws in `DataView` and `.slice` + try { + if (isCallable(value.slice) && !value.resizable) { + clone = value.slice(0); + } else { + length = value.byteLength; + options = 'maxByteLength' in value ? { maxByteLength: value.maxByteLength } : undefined; + // eslint-disable-next-line es/no-resizable-and-growable-arraybuffers -- safe + clone = new ArrayBuffer(length, options); + source = new DataView(value); + target = new DataView(clone); + for (i = 0; i < length; i++) { + target.setUint8(i, source.getUint8(i)); + } + } + } catch (error) { + throw new DOMException('ArrayBuffer is detached', DATA_CLONE_ERROR); + } + } + + mapSet(map, value, clone); + + return clone; + }; + + var cloneView = function (value, type, offset, length, map) { + var C = globalThis[type]; + // in some old engines like Safari 9, typeof C is 'object' + // on Uint8ClampedArray or some other constructors + if (!isObject(C)) throwUnpolyfillable(type); + return new C(cloneBuffer(value.buffer, map), offset, length); + }; + + var structuredCloneInternal = function (value, map) { + if (isSymbol(value)) throwUncloneable('Symbol'); + if (!isObject(value)) return value; + // effectively preserves circular references + if (map) { + if (mapHas(map, value)) return mapGet(map, value); + } else map = new Map(); + + var type = classof(value); + var C, name, cloned, dataTransfer, i, length, keys, key; + + switch (type) { + case 'Array': + cloned = Array(lengthOfArrayLike(value)); + break; + case 'Object': + cloned = {}; + break; + case 'Map': + cloned = new Map(); + break; + case 'Set': + cloned = new Set(); + break; + case 'RegExp': + // in this block because of a Safari 14.1 bug + // old FF does not clone regexes passed to the constructor, so get the source and flags directly + cloned = new RegExp(value.source, getRegExpFlags(value)); + break; + case 'Error': + name = value.name; + switch (name) { + case 'AggregateError': + cloned = new (getBuiltIn(name))([]); + break; + case 'EvalError': + case 'RangeError': + case 'ReferenceError': + case 'SuppressedError': + case 'SyntaxError': + case 'TypeError': + case 'URIError': + cloned = new (getBuiltIn(name))(); + break; + case 'CompileError': + case 'LinkError': + case 'RuntimeError': + cloned = new (getBuiltIn('WebAssembly', name))(); + break; + default: + cloned = new Error(); + } + break; + case 'DOMException': + cloned = new DOMException(value.message, value.name); + break; + case 'ArrayBuffer': + case 'SharedArrayBuffer': + cloned = cloneBuffer(value, map, type); + break; + case 'DataView': + case 'Int8Array': + case 'Uint8Array': + case 'Uint8ClampedArray': + case 'Int16Array': + case 'Uint16Array': + case 'Int32Array': + case 'Uint32Array': + case 'Float16Array': + case 'Float32Array': + case 'Float64Array': + case 'BigInt64Array': + case 'BigUint64Array': + length = type === 'DataView' ? value.byteLength : value.length; + cloned = cloneView(value, type, value.byteOffset, length, map); + break; + case 'DOMQuad': + try { + cloned = new DOMQuad( + structuredCloneInternal(value.p1, map), + structuredCloneInternal(value.p2, map), + structuredCloneInternal(value.p3, map), + structuredCloneInternal(value.p4, map) + ); + } catch (error) { + cloned = tryNativeRestrictedStructuredClone(value, type); + } + break; + case 'File': + if (nativeRestrictedStructuredClone) try { + cloned = nativeRestrictedStructuredClone(value); + // NodeJS 20.0.0 bug, https://github.com/nodejs/node/issues/47612 + if (classof(cloned) !== type) cloned = undefined; + } catch (error) { /* empty */ } + if (!cloned) try { + cloned = new File([value], value.name, value); + } catch (error) { /* empty */ } + if (!cloned) throwUnpolyfillable(type); + break; + case 'FileList': + dataTransfer = createDataTransfer(); + if (dataTransfer) { + for (i = 0, length = lengthOfArrayLike(value); i < length; i++) { + dataTransfer.items.add(structuredCloneInternal(value[i], map)); + } + cloned = dataTransfer.files; + } else cloned = tryNativeRestrictedStructuredClone(value, type); + break; + case 'ImageData': + // Safari 9 ImageData is a constructor, but typeof ImageData is 'object' + try { + cloned = new ImageData( + structuredCloneInternal(value.data, map), + value.width, + value.height, + { colorSpace: value.colorSpace } + ); + } catch (error) { + cloned = tryNativeRestrictedStructuredClone(value, type); + } break; + default: + if (nativeRestrictedStructuredClone) { + cloned = nativeRestrictedStructuredClone(value); + } else switch (type) { + case 'BigInt': + // can be a 3rd party polyfill + cloned = Object(value.valueOf()); + break; + case 'Boolean': + cloned = Object(thisBooleanValue(value)); + break; + case 'Number': + cloned = Object(thisNumberValue(value)); + break; + case 'String': + cloned = Object(thisStringValue(value)); + break; + case 'Date': + cloned = new Date(thisTimeValue(value)); + break; + case 'Blob': + try { + cloned = value.slice(0, value.size, value.type); + } catch (error) { + throwUnpolyfillable(type); + } break; + case 'DOMPoint': + case 'DOMPointReadOnly': + C = globalThis[type]; + try { + cloned = C.fromPoint + ? C.fromPoint(value) + : new C(value.x, value.y, value.z, value.w); + } catch (error) { + throwUnpolyfillable(type); + } break; + case 'DOMRect': + case 'DOMRectReadOnly': + C = globalThis[type]; + try { + cloned = C.fromRect + ? C.fromRect(value) + : new C(value.x, value.y, value.width, value.height); + } catch (error) { + throwUnpolyfillable(type); + } break; + case 'DOMMatrix': + case 'DOMMatrixReadOnly': + C = globalThis[type]; + try { + cloned = C.fromMatrix + ? C.fromMatrix(value) + : new C(value); + } catch (error) { + throwUnpolyfillable(type); + } break; + case 'AudioData': + case 'VideoFrame': + if (!isCallable(value.clone)) throwUnpolyfillable(type); + try { + cloned = value.clone(); + } catch (error) { + throwUncloneable(type); + } break; + case 'CropTarget': + case 'CryptoKey': + case 'FileSystemDirectoryHandle': + case 'FileSystemFileHandle': + case 'FileSystemHandle': + case 'GPUCompilationInfo': + case 'GPUCompilationMessage': + case 'ImageBitmap': + case 'RTCCertificate': + case 'WebAssembly.Module': + throwUnpolyfillable(type); + // break omitted + default: + throwUncloneable(type); + } + } + + mapSet(map, value, cloned); + + switch (type) { + case 'Array': + case 'Object': + keys = objectKeys(value); + for (i = 0, length = lengthOfArrayLike(keys); i < length; i++) { + key = keys[i]; + createProperty(cloned, key, structuredCloneInternal(value[key], map)); + } break; + case 'Map': + value.forEach(function (v, k) { + mapSet(cloned, structuredCloneInternal(k, map), structuredCloneInternal(v, map)); + }); + break; + case 'Set': + value.forEach(function (v) { + setAdd(cloned, structuredCloneInternal(v, map)); + }); + break; + case 'Error': + createNonEnumerableProperty(cloned, 'message', structuredCloneInternal(value.message, map)); + if (hasOwn(value, 'cause')) { + createNonEnumerableProperty(cloned, 'cause', structuredCloneInternal(value.cause, map)); + } + if (name === 'AggregateError') { + cloned.errors = structuredCloneInternal(value.errors, map); + } else if (name === 'SuppressedError') { + cloned.error = structuredCloneInternal(value.error, map); + cloned.suppressed = structuredCloneInternal(value.suppressed, map); + } // break omitted + case 'DOMException': + if (ERROR_STACK_INSTALLABLE) { + createNonEnumerableProperty(cloned, 'stack', structuredCloneInternal(value.stack, map)); + } + } + + return cloned; + }; + + var tryToTransfer = function (rawTransfer, map) { + if (!isObject(rawTransfer)) throw new TypeError('Transfer option cannot be converted to a sequence'); + + var transfer = []; + + iterate(rawTransfer, function (value) { + push(transfer, anObject(value)); + }); + + var i = 0; + var length = lengthOfArrayLike(transfer); + var buffers = new Set(); + var value, type, C, transferred, canvas, context; + + while (i < length) { + value = transfer[i++]; + + type = classof(value); + + if (type === 'ArrayBuffer' ? setHas(buffers, value) : mapHas(map, value)) { + throw new DOMException('Duplicate transferable', DATA_CLONE_ERROR); + } + + if (type === 'ArrayBuffer') { + setAdd(buffers, value); + continue; + } + + if (PROPER_STRUCTURED_CLONE_TRANSFER) { + transferred = nativeStructuredClone(value, { transfer: [value] }); + } else switch (type) { + case 'ImageBitmap': + C = globalThis.OffscreenCanvas; + if (!isConstructor(C)) throwUnpolyfillable(type, TRANSFERRING); + try { + canvas = new C(value.width, value.height); + context = canvas.getContext('bitmaprenderer'); + context.transferFromImageBitmap(value); + transferred = canvas.transferToImageBitmap(); + } catch (error) { /* empty */ } + break; + case 'AudioData': + case 'VideoFrame': + if (!isCallable(value.clone) || !isCallable(value.close)) throwUnpolyfillable(type, TRANSFERRING); + try { + transferred = value.clone(); + value.close(); + } catch (error) { /* empty */ } + break; + case 'MediaSourceHandle': + case 'MessagePort': + case 'OffscreenCanvas': + case 'ReadableStream': + case 'TransformStream': + case 'WritableStream': + throwUnpolyfillable(type, TRANSFERRING); + } + + if (transferred === undefined) throw new DOMException('This object cannot be transferred: ' + type, DATA_CLONE_ERROR); + + mapSet(map, value, transferred); + } + + return buffers; + }; + + var detachBuffers = function (buffers) { + setIterate(buffers, function (buffer) { + if (PROPER_STRUCTURED_CLONE_TRANSFER) { + nativeRestrictedStructuredClone(buffer, { transfer: [buffer] }); + } else if (isCallable(buffer.transfer)) { + buffer.transfer(); + } else if (detachTransferable) { + detachTransferable(buffer); + } else { + throwUnpolyfillable('ArrayBuffer', TRANSFERRING); + } + }); + }; + + // `structuredClone` method + // https://html.spec.whatwg.org/multipage/structured-data.html#dom-structuredclone + $({ global: true, enumerable: true, sham: !PROPER_STRUCTURED_CLONE_TRANSFER, forced: FORCED_REPLACEMENT }, { + structuredClone: function structuredClone(value /* , { transfer } */) { + var options = validateArgumentsLength(arguments.length, 1) > 1 && !isNullOrUndefined(arguments[1]) ? anObject(arguments[1]) : undefined; + var transfer = options ? options.transfer : undefined; + var map, buffers; + + if (transfer !== undefined) { + map = new Map(); + buffers = tryToTransfer(transfer, map); + } + + var clone = structuredCloneInternal(value, map); + + // since of an issue with cloning views of transferred buffers, we a forced to detach them later + // https://github.com/zloirock/core-js/issues/1265 + if (buffers) detachBuffers(buffers); + + return clone; + } + }); + return web_structuredClone; +} + +var web_timers = {}; + +var web_setInterval = {}; + +var hasRequiredWeb_setInterval; + +function requireWeb_setInterval () { + if (hasRequiredWeb_setInterval) return web_setInterval; + hasRequiredWeb_setInterval = 1; + var $ = require_export(); + var globalThis = requireGlobalThis(); + var schedulersFix = requireSchedulersFix(); + + var setInterval = schedulersFix(globalThis.setInterval, true); + + // Bun / IE9- setInterval additional parameters fix + // https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#dom-setinterval + $({ global: true, bind: true, forced: globalThis.setInterval !== setInterval }, { + setInterval: setInterval + }); + return web_setInterval; +} + +var web_setTimeout = {}; + +var hasRequiredWeb_setTimeout; + +function requireWeb_setTimeout () { + if (hasRequiredWeb_setTimeout) return web_setTimeout; + hasRequiredWeb_setTimeout = 1; + var $ = require_export(); + var globalThis = requireGlobalThis(); + var schedulersFix = requireSchedulersFix(); + + var setTimeout = schedulersFix(globalThis.setTimeout, true); + + // Bun / IE9- setTimeout additional parameters fix + // https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#dom-settimeout + $({ global: true, bind: true, forced: globalThis.setTimeout !== setTimeout }, { + setTimeout: setTimeout + }); + return web_setTimeout; +} + +var hasRequiredWeb_timers; + +function requireWeb_timers () { + if (hasRequiredWeb_timers) return web_timers; + hasRequiredWeb_timers = 1; + // TODO: Remove this module from `core-js@4` since it's split to modules listed below + requireWeb_setInterval(); + requireWeb_setTimeout(); + return web_timers; +} + +var web_url = {}; + +var web_url_constructor = {}; + +var urlConstructorDetection; +var hasRequiredUrlConstructorDetection; + +function requireUrlConstructorDetection () { + if (hasRequiredUrlConstructorDetection) return urlConstructorDetection; + hasRequiredUrlConstructorDetection = 1; + var fails = requireFails(); + var wellKnownSymbol = requireWellKnownSymbol(); + var DESCRIPTORS = requireDescriptors(); + var IS_PURE = requireIsPure(); + + var ITERATOR = wellKnownSymbol('iterator'); + + urlConstructorDetection = !fails(function () { + // eslint-disable-next-line unicorn/relative-url-style -- required for testing + var url = new URL('b?a=1&b=2&c=3', 'https://a'); + var params = url.searchParams; + var params2 = new URLSearchParams('a=1&a=2&b=3'); + var result = ''; + url.pathname = 'c%20d'; + params.forEach(function (value, key) { + params['delete']('b'); + result += key + value; + }); + params2['delete']('a', 2); + // `undefined` case is a Chromium 117 bug + // https://bugs.chromium.org/p/v8/issues/detail?id=14222 + params2['delete']('b', undefined); + return (IS_PURE && (!url.toJSON || !params2.has('a', 1) || params2.has('a', 2) || !params2.has('a', undefined) || params2.has('b'))) + || (!params.size && (IS_PURE || !DESCRIPTORS)) + || !params.sort + || url.href !== 'https://a/c%20d?a=1&c=3' + || params.get('c') !== '3' + || String(new URLSearchParams('?a=1')) !== 'a=1' + || !params[ITERATOR] + // throws in Edge + || new URL('https://a@b').username !== 'a' + || new URLSearchParams(new URLSearchParams('a=b')).get('a') !== 'b' + // not punycoded in Edge + || new URL('https://тест').host !== 'xn--e1aybc' + // not escaped in Chrome 62- + || new URL('https://a#б').hash !== '#%D0%B1' + // fails in Chrome 66- + || result !== 'a1c3' + // throws in Safari + || new URL('https://x', undefined).host !== 'x'; + }); + return urlConstructorDetection; +} + +var stringPunycodeToAscii; +var hasRequiredStringPunycodeToAscii; + +function requireStringPunycodeToAscii () { + if (hasRequiredStringPunycodeToAscii) return stringPunycodeToAscii; + hasRequiredStringPunycodeToAscii = 1; + // based on https://github.com/bestiejs/punycode.js/blob/master/punycode.js + var uncurryThis = requireFunctionUncurryThis(); + + var maxInt = 2147483647; // aka. 0x7FFFFFFF or 2^31-1 + var base = 36; + var tMin = 1; + var tMax = 26; + var skew = 38; + var damp = 700; + var initialBias = 72; + var initialN = 128; // 0x80 + var delimiter = '-'; // '\x2D' + var regexNonASCII = /[^\0-\u007E]/; // non-ASCII chars + var regexSeparators = /[.\u3002\uFF0E\uFF61]/g; // RFC 3490 separators + var OVERFLOW_ERROR = 'Overflow: input needs wider integers to process'; + var baseMinusTMin = base - tMin; + + var $RangeError = RangeError; + var exec = uncurryThis(regexSeparators.exec); + var floor = Math.floor; + var fromCharCode = String.fromCharCode; + var charCodeAt = uncurryThis(''.charCodeAt); + var join = uncurryThis([].join); + var push = uncurryThis([].push); + var replace = uncurryThis(''.replace); + var split = uncurryThis(''.split); + var toLowerCase = uncurryThis(''.toLowerCase); + + /** + * Creates an array containing the numeric code points of each Unicode + * character in the string. While JavaScript uses UCS-2 internally, + * this function will convert a pair of surrogate halves (each of which + * UCS-2 exposes as separate characters) into a single code point, + * matching UTF-16. + */ + var ucs2decode = function (string) { + var output = []; + var counter = 0; + var length = string.length; + while (counter < length) { + var value = charCodeAt(string, counter++); + if (value >= 0xD800 && value <= 0xDBFF && counter < length) { + // It's a high surrogate, and there is a next character. + var extra = charCodeAt(string, counter++); + if ((extra & 0xFC00) === 0xDC00) { // Low surrogate. + push(output, ((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000); + } else { + // It's an unmatched surrogate; only append this code unit, in case the + // next code unit is the high surrogate of a surrogate pair. + push(output, value); + counter--; + } + } else { + push(output, value); + } + } + return output; + }; + + /** + * Converts a digit/integer into a basic code point. + */ + var digitToBasic = function (digit) { + // 0..25 map to ASCII a..z or A..Z + // 26..35 map to ASCII 0..9 + return digit + 22 + 75 * (digit < 26); + }; + + /** + * Bias adaptation function as per section 3.4 of RFC 3492. + * https://tools.ietf.org/html/rfc3492#section-3.4 + */ + var adapt = function (delta, numPoints, firstTime) { + var k = 0; + delta = firstTime ? floor(delta / damp) : delta >> 1; + delta += floor(delta / numPoints); + while (delta > baseMinusTMin * tMax >> 1) { + delta = floor(delta / baseMinusTMin); + k += base; + } + return floor(k + (baseMinusTMin + 1) * delta / (delta + skew)); + }; + + /** + * Converts a string of Unicode symbols (e.g. a domain name label) to a + * Punycode string of ASCII-only symbols. + */ + var encode = function (input) { + var output = []; + + // Convert the input in UCS-2 to an array of Unicode code points. + input = ucs2decode(input); + + // Cache the length. + var inputLength = input.length; + + // Initialize the state. + var n = initialN; + var delta = 0; + var bias = initialBias; + var i, currentValue; + + // Handle the basic code points. + for (i = 0; i < input.length; i++) { + currentValue = input[i]; + if (currentValue < 0x80) { + push(output, fromCharCode(currentValue)); + } + } + + var basicLength = output.length; // number of basic code points. + var handledCPCount = basicLength; // number of code points that have been handled; + + // Finish the basic string with a delimiter unless it's empty. + if (basicLength) { + push(output, delimiter); + } + + // Main encoding loop: + while (handledCPCount < inputLength) { + // All non-basic code points < n have been handled already. Find the next larger one: + var m = maxInt; + for (i = 0; i < input.length; i++) { + currentValue = input[i]; + if (currentValue >= n && currentValue < m) { + m = currentValue; + } + } + + // Increase `delta` enough to advance the decoder's state to , but guard against overflow. + var handledCPCountPlusOne = handledCPCount + 1; + if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) { + throw new $RangeError(OVERFLOW_ERROR); + } + + delta += (m - n) * handledCPCountPlusOne; + n = m; + + for (i = 0; i < input.length; i++) { + currentValue = input[i]; + if (currentValue < n && ++delta > maxInt) { + throw new $RangeError(OVERFLOW_ERROR); + } + if (currentValue === n) { + // Represent delta as a generalized variable-length integer. + var q = delta; + var k = base; + while (true) { + var t = k <= bias ? tMin : k >= bias + tMax ? tMax : k - bias; + if (q < t) break; + var qMinusT = q - t; + var baseMinusT = base - t; + push(output, fromCharCode(digitToBasic(t + qMinusT % baseMinusT))); + q = floor(qMinusT / baseMinusT); + k += base; + } + + push(output, fromCharCode(digitToBasic(q))); + bias = adapt(delta, handledCPCountPlusOne, handledCPCount === basicLength); + delta = 0; + handledCPCount++; + } + } + + delta++; + n++; + } + return join(output, ''); + }; + + stringPunycodeToAscii = function (input) { + var encoded = []; + var labels = split(replace(toLowerCase(input), regexSeparators, '\u002E'), '.'); + var i, label; + for (i = 0; i < labels.length; i++) { + label = labels[i]; + push(encoded, exec(regexNonASCII, label) ? 'xn--' + encode(label) : label); + } + return join(encoded, '.'); + }; + return stringPunycodeToAscii; +} + +var web_urlSearchParams_constructor; +var hasRequiredWeb_urlSearchParams_constructor; + +function requireWeb_urlSearchParams_constructor () { + if (hasRequiredWeb_urlSearchParams_constructor) return web_urlSearchParams_constructor; + hasRequiredWeb_urlSearchParams_constructor = 1; + // TODO: in core-js@4, move /modules/ dependencies to public entries for better optimization by tools like `preset-env` + requireEs_array_iterator(); + requireEs_string_fromCodePoint(); + var $ = require_export(); + var globalThis = requireGlobalThis(); + var safeGetBuiltIn = requireSafeGetBuiltIn(); + var getBuiltIn = requireGetBuiltIn(); + var call = requireFunctionCall(); + var uncurryThis = requireFunctionUncurryThis(); + var DESCRIPTORS = requireDescriptors(); + var USE_NATIVE_URL = requireUrlConstructorDetection(); + var defineBuiltIn = requireDefineBuiltIn(); + var defineBuiltInAccessor = requireDefineBuiltInAccessor(); + var defineBuiltIns = requireDefineBuiltIns(); + var setToStringTag = requireSetToStringTag(); + var createIteratorConstructor = requireIteratorCreateConstructor(); + var InternalStateModule = requireInternalState(); + var anInstance = requireAnInstance(); + var isCallable = requireIsCallable(); + var hasOwn = requireHasOwnProperty(); + var bind = requireFunctionBindContext(); + var classof = requireClassof(); + var anObject = requireAnObject(); + var isObject = requireIsObject(); + var $toString = requireToString(); + var create = requireObjectCreate(); + var createPropertyDescriptor = requireCreatePropertyDescriptor(); + var getIterator = requireGetIterator(); + var getIteratorMethod = requireGetIteratorMethod(); + var createIterResultObject = requireCreateIterResultObject(); + var validateArgumentsLength = requireValidateArgumentsLength(); + var wellKnownSymbol = requireWellKnownSymbol(); + var arraySort = requireArraySort(); + + var ITERATOR = wellKnownSymbol('iterator'); + var URL_SEARCH_PARAMS = 'URLSearchParams'; + var URL_SEARCH_PARAMS_ITERATOR = URL_SEARCH_PARAMS + 'Iterator'; + var setInternalState = InternalStateModule.set; + var getInternalParamsState = InternalStateModule.getterFor(URL_SEARCH_PARAMS); + var getInternalIteratorState = InternalStateModule.getterFor(URL_SEARCH_PARAMS_ITERATOR); + + var nativeFetch = safeGetBuiltIn('fetch'); + var NativeRequest = safeGetBuiltIn('Request'); + var Headers = safeGetBuiltIn('Headers'); + var RequestPrototype = NativeRequest && NativeRequest.prototype; + var HeadersPrototype = Headers && Headers.prototype; + var TypeError = globalThis.TypeError; + var encodeURIComponent = globalThis.encodeURIComponent; + var fromCharCode = String.fromCharCode; + var fromCodePoint = getBuiltIn('String', 'fromCodePoint'); + var $parseInt = parseInt; + var charAt = uncurryThis(''.charAt); + var join = uncurryThis([].join); + var push = uncurryThis([].push); + var replace = uncurryThis(''.replace); + var shift = uncurryThis([].shift); + var splice = uncurryThis([].splice); + var split = uncurryThis(''.split); + var stringSlice = uncurryThis(''.slice); + var exec = uncurryThis(/./.exec); + + var plus = /\+/g; + var FALLBACK_REPLACER = '\uFFFD'; + var VALID_HEX = /^[0-9a-f]+$/i; + + var parseHexOctet = function (string, start) { + var substr = stringSlice(string, start, start + 2); + if (!exec(VALID_HEX, substr)) return NaN; + + return $parseInt(substr, 16); + }; + + var getLeadingOnes = function (octet) { + var count = 0; + for (var mask = 0x80; mask > 0 && (octet & mask) !== 0; mask >>= 1) { + count++; + } + return count; + }; + + var utf8Decode = function (octets) { + var codePoint = null; + + switch (octets.length) { + case 1: + codePoint = octets[0]; + break; + case 2: + codePoint = (octets[0] & 0x1F) << 6 | (octets[1] & 0x3F); + break; + case 3: + codePoint = (octets[0] & 0x0F) << 12 | (octets[1] & 0x3F) << 6 | (octets[2] & 0x3F); + break; + case 4: + codePoint = (octets[0] & 0x07) << 18 | (octets[1] & 0x3F) << 12 | (octets[2] & 0x3F) << 6 | (octets[3] & 0x3F); + break; + } + + return codePoint > 0x10FFFF ? null : codePoint; + }; + + var decode = function (input) { + input = replace(input, plus, ' '); + var length = input.length; + var result = ''; + var i = 0; + + while (i < length) { + var decodedChar = charAt(input, i); + + if (decodedChar === '%') { + if (charAt(input, i + 1) === '%' || i + 3 > length) { + result += '%'; + i++; + continue; + } + + var octet = parseHexOctet(input, i + 1); + + // eslint-disable-next-line no-self-compare -- NaN check + if (octet !== octet) { + result += decodedChar; + i++; + continue; + } + + i += 2; + var byteSequenceLength = getLeadingOnes(octet); + + if (byteSequenceLength === 0) { + decodedChar = fromCharCode(octet); + } else { + if (byteSequenceLength === 1 || byteSequenceLength > 4) { + result += FALLBACK_REPLACER; + i++; + continue; + } + + var octets = [octet]; + var sequenceIndex = 1; + + while (sequenceIndex < byteSequenceLength) { + i++; + if (i + 3 > length || charAt(input, i) !== '%') break; + + var nextByte = parseHexOctet(input, i + 1); + + // eslint-disable-next-line no-self-compare -- NaN check + if (nextByte !== nextByte) { + i += 3; + break; + } + if (nextByte > 191 || nextByte < 128) break; + + push(octets, nextByte); + i += 2; + sequenceIndex++; + } + + if (octets.length !== byteSequenceLength) { + result += FALLBACK_REPLACER; + continue; + } + + var codePoint = utf8Decode(octets); + if (codePoint === null) { + result += FALLBACK_REPLACER; + } else { + decodedChar = fromCodePoint(codePoint); + } + } + } + + result += decodedChar; + i++; + } + + return result; + }; + + var find = /[!'()~]|%20/g; + + var replacements = { + '!': '%21', + "'": '%27', + '(': '%28', + ')': '%29', + '~': '%7E', + '%20': '+' + }; + + var replacer = function (match) { + return replacements[match]; + }; + + var serialize = function (it) { + return replace(encodeURIComponent(it), find, replacer); + }; + + var URLSearchParamsIterator = createIteratorConstructor(function Iterator(params, kind) { + setInternalState(this, { + type: URL_SEARCH_PARAMS_ITERATOR, + target: getInternalParamsState(params).entries, + index: 0, + kind: kind + }); + }, URL_SEARCH_PARAMS, function next() { + var state = getInternalIteratorState(this); + var target = state.target; + var index = state.index++; + if (!target || index >= target.length) { + state.target = null; + return createIterResultObject(undefined, true); + } + var entry = target[index]; + switch (state.kind) { + case 'keys': return createIterResultObject(entry.key, false); + case 'values': return createIterResultObject(entry.value, false); + } return createIterResultObject([entry.key, entry.value], false); + }, true); + + var URLSearchParamsState = function (init) { + this.entries = []; + this.url = null; + + if (init !== undefined) { + if (isObject(init)) this.parseObject(init); + else this.parseQuery(typeof init == 'string' ? charAt(init, 0) === '?' ? stringSlice(init, 1) : init : $toString(init)); + } + }; + + URLSearchParamsState.prototype = { + type: URL_SEARCH_PARAMS, + bindURL: function (url) { + this.url = url; + this.update(); + }, + parseObject: function (object) { + var entries = this.entries; + var iteratorMethod = getIteratorMethod(object); + var iterator, next, step, entryIterator, entryNext, first, second; + + if (iteratorMethod) { + iterator = getIterator(object, iteratorMethod); + next = iterator.next; + while (!(step = call(next, iterator)).done) { + entryIterator = getIterator(anObject(step.value)); + entryNext = entryIterator.next; + if ( + (first = call(entryNext, entryIterator)).done || + (second = call(entryNext, entryIterator)).done || + !call(entryNext, entryIterator).done + ) throw new TypeError('Expected sequence with length 2'); + push(entries, { key: $toString(first.value), value: $toString(second.value) }); + } + } else for (var key in object) if (hasOwn(object, key)) { + push(entries, { key: key, value: $toString(object[key]) }); + } + }, + parseQuery: function (query) { + if (query) { + var entries = this.entries; + var attributes = split(query, '&'); + var index = 0; + var attribute, entry; + while (index < attributes.length) { + attribute = attributes[index++]; + if (attribute.length) { + entry = split(attribute, '='); + push(entries, { + key: decode(shift(entry)), + value: decode(join(entry, '=')) + }); + } + } + } + }, + serialize: function () { + var entries = this.entries; + var result = []; + var index = 0; + var entry; + while (index < entries.length) { + entry = entries[index++]; + push(result, serialize(entry.key) + '=' + serialize(entry.value)); + } return join(result, '&'); + }, + update: function () { + this.entries.length = 0; + this.parseQuery(this.url.query); + }, + updateURL: function () { + if (this.url) this.url.update(); + } + }; + + // `URLSearchParams` constructor + // https://url.spec.whatwg.org/#interface-urlsearchparams + var URLSearchParamsConstructor = function URLSearchParams(/* init */) { + anInstance(this, URLSearchParamsPrototype); + var init = arguments.length > 0 ? arguments[0] : undefined; + var state = setInternalState(this, new URLSearchParamsState(init)); + if (!DESCRIPTORS) this.size = state.entries.length; + }; + + var URLSearchParamsPrototype = URLSearchParamsConstructor.prototype; + + defineBuiltIns(URLSearchParamsPrototype, { + // `URLSearchParams.prototype.append` method + // https://url.spec.whatwg.org/#dom-urlsearchparams-append + append: function append(name, value) { + var state = getInternalParamsState(this); + validateArgumentsLength(arguments.length, 2); + push(state.entries, { key: $toString(name), value: $toString(value) }); + if (!DESCRIPTORS) this.length++; + state.updateURL(); + }, + // `URLSearchParams.prototype.delete` method + // https://url.spec.whatwg.org/#dom-urlsearchparams-delete + 'delete': function (name /* , value */) { + var state = getInternalParamsState(this); + var length = validateArgumentsLength(arguments.length, 1); + var entries = state.entries; + var key = $toString(name); + var $value = length < 2 ? undefined : arguments[1]; + var value = $value === undefined ? $value : $toString($value); + var index = 0; + while (index < entries.length) { + var entry = entries[index]; + if (entry.key === key && (value === undefined || entry.value === value)) { + splice(entries, index, 1); + if (value !== undefined) break; + } else index++; + } + if (!DESCRIPTORS) this.size = entries.length; + state.updateURL(); + }, + // `URLSearchParams.prototype.get` method + // https://url.spec.whatwg.org/#dom-urlsearchparams-get + get: function get(name) { + var entries = getInternalParamsState(this).entries; + validateArgumentsLength(arguments.length, 1); + var key = $toString(name); + var index = 0; + for (; index < entries.length; index++) { + if (entries[index].key === key) return entries[index].value; + } + return null; + }, + // `URLSearchParams.prototype.getAll` method + // https://url.spec.whatwg.org/#dom-urlsearchparams-getall + getAll: function getAll(name) { + var entries = getInternalParamsState(this).entries; + validateArgumentsLength(arguments.length, 1); + var key = $toString(name); + var result = []; + var index = 0; + for (; index < entries.length; index++) { + if (entries[index].key === key) push(result, entries[index].value); + } + return result; + }, + // `URLSearchParams.prototype.has` method + // https://url.spec.whatwg.org/#dom-urlsearchparams-has + has: function has(name /* , value */) { + var entries = getInternalParamsState(this).entries; + var length = validateArgumentsLength(arguments.length, 1); + var key = $toString(name); + var $value = length < 2 ? undefined : arguments[1]; + var value = $value === undefined ? $value : $toString($value); + var index = 0; + while (index < entries.length) { + var entry = entries[index++]; + if (entry.key === key && (value === undefined || entry.value === value)) return true; + } + return false; + }, + // `URLSearchParams.prototype.set` method + // https://url.spec.whatwg.org/#dom-urlsearchparams-set + set: function set(name, value) { + var state = getInternalParamsState(this); + validateArgumentsLength(arguments.length, 1); + var entries = state.entries; + var found = false; + var key = $toString(name); + var val = $toString(value); + var index = 0; + var entry; + for (; index < entries.length; index++) { + entry = entries[index]; + if (entry.key === key) { + if (found) splice(entries, index--, 1); + else { + found = true; + entry.value = val; + } + } + } + if (!found) push(entries, { key: key, value: val }); + if (!DESCRIPTORS) this.size = entries.length; + state.updateURL(); + }, + // `URLSearchParams.prototype.sort` method + // https://url.spec.whatwg.org/#dom-urlsearchparams-sort + sort: function sort() { + var state = getInternalParamsState(this); + arraySort(state.entries, function (a, b) { + return a.key > b.key ? 1 : -1; + }); + state.updateURL(); + }, + // `URLSearchParams.prototype.forEach` method + forEach: function forEach(callback /* , thisArg */) { + var entries = getInternalParamsState(this).entries; + var boundFunction = bind(callback, arguments.length > 1 ? arguments[1] : undefined); + var index = 0; + var entry; + while (index < entries.length) { + entry = entries[index++]; + boundFunction(entry.value, entry.key, this); + } + }, + // `URLSearchParams.prototype.keys` method + keys: function keys() { + return new URLSearchParamsIterator(this, 'keys'); + }, + // `URLSearchParams.prototype.values` method + values: function values() { + return new URLSearchParamsIterator(this, 'values'); + }, + // `URLSearchParams.prototype.entries` method + entries: function entries() { + return new URLSearchParamsIterator(this, 'entries'); + } + }, { enumerable: true }); + + // `URLSearchParams.prototype[@@iterator]` method + defineBuiltIn(URLSearchParamsPrototype, ITERATOR, URLSearchParamsPrototype.entries, { name: 'entries' }); + + // `URLSearchParams.prototype.toString` method + // https://url.spec.whatwg.org/#urlsearchparams-stringification-behavior + defineBuiltIn(URLSearchParamsPrototype, 'toString', function toString() { + return getInternalParamsState(this).serialize(); + }, { enumerable: true }); + + // `URLSearchParams.prototype.size` getter + // https://github.com/whatwg/url/pull/734 + if (DESCRIPTORS) defineBuiltInAccessor(URLSearchParamsPrototype, 'size', { + get: function size() { + return getInternalParamsState(this).entries.length; + }, + configurable: true, + enumerable: true + }); + + setToStringTag(URLSearchParamsConstructor, URL_SEARCH_PARAMS); + + $({ global: true, constructor: true, forced: !USE_NATIVE_URL }, { + URLSearchParams: URLSearchParamsConstructor + }); + + // Wrap `fetch` and `Request` for correct work with polyfilled `URLSearchParams` + if (!USE_NATIVE_URL && isCallable(Headers)) { + var headersHas = uncurryThis(HeadersPrototype.has); + var headersSet = uncurryThis(HeadersPrototype.set); + + var wrapRequestOptions = function (init) { + if (isObject(init)) { + var body = init.body; + var headers; + if (classof(body) === URL_SEARCH_PARAMS) { + headers = init.headers ? new Headers(init.headers) : new Headers(); + if (!headersHas(headers, 'content-type')) { + headersSet(headers, 'content-type', 'application/x-www-form-urlencoded;charset=UTF-8'); + } + return create(init, { + body: createPropertyDescriptor(0, $toString(body)), + headers: createPropertyDescriptor(0, headers) + }); + } + } return init; + }; + + if (isCallable(nativeFetch)) { + $({ global: true, enumerable: true, dontCallGetSet: true, forced: true }, { + fetch: function fetch(input /* , init */) { + return nativeFetch(input, arguments.length > 1 ? wrapRequestOptions(arguments[1]) : {}); + } + }); + } + + if (isCallable(NativeRequest)) { + var RequestConstructor = function Request(input /* , init */) { + anInstance(this, RequestPrototype); + return new NativeRequest(input, arguments.length > 1 ? wrapRequestOptions(arguments[1]) : {}); + }; + + RequestPrototype.constructor = RequestConstructor; + RequestConstructor.prototype = RequestPrototype; + + $({ global: true, constructor: true, dontCallGetSet: true, forced: true }, { + Request: RequestConstructor + }); + } + } + + web_urlSearchParams_constructor = { + URLSearchParams: URLSearchParamsConstructor, + getState: getInternalParamsState + }; + return web_urlSearchParams_constructor; +} + +var hasRequiredWeb_url_constructor; + +function requireWeb_url_constructor () { + if (hasRequiredWeb_url_constructor) return web_url_constructor; + hasRequiredWeb_url_constructor = 1; + // TODO: in core-js@4, move /modules/ dependencies to public entries for better optimization by tools like `preset-env` + requireEs_string_iterator(); + var $ = require_export(); + var DESCRIPTORS = requireDescriptors(); + var USE_NATIVE_URL = requireUrlConstructorDetection(); + var globalThis = requireGlobalThis(); + var bind = requireFunctionBindContext(); + var uncurryThis = requireFunctionUncurryThis(); + var defineBuiltIn = requireDefineBuiltIn(); + var defineBuiltInAccessor = requireDefineBuiltInAccessor(); + var anInstance = requireAnInstance(); + var hasOwn = requireHasOwnProperty(); + var assign = requireObjectAssign(); + var arrayFrom = requireArrayFrom(); + var arraySlice = requireArraySlice(); + var codeAt = requireStringMultibyte().codeAt; + var toASCII = requireStringPunycodeToAscii(); + var $toString = requireToString(); + var setToStringTag = requireSetToStringTag(); + var validateArgumentsLength = requireValidateArgumentsLength(); + var URLSearchParamsModule = requireWeb_urlSearchParams_constructor(); + var InternalStateModule = requireInternalState(); + + var setInternalState = InternalStateModule.set; + var getInternalURLState = InternalStateModule.getterFor('URL'); + var URLSearchParams = URLSearchParamsModule.URLSearchParams; + var getInternalSearchParamsState = URLSearchParamsModule.getState; + + var NativeURL = globalThis.URL; + var TypeError = globalThis.TypeError; + var parseInt = globalThis.parseInt; + var floor = Math.floor; + var pow = Math.pow; + var charAt = uncurryThis(''.charAt); + var exec = uncurryThis(/./.exec); + var join = uncurryThis([].join); + var numberToString = uncurryThis(1.0.toString); + var pop = uncurryThis([].pop); + var push = uncurryThis([].push); + var replace = uncurryThis(''.replace); + var shift = uncurryThis([].shift); + var split = uncurryThis(''.split); + var stringSlice = uncurryThis(''.slice); + var toLowerCase = uncurryThis(''.toLowerCase); + var unshift = uncurryThis([].unshift); + + var INVALID_AUTHORITY = 'Invalid authority'; + var INVALID_SCHEME = 'Invalid scheme'; + var INVALID_HOST = 'Invalid host'; + var INVALID_PORT = 'Invalid port'; + + var ALPHA = /[a-z]/i; + // eslint-disable-next-line regexp/no-obscure-range -- safe + var ALPHANUMERIC = /[\d+-.a-z]/i; + var DIGIT = /\d/; + var HEX_START = /^0x/i; + var OCT = /^[0-7]+$/; + var DEC = /^\d+$/; + var HEX = /^[\da-f]+$/i; + /* eslint-disable regexp/no-control-character -- safe */ + var FORBIDDEN_HOST_CODE_POINT = /[\0\t\n\r #%/:<>?@[\\\]^|]/; + var FORBIDDEN_HOST_CODE_POINT_EXCLUDING_PERCENT = /[\0\t\n\r #/:<>?@[\\\]^|]/; + var LEADING_C0_CONTROL_OR_SPACE = /^[\u0000-\u0020]+/; + var TRAILING_C0_CONTROL_OR_SPACE = /(^|[^\u0000-\u0020])[\u0000-\u0020]+$/; + var TAB_AND_NEW_LINE = /[\t\n\r]/g; + /* eslint-enable regexp/no-control-character -- safe */ + var EOF; + + // https://url.spec.whatwg.org/#ipv4-number-parser + var parseIPv4 = function (input) { + var parts = split(input, '.'); + var partsLength, numbers, index, part, radix, number, ipv4; + if (parts.length && parts[parts.length - 1] === '') { + parts.length--; + } + partsLength = parts.length; + if (partsLength > 4) return input; + numbers = []; + for (index = 0; index < partsLength; index++) { + part = parts[index]; + if (part === '') return input; + radix = 10; + if (part.length > 1 && charAt(part, 0) === '0') { + radix = exec(HEX_START, part) ? 16 : 8; + part = stringSlice(part, radix === 8 ? 1 : 2); + } + if (part === '') { + number = 0; + } else { + if (!exec(radix === 10 ? DEC : radix === 8 ? OCT : HEX, part)) return input; + number = parseInt(part, radix); + } + push(numbers, number); + } + for (index = 0; index < partsLength; index++) { + number = numbers[index]; + if (index === partsLength - 1) { + if (number >= pow(256, 5 - partsLength)) return null; + } else if (number > 255) return null; + } + ipv4 = pop(numbers); + for (index = 0; index < numbers.length; index++) { + ipv4 += numbers[index] * pow(256, 3 - index); + } + return ipv4; + }; + + // https://url.spec.whatwg.org/#concept-ipv6-parser + // eslint-disable-next-line max-statements -- TODO + var parseIPv6 = function (input) { + var address = [0, 0, 0, 0, 0, 0, 0, 0]; + var pieceIndex = 0; + var compress = null; + var pointer = 0; + var value, length, numbersSeen, ipv4Piece, number, swaps, swap; + + var chr = function () { + return charAt(input, pointer); + }; + + if (chr() === ':') { + if (charAt(input, 1) !== ':') return; + pointer += 2; + pieceIndex++; + compress = pieceIndex; + } + while (chr()) { + if (pieceIndex === 8) return; + if (chr() === ':') { + if (compress !== null) return; + pointer++; + pieceIndex++; + compress = pieceIndex; + continue; + } + value = length = 0; + while (length < 4 && exec(HEX, chr())) { + value = value * 16 + parseInt(chr(), 16); + pointer++; + length++; + } + if (chr() === '.') { + if (length === 0) return; + pointer -= length; + if (pieceIndex > 6) return; + numbersSeen = 0; + while (chr()) { + ipv4Piece = null; + if (numbersSeen > 0) { + if (chr() === '.' && numbersSeen < 4) pointer++; + else return; + } + if (!exec(DIGIT, chr())) return; + while (exec(DIGIT, chr())) { + number = parseInt(chr(), 10); + if (ipv4Piece === null) ipv4Piece = number; + else if (ipv4Piece === 0) return; + else ipv4Piece = ipv4Piece * 10 + number; + if (ipv4Piece > 255) return; + pointer++; + } + address[pieceIndex] = address[pieceIndex] * 256 + ipv4Piece; + numbersSeen++; + if (numbersSeen === 2 || numbersSeen === 4) pieceIndex++; + } + if (numbersSeen !== 4) return; + break; + } else if (chr() === ':') { + pointer++; + if (!chr()) return; + } else if (chr()) return; + address[pieceIndex++] = value; + } + if (compress !== null) { + swaps = pieceIndex - compress; + pieceIndex = 7; + while (pieceIndex !== 0 && swaps > 0) { + swap = address[pieceIndex]; + address[pieceIndex--] = address[compress + swaps - 1]; + address[compress + --swaps] = swap; + } + } else if (pieceIndex !== 8) return; + return address; + }; + + var findLongestZeroSequence = function (ipv6) { + var maxIndex = null; + var maxLength = 1; + var currStart = null; + var currLength = 0; + var index = 0; + for (; index < 8; index++) { + if (ipv6[index] !== 0) { + if (currLength > maxLength) { + maxIndex = currStart; + maxLength = currLength; + } + currStart = null; + currLength = 0; + } else { + if (currStart === null) currStart = index; + ++currLength; + } + } + return currLength > maxLength ? currStart : maxIndex; + }; + + // https://url.spec.whatwg.org/#host-serializing + var serializeHost = function (host) { + var result, index, compress, ignore0; + + // ipv4 + if (typeof host == 'number') { + result = []; + for (index = 0; index < 4; index++) { + unshift(result, host % 256); + host = floor(host / 256); + } + return join(result, '.'); + } + + // ipv6 + if (typeof host == 'object') { + result = ''; + compress = findLongestZeroSequence(host); + for (index = 0; index < 8; index++) { + if (ignore0 && host[index] === 0) continue; + if (ignore0) ignore0 = false; + if (compress === index) { + result += index ? ':' : '::'; + ignore0 = true; + } else { + result += numberToString(host[index], 16); + if (index < 7) result += ':'; + } + } + return '[' + result + ']'; + } + + return host; + }; + + var C0ControlPercentEncodeSet = {}; + var fragmentPercentEncodeSet = assign({}, C0ControlPercentEncodeSet, { + ' ': 1, '"': 1, '<': 1, '>': 1, '`': 1 + }); + var pathPercentEncodeSet = assign({}, fragmentPercentEncodeSet, { + '#': 1, '?': 1, '{': 1, '}': 1 + }); + var userinfoPercentEncodeSet = assign({}, pathPercentEncodeSet, { + '/': 1, ':': 1, ';': 1, '=': 1, '@': 1, '[': 1, '\\': 1, ']': 1, '^': 1, '|': 1 + }); + + var percentEncode = function (chr, set) { + var code = codeAt(chr, 0); + return code > 0x20 && code < 0x7F && !hasOwn(set, chr) ? chr : encodeURIComponent(chr); + }; + + // https://url.spec.whatwg.org/#special-scheme + var specialSchemes = { + ftp: 21, + file: null, + http: 80, + https: 443, + ws: 80, + wss: 443 + }; + + // https://url.spec.whatwg.org/#windows-drive-letter + var isWindowsDriveLetter = function (string, normalized) { + var second; + return string.length === 2 && exec(ALPHA, charAt(string, 0)) + && ((second = charAt(string, 1)) === ':' || (!normalized && second === '|')); + }; + + // https://url.spec.whatwg.org/#start-with-a-windows-drive-letter + var startsWithWindowsDriveLetter = function (string) { + var third; + return string.length > 1 && isWindowsDriveLetter(stringSlice(string, 0, 2)) && ( + string.length === 2 || + ((third = charAt(string, 2)) === '/' || third === '\\' || third === '?' || third === '#') + ); + }; + + // https://url.spec.whatwg.org/#single-dot-path-segment + var isSingleDot = function (segment) { + return segment === '.' || toLowerCase(segment) === '%2e'; + }; + + // https://url.spec.whatwg.org/#double-dot-path-segment + var isDoubleDot = function (segment) { + segment = toLowerCase(segment); + return segment === '..' || segment === '%2e.' || segment === '.%2e' || segment === '%2e%2e'; + }; + + // States: + var SCHEME_START = {}; + var SCHEME = {}; + var NO_SCHEME = {}; + var SPECIAL_RELATIVE_OR_AUTHORITY = {}; + var PATH_OR_AUTHORITY = {}; + var RELATIVE = {}; + var RELATIVE_SLASH = {}; + var SPECIAL_AUTHORITY_SLASHES = {}; + var SPECIAL_AUTHORITY_IGNORE_SLASHES = {}; + var AUTHORITY = {}; + var HOST = {}; + var HOSTNAME = {}; + var PORT = {}; + var FILE = {}; + var FILE_SLASH = {}; + var FILE_HOST = {}; + var PATH_START = {}; + var PATH = {}; + var CANNOT_BE_A_BASE_URL_PATH = {}; + var QUERY = {}; + var FRAGMENT = {}; + + var URLState = function (url, isBase, base) { + var urlString = $toString(url); + var baseState, failure, searchParams; + if (isBase) { + failure = this.parse(urlString); + if (failure) throw new TypeError(failure); + this.searchParams = null; + } else { + if (base !== undefined) baseState = new URLState(base, true); + failure = this.parse(urlString, null, baseState); + if (failure) throw new TypeError(failure); + searchParams = getInternalSearchParamsState(new URLSearchParams()); + searchParams.bindURL(this); + this.searchParams = searchParams; + } + }; + + URLState.prototype = { + type: 'URL', + // https://url.spec.whatwg.org/#url-parsing + // eslint-disable-next-line max-statements -- TODO + parse: function (input, stateOverride, base) { + var url = this; + var state = stateOverride || SCHEME_START; + var pointer = 0; + var buffer = ''; + var seenAt = false; + var seenBracket = false; + var seenPasswordToken = false; + var codePoints, chr, bufferCodePoints, failure; + + input = $toString(input); + + if (!stateOverride) { + url.scheme = ''; + url.username = ''; + url.password = ''; + url.host = null; + url.port = null; + url.path = []; + url.query = null; + url.fragment = null; + url.cannotBeABaseURL = false; + input = replace(input, LEADING_C0_CONTROL_OR_SPACE, ''); + input = replace(input, TRAILING_C0_CONTROL_OR_SPACE, '$1'); + } + + input = replace(input, TAB_AND_NEW_LINE, ''); + + codePoints = arrayFrom(input); + + while (pointer <= codePoints.length) { + chr = codePoints[pointer]; + switch (state) { + case SCHEME_START: + if (chr && exec(ALPHA, chr)) { + buffer += toLowerCase(chr); + state = SCHEME; + } else if (!stateOverride) { + state = NO_SCHEME; + continue; + } else return INVALID_SCHEME; + break; + + case SCHEME: + if (chr && (exec(ALPHANUMERIC, chr) || chr === '+' || chr === '-' || chr === '.')) { + buffer += toLowerCase(chr); + } else if (chr === ':') { + if (stateOverride && ( + (url.isSpecial() !== hasOwn(specialSchemes, buffer)) || + (buffer === 'file' && (url.includesCredentials() || url.port !== null)) || + (url.scheme === 'file' && !url.host) + )) return; + url.scheme = buffer; + if (stateOverride) { + if (url.isSpecial() && specialSchemes[url.scheme] === url.port) url.port = null; + return; + } + buffer = ''; + if (url.scheme === 'file') { + state = FILE; + } else if (url.isSpecial() && base && base.scheme === url.scheme) { + state = SPECIAL_RELATIVE_OR_AUTHORITY; + } else if (url.isSpecial()) { + state = SPECIAL_AUTHORITY_SLASHES; + } else if (codePoints[pointer + 1] === '/') { + state = PATH_OR_AUTHORITY; + pointer++; + } else { + url.cannotBeABaseURL = true; + push(url.path, ''); + state = CANNOT_BE_A_BASE_URL_PATH; + } + } else if (!stateOverride) { + buffer = ''; + state = NO_SCHEME; + pointer = 0; + continue; + } else return INVALID_SCHEME; + break; + + case NO_SCHEME: + if (!base || (base.cannotBeABaseURL && chr !== '#')) return INVALID_SCHEME; + if (base.cannotBeABaseURL && chr === '#') { + url.scheme = base.scheme; + url.path = arraySlice(base.path); + url.query = base.query; + url.fragment = ''; + url.cannotBeABaseURL = true; + state = FRAGMENT; + break; + } + state = base.scheme === 'file' ? FILE : RELATIVE; + continue; + + case SPECIAL_RELATIVE_OR_AUTHORITY: + if (chr === '/' && codePoints[pointer + 1] === '/') { + state = SPECIAL_AUTHORITY_IGNORE_SLASHES; + pointer++; + } else { + state = RELATIVE; + continue; + } break; + + case PATH_OR_AUTHORITY: + if (chr === '/') { + state = AUTHORITY; + break; + } else { + state = PATH; + continue; + } + + case RELATIVE: + url.scheme = base.scheme; + if (chr === EOF) { + url.username = base.username; + url.password = base.password; + url.host = base.host; + url.port = base.port; + url.path = arraySlice(base.path); + url.query = base.query; + } else if (chr === '/' || (chr === '\\' && url.isSpecial())) { + state = RELATIVE_SLASH; + } else if (chr === '?') { + url.username = base.username; + url.password = base.password; + url.host = base.host; + url.port = base.port; + url.path = arraySlice(base.path); + url.query = ''; + state = QUERY; + } else if (chr === '#') { + url.username = base.username; + url.password = base.password; + url.host = base.host; + url.port = base.port; + url.path = arraySlice(base.path); + url.query = base.query; + url.fragment = ''; + state = FRAGMENT; + } else { + url.username = base.username; + url.password = base.password; + url.host = base.host; + url.port = base.port; + url.path = arraySlice(base.path); + url.path.length--; + state = PATH; + continue; + } break; + + case RELATIVE_SLASH: + if (url.isSpecial() && (chr === '/' || chr === '\\')) { + state = SPECIAL_AUTHORITY_IGNORE_SLASHES; + } else if (chr === '/') { + state = AUTHORITY; + } else { + url.username = base.username; + url.password = base.password; + url.host = base.host; + url.port = base.port; + state = PATH; + continue; + } break; + + case SPECIAL_AUTHORITY_SLASHES: + state = SPECIAL_AUTHORITY_IGNORE_SLASHES; + if (chr !== '/' || charAt(buffer, pointer + 1) !== '/') continue; + pointer++; + break; + + case SPECIAL_AUTHORITY_IGNORE_SLASHES: + if (chr !== '/' && chr !== '\\') { + state = AUTHORITY; + continue; + } break; + + case AUTHORITY: + if (chr === '@') { + if (seenAt) buffer = '%40' + buffer; + seenAt = true; + bufferCodePoints = arrayFrom(buffer); + for (var i = 0; i < bufferCodePoints.length; i++) { + var codePoint = bufferCodePoints[i]; + if (codePoint === ':' && !seenPasswordToken) { + seenPasswordToken = true; + continue; + } + var encodedCodePoints = percentEncode(codePoint, userinfoPercentEncodeSet); + if (seenPasswordToken) url.password += encodedCodePoints; + else url.username += encodedCodePoints; + } + buffer = ''; + } else if ( + chr === EOF || chr === '/' || chr === '?' || chr === '#' || + (chr === '\\' && url.isSpecial()) + ) { + if (seenAt && buffer === '') return INVALID_AUTHORITY; + pointer -= arrayFrom(buffer).length + 1; + buffer = ''; + state = HOST; + } else buffer += chr; + break; + + case HOST: + case HOSTNAME: + if (stateOverride && url.scheme === 'file') { + state = FILE_HOST; + continue; + } else if (chr === ':' && !seenBracket) { + if (buffer === '') return INVALID_HOST; + failure = url.parseHost(buffer); + if (failure) return failure; + buffer = ''; + state = PORT; + if (stateOverride === HOSTNAME) return; + } else if ( + chr === EOF || chr === '/' || chr === '?' || chr === '#' || + (chr === '\\' && url.isSpecial()) + ) { + if (url.isSpecial() && buffer === '') return INVALID_HOST; + if (stateOverride && buffer === '' && (url.includesCredentials() || url.port !== null)) return; + failure = url.parseHost(buffer); + if (failure) return failure; + buffer = ''; + state = PATH_START; + if (stateOverride) return; + continue; + } else { + if (chr === '[') seenBracket = true; + else if (chr === ']') seenBracket = false; + buffer += chr; + } break; + + case PORT: + if (exec(DIGIT, chr)) { + buffer += chr; + } else if ( + chr === EOF || chr === '/' || chr === '?' || chr === '#' || + (chr === '\\' && url.isSpecial()) || + stateOverride + ) { + if (buffer !== '') { + var port = parseInt(buffer, 10); + if (port > 0xFFFF) return INVALID_PORT; + url.port = (url.isSpecial() && port === specialSchemes[url.scheme]) ? null : port; + buffer = ''; + } + if (stateOverride) return; + state = PATH_START; + continue; + } else return INVALID_PORT; + break; + + case FILE: + url.scheme = 'file'; + if (chr === '/' || chr === '\\') state = FILE_SLASH; + else if (base && base.scheme === 'file') { + switch (chr) { + case EOF: + url.host = base.host; + url.path = arraySlice(base.path); + url.query = base.query; + break; + case '?': + url.host = base.host; + url.path = arraySlice(base.path); + url.query = ''; + state = QUERY; + break; + case '#': + url.host = base.host; + url.path = arraySlice(base.path); + url.query = base.query; + url.fragment = ''; + state = FRAGMENT; + break; + default: + if (!startsWithWindowsDriveLetter(join(arraySlice(codePoints, pointer), ''))) { + url.host = base.host; + url.path = arraySlice(base.path); + url.shortenPath(); + } + state = PATH; + continue; + } + } else { + state = PATH; + continue; + } break; + + case FILE_SLASH: + if (chr === '/' || chr === '\\') { + state = FILE_HOST; + break; + } + if (base && base.scheme === 'file' && !startsWithWindowsDriveLetter(join(arraySlice(codePoints, pointer), ''))) { + if (isWindowsDriveLetter(base.path[0], true)) push(url.path, base.path[0]); + else url.host = base.host; + } + state = PATH; + continue; + + case FILE_HOST: + if (chr === EOF || chr === '/' || chr === '\\' || chr === '?' || chr === '#') { + if (!stateOverride && isWindowsDriveLetter(buffer)) { + state = PATH; + } else if (buffer === '') { + url.host = ''; + if (stateOverride) return; + state = PATH_START; + } else { + failure = url.parseHost(buffer); + if (failure) return failure; + if (url.host === 'localhost') url.host = ''; + if (stateOverride) return; + buffer = ''; + state = PATH_START; + } continue; + } else buffer += chr; + break; + + case PATH_START: + if (url.isSpecial()) { + state = PATH; + if (chr !== '/' && chr !== '\\') continue; + } else if (!stateOverride && chr === '?') { + url.query = ''; + state = QUERY; + } else if (!stateOverride && chr === '#') { + url.fragment = ''; + state = FRAGMENT; + } else if (chr !== EOF) { + state = PATH; + if (chr !== '/') continue; + } break; + + case PATH: + if ( + chr === EOF || chr === '/' || + (chr === '\\' && url.isSpecial()) || + (!stateOverride && (chr === '?' || chr === '#')) + ) { + if (isDoubleDot(buffer)) { + url.shortenPath(); + if (chr !== '/' && !(chr === '\\' && url.isSpecial())) { + push(url.path, ''); + } + } else if (isSingleDot(buffer)) { + if (chr !== '/' && !(chr === '\\' && url.isSpecial())) { + push(url.path, ''); + } + } else { + if (url.scheme === 'file' && !url.path.length && isWindowsDriveLetter(buffer)) { + if (url.host) url.host = ''; + buffer = charAt(buffer, 0) + ':'; // normalize windows drive letter + } + push(url.path, buffer); + } + buffer = ''; + if (url.scheme === 'file' && (chr === EOF || chr === '?' || chr === '#')) { + while (url.path.length > 1 && url.path[0] === '') { + shift(url.path); + } + } + if (chr === '?') { + url.query = ''; + state = QUERY; + } else if (chr === '#') { + url.fragment = ''; + state = FRAGMENT; + } + } else { + buffer += percentEncode(chr, pathPercentEncodeSet); + } break; + + case CANNOT_BE_A_BASE_URL_PATH: + if (chr === '?') { + url.query = ''; + state = QUERY; + } else if (chr === '#') { + url.fragment = ''; + state = FRAGMENT; + } else if (chr !== EOF) { + url.path[0] += percentEncode(chr, C0ControlPercentEncodeSet); + } break; + + case QUERY: + if (!stateOverride && chr === '#') { + url.fragment = ''; + state = FRAGMENT; + } else if (chr !== EOF) { + if (chr === "'" && url.isSpecial()) url.query += '%27'; + else if (chr === '#') url.query += '%23'; + else url.query += percentEncode(chr, C0ControlPercentEncodeSet); + } break; + + case FRAGMENT: + if (chr !== EOF) url.fragment += percentEncode(chr, fragmentPercentEncodeSet); + break; + } + + pointer++; + } + }, + // https://url.spec.whatwg.org/#host-parsing + parseHost: function (input) { + var result, codePoints, index; + if (charAt(input, 0) === '[') { + if (charAt(input, input.length - 1) !== ']') return INVALID_HOST; + result = parseIPv6(stringSlice(input, 1, -1)); + if (!result) return INVALID_HOST; + this.host = result; + // opaque host + } else if (!this.isSpecial()) { + if (exec(FORBIDDEN_HOST_CODE_POINT_EXCLUDING_PERCENT, input)) return INVALID_HOST; + result = ''; + codePoints = arrayFrom(input); + for (index = 0; index < codePoints.length; index++) { + result += percentEncode(codePoints[index], C0ControlPercentEncodeSet); + } + this.host = result; + } else { + input = toASCII(input); + if (exec(FORBIDDEN_HOST_CODE_POINT, input)) return INVALID_HOST; + result = parseIPv4(input); + if (result === null) return INVALID_HOST; + this.host = result; + } + }, + // https://url.spec.whatwg.org/#cannot-have-a-username-password-port + cannotHaveUsernamePasswordPort: function () { + return !this.host || this.cannotBeABaseURL || this.scheme === 'file'; + }, + // https://url.spec.whatwg.org/#include-credentials + includesCredentials: function () { + return this.username !== '' || this.password !== ''; + }, + // https://url.spec.whatwg.org/#is-special + isSpecial: function () { + return hasOwn(specialSchemes, this.scheme); + }, + // https://url.spec.whatwg.org/#shorten-a-urls-path + shortenPath: function () { + var path = this.path; + var pathSize = path.length; + if (pathSize && (this.scheme !== 'file' || pathSize !== 1 || !isWindowsDriveLetter(path[0], true))) { + path.length--; + } + }, + // https://url.spec.whatwg.org/#concept-url-serializer + serialize: function () { + var url = this; + var scheme = url.scheme; + var username = url.username; + var password = url.password; + var host = url.host; + var port = url.port; + var path = url.path; + var query = url.query; + var fragment = url.fragment; + var output = scheme + ':'; + if (host !== null) { + output += '//'; + if (url.includesCredentials()) { + output += username + (password ? ':' + password : '') + '@'; + } + output += serializeHost(host); + if (port !== null) output += ':' + port; + } else if (scheme === 'file') output += '//'; + output += url.cannotBeABaseURL ? path[0] : path.length ? '/' + join(path, '/') : ''; + if (query !== null) output += '?' + query; + if (fragment !== null) output += '#' + fragment; + return output; + }, + // https://url.spec.whatwg.org/#dom-url-href + setHref: function (href) { + var failure = this.parse(href); + if (failure) throw new TypeError(failure); + this.searchParams.update(); + }, + // https://url.spec.whatwg.org/#dom-url-origin + getOrigin: function () { + var scheme = this.scheme; + var port = this.port; + if (scheme === 'blob') try { + return new URLConstructor(scheme.path[0]).origin; + } catch (error) { + return 'null'; + } + if (scheme === 'file' || !this.isSpecial()) return 'null'; + return scheme + '://' + serializeHost(this.host) + (port !== null ? ':' + port : ''); + }, + // https://url.spec.whatwg.org/#dom-url-protocol + getProtocol: function () { + return this.scheme + ':'; + }, + setProtocol: function (protocol) { + this.parse($toString(protocol) + ':', SCHEME_START); + }, + // https://url.spec.whatwg.org/#dom-url-username + getUsername: function () { + return this.username; + }, + setUsername: function (username) { + var codePoints = arrayFrom($toString(username)); + if (this.cannotHaveUsernamePasswordPort()) return; + this.username = ''; + for (var i = 0; i < codePoints.length; i++) { + this.username += percentEncode(codePoints[i], userinfoPercentEncodeSet); + } + }, + // https://url.spec.whatwg.org/#dom-url-password + getPassword: function () { + return this.password; + }, + setPassword: function (password) { + var codePoints = arrayFrom($toString(password)); + if (this.cannotHaveUsernamePasswordPort()) return; + this.password = ''; + for (var i = 0; i < codePoints.length; i++) { + this.password += percentEncode(codePoints[i], userinfoPercentEncodeSet); + } + }, + // https://url.spec.whatwg.org/#dom-url-host + getHost: function () { + var host = this.host; + var port = this.port; + return host === null ? '' + : port === null ? serializeHost(host) + : serializeHost(host) + ':' + port; + }, + setHost: function (host) { + if (this.cannotBeABaseURL) return; + this.parse(host, HOST); + }, + // https://url.spec.whatwg.org/#dom-url-hostname + getHostname: function () { + var host = this.host; + return host === null ? '' : serializeHost(host); + }, + setHostname: function (hostname) { + if (this.cannotBeABaseURL) return; + this.parse(hostname, HOSTNAME); + }, + // https://url.spec.whatwg.org/#dom-url-port + getPort: function () { + var port = this.port; + return port === null ? '' : $toString(port); + }, + setPort: function (port) { + if (this.cannotHaveUsernamePasswordPort()) return; + port = $toString(port); + if (port === '') this.port = null; + else this.parse(port, PORT); + }, + // https://url.spec.whatwg.org/#dom-url-pathname + getPathname: function () { + var path = this.path; + return this.cannotBeABaseURL ? path[0] : path.length ? '/' + join(path, '/') : ''; + }, + setPathname: function (pathname) { + if (this.cannotBeABaseURL) return; + this.path = []; + this.parse(pathname, PATH_START); + }, + // https://url.spec.whatwg.org/#dom-url-search + getSearch: function () { + var query = this.query; + return query ? '?' + query : ''; + }, + setSearch: function (search) { + search = $toString(search); + if (search === '') { + this.query = null; + } else { + if (charAt(search, 0) === '?') search = stringSlice(search, 1); + this.query = ''; + this.parse(search, QUERY); + } + this.searchParams.update(); + }, + // https://url.spec.whatwg.org/#dom-url-searchparams + getSearchParams: function () { + return this.searchParams.facade; + }, + // https://url.spec.whatwg.org/#dom-url-hash + getHash: function () { + var fragment = this.fragment; + return fragment ? '#' + fragment : ''; + }, + setHash: function (hash) { + hash = $toString(hash); + if (hash === '') { + this.fragment = null; + return; + } + if (charAt(hash, 0) === '#') hash = stringSlice(hash, 1); + this.fragment = ''; + this.parse(hash, FRAGMENT); + }, + update: function () { + this.query = this.searchParams.serialize() || null; + } + }; + + // `URL` constructor + // https://url.spec.whatwg.org/#url-class + var URLConstructor = function URL(url /* , base */) { + var that = anInstance(this, URLPrototype); + var base = validateArgumentsLength(arguments.length, 1) > 1 ? arguments[1] : undefined; + var state = setInternalState(that, new URLState(url, false, base)); + if (!DESCRIPTORS) { + that.href = state.serialize(); + that.origin = state.getOrigin(); + that.protocol = state.getProtocol(); + that.username = state.getUsername(); + that.password = state.getPassword(); + that.host = state.getHost(); + that.hostname = state.getHostname(); + that.port = state.getPort(); + that.pathname = state.getPathname(); + that.search = state.getSearch(); + that.searchParams = state.getSearchParams(); + that.hash = state.getHash(); + } + }; + + var URLPrototype = URLConstructor.prototype; + + var accessorDescriptor = function (getter, setter) { + return { + get: function () { + return getInternalURLState(this)[getter](); + }, + set: setter && function (value) { + return getInternalURLState(this)[setter](value); + }, + configurable: true, + enumerable: true + }; + }; + + if (DESCRIPTORS) { + // `URL.prototype.href` accessors pair + // https://url.spec.whatwg.org/#dom-url-href + defineBuiltInAccessor(URLPrototype, 'href', accessorDescriptor('serialize', 'setHref')); + // `URL.prototype.origin` getter + // https://url.spec.whatwg.org/#dom-url-origin + defineBuiltInAccessor(URLPrototype, 'origin', accessorDescriptor('getOrigin')); + // `URL.prototype.protocol` accessors pair + // https://url.spec.whatwg.org/#dom-url-protocol + defineBuiltInAccessor(URLPrototype, 'protocol', accessorDescriptor('getProtocol', 'setProtocol')); + // `URL.prototype.username` accessors pair + // https://url.spec.whatwg.org/#dom-url-username + defineBuiltInAccessor(URLPrototype, 'username', accessorDescriptor('getUsername', 'setUsername')); + // `URL.prototype.password` accessors pair + // https://url.spec.whatwg.org/#dom-url-password + defineBuiltInAccessor(URLPrototype, 'password', accessorDescriptor('getPassword', 'setPassword')); + // `URL.prototype.host` accessors pair + // https://url.spec.whatwg.org/#dom-url-host + defineBuiltInAccessor(URLPrototype, 'host', accessorDescriptor('getHost', 'setHost')); + // `URL.prototype.hostname` accessors pair + // https://url.spec.whatwg.org/#dom-url-hostname + defineBuiltInAccessor(URLPrototype, 'hostname', accessorDescriptor('getHostname', 'setHostname')); + // `URL.prototype.port` accessors pair + // https://url.spec.whatwg.org/#dom-url-port + defineBuiltInAccessor(URLPrototype, 'port', accessorDescriptor('getPort', 'setPort')); + // `URL.prototype.pathname` accessors pair + // https://url.spec.whatwg.org/#dom-url-pathname + defineBuiltInAccessor(URLPrototype, 'pathname', accessorDescriptor('getPathname', 'setPathname')); + // `URL.prototype.search` accessors pair + // https://url.spec.whatwg.org/#dom-url-search + defineBuiltInAccessor(URLPrototype, 'search', accessorDescriptor('getSearch', 'setSearch')); + // `URL.prototype.searchParams` getter + // https://url.spec.whatwg.org/#dom-url-searchparams + defineBuiltInAccessor(URLPrototype, 'searchParams', accessorDescriptor('getSearchParams')); + // `URL.prototype.hash` accessors pair + // https://url.spec.whatwg.org/#dom-url-hash + defineBuiltInAccessor(URLPrototype, 'hash', accessorDescriptor('getHash', 'setHash')); + } + + // `URL.prototype.toJSON` method + // https://url.spec.whatwg.org/#dom-url-tojson + defineBuiltIn(URLPrototype, 'toJSON', function toJSON() { + return getInternalURLState(this).serialize(); + }, { enumerable: true }); + + // `URL.prototype.toString` method + // https://url.spec.whatwg.org/#URL-stringification-behavior + defineBuiltIn(URLPrototype, 'toString', function toString() { + return getInternalURLState(this).serialize(); + }, { enumerable: true }); + + if (NativeURL) { + var nativeCreateObjectURL = NativeURL.createObjectURL; + var nativeRevokeObjectURL = NativeURL.revokeObjectURL; + // `URL.createObjectURL` method + // https://developer.mozilla.org/en-US/docs/Web/API/URL/createObjectURL + if (nativeCreateObjectURL) defineBuiltIn(URLConstructor, 'createObjectURL', bind(nativeCreateObjectURL, NativeURL)); + // `URL.revokeObjectURL` method + // https://developer.mozilla.org/en-US/docs/Web/API/URL/revokeObjectURL + if (nativeRevokeObjectURL) defineBuiltIn(URLConstructor, 'revokeObjectURL', bind(nativeRevokeObjectURL, NativeURL)); + } + + setToStringTag(URLConstructor, 'URL'); + + $({ global: true, constructor: true, forced: !USE_NATIVE_URL, sham: !DESCRIPTORS }, { + URL: URLConstructor + }); + return web_url_constructor; +} + +var hasRequiredWeb_url; + +function requireWeb_url () { + if (hasRequiredWeb_url) return web_url; + hasRequiredWeb_url = 1; + // TODO: Remove this module from `core-js@4` since it's replaced to module below + requireWeb_url_constructor(); + return web_url; +} + +var web_url_canParse = {}; + +var hasRequiredWeb_url_canParse; + +function requireWeb_url_canParse () { + if (hasRequiredWeb_url_canParse) return web_url_canParse; + hasRequiredWeb_url_canParse = 1; + var $ = require_export(); + var getBuiltIn = requireGetBuiltIn(); + var fails = requireFails(); + var validateArgumentsLength = requireValidateArgumentsLength(); + var toString = requireToString(); + var USE_NATIVE_URL = requireUrlConstructorDetection(); + + var URL = getBuiltIn('URL'); + + // https://github.com/nodejs/node/issues/47505 + // https://github.com/denoland/deno/issues/18893 + var THROWS_WITHOUT_ARGUMENTS = USE_NATIVE_URL && fails(function () { + URL.canParse(); + }); + + // Bun ~ 1.0.30 bug + // https://github.com/oven-sh/bun/issues/9250 + var WRONG_ARITY = fails(function () { + return URL.canParse.length !== 1; + }); + + // `URL.canParse` method + // https://url.spec.whatwg.org/#dom-url-canparse + $({ target: 'URL', stat: true, forced: !THROWS_WITHOUT_ARGUMENTS || WRONG_ARITY }, { + canParse: function canParse(url) { + var length = validateArgumentsLength(arguments.length, 1); + var urlString = toString(url); + var base = length < 2 || arguments[1] === undefined ? undefined : toString(arguments[1]); + try { + return !!new URL(urlString, base); + } catch (error) { + return false; + } + } + }); + return web_url_canParse; +} + +var web_url_parse = {}; + +var hasRequiredWeb_url_parse; + +function requireWeb_url_parse () { + if (hasRequiredWeb_url_parse) return web_url_parse; + hasRequiredWeb_url_parse = 1; + var $ = require_export(); + var getBuiltIn = requireGetBuiltIn(); + var validateArgumentsLength = requireValidateArgumentsLength(); + var toString = requireToString(); + var USE_NATIVE_URL = requireUrlConstructorDetection(); + + var URL = getBuiltIn('URL'); + + // `URL.parse` method + // https://url.spec.whatwg.org/#dom-url-canparse + $({ target: 'URL', stat: true, forced: !USE_NATIVE_URL }, { + parse: function parse(url) { + var length = validateArgumentsLength(arguments.length, 1); + var urlString = toString(url); + var base = length < 2 || arguments[1] === undefined ? undefined : toString(arguments[1]); + try { + return new URL(urlString, base); + } catch (error) { + return null; + } + } + }); + return web_url_parse; +} + +var web_url_toJson = {}; + +var hasRequiredWeb_url_toJson; + +function requireWeb_url_toJson () { + if (hasRequiredWeb_url_toJson) return web_url_toJson; + hasRequiredWeb_url_toJson = 1; + var $ = require_export(); + var call = requireFunctionCall(); + + // `URL.prototype.toJSON` method + // https://url.spec.whatwg.org/#dom-url-tojson + $({ target: 'URL', proto: true, enumerable: true }, { + toJSON: function toJSON() { + return call(URL.prototype.toString, this); + } + }); + return web_url_toJson; +} + +var web_urlSearchParams = {}; + +var hasRequiredWeb_urlSearchParams; + +function requireWeb_urlSearchParams () { + if (hasRequiredWeb_urlSearchParams) return web_urlSearchParams; + hasRequiredWeb_urlSearchParams = 1; + // TODO: Remove this module from `core-js@4` since it's replaced to module below + requireWeb_urlSearchParams_constructor(); + return web_urlSearchParams; +} + +var web_urlSearchParams_delete = {}; + +var hasRequiredWeb_urlSearchParams_delete; + +function requireWeb_urlSearchParams_delete () { + if (hasRequiredWeb_urlSearchParams_delete) return web_urlSearchParams_delete; + hasRequiredWeb_urlSearchParams_delete = 1; + var defineBuiltIn = requireDefineBuiltIn(); + var uncurryThis = requireFunctionUncurryThis(); + var toString = requireToString(); + var validateArgumentsLength = requireValidateArgumentsLength(); + + var $URLSearchParams = URLSearchParams; + var URLSearchParamsPrototype = $URLSearchParams.prototype; + var append = uncurryThis(URLSearchParamsPrototype.append); + var $delete = uncurryThis(URLSearchParamsPrototype['delete']); + var forEach = uncurryThis(URLSearchParamsPrototype.forEach); + var push = uncurryThis([].push); + var params = new $URLSearchParams('a=1&a=2&b=3'); + + params['delete']('a', 1); + // `undefined` case is a Chromium 117 bug + // https://bugs.chromium.org/p/v8/issues/detail?id=14222 + params['delete']('b', undefined); + + if (params + '' !== 'a=2') { + defineBuiltIn(URLSearchParamsPrototype, 'delete', function (name /* , value */) { + var length = arguments.length; + var $value = length < 2 ? undefined : arguments[1]; + if (length && $value === undefined) return $delete(this, name); + var entries = []; + forEach(this, function (v, k) { // also validates `this` + push(entries, { key: k, value: v }); + }); + validateArgumentsLength(length, 1); + var key = toString(name); + var value = toString($value); + var index = 0; + var dindex = 0; + var found = false; + var entriesLength = entries.length; + var entry; + while (index < entriesLength) { + entry = entries[index++]; + if (found || entry.key === key) { + found = true; + $delete(this, entry.key); + } else dindex++; + } + while (dindex < entriesLength) { + entry = entries[dindex++]; + if (!(entry.key === key && entry.value === value)) append(this, entry.key, entry.value); + } + }, { enumerable: true, unsafe: true }); + } + return web_urlSearchParams_delete; +} + +var web_urlSearchParams_has = {}; + +var hasRequiredWeb_urlSearchParams_has; + +function requireWeb_urlSearchParams_has () { + if (hasRequiredWeb_urlSearchParams_has) return web_urlSearchParams_has; + hasRequiredWeb_urlSearchParams_has = 1; + var defineBuiltIn = requireDefineBuiltIn(); + var uncurryThis = requireFunctionUncurryThis(); + var toString = requireToString(); + var validateArgumentsLength = requireValidateArgumentsLength(); + + var $URLSearchParams = URLSearchParams; + var URLSearchParamsPrototype = $URLSearchParams.prototype; + var getAll = uncurryThis(URLSearchParamsPrototype.getAll); + var $has = uncurryThis(URLSearchParamsPrototype.has); + var params = new $URLSearchParams('a=1'); + + // `undefined` case is a Chromium 117 bug + // https://bugs.chromium.org/p/v8/issues/detail?id=14222 + if (params.has('a', 2) || !params.has('a', undefined)) { + defineBuiltIn(URLSearchParamsPrototype, 'has', function has(name /* , value */) { + var length = arguments.length; + var $value = length < 2 ? undefined : arguments[1]; + if (length && $value === undefined) return $has(this, name); + var values = getAll(this, name); // also validates `this` + validateArgumentsLength(length, 1); + var value = toString($value); + var index = 0; + while (index < values.length) { + if (values[index++] === value) return true; + } return false; + }, { enumerable: true, unsafe: true }); + } + return web_urlSearchParams_has; +} + +var web_urlSearchParams_size = {}; + +var hasRequiredWeb_urlSearchParams_size; + +function requireWeb_urlSearchParams_size () { + if (hasRequiredWeb_urlSearchParams_size) return web_urlSearchParams_size; + hasRequiredWeb_urlSearchParams_size = 1; + var DESCRIPTORS = requireDescriptors(); + var uncurryThis = requireFunctionUncurryThis(); + var defineBuiltInAccessor = requireDefineBuiltInAccessor(); + + var URLSearchParamsPrototype = URLSearchParams.prototype; + var forEach = uncurryThis(URLSearchParamsPrototype.forEach); + + // `URLSearchParams.prototype.size` getter + // https://github.com/whatwg/url/pull/734 + if (DESCRIPTORS && !('size' in URLSearchParamsPrototype)) { + defineBuiltInAccessor(URLSearchParamsPrototype, 'size', { + get: function size() { + var count = 0; + forEach(this, function () { count++; }); + return count; + }, + configurable: true, + enumerable: true + }); + } + return web_urlSearchParams_size; +} + +var full; +var hasRequiredFull; + +function requireFull () { + if (hasRequiredFull) return full; + hasRequiredFull = 1; + requireEs_symbol(); + requireEs_symbol_description(); + requireEs_symbol_asyncIterator(); + requireEs_symbol_hasInstance(); + requireEs_symbol_isConcatSpreadable(); + requireEs_symbol_iterator(); + requireEs_symbol_match(); + requireEs_symbol_matchAll(); + requireEs_symbol_replace(); + requireEs_symbol_search(); + requireEs_symbol_species(); + requireEs_symbol_split(); + requireEs_symbol_toPrimitive(); + requireEs_symbol_toStringTag(); + requireEs_symbol_unscopables(); + requireEs_error_cause(); + requireEs_error_toString(); + requireEs_aggregateError(); + requireEs_aggregateError_cause(); + requireEs_array_at(); + requireEs_array_concat(); + requireEs_array_copyWithin(); + requireEs_array_every(); + requireEs_array_fill(); + requireEs_array_filter(); + requireEs_array_find(); + requireEs_array_findIndex(); + requireEs_array_findLast(); + requireEs_array_findLastIndex(); + requireEs_array_flat(); + requireEs_array_flatMap(); + requireEs_array_forEach(); + requireEs_array_from(); + requireEs_array_includes(); + requireEs_array_indexOf(); + requireEs_array_isArray(); + requireEs_array_iterator(); + requireEs_array_join(); + requireEs_array_lastIndexOf(); + requireEs_array_map(); + requireEs_array_of(); + requireEs_array_push(); + requireEs_array_reduce(); + requireEs_array_reduceRight(); + requireEs_array_reverse(); + requireEs_array_slice(); + requireEs_array_some(); + requireEs_array_sort(); + requireEs_array_species(); + requireEs_array_splice(); + requireEs_array_toReversed(); + requireEs_array_toSorted(); + requireEs_array_toSpliced(); + requireEs_array_unscopables_flat(); + requireEs_array_unscopables_flatMap(); + requireEs_array_unshift(); + requireEs_array_with(); + requireEs_arrayBuffer_constructor(); + requireEs_arrayBuffer_isView(); + requireEs_arrayBuffer_slice(); + requireEs_dataView(); + requireEs_arrayBuffer_detached(); + requireEs_arrayBuffer_transfer(); + requireEs_arrayBuffer_transferToFixedLength(); + requireEs_date_getYear(); + requireEs_date_now(); + requireEs_date_setYear(); + requireEs_date_toGmtString(); + requireEs_date_toIsoString(); + requireEs_date_toJson(); + requireEs_date_toPrimitive(); + requireEs_date_toString(); + requireEs_escape(); + requireEs_function_bind(); + requireEs_function_hasInstance(); + requireEs_function_name(); + requireEs_globalThis(); + requireEs_json_stringify(); + requireEs_json_toStringTag(); + requireEs_map(); + requireEs_map_groupBy(); + requireEs_math_acosh(); + requireEs_math_asinh(); + requireEs_math_atanh(); + requireEs_math_cbrt(); + requireEs_math_clz32(); + requireEs_math_cosh(); + requireEs_math_expm1(); + requireEs_math_fround(); + requireEs_math_hypot(); + requireEs_math_imul(); + requireEs_math_log10(); + requireEs_math_log1p(); + requireEs_math_log2(); + requireEs_math_sign(); + requireEs_math_sinh(); + requireEs_math_tanh(); + requireEs_math_toStringTag(); + requireEs_math_trunc(); + requireEs_number_constructor(); + requireEs_number_epsilon(); + requireEs_number_isFinite(); + requireEs_number_isInteger(); + requireEs_number_isNan(); + requireEs_number_isSafeInteger(); + requireEs_number_maxSafeInteger(); + requireEs_number_minSafeInteger(); + requireEs_number_parseFloat(); + requireEs_number_parseInt(); + requireEs_number_toExponential(); + requireEs_number_toFixed(); + requireEs_number_toPrecision(); + requireEs_object_assign(); + requireEs_object_create(); + requireEs_object_defineGetter(); + requireEs_object_defineProperties(); + requireEs_object_defineProperty(); + requireEs_object_defineSetter(); + requireEs_object_entries(); + requireEs_object_freeze(); + requireEs_object_fromEntries(); + requireEs_object_getOwnPropertyDescriptor(); + requireEs_object_getOwnPropertyDescriptors(); + requireEs_object_getOwnPropertyNames(); + requireEs_object_getPrototypeOf(); + requireEs_object_groupBy(); + requireEs_object_hasOwn(); + requireEs_object_is(); + requireEs_object_isExtensible(); + requireEs_object_isFrozen(); + requireEs_object_isSealed(); + requireEs_object_keys(); + requireEs_object_lookupGetter(); + requireEs_object_lookupSetter(); + requireEs_object_preventExtensions(); + requireEs_object_proto(); + requireEs_object_seal(); + requireEs_object_setPrototypeOf(); + requireEs_object_toString(); + requireEs_object_values(); + requireEs_parseFloat(); + requireEs_parseInt(); + requireEs_promise(); + requireEs_promise_allSettled(); + requireEs_promise_any(); + requireEs_promise_finally(); + requireEs_promise_withResolvers(); + requireEs_reflect_apply(); + requireEs_reflect_construct(); + requireEs_reflect_defineProperty(); + requireEs_reflect_deleteProperty(); + requireEs_reflect_get(); + requireEs_reflect_getOwnPropertyDescriptor(); + requireEs_reflect_getPrototypeOf(); + requireEs_reflect_has(); + requireEs_reflect_isExtensible(); + requireEs_reflect_ownKeys(); + requireEs_reflect_preventExtensions(); + requireEs_reflect_set(); + requireEs_reflect_setPrototypeOf(); + requireEs_reflect_toStringTag(); + requireEs_regexp_constructor(); + requireEs_regexp_dotAll(); + requireEs_regexp_exec(); + requireEs_regexp_flags(); + requireEs_regexp_sticky(); + requireEs_regexp_test(); + requireEs_regexp_toString(); + requireEs_set(); + requireEs_set_difference_v2(); + requireEs_set_intersection_v2(); + requireEs_set_isDisjointFrom_v2(); + requireEs_set_isSubsetOf_v2(); + requireEs_set_isSupersetOf_v2(); + requireEs_set_symmetricDifference_v2(); + requireEs_set_union_v2(); + requireEs_string_atAlternative(); + requireEs_string_codePointAt(); + requireEs_string_endsWith(); + requireEs_string_fromCodePoint(); + requireEs_string_includes(); + requireEs_string_isWellFormed(); + requireEs_string_iterator(); + requireEs_string_match(); + requireEs_string_matchAll(); + requireEs_string_padEnd(); + requireEs_string_padStart(); + requireEs_string_raw(); + requireEs_string_repeat(); + requireEs_string_replace(); + requireEs_string_replaceAll(); + requireEs_string_search(); + requireEs_string_split(); + requireEs_string_startsWith(); + requireEs_string_substr(); + requireEs_string_toWellFormed(); + requireEs_string_trim(); + requireEs_string_trimEnd(); + requireEs_string_trimStart(); + requireEs_string_anchor(); + requireEs_string_big(); + requireEs_string_blink(); + requireEs_string_bold(); + requireEs_string_fixed(); + requireEs_string_fontcolor(); + requireEs_string_fontsize(); + requireEs_string_italics(); + requireEs_string_link(); + requireEs_string_small(); + requireEs_string_strike(); + requireEs_string_sub(); + requireEs_string_sup(); + requireEs_typedArray_float32Array(); + requireEs_typedArray_float64Array(); + requireEs_typedArray_int8Array(); + requireEs_typedArray_int16Array(); + requireEs_typedArray_int32Array(); + requireEs_typedArray_uint8Array(); + requireEs_typedArray_uint8ClampedArray(); + requireEs_typedArray_uint16Array(); + requireEs_typedArray_uint32Array(); + requireEs_typedArray_at(); + requireEs_typedArray_copyWithin(); + requireEs_typedArray_every(); + requireEs_typedArray_fill(); + requireEs_typedArray_filter(); + requireEs_typedArray_find(); + requireEs_typedArray_findIndex(); + requireEs_typedArray_findLast(); + requireEs_typedArray_findLastIndex(); + requireEs_typedArray_forEach(); + requireEs_typedArray_from(); + requireEs_typedArray_includes(); + requireEs_typedArray_indexOf(); + requireEs_typedArray_iterator(); + requireEs_typedArray_join(); + requireEs_typedArray_lastIndexOf(); + requireEs_typedArray_map(); + requireEs_typedArray_of(); + requireEs_typedArray_reduce(); + requireEs_typedArray_reduceRight(); + requireEs_typedArray_reverse(); + requireEs_typedArray_set(); + requireEs_typedArray_slice(); + requireEs_typedArray_some(); + requireEs_typedArray_sort(); + requireEs_typedArray_subarray(); + requireEs_typedArray_toLocaleString(); + requireEs_typedArray_toReversed(); + requireEs_typedArray_toSorted(); + requireEs_typedArray_toString(); + requireEs_typedArray_with(); + requireEs_unescape(); + requireEs_weakMap(); + requireEs_weakSet(); + requireEsnext_aggregateError(); + requireEsnext_suppressedError_constructor(); + requireEsnext_array_fromAsync(); + requireEsnext_array_at(); + requireEsnext_array_filterOut(); + requireEsnext_array_filterReject(); + requireEsnext_array_findLast(); + requireEsnext_array_findLastIndex(); + requireEsnext_array_group(); + requireEsnext_array_groupBy(); + requireEsnext_array_groupByToMap(); + requireEsnext_array_groupToMap(); + requireEsnext_array_isTemplateObject(); + requireEsnext_array_lastIndex(); + requireEsnext_array_lastItem(); + requireEsnext_array_toReversed(); + requireEsnext_array_toSorted(); + requireEsnext_array_toSpliced(); + requireEsnext_array_uniqueBy(); + requireEsnext_array_with(); + requireEsnext_arrayBuffer_detached(); + requireEsnext_arrayBuffer_transfer(); + requireEsnext_arrayBuffer_transferToFixedLength(); + requireEsnext_asyncDisposableStack_constructor(); + requireEsnext_asyncIterator_constructor(); + requireEsnext_asyncIterator_asIndexedPairs(); + requireEsnext_asyncIterator_asyncDispose(); + requireEsnext_asyncIterator_drop(); + requireEsnext_asyncIterator_every(); + requireEsnext_asyncIterator_filter(); + requireEsnext_asyncIterator_find(); + requireEsnext_asyncIterator_flatMap(); + requireEsnext_asyncIterator_forEach(); + requireEsnext_asyncIterator_from(); + requireEsnext_asyncIterator_indexed(); + requireEsnext_asyncIterator_map(); + requireEsnext_asyncIterator_reduce(); + requireEsnext_asyncIterator_some(); + requireEsnext_asyncIterator_take(); + requireEsnext_asyncIterator_toArray(); + requireEsnext_bigint_range(); + requireEsnext_compositeKey(); + requireEsnext_compositeSymbol(); + requireEsnext_dataView_getFloat16(); + requireEsnext_dataView_getUint8Clamped(); + requireEsnext_dataView_setFloat16(); + requireEsnext_dataView_setUint8Clamped(); + requireEsnext_disposableStack_constructor(); + requireEsnext_function_demethodize(); + requireEsnext_function_isCallable(); + requireEsnext_function_isConstructor(); + requireEsnext_function_metadata(); + requireEsnext_function_unThis(); + requireEsnext_globalThis(); + requireEsnext_iterator_constructor(); + requireEsnext_iterator_asIndexedPairs(); + requireEsnext_iterator_dispose(); + requireEsnext_iterator_drop(); + requireEsnext_iterator_every(); + requireEsnext_iterator_filter(); + requireEsnext_iterator_find(); + requireEsnext_iterator_flatMap(); + requireEsnext_iterator_forEach(); + requireEsnext_iterator_from(); + requireEsnext_iterator_indexed(); + requireEsnext_iterator_map(); + requireEsnext_iterator_range(); + requireEsnext_iterator_reduce(); + requireEsnext_iterator_some(); + requireEsnext_iterator_take(); + requireEsnext_iterator_toArray(); + requireEsnext_iterator_toAsync(); + requireEsnext_json_isRawJson(); + requireEsnext_json_parse(); + requireEsnext_json_rawJson(); + requireEsnext_map_deleteAll(); + requireEsnext_map_emplace(); + requireEsnext_map_every(); + requireEsnext_map_filter(); + requireEsnext_map_find(); + requireEsnext_map_findKey(); + requireEsnext_map_from(); + requireEsnext_map_groupBy(); + requireEsnext_map_includes(); + requireEsnext_map_keyBy(); + requireEsnext_map_keyOf(); + requireEsnext_map_mapKeys(); + requireEsnext_map_mapValues(); + requireEsnext_map_merge(); + requireEsnext_map_of(); + requireEsnext_map_reduce(); + requireEsnext_map_some(); + requireEsnext_map_update(); + requireEsnext_map_updateOrInsert(); + requireEsnext_map_upsert(); + requireEsnext_math_clamp(); + requireEsnext_math_degPerRad(); + requireEsnext_math_degrees(); + requireEsnext_math_fscale(); + requireEsnext_math_f16round(); + requireEsnext_math_iaddh(); + requireEsnext_math_imulh(); + requireEsnext_math_isubh(); + requireEsnext_math_radPerDeg(); + requireEsnext_math_radians(); + requireEsnext_math_scale(); + requireEsnext_math_seededPrng(); + requireEsnext_math_signbit(); + requireEsnext_math_sumPrecise(); + requireEsnext_math_umulh(); + requireEsnext_number_fromString(); + requireEsnext_number_range(); + requireEsnext_object_hasOwn(); + requireEsnext_object_iterateEntries(); + requireEsnext_object_iterateKeys(); + requireEsnext_object_iterateValues(); + requireEsnext_object_groupBy(); + requireEsnext_observable(); + requireEsnext_promise_allSettled(); + requireEsnext_promise_any(); + requireEsnext_promise_try(); + requireEsnext_promise_withResolvers(); + requireEsnext_reflect_defineMetadata(); + requireEsnext_reflect_deleteMetadata(); + requireEsnext_reflect_getMetadata(); + requireEsnext_reflect_getMetadataKeys(); + requireEsnext_reflect_getOwnMetadata(); + requireEsnext_reflect_getOwnMetadataKeys(); + requireEsnext_reflect_hasMetadata(); + requireEsnext_reflect_hasOwnMetadata(); + requireEsnext_reflect_metadata(); + requireEsnext_regexp_escape(); + requireEsnext_set_addAll(); + requireEsnext_set_deleteAll(); + requireEsnext_set_difference_v2(); + requireEsnext_set_difference(); + requireEsnext_set_every(); + requireEsnext_set_filter(); + requireEsnext_set_find(); + requireEsnext_set_from(); + requireEsnext_set_intersection_v2(); + requireEsnext_set_intersection(); + requireEsnext_set_isDisjointFrom_v2(); + requireEsnext_set_isDisjointFrom(); + requireEsnext_set_isSubsetOf_v2(); + requireEsnext_set_isSubsetOf(); + requireEsnext_set_isSupersetOf_v2(); + requireEsnext_set_isSupersetOf(); + requireEsnext_set_join(); + requireEsnext_set_map(); + requireEsnext_set_of(); + requireEsnext_set_reduce(); + requireEsnext_set_some(); + requireEsnext_set_symmetricDifference_v2(); + requireEsnext_set_symmetricDifference(); + requireEsnext_set_union_v2(); + requireEsnext_set_union(); + requireEsnext_string_at(); + requireEsnext_string_cooked(); + requireEsnext_string_codePoints(); + requireEsnext_string_dedent(); + requireEsnext_string_isWellFormed(); + requireEsnext_string_matchAll(); + requireEsnext_string_replaceAll(); + requireEsnext_string_toWellFormed(); + requireEsnext_symbol_asyncDispose(); + requireEsnext_symbol_customMatcher(); + requireEsnext_symbol_dispose(); + requireEsnext_symbol_isRegisteredSymbol(); + requireEsnext_symbol_isRegistered(); + requireEsnext_symbol_isWellKnownSymbol(); + requireEsnext_symbol_isWellKnown(); + requireEsnext_symbol_matcher(); + requireEsnext_symbol_metadata(); + requireEsnext_symbol_metadataKey(); + requireEsnext_symbol_observable(); + requireEsnext_symbol_patternMatch(); + requireEsnext_symbol_replaceAll(); + requireEsnext_typedArray_fromAsync(); + requireEsnext_typedArray_at(); + requireEsnext_typedArray_filterOut(); + requireEsnext_typedArray_filterReject(); + requireEsnext_typedArray_findLast(); + requireEsnext_typedArray_findLastIndex(); + requireEsnext_typedArray_groupBy(); + requireEsnext_typedArray_toReversed(); + requireEsnext_typedArray_toSorted(); + requireEsnext_typedArray_toSpliced(); + requireEsnext_typedArray_uniqueBy(); + requireEsnext_typedArray_with(); + requireEsnext_uint8Array_fromBase64(); + requireEsnext_uint8Array_fromHex(); + requireEsnext_uint8Array_setFromBase64(); + requireEsnext_uint8Array_setFromHex(); + requireEsnext_uint8Array_toBase64(); + requireEsnext_uint8Array_toHex(); + requireEsnext_weakMap_deleteAll(); + requireEsnext_weakMap_from(); + requireEsnext_weakMap_of(); + requireEsnext_weakMap_emplace(); + requireEsnext_weakMap_upsert(); + requireEsnext_weakSet_addAll(); + requireEsnext_weakSet_deleteAll(); + requireEsnext_weakSet_from(); + requireEsnext_weakSet_of(); + requireWeb_atob(); + requireWeb_btoa(); + requireWeb_domCollections_forEach(); + requireWeb_domCollections_iterator(); + requireWeb_domException_constructor(); + requireWeb_domException_stack(); + requireWeb_domException_toStringTag(); + requireWeb_immediate(); + requireWeb_queueMicrotask(); + requireWeb_self(); + requireWeb_structuredClone(); + requireWeb_timers(); + requireWeb_url(); + requireWeb_url_canParse(); + requireWeb_url_parse(); + requireWeb_url_toJson(); + requireWeb_urlSearchParams(); + requireWeb_urlSearchParams_delete(); + requireWeb_urlSearchParams_has(); + requireWeb_urlSearchParams_size(); + + full = requirePath(); + return full; +} + +var coreJs; +var hasRequiredCoreJs; + +function requireCoreJs () { + if (hasRequiredCoreJs) return coreJs; + hasRequiredCoreJs = 1; + coreJs = requireFull(); + return coreJs; +} -/* eslint-disable no-new */ - -var global$e = global$L; -var fails$b = fails$Y; -var checkCorrectnessOfIteration = checkCorrectnessOfIteration$4; -var NATIVE_ARRAY_BUFFER_VIEWS$1 = arrayBufferViewCore.NATIVE_ARRAY_BUFFER_VIEWS; - -var ArrayBuffer$2 = global$e.ArrayBuffer; -var Int8Array$2 = global$e.Int8Array; - -var typedArrayConstructorsRequireWrappers = !NATIVE_ARRAY_BUFFER_VIEWS$1 || !fails$b(function () { - Int8Array$2(1); -}) || !fails$b(function () { - new Int8Array$2(-1); -}) || !checkCorrectnessOfIteration(function (iterable) { - new Int8Array$2(); - new Int8Array$2(null); - new Int8Array$2(1.5); - new Int8Array$2(iterable); -}, true) || fails$b(function () { - // Safari (11+) bug - a reason why even Safari 13 should load a typed array polyfill - return new Int8Array$2(new ArrayBuffer$2(2), 1, undefined).length !== 1; -}); - -var toInteger$3 = toInteger$f; - -var toPositiveInteger$5 = function (it) { - var result = toInteger$3(it); - if (result < 0) throw RangeError("The argument can't be less than 0"); - return result; -}; - -var toPositiveInteger$4 = toPositiveInteger$5; - -var toOffset$2 = function (it, BYTES) { - var offset = toPositiveInteger$4(it); - if (offset % BYTES) throw RangeError('Wrong offset'); - return offset; -}; - -var toObject$8 = toObject$u; -var toLength$8 = toLength$y; -var getIteratorMethod$5 = getIteratorMethod$8; -var isArrayIteratorMethod = isArrayIteratorMethod$3; -var bind$f = functionBindContext; -var aTypedArrayConstructor$6 = arrayBufferViewCore.aTypedArrayConstructor; - -var typedArrayFrom$2 = function from(source /* , mapfn, thisArg */) { - var O = toObject$8(source); - var argumentsLength = arguments.length; - var mapfn = argumentsLength > 1 ? arguments[1] : undefined; - var mapping = mapfn !== undefined; - var iteratorMethod = getIteratorMethod$5(O); - var i, length, result, step, iterator, next; - if (iteratorMethod != undefined && !isArrayIteratorMethod(iteratorMethod)) { - iterator = iteratorMethod.call(O); - next = iterator.next; - O = []; - while (!(step = next.call(iterator)).done) { - O.push(step.value); - } - } - if (mapping && argumentsLength > 2) { - mapfn = bind$f(mapfn, arguments[2], 2); - } - length = toLength$8(O.length); - result = new (aTypedArrayConstructor$6(this))(length); - for (i = 0; length > i; i++) { - result[i] = mapping ? mapfn(O[i], i) : O[i]; - } - return result; -}; - -var $$25 = _export; -var global$d = global$L; -var DESCRIPTORS$7 = descriptors; -var TYPED_ARRAYS_CONSTRUCTORS_REQUIRES_WRAPPERS$2 = typedArrayConstructorsRequireWrappers; -var ArrayBufferViewCore$p = arrayBufferViewCore; -var ArrayBufferModule = arrayBuffer; -var anInstance$5 = anInstance$b; -var createPropertyDescriptor$2 = createPropertyDescriptor$9; -var createNonEnumerableProperty$8 = createNonEnumerableProperty$m; -var toLength$7 = toLength$y; -var toIndex = toIndex$2; -var toOffset$1 = toOffset$2; -var toPrimitive$1 = toPrimitive$b; -var has$7 = has$o; -var classof$1 = classof$b; -var isObject$7 = isObject$B; -var create$6 = objectCreate; -var setPrototypeOf = objectSetPrototypeOf$1; -var getOwnPropertyNames = objectGetOwnPropertyNames.f; -var typedArrayFrom$1 = typedArrayFrom$2; -var forEach$1 = arrayIteration.forEach; -var setSpecies$1 = setSpecies$7; -var definePropertyModule$2 = objectDefineProperty; -var getOwnPropertyDescriptorModule$3 = objectGetOwnPropertyDescriptor; -var InternalStateModule$9 = internalState; -var inheritIfRequired = inheritIfRequired$4; - -var getInternalState$7 = InternalStateModule$9.get; -var setInternalState$9 = InternalStateModule$9.set; -var nativeDefineProperty = definePropertyModule$2.f; -var nativeGetOwnPropertyDescriptor = getOwnPropertyDescriptorModule$3.f; -var round = Math.round; -var RangeError$1 = global$d.RangeError; -var ArrayBuffer$1 = ArrayBufferModule.ArrayBuffer; -var DataView$1 = ArrayBufferModule.DataView; -var NATIVE_ARRAY_BUFFER_VIEWS = ArrayBufferViewCore$p.NATIVE_ARRAY_BUFFER_VIEWS; -var TYPED_ARRAY_TAG = ArrayBufferViewCore$p.TYPED_ARRAY_TAG; -var TypedArray = ArrayBufferViewCore$p.TypedArray; -var TypedArrayPrototype = ArrayBufferViewCore$p.TypedArrayPrototype; -var aTypedArrayConstructor$5 = ArrayBufferViewCore$p.aTypedArrayConstructor; -var isTypedArray = ArrayBufferViewCore$p.isTypedArray; -var BYTES_PER_ELEMENT = 'BYTES_PER_ELEMENT'; -var WRONG_LENGTH = 'Wrong length'; - -var fromList = function (C, list) { - var index = 0; - var length = list.length; - var result = new (aTypedArrayConstructor$5(C))(length); - while (length > index) result[index] = list[index++]; - return result; -}; - -var addGetter = function (it, key) { - nativeDefineProperty(it, key, { get: function () { - return getInternalState$7(this)[key]; - } }); -}; - -var isArrayBuffer = function (it) { - var klass; - return it instanceof ArrayBuffer$1 || (klass = classof$1(it)) == 'ArrayBuffer' || klass == 'SharedArrayBuffer'; -}; - -var isTypedArrayIndex = function (target, key) { - return isTypedArray(target) - && typeof key != 'symbol' - && key in target - && String(+key) == String(key); -}; - -var wrappedGetOwnPropertyDescriptor = function getOwnPropertyDescriptor(target, key) { - return isTypedArrayIndex(target, key = toPrimitive$1(key, true)) - ? createPropertyDescriptor$2(2, target[key]) - : nativeGetOwnPropertyDescriptor(target, key); -}; - -var wrappedDefineProperty = function defineProperty(target, key, descriptor) { - if (isTypedArrayIndex(target, key = toPrimitive$1(key, true)) - && isObject$7(descriptor) - && has$7(descriptor, 'value') - && !has$7(descriptor, 'get') - && !has$7(descriptor, 'set') - // TODO: add validation descriptor w/o calling accessors - && !descriptor.configurable - && (!has$7(descriptor, 'writable') || descriptor.writable) - && (!has$7(descriptor, 'enumerable') || descriptor.enumerable) - ) { - target[key] = descriptor.value; - return target; - } return nativeDefineProperty(target, key, descriptor); -}; - -if (DESCRIPTORS$7) { - if (!NATIVE_ARRAY_BUFFER_VIEWS) { - getOwnPropertyDescriptorModule$3.f = wrappedGetOwnPropertyDescriptor; - definePropertyModule$2.f = wrappedDefineProperty; - addGetter(TypedArrayPrototype, 'buffer'); - addGetter(TypedArrayPrototype, 'byteOffset'); - addGetter(TypedArrayPrototype, 'byteLength'); - addGetter(TypedArrayPrototype, 'length'); - } - - $$25({ target: 'Object', stat: true, forced: !NATIVE_ARRAY_BUFFER_VIEWS }, { - getOwnPropertyDescriptor: wrappedGetOwnPropertyDescriptor, - defineProperty: wrappedDefineProperty - }); - - typedArrayConstructor.exports = function (TYPE, wrapper, CLAMPED) { - var BYTES = TYPE.match(/\d+$/)[0] / 8; - var CONSTRUCTOR_NAME = TYPE + (CLAMPED ? 'Clamped' : '') + 'Array'; - var GETTER = 'get' + TYPE; - var SETTER = 'set' + TYPE; - var NativeTypedArrayConstructor = global$d[CONSTRUCTOR_NAME]; - var TypedArrayConstructor = NativeTypedArrayConstructor; - var TypedArrayConstructorPrototype = TypedArrayConstructor && TypedArrayConstructor.prototype; - var exported = {}; - - var getter = function (that, index) { - var data = getInternalState$7(that); - return data.view[GETTER](index * BYTES + data.byteOffset, true); - }; - - var setter = function (that, index, value) { - var data = getInternalState$7(that); - if (CLAMPED) value = (value = round(value)) < 0 ? 0 : value > 0xFF ? 0xFF : value & 0xFF; - data.view[SETTER](index * BYTES + data.byteOffset, value, true); - }; - - var addElement = function (that, index) { - nativeDefineProperty(that, index, { - get: function () { - return getter(this, index); - }, - set: function (value) { - return setter(this, index, value); - }, - enumerable: true - }); - }; - - if (!NATIVE_ARRAY_BUFFER_VIEWS) { - TypedArrayConstructor = wrapper(function (that, data, offset, $length) { - anInstance$5(that, TypedArrayConstructor, CONSTRUCTOR_NAME); - var index = 0; - var byteOffset = 0; - var buffer, byteLength, length; - if (!isObject$7(data)) { - length = toIndex(data); - byteLength = length * BYTES; - buffer = new ArrayBuffer$1(byteLength); - } else if (isArrayBuffer(data)) { - buffer = data; - byteOffset = toOffset$1(offset, BYTES); - var $len = data.byteLength; - if ($length === undefined) { - if ($len % BYTES) throw RangeError$1(WRONG_LENGTH); - byteLength = $len - byteOffset; - if (byteLength < 0) throw RangeError$1(WRONG_LENGTH); - } else { - byteLength = toLength$7($length) * BYTES; - if (byteLength + byteOffset > $len) throw RangeError$1(WRONG_LENGTH); - } - length = byteLength / BYTES; - } else if (isTypedArray(data)) { - return fromList(TypedArrayConstructor, data); - } else { - return typedArrayFrom$1.call(TypedArrayConstructor, data); - } - setInternalState$9(that, { - buffer: buffer, - byteOffset: byteOffset, - byteLength: byteLength, - length: length, - view: new DataView$1(buffer) - }); - while (index < length) addElement(that, index++); - }); - - if (setPrototypeOf) setPrototypeOf(TypedArrayConstructor, TypedArray); - TypedArrayConstructorPrototype = TypedArrayConstructor.prototype = create$6(TypedArrayPrototype); - } else if (TYPED_ARRAYS_CONSTRUCTORS_REQUIRES_WRAPPERS$2) { - TypedArrayConstructor = wrapper(function (dummy, data, typedArrayOffset, $length) { - anInstance$5(dummy, TypedArrayConstructor, CONSTRUCTOR_NAME); - return inheritIfRequired(function () { - if (!isObject$7(data)) return new NativeTypedArrayConstructor(toIndex(data)); - if (isArrayBuffer(data)) return $length !== undefined - ? new NativeTypedArrayConstructor(data, toOffset$1(typedArrayOffset, BYTES), $length) - : typedArrayOffset !== undefined - ? new NativeTypedArrayConstructor(data, toOffset$1(typedArrayOffset, BYTES)) - : new NativeTypedArrayConstructor(data); - if (isTypedArray(data)) return fromList(TypedArrayConstructor, data); - return typedArrayFrom$1.call(TypedArrayConstructor, data); - }(), dummy, TypedArrayConstructor); - }); - - if (setPrototypeOf) setPrototypeOf(TypedArrayConstructor, TypedArray); - forEach$1(getOwnPropertyNames(NativeTypedArrayConstructor), function (key) { - if (!(key in TypedArrayConstructor)) { - createNonEnumerableProperty$8(TypedArrayConstructor, key, NativeTypedArrayConstructor[key]); - } - }); - TypedArrayConstructor.prototype = TypedArrayConstructorPrototype; - } - - if (TypedArrayConstructorPrototype.constructor !== TypedArrayConstructor) { - createNonEnumerableProperty$8(TypedArrayConstructorPrototype, 'constructor', TypedArrayConstructor); - } - - if (TYPED_ARRAY_TAG) { - createNonEnumerableProperty$8(TypedArrayConstructorPrototype, TYPED_ARRAY_TAG, CONSTRUCTOR_NAME); - } - - exported[CONSTRUCTOR_NAME] = TypedArrayConstructor; - - $$25({ - global: true, forced: TypedArrayConstructor != NativeTypedArrayConstructor, sham: !NATIVE_ARRAY_BUFFER_VIEWS - }, exported); - - if (!(BYTES_PER_ELEMENT in TypedArrayConstructor)) { - createNonEnumerableProperty$8(TypedArrayConstructor, BYTES_PER_ELEMENT, BYTES); - } - - if (!(BYTES_PER_ELEMENT in TypedArrayConstructorPrototype)) { - createNonEnumerableProperty$8(TypedArrayConstructorPrototype, BYTES_PER_ELEMENT, BYTES); - } - - setSpecies$1(CONSTRUCTOR_NAME); - }; -} else typedArrayConstructor.exports = function () { /* empty */ }; - -var createTypedArrayConstructor$8 = typedArrayConstructor.exports; - -// `Int8Array` constructor -// https://tc39.es/ecma262/#sec-typedarray-objects -createTypedArrayConstructor$8('Int8', function (init) { - return function Int8Array(data, byteOffset, length) { - return init(this, data, byteOffset, length); - }; -}); - -var createTypedArrayConstructor$7 = typedArrayConstructor.exports; - -// `Uint8Array` constructor -// https://tc39.es/ecma262/#sec-typedarray-objects -createTypedArrayConstructor$7('Uint8', function (init) { - return function Uint8Array(data, byteOffset, length) { - return init(this, data, byteOffset, length); - }; -}); - -var createTypedArrayConstructor$6 = typedArrayConstructor.exports; - -// `Uint8ClampedArray` constructor -// https://tc39.es/ecma262/#sec-typedarray-objects -createTypedArrayConstructor$6('Uint8', function (init) { - return function Uint8ClampedArray(data, byteOffset, length) { - return init(this, data, byteOffset, length); - }; -}, true); - -var createTypedArrayConstructor$5 = typedArrayConstructor.exports; - -// `Int16Array` constructor -// https://tc39.es/ecma262/#sec-typedarray-objects -createTypedArrayConstructor$5('Int16', function (init) { - return function Int16Array(data, byteOffset, length) { - return init(this, data, byteOffset, length); - }; -}); - -var createTypedArrayConstructor$4 = typedArrayConstructor.exports; - -// `Uint16Array` constructor -// https://tc39.es/ecma262/#sec-typedarray-objects -createTypedArrayConstructor$4('Uint16', function (init) { - return function Uint16Array(data, byteOffset, length) { - return init(this, data, byteOffset, length); - }; -}); - -var createTypedArrayConstructor$3 = typedArrayConstructor.exports; - -// `Int32Array` constructor -// https://tc39.es/ecma262/#sec-typedarray-objects -createTypedArrayConstructor$3('Int32', function (init) { - return function Int32Array(data, byteOffset, length) { - return init(this, data, byteOffset, length); - }; -}); - -var createTypedArrayConstructor$2 = typedArrayConstructor.exports; - -// `Uint32Array` constructor -// https://tc39.es/ecma262/#sec-typedarray-objects -createTypedArrayConstructor$2('Uint32', function (init) { - return function Uint32Array(data, byteOffset, length) { - return init(this, data, byteOffset, length); - }; -}); - -var createTypedArrayConstructor$1 = typedArrayConstructor.exports; - -// `Float32Array` constructor -// https://tc39.es/ecma262/#sec-typedarray-objects -createTypedArrayConstructor$1('Float32', function (init) { - return function Float32Array(data, byteOffset, length) { - return init(this, data, byteOffset, length); - }; -}); - -var createTypedArrayConstructor = typedArrayConstructor.exports; - -// `Float64Array` constructor -// https://tc39.es/ecma262/#sec-typedarray-objects -createTypedArrayConstructor('Float64', function (init) { - return function Float64Array(data, byteOffset, length) { - return init(this, data, byteOffset, length); - }; -}); - -var TYPED_ARRAYS_CONSTRUCTORS_REQUIRES_WRAPPERS$1 = typedArrayConstructorsRequireWrappers; -var exportTypedArrayStaticMethod$1 = arrayBufferViewCore.exportTypedArrayStaticMethod; -var typedArrayFrom = typedArrayFrom$2; - -// `%TypedArray%.from` method -// https://tc39.es/ecma262/#sec-%typedarray%.from -exportTypedArrayStaticMethod$1('from', typedArrayFrom, TYPED_ARRAYS_CONSTRUCTORS_REQUIRES_WRAPPERS$1); - -var ArrayBufferViewCore$o = arrayBufferViewCore; -var TYPED_ARRAYS_CONSTRUCTORS_REQUIRES_WRAPPERS = typedArrayConstructorsRequireWrappers; - -var aTypedArrayConstructor$4 = ArrayBufferViewCore$o.aTypedArrayConstructor; -var exportTypedArrayStaticMethod = ArrayBufferViewCore$o.exportTypedArrayStaticMethod; - -// `%TypedArray%.of` method -// https://tc39.es/ecma262/#sec-%typedarray%.of -exportTypedArrayStaticMethod('of', function of(/* ...items */) { - var index = 0; - var length = arguments.length; - var result = new (aTypedArrayConstructor$4(this))(length); - while (length > index) result[index] = arguments[index++]; - return result; -}, TYPED_ARRAYS_CONSTRUCTORS_REQUIRES_WRAPPERS); - -var ArrayBufferViewCore$n = arrayBufferViewCore; -var $copyWithin = arrayCopyWithin; - -var aTypedArray$n = ArrayBufferViewCore$n.aTypedArray; -var exportTypedArrayMethod$o = ArrayBufferViewCore$n.exportTypedArrayMethod; - -// `%TypedArray%.prototype.copyWithin` method -// https://tc39.es/ecma262/#sec-%typedarray%.prototype.copywithin -exportTypedArrayMethod$o('copyWithin', function copyWithin(target, start /* , end */) { - return $copyWithin.call(aTypedArray$n(this), target, start, arguments.length > 2 ? arguments[2] : undefined); -}); - -var ArrayBufferViewCore$m = arrayBufferViewCore; -var $every$1 = arrayIteration.every; - -var aTypedArray$m = ArrayBufferViewCore$m.aTypedArray; -var exportTypedArrayMethod$n = ArrayBufferViewCore$m.exportTypedArrayMethod; - -// `%TypedArray%.prototype.every` method -// https://tc39.es/ecma262/#sec-%typedarray%.prototype.every -exportTypedArrayMethod$n('every', function every(callbackfn /* , thisArg */) { - return $every$1(aTypedArray$m(this), callbackfn, arguments.length > 1 ? arguments[1] : undefined); -}); - -var ArrayBufferViewCore$l = arrayBufferViewCore; -var $fill = arrayFill$1; - -var aTypedArray$l = ArrayBufferViewCore$l.aTypedArray; -var exportTypedArrayMethod$m = ArrayBufferViewCore$l.exportTypedArrayMethod; - -// `%TypedArray%.prototype.fill` method -// https://tc39.es/ecma262/#sec-%typedarray%.prototype.fill -// eslint-disable-next-line no-unused-vars -exportTypedArrayMethod$m('fill', function fill(value /* , start, end */) { - return $fill.apply(aTypedArray$l(this), arguments); -}); - -var ArrayBufferViewCore$k = arrayBufferViewCore; -var $filter = arrayIteration.filter; -var speciesConstructor$d = speciesConstructor$j; - -var aTypedArray$k = ArrayBufferViewCore$k.aTypedArray; -var aTypedArrayConstructor$3 = ArrayBufferViewCore$k.aTypedArrayConstructor; -var exportTypedArrayMethod$l = ArrayBufferViewCore$k.exportTypedArrayMethod; - -// `%TypedArray%.prototype.filter` method -// https://tc39.es/ecma262/#sec-%typedarray%.prototype.filter -exportTypedArrayMethod$l('filter', function filter(callbackfn /* , thisArg */) { - var list = $filter(aTypedArray$k(this), callbackfn, arguments.length > 1 ? arguments[1] : undefined); - var C = speciesConstructor$d(this, this.constructor); - var index = 0; - var length = list.length; - var result = new (aTypedArrayConstructor$3(C))(length); - while (length > index) result[index] = list[index++]; - return result; -}); - -var ArrayBufferViewCore$j = arrayBufferViewCore; -var $find$1 = arrayIteration.find; - -var aTypedArray$j = ArrayBufferViewCore$j.aTypedArray; -var exportTypedArrayMethod$k = ArrayBufferViewCore$j.exportTypedArrayMethod; - -// `%TypedArray%.prototype.find` method -// https://tc39.es/ecma262/#sec-%typedarray%.prototype.find -exportTypedArrayMethod$k('find', function find(predicate /* , thisArg */) { - return $find$1(aTypedArray$j(this), predicate, arguments.length > 1 ? arguments[1] : undefined); -}); - -var ArrayBufferViewCore$i = arrayBufferViewCore; -var $findIndex = arrayIteration.findIndex; - -var aTypedArray$i = ArrayBufferViewCore$i.aTypedArray; -var exportTypedArrayMethod$j = ArrayBufferViewCore$i.exportTypedArrayMethod; - -// `%TypedArray%.prototype.findIndex` method -// https://tc39.es/ecma262/#sec-%typedarray%.prototype.findindex -exportTypedArrayMethod$j('findIndex', function findIndex(predicate /* , thisArg */) { - return $findIndex(aTypedArray$i(this), predicate, arguments.length > 1 ? arguments[1] : undefined); -}); - -var ArrayBufferViewCore$h = arrayBufferViewCore; -var $forEach$1 = arrayIteration.forEach; - -var aTypedArray$h = ArrayBufferViewCore$h.aTypedArray; -var exportTypedArrayMethod$i = ArrayBufferViewCore$h.exportTypedArrayMethod; - -// `%TypedArray%.prototype.forEach` method -// https://tc39.es/ecma262/#sec-%typedarray%.prototype.foreach -exportTypedArrayMethod$i('forEach', function forEach(callbackfn /* , thisArg */) { - $forEach$1(aTypedArray$h(this), callbackfn, arguments.length > 1 ? arguments[1] : undefined); -}); - -var ArrayBufferViewCore$g = arrayBufferViewCore; -var $includes = arrayIncludes.includes; - -var aTypedArray$g = ArrayBufferViewCore$g.aTypedArray; -var exportTypedArrayMethod$h = ArrayBufferViewCore$g.exportTypedArrayMethod; - -// `%TypedArray%.prototype.includes` method -// https://tc39.es/ecma262/#sec-%typedarray%.prototype.includes -exportTypedArrayMethod$h('includes', function includes(searchElement /* , fromIndex */) { - return $includes(aTypedArray$g(this), searchElement, arguments.length > 1 ? arguments[1] : undefined); -}); - -var ArrayBufferViewCore$f = arrayBufferViewCore; -var $indexOf = arrayIncludes.indexOf; - -var aTypedArray$f = ArrayBufferViewCore$f.aTypedArray; -var exportTypedArrayMethod$g = ArrayBufferViewCore$f.exportTypedArrayMethod; - -// `%TypedArray%.prototype.indexOf` method -// https://tc39.es/ecma262/#sec-%typedarray%.prototype.indexof -exportTypedArrayMethod$g('indexOf', function indexOf(searchElement /* , fromIndex */) { - return $indexOf(aTypedArray$f(this), searchElement, arguments.length > 1 ? arguments[1] : undefined); -}); - -var global$c = global$L; -var ArrayBufferViewCore$e = arrayBufferViewCore; -var ArrayIterators = es_array_iterator; -var wellKnownSymbol$a = wellKnownSymbol$C; - -var ITERATOR$3 = wellKnownSymbol$a('iterator'); -var Uint8Array$1 = global$c.Uint8Array; -var arrayValues = ArrayIterators.values; -var arrayKeys = ArrayIterators.keys; -var arrayEntries = ArrayIterators.entries; -var aTypedArray$e = ArrayBufferViewCore$e.aTypedArray; -var exportTypedArrayMethod$f = ArrayBufferViewCore$e.exportTypedArrayMethod; -var nativeTypedArrayIterator = Uint8Array$1 && Uint8Array$1.prototype[ITERATOR$3]; - -var CORRECT_ITER_NAME = !!nativeTypedArrayIterator - && (nativeTypedArrayIterator.name == 'values' || nativeTypedArrayIterator.name == undefined); - -var typedArrayValues = function values() { - return arrayValues.call(aTypedArray$e(this)); -}; - -// `%TypedArray%.prototype.entries` method -// https://tc39.es/ecma262/#sec-%typedarray%.prototype.entries -exportTypedArrayMethod$f('entries', function entries() { - return arrayEntries.call(aTypedArray$e(this)); -}); -// `%TypedArray%.prototype.keys` method -// https://tc39.es/ecma262/#sec-%typedarray%.prototype.keys -exportTypedArrayMethod$f('keys', function keys() { - return arrayKeys.call(aTypedArray$e(this)); -}); -// `%TypedArray%.prototype.values` method -// https://tc39.es/ecma262/#sec-%typedarray%.prototype.values -exportTypedArrayMethod$f('values', typedArrayValues, !CORRECT_ITER_NAME); -// `%TypedArray%.prototype[@@iterator]` method -// https://tc39.es/ecma262/#sec-%typedarray%.prototype-@@iterator -exportTypedArrayMethod$f(ITERATOR$3, typedArrayValues, !CORRECT_ITER_NAME); - -var ArrayBufferViewCore$d = arrayBufferViewCore; - -var aTypedArray$d = ArrayBufferViewCore$d.aTypedArray; -var exportTypedArrayMethod$e = ArrayBufferViewCore$d.exportTypedArrayMethod; -var $join = [].join; - -// `%TypedArray%.prototype.join` method -// https://tc39.es/ecma262/#sec-%typedarray%.prototype.join -// eslint-disable-next-line no-unused-vars -exportTypedArrayMethod$e('join', function join(separator) { - return $join.apply(aTypedArray$d(this), arguments); -}); - -var ArrayBufferViewCore$c = arrayBufferViewCore; -var $lastIndexOf = arrayLastIndexOf; - -var aTypedArray$c = ArrayBufferViewCore$c.aTypedArray; -var exportTypedArrayMethod$d = ArrayBufferViewCore$c.exportTypedArrayMethod; - -// `%TypedArray%.prototype.lastIndexOf` method -// https://tc39.es/ecma262/#sec-%typedarray%.prototype.lastindexof -// eslint-disable-next-line no-unused-vars -exportTypedArrayMethod$d('lastIndexOf', function lastIndexOf(searchElement /* , fromIndex */) { - return $lastIndexOf.apply(aTypedArray$c(this), arguments); -}); - -var ArrayBufferViewCore$b = arrayBufferViewCore; -var $map = arrayIteration.map; -var speciesConstructor$c = speciesConstructor$j; - -var aTypedArray$b = ArrayBufferViewCore$b.aTypedArray; -var aTypedArrayConstructor$2 = ArrayBufferViewCore$b.aTypedArrayConstructor; -var exportTypedArrayMethod$c = ArrayBufferViewCore$b.exportTypedArrayMethod; - -// `%TypedArray%.prototype.map` method -// https://tc39.es/ecma262/#sec-%typedarray%.prototype.map -exportTypedArrayMethod$c('map', function map(mapfn /* , thisArg */) { - return $map(aTypedArray$b(this), mapfn, arguments.length > 1 ? arguments[1] : undefined, function (O, length) { - return new (aTypedArrayConstructor$2(speciesConstructor$c(O, O.constructor)))(length); - }); -}); - -var ArrayBufferViewCore$a = arrayBufferViewCore; -var $reduce = arrayReduce.left; - -var aTypedArray$a = ArrayBufferViewCore$a.aTypedArray; -var exportTypedArrayMethod$b = ArrayBufferViewCore$a.exportTypedArrayMethod; - -// `%TypedArray%.prototype.reduce` method -// https://tc39.es/ecma262/#sec-%typedarray%.prototype.reduce -exportTypedArrayMethod$b('reduce', function reduce(callbackfn /* , initialValue */) { - return $reduce(aTypedArray$a(this), callbackfn, arguments.length, arguments.length > 1 ? arguments[1] : undefined); -}); - -var ArrayBufferViewCore$9 = arrayBufferViewCore; -var $reduceRight = arrayReduce.right; - -var aTypedArray$9 = ArrayBufferViewCore$9.aTypedArray; -var exportTypedArrayMethod$a = ArrayBufferViewCore$9.exportTypedArrayMethod; - -// `%TypedArray%.prototype.reduceRicht` method -// https://tc39.es/ecma262/#sec-%typedarray%.prototype.reduceright -exportTypedArrayMethod$a('reduceRight', function reduceRight(callbackfn /* , initialValue */) { - return $reduceRight(aTypedArray$9(this), callbackfn, arguments.length, arguments.length > 1 ? arguments[1] : undefined); -}); - -var ArrayBufferViewCore$8 = arrayBufferViewCore; - -var aTypedArray$8 = ArrayBufferViewCore$8.aTypedArray; -var exportTypedArrayMethod$9 = ArrayBufferViewCore$8.exportTypedArrayMethod; -var floor$2 = Math.floor; - -// `%TypedArray%.prototype.reverse` method -// https://tc39.es/ecma262/#sec-%typedarray%.prototype.reverse -exportTypedArrayMethod$9('reverse', function reverse() { - var that = this; - var length = aTypedArray$8(that).length; - var middle = floor$2(length / 2); - var index = 0; - var value; - while (index < middle) { - value = that[index]; - that[index++] = that[--length]; - that[length] = value; - } return that; -}); - -var ArrayBufferViewCore$7 = arrayBufferViewCore; -var toLength$6 = toLength$y; -var toOffset = toOffset$2; -var toObject$7 = toObject$u; -var fails$a = fails$Y; - -var aTypedArray$7 = ArrayBufferViewCore$7.aTypedArray; -var exportTypedArrayMethod$8 = ArrayBufferViewCore$7.exportTypedArrayMethod; - -var FORCED$6 = fails$a(function () { - // eslint-disable-next-line no-undef - new Int8Array(1).set({}); -}); - -// `%TypedArray%.prototype.set` method -// https://tc39.es/ecma262/#sec-%typedarray%.prototype.set -exportTypedArrayMethod$8('set', function set(arrayLike /* , offset */) { - aTypedArray$7(this); - var offset = toOffset(arguments.length > 1 ? arguments[1] : undefined, 1); - var length = this.length; - var src = toObject$7(arrayLike); - var len = toLength$6(src.length); - var index = 0; - if (len + offset > length) throw RangeError('Wrong length'); - while (index < len) this[offset + index] = src[index++]; -}, FORCED$6); - -var ArrayBufferViewCore$6 = arrayBufferViewCore; -var speciesConstructor$b = speciesConstructor$j; -var fails$9 = fails$Y; - -var aTypedArray$6 = ArrayBufferViewCore$6.aTypedArray; -var aTypedArrayConstructor$1 = ArrayBufferViewCore$6.aTypedArrayConstructor; -var exportTypedArrayMethod$7 = ArrayBufferViewCore$6.exportTypedArrayMethod; -var $slice$1 = [].slice; - -var FORCED$5 = fails$9(function () { - // eslint-disable-next-line no-undef - new Int8Array(1).slice(); -}); - -// `%TypedArray%.prototype.slice` method -// https://tc39.es/ecma262/#sec-%typedarray%.prototype.slice -exportTypedArrayMethod$7('slice', function slice(start, end) { - var list = $slice$1.call(aTypedArray$6(this), start, end); - var C = speciesConstructor$b(this, this.constructor); - var index = 0; - var length = list.length; - var result = new (aTypedArrayConstructor$1(C))(length); - while (length > index) result[index] = list[index++]; - return result; -}, FORCED$5); - -var ArrayBufferViewCore$5 = arrayBufferViewCore; -var $some$1 = arrayIteration.some; - -var aTypedArray$5 = ArrayBufferViewCore$5.aTypedArray; -var exportTypedArrayMethod$6 = ArrayBufferViewCore$5.exportTypedArrayMethod; - -// `%TypedArray%.prototype.some` method -// https://tc39.es/ecma262/#sec-%typedarray%.prototype.some -exportTypedArrayMethod$6('some', function some(callbackfn /* , thisArg */) { - return $some$1(aTypedArray$5(this), callbackfn, arguments.length > 1 ? arguments[1] : undefined); -}); - -var ArrayBufferViewCore$4 = arrayBufferViewCore; - -var aTypedArray$4 = ArrayBufferViewCore$4.aTypedArray; -var exportTypedArrayMethod$5 = ArrayBufferViewCore$4.exportTypedArrayMethod; -var $sort = [].sort; - -// `%TypedArray%.prototype.sort` method -// https://tc39.es/ecma262/#sec-%typedarray%.prototype.sort -exportTypedArrayMethod$5('sort', function sort(comparefn) { - return $sort.call(aTypedArray$4(this), comparefn); -}); - -var ArrayBufferViewCore$3 = arrayBufferViewCore; -var toLength$5 = toLength$y; -var toAbsoluteIndex = toAbsoluteIndex$8; -var speciesConstructor$a = speciesConstructor$j; - -var aTypedArray$3 = ArrayBufferViewCore$3.aTypedArray; -var exportTypedArrayMethod$4 = ArrayBufferViewCore$3.exportTypedArrayMethod; - -// `%TypedArray%.prototype.subarray` method -// https://tc39.es/ecma262/#sec-%typedarray%.prototype.subarray -exportTypedArrayMethod$4('subarray', function subarray(begin, end) { - var O = aTypedArray$3(this); - var length = O.length; - var beginIndex = toAbsoluteIndex(begin, length); - return new (speciesConstructor$a(O, O.constructor))( - O.buffer, - O.byteOffset + beginIndex * O.BYTES_PER_ELEMENT, - toLength$5((end === undefined ? length : toAbsoluteIndex(end, length)) - beginIndex) - ); -}); - -var global$b = global$L; -var ArrayBufferViewCore$2 = arrayBufferViewCore; -var fails$8 = fails$Y; - -var Int8Array$1 = global$b.Int8Array; -var aTypedArray$2 = ArrayBufferViewCore$2.aTypedArray; -var exportTypedArrayMethod$3 = ArrayBufferViewCore$2.exportTypedArrayMethod; -var $toLocaleString = [].toLocaleString; -var $slice = [].slice; - -// iOS Safari 6.x fails here -var TO_LOCALE_STRING_BUG = !!Int8Array$1 && fails$8(function () { - $toLocaleString.call(new Int8Array$1(1)); -}); - -var FORCED$4 = fails$8(function () { - return [1, 2].toLocaleString() != new Int8Array$1([1, 2]).toLocaleString(); -}) || !fails$8(function () { - Int8Array$1.prototype.toLocaleString.call([1, 2]); -}); - -// `%TypedArray%.prototype.toLocaleString` method -// https://tc39.es/ecma262/#sec-%typedarray%.prototype.tolocalestring -exportTypedArrayMethod$3('toLocaleString', function toLocaleString() { - return $toLocaleString.apply(TO_LOCALE_STRING_BUG ? $slice.call(aTypedArray$2(this)) : aTypedArray$2(this), arguments); -}, FORCED$4); - -var exportTypedArrayMethod$2 = arrayBufferViewCore.exportTypedArrayMethod; -var fails$7 = fails$Y; -var global$a = global$L; - -var Uint8Array = global$a.Uint8Array; -var Uint8ArrayPrototype = Uint8Array && Uint8Array.prototype || {}; -var arrayToString = [].toString; -var arrayJoin = [].join; - -if (fails$7(function () { arrayToString.call({}); })) { - arrayToString = function toString() { - return arrayJoin.call(this); - }; -} - -var IS_NOT_ARRAY_METHOD = Uint8ArrayPrototype.toString != arrayToString; - -// `%TypedArray%.prototype.toString` method -// https://tc39.es/ecma262/#sec-%typedarray%.prototype.tostring -exportTypedArrayMethod$2('toString', arrayToString, IS_NOT_ARRAY_METHOD); - -var $$24 = _export; -var getBuiltIn$j = getBuiltIn$t; -var aFunction$D = aFunction$R; -var anObject$1d = anObject$1z; -var fails$6 = fails$Y; - -var nativeApply = getBuiltIn$j('Reflect', 'apply'); -var functionApply = Function.apply; - -// MS Edge argumentsList argument is optional -var OPTIONAL_ARGUMENTS_LIST = !fails$6(function () { - nativeApply(function () { /* empty */ }); -}); - -// `Reflect.apply` method -// https://tc39.es/ecma262/#sec-reflect.apply -$$24({ target: 'Reflect', stat: true, forced: OPTIONAL_ARGUMENTS_LIST }, { - apply: function apply(target, thisArgument, argumentsList) { - aFunction$D(target); - anObject$1d(argumentsList); - return nativeApply - ? nativeApply(target, thisArgument, argumentsList) - : functionApply.call(target, thisArgument, argumentsList); - } -}); - -var $$23 = _export; -var getBuiltIn$i = getBuiltIn$t; -var aFunction$C = aFunction$R; -var anObject$1c = anObject$1z; -var isObject$6 = isObject$B; -var create$5 = objectCreate; -var bind$e = functionBind; -var fails$5 = fails$Y; - -var nativeConstruct = getBuiltIn$i('Reflect', 'construct'); - -// `Reflect.construct` method -// https://tc39.es/ecma262/#sec-reflect.construct -// MS Edge supports only 2 arguments and argumentsList argument is optional -// FF Nightly sets third argument as `new.target`, but does not create `this` from it -var NEW_TARGET_BUG = fails$5(function () { - function F() { /* empty */ } - return !(nativeConstruct(function () { /* empty */ }, [], F) instanceof F); -}); -var ARGS_BUG = !fails$5(function () { - nativeConstruct(function () { /* empty */ }); -}); -var FORCED$3 = NEW_TARGET_BUG || ARGS_BUG; - -$$23({ target: 'Reflect', stat: true, forced: FORCED$3, sham: FORCED$3 }, { - construct: function construct(Target, args /* , newTarget */) { - aFunction$C(Target); - anObject$1c(args); - var newTarget = arguments.length < 3 ? Target : aFunction$C(arguments[2]); - if (ARGS_BUG && !NEW_TARGET_BUG) return nativeConstruct(Target, args, newTarget); - if (Target == newTarget) { - // w/o altered newTarget, optimization for 0-4 arguments - switch (args.length) { - case 0: return new Target(); - case 1: return new Target(args[0]); - case 2: return new Target(args[0], args[1]); - case 3: return new Target(args[0], args[1], args[2]); - case 4: return new Target(args[0], args[1], args[2], args[3]); - } - // w/o altered newTarget, lot of arguments case - var $args = [null]; - $args.push.apply($args, args); - return new (bind$e.apply(Target, $args))(); - } - // with altered newTarget, not support built-in constructors - var proto = newTarget.prototype; - var instance = create$5(isObject$6(proto) ? proto : Object.prototype); - var result = Function.apply.call(Target, instance, args); - return isObject$6(result) ? result : instance; - } -}); - -var $$22 = _export; -var DESCRIPTORS$6 = descriptors; -var anObject$1b = anObject$1z; -var toPrimitive = toPrimitive$b; -var definePropertyModule$1 = objectDefineProperty; -var fails$4 = fails$Y; - -// MS Edge has broken Reflect.defineProperty - throwing instead of returning false -var ERROR_INSTEAD_OF_FALSE = fails$4(function () { - // eslint-disable-next-line no-undef - Reflect.defineProperty(definePropertyModule$1.f({}, 1, { value: 1 }), 1, { value: 2 }); -}); - -// `Reflect.defineProperty` method -// https://tc39.es/ecma262/#sec-reflect.defineproperty -$$22({ target: 'Reflect', stat: true, forced: ERROR_INSTEAD_OF_FALSE, sham: !DESCRIPTORS$6 }, { - defineProperty: function defineProperty(target, propertyKey, attributes) { - anObject$1b(target); - var key = toPrimitive(propertyKey, true); - anObject$1b(attributes); - try { - definePropertyModule$1.f(target, key, attributes); - return true; - } catch (error) { - return false; - } - } -}); - -var $$21 = _export; -var anObject$1a = anObject$1z; -var getOwnPropertyDescriptor = objectGetOwnPropertyDescriptor.f; - -// `Reflect.deleteProperty` method -// https://tc39.es/ecma262/#sec-reflect.deleteproperty -$$21({ target: 'Reflect', stat: true }, { - deleteProperty: function deleteProperty(target, propertyKey) { - var descriptor = getOwnPropertyDescriptor(anObject$1a(target), propertyKey); - return descriptor && !descriptor.configurable ? false : delete target[propertyKey]; - } -}); - -var $$20 = _export; -var isObject$5 = isObject$B; -var anObject$19 = anObject$1z; -var has$6 = has$o; -var getOwnPropertyDescriptorModule$2 = objectGetOwnPropertyDescriptor; -var getPrototypeOf$5 = objectGetPrototypeOf$1; - -// `Reflect.get` method -// https://tc39.es/ecma262/#sec-reflect.get -function get(target, propertyKey /* , receiver */) { - var receiver = arguments.length < 3 ? target : arguments[2]; - var descriptor, prototype; - if (anObject$19(target) === receiver) return target[propertyKey]; - if (descriptor = getOwnPropertyDescriptorModule$2.f(target, propertyKey)) return has$6(descriptor, 'value') - ? descriptor.value - : descriptor.get === undefined - ? undefined - : descriptor.get.call(receiver); - if (isObject$5(prototype = getPrototypeOf$5(target))) return get(prototype, propertyKey, receiver); -} - -$$20({ target: 'Reflect', stat: true }, { - get: get -}); - -var $$1$ = _export; -var DESCRIPTORS$5 = descriptors; -var anObject$18 = anObject$1z; -var getOwnPropertyDescriptorModule$1 = objectGetOwnPropertyDescriptor; - -// `Reflect.getOwnPropertyDescriptor` method -// https://tc39.es/ecma262/#sec-reflect.getownpropertydescriptor -$$1$({ target: 'Reflect', stat: true, sham: !DESCRIPTORS$5 }, { - getOwnPropertyDescriptor: function getOwnPropertyDescriptor(target, propertyKey) { - return getOwnPropertyDescriptorModule$1.f(anObject$18(target), propertyKey); - } -}); - -var $$1_ = _export; -var anObject$17 = anObject$1z; -var objectGetPrototypeOf = objectGetPrototypeOf$1; -var CORRECT_PROTOTYPE_GETTER = correctPrototypeGetter; - -// `Reflect.getPrototypeOf` method -// https://tc39.es/ecma262/#sec-reflect.getprototypeof -$$1_({ target: 'Reflect', stat: true, sham: !CORRECT_PROTOTYPE_GETTER }, { - getPrototypeOf: function getPrototypeOf(target) { - return objectGetPrototypeOf(anObject$17(target)); - } -}); - -var $$1Z = _export; - -// `Reflect.has` method -// https://tc39.es/ecma262/#sec-reflect.has -$$1Z({ target: 'Reflect', stat: true }, { - has: function has(target, propertyKey) { - return propertyKey in target; - } -}); - -var $$1Y = _export; -var anObject$16 = anObject$1z; - -var objectIsExtensible = Object.isExtensible; - -// `Reflect.isExtensible` method -// https://tc39.es/ecma262/#sec-reflect.isextensible -$$1Y({ target: 'Reflect', stat: true }, { - isExtensible: function isExtensible(target) { - anObject$16(target); - return objectIsExtensible ? objectIsExtensible(target) : true; - } -}); - -var $$1X = _export; -var ownKeys = ownKeys$3; - -// `Reflect.ownKeys` method -// https://tc39.es/ecma262/#sec-reflect.ownkeys -$$1X({ target: 'Reflect', stat: true }, { - ownKeys: ownKeys -}); - -var $$1W = _export; -var getBuiltIn$h = getBuiltIn$t; -var anObject$15 = anObject$1z; -var FREEZING = freezing; - -// `Reflect.preventExtensions` method -// https://tc39.es/ecma262/#sec-reflect.preventextensions -$$1W({ target: 'Reflect', stat: true, sham: !FREEZING }, { - preventExtensions: function preventExtensions(target) { - anObject$15(target); - try { - var objectPreventExtensions = getBuiltIn$h('Object', 'preventExtensions'); - if (objectPreventExtensions) objectPreventExtensions(target); - return true; - } catch (error) { - return false; - } - } -}); - -var $$1V = _export; -var anObject$14 = anObject$1z; -var isObject$4 = isObject$B; -var has$5 = has$o; -var fails$3 = fails$Y; -var definePropertyModule = objectDefineProperty; -var getOwnPropertyDescriptorModule = objectGetOwnPropertyDescriptor; -var getPrototypeOf$4 = objectGetPrototypeOf$1; -var createPropertyDescriptor$1 = createPropertyDescriptor$9; - -// `Reflect.set` method -// https://tc39.es/ecma262/#sec-reflect.set -function set(target, propertyKey, V /* , receiver */) { - var receiver = arguments.length < 4 ? target : arguments[3]; - var ownDescriptor = getOwnPropertyDescriptorModule.f(anObject$14(target), propertyKey); - var existingDescriptor, prototype; - if (!ownDescriptor) { - if (isObject$4(prototype = getPrototypeOf$4(target))) { - return set(prototype, propertyKey, V, receiver); - } - ownDescriptor = createPropertyDescriptor$1(0); - } - if (has$5(ownDescriptor, 'value')) { - if (ownDescriptor.writable === false || !isObject$4(receiver)) return false; - if (existingDescriptor = getOwnPropertyDescriptorModule.f(receiver, propertyKey)) { - if (existingDescriptor.get || existingDescriptor.set || existingDescriptor.writable === false) return false; - existingDescriptor.value = V; - definePropertyModule.f(receiver, propertyKey, existingDescriptor); - } else definePropertyModule.f(receiver, propertyKey, createPropertyDescriptor$1(0, V)); - return true; - } - return ownDescriptor.set === undefined ? false : (ownDescriptor.set.call(receiver, V), true); -} - -// MS Edge 17-18 Reflect.set allows setting the property to object -// with non-writable property on the prototype -var MS_EDGE_BUG = fails$3(function () { - var Constructor = function () { /* empty */ }; - var object = definePropertyModule.f(new Constructor(), 'a', { configurable: true }); - // eslint-disable-next-line no-undef - return Reflect.set(Constructor.prototype, 'a', 1, object) !== false; -}); - -$$1V({ target: 'Reflect', stat: true, forced: MS_EDGE_BUG }, { - set: set -}); - -var $$1U = _export; -var anObject$13 = anObject$1z; -var aPossiblePrototype = aPossiblePrototype$2; -var objectSetPrototypeOf = objectSetPrototypeOf$1; - -// `Reflect.setPrototypeOf` method -// https://tc39.es/ecma262/#sec-reflect.setprototypeof -if (objectSetPrototypeOf) $$1U({ target: 'Reflect', stat: true }, { - setPrototypeOf: function setPrototypeOf(target, proto) { - anObject$13(target); - aPossiblePrototype(proto); - try { - objectSetPrototypeOf(target, proto); - return true; - } catch (error) { - return false; - } - } -}); - -var $$1T = _export; -var global$9 = global$L; -var setToStringTag$2 = setToStringTag$b; - -$$1T({ global: true }, { Reflect: {} }); - -// Reflect[@@toStringTag] property -// https://tc39.es/ecma262/#sec-reflect-@@tostringtag -setToStringTag$2(global$9.Reflect, 'Reflect', true); - -// TODO: in core-js@4, move /modules/ dependencies to public entries for better optimization by tools like `preset-env` -var Map$2 = es_map; -var WeakMap$1 = es_weakMap.exports; -var shared$1 = shared$6.exports; - -var metadata = shared$1('metadata'); -var store$1 = metadata.store || (metadata.store = new WeakMap$1()); - -var getOrCreateMetadataMap$1 = function (target, targetKey, create) { - var targetMetadata = store$1.get(target); - if (!targetMetadata) { - if (!create) return; - store$1.set(target, targetMetadata = new Map$2()); - } - var keyMetadata = targetMetadata.get(targetKey); - if (!keyMetadata) { - if (!create) return; - targetMetadata.set(targetKey, keyMetadata = new Map$2()); - } return keyMetadata; -}; - -var ordinaryHasOwnMetadata$3 = function (MetadataKey, O, P) { - var metadataMap = getOrCreateMetadataMap$1(O, P, false); - return metadataMap === undefined ? false : metadataMap.has(MetadataKey); -}; - -var ordinaryGetOwnMetadata$2 = function (MetadataKey, O, P) { - var metadataMap = getOrCreateMetadataMap$1(O, P, false); - return metadataMap === undefined ? undefined : metadataMap.get(MetadataKey); -}; - -var ordinaryDefineOwnMetadata$2 = function (MetadataKey, MetadataValue, O, P) { - getOrCreateMetadataMap$1(O, P, true).set(MetadataKey, MetadataValue); -}; - -var ordinaryOwnMetadataKeys$2 = function (target, targetKey) { - var metadataMap = getOrCreateMetadataMap$1(target, targetKey, false); - var keys = []; - if (metadataMap) metadataMap.forEach(function (_, key) { keys.push(key); }); - return keys; -}; - -var toMetadataKey$9 = function (it) { - return it === undefined || typeof it == 'symbol' ? it : String(it); -}; - -var reflectMetadata = { - store: store$1, - getMap: getOrCreateMetadataMap$1, - has: ordinaryHasOwnMetadata$3, - get: ordinaryGetOwnMetadata$2, - set: ordinaryDefineOwnMetadata$2, - keys: ordinaryOwnMetadataKeys$2, - toKey: toMetadataKey$9 -}; - -var $$1S = _export; -var ReflectMetadataModule$8 = reflectMetadata; -var anObject$12 = anObject$1z; - -var toMetadataKey$8 = ReflectMetadataModule$8.toKey; -var ordinaryDefineOwnMetadata$1 = ReflectMetadataModule$8.set; - -// `Reflect.defineMetadata` method -// https://github.com/rbuckton/reflect-metadata -$$1S({ target: 'Reflect', stat: true }, { - defineMetadata: function defineMetadata(metadataKey, metadataValue, target /* , targetKey */) { - var targetKey = arguments.length < 4 ? undefined : toMetadataKey$8(arguments[3]); - ordinaryDefineOwnMetadata$1(metadataKey, metadataValue, anObject$12(target), targetKey); - } -}); - -var $$1R = _export; -var ReflectMetadataModule$7 = reflectMetadata; -var anObject$11 = anObject$1z; - -var toMetadataKey$7 = ReflectMetadataModule$7.toKey; -var getOrCreateMetadataMap = ReflectMetadataModule$7.getMap; -var store = ReflectMetadataModule$7.store; - -// `Reflect.deleteMetadata` method -// https://github.com/rbuckton/reflect-metadata -$$1R({ target: 'Reflect', stat: true }, { - deleteMetadata: function deleteMetadata(metadataKey, target /* , targetKey */) { - var targetKey = arguments.length < 3 ? undefined : toMetadataKey$7(arguments[2]); - var metadataMap = getOrCreateMetadataMap(anObject$11(target), targetKey, false); - if (metadataMap === undefined || !metadataMap['delete'](metadataKey)) return false; - if (metadataMap.size) return true; - var targetMetadata = store.get(target); - targetMetadata['delete'](targetKey); - return !!targetMetadata.size || store['delete'](target); - } -}); - -var $$1Q = _export; -var ReflectMetadataModule$6 = reflectMetadata; -var anObject$10 = anObject$1z; -var getPrototypeOf$3 = objectGetPrototypeOf$1; - -var ordinaryHasOwnMetadata$2 = ReflectMetadataModule$6.has; -var ordinaryGetOwnMetadata$1 = ReflectMetadataModule$6.get; -var toMetadataKey$6 = ReflectMetadataModule$6.toKey; - -var ordinaryGetMetadata = function (MetadataKey, O, P) { - var hasOwn = ordinaryHasOwnMetadata$2(MetadataKey, O, P); - if (hasOwn) return ordinaryGetOwnMetadata$1(MetadataKey, O, P); - var parent = getPrototypeOf$3(O); - return parent !== null ? ordinaryGetMetadata(MetadataKey, parent, P) : undefined; -}; - -// `Reflect.getMetadata` method -// https://github.com/rbuckton/reflect-metadata -$$1Q({ target: 'Reflect', stat: true }, { - getMetadata: function getMetadata(metadataKey, target /* , targetKey */) { - var targetKey = arguments.length < 3 ? undefined : toMetadataKey$6(arguments[2]); - return ordinaryGetMetadata(metadataKey, anObject$10(target), targetKey); - } -}); - -var $$1P = _export; -// TODO: in core-js@4, move /modules/ dependencies to public entries for better optimization by tools like `preset-env` -var Set$1 = es_set; -var ReflectMetadataModule$5 = reflectMetadata; -var anObject$$ = anObject$1z; -var getPrototypeOf$2 = objectGetPrototypeOf$1; -var iterate$z = iterate$I; - -var ordinaryOwnMetadataKeys$1 = ReflectMetadataModule$5.keys; -var toMetadataKey$5 = ReflectMetadataModule$5.toKey; - -var from$4 = function (iter) { - var result = []; - iterate$z(iter, result.push, { that: result }); - return result; -}; - -var ordinaryMetadataKeys = function (O, P) { - var oKeys = ordinaryOwnMetadataKeys$1(O, P); - var parent = getPrototypeOf$2(O); - if (parent === null) return oKeys; - var pKeys = ordinaryMetadataKeys(parent, P); - return pKeys.length ? oKeys.length ? from$4(new Set$1(oKeys.concat(pKeys))) : pKeys : oKeys; -}; - -// `Reflect.getMetadataKeys` method -// https://github.com/rbuckton/reflect-metadata -$$1P({ target: 'Reflect', stat: true }, { - getMetadataKeys: function getMetadataKeys(target /* , targetKey */) { - var targetKey = arguments.length < 2 ? undefined : toMetadataKey$5(arguments[1]); - return ordinaryMetadataKeys(anObject$$(target), targetKey); - } -}); - -var $$1O = _export; -var ReflectMetadataModule$4 = reflectMetadata; -var anObject$_ = anObject$1z; - -var ordinaryGetOwnMetadata = ReflectMetadataModule$4.get; -var toMetadataKey$4 = ReflectMetadataModule$4.toKey; - -// `Reflect.getOwnMetadata` method -// https://github.com/rbuckton/reflect-metadata -$$1O({ target: 'Reflect', stat: true }, { - getOwnMetadata: function getOwnMetadata(metadataKey, target /* , targetKey */) { - var targetKey = arguments.length < 3 ? undefined : toMetadataKey$4(arguments[2]); - return ordinaryGetOwnMetadata(metadataKey, anObject$_(target), targetKey); - } -}); - -var $$1N = _export; -var ReflectMetadataModule$3 = reflectMetadata; -var anObject$Z = anObject$1z; - -var ordinaryOwnMetadataKeys = ReflectMetadataModule$3.keys; -var toMetadataKey$3 = ReflectMetadataModule$3.toKey; - -// `Reflect.getOwnMetadataKeys` method -// https://github.com/rbuckton/reflect-metadata -$$1N({ target: 'Reflect', stat: true }, { - getOwnMetadataKeys: function getOwnMetadataKeys(target /* , targetKey */) { - var targetKey = arguments.length < 2 ? undefined : toMetadataKey$3(arguments[1]); - return ordinaryOwnMetadataKeys(anObject$Z(target), targetKey); - } -}); - -var $$1M = _export; -var ReflectMetadataModule$2 = reflectMetadata; -var anObject$Y = anObject$1z; -var getPrototypeOf$1 = objectGetPrototypeOf$1; - -var ordinaryHasOwnMetadata$1 = ReflectMetadataModule$2.has; -var toMetadataKey$2 = ReflectMetadataModule$2.toKey; - -var ordinaryHasMetadata = function (MetadataKey, O, P) { - var hasOwn = ordinaryHasOwnMetadata$1(MetadataKey, O, P); - if (hasOwn) return true; - var parent = getPrototypeOf$1(O); - return parent !== null ? ordinaryHasMetadata(MetadataKey, parent, P) : false; -}; - -// `Reflect.hasMetadata` method -// https://github.com/rbuckton/reflect-metadata -$$1M({ target: 'Reflect', stat: true }, { - hasMetadata: function hasMetadata(metadataKey, target /* , targetKey */) { - var targetKey = arguments.length < 3 ? undefined : toMetadataKey$2(arguments[2]); - return ordinaryHasMetadata(metadataKey, anObject$Y(target), targetKey); - } -}); - -var $$1L = _export; -var ReflectMetadataModule$1 = reflectMetadata; -var anObject$X = anObject$1z; - -var ordinaryHasOwnMetadata = ReflectMetadataModule$1.has; -var toMetadataKey$1 = ReflectMetadataModule$1.toKey; - -// `Reflect.hasOwnMetadata` method -// https://github.com/rbuckton/reflect-metadata -$$1L({ target: 'Reflect', stat: true }, { - hasOwnMetadata: function hasOwnMetadata(metadataKey, target /* , targetKey */) { - var targetKey = arguments.length < 3 ? undefined : toMetadataKey$1(arguments[2]); - return ordinaryHasOwnMetadata(metadataKey, anObject$X(target), targetKey); - } -}); - -var $$1K = _export; -var ReflectMetadataModule = reflectMetadata; -var anObject$W = anObject$1z; - -var toMetadataKey = ReflectMetadataModule.toKey; -var ordinaryDefineOwnMetadata = ReflectMetadataModule.set; - -// `Reflect.metadata` method -// https://github.com/rbuckton/reflect-metadata -$$1K({ target: 'Reflect', stat: true }, { - metadata: function metadata(metadataKey, metadataValue) { - return function decorator(target, key) { - ordinaryDefineOwnMetadata(metadataKey, metadataValue, anObject$W(target), toMetadataKey(key)); - }; - } -}); - -var $$1J = _export; - -// `Math.iaddh` method -// https://gist.github.com/BrendanEich/4294d5c212a6d2254703 -// TODO: Remove from `core-js@4` -$$1J({ target: 'Math', stat: true }, { - iaddh: function iaddh(x0, x1, y0, y1) { - var $x0 = x0 >>> 0; - var $x1 = x1 >>> 0; - var $y0 = y0 >>> 0; - return $x1 + (y1 >>> 0) + (($x0 & $y0 | ($x0 | $y0) & ~($x0 + $y0 >>> 0)) >>> 31) | 0; - } -}); - -var $$1I = _export; - -// `Math.isubh` method -// https://gist.github.com/BrendanEich/4294d5c212a6d2254703 -// TODO: Remove from `core-js@4` -$$1I({ target: 'Math', stat: true }, { - isubh: function isubh(x0, x1, y0, y1) { - var $x0 = x0 >>> 0; - var $x1 = x1 >>> 0; - var $y0 = y0 >>> 0; - return $x1 - (y1 >>> 0) - ((~$x0 & $y0 | ~($x0 ^ $y0) & $x0 - $y0 >>> 0) >>> 31) | 0; - } -}); - -var $$1H = _export; - -// `Math.imulh` method -// https://gist.github.com/BrendanEich/4294d5c212a6d2254703 -// TODO: Remove from `core-js@4` -$$1H({ target: 'Math', stat: true }, { - imulh: function imulh(u, v) { - var UINT16 = 0xFFFF; - var $u = +u; - var $v = +v; - var u0 = $u & UINT16; - var v0 = $v & UINT16; - var u1 = $u >> 16; - var v1 = $v >> 16; - var t = (u1 * v0 >>> 0) + (u0 * v0 >>> 16); - return u1 * v1 + (t >> 16) + ((u0 * v1 >>> 0) + (t & UINT16) >> 16); - } -}); - -var $$1G = _export; - -// `Math.umulh` method -// https://gist.github.com/BrendanEich/4294d5c212a6d2254703 -// TODO: Remove from `core-js@4` -$$1G({ target: 'Math', stat: true }, { - umulh: function umulh(u, v) { - var UINT16 = 0xFFFF; - var $u = +u; - var $v = +v; - var u0 = $u & UINT16; - var v0 = $v & UINT16; - var u1 = $u >>> 16; - var v1 = $v >>> 16; - var t = (u1 * v0 >>> 0) + (u0 * v0 >>> 16); - return u1 * v1 + (t >>> 16) + ((u0 * v1 >>> 0) + (t & UINT16) >>> 16); - } -}); - -var $$1F = _export; -var charAt$1 = stringMultibyte.charAt; -var fails$2 = fails$Y; - -var FORCED$2 = fails$2(function () { - return '𠮷'.at(0) !== '𠮷'; -}); - -// `String.prototype.at` method -// https://github.com/mathiasbynens/String.prototype.at -$$1F({ target: 'String', proto: true, forced: FORCED$2 }, { - at: function at(pos) { - return charAt$1(this, pos); - } -}); - -var fails$1 = fails$Y; -var wellKnownSymbol$9 = wellKnownSymbol$C; -var IS_PURE$C = isPure; - -var ITERATOR$2 = wellKnownSymbol$9('iterator'); - -var nativeUrl = !fails$1(function () { - var url = new URL('b?a=1&b=2&c=3', 'http://a'); - var searchParams = url.searchParams; - var result = ''; - url.pathname = 'c%20d'; - searchParams.forEach(function (value, key) { - searchParams['delete']('b'); - result += key + value; - }); - return (IS_PURE$C && !url.toJSON) - || !searchParams.sort - || url.href !== 'http://a/c%20d?a=1&c=3' - || searchParams.get('c') !== '3' - || String(new URLSearchParams('?a=1')) !== 'a=1' - || !searchParams[ITERATOR$2] - // throws in Edge - || new URL('https://a@b').username !== 'a' - || new URLSearchParams(new URLSearchParams('a=b')).get('a') !== 'b' - // not punycoded in Edge - || new URL('http://тест').host !== 'xn--e1aybc' - // not escaped in Chrome 62- - || new URL('http://a#б').hash !== '#%D0%B1' - // fails in Chrome 66- - || result !== 'a1c3' - // throws in Safari - || new URL('http://x', undefined).host !== 'x'; -}); - -// based on https://github.com/bestiejs/punycode.js/blob/master/punycode.js -var maxInt = 2147483647; // aka. 0x7FFFFFFF or 2^31-1 -var base = 36; -var tMin = 1; -var tMax = 26; -var skew = 38; -var damp = 700; -var initialBias = 72; -var initialN = 128; // 0x80 -var delimiter = '-'; // '\x2D' -var regexNonASCII = /[^\0-\u007E]/; // non-ASCII chars -var regexSeparators = /[.\u3002\uFF0E\uFF61]/g; // RFC 3490 separators -var OVERFLOW_ERROR = 'Overflow: input needs wider integers to process'; -var baseMinusTMin = base - tMin; -var floor$1 = Math.floor; -var stringFromCharCode = String.fromCharCode; - -/** - * Creates an array containing the numeric code points of each Unicode - * character in the string. While JavaScript uses UCS-2 internally, - * this function will convert a pair of surrogate halves (each of which - * UCS-2 exposes as separate characters) into a single code point, - * matching UTF-16. - */ -var ucs2decode = function (string) { - var output = []; - var counter = 0; - var length = string.length; - while (counter < length) { - var value = string.charCodeAt(counter++); - if (value >= 0xD800 && value <= 0xDBFF && counter < length) { - // It's a high surrogate, and there is a next character. - var extra = string.charCodeAt(counter++); - if ((extra & 0xFC00) == 0xDC00) { // Low surrogate. - output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000); - } else { - // It's an unmatched surrogate; only append this code unit, in case the - // next code unit is the high surrogate of a surrogate pair. - output.push(value); - counter--; - } - } else { - output.push(value); - } - } - return output; -}; - -/** - * Converts a digit/integer into a basic code point. - */ -var digitToBasic = function (digit) { - // 0..25 map to ASCII a..z or A..Z - // 26..35 map to ASCII 0..9 - return digit + 22 + 75 * (digit < 26); -}; - -/** - * Bias adaptation function as per section 3.4 of RFC 3492. - * https://tools.ietf.org/html/rfc3492#section-3.4 - */ -var adapt = function (delta, numPoints, firstTime) { - var k = 0; - delta = firstTime ? floor$1(delta / damp) : delta >> 1; - delta += floor$1(delta / numPoints); - for (; delta > baseMinusTMin * tMax >> 1; k += base) { - delta = floor$1(delta / baseMinusTMin); - } - return floor$1(k + (baseMinusTMin + 1) * delta / (delta + skew)); -}; - -/** - * Converts a string of Unicode symbols (e.g. a domain name label) to a - * Punycode string of ASCII-only symbols. - */ -// eslint-disable-next-line max-statements -var encode = function (input) { - var output = []; - - // Convert the input in UCS-2 to an array of Unicode code points. - input = ucs2decode(input); - - // Cache the length. - var inputLength = input.length; - - // Initialize the state. - var n = initialN; - var delta = 0; - var bias = initialBias; - var i, currentValue; - - // Handle the basic code points. - for (i = 0; i < input.length; i++) { - currentValue = input[i]; - if (currentValue < 0x80) { - output.push(stringFromCharCode(currentValue)); - } - } - - var basicLength = output.length; // number of basic code points. - var handledCPCount = basicLength; // number of code points that have been handled; - - // Finish the basic string with a delimiter unless it's empty. - if (basicLength) { - output.push(delimiter); - } - - // Main encoding loop: - while (handledCPCount < inputLength) { - // All non-basic code points < n have been handled already. Find the next larger one: - var m = maxInt; - for (i = 0; i < input.length; i++) { - currentValue = input[i]; - if (currentValue >= n && currentValue < m) { - m = currentValue; - } - } - - // Increase `delta` enough to advance the decoder's state to , but guard against overflow. - var handledCPCountPlusOne = handledCPCount + 1; - if (m - n > floor$1((maxInt - delta) / handledCPCountPlusOne)) { - throw RangeError(OVERFLOW_ERROR); - } - - delta += (m - n) * handledCPCountPlusOne; - n = m; - - for (i = 0; i < input.length; i++) { - currentValue = input[i]; - if (currentValue < n && ++delta > maxInt) { - throw RangeError(OVERFLOW_ERROR); - } - if (currentValue == n) { - // Represent delta as a generalized variable-length integer. - var q = delta; - for (var k = base; /* no condition */; k += base) { - var t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias); - if (q < t) break; - var qMinusT = q - t; - var baseMinusT = base - t; - output.push(stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT))); - q = floor$1(qMinusT / baseMinusT); - } - - output.push(stringFromCharCode(digitToBasic(q))); - bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength); - delta = 0; - ++handledCPCount; - } - } - - ++delta; - ++n; - } - return output.join(''); -}; - -var stringPunycodeToAscii = function (input) { - var encoded = []; - var labels = input.toLowerCase().replace(regexSeparators, '\u002E').split('.'); - var i, label; - for (i = 0; i < labels.length; i++) { - label = labels[i]; - encoded.push(regexNonASCII.test(label) ? 'xn--' + encode(label) : label); - } - return encoded.join('.'); -}; - -var anObject$V = anObject$1z; -var getIteratorMethod$4 = getIteratorMethod$8; - -var getIterator$3 = function (it) { - var iteratorMethod = getIteratorMethod$4(it); - if (typeof iteratorMethod != 'function') { - throw TypeError(String(it) + ' is not iterable'); - } return anObject$V(iteratorMethod.call(it)); -}; - -// TODO: in core-js@4, move /modules/ dependencies to public entries for better optimization by tools like `preset-env` - -var $$1E = _export; -var getBuiltIn$g = getBuiltIn$t; -var USE_NATIVE_URL$1 = nativeUrl; -var redefine$1 = redefine$g.exports; -var redefineAll$3 = redefineAll$9; -var setToStringTag$1 = setToStringTag$b; -var createIteratorConstructor$4 = createIteratorConstructor$7; -var InternalStateModule$8 = internalState; -var anInstance$4 = anInstance$b; -var hasOwn = has$o; -var bind$d = functionBindContext; -var classof = classof$b; -var anObject$U = anObject$1z; -var isObject$3 = isObject$B; -var create$4 = objectCreate; -var createPropertyDescriptor = createPropertyDescriptor$9; -var getIterator$2 = getIterator$3; -var getIteratorMethod$3 = getIteratorMethod$8; -var wellKnownSymbol$8 = wellKnownSymbol$C; - -var $fetch = getBuiltIn$g('fetch'); -var Headers = getBuiltIn$g('Headers'); -var ITERATOR$1 = wellKnownSymbol$8('iterator'); -var URL_SEARCH_PARAMS = 'URLSearchParams'; -var URL_SEARCH_PARAMS_ITERATOR = URL_SEARCH_PARAMS + 'Iterator'; -var setInternalState$8 = InternalStateModule$8.set; -var getInternalParamsState = InternalStateModule$8.getterFor(URL_SEARCH_PARAMS); -var getInternalIteratorState = InternalStateModule$8.getterFor(URL_SEARCH_PARAMS_ITERATOR); - -var plus = /\+/g; -var sequences = Array(4); - -var percentSequence = function (bytes) { - return sequences[bytes - 1] || (sequences[bytes - 1] = RegExp('((?:%[\\da-f]{2}){' + bytes + '})', 'gi')); -}; - -var percentDecode = function (sequence) { - try { - return decodeURIComponent(sequence); - } catch (error) { - return sequence; - } -}; - -var deserialize = function (it) { - var result = it.replace(plus, ' '); - var bytes = 4; - try { - return decodeURIComponent(result); - } catch (error) { - while (bytes) { - result = result.replace(percentSequence(bytes--), percentDecode); - } - return result; - } -}; - -var find = /[!'()~]|%20/g; - -var replace = { - '!': '%21', - "'": '%27', - '(': '%28', - ')': '%29', - '~': '%7E', - '%20': '+' -}; - -var replacer = function (match) { - return replace[match]; -}; - -var serialize = function (it) { - return encodeURIComponent(it).replace(find, replacer); -}; - -var parseSearchParams = function (result, query) { - if (query) { - var attributes = query.split('&'); - var index = 0; - var attribute, entry; - while (index < attributes.length) { - attribute = attributes[index++]; - if (attribute.length) { - entry = attribute.split('='); - result.push({ - key: deserialize(entry.shift()), - value: deserialize(entry.join('=')) - }); - } - } - } -}; - -var updateSearchParams = function (query) { - this.entries.length = 0; - parseSearchParams(this.entries, query); -}; - -var validateArgumentsLength = function (passed, required) { - if (passed < required) throw TypeError('Not enough arguments'); -}; - -var URLSearchParamsIterator = createIteratorConstructor$4(function Iterator(params, kind) { - setInternalState$8(this, { - type: URL_SEARCH_PARAMS_ITERATOR, - iterator: getIterator$2(getInternalParamsState(params).entries), - kind: kind - }); -}, 'Iterator', function next() { - var state = getInternalIteratorState(this); - var kind = state.kind; - var step = state.iterator.next(); - var entry = step.value; - if (!step.done) { - step.value = kind === 'keys' ? entry.key : kind === 'values' ? entry.value : [entry.key, entry.value]; - } return step; -}); - -// `URLSearchParams` constructor -// https://url.spec.whatwg.org/#interface-urlsearchparams -var URLSearchParamsConstructor = function URLSearchParams(/* init */) { - anInstance$4(this, URLSearchParamsConstructor, URL_SEARCH_PARAMS); - var init = arguments.length > 0 ? arguments[0] : undefined; - var that = this; - var entries = []; - var iteratorMethod, iterator, next, step, entryIterator, entryNext, first, second, key; - - setInternalState$8(that, { - type: URL_SEARCH_PARAMS, - entries: entries, - updateURL: function () { /* empty */ }, - updateSearchParams: updateSearchParams - }); - - if (init !== undefined) { - if (isObject$3(init)) { - iteratorMethod = getIteratorMethod$3(init); - if (typeof iteratorMethod === 'function') { - iterator = iteratorMethod.call(init); - next = iterator.next; - while (!(step = next.call(iterator)).done) { - entryIterator = getIterator$2(anObject$U(step.value)); - entryNext = entryIterator.next; - if ( - (first = entryNext.call(entryIterator)).done || - (second = entryNext.call(entryIterator)).done || - !entryNext.call(entryIterator).done - ) throw TypeError('Expected sequence with length 2'); - entries.push({ key: first.value + '', value: second.value + '' }); - } - } else for (key in init) if (hasOwn(init, key)) entries.push({ key: key, value: init[key] + '' }); - } else { - parseSearchParams(entries, typeof init === 'string' ? init.charAt(0) === '?' ? init.slice(1) : init : init + ''); - } - } -}; - -var URLSearchParamsPrototype = URLSearchParamsConstructor.prototype; - -redefineAll$3(URLSearchParamsPrototype, { - // `URLSearchParams.prototype.append` method - // https://url.spec.whatwg.org/#dom-urlsearchparams-append - append: function append(name, value) { - validateArgumentsLength(arguments.length, 2); - var state = getInternalParamsState(this); - state.entries.push({ key: name + '', value: value + '' }); - state.updateURL(); - }, - // `URLSearchParams.prototype.delete` method - // https://url.spec.whatwg.org/#dom-urlsearchparams-delete - 'delete': function (name) { - validateArgumentsLength(arguments.length, 1); - var state = getInternalParamsState(this); - var entries = state.entries; - var key = name + ''; - var index = 0; - while (index < entries.length) { - if (entries[index].key === key) entries.splice(index, 1); - else index++; - } - state.updateURL(); - }, - // `URLSearchParams.prototype.get` method - // https://url.spec.whatwg.org/#dom-urlsearchparams-get - get: function get(name) { - validateArgumentsLength(arguments.length, 1); - var entries = getInternalParamsState(this).entries; - var key = name + ''; - var index = 0; - for (; index < entries.length; index++) { - if (entries[index].key === key) return entries[index].value; - } - return null; - }, - // `URLSearchParams.prototype.getAll` method - // https://url.spec.whatwg.org/#dom-urlsearchparams-getall - getAll: function getAll(name) { - validateArgumentsLength(arguments.length, 1); - var entries = getInternalParamsState(this).entries; - var key = name + ''; - var result = []; - var index = 0; - for (; index < entries.length; index++) { - if (entries[index].key === key) result.push(entries[index].value); - } - return result; - }, - // `URLSearchParams.prototype.has` method - // https://url.spec.whatwg.org/#dom-urlsearchparams-has - has: function has(name) { - validateArgumentsLength(arguments.length, 1); - var entries = getInternalParamsState(this).entries; - var key = name + ''; - var index = 0; - while (index < entries.length) { - if (entries[index++].key === key) return true; - } - return false; - }, - // `URLSearchParams.prototype.set` method - // https://url.spec.whatwg.org/#dom-urlsearchparams-set - set: function set(name, value) { - validateArgumentsLength(arguments.length, 1); - var state = getInternalParamsState(this); - var entries = state.entries; - var found = false; - var key = name + ''; - var val = value + ''; - var index = 0; - var entry; - for (; index < entries.length; index++) { - entry = entries[index]; - if (entry.key === key) { - if (found) entries.splice(index--, 1); - else { - found = true; - entry.value = val; - } - } - } - if (!found) entries.push({ key: key, value: val }); - state.updateURL(); - }, - // `URLSearchParams.prototype.sort` method - // https://url.spec.whatwg.org/#dom-urlsearchparams-sort - sort: function sort() { - var state = getInternalParamsState(this); - var entries = state.entries; - // Array#sort is not stable in some engines - var slice = entries.slice(); - var entry, entriesIndex, sliceIndex; - entries.length = 0; - for (sliceIndex = 0; sliceIndex < slice.length; sliceIndex++) { - entry = slice[sliceIndex]; - for (entriesIndex = 0; entriesIndex < sliceIndex; entriesIndex++) { - if (entries[entriesIndex].key > entry.key) { - entries.splice(entriesIndex, 0, entry); - break; - } - } - if (entriesIndex === sliceIndex) entries.push(entry); - } - state.updateURL(); - }, - // `URLSearchParams.prototype.forEach` method - forEach: function forEach(callback /* , thisArg */) { - var entries = getInternalParamsState(this).entries; - var boundFunction = bind$d(callback, arguments.length > 1 ? arguments[1] : undefined, 3); - var index = 0; - var entry; - while (index < entries.length) { - entry = entries[index++]; - boundFunction(entry.value, entry.key, this); - } - }, - // `URLSearchParams.prototype.keys` method - keys: function keys() { - return new URLSearchParamsIterator(this, 'keys'); - }, - // `URLSearchParams.prototype.values` method - values: function values() { - return new URLSearchParamsIterator(this, 'values'); - }, - // `URLSearchParams.prototype.entries` method - entries: function entries() { - return new URLSearchParamsIterator(this, 'entries'); - } -}, { enumerable: true }); - -// `URLSearchParams.prototype[@@iterator]` method -redefine$1(URLSearchParamsPrototype, ITERATOR$1, URLSearchParamsPrototype.entries); - -// `URLSearchParams.prototype.toString` method -// https://url.spec.whatwg.org/#urlsearchparams-stringification-behavior -redefine$1(URLSearchParamsPrototype, 'toString', function toString() { - var entries = getInternalParamsState(this).entries; - var result = []; - var index = 0; - var entry; - while (index < entries.length) { - entry = entries[index++]; - result.push(serialize(entry.key) + '=' + serialize(entry.value)); - } return result.join('&'); -}, { enumerable: true }); - -setToStringTag$1(URLSearchParamsConstructor, URL_SEARCH_PARAMS); - -$$1E({ global: true, forced: !USE_NATIVE_URL$1 }, { - URLSearchParams: URLSearchParamsConstructor -}); - -// Wrap `fetch` for correct work with polyfilled `URLSearchParams` -// https://github.com/zloirock/core-js/issues/674 -if (!USE_NATIVE_URL$1 && typeof $fetch == 'function' && typeof Headers == 'function') { - $$1E({ global: true, enumerable: true, forced: true }, { - fetch: function fetch(input /* , init */) { - var args = [input]; - var init, body, headers; - if (arguments.length > 1) { - init = arguments[1]; - if (isObject$3(init)) { - body = init.body; - if (classof(body) === URL_SEARCH_PARAMS) { - headers = init.headers ? new Headers(init.headers) : new Headers(); - if (!headers.has('content-type')) { - headers.set('content-type', 'application/x-www-form-urlencoded;charset=UTF-8'); - } - init = create$4(init, { - body: createPropertyDescriptor(0, String(body)), - headers: createPropertyDescriptor(0, headers) - }); - } - } - args.push(init); - } return $fetch.apply(this, args); - } - }); -} - -var web_urlSearchParams = { - URLSearchParams: URLSearchParamsConstructor, - getState: getInternalParamsState -}; - -// TODO: in core-js@4, move /modules/ dependencies to public entries for better optimization by tools like `preset-env` - -var $$1D = _export; -var DESCRIPTORS$4 = descriptors; -var USE_NATIVE_URL = nativeUrl; -var global$8 = global$L; -var defineProperties$1 = objectDefineProperties; -var redefine = redefine$g.exports; -var anInstance$3 = anInstance$b; -var has$4 = has$o; -var assign = objectAssign; -var arrayFrom = arrayFrom$1; -var codeAt$1 = stringMultibyte.codeAt; -var toASCII = stringPunycodeToAscii; -var setToStringTag = setToStringTag$b; -var URLSearchParamsModule = web_urlSearchParams; -var InternalStateModule$7 = internalState; - -var NativeURL = global$8.URL; -var URLSearchParams$1 = URLSearchParamsModule.URLSearchParams; -var getInternalSearchParamsState = URLSearchParamsModule.getState; -var setInternalState$7 = InternalStateModule$7.set; -var getInternalURLState = InternalStateModule$7.getterFor('URL'); -var floor = Math.floor; -var pow = Math.pow; - -var INVALID_AUTHORITY = 'Invalid authority'; -var INVALID_SCHEME = 'Invalid scheme'; -var INVALID_HOST = 'Invalid host'; -var INVALID_PORT = 'Invalid port'; - -var ALPHA = /[A-Za-z]/; -var ALPHANUMERIC = /[\d+-.A-Za-z]/; -var DIGIT = /\d/; -var HEX_START = /^(0x|0X)/; -var OCT = /^[0-7]+$/; -var DEC = /^\d+$/; -var HEX = /^[\dA-Fa-f]+$/; -// eslint-disable-next-line no-control-regex -var FORBIDDEN_HOST_CODE_POINT = /[\u0000\u0009\u000A\u000D #%/:?@[\\]]/; -// eslint-disable-next-line no-control-regex -var FORBIDDEN_HOST_CODE_POINT_EXCLUDING_PERCENT = /[\u0000\u0009\u000A\u000D #/:?@[\\]]/; -// eslint-disable-next-line no-control-regex -var LEADING_AND_TRAILING_C0_CONTROL_OR_SPACE = /^[\u0000-\u001F ]+|[\u0000-\u001F ]+$/g; -// eslint-disable-next-line no-control-regex -var TAB_AND_NEW_LINE = /[\u0009\u000A\u000D]/g; -var EOF; - -var parseHost = function (url, input) { - var result, codePoints, index; - if (input.charAt(0) == '[') { - if (input.charAt(input.length - 1) != ']') return INVALID_HOST; - result = parseIPv6(input.slice(1, -1)); - if (!result) return INVALID_HOST; - url.host = result; - // opaque host - } else if (!isSpecial(url)) { - if (FORBIDDEN_HOST_CODE_POINT_EXCLUDING_PERCENT.test(input)) return INVALID_HOST; - result = ''; - codePoints = arrayFrom(input); - for (index = 0; index < codePoints.length; index++) { - result += percentEncode(codePoints[index], C0ControlPercentEncodeSet); - } - url.host = result; - } else { - input = toASCII(input); - if (FORBIDDEN_HOST_CODE_POINT.test(input)) return INVALID_HOST; - result = parseIPv4(input); - if (result === null) return INVALID_HOST; - url.host = result; - } -}; - -var parseIPv4 = function (input) { - var parts = input.split('.'); - var partsLength, numbers, index, part, radix, number, ipv4; - if (parts.length && parts[parts.length - 1] == '') { - parts.pop(); - } - partsLength = parts.length; - if (partsLength > 4) return input; - numbers = []; - for (index = 0; index < partsLength; index++) { - part = parts[index]; - if (part == '') return input; - radix = 10; - if (part.length > 1 && part.charAt(0) == '0') { - radix = HEX_START.test(part) ? 16 : 8; - part = part.slice(radix == 8 ? 1 : 2); - } - if (part === '') { - number = 0; - } else { - if (!(radix == 10 ? DEC : radix == 8 ? OCT : HEX).test(part)) return input; - number = parseInt(part, radix); - } - numbers.push(number); - } - for (index = 0; index < partsLength; index++) { - number = numbers[index]; - if (index == partsLength - 1) { - if (number >= pow(256, 5 - partsLength)) return null; - } else if (number > 255) return null; - } - ipv4 = numbers.pop(); - for (index = 0; index < numbers.length; index++) { - ipv4 += numbers[index] * pow(256, 3 - index); - } - return ipv4; -}; - -// eslint-disable-next-line max-statements -var parseIPv6 = function (input) { - var address = [0, 0, 0, 0, 0, 0, 0, 0]; - var pieceIndex = 0; - var compress = null; - var pointer = 0; - var value, length, numbersSeen, ipv4Piece, number, swaps, swap; - - var char = function () { - return input.charAt(pointer); - }; - - if (char() == ':') { - if (input.charAt(1) != ':') return; - pointer += 2; - pieceIndex++; - compress = pieceIndex; - } - while (char()) { - if (pieceIndex == 8) return; - if (char() == ':') { - if (compress !== null) return; - pointer++; - pieceIndex++; - compress = pieceIndex; - continue; - } - value = length = 0; - while (length < 4 && HEX.test(char())) { - value = value * 16 + parseInt(char(), 16); - pointer++; - length++; - } - if (char() == '.') { - if (length == 0) return; - pointer -= length; - if (pieceIndex > 6) return; - numbersSeen = 0; - while (char()) { - ipv4Piece = null; - if (numbersSeen > 0) { - if (char() == '.' && numbersSeen < 4) pointer++; - else return; - } - if (!DIGIT.test(char())) return; - while (DIGIT.test(char())) { - number = parseInt(char(), 10); - if (ipv4Piece === null) ipv4Piece = number; - else if (ipv4Piece == 0) return; - else ipv4Piece = ipv4Piece * 10 + number; - if (ipv4Piece > 255) return; - pointer++; - } - address[pieceIndex] = address[pieceIndex] * 256 + ipv4Piece; - numbersSeen++; - if (numbersSeen == 2 || numbersSeen == 4) pieceIndex++; - } - if (numbersSeen != 4) return; - break; - } else if (char() == ':') { - pointer++; - if (!char()) return; - } else if (char()) return; - address[pieceIndex++] = value; - } - if (compress !== null) { - swaps = pieceIndex - compress; - pieceIndex = 7; - while (pieceIndex != 0 && swaps > 0) { - swap = address[pieceIndex]; - address[pieceIndex--] = address[compress + swaps - 1]; - address[compress + --swaps] = swap; - } - } else if (pieceIndex != 8) return; - return address; -}; - -var findLongestZeroSequence = function (ipv6) { - var maxIndex = null; - var maxLength = 1; - var currStart = null; - var currLength = 0; - var index = 0; - for (; index < 8; index++) { - if (ipv6[index] !== 0) { - if (currLength > maxLength) { - maxIndex = currStart; - maxLength = currLength; - } - currStart = null; - currLength = 0; - } else { - if (currStart === null) currStart = index; - ++currLength; - } - } - if (currLength > maxLength) { - maxIndex = currStart; - maxLength = currLength; - } - return maxIndex; -}; - -var serializeHost = function (host) { - var result, index, compress, ignore0; - // ipv4 - if (typeof host == 'number') { - result = []; - for (index = 0; index < 4; index++) { - result.unshift(host % 256); - host = floor(host / 256); - } return result.join('.'); - // ipv6 - } else if (typeof host == 'object') { - result = ''; - compress = findLongestZeroSequence(host); - for (index = 0; index < 8; index++) { - if (ignore0 && host[index] === 0) continue; - if (ignore0) ignore0 = false; - if (compress === index) { - result += index ? ':' : '::'; - ignore0 = true; - } else { - result += host[index].toString(16); - if (index < 7) result += ':'; - } - } - return '[' + result + ']'; - } return host; -}; - -var C0ControlPercentEncodeSet = {}; -var fragmentPercentEncodeSet = assign({}, C0ControlPercentEncodeSet, { - ' ': 1, '"': 1, '<': 1, '>': 1, '`': 1 -}); -var pathPercentEncodeSet = assign({}, fragmentPercentEncodeSet, { - '#': 1, '?': 1, '{': 1, '}': 1 -}); -var userinfoPercentEncodeSet = assign({}, pathPercentEncodeSet, { - '/': 1, ':': 1, ';': 1, '=': 1, '@': 1, '[': 1, '\\': 1, ']': 1, '^': 1, '|': 1 -}); - -var percentEncode = function (char, set) { - var code = codeAt$1(char, 0); - return code > 0x20 && code < 0x7F && !has$4(set, char) ? char : encodeURIComponent(char); -}; - -var specialSchemes = { - ftp: 21, - file: null, - http: 80, - https: 443, - ws: 80, - wss: 443 -}; - -var isSpecial = function (url) { - return has$4(specialSchemes, url.scheme); -}; - -var includesCredentials = function (url) { - return url.username != '' || url.password != ''; -}; - -var cannotHaveUsernamePasswordPort = function (url) { - return !url.host || url.cannotBeABaseURL || url.scheme == 'file'; -}; - -var isWindowsDriveLetter = function (string, normalized) { - var second; - return string.length == 2 && ALPHA.test(string.charAt(0)) - && ((second = string.charAt(1)) == ':' || (!normalized && second == '|')); -}; - -var startsWithWindowsDriveLetter = function (string) { - var third; - return string.length > 1 && isWindowsDriveLetter(string.slice(0, 2)) && ( - string.length == 2 || - ((third = string.charAt(2)) === '/' || third === '\\' || third === '?' || third === '#') - ); -}; - -var shortenURLsPath = function (url) { - var path = url.path; - var pathSize = path.length; - if (pathSize && (url.scheme != 'file' || pathSize != 1 || !isWindowsDriveLetter(path[0], true))) { - path.pop(); - } -}; - -var isSingleDot = function (segment) { - return segment === '.' || segment.toLowerCase() === '%2e'; -}; - -var isDoubleDot = function (segment) { - segment = segment.toLowerCase(); - return segment === '..' || segment === '%2e.' || segment === '.%2e' || segment === '%2e%2e'; -}; - -// States: -var SCHEME_START = {}; -var SCHEME = {}; -var NO_SCHEME = {}; -var SPECIAL_RELATIVE_OR_AUTHORITY = {}; -var PATH_OR_AUTHORITY = {}; -var RELATIVE = {}; -var RELATIVE_SLASH = {}; -var SPECIAL_AUTHORITY_SLASHES = {}; -var SPECIAL_AUTHORITY_IGNORE_SLASHES = {}; -var AUTHORITY = {}; -var HOST = {}; -var HOSTNAME = {}; -var PORT = {}; -var FILE = {}; -var FILE_SLASH = {}; -var FILE_HOST = {}; -var PATH_START = {}; -var PATH = {}; -var CANNOT_BE_A_BASE_URL_PATH = {}; -var QUERY = {}; -var FRAGMENT = {}; - -// eslint-disable-next-line max-statements -var parseURL = function (url, input, stateOverride, base) { - var state = stateOverride || SCHEME_START; - var pointer = 0; - var buffer = ''; - var seenAt = false; - var seenBracket = false; - var seenPasswordToken = false; - var codePoints, char, bufferCodePoints, failure; - - if (!stateOverride) { - url.scheme = ''; - url.username = ''; - url.password = ''; - url.host = null; - url.port = null; - url.path = []; - url.query = null; - url.fragment = null; - url.cannotBeABaseURL = false; - input = input.replace(LEADING_AND_TRAILING_C0_CONTROL_OR_SPACE, ''); - } - - input = input.replace(TAB_AND_NEW_LINE, ''); - - codePoints = arrayFrom(input); - - while (pointer <= codePoints.length) { - char = codePoints[pointer]; - switch (state) { - case SCHEME_START: - if (char && ALPHA.test(char)) { - buffer += char.toLowerCase(); - state = SCHEME; - } else if (!stateOverride) { - state = NO_SCHEME; - continue; - } else return INVALID_SCHEME; - break; - - case SCHEME: - if (char && (ALPHANUMERIC.test(char) || char == '+' || char == '-' || char == '.')) { - buffer += char.toLowerCase(); - } else if (char == ':') { - if (stateOverride && ( - (isSpecial(url) != has$4(specialSchemes, buffer)) || - (buffer == 'file' && (includesCredentials(url) || url.port !== null)) || - (url.scheme == 'file' && !url.host) - )) return; - url.scheme = buffer; - if (stateOverride) { - if (isSpecial(url) && specialSchemes[url.scheme] == url.port) url.port = null; - return; - } - buffer = ''; - if (url.scheme == 'file') { - state = FILE; - } else if (isSpecial(url) && base && base.scheme == url.scheme) { - state = SPECIAL_RELATIVE_OR_AUTHORITY; - } else if (isSpecial(url)) { - state = SPECIAL_AUTHORITY_SLASHES; - } else if (codePoints[pointer + 1] == '/') { - state = PATH_OR_AUTHORITY; - pointer++; - } else { - url.cannotBeABaseURL = true; - url.path.push(''); - state = CANNOT_BE_A_BASE_URL_PATH; - } - } else if (!stateOverride) { - buffer = ''; - state = NO_SCHEME; - pointer = 0; - continue; - } else return INVALID_SCHEME; - break; - - case NO_SCHEME: - if (!base || (base.cannotBeABaseURL && char != '#')) return INVALID_SCHEME; - if (base.cannotBeABaseURL && char == '#') { - url.scheme = base.scheme; - url.path = base.path.slice(); - url.query = base.query; - url.fragment = ''; - url.cannotBeABaseURL = true; - state = FRAGMENT; - break; - } - state = base.scheme == 'file' ? FILE : RELATIVE; - continue; - - case SPECIAL_RELATIVE_OR_AUTHORITY: - if (char == '/' && codePoints[pointer + 1] == '/') { - state = SPECIAL_AUTHORITY_IGNORE_SLASHES; - pointer++; - } else { - state = RELATIVE; - continue; - } break; - - case PATH_OR_AUTHORITY: - if (char == '/') { - state = AUTHORITY; - break; - } else { - state = PATH; - continue; - } - - case RELATIVE: - url.scheme = base.scheme; - if (char == EOF) { - url.username = base.username; - url.password = base.password; - url.host = base.host; - url.port = base.port; - url.path = base.path.slice(); - url.query = base.query; - } else if (char == '/' || (char == '\\' && isSpecial(url))) { - state = RELATIVE_SLASH; - } else if (char == '?') { - url.username = base.username; - url.password = base.password; - url.host = base.host; - url.port = base.port; - url.path = base.path.slice(); - url.query = ''; - state = QUERY; - } else if (char == '#') { - url.username = base.username; - url.password = base.password; - url.host = base.host; - url.port = base.port; - url.path = base.path.slice(); - url.query = base.query; - url.fragment = ''; - state = FRAGMENT; - } else { - url.username = base.username; - url.password = base.password; - url.host = base.host; - url.port = base.port; - url.path = base.path.slice(); - url.path.pop(); - state = PATH; - continue; - } break; - - case RELATIVE_SLASH: - if (isSpecial(url) && (char == '/' || char == '\\')) { - state = SPECIAL_AUTHORITY_IGNORE_SLASHES; - } else if (char == '/') { - state = AUTHORITY; - } else { - url.username = base.username; - url.password = base.password; - url.host = base.host; - url.port = base.port; - state = PATH; - continue; - } break; - - case SPECIAL_AUTHORITY_SLASHES: - state = SPECIAL_AUTHORITY_IGNORE_SLASHES; - if (char != '/' || buffer.charAt(pointer + 1) != '/') continue; - pointer++; - break; - - case SPECIAL_AUTHORITY_IGNORE_SLASHES: - if (char != '/' && char != '\\') { - state = AUTHORITY; - continue; - } break; - - case AUTHORITY: - if (char == '@') { - if (seenAt) buffer = '%40' + buffer; - seenAt = true; - bufferCodePoints = arrayFrom(buffer); - for (var i = 0; i < bufferCodePoints.length; i++) { - var codePoint = bufferCodePoints[i]; - if (codePoint == ':' && !seenPasswordToken) { - seenPasswordToken = true; - continue; - } - var encodedCodePoints = percentEncode(codePoint, userinfoPercentEncodeSet); - if (seenPasswordToken) url.password += encodedCodePoints; - else url.username += encodedCodePoints; - } - buffer = ''; - } else if ( - char == EOF || char == '/' || char == '?' || char == '#' || - (char == '\\' && isSpecial(url)) - ) { - if (seenAt && buffer == '') return INVALID_AUTHORITY; - pointer -= arrayFrom(buffer).length + 1; - buffer = ''; - state = HOST; - } else buffer += char; - break; - - case HOST: - case HOSTNAME: - if (stateOverride && url.scheme == 'file') { - state = FILE_HOST; - continue; - } else if (char == ':' && !seenBracket) { - if (buffer == '') return INVALID_HOST; - failure = parseHost(url, buffer); - if (failure) return failure; - buffer = ''; - state = PORT; - if (stateOverride == HOSTNAME) return; - } else if ( - char == EOF || char == '/' || char == '?' || char == '#' || - (char == '\\' && isSpecial(url)) - ) { - if (isSpecial(url) && buffer == '') return INVALID_HOST; - if (stateOverride && buffer == '' && (includesCredentials(url) || url.port !== null)) return; - failure = parseHost(url, buffer); - if (failure) return failure; - buffer = ''; - state = PATH_START; - if (stateOverride) return; - continue; - } else { - if (char == '[') seenBracket = true; - else if (char == ']') seenBracket = false; - buffer += char; - } break; - - case PORT: - if (DIGIT.test(char)) { - buffer += char; - } else if ( - char == EOF || char == '/' || char == '?' || char == '#' || - (char == '\\' && isSpecial(url)) || - stateOverride - ) { - if (buffer != '') { - var port = parseInt(buffer, 10); - if (port > 0xFFFF) return INVALID_PORT; - url.port = (isSpecial(url) && port === specialSchemes[url.scheme]) ? null : port; - buffer = ''; - } - if (stateOverride) return; - state = PATH_START; - continue; - } else return INVALID_PORT; - break; - - case FILE: - url.scheme = 'file'; - if (char == '/' || char == '\\') state = FILE_SLASH; - else if (base && base.scheme == 'file') { - if (char == EOF) { - url.host = base.host; - url.path = base.path.slice(); - url.query = base.query; - } else if (char == '?') { - url.host = base.host; - url.path = base.path.slice(); - url.query = ''; - state = QUERY; - } else if (char == '#') { - url.host = base.host; - url.path = base.path.slice(); - url.query = base.query; - url.fragment = ''; - state = FRAGMENT; - } else { - if (!startsWithWindowsDriveLetter(codePoints.slice(pointer).join(''))) { - url.host = base.host; - url.path = base.path.slice(); - shortenURLsPath(url); - } - state = PATH; - continue; - } - } else { - state = PATH; - continue; - } break; - - case FILE_SLASH: - if (char == '/' || char == '\\') { - state = FILE_HOST; - break; - } - if (base && base.scheme == 'file' && !startsWithWindowsDriveLetter(codePoints.slice(pointer).join(''))) { - if (isWindowsDriveLetter(base.path[0], true)) url.path.push(base.path[0]); - else url.host = base.host; - } - state = PATH; - continue; - - case FILE_HOST: - if (char == EOF || char == '/' || char == '\\' || char == '?' || char == '#') { - if (!stateOverride && isWindowsDriveLetter(buffer)) { - state = PATH; - } else if (buffer == '') { - url.host = ''; - if (stateOverride) return; - state = PATH_START; - } else { - failure = parseHost(url, buffer); - if (failure) return failure; - if (url.host == 'localhost') url.host = ''; - if (stateOverride) return; - buffer = ''; - state = PATH_START; - } continue; - } else buffer += char; - break; - - case PATH_START: - if (isSpecial(url)) { - state = PATH; - if (char != '/' && char != '\\') continue; - } else if (!stateOverride && char == '?') { - url.query = ''; - state = QUERY; - } else if (!stateOverride && char == '#') { - url.fragment = ''; - state = FRAGMENT; - } else if (char != EOF) { - state = PATH; - if (char != '/') continue; - } break; - - case PATH: - if ( - char == EOF || char == '/' || - (char == '\\' && isSpecial(url)) || - (!stateOverride && (char == '?' || char == '#')) - ) { - if (isDoubleDot(buffer)) { - shortenURLsPath(url); - if (char != '/' && !(char == '\\' && isSpecial(url))) { - url.path.push(''); - } - } else if (isSingleDot(buffer)) { - if (char != '/' && !(char == '\\' && isSpecial(url))) { - url.path.push(''); - } - } else { - if (url.scheme == 'file' && !url.path.length && isWindowsDriveLetter(buffer)) { - if (url.host) url.host = ''; - buffer = buffer.charAt(0) + ':'; // normalize windows drive letter - } - url.path.push(buffer); - } - buffer = ''; - if (url.scheme == 'file' && (char == EOF || char == '?' || char == '#')) { - while (url.path.length > 1 && url.path[0] === '') { - url.path.shift(); - } - } - if (char == '?') { - url.query = ''; - state = QUERY; - } else if (char == '#') { - url.fragment = ''; - state = FRAGMENT; - } - } else { - buffer += percentEncode(char, pathPercentEncodeSet); - } break; - - case CANNOT_BE_A_BASE_URL_PATH: - if (char == '?') { - url.query = ''; - state = QUERY; - } else if (char == '#') { - url.fragment = ''; - state = FRAGMENT; - } else if (char != EOF) { - url.path[0] += percentEncode(char, C0ControlPercentEncodeSet); - } break; - - case QUERY: - if (!stateOverride && char == '#') { - url.fragment = ''; - state = FRAGMENT; - } else if (char != EOF) { - if (char == "'" && isSpecial(url)) url.query += '%27'; - else if (char == '#') url.query += '%23'; - else url.query += percentEncode(char, C0ControlPercentEncodeSet); - } break; - - case FRAGMENT: - if (char != EOF) url.fragment += percentEncode(char, fragmentPercentEncodeSet); - break; - } - - pointer++; - } -}; - -// `URL` constructor -// https://url.spec.whatwg.org/#url-class -var URLConstructor = function URL(url /* , base */) { - var that = anInstance$3(this, URLConstructor, 'URL'); - var base = arguments.length > 1 ? arguments[1] : undefined; - var urlString = String(url); - var state = setInternalState$7(that, { type: 'URL' }); - var baseState, failure; - if (base !== undefined) { - if (base instanceof URLConstructor) baseState = getInternalURLState(base); - else { - failure = parseURL(baseState = {}, String(base)); - if (failure) throw TypeError(failure); - } - } - failure = parseURL(state, urlString, null, baseState); - if (failure) throw TypeError(failure); - var searchParams = state.searchParams = new URLSearchParams$1(); - var searchParamsState = getInternalSearchParamsState(searchParams); - searchParamsState.updateSearchParams(state.query); - searchParamsState.updateURL = function () { - state.query = String(searchParams) || null; - }; - if (!DESCRIPTORS$4) { - that.href = serializeURL.call(that); - that.origin = getOrigin.call(that); - that.protocol = getProtocol.call(that); - that.username = getUsername.call(that); - that.password = getPassword.call(that); - that.host = getHost.call(that); - that.hostname = getHostname.call(that); - that.port = getPort.call(that); - that.pathname = getPathname.call(that); - that.search = getSearch.call(that); - that.searchParams = getSearchParams.call(that); - that.hash = getHash.call(that); - } -}; - -var URLPrototype = URLConstructor.prototype; - -var serializeURL = function () { - var url = getInternalURLState(this); - var scheme = url.scheme; - var username = url.username; - var password = url.password; - var host = url.host; - var port = url.port; - var path = url.path; - var query = url.query; - var fragment = url.fragment; - var output = scheme + ':'; - if (host !== null) { - output += '//'; - if (includesCredentials(url)) { - output += username + (password ? ':' + password : '') + '@'; - } - output += serializeHost(host); - if (port !== null) output += ':' + port; - } else if (scheme == 'file') output += '//'; - output += url.cannotBeABaseURL ? path[0] : path.length ? '/' + path.join('/') : ''; - if (query !== null) output += '?' + query; - if (fragment !== null) output += '#' + fragment; - return output; -}; - -var getOrigin = function () { - var url = getInternalURLState(this); - var scheme = url.scheme; - var port = url.port; - if (scheme == 'blob') try { - return new URL(scheme.path[0]).origin; - } catch (error) { - return 'null'; - } - if (scheme == 'file' || !isSpecial(url)) return 'null'; - return scheme + '://' + serializeHost(url.host) + (port !== null ? ':' + port : ''); -}; - -var getProtocol = function () { - return getInternalURLState(this).scheme + ':'; -}; - -var getUsername = function () { - return getInternalURLState(this).username; -}; - -var getPassword = function () { - return getInternalURLState(this).password; -}; - -var getHost = function () { - var url = getInternalURLState(this); - var host = url.host; - var port = url.port; - return host === null ? '' - : port === null ? serializeHost(host) - : serializeHost(host) + ':' + port; -}; - -var getHostname = function () { - var host = getInternalURLState(this).host; - return host === null ? '' : serializeHost(host); -}; - -var getPort = function () { - var port = getInternalURLState(this).port; - return port === null ? '' : String(port); -}; - -var getPathname = function () { - var url = getInternalURLState(this); - var path = url.path; - return url.cannotBeABaseURL ? path[0] : path.length ? '/' + path.join('/') : ''; -}; - -var getSearch = function () { - var query = getInternalURLState(this).query; - return query ? '?' + query : ''; -}; - -var getSearchParams = function () { - return getInternalURLState(this).searchParams; -}; - -var getHash = function () { - var fragment = getInternalURLState(this).fragment; - return fragment ? '#' + fragment : ''; -}; - -var accessorDescriptor = function (getter, setter) { - return { get: getter, set: setter, configurable: true, enumerable: true }; -}; - -if (DESCRIPTORS$4) { - defineProperties$1(URLPrototype, { - // `URL.prototype.href` accessors pair - // https://url.spec.whatwg.org/#dom-url-href - href: accessorDescriptor(serializeURL, function (href) { - var url = getInternalURLState(this); - var urlString = String(href); - var failure = parseURL(url, urlString); - if (failure) throw TypeError(failure); - getInternalSearchParamsState(url.searchParams).updateSearchParams(url.query); - }), - // `URL.prototype.origin` getter - // https://url.spec.whatwg.org/#dom-url-origin - origin: accessorDescriptor(getOrigin), - // `URL.prototype.protocol` accessors pair - // https://url.spec.whatwg.org/#dom-url-protocol - protocol: accessorDescriptor(getProtocol, function (protocol) { - var url = getInternalURLState(this); - parseURL(url, String(protocol) + ':', SCHEME_START); - }), - // `URL.prototype.username` accessors pair - // https://url.spec.whatwg.org/#dom-url-username - username: accessorDescriptor(getUsername, function (username) { - var url = getInternalURLState(this); - var codePoints = arrayFrom(String(username)); - if (cannotHaveUsernamePasswordPort(url)) return; - url.username = ''; - for (var i = 0; i < codePoints.length; i++) { - url.username += percentEncode(codePoints[i], userinfoPercentEncodeSet); - } - }), - // `URL.prototype.password` accessors pair - // https://url.spec.whatwg.org/#dom-url-password - password: accessorDescriptor(getPassword, function (password) { - var url = getInternalURLState(this); - var codePoints = arrayFrom(String(password)); - if (cannotHaveUsernamePasswordPort(url)) return; - url.password = ''; - for (var i = 0; i < codePoints.length; i++) { - url.password += percentEncode(codePoints[i], userinfoPercentEncodeSet); - } - }), - // `URL.prototype.host` accessors pair - // https://url.spec.whatwg.org/#dom-url-host - host: accessorDescriptor(getHost, function (host) { - var url = getInternalURLState(this); - if (url.cannotBeABaseURL) return; - parseURL(url, String(host), HOST); - }), - // `URL.prototype.hostname` accessors pair - // https://url.spec.whatwg.org/#dom-url-hostname - hostname: accessorDescriptor(getHostname, function (hostname) { - var url = getInternalURLState(this); - if (url.cannotBeABaseURL) return; - parseURL(url, String(hostname), HOSTNAME); - }), - // `URL.prototype.port` accessors pair - // https://url.spec.whatwg.org/#dom-url-port - port: accessorDescriptor(getPort, function (port) { - var url = getInternalURLState(this); - if (cannotHaveUsernamePasswordPort(url)) return; - port = String(port); - if (port == '') url.port = null; - else parseURL(url, port, PORT); - }), - // `URL.prototype.pathname` accessors pair - // https://url.spec.whatwg.org/#dom-url-pathname - pathname: accessorDescriptor(getPathname, function (pathname) { - var url = getInternalURLState(this); - if (url.cannotBeABaseURL) return; - url.path = []; - parseURL(url, pathname + '', PATH_START); - }), - // `URL.prototype.search` accessors pair - // https://url.spec.whatwg.org/#dom-url-search - search: accessorDescriptor(getSearch, function (search) { - var url = getInternalURLState(this); - search = String(search); - if (search == '') { - url.query = null; - } else { - if ('?' == search.charAt(0)) search = search.slice(1); - url.query = ''; - parseURL(url, search, QUERY); - } - getInternalSearchParamsState(url.searchParams).updateSearchParams(url.query); - }), - // `URL.prototype.searchParams` getter - // https://url.spec.whatwg.org/#dom-url-searchparams - searchParams: accessorDescriptor(getSearchParams), - // `URL.prototype.hash` accessors pair - // https://url.spec.whatwg.org/#dom-url-hash - hash: accessorDescriptor(getHash, function (hash) { - var url = getInternalURLState(this); - hash = String(hash); - if (hash == '') { - url.fragment = null; - return; - } - if ('#' == hash.charAt(0)) hash = hash.slice(1); - url.fragment = ''; - parseURL(url, hash, FRAGMENT); - }) - }); -} - -// `URL.prototype.toJSON` method -// https://url.spec.whatwg.org/#dom-url-tojson -redefine(URLPrototype, 'toJSON', function toJSON() { - return serializeURL.call(this); -}, { enumerable: true }); - -// `URL.prototype.toString` method -// https://url.spec.whatwg.org/#URL-stringification-behavior -redefine(URLPrototype, 'toString', function toString() { - return serializeURL.call(this); -}, { enumerable: true }); - -if (NativeURL) { - var nativeCreateObjectURL = NativeURL.createObjectURL; - var nativeRevokeObjectURL = NativeURL.revokeObjectURL; - // `URL.createObjectURL` method - // https://developer.mozilla.org/en-US/docs/Web/API/URL/createObjectURL - // eslint-disable-next-line no-unused-vars - if (nativeCreateObjectURL) redefine(URLConstructor, 'createObjectURL', function createObjectURL(blob) { - return nativeCreateObjectURL.apply(NativeURL, arguments); - }); - // `URL.revokeObjectURL` method - // https://developer.mozilla.org/en-US/docs/Web/API/URL/revokeObjectURL - // eslint-disable-next-line no-unused-vars - if (nativeRevokeObjectURL) redefine(URLConstructor, 'revokeObjectURL', function revokeObjectURL(url) { - return nativeRevokeObjectURL.apply(NativeURL, arguments); - }); -} - -setToStringTag(URLConstructor, 'URL'); - -$$1D({ global: true, forced: !USE_NATIVE_URL, sham: !DESCRIPTORS$4 }, { - URL: URLConstructor -}); - -var $$1C = _export; - -// `URL.prototype.toJSON` method -// https://url.spec.whatwg.org/#dom-url-tojson -$$1C({ target: 'URL', proto: true, enumerable: true }, { - toJSON: function toJSON() { - return URL.prototype.toString.call(this); - } -}); - -var $$1B = _export; -var $filterOut$1 = arrayIteration.filterOut; -var addToUnscopables$4 = addToUnscopables$d; - -// `Array.prototype.filterOut` method -// https://github.com/tc39/proposal-array-filtering -$$1B({ target: 'Array', proto: true }, { - filterOut: function filterOut(callbackfn /* , thisArg */) { - return $filterOut$1(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined); - } -}); - -addToUnscopables$4('filterOut'); - -var ArrayBufferViewCore$1 = arrayBufferViewCore; -var $filterOut = arrayIteration.filterOut; -var speciesConstructor$9 = speciesConstructor$j; - -var aTypedArray$1 = ArrayBufferViewCore$1.aTypedArray; -var aTypedArrayConstructor = ArrayBufferViewCore$1.aTypedArrayConstructor; -var exportTypedArrayMethod$1 = ArrayBufferViewCore$1.exportTypedArrayMethod; - -// `%TypedArray%.prototype.filterOut` method -// https://github.com/tc39/proposal-array-filtering -exportTypedArrayMethod$1('filterOut', function filterOut(callbackfn /* , thisArg */) { - var list = $filterOut(aTypedArray$1(this), callbackfn, arguments.length > 1 ? arguments[1] : undefined); - var C = speciesConstructor$9(this, this.constructor); - var index = 0; - var length = list.length; - var result = new (aTypedArrayConstructor(C))(length); - while (length > index) result[index] = list[index++]; - return result; -}); - -var DESCRIPTORS$3 = descriptors; -var addToUnscopables$3 = addToUnscopables$d; -var toObject$6 = toObject$u; -var toLength$4 = toLength$y; -var defineProperty$2 = objectDefineProperty.f; - -// `Array.prototype.lastIndex` getter -// https://github.com/keithamus/proposal-array-last -if (DESCRIPTORS$3 && !('lastIndex' in [])) { - defineProperty$2(Array.prototype, 'lastIndex', { - configurable: true, - get: function lastIndex() { - var O = toObject$6(this); - var len = toLength$4(O.length); - return len == 0 ? 0 : len - 1; - } - }); - - addToUnscopables$3('lastIndex'); -} - -var DESCRIPTORS$2 = descriptors; -var addToUnscopables$2 = addToUnscopables$d; -var toObject$5 = toObject$u; -var toLength$3 = toLength$y; -var defineProperty$1 = objectDefineProperty.f; - -// `Array.prototype.lastIndex` accessor -// https://github.com/keithamus/proposal-array-last -if (DESCRIPTORS$2 && !('lastItem' in [])) { - defineProperty$1(Array.prototype, 'lastItem', { - configurable: true, - get: function lastItem() { - var O = toObject$5(this); - var len = toLength$3(O.length); - return len == 0 ? undefined : O[len - 1]; - }, - set: function lastItem(value) { - var O = toObject$5(this); - var len = toLength$3(O.length); - return O[len == 0 ? 0 : len - 1] = value; - } - }); - - addToUnscopables$2('lastItem'); -} - -var $$1A = _export; -var toLength$2 = toLength$y; -var toObject$4 = toObject$u; -var getBuiltIn$f = getBuiltIn$t; -var arraySpeciesCreate = arraySpeciesCreate$6; -var addToUnscopables$1 = addToUnscopables$d; - -var push$2 = [].push; - -// `Array.prototype.uniqueBy` method -// https://github.com/tc39/proposal-array-unique -$$1A({ target: 'Array', proto: true }, { - uniqueBy: function uniqueBy(resolver) { - var that = toObject$4(this); - var length = toLength$2(that.length); - var result = arraySpeciesCreate(that, 0); - var Map = getBuiltIn$f('Map'); - var map = new Map(); - var resolverFunction, index, item, key; - if (typeof resolver == 'function') resolverFunction = resolver; - else if (resolver == null) resolverFunction = function (value) { - return value; - }; - else throw new TypeError('Incorrect resolver!'); - for (index = 0; index < length; index++) { - item = that[index]; - key = resolverFunction(item); - if (!map.has(key)) map.set(key, item); - } - map.forEach(function (value) { - push$2.call(result, value); - }); - return result; - } -}); - -addToUnscopables$1('uniqueBy'); - -var $$1z = _export; -var iterate$y = iterate$I; -var aFunction$B = aFunction$R; - -// `Map.groupBy` method -// https://github.com/tc39/proposal-collection-methods -$$1z({ target: 'Map', stat: true }, { - groupBy: function groupBy(iterable, keyDerivative) { - var newMap = new this(); - aFunction$B(keyDerivative); - var has = aFunction$B(newMap.has); - var get = aFunction$B(newMap.get); - var set = aFunction$B(newMap.set); - iterate$y(iterable, function (element) { - var derivedKey = keyDerivative(element); - if (!has.call(newMap, derivedKey)) set.call(newMap, derivedKey, [element]); - else get.call(newMap, derivedKey).push(element); - }); - return newMap; - } -}); - -var $$1y = _export; -var iterate$x = iterate$I; -var aFunction$A = aFunction$R; - -// `Map.keyBy` method -// https://github.com/tc39/proposal-collection-methods -$$1y({ target: 'Map', stat: true }, { - keyBy: function keyBy(iterable, keyDerivative) { - var newMap = new this(); - aFunction$A(keyDerivative); - var setter = aFunction$A(newMap.set); - iterate$x(iterable, function (element) { - setter.call(newMap, keyDerivative(element), element); - }); - return newMap; - } -}); - -var anObject$T = anObject$1z; -var aFunction$z = aFunction$R; - -// https://github.com/tc39/collection-methods -var collectionDeleteAll$4 = function (/* ...elements */) { - var collection = anObject$T(this); - var remover = aFunction$z(collection['delete']); - var allDeleted = true; - var wasDeleted; - for (var k = 0, len = arguments.length; k < len; k++) { - wasDeleted = remover.call(collection, arguments[k]); - allDeleted = allDeleted && wasDeleted; - } - return !!allDeleted; -}; - -var $$1x = _export; -var IS_PURE$B = isPure; -var collectionDeleteAll$3 = collectionDeleteAll$4; - -// `Map.prototype.deleteAll` method -// https://github.com/tc39/proposal-collection-methods -$$1x({ target: 'Map', proto: true, real: true, forced: IS_PURE$B }, { - deleteAll: function deleteAll(/* ...elements */) { - return collectionDeleteAll$3.apply(this, arguments); - } -}); - -var getMapIterator$a = function (it) { - // eslint-disable-next-line no-undef - return Map.prototype.entries.call(it); -}; - -var $$1w = _export; -var IS_PURE$A = isPure; -var anObject$S = anObject$1z; -var bind$c = functionBindContext; -var getMapIterator$9 = getMapIterator$a; -var iterate$w = iterate$I; - -// `Map.prototype.every` method -// https://github.com/tc39/proposal-collection-methods -$$1w({ target: 'Map', proto: true, real: true, forced: IS_PURE$A }, { - every: function every(callbackfn /* , thisArg */) { - var map = anObject$S(this); - var iterator = getMapIterator$9(map); - var boundFunction = bind$c(callbackfn, arguments.length > 1 ? arguments[1] : undefined, 3); - return !iterate$w(iterator, function (key, value, stop) { - if (!boundFunction(value, key, map)) return stop(); - }, { AS_ENTRIES: true, IS_ITERATOR: true, INTERRUPTED: true }).stopped; - } -}); - -var $$1v = _export; -var IS_PURE$z = isPure; -var getBuiltIn$e = getBuiltIn$t; -var anObject$R = anObject$1z; -var aFunction$y = aFunction$R; -var bind$b = functionBindContext; -var speciesConstructor$8 = speciesConstructor$j; -var getMapIterator$8 = getMapIterator$a; -var iterate$v = iterate$I; - -// `Map.prototype.filter` method -// https://github.com/tc39/proposal-collection-methods -$$1v({ target: 'Map', proto: true, real: true, forced: IS_PURE$z }, { - filter: function filter(callbackfn /* , thisArg */) { - var map = anObject$R(this); - var iterator = getMapIterator$8(map); - var boundFunction = bind$b(callbackfn, arguments.length > 1 ? arguments[1] : undefined, 3); - var newMap = new (speciesConstructor$8(map, getBuiltIn$e('Map')))(); - var setter = aFunction$y(newMap.set); - iterate$v(iterator, function (key, value) { - if (boundFunction(value, key, map)) setter.call(newMap, key, value); - }, { AS_ENTRIES: true, IS_ITERATOR: true }); - return newMap; - } -}); - -var $$1u = _export; -var IS_PURE$y = isPure; -var anObject$Q = anObject$1z; -var bind$a = functionBindContext; -var getMapIterator$7 = getMapIterator$a; -var iterate$u = iterate$I; - -// `Map.prototype.find` method -// https://github.com/tc39/proposal-collection-methods -$$1u({ target: 'Map', proto: true, real: true, forced: IS_PURE$y }, { - find: function find(callbackfn /* , thisArg */) { - var map = anObject$Q(this); - var iterator = getMapIterator$7(map); - var boundFunction = bind$a(callbackfn, arguments.length > 1 ? arguments[1] : undefined, 3); - return iterate$u(iterator, function (key, value, stop) { - if (boundFunction(value, key, map)) return stop(value); - }, { AS_ENTRIES: true, IS_ITERATOR: true, INTERRUPTED: true }).result; - } -}); - -var $$1t = _export; -var IS_PURE$x = isPure; -var anObject$P = anObject$1z; -var bind$9 = functionBindContext; -var getMapIterator$6 = getMapIterator$a; -var iterate$t = iterate$I; - -// `Map.prototype.findKey` method -// https://github.com/tc39/proposal-collection-methods -$$1t({ target: 'Map', proto: true, real: true, forced: IS_PURE$x }, { - findKey: function findKey(callbackfn /* , thisArg */) { - var map = anObject$P(this); - var iterator = getMapIterator$6(map); - var boundFunction = bind$9(callbackfn, arguments.length > 1 ? arguments[1] : undefined, 3); - return iterate$t(iterator, function (key, value, stop) { - if (boundFunction(value, key, map)) return stop(key); - }, { AS_ENTRIES: true, IS_ITERATOR: true, INTERRUPTED: true }).result; - } -}); - -// `SameValueZero` abstract operation -// https://tc39.es/ecma262/#sec-samevaluezero -var sameValueZero$1 = function (x, y) { - // eslint-disable-next-line no-self-compare - return x === y || x != x && y != y; -}; - -var $$1s = _export; -var IS_PURE$w = isPure; -var anObject$O = anObject$1z; -var getMapIterator$5 = getMapIterator$a; -var sameValueZero = sameValueZero$1; -var iterate$s = iterate$I; - -// `Map.prototype.includes` method -// https://github.com/tc39/proposal-collection-methods -$$1s({ target: 'Map', proto: true, real: true, forced: IS_PURE$w }, { - includes: function includes(searchElement) { - return iterate$s(getMapIterator$5(anObject$O(this)), function (key, value, stop) { - if (sameValueZero(value, searchElement)) return stop(); - }, { AS_ENTRIES: true, IS_ITERATOR: true, INTERRUPTED: true }).stopped; - } -}); - -var $$1r = _export; -var IS_PURE$v = isPure; -var anObject$N = anObject$1z; -var getMapIterator$4 = getMapIterator$a; -var iterate$r = iterate$I; - -// `Map.prototype.includes` method -// https://github.com/tc39/proposal-collection-methods -$$1r({ target: 'Map', proto: true, real: true, forced: IS_PURE$v }, { - keyOf: function keyOf(searchElement) { - return iterate$r(getMapIterator$4(anObject$N(this)), function (key, value, stop) { - if (value === searchElement) return stop(key); - }, { AS_ENTRIES: true, IS_ITERATOR: true, INTERRUPTED: true }).result; - } -}); - -var $$1q = _export; -var IS_PURE$u = isPure; -var getBuiltIn$d = getBuiltIn$t; -var anObject$M = anObject$1z; -var aFunction$x = aFunction$R; -var bind$8 = functionBindContext; -var speciesConstructor$7 = speciesConstructor$j; -var getMapIterator$3 = getMapIterator$a; -var iterate$q = iterate$I; - -// `Map.prototype.mapKeys` method -// https://github.com/tc39/proposal-collection-methods -$$1q({ target: 'Map', proto: true, real: true, forced: IS_PURE$u }, { - mapKeys: function mapKeys(callbackfn /* , thisArg */) { - var map = anObject$M(this); - var iterator = getMapIterator$3(map); - var boundFunction = bind$8(callbackfn, arguments.length > 1 ? arguments[1] : undefined, 3); - var newMap = new (speciesConstructor$7(map, getBuiltIn$d('Map')))(); - var setter = aFunction$x(newMap.set); - iterate$q(iterator, function (key, value) { - setter.call(newMap, boundFunction(value, key, map), value); - }, { AS_ENTRIES: true, IS_ITERATOR: true }); - return newMap; - } -}); - -var $$1p = _export; -var IS_PURE$t = isPure; -var getBuiltIn$c = getBuiltIn$t; -var anObject$L = anObject$1z; -var aFunction$w = aFunction$R; -var bind$7 = functionBindContext; -var speciesConstructor$6 = speciesConstructor$j; -var getMapIterator$2 = getMapIterator$a; -var iterate$p = iterate$I; - -// `Map.prototype.mapValues` method -// https://github.com/tc39/proposal-collection-methods -$$1p({ target: 'Map', proto: true, real: true, forced: IS_PURE$t }, { - mapValues: function mapValues(callbackfn /* , thisArg */) { - var map = anObject$L(this); - var iterator = getMapIterator$2(map); - var boundFunction = bind$7(callbackfn, arguments.length > 1 ? arguments[1] : undefined, 3); - var newMap = new (speciesConstructor$6(map, getBuiltIn$c('Map')))(); - var setter = aFunction$w(newMap.set); - iterate$p(iterator, function (key, value) { - setter.call(newMap, key, boundFunction(value, key, map)); - }, { AS_ENTRIES: true, IS_ITERATOR: true }); - return newMap; - } -}); - -var $$1o = _export; -var IS_PURE$s = isPure; -var anObject$K = anObject$1z; -var aFunction$v = aFunction$R; -var iterate$o = iterate$I; - -// `Map.prototype.merge` method -// https://github.com/tc39/proposal-collection-methods -$$1o({ target: 'Map', proto: true, real: true, forced: IS_PURE$s }, { - // eslint-disable-next-line no-unused-vars - merge: function merge(iterable /* ...iterbles */) { - var map = anObject$K(this); - var setter = aFunction$v(map.set); - var i = 0; - while (i < arguments.length) { - iterate$o(arguments[i++], setter, { that: map, AS_ENTRIES: true }); - } - return map; - } -}); - -var $$1n = _export; -var IS_PURE$r = isPure; -var anObject$J = anObject$1z; -var aFunction$u = aFunction$R; -var getMapIterator$1 = getMapIterator$a; -var iterate$n = iterate$I; - -// `Map.prototype.reduce` method -// https://github.com/tc39/proposal-collection-methods -$$1n({ target: 'Map', proto: true, real: true, forced: IS_PURE$r }, { - reduce: function reduce(callbackfn /* , initialValue */) { - var map = anObject$J(this); - var iterator = getMapIterator$1(map); - var noInitial = arguments.length < 2; - var accumulator = noInitial ? undefined : arguments[1]; - aFunction$u(callbackfn); - iterate$n(iterator, function (key, value) { - if (noInitial) { - noInitial = false; - accumulator = value; - } else { - accumulator = callbackfn(accumulator, value, key, map); - } - }, { AS_ENTRIES: true, IS_ITERATOR: true }); - if (noInitial) throw TypeError('Reduce of empty map with no initial value'); - return accumulator; - } -}); - -var $$1m = _export; -var IS_PURE$q = isPure; -var anObject$I = anObject$1z; -var bind$6 = functionBindContext; -var getMapIterator = getMapIterator$a; -var iterate$m = iterate$I; - -// `Set.prototype.some` method -// https://github.com/tc39/proposal-collection-methods -$$1m({ target: 'Map', proto: true, real: true, forced: IS_PURE$q }, { - some: function some(callbackfn /* , thisArg */) { - var map = anObject$I(this); - var iterator = getMapIterator(map); - var boundFunction = bind$6(callbackfn, arguments.length > 1 ? arguments[1] : undefined, 3); - return iterate$m(iterator, function (key, value, stop) { - if (boundFunction(value, key, map)) return stop(); - }, { AS_ENTRIES: true, IS_ITERATOR: true, INTERRUPTED: true }).stopped; - } -}); - -var $$1l = _export; -var IS_PURE$p = isPure; -var anObject$H = anObject$1z; -var aFunction$t = aFunction$R; - -// `Set.prototype.update` method -// https://github.com/tc39/proposal-collection-methods -$$1l({ target: 'Map', proto: true, real: true, forced: IS_PURE$p }, { - update: function update(key, callback /* , thunk */) { - var map = anObject$H(this); - var length = arguments.length; - aFunction$t(callback); - var isPresentInMap = map.has(key); - if (!isPresentInMap && length < 3) { - throw TypeError('Updating absent value'); - } - var value = isPresentInMap ? map.get(key) : aFunction$t(length > 2 ? arguments[2] : undefined)(key, map); - map.set(key, callback(value, key, map)); - return map; - } -}); - -var anObject$G = anObject$1z; -var aFunction$s = aFunction$R; - -// https://github.com/tc39/collection-methods -var collectionAddAll$2 = function (/* ...elements */) { - var set = anObject$G(this); - var adder = aFunction$s(set.add); - for (var k = 0, len = arguments.length; k < len; k++) { - adder.call(set, arguments[k]); - } - return set; -}; - -var $$1k = _export; -var IS_PURE$o = isPure; -var collectionAddAll$1 = collectionAddAll$2; - -// `Set.prototype.addAll` method -// https://github.com/tc39/proposal-collection-methods -$$1k({ target: 'Set', proto: true, real: true, forced: IS_PURE$o }, { - addAll: function addAll(/* ...elements */) { - return collectionAddAll$1.apply(this, arguments); - } -}); - -var $$1j = _export; -var IS_PURE$n = isPure; -var collectionDeleteAll$2 = collectionDeleteAll$4; - -// `Set.prototype.deleteAll` method -// https://github.com/tc39/proposal-collection-methods -$$1j({ target: 'Set', proto: true, real: true, forced: IS_PURE$n }, { - deleteAll: function deleteAll(/* ...elements */) { - return collectionDeleteAll$2.apply(this, arguments); - } -}); - -var getSetIterator$7 = function (it) { - // eslint-disable-next-line no-undef - return Set.prototype.values.call(it); -}; - -var $$1i = _export; -var IS_PURE$m = isPure; -var anObject$F = anObject$1z; -var bind$5 = functionBindContext; -var getSetIterator$6 = getSetIterator$7; -var iterate$l = iterate$I; - -// `Set.prototype.every` method -// https://github.com/tc39/proposal-collection-methods -$$1i({ target: 'Set', proto: true, real: true, forced: IS_PURE$m }, { - every: function every(callbackfn /* , thisArg */) { - var set = anObject$F(this); - var iterator = getSetIterator$6(set); - var boundFunction = bind$5(callbackfn, arguments.length > 1 ? arguments[1] : undefined, 3); - return !iterate$l(iterator, function (value, stop) { - if (!boundFunction(value, value, set)) return stop(); - }, { IS_ITERATOR: true, INTERRUPTED: true }).stopped; - } -}); - -var $$1h = _export; -var IS_PURE$l = isPure; -var getBuiltIn$b = getBuiltIn$t; -var anObject$E = anObject$1z; -var aFunction$r = aFunction$R; -var bind$4 = functionBindContext; -var speciesConstructor$5 = speciesConstructor$j; -var getSetIterator$5 = getSetIterator$7; -var iterate$k = iterate$I; - -// `Set.prototype.filter` method -// https://github.com/tc39/proposal-collection-methods -$$1h({ target: 'Set', proto: true, real: true, forced: IS_PURE$l }, { - filter: function filter(callbackfn /* , thisArg */) { - var set = anObject$E(this); - var iterator = getSetIterator$5(set); - var boundFunction = bind$4(callbackfn, arguments.length > 1 ? arguments[1] : undefined, 3); - var newSet = new (speciesConstructor$5(set, getBuiltIn$b('Set')))(); - var adder = aFunction$r(newSet.add); - iterate$k(iterator, function (value) { - if (boundFunction(value, value, set)) adder.call(newSet, value); - }, { IS_ITERATOR: true }); - return newSet; - } -}); - -var $$1g = _export; -var IS_PURE$k = isPure; -var anObject$D = anObject$1z; -var bind$3 = functionBindContext; -var getSetIterator$4 = getSetIterator$7; -var iterate$j = iterate$I; - -// `Set.prototype.find` method -// https://github.com/tc39/proposal-collection-methods -$$1g({ target: 'Set', proto: true, real: true, forced: IS_PURE$k }, { - find: function find(callbackfn /* , thisArg */) { - var set = anObject$D(this); - var iterator = getSetIterator$4(set); - var boundFunction = bind$3(callbackfn, arguments.length > 1 ? arguments[1] : undefined, 3); - return iterate$j(iterator, function (value, stop) { - if (boundFunction(value, value, set)) return stop(value); - }, { IS_ITERATOR: true, INTERRUPTED: true }).result; - } -}); - -var $$1f = _export; -var IS_PURE$j = isPure; -var anObject$C = anObject$1z; -var getSetIterator$3 = getSetIterator$7; -var iterate$i = iterate$I; - -// `Set.prototype.join` method -// https://github.com/tc39/proposal-collection-methods -$$1f({ target: 'Set', proto: true, real: true, forced: IS_PURE$j }, { - join: function join(separator) { - var set = anObject$C(this); - var iterator = getSetIterator$3(set); - var sep = separator === undefined ? ',' : String(separator); - var result = []; - iterate$i(iterator, result.push, { that: result, IS_ITERATOR: true }); - return result.join(sep); - } -}); - -var $$1e = _export; -var IS_PURE$i = isPure; -var getBuiltIn$a = getBuiltIn$t; -var anObject$B = anObject$1z; -var aFunction$q = aFunction$R; -var bind$2 = functionBindContext; -var speciesConstructor$4 = speciesConstructor$j; -var getSetIterator$2 = getSetIterator$7; -var iterate$h = iterate$I; - -// `Set.prototype.map` method -// https://github.com/tc39/proposal-collection-methods -$$1e({ target: 'Set', proto: true, real: true, forced: IS_PURE$i }, { - map: function map(callbackfn /* , thisArg */) { - var set = anObject$B(this); - var iterator = getSetIterator$2(set); - var boundFunction = bind$2(callbackfn, arguments.length > 1 ? arguments[1] : undefined, 3); - var newSet = new (speciesConstructor$4(set, getBuiltIn$a('Set')))(); - var adder = aFunction$q(newSet.add); - iterate$h(iterator, function (value) { - adder.call(newSet, boundFunction(value, value, set)); - }, { IS_ITERATOR: true }); - return newSet; - } -}); - -var $$1d = _export; -var IS_PURE$h = isPure; -var anObject$A = anObject$1z; -var aFunction$p = aFunction$R; -var getSetIterator$1 = getSetIterator$7; -var iterate$g = iterate$I; - -// `Set.prototype.reduce` method -// https://github.com/tc39/proposal-collection-methods -$$1d({ target: 'Set', proto: true, real: true, forced: IS_PURE$h }, { - reduce: function reduce(callbackfn /* , initialValue */) { - var set = anObject$A(this); - var iterator = getSetIterator$1(set); - var noInitial = arguments.length < 2; - var accumulator = noInitial ? undefined : arguments[1]; - aFunction$p(callbackfn); - iterate$g(iterator, function (value) { - if (noInitial) { - noInitial = false; - accumulator = value; - } else { - accumulator = callbackfn(accumulator, value, value, set); - } - }, { IS_ITERATOR: true }); - if (noInitial) throw TypeError('Reduce of empty set with no initial value'); - return accumulator; - } -}); - -var $$1c = _export; -var IS_PURE$g = isPure; -var anObject$z = anObject$1z; -var bind$1 = functionBindContext; -var getSetIterator = getSetIterator$7; -var iterate$f = iterate$I; - -// `Set.prototype.some` method -// https://github.com/tc39/proposal-collection-methods -$$1c({ target: 'Set', proto: true, real: true, forced: IS_PURE$g }, { - some: function some(callbackfn /* , thisArg */) { - var set = anObject$z(this); - var iterator = getSetIterator(set); - var boundFunction = bind$1(callbackfn, arguments.length > 1 ? arguments[1] : undefined, 3); - return iterate$f(iterator, function (value, stop) { - if (boundFunction(value, value, set)) return stop(); - }, { IS_ITERATOR: true, INTERRUPTED: true }).stopped; - } -}); - -var $$1b = _export; -var IS_PURE$f = isPure; -var collectionDeleteAll$1 = collectionDeleteAll$4; - -// `WeakMap.prototype.deleteAll` method -// https://github.com/tc39/proposal-collection-methods -$$1b({ target: 'WeakMap', proto: true, real: true, forced: IS_PURE$f }, { - deleteAll: function deleteAll(/* ...elements */) { - return collectionDeleteAll$1.apply(this, arguments); - } -}); - -var $$1a = _export; -var IS_PURE$e = isPure; -var collectionAddAll = collectionAddAll$2; - -// `WeakSet.prototype.addAll` method -// https://github.com/tc39/proposal-collection-methods -$$1a({ target: 'WeakSet', proto: true, real: true, forced: IS_PURE$e }, { - addAll: function addAll(/* ...elements */) { - return collectionAddAll.apply(this, arguments); - } -}); - -var $$19 = _export; -var IS_PURE$d = isPure; -var collectionDeleteAll = collectionDeleteAll$4; - -// `WeakSet.prototype.deleteAll` method -// https://github.com/tc39/proposal-collection-methods -$$19({ target: 'WeakSet', proto: true, real: true, forced: IS_PURE$d }, { - deleteAll: function deleteAll(/* ...elements */) { - return collectionDeleteAll.apply(this, arguments); - } -}); - -// https://tc39.github.io/proposal-setmap-offrom/ -var aFunction$o = aFunction$R; -var bind = functionBindContext; -var iterate$e = iterate$I; - -var collectionFrom = function from(source /* , mapFn, thisArg */) { - var length = arguments.length; - var mapFn = length > 1 ? arguments[1] : undefined; - var mapping, array, n, boundFunction; - aFunction$o(this); - mapping = mapFn !== undefined; - if (mapping) aFunction$o(mapFn); - if (source == undefined) return new this(); - array = []; - if (mapping) { - n = 0; - boundFunction = bind(mapFn, length > 2 ? arguments[2] : undefined, 2); - iterate$e(source, function (nextItem) { - array.push(boundFunction(nextItem, n++)); - }); - } else { - iterate$e(source, array.push, { that: array }); - } - return new this(array); -}; - -var $$18 = _export; -var from$3 = collectionFrom; - -// `Map.from` method -// https://tc39.github.io/proposal-setmap-offrom/#sec-map.from -$$18({ target: 'Map', stat: true }, { - from: from$3 -}); - -// https://tc39.github.io/proposal-setmap-offrom/ -var collectionOf = function of() { - var length = arguments.length; - var A = new Array(length); - while (length--) A[length] = arguments[length]; - return new this(A); -}; - -var $$17 = _export; -var of$3 = collectionOf; - -// `Map.of` method -// https://tc39.github.io/proposal-setmap-offrom/#sec-map.of -$$17({ target: 'Map', stat: true }, { - of: of$3 -}); - -var $$16 = _export; -var from$2 = collectionFrom; - -// `Set.from` method -// https://tc39.github.io/proposal-setmap-offrom/#sec-set.from -$$16({ target: 'Set', stat: true }, { - from: from$2 -}); - -var $$15 = _export; -var of$2 = collectionOf; - -// `Set.of` method -// https://tc39.github.io/proposal-setmap-offrom/#sec-set.of -$$15({ target: 'Set', stat: true }, { - of: of$2 -}); - -var $$14 = _export; -var from$1 = collectionFrom; - -// `WeakMap.from` method -// https://tc39.github.io/proposal-setmap-offrom/#sec-weakmap.from -$$14({ target: 'WeakMap', stat: true }, { - from: from$1 -}); - -var $$13 = _export; -var of$1 = collectionOf; - -// `WeakMap.of` method -// https://tc39.github.io/proposal-setmap-offrom/#sec-weakmap.of -$$13({ target: 'WeakMap', stat: true }, { - of: of$1 -}); - -var $$12 = _export; -var from = collectionFrom; - -// `WeakSet.from` method -// https://tc39.github.io/proposal-setmap-offrom/#sec-weakset.from -$$12({ target: 'WeakSet', stat: true }, { - from: from -}); - -var $$11 = _export; -var of = collectionOf; - -// `WeakSet.of` method -// https://tc39.github.io/proposal-setmap-offrom/#sec-weakset.of -$$11({ target: 'WeakSet', stat: true }, { - of: of -}); - -// TODO: in core-js@4, move /modules/ dependencies to public entries for better optimization by tools like `preset-env` -var Map$1 = es_map; -var WeakMap = es_weakMap.exports; -var create$3 = objectCreate; -var isObject$2 = isObject$B; - -var Node = function () { - // keys - this.object = null; - this.symbol = null; - // child nodes - this.primitives = null; - this.objectsByIndex = create$3(null); -}; - -Node.prototype.get = function (key, initializer) { - return this[key] || (this[key] = initializer()); -}; - -Node.prototype.next = function (i, it, IS_OBJECT) { - var store = IS_OBJECT - ? this.objectsByIndex[i] || (this.objectsByIndex[i] = new WeakMap()) - : this.primitives || (this.primitives = new Map$1()); - var entry = store.get(it); - if (!entry) store.set(it, entry = new Node()); - return entry; -}; - -var root = new Node(); - -var compositeKey = function () { - var active = root; - var length = arguments.length; - var i, it; - // for prevent leaking, start from objects - for (i = 0; i < length; i++) { - if (isObject$2(it = arguments[i])) active = active.next(i, it, true); - } - if (this === Object && active === root) throw TypeError('Composite keys must contain a non-primitive component'); - for (i = 0; i < length; i++) { - if (!isObject$2(it = arguments[i])) active = active.next(i, it, false); - } return active; -}; - -var $$10 = _export; -var getCompositeKeyNode$1 = compositeKey; -var getBuiltIn$9 = getBuiltIn$t; -var create$2 = objectCreate; - -var initializer = function () { - var freeze = getBuiltIn$9('Object', 'freeze'); - return freeze ? freeze(create$2(null)) : create$2(null); -}; - -// https://github.com/tc39/proposal-richer-keys/tree/master/compositeKey -$$10({ global: true }, { - compositeKey: function compositeKey() { - return getCompositeKeyNode$1.apply(Object, arguments).get('object', initializer); - } -}); - -var $$$ = _export; -var getCompositeKeyNode = compositeKey; -var getBuiltIn$8 = getBuiltIn$t; - -// https://github.com/tc39/proposal-richer-keys/tree/master/compositeKey -$$$({ global: true }, { - compositeSymbol: function compositeSymbol() { - if (arguments.length === 1 && typeof arguments[0] === 'string') return getBuiltIn$8('Symbol')['for'](arguments[0]); - return getCompositeKeyNode.apply(null, arguments).get('symbol', getBuiltIn$8('Symbol')); - } -}); - -var $$_ = _export; - -var min = Math.min; -var max = Math.max; - -// `Math.clamp` method -// https://rwaldron.github.io/proposal-math-extensions/ -$$_({ target: 'Math', stat: true }, { - clamp: function clamp(x, lower, upper) { - return min(upper, max(lower, x)); - } -}); - -var $$Z = _export; - -// `Math.DEG_PER_RAD` constant -// https://rwaldron.github.io/proposal-math-extensions/ -$$Z({ target: 'Math', stat: true }, { - DEG_PER_RAD: Math.PI / 180 -}); - -var $$Y = _export; - -var RAD_PER_DEG = 180 / Math.PI; - -// `Math.degrees` method -// https://rwaldron.github.io/proposal-math-extensions/ -$$Y({ target: 'Math', stat: true }, { - degrees: function degrees(radians) { - return radians * RAD_PER_DEG; - } -}); - -// `Math.scale` method implementation -// https://rwaldron.github.io/proposal-math-extensions/ -var mathScale = Math.scale || function scale(x, inLow, inHigh, outLow, outHigh) { - if ( - arguments.length === 0 - /* eslint-disable no-self-compare */ - || x != x - || inLow != inLow - || inHigh != inHigh - || outLow != outLow - || outHigh != outHigh - /* eslint-enable no-self-compare */ - ) return NaN; - if (x === Infinity || x === -Infinity) return x; - return (x - inLow) * (outHigh - outLow) / (inHigh - inLow) + outLow; -}; - -var $$X = _export; - -var scale$1 = mathScale; -var fround = mathFround; - -// `Math.fscale` method -// https://rwaldron.github.io/proposal-math-extensions/ -$$X({ target: 'Math', stat: true }, { - fscale: function fscale(x, inLow, inHigh, outLow, outHigh) { - return fround(scale$1(x, inLow, inHigh, outLow, outHigh)); - } -}); - -var $$W = _export; - -// `Math.RAD_PER_DEG` constant -// https://rwaldron.github.io/proposal-math-extensions/ -$$W({ target: 'Math', stat: true }, { - RAD_PER_DEG: 180 / Math.PI -}); - -var $$V = _export; - -var DEG_PER_RAD = Math.PI / 180; - -// `Math.radians` method -// https://rwaldron.github.io/proposal-math-extensions/ -$$V({ target: 'Math', stat: true }, { - radians: function radians(degrees) { - return degrees * DEG_PER_RAD; - } -}); - -var $$U = _export; -var scale = mathScale; - -// `Math.scale` method -// https://rwaldron.github.io/proposal-math-extensions/ -$$U({ target: 'Math', stat: true }, { - scale: scale -}); - -var $$T = _export; - -// `Math.signbit` method -// https://github.com/tc39/proposal-Math.signbit -$$T({ target: 'Math', stat: true }, { - signbit: function signbit(x) { - return (x = +x) == x && x == 0 ? 1 / x == -Infinity : x < 0; - } -}); - -var $$S = _export; -var toInteger$2 = toInteger$f; -var parseInt$1 = numberParseInt; - -var INVALID_NUMBER_REPRESENTATION = 'Invalid number representation'; -var INVALID_RADIX = 'Invalid radix'; -var valid = /^[\da-z]+$/; - -// `Number.fromString` method -// https://github.com/tc39/proposal-number-fromstring -$$S({ target: 'Number', stat: true }, { - fromString: function fromString(string, radix) { - var sign = 1; - var R, mathNum; - if (typeof string != 'string') throw TypeError(INVALID_NUMBER_REPRESENTATION); - if (!string.length) throw SyntaxError(INVALID_NUMBER_REPRESENTATION); - if (string.charAt(0) == '-') { - sign = -1; - string = string.slice(1); - if (!string.length) throw SyntaxError(INVALID_NUMBER_REPRESENTATION); - } - R = radix === undefined ? 10 : toInteger$2(radix); - if (R < 2 || R > 36) throw RangeError(INVALID_RADIX); - if (!valid.test(string) || (mathNum = parseInt$1(string, R)).toString(R) !== string) { - throw SyntaxError(INVALID_NUMBER_REPRESENTATION); - } - return sign * mathNum; - } -}); - -var InternalStateModule$6 = internalState; -var createIteratorConstructor$3 = createIteratorConstructor$7; -var isObject$1 = isObject$B; -var defineProperties = objectDefineProperties; -var DESCRIPTORS$1 = descriptors; - -var INCORRECT_RANGE = 'Incorrect Number.range arguments'; -var RANGE_ITERATOR = 'RangeIterator'; - -var setInternalState$6 = InternalStateModule$6.set; -var getInternalState$6 = InternalStateModule$6.getterFor(RANGE_ITERATOR); - -var $RangeIterator = createIteratorConstructor$3(function RangeIterator(start, end, option, type, zero, one) { - if (typeof start != type || (end !== Infinity && end !== -Infinity && typeof end != type)) { - throw new TypeError(INCORRECT_RANGE); - } - if (start === Infinity || start === -Infinity) { - throw new RangeError(INCORRECT_RANGE); - } - var ifIncrease = end > start; - var inclusiveEnd = false; - var step; - if (option === undefined) { - step = undefined; - } else if (isObject$1(option)) { - step = option.step; - inclusiveEnd = !!option.inclusive; - } else if (typeof option == type) { - step = option; - } else { - throw new TypeError(INCORRECT_RANGE); - } - if (step == null) { - step = ifIncrease ? one : -one; - } - if (typeof step != type) { - throw new TypeError(INCORRECT_RANGE); - } - if (step === Infinity || step === -Infinity || (step === zero && start !== end)) { - throw new RangeError(INCORRECT_RANGE); - } - // eslint-disable-next-line no-self-compare - var hitsEnd = start != start || end != end || step != step || (end > start) !== (step > zero); - setInternalState$6(this, { - type: RANGE_ITERATOR, - start: start, - end: end, - step: step, - inclusiveEnd: inclusiveEnd, - hitsEnd: hitsEnd, - currentCount: zero, - zero: zero - }); - if (!DESCRIPTORS$1) { - this.start = start; - this.end = end; - this.step = step; - this.inclusive = inclusiveEnd; - } -}, RANGE_ITERATOR, function next() { - var state = getInternalState$6(this); - if (state.hitsEnd) return { value: undefined, done: true }; - var start = state.start; - var end = state.end; - var step = state.step; - var currentYieldingValue = start + (step * state.currentCount++); - if (currentYieldingValue === end) state.hitsEnd = true; - var inclusiveEnd = state.inclusiveEnd; - var endCondition; - if (end > start) { - endCondition = inclusiveEnd ? currentYieldingValue > end : currentYieldingValue >= end; - } else { - endCondition = inclusiveEnd ? end > currentYieldingValue : end >= currentYieldingValue; - } - if (endCondition) { - return { value: undefined, done: state.hitsEnd = true }; - } return { value: currentYieldingValue, done: false }; -}); - -var getter = function (fn) { - return { get: fn, set: function () { /* empty */ }, configurable: true, enumerable: false }; -}; - -if (DESCRIPTORS$1) { - defineProperties($RangeIterator.prototype, { - start: getter(function () { - return getInternalState$6(this).start; - }), - end: getter(function () { - return getInternalState$6(this).end; - }), - inclusive: getter(function () { - return getInternalState$6(this).inclusiveEnd; - }), - step: getter(function () { - return getInternalState$6(this).step; - }) - }); -} - -var rangeIterator = $RangeIterator; - -var $$R = _export; -var RangeIterator$1 = rangeIterator; - -// `BigInt.range` method -// https://github.com/tc39/proposal-Number.range -if (typeof BigInt == 'function') { - $$R({ target: 'BigInt', stat: true }, { - range: function range(start, end, option) { - // eslint-disable-next-line no-undef - return new RangeIterator$1(start, end, option, 'bigint', BigInt(0), BigInt(1)); - } - }); -} - -var $$Q = _export; -var RangeIterator = rangeIterator; - -// `Number.range` method -// https://github.com/tc39/proposal-Number.range -$$Q({ target: 'Number', stat: true }, { - range: function range(start, end, option) { - return new RangeIterator(start, end, option, 'number', 0, 1); - } -}); - -var InternalStateModule$5 = internalState; -var createIteratorConstructor$2 = createIteratorConstructor$7; -var has$3 = has$o; -var objectKeys = objectKeys$5; -var toObject$3 = toObject$u; - -var OBJECT_ITERATOR = 'Object Iterator'; -var setInternalState$5 = InternalStateModule$5.set; -var getInternalState$5 = InternalStateModule$5.getterFor(OBJECT_ITERATOR); - -var objectIterator = createIteratorConstructor$2(function ObjectIterator(source, mode) { - var object = toObject$3(source); - setInternalState$5(this, { - type: OBJECT_ITERATOR, - mode: mode, - object: object, - keys: objectKeys(object), - index: 0 - }); -}, 'Object', function next() { - var state = getInternalState$5(this); - var keys = state.keys; - while (true) { - if (keys === null || state.index >= keys.length) { - state.object = state.keys = null; - return { value: undefined, done: true }; - } - var key = keys[state.index++]; - var object = state.object; - if (!has$3(object, key)) continue; - switch (state.mode) { - case 'keys': return { value: key, done: false }; - case 'values': return { value: object[key], done: false }; - } /* entries */ return { value: [key, object[key]], done: false }; - } -}); - -var $$P = _export; -var ObjectIterator$2 = objectIterator; - -// `Object.iterateEntries` method -// https://github.com/tc39/proposal-object-iteration -$$P({ target: 'Object', stat: true }, { - iterateEntries: function iterateEntries(object) { - return new ObjectIterator$2(object, 'entries'); - } -}); - -var $$O = _export; -var ObjectIterator$1 = objectIterator; - -// `Object.iterateKeys` method -// https://github.com/tc39/proposal-object-iteration -$$O({ target: 'Object', stat: true }, { - iterateKeys: function iterateKeys(object) { - return new ObjectIterator$1(object, 'keys'); - } -}); - -var $$N = _export; -var ObjectIterator = objectIterator; - -// `Object.iterateValues` method -// https://github.com/tc39/proposal-object-iteration -$$N({ target: 'Object', stat: true }, { - iterateValues: function iterateValues(object) { - return new ObjectIterator(object, 'values'); - } -}); - -// https://github.com/tc39/proposal-observable -var $$M = _export; -var DESCRIPTORS = descriptors; -var setSpecies = setSpecies$7; -var aFunction$n = aFunction$R; -var anObject$y = anObject$1z; -var isObject = isObject$B; -var anInstance$2 = anInstance$b; -var defineProperty = objectDefineProperty.f; -var createNonEnumerableProperty$7 = createNonEnumerableProperty$m; -var redefineAll$2 = redefineAll$9; -var getIterator$1 = getIterator$3; -var iterate$d = iterate$I; -var hostReportErrors = hostReportErrors$2; -var wellKnownSymbol$7 = wellKnownSymbol$C; -var InternalStateModule$4 = internalState; - -var OBSERVABLE = wellKnownSymbol$7('observable'); -var getInternalState$4 = InternalStateModule$4.get; -var setInternalState$4 = InternalStateModule$4.set; - -var getMethod = function (fn) { - return fn == null ? undefined : aFunction$n(fn); -}; - -var cleanupSubscription = function (subscriptionState) { - var cleanup = subscriptionState.cleanup; - if (cleanup) { - subscriptionState.cleanup = undefined; - try { - cleanup(); - } catch (error) { - hostReportErrors(error); - } - } -}; - -var subscriptionClosed = function (subscriptionState) { - return subscriptionState.observer === undefined; -}; - -var close = function (subscription, subscriptionState) { - if (!DESCRIPTORS) { - subscription.closed = true; - var subscriptionObserver = subscriptionState.subscriptionObserver; - if (subscriptionObserver) subscriptionObserver.closed = true; - } subscriptionState.observer = undefined; -}; - -var Subscription = function (observer, subscriber) { - var subscriptionState = setInternalState$4(this, { - cleanup: undefined, - observer: anObject$y(observer), - subscriptionObserver: undefined - }); - var start; - if (!DESCRIPTORS) this.closed = false; - try { - if (start = getMethod(observer.start)) start.call(observer, this); - } catch (error) { - hostReportErrors(error); - } - if (subscriptionClosed(subscriptionState)) return; - var subscriptionObserver = subscriptionState.subscriptionObserver = new SubscriptionObserver(this); - try { - var cleanup = subscriber(subscriptionObserver); - var subscription = cleanup; - if (cleanup != null) subscriptionState.cleanup = typeof cleanup.unsubscribe === 'function' - ? function () { subscription.unsubscribe(); } - : aFunction$n(cleanup); - } catch (error) { - subscriptionObserver.error(error); - return; - } if (subscriptionClosed(subscriptionState)) cleanupSubscription(subscriptionState); -}; - -Subscription.prototype = redefineAll$2({}, { - unsubscribe: function unsubscribe() { - var subscriptionState = getInternalState$4(this); - if (!subscriptionClosed(subscriptionState)) { - close(this, subscriptionState); - cleanupSubscription(subscriptionState); - } - } -}); - -if (DESCRIPTORS) defineProperty(Subscription.prototype, 'closed', { - configurable: true, - get: function () { - return subscriptionClosed(getInternalState$4(this)); - } -}); - -var SubscriptionObserver = function (subscription) { - setInternalState$4(this, { subscription: subscription }); - if (!DESCRIPTORS) this.closed = false; -}; - -SubscriptionObserver.prototype = redefineAll$2({}, { - next: function next(value) { - var subscriptionState = getInternalState$4(getInternalState$4(this).subscription); - if (!subscriptionClosed(subscriptionState)) { - var observer = subscriptionState.observer; - try { - var nextMethod = getMethod(observer.next); - if (nextMethod) nextMethod.call(observer, value); - } catch (error) { - hostReportErrors(error); - } - } - }, - error: function error(value) { - var subscription = getInternalState$4(this).subscription; - var subscriptionState = getInternalState$4(subscription); - if (!subscriptionClosed(subscriptionState)) { - var observer = subscriptionState.observer; - close(subscription, subscriptionState); - try { - var errorMethod = getMethod(observer.error); - if (errorMethod) errorMethod.call(observer, value); - else hostReportErrors(value); - } catch (err) { - hostReportErrors(err); - } cleanupSubscription(subscriptionState); - } - }, - complete: function complete() { - var subscription = getInternalState$4(this).subscription; - var subscriptionState = getInternalState$4(subscription); - if (!subscriptionClosed(subscriptionState)) { - var observer = subscriptionState.observer; - close(subscription, subscriptionState); - try { - var completeMethod = getMethod(observer.complete); - if (completeMethod) completeMethod.call(observer); - } catch (error) { - hostReportErrors(error); - } cleanupSubscription(subscriptionState); - } - } -}); - -if (DESCRIPTORS) defineProperty(SubscriptionObserver.prototype, 'closed', { - configurable: true, - get: function () { - return subscriptionClosed(getInternalState$4(getInternalState$4(this).subscription)); - } -}); - -var $Observable = function Observable(subscriber) { - anInstance$2(this, $Observable, 'Observable'); - setInternalState$4(this, { subscriber: aFunction$n(subscriber) }); -}; - -redefineAll$2($Observable.prototype, { - subscribe: function subscribe(observer) { - var length = arguments.length; - return new Subscription(typeof observer === 'function' ? { - next: observer, - error: length > 1 ? arguments[1] : undefined, - complete: length > 2 ? arguments[2] : undefined - } : isObject(observer) ? observer : {}, getInternalState$4(this).subscriber); - } -}); - -redefineAll$2($Observable, { - from: function from(x) { - var C = typeof this === 'function' ? this : $Observable; - var observableMethod = getMethod(anObject$y(x)[OBSERVABLE]); - if (observableMethod) { - var observable = anObject$y(observableMethod.call(x)); - return observable.constructor === C ? observable : new C(function (observer) { - return observable.subscribe(observer); - }); - } - var iterator = getIterator$1(x); - return new C(function (observer) { - iterate$d(iterator, function (it, stop) { - observer.next(it); - if (observer.closed) return stop(); - }, { IS_ITERATOR: true, INTERRUPTED: true }); - observer.complete(); - }); - }, - of: function of() { - var C = typeof this === 'function' ? this : $Observable; - var length = arguments.length; - var items = new Array(length); - var index = 0; - while (index < length) items[index] = arguments[index++]; - return new C(function (observer) { - for (var i = 0; i < length; i++) { - observer.next(items[i]); - if (observer.closed) return; - } observer.complete(); - }); - } -}); - -createNonEnumerableProperty$7($Observable.prototype, OBSERVABLE, function () { return this; }); - -$$M({ global: true }, { - Observable: $Observable -}); - -setSpecies('Observable'); - -var defineWellKnownSymbol$4 = defineWellKnownSymbol$j; - -// `Symbol.observable` well-known symbol -// https://github.com/tc39/proposal-observable -defineWellKnownSymbol$4('observable'); - -var defineWellKnownSymbol$3 = defineWellKnownSymbol$j; - -// `Symbol.patternMatch` well-known symbol -// https://github.com/tc39/proposal-pattern-matching -defineWellKnownSymbol$3('patternMatch'); - -var $$L = _export; -var newPromiseCapabilityModule = newPromiseCapability$2; -var perform = perform$4; - -// `Promise.try` method -// https://github.com/tc39/proposal-promise-try -$$L({ target: 'Promise', stat: true }, { - 'try': function (callbackfn) { - var promiseCapability = newPromiseCapabilityModule.f(this); - var result = perform(callbackfn); - (result.error ? promiseCapability.reject : promiseCapability.resolve)(result.value); - return promiseCapability.promise; - } -}); - -var $$K = _export; -var anObject$x = anObject$1z; -var numberIsFinite = numberIsFinite$2; -var createIteratorConstructor$1 = createIteratorConstructor$7; -var InternalStateModule$3 = internalState; - -var SEEDED_RANDOM = 'Seeded Random'; -var SEEDED_RANDOM_GENERATOR = SEEDED_RANDOM + ' Generator'; -var setInternalState$3 = InternalStateModule$3.set; -var getInternalState$3 = InternalStateModule$3.getterFor(SEEDED_RANDOM_GENERATOR); -var SEED_TYPE_ERROR = 'Math.seededPRNG() argument should have a "seed" field with a finite value.'; - -var $SeededRandomGenerator = createIteratorConstructor$1(function SeededRandomGenerator(seed) { - setInternalState$3(this, { - type: SEEDED_RANDOM_GENERATOR, - seed: seed % 2147483647 - }); -}, SEEDED_RANDOM, function next() { - var state = getInternalState$3(this); - var seed = state.seed = (state.seed * 1103515245 + 12345) % 2147483647; - return { value: (seed & 1073741823) / 1073741823, done: false }; -}); - -// `Math.seededPRNG` method -// https://github.com/tc39/proposal-seeded-random -// based on https://github.com/tc39/proposal-seeded-random/blob/78b8258835b57fc2100d076151ab506bc3202ae6/demo.html -$$K({ target: 'Math', stat: true, forced: true }, { - seededPRNG: function seededPRNG(it) { - var seed = anObject$x(it).seed; - if (!numberIsFinite(seed)) throw TypeError(SEED_TYPE_ERROR); - return new $SeededRandomGenerator(seed); - } -}); - -var $$J = _export; -var createIteratorConstructor = createIteratorConstructor$7; -var requireObjectCoercible = requireObjectCoercible$h; -var InternalStateModule$2 = internalState; -var StringMultibyteModule = stringMultibyte; - -var codeAt = StringMultibyteModule.codeAt; -var charAt = StringMultibyteModule.charAt; -var STRING_ITERATOR = 'String Iterator'; -var setInternalState$2 = InternalStateModule$2.set; -var getInternalState$2 = InternalStateModule$2.getterFor(STRING_ITERATOR); - -// TODO: unify with String#@@iterator -var $StringIterator = createIteratorConstructor(function StringIterator(string) { - setInternalState$2(this, { - type: STRING_ITERATOR, - string: string, - index: 0 - }); -}, 'String', function next() { - var state = getInternalState$2(this); - var string = state.string; - var index = state.index; - var point; - if (index >= string.length) return { value: undefined, done: true }; - point = charAt(string, index); - state.index += point.length; - return { value: { codePoint: codeAt(point, 0), position: index }, done: false }; -}); - -// `String.prototype.codePoints` method -// https://github.com/tc39/proposal-string-prototype-codepoints -$$J({ target: 'String', proto: true }, { - codePoints: function codePoints() { - return new $StringIterator(String(requireObjectCoercible(this))); - } -}); - -var $$I = _export; -var isArray = isArray$8; - -var isFrozen = Object.isFrozen; - -var isFrozenStringArray = function (array, allowUndefined) { - if (!isFrozen || !isArray(array) || !isFrozen(array)) return false; - var index = 0; - var length = array.length; - var element; - while (index < length) { - element = array[index++]; - if (!(typeof element === 'string' || (allowUndefined && typeof element === 'undefined'))) { - return false; - } - } return length !== 0; -}; - -// `Array.isTemplateObject` method -// https://github.com/tc39/proposal-array-is-template-object -$$I({ target: 'Array', stat: true }, { - isTemplateObject: function isTemplateObject(value) { - if (!isFrozenStringArray(value, true)) return false; - var raw = value.raw; - if (raw.length !== value.length || !isFrozenStringArray(raw, false)) return false; - return true; - } -}); - -var global$7 = global$L; -var shared = sharedStore; -var getPrototypeOf = objectGetPrototypeOf$1; -var has$2 = has$o; -var createNonEnumerableProperty$6 = createNonEnumerableProperty$m; -var wellKnownSymbol$6 = wellKnownSymbol$C; - -var USE_FUNCTION_CONSTRUCTOR = 'USE_FUNCTION_CONSTRUCTOR'; -var ASYNC_ITERATOR$1 = wellKnownSymbol$6('asyncIterator'); -var AsyncIterator$1 = global$7.AsyncIterator; -var PassedAsyncIteratorPrototype = shared.AsyncIteratorPrototype; -var AsyncIteratorPrototype$1, prototype; - -{ - if (PassedAsyncIteratorPrototype) { - AsyncIteratorPrototype$1 = PassedAsyncIteratorPrototype; - } else if (typeof AsyncIterator$1 == 'function') { - AsyncIteratorPrototype$1 = AsyncIterator$1.prototype; - } else if (shared[USE_FUNCTION_CONSTRUCTOR] || global$7[USE_FUNCTION_CONSTRUCTOR]) { - try { - // eslint-disable-next-line no-new-func - prototype = getPrototypeOf(getPrototypeOf(getPrototypeOf(Function('return async function*(){}()')()))); - if (getPrototypeOf(prototype) === Object.prototype) AsyncIteratorPrototype$1 = prototype; - } catch (error) { /* empty */ } - } -} - -if (!AsyncIteratorPrototype$1) AsyncIteratorPrototype$1 = {}; - -if (!has$2(AsyncIteratorPrototype$1, ASYNC_ITERATOR$1)) { - createNonEnumerableProperty$6(AsyncIteratorPrototype$1, ASYNC_ITERATOR$1, function () { - return this; - }); -} - -var asyncIteratorPrototype = AsyncIteratorPrototype$1; - -// https://github.com/tc39/proposal-iterator-helpers -var $$H = _export; -var anInstance$1 = anInstance$b; -var createNonEnumerableProperty$5 = createNonEnumerableProperty$m; -var has$1 = has$o; -var wellKnownSymbol$5 = wellKnownSymbol$C; -var AsyncIteratorPrototype = asyncIteratorPrototype; -var IS_PURE$c = isPure; - -var TO_STRING_TAG$4 = wellKnownSymbol$5('toStringTag'); - -var AsyncIteratorConstructor = function AsyncIterator() { - anInstance$1(this, AsyncIteratorConstructor); -}; - -AsyncIteratorConstructor.prototype = AsyncIteratorPrototype; - -if (!has$1(AsyncIteratorPrototype, TO_STRING_TAG$4)) { - createNonEnumerableProperty$5(AsyncIteratorPrototype, TO_STRING_TAG$4, 'AsyncIterator'); -} - -if (!has$1(AsyncIteratorPrototype, 'constructor') || AsyncIteratorPrototype.constructor === Object) { - createNonEnumerableProperty$5(AsyncIteratorPrototype, 'constructor', AsyncIteratorConstructor); -} - -$$H({ global: true, forced: IS_PURE$c }, { - AsyncIterator: AsyncIteratorConstructor -}); - -var path$3 = path$6; -var aFunction$m = aFunction$R; -var anObject$w = anObject$1z; -var create$1 = objectCreate; -var createNonEnumerableProperty$4 = createNonEnumerableProperty$m; -var redefineAll$1 = redefineAll$9; -var wellKnownSymbol$4 = wellKnownSymbol$C; -var InternalStateModule$1 = internalState; -var getBuiltIn$7 = getBuiltIn$t; - -var Promise$3 = getBuiltIn$7('Promise'); - -var setInternalState$1 = InternalStateModule$1.set; -var getInternalState$1 = InternalStateModule$1.get; - -var TO_STRING_TAG$3 = wellKnownSymbol$4('toStringTag'); - -var $return$1 = function (value) { - var iterator = getInternalState$1(this).iterator; - var $$return = iterator['return']; - return $$return === undefined - ? Promise$3.resolve({ done: true, value: value }) - : anObject$w($$return.call(iterator, value)); -}; - -var $throw$1 = function (value) { - var iterator = getInternalState$1(this).iterator; - var $$throw = iterator['throw']; - return $$throw === undefined - ? Promise$3.reject(value) - : $$throw.call(iterator, value); -}; - -var asyncIteratorCreateProxy = function (nextHandler, IS_ITERATOR) { - var AsyncIteratorProxy = function AsyncIterator(state) { - state.next = aFunction$m(state.iterator.next); - state.done = false; - setInternalState$1(this, state); - }; - - AsyncIteratorProxy.prototype = redefineAll$1(create$1(path$3.AsyncIterator.prototype), { - next: function next(arg) { - var state = getInternalState$1(this); - if (state.done) return Promise$3.resolve({ done: true, value: undefined }); - try { - return Promise$3.resolve(anObject$w(nextHandler.call(state, arg, Promise$3))); - } catch (error) { - return Promise$3.reject(error); - } - }, - 'return': $return$1, - 'throw': $throw$1 - }); - - if (!IS_ITERATOR) { - createNonEnumerableProperty$4(AsyncIteratorProxy.prototype, TO_STRING_TAG$3, 'Generator'); - } - - return AsyncIteratorProxy; -}; - -// https://github.com/tc39/proposal-iterator-helpers -var $$G = _export; -var anObject$v = anObject$1z; -var createAsyncIteratorProxy$6 = asyncIteratorCreateProxy; - -var AsyncIteratorProxy$6 = createAsyncIteratorProxy$6(function (arg, Promise) { - var state = this; - var iterator = state.iterator; - - return Promise.resolve(anObject$v(state.next.call(iterator, arg))).then(function (step) { - if (anObject$v(step).done) { - state.done = true; - return { done: true, value: undefined }; - } - return { done: false, value: [state.index++, step.value] }; - }); -}); - -$$G({ target: 'AsyncIterator', proto: true, real: true }, { - asIndexedPairs: function asIndexedPairs() { - return new AsyncIteratorProxy$6({ - iterator: anObject$v(this), - index: 0 - }); - } -}); - -// https://github.com/tc39/proposal-iterator-helpers -var $$F = _export; -var anObject$u = anObject$1z; -var toPositiveInteger$3 = toPositiveInteger$5; -var createAsyncIteratorProxy$5 = asyncIteratorCreateProxy; - -var AsyncIteratorProxy$5 = createAsyncIteratorProxy$5(function (arg, Promise) { - var state = this; - - return new Promise(function (resolve, reject) { - var loop = function () { - try { - Promise.resolve( - anObject$u(state.next.call(state.iterator, state.remaining ? undefined : arg)) - ).then(function (step) { - try { - if (anObject$u(step).done) { - state.done = true; - resolve({ done: true, value: undefined }); - } else if (state.remaining) { - state.remaining--; - loop(); - } else resolve({ done: false, value: step.value }); - } catch (err) { reject(err); } - }, reject); - } catch (error) { reject(error); } - }; - - loop(); - }); -}); - -$$F({ target: 'AsyncIterator', proto: true, real: true }, { - drop: function drop(limit) { - return new AsyncIteratorProxy$5({ - iterator: anObject$u(this), - remaining: toPositiveInteger$3(limit) - }); - } -}); - -// https://github.com/tc39/proposal-iterator-helpers -var aFunction$l = aFunction$R; -var anObject$t = anObject$1z; -var getBuiltIn$6 = getBuiltIn$t; - -var Promise$2 = getBuiltIn$6('Promise'); -var push$1 = [].push; - -var createMethod = function (TYPE) { - var IS_TO_ARRAY = TYPE == 0; - var IS_FOR_EACH = TYPE == 1; - var IS_EVERY = TYPE == 2; - var IS_SOME = TYPE == 3; - return function (iterator, fn) { - anObject$t(iterator); - var next = aFunction$l(iterator.next); - var array = IS_TO_ARRAY ? [] : undefined; - if (!IS_TO_ARRAY) aFunction$l(fn); - - return new Promise$2(function (resolve, reject) { - var closeIteration = function (method, argument) { - try { - var returnMethod = iterator['return']; - if (returnMethod !== undefined) { - return Promise$2.resolve(returnMethod.call(iterator)).then(function () { - method(argument); - }, function (error) { - reject(error); - }); - } - } catch (error2) { - return reject(error2); - } method(argument); - }; - - var onError = function (error) { - closeIteration(reject, error); - }; - - var loop = function () { - try { - Promise$2.resolve(anObject$t(next.call(iterator))).then(function (step) { - try { - if (anObject$t(step).done) { - resolve(IS_TO_ARRAY ? array : IS_SOME ? false : IS_EVERY || undefined); - } else { - var value = step.value; - if (IS_TO_ARRAY) { - push$1.call(array, value); - loop(); - } else { - Promise$2.resolve(fn(value)).then(function (result) { - if (IS_FOR_EACH) { - loop(); - } else if (IS_EVERY) { - result ? loop() : closeIteration(resolve, false); - } else { - result ? closeIteration(resolve, IS_SOME || value) : loop(); - } - }, onError); - } - } - } catch (error) { onError(error); } - }, onError); - } catch (error2) { onError(error2); } - }; - - loop(); - }); - }; -}; - -var asyncIteratorIteration = { - toArray: createMethod(0), - forEach: createMethod(1), - every: createMethod(2), - some: createMethod(3), - find: createMethod(4) -}; - -// https://github.com/tc39/proposal-iterator-helpers -var $$E = _export; -var $every = asyncIteratorIteration.every; - -$$E({ target: 'AsyncIterator', proto: true, real: true }, { - every: function every(fn) { - return $every(this, fn); - } -}); - -// https://github.com/tc39/proposal-iterator-helpers -var $$D = _export; -var aFunction$k = aFunction$R; -var anObject$s = anObject$1z; -var createAsyncIteratorProxy$4 = asyncIteratorCreateProxy; - -var AsyncIteratorProxy$4 = createAsyncIteratorProxy$4(function (arg, Promise) { - var state = this; - var filterer = state.filterer; - - return new Promise(function (resolve, reject) { - var loop = function () { - try { - Promise.resolve(anObject$s(state.next.call(state.iterator, arg))).then(function (step) { - try { - if (anObject$s(step).done) { - state.done = true; - resolve({ done: true, value: undefined }); - } else { - var value = step.value; - Promise.resolve(filterer(value)).then(function (selected) { - selected ? resolve({ done: false, value: value }) : loop(); - }, reject); - } - } catch (err) { reject(err); } - }, reject); - } catch (error) { reject(error); } - }; - - loop(); - }); -}); - -$$D({ target: 'AsyncIterator', proto: true, real: true }, { - filter: function filter(filterer) { - return new AsyncIteratorProxy$4({ - iterator: anObject$s(this), - filterer: aFunction$k(filterer) - }); - } -}); - -// https://github.com/tc39/proposal-iterator-helpers -var $$C = _export; -var $find = asyncIteratorIteration.find; - -$$C({ target: 'AsyncIterator', proto: true, real: true }, { - find: function find(fn) { - return $find(this, fn); - } -}); - -var getIteratorMethod$2 = getIteratorMethod$8; -var wellKnownSymbol$3 = wellKnownSymbol$C; - -var ASYNC_ITERATOR = wellKnownSymbol$3('asyncIterator'); - -var getAsyncIteratorMethod$2 = function (it) { - var method = it[ASYNC_ITERATOR]; - return method === undefined ? getIteratorMethod$2(it) : method; -}; - -// https://github.com/tc39/proposal-iterator-helpers -var $$B = _export; -var aFunction$j = aFunction$R; -var anObject$r = anObject$1z; -var createAsyncIteratorProxy$3 = asyncIteratorCreateProxy; -var getAsyncIteratorMethod$1 = getAsyncIteratorMethod$2; - -var AsyncIteratorProxy$3 = createAsyncIteratorProxy$3(function (arg, Promise) { - var state = this; - var mapper = state.mapper; - var innerIterator, iteratorMethod; - - return new Promise(function (resolve, reject) { - var outerLoop = function () { - try { - Promise.resolve(anObject$r(state.next.call(state.iterator, arg))).then(function (step) { - try { - if (anObject$r(step).done) { - state.done = true; - resolve({ done: true, value: undefined }); - } else { - Promise.resolve(mapper(step.value)).then(function (mapped) { - try { - iteratorMethod = getAsyncIteratorMethod$1(mapped); - if (iteratorMethod !== undefined) { - state.innerIterator = innerIterator = anObject$r(iteratorMethod.call(mapped)); - state.innerNext = aFunction$j(innerIterator.next); - return innerLoop(); - } reject(TypeError('.flatMap callback should return an iterable object')); - } catch (error2) { reject(error2); } - }, reject); - } - } catch (error1) { reject(error1); } - }, reject); - } catch (error) { reject(error); } - }; - - var innerLoop = function () { - if (innerIterator = state.innerIterator) { - try { - Promise.resolve(anObject$r(state.innerNext.call(innerIterator))).then(function (result) { - try { - if (anObject$r(result).done) { - state.innerIterator = state.innerNext = null; - outerLoop(); - } else resolve({ done: false, value: result.value }); - } catch (error1) { reject(error1); } - }, reject); - } catch (error) { reject(error); } - } else outerLoop(); - }; - - innerLoop(); - }); -}); - -$$B({ target: 'AsyncIterator', proto: true, real: true }, { - flatMap: function flatMap(mapper) { - return new AsyncIteratorProxy$3({ - iterator: anObject$r(this), - mapper: aFunction$j(mapper), - innerIterator: null, - innerNext: null - }); - } -}); - -// https://github.com/tc39/proposal-iterator-helpers -var $$A = _export; -var $forEach = asyncIteratorIteration.forEach; - -$$A({ target: 'AsyncIterator', proto: true, real: true }, { - forEach: function forEach(fn) { - return $forEach(this, fn); - } -}); - -// https://github.com/tc39/proposal-iterator-helpers -var $$z = _export; -var path$2 = path$6; -var aFunction$i = aFunction$R; -var anObject$q = anObject$1z; -var toObject$2 = toObject$u; -var createAsyncIteratorProxy$2 = asyncIteratorCreateProxy; -var getAsyncIteratorMethod = getAsyncIteratorMethod$2; - -var AsyncIterator = path$2.AsyncIterator; - -var AsyncIteratorProxy$2 = createAsyncIteratorProxy$2(function (arg) { - return anObject$q(this.next.call(this.iterator, arg)); -}, true); - -$$z({ target: 'AsyncIterator', stat: true }, { - from: function from(O) { - var object = toObject$2(O); - var usingIterator = getAsyncIteratorMethod(object); - var iterator; - if (usingIterator != null) { - iterator = aFunction$i(usingIterator).call(object); - if (iterator instanceof AsyncIterator) return iterator; - } else { - iterator = object; - } return new AsyncIteratorProxy$2({ - iterator: iterator - }); - } -}); - -// https://github.com/tc39/proposal-iterator-helpers -var $$y = _export; -var aFunction$h = aFunction$R; -var anObject$p = anObject$1z; -var createAsyncIteratorProxy$1 = asyncIteratorCreateProxy; - -var AsyncIteratorProxy$1 = createAsyncIteratorProxy$1(function (arg, Promise) { - var state = this; - var mapper = state.mapper; - - return Promise.resolve(anObject$p(state.next.call(state.iterator, arg))).then(function (step) { - if (anObject$p(step).done) { - state.done = true; - return { done: true, value: undefined }; - } - return Promise.resolve(mapper(step.value)).then(function (value) { - return { done: false, value: value }; - }); - }); -}); - -$$y({ target: 'AsyncIterator', proto: true, real: true }, { - map: function map(mapper) { - return new AsyncIteratorProxy$1({ - iterator: anObject$p(this), - mapper: aFunction$h(mapper) - }); - } -}); - -// https://github.com/tc39/proposal-iterator-helpers -var $$x = _export; -var aFunction$g = aFunction$R; -var anObject$o = anObject$1z; -var getBuiltIn$5 = getBuiltIn$t; - -var Promise$1 = getBuiltIn$5('Promise'); - -$$x({ target: 'AsyncIterator', proto: true, real: true }, { - reduce: function reduce(reducer /* , initialValue */) { - var iterator = anObject$o(this); - var next = aFunction$g(iterator.next); - var noInitial = arguments.length < 2; - var accumulator = noInitial ? undefined : arguments[1]; - aFunction$g(reducer); - - return new Promise$1(function (resolve, reject) { - var loop = function () { - try { - Promise$1.resolve(anObject$o(next.call(iterator))).then(function (step) { - try { - if (anObject$o(step).done) { - noInitial ? reject(TypeError('Reduce of empty iterator with no initial value')) : resolve(accumulator); - } else { - var value = step.value; - if (noInitial) { - noInitial = false; - accumulator = value; - loop(); - } else { - Promise$1.resolve(reducer(accumulator, value)).then(function (result) { - accumulator = result; - loop(); - }, reject); - } - } - } catch (err) { reject(err); } - }, reject); - } catch (error) { reject(error); } - }; - - loop(); - }); - } -}); - -// https://github.com/tc39/proposal-iterator-helpers -var $$w = _export; -var $some = asyncIteratorIteration.some; - -$$w({ target: 'AsyncIterator', proto: true, real: true }, { - some: function some(fn) { - return $some(this, fn); - } -}); - -// https://github.com/tc39/proposal-iterator-helpers -var $$v = _export; -var anObject$n = anObject$1z; -var toPositiveInteger$2 = toPositiveInteger$5; -var createAsyncIteratorProxy = asyncIteratorCreateProxy; - -var AsyncIteratorProxy = createAsyncIteratorProxy(function (arg, Promise) { - var iterator = this.iterator; - var returnMethod, result; - if (!this.remaining--) { - result = { done: true, value: undefined }; - this.done = true; - returnMethod = iterator['return']; - if (returnMethod !== undefined) { - return Promise.resolve(returnMethod.call(iterator)).then(function () { - return result; - }); - } - return result; - } return this.next.call(iterator, arg); -}); - -$$v({ target: 'AsyncIterator', proto: true, real: true }, { - take: function take(limit) { - return new AsyncIteratorProxy({ - iterator: anObject$n(this), - remaining: toPositiveInteger$2(limit) - }); - } -}); - -// https://github.com/tc39/proposal-iterator-helpers -var $$u = _export; -var $toArray = asyncIteratorIteration.toArray; - -$$u({ target: 'AsyncIterator', proto: true, real: true }, { - toArray: function toArray() { - return $toArray(this); - } -}); - -// https://github.com/tc39/proposal-iterator-helpers -var $$t = _export; -var global$6 = global$L; -var anInstance = anInstance$b; -var createNonEnumerableProperty$3 = createNonEnumerableProperty$m; -var fails = fails$Y; -var has = has$o; -var wellKnownSymbol$2 = wellKnownSymbol$C; -var IteratorPrototype = iteratorsCore.IteratorPrototype; - -wellKnownSymbol$2('iterator'); -var TO_STRING_TAG$2 = wellKnownSymbol$2('toStringTag'); - -var NativeIterator = global$6.Iterator; - -// FF56- have non-standard global helper `Iterator` -var FORCED$1 = typeof NativeIterator != 'function' - || NativeIterator.prototype !== IteratorPrototype - // FF44- non-standard `Iterator` passes previous tests - || !fails(function () { NativeIterator({}); }); - -var IteratorConstructor = function Iterator() { - anInstance(this, IteratorConstructor); -}; - -if (!has(IteratorPrototype, TO_STRING_TAG$2)) { - createNonEnumerableProperty$3(IteratorPrototype, TO_STRING_TAG$2, 'Iterator'); -} - -if (FORCED$1 || !has(IteratorPrototype, 'constructor') || IteratorPrototype.constructor === Object) { - createNonEnumerableProperty$3(IteratorPrototype, 'constructor', IteratorConstructor); -} - -IteratorConstructor.prototype = IteratorPrototype; - -$$t({ global: true, forced: FORCED$1 }, { - Iterator: IteratorConstructor -}); - -var path$1 = path$6; -var aFunction$f = aFunction$R; -var anObject$m = anObject$1z; -var create = objectCreate; -var createNonEnumerableProperty$2 = createNonEnumerableProperty$m; -var redefineAll = redefineAll$9; -var wellKnownSymbol$1 = wellKnownSymbol$C; -var InternalStateModule = internalState; - -var setInternalState = InternalStateModule.set; -var getInternalState = InternalStateModule.get; - -var TO_STRING_TAG$1 = wellKnownSymbol$1('toStringTag'); - -var $return = function (value) { - var iterator = getInternalState(this).iterator; - var $$return = iterator['return']; - return $$return === undefined ? { done: true, value: value } : anObject$m($$return.call(iterator, value)); -}; - -var $throw = function (value) { - var iterator = getInternalState(this).iterator; - var $$throw = iterator['throw']; - if ($$throw === undefined) throw value; - return $$throw.call(iterator, value); -}; - -var iteratorCreateProxy = function (nextHandler, IS_ITERATOR) { - var IteratorProxy = function Iterator(state) { - state.next = aFunction$f(state.iterator.next); - state.done = false; - setInternalState(this, state); - }; - - IteratorProxy.prototype = redefineAll(create(path$1.Iterator.prototype), { - next: function next() { - var state = getInternalState(this); - var result = state.done ? undefined : nextHandler.apply(state, arguments); - return { done: state.done, value: result }; - }, - 'return': $return, - 'throw': $throw - }); - - if (!IS_ITERATOR) { - createNonEnumerableProperty$2(IteratorProxy.prototype, TO_STRING_TAG$1, 'Generator'); - } - - return IteratorProxy; -}; - -// https://github.com/tc39/proposal-iterator-helpers -var $$s = _export; -var anObject$l = anObject$1z; -var createIteratorProxy$6 = iteratorCreateProxy; - -var IteratorProxy$6 = createIteratorProxy$6(function (arg) { - var result = anObject$l(this.next.call(this.iterator, arg)); - var done = this.done = !!result.done; - if (!done) return [this.index++, result.value]; -}); - -$$s({ target: 'Iterator', proto: true, real: true }, { - asIndexedPairs: function asIndexedPairs() { - return new IteratorProxy$6({ - iterator: anObject$l(this), - index: 0 - }); - } -}); - -// https://github.com/tc39/proposal-iterator-helpers -var $$r = _export; -var anObject$k = anObject$1z; -var toPositiveInteger$1 = toPositiveInteger$5; -var createIteratorProxy$5 = iteratorCreateProxy; - -var IteratorProxy$5 = createIteratorProxy$5(function (arg) { - var iterator = this.iterator; - var next = this.next; - var result, done; - while (this.remaining) { - this.remaining--; - result = anObject$k(next.call(iterator)); - done = this.done = !!result.done; - if (done) return; - } - result = anObject$k(next.call(iterator, arg)); - done = this.done = !!result.done; - if (!done) return result.value; -}); - -$$r({ target: 'Iterator', proto: true, real: true }, { - drop: function drop(limit) { - return new IteratorProxy$5({ - iterator: anObject$k(this), - remaining: toPositiveInteger$1(limit) - }); - } -}); - -// https://github.com/tc39/proposal-iterator-helpers -var $$q = _export; -var iterate$c = iterate$I; -var aFunction$e = aFunction$R; -var anObject$j = anObject$1z; - -$$q({ target: 'Iterator', proto: true, real: true }, { - every: function every(fn) { - anObject$j(this); - aFunction$e(fn); - return !iterate$c(this, function (value, stop) { - if (!fn(value)) return stop(); - }, { IS_ITERATOR: true, INTERRUPTED: true }).stopped; - } -}); - -// https://github.com/tc39/proposal-iterator-helpers -var $$p = _export; -var aFunction$d = aFunction$R; -var anObject$i = anObject$1z; -var createIteratorProxy$4 = iteratorCreateProxy; -var callWithSafeIterationClosing$1 = callWithSafeIterationClosing$3; - -var IteratorProxy$4 = createIteratorProxy$4(function (arg) { - var iterator = this.iterator; - var filterer = this.filterer; - var next = this.next; - var result, done, value; - while (true) { - result = anObject$i(next.call(iterator, arg)); - done = this.done = !!result.done; - if (done) return; - value = result.value; - if (callWithSafeIterationClosing$1(iterator, filterer, value)) return value; - } -}); - -$$p({ target: 'Iterator', proto: true, real: true }, { - filter: function filter(filterer) { - return new IteratorProxy$4({ - iterator: anObject$i(this), - filterer: aFunction$d(filterer) - }); - } -}); - -// https://github.com/tc39/proposal-iterator-helpers -var $$o = _export; -var iterate$b = iterate$I; -var aFunction$c = aFunction$R; -var anObject$h = anObject$1z; - -$$o({ target: 'Iterator', proto: true, real: true }, { - find: function find(fn) { - anObject$h(this); - aFunction$c(fn); - return iterate$b(this, function (value, stop) { - if (fn(value)) return stop(value); - }, { IS_ITERATOR: true, INTERRUPTED: true }).result; - } -}); - -// https://github.com/tc39/proposal-iterator-helpers -var $$n = _export; -var aFunction$b = aFunction$R; -var anObject$g = anObject$1z; -var getIteratorMethod$1 = getIteratorMethod$8; -var createIteratorProxy$3 = iteratorCreateProxy; -var iteratorClose$1 = iteratorClose$4; - -var IteratorProxy$3 = createIteratorProxy$3(function (arg) { - var iterator = this.iterator; - var mapper = this.mapper; - var result, mapped, iteratorMethod, innerIterator; - - while (true) { - try { - if (innerIterator = this.innerIterator) { - result = anObject$g(this.innerNext.call(innerIterator)); - if (!result.done) return result.value; - this.innerIterator = this.innerNext = null; - } - - result = anObject$g(this.next.call(iterator, arg)); - - if (this.done = !!result.done) return; - - mapped = mapper(result.value); - iteratorMethod = getIteratorMethod$1(mapped); - - if (iteratorMethod === undefined) { - throw TypeError('.flatMap callback should return an iterable object'); - } - - this.innerIterator = innerIterator = anObject$g(iteratorMethod.call(mapped)); - this.innerNext = aFunction$b(innerIterator.next); - } catch (error) { - iteratorClose$1(iterator); - throw error; - } - } -}); - -$$n({ target: 'Iterator', proto: true, real: true }, { - flatMap: function flatMap(mapper) { - return new IteratorProxy$3({ - iterator: anObject$g(this), - mapper: aFunction$b(mapper), - innerIterator: null, - innerNext: null - }); - } -}); - -// https://github.com/tc39/proposal-iterator-helpers -var $$m = _export; -var iterate$a = iterate$I; -var anObject$f = anObject$1z; - -$$m({ target: 'Iterator', proto: true, real: true }, { - forEach: function forEach(fn) { - iterate$a(anObject$f(this), fn, { IS_ITERATOR: true }); - } -}); - -// https://github.com/tc39/proposal-iterator-helpers -var $$l = _export; -var path = path$6; -var aFunction$a = aFunction$R; -var anObject$e = anObject$1z; -var toObject$1 = toObject$u; -var createIteratorProxy$2 = iteratorCreateProxy; -var getIteratorMethod = getIteratorMethod$8; - -var Iterator = path.Iterator; - -var IteratorProxy$2 = createIteratorProxy$2(function (arg) { - var result = anObject$e(this.next.call(this.iterator, arg)); - var done = this.done = !!result.done; - if (!done) return result.value; -}, true); - -$$l({ target: 'Iterator', stat: true }, { - from: function from(O) { - var object = toObject$1(O); - var usingIterator = getIteratorMethod(object); - var iterator; - if (usingIterator != null) { - iterator = aFunction$a(usingIterator).call(object); - if (iterator instanceof Iterator) return iterator; - } else { - iterator = object; - } return new IteratorProxy$2({ - iterator: iterator - }); - } -}); - -// https://github.com/tc39/proposal-iterator-helpers -var $$k = _export; -var aFunction$9 = aFunction$R; -var anObject$d = anObject$1z; -var createIteratorProxy$1 = iteratorCreateProxy; -var callWithSafeIterationClosing = callWithSafeIterationClosing$3; - -var IteratorProxy$1 = createIteratorProxy$1(function (arg) { - var iterator = this.iterator; - var result = anObject$d(this.next.call(iterator, arg)); - var done = this.done = !!result.done; - if (!done) return callWithSafeIterationClosing(iterator, this.mapper, result.value); -}); - -$$k({ target: 'Iterator', proto: true, real: true }, { - map: function map(mapper) { - return new IteratorProxy$1({ - iterator: anObject$d(this), - mapper: aFunction$9(mapper) - }); - } -}); - -// https://github.com/tc39/proposal-iterator-helpers -var $$j = _export; -var iterate$9 = iterate$I; -var aFunction$8 = aFunction$R; -var anObject$c = anObject$1z; - -$$j({ target: 'Iterator', proto: true, real: true }, { - reduce: function reduce(reducer /* , initialValue */) { - anObject$c(this); - aFunction$8(reducer); - var noInitial = arguments.length < 2; - var accumulator = noInitial ? undefined : arguments[1]; - iterate$9(this, function (value) { - if (noInitial) { - noInitial = false; - accumulator = value; - } else { - accumulator = reducer(accumulator, value); - } - }, { IS_ITERATOR: true }); - if (noInitial) throw TypeError('Reduce of empty iterator with no initial value'); - return accumulator; - } -}); - -// https://github.com/tc39/proposal-iterator-helpers -var $$i = _export; -var iterate$8 = iterate$I; -var aFunction$7 = aFunction$R; -var anObject$b = anObject$1z; - -$$i({ target: 'Iterator', proto: true, real: true }, { - some: function some(fn) { - anObject$b(this); - aFunction$7(fn); - return iterate$8(this, function (value, stop) { - if (fn(value)) return stop(); - }, { IS_ITERATOR: true, INTERRUPTED: true }).stopped; - } -}); - -// https://github.com/tc39/proposal-iterator-helpers -var $$h = _export; -var anObject$a = anObject$1z; -var toPositiveInteger = toPositiveInteger$5; -var createIteratorProxy = iteratorCreateProxy; -var iteratorClose = iteratorClose$4; - -var IteratorProxy = createIteratorProxy(function (arg) { - var iterator = this.iterator; - if (!this.remaining--) { - this.done = true; - return iteratorClose(iterator); - } - var result = anObject$a(this.next.call(iterator, arg)); - var done = this.done = !!result.done; - if (!done) return result.value; -}); - -$$h({ target: 'Iterator', proto: true, real: true }, { - take: function take(limit) { - return new IteratorProxy({ - iterator: anObject$a(this), - remaining: toPositiveInteger(limit) - }); - } -}); - -// https://github.com/tc39/proposal-iterator-helpers -var $$g = _export; -var iterate$7 = iterate$I; -var anObject$9 = anObject$1z; - -var push = [].push; - -$$g({ target: 'Iterator', proto: true, real: true }, { - toArray: function toArray() { - var result = []; - iterate$7(anObject$9(this), push, { that: result, IS_ITERATOR: true }); - return result; - } -}); - -var anObject$8 = anObject$1z; - -// `Map.prototype.emplace` method -// https://github.com/thumbsupep/proposal-upsert -var mapEmplace = function emplace(key, handler) { - var map = anObject$8(this); - var value = (map.has(key) && 'update' in handler) - ? handler.update(map.get(key), key, map) - : handler.insert(key, map); - map.set(key, value); - return value; -}; - -var $$f = _export; -var IS_PURE$b = isPure; -var $emplace$1 = mapEmplace; - -// `Map.prototype.emplace` method -// https://github.com/thumbsupep/proposal-upsert -$$f({ target: 'Map', proto: true, real: true, forced: IS_PURE$b }, { - emplace: $emplace$1 -}); - -var anObject$7 = anObject$1z; - -// `Map.prototype.upsert` method -// https://github.com/thumbsupep/proposal-upsert -var mapUpsert = function upsert(key, updateFn /* , insertFn */) { - var map = anObject$7(this); - var insertFn = arguments.length > 2 ? arguments[2] : undefined; - var value; - if (typeof updateFn != 'function' && typeof insertFn != 'function') { - throw TypeError('At least one callback required'); - } - if (map.has(key)) { - value = map.get(key); - if (typeof updateFn == 'function') { - value = updateFn(value); - map.set(key, value); - } - } else if (typeof insertFn == 'function') { - value = insertFn(); - map.set(key, value); - } return value; -}; - -// TODO: remove from `core-js@4` -var $$e = _export; -var IS_PURE$a = isPure; -var $upsert$2 = mapUpsert; - -// `Map.prototype.updateOrInsert` method (replaced by `Map.prototype.emplace`) -// https://github.com/thumbsupep/proposal-upsert -$$e({ target: 'Map', proto: true, real: true, forced: IS_PURE$a }, { - updateOrInsert: $upsert$2 -}); - -// TODO: remove from `core-js@4` -var $$d = _export; -var IS_PURE$9 = isPure; -var $upsert$1 = mapUpsert; - -// `Map.prototype.upsert` method (replaced by `Map.prototype.emplace`) -// https://github.com/thumbsupep/proposal-upsert -$$d({ target: 'Map', proto: true, real: true, forced: IS_PURE$9 }, { - upsert: $upsert$1 -}); - -var $$c = _export; -var IS_PURE$8 = isPure; -var $emplace = mapEmplace; - -// `WeakMap.prototype.emplace` method -// https://github.com/tc39/proposal-upsert -$$c({ target: 'WeakMap', proto: true, real: true, forced: IS_PURE$8 }, { - emplace: $emplace -}); - -// TODO: remove from `core-js@4` -var $$b = _export; -var IS_PURE$7 = isPure; -var $upsert = mapUpsert; - -// `WeakMap.prototype.upsert` method (replaced by `WeakMap.prototype.emplace`) -// https://github.com/tc39/proposal-upsert -$$b({ target: 'WeakMap', proto: true, real: true, forced: IS_PURE$7 }, { - upsert: $upsert -}); - -var $$a = _export; -var IS_PURE$6 = isPure; -var getBuiltIn$4 = getBuiltIn$t; -var anObject$6 = anObject$1z; -var aFunction$6 = aFunction$R; -var speciesConstructor$3 = speciesConstructor$j; -var iterate$6 = iterate$I; - -// `Set.prototype.difference` method -// https://github.com/tc39/proposal-set-methods -$$a({ target: 'Set', proto: true, real: true, forced: IS_PURE$6 }, { - difference: function difference(iterable) { - var set = anObject$6(this); - var newSet = new (speciesConstructor$3(set, getBuiltIn$4('Set')))(set); - var remover = aFunction$6(newSet['delete']); - iterate$6(iterable, function (value) { - remover.call(newSet, value); - }); - return newSet; - } -}); - -var $$9 = _export; -var IS_PURE$5 = isPure; -var getBuiltIn$3 = getBuiltIn$t; -var anObject$5 = anObject$1z; -var aFunction$5 = aFunction$R; -var speciesConstructor$2 = speciesConstructor$j; -var iterate$5 = iterate$I; - -// `Set.prototype.intersection` method -// https://github.com/tc39/proposal-set-methods -$$9({ target: 'Set', proto: true, real: true, forced: IS_PURE$5 }, { - intersection: function intersection(iterable) { - var set = anObject$5(this); - var newSet = new (speciesConstructor$2(set, getBuiltIn$3('Set')))(); - var hasCheck = aFunction$5(set.has); - var adder = aFunction$5(newSet.add); - iterate$5(iterable, function (value) { - if (hasCheck.call(set, value)) adder.call(newSet, value); - }); - return newSet; - } -}); - -var $$8 = _export; -var IS_PURE$4 = isPure; -var anObject$4 = anObject$1z; -var aFunction$4 = aFunction$R; -var iterate$4 = iterate$I; - -// `Set.prototype.isDisjointFrom` method -// https://tc39.github.io/proposal-set-methods/#Set.prototype.isDisjointFrom -$$8({ target: 'Set', proto: true, real: true, forced: IS_PURE$4 }, { - isDisjointFrom: function isDisjointFrom(iterable) { - var set = anObject$4(this); - var hasCheck = aFunction$4(set.has); - return !iterate$4(iterable, function (value, stop) { - if (hasCheck.call(set, value) === true) return stop(); - }, { INTERRUPTED: true }).stopped; - } -}); - -var $$7 = _export; -var IS_PURE$3 = isPure; -var getBuiltIn$2 = getBuiltIn$t; -var anObject$3 = anObject$1z; -var aFunction$3 = aFunction$R; -var getIterator = getIterator$3; -var iterate$3 = iterate$I; - -// `Set.prototype.isSubsetOf` method -// https://tc39.github.io/proposal-set-methods/#Set.prototype.isSubsetOf -$$7({ target: 'Set', proto: true, real: true, forced: IS_PURE$3 }, { - isSubsetOf: function isSubsetOf(iterable) { - var iterator = getIterator(this); - var otherSet = anObject$3(iterable); - var hasCheck = otherSet.has; - if (typeof hasCheck != 'function') { - otherSet = new (getBuiltIn$2('Set'))(iterable); - hasCheck = aFunction$3(otherSet.has); - } - return !iterate$3(iterator, function (value, stop) { - if (hasCheck.call(otherSet, value) === false) return stop(); - }, { IS_ITERATOR: true, INTERRUPTED: true }).stopped; - } -}); - -var $$6 = _export; -var IS_PURE$2 = isPure; -var anObject$2 = anObject$1z; -var aFunction$2 = aFunction$R; -var iterate$2 = iterate$I; - -// `Set.prototype.isSupersetOf` method -// https://tc39.github.io/proposal-set-methods/#Set.prototype.isSupersetOf -$$6({ target: 'Set', proto: true, real: true, forced: IS_PURE$2 }, { - isSupersetOf: function isSupersetOf(iterable) { - var set = anObject$2(this); - var hasCheck = aFunction$2(set.has); - return !iterate$2(iterable, function (value, stop) { - if (hasCheck.call(set, value) === false) return stop(); - }, { INTERRUPTED: true }).stopped; - } -}); - -var $$5 = _export; -var IS_PURE$1 = isPure; -var getBuiltIn$1 = getBuiltIn$t; -var anObject$1 = anObject$1z; -var aFunction$1 = aFunction$R; -var speciesConstructor$1 = speciesConstructor$j; -var iterate$1 = iterate$I; - -// `Set.prototype.union` method -// https://github.com/tc39/proposal-set-methods -$$5({ target: 'Set', proto: true, real: true, forced: IS_PURE$1 }, { - union: function union(iterable) { - var set = anObject$1(this); - var newSet = new (speciesConstructor$1(set, getBuiltIn$1('Set')))(set); - iterate$1(iterable, aFunction$1(newSet.add), { that: newSet }); - return newSet; - } -}); - -var $$4 = _export; -var IS_PURE = isPure; -var getBuiltIn = getBuiltIn$t; -var anObject = anObject$1z; -var aFunction = aFunction$R; -var speciesConstructor = speciesConstructor$j; -var iterate = iterate$I; - -// `Set.prototype.symmetricDifference` method -// https://github.com/tc39/proposal-set-methods -$$4({ target: 'Set', proto: true, real: true, forced: IS_PURE }, { - symmetricDifference: function symmetricDifference(iterable) { - var set = anObject(this); - var newSet = new (speciesConstructor(set, getBuiltIn('Set')))(set); - var remover = aFunction(newSet['delete']); - var adder = aFunction(newSet.add); - iterate(iterable, function (value) { - remover.call(newSet, value) || adder.call(newSet, value); - }); - return newSet; - } -}); - -var defineWellKnownSymbol$2 = defineWellKnownSymbol$j; - -// `Symbol.asyncDispose` well-known symbol -// https://github.com/tc39/proposal-using-statement -defineWellKnownSymbol$2('asyncDispose'); - -var defineWellKnownSymbol$1 = defineWellKnownSymbol$j; - -// `Symbol.dispose` well-known symbol -// https://github.com/tc39/proposal-using-statement -defineWellKnownSymbol$1('dispose'); - -var $$3 = _export; -var toObject = toObject$u; -var toLength$1 = toLength$y; -var toInteger$1 = toInteger$f; -var addToUnscopables = addToUnscopables$d; - -// `Array.prototype.at` method -// https://github.com/tc39/proposal-relative-indexing-method -$$3({ target: 'Array', proto: true }, { - at: function at(index) { - var O = toObject(this); - var len = toLength$1(O.length); - var relativeIndex = toInteger$1(index); - var k = relativeIndex >= 0 ? relativeIndex : len + relativeIndex; - return (k < 0 || k >= len) ? undefined : O[k]; - } -}); - -addToUnscopables('at'); - -var ArrayBufferViewCore = arrayBufferViewCore; -var toLength = toLength$y; -var toInteger = toInteger$f; - -var aTypedArray = ArrayBufferViewCore.aTypedArray; -var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod; - -// `%TypedArray%.prototype.at` method -// https://github.com/tc39/proposal-relative-indexing-method -exportTypedArrayMethod('at', function at(index) { - var O = aTypedArray(this); - var len = toLength(O.length); - var relativeIndex = toInteger(index); - var k = relativeIndex >= 0 ? relativeIndex : len + relativeIndex; - return (k < 0 || k >= len) ? undefined : O[k]; -}); - -// TODO: remove from `core-js@4` -var defineWellKnownSymbol = defineWellKnownSymbol$j; - -defineWellKnownSymbol('replaceAll'); - -// iterable DOM collections -// flag - `iterable` interface - 'entries', 'keys', 'values', 'forEach' methods -var domIterables = { - CSSRuleList: 0, - CSSStyleDeclaration: 0, - CSSValueList: 0, - ClientRectList: 0, - DOMRectList: 0, - DOMStringList: 0, - DOMTokenList: 1, - DataTransferItemList: 0, - FileList: 0, - HTMLAllCollection: 0, - HTMLCollection: 0, - HTMLFormElement: 0, - HTMLSelectElement: 0, - MediaList: 0, - MimeTypeArray: 0, - NamedNodeMap: 0, - NodeList: 1, - PaintRequestList: 0, - Plugin: 0, - PluginArray: 0, - SVGLengthList: 0, - SVGNumberList: 0, - SVGPathSegList: 0, - SVGPointList: 0, - SVGStringList: 0, - SVGTransformList: 0, - SourceBufferList: 0, - StyleSheetList: 0, - TextTrackCueList: 0, - TextTrackList: 0, - TouchList: 0 -}; - -var global$5 = global$L; -var DOMIterables$1 = domIterables; -var forEach = arrayForEach; -var createNonEnumerableProperty$1 = createNonEnumerableProperty$m; - -for (var COLLECTION_NAME$1 in DOMIterables$1) { - var Collection$1 = global$5[COLLECTION_NAME$1]; - var CollectionPrototype$1 = Collection$1 && Collection$1.prototype; - // some Chrome versions have non-configurable methods on DOMTokenList - if (CollectionPrototype$1 && CollectionPrototype$1.forEach !== forEach) try { - createNonEnumerableProperty$1(CollectionPrototype$1, 'forEach', forEach); - } catch (error) { - CollectionPrototype$1.forEach = forEach; - } -} - -var global$4 = global$L; -var DOMIterables = domIterables; -var ArrayIteratorMethods = es_array_iterator; -var createNonEnumerableProperty = createNonEnumerableProperty$m; -var wellKnownSymbol = wellKnownSymbol$C; - -var ITERATOR = wellKnownSymbol('iterator'); -var TO_STRING_TAG = wellKnownSymbol('toStringTag'); -var ArrayValues = ArrayIteratorMethods.values; - -for (var COLLECTION_NAME in DOMIterables) { - var Collection = global$4[COLLECTION_NAME]; - var CollectionPrototype = Collection && Collection.prototype; - if (CollectionPrototype) { - // some Chrome versions have non-configurable methods on DOMTokenList - if (CollectionPrototype[ITERATOR] !== ArrayValues) try { - createNonEnumerableProperty(CollectionPrototype, ITERATOR, ArrayValues); - } catch (error) { - CollectionPrototype[ITERATOR] = ArrayValues; - } - if (!CollectionPrototype[TO_STRING_TAG]) { - createNonEnumerableProperty(CollectionPrototype, TO_STRING_TAG, COLLECTION_NAME); - } - if (DOMIterables[COLLECTION_NAME]) for (var METHOD_NAME in ArrayIteratorMethods) { - // some Chrome versions have non-configurable methods on DOMTokenList - if (CollectionPrototype[METHOD_NAME] !== ArrayIteratorMethods[METHOD_NAME]) try { - createNonEnumerableProperty(CollectionPrototype, METHOD_NAME, ArrayIteratorMethods[METHOD_NAME]); - } catch (error) { - CollectionPrototype[METHOD_NAME] = ArrayIteratorMethods[METHOD_NAME]; - } - } - } -} - -var $$2 = _export; -var global$3 = global$L; -var task = task$2; - -var FORCED = !global$3.setImmediate || !global$3.clearImmediate; - -// http://w3c.github.io/setImmediate/ -$$2({ global: true, bind: true, enumerable: true, forced: FORCED }, { - // `setImmediate` method - // http://w3c.github.io/setImmediate/#si-setImmediate - setImmediate: task.set, - // `clearImmediate` method - // http://w3c.github.io/setImmediate/#si-clearImmediate - clearImmediate: task.clear -}); - -var $$1 = _export; -var global$2 = global$L; -var microtask = microtask$2; -var IS_NODE = engineIsNode; - -var process = global$2.process; - -// `queueMicrotask` method -// https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#dom-queuemicrotask -$$1({ global: true, enumerable: true, noTargetGet: true }, { - queueMicrotask: function queueMicrotask(fn) { - var domain = IS_NODE && process.domain; - microtask(domain ? domain.bind(fn) : fn); - } -}); - -var $ = _export; -var global$1 = global$L; -var userAgent = engineUserAgent; - -var slice = [].slice; -var MSIE = /MSIE .\./.test(userAgent); // <- dirty ie9- check - -var wrap = function (scheduler) { - return function (handler, timeout /* , ...arguments */) { - var boundArgs = arguments.length > 2; - var args = boundArgs ? slice.call(arguments, 2) : undefined; - return scheduler(boundArgs ? function () { - // eslint-disable-next-line no-new-func - (typeof handler == 'function' ? handler : Function(handler)).apply(this, args); - } : handler, timeout); - }; -}; - -// ie9- setTimeout & setInterval additional parameters fix -// https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#timers -$({ global: true, bind: true, forced: MSIE }, { - // `setTimeout` method - // https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#dom-settimeout - setTimeout: wrap(global$1.setTimeout), - // `setInterval` method - // https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#dom-setinterval - setInterval: wrap(global$1.setInterval) -}); +requireCoreJs(); diff --git a/test/form/samples/supports-es5-shim/_config.js b/test/form/samples/supports-es5-shim/_config.js index f107d95a931..564ffd1e518 100644 --- a/test/form/samples/supports-es5-shim/_config.js +++ b/test/form/samples/supports-es5-shim/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'supports es5-shim', options: { onwarn(warning) { @@ -6,7 +6,6 @@ module.exports = { throw new Error(warning.message); } }, - // TODO notable exception: Promise.resolve(thenable) not yet retained // check against tree-shake: false when updating the shim treeshake: true, plugins: [ @@ -14,4 +13,4 @@ module.exports = { require('@rollup/plugin-commonjs')() ] } -}; +}); diff --git a/test/form/samples/supports-es5-shim/_expected.js b/test/form/samples/supports-es5-shim/_expected.js index a240d888a87..4dadb484e54 100644 --- a/test/form/samples/supports-es5-shim/_expected.js +++ b/test/form/samples/supports-es5-shim/_expected.js @@ -1,2110 +1,2338 @@ -var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; - -var es5Shim = {exports: {}}; +var es5Shim$1 = {exports: {}}; /*! * https://github.com/es-shims/es5-shim * @license es5-shim Copyright 2009-2020 by contributors, MIT License * see https://github.com/es-shims/es5-shim/blob/master/LICENSE */ - -(function (module, exports) { - -// UMD (Universal Module Definition) -// see https://github.com/umdjs/umd/blob/master/templates/returnExports.js -(function (root, factory) { - - /* global define */ - { - // Node. Does not work with strict CommonJS, but - // only CommonJS-like enviroments that support module.exports, - // like Node. - module.exports = factory(); - } -}(commonjsGlobal, function () { - /** - * Brings an environment as close to ECMAScript 5 compliance - * as is possible with the facilities of erstwhile engines. - * - * Annotated ES5: http://es5.github.com/ (specific links below) - * ES5 Spec: http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf - * Required reading: http://javascriptweblog.wordpress.com/2011/12/05/extending-javascript-natives/ - */ - - // Shortcut to an often accessed properties, in order to avoid multiple - // dereference that costs universally. This also holds a reference to known-good - // functions. - var $Array = Array; - var ArrayPrototype = $Array.prototype; - var $Object = Object; - var ObjectPrototype = $Object.prototype; - var $Function = Function; - var FunctionPrototype = $Function.prototype; - var $String = String; - var StringPrototype = $String.prototype; - var $Number = Number; - var NumberPrototype = $Number.prototype; - var array_slice = ArrayPrototype.slice; - var array_splice = ArrayPrototype.splice; - var array_push = ArrayPrototype.push; - var array_unshift = ArrayPrototype.unshift; - var array_concat = ArrayPrototype.concat; - var array_join = ArrayPrototype.join; - var call = FunctionPrototype.call; - var apply = FunctionPrototype.apply; - var max = Math.max; - var min = Math.min; - var floor = Math.floor; - var abs = Math.abs; - var pow = Math.pow; - - // Having a toString local variable name breaks in Opera so use to_string. - var to_string = ObjectPrototype.toString; - - /* eslint-disable one-var-declaration-per-line, no-redeclare, max-statements-per-line */ - var hasToStringTag = typeof Symbol === 'function' && typeof Symbol.toStringTag === 'symbol'; - var isCallable; /* inlined from https://npmjs.com/is-callable */ var fnToStr = Function.prototype.toString, constructorRegex = /^\s*class /, isES6ClassFn = function isES6ClassFn(value) { try { var fnStr = fnToStr.call(value); var singleStripped = fnStr.replace(/\/\/.*\n/g, ''); var multiStripped = singleStripped.replace(/\/\*[.\s\S]*\*\//g, ''); var spaceStripped = multiStripped.replace(/\n/mg, ' ').replace(/ {2}/g, ' '); return constructorRegex.test(spaceStripped); } catch (e) { return false; /* not a function */ } }, tryFunctionObject = function tryFunctionObject(value) { try { if (isES6ClassFn(value)) { return false; } fnToStr.call(value); return true; } catch (e) { return false; } }, fnClass = '[object Function]', genClass = '[object GeneratorFunction]', isCallable = function isCallable(value) { if (!value) { return false; } if (typeof value !== 'function' && typeof value !== 'object') { return false; } if (hasToStringTag) { return tryFunctionObject(value); } if (isES6ClassFn(value)) { return false; } var strClass = to_string.call(value); return strClass === fnClass || strClass === genClass; }; - - var isRegex; /* inlined from https://npmjs.com/is-regex */ var regexExec = RegExp.prototype.exec, tryRegexExec = function tryRegexExec(value) { try { regexExec.call(value); return true; } catch (e) { return false; } }, regexClass = '[object RegExp]'; isRegex = function isRegex(value) { if (typeof value !== 'object') { return false; } return hasToStringTag ? tryRegexExec(value) : to_string.call(value) === regexClass; }; - var isString; /* inlined from https://npmjs.com/is-string */ var strValue = String.prototype.valueOf, tryStringObject = function tryStringObject(value) { try { strValue.call(value); return true; } catch (e) { return false; } }, stringClass = '[object String]'; isString = function isString(value) { if (typeof value === 'string') { return true; } if (typeof value !== 'object') { return false; } return hasToStringTag ? tryStringObject(value) : to_string.call(value) === stringClass; }; - /* eslint-enable one-var-declaration-per-line, no-redeclare, max-statements-per-line */ - - /* inlined from http://npmjs.com/define-properties */ - var supportsDescriptors = $Object.defineProperty && (function () { - try { - var obj = {}; - $Object.defineProperty(obj, 'x', { enumerable: false, value: obj }); - // eslint-disable-next-line no-unreachable-loop, max-statements-per-line - for (var _ in obj) { return false; } // jscs:ignore disallowUnusedVariables - return obj.x === obj; - } catch (e) { /* this is ES3 */ - return false; - } - }()); - var defineProperties = (function (has) { - // Define configurable, writable, and non-enumerable props - // if they don't exist. - var defineProperty; - if (supportsDescriptors) { - defineProperty = function (object, name, method, forceAssign) { - if (!forceAssign && (name in object)) { - return; - } - $Object.defineProperty(object, name, { - configurable: true, - enumerable: false, - writable: true, - value: method - }); - }; - } else { - defineProperty = function (object, name, method, forceAssign) { - if (!forceAssign && (name in object)) { - return; - } - object[name] = method; // eslint-disable-line no-param-reassign - }; - } - return function defineProperties(object, map, forceAssign) { - for (var name in map) { - if (has.call(map, name)) { - defineProperty(object, name, map[name], forceAssign); - } - } - }; - }(ObjectPrototype.hasOwnProperty)); - - // - // Util - // ====== - // - - /* replaceable with https://npmjs.com/package/es-abstract /helpers/isPrimitive */ - var isPrimitive = function isPrimitive(input) { - var type = typeof input; - return input === null || (type !== 'object' && type !== 'function'); - }; - - var isActualNaN = $Number.isNaN || function isActualNaN(x) { - return x !== x; - }; - - var ES = { - // ES5 9.4 - // http://es5.github.com/#x9.4 - // http://jsperf.com/to-integer - /* replaceable with https://npmjs.com/package/es-abstract ES5.ToInteger */ - ToInteger: function ToInteger(num) { - var n = +num; - if (isActualNaN(n)) { - n = 0; - } else if (n !== 0 && n !== (1 / 0) && n !== -(1 / 0)) { - n = (n > 0 || -1) * floor(abs(n)); - } - return n; - }, - - /* replaceable with https://npmjs.com/package/es-abstract ES5.ToPrimitive */ - ToPrimitive: function ToPrimitive(input) { - var val, valueOf, toStr; - if (isPrimitive(input)) { - return input; - } - valueOf = input.valueOf; - if (isCallable(valueOf)) { - val = valueOf.call(input); - if (isPrimitive(val)) { - return val; - } - } - toStr = input.toString; - if (isCallable(toStr)) { - val = toStr.call(input); - if (isPrimitive(val)) { - return val; - } - } - throw new TypeError(); - }, - - // ES5 9.9 - // http://es5.github.com/#x9.9 - /* replaceable with https://npmjs.com/package/es-abstract ES5.ToObject */ - ToObject: function (o) { - if (o == null) { // this matches both null and undefined - throw new TypeError("can't convert " + o + ' to object'); - } - return $Object(o); - }, - - /* replaceable with https://npmjs.com/package/es-abstract ES5.ToUint32 */ - ToUint32: function ToUint32(x) { - return x >>> 0; - } - }; - - // - // Function - // ======== - // - - // ES-5 15.3.4.5 - // http://es5.github.com/#x15.3.4.5 - - var Empty = function Empty() {}; - - defineProperties(FunctionPrototype, { - bind: function bind(that) { // .length is 1 - // 1. Let Target be the this value. - var target = this; - // 2. If IsCallable(Target) is false, throw a TypeError exception. - if (!isCallable(target)) { - throw new TypeError('Function.prototype.bind called on incompatible ' + target); - } - // 3. Let A be a new (possibly empty) internal list of all of the - // argument values provided after thisArg (arg1, arg2 etc), in order. - // XXX slicedArgs will stand in for "A" if used - var args = array_slice.call(arguments, 1); // for normal call - // 4. Let F be a new native ECMAScript object. - // 11. Set the [[Prototype]] internal property of F to the standard - // built-in Function prototype object as specified in 15.3.3.1. - // 12. Set the [[Call]] internal property of F as described in - // 15.3.4.5.1. - // 13. Set the [[Construct]] internal property of F as described in - // 15.3.4.5.2. - // 14. Set the [[HasInstance]] internal property of F as described in - // 15.3.4.5.3. - var bound; - var binder = function () { - - if (this instanceof bound) { - // 15.3.4.5.2 [[Construct]] - // When the [[Construct]] internal method of a function object, - // F that was created using the bind function is called with a - // list of arguments ExtraArgs, the following steps are taken: - // 1. Let target be the value of F's [[TargetFunction]] - // internal property. - // 2. If target has no [[Construct]] internal method, a - // TypeError exception is thrown. - // 3. Let boundArgs be the value of F's [[BoundArgs]] internal - // property. - // 4. Let args be a new list containing the same values as the - // list boundArgs in the same order followed by the same - // values as the list ExtraArgs in the same order. - // 5. Return the result of calling the [[Construct]] internal - // method of target providing args as the arguments. - - var result = apply.call( - target, - this, - array_concat.call(args, array_slice.call(arguments)) - ); - if ($Object(result) === result) { - return result; - } - return this; - - } else { - // 15.3.4.5.1 [[Call]] - // When the [[Call]] internal method of a function object, F, - // which was created using the bind function is called with a - // this value and a list of arguments ExtraArgs, the following - // steps are taken: - // 1. Let boundArgs be the value of F's [[BoundArgs]] internal - // property. - // 2. Let boundThis be the value of F's [[BoundThis]] internal - // property. - // 3. Let target be the value of F's [[TargetFunction]] internal - // property. - // 4. Let args be a new list containing the same values as the - // list boundArgs in the same order followed by the same - // values as the list ExtraArgs in the same order. - // 5. Return the result of calling the [[Call]] internal method - // of target providing boundThis as the this value and - // providing args as the arguments. - - // equiv: target.call(this, ...boundArgs, ...args) - return apply.call( - target, - that, - array_concat.call(args, array_slice.call(arguments)) - ); - - } - - }; - - // 15. If the [[Class]] internal property of Target is "Function", then - // a. Let L be the length property of Target minus the length of A. - // b. Set the length own property of F to either 0 or L, whichever is - // larger. - // 16. Else set the length own property of F to 0. - - var boundLength = max(0, target.length - args.length); - - // 17. Set the attributes of the length own property of F to the values - // specified in 15.3.5.1. - var boundArgs = []; - for (var i = 0; i < boundLength; i++) { - array_push.call(boundArgs, '$' + i); - } - - // XXX Build a dynamic function with desired amount of arguments is the only - // way to set the length property of a function. - // In environments where Content Security Policies enabled (Chrome extensions, - // for ex.) all use of eval or Function costructor throws an exception. - // However in all of these environments Function.prototype.bind exists - // and so this code will never be executed. - bound = $Function('binder', 'return function (' + array_join.call(boundArgs, ',') + '){ return binder.apply(this, arguments); }')(binder); - - if (target.prototype) { - Empty.prototype = target.prototype; - bound.prototype = new Empty(); - // Clean up dangling references. - Empty.prototype = null; - } - - // TODO - // 18. Set the [[Extensible]] internal property of F to true. - - // TODO - // 19. Let thrower be the [[ThrowTypeError]] function Object (13.2.3). - // 20. Call the [[DefineOwnProperty]] internal method of F with - // arguments "caller", PropertyDescriptor {[[Get]]: thrower, [[Set]]: - // thrower, [[Enumerable]]: false, [[Configurable]]: false}, and - // false. - // 21. Call the [[DefineOwnProperty]] internal method of F with - // arguments "arguments", PropertyDescriptor {[[Get]]: thrower, - // [[Set]]: thrower, [[Enumerable]]: false, [[Configurable]]: false}, - // and false. - - // TODO - // NOTE Function objects created using Function.prototype.bind do not - // have a prototype property or the [[Code]], [[FormalParameters]], and - // [[Scope]] internal properties. - // XXX can't delete prototype in pure-js. - - // 22. Return F. - return bound; - } - }); - - // _Please note: Shortcuts are defined after `Function.prototype.bind` as we - // use it in defining shortcuts. - var owns = call.bind(ObjectPrototype.hasOwnProperty); - var toStr = call.bind(ObjectPrototype.toString); - var arraySlice = call.bind(array_slice); - var arraySliceApply = apply.bind(array_slice); - /* globals document */ - if (typeof document === 'object' && document && document.documentElement) { - try { - arraySlice(document.documentElement.childNodes); - } catch (e) { - var origArraySlice = arraySlice; - var origArraySliceApply = arraySliceApply; - arraySlice = function arraySliceIE(arr) { - var r = []; - var i = arr.length; - while (i-- > 0) { - r[i] = arr[i]; - } - return origArraySliceApply(r, origArraySlice(arguments, 1)); - }; - arraySliceApply = function arraySliceApplyIE(arr, args) { - return origArraySliceApply(arraySlice(arr), args); - }; - } - } - var strSlice = call.bind(StringPrototype.slice); - var strSplit = call.bind(StringPrototype.split); - var strIndexOf = call.bind(StringPrototype.indexOf); - var pushCall = call.bind(array_push); - var isEnum = call.bind(ObjectPrototype.propertyIsEnumerable); - var arraySort = call.bind(ArrayPrototype.sort); - - // - // Array - // ===== - // - - var isArray = $Array.isArray || function isArray(obj) { - return toStr(obj) === '[object Array]'; - }; - - // ES5 15.4.4.12 - // http://es5.github.com/#x15.4.4.13 - // Return len+argCount. - // [bugfix, ielt8] - // IE < 8 bug: [].unshift(0) === undefined but should be "1" - var hasUnshiftReturnValueBug = [].unshift(0) !== 1; - defineProperties(ArrayPrototype, { - unshift: function () { - array_unshift.apply(this, arguments); - return this.length; - } - }, hasUnshiftReturnValueBug); - - // ES5 15.4.3.2 - // http://es5.github.com/#x15.4.3.2 - // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/isArray - defineProperties($Array, { isArray: isArray }); - - // The IsCallable() check in the Array functions - // has been replaced with a strict check on the - // internal class of the object to trap cases where - // the provided function was actually a regular - // expression literal, which in V8 and - // JavaScriptCore is a typeof "function". Only in - // V8 are regular expression literals permitted as - // reduce parameters, so it is desirable in the - // general case for the shim to match the more - // strict and common behavior of rejecting regular - // expressions. - - // ES5 15.4.4.18 - // http://es5.github.com/#x15.4.4.18 - // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/array/forEach - - // Check failure of by-index access of string characters (IE < 9) - // and failure of `0 in boxedString` (Rhino) - var boxedString = $Object('a'); - var splitString = boxedString[0] !== 'a' || !(0 in boxedString); - - var properlyBoxesContext = function properlyBoxed(method) { - // Check node 0.6.21 bug where third parameter is not boxed - var properlyBoxesNonStrict = true; - var properlyBoxesStrict = true; - var threwException = false; - if (method) { - try { - method.call('foo', function (_, __, context) { - if (typeof context !== 'object') { - properlyBoxesNonStrict = false; - } - }); - - method.call([1], function () { - 'use strict'; - - properlyBoxesStrict = typeof this === 'string'; - }, 'x'); - } catch (e) { - threwException = true; - } - } - return !!method && !threwException && properlyBoxesNonStrict && properlyBoxesStrict; - }; - - defineProperties(ArrayPrototype, { - forEach: function forEach(callbackfn/*, thisArg*/) { - var object = ES.ToObject(this); - var self = splitString && isString(this) ? strSplit(this, '') : object; - var i = -1; - var length = ES.ToUint32(self.length); - var T; - if (arguments.length > 1) { - T = arguments[1]; - } - - // If no callback function or if callback is not a callable function - if (!isCallable(callbackfn)) { - throw new TypeError('Array.prototype.forEach callback must be a function'); - } - - while (++i < length) { - if (i in self) { - // Invoke the callback function with call, passing arguments: - // context, property value, property key, thisArg object - if (typeof T === 'undefined') { - callbackfn(self[i], i, object); - } else { - callbackfn.call(T, self[i], i, object); - } - } - } - } - }, !properlyBoxesContext(ArrayPrototype.forEach)); - - // ES5 15.4.4.19 - // http://es5.github.com/#x15.4.4.19 - // https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/map - defineProperties(ArrayPrototype, { - map: function map(callbackfn/*, thisArg*/) { - var object = ES.ToObject(this); - var self = splitString && isString(this) ? strSplit(this, '') : object; - var length = ES.ToUint32(self.length); - var result = $Array(length); - var T; - if (arguments.length > 1) { - T = arguments[1]; - } - - // If no callback function or if callback is not a callable function - if (!isCallable(callbackfn)) { - throw new TypeError('Array.prototype.map callback must be a function'); - } - - for (var i = 0; i < length; i++) { - if (i in self) { - if (typeof T === 'undefined') { - result[i] = callbackfn(self[i], i, object); - } else { - result[i] = callbackfn.call(T, self[i], i, object); - } - } - } - return result; - } - }, !properlyBoxesContext(ArrayPrototype.map)); - - // ES5 15.4.4.20 - // http://es5.github.com/#x15.4.4.20 - // https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/filter - defineProperties(ArrayPrototype, { - filter: function filter(callbackfn/*, thisArg*/) { - var object = ES.ToObject(this); - var self = splitString && isString(this) ? strSplit(this, '') : object; - var length = ES.ToUint32(self.length); - var result = []; - var value; - var T; - if (arguments.length > 1) { - T = arguments[1]; - } - - // If no callback function or if callback is not a callable function - if (!isCallable(callbackfn)) { - throw new TypeError('Array.prototype.filter callback must be a function'); - } - - for (var i = 0; i < length; i++) { - if (i in self) { - value = self[i]; - if (typeof T === 'undefined' ? callbackfn(value, i, object) : callbackfn.call(T, value, i, object)) { - pushCall(result, value); - } - } - } - return result; - } - }, !properlyBoxesContext(ArrayPrototype.filter)); - - // ES5 15.4.4.16 - // http://es5.github.com/#x15.4.4.16 - // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/every - defineProperties(ArrayPrototype, { - every: function every(callbackfn/*, thisArg*/) { - var object = ES.ToObject(this); - var self = splitString && isString(this) ? strSplit(this, '') : object; - var length = ES.ToUint32(self.length); - var T; - if (arguments.length > 1) { - T = arguments[1]; - } - - // If no callback function or if callback is not a callable function - if (!isCallable(callbackfn)) { - throw new TypeError('Array.prototype.every callback must be a function'); - } - - for (var i = 0; i < length; i++) { - if (i in self && !(typeof T === 'undefined' ? callbackfn(self[i], i, object) : callbackfn.call(T, self[i], i, object))) { - return false; - } - } - return true; - } - }, !properlyBoxesContext(ArrayPrototype.every)); - - // ES5 15.4.4.17 - // http://es5.github.com/#x15.4.4.17 - // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/some - defineProperties(ArrayPrototype, { - some: function some(callbackfn/*, thisArg */) { - var object = ES.ToObject(this); - var self = splitString && isString(this) ? strSplit(this, '') : object; - var length = ES.ToUint32(self.length); - var T; - if (arguments.length > 1) { - T = arguments[1]; - } - - // If no callback function or if callback is not a callable function - if (!isCallable(callbackfn)) { - throw new TypeError('Array.prototype.some callback must be a function'); - } - - for (var i = 0; i < length; i++) { - if (i in self && (typeof T === 'undefined' ? callbackfn(self[i], i, object) : callbackfn.call(T, self[i], i, object))) { - return true; - } - } - return false; - } - }, !properlyBoxesContext(ArrayPrototype.some)); - - // ES5 15.4.4.21 - // http://es5.github.com/#x15.4.4.21 - // https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/reduce - var reduceCoercesToObject = false; - if (ArrayPrototype.reduce) { - reduceCoercesToObject = typeof ArrayPrototype.reduce.call('es5', function (_, __, ___, list) { - return list; - }) === 'object'; - } - defineProperties(ArrayPrototype, { - reduce: function reduce(callbackfn/*, initialValue*/) { - var object = ES.ToObject(this); - var self = splitString && isString(this) ? strSplit(this, '') : object; - var length = ES.ToUint32(self.length); - - // If no callback function or if callback is not a callable function - if (!isCallable(callbackfn)) { - throw new TypeError('Array.prototype.reduce callback must be a function'); - } - - // no value to return if no initial value and an empty array - if (length === 0 && arguments.length === 1) { - throw new TypeError('reduce of empty array with no initial value'); - } - - var i = 0; - var result; - if (arguments.length >= 2) { - result = arguments[1]; - } else { - do { - if (i in self) { - result = self[i++]; - break; - } - - // if array contains no values, no initial value to return - if (++i >= length) { - throw new TypeError('reduce of empty array with no initial value'); - } - } while (true); - } - - for (; i < length; i++) { - if (i in self) { - result = callbackfn(result, self[i], i, object); - } - } - - return result; - } - }, !reduceCoercesToObject); - - // ES5 15.4.4.22 - // http://es5.github.com/#x15.4.4.22 - // https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/reduceRight - var reduceRightCoercesToObject = false; - if (ArrayPrototype.reduceRight) { - reduceRightCoercesToObject = typeof ArrayPrototype.reduceRight.call('es5', function (_, __, ___, list) { - return list; - }) === 'object'; - } - defineProperties(ArrayPrototype, { - reduceRight: function reduceRight(callbackfn/*, initial*/) { - var object = ES.ToObject(this); - var self = splitString && isString(this) ? strSplit(this, '') : object; - var length = ES.ToUint32(self.length); - - // If no callback function or if callback is not a callable function - if (!isCallable(callbackfn)) { - throw new TypeError('Array.prototype.reduceRight callback must be a function'); - } - - // no value to return if no initial value, empty array - if (length === 0 && arguments.length === 1) { - throw new TypeError('reduceRight of empty array with no initial value'); - } - - var result; - var i = length - 1; - if (arguments.length >= 2) { - result = arguments[1]; - } else { - do { - if (i in self) { - result = self[i--]; - break; - } - - // if array contains no values, no initial value to return - if (--i < 0) { - throw new TypeError('reduceRight of empty array with no initial value'); - } - } while (true); - } - - if (i < 0) { - return result; - } - - do { - if (i in self) { - result = callbackfn(result, self[i], i, object); - } - } while (i--); - - return result; - } - }, !reduceRightCoercesToObject); - - // ES5 15.4.4.14 - // http://es5.github.com/#x15.4.4.14 - // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/indexOf - var hasFirefox2IndexOfBug = ArrayPrototype.indexOf && [0, 1].indexOf(1, 2) !== -1; - defineProperties(ArrayPrototype, { - indexOf: function indexOf(searchElement/*, fromIndex */) { - var self = splitString && isString(this) ? strSplit(this, '') : ES.ToObject(this); - var length = ES.ToUint32(self.length); - - if (length === 0) { - return -1; - } - - var i = 0; - if (arguments.length > 1) { - i = ES.ToInteger(arguments[1]); - } - - // handle negative indices - i = i >= 0 ? i : max(0, length + i); - for (; i < length; i++) { - if (i in self && self[i] === searchElement) { - return i; - } - } - return -1; - } - }, hasFirefox2IndexOfBug); - - // ES5 15.4.4.15 - // http://es5.github.com/#x15.4.4.15 - // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/lastIndexOf - var hasFirefox2LastIndexOfBug = ArrayPrototype.lastIndexOf && [0, 1].lastIndexOf(0, -3) !== -1; - defineProperties(ArrayPrototype, { - lastIndexOf: function lastIndexOf(searchElement/*, fromIndex */) { - var self = splitString && isString(this) ? strSplit(this, '') : ES.ToObject(this); - var length = ES.ToUint32(self.length); - - if (length === 0) { - return -1; - } - var i = length - 1; - if (arguments.length > 1) { - i = min(i, ES.ToInteger(arguments[1])); - } - // handle negative indices - i = i >= 0 ? i : length - abs(i); - for (; i >= 0; i--) { - if (i in self && searchElement === self[i]) { - return i; - } - } - return -1; - } - }, hasFirefox2LastIndexOfBug); - - // ES5 15.4.4.12 - // http://es5.github.com/#x15.4.4.12 - var spliceNoopReturnsEmptyArray = (function () { - var a = [1, 2]; - var result = a.splice(); - return a.length === 2 && isArray(result) && result.length === 0; - }()); - defineProperties(ArrayPrototype, { - // Safari 5.0 bug where .splice() returns undefined - splice: function splice(start, deleteCount) { - if (arguments.length === 0) { - return []; - } else { - return array_splice.apply(this, arguments); - } - } - }, !spliceNoopReturnsEmptyArray); - - var spliceWorksWithEmptyObject = (function () { - var obj = {}; - ArrayPrototype.splice.call(obj, 0, 0, 1); - return obj.length === 1; - }()); - defineProperties(ArrayPrototype, { - splice: function splice(start, deleteCount) { - if (arguments.length === 0) { - return []; - } - var args = arguments; - this.length = max(ES.ToInteger(this.length), 0); - if (arguments.length > 0 && typeof deleteCount !== 'number') { - args = arraySlice(arguments); - if (args.length < 2) { - pushCall(args, this.length - start); - } else { - args[1] = ES.ToInteger(deleteCount); - } - } - return array_splice.apply(this, args); - } - }, !spliceWorksWithEmptyObject); - var spliceWorksWithLargeSparseArrays = (function () { - // Per https://github.com/es-shims/es5-shim/issues/295 - // Safari 7/8 breaks with sparse arrays of size 1e5 or greater - var arr = new $Array(1e5); - // note: the index MUST be 8 or larger or the test will false pass - arr[8] = 'x'; - arr.splice(1, 1); - // note: this test must be defined *after* the indexOf shim - // per https://github.com/es-shims/es5-shim/issues/313 - return arr.indexOf('x') === 7; - }()); - var spliceWorksWithSmallSparseArrays = (function () { - // Per https://github.com/es-shims/es5-shim/issues/295 - // Opera 12.15 breaks on this, no idea why. - var n = 256; - var arr = []; - arr[n] = 'a'; - arr.splice(n + 1, 0, 'b'); - return arr[n] === 'a'; - }()); - defineProperties(ArrayPrototype, { - splice: function splice(start, deleteCount) { - var O = ES.ToObject(this); - var A = []; - var len = ES.ToUint32(O.length); - var relativeStart = ES.ToInteger(start); - var actualStart = relativeStart < 0 ? max((len + relativeStart), 0) : min(relativeStart, len); - var actualDeleteCount = arguments.length === 0 - ? 0 - : arguments.length === 1 - ? len - actualStart - : min(max(ES.ToInteger(deleteCount), 0), len - actualStart); - - var k = 0; - var from; - while (k < actualDeleteCount) { - from = $String(actualStart + k); - if (owns(O, from)) { - A[k] = O[from]; - } - k += 1; - } - - var items = arraySlice(arguments, 2); - var itemCount = items.length; - var to; - if (itemCount < actualDeleteCount) { - k = actualStart; - var maxK = len - actualDeleteCount; - while (k < maxK) { - from = $String(k + actualDeleteCount); - to = $String(k + itemCount); - if (owns(O, from)) { - O[to] = O[from]; - } else { - delete O[to]; - } - k += 1; - } - k = len; - var minK = len - actualDeleteCount + itemCount; - while (k > minK) { - delete O[k - 1]; - k -= 1; - } - } else if (itemCount > actualDeleteCount) { - k = len - actualDeleteCount; - while (k > actualStart) { - from = $String(k + actualDeleteCount - 1); - to = $String(k + itemCount - 1); - if (owns(O, from)) { - O[to] = O[from]; - } else { - delete O[to]; - } - k -= 1; - } - } - k = actualStart; - for (var i = 0; i < items.length; ++i) { - O[k] = items[i]; - k += 1; - } - O.length = len - actualDeleteCount + itemCount; - - return A; - } - }, !spliceWorksWithLargeSparseArrays || !spliceWorksWithSmallSparseArrays); - - var originalJoin = ArrayPrototype.join; - var hasStringJoinBug; - try { - hasStringJoinBug = Array.prototype.join.call('123', ',') !== '1,2,3'; - } catch (e) { - hasStringJoinBug = true; - } - if (hasStringJoinBug) { - defineProperties(ArrayPrototype, { - join: function join(separator) { - var sep = typeof separator === 'undefined' ? ',' : separator; - return originalJoin.call(isString(this) ? strSplit(this, '') : this, sep); - } - }, hasStringJoinBug); - } - - var hasJoinUndefinedBug = [1, 2].join(undefined) !== '1,2'; - if (hasJoinUndefinedBug) { - defineProperties(ArrayPrototype, { - join: function join(separator) { - var sep = typeof separator === 'undefined' ? ',' : separator; - return originalJoin.call(this, sep); - } - }, hasJoinUndefinedBug); - } - - var pushShim = function push(item) { - var O = ES.ToObject(this); - var n = ES.ToUint32(O.length); - var i = 0; - while (i < arguments.length) { - O[n + i] = arguments[i]; - i += 1; - } - O.length = n + i; - return n + i; - }; - - var pushIsNotGeneric = (function () { - var obj = {}; - var result = Array.prototype.push.call(obj, undefined); - return result !== 1 || obj.length !== 1 || typeof obj[0] !== 'undefined' || !owns(obj, 0); - }()); - defineProperties(ArrayPrototype, { - push: function push(item) { - if (isArray(this)) { - return array_push.apply(this, arguments); - } - return pushShim.apply(this, arguments); - } - }, pushIsNotGeneric); - - // This fixes a very weird bug in Opera 10.6 when pushing `undefined - var pushUndefinedIsWeird = (function () { - var arr = []; - var result = arr.push(undefined); - return result !== 1 || arr.length !== 1 || typeof arr[0] !== 'undefined' || !owns(arr, 0); - }()); - defineProperties(ArrayPrototype, { push: pushShim }, pushUndefinedIsWeird); - - // ES5 15.2.3.14 - // http://es5.github.io/#x15.4.4.10 - // Fix boxed string bug - defineProperties(ArrayPrototype, { - slice: function (start, end) { - var arr = isString(this) ? strSplit(this, '') : this; - return arraySliceApply(arr, arguments); - } - }, splitString); - - var sortIgnoresNonFunctions = (function () { - try { - [1, 2].sort(null); - } catch (e) { - try { - [1, 2].sort({}); - } catch (e2) { - return false; - } - } - return true; - }()); - var sortThrowsOnRegex = (function () { - // this is a problem in Firefox 4, in which `typeof /a/ === 'function'` - try { - [1, 2].sort(/a/); - return false; - } catch (e) {} - return true; - }()); - var sortIgnoresUndefined = (function () { - // applies in IE 8, for one. - try { - [1, 2].sort(undefined); - return true; - } catch (e) {} - return false; - }()); - defineProperties(ArrayPrototype, { - sort: function sort(compareFn) { - if (typeof compareFn === 'undefined') { - return arraySort(this); - } - if (!isCallable(compareFn)) { - throw new TypeError('Array.prototype.sort callback must be a function'); - } - return arraySort(this, compareFn); - } - }, sortIgnoresNonFunctions || !sortIgnoresUndefined || !sortThrowsOnRegex); - - // - // Object - // ====== - // - - // ES5 15.2.3.14 - // http://es5.github.com/#x15.2.3.14 - - // http://whattheheadsaid.com/2010/10/a-safer-object-keys-compatibility-implementation - var hasDontEnumBug = !isEnum({ 'toString': null }, 'toString'); // jscs:ignore disallowQuotedKeysInObjects - var hasProtoEnumBug = isEnum(function () {}, 'prototype'); - var hasStringEnumBug = !owns('x', '0'); - var equalsConstructorPrototype = function (o) { - var ctor = o.constructor; - return ctor && ctor.prototype === o; - }; - var excludedKeys = { - $applicationCache: true, - $console: true, - $external: true, - $frame: true, - $frameElement: true, - $frames: true, - $innerHeight: true, - $innerWidth: true, - $onmozfullscreenchange: true, - $onmozfullscreenerror: true, - $outerHeight: true, - $outerWidth: true, - $pageXOffset: true, - $pageYOffset: true, - $parent: true, - $scrollLeft: true, - $scrollTop: true, - $scrollX: true, - $scrollY: true, - $self: true, - $webkitIndexedDB: true, - $webkitStorageInfo: true, - $window: true, - - $width: true, - $height: true, - $top: true, - $localStorage: true - }; - var hasAutomationEqualityBug = (function () { - /* globals window */ - if (typeof window === 'undefined') { - return false; - } - for (var k in window) { - try { - if (!excludedKeys['$' + k] && owns(window, k) && window[k] !== null && typeof window[k] === 'object') { - equalsConstructorPrototype(window[k]); - } - } catch (e) { - return true; - } - } - return false; - }()); - var equalsConstructorPrototypeIfNotBuggy = function (object) { - if (typeof window === 'undefined' || !hasAutomationEqualityBug) { - return equalsConstructorPrototype(object); - } - try { - return equalsConstructorPrototype(object); - } catch (e) { - return false; - } - }; - var dontEnums = [ - 'toString', - 'toLocaleString', - 'valueOf', - 'hasOwnProperty', - 'isPrototypeOf', - 'propertyIsEnumerable', - 'constructor' - ]; - var dontEnumsLength = dontEnums.length; - - // taken directly from https://github.com/ljharb/is-arguments/blob/master/index.js - // can be replaced with require('is-arguments') if we ever use a build process instead - var isStandardArguments = function isArguments(value) { - return toStr(value) === '[object Arguments]'; - }; - var isLegacyArguments = function isArguments(value) { - return value !== null - && typeof value === 'object' - && typeof value.length === 'number' - && value.length >= 0 - && !isArray(value) - && isCallable(value.callee); - }; - var isArguments = isStandardArguments(arguments) ? isStandardArguments : isLegacyArguments; - - defineProperties($Object, { - keys: function keys(object) { - var isFn = isCallable(object); - var isArgs = isArguments(object); - var isObject = object !== null && typeof object === 'object'; - var isStr = isObject && isString(object); - - if (!isObject && !isFn && !isArgs) { - throw new TypeError('Object.keys called on a non-object'); - } - - var theKeys = []; - var skipProto = hasProtoEnumBug && isFn; - if ((isStr && hasStringEnumBug) || isArgs) { - for (var i = 0; i < object.length; ++i) { - pushCall(theKeys, $String(i)); - } - } - - if (!isArgs) { - for (var name in object) { - if (!(skipProto && name === 'prototype') && owns(object, name)) { - pushCall(theKeys, $String(name)); - } - } - } - - if (hasDontEnumBug) { - var skipConstructor = equalsConstructorPrototypeIfNotBuggy(object); - for (var j = 0; j < dontEnumsLength; j++) { - var dontEnum = dontEnums[j]; - if (!(skipConstructor && dontEnum === 'constructor') && owns(object, dontEnum)) { - pushCall(theKeys, dontEnum); - } - } - } - return theKeys; - } - }); - - var keysWorksWithArguments = $Object.keys && (function () { - // Safari 5.0 bug - return $Object.keys(arguments).length === 2; - }(1, 2)); - var keysHasArgumentsLengthBug = $Object.keys && (function () { - var argKeys = $Object.keys(arguments); - return arguments.length !== 1 || argKeys.length !== 1 || argKeys[0] !== 1; - }(1)); - var originalKeys = $Object.keys; - defineProperties($Object, { - keys: function keys(object) { - if (isArguments(object)) { - return originalKeys(arraySlice(object)); - } else { - return originalKeys(object); - } - } - }, !keysWorksWithArguments || keysHasArgumentsLengthBug); - - // - // Date - // ==== - // - - var hasNegativeMonthYearBug = new Date(-3509827329600292).getUTCMonth() !== 0; - var aNegativeTestDate = new Date(-1509842289600292); - var aPositiveTestDate = new Date(1449662400000); - var hasToUTCStringFormatBug = aNegativeTestDate.toUTCString() !== 'Mon, 01 Jan -45875 11:59:59 GMT'; - var hasToDateStringFormatBug; - var hasToStringFormatBug; - var timeZoneOffset = aNegativeTestDate.getTimezoneOffset(); - if (timeZoneOffset < -720) { - hasToDateStringFormatBug = aNegativeTestDate.toDateString() !== 'Tue Jan 02 -45875'; - hasToStringFormatBug = !(/^Thu Dec 10 2015 \d\d:\d\d:\d\d GMT[-+]\d\d\d\d(?: |$)/).test(String(aPositiveTestDate)); - } else { - hasToDateStringFormatBug = aNegativeTestDate.toDateString() !== 'Mon Jan 01 -45875'; - hasToStringFormatBug = !(/^Wed Dec 09 2015 \d\d:\d\d:\d\d GMT[-+]\d\d\d\d(?: |$)/).test(String(aPositiveTestDate)); - } - - var originalGetFullYear = call.bind(Date.prototype.getFullYear); - var originalGetMonth = call.bind(Date.prototype.getMonth); - var originalGetDate = call.bind(Date.prototype.getDate); - var originalGetUTCFullYear = call.bind(Date.prototype.getUTCFullYear); - var originalGetUTCMonth = call.bind(Date.prototype.getUTCMonth); - var originalGetUTCDate = call.bind(Date.prototype.getUTCDate); - var originalGetUTCDay = call.bind(Date.prototype.getUTCDay); - var originalGetUTCHours = call.bind(Date.prototype.getUTCHours); - var originalGetUTCMinutes = call.bind(Date.prototype.getUTCMinutes); - var originalGetUTCSeconds = call.bind(Date.prototype.getUTCSeconds); - var originalGetUTCMilliseconds = call.bind(Date.prototype.getUTCMilliseconds); - var dayName = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']; - var monthName = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']; - var daysInMonth = function daysInMonth(month, year) { - return originalGetDate(new Date(year, month, 0)); - }; - - defineProperties(Date.prototype, { - getFullYear: function getFullYear() { - if (!this || !(this instanceof Date)) { - throw new TypeError('this is not a Date object.'); - } - var year = originalGetFullYear(this); - if (year < 0 && originalGetMonth(this) > 11) { - return year + 1; - } - return year; - }, - getMonth: function getMonth() { - if (!this || !(this instanceof Date)) { - throw new TypeError('this is not a Date object.'); - } - var year = originalGetFullYear(this); - var month = originalGetMonth(this); - if (year < 0 && month > 11) { - return 0; - } - return month; - }, - getDate: function getDate() { - if (!this || !(this instanceof Date)) { - throw new TypeError('this is not a Date object.'); - } - var year = originalGetFullYear(this); - var month = originalGetMonth(this); - var date = originalGetDate(this); - if (year < 0 && month > 11) { - if (month === 12) { - return date; - } - var days = daysInMonth(0, year + 1); - return (days - date) + 1; - } - return date; - }, - getUTCFullYear: function getUTCFullYear() { - if (!this || !(this instanceof Date)) { - throw new TypeError('this is not a Date object.'); - } - var year = originalGetUTCFullYear(this); - if (year < 0 && originalGetUTCMonth(this) > 11) { - return year + 1; - } - return year; - }, - getUTCMonth: function getUTCMonth() { - if (!this || !(this instanceof Date)) { - throw new TypeError('this is not a Date object.'); - } - var year = originalGetUTCFullYear(this); - var month = originalGetUTCMonth(this); - if (year < 0 && month > 11) { - return 0; - } - return month; - }, - getUTCDate: function getUTCDate() { - if (!this || !(this instanceof Date)) { - throw new TypeError('this is not a Date object.'); - } - var year = originalGetUTCFullYear(this); - var month = originalGetUTCMonth(this); - var date = originalGetUTCDate(this); - if (year < 0 && month > 11) { - if (month === 12) { - return date; - } - var days = daysInMonth(0, year + 1); - return (days - date) + 1; - } - return date; - } - }, hasNegativeMonthYearBug); - - defineProperties(Date.prototype, { - toUTCString: function toUTCString() { - if (!this || !(this instanceof Date)) { - throw new TypeError('this is not a Date object.'); - } - var day = originalGetUTCDay(this); - var date = originalGetUTCDate(this); - var month = originalGetUTCMonth(this); - var year = originalGetUTCFullYear(this); - var hour = originalGetUTCHours(this); - var minute = originalGetUTCMinutes(this); - var second = originalGetUTCSeconds(this); - return dayName[day] + ', ' - + (date < 10 ? '0' + date : date) + ' ' - + monthName[month] + ' ' - + year + ' ' - + (hour < 10 ? '0' + hour : hour) + ':' - + (minute < 10 ? '0' + minute : minute) + ':' - + (second < 10 ? '0' + second : second) + ' GMT'; - } - }, hasNegativeMonthYearBug || hasToUTCStringFormatBug); - - // Opera 12 has `,` - defineProperties(Date.prototype, { - toDateString: function toDateString() { - if (!this || !(this instanceof Date)) { - throw new TypeError('this is not a Date object.'); - } - var day = this.getDay(); - var date = this.getDate(); - var month = this.getMonth(); - var year = this.getFullYear(); - return dayName[day] + ' ' - + monthName[month] + ' ' - + (date < 10 ? '0' + date : date) + ' ' - + year; - } - }, hasNegativeMonthYearBug || hasToDateStringFormatBug); - - // can't use defineProperties here because of toString enumeration issue in IE <= 8 - if (hasNegativeMonthYearBug || hasToStringFormatBug) { - Date.prototype.toString = function toString() { - if (!this || !(this instanceof Date)) { - throw new TypeError('this is not a Date object.'); - } - var day = this.getDay(); - var date = this.getDate(); - var month = this.getMonth(); - var year = this.getFullYear(); - var hour = this.getHours(); - var minute = this.getMinutes(); - var second = this.getSeconds(); - var timezoneOffset = this.getTimezoneOffset(); - var hoursOffset = floor(abs(timezoneOffset) / 60); - var minutesOffset = floor(abs(timezoneOffset) % 60); - return dayName[day] + ' ' - + monthName[month] + ' ' - + (date < 10 ? '0' + date : date) + ' ' - + year + ' ' - + (hour < 10 ? '0' + hour : hour) + ':' - + (minute < 10 ? '0' + minute : minute) + ':' - + (second < 10 ? '0' + second : second) + ' GMT' - + (timezoneOffset > 0 ? '-' : '+') - + (hoursOffset < 10 ? '0' + hoursOffset : hoursOffset) - + (minutesOffset < 10 ? '0' + minutesOffset : minutesOffset); - }; - if (supportsDescriptors) { - $Object.defineProperty(Date.prototype, 'toString', { - configurable: true, - enumerable: false, - writable: true - }); - } - } - - // ES5 15.9.5.43 - // http://es5.github.com/#x15.9.5.43 - // This function returns a String value represent the instance in time - // represented by this Date object. The format of the String is the Date Time - // string format defined in 15.9.1.15. All fields are present in the String. - // The time zone is always UTC, denoted by the suffix Z. If the time value of - // this object is not a finite Number a RangeError exception is thrown. - var negativeDate = -62198755200000; - var negativeYearString = '-000001'; - var hasNegativeDateBug = Date.prototype.toISOString && new Date(negativeDate).toISOString().indexOf(negativeYearString) === -1; // eslint-disable-line max-len - var hasSafari51DateBug = Date.prototype.toISOString && new Date(-1).toISOString() !== '1969-12-31T23:59:59.999Z'; - - var getTime = call.bind(Date.prototype.getTime); - - defineProperties(Date.prototype, { - toISOString: function toISOString() { - if (!isFinite(this) || !isFinite(getTime(this))) { - // Adope Photoshop requires the second check. - throw new RangeError('Date.prototype.toISOString called on non-finite value.'); - } - - var year = originalGetUTCFullYear(this); - - var month = originalGetUTCMonth(this); - // see https://github.com/es-shims/es5-shim/issues/111 - year += floor(month / 12); - month = ((month % 12) + 12) % 12; - - // the date time string format is specified in 15.9.1.15. - var result = [ - month + 1, - originalGetUTCDate(this), - originalGetUTCHours(this), - originalGetUTCMinutes(this), - originalGetUTCSeconds(this) - ]; - year = ( - (year < 0 ? '-' : (year > 9999 ? '+' : '')) - + strSlice('00000' + abs(year), (0 <= year && year <= 9999) ? -4 : -6) - ); - - for (var i = 0; i < result.length; ++i) { - // pad months, days, hours, minutes, and seconds to have two digits. - result[i] = strSlice('00' + result[i], -2); - } - // pad milliseconds to have three digits. - return ( - year + '-' + arraySlice(result, 0, 2).join('-') - + 'T' + arraySlice(result, 2).join(':') + '.' - + strSlice('000' + originalGetUTCMilliseconds(this), -3) + 'Z' - ); - } - }, hasNegativeDateBug || hasSafari51DateBug); - - // ES5 15.9.5.44 - // http://es5.github.com/#x15.9.5.44 - // This function provides a String representation of a Date object for use by - // JSON.stringify (15.12.3). - var dateToJSONIsSupported = (function () { - try { - return Date.prototype.toJSON - && new Date(NaN).toJSON() === null - && new Date(negativeDate).toJSON().indexOf(negativeYearString) !== -1 - && Date.prototype.toJSON.call({ // generic - toISOString: function () { return true; } - }); - } catch (e) { - return false; - } - }()); - if (!dateToJSONIsSupported) { - Date.prototype.toJSON = function toJSON(key) { - // When the toJSON method is called with argument key, the following - // steps are taken: - - // 1. Let O be the result of calling ToObject, giving it the this - // value as its argument. - // 2. Let tv be ES.ToPrimitive(O, hint Number). - var O = $Object(this); - var tv = ES.ToPrimitive(O); - // 3. If tv is a Number and is not finite, return null. - if (typeof tv === 'number' && !isFinite(tv)) { - return null; - } - // 4. Let toISO be the result of calling the [[Get]] internal method of - // O with argument "toISOString". - var toISO = O.toISOString; - // 5. If IsCallable(toISO) is false, throw a TypeError exception. - if (!isCallable(toISO)) { - throw new TypeError('toISOString property is not callable'); - } - // 6. Return the result of calling the [[Call]] internal method of - // toISO with O as the this value and an empty argument list. - return toISO.call(O); - - // NOTE 1 The argument is ignored. - - // NOTE 2 The toJSON function is intentionally generic; it does not - // require that its this value be a Date object. Therefore, it can be - // transferred to other kinds of objects for use as a method. However, - // it does require that any such object have a toISOString method. An - // object is free to use the argument key to filter its - // stringification. - }; - } - - // ES5 15.9.4.2 - // http://es5.github.com/#x15.9.4.2 - // based on work shared by Daniel Friesen (dantman) - // http://gist.github.com/303249 - var supportsExtendedYears = Date.parse('+033658-09-27T01:46:40.000Z') === 1e15; - var acceptsInvalidDates = !isNaN(Date.parse('2012-04-04T24:00:00.500Z')) || !isNaN(Date.parse('2012-11-31T23:59:59.000Z')) || !isNaN(Date.parse('2012-12-31T23:59:60.000Z')); - var doesNotParseY2KNewYear = isNaN(Date.parse('2000-01-01T00:00:00.000Z')); - if (doesNotParseY2KNewYear || acceptsInvalidDates || !supportsExtendedYears) { - // XXX global assignment won't work in embeddings that use - // an alternate object for the context. - var maxSafeUnsigned32Bit = pow(2, 31) - 1; - var hasSafariSignedIntBug = isActualNaN(new Date(1970, 0, 1, 0, 0, 0, maxSafeUnsigned32Bit + 1).getTime()); - // eslint-disable-next-line no-implicit-globals, no-global-assign - Date = (function (NativeDate) { - // Date.length === 7 - var DateShim = function Date(Y, M, D, h, m, s, ms) { - var length = arguments.length; - var date; - if (this instanceof NativeDate) { - var seconds = s; - var millis = ms; - if (hasSafariSignedIntBug && length >= 7 && ms > maxSafeUnsigned32Bit) { - // work around a Safari 8/9 bug where it treats the seconds as signed - var msToShift = floor(ms / maxSafeUnsigned32Bit) * maxSafeUnsigned32Bit; - var sToShift = floor(msToShift / 1e3); - seconds += sToShift; - millis -= sToShift * 1e3; - } - date = length === 1 && $String(Y) === Y // isString(Y) - // We explicitly pass it through parse: - ? new NativeDate(DateShim.parse(Y)) - // We have to manually make calls depending on argument - // length here - : length >= 7 ? new NativeDate(Y, M, D, h, m, seconds, millis) - : length >= 6 ? new NativeDate(Y, M, D, h, m, seconds) - : length >= 5 ? new NativeDate(Y, M, D, h, m) - : length >= 4 ? new NativeDate(Y, M, D, h) - : length >= 3 ? new NativeDate(Y, M, D) - : length >= 2 ? new NativeDate(Y, M) - : length >= 1 ? new NativeDate(Y instanceof NativeDate ? +Y : Y) - : new NativeDate(); - } else { - date = NativeDate.apply(this, arguments); - } - if (!isPrimitive(date)) { - // Prevent mixups with unfixed Date object - defineProperties(date, { constructor: DateShim }, true); - } - return date; - }; - - // 15.9.1.15 Date Time String Format. - var isoDateExpression = new RegExp('^' - + '(\\d{4}|[+-]\\d{6})' // four-digit year capture or sign + 6-digit extended year - + '(?:-(\\d{2})' // optional month capture - + '(?:-(\\d{2})' // optional day capture - + '(?:' // capture hours:minutes:seconds.milliseconds - + 'T(\\d{2})' // hours capture - + ':(\\d{2})' // minutes capture - + '(?:' // optional :seconds.milliseconds - + ':(\\d{2})' // seconds capture - + '(?:(\\.\\d{1,}))?' // milliseconds capture - + ')?' - + '(' // capture UTC offset component - + 'Z|' // UTC capture - + '(?:' // offset specifier +/-hours:minutes - + '([-+])' // sign capture - + '(\\d{2})' // hours offset capture - + ':(\\d{2})' // minutes offset capture - + ')' - + ')?)?)?)?' - + '$'); - - var months = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365]; - - var dayFromMonth = function dayFromMonth(year, month) { - var t = month > 1 ? 1 : 0; - return ( - months[month] - + floor((year - 1969 + t) / 4) - - floor((year - 1901 + t) / 100) - + floor((year - 1601 + t) / 400) - + (365 * (year - 1970)) - ); - }; - - var toUTC = function toUTC(t) { - var s = 0; - var ms = t; - if (hasSafariSignedIntBug && ms > maxSafeUnsigned32Bit) { - // work around a Safari 8/9 bug where it treats the seconds as signed - var msToShift = floor(ms / maxSafeUnsigned32Bit) * maxSafeUnsigned32Bit; - var sToShift = floor(msToShift / 1e3); - s += sToShift; - ms -= sToShift * 1e3; - } - return $Number(new NativeDate(1970, 0, 1, 0, 0, s, ms)); - }; - - // Copy any custom methods a 3rd party library may have added - for (var key in NativeDate) { - if (owns(NativeDate, key)) { - DateShim[key] = NativeDate[key]; - } - } - - // Copy "native" methods explicitly; they may be non-enumerable - defineProperties(DateShim, { - now: NativeDate.now, - UTC: NativeDate.UTC - }, true); - DateShim.prototype = NativeDate.prototype; - defineProperties(DateShim.prototype, { constructor: DateShim }, true); - - // Upgrade Date.parse to handle simplified ISO 8601 strings - var parseShim = function parse(string) { - var match = isoDateExpression.exec(string); - if (match) { - // parse months, days, hours, minutes, seconds, and milliseconds - // provide default values if necessary - // parse the UTC offset component - var year = $Number(match[1]), - month = $Number(match[2] || 1) - 1, - day = $Number(match[3] || 1) - 1, - hour = $Number(match[4] || 0), - minute = $Number(match[5] || 0), - second = $Number(match[6] || 0), - millisecond = floor($Number(match[7] || 0) * 1000), - // When time zone is missed, local offset should be used - // (ES 5.1 bug) - // see https://bugs.ecmascript.org/show_bug.cgi?id=112 - isLocalTime = Boolean(match[4] && !match[8]), - signOffset = match[9] === '-' ? 1 : -1, - hourOffset = $Number(match[10] || 0), - minuteOffset = $Number(match[11] || 0), - result; - var hasMinutesOrSecondsOrMilliseconds = minute > 0 || second > 0 || millisecond > 0; - if ( - hour < (hasMinutesOrSecondsOrMilliseconds ? 24 : 25) - && minute < 60 && second < 60 && millisecond < 1000 - && month > -1 && month < 12 && hourOffset < 24 - && minuteOffset < 60 // detect invalid offsets - && day > -1 - && day < (dayFromMonth(year, month + 1) - dayFromMonth(year, month)) - ) { - result = ( - ((dayFromMonth(year, month) + day) * 24) - + hour - + (hourOffset * signOffset) - ) * 60; - result = (( - ((result + minute + (minuteOffset * signOffset)) * 60) - + second - ) * 1000) + millisecond; - if (isLocalTime) { - result = toUTC(result); - } - if (-8.64e15 <= result && result <= 8.64e15) { - return result; - } - } - return NaN; - } - return NativeDate.parse.apply(this, arguments); - }; - defineProperties(DateShim, { parse: parseShim }); - - return DateShim; - }(Date)); - } - - // ES5 15.9.4.4 - // http://es5.github.com/#x15.9.4.4 - if (!Date.now) { - Date.now = function now() { - return new Date().getTime(); - }; - } - - // - // Number - // ====== - // - - // ES5.1 15.7.4.5 - // http://es5.github.com/#x15.7.4.5 - var hasToFixedBugs = NumberPrototype.toFixed && ( - (0.00008).toFixed(3) !== '0.000' - || (0.9).toFixed(0) !== '1' - || (1.255).toFixed(2) !== '1.25' - || (1000000000000000128).toFixed(0) !== '1000000000000000128' - ); - - var toFixedHelpers = { - base: 1e7, - size: 6, - data: [0, 0, 0, 0, 0, 0], - multiply: function multiply(n, c) { - var i = -1; - var c2 = c; - while (++i < toFixedHelpers.size) { - c2 += n * toFixedHelpers.data[i]; - toFixedHelpers.data[i] = c2 % toFixedHelpers.base; - c2 = floor(c2 / toFixedHelpers.base); - } - }, - divide: function divide(n) { - var i = toFixedHelpers.size; - var c = 0; - while (--i >= 0) { - c += toFixedHelpers.data[i]; - toFixedHelpers.data[i] = floor(c / n); - c = (c % n) * toFixedHelpers.base; - } - }, - numToString: function numToString() { - var i = toFixedHelpers.size; - var s = ''; - while (--i >= 0) { - if (s !== '' || i === 0 || toFixedHelpers.data[i] !== 0) { - var t = $String(toFixedHelpers.data[i]); - if (s === '') { - s = t; - } else { - s += strSlice('0000000', 0, 7 - t.length) + t; - } - } - } - return s; - }, - pow: function pow(x, n, acc) { - return (n === 0 ? acc : (n % 2 === 1 ? pow(x, n - 1, acc * x) : pow(x * x, n / 2, acc))); - }, - log: function log(x) { - var n = 0; - var x2 = x; - while (x2 >= 4096) { - n += 12; - x2 /= 4096; - } - while (x2 >= 2) { - n += 1; - x2 /= 2; - } - return n; - } - }; - - var toFixedShim = function toFixed(fractionDigits) { - var f, x, s, m, e, z, j, k; - - // Test for NaN and round fractionDigits down - f = $Number(fractionDigits); - f = isActualNaN(f) ? 0 : floor(f); - - if (f < 0 || f > 20) { - throw new RangeError('Number.toFixed called with invalid number of decimals'); - } - - x = $Number(this); - - if (isActualNaN(x)) { - return 'NaN'; - } - - // If it is too big or small, return the string value of the number - if (x <= -1e21 || x >= 1e21) { - return $String(x); - } - - s = ''; - - if (x < 0) { - s = '-'; - x = -x; - } - - m = '0'; - - if (x > 1e-21) { - // 1e-21 < x < 1e21 - // -70 < log2(x) < 70 - e = toFixedHelpers.log(x * toFixedHelpers.pow(2, 69, 1)) - 69; - z = (e < 0 ? x * toFixedHelpers.pow(2, -e, 1) : x / toFixedHelpers.pow(2, e, 1)); - z *= 0x10000000000000; // pow(2, 52); - e = 52 - e; - - // -18 < e < 122 - // x = z / 2 ^ e - if (e > 0) { - toFixedHelpers.multiply(0, z); - j = f; - - while (j >= 7) { - toFixedHelpers.multiply(1e7, 0); - j -= 7; - } - - toFixedHelpers.multiply(toFixedHelpers.pow(10, j, 1), 0); - j = e - 1; - - while (j >= 23) { - toFixedHelpers.divide(1 << 23); - j -= 23; - } - - toFixedHelpers.divide(1 << j); - toFixedHelpers.multiply(1, 1); - toFixedHelpers.divide(2); - m = toFixedHelpers.numToString(); - } else { - toFixedHelpers.multiply(0, z); - toFixedHelpers.multiply(1 << (-e), 0); - m = toFixedHelpers.numToString() + strSlice('0.00000000000000000000', 2, 2 + f); - } - } - - if (f > 0) { - k = m.length; - - if (k <= f) { - m = s + strSlice('0.0000000000000000000', 0, f - k + 2) + m; - } else { - m = s + strSlice(m, 0, k - f) + '.' + strSlice(m, k - f); - } - } else { - m = s + m; - } - - return m; - }; - defineProperties(NumberPrototype, { toFixed: toFixedShim }, hasToFixedBugs); - - var hasToPrecisionUndefinedBug = (function () { - try { - return 1.0.toPrecision(undefined) === '1'; - } catch (e) { - return true; - } - }()); - var originalToPrecision = NumberPrototype.toPrecision; - defineProperties(NumberPrototype, { - toPrecision: function toPrecision(precision) { - return typeof precision === 'undefined' ? originalToPrecision.call(this) : originalToPrecision.call(this, precision); - } - }, hasToPrecisionUndefinedBug); - - // - // String - // ====== - // - - // ES5 15.5.4.14 - // http://es5.github.com/#x15.5.4.14 - - // [bugfix, IE lt 9, firefox 4, Konqueror, Opera, obscure browsers] - // Many browsers do not split properly with regular expressions or they - // do not perform the split correctly under obscure conditions. - // See http://blog.stevenlevithan.com/archives/cross-browser-split - // I've tested in many browsers and this seems to cover the deviant ones: - // 'ab'.split(/(?:ab)*/) should be ["", ""], not [""] - // '.'.split(/(.?)(.?)/) should be ["", ".", "", ""], not ["", ""] - // 'tesst'.split(/(s)*/) should be ["t", undefined, "e", "s", "t"], not - // [undefined, "t", undefined, "e", ...] - // ''.split(/.?/) should be [], not [""] - // '.'.split(/()()/) should be ["."], not ["", "", "."] - - if ( - 'ab'.split(/(?:ab)*/).length !== 2 - || '.'.split(/(.?)(.?)/).length !== 4 - || 'tesst'.split(/(s)*/)[1] === 't' - || 'test'.split(/(?:)/, -1).length !== 4 - || ''.split(/.?/).length - || '.'.split(/()()/).length > 1 - ) { - (function () { - var compliantExecNpcg = typeof (/()??/).exec('')[1] === 'undefined'; // NPCG: nonparticipating capturing group - var maxSafe32BitInt = pow(2, 32) - 1; - - StringPrototype.split = function split(separator, limit) { - var string = String(this); - if (typeof separator === 'undefined' && limit === 0) { - return []; - } - - // If `separator` is not a regex, use native split - if (!isRegex(separator)) { - return strSplit(this, separator, limit); - } - - var output = []; - var flags = (separator.ignoreCase ? 'i' : '') - + (separator.multiline ? 'm' : '') - + (separator.unicode ? 'u' : '') // in ES6 - + (separator.sticky ? 'y' : ''), // Firefox 3+ and ES6 - lastLastIndex = 0, - // Make `global` and avoid `lastIndex` issues by working with a copy - separator2, match, lastIndex, lastLength; - var separatorCopy = new RegExp(separator.source, flags + 'g'); - if (!compliantExecNpcg) { - // Doesn't need flags gy, but they don't hurt - separator2 = new RegExp('^' + separatorCopy.source + '$(?!\\s)', flags); - } - /* Values for `limit`, per the spec: - * If undefined: 4294967295 // maxSafe32BitInt - * If 0, Infinity, or NaN: 0 - * If positive number: limit = floor(limit); if (limit > 4294967295) limit -= 4294967296; - * If negative number: 4294967296 - floor(abs(limit)) - * If other: Type-convert, then use the above rules - */ - var splitLimit = typeof limit === 'undefined' ? maxSafe32BitInt : ES.ToUint32(limit); - match = separatorCopy.exec(string); - while (match) { - // `separatorCopy.lastIndex` is not reliable cross-browser - lastIndex = match.index + match[0].length; - if (lastIndex > lastLastIndex) { - pushCall(output, strSlice(string, lastLastIndex, match.index)); - // Fix browsers whose `exec` methods don't consistently return `undefined` for - // nonparticipating capturing groups - if (!compliantExecNpcg && match.length > 1) { - /* eslint-disable no-loop-func */ - match[0].replace(separator2, function () { - for (var i = 1; i < arguments.length - 2; i++) { - if (typeof arguments[i] === 'undefined') { - match[i] = void 0; - } - } - }); - /* eslint-enable no-loop-func */ - } - if (match.length > 1 && match.index < string.length) { - array_push.apply(output, arraySlice(match, 1)); - } - lastLength = match[0].length; - lastLastIndex = lastIndex; - if (output.length >= splitLimit) { - break; - } - } - if (separatorCopy.lastIndex === match.index) { - separatorCopy.lastIndex++; // Avoid an infinite loop - } - match = separatorCopy.exec(string); - } - if (lastLastIndex === string.length) { - if (lastLength || !separatorCopy.test('')) { - pushCall(output, ''); - } - } else { - pushCall(output, strSlice(string, lastLastIndex)); - } - return output.length > splitLimit ? arraySlice(output, 0, splitLimit) : output; - }; - }()); - - // [bugfix, chrome] - // If separator is undefined, then the result array contains just one String, - // which is the this value (converted to a String). If limit is not undefined, - // then the output array is truncated so that it contains no more than limit - // elements. - // "0".split(undefined, 0) -> [] - } else if ('0'.split(void 0, 0).length) { - StringPrototype.split = function split(separator, limit) { - if (typeof separator === 'undefined' && limit === 0) { - return []; - } - return strSplit(this, separator, limit); - }; - } - - var str_replace = StringPrototype.replace; - var replaceReportsGroupsCorrectly = (function () { - var groups = []; - 'x'.replace(/x(.)?/g, function (match, group) { - pushCall(groups, group); - }); - return groups.length === 1 && typeof groups[0] === 'undefined'; - }()); - - if (!replaceReportsGroupsCorrectly) { - StringPrototype.replace = function replace(searchValue, replaceValue) { - var isFn = isCallable(replaceValue); - var hasCapturingGroups = isRegex(searchValue) && (/\)[*?]/).test(searchValue.source); - if (!isFn || !hasCapturingGroups) { - return str_replace.call(this, searchValue, replaceValue); - } else { - var wrappedReplaceValue = function (match) { - var length = arguments.length; - var originalLastIndex = searchValue.lastIndex; - searchValue.lastIndex = 0; // eslint-disable-line no-param-reassign - var args = searchValue.exec(match) || []; - searchValue.lastIndex = originalLastIndex; // eslint-disable-line no-param-reassign - pushCall(args, arguments[length - 2], arguments[length - 1]); - return replaceValue.apply(this, args); - }; - return str_replace.call(this, searchValue, wrappedReplaceValue); - } - }; - } - - // ECMA-262, 3rd B.2.3 - // Not an ECMAScript standard, although ECMAScript 3rd Edition has a - // non-normative section suggesting uniform semantics and it should be - // normalized across all browsers - // [bugfix, IE lt 9] IE < 9 substr() with negative value not working in IE - var string_substr = StringPrototype.substr; - var hasNegativeSubstrBug = ''.substr && '0b'.substr(-1) !== 'b'; - defineProperties(StringPrototype, { - substr: function substr(start, length) { - var normalizedStart = start; - if (start < 0) { - normalizedStart = max(this.length + start, 0); - } - return string_substr.call(this, normalizedStart, length); - } - }, hasNegativeSubstrBug); - - // ES5 15.5.4.20 - // whitespace from: http://es5.github.io/#x15.5.4.20 - var ws = '\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003' - + '\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028' - + '\u2029\uFEFF'; - var zeroWidth = '\u200b'; - var wsRegexChars = '[' + ws + ']'; - var trimBeginRegexp = new RegExp('^' + wsRegexChars + wsRegexChars + '*'); - var trimEndRegexp = new RegExp(wsRegexChars + wsRegexChars + '*$'); - var hasTrimWhitespaceBug = StringPrototype.trim && (ws.trim() || !zeroWidth.trim()); - defineProperties(StringPrototype, { - // http://blog.stevenlevithan.com/archives/faster-trim-javascript - // http://perfectionkills.com/whitespace-deviations/ - trim: function trim() { - if (typeof this === 'undefined' || this === null) { - throw new TypeError("can't convert " + this + ' to object'); - } - return $String(this).replace(trimBeginRegexp, '').replace(trimEndRegexp, ''); - } - }, hasTrimWhitespaceBug); - var trim = call.bind(String.prototype.trim); - - var hasLastIndexBug = StringPrototype.lastIndexOf && 'abcあい'.lastIndexOf('あい', 2) !== -1; - defineProperties(StringPrototype, { - lastIndexOf: function lastIndexOf(searchString) { - if (typeof this === 'undefined' || this === null) { - throw new TypeError("can't convert " + this + ' to object'); - } - var S = $String(this); - var searchStr = $String(searchString); - var numPos = arguments.length > 1 ? $Number(arguments[1]) : NaN; - var pos = isActualNaN(numPos) ? Infinity : ES.ToInteger(numPos); - var start = min(max(pos, 0), S.length); - var searchLen = searchStr.length; - var k = start + searchLen; - while (k > 0) { - k = max(0, k - searchLen); - var index = strIndexOf(strSlice(S, k, start + searchLen), searchStr); - if (index !== -1) { - return k + index; - } - } - return -1; - } - }, hasLastIndexBug); - - var originalLastIndexOf = StringPrototype.lastIndexOf; - defineProperties(StringPrototype, { - lastIndexOf: function lastIndexOf(searchString) { - return originalLastIndexOf.apply(this, arguments); - } - }, StringPrototype.lastIndexOf.length !== 1); - - // ES-5 15.1.2.2 - // eslint-disable-next-line radix - if (parseInt(ws + '08') !== 8 || parseInt(ws + '0x16') !== 22) { - // eslint-disable-next-line no-global-assign, no-implicit-globals - parseInt = (function (origParseInt) { - var hexRegex = /^[-+]?0[xX]/; - return function parseInt(str, radix) { - if (typeof str === 'symbol') { - // handle Symbols in node 8.3/8.4 - // eslint-disable-next-line no-implicit-coercion, no-unused-expressions - '' + str; // jscs:ignore disallowImplicitTypeConversion - } - - var string = trim(String(str)); - var defaultedRadix = $Number(radix) || (hexRegex.test(string) ? 16 : 10); - return origParseInt(string, defaultedRadix); - }; - }(parseInt)); - } - - // https://es5.github.io/#x15.1.2.3 - if (1 / parseFloat('-0') !== -Infinity) { - // eslint-disable-next-line no-global-assign, no-implicit-globals, no-native-reassign - parseFloat = (function (origParseFloat) { - return function parseFloat(string) { - var inputString = trim(String(string)); - var result = origParseFloat(inputString); - return result === 0 && strSlice(inputString, 0, 1) === '-' ? -0 : result; - }; - }(parseFloat)); - } - - if (String(new RangeError('test')) !== 'RangeError: test') { - var errorToStringShim = function toString() { - if (typeof this === 'undefined' || this === null) { - throw new TypeError("can't convert " + this + ' to object'); - } - var name = this.name; - if (typeof name === 'undefined') { - name = 'Error'; - } else if (typeof name !== 'string') { - name = $String(name); - } - var msg = this.message; - if (typeof msg === 'undefined') { - msg = ''; - } else if (typeof msg !== 'string') { - msg = $String(msg); - } - if (!name) { - return msg; - } - if (!msg) { - return name; - } - return name + ': ' + msg; - }; - // can't use defineProperties here because of toString enumeration issue in IE <= 8 - Error.prototype.toString = errorToStringShim; - } - - if (supportsDescriptors) { - var ensureNonEnumerable = function (obj, prop) { - if (isEnum(obj, prop)) { - var desc = Object.getOwnPropertyDescriptor(obj, prop); - if (desc.configurable) { - desc.enumerable = false; - Object.defineProperty(obj, prop, desc); - } - } - }; - ensureNonEnumerable(Error.prototype, 'message'); - if (Error.prototype.message !== '') { - Error.prototype.message = ''; - } - ensureNonEnumerable(Error.prototype, 'name'); - } - - if (String(/a/mig) !== '/a/gim') { - var regexToString = function toString() { - var str = '/' + this.source + '/'; - if (this.global) { - str += 'g'; - } - if (this.ignoreCase) { - str += 'i'; - } - if (this.multiline) { - str += 'm'; - } - return str; - }; - // can't use defineProperties here because of toString enumeration issue in IE <= 8 - RegExp.prototype.toString = regexToString; - } -})); -}(es5Shim)); +var es5Shim = es5Shim$1.exports; + +var hasRequiredEs5Shim; + +function requireEs5Shim () { + if (hasRequiredEs5Shim) return es5Shim$1.exports; + hasRequiredEs5Shim = 1; + (function (module, exports$1) { + + // UMD (Universal Module Definition) + // see https://github.com/umdjs/umd/blob/master/templates/returnExports.js + (function (root, factory) { + + /* global define */ + { + // Node. Does not work with strict CommonJS, but + // only CommonJS-like enviroments that support module.exports, + // like Node. + module.exports = factory(); + } + }(es5Shim, function () { + /** + * Brings an environment as close to ECMAScript 5 compliance + * as is possible with the facilities of erstwhile engines. + * + * Annotated ES5: https://es5.github.io/ (specific links below) + * ES5 Spec: https://www.ecma-international.org/wp-content/uploads/ECMA-262_5.1_edition_june_2011.pdf + * Required reading: https://javascriptweblog.wordpress.com/2011/12/05/extending-javascript-natives/ + */ + + // Shortcut to an often accessed properties, in order to avoid multiple + // dereference that costs universally. This also holds a reference to known-good + // functions. + var $Array = Array; + var ArrayPrototype = $Array.prototype; + var $Object = Object; + var ObjectPrototype = $Object.prototype; + var $Function = Function; + var FunctionPrototype = $Function.prototype; + var $String = String; + var StringPrototype = $String.prototype; + var $Number = Number; + var NumberPrototype = $Number.prototype; + var array_slice = ArrayPrototype.slice; + var array_splice = ArrayPrototype.splice; + var array_push = ArrayPrototype.push; + var array_unshift = ArrayPrototype.unshift; + var array_concat = ArrayPrototype.concat; + var array_join = ArrayPrototype.join; + var call = FunctionPrototype.call; + var apply = FunctionPrototype.apply; + var max = Math.max; + var min = Math.min; + var floor = Math.floor; + var abs = Math.abs; + var pow = Math.pow; + var round = Math.round; + var log = Math.log; + var LOG10E = Math.LOG10E; + var log10 = Math.log10 || function log10(value) { + return log(value) * LOG10E; + }; + + // Having a toString local variable name breaks in Opera so use to_string. + var to_string = ObjectPrototype.toString; + + /* eslint-disable one-var-declaration-per-line, no-redeclare, max-statements-per-line */ + var hasToStringTag = typeof Symbol === 'function' && typeof Symbol.toStringTag === 'symbol'; + var isCallable; /* inlined from https://npmjs.com/is-callable */ var fnToStr = Function.prototype.toString, constructorRegex = /^\s*class /, isES6ClassFn = function isES6ClassFn(value) { try { var fnStr = fnToStr.call(value); var singleStripped = fnStr.replace(/\/\/.*\n/g, ''); var multiStripped = singleStripped.replace(/\/\*[.\s\S]*\*\//g, ''); var spaceStripped = multiStripped.replace(/\n/mg, ' ').replace(/ {2}/g, ' '); return constructorRegex.test(spaceStripped); } catch (e) { return false; /* not a function */ } }, tryFunctionObject = function tryFunctionObject(value) { try { if (isES6ClassFn(value)) { return false; } fnToStr.call(value); return true; } catch (e) { return false; } }, fnClass = '[object Function]', genClass = '[object GeneratorFunction]', isCallable = function isCallable(value) { if (!value) { return false; } if (typeof value !== 'function' && typeof value !== 'object') { return false; } if (hasToStringTag) { return tryFunctionObject(value); } if (isES6ClassFn(value)) { return false; } var strClass = to_string.call(value); return strClass === fnClass || strClass === genClass; }; + + var isRegex; /* inlined from https://npmjs.com/is-regex */ var regexExec = RegExp.prototype.exec, tryRegexExec = function tryRegexExec(value) { try { regexExec.call(value); return true; } catch (e) { return false; } }, regexClass = '[object RegExp]'; isRegex = function isRegex(value) { if (typeof value !== 'object') { return false; } return hasToStringTag ? tryRegexExec(value) : to_string.call(value) === regexClass; }; + var isString; /* inlined from https://npmjs.com/is-string */ var strValue = String.prototype.valueOf, tryStringObject = function tryStringObject(value) { try { strValue.call(value); return true; } catch (e) { return false; } }, stringClass = '[object String]'; isString = function isString(value) { if (typeof value === 'string') { return true; } if (typeof value !== 'object') { return false; } return hasToStringTag ? tryStringObject(value) : to_string.call(value) === stringClass; }; + /* eslint-enable one-var-declaration-per-line, no-redeclare, max-statements-per-line */ + + /* inlined from https://npmjs.com/define-properties */ + var supportsDescriptors = $Object.defineProperty && (function () { + try { + var obj = {}; + $Object.defineProperty(obj, 'x', { enumerable: false, value: obj }); + // eslint-disable-next-line no-unreachable-loop, max-statements-per-line + for (var _ in obj) { return false; } // jscs:ignore disallowUnusedVariables + return obj.x === obj; + } catch (e) { /* this is ES3 */ + return false; + } + }()); + var defineProperties = (function (has) { + // Define configurable, writable, and non-enumerable props + // if they don't exist. + var defineProperty; + if (supportsDescriptors) { + defineProperty = function (object, name, method, forceAssign) { + if (!forceAssign && (name in object)) { + return; + } + $Object.defineProperty(object, name, { + configurable: true, + enumerable: false, + writable: true, + value: method + }); + }; + } else { + defineProperty = function (object, name, method, forceAssign) { + if (!forceAssign && (name in object)) { + return; + } + object[name] = method; // eslint-disable-line no-param-reassign + }; + } + return function defineProperties(object, map, forceAssign) { + for (var name in map) { + if (has.call(map, name)) { + defineProperty(object, name, map[name], forceAssign); + } + } + }; + }(ObjectPrototype.hasOwnProperty)); + + // this is needed in Chrome 15 (probably earlier) - 36 + // https://bugs.chromium.org/p/v8/issues/detail?id=3334 + if ($Object.defineProperty && supportsDescriptors) { + var F = function () {}; + var toStringSentinel = {}; + var sentinel = { toString: toStringSentinel }; + $Object.defineProperty(F, 'prototype', { value: sentinel, writable: false }); + if ((new F()).toString !== toStringSentinel) { + var $dP = $Object.defineProperty; + var $gOPD = $Object.getOwnPropertyDescriptor; + defineProperties($Object, { + defineProperty: function defineProperty(o, k, d) { + var key = $String(k); + if (typeof o === 'function' && key === 'prototype') { + var desc = $gOPD(o, key); + if (desc.writable && !d.writable && 'value' in d) { + try { + o[key] = d.value; // eslint-disable-line no-param-reassign + } catch (e) { /**/ } + } + return $dP(o, key, { + configurable: 'configurable' in d ? d.configurable : desc.configurable, + enumerable: 'enumerable' in d ? d.enumerable : desc.enumerable, + writable: d.writable + }); + } + return $dP(o, key, d); + } + }, true); + } + } + + // + // Util + // ====== + // + + /* replaceable with https://npmjs.com/package/es-abstract /helpers/isPrimitive */ + var isPrimitive = function isPrimitive(input) { + var type = typeof input; + return input === null || (type !== 'object' && type !== 'function'); + }; + + var isActualNaN = $Number.isNaN || function isActualNaN(x) { + return x !== x; + }; + + var ES = { + // ES5 9.4 + // https://es5.github.io/#x9.4 + // http://jsperf.com/to-integer + /* replaceable with https://npmjs.com/package/es-abstract ES5.ToInteger */ + ToInteger: function ToInteger(num) { + var n = +num; + if (isActualNaN(n)) { + n = 0; + } else if (n !== 0 && n !== (1 / 0) && n !== -Infinity) { + n = (n > 0 || -1) * floor(abs(n)); + } + return n; + }, + + /* replaceable with https://npmjs.com/package/es-abstract ES5.ToPrimitive */ + ToPrimitive: function ToPrimitive(input) { + var val, valueOf, toStr; + if (isPrimitive(input)) { + return input; + } + valueOf = input.valueOf; + if (isCallable(valueOf)) { + val = valueOf.call(input); + if (isPrimitive(val)) { + return val; + } + } + toStr = input.toString; + if (isCallable(toStr)) { + val = toStr.call(input); + if (isPrimitive(val)) { + return val; + } + } + throw new TypeError(); + }, + + // ES5 9.9 + // https://es5.github.io/#x9.9 + /* replaceable with https://npmjs.com/package/es-abstract ES5.ToObject */ + ToObject: function (o) { + if (o == null) { // this matches both null and undefined + throw new TypeError("can't convert " + o + ' to object'); + } + return $Object(o); + }, + + /* replaceable with https://npmjs.com/package/es-abstract ES5.ToUint32 */ + ToUint32: function ToUint32(x) { + return x >>> 0; + } + }; + + // + // Function + // ======== + // + + // ES-5 15.3.4.5 + // https://es5.github.io/#x15.3.4.5 + + var Empty = function Empty() {}; + + defineProperties(FunctionPrototype, { + bind: function bind(that) { // .length is 1 + // 1. Let Target be the this value. + var target = this; + // 2. If IsCallable(Target) is false, throw a TypeError exception. + if (!isCallable(target)) { + throw new TypeError('Function.prototype.bind called on incompatible ' + target); + } + // 3. Let A be a new (possibly empty) internal list of all of the + // argument values provided after thisArg (arg1, arg2 etc), in order. + // XXX slicedArgs will stand in for "A" if used + var args = array_slice.call(arguments, 1); // for normal call + // 4. Let F be a new native ECMAScript object. + // 11. Set the [[Prototype]] internal property of F to the standard + // built-in Function prototype object as specified in 15.3.3.1. + // 12. Set the [[Call]] internal property of F as described in + // 15.3.4.5.1. + // 13. Set the [[Construct]] internal property of F as described in + // 15.3.4.5.2. + // 14. Set the [[HasInstance]] internal property of F as described in + // 15.3.4.5.3. + var bound; + var binder = function () { + + if (this instanceof bound) { + // 15.3.4.5.2 [[Construct]] + // When the [[Construct]] internal method of a function object, + // F that was created using the bind function is called with a + // list of arguments ExtraArgs, the following steps are taken: + // 1. Let target be the value of F's [[TargetFunction]] + // internal property. + // 2. If target has no [[Construct]] internal method, a + // TypeError exception is thrown. + // 3. Let boundArgs be the value of F's [[BoundArgs]] internal + // property. + // 4. Let args be a new list containing the same values as the + // list boundArgs in the same order followed by the same + // values as the list ExtraArgs in the same order. + // 5. Return the result of calling the [[Construct]] internal + // method of target providing args as the arguments. + + var result = apply.call( + target, + this, + array_concat.call(args, array_slice.call(arguments)) + ); + if ($Object(result) === result) { + return result; + } + return this; + + } + // 15.3.4.5.1 [[Call]] + // When the [[Call]] internal method of a function object, F, + // which was created using the bind function is called with a + // this value and a list of arguments ExtraArgs, the following + // steps are taken: + // 1. Let boundArgs be the value of F's [[BoundArgs]] internal + // property. + // 2. Let boundThis be the value of F's [[BoundThis]] internal + // property. + // 3. Let target be the value of F's [[TargetFunction]] internal + // property. + // 4. Let args be a new list containing the same values as the + // list boundArgs in the same order followed by the same + // values as the list ExtraArgs in the same order. + // 5. Return the result of calling the [[Call]] internal method + // of target providing boundThis as the this value and + // providing args as the arguments. + + // equiv: target.call(this, ...boundArgs, ...args) + return apply.call( + target, + that, + array_concat.call(args, array_slice.call(arguments)) + ); + + }; + + // 15. If the [[Class]] internal property of Target is "Function", then + // a. Let L be the length property of Target minus the length of A. + // b. Set the length own property of F to either 0 or L, whichever is + // larger. + // 16. Else set the length own property of F to 0. + + var boundLength = max(0, target.length - args.length); + + // 17. Set the attributes of the length own property of F to the values + // specified in 15.3.5.1. + var boundArgs = []; + for (var i = 0; i < boundLength; i++) { + array_push.call(boundArgs, '$' + i); + } + + // XXX Build a dynamic function with desired amount of arguments is the only + // way to set the length property of a function. + // In environments where Content Security Policies enabled (Chrome extensions, + // for ex.) all use of eval or Function costructor throws an exception. + // However in all of these environments Function.prototype.bind exists + // and so this code will never be executed. + bound = $Function('binder', 'return function (' + array_join.call(boundArgs, ',') + '){ return binder.apply(this, arguments); }')(binder); + + if (target.prototype) { + Empty.prototype = target.prototype; + bound.prototype = new Empty(); + // Clean up dangling references. + Empty.prototype = null; + } + + // TODO + // 18. Set the [[Extensible]] internal property of F to true. + + // TODO + // 19. Let thrower be the [[ThrowTypeError]] function Object (13.2.3). + // 20. Call the [[DefineOwnProperty]] internal method of F with + // arguments "caller", PropertyDescriptor {[[Get]]: thrower, [[Set]]: + // thrower, [[Enumerable]]: false, [[Configurable]]: false}, and + // false. + // 21. Call the [[DefineOwnProperty]] internal method of F with + // arguments "arguments", PropertyDescriptor {[[Get]]: thrower, + // [[Set]]: thrower, [[Enumerable]]: false, [[Configurable]]: false}, + // and false. + + // TODO + // NOTE Function objects created using Function.prototype.bind do not + // have a prototype property or the [[Code]], [[FormalParameters]], and + // [[Scope]] internal properties. + // XXX can't delete prototype in pure-js. + + // 22. Return F. + return bound; + } + }); + + // _Please note: Shortcuts are defined after `Function.prototype.bind` as we + // use it in defining shortcuts. + var owns = call.bind(ObjectPrototype.hasOwnProperty); + var toStr = call.bind(ObjectPrototype.toString); + var arraySlice = call.bind(array_slice); + var arraySliceApply = apply.bind(array_slice); + /* globals document */ + if (typeof document === 'object' && document && document.documentElement) { + try { + arraySlice(document.documentElement.childNodes); + } catch (e) { + var origArraySlice = arraySlice; + var origArraySliceApply = arraySliceApply; + arraySlice = function arraySliceIE(arr) { + var r = []; + var i = arr.length; + while (i-- > 0) { + r[i] = arr[i]; + } + return origArraySliceApply(r, origArraySlice(arguments, 1)); + }; + arraySliceApply = function arraySliceApplyIE(arr, args) { + return origArraySliceApply(arraySlice(arr), args); + }; + } + } + var strSlice = call.bind(StringPrototype.slice); + var strSplit = call.bind(StringPrototype.split); + var strIndexOf = call.bind(StringPrototype.indexOf); + var pushCall = call.bind(array_push); + var isEnum = call.bind(ObjectPrototype.propertyIsEnumerable); + var arraySort = call.bind(ArrayPrototype.sort); + + // + // Array + // ===== + // + + var isArray = $Array.isArray || function isArray(obj) { + return toStr(obj) === '[object Array]'; + }; + + // ES5 15.4.4.12 + // https://es5.github.io/#x15.4.4.13 + // Return len+argCount. + // [bugfix, ielt8] + // IE < 8 bug: [].unshift(0) === undefined but should be "1" + var hasUnshiftReturnValueBug = [].unshift(0) !== 1; + defineProperties(ArrayPrototype, { + unshift: function () { + array_unshift.apply(this, arguments); + return this.length; + } + }, hasUnshiftReturnValueBug); + + // ES5 15.4.3.2 + // https://es5.github.io/#x15.4.3.2 + // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/isArray + defineProperties($Array, { isArray: isArray }); + + // The IsCallable() check in the Array functions + // has been replaced with a strict check on the + // internal class of the object to trap cases where + // the provided function was actually a regular + // expression literal, which in V8 and + // JavaScriptCore is a typeof "function". Only in + // V8 are regular expression literals permitted as + // reduce parameters, so it is desirable in the + // general case for the shim to match the more + // strict and common behavior of rejecting regular + // expressions. + + // ES5 15.4.4.18 + // https://es5.github.io/#x15.4.4.18 + // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/array/forEach + + // Check failure of by-index access of string characters (IE < 9) + // and failure of `0 in boxedString` (Rhino) + var boxedString = $Object('a'); + var splitString = boxedString[0] !== 'a' || !(0 in boxedString); + + var properlyBoxesContext = function properlyBoxed(method) { + // Check node 0.6.21 bug where third parameter is not boxed + var properlyBoxesNonStrict = true; + var properlyBoxesStrict = true; + var threwException = false; + if (method) { + try { + method.call('foo', function (_, __, context) { + if (typeof context !== 'object') { + properlyBoxesNonStrict = false; + } + }); + + method.call([1], function () { + 'use strict'; + + properlyBoxesStrict = typeof this === 'string'; + }, 'x'); + } catch (e) { + threwException = true; + } + } + return !!method && !threwException && properlyBoxesNonStrict && properlyBoxesStrict; + }; + + defineProperties(ArrayPrototype, { + forEach: function forEach(callbackfn/*, thisArg*/) { + var object = ES.ToObject(this); + var self = splitString && isString(this) ? strSplit(this, '') : object; + var i = -1; + var length = ES.ToUint32(self.length); + var T; + if (arguments.length > 1) { + T = arguments[1]; + } + + // If no callback function or if callback is not a callable function + if (!isCallable(callbackfn)) { + throw new TypeError('Array.prototype.forEach callback must be a function'); + } + + while (++i < length) { + if (i in self) { + // Invoke the callback function with call, passing arguments: + // context, property value, property key, thisArg object + if (typeof T === 'undefined') { + callbackfn(self[i], i, object); + } else { + callbackfn.call(T, self[i], i, object); + } + } + } + } + }, !properlyBoxesContext(ArrayPrototype.forEach)); + + // ES5 15.4.4.19 + // https://es5.github.io/#x15.4.4.19 + // https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/map + defineProperties(ArrayPrototype, { + map: function map(callbackfn/*, thisArg*/) { + var object = ES.ToObject(this); + var self = splitString && isString(this) ? strSplit(this, '') : object; + var length = ES.ToUint32(self.length); + var result = $Array(length); + var T; + if (arguments.length > 1) { + T = arguments[1]; + } + + // If no callback function or if callback is not a callable function + if (!isCallable(callbackfn)) { + throw new TypeError('Array.prototype.map callback must be a function'); + } + + for (var i = 0; i < length; i++) { + if (i in self) { + if (typeof T === 'undefined') { + result[i] = callbackfn(self[i], i, object); + } else { + result[i] = callbackfn.call(T, self[i], i, object); + } + } + } + return result; + } + }, !properlyBoxesContext(ArrayPrototype.map)); + + // ES5 15.4.4.20 + // https://es5.github.io/#x15.4.4.20 + // https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/filter + defineProperties(ArrayPrototype, { + filter: function filter(callbackfn/*, thisArg*/) { + var object = ES.ToObject(this); + var self = splitString && isString(this) ? strSplit(this, '') : object; + var length = ES.ToUint32(self.length); + var result = []; + var value; + var T; + if (arguments.length > 1) { + T = arguments[1]; + } + + // If no callback function or if callback is not a callable function + if (!isCallable(callbackfn)) { + throw new TypeError('Array.prototype.filter callback must be a function'); + } + + for (var i = 0; i < length; i++) { + if (i in self) { + value = self[i]; + if (typeof T === 'undefined' ? callbackfn(value, i, object) : callbackfn.call(T, value, i, object)) { + pushCall(result, value); + } + } + } + return result; + } + }, !properlyBoxesContext(ArrayPrototype.filter)); + + // ES5 15.4.4.16 + // https://es5.github.io/#x15.4.4.16 + // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/every + defineProperties(ArrayPrototype, { + every: function every(callbackfn/*, thisArg*/) { + var object = ES.ToObject(this); + var self = splitString && isString(this) ? strSplit(this, '') : object; + var length = ES.ToUint32(self.length); + var T; + if (arguments.length > 1) { + T = arguments[1]; + } + + // If no callback function or if callback is not a callable function + if (!isCallable(callbackfn)) { + throw new TypeError('Array.prototype.every callback must be a function'); + } + + for (var i = 0; i < length; i++) { + if (i in self && !(typeof T === 'undefined' ? callbackfn(self[i], i, object) : callbackfn.call(T, self[i], i, object))) { + return false; + } + } + return true; + } + }, !properlyBoxesContext(ArrayPrototype.every)); + + // ES5 15.4.4.17 + // https://es5.github.io/#x15.4.4.17 + // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/some + defineProperties(ArrayPrototype, { + some: function some(callbackfn/*, thisArg */) { + var object = ES.ToObject(this); + var self = splitString && isString(this) ? strSplit(this, '') : object; + var length = ES.ToUint32(self.length); + var T; + if (arguments.length > 1) { + T = arguments[1]; + } + + // If no callback function or if callback is not a callable function + if (!isCallable(callbackfn)) { + throw new TypeError('Array.prototype.some callback must be a function'); + } + + for (var i = 0; i < length; i++) { + if (i in self && (typeof T === 'undefined' ? callbackfn(self[i], i, object) : callbackfn.call(T, self[i], i, object))) { + return true; + } + } + return false; + } + }, !properlyBoxesContext(ArrayPrototype.some)); + + // ES5 15.4.4.21 + // https://es5.github.io/#x15.4.4.21 + // https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/reduce + var reduceCoercesToObject = false; + if (ArrayPrototype.reduce) { + reduceCoercesToObject = typeof ArrayPrototype.reduce.call('es5', function (_, __, ___, list) { + return list; + }) === 'object'; + } + defineProperties(ArrayPrototype, { + reduce: function reduce(callbackfn/*, initialValue*/) { + var object = ES.ToObject(this); + var self = splitString && isString(this) ? strSplit(this, '') : object; + var length = ES.ToUint32(self.length); + + // If no callback function or if callback is not a callable function + if (!isCallable(callbackfn)) { + throw new TypeError('Array.prototype.reduce callback must be a function'); + } + + // no value to return if no initial value and an empty array + if (length === 0 && arguments.length === 1) { + throw new TypeError('reduce of empty array with no initial value'); + } + + var i = 0; + var result; + if (arguments.length >= 2) { + result = arguments[1]; + } else { + do { + if (i in self) { + result = self[i++]; + break; + } + + // if array contains no values, no initial value to return + if (++i >= length) { + throw new TypeError('reduce of empty array with no initial value'); + } + } while (true); + } + + for (; i < length; i++) { + if (i in self) { + result = callbackfn(result, self[i], i, object); + } + } + + return result; + } + }, !reduceCoercesToObject); + + // ES5 15.4.4.22 + // https://es5.github.io/#x15.4.4.22 + // https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/reduceRight + var reduceRightCoercesToObject = false; + if (ArrayPrototype.reduceRight) { + reduceRightCoercesToObject = typeof ArrayPrototype.reduceRight.call('es5', function (_, __, ___, list) { + return list; + }) === 'object'; + } + defineProperties(ArrayPrototype, { + reduceRight: function reduceRight(callbackfn/*, initial*/) { + var object = ES.ToObject(this); + var self = splitString && isString(this) ? strSplit(this, '') : object; + var length = ES.ToUint32(self.length); + + // If no callback function or if callback is not a callable function + if (!isCallable(callbackfn)) { + throw new TypeError('Array.prototype.reduceRight callback must be a function'); + } + + // no value to return if no initial value, empty array + if (length === 0 && arguments.length === 1) { + throw new TypeError('reduceRight of empty array with no initial value'); + } + + var result; + var i = length - 1; + if (arguments.length >= 2) { + result = arguments[1]; + } else { + do { + if (i in self) { + result = self[i--]; + break; + } + + // if array contains no values, no initial value to return + if (--i < 0) { + throw new TypeError('reduceRight of empty array with no initial value'); + } + } while (true); + } + + if (i < 0) { + return result; + } + + do { + if (i in self) { + result = callbackfn(result, self[i], i, object); + } + } while (i--); + + return result; + } + }, !reduceRightCoercesToObject); + + // ES5 15.4.4.14 + // https://es5.github.io/#x15.4.4.14 + // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/indexOf + var hasFirefox2IndexOfBug = ArrayPrototype.indexOf && [0, 1].indexOf(1, 2) !== -1; + defineProperties(ArrayPrototype, { + indexOf: function indexOf(searchElement/*, fromIndex */) { + var self = splitString && isString(this) ? strSplit(this, '') : ES.ToObject(this); + var length = ES.ToUint32(self.length); + + if (length === 0) { + return -1; + } + + var i = 0; + if (arguments.length > 1) { + i = ES.ToInteger(arguments[1]); + } + + // handle negative indices + i = i >= 0 ? i : max(0, length + i); + for (; i < length; i++) { + if (i in self && self[i] === searchElement) { + return i; + } + } + return -1; + } + }, hasFirefox2IndexOfBug); + + // ES5 15.4.4.15 + // https://es5.github.io/#x15.4.4.15 + // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/lastIndexOf + var hasFirefox2LastIndexOfBug = ArrayPrototype.lastIndexOf && [0, 1].lastIndexOf(0, -3) !== -1; + defineProperties(ArrayPrototype, { + lastIndexOf: function lastIndexOf(searchElement/*, fromIndex */) { + var self = splitString && isString(this) ? strSplit(this, '') : ES.ToObject(this); + var length = ES.ToUint32(self.length); + + if (length === 0) { + return -1; + } + var i = length - 1; + if (arguments.length > 1) { + i = min(i, ES.ToInteger(arguments[1])); + } + // handle negative indices + i = i >= 0 ? i : length - abs(i); + for (; i >= 0; i--) { + if (i in self && searchElement === self[i]) { + return i; + } + } + return -1; + } + }, hasFirefox2LastIndexOfBug); + + // ES5 15.4.4.12 + // https://es5.github.io/#x15.4.4.12 + var spliceNoopReturnsEmptyArray = (function () { + var a = [1, 2]; + var result = a.splice(); + return a.length === 2 && isArray(result) && result.length === 0; + }()); + defineProperties(ArrayPrototype, { + // Safari 5.0 bug where .splice() returns undefined + splice: function splice(start, deleteCount) { + if (arguments.length === 0) { + return []; + } + return array_splice.apply(this, arguments); + + } + }, !spliceNoopReturnsEmptyArray); + + var spliceWorksWithEmptyObject = (function () { + var obj = {}; + ArrayPrototype.splice.call(obj, 0, 0, 1); + return obj.length === 1; + }()); + var hasES6Defaults = [0, 1, 2].splice(0).length === 3; + defineProperties(ArrayPrototype, { + splice: function splice(start, deleteCount) { + if (arguments.length === 0) { + return []; + } + var args = arguments; + this.length = max(ES.ToInteger(this.length), 0); + if (arguments.length > 0 && typeof deleteCount !== 'number') { + args = arraySlice(arguments); + if (args.length < 2) { + pushCall(args, this.length - start); + } else { + args[1] = ES.ToInteger(deleteCount); + } + } + return array_splice.apply(this, args); + } + }, !spliceWorksWithEmptyObject || !hasES6Defaults); + var spliceWorksWithLargeSparseArrays = (function () { + // Per https://github.com/es-shims/es5-shim/issues/295 + // Safari 7/8 breaks with sparse arrays of size 1e5 or greater + var arr = new $Array(1e5); + // note: the index MUST be 8 or larger or the test will false pass + arr[8] = 'x'; + arr.splice(1, 1); + // note: this test must be defined *after* the indexOf shim + // per https://github.com/es-shims/es5-shim/issues/313 + return arr.indexOf('x') === 7; + }()); + var spliceWorksWithSmallSparseArrays = (function () { + // Per https://github.com/es-shims/es5-shim/issues/295 + // Opera 12.15 breaks on this, no idea why. + var n = 256; + var arr = []; + arr[n] = 'a'; + arr.splice(n + 1, 0, 'b'); + return arr[n] === 'a'; + }()); + defineProperties(ArrayPrototype, { + splice: function splice(start, deleteCount) { + var O = ES.ToObject(this); + var A = []; + var len = ES.ToUint32(O.length); + var relativeStart = ES.ToInteger(start); + var actualStart = relativeStart < 0 ? max((len + relativeStart), 0) : min(relativeStart, len); + var actualDeleteCount = arguments.length === 0 + ? 0 + : arguments.length === 1 + ? len - actualStart + : min(max(ES.ToInteger(deleteCount), 0), len - actualStart); + + var k = 0; + var from; + while (k < actualDeleteCount) { + from = $String(actualStart + k); + if (owns(O, from)) { + A[k] = O[from]; + } + k += 1; + } + + var items = arraySlice(arguments, 2); + var itemCount = items.length; + var to; + if (itemCount < actualDeleteCount) { + k = actualStart; + var maxK = len - actualDeleteCount; + while (k < maxK) { + from = $String(k + actualDeleteCount); + to = $String(k + itemCount); + if (owns(O, from)) { + O[to] = O[from]; + } else { + delete O[to]; + } + k += 1; + } + k = len; + var minK = len - actualDeleteCount + itemCount; + while (k > minK) { + delete O[k - 1]; + k -= 1; + } + } else if (itemCount > actualDeleteCount) { + k = len - actualDeleteCount; + while (k > actualStart) { + from = $String(k + actualDeleteCount - 1); + to = $String(k + itemCount - 1); + if (owns(O, from)) { + O[to] = O[from]; + } else { + delete O[to]; + } + k -= 1; + } + } + k = actualStart; + for (var i = 0; i < items.length; ++i) { + O[k] = items[i]; + k += 1; + } + O.length = len - actualDeleteCount + itemCount; + + return A; + } + }, !spliceWorksWithLargeSparseArrays || !spliceWorksWithSmallSparseArrays); + + var originalJoin = ArrayPrototype.join; + var hasStringJoinBug; + try { + hasStringJoinBug = Array.prototype.join.call('123', ',') !== '1,2,3'; + } catch (e) { + hasStringJoinBug = true; + } + if (hasStringJoinBug) { + defineProperties(ArrayPrototype, { + join: function join(separator) { + var sep = typeof separator === 'undefined' ? ',' : separator; + return originalJoin.call(isString(this) ? strSplit(this, '') : this, sep); + } + }, hasStringJoinBug); + } + + var hasJoinUndefinedBug = [1, 2].join(undefined) !== '1,2'; + if (hasJoinUndefinedBug) { + defineProperties(ArrayPrototype, { + join: function join(separator) { + var sep = typeof separator === 'undefined' ? ',' : separator; + return originalJoin.call(this, sep); + } + }, hasJoinUndefinedBug); + } + + var pushShim = function push(item) { + var O = ES.ToObject(this); + var n = ES.ToUint32(O.length); + var i = 0; + while (i < arguments.length) { + O[n + i] = arguments[i]; + i += 1; + } + O.length = n + i; + return n + i; + }; + + var pushIsNotGeneric = (function () { + var obj = {}; + var result = Array.prototype.push.call(obj, undefined); + return result !== 1 || obj.length !== 1 || typeof obj[0] !== 'undefined' || !owns(obj, 0); + }()); + defineProperties(ArrayPrototype, { + push: function push(item) { + if (isArray(this)) { + return array_push.apply(this, arguments); + } + return pushShim.apply(this, arguments); + } + }, pushIsNotGeneric); + + // This fixes a very weird bug in Opera 10.6 when pushing `undefined + var pushUndefinedIsWeird = (function () { + var arr = []; + var result = arr.push(undefined); + return result !== 1 || arr.length !== 1 || typeof arr[0] !== 'undefined' || !owns(arr, 0); + }()); + defineProperties(ArrayPrototype, { push: pushShim }, pushUndefinedIsWeird); + + // ES5 15.2.3.14 + // https://es5.github.io/#x15.4.4.10 + // Fix boxed string bug + defineProperties(ArrayPrototype, { + slice: function (start, end) { + var arr = isString(this) ? strSplit(this, '') : this; + return arraySliceApply(arr, arguments); + } + }, splitString); + + var sortIgnoresNonFunctions = (function () { + try { + [1, 2].sort(null); + } catch (e) { + try { + [1, 2].sort({}); + } catch (e2) { + return false; + } + } + return true; + }()); + var sortThrowsOnRegex = (function () { + // this is a problem in Firefox 4, in which `typeof /a/ === 'function'` + try { + [1, 2].sort(/a/); + return false; + } catch (e) {} + return true; + }()); + var sortIgnoresUndefined = (function () { + // applies in IE 8, for one. + try { + [1, 2].sort(undefined); + return true; + } catch (e) {} + return false; + }()); + defineProperties(ArrayPrototype, { + sort: function sort(compareFn) { + if (typeof compareFn === 'undefined') { + return arraySort(this); + } + if (!isCallable(compareFn)) { + throw new TypeError('Array.prototype.sort callback must be a function'); + } + return arraySort(this, compareFn); + } + }, sortIgnoresNonFunctions || !sortIgnoresUndefined || !sortThrowsOnRegex); + + // + // Object + // ====== + // + + // ES5 15.2.3.14 + // https://es5.github.io/#x15.2.3.14 + + // https://web.archive.org/web/20140727042234/http://whattheheadsaid.com/2010/10/a-safer-object-keys-compatibility-implementation + // eslint-disable-next-line quote-props + var hasDontEnumBug = !isEnum({ 'toString': null }, 'toString'); // jscs:ignore disallowQuotedKeysInObjects + var hasProtoEnumBug = isEnum(function () {}, 'prototype'); + var hasStringEnumBug = !owns('x', '0'); + var equalsConstructorPrototype = function (o) { + var ctor = o.constructor; + return ctor && ctor.prototype === o; + }; + var excludedKeys = { + $applicationCache: true, + $console: true, + $external: true, + $frame: true, + $frameElement: true, + $frames: true, + $innerHeight: true, + $innerWidth: true, + $onmozfullscreenchange: true, + $onmozfullscreenerror: true, + $outerHeight: true, + $outerWidth: true, + $pageXOffset: true, + $pageYOffset: true, + $parent: true, + $scrollLeft: true, + $scrollTop: true, + $scrollX: true, + $scrollY: true, + $self: true, + $webkitIndexedDB: true, + $webkitStorageInfo: true, + $window: true, + + $width: true, + $height: true, + $top: true, + $localStorage: true + }; + var hasAutomationEqualityBug = (function () { + /* globals window */ + if (typeof window === 'undefined') { + return false; + } + for (var k in window) { + try { + if (!excludedKeys['$' + k] && owns(window, k) && window[k] !== null && typeof window[k] === 'object') { + equalsConstructorPrototype(window[k]); + } + } catch (e) { + return true; + } + } + return false; + }()); + var equalsConstructorPrototypeIfNotBuggy = function (object) { + if (typeof window === 'undefined' || !hasAutomationEqualityBug) { + return equalsConstructorPrototype(object); + } + try { + return equalsConstructorPrototype(object); + } catch (e) { + return false; + } + }; + var dontEnums = [ + 'toString', + 'toLocaleString', + 'valueOf', + 'hasOwnProperty', + 'isPrototypeOf', + 'propertyIsEnumerable', + 'constructor' + ]; + var dontEnumsLength = dontEnums.length; + + // taken directly from https://github.com/ljharb/is-arguments/blob/master/index.js + // can be replaced with require('is-arguments') if we ever use a build process instead + var isStandardArguments = function isArguments(value) { + return toStr(value) === '[object Arguments]'; + }; + var isLegacyArguments = function isArguments(value) { + return value !== null + && typeof value === 'object' + && typeof value.length === 'number' + && value.length >= 0 + && !isArray(value) + && isCallable(value.callee); + }; + var isArguments = isStandardArguments(arguments) ? isStandardArguments : isLegacyArguments; + + defineProperties($Object, { + keys: function keys(object) { + var isFn = isCallable(object); + var isArgs = isArguments(object); + var isObject = object !== null && typeof object === 'object'; + var isStr = isObject && isString(object); + + if (!isObject && !isFn && !isArgs) { + throw new TypeError('Object.keys called on a non-object'); + } + + var theKeys = []; + var skipProto = hasProtoEnumBug && isFn; + if ((isStr && hasStringEnumBug) || isArgs) { + for (var i = 0; i < object.length; ++i) { + pushCall(theKeys, $String(i)); + } + } + + if (!isArgs) { + for (var name in object) { + if (!(skipProto && name === 'prototype') && owns(object, name)) { + pushCall(theKeys, $String(name)); + } + } + } + + if (hasDontEnumBug) { + var skipConstructor = equalsConstructorPrototypeIfNotBuggy(object); + for (var j = 0; j < dontEnumsLength; j++) { + var dontEnum = dontEnums[j]; + if (!(skipConstructor && dontEnum === 'constructor') && owns(object, dontEnum)) { + pushCall(theKeys, dontEnum); + } + } + } + return theKeys; + } + }); + + var keysWorksWithArguments = $Object.keys && (function () { + // Safari 5.0 bug + return $Object.keys(arguments).length === 2; + }(1, 2)); + var keysHasArgumentsLengthBug = $Object.keys && (function () { + var argKeys = $Object.keys(arguments); + return arguments.length !== 1 || argKeys.length !== 1 || argKeys[0] !== 1; + }(1)); + var originalKeys = $Object.keys; + defineProperties($Object, { + keys: function keys(object) { + if (isArguments(object)) { + return originalKeys(arraySlice(object)); + } + return originalKeys(object); + + } + }, !keysWorksWithArguments || keysHasArgumentsLengthBug); + + // + // Date + // ==== + // + + var hasNegativeMonthYearBug = new Date(-3509827329600292).getUTCMonth() !== 0; + var aNegativeTestDate = new Date(-1509842289600292); + var aPositiveTestDate = new Date(1449662400000); + var hasToUTCStringFormatBug = aNegativeTestDate.toUTCString() !== 'Mon, 01 Jan -45875 11:59:59 GMT'; + var hasToDateStringFormatBug; + var hasToStringFormatBug; + var timeZoneOffset = aNegativeTestDate.getTimezoneOffset(); + if (timeZoneOffset < -720) { + hasToDateStringFormatBug = aNegativeTestDate.toDateString() !== 'Tue Jan 02 -45875'; + hasToStringFormatBug = !(/^Thu Dec 10 2015 \d\d:\d\d:\d\d GMT[-+]\d\d\d\d(?: |$)/).test(String(aPositiveTestDate)); + } else { + hasToDateStringFormatBug = aNegativeTestDate.toDateString() !== 'Mon Jan 01 -45875'; + hasToStringFormatBug = !(/^Wed Dec 09 2015 \d\d:\d\d:\d\d GMT[-+]\d\d\d\d(?: |$)/).test(String(aPositiveTestDate)); + } + + var originalGetFullYear = call.bind(Date.prototype.getFullYear); + var originalGetMonth = call.bind(Date.prototype.getMonth); + var originalGetDate = call.bind(Date.prototype.getDate); + var originalGetUTCFullYear = call.bind(Date.prototype.getUTCFullYear); + var originalGetUTCMonth = call.bind(Date.prototype.getUTCMonth); + var originalGetUTCDate = call.bind(Date.prototype.getUTCDate); + var originalGetUTCDay = call.bind(Date.prototype.getUTCDay); + var originalGetUTCHours = call.bind(Date.prototype.getUTCHours); + var originalGetUTCMinutes = call.bind(Date.prototype.getUTCMinutes); + var originalGetUTCSeconds = call.bind(Date.prototype.getUTCSeconds); + var originalGetUTCMilliseconds = call.bind(Date.prototype.getUTCMilliseconds); + var dayName = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']; + var monthName = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']; + var daysInMonth = function daysInMonth(month, year) { + return originalGetDate(new Date(year, month, 0)); + }; + + defineProperties(Date.prototype, { + getFullYear: function getFullYear() { + if (!this || !(this instanceof Date)) { + throw new TypeError('this is not a Date object.'); + } + var year = originalGetFullYear(this); + if (year < 0 && originalGetMonth(this) > 11) { + return year + 1; + } + return year; + }, + getMonth: function getMonth() { + if (!this || !(this instanceof Date)) { + throw new TypeError('this is not a Date object.'); + } + var year = originalGetFullYear(this); + var month = originalGetMonth(this); + if (year < 0 && month > 11) { + return 0; + } + return month; + }, + getDate: function getDate() { + if (!this || !(this instanceof Date)) { + throw new TypeError('this is not a Date object.'); + } + var year = originalGetFullYear(this); + var month = originalGetMonth(this); + var date = originalGetDate(this); + if (year < 0 && month > 11) { + if (month === 12) { + return date; + } + var days = daysInMonth(0, year + 1); + return (days - date) + 1; + } + return date; + }, + getUTCFullYear: function getUTCFullYear() { + if (!this || !(this instanceof Date)) { + throw new TypeError('this is not a Date object.'); + } + var year = originalGetUTCFullYear(this); + if (year < 0 && originalGetUTCMonth(this) > 11) { + return year + 1; + } + return year; + }, + getUTCMonth: function getUTCMonth() { + if (!this || !(this instanceof Date)) { + throw new TypeError('this is not a Date object.'); + } + var year = originalGetUTCFullYear(this); + var month = originalGetUTCMonth(this); + if (year < 0 && month > 11) { + return 0; + } + return month; + }, + getUTCDate: function getUTCDate() { + if (!this || !(this instanceof Date)) { + throw new TypeError('this is not a Date object.'); + } + var year = originalGetUTCFullYear(this); + var month = originalGetUTCMonth(this); + var date = originalGetUTCDate(this); + if (year < 0 && month > 11) { + if (month === 12) { + return date; + } + var days = daysInMonth(0, year + 1); + return (days - date) + 1; + } + return date; + } + }, hasNegativeMonthYearBug); + + defineProperties(Date.prototype, { + toUTCString: function toUTCString() { + if (!this || !(this instanceof Date)) { + throw new TypeError('this is not a Date object.'); + } + var day = originalGetUTCDay(this); + var date = originalGetUTCDate(this); + var month = originalGetUTCMonth(this); + var year = originalGetUTCFullYear(this); + var hour = originalGetUTCHours(this); + var minute = originalGetUTCMinutes(this); + var second = originalGetUTCSeconds(this); + return dayName[day] + ', ' + + (date < 10 ? '0' + date : date) + ' ' + + monthName[month] + ' ' + + year + ' ' + + (hour < 10 ? '0' + hour : hour) + ':' + + (minute < 10 ? '0' + minute : minute) + ':' + + (second < 10 ? '0' + second : second) + ' GMT'; + } + }, hasNegativeMonthYearBug || hasToUTCStringFormatBug); + + // Opera 12 has `,` + defineProperties(Date.prototype, { + toDateString: function toDateString() { + if (!this || !(this instanceof Date)) { + throw new TypeError('this is not a Date object.'); + } + var day = this.getDay(); + var date = this.getDate(); + var month = this.getMonth(); + var year = this.getFullYear(); + return dayName[day] + ' ' + + monthName[month] + ' ' + + (date < 10 ? '0' + date : date) + ' ' + + year; + } + }, hasNegativeMonthYearBug || hasToDateStringFormatBug); + + // can't use defineProperties here because of toString enumeration issue in IE <= 8 + if (hasNegativeMonthYearBug || hasToStringFormatBug) { + Date.prototype.toString = function toString() { + if (!this || !(this instanceof Date)) { + throw new TypeError('this is not a Date object.'); + } + var day = this.getDay(); + var date = this.getDate(); + var month = this.getMonth(); + var year = this.getFullYear(); + var hour = this.getHours(); + var minute = this.getMinutes(); + var second = this.getSeconds(); + var timezoneOffset = this.getTimezoneOffset(); + var hoursOffset = floor(abs(timezoneOffset) / 60); + var minutesOffset = floor(abs(timezoneOffset) % 60); + return dayName[day] + ' ' + + monthName[month] + ' ' + + (date < 10 ? '0' + date : date) + ' ' + + year + ' ' + + (hour < 10 ? '0' + hour : hour) + ':' + + (minute < 10 ? '0' + minute : minute) + ':' + + (second < 10 ? '0' + second : second) + ' GMT' + + (timezoneOffset > 0 ? '-' : '+') + + (hoursOffset < 10 ? '0' + hoursOffset : hoursOffset) + + (minutesOffset < 10 ? '0' + minutesOffset : minutesOffset); + }; + if (supportsDescriptors) { + $Object.defineProperty(Date.prototype, 'toString', { + configurable: true, + enumerable: false, + writable: true + }); + } + } + + // ES5 15.9.5.43 + // https://es5.github.io/#x15.9.5.43 + // This function returns a String value represent the instance in time + // represented by this Date object. The format of the String is the Date Time + // string format defined in 15.9.1.15. All fields are present in the String. + // The time zone is always UTC, denoted by the suffix Z. If the time value of + // this object is not a finite Number a RangeError exception is thrown. + var negativeDate = -621987552e5; + var negativeYearString = '-000001'; + var hasNegativeDateBug = Date.prototype.toISOString && new Date(negativeDate).toISOString().indexOf(negativeYearString) === -1; // eslint-disable-line max-len + var hasSafari51DateBug = Date.prototype.toISOString && new Date(-1).toISOString() !== '1969-12-31T23:59:59.999Z'; + + var getTime = call.bind(Date.prototype.getTime); + + defineProperties(Date.prototype, { + toISOString: function toISOString() { + if (!isFinite(this) || !isFinite(getTime(this))) { + // Adope Photoshop requires the second check. + throw new RangeError('Date.prototype.toISOString called on non-finite value.'); + } + + var year = originalGetUTCFullYear(this); + + var month = originalGetUTCMonth(this); + // see https://github.com/es-shims/es5-shim/issues/111 + year += floor(month / 12); + month = ((month % 12) + 12) % 12; + + // the date time string format is specified in 15.9.1.15. + var result = [ + month + 1, + originalGetUTCDate(this), + originalGetUTCHours(this), + originalGetUTCMinutes(this), + originalGetUTCSeconds(this) + ]; + year = ( + (year < 0 ? '-' : (year > 9999 ? '+' : '')) + + strSlice('00000' + abs(year), (0 <= year && year <= 9999) ? -4 : -6) + ); + + for (var i = 0; i < result.length; ++i) { + // pad months, days, hours, minutes, and seconds to have two digits. + result[i] = strSlice('00' + result[i], -2); + } + // pad milliseconds to have three digits. + return ( + year + '-' + arraySlice(result, 0, 2).join('-') + + 'T' + arraySlice(result, 2).join(':') + '.' + + strSlice('000' + originalGetUTCMilliseconds(this), -3) + 'Z' + ); + } + }, hasNegativeDateBug || hasSafari51DateBug); + + // ES5 15.9.5.44 + // https://es5.github.io/#x15.9.5.44 + // This function provides a String representation of a Date object for use by + // JSON.stringify (15.12.3). + var dateToJSONIsSupported = (function () { + try { + return Date.prototype.toJSON + && new Date(NaN).toJSON() === null + && new Date(negativeDate).toJSON().indexOf(negativeYearString) !== -1 + && Date.prototype.toJSON.call({ // generic + toISOString: function () { return true; } + }); + } catch (e) { + return false; + } + }()); + if (!dateToJSONIsSupported) { + Date.prototype.toJSON = function toJSON(key) { + // When the toJSON method is called with argument key, the following + // steps are taken: + + // 1. Let O be the result of calling ToObject, giving it the this + // value as its argument. + // 2. Let tv be ES.ToPrimitive(O, hint Number). + var O = $Object(this); + var tv = ES.ToPrimitive(O); + // 3. If tv is a Number and is not finite, return null. + if (typeof tv === 'number' && !isFinite(tv)) { + return null; + } + // 4. Let toISO be the result of calling the [[Get]] internal method of + // O with argument "toISOString". + var toISO = O.toISOString; + // 5. If IsCallable(toISO) is false, throw a TypeError exception. + if (!isCallable(toISO)) { + throw new TypeError('toISOString property is not callable'); + } + // 6. Return the result of calling the [[Call]] internal method of + // toISO with O as the this value and an empty argument list. + return toISO.call(O); + + // NOTE 1 The argument is ignored. + + // NOTE 2 The toJSON function is intentionally generic; it does not + // require that its this value be a Date object. Therefore, it can be + // transferred to other kinds of objects for use as a method. However, + // it does require that any such object have a toISOString method. An + // object is free to use the argument key to filter its + // stringification. + }; + } + + // ES5 15.9.4.2 + // https://es5.github.io/#x15.9.4.2 + // based on work shared by Daniel Friesen (dantman) + // https://gist.github.com/303249 + var supportsExtendedYears = Date.parse('+033658-09-27T01:46:40.000Z') === 1e15; + var acceptsInvalidDates = !isNaN(Date.parse('2012-04-04T24:00:00.500Z')) || !isNaN(Date.parse('2012-11-31T23:59:59.000Z')) || !isNaN(Date.parse('2012-12-31T23:59:60.000Z')); + var doesNotParseY2KNewYear = isNaN(Date.parse('2000-01-01T00:00:00.000Z')); + if (doesNotParseY2KNewYear || acceptsInvalidDates || !supportsExtendedYears) { + // XXX global assignment won't work in embeddings that use + // an alternate object for the context. + var maxSafeUnsigned32Bit = pow(2, 31) - 1; + var hasSafariSignedIntBug = isActualNaN(new Date(1970, 0, 1, 0, 0, 0, maxSafeUnsigned32Bit + 1).getTime()); + // eslint-disable-next-line no-implicit-globals, no-global-assign + Date = (function (NativeDate) { + // Date.length === 7 + var DateShim = function Date(Y, M, D, h, m, s, ms) { + var length = arguments.length; + var date; + if (this instanceof NativeDate) { + var seconds = s; + var millis = ms; + if (hasSafariSignedIntBug && length >= 7 && ms > maxSafeUnsigned32Bit) { + // work around a Safari 8/9 bug where it treats the seconds as signed + var msToShift = floor(ms / maxSafeUnsigned32Bit) * maxSafeUnsigned32Bit; + var sToShift = floor(msToShift / 1e3); + seconds += sToShift; + millis -= sToShift * 1e3; + } + var parsed = DateShim.parse(Y); + var hasNegTimestampParseBug = isNaN(parsed); + date = length === 1 && $String(Y) === Y && !hasNegTimestampParseBug // isString(Y) + // We explicitly pass it through parse: + ? new NativeDate(parsed) + // We have to manually make calls depending on argument + // length here + : length >= 7 ? new NativeDate(Y, M, D, h, m, seconds, millis) + : length >= 6 ? new NativeDate(Y, M, D, h, m, seconds) + : length >= 5 ? new NativeDate(Y, M, D, h, m) + : length >= 4 ? new NativeDate(Y, M, D, h) + : length >= 3 ? new NativeDate(Y, M, D) + : length >= 2 ? new NativeDate(Y, M) + : length >= 1 ? new NativeDate(Y instanceof NativeDate ? +Y : Y) + : new NativeDate(); + } else { + date = NativeDate.apply(this, arguments); + } + if (!isPrimitive(date)) { + // Prevent mixups with unfixed Date object + defineProperties(date, { constructor: DateShim }, true); + } + return date; + }; + + // 15.9.1.15 Date Time String Format. + var isoDateExpression = new RegExp('^' + + '(\\d{4}|[+-]\\d{6})' // four-digit year capture or sign + 6-digit extended year + + '(?:-(\\d{2})' // optional month capture + + '(?:-(\\d{2})' // optional day capture + + '(?:' // capture hours:minutes:seconds.milliseconds + + 'T(\\d{2})' // hours capture + + ':(\\d{2})' // minutes capture + + '(?:' // optional :seconds.milliseconds + + ':(\\d{2})' // seconds capture + + '(?:(\\.\\d{1,}))?' // milliseconds capture + + ')?' + + '(' // capture UTC offset component + + 'Z|' // UTC capture + + '(?:' // offset specifier +/-hours:minutes + + '([-+])' // sign capture + + '(\\d{2})' // hours offset capture + + ':(\\d{2})' // minutes offset capture + + ')' + + ')?)?)?)?' + + '$'); + + var months = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365]; + + var dayFromMonth = function dayFromMonth(year, month) { + var t = month > 1 ? 1 : 0; + return ( + months[month] + + floor((year - 1969 + t) / 4) + - floor((year - 1901 + t) / 100) + + floor((year - 1601 + t) / 400) + + (365 * (year - 1970)) + ); + }; + + var toUTC = function toUTC(t) { + var s = 0; + var ms = t; + if (hasSafariSignedIntBug && ms > maxSafeUnsigned32Bit) { + // work around a Safari 8/9 bug where it treats the seconds as signed + var msToShift = floor(ms / maxSafeUnsigned32Bit) * maxSafeUnsigned32Bit; + var sToShift = floor(msToShift / 1e3); + s += sToShift; + ms -= sToShift * 1e3; + } + return $Number(new NativeDate(1970, 0, 1, 0, 0, s, ms)); + }; + + // Copy any custom methods a 3rd party library may have added + for (var key in NativeDate) { + if (owns(NativeDate, key)) { + DateShim[key] = NativeDate[key]; + } + } + + // Copy "native" methods explicitly; they may be non-enumerable + defineProperties(DateShim, { + now: NativeDate.now, + UTC: NativeDate.UTC + }, true); + DateShim.prototype = NativeDate.prototype; + defineProperties(DateShim.prototype, { constructor: DateShim }, true); + + // Upgrade Date.parse to handle simplified ISO 8601 strings + var parseShim = function parse(string) { + var match = isoDateExpression.exec(string); + if (match) { + // parse months, days, hours, minutes, seconds, and milliseconds + // provide default values if necessary + // parse the UTC offset component + var year = $Number(match[1]), + month = $Number(match[2] || 1) - 1, + day = $Number(match[3] || 1) - 1, + hour = $Number(match[4] || 0), + minute = $Number(match[5] || 0), + second = $Number(match[6] || 0), + millisecond = floor($Number(match[7] || 0) * 1000), + // When time zone is missed, local offset should be used + // (ES 5.1 bug) + // see https://bugs.ecmascript.org/show_bug.cgi?id=112 + isLocalTime = Boolean(match[4] && !match[8]), + signOffset = match[9] === '-' ? 1 : -1, + hourOffset = $Number(match[10] || 0), + minuteOffset = $Number(match[11] || 0), + result; + var hasMinutesOrSecondsOrMilliseconds = minute > 0 || second > 0 || millisecond > 0; + if ( + hour < (hasMinutesOrSecondsOrMilliseconds ? 24 : 25) + && minute < 60 && second < 60 && millisecond < 1000 + && month > -1 && month < 12 && hourOffset < 24 + && minuteOffset < 60 // detect invalid offsets + && day > -1 + && day < (dayFromMonth(year, month + 1) - dayFromMonth(year, month)) + ) { + result = ( + ((dayFromMonth(year, month) + day) * 24) + + hour + + (hourOffset * signOffset) + ) * 60; + result = (( + ((result + minute + (minuteOffset * signOffset)) * 60) + + second + ) * 1000) + millisecond; + if (isLocalTime) { + result = toUTC(result); + } + if (-864e13 <= result && result <= 8.64e15) { + return result; + } + } + return NaN; + } + return NativeDate.parse.apply(this, arguments); + }; + defineProperties(DateShim, { parse: parseShim }); + + return DateShim; + }(Date)); + } + + // ES5 15.9.4.4 + // https://es5.github.io/#x15.9.4.4 + if (!Date.now) { + Date.now = function now() { + return new Date().getTime(); + }; + } + + // + // Number + // ====== + // + + // ES5.1 15.7.4.5 + // https://es5.github.io/#x15.7.4.5 + var hasToFixedBugs = NumberPrototype.toFixed && ( + (0.00008).toFixed(3) !== '0.000' + || (0.9).toFixed(0) !== '1' + || (1.255).toFixed(2) !== '1.25' + || (1000000000000000128).toFixed(0) !== '1000000000000000128' + ); + + var toFixedHelpers = { + base: 1e7, + size: 6, + data: [0, 0, 0, 0, 0, 0], + multiply: function multiply(n, c) { + var i = -1; + var c2 = c; + while (++i < toFixedHelpers.size) { + c2 += n * toFixedHelpers.data[i]; + toFixedHelpers.data[i] = c2 % toFixedHelpers.base; + c2 = floor(c2 / toFixedHelpers.base); + } + }, + divide: function divide(n) { + var i = toFixedHelpers.size; + var c = 0; + while (--i >= 0) { + c += toFixedHelpers.data[i]; + toFixedHelpers.data[i] = floor(c / n); + c = (c % n) * toFixedHelpers.base; + } + }, + numToString: function numToString() { + var i = toFixedHelpers.size; + var s = ''; + while (--i >= 0) { + if (s !== '' || i === 0 || toFixedHelpers.data[i] !== 0) { + var t = $String(toFixedHelpers.data[i]); + if (s === '') { + s = t; + } else { + s += strSlice('0000000', 0, 7 - t.length) + t; + } + } + } + return s; + }, + pow: function pow(x, n, acc) { + return (n === 0 ? acc : (n % 2 === 1 ? pow(x, n - 1, acc * x) : pow(x * x, n / 2, acc))); + }, + log: function log(x) { + var n = 0; + var x2 = x; + while (x2 >= 4096) { + n += 12; + x2 /= 4096; + } + while (x2 >= 2) { + n += 1; + x2 /= 2; + } + return n; + } + }; + + var toFixedShim = function toFixed(fractionDigits) { + var f, x, s, m, e, z, j, k; + + // Test for NaN and round fractionDigits down + f = $Number(fractionDigits); + f = isActualNaN(f) ? 0 : floor(f); + + if (f < 0 || f > 20) { + throw new RangeError('Number.toFixed called with invalid number of decimals'); + } + + x = $Number(this); + + if (isActualNaN(x)) { + return 'NaN'; + } + + // If it is too big or small, return the string value of the number + if (x <= -1e21 || x >= 1e21) { + return $String(x); + } + + s = ''; + + if (x < 0) { + s = '-'; + x = -x; + } + + m = '0'; + + if (x > 1e-21) { + // 1e-21 < x < 1e21 + // -70 < log2(x) < 70 + e = toFixedHelpers.log(x * toFixedHelpers.pow(2, 69, 1)) - 69; + z = (e < 0 ? x * toFixedHelpers.pow(2, -e, 1) : x / toFixedHelpers.pow(2, e, 1)); + z *= 0x10000000000000; // pow(2, 52); + e = 52 - e; + + // -18 < e < 122 + // x = z / 2 ^ e + if (e > 0) { + toFixedHelpers.multiply(0, z); + j = f; + + while (j >= 7) { + toFixedHelpers.multiply(1e7, 0); + j -= 7; + } + + toFixedHelpers.multiply(toFixedHelpers.pow(10, j, 1), 0); + j = e - 1; + + while (j >= 23) { + toFixedHelpers.divide(1 << 23); + j -= 23; + } + + toFixedHelpers.divide(1 << j); + toFixedHelpers.multiply(1, 1); + toFixedHelpers.divide(2); + m = toFixedHelpers.numToString(); + } else { + toFixedHelpers.multiply(0, z); + toFixedHelpers.multiply(1 << (-e), 0); + m = toFixedHelpers.numToString() + strSlice('0.00000000000000000000', 2, 2 + f); + } + } + + if (f > 0) { + k = m.length; + + if (k <= f) { + m = s + strSlice('0.0000000000000000000', 0, f - k + 2) + m; + } else { + m = s + strSlice(m, 0, k - f) + '.' + strSlice(m, k - f); + } + } else { + m = s + m; + } + + return m; + }; + defineProperties(NumberPrototype, { toFixed: toFixedShim }, hasToFixedBugs); + + var hasToExponentialRoundingBug = (function () { + try { + return (-6.9e-11).toExponential(4) !== '-6.9000e-11'; + } catch (e) { + return false; + } + }()); + var toExponentialAllowsInfiniteDigits = (function () { + try { + (1).toExponential(Infinity); + (1).toExponential(-Infinity); + return true; + } catch (e) { + return false; + } + }()); + var originalToExponential = call.bind(NumberPrototype.toExponential); + var numberToString = call.bind(NumberPrototype.toString); + var numberValueOf = call.bind(NumberPrototype.valueOf); + defineProperties(NumberPrototype, { + toExponential: function toExponential(fractionDigits) { + // 1: Let x be this Number value. + var x = numberValueOf(this); + + if (typeof fractionDigits === 'undefined') { + return originalToExponential(x); + } + var f = ES.ToInteger(fractionDigits); + if (isActualNaN(x)) { + return 'NaN'; + } + + if (f < 0 || f > 20) { + if (!isFinite(f)) { + // IE 6 doesn't throw in the native one + throw new RangeError('toExponential() argument must be between 0 and 20'); + } + // this will probably have thrown already + return originalToExponential(x, f); + } + + // only cases left are a finite receiver + in-range fractionDigits + + // implementation adapted from https://gist.github.com/SheetJSDev/1100ad56b9f856c95299ed0e068eea08 + + // 4: Let s be the empty string + var s = ''; + + // 5: If x < 0 + if (x < 0) { + s = '-'; + x = -x; + } + + // 6: If x = +Infinity + if (x === Infinity) { + return s + 'Infinity'; + } + + // 7: If fractionDigits is not undefined and (f < 0 or f > 20), throw a RangeError exception. + if (typeof fractionDigits !== 'undefined' && (f < 0 || f > 20)) { + throw new RangeError('Fraction digits ' + fractionDigits + ' out of range'); + } + + var m = ''; + var e = 0; + var c = ''; + var d = ''; + + // 8: If x = 0 then + if (x === 0) { + e = 0; + f = 0; + m = '0'; + } else { // 9: Else, x != 0 + var L = log10(x); + e = floor(L); // 10 ** e <= x and x < 10 ** (e+1) + var n = 0; + if (typeof fractionDigits !== 'undefined') { // eslint-disable-line no-negated-condition + var w = pow(10, e - f); // x / 10 ** (f+1) < w and w <= x / 10 ** f + n = round(x / w); // 10 ** f <= n and n < 10 ** (f+1) + if (2 * x >= (((2 * n) + 1) * w)) { + n += 1; // pick larger value + } + if (n >= pow(10, f + 1)) { // 10e-1 = 1e0 + n /= 10; + e += 1; + } + } else { + f = 16; // start from Math.ceil(Math.log10(Number.MAX_SAFE_INTEGER)) and loop down + var guess_n = round(pow(10, L - e + f)); + var target_f = f; + while (f-- > 0) { + guess_n = round(pow(10, L - e + f)); + if ( + abs((guess_n * pow(10, e - f)) - x) + <= abs((n * pow(10, e - target_f)) - x) + ) { + target_f = f; + n = guess_n; + } + } + } + m = numberToString(n, 10); + if (typeof fractionDigits === 'undefined') { + while (strSlice(m, -1) === '0') { + m = strSlice(m, 0, -1); + d += 1; + } + } + } + + // 10: If f != 0, then + if (f !== 0) { + m = strSlice(m, 0, 1) + '.' + strSlice(m, 1); + } + + // 11: If e = 0, then + if (e === 0) { + c = '+'; + d = '0'; + } else { // 12: Else + c = e > 0 ? '+' : '-'; + d = numberToString(abs(e), 10); + } + + // 13: Let m be the concatenation of the four Strings m, "e", c, and d. + m += 'e' + c + d; + + // 14: Return the concatenation of the Strings s and m. + return s + m; + } + }, hasToExponentialRoundingBug || toExponentialAllowsInfiniteDigits); + + var hasToPrecisionUndefinedBug = (function () { + try { + return 1.0.toPrecision(undefined) === '1'; + } catch (e) { + return true; + } + }()); + var originalToPrecision = call.bind(NumberPrototype.toPrecision); + defineProperties(NumberPrototype, { + toPrecision: function toPrecision(precision) { + return typeof precision === 'undefined' ? originalToPrecision(this) : originalToPrecision(this, precision); + } + }, hasToPrecisionUndefinedBug); + + // + // String + // ====== + // + + // ES5 15.5.4.14 + // https://es5.github.io/#x15.5.4.14 + + // [bugfix, IE lt 9, firefox 4, Konqueror, Opera, obscure browsers] + // Many browsers do not split properly with regular expressions or they + // do not perform the split correctly under obscure conditions. + // See https://blog.stevenlevithan.com/archives/cross-browser-split + // I've tested in many browsers and this seems to cover the deviant ones: + // 'ab'.split(/(?:ab)*/) should be ["", ""], not [""] + // '.'.split(/(.?)(.?)/) should be ["", ".", "", ""], not ["", ""] + // 'tesst'.split(/(s)*/) should be ["t", undefined, "e", "s", "t"], not + // [undefined, "t", undefined, "e", ...] + // ''.split(/.?/) should be [], not [""] + // '.'.split(/()()/) should be ["."], not ["", "", "."] + + if ( + 'ab'.split(/(?:ab)*/).length !== 2 + || '.'.split(/(.?)(.?)/).length !== 4 + || 'tesst'.split(/(s)*/)[1] === 't' + || 'test'.split(/(?:)/, -1).length !== 4 + || ''.split(/.?/).length + || '.'.split(/()()/).length > 1 + ) { + (function () { + var compliantExecNpcg = typeof (/()??/).exec('')[1] === 'undefined'; // NPCG: nonparticipating capturing group + var maxSafe32BitInt = pow(2, 32) - 1; + + StringPrototype.split = function split(separator, limit) { + var string = String(this); + if (typeof separator === 'undefined' && limit === 0) { + return []; + } + + // If `separator` is not a regex, use native split + if (!isRegex(separator)) { + return strSplit(this, separator, limit); + } + + var output = []; + var flags = (separator.ignoreCase ? 'i' : '') + + (separator.multiline ? 'm' : '') + + (separator.unicode ? 'u' : '') // in ES6 + + (separator.sticky ? 'y' : ''), // Firefox 3+ and ES6 + lastLastIndex = 0, + // Make `global` and avoid `lastIndex` issues by working with a copy + separator2, match, lastIndex, lastLength; + var separatorCopy = new RegExp(separator.source, flags + 'g'); + if (!compliantExecNpcg) { + // Doesn't need flags gy, but they don't hurt + separator2 = new RegExp('^' + separatorCopy.source + '$(?!\\s)', flags); + } + /* Values for `limit`, per the spec: + * If undefined: 4294967295 // maxSafe32BitInt + * If 0, Infinity, or NaN: 0 + * If positive number: limit = floor(limit); if (limit > 4294967295) limit -= 4294967296; + * If negative number: 4294967296 - floor(abs(limit)) + * If other: Type-convert, then use the above rules + */ + var splitLimit = typeof limit === 'undefined' ? maxSafe32BitInt : ES.ToUint32(limit); + match = separatorCopy.exec(string); + while (match) { + // `separatorCopy.lastIndex` is not reliable cross-browser + lastIndex = match.index + match[0].length; + if (lastIndex > lastLastIndex) { + pushCall(output, strSlice(string, lastLastIndex, match.index)); + // Fix browsers whose `exec` methods don't consistently return `undefined` for + // nonparticipating capturing groups + if (!compliantExecNpcg && match.length > 1) { + /* eslint-disable no-loop-func */ + match[0].replace(separator2, function () { + for (var i = 1; i < arguments.length - 2; i++) { + if (typeof arguments[i] === 'undefined') { + match[i] = void 0; + } + } + }); + /* eslint-enable no-loop-func */ + } + if (match.length > 1 && match.index < string.length) { + array_push.apply(output, arraySlice(match, 1)); + } + lastLength = match[0].length; + lastLastIndex = lastIndex; + if (output.length >= splitLimit) { + break; + } + } + if (separatorCopy.lastIndex === match.index) { + separatorCopy.lastIndex++; // Avoid an infinite loop + } + match = separatorCopy.exec(string); + } + if (lastLastIndex === string.length) { + if (lastLength || !separatorCopy.test('')) { + pushCall(output, ''); + } + } else { + pushCall(output, strSlice(string, lastLastIndex)); + } + return output.length > splitLimit ? arraySlice(output, 0, splitLimit) : output; + }; + }()); + + // [bugfix, chrome] + // If separator is undefined, then the result array contains just one String, + // which is the this value (converted to a String). If limit is not undefined, + // then the output array is truncated so that it contains no more than limit + // elements. + // "0".split(undefined, 0) -> [] + } else if ('0'.split(void 0, 0).length) { + StringPrototype.split = function split(separator, limit) { + if (typeof separator === 'undefined' && limit === 0) { + return []; + } + return strSplit(this, separator, limit); + }; + } + + var str_replace = StringPrototype.replace; + var replaceReportsGroupsCorrectly = (function () { + var groups = []; + 'x'.replace(/x(.)?/g, function (match, group) { + pushCall(groups, group); + }); + return groups.length === 1 && typeof groups[0] === 'undefined'; + }()); + + if (!replaceReportsGroupsCorrectly) { + StringPrototype.replace = function replace(searchValue, replaceValue) { + var isFn = isCallable(replaceValue); + var hasCapturingGroups = isRegex(searchValue) && (/\)[*?]/).test(searchValue.source); + if (!isFn || !hasCapturingGroups) { + return str_replace.call(this, searchValue, replaceValue); + } + var wrappedReplaceValue = function (match) { + var length = arguments.length; + var originalLastIndex = searchValue.lastIndex; + searchValue.lastIndex = 0; // eslint-disable-line no-param-reassign + var args = searchValue.exec(match) || []; + searchValue.lastIndex = originalLastIndex; // eslint-disable-line no-param-reassign + pushCall(args, arguments[length - 2], arguments[length - 1]); + return replaceValue.apply(this, args); + }; + return str_replace.call(this, searchValue, wrappedReplaceValue); + + }; + } + + // ECMA-262, 3rd B.2.3 + // Not an ECMAScript standard, although ECMAScript 3rd Edition has a + // non-normative section suggesting uniform semantics and it should be + // normalized across all browsers + // [bugfix, IE lt 9] IE < 9 substr() with negative value not working in IE + var hasNegativeSubstrBug = ''.substr && '0b'.substr(-1) !== 'b'; + var string_substr = hasNegativeSubstrBug && call.bind(StringPrototype.substr); + defineProperties(StringPrototype, { + substr: function substr(start, length) { + var normalizedStart = start; + if (start < 0) { + normalizedStart = max(this.length + start, 0); + } + return string_substr(this, normalizedStart, length); + } + }, hasNegativeSubstrBug); + + // ES5 15.5.4.20 + // whitespace from: https://es5.github.io/#x15.5.4.20 + var mvs = '\u180E'; + var mvsIsWS = (/\s/).test(mvs); + var ws = '\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF' + .replace(/\S/g, ''); // remove the mongolian vowel separator (\u180E) in modern engines + var zeroWidth = '\u200b'; + var wsRegexChars = '[' + ws + ']'; + var trimBeginRegexp = new RegExp('^' + wsRegexChars + wsRegexChars + '*'); + var trimEndRegexp = new RegExp(wsRegexChars + wsRegexChars + '*$'); + var hasTrimWhitespaceBug = StringPrototype.trim && ( + ws.trim() !== '' // if ws is not considered whitespace + || zeroWidth.trim() === '' // if zero-width IS considered whitespace + || mvs.trim() !== (mvsIsWS ? '' : mvs) // if MVS is either wrongly considered whitespace, or, wrongly considered NOT whitespace + ); + defineProperties(StringPrototype, { + // https://blog.stevenlevithan.com/archives/faster-trim-javascript + // http://perfectionkills.com/whitespace-deviations/ + trim: function trim() { + + if (typeof this === 'undefined' || this === null) { + throw new TypeError("can't convert " + this + ' to object'); + } + return $String(this).replace(trimBeginRegexp, '').replace(trimEndRegexp, ''); + } + }, hasTrimWhitespaceBug); + var trim = call.bind(String.prototype.trim); + + var hasLastIndexBug = StringPrototype.lastIndexOf && 'abcあい'.lastIndexOf('あい', 2) !== -1; + defineProperties(StringPrototype, { + lastIndexOf: function lastIndexOf(searchString) { + if (typeof this === 'undefined' || this === null) { + throw new TypeError("can't convert " + this + ' to object'); + } + var S = $String(this); + var searchStr = $String(searchString); + var numPos = arguments.length > 1 ? $Number(arguments[1]) : NaN; + var pos = isActualNaN(numPos) ? Infinity : ES.ToInteger(numPos); + var start = min(max(pos, 0), S.length); + var searchLen = searchStr.length; + var k = start + searchLen; + while (k > 0) { + k = max(0, k - searchLen); + var index = strIndexOf(strSlice(S, k, start + searchLen), searchStr); + if (index !== -1) { + return k + index; + } + } + return -1; + } + }, hasLastIndexBug); + + var originalLastIndexOf = StringPrototype.lastIndexOf; + defineProperties(StringPrototype, { + lastIndexOf: function lastIndexOf(searchString) { + return originalLastIndexOf.apply(this, arguments); + } + }, StringPrototype.lastIndexOf.length !== 1); + + var hexRegex = /^[-+]?0[xX]/; + + // ES-5 15.1.2.2 + if ( + parseInt(ws + '08') !== 8 // eslint-disable-line radix + || parseInt(ws + '0x16') !== 22 // eslint-disable-line radix + || (mvsIsWS ? parseInt(mvs + 1) !== 1 : !isNaN(parseInt(mvs + 1))) // eslint-disable-line radix + ) { + // eslint-disable-next-line no-global-assign, no-implicit-globals + parseInt = (function (origParseInt) { + return function parseInt(str, radix) { + var string = trim(String(str)); + var defaultedRadix = $Number(radix) || (hexRegex.test(string) ? 16 : 10); + return origParseInt(string, defaultedRadix); + }; + }(parseInt)); + } + // Edge 15-18 + var parseIntFailsToThrowOnBoxedSymbols = (function () { + if (typeof Symbol !== 'function') { + return false; + } + try { + // eslint-disable-next-line radix + parseInt(Object(Symbol.iterator)); + return true; + } catch (e) { /**/ } + + try { + // eslint-disable-next-line radix + parseInt(Symbol.iterator); + return true; + } catch (e) { /**/ } + + return false; + }()); + if (parseIntFailsToThrowOnBoxedSymbols) { + var symbolValueOf = Symbol.prototype.valueOf; + // eslint-disable-next-line no-global-assign, no-implicit-globals + parseInt = (function (origParseInt) { + return function parseInt(str, radix) { + var isSym = typeof str === 'symbol'; + if (!isSym && str && typeof str === 'object') { + try { + symbolValueOf.call(str); + isSym = true; + } catch (e) { /**/ } + } + if (isSym) { + // handle Symbols in node 8.3/8.4 + // eslint-disable-next-line no-implicit-coercion, no-unused-expressions + '' + str; // jscs:ignore disallowImplicitTypeConversion + } + var string = trim(String(str)); + var defaultedRadix = $Number(radix) || (hexRegex.test(string) ? 16 : 10); + return origParseInt(string, defaultedRadix); + }; + }(parseInt)); + } + + // https://es5.github.io/#x15.1.2.3 + if (1 / parseFloat('-0') !== -Infinity) { + // eslint-disable-next-line no-global-assign, no-implicit-globals, no-native-reassign + parseFloat = (function (origParseFloat) { + return function parseFloat(string) { + var inputString = trim(String(string)); + var result = origParseFloat(inputString); + return result === 0 && strSlice(inputString, 0, 1) === '-' ? -0 : result; + }; + }(parseFloat)); + } + + if (String(new RangeError('test')) !== 'RangeError: test') { + var errorToStringShim = function toString() { + if (typeof this === 'undefined' || this === null) { + throw new TypeError("can't convert " + this + ' to object'); + } + var name = this.name; + if (typeof name === 'undefined') { + name = 'Error'; + } else if (typeof name !== 'string') { + name = $String(name); + } + var msg = this.message; + if (typeof msg === 'undefined') { + msg = ''; + } else if (typeof msg !== 'string') { + msg = $String(msg); + } + if (!name) { + return msg; + } + if (!msg) { + return name; + } + return name + ': ' + msg; + }; + // can't use defineProperties here because of toString enumeration issue in IE <= 8 + Error.prototype.toString = errorToStringShim; + } + + if (supportsDescriptors) { + var ensureNonEnumerable = function (obj, prop) { + if (isEnum(obj, prop)) { + var desc = Object.getOwnPropertyDescriptor(obj, prop); + if (desc.configurable) { + desc.enumerable = false; + Object.defineProperty(obj, prop, desc); + } + } + }; + ensureNonEnumerable(Error.prototype, 'message'); + if (Error.prototype.message !== '') { + Error.prototype.message = ''; + } + ensureNonEnumerable(Error.prototype, 'name'); + } + + if (String(/a/mig) !== '/a/gim') { + var regexToString = function toString() { + var str = '/' + this.source + '/'; + if (this.global) { + str += 'g'; + } + if (this.ignoreCase) { + str += 'i'; + } + if (this.multiline) { + str += 'm'; + } + return str; + }; + // can't use defineProperties here because of toString enumeration issue in IE <= 8 + RegExp.prototype.toString = regexToString; + } + })); + } (es5Shim$1)); + return es5Shim$1.exports; +} + +requireEs5Shim(); diff --git a/test/form/samples/supports-es6-shim/_config.js b/test/form/samples/supports-es6-shim/_config.js index 0697dbda361..442c76aefa0 100644 --- a/test/form/samples/supports-es6-shim/_config.js +++ b/test/form/samples/supports-es6-shim/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'supports es6-shim', options: { onwarn(warning) { @@ -10,7 +10,7 @@ module.exports = { treeshake: true, plugins: [ require('@rollup/plugin-node-resolve').default(), - require('@rollup/plugin-commonjs')() + require('@rollup/plugin-commonjs').default() ] } -}; +}); diff --git a/test/form/samples/supports-es6-shim/_expected.js b/test/form/samples/supports-es6-shim/_expected.js index eb47b8951c0..2a33f1fb926 100644 --- a/test/form/samples/supports-es6-shim/_expected.js +++ b/test/form/samples/supports-es6-shim/_expected.js @@ -1,6 +1,6 @@ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; -var es6Shim = {exports: {}}; +var es6Shim$1 = {exports: {}}; /*! * https://github.com/paulmillr/es6-shim @@ -11,3878 +11,3893 @@ var es6Shim = {exports: {}}; * Details and documentation: * https://github.com/paulmillr/es6-shim/ */ - -(function (module, exports) { -// UMD (Universal Module Definition) -// see https://github.com/umdjs/umd/blob/master/returnExports.js -(function (root, factory) { - /*global define */ - { - // Node. Does not work with strict CommonJS, but - // only CommonJS-like environments that support module.exports, - // like Node. - module.exports = factory(); - } -}(commonjsGlobal, function () { - - var _apply = Function.call.bind(Function.apply); - var _call = Function.call.bind(Function.call); - var isArray = Array.isArray; - var keys = Object.keys; - - var not = function notThunker(func) { - return function notThunk() { - return !_apply(func, this, arguments); - }; - }; - var throwsError = function (func) { - try { - func(); - return false; - } catch (e) { - return true; - } - }; - var valueOrFalseIfThrows = function valueOrFalseIfThrows(func) { - try { - return func(); - } catch (e) { - return false; - } - }; - - var isCallableWithoutNew = not(throwsError); - var arePropertyDescriptorsSupported = function () { - // if Object.defineProperty exists but throws, it's IE 8 - return !throwsError(function () { - return Object.defineProperty({}, 'x', { get: function () { } }); // eslint-disable-line getter-return - }); - }; - var supportsDescriptors = !!Object.defineProperty && arePropertyDescriptorsSupported(); - var functionsHaveNames = (function foo() {}).name === 'foo'; // eslint-disable-line no-extra-parens - - var _forEach = Function.call.bind(Array.prototype.forEach); - var _reduce = Function.call.bind(Array.prototype.reduce); - var _filter = Function.call.bind(Array.prototype.filter); - var _some = Function.call.bind(Array.prototype.some); - - var defineProperty = function (object, name, value, force) { - if (!force && name in object) { return; } - if (supportsDescriptors) { - Object.defineProperty(object, name, { - configurable: true, - enumerable: false, - writable: true, - value: value - }); - } else { - object[name] = value; - } - }; - - // Define configurable, writable and non-enumerable props - // if they don’t exist. - var defineProperties = function (object, map, forceOverride) { - _forEach(keys(map), function (name) { - var method = map[name]; - defineProperty(object, name, method, !!forceOverride); - }); - }; - - var _toString = Function.call.bind(Object.prototype.toString); - var isCallable = typeof /abc/ === 'function' ? function IsCallableSlow(x) { - // Some old browsers (IE, FF) say that typeof /abc/ === 'function' - return typeof x === 'function' && _toString(x) === '[object Function]'; - } : function IsCallableFast(x) { return typeof x === 'function'; }; - - var Value = { - getter: function (object, name, getter) { - if (!supportsDescriptors) { - throw new TypeError('getters require true ES5 support'); - } - Object.defineProperty(object, name, { - configurable: true, - enumerable: false, - get: getter - }); - }, - proxy: function (originalObject, key, targetObject) { - if (!supportsDescriptors) { - throw new TypeError('getters require true ES5 support'); - } - var originalDescriptor = Object.getOwnPropertyDescriptor(originalObject, key); - Object.defineProperty(targetObject, key, { - configurable: originalDescriptor.configurable, - enumerable: originalDescriptor.enumerable, - get: function getKey() { return originalObject[key]; }, - set: function setKey(value) { originalObject[key] = value; } - }); - }, - redefine: function (object, property, newValue) { - if (supportsDescriptors) { - var descriptor = Object.getOwnPropertyDescriptor(object, property); - descriptor.value = newValue; - Object.defineProperty(object, property, descriptor); - } else { - object[property] = newValue; - } - }, - defineByDescriptor: function (object, property, descriptor) { - if (supportsDescriptors) { - Object.defineProperty(object, property, descriptor); - } else if ('value' in descriptor) { - object[property] = descriptor.value; - } - }, - preserveToString: function (target, source) { - if (source && isCallable(source.toString)) { - defineProperty(target, 'toString', source.toString.bind(source), true); - } - } - }; - - // Simple shim for Object.create on ES3 browsers - // (unlike real shim, no attempt to support `prototype === null`) - var create = Object.create || function (prototype, properties) { - var Prototype = function Prototype() {}; - Prototype.prototype = prototype; - var object = new Prototype(); - if (typeof properties !== 'undefined') { - keys(properties).forEach(function (key) { - Value.defineByDescriptor(object, key, properties[key]); - }); - } - return object; - }; - - var supportsSubclassing = function (C, f) { - if (!Object.setPrototypeOf) { return false; /* skip test on IE < 11 */ } - return valueOrFalseIfThrows(function () { - var Sub = function Subclass(arg) { - var o = new C(arg); - Object.setPrototypeOf(o, Subclass.prototype); - return o; - }; - Object.setPrototypeOf(Sub, C); - Sub.prototype = create(C.prototype, { - constructor: { value: Sub } - }); - return f(Sub); - }); - }; - - var getGlobal = function () { - /* global self, window */ - // the only reliable means to get the global object is - // `Function('return this')()` - // However, this causes CSP violations in Chrome apps. - if (typeof self !== 'undefined') { return self; } - if (typeof window !== 'undefined') { return window; } - if (typeof commonjsGlobal !== 'undefined') { return commonjsGlobal; } - throw new Error('unable to locate global object'); - }; - - var globals = getGlobal(); - var globalIsFinite = globals.isFinite; - var _indexOf = Function.call.bind(String.prototype.indexOf); - var _arrayIndexOfApply = Function.apply.bind(Array.prototype.indexOf); - var _concat = Function.call.bind(Array.prototype.concat); - // var _sort = Function.call.bind(Array.prototype.sort); - var _strSlice = Function.call.bind(String.prototype.slice); - var _push = Function.call.bind(Array.prototype.push); - var _pushApply = Function.apply.bind(Array.prototype.push); - var _join = Function.call.bind(Array.prototype.join); - var _shift = Function.call.bind(Array.prototype.shift); - var _max = Math.max; - var _min = Math.min; - var _floor = Math.floor; - var _abs = Math.abs; - var _exp = Math.exp; - var _log = Math.log; - var _sqrt = Math.sqrt; - var _hasOwnProperty = Function.call.bind(Object.prototype.hasOwnProperty); - var ArrayIterator; // make our implementation private - var noop = function () {}; - - var OrigMap = globals.Map; - var origMapDelete = OrigMap && OrigMap.prototype['delete']; - var origMapGet = OrigMap && OrigMap.prototype.get; - var origMapHas = OrigMap && OrigMap.prototype.has; - var origMapSet = OrigMap && OrigMap.prototype.set; - - var Symbol = globals.Symbol || {}; - var symbolSpecies = Symbol.species || '@@species'; - - var numberIsNaN = Number.isNaN || function isNaN(value) { - // NaN !== NaN, but they are identical. - // NaNs are the only non-reflexive value, i.e., if x !== x, - // then x is NaN. - // isNaN is broken: it converts its argument to number, so - // isNaN('foo') => true - return value !== value; - }; - var numberIsFinite = Number.isFinite || function isFinite(value) { - return typeof value === 'number' && globalIsFinite(value); - }; - var _sign = isCallable(Math.sign) ? Math.sign : function sign(value) { - var number = Number(value); - if (number === 0) { return number; } - if (numberIsNaN(number)) { return number; } - return number < 0 ? -1 : 1; - }; - var _log1p = function log1p(value) { - var x = Number(value); - if (x < -1 || numberIsNaN(x)) { return NaN; } - if (x === 0 || x === Infinity) { return x; } - if (x === -1) { return -Infinity; } - - return (1 + x) - 1 === 0 ? x : x * (_log(1 + x) / ((1 + x) - 1)); - }; - - // taken directly from https://github.com/ljharb/is-arguments/blob/master/index.js - // can be replaced with require('is-arguments') if we ever use a build process instead - var isStandardArguments = function isArguments(value) { - return _toString(value) === '[object Arguments]'; - }; - var isLegacyArguments = function isArguments(value) { - return value !== null && - typeof value === 'object' && - typeof value.length === 'number' && - value.length >= 0 && - _toString(value) !== '[object Array]' && - _toString(value.callee) === '[object Function]'; - }; - var isArguments = isStandardArguments(arguments) ? isStandardArguments : isLegacyArguments; - - var Type = { - primitive: function (x) { return x === null || (typeof x !== 'function' && typeof x !== 'object'); }, - string: function (x) { return _toString(x) === '[object String]'; }, - regex: function (x) { return _toString(x) === '[object RegExp]'; }, - symbol: function (x) { - return typeof globals.Symbol === 'function' && typeof x === 'symbol'; - } - }; - - var overrideNative = function overrideNative(object, property, replacement) { - var original = object[property]; - defineProperty(object, property, replacement, true); - Value.preserveToString(object[property], original); - }; - - // eslint-disable-next-line no-restricted-properties - var hasSymbols = typeof Symbol === 'function' && typeof Symbol['for'] === 'function' && Type.symbol(Symbol()); - - // This is a private name in the es6 spec, equal to '[Symbol.iterator]' - // we're going to use an arbitrary _-prefixed name to make our shims - // work properly with each other, even though we don't have full Iterator - // support. That is, `Array.from(map.keys())` will work, but we don't - // pretend to export a "real" Iterator interface. - var $iterator$ = Type.symbol(Symbol.iterator) ? Symbol.iterator : '_es6-shim iterator_'; - // Firefox ships a partial implementation using the name @@iterator. - // https://bugzilla.mozilla.org/show_bug.cgi?id=907077#c14 - // So use that name if we detect it. - if (globals.Set && typeof new globals.Set()['@@iterator'] === 'function') { - $iterator$ = '@@iterator'; - } - - // Reflect - if (!globals.Reflect) { - defineProperty(globals, 'Reflect', {}, true); - } - var Reflect = globals.Reflect; - - var $String = String; - - /* global document */ - var domAll = (typeof document === 'undefined' || !document) ? null : document.all; - var isNullOrUndefined = domAll == null ? function isNullOrUndefined(x) { - return x == null; - } : function isNullOrUndefinedAndNotDocumentAll(x) { - return x == null && x !== domAll; - }; - - var ES = { - // http://www.ecma-international.org/ecma-262/6.0/#sec-call - Call: function Call(F, V) { - var args = arguments.length > 2 ? arguments[2] : []; - if (!ES.IsCallable(F)) { - throw new TypeError(F + ' is not a function'); - } - return _apply(F, V, args); - }, - - RequireObjectCoercible: function (x, optMessage) { - if (isNullOrUndefined(x)) { - throw new TypeError(optMessage || 'Cannot call method on ' + x); - } - return x; - }, - - // This might miss the "(non-standard exotic and does not implement - // [[Call]])" case from - // http://www.ecma-international.org/ecma-262/6.0/#sec-typeof-operator-runtime-semantics-evaluation - // but we can't find any evidence these objects exist in practice. - // If we find some in the future, you could test `Object(x) === x`, - // which is reliable according to - // http://www.ecma-international.org/ecma-262/6.0/#sec-toobject - // but is not well optimized by runtimes and creates an object - // whenever it returns false, and thus is very slow. - TypeIsObject: function (x) { - if (x === void 0 || x === null || x === true || x === false) { - return false; - } - return typeof x === 'function' || typeof x === 'object' || x === domAll; - }, - - ToObject: function (o, optMessage) { - return Object(ES.RequireObjectCoercible(o, optMessage)); - }, - - IsCallable: isCallable, - - IsConstructor: function (x) { - // We can't tell callables from constructors in ES5 - return ES.IsCallable(x); - }, - - ToInt32: function (x) { - return ES.ToNumber(x) >> 0; - }, - - ToUint32: function (x) { - return ES.ToNumber(x) >>> 0; - }, - - ToNumber: function (value) { - if (hasSymbols && _toString(value) === '[object Symbol]') { - throw new TypeError('Cannot convert a Symbol value to a number'); - } - return +value; - }, - - ToInteger: function (value) { - var number = ES.ToNumber(value); - if (numberIsNaN(number)) { return 0; } - if (number === 0 || !numberIsFinite(number)) { return number; } - return (number > 0 ? 1 : -1) * _floor(_abs(number)); - }, - - ToLength: function (value) { - var len = ES.ToInteger(value); - if (len <= 0) { return 0; } // includes converting -0 to +0 - if (len > Number.MAX_SAFE_INTEGER) { return Number.MAX_SAFE_INTEGER; } - return len; - }, - - SameValue: function (a, b) { - if (a === b) { - // 0 === -0, but they are not identical. - if (a === 0) { return 1 / a === 1 / b; } - return true; - } - return numberIsNaN(a) && numberIsNaN(b); - }, - - SameValueZero: function (a, b) { - // same as SameValue except for SameValueZero(+0, -0) == true - return (a === b) || (numberIsNaN(a) && numberIsNaN(b)); - }, - - IsIterable: function (o) { - return ES.TypeIsObject(o) && (typeof o[$iterator$] !== 'undefined' || isArguments(o)); - }, - - GetIterator: function (o) { - if (isArguments(o)) { - // special case support for `arguments` - return new ArrayIterator(o, 'value'); - } - var itFn = ES.GetMethod(o, $iterator$); - if (!ES.IsCallable(itFn)) { - // Better diagnostics if itFn is null or undefined - throw new TypeError('value is not an iterable'); - } - var it = ES.Call(itFn, o); - if (!ES.TypeIsObject(it)) { - throw new TypeError('bad iterator'); - } - return it; - }, - - GetMethod: function (o, p) { - var func = ES.ToObject(o)[p]; - if (isNullOrUndefined(func)) { - return void 0; - } - if (!ES.IsCallable(func)) { - throw new TypeError('Method not callable: ' + p); - } - return func; - }, - - IteratorComplete: function (iterResult) { - return !!iterResult.done; - }, - - IteratorClose: function (iterator, completionIsThrow) { - var returnMethod = ES.GetMethod(iterator, 'return'); - if (returnMethod === void 0) { - return; - } - var innerResult, innerException; - try { - innerResult = ES.Call(returnMethod, iterator); - } catch (e) { - innerException = e; - } - if (completionIsThrow) { - return; - } - if (innerException) { - throw innerException; - } - if (!ES.TypeIsObject(innerResult)) { - throw new TypeError("Iterator's return method returned a non-object."); - } - }, - - IteratorNext: function (it) { - var result = arguments.length > 1 ? it.next(arguments[1]) : it.next(); - if (!ES.TypeIsObject(result)) { - throw new TypeError('bad iterator'); - } - return result; - }, - - IteratorStep: function (it) { - var result = ES.IteratorNext(it); - var done = ES.IteratorComplete(result); - return done ? false : result; - }, - - Construct: function (C, args, newTarget, isES6internal) { - var target = typeof newTarget === 'undefined' ? C : newTarget; - - if (!isES6internal && Reflect.construct) { - // Try to use Reflect.construct if available - return Reflect.construct(C, args, target); - } - // OK, we have to fake it. This will only work if the - // C.[[ConstructorKind]] == "base" -- but that's the only - // kind we can make in ES5 code anyway. - - // OrdinaryCreateFromConstructor(target, "%ObjectPrototype%") - var proto = target.prototype; - if (!ES.TypeIsObject(proto)) { - proto = Object.prototype; - } - var obj = create(proto); - // Call the constructor. - var result = ES.Call(C, obj, args); - return ES.TypeIsObject(result) ? result : obj; - }, - - SpeciesConstructor: function (O, defaultConstructor) { - var C = O.constructor; - if (C === void 0) { - return defaultConstructor; - } - if (!ES.TypeIsObject(C)) { - throw new TypeError('Bad constructor'); - } - var S = C[symbolSpecies]; - if (isNullOrUndefined(S)) { - return defaultConstructor; - } - if (!ES.IsConstructor(S)) { - throw new TypeError('Bad @@species'); - } - return S; - }, - - CreateHTML: function (string, tag, attribute, value) { - var S = ES.ToString(string); - var p1 = '<' + tag; - if (attribute !== '') { - var V = ES.ToString(value); - var escapedV = V.replace(/"/g, '"'); - p1 += ' ' + attribute + '="' + escapedV + '"'; - } - var p2 = p1 + '>'; - var p3 = p2 + S; - return p3 + ''; - }, - - IsRegExp: function IsRegExp(argument) { - if (!ES.TypeIsObject(argument)) { - return false; - } - var isRegExp = argument[Symbol.match]; - if (typeof isRegExp !== 'undefined') { - return !!isRegExp; - } - return Type.regex(argument); - }, - - ToString: function ToString(string) { - if (hasSymbols && _toString(string) === '[object Symbol]') { - throw new TypeError('Cannot convert a Symbol value to a number'); - } - return $String(string); - } - }; - - // Well-known Symbol shims - if (supportsDescriptors && hasSymbols) { - var defineWellKnownSymbol = function defineWellKnownSymbol(name) { - if (Type.symbol(Symbol[name])) { - return Symbol[name]; - } - // eslint-disable-next-line no-restricted-properties - var sym = Symbol['for']('Symbol.' + name); - Object.defineProperty(Symbol, name, { - configurable: false, - enumerable: false, - writable: false, - value: sym - }); - return sym; - }; - if (!Type.symbol(Symbol.search)) { - var symbolSearch = defineWellKnownSymbol('search'); - var originalSearch = String.prototype.search; - defineProperty(RegExp.prototype, symbolSearch, function search(string) { - return ES.Call(originalSearch, string, [this]); - }); - var searchShim = function search(regexp) { - var O = ES.RequireObjectCoercible(this); - if (!isNullOrUndefined(regexp)) { - var searcher = ES.GetMethod(regexp, symbolSearch); - if (typeof searcher !== 'undefined') { - return ES.Call(searcher, regexp, [O]); - } - } - return ES.Call(originalSearch, O, [ES.ToString(regexp)]); - }; - overrideNative(String.prototype, 'search', searchShim); - } - if (!Type.symbol(Symbol.replace)) { - var symbolReplace = defineWellKnownSymbol('replace'); - var originalReplace = String.prototype.replace; - defineProperty(RegExp.prototype, symbolReplace, function replace(string, replaceValue) { - return ES.Call(originalReplace, string, [this, replaceValue]); - }); - var replaceShim = function replace(searchValue, replaceValue) { - var O = ES.RequireObjectCoercible(this); - if (!isNullOrUndefined(searchValue)) { - var replacer = ES.GetMethod(searchValue, symbolReplace); - if (typeof replacer !== 'undefined') { - return ES.Call(replacer, searchValue, [O, replaceValue]); - } - } - return ES.Call(originalReplace, O, [ES.ToString(searchValue), replaceValue]); - }; - overrideNative(String.prototype, 'replace', replaceShim); - } - if (!Type.symbol(Symbol.split)) { - var symbolSplit = defineWellKnownSymbol('split'); - var originalSplit = String.prototype.split; - defineProperty(RegExp.prototype, symbolSplit, function split(string, limit) { - return ES.Call(originalSplit, string, [this, limit]); - }); - var splitShim = function split(separator, limit) { - var O = ES.RequireObjectCoercible(this); - if (!isNullOrUndefined(separator)) { - var splitter = ES.GetMethod(separator, symbolSplit); - if (typeof splitter !== 'undefined') { - return ES.Call(splitter, separator, [O, limit]); - } - } - return ES.Call(originalSplit, O, [ES.ToString(separator), limit]); - }; - overrideNative(String.prototype, 'split', splitShim); - } - var symbolMatchExists = Type.symbol(Symbol.match); - var stringMatchIgnoresSymbolMatch = symbolMatchExists && (function () { - // Firefox 41, through Nightly 45 has Symbol.match, but String#match ignores it. - // Firefox 40 and below have Symbol.match but String#match works fine. - var o = {}; - o[Symbol.match] = function () { return 42; }; - return 'a'.match(o) !== 42; - }()); - if (!symbolMatchExists || stringMatchIgnoresSymbolMatch) { - var symbolMatch = defineWellKnownSymbol('match'); - - var originalMatch = String.prototype.match; - defineProperty(RegExp.prototype, symbolMatch, function match(string) { - return ES.Call(originalMatch, string, [this]); - }); - - var matchShim = function match(regexp) { - var O = ES.RequireObjectCoercible(this); - if (!isNullOrUndefined(regexp)) { - var matcher = ES.GetMethod(regexp, symbolMatch); - if (typeof matcher !== 'undefined') { - return ES.Call(matcher, regexp, [O]); - } - } - return ES.Call(originalMatch, O, [ES.ToString(regexp)]); - }; - overrideNative(String.prototype, 'match', matchShim); - } - } - - var wrapConstructor = function wrapConstructor(original, replacement, keysToSkip) { - Value.preserveToString(replacement, original); - if (Object.setPrototypeOf) { - // sets up proper prototype chain where possible - Object.setPrototypeOf(original, replacement); - } - if (supportsDescriptors) { - _forEach(Object.getOwnPropertyNames(original), function (key) { - if (key in noop || keysToSkip[key]) { return; } - Value.proxy(original, key, replacement); - }); - } else { - _forEach(Object.keys(original), function (key) { - if (key in noop || keysToSkip[key]) { return; } - replacement[key] = original[key]; - }); - } - replacement.prototype = original.prototype; - Value.redefine(original.prototype, 'constructor', replacement); - }; - - var defaultSpeciesGetter = function () { return this; }; - var addDefaultSpecies = function (C) { - if (supportsDescriptors && !_hasOwnProperty(C, symbolSpecies)) { - Value.getter(C, symbolSpecies, defaultSpeciesGetter); - } - }; - - var addIterator = function (prototype, impl) { - var implementation = impl || function iterator() { return this; }; - defineProperty(prototype, $iterator$, implementation); - if (!prototype[$iterator$] && Type.symbol($iterator$)) { - // implementations are buggy when $iterator$ is a Symbol - prototype[$iterator$] = implementation; - } - }; - - var createDataProperty = function createDataProperty(object, name, value) { - if (supportsDescriptors) { - Object.defineProperty(object, name, { - configurable: true, - enumerable: true, - writable: true, - value: value - }); - } else { - object[name] = value; - } - }; - var createDataPropertyOrThrow = function createDataPropertyOrThrow(object, name, value) { - createDataProperty(object, name, value); - if (!ES.SameValue(object[name], value)) { - throw new TypeError('property is nonconfigurable'); - } - }; - - var emulateES6construct = function (o, defaultNewTarget, defaultProto, slots) { - // This is an es5 approximation to es6 construct semantics. in es6, - // 'new Foo' invokes Foo.[[Construct]] which (for almost all objects) - // just sets the internal variable NewTarget (in es6 syntax `new.target`) - // to Foo and then returns Foo(). - - // Many ES6 object then have constructors of the form: - // 1. If NewTarget is undefined, throw a TypeError exception - // 2. Let xxx by OrdinaryCreateFromConstructor(NewTarget, yyy, zzz) - - // So we're going to emulate those first two steps. - if (!ES.TypeIsObject(o)) { - throw new TypeError('Constructor requires `new`: ' + defaultNewTarget.name); - } - var proto = defaultNewTarget.prototype; - if (!ES.TypeIsObject(proto)) { - proto = defaultProto; - } - var obj = create(proto); - for (var name in slots) { - if (_hasOwnProperty(slots, name)) { - var value = slots[name]; - defineProperty(obj, name, value, true); - } - } - return obj; - }; - - // Firefox 31 reports this function's length as 0 - // https://bugzilla.mozilla.org/show_bug.cgi?id=1062484 - if (String.fromCodePoint && String.fromCodePoint.length !== 1) { - var originalFromCodePoint = String.fromCodePoint; - overrideNative(String, 'fromCodePoint', function fromCodePoint(codePoints) { - return ES.Call(originalFromCodePoint, this, arguments); - }); - } - - var StringShims = { - fromCodePoint: function fromCodePoint(codePoints) { - var result = []; - var next; - for (var i = 0, length = arguments.length; i < length; i++) { - next = Number(arguments[i]); - if (!ES.SameValue(next, ES.ToInteger(next)) || next < 0 || next > 0x10FFFF) { - throw new RangeError('Invalid code point ' + next); - } - - if (next < 0x10000) { - _push(result, String.fromCharCode(next)); - } else { - next -= 0x10000; - _push(result, String.fromCharCode((next >> 10) + 0xD800)); - _push(result, String.fromCharCode((next % 0x400) + 0xDC00)); - } - } - return _join(result, ''); - }, - - raw: function raw(template) { - var cooked = ES.ToObject(template, 'bad template'); - var raw = ES.ToObject(cooked.raw, 'bad raw value'); - var len = raw.length; - var literalSegments = ES.ToLength(len); - if (literalSegments <= 0) { - return ''; - } - - var stringElements = []; - var nextIndex = 0; - var nextKey, next, nextSeg, nextSub; - while (nextIndex < literalSegments) { - nextKey = ES.ToString(nextIndex); - nextSeg = ES.ToString(raw[nextKey]); - _push(stringElements, nextSeg); - if (nextIndex + 1 >= literalSegments) { - break; - } - next = nextIndex + 1 < arguments.length ? arguments[nextIndex + 1] : ''; - nextSub = ES.ToString(next); - _push(stringElements, nextSub); - nextIndex += 1; - } - return _join(stringElements, ''); - } - }; - if (String.raw && String.raw({ raw: { 0: 'x', 1: 'y', length: 2 } }) !== 'xy') { - // IE 11 TP has a broken String.raw implementation - overrideNative(String, 'raw', StringShims.raw); - } - defineProperties(String, StringShims); - - // Fast repeat, uses the `Exponentiation by squaring` algorithm. - // Perf: http://jsperf.com/string-repeat2/2 - var stringRepeat = function repeat(s, times) { - if (times < 1) { return ''; } - if (times % 2) { return repeat(s, times - 1) + s; } - var half = repeat(s, times / 2); - return half + half; - }; - var stringMaxLength = Infinity; - - var StringPrototypeShims = { - repeat: function repeat(times) { - var thisStr = ES.ToString(ES.RequireObjectCoercible(this)); - var numTimes = ES.ToInteger(times); - if (numTimes < 0 || numTimes >= stringMaxLength) { - throw new RangeError('repeat count must be less than infinity and not overflow maximum string size'); - } - return stringRepeat(thisStr, numTimes); - }, - - startsWith: function startsWith(searchString) { - var S = ES.ToString(ES.RequireObjectCoercible(this)); - if (ES.IsRegExp(searchString)) { - throw new TypeError('Cannot call method "startsWith" with a regex'); - } - var searchStr = ES.ToString(searchString); - var position; - if (arguments.length > 1) { - position = arguments[1]; - } - var start = _max(ES.ToInteger(position), 0); - return _strSlice(S, start, start + searchStr.length) === searchStr; - }, - - endsWith: function endsWith(searchString) { - var S = ES.ToString(ES.RequireObjectCoercible(this)); - if (ES.IsRegExp(searchString)) { - throw new TypeError('Cannot call method "endsWith" with a regex'); - } - var searchStr = ES.ToString(searchString); - var len = S.length; - var endPosition; - if (arguments.length > 1) { - endPosition = arguments[1]; - } - var pos = typeof endPosition === 'undefined' ? len : ES.ToInteger(endPosition); - var end = _min(_max(pos, 0), len); - return _strSlice(S, end - searchStr.length, end) === searchStr; - }, - - includes: function includes(searchString) { - if (ES.IsRegExp(searchString)) { - throw new TypeError('"includes" does not accept a RegExp'); - } - var searchStr = ES.ToString(searchString); - var position; - if (arguments.length > 1) { - position = arguments[1]; - } - // Somehow this trick makes method 100% compat with the spec. - return _indexOf(this, searchStr, position) !== -1; - }, - - codePointAt: function codePointAt(pos) { - var thisStr = ES.ToString(ES.RequireObjectCoercible(this)); - var position = ES.ToInteger(pos); - var length = thisStr.length; - if (position >= 0 && position < length) { - var first = thisStr.charCodeAt(position); - var isEnd = position + 1 === length; - if (first < 0xD800 || first > 0xDBFF || isEnd) { return first; } - var second = thisStr.charCodeAt(position + 1); - if (second < 0xDC00 || second > 0xDFFF) { return first; } - return ((first - 0xD800) * 1024) + (second - 0xDC00) + 0x10000; - } - } - }; - if (String.prototype.includes && 'a'.includes('a', Infinity) !== false) { - overrideNative(String.prototype, 'includes', StringPrototypeShims.includes); - } - - if (String.prototype.startsWith && String.prototype.endsWith) { - var startsWithRejectsRegex = throwsError(function () { - /* throws if spec-compliant */ - return '/a/'.startsWith(/a/); - }); - var startsWithHandlesInfinity = valueOrFalseIfThrows(function () { - return 'abc'.startsWith('a', Infinity) === false; - }); - if (!startsWithRejectsRegex || !startsWithHandlesInfinity) { - // Firefox (< 37?) and IE 11 TP have a noncompliant startsWith implementation - overrideNative(String.prototype, 'startsWith', StringPrototypeShims.startsWith); - overrideNative(String.prototype, 'endsWith', StringPrototypeShims.endsWith); - } - } - if (hasSymbols) { - var startsWithSupportsSymbolMatch = valueOrFalseIfThrows(function () { - var re = /a/; - re[Symbol.match] = false; - return '/a/'.startsWith(re); - }); - if (!startsWithSupportsSymbolMatch) { - overrideNative(String.prototype, 'startsWith', StringPrototypeShims.startsWith); - } - var endsWithSupportsSymbolMatch = valueOrFalseIfThrows(function () { - var re = /a/; - re[Symbol.match] = false; - return '/a/'.endsWith(re); - }); - if (!endsWithSupportsSymbolMatch) { - overrideNative(String.prototype, 'endsWith', StringPrototypeShims.endsWith); - } - var includesSupportsSymbolMatch = valueOrFalseIfThrows(function () { - var re = /a/; - re[Symbol.match] = false; - return '/a/'.includes(re); - }); - if (!includesSupportsSymbolMatch) { - overrideNative(String.prototype, 'includes', StringPrototypeShims.includes); - } - } - - defineProperties(String.prototype, StringPrototypeShims); - - // whitespace from: http://es5.github.io/#x15.5.4.20 - // implementation from https://github.com/es-shims/es5-shim/blob/v3.4.0/es5-shim.js#L1304-L1324 - var ws = [ - '\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003', - '\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028', - '\u2029\uFEFF' - ].join(''); - var trimRegexp = new RegExp('(^[' + ws + ']+)|([' + ws + ']+$)', 'g'); - var trimShim = function trim() { - return ES.ToString(ES.RequireObjectCoercible(this)).replace(trimRegexp, ''); - }; - var nonWS = ['\u0085', '\u200b', '\ufffe'].join(''); - var nonWSregex = new RegExp('[' + nonWS + ']', 'g'); - var isBadHexRegex = /^[-+]0x[0-9a-f]+$/i; - var hasStringTrimBug = nonWS.trim().length !== nonWS.length; - defineProperty(String.prototype, 'trim', trimShim, hasStringTrimBug); - - // Given an argument x, it will return an IteratorResult object, - // with value set to x and done to false. - // Given no arguments, it will return an iterator completion object. - var iteratorResult = function (x) { - return { value: x, done: arguments.length === 0 }; - }; - - // see http://www.ecma-international.org/ecma-262/6.0/#sec-string.prototype-@@iterator - var StringIterator = function (s) { - ES.RequireObjectCoercible(s); - this._s = ES.ToString(s); - this._i = 0; - }; - StringIterator.prototype.next = function () { - var s = this._s; - var i = this._i; - if (typeof s === 'undefined' || i >= s.length) { - this._s = void 0; - return iteratorResult(); - } - var first = s.charCodeAt(i); - var second, len; - if (first < 0xD800 || first > 0xDBFF || (i + 1) === s.length) { - len = 1; - } else { - second = s.charCodeAt(i + 1); - len = (second < 0xDC00 || second > 0xDFFF) ? 1 : 2; - } - this._i = i + len; - return iteratorResult(s.substr(i, len)); - }; - addIterator(StringIterator.prototype); - addIterator(String.prototype, function () { - return new StringIterator(this); - }); - - var ArrayShims = { - from: function from(items) { - var C = this; - var mapFn; - if (arguments.length > 1) { - mapFn = arguments[1]; - } - var mapping, T; - if (typeof mapFn === 'undefined') { - mapping = false; - } else { - if (!ES.IsCallable(mapFn)) { - throw new TypeError('Array.from: when provided, the second argument must be a function'); - } - if (arguments.length > 2) { - T = arguments[2]; - } - mapping = true; - } - - // Note that that Arrays will use ArrayIterator: - // https://bugs.ecmascript.org/show_bug.cgi?id=2416 - var usingIterator = typeof (isArguments(items) || ES.GetMethod(items, $iterator$)) !== 'undefined'; - - var length, result, i; - if (usingIterator) { - result = ES.IsConstructor(C) ? Object(new C()) : []; - var iterator = ES.GetIterator(items); - var next, nextValue; - - i = 0; - while (true) { - next = ES.IteratorStep(iterator); - if (next === false) { - break; - } - nextValue = next.value; - try { - if (mapping) { - nextValue = typeof T === 'undefined' ? mapFn(nextValue, i) : _call(mapFn, T, nextValue, i); - } - result[i] = nextValue; - } catch (e) { - ES.IteratorClose(iterator, true); - throw e; - } - i += 1; - } - length = i; - } else { - var arrayLike = ES.ToObject(items); - length = ES.ToLength(arrayLike.length); - result = ES.IsConstructor(C) ? Object(new C(length)) : new Array(length); - var value; - for (i = 0; i < length; ++i) { - value = arrayLike[i]; - if (mapping) { - value = typeof T === 'undefined' ? mapFn(value, i) : _call(mapFn, T, value, i); - } - createDataPropertyOrThrow(result, i, value); - } - } - - result.length = length; - return result; - }, - - of: function of() { - var len = arguments.length; - var C = this; - var A = isArray(C) || !ES.IsCallable(C) ? new Array(len) : ES.Construct(C, [len]); - for (var k = 0; k < len; ++k) { - createDataPropertyOrThrow(A, k, arguments[k]); - } - A.length = len; - return A; - } - }; - defineProperties(Array, ArrayShims); - addDefaultSpecies(Array); - - // Our ArrayIterator is private; see - // https://github.com/paulmillr/es6-shim/issues/252 - ArrayIterator = function (array, kind) { - this.i = 0; - this.array = array; - this.kind = kind; - }; - - defineProperties(ArrayIterator.prototype, { - next: function () { - var i = this.i; - var array = this.array; - if (!(this instanceof ArrayIterator)) { - throw new TypeError('Not an ArrayIterator'); - } - if (typeof array !== 'undefined') { - var len = ES.ToLength(array.length); - if (i < len) { - //for (; i < len; i++) { - var kind = this.kind; - var retval; - if (kind === 'key') { - retval = i; - } else if (kind === 'value') { - retval = array[i]; - } else if (kind === 'entry') { - retval = [i, array[i]]; - } - this.i = i + 1; - return iteratorResult(retval); - } - } - this.array = void 0; - return iteratorResult(); - } - }); - addIterator(ArrayIterator.prototype); - - /* - var orderKeys = function orderKeys(a, b) { - var aNumeric = String(ES.ToInteger(a)) === a; - var bNumeric = String(ES.ToInteger(b)) === b; - if (aNumeric && bNumeric) { - return b - a; - } else if (aNumeric && !bNumeric) { - return -1; - } else if (!aNumeric && bNumeric) { - return 1; - } else { - return a.localeCompare(b); - } - }; - - var getAllKeys = function getAllKeys(object) { - var ownKeys = []; - var keys = []; - - for (var key in object) { - _push(_hasOwnProperty(object, key) ? ownKeys : keys, key); - } - _sort(ownKeys, orderKeys); - _sort(keys, orderKeys); - - return _concat(ownKeys, keys); - }; - */ - - // note: this is positioned here because it depends on ArrayIterator - var arrayOfSupportsSubclassing = Array.of === ArrayShims.of || (function () { - // Detects a bug in Webkit nightly r181886 - var Foo = function Foo(len) { this.length = len; }; - Foo.prototype = []; - var fooArr = Array.of.apply(Foo, [1, 2]); - return fooArr instanceof Foo && fooArr.length === 2; - }()); - if (!arrayOfSupportsSubclassing) { - overrideNative(Array, 'of', ArrayShims.of); - } - - var ArrayPrototypeShims = { - copyWithin: function copyWithin(target, start) { - var o = ES.ToObject(this); - var len = ES.ToLength(o.length); - var relativeTarget = ES.ToInteger(target); - var relativeStart = ES.ToInteger(start); - var to = relativeTarget < 0 ? _max(len + relativeTarget, 0) : _min(relativeTarget, len); - var from = relativeStart < 0 ? _max(len + relativeStart, 0) : _min(relativeStart, len); - var end; - if (arguments.length > 2) { - end = arguments[2]; - } - var relativeEnd = typeof end === 'undefined' ? len : ES.ToInteger(end); - var finalItem = relativeEnd < 0 ? _max(len + relativeEnd, 0) : _min(relativeEnd, len); - var count = _min(finalItem - from, len - to); - var direction = 1; - if (from < to && to < (from + count)) { - direction = -1; - from += count - 1; - to += count - 1; - } - while (count > 0) { - if (from in o) { - o[to] = o[from]; - } else { - delete o[to]; - } - from += direction; - to += direction; - count -= 1; - } - return o; - }, - - fill: function fill(value) { - var start; - if (arguments.length > 1) { - start = arguments[1]; - } - var end; - if (arguments.length > 2) { - end = arguments[2]; - } - var O = ES.ToObject(this); - var len = ES.ToLength(O.length); - start = ES.ToInteger(typeof start === 'undefined' ? 0 : start); - end = ES.ToInteger(typeof end === 'undefined' ? len : end); - - var relativeStart = start < 0 ? _max(len + start, 0) : _min(start, len); - var relativeEnd = end < 0 ? len + end : end; - - for (var i = relativeStart; i < len && i < relativeEnd; ++i) { - O[i] = value; - } - return O; - }, - - find: function find(predicate) { - var list = ES.ToObject(this); - var length = ES.ToLength(list.length); - if (!ES.IsCallable(predicate)) { - throw new TypeError('Array#find: predicate must be a function'); - } - var thisArg = arguments.length > 1 ? arguments[1] : null; - for (var i = 0, value; i < length; i++) { - value = list[i]; - if (thisArg) { - if (_call(predicate, thisArg, value, i, list)) { - return value; - } - } else if (predicate(value, i, list)) { - return value; - } - } - }, - - findIndex: function findIndex(predicate) { - var list = ES.ToObject(this); - var length = ES.ToLength(list.length); - if (!ES.IsCallable(predicate)) { - throw new TypeError('Array#findIndex: predicate must be a function'); - } - var thisArg = arguments.length > 1 ? arguments[1] : null; - for (var i = 0; i < length; i++) { - if (thisArg) { - if (_call(predicate, thisArg, list[i], i, list)) { - return i; - } - } else if (predicate(list[i], i, list)) { - return i; - } - } - return -1; - }, - - keys: function keys() { - return new ArrayIterator(this, 'key'); - }, - - values: function values() { - return new ArrayIterator(this, 'value'); - }, - - entries: function entries() { - return new ArrayIterator(this, 'entry'); - } - }; - // Safari 7.1 defines Array#keys and Array#entries natively, - // but the resulting ArrayIterator objects don't have a "next" method. - if (Array.prototype.keys && !ES.IsCallable([1].keys().next)) { - delete Array.prototype.keys; - } - if (Array.prototype.entries && !ES.IsCallable([1].entries().next)) { - delete Array.prototype.entries; - } - - // Chrome 38 defines Array#keys and Array#entries, and Array#@@iterator, but not Array#values - if (Array.prototype.keys && Array.prototype.entries && !Array.prototype.values && Array.prototype[$iterator$]) { - defineProperties(Array.prototype, { - values: Array.prototype[$iterator$] - }); - if (Type.symbol(Symbol.unscopables)) { - Array.prototype[Symbol.unscopables].values = true; - } - } - // Chrome 40 defines Array#values with the incorrect name, although Array#{keys,entries} have the correct name - if (functionsHaveNames && Array.prototype.values && Array.prototype.values.name !== 'values') { - var originalArrayPrototypeValues = Array.prototype.values; - overrideNative(Array.prototype, 'values', function values() { return ES.Call(originalArrayPrototypeValues, this, arguments); }); - defineProperty(Array.prototype, $iterator$, Array.prototype.values, true); - } - defineProperties(Array.prototype, ArrayPrototypeShims); - - if (1 / [true].indexOf(true, -0) < 0) { - // indexOf when given a position arg of -0 should return +0. - // https://github.com/tc39/ecma262/pull/316 - defineProperty(Array.prototype, 'indexOf', function indexOf(searchElement) { - var value = _arrayIndexOfApply(this, arguments); - if (value === 0 && (1 / value) < 0) { - return 0; - } - return value; - }, true); - } - - addIterator(Array.prototype, function () { return this.values(); }); - // Chrome defines keys/values/entries on Array, but doesn't give us - // any way to identify its iterator. So add our own shimmed field. - if (Object.getPrototypeOf) { - addIterator(Object.getPrototypeOf([].values())); - } - - // note: this is positioned here because it relies on Array#entries - var arrayFromSwallowsNegativeLengths = (function () { - // Detects a Firefox bug in v32 - // https://bugzilla.mozilla.org/show_bug.cgi?id=1063993 - return valueOrFalseIfThrows(function () { - return Array.from({ length: -1 }).length === 0; - }); - }()); - var arrayFromHandlesIterables = (function () { - // Detects a bug in Webkit nightly r181886 - var arr = Array.from([0].entries()); - return arr.length === 1 && isArray(arr[0]) && arr[0][0] === 0 && arr[0][1] === 0; - }()); - if (!arrayFromSwallowsNegativeLengths || !arrayFromHandlesIterables) { - overrideNative(Array, 'from', ArrayShims.from); - } - var arrayFromHandlesUndefinedMapFunction = (function () { - // Microsoft Edge v0.11 throws if the mapFn argument is *provided* but undefined, - // but the spec doesn't care if it's provided or not - undefined doesn't throw. - return valueOrFalseIfThrows(function () { - return Array.from([0], void 0); - }); - }()); - if (!arrayFromHandlesUndefinedMapFunction) { - var origArrayFrom = Array.from; - overrideNative(Array, 'from', function from(items) { - if (arguments.length > 1 && typeof arguments[1] !== 'undefined') { - return ES.Call(origArrayFrom, this, arguments); - } else { - return _call(origArrayFrom, this, items); - } - }); - } - - var int32sAsOne = -(Math.pow(2, 32) - 1); - var toLengthsCorrectly = function (method, reversed) { - var obj = { length: int32sAsOne }; - obj[reversed ? (obj.length >>> 0) - 1 : 0] = true; - return valueOrFalseIfThrows(function () { - _call(method, obj, function () { - // note: in nonconforming browsers, this will be called - // -1 >>> 0 times, which is 4294967295, so the throw matters. - throw new RangeError('should not reach here'); - }, []); - return true; - }); - }; - if (!toLengthsCorrectly(Array.prototype.forEach)) { - var originalForEach = Array.prototype.forEach; - overrideNative(Array.prototype, 'forEach', function forEach(callbackFn) { - return ES.Call(originalForEach, this.length >= 0 ? this : [], arguments); - }); - } - if (!toLengthsCorrectly(Array.prototype.map)) { - var originalMap = Array.prototype.map; - overrideNative(Array.prototype, 'map', function map(callbackFn) { - return ES.Call(originalMap, this.length >= 0 ? this : [], arguments); - }); - } - if (!toLengthsCorrectly(Array.prototype.filter)) { - var originalFilter = Array.prototype.filter; - overrideNative(Array.prototype, 'filter', function filter(callbackFn) { - return ES.Call(originalFilter, this.length >= 0 ? this : [], arguments); - }); - } - if (!toLengthsCorrectly(Array.prototype.some)) { - var originalSome = Array.prototype.some; - overrideNative(Array.prototype, 'some', function some(callbackFn) { - return ES.Call(originalSome, this.length >= 0 ? this : [], arguments); - }); - } - if (!toLengthsCorrectly(Array.prototype.every)) { - var originalEvery = Array.prototype.every; - overrideNative(Array.prototype, 'every', function every(callbackFn) { - return ES.Call(originalEvery, this.length >= 0 ? this : [], arguments); - }); - } - if (!toLengthsCorrectly(Array.prototype.reduce)) { - var originalReduce = Array.prototype.reduce; - overrideNative(Array.prototype, 'reduce', function reduce(callbackFn) { - return ES.Call(originalReduce, this.length >= 0 ? this : [], arguments); - }); - } - if (!toLengthsCorrectly(Array.prototype.reduceRight, true)) { - var originalReduceRight = Array.prototype.reduceRight; - overrideNative(Array.prototype, 'reduceRight', function reduceRight(callbackFn) { - return ES.Call(originalReduceRight, this.length >= 0 ? this : [], arguments); - }); - } - - var lacksOctalSupport = Number('0o10') !== 8; - var lacksBinarySupport = Number('0b10') !== 2; - var trimsNonWhitespace = _some(nonWS, function (c) { - return Number(c + 0 + c) === 0; - }); - if (lacksOctalSupport || lacksBinarySupport || trimsNonWhitespace) { - var OrigNumber = Number; - var binaryRegex = /^0b[01]+$/i; - var octalRegex = /^0o[0-7]+$/i; - // Note that in IE 8, RegExp.prototype.test doesn't seem to exist: ie, "test" is an own property of regexes. wtf. - var isBinary = binaryRegex.test.bind(binaryRegex); - var isOctal = octalRegex.test.bind(octalRegex); - var toPrimitive = function (O, hint) { // need to replace this with `es-to-primitive/es6` - var result; - if (typeof O.valueOf === 'function') { - result = O.valueOf(); - if (Type.primitive(result)) { - return result; - } - } - if (typeof O.toString === 'function') { - result = O.toString(); - if (Type.primitive(result)) { - return result; - } - } - throw new TypeError('No default value'); - }; - var hasNonWS = nonWSregex.test.bind(nonWSregex); - var isBadHex = isBadHexRegex.test.bind(isBadHexRegex); - var NumberShim = (function () { - // this is wrapped in an IIFE because of IE 6-8's wacky scoping issues with named function expressions. - var NumberShim = function Number(value) { - var primValue; - if (arguments.length > 0) { - primValue = Type.primitive(value) ? value : toPrimitive(value, 'number'); - } else { - primValue = 0; - } - if (typeof primValue === 'string') { - primValue = ES.Call(trimShim, primValue); - if (isBinary(primValue)) { - primValue = parseInt(_strSlice(primValue, 2), 2); - } else if (isOctal(primValue)) { - primValue = parseInt(_strSlice(primValue, 2), 8); - } else if (hasNonWS(primValue) || isBadHex(primValue)) { - primValue = NaN; - } - } - var receiver = this; - var valueOfSucceeds = valueOrFalseIfThrows(function () { - OrigNumber.prototype.valueOf.call(receiver); - return true; - }); - if (receiver instanceof NumberShim && !valueOfSucceeds) { - return new OrigNumber(primValue); - } - return OrigNumber(primValue); - }; - return NumberShim; - }()); - wrapConstructor(OrigNumber, NumberShim, {}); - // this is necessary for ES3 browsers, where these properties are non-enumerable. - defineProperties(NumberShim, { - NaN: OrigNumber.NaN, - MAX_VALUE: OrigNumber.MAX_VALUE, - MIN_VALUE: OrigNumber.MIN_VALUE, - NEGATIVE_INFINITY: OrigNumber.NEGATIVE_INFINITY, - POSITIVE_INFINITY: OrigNumber.POSITIVE_INFINITY - }); - /* eslint-disable no-undef, no-global-assign */ - Number = NumberShim; - Value.redefine(globals, 'Number', NumberShim); - /* eslint-enable no-undef, no-global-assign */ - } - - var maxSafeInteger = Math.pow(2, 53) - 1; - defineProperties(Number, { - MAX_SAFE_INTEGER: maxSafeInteger, - MIN_SAFE_INTEGER: -maxSafeInteger, - EPSILON: 2.220446049250313e-16, - - parseInt: globals.parseInt, - parseFloat: globals.parseFloat, - - isFinite: numberIsFinite, - - isInteger: function isInteger(value) { - return numberIsFinite(value) && ES.ToInteger(value) === value; - }, - - isSafeInteger: function isSafeInteger(value) { - return Number.isInteger(value) && _abs(value) <= Number.MAX_SAFE_INTEGER; - }, - - isNaN: numberIsNaN - }); - // Firefox 37 has a conforming Number.parseInt, but it's not === to the global parseInt (fixed in v40) - defineProperty(Number, 'parseInt', globals.parseInt, Number.parseInt !== globals.parseInt); - - // Work around bugs in Array#find and Array#findIndex -- early - // implementations skipped holes in sparse arrays. (Note that the - // implementations of find/findIndex indirectly use shimmed - // methods of Number, so this test has to happen down here.) - /* eslint-disable no-sparse-arrays */ - if ([, 1].find(function () { return true; }) === 1) { - overrideNative(Array.prototype, 'find', ArrayPrototypeShims.find); - } - if ([, 1].findIndex(function () { return true; }) !== 0) { - overrideNative(Array.prototype, 'findIndex', ArrayPrototypeShims.findIndex); - } - /* eslint-enable no-sparse-arrays */ - - var isEnumerableOn = Function.bind.call(Function.bind, Object.prototype.propertyIsEnumerable); - var ensureEnumerable = function ensureEnumerable(obj, prop) { - if (supportsDescriptors && isEnumerableOn(obj, prop)) { - Object.defineProperty(obj, prop, { enumerable: false }); - } - }; - var sliceArgs = function sliceArgs() { - // per https://github.com/petkaantonov/bluebird/wiki/Optimization-killers#32-leaking-arguments - // and https://gist.github.com/WebReflection/4327762cb87a8c634a29 - var initial = Number(this); - var len = arguments.length; - var desiredArgCount = len - initial; - var args = new Array(desiredArgCount < 0 ? 0 : desiredArgCount); - for (var i = initial; i < len; ++i) { - args[i - initial] = arguments[i]; - } - return args; - }; - var assignTo = function assignTo(source) { - return function assignToSource(target, key) { - target[key] = source[key]; - return target; - }; - }; - var assignReducer = function (target, source) { - var sourceKeys = keys(Object(source)); - var symbols; - if (ES.IsCallable(Object.getOwnPropertySymbols)) { - symbols = _filter(Object.getOwnPropertySymbols(Object(source)), isEnumerableOn(source)); - } - return _reduce(_concat(sourceKeys, symbols || []), assignTo(source), target); - }; - - var ObjectShims = { - // 19.1.3.1 - assign: function (target, source) { - var to = ES.ToObject(target, 'Cannot convert undefined or null to object'); - return _reduce(ES.Call(sliceArgs, 1, arguments), assignReducer, to); - }, - - // Added in WebKit in https://bugs.webkit.org/show_bug.cgi?id=143865 - is: function is(a, b) { - return ES.SameValue(a, b); - } - }; - var assignHasPendingExceptions = Object.assign && Object.preventExtensions && (function () { - // Firefox 37 still has "pending exception" logic in its Object.assign implementation, - // which is 72% slower than our shim, and Firefox 40's native implementation. - var thrower = Object.preventExtensions({ 1: 2 }); - try { - Object.assign(thrower, 'xy'); - } catch (e) { - return thrower[1] === 'y'; - } - }()); - if (assignHasPendingExceptions) { - overrideNative(Object, 'assign', ObjectShims.assign); - } - defineProperties(Object, ObjectShims); - - if (supportsDescriptors) { - var ES5ObjectShims = { - // 19.1.3.9 - // shim from https://gist.github.com/WebReflection/5593554 - setPrototypeOf: (function (Object, magic) { - var set; - - var checkArgs = function (O, proto) { - if (!ES.TypeIsObject(O)) { - throw new TypeError('cannot set prototype on a non-object'); - } - if (!(proto === null || ES.TypeIsObject(proto))) { - throw new TypeError('can only set prototype to an object or null' + proto); - } - }; - - var setPrototypeOf = function (O, proto) { - checkArgs(O, proto); - _call(set, O, proto); - return O; - }; - - try { - // this works already in Firefox and Safari - set = Object.getOwnPropertyDescriptor(Object.prototype, magic).set; - _call(set, {}, null); - } catch (e) { - if (Object.prototype !== {}[magic]) { - // IE < 11 cannot be shimmed - return; - } - // probably Chrome or some old Mobile stock browser - set = function (proto) { - this[magic] = proto; - }; - // please note that this will **not** work - // in those browsers that do not inherit - // __proto__ by mistake from Object.prototype - // in these cases we should probably throw an error - // or at least be informed about the issue - setPrototypeOf.polyfill = setPrototypeOf( - setPrototypeOf({}, null), - Object.prototype - ) instanceof Object; - // setPrototypeOf.polyfill === true means it works as meant - // setPrototypeOf.polyfill === false means it's not 100% reliable - // setPrototypeOf.polyfill === undefined - // or - // setPrototypeOf.polyfill == null means it's not a polyfill - // which means it works as expected - // we can even delete Object.prototype.__proto__; - } - return setPrototypeOf; - }(Object, '__proto__')) - }; - - defineProperties(Object, ES5ObjectShims); - } - - // Workaround bug in Opera 12 where setPrototypeOf(x, null) doesn't work, - // but Object.create(null) does. - if (Object.setPrototypeOf && Object.getPrototypeOf && - Object.getPrototypeOf(Object.setPrototypeOf({}, null)) !== null && - Object.getPrototypeOf(Object.create(null)) === null) { - (function () { - var FAKENULL = Object.create(null); - var gpo = Object.getPrototypeOf; - var spo = Object.setPrototypeOf; - Object.getPrototypeOf = function (o) { - var result = gpo(o); - return result === FAKENULL ? null : result; - }; - Object.setPrototypeOf = function (o, p) { - var proto = p === null ? FAKENULL : p; - return spo(o, proto); - }; - Object.setPrototypeOf.polyfill = false; - }()); - } - - var objectKeysAcceptsPrimitives = !throwsError(function () { return Object.keys('foo'); }); - if (!objectKeysAcceptsPrimitives) { - var originalObjectKeys = Object.keys; - overrideNative(Object, 'keys', function keys(value) { - return originalObjectKeys(ES.ToObject(value)); - }); - keys = Object.keys; - } - var objectKeysRejectsRegex = throwsError(function () { return Object.keys(/a/g); }); - if (objectKeysRejectsRegex) { - var regexRejectingObjectKeys = Object.keys; - overrideNative(Object, 'keys', function keys(value) { - if (Type.regex(value)) { - var regexKeys = []; - for (var k in value) { - if (_hasOwnProperty(value, k)) { - _push(regexKeys, k); - } - } - return regexKeys; - } - return regexRejectingObjectKeys(value); - }); - keys = Object.keys; - } - - if (Object.getOwnPropertyNames) { - var objectGOPNAcceptsPrimitives = !throwsError(function () { return Object.getOwnPropertyNames('foo'); }); - if (!objectGOPNAcceptsPrimitives) { - var cachedWindowNames = typeof window === 'object' ? Object.getOwnPropertyNames(window) : []; - var originalObjectGetOwnPropertyNames = Object.getOwnPropertyNames; - overrideNative(Object, 'getOwnPropertyNames', function getOwnPropertyNames(value) { - var val = ES.ToObject(value); - if (_toString(val) === '[object Window]') { - try { - return originalObjectGetOwnPropertyNames(val); - } catch (e) { - // IE bug where layout engine calls userland gOPN for cross-domain `window` objects - return _concat([], cachedWindowNames); - } - } - return originalObjectGetOwnPropertyNames(val); - }); - } - } - if (Object.getOwnPropertyDescriptor) { - var objectGOPDAcceptsPrimitives = !throwsError(function () { return Object.getOwnPropertyDescriptor('foo', 'bar'); }); - if (!objectGOPDAcceptsPrimitives) { - var originalObjectGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; - overrideNative(Object, 'getOwnPropertyDescriptor', function getOwnPropertyDescriptor(value, property) { - return originalObjectGetOwnPropertyDescriptor(ES.ToObject(value), property); - }); - } - } - if (Object.seal) { - var objectSealAcceptsPrimitives = !throwsError(function () { return Object.seal('foo'); }); - if (!objectSealAcceptsPrimitives) { - var originalObjectSeal = Object.seal; - overrideNative(Object, 'seal', function seal(value) { - if (!ES.TypeIsObject(value)) { return value; } - return originalObjectSeal(value); - }); - } - } - if (Object.isSealed) { - var objectIsSealedAcceptsPrimitives = !throwsError(function () { return Object.isSealed('foo'); }); - if (!objectIsSealedAcceptsPrimitives) { - var originalObjectIsSealed = Object.isSealed; - overrideNative(Object, 'isSealed', function isSealed(value) { - if (!ES.TypeIsObject(value)) { return true; } - return originalObjectIsSealed(value); - }); - } - } - if (Object.freeze) { - var objectFreezeAcceptsPrimitives = !throwsError(function () { return Object.freeze('foo'); }); - if (!objectFreezeAcceptsPrimitives) { - var originalObjectFreeze = Object.freeze; - overrideNative(Object, 'freeze', function freeze(value) { - if (!ES.TypeIsObject(value)) { return value; } - return originalObjectFreeze(value); - }); - } - } - if (Object.isFrozen) { - var objectIsFrozenAcceptsPrimitives = !throwsError(function () { return Object.isFrozen('foo'); }); - if (!objectIsFrozenAcceptsPrimitives) { - var originalObjectIsFrozen = Object.isFrozen; - overrideNative(Object, 'isFrozen', function isFrozen(value) { - if (!ES.TypeIsObject(value)) { return true; } - return originalObjectIsFrozen(value); - }); - } - } - if (Object.preventExtensions) { - var objectPreventExtensionsAcceptsPrimitives = !throwsError(function () { return Object.preventExtensions('foo'); }); - if (!objectPreventExtensionsAcceptsPrimitives) { - var originalObjectPreventExtensions = Object.preventExtensions; - overrideNative(Object, 'preventExtensions', function preventExtensions(value) { - if (!ES.TypeIsObject(value)) { return value; } - return originalObjectPreventExtensions(value); - }); - } - } - if (Object.isExtensible) { - var objectIsExtensibleAcceptsPrimitives = !throwsError(function () { return Object.isExtensible('foo'); }); - if (!objectIsExtensibleAcceptsPrimitives) { - var originalObjectIsExtensible = Object.isExtensible; - overrideNative(Object, 'isExtensible', function isExtensible(value) { - if (!ES.TypeIsObject(value)) { return false; } - return originalObjectIsExtensible(value); - }); - } - } - if (Object.getPrototypeOf) { - var objectGetProtoAcceptsPrimitives = !throwsError(function () { return Object.getPrototypeOf('foo'); }); - if (!objectGetProtoAcceptsPrimitives) { - var originalGetProto = Object.getPrototypeOf; - overrideNative(Object, 'getPrototypeOf', function getPrototypeOf(value) { - return originalGetProto(ES.ToObject(value)); - }); - } - } - - var hasFlags = supportsDescriptors && (function () { - var desc = Object.getOwnPropertyDescriptor(RegExp.prototype, 'flags'); - return desc && ES.IsCallable(desc.get); - }()); - if (supportsDescriptors && !hasFlags) { - var regExpFlagsGetter = function flags() { - if (!ES.TypeIsObject(this)) { - throw new TypeError('Method called on incompatible type: must be an object.'); - } - var result = ''; - if (this.global) { - result += 'g'; - } - if (this.ignoreCase) { - result += 'i'; - } - if (this.multiline) { - result += 'm'; - } - if (this.unicode) { - result += 'u'; - } - if (this.sticky) { - result += 'y'; - } - return result; - }; - - Value.getter(RegExp.prototype, 'flags', regExpFlagsGetter); - } - - var regExpSupportsFlagsWithRegex = supportsDescriptors && valueOrFalseIfThrows(function () { - return String(new RegExp(/a/g, 'i')) === '/a/i'; - }); - var regExpNeedsToSupportSymbolMatch = hasSymbols && supportsDescriptors && (function () { - // Edge 0.12 supports flags fully, but does not support Symbol.match - var regex = /./; - regex[Symbol.match] = false; - return RegExp(regex) === regex; - }()); - - var regexToStringIsGeneric = valueOrFalseIfThrows(function () { - return RegExp.prototype.toString.call({ source: 'abc' }) === '/abc/'; - }); - var regexToStringSupportsGenericFlags = regexToStringIsGeneric && valueOrFalseIfThrows(function () { - return RegExp.prototype.toString.call({ source: 'a', flags: 'b' }) === '/a/b'; - }); - if (!regexToStringIsGeneric || !regexToStringSupportsGenericFlags) { - var origRegExpToString = RegExp.prototype.toString; - defineProperty(RegExp.prototype, 'toString', function toString() { - var R = ES.RequireObjectCoercible(this); - if (Type.regex(R)) { - return _call(origRegExpToString, R); - } - var pattern = $String(R.source); - var flags = $String(R.flags); - return '/' + pattern + '/' + flags; - }, true); - Value.preserveToString(RegExp.prototype.toString, origRegExpToString); - } - - if (supportsDescriptors && (!regExpSupportsFlagsWithRegex || regExpNeedsToSupportSymbolMatch)) { - var flagsGetter = Object.getOwnPropertyDescriptor(RegExp.prototype, 'flags').get; - var sourceDesc = Object.getOwnPropertyDescriptor(RegExp.prototype, 'source') || {}; - var legacySourceGetter = function () { - // prior to it being a getter, it's own + nonconfigurable - return this.source; - }; - var sourceGetter = ES.IsCallable(sourceDesc.get) ? sourceDesc.get : legacySourceGetter; - - var OrigRegExp = RegExp; - var RegExpShim = (function () { - return function RegExp(pattern, flags) { - var patternIsRegExp = ES.IsRegExp(pattern); - var calledWithNew = this instanceof RegExp; - if (!calledWithNew && patternIsRegExp && typeof flags === 'undefined' && pattern.constructor === RegExp) { - return pattern; - } - - var P = pattern; - var F = flags; - if (Type.regex(pattern)) { - P = ES.Call(sourceGetter, pattern); - F = typeof flags === 'undefined' ? ES.Call(flagsGetter, pattern) : flags; - return new RegExp(P, F); - } else if (patternIsRegExp) { - P = pattern.source; - F = typeof flags === 'undefined' ? pattern.flags : flags; - } - return new OrigRegExp(pattern, flags); - }; - }()); - wrapConstructor(OrigRegExp, RegExpShim, { - $input: true // Chrome < v39 & Opera < 26 have a nonstandard "$input" property - }); - /* eslint-disable no-undef, no-global-assign */ - RegExp = RegExpShim; - Value.redefine(globals, 'RegExp', RegExpShim); - /* eslint-enable no-undef, no-global-assign */ - } - - if (supportsDescriptors) { - var regexGlobals = { - input: '$_', - lastMatch: '$&', - lastParen: '$+', - leftContext: '$`', - rightContext: '$\'' - }; - _forEach(keys(regexGlobals), function (prop) { - if (prop in RegExp && !(regexGlobals[prop] in RegExp)) { - Value.getter(RegExp, regexGlobals[prop], function get() { - return RegExp[prop]; - }); - } - }); - } - addDefaultSpecies(RegExp); - - var inverseEpsilon = 1 / Number.EPSILON; - var roundTiesToEven = function roundTiesToEven(n) { - // Even though this reduces down to `return n`, it takes advantage of built-in rounding. - return (n + inverseEpsilon) - inverseEpsilon; - }; - var BINARY_32_EPSILON = Math.pow(2, -23); - var BINARY_32_MAX_VALUE = Math.pow(2, 127) * (2 - BINARY_32_EPSILON); - var BINARY_32_MIN_VALUE = Math.pow(2, -126); - var E = Math.E; - var LOG2E = Math.LOG2E; - var LOG10E = Math.LOG10E; - var numberCLZ = Number.prototype.clz; - delete Number.prototype.clz; // Safari 8 has Number#clz - - var MathShims = { - acosh: function acosh(value) { - var x = Number(value); - if (numberIsNaN(x) || value < 1) { return NaN; } - if (x === 1) { return 0; } - if (x === Infinity) { return x; } - - var xInvSquared = 1 / (x * x); - if (x < 2) { - return _log1p(x - 1 + (_sqrt(1 - xInvSquared) * x)); - } - var halfX = x / 2; - return _log1p(halfX + (_sqrt(1 - xInvSquared) * halfX) - 1) + (1 / LOG2E); - }, - - asinh: function asinh(value) { - var x = Number(value); - if (x === 0 || !globalIsFinite(x)) { - return x; - } - - var a = _abs(x); - var aSquared = a * a; - var s = _sign(x); - if (a < 1) { - return s * _log1p(a + (aSquared / (_sqrt(aSquared + 1) + 1))); - } - return s * (_log1p((a / 2) + (_sqrt(1 + (1 / aSquared)) * a / 2) - 1) + (1 / LOG2E)); - }, - - atanh: function atanh(value) { - var x = Number(value); - - if (x === 0) { return x; } - if (x === -1) { return -Infinity; } - if (x === 1) { return Infinity; } - if (numberIsNaN(x) || x < -1 || x > 1) { - return NaN; - } - - var a = _abs(x); - return _sign(x) * _log1p(2 * a / (1 - a)) / 2; - }, - - cbrt: function cbrt(value) { - var x = Number(value); - if (x === 0) { return x; } - var negate = x < 0; - var result; - if (negate) { x = -x; } - if (x === Infinity) { - result = Infinity; - } else { - result = _exp(_log(x) / 3); - // from http://en.wikipedia.org/wiki/Cube_root#Numerical_methods - result = ((x / (result * result)) + (2 * result)) / 3; - } - return negate ? -result : result; - }, - - clz32: function clz32(value) { - // See https://bugs.ecmascript.org/show_bug.cgi?id=2465 - var x = Number(value); - var number = ES.ToUint32(x); - if (number === 0) { - return 32; - } - return numberCLZ ? ES.Call(numberCLZ, number) : 31 - _floor(_log(number + 0.5) * LOG2E); - }, - - cosh: function cosh(value) { - var x = Number(value); - if (x === 0) { return 1; } // +0 or -0 - if (numberIsNaN(x)) { return NaN; } - if (!globalIsFinite(x)) { return Infinity; } - - var t = _exp(_abs(x) - 1); - return (t + (1 / (t * E * E))) * (E / 2); - }, - - expm1: function expm1(value) { - var x = Number(value); - if (x === -Infinity) { return -1; } - if (!globalIsFinite(x) || x === 0) { return x; } - if (_abs(x) > 0.5) { - return _exp(x) - 1; - } - // A more precise approximation using Taylor series expansion - // from https://github.com/paulmillr/es6-shim/issues/314#issuecomment-70293986 - var t = x; - var sum = 0; - var n = 1; - while (sum + t !== sum) { - sum += t; - n += 1; - t *= x / n; - } - return sum; - }, - - hypot: function hypot(x, y) { - var result = 0; - var largest = 0; - for (var i = 0; i < arguments.length; ++i) { - var value = _abs(Number(arguments[i])); - if (largest < value) { - result *= (largest / value) * (largest / value); - result += 1; - largest = value; - } else { - result += value > 0 ? (value / largest) * (value / largest) : value; - } - } - return largest === Infinity ? Infinity : largest * _sqrt(result); - }, - - log2: function log2(value) { - return _log(value) * LOG2E; - }, - - log10: function log10(value) { - return _log(value) * LOG10E; - }, - - log1p: _log1p, - - sign: _sign, - - sinh: function sinh(value) { - var x = Number(value); - if (!globalIsFinite(x) || x === 0) { return x; } - - var a = _abs(x); - if (a < 1) { - var u = Math.expm1(a); - return _sign(x) * u * (1 + (1 / (u + 1))) / 2; - } - var t = _exp(a - 1); - return _sign(x) * (t - (1 / (t * E * E))) * (E / 2); - }, - - tanh: function tanh(value) { - var x = Number(value); - if (numberIsNaN(x) || x === 0) { return x; } - // can exit early at +-20 as JS loses precision for true value at this integer - if (x >= 20) { return 1; } - if (x <= -20) { return -1; } - - return (Math.expm1(x) - Math.expm1(-x)) / (_exp(x) + _exp(-x)); - }, - - trunc: function trunc(value) { - var x = Number(value); - return x < 0 ? -_floor(-x) : _floor(x); - }, - - imul: function imul(x, y) { - // taken from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/imul - var a = ES.ToUint32(x); - var b = ES.ToUint32(y); - var ah = (a >>> 16) & 0xffff; - var al = a & 0xffff; - var bh = (b >>> 16) & 0xffff; - var bl = b & 0xffff; - // the shift by 0 fixes the sign on the high part - // the final |0 converts the unsigned value into a signed value - return (al * bl) + ((((ah * bl) + (al * bh)) << 16) >>> 0) | 0; - }, - - fround: function fround(x) { - var v = Number(x); - if (v === 0 || v === Infinity || v === -Infinity || numberIsNaN(v)) { - return v; - } - var sign = _sign(v); - var abs = _abs(v); - if (abs < BINARY_32_MIN_VALUE) { - return sign * roundTiesToEven(abs / BINARY_32_MIN_VALUE / BINARY_32_EPSILON) * BINARY_32_MIN_VALUE * BINARY_32_EPSILON; - } - // Veltkamp's splitting (?) - var a = (1 + (BINARY_32_EPSILON / Number.EPSILON)) * abs; - var result = a - (a - abs); - if (result > BINARY_32_MAX_VALUE || numberIsNaN(result)) { - return sign * Infinity; - } - return sign * result; - } - }; - - var withinULPDistance = function withinULPDistance(result, expected, distance) { - return _abs(1 - (result / expected)) / Number.EPSILON < (distance || 8); - }; - - defineProperties(Math, MathShims); - // Chrome < 40 sinh returns ∞ for large numbers - defineProperty(Math, 'sinh', MathShims.sinh, Math.sinh(710) === Infinity); - // Chrome < 40 cosh returns ∞ for large numbers - defineProperty(Math, 'cosh', MathShims.cosh, Math.cosh(710) === Infinity); - // IE 11 TP has an imprecise log1p: reports Math.log1p(-1e-17) as 0 - defineProperty(Math, 'log1p', MathShims.log1p, Math.log1p(-1e-17) !== -1e-17); - // IE 11 TP has an imprecise asinh: reports Math.asinh(-1e7) as not exactly equal to -Math.asinh(1e7) - defineProperty(Math, 'asinh', MathShims.asinh, Math.asinh(-1e7) !== -Math.asinh(1e7)); - // Chrome < 54 asinh returns ∞ for large numbers and should not - defineProperty(Math, 'asinh', MathShims.asinh, Math.asinh(1e+300) === Infinity); - // Chrome < 54 atanh incorrectly returns 0 for large numbers - defineProperty(Math, 'atanh', MathShims.atanh, Math.atanh(1e-300) === 0); - // Chrome 40 has an imprecise Math.tanh with very small numbers - defineProperty(Math, 'tanh', MathShims.tanh, Math.tanh(-2e-17) !== -2e-17); - // Chrome 40 loses Math.acosh precision with high numbers - defineProperty(Math, 'acosh', MathShims.acosh, Math.acosh(Number.MAX_VALUE) === Infinity); - // Chrome < 54 has an inaccurate acosh for EPSILON deltas - defineProperty(Math, 'acosh', MathShims.acosh, !withinULPDistance(Math.acosh(1 + Number.EPSILON), Math.sqrt(2 * Number.EPSILON))); - // Firefox 38 on Windows - defineProperty(Math, 'cbrt', MathShims.cbrt, !withinULPDistance(Math.cbrt(1e-300), 1e-100)); - // node 0.11 has an imprecise Math.sinh with very small numbers - defineProperty(Math, 'sinh', MathShims.sinh, Math.sinh(-2e-17) !== -2e-17); - // FF 35 on Linux reports 22025.465794806725 for Math.expm1(10) - var expm1OfTen = Math.expm1(10); - defineProperty(Math, 'expm1', MathShims.expm1, expm1OfTen > 22025.465794806719 || expm1OfTen < 22025.4657948067165168); - // node v12.11 - v12.15 report NaN - defineProperty(Math, 'hypot', MathShims.hypot, Math.hypot(Infinity, NaN) !== Infinity); - - var origMathRound = Math.round; - // breaks in e.g. Safari 8, Internet Explorer 11, Opera 12 - var roundHandlesBoundaryConditions = Math.round(0.5 - (Number.EPSILON / 4)) === 0 && - Math.round(-0.5 + (Number.EPSILON / 3.99)) === 1; - - // When engines use Math.floor(x + 0.5) internally, Math.round can be buggy for large integers. - // This behavior should be governed by "round to nearest, ties to even mode" - // see http://www.ecma-international.org/ecma-262/6.0/#sec-terms-and-definitions-number-type - // These are the boundary cases where it breaks. - var smallestPositiveNumberWhereRoundBreaks = inverseEpsilon + 1; - var largestPositiveNumberWhereRoundBreaks = (2 * inverseEpsilon) - 1; - var roundDoesNotIncreaseIntegers = [ - smallestPositiveNumberWhereRoundBreaks, - largestPositiveNumberWhereRoundBreaks - ].every(function (num) { - return Math.round(num) === num; - }); - defineProperty(Math, 'round', function round(x) { - var floor = _floor(x); - var ceil = floor === -1 ? -0 : floor + 1; - return x - floor < 0.5 ? floor : ceil; - }, !roundHandlesBoundaryConditions || !roundDoesNotIncreaseIntegers); - Value.preserveToString(Math.round, origMathRound); - - var origImul = Math.imul; - if (Math.imul(0xffffffff, 5) !== -5) { - // Safari 6.1, at least, reports "0" for this value - Math.imul = MathShims.imul; - Value.preserveToString(Math.imul, origImul); - } - if (Math.imul.length !== 2) { - // Safari 8.0.4 has a length of 1 - // fixed in https://bugs.webkit.org/show_bug.cgi?id=143658 - overrideNative(Math, 'imul', function imul(x, y) { - return ES.Call(origImul, Math, arguments); - }); - } - - // Promises - // Simplest possible implementation; use a 3rd-party library if you - // want the best possible speed and/or long stack traces. - var PromiseShim = (function () { - var setTimeout = globals.setTimeout; - // some environments don't have setTimeout - no way to shim here. - if (typeof setTimeout !== 'function' && typeof setTimeout !== 'object') { return; } - - ES.IsPromise = function (promise) { - if (!ES.TypeIsObject(promise)) { - return false; - } - if (typeof promise._promise === 'undefined') { - return false; // uninitialized, or missing our hidden field. - } - return true; - }; - - // "PromiseCapability" in the spec is what most promise implementations - // call a "deferred". - var PromiseCapability = function (C) { - if (!ES.IsConstructor(C)) { - throw new TypeError('Bad promise constructor'); - } - var capability = this; - var resolver = function (resolve, reject) { - if (capability.resolve !== void 0 || capability.reject !== void 0) { - throw new TypeError('Bad Promise implementation!'); - } - capability.resolve = resolve; - capability.reject = reject; - }; - // Initialize fields to inform optimizers about the object shape. - capability.resolve = void 0; - capability.reject = void 0; - capability.promise = new C(resolver); - if (!(ES.IsCallable(capability.resolve) && ES.IsCallable(capability.reject))) { - throw new TypeError('Bad promise constructor'); - } - }; - - // find an appropriate setImmediate-alike - var makeZeroTimeout; - if (typeof window !== 'undefined' && ES.IsCallable(window.postMessage)) { - makeZeroTimeout = function () { - // from http://dbaron.org/log/20100309-faster-timeouts - var timeouts = []; - var messageName = 'zero-timeout-message'; - var setZeroTimeout = function (fn) { - _push(timeouts, fn); - window.postMessage(messageName, '*'); - }; - var handleMessage = function (event) { - if (event.source === window && event.data === messageName) { - event.stopPropagation(); - if (timeouts.length === 0) { return; } - var fn = _shift(timeouts); - fn(); - } - }; - window.addEventListener('message', handleMessage, true); - return setZeroTimeout; - }; - } - var makePromiseAsap = function () { - // An efficient task-scheduler based on a pre-existing Promise - // implementation, which we can use even if we override the - // global Promise below (in order to workaround bugs) - // https://github.com/Raynos/observ-hash/issues/2#issuecomment-35857671 - var P = globals.Promise; - var pr = P && P.resolve && P.resolve(); - return pr && function (task) { - return pr.then(task); - }; - }; - var enqueue = ES.IsCallable(globals.setImmediate) ? - globals.setImmediate : - typeof process === 'object' && process.nextTick ? process.nextTick : makePromiseAsap() || - (ES.IsCallable(makeZeroTimeout) ? makeZeroTimeout() : function (task) { setTimeout(task, 0); }); // fallback - - // Constants for Promise implementation - var PROMISE_IDENTITY = function (x) { return x; }; - var PROMISE_THROWER = function (e) { throw e; }; - var PROMISE_PENDING = 0; - var PROMISE_FULFILLED = 1; - var PROMISE_REJECTED = 2; - // We store fulfill/reject handlers and capabilities in a single array. - var PROMISE_FULFILL_OFFSET = 0; - var PROMISE_REJECT_OFFSET = 1; - var PROMISE_CAPABILITY_OFFSET = 2; - // This is used in an optimization for chaining promises via then. - var PROMISE_FAKE_CAPABILITY = {}; - - var enqueuePromiseReactionJob = function (handler, capability, argument) { - enqueue(function () { - promiseReactionJob(handler, capability, argument); - }); - }; - - var promiseReactionJob = function (handler, promiseCapability, argument) { - var handlerResult, f; - if (promiseCapability === PROMISE_FAKE_CAPABILITY) { - // Fast case, when we don't actually need to chain through to a - // (real) promiseCapability. - return handler(argument); - } - try { - handlerResult = handler(argument); - f = promiseCapability.resolve; - } catch (e) { - handlerResult = e; - f = promiseCapability.reject; - } - f(handlerResult); - }; - - var fulfillPromise = function (promise, value) { - var _promise = promise._promise; - var length = _promise.reactionLength; - if (length > 0) { - enqueuePromiseReactionJob( - _promise.fulfillReactionHandler0, - _promise.reactionCapability0, - value - ); - _promise.fulfillReactionHandler0 = void 0; - _promise.rejectReactions0 = void 0; - _promise.reactionCapability0 = void 0; - if (length > 1) { - for (var i = 1, idx = 0; i < length; i++, idx += 3) { - enqueuePromiseReactionJob( - _promise[idx + PROMISE_FULFILL_OFFSET], - _promise[idx + PROMISE_CAPABILITY_OFFSET], - value - ); - promise[idx + PROMISE_FULFILL_OFFSET] = void 0; - promise[idx + PROMISE_REJECT_OFFSET] = void 0; - promise[idx + PROMISE_CAPABILITY_OFFSET] = void 0; - } - } - } - _promise.result = value; - _promise.state = PROMISE_FULFILLED; - _promise.reactionLength = 0; - }; - - var rejectPromise = function (promise, reason) { - var _promise = promise._promise; - var length = _promise.reactionLength; - if (length > 0) { - enqueuePromiseReactionJob( - _promise.rejectReactionHandler0, - _promise.reactionCapability0, - reason - ); - _promise.fulfillReactionHandler0 = void 0; - _promise.rejectReactions0 = void 0; - _promise.reactionCapability0 = void 0; - if (length > 1) { - for (var i = 1, idx = 0; i < length; i++, idx += 3) { - enqueuePromiseReactionJob( - _promise[idx + PROMISE_REJECT_OFFSET], - _promise[idx + PROMISE_CAPABILITY_OFFSET], - reason - ); - promise[idx + PROMISE_FULFILL_OFFSET] = void 0; - promise[idx + PROMISE_REJECT_OFFSET] = void 0; - promise[idx + PROMISE_CAPABILITY_OFFSET] = void 0; - } - } - } - _promise.result = reason; - _promise.state = PROMISE_REJECTED; - _promise.reactionLength = 0; - }; - - var createResolvingFunctions = function (promise) { - var alreadyResolved = false; - var resolve = function (resolution) { - var then; - if (alreadyResolved) { return; } - alreadyResolved = true; - if (resolution === promise) { - return rejectPromise(promise, new TypeError('Self resolution')); - } - if (!ES.TypeIsObject(resolution)) { - return fulfillPromise(promise, resolution); - } - try { - then = resolution.then; - } catch (e) { - return rejectPromise(promise, e); - } - if (!ES.IsCallable(then)) { - return fulfillPromise(promise, resolution); - } - enqueue(function () { - promiseResolveThenableJob(promise, resolution, then); - }); - }; - var reject = function (reason) { - if (alreadyResolved) { return; } - alreadyResolved = true; - return rejectPromise(promise, reason); - }; - return { resolve: resolve, reject: reject }; - }; - - var optimizedThen = function (then, thenable, resolve, reject) { - // Optimization: since we discard the result, we can pass our - // own then implementation a special hint to let it know it - // doesn't have to create it. (The PROMISE_FAKE_CAPABILITY - // object is local to this implementation and unforgeable outside.) - if (then === Promise$prototype$then) { - _call(then, thenable, resolve, reject, PROMISE_FAKE_CAPABILITY); - } else { - _call(then, thenable, resolve, reject); - } - }; - var promiseResolveThenableJob = function (promise, thenable, then) { - var resolvingFunctions = createResolvingFunctions(promise); - var resolve = resolvingFunctions.resolve; - var reject = resolvingFunctions.reject; - try { - optimizedThen(then, thenable, resolve, reject); - } catch (e) { - reject(e); - } - }; - - var Promise$prototype, Promise$prototype$then; - var Promise = (function () { - var PromiseShim = function Promise(resolver) { - if (!(this instanceof PromiseShim)) { - throw new TypeError('Constructor Promise requires "new"'); - } - if (this && this._promise) { - throw new TypeError('Bad construction'); - } - // see https://bugs.ecmascript.org/show_bug.cgi?id=2482 - if (!ES.IsCallable(resolver)) { - throw new TypeError('not a valid resolver'); - } - var promise = emulateES6construct(this, PromiseShim, Promise$prototype, { - _promise: { - result: void 0, - state: PROMISE_PENDING, - // The first member of the "reactions" array is inlined here, - // since most promises only have one reaction. - // We've also exploded the 'reaction' object to inline the - // "handler" and "capability" fields, since both fulfill and - // reject reactions share the same capability. - reactionLength: 0, - fulfillReactionHandler0: void 0, - rejectReactionHandler0: void 0, - reactionCapability0: void 0 - } - }); - var resolvingFunctions = createResolvingFunctions(promise); - var reject = resolvingFunctions.reject; - try { - resolver(resolvingFunctions.resolve, reject); - } catch (e) { - reject(e); - } - return promise; - }; - return PromiseShim; - }()); - Promise$prototype = Promise.prototype; - - var _promiseAllResolver = function (index, values, capability, remaining) { - var alreadyCalled = false; - return function (x) { - if (alreadyCalled) { return; } - alreadyCalled = true; - values[index] = x; - if ((--remaining.count) === 0) { - var resolve = capability.resolve; - resolve(values); // call w/ this===undefined - } - }; - }; - - var performPromiseAll = function (iteratorRecord, C, resultCapability) { - var it = iteratorRecord.iterator; - var values = []; - var remaining = { count: 1 }; - var next, nextValue; - var index = 0; - while (true) { - try { - next = ES.IteratorStep(it); - if (next === false) { - iteratorRecord.done = true; - break; - } - nextValue = next.value; - } catch (e) { - iteratorRecord.done = true; - throw e; - } - values[index] = void 0; - var nextPromise = C.resolve(nextValue); - var resolveElement = _promiseAllResolver( - index, - values, - resultCapability, - remaining - ); - remaining.count += 1; - optimizedThen(nextPromise.then, nextPromise, resolveElement, resultCapability.reject); - index += 1; - } - if ((--remaining.count) === 0) { - var resolve = resultCapability.resolve; - resolve(values); // call w/ this===undefined - } - return resultCapability.promise; - }; - - var performPromiseRace = function (iteratorRecord, C, resultCapability) { - var it = iteratorRecord.iterator; - var next, nextValue, nextPromise; - while (true) { - try { - next = ES.IteratorStep(it); - if (next === false) { - // NOTE: If iterable has no items, resulting promise will never - // resolve; see: - // https://github.com/domenic/promises-unwrapping/issues/75 - // https://bugs.ecmascript.org/show_bug.cgi?id=2515 - iteratorRecord.done = true; - break; - } - nextValue = next.value; - } catch (e) { - iteratorRecord.done = true; - throw e; - } - nextPromise = C.resolve(nextValue); - optimizedThen(nextPromise.then, nextPromise, resultCapability.resolve, resultCapability.reject); - } - return resultCapability.promise; - }; - - defineProperties(Promise, { - all: function all(iterable) { - var C = this; - if (!ES.TypeIsObject(C)) { - throw new TypeError('Promise is not object'); - } - var capability = new PromiseCapability(C); - var iterator, iteratorRecord; - try { - iterator = ES.GetIterator(iterable); - iteratorRecord = { iterator: iterator, done: false }; - return performPromiseAll(iteratorRecord, C, capability); - } catch (e) { - var exception = e; - if (iteratorRecord && !iteratorRecord.done) { - try { - ES.IteratorClose(iterator, true); - } catch (ee) { - exception = ee; - } - } - var reject = capability.reject; - reject(exception); - return capability.promise; - } - }, - - race: function race(iterable) { - var C = this; - if (!ES.TypeIsObject(C)) { - throw new TypeError('Promise is not object'); - } - var capability = new PromiseCapability(C); - var iterator, iteratorRecord; - try { - iterator = ES.GetIterator(iterable); - iteratorRecord = { iterator: iterator, done: false }; - return performPromiseRace(iteratorRecord, C, capability); - } catch (e) { - var exception = e; - if (iteratorRecord && !iteratorRecord.done) { - try { - ES.IteratorClose(iterator, true); - } catch (ee) { - exception = ee; - } - } - var reject = capability.reject; - reject(exception); - return capability.promise; - } - }, - - reject: function reject(reason) { - var C = this; - if (!ES.TypeIsObject(C)) { - throw new TypeError('Bad promise constructor'); - } - var capability = new PromiseCapability(C); - var rejectFunc = capability.reject; - rejectFunc(reason); // call with this===undefined - return capability.promise; - }, - - resolve: function resolve(v) { - // See https://esdiscuss.org/topic/fixing-promise-resolve for spec - var C = this; - if (!ES.TypeIsObject(C)) { - throw new TypeError('Bad promise constructor'); - } - if (ES.IsPromise(v)) { - var constructor = v.constructor; - if (constructor === C) { - return v; - } - } - var capability = new PromiseCapability(C); - var resolveFunc = capability.resolve; - resolveFunc(v); // call with this===undefined - return capability.promise; - } - }); - - defineProperties(Promise$prototype, { - 'catch': function (onRejected) { - return this.then(null, onRejected); - }, - - then: function then(onFulfilled, onRejected) { - var promise = this; - if (!ES.IsPromise(promise)) { throw new TypeError('not a promise'); } - var C = ES.SpeciesConstructor(promise, Promise); - var resultCapability; - var returnValueIsIgnored = arguments.length > 2 && arguments[2] === PROMISE_FAKE_CAPABILITY; - if (returnValueIsIgnored && C === Promise) { - resultCapability = PROMISE_FAKE_CAPABILITY; - } else { - resultCapability = new PromiseCapability(C); - } - // PerformPromiseThen(promise, onFulfilled, onRejected, resultCapability) - // Note that we've split the 'reaction' object into its two - // components, "capabilities" and "handler" - // "capabilities" is always equal to `resultCapability` - var fulfillReactionHandler = ES.IsCallable(onFulfilled) ? onFulfilled : PROMISE_IDENTITY; - var rejectReactionHandler = ES.IsCallable(onRejected) ? onRejected : PROMISE_THROWER; - var _promise = promise._promise; - var value; - if (_promise.state === PROMISE_PENDING) { - if (_promise.reactionLength === 0) { - _promise.fulfillReactionHandler0 = fulfillReactionHandler; - _promise.rejectReactionHandler0 = rejectReactionHandler; - _promise.reactionCapability0 = resultCapability; - } else { - var idx = 3 * (_promise.reactionLength - 1); - _promise[idx + PROMISE_FULFILL_OFFSET] = fulfillReactionHandler; - _promise[idx + PROMISE_REJECT_OFFSET] = rejectReactionHandler; - _promise[idx + PROMISE_CAPABILITY_OFFSET] = resultCapability; - } - _promise.reactionLength += 1; - } else if (_promise.state === PROMISE_FULFILLED) { - value = _promise.result; - enqueuePromiseReactionJob( - fulfillReactionHandler, - resultCapability, - value - ); - } else if (_promise.state === PROMISE_REJECTED) { - value = _promise.result; - enqueuePromiseReactionJob( - rejectReactionHandler, - resultCapability, - value - ); - } else { - throw new TypeError('unexpected Promise state'); - } - return resultCapability.promise; - } - }); - // This helps the optimizer by ensuring that methods which take - // capabilities aren't polymorphic. - PROMISE_FAKE_CAPABILITY = new PromiseCapability(Promise); - Promise$prototype$then = Promise$prototype.then; - - return Promise; - }()); - - // Chrome's native Promise has extra methods that it shouldn't have. Let's remove them. - if (globals.Promise) { - delete globals.Promise.accept; - delete globals.Promise.defer; - delete globals.Promise.prototype.chain; - } - - if (typeof PromiseShim === 'function') { - // export the Promise constructor. - defineProperties(globals, { Promise: PromiseShim }); - // In Chrome 33 (and thereabouts) Promise is defined, but the - // implementation is buggy in a number of ways. Let's check subclassing - // support to see if we have a buggy implementation. - var promiseSupportsSubclassing = supportsSubclassing(globals.Promise, function (S) { - return S.resolve(42).then(function () {}) instanceof S; - }); - var promiseIgnoresNonFunctionThenCallbacks = !throwsError(function () { - return globals.Promise.reject(42).then(null, 5).then(null, noop); - }); - var promiseRequiresObjectContext = throwsError(function () { return globals.Promise.call(3, noop); }); - // Promise.resolve() was errata'ed late in the ES6 process. - // See: https://bugzilla.mozilla.org/show_bug.cgi?id=1170742 - // https://code.google.com/p/v8/issues/detail?id=4161 - // It serves as a proxy for a number of other bugs in early Promise - // implementations. - var promiseResolveBroken = (function (Promise) { - var p = Promise.resolve(5); - p.constructor = {}; - var p2 = Promise.resolve(p); - try { - p2.then(null, noop).then(null, noop); // avoid "uncaught rejection" warnings in console - } catch (e) { - return true; // v8 native Promises break here https://code.google.com/p/chromium/issues/detail?id=575314 - } - return p === p2; // This *should* be false! - }(globals.Promise)); - - // Chrome 46 (probably older too) does not retrieve a thenable's .then synchronously - var getsThenSynchronously = supportsDescriptors && (function () { - var count = 0; - // eslint-disable-next-line getter-return - Object.defineProperty({}, 'then', { get: function () { count += 1; } }); - return count === 1; - }()); - - var BadResolverPromise = function BadResolverPromise(executor) { - var p = new Promise(executor); - executor(3, function () {}); - this.then = p.then; - this.constructor = BadResolverPromise; - }; - BadResolverPromise.prototype = Promise.prototype; - BadResolverPromise.all = Promise.all; - // Chrome Canary 49 (probably older too) has some implementation bugs - var hasBadResolverPromise = valueOrFalseIfThrows(function () { - return !!BadResolverPromise.all([1, 2]); - }); - - if (!promiseSupportsSubclassing || !promiseIgnoresNonFunctionThenCallbacks || - !promiseRequiresObjectContext || promiseResolveBroken || - !getsThenSynchronously || hasBadResolverPromise) { - /* globals Promise: true */ - /* eslint-disable no-undef, no-global-assign */ - Promise = PromiseShim; - /* eslint-enable no-undef, no-global-assign */ - overrideNative(globals, 'Promise', PromiseShim); - } - if (Promise.all.length !== 1) { - var origAll = Promise.all; - overrideNative(Promise, 'all', function all(iterable) { - return ES.Call(origAll, this, arguments); - }); - } - if (Promise.race.length !== 1) { - var origRace = Promise.race; - overrideNative(Promise, 'race', function race(iterable) { - return ES.Call(origRace, this, arguments); - }); - } - if (Promise.resolve.length !== 1) { - var origResolve = Promise.resolve; - overrideNative(Promise, 'resolve', function resolve(x) { - return ES.Call(origResolve, this, arguments); - }); - } - if (Promise.reject.length !== 1) { - var origReject = Promise.reject; - overrideNative(Promise, 'reject', function reject(r) { - return ES.Call(origReject, this, arguments); - }); - } - ensureEnumerable(Promise, 'all'); - ensureEnumerable(Promise, 'race'); - ensureEnumerable(Promise, 'resolve'); - ensureEnumerable(Promise, 'reject'); - addDefaultSpecies(Promise); - } - - // Map and Set require a true ES5 environment - // Their fast path also requires that the environment preserve - // property insertion order, which is not guaranteed by the spec. - var testOrder = function (a) { - var b = keys(_reduce(a, function (o, k) { - o[k] = true; - return o; - }, {})); - return a.join(':') === b.join(':'); - }; - var preservesInsertionOrder = testOrder(['z', 'a', 'bb']); - // some engines (eg, Chrome) only preserve insertion order for string keys - var preservesNumericInsertionOrder = testOrder(['z', 1, 'a', '3', 2]); - - if (supportsDescriptors) { - - var fastkey = function fastkey(key, skipInsertionOrderCheck) { - if (!skipInsertionOrderCheck && !preservesInsertionOrder) { - return null; - } - if (isNullOrUndefined(key)) { - return '^' + ES.ToString(key); - } else if (typeof key === 'string') { - return '$' + key; - } else if (typeof key === 'number') { - // note that -0 will get coerced to "0" when used as a property key - if (!preservesNumericInsertionOrder) { - return 'n' + key; - } - return key; - } else if (typeof key === 'boolean') { - return 'b' + key; - } - return null; - }; - - var emptyObject = function emptyObject() { - // accomodate some older not-quite-ES5 browsers - return Object.create ? Object.create(null) : {}; - }; - - var addIterableToMap = function addIterableToMap(MapConstructor, map, iterable) { - if (isArray(iterable) || Type.string(iterable)) { - _forEach(iterable, function (entry) { - if (!ES.TypeIsObject(entry)) { - throw new TypeError('Iterator value ' + entry + ' is not an entry object'); - } - map.set(entry[0], entry[1]); - }); - } else if (iterable instanceof MapConstructor) { - _call(MapConstructor.prototype.forEach, iterable, function (value, key) { - map.set(key, value); - }); - } else { - var iter, adder; - if (!isNullOrUndefined(iterable)) { - adder = map.set; - if (!ES.IsCallable(adder)) { throw new TypeError('bad map'); } - iter = ES.GetIterator(iterable); - } - if (typeof iter !== 'undefined') { - while (true) { - var next = ES.IteratorStep(iter); - if (next === false) { break; } - var nextItem = next.value; - try { - if (!ES.TypeIsObject(nextItem)) { - throw new TypeError('Iterator value ' + nextItem + ' is not an entry object'); - } - _call(adder, map, nextItem[0], nextItem[1]); - } catch (e) { - ES.IteratorClose(iter, true); - throw e; - } - } - } - } - }; - var addIterableToSet = function addIterableToSet(SetConstructor, set, iterable) { - if (isArray(iterable) || Type.string(iterable)) { - _forEach(iterable, function (value) { - set.add(value); - }); - } else if (iterable instanceof SetConstructor) { - _call(SetConstructor.prototype.forEach, iterable, function (value) { - set.add(value); - }); - } else { - var iter, adder; - if (!isNullOrUndefined(iterable)) { - adder = set.add; - if (!ES.IsCallable(adder)) { throw new TypeError('bad set'); } - iter = ES.GetIterator(iterable); - } - if (typeof iter !== 'undefined') { - while (true) { - var next = ES.IteratorStep(iter); - if (next === false) { break; } - var nextValue = next.value; - try { - _call(adder, set, nextValue); - } catch (e) { - ES.IteratorClose(iter, true); - throw e; - } - } - } - } - }; - - var collectionShims = { - Map: (function () { - - var empty = {}; - - var MapEntry = function MapEntry(key, value) { - this.key = key; - this.value = value; - this.next = null; - this.prev = null; - }; - - MapEntry.prototype.isRemoved = function isRemoved() { - return this.key === empty; - }; - - var isMap = function isMap(map) { - return !!map._es6map; - }; - - var requireMapSlot = function requireMapSlot(map, method) { - if (!ES.TypeIsObject(map) || !isMap(map)) { - throw new TypeError('Method Map.prototype.' + method + ' called on incompatible receiver ' + ES.ToString(map)); - } - }; - - var MapIterator = function MapIterator(map, kind) { - requireMapSlot(map, '[[MapIterator]]'); - this.head = map._head; - this.i = this.head; - this.kind = kind; - }; - - MapIterator.prototype = { - isMapIterator: true, - next: function next() { - if (!this.isMapIterator) { - throw new TypeError('Not a MapIterator'); - } - var i = this.i; - var kind = this.kind; - var head = this.head; - if (typeof this.i === 'undefined') { - return iteratorResult(); - } - while (i.isRemoved() && i !== head) { - // back up off of removed entries - i = i.prev; - } - // advance to next unreturned element. - var result; - while (i.next !== head) { - i = i.next; - if (!i.isRemoved()) { - if (kind === 'key') { - result = i.key; - } else if (kind === 'value') { - result = i.value; - } else { - result = [i.key, i.value]; - } - this.i = i; - return iteratorResult(result); - } - } - // once the iterator is done, it is done forever. - this.i = void 0; - return iteratorResult(); - } - }; - addIterator(MapIterator.prototype); - - var Map$prototype; - var MapShim = function Map() { - if (!(this instanceof Map)) { - throw new TypeError('Constructor Map requires "new"'); - } - if (this && this._es6map) { - throw new TypeError('Bad construction'); - } - var map = emulateES6construct(this, Map, Map$prototype, { - _es6map: true, - _head: null, - _map: OrigMap ? new OrigMap() : null, - _size: 0, - _storage: emptyObject() - }); - - var head = new MapEntry(null, null); - // circular doubly-linked list. - /* eslint no-multi-assign: 1 */ - head.next = head.prev = head; - map._head = head; - - // Optionally initialize map from iterable - if (arguments.length > 0) { - addIterableToMap(Map, map, arguments[0]); - } - return map; - }; - Map$prototype = MapShim.prototype; - - Value.getter(Map$prototype, 'size', function () { - if (typeof this._size === 'undefined') { - throw new TypeError('size method called on incompatible Map'); - } - return this._size; - }); - - defineProperties(Map$prototype, { - get: function get(key) { - requireMapSlot(this, 'get'); - var entry; - var fkey = fastkey(key, true); - if (fkey !== null) { - // fast O(1) path - entry = this._storage[fkey]; - if (entry) { - return entry.value; - } else { - return; - } - } - if (this._map) { - // fast object key path - entry = origMapGet.call(this._map, key); - if (entry) { - return entry.value; - } else { - return; - } - } - var head = this._head; - var i = head; - while ((i = i.next) !== head) { - if (ES.SameValueZero(i.key, key)) { - return i.value; - } - } - }, - - has: function has(key) { - requireMapSlot(this, 'has'); - var fkey = fastkey(key, true); - if (fkey !== null) { - // fast O(1) path - return typeof this._storage[fkey] !== 'undefined'; - } - if (this._map) { - // fast object key path - return origMapHas.call(this._map, key); - } - var head = this._head; - var i = head; - while ((i = i.next) !== head) { - if (ES.SameValueZero(i.key, key)) { - return true; - } - } - return false; - }, - - set: function set(key, value) { - requireMapSlot(this, 'set'); - var head = this._head; - var i = head; - var entry; - var fkey = fastkey(key, true); - if (fkey !== null) { - // fast O(1) path - if (typeof this._storage[fkey] !== 'undefined') { - this._storage[fkey].value = value; - return this; - } else { - entry = this._storage[fkey] = new MapEntry(key, value); /* eslint no-multi-assign: 1 */ - i = head.prev; - // fall through - } - } else if (this._map) { - // fast object key path - if (origMapHas.call(this._map, key)) { - origMapGet.call(this._map, key).value = value; - } else { - entry = new MapEntry(key, value); - origMapSet.call(this._map, key, entry); - i = head.prev; - // fall through - } - } - while ((i = i.next) !== head) { - if (ES.SameValueZero(i.key, key)) { - i.value = value; - return this; - } - } - entry = entry || new MapEntry(key, value); - if (ES.SameValue(-0, key)) { - entry.key = +0; // coerce -0 to +0 in entry - } - entry.next = this._head; - entry.prev = this._head.prev; - entry.prev.next = entry; - entry.next.prev = entry; - this._size += 1; - return this; - }, - - 'delete': function (key) { - requireMapSlot(this, 'delete'); - var head = this._head; - var i = head; - var fkey = fastkey(key, true); - if (fkey !== null) { - // fast O(1) path - if (typeof this._storage[fkey] === 'undefined') { - return false; - } - i = this._storage[fkey].prev; - delete this._storage[fkey]; - // fall through - } else if (this._map) { - // fast object key path - if (!origMapHas.call(this._map, key)) { - return false; - } - i = origMapGet.call(this._map, key).prev; - origMapDelete.call(this._map, key); - // fall through - } - while ((i = i.next) !== head) { - if (ES.SameValueZero(i.key, key)) { - i.key = empty; - i.value = empty; - i.prev.next = i.next; - i.next.prev = i.prev; - this._size -= 1; - return true; - } - } - return false; - }, - - clear: function clear() { - /* eslint no-multi-assign: 1 */ - requireMapSlot(this, 'clear'); - this._map = OrigMap ? new OrigMap() : null; - this._size = 0; - this._storage = emptyObject(); - var head = this._head; - var i = head; - var p = i.next; - while ((i = p) !== head) { - i.key = empty; - i.value = empty; - p = i.next; - i.next = i.prev = head; - } - head.next = head.prev = head; - }, - - keys: function keys() { - requireMapSlot(this, 'keys'); - return new MapIterator(this, 'key'); - }, - - values: function values() { - requireMapSlot(this, 'values'); - return new MapIterator(this, 'value'); - }, - - entries: function entries() { - requireMapSlot(this, 'entries'); - return new MapIterator(this, 'key+value'); - }, - - forEach: function forEach(callback) { - requireMapSlot(this, 'forEach'); - var context = arguments.length > 1 ? arguments[1] : null; - var it = this.entries(); - for (var entry = it.next(); !entry.done; entry = it.next()) { - if (context) { - _call(callback, context, entry.value[1], entry.value[0], this); - } else { - callback(entry.value[1], entry.value[0], this); - } - } - } - }); - addIterator(Map$prototype, Map$prototype.entries); - - return MapShim; - }()), - - Set: (function () { - var isSet = function isSet(set) { - return set._es6set && typeof set._storage !== 'undefined'; - }; - var requireSetSlot = function requireSetSlot(set, method) { - if (!ES.TypeIsObject(set) || !isSet(set)) { - // https://github.com/paulmillr/es6-shim/issues/176 - throw new TypeError('Set.prototype.' + method + ' called on incompatible receiver ' + ES.ToString(set)); - } - }; - - // Creating a Map is expensive. To speed up the common case of - // Sets containing only string or numeric keys, we use an object - // as backing storage and lazily create a full Map only when - // required. - var Set$prototype; - var SetShim = function Set() { - if (!(this instanceof Set)) { - throw new TypeError('Constructor Set requires "new"'); - } - if (this && this._es6set) { - throw new TypeError('Bad construction'); - } - var set = emulateES6construct(this, Set, Set$prototype, { - _es6set: true, - '[[SetData]]': null, - _storage: emptyObject() - }); - if (!set._es6set) { - throw new TypeError('bad set'); - } - - // Optionally initialize Set from iterable - if (arguments.length > 0) { - addIterableToSet(Set, set, arguments[0]); - } - return set; - }; - Set$prototype = SetShim.prototype; - - var decodeKey = function (key) { - var k = key; - if (k === '^null') { - return null; - } else if (k === '^undefined') { - return void 0; - } else { - var first = k.charAt(0); - if (first === '$') { - return _strSlice(k, 1); - } else if (first === 'n') { - return +_strSlice(k, 1); - } else if (first === 'b') { - return k === 'btrue'; - } - } - return +k; - }; - // Switch from the object backing storage to a full Map. - var ensureMap = function ensureMap(set) { - if (!set['[[SetData]]']) { - var m = new collectionShims.Map(); - set['[[SetData]]'] = m; - _forEach(keys(set._storage), function (key) { - var k = decodeKey(key); - m.set(k, k); - }); - set['[[SetData]]'] = m; - } - set._storage = null; // free old backing storage - }; - - Value.getter(SetShim.prototype, 'size', function () { - requireSetSlot(this, 'size'); - if (this._storage) { - return keys(this._storage).length; - } - ensureMap(this); - return this['[[SetData]]'].size; - }); - - defineProperties(SetShim.prototype, { - has: function has(key) { - requireSetSlot(this, 'has'); - var fkey; - if (this._storage && (fkey = fastkey(key)) !== null) { - return !!this._storage[fkey]; - } - ensureMap(this); - return this['[[SetData]]'].has(key); - }, - - add: function add(key) { - requireSetSlot(this, 'add'); - var fkey; - if (this._storage && (fkey = fastkey(key)) !== null) { - this._storage[fkey] = true; - return this; - } - ensureMap(this); - this['[[SetData]]'].set(key, key); - return this; - }, - - 'delete': function (key) { - requireSetSlot(this, 'delete'); - var fkey; - if (this._storage && (fkey = fastkey(key)) !== null) { - var hasFKey = _hasOwnProperty(this._storage, fkey); - return (delete this._storage[fkey]) && hasFKey; - } - ensureMap(this); - return this['[[SetData]]']['delete'](key); - }, - - clear: function clear() { - requireSetSlot(this, 'clear'); - if (this._storage) { - this._storage = emptyObject(); - } - if (this['[[SetData]]']) { - this['[[SetData]]'].clear(); - } - }, - - values: function values() { - requireSetSlot(this, 'values'); - ensureMap(this); - return new SetIterator(this['[[SetData]]'].values()); - }, - - entries: function entries() { - requireSetSlot(this, 'entries'); - ensureMap(this); - return new SetIterator(this['[[SetData]]'].entries()); - }, - - forEach: function forEach(callback) { - requireSetSlot(this, 'forEach'); - var context = arguments.length > 1 ? arguments[1] : null; - var entireSet = this; - ensureMap(entireSet); - this['[[SetData]]'].forEach(function (value, key) { - if (context) { - _call(callback, context, key, key, entireSet); - } else { - callback(key, key, entireSet); - } - }); - } - }); - defineProperty(SetShim.prototype, 'keys', SetShim.prototype.values, true); - addIterator(SetShim.prototype, SetShim.prototype.values); - - var SetIterator = function SetIterator(it) { - this.it = it; - }; - SetIterator.prototype = { - isSetIterator: true, - next: function next() { - if (!this.isSetIterator) { - throw new TypeError('Not a SetIterator'); - } - return this.it.next(); - } - }; - addIterator(SetIterator.prototype); - - return SetShim; - }()) - }; - - var isGoogleTranslate = globals.Set && !Set.prototype['delete'] && Set.prototype.remove && Set.prototype.items && Set.prototype.map && Array.isArray(new Set().keys); - if (isGoogleTranslate) { - // special-case force removal of wildly invalid Set implementation in Google Translate iframes - // see https://github.com/paulmillr/es6-shim/issues/438 / https://twitter.com/ljharb/status/849335573114363904 - globals.Set = collectionShims.Set; - } - if (globals.Map || globals.Set) { - // Safari 8, for example, doesn't accept an iterable. - var mapAcceptsArguments = valueOrFalseIfThrows(function () { return new Map([[1, 2]]).get(1) === 2; }); - if (!mapAcceptsArguments) { - globals.Map = function Map() { - if (!(this instanceof Map)) { - throw new TypeError('Constructor Map requires "new"'); - } - var m = new OrigMap(); - if (arguments.length > 0) { - addIterableToMap(Map, m, arguments[0]); - } - delete m.constructor; - Object.setPrototypeOf(m, globals.Map.prototype); - return m; - }; - globals.Map.prototype = create(OrigMap.prototype); - defineProperty(globals.Map.prototype, 'constructor', globals.Map, true); - Value.preserveToString(globals.Map, OrigMap); - } - var testMap = new Map(); - var mapUsesSameValueZero = (function () { - // Chrome 38-42, node 0.11/0.12, iojs 1/2 also have a bug when the Map has a size > 4 - var m = new Map([[1, 0], [2, 0], [3, 0], [4, 0]]); - m.set(-0, m); - return m.get(0) === m && m.get(-0) === m && m.has(0) && m.has(-0); - }()); - var mapSupportsChaining = testMap.set(1, 2) === testMap; - if (!mapUsesSameValueZero || !mapSupportsChaining) { - overrideNative(Map.prototype, 'set', function set(k, v) { - _call(origMapSet, this, k === 0 ? 0 : k, v); - return this; - }); - } - if (!mapUsesSameValueZero) { - defineProperties(Map.prototype, { - get: function get(k) { - return _call(origMapGet, this, k === 0 ? 0 : k); - }, - has: function has(k) { - return _call(origMapHas, this, k === 0 ? 0 : k); - } - }, true); - Value.preserveToString(Map.prototype.get, origMapGet); - Value.preserveToString(Map.prototype.has, origMapHas); - } - var testSet = new Set(); - var setUsesSameValueZero = Set.prototype['delete'] && Set.prototype.add && Set.prototype.has && (function (s) { - s['delete'](0); - s.add(-0); - return !s.has(0); - }(testSet)); - var setSupportsChaining = testSet.add(1) === testSet; - if (!setUsesSameValueZero || !setSupportsChaining) { - var origSetAdd = Set.prototype.add; - Set.prototype.add = function add(v) { - _call(origSetAdd, this, v === 0 ? 0 : v); - return this; - }; - Value.preserveToString(Set.prototype.add, origSetAdd); - } - if (!setUsesSameValueZero) { - var origSetHas = Set.prototype.has; - Set.prototype.has = function has(v) { - return _call(origSetHas, this, v === 0 ? 0 : v); - }; - Value.preserveToString(Set.prototype.has, origSetHas); - var origSetDel = Set.prototype['delete']; - Set.prototype['delete'] = function SetDelete(v) { - return _call(origSetDel, this, v === 0 ? 0 : v); - }; - Value.preserveToString(Set.prototype['delete'], origSetDel); - } - var mapSupportsSubclassing = supportsSubclassing(globals.Map, function (M) { - var m = new M([]); - // Firefox 32 is ok with the instantiating the subclass but will - // throw when the map is used. - m.set(42, 42); - return m instanceof M; - }); - // without Object.setPrototypeOf, subclassing is not possible - var mapFailsToSupportSubclassing = Object.setPrototypeOf && !mapSupportsSubclassing; - var mapRequiresNew = (function () { - try { - return !(globals.Map() instanceof globals.Map); - } catch (e) { - return e instanceof TypeError; - } - }()); - if (globals.Map.length !== 0 || mapFailsToSupportSubclassing || !mapRequiresNew) { - globals.Map = function Map() { - if (!(this instanceof Map)) { - throw new TypeError('Constructor Map requires "new"'); - } - var m = new OrigMap(); - if (arguments.length > 0) { - addIterableToMap(Map, m, arguments[0]); - } - delete m.constructor; - Object.setPrototypeOf(m, Map.prototype); - return m; - }; - globals.Map.prototype = OrigMap.prototype; - defineProperty(globals.Map.prototype, 'constructor', globals.Map, true); - Value.preserveToString(globals.Map, OrigMap); - } - var setSupportsSubclassing = supportsSubclassing(globals.Set, function (S) { - var s = new S([]); - s.add(42, 42); - return s instanceof S; - }); - // without Object.setPrototypeOf, subclassing is not possible - var setFailsToSupportSubclassing = Object.setPrototypeOf && !setSupportsSubclassing; - var setRequiresNew = (function () { - try { - return !(globals.Set() instanceof globals.Set); - } catch (e) { - return e instanceof TypeError; - } - }()); - if (globals.Set.length !== 0 || setFailsToSupportSubclassing || !setRequiresNew) { - var OrigSet = globals.Set; - globals.Set = function Set() { - if (!(this instanceof Set)) { - throw new TypeError('Constructor Set requires "new"'); - } - var s = new OrigSet(); - if (arguments.length > 0) { - addIterableToSet(Set, s, arguments[0]); - } - delete s.constructor; - Object.setPrototypeOf(s, Set.prototype); - return s; - }; - globals.Set.prototype = OrigSet.prototype; - defineProperty(globals.Set.prototype, 'constructor', globals.Set, true); - Value.preserveToString(globals.Set, OrigSet); - } - var newMap = new globals.Map(); - var mapIterationThrowsStopIterator = !valueOrFalseIfThrows(function () { - return newMap.keys().next().done; - }); - /* - - In Firefox < 23, Map#size is a function. - - In all current Firefox, Set#entries/keys/values & Map#clear do not exist - - https://bugzilla.mozilla.org/show_bug.cgi?id=869996 - - In Firefox 24, Map and Set do not implement forEach - - In Firefox 25 at least, Map and Set are callable without "new" - */ - if ( - typeof globals.Map.prototype.clear !== 'function' || - new globals.Set().size !== 0 || - newMap.size !== 0 || - typeof globals.Map.prototype.keys !== 'function' || - typeof globals.Set.prototype.keys !== 'function' || - typeof globals.Map.prototype.forEach !== 'function' || - typeof globals.Set.prototype.forEach !== 'function' || - isCallableWithoutNew(globals.Map) || - isCallableWithoutNew(globals.Set) || - typeof newMap.keys().next !== 'function' || // Safari 8 - mapIterationThrowsStopIterator || // Firefox 25 - !mapSupportsSubclassing - ) { - defineProperties(globals, { - Map: collectionShims.Map, - Set: collectionShims.Set - }, true); - } - - if (globals.Set.prototype.keys !== globals.Set.prototype.values) { - // Fixed in WebKit with https://bugs.webkit.org/show_bug.cgi?id=144190 - defineProperty(globals.Set.prototype, 'keys', globals.Set.prototype.values, true); - } - - // Shim incomplete iterator implementations. - addIterator(Object.getPrototypeOf((new globals.Map()).keys())); - addIterator(Object.getPrototypeOf((new globals.Set()).keys())); - - if (functionsHaveNames && globals.Set.prototype.has.name !== 'has') { - // Microsoft Edge v0.11.10074.0 is missing a name on Set#has - var anonymousSetHas = globals.Set.prototype.has; - overrideNative(globals.Set.prototype, 'has', function has(key) { - return _call(anonymousSetHas, this, key); - }); - } - } - defineProperties(globals, collectionShims); - addDefaultSpecies(globals.Map); - addDefaultSpecies(globals.Set); - } - - var throwUnlessTargetIsObject = function throwUnlessTargetIsObject(target) { - if (!ES.TypeIsObject(target)) { - throw new TypeError('target must be an object'); - } - }; - - // Some Reflect methods are basically the same as - // those on the Object global, except that a TypeError is thrown if - // target isn't an object. As well as returning a boolean indicating - // the success of the operation. - var ReflectShims = { - // Apply method in a functional form. - apply: function apply() { - return ES.Call(ES.Call, null, arguments); - }, - - // New operator in a functional form. - construct: function construct(constructor, args) { - if (!ES.IsConstructor(constructor)) { - throw new TypeError('First argument must be a constructor.'); - } - var newTarget = arguments.length > 2 ? arguments[2] : constructor; - if (!ES.IsConstructor(newTarget)) { - throw new TypeError('new.target must be a constructor.'); - } - return ES.Construct(constructor, args, newTarget, 'internal'); - }, - - // When deleting a non-existent or configurable property, - // true is returned. - // When attempting to delete a non-configurable property, - // it will return false. - deleteProperty: function deleteProperty(target, key) { - throwUnlessTargetIsObject(target); - if (supportsDescriptors) { - var desc = Object.getOwnPropertyDescriptor(target, key); - - if (desc && !desc.configurable) { - return false; - } - } - - // Will return true. - return delete target[key]; - }, - - has: function has(target, key) { - throwUnlessTargetIsObject(target); - return key in target; - } - }; - - if (Object.getOwnPropertyNames) { - Object.assign(ReflectShims, { - // Basically the result of calling the internal [[OwnPropertyKeys]]. - // Concatenating propertyNames and propertySymbols should do the trick. - // This should continue to work together with a Symbol shim - // which overrides Object.getOwnPropertyNames and implements - // Object.getOwnPropertySymbols. - ownKeys: function ownKeys(target) { - throwUnlessTargetIsObject(target); - var keys = Object.getOwnPropertyNames(target); - - if (ES.IsCallable(Object.getOwnPropertySymbols)) { - _pushApply(keys, Object.getOwnPropertySymbols(target)); - } - - return keys; - } - }); - } - - var callAndCatchException = function ConvertExceptionToBoolean(func) { - return !throwsError(func); - }; - - if (Object.preventExtensions) { - Object.assign(ReflectShims, { - isExtensible: function isExtensible(target) { - throwUnlessTargetIsObject(target); - return Object.isExtensible(target); - }, - preventExtensions: function preventExtensions(target) { - throwUnlessTargetIsObject(target); - return callAndCatchException(function () { - return Object.preventExtensions(target); - }); - } - }); - } - - if (supportsDescriptors) { - var internalGet = function get(target, key, receiver) { - var desc = Object.getOwnPropertyDescriptor(target, key); - - if (!desc) { - var parent = Object.getPrototypeOf(target); - - if (parent === null) { - return void 0; - } - - return internalGet(parent, key, receiver); - } - - if ('value' in desc) { - return desc.value; - } - - if (desc.get) { - return ES.Call(desc.get, receiver); - } - - return void 0; - }; - - var internalSet = function set(target, key, value, receiver) { - var desc = Object.getOwnPropertyDescriptor(target, key); - - if (!desc) { - var parent = Object.getPrototypeOf(target); - - if (parent !== null) { - return internalSet(parent, key, value, receiver); - } - - desc = { - value: void 0, - writable: true, - enumerable: true, - configurable: true - }; - } - - if ('value' in desc) { - if (!desc.writable) { - return false; - } - - if (!ES.TypeIsObject(receiver)) { - return false; - } - - var existingDesc = Object.getOwnPropertyDescriptor(receiver, key); - - if (existingDesc) { - return Reflect.defineProperty(receiver, key, { - value: value - }); - } else { - return Reflect.defineProperty(receiver, key, { - value: value, - writable: true, - enumerable: true, - configurable: true - }); - } - } - - if (desc.set) { - _call(desc.set, receiver, value); - return true; - } - - return false; - }; - - Object.assign(ReflectShims, { - defineProperty: function defineProperty(target, propertyKey, attributes) { - throwUnlessTargetIsObject(target); - return callAndCatchException(function () { - return Object.defineProperty(target, propertyKey, attributes); - }); - }, - - getOwnPropertyDescriptor: function getOwnPropertyDescriptor(target, propertyKey) { - throwUnlessTargetIsObject(target); - return Object.getOwnPropertyDescriptor(target, propertyKey); - }, - - // Syntax in a functional form. - get: function get(target, key) { - throwUnlessTargetIsObject(target); - var receiver = arguments.length > 2 ? arguments[2] : target; - - return internalGet(target, key, receiver); - }, - - set: function set(target, key, value) { - throwUnlessTargetIsObject(target); - var receiver = arguments.length > 3 ? arguments[3] : target; - - return internalSet(target, key, value, receiver); - } - }); - } - - if (Object.getPrototypeOf) { - var objectDotGetPrototypeOf = Object.getPrototypeOf; - ReflectShims.getPrototypeOf = function getPrototypeOf(target) { - throwUnlessTargetIsObject(target); - return objectDotGetPrototypeOf(target); - }; - } - - if (Object.setPrototypeOf && ReflectShims.getPrototypeOf) { - var willCreateCircularPrototype = function (object, lastProto) { - var proto = lastProto; - while (proto) { - if (object === proto) { - return true; - } - proto = ReflectShims.getPrototypeOf(proto); - } - return false; - }; - - Object.assign(ReflectShims, { - // Sets the prototype of the given object. - // Returns true on success, otherwise false. - setPrototypeOf: function setPrototypeOf(object, proto) { - throwUnlessTargetIsObject(object); - if (proto !== null && !ES.TypeIsObject(proto)) { - throw new TypeError('proto must be an object or null'); - } - - // If they already are the same, we're done. - if (proto === Reflect.getPrototypeOf(object)) { - return true; - } - - // Cannot alter prototype if object not extensible. - if (Reflect.isExtensible && !Reflect.isExtensible(object)) { - return false; - } - - // Ensure that we do not create a circular prototype chain. - if (willCreateCircularPrototype(object, proto)) { - return false; - } - - Object.setPrototypeOf(object, proto); - - return true; - } - }); - } - var defineOrOverrideReflectProperty = function (key, shim) { - if (!ES.IsCallable(globals.Reflect[key])) { - defineProperty(globals.Reflect, key, shim); - } else { - var acceptsPrimitives = valueOrFalseIfThrows(function () { - globals.Reflect[key](1); - globals.Reflect[key](NaN); - globals.Reflect[key](true); - return true; - }); - if (acceptsPrimitives) { - overrideNative(globals.Reflect, key, shim); - } - } - }; - Object.keys(ReflectShims).forEach(function (key) { - defineOrOverrideReflectProperty(key, ReflectShims[key]); - }); - var originalReflectGetProto = globals.Reflect.getPrototypeOf; - if (functionsHaveNames && originalReflectGetProto && originalReflectGetProto.name !== 'getPrototypeOf') { - overrideNative(globals.Reflect, 'getPrototypeOf', function getPrototypeOf(target) { - return _call(originalReflectGetProto, globals.Reflect, target); - }); - } - if (globals.Reflect.setPrototypeOf) { - if (valueOrFalseIfThrows(function () { - globals.Reflect.setPrototypeOf(1, {}); - return true; - })) { - overrideNative(globals.Reflect, 'setPrototypeOf', ReflectShims.setPrototypeOf); - } - } - if (globals.Reflect.defineProperty) { - if (!valueOrFalseIfThrows(function () { - var basic = !globals.Reflect.defineProperty(1, 'test', { value: 1 }); - // "extensible" fails on Edge 0.12 - var extensible = typeof Object.preventExtensions !== 'function' || !globals.Reflect.defineProperty(Object.preventExtensions({}), 'test', {}); - return basic && extensible; - })) { - overrideNative(globals.Reflect, 'defineProperty', ReflectShims.defineProperty); - } - } - if (globals.Reflect.construct) { - if (!valueOrFalseIfThrows(function () { - var F = function F() {}; - return globals.Reflect.construct(function () {}, [], F) instanceof F; - })) { - overrideNative(globals.Reflect, 'construct', ReflectShims.construct); - } - } - - if (String(new Date(NaN)) !== 'Invalid Date') { - var dateToString = Date.prototype.toString; - var shimmedDateToString = function toString() { - var valueOf = +this; - if (valueOf !== valueOf) { - return 'Invalid Date'; - } - return ES.Call(dateToString, this); - }; - overrideNative(Date.prototype, 'toString', shimmedDateToString); - } - - // Annex B HTML methods - // http://www.ecma-international.org/ecma-262/6.0/#sec-additional-properties-of-the-string.prototype-object - var stringHTMLshims = { - anchor: function anchor(name) { return ES.CreateHTML(this, 'a', 'name', name); }, - big: function big() { return ES.CreateHTML(this, 'big', '', ''); }, - blink: function blink() { return ES.CreateHTML(this, 'blink', '', ''); }, - bold: function bold() { return ES.CreateHTML(this, 'b', '', ''); }, - fixed: function fixed() { return ES.CreateHTML(this, 'tt', '', ''); }, - fontcolor: function fontcolor(color) { return ES.CreateHTML(this, 'font', 'color', color); }, - fontsize: function fontsize(size) { return ES.CreateHTML(this, 'font', 'size', size); }, - italics: function italics() { return ES.CreateHTML(this, 'i', '', ''); }, - link: function link(url) { return ES.CreateHTML(this, 'a', 'href', url); }, - small: function small() { return ES.CreateHTML(this, 'small', '', ''); }, - strike: function strike() { return ES.CreateHTML(this, 'strike', '', ''); }, - sub: function sub() { return ES.CreateHTML(this, 'sub', '', ''); }, - sup: function sub() { return ES.CreateHTML(this, 'sup', '', ''); } - }; - _forEach(Object.keys(stringHTMLshims), function (key) { - var method = String.prototype[key]; - var shouldOverwrite = false; - if (ES.IsCallable(method)) { - var output = _call(method, '', ' " '); - var quotesCount = _concat([], output.match(/"/g)).length; - shouldOverwrite = output !== output.toLowerCase() || quotesCount > 2; - } else { - shouldOverwrite = true; - } - if (shouldOverwrite) { - overrideNative(String.prototype, key, stringHTMLshims[key]); - } - }); - - var JSONstringifiesSymbols = (function () { - // Microsoft Edge v0.12 stringifies Symbols incorrectly - if (!hasSymbols) { return false; } // Symbols are not supported - var stringify = typeof JSON === 'object' && typeof JSON.stringify === 'function' ? JSON.stringify : null; - if (!stringify) { return false; } // JSON.stringify is not supported - if (typeof stringify(Symbol()) !== 'undefined') { return true; } // Symbols should become `undefined` - if (stringify([Symbol()]) !== '[null]') { return true; } // Symbols in arrays should become `null` - var obj = { a: Symbol() }; - obj[Symbol()] = true; - if (stringify(obj) !== '{}') { return true; } // Symbol-valued keys *and* Symbol-valued properties should be omitted - return false; - }()); - var JSONstringifyAcceptsObjectSymbol = valueOrFalseIfThrows(function () { - // Chrome 45 throws on stringifying object symbols - if (!hasSymbols) { return true; } // Symbols are not supported - return JSON.stringify(Object(Symbol())) === '{}' && JSON.stringify([Object(Symbol())]) === '[{}]'; - }); - if (JSONstringifiesSymbols || !JSONstringifyAcceptsObjectSymbol) { - var origStringify = JSON.stringify; - overrideNative(JSON, 'stringify', function stringify(value) { - if (typeof value === 'symbol') { return; } - var replacer; - if (arguments.length > 1) { - replacer = arguments[1]; - } - var args = [value]; - if (!isArray(replacer)) { - var replaceFn = ES.IsCallable(replacer) ? replacer : null; - var wrappedReplacer = function (key, val) { - var parsedValue = replaceFn ? _call(replaceFn, this, key, val) : val; - if (typeof parsedValue !== 'symbol') { - if (Type.symbol(parsedValue)) { - return assignTo({})(parsedValue); - } else { - return parsedValue; - } - } - }; - args.push(wrappedReplacer); - } else { - // create wrapped replacer that handles an array replacer? - args.push(replacer); - } - if (arguments.length > 2) { - args.push(arguments[2]); - } - return origStringify.apply(this, args); - }); - } - - return globals; -})); -}(es6Shim)); +var es6Shim = es6Shim$1.exports; + +var hasRequiredEs6Shim; + +function requireEs6Shim () { + if (hasRequiredEs6Shim) return es6Shim$1.exports; + hasRequiredEs6Shim = 1; + (function (module, exports$1) { + // UMD (Universal Module Definition) + // see https://github.com/umdjs/umd/blob/master/returnExports.js + (function (root, factory) { + /*global define */ + { + // Node. Does not work with strict CommonJS, but + // only CommonJS-like environments that support module.exports, + // like Node. + module.exports = factory(); + } + }(es6Shim, function () { + + var _apply = Function.call.bind(Function.apply); + var _call = Function.call.bind(Function.call); + var isArray = Array.isArray; + var keys = Object.keys; + + var not = function notThunker(func) { + return function notThunk() { + return !_apply(func, this, arguments); + }; + }; + var throwsError = function (func) { + try { + func(); + return false; + } catch (e) { + return true; + } + }; + var valueOrFalseIfThrows = function valueOrFalseIfThrows(func) { + try { + return func(); + } catch (e) { + return false; + } + }; + + var isCallableWithoutNew = not(throwsError); + var arePropertyDescriptorsSupported = function () { + // if Object.defineProperty exists but throws, it's IE 8 + return !throwsError(function () { + return Object.defineProperty({}, 'x', { get: function () { } }); // eslint-disable-line getter-return + }); + }; + var supportsDescriptors = !!Object.defineProperty && arePropertyDescriptorsSupported(); + var functionsHaveNames = (function foo() {}).name === 'foo'; + + var _forEach = Function.call.bind(Array.prototype.forEach); + var _reduce = Function.call.bind(Array.prototype.reduce); + var _filter = Function.call.bind(Array.prototype.filter); + var _some = Function.call.bind(Array.prototype.some); + + var defineProperty = function (object, name, value, force) { + if (!force && name in object) { return; } + if (supportsDescriptors) { + Object.defineProperty(object, name, { + configurable: true, + enumerable: false, + writable: true, + value: value + }); + } else { + object[name] = value; + } + }; + + // Define configurable, writable and non-enumerable props + // if they don’t exist. + var defineProperties = function (object, map, forceOverride) { + _forEach(keys(map), function (name) { + var method = map[name]; + defineProperty(object, name, method, !!forceOverride); + }); + }; + + var _toString = Function.call.bind(Object.prototype.toString); + var isCallable = typeof /abc/ === 'function' ? function IsCallableSlow(x) { + // Some old browsers (IE, FF) say that typeof /abc/ === 'function' + return typeof x === 'function' && _toString(x) === '[object Function]'; + } : function IsCallableFast(x) { return typeof x === 'function'; }; + + var Value = { + getter: function (object, name, getter) { + if (!supportsDescriptors) { + throw new TypeError('getters require true ES5 support'); + } + Object.defineProperty(object, name, { + configurable: true, + enumerable: false, + get: getter + }); + }, + proxy: function (originalObject, key, targetObject) { + if (!supportsDescriptors) { + throw new TypeError('getters require true ES5 support'); + } + var originalDescriptor = Object.getOwnPropertyDescriptor(originalObject, key); + Object.defineProperty(targetObject, key, { + configurable: originalDescriptor.configurable, + enumerable: originalDescriptor.enumerable, + get: function getKey() { return originalObject[key]; }, + set: function setKey(value) { originalObject[key] = value; } + }); + }, + redefine: function (object, property, newValue) { + if (supportsDescriptors) { + var descriptor = Object.getOwnPropertyDescriptor(object, property); + descriptor.value = newValue; + Object.defineProperty(object, property, descriptor); + } else { + object[property] = newValue; + } + }, + defineByDescriptor: function (object, property, descriptor) { + if (supportsDescriptors) { + Object.defineProperty(object, property, descriptor); + } else if ('value' in descriptor) { + object[property] = descriptor.value; + } + }, + preserveToString: function (target, source) { + if (source && isCallable(source.toString)) { + defineProperty(target, 'toString', source.toString.bind(source), true); + } + } + }; + + // Simple shim for Object.create on ES3 browsers + // (unlike real shim, no attempt to support `prototype === null`) + var create = Object.create || function (prototype, properties) { + var Prototype = function Prototype() {}; + Prototype.prototype = prototype; + var object = new Prototype(); + if (typeof properties !== 'undefined') { + keys(properties).forEach(function (key) { + Value.defineByDescriptor(object, key, properties[key]); + }); + } + return object; + }; + + var supportsSubclassing = function (C, f) { + if (!Object.setPrototypeOf) { return false; /* skip test on IE < 11 */ } + return valueOrFalseIfThrows(function () { + var Sub = function Subclass(arg) { + var o = new C(arg); + Object.setPrototypeOf(o, Subclass.prototype); + return o; + }; + Object.setPrototypeOf(Sub, C); + Sub.prototype = create(C.prototype, { + constructor: { value: Sub } + }); + return f(Sub); + }); + }; + + var getGlobal = function () { + /* global self, window */ + // the only reliable means to get the global object is + // `Function('return this')()` + // However, this causes CSP violations in Chrome apps. + if (typeof self !== 'undefined') { return self; } + if (typeof window !== 'undefined') { return window; } + if (typeof commonjsGlobal !== 'undefined') { return commonjsGlobal; } + throw new Error('unable to locate global object'); + }; + + var globals = getGlobal(); + var globalIsFinite = globals.isFinite; + var _indexOf = Function.call.bind(String.prototype.indexOf); + var _arrayIndexOfApply = Function.apply.bind(Array.prototype.indexOf); + var _concat = Function.call.bind(Array.prototype.concat); + // var _sort = Function.call.bind(Array.prototype.sort); + var _strSlice = Function.call.bind(String.prototype.slice); + var _push = Function.call.bind(Array.prototype.push); + var _pushApply = Function.apply.bind(Array.prototype.push); + var _join = Function.call.bind(Array.prototype.join); + var _shift = Function.call.bind(Array.prototype.shift); + var _max = Math.max; + var _min = Math.min; + var _floor = Math.floor; + var _abs = Math.abs; + var _exp = Math.exp; + var _log = Math.log; + var _sqrt = Math.sqrt; + var _hasOwnProperty = Function.call.bind(Object.prototype.hasOwnProperty); + var ArrayIterator; // make our implementation private + var noop = function () {}; + + var OrigMap = globals.Map; + var origMapDelete = OrigMap && OrigMap.prototype['delete']; + var origMapGet = OrigMap && OrigMap.prototype.get; + var origMapHas = OrigMap && OrigMap.prototype.has; + var origMapSet = OrigMap && OrigMap.prototype.set; + + var Symbol = globals.Symbol || {}; + var symbolSpecies = Symbol.species || '@@species'; + + var numberIsNaN = Number.isNaN || function isNaN(value) { + // NaN !== NaN, but they are identical. + // NaNs are the only non-reflexive value, i.e., if x !== x, + // then x is NaN. + // isNaN is broken: it converts its argument to number, so + // isNaN('foo') => true + return value !== value; + }; + var numberIsFinite = Number.isFinite || function isFinite(value) { + return typeof value === 'number' && globalIsFinite(value); + }; + var _sign = isCallable(Math.sign) ? Math.sign : function sign(value) { + var number = Number(value); + if (number === 0) { return number; } + if (numberIsNaN(number)) { return number; } + return number < 0 ? -1 : 1; + }; + var _log1p = function log1p(value) { + var x = Number(value); + if (x < -1 || numberIsNaN(x)) { return NaN; } + if (x === 0 || x === Infinity) { return x; } + if (x === -1) { return -Infinity; } + + return (1 + x) - 1 === 0 ? x : x * (_log(1 + x) / ((1 + x) - 1)); + }; + + // taken directly from https://github.com/ljharb/is-arguments/blob/master/index.js + // can be replaced with require('is-arguments') if we ever use a build process instead + var isStandardArguments = function isArguments(value) { + return _toString(value) === '[object Arguments]'; + }; + var isLegacyArguments = function isArguments(value) { + return value !== null + && typeof value === 'object' + && typeof value.length === 'number' + && value.length >= 0 + && _toString(value) !== '[object Array]' + && _toString(value.callee) === '[object Function]'; + }; + var isArguments = isStandardArguments(arguments) ? isStandardArguments : isLegacyArguments; + + var Type = { + primitive: function (x) { return x === null || (typeof x !== 'function' && typeof x !== 'object'); }, + string: function (x) { return _toString(x) === '[object String]'; }, + regex: function (x) { return _toString(x) === '[object RegExp]'; }, + symbol: function (x) { + return typeof globals.Symbol === 'function' && typeof x === 'symbol'; + } + }; + + var overrideNative = function overrideNative(object, property, replacement) { + var original = object[property]; + defineProperty(object, property, replacement, true); + Value.preserveToString(object[property], original); + }; + + // eslint-disable-next-line no-restricted-properties + var hasSymbols = typeof Symbol === 'function' && typeof Symbol['for'] === 'function' && Type.symbol(Symbol()); + + // This is a private name in the es6 spec, equal to '[Symbol.iterator]' + // we're going to use an arbitrary _-prefixed name to make our shims + // work properly with each other, even though we don't have full Iterator + // support. That is, `Array.from(map.keys())` will work, but we don't + // pretend to export a "real" Iterator interface. + var $iterator$ = Type.symbol(Symbol.iterator) ? Symbol.iterator : '_es6-shim iterator_'; + // Firefox ships a partial implementation using the name @@iterator. + // https://bugzilla.mozilla.org/show_bug.cgi?id=907077#c14 + // So use that name if we detect it. + if (globals.Set && typeof new globals.Set()['@@iterator'] === 'function') { + $iterator$ = '@@iterator'; + } + + // Reflect + if (!globals.Reflect) { + defineProperty(globals, 'Reflect', {}, true); + } + var Reflect = globals.Reflect; + + var $String = String; + + /* global document */ + var domAll = (typeof document === 'undefined' || !document) ? null : document.all; + var isNullOrUndefined = domAll == null ? function isNullOrUndefined(x) { + return x == null; + } : function isNullOrUndefinedAndNotDocumentAll(x) { + return x == null && x !== domAll; + }; + + var ES = { + // http://www.ecma-international.org/ecma-262/6.0/#sec-call + Call: function Call(F, V) { + var args = arguments.length > 2 ? arguments[2] : []; + if (!ES.IsCallable(F)) { + throw new TypeError(F + ' is not a function'); + } + return _apply(F, V, args); + }, + + RequireObjectCoercible: function (x, optMessage) { + if (isNullOrUndefined(x)) { + throw new TypeError(optMessage || 'Cannot call method on ' + x); + } + return x; + }, + + // This might miss the "(non-standard exotic and does not implement + // [[Call]])" case from + // http://www.ecma-international.org/ecma-262/6.0/#sec-typeof-operator-runtime-semantics-evaluation + // but we can't find any evidence these objects exist in practice. + // If we find some in the future, you could test `Object(x) === x`, + // which is reliable according to + // http://www.ecma-international.org/ecma-262/6.0/#sec-toobject + // but is not well optimized by runtimes and creates an object + // whenever it returns false, and thus is very slow. + TypeIsObject: function (x) { + if (x === void 0 || x === null || x === true || x === false) { + return false; + } + return typeof x === 'function' || typeof x === 'object' || x === domAll; + }, + + ToObject: function (o, optMessage) { + return Object(ES.RequireObjectCoercible(o, optMessage)); + }, + + IsCallable: isCallable, + + IsConstructor: function (x) { + // We can't tell callables from constructors in ES5 + return ES.IsCallable(x); + }, + + ToInt32: function (x) { + return ES.ToNumber(x) >> 0; + }, + + ToUint32: function (x) { + return ES.ToNumber(x) >>> 0; + }, + + ToNumber: function (value) { + if (hasSymbols && _toString(value) === '[object Symbol]') { + throw new TypeError('Cannot convert a Symbol value to a number'); + } + return +value; + }, + + ToInteger: function (value) { + var number = ES.ToNumber(value); + if (numberIsNaN(number)) { return 0; } + if (number === 0 || !numberIsFinite(number)) { return number; } + return (number > 0 ? 1 : -1) * _floor(_abs(number)); + }, + + ToLength: function (value) { + var len = ES.ToInteger(value); + if (len <= 0) { return 0; } // includes converting -0 to +0 + if (len > Number.MAX_SAFE_INTEGER) { return Number.MAX_SAFE_INTEGER; } + return len; + }, + + SameValue: function (a, b) { + if (a === b) { + // 0 === -0, but they are not identical. + if (a === 0) { return 1 / a === 1 / b; } + return true; + } + return numberIsNaN(a) && numberIsNaN(b); + }, + + SameValueZero: function (a, b) { + // same as SameValue except for SameValueZero(+0, -0) == true + return (a === b) || (numberIsNaN(a) && numberIsNaN(b)); + }, + + GetIterator: function (o) { + if (isArguments(o)) { + // special case support for `arguments` + return new ArrayIterator(o, 'value'); + } + var itFn = ES.GetMethod(o, $iterator$); + if (!ES.IsCallable(itFn)) { + // Better diagnostics if itFn is null or undefined + throw new TypeError('value is not an iterable'); + } + var it = ES.Call(itFn, o); + if (!ES.TypeIsObject(it)) { + throw new TypeError('bad iterator'); + } + return it; + }, + + GetMethod: function (o, p) { + var func = ES.ToObject(o)[p]; + if (isNullOrUndefined(func)) { + return void 0; + } + if (!ES.IsCallable(func)) { + throw new TypeError('Method not callable: ' + p); + } + return func; + }, + + IteratorComplete: function (iterResult) { + return !!iterResult.done; + }, + + IteratorClose: function (iterator, completionIsThrow) { + var returnMethod = ES.GetMethod(iterator, 'return'); + if (returnMethod === void 0) { + return; + } + var innerResult, innerException; + try { + innerResult = ES.Call(returnMethod, iterator); + } catch (e) { + innerException = e; + } + if (completionIsThrow) { + return; + } + if (innerException) { + throw innerException; + } + if (!ES.TypeIsObject(innerResult)) { + throw new TypeError("Iterator's return method returned a non-object."); + } + }, + + IteratorNext: function (it) { + var result = arguments.length > 1 ? it.next(arguments[1]) : it.next(); + if (!ES.TypeIsObject(result)) { + throw new TypeError('bad iterator'); + } + return result; + }, + + IteratorStep: function (it) { + var result = ES.IteratorNext(it); + var done = ES.IteratorComplete(result); + return done ? false : result; + }, + + Construct: function (C, args, newTarget, isES6internal) { + var target = typeof newTarget === 'undefined' ? C : newTarget; + + if (!isES6internal && Reflect.construct) { + // Try to use Reflect.construct if available + return Reflect.construct(C, args, target); + } + // OK, we have to fake it. This will only work if the + // C.[[ConstructorKind]] == "base" -- but that's the only + // kind we can make in ES5 code anyway. + + // OrdinaryCreateFromConstructor(target, "%ObjectPrototype%") + var proto = target.prototype; + if (!ES.TypeIsObject(proto)) { + proto = Object.prototype; + } + var obj = create(proto); + // Call the constructor. + var result = ES.Call(C, obj, args); + return ES.TypeIsObject(result) ? result : obj; + }, + + SpeciesConstructor: function (O, defaultConstructor) { + var C = O.constructor; + if (C === void 0) { + return defaultConstructor; + } + if (!ES.TypeIsObject(C)) { + throw new TypeError('Bad constructor'); + } + var S = C[symbolSpecies]; + if (isNullOrUndefined(S)) { + return defaultConstructor; + } + if (!ES.IsConstructor(S)) { + throw new TypeError('Bad @@species'); + } + return S; + }, + + CreateHTML: function (string, tag, attribute, value) { + var S = ES.ToString(string); + var p1 = '<' + tag; + if (attribute !== '') { + var V = ES.ToString(value); + var escapedV = V.replace(/"/g, '"'); + p1 += ' ' + attribute + '="' + escapedV + '"'; + } + var p2 = p1 + '>'; + var p3 = p2 + S; + return p3 + ''; + }, + + IsRegExp: function IsRegExp(argument) { + if (!ES.TypeIsObject(argument)) { + return false; + } + var isRegExp = argument[Symbol.match]; + if (typeof isRegExp !== 'undefined') { + return !!isRegExp; + } + return Type.regex(argument); + }, + + ToString: function ToString(string) { + if (hasSymbols && _toString(string) === '[object Symbol]') { + throw new TypeError('Cannot convert a Symbol value to a number'); + } + return $String(string); + } + }; + + // Well-known Symbol shims + if (supportsDescriptors && hasSymbols) { + var defineWellKnownSymbol = function defineWellKnownSymbol(name) { + if (Type.symbol(Symbol[name])) { + return Symbol[name]; + } + // eslint-disable-next-line no-restricted-properties + var sym = Symbol['for']('Symbol.' + name); + Object.defineProperty(Symbol, name, { + configurable: false, + enumerable: false, + writable: false, + value: sym + }); + return sym; + }; + if (!Type.symbol(Symbol.search)) { + var symbolSearch = defineWellKnownSymbol('search'); + var originalSearch = String.prototype.search; + defineProperty(RegExp.prototype, symbolSearch, function search(string) { + return ES.Call(originalSearch, string, [this]); + }); + var searchShim = function search(regexp) { + var O = ES.RequireObjectCoercible(this); + if (!isNullOrUndefined(regexp)) { + var searcher = ES.GetMethod(regexp, symbolSearch); + if (typeof searcher !== 'undefined') { + return ES.Call(searcher, regexp, [O]); + } + } + return ES.Call(originalSearch, O, [ES.ToString(regexp)]); + }; + overrideNative(String.prototype, 'search', searchShim); + } + if (!Type.symbol(Symbol.replace)) { + var symbolReplace = defineWellKnownSymbol('replace'); + var originalReplace = String.prototype.replace; + defineProperty(RegExp.prototype, symbolReplace, function replace(string, replaceValue) { + return ES.Call(originalReplace, string, [this, replaceValue]); + }); + var replaceShim = function replace(searchValue, replaceValue) { + var O = ES.RequireObjectCoercible(this); + if (!isNullOrUndefined(searchValue)) { + var replacer = ES.GetMethod(searchValue, symbolReplace); + if (typeof replacer !== 'undefined') { + return ES.Call(replacer, searchValue, [O, replaceValue]); + } + } + return ES.Call(originalReplace, O, [ES.ToString(searchValue), replaceValue]); + }; + overrideNative(String.prototype, 'replace', replaceShim); + } + if (!Type.symbol(Symbol.split)) { + var symbolSplit = defineWellKnownSymbol('split'); + var originalSplit = String.prototype.split; + defineProperty(RegExp.prototype, symbolSplit, function split(string, limit) { + return ES.Call(originalSplit, string, [this, limit]); + }); + var splitShim = function split(separator, limit) { + var O = ES.RequireObjectCoercible(this); + if (!isNullOrUndefined(separator)) { + var splitter = ES.GetMethod(separator, symbolSplit); + if (typeof splitter !== 'undefined') { + return ES.Call(splitter, separator, [O, limit]); + } + } + return ES.Call(originalSplit, O, [ES.ToString(separator), limit]); + }; + overrideNative(String.prototype, 'split', splitShim); + } + var symbolMatchExists = Type.symbol(Symbol.match); + var stringMatchIgnoresSymbolMatch = symbolMatchExists && (function () { + // Firefox 41, through Nightly 45 has Symbol.match, but String#match ignores it. + // Firefox 40 and below have Symbol.match but String#match works fine. + var o = {}; + o[Symbol.match] = function () { return 42; }; + return 'a'.match(o) !== 42; + }()); + if (!symbolMatchExists || stringMatchIgnoresSymbolMatch) { + var symbolMatch = defineWellKnownSymbol('match'); + + var originalMatch = String.prototype.match; + defineProperty(RegExp.prototype, symbolMatch, function match(string) { + return ES.Call(originalMatch, string, [this]); + }); + + var matchShim = function match(regexp) { + var O = ES.RequireObjectCoercible(this); + if (!isNullOrUndefined(regexp)) { + var matcher = ES.GetMethod(regexp, symbolMatch); + if (typeof matcher !== 'undefined') { + return ES.Call(matcher, regexp, [O]); + } + } + return ES.Call(originalMatch, O, [ES.ToString(regexp)]); + }; + overrideNative(String.prototype, 'match', matchShim); + } + } + + var wrapConstructor = function wrapConstructor(original, replacement, keysToSkip) { + Value.preserveToString(replacement, original); + if (Object.setPrototypeOf) { + // sets up proper prototype chain where possible + Object.setPrototypeOf(original, replacement); + } + if (supportsDescriptors) { + _forEach(Object.getOwnPropertyNames(original), function (key) { + if (key in noop || keysToSkip[key]) { return; } + Value.proxy(original, key, replacement); + }); + } else { + _forEach(Object.keys(original), function (key) { + if (key in noop || keysToSkip[key]) { return; } + replacement[key] = original[key]; + }); + } + replacement.prototype = original.prototype; + Value.redefine(original.prototype, 'constructor', replacement); + }; + + var defaultSpeciesGetter = function () { return this; }; + var addDefaultSpecies = function (C) { + if (supportsDescriptors && !_hasOwnProperty(C, symbolSpecies)) { + Value.getter(C, symbolSpecies, defaultSpeciesGetter); + } + }; + + var addIterator = function (prototype, impl) { + var implementation = impl || function iterator() { return this; }; + defineProperty(prototype, $iterator$, implementation); + if (!prototype[$iterator$] && Type.symbol($iterator$)) { + // implementations are buggy when $iterator$ is a Symbol + prototype[$iterator$] = implementation; + } + }; + + var createDataProperty = function createDataProperty(object, name, value) { + if (supportsDescriptors) { + Object.defineProperty(object, name, { + configurable: true, + enumerable: true, + writable: true, + value: value + }); + } else { + object[name] = value; + } + }; + var createDataPropertyOrThrow = function createDataPropertyOrThrow(object, name, value) { + createDataProperty(object, name, value); + if (!ES.SameValue(object[name], value)) { + throw new TypeError('property is nonconfigurable'); + } + }; + + var emulateES6construct = function (o, defaultNewTarget, defaultProto, slots) { + // This is an es5 approximation to es6 construct semantics. in es6, + // 'new Foo' invokes Foo.[[Construct]] which (for almost all objects) + // just sets the internal variable NewTarget (in es6 syntax `new.target`) + // to Foo and then returns Foo(). + + // Many ES6 object then have constructors of the form: + // 1. If NewTarget is undefined, throw a TypeError exception + // 2. Let xxx by OrdinaryCreateFromConstructor(NewTarget, yyy, zzz) + + // So we're going to emulate those first two steps. + if (!ES.TypeIsObject(o)) { + throw new TypeError('Constructor requires `new`: ' + defaultNewTarget.name); + } + var proto = defaultNewTarget.prototype; + if (!ES.TypeIsObject(proto)) { + proto = defaultProto; + } + var obj = create(proto); + for (var name in slots) { + if (_hasOwnProperty(slots, name)) { + var value = slots[name]; + defineProperty(obj, name, value, true); + } + } + return obj; + }; + + // Firefox 31 reports this function's length as 0 + // https://bugzilla.mozilla.org/show_bug.cgi?id=1062484 + if (String.fromCodePoint && String.fromCodePoint.length !== 1) { + var originalFromCodePoint = String.fromCodePoint; + overrideNative(String, 'fromCodePoint', function fromCodePoint(codePoints) { + return ES.Call(originalFromCodePoint, this, arguments); + }); + } + + var StringShims = { + fromCodePoint: function fromCodePoint(codePoints) { + var result = []; + var next; + for (var i = 0, length = arguments.length; i < length; i++) { + next = Number(arguments[i]); + if (!ES.SameValue(next, ES.ToInteger(next)) || next < 0 || next > 0x10FFFF) { + throw new RangeError('Invalid code point ' + next); + } + + if (next < 0x10000) { + _push(result, String.fromCharCode(next)); + } else { + next -= 0x10000; + _push(result, String.fromCharCode((next >> 10) + 0xD800)); + _push(result, String.fromCharCode((next % 0x400) + 0xDC00)); + } + } + return _join(result, ''); + }, + + raw: function raw(template) { + var cooked = ES.ToObject(template, 'bad template'); + var raw = ES.ToObject(cooked.raw, 'bad raw value'); + var len = raw.length; + var literalSegments = ES.ToLength(len); + if (literalSegments <= 0) { + return ''; + } + + var stringElements = []; + var nextIndex = 0; + var nextKey, next, nextSeg, nextSub; + while (nextIndex < literalSegments) { + nextKey = ES.ToString(nextIndex); + nextSeg = ES.ToString(raw[nextKey]); + _push(stringElements, nextSeg); + if (nextIndex + 1 >= literalSegments) { + break; + } + next = nextIndex + 1 < arguments.length ? arguments[nextIndex + 1] : ''; + nextSub = ES.ToString(next); + _push(stringElements, nextSub); + nextIndex += 1; + } + return _join(stringElements, ''); + } + }; + if (String.raw && String.raw({ raw: { 0: 'x', 1: 'y', length: 2 } }) !== 'xy') { + // IE 11 TP has a broken String.raw implementation + overrideNative(String, 'raw', StringShims.raw); + } + defineProperties(String, StringShims); + + // Fast repeat, uses the `Exponentiation by squaring` algorithm. + // Perf: http://jsperf.com/string-repeat2/2 + var stringRepeat = function repeat(s, times) { + if (times < 1) { return ''; } + if (times % 2) { return repeat(s, times - 1) + s; } + var half = repeat(s, times / 2); + return half + half; + }; + var stringMaxLength = Infinity; + + var StringPrototypeShims = { + repeat: function repeat(times) { + var thisStr = ES.ToString(ES.RequireObjectCoercible(this)); + var numTimes = ES.ToInteger(times); + if (numTimes < 0 || numTimes >= stringMaxLength) { + throw new RangeError('repeat count must be less than infinity and not overflow maximum string size'); + } + return stringRepeat(thisStr, numTimes); + }, + + startsWith: function startsWith(searchString) { + var S = ES.ToString(ES.RequireObjectCoercible(this)); + if (ES.IsRegExp(searchString)) { + throw new TypeError('Cannot call method "startsWith" with a regex'); + } + var searchStr = ES.ToString(searchString); + var position; + if (arguments.length > 1) { + position = arguments[1]; + } + var start = _max(ES.ToInteger(position), 0); + return _strSlice(S, start, start + searchStr.length) === searchStr; + }, + + endsWith: function endsWith(searchString) { + var S = ES.ToString(ES.RequireObjectCoercible(this)); + if (ES.IsRegExp(searchString)) { + throw new TypeError('Cannot call method "endsWith" with a regex'); + } + var searchStr = ES.ToString(searchString); + var len = S.length; + var endPosition; + if (arguments.length > 1) { + endPosition = arguments[1]; + } + var pos = typeof endPosition === 'undefined' ? len : ES.ToInteger(endPosition); + var end = _min(_max(pos, 0), len); + return _strSlice(S, end - searchStr.length, end) === searchStr; + }, + + includes: function includes(searchString) { + if (ES.IsRegExp(searchString)) { + throw new TypeError('"includes" does not accept a RegExp'); + } + var searchStr = ES.ToString(searchString); + var position; + if (arguments.length > 1) { + position = arguments[1]; + } + // Somehow this trick makes method 100% compat with the spec. + return _indexOf(this, searchStr, position) !== -1; + }, + + codePointAt: function codePointAt(pos) { + var thisStr = ES.ToString(ES.RequireObjectCoercible(this)); + var position = ES.ToInteger(pos); + var length = thisStr.length; + if (position >= 0 && position < length) { + var first = thisStr.charCodeAt(position); + var isEnd = position + 1 === length; + if (first < 0xD800 || first > 0xDBFF || isEnd) { return first; } + var second = thisStr.charCodeAt(position + 1); + if (second < 0xDC00 || second > 0xDFFF) { return first; } + return ((first - 0xD800) * 1024) + (second - 0xDC00) + 0x10000; + } + } + }; + if (String.prototype.includes && 'a'.includes('a', Infinity) !== false) { + overrideNative(String.prototype, 'includes', StringPrototypeShims.includes); + } + + if (String.prototype.startsWith && String.prototype.endsWith) { + var startsWithRejectsRegex = throwsError(function () { + /* throws if spec-compliant */ + return '/a/'.startsWith(/a/); + }); + var startsWithHandlesInfinity = valueOrFalseIfThrows(function () { + return 'abc'.startsWith('a', Infinity) === false; + }); + if (!startsWithRejectsRegex || !startsWithHandlesInfinity) { + // Firefox (< 37?) and IE 11 TP have a noncompliant startsWith implementation + overrideNative(String.prototype, 'startsWith', StringPrototypeShims.startsWith); + overrideNative(String.prototype, 'endsWith', StringPrototypeShims.endsWith); + } + } + if (hasSymbols) { + var startsWithSupportsSymbolMatch = valueOrFalseIfThrows(function () { + var re = /a/; + re[Symbol.match] = false; + return '/a/'.startsWith(re); + }); + if (!startsWithSupportsSymbolMatch) { + overrideNative(String.prototype, 'startsWith', StringPrototypeShims.startsWith); + } + var endsWithSupportsSymbolMatch = valueOrFalseIfThrows(function () { + var re = /a/; + re[Symbol.match] = false; + return '/a/'.endsWith(re); + }); + if (!endsWithSupportsSymbolMatch) { + overrideNative(String.prototype, 'endsWith', StringPrototypeShims.endsWith); + } + var includesSupportsSymbolMatch = valueOrFalseIfThrows(function () { + var re = /a/; + re[Symbol.match] = false; + return '/a/'.includes(re); + }); + if (!includesSupportsSymbolMatch) { + overrideNative(String.prototype, 'includes', StringPrototypeShims.includes); + } + } + + defineProperties(String.prototype, StringPrototypeShims); + + // whitespace from: http://es5.github.io/#x15.5.4.20 + // implementation from https://github.com/es-shims/es5-shim/blob/v3.4.0/es5-shim.js#L1304-L1324 + var ws = [ + '\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003', + '\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028', + '\u2029\uFEFF' + ].join(''); + var trimRegexp = new RegExp('(^[' + ws + ']+)|([' + ws + ']+$)', 'g'); + var trimShim = function trim() { + return ES.ToString(ES.RequireObjectCoercible(this)).replace(trimRegexp, ''); + }; + var nonWS = ['\u0085', '\u200b', '\ufffe'].join(''); + var nonWSregex = new RegExp('[' + nonWS + ']', 'g'); + var isBadHexRegex = /^[-+]0x[0-9a-f]+$/i; + var hasStringTrimBug = nonWS.trim().length !== nonWS.length; + defineProperty(String.prototype, 'trim', trimShim, hasStringTrimBug); + + // Given an argument x, it will return an IteratorResult object, + // with value set to x and done to false. + // Given no arguments, it will return an iterator completion object. + var iteratorResult = function (x) { + return { value: x, done: arguments.length === 0 }; + }; + + // see http://www.ecma-international.org/ecma-262/6.0/#sec-string.prototype-@@iterator + var StringIterator = function (s) { + ES.RequireObjectCoercible(s); + defineProperty(this, '_s', ES.ToString(s)); + defineProperty(this, '_i', 0); + }; + StringIterator.prototype.next = function () { + var s = this._s; + var i = this._i; + if (typeof s === 'undefined' || i >= s.length) { + this._s = void 0; + return iteratorResult(); + } + var first = s.charCodeAt(i); + var second, len; + if (first < 0xD800 || first > 0xDBFF || (i + 1) === s.length) { + len = 1; + } else { + second = s.charCodeAt(i + 1); + len = (second < 0xDC00 || second > 0xDFFF) ? 1 : 2; + } + this._i = i + len; + return iteratorResult(s.substr(i, len)); + }; + addIterator(StringIterator.prototype); + addIterator(String.prototype, function () { + return new StringIterator(this); + }); + + var ArrayShims = { + from: function from(items) { + var C = this; + var mapFn; + if (arguments.length > 1) { + mapFn = arguments[1]; + } + var mapping, T; + if (typeof mapFn === 'undefined') { + mapping = false; + } else { + if (!ES.IsCallable(mapFn)) { + throw new TypeError('Array.from: when provided, the second argument must be a function'); + } + if (arguments.length > 2) { + T = arguments[2]; + } + mapping = true; + } + + // Note that that Arrays will use ArrayIterator: + // https://bugs.ecmascript.org/show_bug.cgi?id=2416 + var usingIterator = typeof (isArguments(items) || ES.GetMethod(items, $iterator$)) !== 'undefined'; + + var length, result, i; + if (usingIterator) { + result = ES.IsConstructor(C) ? Object(new C()) : []; + var iterator = ES.GetIterator(items); + var next, nextValue; + + i = 0; + while (true) { + next = ES.IteratorStep(iterator); + if (next === false) { + break; + } + nextValue = next.value; + try { + if (mapping) { + nextValue = typeof T === 'undefined' ? mapFn(nextValue, i) : _call(mapFn, T, nextValue, i); + } + result[i] = nextValue; + } catch (e) { + ES.IteratorClose(iterator, true); + throw e; + } + i += 1; + } + length = i; + } else { + var arrayLike = ES.ToObject(items); + length = ES.ToLength(arrayLike.length); + result = ES.IsConstructor(C) ? Object(new C(length)) : new Array(length); + var value; + for (i = 0; i < length; ++i) { + value = arrayLike[i]; + if (mapping) { + value = typeof T === 'undefined' ? mapFn(value, i) : _call(mapFn, T, value, i); + } + createDataPropertyOrThrow(result, i, value); + } + } + + result.length = length; + return result; + }, + + of: function of() { + var len = arguments.length; + var C = this; + var A = isArray(C) || !ES.IsCallable(C) ? new Array(len) : ES.Construct(C, [len]); + for (var k = 0; k < len; ++k) { + createDataPropertyOrThrow(A, k, arguments[k]); + } + A.length = len; + return A; + } + }; + defineProperties(Array, ArrayShims); + addDefaultSpecies(Array); + + // Our ArrayIterator is private; see + // https://github.com/paulmillr/es6-shim/issues/252 + ArrayIterator = function (array, kind) { + defineProperty(this, 'i', 0); + defineProperty(this, 'array', array); + defineProperty(this, 'kind', kind); + }; + + defineProperties(ArrayIterator.prototype, { + next: function () { + var i = this.i; + var array = this.array; + if (!(this instanceof ArrayIterator)) { + throw new TypeError('Not an ArrayIterator'); + } + if (typeof array !== 'undefined') { + var len = ES.ToLength(array.length); + if (i < len) { + //for (; i < len; i++) { + var kind = this.kind; + var retval; + if (kind === 'key') { + retval = i; + } else if (kind === 'value') { + retval = array[i]; + } else if (kind === 'entry') { + retval = [i, array[i]]; + } + this.i = i + 1; + return iteratorResult(retval); + } + } + this.array = void 0; + return iteratorResult(); + } + }); + addIterator(ArrayIterator.prototype); + + /* + var orderKeys = function orderKeys(a, b) { + var aNumeric = String(ES.ToInteger(a)) === a; + var bNumeric = String(ES.ToInteger(b)) === b; + if (aNumeric && bNumeric) { + return b - a; + } else if (aNumeric && !bNumeric) { + return -1; + } else if (!aNumeric && bNumeric) { + return 1; + } else { + return a.localeCompare(b); + } + }; + + var getAllKeys = function getAllKeys(object) { + var ownKeys = []; + var keys = []; + + for (var key in object) { + _push(_hasOwnProperty(object, key) ? ownKeys : keys, key); + } + _sort(ownKeys, orderKeys); + _sort(keys, orderKeys); + + return _concat(ownKeys, keys); + }; + */ + + // note: this is positioned here because it depends on ArrayIterator + var arrayOfSupportsSubclassing = Array.of === ArrayShims.of || (function () { + // Detects a bug in Webkit nightly r181886 + var Foo = function Foo(len) { this.length = len; }; + Foo.prototype = []; + var fooArr = Array.of.apply(Foo, [1, 2]); + return fooArr instanceof Foo && fooArr.length === 2; + }()); + if (!arrayOfSupportsSubclassing) { + overrideNative(Array, 'of', ArrayShims.of); + } + + var ArrayPrototypeShims = { + copyWithin: function copyWithin(target, start) { + var o = ES.ToObject(this); + var len = ES.ToLength(o.length); + var relativeTarget = ES.ToInteger(target); + var relativeStart = ES.ToInteger(start); + var to = relativeTarget < 0 ? _max(len + relativeTarget, 0) : _min(relativeTarget, len); + var from = relativeStart < 0 ? _max(len + relativeStart, 0) : _min(relativeStart, len); + var end; + if (arguments.length > 2) { + end = arguments[2]; + } + var relativeEnd = typeof end === 'undefined' ? len : ES.ToInteger(end); + var finalItem = relativeEnd < 0 ? _max(len + relativeEnd, 0) : _min(relativeEnd, len); + var count = _min(finalItem - from, len - to); + var direction = 1; + if (from < to && to < (from + count)) { + direction = -1; + from += count - 1; + to += count - 1; + } + while (count > 0) { + if (from in o) { + o[to] = o[from]; + } else { + delete o[to]; + } + from += direction; + to += direction; + count -= 1; + } + return o; + }, + + fill: function fill(value) { + var start; + if (arguments.length > 1) { + start = arguments[1]; + } + var end; + if (arguments.length > 2) { + end = arguments[2]; + } + var O = ES.ToObject(this); + var len = ES.ToLength(O.length); + start = ES.ToInteger(typeof start === 'undefined' ? 0 : start); + end = ES.ToInteger(typeof end === 'undefined' ? len : end); + + var relativeStart = start < 0 ? _max(len + start, 0) : _min(start, len); + var relativeEnd = end < 0 ? len + end : end; + + for (var i = relativeStart; i < len && i < relativeEnd; ++i) { + O[i] = value; + } + return O; + }, + + find: function find(predicate) { + var list = ES.ToObject(this); + var length = ES.ToLength(list.length); + if (!ES.IsCallable(predicate)) { + throw new TypeError('Array#find: predicate must be a function'); + } + var thisArg = arguments.length > 1 ? arguments[1] : null; + for (var i = 0, value; i < length; i++) { + value = list[i]; + if (thisArg) { + if (_call(predicate, thisArg, value, i, list)) { + return value; + } + } else if (predicate(value, i, list)) { + return value; + } + } + }, + + findIndex: function findIndex(predicate) { + var list = ES.ToObject(this); + var length = ES.ToLength(list.length); + if (!ES.IsCallable(predicate)) { + throw new TypeError('Array#findIndex: predicate must be a function'); + } + var thisArg = arguments.length > 1 ? arguments[1] : null; + for (var i = 0; i < length; i++) { + if (thisArg) { + if (_call(predicate, thisArg, list[i], i, list)) { + return i; + } + } else if (predicate(list[i], i, list)) { + return i; + } + } + return -1; + }, + + keys: function keys() { + return new ArrayIterator(this, 'key'); + }, + + values: function values() { + return new ArrayIterator(this, 'value'); + }, + + entries: function entries() { + return new ArrayIterator(this, 'entry'); + } + }; + // Safari 7.1 defines Array#keys and Array#entries natively, + // but the resulting ArrayIterator objects don't have a "next" method. + if (Array.prototype.keys && !ES.IsCallable([1].keys().next)) { + delete Array.prototype.keys; + } + if (Array.prototype.entries && !ES.IsCallable([1].entries().next)) { + delete Array.prototype.entries; + } + + // Chrome 38 defines Array#keys and Array#entries, and Array#@@iterator, but not Array#values + if (Array.prototype.keys && Array.prototype.entries && !Array.prototype.values && Array.prototype[$iterator$]) { + defineProperties(Array.prototype, { + values: Array.prototype[$iterator$] + }); + if (Type.symbol(Symbol.unscopables)) { + Array.prototype[Symbol.unscopables].values = true; + } + } + // Chrome 40 defines Array#values with the incorrect name, although Array#{keys,entries} have the correct name + if (functionsHaveNames && Array.prototype.values && Array.prototype.values.name !== 'values') { + var originalArrayPrototypeValues = Array.prototype.values; + overrideNative(Array.prototype, 'values', function values() { return ES.Call(originalArrayPrototypeValues, this, arguments); }); + defineProperty(Array.prototype, $iterator$, Array.prototype.values, true); + } + defineProperties(Array.prototype, ArrayPrototypeShims); + + if (1 / [true].indexOf(true, -0) < 0) { + // indexOf when given a position arg of -0 should return +0. + // https://github.com/tc39/ecma262/pull/316 + defineProperty(Array.prototype, 'indexOf', function indexOf(searchElement) { + var value = _arrayIndexOfApply(this, arguments); + if (value === 0 && (1 / value) < 0) { + return 0; + } + return value; + }, true); + } + + addIterator(Array.prototype, function () { return this.values(); }); + // Chrome defines keys/values/entries on Array, but doesn't give us + // any way to identify its iterator. So add our own shimmed field. + if (Object.getPrototypeOf) { + var ChromeArrayIterator = Object.getPrototypeOf([].values()); + if (ChromeArrayIterator) { // in WSH, this is `undefined` + addIterator(ChromeArrayIterator); + } + } + + // note: this is positioned here because it relies on Array#entries + var arrayFromSwallowsNegativeLengths = (function () { + // Detects a Firefox bug in v32 + // https://bugzilla.mozilla.org/show_bug.cgi?id=1063993 + return valueOrFalseIfThrows(function () { + return Array.from({ length: -1 }).length === 0; + }); + }()); + var arrayFromHandlesIterables = (function () { + // Detects a bug in Webkit nightly r181886 + var arr = Array.from([0].entries()); + return arr.length === 1 && isArray(arr[0]) && arr[0][0] === 0 && arr[0][1] === 0; + }()); + if (!arrayFromSwallowsNegativeLengths || !arrayFromHandlesIterables) { + overrideNative(Array, 'from', ArrayShims.from); + } + var arrayFromHandlesUndefinedMapFunction = (function () { + // Microsoft Edge v0.11 throws if the mapFn argument is *provided* but undefined, + // but the spec doesn't care if it's provided or not - undefined doesn't throw. + return valueOrFalseIfThrows(function () { + return Array.from([0], void 0); + }); + }()); + if (!arrayFromHandlesUndefinedMapFunction) { + var origArrayFrom = Array.from; + overrideNative(Array, 'from', function from(items) { + if (arguments.length > 1 && typeof arguments[1] !== 'undefined') { + return ES.Call(origArrayFrom, this, arguments); + } + return _call(origArrayFrom, this, items); + + }); + } + + var int32sAsOne = -(Math.pow(2, 32) - 1); + var toLengthsCorrectly = function (method, reversed) { + var obj = { length: int32sAsOne }; + obj[reversed ? (obj.length >>> 0) - 1 : 0] = true; + return valueOrFalseIfThrows(function () { + _call(method, obj, function () { + // note: in nonconforming browsers, this will be called + // -1 >>> 0 times, which is 4294967295, so the throw matters. + throw new RangeError('should not reach here'); + }, []); + return true; + }); + }; + if (!toLengthsCorrectly(Array.prototype.forEach)) { + var originalForEach = Array.prototype.forEach; + overrideNative(Array.prototype, 'forEach', function forEach(callbackFn) { + return ES.Call(originalForEach, this.length >= 0 ? this : [], arguments); + }); + } + if (!toLengthsCorrectly(Array.prototype.map)) { + var originalMap = Array.prototype.map; + overrideNative(Array.prototype, 'map', function map(callbackFn) { + return ES.Call(originalMap, this.length >= 0 ? this : [], arguments); + }); + } + if (!toLengthsCorrectly(Array.prototype.filter)) { + var originalFilter = Array.prototype.filter; + overrideNative(Array.prototype, 'filter', function filter(callbackFn) { + return ES.Call(originalFilter, this.length >= 0 ? this : [], arguments); + }); + } + if (!toLengthsCorrectly(Array.prototype.some)) { + var originalSome = Array.prototype.some; + overrideNative(Array.prototype, 'some', function some(callbackFn) { + return ES.Call(originalSome, this.length >= 0 ? this : [], arguments); + }); + } + if (!toLengthsCorrectly(Array.prototype.every)) { + var originalEvery = Array.prototype.every; + overrideNative(Array.prototype, 'every', function every(callbackFn) { + return ES.Call(originalEvery, this.length >= 0 ? this : [], arguments); + }); + } + if (!toLengthsCorrectly(Array.prototype.reduce)) { + var originalReduce = Array.prototype.reduce; + overrideNative(Array.prototype, 'reduce', function reduce(callbackFn) { + return ES.Call(originalReduce, this.length >= 0 ? this : [], arguments); + }); + } + if (!toLengthsCorrectly(Array.prototype.reduceRight, true)) { + var originalReduceRight = Array.prototype.reduceRight; + overrideNative(Array.prototype, 'reduceRight', function reduceRight(callbackFn) { + return ES.Call(originalReduceRight, this.length >= 0 ? this : [], arguments); + }); + } + + var lacksOctalSupport = Number('0o10') !== 8; + var lacksBinarySupport = Number('0b10') !== 2; + var trimsNonWhitespace = _some(nonWS, function (c) { + return Number(c + 0 + c) === 0; + }); + if (lacksOctalSupport || lacksBinarySupport || trimsNonWhitespace) { + var OrigNumber = Number; + var binaryRegex = /^0b[01]+$/i; + var octalRegex = /^0o[0-7]+$/i; + // Note that in IE 8, RegExp.prototype.test doesn't seem to exist: ie, "test" is an own property of regexes. wtf. + var isBinary = binaryRegex.test.bind(binaryRegex); + var isOctal = octalRegex.test.bind(octalRegex); + var toPrimitive = function (O, hint) { // need to replace this with `es-to-primitive/es6` + var result; + if (typeof O.valueOf === 'function') { + result = O.valueOf(); + if (Type.primitive(result)) { + return result; + } + } + if (typeof O.toString === 'function') { + result = O.toString(); + if (Type.primitive(result)) { + return result; + } + } + throw new TypeError('No default value'); + }; + var hasNonWS = nonWSregex.test.bind(nonWSregex); + var isBadHex = isBadHexRegex.test.bind(isBadHexRegex); + var NumberShim = (function () { + // this is wrapped in an IIFE because of IE 6-8's wacky scoping issues with named function expressions. + var NumberShim = function Number(value) { + var primValue; + if (arguments.length > 0) { + primValue = Type.primitive(value) ? value : toPrimitive(value, 'number'); + } else { + primValue = 0; + } + if (typeof primValue === 'string') { + primValue = ES.Call(trimShim, primValue); + if (isBinary(primValue)) { + primValue = parseInt(_strSlice(primValue, 2), 2); + } else if (isOctal(primValue)) { + primValue = parseInt(_strSlice(primValue, 2), 8); + } else if (hasNonWS(primValue) || isBadHex(primValue)) { + primValue = NaN; + } + } + var receiver = this; + var valueOfSucceeds = valueOrFalseIfThrows(function () { + OrigNumber.prototype.valueOf.call(receiver); + return true; + }); + if (receiver instanceof NumberShim && !valueOfSucceeds) { + return new OrigNumber(primValue); + } + return OrigNumber(primValue); + }; + return NumberShim; + }()); + wrapConstructor(OrigNumber, NumberShim, {}); + // this is necessary for ES3 browsers, where these properties are non-enumerable. + defineProperties(NumberShim, { + NaN: OrigNumber.NaN, + MAX_VALUE: OrigNumber.MAX_VALUE, + MIN_VALUE: OrigNumber.MIN_VALUE, + NEGATIVE_INFINITY: OrigNumber.NEGATIVE_INFINITY, + POSITIVE_INFINITY: OrigNumber.POSITIVE_INFINITY + }); + Number = NumberShim; // eslint-disable-line no-global-assign + Value.redefine(globals, 'Number', NumberShim); + } + + var maxSafeInteger = Math.pow(2, 53) - 1; + defineProperties(Number, { + MAX_SAFE_INTEGER: maxSafeInteger, + MIN_SAFE_INTEGER: -maxSafeInteger, + EPSILON: 2.220446049250313e-16, + + parseInt: globals.parseInt, + parseFloat: globals.parseFloat, + + isFinite: numberIsFinite, + + isInteger: function isInteger(value) { + return numberIsFinite(value) && ES.ToInteger(value) === value; + }, + + isSafeInteger: function isSafeInteger(value) { + return Number.isInteger(value) && _abs(value) <= Number.MAX_SAFE_INTEGER; + }, + + isNaN: numberIsNaN + }); + // Firefox 37 has a conforming Number.parseInt, but it's not === to the global parseInt (fixed in v40) + defineProperty(Number, 'parseInt', globals.parseInt, Number.parseInt !== globals.parseInt); + + // Work around bugs in Array#find and Array#findIndex -- early + // implementations skipped holes in sparse arrays. (Note that the + // implementations of find/findIndex indirectly use shimmed + // methods of Number, so this test has to happen down here.) + /* eslint-disable no-sparse-arrays */ + if ([, 1].find(function () { return true; }) === 1) { + overrideNative(Array.prototype, 'find', ArrayPrototypeShims.find); + } + if ([, 1].findIndex(function () { return true; }) !== 0) { + overrideNative(Array.prototype, 'findIndex', ArrayPrototypeShims.findIndex); + } + /* eslint-enable no-sparse-arrays */ + + var isEnumerableOn = Function.bind.call(Function.bind, Object.prototype.propertyIsEnumerable); + var ensureEnumerable = function ensureEnumerable(obj, prop) { + if (supportsDescriptors && isEnumerableOn(obj, prop)) { + Object.defineProperty(obj, prop, { enumerable: false }); + } + }; + var sliceArgs = function sliceArgs() { + // per https://github.com/petkaantonov/bluebird/wiki/Optimization-killers#32-leaking-arguments + // and https://gist.github.com/WebReflection/4327762cb87a8c634a29 + var initial = Number(this); + var len = arguments.length; + var desiredArgCount = len - initial; + var args = new Array(desiredArgCount < 0 ? 0 : desiredArgCount); + for (var i = initial; i < len; ++i) { + args[i - initial] = arguments[i]; + } + return args; + }; + var assignTo = function assignTo(source) { + return function assignToSource(target, key) { + target[key] = source[key]; + return target; + }; + }; + var assignReducer = function (target, source) { + var sourceKeys = keys(Object(source)); + var symbols; + if (ES.IsCallable(Object.getOwnPropertySymbols)) { + symbols = _filter(Object.getOwnPropertySymbols(Object(source)), isEnumerableOn(source)); + } + return _reduce(_concat(sourceKeys, symbols || []), assignTo(source), target); + }; + + var ObjectShims = { + // 19.1.3.1 + assign: function (target, source) { + var to = ES.ToObject(target, 'Cannot convert undefined or null to object'); + return _reduce(ES.Call(sliceArgs, 1, arguments), assignReducer, to); + }, + + // Added in WebKit in https://bugs.webkit.org/show_bug.cgi?id=143865 + is: function is(a, b) { + return ES.SameValue(a, b); + } + }; + var assignHasPendingExceptions = Object.assign && Object.preventExtensions && (function () { + // Firefox 37 still has "pending exception" logic in its Object.assign implementation, + // which is 72% slower than our shim, and Firefox 40's native implementation. + var thrower = Object.preventExtensions({ 1: 2 }); + try { + Object.assign(thrower, 'xy'); + } catch (e) { + return thrower[1] === 'y'; + } + }()); + if (assignHasPendingExceptions) { + overrideNative(Object, 'assign', ObjectShims.assign); + } + defineProperties(Object, ObjectShims); + + if (supportsDescriptors) { + var ES5ObjectShims = { + // 19.1.3.9 + // shim from https://gist.github.com/WebReflection/5593554 + setPrototypeOf: (function (Object) { + var set; + + var checkArgs = function (O, proto) { + if (!ES.TypeIsObject(O)) { + throw new TypeError('cannot set prototype on a non-object'); + } + if (!(proto === null || ES.TypeIsObject(proto))) { + throw new TypeError('can only set prototype to an object or null' + proto); + } + }; + + var setPrototypeOf = function (O, proto) { + checkArgs(O, proto); + _call(set, O, proto); + return O; + }; + + try { + // this works already in Firefox and Safari + set = Object.getOwnPropertyDescriptor(Object.prototype, '__proto__').set; + _call(set, {}, null); + } catch (e) { + if (Object.prototype !== ({}).__proto__) { // eslint-disable-line no-proto + // IE < 11 cannot be shimmed + return; + } + // probably Chrome or some old Mobile stock browser + set = function (proto) { + this.__proto__ = proto; // eslint-disable-line no-proto + }; + // please note that this will **not** work + // in those browsers that do not inherit + // __proto__ by mistake from Object.prototype + // in these cases we should probably throw an error + // or at least be informed about the issue + setPrototypeOf.polyfill = setPrototypeOf( + setPrototypeOf({}, null), + Object.prototype + ) instanceof Object; + // setPrototypeOf.polyfill === true means it works as meant + // setPrototypeOf.polyfill === false means it's not 100% reliable + // setPrototypeOf.polyfill === undefined + // or + // setPrototypeOf.polyfill == null means it's not a polyfill + // which means it works as expected + // we can even delete Object.prototype.__proto__; + } + return setPrototypeOf; + }(Object)) + }; + + defineProperties(Object, ES5ObjectShims); + } + + // Workaround bug in Opera 12 where setPrototypeOf(x, null) doesn't work, + // but Object.create(null) does. + if ( + Object.setPrototypeOf + && Object.getPrototypeOf + && Object.getPrototypeOf(Object.setPrototypeOf({}, null)) !== null + && Object.getPrototypeOf(Object.create(null)) === null + ) { + (function () { + var FAKENULL = Object.create(null); + var gpo = Object.getPrototypeOf; + var spo = Object.setPrototypeOf; + Object.getPrototypeOf = function (o) { + var result = gpo(o); + return result === FAKENULL ? null : result; + }; + Object.setPrototypeOf = function (o, p) { + var proto = p === null ? FAKENULL : p; + return spo(o, proto); + }; + Object.setPrototypeOf.polyfill = false; + }()); + } + + var objectKeysAcceptsPrimitives = !throwsError(function () { return Object.keys('foo'); }); + if (!objectKeysAcceptsPrimitives) { + var originalObjectKeys = Object.keys; + overrideNative(Object, 'keys', function keys(value) { + return originalObjectKeys(ES.ToObject(value)); + }); + keys = Object.keys; + } + var objectKeysRejectsRegex = throwsError(function () { return Object.keys(/a/g); }); + if (objectKeysRejectsRegex) { + var regexRejectingObjectKeys = Object.keys; + overrideNative(Object, 'keys', function keys(value) { + if (Type.regex(value)) { + var regexKeys = []; + for (var k in value) { + if (_hasOwnProperty(value, k)) { + _push(regexKeys, k); + } + } + return regexKeys; + } + return regexRejectingObjectKeys(value); + }); + keys = Object.keys; + } + + if (Object.getOwnPropertyNames) { + var objectGOPNAcceptsPrimitives = !throwsError(function () { return Object.getOwnPropertyNames('foo'); }); + if (!objectGOPNAcceptsPrimitives) { + var cachedWindowNames = typeof window === 'object' ? Object.getOwnPropertyNames(window) : []; + var originalObjectGetOwnPropertyNames = Object.getOwnPropertyNames; + overrideNative(Object, 'getOwnPropertyNames', function getOwnPropertyNames(value) { + var val = ES.ToObject(value); + if (_toString(val) === '[object Window]') { + try { + return originalObjectGetOwnPropertyNames(val); + } catch (e) { + // IE bug where layout engine calls userland gOPN for cross-domain `window` objects + return _concat([], cachedWindowNames); + } + } + return originalObjectGetOwnPropertyNames(val); + }); + } + } + if (Object.getOwnPropertyDescriptor) { + var objectGOPDAcceptsPrimitives = !throwsError(function () { return Object.getOwnPropertyDescriptor('foo', 'bar'); }); + if (!objectGOPDAcceptsPrimitives) { + var originalObjectGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; + overrideNative(Object, 'getOwnPropertyDescriptor', function getOwnPropertyDescriptor(value, property) { + return originalObjectGetOwnPropertyDescriptor(ES.ToObject(value), property); + }); + } + } + if (Object.seal) { + var objectSealAcceptsPrimitives = !throwsError(function () { return Object.seal('foo'); }); + if (!objectSealAcceptsPrimitives) { + var originalObjectSeal = Object.seal; + overrideNative(Object, 'seal', function seal(value) { + if (!ES.TypeIsObject(value)) { return value; } + return originalObjectSeal(value); + }); + } + } + if (Object.isSealed) { + var objectIsSealedAcceptsPrimitives = !throwsError(function () { return Object.isSealed('foo'); }); + if (!objectIsSealedAcceptsPrimitives) { + var originalObjectIsSealed = Object.isSealed; + overrideNative(Object, 'isSealed', function isSealed(value) { + if (!ES.TypeIsObject(value)) { return true; } + return originalObjectIsSealed(value); + }); + } + } + if (Object.freeze) { + var objectFreezeAcceptsPrimitives = !throwsError(function () { return Object.freeze('foo'); }); + if (!objectFreezeAcceptsPrimitives) { + var originalObjectFreeze = Object.freeze; + overrideNative(Object, 'freeze', function freeze(value) { + if (!ES.TypeIsObject(value)) { return value; } + return originalObjectFreeze(value); + }); + } + } + if (Object.isFrozen) { + var objectIsFrozenAcceptsPrimitives = !throwsError(function () { return Object.isFrozen('foo'); }); + if (!objectIsFrozenAcceptsPrimitives) { + var originalObjectIsFrozen = Object.isFrozen; + overrideNative(Object, 'isFrozen', function isFrozen(value) { + if (!ES.TypeIsObject(value)) { return true; } + return originalObjectIsFrozen(value); + }); + } + } + if (Object.preventExtensions) { + var objectPreventExtensionsAcceptsPrimitives = !throwsError(function () { return Object.preventExtensions('foo'); }); + if (!objectPreventExtensionsAcceptsPrimitives) { + var originalObjectPreventExtensions = Object.preventExtensions; + overrideNative(Object, 'preventExtensions', function preventExtensions(value) { + if (!ES.TypeIsObject(value)) { return value; } + return originalObjectPreventExtensions(value); + }); + } + } + if (Object.isExtensible) { + var objectIsExtensibleAcceptsPrimitives = !throwsError(function () { return Object.isExtensible('foo'); }); + if (!objectIsExtensibleAcceptsPrimitives) { + var originalObjectIsExtensible = Object.isExtensible; + overrideNative(Object, 'isExtensible', function isExtensible(value) { + if (!ES.TypeIsObject(value)) { return false; } + return originalObjectIsExtensible(value); + }); + } + } + if (Object.getPrototypeOf) { + var objectGetProtoAcceptsPrimitives = !throwsError(function () { return Object.getPrototypeOf('foo'); }); + if (!objectGetProtoAcceptsPrimitives) { + var originalGetProto = Object.getPrototypeOf; + overrideNative(Object, 'getPrototypeOf', function getPrototypeOf(value) { + return originalGetProto(ES.ToObject(value)); + }); + } + } + + var hasFlags = supportsDescriptors && (function () { + var desc = Object.getOwnPropertyDescriptor(RegExp.prototype, 'flags'); + return desc && ES.IsCallable(desc.get); + }()); + if (supportsDescriptors && !hasFlags) { + var regExpFlagsGetter = function flags() { + if (!ES.TypeIsObject(this)) { + throw new TypeError('Method called on incompatible type: must be an object.'); + } + var result = ''; + if (this.global) { + result += 'g'; + } + if (this.ignoreCase) { + result += 'i'; + } + if (this.multiline) { + result += 'm'; + } + if (this.unicode) { + result += 'u'; + } + if (this.sticky) { + result += 'y'; + } + return result; + }; + + Value.getter(RegExp.prototype, 'flags', regExpFlagsGetter); + } + + var regExpSupportsFlagsWithRegex = supportsDescriptors && valueOrFalseIfThrows(function () { + return String(new RegExp(/a/g, 'i')) === '/a/i'; + }); + var regExpNeedsToSupportSymbolMatch = hasSymbols && supportsDescriptors && (function () { + // Edge 0.12 supports flags fully, but does not support Symbol.match + var regex = /./; + regex[Symbol.match] = false; + return RegExp(regex) === regex; + }()); + + var regexToStringIsGeneric = valueOrFalseIfThrows(function () { + return RegExp.prototype.toString.call({ source: 'abc' }) === '/abc/'; + }); + var regexToStringSupportsGenericFlags = regexToStringIsGeneric && valueOrFalseIfThrows(function () { + return RegExp.prototype.toString.call({ source: 'a', flags: 'b' }) === '/a/b'; + }); + if (!regexToStringIsGeneric || !regexToStringSupportsGenericFlags) { + var origRegExpToString = RegExp.prototype.toString; + defineProperty(RegExp.prototype, 'toString', function toString() { + var R = ES.RequireObjectCoercible(this); + if (Type.regex(R)) { + return _call(origRegExpToString, R); + } + var pattern = $String(R.source); + var flags = $String(R.flags); + return '/' + pattern + '/' + flags; + }, true); + Value.preserveToString(RegExp.prototype.toString, origRegExpToString); + RegExp.prototype.toString.prototype = void 0; + } + + if (supportsDescriptors && (!regExpSupportsFlagsWithRegex || regExpNeedsToSupportSymbolMatch)) { + var flagsGetter = Object.getOwnPropertyDescriptor(RegExp.prototype, 'flags').get; + var sourceDesc = Object.getOwnPropertyDescriptor(RegExp.prototype, 'source') || {}; + var legacySourceGetter = function () { + // prior to it being a getter, it's own + nonconfigurable + return this.source; + }; + var sourceGetter = ES.IsCallable(sourceDesc.get) ? sourceDesc.get : legacySourceGetter; + + var OrigRegExp = RegExp; + var RegExpShim = (function () { + return function RegExp(pattern, flags) { + var patternIsRegExp = ES.IsRegExp(pattern); + var calledWithNew = this instanceof RegExp; + if (!calledWithNew && patternIsRegExp && typeof flags === 'undefined' && pattern.constructor === RegExp) { + return pattern; + } + + var P = pattern; + var F = flags; + if (Type.regex(pattern)) { + P = ES.Call(sourceGetter, pattern); + F = typeof flags === 'undefined' ? ES.Call(flagsGetter, pattern) : flags; + return new RegExp(P, F); + } else if (patternIsRegExp) { + P = pattern.source; + F = typeof flags === 'undefined' ? pattern.flags : flags; + } + return new OrigRegExp(pattern, flags); + }; + }()); + wrapConstructor(OrigRegExp, RegExpShim, { + $input: true // Chrome < v39 & Opera < 26 have a nonstandard "$input" property + }); + RegExp = RegExpShim; // eslint-disable-line no-global-assign + Value.redefine(globals, 'RegExp', RegExpShim); + } + + if (supportsDescriptors) { + var regexGlobals = { + input: '$_', + lastMatch: '$&', + lastParen: '$+', + leftContext: '$`', + rightContext: '$\'' + }; + _forEach(keys(regexGlobals), function (prop) { + if (prop in RegExp && !(regexGlobals[prop] in RegExp)) { + Value.getter(RegExp, regexGlobals[prop], function get() { + return RegExp[prop]; + }); + } + }); + } + addDefaultSpecies(RegExp); + + var inverseEpsilon = 1 / Number.EPSILON; + var roundTiesToEven = function roundTiesToEven(n) { + // Even though this reduces down to `return n`, it takes advantage of built-in rounding. + return (n + inverseEpsilon) - inverseEpsilon; + }; + var BINARY_32_EPSILON = Math.pow(2, -23); + var BINARY_32_MAX_VALUE = Math.pow(2, 127) * (2 - BINARY_32_EPSILON); + var BINARY_32_MIN_VALUE = Math.pow(2, -126); + var E = Math.E; + var LOG2E = Math.LOG2E; + var LOG10E = Math.LOG10E; + var numberCLZ = Number.prototype.clz; + delete Number.prototype.clz; // Safari 8 has Number#clz + + var MathShims = { + acosh: function acosh(value) { + var x = Number(value); + if (numberIsNaN(x) || value < 1) { return NaN; } + if (x === 1) { return 0; } + if (x === Infinity) { return x; } + + var xInvSquared = 1 / (x * x); + if (x < 2) { + return _log1p(x - 1 + (_sqrt(1 - xInvSquared) * x)); + } + var halfX = x / 2; + return _log1p(halfX + (_sqrt(1 - xInvSquared) * halfX) - 1) + (1 / LOG2E); + }, + + asinh: function asinh(value) { + var x = Number(value); + if (x === 0 || !globalIsFinite(x)) { + return x; + } + + var a = _abs(x); + var aSquared = a * a; + var s = _sign(x); + if (a < 1) { + return s * _log1p(a + (aSquared / (_sqrt(aSquared + 1) + 1))); + } + return s * (_log1p((a / 2) + (_sqrt(1 + (1 / aSquared)) * a / 2) - 1) + (1 / LOG2E)); + }, + + atanh: function atanh(value) { + var x = Number(value); + + if (x === 0) { return x; } + if (x === -1) { return -Infinity; } + if (x === 1) { return Infinity; } + if (numberIsNaN(x) || x < -1 || x > 1) { + return NaN; + } + + var a = _abs(x); + return _sign(x) * _log1p(2 * a / (1 - a)) / 2; + }, + + cbrt: function cbrt(value) { + var x = Number(value); + if (x === 0) { return x; } + var negate = x < 0; + var result; + if (negate) { x = -x; } + if (x === Infinity) { + result = Infinity; + } else { + result = _exp(_log(x) / 3); + // from http://en.wikipedia.org/wiki/Cube_root#Numerical_methods + result = ((x / (result * result)) + (2 * result)) / 3; + } + return negate ? -result : result; + }, + + clz32: function clz32(value) { + // See https://bugs.ecmascript.org/show_bug.cgi?id=2465 + var x = Number(value); + var number = ES.ToUint32(x); + if (number === 0) { + return 32; + } + return numberCLZ ? ES.Call(numberCLZ, number) : 31 - _floor(_log(number + 0.5) * LOG2E); + }, + + cosh: function cosh(value) { + var x = Number(value); + if (x === 0) { return 1; } // +0 or -0 + if (numberIsNaN(x)) { return NaN; } + if (!globalIsFinite(x)) { return Infinity; } + + var t = _exp(_abs(x) - 1); + return (t + (1 / (t * E * E))) * (E / 2); + }, + + expm1: function expm1(value) { + var x = Number(value); + if (x === -Infinity) { return -1; } + if (!globalIsFinite(x) || x === 0) { return x; } + if (_abs(x) > 0.5) { + return _exp(x) - 1; + } + // A more precise approximation using Taylor series expansion + // from https://github.com/paulmillr/es6-shim/issues/314#issuecomment-70293986 + var t = x; + var sum = 0; + var n = 1; + while (sum + t !== sum) { + sum += t; + n += 1; + t *= x / n; + } + return sum; + }, + + hypot: function hypot(x, y) { + var result = 0; + var largest = 0; + for (var i = 0; i < arguments.length; ++i) { + var value = _abs(Number(arguments[i])); + if (largest < value) { + result *= (largest / value) * (largest / value); + result += 1; + largest = value; + } else { + result += value > 0 ? (value / largest) * (value / largest) : value; + } + } + return largest === Infinity ? Infinity : largest * _sqrt(result); + }, + + log2: function log2(value) { + return _log(value) * LOG2E; + }, + + log10: function log10(value) { + return _log(value) * LOG10E; + }, + + log1p: _log1p, + + sign: _sign, + + sinh: function sinh(value) { + var x = Number(value); + if (!globalIsFinite(x) || x === 0) { return x; } + + var a = _abs(x); + if (a < 1) { + var u = Math.expm1(a); + return _sign(x) * u * (1 + (1 / (u + 1))) / 2; + } + var t = _exp(a - 1); + return _sign(x) * (t - (1 / (t * E * E))) * (E / 2); + }, + + tanh: function tanh(value) { + var x = Number(value); + if (numberIsNaN(x) || x === 0) { return x; } + // can exit early at +-20 as JS loses precision for true value at this integer + if (x >= 20) { return 1; } + if (x <= -20) { return -1; } + + return (Math.expm1(x) - Math.expm1(-x)) / (_exp(x) + _exp(-x)); + }, + + trunc: function trunc(value) { + var x = Number(value); + return x < 0 ? -_floor(-x) : _floor(x); + }, + + imul: function imul(x, y) { + // taken from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/imul + var a = ES.ToUint32(x); + var b = ES.ToUint32(y); + var ah = (a >>> 16) & 0xffff; + var al = a & 0xffff; + var bh = (b >>> 16) & 0xffff; + var bl = b & 0xffff; + // the shift by 0 fixes the sign on the high part + // the final |0 converts the unsigned value into a signed value + return (al * bl) + ((((ah * bl) + (al * bh)) << 16) >>> 0) | 0; + }, + + fround: function fround(x) { + var v = Number(x); + if (v === 0 || v === Infinity || v === -Infinity || numberIsNaN(v)) { + return v; + } + var sign = _sign(v); + var abs = _abs(v); + if (abs < BINARY_32_MIN_VALUE) { + return sign * roundTiesToEven(abs / BINARY_32_MIN_VALUE / BINARY_32_EPSILON) * BINARY_32_MIN_VALUE * BINARY_32_EPSILON; + } + // Veltkamp's splitting (?) + var a = (1 + (BINARY_32_EPSILON / Number.EPSILON)) * abs; + var result = a - (a - abs); + if (result > BINARY_32_MAX_VALUE || numberIsNaN(result)) { + return sign * Infinity; + } + return sign * result; + } + }; + + var withinULPDistance = function withinULPDistance(result, expected, distance) { + return _abs(1 - (result / expected)) / Number.EPSILON < (8); + }; + + defineProperties(Math, MathShims); + // Chrome < 40 sinh returns ∞ for large numbers + defineProperty(Math, 'sinh', MathShims.sinh, Math.sinh(710) === Infinity); + // Chrome < 40 cosh returns ∞ for large numbers + defineProperty(Math, 'cosh', MathShims.cosh, Math.cosh(710) === Infinity); + // IE 11 TP has an imprecise log1p: reports Math.log1p(-1e-17) as 0 + defineProperty(Math, 'log1p', MathShims.log1p, Math.log1p(-1e-17) !== -1e-17); + // IE 11 TP has an imprecise asinh: reports Math.asinh(-1e7) as not exactly equal to -Math.asinh(1e7) + defineProperty(Math, 'asinh', MathShims.asinh, Math.asinh(-1e7) !== -Math.asinh(1e7)); + // Chrome < 54 asinh returns ∞ for large numbers and should not + defineProperty(Math, 'asinh', MathShims.asinh, Math.asinh(1e+300) === Infinity); + // Chrome < 54 atanh incorrectly returns 0 for large numbers + defineProperty(Math, 'atanh', MathShims.atanh, Math.atanh(1e-300) === 0); + // Chrome 40 has an imprecise Math.tanh with very small numbers + defineProperty(Math, 'tanh', MathShims.tanh, Math.tanh(-2e-17) !== -2e-17); + // Chrome 40 loses Math.acosh precision with high numbers + defineProperty(Math, 'acosh', MathShims.acosh, Math.acosh(Number.MAX_VALUE) === Infinity); + // Chrome < 54 has an inaccurate acosh for EPSILON deltas + defineProperty(Math, 'acosh', MathShims.acosh, !withinULPDistance(Math.acosh(1 + Number.EPSILON), Math.sqrt(2 * Number.EPSILON))); + // Firefox 38 on Windows + defineProperty(Math, 'cbrt', MathShims.cbrt, !withinULPDistance(Math.cbrt(1e-300), 1e-100)); + // node 0.11 has an imprecise Math.sinh with very small numbers + defineProperty(Math, 'sinh', MathShims.sinh, Math.sinh(-2e-17) !== -2e-17); + // FF 35 on Linux reports 22025.465794806725 for Math.expm1(10) + var expm1OfTen = Math.expm1(10); + defineProperty(Math, 'expm1', MathShims.expm1, expm1OfTen > 22025.465794806719 || expm1OfTen < 22025.4657948067165168); + // node v12.11 - v12.15 report NaN + defineProperty(Math, 'hypot', MathShims.hypot, Math.hypot(Infinity, NaN) !== Infinity); + + var origMathRound = Math.round; + // breaks in e.g. Safari 8, Internet Explorer 11, Opera 12 + var roundHandlesBoundaryConditions = Math.round(0.5 - (Number.EPSILON / 4)) === 0 + && Math.round(-0.5 + (Number.EPSILON / 3.99)) === 1; + + // When engines use Math.floor(x + 0.5) internally, Math.round can be buggy for large integers. + // This behavior should be governed by "round to nearest, ties to even mode" + // see http://www.ecma-international.org/ecma-262/6.0/#sec-terms-and-definitions-number-type + // These are the boundary cases where it breaks. + var smallestPositiveNumberWhereRoundBreaks = inverseEpsilon + 1; + var largestPositiveNumberWhereRoundBreaks = (2 * inverseEpsilon) - 1; + var roundDoesNotIncreaseIntegers = [ + smallestPositiveNumberWhereRoundBreaks, + largestPositiveNumberWhereRoundBreaks + ].every(function (num) { + return Math.round(num) === num; + }); + defineProperty(Math, 'round', function round(x) { + var floor = _floor(x); + var ceil = floor === -1 ? -0 : floor + 1; + return x - floor < 0.5 ? floor : ceil; + }, !roundHandlesBoundaryConditions || !roundDoesNotIncreaseIntegers); + Value.preserveToString(Math.round, origMathRound); + + var origImul = Math.imul; + if (Math.imul(0xffffffff, 5) !== -5) { + // Safari 6.1, at least, reports "0" for this value + Math.imul = MathShims.imul; + Value.preserveToString(Math.imul, origImul); + } + if (Math.imul.length !== 2) { + // Safari 8.0.4 has a length of 1 + // fixed in https://bugs.webkit.org/show_bug.cgi?id=143658 + overrideNative(Math, 'imul', function imul(x, y) { + return ES.Call(origImul, Math, arguments); + }); + } + + // Promises + // Simplest possible implementation; use a 3rd-party library if you + // want the best possible speed and/or long stack traces. + var PromiseShim = (function () { + var setTimeout = globals.setTimeout; + // some environments don't have setTimeout - no way to shim here. + if (typeof setTimeout !== 'function' && typeof setTimeout !== 'object') { return; } + + ES.IsPromise = function (promise) { + if (!ES.TypeIsObject(promise)) { + return false; + } + if (typeof promise._promise === 'undefined') { + return false; // uninitialized, or missing our hidden field. + } + return true; + }; + + // "PromiseCapability" in the spec is what most promise implementations + // call a "deferred". + var PromiseCapability = function (C) { + if (!ES.IsConstructor(C)) { + throw new TypeError('Bad promise constructor'); + } + var capability = this; + var resolver = function (resolve, reject) { + if (capability.resolve !== void 0 || capability.reject !== void 0) { + throw new TypeError('Bad Promise implementation!'); + } + capability.resolve = resolve; + capability.reject = reject; + }; + // Initialize fields to inform optimizers about the object shape. + capability.resolve = void 0; + capability.reject = void 0; + capability.promise = new C(resolver); + if (!(ES.IsCallable(capability.resolve) && ES.IsCallable(capability.reject))) { + throw new TypeError('Bad promise constructor'); + } + }; + + // find an appropriate setImmediate-alike + var makeZeroTimeout; + if (typeof window !== 'undefined' && ES.IsCallable(window.postMessage)) { + makeZeroTimeout = function () { + // from http://dbaron.org/log/20100309-faster-timeouts + var timeouts = []; + var messageName = 'zero-timeout-message'; + var setZeroTimeout = function (fn) { + _push(timeouts, fn); + window.postMessage(messageName, '*'); + }; + var handleMessage = function (event) { + if (event.source === window && event.data === messageName) { + event.stopPropagation(); + if (timeouts.length === 0) { return; } + var fn = _shift(timeouts); + fn(); + } + }; + window.addEventListener('message', handleMessage, true); + return setZeroTimeout; + }; + } + var makePromiseAsap = function () { + // An efficient task-scheduler based on a pre-existing Promise + // implementation, which we can use even if we override the + // global Promise below (in order to workaround bugs) + // https://github.com/Raynos/observ-hash/issues/2#issuecomment-35857671 + var P = globals.Promise; + var pr = P && P.resolve && P.resolve(); + return pr && function (task) { + return pr.then(task); + }; + }; + var enqueue = ES.IsCallable(globals.setImmediate) + ? globals.setImmediate + : ( + typeof process === 'object' && process.nextTick + ? process.nextTick + : makePromiseAsap() || (ES.IsCallable(makeZeroTimeout) ? makeZeroTimeout() : function (task) { setTimeout(task, 0); }) + ); // fallback + + // Constants for Promise implementation + var PROMISE_IDENTITY = function (x) { return x; }; + var PROMISE_THROWER = function (e) { throw e; }; + var PROMISE_PENDING = 0; + var PROMISE_FULFILLED = 1; + var PROMISE_REJECTED = 2; + // We store fulfill/reject handlers and capabilities in a single array. + var PROMISE_FULFILL_OFFSET = 0; + var PROMISE_REJECT_OFFSET = 1; + var PROMISE_CAPABILITY_OFFSET = 2; + // This is used in an optimization for chaining promises via then. + var PROMISE_FAKE_CAPABILITY = {}; + + var enqueuePromiseReactionJob = function (handler, capability, argument) { + enqueue(function () { + promiseReactionJob(handler, capability, argument); + }); + }; + + var promiseReactionJob = function (handler, promiseCapability, argument) { + var handlerResult, f; + if (promiseCapability === PROMISE_FAKE_CAPABILITY) { + // Fast case, when we don't actually need to chain through to a + // (real) promiseCapability. + return handler(argument); + } + try { + handlerResult = handler(argument); + f = promiseCapability.resolve; + } catch (e) { + handlerResult = e; + f = promiseCapability.reject; + } + f(handlerResult); + }; + + var fulfillPromise = function (promise, value) { + var _promise = promise._promise; + var length = _promise.reactionLength; + if (length > 0) { + enqueuePromiseReactionJob( + _promise.fulfillReactionHandler0, + _promise.reactionCapability0, + value + ); + _promise.fulfillReactionHandler0 = void 0; + _promise.rejectReactions0 = void 0; + _promise.reactionCapability0 = void 0; + if (length > 1) { + for (var i = 1, idx = 0; i < length; i++, idx += 3) { + enqueuePromiseReactionJob( + _promise[idx + PROMISE_FULFILL_OFFSET], + _promise[idx + PROMISE_CAPABILITY_OFFSET], + value + ); + promise[idx + PROMISE_FULFILL_OFFSET] = void 0; + promise[idx + PROMISE_REJECT_OFFSET] = void 0; + promise[idx + PROMISE_CAPABILITY_OFFSET] = void 0; + } + } + } + _promise.result = value; + _promise.state = PROMISE_FULFILLED; + _promise.reactionLength = 0; + }; + + var rejectPromise = function (promise, reason) { + var _promise = promise._promise; + var length = _promise.reactionLength; + if (length > 0) { + enqueuePromiseReactionJob( + _promise.rejectReactionHandler0, + _promise.reactionCapability0, + reason + ); + _promise.fulfillReactionHandler0 = void 0; + _promise.rejectReactions0 = void 0; + _promise.reactionCapability0 = void 0; + if (length > 1) { + for (var i = 1, idx = 0; i < length; i++, idx += 3) { + enqueuePromiseReactionJob( + _promise[idx + PROMISE_REJECT_OFFSET], + _promise[idx + PROMISE_CAPABILITY_OFFSET], + reason + ); + promise[idx + PROMISE_FULFILL_OFFSET] = void 0; + promise[idx + PROMISE_REJECT_OFFSET] = void 0; + promise[idx + PROMISE_CAPABILITY_OFFSET] = void 0; + } + } + } + _promise.result = reason; + _promise.state = PROMISE_REJECTED; + _promise.reactionLength = 0; + }; + + var createResolvingFunctions = function (promise) { + var alreadyResolved = false; + var resolve = function (resolution) { + var then; + if (alreadyResolved) { return; } + alreadyResolved = true; + if (resolution === promise) { + return rejectPromise(promise, new TypeError('Self resolution')); + } + if (!ES.TypeIsObject(resolution)) { + return fulfillPromise(promise, resolution); + } + try { + then = resolution.then; + } catch (e) { + return rejectPromise(promise, e); + } + if (!ES.IsCallable(then)) { + return fulfillPromise(promise, resolution); + } + enqueue(function () { + promiseResolveThenableJob(promise, resolution, then); + }); + }; + var reject = function (reason) { + if (alreadyResolved) { return; } + alreadyResolved = true; + return rejectPromise(promise, reason); + }; + return { resolve: resolve, reject: reject }; + }; + + var optimizedThen = function (then, thenable, resolve, reject) { + // Optimization: since we discard the result, we can pass our + // own then implementation a special hint to let it know it + // doesn't have to create it. (The PROMISE_FAKE_CAPABILITY + // object is local to this implementation and unforgeable outside.) + if (then === Promise$prototype$then) { + _call(then, thenable, resolve, reject, PROMISE_FAKE_CAPABILITY); + } else { + _call(then, thenable, resolve, reject); + } + }; + var promiseResolveThenableJob = function (promise, thenable, then) { + var resolvingFunctions = createResolvingFunctions(promise); + var resolve = resolvingFunctions.resolve; + var reject = resolvingFunctions.reject; + try { + optimizedThen(then, thenable, resolve, reject); + } catch (e) { + reject(e); + } + }; + + var Promise$prototype, Promise$prototype$then; + var Promise = (function () { + var PromiseShim = function Promise(resolver) { + if (!(this instanceof PromiseShim)) { + throw new TypeError('Constructor Promise requires "new"'); + } + if (this && this._promise) { + throw new TypeError('Bad construction'); + } + // see https://bugs.ecmascript.org/show_bug.cgi?id=2482 + if (!ES.IsCallable(resolver)) { + throw new TypeError('not a valid resolver'); + } + var promise = emulateES6construct(this, PromiseShim, Promise$prototype, { + _promise: { + result: void 0, + state: PROMISE_PENDING, + // The first member of the "reactions" array is inlined here, + // since most promises only have one reaction. + // We've also exploded the 'reaction' object to inline the + // "handler" and "capability" fields, since both fulfill and + // reject reactions share the same capability. + reactionLength: 0, + fulfillReactionHandler0: void 0, + rejectReactionHandler0: void 0, + reactionCapability0: void 0 + } + }); + var resolvingFunctions = createResolvingFunctions(promise); + var reject = resolvingFunctions.reject; + try { + resolver(resolvingFunctions.resolve, reject); + } catch (e) { + reject(e); + } + return promise; + }; + return PromiseShim; + }()); + Promise$prototype = Promise.prototype; + + var _promiseAllResolver = function (index, values, capability, remaining) { + var alreadyCalled = false; + return function (x) { + if (alreadyCalled) { return; } + alreadyCalled = true; + values[index] = x; + if ((--remaining.count) === 0) { + var resolve = capability.resolve; + resolve(values); // call w/ this===undefined + } + }; + }; + + var performPromiseAll = function (iteratorRecord, C, resultCapability) { + var it = iteratorRecord.iterator; + var values = []; + var remaining = { count: 1 }; + var next, nextValue; + var index = 0; + while (true) { + try { + next = ES.IteratorStep(it); + if (next === false) { + iteratorRecord.done = true; + break; + } + nextValue = next.value; + } catch (e) { + iteratorRecord.done = true; + throw e; + } + values[index] = void 0; + var nextPromise = C.resolve(nextValue); + var resolveElement = _promiseAllResolver( + index, + values, + resultCapability, + remaining + ); + remaining.count += 1; + optimizedThen(nextPromise.then, nextPromise, resolveElement, resultCapability.reject); + index += 1; + } + if ((--remaining.count) === 0) { + var resolve = resultCapability.resolve; + resolve(values); // call w/ this===undefined + } + return resultCapability.promise; + }; + + var performPromiseRace = function (iteratorRecord, C, resultCapability) { + var it = iteratorRecord.iterator; + var next, nextValue, nextPromise; + while (true) { + try { + next = ES.IteratorStep(it); + if (next === false) { + // NOTE: If iterable has no items, resulting promise will never + // resolve; see: + // https://github.com/domenic/promises-unwrapping/issues/75 + // https://bugs.ecmascript.org/show_bug.cgi?id=2515 + iteratorRecord.done = true; + break; + } + nextValue = next.value; + } catch (e) { + iteratorRecord.done = true; + throw e; + } + nextPromise = C.resolve(nextValue); + optimizedThen(nextPromise.then, nextPromise, resultCapability.resolve, resultCapability.reject); + } + return resultCapability.promise; + }; + + defineProperties(Promise, { + all: function all(iterable) { + var C = this; + if (!ES.TypeIsObject(C)) { + throw new TypeError('Promise is not object'); + } + var capability = new PromiseCapability(C); + var iterator, iteratorRecord; + try { + iterator = ES.GetIterator(iterable); + iteratorRecord = { iterator: iterator, done: false }; + return performPromiseAll(iteratorRecord, C, capability); + } catch (e) { + var exception = e; + if (iteratorRecord && !iteratorRecord.done) { + try { + ES.IteratorClose(iterator, true); + } catch (ee) { + exception = ee; + } + } + var reject = capability.reject; + reject(exception); + return capability.promise; + } + }, + + race: function race(iterable) { + var C = this; + if (!ES.TypeIsObject(C)) { + throw new TypeError('Promise is not object'); + } + var capability = new PromiseCapability(C); + var iterator, iteratorRecord; + try { + iterator = ES.GetIterator(iterable); + iteratorRecord = { iterator: iterator, done: false }; + return performPromiseRace(iteratorRecord, C, capability); + } catch (e) { + var exception = e; + if (iteratorRecord && !iteratorRecord.done) { + try { + ES.IteratorClose(iterator, true); + } catch (ee) { + exception = ee; + } + } + var reject = capability.reject; + reject(exception); + return capability.promise; + } + }, + + reject: function reject(reason) { + var C = this; + if (!ES.TypeIsObject(C)) { + throw new TypeError('Bad promise constructor'); + } + var capability = new PromiseCapability(C); + var rejectFunc = capability.reject; + rejectFunc(reason); // call with this===undefined + return capability.promise; + }, + + resolve: function resolve(v) { + // See https://esdiscuss.org/topic/fixing-promise-resolve for spec + var C = this; + if (!ES.TypeIsObject(C)) { + throw new TypeError('Bad promise constructor'); + } + if (ES.IsPromise(v)) { + var constructor = v.constructor; + if (constructor === C) { + return v; + } + } + var capability = new PromiseCapability(C); + var resolveFunc = capability.resolve; + resolveFunc(v); // call with this===undefined + return capability.promise; + } + }); + + defineProperties(Promise$prototype, { + 'catch': function (onRejected) { + return this.then(null, onRejected); + }, + + then: function then(onFulfilled, onRejected) { + var promise = this; + if (!ES.IsPromise(promise)) { throw new TypeError('not a promise'); } + var C = ES.SpeciesConstructor(promise, Promise); + var resultCapability; + var returnValueIsIgnored = arguments.length > 2 && arguments[2] === PROMISE_FAKE_CAPABILITY; + if (returnValueIsIgnored && C === Promise) { + resultCapability = PROMISE_FAKE_CAPABILITY; + } else { + resultCapability = new PromiseCapability(C); + } + // PerformPromiseThen(promise, onFulfilled, onRejected, resultCapability) + // Note that we've split the 'reaction' object into its two + // components, "capabilities" and "handler" + // "capabilities" is always equal to `resultCapability` + var fulfillReactionHandler = ES.IsCallable(onFulfilled) ? onFulfilled : PROMISE_IDENTITY; + var rejectReactionHandler = ES.IsCallable(onRejected) ? onRejected : PROMISE_THROWER; + var _promise = promise._promise; + var value; + if (_promise.state === PROMISE_PENDING) { + if (_promise.reactionLength === 0) { + _promise.fulfillReactionHandler0 = fulfillReactionHandler; + _promise.rejectReactionHandler0 = rejectReactionHandler; + _promise.reactionCapability0 = resultCapability; + } else { + var idx = 3 * (_promise.reactionLength - 1); + _promise[idx + PROMISE_FULFILL_OFFSET] = fulfillReactionHandler; + _promise[idx + PROMISE_REJECT_OFFSET] = rejectReactionHandler; + _promise[idx + PROMISE_CAPABILITY_OFFSET] = resultCapability; + } + _promise.reactionLength += 1; + } else if (_promise.state === PROMISE_FULFILLED) { + value = _promise.result; + enqueuePromiseReactionJob( + fulfillReactionHandler, + resultCapability, + value + ); + } else if (_promise.state === PROMISE_REJECTED) { + value = _promise.result; + enqueuePromiseReactionJob( + rejectReactionHandler, + resultCapability, + value + ); + } else { + throw new TypeError('unexpected Promise state'); + } + return resultCapability.promise; + } + }); + // This helps the optimizer by ensuring that methods which take + // capabilities aren't polymorphic. + PROMISE_FAKE_CAPABILITY = new PromiseCapability(Promise); + Promise$prototype$then = Promise$prototype.then; + + return Promise; + }()); + + // Chrome's native Promise has extra methods that it shouldn't have. Let's remove them. + if (globals.Promise) { + delete globals.Promise.accept; + delete globals.Promise.defer; + delete globals.Promise.prototype.chain; + } + + if (typeof PromiseShim === 'function') { + // export the Promise constructor. + defineProperties(globals, { Promise: PromiseShim }); + // In Chrome 33 (and thereabouts) Promise is defined, but the + // implementation is buggy in a number of ways. Let's check subclassing + // support to see if we have a buggy implementation. + var promiseSupportsSubclassing = supportsSubclassing(globals.Promise, function (S) { + return S.resolve(42).then(function () {}) instanceof S; + }); + var promiseIgnoresNonFunctionThenCallbacks = !throwsError(function () { + return globals.Promise.reject(42).then(null, 5).then(null, noop); + }); + var promiseRequiresObjectContext = throwsError(function () { return globals.Promise.call(3, noop); }); + // Promise.resolve() was errata'ed late in the ES6 process. + // See: https://bugzilla.mozilla.org/show_bug.cgi?id=1170742 + // https://code.google.com/p/v8/issues/detail?id=4161 + // It serves as a proxy for a number of other bugs in early Promise + // implementations. + var promiseResolveBroken = (function (Promise) { + var p = Promise.resolve(5); + p.constructor = {}; + var p2 = Promise.resolve(p); + try { + p2.then(null, noop).then(null, noop); // avoid "uncaught rejection" warnings in console + } catch (e) { + return true; // v8 native Promises break here https://code.google.com/p/chromium/issues/detail?id=575314 + } + return p === p2; // This *should* be false! + }(globals.Promise)); + + // Chrome 46 (probably older too) does not retrieve a thenable's .then synchronously + var getsThenSynchronously = supportsDescriptors && (function () { + var count = 0; + // eslint-disable-next-line getter-return + var thenable = Object.defineProperty({}, 'then', { get: function () { count += 1; } }); + Promise.resolve(thenable); + return count === 1; + }()); + + var BadResolverPromise = function BadResolverPromise(executor) { + var p = new Promise(executor); + executor(3, function () {}); + this.then = p.then; + this.constructor = BadResolverPromise; + }; + BadResolverPromise.prototype = Promise.prototype; + BadResolverPromise.all = Promise.all; + // Chrome Canary 49 (probably older too) has some implementation bugs + var hasBadResolverPromise = valueOrFalseIfThrows(function () { + return !!BadResolverPromise.all([1, 2]); + }); + + if ( + !promiseSupportsSubclassing + || !promiseIgnoresNonFunctionThenCallbacks + || !promiseRequiresObjectContext + || promiseResolveBroken + || !getsThenSynchronously + || hasBadResolverPromise + ) { + Promise = PromiseShim; // eslint-disable-line no-global-assign + overrideNative(globals, 'Promise', PromiseShim); + } + if (Promise.all.length !== 1) { + var origAll = Promise.all; + overrideNative(Promise, 'all', function all(iterable) { + return ES.Call(origAll, this, arguments); + }); + } + if (Promise.race.length !== 1) { + var origRace = Promise.race; + overrideNative(Promise, 'race', function race(iterable) { + return ES.Call(origRace, this, arguments); + }); + } + if (Promise.resolve.length !== 1) { + var origResolve = Promise.resolve; + overrideNative(Promise, 'resolve', function resolve(x) { + return ES.Call(origResolve, this, arguments); + }); + } + if (Promise.reject.length !== 1) { + var origReject = Promise.reject; + overrideNative(Promise, 'reject', function reject(r) { + return ES.Call(origReject, this, arguments); + }); + } + ensureEnumerable(Promise, 'all'); + ensureEnumerable(Promise, 'race'); + ensureEnumerable(Promise, 'resolve'); + ensureEnumerable(Promise, 'reject'); + addDefaultSpecies(Promise); + } + + // Map and Set require a true ES5 environment + // Their fast path also requires that the environment preserve + // property insertion order, which is not guaranteed by the spec. + var testOrder = function (a) { + var b = keys(_reduce(a, function (o, k) { + o[k] = true; + return o; + }, {})); + return a.join(':') === b.join(':'); + }; + var preservesInsertionOrder = testOrder(['z', 'a', 'bb']); + // some engines (eg, Chrome) only preserve insertion order for string keys + var preservesNumericInsertionOrder = testOrder(['z', 1, 'a', '3', 2]); + + if (supportsDescriptors) { + + var fastkey = function fastkey(key, skipInsertionOrderCheck) { + if (!skipInsertionOrderCheck && !preservesInsertionOrder) { + return null; + } + if (isNullOrUndefined(key)) { + return '^' + ES.ToString(key); + } else if (typeof key === 'string') { + return '$' + key; + } else if (typeof key === 'number') { + // note that -0 will get coerced to "0" when used as a property key + if (!preservesNumericInsertionOrder) { + return 'n' + key; + } + return key; + } else if (typeof key === 'boolean') { + return 'b' + key; + } + return null; + }; + + var emptyObject = function emptyObject() { + // accomodate some older not-quite-ES5 browsers + return Object.create ? Object.create(null) : {}; + }; + + var addIterableToMap = function addIterableToMap(MapConstructor, map, iterable) { + if (isArray(iterable) || Type.string(iterable)) { + _forEach(iterable, function (entry) { + if (!ES.TypeIsObject(entry)) { + throw new TypeError('Iterator value ' + entry + ' is not an entry object'); + } + map.set(entry[0], entry[1]); + }); + } else if (iterable instanceof MapConstructor) { + _call(MapConstructor.prototype.forEach, iterable, function (value, key) { + map.set(key, value); + }); + } else { + var iter, adder; + if (!isNullOrUndefined(iterable)) { + adder = map.set; + if (!ES.IsCallable(adder)) { throw new TypeError('bad map'); } + iter = ES.GetIterator(iterable); + } + if (typeof iter !== 'undefined') { + while (true) { + var next = ES.IteratorStep(iter); + if (next === false) { break; } + var nextItem = next.value; + try { + if (!ES.TypeIsObject(nextItem)) { + throw new TypeError('Iterator value ' + nextItem + ' is not an entry object'); + } + _call(adder, map, nextItem[0], nextItem[1]); + } catch (e) { + ES.IteratorClose(iter, true); + throw e; + } + } + } + } + }; + var addIterableToSet = function addIterableToSet(SetConstructor, set, iterable) { + if (isArray(iterable) || Type.string(iterable)) { + _forEach(iterable, function (value) { + set.add(value); + }); + } else if (iterable instanceof SetConstructor) { + _call(SetConstructor.prototype.forEach, iterable, function (value) { + set.add(value); + }); + } else { + var iter, adder; + if (!isNullOrUndefined(iterable)) { + adder = set.add; + if (!ES.IsCallable(adder)) { throw new TypeError('bad set'); } + iter = ES.GetIterator(iterable); + } + if (typeof iter !== 'undefined') { + while (true) { + var next = ES.IteratorStep(iter); + if (next === false) { break; } + var nextValue = next.value; + try { + _call(adder, set, nextValue); + } catch (e) { + ES.IteratorClose(iter, true); + throw e; + } + } + } + } + }; + + var collectionShims = { + Map: (function () { + + var empty = {}; + + var MapEntry = function MapEntry(key, value) { + this.key = key; + this.value = value; + this.next = null; + this.prev = null; + }; + + MapEntry.prototype.isRemoved = function isRemoved() { + return this.key === empty; + }; + + var isMap = function isMap(map) { + return !!map._es6map; + }; + + var requireMapSlot = function requireMapSlot(map, method) { + if (!ES.TypeIsObject(map) || !isMap(map)) { + throw new TypeError('Method Map.prototype.' + method + ' called on incompatible receiver ' + ES.ToString(map)); + } + }; + + var MapIterator = function MapIterator(map, kind) { + requireMapSlot(map, '[[MapIterator]]'); + defineProperty(this, 'head', map._head); + defineProperty(this, 'i', this.head); + defineProperty(this, 'kind', kind); + }; + + MapIterator.prototype = { + isMapIterator: true, + next: function next() { + if (!this.isMapIterator) { + throw new TypeError('Not a MapIterator'); + } + var i = this.i; + var kind = this.kind; + var head = this.head; + if (typeof this.i === 'undefined') { + return iteratorResult(); + } + while (i.isRemoved() && i !== head) { + // back up off of removed entries + i = i.prev; + } + // advance to next unreturned element. + var result; + while (i.next !== head) { + i = i.next; + if (!i.isRemoved()) { + if (kind === 'key') { + result = i.key; + } else if (kind === 'value') { + result = i.value; + } else { + result = [i.key, i.value]; + } + this.i = i; + return iteratorResult(result); + } + } + // once the iterator is done, it is done forever. + this.i = void 0; + return iteratorResult(); + } + }; + addIterator(MapIterator.prototype); + + var Map$prototype; + var MapShim = function Map() { + if (!(this instanceof Map)) { + throw new TypeError('Constructor Map requires "new"'); + } + if (this && this._es6map) { + throw new TypeError('Bad construction'); + } + var map = emulateES6construct(this, Map, Map$prototype, { + _es6map: true, + _head: null, + _map: OrigMap ? new OrigMap() : null, + _size: 0, + _storage: emptyObject() + }); + + var head = new MapEntry(null, null); + // circular doubly-linked list. + /* eslint no-multi-assign: 1 */ + head.next = head.prev = head; + map._head = head; + + // Optionally initialize map from iterable + if (arguments.length > 0) { + addIterableToMap(Map, map, arguments[0]); + } + return map; + }; + Map$prototype = MapShim.prototype; + + Value.getter(Map$prototype, 'size', function () { + if (typeof this._size === 'undefined') { + throw new TypeError('size method called on incompatible Map'); + } + return this._size; + }); + + defineProperties(Map$prototype, { + get: function get(key) { + requireMapSlot(this, 'get'); + var entry; + var fkey = fastkey(key, true); + if (fkey !== null) { + // fast O(1) path + entry = this._storage[fkey]; + if (entry) { + return entry.value; + } + return; + + } + if (this._map) { + // fast object key path + entry = origMapGet.call(this._map, key); + if (entry) { + return entry.value; + } + return; + + } + var head = this._head; + var i = head; + while ((i = i.next) !== head) { + if (ES.SameValueZero(i.key, key)) { + return i.value; + } + } + }, + + has: function has(key) { + requireMapSlot(this, 'has'); + var fkey = fastkey(key, true); + if (fkey !== null) { + // fast O(1) path + return typeof this._storage[fkey] !== 'undefined'; + } + if (this._map) { + // fast object key path + return origMapHas.call(this._map, key); + } + var head = this._head; + var i = head; + while ((i = i.next) !== head) { + if (ES.SameValueZero(i.key, key)) { + return true; + } + } + return false; + }, + + set: function set(key, value) { + requireMapSlot(this, 'set'); + var head = this._head; + var i = head; + var entry; + var fkey = fastkey(key, true); + if (fkey !== null) { + // fast O(1) path + if (typeof this._storage[fkey] !== 'undefined') { + this._storage[fkey].value = value; + return this; + } + entry = this._storage[fkey] = new MapEntry(key, value); /* eslint no-multi-assign: 1 */ + i = head.prev; + // fall through + + } else if (this._map) { + // fast object key path + if (origMapHas.call(this._map, key)) { + origMapGet.call(this._map, key).value = value; + } else { + entry = new MapEntry(key, value); + origMapSet.call(this._map, key, entry); + i = head.prev; + // fall through + } + } + while ((i = i.next) !== head) { + if (ES.SameValueZero(i.key, key)) { + i.value = value; + return this; + } + } + entry = entry || new MapEntry(key, value); + if (ES.SameValue(-0, key)) { + entry.key = 0; // coerce -0 to +0 in entry + } + entry.next = this._head; + entry.prev = this._head.prev; + entry.prev.next = entry; + entry.next.prev = entry; + this._size += 1; + return this; + }, + + 'delete': function (key) { + requireMapSlot(this, 'delete'); + var head = this._head; + var i = head; + var fkey = fastkey(key, true); + if (fkey !== null) { + // fast O(1) path + if (typeof this._storage[fkey] === 'undefined') { + return false; + } + i = this._storage[fkey].prev; + delete this._storage[fkey]; + // fall through + } else if (this._map) { + // fast object key path + if (!origMapHas.call(this._map, key)) { + return false; + } + i = origMapGet.call(this._map, key).prev; + origMapDelete.call(this._map, key); + // fall through + } + while ((i = i.next) !== head) { + if (ES.SameValueZero(i.key, key)) { + i.key = empty; + i.value = empty; + i.prev.next = i.next; + i.next.prev = i.prev; + this._size -= 1; + return true; + } + } + return false; + }, + + clear: function clear() { + /* eslint no-multi-assign: 1 */ + requireMapSlot(this, 'clear'); + this._map = OrigMap ? new OrigMap() : null; + this._size = 0; + this._storage = emptyObject(); + var head = this._head; + var i = head; + var p = i.next; + while ((i = p) !== head) { + i.key = empty; + i.value = empty; + p = i.next; + i.next = i.prev = head; + } + head.next = head.prev = head; + }, + + keys: function keys() { + requireMapSlot(this, 'keys'); + return new MapIterator(this, 'key'); + }, + + values: function values() { + requireMapSlot(this, 'values'); + return new MapIterator(this, 'value'); + }, + + entries: function entries() { + requireMapSlot(this, 'entries'); + return new MapIterator(this, 'key+value'); + }, + + forEach: function forEach(callback) { + requireMapSlot(this, 'forEach'); + var context = arguments.length > 1 ? arguments[1] : null; + var it = this.entries(); + for (var entry = it.next(); !entry.done; entry = it.next()) { + if (context) { + _call(callback, context, entry.value[1], entry.value[0], this); + } else { + callback(entry.value[1], entry.value[0], this); + } + } + } + }); + addIterator(Map$prototype, Map$prototype.entries); + + return MapShim; + }()), + + Set: (function () { + var isSet = function isSet(set) { + return set._es6set && typeof set._storage !== 'undefined'; + }; + var requireSetSlot = function requireSetSlot(set, method) { + if (!ES.TypeIsObject(set) || !isSet(set)) { + // https://github.com/paulmillr/es6-shim/issues/176 + throw new TypeError('Set.prototype.' + method + ' called on incompatible receiver ' + ES.ToString(set)); + } + }; + + // Creating a Map is expensive. To speed up the common case of + // Sets containing only string or numeric keys, we use an object + // as backing storage and lazily create a full Map only when + // required. + var Set$prototype; + var SetShim = function Set() { + if (!(this instanceof Set)) { + throw new TypeError('Constructor Set requires "new"'); + } + if (this && this._es6set) { + throw new TypeError('Bad construction'); + } + var set = emulateES6construct(this, Set, Set$prototype, { + _es6set: true, + '[[SetData]]': null, + _storage: emptyObject() + }); + if (!set._es6set) { + throw new TypeError('bad set'); + } + + // Optionally initialize Set from iterable + if (arguments.length > 0) { + addIterableToSet(Set, set, arguments[0]); + } + return set; + }; + Set$prototype = SetShim.prototype; + + var decodeKey = function (key) { + var k = key; + if (k === '^null') { + return null; + } else if (k === '^undefined') { + return void 0; + } + var first = k.charAt(0); + if (first === '$') { + return _strSlice(k, 1); + } else if (first === 'n') { + return +_strSlice(k, 1); + } else if (first === 'b') { + return k === 'btrue'; + } + + return +k; + }; + // Switch from the object backing storage to a full Map. + var ensureMap = function ensureMap(set) { + if (!set['[[SetData]]']) { + var m = new collectionShims.Map(); + set['[[SetData]]'] = m; + _forEach(keys(set._storage), function (key) { + var k = decodeKey(key); + m.set(k, k); + }); + set['[[SetData]]'] = m; + } + set._storage = null; // free old backing storage + }; + + Value.getter(SetShim.prototype, 'size', function () { + requireSetSlot(this, 'size'); + if (this._storage) { + return keys(this._storage).length; + } + ensureMap(this); + return this['[[SetData]]'].size; + }); + + defineProperties(SetShim.prototype, { + has: function has(key) { + requireSetSlot(this, 'has'); + var fkey; + if (this._storage && (fkey = fastkey(key)) !== null) { + return !!this._storage[fkey]; + } + ensureMap(this); + return this['[[SetData]]'].has(key); + }, + + add: function add(key) { + requireSetSlot(this, 'add'); + var fkey; + if (this._storage && (fkey = fastkey(key)) !== null) { + this._storage[fkey] = true; + return this; + } + ensureMap(this); + this['[[SetData]]'].set(key, key); + return this; + }, + + 'delete': function (key) { + requireSetSlot(this, 'delete'); + var fkey; + if (this._storage && (fkey = fastkey(key)) !== null) { + var hasFKey = _hasOwnProperty(this._storage, fkey); + return (delete this._storage[fkey]) && hasFKey; + } + ensureMap(this); + return this['[[SetData]]']['delete'](key); + }, + + clear: function clear() { + requireSetSlot(this, 'clear'); + if (this._storage) { + this._storage = emptyObject(); + } + if (this['[[SetData]]']) { + this['[[SetData]]'].clear(); + } + }, + + values: function values() { + requireSetSlot(this, 'values'); + ensureMap(this); + return new SetIterator(this['[[SetData]]'].values()); + }, + + entries: function entries() { + requireSetSlot(this, 'entries'); + ensureMap(this); + return new SetIterator(this['[[SetData]]'].entries()); + }, + + forEach: function forEach(callback) { + requireSetSlot(this, 'forEach'); + var context = arguments.length > 1 ? arguments[1] : null; + var entireSet = this; + ensureMap(entireSet); + this['[[SetData]]'].forEach(function (value, key) { + if (context) { + _call(callback, context, key, key, entireSet); + } else { + callback(key, key, entireSet); + } + }); + } + }); + defineProperty(SetShim.prototype, 'keys', SetShim.prototype.values, true); + addIterator(SetShim.prototype, SetShim.prototype.values); + + var SetIterator = function SetIterator(it) { + defineProperty(this, 'it', it); + }; + SetIterator.prototype = { + isSetIterator: true, + next: function next() { + if (!this.isSetIterator) { + throw new TypeError('Not a SetIterator'); + } + return this.it.next(); + } + }; + addIterator(SetIterator.prototype); + + return SetShim; + }()) + }; + + var isGoogleTranslate = globals.Set && !Set.prototype['delete'] && Set.prototype.remove && Set.prototype.items && Set.prototype.map && Array.isArray(new Set().keys); + if (isGoogleTranslate) { + // special-case force removal of wildly invalid Set implementation in Google Translate iframes + // see https://github.com/paulmillr/es6-shim/issues/438 / https://twitter.com/ljharb/status/849335573114363904 + globals.Set = collectionShims.Set; + } + if (globals.Map || globals.Set) { + // Safari 8, for example, doesn't accept an iterable. + var mapAcceptsArguments = valueOrFalseIfThrows(function () { return new Map([[1, 2]]).get(1) === 2; }); + if (!mapAcceptsArguments) { + globals.Map = function Map() { + if (!(this instanceof Map)) { + throw new TypeError('Constructor Map requires "new"'); + } + var m = new OrigMap(); + if (arguments.length > 0) { + addIterableToMap(Map, m, arguments[0]); + } + delete m.constructor; + Object.setPrototypeOf(m, globals.Map.prototype); + return m; + }; + globals.Map.prototype = create(OrigMap.prototype); + defineProperty(globals.Map.prototype, 'constructor', globals.Map, true); + Value.preserveToString(globals.Map, OrigMap); + } + var testMap = new Map(); + var mapUsesSameValueZero = (function () { + // Chrome 38-42, node 0.11/0.12, iojs 1/2 also have a bug when the Map has a size > 4 + var m = new Map([[1, 0], [2, 0], [3, 0], [4, 0]]); + m.set(-0, m); + return m.get(0) === m && m.get(-0) === m && m.has(0) && m.has(-0); + }()); + var mapSupportsChaining = testMap.set(1, 2) === testMap; + if (!mapUsesSameValueZero || !mapSupportsChaining) { + overrideNative(Map.prototype, 'set', function set(k, v) { + _call(origMapSet, this, k === 0 ? 0 : k, v); + return this; + }); + } + if (!mapUsesSameValueZero) { + defineProperties(Map.prototype, { + get: function get(k) { + return _call(origMapGet, this, k === 0 ? 0 : k); + }, + has: function has(k) { + return _call(origMapHas, this, k === 0 ? 0 : k); + } + }, true); + Value.preserveToString(Map.prototype.get, origMapGet); + Value.preserveToString(Map.prototype.has, origMapHas); + } + var testSet = new Set(); + var setUsesSameValueZero = Set.prototype['delete'] && Set.prototype.add && Set.prototype.has && (function (s) { + s['delete'](0); + s.add(-0); + return !s.has(0); + }(testSet)); + var setSupportsChaining = testSet.add(1) === testSet; + if (!setUsesSameValueZero || !setSupportsChaining) { + var origSetAdd = Set.prototype.add; + Set.prototype.add = function add(v) { + _call(origSetAdd, this, v === 0 ? 0 : v); + return this; + }; + Value.preserveToString(Set.prototype.add, origSetAdd); + } + if (!setUsesSameValueZero) { + var origSetHas = Set.prototype.has; + Set.prototype.has = function has(v) { + return _call(origSetHas, this, v === 0 ? 0 : v); + }; + Value.preserveToString(Set.prototype.has, origSetHas); + var origSetDel = Set.prototype['delete']; + Set.prototype['delete'] = function SetDelete(v) { + return _call(origSetDel, this, v === 0 ? 0 : v); + }; + Value.preserveToString(Set.prototype['delete'], origSetDel); + } + var mapSupportsSubclassing = supportsSubclassing(globals.Map, function (M) { + var m = new M([]); + // Firefox 32 is ok with the instantiating the subclass but will + // throw when the map is used. + m.set(42, 42); + return m instanceof M; + }); + // without Object.setPrototypeOf, subclassing is not possible + var mapFailsToSupportSubclassing = Object.setPrototypeOf && !mapSupportsSubclassing; + var mapRequiresNew = (function () { + try { + return !(globals.Map() instanceof globals.Map); + } catch (e) { + return e instanceof TypeError; + } + }()); + if (globals.Map.length !== 0 || mapFailsToSupportSubclassing || !mapRequiresNew) { + globals.Map = function Map() { + if (!(this instanceof Map)) { + throw new TypeError('Constructor Map requires "new"'); + } + var m = new OrigMap(); + if (arguments.length > 0) { + addIterableToMap(Map, m, arguments[0]); + } + delete m.constructor; + Object.setPrototypeOf(m, Map.prototype); + return m; + }; + globals.Map.prototype = OrigMap.prototype; + defineProperty(globals.Map.prototype, 'constructor', globals.Map, true); + Value.preserveToString(globals.Map, OrigMap); + } + var setSupportsSubclassing = supportsSubclassing(globals.Set, function (S) { + var s = new S([]); + s.add(42, 42); + return s instanceof S; + }); + // without Object.setPrototypeOf, subclassing is not possible + var setFailsToSupportSubclassing = Object.setPrototypeOf && !setSupportsSubclassing; + var setRequiresNew = (function () { + try { + return !(globals.Set() instanceof globals.Set); + } catch (e) { + return e instanceof TypeError; + } + }()); + if (globals.Set.length !== 0 || setFailsToSupportSubclassing || !setRequiresNew) { + var OrigSet = globals.Set; + globals.Set = function Set() { + if (!(this instanceof Set)) { + throw new TypeError('Constructor Set requires "new"'); + } + var s = new OrigSet(); + if (arguments.length > 0) { + addIterableToSet(Set, s, arguments[0]); + } + delete s.constructor; + Object.setPrototypeOf(s, Set.prototype); + return s; + }; + globals.Set.prototype = OrigSet.prototype; + defineProperty(globals.Set.prototype, 'constructor', globals.Set, true); + Value.preserveToString(globals.Set, OrigSet); + } + var newMap = new globals.Map(); + var mapIterationThrowsStopIterator = !valueOrFalseIfThrows(function () { + return newMap.keys().next().done; + }); + /* + - In Firefox < 23, Map#size is a function. + - In all current Firefox, Set#entries/keys/values & Map#clear do not exist + - https://bugzilla.mozilla.org/show_bug.cgi?id=869996 + - In Firefox 24, Map and Set do not implement forEach + - In Firefox 25 at least, Map and Set are callable without "new" + */ + if ( + typeof globals.Map.prototype.clear !== 'function' + || new globals.Set().size !== 0 + || newMap.size !== 0 + || typeof globals.Map.prototype.keys !== 'function' + || typeof globals.Set.prototype.keys !== 'function' + || typeof globals.Map.prototype.forEach !== 'function' + || typeof globals.Set.prototype.forEach !== 'function' + || isCallableWithoutNew(globals.Map) + || isCallableWithoutNew(globals.Set) + || typeof newMap.keys().next !== 'function' // Safari 8 + || mapIterationThrowsStopIterator // Firefox 25 + || !mapSupportsSubclassing + ) { + defineProperties(globals, { + Map: collectionShims.Map, + Set: collectionShims.Set + }, true); + } + + if (globals.Set.prototype.keys !== globals.Set.prototype.values) { + // Fixed in WebKit with https://bugs.webkit.org/show_bug.cgi?id=144190 + defineProperty(globals.Set.prototype, 'keys', globals.Set.prototype.values, true); + } + + // Shim incomplete iterator implementations. + addIterator(Object.getPrototypeOf((new globals.Map()).keys())); + addIterator(Object.getPrototypeOf((new globals.Set()).keys())); + + if (functionsHaveNames && globals.Set.prototype.has.name !== 'has') { + // Microsoft Edge v0.11.10074.0 is missing a name on Set#has + var anonymousSetHas = globals.Set.prototype.has; + overrideNative(globals.Set.prototype, 'has', function has(key) { + return _call(anonymousSetHas, this, key); + }); + } + } + defineProperties(globals, collectionShims); + addDefaultSpecies(globals.Map); + addDefaultSpecies(globals.Set); + } + + var throwUnlessTargetIsObject = function throwUnlessTargetIsObject(target) { + if (!ES.TypeIsObject(target)) { + throw new TypeError('target must be an object'); + } + }; + + // Some Reflect methods are basically the same as + // those on the Object global, except that a TypeError is thrown if + // target isn't an object. As well as returning a boolean indicating + // the success of the operation. + var ReflectShims = { + // Apply method in a functional form. + apply: function apply() { + return ES.Call(ES.Call, null, arguments); + }, + + // New operator in a functional form. + construct: function construct(constructor, args) { + if (!ES.IsConstructor(constructor)) { + throw new TypeError('First argument must be a constructor.'); + } + var newTarget = arguments.length > 2 ? arguments[2] : constructor; + if (!ES.IsConstructor(newTarget)) { + throw new TypeError('new.target must be a constructor.'); + } + return ES.Construct(constructor, args, newTarget, 'internal'); + }, + + // When deleting a non-existent or configurable property, + // true is returned. + // When attempting to delete a non-configurable property, + // it will return false. + deleteProperty: function deleteProperty(target, key) { + throwUnlessTargetIsObject(target); + if (supportsDescriptors) { + var desc = Object.getOwnPropertyDescriptor(target, key); + + if (desc && !desc.configurable) { + return false; + } + } + + // Will return true. + return delete target[key]; + }, + + has: function has(target, key) { + throwUnlessTargetIsObject(target); + return key in target; + } + }; + + if (Object.getOwnPropertyNames) { + Object.assign(ReflectShims, { + // Basically the result of calling the internal [[OwnPropertyKeys]]. + // Concatenating propertyNames and propertySymbols should do the trick. + // This should continue to work together with a Symbol shim + // which overrides Object.getOwnPropertyNames and implements + // Object.getOwnPropertySymbols. + ownKeys: function ownKeys(target) { + throwUnlessTargetIsObject(target); + var keys = Object.getOwnPropertyNames(target); + + if (ES.IsCallable(Object.getOwnPropertySymbols)) { + _pushApply(keys, Object.getOwnPropertySymbols(target)); + } + + return keys; + } + }); + } + + var callAndCatchException = function ConvertExceptionToBoolean(func) { + return !throwsError(func); + }; + + if (Object.preventExtensions) { + Object.assign(ReflectShims, { + isExtensible: function isExtensible(target) { + throwUnlessTargetIsObject(target); + return Object.isExtensible(target); + }, + preventExtensions: function preventExtensions(target) { + throwUnlessTargetIsObject(target); + return callAndCatchException(function () { + return Object.preventExtensions(target); + }); + } + }); + } + + if (supportsDescriptors) { + var internalGet = function get(target, key, receiver) { + var desc = Object.getOwnPropertyDescriptor(target, key); + + if (!desc) { + var parent = Object.getPrototypeOf(target); + + if (parent === null) { + return void 0; + } + + return internalGet(parent, key, receiver); + } + + if ('value' in desc) { + return desc.value; + } + + if (desc.get) { + return ES.Call(desc.get, receiver); + } + + return void 0; + }; + + var internalSet = function set(target, key, value, receiver) { + var desc = Object.getOwnPropertyDescriptor(target, key); + + if (!desc) { + var parent = Object.getPrototypeOf(target); + + if (parent !== null) { + return internalSet(parent, key, value, receiver); + } + + desc = { + value: void 0, + writable: true, + enumerable: true, + configurable: true + }; + } + + if ('value' in desc) { + if (!desc.writable) { + return false; + } + + if (!ES.TypeIsObject(receiver)) { + return false; + } + + var existingDesc = Object.getOwnPropertyDescriptor(receiver, key); + + if (existingDesc) { + return Reflect.defineProperty(receiver, key, { + value: value + }); + } + return Reflect.defineProperty(receiver, key, { + value: value, + writable: true, + enumerable: true, + configurable: true + }); + + } + + if (desc.set) { + _call(desc.set, receiver, value); + return true; + } + + return false; + }; + + Object.assign(ReflectShims, { + defineProperty: function defineProperty(target, propertyKey, attributes) { + throwUnlessTargetIsObject(target); + return callAndCatchException(function () { + return Object.defineProperty(target, propertyKey, attributes); + }); + }, + + getOwnPropertyDescriptor: function getOwnPropertyDescriptor(target, propertyKey) { + throwUnlessTargetIsObject(target); + return Object.getOwnPropertyDescriptor(target, propertyKey); + }, + + // Syntax in a functional form. + get: function get(target, key) { + throwUnlessTargetIsObject(target); + var receiver = arguments.length > 2 ? arguments[2] : target; + + return internalGet(target, key, receiver); + }, + + set: function set(target, key, value) { + throwUnlessTargetIsObject(target); + var receiver = arguments.length > 3 ? arguments[3] : target; + + return internalSet(target, key, value, receiver); + } + }); + } + + if (Object.getPrototypeOf) { + var objectDotGetPrototypeOf = Object.getPrototypeOf; + ReflectShims.getPrototypeOf = function getPrototypeOf(target) { + throwUnlessTargetIsObject(target); + return objectDotGetPrototypeOf(target); + }; + } + + if (Object.setPrototypeOf && ReflectShims.getPrototypeOf) { + var willCreateCircularPrototype = function (object, lastProto) { + var proto = lastProto; + while (proto) { + if (object === proto) { + return true; + } + proto = ReflectShims.getPrototypeOf(proto); + } + return false; + }; + + Object.assign(ReflectShims, { + // Sets the prototype of the given object. + // Returns true on success, otherwise false. + setPrototypeOf: function setPrototypeOf(object, proto) { + throwUnlessTargetIsObject(object); + if (proto !== null && !ES.TypeIsObject(proto)) { + throw new TypeError('proto must be an object or null'); + } + + // If they already are the same, we're done. + if (proto === Reflect.getPrototypeOf(object)) { + return true; + } + + // Cannot alter prototype if object not extensible. + if (Reflect.isExtensible && !Reflect.isExtensible(object)) { + return false; + } + + // Ensure that we do not create a circular prototype chain. + if (willCreateCircularPrototype(object, proto)) { + return false; + } + + Object.setPrototypeOf(object, proto); + + return true; + } + }); + } + var defineOrOverrideReflectProperty = function (key, shim) { + if (!ES.IsCallable(globals.Reflect[key])) { + defineProperty(globals.Reflect, key, shim); + } else { + var acceptsPrimitives = valueOrFalseIfThrows(function () { + globals.Reflect[key](1); + globals.Reflect[key](NaN); + globals.Reflect[key](true); + return true; + }); + if (acceptsPrimitives) { + overrideNative(globals.Reflect, key, shim); + } + } + }; + Object.keys(ReflectShims).forEach(function (key) { + defineOrOverrideReflectProperty(key, ReflectShims[key]); + }); + var originalReflectGetProto = globals.Reflect.getPrototypeOf; + if (functionsHaveNames && originalReflectGetProto && originalReflectGetProto.name !== 'getPrototypeOf') { + overrideNative(globals.Reflect, 'getPrototypeOf', function getPrototypeOf(target) { + return _call(originalReflectGetProto, globals.Reflect, target); + }); + } + if (globals.Reflect.setPrototypeOf) { + if (valueOrFalseIfThrows(function () { + globals.Reflect.setPrototypeOf(1, {}); + return true; + })) { + overrideNative(globals.Reflect, 'setPrototypeOf', ReflectShims.setPrototypeOf); + } + } + if (globals.Reflect.defineProperty) { + if (!valueOrFalseIfThrows(function () { + var basic = !globals.Reflect.defineProperty(1, 'test', { value: 1 }); + // "extensible" fails on Edge 0.12 + var extensible = typeof Object.preventExtensions !== 'function' || !globals.Reflect.defineProperty(Object.preventExtensions({}), 'test', {}); + return basic && extensible; + })) { + overrideNative(globals.Reflect, 'defineProperty', ReflectShims.defineProperty); + } + } + if (globals.Reflect.construct) { + if (!valueOrFalseIfThrows(function () { + var F = function F() {}; + return globals.Reflect.construct(function () {}, [], F) instanceof F; + })) { + overrideNative(globals.Reflect, 'construct', ReflectShims.construct); + } + } + + if (String(new Date(NaN)) !== 'Invalid Date') { + var dateToString = Date.prototype.toString; + var shimmedDateToString = function toString() { + var valueOf = +this; + if (valueOf !== valueOf) { + return 'Invalid Date'; + } + return ES.Call(dateToString, this); + }; + overrideNative(Date.prototype, 'toString', shimmedDateToString); + } + + // Annex B HTML methods + // http://www.ecma-international.org/ecma-262/6.0/#sec-additional-properties-of-the-string.prototype-object + var stringHTMLshims = { + anchor: function anchor(name) { return ES.CreateHTML(this, 'a', 'name', name); }, + big: function big() { return ES.CreateHTML(this, 'big', '', ''); }, + blink: function blink() { return ES.CreateHTML(this, 'blink', '', ''); }, + bold: function bold() { return ES.CreateHTML(this, 'b', '', ''); }, + fixed: function fixed() { return ES.CreateHTML(this, 'tt', '', ''); }, + fontcolor: function fontcolor(color) { return ES.CreateHTML(this, 'font', 'color', color); }, + fontsize: function fontsize(size) { return ES.CreateHTML(this, 'font', 'size', size); }, + italics: function italics() { return ES.CreateHTML(this, 'i', '', ''); }, + link: function link(url) { return ES.CreateHTML(this, 'a', 'href', url); }, + small: function small() { return ES.CreateHTML(this, 'small', '', ''); }, + strike: function strike() { return ES.CreateHTML(this, 'strike', '', ''); }, + sub: function sub() { return ES.CreateHTML(this, 'sub', '', ''); }, + sup: function sub() { return ES.CreateHTML(this, 'sup', '', ''); } + }; + _forEach(Object.keys(stringHTMLshims), function (key) { + var method = String.prototype[key]; + var shouldOverwrite = false; + if (ES.IsCallable(method)) { + var output = _call(method, '', ' " '); + var quotesCount = _concat([], output.match(/"/g)).length; + shouldOverwrite = output !== output.toLowerCase() || quotesCount > 2; + } else { + shouldOverwrite = true; + } + if (shouldOverwrite) { + overrideNative(String.prototype, key, stringHTMLshims[key]); + } + }); + + var JSONstringifiesSymbols = (function () { + // Microsoft Edge v0.12 stringifies Symbols incorrectly + if (!hasSymbols) { return false; } // Symbols are not supported + var stringify = typeof JSON === 'object' && typeof JSON.stringify === 'function' ? JSON.stringify : null; + if (!stringify) { return false; } // JSON.stringify is not supported + if (typeof stringify(Symbol()) !== 'undefined') { return true; } // Symbols should become `undefined` + if (stringify([Symbol()]) !== '[null]') { return true; } // Symbols in arrays should become `null` + var obj = { a: Symbol() }; + obj[Symbol()] = true; + if (stringify(obj) !== '{}') { return true; } // Symbol-valued keys *and* Symbol-valued properties should be omitted + return false; + }()); + var JSONstringifyAcceptsObjectSymbol = valueOrFalseIfThrows(function () { + // Chrome 45 throws on stringifying object symbols + if (!hasSymbols) { return true; } // Symbols are not supported + return JSON.stringify(Object(Symbol())) === '{}' && JSON.stringify([Object(Symbol())]) === '[{}]'; + }); + if (JSONstringifiesSymbols || !JSONstringifyAcceptsObjectSymbol) { + var origStringify = JSON.stringify; + overrideNative(JSON, 'stringify', function stringify(value) { + if (typeof value === 'symbol') { return; } + var replacer; + if (arguments.length > 1) { + replacer = arguments[1]; + } + var args = [value]; + if (!isArray(replacer)) { + var replaceFn = ES.IsCallable(replacer) ? replacer : null; + var wrappedReplacer = function (key, val) { + var parsedValue = replaceFn ? _call(replaceFn, this, key, val) : val; + if (typeof parsedValue !== 'symbol') { + if (Type.symbol(parsedValue)) { + return assignTo({})(parsedValue); + } + return parsedValue; + + } + }; + args.push(wrappedReplacer); + } else { + // create wrapped replacer that handles an array replacer? + args.push(replacer); + } + if (arguments.length > 2) { + args.push(arguments[2]); + } + return origStringify.apply(this, args); + }); + } + + return globals; + })); + } (es6Shim$1)); + return es6Shim$1.exports; +} + +requireEs6Shim(); diff --git a/test/form/samples/switch-cases/missing-space/_config.js b/test/form/samples/switch-cases/missing-space/_config.js new file mode 100644 index 00000000000..f9d55d696d7 --- /dev/null +++ b/test/form/samples/switch-cases/missing-space/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'Inserts space when simplifying switch cases without space' +}); diff --git a/test/form/samples/switch-cases/missing-space/_expected.js b/test/form/samples/switch-cases/missing-space/_expected.js new file mode 100644 index 00000000000..ae4276cfd60 --- /dev/null +++ b/test/form/samples/switch-cases/missing-space/_expected.js @@ -0,0 +1,5 @@ +switch (bar) { + case 1: + console.log('1'); + break; +} diff --git a/test/form/samples/switch-cases/missing-space/main.js b/test/form/samples/switch-cases/missing-space/main.js new file mode 100644 index 00000000000..9abe40f7902 --- /dev/null +++ b/test/form/samples/switch-cases/missing-space/main.js @@ -0,0 +1,5 @@ +switch (bar) { + case!0?1:2: + console.log('1'); + break; +} \ No newline at end of file diff --git a/test/form/samples/switch-scopes/_config.js b/test/form/samples/switch-scopes/_config.js index 79a7b97dd61..86c4398bd0b 100644 --- a/test/form/samples/switch-scopes/_config.js +++ b/test/form/samples/switch-scopes/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'correctly handles switch scopes', options: { output: { name: 'myBundle' } } -}; +}); diff --git a/test/form/samples/synthetic-named-exports/_config.js b/test/form/samples/synthetic-named-exports/_config.js index 65eff57dc5c..6cb3e13e740 100644 --- a/test/form/samples/synthetic-named-exports/_config.js +++ b/test/form/samples/synthetic-named-exports/_config.js @@ -1,8 +1,9 @@ -module.exports = { +module.exports = defineTest({ description: 'synthetic named exports', options: { plugins: [ { + name: 'test', resolveId(id) { if (id.endsWith('dep1.js')) { return id; @@ -15,7 +16,7 @@ module.exports = { code: ` const d = { fn: 42, - hello: 'hola' + unused: 'tree-shaken', }; export default d;`, syntheticNamedExports: true @@ -26,4 +27,4 @@ export default d;`, } ] } -}; +}); diff --git a/test/form/samples/synthetic-named-exports/_expected.js b/test/form/samples/synthetic-named-exports/_expected.js index ecd2e3e91a7..0ce78ec5ea1 100644 --- a/test/form/samples/synthetic-named-exports/_expected.js +++ b/test/form/samples/synthetic-named-exports/_expected.js @@ -1,7 +1,5 @@ const d = { - fn: 42, - hello: 'hola' -}; + fn: 42}; console.log(d.fn); console.log(d.foo); diff --git a/test/form/samples/system-comments/_config.js b/test/form/samples/system-comments/_config.js index 074f8c0a72e..74c6254868c 100644 --- a/test/form/samples/system-comments/_config.js +++ b/test/form/samples/system-comments/_config.js @@ -1,8 +1,8 @@ -module.exports = { +module.exports = defineTest({ description: 'Correctly places leading comments when rendering system bindings', options: { output: { format: 'system' } } -}; +}); diff --git a/test/form/samples/system-comments/_expected.js b/test/form/samples/system-comments/_expected.js index 474e9b8e7d1..3f11f66e87d 100644 --- a/test/form/samples/system-comments/_expected.js +++ b/test/form/samples/system-comments/_expected.js @@ -1,21 +1,22 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { const pureFunc = () => console.log('not really pure') || 0; - var singleLine = exports('singleLine', /*#__PURE__*/pureFunc()); + var singleLine = exports("singleLine", /*#__PURE__*/pureFunc()); - singleLine = exports('singleLine', /*#__PURE__*/pureFunc()); + exports("singleLine", singleLine = /*#__PURE__*/pureFunc()); var multiLine = - exports('multiLine', /*#__PURE__*/ + exports("multiLine", /*#__PURE__*/ pureFunc()); - multiLine = exports('multiLine', /*#__PURE__*/ + exports("multiLine", multiLine = + /*#__PURE__*/ pureFunc()); - } + }) }; -}); +})); diff --git a/test/form/samples/system-default-comments/_config.js b/test/form/samples/system-default-comments/_config.js index 1054b71b8a2..3b6b40660b1 100644 --- a/test/form/samples/system-default-comments/_config.js +++ b/test/form/samples/system-default-comments/_config.js @@ -1,8 +1,8 @@ -module.exports = { +module.exports = defineTest({ description: 'Correctly places leading comments when rendering system default exports', options: { output: { format: 'system' } } -}; +}); diff --git a/test/form/samples/system-default-comments/_expected.js b/test/form/samples/system-default-comments/_expected.js index e2da4be4ac2..9957fc224d1 100644 --- a/test/form/samples/system-default-comments/_expected.js +++ b/test/form/samples/system-default-comments/_expected.js @@ -1,12 +1,12 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { const pureFunc = () => console.log('not really pure') || 0; - var main = exports('default', /*#__PURE__*/pureFunc()); + var main = exports("default", /*#__PURE__*/pureFunc()); - } + }) }; -}); +})); diff --git a/test/form/samples/system-export-compact/_config.js b/test/form/samples/system-export-compact/_config.js deleted file mode 100644 index 7dc4dfaa73a..00000000000 --- a/test/form/samples/system-export-compact/_config.js +++ /dev/null @@ -1,9 +0,0 @@ -module.exports = { - description: 'supports destructuring assignments of exports for systemJS', - options: { - output: { - format: 'system', - compact: true - } - } -}; diff --git a/test/form/samples/system-export-compact/_expected.js b/test/form/samples/system-export-compact/_expected.js deleted file mode 100644 index 1160f5e7b11..00000000000 --- a/test/form/samples/system-export-compact/_expected.js +++ /dev/null @@ -1,3 +0,0 @@ -System.register([],function(exports){'use strict';return{execute:function(){exports({a:void 0,b:void 0,c:void 0});let a, b; - -(function(v){return exports({a:a}),v}([{ b: a = (exports('a',a-1),a--) }] = { b: (function(v){return exports({b:v,c:v}),v}(--b)) })), (function(v){return exports({a:a}),v}([a] = [1]));}}}); \ No newline at end of file diff --git a/test/form/samples/system-export-compact/main.js b/test/form/samples/system-export-compact/main.js deleted file mode 100644 index 41f58664a03..00000000000 --- a/test/form/samples/system-export-compact/main.js +++ /dev/null @@ -1,5 +0,0 @@ -export let a, b; - -[{ b: a = a-- }] = { b: b-- }, [a] = [1]; - -export { b as c }; diff --git a/test/form/samples/system-export-declarations/_config.js b/test/form/samples/system-export-declarations/_config.js new file mode 100644 index 00000000000..3b93d3d5bcc --- /dev/null +++ b/test/form/samples/system-export-declarations/_config.js @@ -0,0 +1,8 @@ +module.exports = defineTest({ + description: 'Renders declarations where some variables are exported', + options: { + output: { + format: 'system' + } + } +}); diff --git a/test/form/samples/system-export-declarations/_expected.js b/test/form/samples/system-export-declarations/_expected.js new file mode 100644 index 00000000000..80e548b6c64 --- /dev/null +++ b/test/form/samples/system-export-declarations/_expected.js @@ -0,0 +1,30 @@ +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + + // middle binding + const a1 = 1, a2 = exports("a2", 2), a3 = 3; + console.log(a1, a2, a3); + + // first binding + const b1 = exports("b1", 1), b2 = 2; + console.log(b1, b2); + + // last binding + const c1 = 1, c2 = exports("c2", 2); + console.log(c1, c2); + + // middle binding with other bindings removed + const d2 = exports("d2", 2); + + // uninitialized binding + let e1 = 1, e2, e3 = 3; exports("e2", e2); + console.log(e1, e2, e3); + + // destructuring declaration + let {f1, f2} = globalThis.obj, {f3} = globalThis.obj; exports("f2", f2); + + }) + }; +})); diff --git a/test/form/samples/system-export-declarations/main.js b/test/form/samples/system-export-declarations/main.js new file mode 100644 index 00000000000..b61ed02d886 --- /dev/null +++ b/test/form/samples/system-export-declarations/main.js @@ -0,0 +1,27 @@ +// middle binding +const a1 = 1, a2 = 2, a3 = 3; +console.log(a1, a2, a3); +export { a2 }; + +// first binding +const b1 = 1, b2 = 2; +console.log(b1, b2); +export { b1 }; + +// last binding +const c1 = 1, c2 = 2; +console.log(c1, c2); +export { c2 }; + +// middle binding with other bindings removed +const d1 = 1, d2 = 2, d3 = 3; +export { d2 }; + +// uninitialized binding +let e1 = 1, e2, e3 = 3; +console.log(e1, e2, e3); +export { e2 }; + +// destructuring declaration +let {f1, f2} = globalThis.obj, {f3} = globalThis.obj; +export { f2 }; diff --git a/test/form/samples/system-export-destructuring-assignment/_config.js b/test/form/samples/system-export-destructuring-assignment/_config.js deleted file mode 100644 index 82ec35dd48d..00000000000 --- a/test/form/samples/system-export-destructuring-assignment/_config.js +++ /dev/null @@ -1,8 +0,0 @@ -module.exports = { - description: 'supports destructuring assignments of exports for systemJS', - options: { - output: { - format: 'system' - } - } -}; diff --git a/test/form/samples/system-export-destructuring-assignment/_expected.js b/test/form/samples/system-export-destructuring-assignment/_expected.js deleted file mode 100644 index 37d18c89069..00000000000 --- a/test/form/samples/system-export-destructuring-assignment/_expected.js +++ /dev/null @@ -1,19 +0,0 @@ -System.register([], function (exports) { - 'use strict'; - return { - execute: function () { - - exports({ - a: void 0, - b: void 0, - c: void 0 - }); - - let a, b, c; - - console.log((function (v) { return exports({ a: a }), v; }({a} = someObject))); - ((function (v) { return exports({ b: b, c: c }), v; }({b, c} = someObject))); - - } - }; -}); diff --git a/test/form/samples/system-export-destructuring-assignment/main.js b/test/form/samples/system-export-destructuring-assignment/main.js deleted file mode 100644 index 5f3831cdff7..00000000000 --- a/test/form/samples/system-export-destructuring-assignment/main.js +++ /dev/null @@ -1,4 +0,0 @@ -export let a, b, c; - -console.log({a} = someObject); -({b, c} = someObject); diff --git a/test/form/samples/system-export-destructuring-declaration/_config.js b/test/form/samples/system-export-destructuring-declaration/_config.js index db198f829d5..7bfd1fc2319 100644 --- a/test/form/samples/system-export-destructuring-declaration/_config.js +++ b/test/form/samples/system-export-destructuring-declaration/_config.js @@ -1,8 +1,8 @@ -module.exports = { +module.exports = defineTest({ description: 'supports destructuring declarations for systemJS', options: { output: { format: 'system' } } -}; +}); diff --git a/test/form/samples/system-export-destructuring-declaration/_expected.js b/test/form/samples/system-export-destructuring-declaration/_expected.js index 6e2ba2be402..47ea562c655 100644 --- a/test/form/samples/system-export-destructuring-declaration/_expected.js +++ b/test/form/samples/system-export-destructuring-declaration/_expected.js @@ -1,15 +1,17 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - const {a = 1, ...b} = global1, c = exports('c', global2), {d} = global3; exports({ a: a, b: b, d: d }); + const {a = 1, ...b} = global1, c = global2, {d} = global3; exports({ a: a, b: b, c: c, d: d }); const [e, ...f] = global4; exports({ e: e, f: f }); const {g, x: h = 2, y: {z: i}, a: [j ,k,, l]} = global5; exports({ g: g, h: h, i: i, j: j, k: k, l: l }); - var m = exports('m', 1); - var {m} = global6; exports('m', m); + var m = exports("m", 1); + var {m} = global6; exports("m", m); - } + (function (v) { return exports("m", m), v; })({m} = global7); + + }) }; -}); +})); diff --git a/test/form/samples/system-export-destructuring-declaration/main.js b/test/form/samples/system-export-destructuring-declaration/main.js index aacc41461f2..1433c43e60d 100644 --- a/test/form/samples/system-export-destructuring-declaration/main.js +++ b/test/form/samples/system-export-destructuring-declaration/main.js @@ -4,3 +4,5 @@ export const {g, x: h = 2, y: {z: i}, a: [j ,k,, l]} = global5; export var m = 1; var {m} = global6; + +null, {m} = global7; diff --git a/test/form/samples/system-export-rendering-compact/_config.js b/test/form/samples/system-export-rendering-compact/_config.js new file mode 100644 index 00000000000..a9033223df1 --- /dev/null +++ b/test/form/samples/system-export-rendering-compact/_config.js @@ -0,0 +1,9 @@ +module.exports = defineTest({ + description: 'Renders updates of exported variables for SystemJS output in compact mode', + options: { + output: { + format: 'system', + compact: true + } + } +}); diff --git a/test/form/samples/system-export-rendering-compact/_expected.js b/test/form/samples/system-export-rendering-compact/_expected.js new file mode 100644 index 00000000000..c83c5b4051a --- /dev/null +++ b/test/form/samples/system-export-rendering-compact/_expected.js @@ -0,0 +1,55 @@ +System.register([],(function(exports){'use strict';return{execute:(function(){// --- +// Single export name +let foo = exports("foo",1); + +// Assignment +// foo = 2 +exports("foo",foo = 2); +console.log(exports("foo",foo = 2)); + +// foo += 2 +exports("foo",foo += 2); +console.log(exports("foo",foo += 2)); + +// { foo } = obj +(function(v){return exports("foo",foo),v}({ foo } = obj)); +console.log(function(v){return exports("foo",foo),v}({ foo } = obj)); + +// Update +// foo++ +exports("foo",foo+1),foo++; +console.log((exports("foo",foo+1),foo++)); +exports("foo",foo-1),foo--; + +// ++foo +exports("foo",++foo); +console.log(exports("foo",++foo)); +exports("foo",--foo); + +// --- +// Multiple export names +let bar = 1; exports({bar:bar,bar2:bar}); + +// Assignment +// bar = 2 +bar = 2,exports({bar:bar,bar2:bar}),bar; +console.log((bar = 2,exports({bar:bar,bar2:bar}),bar)); + +// bar += 2 +bar += 2,exports({bar:bar,bar2:bar}),bar; +console.log((bar += 2,exports({bar:bar,bar2:bar}),bar)); + +// { bar } = obj +(function(v){return exports({bar:bar,bar2:bar}),v}({ bar } = obj)); +console.log(function(v){return exports({bar:bar,bar2:bar}),v}({ bar } = obj)); + +// Update +// bar++ +exports({bar:bar+1,bar2:bar+1}),bar++; +console.log((exports({bar:bar+1,bar2:bar+1}),bar++)); +exports({bar:bar-1,bar2:bar-1}),bar--; + +// ++bar +++bar,exports({bar:bar,bar2:bar}),bar; +console.log((++bar,exports({bar:bar,bar2:bar}),bar)); +--bar,exports({bar:bar,bar2:bar}),bar;})}})); \ No newline at end of file diff --git a/test/form/samples/system-export-rendering-compact/main.js b/test/form/samples/system-export-rendering-compact/main.js new file mode 100644 index 00000000000..3ab355b4663 --- /dev/null +++ b/test/form/samples/system-export-rendering-compact/main.js @@ -0,0 +1,56 @@ +// --- +// Single export name +export let foo = 1; + +// Assignment +// foo = 2 +foo = 2; +console.log(foo = 2); + +// foo += 2 +foo += 2; +console.log(foo += 2); + +// { foo } = obj +({ foo } = obj); +console.log({ foo } = obj); + +// Update +// foo++ +foo++; +console.log(foo++); +foo--; + +// ++foo +++foo; +console.log(++foo); +--foo; + +// --- +// Multiple export names +export let bar = 1; +export { bar as bar2 }; + +// Assignment +// bar = 2 +bar = 2; +console.log(bar = 2); + +// bar += 2 +bar += 2; +console.log(bar += 2); + +// { bar } = obj +({ bar } = obj); +console.log({ bar } = obj); + +// Update +// bar++ +bar++; +console.log(bar++); +bar--; + +// ++bar +++bar; +console.log(++bar); +--bar; diff --git a/test/form/samples/system-export-rendering/_config.js b/test/form/samples/system-export-rendering/_config.js new file mode 100644 index 00000000000..843cea4565a --- /dev/null +++ b/test/form/samples/system-export-rendering/_config.js @@ -0,0 +1,8 @@ +module.exports = defineTest({ + description: 'Renders updates of exported variables for SystemJS output', + options: { + output: { + format: 'system' + } + } +}); diff --git a/test/form/samples/system-export-rendering/_expected.js b/test/form/samples/system-export-rendering/_expected.js new file mode 100644 index 00000000000..5ff33652780 --- /dev/null +++ b/test/form/samples/system-export-rendering/_expected.js @@ -0,0 +1,64 @@ +System.register([], (function (exports) { + 'use strict'; + return { + execute: (function () { + + // --- + // Single export name + let foo = exports("foo", 1); + + // Assignment + // foo = 2 + exports("foo", foo = 2); + console.log(exports("foo", foo = 2)); + + // foo += 2 + exports("foo", foo += 2); + console.log(exports("foo", foo += 2)); + + // { foo } = obj + (function (v) { return exports("foo", foo), v; }({ foo } = obj)); + console.log(function (v) { return exports("foo", foo), v; }({ foo } = obj)); + + // Update + // foo++ + exports("foo", foo + 1), foo++; + console.log((exports("foo", foo + 1), foo++)); + exports("foo", foo - 1), foo--; + + // ++foo + exports("foo", ++foo); + console.log(exports("foo", ++foo)); + exports("foo", --foo); + + // --- + // Multiple export names + let bar = 1; exports({ bar: bar, bar2: bar }); + + // Assignment + // bar = 2 + bar = 2, exports({ bar: bar, bar2: bar }), bar; + console.log((bar = 2, exports({ bar: bar, bar2: bar }), bar)); + + // bar += 2 + bar += 2, exports({ bar: bar, bar2: bar }), bar; + console.log((bar += 2, exports({ bar: bar, bar2: bar }), bar)); + + // { bar } = obj + (function (v) { return exports({ bar: bar, bar2: bar }), v; }({ bar } = obj)); + console.log(function (v) { return exports({ bar: bar, bar2: bar }), v; }({ bar } = obj)); + + // Update + // bar++ + exports({ bar: bar + 1, bar2: bar + 1 }), bar++; + console.log((exports({ bar: bar + 1, bar2: bar + 1 }), bar++)); + exports({ bar: bar - 1, bar2: bar - 1 }), bar--; + + // ++bar + ++bar, exports({ bar: bar, bar2: bar }), bar; + console.log((++bar, exports({ bar: bar, bar2: bar }), bar)); + --bar, exports({ bar: bar, bar2: bar }), bar; + + }) + }; +})); diff --git a/test/form/samples/system-export-rendering/main.js b/test/form/samples/system-export-rendering/main.js new file mode 100644 index 00000000000..3ab355b4663 --- /dev/null +++ b/test/form/samples/system-export-rendering/main.js @@ -0,0 +1,56 @@ +// --- +// Single export name +export let foo = 1; + +// Assignment +// foo = 2 +foo = 2; +console.log(foo = 2); + +// foo += 2 +foo += 2; +console.log(foo += 2); + +// { foo } = obj +({ foo } = obj); +console.log({ foo } = obj); + +// Update +// foo++ +foo++; +console.log(foo++); +foo--; + +// ++foo +++foo; +console.log(++foo); +--foo; + +// --- +// Multiple export names +export let bar = 1; +export { bar as bar2 }; + +// Assignment +// bar = 2 +bar = 2; +console.log(bar = 2); + +// bar += 2 +bar += 2; +console.log(bar += 2); + +// { bar } = obj +({ bar } = obj); +console.log({ bar } = obj); + +// Update +// bar++ +bar++; +console.log(bar++); +bar--; + +// ++bar +++bar; +console.log(++bar); +--bar; diff --git a/test/form/samples/system-module-reserved/_config.js b/test/form/samples/system-module-reserved/_config.js index 0da470d6610..e075c35824c 100644 --- a/test/form/samples/system-module-reserved/_config.js +++ b/test/form/samples/system-module-reserved/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'does not output reserved system format identifiers', options: { external: ['test'], @@ -7,4 +7,4 @@ module.exports = { globals: { test: 'test' } } } -}; +}); diff --git a/test/form/samples/system-module-reserved/_expected/amd.js b/test/form/samples/system-module-reserved/_expected/amd.js index 488ded02f9b..86042a75da3 100644 --- a/test/form/samples/system-module-reserved/_expected/amd.js +++ b/test/form/samples/system-module-reserved/_expected/amd.js @@ -1,5 +1,5 @@ -define(['test'], function (test) { 'use strict'; +define(['test'], (function (test) { 'use strict'; console.log(test.module, test.other); -}); +})); diff --git a/test/form/samples/system-module-reserved/_expected/es.js b/test/form/samples/system-module-reserved/_expected/es.js index 971dfd52efc..e81bbb4e657 100644 --- a/test/form/samples/system-module-reserved/_expected/es.js +++ b/test/form/samples/system-module-reserved/_expected/es.js @@ -1,3 +1,3 @@ -import { module, other } from 'test'; +import { module as module$1, other } from 'test'; -console.log(module, other); +console.log(module$1, other); diff --git a/test/form/samples/system-module-reserved/_expected/iife.js b/test/form/samples/system-module-reserved/_expected/iife.js index 6f0152b4b41..1d46e16850b 100644 --- a/test/form/samples/system-module-reserved/_expected/iife.js +++ b/test/form/samples/system-module-reserved/_expected/iife.js @@ -3,4 +3,4 @@ console.log(test.module, test.other); -}(test)); +})(test); diff --git a/test/form/samples/system-module-reserved/_expected/system.js b/test/form/samples/system-module-reserved/_expected/system.js index dd6fda8d273..945afaa55e8 100644 --- a/test/form/samples/system-module-reserved/_expected/system.js +++ b/test/form/samples/system-module-reserved/_expected/system.js @@ -1,4 +1,4 @@ -System.register('systemReserved', ['test'], function () { +System.register('systemReserved', ['test'], (function () { 'use strict'; var module$1, other; return { @@ -6,10 +6,10 @@ System.register('systemReserved', ['test'], function () { module$1 = module.module; other = module.other; }], - execute: function () { + execute: (function () { console.log(module$1, other); - } + }) }; -}); +})); diff --git a/test/form/samples/system-module-reserved/_expected/umd.js b/test/form/samples/system-module-reserved/_expected/umd.js index 45ef58765d1..dba95d9f931 100644 --- a/test/form/samples/system-module-reserved/_expected/umd.js +++ b/test/form/samples/system-module-reserved/_expected/umd.js @@ -2,8 +2,8 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('test')) : typeof define === 'function' && define.amd ? define(['test'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.test)); -}(this, (function (test) { 'use strict'; +})(this, (function (test) { 'use strict'; console.log(test.module, test.other); -}))); +})); diff --git a/test/form/samples/system-multiple-export-bindings/_config.js b/test/form/samples/system-multiple-export-bindings/_config.js index 3756936c774..dd6093f9600 100644 --- a/test/form/samples/system-multiple-export-bindings/_config.js +++ b/test/form/samples/system-multiple-export-bindings/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'supports multiple live bindings for the same symbol in systemJS', options: { output: { @@ -6,4 +6,4 @@ module.exports = { exports: 'named' } } -}; +}); diff --git a/test/form/samples/system-multiple-export-bindings/_expected.js b/test/form/samples/system-multiple-export-bindings/_expected.js index c72502e8b94..13eb2d55243 100644 --- a/test/form/samples/system-multiple-export-bindings/_expected.js +++ b/test/form/samples/system-multiple-export-bindings/_expected.js @@ -1,15 +1,15 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { exports({ fn: fn, fn2: fn }); - const x = exports('x', 123); - const y = exports('y', 456); + const x = exports("x", 123); + const y = exports("y", 456); var namespace = /*#__PURE__*/Object.freeze({ __proto__: null, @@ -21,35 +21,35 @@ System.register([], function (exports) { // Namespace variable // Variable Declaration - let a = function (v) { return exports({ a: v, a2: v }), v; }(1), b = exports('b', 2), c = function (v) { return exports({ c: v, c2: v }), v; }(3); + let a = 1, b = 2, c = 3; exports({ a: a, a2: a, b: b, c: c, c2: c }); // Export default expression - var a$1 = exports('default', a); + var a_default = exports("default", a); // Assignment Expression - a = function (v) { return exports({ a: v, a2: v }), v; }(b = exports('b', c = function (v) { return exports({ c: v, c2: v }), v; }(0))); + a = exports("b", b = (c = 0, exports({ c: c, c2: c }), c)), exports({ a: a, a2: a }), a; // Destructing Assignment Expression - ((function (v) { return exports({ a: a, a2: a, b: b, c: c, c2: c }), v; }({ a, b, c } = { c: 4, b: 5, a: 6 }))); + (function (v) { return exports({ a: a, a2: a, b: b, c: c, c2: c }), v; }({ a, b, c } = { c: 4, b: 5, a: 6 })); // Destructuring Defaults - var p = function (v) { return exports({ p: v, pp: v }), v; }(5); - var q = function (v) { return exports({ q: v, qq: v }), v; }(10); - ((function (v) { return exports({ p: p, pp: p }), v; }({ p = q = function (v) { return exports({ q: v, qq: v }), v; }(20) } = {}))); + var p = 5; exports({ p: p, pp: p }); + var q = 10; exports({ q: q, qq: q }); + (function (v) { return exports({ p: p, pp: p }), v; }({ p = (q = 20, exports({ q: q, qq: q }), q) } = {})); // Function Assignment function fn () { } - fn = function (v) { return exports({ fn: v, fn2: v }), v; }(5); + fn = 5, exports({ fn: fn, fn2: fn }), fn; // Update Expression - (function (v) { return exports({ a: v, a2: v }), v; }(++a)), (exports('b', b + 1), b++), (++c, exports({ c: c, c2: c }), c); - (function (v) { return exports({ a: v, a2: v }), v; }(++a)); + (exports({ a: a + 1, a2: a + 1 }), a++), (exports("b", b + 1), b++), (++c, exports({ c: c, c2: c }), c); + (exports({ a: a + 1, a2: a + 1 }), a++); // Class Declaration class A {} exports({ A: A, B: A }); - } + }) }; -}); +})); diff --git a/test/form/samples/system-null-setters/_config.js b/test/form/samples/system-null-setters/_config.js new file mode 100644 index 00000000000..1e743cbf829 --- /dev/null +++ b/test/form/samples/system-null-setters/_config.js @@ -0,0 +1,10 @@ +module.exports = defineTest({ + description: 'allows to avoid null setters for side effect only imports', + options: { + external: ['external'], + output: { + format: 'system', + systemNullSetters: false + } + } +}); diff --git a/test/form/samples/system-null-setters/_expected.js b/test/form/samples/system-null-setters/_expected.js new file mode 100644 index 00000000000..664e7499cd3 --- /dev/null +++ b/test/form/samples/system-null-setters/_expected.js @@ -0,0 +1,11 @@ +System.register(['external'], (function () { + 'use strict'; + return { + setters: [function () {}], + execute: (function () { + + + + }) + }; +})); diff --git a/test/form/samples/system-null-setters/main.js b/test/form/samples/system-null-setters/main.js new file mode 100644 index 00000000000..007d6fbc2da --- /dev/null +++ b/test/form/samples/system-null-setters/main.js @@ -0,0 +1,2 @@ +import 'external'; + diff --git a/test/form/samples/system-reexports/_config.js b/test/form/samples/system-reexports/_config.js new file mode 100644 index 00000000000..589a68d7d3e --- /dev/null +++ b/test/form/samples/system-reexports/_config.js @@ -0,0 +1,7 @@ +module.exports = defineTest({ + description: 'merges reexports in systemjs', + options: { + external: () => true, + output: { format: 'system' } + } +}); diff --git a/test/form/samples/system-reexports/_expected.js b/test/form/samples/system-reexports/_expected.js new file mode 100644 index 00000000000..9f467a4eeec --- /dev/null +++ b/test/form/samples/system-reexports/_expected.js @@ -0,0 +1,39 @@ +System.register(['external1', 'external2', 'external3', 'external4', 'external5'], (function (exports) { + 'use strict'; + var _starExcludes = { + __proto__: null, + default: 1, + namedReexport1: 1, + namedReexport2a: 1, + namedReexport2b: 1, + namespaceReexport3: 1, + namedReexport5: 1, + namespaceReexport5: 1 + }; + return { + setters: [function (module) { + exports("namedReexport1", module.namedReexport1); + }, function (module) { + exports({ namedReexport2a: module.namedReexport2a, namedReexport2b: module.default }); + }, function (module) { + exports("namespaceReexport3", module); + }, function (module) { + var setter = { __proto__: null }; + for (var name in module) { + if (!_starExcludes[name]) setter[name] = module[name]; + } + exports(setter); + }, function (module) { + var setter = { __proto__: null, namedReexport5: module.namedReexport5, namespaceReexport5: module }; + for (var name in module) { + if (!_starExcludes[name]) setter[name] = module[name]; + } + exports(setter); + }], + execute: (function () { + + + + }) + }; +})); diff --git a/test/form/samples/system-reexports/main.js b/test/form/samples/system-reexports/main.js new file mode 100644 index 00000000000..750ad5d7dfc --- /dev/null +++ b/test/form/samples/system-reexports/main.js @@ -0,0 +1,12 @@ +export { namedReexport1 } from 'external1'; + +export { namedReexport2a } from 'external2'; +export { default as namedReexport2b } from 'external2'; + +export * as namespaceReexport3 from 'external3'; + +export * from 'external4'; + +export { namedReexport5 } from 'external5'; +export * as namespaceReexport5 from 'external5'; +export * from 'external5'; diff --git a/test/form/samples/system-reexports/system.js b/test/form/samples/system-reexports/system.js new file mode 100644 index 00000000000..af5613225f7 --- /dev/null +++ b/test/form/samples/system-reexports/system.js @@ -0,0 +1,26 @@ +System.register([], (function () { + 'use strict'; + return { + execute: (function () { + + var effect1 = () => console.log( 'effect' ); // must not be removed! + function isKept1 ( x = effect1 ) { + x(); + } + isKept1(); + + var effect2 = () => console.log( 'effect' ); // must not be removed! + var isKept2 = function ( x = effect2 ) { + x(); + }; + isKept2(); + + var effect3 = () => console.log( 'effect' ); // must not be removed! + var isKept3 = ( x = effect3 ) => { + x(); + }; + isKept3(); + + }) + }; +})); diff --git a/test/form/samples/system-semicolon/_config.js b/test/form/samples/system-semicolon/_config.js index 224cae88f2f..4fc44dcd580 100644 --- a/test/form/samples/system-semicolon/_config.js +++ b/test/form/samples/system-semicolon/_config.js @@ -1,8 +1,8 @@ -module.exports = { +module.exports = defineTest({ description: 'supports asi in system binding output', options: { output: { format: 'system' } } -}; +}); diff --git a/test/form/samples/system-semicolon/_expected.js b/test/form/samples/system-semicolon/_expected.js index c7c7ae0cb9b..c47366bdb60 100644 --- a/test/form/samples/system-semicolon/_expected.js +++ b/test/form/samples/system-semicolon/_expected.js @@ -1,12 +1,12 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - var main = exports('default', typeof global !== "undefined" ? global : + var main = exports("default", typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}); - } + }) }; -}); +})); diff --git a/test/form/samples/system-uninitialized/_config.js b/test/form/samples/system-uninitialized/_config.js index 2ff19964cbd..685acc69dcf 100644 --- a/test/form/samples/system-uninitialized/_config.js +++ b/test/form/samples/system-uninitialized/_config.js @@ -1,11 +1,8 @@ -// Changed due to https://github.com/acornjs/acorn/issues/806 -// Consider reverting this change should this become an acorn option - -module.exports = { +module.exports = defineTest({ description: 'supports uninitialized binding exports', options: { output: { format: 'system' } } -}; +}); diff --git a/test/form/samples/system-uninitialized/_expected.js b/test/form/samples/system-uninitialized/_expected.js index 15dbebf0095..d9653c67b39 100644 --- a/test/form/samples/system-uninitialized/_expected.js +++ b/test/form/samples/system-uninitialized/_expected.js @@ -1,18 +1,15 @@ -System.register([], function (exports) { +System.register([], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - exports({ - p: void 0, - q: q - }); + exports("q", q); - var p; + var p; exports("p", p); function q () { - p = exports('p', 10); + exports("p", p = 10); } - } + }) }; -}); +})); diff --git a/test/form/samples/tdz-access-in-declaration/_config.js b/test/form/samples/tdz-access-in-declaration/_config.js new file mode 100644 index 00000000000..05017512a52 --- /dev/null +++ b/test/form/samples/tdz-access-in-declaration/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'detect accessing TDZ variables within the declaration' +}); diff --git a/test/form/samples/tdz-access-in-declaration/_expected.js b/test/form/samples/tdz-access-in-declaration/_expected.js new file mode 100644 index 00000000000..dfb1cc54fcb --- /dev/null +++ b/test/form/samples/tdz-access-in-declaration/_expected.js @@ -0,0 +1,13 @@ +const a = a; // keep + +const b = getB(); // keep +function getB() { + return b; +} + +function getC() { + return c; +} +const c = getC(); // keep + +class d extends d {} // keep diff --git a/test/form/samples/tdz-access-in-declaration/main.js b/test/form/samples/tdz-access-in-declaration/main.js new file mode 100644 index 00000000000..dfb1cc54fcb --- /dev/null +++ b/test/form/samples/tdz-access-in-declaration/main.js @@ -0,0 +1,13 @@ +const a = a; // keep + +const b = getB(); // keep +function getB() { + return b; +} + +function getC() { + return c; +} +const c = getC(); // keep + +class d extends d {} // keep diff --git a/test/form/samples/tdz-common/_config.js b/test/form/samples/tdz-common/_config.js new file mode 100644 index 00000000000..27cc234e89a --- /dev/null +++ b/test/form/samples/tdz-common/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'preserve common TDZ violations' +}); diff --git a/test/form/samples/tdz-common/_expected.js b/test/form/samples/tdz-common/_expected.js new file mode 100644 index 00000000000..1a42cdb10ee --- /dev/null +++ b/test/form/samples/tdz-common/_expected.js @@ -0,0 +1,56 @@ +console.log(function() { + if (x) return "HELLO"; // TDZ + const x = 1; // keep + return "WORLD"; // not reached +}()); + +const C = 1 + C + 2; // TDZ +let L = L; // TDZ +console.log("X+" ); // optimize + +console.log(Y ? "Y+" : "Y-"); // TDZ +const Y = 2; // keep + +console.log(Z ? "Z+" : "Z-"); // TDZ +const Z = 3; // keep +console.log("Z+" ); // keep + +console.log(obj.x.y ? 1 : 2); // TDZ +const obj = { // keep + x: { + y: true + } +}; +console.log(3 ); // keep + +L2; // TDZ for L2 +L3 = 20; // TDZ for L3 +let L2, L3; // keep L2, L3 +L3 = 30; // keep + +cls; // TDZ +class cls {} + +// Note that typical var/const/let use is still optimized +(function() { + console.log(A ? "A" : "!A"); + var A = 1; + console.log("A" ); + console.log("B"); + console.log("B" ); + console.log("C" ); + console.log("D" ); +})(); + +(function let_tdz() { + let flag = false; + function foo() { + if (flag) { + value; // TDZ + } + let value; + } + foo(); + flag = true; + foo(); +})(); diff --git a/test/form/samples/tdz-common/main.js b/test/form/samples/tdz-common/main.js new file mode 100644 index 00000000000..dabb32af0e6 --- /dev/null +++ b/test/form/samples/tdz-common/main.js @@ -0,0 +1,80 @@ +console.log(function() { + if (x) return "HELLO"; // TDZ + const x = 1; // keep + return "WORLD"; // not reached +}()); + +const unused1 = 1; // drop +let unused2 = 2; // drop +unused3; // drop +var unused3 = 3; // drop +class unused4 {} // drop + +const C = 1 + C + 2; // TDZ +let L = L; // TDZ + +const X = 1; // drop +console.log(X ? "X+" : "X-"); // optimize + +console.log(Y ? "Y+" : "Y-"); // TDZ +const Y = 2; // keep + +console.log(Z ? "Z+" : "Z-"); // TDZ +const Z = 3; // keep +console.log(Z ? "Z+" : "Z-"); // keep + +console.log(obj.x.y ? 1 : 2); // TDZ +const obj = { // keep + x: { + y: true + } +}; +console.log(obj.x.y ? 3 : 4); // keep + +V2, L2; // TDZ for L2 +var V2; // drop +V3 = 10, L3 = 20; // TDZ for L3 +let L1, L2, L3, L4; // keep L2, L3 +var V3; // drop +L3 = 30; // keep +L4 = 40; // drop + +cls; // TDZ +class cls {} + +// Note that typical var/const/let use is still optimized +(function() { + console.log(A ? "A" : "!A"); + var A = 1, B = 2; + const C = 3; + let D = 4; + console.log(A ? "A" : "!A"); + if (B) console.log("B"); + else console.log("!B"); + console.log(B ? "B" : "!B"); + console.log(C ? "C" : "!C"); + console.log(D ? "D" : "!D"); +})(); + +(function let_tdz() { + let flag = false; + function foo() { + if (flag) { + value; // TDZ + } + let value; + } + foo(); + flag = true; + foo(); +})(); + +// should be dropped +(function() { + function foo() { + const access = () => value; + let value; + access(); + }; + foo(); +})(); diff --git a/test/form/samples/tdz-pattern-access/_config.js b/test/form/samples/tdz-pattern-access/_config.js new file mode 100644 index 00000000000..c62bbc85985 --- /dev/null +++ b/test/form/samples/tdz-pattern-access/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'handles accessing variables declared in patterns before their declaration' +}); diff --git a/test/form/samples/tdz-pattern-access/_expected.js b/test/form/samples/tdz-pattern-access/_expected.js new file mode 100644 index 00000000000..44e35fc1981 --- /dev/null +++ b/test/form/samples/tdz-pattern-access/_expected.js @@ -0,0 +1,8 @@ +x + y; +const { x } = {}; +const [y] = []; + +if (z) console.log('unimportant'); +else console.log('retained'); + +var { z } = { z: true }; diff --git a/test/form/samples/tdz-pattern-access/main.js b/test/form/samples/tdz-pattern-access/main.js new file mode 100644 index 00000000000..847dbb3bc06 --- /dev/null +++ b/test/form/samples/tdz-pattern-access/main.js @@ -0,0 +1,8 @@ +const tdzAccess = x + y; +const { x } = {}; +const [y] = []; + +if (z) console.log('unimportant'); +else console.log('retained'); + +var { z } = { z: true }; diff --git a/test/form/samples/template-literal/computed-properties/_config.js b/test/form/samples/template-literal/computed-properties/_config.js index 85451aa7e27..0dc3474cb31 100644 --- a/test/form/samples/template-literal/computed-properties/_config.js +++ b/test/form/samples/template-literal/computed-properties/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'Resolve template literals in computed property keys' -}; +}); diff --git a/test/form/samples/template-literal/simplify-conditionals/_config.js b/test/form/samples/template-literal/simplify-conditionals/_config.js index 47e0a8f442d..11d57dc3dd7 100644 --- a/test/form/samples/template-literal/simplify-conditionals/_config.js +++ b/test/form/samples/template-literal/simplify-conditionals/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'Template literals can be simplified when used in conditionals' -}; +}); diff --git a/test/form/samples/this-in-class-body/_config.js b/test/form/samples/this-in-class-body/_config.js new file mode 100644 index 00000000000..3f970f301a3 --- /dev/null +++ b/test/form/samples/this-in-class-body/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'uses the correct "this" value in class properties' +}); diff --git a/test/form/samples/this-in-class-body/_expected.js b/test/form/samples/this-in-class-body/_expected.js new file mode 100644 index 00000000000..ffc2e565be4 --- /dev/null +++ b/test/form/samples/this-in-class-body/_expected.js @@ -0,0 +1,37 @@ +class Used { + static flag = false; + static mutate = () => { + this.flag = true; + }; +} +Used.mutate(); + +if (Used.flag) console.log('retained'); +else console.log('unimportant'); + +class InstanceMutation { + static flag = false; + flag = false; + mutate = () => { + this.flag = true; + }; +} +new InstanceMutation().mutate(); + +console.log('retained'); + +class UsedSuper { + static flag = false; +} +class UsedWithSuper extends UsedSuper { + static mutate = () => { + super.flag = true; + }; +} +UsedWithSuper.mutate(); + +if (UsedWithSuper.flag) console.log('retained'); +else console.log('unimportant'); + +// Assignments via "super" do NOT mutate the super class! +console.log('retained'); diff --git a/test/form/samples/this-in-class-body/main.js b/test/form/samples/this-in-class-body/main.js new file mode 100644 index 00000000000..a02119ea207 --- /dev/null +++ b/test/form/samples/this-in-class-body/main.js @@ -0,0 +1,47 @@ +class Unused { + static flag = false; + static mutate = () => { + this.flag = true; + }; +} +Unused.mutate(); + +class Used { + static flag = false; + static mutate = () => { + this.flag = true; + }; +} +Used.mutate(); + +if (Used.flag) console.log('retained'); +else console.log('unimportant'); + +class InstanceMutation { + static flag = false; + flag = false; + mutate = () => { + this.flag = true; + }; +} +new InstanceMutation().mutate(); + +if (InstanceMutation.flag) console.log('removed'); +else console.log('retained'); + +class UsedSuper { + static flag = false; +} +class UsedWithSuper extends UsedSuper { + static mutate = () => { + super.flag = true; + }; +} +UsedWithSuper.mutate(); + +if (UsedWithSuper.flag) console.log('retained'); +else console.log('unimportant'); + +// Assignments via "super" do NOT mutate the super class! +if (UsedSuper.flag) console.log('removed'); +else console.log('retained'); diff --git a/test/form/samples/this-in-imports/_config.js b/test/form/samples/this-in-imports/_config.js index 968d0327b35..a31fabfa411 100644 --- a/test/form/samples/this-in-imports/_config.js +++ b/test/form/samples/this-in-imports/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'properly keep or ignore "this"-expressions when calling imported functions' -}; +}); diff --git a/test/form/samples/this-is-undefined/_config.js b/test/form/samples/this-is-undefined/_config.js index 75134029384..d9622af3c10 100644 --- a/test/form/samples/this-is-undefined/_config.js +++ b/test/form/samples/this-is-undefined/_config.js @@ -1,6 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'top-level `this` expression is rewritten as `undefined`', - options: { - onwarn: () => {} - } -}; + expectedWarnings: ['THIS_IS_UNDEFINED'] +}); diff --git a/test/form/samples/this-is-undefined/_expected/amd.js b/test/form/samples/this-is-undefined/_expected/amd.js index c90e975185d..87b9c13c351 100644 --- a/test/form/samples/this-is-undefined/_expected/amd.js +++ b/test/form/samples/this-is-undefined/_expected/amd.js @@ -1,4 +1,4 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; const fooContext = {}; @@ -18,4 +18,4 @@ define(function () { 'use strict'; // outside a function, `this` is undefined assert.strictEqual( undefined, undefined ); -}); +})); diff --git a/test/form/samples/this-is-undefined/_expected/iife.js b/test/form/samples/this-is-undefined/_expected/iife.js index f82edce9c6c..06e976b27af 100644 --- a/test/form/samples/this-is-undefined/_expected/iife.js +++ b/test/form/samples/this-is-undefined/_expected/iife.js @@ -19,4 +19,4 @@ // outside a function, `this` is undefined assert.strictEqual( undefined, undefined ); -}()); +})(); diff --git a/test/form/samples/this-is-undefined/_expected/system.js b/test/form/samples/this-is-undefined/_expected/system.js index cf485fcc549..c172f6dae40 100644 --- a/test/form/samples/this-is-undefined/_expected/system.js +++ b/test/form/samples/this-is-undefined/_expected/system.js @@ -1,7 +1,7 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { const fooContext = {}; @@ -21,6 +21,6 @@ System.register([], function () { // outside a function, `this` is undefined assert.strictEqual( undefined, undefined ); - } + }) }; -}); +})); diff --git a/test/form/samples/this-is-undefined/_expected/umd.js b/test/form/samples/this-is-undefined/_expected/umd.js index ebe49fe5916..e8b192d8363 100644 --- a/test/form/samples/this-is-undefined/_expected/umd.js +++ b/test/form/samples/this-is-undefined/_expected/umd.js @@ -1,7 +1,7 @@ (function (factory) { typeof define === 'function' && define.amd ? define(factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; const fooContext = {}; @@ -21,4 +21,4 @@ // outside a function, `this` is undefined assert.strictEqual( undefined, undefined ); -}))); +})); diff --git a/test/form/samples/top-level-await/_config.js b/test/form/samples/top-level-await/_config.js index a572b8a99f0..2ed3902716c 100644 --- a/test/form/samples/top-level-await/_config.js +++ b/test/form/samples/top-level-await/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'top-level await support', formats: ['system', 'es'] -}; +}); diff --git a/test/form/samples/top-level-await/_expected/system.js b/test/form/samples/top-level-await/_expected/system.js index 14c43dfc074..f109ac1166b 100644 --- a/test/form/samples/top-level-await/_expected/system.js +++ b/test/form/samples/top-level-await/_expected/system.js @@ -1,12 +1,12 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: async function () { + execute: (async function () { await operation(); await retainedOperation(); - } + }) }; -}); +})); diff --git a/test/form/samples/tree-shake-arguments-conditional/_config.js b/test/form/samples/tree-shake-arguments-conditional/_config.js index 4390bfa586a..e5228acda32 100644 --- a/test/form/samples/tree-shake-arguments-conditional/_config.js +++ b/test/form/samples/tree-shake-arguments-conditional/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'tracks tree-shaking of arguments through simplified conditionals' -}; +}); diff --git a/test/form/samples/tree-shake-curried-functions/_config.js b/test/form/samples/tree-shake-curried-functions/_config.js index f022678d476..819de8801dd 100644 --- a/test/form/samples/tree-shake-curried-functions/_config.js +++ b/test/form/samples/tree-shake-curried-functions/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'Remove side-effect-free curried functions (#1263)', expectedWarnings: ['EMPTY_BUNDLE'] -}; +}); diff --git a/test/form/samples/tree-shake-default-exports/_config.js b/test/form/samples/tree-shake-default-exports/_config.js index 8b7be460d61..8ae42ad6db0 100644 --- a/test/form/samples/tree-shake-default-exports/_config.js +++ b/test/form/samples/tree-shake-default-exports/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'properly remove unused default exports' -}; +}); diff --git a/test/form/samples/tree-shake-default-exports/_expected/amd.js b/test/form/samples/tree-shake-default-exports/_expected/amd.js index fa3e3c3a440..ddd6976b476 100644 --- a/test/form/samples/tree-shake-default-exports/_expected/amd.js +++ b/test/form/samples/tree-shake-default-exports/_expected/amd.js @@ -1,4 +1,4 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; /* header 3 */ @@ -54,4 +54,4 @@ define(function () { 'use strict'; importedUsedFunction(); usedNamedFunction(); -}); +})); diff --git a/test/form/samples/tree-shake-default-exports/_expected/iife.js b/test/form/samples/tree-shake-default-exports/_expected/iife.js index 6be2f732727..b96ee3775ae 100644 --- a/test/form/samples/tree-shake-default-exports/_expected/iife.js +++ b/test/form/samples/tree-shake-default-exports/_expected/iife.js @@ -55,4 +55,4 @@ importedUsedFunction(); usedNamedFunction(); -}()); +})(); diff --git a/test/form/samples/tree-shake-default-exports/_expected/system.js b/test/form/samples/tree-shake-default-exports/_expected/system.js index e6e9a00d418..caf635fe6c8 100644 --- a/test/form/samples/tree-shake-default-exports/_expected/system.js +++ b/test/form/samples/tree-shake-default-exports/_expected/system.js @@ -1,7 +1,7 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { /* header 3 */ @@ -57,6 +57,6 @@ System.register([], function () { importedUsedFunction(); usedNamedFunction(); - } + }) }; -}); +})); diff --git a/test/form/samples/tree-shake-default-exports/_expected/umd.js b/test/form/samples/tree-shake-default-exports/_expected/umd.js index 416e9c52b92..000e1bf9cb6 100644 --- a/test/form/samples/tree-shake-default-exports/_expected/umd.js +++ b/test/form/samples/tree-shake-default-exports/_expected/umd.js @@ -1,7 +1,7 @@ (function (factory) { typeof define === 'function' && define.amd ? define(factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; /* header 3 */ @@ -57,4 +57,4 @@ importedUsedFunction(); usedNamedFunction(); -}))); +})); diff --git a/test/form/samples/tree-shake-global-variables/_config.js b/test/form/samples/tree-shake-global-variables/_config.js new file mode 100644 index 00000000000..fd7f618e7e7 --- /dev/null +++ b/test/form/samples/tree-shake-global-variables/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'retain Set, Map, WeakSet and WeakMap which called with array arguments' +}); diff --git a/test/form/samples/tree-shake-global-variables/_expected.js b/test/form/samples/tree-shake-global-variables/_expected.js new file mode 100644 index 00000000000..d164447d06d --- /dev/null +++ b/test/form/samples/tree-shake-global-variables/_expected.js @@ -0,0 +1,7 @@ +new Set([f()]); //retained + +new WeakSet([f()]); //retained + +new Map([['a', f()]]); //retained + +new WeakMap([[f(), 'a']]); //retained diff --git a/test/form/samples/tree-shake-global-variables/main.js b/test/form/samples/tree-shake-global-variables/main.js new file mode 100644 index 00000000000..32182ba5b91 --- /dev/null +++ b/test/form/samples/tree-shake-global-variables/main.js @@ -0,0 +1,23 @@ +new Set([f()]); //retained + +new Set(['a']); + +new Set(); + +new WeakSet([f()]); //retained + +new WeakSet([{}]); + +new WeakSet(); + +new Map([['a', f()]]); //retained + +new Map([['a', 'a']]); + +new Map(); + +new WeakMap([[f(), 'a']]); //retained + +new WeakMap([[{}, 'a']]); + +new WeakMap(); diff --git a/test/form/samples/tree-shake-if-statements/_config.js b/test/form/samples/tree-shake-if-statements/_config.js index 3debad2c2a7..c626947098c 100644 --- a/test/form/samples/tree-shake-if-statements/_config.js +++ b/test/form/samples/tree-shake-if-statements/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'tree-shake if-statements with a condition that can be evaluated' -}; +}); diff --git a/test/form/samples/tree-shake-literal-parameter/argument-assignment/_config.js b/test/form/samples/tree-shake-literal-parameter/argument-assignment/_config.js new file mode 100644 index 00000000000..1a210baea05 --- /dev/null +++ b/test/form/samples/tree-shake-literal-parameter/argument-assignment/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'argument assignment side-effect' +}); diff --git a/test/form/samples/tree-shake-literal-parameter/argument-assignment/_expected.js b/test/form/samples/tree-shake-literal-parameter/argument-assignment/_expected.js new file mode 100644 index 00000000000..f7cb2c16d5a --- /dev/null +++ b/test/form/samples/tree-shake-literal-parameter/argument-assignment/_expected.js @@ -0,0 +1,15 @@ +function add(a, b) { + let sum = 0; + for (let i = a; i < b; i++) { + sum += i; + } + return sum; +} + +function foo(a) { + // don't optimize to '0;' + a = 0; + console.log(a); +} + +console.log(foo(add(0, 100))); diff --git a/test/form/samples/tree-shake-literal-parameter/argument-assignment/main.js b/test/form/samples/tree-shake-literal-parameter/argument-assignment/main.js new file mode 100644 index 00000000000..d9b3646538f --- /dev/null +++ b/test/form/samples/tree-shake-literal-parameter/argument-assignment/main.js @@ -0,0 +1,15 @@ +function add(a, b) { + let sum = 0; + for (let i = a; i < b; i++) { + sum += i; + } + return sum; +} + +function foo(a) { + // don't optimize to '0;' + a = 0; + console.log(a) +} + +console.log(foo(add(0, 100))) diff --git a/test/form/samples/tree-shake-literal-parameter/do-not-optimize/_config.js b/test/form/samples/tree-shake-literal-parameter/do-not-optimize/_config.js new file mode 100644 index 00000000000..d16519b0931 --- /dev/null +++ b/test/form/samples/tree-shake-literal-parameter/do-not-optimize/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'do not tree-shake literal parameter cases' +}); diff --git a/test/form/samples/tree-shake-literal-parameter/do-not-optimize/_expected.js b/test/form/samples/tree-shake-literal-parameter/do-not-optimize/_expected.js new file mode 100644 index 00000000000..8e1230c7540 --- /dev/null +++ b/test/form/samples/tree-shake-literal-parameter/do-not-optimize/_expected.js @@ -0,0 +1,18 @@ +function foo(enable) { + console.log(enable ? 1 : 0); +} + +foo(1); + +function bar(f = foo) { + f(0); +} + +// global variable +g = function (enable) { + console.log(enable ? 1: 0); +}; + +g(1); + +export { bar }; diff --git a/test/form/samples/tree-shake-literal-parameter/do-not-optimize/main.js b/test/form/samples/tree-shake-literal-parameter/do-not-optimize/main.js new file mode 100644 index 00000000000..079d60a1be5 --- /dev/null +++ b/test/form/samples/tree-shake-literal-parameter/do-not-optimize/main.js @@ -0,0 +1,16 @@ +function foo(enable) { + console.log(enable ? 1 : 0); +} + +foo(1); + +export function bar(f = foo) { + f(0); +} + +// global variable +g = function (enable) { + console.log(enable ? 1: 0); +}; + +g(1); diff --git a/test/form/samples/tree-shake-literal-parameter/expression-cache/_config.js b/test/form/samples/tree-shake-literal-parameter/expression-cache/_config.js new file mode 100644 index 00000000000..697aea54b46 --- /dev/null +++ b/test/form/samples/tree-shake-literal-parameter/expression-cache/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'should update cache of logical and conditional expressions' +}); diff --git a/test/form/samples/tree-shake-literal-parameter/expression-cache/_expected.js b/test/form/samples/tree-shake-literal-parameter/expression-cache/_expected.js new file mode 100644 index 00000000000..8cee561823a --- /dev/null +++ b/test/form/samples/tree-shake-literal-parameter/expression-cache/_expected.js @@ -0,0 +1,14 @@ +function add1(a, b, enable) { + { + return a + b; + } +} + +function add2(a, b, enable) { + { + return a + b; + } +} + +console.log(add1(1, 2)); +console.log(add2(1, 2)); diff --git a/test/form/samples/tree-shake-literal-parameter/expression-cache/main.js b/test/form/samples/tree-shake-literal-parameter/expression-cache/main.js new file mode 100644 index 00000000000..4c1f739a1d5 --- /dev/null +++ b/test/form/samples/tree-shake-literal-parameter/expression-cache/main.js @@ -0,0 +1,16 @@ +function add1(a, b, enable) { + if (enable? true: false) { + return a + b; + } + return a - b; +} + +function add2(a, b, enable) { + if (enable && 1) { + return a + b; + } + return a - b; +} + +console.log(add1(1, 2, true)); +console.log(add2(1, 2, true)); \ No newline at end of file diff --git a/test/form/samples/tree-shake-literal-parameter/iife/_config.js b/test/form/samples/tree-shake-literal-parameter/iife/_config.js new file mode 100644 index 00000000000..789458177ac --- /dev/null +++ b/test/form/samples/tree-shake-literal-parameter/iife/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'tree-shake literal parameter for IIFE' +}); diff --git a/test/form/samples/tree-shake-literal-parameter/iife/_expected.js b/test/form/samples/tree-shake-literal-parameter/iife/_expected.js new file mode 100644 index 00000000000..3e6eaeced15 --- /dev/null +++ b/test/form/samples/tree-shake-literal-parameter/iife/_expected.js @@ -0,0 +1,32 @@ +const result1 = ((enable) => { + { + return 'enabled'; + } +})(); + +const result2 = (function (enable) { + { + return 'enabled'; + } +})(); + +const result3 = (function foo (enable) { + { + return 'enabled'; + } +})(); + +// lose track of iife +const result4 = (function foo (enable) { + if (enable) { + unknown_global_function(foo); + return 'enabled'; + } else { + return 'disabled'; + } +})(true); + +console.log(result1); +console.log(result2); +console.log(result3); +console.log(result4); diff --git a/test/form/samples/tree-shake-literal-parameter/iife/main.js b/test/form/samples/tree-shake-literal-parameter/iife/main.js new file mode 100644 index 00000000000..844a193c3ff --- /dev/null +++ b/test/form/samples/tree-shake-literal-parameter/iife/main.js @@ -0,0 +1,38 @@ +const result1 = ((enable) => { + if (enable) { + return 'enabled'; + } else { + return 'disabled'; + } +})(true); + +const result2 = (function (enable) { + if (enable) { + return 'enabled'; + } else { + return 'disabled'; + } +})(true); + +const result3 = (function foo (enable) { + if (enable) { + return 'enabled'; + } else { + return 'disabled'; + } +})(true); + +// lose track of iife +const result4 = (function foo (enable) { + if (enable) { + unknown_global_function(foo); + return 'enabled'; + } else { + return 'disabled'; + } +})(true); + +console.log(result1); +console.log(result2); +console.log(result3); +console.log(result4); diff --git a/test/form/samples/tree-shake-literal-parameter/import-function/_config.js b/test/form/samples/tree-shake-literal-parameter/import-function/_config.js new file mode 100644 index 00000000000..e4a54b5f90f --- /dev/null +++ b/test/form/samples/tree-shake-literal-parameter/import-function/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'set parameters to literal if all calls are literal' +}); diff --git a/test/form/samples/tree-shake-literal-parameter/import-function/_expected.js b/test/form/samples/tree-shake-literal-parameter/import-function/_expected.js new file mode 100644 index 00000000000..f9d8a0fd937 --- /dev/null +++ b/test/form/samples/tree-shake-literal-parameter/import-function/_expected.js @@ -0,0 +1,70 @@ +// export default +function add (a, b, enable) { + { + return a + b; + } +} + +function add1(a, b, enable) { + return a - b; +} + +function add2(a, b, enable) { + return a - b; +} + +// keep it +function add3(a, b, enable) { + if (enable) { + return a + b; + } + return a - b; +} + +// conditional expression +function add4(a, b, enable) { + { + return a + b; + } +} + +// export default +var arrowAdd = (a, b, enable) => { + { + return a + b; + } +}; + +const arrowAdd1 = (a, b, enable) => { + return a - b; +}; + +// keep it +const arrowAdd2 = (a, b, enable) => { + if (enable) { + return a + b; + } + return a - b; +}; + +// conditional expression +const arrowAdd3 = (a, b, enable) => { + { + return a + b; + } +}; + +function foo(bar) { + console.log(bar()); +} + +console.log(add(1, 2)); +console.log(add1(1, 2)); +console.log(add2(1, 2)); // unused argument should be treated as undefined +console.log(foo(add3)); +console.log(add4(1, 2)); + +console.log(arrowAdd(1, 2)); +console.log(arrowAdd1(1, 2)); +console.log(foo(arrowAdd2)); +console.log(arrowAdd3(1, 2)); diff --git a/test/form/samples/tree-shake-literal-parameter/import-function/arrow_lib.js b/test/form/samples/tree-shake-literal-parameter/import-function/arrow_lib.js new file mode 100644 index 00000000000..8b85efc44a7 --- /dev/null +++ b/test/form/samples/tree-shake-literal-parameter/import-function/arrow_lib.js @@ -0,0 +1,30 @@ +// export default +export default (a, b, enable) => { + if (enable) { + return a + b; + } + return a - b; +} + +export const arrowAdd1 = (a, b, enable) => { + if (enable) { + return a + b; + } + return a - b; +} + +// keep it +export const arrowAdd2 = (a, b, enable) => { + if (enable) { + return a + b; + } + return a - b; +} + +// conditional expression +export const arrowAdd3 = (a, b, enable) => { + if (enable? true: false) { + return a + b; + } + return a - b; +} diff --git a/test/form/samples/tree-shake-literal-parameter/import-function/lib.js b/test/form/samples/tree-shake-literal-parameter/import-function/lib.js new file mode 100644 index 00000000000..be4b8a63c76 --- /dev/null +++ b/test/form/samples/tree-shake-literal-parameter/import-function/lib.js @@ -0,0 +1,37 @@ +// export default +export default function (a, b, enable) { + if (enable) { + return a + b; + } + return a - b; +} + +export function add1(a, b, enable) { + if (enable) { + return a + b; + } + return a - b; +} + +export function add2(a, b, enable) { + if (enable) { + return a + b; + } + return a - b; +} + +// keep it +export function add3(a, b, enable) { + if (enable) { + return a + b; + } + return a - b; +} + +// conditional expression +export function add4(a, b, enable) { + if (enable? true: false) { + return a + b; + } + return a - b; +} diff --git a/test/form/samples/tree-shake-literal-parameter/import-function/main.js b/test/form/samples/tree-shake-literal-parameter/import-function/main.js new file mode 100644 index 00000000000..fcd0b9dcbe1 --- /dev/null +++ b/test/form/samples/tree-shake-literal-parameter/import-function/main.js @@ -0,0 +1,17 @@ +import add, { add1, add2, add3, add4 } from './lib.js' +import arrowAdd, { arrowAdd1, arrowAdd2, arrowAdd3 } from './arrow_lib.js' + +function foo(bar) { + console.log(bar()); +} + +console.log(add(1, 2, true)); +console.log(add1(1, 2, false)); +console.log(add2(1, 2)); // unused argument should be treated as undefined +console.log(foo(add3)) +console.log(add4(1, 2, true)); + +console.log(arrowAdd(1, 2, true)); +console.log(arrowAdd1(1, 2, false)); +console.log(foo(arrowAdd2)); +console.log(arrowAdd3(1, 2, true)); \ No newline at end of file diff --git a/test/form/samples/tree-shake-literal-parameter/indirect-import-function/_config.js b/test/form/samples/tree-shake-literal-parameter/indirect-import-function/_config.js new file mode 100644 index 00000000000..43454f74be2 --- /dev/null +++ b/test/form/samples/tree-shake-literal-parameter/indirect-import-function/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'parameters of indirect function import should also be tree-shaken' +}); diff --git a/test/form/samples/tree-shake-literal-parameter/indirect-import-function/_expected.js b/test/form/samples/tree-shake-literal-parameter/indirect-import-function/_expected.js new file mode 100644 index 00000000000..39872a4cff7 --- /dev/null +++ b/test/form/samples/tree-shake-literal-parameter/indirect-import-function/_expected.js @@ -0,0 +1,14 @@ +function importThenExportSub(enable) { + { + return 'importThenExportSub'; + } +} + +function defineAndExportDefault(enable) { + { + return 'defineAndExportDefault'; + } +} + +console.log(importThenExportSub()); +console.log(defineAndExportDefault()); diff --git a/test/form/samples/tree-shake-literal-parameter/indirect-import-function/define_and_export_default.js b/test/form/samples/tree-shake-literal-parameter/indirect-import-function/define_and_export_default.js new file mode 100644 index 00000000000..b52e1846d0f --- /dev/null +++ b/test/form/samples/tree-shake-literal-parameter/indirect-import-function/define_and_export_default.js @@ -0,0 +1,7 @@ +function defineAndExportDefault(enable) { + if (enable) { + return 'defineAndExportDefault'; + } +} + +export default defineAndExportDefault; diff --git a/test/form/samples/tree-shake-literal-parameter/indirect-import-function/import_then_export.js b/test/form/samples/tree-shake-literal-parameter/indirect-import-function/import_then_export.js new file mode 100644 index 00000000000..30e7e2b911d --- /dev/null +++ b/test/form/samples/tree-shake-literal-parameter/indirect-import-function/import_then_export.js @@ -0,0 +1,3 @@ +import { importThenExportSub } from './import_then_export_sub.js' + +export { importThenExportSub } diff --git a/test/form/samples/tree-shake-literal-parameter/indirect-import-function/import_then_export_sub.js b/test/form/samples/tree-shake-literal-parameter/indirect-import-function/import_then_export_sub.js new file mode 100644 index 00000000000..2afc494681e --- /dev/null +++ b/test/form/samples/tree-shake-literal-parameter/indirect-import-function/import_then_export_sub.js @@ -0,0 +1,5 @@ +export function importThenExportSub(enable) { + if (enable) { + return 'importThenExportSub'; + } +} diff --git a/test/form/samples/tree-shake-literal-parameter/indirect-import-function/main.js b/test/form/samples/tree-shake-literal-parameter/indirect-import-function/main.js new file mode 100644 index 00000000000..ad0e9fb2639 --- /dev/null +++ b/test/form/samples/tree-shake-literal-parameter/indirect-import-function/main.js @@ -0,0 +1,5 @@ +import { importThenExportSub } from './import_then_export.js' +import defineAndExportDefault from './define_and_export_default.js' + +console.log(importThenExportSub(true)) +console.log(defineAndExportDefault(true)) diff --git a/test/form/samples/tree-shake-literal-parameter/recursion-literal-object/_config.js b/test/form/samples/tree-shake-literal-parameter/recursion-literal-object/_config.js new file mode 100644 index 00000000000..251df7a6a12 --- /dev/null +++ b/test/form/samples/tree-shake-literal-parameter/recursion-literal-object/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'function parameters tree-shaken should be recursive if literal' +}); diff --git a/test/form/samples/tree-shake-literal-parameter/recursion-literal-object/_expected.js b/test/form/samples/tree-shake-literal-parameter/recursion-literal-object/_expected.js new file mode 100644 index 00000000000..f909ce360ec --- /dev/null +++ b/test/form/samples/tree-shake-literal-parameter/recursion-literal-object/_expected.js @@ -0,0 +1,22 @@ +function fun1(options) { + { + return 'fun1'; + } +} + +function fun2(options) { + { + return fun1(); + } +} + +function fun4(options) { + { + console.log('func4'); + } +} + +console.log( + fun2(), + fun4() +); diff --git a/test/form/samples/tree-shake-literal-parameter/recursion-literal-object/main.js b/test/form/samples/tree-shake-literal-parameter/recursion-literal-object/main.js new file mode 100644 index 00000000000..4f845cc4e2c --- /dev/null +++ b/test/form/samples/tree-shake-literal-parameter/recursion-literal-object/main.js @@ -0,0 +1,40 @@ +function fun1(options) { + if (options.enable) { + return 'fun1'; + } else { + console.log('func1'); + } +} + +function fun2(options) { + if (options.enable) { + return fun1(options); + } else { + console.log('func2'); + } +} + +function fun3(options) { + if (options.enable) { + return 'fun3'; + } else { + console.log('func3'); + } +} + +function fun4(options) { + if (options.enable) { + return fun3(options); + } else { + console.log('func4'); + } +} + +console.log( + fun2({ + enable: true + }), + fun4({ + enable: false + }) +); diff --git a/test/form/samples/tree-shake-literal-parameter/recursion-literal/_config.js b/test/form/samples/tree-shake-literal-parameter/recursion-literal/_config.js new file mode 100644 index 00000000000..251df7a6a12 --- /dev/null +++ b/test/form/samples/tree-shake-literal-parameter/recursion-literal/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'function parameters tree-shaken should be recursive if literal' +}); diff --git a/test/form/samples/tree-shake-literal-parameter/recursion-literal/_expected.js b/test/form/samples/tree-shake-literal-parameter/recursion-literal/_expected.js new file mode 100644 index 00000000000..3886e024ce4 --- /dev/null +++ b/test/form/samples/tree-shake-literal-parameter/recursion-literal/_expected.js @@ -0,0 +1,13 @@ +function fun1(enable) { + { + return 'fun1'; + } +} + +function fun2(enable) { + { + return fun1(); + } +} + +console.log(fun2()); diff --git a/test/form/samples/tree-shake-literal-parameter/recursion-literal/main.js b/test/form/samples/tree-shake-literal-parameter/recursion-literal/main.js new file mode 100644 index 00000000000..1187cc47fb3 --- /dev/null +++ b/test/form/samples/tree-shake-literal-parameter/recursion-literal/main.js @@ -0,0 +1,13 @@ +function fun1(enable) { + if (enable) { + return 'fun1'; + } +} + +function fun2(enable) { + if (enable) { + return fun1(enable); + } +} + +console.log(fun2(true)); \ No newline at end of file diff --git a/test/form/samples/tree-shake-literal-parameter/reexport-function/_config.js b/test/form/samples/tree-shake-literal-parameter/reexport-function/_config.js new file mode 100644 index 00000000000..74efd8ee3ad --- /dev/null +++ b/test/form/samples/tree-shake-literal-parameter/reexport-function/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'function parameters tree-shaken should support reexport' +}); diff --git a/test/form/samples/tree-shake-literal-parameter/reexport-function/_expected.js b/test/form/samples/tree-shake-literal-parameter/reexport-function/_expected.js new file mode 100644 index 00000000000..fb14309f49f --- /dev/null +++ b/test/form/samples/tree-shake-literal-parameter/reexport-function/_expected.js @@ -0,0 +1,7 @@ +function module2 (enable) { + { + return 'module2' + } +} + +console.log(module2()); diff --git a/test/form/samples/tree-shake-literal-parameter/reexport-function/main.js b/test/form/samples/tree-shake-literal-parameter/reexport-function/main.js new file mode 100644 index 00000000000..c83b279bb08 --- /dev/null +++ b/test/form/samples/tree-shake-literal-parameter/reexport-function/main.js @@ -0,0 +1,3 @@ +import { module2 } from './module1.js' + +console.log(module2(true)) \ No newline at end of file diff --git a/test/form/samples/tree-shake-literal-parameter/reexport-function/module1.js b/test/form/samples/tree-shake-literal-parameter/reexport-function/module1.js new file mode 100644 index 00000000000..01e152738e8 --- /dev/null +++ b/test/form/samples/tree-shake-literal-parameter/reexport-function/module1.js @@ -0,0 +1 @@ +export * from './module2.js'; \ No newline at end of file diff --git a/test/form/samples/tree-shake-literal-parameter/reexport-function/module2.js b/test/form/samples/tree-shake-literal-parameter/reexport-function/module2.js new file mode 100644 index 00000000000..c4f4cacafd1 --- /dev/null +++ b/test/form/samples/tree-shake-literal-parameter/reexport-function/module2.js @@ -0,0 +1,5 @@ +export function module2 (enable) { + if (enable) { + return 'module2' + } +} \ No newline at end of file diff --git a/test/form/samples/tree-shake-literal-parameter/side-effect/_config.js b/test/form/samples/tree-shake-literal-parameter/side-effect/_config.js new file mode 100644 index 00000000000..e06ff5cdc74 --- /dev/null +++ b/test/form/samples/tree-shake-literal-parameter/side-effect/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'test tree-shake-literal-parameter with side-effect' +}); diff --git a/test/form/samples/tree-shake-literal-parameter/side-effect/_expected.js b/test/form/samples/tree-shake-literal-parameter/side-effect/_expected.js new file mode 100644 index 00000000000..77275663462 --- /dev/null +++ b/test/form/samples/tree-shake-literal-parameter/side-effect/_expected.js @@ -0,0 +1,63 @@ +function foo1() { + return 1; +} + +function bar1(foo) { + console.log(foo()); +} + +function bar2(foo) { +} + +// not pure, preserve +function foo3() { + console.log(1); +} + +function bar3(foo) { + foo(); +} + +console.log(bar1(foo1), bar2(), bar3(foo3)); + +const options = { + enable: 1 +}; + +const options2 = { + enable: 1 +}; + +function calledWithSameVariable(options) { + { + return 'enabled'; + } +} + +function calledWithDifferentVariable(options) { + if (options.enable) { + return 'enabled'; + } else { + return 'disabled'; + } +} + +// forward hasEffects to `options` +console.log(calledWithSameVariable(), calledWithSameVariable()); +// no optimization +console.log(calledWithDifferentVariable(options), calledWithDifferentVariable(options2)); + +const optionsBeModified = { + enable: 1 +}; + +function calledWithModifiedVariable(options) { + if (options.enable) { + return 'enabled'; + } else { + return 'disabled'; + } +} + +console.log(calledWithModifiedVariable(optionsBeModified)); +optionsBeModified.enable = 0; diff --git a/test/form/samples/tree-shake-literal-parameter/side-effect/main.js b/test/form/samples/tree-shake-literal-parameter/side-effect/main.js new file mode 100644 index 00000000000..d7f3ba00148 --- /dev/null +++ b/test/form/samples/tree-shake-literal-parameter/side-effect/main.js @@ -0,0 +1,71 @@ +function foo1() { + return 1; +} + +function bar1(foo) { + console.log(foo()) +} + +// pure, can be tree-shaken +function foo2() { + return 1; +} + +function bar2(foo) { + foo() +} + +// not pure, preserve +function foo3() { + console.log(1); +} + +function bar3(foo) { + foo() +} + +console.log(bar1(foo1), bar2(foo2), bar3(foo3)) + +const options = { + enable: 1 +} + +const options2 = { + enable: 1 +} + +function calledWithSameVariable(options) { + if (options.enable) { + return 'enabled'; + } else { + return 'disabled'; + } +} + +function calledWithDifferentVariable(options) { + if (options.enable) { + return 'enabled'; + } else { + return 'disabled'; + } +} + +// forward hasEffects to `options` +console.log(calledWithSameVariable(options), calledWithSameVariable(options)) +// no optimization +console.log(calledWithDifferentVariable(options), calledWithDifferentVariable(options2)) + +const optionsBeModified = { + enable: 1 +} + +function calledWithModifiedVariable(options) { + if (options.enable) { + return 'enabled'; + } else { + return 'disabled'; + } +} + +console.log(calledWithModifiedVariable(optionsBeModified)) +optionsBeModified.enable = 0; diff --git a/test/form/samples/tree-shake-literal-parameter/top-level/_config.js b/test/form/samples/tree-shake-literal-parameter/top-level/_config.js new file mode 100644 index 00000000000..027f90cf36d --- /dev/null +++ b/test/form/samples/tree-shake-literal-parameter/top-level/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'Top level exports and global variables should not be optimized' +}); diff --git a/test/form/samples/tree-shake-literal-parameter/top-level/_expected.js b/test/form/samples/tree-shake-literal-parameter/top-level/_expected.js new file mode 100644 index 00000000000..70d050ab798 --- /dev/null +++ b/test/form/samples/tree-shake-literal-parameter/top-level/_expected.js @@ -0,0 +1,23 @@ +function foo(x) { + // The exported function might also be called with "false" + if (x) console.log('true'); + else console.log('false'); +} + +// global variable should not be optimized +foo2 = (x) => { + if (x) console.log('true'); + else console.log('false'); +}; + +// export default should not be optimized +var main = foo3 = (x) => { + if (x) console.log('true'); + else console.log('false'); +}; + +foo(true); +foo2(true); +foo3(true); + +export { main as default, foo }; diff --git a/test/form/samples/tree-shake-literal-parameter/top-level/main.js b/test/form/samples/tree-shake-literal-parameter/top-level/main.js new file mode 100644 index 00000000000..9f706606d6f --- /dev/null +++ b/test/form/samples/tree-shake-literal-parameter/top-level/main.js @@ -0,0 +1,23 @@ +function foo(x) { + // The exported function might also be called with "false" + if (x) console.log('true'); + else console.log('false'); +} + +// global variable should not be optimized +foo2 = (x) => { + if (x) console.log('true'); + else console.log('false'); +} + +// export default should not be optimized +export default foo3 = (x) => { + if (x) console.log('true'); + else console.log('false'); +} + +foo(true); +foo2(true); +foo3(true); + +export { foo }; diff --git a/test/form/samples/tree-shake-logical-expressions/_config.js b/test/form/samples/tree-shake-logical-expressions/_config.js index b0ab3abfc42..7a16f15ccfe 100644 --- a/test/form/samples/tree-shake-logical-expressions/_config.js +++ b/test/form/samples/tree-shake-logical-expressions/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'tree-shake unused parts of logical expressions' -}; +}); diff --git a/test/form/samples/tree-shake-logical-expressions/_expected/amd.js b/test/form/samples/tree-shake-logical-expressions/_expected/amd.js index 31345bf4fa3..0c14d126de0 100644 --- a/test/form/samples/tree-shake-logical-expressions/_expected/amd.js +++ b/test/form/samples/tree-shake-logical-expressions/_expected/amd.js @@ -1,4 +1,4 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; function getStringA() { return 'A'; @@ -6,9 +6,9 @@ define(function () { 'use strict'; console.log(getStringA()); - console.log(false ); + console.log(false); - console.log(true ); + console.log(true); function getStringD() { return 'D'; @@ -16,4 +16,4 @@ define(function () { 'use strict'; console.log(getStringD()); -}); +})); diff --git a/test/form/samples/tree-shake-logical-expressions/_expected/cjs.js b/test/form/samples/tree-shake-logical-expressions/_expected/cjs.js index d36465fff14..9792485a4b1 100644 --- a/test/form/samples/tree-shake-logical-expressions/_expected/cjs.js +++ b/test/form/samples/tree-shake-logical-expressions/_expected/cjs.js @@ -6,9 +6,9 @@ function getStringA() { console.log(getStringA()); -console.log(false ); +console.log(false); -console.log(true ); +console.log(true); function getStringD() { return 'D'; diff --git a/test/form/samples/tree-shake-logical-expressions/_expected/es.js b/test/form/samples/tree-shake-logical-expressions/_expected/es.js index bc04584d034..0ccf0053a6d 100644 --- a/test/form/samples/tree-shake-logical-expressions/_expected/es.js +++ b/test/form/samples/tree-shake-logical-expressions/_expected/es.js @@ -4,9 +4,9 @@ function getStringA() { console.log(getStringA()); -console.log(false ); +console.log(false); -console.log(true ); +console.log(true); function getStringD() { return 'D'; diff --git a/test/form/samples/tree-shake-logical-expressions/_expected/iife.js b/test/form/samples/tree-shake-logical-expressions/_expected/iife.js index 2ce582c819f..180a99ca077 100644 --- a/test/form/samples/tree-shake-logical-expressions/_expected/iife.js +++ b/test/form/samples/tree-shake-logical-expressions/_expected/iife.js @@ -7,9 +7,9 @@ console.log(getStringA()); - console.log(false ); + console.log(false); - console.log(true ); + console.log(true); function getStringD() { return 'D'; @@ -17,4 +17,4 @@ console.log(getStringD()); -}()); +})(); diff --git a/test/form/samples/tree-shake-logical-expressions/_expected/system.js b/test/form/samples/tree-shake-logical-expressions/_expected/system.js index 05ea8647e1a..8891e125edd 100644 --- a/test/form/samples/tree-shake-logical-expressions/_expected/system.js +++ b/test/form/samples/tree-shake-logical-expressions/_expected/system.js @@ -1,7 +1,7 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { function getStringA() { return 'A'; @@ -9,9 +9,9 @@ System.register([], function () { console.log(getStringA()); - console.log(false ); + console.log(false); - console.log(true ); + console.log(true); function getStringD() { return 'D'; @@ -19,6 +19,6 @@ System.register([], function () { console.log(getStringD()); - } + }) }; -}); +})); diff --git a/test/form/samples/tree-shake-logical-expressions/_expected/umd.js b/test/form/samples/tree-shake-logical-expressions/_expected/umd.js index ac7fc0f38ab..07635dd0544 100644 --- a/test/form/samples/tree-shake-logical-expressions/_expected/umd.js +++ b/test/form/samples/tree-shake-logical-expressions/_expected/umd.js @@ -1,7 +1,7 @@ (function (factory) { typeof define === 'function' && define.amd ? define(factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; function getStringA() { return 'A'; @@ -9,9 +9,9 @@ console.log(getStringA()); - console.log(false ); + console.log(false); - console.log(true ); + console.log(true); function getStringD() { return 'D'; @@ -19,4 +19,4 @@ console.log(getStringD()); -}))); +})); diff --git a/test/form/samples/tree-shake-nested-call-no-module-side-effects/_config.js b/test/form/samples/tree-shake-nested-call-no-module-side-effects/_config.js new file mode 100644 index 00000000000..769c72b1ba7 --- /dev/null +++ b/test/form/samples/tree-shake-nested-call-no-module-side-effects/_config.js @@ -0,0 +1,8 @@ +module.exports = defineTest({ + description: 'properly tree-shakes nested function calls when moduleSideEffects are disabled', + options: { + treeshake: { + moduleSideEffects: false + } + } +}); diff --git a/test/form/samples/tree-shake-nested-call-no-module-side-effects/_expected.js b/test/form/samples/tree-shake-nested-call-no-module-side-effects/_expected.js new file mode 100644 index 00000000000..4f3b74e3cd6 --- /dev/null +++ b/test/form/samples/tree-shake-nested-call-no-module-side-effects/_expected.js @@ -0,0 +1,4 @@ +const main = () => { +}; + +export { main }; diff --git a/test/form/samples/tree-shake-nested-call-no-module-side-effects/alpha.js b/test/form/samples/tree-shake-nested-call-no-module-side-effects/alpha.js new file mode 100644 index 00000000000..3c09fc4de05 --- /dev/null +++ b/test/form/samples/tree-shake-nested-call-no-module-side-effects/alpha.js @@ -0,0 +1,7 @@ +const doNothing = () => {}; + +const alpha = () => { + doNothing(); +}; + +export { alpha }; diff --git a/test/form/samples/tree-shake-nested-call-no-module-side-effects/main.js b/test/form/samples/tree-shake-nested-call-no-module-side-effects/main.js new file mode 100644 index 00000000000..62daf1e4644 --- /dev/null +++ b/test/form/samples/tree-shake-nested-call-no-module-side-effects/main.js @@ -0,0 +1,7 @@ +import { alpha } from "./alpha"; + +const main = () => { + alpha(); +}; + +export { main }; diff --git a/test/form/samples/tree-shake-object-with-sideeffctful-getter/_config.js b/test/form/samples/tree-shake-object-with-sideeffctful-getter/_config.js new file mode 100644 index 00000000000..e35dd23c351 --- /dev/null +++ b/test/form/samples/tree-shake-object-with-sideeffctful-getter/_config.js @@ -0,0 +1,3 @@ +module.exports = { + description: 'retain functions that accept a object with a getter that has side effects' +}; diff --git a/test/form/samples/tree-shake-object-with-sideeffctful-getter/_expected.js b/test/form/samples/tree-shake-object-with-sideeffctful-getter/_expected.js new file mode 100644 index 00000000000..a21f171ed64 --- /dev/null +++ b/test/form/samples/tree-shake-object-with-sideeffctful-getter/_expected.js @@ -0,0 +1,13 @@ +let effects = 0; + +const objWithEffect = { + get foo() { + effects++; + return 'foo'; + } +}; + +Object.values(objWithEffect); +Object.entries(objWithEffect); + +assert.equal(effects, 2); diff --git a/test/form/samples/tree-shake-object-with-sideeffctful-getter/main.js b/test/form/samples/tree-shake-object-with-sideeffctful-getter/main.js new file mode 100644 index 00000000000..d5a774cf8b1 --- /dev/null +++ b/test/form/samples/tree-shake-object-with-sideeffctful-getter/main.js @@ -0,0 +1,27 @@ +let effects = 0; + +const objWithEffect = { + get foo() { + effects++; + return 'foo'; + } +}; + +const objWithoutEffect1 = { + get foo() { + return 'foo'; + } +}; +const objWithoutEffect2 = { + foo: 'foo' +}; + +Object.values(objWithEffect); +Object.entries(objWithEffect); + +Object.values(objWithoutEffect1); +Object.entries(objWithoutEffect1); +Object.values(objWithoutEffect2); +Object.entries(objWithoutEffect2); + +assert.equal(effects, 2); diff --git a/test/form/samples/tree-shake-optional-chaining-literal/_config.js b/test/form/samples/tree-shake-optional-chaining-literal/_config.js new file mode 100644 index 00000000000..64bc4f5bbd3 --- /dev/null +++ b/test/form/samples/tree-shake-optional-chaining-literal/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'tree-shake expressions optional chaining with literal values' +}); diff --git a/test/form/samples/tree-shake-optional-chaining-literal/_expected.js b/test/form/samples/tree-shake-optional-chaining-literal/_expected.js new file mode 100644 index 00000000000..f70af17a301 --- /dev/null +++ b/test/form/samples/tree-shake-optional-chaining-literal/_expected.js @@ -0,0 +1,6 @@ +// remains +exist?.foo?.(); + +if (exist?.z) { + console.log("remains"); +} diff --git a/test/form/samples/tree-shake-optional-chaining-literal/main.js b/test/form/samples/tree-shake-optional-chaining-literal/main.js new file mode 100644 index 00000000000..fd7adc0d70e --- /dev/null +++ b/test/form/samples/tree-shake-optional-chaining-literal/main.js @@ -0,0 +1,23 @@ +undefined?.foo(); +undefined?.foo?.bar?.(); +undefined?.(); + +if (undefined?.foo) { + console.log("shaked"); +} + +if (undefined?.foo?.bar || false) { + console.log("shaked"); +} + +(undefined || null)?.foo(); +(undefined ?? null ?? undefined?.bar)?.foo(); + +null?.bar(); + +// remains +exist?.foo?.(); + +if (exist?.z) { + console.log("remains") +} diff --git a/test/form/samples/tree-shake-pure-optional-chaining/_config.js b/test/form/samples/tree-shake-pure-optional-chaining/_config.js index f35ab64b278..58251c2acda 100644 --- a/test/form/samples/tree-shake-pure-optional-chaining/_config.js +++ b/test/form/samples/tree-shake-pure-optional-chaining/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'tree-shake pure call expressions involving optional chaining' -}; +}); diff --git a/test/form/samples/tree-shake-un-included-elements-in-array-pattern/_config.js b/test/form/samples/tree-shake-un-included-elements-in-array-pattern/_config.js new file mode 100644 index 00000000000..367faadf681 --- /dev/null +++ b/test/form/samples/tree-shake-un-included-elements-in-array-pattern/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'tree-shake un-included elements in array pattern' +}); diff --git a/test/form/samples/tree-shake-un-included-elements-in-array-pattern/_expected.js b/test/form/samples/tree-shake-un-included-elements-in-array-pattern/_expected.js new file mode 100644 index 00000000000..74b07233f15 --- /dev/null +++ b/test/form/samples/tree-shake-un-included-elements-in-array-pattern/_expected.js @@ -0,0 +1,10 @@ +function useState() { + return ['foo', 'bar', 'qux']; +} + +const [foo$1] = useState(); +assert.ok(foo$1); + +const [foo, , qux] = useState(); +assert.ok(foo); +assert.ok(qux); diff --git a/test/form/samples/tree-shake-un-included-elements-in-array-pattern/main.js b/test/form/samples/tree-shake-un-included-elements-in-array-pattern/main.js new file mode 100644 index 00000000000..0fa4f7deeb8 --- /dev/null +++ b/test/form/samples/tree-shake-un-included-elements-in-array-pattern/main.js @@ -0,0 +1,2 @@ +import './module1.js'; +import './module2.js'; diff --git a/test/form/samples/tree-shake-un-included-elements-in-array-pattern/module1.js b/test/form/samples/tree-shake-un-included-elements-in-array-pattern/module1.js new file mode 100644 index 00000000000..deb517c19bf --- /dev/null +++ b/test/form/samples/tree-shake-un-included-elements-in-array-pattern/module1.js @@ -0,0 +1,3 @@ +import useState from './module3.js'; +const [foo, , qux] = useState(); +assert.ok(foo); diff --git a/test/form/samples/tree-shake-un-included-elements-in-array-pattern/module2.js b/test/form/samples/tree-shake-un-included-elements-in-array-pattern/module2.js new file mode 100644 index 00000000000..59950b550d7 --- /dev/null +++ b/test/form/samples/tree-shake-un-included-elements-in-array-pattern/module2.js @@ -0,0 +1,4 @@ +import useState from './module3.js'; +const [foo, , qux] = useState(); +assert.ok(foo); +assert.ok(qux); diff --git a/test/form/samples/tree-shake-un-included-elements-in-array-pattern/module3.js b/test/form/samples/tree-shake-un-included-elements-in-array-pattern/module3.js new file mode 100644 index 00000000000..8442cc18b1d --- /dev/null +++ b/test/form/samples/tree-shake-un-included-elements-in-array-pattern/module3.js @@ -0,0 +1,3 @@ +export default function useState() { + return ['foo', 'bar', 'qux']; +} diff --git a/test/form/samples/treeshake-classes-with-fields/_config.js b/test/form/samples/treeshake-classes-with-fields/_config.js index 850350bdabd..76c38b0bc48 100644 --- a/test/form/samples/treeshake-classes-with-fields/_config.js +++ b/test/form/samples/treeshake-classes-with-fields/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'treeshakes classes with class fields (#3564)' -}; +}); diff --git a/test/form/samples/treeshake-deterministic-dynamic-import/_config.js b/test/form/samples/treeshake-deterministic-dynamic-import/_config.js new file mode 100644 index 00000000000..318fef923df --- /dev/null +++ b/test/form/samples/treeshake-deterministic-dynamic-import/_config.js @@ -0,0 +1,41 @@ +module.exports = { + description: 'treeshakes dynamic imports when the target is deterministic', + options: { + output: { + inlineDynamicImports: true + }, + external: ['external'], + plugins: [ + { + resolveId(id) { + if (/(bail|effect)-(\d+).js$/.test(id)) { + return id; + } + return null; + }, + load(id) { + const match = /(bail|effect)-(\d+).js$/.exec(id); + if (match) { + const [, name, index] = match; + if (name === 'bail') + return { + code: [ + `export default '@included-bail-${index}'`, + `export const named${index} = 'bail${index}';` + ].join('\n') + }; + else if (name === 'effect') { + return { + code: [ + `export function fn${index}() { /* @tree-shaken */ }`, + `console.log('@included-effect-${index}');` + ].join('\n') + }; + } + } + return null; + } + } + ] + } +}; diff --git a/test/form/samples/treeshake-deterministic-dynamic-import/_expected.js b/test/form/samples/treeshake-deterministic-dynamic-import/_expected.js new file mode 100644 index 00000000000..f795826b436 --- /dev/null +++ b/test/form/samples/treeshake-deterministic-dynamic-import/_expected.js @@ -0,0 +1,285 @@ +import * as external from 'external'; + +function _mergeNamespaces(n, m) { + m.forEach(function (e) { + e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) { + if (k !== 'default' && !(k in n)) { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + }); + return Object.freeze(n); +} + +async function entry() { + // simple + const { foo1: foo } = await Promise.resolve().then(function () { return sub1; }); + const { doesNotExists } = await Promise.resolve().then(function () { return sub1; }); + + // multiple + const { bar2 } = await Promise.resolve().then(function () { return sub2; }); + bar2(); + const { foo2 } = await Promise.resolve().then(function () { return sub2; }); + const { foo3 } = await Promise.resolve().then(function () { return sub2; }); + Promise.resolve().then(function () { return sub2; }).then(m => m.baz2); + Promise.resolve().then(function () { return sub2; }).then(m => { + function f(m) { + console.log(m.baz2); + } + f(m); + }); + Promise.resolve().then(function () { return sub2; }).then(function (m) { + function f(m) { + console.log(m.baz2); + } + f(m); + }); + Promise.resolve().then(function () { return sub2; }).then(({ baz2 }) => baz2); + Promise.resolve().then(function () { return sub2; }) + .catch() + .finally() + .then(({ a }) => console.log(a)); + Promise.resolve().then(function () { return sub2; }).then(function ({ reexported }) { + }); + + // external with unknown namespace + const { foo4, x } = await Promise.resolve().then(function () { return sub4; }); + + // side-effect only + Promise.resolve().then(function () { return effect1; }); + await Promise.resolve().then(function () { return effect2; }); + Promise.resolve().then(function () { return effect3; }).then(); + Promise.resolve().then(function () { return effect4; }).then(function () {}); + Promise.resolve().then(function () { return effect5; }).catch(() => {}); + Promise.resolve().then(function () { return effect6; }).catch(() => {}).then(() => {}); + Promise.resolve().then(function () { return effect7; }).finally(() => {}); + Promise.resolve().then(function () { return effect8; }).finally(() => {}).then(() => {}); + + // bail out + const { named1 } = await Promise.resolve().then(function () { return bail1$1; }); + Promise.resolve().then(function () { return bail1$1; }); // this make it bail out + + const { ...named2 } = await Promise.resolve().then(function () { return bail2$1; })(await Promise.resolve().then(function () { return bail3$1; }))[foo]; + + await Promise.resolve().then(function () { return bail4$1; }).name4; // access on promise, not on export + + Promise.resolve().then(function () { return bail5$1; }).then(foo); + + await Promise.resolve().then(function () { return bail6$1; }).then(function ({ named6, ...args }) {}); + + await Promise.resolve().then(function () { return bail6$1; }).then(m => globalThis.named6); + + [Promise.resolve().then(function () { return bail7$1; }), Promise.resolve().then(function () { return bail8$1; })]; + + const { [foo]: bar } = await Promise.resolve().then(function () { return bail9$1; }); + + Promise.resolve().then(function () { return bail10$1; }).then(({ [foo]: bar }) => {}); + + const [name11] = await Promise.resolve().then(function () { return bail11$1; }); +} + +function foo1() { + return 'foo1'; +} + +console.log('side-effect1'); + +var sub1 = /*#__PURE__*/Object.freeze({ + __proto__: null, + foo1: foo1 +}); + +function foo3() { + return 'foo3'; +} + +function bar3() { + return 'bar3'; +} + +console.log('side-effect3'); + +function foo2() { + return 'foo2'; +} + +function bar2() { + return 'bar2'; +} + +function baz2() { + return 'baz2'; +} + +const a = 1; + +var sub2 = /*#__PURE__*/Object.freeze({ + __proto__: null, + a: a, + bar2: bar2, + bar3: bar3, + baz2: baz2, + foo2: foo2, + foo3: foo3, + reexported: bar3 +}); + +const foo4 = 3; + +var sub4 = /*#__PURE__*/_mergeNamespaces({ + __proto__: null, + foo4: foo4 +}, [external]); + +console.log('@included-effect-1'); + +var effect1 = /*#__PURE__*/Object.freeze({ + __proto__: null +}); + +console.log('@included-effect-2'); + +var effect2 = /*#__PURE__*/Object.freeze({ + __proto__: null +}); + +console.log('@included-effect-3'); + +var effect3 = /*#__PURE__*/Object.freeze({ + __proto__: null +}); + +console.log('@included-effect-4'); + +var effect4 = /*#__PURE__*/Object.freeze({ + __proto__: null +}); + +console.log('@included-effect-5'); + +var effect5 = /*#__PURE__*/Object.freeze({ + __proto__: null +}); + +console.log('@included-effect-6'); + +var effect6 = /*#__PURE__*/Object.freeze({ + __proto__: null +}); + +console.log('@included-effect-7'); + +var effect7 = /*#__PURE__*/Object.freeze({ + __proto__: null +}); + +console.log('@included-effect-8'); + +var effect8 = /*#__PURE__*/Object.freeze({ + __proto__: null +}); + +var bail1 = '@included-bail-1'; +const named1 = 'bail1'; + +var bail1$1 = /*#__PURE__*/Object.freeze({ + __proto__: null, + default: bail1, + named1: named1 +}); + +var bail2 = '@included-bail-2'; +const named2 = 'bail2'; + +var bail2$1 = /*#__PURE__*/Object.freeze({ + __proto__: null, + default: bail2, + named2: named2 +}); + +var bail3 = '@included-bail-3'; +const named3 = 'bail3'; + +var bail3$1 = /*#__PURE__*/Object.freeze({ + __proto__: null, + default: bail3, + named3: named3 +}); + +var bail4 = '@included-bail-4'; +const named4 = 'bail4'; + +var bail4$1 = /*#__PURE__*/Object.freeze({ + __proto__: null, + default: bail4, + named4: named4 +}); + +var bail5 = '@included-bail-5'; +const named5 = 'bail5'; + +var bail5$1 = /*#__PURE__*/Object.freeze({ + __proto__: null, + default: bail5, + named5: named5 +}); + +var bail6 = '@included-bail-6'; +const named6 = 'bail6'; + +var bail6$1 = /*#__PURE__*/Object.freeze({ + __proto__: null, + default: bail6, + named6: named6 +}); + +var bail7 = '@included-bail-7'; +const named7 = 'bail7'; + +var bail7$1 = /*#__PURE__*/Object.freeze({ + __proto__: null, + default: bail7, + named7: named7 +}); + +var bail8 = '@included-bail-8'; +const named8 = 'bail8'; + +var bail8$1 = /*#__PURE__*/Object.freeze({ + __proto__: null, + default: bail8, + named8: named8 +}); + +var bail9 = '@included-bail-9'; +const named9 = 'bail9'; + +var bail9$1 = /*#__PURE__*/Object.freeze({ + __proto__: null, + default: bail9, + named9: named9 +}); + +var bail10 = '@included-bail-10'; +const named10 = 'bail10'; + +var bail10$1 = /*#__PURE__*/Object.freeze({ + __proto__: null, + default: bail10, + named10: named10 +}); + +var bail11 = '@included-bail-11'; +const named11 = 'bail11'; + +var bail11$1 = /*#__PURE__*/Object.freeze({ + __proto__: null, + default: bail11, + named11: named11 +}); + +export { entry }; diff --git a/test/form/samples/treeshake-deterministic-dynamic-import/main.js b/test/form/samples/treeshake-deterministic-dynamic-import/main.js new file mode 100644 index 00000000000..87c88214de7 --- /dev/null +++ b/test/form/samples/treeshake-deterministic-dynamic-import/main.js @@ -0,0 +1,67 @@ +export async function entry() { + // simple + const { foo1: foo } = await import('./sub1.js'); + const { doesNotExists } = await import('./sub1.js'); + + // multiple + const { bar2 } = await import('./sub2.js'); + bar2(); + const { foo2 } = await import('./sub2.js'); + const { foo3 } = await import('./sub2.js'); + import('./sub2.js').then(m => m.baz2); + import('./sub2.js').then(m => { + function f(m) { + console.log(m.baz2); + } + f(m); + }); + import('./sub2.js').then(function (m) { + function f(m) { + console.log(m.baz2); + } + f(m); + }); + import('./sub2.js').then(({ baz2 }) => baz2); + import('./sub2.js') + .catch() + .finally() + .then(({ a }) => console.log(a)); + import('./sub2.js').then(function ({ reexported }) { + reexported; + }); + + // external with unknown namespace + const { foo4, x } = await import('./sub4'); + + // side-effect only + import('./effect-1.js'); + await import('./effect-2.js'); + import('./effect-3.js').then(); + import('./effect-4.js').then(function () {}); + import('./effect-5.js').catch(() => {}); + import('./effect-6.js').catch(() => {}).then(() => {}); + import('./effect-7.js').finally(() => {}); + import('./effect-8.js').finally(() => {}).then(() => {}); + + // bail out + const { named1 } = await import('./bail-1.js'); + const promise = import('./bail-1.js'); // this make it bail out + + const { ...named2 } = await import('./bail-2.js')(await import('./bail-3.js'))[foo]; + + await import('./bail-4.js').name4; // access on promise, not on export + + import('./bail-5.js').then(foo); + + await import('./bail-6.js').then(function ({ named6, ...args }) {}); + + await import('./bail-6.js').then(m => globalThis.named6); + + const promises = [import('./bail-7.js'), import('./bail-8.js')]; + + const { [foo]: bar } = await import('./bail-9.js'); + + import('./bail-10.js').then(({ [foo]: bar }) => {}); + + const [name11] = await import('./bail-11.js'); +} diff --git a/test/form/samples/treeshake-deterministic-dynamic-import/sub1.js b/test/form/samples/treeshake-deterministic-dynamic-import/sub1.js new file mode 100644 index 00000000000..13f7de36261 --- /dev/null +++ b/test/form/samples/treeshake-deterministic-dynamic-import/sub1.js @@ -0,0 +1,9 @@ +export function foo1() { + return 'foo1'; +} + +export function bar1() { + return 'bar1'; // this should be tree-shaken +} + +console.log('side-effect1'); diff --git a/test/form/samples/treeshake-deterministic-dynamic-import/sub2.js b/test/form/samples/treeshake-deterministic-dynamic-import/sub2.js new file mode 100644 index 00000000000..4628d99a178 --- /dev/null +++ b/test/form/samples/treeshake-deterministic-dynamic-import/sub2.js @@ -0,0 +1,21 @@ +export function foo2() { + return 'foo2'; +} + +export function bar2() { + return 'bar2'; +} + +export function baz2() { + return 'baz2'; +} + +export function qux2() { + return 'qux2'; // this should be tree-shaken +} + +export const a = 1; + +export { bar3 as reexported } from './sub3.js' + +export * from './sub3.js'; diff --git a/test/form/samples/treeshake-deterministic-dynamic-import/sub3.js b/test/form/samples/treeshake-deterministic-dynamic-import/sub3.js new file mode 100644 index 00000000000..0e0a3c530fb --- /dev/null +++ b/test/form/samples/treeshake-deterministic-dynamic-import/sub3.js @@ -0,0 +1,13 @@ +export function foo3() { + return 'foo3'; +} + +export function bar3() { + return 'bar3'; +} + +export function baz3() { + return 'baz3'; // this should be tree-shaken +} + +console.log('side-effect3') diff --git a/test/form/samples/treeshake-deterministic-dynamic-import/sub4.js b/test/form/samples/treeshake-deterministic-dynamic-import/sub4.js new file mode 100644 index 00000000000..746302805dd --- /dev/null +++ b/test/form/samples/treeshake-deterministic-dynamic-import/sub4.js @@ -0,0 +1,4 @@ +export const foo4 = 3; +export const bar4 = 4; + +export * from 'external'; diff --git a/test/form/samples/treeshake-excess-arguments/argument-side-effects/_config.js b/test/form/samples/treeshake-excess-arguments/argument-side-effects/_config.js index d2acef03025..2c2aefb246a 100644 --- a/test/form/samples/treeshake-excess-arguments/argument-side-effects/_config.js +++ b/test/form/samples/treeshake-excess-arguments/argument-side-effects/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'retains arguments that have side-effects' -}; +}); diff --git a/test/form/samples/treeshake-excess-arguments/arguments-variable/_config.js b/test/form/samples/treeshake-excess-arguments/arguments-variable/_config.js index 86854f25350..85a33fbb24c 100644 --- a/test/form/samples/treeshake-excess-arguments/arguments-variable/_config.js +++ b/test/form/samples/treeshake-excess-arguments/arguments-variable/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'does not remove arguments from call when arguments variables is accessed' -}; +}); diff --git a/test/form/samples/treeshake-excess-arguments/arrow-function-arguments/_config.js b/test/form/samples/treeshake-excess-arguments/arrow-function-arguments/_config.js index 8c4887c4e0a..4b7c0e47074 100644 --- a/test/form/samples/treeshake-excess-arguments/arrow-function-arguments/_config.js +++ b/test/form/samples/treeshake-excess-arguments/arrow-function-arguments/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'removes unneeded arguments from calls to arrow functions' -}; +}); diff --git a/test/form/samples/treeshake-excess-arguments/function-arguments/_config.js b/test/form/samples/treeshake-excess-arguments/function-arguments/_config.js index 2a51e6c38af..762ac6c939c 100644 --- a/test/form/samples/treeshake-excess-arguments/function-arguments/_config.js +++ b/test/form/samples/treeshake-excess-arguments/function-arguments/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'removes unneeded arguments from calls to functions' -}; +}); diff --git a/test/form/samples/treeshake-excess-arguments/function-arguments/_expected.js b/test/form/samples/treeshake-excess-arguments/function-arguments/_expected.js index 6c216679275..2a7e9951bc2 100644 --- a/test/form/samples/treeshake-excess-arguments/function-arguments/_expected.js +++ b/test/form/samples/treeshake-excess-arguments/function-arguments/_expected.js @@ -1,37 +1,31 @@ function noParams() { console.log(); } + function someUsedParams(p1, p2, p3) { console.log(p1, p3); } - noParams(); - const needed21 = 1; const needed22 = 2; const needed23 = 3; - someUsedParams(needed21, needed22, needed23); const noParamsExp = function() { console.log(); }; + const someUsedParamsExp = function(p1, p2, p3) { console.log(p1, p3); }; - noParamsExp(); - const needed41 = 1; const needed42 = 2; const needed43 = 3; - someUsedParamsExp(needed41, needed42, needed43); - (function() { console.log(); }()); - const needed61 = 1; const needed62 = 2; const needed63 = 3; diff --git a/test/form/samples/treeshake-excess-arguments/function-arguments/main.js b/test/form/samples/treeshake-excess-arguments/function-arguments/main.js index a7d8a634f68..b0492cca08b 100644 --- a/test/form/samples/treeshake-excess-arguments/function-arguments/main.js +++ b/test/form/samples/treeshake-excess-arguments/function-arguments/main.js @@ -1,47 +1,44 @@ function noParams() { console.log(); } + function someUsedParams(p1, p2, p3) { console.log(p1, p3); } -const unneeded1 = 1; +const unneeded1 = 1; noParams(unneeded1); -const unneeded2 = 1; - +const unneeded21 = 1; +const unneeded22 = 1; const needed21 = 1; const needed22 = 2; const needed23 = 3; - -someUsedParams(needed21, needed22, needed23, unneeded2); +someUsedParams(needed21, needed22, needed23, unneeded21, unneeded22); const noParamsExp = function() { console.log(); }; + const someUsedParamsExp = function(p1, p2, p3) { console.log(p1, p3); }; -const unneeded3 = 1; +const unneeded3 = 1; noParamsExp(unneeded3); const unneeded4 = 1; - const needed41 = 1; const needed42 = 2; const needed43 = 3; - someUsedParamsExp(needed41, needed42, needed43, unneeded4); const unneeded5 = 1; - (function() { console.log(); }(unneeded5)); const unneeded6 = 1; - const needed61 = 1; const needed62 = 2; const needed63 = 3; diff --git a/test/form/samples/treeshake-excess-arguments/namespace-members/_config.js b/test/form/samples/treeshake-excess-arguments/namespace-members/_config.js index 1f3e70ad8c1..e6af8a352a8 100644 --- a/test/form/samples/treeshake-excess-arguments/namespace-members/_config.js +++ b/test/form/samples/treeshake-excess-arguments/namespace-members/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'removes unneeded arguments across namespace member calls' -}; +}); diff --git a/test/form/samples/treeshake-excess-arguments/patterns/_config.js b/test/form/samples/treeshake-excess-arguments/patterns/_config.js index 6a644e8b64e..1d2c361300b 100644 --- a/test/form/samples/treeshake-excess-arguments/patterns/_config.js +++ b/test/form/samples/treeshake-excess-arguments/patterns/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'removes unneeded arguments from calls when patterns are used' -}; +}); diff --git a/test/form/samples/treeshake-excess-arguments/rest-element/_config.js b/test/form/samples/treeshake-excess-arguments/rest-element/_config.js index 2daa706360d..2b00e145816 100644 --- a/test/form/samples/treeshake-excess-arguments/rest-element/_config.js +++ b/test/form/samples/treeshake-excess-arguments/rest-element/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'does not remove arguments from calls when rest parameters are used' -}; +}); diff --git a/test/form/samples/treeshake-excess-arguments/unused-parameters/_config.js b/test/form/samples/treeshake-excess-arguments/unused-parameters/_config.js index ebe92e0065f..c68fa60250e 100644 --- a/test/form/samples/treeshake-excess-arguments/unused-parameters/_config.js +++ b/test/form/samples/treeshake-excess-arguments/unused-parameters/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'removes arguments that correspond to unused parameters' -}; +}); diff --git a/test/form/samples/treeshake-if-statement/_config.js b/test/form/samples/treeshake-if-statement/_config.js new file mode 100644 index 00000000000..2fdd5a00f6e --- /dev/null +++ b/test/form/samples/treeshake-if-statement/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'treeshakes if statement' +}); diff --git a/test/form/samples/treeshake-if-statement/_expected.js b/test/form/samples/treeshake-if-statement/_expected.js new file mode 100644 index 00000000000..4e5d36dbb85 --- /dev/null +++ b/test/form/samples/treeshake-if-statement/_expected.js @@ -0,0 +1,13 @@ +{ + assert.ok(true); +} + +if (typeof parseInt === 'function' ?? 'a' === 'a') { + assert.ok(true); +} + +if (!(unknownGlobal ? 'asdf' : true)) ; + +if (unknownGlobal ? 0 : false) ; + +if (!(unknownGlobal ? 'a' === 'a' : true)) ; diff --git a/test/form/samples/treeshake-if-statement/main.js b/test/form/samples/treeshake-if-statement/main.js new file mode 100644 index 00000000000..96988e772df --- /dev/null +++ b/test/form/samples/treeshake-if-statement/main.js @@ -0,0 +1,23 @@ +if (typeof parseInt === 'function' && 'a' === 'b') { + assert.ok(false); +} + +if (typeof parseInt === 'function' || 'a' === 'a') { + assert.ok(true); +} + +if (typeof parseInt === 'function' ?? 'a' === 'a') { + assert.ok(true); +} + +if (!(unknownGlobal ? 'asdf' : true)) { + assert.ok(false); +} + +if (unknownGlobal ? 0 : false) { + assert.ok(false); +} + +if (!(unknownGlobal ? 'a' === 'a' : true)) { + assert.ok(false); +} diff --git a/test/form/samples/treeshake-import-meta-props/_config.js b/test/form/samples/treeshake-import-meta-props/_config.js index d73457be9b1..cff2de822ac 100644 --- a/test/form/samples/treeshake-import-meta-props/_config.js +++ b/test/form/samples/treeshake-import-meta-props/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'also does not include format globals when tree-shaking import meta' -}; +}); diff --git a/test/form/samples/treeshake-import-meta-props/_expected/amd.js b/test/form/samples/treeshake-import-meta-props/_expected/amd.js index 126aa22ee83..49540b44d78 100644 --- a/test/form/samples/treeshake-import-meta-props/_expected/amd.js +++ b/test/form/samples/treeshake-import-meta-props/_expected/amd.js @@ -1,5 +1,5 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; console.log('main'); -}); +})); diff --git a/test/form/samples/treeshake-import-meta-props/_expected/iife.js b/test/form/samples/treeshake-import-meta-props/_expected/iife.js index d283cbce8ba..455edee6aa6 100644 --- a/test/form/samples/treeshake-import-meta-props/_expected/iife.js +++ b/test/form/samples/treeshake-import-meta-props/_expected/iife.js @@ -3,4 +3,4 @@ console.log('main'); -}()); +})(); diff --git a/test/form/samples/treeshake-import-meta-props/_expected/system.js b/test/form/samples/treeshake-import-meta-props/_expected/system.js index c83499bc2d4..35e2693371a 100644 --- a/test/form/samples/treeshake-import-meta-props/_expected/system.js +++ b/test/form/samples/treeshake-import-meta-props/_expected/system.js @@ -1,10 +1,10 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { console.log('main'); - } + }) }; -}); +})); diff --git a/test/form/samples/treeshake-import-meta-props/_expected/umd.js b/test/form/samples/treeshake-import-meta-props/_expected/umd.js index f69e11c0256..c8ba7daa897 100644 --- a/test/form/samples/treeshake-import-meta-props/_expected/umd.js +++ b/test/form/samples/treeshake-import-meta-props/_expected/umd.js @@ -1,8 +1,8 @@ (function (factory) { typeof define === 'function' && define.amd ? define(factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; console.log('main'); -}))); +})); diff --git a/test/form/samples/treeshake-import-meta/_config.js b/test/form/samples/treeshake-import-meta/_config.js index 64d9f998bc0..42c63f7922f 100644 --- a/test/form/samples/treeshake-import-meta/_config.js +++ b/test/form/samples/treeshake-import-meta/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'supports tree-shaking for meta properties' -}; +}); diff --git a/test/form/samples/treeshake-json/_config.js b/test/form/samples/treeshake-json/_config.js index 732525751e4..5adc22a8df2 100644 --- a/test/form/samples/treeshake-json/_config.js +++ b/test/form/samples/treeshake-json/_config.js @@ -1,6 +1,6 @@ -const json = require('@rollup/plugin-json'); +const json = require('@rollup/plugin-json').default; -module.exports = { +module.exports = defineTest({ description: 'removes unusued json keys', options: { plugins: [json()] } -}; +}); diff --git a/test/form/samples/treeshake-namespace-access/_config.js b/test/form/samples/treeshake-namespace-access/_config.js index 8f398f593b2..de35a4275e8 100644 --- a/test/form/samples/treeshake-namespace-access/_config.js +++ b/test/form/samples/treeshake-namespace-access/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'does not count namespace property access as side-effect', options: { external: 'external' } -}; +}); diff --git a/test/form/samples/treeshake-namespace-access/_expected/amd.js b/test/form/samples/treeshake-namespace-access/_expected/amd.js index 0bae1e8d57f..abb86309e1b 100644 --- a/test/form/samples/treeshake-namespace-access/_expected/amd.js +++ b/test/form/samples/treeshake-namespace-access/_expected/amd.js @@ -1,5 +1,5 @@ -define(['external'], function (external) { 'use strict'; +define(['external'], (function (external) { 'use strict'; console.log('main'); -}); +})); diff --git a/test/form/samples/treeshake-namespace-access/_expected/iife.js b/test/form/samples/treeshake-namespace-access/_expected/iife.js index d283cbce8ba..455edee6aa6 100644 --- a/test/form/samples/treeshake-namespace-access/_expected/iife.js +++ b/test/form/samples/treeshake-namespace-access/_expected/iife.js @@ -3,4 +3,4 @@ console.log('main'); -}()); +})(); diff --git a/test/form/samples/treeshake-namespace-access/_expected/system.js b/test/form/samples/treeshake-namespace-access/_expected/system.js index d927c51ce7d..e0dce5b6f40 100644 --- a/test/form/samples/treeshake-namespace-access/_expected/system.js +++ b/test/form/samples/treeshake-namespace-access/_expected/system.js @@ -1,11 +1,11 @@ -System.register(['external'], function () { +System.register(['external'], (function () { 'use strict'; return { - setters: [function () {}], - execute: function () { + setters: [null], + execute: (function () { console.log('main'); - } + }) }; -}); +})); diff --git a/test/form/samples/treeshake-namespace-access/_expected/umd.js b/test/form/samples/treeshake-namespace-access/_expected/umd.js index a0358332ac1..33824109fc6 100644 --- a/test/form/samples/treeshake-namespace-access/_expected/umd.js +++ b/test/form/samples/treeshake-namespace-access/_expected/umd.js @@ -1,8 +1,8 @@ (function (factory) { typeof define === 'function' && define.amd ? define(['external'], factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; console.log('main'); -}))); +})); diff --git a/test/form/samples/treeshake-presets/preset-with-override/_config.js b/test/form/samples/treeshake-presets/preset-with-override/_config.js new file mode 100644 index 00000000000..b1741c8afba --- /dev/null +++ b/test/form/samples/treeshake-presets/preset-with-override/_config.js @@ -0,0 +1,30 @@ +const assert = require('node:assert'); +const path = require('node:path'); + +module.exports = defineTest({ + description: 'allows using the "preset" option with overrides', + options: { + treeshake: { + preset: 'smallest', + unknownGlobalSideEffects: true + }, + plugins: [ + { + name: 'test-plugin', + buildStart(options) { + if (!options.treeshake) { + throw new Error('Treeshaking options not found'); + } + assert.strictEqual(options.treeshake.correctVarValueBeforeDeclaration, false); + assert.strictEqual(options.treeshake.propertyReadSideEffects, false); + assert.strictEqual(options.treeshake.tryCatchDeoptimization, false); + assert.strictEqual(options.treeshake.unknownGlobalSideEffects, true); + assert.strictEqual( + options.treeshake.moduleSideEffects(path.join(__dirname, 'dep.js'), false), + false + ); + } + } + ] + } +}); diff --git a/test/form/samples/treeshake-presets/preset-with-override/_expected.js b/test/form/samples/treeshake-presets/preset-with-override/_expected.js new file mode 100644 index 00000000000..e7591da9dfd --- /dev/null +++ b/test/form/samples/treeshake-presets/preset-with-override/_expected.js @@ -0,0 +1,17 @@ +console.log('main'); + +unknownGlobal; + +let flag = true; + +function test() { + if (flag) var x = true; + if (x) { + return; + } + console.log('effect'); +} + +test(); +flag = false; +test(); diff --git a/test/form/samples/treeshake-presets/preset-with-override/dep.js b/test/form/samples/treeshake-presets/preset-with-override/dep.js new file mode 100644 index 00000000000..b74a9837c07 --- /dev/null +++ b/test/form/samples/treeshake-presets/preset-with-override/dep.js @@ -0,0 +1 @@ +console.log('dep'); diff --git a/test/form/samples/treeshake-presets/preset-with-override/main.js b/test/form/samples/treeshake-presets/preset-with-override/main.js new file mode 100644 index 00000000000..d6c035738d1 --- /dev/null +++ b/test/form/samples/treeshake-presets/preset-with-override/main.js @@ -0,0 +1,29 @@ +import './dep.js'; + +console.log('main'); + +({ + get foo() { + console.log('effect'); + } +}.foo); + +try { + const noeffect = 1; +} catch {} + +unknownGlobal; + +let flag = true; + +function test() { + if (flag) var x = true; + if (x) { + return; + } + console.log('effect'); +} + +test(); +flag = false; +test(); diff --git a/test/form/samples/treeshake-presets/recommended/_config.js b/test/form/samples/treeshake-presets/recommended/_config.js new file mode 100644 index 00000000000..c55983ad497 --- /dev/null +++ b/test/form/samples/treeshake-presets/recommended/_config.js @@ -0,0 +1,27 @@ +const assert = require('node:assert'); +const path = require('node:path'); + +module.exports = defineTest({ + description: 'handles treeshake preset "recommended"', + options: { + treeshake: 'recommended', + plugins: [ + { + name: 'test-plugin', + buildStart(options) { + if (!options.treeshake) { + throw new Error('Treeshaking options not found'); + } + assert.strictEqual(options.treeshake.correctVarValueBeforeDeclaration, false); + assert.strictEqual(options.treeshake.propertyReadSideEffects, true); + assert.strictEqual(options.treeshake.tryCatchDeoptimization, true); + assert.strictEqual(options.treeshake.unknownGlobalSideEffects, false); + assert.strictEqual( + options.treeshake.moduleSideEffects(path.join(__dirname, 'dep.js'), false), + true + ); + } + } + ] + } +}); diff --git a/test/form/samples/treeshake-presets/recommended/_expected.js b/test/form/samples/treeshake-presets/recommended/_expected.js new file mode 100644 index 00000000000..53c9eb40b06 --- /dev/null +++ b/test/form/samples/treeshake-presets/recommended/_expected.js @@ -0,0 +1,27 @@ +console.log('dep'); + +console.log('main'); + +({ + get foo() { + console.log('effect'); + } +}.foo); + +try { + const noeffect = 1; +} catch {} + +let flag = true; + +function test() { + if (flag) var x = true; + if (x) { + return; + } + console.log('effect'); +} + +test(); +flag = false; +test(); diff --git a/test/form/samples/treeshake-presets/recommended/dep.js b/test/form/samples/treeshake-presets/recommended/dep.js new file mode 100644 index 00000000000..b74a9837c07 --- /dev/null +++ b/test/form/samples/treeshake-presets/recommended/dep.js @@ -0,0 +1 @@ +console.log('dep'); diff --git a/test/form/samples/treeshake-presets/recommended/main.js b/test/form/samples/treeshake-presets/recommended/main.js new file mode 100644 index 00000000000..d6c035738d1 --- /dev/null +++ b/test/form/samples/treeshake-presets/recommended/main.js @@ -0,0 +1,29 @@ +import './dep.js'; + +console.log('main'); + +({ + get foo() { + console.log('effect'); + } +}.foo); + +try { + const noeffect = 1; +} catch {} + +unknownGlobal; + +let flag = true; + +function test() { + if (flag) var x = true; + if (x) { + return; + } + console.log('effect'); +} + +test(); +flag = false; +test(); diff --git a/test/form/samples/treeshake-presets/safest/_config.js b/test/form/samples/treeshake-presets/safest/_config.js new file mode 100644 index 00000000000..050200d282a --- /dev/null +++ b/test/form/samples/treeshake-presets/safest/_config.js @@ -0,0 +1,27 @@ +const assert = require('node:assert'); +const path = require('node:path'); + +module.exports = defineTest({ + description: 'handles treeshake preset "safest"', + options: { + treeshake: 'safest', + plugins: [ + { + name: 'test', + buildStart(options) { + if (!options.treeshake) { + throw new Error('Treeshaking options not found'); + } + assert.strictEqual(options.treeshake.correctVarValueBeforeDeclaration, true); + assert.strictEqual(options.treeshake.propertyReadSideEffects, true); + assert.strictEqual(options.treeshake.tryCatchDeoptimization, true); + assert.strictEqual(options.treeshake.unknownGlobalSideEffects, true); + assert.strictEqual( + options.treeshake.moduleSideEffects(path.join(__dirname, 'dep.js'), false), + true + ); + } + } + ] + } +}); diff --git a/test/form/samples/treeshake-presets/safest/_expected.js b/test/form/samples/treeshake-presets/safest/_expected.js new file mode 100644 index 00000000000..889d307e6f9 --- /dev/null +++ b/test/form/samples/treeshake-presets/safest/_expected.js @@ -0,0 +1,29 @@ +console.log('dep'); + +console.log('main'); + +({ + get foo() { + console.log('effect'); + } +}.foo); + +try { + const noeffect = 1; +} catch {} + +unknownGlobal; + +let flag = true; + +function test() { + if (flag) var x = true; + if (x) { + return; + } + console.log('effect'); +} + +test(); +flag = false; +test(); diff --git a/test/form/samples/treeshake-presets/safest/dep.js b/test/form/samples/treeshake-presets/safest/dep.js new file mode 100644 index 00000000000..b74a9837c07 --- /dev/null +++ b/test/form/samples/treeshake-presets/safest/dep.js @@ -0,0 +1 @@ +console.log('dep'); diff --git a/test/form/samples/treeshake-presets/safest/main.js b/test/form/samples/treeshake-presets/safest/main.js new file mode 100644 index 00000000000..d6c035738d1 --- /dev/null +++ b/test/form/samples/treeshake-presets/safest/main.js @@ -0,0 +1,29 @@ +import './dep.js'; + +console.log('main'); + +({ + get foo() { + console.log('effect'); + } +}.foo); + +try { + const noeffect = 1; +} catch {} + +unknownGlobal; + +let flag = true; + +function test() { + if (flag) var x = true; + if (x) { + return; + } + console.log('effect'); +} + +test(); +flag = false; +test(); diff --git a/test/form/samples/treeshake-presets/smallest/_config.js b/test/form/samples/treeshake-presets/smallest/_config.js new file mode 100644 index 00000000000..67519625a65 --- /dev/null +++ b/test/form/samples/treeshake-presets/smallest/_config.js @@ -0,0 +1,27 @@ +const assert = require('node:assert'); +const path = require('node:path'); + +module.exports = defineTest({ + description: 'handles treeshake preset "smallest"', + options: { + treeshake: 'smallest', + plugins: [ + { + name: 'test', + buildStart(options) { + if (!options.treeshake) { + throw new Error('Treeshaking options not found'); + } + assert.strictEqual(options.treeshake.correctVarValueBeforeDeclaration, false); + assert.strictEqual(options.treeshake.propertyReadSideEffects, false); + assert.strictEqual(options.treeshake.tryCatchDeoptimization, false); + assert.strictEqual(options.treeshake.unknownGlobalSideEffects, false); + assert.strictEqual( + options.treeshake.moduleSideEffects(path.join(__dirname, 'dep.js'), false), + false + ); + } + } + ] + } +}); diff --git a/test/form/samples/treeshake-presets/smallest/_expected.js b/test/form/samples/treeshake-presets/smallest/_expected.js new file mode 100644 index 00000000000..46ba2af27ac --- /dev/null +++ b/test/form/samples/treeshake-presets/smallest/_expected.js @@ -0,0 +1,15 @@ +console.log('main'); + +let flag = true; + +function test() { + if (flag) var x = true; + if (x) { + return; + } + console.log('effect'); +} + +test(); +flag = false; +test(); diff --git a/test/form/samples/treeshake-presets/smallest/dep.js b/test/form/samples/treeshake-presets/smallest/dep.js new file mode 100644 index 00000000000..b74a9837c07 --- /dev/null +++ b/test/form/samples/treeshake-presets/smallest/dep.js @@ -0,0 +1 @@ +console.log('dep'); diff --git a/test/form/samples/treeshake-presets/smallest/main.js b/test/form/samples/treeshake-presets/smallest/main.js new file mode 100644 index 00000000000..d6c035738d1 --- /dev/null +++ b/test/form/samples/treeshake-presets/smallest/main.js @@ -0,0 +1,29 @@ +import './dep.js'; + +console.log('main'); + +({ + get foo() { + console.log('effect'); + } +}.foo); + +try { + const noeffect = 1; +} catch {} + +unknownGlobal; + +let flag = true; + +function test() { + if (flag) var x = true; + if (x) { + return; + } + console.log('effect'); +} + +test(); +flag = false; +test(); diff --git a/test/form/samples/treeshake-presets/true/_config.js b/test/form/samples/treeshake-presets/true/_config.js new file mode 100644 index 00000000000..dbdb5fd849a --- /dev/null +++ b/test/form/samples/treeshake-presets/true/_config.js @@ -0,0 +1,27 @@ +const assert = require('node:assert'); +const path = require('node:path'); + +module.exports = defineTest({ + description: 'handles treeshake preset true', + options: { + treeshake: true, + plugins: [ + { + name: 'test', + buildStart(options) { + if (!options.treeshake) { + throw new Error('Treeshaking is not enabled'); + } + assert.strictEqual(options.treeshake.correctVarValueBeforeDeclaration, false); + assert.strictEqual(options.treeshake.propertyReadSideEffects, true); + assert.strictEqual(options.treeshake.tryCatchDeoptimization, true); + assert.strictEqual(options.treeshake.unknownGlobalSideEffects, true); + assert.strictEqual( + options.treeshake.moduleSideEffects(path.join(__dirname, 'dep.js'), false), + true + ); + } + } + ] + } +}); diff --git a/test/form/samples/treeshake-presets/true/_expected.js b/test/form/samples/treeshake-presets/true/_expected.js new file mode 100644 index 00000000000..889d307e6f9 --- /dev/null +++ b/test/form/samples/treeshake-presets/true/_expected.js @@ -0,0 +1,29 @@ +console.log('dep'); + +console.log('main'); + +({ + get foo() { + console.log('effect'); + } +}.foo); + +try { + const noeffect = 1; +} catch {} + +unknownGlobal; + +let flag = true; + +function test() { + if (flag) var x = true; + if (x) { + return; + } + console.log('effect'); +} + +test(); +flag = false; +test(); diff --git a/test/form/samples/treeshake-presets/true/dep.js b/test/form/samples/treeshake-presets/true/dep.js new file mode 100644 index 00000000000..b74a9837c07 --- /dev/null +++ b/test/form/samples/treeshake-presets/true/dep.js @@ -0,0 +1 @@ +console.log('dep'); diff --git a/test/form/samples/treeshake-presets/true/main.js b/test/form/samples/treeshake-presets/true/main.js new file mode 100644 index 00000000000..d6c035738d1 --- /dev/null +++ b/test/form/samples/treeshake-presets/true/main.js @@ -0,0 +1,29 @@ +import './dep.js'; + +console.log('main'); + +({ + get foo() { + console.log('effect'); + } +}.foo); + +try { + const noeffect = 1; +} catch {} + +unknownGlobal; + +let flag = true; + +function test() { + if (flag) var x = true; + if (x) { + return; + } + console.log('effect'); +} + +test(); +flag = false; +test(); diff --git a/test/form/samples/treeshake-sequence-expressions/_config.js b/test/form/samples/treeshake-sequence-expressions/_config.js new file mode 100644 index 00000000000..4b854f85752 --- /dev/null +++ b/test/form/samples/treeshake-sequence-expressions/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'removes the last element of a sequence expression if it is unused' +}); diff --git a/test/form/samples/treeshake-sequence-expressions/_expected.js b/test/form/samples/treeshake-sequence-expressions/_expected.js new file mode 100644 index 00000000000..46ec11c0e7d --- /dev/null +++ b/test/form/samples/treeshake-sequence-expressions/_expected.js @@ -0,0 +1,5 @@ +console.log(1); +console.log(2); +console.log(3); +const x = (console.log(2), 3); +console.log(x); diff --git a/test/form/samples/treeshake-sequence-expressions/main.js b/test/form/samples/treeshake-sequence-expressions/main.js new file mode 100644 index 00000000000..8bb8224a18c --- /dev/null +++ b/test/form/samples/treeshake-sequence-expressions/main.js @@ -0,0 +1,6 @@ +1, 2, 3; +console.log(1), 2, 3; +1, console.log(2), 3; +1, 2, console.log(3); +const x = (1, console.log(2), 3); +console.log(x); diff --git a/test/form/samples/treeshake-unary/_config.js b/test/form/samples/treeshake-unary/_config.js new file mode 100644 index 00000000000..54b8d6d20a3 --- /dev/null +++ b/test/form/samples/treeshake-unary/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'treeshakes unary expressions' +}); diff --git a/test/form/samples/treeshake-unary/_expected.js b/test/form/samples/treeshake-unary/_expected.js new file mode 100644 index 00000000000..abc0b59660e --- /dev/null +++ b/test/form/samples/treeshake-unary/_expected.js @@ -0,0 +1,53 @@ +console.log(true); +console.log(false); +console.log(true); + +function foo2() { + console.log('has side effect'); + return false; +} +console.log(!foo2()); + +console.log(void 0); +console.log(typeof foo2); +console.log(-Infinity); +console.log(-180n); +console.log(-1000000100); +console.log(-1000001e3); +console.log(-0.011222); +console.log(-1222e-6); +console.log(-1e28); +console.log(-0); +console.log(Infinity); +console.log(-2); +console.log(false); + +function foo3() { + return false; +} + +console.log(delete foo3.a); + +switch (bar) { + case false: + console.log('false'); + break; + case true: + console.log('true'); + break; + case 1: + console.log('1'); + break; + case 1: + console.log('1'); + break; + case 1: + console.log('1'); + break; +} + +async function baz(){ + await true; +} + +export { baz }; diff --git a/test/form/samples/treeshake-unary/main.js b/test/form/samples/treeshake-unary/main.js new file mode 100644 index 00000000000..86fdd722978 --- /dev/null +++ b/test/form/samples/treeshake-unary/main.js @@ -0,0 +1,56 @@ +function foo() { + // removed + return false; +} + +console.log(!foo()); +console.log(!!foo()); +console.log(!!!foo()); + +function foo2() { + console.log('has side effect'); + return false; +} +console.log(!foo2()); + +console.log(void 0); +console.log(typeof foo2); +console.log(-(1 / 0)); +console.log(-180n); +console.log(-1000000100); +console.log(-1000001000); +console.log(-0.011222); +console.log(-0.001222); +console.log(-1e28); +console.log(-0); +console.log(+(1 / 0)); +console.log(~1); +console.log(!!!true); + +function foo3() { + return false; +} + +console.log(delete foo3.a); + +switch (bar) { + case!1: + console.log('false'); + break; + case!0: + console.log('true'); + break; + case+1: + console.log('1'); + break; + case~-2: + console.log('1'); + break; + case ~-2: + console.log('1'); + break; +} + +export async function baz(){ + await!0; +} \ No newline at end of file diff --git a/test/form/samples/try-statement-deoptimization/deactivate-via-option/_config.js b/test/form/samples/try-statement-deoptimization/deactivate-via-option/_config.js index 51ef18c06d6..3515683a734 100644 --- a/test/form/samples/try-statement-deoptimization/deactivate-via-option/_config.js +++ b/test/form/samples/try-statement-deoptimization/deactivate-via-option/_config.js @@ -1,8 +1,8 @@ -module.exports = { +module.exports = defineTest({ description: 'deactivates try-catch-deoptimization via option', options: { treeshake: { tryCatchDeoptimization: false } } -}; +}); diff --git a/test/form/samples/try-statement-deoptimization/deactivate-via-option/_expected.js b/test/form/samples/try-statement-deoptimization/deactivate-via-option/_expected.js index a8d430c8fbb..7a1891aaca5 100644 --- a/test/form/samples/try-statement-deoptimization/deactivate-via-option/_expected.js +++ b/test/form/samples/try-statement-deoptimization/deactivate-via-option/_expected.js @@ -6,13 +6,11 @@ const mutated = {}; function test(callback) { try { - callback(); mutate(mutated); } catch {} } -test(() => { -}); +test(); try {} finally { console.log('retained'); diff --git a/test/form/samples/try-statement-deoptimization/direct-inclusion/_config.js b/test/form/samples/try-statement-deoptimization/direct-inclusion/_config.js index 2b9014d625b..254e057ee62 100644 --- a/test/form/samples/try-statement-deoptimization/direct-inclusion/_config.js +++ b/test/form/samples/try-statement-deoptimization/direct-inclusion/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'retains side-effect-free code in try-statement-blocks' -}; +}); diff --git a/test/form/samples/try-statement-deoptimization/follow-parameters/_config.js b/test/form/samples/try-statement-deoptimization/follow-parameters/_config.js index 4093ba3d54e..c36adec4846 100644 --- a/test/form/samples/try-statement-deoptimization/follow-parameters/_config.js +++ b/test/form/samples/try-statement-deoptimization/follow-parameters/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'retains side-effect-free code in parameters called from try-statement-blocks' -}; +}); diff --git a/test/form/samples/try-statement-deoptimization/follow-pattern-parameters/_config.js b/test/form/samples/try-statement-deoptimization/follow-pattern-parameters/_config.js index 6ce753ad006..1eb45daf126 100644 --- a/test/form/samples/try-statement-deoptimization/follow-pattern-parameters/_config.js +++ b/test/form/samples/try-statement-deoptimization/follow-pattern-parameters/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'retains side-effect-free code in pattern parameters called from try-statement-blocks' -}; +}); diff --git a/test/form/samples/try-statement-deoptimization/follow-variables/_config.js b/test/form/samples/try-statement-deoptimization/follow-variables/_config.js index 7422ae5cf03..277d526d601 100644 --- a/test/form/samples/try-statement-deoptimization/follow-variables/_config.js +++ b/test/form/samples/try-statement-deoptimization/follow-variables/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'does not retain side-effect-free code in functions called from try-statement-blocks' -}; +}); diff --git a/test/form/samples/try-statement-deoptimization/include-via-outside-variable/_config.js b/test/form/samples/try-statement-deoptimization/include-via-outside-variable/_config.js index 8c0617a56c6..e6f03cf5d2f 100644 --- a/test/form/samples/try-statement-deoptimization/include-via-outside-variable/_config.js +++ b/test/form/samples/try-statement-deoptimization/include-via-outside-variable/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'works when the try-statement is included via an outside variable' -}; +}); diff --git a/test/form/samples/try-statement-deoptimization/supports-core-js/_config.js b/test/form/samples/try-statement-deoptimization/supports-core-js/_config.js index ee05dfb0bf9..ad69e3e1050 100644 --- a/test/form/samples/try-statement-deoptimization/supports-core-js/_config.js +++ b/test/form/samples/try-statement-deoptimization/supports-core-js/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'supports core-js feature detection (#2869)' -}; +}); diff --git a/test/form/samples/typeof-side-effect/_config.js b/test/form/samples/typeof-side-effect/_config.js index bbdda1c3147..99bb8e82b43 100644 --- a/test/form/samples/typeof-side-effect/_config.js +++ b/test/form/samples/typeof-side-effect/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'using typeof is does not trigger global side-effects' -}; +}); diff --git a/test/form/samples/umd-noconflict-extend/_config.js b/test/form/samples/umd-noconflict-extend/_config.js index 8ca8fb742a0..cb71f124fcc 100644 --- a/test/form/samples/umd-noconflict-extend/_config.js +++ b/test/form/samples/umd-noconflict-extend/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'exports noConflict method for default umd when requested', options: { output: { @@ -7,4 +7,4 @@ module.exports = { name: 'FooBar' } } -}; +}); diff --git a/test/form/samples/umd-noconflict-extend/_expected/amd.js b/test/form/samples/umd-noconflict-extend/_expected/amd.js index f2fd756cbda..7854ff6b6a0 100644 --- a/test/form/samples/umd-noconflict-extend/_expected/amd.js +++ b/test/form/samples/umd-noconflict-extend/_expected/amd.js @@ -1,4 +1,4 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; function doThings() { console.log( 'doing things...' ); @@ -12,6 +12,4 @@ define(['exports'], function (exports) { 'use strict'; exports.number = number; exports.setting = setting; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/form/samples/umd-noconflict-extend/_expected/cjs.js b/test/form/samples/umd-noconflict-extend/_expected/cjs.js index 05952881691..94847dc35a0 100644 --- a/test/form/samples/umd-noconflict-extend/_expected/cjs.js +++ b/test/form/samples/umd-noconflict-extend/_expected/cjs.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - function doThings() { console.log( 'doing things...' ); } diff --git a/test/form/samples/umd-noconflict-extend/_expected/iife.js b/test/form/samples/umd-noconflict-extend/_expected/iife.js index 4f2588f8f19..3458187fb27 100644 --- a/test/form/samples/umd-noconflict-extend/_expected/iife.js +++ b/test/form/samples/umd-noconflict-extend/_expected/iife.js @@ -13,6 +13,4 @@ exports.number = number; exports.setting = setting; - Object.defineProperty(exports, '__esModule', { value: true }); - -}(this.FooBar = this.FooBar || {})); +})(this.FooBar = this.FooBar || {}); diff --git a/test/form/samples/umd-noconflict-extend/_expected/system.js b/test/form/samples/umd-noconflict-extend/_expected/system.js index 50b3617c196..02967f7e93c 100644 --- a/test/form/samples/umd-noconflict-extend/_expected/system.js +++ b/test/form/samples/umd-noconflict-extend/_expected/system.js @@ -1,18 +1,18 @@ -System.register('FooBar', [], function (exports) { +System.register('FooBar', [], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - exports('doThings', doThings); + exports("doThings", doThings); function doThings() { console.log( 'doing things...' ); } - const number = exports('number', 42); + const number = exports("number", 42); - var setting = exports('setting', 'no'); + var setting = exports("setting", 'no'); - } + }) }; -}); +})); diff --git a/test/form/samples/umd-noconflict-extend/_expected/umd.js b/test/form/samples/umd-noconflict-extend/_expected/umd.js index 148718c54c7..d3628d82101 100644 --- a/test/form/samples/umd-noconflict-extend/_expected/umd.js +++ b/test/form/samples/umd-noconflict-extend/_expected/umd.js @@ -6,8 +6,8 @@ var exports = global.FooBar = global.FooBar || {}; factory(exports); exports.noConflict = function () { global.FooBar = current; return exports; }; - }())); -}(this, (function (exports) { 'use strict'; + })()); +})(this, (function (exports) { 'use strict'; function doThings() { console.log( 'doing things...' ); @@ -21,6 +21,4 @@ exports.number = number; exports.setting = setting; - Object.defineProperty(exports, '__esModule', { value: true }); - -}))); +})); diff --git a/test/form/samples/umd-noconflict-namespaced/_config.js b/test/form/samples/umd-noconflict-namespaced/_config.js index 5a404b1f2da..22ba6ee0073 100644 --- a/test/form/samples/umd-noconflict-namespaced/_config.js +++ b/test/form/samples/umd-noconflict-namespaced/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'exports noConflict method for default umd when requested', options: { output: { @@ -6,4 +6,4 @@ module.exports = { name: 'my.name.spaced.module' } } -}; +}); diff --git a/test/form/samples/umd-noconflict-namespaced/_expected/amd.js b/test/form/samples/umd-noconflict-namespaced/_expected/amd.js index f2fd756cbda..7854ff6b6a0 100644 --- a/test/form/samples/umd-noconflict-namespaced/_expected/amd.js +++ b/test/form/samples/umd-noconflict-namespaced/_expected/amd.js @@ -1,4 +1,4 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; function doThings() { console.log( 'doing things...' ); @@ -12,6 +12,4 @@ define(['exports'], function (exports) { 'use strict'; exports.number = number; exports.setting = setting; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/form/samples/umd-noconflict-namespaced/_expected/cjs.js b/test/form/samples/umd-noconflict-namespaced/_expected/cjs.js index 05952881691..94847dc35a0 100644 --- a/test/form/samples/umd-noconflict-namespaced/_expected/cjs.js +++ b/test/form/samples/umd-noconflict-namespaced/_expected/cjs.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - function doThings() { console.log( 'doing things...' ); } diff --git a/test/form/samples/umd-noconflict-namespaced/_expected/iife.js b/test/form/samples/umd-noconflict-namespaced/_expected/iife.js index 2d11e13eb7a..9499324cf8e 100644 --- a/test/form/samples/umd-noconflict-namespaced/_expected/iife.js +++ b/test/form/samples/umd-noconflict-namespaced/_expected/iife.js @@ -16,8 +16,6 @@ this.my.name.spaced.module = (function (exports) { exports.number = number; exports.setting = setting; - Object.defineProperty(exports, '__esModule', { value: true }); - return exports; -}({})); +})({}); diff --git a/test/form/samples/umd-noconflict-namespaced/_expected/system.js b/test/form/samples/umd-noconflict-namespaced/_expected/system.js index 3a0183e00d5..afbb47c4baf 100644 --- a/test/form/samples/umd-noconflict-namespaced/_expected/system.js +++ b/test/form/samples/umd-noconflict-namespaced/_expected/system.js @@ -1,18 +1,18 @@ -System.register('my.name.spaced.module', [], function (exports) { +System.register('my.name.spaced.module', [], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - exports('doThings', doThings); + exports("doThings", doThings); function doThings() { console.log( 'doing things...' ); } - const number = exports('number', 42); + const number = exports("number", 42); - var setting = exports('setting', 'no'); + var setting = exports("setting", 'no'); - } + }) }; -}); +})); diff --git a/test/form/samples/umd-noconflict-namespaced/_expected/umd.js b/test/form/samples/umd-noconflict-namespaced/_expected/umd.js index 02fb7e6e363..7bc84974f32 100644 --- a/test/form/samples/umd-noconflict-namespaced/_expected/umd.js +++ b/test/form/samples/umd-noconflict-namespaced/_expected/umd.js @@ -6,8 +6,8 @@ var exports = (global.my = global.my || {}, global.my.name = global.my.name || {}, global.my.name.spaced = global.my.name.spaced || {}, global.my.name.spaced.module = {}); factory(exports); exports.noConflict = function () { global.my.name.spaced.module = current; return exports; }; - }())); -}(this, (function (exports) { 'use strict'; + })()); +})(this, (function (exports) { 'use strict'; function doThings() { console.log( 'doing things...' ); @@ -21,6 +21,4 @@ exports.number = number; exports.setting = setting; - Object.defineProperty(exports, '__esModule', { value: true }); - -}))); +})); diff --git a/test/form/samples/umd-noconflict-no-exports/_config.js b/test/form/samples/umd-noconflict-no-exports/_config.js index 93a353386b0..8ce873ecaf0 100644 --- a/test/form/samples/umd-noconflict-no-exports/_config.js +++ b/test/form/samples/umd-noconflict-no-exports/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'exports noConflict even when there are no exports', options: { output: { @@ -6,4 +6,4 @@ module.exports = { name: 'FooBar' } } -}; +}); diff --git a/test/form/samples/umd-noconflict-no-exports/_expected/amd.js b/test/form/samples/umd-noconflict-no-exports/_expected/amd.js index 861a053bf95..68a316e6896 100644 --- a/test/form/samples/umd-noconflict-no-exports/_expected/amd.js +++ b/test/form/samples/umd-noconflict-no-exports/_expected/amd.js @@ -1,5 +1,5 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; console.log('no exports'); -}); +})); diff --git a/test/form/samples/umd-noconflict-no-exports/_expected/iife.js b/test/form/samples/umd-noconflict-no-exports/_expected/iife.js index 13ad15c8736..3e1b72c6f80 100644 --- a/test/form/samples/umd-noconflict-no-exports/_expected/iife.js +++ b/test/form/samples/umd-noconflict-no-exports/_expected/iife.js @@ -3,4 +3,4 @@ console.log('no exports'); -}()); +})(); diff --git a/test/form/samples/umd-noconflict-no-exports/_expected/system.js b/test/form/samples/umd-noconflict-no-exports/_expected/system.js index 04195b57c57..5f9b5691d66 100644 --- a/test/form/samples/umd-noconflict-no-exports/_expected/system.js +++ b/test/form/samples/umd-noconflict-no-exports/_expected/system.js @@ -1,10 +1,10 @@ -System.register('FooBar', [], function () { +System.register('FooBar', [], (function () { 'use strict'; return { - execute: function () { + execute: (function () { console.log('no exports'); - } + }) }; -}); +})); diff --git a/test/form/samples/umd-noconflict-no-exports/_expected/umd.js b/test/form/samples/umd-noconflict-no-exports/_expected/umd.js index d088870abc1..ca71c706eb9 100644 --- a/test/form/samples/umd-noconflict-no-exports/_expected/umd.js +++ b/test/form/samples/umd-noconflict-no-exports/_expected/umd.js @@ -6,9 +6,9 @@ var exports = global.FooBar = {}; factory(exports); exports.noConflict = function () { global.FooBar = current; return exports; }; - }())); -}(this, (function (exports) { 'use strict'; + })()); +})(this, (function (exports) { 'use strict'; console.log('no exports'); -}))); +})); diff --git a/test/form/samples/umd-noconflict/_config.js b/test/form/samples/umd-noconflict/_config.js index 69e810bb044..c24d5fecf6b 100644 --- a/test/form/samples/umd-noconflict/_config.js +++ b/test/form/samples/umd-noconflict/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'exports noConflict method for default umd when requested', options: { output: { @@ -6,4 +6,4 @@ module.exports = { name: 'FooBar' } } -}; +}); diff --git a/test/form/samples/umd-noconflict/_expected/amd.js b/test/form/samples/umd-noconflict/_expected/amd.js index f2fd756cbda..7854ff6b6a0 100644 --- a/test/form/samples/umd-noconflict/_expected/amd.js +++ b/test/form/samples/umd-noconflict/_expected/amd.js @@ -1,4 +1,4 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; function doThings() { console.log( 'doing things...' ); @@ -12,6 +12,4 @@ define(['exports'], function (exports) { 'use strict'; exports.number = number; exports.setting = setting; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/form/samples/umd-noconflict/_expected/cjs.js b/test/form/samples/umd-noconflict/_expected/cjs.js index 05952881691..94847dc35a0 100644 --- a/test/form/samples/umd-noconflict/_expected/cjs.js +++ b/test/form/samples/umd-noconflict/_expected/cjs.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - function doThings() { console.log( 'doing things...' ); } diff --git a/test/form/samples/umd-noconflict/_expected/iife.js b/test/form/samples/umd-noconflict/_expected/iife.js index 08612208549..257d74ec593 100644 --- a/test/form/samples/umd-noconflict/_expected/iife.js +++ b/test/form/samples/umd-noconflict/_expected/iife.js @@ -13,8 +13,6 @@ var FooBar = (function (exports) { exports.number = number; exports.setting = setting; - Object.defineProperty(exports, '__esModule', { value: true }); - return exports; -}({})); +})({}); diff --git a/test/form/samples/umd-noconflict/_expected/system.js b/test/form/samples/umd-noconflict/_expected/system.js index 50b3617c196..02967f7e93c 100644 --- a/test/form/samples/umd-noconflict/_expected/system.js +++ b/test/form/samples/umd-noconflict/_expected/system.js @@ -1,18 +1,18 @@ -System.register('FooBar', [], function (exports) { +System.register('FooBar', [], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - exports('doThings', doThings); + exports("doThings", doThings); function doThings() { console.log( 'doing things...' ); } - const number = exports('number', 42); + const number = exports("number", 42); - var setting = exports('setting', 'no'); + var setting = exports("setting", 'no'); - } + }) }; -}); +})); diff --git a/test/form/samples/umd-noconflict/_expected/umd.js b/test/form/samples/umd-noconflict/_expected/umd.js index fe606d7300d..a6ac7db34f1 100644 --- a/test/form/samples/umd-noconflict/_expected/umd.js +++ b/test/form/samples/umd-noconflict/_expected/umd.js @@ -6,8 +6,8 @@ var exports = global.FooBar = {}; factory(exports); exports.noConflict = function () { global.FooBar = current; return exports; }; - }())); -}(this, (function (exports) { 'use strict'; + })()); +})(this, (function (exports) { 'use strict'; function doThings() { console.log( 'doing things...' ); @@ -21,6 +21,4 @@ exports.number = number; exports.setting = setting; - Object.defineProperty(exports, '__esModule', { value: true }); - -}))); +})); diff --git a/test/form/samples/unary-expressions-literal-value/_config.js b/test/form/samples/unary-expressions-literal-value/_config.js new file mode 100644 index 00000000000..a51bbef3d0c --- /dev/null +++ b/test/form/samples/unary-expressions-literal-value/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'Optimize the literal value of unary expressions to remove the unused code' +}); diff --git a/test/form/samples/unary-expressions-literal-value/_expected.js b/test/form/samples/unary-expressions-literal-value/_expected.js new file mode 100644 index 00000000000..55369b20580 --- /dev/null +++ b/test/form/samples/unary-expressions-literal-value/_expected.js @@ -0,0 +1,5 @@ +bar(); + +bar(); + +bar(); diff --git a/test/form/samples/unary-expressions-literal-value/main.js b/test/form/samples/unary-expressions-literal-value/main.js new file mode 100644 index 00000000000..6936d383e27 --- /dev/null +++ b/test/form/samples/unary-expressions-literal-value/main.js @@ -0,0 +1,9 @@ +void Symbol(1) ? foo() : bar(); + +!(Symbol(1) || true) ? foo() : bar(); + +quz() ? foo() : bar(); + +function quz() { + return !!(Symbol(1) && false); +} diff --git a/test/form/samples/unary-expressions-preserve-constants/_config.js b/test/form/samples/unary-expressions-preserve-constants/_config.js new file mode 100644 index 00000000000..da9b696b905 --- /dev/null +++ b/test/form/samples/unary-expressions-preserve-constants/_config.js @@ -0,0 +1,4 @@ +module.exports = defineTest({ + description: + 'Preserves constant identifiers in unary expressions when constants are used elsewhere' +}); diff --git a/test/form/samples/unary-expressions-preserve-constants/_expected.js b/test/form/samples/unary-expressions-preserve-constants/_expected.js new file mode 100644 index 00000000000..2bdd580075f --- /dev/null +++ b/test/form/samples/unary-expressions-preserve-constants/_expected.js @@ -0,0 +1,25 @@ +const BOB = 3; +const ALICE = 5; + +function getBob() { + return {x: BOB, y: -BOB, z: +BOB}; +} + +function getAlice() { + console.log(ALICE); + return ~ALICE; +} + +// Test with different operators +function testOperators() { + return { + negate: -BOB, + plus: +BOB, + not: !BOB, + bitwise: ~BOB, + typeof: typeof BOB, + void: void BOB + }; +} + +export { ALICE, BOB, getAlice, getBob, testOperators }; diff --git a/test/form/samples/unary-expressions-preserve-constants/main.js b/test/form/samples/unary-expressions-preserve-constants/main.js new file mode 100644 index 00000000000..9dc8dcce39a --- /dev/null +++ b/test/form/samples/unary-expressions-preserve-constants/main.js @@ -0,0 +1,23 @@ +export const BOB = 3; +export const ALICE = 5; + +export function getBob() { + return {x: BOB, y: -BOB, z: +BOB}; +} + +export function getAlice() { + console.log(ALICE); + return ~ALICE; +} + +// Test with different operators +export function testOperators() { + return { + negate: -BOB, + plus: +BOB, + not: !BOB, + bitwise: ~BOB, + typeof: typeof BOB, + void: void BOB + }; +} diff --git a/test/form/samples/unary-expressions/_config.js b/test/form/samples/unary-expressions/_config.js index 9e363ae5176..beef6b92d99 100644 --- a/test/form/samples/unary-expressions/_config.js +++ b/test/form/samples/unary-expressions/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'handles unary expression side-effects' -}; +}); diff --git a/test/form/samples/unary-expressions/_expected.js b/test/form/samples/unary-expressions/_expected.js index d51c6bfe41b..1743f0f520f 100644 --- a/test/form/samples/unary-expressions/_expected.js +++ b/test/form/samples/unary-expressions/_expected.js @@ -1,4 +1,4 @@ -if ((!true).unknown) { +if ((false).unknown) { console.log('retained'); } else { console.log('retained'); diff --git a/test/form/samples/undefined-default-export/_config.js b/test/form/samples/undefined-default-export/_config.js index 1149b6e503d..ac9baa670ac 100644 --- a/test/form/samples/undefined-default-export/_config.js +++ b/test/form/samples/undefined-default-export/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'handles default exporting undefined' -}; +}); diff --git a/test/form/samples/undefined-properties/_config.js b/test/form/samples/undefined-properties/_config.js deleted file mode 100644 index a89e4af5ef0..00000000000 --- a/test/form/samples/undefined-properties/_config.js +++ /dev/null @@ -1,4 +0,0 @@ -module.exports = { - description: 'detects undefined properties', - expectedWarnings: ['EMPTY_BUNDLE'] -}; diff --git a/test/form/samples/undefined-properties/main.js b/test/form/samples/undefined-properties/main.js deleted file mode 100644 index e7df0af9514..00000000000 --- a/test/form/samples/undefined-properties/main.js +++ /dev/null @@ -1,8 +0,0 @@ -var a = { - b: { - c: 'd' - } -}; - -if (a.b.d) - console.log('yes'); \ No newline at end of file diff --git a/test/form/samples/undefined-var/_config.js b/test/form/samples/undefined-var/_config.js index 7144d47d8f1..c516217f427 100644 --- a/test/form/samples/undefined-var/_config.js +++ b/test/form/samples/undefined-var/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'treeshakes undefined variable literals' -}; +}); diff --git a/test/form/samples/unknown-token-effects/_config.js b/test/form/samples/unknown-token-effects/_config.js deleted file mode 100644 index 9f9b2eac443..00000000000 --- a/test/form/samples/unknown-token-effects/_config.js +++ /dev/null @@ -1,17 +0,0 @@ -module.exports = { - description: 'does not tree-shake unknown tokens', - options: { - acornInjectPlugins: Parser => - class extends Parser { - parseExprAtom(refDestructuringErrors) { - if (this.type.keyword === 'do') { - this.eat(this.type); - const node = this.startNode(); - node.body = this.parseBlock(); - return this.finishNode(node, 'DoExpression'); - } - return super.parseExprAtom(refDestructuringErrors); - } - } - } -}; diff --git a/test/form/samples/unknown-token-effects/_expected.js b/test/form/samples/unknown-token-effects/_expected.js deleted file mode 100644 index ecb1863985c..00000000000 --- a/test/form/samples/unknown-token-effects/_expected.js +++ /dev/null @@ -1,34 +0,0 @@ -(do { - () => console.log('retained'); -}()); -(do { - null; -}.y); -(do { - ({ y: () => console.log('retained') }); -}.y()); -(do { - ({ - set y(value) { - console.log(value); - } - }); -}.y = 'retained'); - -const functionUsedInExpr = () => 1; -const objectUsedInExpr = { value: 2 }; -const valueUsedInExpr = 3; - -const exprValue = do { - if (unknownCondition1) { - functionUsedInExpr(); - } else if (unknownCondition2) { - objectUsedInExpr.value; - } else if (unknownCondition3) { - valueUsedInExpr; - } else { - 'direct value'; - } -}; - -export { exprValue }; diff --git a/test/form/samples/unknown-token-effects/main.js b/test/form/samples/unknown-token-effects/main.js deleted file mode 100644 index 6242104883a..00000000000 --- a/test/form/samples/unknown-token-effects/main.js +++ /dev/null @@ -1,32 +0,0 @@ -(do { - () => console.log('retained'); -}()); -(do { - null; -}.y); -(do { - ({ y: () => console.log('retained') }); -}.y()); -(do { - ({ - set y(value) { - console.log(value); - } - }); -}.y = 'retained'); - -const functionUsedInExpr = () => 1; -const objectUsedInExpr = { value: 2 }; -const valueUsedInExpr = 3; - -export const exprValue = do { - if (unknownCondition1) { - functionUsedInExpr(); - } else if (unknownCondition2) { - objectUsedInExpr.value; - } else if (unknownCondition3) { - valueUsedInExpr; - } else { - 'direct value' - } -}; diff --git a/test/form/samples/unmodified-default-exports-function-argument/_config.js b/test/form/samples/unmodified-default-exports-function-argument/_config.js index 3ccba4c4a9e..2d939cc98fb 100644 --- a/test/form/samples/unmodified-default-exports-function-argument/_config.js +++ b/test/form/samples/unmodified-default-exports-function-argument/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'passing unbound default export to function cannot rebind it' -}; +}); diff --git a/test/form/samples/unmodified-default-exports/_config.js b/test/form/samples/unmodified-default-exports/_config.js index c37ef0f18d7..ed52a41221f 100644 --- a/test/form/samples/unmodified-default-exports/_config.js +++ b/test/form/samples/unmodified-default-exports/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'does not treat property assignment as rebinding for sake of unbound default exports' -}; +}); diff --git a/test/form/samples/unused-called-import/_config.js b/test/form/samples/unused-called-import/_config.js index 0f1029d3236..f5a7460e1ae 100644 --- a/test/form/samples/unused-called-import/_config.js +++ b/test/form/samples/unused-called-import/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'does not include called-in-unused-code import' -}; +}); diff --git a/test/form/samples/unused-called-import/_expected/amd.js b/test/form/samples/unused-called-import/_expected/amd.js index b9ef0a7058b..41a24f9bf1b 100644 --- a/test/form/samples/unused-called-import/_expected/amd.js +++ b/test/form/samples/unused-called-import/_expected/amd.js @@ -1,7 +1,7 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; function foo() { return 'foo'; } assert.equal( foo(), 'foo' ); -}); +})); diff --git a/test/form/samples/unused-called-import/_expected/iife.js b/test/form/samples/unused-called-import/_expected/iife.js index 645453ade5a..b1b36c314a3 100644 --- a/test/form/samples/unused-called-import/_expected/iife.js +++ b/test/form/samples/unused-called-import/_expected/iife.js @@ -5,4 +5,4 @@ assert.equal( foo(), 'foo' ); -}()); +})(); diff --git a/test/form/samples/unused-called-import/_expected/system.js b/test/form/samples/unused-called-import/_expected/system.js index 6efccc5fd34..b775f5fc159 100644 --- a/test/form/samples/unused-called-import/_expected/system.js +++ b/test/form/samples/unused-called-import/_expected/system.js @@ -1,12 +1,12 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { function foo() { return 'foo'; } assert.equal( foo(), 'foo' ); - } + }) }; -}); +})); diff --git a/test/form/samples/unused-called-import/_expected/umd.js b/test/form/samples/unused-called-import/_expected/umd.js index a80a818e2c7..494675745ae 100644 --- a/test/form/samples/unused-called-import/_expected/umd.js +++ b/test/form/samples/unused-called-import/_expected/umd.js @@ -1,10 +1,10 @@ (function (factory) { typeof define === 'function' && define.amd ? define(factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; function foo() { return 'foo'; } assert.equal( foo(), 'foo' ); -}))); +})); diff --git a/test/form/samples/unused-called-with-side-effects/_config.js b/test/form/samples/unused-called-with-side-effects/_config.js index 0f1029d3236..f5a7460e1ae 100644 --- a/test/form/samples/unused-called-with-side-effects/_config.js +++ b/test/form/samples/unused-called-with-side-effects/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'does not include called-in-unused-code import' -}; +}); diff --git a/test/form/samples/unused-called-with-side-effects/_expected/amd.js b/test/form/samples/unused-called-with-side-effects/_expected/amd.js index 8be9631bd93..27a46c2b3ed 100644 --- a/test/form/samples/unused-called-with-side-effects/_expected/amd.js +++ b/test/form/samples/unused-called-with-side-effects/_expected/amd.js @@ -1,4 +1,4 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; function foo() { return 'foo' @@ -6,4 +6,4 @@ define(function () { 'use strict'; assert.equal( foo(), 'foo' ); -}); +})); diff --git a/test/form/samples/unused-called-with-side-effects/_expected/iife.js b/test/form/samples/unused-called-with-side-effects/_expected/iife.js index ccdb513770d..486507072b3 100644 --- a/test/form/samples/unused-called-with-side-effects/_expected/iife.js +++ b/test/form/samples/unused-called-with-side-effects/_expected/iife.js @@ -7,4 +7,4 @@ assert.equal( foo(), 'foo' ); -}()); +})(); diff --git a/test/form/samples/unused-called-with-side-effects/_expected/system.js b/test/form/samples/unused-called-with-side-effects/_expected/system.js index 39ac06ae5b5..1819b411595 100644 --- a/test/form/samples/unused-called-with-side-effects/_expected/system.js +++ b/test/form/samples/unused-called-with-side-effects/_expected/system.js @@ -1,7 +1,7 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { function foo() { return 'foo' @@ -9,6 +9,6 @@ System.register([], function () { assert.equal( foo(), 'foo' ); - } + }) }; -}); +})); diff --git a/test/form/samples/unused-called-with-side-effects/_expected/umd.js b/test/form/samples/unused-called-with-side-effects/_expected/umd.js index 56efa82701e..05cd01a517f 100644 --- a/test/form/samples/unused-called-with-side-effects/_expected/umd.js +++ b/test/form/samples/unused-called-with-side-effects/_expected/umd.js @@ -1,7 +1,7 @@ (function (factory) { typeof define === 'function' && define.amd ? define(factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; function foo() { return 'foo' @@ -9,4 +9,4 @@ assert.equal( foo(), 'foo' ); -}))); +})); diff --git a/test/form/samples/unused-default-exports/_config.js b/test/form/samples/unused-default-exports/_config.js index 31eeacde501..00ac617d1d8 100644 --- a/test/form/samples/unused-default-exports/_config.js +++ b/test/form/samples/unused-default-exports/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'does not name unused-but-included default export' -}; +}); diff --git a/test/form/samples/unused-default-exports/_expected/amd.js b/test/form/samples/unused-default-exports/_expected/amd.js index 78573431c22..c9e995f30a5 100644 --- a/test/form/samples/unused-default-exports/_expected/amd.js +++ b/test/form/samples/unused-default-exports/_expected/amd.js @@ -1,4 +1,4 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; var foo = { value: 1 }; @@ -11,4 +11,4 @@ define(function () { 'use strict'; assert.equal( foo.value, 2 ); -}); +})); diff --git a/test/form/samples/unused-default-exports/_expected/iife.js b/test/form/samples/unused-default-exports/_expected/iife.js index 2c6a51572d0..ed5ba8f8a33 100644 --- a/test/form/samples/unused-default-exports/_expected/iife.js +++ b/test/form/samples/unused-default-exports/_expected/iife.js @@ -12,4 +12,4 @@ assert.equal( foo.value, 2 ); -}()); +})(); diff --git a/test/form/samples/unused-default-exports/_expected/system.js b/test/form/samples/unused-default-exports/_expected/system.js index b739002d779..4c9981aabae 100644 --- a/test/form/samples/unused-default-exports/_expected/system.js +++ b/test/form/samples/unused-default-exports/_expected/system.js @@ -1,7 +1,7 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { var foo = { value: 1 }; @@ -14,6 +14,6 @@ System.register([], function () { assert.equal( foo.value, 2 ); - } + }) }; -}); +})); diff --git a/test/form/samples/unused-default-exports/_expected/umd.js b/test/form/samples/unused-default-exports/_expected/umd.js index 708608f9243..0aec0d70b38 100644 --- a/test/form/samples/unused-default-exports/_expected/umd.js +++ b/test/form/samples/unused-default-exports/_expected/umd.js @@ -1,7 +1,7 @@ (function (factory) { typeof define === 'function' && define.amd ? define(factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; var foo = { value: 1 }; @@ -14,4 +14,4 @@ assert.equal( foo.value, 2 ); -}))); +})); diff --git a/test/form/samples/unused-function-and-class-expressions/_config.js b/test/form/samples/unused-function-and-class-expressions/_config.js index d45e980e08a..1bd53412422 100644 --- a/test/form/samples/unused-function-and-class-expressions/_config.js +++ b/test/form/samples/unused-function-and-class-expressions/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'properly remove unused function and class expressions' -}; +}); diff --git a/test/form/samples/unused-function-and-class-expressions/_expected/amd.js b/test/form/samples/unused-function-and-class-expressions/_expected/amd.js index da2ca3527c2..db5784b8c72 100644 --- a/test/form/samples/unused-function-and-class-expressions/_expected/amd.js +++ b/test/form/samples/unused-function-and-class-expressions/_expected/amd.js @@ -1,4 +1,4 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; function foo() { console.log("foo"); @@ -6,4 +6,4 @@ define(function () { 'use strict'; foo(); -}); +})); diff --git a/test/form/samples/unused-function-and-class-expressions/_expected/iife.js b/test/form/samples/unused-function-and-class-expressions/_expected/iife.js index b1ac97f22cf..9a66fb96927 100644 --- a/test/form/samples/unused-function-and-class-expressions/_expected/iife.js +++ b/test/form/samples/unused-function-and-class-expressions/_expected/iife.js @@ -7,4 +7,4 @@ foo(); -}()); +})(); diff --git a/test/form/samples/unused-function-and-class-expressions/_expected/system.js b/test/form/samples/unused-function-and-class-expressions/_expected/system.js index 0151e8d9b48..ccf8bd29b38 100644 --- a/test/form/samples/unused-function-and-class-expressions/_expected/system.js +++ b/test/form/samples/unused-function-and-class-expressions/_expected/system.js @@ -1,7 +1,7 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { function foo() { console.log("foo"); @@ -9,6 +9,6 @@ System.register([], function () { foo(); - } + }) }; -}); +})); diff --git a/test/form/samples/unused-function-and-class-expressions/_expected/umd.js b/test/form/samples/unused-function-and-class-expressions/_expected/umd.js index 640549e9a0c..5e612caf809 100644 --- a/test/form/samples/unused-function-and-class-expressions/_expected/umd.js +++ b/test/form/samples/unused-function-and-class-expressions/_expected/umd.js @@ -1,7 +1,7 @@ (function (factory) { typeof define === 'function' && define.amd ? define(factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; function foo() { console.log("foo"); @@ -9,4 +9,4 @@ foo(); -}))); +})); diff --git a/test/form/samples/unused-import/_config.js b/test/form/samples/unused-import/_config.js index 905b43be2bf..c226e0233b2 100644 --- a/test/form/samples/unused-import/_config.js +++ b/test/form/samples/unused-import/_config.js @@ -1,10 +1,9 @@ -module.exports = { +module.exports = defineTest({ description: 'excludes unused imports ([#595])', options: { external: ['external'], output: { - globals: { external: 'external' }, - systemNullSetters: true + globals: { external: 'external' } } } -}; +}); diff --git a/test/form/samples/unused-import/_expected/amd.js b/test/form/samples/unused-import/_expected/amd.js index cf0fc03cc9c..23be7b2b64c 100644 --- a/test/form/samples/unused-import/_expected/amd.js +++ b/test/form/samples/unused-import/_expected/amd.js @@ -1,5 +1,5 @@ -define(['external'], function (external) { 'use strict'; +define(['external'], (function (external) { 'use strict'; -}); +})); diff --git a/test/form/samples/unused-import/_expected/iife.js b/test/form/samples/unused-import/_expected/iife.js index 43ef5426880..31dfeb95ed9 100644 --- a/test/form/samples/unused-import/_expected/iife.js +++ b/test/form/samples/unused-import/_expected/iife.js @@ -3,4 +3,4 @@ -}()); +})(); diff --git a/test/form/samples/unused-import/_expected/system.js b/test/form/samples/unused-import/_expected/system.js index bddf5f14220..f950dd1bbc9 100644 --- a/test/form/samples/unused-import/_expected/system.js +++ b/test/form/samples/unused-import/_expected/system.js @@ -1,11 +1,11 @@ -System.register(['external'], function () { +System.register(['external'], (function () { 'use strict'; return { setters: [null], - execute: function () { + execute: (function () { - } + }) }; -}); +})); diff --git a/test/form/samples/unused-import/_expected/umd.js b/test/form/samples/unused-import/_expected/umd.js index e4f8be89456..60f03df0b22 100644 --- a/test/form/samples/unused-import/_expected/umd.js +++ b/test/form/samples/unused-import/_expected/umd.js @@ -1,8 +1,8 @@ (function (factory) { typeof define === 'function' && define.amd ? define(['external'], factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; -}))); +})); diff --git a/test/form/samples/unused-import/main.js b/test/form/samples/unused-import/main.js index ce3e0cb6298..55c90f2c21a 100644 --- a/test/form/samples/unused-import/main.js +++ b/test/form/samples/unused-import/main.js @@ -1,4 +1,4 @@ -import { unused } from 'external'; +import 'external'; function alsoUnused () { unused(); diff --git a/test/form/samples/unused-inner-functions-and-classes/_config.js b/test/form/samples/unused-inner-functions-and-classes/_config.js index 76b31d1b101..4cc2333a8a3 100644 --- a/test/form/samples/unused-inner-functions-and-classes/_config.js +++ b/test/form/samples/unused-inner-functions-and-classes/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'does not include unused inner functions and classes' -}; +}); diff --git a/test/form/samples/unused-inner-functions-and-classes/_expected/amd.js b/test/form/samples/unused-inner-functions-and-classes/_expected/amd.js index e1eb59196ea..fff302d58e8 100644 --- a/test/form/samples/unused-inner-functions-and-classes/_expected/amd.js +++ b/test/form/samples/unused-inner-functions-and-classes/_expected/amd.js @@ -1,4 +1,4 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; function bar () { console.log("outer bar"); } @@ -20,4 +20,4 @@ define(function () { 'use strict'; console.log( getClass().name ); -}); +})); diff --git a/test/form/samples/unused-inner-functions-and-classes/_expected/iife.js b/test/form/samples/unused-inner-functions-and-classes/_expected/iife.js index 7759377c142..352c9805fa6 100644 --- a/test/form/samples/unused-inner-functions-and-classes/_expected/iife.js +++ b/test/form/samples/unused-inner-functions-and-classes/_expected/iife.js @@ -21,4 +21,4 @@ console.log( getClass().name ); -}()); +})(); diff --git a/test/form/samples/unused-inner-functions-and-classes/_expected/system.js b/test/form/samples/unused-inner-functions-and-classes/_expected/system.js index 012aeb76037..2a597a5cccb 100644 --- a/test/form/samples/unused-inner-functions-and-classes/_expected/system.js +++ b/test/form/samples/unused-inner-functions-and-classes/_expected/system.js @@ -1,7 +1,7 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { function bar () { console.log("outer bar"); } @@ -23,6 +23,6 @@ System.register([], function () { console.log( getClass().name ); - } + }) }; -}); +})); diff --git a/test/form/samples/unused-inner-functions-and-classes/_expected/umd.js b/test/form/samples/unused-inner-functions-and-classes/_expected/umd.js index 512ea191f81..a2cec2a16dc 100644 --- a/test/form/samples/unused-inner-functions-and-classes/_expected/umd.js +++ b/test/form/samples/unused-inner-functions-and-classes/_expected/umd.js @@ -1,7 +1,7 @@ (function (factory) { typeof define === 'function' && define.amd ? define(factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; function bar () { console.log("outer bar"); } @@ -23,4 +23,4 @@ console.log( getClass().name ); -}))); +})); diff --git a/test/form/samples/unused-var/_config.js b/test/form/samples/unused-var/_config.js index b89eb86733e..c4abc4beadf 100644 --- a/test/form/samples/unused-var/_config.js +++ b/test/form/samples/unused-var/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'omits unused var declaration' -}; +}); diff --git a/test/form/samples/unused-var/_expected/amd.js b/test/form/samples/unused-var/_expected/amd.js index 29e6e692419..bf7a35d921a 100644 --- a/test/form/samples/unused-var/_expected/amd.js +++ b/test/form/samples/unused-var/_expected/amd.js @@ -1,7 +1,7 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; var foo = 'lol'; console.log( foo ); -}); +})); diff --git a/test/form/samples/unused-var/_expected/iife.js b/test/form/samples/unused-var/_expected/iife.js index e50863df51f..3d80d3599a3 100644 --- a/test/form/samples/unused-var/_expected/iife.js +++ b/test/form/samples/unused-var/_expected/iife.js @@ -5,4 +5,4 @@ console.log( foo ); -}()); +})(); diff --git a/test/form/samples/unused-var/_expected/system.js b/test/form/samples/unused-var/_expected/system.js index 29f4d12cf84..c5ac67e8c30 100644 --- a/test/form/samples/unused-var/_expected/system.js +++ b/test/form/samples/unused-var/_expected/system.js @@ -1,12 +1,12 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { var foo = 'lol'; console.log( foo ); - } + }) }; -}); +})); diff --git a/test/form/samples/unused-var/_expected/umd.js b/test/form/samples/unused-var/_expected/umd.js index 775b46ba2af..3727ca26377 100644 --- a/test/form/samples/unused-var/_expected/umd.js +++ b/test/form/samples/unused-var/_expected/umd.js @@ -1,10 +1,10 @@ (function (factory) { typeof define === 'function' && define.amd ? define(factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; var foo = 'lol'; console.log( foo ); -}))); +})); diff --git a/test/form/samples/update-expression-side-effects/_config.js b/test/form/samples/update-expression-side-effects/_config.js index 4dbc0f43e3f..f0459d97088 100644 --- a/test/form/samples/update-expression-side-effects/_config.js +++ b/test/form/samples/update-expression-side-effects/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'detect side-effects when dealing with update expressions' -}; +}); diff --git a/test/form/samples/update-expression-side-effects/_expected/amd.js b/test/form/samples/update-expression-side-effects/_expected/amd.js index 5b0fca61a05..f87acf1a3ce 100644 --- a/test/form/samples/update-expression-side-effects/_expected/amd.js +++ b/test/form/samples/update-expression-side-effects/_expected/amd.js @@ -1,4 +1,4 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; const effectY = () => { console.log('effect'); @@ -12,4 +12,4 @@ define(function () { 'use strict'; foo++; foo.bar.baz = 1; -}); +})); diff --git a/test/form/samples/update-expression-side-effects/_expected/iife.js b/test/form/samples/update-expression-side-effects/_expected/iife.js index 4811226e493..c3aa12cc8e1 100644 --- a/test/form/samples/update-expression-side-effects/_expected/iife.js +++ b/test/form/samples/update-expression-side-effects/_expected/iife.js @@ -13,4 +13,4 @@ foo++; foo.bar.baz = 1; -}()); +})(); diff --git a/test/form/samples/update-expression-side-effects/_expected/system.js b/test/form/samples/update-expression-side-effects/_expected/system.js index b21da97ab35..e25b6d84d37 100644 --- a/test/form/samples/update-expression-side-effects/_expected/system.js +++ b/test/form/samples/update-expression-side-effects/_expected/system.js @@ -1,7 +1,7 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { const effectY = () => { console.log('effect'); @@ -15,6 +15,6 @@ System.register([], function () { foo++; foo.bar.baz = 1; - } + }) }; -}); +})); diff --git a/test/form/samples/update-expression-side-effects/_expected/umd.js b/test/form/samples/update-expression-side-effects/_expected/umd.js index 5eee7ba283d..aee4c06d7cb 100644 --- a/test/form/samples/update-expression-side-effects/_expected/umd.js +++ b/test/form/samples/update-expression-side-effects/_expected/umd.js @@ -1,7 +1,7 @@ (function (factory) { typeof define === 'function' && define.amd ? define(factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; const effectY = () => { console.log('effect'); @@ -15,4 +15,4 @@ foo++; foo.bar.baz = 1; -}))); +})); diff --git a/test/form/samples/updating-assignments/_config.js b/test/form/samples/updating-assignments/_config.js index b6633185ee0..c3745d1ecd0 100644 --- a/test/form/samples/updating-assignments/_config.js +++ b/test/form/samples/updating-assignments/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'Correctly handles assignment operators on exports', options: { output: { name: 'bundle' } } -}; +}); diff --git a/test/form/samples/updating-assignments/_expected/amd.js b/test/form/samples/updating-assignments/_expected/amd.js index addd8e09cdf..b93e3af25aa 100644 --- a/test/form/samples/updating-assignments/_expected/amd.js +++ b/test/form/samples/updating-assignments/_expected/amd.js @@ -1,4 +1,4 @@ -define(['exports'], function (exports) { 'use strict'; +define(['exports'], (function (exports) { 'use strict'; exports.x = 1; exports.x = 2; @@ -15,6 +15,4 @@ define(['exports'], function (exports) { 'use strict'; exports.x ^= 2; exports.x |= 2; - Object.defineProperty(exports, '__esModule', { value: true }); - -}); +})); diff --git a/test/form/samples/updating-assignments/_expected/cjs.js b/test/form/samples/updating-assignments/_expected/cjs.js index 3824b02062a..fe8c94b26dd 100644 --- a/test/form/samples/updating-assignments/_expected/cjs.js +++ b/test/form/samples/updating-assignments/_expected/cjs.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - exports.x = 1; exports.x = 2; exports.x += 1; diff --git a/test/form/samples/updating-assignments/_expected/iife.js b/test/form/samples/updating-assignments/_expected/iife.js index c4ad3ef4f28..913bb7b37b6 100644 --- a/test/form/samples/updating-assignments/_expected/iife.js +++ b/test/form/samples/updating-assignments/_expected/iife.js @@ -16,8 +16,6 @@ var bundle = (function (exports) { exports.x ^= 2; exports.x |= 2; - Object.defineProperty(exports, '__esModule', { value: true }); - return exports; -}({})); +})({}); diff --git a/test/form/samples/updating-assignments/_expected/system.js b/test/form/samples/updating-assignments/_expected/system.js index 78a7127d368..72c2bea333a 100644 --- a/test/form/samples/updating-assignments/_expected/system.js +++ b/test/form/samples/updating-assignments/_expected/system.js @@ -1,23 +1,23 @@ -System.register('bundle', [], function (exports) { +System.register('bundle', [], (function (exports) { 'use strict'; return { - execute: function () { + execute: (function () { - let x = exports('x', 1); - x = exports('x', 2); - x = exports('x', x + 1); - x = exports('x', x - 1); - x = exports('x', x * 2); - x = exports('x', x / 2); - x = exports('x', x % 2); - x = exports('x', x ** 2); - x = exports('x', x << 1); - x = exports('x', x >> 1); - x = exports('x', x >>> 1); - x = exports('x', x & 3); - x = exports('x', x ^ 2); - x = exports('x', x | 2); + let x = exports("x", 1); + exports("x", x = 2); + exports("x", x += 1); + exports("x", x -= 1); + exports("x", x *= 2); + exports("x", x /= 2); + exports("x", x %= 2); + exports("x", x **= 2); + exports("x", x <<= 1); + exports("x", x >>= 1); + exports("x", x >>>= 1); + exports("x", x &= 3); + exports("x", x ^= 2); + exports("x", x |= 2); - } + }) }; -}); +})); diff --git a/test/form/samples/updating-assignments/_expected/umd.js b/test/form/samples/updating-assignments/_expected/umd.js index 84f36354077..66d4cfdb2c9 100644 --- a/test/form/samples/updating-assignments/_expected/umd.js +++ b/test/form/samples/updating-assignments/_expected/umd.js @@ -2,7 +2,7 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.bundle = {})); -}(this, (function (exports) { 'use strict'; +})(this, (function (exports) { 'use strict'; exports.x = 1; exports.x = 2; @@ -19,6 +19,4 @@ exports.x ^= 2; exports.x |= 2; - Object.defineProperty(exports, '__esModule', { value: true }); - -}))); +})); diff --git a/test/form/samples/url-external/_config.js b/test/form/samples/url-external/_config.js index 1a4fb129c72..837b3fc9b98 100644 --- a/test/form/samples/url-external/_config.js +++ b/test/form/samples/url-external/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'supports URL externals', options: { external: ['https://external.com/external.js'], @@ -6,4 +6,4 @@ module.exports = { globals: { 'https://external.com/external.js': 'external' } } } -}; +}); diff --git a/test/form/samples/url-external/_expected/amd.js b/test/form/samples/url-external/_expected/amd.js index 761c7fcb20f..57ddf13f248 100644 --- a/test/form/samples/url-external/_expected/amd.js +++ b/test/form/samples/url-external/_expected/amd.js @@ -1,9 +1,5 @@ -define(['https://external.com/external.js'], function (external) { 'use strict'; +define(['https://external.com/external.js'], (function (external) { 'use strict'; - function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } + console.log(external); - var external__default = /*#__PURE__*/_interopDefaultLegacy(external); - - console.log(external__default['default']); - -}); +})); diff --git a/test/form/samples/url-external/_expected/cjs.js b/test/form/samples/url-external/_expected/cjs.js index 68eb1525baa..bf3ba7bb58a 100644 --- a/test/form/samples/url-external/_expected/cjs.js +++ b/test/form/samples/url-external/_expected/cjs.js @@ -2,8 +2,4 @@ var external = require('https://external.com/external.js'); -function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } - -var external__default = /*#__PURE__*/_interopDefaultLegacy(external); - -console.log(external__default['default']); +console.log(external); diff --git a/test/form/samples/url-external/_expected/iife.js b/test/form/samples/url-external/_expected/iife.js index db1e304cd12..c458d91ba9a 100644 --- a/test/form/samples/url-external/_expected/iife.js +++ b/test/form/samples/url-external/_expected/iife.js @@ -1,10 +1,6 @@ (function (external) { 'use strict'; - function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } + console.log(external); - var external__default = /*#__PURE__*/_interopDefaultLegacy(external); - - console.log(external__default['default']); - -}(external)); +})(external); diff --git a/test/form/samples/url-external/_expected/system.js b/test/form/samples/url-external/_expected/system.js index 43a69cb5dfd..244ee54bf52 100644 --- a/test/form/samples/url-external/_expected/system.js +++ b/test/form/samples/url-external/_expected/system.js @@ -1,14 +1,14 @@ -System.register(['https://external.com/external.js'], function () { +System.register(['https://external.com/external.js'], (function () { 'use strict'; var external; return { setters: [function (module) { external = module.default; }], - execute: function () { + execute: (function () { console.log(external); - } + }) }; -}); +})); diff --git a/test/form/samples/url-external/_expected/umd.js b/test/form/samples/url-external/_expected/umd.js index 933e5f0fdbf..e7d4db18e29 100644 --- a/test/form/samples/url-external/_expected/umd.js +++ b/test/form/samples/url-external/_expected/umd.js @@ -2,12 +2,8 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('https://external.com/external.js')) : typeof define === 'function' && define.amd ? define(['https://external.com/external.js'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.external)); -}(this, (function (external) { 'use strict'; +})(this, (function (external) { 'use strict'; - function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } + console.log(external); - var external__default = /*#__PURE__*/_interopDefaultLegacy(external); - - console.log(external__default['default']); - -}))); +})); diff --git a/test/form/samples/use-class-name-in-static-block/_config.js b/test/form/samples/use-class-name-in-static-block/_config.js new file mode 100644 index 00000000000..5252b5c23d8 --- /dev/null +++ b/test/form/samples/use-class-name-in-static-block/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'use the original class name instead of renderName in class body' +}); diff --git a/test/form/samples/use-class-name-in-static-block/_expected/amd.js b/test/form/samples/use-class-name-in-static-block/_expected/amd.js new file mode 100644 index 00000000000..b42174f3455 --- /dev/null +++ b/test/form/samples/use-class-name-in-static-block/_expected/amd.js @@ -0,0 +1,36 @@ +define((function () { 'use strict'; + + let Test$1 = class Test { + constructor() { + assert.ok(Test.test); + assert.ok(this.getText()); + } + getText() { + return Test.test; + } + static test = 'Test1'; + static { + assert.ok(Test.test); + new Test(); + } + }; + + class Test { + constructor() { + assert.ok(Test.test); + assert.ok(this.getText()); + } + getText() { + return Test.test; + } + static test = 'Test2'; + static { + assert.ok(Test.test); + new Test(); + } + } + + assert.ok(Test$1.test); + assert.ok(Test.test); + +})); diff --git a/test/form/samples/use-class-name-in-static-block/_expected/cjs.js b/test/form/samples/use-class-name-in-static-block/_expected/cjs.js new file mode 100644 index 00000000000..764d68ec68a --- /dev/null +++ b/test/form/samples/use-class-name-in-static-block/_expected/cjs.js @@ -0,0 +1,34 @@ +'use strict'; + +let Test$1 = class Test { + constructor() { + assert.ok(Test.test); + assert.ok(this.getText()); + } + getText() { + return Test.test; + } + static test = 'Test1'; + static { + assert.ok(Test.test); + new Test(); + } +}; + +class Test { + constructor() { + assert.ok(Test.test); + assert.ok(this.getText()); + } + getText() { + return Test.test; + } + static test = 'Test2'; + static { + assert.ok(Test.test); + new Test(); + } +} + +assert.ok(Test$1.test); +assert.ok(Test.test); diff --git a/test/form/samples/use-class-name-in-static-block/_expected/es.js b/test/form/samples/use-class-name-in-static-block/_expected/es.js new file mode 100644 index 00000000000..eddebce6e34 --- /dev/null +++ b/test/form/samples/use-class-name-in-static-block/_expected/es.js @@ -0,0 +1,32 @@ +let Test$1 = class Test { + constructor() { + assert.ok(Test.test); + assert.ok(this.getText()); + } + getText() { + return Test.test; + } + static test = 'Test1'; + static { + assert.ok(Test.test); + new Test(); + } +}; + +class Test { + constructor() { + assert.ok(Test.test); + assert.ok(this.getText()); + } + getText() { + return Test.test; + } + static test = 'Test2'; + static { + assert.ok(Test.test); + new Test(); + } +} + +assert.ok(Test$1.test); +assert.ok(Test.test); diff --git a/test/form/samples/use-class-name-in-static-block/_expected/iife.js b/test/form/samples/use-class-name-in-static-block/_expected/iife.js new file mode 100644 index 00000000000..0b0a9b0c0aa --- /dev/null +++ b/test/form/samples/use-class-name-in-static-block/_expected/iife.js @@ -0,0 +1,37 @@ +(function () { + 'use strict'; + + let Test$1 = class Test { + constructor() { + assert.ok(Test.test); + assert.ok(this.getText()); + } + getText() { + return Test.test; + } + static test = 'Test1'; + static { + assert.ok(Test.test); + new Test(); + } + }; + + class Test { + constructor() { + assert.ok(Test.test); + assert.ok(this.getText()); + } + getText() { + return Test.test; + } + static test = 'Test2'; + static { + assert.ok(Test.test); + new Test(); + } + } + + assert.ok(Test$1.test); + assert.ok(Test.test); + +})(); diff --git a/test/form/samples/use-class-name-in-static-block/_expected/system.js b/test/form/samples/use-class-name-in-static-block/_expected/system.js new file mode 100644 index 00000000000..a1bc68606c8 --- /dev/null +++ b/test/form/samples/use-class-name-in-static-block/_expected/system.js @@ -0,0 +1,41 @@ +System.register([], (function () { + 'use strict'; + return { + execute: (function () { + + let Test$1 = class Test { + constructor() { + assert.ok(Test.test); + assert.ok(this.getText()); + } + getText() { + return Test.test; + } + static test = 'Test1'; + static { + assert.ok(Test.test); + new Test(); + } + }; + + class Test { + constructor() { + assert.ok(Test.test); + assert.ok(this.getText()); + } + getText() { + return Test.test; + } + static test = 'Test2'; + static { + assert.ok(Test.test); + new Test(); + } + } + + assert.ok(Test$1.test); + assert.ok(Test.test); + + }) + }; +})); diff --git a/test/form/samples/use-class-name-in-static-block/_expected/umd.js b/test/form/samples/use-class-name-in-static-block/_expected/umd.js new file mode 100644 index 00000000000..d2b0377bf59 --- /dev/null +++ b/test/form/samples/use-class-name-in-static-block/_expected/umd.js @@ -0,0 +1,39 @@ +(function (factory) { + typeof define === 'function' && define.amd ? define(factory) : + factory(); +})((function () { 'use strict'; + + let Test$1 = class Test { + constructor() { + assert.ok(Test.test); + assert.ok(this.getText()); + } + getText() { + return Test.test; + } + static test = 'Test1'; + static { + assert.ok(Test.test); + new Test(); + } + }; + + class Test { + constructor() { + assert.ok(Test.test); + assert.ok(this.getText()); + } + getText() { + return Test.test; + } + static test = 'Test2'; + static { + assert.ok(Test.test); + new Test(); + } + } + + assert.ok(Test$1.test); + assert.ok(Test.test); + +})); diff --git a/test/form/samples/use-class-name-in-static-block/main.js b/test/form/samples/use-class-name-in-static-block/main.js new file mode 100644 index 00000000000..27ceb8b9400 --- /dev/null +++ b/test/form/samples/use-class-name-in-static-block/main.js @@ -0,0 +1,5 @@ +import { Test } from './test1.js'; +import { Test as Test2 } from './test2.js'; + +assert.ok(Test.test); +assert.ok(Test2.test); diff --git a/test/form/samples/use-class-name-in-static-block/test1.js b/test/form/samples/use-class-name-in-static-block/test1.js new file mode 100644 index 00000000000..e6d964bb0e0 --- /dev/null +++ b/test/form/samples/use-class-name-in-static-block/test1.js @@ -0,0 +1,14 @@ +export class Test { + constructor() { + assert.ok(Test.test); + assert.ok(this.getText()); + } + getText() { + return Test.test; + } + static test = 'Test1'; + static { + assert.ok(Test.test); + new Test(); + } +} diff --git a/test/form/samples/use-class-name-in-static-block/test2.js b/test/form/samples/use-class-name-in-static-block/test2.js new file mode 100644 index 00000000000..0ac76f89d2c --- /dev/null +++ b/test/form/samples/use-class-name-in-static-block/test2.js @@ -0,0 +1,14 @@ +export class Test { + constructor() { + assert.ok(Test.test); + assert.ok(this.getText()); + } + getText() { + return Test.test; + } + static test = 'Test2'; + static { + assert.ok(Test.test); + new Test(); + } +} diff --git a/test/form/samples/use-global-map-for-export-name/_config.js b/test/form/samples/use-global-map-for-export-name/_config.js index a2836987199..d47ec6c6faa 100644 --- a/test/form/samples/use-global-map-for-export-name/_config.js +++ b/test/form/samples/use-global-map-for-export-name/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'applies globals to output name', options: { output: { @@ -7,4 +7,4 @@ module.exports = { }, external: ['leaflet'] } -}; +}); diff --git a/test/form/samples/use-global-map-for-export-name/_expected/amd.js b/test/form/samples/use-global-map-for-export-name/_expected/amd.js index 49366bee230..82874afc7ff 100644 --- a/test/form/samples/use-global-map-for-export-name/_expected/amd.js +++ b/test/form/samples/use-global-map-for-export-name/_expected/amd.js @@ -1,10 +1,6 @@ -define(['leaflet'], function (L) { 'use strict'; +define(['leaflet'], (function (L) { 'use strict'; - function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } - - var L__default = /*#__PURE__*/_interopDefaultLegacy(L); - - L__default['default'].terminator = function(options) { + L.terminator = function(options) { }; -}); +})); diff --git a/test/form/samples/use-global-map-for-export-name/_expected/cjs.js b/test/form/samples/use-global-map-for-export-name/_expected/cjs.js index d09a88ea6f7..3a86b17b793 100644 --- a/test/form/samples/use-global-map-for-export-name/_expected/cjs.js +++ b/test/form/samples/use-global-map-for-export-name/_expected/cjs.js @@ -2,9 +2,5 @@ var L = require('leaflet'); -function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } - -var L__default = /*#__PURE__*/_interopDefaultLegacy(L); - -L__default['default'].terminator = function(options) { +L.terminator = function(options) { }; diff --git a/test/form/samples/use-global-map-for-export-name/_expected/iife.js b/test/form/samples/use-global-map-for-export-name/_expected/iife.js index f53c12bd820..651a4174f76 100644 --- a/test/form/samples/use-global-map-for-export-name/_expected/iife.js +++ b/test/form/samples/use-global-map-for-export-name/_expected/iife.js @@ -1,11 +1,7 @@ (function (L) { 'use strict'; - function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } - - var L__default = /*#__PURE__*/_interopDefaultLegacy(L); - - L__default['default'].terminator = function(options) { + L.terminator = function(options) { }; -}(L)); +})(L); diff --git a/test/form/samples/use-global-map-for-export-name/_expected/system.js b/test/form/samples/use-global-map-for-export-name/_expected/system.js index 213c132f814..acbda5c7701 100644 --- a/test/form/samples/use-global-map-for-export-name/_expected/system.js +++ b/test/form/samples/use-global-map-for-export-name/_expected/system.js @@ -1,15 +1,15 @@ -System.register('leaflet.terminator', ['leaflet'], function () { +System.register('leaflet.terminator', ['leaflet'], (function () { 'use strict'; var L; return { setters: [function (module) { L = module.default; }], - execute: function () { + execute: (function () { L.terminator = function(options) { }; - } + }) }; -}); +})); diff --git a/test/form/samples/use-global-map-for-export-name/_expected/umd.js b/test/form/samples/use-global-map-for-export-name/_expected/umd.js index 6397f0d33e5..c46f94e9d07 100644 --- a/test/form/samples/use-global-map-for-export-name/_expected/umd.js +++ b/test/form/samples/use-global-map-for-export-name/_expected/umd.js @@ -2,13 +2,9 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('leaflet')) : typeof define === 'function' && define.amd ? define(['leaflet'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.L)); -}(this, (function (L) { 'use strict'; +})(this, (function (L) { 'use strict'; - function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } - - var L__default = /*#__PURE__*/_interopDefaultLegacy(L); - - L__default['default'].terminator = function(options) { + L.terminator = function(options) { }; -}))); +})); diff --git a/test/form/samples/using-statement-symbol-usage/_config.js b/test/form/samples/using-statement-symbol-usage/_config.js new file mode 100644 index 00000000000..eec87515755 --- /dev/null +++ b/test/form/samples/using-statement-symbol-usage/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'preserves Symbol.dispose side effects when used in using statement' +}); diff --git a/test/form/samples/using-statement-symbol-usage/_expected.js b/test/form/samples/using-statement-symbol-usage/_expected.js new file mode 100644 index 00000000000..3e1a4d6abcd --- /dev/null +++ b/test/form/samples/using-statement-symbol-usage/_expected.js @@ -0,0 +1,13 @@ +function process() { + using _ = { + [Symbol.dispose]: () => console.log('dispose')}; +} + +process(); + +async function processAsync() { + await using _ = { + [Symbol.asyncDispose]: () => console.log('asyncDispose')}; +} + +processAsync(); diff --git a/test/form/samples/using-statement-symbol-usage/main.js b/test/form/samples/using-statement-symbol-usage/main.js new file mode 100644 index 00000000000..9c5802630e9 --- /dev/null +++ b/test/form/samples/using-statement-symbol-usage/main.js @@ -0,0 +1,19 @@ +function process() { + using _ = { + [Symbol.dispose]: () => console.log('dispose'), + [Symbol.asyncDispose]: () => console.log('asyncDispose'), + [Symbol.hasInstance]: () => console.log('hasInstance') + }; +} + +process(); + +async function processAsync() { + await using _ = { + [Symbol.dispose]: () => console.log('dispose'), + [Symbol.asyncDispose]: () => console.log('asyncDispose'), + [Symbol.hasInstance]: () => console.log('hasInstance') + }; +} + +processAsync(); diff --git a/test/form/samples/whitespace-around-namespace-member-expression/_config.js b/test/form/samples/whitespace-around-namespace-member-expression/_config.js index a97b168da8c..0329c415933 100644 --- a/test/form/samples/whitespace-around-namespace-member-expression/_config.js +++ b/test/form/samples/whitespace-around-namespace-member-expression/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'whitespace around the "." in member expressions does not mess up renaming' -}; +}); diff --git a/test/form/samples/whitespace-around-namespace-member-expression/_expected/amd.js b/test/form/samples/whitespace-around-namespace-member-expression/_expected/amd.js index 144665ac4d9..31a6ecf26bf 100644 --- a/test/form/samples/whitespace-around-namespace-member-expression/_expected/amd.js +++ b/test/form/samples/whitespace-around-namespace-member-expression/_expected/amd.js @@ -1,4 +1,4 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; function yar() { console.log('yar?'); @@ -6,4 +6,4 @@ define(function () { 'use strict'; yar(); -}); +})); diff --git a/test/form/samples/whitespace-around-namespace-member-expression/_expected/iife.js b/test/form/samples/whitespace-around-namespace-member-expression/_expected/iife.js index d776c9d75fe..7d2d33d4f88 100644 --- a/test/form/samples/whitespace-around-namespace-member-expression/_expected/iife.js +++ b/test/form/samples/whitespace-around-namespace-member-expression/_expected/iife.js @@ -7,4 +7,4 @@ yar(); -}()); +})(); diff --git a/test/form/samples/whitespace-around-namespace-member-expression/_expected/system.js b/test/form/samples/whitespace-around-namespace-member-expression/_expected/system.js index 5f952ef25b8..2f949c39fa9 100644 --- a/test/form/samples/whitespace-around-namespace-member-expression/_expected/system.js +++ b/test/form/samples/whitespace-around-namespace-member-expression/_expected/system.js @@ -1,7 +1,7 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { function yar() { console.log('yar?'); @@ -9,6 +9,6 @@ System.register([], function () { yar(); - } + }) }; -}); +})); diff --git a/test/form/samples/whitespace-around-namespace-member-expression/_expected/umd.js b/test/form/samples/whitespace-around-namespace-member-expression/_expected/umd.js index 6e2c969dabc..5970dd96a5f 100644 --- a/test/form/samples/whitespace-around-namespace-member-expression/_expected/umd.js +++ b/test/form/samples/whitespace-around-namespace-member-expression/_expected/umd.js @@ -1,7 +1,7 @@ (function (factory) { typeof define === 'function' && define.amd ? define(factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; function yar() { console.log('yar?'); @@ -9,4 +9,4 @@ yar(); -}))); +})); diff --git a/test/form/samples/wrap-simplified-expressions/_config.js b/test/form/samples/wrap-simplified-expressions/_config.js index dfc3eb92f71..98a24ea9330 100644 --- a/test/form/samples/wrap-simplified-expressions/_config.js +++ b/test/form/samples/wrap-simplified-expressions/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'wraps simplified expressions that have become callees if necessary' -}; +}); diff --git a/test/form/samples/wrap-simplified-expressions/_expected/amd.js b/test/form/samples/wrap-simplified-expressions/_expected/amd.js index 435a2bc2ac0..4ab9f4486e0 100644 --- a/test/form/samples/wrap-simplified-expressions/_expected/amd.js +++ b/test/form/samples/wrap-simplified-expressions/_expected/amd.js @@ -1,4 +1,4 @@ -define(function () { 'use strict'; +define((function () { 'use strict'; const wrapper = { foo() { @@ -26,4 +26,4 @@ define(function () { 'use strict'; testEval.call('test'); -}); +})); diff --git a/test/form/samples/wrap-simplified-expressions/_expected/iife.js b/test/form/samples/wrap-simplified-expressions/_expected/iife.js index 15613c42434..6475bf46d4c 100644 --- a/test/form/samples/wrap-simplified-expressions/_expected/iife.js +++ b/test/form/samples/wrap-simplified-expressions/_expected/iife.js @@ -27,4 +27,4 @@ testEval.call('test'); -}()); +})(); diff --git a/test/form/samples/wrap-simplified-expressions/_expected/system.js b/test/form/samples/wrap-simplified-expressions/_expected/system.js index 5098c174597..e202ad77581 100644 --- a/test/form/samples/wrap-simplified-expressions/_expected/system.js +++ b/test/form/samples/wrap-simplified-expressions/_expected/system.js @@ -1,7 +1,7 @@ -System.register([], function () { +System.register([], (function () { 'use strict'; return { - execute: function () { + execute: (function () { const wrapper = { foo() { @@ -29,6 +29,6 @@ System.register([], function () { testEval.call('test'); - } + }) }; -}); +})); diff --git a/test/form/samples/wrap-simplified-expressions/_expected/umd.js b/test/form/samples/wrap-simplified-expressions/_expected/umd.js index 62e10c51297..d8e2f1c3d38 100644 --- a/test/form/samples/wrap-simplified-expressions/_expected/umd.js +++ b/test/form/samples/wrap-simplified-expressions/_expected/umd.js @@ -1,7 +1,7 @@ (function (factory) { typeof define === 'function' && define.amd ? define(factory) : factory(); -}((function () { 'use strict'; +})((function () { 'use strict'; const wrapper = { foo() { @@ -29,4 +29,4 @@ testEval.call('test'); -}))); +})); diff --git a/test/form/samples/yield-expression/missing-space/_config.js b/test/form/samples/yield-expression/missing-space/_config.js index 3dace68f84f..fe27240a3bc 100644 --- a/test/form/samples/yield-expression/missing-space/_config.js +++ b/test/form/samples/yield-expression/missing-space/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'Inserts space when simplifying yield expression without space' -}; +}); diff --git a/test/form/tsconfig.json b/test/form/tsconfig.json new file mode 100644 index 00000000000..4a26f3ee84c --- /dev/null +++ b/test/form/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": "../tsconfig.base.json", + "include": [ + "**/_config.js", + "./index.js", + "./define.d.ts" + ] +} diff --git a/test/function/define.d.ts b/test/function/define.d.ts new file mode 100644 index 00000000000..277a867082b --- /dev/null +++ b/test/function/define.d.ts @@ -0,0 +1,5 @@ +import type { TestConfigFunction } from '../types'; + +declare global { + function defineTest(config: TestConfigFunction): TestConfigFunction; +} diff --git a/test/function/index.js b/test/function/index.js index 0f2a85d63a5..f1aef785828 100644 --- a/test/function/index.js +++ b/test/function/index.js @@ -1,16 +1,25 @@ -const path = require('path'); -const assert = require('assert'); +const assert = require('node:assert'); +const path = require('node:path'); +/** + * @type {import('../../src/rollup/types')} Rollup + */ +// @ts-expect-error not included in types const rollup = require('../../dist/rollup'); -const { compareError, compareWarnings, runTestSuiteWithSamples } = require('../utils.js'); +const { + compareError, + compareLogs, + runTestSuiteWithSamples, + verifyAstPlugin +} = require('../testHelpers.js'); function requireWithContext(code, context, exports) { const module = { exports }; - const contextWithExports = Object.assign({}, context, { module, exports }); + const contextWithExports = { ...context, module, exports }; const contextKeys = Object.keys(contextWithExports); const contextValues = contextKeys.map(key => contextWithExports[key]); try { - const fn = new Function(contextKeys, code); - fn.apply({}, contextValues); + const function_ = new Function(contextKeys, code); + function_.apply({}, contextValues); } catch (error) { error.exports = module.exports; throw error; @@ -27,18 +36,16 @@ function runCodeSplitTest(codeMap, entryId, configContext) { return exportsMap[outputId]; } const code = codeMap[outputId]; - if (typeof code !== 'undefined') { - return (exportsMap[outputId] = requireWithContext( - code, - Object.assign({ require: requireFromOutputVia(outputId) }, context), - (exportsMap[outputId] = {}) - )); - } else { - return require(importee); - } + return code === undefined + ? require(importee) + : (exportsMap[outputId] = requireWithContext( + code, + { require: requireFromOutputVia(outputId), ...context }, + (exportsMap[outputId] = {}) + )); }; - const context = Object.assign({ assert }, configContext); + const context = { assert, ...configContext }; let exports; try { exports = requireFromOutputVia(entryId)(entryId); @@ -48,144 +55,169 @@ function runCodeSplitTest(codeMap, entryId, configContext) { return { exports }; } -runTestSuiteWithSamples('function', path.resolve(__dirname, 'samples'), (dir, config) => { - (config.skip ? it.skip : config.solo ? it.only : it)( - path.basename(dir) + ': ' + config.description, - () => { - if (config.show) console.group(path.basename(dir)); - if (config.before) config.before(); - process.chdir(dir); - const warnings = []; +runTestSuiteWithSamples( + 'function', + path.join(__dirname, 'samples'), + /** + * @param {import('../types').TestConfigFunction} config + */ + (directory, config) => { + (config.skip ? it.skip : config.solo ? it.only : it)( + path.basename(directory) + ': ' + config.description, + async () => { + if (config.show) console.group(path.basename(directory)); + if (config.before) { + await config.before(); + } + process.chdir(directory); + const logs = []; + const warnings = []; + const plugins = + config.verifyAst === false + ? config.options?.plugins + : config.options?.plugins === undefined + ? verifyAstPlugin + : Array.isArray(config.options.plugins) + ? [...config.options.plugins, verifyAstPlugin] + : config.options.plugins; - return rollup - .rollup( - Object.assign( - { - input: dir + '/main.js', - onwarn: warning => warnings.push(warning), - strictDeprecations: true + return rollup + .rollup({ + input: path.join(directory, 'main.js'), + onLog: (level, log) => { + logs.push({ level, ...log }); + if (level === 'warn') { + warnings.push(log); + } }, - config.options || {} - ) - ) - .then(bundle => { - let unintendedError; + strictDeprecations: true, + ...config.options, + plugins + }) + .then(bundle => { + let unintendedError; - if (config.error) { - throw new Error('Expected an error while rolling up'); - } + if (config.error) { + throw new Error('Expected an error while rolling up'); + } - let result; + let result; - return bundle - .generate( - Object.assign( - { - exports: 'auto', - format: 'cjs' - }, - (config.options || {}).output || {} - ) - ) - .then(({ output }) => { - if (config.generateError) { - unintendedError = new Error('Expected an error while generating output'); - } + return bundle + .generate({ + exports: 'auto', + format: 'cjs', + ...(config.options || {}).output + }) + .then(({ output }) => { + if (config.generateError) { + unintendedError = new Error('Expected an error while generating output'); + } - result = output; - }) - .catch(err => { - if (config.generateError) { - compareError(err, config.generateError); - } else { - throw err; - } - }) - .then(() => { - if (unintendedError) throw unintendedError; - if (config.error || config.generateError) return; + result = output; + }) + .catch(error => { + if (config.generateError) { + compareError(error, config.generateError); + } else { + throw error; + } + }) + .then(() => { + if (unintendedError) throw unintendedError; + if (config.error || config.generateError) return; - const codeMap = result.reduce((codeMap, chunk) => { - codeMap[chunk.fileName] = chunk.code; - return codeMap; - }, {}); - if (config.code) { - config.code(result.length === 1 ? result[0].code : codeMap); - } + const codeMap = result.reduce((codeMap, chunk) => { + codeMap[chunk.fileName] = chunk.code; + return codeMap; + }, {}); + if (config.code) { + config.code(result.length === 1 ? result[0].code : codeMap); + } - const entryId = result.length === 1 ? result[0].fileName : 'main.js'; - if (!codeMap.hasOwnProperty(entryId)) { - throw new Error( - `Could not find entry "${entryId}" in generated output.\nChunks:\n${Object.keys( - codeMap - ).join('\n')}` - ); - } - const { exports, error } = runCodeSplitTest(codeMap, entryId, config.context); - if (config.runtimeError) { - if (error) { - config.runtimeError(error); - } else { - unintendedError = new Error('Expected an error while executing output'); + const entryId = result.length === 1 ? result[0].fileName : 'main.js'; + if (!codeMap.hasOwnProperty(entryId)) { + throw new Error( + `Could not find entry "${entryId}" in generated output.\nChunks:\n${Object.keys( + codeMap + ).join('\n')}` + ); } - } else if (error) { - unintendedError = error; - } - return Promise.resolve() - .then(() => { - if (config.exports && !unintendedError) { - return config.exports(exports); - } - }) - .then(() => { - if (config.bundle && !unintendedError) { - return config.bundle(bundle); - } - }) - .catch(err => { - if (config.runtimeError) { - config.runtimeError(err); + const { exports, error } = runCodeSplitTest(codeMap, entryId, config.context); + if (config.runtimeError) { + if (error) { + config.runtimeError(error); } else { - unintendedError = err; + unintendedError = new Error('Expected an error while executing output'); } - }) - .then(() => { - if (config.show || unintendedError) { - for (const chunk of result) { - console.group(chunk.fileName); - console.log(chunk.code); - console.groupEnd(); - console.log(); + } else if (error) { + unintendedError = error; + } + return Promise.resolve() + .then(() => { + if (config.exports && !unintendedError) { + return config.exports(exports); } - } - - if (config.warnings) { - if (Array.isArray(config.warnings)) { - compareWarnings(warnings, config.warnings); + }) + .then(() => { + if (config.bundle && !unintendedError) { + return config.bundle(bundle); + } + }) + .catch(error_ => { + if (config.runtimeError) { + config.runtimeError(error_); } else { - config.warnings(warnings); + unintendedError = error_; } - } else if (warnings.length) { - throw new Error( - `Got unexpected warnings:\n${warnings - .map(warning => warning.message) - .join('\n')}` - ); - } - if (config.show) console.groupEnd(); - if (unintendedError) throw unintendedError; - if (config.after) config.after(); - }); - }); - }) - .catch(err => { - if (config.after) config.after(); - if (config.error) { - compareError(err, config.error); - } else { - throw err; - } - }); - } - ); -}); + }) + .then(() => { + if (config.show || unintendedError) { + for (const chunk of result) { + console.group(chunk.fileName); + console.log(chunk.code); + console.groupEnd(); + console.log(); + } + } + + if (config.logs) { + if (config.warnings) { + throw new Error('Cannot use both "logs" and "warnings" in a test'); + } + compareLogs(logs, config.logs); + } else if (config.warnings) { + if (Array.isArray(config.warnings)) { + compareLogs(warnings, config.warnings); + } else { + config.warnings(warnings); + } + } else if (warnings.length > 0) { + throw new Error( + `Got unexpected warnings:\n${warnings + .map(warning => warning.message) + .join('\n')}` + ); + } + if (config.show) console.groupEnd(); + if (unintendedError) throw unintendedError; + if (config.after) { + return config.after(); + } + }); + }); + }) + .catch(error => { + if (config.error) { + compareError(error, config.error); + } else { + throw error; + } + if (config.after) { + return config.after(); + } + }); + } + ); + } +); diff --git a/test/function/samples/access-instance-prop/_config.js b/test/function/samples/access-instance-prop/_config.js new file mode 100644 index 00000000000..cfe057741b2 --- /dev/null +++ b/test/function/samples/access-instance-prop/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'respects getters when accessing properties of an instance' +}); diff --git a/test/function/samples/access-instance-prop/main.js b/test/function/samples/access-instance-prop/main.js new file mode 100644 index 00000000000..69b8f8f7946 --- /dev/null +++ b/test/function/samples/access-instance-prop/main.js @@ -0,0 +1,13 @@ +let effect = false; + +var b = { + get a() { + effect = true; + } +}; + +function X() {} +X.prototype = b; +new X().a; + +assert.ok(effect); diff --git a/test/function/samples/acorn-walk/_config.js b/test/function/samples/acorn-walk/_config.js new file mode 100644 index 00000000000..02a5c20f5dd --- /dev/null +++ b/test/function/samples/acorn-walk/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'in acorn walk, immediate function lose track so we do not optimize parameter' +}); diff --git a/test/function/samples/acorn-walk/main.js b/test/function/samples/acorn-walk/main.js new file mode 100644 index 00000000000..32da4905193 --- /dev/null +++ b/test/function/samples/acorn-walk/main.js @@ -0,0 +1,26 @@ +let found = false; + +const base = { + ExpressionStatement(node, c) { + c(node.value, "Expression"); + }, + Expression() { }, + Identifier() { } +}; + +function simple(node, visitors, baseVisitor) { + if (!baseVisitor) baseVisitor = base + ; (function c(node, override) { + let type = override || node.type + baseVisitor[type](node, c) + if (visitors[type]) visitors[type](node) + })(node) +} + +simple({ type: "ExpressionStatement", value: { type: "Identifier" } }, { + Expression(node) { + found = true; + } +}); + +assert.equal(found, true); diff --git a/test/function/samples/add-watch-file-generate/_config.js b/test/function/samples/add-watch-file-generate/_config.js deleted file mode 100644 index 49d71307ea2..00000000000 --- a/test/function/samples/add-watch-file-generate/_config.js +++ /dev/null @@ -1,20 +0,0 @@ -const path = require('path'); - -module.exports = { - description: 'throws when adding watch files during generate', - options: { - plugins: { - name: 'test-plugin', - renderStart() { - this.addWatchFile(path.join(__dirname, 'watched.js')); - } - } - }, - generateError: { - code: 'PLUGIN_ERROR', - hook: 'renderStart', - message: 'Cannot call addWatchFile after the build has finished.', - plugin: 'test-plugin', - pluginCode: 'INVALID_ROLLUP_PHASE' - } -}; diff --git a/test/function/samples/add-watch-file-generate/main.js b/test/function/samples/add-watch-file-generate/main.js deleted file mode 100644 index a9244a453fb..00000000000 --- a/test/function/samples/add-watch-file-generate/main.js +++ /dev/null @@ -1 +0,0 @@ -throw new Error('Not executed'); diff --git a/test/function/samples/adds-json-hint-for-missing-export-if-is-json-file/_config.js b/test/function/samples/adds-json-hint-for-missing-export-if-is-json-file/_config.js new file mode 100644 index 00000000000..8751b31c249 --- /dev/null +++ b/test/function/samples/adds-json-hint-for-missing-export-if-is-json-file/_config.js @@ -0,0 +1,28 @@ +const path = require('node:path'); +const ID_MAIN = path.join(__dirname, 'main.js'); +const ID_ARRAY_JSON = path.join(__dirname, 'array.json'); + +module.exports = defineTest({ + description: 'should provide json hint when importing a no export json file', + error: { + binding: 'default', + code: 'MISSING_EXPORT', + exporter: ID_ARRAY_JSON, + id: ID_MAIN, + url: 'https://rollupjs.org/troubleshooting/#error-name-is-not-exported-by-module', + pos: 7, + loc: { + column: 7, + file: ID_MAIN, + line: 1 + }, + frame: ` +1: import theArray from './array.json'; + ^ +2: export default theArray; + `, + watchFiles: [ID_ARRAY_JSON, ID_MAIN], + message: + 'main.js (1:7): "default" is not exported by "array.json", imported by "main.js". (Note that you need @rollup/plugin-json to import JSON files)' + } +}); diff --git a/test/function/samples/adds-json-hint-for-missing-export-if-is-json-file/array.json b/test/function/samples/adds-json-hint-for-missing-export-if-is-json-file/array.json new file mode 100644 index 00000000000..a5fb3048965 --- /dev/null +++ b/test/function/samples/adds-json-hint-for-missing-export-if-is-json-file/array.json @@ -0,0 +1 @@ +["foo", "bar"] diff --git a/test/function/samples/adds-json-hint-for-missing-export-if-is-json-file/main.js b/test/function/samples/adds-json-hint-for-missing-export-if-is-json-file/main.js new file mode 100644 index 00000000000..9c42986130e --- /dev/null +++ b/test/function/samples/adds-json-hint-for-missing-export-if-is-json-file/main.js @@ -0,0 +1,2 @@ +import theArray from './array.json'; +export default theArray; diff --git a/test/function/samples/adds-semicolons-if-necessary-b/_config.js b/test/function/samples/adds-semicolons-if-necessary-b/_config.js index bb17123ec79..b7cbe7a3f55 100644 --- a/test/function/samples/adds-semicolons-if-necessary-b/_config.js +++ b/test/function/samples/adds-semicolons-if-necessary-b/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'adds semi-colons if necessary' -}; +}); diff --git a/test/function/samples/adds-semicolons-if-necessary-c/_config.js b/test/function/samples/adds-semicolons-if-necessary-c/_config.js index bb17123ec79..b7cbe7a3f55 100644 --- a/test/function/samples/adds-semicolons-if-necessary-c/_config.js +++ b/test/function/samples/adds-semicolons-if-necessary-c/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'adds semi-colons if necessary' -}; +}); diff --git a/test/function/samples/adds-semicolons-if-necessary-d/_config.js b/test/function/samples/adds-semicolons-if-necessary-d/_config.js index bb17123ec79..b7cbe7a3f55 100644 --- a/test/function/samples/adds-semicolons-if-necessary-d/_config.js +++ b/test/function/samples/adds-semicolons-if-necessary-d/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'adds semi-colons if necessary' -}; +}); diff --git a/test/function/samples/adds-semicolons-if-necessary/_config.js b/test/function/samples/adds-semicolons-if-necessary/_config.js index bb17123ec79..b7cbe7a3f55 100644 --- a/test/function/samples/adds-semicolons-if-necessary/_config.js +++ b/test/function/samples/adds-semicolons-if-necessary/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'adds semi-colons if necessary' -}; +}); diff --git a/test/function/samples/adds-timings-to-bundle-when-codesplitting/_config.js b/test/function/samples/adds-timings-to-bundle-when-codesplitting/_config.js index 1e8e7d68fe5..88086e2d5a8 100644 --- a/test/function/samples/adds-timings-to-bundle-when-codesplitting/_config.js +++ b/test/function/samples/adds-timings-to-bundle-when-codesplitting/_config.js @@ -1,6 +1,6 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'Adds timing information to bundle when bundling with perf=true', options: { input: ['main.js', 'main2.js'], @@ -9,12 +9,12 @@ module.exports = { bundle(bundle) { const timings = bundle.getTimings(); const timers = Object.keys(timings); - assert.ok(timers.indexOf('# BUILD') >= 0, '# BUILD time is not measured.'); - assert.ok(timers.indexOf('# GENERATE') >= 0, '# GENERATE time is not measured.'); - timers.forEach(timer => { + assert.ok(timers.includes('# BUILD'), '# BUILD time is not measured.'); + assert.ok(timers.includes('# GENERATE'), '# GENERATE time is not measured.'); + for (const timer of timers) { assert.equal(typeof timings[timer][0], 'number'); assert.equal(typeof timings[timer][1], 'number'); assert.ok(timings[timer][0] >= 0, 'Timer is not non-negative.'); - }); + } } -}; +}); diff --git a/test/function/samples/adds-timings-to-bundle/_config.js b/test/function/samples/adds-timings-to-bundle/_config.js index aebf0646f37..66ced94a3e2 100644 --- a/test/function/samples/adds-timings-to-bundle/_config.js +++ b/test/function/samples/adds-timings-to-bundle/_config.js @@ -1,6 +1,6 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'Adds timing information to bundle when bundling with perf=true', options: { perf: true @@ -8,12 +8,12 @@ module.exports = { bundle(bundle) { const timings = bundle.getTimings(); const timers = Object.keys(timings); - assert.ok(timers.indexOf('# BUILD') >= 0, '# BUILD time is not measured.'); - assert.ok(timers.indexOf('# GENERATE') >= 0, '# GENERATE time is not measured.'); - timers.forEach(timer => { + assert.ok(timers.includes('# BUILD'), '# BUILD time is not measured.'); + assert.ok(timers.includes('# GENERATE'), '# GENERATE time is not measured.'); + for (const timer of timers) { assert.equal(typeof timings[timer][0], 'number'); assert.equal(typeof timings[timer][1], 'number'); assert.ok(timings[timer][0] >= 0, 'Timer is not non-negative.'); - }); + } } -}; +}); diff --git a/test/function/samples/aliased-not-exported-twice/_config.js b/test/function/samples/aliased-not-exported-twice/_config.js index 1f4752d3a49..0f9e90ff730 100644 --- a/test/function/samples/aliased-not-exported-twice/_config.js +++ b/test/function/samples/aliased-not-exported-twice/_config.js @@ -1,6 +1,6 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'does not export aliased binding under original name (#438)', exports(exports) { assert.equal(exports.number, 0); @@ -9,4 +9,4 @@ module.exports = { assert.ok(!('count' in exports)); } -}; +}); diff --git a/test/function/samples/allow-reserved/_config.js b/test/function/samples/allow-reserved/_config.js deleted file mode 100644 index 63f2a11c03f..00000000000 --- a/test/function/samples/allow-reserved/_config.js +++ /dev/null @@ -1,8 +0,0 @@ -module.exports = { - description: 'allow reserved identifiers via custom acorn options', - options: { - acorn: { - allowReserved: true - } - } -}; diff --git a/test/function/samples/allow-reserved/main.js b/test/function/samples/allow-reserved/main.js deleted file mode 100644 index 00782b93d9c..00000000000 --- a/test/function/samples/allow-reserved/main.js +++ /dev/null @@ -1,4 +0,0 @@ -var x = function await() { - return 42; -}; -assert.equal(x(), 42); diff --git a/test/function/samples/allow-undefined-as-parameter/_config.js b/test/function/samples/allow-undefined-as-parameter/_config.js index 5143691be92..9428adf5439 100644 --- a/test/function/samples/allow-undefined-as-parameter/_config.js +++ b/test/function/samples/allow-undefined-as-parameter/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'do not make assumptions about its value when using undefined as a parameter name' -}; +}); diff --git a/test/function/samples/allows-external-modules-from-nested-module/_config.js b/test/function/samples/allows-external-modules-from-nested-module/_config.js index f59b20ffa1b..b3523c17432 100644 --- a/test/function/samples/allows-external-modules-from-nested-module/_config.js +++ b/test/function/samples/allows-external-modules-from-nested-module/_config.js @@ -1,6 +1,6 @@ -module.exports = { +module.exports = defineTest({ description: 'imports external modules from nested internal modules', options: { external: ['path'] } -}; +}); diff --git a/test/function/samples/allows-unknown-binary-operators/_config.js b/test/function/samples/allows-unknown-binary-operators/_config.js index 59419b6caa7..8c4b6a8bd1a 100644 --- a/test/function/samples/allows-unknown-binary-operators/_config.js +++ b/test/function/samples/allows-unknown-binary-operators/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'allows unknown binary operators' -}; +}); diff --git a/test/function/samples/already-deshadowed-import/_config.js b/test/function/samples/already-deshadowed-import/_config.js index b8ce432d1ac..abe0336dca5 100644 --- a/test/function/samples/already-deshadowed-import/_config.js +++ b/test/function/samples/already-deshadowed-import/_config.js @@ -1,12 +1,15 @@ -module.exports = { +const path = require('node:path'); +const ID_BOB = path.join(__dirname, 'bob.js'); +const ID_ALICE = path.join(__dirname, 'alice.js'); + +module.exports = defineTest({ description: 'handle already module import names correctly if they are have already been deshadowed', warnings: [ { code: 'CIRCULAR_DEPENDENCY', - cycle: ['bob.js', 'alice.js', 'bob.js'], - importer: 'bob.js', + ids: [ID_BOB, ID_ALICE, ID_BOB], message: 'Circular dependency: bob.js -> alice.js -> bob.js' } ] -}; +}); diff --git a/test/function/samples/amd-auto-id-id/_config.js b/test/function/samples/amd-auto-id-id/_config.js index 0041b5d33c0..856db562577 100644 --- a/test/function/samples/amd-auto-id-id/_config.js +++ b/test/function/samples/amd-auto-id-id/_config.js @@ -1,11 +1,21 @@ -module.exports = { +// @ts-check + +module.exports = defineTest({ description: 'throws when using both the amd.autoId and the amd.id option', options: { - output: { dir: 'dist', amd: { autoId: 'a', id: 'a' } } + output: { + dir: 'dist', + amd: { + // @ts-expect-error expected error + autoId: 'a', + id: 'a' + } + } }, generateError: { code: 'INVALID_OPTION', message: - '"output.amd.autoId"/"output.amd.basePath" and "output.amd.id" cannot be used together.' + 'Invalid value for option "output.amd.id" - this option cannot be used together with "output.amd.autoId"/"output.amd.basePath".', + url: 'https://rollupjs.org/configuration-options/#output-amd-id' } -}; +}); diff --git a/test/function/samples/amd-base-path-id/_config.js b/test/function/samples/amd-base-path-id/_config.js index 5e11750896b..6fd36255965 100644 --- a/test/function/samples/amd-base-path-id/_config.js +++ b/test/function/samples/amd-base-path-id/_config.js @@ -1,11 +1,21 @@ -module.exports = { +// @ts-check + +module.exports = defineTest({ description: 'throws when using both the amd.basePath and the amd.id option', options: { - output: { dir: 'dist', amd: { basePath: 'a', id: 'a' } } + output: { + dir: 'dist', + amd: { + // @ts-expect-error expected error + basePath: 'a', + id: 'a' + } + } }, generateError: { code: 'INVALID_OPTION', message: - '"output.amd.autoId"/"output.amd.basePath" and "output.amd.id" cannot be used together.' + 'Invalid value for option "output.amd.id" - this option cannot be used together with "output.amd.autoId"/"output.amd.basePath".', + url: 'https://rollupjs.org/configuration-options/#output-amd-id' } -}; +}); diff --git a/test/function/samples/amd-base-path/_config.js b/test/function/samples/amd-base-path/_config.js index 9ebfc670a9d..12d674d59a7 100644 --- a/test/function/samples/amd-base-path/_config.js +++ b/test/function/samples/amd-base-path/_config.js @@ -1,10 +1,18 @@ -module.exports = { +module.exports = defineTest({ description: 'throws when using only amd.basePath option', options: { - output: { dir: 'dist', amd: { basePath: 'a' } } + output: { + dir: 'dist', + amd: { + // @ts-expect-error expected error + basePath: 'a' + } + } }, generateError: { code: 'INVALID_OPTION', - message: '"output.amd.basePath" only works with "output.amd.autoId".' + message: + 'Invalid value for option "output.amd.basePath" - this option only works with "output.amd.autoId".', + url: 'https://rollupjs.org/configuration-options/#output-amd-basepath' } -}; +}); diff --git a/test/function/samples/arbitrary-module-namespace-identifiers/_config.js b/test/function/samples/arbitrary-module-namespace-identifiers/_config.js new file mode 100644 index 00000000000..4de0134af78 --- /dev/null +++ b/test/function/samples/arbitrary-module-namespace-identifiers/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'supports arbitrary module namespace identifiers' +}); diff --git a/test/function/samples/arbitrary-module-namespace-identifiers/foo.js b/test/function/samples/arbitrary-module-namespace-identifiers/foo.js new file mode 100644 index 00000000000..c9bcef7506a --- /dev/null +++ b/test/function/samples/arbitrary-module-namespace-identifiers/foo.js @@ -0,0 +1,2 @@ +const foo = 42; +export { foo as ' 😆 ' }; diff --git a/test/function/samples/arbitrary-module-namespace-identifiers/main.js b/test/function/samples/arbitrary-module-namespace-identifiers/main.js new file mode 100644 index 00000000000..ed6192936f5 --- /dev/null +++ b/test/function/samples/arbitrary-module-namespace-identifiers/main.js @@ -0,0 +1,3 @@ +import { ' 🙄 ' as foo } from './reexport.js'; + +assert.strictEqual(foo, 42); diff --git a/test/function/samples/arbitrary-module-namespace-identifiers/reexport.js b/test/function/samples/arbitrary-module-namespace-identifiers/reexport.js new file mode 100644 index 00000000000..bbf38851b35 --- /dev/null +++ b/test/function/samples/arbitrary-module-namespace-identifiers/reexport.js @@ -0,0 +1 @@ +export { ' 😆 ' as ' 🙄 ' } from './foo.js'; diff --git a/test/function/samples/argument-deoptimization/global-calls/_config.js b/test/function/samples/argument-deoptimization/global-calls/_config.js new file mode 100644 index 00000000000..4cae795a68a --- /dev/null +++ b/test/function/samples/argument-deoptimization/global-calls/_config.js @@ -0,0 +1,8 @@ +module.exports = defineTest({ + description: 'tracks argument mutations of calls to globals', + options: { + treeshake: { + tryCatchDeoptimization: false + } + } +}); diff --git a/test/function/samples/argument-deoptimization/global-calls/main.js b/test/function/samples/argument-deoptimization/global-calls/main.js new file mode 100644 index 00000000000..0ab9d9cc321 --- /dev/null +++ b/test/function/samples/argument-deoptimization/global-calls/main.js @@ -0,0 +1,17 @@ +let errored = false; +try { + const a = {}; + Object.freeze(a); + a.notAllowed = 1; +} catch (error) { + errored = true; +} +assert.ok(errored); + +const b = { mutated: false }; +Object.defineProperty(b, 'mutated', { value: true }); +assert.ok(b.mutated ? true : false); + +const c = { mutated: false }; +Object.defineProperties(c, { mutated: { value: true } }); +assert.ok(c.mutated ? true : false); diff --git a/test/function/samples/argument-deoptimization/parameter-access-mutation/_config.js b/test/function/samples/argument-deoptimization/parameter-access-mutation/_config.js new file mode 100644 index 00000000000..e495ceb3b8c --- /dev/null +++ b/test/function/samples/argument-deoptimization/parameter-access-mutation/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'tracks mutations of function parameters when accessed' +}); diff --git a/test/function/samples/argument-deoptimization/parameter-access-mutation/main.js b/test/function/samples/argument-deoptimization/parameter-access-mutation/main.js new file mode 100644 index 00000000000..fc538ceb75d --- /dev/null +++ b/test/function/samples/argument-deoptimization/parameter-access-mutation/main.js @@ -0,0 +1,14 @@ +const obj = { + get mutator() { + this.mutated = true; + }, + mutated: false +}; + +function updateObj(target) { + target.mutator; +} + +updateObj(obj); + +assert.ok(obj.mutated ? true : false); diff --git a/test/function/samples/argument-deoptimization/parameter-call-mutation/_config.js b/test/function/samples/argument-deoptimization/parameter-call-mutation/_config.js new file mode 100644 index 00000000000..0bbcc602c1f --- /dev/null +++ b/test/function/samples/argument-deoptimization/parameter-call-mutation/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'tracks mutations of function parameters when called' +}); diff --git a/test/function/samples/argument-deoptimization/parameter-call-mutation/main.js b/test/function/samples/argument-deoptimization/parameter-call-mutation/main.js new file mode 100644 index 00000000000..965a98242eb --- /dev/null +++ b/test/function/samples/argument-deoptimization/parameter-call-mutation/main.js @@ -0,0 +1,14 @@ +const obj = { + mutator() { + this.mutated = true; + }, + mutated: false +}; + +function updateObj(target) { + target.mutator(); +} + +updateObj(obj); + +assert.ok(obj.mutated ? true : false); diff --git a/test/function/samples/argument-deoptimization/parameter-deep-access-mutation/_config.js b/test/function/samples/argument-deoptimization/parameter-deep-access-mutation/_config.js new file mode 100644 index 00000000000..e495ceb3b8c --- /dev/null +++ b/test/function/samples/argument-deoptimization/parameter-deep-access-mutation/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'tracks mutations of function parameters when accessed' +}); diff --git a/test/function/samples/argument-deoptimization/parameter-deep-access-mutation/main.js b/test/function/samples/argument-deoptimization/parameter-deep-access-mutation/main.js new file mode 100644 index 00000000000..12a18d70362 --- /dev/null +++ b/test/function/samples/argument-deoptimization/parameter-deep-access-mutation/main.js @@ -0,0 +1,16 @@ +const obj = { + nested: { + get mutator() { + this.mutated = true; + }, + mutated: false + } +}; + +function updateObj(target) { + target.nested.mutator; +} + +updateObj(obj); + +assert.ok(obj.nested.mutated ? true : false); diff --git a/test/function/samples/argument-deoptimization/parameter-mutation-destructured/_config.js b/test/function/samples/argument-deoptimization/parameter-mutation-destructured/_config.js new file mode 100644 index 00000000000..4513b76f394 --- /dev/null +++ b/test/function/samples/argument-deoptimization/parameter-mutation-destructured/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'tracks mutations of destructured function parameters' +}); diff --git a/test/function/samples/argument-deoptimization/parameter-mutation-destructured/main.js b/test/function/samples/argument-deoptimization/parameter-mutation-destructured/main.js new file mode 100644 index 00000000000..3f4d8321654 --- /dev/null +++ b/test/function/samples/argument-deoptimization/parameter-mutation-destructured/main.js @@ -0,0 +1,9 @@ +const obj = { nested: { mutated: false } }; + +function updateObj({ nested }) { + nested.mutated = true; +} + +updateObj(obj); + +assert.ok(obj.nested.mutated ? true : false); diff --git a/test/function/samples/argument-deoptimization/parameter-mutation-spread/_config.js b/test/function/samples/argument-deoptimization/parameter-mutation-spread/_config.js new file mode 100644 index 00000000000..1bff8ad08c4 --- /dev/null +++ b/test/function/samples/argument-deoptimization/parameter-mutation-spread/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'tracks mutations of function parameters picked up by spread operator' +}); diff --git a/test/function/samples/argument-deoptimization/parameter-mutation-spread/main.js b/test/function/samples/argument-deoptimization/parameter-mutation-spread/main.js new file mode 100644 index 00000000000..3575249c051 --- /dev/null +++ b/test/function/samples/argument-deoptimization/parameter-mutation-spread/main.js @@ -0,0 +1,12 @@ +const obj1 = { mutated: false }; +const obj2 = { mutated: false }; + +function updateObj(...args) { + args[0].mutated = true; + args[1].mutated = true; +} + +updateObj(obj1, obj2); + +assert.ok(obj1.mutated ? true : false, 'obj1'); +assert.ok(obj2.mutated ? true : false, 'obj2'); diff --git a/test/function/samples/argument-deoptimization/parameter-mutation/_config.js b/test/function/samples/argument-deoptimization/parameter-mutation/_config.js new file mode 100644 index 00000000000..b9398cb6bdf --- /dev/null +++ b/test/function/samples/argument-deoptimization/parameter-mutation/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'tracks mutations of function parameters' +}); diff --git a/test/function/samples/argument-deoptimization/parameter-mutation/main.js b/test/function/samples/argument-deoptimization/parameter-mutation/main.js new file mode 100644 index 00000000000..cf077b3148a --- /dev/null +++ b/test/function/samples/argument-deoptimization/parameter-mutation/main.js @@ -0,0 +1,9 @@ +const obj = { mutated: false }; + +function updateObj(target) { + target.mutated = true; +} + +updateObj(obj); + +assert.ok(obj.mutated ? true : false); diff --git a/test/function/samples/argument-deoptimization/parameter-variable-merge/_config.js b/test/function/samples/argument-deoptimization/parameter-variable-merge/_config.js new file mode 100644 index 00000000000..6e54decc80b --- /dev/null +++ b/test/function/samples/argument-deoptimization/parameter-variable-merge/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'correctly merges parameters and variable declarations' +}); diff --git a/test/function/samples/argument-deoptimization/parameter-variable-merge/main.js b/test/function/samples/argument-deoptimization/parameter-variable-merge/main.js new file mode 100644 index 00000000000..23a826d3318 --- /dev/null +++ b/test/function/samples/argument-deoptimization/parameter-variable-merge/main.js @@ -0,0 +1,8 @@ +function test(foo) { + var foo; + var foo; + assert.ok(foo ? true : false); + return foo; +} + +assert.ok(test(true) ? true : false); diff --git a/test/function/samples/argument-deoptimization/return-function-known/_config.js b/test/function/samples/argument-deoptimization/return-function-known/_config.js new file mode 100644 index 00000000000..d3d765cf06d --- /dev/null +++ b/test/function/samples/argument-deoptimization/return-function-known/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'tracks mutations of function parameters by known returned functions' +}); diff --git a/test/function/samples/argument-deoptimization/return-function-known/main.js b/test/function/samples/argument-deoptimization/return-function-known/main.js new file mode 100644 index 00000000000..c1d21a21968 --- /dev/null +++ b/test/function/samples/argument-deoptimization/return-function-known/main.js @@ -0,0 +1,11 @@ +const obj = { mutated: false }; + +function updateObj() { + return target => { + target.mutated = true; + }; +} + +updateObj()(obj); + +assert.ok(obj.mutated ? true : false); diff --git a/test/function/samples/argument-deoptimization/return-function-unknown/_config.js b/test/function/samples/argument-deoptimization/return-function-unknown/_config.js new file mode 100644 index 00000000000..d3d765cf06d --- /dev/null +++ b/test/function/samples/argument-deoptimization/return-function-unknown/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'tracks mutations of function parameters by known returned functions' +}); diff --git a/test/function/samples/argument-deoptimization/return-function-unknown/main.js b/test/function/samples/argument-deoptimization/return-function-unknown/main.js new file mode 100644 index 00000000000..411896e7a87 --- /dev/null +++ b/test/function/samples/argument-deoptimization/return-function-unknown/main.js @@ -0,0 +1,10 @@ +const obj = { mutated: false }; + +global.handler = () => target => { + target.mutated = true; + delete global.handler; +}; + +handler()(obj); + +assert.ok(obj.mutated ? true : false); diff --git a/test/function/samples/argument-deoptimization/unknown-global-assignment/_config.js b/test/function/samples/argument-deoptimization/unknown-global-assignment/_config.js new file mode 100644 index 00000000000..14760749f35 --- /dev/null +++ b/test/function/samples/argument-deoptimization/unknown-global-assignment/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'tracks mutations of assignments to unknown globals' +}); diff --git a/test/function/samples/argument-deoptimization/unknown-global-assignment/main.js b/test/function/samples/argument-deoptimization/unknown-global-assignment/main.js new file mode 100644 index 00000000000..7480e02a135 --- /dev/null +++ b/test/function/samples/argument-deoptimization/unknown-global-assignment/main.js @@ -0,0 +1,13 @@ +globalThis.obj = { + set target(value) { + value.mutated = true; + } +}; + +const assigned = { + mutated: false +}; + +obj.target = assigned; + +assert.ok(assigned.mutated ? true : false); diff --git a/test/function/samples/argument-deoptimization/unknown-global-call/_config.js b/test/function/samples/argument-deoptimization/unknown-global-call/_config.js new file mode 100644 index 00000000000..e081e8244db --- /dev/null +++ b/test/function/samples/argument-deoptimization/unknown-global-call/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'tracks argument mutations of calls to unknown globals' +}); diff --git a/test/function/samples/argument-deoptimization/unknown-global-call/main.js b/test/function/samples/argument-deoptimization/unknown-global-call/main.js new file mode 100644 index 00000000000..e77b53a0dfe --- /dev/null +++ b/test/function/samples/argument-deoptimization/unknown-global-call/main.js @@ -0,0 +1,11 @@ +globalThis.fn = arg => { + arg.mutated = true; +}; + +const obj = { + mutated: false +}; + +fn(obj); + +assert.ok(obj.mutated ? true : false); diff --git a/test/function/samples/argument-treeshaking-parameter-conflict/_config.js b/test/function/samples/argument-treeshaking-parameter-conflict/_config.js index a5e3f2c5620..cccfdf70011 100644 --- a/test/function/samples/argument-treeshaking-parameter-conflict/_config.js +++ b/test/function/samples/argument-treeshaking-parameter-conflict/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'does not cause conflicts when deconflicting non-included parameters' -}; +}); diff --git a/test/function/samples/array-deoptimization/_config.js b/test/function/samples/array-deoptimization/_config.js new file mode 100644 index 00000000000..f9955d9d194 --- /dev/null +++ b/test/function/samples/array-deoptimization/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'tracks array deoptimizations' +}); diff --git a/test/function/samples/array-deoptimization/main.js b/test/function/samples/array-deoptimization/main.js new file mode 100644 index 00000000000..4a41b190942 --- /dev/null +++ b/test/function/samples/array-deoptimization/main.js @@ -0,0 +1,11 @@ +const array = [true]; + +function test(){ + if (array[0] || false) { + array.unshift(false); + } + assert.strictEqual(array[0] && true, false); +} + +test() +test() diff --git a/test/function/samples/array-double-spread/_config.js b/test/function/samples/array-double-spread/_config.js new file mode 100644 index 00000000000..131e3581fbf --- /dev/null +++ b/test/function/samples/array-double-spread/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'correctly deoptimizes when there is no proto' +}); diff --git a/test/function/samples/array-double-spread/main.js b/test/function/samples/array-double-spread/main.js new file mode 100644 index 00000000000..eeae903a1bd --- /dev/null +++ b/test/function/samples/array-double-spread/main.js @@ -0,0 +1,19 @@ +const a = [false, , true]; +const b = [false, , true, ...a, false, , true, ...a]; + +let count = 0; + +b[0] ? count+= 10: count++; +b[1] ? count+= 10: count++; +b[2] ? count+= 10: count++; +b[3] ? count+= 10: count++; +b[4] ? count+= 10: count++; +b[5] ? count+= 10: count++; +b[6] ? count+= 10: count++; +b[7] ? count+= 10: count++; +b[8] ? count+= 10: count++; +b[9] ? count+= 10: count++; +b[10] ? count+= 10: count++; +b[11] ? count+= 10: count++; + +assert.strictEqual(count, 48); diff --git a/test/function/samples/array-from-side-effect/_config.js b/test/function/samples/array-from-side-effect/_config.js index f8fffc8cca0..13db3d76d16 100644 --- a/test/function/samples/array-from-side-effect/_config.js +++ b/test/function/samples/array-from-side-effect/_config.js @@ -1,8 +1,8 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'Observes side-effects in Array.from', exports(exports) { assert.strictEqual(exports.x, 7); } -}; +}); diff --git a/test/function/samples/array-getter/_config.js b/test/function/samples/array-getter/_config.js new file mode 100644 index 00000000000..77d995f7548 --- /dev/null +++ b/test/function/samples/array-getter/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'handles getters defined on arrays' +}); diff --git a/test/function/samples/array-getter/main.js b/test/function/samples/array-getter/main.js new file mode 100644 index 00000000000..9ac16a7b6e6 --- /dev/null +++ b/test/function/samples/array-getter/main.js @@ -0,0 +1,14 @@ +let flag = false; +const array = []; + +Object.defineProperty(array, 'prop', { + get() { + flag = true; + } +}); + +array.prop; + +if (!flag) { + throw new Error('Mutation not detected'); +} diff --git a/test/function/samples/array-mutation/_config.js b/test/function/samples/array-mutation/_config.js new file mode 100644 index 00000000000..7aedc8b8dad --- /dev/null +++ b/test/function/samples/array-mutation/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'tracks array mutations' +}); diff --git a/test/function/samples/array-mutation/main.js b/test/function/samples/array-mutation/main.js new file mode 100644 index 00000000000..98363f0f469 --- /dev/null +++ b/test/function/samples/array-mutation/main.js @@ -0,0 +1,4 @@ +const array = []; +array.push(true); + +assert.strictEqual(array[0] || false, true); diff --git a/test/function/samples/asi-prevention-with-comment-like-strings/_config.js b/test/function/samples/asi-prevention-with-comment-like-strings/_config.js index 97a6b347859..c23920aa81d 100644 --- a/test/function/samples/asi-prevention-with-comment-like-strings/_config.js +++ b/test/function/samples/asi-prevention-with-comment-like-strings/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'do not hang when scanning for line-breaks in ASI prevention and there are comment-like strings' -}; +}); diff --git a/test/function/samples/assign-namespace-to-var/_config.js b/test/function/samples/assign-namespace-to-var/_config.js index 4a5e6b0a579..dfa32a14fcd 100644 --- a/test/function/samples/assign-namespace-to-var/_config.js +++ b/test/function/samples/assign-namespace-to-var/_config.js @@ -1,10 +1,10 @@ -module.exports = { +module.exports = defineTest({ description: 'allows a namespace to be assigned to a variable', warnings: [ { - chunkName: 'main', code: 'EMPTY_BUNDLE', - message: 'Generated an empty chunk: "main"' + message: 'Generated an empty chunk: "main".', + names: ['main'] } ] -}; +}); diff --git a/test/function/samples/assignment-deoptimization/assignee-is-deoptimized/_config.js b/test/function/samples/assignment-deoptimization/assignee-is-deoptimized/_config.js index 25bb08a0f03..746e1e85c49 100644 --- a/test/function/samples/assignment-deoptimization/assignee-is-deoptimized/_config.js +++ b/test/function/samples/assignment-deoptimization/assignee-is-deoptimized/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'makes sure the assignee is deoptimized' -}; +}); diff --git a/test/function/samples/assignment-deoptimization/assignment-target-is-deoptimized/_config.js b/test/function/samples/assignment-deoptimization/assignment-target-is-deoptimized/_config.js index cd94f45ae26..97798c8804f 100644 --- a/test/function/samples/assignment-deoptimization/assignment-target-is-deoptimized/_config.js +++ b/test/function/samples/assignment-deoptimization/assignment-target-is-deoptimized/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'makes sure the assignment target is deoptimized' -}; +}); diff --git a/test/function/samples/assignment-deoptimization/nested-assignment/_config.js b/test/function/samples/assignment-deoptimization/nested-assignment/_config.js index 7c3114ddadc..4fe911d3261 100644 --- a/test/function/samples/assignment-deoptimization/nested-assignment/_config.js +++ b/test/function/samples/assignment-deoptimization/nested-assignment/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'tracks assigments nested in expressions that are included for other reasons' -}; +}); diff --git a/test/function/samples/assignment-deoptimization/try-catch-inclusion/_config.js b/test/function/samples/assignment-deoptimization/try-catch-inclusion/_config.js index 4a7b55c699a..16c632cf582 100644 --- a/test/function/samples/assignment-deoptimization/try-catch-inclusion/_config.js +++ b/test/function/samples/assignment-deoptimization/try-catch-inclusion/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'tracks assigments included via try-catch-deoptimization' -}; +}); diff --git a/test/function/samples/assignment-patterns/_config.js b/test/function/samples/assignment-patterns/_config.js index 691299185ea..e106844c0c3 100644 --- a/test/function/samples/assignment-patterns/_config.js +++ b/test/function/samples/assignment-patterns/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'allows reassigments to default parameters that shadow imports' -}; +}); diff --git a/test/function/samples/assignment-to-exports-b/_config.js b/test/function/samples/assignment-to-exports-b/_config.js index 3d00cb3fc58..6a87b721e67 100644 --- a/test/function/samples/assignment-to-exports-b/_config.js +++ b/test/function/samples/assignment-to-exports-b/_config.js @@ -1,8 +1,8 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'exports are rewritten inside a variable init', exports: exports => { assert.equal(exports.b, 42); } -}; +}); diff --git a/test/function/samples/assignment-to-exports/_config.js b/test/function/samples/assignment-to-exports/_config.js index 5617f38aaaa..9c94ca8be1f 100644 --- a/test/function/samples/assignment-to-exports/_config.js +++ b/test/function/samples/assignment-to-exports/_config.js @@ -1,10 +1,10 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'exports are kept up-to-date', exports(exports) { assert.equal(exports.count, 0); exports.incr(); assert.equal(exports.count, 1); } -}; +}); diff --git a/test/function/samples/assignment-to-re-exports-conflict/_config.js b/test/function/samples/assignment-to-re-exports-conflict/_config.js index 54c8497857f..831474af81d 100644 --- a/test/function/samples/assignment-to-re-exports-conflict/_config.js +++ b/test/function/samples/assignment-to-re-exports-conflict/_config.js @@ -1,10 +1,10 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 're-exports are kept up-to-date', exports(exports) { assert.equal(exports.count, 0); exports.incr(); assert.equal(exports.count, 1); } -}; +}); diff --git a/test/function/samples/assignment-to-re-exports/_config.js b/test/function/samples/assignment-to-re-exports/_config.js index 54c8497857f..831474af81d 100644 --- a/test/function/samples/assignment-to-re-exports/_config.js +++ b/test/function/samples/assignment-to-re-exports/_config.js @@ -1,10 +1,10 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 're-exports are kept up-to-date', exports(exports) { assert.equal(exports.count, 0); exports.incr(); assert.equal(exports.count, 1); } -}; +}); diff --git a/test/function/samples/associate-arrow-function-parameter-mutations/_config.js b/test/function/samples/associate-arrow-function-parameter-mutations/_config.js index ea84da17ebd..cb9e0ebafee 100644 --- a/test/function/samples/associate-arrow-function-parameter-mutations/_config.js +++ b/test/function/samples/associate-arrow-function-parameter-mutations/_config.js @@ -1,9 +1,9 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'Associates arrow function parameters with their call arguments with regard to mutations', exports(exports) { assert.equal(exports.baz, 'present'); } -}; +}); diff --git a/test/function/samples/associate-arrow-function-return-values/_config.js b/test/function/samples/associate-arrow-function-return-values/_config.js index c44afb3de67..9de1dd167b9 100644 --- a/test/function/samples/associate-arrow-function-return-values/_config.js +++ b/test/function/samples/associate-arrow-function-return-values/_config.js @@ -1,8 +1,8 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'Associates function return values with regard to mutations', exports(exports) { assert.equal(exports.bar, 'present'); } -}; +}); diff --git a/test/function/samples/associate-es5-constructor-parameter-mutations/_config.js b/test/function/samples/associate-es5-constructor-parameter-mutations/_config.js index e1cd7b66e4f..58d8bdb147a 100644 --- a/test/function/samples/associate-es5-constructor-parameter-mutations/_config.js +++ b/test/function/samples/associate-es5-constructor-parameter-mutations/_config.js @@ -1,8 +1,8 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'Associates ES5 constructor parameters with their call arguments', exports(exports) { assert.equal(exports.bar, 'present'); } -}; +}); diff --git a/test/function/samples/associate-es6-constructor-parameter-mutations/_config.js b/test/function/samples/associate-es6-constructor-parameter-mutations/_config.js index e1cd7b66e4f..58d8bdb147a 100644 --- a/test/function/samples/associate-es6-constructor-parameter-mutations/_config.js +++ b/test/function/samples/associate-es6-constructor-parameter-mutations/_config.js @@ -1,8 +1,8 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'Associates ES5 constructor parameters with their call arguments', exports(exports) { assert.equal(exports.bar, 'present'); } -}; +}); diff --git a/test/function/samples/associate-function-parameter-mutations-2/_config.js b/test/function/samples/associate-function-parameter-mutations-2/_config.js index 226fd6ac9a3..7cb7c66853e 100644 --- a/test/function/samples/associate-function-parameter-mutations-2/_config.js +++ b/test/function/samples/associate-function-parameter-mutations-2/_config.js @@ -1,8 +1,8 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'Associates function parameters with their call arguments with regard to mutations', exports(exports) { assert.equal(exports.bar, 'present'); } -}; +}); diff --git a/test/function/samples/associate-function-parameter-mutations/_config.js b/test/function/samples/associate-function-parameter-mutations/_config.js index 86683fa2249..b9835c8de95 100644 --- a/test/function/samples/associate-function-parameter-mutations/_config.js +++ b/test/function/samples/associate-function-parameter-mutations/_config.js @@ -1,8 +1,8 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'Associates function parameters with their call arguments with regard to mutations', exports(exports) { assert.equal(exports.baz, 'present'); } -}; +}); diff --git a/test/function/samples/associate-function-return-values-2/_config.js b/test/function/samples/associate-function-return-values-2/_config.js index 5ea65ab536c..459e20d848c 100644 --- a/test/function/samples/associate-function-return-values-2/_config.js +++ b/test/function/samples/associate-function-return-values-2/_config.js @@ -1,8 +1,8 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'Associates function return values with regard to calls', exports(exports) { assert.equal(exports.bar, 'present'); } -}; +}); diff --git a/test/function/samples/associate-function-return-values-3/_config.js b/test/function/samples/associate-function-return-values-3/_config.js index 433f0b678d6..5e415df184a 100644 --- a/test/function/samples/associate-function-return-values-3/_config.js +++ b/test/function/samples/associate-function-return-values-3/_config.js @@ -1,8 +1,8 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'Associates function return values of returned functions', exports(exports) { assert.equal(exports.bar, 'present'); } -}; +}); diff --git a/test/function/samples/associate-function-return-values-4/_config.js b/test/function/samples/associate-function-return-values-4/_config.js index 80e49effd2d..00eb1b235e0 100644 --- a/test/function/samples/associate-function-return-values-4/_config.js +++ b/test/function/samples/associate-function-return-values-4/_config.js @@ -1,8 +1,8 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'Handles empty return statements (#1702)', exports(exports) { assert.equal(exports.bar, 'present'); } -}; +}); diff --git a/test/function/samples/associate-function-return-values-5/_config.js b/test/function/samples/associate-function-return-values-5/_config.js index 9697947601e..6884e5d5bd8 100644 --- a/test/function/samples/associate-function-return-values-5/_config.js +++ b/test/function/samples/associate-function-return-values-5/_config.js @@ -1,8 +1,8 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'Associates value mutations across return values', exports(exports) { assert.equal(exports.bar, 'present'); } -}; +}); diff --git a/test/function/samples/associate-function-return-values-across-other-expressions/_config.js b/test/function/samples/associate-function-return-values-across-other-expressions/_config.js index c44afb3de67..9de1dd167b9 100644 --- a/test/function/samples/associate-function-return-values-across-other-expressions/_config.js +++ b/test/function/samples/associate-function-return-values-across-other-expressions/_config.js @@ -1,8 +1,8 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'Associates function return values with regard to mutations', exports(exports) { assert.equal(exports.bar, 'present'); } -}; +}); diff --git a/test/function/samples/associate-function-return-values/_config.js b/test/function/samples/associate-function-return-values/_config.js index c44afb3de67..9de1dd167b9 100644 --- a/test/function/samples/associate-function-return-values/_config.js +++ b/test/function/samples/associate-function-return-values/_config.js @@ -1,8 +1,8 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'Associates function return values with regard to mutations', exports(exports) { assert.equal(exports.bar, 'present'); } -}; +}); diff --git a/test/function/samples/associate-getter-return-values-2/_config.js b/test/function/samples/associate-getter-return-values-2/_config.js index 18d48c57e37..5019d71d961 100644 --- a/test/function/samples/associate-getter-return-values-2/_config.js +++ b/test/function/samples/associate-getter-return-values-2/_config.js @@ -1,8 +1,8 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'Associates getter return values with regard to calls', exports(exports) { assert.equal(exports.bar, 'present'); } -}; +}); diff --git a/test/function/samples/associate-getter-return-values/_config.js b/test/function/samples/associate-getter-return-values/_config.js index 22ebb748299..8d9ba8ae18a 100644 --- a/test/function/samples/associate-getter-return-values/_config.js +++ b/test/function/samples/associate-getter-return-values/_config.js @@ -1,8 +1,8 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'Associates getter return values with regard to mutations', exports(exports) { assert.equal(exports.bar, 'present'); } -}; +}); diff --git a/test/function/samples/associate-method-parameter-mutations-2/_config.js b/test/function/samples/associate-method-parameter-mutations-2/_config.js index 9155e9aa8d9..ce60a4a200d 100644 --- a/test/function/samples/associate-method-parameter-mutations-2/_config.js +++ b/test/function/samples/associate-method-parameter-mutations-2/_config.js @@ -1,8 +1,8 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'Associates method parameters with their call arguments with regard to mutations', exports(exports) { assert.equal(exports.bar, 'present'); } -}; +}); diff --git a/test/function/samples/associate-method-parameter-mutations/_config.js b/test/function/samples/associate-method-parameter-mutations/_config.js index 0ec01955886..9604ccf9bad 100644 --- a/test/function/samples/associate-method-parameter-mutations/_config.js +++ b/test/function/samples/associate-method-parameter-mutations/_config.js @@ -1,8 +1,8 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'Associates method parameters with their call arguments with regard to mutations', exports(exports) { assert.equal(exports.baz, 'present'); } -}; +}); diff --git a/test/function/samples/associate-object-expression-parameter-mutations/_config.js b/test/function/samples/associate-object-expression-parameter-mutations/_config.js index cf6358633f1..5ce355cb425 100644 --- a/test/function/samples/associate-object-expression-parameter-mutations/_config.js +++ b/test/function/samples/associate-object-expression-parameter-mutations/_config.js @@ -1,8 +1,8 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'Associates object expression member parameters with their call arguments', exports(exports) { assert.equal(exports.bar, 'present'); } -}; +}); diff --git a/test/function/samples/associate-object-expression-return-values/_config.js b/test/function/samples/associate-object-expression-return-values/_config.js index cf6358633f1..5ce355cb425 100644 --- a/test/function/samples/associate-object-expression-return-values/_config.js +++ b/test/function/samples/associate-object-expression-return-values/_config.js @@ -1,8 +1,8 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'Associates object expression member parameters with their call arguments', exports(exports) { assert.equal(exports.bar, 'present'); } -}; +}); diff --git a/test/function/samples/associate-parameter-mutations-across-other-expressions/_config.js b/test/function/samples/associate-parameter-mutations-across-other-expressions/_config.js index dd35b41d1de..0d06672ea9a 100644 --- a/test/function/samples/associate-parameter-mutations-across-other-expressions/_config.js +++ b/test/function/samples/associate-parameter-mutations-across-other-expressions/_config.js @@ -1,8 +1,8 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'Associates parameters with their call arguments across other expressions', exports(exports) { assert.equal(exports.bar, 'present'); } -}; +}); diff --git a/test/function/samples/associate-setter-parameters/_config.js b/test/function/samples/associate-setter-parameters/_config.js index 22ebb748299..8d9ba8ae18a 100644 --- a/test/function/samples/associate-setter-parameters/_config.js +++ b/test/function/samples/associate-setter-parameters/_config.js @@ -1,8 +1,8 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'Associates getter return values with regard to mutations', exports(exports) { assert.equal(exports.bar, 'present'); } -}; +}); diff --git a/test/function/samples/ast-validations/double-default-export/_config.js b/test/function/samples/ast-validations/double-default-export/_config.js new file mode 100644 index 00000000000..1c4175b7164 --- /dev/null +++ b/test/function/samples/ast-validations/double-default-export/_config.js @@ -0,0 +1,24 @@ +const path = require('node:path'); +const ID_FOO = path.join(__dirname, 'foo.js'); +const ID_MAIN = path.join(__dirname, 'main.js'); + +module.exports = defineTest({ + description: 'throws on double default exports', + error: { + code: 'DUPLICATE_EXPORT', + message: 'foo.js (2:0): Duplicate export "default"', + id: ID_FOO, + pos: 18, + watchFiles: [ID_FOO, ID_MAIN], + loc: { + file: ID_FOO, + line: 2, + column: 0 + }, + frame: ` + 1: export default 1; + 2: export default 2; + ^ + ` + } +}); diff --git a/test/function/samples/double-default-export/foo.js b/test/function/samples/ast-validations/double-default-export/foo.js similarity index 100% rename from test/function/samples/double-default-export/foo.js rename to test/function/samples/ast-validations/double-default-export/foo.js diff --git a/test/function/samples/double-default-export/main.js b/test/function/samples/ast-validations/double-default-export/main.js similarity index 100% rename from test/function/samples/double-default-export/main.js rename to test/function/samples/ast-validations/double-default-export/main.js diff --git a/test/function/samples/ast-validations/double-named-export/_config.js b/test/function/samples/ast-validations/double-named-export/_config.js new file mode 100644 index 00000000000..af6811c6656 --- /dev/null +++ b/test/function/samples/ast-validations/double-named-export/_config.js @@ -0,0 +1,25 @@ +const path = require('node:path'); +const ID_MAIN = path.join(__dirname, 'main.js'); +const ID_FOO = path.join(__dirname, 'foo.js'); + +module.exports = defineTest({ + description: 'throws on duplicate named exports', + error: { + code: 'DUPLICATE_EXPORT', + message: 'foo.js (3:9): Duplicate export "foo"', + id: ID_FOO, + pos: 38, + watchFiles: [ID_FOO, ID_MAIN], + loc: { + file: ID_FOO, + line: 3, + column: 9 + }, + frame: ` + 1: var foo = 1; + 2: export { foo }; + 3: export { foo }; + ^ + ` + } +}); diff --git a/test/function/samples/double-named-export/foo.js b/test/function/samples/ast-validations/double-named-export/foo.js similarity index 100% rename from test/function/samples/double-named-export/foo.js rename to test/function/samples/ast-validations/double-named-export/foo.js diff --git a/test/function/samples/double-named-export/main.js b/test/function/samples/ast-validations/double-named-export/main.js similarity index 100% rename from test/function/samples/double-named-export/main.js rename to test/function/samples/ast-validations/double-named-export/main.js diff --git a/test/function/samples/ast-validations/double-named-reexport/_config.js b/test/function/samples/ast-validations/double-named-reexport/_config.js new file mode 100644 index 00000000000..009e412c77d --- /dev/null +++ b/test/function/samples/ast-validations/double-named-reexport/_config.js @@ -0,0 +1,25 @@ +const path = require('node:path'); +const ID_MAIN = path.join(__dirname, 'main.js'); +const ID_FOO = path.join(__dirname, 'foo.js'); + +module.exports = defineTest({ + description: 'throws on duplicate named exports', + error: { + code: 'DUPLICATE_EXPORT', + message: 'foo.js (3:9): Duplicate export "foo"', + id: ID_FOO, + pos: 38, + watchFiles: [ID_FOO, ID_MAIN], + loc: { + file: ID_FOO, + line: 3, + column: 9 + }, + frame: ` + 1: var foo = 1; + 2: export { foo }; + 3: export { foo } from './bar.js'; + ^ + ` + } +}); diff --git a/test/function/samples/double-named-reexport/bar.js b/test/function/samples/ast-validations/double-named-reexport/bar.js similarity index 100% rename from test/function/samples/double-named-reexport/bar.js rename to test/function/samples/ast-validations/double-named-reexport/bar.js diff --git a/test/function/samples/double-named-reexport/foo.js b/test/function/samples/ast-validations/double-named-reexport/foo.js similarity index 100% rename from test/function/samples/double-named-reexport/foo.js rename to test/function/samples/ast-validations/double-named-reexport/foo.js diff --git a/test/function/samples/double-named-reexport/main.js b/test/function/samples/ast-validations/double-named-reexport/main.js similarity index 100% rename from test/function/samples/double-named-reexport/main.js rename to test/function/samples/ast-validations/double-named-reexport/main.js diff --git a/test/function/samples/ast-validations/duplicate-function-export/_config.js b/test/function/samples/ast-validations/duplicate-function-export/_config.js new file mode 100644 index 00000000000..5d255f63fa9 --- /dev/null +++ b/test/function/samples/ast-validations/duplicate-function-export/_config.js @@ -0,0 +1,23 @@ +const path = require('node:path'); +const ID_MAIN = path.join(__dirname, 'main.js'); + +module.exports = defineTest({ + description: 'throws on duplicate namespace exports', + error: { + code: 'DUPLICATE_EXPORT', + message: 'main.js (3:16): Duplicate export "foo"', + id: ID_MAIN, + pos: 54, + watchFiles: [ID_MAIN], + loc: { + file: ID_MAIN, + line: 3, + column: 16 + }, + frame: ` + 1: const bar = 1; + 2: export { bar as foo }; + 3: export function foo() {} + ^` + } +}); diff --git a/test/function/samples/ast-validations/duplicate-function-export/main.js b/test/function/samples/ast-validations/duplicate-function-export/main.js new file mode 100644 index 00000000000..cc67c7065ad --- /dev/null +++ b/test/function/samples/ast-validations/duplicate-function-export/main.js @@ -0,0 +1,3 @@ +const bar = 1; +export { bar as foo }; +export function foo() {} diff --git a/test/function/samples/ast-validations/duplicate-import-fails/_config.js b/test/function/samples/ast-validations/duplicate-import-fails/_config.js new file mode 100644 index 00000000000..5d313cc4d58 --- /dev/null +++ b/test/function/samples/ast-validations/duplicate-import-fails/_config.js @@ -0,0 +1,27 @@ +const path = require('node:path'); +const ID_MAIN = path.join(__dirname, 'main.js'); + +module.exports = defineTest({ + description: 'disallows duplicate imports', + error: { + code: 'REDECLARATION_ERROR', + message: 'main.js (2:9): Identifier "a" has already been declared', + id: ID_MAIN, + pos: 36, + watchFiles: [ID_MAIN], + loc: { + file: ID_MAIN, + line: 2, + column: 9 + }, + frame: ` + 1: import { a } from './foo'; + 2: import { a } from './foo'; + ^ + 3: + 4: assert.equal(a, 1); + ` + } +}); + +// test copied from https://github.com/esnext/es6-module-transpiler/tree/master/test/examples/duplicate-import-fails diff --git a/test/function/samples/duplicate-import-fails/foo.js b/test/function/samples/ast-validations/duplicate-import-fails/foo.js similarity index 100% rename from test/function/samples/duplicate-import-fails/foo.js rename to test/function/samples/ast-validations/duplicate-import-fails/foo.js diff --git a/test/function/samples/duplicate-import-fails/main.js b/test/function/samples/ast-validations/duplicate-import-fails/main.js similarity index 100% rename from test/function/samples/duplicate-import-fails/main.js rename to test/function/samples/ast-validations/duplicate-import-fails/main.js diff --git a/test/function/samples/ast-validations/duplicate-import-specifier-fails/_config.js b/test/function/samples/ast-validations/duplicate-import-specifier-fails/_config.js new file mode 100644 index 00000000000..641d84416e5 --- /dev/null +++ b/test/function/samples/ast-validations/duplicate-import-specifier-fails/_config.js @@ -0,0 +1,25 @@ +const path = require('node:path'); +const ID_MAIN = path.join(__dirname, 'main.js'); + +module.exports = defineTest({ + description: 'disallows duplicate import specifiers', + error: { + code: 'REDECLARATION_ERROR', + message: 'main.js (1:12): Identifier "a" has already been declared', + id: ID_MAIN, + pos: 12, + watchFiles: [ID_MAIN], + loc: { + file: ID_MAIN, + line: 1, + column: 12 + }, + frame: ` + 1: import { a, a } from './foo'; + ^ + 2: assert.equal(a, 1); + ` + } +}); + +// test copied from https://github.com/esnext/es6-module-transpiler/tree/master/test/examples/duplicate-import-specifier-fails diff --git a/test/function/samples/duplicate-import-specifier-fails/foo.js b/test/function/samples/ast-validations/duplicate-import-specifier-fails/foo.js similarity index 100% rename from test/function/samples/duplicate-import-specifier-fails/foo.js rename to test/function/samples/ast-validations/duplicate-import-specifier-fails/foo.js diff --git a/test/function/samples/duplicate-import-specifier-fails/main.js b/test/function/samples/ast-validations/duplicate-import-specifier-fails/main.js similarity index 100% rename from test/function/samples/duplicate-import-specifier-fails/main.js rename to test/function/samples/ast-validations/duplicate-import-specifier-fails/main.js diff --git a/test/function/samples/ast-validations/duplicate-namespace-export/_config.js b/test/function/samples/ast-validations/duplicate-namespace-export/_config.js new file mode 100644 index 00000000000..7a418d42c92 --- /dev/null +++ b/test/function/samples/ast-validations/duplicate-namespace-export/_config.js @@ -0,0 +1,23 @@ +const path = require('node:path'); +const ID_MAIN = path.join(__dirname, 'main.js'); + +module.exports = defineTest({ + description: 'throws on duplicate namespace exports', + error: { + code: 'DUPLICATE_EXPORT', + message: 'main.js (3:12): Duplicate export "foo"', + id: ID_MAIN, + pos: 50, + watchFiles: [ID_MAIN], + loc: { + file: ID_MAIN, + line: 3, + column: 12 + }, + frame: ` + 1: const bar = 1; + 2: export { bar as foo }; + 3: export * as foo from './main.js'; + ^` + } +}); diff --git a/test/function/samples/ast-validations/duplicate-namespace-export/main.js b/test/function/samples/ast-validations/duplicate-namespace-export/main.js new file mode 100644 index 00000000000..0aa09f86c72 --- /dev/null +++ b/test/function/samples/ast-validations/duplicate-namespace-export/main.js @@ -0,0 +1,3 @@ +const bar = 1; +export { bar as foo }; +export * as foo from './main.js'; diff --git a/test/function/samples/ast-validations/duplicate-parameter-name/_config.js b/test/function/samples/ast-validations/duplicate-parameter-name/_config.js new file mode 100644 index 00000000000..9a048b8fd59 --- /dev/null +++ b/test/function/samples/ast-validations/duplicate-parameter-name/_config.js @@ -0,0 +1,21 @@ +const path = require('node:path'); +const ID_MAIN = path.join(__dirname, 'main.js'); + +module.exports = defineTest({ + description: 'throws on duplicate parameter names as it would when running in strict mode', + error: { + code: 'DUPLICATE_ARGUMENT_NAME', + message: 'main.js (1:15): Duplicate argument name "a"', + id: ID_MAIN, + pos: 15, + watchFiles: [ID_MAIN], + loc: { + file: ID_MAIN, + line: 1, + column: 15 + }, + frame: ` + 1: function foo(a,a) {} + ^` + } +}); diff --git a/test/function/samples/ast-validations/duplicate-parameter-name/main.js b/test/function/samples/ast-validations/duplicate-parameter-name/main.js new file mode 100644 index 00000000000..9385a53d493 --- /dev/null +++ b/test/function/samples/ast-validations/duplicate-parameter-name/main.js @@ -0,0 +1 @@ +function foo(a,a) {} diff --git a/test/function/samples/ast-validations/duplicate-var-export/_config.js b/test/function/samples/ast-validations/duplicate-var-export/_config.js new file mode 100644 index 00000000000..4572eee6004 --- /dev/null +++ b/test/function/samples/ast-validations/duplicate-var-export/_config.js @@ -0,0 +1,22 @@ +const path = require('node:path'); +const ID_MAIN = path.join(__dirname, 'main.js'); + +module.exports = defineTest({ + description: 'throws on duplicate exports declared with "var"', + error: { + code: 'DUPLICATE_EXPORT', + message: 'main.js (2:11): Duplicate export "x"', + id: ID_MAIN, + pos: 29, + watchFiles: [ID_MAIN], + loc: { + file: ID_MAIN, + line: 2, + column: 11 + }, + frame: ` + 1: export var x = 1; + 2: export var x = 2; + ^` + } +}); diff --git a/test/function/samples/ast-validations/duplicate-var-export/main.js b/test/function/samples/ast-validations/duplicate-var-export/main.js new file mode 100644 index 00000000000..3e861a45400 --- /dev/null +++ b/test/function/samples/ast-validations/duplicate-var-export/main.js @@ -0,0 +1,2 @@ +export var x = 1; +export var x = 2; diff --git a/test/function/samples/ast-validations/reassign-import-fails/_config.js b/test/function/samples/ast-validations/reassign-import-fails/_config.js new file mode 100644 index 00000000000..086d01cb779 --- /dev/null +++ b/test/function/samples/ast-validations/reassign-import-fails/_config.js @@ -0,0 +1,26 @@ +const path = require('node:path'); +const ID_MAIN = path.join(__dirname, 'main.js'); +const ID_FOO = path.join(__dirname, 'foo.js'); + +module.exports = defineTest({ + description: 'disallows assignments to imported bindings', + error: { + code: 'ILLEGAL_REASSIGNMENT', + id: ID_MAIN, + pos: 113, + loc: { + column: 0, + file: ID_MAIN, + line: 8 + }, + frame: ` + 6: }); + 7: + 8: x = 10; + ^`, + watchFiles: [ID_FOO, ID_MAIN], + message: 'main.js (8:0): Illegal reassignment of import "x" in "main.js".' + } +}); + +// test copied from https://github.com/esnext/es6-module-transpiler/tree/master/test/examples/reassign-import-fails diff --git a/test/function/samples/reassign-import-fails/foo.js b/test/function/samples/ast-validations/reassign-import-fails/foo.js similarity index 100% rename from test/function/samples/reassign-import-fails/foo.js rename to test/function/samples/ast-validations/reassign-import-fails/foo.js diff --git a/test/function/samples/reassign-import-fails/main.js b/test/function/samples/ast-validations/reassign-import-fails/main.js similarity index 100% rename from test/function/samples/reassign-import-fails/main.js rename to test/function/samples/ast-validations/reassign-import-fails/main.js diff --git a/test/function/samples/ast-validations/reassign-import-not-at-top-level-fails/_config.js b/test/function/samples/ast-validations/reassign-import-not-at-top-level-fails/_config.js new file mode 100644 index 00000000000..f48f99eb8de --- /dev/null +++ b/test/function/samples/ast-validations/reassign-import-not-at-top-level-fails/_config.js @@ -0,0 +1,27 @@ +const path = require('node:path'); +const ID_MAIN = path.join(__dirname, 'main.js'); +const ID_FOO = path.join(__dirname, 'foo.js'); + +module.exports = defineTest({ + description: 'disallows assignments to imported bindings not at the top level', + error: { + code: 'ILLEGAL_REASSIGNMENT', + id: ID_MAIN, + pos: 95, + loc: { + column: 2, + file: ID_MAIN, + line: 7 + }, + frame: ` + 5: } + 6: export function bar () { + 7: x = 1; + ^ + 8: }`, + watchFiles: [ID_FOO, ID_MAIN], + message: 'main.js (7:2): Illegal reassignment of import "x" in "main.js".' + } +}); + +// test copied from https://github.com/esnext/es6-module-transpiler/tree/master/test/examples/reassign-import-fails diff --git a/test/function/samples/reassign-import-not-at-top-level-fails/foo.js b/test/function/samples/ast-validations/reassign-import-not-at-top-level-fails/foo.js similarity index 100% rename from test/function/samples/reassign-import-not-at-top-level-fails/foo.js rename to test/function/samples/ast-validations/reassign-import-not-at-top-level-fails/foo.js diff --git a/test/function/samples/reassign-import-not-at-top-level-fails/main.js b/test/function/samples/ast-validations/reassign-import-not-at-top-level-fails/main.js similarity index 100% rename from test/function/samples/reassign-import-not-at-top-level-fails/main.js rename to test/function/samples/ast-validations/reassign-import-not-at-top-level-fails/main.js diff --git a/test/function/samples/ast-validations/redeclare-block-function-function/_config.js b/test/function/samples/ast-validations/redeclare-block-function-function/_config.js new file mode 100644 index 00000000000..a020d9d761a --- /dev/null +++ b/test/function/samples/ast-validations/redeclare-block-function-function/_config.js @@ -0,0 +1,24 @@ +const path = require('node:path'); +const ID_MAIN = path.join(__dirname, 'main.js'); + +module.exports = defineTest({ + description: 'throws when redeclaring a function binding as a function in a block scope', + error: { + code: 'REDECLARATION_ERROR', + frame: ` + 1: { + 2: function foo() {} + 3: function foo() {} + ^ + 4: }`, + id: ID_MAIN, + loc: { + column: 10, + file: ID_MAIN, + line: 3 + }, + message: 'main.js (3:10): Identifier "foo" has already been declared', + pos: 31, + watchFiles: [ID_MAIN] + } +}); diff --git a/test/function/samples/ast-validations/redeclare-block-function-function/main.js b/test/function/samples/ast-validations/redeclare-block-function-function/main.js new file mode 100644 index 00000000000..0a33693175b --- /dev/null +++ b/test/function/samples/ast-validations/redeclare-block-function-function/main.js @@ -0,0 +1,4 @@ +{ + function foo() {} + function foo() {} +} diff --git a/test/function/samples/ast-validations/redeclare-catch-scope-local-variable-function/_config.js b/test/function/samples/ast-validations/redeclare-catch-scope-local-variable-function/_config.js new file mode 100644 index 00000000000..3fa1e8df324 --- /dev/null +++ b/test/function/samples/ast-validations/redeclare-catch-scope-local-variable-function/_config.js @@ -0,0 +1,24 @@ +const path = require('node:path'); +const ID_MAIN = path.join(__dirname, 'main.js'); + +module.exports = defineTest({ + description: 'throws when redeclaring the parameter of a catch scope as a function', + error: { + code: 'REDECLARATION_ERROR', + frame: ` + 2: throw new Error('failed'); + 3: } catch (error) { + 4: function error() {} + ^ + 5: }`, + id: ID_MAIN, + loc: { + column: 10, + file: ID_MAIN, + line: 4 + }, + message: 'main.js (4:10): Identifier "error" has already been declared', + pos: 62, + watchFiles: [ID_MAIN] + } +}); diff --git a/test/function/samples/ast-validations/redeclare-catch-scope-local-variable-function/main.js b/test/function/samples/ast-validations/redeclare-catch-scope-local-variable-function/main.js new file mode 100644 index 00000000000..8ae5964442f --- /dev/null +++ b/test/function/samples/ast-validations/redeclare-catch-scope-local-variable-function/main.js @@ -0,0 +1,5 @@ +try { + throw new Error('failed'); +} catch (error) { + function error() {} +} diff --git a/test/function/samples/ast-validations/redeclare-catch-scope-parameter-function/_config.js b/test/function/samples/ast-validations/redeclare-catch-scope-parameter-function/_config.js new file mode 100644 index 00000000000..6416f2c7702 --- /dev/null +++ b/test/function/samples/ast-validations/redeclare-catch-scope-parameter-function/_config.js @@ -0,0 +1,24 @@ +const path = require('node:path'); +const ID_MAIN = path.join(__dirname, 'main.js'); + +module.exports = defineTest({ + description: 'throws when redeclaring local variable in a catch scope as a function', + error: { + code: 'REDECLARATION_ERROR', + frame: ` + 3: } catch (e) { + 4: const a = 1; + 5: function a() {} + ^ + 6: }`, + id: ID_MAIN, + loc: { + column: 10, + file: ID_MAIN, + line: 5 + }, + message: 'main.js (5:10): Identifier "a" has already been declared', + pos: 64, + watchFiles: [ID_MAIN] + } +}); diff --git a/test/function/samples/ast-validations/redeclare-catch-scope-parameter-function/main.js b/test/function/samples/ast-validations/redeclare-catch-scope-parameter-function/main.js new file mode 100644 index 00000000000..ad83b8a4f82 --- /dev/null +++ b/test/function/samples/ast-validations/redeclare-catch-scope-parameter-function/main.js @@ -0,0 +1,6 @@ +try { + throw new Error(); +} catch (e) { + const a = 1; + function a() {} +} diff --git a/test/function/samples/ast-validations/redeclare-catch-scope-parameter-var-outside-conflict/_config.js b/test/function/samples/ast-validations/redeclare-catch-scope-parameter-var-outside-conflict/_config.js new file mode 100644 index 00000000000..5869cac02bd --- /dev/null +++ b/test/function/samples/ast-validations/redeclare-catch-scope-parameter-var-outside-conflict/_config.js @@ -0,0 +1,25 @@ +const path = require('node:path'); +const ID_MAIN = path.join(__dirname, 'main.js'); + +module.exports = defineTest({ + description: + 'throws when redeclaring a parameter of a catch scope as a var that conflicts with an outside binding', + error: { + code: 'REDECLARATION_ERROR', + frame: ` + 3: throw new Error('failed'); + 4: } catch (error) { + 5: var error; + ^ + 6: }`, + id: ID_MAIN, + loc: { + column: 5, + file: ID_MAIN, + line: 5 + }, + message: 'main.js (5:5): Identifier "error" has already been declared', + pos: 68, + watchFiles: [ID_MAIN] + } +}); diff --git a/test/function/samples/ast-validations/redeclare-catch-scope-parameter-var-outside-conflict/main.js b/test/function/samples/ast-validations/redeclare-catch-scope-parameter-var-outside-conflict/main.js new file mode 100644 index 00000000000..cb5868555f2 --- /dev/null +++ b/test/function/samples/ast-validations/redeclare-catch-scope-parameter-var-outside-conflict/main.js @@ -0,0 +1,6 @@ +let error; +try { + throw new Error('failed'); +} catch (error) { + var error; +} diff --git a/test/function/samples/ast-validations/redeclare-catch-scope-parameter-var/_config.js b/test/function/samples/ast-validations/redeclare-catch-scope-parameter-var/_config.js new file mode 100644 index 00000000000..1e43f1b49ab --- /dev/null +++ b/test/function/samples/ast-validations/redeclare-catch-scope-parameter-var/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'allows redeclaring a primitive parameter of a catch scope as a var' +}); diff --git a/test/function/samples/ast-validations/redeclare-catch-scope-parameter-var/main.js b/test/function/samples/ast-validations/redeclare-catch-scope-parameter-var/main.js new file mode 100644 index 00000000000..882bf742f46 --- /dev/null +++ b/test/function/samples/ast-validations/redeclare-catch-scope-parameter-var/main.js @@ -0,0 +1,7 @@ +try { + throw new Error('failed'); +} catch (error) { + var error = 1; + assert.ok(error === 1 ? true : false); +} +assert.ok(error === undefined ? true : false); diff --git a/test/function/samples/ast-validations/redeclare-catch-scope-pattern-parameter-var/_config.js b/test/function/samples/ast-validations/redeclare-catch-scope-pattern-parameter-var/_config.js new file mode 100644 index 00000000000..dbecc5f9d31 --- /dev/null +++ b/test/function/samples/ast-validations/redeclare-catch-scope-pattern-parameter-var/_config.js @@ -0,0 +1,24 @@ +const path = require('node:path'); +const ID_MAIN = path.join(__dirname, 'main.js'); + +module.exports = defineTest({ + description: 'throws when redeclaring a pattern parameter of a catch scope as a var', + error: { + code: 'REDECLARATION_ERROR', + frame: ` + 2: throw new Error('failed'); + 3: } catch ({ message }) { + 4: var message; + ^ + 5: }`, + id: ID_MAIN, + loc: { + column: 5, + file: ID_MAIN, + line: 4 + }, + message: 'main.js (4:5): Identifier "message" has already been declared', + pos: 63, + watchFiles: [ID_MAIN] + } +}); diff --git a/test/function/samples/ast-validations/redeclare-catch-scope-pattern-parameter-var/main.js b/test/function/samples/ast-validations/redeclare-catch-scope-pattern-parameter-var/main.js new file mode 100644 index 00000000000..1cd5e9dd317 --- /dev/null +++ b/test/function/samples/ast-validations/redeclare-catch-scope-pattern-parameter-var/main.js @@ -0,0 +1,5 @@ +try { + throw new Error('failed'); +} catch ({ message }) { + var message; +} diff --git a/test/function/samples/ast-validations/redeclare-class-function/_config.js b/test/function/samples/ast-validations/redeclare-class-function/_config.js new file mode 100644 index 00000000000..ef910f3a3d2 --- /dev/null +++ b/test/function/samples/ast-validations/redeclare-class-function/_config.js @@ -0,0 +1,22 @@ +const path = require('node:path'); +const ID_MAIN = path.join(__dirname, 'main.js'); + +module.exports = defineTest({ + description: 'throws when redeclaring a class binding as a function', + error: { + code: 'REDECLARATION_ERROR', + frame: ` + 1: class foo {} + 2: function foo() {} + ^`, + id: ID_MAIN, + loc: { + column: 9, + file: ID_MAIN, + line: 2 + }, + message: 'main.js (2:9): Identifier "foo" has already been declared', + pos: 22, + watchFiles: [ID_MAIN] + } +}); diff --git a/test/function/samples/ast-validations/redeclare-class-function/main.js b/test/function/samples/ast-validations/redeclare-class-function/main.js new file mode 100644 index 00000000000..c30e6cf9fea --- /dev/null +++ b/test/function/samples/ast-validations/redeclare-class-function/main.js @@ -0,0 +1,2 @@ +class foo {} +function foo() {} diff --git a/test/function/samples/ast-validations/redeclare-const-function/_config.js b/test/function/samples/ast-validations/redeclare-const-function/_config.js new file mode 100644 index 00000000000..f070c473602 --- /dev/null +++ b/test/function/samples/ast-validations/redeclare-const-function/_config.js @@ -0,0 +1,22 @@ +const path = require('node:path'); +const ID_MAIN = path.join(__dirname, 'main.js'); + +module.exports = defineTest({ + description: 'throws when redeclaring a const binding as a function', + error: { + code: 'REDECLARATION_ERROR', + frame: ` + 1: const foo = 1; + 2: function foo() {} + ^`, + id: ID_MAIN, + loc: { + column: 9, + file: ID_MAIN, + line: 2 + }, + message: 'main.js (2:9): Identifier "foo" has already been declared', + pos: 24, + watchFiles: [ID_MAIN] + } +}); diff --git a/test/function/samples/ast-validations/redeclare-const-function/main.js b/test/function/samples/ast-validations/redeclare-const-function/main.js new file mode 100644 index 00000000000..9b5434bbd5a --- /dev/null +++ b/test/function/samples/ast-validations/redeclare-const-function/main.js @@ -0,0 +1,2 @@ +const foo = 1; +function foo() {} diff --git a/test/function/samples/ast-validations/redeclare-default-import-function/_config.js b/test/function/samples/ast-validations/redeclare-default-import-function/_config.js new file mode 100644 index 00000000000..b4b17b3b6a6 --- /dev/null +++ b/test/function/samples/ast-validations/redeclare-default-import-function/_config.js @@ -0,0 +1,23 @@ +const path = require('node:path'); +const ID_MAIN = path.join(__dirname, 'main.js'); + +module.exports = defineTest({ + description: 'throws when redeclaring a default import with a function', + error: { + code: 'REDECLARATION_ERROR', + message: 'main.js (4:9): Identifier "foo" has already been declared', + id: ID_MAIN, + pos: 56, + watchFiles: [ID_MAIN], + loc: { + file: ID_MAIN, + line: 4, + column: 9 + }, + frame: ` + 2: + 3: console.log(foo); + 4: function foo() {} + ^` + } +}); diff --git a/test/function/samples/ast-validations/redeclare-default-import-function/foo.js b/test/function/samples/ast-validations/redeclare-default-import-function/foo.js new file mode 100644 index 00000000000..aef22247d75 --- /dev/null +++ b/test/function/samples/ast-validations/redeclare-default-import-function/foo.js @@ -0,0 +1 @@ +export default 1; diff --git a/test/function/samples/ast-validations/redeclare-default-import-function/main.js b/test/function/samples/ast-validations/redeclare-default-import-function/main.js new file mode 100644 index 00000000000..97347b250b1 --- /dev/null +++ b/test/function/samples/ast-validations/redeclare-default-import-function/main.js @@ -0,0 +1,4 @@ +import foo from './foo.js'; + +console.log(foo); +function foo() {} diff --git a/test/function/samples/ast-validations/redeclare-import-var/_config.js b/test/function/samples/ast-validations/redeclare-import-var/_config.js new file mode 100644 index 00000000000..587535a6578 --- /dev/null +++ b/test/function/samples/ast-validations/redeclare-import-var/_config.js @@ -0,0 +1,23 @@ +const path = require('node:path'); +const ID_MAIN = path.join(__dirname, 'main.js'); + +module.exports = defineTest({ + description: 'throws when redeclaring an import with a var', + error: { + code: 'REDECLARATION_ERROR', + message: 'main.js (4:4): Identifier "foo" has already been declared', + id: ID_MAIN, + pos: 55, + watchFiles: [ID_MAIN], + loc: { + file: ID_MAIN, + line: 4, + column: 4 + }, + frame: ` + 2: + 3: console.log(foo); + 4: var foo = 2; + ^` + } +}); diff --git a/test/function/samples/ast-validations/redeclare-import-var/foo.js b/test/function/samples/ast-validations/redeclare-import-var/foo.js new file mode 100644 index 00000000000..bb1843d113a --- /dev/null +++ b/test/function/samples/ast-validations/redeclare-import-var/foo.js @@ -0,0 +1 @@ +export const foo = 1; diff --git a/test/function/samples/ast-validations/redeclare-import-var/main.js b/test/function/samples/ast-validations/redeclare-import-var/main.js new file mode 100644 index 00000000000..ac6df0fc585 --- /dev/null +++ b/test/function/samples/ast-validations/redeclare-import-var/main.js @@ -0,0 +1,4 @@ +import { foo } from './foo.js'; + +console.log(foo); +var foo = 2; diff --git a/test/function/samples/ast-validations/redeclare-let-function/_config.js b/test/function/samples/ast-validations/redeclare-let-function/_config.js new file mode 100644 index 00000000000..f73e86b394f --- /dev/null +++ b/test/function/samples/ast-validations/redeclare-let-function/_config.js @@ -0,0 +1,22 @@ +const path = require('node:path'); +const ID_MAIN = path.join(__dirname, 'main.js'); + +module.exports = defineTest({ + description: 'throws when redeclaring a let binding as a function', + error: { + code: 'REDECLARATION_ERROR', + frame: ` + 1: let foo; + 2: function foo() {} + ^`, + id: ID_MAIN, + loc: { + column: 9, + file: ID_MAIN, + line: 2 + }, + message: 'main.js (2:9): Identifier "foo" has already been declared', + pos: 18, + watchFiles: [ID_MAIN] + } +}); diff --git a/test/function/samples/ast-validations/redeclare-let-function/main.js b/test/function/samples/ast-validations/redeclare-let-function/main.js new file mode 100644 index 00000000000..23cf6420e84 --- /dev/null +++ b/test/function/samples/ast-validations/redeclare-let-function/main.js @@ -0,0 +1,2 @@ +let foo; +function foo() {} diff --git a/test/function/samples/ast-validations/redeclare-let-nested-var/_config.js b/test/function/samples/ast-validations/redeclare-let-nested-var/_config.js new file mode 100644 index 00000000000..6ae94ac8356 --- /dev/null +++ b/test/function/samples/ast-validations/redeclare-let-nested-var/_config.js @@ -0,0 +1,25 @@ +const path = require('node:path'); +const ID_MAIN = path.join(__dirname, 'main.js'); + +module.exports = defineTest({ + description: 'throws when redeclaring a let binding with a nested var', + error: { + code: 'REDECLARATION_ERROR', + frame: ` + 2: let foo = 'test'; + 3: { + 4: var foo = 'other'; + ^ + 5: } + 6: console.log(foo);`, + id: ID_MAIN, + loc: { + column: 8, + file: ID_MAIN, + line: 4 + }, + message: 'main.js (4:8): Identifier "foo" has already been declared', + pos: 34, + watchFiles: [ID_MAIN] + } +}); diff --git a/test/function/samples/ast-validations/redeclare-let-nested-var/main.js b/test/function/samples/ast-validations/redeclare-let-nested-var/main.js new file mode 100644 index 00000000000..43ef33b70ab --- /dev/null +++ b/test/function/samples/ast-validations/redeclare-let-nested-var/main.js @@ -0,0 +1,7 @@ +{ + let foo = 'test'; + { + var foo = 'other'; + } + console.log(foo); +} diff --git a/test/function/samples/ast-validations/redeclare-nested-var-let/_config.js b/test/function/samples/ast-validations/redeclare-nested-var-let/_config.js new file mode 100644 index 00000000000..afbdf8fd080 --- /dev/null +++ b/test/function/samples/ast-validations/redeclare-nested-var-let/_config.js @@ -0,0 +1,25 @@ +const path = require('node:path'); +const ID_MAIN = path.join(__dirname, 'main.js'); + +module.exports = defineTest({ + description: 'throws when redeclaring a nested var binding with let', + error: { + code: 'REDECLARATION_ERROR', + frame: ` + 3: var foo = 'other'; + 4: } + 5: let foo = 'test'; + ^ + 6: console.log(foo); + 7: }`, + id: ID_MAIN, + loc: { + column: 6, + file: ID_MAIN, + line: 5 + }, + message: 'main.js (5:6): Identifier "foo" has already been declared', + pos: 39, + watchFiles: [ID_MAIN] + } +}); diff --git a/test/function/samples/ast-validations/redeclare-nested-var-let/main.js b/test/function/samples/ast-validations/redeclare-nested-var-let/main.js new file mode 100644 index 00000000000..3f98af0e689 --- /dev/null +++ b/test/function/samples/ast-validations/redeclare-nested-var-let/main.js @@ -0,0 +1,7 @@ +{ + { + var foo = 'other'; + } + let foo = 'test'; + console.log(foo); +} diff --git a/test/function/samples/ast-validations/redeclare-parameter-let/_config.js b/test/function/samples/ast-validations/redeclare-parameter-let/_config.js new file mode 100644 index 00000000000..8b523e282b6 --- /dev/null +++ b/test/function/samples/ast-validations/redeclare-parameter-let/_config.js @@ -0,0 +1,23 @@ +const path = require('node:path'); +const ID_MAIN = path.join(__dirname, 'main.js'); + +module.exports = defineTest({ + description: 'throws when redeclaring the parameter of a function as a let', + error: { + code: 'REDECLARATION_ERROR', + frame: ` + 1: function foo(x) { + 2: let x; // throws + ^ + 3: }`, + id: ID_MAIN, + loc: { + column: 5, + file: ID_MAIN, + line: 2 + }, + message: 'main.js (2:5): Identifier "x" has already been declared', + pos: 23, + watchFiles: [ID_MAIN] + } +}); diff --git a/test/function/samples/ast-validations/redeclare-parameter-let/main.js b/test/function/samples/ast-validations/redeclare-parameter-let/main.js new file mode 100644 index 00000000000..763d09cf014 --- /dev/null +++ b/test/function/samples/ast-validations/redeclare-parameter-let/main.js @@ -0,0 +1,5 @@ +function foo(x) { + let x; // throws +} + +foo(); diff --git a/test/function/samples/ast-validations/redeclare-parameter-var-function/_config.js b/test/function/samples/ast-validations/redeclare-parameter-var-function/_config.js new file mode 100644 index 00000000000..fedae8f877f --- /dev/null +++ b/test/function/samples/ast-validations/redeclare-parameter-var-function/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'allows to redeclare parameters as var or function' +}); diff --git a/test/function/samples/ast-validations/redeclare-parameter-var-function/main.js b/test/function/samples/ast-validations/redeclare-parameter-var-function/main.js new file mode 100644 index 00000000000..daf52319555 --- /dev/null +++ b/test/function/samples/ast-validations/redeclare-parameter-var-function/main.js @@ -0,0 +1,28 @@ +function first(x) { + var x = 2; + assert.ok(x === 2 ? true : false); +} + +function second(x) { + function x() { + return 2; + } + assert.ok(x() === 2 ? true : false); +} + +function third([x]) { + var x = 2; + assert.ok(x === 2 ? true : false); +} + +function fourth([x]) { + function x() { + return 2; + } + assert.ok(x() === 2 ? true : false); +} + +first(1); +second(1); +third([1]); +fourth([1]); diff --git a/test/function/samples/ast-validations/redeclare-top-level-function-function/_config.js b/test/function/samples/ast-validations/redeclare-top-level-function-function/_config.js new file mode 100644 index 00000000000..5c617c24d0b --- /dev/null +++ b/test/function/samples/ast-validations/redeclare-top-level-function-function/_config.js @@ -0,0 +1,22 @@ +const path = require('node:path'); +const ID_MAIN = path.join(__dirname, 'main.js'); + +module.exports = defineTest({ + description: 'throws when redeclaring a top-level function binding as a function', + error: { + code: 'REDECLARATION_ERROR', + frame: ` + 1: function foo() {} + 2: function foo() {} + ^`, + id: ID_MAIN, + loc: { + column: 9, + file: ID_MAIN, + line: 2 + }, + message: 'main.js (2:9): Identifier "foo" has already been declared', + pos: 27, + watchFiles: [ID_MAIN] + } +}); diff --git a/test/function/samples/ast-validations/redeclare-top-level-function-function/main.js b/test/function/samples/ast-validations/redeclare-top-level-function-function/main.js new file mode 100644 index 00000000000..11a6da2a7eb --- /dev/null +++ b/test/function/samples/ast-validations/redeclare-top-level-function-function/main.js @@ -0,0 +1,2 @@ +function foo() {} +function foo() {} diff --git a/test/function/samples/ast-validations/redeclare-top-level-var-function/_config.js b/test/function/samples/ast-validations/redeclare-top-level-var-function/_config.js new file mode 100644 index 00000000000..46f344e65e7 --- /dev/null +++ b/test/function/samples/ast-validations/redeclare-top-level-var-function/_config.js @@ -0,0 +1,22 @@ +const path = require('node:path'); +const ID_MAIN = path.join(__dirname, 'main.js'); + +module.exports = defineTest({ + description: 'throws when redeclaring a top-level var binding as a function', + error: { + code: 'REDECLARATION_ERROR', + frame: ` + 1: var foo; + 2: function foo() {} + ^`, + id: ID_MAIN, + loc: { + column: 9, + file: ID_MAIN, + line: 2 + }, + message: 'main.js (2:9): Identifier "foo" has already been declared', + pos: 18, + watchFiles: [ID_MAIN] + } +}); diff --git a/test/function/samples/ast-validations/redeclare-top-level-var-function/main.js b/test/function/samples/ast-validations/redeclare-top-level-var-function/main.js new file mode 100644 index 00000000000..1403e08b8b0 --- /dev/null +++ b/test/function/samples/ast-validations/redeclare-top-level-var-function/main.js @@ -0,0 +1,2 @@ +var foo; +function foo() {} diff --git a/test/function/samples/ast-validations/redeclare-var-class/_config.js b/test/function/samples/ast-validations/redeclare-var-class/_config.js new file mode 100644 index 00000000000..45c20f9f69b --- /dev/null +++ b/test/function/samples/ast-validations/redeclare-var-class/_config.js @@ -0,0 +1,22 @@ +const path = require('node:path'); +const ID_MAIN = path.join(__dirname, 'main.js'); + +module.exports = defineTest({ + description: 'throws when redeclaring a var binding as a class', + error: { + code: 'REDECLARATION_ERROR', + frame: ` + 1: var foo; + 2: class foo {} + ^`, + id: ID_MAIN, + loc: { + column: 6, + file: ID_MAIN, + line: 2 + }, + message: 'main.js (2:6): Identifier "foo" has already been declared', + pos: 15, + watchFiles: [ID_MAIN] + } +}); diff --git a/test/function/samples/ast-validations/redeclare-var-class/main.js b/test/function/samples/ast-validations/redeclare-var-class/main.js new file mode 100644 index 00000000000..6a803e0278d --- /dev/null +++ b/test/function/samples/ast-validations/redeclare-var-class/main.js @@ -0,0 +1,2 @@ +var foo; +class foo {} diff --git a/test/function/samples/ast-validations/redeclare-var-function/_config.js b/test/function/samples/ast-validations/redeclare-var-function/_config.js new file mode 100644 index 00000000000..9547a3c580b --- /dev/null +++ b/test/function/samples/ast-validations/redeclare-var-function/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'allows to redeclare vars and functions as vars and functions in function scopes' +}); diff --git a/test/function/samples/ast-validations/redeclare-var-function/main.js b/test/function/samples/ast-validations/redeclare-var-function/main.js new file mode 100644 index 00000000000..ac8d372d45a --- /dev/null +++ b/test/function/samples/ast-validations/redeclare-var-function/main.js @@ -0,0 +1,10 @@ +function foo() { + var fn = 1; + function fn() {} + function fn() {} + var fn = 2; + + assert.equal(fn, 2); +} + +foo(); diff --git a/test/function/samples/ast-validations/redeclare-var-parameter-nested/_config.js b/test/function/samples/ast-validations/redeclare-var-parameter-nested/_config.js new file mode 100644 index 00000000000..36a2b6a8273 --- /dev/null +++ b/test/function/samples/ast-validations/redeclare-var-parameter-nested/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'allows to redeclare parameters with multiple nested vars' +}); diff --git a/test/function/samples/ast-validations/redeclare-var-parameter-nested/main.js b/test/function/samples/ast-validations/redeclare-var-parameter-nested/main.js new file mode 100644 index 00000000000..4973c455dac --- /dev/null +++ b/test/function/samples/ast-validations/redeclare-var-parameter-nested/main.js @@ -0,0 +1,21 @@ +export function f(val) { + { + var val = 1; + var val = 2; + } + assert.equal(val, 2); +} +f(0); + +export function g(val) { + { + { + var val = 1; + } + { + var val = 2; + } + } + assert.equal(val, 2); +} +g(0); diff --git a/test/function/samples/ast-validations/update-expression-of-import-fails/_config.js b/test/function/samples/ast-validations/update-expression-of-import-fails/_config.js new file mode 100644 index 00000000000..0be391dd4fc --- /dev/null +++ b/test/function/samples/ast-validations/update-expression-of-import-fails/_config.js @@ -0,0 +1,26 @@ +const path = require('node:path'); +const ID_MAIN = path.join(__dirname, 'main.js'); +const ID_FOO = path.join(__dirname, 'foo.js'); + +module.exports = defineTest({ + description: 'disallows updates to imported bindings', + error: { + code: 'ILLEGAL_REASSIGNMENT', + id: ID_MAIN, + pos: 28, + loc: { + column: 0, + file: ID_MAIN, + line: 3 + }, + frame: ` + 1: import { a } from './foo'; + 2: + 3: a++; + ^`, + watchFiles: [ID_FOO, ID_MAIN], + message: 'main.js (3:0): Illegal reassignment of import "a" in "main.js".' + } +}); + +// test copied from https://github.com/esnext/es6-module-transpiler/tree/master/test/examples/update-expression-of-import-fails diff --git a/test/function/samples/update-expression-of-import-fails/foo.js b/test/function/samples/ast-validations/update-expression-of-import-fails/foo.js similarity index 100% rename from test/function/samples/update-expression-of-import-fails/foo.js rename to test/function/samples/ast-validations/update-expression-of-import-fails/foo.js diff --git a/test/function/samples/update-expression-of-import-fails/main.js b/test/function/samples/ast-validations/update-expression-of-import-fails/main.js similarity index 100% rename from test/function/samples/update-expression-of-import-fails/main.js rename to test/function/samples/ast-validations/update-expression-of-import-fails/main.js diff --git a/test/function/samples/async-function-return/_config.js b/test/function/samples/async-function-return/_config.js new file mode 100644 index 00000000000..1f8ff777575 --- /dev/null +++ b/test/function/samples/async-function-return/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'uses the correct return value for async functions' +}); diff --git a/test/function/samples/async-function-return/main.js b/test/function/samples/async-function-return/main.js new file mode 100644 index 00000000000..c9d4179f287 --- /dev/null +++ b/test/function/samples/async-function-return/main.js @@ -0,0 +1,9 @@ +const foo = async function () { + return false; +}; +const fooResult = foo(); +assert.strictEqual(fooResult ? 'retained' : 'ignored', 'retained'); + +const bar = async () => false; +const barResult = bar(); +assert.strictEqual(barResult ? 'retained' : 'ignored', 'retained'); diff --git a/test/function/samples/avoid-exports-dot-asterisk/_config.js b/test/function/samples/avoid-exports-dot-asterisk/_config.js index 76470f6f02d..c33467238dd 100644 --- a/test/function/samples/avoid-exports-dot-asterisk/_config.js +++ b/test/function/samples/avoid-exports-dot-asterisk/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'avoid return or set module.exports to dot-asterisk style', options: { external: () => true, @@ -6,4 +6,4 @@ module.exports = { format: 'cjs' } } -}; +}); diff --git a/test/function/samples/avoid-variable-be-empty/_config.js b/test/function/samples/avoid-variable-be-empty/_config.js index 9571570ca02..c1458c2e12d 100644 --- a/test/function/samples/avoid-variable-be-empty/_config.js +++ b/test/function/samples/avoid-variable-be-empty/_config.js @@ -1,19 +1,20 @@ -module.exports = { +module.exports = defineTest({ description: 'avoid variable from empty module name be empty', options: { input: '', plugins: [ { - resolveId (importee) { + name: 'test-plugin', + resolveId() { return ''; }, - load (path) { + load() { return 'export default 0;'; - }, + } } ], output: { format: 'cjs' } } -}; +}); diff --git a/test/function/samples/aync-options/_config.js b/test/function/samples/aync-options/_config.js index 31fa811ee27..837b483be0f 100644 --- a/test/function/samples/aync-options/_config.js +++ b/test/function/samples/aync-options/_config.js @@ -1,17 +1,19 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'handles async plugin options', options: { preserveEntrySignatures: false, plugins: [ { + name: 'test-plugin1', options(options) { assert.strictEqual(options.preserveEntrySignatures, false); return Promise.resolve({ ...options, preserveEntrySignatures: 'strict' }); } }, { + name: 'test-plugin2', options(options) { assert.strictEqual(options.preserveEntrySignatures, 'strict'); return Promise.resolve(null); @@ -22,4 +24,4 @@ module.exports = { exports(exports) { assert.strictEqual(exports.foo, 1); } -}; +}); diff --git a/test/function/samples/banner-and-footer/_config.js b/test/function/samples/banner-and-footer/_config.js index 40d3b05b3c8..69ad8b91fa1 100644 --- a/test/function/samples/banner-and-footer/_config.js +++ b/test/function/samples/banner-and-footer/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'adds a banner/footer', options: { output: { @@ -7,18 +7,21 @@ module.exports = { }, plugins: [ { + name: 'test-plugin1', banner: '/* first banner */', footer() { return '/* first footer */'; } }, { + name: 'test-plugin2', banner() { return '/* second banner */'; }, footer: '/* second footer */' }, { + name: 'test-plugin3', banner() { return Promise.reject(new Error('Could not generate banner.')); }, @@ -29,6 +32,7 @@ module.exports = { generateError: { code: 'ADDON_ERROR', message: - 'Could not retrieve banner. Check configuration of plugin at position 3.\n\tError Message: Could not generate banner.' + 'Could not retrieve "banner". Check configuration of plugin "test-plugin3".\n' + + '\tError Message: Could not generate banner.' } -}; +}); diff --git a/test/function/samples/bindings/_config.js b/test/function/samples/bindings/_config.js index 963674adbca..33615aaf9d8 100644 --- a/test/function/samples/bindings/_config.js +++ b/test/function/samples/bindings/_config.js @@ -1,5 +1,5 @@ -module.exports = { +module.exports = defineTest({ description: 'maintains live bindings' -}; +}); // test copied from https://github.com/esnext/es6-module-transpiler/tree/master/test/examples/bindings diff --git a/test/function/samples/braceless-arrow-function-returning-function/_config.js b/test/function/samples/braceless-arrow-function-returning-function/_config.js index 03ddb4d4951..6b96e32c1b3 100644 --- a/test/function/samples/braceless-arrow-function-returning-function/_config.js +++ b/test/function/samples/braceless-arrow-function-returning-function/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'arrow function without braces returning a function (#1032)' -}; +}); diff --git a/test/function/samples/break-label/_config.js b/test/function/samples/break-label/_config.js index aa7779caafc..d6d5bb4a607 100644 --- a/test/function/samples/break-label/_config.js +++ b/test/function/samples/break-label/_config.js @@ -1,8 +1,8 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'do not deconflict break label (#2773)', exports(exports) { assert.deepStrictEqual(exports, { value: 'original', n: 1 }); } -}; +}); diff --git a/test/function/samples/build-promise-chain/_config.js b/test/function/samples/build-promise-chain/_config.js index 080c0fd694e..1bd9091454f 100644 --- a/test/function/samples/build-promise-chain/_config.js +++ b/test/function/samples/build-promise-chain/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'Does not fail when iteratively chaining promises' -}; +}); diff --git a/test/function/samples/builtin-prototypes/argument-side-effects/_config.js b/test/function/samples/builtin-prototypes/argument-side-effects/_config.js index 5e77f83b5cc..7c090771b85 100644 --- a/test/function/samples/builtin-prototypes/argument-side-effects/_config.js +++ b/test/function/samples/builtin-prototypes/argument-side-effects/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'detects side-effects in chained string method arguments' -}; +}); diff --git a/test/function/samples/builtin-prototypes/truthiness/_config.js b/test/function/samples/builtin-prototypes/truthiness/_config.js index 9c57e067add..486d00cfbbc 100644 --- a/test/function/samples/builtin-prototypes/truthiness/_config.js +++ b/test/function/samples/builtin-prototypes/truthiness/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'regards builtin methods as truthy in objects' -}; +}); diff --git a/test/function/samples/bundle-facade-order/_config.js b/test/function/samples/bundle-facade-order/_config.js index b202a1b5733..2c45be4d5d7 100644 --- a/test/function/samples/bundle-facade-order/_config.js +++ b/test/function/samples/bundle-facade-order/_config.js @@ -1,6 +1,6 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'respects the order of entry points when there are additional facades for chunks', options: { input: { @@ -8,20 +8,23 @@ module.exports = { 'main-alias': 'main', other: 'other' }, - plugins: { - generateBundle(options, bundle) { - assert.deepStrictEqual( - Object.keys(bundle).map(id => [id, bundle[id].code]), - [ - ['main.js', "'use strict';\n\nvar main = 'main1';\n\nmodule.exports = main;\n"], - ['other.js', "'use strict';\n\nvar other = 'main2';\n\nmodule.exports = other;\n"], + plugins: [ + { + name: 'test-plugin', + generateBundle(options, bundle) { + assert.deepStrictEqual( + Object.keys(bundle).map(id => [id, bundle[id].code]), [ - 'main-alias.js', - "'use strict';\n\nvar main = require('./main.js');\n\n\n\nmodule.exports = main;\n" + ['main.js', "'use strict';\n\nvar main = 'main1';\n\nmodule.exports = main;\n"], + ['other.js', "'use strict';\n\nvar other = 'main2';\n\nmodule.exports = other;\n"], + [ + 'main-alias.js', + "'use strict';\n\nvar main = require('./main.js');\n\n\n\nmodule.exports = main;\n" + ] ] - ] - ); + ); + } } - } + ] } -}; +}); diff --git a/test/function/samples/call-external-function/_config.js b/test/function/samples/call-external-function/_config.js index 5e2f554e13d..173be565ecc 100644 --- a/test/function/samples/call-external-function/_config.js +++ b/test/function/samples/call-external-function/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'handles call of aliased external function (#957)', warnings() {}, context: { @@ -8,4 +8,4 @@ module.exports = { } } } -}; +}); diff --git a/test/function/samples/call-marked-pure-with-plugin-parse-ast/_config.js b/test/function/samples/call-marked-pure-with-plugin-parse-ast/_config.js index 1b24a95fa58..d736faba6a3 100644 --- a/test/function/samples/call-marked-pure-with-plugin-parse-ast/_config.js +++ b/test/function/samples/call-marked-pure-with-plugin-parse-ast/_config.js @@ -1,19 +1,18 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { - description: 'external function calls marked with pure comment do not have effects and should be removed even if parsed by PluginContext.parse method', +module.exports = defineTest({ + description: + 'external function calls marked with pure comment do not have effects and should be removed even if parsed by PluginContext.parse method', options: { external: ['socks'], - plugins:[{ - transform(code, _id) { - const comments = []; - const ast = this.parse(code, {onComment: comments}); - if (comments.length != 5 || comments.some(({value}) => !value.includes('PURE'))) { - throw new Error('failed to get comments'); + plugins: [ + { + transform(code) { + const ast = this.parse(code); + return { ast, code, map: null }; } - return {ast, code, map: null}; - }, - }], + } + ] }, context: { require(id) { @@ -27,4 +26,4 @@ module.exports = { code(code) { assert.ok(code.search(/socks\(\)/) === -1); } -}; +}); diff --git a/test/function/samples/call-marked-pure/_config.js b/test/function/samples/call-marked-pure/_config.js index df52a595dcf..577284c52d3 100644 --- a/test/function/samples/call-marked-pure/_config.js +++ b/test/function/samples/call-marked-pure/_config.js @@ -1,6 +1,6 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'external function calls marked with pure comment do not have effects', options: { external: ['socks'] @@ -17,4 +17,4 @@ module.exports = { code(code) { assert.ok(code.search(/socks\(\)/) === -1); } -}; +}); diff --git a/test/function/samples/call-non-function-default-exports/_config.js b/test/function/samples/call-non-function-default-exports/_config.js index e03afa4b73a..0213570792c 100644 --- a/test/function/samples/call-non-function-default-exports/_config.js +++ b/test/function/samples/call-non-function-default-exports/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'calls non-function default exports' -}; +}); diff --git a/test/function/samples/can-import-self-treeshake/_config.js b/test/function/samples/can-import-self-treeshake/_config.js index 7873b58b34a..6ab879fbb27 100644 --- a/test/function/samples/can-import-self-treeshake/_config.js +++ b/test/function/samples/can-import-self-treeshake/_config.js @@ -1,16 +1,18 @@ -module.exports = { +const path = require('node:path'); +const ID_LIB = path.join(__dirname, 'lib.js'); + +module.exports = defineTest({ description: 'direct self import', warnings: [ { code: 'CIRCULAR_DEPENDENCY', - cycle: ['lib.js', 'lib.js'], - importer: 'lib.js', + ids: [ID_LIB, ID_LIB], message: 'Circular dependency: lib.js -> lib.js' }, { - chunkName: 'main', code: 'EMPTY_BUNDLE', - message: `Generated an empty chunk: "main"` + message: 'Generated an empty chunk: "main".', + names: ['main'] } ] -}; +}); diff --git a/test/function/samples/can-import-self/_config.js b/test/function/samples/can-import-self/_config.js index f49dfc06ef3..1cdda707710 100644 --- a/test/function/samples/can-import-self/_config.js +++ b/test/function/samples/can-import-self/_config.js @@ -1,6 +1,8 @@ -const assert = require('assert'); +const assert = require('node:assert'); +const path = require('node:path'); +const ID_LIB = path.join(__dirname, 'lib.js'); -module.exports = { +module.exports = defineTest({ description: 'a module importing its own bindings', exports(exports) { assert.equal(exports.result, 4); @@ -8,9 +10,8 @@ module.exports = { warnings: [ { code: 'CIRCULAR_DEPENDENCY', - cycle: ['lib.js', 'lib.js'], - importer: 'lib.js', + ids: [ID_LIB, ID_LIB], message: 'Circular dependency: lib.js -> lib.js' } ] -}; +}); diff --git a/test/function/samples/cannot-call-external-namespace/_config.js b/test/function/samples/cannot-call-external-namespace/_config.js index 20b6a35ada5..8b8fbed6732 100644 --- a/test/function/samples/cannot-call-external-namespace/_config.js +++ b/test/function/samples/cannot-call-external-namespace/_config.js @@ -1,14 +1,14 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'warns if code calls an external namespace', options: { external: ['fs'] }, warnings(warnings) { assert.deepStrictEqual(warnings.map(String), [ - "main.js (4:1) Cannot call a namespace ('foo')", - "main.js (8:1) Cannot call a namespace ('foo')" + 'main.js (4:1): Cannot call a namespace ("foo").', + 'main.js (8:1): Cannot call a namespace ("foo").' ]); } -}; +}); diff --git a/test/function/samples/cannot-call-internal-namespace/_config.js b/test/function/samples/cannot-call-internal-namespace/_config.js index b61157e6158..30a32c1c895 100644 --- a/test/function/samples/cannot-call-internal-namespace/_config.js +++ b/test/function/samples/cannot-call-internal-namespace/_config.js @@ -1,11 +1,11 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'warns if code calls an internal namespace', warnings(warnings) { assert.deepStrictEqual(warnings.map(String), [ - "main.js (4:1) Cannot call a namespace ('foo')", - "main.js (8:1) Cannot call a namespace ('foo')" + 'main.js (4:1): Cannot call a namespace ("foo").', + 'main.js (8:1): Cannot call a namespace ("foo").' ]); } -}; +}); diff --git a/test/function/samples/cannot-resolve-sourcemap-warning/_config.js b/test/function/samples/cannot-resolve-sourcemap-warning/_config.js index a803b5b72e8..0306bd7771c 100644 --- a/test/function/samples/cannot-resolve-sourcemap-warning/_config.js +++ b/test/function/samples/cannot-resolve-sourcemap-warning/_config.js @@ -1,18 +1,23 @@ -const path = require('path'); +const path = require('node:path'); const ID_MAIN = path.join(__dirname, 'main.js'); -module.exports = { +module.exports = defineTest({ description: 'handles when a sourcemap cannot be resolved in a warning', options: { - plugins: { - name: 'test-plugin', - transform() { - return { code: 'export default this', map: { mappings: 'X' } }; + plugins: [ + { + name: 'test-plugin', + transform() { + return { code: 'export default this', map: { mappings: '' } }; + } } - } + ] }, warnings: [ { + cause: { + message: "Can't resolve original location of error." + }, code: 'SOURCEMAP_ERROR', id: ID_MAIN, loc: { @@ -21,7 +26,7 @@ module.exports = { line: 1 }, message: - "Error when using sourcemap for reporting an error: Can't resolve original location of error.", + "main.js (1:15): Error when using sourcemap for reporting an error: Can't resolve original location of error.", pos: 15 }, { @@ -37,9 +42,9 @@ module.exports = { line: 1 }, message: - "The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten", + "main.js (1:15): The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten", pos: 15, - url: 'https://rollupjs.org/guide/en/#error-this-is-undefined' + url: 'https://rollupjs.org/troubleshooting/#error-this-is-undefined' } ] -}; +}); diff --git a/test/function/samples/catch-block-scope/_config.js b/test/function/samples/catch-block-scope/_config.js new file mode 100644 index 00000000000..aa81898ae7a --- /dev/null +++ b/test/function/samples/catch-block-scope/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'uses correct scope in catch blocks' +}); diff --git a/test/function/samples/catch-block-scope/main.js b/test/function/samples/catch-block-scope/main.js new file mode 100644 index 00000000000..e5f44afedc3 --- /dev/null +++ b/test/function/samples/catch-block-scope/main.js @@ -0,0 +1,17 @@ +try { + throw 'FAIL'; +} catch (t) { + var t = 'PASS'; + assert.strictEqual(t, 'PASS'); +} + +let a = 1; +let def = 'PASS2'; +try { + throw ['FAIL2', 'PASS1']; +} catch ({ [a]: b, 3: d = def }) { + let a = 0, + def = 'FAIL3'; + assert.strictEqual(b, 'PASS1'); + assert.strictEqual(d, 'PASS2'); +} diff --git a/test/function/samples/catch-dynamic-import-failure/_config.js b/test/function/samples/catch-dynamic-import-failure/_config.js index 98030f30575..bb2bfb4c966 100644 --- a/test/function/samples/catch-dynamic-import-failure/_config.js +++ b/test/function/samples/catch-dynamic-import-failure/_config.js @@ -1,6 +1,6 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'allows catching failed dynamic imports', options: { input: ['main', 'exists-default'], @@ -10,8 +10,8 @@ module.exports = { return exports.then(result => { assert.strictEqual(result[0].message, 'exists-named'); assert.strictEqual(result[1].message, 'exists-default'); - const expectedError = "Cannot find module 'does-not-exist'"; + const expectedError = "Cannot find package 'does-not-exist'"; assert.strictEqual(result[2].message.slice(0, expectedError.length), expectedError); }); } -}; +}); diff --git a/test/function/samples/catch-rust-panic-parse/_config.js b/test/function/samples/catch-rust-panic-parse/_config.js new file mode 100644 index 00000000000..61204017d0e --- /dev/null +++ b/test/function/samples/catch-rust-panic-parse/_config.js @@ -0,0 +1,21 @@ +module.exports = defineTest({ + description: 'Catch Rust panics and then throw them in Node when using this.parse', + options: { + plugins: [ + { + name: 'test', + buildStart() { + this.parse(`const foo = { bar = baz };`); + } + } + ] + }, + error: { + code: 'PLUGIN_ERROR', + hook: 'buildStart', + message: 'not implemented: Cannot convert Prop::Assign', + plugin: 'test', + pluginCode: 'PARSE_ERROR', + pos: undefined + } +}); diff --git a/test/function/samples/catch-rust-panic-parse/main.js b/test/function/samples/catch-rust-panic-parse/main.js new file mode 100644 index 00000000000..f8289c71bb9 --- /dev/null +++ b/test/function/samples/catch-rust-panic-parse/main.js @@ -0,0 +1 @@ +assert.ok(true) diff --git a/test/function/samples/catch-rust-panic/_config.js b/test/function/samples/catch-rust-panic/_config.js new file mode 100644 index 00000000000..d729855c34d --- /dev/null +++ b/test/function/samples/catch-rust-panic/_config.js @@ -0,0 +1,17 @@ +const path = require('node:path'); +const MAIN_ID = path.resolve(__dirname, './main.js'); + +module.exports = defineTest({ + description: 'Catch Rust panics and then throw them in Node', + error: { + cause: { + code: 'PARSE_ERROR', + message: 'not implemented: Cannot convert Prop::Assign', + pos: undefined + }, + code: 'PARSE_ERROR', + id: MAIN_ID, + message: 'not implemented: Cannot convert Prop::Assign', + watchFiles: [MAIN_ID] + } +}); diff --git a/test/function/samples/catch-rust-panic/main.js b/test/function/samples/catch-rust-panic/main.js new file mode 100644 index 00000000000..7c907819fd3 --- /dev/null +++ b/test/function/samples/catch-rust-panic/main.js @@ -0,0 +1,3 @@ +const foo = { + bar = baz +}; diff --git a/test/function/samples/catch-scope-deconflicting/_config.js b/test/function/samples/catch-scope-deconflicting/_config.js new file mode 100644 index 00000000000..6a6ab3cd6ee --- /dev/null +++ b/test/function/samples/catch-scope-deconflicting/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'deconflicts catch scope parameters correctly' +}); diff --git a/test/function/samples/catch-scope-deconflicting/dep.js b/test/function/samples/catch-scope-deconflicting/dep.js new file mode 100644 index 00000000000..37828c3c69f --- /dev/null +++ b/test/function/samples/catch-scope-deconflicting/dep.js @@ -0,0 +1,8 @@ +error = 3; +try { + throw new Error('failed'); +} catch (error) { + var error = 4; + assert.equal(error, 4); +} +assert.equal(error, 3); diff --git a/test/function/samples/catch-scope-deconflicting/main.js b/test/function/samples/catch-scope-deconflicting/main.js new file mode 100644 index 00000000000..4591297e356 --- /dev/null +++ b/test/function/samples/catch-scope-deconflicting/main.js @@ -0,0 +1,10 @@ +import './dep.js'; + +error = 1; +try { + throw new Error('failed'); +} catch (error) { + var error = 2; + assert.equal(error, 2); +} +assert.equal(error, 1); diff --git a/test/function/samples/catch-scope-default/_config.js b/test/function/samples/catch-scope-default/_config.js new file mode 100644 index 00000000000..7e8ac2a80a8 --- /dev/null +++ b/test/function/samples/catch-scope-default/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'associates default values in catch parameters with the outer scope' +}); diff --git a/test/function/samples/catch-scope-default/main.js b/test/function/samples/catch-scope-default/main.js new file mode 100644 index 00000000000..c18cf8a4709 --- /dev/null +++ b/test/function/samples/catch-scope-default/main.js @@ -0,0 +1,7 @@ +var value = 'PASS'; +try { + throw new Error(); +} catch ({ code = value }) { + const value = 'FAIL'; + assert.equal(code, 'PASS'); +} diff --git a/test/function/samples/catch-scope-nested-deconflicting/_config.js b/test/function/samples/catch-scope-nested-deconflicting/_config.js new file mode 100644 index 00000000000..1330efdeaff --- /dev/null +++ b/test/function/samples/catch-scope-nested-deconflicting/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'deconflicts nested catch scope parameters correctly' +}); diff --git a/test/function/samples/catch-scope-nested-deconflicting/dep.js b/test/function/samples/catch-scope-nested-deconflicting/dep.js new file mode 100644 index 00000000000..1e42f951702 --- /dev/null +++ b/test/function/samples/catch-scope-nested-deconflicting/dep.js @@ -0,0 +1,12 @@ +try { + throw new Error('1'); +} catch (e) { + try { + throw new Error('2'); + } catch (e) { + var e = 'e'; + assert.equal(e, 'e'); + } + assert.equal(e.message, '1'); +} +assert.equal(e, undefined); diff --git a/test/function/samples/catch-scope-nested-deconflicting/main.js b/test/function/samples/catch-scope-nested-deconflicting/main.js new file mode 100644 index 00000000000..25d321351a4 --- /dev/null +++ b/test/function/samples/catch-scope-nested-deconflicting/main.js @@ -0,0 +1,14 @@ +import './dep.js'; + +try { + throw new Error('1'); +} catch (e) { + try { + throw new Error('2'); + } catch (e) { + var e = 'e'; + assert.equal(e, 'e'); + } + assert.equal(e.message, '1'); +} +assert.equal(e, undefined); diff --git a/test/function/samples/catch-scope-shadowing/_config.js b/test/function/samples/catch-scope-shadowing/_config.js new file mode 100644 index 00000000000..4d19aa4f1f4 --- /dev/null +++ b/test/function/samples/catch-scope-shadowing/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'correctly associates shadowed variables in catch scopes' +}); diff --git a/test/function/samples/catch-scope-shadowing/main.js b/test/function/samples/catch-scope-shadowing/main.js new file mode 100644 index 00000000000..5cc45ec7ff6 --- /dev/null +++ b/test/function/samples/catch-scope-shadowing/main.js @@ -0,0 +1,23 @@ +var e = 'failed1', + x = 'value'; + +(function () { + try { + // empty + } catch (e) { + var e = 'failed2'; + } + + assert.strictEqual(e, undefined); + assert.strictEqual(x, undefined); + x = 'failed3'; + return; + + try { + not_reached(); + } catch (x) { + var x = 'failed4'; + } +})(); + +assert.strictEqual(x, 'value'); diff --git a/test/function/samples/catch-scope-shadowing2/_config.js b/test/function/samples/catch-scope-shadowing2/_config.js new file mode 100644 index 00000000000..3e1727fe045 --- /dev/null +++ b/test/function/samples/catch-scope-shadowing2/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'handles nested hoisted variables in catch scope' +}); diff --git a/test/function/samples/catch-scope-shadowing2/main.js b/test/function/samples/catch-scope-shadowing2/main.js new file mode 100644 index 00000000000..9c8ad85cf90 --- /dev/null +++ b/test/function/samples/catch-scope-shadowing2/main.js @@ -0,0 +1,10 @@ +try { + throw new Error(); +} catch (e) { + var e = 1; + { + var e = 2; + } + assert.equal(e, 2); +} +assert.equal(e, undefined); diff --git a/test/function/samples/catch-scope-variables/_config.js b/test/function/samples/catch-scope-variables/_config.js index b902e7168d5..a18b60e2583 100644 --- a/test/function/samples/catch-scope-variables/_config.js +++ b/test/function/samples/catch-scope-variables/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'handles variable declarations in catch scopes' -}; +}); diff --git a/test/function/samples/chained-mutable-array-methods/_config.js b/test/function/samples/chained-mutable-array-methods/_config.js index 5158171bc6b..8d79493c4b8 100644 --- a/test/function/samples/chained-mutable-array-methods/_config.js +++ b/test/function/samples/chained-mutable-array-methods/_config.js @@ -1,9 +1,9 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'recognizes side-effects when applying mutable array methods to chained array methods (#3555)', exports(exports) { assert.deepStrictEqual(exports.a, ['PASS']); } -}; +}); diff --git a/test/function/samples/check-exports-exportedBindings-as-a-supplementary-test/_config.js b/test/function/samples/check-exports-exportedBindings-as-a-supplementary-test/_config.js new file mode 100644 index 00000000000..dbfddc29c42 --- /dev/null +++ b/test/function/samples/check-exports-exportedBindings-as-a-supplementary-test/_config.js @@ -0,0 +1,36 @@ +const assert = require('node:assert'); +const path = require('node:path'); + +const ID_MAIN = path.join(__dirname, 'main.js'); +const ID_MODULE = path.join(__dirname, 'module.js'); +const ID_MODULE_2 = path.join(__dirname, 'module2.js'); + +const expectedResult = { + [ID_MAIN]: { + exports: ['moduleAlias', '*'], + exportedBindings: { '.': [], './module.js': ['moduleAlias', '*'] } + }, + [ID_MODULE]: { + exports: ['default', 'module', '*'], + exportedBindings: { '.': ['default', 'module'], './module2.js': ['*'] } + }, + [ID_MODULE_2]: { + exports: ['module2'], + exportedBindings: { '.': ['module2'] } + } +}; + +module.exports = defineTest({ + description: 'check exports and exportedBindings in moduleParsed as a supplementary test', + options: { + plugins: [ + { + name: 'test-plugin', + moduleParsed(moduleInfo) { + const { exports, exportedBindings, id } = moduleInfo; + assert.deepStrictEqual({ exports, exportedBindings }, expectedResult[id]); + } + } + ] + } +}); diff --git a/test/function/samples/check-exports-exportedBindings-as-a-supplementary-test/main.js b/test/function/samples/check-exports-exportedBindings-as-a-supplementary-test/main.js new file mode 100644 index 00000000000..7074f166f70 --- /dev/null +++ b/test/function/samples/check-exports-exportedBindings-as-a-supplementary-test/main.js @@ -0,0 +1,3 @@ +export * from './module.js'; +export { module as moduleAlias } from './module.js'; +assert.ok(true); diff --git a/test/function/samples/check-exports-exportedBindings-as-a-supplementary-test/module.js b/test/function/samples/check-exports-exportedBindings-as-a-supplementary-test/module.js new file mode 100644 index 00000000000..c2c66575c62 --- /dev/null +++ b/test/function/samples/check-exports-exportedBindings-as-a-supplementary-test/module.js @@ -0,0 +1,3 @@ +export * from './module2.js'; +export default 1; +export const module = 1; diff --git a/test/function/samples/check-exports-exportedBindings-as-a-supplementary-test/module2.js b/test/function/samples/check-exports-exportedBindings-as-a-supplementary-test/module2.js new file mode 100644 index 00000000000..e77bbfca10b --- /dev/null +++ b/test/function/samples/check-exports-exportedBindings-as-a-supplementary-test/module2.js @@ -0,0 +1 @@ +export const module2 = 1; diff --git a/test/function/samples/check-resolve-for-entry/_config.js b/test/function/samples/check-resolve-for-entry/_config.js index 88ef2dd83be..5fa4ed9deb9 100644 --- a/test/function/samples/check-resolve-for-entry/_config.js +++ b/test/function/samples/check-resolve-for-entry/_config.js @@ -1,10 +1,10 @@ -module.exports = { +module.exports = defineTest({ description: 'checks that entry is resolved', options: { input: 'not/a/path/that/actually/really/exists' }, error: { code: 'UNRESOLVED_ENTRY', - message: 'Could not resolve entry module (not/a/path/that/actually/really/exists).' + message: 'Could not resolve entry module "not/a/path/that/actually/really/exists".' } -}; +}); diff --git a/test/function/samples/chunk-external-dependency-execution-order/_config.js b/test/function/samples/chunk-external-dependency-execution-order/_config.js index 2fde7185af1..47ba9b5d48c 100644 --- a/test/function/samples/chunk-external-dependency-execution-order/_config.js +++ b/test/function/samples/chunk-external-dependency-execution-order/_config.js @@ -1,7 +1,7 @@ -const assert = require('assert'); +const assert = require('node:assert'); const executionOrder = []; -module.exports = { +module.exports = defineTest({ description: 'Uses correct execution order when several modules in a chunk have external dependencies', context: { @@ -17,4 +17,4 @@ module.exports = { exports() { assert.deepStrictEqual(executionOrder, ['external-first', 'external-second', 'dep', 'main']); } -}; +}); diff --git a/test/function/samples/chunking-duplicate-reexport/_config.js b/test/function/samples/chunking-duplicate-reexport/_config.js index 811122ba995..2dc5fbac568 100644 --- a/test/function/samples/chunking-duplicate-reexport/_config.js +++ b/test/function/samples/chunking-duplicate-reexport/_config.js @@ -1,8 +1,13 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'handles duplicate reexports when using dynamic imports', exports(exports) { - return exports.then(result => assert.deepStrictEqual(result, [{ answer: 42 }, { answer: 42 }])); + return exports.then(result => + assert.deepStrictEqual(result, [ + { __proto__: null, answer: 42 }, + { __proto__: null, answer: 42 } + ]) + ); } -}; +}); diff --git a/test/function/samples/circular-default-exports/_config.js b/test/function/samples/circular-default-exports/_config.js index 37b93142200..6d418f49b45 100644 --- a/test/function/samples/circular-default-exports/_config.js +++ b/test/function/samples/circular-default-exports/_config.js @@ -1,11 +1,13 @@ -module.exports = { +const path = require('node:path'); +const ID_MAIN = path.join(__dirname, 'main.js'); + +module.exports = defineTest({ description: 'handles circular default exports', warnings: [ { code: 'CIRCULAR_DEPENDENCY', - cycle: ['main.js', 'main.js'], - importer: 'main.js', + ids: [ID_MAIN, ID_MAIN], message: 'Circular dependency: main.js -> main.js' } ] -}; +}); diff --git a/test/function/samples/circular-missed-reexports-2/_config.js b/test/function/samples/circular-missed-reexports-2/_config.js index acd6155794c..7aba287f3aa 100644 --- a/test/function/samples/circular-missed-reexports-2/_config.js +++ b/test/function/samples/circular-missed-reexports-2/_config.js @@ -1,20 +1,19 @@ -const assert = require('assert'); -const path = require('path'); +const assert = require('node:assert'); +const path = require('node:path'); +const ID_MAIN = path.join(__dirname, 'main.js'); +const ID_DEP1 = path.join(__dirname, 'dep1.js'); +const ID_DEP2 = path.join(__dirname, 'dep2.js'); -module.exports = { +module.exports = defineTest({ description: 'handles circular reexports', exports(exports) { assert.strictEqual(exports.exists, 42); }, error: { code: 'CIRCULAR_REEXPORT', - id: path.join(__dirname, 'dep1.js'), + exporter: ID_DEP1, message: - '"doesNotExist" cannot be exported from dep1.js as it is a reexport that references itself.', - watchFiles: [ - path.join(__dirname, 'main.js'), - path.join(__dirname, 'dep1.js'), - path.join(__dirname, 'dep2.js') - ] + '"doesNotExist" cannot be exported from "dep1.js" as it is a reexport that references itself.', + watchFiles: [ID_DEP1, ID_DEP2, ID_MAIN] } -}; +}); diff --git a/test/function/samples/circular-missed-reexports/_config.js b/test/function/samples/circular-missed-reexports/_config.js index 3e576566bca..3220286c9aa 100644 --- a/test/function/samples/circular-missed-reexports/_config.js +++ b/test/function/samples/circular-missed-reexports/_config.js @@ -1,10 +1,11 @@ -const assert = require('assert'); -const path = require('path'); +const assert = require('node:assert'); +const path = require('node:path'); const ID_MAIN = path.join(__dirname, 'main.js'); const ID_DEP1 = path.join(__dirname, 'dep1.js'); +const ID_DEP2 = path.join(__dirname, 'dep2.js'); -module.exports = { +module.exports = defineTest({ description: 'handles circular reexports', exports(exports) { assert.strictEqual(exports.exists, 42); @@ -12,22 +13,21 @@ module.exports = { warnings: [ { code: 'CIRCULAR_DEPENDENCY', - cycle: ['dep1.js', 'dep2.js', 'dep1.js'], - importer: 'dep1.js', + ids: [ID_DEP1, ID_DEP2, ID_DEP1], message: 'Circular dependency: dep1.js -> dep2.js -> dep1.js' }, { code: 'CIRCULAR_DEPENDENCY', - cycle: ['dep1.js', 'dep1.js'], - importer: 'dep1.js', + ids: [ID_DEP1, ID_DEP1], message: 'Circular dependency: dep1.js -> dep1.js' }, { - code: 'NON_EXISTENT_EXPORT', - message: "Non-existent export 'doesNotExist' is imported from dep1.js", - name: 'doesNotExist', - source: ID_DEP1, + binding: 'doesNotExist', + code: 'MISSING_EXPORT', id: ID_MAIN, + message: + 'main.js (1:17): "doesNotExist" is not exported by "dep1.js", imported by "main.js".', + exporter: ID_DEP1, pos: 17, loc: { file: ID_MAIN, @@ -37,7 +37,16 @@ module.exports = { frame: ` 1: import { exists, doesNotExist } from './dep1.js'; ^ -2: export { exists };` +2: export { exists };`, + url: 'https://rollupjs.org/troubleshooting/#error-name-is-not-exported-by-module' + }, + { + code: 'CYCLIC_CROSS_CHUNK_REEXPORT', + exporter: ID_DEP1, + id: ID_MAIN, + message: + 'Export "exists" of module "dep1.js" was reexported through module "dep2.js" while both modules are dependencies of each other and will end up in different chunks by current Rollup settings. This scenario is not well supported at the moment as it will produce a circular dependency between chunks and will likely lead to broken execution order.\nEither change the import in "main.js" to point directly to the exporting module or reconfigure "output.manualChunks" to ensure these modules end up in the same chunk.', + reexporter: ID_DEP2 } ] -}; +}); diff --git a/test/function/samples/circular-namespace-reexport-manual-chunks/_config.js b/test/function/samples/circular-namespace-reexport-manual-chunks/_config.js new file mode 100644 index 00000000000..b3b72ba8471 --- /dev/null +++ b/test/function/samples/circular-namespace-reexport-manual-chunks/_config.js @@ -0,0 +1,73 @@ +const path = require('node:path'); + +const ID_INDEX = path.join(__dirname, 'index.js'); +const ID_TYPES = path.join(__dirname, 'types.js'); +const ID_FORMATTERS = path.join(__dirname, 'formatters.js'); +const ID_MAIN = path.join(__dirname, 'main.js'); + +module.exports = defineTest({ + description: + 'correctly handles namespace reexports with circular dependencies when using manual chunks', + options: { + output: { + manualChunks(id) { + return path.basename(id); + } + } + }, + warnings: [ + { + code: 'CIRCULAR_CHUNK', + ids: ['formatters.js', 'types.js', 'formatters.js'], + message: + 'Circular chunk: formatters.js -> types.js -> formatters.js. Please adjust the manual chunk logic for these chunks.' + }, + { + code: 'CIRCULAR_DEPENDENCY', + ids: [ID_INDEX, ID_TYPES, ID_INDEX], + message: 'Circular dependency: index.js -> types.js -> index.js' + }, + { + code: 'CIRCULAR_DEPENDENCY', + ids: [ID_INDEX, ID_FORMATTERS, ID_INDEX], + message: 'Circular dependency: index.js -> formatters.js -> index.js' + }, + { + code: 'CYCLIC_CROSS_CHUNK_REEXPORT', + exporter: ID_TYPES, + id: ID_FORMATTERS, + message: + 'Export "LANGUAGES" of module "types.js" was reexported through module "index.js" while both modules are dependencies of each other and will end up in different chunks by current Rollup settings. This scenario is not well supported at the moment as it will produce a circular dependency between chunks and will likely lead to broken execution order.\nEither change the import in "formatters.js" to point directly to the exporting module or reconfigure "output.manualChunks" to ensure these modules end up in the same chunk.', + reexporter: ID_INDEX + }, + { + code: 'CYCLIC_CROSS_CHUNK_REEXPORT', + exporter: ID_FORMATTERS, + id: ID_MAIN, + message: + 'Export "*" of module "formatters.js" was reexported through module "index.js" while both modules are dependencies of each other and will end up in different chunks by current Rollup settings. This scenario is not well supported at the moment as it will produce a circular dependency between chunks and will likely lead to broken execution order.\nEither change the import in "main.js" to point directly to the exporting module or reconfigure "output.manualChunks" to ensure these modules end up in the same chunk.', + reexporter: ID_INDEX + }, + { + code: 'CYCLIC_CROSS_CHUNK_REEXPORT', + exporter: ID_FORMATTERS, + id: ID_MAIN, + message: + 'Export "*" of module "formatters.js" was reexported through module "index.js" while both modules are dependencies of each other and will end up in different chunks by current Rollup settings. This scenario is not well supported at the moment as it will produce a circular dependency between chunks and will likely lead to broken execution order.\nEither change the import in "main.js" to point directly to the exporting module or reconfigure "output.manualChunks" to ensure these modules end up in the same chunk.', + reexporter: ID_INDEX + }, + { + code: 'CYCLIC_CROSS_CHUNK_REEXPORT', + exporter: ID_FORMATTERS, + id: ID_TYPES, + message: + 'Export "*" of module "formatters.js" was reexported through module "index.js" while both modules are dependencies of each other and will end up in different chunks by current Rollup settings. This scenario is not well supported at the moment as it will produce a circular dependency between chunks and will likely lead to broken execution order.\nEither change the import in "types.js" to point directly to the exporting module or reconfigure "output.manualChunks" to ensure these modules end up in the same chunk.', + reexporter: ID_INDEX + }, + { + code: 'EMPTY_BUNDLE', + message: 'Generated an empty chunk: "index.js".', + names: ['index.js'] + } + ] +}); diff --git a/test/function/samples/circular-namespace-reexport-manual-chunks/formatters.js b/test/function/samples/circular-namespace-reexport-manual-chunks/formatters.js new file mode 100644 index 00000000000..202cbf4161d --- /dev/null +++ b/test/function/samples/circular-namespace-reexport-manual-chunks/formatters.js @@ -0,0 +1,3 @@ +import { LANGUAGES } from './index.js'; + +export const format = () => LANGUAGES; diff --git a/test/function/samples/circular-namespace-reexport-manual-chunks/index.js b/test/function/samples/circular-namespace-reexport-manual-chunks/index.js new file mode 100644 index 00000000000..26d94d9e3c9 --- /dev/null +++ b/test/function/samples/circular-namespace-reexport-manual-chunks/index.js @@ -0,0 +1,2 @@ +export { LANGUAGES } from './types.js'; +export * as formatters from './formatters.js'; diff --git a/test/function/samples/circular-namespace-reexport-manual-chunks/main.js b/test/function/samples/circular-namespace-reexport-manual-chunks/main.js new file mode 100644 index 00000000000..ab8895256dd --- /dev/null +++ b/test/function/samples/circular-namespace-reexport-manual-chunks/main.js @@ -0,0 +1,2 @@ +import { formatters } from './index.js' +export default formatters; diff --git a/test/function/samples/circular-namespace-reexport-manual-chunks/types.js b/test/function/samples/circular-namespace-reexport-manual-chunks/types.js new file mode 100644 index 00000000000..2773e071ac9 --- /dev/null +++ b/test/function/samples/circular-namespace-reexport-manual-chunks/types.js @@ -0,0 +1,2 @@ +import { formatters } from './index.js' +export const LANGUAGES = () => formatters; diff --git a/test/function/samples/circular-namespace-reexport-preserve-modules/_config.js b/test/function/samples/circular-namespace-reexport-preserve-modules/_config.js new file mode 100644 index 00000000000..f6f9ce12192 --- /dev/null +++ b/test/function/samples/circular-namespace-reexport-preserve-modules/_config.js @@ -0,0 +1,60 @@ +const path = require('node:path'); + +const ID_INDEX = path.join(__dirname, 'index.js'); +const ID_TYPES = path.join(__dirname, 'types.js'); +const ID_FORMATTERS = path.join(__dirname, 'formatters.js'); +const ID_MAIN = path.join(__dirname, 'main.js'); + +module.exports = defineTest({ + description: + 'correctly handles namespace reexports with circular dependencies when preserving modules', + options: { + output: { + preserveModules: true + } + }, + warnings: [ + { + code: 'CIRCULAR_DEPENDENCY', + ids: [ID_INDEX, ID_TYPES, ID_INDEX], + message: 'Circular dependency: index.js -> types.js -> index.js' + }, + { + code: 'CIRCULAR_DEPENDENCY', + ids: [ID_INDEX, ID_FORMATTERS, ID_INDEX], + message: 'Circular dependency: index.js -> formatters.js -> index.js' + }, + { + code: 'CYCLIC_CROSS_CHUNK_REEXPORT', + exporter: ID_FORMATTERS, + id: ID_MAIN, + message: + 'Export "*" of module "formatters.js" was reexported through module "index.js" while both modules are dependencies of each other and will end up in different chunks by current Rollup settings. This scenario is not well supported at the moment as it will produce a circular dependency between chunks and will likely lead to broken execution order.\nEither change the import in "main.js" to point directly to the exporting module or do not use "output.preserveModules" to ensure these modules end up in the same chunk.', + reexporter: ID_INDEX + }, + { + code: 'CYCLIC_CROSS_CHUNK_REEXPORT', + exporter: ID_FORMATTERS, + id: ID_MAIN, + message: + 'Export "*" of module "formatters.js" was reexported through module "index.js" while both modules are dependencies of each other and will end up in different chunks by current Rollup settings. This scenario is not well supported at the moment as it will produce a circular dependency between chunks and will likely lead to broken execution order.\nEither change the import in "main.js" to point directly to the exporting module or do not use "output.preserveModules" to ensure these modules end up in the same chunk.', + reexporter: ID_INDEX + }, + { + code: 'CYCLIC_CROSS_CHUNK_REEXPORT', + exporter: ID_FORMATTERS, + id: ID_TYPES, + message: + 'Export "*" of module "formatters.js" was reexported through module "index.js" while both modules are dependencies of each other and will end up in different chunks by current Rollup settings. This scenario is not well supported at the moment as it will produce a circular dependency between chunks and will likely lead to broken execution order.\nEither change the import in "types.js" to point directly to the exporting module or do not use "output.preserveModules" to ensure these modules end up in the same chunk.', + reexporter: ID_INDEX + }, + { + code: 'CYCLIC_CROSS_CHUNK_REEXPORT', + exporter: ID_TYPES, + id: ID_FORMATTERS, + message: + 'Export "LANGUAGES" of module "types.js" was reexported through module "index.js" while both modules are dependencies of each other and will end up in different chunks by current Rollup settings. This scenario is not well supported at the moment as it will produce a circular dependency between chunks and will likely lead to broken execution order.\nEither change the import in "formatters.js" to point directly to the exporting module or do not use "output.preserveModules" to ensure these modules end up in the same chunk.', + reexporter: ID_INDEX + } + ] +}); diff --git a/test/function/samples/circular-namespace-reexport-preserve-modules/formatters.js b/test/function/samples/circular-namespace-reexport-preserve-modules/formatters.js new file mode 100644 index 00000000000..202cbf4161d --- /dev/null +++ b/test/function/samples/circular-namespace-reexport-preserve-modules/formatters.js @@ -0,0 +1,3 @@ +import { LANGUAGES } from './index.js'; + +export const format = () => LANGUAGES; diff --git a/test/function/samples/circular-namespace-reexport-preserve-modules/index.js b/test/function/samples/circular-namespace-reexport-preserve-modules/index.js new file mode 100644 index 00000000000..26d94d9e3c9 --- /dev/null +++ b/test/function/samples/circular-namespace-reexport-preserve-modules/index.js @@ -0,0 +1,2 @@ +export { LANGUAGES } from './types.js'; +export * as formatters from './formatters.js'; diff --git a/test/function/samples/circular-namespace-reexport-preserve-modules/main.js b/test/function/samples/circular-namespace-reexport-preserve-modules/main.js new file mode 100644 index 00000000000..ab8895256dd --- /dev/null +++ b/test/function/samples/circular-namespace-reexport-preserve-modules/main.js @@ -0,0 +1,2 @@ +import { formatters } from './index.js' +export default formatters; diff --git a/test/function/samples/circular-namespace-reexport-preserve-modules/types.js b/test/function/samples/circular-namespace-reexport-preserve-modules/types.js new file mode 100644 index 00000000000..2773e071ac9 --- /dev/null +++ b/test/function/samples/circular-namespace-reexport-preserve-modules/types.js @@ -0,0 +1,2 @@ +import { formatters } from './index.js' +export const LANGUAGES = () => formatters; diff --git a/test/function/samples/circular-preserve-modules/_config.js b/test/function/samples/circular-preserve-modules/_config.js index 097090160d3..08e6b353be8 100644 --- a/test/function/samples/circular-preserve-modules/_config.js +++ b/test/function/samples/circular-preserve-modules/_config.js @@ -1,41 +1,39 @@ -const path = require('path'); +const path = require('node:path'); const ID_MAIN = path.join(__dirname, 'main.js'); const ID_FIRST = path.join(__dirname, 'first.js'); const ID_SECOND = path.join(__dirname, 'second.js'); -module.exports = { - description: 'correctly handles circular dependencies whe preserving modules', +module.exports = defineTest({ + description: 'correctly handles circular dependencies when preserving modules', options: { output: { preserveModules: true } }, warnings: [ { code: 'CIRCULAR_DEPENDENCY', - cycle: ['main.js', 'first.js', 'main.js'], - importer: 'main.js', + ids: [ID_MAIN, ID_FIRST, ID_MAIN], message: 'Circular dependency: main.js -> first.js -> main.js' }, { code: 'CIRCULAR_DEPENDENCY', - cycle: ['main.js', 'second.js', 'main.js'], - importer: 'main.js', + ids: [ID_MAIN, ID_SECOND, ID_MAIN], message: 'Circular dependency: main.js -> second.js -> main.js' }, { code: 'CYCLIC_CROSS_CHUNK_REEXPORT', exporter: ID_SECOND, - importer: ID_FIRST, + id: ID_FIRST, message: - 'Export "second" of module second.js was reexported through module main.js while both modules are dependencies of each other and will end up in different chunks by current Rollup settings. This scenario is not well supported at the moment as it will produce a circular dependency between chunks and will likely lead to broken execution order.\nEither change the import in first.js to point directly to the exporting module or do not use "preserveModules" to ensure these modules end up in the same chunk.', + 'Export "second" of module "second.js" was reexported through module "main.js" while both modules are dependencies of each other and will end up in different chunks by current Rollup settings. This scenario is not well supported at the moment as it will produce a circular dependency between chunks and will likely lead to broken execution order.\nEither change the import in "first.js" to point directly to the exporting module or do not use "output.preserveModules" to ensure these modules end up in the same chunk.', reexporter: ID_MAIN }, { code: 'CYCLIC_CROSS_CHUNK_REEXPORT', exporter: ID_FIRST, - importer: ID_SECOND, + id: ID_SECOND, message: - 'Export "first" of module first.js was reexported through module main.js while both modules are dependencies of each other and will end up in different chunks by current Rollup settings. This scenario is not well supported at the moment as it will produce a circular dependency between chunks and will likely lead to broken execution order.\nEither change the import in second.js to point directly to the exporting module or do not use "preserveModules" to ensure these modules end up in the same chunk.', + 'Export "first" of module "first.js" was reexported through module "main.js" while both modules are dependencies of each other and will end up in different chunks by current Rollup settings. This scenario is not well supported at the moment as it will produce a circular dependency between chunks and will likely lead to broken execution order.\nEither change the import in "second.js" to point directly to the exporting module or do not use "output.preserveModules" to ensure these modules end up in the same chunk.', reexporter: ID_MAIN } ] -}; +}); diff --git a/test/function/samples/circular-reexport/_config.js b/test/function/samples/circular-reexport/_config.js new file mode 100644 index 00000000000..bf4f6900872 --- /dev/null +++ b/test/function/samples/circular-reexport/_config.js @@ -0,0 +1,12 @@ +const path = require('node:path'); +const ID_MAIN = path.join(__dirname, 'main.js'); + +module.exports = defineTest({ + description: 'throws proper error for circular reexports', + error: { + code: 'CIRCULAR_REEXPORT', + exporter: ID_MAIN, + message: '"foo" cannot be exported from "main.js" as it is a reexport that references itself.', + watchFiles: [ID_MAIN] + } +}); diff --git a/test/function/samples/circular-reexport/main.js b/test/function/samples/circular-reexport/main.js new file mode 100644 index 00000000000..6572efc076a --- /dev/null +++ b/test/function/samples/circular-reexport/main.js @@ -0,0 +1,3 @@ +import { foo } from './main.js'; + +export { foo }; diff --git a/test/function/samples/class-method-getter-properties/_config.js b/test/function/samples/class-method-getter-properties/_config.js new file mode 100644 index 00000000000..d8e5749680a --- /dev/null +++ b/test/function/samples/class-method-getter-properties/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'respects getters added to class methods' +}); diff --git a/test/function/samples/class-method-getter-properties/main.js b/test/function/samples/class-method-getter-properties/main.js new file mode 100644 index 00000000000..eb537bcefb4 --- /dev/null +++ b/test/function/samples/class-method-getter-properties/main.js @@ -0,0 +1,44 @@ +let effect = false; + +class TestSuper { + constructor() { + } + + static bar() {} +} + +class Test extends TestSuper { + constructor() { + super(); + } + + static foo() {} +} + +const setEffect = { + get() { + effect = true; + }, +}; + +const addGetters = obj => { + Object.defineProperty(obj, 'x', setEffect); + Object.defineProperty(obj.foo, 'x', setEffect); + Object.defineProperty(obj.bar, 'x', setEffect); +}; + +const checkEffect = () => { + assert.ok(effect); + effect = false; +}; + +addGetters(Test); + +Test.x; +checkEffect(); + +Test.foo.x; +checkEffect(); + +TestSuper.bar.x; +checkEffect(); diff --git a/test/function/samples/class-method-mutation/_config.js b/test/function/samples/class-method-mutation/_config.js new file mode 100644 index 00000000000..d8d9a82bf11 --- /dev/null +++ b/test/function/samples/class-method-mutation/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'tracks mutations of class methods' +}); diff --git a/test/function/samples/class-method-mutation/main.js b/test/function/samples/class-method-mutation/main.js new file mode 100644 index 00000000000..0d089acdd3e --- /dev/null +++ b/test/function/samples/class-method-mutation/main.js @@ -0,0 +1,14 @@ +let effect = false; + +class Foo { + method() {} +} + +const foo = new Foo(); +Object.defineProperty(foo.method, 'effect', { + get() { + effect = true; + } +}); + +Foo.prototype.method.effect; diff --git a/test/function/samples/class-method-mutations/_config.js b/test/function/samples/class-method-mutations/_config.js new file mode 100644 index 00000000000..26bdbf66dae --- /dev/null +++ b/test/function/samples/class-method-mutations/_config.js @@ -0,0 +1,11 @@ +const assert = require('node:assert'); + +module.exports = defineTest({ + description: 'includes variable mutations in class methods if tree-shaking is disabled', + options: { + treeshake: false + }, + async exports({ promise }) { + assert.strictEqual(await promise, 'ok'); + } +}); diff --git a/test/function/samples/class-method-mutations/main.js b/test/function/samples/class-method-mutations/main.js new file mode 100644 index 00000000000..4a72b001572 --- /dev/null +++ b/test/function/samples/class-method-mutations/main.js @@ -0,0 +1,11 @@ +class LookupService { + updateLookupById() { + return new Promise((resolve) => { + let result; + result = 'ok'; + resolve(result); + }); + } +} + +export const promise = new LookupService().updateLookupById(); \ No newline at end of file diff --git a/test/function/samples/class-method-returns/_config.js b/test/function/samples/class-method-returns/_config.js new file mode 100644 index 00000000000..8ed280724b7 --- /dev/null +++ b/test/function/samples/class-method-returns/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'deoptimizes return values of class methods' +}); diff --git a/test/function/samples/class-method-returns/main.js b/test/function/samples/class-method-returns/main.js new file mode 100644 index 00000000000..ce1fc1aa74f --- /dev/null +++ b/test/function/samples/class-method-returns/main.js @@ -0,0 +1,29 @@ +const a = { mutated: false }; +const b = { mutated: false }; +const c = { mutated: false }; +const d = { mutated: false }; + +class Foo { + static staticProp = () => a; + static staticMethod() { + return b; + } + prop = () => c; + method() { + return d; + } +} + +Foo.staticProp().mutated = true; +assert.ok(a.mutated ? true : false); + +Foo.staticMethod().mutated = true; +assert.ok(b.mutated ? true : false); + +const foo = new Foo(); + +foo.prop().mutated = true; +assert.ok(c.mutated ? true : false); + +foo.method().mutated = true; +assert.ok(d.mutated ? true : false); diff --git a/test/function/samples/class-methods-not-renamed/_config.js b/test/function/samples/class-methods-not-renamed/_config.js index a5afb24b4d8..1ea78082822 100644 --- a/test/function/samples/class-methods-not-renamed/_config.js +++ b/test/function/samples/class-methods-not-renamed/_config.js @@ -1,6 +1,6 @@ -module.exports = { +module.exports = defineTest({ description: 'does not rename class methods incorrectly', options: { external: ['path'] } -}; +}); diff --git a/test/function/samples/class-name-conflict-2/_config.js b/test/function/samples/class-name-conflict-2/_config.js new file mode 100644 index 00000000000..95925814430 --- /dev/null +++ b/test/function/samples/class-name-conflict-2/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'does not shadow variables when preserving class names' +}); diff --git a/test/function/samples/class-name-conflict-2/bar.js b/test/function/samples/class-name-conflict-2/bar.js new file mode 100644 index 00000000000..757c04f3472 --- /dev/null +++ b/test/function/samples/class-name-conflict-2/bar.js @@ -0,0 +1,3 @@ +export class bar { + static base = true; +} diff --git a/test/function/samples/class-name-conflict-2/declaration.js b/test/function/samples/class-name-conflict-2/declaration.js new file mode 100644 index 00000000000..22e997ebd9f --- /dev/null +++ b/test/function/samples/class-name-conflict-2/declaration.js @@ -0,0 +1,12 @@ +import { foo as foo$ } from './foo.js'; + +{ + class foo extends foo$ { + static test() { + assert.ok(foo.base); + } + } + + assert.strictEqual(foo.name, 'foo'); + foo.test(); +} diff --git a/test/function/samples/class-name-conflict-2/expression.js b/test/function/samples/class-name-conflict-2/expression.js new file mode 100644 index 00000000000..d84b1cfd35c --- /dev/null +++ b/test/function/samples/class-name-conflict-2/expression.js @@ -0,0 +1,12 @@ +import { bar as bar$ } from './bar.js'; + +{ + let bar = class extends bar$ { + static test() { + assert.ok(bar.base); + } + }; + + assert.strictEqual(bar.name, 'bar'); + bar.test(); +} diff --git a/test/function/samples/class-name-conflict-2/foo.js b/test/function/samples/class-name-conflict-2/foo.js new file mode 100644 index 00000000000..6c761e6abc0 --- /dev/null +++ b/test/function/samples/class-name-conflict-2/foo.js @@ -0,0 +1,3 @@ +export class foo { + static base = true; +} diff --git a/test/function/samples/class-name-conflict-2/main.js b/test/function/samples/class-name-conflict-2/main.js new file mode 100644 index 00000000000..6ff85b30e14 --- /dev/null +++ b/test/function/samples/class-name-conflict-2/main.js @@ -0,0 +1,2 @@ +import './expression'; +import './declaration'; diff --git a/test/function/samples/class-name-conflict-3/_config.js b/test/function/samples/class-name-conflict-3/_config.js new file mode 100644 index 00000000000..95925814430 --- /dev/null +++ b/test/function/samples/class-name-conflict-3/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'does not shadow variables when preserving class names' +}); diff --git a/test/function/samples/class-name-conflict-3/foo.js b/test/function/samples/class-name-conflict-3/foo.js new file mode 100644 index 00000000000..7804111002d --- /dev/null +++ b/test/function/samples/class-name-conflict-3/foo.js @@ -0,0 +1 @@ +export default class Foo {} diff --git a/test/function/samples/class-name-conflict-3/main.js b/test/function/samples/class-name-conflict-3/main.js new file mode 100644 index 00000000000..22b9b90b33a --- /dev/null +++ b/test/function/samples/class-name-conflict-3/main.js @@ -0,0 +1,14 @@ +import Bar from './foo'; + +const wrapper = () => { + class Foo extends Bar { + static assertName() { + assert.strictEqual(this.name, 'Foo'); + assert.strictEqual(super.name, 'Foo'); + } + } + + return Foo; +}; + +wrapper().assertName(); diff --git a/test/function/samples/class-name-conflict-4/_config.js b/test/function/samples/class-name-conflict-4/_config.js new file mode 100644 index 00000000000..95925814430 --- /dev/null +++ b/test/function/samples/class-name-conflict-4/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'does not shadow variables when preserving class names' +}); diff --git a/test/function/samples/class-name-conflict-4/foo.js b/test/function/samples/class-name-conflict-4/foo.js new file mode 100644 index 00000000000..03e6dcc163e --- /dev/null +++ b/test/function/samples/class-name-conflict-4/foo.js @@ -0,0 +1,5 @@ +var Foo = class {}; + +export default Foo; + +Foo = 'reassigned'; diff --git a/test/function/samples/class-name-conflict-4/main.js b/test/function/samples/class-name-conflict-4/main.js new file mode 100644 index 00000000000..70152e988cc --- /dev/null +++ b/test/function/samples/class-name-conflict-4/main.js @@ -0,0 +1,14 @@ +import Bar from './reexport'; + +const wrapper = () => { + class Foo extends Bar { + static assertName() { + assert.strictEqual(this.name, 'Foo'); + assert.strictEqual(super.name, 'Foo'); + } + } + + return Foo; +}; + +wrapper().assertName(); diff --git a/test/function/samples/class-name-conflict-4/reexport.js b/test/function/samples/class-name-conflict-4/reexport.js new file mode 100644 index 00000000000..ee90f7e3084 --- /dev/null +++ b/test/function/samples/class-name-conflict-4/reexport.js @@ -0,0 +1,2 @@ +import Foo from './foo'; +export default Foo; diff --git a/test/function/samples/class-name-conflict/_config.js b/test/function/samples/class-name-conflict/_config.js new file mode 100644 index 00000000000..035c45e3734 --- /dev/null +++ b/test/function/samples/class-name-conflict/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'preserves class names even if the class is renamed' +}); diff --git a/test/function/samples/class-name-conflict/declaration1.js b/test/function/samples/class-name-conflict/declaration1.js new file mode 100644 index 00000000000..ea4c231065c --- /dev/null +++ b/test/function/samples/class-name-conflict/declaration1.js @@ -0,0 +1,3 @@ +class foo {} + +assert.strictEqual(foo.name, 'foo'); diff --git a/test/function/samples/class-name-conflict/declaration2.js b/test/function/samples/class-name-conflict/declaration2.js new file mode 100644 index 00000000000..ea4c231065c --- /dev/null +++ b/test/function/samples/class-name-conflict/declaration2.js @@ -0,0 +1,3 @@ +class foo {} + +assert.strictEqual(foo.name, 'foo'); diff --git a/test/function/samples/class-name-conflict/expression1.js b/test/function/samples/class-name-conflict/expression1.js new file mode 100644 index 00000000000..f081a730090 --- /dev/null +++ b/test/function/samples/class-name-conflict/expression1.js @@ -0,0 +1,3 @@ +let foo = class {}; + +assert.strictEqual(foo.name, 'foo'); diff --git a/test/function/samples/class-name-conflict/expression2.js b/test/function/samples/class-name-conflict/expression2.js new file mode 100644 index 00000000000..f081a730090 --- /dev/null +++ b/test/function/samples/class-name-conflict/expression2.js @@ -0,0 +1,3 @@ +let foo = class {}; + +assert.strictEqual(foo.name, 'foo'); diff --git a/test/function/samples/class-name-conflict/main.js b/test/function/samples/class-name-conflict/main.js new file mode 100644 index 00000000000..a72f0553ec3 --- /dev/null +++ b/test/function/samples/class-name-conflict/main.js @@ -0,0 +1,4 @@ +import './expression1'; +import './declaration1'; +import './expression2'; +import './declaration2'; diff --git a/test/function/samples/class-prop-returns/_config.js b/test/function/samples/class-prop-returns/_config.js new file mode 100644 index 00000000000..20b3952ccc2 --- /dev/null +++ b/test/function/samples/class-prop-returns/_config.js @@ -0,0 +1,21 @@ +const assert = require('node:assert'); + +module.exports = defineTest({ + description: 'does not remove calls to props without value', + exports({ callProp, callStaticProp }) { + let hasError = false; + try { + callStaticProp(); + } catch { + hasError = true; + } + assert.ok(hasError); + hasError = false; + try { + callProp(); + } catch { + hasError = true; + } + assert.ok(hasError); + } +}); diff --git a/test/function/samples/class-prop-returns/main.js b/test/function/samples/class-prop-returns/main.js new file mode 100644 index 00000000000..03c01649472 --- /dev/null +++ b/test/function/samples/class-prop-returns/main.js @@ -0,0 +1,11 @@ +class Foo { + static staticProp; + prop; +} + +export const callStaticProp = () => Foo.staticProp() || false; + +export const callProp = () => { + const foo = new Foo(); + return foo.prop() || false; +}; diff --git a/test/function/samples/class-static-block-tree-shaking/_config.js b/test/function/samples/class-static-block-tree-shaking/_config.js new file mode 100644 index 00000000000..994c26ecde3 --- /dev/null +++ b/test/function/samples/class-static-block-tree-shaking/_config.js @@ -0,0 +1,10 @@ +module.exports = defineTest({ + description: 'treeshakes no effect static blocks', + warnings: [ + { + code: 'EMPTY_BUNDLE', + message: 'Generated an empty chunk: "main".', + names: ['main'] + } + ] +}); diff --git a/test/function/samples/class-static-block-tree-shaking/main.js b/test/function/samples/class-static-block-tree-shaking/main.js new file mode 100644 index 00000000000..f5fd03ffb1f --- /dev/null +++ b/test/function/samples/class-static-block-tree-shaking/main.js @@ -0,0 +1,5 @@ +class D { + static { + this.foo = 'foo'; + } +} diff --git a/test/function/samples/code-splitting-export-default-from-entry/_config.js b/test/function/samples/code-splitting-export-default-from-entry/_config.js index 376c52b9c37..ec6ed9cb990 100644 --- a/test/function/samples/code-splitting-export-default-from-entry/_config.js +++ b/test/function/samples/code-splitting-export-default-from-entry/_config.js @@ -1,6 +1,6 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'correctly imports the default from an entry point', options: { input: ['main', 'dep'] @@ -10,4 +10,4 @@ module.exports = { value: 42 }); } -}; +}); diff --git a/test/function/samples/compact-multiple-imports/_config.js b/test/function/samples/compact-multiple-imports/_config.js index b651e98d09d..ac16f392074 100644 --- a/test/function/samples/compact-multiple-imports/_config.js +++ b/test/function/samples/compact-multiple-imports/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'correctly handles empty external imports in compact mode', context: { require(id) { @@ -13,4 +13,4 @@ module.exports = { compact: true } } -}; +}); diff --git a/test/function/samples/compact/_config.js b/test/function/samples/compact/_config.js index e41b7457fa6..3575f7e9fe5 100644 --- a/test/function/samples/compact/_config.js +++ b/test/function/samples/compact/_config.js @@ -1,23 +1,25 @@ -module.exports = { +const path = require('node:path'); +const ID_MAIN = path.join(__dirname, 'main.js'); + +module.exports = defineTest({ description: 'compact output with compact: true', options: { external: ['external'], output: { compact: true, - namespaceToStringTag: true + generatedCode: { symbols: true } } }, warnings: [ { code: 'CIRCULAR_DEPENDENCY', - cycle: ['main.js', 'main.js'], - importer: 'main.js', + ids: [ID_MAIN, ID_MAIN], message: 'Circular dependency: main.js -> main.js' } ], context: { - require(x) { + require() { return 42; } } -}; +}); diff --git a/test/function/samples/conditional-catch/_config.js b/test/function/samples/conditional-catch/_config.js index 7fe0c318b80..bc61ae8dd89 100644 --- a/test/function/samples/conditional-catch/_config.js +++ b/test/function/samples/conditional-catch/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'handles conditional catch blocks (#3869)' -}; +}); diff --git a/test/function/samples/conditional-definition/_config.js b/test/function/samples/conditional-definition/_config.js index a6b22f45c2e..66735855054 100644 --- a/test/function/samples/conditional-definition/_config.js +++ b/test/function/samples/conditional-definition/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'avoids infinite loop when testing conditional definitions' -}; +}); diff --git a/test/function/samples/conditional-expression-literal-value/_config.js b/test/function/samples/conditional-expression-literal-value/_config.js new file mode 100644 index 00000000000..4df2805d473 --- /dev/null +++ b/test/function/samples/conditional-expression-literal-value/_config.js @@ -0,0 +1,4 @@ +module.exports = { + description: + 'do not optimize the literal value of conditional expression if the cache is deoptimized' +}; diff --git a/test/function/samples/conditional-expression-literal-value/main.js b/test/function/samples/conditional-expression-literal-value/main.js new file mode 100644 index 00000000000..707bfd551e1 --- /dev/null +++ b/test/function/samples/conditional-expression-literal-value/main.js @@ -0,0 +1,8 @@ +let count = 0; +let foo = false; +let bar = false; +let condition = foo ? bar ? true: false : false; +if (!condition) count++; +foo = true; +if (!condition) count++; +assert.strictEqual(count, 2); \ No newline at end of file diff --git a/test/function/samples/conditionals-deoptimization/_config.js b/test/function/samples/conditionals-deoptimization/_config.js new file mode 100644 index 00000000000..29fd6dc5609 --- /dev/null +++ b/test/function/samples/conditionals-deoptimization/_config.js @@ -0,0 +1,17 @@ +const assert = require('node:assert'); + +module.exports = defineTest({ + description: 'handles deoptimization of conditionals', + exports(exports) { + assert.deepStrictEqual(exports, { + cond1a: true, + cond1b: true, + cond2a: true, + cond2b: true, + log1a: true, + log1b: true, + log2a: true, + log2b: true + }); + } +}); diff --git a/test/function/samples/conditionals-deoptimization/main.js b/test/function/samples/conditionals-deoptimization/main.js new file mode 100644 index 00000000000..667d597cdca --- /dev/null +++ b/test/function/samples/conditionals-deoptimization/main.js @@ -0,0 +1,39 @@ +export let cond1a = false; +export let cond1b = false; +export let cond2a = false; +export let cond2b = false; +export let log1a = false; +export let log1b = false; +export let log2a = false; +export let log2b = false; + +let flag = false; +checkConditional1(); +checkConditional2(); +checkLogical1(); +checkLogical2(); +flag = true; +checkConditional1(); +checkConditional2(); +checkLogical1(); +checkLogical2(); + +function checkConditional1() { + if (flag ? true : false) cond1a = true; + else cond1b = true; +} + +function checkConditional2() { + if (!flag ? true : false) cond2a = true; + else cond2b = true; +} + +function checkLogical1() { + if (flag && true) log1a = true; + else log1b = true; +} + +function checkLogical2() { + if (!flag && true) log2a = true; + else log2b = true; +} diff --git a/test/function/samples/configure-external-module-b/_config.js b/test/function/samples/configure-external-module-b/_config.js index b3230047641..74bb65a6bec 100644 --- a/test/function/samples/configure-external-module-b/_config.js +++ b/test/function/samples/configure-external-module-b/_config.js @@ -1,11 +1,12 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'allows external module to be configured (b)', options: { external: ['path'] }, exports() { - assert.equal(require('path').resolve.configured, 'yes'); + // @ts-expect-error missing types + assert.equal(require('node:path').resolve.configured, 'yes'); } -}; +}); diff --git a/test/function/samples/configure-external-module/_config.js b/test/function/samples/configure-external-module/_config.js index 81cf516f0cb..88a7d2b0c22 100644 --- a/test/function/samples/configure-external-module/_config.js +++ b/test/function/samples/configure-external-module/_config.js @@ -1,11 +1,11 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'allows external module to be configured', options: { external: ['path'] }, exports() { - assert.equal(require('path').resolve.configured, 'yes'); + assert.equal(require('node:path').resolve.configured, 'yes'); } -}; +}); diff --git a/test/function/samples/configure-relative-external-module/_config.js b/test/function/samples/configure-relative-external-module/_config.js index ed6067a48c9..2337110d002 100644 --- a/test/function/samples/configure-relative-external-module/_config.js +++ b/test/function/samples/configure-relative-external-module/_config.js @@ -1,11 +1,11 @@ -const assert = require('assert'); -const path = require('path'); +const assert = require('node:assert'); +const path = require('node:path'); const mockedValue = { val: 'A value' }; -module.exports = { +module.exports = defineTest({ description: 'allows a nonexistent relative module to be configured as external', options: { external: [path.join(__dirname, './nonexistent-relative-dependency.js')] @@ -18,4 +18,4 @@ module.exports = { exports() { assert.equal(mockedValue.wasAltered, true); } -}; +}); diff --git a/test/function/samples/conflicting-reexports/named-import-external/_config.js b/test/function/samples/conflicting-reexports/named-import-external/_config.js new file mode 100644 index 00000000000..cf0cfc19e42 --- /dev/null +++ b/test/function/samples/conflicting-reexports/named-import-external/_config.js @@ -0,0 +1,30 @@ +const path = require('node:path'); +const ID_REEXPORT = path.join(__dirname, 'reexport.js'); + +module.exports = defineTest({ + description: + 'warns when a conflicting binding is imported via a named import from external namespaces', + warnings: [ + { + binding: 'foo', + code: 'AMBIGUOUS_EXTERNAL_NAMESPACES', + ids: ['first', 'second'], + message: + 'Ambiguous external namespace resolution: "reexport.js" re-exports "foo" from one of the external modules "first" and "second", guessing "first".', + reexporter: ID_REEXPORT + }, + { + code: 'UNUSED_EXTERNAL_IMPORT', + exporter: 'second', + ids: [ID_REEXPORT], + message: '"foo" is imported from external module "second" but never used in "reexport.js".', + names: ['foo'] + } + ], + options: { external: ['first', 'second'] }, + context: { + require(id) { + return { foo: id }; + } + } +}); diff --git a/test/function/samples/conflicting-reexports/named-import-external/main.js b/test/function/samples/conflicting-reexports/named-import-external/main.js new file mode 100644 index 00000000000..c76b16a35ad --- /dev/null +++ b/test/function/samples/conflicting-reexports/named-import-external/main.js @@ -0,0 +1,3 @@ +import { foo } from './reexport.js'; + +assert.strictEqual(foo, 'first'); diff --git a/test/function/samples/conflicting-reexports/named-import-external/reexport.js b/test/function/samples/conflicting-reexports/named-import-external/reexport.js new file mode 100644 index 00000000000..914892c4459 --- /dev/null +++ b/test/function/samples/conflicting-reexports/named-import-external/reexport.js @@ -0,0 +1,2 @@ +export * from 'first'; +export * from 'second'; diff --git a/test/function/samples/conflicting-reexports/named-import/_config.js b/test/function/samples/conflicting-reexports/named-import/_config.js new file mode 100644 index 00000000000..ed209d3b67d --- /dev/null +++ b/test/function/samples/conflicting-reexports/named-import/_config.js @@ -0,0 +1,30 @@ +const path = require('node:path'); + +const ID_MAIN = path.join(__dirname, 'main.js'); +const ID_REEXPORT = path.join(__dirname, 'reexport.js'); +const ID_FIRST = path.join(__dirname, 'first.js'); +const ID_SECOND = path.join(__dirname, 'second.js'); + +module.exports = defineTest({ + description: 'throws when a conflicting binding is imported via a named import', + error: { + binding: 'foo', + code: 'MISSING_EXPORT', + exporter: ID_REEXPORT, + id: ID_MAIN, + url: 'https://rollupjs.org/troubleshooting/#error-name-is-not-exported-by-module', + pos: 9, + loc: { + column: 9, + file: ID_MAIN, + line: 1 + }, + frame: ` + 1: import { foo } from './reexport.js'; + ^ + 2: + 3: assert.strictEqual(foo, 1);`, + watchFiles: [ID_FIRST, ID_MAIN, ID_REEXPORT, ID_SECOND], + message: 'main.js (1:9): "foo" is not exported by "reexport.js", imported by "main.js".' + } +}); diff --git a/test/function/samples/conflicting-reexports/named-import/first.js b/test/function/samples/conflicting-reexports/named-import/first.js new file mode 100644 index 00000000000..bb1843d113a --- /dev/null +++ b/test/function/samples/conflicting-reexports/named-import/first.js @@ -0,0 +1 @@ +export const foo = 1; diff --git a/test/function/samples/conflicting-reexports/named-import/main.js b/test/function/samples/conflicting-reexports/named-import/main.js new file mode 100644 index 00000000000..38098ddc140 --- /dev/null +++ b/test/function/samples/conflicting-reexports/named-import/main.js @@ -0,0 +1,3 @@ +import { foo } from './reexport.js'; + +assert.strictEqual(foo, 1); diff --git a/test/function/samples/conflicting-reexports/named-import/reexport.js b/test/function/samples/conflicting-reexports/named-import/reexport.js new file mode 100644 index 00000000000..7216b37efc0 --- /dev/null +++ b/test/function/samples/conflicting-reexports/named-import/reexport.js @@ -0,0 +1,2 @@ +export * from './first.js'; +export * from './second.js'; diff --git a/test/function/samples/conflicting-reexports/named-import/second.js b/test/function/samples/conflicting-reexports/named-import/second.js new file mode 100644 index 00000000000..cc57a55e257 --- /dev/null +++ b/test/function/samples/conflicting-reexports/named-import/second.js @@ -0,0 +1 @@ +export const foo = 2; diff --git a/test/function/samples/conflicting-reexports/namespace-import/_config.js b/test/function/samples/conflicting-reexports/namespace-import/_config.js new file mode 100644 index 00000000000..b633dead37f --- /dev/null +++ b/test/function/samples/conflicting-reexports/namespace-import/_config.js @@ -0,0 +1,38 @@ +const path = require('node:path'); +const ID_MAIN = path.join(__dirname, 'main.js'); +const ID_FIRST = path.join(__dirname, 'first.js'); +const ID_SECOND = path.join(__dirname, 'second.js'); +const ID_REEXPORT = path.join(__dirname, 'reexport.js'); + +module.exports = defineTest({ + description: 'warns when a conflicting binding is imported via a namespace import', + warnings: [ + { + binding: 'foo', + code: 'NAMESPACE_CONFLICT', + ids: [ID_FIRST, ID_SECOND], + message: + 'Conflicting namespaces: "reexport.js" re-exports "foo" from one of the modules "first.js" and "second.js" (will be ignored).', + reexporter: ID_REEXPORT + }, + { + binding: 'foo', + code: 'MISSING_EXPORT', + exporter: ID_REEXPORT, + id: ID_MAIN, + message: 'main.js (4:22): "foo" is not exported by "reexport.js", imported by "main.js".', + url: 'https://rollupjs.org/troubleshooting/#error-name-is-not-exported-by-module', + pos: 125, + loc: { + column: 22, + file: ID_MAIN, + line: 4 + }, + frame: ` + 2: + 3: assert.deepStrictEqual(ns, { __proto__: null, bar: 1, baz: 2 }); + 4: assert.strictEqual(ns.foo, undefined) + ^` + } + ] +}); diff --git a/test/function/samples/conflicting-reexports/namespace-import/first.js b/test/function/samples/conflicting-reexports/namespace-import/first.js new file mode 100644 index 00000000000..572a5ca84a0 --- /dev/null +++ b/test/function/samples/conflicting-reexports/namespace-import/first.js @@ -0,0 +1,2 @@ +export const foo = 1; +export const bar = 1; diff --git a/test/function/samples/conflicting-reexports/namespace-import/main.js b/test/function/samples/conflicting-reexports/namespace-import/main.js new file mode 100644 index 00000000000..dbee2dc6cd6 --- /dev/null +++ b/test/function/samples/conflicting-reexports/namespace-import/main.js @@ -0,0 +1,4 @@ +import * as ns from './reexport.js'; + +assert.deepStrictEqual(ns, { __proto__: null, bar: 1, baz: 2 }); +assert.strictEqual(ns.foo, undefined) \ No newline at end of file diff --git a/test/function/samples/conflicting-reexports/namespace-import/reexport.js b/test/function/samples/conflicting-reexports/namespace-import/reexport.js new file mode 100644 index 00000000000..7216b37efc0 --- /dev/null +++ b/test/function/samples/conflicting-reexports/namespace-import/reexport.js @@ -0,0 +1,2 @@ +export * from './first.js'; +export * from './second.js'; diff --git a/test/function/samples/conflicting-reexports/namespace-import/second.js b/test/function/samples/conflicting-reexports/namespace-import/second.js new file mode 100644 index 00000000000..2a2835dba0f --- /dev/null +++ b/test/function/samples/conflicting-reexports/namespace-import/second.js @@ -0,0 +1,2 @@ +export const foo = 2; +export const baz = 2; diff --git a/test/function/samples/conflicting-reexports/same-binding/_config.js b/test/function/samples/conflicting-reexports/same-binding/_config.js new file mode 100644 index 00000000000..f11f6f192ad --- /dev/null +++ b/test/function/samples/conflicting-reexports/same-binding/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'does not fail when the same binding is reexported from different files' +}); diff --git a/test/function/samples/conflicting-reexports/same-binding/first.js b/test/function/samples/conflicting-reexports/same-binding/first.js new file mode 100644 index 00000000000..1fd2a2d127f --- /dev/null +++ b/test/function/samples/conflicting-reexports/same-binding/first.js @@ -0,0 +1 @@ +export { foo } from './shared.js'; diff --git a/test/function/samples/conflicting-reexports/same-binding/main.js b/test/function/samples/conflicting-reexports/same-binding/main.js new file mode 100644 index 00000000000..38098ddc140 --- /dev/null +++ b/test/function/samples/conflicting-reexports/same-binding/main.js @@ -0,0 +1,3 @@ +import { foo } from './reexport.js'; + +assert.strictEqual(foo, 1); diff --git a/test/function/samples/conflicting-reexports/same-binding/reexport.js b/test/function/samples/conflicting-reexports/same-binding/reexport.js new file mode 100644 index 00000000000..7216b37efc0 --- /dev/null +++ b/test/function/samples/conflicting-reexports/same-binding/reexport.js @@ -0,0 +1,2 @@ +export * from './first.js'; +export * from './second.js'; diff --git a/test/function/samples/conflicting-reexports/same-binding/second.js b/test/function/samples/conflicting-reexports/same-binding/second.js new file mode 100644 index 00000000000..1fd2a2d127f --- /dev/null +++ b/test/function/samples/conflicting-reexports/same-binding/second.js @@ -0,0 +1 @@ +export { foo } from './shared.js'; diff --git a/test/function/samples/conflicting-reexports/same-binding/shared.js b/test/function/samples/conflicting-reexports/same-binding/shared.js new file mode 100644 index 00000000000..bb1843d113a --- /dev/null +++ b/test/function/samples/conflicting-reexports/same-binding/shared.js @@ -0,0 +1 @@ +export const foo = 1; diff --git a/test/function/samples/confused-default-identifier/_config.js b/test/function/samples/confused-default-identifier/_config.js index adb7973ab8f..2da3393b6c4 100644 --- a/test/function/samples/confused-default-identifier/_config.js +++ b/test/function/samples/confused-default-identifier/_config.js @@ -1,6 +1,6 @@ -module.exports = { +module.exports = defineTest({ description: 'Rollup should not get confused and allow "default" as an identifier name', warnings() {} // suppress -}; +}); // https://github.com/rollup/rollup/issues/215 diff --git a/test/function/samples/consistent-renaming-b/_config.js b/test/function/samples/consistent-renaming-b/_config.js index f1b3ee69460..5dbd2de1ae7 100644 --- a/test/function/samples/consistent-renaming-b/_config.js +++ b/test/function/samples/consistent-renaming-b/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'consistent renaming test b' -}; +}); diff --git a/test/function/samples/consistent-renaming-c/_config.js b/test/function/samples/consistent-renaming-c/_config.js index 4b30d565081..8d572fa3132 100644 --- a/test/function/samples/consistent-renaming-c/_config.js +++ b/test/function/samples/consistent-renaming-c/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'consistent renaming test c' -}; +}); diff --git a/test/function/samples/consistent-renaming-d/_config.js b/test/function/samples/consistent-renaming-d/_config.js index 6859f78784e..af41fcd4273 100644 --- a/test/function/samples/consistent-renaming-d/_config.js +++ b/test/function/samples/consistent-renaming-d/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'consistent renaming test d' -}; +}); diff --git a/test/function/samples/consistent-renaming-e/_config.js b/test/function/samples/consistent-renaming-e/_config.js index 52455ada4c0..e939f587557 100644 --- a/test/function/samples/consistent-renaming-e/_config.js +++ b/test/function/samples/consistent-renaming-e/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'consistent renaming test e' -}; +}); diff --git a/test/function/samples/consistent-renaming-f/_config.js b/test/function/samples/consistent-renaming-f/_config.js index 873e29605c1..e440022425e 100644 --- a/test/function/samples/consistent-renaming-f/_config.js +++ b/test/function/samples/consistent-renaming-f/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'consistent renaming test f' -}; +}); diff --git a/test/function/samples/consistent-renaming/_config.js b/test/function/samples/consistent-renaming/_config.js index e6760b1fe5a..5a13ac8bd51 100644 --- a/test/function/samples/consistent-renaming/_config.js +++ b/test/function/samples/consistent-renaming/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'consistent renaming test' -}; +}); diff --git a/test/function/samples/consistently-renames-destructured-parameters/_config.js b/test/function/samples/consistently-renames-destructured-parameters/_config.js index 6eb58a04984..04b2a7b203b 100644 --- a/test/function/samples/consistently-renames-destructured-parameters/_config.js +++ b/test/function/samples/consistently-renames-destructured-parameters/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'destructured parameters are properly renamed (#2418)' -}; +}); diff --git a/test/function/samples/context-resolve-skipself/_config.js b/test/function/samples/context-resolve-skipself/_config.js index 9376a2c6850..3f1d53a7101 100644 --- a/test/function/samples/context-resolve-skipself/_config.js +++ b/test/function/samples/context-resolve-skipself/_config.js @@ -1,6 +1,9 @@ -const path = require('path'); +const path = require('node:path'); -module.exports = { +let hasInfinite = false; +const importer = path.join(__dirname, 'main.js'); + +module.exports = defineTest({ description: 'allows a plugin to skip its own resolveId hook when using this.resolve', options: { plugins: [ @@ -9,15 +12,15 @@ module.exports = { if (id === 'resolutions') { return id; } - if (id.startsWith('test')) { + if (id.startsWith('test') || id.startsWith('foo') || id.startsWith('bar')) { return 'own-resolution'; } }, load(id) { if (id === 'resolutions') { - const importer = path.join(__dirname, 'main.js'); return Promise.all([ - this.resolve('test', importer).then(result => ({ id: result.id, text: 'all' })), + this.resolve('bar', importer).then(result => ({ id: result.id, text: 'bar' })), + this.resolve('foo', importer).then(result => ({ id: result.id, text: 'foo' })), this.resolve('test', importer, { skipSelf: false }).then(result => ({ id: result.id, text: 'unskipped' @@ -32,11 +35,28 @@ module.exports = { }, { resolveId(id) { + if (id.startsWith('bar')) { + return this.resolve('bar', importer); + } + if (id.startsWith('foo')) { + if (hasInfinite) { + return 'foo-resolution'; + } + hasInfinite = true; + return this.resolve('foo', importer, { skipSelf: false }); + } if (id.startsWith('test')) { return 'other-resolution'; } } + }, + { + resolveId(id) { + if (id.startsWith('bar')) { + return 'bar-resolution'; + } + } } ] } -}; +}); diff --git a/test/function/samples/context-resolve-skipself/existing.js b/test/function/samples/context-resolve-skipself/existing.js deleted file mode 100644 index 9486260537f..00000000000 --- a/test/function/samples/context-resolve-skipself/existing.js +++ /dev/null @@ -1 +0,0 @@ -console.log('existing'); diff --git a/test/function/samples/context-resolve-skipself/main.js b/test/function/samples/context-resolve-skipself/main.js index a0be821e3ed..d490fbe1489 100644 --- a/test/function/samples/context-resolve-skipself/main.js +++ b/test/function/samples/context-resolve-skipself/main.js @@ -2,8 +2,12 @@ import resolutions from 'resolutions'; assert.deepStrictEqual(resolutions, [ { - id: 'own-resolution', - text: 'all' + id: 'bar-resolution', + text: 'bar' + }, + { + id: 'foo-resolution', + text: 'foo' }, { id: 'own-resolution', diff --git a/test/function/samples/context-resolve/_config.js b/test/function/samples/context-resolve/_config.js index 9c83e137c9b..985585d5c4d 100644 --- a/test/function/samples/context-resolve/_config.js +++ b/test/function/samples/context-resolve/_config.js @@ -1,13 +1,15 @@ -const path = require('path'); -const assert = require('assert'); +const assert = require('node:assert'); +const path = require('node:path'); const tests = [ { source: './existing', expected: { id: path.join(__dirname, 'existing.js'), + attributes: {}, external: false, meta: {}, + resolvedBy: 'rollup', moduleSideEffects: true, syntheticNamedExports: false } @@ -24,9 +26,11 @@ const tests = [ source: './marked-directly-external-relative', expected: { id: path.join(__dirname, 'marked-directly-external-relative'), + attributes: {}, external: true, meta: {}, moduleSideEffects: true, + resolvedBy: 'rollup', syntheticNamedExports: false } }, @@ -34,9 +38,11 @@ const tests = [ source: './marked-external-relative', expected: { id: path.join(__dirname, 'marked-external-relative'), + attributes: {}, external: true, meta: {}, moduleSideEffects: true, + resolvedBy: 'rollup', syntheticNamedExports: false } }, @@ -44,9 +50,11 @@ const tests = [ source: 'marked-external-absolute', expected: { id: 'marked-external-absolute', + attributes: {}, external: true, meta: {}, moduleSideEffects: true, + resolvedBy: 'rollup', syntheticNamedExports: false } }, @@ -54,9 +62,11 @@ const tests = [ source: 'resolved-name', expected: { id: 'resolved:resolved-name', + attributes: {}, external: false, meta: {}, moduleSideEffects: true, + resolvedBy: 'at position 2', syntheticNamedExports: false } }, @@ -64,8 +74,10 @@ const tests = [ source: 'resolved-false', expected: { id: 'resolved-false', + attributes: {}, external: true, meta: {}, + resolvedBy: 'rollup', moduleSideEffects: true, syntheticNamedExports: false } @@ -74,9 +86,11 @@ const tests = [ source: 'resolved-object', expected: { id: 'resolved:resolved-object', + attributes: {}, external: false, meta: {}, moduleSideEffects: true, + resolvedBy: 'at position 2', syntheticNamedExports: false } }, @@ -84,9 +98,11 @@ const tests = [ source: 'resolved-object-non-external', expected: { id: 'resolved:resolved-object-non-external', + attributes: {}, external: false, meta: {}, moduleSideEffects: true, + resolvedBy: 'at position 2', syntheticNamedExports: false } }, @@ -94,15 +110,17 @@ const tests = [ source: 'resolved-object-external', expected: { id: 'resolved:resolved-object-external', + attributes: {}, external: true, meta: {}, moduleSideEffects: true, + resolvedBy: 'at position 2', syntheticNamedExports: false } } ]; -module.exports = { +module.exports = defineTest({ description: 'returns the correct results for the context resolve helper', options: { external: [ @@ -132,19 +150,24 @@ module.exports = { { resolveId(id) { switch (id) { - case 'resolved-name': + case 'resolved-name': { return 'resolved:resolved-name'; - case 'resolved-false': + } + case 'resolved-false': { return false; - case 'resolved-object': + } + case 'resolved-object': { return { id: 'resolved:resolved-object' }; - case 'resolved-object-non-external': + } + case 'resolved-object-non-external': { return { id: 'resolved:resolved-object-non-external', external: false }; - case 'resolved-object-external': + } + case 'resolved-object-external': { return { id: 'resolved:resolved-object-external', external: true }; + } } } } ] } -}; +}); diff --git a/test/function/samples/correct-var-before-declaration-deopt/_config.js b/test/function/samples/correct-var-before-declaration-deopt/_config.js new file mode 100644 index 00000000000..3e202ed1193 --- /dev/null +++ b/test/function/samples/correct-var-before-declaration-deopt/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'adds necessary deoptimizations when using var' +}); diff --git a/test/function/samples/correct-var-before-declaration-deopt/main.js b/test/function/samples/correct-var-before-declaration-deopt/main.js new file mode 100644 index 00000000000..4d36f4a924b --- /dev/null +++ b/test/function/samples/correct-var-before-declaration-deopt/main.js @@ -0,0 +1,7 @@ +const obj = { flag: false }; +var foo = obj; +foo.flag = true; +assert.ok(obj.flag ? true : false, 'init deoptimization'); + +assert.ok(bar ? false : true, 'value deoptimization'); +var bar = true; diff --git a/test/function/samples/create-undefined-export-property-compact/_config.js b/test/function/samples/create-undefined-export-property-compact/_config.js index 6ba6b054ee9..fa3cc4a85a8 100644 --- a/test/function/samples/create-undefined-export-property-compact/_config.js +++ b/test/function/samples/create-undefined-export-property-compact/_config.js @@ -1,6 +1,6 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'creates an export as an exports property even if is has no initializer', options: { output: { compact: true } }, exports(exports) { @@ -14,4 +14,4 @@ module.exports = { assert.strictEqual(exports.foo, 'defined'); assert.strictEqual(exports.bar, 'defined'); } -}; +}); diff --git a/test/function/samples/create-undefined-export-property/_config.js b/test/function/samples/create-undefined-export-property/_config.js index 7c95c097373..a08ad11a22e 100644 --- a/test/function/samples/create-undefined-export-property/_config.js +++ b/test/function/samples/create-undefined-export-property/_config.js @@ -1,6 +1,6 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'creates an export as an exports property even if is has no initializer', exports(exports) { assert.strictEqual(exports.foo, undefined); @@ -13,4 +13,4 @@ module.exports = { assert.strictEqual(exports.foo, 'defined'); assert.strictEqual(exports.bar, 'defined'); } -}; +}); diff --git a/test/function/samples/cross-chunk-live-binding-compact/_config.js b/test/function/samples/cross-chunk-live-binding-compact/_config.js index 7e324338e77..b266c4e575f 100644 --- a/test/function/samples/cross-chunk-live-binding-compact/_config.js +++ b/test/function/samples/cross-chunk-live-binding-compact/_config.js @@ -1,6 +1,6 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'handles cross-chunk live-bindings in compact mode', options: { input: ['main.js', 'named.js', 'star.js'], @@ -17,4 +17,4 @@ module.exports = { exports.incrementStar(); assert.equal(exports.star, 1, 'star'); } -}; +}); diff --git a/test/function/samples/cross-chunk-live-binding/_config.js b/test/function/samples/cross-chunk-live-binding/_config.js index e598590dda3..ec3f2bf877c 100644 --- a/test/function/samples/cross-chunk-live-binding/_config.js +++ b/test/function/samples/cross-chunk-live-binding/_config.js @@ -1,6 +1,6 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'handles cross-chunk live-bindings', options: { input: ['main.js', 'named.js', 'star.js'] @@ -14,4 +14,4 @@ module.exports = { exports.incrementStar(); assert.equal(exports.star, 1, 'star'); } -}; +}); diff --git a/test/function/samples/custom-external-module-options/_config.js b/test/function/samples/custom-external-module-options/_config.js index eb4a6b4fa9f..0447a5bd051 100644 --- a/test/function/samples/custom-external-module-options/_config.js +++ b/test/function/samples/custom-external-module-options/_config.js @@ -1,6 +1,6 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'supports adding custom options to external modules', options: { plugins: [ @@ -22,4 +22,4 @@ module.exports = { } ] } -}; +}); diff --git a/test/function/samples/custom-external-resolver-async/_config.js b/test/function/samples/custom-external-resolver-async/_config.js index 9676201ebbd..78dc805d4df 100644 --- a/test/function/samples/custom-external-resolver-async/_config.js +++ b/test/function/samples/custom-external-resolver-async/_config.js @@ -1,7 +1,7 @@ -const path = require('path'); -const assert = require('assert'); +const assert = require('node:assert'); +const path = require('node:path'); -module.exports = { +module.exports = defineTest({ description: 'uses a custom external path resolver (asynchronous)', options: { plugins: [ @@ -16,4 +16,4 @@ module.exports = { exports(exports) { assert.ok(exports.success); } -}; +}); diff --git a/test/function/samples/custom-external-resolver-sync/_config.js b/test/function/samples/custom-external-resolver-sync/_config.js index c86de8bf391..f90dba7f7f5 100644 --- a/test/function/samples/custom-external-resolver-sync/_config.js +++ b/test/function/samples/custom-external-resolver-sync/_config.js @@ -1,7 +1,7 @@ -const path = require('path'); -const assert = require('assert'); +const assert = require('node:assert'); +const path = require('node:path'); -module.exports = { +module.exports = defineTest({ description: 'uses a custom external path resolver (synchronous)', options: { plugins: [ @@ -15,4 +15,4 @@ module.exports = { exports(exports) { assert.ok(exports.success); } -}; +}); diff --git a/test/function/samples/custom-iterator-2/_config.js b/test/function/samples/custom-iterator-2/_config.js index 046c68b3d57..5c221ae64b5 100644 --- a/test/function/samples/custom-iterator-2/_config.js +++ b/test/function/samples/custom-iterator-2/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'handles manually defined iterators' -}; +}); diff --git a/test/function/samples/custom-iterator/_config.js b/test/function/samples/custom-iterator/_config.js index 046c68b3d57..5c221ae64b5 100644 --- a/test/function/samples/custom-iterator/_config.js +++ b/test/function/samples/custom-iterator/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'handles manually defined iterators' -}; +}); diff --git a/test/function/samples/custom-loaders/_config.js b/test/function/samples/custom-loaders/_config.js index e2f0cec12b1..d35f66376ce 100644 --- a/test/function/samples/custom-loaders/_config.js +++ b/test/function/samples/custom-loaders/_config.js @@ -1,23 +1,23 @@ -const fs = require('fs'); +const { readFileSync } = require('node:fs'); -module.exports = { +module.exports = defineTest({ description: 'uses custom loaders, falling back to default', options: { plugins: [ { load(id) { if (/foo\.js/.test(id)) { - return fs.readFileSync(id, 'utf-8').replace('@', 1); + return readFileSync(id, 'utf8').replace('@', 1); } } }, { load(id) { if (/bar\.js/.test(id)) { - return fs.readFileSync(id, 'utf-8').replace('@', 2); + return readFileSync(id, 'utf8').replace('@', 2); } } } ] } -}; +}); diff --git a/test/function/samples/custom-module-options/_config.js b/test/function/samples/custom-module-options/_config.js index 8bb4344e691..162add3d59a 100644 --- a/test/function/samples/custom-module-options/_config.js +++ b/test/function/samples/custom-module-options/_config.js @@ -1,4 +1,6 @@ -const assert = require('assert'); +const assert = require('node:assert'); +// @ts-expect-error file outside root +const { getObject } = require('../../../testHelpers'); function getTestPlugin(index) { const pluginName = `test-${index}`; @@ -29,7 +31,7 @@ function getTestPlugin(index) { }; } -module.exports = { +module.exports = defineTest({ description: 'supports adding custom options to modules', options: { plugins: [ @@ -40,28 +42,26 @@ module.exports = { name: 'wrap-up', buildEnd() { assert.deepStrictEqual( - [...this.getModuleIds()] - .filter(id => id.includes('resolve')) - .sort() - .map(id => ({ id, meta: this.getModuleInfo(id).meta })), - [ - { - id: 'resolve1-load2-transform3', - meta: { - 'test-1': { resolved: 1 }, - 'test-2': { loaded: 2 }, - 'test-3': { transformed: 3 } - } + getObject( + [...this.getModuleIds()] + .filter(id => id.includes('resolve')) + .map(id => [id, this.getModuleInfo(id).meta]) + ), + { + 'resolve1-load2-transform3': { + 'test-1': { resolved: 1 }, + 'test-2': { loaded: 2 }, + 'test-3': { transformed: 3 } }, - { - id: 'resolve2-load2-transform3', - meta: { 'test-2': { loaded: 2 }, 'test-3': { transformed: 3 } } + 'resolve2-load2-transform3': { + 'test-2': { loaded: 2 }, + 'test-3': { transformed: 3 } }, - { - id: 'resolve3-load3-transform1-transform3', - meta: { 'test-3': { transformed: 3 }, 'test-1': { transformed: 1 } } + 'resolve3-load3-transform1-transform3': { + 'test-3': { transformed: 3 }, + 'test-1': { transformed: 1 } } - ] + } ); } } @@ -74,4 +74,4 @@ module.exports = { value3: { 'test-3': { loaded: 3 }, 'test-1': { transformed: 1 } } }); } -}; +}); diff --git a/test/function/samples/custom-path-resolver-async/_config.js b/test/function/samples/custom-path-resolver-async/_config.js index 7e568daaaea..85a34e95e8b 100644 --- a/test/function/samples/custom-path-resolver-async/_config.js +++ b/test/function/samples/custom-path-resolver-async/_config.js @@ -1,28 +1,20 @@ -const path = require('path'); -const assert = require('assert'); +const assert = require('node:assert'); +const path = require('node:path'); -module.exports = { +module.exports = defineTest({ description: 'uses a custom path resolver (asynchronous)', options: { plugins: [ { - resolveId(importee, importer) { - let resolved; - + resolveId(importee) { if (path.normalize(importee) === path.join(__dirname, 'main.js')) return importee; - if (importee === 'foo') { - resolved = path.join(__dirname, 'bar.js'); - } else { - resolved = false; - } - - return Promise.resolve(resolved); + return Promise.resolve(importee === 'foo' ? path.join(__dirname, 'bar.js') : false); } } ] }, exports(exports) { - assert.strictEqual(exports.path, require('path')); + assert.strictEqual(exports.path, require('node:path')); } -}; +}); diff --git a/test/function/samples/custom-path-resolver-on-entry/_config.js b/test/function/samples/custom-path-resolver-on-entry/_config.js index fe037e6ab7d..a525fbffc30 100644 --- a/test/function/samples/custom-path-resolver-on-entry/_config.js +++ b/test/function/samples/custom-path-resolver-on-entry/_config.js @@ -1,12 +1,12 @@ -const path = require('path'); -const fs = require('fs'); -const assert = require('assert'); +const assert = require('node:assert'); +const { readFileSync } = require('node:fs'); +const path = require('node:path'); const cachedModules = { '@main.js': 'import foo from "./foo"; export default foo();' }; -module.exports = { +module.exports = defineTest({ description: 'applies custom resolver to entry point', options: { plugins: [ @@ -25,7 +25,7 @@ module.exports = { return cachedModules[moduleId]; } - return fs.readFileSync(moduleId, 'utf-8'); + return readFileSync(moduleId, 'utf8'); } } ] @@ -33,4 +33,4 @@ module.exports = { exports(exports) { assert.equal(exports, 42); } -}; +}); diff --git a/test/function/samples/custom-path-resolver-plural-b/_config.js b/test/function/samples/custom-path-resolver-plural-b/_config.js index ea7f6ca023c..f3313f15046 100644 --- a/test/function/samples/custom-path-resolver-plural-b/_config.js +++ b/test/function/samples/custom-path-resolver-plural-b/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'resolver error is not caught', options: { plugins: [ @@ -11,7 +11,7 @@ module.exports = { } }, { - resolveId(importee, importer) { + resolveId() { return 'main'; } } @@ -23,4 +23,4 @@ module.exports = { message: 'nope', plugin: 'at position 1' } -}; +}); diff --git a/test/function/samples/custom-path-resolver-plural/_config.js b/test/function/samples/custom-path-resolver-plural/_config.js index e95e1b1885a..44b535d3e31 100644 --- a/test/function/samples/custom-path-resolver-plural/_config.js +++ b/test/function/samples/custom-path-resolver-plural/_config.js @@ -1,7 +1,7 @@ -const path = require('path'); -const assert = require('assert'); +const assert = require('node:assert'); +const path = require('node:path'); -module.exports = { +module.exports = defineTest({ description: 'uses custom path resolvers (plural)', options: { plugins: [ @@ -24,4 +24,4 @@ module.exports = { exports(exports) { assert.strictEqual(exports.res, 0); } -}; +}); diff --git a/test/function/samples/custom-path-resolver-sync/_config.js b/test/function/samples/custom-path-resolver-sync/_config.js index 373cb3f0049..4961137da1b 100644 --- a/test/function/samples/custom-path-resolver-sync/_config.js +++ b/test/function/samples/custom-path-resolver-sync/_config.js @@ -1,12 +1,12 @@ -const path = require('path'); -const assert = require('assert'); +const assert = require('node:assert'); +const path = require('node:path'); -module.exports = { +module.exports = defineTest({ description: 'uses a custom path resolver (synchronous)', options: { plugins: [ { - resolveId(importee, importer) { + resolveId(importee) { if (path.normalize(importee) === path.join(__dirname, 'main.js')) return importee; if (importee === 'foo') return path.join(__dirname, 'bar.js'); @@ -16,6 +16,6 @@ module.exports = { ] }, exports(exports) { - assert.strictEqual(exports.path, require('path')); + assert.strictEqual(exports.path, require('node:path')); } -}; +}); diff --git a/test/function/samples/custom-resolve-options/_config.js b/test/function/samples/custom-resolve-options/_config.js index 88d95c3c8a9..7828849764e 100644 --- a/test/function/samples/custom-resolve-options/_config.js +++ b/test/function/samples/custom-resolve-options/_config.js @@ -1,7 +1,7 @@ -const assert = require('assert'); -const path = require('path'); +const assert = require('node:assert'); +const path = require('node:path'); -module.exports = { +module.exports = defineTest({ description: 'supports custom resolve options', options: { plugins: [ @@ -34,4 +34,4 @@ module.exports = { second: 'the-actual-id' }); } -}; +}); diff --git a/test/function/samples/cycles-default-anonymous-function-hoisted/_config.js b/test/function/samples/cycles-default-anonymous-function-hoisted/_config.js index 60e42dcfb98..60e599ad677 100644 --- a/test/function/samples/cycles-default-anonymous-function-hoisted/_config.js +++ b/test/function/samples/cycles-default-anonymous-function-hoisted/_config.js @@ -1,11 +1,14 @@ -module.exports = { +const path = require('node:path'); +const ID_F = path.join(__dirname, 'f.js'); +const ID_G = path.join(__dirname, 'g.js'); + +module.exports = defineTest({ description: 'Anonymous function declarations are hoisted', warnings: [ { code: 'CIRCULAR_DEPENDENCY', - cycle: ['f.js', 'g.js', 'f.js'], - importer: 'f.js', + ids: [ID_F, ID_G, ID_F], message: 'Circular dependency: f.js -> g.js -> f.js' } ] -}; +}); diff --git a/test/function/samples/cycles-defaults/_config.js b/test/function/samples/cycles-defaults/_config.js index 84969a977d2..5c472c4ef87 100644 --- a/test/function/samples/cycles-defaults/_config.js +++ b/test/function/samples/cycles-defaults/_config.js @@ -1,13 +1,16 @@ -module.exports = { +const path = require('node:path'); +const ID_A = path.join(__dirname, 'a.js'); +const ID_B = path.join(__dirname, 'b.js'); + +module.exports = defineTest({ description: 'cycles work with default exports', warnings: [ { code: 'CIRCULAR_DEPENDENCY', - cycle: ['a.js', 'b.js', 'a.js'], - importer: 'a.js', + ids: [ID_A, ID_B, ID_A], message: 'Circular dependency: a.js -> b.js -> a.js' } ] -}; +}); // test copied from https://github.com/esnext/es6-module-transpiler/tree/master/test/examples/cycles-defaults diff --git a/test/function/samples/cycles-export-star/_config.js b/test/function/samples/cycles-export-star/_config.js index b1f63718246..0396bfbca73 100644 --- a/test/function/samples/cycles-export-star/_config.js +++ b/test/function/samples/cycles-export-star/_config.js @@ -1,6 +1,9 @@ -const assert = require('assert'); +const assert = require('node:assert'); +const path = require('node:path'); +const ID_A = path.join(__dirname, 'a.js'); +const ID_B = path.join(__dirname, 'b.js'); -module.exports = { +module.exports = defineTest({ description: 'does not stack overflow on `export * from X` cycles', code(code) { assert.equal( @@ -11,9 +14,8 @@ module.exports = { warnings: [ { code: 'CIRCULAR_DEPENDENCY', - cycle: ['a.js', 'b.js', 'a.js'], - importer: 'a.js', + ids: [ID_A, ID_B, ID_A], message: 'Circular dependency: a.js -> b.js -> a.js' } ] -}; +}); diff --git a/test/function/samples/cycles-immediate/_config.js b/test/function/samples/cycles-immediate/_config.js index 8c4b9235fd3..2464a9d2bfc 100644 --- a/test/function/samples/cycles-immediate/_config.js +++ b/test/function/samples/cycles-immediate/_config.js @@ -1,13 +1,16 @@ -module.exports = { +const path = require('node:path'); +const ID_EVENS = path.join(__dirname, 'evens.js'); +const ID_ODDS = path.join(__dirname, 'odds.js'); + +module.exports = defineTest({ description: 'handles cycles where imports are immediately used', warnings: [ { code: 'CIRCULAR_DEPENDENCY', - cycle: ['evens.js', 'odds.js', 'evens.js'], - importer: 'evens.js', + ids: [ID_EVENS, ID_ODDS, ID_EVENS], message: 'Circular dependency: evens.js -> odds.js -> evens.js' } ] -}; +}); // Test copied from https://github.com/esnext/es6-module-transpiler/tree/master/test/examples/cycles-immediate diff --git a/test/function/samples/cycles-pathological-2/_config.js b/test/function/samples/cycles-pathological-2/_config.js index e57e6d43318..3856aa83021 100644 --- a/test/function/samples/cycles-pathological-2/_config.js +++ b/test/function/samples/cycles-pathological-2/_config.js @@ -1,23 +1,26 @@ -module.exports = { +const path = require('node:path'); +const ID_MAIN = path.join(__dirname, 'main.js'); +const ID_B = path.join(__dirname, 'b.js'); +const ID_C = path.join(__dirname, 'c.js'); +const ID_D = path.join(__dirname, 'd.js'); + +module.exports = defineTest({ description: 'resolves even more pathological cyclical dependencies gracefully', warnings: [ { code: 'CIRCULAR_DEPENDENCY', - cycle: ['main.js', 'b.js', 'main.js'], - importer: 'main.js', + ids: [ID_MAIN, ID_B, ID_MAIN], message: 'Circular dependency: main.js -> b.js -> main.js' }, { code: 'CIRCULAR_DEPENDENCY', - cycle: ['b.js', 'd.js', 'c.js', 'b.js'], - importer: 'b.js', + ids: [ID_B, ID_D, ID_C, ID_B], message: 'Circular dependency: b.js -> d.js -> c.js -> b.js' }, { code: 'CIRCULAR_DEPENDENCY', - cycle: ['main.js', 'b.js', 'd.js', 'c.js', 'main.js'], - importer: 'main.js', + ids: [ID_MAIN, ID_B, ID_D, ID_C, ID_MAIN], message: 'Circular dependency: main.js -> b.js -> d.js -> c.js -> main.js' } ] -}; +}); diff --git a/test/function/samples/cycles-stack-overflow/_config.js b/test/function/samples/cycles-stack-overflow/_config.js index 7c01540e491..24dc31d12ca 100644 --- a/test/function/samples/cycles-stack-overflow/_config.js +++ b/test/function/samples/cycles-stack-overflow/_config.js @@ -1,17 +1,20 @@ -module.exports = { +const path = require('node:path'); +const ID_B = path.join(__dirname, 'b.js'); +const ID_C = path.join(__dirname, 'c.js'); +const ID_D = path.join(__dirname, 'd.js'); + +module.exports = defineTest({ description: 'does not stack overflow on crazy cyclical dependencies', warnings: [ { code: 'CIRCULAR_DEPENDENCY', - cycle: ['c.js', 'd.js', 'b.js', 'c.js'], - importer: 'c.js', + ids: [ID_C, ID_D, ID_B, ID_C], message: 'Circular dependency: c.js -> d.js -> b.js -> c.js' }, { code: 'CIRCULAR_DEPENDENCY', - cycle: ['c.js', 'd.js', 'c.js'], - importer: 'c.js', + ids: [ID_C, ID_D, ID_C], message: 'Circular dependency: c.js -> d.js -> c.js' } ] -}; +}); diff --git a/test/function/samples/cyclic-assignments/_config.js b/test/function/samples/cyclic-assignments/_config.js index ca96493478d..26be52cb8e7 100644 --- a/test/function/samples/cyclic-assignments/_config.js +++ b/test/function/samples/cyclic-assignments/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'does not fail for cyclic assignments' -}; +}); diff --git a/test/function/samples/deconflict-deconflicted/_config.js b/test/function/samples/deconflict-deconflicted/_config.js index a3fcda5c37c..2e2ed2b323d 100644 --- a/test/function/samples/deconflict-deconflicted/_config.js +++ b/test/function/samples/deconflict-deconflicted/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'also deconflict variables which already appear to be deconflicted (#2683)' -}; +}); diff --git a/test/function/samples/deconflict-default-exported-named-function/_config.js b/test/function/samples/deconflict-default-exported-named-function/_config.js index 20c051e2287..30ff2e3b248 100644 --- a/test/function/samples/deconflict-default-exported-named-function/_config.js +++ b/test/function/samples/deconflict-default-exported-named-function/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'deconflict default exported named function and class expressions' -}; +}); diff --git a/test/function/samples/deconflict-ids/_config.js b/test/function/samples/deconflict-ids/_config.js index 0d91c9ee299..7e5ede0433f 100644 --- a/test/function/samples/deconflict-ids/_config.js +++ b/test/function/samples/deconflict-ids/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'deconflicts reassigned ids' -}; +}); diff --git a/test/function/samples/deconflict-parameter-defaults/_config.js b/test/function/samples/deconflict-parameter-defaults/_config.js index dcba432ae02..b81ed6af1b6 100644 --- a/test/function/samples/deconflict-parameter-defaults/_config.js +++ b/test/function/samples/deconflict-parameter-defaults/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'consistently deconflict variable names for parameter defaults' -}; +}); diff --git a/test/function/samples/deconflict-synthetic-named-export-cross-chunk/_config.js b/test/function/samples/deconflict-synthetic-named-export-cross-chunk/_config.js index 17d415a72aa..cd8c4b600a5 100644 --- a/test/function/samples/deconflict-synthetic-named-export-cross-chunk/_config.js +++ b/test/function/samples/deconflict-synthetic-named-export-cross-chunk/_config.js @@ -1,6 +1,6 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'deconflicts synthetic named exports across chunks', options: { input: ['main', 'foo'], @@ -16,4 +16,4 @@ module.exports = { exports(exports) { assert.strictEqual(exports(2), 4); } -}; +}); diff --git a/test/function/samples/deconflict-synthetic-named-export/_config.js b/test/function/samples/deconflict-synthetic-named-export/_config.js index c81939d2267..d101643e5c0 100644 --- a/test/function/samples/deconflict-synthetic-named-export/_config.js +++ b/test/function/samples/deconflict-synthetic-named-export/_config.js @@ -1,6 +1,6 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'deconflicts synthetic named exports', options: { plugins: [ @@ -14,4 +14,4 @@ module.exports = { exports(exports) { assert.strictEqual(exports(2), 4); } -}; +}); diff --git a/test/function/samples/deconflicts-classes/_config.js b/test/function/samples/deconflicts-classes/_config.js index ee66bd1122b..af419d4f56c 100644 --- a/test/function/samples/deconflicts-classes/_config.js +++ b/test/function/samples/deconflicts-classes/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'deconflicts top-level classes' -}; +}); diff --git a/test/function/samples/deconflicts-exports-2/_config.js b/test/function/samples/deconflicts-exports-2/_config.js index 4847f2e53b6..5f401c8582f 100644 --- a/test/function/samples/deconflicts-exports-2/_config.js +++ b/test/function/samples/deconflicts-exports-2/_config.js @@ -1,8 +1,8 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'renames nested variables named "exports" if necessary', exports(exports) { assert.equal(exports.x, 2); } -}; +}); diff --git a/test/function/samples/deconflicts-exports-3/_config.js b/test/function/samples/deconflicts-exports-3/_config.js index 880946bafe3..51492dda6d0 100644 --- a/test/function/samples/deconflicts-exports-3/_config.js +++ b/test/function/samples/deconflicts-exports-3/_config.js @@ -1,8 +1,8 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'renames variables named "module" if necessary', exports(exports) { assert.equal(exports, 1); } -}; +}); diff --git a/test/function/samples/deconflicts-exports/_config.js b/test/function/samples/deconflicts-exports/_config.js index 60fb3ef5dc4..d625077df69 100644 --- a/test/function/samples/deconflicts-exports/_config.js +++ b/test/function/samples/deconflicts-exports/_config.js @@ -1,10 +1,10 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'renames variables named "exports" if necessary', exports(exports) { assert.deepEqual(Object.keys(exports), ['a', 'b']); assert.equal(exports.a, 'A'); assert.equal(exports.b, 42); } -}; +}); diff --git a/test/function/samples/deconflicts-external-imports/_config.js b/test/function/samples/deconflicts-external-imports/_config.js index ae1586cbaf4..458adc6a05c 100644 --- a/test/function/samples/deconflicts-external-imports/_config.js +++ b/test/function/samples/deconflicts-external-imports/_config.js @@ -1,8 +1,8 @@ -module.exports = { +module.exports = defineTest({ description: 'deconflicts external imports', context: { require(id) { - return function() { + return function () { return id; }; } @@ -10,4 +10,4 @@ module.exports = { options: { external: ['foo', 'bar'] } -}; +}); diff --git a/test/function/samples/deconflicts-generated-default-names/_config.js b/test/function/samples/deconflicts-generated-default-names/_config.js index ebf4a0748f9..ee6eca2098c 100644 --- a/test/function/samples/deconflicts-generated-default-names/_config.js +++ b/test/function/samples/deconflicts-generated-default-names/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'deconflicts generated default export names' -}; +}); diff --git a/test/function/samples/deconflicts-globals/_config.js b/test/function/samples/deconflicts-globals/_config.js index 360ce512dc9..d6a0ce092f1 100644 --- a/test/function/samples/deconflicts-globals/_config.js +++ b/test/function/samples/deconflicts-globals/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'deconflicts names that are assumed to be global' -}; +}); diff --git a/test/function/samples/deconflicts-interop/_config.js b/test/function/samples/deconflicts-interop/_config.js index ba24715b9d6..bd5f4665e8e 100644 --- a/test/function/samples/deconflicts-interop/_config.js +++ b/test/function/samples/deconflicts-interop/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'deconflicts the interop function', options: { external(id) { @@ -8,21 +8,24 @@ module.exports = { interop(id) { switch (id) { case 'external1': - case 'external2': + case 'external2': { return 'auto'; - case 'external3': + } + case 'external3': { return 'default'; - case 'external4': + } + case 'external4': { return 'defaultOnly'; - default: + } + default: { throw new Error(`Unexpected require "${id}"`); + } } } } }, context: { - require: id => { - return Object.defineProperty({ foo: 'foo', default: 'bar' }, '__esModule', { value: true }); - } + require: () => + Object.defineProperty({ foo: 'foo', default: 'bar' }, '__esModule', { value: true }) } -}; +}); diff --git a/test/function/samples/deconstructed-exported-vars/_config.js b/test/function/samples/deconstructed-exported-vars/_config.js index 34c4dced654..4570f1fb17e 100644 --- a/test/function/samples/deconstructed-exported-vars/_config.js +++ b/test/function/samples/deconstructed-exported-vars/_config.js @@ -1,9 +1,9 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'allows destructuring in exported variable declarations, synthetic or otherwise', exports(exports) { assert.equal(exports.a, 1); assert.equal(exports.d, 4); } -}; +}); diff --git a/test/function/samples/default-export-as-is-bound/_config.js b/test/function/samples/default-export-as-is-bound/_config.js index 87d11362eae..9608b0e29ad 100644 --- a/test/function/samples/default-export-as-is-bound/_config.js +++ b/test/function/samples/default-export-as-is-bound/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'does bind export as default (#1078)' -}; +}); diff --git a/test/function/samples/default-export-before-declaration/_config.js b/test/function/samples/default-export-before-declaration/_config.js new file mode 100644 index 00000000000..e42ecbbad56 --- /dev/null +++ b/test/function/samples/default-export-before-declaration/_config.js @@ -0,0 +1,8 @@ +const assert = require('node:assert'); + +module.exports = defineTest({ + description: 'handles default exports before a variable is declared', + exports(exports) { + assert.strictEqual(exports, undefined); + } +}); diff --git a/test/function/samples/default-export-before-declaration/main.js b/test/function/samples/default-export-before-declaration/main.js new file mode 100644 index 00000000000..83d89bb4ea4 --- /dev/null +++ b/test/function/samples/default-export-before-declaration/main.js @@ -0,0 +1,2 @@ +export default foo; +var foo = true; diff --git a/test/function/samples/default-export-is-not-bound-b/_config.js b/test/function/samples/default-export-is-not-bound-b/_config.js index 807e41fe74c..67004d32d3e 100644 --- a/test/function/samples/default-export-is-not-bound-b/_config.js +++ b/test/function/samples/default-export-is-not-bound-b/_config.js @@ -1,8 +1,8 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'does not move default export statement above earlier statements', exports(exports) { assert.equal(exports.bar, 42); } -}; +}); diff --git a/test/function/samples/default-export-is-not-bound/_config.js b/test/function/samples/default-export-is-not-bound/_config.js index ca098561546..b62fbbd867e 100644 --- a/test/function/samples/default-export-is-not-bound/_config.js +++ b/test/function/samples/default-export-is-not-bound/_config.js @@ -1,5 +1,5 @@ -module.exports = { +module.exports = defineTest({ description: 'does not bind default exports' -}; +}); // test copied from https://github.com/esnext/es6-module-transpiler/tree/master/test/examples/export-default diff --git a/test/function/samples/default-export-with-null-prototype/_config.js b/test/function/samples/default-export-with-null-prototype/_config.js index 8912ca75d4c..2121ec23792 100644 --- a/test/function/samples/default-export-with-null-prototype/_config.js +++ b/test/function/samples/default-export-with-null-prototype/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'default exports of objects with null prototypes are supported', options: { external: ['foo'], @@ -15,4 +15,4 @@ module.exports = { } ] } -}; +}); diff --git a/test/function/samples/default-exported-global/_config.js b/test/function/samples/default-exported-global/_config.js index 1a0b229828e..4c5557f41a0 100644 --- a/test/function/samples/default-exported-global/_config.js +++ b/test/function/samples/default-exported-global/_config.js @@ -1,8 +1,8 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'Tracks updates of default exported globals', exports(exports) { assert.deepStrictEqual(exports, { original: 1, updated: 2 }); } -}; +}); diff --git a/test/function/samples/default-exports-in-parens-class-with-id/_config.js b/test/function/samples/default-exports-in-parens-class-with-id/_config.js index 464d56a7ca3..a7e97bb5338 100644 --- a/test/function/samples/default-exports-in-parens-class-with-id/_config.js +++ b/test/function/samples/default-exports-in-parens-class-with-id/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'handles default class with id exports wrapped in parens' -}; +}); diff --git a/test/function/samples/default-exports-in-parens-class-without-id/_config.js b/test/function/samples/default-exports-in-parens-class-without-id/_config.js index bbde1c72917..a632ab6a4f7 100644 --- a/test/function/samples/default-exports-in-parens-class-without-id/_config.js +++ b/test/function/samples/default-exports-in-parens-class-without-id/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'handles default class without id exports wrapped in parens' -}; +}); diff --git a/test/function/samples/default-exports-in-parens-function-with-id/_config.js b/test/function/samples/default-exports-in-parens-function-with-id/_config.js index bc7b8f3b5ea..b76523bd897 100644 --- a/test/function/samples/default-exports-in-parens-function-with-id/_config.js +++ b/test/function/samples/default-exports-in-parens-function-with-id/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'handles default function with id exports wrapped in parens' -}; +}); diff --git a/test/function/samples/default-exports-in-parens-function-without-id/_config.js b/test/function/samples/default-exports-in-parens-function-without-id/_config.js index 1d26a7d399f..9c0d16b8881 100644 --- a/test/function/samples/default-exports-in-parens-function-without-id/_config.js +++ b/test/function/samples/default-exports-in-parens-function-without-id/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'handles default function without id exports wrapped in parens' -}; +}); diff --git a/test/function/samples/default-function-export-conflict/_config.js b/test/function/samples/default-function-export-conflict/_config.js index d062e00bd7e..7934a8be019 100644 --- a/test/function/samples/default-function-export-conflict/_config.js +++ b/test/function/samples/default-function-export-conflict/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'default export of anonymous function' -}; +}); diff --git a/test/function/samples/default-not-reexported/_config.js b/test/function/samples/default-not-reexported/_config.js index 9849876b116..c1807d5c2a7 100644 --- a/test/function/samples/default-not-reexported/_config.js +++ b/test/function/samples/default-not-reexported/_config.js @@ -1,19 +1,20 @@ -const path = require('path'); +const path = require('node:path'); +const ID_MAIN = path.join(__dirname, 'main.js'); +const ID_FOO = path.join(__dirname, 'foo.js'); +const ID_BAR = path.join(__dirname, 'bar.js'); -module.exports = { +module.exports = defineTest({ description: 'default export is not re-exported with export *', error: { + binding: 'default', code: 'MISSING_EXPORT', - message: `'default' is not exported by foo.js, imported by main.js`, - id: path.join(__dirname, 'main.js'), + exporter: ID_FOO, + message: 'main.js (1:7): "default" is not exported by "foo.js", imported by "main.js".', + id: ID_MAIN, pos: 7, - watchFiles: [ - path.join(__dirname, 'main.js'), - path.join(__dirname, 'foo.js'), - path.join(__dirname, 'bar.js') - ], + watchFiles: [ID_BAR, ID_FOO, ID_MAIN], loc: { - file: path.join(__dirname, 'main.js'), + file: ID_MAIN, line: 1, column: 7 }, @@ -23,6 +24,6 @@ module.exports = { 2: 3: console.log( def ); `, - url: `https://rollupjs.org/guide/en/#error-name-is-not-exported-by-module` + url: `https://rollupjs.org/troubleshooting/#error-name-is-not-exported-by-module` } -}; +}); diff --git a/test/function/samples/default-on-warn/_config.js b/test/function/samples/default-on-warn/_config.js deleted file mode 100644 index 2ad6c83bb07..00000000000 --- a/test/function/samples/default-on-warn/_config.js +++ /dev/null @@ -1,27 +0,0 @@ -const assert = require('assert'); -let oldConsoleWarn; -const warnings = []; - -module.exports = { - description: 'provides a default handler for warnings to onwarn that handles strings and objects', - options: { - onwarn(warning, defaultHandler) { - if (warning.code === 'EVAL') { - defaultHandler(warning); - } else { - defaultHandler(warning.message); - } - } - }, - before() { - oldConsoleWarn = console.warn; - console.warn = msg => warnings.push(msg); - }, - after() { - console.warn = oldConsoleWarn; - assert.deepStrictEqual(warnings, [ - 'Use of eval is strongly discouraged, as it poses security risks and may cause issues with minification', - 'Entry module "main.js" is using named and default exports together. Consumers of your bundle will have to use `chunk["default"]` to access the default export, which may not be what you want. Use `output.exports: "named"` to disable this warning' - ]); - } -}; diff --git a/test/function/samples/default-on-warn/main.js b/test/function/samples/default-on-warn/main.js deleted file mode 100644 index dbf5aa85027..00000000000 --- a/test/function/samples/default-on-warn/main.js +++ /dev/null @@ -1,2 +0,0 @@ -export const x = eval('42'); -export default 42; diff --git a/test/function/samples/define-property-side-effect-on-local/_config.js b/test/function/samples/define-property-side-effect-on-local/_config.js new file mode 100644 index 00000000000..c8dd2853fc6 --- /dev/null +++ b/test/function/samples/define-property-side-effect-on-local/_config.js @@ -0,0 +1,4 @@ +module.exports = defineTest({ + description: + 'includes side effects from Object.defineProperty on a local variable assigned to a property' +}); diff --git a/test/function/samples/define-property-side-effect-on-local/main.js b/test/function/samples/define-property-side-effect-on-local/main.js new file mode 100644 index 00000000000..03dd355eddb --- /dev/null +++ b/test/function/samples/define-property-side-effect-on-local/main.js @@ -0,0 +1,5 @@ +const obj = {}; +const local = (obj.a = {}); +Object.defineProperty(local, 'b', { value: 42 }); + +assert.equal(obj.a.b, 42); diff --git a/test/function/samples/delete/_config.js b/test/function/samples/delete/_config.js index 3495183e618..6a64667ef0b 100644 --- a/test/function/samples/delete/_config.js +++ b/test/function/samples/delete/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: '`delete` operator at the top level is preserved' -}; +}); diff --git a/test/function/samples/deoptimize-assumes-getters/_config.js b/test/function/samples/deoptimize-assumes-getters/_config.js new file mode 100644 index 00000000000..78bb505bb7e --- /dev/null +++ b/test/function/samples/deoptimize-assumes-getters/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'assume full deoptimization may inject side-effectful getters' +}); diff --git a/test/function/samples/deoptimize-assumes-getters/main.js b/test/function/samples/deoptimize-assumes-getters/main.js new file mode 100644 index 00000000000..c11b529a8ff --- /dev/null +++ b/test/function/samples/deoptimize-assumes-getters/main.js @@ -0,0 +1,14 @@ +const obj = {}; +addGetter(obj); + +let mutated = false; +obj.prop; +assert.ok(mutated); + +function addGetter(o) { + Object.defineProperty(o, 'prop', { + get() { + mutated = true; + } + }); +} diff --git a/test/function/samples/deoptimize-cached-prop/_config.js b/test/function/samples/deoptimize-cached-prop/_config.js index 5bffd221ee2..0044a4af351 100644 --- a/test/function/samples/deoptimize-cached-prop/_config.js +++ b/test/function/samples/deoptimize-cached-prop/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'deoptimizes cached properties and return values if necessary (#3264)' -}; +}); diff --git a/test/function/samples/deoptimize-call-expression-reassignments/_config.js b/test/function/samples/deoptimize-call-expression-reassignments/_config.js index 43137f61764..a464b295af1 100644 --- a/test/function/samples/deoptimize-call-expression-reassignments/_config.js +++ b/test/function/samples/deoptimize-call-expression-reassignments/_config.js @@ -1,3 +1,4 @@ -module.exports = { - description: 'deoptimizes call expressions of conditional expressions if their return value is reassigned' -}; +module.exports = defineTest({ + description: + 'deoptimizes call expressions of conditional expressions if their return value is reassigned' +}); diff --git a/test/function/samples/deoptimize-call-expressions/_config.js b/test/function/samples/deoptimize-call-expressions/_config.js index 3a29c368ab9..50faf79d57b 100644 --- a/test/function/samples/deoptimize-call-expressions/_config.js +++ b/test/function/samples/deoptimize-call-expressions/_config.js @@ -1,3 +1,4 @@ -module.exports = { - description: 'deoptimizes call expressions conditional expressions if their return value is reassigned' -}; +module.exports = defineTest({ + description: + 'deoptimizes call expressions conditional expressions if their return value is reassigned' +}); diff --git a/test/function/samples/deoptimize-class/_config.js b/test/function/samples/deoptimize-class/_config.js new file mode 100644 index 00000000000..e92d39ee268 --- /dev/null +++ b/test/function/samples/deoptimize-class/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'handles deoptimization of static class properties' +}); diff --git a/test/function/samples/deoptimize-class/main.js b/test/function/samples/deoptimize-class/main.js new file mode 100644 index 00000000000..f67b5d66413 --- /dev/null +++ b/test/function/samples/deoptimize-class/main.js @@ -0,0 +1,20 @@ +let trueProp = 'old'; +let falseProp = 'new'; + +function getClass() { + return class { + static [trueProp]() { + return true; + } + static [falseProp]() { + return false; + } + }; +} + +if (!getClass().old()) throw new Error('old missing'); +if (getClass().new()) throw new Error('new present'); +trueProp = 'new'; +falseProp = 'old'; +if (getClass().old()) throw new Error('old present'); +if (!getClass().new()) throw new Error('new missing'); diff --git a/test/function/samples/deoptimize-computed-class-keys/_config.js b/test/function/samples/deoptimize-computed-class-keys/_config.js new file mode 100644 index 00000000000..328acfdc0db --- /dev/null +++ b/test/function/samples/deoptimize-computed-class-keys/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'deoptimizes computed class property keys' +}); diff --git a/test/function/samples/deoptimize-computed-class-keys/main.js b/test/function/samples/deoptimize-computed-class-keys/main.js new file mode 100644 index 00000000000..bad340b2305 --- /dev/null +++ b/test/function/samples/deoptimize-computed-class-keys/main.js @@ -0,0 +1,17 @@ +var key1 = 'x'; +var key2 = 'y'; + +changeKeys(); + +class Foo { + static [key1] = true; + static [key2] = false; +} + +assert.strictEqual(Foo.x, false); +assert.strictEqual(Foo.y, true); + +function changeKeys() { + key1 = 'y'; + key2 = 'x'; +} diff --git a/test/function/samples/deoptimize-computed-keys/_config.js b/test/function/samples/deoptimize-computed-keys/_config.js new file mode 100644 index 00000000000..f9dcf153b0d --- /dev/null +++ b/test/function/samples/deoptimize-computed-keys/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'deoptimizes computed object property keys' +}); diff --git a/test/function/samples/deoptimize-computed-keys/main.js b/test/function/samples/deoptimize-computed-keys/main.js new file mode 100644 index 00000000000..273087a4e6a --- /dev/null +++ b/test/function/samples/deoptimize-computed-keys/main.js @@ -0,0 +1,14 @@ +var key1 = 'x' +var key2 = 'y' + +changeKeys(); + +var foo = { [key1]: true, [key2]: false }; + +assert.strictEqual(foo.x, false); +assert.strictEqual(foo.y, true); + +function changeKeys() { + key1 = 'y' + key2 = 'x' +} \ No newline at end of file diff --git a/test/function/samples/deoptimize-conditional-expression-reassignments/_config.js b/test/function/samples/deoptimize-conditional-expression-reassignments/_config.js index 61dd10aee3b..866f6cf2787 100644 --- a/test/function/samples/deoptimize-conditional-expression-reassignments/_config.js +++ b/test/function/samples/deoptimize-conditional-expression-reassignments/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'tracks reassignments of deoptimized conditional expressions' -}; +}); diff --git a/test/function/samples/deoptimize-conditional-expressions/_config.js b/test/function/samples/deoptimize-conditional-expressions/_config.js index d7cd37d7ce8..a09e621dc55 100644 --- a/test/function/samples/deoptimize-conditional-expressions/_config.js +++ b/test/function/samples/deoptimize-conditional-expressions/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'keeps conditional expressions if their test value is reassigned' -}; +}); diff --git a/test/function/samples/deoptimize-logical-expression-reassignments/_config.js b/test/function/samples/deoptimize-logical-expression-reassignments/_config.js index 8626c0b4ffa..83b50025e9a 100644 --- a/test/function/samples/deoptimize-logical-expression-reassignments/_config.js +++ b/test/function/samples/deoptimize-logical-expression-reassignments/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'tracks reassignments of deoptimized logical expressions' -}; +}); diff --git a/test/function/samples/deoptimize-logical-expressions-2/_config.js b/test/function/samples/deoptimize-logical-expressions-2/_config.js new file mode 100644 index 00000000000..caecfee232d --- /dev/null +++ b/test/function/samples/deoptimize-logical-expressions-2/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'Successfully built despite the deoptimization of a logical expression' +}); diff --git a/test/function/samples/deoptimize-logical-expressions-2/main.js b/test/function/samples/deoptimize-logical-expressions-2/main.js new file mode 100644 index 00000000000..13475f872dd --- /dev/null +++ b/test/function/samples/deoptimize-logical-expressions-2/main.js @@ -0,0 +1,8 @@ +function foo() { + return bar || 'a'; +} +let bar = true; +export default function () { + bar = false; + return foo() !== 'b' || (foo() == 'c' && foo() == 'd'); +} diff --git a/test/function/samples/deoptimize-logical-expressions/_config.js b/test/function/samples/deoptimize-logical-expressions/_config.js index fbdb65233c4..a73192c1f97 100644 --- a/test/function/samples/deoptimize-logical-expressions/_config.js +++ b/test/function/samples/deoptimize-logical-expressions/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'keeps logical expressions if the first part is reassigned' -}; +}); diff --git a/test/function/samples/deoptimize-loop-element/_config.js b/test/function/samples/deoptimize-loop-element/_config.js new file mode 100644 index 00000000000..dcfdd76b0b2 --- /dev/null +++ b/test/function/samples/deoptimize-loop-element/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'deoptimizes the loop element when it is reassigned' +}); diff --git a/test/function/samples/deoptimize-loop-element/main.js b/test/function/samples/deoptimize-loop-element/main.js new file mode 100644 index 00000000000..a5a0d0d5edb --- /dev/null +++ b/test/function/samples/deoptimize-loop-element/main.js @@ -0,0 +1,7 @@ +const foo = [{ value: 1 }]; + +for (const item of foo) { + item.value = 0; +} + +assert.ok(foo[0].value === 0 ? true : false); diff --git a/test/function/samples/deoptimize-member-expressions/_config.js b/test/function/samples/deoptimize-member-expressions/_config.js index ccd60b17f58..c79a8b71f2a 100644 --- a/test/function/samples/deoptimize-member-expressions/_config.js +++ b/test/function/samples/deoptimize-member-expressions/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'keeps accesses to computed properties if their key is reassigned' -}; +}); diff --git a/test/function/samples/deoptimize-missing-namespace-members/_config.js b/test/function/samples/deoptimize-missing-namespace-members/_config.js new file mode 100644 index 00000000000..e68ea27ed9b --- /dev/null +++ b/test/function/samples/deoptimize-missing-namespace-members/_config.js @@ -0,0 +1,8 @@ +const assert = require('node:assert'); + +module.exports = defineTest({ + description: 'handles deoptimization of non-existing namespace members', + exports(exports) { + assert.strictEqual(exports.bar, undefined); + } +}); diff --git a/test/function/samples/deoptimize-missing-namespace-members/main.js b/test/function/samples/deoptimize-missing-namespace-members/main.js new file mode 100644 index 00000000000..fff92bced04 --- /dev/null +++ b/test/function/samples/deoptimize-missing-namespace-members/main.js @@ -0,0 +1,4 @@ +import * as ns from './other.js'; + +const foo = 'foo'; +export const bar = ns[foo]; diff --git a/test/function/samples/deoptimize-missing-namespace-members/other.js b/test/function/samples/deoptimize-missing-namespace-members/other.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/function/samples/deoptimize-nested-function-arg/_config.js b/test/function/samples/deoptimize-nested-function-arg/_config.js new file mode 100644 index 00000000000..c35dc775cb0 --- /dev/null +++ b/test/function/samples/deoptimize-nested-function-arg/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'deoptimizes call arguments to functions nested in function properties' +}); diff --git a/test/function/samples/deoptimize-nested-function-arg/main.js b/test/function/samples/deoptimize-nested-function-arg/main.js new file mode 100644 index 00000000000..ce66ae7454b --- /dev/null +++ b/test/function/samples/deoptimize-nested-function-arg/main.js @@ -0,0 +1,8 @@ +function test() {} + +test.mutate = a => (a.mutated = true); + +const obj = { mutated: false }; +test.mutate(obj); + +assert.strictEqual(obj.mutated ? 'OK' : 'FAIL', 'OK'); diff --git a/test/function/samples/deoptimize-object-expressions-2/_config.js b/test/function/samples/deoptimize-object-expressions-2/_config.js index e813da503b0..0059042c404 100644 --- a/test/function/samples/deoptimize-object-expressions-2/_config.js +++ b/test/function/samples/deoptimize-object-expressions-2/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'track deoptimizations of computed properties of empty objects' -}; +}); diff --git a/test/function/samples/deoptimize-object-expressions/_config.js b/test/function/samples/deoptimize-object-expressions/_config.js index c848c2ffc44..601c94248fd 100644 --- a/test/function/samples/deoptimize-object-expressions/_config.js +++ b/test/function/samples/deoptimize-object-expressions/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'track deoptimizations of computed properties' -}; +}); diff --git a/test/function/samples/deoptimize-object/_config.js b/test/function/samples/deoptimize-object/_config.js new file mode 100644 index 00000000000..8cb5aad18bd --- /dev/null +++ b/test/function/samples/deoptimize-object/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'handles deoptimization of object properties' +}); diff --git a/test/function/samples/deoptimize-object/main.js b/test/function/samples/deoptimize-object/main.js new file mode 100644 index 00000000000..bfd1b80873e --- /dev/null +++ b/test/function/samples/deoptimize-object/main.js @@ -0,0 +1,13 @@ +let prop = 'old'; + +function getObj() { + return { + [prop]: true + }; +} + +if (!getObj().old) throw new Error('old missing'); +if (getObj().new) throw new Error('new present'); +prop = 'new'; +if (getObj().old) throw new Error('old present'); +if (!getObj().new) throw new Error('new missing'); diff --git a/test/function/samples/deoptimize-pushed-array-element/_config.js b/test/function/samples/deoptimize-pushed-array-element/_config.js new file mode 100644 index 00000000000..4fe08f2f9a6 --- /dev/null +++ b/test/function/samples/deoptimize-pushed-array-element/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'deoptimizes elements pushed into an array' +}); diff --git a/test/function/samples/deoptimize-pushed-array-element/main.js b/test/function/samples/deoptimize-pushed-array-element/main.js new file mode 100644 index 00000000000..455bcad0ada --- /dev/null +++ b/test/function/samples/deoptimize-pushed-array-element/main.js @@ -0,0 +1,21 @@ +let mutated1 = false; +const state1 = { + foo: undefined +}; + +let mutated2 = false; +const state2 = { + foo: undefined +}; + +const stack = []; +stack.push(state1, state2); +stack[0].foo = () => (mutated1 = true); +stack.at(-1).foo = () => (mutated2 = true); + +state1.foo?.(); +assert.ok(mutated1, '1'); + +state2.foo?.(); +assert.ok(mutated2, '2'); + diff --git a/test/function/samples/deoptimize-request-treeshaking-pass/_config.js b/test/function/samples/deoptimize-request-treeshaking-pass/_config.js new file mode 100644 index 00000000000..c2edc9f8248 --- /dev/null +++ b/test/function/samples/deoptimize-request-treeshaking-pass/_config.js @@ -0,0 +1,10 @@ +const assert = require('node:assert'); +const result = { value: 0 }; + +module.exports = defineTest({ + description: 'makes sure to request additional passes when a variable is deoptimized', + context: { result }, + exports() { + assert.strictEqual(result.value, 2); + } +}); diff --git a/test/function/samples/deoptimize-request-treeshaking-pass/main.js b/test/function/samples/deoptimize-request-treeshaking-pass/main.js new file mode 100644 index 00000000000..e8c93aad9eb --- /dev/null +++ b/test/function/samples/deoptimize-request-treeshaking-pass/main.js @@ -0,0 +1,17 @@ +function heisenbug() { + var a = false; + function f(b) { + if (a) a === b.c ? result.value++ : result.value--; + a = b.c; + } + function g() {} + function h() { + f({ + c: g + }); + } + h(); + h(); +} +heisenbug(); +heisenbug(); diff --git a/test/function/samples/deoptimize-this-parameters/_config.js b/test/function/samples/deoptimize-this-parameters/_config.js new file mode 100644 index 00000000000..942450e90a6 --- /dev/null +++ b/test/function/samples/deoptimize-this-parameters/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'handles deoptimization of this parameters' +}); diff --git a/test/function/samples/deoptimize-this-parameters/main.js b/test/function/samples/deoptimize-this-parameters/main.js new file mode 100644 index 00000000000..89792dd4aea --- /dev/null +++ b/test/function/samples/deoptimize-this-parameters/main.js @@ -0,0 +1,21 @@ +const obj = { + flag: false, + otherFlag: false, + otherProp() { + this.otherFlag = true; + }, + prop() { + this.flag = true; + this.otherProp(); + } +}; + +const otherObj = { + prop: obj.prop, + otherProp: obj.otherProp +}; + +obj.prop(); +otherObj.prop(); +if (!obj.flag) throw new Error('first flag missing'); +if (!otherObj.flag) throw new Error('second flag missing'); diff --git a/test/function/samples/deoptimize-via-arguments/_config.js b/test/function/samples/deoptimize-via-arguments/_config.js new file mode 100644 index 00000000000..c71d20260b1 --- /dev/null +++ b/test/function/samples/deoptimize-via-arguments/_config.js @@ -0,0 +1,3 @@ +module.exports = { + description: 'deoptimize call parameters when arguments variable is used' +}; diff --git a/test/function/samples/deoptimize-via-arguments/main.js b/test/function/samples/deoptimize-via-arguments/main.js new file mode 100644 index 00000000000..9bebcde6842 --- /dev/null +++ b/test/function/samples/deoptimize-via-arguments/main.js @@ -0,0 +1,17 @@ +function mutate(a) { + arguments[0].x = true; + arguments[1].x = true; +} + +var obj1 = { + x: false +}; + +var obj2 = { + x: false +}; + +mutate(obj1, obj2); + +assert.ok(obj1.x ? true : false, 'obj1'); +assert.ok(obj2.x ? true : false, 'obj2'); diff --git a/test/function/samples/deprecated/context-resolve-id/_config.js b/test/function/samples/deprecated/context-resolve-id/_config.js deleted file mode 100644 index 17c7fee1800..00000000000 --- a/test/function/samples/deprecated/context-resolve-id/_config.js +++ /dev/null @@ -1,86 +0,0 @@ -const path = require('path'); -const assert = require('assert'); - -module.exports = { - description: 'correctly returns string or null for the context resolveId helper', - context: { - require(id) { - switch (id) { - case 'external-name': - return { value: 'external name' }; - case 'external-object': - return { value: 'external object' }; - case 'resolveto-unresolved': - return { value: 'unresolved' }; - default: - throw new Error(`Unexpected import ${id}`); - } - } - }, - warnings: [ - { - code: 'DEPRECATED_FEATURE', - message: - 'The "this.resolveId" plugin context function used by plugin at position 1 is deprecated. The "this.resolve" plugin context function should be used instead.', - plugin: 'at position 1' - }, - { - code: 'UNRESOLVED_IMPORT', - importer: 'main.js', - message: - "'resolveto-unresolved' is imported by main.js, but could not be resolved – treating it as an external dependency", - source: 'resolveto-unresolved', - url: 'https://rollupjs.org/guide/en/#warning-treating-module-as-external-dependency' - } - ], - options: { - strictDeprecations: false, - plugins: [ - { - resolveId(id, importer) { - if (id.startsWith('resolveto-')) { - const resolutionId = id.slice('resolveto-'.length); - return this.resolveId(resolutionId, importer).then(resolvedId => { - if (!resolvedId) { - assert.strictEqual(resolutionId, 'unresolved'); - assert.strictEqual(resolvedId, null); - } else { - if (typeof resolvedId !== 'string') { - throw new Error( - `Only valid resolveId return types are string and null, found ${typeof resolvedId} ${JSON.stringify( - resolvedId - )}` - ); - } - return { - id: resolvedId, - external: resolvedId.startsWith('external') - }; - } - }); - } - } - }, - { - resolveId(id) { - switch (id) { - case 'object': - return { - id: path.join(__dirname, 'existing-object.js'), - external: false - }; - case 'external-object': - return { - id: 'external-object', - external: true - }; - case 'name': - return path.join(__dirname, 'existing-name.js'); - case 'external-name': - return false; - } - } - } - ] - } -}; diff --git a/test/function/samples/deprecated/context-resolve-id/existing-name.js b/test/function/samples/deprecated/context-resolve-id/existing-name.js deleted file mode 100644 index d7aebd0e184..00000000000 --- a/test/function/samples/deprecated/context-resolve-id/existing-name.js +++ /dev/null @@ -1 +0,0 @@ -export const value = 'existing name'; diff --git a/test/function/samples/deprecated/context-resolve-id/existing-object.js b/test/function/samples/deprecated/context-resolve-id/existing-object.js deleted file mode 100644 index fb5c62510d0..00000000000 --- a/test/function/samples/deprecated/context-resolve-id/existing-object.js +++ /dev/null @@ -1 +0,0 @@ -export const value = 'existing object'; diff --git a/test/function/samples/deprecated/context-resolve-id/main.js b/test/function/samples/deprecated/context-resolve-id/main.js deleted file mode 100644 index 188a3921e2e..00000000000 --- a/test/function/samples/deprecated/context-resolve-id/main.js +++ /dev/null @@ -1,11 +0,0 @@ -import { value as name } from 'resolveto-name'; -import { value as externalName } from 'resolveto-external-name'; -import { value as object } from 'resolveto-object'; -import { value as externalObject } from 'resolveto-external-object'; -import { value as unresolved } from 'resolveto-unresolved'; - -assert.strictEqual(externalName, 'external name'); -assert.strictEqual(externalObject, 'external object'); -assert.strictEqual(name, 'existing name'); -assert.strictEqual(object, 'existing object'); -assert.strictEqual(unresolved, 'unresolved'); diff --git a/test/function/samples/deprecated/deconflicts-interop-boolean/_config.js b/test/function/samples/deprecated/deconflicts-interop-boolean/_config.js deleted file mode 100644 index ae0552e5059..00000000000 --- a/test/function/samples/deprecated/deconflicts-interop-boolean/_config.js +++ /dev/null @@ -1,17 +0,0 @@ -module.exports = { - description: 'deconflicts the interop function for "true"', - options: { - strictDeprecations: false, - external(id) { - return id.startsWith('external'); - }, - output: { - interop: true - } - }, - context: { - require: id => { - return Object.defineProperty({ foo: 'foo', default: 'bar' }, '__esModule', { value: true }); - } - } -}; diff --git a/test/function/samples/deprecated/deconflicts-interop-boolean/main.js b/test/function/samples/deprecated/deconflicts-interop-boolean/main.js deleted file mode 100644 index 9d819c8a98c..00000000000 --- a/test/function/samples/deprecated/deconflicts-interop-boolean/main.js +++ /dev/null @@ -1,10 +0,0 @@ -import external1 from 'external'; -import * as external2 from 'external'; - -const _interopDefaultLegacy = null; -const _interopNamespace = null; - -assert.strictEqual(_interopDefaultLegacy, null); -assert.strictEqual(_interopNamespace, null); -assert.strictEqual(external1, 'bar'); -assert.deepStrictEqual(external2, { default: 'bar', foo: 'foo' }); diff --git a/test/function/samples/deprecated/dynamic-import-duplicates/_config.js b/test/function/samples/deprecated/dynamic-import-duplicates/_config.js deleted file mode 100644 index c71c26f5b04..00000000000 --- a/test/function/samples/deprecated/dynamic-import-duplicates/_config.js +++ /dev/null @@ -1,15 +0,0 @@ -const assert = require('assert'); - -module.exports = { - description: 'Dynamic import inlining', - options: { - strictDeprecations: false, - inlineDynamicImports: true - }, - exports(exports) { - assert.equal(exports.x, 41); - return exports.promise.then(y => { - assert.equal(y, 42); - }); - } -}; diff --git a/test/function/samples/deprecated/dynamic-import-duplicates/foo.js b/test/function/samples/deprecated/dynamic-import-duplicates/foo.js deleted file mode 100644 index ddb14e1522c..00000000000 --- a/test/function/samples/deprecated/dynamic-import-duplicates/foo.js +++ /dev/null @@ -1 +0,0 @@ -export var x = 42; \ No newline at end of file diff --git a/test/function/samples/deprecated/dynamic-import-duplicates/main.js b/test/function/samples/deprecated/dynamic-import-duplicates/main.js deleted file mode 100644 index 37a427d7d1a..00000000000 --- a/test/function/samples/deprecated/dynamic-import-duplicates/main.js +++ /dev/null @@ -1,5 +0,0 @@ -export var x = 41; - -export var promise = Promise.all([import('./foo'), import('./foo')]).then(foos => { - return foos[0].x; -}); diff --git a/test/function/samples/deprecated/dynamic-import-inlining/_config.js b/test/function/samples/deprecated/dynamic-import-inlining/_config.js deleted file mode 100644 index c71c26f5b04..00000000000 --- a/test/function/samples/deprecated/dynamic-import-inlining/_config.js +++ /dev/null @@ -1,15 +0,0 @@ -const assert = require('assert'); - -module.exports = { - description: 'Dynamic import inlining', - options: { - strictDeprecations: false, - inlineDynamicImports: true - }, - exports(exports) { - assert.equal(exports.x, 41); - return exports.promise.then(y => { - assert.equal(y, 42); - }); - } -}; diff --git a/test/function/samples/deprecated/dynamic-import-inlining/foo.js b/test/function/samples/deprecated/dynamic-import-inlining/foo.js deleted file mode 100644 index ddb14e1522c..00000000000 --- a/test/function/samples/deprecated/dynamic-import-inlining/foo.js +++ /dev/null @@ -1 +0,0 @@ -export var x = 42; \ No newline at end of file diff --git a/test/function/samples/deprecated/dynamic-import-inlining/main.js b/test/function/samples/deprecated/dynamic-import-inlining/main.js deleted file mode 100644 index 94869cb0b70..00000000000 --- a/test/function/samples/deprecated/dynamic-import-inlining/main.js +++ /dev/null @@ -1,5 +0,0 @@ -export var x = 41; - -export var promise = import('./foo').then(foo => { - return foo.x; -}); diff --git a/test/function/samples/deprecated/dynamic-import-name-warn/_config.js b/test/function/samples/deprecated/dynamic-import-name-warn/_config.js deleted file mode 100644 index 7a8e97c0fc1..00000000000 --- a/test/function/samples/deprecated/dynamic-import-name-warn/_config.js +++ /dev/null @@ -1,35 +0,0 @@ -const assert = require('assert'); - -module.exports = { - description: 'warns when specifying a custom importer function for formats other than "es"', - context: { - require(path) { - assert.equal(path, './foo.js'); - return 42; - } - }, - options: { - strictDeprecations: false, - input: 'main.js', - plugins: { - resolveDynamicImport() { - return false; - } - }, - output: { - dynamicImportFunction: 'myImporter', - format: 'cjs' - } - }, - exports(exports) { - return exports.fromFoo.then(value => - assert.deepStrictEqual(value, { __proto__: null, default: 42 }) - ); - }, - warnings: [ - { - code: 'INVALID_OPTION', - message: '"output.dynamicImportFunction" is ignored for formats other than "es".' - } - ] -}; diff --git a/test/function/samples/deprecated/dynamic-import-name-warn/main.js b/test/function/samples/deprecated/dynamic-import-name-warn/main.js deleted file mode 100644 index ed74de99fab..00000000000 --- a/test/function/samples/deprecated/dynamic-import-name-warn/main.js +++ /dev/null @@ -1 +0,0 @@ -export const fromFoo = import('./foo.js'); diff --git a/test/function/samples/deprecated/dynamic-import-name/_config.js b/test/function/samples/deprecated/dynamic-import-name/_config.js deleted file mode 100644 index afb4f3ba114..00000000000 --- a/test/function/samples/deprecated/dynamic-import-name/_config.js +++ /dev/null @@ -1,28 +0,0 @@ -const assert = require('assert'); -let imported = false; - -module.exports = { - description: 'allows specifying a custom importer function', - context: { - myImporter(path) { - assert.equal(path, './foo.js'); - imported = true; - } - }, - options: { - strictDeprecations: false, - input: 'main.js', - plugins: { - resolveDynamicImport() { - return false; - } - }, - output: { - dynamicImportFunction: 'myImporter', - format: 'es' - } - }, - exports() { - assert.ok(imported); - } -}; diff --git a/test/function/samples/deprecated/emit-asset/asset-source-missing-2/_config.js b/test/function/samples/deprecated/emit-asset/asset-source-missing-2/_config.js deleted file mode 100644 index 4b973d7d804..00000000000 --- a/test/function/samples/deprecated/emit-asset/asset-source-missing-2/_config.js +++ /dev/null @@ -1,17 +0,0 @@ -module.exports = { - description: 'throws when not setting the asset source and accessing the asset URL', - options: { - strictDeprecations: false, - plugins: { - name: 'test-plugin', - load() { - return `export default import.meta.ROLLUP_ASSET_URL_${this.emitAsset('test.ext')};`; - } - } - }, - generateError: { - code: 'ASSET_NOT_FINALISED', - message: - 'Plugin error - Unable to get file name for asset "test.ext". Ensure that the source is set and that generate is called first.' - } -}; diff --git a/test/function/samples/deprecated/emit-asset/asset-source-missing-3/_config.js b/test/function/samples/deprecated/emit-asset/asset-source-missing-3/_config.js deleted file mode 100644 index 131b79c50c8..00000000000 --- a/test/function/samples/deprecated/emit-asset/asset-source-missing-3/_config.js +++ /dev/null @@ -1,21 +0,0 @@ -module.exports = { - description: 'throws when setting an empty asset source', - options: { - strictDeprecations: false, - plugins: { - name: 'test-plugin', - buildStart() { - const assetId = this.emitAsset('test.ext'); - this.setAssetSource(assetId, null); - } - } - }, - error: { - code: 'PLUGIN_ERROR', - hook: 'buildStart', - message: - 'Could not set source for asset "test.ext", asset source needs to be a string, Uint8Array or Buffer.', - plugin: 'test-plugin', - pluginCode: 'VALIDATION_ERROR' - } -}; diff --git a/test/function/samples/deprecated/emit-asset/asset-source-missing/_config.js b/test/function/samples/deprecated/emit-asset/asset-source-missing/_config.js deleted file mode 100644 index 59b5946f927..00000000000 --- a/test/function/samples/deprecated/emit-asset/asset-source-missing/_config.js +++ /dev/null @@ -1,16 +0,0 @@ -module.exports = { - description: 'throws when not setting the asset source', - options: { - strictDeprecations: false, - plugins: { - name: 'test-plugin', - load() { - this.emitAsset('test.ext'); - } - } - }, - generateError: { - code: 'ASSET_SOURCE_MISSING', - message: 'Plugin error creating asset "test.ext" - no asset source set.' - } -}; diff --git a/test/function/samples/deprecated/emit-asset/asset-source-missing/main.js b/test/function/samples/deprecated/emit-asset/asset-source-missing/main.js deleted file mode 100644 index c4b940fc952..00000000000 --- a/test/function/samples/deprecated/emit-asset/asset-source-missing/main.js +++ /dev/null @@ -1 +0,0 @@ -throw new Error('should not build'); diff --git a/test/function/samples/deprecated/emit-asset/invalid-asset-id/_config.js b/test/function/samples/deprecated/emit-asset/invalid-asset-id/_config.js deleted file mode 100644 index 85f8e8fe64f..00000000000 --- a/test/function/samples/deprecated/emit-asset/invalid-asset-id/_config.js +++ /dev/null @@ -1,16 +0,0 @@ -module.exports = { - description: 'throws for invalid asset ids', - options: { - strictDeprecations: false, - plugins: { - name: 'test-plugin', - load() { - return `export default import.meta.ROLLUP_ASSET_URL_invalid;`; - } - } - }, - generateError: { - code: 'FILE_NOT_FOUND', - message: 'Plugin error - Unable to get file name for unknown file "invalid".' - } -}; diff --git a/test/function/samples/deprecated/emit-asset/invalid-asset-id/main.js b/test/function/samples/deprecated/emit-asset/invalid-asset-id/main.js deleted file mode 100644 index c4b940fc952..00000000000 --- a/test/function/samples/deprecated/emit-asset/invalid-asset-id/main.js +++ /dev/null @@ -1 +0,0 @@ -throw new Error('should not build'); diff --git a/test/function/samples/deprecated/emit-asset/invalid-asset-name/_config.js b/test/function/samples/deprecated/emit-asset/invalid-asset-name/_config.js deleted file mode 100644 index 8add304a305..00000000000 --- a/test/function/samples/deprecated/emit-asset/invalid-asset-name/_config.js +++ /dev/null @@ -1,20 +0,0 @@ -module.exports = { - description: 'throws for invalid asset names', - options: { - strictDeprecations: false, - plugins: { - name: 'test-plugin', - buildStart() { - this.emitAsset('/test.ext', 'content'); - } - } - }, - error: { - code: 'PLUGIN_ERROR', - hook: 'buildStart', - message: - 'The "fileName" or "name" properties of emitted files must be strings that are neither absolute nor relative paths and do not contain invalid characters, received "/test.ext".', - plugin: 'test-plugin', - pluginCode: 'VALIDATION_ERROR' - } -}; diff --git a/test/function/samples/deprecated/emit-asset/invalid-asset-name/main.js b/test/function/samples/deprecated/emit-asset/invalid-asset-name/main.js deleted file mode 100644 index c4b940fc952..00000000000 --- a/test/function/samples/deprecated/emit-asset/invalid-asset-name/main.js +++ /dev/null @@ -1 +0,0 @@ -throw new Error('should not build'); diff --git a/test/function/samples/deprecated/emit-asset/invalid-set-asset-source-id/_config.js b/test/function/samples/deprecated/emit-asset/invalid-set-asset-source-id/_config.js deleted file mode 100644 index 1f536fd748d..00000000000 --- a/test/function/samples/deprecated/emit-asset/invalid-set-asset-source-id/_config.js +++ /dev/null @@ -1,19 +0,0 @@ -module.exports = { - description: 'throws for invalid asset ids', - options: { - strictDeprecations: false, - plugins: { - name: 'test-plugin', - buildStart() { - this.setAssetSource('invalid', 'content'); - } - } - }, - error: { - code: 'PLUGIN_ERROR', - hook: 'buildStart', - message: 'Plugin error - Unable to set the source for unknown asset "invalid".', - plugin: 'test-plugin', - pluginCode: 'ASSET_NOT_FOUND' - } -}; diff --git a/test/function/samples/deprecated/emit-asset/invalid-set-asset-source-id/main.js b/test/function/samples/deprecated/emit-asset/invalid-set-asset-source-id/main.js deleted file mode 100644 index c4b940fc952..00000000000 --- a/test/function/samples/deprecated/emit-asset/invalid-set-asset-source-id/main.js +++ /dev/null @@ -1 +0,0 @@ -throw new Error('should not build'); diff --git a/test/function/samples/deprecated/emit-asset/set-asset-source-transform/_config.js b/test/function/samples/deprecated/emit-asset/set-asset-source-transform/_config.js deleted file mode 100644 index a65b559c360..00000000000 --- a/test/function/samples/deprecated/emit-asset/set-asset-source-transform/_config.js +++ /dev/null @@ -1,26 +0,0 @@ -const path = require('path'); - -module.exports = { - description: 'throws when setting the asset source in the transform hook', - options: { - strictDeprecations: false, - plugins: { - name: 'test-plugin', - transform(code) { - const assetId = this.emitAsset('test.ext'); - this.setAssetSource(assetId, 'asdf'); - return code; - } - } - }, - error: { - code: 'PLUGIN_ERROR', - hook: 'transform', - id: path.join(__dirname, 'main.js'), - message: - 'setAssetSource cannot be called in transform for caching reasons. Use emitFile with a source, or call setAssetSource in another hook.', - plugin: 'test-plugin', - pluginCode: 'INVALID_SETASSETSOURCE', - watchFiles: [path.join(__dirname, 'main.js')] - } -}; diff --git a/test/function/samples/deprecated/emit-asset/set-asset-source-transform/main.js b/test/function/samples/deprecated/emit-asset/set-asset-source-transform/main.js deleted file mode 100644 index c4b940fc952..00000000000 --- a/test/function/samples/deprecated/emit-asset/set-asset-source-transform/main.js +++ /dev/null @@ -1 +0,0 @@ -throw new Error('should not build'); diff --git a/test/function/samples/deprecated/emit-asset/set-asset-source-twice/_config.js b/test/function/samples/deprecated/emit-asset/set-asset-source-twice/_config.js deleted file mode 100644 index 1f6d657d302..00000000000 --- a/test/function/samples/deprecated/emit-asset/set-asset-source-twice/_config.js +++ /dev/null @@ -1,21 +0,0 @@ -module.exports = { - description: 'throws when setting the asset source twice', - options: { - strictDeprecations: false, - plugins: { - name: 'test-plugin', - buildEnd() { - const assetId = this.emitAsset('test.ext'); - this.setAssetSource(assetId, 'hello world'); - this.setAssetSource(assetId, 'another'); - } - } - }, - error: { - code: 'PLUGIN_ERROR', - hook: 'buildEnd', - message: 'Unable to set the source for asset "test.ext", source already set.', - plugin: 'test-plugin', - pluginCode: 'ASSET_SOURCE_ALREADY_SET' - } -}; diff --git a/test/function/samples/deprecated/emit-asset/set-asset-source-twice/main.js b/test/function/samples/deprecated/emit-asset/set-asset-source-twice/main.js deleted file mode 100644 index c4b940fc952..00000000000 --- a/test/function/samples/deprecated/emit-asset/set-asset-source-twice/main.js +++ /dev/null @@ -1 +0,0 @@ -throw new Error('should not build'); diff --git a/test/function/samples/deprecated/emit-chunk/chunk-filename-not-available-render-start/_config.js b/test/function/samples/deprecated/emit-chunk/chunk-filename-not-available-render-start/_config.js deleted file mode 100644 index 42a48e679eb..00000000000 --- a/test/function/samples/deprecated/emit-chunk/chunk-filename-not-available-render-start/_config.js +++ /dev/null @@ -1,26 +0,0 @@ -let chunkId; - -module.exports = { - description: 'Throws when accessing the filename in renderStart', - options: { - strictDeprecations: false, - input: 'main.js', - plugins: { - name: 'test-plugin', - buildStart() { - chunkId = this.emitChunk('chunk.js'); - }, - renderStart() { - this.getChunkFileName(chunkId); - } - } - }, - generateError: { - code: 'PLUGIN_ERROR', - hook: 'renderStart', - message: - 'Plugin error - Unable to get file name for chunk "chunk.js". Ensure that generate is called first.', - plugin: 'test-plugin', - pluginCode: 'CHUNK_NOT_GENERATED' - } -}; diff --git a/test/function/samples/deprecated/emit-chunk/chunk-filename-not-available-render-start/chunk.js b/test/function/samples/deprecated/emit-chunk/chunk-filename-not-available-render-start/chunk.js deleted file mode 100644 index 36b1d61dd25..00000000000 --- a/test/function/samples/deprecated/emit-chunk/chunk-filename-not-available-render-start/chunk.js +++ /dev/null @@ -1 +0,0 @@ -console.log('chunk'); diff --git a/test/function/samples/deprecated/emit-chunk/chunk-filename-not-available/_config.js b/test/function/samples/deprecated/emit-chunk/chunk-filename-not-available/_config.js deleted file mode 100644 index b9f7b03693f..00000000000 --- a/test/function/samples/deprecated/emit-chunk/chunk-filename-not-available/_config.js +++ /dev/null @@ -1,25 +0,0 @@ -const path = require('path'); - -module.exports = { - description: 'Throws when accessing the filename before it has been generated', - options: { - strictDeprecations: false, - input: 'main.js', - plugins: { - name: 'test-plugin', - buildStart() { - const chunkId = this.emitChunk('chunk.js'); - this.getChunkFileName(chunkId); - } - } - }, - error: { - code: 'PLUGIN_ERROR', - hook: 'buildStart', - message: - 'Plugin error - Unable to get file name for chunk "chunk.js". Ensure that generate is called first.', - plugin: 'test-plugin', - pluginCode: 'CHUNK_NOT_GENERATED', - watchFiles: [path.join(__dirname, 'chunk.js')] - } -}; diff --git a/test/function/samples/deprecated/emit-chunk/chunk-filename-not-available/chunk.js b/test/function/samples/deprecated/emit-chunk/chunk-filename-not-available/chunk.js deleted file mode 100644 index 36b1d61dd25..00000000000 --- a/test/function/samples/deprecated/emit-chunk/chunk-filename-not-available/chunk.js +++ /dev/null @@ -1 +0,0 @@ -console.log('chunk'); diff --git a/test/function/samples/deprecated/emit-chunk/chunk-not-found/_config.js b/test/function/samples/deprecated/emit-chunk/chunk-not-found/_config.js deleted file mode 100644 index c731c60c9c5..00000000000 --- a/test/function/samples/deprecated/emit-chunk/chunk-not-found/_config.js +++ /dev/null @@ -1,19 +0,0 @@ -const path = require('path'); - -module.exports = { - description: 'Throws if an emitted entry chunk cannot be resolved', - options: { - strictDeprecations: false, - input: 'main.js', - plugins: { - buildStart() { - this.emitChunk('not-found.js'); - } - } - }, - error: { - code: 'UNRESOLVED_ENTRY', - message: 'Could not resolve entry module (not-found.js).', - watchFiles: [path.join(__dirname, 'main.js')] - } -}; diff --git a/test/function/samples/deprecated/emit-chunk/invalid-chunk-id/_config.js b/test/function/samples/deprecated/emit-chunk/invalid-chunk-id/_config.js deleted file mode 100644 index 5f131d72bd5..00000000000 --- a/test/function/samples/deprecated/emit-chunk/invalid-chunk-id/_config.js +++ /dev/null @@ -1,16 +0,0 @@ -module.exports = { - description: 'throws for invalid chunk ids', - options: { - strictDeprecations: false, - plugins: { - name: 'test-plugin', - load() { - return `export default import.meta.ROLLUP_CHUNK_URL_invalid;`; - } - } - }, - generateError: { - code: 'FILE_NOT_FOUND', - message: 'Plugin error - Unable to get file name for unknown file "invalid".' - } -}; diff --git a/test/function/samples/deprecated/emit-chunk/invalid-chunk-id/main.js b/test/function/samples/deprecated/emit-chunk/invalid-chunk-id/main.js deleted file mode 100644 index c4b940fc952..00000000000 --- a/test/function/samples/deprecated/emit-chunk/invalid-chunk-id/main.js +++ /dev/null @@ -1 +0,0 @@ -throw new Error('should not build'); diff --git a/test/function/samples/deprecated/emit-chunk/modules-loaded/_config.js b/test/function/samples/deprecated/emit-chunk/modules-loaded/_config.js deleted file mode 100644 index da093620bc8..00000000000 --- a/test/function/samples/deprecated/emit-chunk/modules-loaded/_config.js +++ /dev/null @@ -1,20 +0,0 @@ -module.exports = { - description: 'Throws when adding a chunk after the modules have finished loading', - options: { - strictDeprecations: false, - input: 'main.js', - plugins: { - name: 'test-plugin', - buildEnd() { - this.emitChunk('chunk.js'); - } - } - }, - error: { - code: 'PLUGIN_ERROR', - hook: 'buildEnd', - message: 'Cannot emit chunks after module loading has finished.', - plugin: 'test-plugin', - pluginCode: 'INVALID_ROLLUP_PHASE' - } -}; diff --git a/test/function/samples/deprecated/emit-chunk/modules-loaded/chunk.js b/test/function/samples/deprecated/emit-chunk/modules-loaded/chunk.js deleted file mode 100644 index a9244a453fb..00000000000 --- a/test/function/samples/deprecated/emit-chunk/modules-loaded/chunk.js +++ /dev/null @@ -1 +0,0 @@ -throw new Error('Not executed'); diff --git a/test/function/samples/deprecated/emit-chunk/no-input/_config.js b/test/function/samples/deprecated/emit-chunk/no-input/_config.js deleted file mode 100644 index 7536323ba6a..00000000000 --- a/test/function/samples/deprecated/emit-chunk/no-input/_config.js +++ /dev/null @@ -1,21 +0,0 @@ -module.exports = { - description: 'It is not necessary to provide an input if a dynamic entry is emitted', - options: { - strictDeprecations: false, - input: undefined, - plugins: { - name: 'test-plugin', - buildStart() { - this.emitChunk('chunk.js'); - } - } - }, - warnings: [ - { - code: 'DEPRECATED_FEATURE', - message: - 'The "this.emitChunk" plugin context function used by plugin test-plugin is deprecated. The "this.emitFile" plugin context function should be used instead.', - plugin: 'test-plugin' - } - ] -}; diff --git a/test/function/samples/deprecated/emit-chunk/no-input/chunk.js b/test/function/samples/deprecated/emit-chunk/no-input/chunk.js deleted file mode 100644 index c40c320ba58..00000000000 --- a/test/function/samples/deprecated/emit-chunk/no-input/chunk.js +++ /dev/null @@ -1 +0,0 @@ -assert.equal(42, 42); diff --git a/test/function/samples/deprecated/emit-file/original-file-name/_config.js b/test/function/samples/deprecated/emit-file/original-file-name/_config.js new file mode 100644 index 00000000000..f447b06fe90 --- /dev/null +++ b/test/function/samples/deprecated/emit-file/original-file-name/_config.js @@ -0,0 +1,53 @@ +const assert = require('node:assert'); +const path = require('node:path'); + +const ORIGINAL_FILE_NAME = path.join(__dirname, 'original.txt'); + +module.exports = defineTest({ + description: 'forwards the original file name to other hooks', + options: { + strictDeprecations: false, + output: { + assetFileNames(info) { + if (info.name === 'with_original.txt') { + assert.strictEqual(info.originalFileName, ORIGINAL_FILE_NAME); + } else { + assert.strictEqual(info.originalFileName, null); + } + return info.name; + } + }, + plugins: [ + { + name: 'test', + buildStart() { + this.emitFile({ + type: 'asset', + name: 'with_original.txt', + originalFileName: ORIGINAL_FILE_NAME, + source: 'with original file name' + }); + this.emitFile({ + type: 'asset', + name: 'with_original_null.txt', + originalFileName: null, + source: 'with original file name null' + }); + this.emitFile({ + type: 'asset', + name: 'without_original.txt', + source: 'without original file name' + }); + }, + generateBundle(options, bundle) { + assert.strictEqual(bundle['with_original.txt'].name, 'with_original.txt'); + assert.strictEqual(bundle['with_original.txt'].originalFileName, ORIGINAL_FILE_NAME); + assert.strictEqual(bundle['with_original_null.txt'].name, 'with_original_null.txt'); + assert.strictEqual(bundle['with_original_null.txt'].originalFileName, null); + assert.strictEqual(bundle['without_original.txt'].name, 'without_original.txt'); + assert.strictEqual(bundle['without_original.txt'].originalFileName, null); + } + } + ] + } +}); diff --git a/test/function/samples/deprecated/emit-file/original-file-name/main.js b/test/function/samples/deprecated/emit-file/original-file-name/main.js new file mode 100644 index 00000000000..69b8f8f7946 --- /dev/null +++ b/test/function/samples/deprecated/emit-file/original-file-name/main.js @@ -0,0 +1,13 @@ +let effect = false; + +var b = { + get a() { + effect = true; + } +}; + +function X() {} +X.prototype = b; +new X().a; + +assert.ok(effect); diff --git a/test/function/samples/deprecated/inline-dynamic-imports-bundle/_config.js b/test/function/samples/deprecated/inline-dynamic-imports-bundle/_config.js deleted file mode 100644 index ce23254e2ce..00000000000 --- a/test/function/samples/deprecated/inline-dynamic-imports-bundle/_config.js +++ /dev/null @@ -1,18 +0,0 @@ -const assert = require('assert'); -const path = require('path'); - -module.exports = { - description: 'ignores non-bundled modules when inlining dynamic imports', - options: { - strictDeprecations: false, - inlineDynamicImports: true, - plugins: { - generateBundle(options, bundle) { - assert.deepStrictEqual(Object.keys(bundle['main.js'].modules), [ - path.join(__dirname, 'lib.js'), - path.join(__dirname, 'main.js') - ]); - } - } - } -}; diff --git a/test/function/samples/deprecated/inline-dynamic-imports-bundle/lib.js b/test/function/samples/deprecated/inline-dynamic-imports-bundle/lib.js deleted file mode 100644 index 9d7381d29f6..00000000000 --- a/test/function/samples/deprecated/inline-dynamic-imports-bundle/lib.js +++ /dev/null @@ -1 +0,0 @@ -export const foo = 42; diff --git a/test/function/samples/deprecated/inline-dynamic-imports-bundle/main.js b/test/function/samples/deprecated/inline-dynamic-imports-bundle/main.js deleted file mode 100644 index 0bb1f9f4b4a..00000000000 --- a/test/function/samples/deprecated/inline-dynamic-imports-bundle/main.js +++ /dev/null @@ -1 +0,0 @@ -export { foo } from './reexporter'; diff --git a/test/function/samples/deprecated/inline-dynamic-imports-bundle/reexporter.js b/test/function/samples/deprecated/inline-dynamic-imports-bundle/reexporter.js deleted file mode 100644 index 26a05cf13db..00000000000 --- a/test/function/samples/deprecated/inline-dynamic-imports-bundle/reexporter.js +++ /dev/null @@ -1 +0,0 @@ -export { foo } from './lib'; diff --git a/test/function/samples/deprecated/inline-imports-with-manual/_config.js b/test/function/samples/deprecated/inline-imports-with-manual/_config.js deleted file mode 100644 index 803c6f315cd..00000000000 --- a/test/function/samples/deprecated/inline-imports-with-manual/_config.js +++ /dev/null @@ -1,15 +0,0 @@ -module.exports = { - description: 'Manual chunks are not supported when inlining dynamic imports', - options: { - strictDeprecations: false, - input: ['main.js'], - inlineDynamicImports: true, - manualChunks: { - lib: ['lib.js'] - } - }, - generateError: { - code: 'INVALID_OPTION', - message: 'The "output.manualChunks" option is not supported for "output.inlineDynamicImports".' - } -}; diff --git a/test/function/samples/deprecated/inline-imports-with-manual/main.js b/test/function/samples/deprecated/inline-imports-with-manual/main.js deleted file mode 100644 index 4869dc82f38..00000000000 --- a/test/function/samples/deprecated/inline-imports-with-manual/main.js +++ /dev/null @@ -1 +0,0 @@ -import('./lib').then(({value}) => assert.equal(value, 42)); diff --git a/test/function/samples/deprecated/inline-imports-with-multiple-array/_config.js b/test/function/samples/deprecated/inline-imports-with-multiple-array/_config.js deleted file mode 100644 index dd87192aaf2..00000000000 --- a/test/function/samples/deprecated/inline-imports-with-multiple-array/_config.js +++ /dev/null @@ -1,12 +0,0 @@ -module.exports = { - description: 'Having multiple inputs in an array is not supported when inlining dynamic imports', - options: { - strictDeprecations: false, - input: ['main.js', 'lib.js'], - inlineDynamicImports: true - }, - generateError: { - code: 'INVALID_OPTION', - message: 'Multiple inputs are not supported for "output.inlineDynamicImports".' - } -}; diff --git a/test/function/samples/deprecated/inline-imports-with-multiple-array/lib.js b/test/function/samples/deprecated/inline-imports-with-multiple-array/lib.js deleted file mode 100644 index 46d3ca8c61f..00000000000 --- a/test/function/samples/deprecated/inline-imports-with-multiple-array/lib.js +++ /dev/null @@ -1 +0,0 @@ -export const value = 42; diff --git a/test/function/samples/deprecated/inline-imports-with-multiple-array/main.js b/test/function/samples/deprecated/inline-imports-with-multiple-array/main.js deleted file mode 100644 index 4869dc82f38..00000000000 --- a/test/function/samples/deprecated/inline-imports-with-multiple-array/main.js +++ /dev/null @@ -1 +0,0 @@ -import('./lib').then(({value}) => assert.equal(value, 42)); diff --git a/test/function/samples/deprecated/inline-imports-with-multiple-object/_config.js b/test/function/samples/deprecated/inline-imports-with-multiple-object/_config.js deleted file mode 100644 index 58bd7b00a6f..00000000000 --- a/test/function/samples/deprecated/inline-imports-with-multiple-object/_config.js +++ /dev/null @@ -1,12 +0,0 @@ -module.exports = { - description: 'Having multiple inputs in an object is not supported when inlining dynamic imports', - options: { - strictDeprecations: false, - input: { main: 'main.js', lib: 'lib.js' }, - inlineDynamicImports: true - }, - generateError: { - code: 'INVALID_OPTION', - message: 'Multiple inputs are not supported for "output.inlineDynamicImports".' - } -}; diff --git a/test/function/samples/deprecated/inline-imports-with-multiple-object/lib.js b/test/function/samples/deprecated/inline-imports-with-multiple-object/lib.js deleted file mode 100644 index 46d3ca8c61f..00000000000 --- a/test/function/samples/deprecated/inline-imports-with-multiple-object/lib.js +++ /dev/null @@ -1 +0,0 @@ -export const value = 42; diff --git a/test/function/samples/deprecated/inline-imports-with-multiple-object/main.js b/test/function/samples/deprecated/inline-imports-with-multiple-object/main.js deleted file mode 100644 index 4869dc82f38..00000000000 --- a/test/function/samples/deprecated/inline-imports-with-multiple-object/main.js +++ /dev/null @@ -1 +0,0 @@ -import('./lib').then(({value}) => assert.equal(value, 42)); diff --git a/test/function/samples/deprecated/interop-false/_config.js b/test/function/samples/deprecated/interop-false/_config.js deleted file mode 100644 index f50a6495ea5..00000000000 --- a/test/function/samples/deprecated/interop-false/_config.js +++ /dev/null @@ -1,61 +0,0 @@ -let fooModule = 'foo'; -let barModule = 'bar'; -let barCjs = 'bar'; -let fooDefault = 'foo'; -let barDefault = 'bar'; - -module.exports = { - description: 'handles interop "false" with live-bindings support', - options: { - strictDeprecations: false, - external: id => id.startsWith('external') || id === 'update', - output: { - interop: false, - format: 'cjs' - } - }, - context: { - require(id) { - switch (id) { - case 'external-module': - return Object.defineProperty( - { - get default() { - return fooModule; - }, - get barModule() { - return barModule; - } - }, - '__esModule', - { value: true } - ); - case 'external-cjs': - return { - get barCjs() { - return barCjs; - } - }; - case 'external-cjs-with-default': - return { - get default() { - return fooDefault; - }, - get barDefault() { - return barDefault; - } - }; - case 'update': - return () => { - fooModule = 'foo2'; - barModule = 'bar2'; - barCjs = 'bar2'; - fooDefault = 'foo2'; - barDefault = 'bar2'; - }; - default: - throw new Error(`Unexpected import "${id}"`); - } - } - } -}; diff --git a/test/function/samples/deprecated/interop-false/main.js b/test/function/samples/deprecated/interop-false/main.js deleted file mode 100644 index ef2d7bbd26a..00000000000 --- a/test/function/samples/deprecated/interop-false/main.js +++ /dev/null @@ -1,29 +0,0 @@ -import fooModule, { barModule } from 'external-module'; -import * as bazModule from 'external-module'; -import fooCjs, { barCjs } from 'external-cjs'; -import * as bazCjs from 'external-cjs'; -import fooDefault, { barDefault } from 'external-cjs-with-default'; -import * as bazDefault from 'external-cjs-with-default'; -import update from 'update'; - -assert.deepStrictEqual(fooModule, { barModule: 'bar', default: 'foo' }, 'module'); -assert.strictEqual(barModule, 'bar', 'module'); -assert.deepStrictEqual(bazModule, { barModule: 'bar', default: 'foo' }, 'module'); -assert.deepStrictEqual(fooCjs, { barCjs: 'bar' }, 'cjs'); -assert.strictEqual(barCjs, 'bar', 'cjs'); -assert.deepStrictEqual(bazCjs, { barCjs: 'bar' }, 'cjs'); -assert.deepStrictEqual(fooDefault, { barDefault: 'bar', default: 'foo' }, 'default'); -assert.strictEqual(barDefault, 'bar', 'default'); -assert.deepStrictEqual(bazDefault, { barDefault: 'bar', default: 'foo' }, 'default'); - -update(); - -assert.deepStrictEqual(fooModule, { barModule: 'bar2', default: 'foo2' }, 'module'); -assert.strictEqual(barModule, 'bar2', 'module'); -assert.deepStrictEqual(bazModule, { barModule: 'bar2', default: 'foo2' }, 'module'); -assert.deepStrictEqual(fooCjs, { barCjs: 'bar2' }, 'cjs'); -assert.strictEqual(barCjs, 'bar2', 'cjs'); -assert.deepStrictEqual(bazCjs, { barCjs: 'bar2' }, 'cjs'); -assert.deepStrictEqual(fooDefault, { barDefault: 'bar2', default: 'foo2' }, 'default'); -assert.strictEqual(barDefault, 'bar2', 'default'); -assert.deepStrictEqual(bazDefault, { barDefault: 'bar2', default: 'foo2' }, 'default'); diff --git a/test/function/samples/deprecated/interop-true-live-bindings/_config.js b/test/function/samples/deprecated/interop-true-live-bindings/_config.js deleted file mode 100644 index aa0adf12c4d..00000000000 --- a/test/function/samples/deprecated/interop-true-live-bindings/_config.js +++ /dev/null @@ -1,61 +0,0 @@ -let fooModule = 'foo'; -let barModule = 'bar'; -let barCjs = 'bar'; -let fooDefault = 'foo'; -let barDefault = 'bar'; - -module.exports = { - description: 'handles interop "true" with live-bindings support', - options: { - strictDeprecations: false, - external: id => id.startsWith('external') || id === 'update', - output: { - interop: true, - format: 'cjs' - } - }, - context: { - require(id) { - switch (id) { - case 'external-module': - return Object.defineProperty( - { - get default() { - return fooModule; - }, - get barModule() { - return barModule; - } - }, - '__esModule', - { value: true } - ); - case 'external-cjs': - return { - get barCjs() { - return barCjs; - } - }; - case 'external-cjs-with-default': - return { - get default() { - return fooDefault; - }, - get barDefault() { - return barDefault; - } - }; - case 'update': - return () => { - fooModule = 'foo2'; - barModule = 'bar2'; - barCjs = 'bar2'; - fooDefault = 'foo2'; - barDefault = 'bar2'; - }; - default: - throw new Error(`Unexpected import "${id}"`); - } - } - } -}; diff --git a/test/function/samples/deprecated/interop-true-live-bindings/main.js b/test/function/samples/deprecated/interop-true-live-bindings/main.js deleted file mode 100644 index 6d04bcb4cd0..00000000000 --- a/test/function/samples/deprecated/interop-true-live-bindings/main.js +++ /dev/null @@ -1,45 +0,0 @@ -import fooModule, { barModule } from 'external-module'; -import * as bazModule from 'external-module'; -import fooCjs, { barCjs } from 'external-cjs'; -import * as bazCjs from 'external-cjs'; -import fooDefault, { barDefault } from 'external-cjs-with-default'; -import * as bazDefault from 'external-cjs-with-default'; -import update from 'update'; - -assert.strictEqual(fooModule, 'foo', 'module'); -assert.strictEqual(barModule, 'bar', 'module'); -assert.deepStrictEqual(bazModule, { barModule: 'bar', default: 'foo' }, 'module'); -assert.deepStrictEqual(fooCjs, { barCjs: 'bar' }, 'cjs'); -assert.strictEqual(barCjs, 'bar', 'cjs'); -assert.deepStrictEqual( - bazCjs, - { __proto__: null, barCjs: 'bar', default: { barCjs: 'bar' } }, - 'cjs' -); -assert.deepStrictEqual(fooDefault, 'foo', 'default'); -assert.strictEqual(barDefault, 'bar', 'default'); -assert.deepStrictEqual( - bazDefault, - { __proto__: null, barDefault: 'bar', default: { barDefault: 'bar', default: 'foo' } }, - 'default' -); - -update(); - -assert.strictEqual(fooModule, 'foo2', 'module'); -assert.strictEqual(barModule, 'bar2', 'module'); -assert.deepStrictEqual(bazModule, { barModule: 'bar2', default: 'foo2' }, 'module'); -assert.deepStrictEqual(fooCjs, { barCjs: 'bar2' }, 'cjs'); -assert.strictEqual(barCjs, 'bar2', 'cjs'); -assert.deepStrictEqual( - bazCjs, - { __proto__: null, barCjs: 'bar2', default: { barCjs: 'bar2' } }, - 'cjs' -); -assert.deepStrictEqual(fooDefault, 'foo2', 'default'); -assert.strictEqual(barDefault, 'bar2', 'default'); -assert.deepStrictEqual( - bazDefault, - { __proto__: null, barDefault: 'bar2', default: { barDefault: 'bar2', default: 'foo2' } }, - 'default' -); diff --git a/test/function/samples/deprecated/interop-true-no-live-bindings/_config.js b/test/function/samples/deprecated/interop-true-no-live-bindings/_config.js deleted file mode 100644 index d53d739e94c..00000000000 --- a/test/function/samples/deprecated/interop-true-no-live-bindings/_config.js +++ /dev/null @@ -1,48 +0,0 @@ -module.exports = { - description: 'handles interop "true" without live-bindings support', - options: { - strictDeprecations: false, - external: id => id.startsWith('external') || id === 'update', - output: { - interop: true, - format: 'cjs', - externalLiveBindings: false - } - }, - context: { - require(id) { - switch (id) { - case 'external-module': - return Object.defineProperty( - { - get default() { - return 'foo'; - }, - get barModule() { - return 'bar'; - } - }, - '__esModule', - { value: true } - ); - case 'external-cjs': - return { - get barCjs() { - return 'bar'; - } - }; - case 'external-cjs-with-default': - return { - get default() { - return 'foo'; - }, - get barDefault() { - return 'bar'; - } - }; - default: - throw new Error(`Unexpected import "${id}"`); - } - } - } -}; diff --git a/test/function/samples/deprecated/interop-true-no-live-bindings/main.js b/test/function/samples/deprecated/interop-true-no-live-bindings/main.js deleted file mode 100644 index b32dcac1b99..00000000000 --- a/test/function/samples/deprecated/interop-true-no-live-bindings/main.js +++ /dev/null @@ -1,24 +0,0 @@ -import fooModule, { barModule } from 'external-module'; -import * as bazModule from 'external-module'; -import fooCjs, { barCjs } from 'external-cjs'; -import * as bazCjs from 'external-cjs'; -import fooDefault, { barDefault } from 'external-cjs-with-default'; -import * as bazDefault from 'external-cjs-with-default'; - -assert.strictEqual(fooModule, 'foo', 'module'); -assert.strictEqual(barModule, 'bar', 'module'); -assert.deepStrictEqual(bazModule, { barModule: 'bar', default: 'foo' }, 'module'); -assert.deepStrictEqual(fooCjs, { barCjs: 'bar' }, 'cjs'); -assert.strictEqual(barCjs, 'bar', 'cjs'); -assert.deepStrictEqual( - bazCjs, - { __proto__: null, barCjs: 'bar', default: { barCjs: 'bar' } }, - 'cjs' -); -assert.deepStrictEqual(fooDefault, 'foo', 'default'); -assert.strictEqual(barDefault, 'bar', 'default'); -assert.deepStrictEqual( - bazDefault, - { __proto__: null, barDefault: 'bar', default: { barDefault: 'bar', default: 'foo' } }, - 'default' -); diff --git a/test/function/samples/deprecated/keep-used-imports-from-pure-external-modules/_config.js b/test/function/samples/deprecated/keep-used-imports-from-pure-external-modules/_config.js deleted file mode 100644 index 45fe156dc40..00000000000 --- a/test/function/samples/deprecated/keep-used-imports-from-pure-external-modules/_config.js +++ /dev/null @@ -1,24 +0,0 @@ -const assert = require('assert'); - -module.exports = { - description: 'imports from pure external modules that are used should not be omitted', - options: { - strictDeprecations: false, - external: ['warning'], - treeshake: { - pureExternalModules: ['warning'] - } - }, - context: { - require: id => { - if (id === 'warning') return arg => assert.equal(arg, 'hi'); - throw new Error('Unexpected import', id); - } - }, - warnings: [ - { - code: 'DEPRECATED_FEATURE', - message: `The "treeshake.pureExternalModules" option is deprecated. The "treeshake.moduleSideEffects" option should be used instead. "treeshake.pureExternalModules: true" is equivalent to "treeshake.moduleSideEffects: 'no-external'"` - } - ] -}; diff --git a/test/function/samples/deprecated/keep-used-imports-from-pure-external-modules/main.js b/test/function/samples/deprecated/keep-used-imports-from-pure-external-modules/main.js deleted file mode 100644 index 992a4573f52..00000000000 --- a/test/function/samples/deprecated/keep-used-imports-from-pure-external-modules/main.js +++ /dev/null @@ -1,3 +0,0 @@ -import warning from 'warning'; - -warning('hi'); diff --git a/test/function/samples/deprecated/manual-chunks-conflict/_config.js b/test/function/samples/deprecated/manual-chunks-conflict/_config.js deleted file mode 100644 index 8ef99e03397..00000000000 --- a/test/function/samples/deprecated/manual-chunks-conflict/_config.js +++ /dev/null @@ -1,17 +0,0 @@ -module.exports = { - description: 'Throws for conflicts between manual chunks', - options: { - strictDeprecations: false, - input: ['main.js'], - output: { - manualChunks: { - dep1: ['dep.js'], - dep2: ['dep.js'] - } - } - }, - generateError: { - code: 'INVALID_CHUNK', - message: `Cannot assign dep.js to the "dep2" chunk as it is already in the "dep1" chunk.` - } -}; diff --git a/test/function/samples/deprecated/manual-chunks-info/_config.js b/test/function/samples/deprecated/manual-chunks-info/_config.js deleted file mode 100644 index 48da2a15c43..00000000000 --- a/test/function/samples/deprecated/manual-chunks-info/_config.js +++ /dev/null @@ -1,240 +0,0 @@ -const assert = require('assert'); -const path = require('path'); - -function getId(name) { - return path.join(__dirname, `${name}.js`); -} - -module.exports = { - description: 'provides additional chunk information to a manualChunks function', - options: { - strictDeprecations: false, - external: 'external', - output: { - manualChunks(id, { getModuleIds, getModuleInfo }) { - assert.deepStrictEqual( - [...getModuleIds()], - [getId('main'), 'external', getId('lib'), getId('dynamic')] - ); - assert.deepStrictEqual( - JSON.parse(JSON.stringify([...getModuleIds()].map(id => getModuleInfo(id)))), - [ - { - ast: { - type: 'Program', - start: 0, - end: 123, - body: [ - { - type: 'ExportNamedDeclaration', - start: 0, - end: 43, - declaration: { - type: 'VariableDeclaration', - start: 7, - end: 43, - declarations: [ - { - type: 'VariableDeclarator', - start: 13, - end: 42, - id: { type: 'Identifier', start: 13, end: 20, name: 'promise' }, - init: { - type: 'ImportExpression', - start: 23, - end: 42, - source: { - type: 'Literal', - start: 30, - end: 41, - value: './dynamic', - raw: "'./dynamic'" - } - } - } - ], - kind: 'const' - }, - specifiers: [], - source: null - }, - { - type: 'ExportNamedDeclaration', - start: 44, - end: 85, - declaration: null, - specifiers: [ - { - type: 'ExportSpecifier', - start: 53, - end: 69, - local: { type: 'Identifier', start: 53, end: 60, name: 'default' }, - exported: { type: 'Identifier', start: 64, end: 69, name: 'value' } - } - ], - source: { type: 'Literal', start: 77, end: 84, value: './lib', raw: "'./lib'" } - }, - { - type: 'ExportNamedDeclaration', - start: 86, - end: 122, - declaration: null, - specifiers: [ - { - type: 'ExportSpecifier', - start: 95, - end: 103, - local: { type: 'Identifier', start: 95, end: 103, name: 'external' }, - exported: { type: 'Identifier', start: 95, end: 103, name: 'external' } - } - ], - source: { - type: 'Literal', - start: 111, - end: 121, - value: 'external', - raw: "'external'" - } - } - ], - sourceType: 'module' - }, - code: - "export const promise = import('./dynamic');\nexport { default as value } from './lib';\nexport { external } from 'external';\n", - dynamicallyImportedIds: [getId('dynamic')], - dynamicImporters: [], - hasModuleSideEffects: true, - id: getId('main'), - implicitlyLoadedAfterOneOf: [], - implicitlyLoadedBefore: [], - importedIds: [getId('lib'), 'external'], - importers: [], - isEntry: true, - isExternal: false, - meta: {}, - syntheticNamedExports: false - }, - { - ast: null, - code: null, - dynamicallyImportedIds: [], - dynamicImporters: [getId('dynamic')], - hasModuleSideEffects: true, - id: 'external', - implicitlyLoadedAfterOneOf: [], - implicitlyLoadedBefore: [], - importedIds: [], - importers: [getId('main')], - isEntry: false, - isExternal: true, - meta: {}, - syntheticNamedExports: false - }, - { - ast: { - type: 'Program', - start: 0, - end: 19, - body: [ - { - type: 'ExportDefaultDeclaration', - start: 0, - end: 18, - declaration: { type: 'Literal', start: 15, end: 17, value: 42, raw: '42' } - } - ], - sourceType: 'module' - }, - code: 'export default 42;\n', - dynamicallyImportedIds: [], - dynamicImporters: [], - hasModuleSideEffects: true, - id: getId('lib'), - implicitlyLoadedAfterOneOf: [], - implicitlyLoadedBefore: [], - importedIds: [], - importers: [getId('dynamic'), getId('main')], - isEntry: false, - isExternal: false, - meta: {}, - syntheticNamedExports: false - }, - { - ast: { - type: 'Program', - start: 0, - end: 88, - body: [ - { - type: 'ExportNamedDeclaration', - start: 0, - end: 42, - declaration: { - type: 'VariableDeclaration', - start: 7, - end: 42, - declarations: [ - { - type: 'VariableDeclarator', - start: 13, - end: 41, - id: { type: 'Identifier', start: 13, end: 20, name: 'promise' }, - init: { - type: 'ImportExpression', - start: 23, - end: 41, - source: { - type: 'Literal', - start: 30, - end: 40, - value: 'external', - raw: "'external'" - } - } - } - ], - kind: 'const' - }, - specifiers: [], - source: null - }, - { - type: 'ExportNamedDeclaration', - start: 43, - end: 87, - declaration: null, - specifiers: [ - { - type: 'ExportSpecifier', - start: 52, - end: 71, - local: { type: 'Identifier', start: 52, end: 59, name: 'default' }, - exported: { type: 'Identifier', start: 63, end: 71, name: 'internal' } - } - ], - source: { type: 'Literal', start: 79, end: 86, value: './lib', raw: "'./lib'" } - } - ], - sourceType: 'module' - }, - code: - "export const promise = import('external');\nexport { default as internal } from './lib';\n", - dynamicallyImportedIds: ['external'], - dynamicImporters: [getId('main')], - hasModuleSideEffects: true, - id: getId('dynamic'), - implicitlyLoadedAfterOneOf: [], - implicitlyLoadedBefore: [], - importedIds: [getId('lib')], - importers: [], - isEntry: false, - isExternal: false, - meta: {}, - syntheticNamedExports: false - } - ] - ); - } - } - } -}; diff --git a/test/function/samples/deprecated/manual-chunks-info/dynamic.js b/test/function/samples/deprecated/manual-chunks-info/dynamic.js deleted file mode 100644 index 2d2ab6f359b..00000000000 --- a/test/function/samples/deprecated/manual-chunks-info/dynamic.js +++ /dev/null @@ -1,2 +0,0 @@ -export const promise = import('external'); -export { default as internal } from './lib'; diff --git a/test/function/samples/deprecated/manual-chunks-info/main.js b/test/function/samples/deprecated/manual-chunks-info/main.js deleted file mode 100644 index c79c2fe09f7..00000000000 --- a/test/function/samples/deprecated/manual-chunks-info/main.js +++ /dev/null @@ -1,3 +0,0 @@ -export const promise = import('./dynamic'); -export { default as value } from './lib'; -export { external } from 'external'; diff --git a/test/function/samples/deprecated/manual-chunks-preserve-modules/_config.js b/test/function/samples/deprecated/manual-chunks-preserve-modules/_config.js deleted file mode 100644 index b896cd2aaa2..00000000000 --- a/test/function/samples/deprecated/manual-chunks-preserve-modules/_config.js +++ /dev/null @@ -1,15 +0,0 @@ -module.exports = { - description: 'Assigning manual chunks fails when preserving modules', - options: { - strictDeprecations: false, - input: ['main.js'], - preserveModules: true, - manualChunks: { - lib: ['lib.js'] - } - }, - generateError: { - code: 'INVALID_OPTION', - message: 'The "output.manualChunks" option is not supported for "output.preserveModules".' - } -}; diff --git a/test/function/samples/deprecated/manual-chunks-preserve-modules/lib.js b/test/function/samples/deprecated/manual-chunks-preserve-modules/lib.js deleted file mode 100644 index 46d3ca8c61f..00000000000 --- a/test/function/samples/deprecated/manual-chunks-preserve-modules/lib.js +++ /dev/null @@ -1 +0,0 @@ -export const value = 42; diff --git a/test/function/samples/deprecated/manual-chunks-preserve-modules/main.js b/test/function/samples/deprecated/manual-chunks-preserve-modules/main.js deleted file mode 100644 index 0786352d0f9..00000000000 --- a/test/function/samples/deprecated/manual-chunks-preserve-modules/main.js +++ /dev/null @@ -1,3 +0,0 @@ -import { value } from './lib'; - -assert.equal(value, 42); diff --git a/test/function/samples/deprecated/nested-inlined-dynamic-import-1/_config.js b/test/function/samples/deprecated/nested-inlined-dynamic-import-1/_config.js deleted file mode 100644 index ad243453388..00000000000 --- a/test/function/samples/deprecated/nested-inlined-dynamic-import-1/_config.js +++ /dev/null @@ -1,12 +0,0 @@ -const assert = require('assert'); - -module.exports = { - description: - 'deconflicts variables when nested dynamic imports are inlined via inlineDynamicImports', - options: { - output: { inlineDynamicImports: true } - }, - exports(exports) { - return exports().then(result => assert.strictEqual(result, 43)); - } -}; diff --git a/test/function/samples/deprecated/nested-inlined-dynamic-import-1/foo.js b/test/function/samples/deprecated/nested-inlined-dynamic-import-1/foo.js deleted file mode 100644 index 46d3ca8c61f..00000000000 --- a/test/function/samples/deprecated/nested-inlined-dynamic-import-1/foo.js +++ /dev/null @@ -1 +0,0 @@ -export const value = 42; diff --git a/test/function/samples/deprecated/nested-inlined-dynamic-import-1/main.js b/test/function/samples/deprecated/nested-inlined-dynamic-import-1/main.js deleted file mode 100644 index 24dfcc33be9..00000000000 --- a/test/function/samples/deprecated/nested-inlined-dynamic-import-1/main.js +++ /dev/null @@ -1,4 +0,0 @@ -export default () => { - const foo = 1; - return import('./foo.js').then(ns => ns.value + foo); -}; diff --git a/test/function/samples/deprecated/plugin-module-ids/_config.js b/test/function/samples/deprecated/plugin-module-ids/_config.js deleted file mode 100644 index 18bc07a2a6c..00000000000 --- a/test/function/samples/deprecated/plugin-module-ids/_config.js +++ /dev/null @@ -1,25 +0,0 @@ -const assert = require('assert'); -const path = require('path'); - -let rendered = false; - -module.exports = { - description: 'provides all module ids on the plugin context', - options: { - strictDeprecations: false, - external: ['path'], - plugins: { - renderStart() { - rendered = true; - assert.deepStrictEqual(Array.from(this.moduleIds), [ - path.join(__dirname, 'main.js'), - path.join(__dirname, 'foo.js'), - 'path' - ]); - } - } - }, - bundle() { - assert.ok(rendered); - } -}; diff --git a/test/function/samples/deprecated/plugin-module-ids/foo.js b/test/function/samples/deprecated/plugin-module-ids/foo.js deleted file mode 100644 index cb4875a0af8..00000000000 --- a/test/function/samples/deprecated/plugin-module-ids/foo.js +++ /dev/null @@ -1,3 +0,0 @@ -import path from 'path'; - -export const foo = path.resolve('foo'); diff --git a/test/function/samples/deprecated/plugin-module-ids/main.js b/test/function/samples/deprecated/plugin-module-ids/main.js deleted file mode 100644 index 9fbe8414a67..00000000000 --- a/test/function/samples/deprecated/plugin-module-ids/main.js +++ /dev/null @@ -1,2 +0,0 @@ -export { foo } from './foo.js'; -export const path = import('path'); diff --git a/test/function/samples/deprecated/preserveModules/inline-dynamic-imports/_config.js b/test/function/samples/deprecated/preserveModules/inline-dynamic-imports/_config.js deleted file mode 100644 index af0f5fe5964..00000000000 --- a/test/function/samples/deprecated/preserveModules/inline-dynamic-imports/_config.js +++ /dev/null @@ -1,14 +0,0 @@ -module.exports = { - description: 'Inlining dynamic imports is not supported when preserving modules', - options: { - strictDeprecations: false, - input: ['main.js'], - preserveModules: true, - inlineDynamicImports: true - }, - generateError: { - code: 'INVALID_OPTION', - message: - 'The "output.inlineDynamicImports" option is not supported for "output.preserveModules".' - } -}; diff --git a/test/function/samples/deprecated/preserveModules/inline-dynamic-imports/lib.js b/test/function/samples/deprecated/preserveModules/inline-dynamic-imports/lib.js deleted file mode 100644 index 46d3ca8c61f..00000000000 --- a/test/function/samples/deprecated/preserveModules/inline-dynamic-imports/lib.js +++ /dev/null @@ -1 +0,0 @@ -export const value = 42; diff --git a/test/function/samples/deprecated/preserveModules/inline-dynamic-imports/main.js b/test/function/samples/deprecated/preserveModules/inline-dynamic-imports/main.js deleted file mode 100644 index 4869dc82f38..00000000000 --- a/test/function/samples/deprecated/preserveModules/inline-dynamic-imports/main.js +++ /dev/null @@ -1 +0,0 @@ -import('./lib').then(({value}) => assert.equal(value, 42)); diff --git a/test/function/samples/deprecated/preserveModules/invalid-default-export-mode/_config.js b/test/function/samples/deprecated/preserveModules/invalid-default-export-mode/_config.js deleted file mode 100644 index 88944569e52..00000000000 --- a/test/function/samples/deprecated/preserveModules/invalid-default-export-mode/_config.js +++ /dev/null @@ -1,16 +0,0 @@ -module.exports = { - description: 'throws when using default export mode with named exports', - options: { - strictDeprecations: false, - input: ['main.js'], - preserveModules: true, - output: { - exports: 'default' - } - }, - generateError: { - code: 'INVALID_EXPORT_OPTION', - message: - '"default" was specified for "output.exports", but entry module "lib.js" has the following exports: value' - } -}; diff --git a/test/function/samples/deprecated/preserveModules/invalid-default-export-mode/lib.js b/test/function/samples/deprecated/preserveModules/invalid-default-export-mode/lib.js deleted file mode 100644 index 46d3ca8c61f..00000000000 --- a/test/function/samples/deprecated/preserveModules/invalid-default-export-mode/lib.js +++ /dev/null @@ -1 +0,0 @@ -export const value = 42; diff --git a/test/function/samples/deprecated/preserveModules/invalid-default-export-mode/main.js b/test/function/samples/deprecated/preserveModules/invalid-default-export-mode/main.js deleted file mode 100644 index c379b667da9..00000000000 --- a/test/function/samples/deprecated/preserveModules/invalid-default-export-mode/main.js +++ /dev/null @@ -1,3 +0,0 @@ -import { value } from './lib.js'; -assert.equal(value, 42); -export default 43; diff --git a/test/function/samples/deprecated/preserveModules/invalid-no-preserve-entry-signatures/_config.js b/test/function/samples/deprecated/preserveModules/invalid-no-preserve-entry-signatures/_config.js deleted file mode 100644 index dc378668cc5..00000000000 --- a/test/function/samples/deprecated/preserveModules/invalid-no-preserve-entry-signatures/_config.js +++ /dev/null @@ -1,14 +0,0 @@ -module.exports = { - description: 'throws when setting preserveEntrySignatures to false', - options: { - strictDeprecations: false, - input: ['main.js'], - preserveModules: true, - preserveEntrySignatures: false - }, - generateError: { - code: 'INVALID_OPTION', - message: - 'Setting "preserveEntrySignatures" to "false" is not supported for "output.preserveModules".' - } -}; diff --git a/test/function/samples/deprecated/preserveModules/invalid-none-export-mode/_config.js b/test/function/samples/deprecated/preserveModules/invalid-none-export-mode/_config.js deleted file mode 100644 index e9fadad6a3e..00000000000 --- a/test/function/samples/deprecated/preserveModules/invalid-none-export-mode/_config.js +++ /dev/null @@ -1,16 +0,0 @@ -module.exports = { - description: 'throws when using none export mode with named exports', - options: { - strictDeprecations: false, - input: ['main.js'], - preserveModules: true, - output: { - exports: 'none' - } - }, - generateError: { - code: 'INVALID_EXPORT_OPTION', - message: - '"none" was specified for "output.exports", but entry module "lib.js" has the following exports: value' - } -}; diff --git a/test/function/samples/deprecated/preserveModules/invalid-none-export-mode/lib.js b/test/function/samples/deprecated/preserveModules/invalid-none-export-mode/lib.js deleted file mode 100644 index 46d3ca8c61f..00000000000 --- a/test/function/samples/deprecated/preserveModules/invalid-none-export-mode/lib.js +++ /dev/null @@ -1 +0,0 @@ -export const value = 42; diff --git a/test/function/samples/deprecated/preserveModules/invalid-none-export-mode/main.js b/test/function/samples/deprecated/preserveModules/invalid-none-export-mode/main.js deleted file mode 100644 index f26e8d860a6..00000000000 --- a/test/function/samples/deprecated/preserveModules/invalid-none-export-mode/main.js +++ /dev/null @@ -1,3 +0,0 @@ -import { value } from './lib.js'; - -assert.equal(value, 42); diff --git a/test/function/samples/deprecated/preserveModules/manual-chunks/_config.js b/test/function/samples/deprecated/preserveModules/manual-chunks/_config.js deleted file mode 100644 index 3bef57f7752..00000000000 --- a/test/function/samples/deprecated/preserveModules/manual-chunks/_config.js +++ /dev/null @@ -1,17 +0,0 @@ -module.exports = { - description: 'Assigning manual chunks fails when preserving modules', - options: { - strictDeprecations: false, - input: ['main.js'], - preserveModules: true, - output: { - manualChunks: { - lib: ['lib.js'] - } - } - }, - generateError: { - code: 'INVALID_OPTION', - message: 'The "output.manualChunks" option is not supported for "output.preserveModules".' - } -}; diff --git a/test/function/samples/deprecated/preserveModules/manual-chunks/lib.js b/test/function/samples/deprecated/preserveModules/manual-chunks/lib.js deleted file mode 100644 index 46d3ca8c61f..00000000000 --- a/test/function/samples/deprecated/preserveModules/manual-chunks/lib.js +++ /dev/null @@ -1 +0,0 @@ -export const value = 42; diff --git a/test/function/samples/deprecated/preserveModules/manual-chunks/main.js b/test/function/samples/deprecated/preserveModules/manual-chunks/main.js deleted file mode 100644 index 0786352d0f9..00000000000 --- a/test/function/samples/deprecated/preserveModules/manual-chunks/main.js +++ /dev/null @@ -1,3 +0,0 @@ -import { value } from './lib'; - -assert.equal(value, 42); diff --git a/test/function/samples/deprecated/preserveModules/mixed-exports/_config.js b/test/function/samples/deprecated/preserveModules/mixed-exports/_config.js deleted file mode 100644 index 239d8f84960..00000000000 --- a/test/function/samples/deprecated/preserveModules/mixed-exports/_config.js +++ /dev/null @@ -1,26 +0,0 @@ -const path = require('path'); - -module.exports = { - description: 'warns for mixed exports in all chunks when preserving modules', - options: { - strictDeprecations: false, - input: ['main.js'], - preserveModules: true - }, - warnings: [ - { - code: 'MIXED_EXPORTS', - id: path.join(__dirname, 'main.js'), - message: - 'Entry module "main.js" is using named and default exports together. Consumers of your bundle will have to use `chunk["default"]` to access the default export, which may not be what you want. Use `output.exports: "named"` to disable this warning', - url: 'https://rollupjs.org/guide/en/#outputexports' - }, - { - code: 'MIXED_EXPORTS', - id: path.join(__dirname, 'lib1.js'), - message: - 'Entry module "lib1.js" is using named and default exports together. Consumers of your bundle will have to use `chunk["default"]` to access the default export, which may not be what you want. Use `output.exports: "named"` to disable this warning', - url: 'https://rollupjs.org/guide/en/#outputexports' - } - ] -}; diff --git a/test/function/samples/deprecated/preserveModules/mixed-exports/lib1.js b/test/function/samples/deprecated/preserveModules/mixed-exports/lib1.js deleted file mode 100644 index fea73e2bf15..00000000000 --- a/test/function/samples/deprecated/preserveModules/mixed-exports/lib1.js +++ /dev/null @@ -1,2 +0,0 @@ -export const value1 = 42; -export default 42; diff --git a/test/function/samples/deprecated/preserveModules/mixed-exports/lib3.js b/test/function/samples/deprecated/preserveModules/mixed-exports/lib3.js deleted file mode 100644 index baeef4a82d8..00000000000 --- a/test/function/samples/deprecated/preserveModules/mixed-exports/lib3.js +++ /dev/null @@ -1 +0,0 @@ -export const value3 = 42; diff --git a/test/function/samples/deprecated/preserveModules/mixed-exports/main.js b/test/function/samples/deprecated/preserveModules/mixed-exports/main.js deleted file mode 100644 index 0bd8737542e..00000000000 --- a/test/function/samples/deprecated/preserveModules/mixed-exports/main.js +++ /dev/null @@ -1,11 +0,0 @@ -import lib1, { value1 } from './lib1'; -import lib2 from './lib2'; -import { value3 } from './lib3'; - -assert.equal(lib1, 42); -assert.equal(value1, 42); -assert.equal(lib2, 42); -assert.equal(value3, 42); - -export const value = 42; -export default 42; diff --git a/test/function/samples/deprecated/preserveModules/virtual-modules-conflict/_config.js b/test/function/samples/deprecated/preserveModules/virtual-modules-conflict/_config.js deleted file mode 100644 index 0f024647c97..00000000000 --- a/test/function/samples/deprecated/preserveModules/virtual-modules-conflict/_config.js +++ /dev/null @@ -1,33 +0,0 @@ -const assert = require('assert'); - -module.exports = { - description: 'Generates actual files for virtual modules when preserving modules', - options: { - strictDeprecations: false, - input: ['main.js'], - preserveModules: true, - plugins: [ - { - resolveId(id) { - if (id === '\0virtualModule.js') return id; - }, - load(id) { - if (id !== '\0virtualModule.js') return null; - return 'export const virtual = "Virtual!";\n'; - }, - transform(code, id) { - if (id === '\0virtualModule.js') return null; - return 'import {virtual} from "\0virtualModule.js";\n' + code; - } - } - ] - }, - bundle(bundle) { - return bundle.generate({ format: 'es' }).then(generated => - assert.deepEqual( - generated.output.map(chunk => chunk.fileName), - ['main.js', '_virtual/_virtualModule.js', '_virtual/_virtualModule2.js'] - ) - ); - } -}; diff --git a/test/function/samples/deprecated/preserveModules/virtual-modules-conflict/_virtual/_virtualModule.js b/test/function/samples/deprecated/preserveModules/virtual-modules-conflict/_virtual/_virtualModule.js deleted file mode 100644 index 3901a31bd31..00000000000 --- a/test/function/samples/deprecated/preserveModules/virtual-modules-conflict/_virtual/_virtualModule.js +++ /dev/null @@ -1,3 +0,0 @@ -export const notSoVirtual = 'real'; - -assert.equal(virtual, 'Virtual!'); diff --git a/test/function/samples/deprecated/preserveModules/virtual-modules-conflict/main.js b/test/function/samples/deprecated/preserveModules/virtual-modules-conflict/main.js deleted file mode 100644 index 7653b354896..00000000000 --- a/test/function/samples/deprecated/preserveModules/virtual-modules-conflict/main.js +++ /dev/null @@ -1,4 +0,0 @@ -import { notSoVirtual } from './_virtual/_virtualModule'; - -assert.equal(virtual, 'Virtual!'); -assert.equal(notSoVirtual, 'real'); diff --git a/test/function/samples/deprecated/preserveModules/virtual-modules/_config.js b/test/function/samples/deprecated/preserveModules/virtual-modules/_config.js deleted file mode 100644 index 47d4dfa4303..00000000000 --- a/test/function/samples/deprecated/preserveModules/virtual-modules/_config.js +++ /dev/null @@ -1,33 +0,0 @@ -const assert = require('assert'); - -module.exports = { - description: 'Generates actual files for virtual modules when preserving modules', - options: { - strictDeprecations: false, - input: ['main.js'], - preserveModules: true, - plugins: [ - { - resolveId(id) { - if (id === '\0virtualModule') return id; - }, - load(id) { - if (id !== '\0virtualModule') return null; - return 'export const virtual = "Virtual!";\n'; - }, - transform(code, id) { - if (id === '\0virtualModule') return null; - return 'import {virtual} from "\0virtualModule";\n' + code; - } - } - ] - }, - bundle(bundle) { - return bundle.generate({ format: 'es' }).then(generated => - assert.deepEqual( - generated.output.map(chunk => chunk.fileName), - ['main.js', '_virtual/_virtualModule', 'lib/lib.js'] - ) - ); - } -}; diff --git a/test/function/samples/deprecated/preserveModules/virtual-modules/lib/lib.js b/test/function/samples/deprecated/preserveModules/virtual-modules/lib/lib.js deleted file mode 100644 index 505982998fa..00000000000 --- a/test/function/samples/deprecated/preserveModules/virtual-modules/lib/lib.js +++ /dev/null @@ -1 +0,0 @@ -assert.equal(virtual, 'Virtual!'); diff --git a/test/function/samples/deprecated/preserveModules/virtual-modules/main.js b/test/function/samples/deprecated/preserveModules/virtual-modules/main.js deleted file mode 100644 index f983b2526f1..00000000000 --- a/test/function/samples/deprecated/preserveModules/virtual-modules/main.js +++ /dev/null @@ -1,3 +0,0 @@ -import './lib/lib.js'; - -assert.equal(virtual, 'Virtual!'); diff --git a/test/function/samples/deprecated/sourcemap-true-generatebundle/_config.js b/test/function/samples/deprecated/sourcemap-true-generatebundle/_config.js new file mode 100644 index 00000000000..c4ce9a2bc67 --- /dev/null +++ b/test/function/samples/deprecated/sourcemap-true-generatebundle/_config.js @@ -0,0 +1,29 @@ +const assert = require('node:assert'); + +module.exports = defineTest({ + description: 'emits sourcemaps before generateBundle hook', + options: { + strictDeprecations: false, + plugins: [ + { + name: 'test', + generateBundle(options, bundle) { + assert.deepStrictEqual(Object.keys(bundle), ['main.js', 'main.js.map']); + assert.strictEqual( + bundle['main.js'].code, + `'use strict'; + +var main = 42; + +module.exports = main; +//# sourceMappingURL=main.js.map +` + ); + assert.strictEqual(bundle['main.js.map'].name, undefined); + assert.strictEqual(bundle['main.js.map'].originalFileName, null); + } + } + ], + output: { sourcemap: true } + } +}); diff --git a/test/function/samples/deprecations/preserveModules/main.js b/test/function/samples/deprecated/sourcemap-true-generatebundle/main.js similarity index 100% rename from test/function/samples/deprecations/preserveModules/main.js rename to test/function/samples/deprecated/sourcemap-true-generatebundle/main.js diff --git a/test/function/samples/deprecations/ROLLUP_ASSET_URL/_config.js b/test/function/samples/deprecations/ROLLUP_ASSET_URL/_config.js deleted file mode 100644 index cc75750f1ab..00000000000 --- a/test/function/samples/deprecations/ROLLUP_ASSET_URL/_config.js +++ /dev/null @@ -1,19 +0,0 @@ -module.exports = { - description: 'marks ROLLUP_ASSET_URL as deprecated', - options: { - plugins: { - load(id) { - return `export default import.meta.ROLLUP_ASSET_URL_${this.emitFile({ - type: 'asset', - name: 'asset', - source: 'asset' - })};`; - } - } - }, - generateError: { - code: 'DEPRECATED_FEATURE', - message: - 'Using the "ROLLUP_ASSET_URL_" prefix to reference files is deprecated. Use the "ROLLUP_FILE_URL_" prefix instead.' - } -}; diff --git a/test/function/samples/deprecations/ROLLUP_ASSET_URL/main.js b/test/function/samples/deprecations/ROLLUP_ASSET_URL/main.js deleted file mode 100644 index f8a2d88d245..00000000000 --- a/test/function/samples/deprecations/ROLLUP_ASSET_URL/main.js +++ /dev/null @@ -1,11 +0,0 @@ -const foo = {}; - -function doIt(x) { - if (foo[x]) { - return true; - } - foo[x] = true; -} - -doIt('x'); -assert.ok(doIt('x'), 'foo was not reassigned'); diff --git a/test/function/samples/deprecations/ROLLUP_CHUNK_URL/_config.js b/test/function/samples/deprecations/ROLLUP_CHUNK_URL/_config.js deleted file mode 100644 index eac2bdb901b..00000000000 --- a/test/function/samples/deprecations/ROLLUP_CHUNK_URL/_config.js +++ /dev/null @@ -1,26 +0,0 @@ -module.exports = { - description: 'marks ROLLUP_CHUNK_URL as deprecated', - options: { - plugins: { - resolveId(id) { - if (id === 'chunk') { - return id; - } - }, - load(id) { - if (id === 'chunk') { - return "console.log('chunk')"; - } - return `export default import.meta.ROLLUP_CHUNK_URL_${this.emitFile({ - type: 'chunk', - id: 'chunk' - })};`; - } - } - }, - generateError: { - code: 'DEPRECATED_FEATURE', - message: - 'Using the "ROLLUP_CHUNK_URL_" prefix to reference files is deprecated. Use the "ROLLUP_FILE_URL_" prefix instead.' - } -}; diff --git a/test/function/samples/deprecations/ROLLUP_CHUNK_URL/main.js b/test/function/samples/deprecations/ROLLUP_CHUNK_URL/main.js deleted file mode 100644 index f8a2d88d245..00000000000 --- a/test/function/samples/deprecations/ROLLUP_CHUNK_URL/main.js +++ /dev/null @@ -1,11 +0,0 @@ -const foo = {}; - -function doIt(x) { - if (foo[x]) { - return true; - } - foo[x] = true; -} - -doIt('x'); -assert.ok(doIt('x'), 'foo was not reassigned'); diff --git a/test/function/samples/deprecations/asset-filename-name/_config.js b/test/function/samples/deprecations/asset-filename-name/_config.js new file mode 100644 index 00000000000..fa9ea1a19d3 --- /dev/null +++ b/test/function/samples/deprecations/asset-filename-name/_config.js @@ -0,0 +1,29 @@ +module.exports = defineTest({ + description: 'marks the "name" property of emitted assets as deprecated in assetFileNames', + options: { + output: { + assetFileNames(chunkInfo) { + console.log(chunkInfo.name); + return '[name][extname]'; + } + }, + strictDeprecations: true, + plugins: { + name: 'test', + buildStart() { + this.emitFile({ + type: 'asset', + name: 'test.txt', + originalFileName: 'test.txt', + source: 'test' + }); + } + } + }, + generateError: { + code: 'DEPRECATED_FEATURE', + message: + 'Accessing the "name" property of emitted assets when generating the file name is deprecated. Use the "names" property instead.', + url: 'https://rollupjs.org/plugin-development/#generatebundle' + } +}); diff --git a/test/function/samples/deprecations/asset-filename-name/_expected.js b/test/function/samples/deprecations/asset-filename-name/_expected.js new file mode 100644 index 00000000000..2d417264620 --- /dev/null +++ b/test/function/samples/deprecations/asset-filename-name/_expected.js @@ -0,0 +1,6 @@ +import('external'); +import(globalThis.unknown); +import('resolvedString'); +import('resolved-id'); +import('resolved-different'); +import('unresolved'); diff --git a/test/function/samples/deprecations/asset-filename-name/main.js b/test/function/samples/deprecations/asset-filename-name/main.js new file mode 100644 index 00000000000..cc1d88a24fa --- /dev/null +++ b/test/function/samples/deprecations/asset-filename-name/main.js @@ -0,0 +1 @@ +assert.ok(true); diff --git a/test/function/samples/deprecations/asset-filename-originalfilename/_config.js b/test/function/samples/deprecations/asset-filename-originalfilename/_config.js new file mode 100644 index 00000000000..837d4ab1057 --- /dev/null +++ b/test/function/samples/deprecations/asset-filename-originalfilename/_config.js @@ -0,0 +1,29 @@ +module.exports = defineTest({ + description: 'marks the "name" property of emitted assets as deprecated in assetFileNames', + options: { + output: { + assetFileNames(chunkInfo) { + console.log(chunkInfo.originalFileName); + return '[name][extname]'; + } + }, + strictDeprecations: true, + plugins: { + name: 'test', + buildStart() { + this.emitFile({ + type: 'asset', + name: 'test.txt', + originalFileName: 'test.txt', + source: 'test' + }); + } + } + }, + generateError: { + code: 'DEPRECATED_FEATURE', + message: + 'Accessing the "originalFileName" property of emitted assets when generating the file name is deprecated. Use the "originalFileNames" property instead.', + url: 'https://rollupjs.org/plugin-development/#generatebundle' + } +}); diff --git a/test/function/samples/deprecations/asset-filename-originalfilename/_expected.js b/test/function/samples/deprecations/asset-filename-originalfilename/_expected.js new file mode 100644 index 00000000000..2d417264620 --- /dev/null +++ b/test/function/samples/deprecations/asset-filename-originalfilename/_expected.js @@ -0,0 +1,6 @@ +import('external'); +import(globalThis.unknown); +import('resolvedString'); +import('resolved-id'); +import('resolved-different'); +import('unresolved'); diff --git a/test/function/samples/deprecations/asset-filename-originalfilename/main.js b/test/function/samples/deprecations/asset-filename-originalfilename/main.js new file mode 100644 index 00000000000..cc1d88a24fa --- /dev/null +++ b/test/function/samples/deprecations/asset-filename-originalfilename/main.js @@ -0,0 +1 @@ +assert.ok(true); diff --git a/test/function/samples/deprecations/asset-name-in-bundle/_config.js b/test/function/samples/deprecations/asset-name-in-bundle/_config.js new file mode 100644 index 00000000000..37300388614 --- /dev/null +++ b/test/function/samples/deprecations/asset-name-in-bundle/_config.js @@ -0,0 +1,30 @@ +module.exports = defineTest({ + description: 'marks the "name" property of emitted assets as deprecated in generateBundle', + options: { + output: { assetFileNames: '[name][extname]' }, + strictDeprecations: true, + plugins: { + name: 'test', + buildStart() { + this.emitFile({ + type: 'asset', + name: 'test.txt', + originalFileName: 'test.txt', + source: 'test' + }); + }, + generateBundle(options, bundle) { + console.log(bundle['test.txt'].name); + } + } + }, + generateError: { + code: 'PLUGIN_ERROR', + hook: 'generateBundle', + message: + 'Accessing the "name" property of emitted assets in the bundle is deprecated. Use the "names" property instead.', + plugin: 'test', + pluginCode: 'DEPRECATED_FEATURE', + url: 'https://rollupjs.org/plugin-development/#generatebundle' + } +}); diff --git a/test/function/samples/deprecations/asset-name-in-bundle/_expected.js b/test/function/samples/deprecations/asset-name-in-bundle/_expected.js new file mode 100644 index 00000000000..2d417264620 --- /dev/null +++ b/test/function/samples/deprecations/asset-name-in-bundle/_expected.js @@ -0,0 +1,6 @@ +import('external'); +import(globalThis.unknown); +import('resolvedString'); +import('resolved-id'); +import('resolved-different'); +import('unresolved'); diff --git a/test/function/samples/deprecations/asset-name-in-bundle/main.js b/test/function/samples/deprecations/asset-name-in-bundle/main.js new file mode 100644 index 00000000000..cc1d88a24fa --- /dev/null +++ b/test/function/samples/deprecations/asset-name-in-bundle/main.js @@ -0,0 +1 @@ +assert.ok(true); diff --git a/test/function/samples/deprecations/asset-originalfilename-in-bundle/_config.js b/test/function/samples/deprecations/asset-originalfilename-in-bundle/_config.js new file mode 100644 index 00000000000..9b25343cf61 --- /dev/null +++ b/test/function/samples/deprecations/asset-originalfilename-in-bundle/_config.js @@ -0,0 +1,31 @@ +module.exports = defineTest({ + description: + 'marks the "originalFileName" property of emitted assets as deprecated in generateBundle', + options: { + output: { assetFileNames: '[name][extname]' }, + strictDeprecations: true, + plugins: { + name: 'test', + buildStart() { + this.emitFile({ + type: 'asset', + name: 'test.txt', + originalFileName: 'test.txt', + source: 'test' + }); + }, + generateBundle(options, bundle) { + console.log(bundle['test.txt'].originalFileName); + } + } + }, + generateError: { + code: 'PLUGIN_ERROR', + hook: 'generateBundle', + message: + 'Accessing the "originalFileName" property of emitted assets in the bundle is deprecated. Use the "originalFileNames" property instead.', + plugin: 'test', + pluginCode: 'DEPRECATED_FEATURE', + url: 'https://rollupjs.org/plugin-development/#generatebundle' + } +}); diff --git a/test/function/samples/deprecations/asset-originalfilename-in-bundle/_expected.js b/test/function/samples/deprecations/asset-originalfilename-in-bundle/_expected.js new file mode 100644 index 00000000000..2d417264620 --- /dev/null +++ b/test/function/samples/deprecations/asset-originalfilename-in-bundle/_expected.js @@ -0,0 +1,6 @@ +import('external'); +import(globalThis.unknown); +import('resolvedString'); +import('resolved-id'); +import('resolved-different'); +import('unresolved'); diff --git a/test/function/samples/deprecations/asset-originalfilename-in-bundle/main.js b/test/function/samples/deprecations/asset-originalfilename-in-bundle/main.js new file mode 100644 index 00000000000..cc1d88a24fa --- /dev/null +++ b/test/function/samples/deprecations/asset-originalfilename-in-bundle/main.js @@ -0,0 +1 @@ +assert.ok(true); diff --git a/test/function/samples/deprecations/asset-render-chunk-name-in-bundle/_config.js b/test/function/samples/deprecations/asset-render-chunk-name-in-bundle/_config.js new file mode 100644 index 00000000000..389aee51783 --- /dev/null +++ b/test/function/samples/deprecations/asset-render-chunk-name-in-bundle/_config.js @@ -0,0 +1,31 @@ +module.exports = defineTest({ + description: + 'marks the "name" property of emitted assets as deprecated in generateBundle when emitted during generate phase', + options: { + output: { assetFileNames: '[name][extname]' }, + strictDeprecations: true, + plugins: { + name: 'test', + renderChunk() { + this.emitFile({ + type: 'asset', + name: 'test.txt', + originalFileName: 'test.txt', + source: 'test' + }); + }, + generateBundle(options, bundle) { + console.log(bundle['test.txt'].name); + } + } + }, + generateError: { + code: 'PLUGIN_ERROR', + hook: 'generateBundle', + message: + 'Accessing the "name" property of emitted assets in the bundle is deprecated. Use the "names" property instead.', + plugin: 'test', + pluginCode: 'DEPRECATED_FEATURE', + url: 'https://rollupjs.org/plugin-development/#generatebundle' + } +}); diff --git a/test/function/samples/deprecations/asset-render-chunk-name-in-bundle/_expected.js b/test/function/samples/deprecations/asset-render-chunk-name-in-bundle/_expected.js new file mode 100644 index 00000000000..2d417264620 --- /dev/null +++ b/test/function/samples/deprecations/asset-render-chunk-name-in-bundle/_expected.js @@ -0,0 +1,6 @@ +import('external'); +import(globalThis.unknown); +import('resolvedString'); +import('resolved-id'); +import('resolved-different'); +import('unresolved'); diff --git a/test/function/samples/deprecations/asset-render-chunk-name-in-bundle/main.js b/test/function/samples/deprecations/asset-render-chunk-name-in-bundle/main.js new file mode 100644 index 00000000000..cc1d88a24fa --- /dev/null +++ b/test/function/samples/deprecations/asset-render-chunk-name-in-bundle/main.js @@ -0,0 +1 @@ +assert.ok(true); diff --git a/test/function/samples/deprecations/asset-render-chunk-originalfilename-in-bundle/_config.js b/test/function/samples/deprecations/asset-render-chunk-originalfilename-in-bundle/_config.js new file mode 100644 index 00000000000..c16ba0cdd69 --- /dev/null +++ b/test/function/samples/deprecations/asset-render-chunk-originalfilename-in-bundle/_config.js @@ -0,0 +1,31 @@ +module.exports = defineTest({ + description: + 'marks the "originalFileName" property of emitted assets as deprecated in generateBundle when emitted during generate phase', + options: { + output: { assetFileNames: '[name][extname]' }, + strictDeprecations: true, + plugins: { + name: 'test', + renderChunk() { + this.emitFile({ + type: 'asset', + name: 'test.txt', + originalFileName: 'test.txt', + source: 'test' + }); + }, + generateBundle(options, bundle) { + console.log(bundle['test.txt'].originalFileName); + } + } + }, + generateError: { + code: 'PLUGIN_ERROR', + hook: 'generateBundle', + message: + 'Accessing the "originalFileName" property of emitted assets in the bundle is deprecated. Use the "originalFileNames" property instead.', + plugin: 'test', + pluginCode: 'DEPRECATED_FEATURE', + url: 'https://rollupjs.org/plugin-development/#generatebundle' + } +}); diff --git a/test/function/samples/deprecations/asset-render-chunk-originalfilename-in-bundle/_expected.js b/test/function/samples/deprecations/asset-render-chunk-originalfilename-in-bundle/_expected.js new file mode 100644 index 00000000000..2d417264620 --- /dev/null +++ b/test/function/samples/deprecations/asset-render-chunk-originalfilename-in-bundle/_expected.js @@ -0,0 +1,6 @@ +import('external'); +import(globalThis.unknown); +import('resolvedString'); +import('resolved-id'); +import('resolved-different'); +import('unresolved'); diff --git a/test/function/samples/deprecations/asset-render-chunk-originalfilename-in-bundle/main.js b/test/function/samples/deprecations/asset-render-chunk-originalfilename-in-bundle/main.js new file mode 100644 index 00000000000..cc1d88a24fa --- /dev/null +++ b/test/function/samples/deprecations/asset-render-chunk-originalfilename-in-bundle/main.js @@ -0,0 +1 @@ +assert.ok(true); diff --git a/test/function/samples/deprecations/dynamicImportFunction/_config.js b/test/function/samples/deprecations/dynamicImportFunction/_config.js deleted file mode 100644 index 10db1585d19..00000000000 --- a/test/function/samples/deprecations/dynamicImportFunction/_config.js +++ /dev/null @@ -1,13 +0,0 @@ -module.exports = { - description: 'marks the "output.dynamicImportFunction" option as deprecated', - options: { - output: { - dynamicImportFunction: 'foo' - } - }, - generateError: { - code: 'DEPRECATED_FEATURE', - message: - 'The "output.dynamicImportFunction" option is deprecated. Use the "renderDynamicImport" plugin hook instead.' - } -}; diff --git a/test/function/samples/deprecations/dynamicImportFunction/main.js b/test/function/samples/deprecations/dynamicImportFunction/main.js deleted file mode 100644 index f8a2d88d245..00000000000 --- a/test/function/samples/deprecations/dynamicImportFunction/main.js +++ /dev/null @@ -1,11 +0,0 @@ -const foo = {}; - -function doIt(x) { - if (foo[x]) { - return true; - } - foo[x] = true; -} - -doIt('x'); -assert.ok(doIt('x'), 'foo was not reassigned'); diff --git a/test/function/samples/deprecations/externalImportAssertions/_config.js b/test/function/samples/deprecations/externalImportAssertions/_config.js new file mode 100644 index 00000000000..ef167bd3a72 --- /dev/null +++ b/test/function/samples/deprecations/externalImportAssertions/_config.js @@ -0,0 +1,12 @@ +module.exports = defineTest({ + description: 'marks the "output.externalImportAssertions" option as deprecated', + options: { + output: { externalImportAssertions: false } + }, + generateError: { + code: 'DEPRECATED_FEATURE', + message: + 'The "output.externalImportAssertions" option is deprecated. Use the "output.externalImportAttributes" option instead.', + url: 'https://rollupjs.org/configuration-options/#output-externalimportattributes' + } +}); diff --git a/test/function/samples/deprecations/externalImportAssertions/_expected.js b/test/function/samples/deprecations/externalImportAssertions/_expected.js new file mode 100644 index 00000000000..2d417264620 --- /dev/null +++ b/test/function/samples/deprecations/externalImportAssertions/_expected.js @@ -0,0 +1,6 @@ +import('external'); +import(globalThis.unknown); +import('resolvedString'); +import('resolved-id'); +import('resolved-different'); +import('unresolved'); diff --git a/test/function/samples/deprecations/externalImportAssertions/main.js b/test/function/samples/deprecations/externalImportAssertions/main.js new file mode 100644 index 00000000000..025b6045192 --- /dev/null +++ b/test/function/samples/deprecations/externalImportAssertions/main.js @@ -0,0 +1,6 @@ +import('external', { with: { type: 'special' } }); +import(globalThis.unknown, { with: { type: 'special' } }); +import(`external-${globalThis.unknown}`, { with: { type: 'special' } }); +import('external' + globalThis.unknown, { with: { type: 'special' } }); +import('external-resolved', { with: { type: 'special' } }); +import('unresolved', { with: { type: 'special' } }); diff --git a/test/function/samples/deprecations/inlineDynamicImports/_config.js b/test/function/samples/deprecations/inlineDynamicImports/_config.js deleted file mode 100644 index 82055f9b9ed..00000000000 --- a/test/function/samples/deprecations/inlineDynamicImports/_config.js +++ /dev/null @@ -1,11 +0,0 @@ -module.exports = { - description: 'marks the "inlineDynamicImports" input option as deprecated', - options: { - inlineDynamicImports: true - }, - error: { - code: 'DEPRECATED_FEATURE', - message: - 'The "inlineDynamicImports" option is deprecated. Use the "output.inlineDynamicImports" option instead.' - } -}; diff --git a/test/function/samples/deprecations/interop-false-function/_config.js b/test/function/samples/deprecations/interop-false-function/_config.js deleted file mode 100644 index 4225a5582f2..00000000000 --- a/test/function/samples/deprecations/interop-false-function/_config.js +++ /dev/null @@ -1,17 +0,0 @@ -module.exports = { - description: - 'marks "false" for the "output.interop" option as deprecated when using the function form', - options: { - strictDeprecations: true, - external: 'external', - output: { - interop: () => false - } - }, - generateError: { - code: 'DEPRECATED_FEATURE', - message: - 'The boolean value "false" for the "output.interop" option is deprecated. Use "esModule", "default" or "defaultOnly" instead.', - url: 'https://rollupjs.org/guide/en/#outputinterop' - } -}; diff --git a/test/function/samples/deprecations/interop-false-function/main.js b/test/function/samples/deprecations/interop-false-function/main.js deleted file mode 100644 index 785cd9f1e41..00000000000 --- a/test/function/samples/deprecations/interop-false-function/main.js +++ /dev/null @@ -1 +0,0 @@ -export { default } from 'external'; diff --git a/test/function/samples/deprecations/interop-false/_config.js b/test/function/samples/deprecations/interop-false/_config.js deleted file mode 100644 index 185d6c320c3..00000000000 --- a/test/function/samples/deprecations/interop-false/_config.js +++ /dev/null @@ -1,16 +0,0 @@ -module.exports = { - description: 'marks "false" for the "output.interop" option as deprecated', - options: { - strictDeprecations: true, - external: 'external', - output: { - interop: false - } - }, - generateError: { - code: 'DEPRECATED_FEATURE', - message: - 'The boolean value "false" for the "output.interop" option is deprecated. Use "esModule", "default" or "defaultOnly" instead.', - url: 'https://rollupjs.org/guide/en/#outputinterop' - } -}; diff --git a/test/function/samples/deprecations/interop-false/main.js b/test/function/samples/deprecations/interop-false/main.js deleted file mode 100644 index 785cd9f1e41..00000000000 --- a/test/function/samples/deprecations/interop-false/main.js +++ /dev/null @@ -1 +0,0 @@ -export { default } from 'external'; diff --git a/test/function/samples/deprecations/interop-true-function/_config.js b/test/function/samples/deprecations/interop-true-function/_config.js deleted file mode 100644 index 83fff02bcb9..00000000000 --- a/test/function/samples/deprecations/interop-true-function/_config.js +++ /dev/null @@ -1,17 +0,0 @@ -module.exports = { - description: - 'marks "true" for the "output.interop" option as deprecated when using the function form', - options: { - strictDeprecations: true, - external: 'external', - output: { - interop: () => true - } - }, - generateError: { - code: 'DEPRECATED_FEATURE', - message: - 'The boolean value "true" for the "output.interop" option is deprecated. Use "auto" instead.', - url: 'https://rollupjs.org/guide/en/#outputinterop' - } -}; diff --git a/test/function/samples/deprecations/interop-true-function/main.js b/test/function/samples/deprecations/interop-true-function/main.js deleted file mode 100644 index 785cd9f1e41..00000000000 --- a/test/function/samples/deprecations/interop-true-function/main.js +++ /dev/null @@ -1 +0,0 @@ -export { default } from 'external'; diff --git a/test/function/samples/deprecations/interop-true/_config.js b/test/function/samples/deprecations/interop-true/_config.js deleted file mode 100644 index 737206217d1..00000000000 --- a/test/function/samples/deprecations/interop-true/_config.js +++ /dev/null @@ -1,16 +0,0 @@ -module.exports = { - description: 'marks "true" for the "output.interop" option as deprecated', - options: { - strictDeprecations: true, - external: 'external', - output: { - interop: true - } - }, - generateError: { - code: 'DEPRECATED_FEATURE', - message: - 'The boolean value "true" for the "output.interop" option is deprecated. Use "auto" instead.', - url: 'https://rollupjs.org/guide/en/#outputinterop' - } -}; diff --git a/test/function/samples/deprecations/interop-true/main.js b/test/function/samples/deprecations/interop-true/main.js deleted file mode 100644 index 785cd9f1e41..00000000000 --- a/test/function/samples/deprecations/interop-true/main.js +++ /dev/null @@ -1 +0,0 @@ -export { default } from 'external'; diff --git a/test/function/samples/deprecations/manualChunks/_config.js b/test/function/samples/deprecations/manualChunks/_config.js deleted file mode 100644 index 186f248569b..00000000000 --- a/test/function/samples/deprecations/manualChunks/_config.js +++ /dev/null @@ -1,13 +0,0 @@ -module.exports = { - description: 'marks the "manualChunks" input option as deprecated', - options: { - manualChunks() { - return 'manual'; - } - }, - error: { - code: 'DEPRECATED_FEATURE', - message: - 'The "manualChunks" option is deprecated. Use the "output.manualChunks" option instead.' - } -}; diff --git a/test/function/samples/deprecations/plugin-module-ids/_config.js b/test/function/samples/deprecations/plugin-module-ids/_config.js deleted file mode 100644 index 51cf0eb4bf7..00000000000 --- a/test/function/samples/deprecations/plugin-module-ids/_config.js +++ /dev/null @@ -1,20 +0,0 @@ -module.exports = { - description: 'provides all module ids on the plugin context', - options: { - external: ['path'], - plugins: { - name: 'test', - renderStart() { - console.log([...this.moduleIds]); - } - } - }, - generateError: { - code: 'PLUGIN_ERROR', - hook: 'renderStart', - message: - 'Accessing "this.moduleIds" on the plugin context by plugin test is deprecated. The "this.getModuleIds" plugin context function should be used instead.', - plugin: 'test', - pluginCode: 'DEPRECATED_FEATURE' - } -}; diff --git a/test/function/samples/deprecations/plugin-module-ids/foo.js b/test/function/samples/deprecations/plugin-module-ids/foo.js deleted file mode 100644 index cb4875a0af8..00000000000 --- a/test/function/samples/deprecations/plugin-module-ids/foo.js +++ /dev/null @@ -1,3 +0,0 @@ -import path from 'path'; - -export const foo = path.resolve('foo'); diff --git a/test/function/samples/deprecations/preserveModules/_config.js b/test/function/samples/deprecations/preserveModules/_config.js deleted file mode 100644 index 5e29e525797..00000000000 --- a/test/function/samples/deprecations/preserveModules/_config.js +++ /dev/null @@ -1,11 +0,0 @@ -module.exports = { - description: 'marks the "preserveModules" input option as deprecated', - options: { - preserveModules: true - }, - error: { - code: 'DEPRECATED_FEATURE', - message: - 'The "preserveModules" option is deprecated. Use the "output.preserveModules" option instead.' - } -}; diff --git a/test/function/samples/deprecations/resolveAssetUrl/_config.js b/test/function/samples/deprecations/resolveAssetUrl/_config.js deleted file mode 100644 index 25e521c58c9..00000000000 --- a/test/function/samples/deprecations/resolveAssetUrl/_config.js +++ /dev/null @@ -1,14 +0,0 @@ -module.exports = { - description: 'marks the resolveAssetUrl hook as deprecated', - options: { - plugins: { - resolveAssetUrl() {} - } - }, - error: { - code: 'DEPRECATED_FEATURE', - message: - 'The "resolveAssetUrl" hook used by plugin at position 1 is deprecated. The "resolveFileUrl" hook should be used instead.', - plugin: 'at position 1' - } -}; diff --git a/test/function/samples/deprecations/resolveAssetUrl/main.js b/test/function/samples/deprecations/resolveAssetUrl/main.js deleted file mode 100644 index f8a2d88d245..00000000000 --- a/test/function/samples/deprecations/resolveAssetUrl/main.js +++ /dev/null @@ -1,11 +0,0 @@ -const foo = {}; - -function doIt(x) { - if (foo[x]) { - return true; - } - foo[x] = true; -} - -doIt('x'); -assert.ok(doIt('x'), 'foo was not reassigned'); diff --git a/test/function/samples/deprecations/this-emitAsset/_config.js b/test/function/samples/deprecations/this-emitAsset/_config.js deleted file mode 100644 index 1a7a563a557..00000000000 --- a/test/function/samples/deprecations/this-emitAsset/_config.js +++ /dev/null @@ -1,17 +0,0 @@ -module.exports = { - description: 'marks this.emitAsset as deprecated', - options: { - plugins: { - buildStart() { - this.emitAsset('asset', 'asset'); - } - } - }, - error: { - code: 'PLUGIN_ERROR', - hook: 'buildStart', - message: `The "this.emitAsset" plugin context function used by plugin at position 1 is deprecated. The "this.emitFile" plugin context function should be used instead.`, - plugin: 'at position 1', - pluginCode: 'DEPRECATED_FEATURE' - } -}; diff --git a/test/function/samples/deprecations/this-emitAsset/main.js b/test/function/samples/deprecations/this-emitAsset/main.js deleted file mode 100644 index f8a2d88d245..00000000000 --- a/test/function/samples/deprecations/this-emitAsset/main.js +++ /dev/null @@ -1,11 +0,0 @@ -const foo = {}; - -function doIt(x) { - if (foo[x]) { - return true; - } - foo[x] = true; -} - -doIt('x'); -assert.ok(doIt('x'), 'foo was not reassigned'); diff --git a/test/function/samples/deprecations/this-emitChunk/_config.js b/test/function/samples/deprecations/this-emitChunk/_config.js deleted file mode 100644 index 207a79446f1..00000000000 --- a/test/function/samples/deprecations/this-emitChunk/_config.js +++ /dev/null @@ -1,17 +0,0 @@ -module.exports = { - description: 'marks this.emitChunk as deprecated', - options: { - plugins: { - buildStart() { - this.emitChunk('chunk'); - } - } - }, - error: { - code: 'PLUGIN_ERROR', - hook: 'buildStart', - message: `The "this.emitChunk" plugin context function used by plugin at position 1 is deprecated. The "this.emitFile" plugin context function should be used instead.`, - plugin: 'at position 1', - pluginCode: 'DEPRECATED_FEATURE' - } -}; diff --git a/test/function/samples/deprecations/this-emitChunk/main.js b/test/function/samples/deprecations/this-emitChunk/main.js deleted file mode 100644 index f8a2d88d245..00000000000 --- a/test/function/samples/deprecations/this-emitChunk/main.js +++ /dev/null @@ -1,11 +0,0 @@ -const foo = {}; - -function doIt(x) { - if (foo[x]) { - return true; - } - foo[x] = true; -} - -doIt('x'); -assert.ok(doIt('x'), 'foo was not reassigned'); diff --git a/test/function/samples/deprecations/this-getAssetFileName/_config.js b/test/function/samples/deprecations/this-getAssetFileName/_config.js deleted file mode 100644 index 85f86ebcdd2..00000000000 --- a/test/function/samples/deprecations/this-getAssetFileName/_config.js +++ /dev/null @@ -1,18 +0,0 @@ -module.exports = { - description: 'marks this.getAssetFileName as deprecated', - options: { - plugins: { - renderChunk() { - this.getAssetFileName(this.emitFile({ type: 'asset', name: 'asset', source: 'asset' })); - } - } - }, - generateError: { - code: 'PLUGIN_ERROR', - hook: 'renderChunk', - message: - 'The "this.getAssetFileName" plugin context function used by plugin at position 1 is deprecated. The "this.getFileName" plugin context function should be used instead.', - plugin: 'at position 1', - pluginCode: 'DEPRECATED_FEATURE' - } -}; diff --git a/test/function/samples/deprecations/this-getAssetFileName/main.js b/test/function/samples/deprecations/this-getAssetFileName/main.js deleted file mode 100644 index f8a2d88d245..00000000000 --- a/test/function/samples/deprecations/this-getAssetFileName/main.js +++ /dev/null @@ -1,11 +0,0 @@ -const foo = {}; - -function doIt(x) { - if (foo[x]) { - return true; - } - foo[x] = true; -} - -doIt('x'); -assert.ok(doIt('x'), 'foo was not reassigned'); diff --git a/test/function/samples/deprecations/this-getChunkFileName/_config.js b/test/function/samples/deprecations/this-getChunkFileName/_config.js deleted file mode 100644 index 641cde735ea..00000000000 --- a/test/function/samples/deprecations/this-getChunkFileName/_config.js +++ /dev/null @@ -1,23 +0,0 @@ -let chunkReferenceId; - -module.exports = { - description: 'marks this.getChunkFileName as deprecated', - options: { - plugins: { - buildStart() { - chunkReferenceId = this.emitFile({ type: 'chunk', id: 'chunk' }); - }, - renderChunk() { - this.getChunkFileName(chunkReferenceId); - } - } - }, - generateError: { - code: 'PLUGIN_ERROR', - hook: 'renderChunk', - message: - 'The "this.getChunkFileName" plugin context function used by plugin at position 1 is deprecated. The "this.getFileName" plugin context function should be used instead.', - plugin: 'at position 1', - pluginCode: 'DEPRECATED_FEATURE' - } -}; diff --git a/test/function/samples/deprecations/this-getChunkFileName/chunk.js b/test/function/samples/deprecations/this-getChunkFileName/chunk.js deleted file mode 100644 index 820c7c052bc..00000000000 --- a/test/function/samples/deprecations/this-getChunkFileName/chunk.js +++ /dev/null @@ -1 +0,0 @@ -assert.equal(1, 1); diff --git a/test/function/samples/deprecations/this-getChunkFileName/main.js b/test/function/samples/deprecations/this-getChunkFileName/main.js deleted file mode 100644 index f8a2d88d245..00000000000 --- a/test/function/samples/deprecations/this-getChunkFileName/main.js +++ /dev/null @@ -1,11 +0,0 @@ -const foo = {}; - -function doIt(x) { - if (foo[x]) { - return true; - } - foo[x] = true; -} - -doIt('x'); -assert.ok(doIt('x'), 'foo was not reassigned'); diff --git a/test/function/samples/deprecations/this-isExternal/_config.js b/test/function/samples/deprecations/this-isExternal/_config.js deleted file mode 100644 index 5c322a5ccd9..00000000000 --- a/test/function/samples/deprecations/this-isExternal/_config.js +++ /dev/null @@ -1,18 +0,0 @@ -module.exports = { - description: 'marks this.isExternal as deprecated', - options: { - plugins: { - buildStart() { - this.isExternal('external'); - } - } - }, - error: { - code: 'PLUGIN_ERROR', - hook: 'buildStart', - message: - 'The "this.isExternal" plugin context function used by plugin at position 1 is deprecated. The "this.resolve" plugin context function should be used instead.', - plugin: 'at position 1', - pluginCode: 'DEPRECATED_FEATURE' - } -}; diff --git a/test/function/samples/deprecations/this-isExternal/main.js b/test/function/samples/deprecations/this-isExternal/main.js deleted file mode 100644 index f8a2d88d245..00000000000 --- a/test/function/samples/deprecations/this-isExternal/main.js +++ /dev/null @@ -1,11 +0,0 @@ -const foo = {}; - -function doIt(x) { - if (foo[x]) { - return true; - } - foo[x] = true; -} - -doIt('x'); -assert.ok(doIt('x'), 'foo was not reassigned'); diff --git a/test/function/samples/deprecations/this-resolveId/_config.js b/test/function/samples/deprecations/this-resolveId/_config.js deleted file mode 100644 index 6ecacb3cf80..00000000000 --- a/test/function/samples/deprecations/this-resolveId/_config.js +++ /dev/null @@ -1,18 +0,0 @@ -module.exports = { - description: 'marks this.resolveId as deprecated', - options: { - plugins: { - buildStart() { - this.resolveId('external'); - } - } - }, - error: { - code: 'PLUGIN_ERROR', - hook: 'buildStart', - message: - 'The "this.resolveId" plugin context function used by plugin at position 1 is deprecated. The "this.resolve" plugin context function should be used instead.', - plugin: 'at position 1', - pluginCode: 'DEPRECATED_FEATURE' - } -}; diff --git a/test/function/samples/deprecations/this-resolveId/main.js b/test/function/samples/deprecations/this-resolveId/main.js deleted file mode 100644 index f8a2d88d245..00000000000 --- a/test/function/samples/deprecations/this-resolveId/main.js +++ /dev/null @@ -1,11 +0,0 @@ -const foo = {}; - -function doIt(x) { - if (foo[x]) { - return true; - } - foo[x] = true; -} - -doIt('x'); -assert.ok(doIt('x'), 'foo was not reassigned'); diff --git a/test/function/samples/deprecations/treeshake-pureExternalModules/_config.js b/test/function/samples/deprecations/treeshake-pureExternalModules/_config.js deleted file mode 100644 index bc0a9aa5e7a..00000000000 --- a/test/function/samples/deprecations/treeshake-pureExternalModules/_config.js +++ /dev/null @@ -1,10 +0,0 @@ -module.exports = { - description: 'marks the treeshake.pureExternalModules option as deprecated', - options: { - treeshake: { pureExternalModules: true } - }, - error: { - code: 'DEPRECATED_FEATURE', - message: `The "treeshake.pureExternalModules" option is deprecated. The "treeshake.moduleSideEffects" option should be used instead. "treeshake.pureExternalModules: true" is equivalent to "treeshake.moduleSideEffects: 'no-external'"` - } -}; diff --git a/test/function/samples/deprecations/treeshake-pureExternalModules/main.js b/test/function/samples/deprecations/treeshake-pureExternalModules/main.js deleted file mode 100644 index f8a2d88d245..00000000000 --- a/test/function/samples/deprecations/treeshake-pureExternalModules/main.js +++ /dev/null @@ -1,11 +0,0 @@ -const foo = {}; - -function doIt(x) { - if (foo[x]) { - return true; - } - foo[x] = true; -} - -doIt('x'); -assert.ok(doIt('x'), 'foo was not reassigned'); diff --git a/test/function/samples/deshadow-respect-existing/_config.js b/test/function/samples/deshadow-respect-existing/_config.js index e8f57bf497a..ee8efb8adf4 100644 --- a/test/function/samples/deshadow-respect-existing/_config.js +++ b/test/function/samples/deshadow-respect-existing/_config.js @@ -1,8 +1,8 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'respect existing variable names when deshadowing', exports(exports) { assert.equal(exports.getValue(), 'mainmainmainmaindep'); } -}; +}); diff --git a/test/function/samples/deshadow-top-level-declaration/_config.js b/test/function/samples/deshadow-top-level-declaration/_config.js index b8d32ac0d85..46454ff8a4a 100644 --- a/test/function/samples/deshadow-top-level-declaration/_config.js +++ b/test/function/samples/deshadow-top-level-declaration/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'deshadows top-level declarations' -}; +}); diff --git a/test/function/samples/deshadowed-destructured-parameter/_config.js b/test/function/samples/deshadowed-destructured-parameter/_config.js index 015ba4ce20c..a67f4436f45 100644 --- a/test/function/samples/deshadowed-destructured-parameter/_config.js +++ b/test/function/samples/deshadowed-destructured-parameter/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'correctly deshadows destructured function parameters (#1008)' -}; +}); diff --git a/test/function/samples/deshadowed-namespaced-external-import-ignored/_config.js b/test/function/samples/deshadowed-namespaced-external-import-ignored/_config.js index 1eb42243357..8b96dc77b36 100644 --- a/test/function/samples/deshadowed-namespaced-external-import-ignored/_config.js +++ b/test/function/samples/deshadowed-namespaced-external-import-ignored/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: '#1547', options: { external: ['external'] @@ -9,4 +9,4 @@ module.exports = { throw new Error('huh?'); } } -}; +}); diff --git a/test/function/samples/deshadowed-namespaced-import-renamed/_config.js b/test/function/samples/deshadowed-namespaced-import-renamed/_config.js index 00c9cc61173..a07e45ebee8 100644 --- a/test/function/samples/deshadowed-namespaced-import-renamed/_config.js +++ b/test/function/samples/deshadowed-namespaced-import-renamed/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: '#1550' -}; +}); diff --git a/test/function/samples/deshadowed-namespaced-import/_config.js b/test/function/samples/deshadowed-namespaced-import/_config.js index 99a1fdc71df..233145edacf 100644 --- a/test/function/samples/deshadowed-namespaced-import/_config.js +++ b/test/function/samples/deshadowed-namespaced-import/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: '#1488' -}; +}); diff --git a/test/function/samples/deshadowed-shorthand-property/_config.js b/test/function/samples/deshadowed-shorthand-property/_config.js index 352f7f3e8b9..e462f81d6e0 100644 --- a/test/function/samples/deshadowed-shorthand-property/_config.js +++ b/test/function/samples/deshadowed-shorthand-property/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'shorthand properties referencing deshadowed variables are expanded' -}; +}); diff --git a/test/function/samples/deshadows-function-expression-id/_config.js b/test/function/samples/deshadows-function-expression-id/_config.js index 2f0ff5381b9..679a6c996f8 100644 --- a/test/function/samples/deshadows-function-expression-id/_config.js +++ b/test/function/samples/deshadows-function-expression-id/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'deshadows function expression ID (#1176)' -}; +}); diff --git a/test/function/samples/destructuring-loop/_config.js b/test/function/samples/destructuring-loop/_config.js index a7307a7e141..2a104f719ce 100644 --- a/test/function/samples/destructuring-loop/_config.js +++ b/test/function/samples/destructuring-loop/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'handles loops with destructuring declarations' -}; +}); diff --git a/test/function/samples/disappearing-exported-value/_config.js b/test/function/samples/disappearing-exported-value/_config.js index 8e7b6b9ea6c..5f4a6b88169 100644 --- a/test/function/samples/disappearing-exported-value/_config.js +++ b/test/function/samples/disappearing-exported-value/_config.js @@ -1,9 +1,9 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'exported values do not mysteriously disappear (#484)', exports(exports) { assert.equal(exports.exportedAnswer, 42); assert.equal(exports.foo(), 42); } -}; +}); diff --git a/test/function/samples/do-while-conditional-break/_config.js b/test/function/samples/do-while-conditional-break/_config.js index f239588d8a8..3af21fa3032 100644 --- a/test/function/samples/do-while-conditional-break/_config.js +++ b/test/function/samples/do-while-conditional-break/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'handles conditional breaks in do-while loops with unconditional return' -}; +}); diff --git a/test/function/samples/does-not-deconflict-undefined/_config.js b/test/function/samples/does-not-deconflict-undefined/_config.js index 56a2f0daa8e..48623db166c 100644 --- a/test/function/samples/does-not-deconflict-undefined/_config.js +++ b/test/function/samples/does-not-deconflict-undefined/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'does not rename undefined' -}; +}); diff --git a/test/function/samples/does-not-fail-for-arguments-test/_config.js b/test/function/samples/does-not-fail-for-arguments-test/_config.js index b9ad98c8d17..485c0adca3d 100644 --- a/test/function/samples/does-not-fail-for-arguments-test/_config.js +++ b/test/function/samples/does-not-fail-for-arguments-test/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'does not fail when non-integer arguments properties are accessed' -}; +}); diff --git a/test/function/samples/does-not-hang-on-missing-module/_config.js b/test/function/samples/does-not-hang-on-missing-module/_config.js index 7adccb63dd1..1369337288a 100644 --- a/test/function/samples/does-not-hang-on-missing-module/_config.js +++ b/test/function/samples/does-not-hang-on-missing-module/_config.js @@ -1,14 +1,17 @@ -const assert = require('assert'); +const assert = require('node:assert'); +const path = require('node:path'); +const ID_MAIN = path.join(__dirname, 'main.js'); -module.exports = { +module.exports = defineTest({ description: 'does not hang on missing module (#53)', warnings: [ { code: 'UNRESOLVED_IMPORT', - importer: 'main.js', - source: 'unlessYouCreatedThisFileForSomeReason', - message: `'unlessYouCreatedThisFileForSomeReason' is imported by main.js, but could not be resolved – treating it as an external dependency`, - url: `https://rollupjs.org/guide/en/#warning-treating-module-as-external-dependency` + exporter: 'unlessYouCreatedThisFileForSomeReason', + id: ID_MAIN, + message: + '"unlessYouCreatedThisFileForSomeReason" is imported by "main.js", but could not be resolved – treating it as an external dependency.', + url: 'https://rollupjs.org/troubleshooting/#warning-treating-module-as-external-dependency' } ], runtimeError(error) { @@ -17,4 +20,4 @@ module.exports = { "Cannot find module 'unlessYouCreatedThisFileForSomeReason'" ); } -}; +}); diff --git a/test/function/samples/does-not-mangle-entry-point/_config.js b/test/function/samples/does-not-mangle-entry-point/_config.js index 9838effde16..4cf513eeafa 100644 --- a/test/function/samples/does-not-mangle-entry-point/_config.js +++ b/test/function/samples/does-not-mangle-entry-point/_config.js @@ -1,11 +1,11 @@ -const assert = require('assert'); +const assert = require('node:assert'); const modules = { 'x\\y': 'export default 42;', 'x/y': 'export default 24;' }; -module.exports = { +module.exports = defineTest({ description: 'does not mangle input', options: { input: 'x\\y', @@ -23,4 +23,4 @@ module.exports = { exports(exports) { assert.equal(exports, 42); } -}; +}); diff --git a/test/function/samples/double-default-export/_config.js b/test/function/samples/double-default-export/_config.js deleted file mode 100644 index 8116bd5ec2c..00000000000 --- a/test/function/samples/double-default-export/_config.js +++ /dev/null @@ -1,31 +0,0 @@ -const path = require('path'); - -module.exports = { - description: 'throws on double default exports', - error: { - code: 'PARSE_ERROR', - message: `Duplicate export 'default'`, - id: path.join(__dirname, 'foo.js'), - parserError: { - loc: { - column: 7, - line: 2 - }, - message: "Duplicate export 'default' (2:7)", - pos: 25, - raisedAt: 34 - }, - pos: 25, - watchFiles: [path.join(__dirname, 'main.js'), path.join(__dirname, 'foo.js')], - loc: { - file: path.join(__dirname, 'foo.js'), - line: 2, - column: 7 - }, - frame: ` - 1: export default 1; - 2: export default 2; - ^ - ` - } -}; diff --git a/test/function/samples/double-named-export/_config.js b/test/function/samples/double-named-export/_config.js deleted file mode 100644 index eee927b47d6..00000000000 --- a/test/function/samples/double-named-export/_config.js +++ /dev/null @@ -1,32 +0,0 @@ -const path = require('path'); - -module.exports = { - description: 'throws on duplicate named exports', - error: { - code: 'PARSE_ERROR', - message: `Duplicate export 'foo'`, - id: path.join(__dirname, 'foo.js'), - parserError: { - loc: { - column: 9, - line: 3 - }, - message: "Duplicate export 'foo' (3:9)", - pos: 38, - raisedAt: 43 - }, - pos: 38, - watchFiles: [path.join(__dirname, 'main.js'), path.join(__dirname, 'foo.js')], - loc: { - file: path.join(__dirname, 'foo.js'), - line: 3, - column: 9 - }, - frame: ` - 1: var foo = 1; - 2: export { foo }; - 3: export { foo }; - ^ - ` - } -}; diff --git a/test/function/samples/double-named-reexport/_config.js b/test/function/samples/double-named-reexport/_config.js deleted file mode 100644 index d631636210e..00000000000 --- a/test/function/samples/double-named-reexport/_config.js +++ /dev/null @@ -1,32 +0,0 @@ -const path = require('path'); - -module.exports = { - description: 'throws on duplicate named exports', - error: { - code: 'PARSE_ERROR', - message: `Duplicate export 'foo'`, - id: path.join(__dirname, 'foo.js'), - parserError: { - loc: { - column: 9, - line: 3 - }, - message: "Duplicate export 'foo' (3:9)", - pos: 38, - raisedAt: 43 - }, - pos: 38, - watchFiles: [path.join(__dirname, 'main.js'), path.join(__dirname, 'foo.js')], - loc: { - file: path.join(__dirname, 'foo.js'), - line: 3, - column: 9 - }, - frame: ` - 1: var foo = 1; - 2: export { foo }; - 3: export { foo } from './bar.js'; - ^ - ` - } -}; diff --git a/test/function/samples/double-namespace-reexport/_config.js b/test/function/samples/double-namespace-reexport/_config.js new file mode 100644 index 00000000000..25c28785975 --- /dev/null +++ b/test/function/samples/double-namespace-reexport/_config.js @@ -0,0 +1,17 @@ +const assert = require('node:assert'); + +module.exports = defineTest({ + description: 'handles chained namespace reexports from externals', + options: { + external: 'external' + }, + context: { + require(id) { + assert.strictEqual(id, 'external'); + return { foo: 42 }; + } + }, + exports({ foo }) { + assert.strictEqual(foo, 42); + } +}); diff --git a/test/function/samples/double-namespace-reexport/first.js b/test/function/samples/double-namespace-reexport/first.js new file mode 100644 index 00000000000..853dbb4b2f2 --- /dev/null +++ b/test/function/samples/double-namespace-reexport/first.js @@ -0,0 +1 @@ +export * from './second.js'; diff --git a/test/function/samples/double-namespace-reexport/main.js b/test/function/samples/double-namespace-reexport/main.js new file mode 100644 index 00000000000..2d9fdc01be5 --- /dev/null +++ b/test/function/samples/double-namespace-reexport/main.js @@ -0,0 +1 @@ +export { foo } from './first.js'; diff --git a/test/function/samples/double-namespace-reexport/second.js b/test/function/samples/double-namespace-reexport/second.js new file mode 100644 index 00000000000..4953eb6e351 --- /dev/null +++ b/test/function/samples/double-namespace-reexport/second.js @@ -0,0 +1 @@ +export * from 'external'; diff --git a/test/function/samples/duplicate-import-fails/_config.js b/test/function/samples/duplicate-import-fails/_config.js deleted file mode 100644 index 71345e647c7..00000000000 --- a/test/function/samples/duplicate-import-fails/_config.js +++ /dev/null @@ -1,35 +0,0 @@ -const path = require('path'); - -module.exports = { - description: 'disallows duplicate imports', - error: { - code: 'PARSE_ERROR', - message: `Identifier 'a' has already been declared`, - id: path.join(__dirname, 'main.js'), - parserError: { - loc: { - column: 9, - line: 2 - }, - message: "Identifier 'a' has already been declared (2:9)", - pos: 36, - raisedAt: 39 - }, - pos: 36, - watchFiles: [path.join(__dirname, 'main.js')], - loc: { - file: path.join(__dirname, 'main.js'), - line: 2, - column: 9 - }, - frame: ` - 1: import { a } from './foo'; - 2: import { a } from './foo'; - ^ - 3: - 4: assert.equal(a, 1); - ` - } -}; - -// test copied from https://github.com/esnext/es6-module-transpiler/tree/master/test/examples/duplicate-import-fails diff --git a/test/function/samples/duplicate-import-specifier-fails/_config.js b/test/function/samples/duplicate-import-specifier-fails/_config.js deleted file mode 100644 index 64d88e09991..00000000000 --- a/test/function/samples/duplicate-import-specifier-fails/_config.js +++ /dev/null @@ -1,33 +0,0 @@ -const path = require('path'); - -module.exports = { - description: 'disallows duplicate import specifiers', - error: { - code: 'PARSE_ERROR', - message: `Identifier 'a' has already been declared`, - id: path.join(__dirname, 'main.js'), - parserError: { - loc: { - column: 12, - line: 1 - }, - message: "Identifier 'a' has already been declared (1:12)", - pos: 12, - raisedAt: 15 - }, - pos: 12, - watchFiles: [path.join(__dirname, 'main.js')], - loc: { - file: path.join(__dirname, 'main.js'), - line: 1, - column: 12 - }, - frame: ` - 1: import { a, a } from './foo'; - ^ - 2: assert.equal(a, 1); - ` - } -}; - -// test copied from https://github.com/esnext/es6-module-transpiler/tree/master/test/examples/duplicate-import-specifier-fails diff --git a/test/function/samples/duplicate-input-entry/_config.js b/test/function/samples/duplicate-input-entry/_config.js index cecb19f2eeb..d70246ccd92 100644 --- a/test/function/samples/duplicate-input-entry/_config.js +++ b/test/function/samples/duplicate-input-entry/_config.js @@ -1,6 +1,6 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'handles duplicate entry modules when using the object form', options: { input: ['entry', 'entry.js'] @@ -8,4 +8,4 @@ module.exports = { exports(exports) { assert.deepStrictEqual(exports, { entry: 'main' }); } -}; +}); diff --git a/test/function/samples/dynamic-import-call-method-with-this-await/_config.js b/test/function/samples/dynamic-import-call-method-with-this-await/_config.js new file mode 100644 index 00000000000..37edcd293f3 --- /dev/null +++ b/test/function/samples/dynamic-import-call-method-with-this-await/_config.js @@ -0,0 +1,7 @@ +module.exports = defineTest({ + description: + 'includes the correct "this" context when calling a method on a dynamically imported module via "await"', + async exports({ test }) { + await test(); + } +}); diff --git a/test/function/samples/dynamic-import-call-method-with-this-await/dep.js b/test/function/samples/dynamic-import-call-method-with-this-await/dep.js new file mode 100644 index 00000000000..84c63f32a6e --- /dev/null +++ b/test/function/samples/dynamic-import-call-method-with-this-await/dep.js @@ -0,0 +1,5 @@ +export function test() { + return this.value; +} + +export const value = 'OK'; diff --git a/test/function/samples/dynamic-import-call-method-with-this-await/main.js b/test/function/samples/dynamic-import-call-method-with-this-await/main.js new file mode 100644 index 00000000000..b1da259e518 --- /dev/null +++ b/test/function/samples/dynamic-import-call-method-with-this-await/main.js @@ -0,0 +1,4 @@ +export const test = async () => { + const n = await import('./dep.js'); + assert.equal(n.test(), 'OK'); +}; diff --git a/test/function/samples/dynamic-import-call-method-with-this-then/_config.js b/test/function/samples/dynamic-import-call-method-with-this-then/_config.js new file mode 100644 index 00000000000..b83d4fa3209 --- /dev/null +++ b/test/function/samples/dynamic-import-call-method-with-this-then/_config.js @@ -0,0 +1,7 @@ +module.exports = defineTest({ + description: + 'includes the correct "this" context when calling a method on a dynamically imported module via "then"', + async exports({ test }) { + await test; + } +}); diff --git a/test/function/samples/dynamic-import-call-method-with-this-then/dep.js b/test/function/samples/dynamic-import-call-method-with-this-then/dep.js new file mode 100644 index 00000000000..84c63f32a6e --- /dev/null +++ b/test/function/samples/dynamic-import-call-method-with-this-then/dep.js @@ -0,0 +1,5 @@ +export function test() { + return this.value; +} + +export const value = 'OK'; diff --git a/test/function/samples/dynamic-import-call-method-with-this-then/main.js b/test/function/samples/dynamic-import-call-method-with-this-then/main.js new file mode 100644 index 00000000000..91ae05e20f8 --- /dev/null +++ b/test/function/samples/dynamic-import-call-method-with-this-then/main.js @@ -0,0 +1 @@ +export const test = import('./dep.js').then(n => n.test()); diff --git a/test/function/samples/dynamic-import-default-mode-facade/_config.js b/test/function/samples/dynamic-import-default-mode-facade/_config.js index e7306a7bc22..1d35721ce8e 100644 --- a/test/function/samples/dynamic-import-default-mode-facade/_config.js +++ b/test/function/samples/dynamic-import-default-mode-facade/_config.js @@ -1,6 +1,6 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'handles dynamic imports from facades using default export mode', options: { input: ['main', 'foo', 'bar'] @@ -10,4 +10,4 @@ module.exports = { assert.deepStrictEqual(exported, { __proto__: null, default: 4 }) ); } -}; +}); diff --git a/test/function/samples/dynamic-import-duplicates/_config.js b/test/function/samples/dynamic-import-duplicates/_config.js index 8ff6c25a426..2bb12ee7cb1 100644 --- a/test/function/samples/dynamic-import-duplicates/_config.js +++ b/test/function/samples/dynamic-import-duplicates/_config.js @@ -1,6 +1,6 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'Dynamic import inlining', options: { output: { inlineDynamicImports: true } @@ -11,4 +11,4 @@ module.exports = { assert.equal(y, 42); }); } -}; +}); diff --git a/test/function/samples/dynamic-import-existing/_config.js b/test/function/samples/dynamic-import-existing/_config.js index cc0a31d2825..9506eac1aff 100644 --- a/test/function/samples/dynamic-import-existing/_config.js +++ b/test/function/samples/dynamic-import-existing/_config.js @@ -1,11 +1,11 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'Dynamic import inlining when resolution id is a module in the bundle', exports(exports) { assert.equal(exports.y, 42); - return Promise.resolve(exports.promise).then(val => { - assert.equal(val, 84); + return Promise.resolve(exports.promise).then(value => { + assert.equal(value, 84); }); } -}; +}); diff --git a/test/function/samples/dynamic-import-expression/_config.js b/test/function/samples/dynamic-import-expression/_config.js index b06c2ee080f..9e754bac9d0 100644 --- a/test/function/samples/dynamic-import-expression/_config.js +++ b/test/function/samples/dynamic-import-expression/_config.js @@ -1,32 +1,31 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'Dynamic import expression replacement', options: { plugins: [ { resolveDynamicImport(specifier) { - if (typeof specifier !== 'string') { - // string literal concatenation - if ( - specifier.type === 'BinaryExpression' && - specifier.operator === '+' && - specifier.left.type === 'Literal' && - specifier.right.type === 'Literal' && - typeof specifier.left.value === 'string' && - typeof specifier.right.value === 'string' - ) { - return '"' + specifier.left.value + specifier.right.value + '"'; - } + if ( + typeof specifier !== 'string' && // string literal concatenation + specifier.type === 'BinaryExpression' && + specifier.operator === '+' && + specifier.left.type === 'Literal' && + specifier.right.type === 'Literal' && + typeof specifier.left.value === 'string' && + typeof specifier.right.value === 'string' + ) { + return '"' + specifier.left.value + specifier.right.value + '"'; } } } - ] + ], + output: { dynamicImportInCjs: false } }, exports(exports) { const expectedError = "Cannot find module 'x/y'"; - return exports.catch(err => - assert.strictEqual(err.message.slice(0, expectedError.length), expectedError) + return exports.catch(error => + assert.strictEqual(error.message.slice(0, expectedError.length), expectedError) ); } -}; +}); diff --git a/test/function/samples/dynamic-import-include-catch-handler/_config.js b/test/function/samples/dynamic-import-include-catch-handler/_config.js new file mode 100644 index 00000000000..c5b59a2a3be --- /dev/null +++ b/test/function/samples/dynamic-import-include-catch-handler/_config.js @@ -0,0 +1,6 @@ +module.exports = defineTest({ + description: 'includes catch handler for dynamic imports', + async exports({ test }) { + await test; + } +}); diff --git a/test/function/samples/dynamic-import-include-catch-handler/dep.js b/test/function/samples/dynamic-import-include-catch-handler/dep.js new file mode 100644 index 00000000000..d39db62ad16 --- /dev/null +++ b/test/function/samples/dynamic-import-include-catch-handler/dep.js @@ -0,0 +1 @@ +throw new Error('Import failed on purpose'); diff --git a/test/function/samples/dynamic-import-include-catch-handler/main.js b/test/function/samples/dynamic-import-include-catch-handler/main.js new file mode 100644 index 00000000000..089804b52af --- /dev/null +++ b/test/function/samples/dynamic-import-include-catch-handler/main.js @@ -0,0 +1,20 @@ +let finallyCalled = false + +export const test = import('./dep.js') + .finally(() => { + finallyCalled = true; + }) + .catch(() => { + const obj = { + value: false, + check() { + return obj.value ? true : false; + } + }; + return obj; + }) + .then(result => { + result.value = true; + assert.ok(result.check()); + assert.ok(finallyCalled); + }); diff --git a/test/function/samples/dynamic-import-inlining/_config.js b/test/function/samples/dynamic-import-inlining/_config.js index 8ff6c25a426..2bb12ee7cb1 100644 --- a/test/function/samples/dynamic-import-inlining/_config.js +++ b/test/function/samples/dynamic-import-inlining/_config.js @@ -1,6 +1,6 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'Dynamic import inlining', options: { output: { inlineDynamicImports: true } @@ -11,4 +11,4 @@ module.exports = { assert.equal(y, 42); }); } -}; +}); diff --git a/test/function/samples/dynamic-import-mutate-namespace-await/_config.js b/test/function/samples/dynamic-import-mutate-namespace-await/_config.js new file mode 100644 index 00000000000..56cfa9a2457 --- /dev/null +++ b/test/function/samples/dynamic-import-mutate-namespace-await/_config.js @@ -0,0 +1,6 @@ +module.exports = defineTest({ + description: 'tracks mutating dynamic import properties via "await"', + async exports({ test }) { + await test(); + } +}); diff --git a/test/function/samples/dynamic-import-mutate-namespace-await/dep.js b/test/function/samples/dynamic-import-mutate-namespace-await/dep.js new file mode 100644 index 00000000000..1fbe158d701 --- /dev/null +++ b/test/function/samples/dynamic-import-mutate-namespace-await/dep.js @@ -0,0 +1 @@ +export const obj = { mutated: false }; diff --git a/test/function/samples/dynamic-import-mutate-namespace-await/main.js b/test/function/samples/dynamic-import-mutate-namespace-await/main.js new file mode 100644 index 00000000000..2805c2b6ca3 --- /dev/null +++ b/test/function/samples/dynamic-import-mutate-namespace-await/main.js @@ -0,0 +1,7 @@ +import { obj } from './dep.js'; + +export const test = async () => { + const n = await import('./dep.js'); + n.obj.mutated = true; + assert.ok(obj.mutated ? true : false); +}; diff --git a/test/function/samples/dynamic-import-mutate-namespace-then/_config.js b/test/function/samples/dynamic-import-mutate-namespace-then/_config.js new file mode 100644 index 00000000000..d0e7099ba0d --- /dev/null +++ b/test/function/samples/dynamic-import-mutate-namespace-then/_config.js @@ -0,0 +1,6 @@ +module.exports = defineTest({ + description: 'tracks mutating dynamic import properties via "then"', + async exports({ test }) { + await test(); + } +}); diff --git a/test/function/samples/dynamic-import-mutate-namespace-then/dep.js b/test/function/samples/dynamic-import-mutate-namespace-then/dep.js new file mode 100644 index 00000000000..1fbe158d701 --- /dev/null +++ b/test/function/samples/dynamic-import-mutate-namespace-then/dep.js @@ -0,0 +1 @@ +export const obj = { mutated: false }; diff --git a/test/function/samples/dynamic-import-mutate-namespace-then/main.js b/test/function/samples/dynamic-import-mutate-namespace-then/main.js new file mode 100644 index 00000000000..34fcc99c5d8 --- /dev/null +++ b/test/function/samples/dynamic-import-mutate-namespace-then/main.js @@ -0,0 +1,7 @@ +import { obj as directObj } from './dep.js'; + +export const test = () => + import('./dep.js').then(({ obj }) => { + obj.mutated = true; + assert.ok(directObj.mutated ? true : false); + }); diff --git a/test/function/samples/dynamic-import-mutate-then-return/_config.js b/test/function/samples/dynamic-import-mutate-then-return/_config.js new file mode 100644 index 00000000000..175ed82e161 --- /dev/null +++ b/test/function/samples/dynamic-import-mutate-then-return/_config.js @@ -0,0 +1,6 @@ +module.exports = defineTest({ + description: 'tracks mutating the return value of a dynamic import .then handler', + async exports({ test }) { + await test; + } +}); diff --git a/test/form/samples/deprecated/nested-inlined-dynamic-import/foo.js b/test/function/samples/dynamic-import-mutate-then-return/dep.js similarity index 100% rename from test/form/samples/deprecated/nested-inlined-dynamic-import/foo.js rename to test/function/samples/dynamic-import-mutate-then-return/dep.js diff --git a/test/function/samples/dynamic-import-mutate-then-return/main.js b/test/function/samples/dynamic-import-mutate-then-return/main.js new file mode 100644 index 00000000000..db64efab2b4 --- /dev/null +++ b/test/function/samples/dynamic-import-mutate-then-return/main.js @@ -0,0 +1,14 @@ +export const test = import('./dep.js') + .then(() => { + const obj = { + value: false, + check() { + assert.ok(obj.value ? true : false); + } + }; + return obj; + }) + .then((obj) => { + obj.value = true; + obj.check(); + }); diff --git a/test/function/samples/dynamic-import-not-found/_config.js b/test/function/samples/dynamic-import-not-found/_config.js index d97d427d0f7..bfb13a5f340 100644 --- a/test/function/samples/dynamic-import-not-found/_config.js +++ b/test/function/samples/dynamic-import-not-found/_config.js @@ -1,4 +1,7 @@ -module.exports = { +const path = require('node:path'); +const ID_MAIN = path.join(__dirname, 'main.js'); + +module.exports = defineTest({ description: 'warns if a dynamic import is not found', context: { require(id) { @@ -10,11 +13,11 @@ module.exports = { warnings: [ { code: 'UNRESOLVED_IMPORT', - importer: 'main.js', + exporter: 'mod', + id: ID_MAIN, message: - "'mod' is imported by main.js, but could not be resolved – treating it as an external dependency", - source: 'mod', - url: 'https://rollupjs.org/guide/en/#warning-treating-module-as-external-dependency' + '"mod" is imported by "main.js", but could not be resolved – treating it as an external dependency.', + url: 'https://rollupjs.org/troubleshooting/#warning-treating-module-as-external-dependency' } ] -}; +}); diff --git a/test/function/samples/dynamic-import-only-default/_config.js b/test/function/samples/dynamic-import-only-default/_config.js index 7a9824acfd1..bcd5cc10ec4 100644 --- a/test/function/samples/dynamic-import-only-default/_config.js +++ b/test/function/samples/dynamic-import-only-default/_config.js @@ -1,6 +1,6 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'correctly imports dynamic namespaces with only a default export from entry- and non-entry-point chunks', options: { @@ -11,4 +11,4 @@ module.exports = { assert.deepStrictEqual(result, [{ __proto__: null, default: 42 }, { default: 42 }]) ); } -}; +}); diff --git a/test/function/samples/dynamic-import-relative-not-found/_config.js b/test/function/samples/dynamic-import-relative-not-found/_config.js index 5b8631590c6..e1e598193eb 100644 --- a/test/function/samples/dynamic-import-relative-not-found/_config.js +++ b/test/function/samples/dynamic-import-relative-not-found/_config.js @@ -1,10 +1,13 @@ -const path = require('path'); +const path = require('node:path'); +const ID_MAIN = path.join(__dirname, 'main.js'); -module.exports = { +module.exports = defineTest({ description: 'throws if a dynamic relative import is not found', error: { code: 'UNRESOLVED_IMPORT', - message: `Could not resolve './mod' from main.js`, - watchFiles: [path.join(__dirname, 'main.js')] + exporter: './mod', + id: ID_MAIN, + message: 'Could not resolve "./mod" from "main.js"', + watchFiles: [ID_MAIN] } -}; +}); diff --git a/test/function/samples/dynamic-import-rewriting/_config.js b/test/function/samples/dynamic-import-rewriting/_config.js index 3680137bc34..5b7608a5a49 100644 --- a/test/function/samples/dynamic-import-rewriting/_config.js +++ b/test/function/samples/dynamic-import-rewriting/_config.js @@ -1,6 +1,6 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'Dynamic import string specifier resolving', options: { external: ['asdf'], @@ -13,9 +13,9 @@ module.exports = { ] }, exports(exports) { - const expectedError = "Cannot find module 'asdf'"; - return exports.promise.catch(err => - assert.strictEqual(err.message.slice(0, expectedError.length), expectedError) + const expectedError = "Cannot find package 'asdf'"; + return exports.promise.catch(error => + assert.strictEqual(error.message.slice(0, expectedError.length), expectedError) ); } -}; +}); diff --git a/test/function/samples/dynamic-import-this-arrow/_config.js b/test/function/samples/dynamic-import-this-arrow/_config.js new file mode 100644 index 00000000000..09d2320f1e9 --- /dev/null +++ b/test/function/samples/dynamic-import-this-arrow/_config.js @@ -0,0 +1,30 @@ +const assert = require('node:assert'); + +module.exports = defineTest({ + description: 'uses correct "this" in dynamic imports when using arrow functions', + context: { + require(id) { + switch (id) { + case 'input': { + return { outputPath: 'output' }; + } + case 'output': { + return { foo: 42 }; + } + default: { + throw new Error(`Unexpected require "${id}"`); + } + } + } + }, + exports({ promise }) { + return promise.then(({ foo }) => assert.strictEqual(foo, 42)); + }, + options: { + external: ['input', 'output'], + output: { + generatedCode: { arrowFunctions: true }, + dynamicImportInCjs: false + } + } +}); diff --git a/test/function/samples/dynamic-import-this-arrow/main.js b/test/function/samples/dynamic-import-this-arrow/main.js new file mode 100644 index 00000000000..bfe419d7fef --- /dev/null +++ b/test/function/samples/dynamic-import-this-arrow/main.js @@ -0,0 +1,13 @@ +import { outputPath } from 'input'; + +class Importer { + constructor() { + this.outputPath = outputPath; + } + + getImport() { + return import(this.outputPath); + } +} + +export const promise = new Importer().getImport(); diff --git a/test/function/samples/dynamic-import-this-function/_config.js b/test/function/samples/dynamic-import-this-function/_config.js new file mode 100644 index 00000000000..069836e93b2 --- /dev/null +++ b/test/function/samples/dynamic-import-this-function/_config.js @@ -0,0 +1,30 @@ +const assert = require('node:assert'); + +module.exports = defineTest({ + description: 'uses correct "this" in dynamic imports when not using arrow functions', + context: { + require(id) { + switch (id) { + case 'input': { + return { outputPath: 'output' }; + } + case 'output': { + return { foo: 42 }; + } + default: { + throw new Error(`Unexpected require "${id}"`); + } + } + } + }, + exports({ promise }) { + return promise.then(({ foo }) => assert.strictEqual(foo, 42)); + }, + options: { + external: ['input', 'output'], + output: { + generatedCode: { arrowFunctions: false }, + dynamicImportInCjs: false + } + } +}); diff --git a/test/function/samples/dynamic-import-this-function/main.js b/test/function/samples/dynamic-import-this-function/main.js new file mode 100644 index 00000000000..bfe419d7fef --- /dev/null +++ b/test/function/samples/dynamic-import-this-function/main.js @@ -0,0 +1,13 @@ +import { outputPath } from 'input'; + +class Importer { + constructor() { + this.outputPath = outputPath; + } + + getImport() { + return import(this.outputPath); + } +} + +export const promise = new Importer().getImport(); diff --git a/test/function/samples/dynamic-imports-shared-exports/_config.js b/test/function/samples/dynamic-imports-shared-exports/_config.js new file mode 100644 index 00000000000..7b43d4c92f2 --- /dev/null +++ b/test/function/samples/dynamic-imports-shared-exports/_config.js @@ -0,0 +1,9 @@ +module.exports = defineTest({ + description: 'allows sharing imports between dynamic chunks', + options: { + preserveEntrySignatures: 'allow-extension' + }, + exports(exports) { + return exports.promise; + } +}); diff --git a/test/function/samples/dynamic-imports-shared-exports/dynamic1.js b/test/function/samples/dynamic-imports-shared-exports/dynamic1.js new file mode 100644 index 00000000000..35d8951ee55 --- /dev/null +++ b/test/function/samples/dynamic-imports-shared-exports/dynamic1.js @@ -0,0 +1,8 @@ +import { sharedDynamic } from './sharedDynamic.js'; + +assert.ok(sharedDynamic); +export const promise = import('./dynamic2.js').then(ns => + assert.deepStrictEqual(ns, { sharedDynamic: true }) +); + +export { shared } from './shared.js'; diff --git a/test/function/samples/dynamic-imports-shared-exports/dynamic2.js b/test/function/samples/dynamic-imports-shared-exports/dynamic2.js new file mode 100644 index 00000000000..2355361e83b --- /dev/null +++ b/test/function/samples/dynamic-imports-shared-exports/dynamic2.js @@ -0,0 +1 @@ +export { sharedDynamic } from './sharedDynamic.js'; diff --git a/test/function/samples/dynamic-imports-shared-exports/main.js b/test/function/samples/dynamic-imports-shared-exports/main.js new file mode 100644 index 00000000000..531c8c54b45 --- /dev/null +++ b/test/function/samples/dynamic-imports-shared-exports/main.js @@ -0,0 +1,7 @@ +import { shared } from './shared.js'; + +assert.ok(shared); +export const promise = import('./dynamic1.js').then(({ promise, ...ns }) => { + assert.deepStrictEqual(ns, { shared: true }); + return ns.promise; +}); diff --git a/test/function/samples/dynamic-imports-shared-exports/shared.js b/test/function/samples/dynamic-imports-shared-exports/shared.js new file mode 100644 index 00000000000..b60d9ba03fb --- /dev/null +++ b/test/function/samples/dynamic-imports-shared-exports/shared.js @@ -0,0 +1 @@ +export const shared = true; diff --git a/test/function/samples/dynamic-imports-shared-exports/sharedDynamic.js b/test/function/samples/dynamic-imports-shared-exports/sharedDynamic.js new file mode 100644 index 00000000000..5cf55fe52ef --- /dev/null +++ b/test/function/samples/dynamic-imports-shared-exports/sharedDynamic.js @@ -0,0 +1 @@ +export const sharedDynamic = true; diff --git a/test/function/samples/dynamic-namespace-lookup/_config.js b/test/function/samples/dynamic-namespace-lookup/_config.js index 3c2fe549cc2..d60a90bece8 100644 --- a/test/function/samples/dynamic-namespace-lookup/_config.js +++ b/test/function/samples/dynamic-namespace-lookup/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'does namespace optimization when possible, but not for dynamic lookups' -}; +}); diff --git a/test/function/samples/emit-chunk-hash/_config.js b/test/function/samples/emit-chunk-hash/_config.js new file mode 100644 index 00000000000..06f792384a8 --- /dev/null +++ b/test/function/samples/emit-chunk-hash/_config.js @@ -0,0 +1,22 @@ +const assert = require('node:assert'); +let referenceId; + +module.exports = defineTest({ + description: 'gives access to the hashed filed name via this.getFileName in generateBundle', + options: { + input: 'main', + output: { + chunkFileNames: '[name]-[hash].js' + }, + plugins: [ + { + buildStart() { + referenceId = this.emitFile({ type: 'chunk', id: 'emitted' }); + }, + generateBundle() { + assert.strictEqual(this.getFileName(referenceId), 'emitted-gSMhVgKt.js'); + } + } + ] + } +}); diff --git a/test/function/samples/emit-chunk-hash/emitted.js b/test/function/samples/emit-chunk-hash/emitted.js new file mode 100644 index 00000000000..cc1d88a24fa --- /dev/null +++ b/test/function/samples/emit-chunk-hash/emitted.js @@ -0,0 +1 @@ +assert.ok(true); diff --git a/test/function/samples/emit-chunk-hash/main.js b/test/function/samples/emit-chunk-hash/main.js new file mode 100644 index 00000000000..cc1d88a24fa --- /dev/null +++ b/test/function/samples/emit-chunk-hash/main.js @@ -0,0 +1 @@ +assert.ok(true); diff --git a/test/function/samples/emit-chunk-manual-asset-source/_config.js b/test/function/samples/emit-chunk-manual-asset-source/_config.js new file mode 100644 index 00000000000..5394233ba14 --- /dev/null +++ b/test/function/samples/emit-chunk-manual-asset-source/_config.js @@ -0,0 +1,29 @@ +const assert = require('node:assert'); +let referenceId; + +module.exports = defineTest({ + description: 'supports setting asset sources as side effect of the manual chunks option', + options: { + output: { + manualChunks: { foo: ['manual.js'] }, + assetFileNames: '[name]-[hash][extname]' + }, + plugins: [ + { + transform(code, id) { + if (id.endsWith('manual.js')) { + referenceId = this.emitFile({ type: 'asset', name: 'emitted.txt' }); + } + }, + moduleParsed({ id }) { + if (id.endsWith('manual.js')) { + this.setAssetSource(referenceId, 'emitted'); + } + }, + generateBundle() { + assert.strictEqual(this.getFileName(referenceId), 'emitted-C6bBH0W1.txt'); + } + } + ] + } +}); diff --git a/test/function/samples/emit-chunk-manual-asset-source/main.js b/test/function/samples/emit-chunk-manual-asset-source/main.js new file mode 100644 index 00000000000..cc1d88a24fa --- /dev/null +++ b/test/function/samples/emit-chunk-manual-asset-source/main.js @@ -0,0 +1 @@ +assert.ok(true); diff --git a/test/function/samples/emit-chunk-manual-asset-source/manual.js b/test/function/samples/emit-chunk-manual-asset-source/manual.js new file mode 100644 index 00000000000..ce898782081 --- /dev/null +++ b/test/function/samples/emit-chunk-manual-asset-source/manual.js @@ -0,0 +1 @@ +import './main'; diff --git a/test/function/samples/emit-chunk-manual/_config.js b/test/function/samples/emit-chunk-manual/_config.js new file mode 100644 index 00000000000..4011b5666b5 --- /dev/null +++ b/test/function/samples/emit-chunk-manual/_config.js @@ -0,0 +1,24 @@ +const assert = require('node:assert'); +let referenceId; + +module.exports = defineTest({ + description: 'supports emitting chunks as side effect of the manual chunks option', + options: { + output: { + manualChunks: { foo: ['manual.js'] }, + assetFileNames: '[name]-[hash][extname]' + }, + plugins: [ + { + transform(code, id) { + if (id.endsWith('manual.js')) { + referenceId = this.emitFile({ type: 'asset', name: 'emitted.txt', source: 'emitted' }); + } + }, + generateBundle() { + assert.strictEqual(this.getFileName(referenceId), 'emitted-C6bBH0W1.txt'); + } + } + ] + } +}); diff --git a/test/function/samples/emit-chunk-manual/main.js b/test/function/samples/emit-chunk-manual/main.js new file mode 100644 index 00000000000..cc1d88a24fa --- /dev/null +++ b/test/function/samples/emit-chunk-manual/main.js @@ -0,0 +1 @@ +assert.ok(true); diff --git a/test/function/samples/emit-chunk-manual/manual.js b/test/function/samples/emit-chunk-manual/manual.js new file mode 100644 index 00000000000..ce898782081 --- /dev/null +++ b/test/function/samples/emit-chunk-manual/manual.js @@ -0,0 +1 @@ +import './main'; diff --git a/test/function/samples/emit-file/asset-source-invalid/_config.js b/test/function/samples/emit-file/asset-source-invalid/_config.js index 95351e3fbee..2767565098b 100644 --- a/test/function/samples/emit-file/asset-source-invalid/_config.js +++ b/test/function/samples/emit-file/asset-source-invalid/_config.js @@ -1,13 +1,15 @@ -module.exports = { +module.exports = defineTest({ description: 'throws when setting an empty asset source', options: { - plugins: { - name: 'test-plugin', - buildStart() { - const assetId = this.emitFile({ type: 'asset', name: 'test.ext' }); - this.setAssetSource(assetId, null); + plugins: [ + { + name: 'test-plugin', + buildStart() { + const assetId = this.emitFile({ type: 'asset', name: 'test.ext' }); + this.setAssetSource(assetId, null); + } } - } + ] }, error: { code: 'PLUGIN_ERROR', @@ -17,4 +19,4 @@ module.exports = { plugin: 'test-plugin', pluginCode: 'VALIDATION_ERROR' } -}; +}); diff --git a/test/function/samples/emit-file/asset-source-invalid2/_config.js b/test/function/samples/emit-file/asset-source-invalid2/_config.js index b41d8952062..8edc13a8c34 100644 --- a/test/function/samples/emit-file/asset-source-invalid2/_config.js +++ b/test/function/samples/emit-file/asset-source-invalid2/_config.js @@ -1,13 +1,15 @@ -module.exports = { +module.exports = defineTest({ description: 'throws when setting an empty asset source', options: { - plugins: { - name: 'test-plugin', - buildStart() { - const assetId = this.emitFile({ type: 'asset', fileName: 'test.ext' }); - this.setAssetSource(assetId, null); + plugins: [ + { + name: 'test-plugin', + buildStart() { + const assetId = this.emitFile({ type: 'asset', fileName: 'test.ext' }); + this.setAssetSource(assetId, null); + } } - } + ] }, error: { code: 'PLUGIN_ERROR', @@ -17,4 +19,4 @@ module.exports = { plugin: 'test-plugin', pluginCode: 'VALIDATION_ERROR' } -}; +}); diff --git a/test/function/samples/emit-file/asset-source-invalid3/_config.js b/test/function/samples/emit-file/asset-source-invalid3/_config.js index 63d0f7cd843..44e62cf8b43 100644 --- a/test/function/samples/emit-file/asset-source-invalid3/_config.js +++ b/test/function/samples/emit-file/asset-source-invalid3/_config.js @@ -1,20 +1,22 @@ -module.exports = { +module.exports = defineTest({ description: 'throws when setting an empty asset source', options: { - plugins: { - name: 'test-plugin', - buildStart() { - const assetId = this.emitFile({ type: 'asset' }); - this.setAssetSource(assetId, null); + plugins: [ + { + name: 'test-plugin', + buildStart() { + const assetId = this.emitFile({ type: 'asset' }); + this.setAssetSource(assetId, null); + } } - } + ] }, error: { code: 'PLUGIN_ERROR', hook: 'buildStart', message: - 'Could not set source for asset "d59386e0", asset source needs to be a string, Uint8Array or Buffer.', + 'Could not set source for asset "BY8ZiPAi", asset source needs to be a string, Uint8Array or Buffer.', plugin: 'test-plugin', pluginCode: 'VALIDATION_ERROR' } -}; +}); diff --git a/test/function/samples/emit-file/asset-source-invalid4/_config.js b/test/function/samples/emit-file/asset-source-invalid4/_config.js index c23119557b1..1f13ddf8c64 100644 --- a/test/function/samples/emit-file/asset-source-invalid4/_config.js +++ b/test/function/samples/emit-file/asset-source-invalid4/_config.js @@ -1,12 +1,14 @@ -module.exports = { +module.exports = defineTest({ description: 'throws when setting an empty asset source', options: { - plugins: { - name: 'test-plugin', - buildStart() { - this.emitFile({ type: 'asset', source: null }); + plugins: [ + { + name: 'test-plugin', + buildStart() { + this.emitFile({ type: 'asset', source: null }); + } } - } + ] }, error: { code: 'PLUGIN_ERROR', @@ -16,4 +18,4 @@ module.exports = { plugin: 'test-plugin', pluginCode: 'VALIDATION_ERROR' } -}; +}); diff --git a/test/function/samples/emit-file/asset-source-missing/_config.js b/test/function/samples/emit-file/asset-source-missing/_config.js index bb97104870f..544d0a299d1 100644 --- a/test/function/samples/emit-file/asset-source-missing/_config.js +++ b/test/function/samples/emit-file/asset-source-missing/_config.js @@ -1,15 +1,17 @@ -module.exports = { +module.exports = defineTest({ description: 'throws when not setting the asset source', options: { - plugins: { - name: 'test-plugin', - load() { - this.emitFile({ type: 'asset', name: 'test.ext' }); + plugins: [ + { + name: 'test-plugin', + load() { + this.emitFile({ type: 'asset', name: 'test.ext' }); + } } - } + ] }, generateError: { code: 'ASSET_SOURCE_MISSING', message: 'Plugin error creating asset "test.ext" - no asset source set.' } -}; +}); diff --git a/test/function/samples/emit-file/asset-source-missing2/_config.js b/test/function/samples/emit-file/asset-source-missing2/_config.js index fad75fd1542..580cc02f51c 100644 --- a/test/function/samples/emit-file/asset-source-missing2/_config.js +++ b/test/function/samples/emit-file/asset-source-missing2/_config.js @@ -1,15 +1,17 @@ -module.exports = { +module.exports = defineTest({ description: 'throws when not setting the asset source', options: { - plugins: { - name: 'test-plugin', - load() { - this.emitFile({ type: 'asset' }); + plugins: [ + { + name: 'test-plugin', + load() { + this.emitFile({ type: 'asset' }); + } } - } + ] }, generateError: { code: 'ASSET_SOURCE_MISSING', - message: 'Plugin error creating asset "d59386e0" - no asset source set.' + message: 'Plugin error creating asset "BY8ZiPAi" - no asset source set.' } -}; +}); diff --git a/test/function/samples/emit-file/asset-source-missing3/_config.js b/test/function/samples/emit-file/asset-source-missing3/_config.js index 85e314793fe..09537c85b1e 100644 --- a/test/function/samples/emit-file/asset-source-missing3/_config.js +++ b/test/function/samples/emit-file/asset-source-missing3/_config.js @@ -1,20 +1,22 @@ -module.exports = { +module.exports = defineTest({ description: 'throws when accessing the file name before the asset source is set', options: { - plugins: { - name: 'test-plugin', - buildStart() { - const assetId = this.emitFile({ type: 'asset', name: 'test.ext' }); - this.getFileName(assetId); + plugins: [ + { + name: 'test-plugin', + buildStart() { + const assetId = this.emitFile({ type: 'asset', name: 'test.ext' }); + this.getFileName(assetId); + } } - } + ] }, error: { code: 'PLUGIN_ERROR', hook: 'buildStart', message: - 'Plugin error - Unable to get file name for asset "test.ext". Ensure that the source is set and that generate is called first.', + 'Plugin error - Unable to get file name for asset "test.ext". Ensure that the source is set and that generate is called first. If you reference assets via import.meta.ROLLUP_FILE_URL_, you need to either have set their source after "renderStart" or need to provide an explicit "fileName" when emitting them.', plugin: 'test-plugin', pluginCode: 'ASSET_NOT_FINALISED' } -}; +}); diff --git a/test/function/samples/emit-file/asset-source-missing4/_config.js b/test/function/samples/emit-file/asset-source-missing4/_config.js index a61bd81012d..df9a9261be9 100644 --- a/test/function/samples/emit-file/asset-source-missing4/_config.js +++ b/test/function/samples/emit-file/asset-source-missing4/_config.js @@ -1,20 +1,22 @@ -module.exports = { +module.exports = defineTest({ description: 'throws when accessing the file name before the asset source is set', options: { - plugins: { - name: 'test-plugin', - buildStart() { - const assetId = this.emitFile({ type: 'asset' }); - this.getFileName(assetId); + plugins: [ + { + name: 'test-plugin', + buildStart() { + const assetId = this.emitFile({ type: 'asset' }); + this.getFileName(assetId); + } } - } + ] }, error: { code: 'PLUGIN_ERROR', hook: 'buildStart', message: - 'Plugin error - Unable to get file name for asset "d59386e0". Ensure that the source is set and that generate is called first.', + 'Plugin error - Unable to get file name for asset "BY8ZiPAi". Ensure that the source is set and that generate is called first. If you reference assets via import.meta.ROLLUP_FILE_URL_, you need to either have set their source after "renderStart" or need to provide an explicit "fileName" when emitting them.', plugin: 'test-plugin', pluginCode: 'ASSET_NOT_FINALISED' } -}; +}); diff --git a/test/function/samples/emit-file/asset-source-missing5/_config.js b/test/function/samples/emit-file/asset-source-missing5/_config.js index 7ba7af1ee9a..eb24df98146 100644 --- a/test/function/samples/emit-file/asset-source-missing5/_config.js +++ b/test/function/samples/emit-file/asset-source-missing5/_config.js @@ -1,19 +1,21 @@ -module.exports = { +module.exports = defineTest({ description: 'throws when not setting the asset source and accessing the asset URL', options: { - plugins: { - name: 'test-plugin', - load() { - return `export default import.meta.ROLLUP_FILE_URL_${this.emitFile({ - type: 'asset', - name: 'test.ext' - })};`; + plugins: [ + { + name: 'test-plugin', + load() { + return `export default import.meta.ROLLUP_FILE_URL_${this.emitFile({ + type: 'asset', + name: 'test.ext' + })};`; + } } - } + ] }, generateError: { code: 'ASSET_NOT_FINALISED', message: - 'Plugin error - Unable to get file name for asset "test.ext". Ensure that the source is set and that generate is called first.' + 'Plugin error - Unable to get file name for asset "test.ext". Ensure that the source is set and that generate is called first. If you reference assets via import.meta.ROLLUP_FILE_URL_, you need to either have set their source after "renderStart" or need to provide an explicit "fileName" when emitting them.' } -}; +}); diff --git a/test/function/samples/emit-file/chunk-filename-not-available-buildEnd/_config.js b/test/function/samples/emit-file/chunk-filename-not-available-buildEnd/_config.js index 95688f451a8..38735eaa063 100644 --- a/test/function/samples/emit-file/chunk-filename-not-available-buildEnd/_config.js +++ b/test/function/samples/emit-file/chunk-filename-not-available-buildEnd/_config.js @@ -1,25 +1,27 @@ let chunkId; -module.exports = { +module.exports = defineTest({ description: 'Throws when accessing the filename before it has been generated in buildEnd', options: { input: 'main.js', - plugins: { - name: 'test-plugin', - buildStart() { - chunkId = this.emitFile({ type: 'chunk', id: 'chunk.js' }); - }, - buildEnd() { - this.getFileName(chunkId); + plugins: [ + { + name: 'test-plugin', + buildStart() { + chunkId = this.emitFile({ type: 'chunk', id: 'chunk.js' }); + }, + buildEnd() { + this.getFileName(chunkId); + } } - } + ] }, error: { code: 'PLUGIN_ERROR', hook: 'buildEnd', message: - 'Plugin error - Unable to get file name for chunk "chunk.js". Ensure that generate is called first.', + 'Plugin error - Unable to get file name for emitted chunk "chunk.js". You can only get file names once chunks have been generated after the "renderStart" hook.', plugin: 'test-plugin', pluginCode: 'CHUNK_NOT_GENERATED' } -}; +}); diff --git a/test/function/samples/emit-file/chunk-filename-not-available-renderStart/_config.js b/test/function/samples/emit-file/chunk-filename-not-available-renderStart/_config.js index 8a35d9cfc2e..ce3bb763440 100644 --- a/test/function/samples/emit-file/chunk-filename-not-available-renderStart/_config.js +++ b/test/function/samples/emit-file/chunk-filename-not-available-renderStart/_config.js @@ -1,25 +1,27 @@ let chunkId; -module.exports = { +module.exports = defineTest({ description: 'Throws when accessing the filename before it has been generated in renderStart', options: { input: 'main.js', - plugins: { - name: 'test-plugin', - buildStart() { - chunkId = this.emitFile({ type: 'chunk', id: 'chunk.js' }); - }, - renderStart() { - this.getFileName(chunkId); + plugins: [ + { + name: 'test-plugin', + buildStart() { + chunkId = this.emitFile({ type: 'chunk', id: 'chunk.js' }); + }, + renderStart() { + this.getFileName(chunkId); + } } - } + ] }, generateError: { code: 'PLUGIN_ERROR', hook: 'renderStart', message: - 'Plugin error - Unable to get file name for chunk "chunk.js". Ensure that generate is called first.', + 'Plugin error - Unable to get file name for emitted chunk "chunk.js". You can only get file names once chunks have been generated after the "renderStart" hook.', plugin: 'test-plugin', pluginCode: 'CHUNK_NOT_GENERATED' } -}; +}); diff --git a/test/function/samples/emit-file/chunk-filename-not-available/_config.js b/test/function/samples/emit-file/chunk-filename-not-available/_config.js index eb87d7d659e..0d7d45e9158 100644 --- a/test/function/samples/emit-file/chunk-filename-not-available/_config.js +++ b/test/function/samples/emit-file/chunk-filename-not-available/_config.js @@ -1,24 +1,23 @@ -const path = require('path'); - -module.exports = { +module.exports = defineTest({ description: 'Throws when accessing the filename before it has been generated', options: { input: 'main.js', - plugins: { - name: 'test-plugin', - buildStart() { - const chunkId = this.emitFile({ type: 'chunk', id: 'chunk.js' }); - this.getFileName(chunkId); + plugins: [ + { + name: 'test-plugin', + buildStart() { + const chunkId = this.emitFile({ type: 'chunk', id: 'chunk.js' }); + this.getFileName(chunkId); + } } - } + ] }, error: { code: 'PLUGIN_ERROR', hook: 'buildStart', message: - 'Plugin error - Unable to get file name for chunk "chunk.js". Ensure that generate is called first.', + 'Plugin error - Unable to get file name for emitted chunk "chunk.js". You can only get file names once chunks have been generated after the "renderStart" hook.', plugin: 'test-plugin', - pluginCode: 'CHUNK_NOT_GENERATED', - watchFiles: [path.join(__dirname, 'chunk.js')] + pluginCode: 'CHUNK_NOT_GENERATED' } -}; +}); diff --git a/test/function/samples/emit-file/chunk-not-found/_config.js b/test/function/samples/emit-file/chunk-not-found/_config.js index 9c0df8d775d..458540b3092 100644 --- a/test/function/samples/emit-file/chunk-not-found/_config.js +++ b/test/function/samples/emit-file/chunk-not-found/_config.js @@ -1,18 +1,21 @@ -const path = require('path'); +const path = require('node:path'); +const ID_MAIN = path.join(__dirname, 'main.js'); -module.exports = { +module.exports = defineTest({ description: 'Throws if an emitted entry chunk cannot be resolved', options: { input: 'main.js', - plugins: { - buildStart() { - this.emitFile({ type: 'chunk', id: 'not-found.js' }); + plugins: [ + { + buildStart() { + this.emitFile({ type: 'chunk', id: 'not-found.js' }); + } } - } + ] }, error: { code: 'UNRESOLVED_ENTRY', - message: 'Could not resolve entry module (not-found.js).', - watchFiles: [path.join(__dirname, 'main.js')] + watchFiles: [ID_MAIN], + message: 'Could not resolve entry module "not-found.js".' } -}; +}); diff --git a/test/function/samples/emit-file/emit-from-output-options/_config.js b/test/function/samples/emit-file/emit-from-output-options/_config.js index bf3ce6381d7..10dec91e0bf 100644 --- a/test/function/samples/emit-file/emit-from-output-options/_config.js +++ b/test/function/samples/emit-file/emit-from-output-options/_config.js @@ -1,22 +1,24 @@ -module.exports = { +module.exports = defineTest({ description: 'throws when trying to emit files from the outputOptions hook', options: { input: 'main', - plugins: { - outputOptions() { - this.emitFile({ - type: 'asset', - source: 'asset' - }); + plugins: [ + { + outputOptions() { + this.emitFile({ + type: 'asset', + source: 'asset' + }); + } } - } + ] }, generateError: { code: 'PLUGIN_ERROR', hook: 'outputOptions', message: - 'Cannot emit files or set asset sources in the "outputOptions" hook, use the "renderStart" hook instead.', + '[plugin at position 1] Cannot emit files or set asset sources in the "outputOptions" hook, use the "renderStart" hook instead.', plugin: 'at position 1', pluginCode: 'CANNOT_EMIT_FROM_OPTIONS_HOOK' } -}; +}); diff --git a/test/function/samples/emit-file/emit-same-file/_config.js b/test/function/samples/emit-file/emit-same-file/_config.js index a0266d5791b..baf87fffcc6 100644 --- a/test/function/samples/emit-file/emit-same-file/_config.js +++ b/test/function/samples/emit-file/emit-same-file/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'warns if multiple files with the same name are emitted', options: { input: 'main.js', @@ -27,4 +27,4 @@ module.exports = { 'The emitted file "generateBundle" overwrites a previously emitted file of the same name.' } ] -}; +}); diff --git a/test/function/samples/emit-file/emit-same-file/_expected/amd/main.js b/test/function/samples/emit-file/emit-same-file/_expected/amd/main.js deleted file mode 100644 index f99c5d38fdf..00000000000 --- a/test/function/samples/emit-file/emit-same-file/_expected/amd/main.js +++ /dev/null @@ -1,9 +0,0 @@ -define(['exports'], function (exports) { 'use strict'; - - function hi() { return 2 } - - exports.hi = hi; - - Object.defineProperty(exports, '__esModule', { value: true }); - -}); diff --git a/test/function/samples/emit-file/emit-same-file/_expected/amd/myfile b/test/function/samples/emit-file/emit-same-file/_expected/amd/myfile deleted file mode 100644 index f2ba8f84ab5..00000000000 --- a/test/function/samples/emit-file/emit-same-file/_expected/amd/myfile +++ /dev/null @@ -1 +0,0 @@ -abc \ No newline at end of file diff --git a/test/function/samples/emit-file/emit-same-file/_expected/cjs/main.js b/test/function/samples/emit-file/emit-same-file/_expected/cjs/main.js deleted file mode 100644 index ce637f0dcc8..00000000000 --- a/test/function/samples/emit-file/emit-same-file/_expected/cjs/main.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { value: true }); - -function hi() { return 2 } - -exports.hi = hi; diff --git a/test/function/samples/emit-file/emit-same-file/_expected/cjs/myfile b/test/function/samples/emit-file/emit-same-file/_expected/cjs/myfile deleted file mode 100644 index f2ba8f84ab5..00000000000 --- a/test/function/samples/emit-file/emit-same-file/_expected/cjs/myfile +++ /dev/null @@ -1 +0,0 @@ -abc \ No newline at end of file diff --git a/test/function/samples/emit-file/emit-same-file/_expected/es/main.js b/test/function/samples/emit-file/emit-same-file/_expected/es/main.js deleted file mode 100644 index 47c2f790880..00000000000 --- a/test/function/samples/emit-file/emit-same-file/_expected/es/main.js +++ /dev/null @@ -1,3 +0,0 @@ -function hi() { return 2 } - -export { hi }; diff --git a/test/function/samples/emit-file/emit-same-file/_expected/es/myfile b/test/function/samples/emit-file/emit-same-file/_expected/es/myfile deleted file mode 100644 index f2ba8f84ab5..00000000000 --- a/test/function/samples/emit-file/emit-same-file/_expected/es/myfile +++ /dev/null @@ -1 +0,0 @@ -abc \ No newline at end of file diff --git a/test/function/samples/emit-file/emit-same-file/_expected/system/main.js b/test/function/samples/emit-file/emit-same-file/_expected/system/main.js deleted file mode 100644 index 0581de90888..00000000000 --- a/test/function/samples/emit-file/emit-same-file/_expected/system/main.js +++ /dev/null @@ -1,12 +0,0 @@ -System.register([], function (exports) { - 'use strict'; - return { - execute: function () { - - exports('hi', hi); - - function hi() { return 2 } - - } - }; -}); diff --git a/test/function/samples/emit-file/emit-same-file/_expected/system/myfile b/test/function/samples/emit-file/emit-same-file/_expected/system/myfile deleted file mode 100644 index f2ba8f84ab5..00000000000 --- a/test/function/samples/emit-file/emit-same-file/_expected/system/myfile +++ /dev/null @@ -1 +0,0 @@ -abc \ No newline at end of file diff --git a/test/function/samples/emit-file/file-references-in-bundle/My%2FFile.js b/test/function/samples/emit-file/file-references-in-bundle/My%2FFile.js new file mode 100644 index 00000000000..41958000064 --- /dev/null +++ b/test/function/samples/emit-file/file-references-in-bundle/My%2FFile.js @@ -0,0 +1 @@ +console.log('Hey!'); diff --git a/test/function/samples/emit-file/file-references-in-bundle/_config.js b/test/function/samples/emit-file/file-references-in-bundle/_config.js index 2d245fd526e..21e2ff675cd 100644 --- a/test/function/samples/emit-file/file-references-in-bundle/_config.js +++ b/test/function/samples/emit-file/file-references-in-bundle/_config.js @@ -1,27 +1,34 @@ -const assert = require('assert'); +const assert = require('node:assert'); +const { pathToFileURL } = require('node:url'); -module.exports = { +module.exports = defineTest({ description: 'lists referenced files in the bundle', options: { input: 'main', - plugins: { - transform() { - return `export const asset = import.meta.ROLLUP_FILE_URL_${this.emitFile({ - type: 'asset', - name: 'asset.txt', - source: 'asset' - })};\nexport const chunk = import.meta.ROLLUP_FILE_URL_${this.emitFile({ - type: 'chunk', - id: 'ref.js' - })}`; - }, - generateBundle(options, bundle) { - assert.deepStrictEqual(bundle['main.js'].referencedFiles, [ - 'assets/asset.txt', - 'chunks/ref.js' - ]); + plugins: [ + { + transform() { + return `export const asset = import.meta.ROLLUP_FILE_URL_${this.emitFile({ + type: 'asset', + name: 'asset.txt', + source: 'asset' + })};\nexport const chunk = import.meta.ROLLUP_FILE_URL_${this.emitFile({ + type: 'chunk', + id: 'ref.js' + })};\nexport const urlEncoding = import.meta.ROLLUP_FILE_URL_${this.emitFile({ + type: 'chunk', + id: 'My%2FFile.js' + })}`; + }, + generateBundle(options, bundle) { + assert.deepStrictEqual(bundle['main.js'].referencedFiles, [ + 'assets/asset.txt', + 'chunks/ref.js', + 'chunks/My_2FFile.js' + ]); + } } - }, + ], output: { assetFileNames: 'assets/[name][extname]', chunkFileNames: 'chunks/[name].js' @@ -31,9 +38,11 @@ module.exports = { __dirname: 'dir' }, exports(exports) { + const directoryURL = pathToFileURL('dir'); assert.deepStrictEqual(exports, { - asset: 'file:///dir/assets/asset.txt', - chunk: 'file:///dir/chunks/ref.js' + asset: `${directoryURL}/assets/asset.txt`, + chunk: `${directoryURL}/chunks/ref.js`, + urlEncoding: `${directoryURL}/chunks/My_2FFile.js` }); } -}; +}); diff --git a/test/function/samples/emit-file/invalid-asset-name/_config.js b/test/function/samples/emit-file/invalid-asset-name/_config.js index 58ff955cc15..27e2dd1843a 100644 --- a/test/function/samples/emit-file/invalid-asset-name/_config.js +++ b/test/function/samples/emit-file/invalid-asset-name/_config.js @@ -1,19 +1,21 @@ -module.exports = { +module.exports = defineTest({ description: 'throws for invalid asset names', options: { - plugins: { - name: 'test-plugin', - buildStart() { - this.emitFile({ type: 'asset', name: '/test.ext', source: 'content' }); + plugins: [ + { + name: 'test-plugin', + buildStart() { + this.emitFile({ type: 'asset', name: '/test.ext', source: 'content' }); + } } - } + ] }, error: { code: 'PLUGIN_ERROR', hook: 'buildStart', message: - 'The "fileName" or "name" properties of emitted files must be strings that are neither absolute nor relative paths and do not contain invalid characters, received "/test.ext".', + 'The "fileName" or "name" properties of emitted chunks and assets must be strings that are neither absolute nor relative paths, received "/test.ext".', plugin: 'test-plugin', pluginCode: 'VALIDATION_ERROR' } -}; +}); diff --git a/test/function/samples/emit-file/invalid-asset-name2/_config.js b/test/function/samples/emit-file/invalid-asset-name2/_config.js deleted file mode 100644 index c0ff923d737..00000000000 --- a/test/function/samples/emit-file/invalid-asset-name2/_config.js +++ /dev/null @@ -1,19 +0,0 @@ -module.exports = { - description: 'throws for invalid asset names with special characters', - options: { - plugins: { - name: 'test-plugin', - buildStart() { - this.emitFile({ type: 'asset', name: '\0test.ext', source: 'content' }); - } - } - }, - error: { - code: 'PLUGIN_ERROR', - hook: 'buildStart', - message: - 'The "fileName" or "name" properties of emitted files must be strings that are neither absolute nor relative paths and do not contain invalid characters, received "\u0000test.ext".', - plugin: 'test-plugin', - pluginCode: 'VALIDATION_ERROR' - } -}; diff --git a/test/function/samples/emit-file/invalid-asset-name2/main.js b/test/function/samples/emit-file/invalid-asset-name2/main.js deleted file mode 100644 index c4b940fc952..00000000000 --- a/test/function/samples/emit-file/invalid-asset-name2/main.js +++ /dev/null @@ -1 +0,0 @@ -throw new Error('should not build'); diff --git a/test/function/samples/emit-file/invalid-asset-name3/_config.js b/test/function/samples/emit-file/invalid-asset-name3/_config.js index da96f00fc22..a882176e131 100644 --- a/test/function/samples/emit-file/invalid-asset-name3/_config.js +++ b/test/function/samples/emit-file/invalid-asset-name3/_config.js @@ -1,19 +1,21 @@ -module.exports = { +module.exports = defineTest({ description: 'throws for invalid asset names with absolute path on Windows OS', options: { - plugins: { - name: 'test-plugin', - buildStart() { - this.emitFile({ type: 'asset', name: 'F:\\test.ext', source: 'content' }); + plugins: [ + { + name: 'test-plugin', + buildStart() { + this.emitFile({ type: 'asset', name: 'F:\\test.ext', source: 'content' }); + } } - } + ] }, error: { code: 'PLUGIN_ERROR', hook: 'buildStart', message: - 'The "fileName" or "name" properties of emitted files must be strings that are neither absolute nor relative paths and do not contain invalid characters, received "F:\\test.ext".', + 'The "fileName" or "name" properties of emitted chunks and assets must be strings that are neither absolute nor relative paths, received "F:\\test.ext".', plugin: 'test-plugin', pluginCode: 'VALIDATION_ERROR' } -}; +}); diff --git a/test/function/samples/emit-file/invalid-chunk-id/_config.js b/test/function/samples/emit-file/invalid-chunk-id/_config.js index ed73d4d4776..9b168b7fbbf 100644 --- a/test/function/samples/emit-file/invalid-chunk-id/_config.js +++ b/test/function/samples/emit-file/invalid-chunk-id/_config.js @@ -1,12 +1,14 @@ -module.exports = { +module.exports = defineTest({ description: 'throws for invalid chunk ids', options: { - plugins: { - name: 'test-plugin', - buildStart() { - this.emitFile({ type: 'chunk', id: null }); + plugins: [ + { + name: 'test-plugin', + buildStart() { + this.emitFile({ type: 'chunk', id: null }); + } } - } + ] }, error: { code: 'PLUGIN_ERROR', @@ -15,4 +17,4 @@ module.exports = { plugin: 'test-plugin', pluginCode: 'VALIDATION_ERROR' } -}; +}); diff --git a/test/function/samples/emit-file/invalid-file-type/_config.js b/test/function/samples/emit-file/invalid-file-type/_config.js index 1c665fc2772..32d7ffaf4d0 100644 --- a/test/function/samples/emit-file/invalid-file-type/_config.js +++ b/test/function/samples/emit-file/invalid-file-type/_config.js @@ -1,18 +1,21 @@ -module.exports = { +module.exports = defineTest({ description: 'throws for invalid file types', options: { - plugins: { - name: 'test-plugin', - buildStart() { - this.emitFile({ type: 'unknown' }); + plugins: [ + { + name: 'test-plugin', + buildStart() { + this.emitFile({ type: 'unknown' }); + } } - } + ] }, error: { code: 'PLUGIN_ERROR', hook: 'buildStart', - message: 'Emitted files must be of type "asset" or "chunk", received "unknown".', + message: + 'Emitted files must be of type "asset", "chunk" or "prebuilt-chunk", received "unknown".', plugin: 'test-plugin', pluginCode: 'VALIDATION_ERROR' } -}; +}); diff --git a/test/function/samples/emit-file/invalid-prebuilt-chunk-filename/_config.js b/test/function/samples/emit-file/invalid-prebuilt-chunk-filename/_config.js new file mode 100644 index 00000000000..36035d57c71 --- /dev/null +++ b/test/function/samples/emit-file/invalid-prebuilt-chunk-filename/_config.js @@ -0,0 +1,24 @@ +module.exports = defineTest({ + description: 'throws for invalid prebuilt chunks filename', + options: { + plugins: [ + { + name: 'test-plugin', + buildStart() { + this.emitFile({ + type: 'prebuilt-chunk', + code: 'console.log("my-chunk")' + }); + } + } + ] + }, + error: { + code: 'PLUGIN_ERROR', + hook: 'buildStart', + message: + 'The "fileName" property of emitted prebuilt chunks must be strings that are neither absolute nor relative paths, received "undefined".', + plugin: 'test-plugin', + pluginCode: 'VALIDATION_ERROR' + } +}); diff --git a/test/function/samples/deprecated/emit-asset/asset-source-missing-2/main.js b/test/function/samples/emit-file/invalid-prebuilt-chunk-filename/main.js similarity index 100% rename from test/function/samples/deprecated/emit-asset/asset-source-missing-2/main.js rename to test/function/samples/emit-file/invalid-prebuilt-chunk-filename/main.js diff --git a/test/function/samples/emit-file/invalid-prebuit-chunk-code/_config.js b/test/function/samples/emit-file/invalid-prebuit-chunk-code/_config.js new file mode 100644 index 00000000000..5b02a32bf0e --- /dev/null +++ b/test/function/samples/emit-file/invalid-prebuit-chunk-code/_config.js @@ -0,0 +1,23 @@ +module.exports = defineTest({ + description: 'throws for invalid prebuilt chunks code', + options: { + plugins: [ + { + name: 'test-plugin', + buildStart() { + this.emitFile({ + type: 'prebuilt-chunk', + fileName: 'my-chunk.js' + }); + } + } + ] + }, + error: { + code: 'PLUGIN_ERROR', + hook: 'buildStart', + message: 'Emitted prebuilt chunks need to have a valid string code, received "undefined".', + plugin: 'test-plugin', + pluginCode: 'VALIDATION_ERROR' + } +}); diff --git a/test/function/samples/deprecated/emit-asset/asset-source-missing-3/main.js b/test/function/samples/emit-file/invalid-prebuit-chunk-code/main.js similarity index 100% rename from test/function/samples/deprecated/emit-asset/asset-source-missing-3/main.js rename to test/function/samples/emit-file/invalid-prebuit-chunk-code/main.js diff --git a/test/function/samples/emit-file/invalid-reference-id/_config.js b/test/function/samples/emit-file/invalid-reference-id/_config.js index 43e4e38420f..b7589ef7ef8 100644 --- a/test/function/samples/emit-file/invalid-reference-id/_config.js +++ b/test/function/samples/emit-file/invalid-reference-id/_config.js @@ -1,15 +1,17 @@ -module.exports = { +module.exports = defineTest({ description: 'throws for invalid reference ids', options: { - plugins: { - name: 'test-plugin', - load() { - return `export default import.meta.ROLLUP_FILE_URL_invalid;`; + plugins: [ + { + name: 'test-plugin', + load() { + return `export default import.meta.ROLLUP_FILE_URL_invalid;`; + } } - } + ] }, generateError: { code: 'FILE_NOT_FOUND', message: 'Plugin error - Unable to get file name for unknown file "invalid".' } -}; +}); diff --git a/test/function/samples/emit-file/invalid-set-asset-source-id/_config.js b/test/function/samples/emit-file/invalid-set-asset-source-id/_config.js index 67ed85414a5..a47185b38e5 100644 --- a/test/function/samples/emit-file/invalid-set-asset-source-id/_config.js +++ b/test/function/samples/emit-file/invalid-set-asset-source-id/_config.js @@ -1,12 +1,14 @@ -module.exports = { +module.exports = defineTest({ description: 'throws for invalid asset ids', options: { - plugins: { - name: 'test-plugin', - buildStart() { - this.setAssetSource('invalid', 'content'); + plugins: [ + { + name: 'test-plugin', + buildStart() { + this.setAssetSource('invalid', 'content'); + } } - } + ] }, error: { code: 'PLUGIN_ERROR', @@ -15,4 +17,4 @@ module.exports = { plugin: 'test-plugin', pluginCode: 'ASSET_NOT_FOUND' } -}; +}); diff --git a/test/function/samples/emit-file/modules-loaded/_config.js b/test/function/samples/emit-file/modules-loaded/_config.js index 3cd01bfcd83..c6b7262148a 100644 --- a/test/function/samples/emit-file/modules-loaded/_config.js +++ b/test/function/samples/emit-file/modules-loaded/_config.js @@ -1,13 +1,15 @@ -module.exports = { +module.exports = defineTest({ description: 'Throws when adding a chunk after the modules have finished loading', options: { input: 'main.js', - plugins: { - name: 'test-plugin', - buildEnd() { - this.emitFile({ type: 'chunk', id: 'chunk.js' }); + plugins: [ + { + name: 'test-plugin', + buildEnd() { + this.emitFile({ type: 'chunk', id: 'chunk.js' }); + } } - } + ] }, error: { code: 'PLUGIN_ERROR', @@ -16,4 +18,4 @@ module.exports = { plugin: 'test-plugin', pluginCode: 'INVALID_ROLLUP_PHASE' } -}; +}); diff --git a/test/function/samples/emit-file/no-input/_config.js b/test/function/samples/emit-file/no-input/_config.js index c35eb800405..e6eaaf3eed5 100644 --- a/test/function/samples/emit-file/no-input/_config.js +++ b/test/function/samples/emit-file/no-input/_config.js @@ -1,12 +1,14 @@ -module.exports = { +module.exports = defineTest({ description: 'It is not necessary to provide an input if a dynamic entry is emitted', options: { input: undefined, - plugins: { - name: 'test-plugin', - buildStart() { - this.emitFile({ type: 'chunk', id: 'chunk.js' }); + plugins: [ + { + name: 'test-plugin', + buildStart() { + this.emitFile({ type: 'chunk', id: 'chunk.js' }); + } } - } + ] } -}; +}); diff --git a/test/function/samples/emit-file/original-file-name/_config.js b/test/function/samples/emit-file/original-file-name/_config.js new file mode 100644 index 00000000000..0463b23563d --- /dev/null +++ b/test/function/samples/emit-file/original-file-name/_config.js @@ -0,0 +1,51 @@ +const assert = require('node:assert'); +const path = require('node:path'); + +const ORIGINAL_FILE_NAME = path.join(__dirname, 'original.txt'); + +module.exports = defineTest({ + description: 'forwards the original file name to other hooks', + options: { + output: { + assetFileNames(info) { + if (info.names.includes('with_original.txt')) { + assert.deepStrictEqual(info.originalFileNames, [ORIGINAL_FILE_NAME]); + } else { + assert.deepStrictEqual(info.originalFileNames, []); + } + return info.names[0]; + } + }, + plugins: [ + { + name: 'test', + buildStart() { + this.emitFile({ + type: 'asset', + name: 'with_original.txt', + originalFileName: ORIGINAL_FILE_NAME, + source: 'with original file name' + }); + this.emitFile({ + type: 'asset', + name: 'with_original_null.txt', + originalFileName: null, + source: 'with original file name null' + }); + this.emitFile({ + type: 'asset', + name: 'without_original.txt', + source: 'without original file name' + }); + }, + generateBundle(options, bundle) { + assert.deepStrictEqual(bundle['with_original.txt'].originalFileNames, [ + ORIGINAL_FILE_NAME + ]); + assert.deepStrictEqual(bundle['with_original_null.txt'].originalFileNames, []); + assert.deepStrictEqual(bundle['without_original.txt'].originalFileNames, []); + } + } + ] + } +}); diff --git a/test/function/samples/emit-file/original-file-name/main.js b/test/function/samples/emit-file/original-file-name/main.js new file mode 100644 index 00000000000..69b8f8f7946 --- /dev/null +++ b/test/function/samples/emit-file/original-file-name/main.js @@ -0,0 +1,13 @@ +let effect = false; + +var b = { + get a() { + effect = true; + } +}; + +function X() {} +X.prototype = b; +new X().a; + +assert.ok(effect); diff --git a/test/function/samples/emit-file/original-file-names/_config.js b/test/function/samples/emit-file/original-file-names/_config.js new file mode 100644 index 00000000000..2abe1bc28f4 --- /dev/null +++ b/test/function/samples/emit-file/original-file-names/_config.js @@ -0,0 +1,85 @@ +const assert = require('node:assert'); +const path = require('node:path'); + +const ORIGINAL_FILE_NAME_1 = path.join(__dirname, 'original.txt'); +const ORIGINAL_FILE_NAME_2A = path.join(__dirname, 'original2a.txt'); +const ORIGINAL_FILE_NAME_2B = path.join(__dirname, 'original2b.txt'); + +module.exports = defineTest({ + description: 'forwards the original file name to other hooks', + options: { + output: { + assetFileNames({ names, originalFileNames, source }) { + switch (source) { + case 'with original file name': + assert.deepEqual(names, ['with_original.txt']); + assert.deepEqual(originalFileNames, [ORIGINAL_FILE_NAME_1]); + break; + case 'with multiple original file names': + assert.deepEqual(names, [ + 'with_multiple_original_a.txt', + 'with_multiple_original_b.txt' + ]); + assert.deepEqual(originalFileNames, [ORIGINAL_FILE_NAME_2A, ORIGINAL_FILE_NAME_2B]); + break; + case 'with original file name null': + assert.deepEqual(names, ['with_original_null.txt']); + assert.deepEqual(originalFileNames, []); + break; + case 'without original file name': + assert.deepEqual(names, ['without_original.txt']); + assert.deepEqual(originalFileNames, []); + break; + default: + throw new Error(`Unexpected source: ${source}`); + } + return names[0]; + } + }, + plugins: [ + { + name: 'test', + buildStart() { + this.emitFile({ + type: 'asset', + name: 'with_original.txt', + originalFileName: ORIGINAL_FILE_NAME_1, + source: 'with original file name' + }); + this.emitFile({ + type: 'asset', + name: 'with_multiple_original_a.txt', + originalFileName: ORIGINAL_FILE_NAME_2A, + source: 'with multiple original file names' + }); + this.emitFile({ + type: 'asset', + name: 'with_multiple_original_b.txt', + originalFileName: ORIGINAL_FILE_NAME_2B, + source: 'with multiple original file names' + }); + this.emitFile({ + type: 'asset', + name: 'with_original_null.txt', + originalFileName: null, + source: 'with original file name null' + }); + this.emitFile({ + type: 'asset', + name: 'without_original.txt', + source: 'without original file name' + }); + }, + generateBundle(options, bundle) { + assert.deepEqual(bundle['with_original.txt'].originalFileNames, [ORIGINAL_FILE_NAME_1]); + assert.deepEqual(bundle['with_multiple_original_a.txt'].originalFileNames, [ + ORIGINAL_FILE_NAME_2A, + ORIGINAL_FILE_NAME_2B + ]); + assert.deepEqual(bundle['with_original_null.txt'].originalFileNames, []); + assert.deepEqual(bundle['without_original.txt'].originalFileNames, []); + } + } + ] + } +}); diff --git a/test/function/samples/emit-file/original-file-names/main.js b/test/function/samples/emit-file/original-file-names/main.js new file mode 100644 index 00000000000..69b8f8f7946 --- /dev/null +++ b/test/function/samples/emit-file/original-file-names/main.js @@ -0,0 +1,13 @@ +let effect = false; + +var b = { + get a() { + effect = true; + } +}; + +function X() {} +X.prototype = b; +new X().a; + +assert.ok(effect); diff --git a/test/function/samples/emit-file/prebuilt-chunk/_config.js b/test/function/samples/emit-file/prebuilt-chunk/_config.js new file mode 100644 index 00000000000..496b924c5d7 --- /dev/null +++ b/test/function/samples/emit-file/prebuilt-chunk/_config.js @@ -0,0 +1,84 @@ +const assert = require('node:assert'); + +const prebuiltChunk1ConsumedProperties = { + fileName: 'my-chunk.js', + code: 'exports.foo = "foo"', + exports: ['foo'] +}; + +const prebuiltChunk2ConsumedProperties = { + fileName: 'my-chunk2.js', + code: 'assert.ok(true)' +}; + +module.exports = defineTest({ + description: 'get right prebuilt chunks', + options: { + plugins: [ + { + resolveId(id) { + if ( + [ + prebuiltChunk1ConsumedProperties.fileName, + prebuiltChunk2ConsumedProperties.fileName + ].includes(id) + ) { + return { + id, + external: true + }; + } + }, + buildStart() { + const referenceId = this.emitFile({ + type: 'prebuilt-chunk', + ...prebuiltChunk1ConsumedProperties + }); + assert.strictEqual( + this.getFileName(referenceId), + prebuiltChunk1ConsumedProperties.fileName + ); + }, + generateBundle(_, bundle) { + const defaultProps = { + dynamicImports: [], + facadeModuleId: null, + implicitlyLoadedBefore: [], + importedBindings: {}, + imports: [], + isDynamicEntry: false, + isEntry: false, + isImplicitEntry: false, + moduleIds: [], + modules: {}, + referencedFiles: [], + type: 'chunk' + }; + const { fileName } = prebuiltChunk1ConsumedProperties; + assert.deepStrictEqual(bundle[fileName], { + ...defaultProps, + ...prebuiltChunk1ConsumedProperties, + name: fileName, + map: null, + sourcemapFileName: null, + preliminaryFileName: 'my-chunk.js' + }); + this.emitFile({ + type: 'prebuilt-chunk', + ...prebuiltChunk2ConsumedProperties + }); + const { fileName: fileName2 } = prebuiltChunk2ConsumedProperties; + assert.deepStrictEqual(bundle[fileName2], { + ...defaultProps, + ...prebuiltChunk2ConsumedProperties, + name: fileName2, + exports: [], + map: null, + sourcemapFileName: null, + preliminaryFileName: 'my-chunk2.js' + }); + } + } + ] + } +}); diff --git a/test/function/samples/emit-file/prebuilt-chunk/main.js b/test/function/samples/emit-file/prebuilt-chunk/main.js new file mode 100644 index 00000000000..822d5884839 --- /dev/null +++ b/test/function/samples/emit-file/prebuilt-chunk/main.js @@ -0,0 +1,3 @@ +import { foo } from 'my-chunk.js'; +import 'my-chunk2.js'; +assert.equal(foo, 'foo'); diff --git a/test/function/samples/emit-file/set-asset-source-chunk/_config.js b/test/function/samples/emit-file/set-asset-source-chunk/_config.js index 5c07fa1556b..03b6b2b5361 100644 --- a/test/function/samples/emit-file/set-asset-source-chunk/_config.js +++ b/test/function/samples/emit-file/set-asset-source-chunk/_config.js @@ -1,22 +1,21 @@ -const path = require('path'); - -module.exports = { +module.exports = defineTest({ description: 'throws when trying to set the asset source of a chunk', options: { - plugins: { - name: 'test-plugin', - buildStart() { - const referenceId = this.emitFile({ type: 'chunk', id: 'chunk' }); - this.setAssetSource(referenceId, 'hello world'); + plugins: [ + { + name: 'test-plugin', + buildStart() { + const referenceId = this.emitFile({ type: 'chunk', id: 'chunk' }); + this.setAssetSource(referenceId, 'hello world'); + } } - } + ] }, error: { code: 'PLUGIN_ERROR', hook: 'buildStart', - message: 'Asset sources can only be set for emitted assets but "6c87f683" is an emitted chunk.', + message: 'Asset sources can only be set for emitted assets but "BVuJu3dA" is an emitted chunk.', plugin: 'test-plugin', - pluginCode: 'VALIDATION_ERROR', - watchFiles: [path.join(__dirname, 'chunk.js')] + pluginCode: 'VALIDATION_ERROR' } -}; +}); diff --git a/test/function/samples/emit-file/set-asset-source-transform/_config.js b/test/function/samples/emit-file/set-asset-source-transform/_config.js index 8c38ccfd344..730ec1f770a 100644 --- a/test/function/samples/emit-file/set-asset-source-transform/_config.js +++ b/test/function/samples/emit-file/set-asset-source-transform/_config.js @@ -1,25 +1,27 @@ -const path = require('path'); +const path = require('node:path'); -module.exports = { +module.exports = defineTest({ description: 'throws when setting the asset source in the transform hook', options: { - plugins: { - name: 'test-plugin', - transform(code) { - const assetId = this.emitFile({ type: 'asset', name: 'test.ext' }); - this.setAssetSource(assetId, 'asdf'); - return code; + plugins: [ + { + name: 'test-plugin', + transform(code) { + const assetId = this.emitFile({ type: 'asset', name: 'test.ext' }); + this.setAssetSource(assetId, 'asdf'); + return code; + } } - } + ] }, error: { code: 'PLUGIN_ERROR', hook: 'transform', id: path.join(__dirname, 'main.js'), message: - 'setAssetSource cannot be called in transform for caching reasons. Use emitFile with a source, or call setAssetSource in another hook.', + '[plugin test-plugin] main.js: setAssetSource cannot be called in transform for caching reasons. Use emitFile with a source, or call setAssetSource in another hook.', plugin: 'test-plugin', pluginCode: 'INVALID_SETASSETSOURCE', watchFiles: [path.join(__dirname, 'main.js')] } -}; +}); diff --git a/test/function/samples/emit-file/set-asset-source-twice/_config.js b/test/function/samples/emit-file/set-asset-source-twice/_config.js index 52e798fec21..fd06baa2be9 100644 --- a/test/function/samples/emit-file/set-asset-source-twice/_config.js +++ b/test/function/samples/emit-file/set-asset-source-twice/_config.js @@ -1,14 +1,16 @@ -module.exports = { +module.exports = defineTest({ description: 'throws when setting the asset source twice', options: { - plugins: { - name: 'test-plugin', - buildEnd() { - const assetId = this.emitFile({ type: 'asset', name: 'test.ext' }); - this.setAssetSource(assetId, 'hello world'); - this.setAssetSource(assetId, 'another'); + plugins: [ + { + name: 'test-plugin', + buildEnd() { + const assetId = this.emitFile({ type: 'asset', name: 'test.ext' }); + this.setAssetSource(assetId, 'hello world'); + this.setAssetSource(assetId, 'another'); + } } - } + ] }, error: { code: 'PLUGIN_ERROR', @@ -17,4 +19,4 @@ module.exports = { plugin: 'test-plugin', pluginCode: 'ASSET_SOURCE_ALREADY_SET' } -}; +}); diff --git a/test/function/samples/emit-file/set-asset-source-twice2/_config.js b/test/function/samples/emit-file/set-asset-source-twice2/_config.js index b02d47bfa18..c53c74dd178 100644 --- a/test/function/samples/emit-file/set-asset-source-twice2/_config.js +++ b/test/function/samples/emit-file/set-asset-source-twice2/_config.js @@ -1,20 +1,22 @@ -module.exports = { +module.exports = defineTest({ description: 'throws when setting the asset source twice', options: { - plugins: { - name: 'test-plugin', - buildEnd() { - const assetId = this.emitFile({ type: 'asset' }); - this.setAssetSource(assetId, 'hello world'); - this.setAssetSource(assetId, 'another'); + plugins: [ + { + name: 'test-plugin', + buildEnd() { + const assetId = this.emitFile({ type: 'asset' }); + this.setAssetSource(assetId, 'hello world'); + this.setAssetSource(assetId, 'another'); + } } - } + ] }, error: { code: 'PLUGIN_ERROR', hook: 'buildEnd', - message: 'Unable to set the source for asset "d59386e0", source already set.', + message: 'Unable to set the source for asset "BY8ZiPAi", source already set.', plugin: 'test-plugin', pluginCode: 'ASSET_SOURCE_ALREADY_SET' } -}; +}); diff --git a/test/function/samples/emit-file/set-source-in-output-options/_config.js b/test/function/samples/emit-file/set-source-in-output-options/_config.js index 6cba91aa9a2..19361049396 100644 --- a/test/function/samples/emit-file/set-source-in-output-options/_config.js +++ b/test/function/samples/emit-file/set-source-in-output-options/_config.js @@ -1,24 +1,26 @@ let referenceId; -module.exports = { +module.exports = defineTest({ description: 'throws when trying to set file sources in the outputOptions hook', options: { input: 'main', - plugins: { - buildStart() { - referenceId = this.emitFile({ type: 'asset' }); - }, - outputOptions() { - this.setAssetSource(referenceId, 'not allowed'); + plugins: [ + { + buildStart() { + referenceId = this.emitFile({ type: 'asset' }); + }, + outputOptions() { + this.setAssetSource(referenceId, 'not allowed'); + } } - } + ] }, generateError: { code: 'PLUGIN_ERROR', hook: 'outputOptions', message: - 'Cannot emit files or set asset sources in the "outputOptions" hook, use the "renderStart" hook instead.', + '[plugin at position 1] Cannot emit files or set asset sources in the "outputOptions" hook, use the "renderStart" hook instead.', plugin: 'at position 1', pluginCode: 'CANNOT_EMIT_FROM_OPTIONS_HOOK' } -}; +}); diff --git a/test/function/samples/empty-imports-have-side-effects/_config.js b/test/function/samples/empty-imports-have-side-effects/_config.js index 683ca7598eb..b9b1ce68533 100644 --- a/test/function/samples/empty-imports-have-side-effects/_config.js +++ b/test/function/samples/empty-imports-have-side-effects/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'empty imports are assumed to contain side-effects' -}; +}); diff --git a/test/function/samples/empty-string-as-module-name/_config.js b/test/function/samples/empty-string-as-module-name/_config.js index dfbc2595b37..df34004792a 100644 --- a/test/function/samples/empty-string-as-module-name/_config.js +++ b/test/function/samples/empty-string-as-module-name/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'allows using empty string as a valid module name', options: { external: () => false, @@ -12,4 +12,4 @@ module.exports = { } ] } -}; +}); diff --git a/test/function/samples/enforce-plugin-order/_config.js b/test/function/samples/enforce-plugin-order/_config.js new file mode 100644 index 00000000000..1ce69b69fb9 --- /dev/null +++ b/test/function/samples/enforce-plugin-order/_config.js @@ -0,0 +1,108 @@ +const assert = require('node:assert'); +const fs = require('node:fs'); +const path = require('node:path'); +const acorn = require('acorn'); + +const ID_MAIN = path.join(__dirname, 'main.js'); +const code = fs.readFileSync(ID_MAIN, 'utf8'); + +const hooks = [ + 'augmentChunkHash', + 'buildEnd', + 'buildStart', + 'generateBundle', + 'load', + 'moduleParsed', + 'options', + 'outputOptions', + 'renderDynamicImport', + 'renderChunk', + 'renderStart', + 'resolveDynamicImport', + 'resolveFileUrl', + 'resolveId', + 'resolveImportMeta', + 'shouldTransformCachedModule', + 'transform' +]; + +const calledHooks = {}; +for (const hook of hooks) { + calledHooks[hook] = []; +} + +const plugins = [ + { + name: 'emitter', + resolveId(source) { + if (source === 'dep') { + return source; + } + }, + load(source) { + if (source === 'dep') { + return `assert.okt(import.meta.url);\nassert.ok(import.meta.ROLLUP_FILE_URL_${this.emitFile( + { + type: 'asset', + source: 'test' + } + )});`; + } + } + } +]; +addPlugin(null); +addPlugin('pre'); +addPlugin('post'); +addPlugin('post'); +addPlugin('pre'); +addPlugin(); +function addPlugin(order) { + const name = `${order}-${plugins.length}`; + const plugin = { name }; + for (const hook of hooks) { + plugin[hook] = { + order, + handler() { + if (!calledHooks[hook].includes(name)) { + calledHooks[hook].push(name); + } + } + }; + } + plugins.push(plugin); +} + +module.exports = defineTest({ + description: 'allows to enforce plugin hook order', + options: { + plugins, + cache: { + modules: [ + { + id: ID_MAIN, + ast: acorn.parse(code, { + ecmaVersion: 2020, + sourceType: 'module' + }), + code, + dependencies: [], + dynamicDependencies: [], + originalCode: code, + resolvedIds: {}, + sourcemapChain: [], + transformDependencies: [] + } + ] + } + }, + exports() { + for (const hook of hooks) { + assert.deepStrictEqual( + calledHooks[hook], + ['pre-2', 'pre-5', 'null-1', 'undefined-6', 'post-3', 'post-4'], + hook + ); + } + } +}); diff --git a/test/function/samples/enforce-plugin-order/main.js b/test/function/samples/enforce-plugin-order/main.js new file mode 100644 index 00000000000..17f9d42facd --- /dev/null +++ b/test/function/samples/enforce-plugin-order/main.js @@ -0,0 +1 @@ +import('dep'); diff --git a/test/function/samples/enforce-sequential-plugin-order/_config.js b/test/function/samples/enforce-sequential-plugin-order/_config.js new file mode 100644 index 00000000000..8d58e4235b6 --- /dev/null +++ b/test/function/samples/enforce-sequential-plugin-order/_config.js @@ -0,0 +1,89 @@ +const assert = require('node:assert'); +const { wait } = require('../../../testHelpers'); + +const hooks = [ + 'banner', + 'buildEnd', + 'buildStart', + 'footer', + 'intro', + 'moduleParsed', + 'outro', + 'renderStart' +]; + +const calledHooks = {}; +const activeHooks = {}; +for (const hook of hooks) { + calledHooks[hook] = []; + activeHooks[hook] = new Set(); +} + +const plugins = []; +addPlugin(null, true); +addPlugin('pre', false); +addPlugin('post', false); +addPlugin('post', false); +addPlugin('pre', false); +addPlugin(undefined, true); +addPlugin(null, false); +addPlugin('pre', true); +addPlugin('post', true); +addPlugin('post', true); +addPlugin('pre', true); +addPlugin(undefined, false); + +function addPlugin(order, sequential) { + const name = `${order}-${sequential ? 'seq-' : ''}${plugins.length + 1}`; + const plugin = { name }; + for (const hook of hooks) { + plugin[hook] = { + order, + async handler() { + const active = activeHooks[hook]; + if (!calledHooks[hook].includes(name)) { + calledHooks[hook].push(sequential ? name : [name, [...active]]); + } + if (sequential && active.size > 0) { + throw new Error(`Detected parallel hook runs in ${hook}.`); + } + active.add(name); + // A setTimeout always takes longer than any chain of immediately + // resolved promises + await wait(0); + active.delete(name); + }, + sequential + }; + } + plugins.push(plugin); +} + +module.exports = defineTest({ + description: 'allows to enforce sequential plugin hook order for parallel plugin hooks', + options: { + plugins + }, + exports() { + for (const hook of hooks) { + assert.deepStrictEqual( + calledHooks[hook], + [ + ['pre-2', []], + ['pre-5', ['pre-2']], + 'pre-seq-8', + 'pre-seq-11', + 'null-seq-1', + 'undefined-seq-6', + ['null-7', []], + ['undefined-12', ['null-7']], + ['post-3', ['null-7', 'undefined-12']], + ['post-4', ['null-7', 'undefined-12', 'post-3']], + 'post-seq-9', + 'post-seq-10' + ], + hook + ); + } + } +}); diff --git a/test/function/samples/enforce-sequential-plugin-order/main.js b/test/function/samples/enforce-sequential-plugin-order/main.js new file mode 100644 index 00000000000..cc1d88a24fa --- /dev/null +++ b/test/function/samples/enforce-sequential-plugin-order/main.js @@ -0,0 +1 @@ +assert.ok(true); diff --git a/test/function/samples/error-after-transform-should-throw-correct-location/_config.js b/test/function/samples/error-after-transform-should-throw-correct-location/_config.js index 5e5026bef19..9cd989d4475 100644 --- a/test/function/samples/error-after-transform-should-throw-correct-location/_config.js +++ b/test/function/samples/error-after-transform-should-throw-correct-location/_config.js @@ -1,12 +1,14 @@ -const path = require('path'); +const path = require('node:path'); const MagicString = require('magic-string'); +const ID_MAIN = path.join(__dirname, 'main.js'); +const ID_EMPTY = path.join(__dirname, 'empty.js'); -module.exports = { +module.exports = defineTest({ description: 'error after transform should throw with correct location of file', options: { plugins: [ { - transform(source, id) { + transform(source) { const s = new MagicString(source); s.prepend("import _assign from 'object-assign';\n"); @@ -19,15 +21,16 @@ module.exports = { ] }, error: { + binding: 'default', code: 'MISSING_EXPORT', - message: `'default' is not exported by empty.js, imported by main.js`, - id: path.join(__dirname, 'main.js'), + exporter: ID_EMPTY, + id: ID_MAIN, + url: 'https://rollupjs.org/troubleshooting/#error-name-is-not-exported-by-module', pos: 44, - watchFiles: [path.join(__dirname, 'main.js'), path.join(__dirname, 'empty.js')], loc: { - file: path.join(__dirname, 'main.js'), - line: 1, - column: 7 + column: 7, + file: ID_MAIN, + line: 1 }, frame: ` 1: import a from './empty.js'; @@ -35,6 +38,7 @@ module.exports = { 2: 3: Object.assign({}, a); `, - url: `https://rollupjs.org/guide/en/#error-name-is-not-exported-by-module` + watchFiles: [ID_EMPTY, ID_MAIN], + message: 'main.js (1:7): "default" is not exported by "empty.js", imported by "main.js".' } -}; +}); diff --git a/test/function/samples/error-missing-umd-name/_config.js b/test/function/samples/error-missing-umd-name/_config.js index 3a722d59f6d..650de3601c4 100644 --- a/test/function/samples/error-missing-umd-name/_config.js +++ b/test/function/samples/error-missing-umd-name/_config.js @@ -1,9 +1,10 @@ -module.exports = { +module.exports = defineTest({ description: 'throws an error if no name is provided for a UMD bundle', options: { output: { format: 'umd' } }, generateError: { code: 'MISSING_NAME_OPTION_FOR_IIFE_EXPORT', message: - 'You must supply "output.name" for UMD bundles that have exports so that the exports are accessible in environments without a module loader.' + 'You must supply "output.name" for UMD bundles that have exports so that the exports are accessible in environments without a module loader.', + url: 'https://rollupjs.org/configuration-options/#output-name' } -}; +}); diff --git a/test/function/samples/error-parse-json/_config.js b/test/function/samples/error-parse-json/_config.js index 5e0f3c57466..c9794c01619 100644 --- a/test/function/samples/error-parse-json/_config.js +++ b/test/function/samples/error-parse-json/_config.js @@ -1,33 +1,32 @@ -const path = require('path'); +const path = require('node:path'); +const ID_MAIN = path.join(__dirname, 'main.js'); +const ID_JSON = path.join(__dirname, 'file.json'); -module.exports = { +module.exports = defineTest({ description: 'throws with an extended error message when failing to parse a file with ".json" extension', error: { - code: 'PARSE_ERROR', - message: 'Unexpected token (Note that you need @rollup/plugin-json to import JSON files)', - id: path.join(__dirname, 'file.json'), - parserError: { - loc: { - column: 8, - line: 2 - }, - message: 'Unexpected token (2:8)', + cause: { + code: 'PARSE_ERROR', pos: 10, - raisedAt: 11 + message: "Expected ';', '}' or " }, + code: 'PARSE_ERROR', + id: ID_JSON, pos: 10, - watchFiles: [path.join(__dirname, 'main.js'), path.join(__dirname, 'file.json')], loc: { - file: path.join(__dirname, 'file.json'), - line: 2, - column: 8 + column: 8, + file: ID_JSON, + line: 2 }, frame: ` 1: { 2: "JSON": "is not really JavaScript" ^ 3: } - ` + `, + watchFiles: [ID_JSON, ID_MAIN], + message: + "file.json (2:8): Expected ';', '}' or (Note that you need @rollup/plugin-json to import JSON files)" } -}; +}); diff --git a/test/function/samples/error-parse-unknown-extension/_config.js b/test/function/samples/error-parse-unknown-extension/_config.js index 20767778673..9570bd753c4 100644 --- a/test/function/samples/error-parse-unknown-extension/_config.js +++ b/test/function/samples/error-parse-unknown-extension/_config.js @@ -1,34 +1,32 @@ -const path = require('path'); +const path = require('node:path'); +const ID_MAIN = path.join(__dirname, 'main.js'); +const ID_CSS = path.join(__dirname, 'file.css'); -module.exports = { +module.exports = defineTest({ description: 'throws with an extended error message when failing to parse a file without .(m)js extension', error: { - code: 'PARSE_ERROR', - message: - 'Unexpected token (Note that you need plugins to import files that are not JavaScript)', - id: path.join(__dirname, 'file.css'), - parserError: { - loc: { - column: 0, - line: 1 - }, - message: 'Unexpected token (1:0)', + cause: { + code: 'PARSE_ERROR', pos: 0, - raisedAt: 1 + message: 'Expression expected' }, + code: 'PARSE_ERROR', + id: ID_CSS, pos: 0, - watchFiles: [path.join(__dirname, 'main.js'), path.join(__dirname, 'file.css')], loc: { - file: path.join(__dirname, 'file.css'), - line: 1, - column: 0 + column: 0, + file: ID_CSS, + line: 1 }, frame: ` 1: .special-class { ^ 2: color: black; 3: } - ` + `, + watchFiles: [ID_CSS, ID_MAIN], + message: + 'file.css (1:0): Expression expected (Note that you need plugins to import files that are not JavaScript)' } -}; +}); diff --git a/test/function/samples/es5-class-called-without-new/_config.js b/test/function/samples/es5-class-called-without-new/_config.js index f053ebf7976..76acf9c94b0 100644 --- a/test/function/samples/es5-class-called-without-new/_config.js +++ b/test/function/samples/es5-class-called-without-new/_config.js @@ -1 +1,3 @@ -module.exports = {}; +module.exports = defineTest({ + description: 'does not swallow type errors when running constructor functions without "new"' +}); diff --git a/test/function/samples/es5-class-called-without-new/main.js b/test/function/samples/es5-class-called-without-new/main.js index 419b8046b3d..22ba3b3f6c8 100644 --- a/test/function/samples/es5-class-called-without-new/main.js +++ b/test/function/samples/es5-class-called-without-new/main.js @@ -2,6 +2,4 @@ import { Foo, Bar } from './foo'; assert.equal( new Foo(5).value, 5 ); -assert.throws( function () { - Bar(5); -}, /^TypeError: Cannot set property 'value' of undefined$/ ); +assert.throws(() => Bar(5), /^TypeError: Cannot set propert.*'value'.*$/ ); diff --git a/test/function/samples/escape-arguments/_config.js b/test/function/samples/escape-arguments/_config.js new file mode 100644 index 00000000000..d6a327e57a5 --- /dev/null +++ b/test/function/samples/escape-arguments/_config.js @@ -0,0 +1,8 @@ +const assert = require('node:assert'); + +module.exports = defineTest({ + description: 'does not use "arguments" as a placeholder variable for a default export', + exports(exports) { + assert.deepStrictEqual(exports, { foo: { __proto__: null, default: 42 } }); + } +}); diff --git a/test/function/samples/warn-implicit-cjs-auto/main.js b/test/function/samples/escape-arguments/arguments.js similarity index 100% rename from test/function/samples/warn-implicit-cjs-auto/main.js rename to test/function/samples/escape-arguments/arguments.js diff --git a/test/function/samples/escape-arguments/main.js b/test/function/samples/escape-arguments/main.js new file mode 100644 index 00000000000..93a8f661807 --- /dev/null +++ b/test/function/samples/escape-arguments/main.js @@ -0,0 +1 @@ +export * as foo from './arguments.js'; diff --git a/test/function/samples/export-all-from-external/_config.js b/test/function/samples/export-all-from-external/_config.js index 86240a5d4cb..20a52edb094 100644 --- a/test/function/samples/export-all-from-external/_config.js +++ b/test/function/samples/export-all-from-external/_config.js @@ -1,6 +1,6 @@ -module.exports = { +module.exports = defineTest({ description: 'allows `export *` from external module, internally', options: { external: ['path'] } -}; +}); diff --git a/test/function/samples/export-all-multiple/_config.js b/test/function/samples/export-all-multiple/_config.js index 409610baa79..8fac9a0598d 100644 --- a/test/function/samples/export-all-multiple/_config.js +++ b/test/function/samples/export-all-multiple/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'allows multiple export * statements' -}; +}); diff --git a/test/function/samples/export-all/_config.js b/test/function/samples/export-all/_config.js index 806031691fa..8afb75446b8 100644 --- a/test/function/samples/export-all/_config.js +++ b/test/function/samples/export-all/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'allows export *' -}; +}); diff --git a/test/function/samples/export-and-import-reference-share-var/_config.js b/test/function/samples/export-and-import-reference-share-var/_config.js index 5b31232f6f4..f68560540d1 100644 --- a/test/function/samples/export-and-import-reference-share-var/_config.js +++ b/test/function/samples/export-and-import-reference-share-var/_config.js @@ -1,10 +1,10 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'allows export and import reference to share name', exports(exports) { assert.equal(exports.b, 9); } -}; +}); // adapted from es6-module-transpiler diff --git a/test/function/samples/export-as/_config.js b/test/function/samples/export-as/_config.js index ed89b856725..a9bb4b25e06 100644 --- a/test/function/samples/export-as/_config.js +++ b/test/function/samples/export-as/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'allows export { x as y }' -}; +}); diff --git a/test/function/samples/export-deconflicted-names/_config.js b/test/function/samples/export-deconflicted-names/_config.js index 073ec44cd81..00393c19e77 100644 --- a/test/function/samples/export-deconflicted-names/_config.js +++ b/test/function/samples/export-deconflicted-names/_config.js @@ -1,8 +1,8 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'correctly exports deconflicted names', exports(exports) { assert.equal(exports.bar(), 'bar'); } -}; +}); diff --git a/test/function/samples/export-default-anonymous-function/_config.js b/test/function/samples/export-default-anonymous-function/_config.js index 7bd66366301..a01760d97b0 100644 --- a/test/function/samples/export-default-anonymous-function/_config.js +++ b/test/function/samples/export-default-anonymous-function/_config.js @@ -1,18 +1,18 @@ -const fs = require('fs'); -const path = require('path'); +const { readFileSync } = require('node:fs'); +const path = require('node:path'); -module.exports = { +module.exports = defineTest({ description: 'exports an anonymous function with custom ID resolver', // yeah, this is a real edge case options: { plugins: [ { - resolveId(importee, importer) { + resolveId(importee) { return path.basename(importee).replace(/\..+/, ''); }, load(id) { - return fs.readFileSync(path.join(__dirname, id + '.js'), 'utf-8'); + return readFileSync(path.join(__dirname, id + '.js'), 'utf8'); } } ] } -}; +}); diff --git a/test/function/samples/export-default-as-b/_config.js b/test/function/samples/export-default-as-b/_config.js index dc8136824ce..9755f45e3c8 100644 --- a/test/function/samples/export-default-as-b/_config.js +++ b/test/function/samples/export-default-as-b/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'exports default-as-named from sibling module (b)' -}; +}); diff --git a/test/function/samples/export-default-as-c/_config.js b/test/function/samples/export-default-as-c/_config.js index 7f130fdafba..941a5f01610 100644 --- a/test/function/samples/export-default-as-c/_config.js +++ b/test/function/samples/export-default-as-c/_config.js @@ -1,8 +1,8 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'exports default-as-named from sibling module (c)', exports(exports) { assert.equal(exports.namespace.baz, 'BAZ'); } -}; +}); diff --git a/test/function/samples/export-default-as/_config.js b/test/function/samples/export-default-as/_config.js index a8be095593a..5ab369b8ed4 100644 --- a/test/function/samples/export-default-as/_config.js +++ b/test/function/samples/export-default-as/_config.js @@ -1,8 +1,8 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'exports default-as-named from sibling module', exports(exports) { assert.equal(exports.foo, 'FOO'); } -}; +}); diff --git a/test/function/samples/export-default-exported-id/_config.js b/test/function/samples/export-default-exported-id/_config.js index 53b6a6360d2..cd35ba842a4 100644 --- a/test/function/samples/export-default-exported-id/_config.js +++ b/test/function/samples/export-default-exported-id/_config.js @@ -1,6 +1,6 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'exports an id that is also a default export', options: { output: { exports: 'named' } @@ -9,4 +9,4 @@ module.exports = { assert.ok(new exports.default().ok); assert.ok(new exports.Image().ok); } -}; +}); diff --git a/test/function/samples/export-default-expression/_config.js b/test/function/samples/export-default-expression/_config.js index 89d8f202906..49325dbe0ed 100644 --- a/test/function/samples/export-default-expression/_config.js +++ b/test/function/samples/export-default-expression/_config.js @@ -1,8 +1,8 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'exports a default value as module.exports', exports(exports) { assert.equal(exports, 42); } -}; +}); diff --git a/test/function/samples/export-default-from-external/_config.js b/test/function/samples/export-default-from-external/_config.js index a4d925a685f..1d539072e3b 100644 --- a/test/function/samples/export-default-from-external/_config.js +++ b/test/function/samples/export-default-from-external/_config.js @@ -1,7 +1,7 @@ -const path = require('path'); -const assert = require('assert'); +const assert = require('node:assert'); +const path = require('node:path'); -module.exports = { +module.exports = defineTest({ description: 'ensures external modules have correct names', options: { external: ['path'] @@ -9,4 +9,4 @@ module.exports = { exports(exports) { assert.equal(exports, path.sep); } -}; +}); diff --git a/test/function/samples/export-default-named-function/_config.js b/test/function/samples/export-default-named-function/_config.js index 4ad4d2e9a28..1cb4ade0599 100644 --- a/test/function/samples/export-default-named-function/_config.js +++ b/test/function/samples/export-default-named-function/_config.js @@ -1,8 +1,8 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'exports a default named function', exports(exports) { assert.equal(exports(), 42); } -}; +}); diff --git a/test/function/samples/export-default-no-space/_config.js b/test/function/samples/export-default-no-space/_config.js index 533fd336251..3cbc2cd9ec9 100644 --- a/test/function/samples/export-default-no-space/_config.js +++ b/test/function/samples/export-default-no-space/_config.js @@ -1,8 +1,8 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'handles default exports with no space before declaration', exports: exports => { assert.deepEqual(exports, {}); } -}; +}); diff --git a/test/function/samples/export-destruction/_config.js b/test/function/samples/export-destruction/_config.js index 470c70dbc9b..67e9ef50538 100644 --- a/test/function/samples/export-destruction/_config.js +++ b/test/function/samples/export-destruction/_config.js @@ -1,6 +1,6 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'handle destruction patterns in export declarations', exports(exports) { @@ -8,4 +8,4 @@ module.exports = { assert.equal(exports.baz, 5); assert.equal(exports.quux, 17); } -}; +}); diff --git a/test/function/samples/export-from-default-renamed/_config.js b/test/function/samples/export-from-default-renamed/_config.js index 2c9c52ad511..248b8bff2c2 100644 --- a/test/function/samples/export-from-default-renamed/_config.js +++ b/test/function/samples/export-from-default-renamed/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'export from works with multiple renamed default exports' -}; +}); diff --git a/test/function/samples/export-from-default/_config.js b/test/function/samples/export-from-default/_config.js index 81d51466e79..1c69852f27c 100644 --- a/test/function/samples/export-from-default/_config.js +++ b/test/function/samples/export-from-default/_config.js @@ -1,5 +1,5 @@ -module.exports = { +module.exports = defineTest({ description: 'export from works with default exports' -}; +}); // test copied from https://github.com/esnext/es6-module-transpiler/tree/master/test/examples/export-from-default diff --git a/test/function/samples/export-from-external/_config.js b/test/function/samples/export-from-external/_config.js index 780aac6e0d9..e389acb7a46 100644 --- a/test/function/samples/export-from-external/_config.js +++ b/test/function/samples/export-from-external/_config.js @@ -1,7 +1,7 @@ -const assert = require('assert'); -const path = require('path'); +const assert = require('node:assert'); +const path = require('node:path'); -module.exports = { +module.exports = defineTest({ description: 'exports directly from an external module', options: { external: ['path'] @@ -9,6 +9,6 @@ module.exports = { exports(exports) { assert.equal(exports.sep, path.sep); } -}; +}); // https://github.com/esperantojs/esperanto/issues/161 diff --git a/test/function/samples/export-from-internal-module/_config.js b/test/function/samples/export-from-internal-module/_config.js index 4de6e932cf3..f9435024a18 100644 --- a/test/function/samples/export-from-internal-module/_config.js +++ b/test/function/samples/export-from-internal-module/_config.js @@ -1,8 +1,8 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'exports from an internal module', exports(exports) { assert.equal(exports.foo, 42); } -}; +}); diff --git a/test/function/samples/export-from-multiple-no-default-conflict/_config.js b/test/function/samples/export-from-multiple-no-default-conflict/_config.js index 10d65d52a4d..a40476decb8 100644 --- a/test/function/samples/export-from-multiple-no-default-conflict/_config.js +++ b/test/function/samples/export-from-multiple-no-default-conflict/_config.js @@ -1,6 +1,6 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'export from does not cause erroneous warning if multiple modules export default', warnings: [], exports: exports => { @@ -9,4 +9,4 @@ module.exports = { bar: 'bar' }); } -}; +}); diff --git a/test/function/samples/export-from-no-local-binding-var/_config.js b/test/function/samples/export-from-no-local-binding-var/_config.js index 6186b69d941..7857a2c5270 100644 --- a/test/function/samples/export-from-no-local-binding-var/_config.js +++ b/test/function/samples/export-from-no-local-binding-var/_config.js @@ -1,8 +1,8 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'export from does not create a local binding', - runtimeError(err) { - assert.ok(/foo is not defined/.test(err.message)); + runtimeError(error) { + assert.ok(/foo is not defined/.test(error.message)); } -}; +}); diff --git a/test/function/samples/export-from-no-local-binding/_config.js b/test/function/samples/export-from-no-local-binding/_config.js index 7500be3ac77..b4d3d6a524b 100644 --- a/test/function/samples/export-from-no-local-binding/_config.js +++ b/test/function/samples/export-from-no-local-binding/_config.js @@ -1,5 +1,5 @@ -module.exports = { +module.exports = defineTest({ description: 'export from does not create a local binding' -}; +}); // test copied from https://github.com/esnext/es6-module-transpiler/tree/master/test/examples/export-from diff --git a/test/function/samples/export-from-renamed/_config.js b/test/function/samples/export-from-renamed/_config.js index 7e88a411cda..e22fd52dff8 100644 --- a/test/function/samples/export-from-renamed/_config.js +++ b/test/function/samples/export-from-renamed/_config.js @@ -1,9 +1,9 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'allows export { x as y } from ...', exports(exports) { assert.equal(exports.y, 42); assert.ok(!('x' in exports)); } -}; +}); diff --git a/test/function/samples/export-from-with-definition-conflict/_config.js b/test/function/samples/export-from-with-definition-conflict/_config.js index 2386f941f9a..64b549c6ad0 100644 --- a/test/function/samples/export-from-with-definition-conflict/_config.js +++ b/test/function/samples/export-from-with-definition-conflict/_config.js @@ -1,12 +1,12 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'ignores conflict between local definitions and export from declaration', exports(exports) { assert.equal(exports.foo, 'a-bar'); assert.equal(exports.bar, 'a-foo'); assert.equal(exports.baz, 'a-baz'); } -}; +}); // https://github.com/rollup/rollup/issues/16 diff --git a/test/function/samples/export-from-with-import-conflict/_config.js b/test/function/samples/export-from-with-import-conflict/_config.js index 3550256be9c..cade051df75 100644 --- a/test/function/samples/export-from-with-import-conflict/_config.js +++ b/test/function/samples/export-from-with-import-conflict/_config.js @@ -1,12 +1,12 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'ignores conflict between import declaration and export from declaration', exports(exports) { assert.equal(exports.foo, 'a-bar'); assert.equal(exports.bar, 'a-foo'); assert.equal(exports.baz, 'a-baz'); } -}; +}); // https://github.com/rollup/rollup/issues/16 diff --git a/test/function/samples/export-global/_config.js b/test/function/samples/export-global/_config.js index 3bf49d21bdd..88af9fd8b68 100644 --- a/test/function/samples/export-global/_config.js +++ b/test/function/samples/export-global/_config.js @@ -1,14 +1,9 @@ -const assert = require('assert'); +const assert = require('node:assert'); -// This used to be "any global variables in scope can be re-exported" -// This, however, is actually not allowed by the spec and acorn, -// see https://github.com/acornjs/acorn/issues/806 -// Consider reverting this change should this become an acorn option - -module.exports = { - description: '"variables corresponding to globals can be exported"', +module.exports = defineTest({ + description: 'variables corresponding to globals can be exported', exports(exports) { assert.equal(exports.Buffer, Buffer); } -}; +}); diff --git a/test/function/samples/export-global/main.js b/test/function/samples/export-global/main.js index aea02862f1f..66c7efc94ee 100644 --- a/test/function/samples/export-global/main.js +++ b/test/function/samples/export-global/main.js @@ -1,2 +1,2 @@ const MyBuffer = Buffer; -export { MyBuffer as Buffer }; +export { MyBuffer as Buffer }; diff --git a/test/function/samples/export-not-at-top-level-fails/_config.js b/test/function/samples/export-not-at-top-level-fails/_config.js index da4885365aa..5b347adf098 100644 --- a/test/function/samples/export-not-at-top-level-fails/_config.js +++ b/test/function/samples/export-not-at-top-level-fails/_config.js @@ -1,32 +1,29 @@ -const path = require('path'); +const path = require('node:path'); +const ID_MAIN = path.join(__dirname, 'main.js'); -module.exports = { +module.exports = defineTest({ description: 'disallows non-top-level exports', error: { - code: 'PARSE_ERROR', - message: `'import' and 'export' may only appear at the top level`, - id: path.join(__dirname, 'main.js'), - parserError: { - loc: { - column: 2, - line: 2 - }, - message: "'import' and 'export' may only appear at the top level (2:2)", + cause: { + code: 'PARSE_ERROR', pos: 19, - raisedAt: 25 + message: "'import', and 'export' cannot be used outside of module code" }, + code: 'PARSE_ERROR', + id: ID_MAIN, pos: 19, - watchFiles: [path.join(__dirname, 'main.js')], loc: { - file: path.join(__dirname, 'main.js'), - line: 2, - column: 2 + column: 2, + file: ID_MAIN, + line: 2 }, frame: ` 1: function foo() { 2: export { foo }; ^ 3: } - ` + `, + watchFiles: [ID_MAIN], + message: "main.js (2:2): 'import', and 'export' cannot be used outside of module code" } -}; +}); diff --git a/test/function/samples/export-two-ways-default-b/_config.js b/test/function/samples/export-two-ways-default-b/_config.js index 95e3fb7ac89..15cadf2373c 100644 --- a/test/function/samples/export-two-ways-default-b/_config.js +++ b/test/function/samples/export-two-ways-default-b/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'side-effects are preserved if subject is exported in multiple ways, even if default export has no direct link to original (#733)' -}; +}); diff --git a/test/function/samples/export-two-ways-default/_config.js b/test/function/samples/export-two-ways-default/_config.js index 88b207f4bca..7633a12e50e 100644 --- a/test/function/samples/export-two-ways-default/_config.js +++ b/test/function/samples/export-two-ways-default/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'side-effects are preserved if subject is exported in multiple ways (#733)' -}; +}); diff --git a/test/function/samples/export-two-ways-function/_config.js b/test/function/samples/export-two-ways-function/_config.js index 47608f3cbb6..3c6145a4791 100644 --- a/test/function/samples/export-two-ways-function/_config.js +++ b/test/function/samples/export-two-ways-function/_config.js @@ -1,9 +1,9 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'exports the same function more than one way (#648)', exports(exports) { assert.equal(exports.foo, exports.bar); assert.equal(exports.foo(), 42); } -}; +}); diff --git a/test/function/samples/export-two-ways/_config.js b/test/function/samples/export-two-ways/_config.js index 7cc77be4926..eea2c7b07c6 100644 --- a/test/function/samples/export-two-ways/_config.js +++ b/test/function/samples/export-two-ways/_config.js @@ -1,10 +1,10 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'exports the same binding more than one way', exports(exports) { assert.equal(exports.a, 2); assert.equal(exports.b, 2); assert.equal(exports.c, 2); } -}; +}); diff --git a/test/function/samples/export-type-mismatch-b/_config.js b/test/function/samples/export-type-mismatch-b/_config.js index 08b7d704027..548ede76828 100644 --- a/test/function/samples/export-type-mismatch-b/_config.js +++ b/test/function/samples/export-type-mismatch-b/_config.js @@ -1,10 +1,10 @@ -module.exports = { +module.exports = defineTest({ description: 'export type must be auto, default, named or none', options: { output: { exports: 'blah' } }, generateError: { code: 'INVALID_EXPORT_OPTION', + url: 'https://rollupjs.org/configuration-options/#output-exports', message: - '"output.exports" must be "default", "named", "none", "auto", or left unspecified (defaults to "auto"), received "blah"', - url: 'https://rollupjs.org/guide/en/#outputexports' + '"output.exports" must be "default", "named", "none", "auto", or left unspecified (defaults to "auto"), received "blah".' } -}; +}); diff --git a/test/function/samples/export-type-mismatch-c/_config.js b/test/function/samples/export-type-mismatch-c/_config.js index 4c19ef8fc39..be7b3966ac7 100644 --- a/test/function/samples/export-type-mismatch-c/_config.js +++ b/test/function/samples/export-type-mismatch-c/_config.js @@ -1,9 +1,10 @@ -module.exports = { +module.exports = defineTest({ description: 'cannot have named exports if explicit export type is default', options: { output: { exports: 'none' } }, generateError: { code: 'INVALID_EXPORT_OPTION', message: - '"none" was specified for "output.exports", but entry module "main.js" has the following exports: default' + '"none" was specified for "output.exports", but entry module "main.js" has the following exports: "default"', + url: 'https://rollupjs.org/configuration-options/#output-exports' } -}; +}); diff --git a/test/function/samples/export-type-mismatch/_config.js b/test/function/samples/export-type-mismatch/_config.js index 1020793bb76..ff7f55fb83b 100644 --- a/test/function/samples/export-type-mismatch/_config.js +++ b/test/function/samples/export-type-mismatch/_config.js @@ -1,9 +1,10 @@ -module.exports = { +module.exports = defineTest({ description: 'cannot have named exports if explicit export type is default', options: { output: { exports: 'default' } }, generateError: { code: 'INVALID_EXPORT_OPTION', message: - '"default" was specified for "output.exports", but entry module "main.js" has the following exports: foo' + '"default" was specified for "output.exports", but entry module "main.js" has the following exports: "foo"', + url: 'https://rollupjs.org/configuration-options/#output-exports' } -}; +}); diff --git a/test/function/samples/exports-are-not-defined/_config.js b/test/function/samples/exports-are-not-defined/_config.js new file mode 100644 index 00000000000..badca760003 --- /dev/null +++ b/test/function/samples/exports-are-not-defined/_config.js @@ -0,0 +1,30 @@ +const path = require('node:path'); + +const ID_MAIN = path.join(__dirname, 'main.js'); +const ID_MODULE = path.join(__dirname, 'module.js'); + +module.exports = defineTest({ + description: 'Throw descriptive error message for used export is not defined', + error: { + binding: 'foo', + code: 'MISSING_EXPORT', + exporter: ID_MODULE, + id: ID_MAIN, + url: 'https://rollupjs.org/troubleshooting/#error-name-is-not-exported-by-module', + pos: 9, + loc: { + column: 9, + file: ID_MAIN, + line: 1 + }, + frame: ` +1: import { foo } from './module'; + ^ +2: console.log(foo); + `, + watchFiles: [ID_MAIN, ID_MODULE], + message: + 'main.js (1:9): Exported variable "foo" is not defined in "module.js", but it is imported by "main.js".' + }, + verifyAst: false +}); diff --git a/test/function/samples/exports-are-not-defined/main.js b/test/function/samples/exports-are-not-defined/main.js new file mode 100644 index 00000000000..b779e09ede3 --- /dev/null +++ b/test/function/samples/exports-are-not-defined/main.js @@ -0,0 +1,2 @@ +import { foo } from './module'; +console.log(foo); diff --git a/test/function/samples/exports-are-not-defined/module.js b/test/function/samples/exports-are-not-defined/module.js new file mode 100644 index 00000000000..f40ac5c3434 --- /dev/null +++ b/test/function/samples/exports-are-not-defined/module.js @@ -0,0 +1 @@ +export { foo }; diff --git a/test/function/samples/exports-flag-allowed-in-options/_config.js b/test/function/samples/exports-flag-allowed-in-options/_config.js index 7a6b504df9f..4ec097478a8 100644 --- a/test/function/samples/exports-flag-allowed-in-options/_config.js +++ b/test/function/samples/exports-flag-allowed-in-options/_config.js @@ -1,6 +1,6 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'exports flag is passed through to bundle options', options: { output: { exports: 'named' } @@ -9,4 +9,4 @@ module.exports = { assert.equal(exports.y, 42); assert.ok(!('x' in exports)); } -}; +}); diff --git a/test/function/samples/exports-named-values/_config.js b/test/function/samples/exports-named-values/_config.js index 3558e3b9793..c14ac2da2a4 100644 --- a/test/function/samples/exports-named-values/_config.js +++ b/test/function/samples/exports-named-values/_config.js @@ -1,8 +1,8 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'exports named values from the bundle entry module', exports(exports) { assert.equal(exports.answer, 42); } -}; +}); diff --git a/test/function/samples/external-alias-parent/_config.js b/test/function/samples/external-alias-parent/_config.js index 9bb827ce7bf..00ce290e63c 100644 --- a/test/function/samples/external-alias-parent/_config.js +++ b/test/function/samples/external-alias-parent/_config.js @@ -1,17 +1,13 @@ -const assert = require('assert'); -const path = require('path'); +const assert = require('node:assert'); +const path = require('node:path'); -module.exports = { +module.exports = defineTest({ description: 'includes an external module included dynamically by an alias', options: { input: path.join(__dirname, 'first', 'main.js'), external(id, parentId, isResolved) { if (isResolved === false || !parentId) return false; - if (parentId.endsWith('main.js')) { - return id === 'lodash'; - } else { - return id === 'underscore'; - } + return parentId.endsWith('main.js') ? id === 'lodash' : id === 'underscore'; }, // Define a simple alias plugin for underscore @@ -32,4 +28,4 @@ module.exports = { return 1; } } -}; +}); diff --git a/test/function/samples/external-alias/_config.js b/test/function/samples/external-alias/_config.js index cd4f7af1d74..179e6d925d8 100644 --- a/test/function/samples/external-alias/_config.js +++ b/test/function/samples/external-alias/_config.js @@ -1,7 +1,7 @@ -const assert = require('assert'); -const path = require('path'); +const assert = require('node:assert'); +const path = require('node:path'); -module.exports = { +module.exports = defineTest({ description: 'includes an external module included dynamically by an alias', options: { input: path.join(__dirname, 'first', 'main.js'), @@ -25,4 +25,4 @@ module.exports = { return 1; } } -}; +}); diff --git a/test/function/samples/external-conflict/_config.js b/test/function/samples/external-conflict/_config.js index bab7fcc4fad..47837de3208 100644 --- a/test/function/samples/external-conflict/_config.js +++ b/test/function/samples/external-conflict/_config.js @@ -1,12 +1,13 @@ -const path = require('path'); +const path = require('node:path'); +const ID_MAIN = path.join(__dirname, 'main.js'); -module.exports = { +module.exports = defineTest({ description: 'external paths from custom resolver remain external (#633)', options: { external: (_id, parent) => parent === 'dep', plugins: [ { - resolveId(id, parent) { + resolveId(id) { if (id === 'dep') return id; }, load(id) { @@ -17,8 +18,8 @@ module.exports = { }, error: { code: 'INVALID_EXTERNAL_ID', + watchFiles: [ID_MAIN], message: - "'dep' is imported as an external by dep, but is already an existing non-external module id.", - watchFiles: [path.join(__dirname, 'main.js'), 'dep'] + '"dep" is imported as an external by "dep", but is already an existing non-external module id.' } -}; +}); diff --git a/test/function/samples/external-directory-import/_config.js b/test/function/samples/external-directory-import/_config.js new file mode 100644 index 00000000000..ca23b880156 --- /dev/null +++ b/test/function/samples/external-directory-import/_config.js @@ -0,0 +1,11 @@ +module.exports = defineTest({ + description: 'handles using ../ as external import (#4349)', + options: { + external() { + return true; + } + }, + context: { + require: id => id + } +}); diff --git a/test/function/samples/external-directory-import/main.js b/test/function/samples/external-directory-import/main.js new file mode 100644 index 00000000000..c4ada305c23 --- /dev/null +++ b/test/function/samples/external-directory-import/main.js @@ -0,0 +1,13 @@ +import foo1 from './'; +import foo2 from '../'; +import foo3 from '.'; +import foo4 from '..'; +import foo5 from './index.js'; +import foo6 from '../index.js'; + +assert.strictEqual(foo1, '.'); +assert.strictEqual(foo2, '..'); +assert.strictEqual(foo3, '.'); +assert.strictEqual(foo4, '..'); +assert.strictEqual(foo5, './index.js'); +assert.strictEqual(foo6, '../index.js'); diff --git a/test/function/samples/external-dynamic-import-live-binding-compact/_config.js b/test/function/samples/external-dynamic-import-live-binding-compact/_config.js index abe387790e3..9601e9279e4 100644 --- a/test/function/samples/external-dynamic-import-live-binding-compact/_config.js +++ b/test/function/samples/external-dynamic-import-live-binding-compact/_config.js @@ -1,22 +1,26 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'supports external dynamic imports with live bindings in compact mode', options: { - external(id) { + external() { return true; }, output: { - compact: true + compact: true, + interop: 'auto', + dynamicImportInCjs: false } }, context: { require(id) { switch (id) { - case 'dep-0': - return undefined; - case 'dep-1': + case 'dep-0': { + return; + } + case 'dep-1': { return () => 42; + } case 'dep-2': { const exp = { value: 1, @@ -43,8 +47,9 @@ module.exports = { }; return exp; } - default: + default: { throw new Error(`Unexpected id ${id}.`); + } } } }, @@ -70,4 +75,4 @@ module.exports = { assert.strictEqual(results[3].default.otherValue, 4); }); } -}; +}); diff --git a/test/function/samples/external-dynamic-import-live-binding/_config.js b/test/function/samples/external-dynamic-import-live-binding/_config.js index ab38f8e6614..8c77233964c 100644 --- a/test/function/samples/external-dynamic-import-live-binding/_config.js +++ b/test/function/samples/external-dynamic-import-live-binding/_config.js @@ -1,19 +1,22 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'supports external dynamic imports with live bindings', options: { - external(id) { + external() { return true; - } + }, + output: { interop: 'auto', dynamicImportInCjs: false } }, context: { require(id) { switch (id) { - case 'dep-0': - return undefined; - case 'dep-1': + case 'dep-0': { + return; + } + case 'dep-1': { return () => 42; + } case 'dep-2': { const exp = { value: 1, @@ -40,8 +43,9 @@ module.exports = { }; return exp; } - default: + default: { throw new Error(`Unexpected id ${id}.`); + } } } }, @@ -67,4 +71,4 @@ module.exports = { assert.strictEqual(results[3].default.otherValue, 4); }); } -}; +}); diff --git a/test/function/samples/external-entry-point-object/_config.js b/test/function/samples/external-entry-point-object/_config.js index 5f27f7b99ac..d406ffa25d0 100644 --- a/test/function/samples/external-entry-point-object/_config.js +++ b/test/function/samples/external-entry-point-object/_config.js @@ -1,14 +1,16 @@ -module.exports = { +module.exports = defineTest({ description: 'throws for entry points that are resolved as an external object by plugins', options: { - plugins: { - resolveId(id) { - return { id, external: true }; + plugins: [ + { + resolveId(id) { + return { id, external: true }; + } } - } + ] }, error: { code: 'UNRESOLVED_ENTRY', - message: `Entry module cannot be external (main.js).` + message: 'Entry module "main.js" cannot be external.' } -}; +}); diff --git a/test/function/samples/external-entry-point/_config.js b/test/function/samples/external-entry-point/_config.js index ce44d387343..e4aabd39e6e 100644 --- a/test/function/samples/external-entry-point/_config.js +++ b/test/function/samples/external-entry-point/_config.js @@ -1,14 +1,16 @@ -module.exports = { +module.exports = defineTest({ description: 'throws for entry points that are resolved as false by plugins', options: { - plugins: { - resolveId() { - return false; + plugins: [ + { + resolveId() { + return false; + } } - } + ] }, error: { code: 'UNRESOLVED_ENTRY', - message: `Entry module cannot be external (main.js).` + message: 'Entry module "main.js" cannot be external.' } -}; +}); diff --git a/test/function/samples/external-function-always-true/_config.js b/test/function/samples/external-function-always-true/_config.js index 36c5a9373b5..4cf8147cb3d 100644 --- a/test/function/samples/external-function-always-true/_config.js +++ b/test/function/samples/external-function-always-true/_config.js @@ -1,10 +1,9 @@ -module.exports = { +module.exports = defineTest({ description: 'Does not call external for entry point', options: { - external (id, parentId, isResolved) { - if (!parentId) - throw new Error('Should not call external for entry point.'); + external(id, parentId) { + if (!parentId) throw new Error('Should not call external for entry point.'); return true; } } -}; +}); diff --git a/test/function/samples/external-function/_config.js b/test/function/samples/external-function/_config.js index cabe004fca3..b795ca84f90 100644 --- a/test/function/samples/external-function/_config.js +++ b/test/function/samples/external-function/_config.js @@ -1,9 +1,7 @@ -module.exports = { +module.exports = defineTest({ description: 'allows external option to be a function (#522)', options: { - external: id => { - return id === 'external'; - } + external: id => id === 'external' }, context: { require: id => { @@ -11,4 +9,4 @@ module.exports = { return require(id); } } -}; +}); diff --git a/test/function/samples/external-ids-not-resolved/_config.js b/test/function/samples/external-ids-not-resolved/_config.js index 10982d1af3e..aa1c6979162 100644 --- a/test/function/samples/external-ids-not-resolved/_config.js +++ b/test/function/samples/external-ids-not-resolved/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'does not attempt to resolve external IDs', options: { external: ['external'], @@ -12,4 +12,4 @@ module.exports = { } ] } -}; +}); diff --git a/test/function/samples/external-ignore-reserved-null-marker/_config.js b/test/function/samples/external-ignore-reserved-null-marker/_config.js index 9e26e3b97b7..cb3a6be7bcb 100644 --- a/test/function/samples/external-ignore-reserved-null-marker/_config.js +++ b/test/function/samples/external-ignore-reserved-null-marker/_config.js @@ -1,9 +1,9 @@ -module.exports = { +module.exports = defineTest({ description: 'external function ignores \\0 started ids', options: { external(id) { - if (id.startsWith('\0')) { - throw Error('\\0 started ids should not be tested as external'); + if (id[0] === '\0') { + throw new Error('\\0 started ids should not be tested as external'); } return true; }, @@ -26,4 +26,4 @@ module.exports = { } ] } -}; +}); diff --git a/test/function/samples/external-live-binding-compact/_config.js b/test/function/samples/external-live-binding-compact/_config.js index 6d373075d51..f2f087dc7bb 100644 --- a/test/function/samples/external-live-binding-compact/_config.js +++ b/test/function/samples/external-live-binding-compact/_config.js @@ -1,6 +1,6 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'handles external live-bindings', options: { external: ['named', 'star'], @@ -42,4 +42,4 @@ module.exports = { exports.incrementStar(); assert.equal(exports.star, 1, 'star'); } -}; +}); diff --git a/test/function/samples/external-live-binding/_config.js b/test/function/samples/external-live-binding/_config.js index 55c033a38ed..fdfbcd3d435 100644 --- a/test/function/samples/external-live-binding/_config.js +++ b/test/function/samples/external-live-binding/_config.js @@ -1,13 +1,14 @@ -const assert = require('assert'); +const assert = require('node:assert'); let named; let star; let defaulted; -module.exports = { +module.exports = defineTest({ description: 'handles external live-bindings', options: { - external: ['named', 'star', 'defaulted'] + external: ['named', 'star', 'defaulted'], + output: { interop: 'compat' } }, context: { require(id) { @@ -56,4 +57,4 @@ module.exports = { // make sure the default is not reexported assert.equal(exports.default, undefined); } -}; +}); diff --git a/test/function/samples/external-namespace-and-default-reexport-compat/_config.js b/test/function/samples/external-namespace-and-default-reexport-compat/_config.js new file mode 100644 index 00000000000..60e4d4f233b --- /dev/null +++ b/test/function/samples/external-namespace-and-default-reexport-compat/_config.js @@ -0,0 +1,27 @@ +const assert = require('node:assert'); + +module.exports = defineTest({ + description: 'reexports both a namespace and the default export when using compat interop', + options: { + external: true, + output: { exports: 'named', interop: 'compat' } + }, + context: { + require: id => { + if (id === 'external') { + return { + __esModule: true, + default: 'default', + foo: 'foo' + }; + } + throw new Error(`Cannot find module ${id}`); + } + }, + exports(exports) { + assert.deepStrictEqual(exports, { + default: 'default', + foo: 'foo' + }); + } +}); diff --git a/test/function/samples/external-namespace-and-default-reexport-compat/main.js b/test/function/samples/external-namespace-and-default-reexport-compat/main.js new file mode 100644 index 00000000000..aa701236c18 --- /dev/null +++ b/test/function/samples/external-namespace-and-default-reexport-compat/main.js @@ -0,0 +1,2 @@ +export * from "external"; +export { default } from "external"; diff --git a/test/function/samples/external-namespace-and-default-reexport-compat2/_config.js b/test/function/samples/external-namespace-and-default-reexport-compat2/_config.js new file mode 100644 index 00000000000..a22b8c49e82 --- /dev/null +++ b/test/function/samples/external-namespace-and-default-reexport-compat2/_config.js @@ -0,0 +1,33 @@ +const assert = require('node:assert'); + +module.exports = defineTest({ + description: + 'reexports both a namespace, the namespace as a name and the default export when using compat interop', + options: { + external: true, + output: { exports: 'named', interop: 'compat' } + }, + context: { + require: id => { + if (id === 'external') { + return { + __esModule: true, + default: 'default', + foo: 'foo' + }; + } + throw new Error(`Cannot find module ${id}`); + } + }, + exports(exports) { + assert.deepStrictEqual(exports, { + default: 'default', + foo: 'foo', + external: { + __esModule: true, + default: 'default', + foo: 'foo' + } + }); + } +}); diff --git a/test/function/samples/external-namespace-and-default-reexport-compat2/main.js b/test/function/samples/external-namespace-and-default-reexport-compat2/main.js new file mode 100644 index 00000000000..af1dccc7445 --- /dev/null +++ b/test/function/samples/external-namespace-and-default-reexport-compat2/main.js @@ -0,0 +1,3 @@ +export * from "external"; +export * as external from 'external'; +export { default } from "external"; diff --git a/test/function/samples/external-namespace-and-default-reexport-compat3/_config.js b/test/function/samples/external-namespace-and-default-reexport-compat3/_config.js new file mode 100644 index 00000000000..99012e4861f --- /dev/null +++ b/test/function/samples/external-namespace-and-default-reexport-compat3/_config.js @@ -0,0 +1,34 @@ +const assert = require('node:assert'); + +module.exports = defineTest({ + description: 'reexports both a namespace and the default export when using compat interop', + options: { + external: true, + output: { exports: 'named', interop: 'compat' } + }, + context: { + require: id => { + if (id === 'external') { + return { + __esModule: true, + default: 'default', + foo: 'foo' + }; + } + throw new Error(`Cannot find module ${id}`); + } + }, + exports(exports) { + assert.deepStrictEqual(exports, { + default: 'default', + foo: 'foo', + wrappedExternal: { + external: { + __esModule: true, + default: 'default', + foo: 'foo' + } + } + }); + } +}); diff --git a/test/function/samples/external-namespace-and-default-reexport-compat3/main.js b/test/function/samples/external-namespace-and-default-reexport-compat3/main.js new file mode 100644 index 00000000000..af3044e19ab --- /dev/null +++ b/test/function/samples/external-namespace-and-default-reexport-compat3/main.js @@ -0,0 +1,5 @@ +export * from 'external'; +import * as external from "external"; + +export const wrappedExternal = { external }; +export { default } from 'external'; diff --git a/test/function/samples/external-normalization/_config.js b/test/function/samples/external-normalization/_config.js index 21aa974b0ae..94f4a0674bf 100644 --- a/test/function/samples/external-normalization/_config.js +++ b/test/function/samples/external-normalization/_config.js @@ -1,7 +1,7 @@ -const path = require('path'); -const assert = require('assert'); +const assert = require('node:assert'); +const path = require('node:path'); -module.exports = { +module.exports = defineTest({ description: 'external paths from custom resolver remain external (#633)', options: { external: ['path'], @@ -17,4 +17,4 @@ module.exports = { exports: exports => { assert.equal(exports, path.resolve); } -}; +}); diff --git a/test/function/samples/external-regex-array/_config.js b/test/function/samples/external-regex-array/_config.js index 44c7fed70dc..7e4d1e16d6a 100644 --- a/test/function/samples/external-regex-array/_config.js +++ b/test/function/samples/external-regex-array/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'allows external option to be an array of regex and strings', options: { external: [/external/, 'other'] @@ -10,4 +10,4 @@ module.exports = { return require(id); } } -}; +}); diff --git a/test/function/samples/external-regex/_config.js b/test/function/samples/external-regex/_config.js index 6be55508350..8dc20af4a7b 100644 --- a/test/function/samples/external-regex/_config.js +++ b/test/function/samples/external-regex/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'allows external option to be a regex', options: { external: /external/ @@ -9,4 +9,4 @@ module.exports = { return require(id); } } -}; +}); diff --git a/test/function/samples/external-resolve-false/_config.js b/test/function/samples/external-resolve-false/_config.js index c7e236d52e8..51a23830865 100644 --- a/test/function/samples/external-resolve-false/_config.js +++ b/test/function/samples/external-resolve-false/_config.js @@ -1,14 +1,13 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'includes an external module with a false resolve return', options: { input: 'main.js', plugins: [ { resolveId(id) { - if (id === './external') - return false; + if (id === './external') return false; } } ] @@ -19,4 +18,4 @@ module.exports = { return 1; } } -}; +}); diff --git a/test/function/samples/external-resolved/_config.js b/test/function/samples/external-resolved/_config.js index a1d7bc5c266..9a182661983 100644 --- a/test/function/samples/external-resolved/_config.js +++ b/test/function/samples/external-resolved/_config.js @@ -1,8 +1,8 @@ -const assert = require('assert'); +const assert = require('node:assert'); const testedIds = []; -module.exports = { +module.exports = defineTest({ description: 'passes both unresolved and resolved ids to the external option', context: { require() { @@ -30,22 +30,29 @@ module.exports = { testedIds.push(id); return id.startsWith('resolved'); }, - plugins: { - name: 'test-plugin', - resolveId(source) { - switch (source) { - case 'resolve-string': - return 'resolved-string'; - case 'resolve-external': - return false; - case 'resolve-object': - return { id: 'resolved-object', external: false }; - case 'resolve-object-external': - return { id: 'resolved-object-external', external: true }; - default: - return null; + plugins: [ + { + name: 'test-plugin', + resolveId(source) { + switch (source) { + case 'resolve-string': { + return 'resolved-string'; + } + case 'resolve-external': { + return false; + } + case 'resolve-object': { + return { id: 'resolved-object', external: false }; + } + case 'resolve-object-external': { + return { id: 'resolved-object-external', external: true }; + } + default: { + return null; + } + } } } - } + ] } -}; +}); diff --git a/test/function/samples/externally-reassigned-default-exports/_config.js b/test/function/samples/externally-reassigned-default-exports/_config.js index d2af24f4b1d..e360e0e8bfc 100644 --- a/test/function/samples/externally-reassigned-default-exports/_config.js +++ b/test/function/samples/externally-reassigned-default-exports/_config.js @@ -1,13 +1,13 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'calls to externally reassigned methods of default exports must be retained', exports(exports) { let triggered = false; - exports.reassigned = function() { + exports.reassigned = function () { triggered = true; }; exports.test(); assert.ok(triggered); } -}; +}); diff --git a/test/function/samples/externally-reassigned-globals/_config.js b/test/function/samples/externally-reassigned-globals/_config.js index aadf61f0726..387c8ed9793 100644 --- a/test/function/samples/externally-reassigned-globals/_config.js +++ b/test/function/samples/externally-reassigned-globals/_config.js @@ -1,16 +1,15 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'calls to externally reassigned global methods must be retained', exports(exports) { let triggered1 = false; - let triggered2 = false; - global.obj1.reassigned = function() { + global.obj1.reassigned = function () { triggered1 = true; }; - global.obj2.reassigned = function() { + global.obj2.reassigned = function () { triggered2 = true; }; @@ -21,4 +20,4 @@ module.exports = { assert.ok(triggered1); assert.ok(triggered2); } -}; +}); diff --git a/test/function/samples/externally-reassigned-named-exports/_config.js b/test/function/samples/externally-reassigned-named-exports/_config.js index ecf6950b996..1ee23f4b552 100644 --- a/test/function/samples/externally-reassigned-named-exports/_config.js +++ b/test/function/samples/externally-reassigned-named-exports/_config.js @@ -1,20 +1,19 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'calls to externally reassigned methods of named exports must be retained', exports(exports) { let triggered1 = false; - let triggered2 = false; - exports.obj1.reassigned = function() { + exports.obj1.reassigned = function () { triggered1 = true; }; - exports.obj2.reassigned = function() { + exports.obj2.reassigned = function () { triggered2 = true; }; exports.test(); assert.ok(triggered1); assert.ok(triggered2); } -}; +}); diff --git a/test/function/samples/externally-reassigned-named-reexports/_config.js b/test/function/samples/externally-reassigned-named-reexports/_config.js index fc9b97b681c..15fab6b87eb 100644 --- a/test/function/samples/externally-reassigned-named-reexports/_config.js +++ b/test/function/samples/externally-reassigned-named-reexports/_config.js @@ -1,13 +1,13 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'calls to externally reassigned methods of named reexports must be retained', exports(exports) { let triggered = false; - exports.obj.reassigned = function() { + exports.obj.reassigned = function () { triggered = true; }; exports.test(); assert.ok(triggered); } -}; +}); diff --git a/test/function/samples/externally-reassigned-star-reexports/_config.js b/test/function/samples/externally-reassigned-star-reexports/_config.js index 883a394adfe..c726c1ae3e4 100644 --- a/test/function/samples/externally-reassigned-star-reexports/_config.js +++ b/test/function/samples/externally-reassigned-star-reexports/_config.js @@ -1,13 +1,13 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'calls to externally reassigned methods of namespace reexports must be retained', exports(exports) { let triggered = false; - exports.obj.reassigned = function() { + exports.obj.reassigned = function () { triggered = true; }; exports.test(); assert.ok(triggered); } -}; +}); diff --git a/test/function/samples/facade-reexports/_config.js b/test/function/samples/facade-reexports/_config.js index d3c1009516f..4144e6becf4 100644 --- a/test/function/samples/facade-reexports/_config.js +++ b/test/function/samples/facade-reexports/_config.js @@ -1,6 +1,6 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'handles reexports when creating a facade chunk and transitive dependencies are not hoisted', options: { @@ -13,4 +13,4 @@ module.exports = { assert.strictEqual(exports.external, true); assert.strictEqual(await exports.dynamic(), 'liblib'); } -}; +}); diff --git a/test/function/samples/fallback-on-warn/_config.js b/test/function/samples/fallback-on-warn/_config.js deleted file mode 100644 index ee7da5de099..00000000000 --- a/test/function/samples/fallback-on-warn/_config.js +++ /dev/null @@ -1,20 +0,0 @@ -const assert = require('assert'); -let oldConsoleWarn; -const warnings = []; - -module.exports = { - description: 'logs as a fallback if no onwarn handler is provided', - options: { - onwarn: null - }, - before() { - oldConsoleWarn = console.warn; - console.warn = msg => warnings.push(msg); - }, - after() { - console.warn = oldConsoleWarn; - assert.deepStrictEqual(warnings, [ - 'Use of eval is strongly discouraged, as it poses security risks and may cause issues with minification' - ]); - } -}; diff --git a/test/function/samples/fallback-on-warn/main.js b/test/function/samples/fallback-on-warn/main.js deleted file mode 100644 index 8972e2933ec..00000000000 --- a/test/function/samples/fallback-on-warn/main.js +++ /dev/null @@ -1 +0,0 @@ -export const x = eval('42'); diff --git a/test/function/samples/file-and-dir/_config.js b/test/function/samples/file-and-dir/_config.js index 5a777946e19..80213977ca9 100644 --- a/test/function/samples/file-and-dir/_config.js +++ b/test/function/samples/file-and-dir/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'throws when using both the file and the dir option', options: { output: { file: 'bundle.js', dir: 'dist' } @@ -6,6 +6,7 @@ module.exports = { generateError: { code: 'INVALID_OPTION', message: - 'You must set either "output.file" for a single-file build or "output.dir" when generating multiple chunks.' + 'Invalid value for option "output.dir" - you must set either "output.file" for a single-file build or "output.dir" when generating multiple chunks.', + url: 'https://rollupjs.org/configuration-options/#output-dir' } -}; +}); diff --git a/test/function/samples/for-in-accessors/_config.js b/test/function/samples/for-in-accessors/_config.js new file mode 100644 index 00000000000..74c22c4655b --- /dev/null +++ b/test/function/samples/for-in-accessors/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'deoptimizes "this" for accessors triggered by for-in loops' +}); diff --git a/test/function/samples/for-in-accessors/main.js b/test/function/samples/for-in-accessors/main.js new file mode 100644 index 00000000000..e5194d0d9ee --- /dev/null +++ b/test/function/samples/for-in-accessors/main.js @@ -0,0 +1,10 @@ +const obj = { + setter: false, + set foo(value) { + this.setter = true; + } +}; + +for (obj.foo in {x:1}); + +assert.ok(obj.setter ? true : false); diff --git a/test/function/samples/for-in-loop-head-dependencies/_config.js b/test/function/samples/for-in-loop-head-dependencies/_config.js index cb555be06af..98cc663fd7d 100644 --- a/test/function/samples/for-in-loop-head-dependencies/_config.js +++ b/test/function/samples/for-in-loop-head-dependencies/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'uses parent scope for right-hand-side in for-in statement (#1480)' -}; +}); diff --git a/test/function/samples/for-loop-head-dependencies/_config.js b/test/function/samples/for-loop-head-dependencies/_config.js index cdd3321626f..b215e966462 100644 --- a/test/function/samples/for-loop-head-dependencies/_config.js +++ b/test/function/samples/for-loop-head-dependencies/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'uses correct scope in for statement (#1538)' -}; +}); diff --git a/test/function/samples/for-loop-parameter/_config.js b/test/function/samples/for-loop-parameter/_config.js new file mode 100644 index 00000000000..5b608c21d64 --- /dev/null +++ b/test/function/samples/for-loop-parameter/_config.js @@ -0,0 +1,9 @@ +const assert = require('node:assert'); + +module.exports = defineTest({ + description: 'includes for-loop parameters', + exports({ checkObject, checkArray }) { + assert.strictEqual(checkObject({ foo: 1 }), 1, 'object'); + assert.strictEqual(checkArray([2]), 2, 'array'); + } +}); diff --git a/test/function/samples/for-loop-parameter/main.js b/test/function/samples/for-loop-parameter/main.js new file mode 100644 index 00000000000..c49d4c37c59 --- /dev/null +++ b/test/function/samples/for-loop-parameter/main.js @@ -0,0 +1,19 @@ +export function checkObject(p) { + return getFromObjectInLoop(p); +} + +export function checkArray(p) { + return getFromArrayInLoop(p); +} + +function getFromObjectInLoop(path) { + for (let { foo } = path;;) { + return foo; + } +} + +function getFromArrayInLoop(path) { + for (let [ foo ] = path;;) { + return foo; + } +} \ No newline at end of file diff --git a/test/function/samples/for-loops-as-assignments/_config.js b/test/function/samples/for-loops-as-assignments/_config.js index 4ba53db414c..1b166fb4b5d 100644 --- a/test/function/samples/for-loops-as-assignments/_config.js +++ b/test/function/samples/for-loops-as-assignments/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'make sure for loops are counted as variable assignments (#2199)' -}; +}); diff --git a/test/function/samples/for-of-accessors/_config.js b/test/function/samples/for-of-accessors/_config.js new file mode 100644 index 00000000000..768c251a6c8 --- /dev/null +++ b/test/function/samples/for-of-accessors/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'deoptimizes "this" for accessors triggered by for-of loops' +}); diff --git a/test/function/samples/for-of-accessors/main.js b/test/function/samples/for-of-accessors/main.js new file mode 100644 index 00000000000..b47bc702e82 --- /dev/null +++ b/test/function/samples/for-of-accessors/main.js @@ -0,0 +1,10 @@ +const obj = { + setter: false, + set foo(value) { + this.setter = true; + } +}; + +for (obj.foo of [1]); + +assert.ok(obj.setter ? true : false); diff --git a/test/function/samples/for-of-loop-head-dependencies/_config.js b/test/function/samples/for-of-loop-head-dependencies/_config.js index 24bba078afc..10a5199dde4 100644 --- a/test/function/samples/for-of-loop-head-dependencies/_config.js +++ b/test/function/samples/for-of-loop-head-dependencies/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'uses parent scope for right-hand-side in for-of statement (#1539)' -}; +}); diff --git a/test/function/samples/for-of-with-in-operator/_config.js b/test/function/samples/for-of-with-in-operator/_config.js index 721aac80114..cde77532f9c 100644 --- a/test/function/samples/for-of-with-in-operator/_config.js +++ b/test/function/samples/for-of-with-in-operator/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'handles using the in operator in the iterator of a for-of loop (#2337)' -}; +}); diff --git a/test/function/samples/function-asm-directive/_config.js b/test/function/samples/function-asm-directive/_config.js index 356737e70c8..b1180a59f11 100644 --- a/test/function/samples/function-asm-directive/_config.js +++ b/test/function/samples/function-asm-directive/_config.js @@ -1,8 +1,8 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: "shouldn't delete use asm from the start of a function body", code(code) { assert.notEqual(code.indexOf('use asm'), -1); } -}; +}); diff --git a/test/function/samples/function-asm-directive/main.js b/test/function/samples/function-asm-directive/main.js index 48744f957f1..252fa6ccb54 100644 --- a/test/function/samples/function-asm-directive/main.js +++ b/test/function/samples/function-asm-directive/main.js @@ -2,4 +2,4 @@ export function a() { "use asm"; return 1; -} \ No newline at end of file +} diff --git a/test/function/samples/function-directive-not-first/_config.js b/test/function/samples/function-directive-not-first/_config.js index 40d9e5d0ae5..7a4a593c3c9 100644 --- a/test/function/samples/function-directive-not-first/_config.js +++ b/test/function/samples/function-directive-not-first/_config.js @@ -1,8 +1,8 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'should delete use asm from function body if it is not the first expression', code(code) { - assert.equal(code.indexOf('use asm'), -1); + assert.ok(!code.includes('use asm')); } -}; +}); diff --git a/test/function/samples/function-directive-not-first/main.js b/test/function/samples/function-directive-not-first/main.js index 55e83d93239..b376307541b 100644 --- a/test/function/samples/function-directive-not-first/main.js +++ b/test/function/samples/function-directive-not-first/main.js @@ -2,4 +2,4 @@ export function a() { const x = 1; "use asm"; return x; -} \ No newline at end of file +} diff --git a/test/function/samples/function-expressions-simplified-to-statement/_config.js b/test/function/samples/function-expressions-simplified-to-statement/_config.js index 2a43659a713..46403b4721d 100644 --- a/test/function/samples/function-expressions-simplified-to-statement/_config.js +++ b/test/function/samples/function-expressions-simplified-to-statement/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'correctly handles function expressions which are simplified to statements' -}; +}); diff --git a/test/function/samples/function-expressions-simplified-to-statement/main.js b/test/function/samples/function-expressions-simplified-to-statement/main.js index f5f4e72e1a7..b1eb76e7652 100644 --- a/test/function/samples/function-expressions-simplified-to-statement/main.js +++ b/test/function/samples/function-expressions-simplified-to-statement/main.js @@ -9,17 +9,17 @@ true ? function foo(x){ value = x; }("consequent") : 2; -assert.equal(value, 'consequent'); +assert.strictEqual(value, 'consequent'); foo("incorrect"); -assert.equal(value, 'foo'); +assert.strictEqual(value, 'foo'); false ? null: function foo(x){ value = x; }("alternate"); -assert.equal(value, 'alternate'); +assert.strictEqual(value, 'alternate'); // logical expression function bar(){ @@ -30,17 +30,17 @@ true && function bar(x){ value = x; }("and"); -assert.equal(value, 'and'); +assert.strictEqual(value, 'and'); bar("incorrect"); -assert.equal(value, 'bar'); +assert.strictEqual(value, 'bar'); false || function bar(x){ value = x; }("or"); -assert.equal(value, 'or'); +assert.strictEqual(value, 'or'); // sequence expression function baz(){ @@ -50,9 +50,8 @@ function baz(){ 0, function baz(x){ value = x; }("comma"); - -assert.equal(value, 'comma'); +assert.strictEqual(value, 'comma'); baz("incorrect"); -assert.equal(value, 'baz'); +assert.strictEqual(value, 'baz'); diff --git a/test/function/samples/function-getter-side-effects/_config.js b/test/function/samples/function-getter-side-effects/_config.js new file mode 100644 index 00000000000..54e6d953558 --- /dev/null +++ b/test/function/samples/function-getter-side-effects/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'respects getters created on functions' +}); diff --git a/test/function/samples/function-getter-side-effects/main.js b/test/function/samples/function-getter-side-effects/main.js new file mode 100644 index 00000000000..4fca02d3838 --- /dev/null +++ b/test/function/samples/function-getter-side-effects/main.js @@ -0,0 +1,17 @@ +let funDeclEffect = false; +function funDecl() {} +Object.defineProperty(funDecl, 'foo', { get() { funDeclEffect = true; }}); +funDecl.foo; +assert.ok(funDeclEffect, 'function declaration'); + +let funExpEffect = false; +const funExp = function () {}; +Object.defineProperty(funExp, 'foo', { get() { funExpEffect = true }}); +funExp.foo; +assert.ok(funExpEffect, 'function expression'); + +let arrowEffect = false; +const arrow = function () {}; +Object.defineProperty(arrow, 'foo', { get() { arrowEffect = true }}); +arrow.foo; +assert.ok(arrowEffect, 'arrow function'); diff --git a/test/function/samples/function-side-effects/_config.js b/test/function/samples/function-side-effects/_config.js index cdbb6090e71..5752f688a50 100644 --- a/test/function/samples/function-side-effects/_config.js +++ b/test/function/samples/function-side-effects/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'assumes functions may mutate objects passed in' -}; +}); diff --git a/test/function/samples/function-use-strict-directive-removed/_config.js b/test/function/samples/function-use-strict-directive-removed/_config.js index 7e1a1344ed1..412c158b82f 100644 --- a/test/function/samples/function-use-strict-directive-removed/_config.js +++ b/test/function/samples/function-use-strict-directive-removed/_config.js @@ -1,8 +1,8 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'should delete use strict from function body', code(code) { assert.equal(code.lastIndexOf('use strict'), 1); } -}; +}); diff --git a/test/function/samples/functions-renamed-correctly/_config.js b/test/function/samples/functions-renamed-correctly/_config.js index b0719a05d4e..c9824eb0d8f 100644 --- a/test/function/samples/functions-renamed-correctly/_config.js +++ b/test/function/samples/functions-renamed-correctly/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'renames function expression IDs correctly' -}; +}); diff --git a/test/function/samples/generate-bundle-mutation/_config.js b/test/function/samples/generate-bundle-mutation/_config.js new file mode 100644 index 00000000000..83085e18144 --- /dev/null +++ b/test/function/samples/generate-bundle-mutation/_config.js @@ -0,0 +1,15 @@ +module.exports = defineTest({ + description: 'handles adding or deleting symbols in generateBundle', + options: { + plugins: [ + { + name: 'test', + generateBundle(options, bundle) { + const myKey = Symbol('test'); + bundle[myKey] = 42; + delete bundle[myKey]; + } + } + ] + } +}); diff --git a/test/function/samples/generate-bundle-mutation/main.js b/test/function/samples/generate-bundle-mutation/main.js new file mode 100644 index 00000000000..cc1d88a24fa --- /dev/null +++ b/test/function/samples/generate-bundle-mutation/main.js @@ -0,0 +1 @@ +assert.ok(true); diff --git a/test/function/samples/globally-called-modifying-function/_config.js b/test/function/samples/globally-called-modifying-function/_config.js index 86b2f620dbd..b4b847d500a 100644 --- a/test/function/samples/globally-called-modifying-function/_config.js +++ b/test/function/samples/globally-called-modifying-function/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'globally called function should be included if it modifies an exported value (#112)' -}; +}); diff --git a/test/function/samples/handle-calling-uncallable/_config.js b/test/function/samples/handle-calling-uncallable/_config.js index 74b7d983f48..0f3939a476b 100644 --- a/test/function/samples/handle-calling-uncallable/_config.js +++ b/test/function/samples/handle-calling-uncallable/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'does not give cryptic error when calling uncallable things (#1257)' -}; +}); diff --git a/test/function/samples/handle-labels-inside-functions/_config.js b/test/function/samples/handle-labels-inside-functions/_config.js index ca46e3f11ec..35cd1299978 100644 --- a/test/function/samples/handle-labels-inside-functions/_config.js +++ b/test/function/samples/handle-labels-inside-functions/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'do not fail when using labels inside functions (#1706)' -}; +}); diff --git a/test/function/samples/handle-missing-export-source/_config.js b/test/function/samples/handle-missing-export-source/_config.js index 0488306701a..4e16bba9b5e 100644 --- a/test/function/samples/handle-missing-export-source/_config.js +++ b/test/function/samples/handle-missing-export-source/_config.js @@ -1,15 +1,18 @@ -module.exports = { +module.exports = defineTest({ description: 'does not fail if a pre-generated AST is omitting the source property of an unused named export (#3210)', + verifyAst: false, options: { - plugins: { - transform(code, id) { - if (id.endsWith('foo.js')) { - const ast = this.parse(code); - delete ast.body.find(node => node.type === 'ExportNamedDeclaration').source; - return { code, ast }; + plugins: [ + { + transform(code, id) { + if (id.endsWith('foo.js')) { + const ast = this.parse(code); + delete ast.body.find(node => node.type === 'ExportNamedDeclaration').source; + return { code, ast }; + } } } - } + ] } -}; +}); diff --git a/test/function/samples/handle-object-rest-spread-patterns/_config.js b/test/function/samples/handle-object-rest-spread-patterns/_config.js index 33660506b71..d0f87e8bd68 100644 --- a/test/function/samples/handle-object-rest-spread-patterns/_config.js +++ b/test/function/samples/handle-object-rest-spread-patterns/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'handles properties created by an object rest spread operator' -}; +}); diff --git a/test/function/samples/handle-object-rest-spread-properties/_config.js b/test/function/samples/handle-object-rest-spread-properties/_config.js index 33660506b71..d0f87e8bd68 100644 --- a/test/function/samples/handle-object-rest-spread-properties/_config.js +++ b/test/function/samples/handle-object-rest-spread-properties/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'handles properties created by an object rest spread operator' -}; +}); diff --git a/test/function/samples/handle-object-rest-spread-reassigments/_config.js b/test/function/samples/handle-object-rest-spread-reassigments/_config.js index 33660506b71..d0f87e8bd68 100644 --- a/test/function/samples/handle-object-rest-spread-reassigments/_config.js +++ b/test/function/samples/handle-object-rest-spread-reassigments/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'handles properties created by an object rest spread operator' -}; +}); diff --git a/test/function/samples/handle-statically-resolvable-if-statements/_config.js b/test/function/samples/handle-statically-resolvable-if-statements/_config.js index 52336bdba51..7ea2bbd27be 100644 --- a/test/function/samples/handle-statically-resolvable-if-statements/_config.js +++ b/test/function/samples/handle-statically-resolvable-if-statements/_config.js @@ -1,6 +1,6 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'handles statically resolvable "if" statements (#2134)', context: { value: 1 @@ -8,4 +8,4 @@ module.exports = { exports({ x }) { assert.equal(x, 1); } -}; +}); diff --git a/test/function/samples/handles-double-declarations/_config.js b/test/function/samples/handles-double-declarations/_config.js index bbeffbcd1d1..054fa15679a 100644 --- a/test/function/samples/handles-double-declarations/_config.js +++ b/test/function/samples/handles-double-declarations/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'does not fail for double declarations with initializers from other modules' -}; +}); diff --git a/test/function/samples/handles-empty-string-sourcemap-mappings/_config.js b/test/function/samples/handles-empty-string-sourcemap-mappings/_config.js index 764c77a324a..1e6ea8a6311 100644 --- a/test/function/samples/handles-empty-string-sourcemap-mappings/_config.js +++ b/test/function/samples/handles-empty-string-sourcemap-mappings/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'handles transforms that return sourcemap with empty mappings', options: { @@ -15,4 +15,4 @@ module.exports = { // ensure source maps are generated output: { sourcemap: true } } -}; +}); diff --git a/test/function/samples/handles-stringified-sourcemaps/_config.js b/test/function/samples/handles-stringified-sourcemaps/_config.js index cf7ff1e18c1..b8a91a55b82 100644 --- a/test/function/samples/handles-stringified-sourcemaps/_config.js +++ b/test/function/samples/handles-stringified-sourcemaps/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'handles transforms that return stringified source maps (#377)', options: { @@ -16,4 +16,4 @@ module.exports = { // ensure source maps are generated output: { sourcemap: true } } -}; +}); diff --git a/test/function/samples/has-default-export/_config.js b/test/function/samples/has-default-export/_config.js new file mode 100644 index 00000000000..c90fb861252 --- /dev/null +++ b/test/function/samples/has-default-export/_config.js @@ -0,0 +1,45 @@ +const assert = require('node:assert'); +const path = require('node:path'); + +module.exports = defineTest({ + description: 'reports if a module has a default export', + options: { + plugins: [ + { + async buildStart() { + const ID_MAIN = path.join(__dirname, 'main.js'); + const loadMain = this.load({ id: ID_MAIN }); + assert.strictEqual(this.getModuleInfo(ID_MAIN).hasDefaultExport, null); + assert.strictEqual((await loadMain).hasDefaultExport, false); + + assert.strictEqual( + (await this.load({ id: path.join(__dirname, 'direct.js') })).hasDefaultExport, + true, + 'direct' + ); + assert.strictEqual( + (await this.load({ id: path.join(__dirname, 'indirect.js') })).hasDefaultExport, + true, + 'indirect' + ); + assert.strictEqual( + (await this.load({ id: path.join(__dirname, 'reexport1.js') })).hasDefaultExport, + true, + 'reexport' + ); + assert.strictEqual( + (await this.load({ id: path.join(__dirname, 'reexport2.js') })).hasDefaultExport, + true, + 'renamed reexport' + ); + }, + load(id) { + assert.strictEqual(this.getModuleInfo(id).hasDefaultExport, null, `load ${id}`); + }, + transform(code, id) { + assert.strictEqual(this.getModuleInfo(id).hasDefaultExport, null, `transform ${id}`); + } + } + ] + } +}); diff --git a/test/function/samples/has-default-export/direct.js b/test/function/samples/has-default-export/direct.js new file mode 100644 index 00000000000..f2f6d5c381b --- /dev/null +++ b/test/function/samples/has-default-export/direct.js @@ -0,0 +1 @@ +export default 'direct'; diff --git a/test/function/samples/has-default-export/indirect.js b/test/function/samples/has-default-export/indirect.js new file mode 100644 index 00000000000..28786796a99 --- /dev/null +++ b/test/function/samples/has-default-export/indirect.js @@ -0,0 +1,2 @@ +const indirect = 'indirect'; +export { indirect as default }; diff --git a/test/function/samples/has-default-export/main.js b/test/function/samples/has-default-export/main.js new file mode 100644 index 00000000000..28d6ee09c9c --- /dev/null +++ b/test/function/samples/has-default-export/main.js @@ -0,0 +1,9 @@ +import direct from './direct.js'; +import indirect from './indirect.js'; +import reexport1 from './reexport1.js'; +import reexport2 from './reexport2.js'; + +assert.strictEqual(direct, 'direct'); +assert.strictEqual(indirect, 'indirect'); +assert.strictEqual(reexport1, 'default'); +assert.strictEqual(reexport2, 'foo'); diff --git a/test/function/samples/has-default-export/other.js b/test/function/samples/has-default-export/other.js new file mode 100644 index 00000000000..a99ac05aa02 --- /dev/null +++ b/test/function/samples/has-default-export/other.js @@ -0,0 +1,2 @@ +export default 'default'; +export const foo = 'foo'; diff --git a/test/function/samples/has-default-export/reexport1.js b/test/function/samples/has-default-export/reexport1.js new file mode 100644 index 00000000000..b98cf73cdb9 --- /dev/null +++ b/test/function/samples/has-default-export/reexport1.js @@ -0,0 +1 @@ +export { default } from './other.js'; diff --git a/test/function/samples/has-default-export/reexport2.js b/test/function/samples/has-default-export/reexport2.js new file mode 100644 index 00000000000..08facccd528 --- /dev/null +++ b/test/function/samples/has-default-export/reexport2.js @@ -0,0 +1 @@ +export { foo as default } from './other.js'; diff --git a/test/function/samples/has-modules-array/_config.js b/test/function/samples/has-modules-array/_config.js index d8e11696214..61bd8a5fd1a 100644 --- a/test/function/samples/has-modules-array/_config.js +++ b/test/function/samples/has-modules-array/_config.js @@ -1,7 +1,7 @@ -const path = require('path'); -const assert = require('assert'); +const assert = require('node:assert'); +const path = require('node:path'); -module.exports = { +module.exports = defineTest({ description: 'user-facing bundle has modules array', bundle(bundle) { assert.ok(bundle.cache.modules); @@ -9,4 +9,4 @@ module.exports = { assert.equal(path.relative(bundle.cache.modules[0].id, path.join(__dirname, 'foo.js')), ''); assert.equal(path.relative(bundle.cache.modules[1].id, path.join(__dirname, 'main.js')), ''); } -}; +}); diff --git a/test/function/samples/hashing/length-at-non-hash/_config.js b/test/function/samples/hashing/length-at-non-hash/_config.js new file mode 100644 index 00000000000..2e40dbf8c52 --- /dev/null +++ b/test/function/samples/hashing/length-at-non-hash/_config.js @@ -0,0 +1,8 @@ +module.exports = defineTest({ + description: 'throws when configuring a length for placeholder other than "hash"', + options: { output: { chunkFileNames: '[name:3].js' } }, + generateError: { + code: 'VALIDATION_ERROR', + message: '"[name:3]" is not a valid placeholder in the "output.chunkFileNames" pattern.' + } +}); diff --git a/test/function/samples/hashing/length-at-non-hash/foo.js b/test/function/samples/hashing/length-at-non-hash/foo.js new file mode 100644 index 00000000000..5f26d709a6b --- /dev/null +++ b/test/function/samples/hashing/length-at-non-hash/foo.js @@ -0,0 +1 @@ +throw new Error('should not be executed'); diff --git a/test/function/samples/deprecated/dynamic-import-name/main.js b/test/function/samples/hashing/length-at-non-hash/main.js similarity index 100% rename from test/function/samples/deprecated/dynamic-import-name/main.js rename to test/function/samples/hashing/length-at-non-hash/main.js diff --git a/test/function/samples/hashing/maximum-hash-size/_config.js b/test/function/samples/hashing/maximum-hash-size/_config.js new file mode 100644 index 00000000000..ac8a747c907 --- /dev/null +++ b/test/function/samples/hashing/maximum-hash-size/_config.js @@ -0,0 +1,9 @@ +module.exports = defineTest({ + description: 'throws when the maximum hash size is exceeded', + options: { output: { chunkFileNames: '[hash:22].js' } }, + generateError: { + code: 'VALIDATION_ERROR', + message: + 'Hashes cannot be longer than 21 characters, received 22. Check the "output.chunkFileNames" option.' + } +}); diff --git a/test/function/samples/hashing/maximum-hash-size/foo.js b/test/function/samples/hashing/maximum-hash-size/foo.js new file mode 100644 index 00000000000..5f26d709a6b --- /dev/null +++ b/test/function/samples/hashing/maximum-hash-size/foo.js @@ -0,0 +1 @@ +throw new Error('should not be executed'); diff --git a/test/function/samples/hashing/maximum-hash-size/main.js b/test/function/samples/hashing/maximum-hash-size/main.js new file mode 100644 index 00000000000..bbe4a5cc219 --- /dev/null +++ b/test/function/samples/hashing/maximum-hash-size/main.js @@ -0,0 +1 @@ +import('./foo.js'); diff --git a/test/function/samples/hashing/minimum-hash-size/_config.js b/test/function/samples/hashing/minimum-hash-size/_config.js new file mode 100644 index 00000000000..b5500a3be19 --- /dev/null +++ b/test/function/samples/hashing/minimum-hash-size/_config.js @@ -0,0 +1,9 @@ +module.exports = defineTest({ + description: 'throws when the maximum hash size is exceeded', + options: { output: { chunkFileNames: '[hash:3].js' } }, + generateError: { + code: 'VALIDATION_ERROR', + message: + 'To generate hashes for this number of chunks (currently 1), you need a minimum hash size of 6, received 3. Check the "output.chunkFileNames" option.' + } +}); diff --git a/test/function/samples/hashing/minimum-hash-size/foo.js b/test/function/samples/hashing/minimum-hash-size/foo.js new file mode 100644 index 00000000000..5f26d709a6b --- /dev/null +++ b/test/function/samples/hashing/minimum-hash-size/foo.js @@ -0,0 +1 @@ +throw new Error('should not be executed'); diff --git a/test/function/samples/hashing/minimum-hash-size/main.js b/test/function/samples/hashing/minimum-hash-size/main.js new file mode 100644 index 00000000000..bbe4a5cc219 --- /dev/null +++ b/test/function/samples/hashing/minimum-hash-size/main.js @@ -0,0 +1 @@ +import('./foo.js'); diff --git a/test/function/samples/hidden-directories/_config.js b/test/function/samples/hidden-directories/_config.js index 80cd78429a6..d8927e53f72 100644 --- a/test/function/samples/hidden-directories/_config.js +++ b/test/function/samples/hidden-directories/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'allows imports from directories with leading "." character' -}; +}); diff --git a/test/function/samples/hoisted-variable-if-else/_config.js b/test/function/samples/hoisted-variable-if-else/_config.js index 84e819ca66d..16dce08e17c 100644 --- a/test/function/samples/hoisted-variable-if-else/_config.js +++ b/test/function/samples/hoisted-variable-if-else/_config.js @@ -1,6 +1,6 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'handles hoisted variables in chained if statements', exports(exports) { exports.test(true); @@ -10,4 +10,4 @@ module.exports = { exports.test('loop'); assert.strictEqual(exports.result, 'fourth'); } -}; +}); diff --git a/test/function/samples/hoisted-variable-name-conflict/_config.js b/test/function/samples/hoisted-variable-name-conflict/_config.js new file mode 100644 index 00000000000..10b88992fae --- /dev/null +++ b/test/function/samples/hoisted-variable-name-conflict/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'resolves conflicts between names of hoisted variables in different modules' +}); diff --git a/test/function/samples/hoisted-variable-name-conflict/dep.js b/test/function/samples/hoisted-variable-name-conflict/dep.js new file mode 100644 index 00000000000..74f8dfbd39f --- /dev/null +++ b/test/function/samples/hoisted-variable-name-conflict/dep.js @@ -0,0 +1,4 @@ +{ + var foo = 1; +} +assert.equal(foo, 1); diff --git a/test/function/samples/hoisted-variable-name-conflict/main.js b/test/function/samples/hoisted-variable-name-conflict/main.js new file mode 100644 index 00000000000..a58e1687b15 --- /dev/null +++ b/test/function/samples/hoisted-variable-name-conflict/main.js @@ -0,0 +1,6 @@ +import './dep.js'; + +{ + var foo; +} +assert.equal(foo, undefined); diff --git a/test/function/samples/identifiers-in-template-literals/_config.js b/test/function/samples/identifiers-in-template-literals/_config.js index 8b031cdab65..0e5cdcad754 100644 --- a/test/function/samples/identifiers-in-template-literals/_config.js +++ b/test/function/samples/identifiers-in-template-literals/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'identifiers in template literals are rendered correctly' -}; +}); diff --git a/test/function/samples/if-statement-insert-whitespace/_config.js b/test/function/samples/if-statement-insert-whitespace/_config.js index bad60394fb9..ea2b1b462d3 100644 --- a/test/function/samples/if-statement-insert-whitespace/_config.js +++ b/test/function/samples/if-statement-insert-whitespace/_config.js @@ -1,11 +1,11 @@ -module.exports = { +module.exports = defineTest({ description: 'inserts necessary white-space when simplifying if-statements (#3419)', options: { external: 'external' }, context: { - require(required) { + require() { return false; } } -}; +}); diff --git a/test/function/samples/if-statement-with-assignment/_config.js b/test/function/samples/if-statement-with-assignment/_config.js index 6c573d5e7bf..2f41d0cbbb4 100644 --- a/test/function/samples/if-statement-with-assignment/_config.js +++ b/test/function/samples/if-statement-with-assignment/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'update assignments to names are preserved (#930)' -}; +}); diff --git a/test/function/samples/if-statement-with-false-condition/_config.js b/test/function/samples/if-statement-with-false-condition/_config.js index b7eda7a022f..19caab3443b 100644 --- a/test/function/samples/if-statement-with-false-condition/_config.js +++ b/test/function/samples/if-statement-with-false-condition/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'if statements with false condition do not break render (#973)' -}; +}); diff --git a/test/function/samples/if-statement-with-update/_config.js b/test/function/samples/if-statement-with-update/_config.js index 8601e12f716..65771fc03e0 100644 --- a/test/function/samples/if-statement-with-update/_config.js +++ b/test/function/samples/if-statement-with-update/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'updates to names are preserved (#930)' -}; +}); diff --git a/test/function/samples/iife-code-splitting/_config.js b/test/function/samples/iife-code-splitting/_config.js index ae4602851f7..5544f274155 100644 --- a/test/function/samples/iife-code-splitting/_config.js +++ b/test/function/samples/iife-code-splitting/_config.js @@ -1,10 +1,12 @@ -module.exports = { +module.exports = defineTest({ description: 'throws when generating multiple chunks for an IIFE build', options: { output: { format: 'iife' } }, generateError: { code: 'INVALID_OPTION', - message: 'UMD and IIFE output formats are not supported for code-splitting builds.' + message: + 'Invalid value "iife" for option "output.format" - UMD and IIFE output formats are not supported for code-splitting builds.', + url: 'https://rollupjs.org/configuration-options/#output-format' } -}; +}); diff --git a/test/function/samples/iife-comments/_config.js b/test/function/samples/iife-comments/_config.js index 73f9b68d449..911aadc6933 100644 --- a/test/function/samples/iife-comments/_config.js +++ b/test/function/samples/iife-comments/_config.js @@ -1,8 +1,8 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'does not wrongly append comments', exports(exports) { assert.equal(exports, 42); } -}; +}); diff --git a/test/function/samples/implicit-dependencies/dependant-dynamic-import-no-effects/_config.js b/test/function/samples/implicit-dependencies/dependant-dynamic-import-no-effects/_config.js index ba821789554..c5449ab263b 100644 --- a/test/function/samples/implicit-dependencies/dependant-dynamic-import-no-effects/_config.js +++ b/test/function/samples/implicit-dependencies/dependant-dynamic-import-no-effects/_config.js @@ -1,18 +1,20 @@ -const path = require('path'); +const path = require('node:path'); -module.exports = { +module.exports = defineTest({ description: 'throws when a module that is loaded before an emitted chunk is fully tree-shaken', options: { - plugins: { - name: 'test-plugin', - buildStart() { - this.emitFile({ - type: 'chunk', - id: 'dep.js', - implicitlyLoadedAfterOneOf: ['dependant'] - }); + plugins: [ + { + name: 'test-plugin', + buildStart() { + this.emitFile({ + type: 'chunk', + id: 'dep.js', + implicitlyLoadedAfterOneOf: ['dependant'] + }); + } } - } + ] }, error: { code: 'MISSING_IMPLICIT_DEPENDANT', @@ -20,8 +22,8 @@ module.exports = { 'Module "dependant.js" that should be implicitly loaded before "dep.js" is not included in the module graph. Either it was not imported by an included module or only via a tree-shaken dynamic import, or no imported bindings were used and it had otherwise no side-effects.', watchFiles: [ path.join(__dirname, 'dep.js'), - path.join(__dirname, 'main.js'), - path.join(__dirname, 'dependant.js') + path.join(__dirname, 'dependant.js'), + path.join(__dirname, 'main.js') ] } -}; +}); diff --git a/test/function/samples/implicit-dependencies/dependant-dynamic-import-not-included/_config.js b/test/function/samples/implicit-dependencies/dependant-dynamic-import-not-included/_config.js index e89b39449de..8050503e3d8 100644 --- a/test/function/samples/implicit-dependencies/dependant-dynamic-import-not-included/_config.js +++ b/test/function/samples/implicit-dependencies/dependant-dynamic-import-not-included/_config.js @@ -1,24 +1,26 @@ -const path = require('path'); +const path = require('node:path'); -module.exports = { +module.exports = defineTest({ description: 'throws when a module that is loaded before an emitted chunk is only linked to the module graph via a tree-shaken dynamic import', options: { - plugins: { - name: 'test-plugin', - buildStart() { - this.emitFile({ - type: 'chunk', - id: 'dep1.js', - implicitlyLoadedAfterOneOf: ['dependant'] - }); - this.emitFile({ - type: 'chunk', - id: 'dep2.js', - implicitlyLoadedAfterOneOf: ['dependant'] - }); + plugins: [ + { + name: 'test-plugin', + buildStart() { + this.emitFile({ + type: 'chunk', + id: 'dep1.js', + implicitlyLoadedAfterOneOf: ['dependant'] + }); + this.emitFile({ + type: 'chunk', + id: 'dep2.js', + implicitlyLoadedAfterOneOf: ['dependant'] + }); + } } - } + ] }, error: { code: 'MISSING_IMPLICIT_DEPENDANT', @@ -27,8 +29,8 @@ module.exports = { watchFiles: [ path.join(__dirname, 'dep1.js'), path.join(__dirname, 'dep2.js'), - path.join(__dirname, 'main.js'), - path.join(__dirname, 'dependant.js') + path.join(__dirname, 'dependant.js'), + path.join(__dirname, 'main.js') ] } -}; +}); diff --git a/test/function/samples/implicit-dependencies/dependant-not-part-of-graph/_config.js b/test/function/samples/implicit-dependencies/dependant-not-part-of-graph/_config.js index 484f9eb1861..1f13bd68367 100644 --- a/test/function/samples/implicit-dependencies/dependant-not-part-of-graph/_config.js +++ b/test/function/samples/implicit-dependencies/dependant-not-part-of-graph/_config.js @@ -1,29 +1,31 @@ -const path = require('path'); +const path = require('node:path'); -module.exports = { +module.exports = defineTest({ description: 'throws when a module that is loaded before an emitted chunk is not part of the module graph', options: { - plugins: { - name: 'test-plugin', - buildStart() { - this.emitFile({ - type: 'chunk', - id: 'dep1.js', - implicitlyLoadedAfterOneOf: ['dependant'] - }); - this.emitFile({ - type: 'chunk', - id: 'dep2.js', - implicitlyLoadedAfterOneOf: ['dependant'] - }); - this.emitFile({ - type: 'chunk', - id: 'dep3.js', - implicitlyLoadedAfterOneOf: ['dependant'] - }); + plugins: [ + { + name: 'test-plugin', + buildStart() { + this.emitFile({ + type: 'chunk', + id: 'dep1.js', + implicitlyLoadedAfterOneOf: ['dependant'] + }); + this.emitFile({ + type: 'chunk', + id: 'dep2.js', + implicitlyLoadedAfterOneOf: ['dependant'] + }); + this.emitFile({ + type: 'chunk', + id: 'dep3.js', + implicitlyLoadedAfterOneOf: ['dependant'] + }); + } } - } + ] }, error: { code: 'MISSING_IMPLICIT_DEPENDANT', @@ -33,8 +35,8 @@ module.exports = { path.join(__dirname, 'dep1.js'), path.join(__dirname, 'dep2.js'), path.join(__dirname, 'dep3.js'), - path.join(__dirname, 'main.js'), - path.join(__dirname, 'dependant.js') + path.join(__dirname, 'dependant.js'), + path.join(__dirname, 'main.js') ] } -}; +}); diff --git a/test/function/samples/implicit-dependencies/external-dependant/_config.js b/test/function/samples/implicit-dependencies/external-dependant/_config.js index 1f29a96943f..3a44a3bc381 100644 --- a/test/function/samples/implicit-dependencies/external-dependant/_config.js +++ b/test/function/samples/implicit-dependencies/external-dependant/_config.js @@ -1,18 +1,20 @@ -const path = require('path'); +const path = require('node:path'); -module.exports = { +module.exports = defineTest({ description: 'throws when a module that is loaded before an emitted chunk does not exist', options: { - plugins: { - name: 'test-plugin', - buildStart() { - this.emitFile({ - type: 'chunk', - id: 'dep.js', - implicitlyLoadedAfterOneOf: ['does-not-exist'] - }); + plugins: [ + { + name: 'test-plugin', + buildStart() { + this.emitFile({ + type: 'chunk', + id: 'dep.js', + implicitlyLoadedAfterOneOf: ['does-not-exist'] + }); + } } - } + ] }, error: { code: 'MISSING_IMPLICIT_DEPENDANT', @@ -20,4 +22,4 @@ module.exports = { 'Module "does-not-exist" that should be implicitly loaded before "dep.js" could not be resolved.', watchFiles: [path.join(__dirname, 'dep.js'), path.join(__dirname, 'main.js')] } -}; +}); diff --git a/test/function/samples/implicit-dependencies/missing-dependant/_config.js b/test/function/samples/implicit-dependencies/missing-dependant/_config.js index 32572367851..5fbdd5d7e06 100644 --- a/test/function/samples/implicit-dependencies/missing-dependant/_config.js +++ b/test/function/samples/implicit-dependencies/missing-dependant/_config.js @@ -1,23 +1,25 @@ -const path = require('path'); +const path = require('node:path'); -module.exports = { +module.exports = defineTest({ description: 'throws when a module that is loaded before an emitted chunk is external', options: { - plugins: { - name: 'test-plugin', - resolveId(id) { - if (id === 'external') { - return false; + plugins: [ + { + name: 'test-plugin', + resolveId(id) { + if (id === 'external') { + return false; + } + }, + buildStart() { + this.emitFile({ + type: 'chunk', + id: 'dep.js', + implicitlyLoadedAfterOneOf: ['external'] + }); } - }, - buildStart() { - this.emitFile({ - type: 'chunk', - id: 'dep.js', - implicitlyLoadedAfterOneOf: ['external'] - }); } - } + ] }, error: { code: 'MISSING_IMPLICIT_DEPENDANT', @@ -25,4 +27,4 @@ module.exports = { 'Module "external" that should be implicitly loaded before "dep.js" cannot be external.', watchFiles: [path.join(__dirname, 'dep.js'), path.join(__dirname, 'main.js')] } -}; +}); diff --git a/test/function/samples/import-as/_config.js b/test/function/samples/import-as/_config.js index 7831d8cd02b..d54b17334d1 100644 --- a/test/function/samples/import-as/_config.js +++ b/test/function/samples/import-as/_config.js @@ -1,5 +1,5 @@ -module.exports = { +module.exports = defineTest({ description: 'renames named and default imports' -}; +}); // test copied from https://github.com/esnext/es6-module-transpiler/tree/master/test/examples/import-as diff --git a/test/function/samples/import-assertions/plugin-assertions-this-resolve/_config.js b/test/function/samples/import-assertions/plugin-assertions-this-resolve/_config.js new file mode 100644 index 00000000000..1ded1d1b603 --- /dev/null +++ b/test/function/samples/import-assertions/plugin-assertions-this-resolve/_config.js @@ -0,0 +1,48 @@ +const assert = require('node:assert'); + +module.exports = defineTest({ + description: 'allows plugins to provide attributes for this.resolve', + options: { + plugins: [ + { + name: 'first', + async resolveId() { + assert.deepStrictEqual( + await this.resolve('external', undefined, { + attributes: { a: 'c', b: 'd' } + }), + { + attributes: { a: 'changed', b: 'changed' }, + external: true, + id: 'external', + meta: {}, + moduleSideEffects: true, + resolvedBy: 'third', + syntheticNamedExports: false + } + ); + } + }, + { + name: 'second', + async resolveId(source, importer, { attributes }) { + if (source === 'external') { + return this.resolve(source, importer, { attributes }); + } + } + }, + { + name: 'third', + async resolveId(source, importer, { attributes }) { + if (source === 'external') { + return { + id: source, + external: true, + attributes: Object.fromEntries(Object.keys(attributes).map(key => [key, 'changed'])) + }; + } + } + } + ] + } +}); diff --git a/test/function/samples/import-assertions/plugin-assertions-this-resolve/main.js b/test/function/samples/import-assertions/plugin-assertions-this-resolve/main.js new file mode 100644 index 00000000000..cc1d88a24fa --- /dev/null +++ b/test/function/samples/import-assertions/plugin-assertions-this-resolve/main.js @@ -0,0 +1 @@ +assert.ok(true); diff --git a/test/function/samples/import-assertions/warn-assertion-conflicts/_config.js b/test/function/samples/import-assertions/warn-assertion-conflicts/_config.js new file mode 100644 index 00000000000..aae733ed2bb --- /dev/null +++ b/test/function/samples/import-assertions/warn-assertion-conflicts/_config.js @@ -0,0 +1,64 @@ +const path = require('node:path'); +const ID_MAIN = path.join(__dirname, 'main.js'); + +module.exports = defineTest({ + description: 'warns for conflicting import attributes', + options: { + external: id => id.startsWith('external') + }, + warnings: [ + { + code: 'INCONSISTENT_IMPORT_ATTRIBUTES', + frame: ` +1: import './other.js'; +2: import 'external' with { type: 'foo' }; +3: import 'external' with { type: 'bar' }; + ^ +4: import 'external'; +5: import('external', { with: { type: 'baz' } });`, + id: ID_MAIN, + loc: { + column: 0, + file: ID_MAIN, + line: 3 + }, + message: + 'main.js (3:0): Module "main.js" tried to import "external" with "type": "bar" attributes, but it was already imported elsewhere with "type": "foo" attributes. Please ensure that import attributes for the same module are always consistent.', + pos: 61 + }, + { + code: 'INCONSISTENT_IMPORT_ATTRIBUTES', + frame: ` +2: import 'external' with { type: 'foo' }; +3: import 'external' with { type: 'bar' }; +4: import 'external'; + ^ +5: import('external', { with: { type: 'baz' } }); +6: import './dep.js' with { type: 'foo' };`, + id: ID_MAIN, + loc: { + column: 0, + file: ID_MAIN, + line: 4 + }, + message: + 'main.js (4:0): Module "main.js" tried to import "external" with no attributes, but it was already imported elsewhere with "type": "foo" attributes. Please ensure that import attributes for the same module are always consistent.', + pos: 101 + }, + { + code: 'INCONSISTENT_IMPORT_ATTRIBUTES', + message: + 'Module "main.js" tried to import "external" with "type": "baz" attributes, but it was already imported elsewhere with "type": "foo" attributes. Please ensure that import attributes for the same module are always consistent.' + }, + { + code: 'INCONSISTENT_IMPORT_ATTRIBUTES', + message: + 'Module "other.js" tried to import "external" with "type": "quuz" attributes, but it was already imported elsewhere with "type": "foo" attributes. Please ensure that import attributes for the same module are always consistent.' + }, + { + code: 'INCONSISTENT_IMPORT_ATTRIBUTES', + message: + 'Module "other.js" tried to import "dep.js" with "type": "bar" attributes, but it was already imported elsewhere with "type": "foo" attributes. Please ensure that import attributes for the same module are always consistent.' + } + ] +}); diff --git a/test/function/samples/import-assertions/warn-assertion-conflicts/dep.js b/test/function/samples/import-assertions/warn-assertion-conflicts/dep.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/function/samples/import-assertions/warn-assertion-conflicts/main.js b/test/function/samples/import-assertions/warn-assertion-conflicts/main.js new file mode 100644 index 00000000000..21a4d427bca --- /dev/null +++ b/test/function/samples/import-assertions/warn-assertion-conflicts/main.js @@ -0,0 +1,6 @@ +import './other.js'; +import 'external' with { type: 'foo' }; +import 'external' with { type: 'bar' }; +import 'external'; +import('external', { with: { type: 'baz' } }); +import './dep.js' with { type: 'foo' }; diff --git a/test/function/samples/import-assertions/warn-assertion-conflicts/other.js b/test/function/samples/import-assertions/warn-assertion-conflicts/other.js new file mode 100644 index 00000000000..24533e1ebc3 --- /dev/null +++ b/test/function/samples/import-assertions/warn-assertion-conflicts/other.js @@ -0,0 +1,2 @@ +import 'external' with { type: 'quuz' }; +import './dep.js' with { type: 'bar' }; diff --git a/test/function/samples/import-assertions/warn-unresolvable-assertions/_config.js b/test/function/samples/import-assertions/warn-unresolvable-assertions/_config.js new file mode 100644 index 00000000000..a27f9c79c31 --- /dev/null +++ b/test/function/samples/import-assertions/warn-unresolvable-assertions/_config.js @@ -0,0 +1,146 @@ +const path = require('node:path'); +const ID_MAIN = path.join(__dirname, 'main.js'); + +module.exports = defineTest({ + description: 'warns for dynamic import attributes that cannot be resolved', + verifyAst: false, + context: { + bar: 'bar', + foo: 'foo', + invalid: 'invalid' + }, + options: { + external: id => id.startsWith('external') + }, + warnings: [ + { + code: 'INVALID_IMPORT_ATTRIBUTE', + message: + 'main.js (1:0): Rollup could not statically analyze an import attribute of a dynamic import in "main.js". Import attributes need to have string keys and values.', + id: ID_MAIN, + pos: 0, + loc: { + column: 0, + file: ID_MAIN, + line: 1 + }, + frame: ` + 1: import('external1', undefined); + ^ + 2: import('external2', global); + 3: import('external3', { with: 'invalid' });` + }, + { + code: 'INVALID_IMPORT_ATTRIBUTE', + message: + 'main.js (2:0): Rollup could not statically analyze an import attribute of a dynamic import in "main.js". Import attributes need to have string keys and values.', + id: ID_MAIN, + pos: 32, + loc: { + column: 0, + file: ID_MAIN, + line: 2 + }, + frame: ` + 1: import('external1', undefined); + 2: import('external2', global); + ^ + 3: import('external3', { with: 'invalid' }); + 4: import('external4', { with: { foo } });` + }, + { + code: 'INVALID_IMPORT_ATTRIBUTE', + message: + 'main.js (4:30): Rollup could not statically analyze an import attribute of a dynamic import in "main.js". Import attributes need to have string keys and values.', + id: ID_MAIN, + pos: 133, + loc: { + column: 30, + file: ID_MAIN, + line: 4 + }, + frame: ` + 2: import('external2', global); + 3: import('external3', { with: 'invalid' }); + 4: import('external4', { with: { foo } }); + ^ + 5: import('external5', { with: { foo: bar } }); + 6: import('external6', { with: { foo() {} } });` + }, + { + code: 'INVALID_IMPORT_ATTRIBUTE', + message: + 'main.js (5:30): Rollup could not statically analyze an import attribute of a dynamic import in "main.js". Import attributes need to have string keys and values.', + id: ID_MAIN, + pos: 173, + loc: { + column: 30, + file: ID_MAIN, + line: 5 + }, + frame: ` + 3: import('external3', { with: 'invalid' }); + 4: import('external4', { with: { foo } }); + 5: import('external5', { with: { foo: bar } }); + ^ + 6: import('external6', { with: { foo() {} } }); + 7: import('external7', { with: { [invalid]: 'foo' } });` + }, + { + code: 'INVALID_IMPORT_ATTRIBUTE', + message: + 'main.js (6:30): Rollup could not statically analyze an import attribute of a dynamic import in "main.js". Import attributes need to have string keys and values.', + id: ID_MAIN, + pos: 218, + loc: { + column: 30, + file: ID_MAIN, + line: 6 + }, + frame: ` + 4: import('external4', { with: { foo } }); + 5: import('external5', { with: { foo: bar } }); + 6: import('external6', { with: { foo() {} } }); + ^ + 7: import('external7', { with: { [invalid]: 'foo' } }); + 8: import('external8', { with: { foo: 'valid' } });` + }, + { + code: 'INVALID_IMPORT_ATTRIBUTE', + message: + 'main.js (7:30): Rollup could not statically analyze an import attribute of a dynamic import in "main.js". Import attributes need to have string keys and values.', + id: ID_MAIN, + pos: 263, + loc: { + column: 30, + file: ID_MAIN, + line: 7 + }, + frame: ` + 5: import('external5', { with: { foo: bar } }); + 6: import('external6', { with: { foo() {} } }); + 7: import('external7', { with: { [invalid]: 'foo' } }); + ^ + 8: import('external8', { with: { foo: 'valid' } });` + }, + { + code: 'INVALID_IMPORT_ATTRIBUTE', + message: + 'main.js (3:0): Rollup could not statically analyze the options argument of a dynamic import in "main.js". Dynamic import options need to be an object with a nested attributes object.', + id: ID_MAIN, + pos: 61, + loc: { + column: 0, + file: ID_MAIN, + line: 3 + }, + frame: ` + 1: import('external1', undefined); + 2: import('external2', global); + 3: import('external3', { with: 'invalid' }); + ^ + 4: import('external4', { with: { foo } }); + 5: import('external5', { with: { foo: bar } });` + } + ] +}); diff --git a/test/function/samples/import-assertions/warn-unresolvable-assertions/main.js b/test/function/samples/import-assertions/warn-unresolvable-assertions/main.js new file mode 100644 index 00000000000..fdc32760cad --- /dev/null +++ b/test/function/samples/import-assertions/warn-unresolvable-assertions/main.js @@ -0,0 +1,8 @@ +import('external1', undefined); +import('external2', global); +import('external3', { with: 'invalid' }); +import('external4', { with: { foo } }); +import('external5', { with: { foo: bar } }); +import('external6', { with: { foo() {} } }); +import('external7', { with: { [invalid]: 'foo' } }); +import('external8', { with: { foo: 'valid' } }); diff --git a/test/function/samples/import-binding/_config.js b/test/function/samples/import-binding/_config.js index d4f7a763af0..bb0c9aff598 100644 --- a/test/function/samples/import-binding/_config.js +++ b/test/function/samples/import-binding/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'import binding' -}; +}); diff --git a/test/function/samples/import-chain-as/_config.js b/test/function/samples/import-chain-as/_config.js index 9294fd44fba..e63edbe8fa0 100644 --- a/test/function/samples/import-chain-as/_config.js +++ b/test/function/samples/import-chain-as/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'imports as- chained exports' -}; +}); diff --git a/test/function/samples/import-chain/_config.js b/test/function/samples/import-chain/_config.js index c6c7a1b124a..34b4702f62e 100644 --- a/test/function/samples/import-chain/_config.js +++ b/test/function/samples/import-chain/_config.js @@ -1,5 +1,5 @@ -module.exports = { +module.exports = defineTest({ description: 'imports chained exports' -}; +}); // test copied from https://github.com/esnext/es6-module-transpiler/tree/master/test/examples/import-chain diff --git a/test/function/samples/import-default-and-named-function/_config.js b/test/function/samples/import-default-and-named-function/_config.js index bd54c449dd1..56341431d1c 100644 --- a/test/function/samples/import-default-and-named-function/_config.js +++ b/test/function/samples/import-default-and-named-function/_config.js @@ -1,5 +1,5 @@ -module.exports = { +module.exports = defineTest({ description: 'imports default and named exports in same declaration' -}; +}); // test copied from https://github.com/esnext/es6-module-transpiler/tree/master/test/examples/export-default-named-function diff --git a/test/function/samples/import-default-as-named/_config.js b/test/function/samples/import-default-as-named/_config.js index e11a2ea1a4d..524fc8bdc2a 100644 --- a/test/function/samples/import-default-as-named/_config.js +++ b/test/function/samples/import-default-as-named/_config.js @@ -1,5 +1,5 @@ -module.exports = { +module.exports = defineTest({ description: 'imports a default export by a name' -}; +}); // test copied from https://github.com/esnext/es6-module-transpiler/tree/master/test/examples/export-default-function diff --git a/test/function/samples/import-default-as-other/_config.js b/test/function/samples/import-default-as-other/_config.js index cb7290bd926..0223a0de039 100644 --- a/test/function/samples/import-default-as-other/_config.js +++ b/test/function/samples/import-default-as-other/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'imports a default import by another name' -}; +}); diff --git a/test/function/samples/import-default-class/_config.js b/test/function/samples/import-default-class/_config.js index becd71d101f..c5b4da3743a 100644 --- a/test/function/samples/import-default-class/_config.js +++ b/test/function/samples/import-default-class/_config.js @@ -1,5 +1,5 @@ -module.exports = { +module.exports = defineTest({ description: 'imports a default class' -}; +}); // test copied from https://github.com/esnext/es6-module-transpiler/tree/master/test/examples/export-default-class diff --git a/test/function/samples/import-default-expression/_config.js b/test/function/samples/import-default-expression/_config.js index b43e8e08046..24227282531 100644 --- a/test/function/samples/import-default-expression/_config.js +++ b/test/function/samples/import-default-expression/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'imports a default expression' -}; +}); diff --git a/test/function/samples/import-default-from-external/_config.js b/test/function/samples/import-default-from-external/_config.js index 9120a3063c3..5dc0683e7db 100644 --- a/test/function/samples/import-default-from-external/_config.js +++ b/test/function/samples/import-default-from-external/_config.js @@ -1,6 +1,6 @@ -module.exports = { +module.exports = defineTest({ description: 'imports default from external module', options: { external: ['path'] } -}; +}); diff --git a/test/function/samples/import-default-function/_config.js b/test/function/samples/import-default-function/_config.js index 77dea2133f8..418b9d421e9 100644 --- a/test/function/samples/import-default-function/_config.js +++ b/test/function/samples/import-default-function/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'imports a default function' -}; +}); diff --git a/test/function/samples/import-dependency-in-other-module/_config.js b/test/function/samples/import-dependency-in-other-module/_config.js index b29eec89fc9..5daebf9f5e3 100644 --- a/test/function/samples/import-dependency-in-other-module/_config.js +++ b/test/function/samples/import-dependency-in-other-module/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'imports a dependency from a separate module' -}; +}); diff --git a/test/function/samples/import-dependency-in-same-module/_config.js b/test/function/samples/import-dependency-in-same-module/_config.js index a08ff3cdab7..c77b1524141 100644 --- a/test/function/samples/import-dependency-in-same-module/_config.js +++ b/test/function/samples/import-dependency-in-same-module/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'imports a dependency from the same module' -}; +}); diff --git a/test/function/samples/import-empty-from-external/_config.js b/test/function/samples/import-empty-from-external/_config.js index 80c91ae85a9..cd7ddc142ac 100644 --- a/test/function/samples/import-empty-from-external/_config.js +++ b/test/function/samples/import-empty-from-external/_config.js @@ -1,9 +1,10 @@ -module.exports = { +module.exports = defineTest({ description: 'imports external module for side effects', context: { // override require here, making "foo" appear as a global module require(name) { if (name === 'foo') { + // @ts-expect-error test file is not included in project return require('./foo'); } return require(name); @@ -12,4 +13,4 @@ module.exports = { options: { external: ['foo'] } -}; +}); diff --git a/test/function/samples/import-meta-url-b/_config.js b/test/function/samples/import-meta-url-b/_config.js new file mode 100644 index 00000000000..cbfd63c2357 --- /dev/null +++ b/test/function/samples/import-meta-url-b/_config.js @@ -0,0 +1,18 @@ +const assert = require('node:assert'); + +const source = 'example.com/main.js'; + +module.exports = defineTest({ + description: 'Access document.currentScript at the top level', + context: { + document: { + currentScript: { + src: source, + tagName: 'SCRIPT' + } + } + }, + exports(exports) { + assert.strictEqual(exports(), source); + } +}); diff --git a/test/function/samples/import-meta-url-b/main.js b/test/function/samples/import-meta-url-b/main.js new file mode 100644 index 00000000000..98e4e438ccf --- /dev/null +++ b/test/function/samples/import-meta-url-b/main.js @@ -0,0 +1,6 @@ +export default function getUrl() { + document.currentScript = { src: '' }; + const url = import.meta.url; + assert.ok(import.meta.abc || true); + return url; +} diff --git a/test/function/samples/import-meta-url-with-compact/_config.js b/test/function/samples/import-meta-url-with-compact/_config.js new file mode 100644 index 00000000000..ac0dc17caff --- /dev/null +++ b/test/function/samples/import-meta-url-with-compact/_config.js @@ -0,0 +1,23 @@ +const assert = require('node:assert'); + +const source = 'example.com/main.js'; + +module.exports = defineTest({ + description: 'Get the right URL with compact output', + context: { + document: { + currentScript: { + src: source, + tagName: 'SCRIPT' + } + } + }, + options: { + output: { + compact: true + } + }, + exports(exports) { + assert.strictEqual(exports(), source); + } +}); diff --git a/test/function/samples/import-meta-url-with-compact/main.js b/test/function/samples/import-meta-url-with-compact/main.js new file mode 100644 index 00000000000..98e4e438ccf --- /dev/null +++ b/test/function/samples/import-meta-url-with-compact/main.js @@ -0,0 +1,6 @@ +export default function getUrl() { + document.currentScript = { src: '' }; + const url = import.meta.url; + assert.ok(import.meta.abc || true); + return url; +} diff --git a/test/function/samples/import-meta-url/_config.js b/test/function/samples/import-meta-url/_config.js index 3a0fe70bc1e..e64f382480d 100644 --- a/test/function/samples/import-meta-url/_config.js +++ b/test/function/samples/import-meta-url/_config.js @@ -1,8 +1,8 @@ -const path = require('path'); -const assert = require('assert'); -const URL = require('url').URL; +const assert = require('node:assert'); +const path = require('node:path'); +const URL = require('node:url').URL; -module.exports = { +module.exports = defineTest({ description: 'resolves import.meta.url', context: { __filename: path.join(__dirname, 'main.js') @@ -10,4 +10,4 @@ module.exports = { exports(exports) { assert.strictEqual(exports, new URL('file:' + path.join(__dirname, 'main.js')).href); } -}; +}); diff --git a/test/function/samples/import-named-class/_config.js b/test/function/samples/import-named-class/_config.js index 60ebeda4bf6..df42f64087a 100644 --- a/test/function/samples/import-named-class/_config.js +++ b/test/function/samples/import-named-class/_config.js @@ -1,5 +1,5 @@ -module.exports = { +module.exports = defineTest({ description: 'imports a named class' -}; +}); // test copied from https://github.com/esnext/es6-module-transpiler/tree/master/test/examples/export-named-class diff --git a/test/function/samples/import-named-from-external/_config.js b/test/function/samples/import-named-from-external/_config.js index de235679722..2c57d1a22b8 100644 --- a/test/function/samples/import-named-from-external/_config.js +++ b/test/function/samples/import-named-from-external/_config.js @@ -1,6 +1,6 @@ -module.exports = { +module.exports = defineTest({ description: 'imports names from an external module', options: { external: ['path'] } -}; +}); diff --git a/test/function/samples/import-named-function-as-other/_config.js b/test/function/samples/import-named-function-as-other/_config.js index 6a949fda9a7..84d41aadf42 100644 --- a/test/function/samples/import-named-function-as-other/_config.js +++ b/test/function/samples/import-named-function-as-other/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'imports a named function by another name' -}; +}); diff --git a/test/function/samples/import-named-function/_config.js b/test/function/samples/import-named-function/_config.js index 56c1faf6f76..6563ac91667 100644 --- a/test/function/samples/import-named-function/_config.js +++ b/test/function/samples/import-named-function/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'imports a named function' -}; +}); diff --git a/test/function/samples/import-nameless-class-expression/_config.js b/test/function/samples/import-nameless-class-expression/_config.js index a001faaa2c3..93771bba1ad 100644 --- a/test/function/samples/import-nameless-class-expression/_config.js +++ b/test/function/samples/import-nameless-class-expression/_config.js @@ -1,5 +1,5 @@ -module.exports = { +module.exports = defineTest({ description: 'imports a nameless class expression' -}; +}); // test copied from https://github.com/esnext/es6-module-transpiler/tree/master/test/examples/export-class-expression diff --git a/test/function/samples/import-namespace-from-external-module-renamed/_config.js b/test/function/samples/import-namespace-from-external-module-renamed/_config.js index 99b31818dfa..7ac860b7dc8 100644 --- a/test/function/samples/import-namespace-from-external-module-renamed/_config.js +++ b/test/function/samples/import-namespace-from-external-module-renamed/_config.js @@ -1,6 +1,6 @@ -module.exports = { +module.exports = defineTest({ description: 'imports a namespace from an external module and renames it', options: { external: ['path'] } -}; +}); diff --git a/test/function/samples/import-namespace-from-external-module/_config.js b/test/function/samples/import-namespace-from-external-module/_config.js index 72d81d042e6..5590999a6a8 100644 --- a/test/function/samples/import-namespace-from-external-module/_config.js +++ b/test/function/samples/import-namespace-from-external-module/_config.js @@ -1,6 +1,6 @@ -module.exports = { +module.exports = defineTest({ description: 'imports a namespace from an external module', options: { external: ['path'] } -}; +}); diff --git a/test/function/samples/import-namespace-from-internal-module-renamed/_config.js b/test/function/samples/import-namespace-from-internal-module-renamed/_config.js index 77f908af9e8..80097934062 100644 --- a/test/function/samples/import-namespace-from-internal-module-renamed/_config.js +++ b/test/function/samples/import-namespace-from-internal-module-renamed/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'correctly exports x as y inside a bundle' -}; +}); diff --git a/test/function/samples/import-namespace-from-internal-module/_config.js b/test/function/samples/import-namespace-from-internal-module/_config.js index d6d0671ffc4..7ce1e566f39 100644 --- a/test/function/samples/import-namespace-from-internal-module/_config.js +++ b/test/function/samples/import-namespace-from-internal-module/_config.js @@ -1,5 +1,5 @@ -module.exports = { +module.exports = defineTest({ description: 'imports a namespace from an internal module' -}; +}); // test copied from https://github.com/esnext/es6-module-transpiler/tree/master/test/examples/namespaces diff --git a/test/function/samples/import-not-at-top-level-fails/_config.js b/test/function/samples/import-not-at-top-level-fails/_config.js index 7fd52d4cde7..955f060572b 100644 --- a/test/function/samples/import-not-at-top-level-fails/_config.js +++ b/test/function/samples/import-not-at-top-level-fails/_config.js @@ -1,32 +1,29 @@ -const path = require('path'); +const path = require('node:path'); +const ID_MAIN = path.join(__dirname, 'main.js'); -module.exports = { +module.exports = defineTest({ description: 'disallows non-top-level imports', error: { - code: 'PARSE_ERROR', - message: `'import' and 'export' may only appear at the top level`, - id: path.join(__dirname, 'main.js'), - parserError: { - loc: { - column: 2, - line: 2 - }, - message: "'import' and 'export' may only appear at the top level (2:2)", + cause: { + code: 'PARSE_ERROR', pos: 19, - raisedAt: 25 + message: "'import', and 'export' cannot be used outside of module code" }, + code: 'PARSE_ERROR', + id: ID_MAIN, pos: 19, - watchFiles: [path.join(__dirname, 'main.js')], loc: { - file: path.join(__dirname, 'main.js'), - line: 2, - column: 2 + column: 2, + file: ID_MAIN, + line: 2 }, frame: ` 1: function foo() { 2: import foo from './foo.js'; ^ 3: } - ` + `, + watchFiles: [ID_MAIN], + message: "main.js (2:2): 'import', and 'export' cannot be used outside of module code" } -}; +}); diff --git a/test/function/samples/import-of-unexported-fails/_config.js b/test/function/samples/import-of-unexported-fails/_config.js index 0dcf4450b34..6ab48fa5072 100644 --- a/test/function/samples/import-of-unexported-fails/_config.js +++ b/test/function/samples/import-of-unexported-fails/_config.js @@ -1,17 +1,20 @@ -const path = require('path'); +const path = require('node:path'); +const ID_MAIN = path.join(__dirname, 'main.js'); +const ID_EMPTY = path.join(__dirname, 'empty.js'); -module.exports = { +module.exports = defineTest({ description: 'marking an imported, but unexported, identifier should throw', error: { + binding: 'default', code: 'MISSING_EXPORT', - message: `'default' is not exported by empty.js, imported by main.js`, - id: path.join(__dirname, 'main.js'), + exporter: ID_EMPTY, + id: ID_MAIN, + url: 'https://rollupjs.org/troubleshooting/#error-name-is-not-exported-by-module', pos: 7, - watchFiles: [path.join(__dirname, 'main.js'), path.join(__dirname, 'empty.js')], loc: { - file: path.join(__dirname, 'main.js'), - line: 1, - column: 7 + column: 7, + file: ID_MAIN, + line: 1 }, frame: ` 1: import a from './empty.js'; @@ -19,6 +22,7 @@ module.exports = { 2: 3: a(); `, - url: `https://rollupjs.org/guide/en/#error-name-is-not-exported-by-module` + watchFiles: [ID_EMPTY, ID_MAIN], + message: 'main.js (1:7): "default" is not exported by "empty.js", imported by "main.js".' } -}; +}); diff --git a/test/function/samples/import-var-declaration/_config.js b/test/function/samples/import-var-declaration/_config.js index f0f30a4e1c8..f09d8c9eeaa 100644 --- a/test/function/samples/import-var-declaration/_config.js +++ b/test/function/samples/import-var-declaration/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'imports a variable declaration' -}; +}); diff --git a/test/function/samples/imports-are-deconflicted-b/_config.js b/test/function/samples/imports-are-deconflicted-b/_config.js index f89a1b06c1c..6513e42a50c 100644 --- a/test/function/samples/imports-are-deconflicted-b/_config.js +++ b/test/function/samples/imports-are-deconflicted-b/_config.js @@ -1,6 +1,6 @@ -module.exports = { +module.exports = defineTest({ description: 'deconflicts imports (redux)', options: { external: ['path'] } -}; +}); diff --git a/test/function/samples/imports-are-deconflicted-c/_config.js b/test/function/samples/imports-are-deconflicted-c/_config.js index b33a03f5ce6..4995fb27bd2 100644 --- a/test/function/samples/imports-are-deconflicted-c/_config.js +++ b/test/function/samples/imports-are-deconflicted-c/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'deconflicts imports, again' -}; +}); diff --git a/test/function/samples/imports-are-deconflicted/_config.js b/test/function/samples/imports-are-deconflicted/_config.js index b6b364ff345..bffa735ccd0 100644 --- a/test/function/samples/imports-are-deconflicted/_config.js +++ b/test/function/samples/imports-are-deconflicted/_config.js @@ -1,6 +1,6 @@ -module.exports = { +module.exports = defineTest({ description: 'deconflicts imports', options: { external: ['path'] } -}; +}); diff --git a/test/function/samples/includes-internally-used-default-export/_config.js b/test/function/samples/includes-internally-used-default-export/_config.js index 3eab34086ad..0a2c6c9f02c 100644 --- a/test/function/samples/includes-internally-used-default-export/_config.js +++ b/test/function/samples/includes-internally-used-default-export/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'includes default exports that are only used internally' -}; +}); diff --git a/test/function/samples/includes-reassignments/_config.js b/test/function/samples/includes-reassignments/_config.js index 1d66654e7d1..bf17b4186f3 100644 --- a/test/function/samples/includes-reassignments/_config.js +++ b/test/function/samples/includes-reassignments/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'includes reassignments that are ignored on an initial pass' -}; +}); diff --git a/test/function/samples/includes-superclass/_config.js b/test/function/samples/includes-superclass/_config.js index 7baf3857813..aef55b3abe2 100644 --- a/test/function/samples/includes-superclass/_config.js +++ b/test/function/samples/includes-superclass/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'includes superclass (#932)' -}; +}); diff --git a/test/function/samples/inline-dynamic-imports-bundle/_config.js b/test/function/samples/inline-dynamic-imports-bundle/_config.js index 79be84373bc..a0e47b6a758 100644 --- a/test/function/samples/inline-dynamic-imports-bundle/_config.js +++ b/test/function/samples/inline-dynamic-imports-bundle/_config.js @@ -1,17 +1,19 @@ -const assert = require('assert'); -const path = require('path'); +const assert = require('node:assert'); +const path = require('node:path'); -module.exports = { +module.exports = defineTest({ description: 'ignores non-bundled modules when inlining dynamic imports', options: { output: { inlineDynamicImports: true }, - plugins: { - generateBundle(options, bundle) { - assert.deepStrictEqual(Object.keys(bundle['main.js'].modules), [ - path.join(__dirname, 'lib.js'), - path.join(__dirname, 'main.js') - ]); + plugins: [ + { + generateBundle(options, bundle) { + assert.deepStrictEqual(Object.keys(bundle['main.js'].modules), [ + path.join(__dirname, 'lib.js'), + path.join(__dirname, 'main.js') + ]); + } } - } + ] } -}; +}); diff --git a/test/function/samples/inline-dynamic-no-treeshake/_config.js b/test/function/samples/inline-dynamic-no-treeshake/_config.js new file mode 100644 index 00000000000..89f7f7caedf --- /dev/null +++ b/test/function/samples/inline-dynamic-no-treeshake/_config.js @@ -0,0 +1,29 @@ +const MAGIC_ENTRY = 'main'; + +module.exports = defineTest({ + description: 'handles inlining dynamic imports when treeshaking is disabled for modules (#4098)', + options: { + input: MAGIC_ENTRY, + output: { + inlineDynamicImports: true + }, + plugins: [ + { + name: 'magic-modules', + buildStart() { + this.emitFile({ type: 'chunk', id: './dep.js' }); + }, + async resolveId(source) { + if (source === MAGIC_ENTRY) { + return { id: source, moduleSideEffects: 'no-treeshake' }; + } + return null; + }, + async load(id) { + if (id !== MAGIC_ENTRY) return null; + return `import {foo} from './reexport.js';assert.strictEqual(foo, 1);`; + } + } + ] + } +}); diff --git a/test/function/samples/inline-dynamic-no-treeshake/dep.js b/test/function/samples/inline-dynamic-no-treeshake/dep.js new file mode 100644 index 00000000000..bb1843d113a --- /dev/null +++ b/test/function/samples/inline-dynamic-no-treeshake/dep.js @@ -0,0 +1 @@ +export const foo = 1; diff --git a/test/function/samples/inline-dynamic-no-treeshake/reexport.js b/test/function/samples/inline-dynamic-no-treeshake/reexport.js new file mode 100644 index 00000000000..67f8e3c5192 --- /dev/null +++ b/test/function/samples/inline-dynamic-no-treeshake/reexport.js @@ -0,0 +1 @@ +export * from './dep.js'; diff --git a/test/function/samples/inline-imports-with-manual/_config.js b/test/function/samples/inline-imports-with-manual/_config.js index e5e7877082c..df7b34acd33 100644 --- a/test/function/samples/inline-imports-with-manual/_config.js +++ b/test/function/samples/inline-imports-with-manual/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'Manual chunks are not supported when inlining dynamic imports', options: { input: ['main.js'], @@ -11,6 +11,8 @@ module.exports = { }, generateError: { code: 'INVALID_OPTION', - message: 'The "output.manualChunks" option is not supported for "output.inlineDynamicImports".' + message: + 'Invalid value for option "output.manualChunks" - this option is not supported for "output.inlineDynamicImports".', + url: 'https://rollupjs.org/configuration-options/#output-manualchunks' } -}; +}); diff --git a/test/function/samples/inline-imports-with-multiple-array/_config.js b/test/function/samples/inline-imports-with-multiple-array/_config.js index a1be26d335e..d2494f70b8a 100644 --- a/test/function/samples/inline-imports-with-multiple-array/_config.js +++ b/test/function/samples/inline-imports-with-multiple-array/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'Having multiple inputs in an array is not supported when inlining dynamic imports', options: { input: ['main.js', 'lib.js'], @@ -6,6 +6,8 @@ module.exports = { }, generateError: { code: 'INVALID_OPTION', - message: 'Multiple inputs are not supported for "output.inlineDynamicImports".' + message: + 'Invalid value for option "output.inlineDynamicImports" - multiple inputs are not supported when "output.inlineDynamicImports" is true.', + url: 'https://rollupjs.org/configuration-options/#output-inlinedynamicimports' } -}; +}); diff --git a/test/function/samples/inline-imports-with-multiple-object/_config.js b/test/function/samples/inline-imports-with-multiple-object/_config.js index 9a5b1fd1af4..bc8dc2150a8 100644 --- a/test/function/samples/inline-imports-with-multiple-object/_config.js +++ b/test/function/samples/inline-imports-with-multiple-object/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'Having multiple inputs in an object is not supported when inlining dynamic imports', options: { input: { main: 'main.js', lib: 'lib.js' }, @@ -6,6 +6,8 @@ module.exports = { }, generateError: { code: 'INVALID_OPTION', - message: 'Multiple inputs are not supported for "output.inlineDynamicImports".' + message: + 'Invalid value for option "output.inlineDynamicImports" - multiple inputs are not supported when "output.inlineDynamicImports" is true.', + url: 'https://rollupjs.org/configuration-options/#output-inlinedynamicimports' } -}; +}); diff --git a/test/function/samples/inlined-dynamic-namespace-compact/_config.js b/test/function/samples/inlined-dynamic-namespace-compact/_config.js index b984528efa1..46930df80e3 100644 --- a/test/function/samples/inlined-dynamic-namespace-compact/_config.js +++ b/test/function/samples/inlined-dynamic-namespace-compact/_config.js @@ -1,9 +1,9 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'properly resolves inlined dynamic namespaces in compact mode', options: { output: { compact: true } }, exports(exports) { return exports.then(result => assert.strictEqual(result, 42 * 3)); } -}; +}); diff --git a/test/function/samples/input-name-validation/_config.js b/test/function/samples/input-name-validation/_config.js index e080d4098c9..5dc766e619f 100644 --- a/test/function/samples/input-name-validation/_config.js +++ b/test/function/samples/input-name-validation/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'throws for absolute paths as input names', options: { input: { '/test': 'main.js' } @@ -8,4 +8,4 @@ module.exports = { message: 'Invalid substitution "/test" for placeholder "[name]" in "output.entryFileNames" pattern, can be neither absolute nor relative path.' } -}; +}); diff --git a/test/function/samples/input-name-validation2/_config.js b/test/function/samples/input-name-validation2/_config.js index 66b864ccf6c..24f9b5b0a2a 100644 --- a/test/function/samples/input-name-validation2/_config.js +++ b/test/function/samples/input-name-validation2/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'throws for relative paths as input names', options: { input: { './test': 'main.js' } @@ -8,4 +8,4 @@ module.exports = { message: 'Invalid substitution "./test" for placeholder "[name]" in "output.entryFileNames" pattern, can be neither absolute nor relative path.' } -}; +}); diff --git a/test/function/samples/input-name-validation3/_config.js b/test/function/samples/input-name-validation3/_config.js index 5c40d5fb728..f7eaa0e73f9 100644 --- a/test/function/samples/input-name-validation3/_config.js +++ b/test/function/samples/input-name-validation3/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'throws for relative paths as input names', options: { input: { '../test': 'main.js' } @@ -8,4 +8,4 @@ module.exports = { message: 'Invalid substitution "../test" for placeholder "[name]" in "output.entryFileNames" pattern, can be neither absolute nor relative path.' } -}; +}); diff --git a/test/function/samples/instanceof/left-hand-effect/_config.js b/test/function/samples/instanceof/left-hand-effect/_config.js new file mode 100644 index 00000000000..20f3087b793 --- /dev/null +++ b/test/function/samples/instanceof/left-hand-effect/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'retains side effects in the left hand side of instanceof' +}); diff --git a/test/function/samples/instanceof/left-hand-effect/main.js b/test/function/samples/instanceof/left-hand-effect/main.js new file mode 100644 index 00000000000..f29fbed86a7 --- /dev/null +++ b/test/function/samples/instanceof/left-hand-effect/main.js @@ -0,0 +1,14 @@ +let effect = false; + +class Bar {} +class Foo { + constructor() { + effect = true; + } +} + +if (new Foo() instanceof Bar) { + assert.fail('Wrong instance relation'); +} + +assert.ok(effect); diff --git a/test/function/samples/instanceof/right-hand-effect/_config.js b/test/function/samples/instanceof/right-hand-effect/_config.js new file mode 100644 index 00000000000..16ad2a1dece --- /dev/null +++ b/test/function/samples/instanceof/right-hand-effect/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'retains side effects in the right hand side of instanceof' +}); diff --git a/test/function/samples/instanceof/right-hand-effect/main.js b/test/function/samples/instanceof/right-hand-effect/main.js new file mode 100644 index 00000000000..01fa8698a53 --- /dev/null +++ b/test/function/samples/instanceof/right-hand-effect/main.js @@ -0,0 +1,14 @@ +let effect = false; + +class Foo {} + +if ( + new Foo() instanceof + class { + [(effect = true)]() {} + } +) { + assert.fail('Wrong instance relation'); +} + +assert.ok(effect); diff --git a/test/function/samples/instanceof/used-parameter/_config.js b/test/function/samples/instanceof/used-parameter/_config.js new file mode 100644 index 00000000000..b054dd1b8fa --- /dev/null +++ b/test/function/samples/instanceof/used-parameter/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'retains instanceof for function parameters' +}); diff --git a/test/function/samples/instanceof/used-parameter/main.js b/test/function/samples/instanceof/used-parameter/main.js new file mode 100644 index 00000000000..61c8724c78d --- /dev/null +++ b/test/function/samples/instanceof/used-parameter/main.js @@ -0,0 +1,12 @@ +let effect = false; + +class Foo {} + +function checkInstance(instance) { + if (instance instanceof Foo) { + effect = true; + } +} + +checkInstance(new Foo()); +assert.ok(effect); diff --git a/test/function/samples/instanceof/used/_config.js b/test/function/samples/instanceof/used/_config.js new file mode 100644 index 00000000000..9056ea08051 --- /dev/null +++ b/test/function/samples/instanceof/used/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'retains instanceof if it is true' +}); diff --git a/test/function/samples/instanceof/used/main.js b/test/function/samples/instanceof/used/main.js new file mode 100644 index 00000000000..cbd5feb2583 --- /dev/null +++ b/test/function/samples/instanceof/used/main.js @@ -0,0 +1,5 @@ +class Foo {} + +if (!(new Foo() instanceof Foo)) { + assert.fail('instanceof not resolved correctly'); +} diff --git a/test/function/samples/inter-chunk-execution-order/_config.js b/test/function/samples/inter-chunk-execution-order/_config.js index c1e48110ac9..7fa0f55be46 100644 --- a/test/function/samples/inter-chunk-execution-order/_config.js +++ b/test/function/samples/inter-chunk-execution-order/_config.js @@ -1,7 +1,7 @@ -const assert = require('assert'); +const assert = require('node:assert'); const execution = { index: 0 }; -module.exports = { +module.exports = defineTest({ description: 'sorts imports between chunks to closely match the actual execution order', context: { execution }, options: { @@ -10,4 +10,4 @@ module.exports = { exports() { assert.equal(execution.index, 4); } -}; +}); diff --git a/test/function/samples/internal-reexports-from-external/_config.js b/test/function/samples/internal-reexports-from-external/_config.js index 83d235ccd90..ba58c6ea611 100644 --- a/test/function/samples/internal-reexports-from-external/_config.js +++ b/test/function/samples/internal-reexports-from-external/_config.js @@ -1,31 +1,32 @@ -const assert = require('assert'); -const fs = require('fs'); -const path = require('path'); +const assert = require('node:assert'); +const fs = require('node:fs'); +const path = require('node:path'); -module.exports = { +module.exports = defineTest({ description: 'supports namespaces with external star reexports', options: { external: ['fs', 'path'], - plugins: { - transform(code, id) { - if (id.endsWith('override.js')) { - return { - code, - syntheticNamedExports: true - }; + plugins: [ + { + transform(code, id) { + if (id.endsWith('override.js')) { + return { + code, + syntheticNamedExports: true + }; + } + return null; } - return null; } - } + ] }, exports(exports) { assert.strictEqual(exports.fs.readFile, fs.readFile); - assert.deepStrictEqual(Object.keys(exports.fs), Object.keys(fs).concat(['default'])); - assert.notStrictEqual(exports.fsOverride.readFile, fs.readFile); + assert.deepStrictEqual(Object.keys(exports.fs), Object.keys(fs)); assert.strictEqual(exports.fsOverride.readFile, 'override'); assert.strictEqual(exports.fsOverride.extra, 'extra'); assert.strictEqual(exports.fsOverride.synthetic, 'synthetic'); - assert.strictEqual(exports.fsOverride.synthetic, 'synthetic'); + assert.strictEqual(exports.fsOverride.readFileSync, fs.readFileSync); assert.strictEqual(exports.fsOverride.dirname, path.dirname); } -}; +}); diff --git a/test/function/samples/interop-auto-live-bindings/_config.js b/test/function/samples/interop-auto-live-bindings/_config.js index 44c164c6aba..7680e514d9f 100644 --- a/test/function/samples/interop-auto-live-bindings/_config.js +++ b/test/function/samples/interop-auto-live-bindings/_config.js @@ -4,7 +4,7 @@ let barCjs = 'bar'; let fooDefault = 'foo'; let barDefault = 'bar'; -module.exports = { +module.exports = defineTest({ description: 'handles interop "auto" with live-bindings support', options: { external: id => id.startsWith('external') || id === 'update', @@ -16,7 +16,7 @@ module.exports = { context: { require(id) { switch (id) { - case 'external-module': + case 'external-module': { return Object.defineProperty( { get default() { @@ -29,13 +29,15 @@ module.exports = { '__esModule', { value: true } ); - case 'external-cjs': + } + case 'external-cjs': { return { get barCjs() { return barCjs; } }; - case 'external-cjs-with-default': + } + case 'external-cjs-with-default': { return { get default() { return fooDefault; @@ -44,7 +46,8 @@ module.exports = { return barDefault; } }; - case 'update': + } + case 'update': { return () => { fooModule = 'foo2'; barModule = 'bar2'; @@ -52,9 +55,11 @@ module.exports = { fooDefault = 'foo2'; barDefault = 'bar2'; }; - default: + } + default: { throw new Error(`Unexpected import "${id}"`); + } } } } -}; +}); diff --git a/test/function/samples/interop-auto-no-live-bindings/_config.js b/test/function/samples/interop-auto-no-live-bindings/_config.js index 8872dd321a8..38031492af8 100644 --- a/test/function/samples/interop-auto-no-live-bindings/_config.js +++ b/test/function/samples/interop-auto-no-live-bindings/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'handles interop "auto" without live-bindings support', options: { external: id => id.startsWith('external') || id === 'update', @@ -11,7 +11,7 @@ module.exports = { context: { require(id) { switch (id) { - case 'external-module': + case 'external-module': { return Object.defineProperty( { get default() { @@ -24,13 +24,15 @@ module.exports = { '__esModule', { value: true } ); - case 'external-cjs': + } + case 'external-cjs': { return { get barCjs() { return 'bar'; } }; - case 'external-cjs-with-default': + } + case 'external-cjs-with-default': { return { get default() { return 'foo'; @@ -39,9 +41,11 @@ module.exports = { return 'bar'; } }; - default: + } + default: { throw new Error(`Unexpected import "${id}"`); + } } } } -}; +}); diff --git a/test/function/samples/interop-default-conflict/_config.js b/test/function/samples/interop-default-conflict/_config.js index aeaf1925ff6..48271360c7b 100644 --- a/test/function/samples/interop-default-conflict/_config.js +++ b/test/function/samples/interop-default-conflict/_config.js @@ -1,13 +1,14 @@ -const assert = require('assert'); +const assert = require('node:assert'); let bar = 'initial bar'; let defaultValue = 'initial foo'; -module.exports = { +module.exports = defineTest({ description: 'handles conflicts with added interop default variables and supports default live bindings', options: { - external: 'external' + external: 'external', + output: { interop: 'compat' } }, context: { require() { @@ -38,4 +39,4 @@ module.exports = { external__default: 2 }); } -}; +}); diff --git a/test/function/samples/interop-default-only-named-import/_config.js b/test/function/samples/interop-default-only-named-import/_config.js index bc378cbebf9..2b03b54fae3 100644 --- a/test/function/samples/interop-default-only-named-import/_config.js +++ b/test/function/samples/interop-default-only-named-import/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'throws when using a named import with interop "defaultOnly"', options: { external: 'external', @@ -8,9 +8,9 @@ module.exports = { }, generateError: { code: 'UNEXPECTED_NAMED_IMPORT', - id: 'external', + exporter: 'external', + url: 'https://rollupjs.org/configuration-options/#output-interop', message: - 'The named export "foo" was imported from the external module external even though its interop type is "defaultOnly". Either remove or change this import or change the value of the "output.interop" option.', - url: 'https://rollupjs.org/guide/en/#outputinterop' + 'The named export "foo" was imported from the external module "external" even though its interop type is "defaultOnly". Either remove or change this import or change the value of the "output.interop" option.' } -}; +}); diff --git a/test/function/samples/interop-default-only-named-namespace-reexport/_config.js b/test/function/samples/interop-default-only-named-namespace-reexport/_config.js index c38d245cd19..ee2ecff0135 100644 --- a/test/function/samples/interop-default-only-named-namespace-reexport/_config.js +++ b/test/function/samples/interop-default-only-named-namespace-reexport/_config.js @@ -1,6 +1,6 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'allows reexporting a namespace as a name when interop is "defaultOnly"', options: { external: 'external', @@ -11,4 +11,4 @@ module.exports = { exports(exports) { assert.deepStrictEqual(exports, { foo: { __proto__: null, default: { external: true } } }); } -}; +}); diff --git a/test/function/samples/interop-default-only-named-reexport/_config.js b/test/function/samples/interop-default-only-named-reexport/_config.js index aab5666562e..2c45a5cdbb1 100644 --- a/test/function/samples/interop-default-only-named-reexport/_config.js +++ b/test/function/samples/interop-default-only-named-reexport/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'throws when reexporting a namespace with interop "defaultOnly"', options: { external: 'external', @@ -8,9 +8,9 @@ module.exports = { }, generateError: { code: 'UNEXPECTED_NAMED_IMPORT', - id: 'external', + exporter: 'external', + url: 'https://rollupjs.org/configuration-options/#output-interop', message: - 'The named export "foo" was reexported from the external module external even though its interop type is "defaultOnly". Either remove or change this reexport or change the value of the "output.interop" option.', - url: 'https://rollupjs.org/guide/en/#outputinterop' + 'The named export "foo" was reexported from the external module "external" even though its interop type is "defaultOnly". Either remove or change this reexport or change the value of the "output.interop" option.' } -}; +}); diff --git a/test/function/samples/interop-default-only-namespace-import/_config.js b/test/function/samples/interop-default-only-namespace-import/_config.js index 754c3628c0b..c817587da2e 100644 --- a/test/function/samples/interop-default-only-namespace-import/_config.js +++ b/test/function/samples/interop-default-only-namespace-import/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'allows importing a namespace when interop is "defaultOnly"', options: { external: 'external', @@ -6,4 +6,4 @@ module.exports = { interop: 'defaultOnly' } } -}; +}); diff --git a/test/function/samples/interop-default-only-namespace-reexport/_config.js b/test/function/samples/interop-default-only-namespace-reexport/_config.js index 71486618f9c..90522d2ae92 100644 --- a/test/function/samples/interop-default-only-namespace-reexport/_config.js +++ b/test/function/samples/interop-default-only-namespace-reexport/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'warns when reexporting a namespace with interop "defaultOnly"', options: { external: 'external', @@ -9,10 +9,10 @@ module.exports = { warnings: [ { code: 'UNEXPECTED_NAMED_IMPORT', - id: 'external', + exporter: 'external', message: - 'There was a namespace "*" reexport from the external module external even though its interop type is "defaultOnly". This will be ignored as namespace reexports only reexport named exports. If this is not intended, either remove or change this reexport or change the value of the "output.interop" option.', - url: 'https://rollupjs.org/guide/en/#outputinterop' + 'There was a namespace "*" reexport from the external module "external" even though its interop type is "defaultOnly". This will be ignored as namespace reexports only reexport named exports. If this is not intended, either remove or change this reexport or change the value of the "output.interop" option.', + url: 'https://rollupjs.org/configuration-options/#output-interop' } ] -}; +}); diff --git a/test/function/samples/interop-default-only/_config.js b/test/function/samples/interop-default-only/_config.js index 926466b7d4b..1e229dca03b 100644 --- a/test/function/samples/interop-default-only/_config.js +++ b/test/function/samples/interop-default-only/_config.js @@ -4,7 +4,7 @@ let barCjs = 'bar'; let fooDefault = 'foo'; let barDefault = 'bar'; -module.exports = { +module.exports = defineTest({ description: 'handles interop "defaultOnly"', options: { external: id => id.startsWith('external') || id === 'update', @@ -16,7 +16,7 @@ module.exports = { context: { require(id) { switch (id) { - case 'external-module': + case 'external-module': { return Object.defineProperty( { get default() { @@ -29,13 +29,15 @@ module.exports = { '__esModule', { value: true } ); - case 'external-cjs': + } + case 'external-cjs': { return { get barCjs() { return barCjs; } }; - case 'external-cjs-with-default': + } + case 'external-cjs-with-default': { return { get default() { return fooDefault; @@ -44,7 +46,8 @@ module.exports = { return barDefault; } }; - case 'update': + } + case 'update': { return () => { fooModule = 'foo2'; barModule = 'bar2'; @@ -52,9 +55,11 @@ module.exports = { fooDefault = 'foo2'; barDefault = 'bar2'; }; - default: + } + default: { throw new Error(`Unexpected import "${id}"`); + } } } } -}; +}); diff --git a/test/function/samples/interop-default/_config.js b/test/function/samples/interop-default/_config.js index 5a37830f9ba..9e97be301ad 100644 --- a/test/function/samples/interop-default/_config.js +++ b/test/function/samples/interop-default/_config.js @@ -4,7 +4,7 @@ let barCjs = 'bar'; let fooDefault = 'foo'; let barDefault = 'bar'; -module.exports = { +module.exports = defineTest({ description: 'handles interop "default" with live-bindings support', options: { external: id => id.startsWith('external') || id === 'update', @@ -16,7 +16,7 @@ module.exports = { context: { require(id) { switch (id) { - case 'external-module': + case 'external-module': { return Object.defineProperty( { get default() { @@ -29,13 +29,15 @@ module.exports = { '__esModule', { value: true } ); - case 'external-cjs': + } + case 'external-cjs': { return { get barCjs() { return barCjs; } }; - case 'external-cjs-with-default': + } + case 'external-cjs-with-default': { return { get default() { return fooDefault; @@ -44,7 +46,8 @@ module.exports = { return barDefault; } }; - case 'update': + } + case 'update': { return () => { fooModule = 'foo2'; barModule = 'bar2'; @@ -52,9 +55,11 @@ module.exports = { fooDefault = 'foo2'; barDefault = 'bar2'; }; - default: + } + default: { throw new Error(`Unexpected import "${id}"`); + } } } } -}; +}); diff --git a/test/function/samples/interop-esmodule/_config.js b/test/function/samples/interop-esmodule/_config.js index a911043f664..219e1b96223 100644 --- a/test/function/samples/interop-esmodule/_config.js +++ b/test/function/samples/interop-esmodule/_config.js @@ -4,7 +4,7 @@ let barCjs = 'bar'; let fooDefault = 'foo'; let barDefault = 'bar'; -module.exports = { +module.exports = defineTest({ description: 'handles interop "esModule" with live-bindings support', options: { external: id => id.startsWith('external') || id === 'update', @@ -16,7 +16,7 @@ module.exports = { context: { require(id) { switch (id) { - case 'external-module': + case 'external-module': { return Object.defineProperty( { get default() { @@ -29,13 +29,15 @@ module.exports = { '__esModule', { value: true } ); - case 'external-cjs': + } + case 'external-cjs': { return { get barCjs() { return barCjs; } }; - case 'external-cjs-with-default': + } + case 'external-cjs-with-default': { return { get default() { return fooDefault; @@ -44,7 +46,8 @@ module.exports = { return barDefault; } }; - case 'update': + } + case 'update': { return { default: () => { fooModule = 'foo2'; @@ -54,9 +57,11 @@ module.exports = { barDefault = 'bar2'; } }; - default: + } + default: { throw new Error(`Unexpected import "${id}"`); + } } } } -}; +}); diff --git a/test/function/samples/invalid-addon-hook/_config.js b/test/function/samples/invalid-addon-hook/_config.js new file mode 100644 index 00000000000..d237b2e56c6 --- /dev/null +++ b/test/function/samples/invalid-addon-hook/_config.js @@ -0,0 +1,11 @@ +module.exports = defineTest({ + description: 'throws when providing a non-string value for an addon hook', + options: { + plugins: [{ intro: 42 }] + }, + generateError: { + code: 'ADDON_ERROR', + message: + 'Could not retrieve "intro". Check configuration of plugin "at position 1".\n\tError Message: [plugin at position 1] Error running plugin hook "intro" for plugin "at position 1", expected a string, a function hook or an object with a "handler" string or function.' + } +}); diff --git a/test/function/samples/invalid-addon-hook/foo.js b/test/function/samples/invalid-addon-hook/foo.js new file mode 100644 index 00000000000..7a4e8a723a4 --- /dev/null +++ b/test/function/samples/invalid-addon-hook/foo.js @@ -0,0 +1 @@ +export default 42; diff --git a/test/function/samples/invalid-addon-hook/main.js b/test/function/samples/invalid-addon-hook/main.js new file mode 100644 index 00000000000..a25cfbd9058 --- /dev/null +++ b/test/function/samples/invalid-addon-hook/main.js @@ -0,0 +1 @@ +export default () => import('./foo.js'); diff --git a/test/function/samples/invalid-default-export-mode/_config.js b/test/function/samples/invalid-default-export-mode/_config.js index 84f919bc080..bef2235260f 100644 --- a/test/function/samples/invalid-default-export-mode/_config.js +++ b/test/function/samples/invalid-default-export-mode/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'throw for invalid default export mode', options: { output: { @@ -8,6 +8,7 @@ module.exports = { generateError: { code: 'INVALID_EXPORT_OPTION', message: - '"default" was specified for "output.exports", but entry module "main.js" has the following exports: default, foo' + '"default" was specified for "output.exports", but entry module "main.js" has the following exports: "default" and "foo"', + url: 'https://rollupjs.org/configuration-options/#output-exports' } -}; +}); diff --git a/test/function/samples/invalid-ignore-list-function/_config.js b/test/function/samples/invalid-ignore-list-function/_config.js new file mode 100644 index 00000000000..48a4611f758 --- /dev/null +++ b/test/function/samples/invalid-ignore-list-function/_config.js @@ -0,0 +1,17 @@ +const path = require('node:path'); + +module.exports = defineTest({ + description: 'throw descriptive error if sourcemapIgnoreList-function does not return a boolean', + options: { + output: { + name: 'myModule', + sourcemap: true, + file: path.join(__dirname, 'main.js'), + sourcemapIgnoreList: () => {} + } + }, + generateError: { + code: 'VALIDATION_ERROR', + message: 'sourcemapIgnoreList function must return a boolean.' + } +}); diff --git a/test/function/samples/invalid-ignore-list-function/main.js b/test/function/samples/invalid-ignore-list-function/main.js new file mode 100644 index 00000000000..7a4e8a723a4 --- /dev/null +++ b/test/function/samples/invalid-ignore-list-function/main.js @@ -0,0 +1 @@ +export default 42; diff --git a/test/function/samples/invalid-interop/_config.js b/test/function/samples/invalid-interop/_config.js index d833dd1a63d..2dae351f071 100644 --- a/test/function/samples/invalid-interop/_config.js +++ b/test/function/samples/invalid-interop/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'throws for invalid interop values', options: { external: 'external', @@ -9,7 +9,7 @@ module.exports = { generateError: { code: 'INVALID_OPTION', message: - 'The value "true" is not supported for "output.interop". Use one of "auto", "esModule", "default", "defaultOnly", true, false instead.', - url: 'https://rollupjs.org/guide/en/#outputinterop' + 'Invalid value "true" for option "output.interop" - use one of "compat", "auto", "esModule", "default", "defaultOnly".', + url: 'https://rollupjs.org/configuration-options/#output-interop' } -}; +}); diff --git a/test/function/samples/invalid-pattern-replacement/_config.js b/test/function/samples/invalid-pattern-replacement/_config.js index e02a3b56d35..31b7448b93d 100644 --- a/test/function/samples/invalid-pattern-replacement/_config.js +++ b/test/function/samples/invalid-pattern-replacement/_config.js @@ -1,10 +1,10 @@ -module.exports = { +module.exports = defineTest({ description: 'throws for invalid placeholders in patterns', options: { output: { entryFileNames: '[invalid].js' } }, generateError: { code: 'VALIDATION_ERROR', - message: '"[invalid]" is not a valid placeholder in "output.entryFileNames" pattern.' + message: '"[invalid]" is not a valid placeholder in the "output.entryFileNames" pattern.' } -}; +}); diff --git a/test/function/samples/invalid-pattern/_config.js b/test/function/samples/invalid-pattern/_config.js index 6275e9e38ac..26d8f1cde7f 100644 --- a/test/function/samples/invalid-pattern/_config.js +++ b/test/function/samples/invalid-pattern/_config.js @@ -1,11 +1,11 @@ -module.exports = { +module.exports = defineTest({ description: 'throws for invalid patterns', options: { - output: { entryFileNames: '\0main.js' } + output: { entryFileNames: '../main.js' } }, generateError: { code: 'VALIDATION_ERROR', message: - 'Invalid pattern "\0main.js" for "output.entryFileNames", patterns can be neither absolute nor relative paths and must not contain invalid characters.' + 'Invalid pattern "../main.js" for "output.entryFileNames", patterns can be neither absolute nor relative paths. If you want your files to be stored in a subdirectory, write its name without a leading slash like this: subdirectory/pattern.' } -}; +}); diff --git a/test/function/samples/invalid-pattern/main.js b/test/function/samples/invalid-pattern/main.js index a9244a453fb..e69de29bb2d 100644 --- a/test/function/samples/invalid-pattern/main.js +++ b/test/function/samples/invalid-pattern/main.js @@ -1 +0,0 @@ -throw new Error('Not executed'); diff --git a/test/function/samples/invalid-property-assignments/_config.js b/test/function/samples/invalid-property-assignments/_config.js index 77c1bcbb785..430ec38353b 100644 --- a/test/function/samples/invalid-property-assignments/_config.js +++ b/test/function/samples/invalid-property-assignments/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'includes invalid property assignments', context: { globalOther: 'other' }, options: { @@ -8,4 +8,4 @@ module.exports = { unknownGlobalSideEffects: false } } -}; +}); diff --git a/test/function/samples/invalid-property-calls/_config.js b/test/function/samples/invalid-property-calls/_config.js index b9a1c9c33f3..eca49dda3b0 100644 --- a/test/function/samples/invalid-property-calls/_config.js +++ b/test/function/samples/invalid-property-calls/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'includes invalid property calls', context: { globalFirst: 'first', globalOther: 'other' }, options: { @@ -8,4 +8,4 @@ module.exports = { unknownGlobalSideEffects: false } } -}; +}); diff --git a/test/function/samples/invalid-top-level-await/_config.js b/test/function/samples/invalid-top-level-await/_config.js index 57540628b06..4586d5a5d62 100644 --- a/test/function/samples/invalid-top-level-await/_config.js +++ b/test/function/samples/invalid-top-level-await/_config.js @@ -1,8 +1,12 @@ -module.exports = { +const path = require('node:path'); +const ID_MAIN = path.join(__dirname, 'main.js'); + +module.exports = defineTest({ description: 'throws for invalid top-level-await format', generateError: { code: 'INVALID_TLA_FORMAT', + id: ID_MAIN, message: - 'Module format cjs does not support top-level await. Use the "es" or "system" output formats rather.' + 'Module format "cjs" does not support top-level await. Use the "es" or "system" output formats rather.' } -}; +}); diff --git a/test/function/samples/invalid-transform-source-function/_config.js b/test/function/samples/invalid-transform-source-function/_config.js index 6f438d91886..375e67a57d6 100644 --- a/test/function/samples/invalid-transform-source-function/_config.js +++ b/test/function/samples/invalid-transform-source-function/_config.js @@ -1,6 +1,6 @@ -const path = require('path'); +const path = require('node:path'); -module.exports = { +module.exports = defineTest({ description: 'throw descriptive error if sourcemapPathTransform-function does not return a string (#3484)', options: { @@ -15,4 +15,4 @@ module.exports = { code: 'VALIDATION_ERROR', message: 'sourcemapPathTransform function must return a string.' } -}; +}); diff --git a/test/function/samples/jsx/missing-jsx-export/_config.js b/test/function/samples/jsx/missing-jsx-export/_config.js new file mode 100644 index 00000000000..5c33d183a3a --- /dev/null +++ b/test/function/samples/jsx/missing-jsx-export/_config.js @@ -0,0 +1,34 @@ +const path = require('node:path'); + +const ID_REACT_JSX = path.join(__dirname, 'react-jsx.js'); +const ID_MAIN = path.join(__dirname, 'main.js'); + +module.exports = defineTest({ + description: 'throws when the JSX factory is not exported', + options: { + jsx: { + jsxImportSource: ID_REACT_JSX, + preset: 'react-jsx' + } + }, + error: { + code: 'MISSING_JSX_EXPORT', + exporter: ID_REACT_JSX, + frame: ` + 1: const Foo = () => {}; + 2: console.log(); + ^`, + id: ID_MAIN, + loc: { + column: 12, + file: ID_MAIN, + line: 2 + }, + message: + 'main.js (2:12): Export "jsx" is not defined in module "react-jsx.js" even though it is needed in "main.js" to provide JSX syntax. Please check your "jsx" option.', + names: ['jsx'], + pos: 34, + url: 'https://rollupjs.org/configuration-options/#jsx', + watchFiles: [ID_MAIN, ID_REACT_JSX] + } +}); diff --git a/test/function/samples/jsx/missing-jsx-export/_expected.js b/test/function/samples/jsx/missing-jsx-export/_expected.js new file mode 100644 index 00000000000..0e6ceaa7ccd --- /dev/null +++ b/test/function/samples/jsx/missing-jsx-export/_expected.js @@ -0,0 +1,16 @@ +const Foo$2 = 'wrong Foo 1'; +const React$1 = 'wrong React 1'; +console.log(Foo$2, React$1); + +var react = { + createElement() { + console.log('createElement'); + } +}; + +const Foo$1 = () => {}; +console.log(/*#__PURE__*/react.createElement(Foo$1, null)); + +const Foo = 'wrong Foo 2'; +const React = 'wrong React 2'; +console.log(Foo, React); diff --git a/test/function/samples/jsx/missing-jsx-export/main.js b/test/function/samples/jsx/missing-jsx-export/main.js new file mode 100644 index 00000000000..4b5671bbbac --- /dev/null +++ b/test/function/samples/jsx/missing-jsx-export/main.js @@ -0,0 +1,2 @@ +const Foo = () => {}; +console.log(); diff --git a/test/function/samples/jsx/missing-jsx-export/react-jsx.js b/test/function/samples/jsx/missing-jsx-export/react-jsx.js new file mode 100644 index 00000000000..0245cde6d1a --- /dev/null +++ b/test/function/samples/jsx/missing-jsx-export/react-jsx.js @@ -0,0 +1 @@ +export default 'actually we need jsx'; diff --git a/test/function/samples/jsx/unknown-mode/_config.js b/test/function/samples/jsx/unknown-mode/_config.js new file mode 100644 index 00000000000..c143e864cb7 --- /dev/null +++ b/test/function/samples/jsx/unknown-mode/_config.js @@ -0,0 +1,14 @@ +module.exports = defineTest({ + description: 'throws when using an unknown jsx mode', + options: { + jsx: { + mode: 'does-not-exist' + } + }, + error: { + code: 'INVALID_OPTION', + message: + 'Invalid value "does-not-exist" for option "jsx.mode" - mode must be "automatic", "classic" or "preserve".', + url: 'https://rollupjs.org/configuration-options/#jsx' + } +}); diff --git a/test/function/samples/jsx/unknown-mode/_expected.js b/test/function/samples/jsx/unknown-mode/_expected.js new file mode 100644 index 00000000000..0e6ceaa7ccd --- /dev/null +++ b/test/function/samples/jsx/unknown-mode/_expected.js @@ -0,0 +1,16 @@ +const Foo$2 = 'wrong Foo 1'; +const React$1 = 'wrong React 1'; +console.log(Foo$2, React$1); + +var react = { + createElement() { + console.log('createElement'); + } +}; + +const Foo$1 = () => {}; +console.log(/*#__PURE__*/react.createElement(Foo$1, null)); + +const Foo = 'wrong Foo 2'; +const React = 'wrong React 2'; +console.log(Foo, React); diff --git a/test/function/samples/jsx/unknown-mode/jsx.js b/test/function/samples/jsx/unknown-mode/jsx.js new file mode 100644 index 00000000000..e4c7f512867 --- /dev/null +++ b/test/function/samples/jsx/unknown-mode/jsx.js @@ -0,0 +1 @@ +export default 'unused'; diff --git a/test/function/samples/jsx/unknown-mode/main.js b/test/function/samples/jsx/unknown-mode/main.js new file mode 100644 index 00000000000..4b5671bbbac --- /dev/null +++ b/test/function/samples/jsx/unknown-mode/main.js @@ -0,0 +1,2 @@ +const Foo = () => {}; +console.log(); diff --git a/test/function/samples/jsx/unnecessary-import-source/_config.js b/test/function/samples/jsx/unnecessary-import-source/_config.js new file mode 100644 index 00000000000..b6019d29303 --- /dev/null +++ b/test/function/samples/jsx/unnecessary-import-source/_config.js @@ -0,0 +1,19 @@ +const path = require('node:path'); + +const ID_JSX = path.join(__dirname, 'jsx.js'); + +module.exports = defineTest({ + description: 'throws when preserving JSX syntax with an unnecessary import source', + options: { + jsx: { + importSource: ID_JSX, + mode: 'preserve' + } + }, + error: { + code: 'INVALID_OPTION', + message: + 'Invalid value for option "jsx" - when preserving JSX and specifying an importSource, you also need to specify a factory or fragment.', + url: 'https://rollupjs.org/configuration-options/#jsx' + } +}); diff --git a/test/function/samples/jsx/unnecessary-import-source/_expected.js b/test/function/samples/jsx/unnecessary-import-source/_expected.js new file mode 100644 index 00000000000..0e6ceaa7ccd --- /dev/null +++ b/test/function/samples/jsx/unnecessary-import-source/_expected.js @@ -0,0 +1,16 @@ +const Foo$2 = 'wrong Foo 1'; +const React$1 = 'wrong React 1'; +console.log(Foo$2, React$1); + +var react = { + createElement() { + console.log('createElement'); + } +}; + +const Foo$1 = () => {}; +console.log(/*#__PURE__*/react.createElement(Foo$1, null)); + +const Foo = 'wrong Foo 2'; +const React = 'wrong React 2'; +console.log(Foo, React); diff --git a/test/function/samples/jsx/unnecessary-import-source/jsx.js b/test/function/samples/jsx/unnecessary-import-source/jsx.js new file mode 100644 index 00000000000..e4c7f512867 --- /dev/null +++ b/test/function/samples/jsx/unnecessary-import-source/jsx.js @@ -0,0 +1 @@ +export default 'unused'; diff --git a/test/function/samples/jsx/unnecessary-import-source/main.js b/test/function/samples/jsx/unnecessary-import-source/main.js new file mode 100644 index 00000000000..4b5671bbbac --- /dev/null +++ b/test/function/samples/jsx/unnecessary-import-source/main.js @@ -0,0 +1,2 @@ +const Foo = () => {}; +console.log(); diff --git a/test/function/samples/keep-cjs-dynamic-import/_config.js b/test/function/samples/keep-cjs-dynamic-import/_config.js new file mode 100644 index 00000000000..1bfa3cc2443 --- /dev/null +++ b/test/function/samples/keep-cjs-dynamic-import/_config.js @@ -0,0 +1,14 @@ +const assert = require('node:assert'); + +module.exports = defineTest({ + description: 'keeps dynamic imports in CJS output by default', + options: { external: ['external-esm'] }, + async exports({ result }) { + const expected = { + __proto__: null, + default: { external: true } + }; + Object.defineProperty(expected, Symbol.toStringTag, { value: 'Module' }); + assert.deepStrictEqual(await result, expected); + } +}); diff --git a/test/function/samples/keep-cjs-dynamic-import/main.js b/test/function/samples/keep-cjs-dynamic-import/main.js new file mode 100644 index 00000000000..8ea197bac62 --- /dev/null +++ b/test/function/samples/keep-cjs-dynamic-import/main.js @@ -0,0 +1 @@ +export const result = import('external-esm'); diff --git a/test/function/samples/keep-the-non-first-assignment-in-destructuring-unknown-array-variables/_config.js b/test/function/samples/keep-the-non-first-assignment-in-destructuring-unknown-array-variables/_config.js new file mode 100644 index 00000000000..61e9488e896 --- /dev/null +++ b/test/function/samples/keep-the-non-first-assignment-in-destructuring-unknown-array-variables/_config.js @@ -0,0 +1,6 @@ +module.exports = defineTest({ + description: 'Keep the non-first assignment in destructuring unknown array variables', + context: { + unknownVariable: [] + } +}); diff --git a/test/function/samples/keep-the-non-first-assignment-in-destructuring-unknown-array-variables/main.js b/test/function/samples/keep-the-non-first-assignment-in-destructuring-unknown-array-variables/main.js new file mode 100644 index 00000000000..4cae78bd080 --- /dev/null +++ b/test/function/samples/keep-the-non-first-assignment-in-destructuring-unknown-array-variables/main.js @@ -0,0 +1,2 @@ +const [a, last2 = { foo: true }] = unknownVariable; +assert.ok(last2.foo); diff --git a/test/function/samples/keep-used-imports-from-pure-external-modules/_config.js b/test/function/samples/keep-used-imports-from-pure-external-modules/_config.js index 586e915ea64..b63182345a9 100644 --- a/test/function/samples/keep-used-imports-from-pure-external-modules/_config.js +++ b/test/function/samples/keep-used-imports-from-pure-external-modules/_config.js @@ -1,6 +1,6 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'imports from pure external modules that are used should not be omitted', options: { external: ['warning'], @@ -10,8 +10,8 @@ module.exports = { }, context: { require: id => { - if (id === 'warning') return arg => assert.equal(arg, 'hi'); + if (id === 'warning') return argument => assert.equal(argument, 'hi'); throw new Error('Unexpected import', id); } } -}; +}); diff --git a/test/function/samples/labeled-statement-conditional-break/_config.js b/test/function/samples/labeled-statement-conditional-break/_config.js index 01c552f861b..53fd176d78b 100644 --- a/test/function/samples/labeled-statement-conditional-break/_config.js +++ b/test/function/samples/labeled-statement-conditional-break/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'handles conditional control flow due to labeled statements' -}; +}); diff --git a/test/function/samples/legal-import-modification/_config.js b/test/function/samples/legal-import-modification/_config.js index 37928575c6b..d53f41da92e 100644 --- a/test/function/samples/legal-import-modification/_config.js +++ b/test/function/samples/legal-import-modification/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'assigning to properties of imported bindings is permitted' -}; +}); diff --git a/test/function/samples/legal-suggested-names/_config.js b/test/function/samples/legal-suggested-names/_config.js index d68f4e75b25..3bca1753545 100644 --- a/test/function/samples/legal-suggested-names/_config.js +++ b/test/function/samples/legal-suggested-names/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'illegal name suggestions are ignored' -}; +}); diff --git a/test/function/samples/load-module-error/buildEnd/_config.js b/test/function/samples/load-module-error/buildEnd/_config.js index 0f3c27d4143..6f28260f7ff 100644 --- a/test/function/samples/load-module-error/buildEnd/_config.js +++ b/test/function/samples/load-module-error/buildEnd/_config.js @@ -1,5 +1,5 @@ -module.exports = { - description: 'buildStart hooks can use this.error', +module.exports = defineTest({ + description: 'buildEnd hooks can use this.error', options: { plugins: [ { @@ -13,7 +13,7 @@ module.exports = { error: { code: 'PLUGIN_ERROR', plugin: 'test', - message: 'nope', + message: '[plugin test] nope', hook: 'buildEnd' } -}; +}); diff --git a/test/function/samples/load-module-error/buildStart/_config.js b/test/function/samples/load-module-error/buildStart/_config.js index 47657147100..fcc14543b60 100644 --- a/test/function/samples/load-module-error/buildStart/_config.js +++ b/test/function/samples/load-module-error/buildStart/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'buildStart hooks can use this.error', options: { plugins: [ @@ -13,7 +13,7 @@ module.exports = { error: { code: 'PLUGIN_ERROR', plugin: 'test', - message: 'nope', + message: '[plugin test] nope', hook: 'buildStart' } -}; +}); diff --git a/test/function/samples/load-module-error/generateBundle/_config.js b/test/function/samples/load-module-error/generateBundle/_config.js index 27ca00e7e9d..cb61e5997b5 100644 --- a/test/function/samples/load-module-error/generateBundle/_config.js +++ b/test/function/samples/load-module-error/generateBundle/_config.js @@ -1,5 +1,5 @@ -module.exports = { - description: 'buildStart hooks can use this.error', +module.exports = defineTest({ + description: 'generateBundle hooks can use this.error', options: { plugins: [ { @@ -13,7 +13,7 @@ module.exports = { generateError: { code: 'PLUGIN_ERROR', plugin: 'test', - message: 'nope', + message: '[plugin test] nope', hook: 'generateBundle' } -}; +}); diff --git a/test/function/samples/load-module-error/load/_config.js b/test/function/samples/load-module-error/load/_config.js index dd8d970e9b3..195843d54a9 100644 --- a/test/function/samples/load-module-error/load/_config.js +++ b/test/function/samples/load-module-error/load/_config.js @@ -1,6 +1,6 @@ -const path = require('path'); +const path = require('node:path'); -module.exports = { +module.exports = defineTest({ description: 'throws when a module cannot be loaded', options: { plugins: [ @@ -24,6 +24,6 @@ module.exports = { hook: 'load', message: `Could not load broken (imported by main.js): It's broken!`, plugin: 'test', - watchFiles: [path.join(__dirname, 'main.js'), 'broken'] + watchFiles: [path.join(__dirname, 'main.js')] } -}; +}); diff --git a/test/function/samples/load-module-error/renderChunk/_config.js b/test/function/samples/load-module-error/renderChunk/_config.js index 3cf2fb6ad5c..fd328c46a6d 100644 --- a/test/function/samples/load-module-error/renderChunk/_config.js +++ b/test/function/samples/load-module-error/renderChunk/_config.js @@ -1,5 +1,5 @@ -module.exports = { - description: 'buildStart hooks can use this.error', +module.exports = defineTest({ + description: 'renderChunk hooks can use this.error', options: { plugins: [ { @@ -13,7 +13,7 @@ module.exports = { generateError: { code: 'PLUGIN_ERROR', plugin: 'test', - message: 'nope', + message: '[plugin test] nope', hook: 'renderChunk' } -}; +}); diff --git a/test/function/samples/load-module-error/renderStart/_config.js b/test/function/samples/load-module-error/renderStart/_config.js index 5c7f9551f4f..cea313619ea 100644 --- a/test/function/samples/load-module-error/renderStart/_config.js +++ b/test/function/samples/load-module-error/renderStart/_config.js @@ -1,5 +1,5 @@ -module.exports = { - description: 'buildStart hooks can use this.error', +module.exports = defineTest({ + description: 'renderStart hooks can use this.error', options: { plugins: [ { @@ -13,7 +13,7 @@ module.exports = { generateError: { code: 'PLUGIN_ERROR', plugin: 'test', - message: 'nope', + message: '[plugin test] nope', hook: 'renderStart' } -}; +}); diff --git a/test/function/samples/load-module-error/resolveId/_config.js b/test/function/samples/load-module-error/resolveId/_config.js index 640b704e011..b63fb4d5014 100644 --- a/test/function/samples/load-module-error/resolveId/_config.js +++ b/test/function/samples/load-module-error/resolveId/_config.js @@ -1,5 +1,5 @@ -module.exports = { - description: 'buildStart hooks can use this.error', +module.exports = defineTest({ + description: 'resolveId hooks can use this.error', options: { plugins: [ { @@ -13,7 +13,7 @@ module.exports = { error: { code: 'PLUGIN_ERROR', plugin: 'test', - message: 'nope', + message: '[plugin test] nope', hook: 'resolveId' } -}; +}); diff --git a/test/function/samples/load-module-error/transform/_config.js b/test/function/samples/load-module-error/transform/_config.js index 582fd5ee4f2..f31ea7dc464 100644 --- a/test/function/samples/load-module-error/transform/_config.js +++ b/test/function/samples/load-module-error/transform/_config.js @@ -1,6 +1,6 @@ -const path = require('path'); +const path = require('node:path'); -module.exports = { +module.exports = defineTest({ description: 'plugin transform hooks can use `this.error({...}, char)` (#1140)', options: { plugins: [ @@ -15,7 +15,7 @@ module.exports = { error: { code: 'PLUGIN_ERROR', plugin: 'test', - message: 'nope', + message: '[plugin test] main.js (1:22): nope', hook: 'transform', id: path.join(__dirname, 'main.js'), watchFiles: [path.join(__dirname, 'main.js')], @@ -30,4 +30,4 @@ module.exports = { ^ ` } -}; +}); diff --git a/test/function/samples/load-resolve-dependencies/_config.js b/test/function/samples/load-resolve-dependencies/_config.js new file mode 100644 index 00000000000..6542590fc3d --- /dev/null +++ b/test/function/samples/load-resolve-dependencies/_config.js @@ -0,0 +1,93 @@ +const assert = require('node:assert'); +const path = require('node:path'); +const ID_FIRST = path.join(__dirname, 'first.js'); +const ID_SECOND = path.join(__dirname, 'second.js'); +const ID_THIRD = path.join(__dirname, 'third.js'); +const DYNAMIC_IMPORT_PROXY_PREFIX = '\0dynamic-import:'; +const chunks = []; + +module.exports = defineTest({ + description: 'allows to wait for dependency resolution in this.load to scan dependency trees', + context: { chunks }, + async exports(exports) { + assert.deepStrictEqual(chunks, []); + const { importSecond } = await exports.importFirst(); + const expectedFirstChunk = [ID_FIRST, ID_SECOND, ID_THIRD]; + assert.deepStrictEqual(chunks, [expectedFirstChunk]); + await importSecond(); + const expectedSecondChunk = [ID_SECOND, ID_THIRD]; + assert.deepStrictEqual(chunks, [expectedFirstChunk, expectedSecondChunk]); + }, + options: { + plugins: [ + { + name: 'add-chunk-log', + async resolveDynamicImport(specifier, importer) { + // Ignore non-static targets + if (!(typeof specifier === 'string')) return; + // Get the id and initial meta information of the import target + const resolved = await this.resolve(specifier, importer); + // Ignore external targets. Explicit externals have the "external" + // property while unresolved imports are "null". + if (resolved && !resolved.external) { + // We trigger loading the module without waiting for it here + // because meta information attached by resolveId hooks (that may + // be contained in "resolved") is only attached to a module the + // first time it is loaded. + // That guarantees this meta information, that plugins like + // commonjs may depend upon, is not lost even if we use "this.load" + // with just the id in the load hook. + this.load(resolved); + return `${DYNAMIC_IMPORT_PROXY_PREFIX}${resolved.id}`; + } + }, + async load(id) { + // Ignore all files but our dynamic import proxies + if (!id.startsWith('\0dynamic-import:')) return null; + const actualId = id.slice(DYNAMIC_IMPORT_PROXY_PREFIX.length); + // To allow loading modules in parallel while keeping complexity low, + // we do not directly await each "this.load" call but put their + // promises into an array where we await each entry via an async for + // loop. + const moduleInfoPromises = [this.load({ id: actualId, resolveDependencies: true })]; + // We track each loaded dependency here so that we do not load a file + // twice and also do not get stuck when there are circular + // dependencies. + const dependencies = new Set([actualId]); + // "importedResolution" tracks the objects created via "resolveId". + // Again we are using those instead of "importedIds" so that + // important meta information is not lost. + for await (const { importedIdResolutions } of moduleInfoPromises) { + for (const resolved of importedIdResolutions) { + if (!dependencies.has(resolved.id)) { + dependencies.add(resolved.id); + moduleInfoPromises.push(this.load({ ...resolved, resolveDependencies: true })); + } + } + } + let code = `chunks.push([${[...dependencies] + .map(JSON.stringify) + .join(', ')}]); export * from ${JSON.stringify(actualId)};`; + // Namespace reexports do not reexport default exports, which is why + // we reexport it manually if it exists + if (this.getModuleInfo(actualId).hasDefaultExport) { + code += `export { default } from ${JSON.stringify(actualId)};`; + } + return code; + }, + async resolveId() { + // We delay resolution just slightly so that we can see the effect of + // resolveDependencies + return new Promise(resolve => setTimeout(() => resolve(null), 10)); + } + } + ] + }, + warnings: [ + { + code: 'CIRCULAR_DEPENDENCY', + ids: [ID_SECOND, ID_THIRD, ID_SECOND], + message: 'Circular dependency: second.js -> third.js -> second.js' + } + ] +}); diff --git a/test/function/samples/load-resolve-dependencies/first.js b/test/function/samples/load-resolve-dependencies/first.js new file mode 100644 index 00000000000..df407ed8c89 --- /dev/null +++ b/test/function/samples/load-resolve-dependencies/first.js @@ -0,0 +1,3 @@ +import './second.js'; +import './third.js'; +export const importSecond = () => import('./second.js'); diff --git a/test/function/samples/load-resolve-dependencies/main.js b/test/function/samples/load-resolve-dependencies/main.js new file mode 100644 index 00000000000..c39b1a72fdb --- /dev/null +++ b/test/function/samples/load-resolve-dependencies/main.js @@ -0,0 +1 @@ +export const importFirst = () => import('./first.js') \ No newline at end of file diff --git a/test/function/samples/load-resolve-dependencies/second.js b/test/function/samples/load-resolve-dependencies/second.js new file mode 100644 index 00000000000..11611eedf50 --- /dev/null +++ b/test/function/samples/load-resolve-dependencies/second.js @@ -0,0 +1 @@ +import './third.js'; diff --git a/test/function/samples/load-resolve-dependencies/third.js b/test/function/samples/load-resolve-dependencies/third.js new file mode 100644 index 00000000000..f986185781a --- /dev/null +++ b/test/function/samples/load-resolve-dependencies/third.js @@ -0,0 +1 @@ +import './second.js'; diff --git a/test/function/samples/load-returns-empty-string/_config.js b/test/function/samples/load-returns-empty-string/_config.js index 206f19d0f8e..bfd45a48d10 100644 --- a/test/function/samples/load-returns-empty-string/_config.js +++ b/test/function/samples/load-returns-empty-string/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'loaders are permitted to return the empty string', options: { plugins: [ @@ -18,4 +18,4 @@ module.exports = { } ] } -}; +}); diff --git a/test/function/samples/load-returns-string-or-null/_config.js b/test/function/samples/load-returns-string-or-null/_config.js index 112cf25d691..56315fcecba 100644 --- a/test/function/samples/load-returns-string-or-null/_config.js +++ b/test/function/samples/load-returns-string-or-null/_config.js @@ -1,6 +1,4 @@ -const path = require('path'); - -module.exports = { +module.exports = defineTest({ description: 'throws error if load returns something wacky', options: { plugins: [ @@ -14,7 +12,7 @@ module.exports = { }, error: { code: 'BAD_LOADER', - message: `Error loading main.js: plugin load hook should return a string, a { code, map } object, or nothing/null`, - watchFiles: [path.join(__dirname, 'main.js')] + message: + 'Error loading "main.js": plugin load hook should return a string, a { code, map } object, or nothing/null.' } -}; +}); diff --git a/test/function/samples/logging/handle-logs-in-plugins/_config.js b/test/function/samples/logging/handle-logs-in-plugins/_config.js new file mode 100644 index 00000000000..7d8e6dd96b6 --- /dev/null +++ b/test/function/samples/logging/handle-logs-in-plugins/_config.js @@ -0,0 +1,217 @@ +const assert = require('node:assert'); +const path = require('node:path'); + +const ID_MAIN = path.join(__dirname, 'main.js'); +const logs = []; + +module.exports = defineTest({ + description: 'allows plugins to read and filter logs', + options: { + logLevel: 'debug', + plugins: [ + { + name: 'first', + buildStart() { + this.info('passed to both plugins'); + }, + onLog(level, log) { + logs.push(['first', level, log]); + if (log.code === 'EVAL') { + return false; + } + if (log.code === 'UNRESOLVED_IMPORT') { + if (level !== 'warn') { + throw new Error( + 'UNRESOLVED_IMPORT log should not be passed back to the first plugin' + ); + } + // This should not be passed back to the first plugin as we are + // logging from the onLog hook + return this.info(log); + } + } + }, + { + name: 'second', + onLog(level, log) { + logs.push(['second', level, log]); + if (log.code === 'EVAL') { + throw new Error('EVAL log should not be passed to second plugin'); + } + if (log.code === 'UNRESOLVED_IMPORT') { + if (level === 'debug') { + throw new Error( + 'UNRESOLVED_IMPORT log should not be passed back to the second plugin' + ); + } + // As we do not filter, the original warn log should also be passed + // to the second plugin + if (level !== 'warn') { + // This should not be passed to either the first or second plugin + // as we are handling a log from the onLog hook of the first + // plugin in the onLog hook of the second plugin + return this.debug(log); + } + } + } + } + ] + }, + after() { + assert.deepEqual(logs, [ + [ + 'first', + 'info', + { message: '[plugin first] passed to both plugins', code: 'PLUGIN_LOG', plugin: 'first' } + ], + [ + 'second', + 'info', + { message: '[plugin first] passed to both plugins', code: 'PLUGIN_LOG', plugin: 'first' } + ], + [ + 'first', + 'warn', + { + code: 'THIS_IS_UNDEFINED', + message: + "main.js (2:5): The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten", + url: 'https://rollupjs.org/troubleshooting/#error-this-is-undefined', + id: ID_MAIN, + pos: 24, + loc: { + column: 5, + file: ID_MAIN, + line: 2 + }, + frame: "1: import 'external';\n2: eval(this);\n ^" + } + ], + [ + 'second', + 'warn', + { + code: 'THIS_IS_UNDEFINED', + message: + "main.js (2:5): The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten", + url: 'https://rollupjs.org/troubleshooting/#error-this-is-undefined', + id: ID_MAIN, + pos: 24, + loc: { + column: 5, + file: ID_MAIN, + line: 2 + }, + frame: "1: import 'external';\n2: eval(this);\n ^" + } + ], + [ + 'first', + 'warn', + { + code: 'UNRESOLVED_IMPORT', + exporter: 'external', + id: ID_MAIN, + message: + '"external" is imported by "main.js", but could not be resolved – treating it as an external dependency.', + url: 'https://rollupjs.org/troubleshooting/#warning-treating-module-as-external-dependency' + } + ], + [ + 'second', + 'info', + { + code: 'UNRESOLVED_IMPORT', + exporter: 'external', + id: ID_MAIN, + message: + '"external" is imported by "main.js", but could not be resolved – treating it as an external dependency.', + url: 'https://rollupjs.org/troubleshooting/#warning-treating-module-as-external-dependency' + } + ], + [ + 'second', + 'warn', + { + code: 'UNRESOLVED_IMPORT', + exporter: 'external', + id: ID_MAIN, + message: + '"external" is imported by "main.js", but could not be resolved – treating it as an external dependency.', + url: 'https://rollupjs.org/troubleshooting/#warning-treating-module-as-external-dependency' + } + ], + [ + 'first', + 'warn', + { + code: 'EVAL', + id: ID_MAIN, + message: + 'main.js (2:0): Use of eval in "main.js" is strongly discouraged as it poses security risks and may cause issues with minification.', + url: 'https://rollupjs.org/troubleshooting/#avoiding-eval', + pos: 19, + loc: { + column: 0, + file: ID_MAIN, + line: 2 + }, + frame: "1: import 'external';\n2: eval(this);\n ^" + } + ] + ]); + }, + logs: [ + { + level: 'debug', + code: 'UNRESOLVED_IMPORT', + exporter: 'external', + id: ID_MAIN, + message: + '"external" is imported by "main.js", but could not be resolved – treating it as an external dependency.', + url: 'https://rollupjs.org/troubleshooting/#warning-treating-module-as-external-dependency' + }, + { + level: 'info', + code: 'UNRESOLVED_IMPORT', + exporter: 'external', + id: ID_MAIN, + message: + '"external" is imported by "main.js", but could not be resolved – treating it as an external dependency.', + url: 'https://rollupjs.org/troubleshooting/#warning-treating-module-as-external-dependency' + }, + { + level: 'warn', + code: 'UNRESOLVED_IMPORT', + exporter: 'external', + id: ID_MAIN, + message: + '"external" is imported by "main.js", but could not be resolved – treating it as an external dependency.', + url: 'https://rollupjs.org/troubleshooting/#warning-treating-module-as-external-dependency' + }, + { + level: 'warn', + code: 'THIS_IS_UNDEFINED', + message: + "main.js (2:5): The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten", + url: 'https://rollupjs.org/troubleshooting/#error-this-is-undefined', + id: ID_MAIN, + pos: 24, + loc: { + column: 5, + file: ID_MAIN, + line: 2 + }, + frame: ` + 1: import 'external'; + 2: eval(this); + ^` + }, + { + level: 'info', + message: '[plugin first] passed to both plugins', + code: 'PLUGIN_LOG', + plugin: 'first' + } + ] +}); diff --git a/test/function/samples/logging/handle-logs-in-plugins/main.js b/test/function/samples/logging/handle-logs-in-plugins/main.js new file mode 100644 index 00000000000..d87759b2a4e --- /dev/null +++ b/test/function/samples/logging/handle-logs-in-plugins/main.js @@ -0,0 +1,2 @@ +import 'external'; +eval(this); diff --git a/test/function/samples/logging/log-from-options/_config.js b/test/function/samples/logging/log-from-options/_config.js new file mode 100644 index 00000000000..7fe79f869c9 --- /dev/null +++ b/test/function/samples/logging/log-from-options/_config.js @@ -0,0 +1,28 @@ +module.exports = defineTest({ + description: 'can log from the options hook', + options: { + logLevel: 'debug', + plugins: [ + { + name: 'test', + options() { + this.debug('debug'); + this.info('info'); + this.warn('warn'); + this.error('error'); + } + } + ] + }, + logs: [ + { level: 'debug', message: 'debug', code: 'PLUGIN_LOG', plugin: 'test' }, + { level: 'info', message: 'info', code: 'PLUGIN_LOG', plugin: 'test' }, + { level: 'warn', message: 'warn', code: 'PLUGIN_WARNING', plugin: 'test' } + ], + error: { + code: 'PLUGIN_ERROR', + hook: 'onLog', + message: '[plugin test] error', + plugin: 'test' + } +}); diff --git a/test/function/samples/logging/log-from-options/main.js b/test/function/samples/logging/log-from-options/main.js new file mode 100644 index 00000000000..cc1d88a24fa --- /dev/null +++ b/test/function/samples/logging/log-from-options/main.js @@ -0,0 +1 @@ +assert.ok(true); diff --git a/test/function/samples/logging/log-from-plugin-onlog-onwarn/_config.js b/test/function/samples/logging/log-from-plugin-onlog-onwarn/_config.js new file mode 100644 index 00000000000..6a480cbaa55 --- /dev/null +++ b/test/function/samples/logging/log-from-plugin-onlog-onwarn/_config.js @@ -0,0 +1,121 @@ +const assert = require('node:assert'); +const { debug, info, warn } = console; +const logs = []; + +module.exports = defineTest({ + description: 'passes logs from plugins to onLog and onwarn', + before() { + console.debug = (...log) => logs.push(['debug', ...log]); + console.info = (...log) => logs.push(['info', ...log]); + console.warn = (...log) => logs.push(['warn', ...log]); + }, + after() { + Object.assign(console, { debug, info, warn }); + assert.deepEqual(logs, [ + [ + 'onLog', + 'warn', + { + message: '[plugin test] warnLog', + pluginCode: 'PLUGIN_CODE', + binding: 'foo', + meta: { test: 'foo' }, + code: 'PLUGIN_WARNING', + plugin: 'test' + } + ], + [ + 'onLog', + 'warn', + { + message: '[plugin test] warnLog', + code: 'PLUGIN_WARNING', + pluginCode: 'PLUGIN_CODE', + plugin: 'test' + } + ], + [ + 'onLog', + 'warn', + { + message: '[plugin test] warnLog', + code: 'PLUGIN_WARNING', + pluginCode: 'THE_CODE', + plugin: 'test' + } + ], + [ + 'onLog', + 'warn', + { message: '[plugin test] warnLog', code: 'PLUGIN_WARNING', plugin: 'test' } + ], + [ + 'onLog', + 'warn', + { message: '[plugin test] warnString', code: 'PLUGIN_WARNING', plugin: 'test' } + ], + [ + 'onLog', + 'info', + { + message: '[plugin test] infoLog', + pluginCode: 'PLUGIN_CODE', + binding: 'foo', + code: 'PLUGIN_LOG', + plugin: 'test' + } + ], + [ + 'onLog', + 'info', + { message: '[plugin test] infoString', code: 'PLUGIN_LOG', plugin: 'test' } + ], + [ + 'onLog', + 'debug', + { + message: '[plugin test] debugLog', + pluginCode: 'PLUGIN_CODE', + binding: 'foo', + code: 'PLUGIN_LOG', + plugin: 'test' + } + ], + [ + 'onLog', + 'debug', + { message: '[plugin test] debugString', code: 'PLUGIN_LOG', plugin: 'test' } + ] + ]); + }, + options: { + logLevel: 'debug', + onwarn(warning) { + logs.push(['onwarn', warning]); + }, + onLog(level, log) { + logs.push(['onLog', level, log]); + }, + plugins: [ + { + name: 'test', + buildStart() { + this.warn(() => ({ + message: 'warnLog', + pluginCode: 'PLUGIN_CODE', + binding: 'foo', + meta: { test: 'foo' } + })); + this.warn({ message: 'warnLog', code: 'THE_CODE', pluginCode: 'PLUGIN_CODE' }); + this.warn({ message: 'warnLog', code: 'THE_CODE' }); + this.warn({ message: 'warnLog' }); + this.warn('warnString'); + this.info({ message: 'infoLog', pluginCode: 'PLUGIN_CODE', binding: 'foo' }); + this.info('infoString'); + this.debug({ message: 'debugLog', pluginCode: 'PLUGIN_CODE', binding: 'foo' }); + this.debug('debugString'); + } + } + ] + } +}); diff --git a/test/function/samples/logging/log-from-plugin-onlog-onwarn/main.js b/test/function/samples/logging/log-from-plugin-onlog-onwarn/main.js new file mode 100644 index 00000000000..cc1d88a24fa --- /dev/null +++ b/test/function/samples/logging/log-from-plugin-onlog-onwarn/main.js @@ -0,0 +1 @@ +assert.ok(true); diff --git a/test/function/samples/logging/log-from-plugin-onlog/_config.js b/test/function/samples/logging/log-from-plugin-onlog/_config.js new file mode 100644 index 00000000000..a5f486fe9d7 --- /dev/null +++ b/test/function/samples/logging/log-from-plugin-onlog/_config.js @@ -0,0 +1,85 @@ +const assert = require('node:assert'); +const { debug, info, warn } = console; +const logs = []; + +module.exports = defineTest({ + description: 'passes logs from plugins to onLog', + before() { + console.debug = (...log) => logs.push(['debug', ...log]); + console.info = (...log) => logs.push(['info', ...log]); + console.warn = (...log) => logs.push(['warn', ...log]); + }, + after() { + Object.assign(console, { debug, info, warn }); + assert.deepEqual(logs, [ + [ + 'onLog', + 'warn', + { + message: '[plugin test] warnLog', + pluginCode: 'PLUGIN_CODE', + binding: 'foo', + code: 'PLUGIN_WARNING', + plugin: 'test' + } + ], + [ + 'onLog', + 'warn', + { message: '[plugin test] warnString', code: 'PLUGIN_WARNING', plugin: 'test' } + ], + [ + 'onLog', + 'info', + { + message: '[plugin test] infoLog', + pluginCode: 'PLUGIN_CODE', + binding: 'foo', + code: 'PLUGIN_LOG', + plugin: 'test' + } + ], + [ + 'onLog', + 'info', + { message: '[plugin test] infoString', code: 'PLUGIN_LOG', plugin: 'test' } + ], + [ + 'onLog', + 'debug', + { + message: '[plugin test] debugLog', + pluginCode: 'PLUGIN_CODE', + binding: 'foo', + code: 'PLUGIN_LOG', + plugin: 'test' + } + ], + [ + 'onLog', + 'debug', + { message: '[plugin test] debugString', code: 'PLUGIN_LOG', plugin: 'test' } + ] + ]); + }, + options: { + logLevel: 'debug', + onwarn: null, + onLog(level, log) { + logs.push(['onLog', level, log]); + }, + plugins: [ + { + name: 'test', + buildStart() { + this.warn({ message: 'warnLog', pluginCode: 'PLUGIN_CODE', binding: 'foo' }); + this.warn('warnString'); + this.info({ message: 'infoLog', pluginCode: 'PLUGIN_CODE', binding: 'foo' }); + this.info('infoString'); + this.debug({ message: 'debugLog', pluginCode: 'PLUGIN_CODE', binding: 'foo' }); + this.debug('debugString'); + } + } + ] + } +}); diff --git a/test/function/samples/logging/log-from-plugin-onlog/main.js b/test/function/samples/logging/log-from-plugin-onlog/main.js new file mode 100644 index 00000000000..cc1d88a24fa --- /dev/null +++ b/test/function/samples/logging/log-from-plugin-onlog/main.js @@ -0,0 +1 @@ +assert.ok(true); diff --git a/test/function/samples/logging/log-from-plugin-onwarn/_config.js b/test/function/samples/logging/log-from-plugin-onwarn/_config.js new file mode 100644 index 00000000000..27670d9d0bd --- /dev/null +++ b/test/function/samples/logging/log-from-plugin-onwarn/_config.js @@ -0,0 +1,52 @@ +const assert = require('node:assert'); +const { debug, info, warn } = console; +const logs = []; + +module.exports = defineTest({ + description: 'passes warn logs from plugins to onwarn', + before() { + console.debug = (...log) => logs.push(['debug', ...log]); + console.info = (...log) => logs.push(['info', ...log]); + console.warn = (...log) => logs.push(['warn', ...log]); + }, + after() { + Object.assign(console, { debug, info, warn }); + assert.deepEqual(logs, [ + [ + 'onwarn', + { + message: '[plugin test] warnLog', + pluginCode: 'PLUGIN_CODE', + binding: 'foo', + code: 'PLUGIN_WARNING', + plugin: 'test' + } + ], + ['onwarn', { message: '[plugin test] warnString', code: 'PLUGIN_WARNING', plugin: 'test' }], + ['info', '[plugin test] infoLog'], + ['info', '[plugin test] infoString'], + ['debug', '[plugin test] debugLog'], + ['debug', '[plugin test] debugString'] + ]); + }, + options: { + logLevel: 'debug', + onwarn(warning) { + logs.push(['onwarn', warning]); + }, + onLog: null, + plugins: [ + { + name: 'test', + buildStart() { + this.warn({ message: 'warnLog', pluginCode: 'PLUGIN_CODE', binding: 'foo' }); + this.warn('warnString'); + this.info({ message: 'infoLog', pluginCode: 'PLUGIN_CODE', binding: 'foo' }); + this.info('infoString'); + this.debug({ message: 'debugLog', pluginCode: 'PLUGIN_CODE', binding: 'foo' }); + this.debug('debugString'); + } + } + ] + } +}); diff --git a/test/function/samples/logging/log-from-plugin-onwarn/main.js b/test/function/samples/logging/log-from-plugin-onwarn/main.js new file mode 100644 index 00000000000..cc1d88a24fa --- /dev/null +++ b/test/function/samples/logging/log-from-plugin-onwarn/main.js @@ -0,0 +1 @@ +assert.ok(true); diff --git a/test/function/samples/logging/log-from-plugin-options-onlog-onwarn/_config.js b/test/function/samples/logging/log-from-plugin-options-onlog-onwarn/_config.js new file mode 100644 index 00000000000..b3709479777 --- /dev/null +++ b/test/function/samples/logging/log-from-plugin-options-onlog-onwarn/_config.js @@ -0,0 +1,92 @@ +const assert = require('node:assert'); +const { debug, info, warn } = console; +const logs = []; + +module.exports = defineTest({ + description: 'passes logs from plugins to onLog and onwarn', + before() { + console.debug = (...log) => logs.push(['debug', ...log]); + console.info = (...log) => logs.push(['info', ...log]); + console.warn = (...log) => logs.push(['warn', ...log]); + }, + after() { + Object.assign(console, { debug, info, warn }); + assert.deepEqual(logs, [ + ['onLog', 'warn', { message: 'warnLog' }], + ['onwarn', { message: 'warnLog' }], + ['warn', 'warnLog'], + [ + 'onLog', + 'warn', + { + message: '[plugin fooPlugin] fooFile (1:2): warnLog', + plugin: 'fooPlugin', + loc: { file: 'fooFile', line: 1, column: 2 } + } + ], + [ + 'onwarn', + { + message: '[plugin fooPlugin] fooFile (1:2): warnLog', + plugin: 'fooPlugin', + loc: { file: 'fooFile', line: 1, column: 2 } + } + ], + ['warn', '[plugin fooPlugin] fooFile (1:2): warnLog'], + ['onLog', 'warn', { message: 'warnLog=' }], + ['onwarn', { message: 'warnLog=' }], + ['onLog', 'warn', { message: 'warnLog+=' }], + ['onwarn', { message: 'warnLog+=' }], + ['warn', 'log was replaced'], + ['onLog', 'warn', { message: 'warnLog-' }], + ['onLog', 'warn', { message: 'warnLog+-' }], + ['info', 'log was replaced'], + ['onLog', 'info', { message: 'infoLog' }], + ['info', 'infoLog'], + ['onLog', 'debug', { message: 'debugLog' }], + ['debug', 'debugLog'] + ]); + assert.strictEqual(logs[0][2].toString(), 'warnLog'); + assert.strictEqual(logs[1][1].toString(), 'warnLog'); + assert.strictEqual(logs[3][2].toString(), '[plugin fooPlugin] fooFile (1:2): warnLog'); + assert.strictEqual(logs[4][1].toString(), '[plugin fooPlugin] fooFile (1:2): warnLog'); + }, + options: { + logLevel: 'debug', + onwarn(warning, handler) { + logs.push(['onwarn', warning]); + if (!warning.message.endsWith('=')) { + handler(warning); + } else if (warning.message.endsWith('+=')) { + handler({ message: 'log was replaced' }); + } + }, + onLog(level, log, handler) { + logs.push(['onLog', level, log]); + if (!log.message.endsWith('-')) { + handler(level, log); + } else if (log.message.endsWith('+-')) { + handler('info', { message: 'log was replaced' }); + } + }, + plugins: [ + { + name: 'test', + buildStart(options) { + options.onLog('warn', { message: 'warnLog' }); + options.onLog('warn', { + message: 'warnLog', + plugin: 'fooPlugin', + loc: { file: 'fooFile', line: 1, column: 2 } + }); + options.onLog('warn', { message: 'warnLog=' }); + options.onLog('warn', { message: 'warnLog+=' }); + options.onLog('warn', { message: 'warnLog-' }); + options.onLog('warn', { message: 'warnLog+-' }); + options.onLog('info', { message: 'infoLog' }); + options.onLog('debug', { message: 'debugLog' }); + } + } + ] + } +}); diff --git a/test/function/samples/logging/log-from-plugin-options-onlog-onwarn/main.js b/test/function/samples/logging/log-from-plugin-options-onlog-onwarn/main.js new file mode 100644 index 00000000000..cc1d88a24fa --- /dev/null +++ b/test/function/samples/logging/log-from-plugin-options-onlog-onwarn/main.js @@ -0,0 +1 @@ +assert.ok(true); diff --git a/test/function/samples/logging/log-from-plugin-options-onlog/_config.js b/test/function/samples/logging/log-from-plugin-options-onlog/_config.js new file mode 100644 index 00000000000..5da91ed8775 --- /dev/null +++ b/test/function/samples/logging/log-from-plugin-options-onlog/_config.js @@ -0,0 +1,72 @@ +const assert = require('node:assert'); +const { debug, info, warn } = console; +const logs = []; + +module.exports = defineTest({ + description: 'passes logs from plugins to onLog', + before() { + console.debug = (...log) => logs.push(['debug', ...log]); + console.info = (...log) => logs.push(['info', ...log]); + console.warn = (...log) => logs.push(['warn', ...log]); + }, + after() { + Object.assign(console, { debug, info, warn }); + assert.deepEqual(logs, [ + ['onLog', 'warn', { message: 'warnLog' }], + ['warn', 'warnLog'], + [ + 'onLog', + 'warn', + { + message: '[plugin fooPlugin] fooFile (1:2): warnLog', + plugin: 'fooPlugin', + loc: { file: 'fooFile', line: 1, column: 2 } + } + ], + ['warn', '[plugin fooPlugin] fooFile (1:2): warnLog'], + ['onLog', 'warn', { message: 'warnLog-' }], + ['onLog', 'warn', { message: 'warnLog+-' }], + ['debug', 'log was replaced'], + ['onLog', 'warn', { message: 'warnLog*-' }], + ['info', 'log was replaced with string'], + ['onLog', 'info', { message: 'infoLog' }], + ['info', 'infoLog'], + ['onLog', 'debug', { message: 'debugLog' }], + ['debug', 'debugLog'] + ]); + assert.strictEqual(logs[0][2].toString(), 'warnLog'); + assert.strictEqual(logs[2][2].toString(), '[plugin fooPlugin] fooFile (1:2): warnLog'); + }, + options: { + logLevel: 'debug', + onwarn: null, + onLog(level, log, handler) { + logs.push(['onLog', level, log]); + if (!log.message.endsWith('-')) { + handler(level, log); + } else if (log.message.endsWith('+-')) { + handler('debug', { message: 'log was replaced' }); + } else if (log.message.endsWith('*-')) { + handler('info', 'log was replaced with string'); + } + }, + plugins: [ + { + name: 'test', + buildStart(options) { + options.onLog('warn', { message: 'warnLog' }); + options.onLog('warn', { + message: 'warnLog', + plugin: 'fooPlugin', + loc: { file: 'fooFile', line: 1, column: 2 } + }); + options.onLog('warn', { message: 'warnLog-' }); + options.onLog('warn', { message: 'warnLog+-' }); + options.onLog('warn', { message: 'warnLog*-' }); + options.onLog('info', { message: 'infoLog' }); + options.onLog('debug', { message: 'debugLog' }); + } + } + ] + } +}); diff --git a/test/function/samples/logging/log-from-plugin-options-onlog/main.js b/test/function/samples/logging/log-from-plugin-options-onlog/main.js new file mode 100644 index 00000000000..cc1d88a24fa --- /dev/null +++ b/test/function/samples/logging/log-from-plugin-options-onlog/main.js @@ -0,0 +1 @@ +assert.ok(true); diff --git a/test/function/samples/logging/log-from-plugin-options-onwarn/_config.js b/test/function/samples/logging/log-from-plugin-options-onwarn/_config.js new file mode 100644 index 00000000000..ebcf3b7b1ea --- /dev/null +++ b/test/function/samples/logging/log-from-plugin-options-onwarn/_config.js @@ -0,0 +1,69 @@ +const assert = require('node:assert'); +const { debug, info, warn } = console; +const logs = []; + +module.exports = defineTest({ + description: 'passes warn logs from plugins to onwarn', + before() { + console.debug = (...log) => logs.push(['debug', ...log]); + console.info = (...log) => logs.push(['info', ...log]); + console.warn = (...log) => logs.push(['warn', ...log]); + }, + after() { + Object.assign(console, { debug, info, warn }); + assert.deepEqual(logs, [ + ['onwarn', { message: 'warnLog' }], + ['warn', 'warnLog'], + [ + 'onwarn', + { + message: '[plugin fooPlugin] fooFile (1:2): warnLog', + plugin: 'fooPlugin', + loc: { file: 'fooFile', line: 1, column: 2 } + } + ], + ['warn', '[plugin fooPlugin] fooFile (1:2): warnLog'], + ['onwarn', { message: 'warnLog-' }], + ['onwarn', { message: 'warnLog+-' }], + ['warn', 'log was replaced'], + ['onwarn', { message: 'warnLog*-' }], + ['warn', 'log was replaced with string'], + ['info', 'infoLog'], + ['debug', 'debugLog'] + ]); + assert.strictEqual(logs[0][1].toString(), 'warnLog'); + assert.strictEqual(logs[2][1].toString(), '[plugin fooPlugin] fooFile (1:2): warnLog'); + }, + options: { + logLevel: 'debug', + onwarn(warning, handler) { + logs.push(['onwarn', warning]); + if (!warning.message.endsWith('-')) { + handler(warning); + } else if (warning.message.endsWith('+-')) { + handler({ message: 'log was replaced' }); + } else if (warning.message.endsWith('*-')) { + handler('log was replaced with string'); + } + }, + onLog: null, + plugins: [ + { + name: 'test', + buildStart(options) { + options.onLog('warn', { message: 'warnLog' }); + options.onLog('warn', { + message: 'warnLog', + plugin: 'fooPlugin', + loc: { file: 'fooFile', line: 1, column: 2 } + }); + options.onLog('warn', { message: 'warnLog-' }); + options.onLog('warn', { message: 'warnLog+-' }); + options.onLog('warn', { message: 'warnLog*-' }); + options.onLog('info', { message: 'infoLog' }); + options.onLog('debug', { message: 'debugLog' }); + } + } + ] + } +}); diff --git a/test/function/samples/logging/log-from-plugin-options-onwarn/main.js b/test/function/samples/logging/log-from-plugin-options-onwarn/main.js new file mode 100644 index 00000000000..cc1d88a24fa --- /dev/null +++ b/test/function/samples/logging/log-from-plugin-options-onwarn/main.js @@ -0,0 +1 @@ +assert.ok(true); diff --git a/test/function/samples/logging/log-from-plugin-options-simple/_config.js b/test/function/samples/logging/log-from-plugin-options-simple/_config.js new file mode 100644 index 00000000000..9cac5dda213 --- /dev/null +++ b/test/function/samples/logging/log-from-plugin-options-simple/_config.js @@ -0,0 +1,44 @@ +const assert = require('node:assert'); +const { debug, info, warn } = console; +const logs = []; +const pluginLogs = []; + +module.exports = defineTest({ + description: 'prints logs from plugins via input options if there are no handlers', + before() { + console.debug = (...log) => logs.push(['debug', ...log]); + console.info = (...log) => logs.push(['info', ...log]); + console.warn = (...log) => logs.push(['warn', ...log]); + }, + after() { + Object.assign(console, { debug, info, warn }); + assert.deepEqual(logs, [ + ['warn', 'warnLog'], + ['info', 'infoLog'], + ['debug', 'debugLog'] + ]); + assert.deepEqual(pluginLogs, [ + ['warn', { message: 'warnLog' }], + ['info', { message: 'infoLog' }], + ['debug', { message: 'debugLog' }] + ]); + }, + options: { + logLevel: 'debug', + onwarn: null, + onLog: null, + plugins: [ + { + name: 'test', + buildStart(options) { + options.onLog('warn', { message: 'warnLog' }); + options.onLog('info', { message: 'infoLog' }); + options.onLog('debug', { message: 'debugLog' }); + }, + onLog(level, log) { + pluginLogs.push([level, log]); + } + } + ] + } +}); diff --git a/test/function/samples/logging/log-from-plugin-options-simple/main.js b/test/function/samples/logging/log-from-plugin-options-simple/main.js new file mode 100644 index 00000000000..cc1d88a24fa --- /dev/null +++ b/test/function/samples/logging/log-from-plugin-options-simple/main.js @@ -0,0 +1 @@ +assert.ok(true); diff --git a/test/function/samples/logging/log-from-plugin-simple/_config.js b/test/function/samples/logging/log-from-plugin-simple/_config.js new file mode 100644 index 00000000000..0e3c4e6463e --- /dev/null +++ b/test/function/samples/logging/log-from-plugin-simple/_config.js @@ -0,0 +1,41 @@ +const assert = require('node:assert'); +const { debug, info, warn } = console; +const logs = []; + +module.exports = defineTest({ + description: 'prints logs from plugins via input options if there are no handlers', + before() { + console.debug = (...log) => logs.push(['debug', ...log]); + console.info = (...log) => logs.push(['info', ...log]); + console.warn = (...log) => logs.push(['warn', ...log]); + }, + after() { + Object.assign(console, { debug, info, warn }); + assert.deepEqual(logs, [ + ['warn', '[plugin test] warnLog'], + ['warn', '[plugin test] warnString'], + ['info', '[plugin test] infoLog'], + ['info', '[plugin test] infoString'], + ['debug', '[plugin test] debugLog'], + ['debug', '[plugin test] debugString'] + ]); + }, + options: { + logLevel: 'debug', + onwarn: null, + onLog: null, + plugins: [ + { + name: 'test', + buildStart() { + this.warn({ message: 'warnLog', pluginCode: 'PLUGIN_CODE', binding: 'foo' }); + this.warn('warnString'); + this.info({ message: 'infoLog', pluginCode: 'PLUGIN_CODE', binding: 'foo' }); + this.info('infoString'); + this.debug({ message: 'debugLog', pluginCode: 'PLUGIN_CODE', binding: 'foo' }); + this.debug('debugString'); + } + } + ] + } +}); diff --git a/test/function/samples/logging/log-from-plugin-simple/main.js b/test/function/samples/logging/log-from-plugin-simple/main.js new file mode 100644 index 00000000000..cc1d88a24fa --- /dev/null +++ b/test/function/samples/logging/log-from-plugin-simple/main.js @@ -0,0 +1 @@ +assert.ok(true); diff --git a/test/function/samples/logging/loglevel-debug/_config.js b/test/function/samples/logging/loglevel-debug/_config.js new file mode 100644 index 00000000000..60e33b6df2f --- /dev/null +++ b/test/function/samples/logging/loglevel-debug/_config.js @@ -0,0 +1,141 @@ +const assert = require('node:assert'); +const path = require('node:path'); + +const { debug, info, warn } = console; +const ID_MAIN = path.join(__dirname, 'main.js'); +const logs = []; +let onLogHookTriggered = false; +let onLogOptionTriggered = false; + +module.exports = defineTest({ + description: 'shows all logs for logLevel:debug', + before() { + console.debug = (...log) => logs.push(['console-debug', ...log]); + console.info = (...log) => logs.push(['console-info', ...log]); + console.warn = (...log) => logs.push(['console-warn', ...log]); + }, + after() { + Object.assign(console, { debug, info, warn }); + assert.deepEqual(logs, [ + ['debug', { message: 'onLog-debug' }], + ['console-debug', 'onLogOption-debug'], + ['console-info', 'onLogOption-info'], + ['console-warn', 'onLogOption-warn'], + ['info', { message: 'onLog-info' }], + ['warn', { message: 'onLog-warn' }], + ['debug', { message: '[plugin test] options-debug', code: 'PLUGIN_LOG', plugin: 'test' }], + ['info', { message: '[plugin test] options-info', code: 'PLUGIN_LOG', plugin: 'test' }], + ['warn', { message: '[plugin test] options-warn', code: 'PLUGIN_WARNING', plugin: 'test' }], + ['debug', { message: '[plugin test] buildStart-debug', code: 'PLUGIN_LOG', plugin: 'test' }], + ['info', { message: '[plugin test] buildStart-info', code: 'PLUGIN_LOG', plugin: 'test' }], + [ + 'warn', + { message: '[plugin test] buildStart-warn', code: 'PLUGIN_WARNING', plugin: 'test' } + ], + ['debug', { message: 'buildStart-options-debug' }], + ['info', { message: 'buildStart-options-info' }], + ['warn', { message: 'buildStart-options-warn' }], + [ + 'debug', + { + message: '[plugin test] main.js: transform-debug', + id: ID_MAIN, + hook: 'transform', + code: 'PLUGIN_LOG', + plugin: 'test' + } + ], + [ + 'info', + { + message: '[plugin test] main.js: transform-info', + id: ID_MAIN, + hook: 'transform', + code: 'PLUGIN_LOG', + plugin: 'test' + } + ], + [ + 'warn', + { + message: '[plugin test] main.js: transform-warn', + id: ID_MAIN, + hook: 'transform', + code: 'PLUGIN_WARNING', + plugin: 'test' + } + ], + [ + 'warn', + { + code: 'EVAL', + id: ID_MAIN, + message: + 'main.js (1:0): Use of eval in "main.js" is strongly discouraged as it poses security risks and may cause issues with minification.', + url: 'https://rollupjs.org/troubleshooting/#avoiding-eval', + pos: 0, + loc: { + column: 0, + file: ID_MAIN, + line: 1 + }, + frame: "1: eval('true');\n ^" + } + ] + ]); + }, + options: { + logLevel: 'debug', + onLog(level, log, handler) { + logs.push([level, log]); + if (!onLogOptionTriggered) { + onLogOptionTriggered = true; + handler('debug', 'onLogOption-debug'); + handler('info', 'onLogOption-info'); + handler('warn', 'onLogOption-warn'); + } + }, + plugins: [ + { + name: 'test', + buildStart(options) { + let triggered = ''; + this.debug(() => { + triggered += 'debug'; + return 'buildStart-debug'; + }); + this.info(() => { + triggered += 'info'; + return 'buildStart-info'; + }); + this.warn(() => { + triggered += 'warn'; + return 'buildStart-warn'; + }); + assert.strictEqual(triggered, 'debuginfowarn'); + options.onLog('debug', { message: 'buildStart-options-debug' }); + options.onLog('info', { message: 'buildStart-options-info' }); + options.onLog('warn', { message: 'buildStart-options-warn' }); + }, + onLog() { + if (!onLogHookTriggered) { + onLogHookTriggered = true; + this.debug('onLog-debug'); + this.info('onLog-info'); + this.warn('onLog-warn'); + } + }, + options() { + this.debug('options-debug'); + this.info('options-info'); + this.warn('options-warn'); + }, + transform() { + this.debug('transform-debug'); + this.info('transform-info'); + this.warn('transform-warn'); + } + } + ] + } +}); diff --git a/test/function/samples/logging/loglevel-debug/main.js b/test/function/samples/logging/loglevel-debug/main.js new file mode 100644 index 00000000000..8395eb3b06d --- /dev/null +++ b/test/function/samples/logging/loglevel-debug/main.js @@ -0,0 +1 @@ +eval('true'); diff --git a/test/function/samples/logging/loglevel-info/_config.js b/test/function/samples/logging/loglevel-info/_config.js new file mode 100644 index 00000000000..5c492aab3f6 --- /dev/null +++ b/test/function/samples/logging/loglevel-info/_config.js @@ -0,0 +1,126 @@ +const assert = require('node:assert'); +const path = require('node:path'); + +const { debug, info, warn } = console; +const ID_MAIN = path.join(__dirname, 'main.js'); +const logs = []; +let onLogHookTriggered = false; +let onLogOptionTriggered = false; + +module.exports = defineTest({ + description: 'does not show debug logs for logLevel:info', + before() { + console.debug = (...log) => logs.push(['console-debug', ...log]); + console.info = (...log) => logs.push(['console-info', ...log]); + console.warn = (...log) => logs.push(['console-warn', ...log]); + }, + after() { + Object.assign(console, { debug, info, warn }); + assert.deepEqual(logs, [ + ['info', { message: 'onLog-info' }], + ['console-info', 'onLogOption-info'], + ['console-warn', 'onLogOption-warn'], + ['warn', { message: 'onLog-warn' }], + ['info', { message: '[plugin test] options-info', code: 'PLUGIN_LOG', plugin: 'test' }], + ['warn', { message: '[plugin test] options-warn', code: 'PLUGIN_WARNING', plugin: 'test' }], + ['info', { message: '[plugin test] buildStart-info', code: 'PLUGIN_LOG', plugin: 'test' }], + [ + 'warn', + { message: '[plugin test] buildStart-warn', code: 'PLUGIN_WARNING', plugin: 'test' } + ], + ['info', { message: 'buildStart-options-info' }], + ['warn', { message: 'buildStart-options-warn' }], + [ + 'info', + { + message: '[plugin test] main.js: transform-info', + id: ID_MAIN, + hook: 'transform', + code: 'PLUGIN_LOG', + plugin: 'test' + } + ], + [ + 'warn', + { + message: '[plugin test] main.js: transform-warn', + id: ID_MAIN, + hook: 'transform', + code: 'PLUGIN_WARNING', + plugin: 'test' + } + ], + [ + 'warn', + { + code: 'EVAL', + id: ID_MAIN, + message: + 'main.js (1:0): Use of eval in "main.js" is strongly discouraged as it poses security risks and may cause issues with minification.', + url: 'https://rollupjs.org/troubleshooting/#avoiding-eval', + pos: 0, + loc: { + column: 0, + file: ID_MAIN, + line: 1 + }, + frame: "1: eval('true');\n ^" + } + ] + ]); + }, + options: { + logLevel: 'info', + onLog(level, log, handler) { + logs.push([level, log]); + if (!onLogOptionTriggered) { + onLogOptionTriggered = true; + handler('debug', 'onLogOption-debug'); + handler('info', 'onLogOption-info'); + handler('warn', 'onLogOption-warn'); + } + }, + plugins: [ + { + name: 'test', + buildStart(options) { + let triggered = ''; + this.debug(() => { + triggered += 'debug'; + return 'buildStart-debug'; + }); + this.info(() => { + triggered += 'info'; + return 'buildStart-info'; + }); + this.warn(() => { + triggered += 'warn'; + return 'buildStart-warn'; + }); + assert.strictEqual(triggered, 'infowarn'); + options.onLog('debug', { message: 'buildStart-options-debug' }); + options.onLog('info', { message: 'buildStart-options-info' }); + options.onLog('warn', { message: 'buildStart-options-warn' }); + }, + onLog() { + if (!onLogHookTriggered) { + onLogHookTriggered = true; + this.debug('onLog-debug'); + this.info('onLog-info'); + this.warn('onLog-warn'); + } + }, + options() { + this.debug('options-debug'); + this.info('options-info'); + this.warn('options-warn'); + }, + transform() { + this.debug('transform-debug'); + this.info('transform-info'); + this.warn('transform-warn'); + } + } + ] + } +}); diff --git a/test/function/samples/logging/loglevel-info/main.js b/test/function/samples/logging/loglevel-info/main.js new file mode 100644 index 00000000000..8395eb3b06d --- /dev/null +++ b/test/function/samples/logging/loglevel-info/main.js @@ -0,0 +1 @@ +eval('true'); diff --git a/test/function/samples/logging/loglevel-silent/_config.js b/test/function/samples/logging/loglevel-silent/_config.js new file mode 100644 index 00000000000..336869aad86 --- /dev/null +++ b/test/function/samples/logging/loglevel-silent/_config.js @@ -0,0 +1,73 @@ +const assert = require('node:assert'); + +const { debug, info, warn } = console; +const logs = []; +let onLogHookTriggered = false; +let onLogOptionTriggered = false; + +module.exports = defineTest({ + description: 'does not show logs for logLevel:silent', + before() { + console.debug = (...log) => logs.push(['console-debug', ...log]); + console.info = (...log) => logs.push(['console-info', ...log]); + console.warn = (...log) => logs.push(['console-warn', ...log]); + }, + after() { + Object.assign(console, { debug, info, warn }); + assert.deepEqual(logs, []); + }, + options: { + logLevel: 'silent', + onLog(level, log, handler) { + logs.push([level, log]); + if (!onLogOptionTriggered) { + onLogOptionTriggered = true; + handler('debug', 'onLogOption-debug'); + handler('info', 'onLogOption-info'); + handler('warn', 'onLogOption-warn'); + } + }, + plugins: [ + { + name: 'test', + buildStart(options) { + let triggered = ''; + this.debug(() => { + triggered += 'debug'; + return 'buildStart-debug'; + }); + this.info(() => { + triggered += 'info'; + return 'buildStart-info'; + }); + this.warn(() => { + triggered += 'warn'; + return 'buildStart-warn'; + }); + assert.strictEqual(triggered, ''); + options.onLog('debug', { message: 'buildStart-options-debug' }); + options.onLog('info', { message: 'buildStart-options-info' }); + options.onLog('warn', { message: 'buildStart-options-warn' }); + }, + onLog() { + if (!onLogHookTriggered) { + onLogHookTriggered = true; + this.debug('onLog-debug'); + this.info('onLog-info'); + this.warn('onLog-warn'); + } + }, + options() { + this.debug('options-debug'); + this.info('options-info'); + this.warn('options-warn'); + }, + transform() { + this.debug('transform-debug'); + this.info('transform-info'); + this.warn('transform-warn'); + } + } + ] + } +}); diff --git a/test/function/samples/logging/loglevel-silent/main.js b/test/function/samples/logging/loglevel-silent/main.js new file mode 100644 index 00000000000..8395eb3b06d --- /dev/null +++ b/test/function/samples/logging/loglevel-silent/main.js @@ -0,0 +1 @@ +eval('true'); diff --git a/test/function/samples/logging/loglevel-warn/_config.js b/test/function/samples/logging/loglevel-warn/_config.js new file mode 100644 index 00000000000..733a645c53e --- /dev/null +++ b/test/function/samples/logging/loglevel-warn/_config.js @@ -0,0 +1,111 @@ +const assert = require('node:assert'); +const path = require('node:path'); + +const { debug, info, warn } = console; +const ID_MAIN = path.join(__dirname, 'main.js'); +const logs = []; +let onLogHookTriggered = false; +let onLogOptionTriggered = false; + +module.exports = defineTest({ + description: 'only shows warning logs for logLevel:warn', + before() { + console.debug = (...log) => logs.push(['console-debug', ...log]); + console.info = (...log) => logs.push(['console-info', ...log]); + console.warn = (...log) => logs.push(['console-warn', ...log]); + }, + after() { + Object.assign(console, { debug, info, warn }); + assert.deepEqual(logs, [ + ['warn', { message: 'onLog-warn' }], + ['console-warn', 'onLogOption-warn'], + ['warn', { message: '[plugin test] options-warn', code: 'PLUGIN_WARNING', plugin: 'test' }], + [ + 'warn', + { message: '[plugin test] buildStart-warn', code: 'PLUGIN_WARNING', plugin: 'test' } + ], + ['warn', { message: 'buildStart-options-warn' }], + [ + 'warn', + { + message: '[plugin test] main.js: transform-warn', + id: ID_MAIN, + hook: 'transform', + code: 'PLUGIN_WARNING', + plugin: 'test' + } + ], + [ + 'warn', + { + code: 'EVAL', + id: ID_MAIN, + message: + 'main.js (1:0): Use of eval in "main.js" is strongly discouraged as it poses security risks and may cause issues with minification.', + url: 'https://rollupjs.org/troubleshooting/#avoiding-eval', + pos: 0, + loc: { + column: 0, + file: ID_MAIN, + line: 1 + }, + frame: "1: eval('true');\n ^" + } + ] + ]); + }, + options: { + logLevel: 'warn', + onLog(level, log, handler) { + logs.push([level, log]); + if (!onLogOptionTriggered) { + onLogOptionTriggered = true; + handler('debug', 'onLogOption-debug'); + handler('info', 'onLogOption-info'); + handler('warn', 'onLogOption-warn'); + } + }, + plugins: [ + { + name: 'test', + buildStart(options) { + let triggered = ''; + this.debug(() => { + triggered += 'debug'; + return 'buildStart-debug'; + }); + this.info(() => { + triggered += 'info'; + return 'buildStart-info'; + }); + this.warn(() => { + triggered += 'warn'; + return 'buildStart-warn'; + }); + assert.strictEqual(triggered, 'warn'); + options.onLog('debug', { message: 'buildStart-options-debug' }); + options.onLog('info', { message: 'buildStart-options-info' }); + options.onLog('warn', { message: 'buildStart-options-warn' }); + }, + onLog() { + if (!onLogHookTriggered) { + onLogHookTriggered = true; + this.debug('onLog-debug'); + this.info('onLog-info'); + this.warn('onLog-warn'); + } + }, + options() { + this.debug('options-debug'); + this.info('options-info'); + this.warn('options-warn'); + }, + transform() { + this.debug('transform-debug'); + this.info('transform-info'); + this.warn('transform-warn'); + } + } + ] + } +}); diff --git a/test/function/samples/logging/loglevel-warn/main.js b/test/function/samples/logging/loglevel-warn/main.js new file mode 100644 index 00000000000..8395eb3b06d --- /dev/null +++ b/test/function/samples/logging/loglevel-warn/main.js @@ -0,0 +1 @@ +eval('true'); diff --git a/test/function/samples/logging/no-log-with-position/_config.js b/test/function/samples/logging/no-log-with-position/_config.js new file mode 100644 index 00000000000..8dcb2cfabf8 --- /dev/null +++ b/test/function/samples/logging/no-log-with-position/_config.js @@ -0,0 +1,74 @@ +module.exports = defineTest({ + description: + 'does not support passing a position to this.warn/info/debug outside the transform hook', + options: { + logLevel: 'debug', + plugins: [ + { + name: 'test', + buildStart() { + this.warn('log-message1', 20); + this.warn('log-message1', { line: 2, column: 1 }); + this.info('log-message1', 20); + this.info('log-message1', { line: 2, column: 1 }); + this.debug('log-message1', 20); + this.debug('log-message1', { line: 2, column: 1 }); + } + } + ] + }, + logs: [ + { + level: 'warn', + code: 'INVALID_LOG_POSITION', + message: + 'Plugin "test" tried to add a file position to a log or warning. This is only supported in the "transform" hook at the moment and will be ignored.' + }, + { + level: 'warn', + code: 'INVALID_LOG_POSITION', + message: + 'Plugin "test" tried to add a file position to a log or warning. This is only supported in the "transform" hook at the moment and will be ignored.' + }, + { + level: 'warn', + code: 'INVALID_LOG_POSITION', + message: + 'Plugin "test" tried to add a file position to a log or warning. This is only supported in the "transform" hook at the moment and will be ignored.' + }, + { + level: 'warn', + code: 'INVALID_LOG_POSITION', + message: + 'Plugin "test" tried to add a file position to a log or warning. This is only supported in the "transform" hook at the moment and will be ignored.' + }, + { + level: 'warn', + code: 'INVALID_LOG_POSITION', + message: + 'Plugin "test" tried to add a file position to a log or warning. This is only supported in the "transform" hook at the moment and will be ignored.' + }, + { + level: 'warn', + code: 'INVALID_LOG_POSITION', + message: + 'Plugin "test" tried to add a file position to a log or warning. This is only supported in the "transform" hook at the moment and will be ignored.' + }, + { + level: 'warn', + message: '[plugin test] log-message1', + code: 'PLUGIN_WARNING', + plugin: 'test' + }, + { + level: 'warn', + message: '[plugin test] log-message1', + code: 'PLUGIN_WARNING', + plugin: 'test' + }, + { level: 'info', message: '[plugin test] log-message1', code: 'PLUGIN_LOG', plugin: 'test' }, + { level: 'info', message: '[plugin test] log-message1', code: 'PLUGIN_LOG', plugin: 'test' }, + { level: 'debug', message: '[plugin test] log-message1', code: 'PLUGIN_LOG', plugin: 'test' }, + { level: 'debug', message: '[plugin test] log-message1', code: 'PLUGIN_LOG', plugin: 'test' } + ] +}); diff --git a/test/function/samples/logging/no-log-with-position/main.js b/test/function/samples/logging/no-log-with-position/main.js new file mode 100644 index 00000000000..49f0fb7dbe9 --- /dev/null +++ b/test/function/samples/logging/no-log-with-position/main.js @@ -0,0 +1,3 @@ +assert.ok(true); +assert.ok(true); +assert.ok(true); diff --git a/test/function/samples/logging/plugin-order/_config.js b/test/function/samples/logging/plugin-order/_config.js new file mode 100644 index 00000000000..48152211149 --- /dev/null +++ b/test/function/samples/logging/plugin-order/_config.js @@ -0,0 +1,61 @@ +const assert = require('node:assert'); + +const logs = []; + +module.exports = defineTest({ + description: 'allows to order plugins when logging', + options: { + logLevel: 'debug', + plugins: [ + { + name: 'first', + buildStart() { + this.info('first'); + this.info('second'); + this.info('third'); + }, + onLog(level, log) { + logs.push(['first', level, log]); + if (log.message.endsWith('first')) { + return false; + } + } + }, + { + name: 'second', + onLog: { + order: 'pre', + handler(level, log) { + logs.push(['second', level, log]); + if (log.message.endsWith('second')) { + return false; + } + } + } + }, + { + name: 'third', + onLog: { + order: 'post', + handler(level, log) { + logs.push(['third', level, log]); + if (log.message.endsWith('third')) { + return false; + } + } + } + } + ] + }, + after() { + assert.deepEqual(logs, [ + ['second', 'info', { message: '[plugin first] first', code: 'PLUGIN_LOG', plugin: 'first' }], + ['first', 'info', { message: '[plugin first] first', code: 'PLUGIN_LOG', plugin: 'first' }], + ['second', 'info', { message: '[plugin first] second', code: 'PLUGIN_LOG', plugin: 'first' }], + ['second', 'info', { message: '[plugin first] third', code: 'PLUGIN_LOG', plugin: 'first' }], + ['first', 'info', { message: '[plugin first] third', code: 'PLUGIN_LOG', plugin: 'first' }], + ['third', 'info', { message: '[plugin first] third', code: 'PLUGIN_LOG', plugin: 'first' }] + ]); + }, + logs: [] +}); diff --git a/test/function/samples/logging/plugin-order/main.js b/test/function/samples/logging/plugin-order/main.js new file mode 100644 index 00000000000..cc1d88a24fa --- /dev/null +++ b/test/function/samples/logging/plugin-order/main.js @@ -0,0 +1 @@ +assert.ok(true); diff --git a/test/function/samples/logging/promote-log-to-error/_config.js b/test/function/samples/logging/promote-log-to-error/_config.js new file mode 100644 index 00000000000..0982a50b859 --- /dev/null +++ b/test/function/samples/logging/promote-log-to-error/_config.js @@ -0,0 +1,38 @@ +const assert = require('node:assert'); +const { debug, info, warn } = console; +const logs = []; + +module.exports = defineTest({ + description: 'allows turning logs into errors', + before() { + console.debug = (...log) => logs.push(['debug', ...log]); + console.info = (...log) => logs.push(['info', ...log]); + console.warn = (...log) => logs.push(['warn', ...log]); + }, + after() { + Object.assign(console, { debug, info, warn }); + assert.deepEqual(logs, []); + }, + options: { + onwarn: null, + onLog(_level, log, handler) { + handler('error', log); + }, + plugins: [ + { + name: 'test', + buildStart() { + this.info({ message: 'info becomes error', code: 'EXTRA_CODE', binding: 'foo' }); + } + } + ] + }, + error: { + binding: 'foo', + code: 'PLUGIN_ERROR', + hook: 'buildStart', + message: '[plugin test] info becomes error', + plugin: 'test', + pluginCode: 'EXTRA_CODE' + } +}); diff --git a/test/function/samples/logging/promote-log-to-error/main.js b/test/function/samples/logging/promote-log-to-error/main.js new file mode 100644 index 00000000000..cc1d88a24fa --- /dev/null +++ b/test/function/samples/logging/promote-log-to-error/main.js @@ -0,0 +1 @@ +assert.ok(true); diff --git a/test/function/samples/logging/this-error-onlog/_config.js b/test/function/samples/logging/this-error-onlog/_config.js new file mode 100644 index 00000000000..624d6c3b3f2 --- /dev/null +++ b/test/function/samples/logging/this-error-onlog/_config.js @@ -0,0 +1,23 @@ +module.exports = defineTest({ + description: 'can turn logs into errors via this.error in the onLog hook', + options: { + plugins: [ + { + name: 'test', + buildStart() { + this.warn({ message: 'test log', code: 'THE_CODE' }); + }, + onLog(level, log) { + this.error(log); + } + } + ] + }, + error: { + code: 'PLUGIN_ERROR', + hook: 'buildStart', + message: '[plugin test] test log', + plugin: 'test', + pluginCode: 'THE_CODE' + } +}); diff --git a/test/function/samples/logging/this-error-onlog/main.js b/test/function/samples/logging/this-error-onlog/main.js new file mode 100644 index 00000000000..cc1d88a24fa --- /dev/null +++ b/test/function/samples/logging/this-error-onlog/main.js @@ -0,0 +1 @@ +assert.ok(true); diff --git a/test/function/samples/logging/transform-log-with-position/_config.js b/test/function/samples/logging/transform-log-with-position/_config.js new file mode 100644 index 00000000000..804a7af4a77 --- /dev/null +++ b/test/function/samples/logging/transform-log-with-position/_config.js @@ -0,0 +1,195 @@ +const path = require('node:path'); +const ID_MAIN = path.join(__dirname, 'main.js'); + +module.exports = defineTest({ + description: 'allows passing a position to this.warn/info/debug in the transform hook', + options: { + logLevel: 'debug', + plugins: [ + { + name: 'test', + transform() { + this.warn('warn-message1', 20); + this.warn('warn-message2', { line: 2, column: 1 }); + this.warn({ message: 'warn-message3', pos: { line: 2, column: 2 } }, 20); + this.info('info-message1', 20); + this.info('info-message2', { line: 2, column: 1 }); + this.info({ message: 'info-message3', pos: { line: 2, column: 2 } }, 20); + this.debug('debug-message1', 20); + this.debug('debug-message2', { line: 2, column: 1 }); + this.debug({ message: 'debug-message3', pos: { line: 2, column: 2 } }, 20); + } + } + ] + }, + logs: [ + { + level: 'warn', + message: '[plugin test] main.js (2:3): warn-message1', + pos: 20, + loc: { + column: 3, + file: ID_MAIN, + line: 2 + }, + frame: ` + 1: assert.ok(true); + 2: assert.ok(true); + ^ + 3: assert.ok(true);`, + id: ID_MAIN, + hook: 'transform', + code: 'PLUGIN_WARNING', + plugin: 'test' + }, + { + level: 'info', + message: '[plugin test] main.js (2:3): info-message1', + pos: 20, + loc: { + column: 3, + file: ID_MAIN, + line: 2 + }, + frame: ` + 1: assert.ok(true); + 2: assert.ok(true); + ^ + 3: assert.ok(true);`, + id: ID_MAIN, + hook: 'transform', + code: 'PLUGIN_LOG', + plugin: 'test' + }, + { + level: 'debug', + message: '[plugin test] main.js (2:3): debug-message1', + pos: 20, + loc: { + column: 3, + file: ID_MAIN, + line: 2 + }, + frame: ` + 1: assert.ok(true); + 2: assert.ok(true); + ^ + 3: assert.ok(true);`, + id: ID_MAIN, + hook: 'transform', + code: 'PLUGIN_LOG', + plugin: 'test' + }, + { + level: 'warn', + message: '[plugin test] main.js (2:1): warn-message2', + loc: { + column: 1, + file: ID_MAIN, + line: 2 + }, + frame: ` + 1: assert.ok(true); + 2: assert.ok(true); + ^ + 3: assert.ok(true);`, + id: ID_MAIN, + hook: 'transform', + code: 'PLUGIN_WARNING', + plugin: 'test' + }, + { + level: 'info', + message: '[plugin test] main.js (2:1): info-message2', + loc: { + column: 1, + file: ID_MAIN, + line: 2 + }, + frame: ` + 1: assert.ok(true); + 2: assert.ok(true); + ^ + 3: assert.ok(true);`, + id: ID_MAIN, + hook: 'transform', + code: 'PLUGIN_LOG', + plugin: 'test' + }, + { + level: 'debug', + message: '[plugin test] main.js (2:1): debug-message2', + loc: { + column: 1, + file: ID_MAIN, + line: 2 + }, + frame: ` + 1: assert.ok(true); + 2: assert.ok(true); + ^ + 3: assert.ok(true);`, + id: ID_MAIN, + hook: 'transform', + code: 'PLUGIN_LOG', + plugin: 'test' + }, + { + level: 'warn', + message: '[plugin test] main.js (2:3): warn-message3', + pos: 20, + loc: { + column: 3, + file: ID_MAIN, + line: 2 + }, + frame: ` + 1: assert.ok(true); + 2: assert.ok(true); + ^ + 3: assert.ok(true);`, + id: ID_MAIN, + hook: 'transform', + code: 'PLUGIN_WARNING', + plugin: 'test' + }, + { + level: 'info', + message: '[plugin test] main.js (2:3): info-message3', + pos: 20, + loc: { + column: 3, + file: ID_MAIN, + line: 2 + }, + frame: ` + 1: assert.ok(true); + 2: assert.ok(true); + ^ + 3: assert.ok(true);`, + id: ID_MAIN, + hook: 'transform', + code: 'PLUGIN_LOG', + plugin: 'test' + }, + { + level: 'debug', + message: '[plugin test] main.js (2:3): debug-message3', + pos: 20, + loc: { + column: 3, + file: ID_MAIN, + line: 2 + }, + frame: ` + 1: assert.ok(true); + 2: assert.ok(true); + ^ + 3: assert.ok(true);`, + id: ID_MAIN, + hook: 'transform', + code: 'PLUGIN_LOG', + plugin: 'test' + } + ] +}); diff --git a/test/function/samples/logging/transform-log-with-position/main.js b/test/function/samples/logging/transform-log-with-position/main.js new file mode 100644 index 00000000000..49f0fb7dbe9 --- /dev/null +++ b/test/function/samples/logging/transform-log-with-position/main.js @@ -0,0 +1,3 @@ +assert.ok(true); +assert.ok(true); +assert.ok(true); diff --git a/test/function/samples/logical-expressions-literal-value/_config.js b/test/function/samples/logical-expressions-literal-value/_config.js new file mode 100644 index 00000000000..32b91103656 --- /dev/null +++ b/test/function/samples/logical-expressions-literal-value/_config.js @@ -0,0 +1,4 @@ +module.exports = defineTest({ + description: 'keep logical expressions', + context: { unknownGlobal: 1 } +}); diff --git a/test/function/samples/logical-expressions-literal-value/main.js b/test/function/samples/logical-expressions-literal-value/main.js new file mode 100644 index 00000000000..0bc3ca4a6e9 --- /dev/null +++ b/test/function/samples/logical-expressions-literal-value/main.js @@ -0,0 +1,9 @@ +var MyEnum = + (unknownGlobal, + (MyEnum2 => { + MyEnum2['foo'] = 'FOO'; + MyEnum2['bar'] = 'BAR'; + return MyEnum2; + })(MyEnum || {})); + +assert.strictEqual(MyEnum.foo, 'FOO'); diff --git a/test/function/samples/long-path-deopt/_config.js b/test/function/samples/long-path-deopt/_config.js new file mode 100644 index 00000000000..926f705cb02 --- /dev/null +++ b/test/function/samples/long-path-deopt/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'deoptimizes getting return expression for long property paths' +}); diff --git a/test/function/samples/long-path-deopt/main.js b/test/function/samples/long-path-deopt/main.js new file mode 100644 index 00000000000..8a00a8a5a0f --- /dev/null +++ b/test/function/samples/long-path-deopt/main.js @@ -0,0 +1,27 @@ +let effect = false; +const obj = { + a: { + b: { + c: { + d: { + e: { + f: { + g: { + h: { + i: { + j: { + k: () => ({ effect: () => (effect = true) }) + } + } + } + } + } + } + } + } + } + } +}; + +obj.a.b.c.d.e.f.g.h.i.j.k().effect(); +assert.ok(effect); diff --git a/test/function/samples/manual-chunks-conflict/_config.js b/test/function/samples/manual-chunks-conflict/_config.js index a3f06ae895c..b5e44eb8c1f 100644 --- a/test/function/samples/manual-chunks-conflict/_config.js +++ b/test/function/samples/manual-chunks-conflict/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'Throws for conflicts between manual chunks', options: { input: ['main.js'], @@ -11,6 +11,6 @@ module.exports = { }, generateError: { code: 'INVALID_CHUNK', - message: `Cannot assign dep.js to the "dep2" chunk as it is already in the "dep1" chunk.` + message: 'Cannot assign "dep.js" to the "dep2" chunk as it is already in the "dep1" chunk.' } -}; +}); diff --git a/test/function/samples/manual-chunks-include-external-modules/_config.js b/test/function/samples/manual-chunks-include-external-modules/_config.js new file mode 100644 index 00000000000..ebf5af09c60 --- /dev/null +++ b/test/function/samples/manual-chunks-include-external-modules/_config.js @@ -0,0 +1,31 @@ +const path = require('node:path'); + +const externalModule = path.join(__dirname, 'external.js'); + +module.exports = defineTest({ + description: + "throws for manualChunks' modules that are resolved as an external module by plugins", + options: { + output: { + manualChunks: { + external: [externalModule] + } + }, + plugins: [ + { + resolveId(id) { + if (id.endsWith('external.js')) { + return { + id: externalModule, + external: true + }; + } + } + } + ] + }, + generateError: { + code: 'EXTERNAL_MODULES_CANNOT_BE_INCLUDED_IN_MANUAL_CHUNKS', + message: `"${externalModule}" cannot be included in manualChunks because it is resolved as an external module by the "external" option or plugins.` + } +}); diff --git a/test/function/samples/manual-chunks-include-external-modules/external.js b/test/function/samples/manual-chunks-include-external-modules/external.js new file mode 100644 index 00000000000..cc1d88a24fa --- /dev/null +++ b/test/function/samples/manual-chunks-include-external-modules/external.js @@ -0,0 +1 @@ +assert.ok(true); diff --git a/test/function/samples/manual-chunks-include-external-modules/main.js b/test/function/samples/manual-chunks-include-external-modules/main.js new file mode 100644 index 00000000000..24f4cd70c44 --- /dev/null +++ b/test/function/samples/manual-chunks-include-external-modules/main.js @@ -0,0 +1 @@ +import './external.js'; diff --git a/test/function/samples/manual-chunks-include-external-modules3/_config.js b/test/function/samples/manual-chunks-include-external-modules3/_config.js new file mode 100644 index 00000000000..af69d3de4c2 --- /dev/null +++ b/test/function/samples/manual-chunks-include-external-modules3/_config.js @@ -0,0 +1,24 @@ +const path = require('node:path'); + +const externalModule = path.join(__dirname, 'external.js'); + +module.exports = defineTest({ + description: + "throws an error EXTERNAL_MODULES_CANNOT_BE_TRANSFORMED_TO_MODULES for manualChunks' modules that are resolved as an external module by the 'external' option", + options: { + external: id => { + if (id.endsWith('external.js')) { + return true; + } + }, + output: { + manualChunks: { + external: [externalModule] + } + } + }, + generateError: { + code: 'EXTERNAL_MODULES_CANNOT_BE_TRANSFORMED_TO_MODULES', + message: `${externalModule} is resolved as a module now, but it was an external module before. Please check whether there are conflicts in your Rollup options "external" and "manualChunks", manualChunks cannot include external modules.` + } +}); diff --git a/test/function/samples/manual-chunks-include-external-modules3/external.js b/test/function/samples/manual-chunks-include-external-modules3/external.js new file mode 100644 index 00000000000..cc1d88a24fa --- /dev/null +++ b/test/function/samples/manual-chunks-include-external-modules3/external.js @@ -0,0 +1 @@ +assert.ok(true); diff --git a/test/function/samples/manual-chunks-include-external-modules3/main.js b/test/function/samples/manual-chunks-include-external-modules3/main.js new file mode 100644 index 00000000000..24f4cd70c44 --- /dev/null +++ b/test/function/samples/manual-chunks-include-external-modules3/main.js @@ -0,0 +1 @@ +import './external.js'; diff --git a/test/function/samples/manual-chunks-info/_config.js b/test/function/samples/manual-chunks-info/_config.js index abf3bde89fe..7b4b40e7d92 100644 --- a/test/function/samples/manual-chunks-info/_config.js +++ b/test/function/samples/manual-chunks-info/_config.js @@ -1,53 +1,58 @@ -const assert = require('assert'); -const path = require('path'); +const assert = require('node:assert'); +const path = require('node:path'); +const { getObject } = require('../../../testHelpers'); function getId(name) { return path.join(__dirname, `${name}.js`); } -module.exports = { +module.exports = defineTest({ description: 'provides additional chunk information to a manualChunks function', options: { external: 'external', output: { manualChunks(id, { getModuleIds, getModuleInfo }) { assert.deepStrictEqual( - [...getModuleIds()], - [getId('main'), 'external', getId('lib'), getId('dynamic')] - ); - assert.deepStrictEqual( - JSON.parse(JSON.stringify([...getModuleIds()].map(id => getModuleInfo(id)))), - [ - { + getObject( + [...getModuleIds()] + .sort() + .map(id => [id, JSON.parse(JSON.stringify(getModuleInfo(id)))]) + ), + { + [getId('dynamic')]: { + id: getId('dynamic'), + attributes: {}, ast: { type: 'Program', start: 0, - end: 123, + end: 88, body: [ { type: 'ExportNamedDeclaration', start: 0, - end: 43, + end: 42, + attributes: [], declaration: { type: 'VariableDeclaration', start: 7, - end: 43, + end: 42, declarations: [ { type: 'VariableDeclarator', start: 13, - end: 42, + end: 41, id: { type: 'Identifier', start: 13, end: 20, name: 'promise' }, init: { type: 'ImportExpression', start: 23, - end: 42, + end: 41, + options: null, source: { type: 'Literal', start: 30, - end: 41, - value: './dynamic', - raw: "'./dynamic'" + end: 40, + value: 'external', + raw: "'external'" } } } @@ -59,77 +64,67 @@ module.exports = { }, { type: 'ExportNamedDeclaration', - start: 44, - end: 85, - declaration: null, - specifiers: [ - { - type: 'ExportSpecifier', - start: 53, - end: 69, - local: { type: 'Identifier', start: 53, end: 60, name: 'default' }, - exported: { type: 'Identifier', start: 64, end: 69, name: 'value' } - } - ], - source: { type: 'Literal', start: 77, end: 84, value: './lib', raw: "'./lib'" } - }, - { - type: 'ExportNamedDeclaration', - start: 86, - end: 122, + start: 43, + end: 87, + attributes: [], declaration: null, specifiers: [ { type: 'ExportSpecifier', - start: 95, - end: 103, - local: { type: 'Identifier', start: 95, end: 103, name: 'external' }, - exported: { type: 'Identifier', start: 95, end: 103, name: 'external' } + start: 52, + end: 71, + local: { type: 'Identifier', start: 52, end: 59, name: 'default' }, + exported: { type: 'Identifier', start: 63, end: 71, name: 'internal' } } ], - source: { - type: 'Literal', - start: 111, - end: 121, - value: 'external', - raw: "'external'" - } + source: { type: 'Literal', start: 79, end: 86, value: './lib', raw: "'./lib'" } } ], sourceType: 'module' }, - code: - "export const promise = import('./dynamic');\nexport { default as value } from './lib';\nexport { external } from 'external';\n", - dynamicallyImportedIds: [getId('dynamic')], - dynamicImporters: [], - hasModuleSideEffects: true, - id: getId('main'), + code: "export const promise = import('external');\nexport { default as internal } from './lib';\n", + dynamicallyImportedIdResolutions: [ + { + attributes: {}, + external: true, + id: 'external', + meta: {}, + moduleSideEffects: true, + resolvedBy: 'rollup', + syntheticNamedExports: false + } + ], + dynamicallyImportedIds: ['external'], + dynamicImporters: [getId('main')], + exportedBindings: { '.': ['promise'], './lib': ['internal'] }, + exports: ['promise', 'internal'], + hasDefaultExport: false, + moduleSideEffects: true, implicitlyLoadedAfterOneOf: [], implicitlyLoadedBefore: [], - importedIds: [getId('lib'), 'external'], + importedIdResolutions: [ + { + attributes: {}, + external: false, + id: getId('lib'), + meta: {}, + moduleSideEffects: true, + resolvedBy: 'rollup', + syntheticNamedExports: false + } + ], + importedIds: [getId('lib')], importers: [], - isEntry: true, - isExternal: false, - meta: {}, - syntheticNamedExports: false - }, - { - ast: null, - code: null, - dynamicallyImportedIds: [], - dynamicImporters: [getId('dynamic')], - hasModuleSideEffects: true, - id: 'external', - implicitlyLoadedAfterOneOf: [], - implicitlyLoadedBefore: [], - importedIds: [], - importers: [getId('main')], isEntry: false, - isExternal: true, + isExternal: false, + isIncluded: true, meta: {}, + safeVariableNames: null, syntheticNamedExports: false }, - { + [getId('lib')]: { + id: getId('lib'), + attributes: {}, ast: { type: 'Program', start: 0, @@ -145,49 +140,59 @@ module.exports = { sourceType: 'module' }, code: 'export default 42;\n', + dynamicallyImportedIdResolutions: [], dynamicallyImportedIds: [], dynamicImporters: [], - hasModuleSideEffects: true, - id: getId('lib'), + exportedBindings: { '.': ['default'] }, + exports: ['default'], + hasDefaultExport: true, + moduleSideEffects: true, implicitlyLoadedAfterOneOf: [], implicitlyLoadedBefore: [], + importedIdResolutions: [], importedIds: [], importers: [getId('dynamic'), getId('main')], isEntry: false, isExternal: false, + isIncluded: true, meta: {}, + safeVariableNames: null, syntheticNamedExports: false }, - { + [getId('main')]: { + id: getId('main'), + attributes: {}, ast: { type: 'Program', start: 0, - end: 88, + end: 123, body: [ { type: 'ExportNamedDeclaration', start: 0, - end: 42, + end: 43, + attributes: [], declaration: { type: 'VariableDeclaration', start: 7, - end: 42, + end: 43, declarations: [ { type: 'VariableDeclarator', start: 13, - end: 41, + end: 42, id: { type: 'Identifier', start: 13, end: 20, name: 'promise' }, init: { type: 'ImportExpression', start: 23, - end: 41, + end: 42, + options: null, source: { type: 'Literal', start: 30, - end: 40, - value: 'external', - raw: "'external'" + end: 41, + value: './dynamic', + raw: "'./dynamic'" } } } @@ -199,41 +204,127 @@ module.exports = { }, { type: 'ExportNamedDeclaration', - start: 43, - end: 87, + start: 44, + end: 85, + attributes: [], declaration: null, specifiers: [ { type: 'ExportSpecifier', - start: 52, - end: 71, - local: { type: 'Identifier', start: 52, end: 59, name: 'default' }, - exported: { type: 'Identifier', start: 63, end: 71, name: 'internal' } + start: 53, + end: 69, + local: { type: 'Identifier', start: 53, end: 60, name: 'default' }, + exported: { type: 'Identifier', start: 64, end: 69, name: 'value' } } ], - source: { type: 'Literal', start: 79, end: 86, value: './lib', raw: "'./lib'" } + source: { type: 'Literal', start: 77, end: 84, value: './lib', raw: "'./lib'" } + }, + { + type: 'ExportNamedDeclaration', + start: 86, + end: 122, + attributes: [], + declaration: null, + specifiers: [ + { + type: 'ExportSpecifier', + start: 95, + end: 103, + local: { type: 'Identifier', start: 95, end: 103, name: 'external' }, + exported: { type: 'Identifier', start: 95, end: 103, name: 'external' } + } + ], + source: { + type: 'Literal', + start: 111, + end: 121, + value: 'external', + raw: "'external'" + } } ], sourceType: 'module' }, - code: - "export const promise = import('external');\nexport { default as internal } from './lib';\n", - dynamicallyImportedIds: ['external'], - dynamicImporters: [getId('main')], - hasModuleSideEffects: true, - id: getId('dynamic'), + code: "export const promise = import('./dynamic');\nexport { default as value } from './lib';\nexport { external } from 'external';\n", + dynamicallyImportedIdResolutions: [ + { + attributes: {}, + external: false, + id: getId('dynamic'), + meta: {}, + moduleSideEffects: true, + resolvedBy: 'rollup', + syntheticNamedExports: false + } + ], + dynamicallyImportedIds: [getId('dynamic')], + dynamicImporters: [], + exportedBindings: { + '.': ['promise'], + './lib': ['value'], + external: ['external'] + }, + exports: ['promise', 'value', 'external'], + hasDefaultExport: false, + moduleSideEffects: true, implicitlyLoadedAfterOneOf: [], implicitlyLoadedBefore: [], - importedIds: [getId('lib')], + importedIdResolutions: [ + { + attributes: {}, + external: false, + id: getId('lib'), + meta: {}, + moduleSideEffects: true, + resolvedBy: 'rollup', + syntheticNamedExports: false + }, + { + attributes: {}, + external: true, + id: 'external', + meta: {}, + moduleSideEffects: true, + resolvedBy: 'rollup', + syntheticNamedExports: false + } + ], + importedIds: [getId('lib'), 'external'], importers: [], - isEntry: false, + isEntry: true, isExternal: false, + isIncluded: true, + meta: {}, + safeVariableNames: null, + syntheticNamedExports: false + }, + external: { + id: 'external', + attributes: {}, + ast: null, + code: null, + dynamicallyImportedIdResolutions: [], + dynamicallyImportedIds: [], + dynamicImporters: [getId('dynamic')], + exportedBindings: null, + exports: null, + hasDefaultExport: null, + moduleSideEffects: true, + implicitlyLoadedAfterOneOf: [], + implicitlyLoadedBefore: [], + importedIdResolutions: [], + importedIds: [], + importers: [getId('main')], + isEntry: false, + isExternal: true, + isIncluded: null, meta: {}, + safeVariableNames: null, syntheticNamedExports: false } - ] + } ); } } } -}; +}); diff --git a/test/function/samples/manual-chunks-order/_config.js b/test/function/samples/manual-chunks-order/_config.js new file mode 100644 index 00000000000..90fda86561c --- /dev/null +++ b/test/function/samples/manual-chunks-order/_config.js @@ -0,0 +1,11 @@ +module.exports = defineTest({ + description: 'sorts manual chunks by entry index', + options: { + output: { + manualChunks: { + chunk1: ['module1.js'], + chunk2: ['module2.js'] + } + } + } +}); diff --git a/test/function/samples/manual-chunks-order/main.js b/test/function/samples/manual-chunks-order/main.js new file mode 100644 index 00000000000..5cf2c8e6843 --- /dev/null +++ b/test/function/samples/manual-chunks-order/main.js @@ -0,0 +1,3 @@ +import { module1 } from './module1.js'; + +assert.ok(module1); diff --git a/test/function/samples/manual-chunks-order/module1.js b/test/function/samples/manual-chunks-order/module1.js new file mode 100644 index 00000000000..fa0d5a2ab50 --- /dev/null +++ b/test/function/samples/manual-chunks-order/module1.js @@ -0,0 +1,4 @@ +import { module2 } from './module2.js'; +import { util } from './util.js'; + +export const module1 = 'module1' + module2 + util; diff --git a/test/function/samples/manual-chunks-order/module2.js b/test/function/samples/manual-chunks-order/module2.js new file mode 100644 index 00000000000..f97824dd590 --- /dev/null +++ b/test/function/samples/manual-chunks-order/module2.js @@ -0,0 +1,3 @@ +import { util } from './util.js'; + +export const module2 = 'module2' + util; \ No newline at end of file diff --git a/test/function/samples/manual-chunks-order/util.js b/test/function/samples/manual-chunks-order/util.js new file mode 100644 index 00000000000..1ee4b7700c8 --- /dev/null +++ b/test/function/samples/manual-chunks-order/util.js @@ -0,0 +1 @@ +export const util = 'util'; \ No newline at end of file diff --git a/test/function/samples/mark-namespace-members/_config.js b/test/function/samples/mark-namespace-members/_config.js index 455a6c6c9e5..9a1d833f06e 100644 --- a/test/function/samples/mark-namespace-members/_config.js +++ b/test/function/samples/mark-namespace-members/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'marks namespace members' -}; +}); diff --git a/test/function/samples/max-parallel-file-operations/default/1.js b/test/function/samples/max-parallel-file-operations/default/1.js new file mode 100644 index 00000000000..877dd1fbb70 --- /dev/null +++ b/test/function/samples/max-parallel-file-operations/default/1.js @@ -0,0 +1 @@ +export const x1 = 1; diff --git a/test/function/samples/max-parallel-file-operations/default/2.js b/test/function/samples/max-parallel-file-operations/default/2.js new file mode 100644 index 00000000000..c269ae0d246 --- /dev/null +++ b/test/function/samples/max-parallel-file-operations/default/2.js @@ -0,0 +1 @@ +export const x2 = 2; diff --git a/test/function/samples/max-parallel-file-operations/default/3.js b/test/function/samples/max-parallel-file-operations/default/3.js new file mode 100644 index 00000000000..1c323539956 --- /dev/null +++ b/test/function/samples/max-parallel-file-operations/default/3.js @@ -0,0 +1 @@ +export const x3 = 3; diff --git a/test/function/samples/max-parallel-file-operations/default/4.js b/test/function/samples/max-parallel-file-operations/default/4.js new file mode 100644 index 00000000000..1b01b419ace --- /dev/null +++ b/test/function/samples/max-parallel-file-operations/default/4.js @@ -0,0 +1 @@ +export const x4 = 4; diff --git a/test/function/samples/max-parallel-file-operations/default/5.js b/test/function/samples/max-parallel-file-operations/default/5.js new file mode 100644 index 00000000000..734bf3f6f04 --- /dev/null +++ b/test/function/samples/max-parallel-file-operations/default/5.js @@ -0,0 +1 @@ +export const x5 = 5; diff --git a/test/function/samples/max-parallel-file-operations/default/_config.js b/test/function/samples/max-parallel-file-operations/default/_config.js new file mode 100644 index 00000000000..5710cdd1a45 --- /dev/null +++ b/test/function/samples/max-parallel-file-operations/default/_config.js @@ -0,0 +1,28 @@ +const assert = require('node:assert'); +const { promises: fs } = require('node:fs'); +const { wait } = require('../../../../testHelpers'); + +const fsReadFile = fs.readFile; +let currentReads = 0; +let maxReads = 0; + +module.exports = defineTest({ + description: 'maxParallelFileOps not set', + options: { + fs + }, + before() { + fs.readFile = async (path, options) => { + currentReads++; + maxReads = Math.max(maxReads, currentReads); + const content = await fsReadFile(path, options); + await wait(50); + currentReads--; + return content; + }; + }, + after() { + fs.readFile = fsReadFile; + assert.strictEqual(maxReads, 5, 'Wrong number of parallel file reads: ' + maxReads); + } +}); diff --git a/test/function/samples/max-parallel-file-operations/default/main.js b/test/function/samples/max-parallel-file-operations/default/main.js new file mode 100644 index 00000000000..5f0a705e464 --- /dev/null +++ b/test/function/samples/max-parallel-file-operations/default/main.js @@ -0,0 +1,5 @@ +export * from './1'; +export * from './2'; +export * from './3'; +export * from './4'; +export * from './5'; diff --git a/test/function/samples/max-parallel-file-operations/error/_config.js b/test/function/samples/max-parallel-file-operations/error/_config.js new file mode 100644 index 00000000000..ff46cae7b60 --- /dev/null +++ b/test/function/samples/max-parallel-file-operations/error/_config.js @@ -0,0 +1,32 @@ +const { promises: fs } = require('node:fs'); +const path = require('node:path'); +const { loader } = require('../../../../testHelpers.js'); + +const fsReadFile = fs.readFile; + +module.exports = defineTest({ + description: 'maxParallelFileOps: fileRead error is forwarded', + options: { + input: 'main', + plugins: loader({ + main: `import {foo} from './dep';` + }), + fs + }, + before() { + fs.readFile = (path, options) => { + if (path.endsWith('dep.js')) { + throw new Error('broken'); + } + + fsReadFile(path, options); + }; + }, + after() { + fs.readFile = fsReadFile; + }, + error: { + message: `Could not load ${path.join(__dirname, 'dep.js')} (imported by main): broken`, + watchFiles: [path.join(__dirname, 'dep.js')] + } +}); diff --git a/test/function/samples/max-parallel-file-operations/error/dep.js b/test/function/samples/max-parallel-file-operations/error/dep.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/function/samples/max-parallel-file-operations/infinity/1.js b/test/function/samples/max-parallel-file-operations/infinity/1.js new file mode 100644 index 00000000000..877dd1fbb70 --- /dev/null +++ b/test/function/samples/max-parallel-file-operations/infinity/1.js @@ -0,0 +1 @@ +export const x1 = 1; diff --git a/test/function/samples/max-parallel-file-operations/infinity/2.js b/test/function/samples/max-parallel-file-operations/infinity/2.js new file mode 100644 index 00000000000..c269ae0d246 --- /dev/null +++ b/test/function/samples/max-parallel-file-operations/infinity/2.js @@ -0,0 +1 @@ +export const x2 = 2; diff --git a/test/function/samples/max-parallel-file-operations/infinity/3.js b/test/function/samples/max-parallel-file-operations/infinity/3.js new file mode 100644 index 00000000000..1c323539956 --- /dev/null +++ b/test/function/samples/max-parallel-file-operations/infinity/3.js @@ -0,0 +1 @@ +export const x3 = 3; diff --git a/test/function/samples/max-parallel-file-operations/infinity/4.js b/test/function/samples/max-parallel-file-operations/infinity/4.js new file mode 100644 index 00000000000..1b01b419ace --- /dev/null +++ b/test/function/samples/max-parallel-file-operations/infinity/4.js @@ -0,0 +1 @@ +export const x4 = 4; diff --git a/test/function/samples/max-parallel-file-operations/infinity/5.js b/test/function/samples/max-parallel-file-operations/infinity/5.js new file mode 100644 index 00000000000..734bf3f6f04 --- /dev/null +++ b/test/function/samples/max-parallel-file-operations/infinity/5.js @@ -0,0 +1 @@ +export const x5 = 5; diff --git a/test/function/samples/max-parallel-file-operations/infinity/_config.js b/test/function/samples/max-parallel-file-operations/infinity/_config.js new file mode 100644 index 00000000000..a672fb4ad56 --- /dev/null +++ b/test/function/samples/max-parallel-file-operations/infinity/_config.js @@ -0,0 +1,29 @@ +const assert = require('node:assert'); +const { promises: fs } = require('node:fs'); +const { wait } = require('../../../../testHelpers'); + +const fsReadFile = fs.readFile; +let currentReads = 0; +let maxReads = 0; + +module.exports = defineTest({ + description: 'maxParallelFileOps set to infinity', + options: { + maxParallelFileOps: 0, + fs + }, + before() { + fs.readFile = async (path, options) => { + currentReads++; + maxReads = Math.max(maxReads, currentReads); + const content = await fsReadFile(path, options); + await wait(50); + currentReads--; + return content; + }; + }, + after() { + fs.readFile = fsReadFile; + assert.strictEqual(maxReads, 5, 'Wrong number of parallel file reads: ' + maxReads); + } +}); diff --git a/test/function/samples/max-parallel-file-operations/infinity/main.js b/test/function/samples/max-parallel-file-operations/infinity/main.js new file mode 100644 index 00000000000..5f0a705e464 --- /dev/null +++ b/test/function/samples/max-parallel-file-operations/infinity/main.js @@ -0,0 +1,5 @@ +export * from './1'; +export * from './2'; +export * from './3'; +export * from './4'; +export * from './5'; diff --git a/test/function/samples/max-parallel-file-operations/set/1.js b/test/function/samples/max-parallel-file-operations/set/1.js new file mode 100644 index 00000000000..877dd1fbb70 --- /dev/null +++ b/test/function/samples/max-parallel-file-operations/set/1.js @@ -0,0 +1 @@ +export const x1 = 1; diff --git a/test/function/samples/max-parallel-file-operations/set/2.js b/test/function/samples/max-parallel-file-operations/set/2.js new file mode 100644 index 00000000000..c269ae0d246 --- /dev/null +++ b/test/function/samples/max-parallel-file-operations/set/2.js @@ -0,0 +1 @@ +export const x2 = 2; diff --git a/test/function/samples/max-parallel-file-operations/set/3.js b/test/function/samples/max-parallel-file-operations/set/3.js new file mode 100644 index 00000000000..1c323539956 --- /dev/null +++ b/test/function/samples/max-parallel-file-operations/set/3.js @@ -0,0 +1 @@ +export const x3 = 3; diff --git a/test/function/samples/max-parallel-file-operations/set/4.js b/test/function/samples/max-parallel-file-operations/set/4.js new file mode 100644 index 00000000000..1b01b419ace --- /dev/null +++ b/test/function/samples/max-parallel-file-operations/set/4.js @@ -0,0 +1 @@ +export const x4 = 4; diff --git a/test/function/samples/max-parallel-file-operations/set/5.js b/test/function/samples/max-parallel-file-operations/set/5.js new file mode 100644 index 00000000000..734bf3f6f04 --- /dev/null +++ b/test/function/samples/max-parallel-file-operations/set/5.js @@ -0,0 +1 @@ +export const x5 = 5; diff --git a/test/function/samples/max-parallel-file-operations/set/_config.js b/test/function/samples/max-parallel-file-operations/set/_config.js new file mode 100644 index 00000000000..8dfac8f3f26 --- /dev/null +++ b/test/function/samples/max-parallel-file-operations/set/_config.js @@ -0,0 +1,29 @@ +const assert = require('node:assert'); +const { promises: fs } = require('node:fs'); +const { wait } = require('../../../../testHelpers'); + +const fsReadFile = fs.readFile; +let currentReads = 0; +let maxReads = 0; + +module.exports = defineTest({ + description: 'maxParallelFileOps set to 3', + options: { + maxParallelFileOps: 3, + fs + }, + before() { + fs.readFile = async (path, options) => { + currentReads++; + maxReads = Math.max(maxReads, currentReads); + const content = await fsReadFile(path, options); + await wait(50); + currentReads--; + return content; + }; + }, + after() { + fs.readFile = fsReadFile; + assert.strictEqual(maxReads, 3, 'Wrong number of parallel file reads: ' + maxReads); + } +}); diff --git a/test/function/samples/max-parallel-file-operations/set/main.js b/test/function/samples/max-parallel-file-operations/set/main.js new file mode 100644 index 00000000000..5f0a705e464 --- /dev/null +++ b/test/function/samples/max-parallel-file-operations/set/main.js @@ -0,0 +1,5 @@ +export * from './1'; +export * from './2'; +export * from './3'; +export * from './4'; +export * from './5'; diff --git a/test/function/samples/max-parallel-file-operations/with-plugin/1.js b/test/function/samples/max-parallel-file-operations/with-plugin/1.js new file mode 100644 index 00000000000..877dd1fbb70 --- /dev/null +++ b/test/function/samples/max-parallel-file-operations/with-plugin/1.js @@ -0,0 +1 @@ +export const x1 = 1; diff --git a/test/function/samples/max-parallel-file-operations/with-plugin/2.js b/test/function/samples/max-parallel-file-operations/with-plugin/2.js new file mode 100644 index 00000000000..c269ae0d246 --- /dev/null +++ b/test/function/samples/max-parallel-file-operations/with-plugin/2.js @@ -0,0 +1 @@ +export const x2 = 2; diff --git a/test/function/samples/max-parallel-file-operations/with-plugin/3.js b/test/function/samples/max-parallel-file-operations/with-plugin/3.js new file mode 100644 index 00000000000..1c323539956 --- /dev/null +++ b/test/function/samples/max-parallel-file-operations/with-plugin/3.js @@ -0,0 +1 @@ +export const x3 = 3; diff --git a/test/function/samples/max-parallel-file-operations/with-plugin/4.js b/test/function/samples/max-parallel-file-operations/with-plugin/4.js new file mode 100644 index 00000000000..1b01b419ace --- /dev/null +++ b/test/function/samples/max-parallel-file-operations/with-plugin/4.js @@ -0,0 +1 @@ +export const x4 = 4; diff --git a/test/function/samples/max-parallel-file-operations/with-plugin/5.js b/test/function/samples/max-parallel-file-operations/with-plugin/5.js new file mode 100644 index 00000000000..734bf3f6f04 --- /dev/null +++ b/test/function/samples/max-parallel-file-operations/with-plugin/5.js @@ -0,0 +1 @@ +export const x5 = 5; diff --git a/test/function/samples/max-parallel-file-operations/with-plugin/_config.js b/test/function/samples/max-parallel-file-operations/with-plugin/_config.js new file mode 100644 index 00000000000..947a7ee1796 --- /dev/null +++ b/test/function/samples/max-parallel-file-operations/with-plugin/_config.js @@ -0,0 +1,35 @@ +const assert = require('node:assert'); +const { promises: fs } = require('node:fs'); +const { wait } = require('../../../../testHelpers'); + +const fsReadFile = fs.readFile; +let currentReads = 0; +let maxReads = 0; + +module.exports = defineTest({ + description: 'maxParallelFileOps with plugin', + options: { + maxParallelFileOps: 3, + plugins: [ + { + load(id) { + return fs.readFile(id, 'utf8'); + } + } + ] + }, + before() { + fs.readFile = async (path, options) => { + currentReads++; + maxReads = Math.max(maxReads, currentReads); + const content = await fsReadFile(path, options); + await wait(50); + currentReads--; + return content; + }; + }, + after() { + fs.readFile = fsReadFile; + assert.strictEqual(maxReads, 3, 'Wrong number of parallel file reads: ' + maxReads); + } +}); diff --git a/test/function/samples/max-parallel-file-operations/with-plugin/main.js b/test/function/samples/max-parallel-file-operations/with-plugin/main.js new file mode 100644 index 00000000000..5f0a705e464 --- /dev/null +++ b/test/function/samples/max-parallel-file-operations/with-plugin/main.js @@ -0,0 +1,5 @@ +export * from './1'; +export * from './2'; +export * from './3'; +export * from './4'; +export * from './5'; diff --git a/test/function/samples/member-expression-assignment-in-function/_config.js b/test/function/samples/member-expression-assignment-in-function/_config.js index b8c93181d67..efec2823c8c 100644 --- a/test/function/samples/member-expression-assignment-in-function/_config.js +++ b/test/function/samples/member-expression-assignment-in-function/_config.js @@ -1,10 +1,10 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'detect side effect in member expression assignment when not top level', code(code) { - assert.equal(code.indexOf('function set(key, value) { foo[key] = value; }') >= 0, true, code); - assert.equal(code.indexOf('set("bar", 2);') >= 0, true, code); - assert.equal(code.indexOf('set("qux", 3);') >= 0, true, code); + assert.ok(code.includes('function set(key, value) { foo[key] = value; }'), code); + assert.ok(code.includes('set("bar", 2);'), code); + assert.ok(code.includes('set("qux", 3);'), code); } -}; +}); diff --git a/test/function/samples/merged-namespace-live-bindings/_config.js b/test/function/samples/merged-namespace-live-bindings/_config.js new file mode 100644 index 00000000000..cb279471181 --- /dev/null +++ b/test/function/samples/merged-namespace-live-bindings/_config.js @@ -0,0 +1,22 @@ +module.exports = defineTest({ + description: 'respects getters when accessing properties of an instance', + context: { + require(id) { + if (id === 'external') { + let external = 'original'; + return { + get external() { + return external; + }, + updateExternal() { + external = 'updated'; + } + }; + } + throw new Error(`Unexpected import "${id}".`); + } + }, + options: { + external: ['external'] + } +}); diff --git a/test/function/samples/merged-namespace-live-bindings/internal.js b/test/function/samples/merged-namespace-live-bindings/internal.js new file mode 100644 index 00000000000..4417abc413d --- /dev/null +++ b/test/function/samples/merged-namespace-live-bindings/internal.js @@ -0,0 +1,3 @@ +export let internal = 'original'; +export const updateInternal = () => (internal = 'updated'); +export default 'ignored'; diff --git a/test/function/samples/merged-namespace-live-bindings/main.js b/test/function/samples/merged-namespace-live-bindings/main.js new file mode 100644 index 00000000000..bf26be46437 --- /dev/null +++ b/test/function/samples/merged-namespace-live-bindings/main.js @@ -0,0 +1,12 @@ +import * as ns from './reexport'; + +const checkNamespace = ns => { + assert.strictEqual(ns.internal, 'original', 'internal'); + ns.updateInternal(); + assert.strictEqual(ns.internal, 'updated', 'internal'); + assert.strictEqual(ns.external, 'original', 'external'); + ns.updateExternal(); + assert.strictEqual(ns.external, 'updated', 'external'); +}; + +checkNamespace(ns); diff --git a/test/function/samples/merged-namespace-live-bindings/reexport.js b/test/function/samples/merged-namespace-live-bindings/reexport.js new file mode 100644 index 00000000000..31b746544b5 --- /dev/null +++ b/test/function/samples/merged-namespace-live-bindings/reexport.js @@ -0,0 +1,2 @@ +export * from './internal'; +export * from 'external'; diff --git a/test/function/samples/method-call-mutates-this/_config.js b/test/function/samples/method-call-mutates-this/_config.js index 66fe25b0716..2a19ae00979 100644 --- a/test/function/samples/method-call-mutates-this/_config.js +++ b/test/function/samples/method-call-mutates-this/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'method calls are assumed to mutate the owner' -}; +}); diff --git a/test/function/samples/method-call-side-effects/_config.js b/test/function/samples/method-call-side-effects/_config.js index 56b01c9e9e6..364be1ac609 100644 --- a/test/function/samples/method-call-side-effects/_config.js +++ b/test/function/samples/method-call-side-effects/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'assumes methods may mutate objects passed in, and self' -}; +}); diff --git a/test/function/samples/missing-entry-export/_config.js b/test/function/samples/missing-entry-export/_config.js new file mode 100644 index 00000000000..f3c7c07d769 --- /dev/null +++ b/test/function/samples/missing-entry-export/_config.js @@ -0,0 +1,15 @@ +const path = require('node:path'); +const ID_MAIN = path.join(__dirname, 'main.js'); + +module.exports = defineTest({ + description: 'throws when exporting something that does not exist from an entry', + verifyAst: false, + error: { + binding: 'doesNotExist', + code: 'MISSING_EXPORT', + exporter: ID_MAIN, + message: 'Exported variable "doesNotExist" is not defined in "main.js".', + url: 'https://rollupjs.org/troubleshooting/#error-name-is-not-exported-by-module', + watchFiles: [ID_MAIN] + } +}); diff --git a/test/function/samples/missing-entry-export/main.js b/test/function/samples/missing-entry-export/main.js new file mode 100644 index 00000000000..aae9fd963e9 --- /dev/null +++ b/test/function/samples/missing-entry-export/main.js @@ -0,0 +1 @@ +export { doesNotExist }; diff --git a/test/function/samples/missing-export-preserve-modules/_config.js b/test/function/samples/missing-export-preserve-modules/_config.js new file mode 100644 index 00000000000..cd10b25726d --- /dev/null +++ b/test/function/samples/missing-export-preserve-modules/_config.js @@ -0,0 +1,19 @@ +const path = require('node:path'); + +module.exports = defineTest({ + description: 'supports shimming missing exports when preserving modules', + options: { + shimMissingExports: true, + output: { + preserveModules: true + } + }, + warnings: [ + { + binding: 'bar', + code: 'SHIMMED_EXPORT', + exporter: path.join(__dirname, 'foo.js'), + message: 'Missing export "bar" has been shimmed in module "foo.js".' + } + ] +}); diff --git a/test/function/samples/missing-export-preserve-modules/foo.js b/test/function/samples/missing-export-preserve-modules/foo.js new file mode 100644 index 00000000000..3329a7d972f --- /dev/null +++ b/test/function/samples/missing-export-preserve-modules/foo.js @@ -0,0 +1 @@ +export const foo = 'foo'; diff --git a/test/function/samples/missing-export-preserve-modules/main.js b/test/function/samples/missing-export-preserve-modules/main.js new file mode 100644 index 00000000000..352d9782b70 --- /dev/null +++ b/test/function/samples/missing-export-preserve-modules/main.js @@ -0,0 +1,2 @@ +import { bar } from './foo'; +assert.strictEqual(bar, undefined); diff --git a/test/function/samples/missing-spaces-after-simplification/_config.js b/test/function/samples/missing-spaces-after-simplification/_config.js index 49540bde635..d7bd26822d5 100644 --- a/test/function/samples/missing-spaces-after-simplification/_config.js +++ b/test/function/samples/missing-spaces-after-simplification/_config.js @@ -1,5 +1,5 @@ -module.exports = { +module.exports = defineTest({ description: 'handle situations where the simplification of an expression can lead to issues due to missing white-space', options: { treeshake: { tryCatchDeoptimization: false } } -}; +}); diff --git a/test/function/samples/mixed-external-paths/_config.js b/test/function/samples/mixed-external-paths/_config.js index 813b9de3e9d..79cbf850c41 100644 --- a/test/function/samples/mixed-external-paths/_config.js +++ b/test/function/samples/mixed-external-paths/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'allows using the path option selectively', options: { external: ['dep-a', 'dep-b'], @@ -19,4 +19,4 @@ module.exports = { throw new Error(`Unexpected dependency ${id}`); } } -}; +}); diff --git a/test/function/samples/modify-assumed-global/_config.js b/test/function/samples/modify-assumed-global/_config.js index c0e80549c74..3bf2795cce5 100644 --- a/test/function/samples/modify-assumed-global/_config.js +++ b/test/function/samples/modify-assumed-global/_config.js @@ -1,14 +1,14 @@ -const assert = require('assert'); +const assert = require('node:assert'); const Math = {}; -module.exports = { +module.exports = defineTest({ description: 'side-effects to assumed globals are included', context: { Math }, - exports(exports) { + exports() { assert.equal(Math.square(3), 9); assert.equal(Math.cube(3), 27); } -}; +}); diff --git a/test/function/samples/modify-meta/_config.js b/test/function/samples/modify-meta/_config.js new file mode 100644 index 00000000000..dda6989060b --- /dev/null +++ b/test/function/samples/modify-meta/_config.js @@ -0,0 +1,66 @@ +const assert = require('node:assert'); +const path = require('node:path'); +const ID_MAIN = path.join(__dirname, 'main.js'); + +let initialMeta; + +module.exports = defineTest({ + description: 'allows to freely modify moduleInfo.meta and maintain object identity', + options: { + plugins: [ + { + name: 'first', + buildStart() { + this.load({ id: ID_MAIN }); + initialMeta = this.getModuleInfo(ID_MAIN).meta; + initialMeta.buildStart = true; + }, + load(id) { + assert.strictEqual(id, ID_MAIN); + const meta = this.getModuleInfo(ID_MAIN).meta; + assert.deepStrictEqual(meta, { buildStart: true }, 'load'); + assert.strictEqual(meta, initialMeta); + meta.load1a = true; + return { code: `assert.ok(true);`, meta: { load1b: true } }; + }, + transform(code, id) { + assert.strictEqual(id, ID_MAIN); + const meta = this.getModuleInfo(ID_MAIN).meta; + assert.deepStrictEqual( + meta, + { buildStart: true, load1a: true, load1b: true }, + 'transform' + ); + assert.strictEqual(meta, initialMeta); + meta.transform1a = true; + return { code: `assert.ok(true);`, meta: { transform1b: true } }; + }, + buildEnd(error) { + if (error) { + throw error; + } + const meta = this.getModuleInfo(ID_MAIN).meta; + assert.deepStrictEqual( + meta, + { + buildStart: true, + load1a: true, + load1b: true, + transform1a: true, + transform1b: true, + transform2: true + }, + 'buildEnd' + ); + } + }, + { + name: 'second', + transform(code, id) { + assert.strictEqual(id, ID_MAIN); + return { code: `assert.ok(true);`, meta: { transform2: true } }; + } + } + ] + } +}); diff --git a/test/function/samples/modify-meta/main.js b/test/function/samples/modify-meta/main.js new file mode 100644 index 00000000000..cc1d88a24fa --- /dev/null +++ b/test/function/samples/modify-meta/main.js @@ -0,0 +1 @@ +assert.ok(true); diff --git a/test/function/samples/modify-object-via-this-a/_config.js b/test/function/samples/modify-object-via-this-a/_config.js index 0c4423de923..c32149fef49 100644 --- a/test/function/samples/modify-object-via-this-a/_config.js +++ b/test/function/samples/modify-object-via-this-a/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'tracks object modification via "this"' -}; +}); diff --git a/test/function/samples/modify-object-via-this-b/_config.js b/test/function/samples/modify-object-via-this-b/_config.js index 0c4423de923..c32149fef49 100644 --- a/test/function/samples/modify-object-via-this-b/_config.js +++ b/test/function/samples/modify-object-via-this-b/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'tracks object modification via "this"' -}; +}); diff --git a/test/function/samples/modify-object-via-this-c/_config.js b/test/function/samples/modify-object-via-this-c/_config.js index 0c4423de923..c32149fef49 100644 --- a/test/function/samples/modify-object-via-this-c/_config.js +++ b/test/function/samples/modify-object-via-this-c/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'tracks object modification via "this"' -}; +}); diff --git a/test/function/samples/modify-object-via-this-d/_config.js b/test/function/samples/modify-object-via-this-d/_config.js new file mode 100644 index 00000000000..c32149fef49 --- /dev/null +++ b/test/function/samples/modify-object-via-this-d/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'tracks object modification via "this"' +}); diff --git a/test/function/samples/modify-object-via-this-d/main.js b/test/function/samples/modify-object-via-this-d/main.js new file mode 100644 index 00000000000..55adf0b053b --- /dev/null +++ b/test/function/samples/modify-object-via-this-d/main.js @@ -0,0 +1,13 @@ +const obj = { + modify() {} +}; + +obj.modify = modify; + +function modify() { + this.modified = true; +} + +obj.modify(); + +assert.strictEqual(obj.modified ? 'MODIFIED' : 'BROKEN', 'MODIFIED'); diff --git a/test/function/samples/modify-this-via-getter/deoptimized-props-with-getter/_config.js b/test/function/samples/modify-this-via-getter/deoptimized-props-with-getter/_config.js new file mode 100644 index 00000000000..80f4db1bf3b --- /dev/null +++ b/test/function/samples/modify-this-via-getter/deoptimized-props-with-getter/_config.js @@ -0,0 +1,11 @@ +module.exports = defineTest({ + description: 'handles fully deoptimized objects', + context: { + require() { + return { unknown: 'prop' }; + } + }, + options: { + external: ['external'] + } +}); diff --git a/test/function/samples/modify-this-via-getter/deoptimized-props-with-getter/main.js b/test/function/samples/modify-this-via-getter/deoptimized-props-with-getter/main.js new file mode 100644 index 00000000000..def94e30b12 --- /dev/null +++ b/test/function/samples/modify-this-via-getter/deoptimized-props-with-getter/main.js @@ -0,0 +1,17 @@ +import { unknown } from 'external'; + +const obj = { + flag: false +}; + +Object.defineProperty(obj, unknown, { + get() { + this.flag = true; + } +}); + +obj.prop; + +if (!obj.flag) { + throw new Error('mutation not detected'); +} diff --git a/test/function/samples/modify-this-via-getter/getter-in-assignment/_config.js b/test/function/samples/modify-this-via-getter/getter-in-assignment/_config.js new file mode 100644 index 00000000000..8fdcc8df131 --- /dev/null +++ b/test/function/samples/modify-this-via-getter/getter-in-assignment/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'handles known getters that are triggered via an assignment' +}); diff --git a/test/function/samples/modify-this-via-getter/getter-in-assignment/main.js b/test/function/samples/modify-this-via-getter/getter-in-assignment/main.js new file mode 100644 index 00000000000..4244e759d89 --- /dev/null +++ b/test/function/samples/modify-this-via-getter/getter-in-assignment/main.js @@ -0,0 +1,14 @@ +const obj = { + flag: false, + get prop() { + this.flag = true; + return 1; + }, + set prop(v) {} +}; + +obj.prop += 1; + +if (!obj.flag) { + throw new Error('mutation not detected'); +} diff --git a/test/function/samples/modify-this-via-getter/getters-on-this/_config.js b/test/function/samples/modify-this-via-getter/getters-on-this/_config.js new file mode 100644 index 00000000000..ed16aacef5a --- /dev/null +++ b/test/function/samples/modify-this-via-getter/getters-on-this/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'handles calling getters on "this"' +}); diff --git a/test/function/samples/modify-this-via-getter/getters-on-this/main.js b/test/function/samples/modify-this-via-getter/getters-on-this/main.js new file mode 100644 index 00000000000..24f3b72fdbd --- /dev/null +++ b/test/function/samples/modify-this-via-getter/getters-on-this/main.js @@ -0,0 +1,39 @@ +const obj = { + flag1: false, + flag2: false, + flag3: false, + flag4: false, + prop1() { + this.flag1 = true; + this.prop2(); + }, + prop2() { + this.flag2 = true; + this.prop3; + }, + get prop3() { + this.flag3 = true; + this.prop4 = true; + }, + set prop4(value) { + this.flag4 = value; + } +}; + +obj.prop1(); + +if (!obj.flag1) { + throw new Error('mutation 1 not detected'); +} + +if (!obj.flag2) { + throw new Error('mutation 2 not detected'); +} + +if (!obj.flag3) { + throw new Error('mutation 3 not detected'); +} + +if (!obj.flag4) { + throw new Error('mutation 4 not detected'); +} diff --git a/test/function/samples/modify-this-via-getter/known-getter/_config.js b/test/function/samples/modify-this-via-getter/known-getter/_config.js new file mode 100644 index 00000000000..0808865bde2 --- /dev/null +++ b/test/function/samples/modify-this-via-getter/known-getter/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'handles known getters that modify "this"' +}); diff --git a/test/function/samples/modify-this-via-getter/known-getter/main.js b/test/function/samples/modify-this-via-getter/known-getter/main.js new file mode 100644 index 00000000000..9fa5e548b09 --- /dev/null +++ b/test/function/samples/modify-this-via-getter/known-getter/main.js @@ -0,0 +1,12 @@ +const obj = { + flag: false, + get prop() { + this.flag = true; + } +}; + +obj.prop; + +if (!obj.flag) { + throw new Error('mutation not detected'); +} diff --git a/test/function/samples/modify-this-via-getter/known-super-prop/_config.js b/test/function/samples/modify-this-via-getter/known-super-prop/_config.js new file mode 100644 index 00000000000..79dfc448949 --- /dev/null +++ b/test/function/samples/modify-this-via-getter/known-super-prop/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'handles getters that modify "this" on prototypes for known properties' +}); diff --git a/test/function/samples/modify-this-via-getter/known-super-prop/main.js b/test/function/samples/modify-this-via-getter/known-super-prop/main.js new file mode 100644 index 00000000000..ca4cd5a954c --- /dev/null +++ b/test/function/samples/modify-this-via-getter/known-super-prop/main.js @@ -0,0 +1,14 @@ +class proto { + static flag = false; + static get prop() { + this.flag = true; + } +} + +class obj extends proto {} + +obj.prop; + +if (!obj.flag) { + throw new Error('mutation not detected'); +} diff --git a/test/function/samples/modify-this-via-getter/unknown-prop-getter/_config.js b/test/function/samples/modify-this-via-getter/unknown-prop-getter/_config.js new file mode 100644 index 00000000000..0c7b01133f1 --- /dev/null +++ b/test/function/samples/modify-this-via-getter/unknown-prop-getter/_config.js @@ -0,0 +1,11 @@ +module.exports = defineTest({ + description: 'handles unknown getters that modify "this"', + context: { + require() { + return { unknown: 'prop' }; + } + }, + options: { + external: ['external'] + } +}); diff --git a/test/function/samples/modify-this-via-getter/unknown-prop-getter/main.js b/test/function/samples/modify-this-via-getter/unknown-prop-getter/main.js new file mode 100644 index 00000000000..c8829e86915 --- /dev/null +++ b/test/function/samples/modify-this-via-getter/unknown-prop-getter/main.js @@ -0,0 +1,14 @@ +import { unknown } from 'external'; + +const obj = { + get [unknown]() { + this.flag = true; + }, + flag: false +}; + +obj.prop; + +if (!obj.flag) { + throw new Error('mutation not detected'); +} diff --git a/test/function/samples/modify-this-via-getter/unknown-prop-unknown-access/_config.js b/test/function/samples/modify-this-via-getter/unknown-prop-unknown-access/_config.js new file mode 100644 index 00000000000..5ef55c92a2a --- /dev/null +++ b/test/function/samples/modify-this-via-getter/unknown-prop-unknown-access/_config.js @@ -0,0 +1,11 @@ +module.exports = defineTest({ + description: 'handles unknown getters that modify "this" for unknown property access', + context: { + require() { + return { unknown: 'prop' }; + } + }, + options: { + external: ['external'] + } +}); diff --git a/test/function/samples/modify-this-via-getter/unknown-prop-unknown-access/main.js b/test/function/samples/modify-this-via-getter/unknown-prop-unknown-access/main.js new file mode 100644 index 00000000000..40846145270 --- /dev/null +++ b/test/function/samples/modify-this-via-getter/unknown-prop-unknown-access/main.js @@ -0,0 +1,14 @@ +import { unknown } from 'external'; + +const obj = { + get [unknown]() { + this.flag = true; + }, + flag: false +}; + +obj[unknown]; + +if (!obj.flag) { + throw new Error('mutation not detected'); +} diff --git a/test/function/samples/modify-this-via-getter/unknown-property-access/_config.js b/test/function/samples/modify-this-via-getter/unknown-property-access/_config.js new file mode 100644 index 00000000000..bb4f3e89906 --- /dev/null +++ b/test/function/samples/modify-this-via-getter/unknown-property-access/_config.js @@ -0,0 +1,11 @@ +module.exports = defineTest({ + description: 'handles getters that modify "this" for unknown property access', + context: { + require() { + return { unknown: 'prop' }; + } + }, + options: { + external: ['external'] + } +}); diff --git a/test/function/samples/modify-this-via-getter/unknown-property-access/main.js b/test/function/samples/modify-this-via-getter/unknown-property-access/main.js new file mode 100644 index 00000000000..0c790f0347f --- /dev/null +++ b/test/function/samples/modify-this-via-getter/unknown-property-access/main.js @@ -0,0 +1,14 @@ +import { unknown } from 'external'; + +const obj = { + flag: false, + get prop() { + this.flag = true; + } +}; + +obj[unknown]; + +if (!obj.flag) { + throw new Error('mutation not detected'); +} diff --git a/test/function/samples/modify-this-via-getter/unknown-super-prop/_config.js b/test/function/samples/modify-this-via-getter/unknown-super-prop/_config.js new file mode 100644 index 00000000000..a29f383894e --- /dev/null +++ b/test/function/samples/modify-this-via-getter/unknown-super-prop/_config.js @@ -0,0 +1,11 @@ +module.exports = defineTest({ + description: 'handles getters that modify "this" on prototypes for unknown properties', + context: { + require() { + return { unknown: 'prop' }; + } + }, + options: { + external: ['external'] + } +}); diff --git a/test/function/samples/modify-this-via-getter/unknown-super-prop/main.js b/test/function/samples/modify-this-via-getter/unknown-super-prop/main.js new file mode 100644 index 00000000000..9530c344172 --- /dev/null +++ b/test/function/samples/modify-this-via-getter/unknown-super-prop/main.js @@ -0,0 +1,16 @@ +import { unknown } from 'external'; + +class proto { + static flag = false; + static get prop() { + this.flag = true; + } +} + +class obj extends proto {} + +obj[unknown]; + +if (!obj.flag) { + throw new Error('mutation not detected'); +} diff --git a/test/function/samples/modify-this-via-setter/deoptimized-props-with-setter/_config.js b/test/function/samples/modify-this-via-setter/deoptimized-props-with-setter/_config.js new file mode 100644 index 00000000000..80f4db1bf3b --- /dev/null +++ b/test/function/samples/modify-this-via-setter/deoptimized-props-with-setter/_config.js @@ -0,0 +1,11 @@ +module.exports = defineTest({ + description: 'handles fully deoptimized objects', + context: { + require() { + return { unknown: 'prop' }; + } + }, + options: { + external: ['external'] + } +}); diff --git a/test/function/samples/modify-this-via-setter/deoptimized-props-with-setter/main.js b/test/function/samples/modify-this-via-setter/deoptimized-props-with-setter/main.js new file mode 100644 index 00000000000..73c7d3a1af3 --- /dev/null +++ b/test/function/samples/modify-this-via-setter/deoptimized-props-with-setter/main.js @@ -0,0 +1,17 @@ +import { unknown } from 'external'; + +const obj = { + flag: false +}; + +Object.defineProperty(obj, unknown, { + set(value) { + this.flag = value; + } +}); + +obj.prop = true; + +if (!obj.flag) { + throw new Error('mutation not detected'); +} diff --git a/test/function/samples/modify-this-via-setter/known-setter/_config.js b/test/function/samples/modify-this-via-setter/known-setter/_config.js new file mode 100644 index 00000000000..be3a5b32853 --- /dev/null +++ b/test/function/samples/modify-this-via-setter/known-setter/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'handles known setters that modify "this"' +}); diff --git a/test/function/samples/modify-this-via-setter/known-setter/main.js b/test/function/samples/modify-this-via-setter/known-setter/main.js new file mode 100644 index 00000000000..74930dba6fb --- /dev/null +++ b/test/function/samples/modify-this-via-setter/known-setter/main.js @@ -0,0 +1,12 @@ +const obj = { + flag: false, + set prop(value) { + this.flag = value; + } +}; + +obj.prop = true; + +if (!obj.flag) { + throw new Error('mutation not detected'); +} diff --git a/test/function/samples/modify-this-via-setter/known-super-prop/_config.js b/test/function/samples/modify-this-via-setter/known-super-prop/_config.js new file mode 100644 index 00000000000..76b842c2941 --- /dev/null +++ b/test/function/samples/modify-this-via-setter/known-super-prop/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'handles setters that modify "this" on prototypes for known properties' +}); diff --git a/test/function/samples/modify-this-via-setter/known-super-prop/main.js b/test/function/samples/modify-this-via-setter/known-super-prop/main.js new file mode 100644 index 00000000000..d6f72d34575 --- /dev/null +++ b/test/function/samples/modify-this-via-setter/known-super-prop/main.js @@ -0,0 +1,14 @@ +class proto { + static flag = false; + static set prop(value) { + this.flag = value; + } +} + +class obj extends proto {} + +obj.prop = true; + +if (!obj.flag) { + throw new Error('mutation not detected'); +} diff --git a/test/function/samples/modify-this-via-setter/unknown-prop-setter/_config.js b/test/function/samples/modify-this-via-setter/unknown-prop-setter/_config.js new file mode 100644 index 00000000000..ffb357c57d6 --- /dev/null +++ b/test/function/samples/modify-this-via-setter/unknown-prop-setter/_config.js @@ -0,0 +1,11 @@ +module.exports = defineTest({ + description: 'handles unknown setters that modify "this"', + context: { + require() { + return { unknown: 'prop' }; + } + }, + options: { + external: ['external'] + } +}); diff --git a/test/function/samples/modify-this-via-setter/unknown-prop-setter/main.js b/test/function/samples/modify-this-via-setter/unknown-prop-setter/main.js new file mode 100644 index 00000000000..4285ed33781 --- /dev/null +++ b/test/function/samples/modify-this-via-setter/unknown-prop-setter/main.js @@ -0,0 +1,14 @@ +import { unknown } from 'external'; + +const obj = { + set [unknown](value) { + this.flag = value; + }, + flag: false +}; + +obj.prop = true; + +if (!obj.flag) { + throw new Error('mutation not detected'); +} diff --git a/test/function/samples/modify-this-via-setter/unknown-prop-unknown-access/_config.js b/test/function/samples/modify-this-via-setter/unknown-prop-unknown-access/_config.js new file mode 100644 index 00000000000..70a60fc3168 --- /dev/null +++ b/test/function/samples/modify-this-via-setter/unknown-prop-unknown-access/_config.js @@ -0,0 +1,11 @@ +module.exports = defineTest({ + description: 'handles unknown setters that modify "this" for unknown property access', + context: { + require() { + return { unknown: 'prop' }; + } + }, + options: { + external: ['external'] + } +}); diff --git a/test/function/samples/modify-this-via-setter/unknown-prop-unknown-access/main.js b/test/function/samples/modify-this-via-setter/unknown-prop-unknown-access/main.js new file mode 100644 index 00000000000..536e3c7fa79 --- /dev/null +++ b/test/function/samples/modify-this-via-setter/unknown-prop-unknown-access/main.js @@ -0,0 +1,14 @@ +import { unknown } from 'external'; + +const obj = { + set [unknown](value) { + this.flag = value; + }, + flag: false +}; + +obj[unknown] = true; + +if (!obj.flag) { + throw new Error('mutation not detected'); +} diff --git a/test/function/samples/modify-this-via-setter/unknown-super-prop/_config.js b/test/function/samples/modify-this-via-setter/unknown-super-prop/_config.js new file mode 100644 index 00000000000..bbd4bf974ad --- /dev/null +++ b/test/function/samples/modify-this-via-setter/unknown-super-prop/_config.js @@ -0,0 +1,11 @@ +module.exports = defineTest({ + description: 'handles setters that modify "this" on prototypes for unknown properties', + context: { + require() { + return { unknown: 'prop' }; + } + }, + options: { + external: ['external'] + } +}); diff --git a/test/function/samples/modify-this-via-setter/unknown-super-prop/main.js b/test/function/samples/modify-this-via-setter/unknown-super-prop/main.js new file mode 100644 index 00000000000..f1e106b4b70 --- /dev/null +++ b/test/function/samples/modify-this-via-setter/unknown-super-prop/main.js @@ -0,0 +1,16 @@ +import { unknown } from 'external'; + +class proto { + static flag = false; + static set prop(value) { + this.flag = value; + } +} + +class obj extends proto {} + +obj[unknown] = true; + +if (!obj.flag) { + throw new Error('mutation not detected'); +} diff --git a/test/function/samples/module-level-directive/_config.js b/test/function/samples/module-level-directive/_config.js index fd2268f6589..bfcff499797 100644 --- a/test/function/samples/module-level-directive/_config.js +++ b/test/function/samples/module-level-directive/_config.js @@ -1,21 +1,25 @@ -const path = require('path'); +const path = require('node:path'); +const ID_MAIN = path.join(__dirname, 'main.js'); -module.exports = { +module.exports = defineTest({ description: 'module level directives should produce warnings', warnings: [ { code: 'MODULE_LEVEL_DIRECTIVE', - message: "Module level directives cause errors when bundled, 'use asm' was ignored.", + id: ID_MAIN, + message: + 'main.js (1:0): Module level directives cause errors when bundled, "use asm" in "main.js" was ignored.', pos: 0, - id: path.join(__dirname, 'main.js'), loc: { - file: path.join(__dirname, 'main.js'), - line: 1, - column: 0 + column: 0, + file: ID_MAIN, + line: 1 }, frame: ` - 1: "use asm";\n ^\n2:\n3: export default 1; - ` + 1: "use asm"; + ^ + 2: + 3: export default 1;` } ] -}; +}); diff --git a/test/function/samples/module-parsed-hook/_config.js b/test/function/samples/module-parsed-hook/_config.js index ffe1a6c8b89..7e8f16f97cf 100644 --- a/test/function/samples/module-parsed-hook/_config.js +++ b/test/function/samples/module-parsed-hook/_config.js @@ -1,113 +1,143 @@ -const assert = require('assert'); -const path = require('path'); +const assert = require('node:assert'); +const path = require('node:path'); const parsedModules = []; const ID_MAIN = path.join(__dirname, 'main.js'); const ID_DEP = path.join(__dirname, 'dep.js'); -module.exports = { +module.exports = defineTest({ description: 'calls the moduleParsedHook once a module is parsed', options: { - plugins: { - name: 'test-plugin', - moduleParsed(moduleInfo) { - parsedModules.push(moduleInfo); - }, - buildEnd() { - assert.deepStrictEqual(JSON.parse(JSON.stringify(parsedModules)), [ - { - ast: { - type: 'Program', - start: 0, - end: 34, - body: [ - { - type: 'ExportNamedDeclaration', - start: 0, - end: 33, - declaration: null, - specifiers: [ - { - type: 'ExportSpecifier', - start: 9, - end: 14, - local: { type: 'Identifier', start: 9, end: 14, name: 'value' }, - exported: { type: 'Identifier', start: 9, end: 14, name: 'value' } - } - ], - source: { - type: 'Literal', - start: 22, - end: 32, - value: './dep.js', - raw: "'./dep.js'" - } - } - ], - sourceType: 'module' - }, - code: "export { value } from './dep.js';\n", - dynamicallyImportedIds: [], - dynamicImporters: [], - hasModuleSideEffects: true, - id: ID_MAIN, - implicitlyLoadedAfterOneOf: [], - implicitlyLoadedBefore: [], - importedIds: [ID_DEP], - importers: [], - isEntry: true, - isExternal: false, - meta: {}, - syntheticNamedExports: false - }, - { - ast: { - type: 'Program', - start: 0, - end: 25, - body: [ - { - type: 'ExportNamedDeclaration', - start: 0, - end: 24, - declaration: { - type: 'VariableDeclaration', - start: 7, - end: 24, - declarations: [ + plugins: [ + { + name: 'test-plugin', + moduleParsed(moduleInfo) { + parsedModules.push(moduleInfo); + }, + buildEnd() { + assert.deepStrictEqual(JSON.parse(JSON.stringify(parsedModules)), [ + { + id: ID_MAIN, + attributes: {}, + ast: { + type: 'Program', + start: 0, + end: 34, + body: [ + { + type: 'ExportNamedDeclaration', + start: 0, + end: 33, + attributes: [], + declaration: null, + specifiers: [ { - type: 'VariableDeclarator', - start: 13, - end: 23, - id: { type: 'Identifier', start: 13, end: 18, name: 'value' }, - init: { type: 'Literal', start: 21, end: 23, value: 42, raw: '42' } + type: 'ExportSpecifier', + start: 9, + end: 14, + local: { type: 'Identifier', start: 9, end: 14, name: 'value' }, + exported: { type: 'Identifier', start: 9, end: 14, name: 'value' } } ], - kind: 'const' - }, - specifiers: [], - source: null + source: { + type: 'Literal', + start: 22, + end: 32, + value: './dep.js', + raw: "'./dep.js'" + } + } + ], + sourceType: 'module' + }, + code: "export { value } from './dep.js';\n", + dynamicallyImportedIdResolutions: [], + dynamicallyImportedIds: [], + dynamicImporters: [], + exportedBindings: { '.': [], './dep.js': ['value'] }, + exports: ['value'], + hasDefaultExport: false, + moduleSideEffects: true, + implicitlyLoadedAfterOneOf: [], + implicitlyLoadedBefore: [], + importedIdResolutions: [ + { + attributes: {}, + external: false, + id: ID_DEP, + meta: {}, + moduleSideEffects: true, + resolvedBy: 'rollup', + syntheticNamedExports: false } ], - sourceType: 'module' + importedIds: [ID_DEP], + importers: [], + isEntry: true, + isExternal: false, + isIncluded: false, + meta: {}, + safeVariableNames: null, + syntheticNamedExports: false }, - code: 'export const value = 42;\n', - dynamicallyImportedIds: [], - dynamicImporters: [], - hasModuleSideEffects: true, - id: ID_DEP, - implicitlyLoadedAfterOneOf: [], - implicitlyLoadedBefore: [], - importedIds: [], - importers: [ID_MAIN], - isEntry: false, - isExternal: false, - meta: {}, - syntheticNamedExports: false - } - ]); + { + id: ID_DEP, + attributes: {}, + ast: { + type: 'Program', + start: 0, + end: 25, + body: [ + { + type: 'ExportNamedDeclaration', + start: 0, + end: 24, + attributes: [], + declaration: { + type: 'VariableDeclaration', + start: 7, + end: 24, + declarations: [ + { + type: 'VariableDeclarator', + start: 13, + end: 23, + id: { type: 'Identifier', start: 13, end: 18, name: 'value' }, + init: { type: 'Literal', start: 21, end: 23, value: 42, raw: '42' } + } + ], + kind: 'const' + }, + specifiers: [], + source: null + } + ], + sourceType: 'module' + }, + code: 'export const value = 42;\n', + dynamicallyImportedIdResolutions: [], + dynamicallyImportedIds: [], + dynamicImporters: [], + exportedBindings: { '.': ['value'] }, + exports: ['value'], + hasDefaultExport: false, + moduleSideEffects: true, + implicitlyLoadedAfterOneOf: [], + implicitlyLoadedBefore: [], + importedIdResolutions: [], + importedIds: [], + importers: [ID_MAIN], + isEntry: false, + isExternal: false, + isIncluded: true, + meta: {}, + safeVariableNames: null, + syntheticNamedExports: false + } + ]); + } } - } + ] } -}; +}); diff --git a/test/function/samples/module-parsed-imported-ids/_config.js b/test/function/samples/module-parsed-imported-ids/_config.js new file mode 100644 index 00000000000..ee051e50216 --- /dev/null +++ b/test/function/samples/module-parsed-imported-ids/_config.js @@ -0,0 +1,31 @@ +const assert = require('node:assert'); +const path = require('node:path'); + +module.exports = defineTest({ + description: 'provides full importedIds and dynamicallyImportedIds in the moduleParsed hook', + options: { + plugins: [ + { + load(id) { + const { dynamicallyImportedIds, importedIds } = this.getModuleInfo(id); + assert.deepStrictEqual(importedIds, []); + assert.deepStrictEqual(dynamicallyImportedIds, []); + }, + transform(code, id) { + const { dynamicallyImportedIds, importedIds } = this.getModuleInfo(id); + assert.deepStrictEqual(importedIds, []); + assert.deepStrictEqual(dynamicallyImportedIds, []); + }, + moduleParsed({ dynamicallyImportedIds, id, importedIds }) { + if (id.endsWith('main.js')) { + assert.deepStrictEqual(importedIds, [path.join(__dirname, 'static.js')]); + assert.deepStrictEqual(dynamicallyImportedIds, [path.join(__dirname, 'dynamic.js')]); + } else { + assert.deepStrictEqual(importedIds, []); + assert.deepStrictEqual(dynamicallyImportedIds, []); + } + } + } + ] + } +}); diff --git a/test/function/samples/module-parsed-imported-ids/dynamic.js b/test/function/samples/module-parsed-imported-ids/dynamic.js new file mode 100644 index 00000000000..b683ac073aa --- /dev/null +++ b/test/function/samples/module-parsed-imported-ids/dynamic.js @@ -0,0 +1 @@ +export const bar = 'dynamic'; diff --git a/test/function/samples/module-parsed-imported-ids/main.js b/test/function/samples/module-parsed-imported-ids/main.js new file mode 100644 index 00000000000..8cebd45cbbf --- /dev/null +++ b/test/function/samples/module-parsed-imported-ids/main.js @@ -0,0 +1,3 @@ +import { foo } from './static.js'; + +export const result = [foo, import('./dynamic.js')]; diff --git a/test/function/samples/module-parsed-imported-ids/static.js b/test/function/samples/module-parsed-imported-ids/static.js new file mode 100644 index 00000000000..a9fadc7ff6e --- /dev/null +++ b/test/function/samples/module-parsed-imported-ids/static.js @@ -0,0 +1 @@ +export const foo = 'static'; diff --git a/test/function/samples/module-side-effect-reexport/_config.js b/test/function/samples/module-side-effect-reexport/_config.js new file mode 100644 index 00000000000..324ef02fe83 --- /dev/null +++ b/test/function/samples/module-side-effect-reexport/_config.js @@ -0,0 +1,13 @@ +module.exports = defineTest({ + description: 'includes side effects of re-exporters unless they have moduleSideEffects: false', + options: { + plugins: [ + { + name: 'ignore-side-effects', + transform(_code, id) { + return { moduleSideEffects: id.endsWith('effect.js') }; + } + } + ] + } +}); diff --git a/test/function/samples/module-side-effect-reexport/foo.js b/test/function/samples/module-side-effect-reexport/foo.js new file mode 100644 index 00000000000..62d968e8238 --- /dev/null +++ b/test/function/samples/module-side-effect-reexport/foo.js @@ -0,0 +1 @@ +export const foo = true; diff --git a/test/function/samples/module-side-effect-reexport/index.js b/test/function/samples/module-side-effect-reexport/index.js new file mode 100644 index 00000000000..c44449ca1fd --- /dev/null +++ b/test/function/samples/module-side-effect-reexport/index.js @@ -0,0 +1,2 @@ +export { foo } from './reexport-effect'; +global.indexEffect = true; diff --git a/test/function/samples/module-side-effect-reexport/main.js b/test/function/samples/module-side-effect-reexport/main.js new file mode 100644 index 00000000000..ffd60829b84 --- /dev/null +++ b/test/function/samples/module-side-effect-reexport/main.js @@ -0,0 +1,12 @@ +import { foo } from './index'; + +assert.ok(foo, 'foo'); + +// effects in reexporters without side effects are ignored +assert.equal(global.indexEffect, undefined, 'indexEffect'); + +// effects in reexporters with side effects are retained +assert.ok(global.reexportEffect, 'reexportEffect'); + +// cleanup +delete global.reexportEffect; diff --git a/test/function/samples/module-side-effect-reexport/reexport-effect.js b/test/function/samples/module-side-effect-reexport/reexport-effect.js new file mode 100644 index 00000000000..d7e77433774 --- /dev/null +++ b/test/function/samples/module-side-effect-reexport/reexport-effect.js @@ -0,0 +1,2 @@ +export { foo } from './foo'; +global.reexportEffect = true; diff --git a/test/function/samples/module-side-effects/array/_config.js b/test/function/samples/module-side-effects/array/_config.js index 979d9f7d3d4..0b64a85a9d6 100644 --- a/test/function/samples/module-side-effects/array/_config.js +++ b/test/function/samples/module-side-effects/array/_config.js @@ -1,8 +1,8 @@ -const assert = require('assert'); -const path = require('path'); +const assert = require('node:assert'); +const path = require('node:path'); const sideEffects = []; -module.exports = { +module.exports = defineTest({ description: 'supports setting module side effects via an array', context: { require(id) { @@ -35,22 +35,24 @@ module.exports = { 'pluginsideeffects-true-external-listed' ] }, - plugins: { - name: 'test-plugin', - resolveId(id) { - if (!path.isAbsolute(id)) { - const moduleSideEffects = JSON.parse(id.split('-')[1]); - if (moduleSideEffects) { - return { id, moduleSideEffects }; + plugins: [ + { + name: 'test-plugin', + resolveId(id) { + if (!path.isAbsolute(id)) { + const moduleSideEffects = JSON.parse(id.split('-')[1]); + if (moduleSideEffects) { + return { id, moduleSideEffects }; + } + return id; + } + }, + load(id) { + if (!path.isAbsolute(id)) { + return `export const value = '${id}'; sideEffects.push(value);`; } - return id; - } - }, - load(id) { - if (!path.isAbsolute(id)) { - return `export const value = '${id}'; sideEffects.push(value);`; } } - } + ] } -}; +}); diff --git a/test/function/samples/module-side-effects/external-false/_config.js b/test/function/samples/module-side-effects/external-false/_config.js index e54cba85b91..c1854672ffe 100644 --- a/test/function/samples/module-side-effects/external-false/_config.js +++ b/test/function/samples/module-side-effects/external-false/_config.js @@ -1,8 +1,10 @@ -const assert = require('assert'); -const path = require('path'); +const assert = require('node:assert'); +const path = require('node:path'); +const ID_MAIN = path.join(__dirname, 'main.js'); + const sideEffects = []; -module.exports = { +module.exports = defineTest({ description: 'supports setting module side effects to false for external modules', context: { require(id) { @@ -18,38 +20,40 @@ module.exports = { treeshake: { moduleSideEffects: 'no-external' }, - plugins: { - name: 'test-plugin', - resolveId(id) { - if (!path.isAbsolute(id)) { - if (id === 'internal') { - return id; - } - if (id === 'implicit-external') { - return null; + plugins: [ + { + name: 'test-plugin', + resolveId(id) { + if (!path.isAbsolute(id)) { + if (id === 'internal') { + return id; + } + if (id === 'implicit-external') { + return null; + } + const moduleSideEffects = JSON.parse(id.split('-')[1]); + if (moduleSideEffects) { + return { id, moduleSideEffects, external: true }; + } + return { id, external: true }; } - const moduleSideEffects = JSON.parse(id.split('-')[1]); - if (moduleSideEffects) { - return { id, moduleSideEffects, external: true }; + }, + load(id) { + if (!path.isAbsolute(id)) { + return `export const value = '${id}'; sideEffects.push(value);`; } - return { id, external: true }; - } - }, - load(id) { - if (!path.isAbsolute(id)) { - return `export const value = '${id}'; sideEffects.push(value);`; } } - } + ] }, warnings: [ { code: 'UNRESOLVED_IMPORT', - importer: 'main.js', + exporter: 'implicit-external', + id: ID_MAIN, message: - "'implicit-external' is imported by main.js, but could not be resolved – treating it as an external dependency", - source: 'implicit-external', - url: 'https://rollupjs.org/guide/en/#warning-treating-module-as-external-dependency' + '"implicit-external" is imported by "main.js", but could not be resolved – treating it as an external dependency.', + url: 'https://rollupjs.org/troubleshooting/#warning-treating-module-as-external-dependency' } ] -}; +}); diff --git a/test/function/samples/module-side-effects/global-false/_config.js b/test/function/samples/module-side-effects/global-false/_config.js index c45c07363a0..05f8d9f6ee2 100644 --- a/test/function/samples/module-side-effects/global-false/_config.js +++ b/test/function/samples/module-side-effects/global-false/_config.js @@ -1,8 +1,8 @@ -const assert = require('assert'); -const path = require('path'); +const assert = require('node:assert'); +const path = require('node:path'); const sideEffects = []; -module.exports = { +module.exports = defineTest({ description: 'supports setting module side effects to false for all modules', context: { require(id) { @@ -19,22 +19,24 @@ module.exports = { treeshake: { moduleSideEffects: false }, - plugins: { - name: 'test-plugin', - resolveId(id) { - if (!path.isAbsolute(id)) { - const moduleSideEffects = JSON.parse(id.split('-')[1]); - if (moduleSideEffects) { - return { id, moduleSideEffects }; + plugins: [ + { + name: 'test-plugin', + resolveId(id) { + if (!path.isAbsolute(id)) { + const moduleSideEffects = JSON.parse(id.split('-')[1]); + if (moduleSideEffects) { + return { id, moduleSideEffects }; + } + return id; + } + }, + load(id) { + if (!path.isAbsolute(id)) { + return `export const value = '${id}'; sideEffects.push(value);`; } - return id; - } - }, - load(id) { - if (!path.isAbsolute(id)) { - return `export const value = '${id}'; sideEffects.push(value);`; } } - } + ] } -}; +}); diff --git a/test/function/samples/module-side-effects/invalid-option/_config.js b/test/function/samples/module-side-effects/invalid-option/_config.js index 0641fcdbfb2..4e8cf447089 100644 --- a/test/function/samples/module-side-effects/invalid-option/_config.js +++ b/test/function/samples/module-side-effects/invalid-option/_config.js @@ -1,15 +1,14 @@ -module.exports = { +module.exports = defineTest({ description: 'warns for invalid options', options: { treeshake: { moduleSideEffects: 'what-is-this?' } }, - warnings: [ - { - code: 'INVALID_OPTION', - message: - 'Invalid value for option "treeshake.moduleSideEffects" - please use one of false, "no-external", a function or an array.' - } - ] -}; + error: { + code: 'INVALID_OPTION', + message: + 'Invalid value for option "treeshake.moduleSideEffects" - please use one of false, "no-external", a function or an array.', + url: 'https://rollupjs.org/configuration-options/#treeshake-modulesideeffects' + } +}); diff --git a/test/function/samples/module-side-effects/load/_config.js b/test/function/samples/module-side-effects/load/_config.js index 0c40a92ea80..8937c4ac8e8 100644 --- a/test/function/samples/module-side-effects/load/_config.js +++ b/test/function/samples/module-side-effects/load/_config.js @@ -1,8 +1,8 @@ -const assert = require('assert'); -const path = require('path'); +const assert = require('node:assert'); +const path = require('node:path'); const sideEffects = []; -module.exports = { +module.exports = defineTest({ description: 'handles setting moduleSideEffects in the load hook', context: { sideEffects @@ -23,22 +23,24 @@ module.exports = { return JSON.parse(id.split('-')[1]); } }, - plugins: { - name: 'test-plugin', - resolveId(id) { - if (!path.isAbsolute(id)) { - return id; - } - }, - load(id) { - if (!path.isAbsolute(id)) { - const moduleSideEffects = JSON.parse(id.split('-')[3]); - return { - code: `export const value = '${id}'; sideEffects.push(value);`, - moduleSideEffects - }; + plugins: [ + { + name: 'test-plugin', + resolveId(id) { + if (!path.isAbsolute(id)) { + return id; + } + }, + load(id) { + if (!path.isAbsolute(id)) { + const moduleSideEffects = JSON.parse(id.split('-')[3]); + return { + code: `export const value = '${id}'; sideEffects.push(value);`, + moduleSideEffects + }; + } } } - } + ] } -}; +}); diff --git a/test/function/samples/module-side-effects/reexport-from-external/_config.js b/test/function/samples/module-side-effects/reexport-from-external/_config.js index ab343af5213..d04b7f3e2c8 100644 --- a/test/function/samples/module-side-effects/reexport-from-external/_config.js +++ b/test/function/samples/module-side-effects/reexport-from-external/_config.js @@ -1,6 +1,6 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'handles reexporting external values when module side-effects are false', context: { require(id) { @@ -21,4 +21,4 @@ module.exports = { moduleSideEffects: false } } -}; +}); diff --git a/test/function/samples/module-side-effects/reexports/_config.js b/test/function/samples/module-side-effects/reexports/_config.js index 3e5604fcb08..2fb509027fc 100644 --- a/test/function/samples/module-side-effects/reexports/_config.js +++ b/test/function/samples/module-side-effects/reexports/_config.js @@ -1,7 +1,7 @@ -const assert = require('assert'); +const assert = require('node:assert'); const sideEffects = []; -module.exports = { +module.exports = defineTest({ description: 'handles reexporting values when module side-effects are false', context: { sideEffects @@ -14,4 +14,4 @@ module.exports = { moduleSideEffects: false } } -}; +}); diff --git a/test/function/samples/module-side-effects/resolve-id-external/_config.js b/test/function/samples/module-side-effects/resolve-id-external/_config.js index 7d612eb749b..86f3a93beff 100644 --- a/test/function/samples/module-side-effects/resolve-id-external/_config.js +++ b/test/function/samples/module-side-effects/resolve-id-external/_config.js @@ -1,8 +1,12 @@ -const assert = require('assert'); -const path = require('path'); +const assert = require('node:assert'); +const path = require('node:path'); +/** + * @type {string[]} + */ const sideEffects = []; +const { getObject } = require('../../../../testHelpers'); -module.exports = { +module.exports = defineTest({ description: 'does not include modules without used exports if moduleSideEffect is false', context: { require(id) { @@ -33,53 +37,54 @@ module.exports = { return JSON.parse(id.split('-')[3]); } }, - plugins: { - name: 'test-plugin', - resolveId(id) { - if (!path.isAbsolute(id)) { - return { - id, - external: true, - moduleSideEffects: JSON.parse(id.split('-')[1]) - }; - } - }, - buildEnd() { - assert.deepStrictEqual( - Array.from(this.getModuleIds()) - .filter(id => !path.isAbsolute(id)) - .sort() - .map(id => ({ id, hasModuleSideEffects: this.getModuleInfo(id).hasModuleSideEffects })), - [ - { id: 'sideeffects-false-usereffects-false', hasModuleSideEffects: false }, + plugins: [ + { + name: 'test-plugin', + resolveId(id) { + if (!path.isAbsolute(id)) { + return { + id, + external: true, + moduleSideEffects: JSON.parse(id.split('-')[1]) + }; + } + }, + buildEnd() { + assert.deepStrictEqual( + getObject( + [...this.getModuleIds()] + .filter(id => !path.isAbsolute(id)) + .sort() + .map(id => [id, this.getModuleInfo(id).moduleSideEffects]) + ), { - id: 'sideeffects-false-usereffects-false-unused-import', - hasModuleSideEffects: false - }, - { id: 'sideeffects-false-usereffects-false-used-import', hasModuleSideEffects: false }, - { id: 'sideeffects-false-usereffects-true', hasModuleSideEffects: false }, - { id: 'sideeffects-false-usereffects-true-unused-import', hasModuleSideEffects: false }, - { id: 'sideeffects-false-usereffects-true-used-import', hasModuleSideEffects: false }, - { id: 'sideeffects-null-usereffects-false', hasModuleSideEffects: false }, - { id: 'sideeffects-null-usereffects-false-unused-import', hasModuleSideEffects: false }, - { id: 'sideeffects-null-usereffects-false-used-import', hasModuleSideEffects: false }, - { id: 'sideeffects-null-usereffects-true', hasModuleSideEffects: true }, - { id: 'sideeffects-null-usereffects-true-unused-import', hasModuleSideEffects: true }, - { id: 'sideeffects-null-usereffects-true-used-import', hasModuleSideEffects: true }, - { id: 'sideeffects-true-usereffects-false', hasModuleSideEffects: true }, - { id: 'sideeffects-true-usereffects-false-unused-import', hasModuleSideEffects: true }, - { id: 'sideeffects-true-usereffects-false-used-import', hasModuleSideEffects: true }, - { id: 'sideeffects-true-usereffects-true', hasModuleSideEffects: true }, - { id: 'sideeffects-true-usereffects-true-unused-import', hasModuleSideEffects: true }, - { id: 'sideeffects-true-usereffects-true-used-import', hasModuleSideEffects: true } - ] - ); + 'sideeffects-false-usereffects-false': false, + 'sideeffects-false-usereffects-false-unused-import': false, + 'sideeffects-false-usereffects-false-used-import': false, + 'sideeffects-false-usereffects-true': false, + 'sideeffects-false-usereffects-true-unused-import': false, + 'sideeffects-false-usereffects-true-used-import': false, + 'sideeffects-null-usereffects-false': false, + 'sideeffects-null-usereffects-false-unused-import': false, + 'sideeffects-null-usereffects-false-used-import': false, + 'sideeffects-null-usereffects-true': true, + 'sideeffects-null-usereffects-true-unused-import': true, + 'sideeffects-null-usereffects-true-used-import': true, + 'sideeffects-true-usereffects-false': true, + 'sideeffects-true-usereffects-false-unused-import': true, + 'sideeffects-true-usereffects-false-used-import': true, + 'sideeffects-true-usereffects-true': true, + 'sideeffects-true-usereffects-true-unused-import': true, + 'sideeffects-true-usereffects-true-used-import': true + } + ); + } } - } + ] }, warnings(warnings) { for (const warning of warnings) { assert.strictEqual(warning.code, 'UNUSED_EXTERNAL_IMPORT'); } } -}; +}); diff --git a/test/function/samples/module-side-effects/resolve-id/_config.js b/test/function/samples/module-side-effects/resolve-id/_config.js index b67cfa57c98..15c6d1aef2c 100644 --- a/test/function/samples/module-side-effects/resolve-id/_config.js +++ b/test/function/samples/module-side-effects/resolve-id/_config.js @@ -1,8 +1,10 @@ -const assert = require('assert'); -const path = require('path'); +const assert = require('node:assert'); +const path = require('node:path'); +const { getObject } = require('../../../../testHelpers'); + const sideEffects = []; -module.exports = { +module.exports = defineTest({ description: 'does not include modules without used exports if moduleSideEffect is false', context: { sideEffects @@ -30,59 +32,60 @@ module.exports = { return JSON.parse(id.split('-')[3]); } }, - plugins: { - name: 'test-plugin', - resolveId(id) { - if (!path.isAbsolute(id)) { - return { - id, - external: false, - moduleSideEffects: JSON.parse(id.split('-')[1]) - }; - } - }, - load(id) { - if (!path.isAbsolute(id)) { - const sideEffects = JSON.parse(id.split('-')[1]); - const userEffects = JSON.parse(id.split('-')[3]); - assert.strictEqual( - this.getModuleInfo(id).hasModuleSideEffects, - typeof sideEffects === 'boolean' ? sideEffects : userEffects + plugins: [ + { + name: 'test-plugin', + resolveId(id) { + if (!path.isAbsolute(id)) { + return { + id, + external: false, + moduleSideEffects: JSON.parse(id.split('-')[1]) + }; + } + }, + load(id) { + if (!path.isAbsolute(id)) { + const sideEffects = JSON.parse(id.split('-')[1]); + const userEffects = JSON.parse(id.split('-')[3]); + assert.strictEqual( + this.getModuleInfo(id).moduleSideEffects, + typeof sideEffects === 'boolean' ? sideEffects : userEffects + ); + return `export const value = '${id}'; sideEffects.push(value);`; + } + }, + buildEnd() { + assert.deepStrictEqual( + getObject( + [...this.getModuleIds()] + .filter(id => !path.isAbsolute(id)) + .sort() + .map(id => [id, this.getModuleInfo(id).moduleSideEffects]) + ), + { + 'sideeffects-false-usereffects-false': false, + 'sideeffects-false-usereffects-false-unused-import': false, + 'sideeffects-false-usereffects-false-used-import': false, + 'sideeffects-false-usereffects-true': false, + 'sideeffects-false-usereffects-true-unused-import': false, + 'sideeffects-false-usereffects-true-used-import': false, + 'sideeffects-null-usereffects-false': false, + 'sideeffects-null-usereffects-false-unused-import': false, + 'sideeffects-null-usereffects-false-used-import': false, + 'sideeffects-null-usereffects-true': true, + 'sideeffects-null-usereffects-true-unused-import': true, + 'sideeffects-null-usereffects-true-used-import': true, + 'sideeffects-true-usereffects-false': true, + 'sideeffects-true-usereffects-false-unused-import': true, + 'sideeffects-true-usereffects-false-used-import': true, + 'sideeffects-true-usereffects-true': true, + 'sideeffects-true-usereffects-true-unused-import': true, + 'sideeffects-true-usereffects-true-used-import': true + } ); - return `export const value = '${id}'; sideEffects.push(value);`; } - }, - buildEnd() { - assert.deepStrictEqual( - Array.from(this.getModuleIds()) - .filter(id => !path.isAbsolute(id)) - .sort() - .map(id => ({ id, hasModuleSideEffects: this.getModuleInfo(id).hasModuleSideEffects })), - [ - { id: 'sideeffects-false-usereffects-false', hasModuleSideEffects: false }, - { - id: 'sideeffects-false-usereffects-false-unused-import', - hasModuleSideEffects: false - }, - { id: 'sideeffects-false-usereffects-false-used-import', hasModuleSideEffects: false }, - { id: 'sideeffects-false-usereffects-true', hasModuleSideEffects: false }, - { id: 'sideeffects-false-usereffects-true-unused-import', hasModuleSideEffects: false }, - { id: 'sideeffects-false-usereffects-true-used-import', hasModuleSideEffects: false }, - { id: 'sideeffects-null-usereffects-false', hasModuleSideEffects: false }, - { id: 'sideeffects-null-usereffects-false-unused-import', hasModuleSideEffects: false }, - { id: 'sideeffects-null-usereffects-false-used-import', hasModuleSideEffects: false }, - { id: 'sideeffects-null-usereffects-true', hasModuleSideEffects: true }, - { id: 'sideeffects-null-usereffects-true-unused-import', hasModuleSideEffects: true }, - { id: 'sideeffects-null-usereffects-true-used-import', hasModuleSideEffects: true }, - { id: 'sideeffects-true-usereffects-false', hasModuleSideEffects: true }, - { id: 'sideeffects-true-usereffects-false-unused-import', hasModuleSideEffects: true }, - { id: 'sideeffects-true-usereffects-false-used-import', hasModuleSideEffects: true }, - { id: 'sideeffects-true-usereffects-true', hasModuleSideEffects: true }, - { id: 'sideeffects-true-usereffects-true-unused-import', hasModuleSideEffects: true }, - { id: 'sideeffects-true-usereffects-true-used-import', hasModuleSideEffects: true } - ] - ); } - } + ] } -}; +}); diff --git a/test/function/samples/module-side-effects/transform/_config.js b/test/function/samples/module-side-effects/transform/_config.js index 2ec9cacdaa7..03e489b4925 100644 --- a/test/function/samples/module-side-effects/transform/_config.js +++ b/test/function/samples/module-side-effects/transform/_config.js @@ -1,8 +1,8 @@ -const assert = require('assert'); -const path = require('path'); +const assert = require('node:assert'); +const path = require('node:path'); const sideEffects = []; -module.exports = { +module.exports = defineTest({ description: 'handles setting moduleSideEffects in the transform hook', context: { sideEffects @@ -69,4 +69,4 @@ module.exports = { } ] } -}; +}); diff --git a/test/function/samples/module-side-effects/writable/_config.js b/test/function/samples/module-side-effects/writable/_config.js new file mode 100644 index 00000000000..4bbc2bfba31 --- /dev/null +++ b/test/function/samples/module-side-effects/writable/_config.js @@ -0,0 +1,68 @@ +// We prefix the polyfill with \0 to tell other plugins not to try to load or +// transform it +const POLYFILL_ID = '\0polyfill'; +const PROXY_SUFFIX = '?inject-polyfill-proxy'; + +module.exports = defineTest({ + description: 'ModuleInfo.moduleSideEffects should be writable during build time', + options: { + treeshake: { moduleSideEffects: false }, + plugins: [ + { + name: 'inject-polyfill', + async resolveId(source, importer, options) { + if (source === POLYFILL_ID) { + // It is important that side effects are always respected for + // polyfills, otherwise using treeshake.moduleSideEffects: false + // may prevent the polyfill from being included. + return { id: POLYFILL_ID, moduleSideEffects: true }; + } + if (options.isEntry) { + // Determine what the actual entry would have been. + const resolution = await this.resolve(source, importer, options); + // If it cannot be resolved or is external, just return it so that + // Rollup can display an error + if (!resolution || resolution.external) return resolution; + // In the load hook of the proxy, need to know if the entry has a + // default export. In the load hook, however, we no longer have the + // full "resolution" object that may contain meta-data from other + // plugins that is only added on first load. Therefore we trigger + // loading here. + const moduleInfo = await this.load(resolution); + // We need to make sure side effects in the original entry point + // are respected even for treeshake.moduleSideEffects: false + moduleInfo.moduleSideEffects = true; + // It is important that the new entry does not start with \0 and + // has the same directory as the original one to not mess up + // relative external import generation. Also keeping the name and + // just adding a "?query" to the end ensures that preserveModules + // will generate the original entry name for this entry. + return `${resolution.id}${PROXY_SUFFIX}`; + } + return null; + }, + load(id) { + if (id === POLYFILL_ID) { + return 'global.polyfilled = true;'; + } + if (id.endsWith(PROXY_SUFFIX)) { + const entryId = id.slice(0, -PROXY_SUFFIX.length); + // We know its ModuleInfo is reliable because we awaited this.load + // in resolveId + const { hasDefaultExport } = this.getModuleInfo(entryId); + let code = + `import ${JSON.stringify(POLYFILL_ID)};` + + `export * from ${JSON.stringify(entryId)};`; + // Namespace reexports do not reexport default, so we need special + // handling here + if (hasDefaultExport) { + code += `export { default } from ${JSON.stringify(entryId)};`; + } + return code; + } + return null; + } + } + ] + } +}); diff --git a/test/function/samples/module-side-effects/writable/foo.js b/test/function/samples/module-side-effects/writable/foo.js new file mode 100644 index 00000000000..d02ba545bd3 --- /dev/null +++ b/test/function/samples/module-side-effects/writable/foo.js @@ -0,0 +1 @@ +export default 'foo'; diff --git a/test/function/samples/module-side-effects/writable/main.js b/test/function/samples/module-side-effects/writable/main.js new file mode 100644 index 00000000000..36f47a320b0 --- /dev/null +++ b/test/function/samples/module-side-effects/writable/main.js @@ -0,0 +1,2 @@ +assert.ok(global.polyfilled, 'polyfill working'); +delete global.polyfilled; diff --git a/test/function/samples/module-sort-order/_config.js b/test/function/samples/module-sort-order/_config.js index 9b7f002d0d3..9fbcae5201f 100644 --- a/test/function/samples/module-sort-order/_config.js +++ b/test/function/samples/module-sort-order/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'module sorter is not confused by top-level call expressions' -}; +}); diff --git a/test/function/samples/module-tree/_config.js b/test/function/samples/module-tree/_config.js index ca506e1aae8..8c978703ffe 100644 --- a/test/function/samples/module-tree/_config.js +++ b/test/function/samples/module-tree/_config.js @@ -1,7 +1,7 @@ -const path = require('path'); -const assert = require('assert'); +const assert = require('node:assert'); +const path = require('node:path'); -module.exports = { +module.exports = defineTest({ description: 'bundle.modules includes dependencies (#903)', bundle(bundle) { const modules = bundle.cache.modules.map(module => ({ @@ -34,9 +34,9 @@ module.exports = { }, warnings: [ { - chunkName: 'main', code: 'EMPTY_BUNDLE', - message: 'Generated an empty chunk: "main"' + message: 'Generated an empty chunk: "main".', + names: ['main'] } ] -}; +}); diff --git a/test/function/samples/mutate-via-parameter/_config.js b/test/function/samples/mutate-via-parameter/_config.js new file mode 100644 index 00000000000..e54a34f1e31 --- /dev/null +++ b/test/function/samples/mutate-via-parameter/_config.js @@ -0,0 +1,9 @@ +const assert = require('node:assert'); + +module.exports = defineTest({ + description: + 'respects variable mutations via unknown parameter values if we lose track of a function', + exports({ test }) { + assert.ok(test(state => (state.modified = true))); + } +}); diff --git a/test/function/samples/mutate-via-parameter/main.js b/test/function/samples/mutate-via-parameter/main.js new file mode 100644 index 00000000000..d1bf83b4bf7 --- /dev/null +++ b/test/function/samples/mutate-via-parameter/main.js @@ -0,0 +1,8 @@ +export function test(callback) { + const state = { + modified: false + }; + callback(state); + if (state.modified) return true; + return false; +} diff --git a/test/function/samples/name-conflict-object/_config.js b/test/function/samples/name-conflict-object/_config.js index 57085bb23a0..18f76ca1d44 100644 --- a/test/function/samples/name-conflict-object/_config.js +++ b/test/function/samples/name-conflict-object/_config.js @@ -1,6 +1,6 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'avoids name conflicts with local variables named Object', options: { external: 'external', @@ -17,4 +17,4 @@ module.exports = { assert.strictEqual(exports.foo.foo, 'foo'); assert.strictEqual(exports.foo.default.foo, 'foo'); } -}; +}); diff --git a/test/function/samples/name-conflict-promise/_config.js b/test/function/samples/name-conflict-promise/_config.js index 10407fe2301..a6581386894 100644 --- a/test/function/samples/name-conflict-promise/_config.js +++ b/test/function/samples/name-conflict-promise/_config.js @@ -1,9 +1,9 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'avoids name conflicts with local variables named Promise', async exports(exports) { assert.strictEqual(exports.Promise, 'bar'); assert.strictEqual((await exports.promised).Promise, 'foo'); } -}; +}); diff --git a/test/function/samples/name-conflict-symbol/_config.js b/test/function/samples/name-conflict-symbol/_config.js index 1ef944a3218..1cd7b638ffe 100644 --- a/test/function/samples/name-conflict-symbol/_config.js +++ b/test/function/samples/name-conflict-symbol/_config.js @@ -1,14 +1,14 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'avoids name conflicts with local variables named Symbol', options: { output: { - namespaceToStringTag: true + generatedCode: { symbols: true } } }, exports(exports) { assert.strictEqual(exports.Symbol, null); assert.strictEqual(exports.toString(), '[object Module]'); } -}; +}); diff --git a/test/function/samples/named-external-method-in-prototype/_config.js b/test/function/samples/named-external-method-in-prototype/_config.js index bb26af2864c..624e4a7bc87 100644 --- a/test/function/samples/named-external-method-in-prototype/_config.js +++ b/test/function/samples/named-external-method-in-prototype/_config.js @@ -1,9 +1,10 @@ -module.exports = { +module.exports = defineTest({ description: 'method of external named import used inside prototype method (#68)', context: { // override require here, making "foo" appear as a global module require(name) { if (name === 'bar') { + // @ts-expect-error test file is not included in project return require('./bar'); } return require(name); @@ -12,4 +13,4 @@ module.exports = { options: { external: ['bar'] } -}; +}); diff --git a/test/function/samples/namespace-import-deoptimization/_config.js b/test/function/samples/namespace-import-deoptimization/_config.js new file mode 100644 index 00000000000..ae69c1b87de --- /dev/null +++ b/test/function/samples/namespace-import-deoptimization/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'includes namespace import properties accessed in try-catch callbacks' +}); diff --git a/test/function/samples/namespace-import-deoptimization/dep.js b/test/function/samples/namespace-import-deoptimization/dep.js new file mode 100644 index 00000000000..88dbc149bf1 --- /dev/null +++ b/test/function/samples/namespace-import-deoptimization/dep.js @@ -0,0 +1 @@ +export const foo = { bar: 'baz' }; diff --git a/test/function/samples/namespace-import-deoptimization/main.js b/test/function/samples/namespace-import-deoptimization/main.js new file mode 100644 index 00000000000..e54604fea13 --- /dev/null +++ b/test/function/samples/namespace-import-deoptimization/main.js @@ -0,0 +1,13 @@ +import * as ns from './dep.js'; + +function runInTryCatch(fn) { + try { + return fn(); + } catch {} +} + +function getBar(obj) { + return obj.bar; +} + +assert.strictEqual(runInTryCatch(() => getBar(ns.foo)), 'baz'); diff --git a/test/function/samples/namespace-include-external-by-name/_config.js b/test/function/samples/namespace-include-external-by-name/_config.js new file mode 100644 index 00000000000..8060ecf0524 --- /dev/null +++ b/test/function/samples/namespace-include-external-by-name/_config.js @@ -0,0 +1,13 @@ +module.exports = defineTest({ + description: 'includes members from external namespaces', + options: { + external: ['external'] + }, + context: { + require(name) { + if (name === 'external') { + return { fromExternal: true }; + } + } + } +}); diff --git a/test/function/samples/namespace-include-external-by-name/dep.js b/test/function/samples/namespace-include-external-by-name/dep.js new file mode 100644 index 00000000000..70aff6d1365 --- /dev/null +++ b/test/function/samples/namespace-include-external-by-name/dep.js @@ -0,0 +1,2 @@ +export const value = true; +export * from 'external'; diff --git a/test/function/samples/namespace-include-external-by-name/main.js b/test/function/samples/namespace-include-external-by-name/main.js new file mode 100644 index 00000000000..57584ca6afc --- /dev/null +++ b/test/function/samples/namespace-include-external-by-name/main.js @@ -0,0 +1,11 @@ +import * as a from './dep.js'; + +const b = a; + +if (!b.fromExternal) { + throw new Error('External export not included'); +} + +if (!b.value) { + throw new Error('Internal export not included'); +} diff --git a/test/function/samples/namespace-include-external/_config.js b/test/function/samples/namespace-include-external/_config.js new file mode 100644 index 00000000000..24f28a1adc0 --- /dev/null +++ b/test/function/samples/namespace-include-external/_config.js @@ -0,0 +1,16 @@ +module.exports = defineTest({ + description: 'includes namespaces including external namespaces', + options: { + external: ['external'] + }, + context: { + require(name) { + if (name === 'external') { + return { fromExternal: true }; + } + } + }, + exports({ test }) { + test(['value', 'fromExternal']); + } +}); diff --git a/test/function/samples/namespace-include-external/dep.js b/test/function/samples/namespace-include-external/dep.js new file mode 100644 index 00000000000..70aff6d1365 --- /dev/null +++ b/test/function/samples/namespace-include-external/dep.js @@ -0,0 +1,2 @@ +export const value = true; +export * from 'external'; diff --git a/test/function/samples/namespace-include-external/main.js b/test/function/samples/namespace-include-external/main.js new file mode 100644 index 00000000000..1aa10248a6c --- /dev/null +++ b/test/function/samples/namespace-include-external/main.js @@ -0,0 +1,11 @@ +import * as a from './dep.js'; + +const b = a; + +export function test(names) { + for (const name of names) { + if (!(name in b)) { + throw new Error(`Export ${name} not included`); + } + } +} diff --git a/test/function/samples/namespace-keys-are-sorted/_config.js b/test/function/samples/namespace-keys-are-sorted/_config.js new file mode 100644 index 00000000000..8c49c57fb2c --- /dev/null +++ b/test/function/samples/namespace-keys-are-sorted/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'supports sorted namespace keys' +}); diff --git a/test/function/samples/namespace-keys-are-sorted/bar.js b/test/function/samples/namespace-keys-are-sorted/bar.js new file mode 100644 index 00000000000..57a77b2323f --- /dev/null +++ b/test/function/samples/namespace-keys-are-sorted/bar.js @@ -0,0 +1 @@ +export const bar = 'foo'; diff --git a/test/function/samples/namespace-keys-are-sorted/foo.js b/test/function/samples/namespace-keys-are-sorted/foo.js new file mode 100644 index 00000000000..504fa7f5f23 --- /dev/null +++ b/test/function/samples/namespace-keys-are-sorted/foo.js @@ -0,0 +1,17 @@ +const foo = 'bar'; + +export { foo as ø }; +export { foo as z }; +export { foo as ZZZ }; +export { foo as $ }; +export { foo as ς }; +export default foo; +export { foo as ___ }; +export { foo as aa }; +export { foo as AA }; +export * as namespace from './bar.js'; +export { foo as Z }; +export { foo as ö }; +export { foo as A }; +export { foo }; +export { foo as $$$ }; diff --git a/test/function/samples/namespace-keys-are-sorted/main.js b/test/function/samples/namespace-keys-are-sorted/main.js new file mode 100644 index 00000000000..33dd8862834 --- /dev/null +++ b/test/function/samples/namespace-keys-are-sorted/main.js @@ -0,0 +1,19 @@ +import * as ns from './foo.js'; + +assert.deepStrictEqual(Object.getOwnPropertyNames(ns), [ + '$', + '$$$', + 'A', + 'AA', + 'Z', + 'ZZZ', + '___', + 'aa', + 'default', + 'foo', + 'namespace', + 'z', + 'ö', + 'ø', + 'ς' +]); diff --git a/test/function/samples/namespace-literal-value/_config.js b/test/function/samples/namespace-literal-value/_config.js new file mode 100644 index 00000000000..07297018242 --- /dev/null +++ b/test/function/samples/namespace-literal-value/_config.js @@ -0,0 +1,9 @@ +const assert = require('node:assert'); + +module.exports = defineTest({ + description: 'does not simplify accessing unknown properties from namespaces', + exports({ isNull }) { + assert.strictEqual(isNull('a'), true); + assert.strictEqual(isNull('b'), false); + } +}); diff --git a/test/function/samples/namespace-literal-value/main.js b/test/function/samples/namespace-literal-value/main.js new file mode 100644 index 00000000000..8eee5b022ea --- /dev/null +++ b/test/function/samples/namespace-literal-value/main.js @@ -0,0 +1,3 @@ +import * as ns from './namespace'; + +export const isNull = prop => (ns[prop] === null ? true : false); diff --git a/test/function/samples/namespace-literal-value/namespace.js b/test/function/samples/namespace-literal-value/namespace.js new file mode 100644 index 00000000000..1d944cff982 --- /dev/null +++ b/test/function/samples/namespace-literal-value/namespace.js @@ -0,0 +1,2 @@ +export const a = null; +export const b = true; diff --git a/test/function/samples/namespace-member-side-effects/assignment/_config.js b/test/function/samples/namespace-member-side-effects/assignment/_config.js new file mode 100644 index 00000000000..e60754de781 --- /dev/null +++ b/test/function/samples/namespace-member-side-effects/assignment/_config.js @@ -0,0 +1,6 @@ +module.exports = defineTest({ + description: 'checks side effects when reassigning namespace members', + options: { + treeshake: { tryCatchDeoptimization: false } + } +}); diff --git a/test/function/samples/namespace-member-side-effects/assignment/api/index.js b/test/function/samples/namespace-member-side-effects/assignment/api/index.js new file mode 100644 index 00000000000..6c17e63eee6 --- /dev/null +++ b/test/function/samples/namespace-member-side-effects/assignment/api/index.js @@ -0,0 +1,5 @@ +import * as namespace from './namespace.js'; + +export default { + namespace +}; diff --git a/test/function/samples/namespace-member-side-effects/assignment/api/namespace.js b/test/function/samples/namespace-member-side-effects/assignment/api/namespace.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/function/samples/namespace-member-side-effects/assignment/main.js b/test/function/samples/namespace-member-side-effects/assignment/main.js new file mode 100644 index 00000000000..5cef4888c24 --- /dev/null +++ b/test/function/samples/namespace-member-side-effects/assignment/main.js @@ -0,0 +1,9 @@ +import api from './api/index'; + +let errored = false; +try { + api.namespace.x = 1; +} catch { + errored = true; +} +assert.ok(errored, 'namespace assignment should be preserved'); diff --git a/test/function/samples/namespace-member-side-effects/call/_config.js b/test/function/samples/namespace-member-side-effects/call/_config.js new file mode 100644 index 00000000000..2c88f17e7e5 --- /dev/null +++ b/test/function/samples/namespace-member-side-effects/call/_config.js @@ -0,0 +1,6 @@ +module.exports = defineTest({ + description: 'checks side effects when calling a namespace', + options: { + treeshake: { tryCatchDeoptimization: false } + } +}); diff --git a/test/function/samples/namespace-member-side-effects/call/api/index.js b/test/function/samples/namespace-member-side-effects/call/api/index.js new file mode 100644 index 00000000000..6c17e63eee6 --- /dev/null +++ b/test/function/samples/namespace-member-side-effects/call/api/index.js @@ -0,0 +1,5 @@ +import * as namespace from './namespace.js'; + +export default { + namespace +}; diff --git a/test/function/samples/namespace-member-side-effects/call/api/namespace.js b/test/function/samples/namespace-member-side-effects/call/api/namespace.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/function/samples/namespace-member-side-effects/call/main.js b/test/function/samples/namespace-member-side-effects/call/main.js new file mode 100644 index 00000000000..8ff2242d9b9 --- /dev/null +++ b/test/function/samples/namespace-member-side-effects/call/main.js @@ -0,0 +1,9 @@ +import api from './api/index'; + +let errored = false +try { + api.namespace() +} catch { + errored = true; +} +assert.ok(errored, 'namespace call should be preserved') diff --git a/test/function/samples/namespace-member-side-effects/member-call/_config.js b/test/function/samples/namespace-member-side-effects/member-call/_config.js new file mode 100644 index 00000000000..6898b7ef559 --- /dev/null +++ b/test/function/samples/namespace-member-side-effects/member-call/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'respects side effects when namespace members are called' +}); diff --git a/test/function/samples/namespace-member-side-effects/member-call/api/index.js b/test/function/samples/namespace-member-side-effects/member-call/api/index.js new file mode 100644 index 00000000000..6c17e63eee6 --- /dev/null +++ b/test/function/samples/namespace-member-side-effects/member-call/api/index.js @@ -0,0 +1,5 @@ +import * as namespace from './namespace.js'; + +export default { + namespace +}; diff --git a/test/function/samples/namespace-member-side-effects/member-call/api/namespace.js b/test/function/samples/namespace-member-side-effects/member-call/api/namespace.js new file mode 100644 index 00000000000..99b514b3ef0 --- /dev/null +++ b/test/function/samples/namespace-member-side-effects/member-call/api/namespace.js @@ -0,0 +1,5 @@ +import { sideEffects } from './sideEffects'; + +export function sideEffectFunction() { + sideEffects.push('fn called'); +} diff --git a/test/function/samples/namespace-member-side-effects/member-call/api/sideEffects.js b/test/function/samples/namespace-member-side-effects/member-call/api/sideEffects.js new file mode 100644 index 00000000000..5f93e6936bf --- /dev/null +++ b/test/function/samples/namespace-member-side-effects/member-call/api/sideEffects.js @@ -0,0 +1 @@ +export const sideEffects = []; diff --git a/test/function/samples/namespace-member-side-effects/member-call/main.js b/test/function/samples/namespace-member-side-effects/member-call/main.js new file mode 100644 index 00000000000..e6487c7fd9e --- /dev/null +++ b/test/function/samples/namespace-member-side-effects/member-call/main.js @@ -0,0 +1,6 @@ +import api from './api/index.js'; +import { sideEffects } from './api/sideEffects'; + +api.namespace.sideEffectFunction(); + +assert.deepStrictEqual(sideEffects, ['fn called']); diff --git a/test/function/samples/namespace-member-side-effects/missing-access/_config.js b/test/function/samples/namespace-member-side-effects/missing-access/_config.js new file mode 100644 index 00000000000..0b3f7d78605 --- /dev/null +++ b/test/function/samples/namespace-member-side-effects/missing-access/_config.js @@ -0,0 +1,6 @@ +module.exports = defineTest({ + description: 'respects side effects when accessing missing namespace members', + options: { + treeshake: { tryCatchDeoptimization: false } + } +}); diff --git a/test/function/samples/namespace-member-side-effects/missing-access/api/index.js b/test/function/samples/namespace-member-side-effects/missing-access/api/index.js new file mode 100644 index 00000000000..6c17e63eee6 --- /dev/null +++ b/test/function/samples/namespace-member-side-effects/missing-access/api/index.js @@ -0,0 +1,5 @@ +import * as namespace from './namespace.js'; + +export default { + namespace +}; diff --git a/test/function/samples/namespace-member-side-effects/missing-access/api/namespace.js b/test/function/samples/namespace-member-side-effects/missing-access/api/namespace.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/function/samples/namespace-member-side-effects/missing-access/main.js b/test/function/samples/namespace-member-side-effects/missing-access/main.js new file mode 100644 index 00000000000..539278fb79a --- /dev/null +++ b/test/function/samples/namespace-member-side-effects/missing-access/main.js @@ -0,0 +1,9 @@ +import api from './api/index'; + +let errored = false; +try { + api.namespace.missing.foo; +} catch { + errored = true; +} +assert.ok(errored, 'unknown nested member access should be preserved'); diff --git a/test/function/samples/namespace-member-side-effects/unknown-access/_config.js b/test/function/samples/namespace-member-side-effects/unknown-access/_config.js new file mode 100644 index 00000000000..60d9f90176d --- /dev/null +++ b/test/function/samples/namespace-member-side-effects/unknown-access/_config.js @@ -0,0 +1,7 @@ +module.exports = defineTest({ + description: 'respects side effects when accessing unknown namespace members', + options: { + external: ['external'], + treeshake: { tryCatchDeoptimization: false } + } +}); diff --git a/test/function/samples/namespace-member-side-effects/unknown-access/api/index.js b/test/function/samples/namespace-member-side-effects/unknown-access/api/index.js new file mode 100644 index 00000000000..6c17e63eee6 --- /dev/null +++ b/test/function/samples/namespace-member-side-effects/unknown-access/api/index.js @@ -0,0 +1,5 @@ +import * as namespace from './namespace.js'; + +export default { + namespace +}; diff --git a/test/function/samples/namespace-member-side-effects/unknown-access/api/namespace.js b/test/function/samples/namespace-member-side-effects/unknown-access/api/namespace.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/function/samples/namespace-member-side-effects/unknown-access/main.js b/test/function/samples/namespace-member-side-effects/unknown-access/main.js new file mode 100644 index 00000000000..337a6f6e2d5 --- /dev/null +++ b/test/function/samples/namespace-member-side-effects/unknown-access/main.js @@ -0,0 +1,10 @@ +import api from './api/index'; +import { external } from 'external'; + +let errored = false; +try { + api.namespace[external].foo; +} catch { + errored = true; +} +assert.ok(errored, 'unknown nested member access should be preserved'); diff --git a/test/function/samples/namespace-missing-export/_config.js b/test/function/samples/namespace-missing-export/_config.js index 9381fe1d17a..fc1445e5424 100644 --- a/test/function/samples/namespace-missing-export/_config.js +++ b/test/function/samples/namespace-missing-export/_config.js @@ -1,28 +1,28 @@ -const path = require('path'); +const path = require('node:path'); +const ID_MAIN = path.join(__dirname, 'main.js'); +const ID_EMPTY = path.join(__dirname, 'empty.js'); -module.exports = { +module.exports = defineTest({ description: 'replaces missing namespace members with undefined and warns about them', warnings: [ { + binding: 'foo', code: 'MISSING_EXPORT', - exporter: 'empty.js', - importer: 'main.js', - id: path.join(__dirname, 'main.js'), - missing: 'foo', - message: `'foo' is not exported by 'empty.js'`, + exporter: ID_EMPTY, + id: ID_MAIN, + message: 'main.js (3:25): "foo" is not exported by "empty.js", imported by "main.js".', + url: 'https://rollupjs.org/troubleshooting/#error-name-is-not-exported-by-module', pos: 61, loc: { - file: require('path').resolve(__dirname, 'main.js'), - line: 3, - column: 25 + column: 25, + file: ID_MAIN, + line: 3 }, frame: ` 1: import * as mod from './empty.js'; 2: 3: assert.equal( typeof mod.foo, 'undefined' ); - ^ - `, - url: `https://rollupjs.org/guide/en/#error-name-is-not-exported-by-module` + ^` } ] -}; +}); diff --git a/test/function/samples/namespace-mutation-unresolvable/_config.js b/test/function/samples/namespace-mutation-unresolvable/_config.js new file mode 100644 index 00000000000..19e2b452cd4 --- /dev/null +++ b/test/function/samples/namespace-mutation-unresolvable/_config.js @@ -0,0 +1,6 @@ +module.exports = defineTest({ + description: 'detects mutations of unresolvable namespace members', + exports({ test }) { + test(['value', 'value2']); + } +}); diff --git a/test/function/samples/namespace-mutation-unresolvable/dep.js b/test/function/samples/namespace-mutation-unresolvable/dep.js new file mode 100644 index 00000000000..a68f2b5529b --- /dev/null +++ b/test/function/samples/namespace-mutation-unresolvable/dep.js @@ -0,0 +1,2 @@ +export const value = { mutated: false }; +export * from './dep2.js'; diff --git a/test/function/samples/namespace-mutation-unresolvable/dep2.js b/test/function/samples/namespace-mutation-unresolvable/dep2.js new file mode 100644 index 00000000000..a30c565b31c --- /dev/null +++ b/test/function/samples/namespace-mutation-unresolvable/dep2.js @@ -0,0 +1 @@ +export const value2 = { mutated: false }; diff --git a/test/function/samples/namespace-mutation-unresolvable/main.js b/test/function/samples/namespace-mutation-unresolvable/main.js new file mode 100644 index 00000000000..a0689be7ad0 --- /dev/null +++ b/test/function/samples/namespace-mutation-unresolvable/main.js @@ -0,0 +1,16 @@ +import * as a from './dep.js'; +import { value2 } from './dep2.js'; + +const b = a; + +export function test(keys) { + for (const key of keys) { + b[key].mutated = true; + } + if (!a.value.mutated) { + throw new Error('Mutation 1 not reflected'); + } + if (!value2.mutated) { + throw new Error('Mutation 2 not reflected'); + } +} diff --git a/test/function/samples/namespace-mutation/_config.js b/test/function/samples/namespace-mutation/_config.js new file mode 100644 index 00000000000..864f19d88a1 --- /dev/null +++ b/test/function/samples/namespace-mutation/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'detects mutations of namespace members' +}); diff --git a/test/function/samples/namespace-mutation/dep.js b/test/function/samples/namespace-mutation/dep.js new file mode 100644 index 00000000000..a68f2b5529b --- /dev/null +++ b/test/function/samples/namespace-mutation/dep.js @@ -0,0 +1,2 @@ +export const value = { mutated: false }; +export * from './dep2.js'; diff --git a/test/function/samples/namespace-mutation/dep2.js b/test/function/samples/namespace-mutation/dep2.js new file mode 100644 index 00000000000..a30c565b31c --- /dev/null +++ b/test/function/samples/namespace-mutation/dep2.js @@ -0,0 +1 @@ +export const value2 = { mutated: false }; diff --git a/test/function/samples/namespace-mutation/main.js b/test/function/samples/namespace-mutation/main.js new file mode 100644 index 00000000000..f7573627cc7 --- /dev/null +++ b/test/function/samples/namespace-mutation/main.js @@ -0,0 +1,15 @@ +import * as a from './dep.js'; +import { value2 } from './dep2.js'; + +const b = a; +b.value.mutated = true; + +if (!a.value.mutated) { + throw new Error('Mutation 1 not reflected'); +} + +b.value2.mutated = true; + +if (!value2.mutated) { + throw new Error('Mutation 2 not reflected'); +} diff --git a/test/function/samples/namespace-override/_config.js b/test/function/samples/namespace-override/_config.js new file mode 100644 index 00000000000..16502433322 --- /dev/null +++ b/test/function/samples/namespace-override/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'does not warn when overriding namespace reexports with explicit ones' +}); diff --git a/test/function/samples/namespace-override/a.js b/test/function/samples/namespace-override/a.js new file mode 100644 index 00000000000..4ef4d03891d --- /dev/null +++ b/test/function/samples/namespace-override/a.js @@ -0,0 +1,5 @@ +export const a = 'a'; +export const aExportOverride = 'a'; +export const aReexportOverride = 'a'; +export const hiddenConflictByExport = 'a'; +export const hiddenConflictByReexport = 'a'; diff --git a/test/function/samples/namespace-override/b.js b/test/function/samples/namespace-override/b.js new file mode 100644 index 00000000000..ac9e1189e42 --- /dev/null +++ b/test/function/samples/namespace-override/b.js @@ -0,0 +1,4 @@ +export const b = 'b'; +export const hiddenConflictByExport = 'b'; +export const hiddenConflictByReexport = 'b'; +export * from './a.js'; diff --git a/test/function/samples/namespace-override/exportAll.js b/test/function/samples/namespace-override/exportAll.js new file mode 100644 index 00000000000..229f7033593 --- /dev/null +++ b/test/function/samples/namespace-override/exportAll.js @@ -0,0 +1,5 @@ +export * from './a.js'; +export * from './b.js'; +export const aExportOverride = 'override'; +export const hiddenConflictByExport = 'hidden'; +export { b as aReexportOverride, b as hiddenConflictByReexport } from './b.js'; diff --git a/test/function/samples/namespace-override/main.js b/test/function/samples/namespace-override/main.js new file mode 100644 index 00000000000..0ad3e6b4278 --- /dev/null +++ b/test/function/samples/namespace-override/main.js @@ -0,0 +1,12 @@ +import * as ns from './exportAll.js'; +import { hiddenConflictByExport, hiddenConflictByReexport } from './exportAll.js'; + +assert.deepStrictEqual(ns, { + __proto__: null, + a: 'a', + aExportOverride: 'override', + aReexportOverride: 'b', + b: 'b', + hiddenConflictByExport: 'hidden', + hiddenConflictByReexport: 'b', +}); diff --git a/test/function/samples/namespace-reassign-import-fails/_config.js b/test/function/samples/namespace-reassign-import-fails/_config.js index 752f319698f..996d21a0317 100644 --- a/test/function/samples/namespace-reassign-import-fails/_config.js +++ b/test/function/samples/namespace-reassign-import-fails/_config.js @@ -1,10 +1,10 @@ -const assert = require('assert'); -const path = require('path'); -const { assertIncludes } = require('../../../utils.js'); - +const assert = require('node:assert'); +const path = require('node:path'); +const { assertIncludes } = require('../../../testHelpers.js'); const ID_MAIN = path.join(__dirname, 'main.js'); +const ID_FOO = path.join(__dirname, 'foo.js'); -module.exports = { +module.exports = defineTest({ description: 'warns for reassignments to namespace exports', code(code) { assertIncludes(code, 'foo = 2'); @@ -12,65 +12,61 @@ module.exports = { }, warnings: [ { + binding: 'bar', code: 'MISSING_EXPORT', - exporter: 'foo.js', - frame: ` - 2: - 3: exp.foo = 2; - 4: exp.bar = 3; - ^ - `, + exporter: ID_FOO, id: ID_MAIN, - importer: 'main.js', + message: 'main.js (4:4): "bar" is not exported by "foo.js", imported by "main.js".', + url: 'https://rollupjs.org/troubleshooting/#error-name-is-not-exported-by-module', + pos: 48, loc: { column: 4, file: ID_MAIN, line: 4 }, - message: "'bar' is not exported by 'foo.js'", - missing: 'bar', - pos: 48, - url: 'https://rollupjs.org/guide/en/#error-name-is-not-exported-by-module' + frame: ` + 2: + 3: exp.foo = 2; + 4: exp.bar = 3; + ^` }, { - code: 'ILLEGAL_NAMESPACE_REASSIGNMENT', - message: `Illegal reassignment to import 'exp'`, + code: 'ILLEGAL_REASSIGNMENT', + message: 'main.js (3:0): Illegal reassignment of import "exp" in "main.js".', id: ID_MAIN, pos: 31, loc: { + column: 0, file: ID_MAIN, - line: 3, - column: 0 + line: 3 }, frame: ` - 1: import * as exp from './foo'; - 2: - 3: exp.foo = 2; - ^ - 4: exp.bar = 3; - ` + 1: import * as exp from './foo'; + 2: + 3: exp.foo = 2; + ^ + 4: exp.bar = 3;` }, { - code: 'ILLEGAL_NAMESPACE_REASSIGNMENT', - message: `Illegal reassignment to import 'exp'`, + code: 'ILLEGAL_REASSIGNMENT', + message: 'main.js (4:0): Illegal reassignment of import "exp" in "main.js".', id: ID_MAIN, pos: 44, loc: { + column: 0, file: ID_MAIN, - line: 4, - column: 0 + line: 4 }, frame: ` - 2: - 3: exp.foo = 2; - 4: exp.bar = 3; - ^ - ` + 2: + 3: exp.foo = 2; + 4: exp.bar = 3; + ^` } ], runtimeError(error) { assert.strictEqual(error.message, 'Assignment to constant variable.'); } -}; +}); // test copied from https://github.com/esnext/es6-module-transpiler/tree/master/test/examples/namespace-reassign-import-fails diff --git a/test/function/samples/namespace-reexport-deoptimization/_config.js b/test/function/samples/namespace-reexport-deoptimization/_config.js new file mode 100644 index 00000000000..8ec3a55d7eb --- /dev/null +++ b/test/function/samples/namespace-reexport-deoptimization/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'includes namespace reexport properties accessed in try-catch callbacks' +}); diff --git a/test/function/samples/namespace-reexport-deoptimization/dep.js b/test/function/samples/namespace-reexport-deoptimization/dep.js new file mode 100644 index 00000000000..61c4dd0ad11 --- /dev/null +++ b/test/function/samples/namespace-reexport-deoptimization/dep.js @@ -0,0 +1 @@ +export * as ns from './values.js'; diff --git a/test/function/samples/namespace-reexport-deoptimization/main.js b/test/function/samples/namespace-reexport-deoptimization/main.js new file mode 100644 index 00000000000..d63204974dd --- /dev/null +++ b/test/function/samples/namespace-reexport-deoptimization/main.js @@ -0,0 +1,13 @@ +import { ns } from './dep.js'; + +function runInTryCatch(fn) { + try { + return fn(); + } catch {} +} + +function getBar(obj) { + return obj.bar; +} + +assert.strictEqual(runInTryCatch(() => getBar(ns.foo)), 'baz'); diff --git a/test/function/samples/namespace-reexport-deoptimization/values.js b/test/function/samples/namespace-reexport-deoptimization/values.js new file mode 100644 index 00000000000..88dbc149bf1 --- /dev/null +++ b/test/function/samples/namespace-reexport-deoptimization/values.js @@ -0,0 +1 @@ +export const foo = { bar: 'baz' }; diff --git a/test/function/samples/namespace-tostring/dynamic-import-default-mode/_config.js b/test/function/samples/namespace-tostring/dynamic-import-default-mode/_config.js index 0b803ae86e3..2f680fad574 100644 --- a/test/function/samples/namespace-tostring/dynamic-import-default-mode/_config.js +++ b/test/function/samples/namespace-tostring/dynamic-import-default-mode/_config.js @@ -1,12 +1,12 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'adds Symbol.toStringTag property to dynamic imports of entry chunks with default export mode', options: { input: ['main', 'foo'], output: { - namespaceToStringTag: true + generatedCode: { symbols: true } } }, async exports(exports) { @@ -15,4 +15,4 @@ module.exports = { assert.strictEqual(Object.prototype.toString.call(foo), '[object Module]'); assert.strictEqual(foo.default, 42); } -}; +}); diff --git a/test/function/samples/namespace-tostring/dynamic-import/_config.js b/test/function/samples/namespace-tostring/dynamic-import/_config.js index 90958a0c768..5a31d438523 100644 --- a/test/function/samples/namespace-tostring/dynamic-import/_config.js +++ b/test/function/samples/namespace-tostring/dynamic-import/_config.js @@ -1,16 +1,21 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'adds Symbol.toStringTag property to dynamic imports', options: { output: { - namespaceToStringTag: true + generatedCode: { symbols: true } } }, async exports(exports) { - const foo = await exports; - assert.strictEqual(foo[Symbol.toStringTag], 'Module'); - assert.strictEqual(Object.prototype.toString.call(foo), '[object Module]'); - assert.strictEqual(foo.bar, 42); + const namespace = await exports; + assert.strictEqual(Object.prototype.toString.call(namespace), '[object Module]'); + assert.strictEqual(namespace[Symbol.toStringTag], 'Module'); + assert.strictEqual(namespace.bar, 42); + + const copied = { ...namespace }; + assert.deepStrictEqual(copied, { bar: 42 }); + assert.strictEqual(Object.prototype.toString.call(copied), '[object Object]'); + assert.strictEqual(copied[Symbol.toStringTag], undefined); } -}; +}); diff --git a/test/function/samples/namespace-tostring/entry-default/_config.js b/test/function/samples/namespace-tostring/entry-default/_config.js index fd09a408684..d01569bbdb2 100644 --- a/test/function/samples/namespace-tostring/entry-default/_config.js +++ b/test/function/samples/namespace-tostring/entry-default/_config.js @@ -1,10 +1,10 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'does not add Symbol.toStringTag property to entry chunks with default export mode', options: { output: { - namespaceToStringTag: true, + generatedCode: { symbols: true }, exports: 'default' } }, @@ -13,4 +13,4 @@ module.exports = { assert.strictEqual(Object.prototype.toString.call(exports), '[object Object]'); assert.strictEqual(exports.foo, 42); } -}; +}); diff --git a/test/function/samples/namespace-tostring/entry-named/_config.js b/test/function/samples/namespace-tostring/entry-named/_config.js index 15bdf092827..f7b51b78b2b 100644 --- a/test/function/samples/namespace-tostring/entry-named/_config.js +++ b/test/function/samples/namespace-tostring/entry-named/_config.js @@ -1,16 +1,21 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'adds Symbol.toStringTag property to entry chunks with named exports', options: { output: { - namespaceToStringTag: true, + generatedCode: { symbols: true }, exports: 'named' } }, exports(exports) { - assert.strictEqual(exports[Symbol.toStringTag], 'Module'); assert.strictEqual(Object.prototype.toString.call(exports), '[object Module]'); + assert.strictEqual(exports[Symbol.toStringTag], 'Module'); assert.strictEqual(exports.foo, 42); + + const copied = { ...exports }; + assert.deepStrictEqual(copied, { foo: 42 }); + assert.strictEqual(Object.prototype.toString.call(copied), '[object Object]'); + assert.strictEqual(copied[Symbol.toStringTag], undefined); } -}; +}); diff --git a/test/function/samples/namespace-tostring/external-namespaces/_config.js b/test/function/samples/namespace-tostring/external-namespaces/_config.js index 7f3f4eda0fc..3006d93c60b 100644 --- a/test/function/samples/namespace-tostring/external-namespaces/_config.js +++ b/test/function/samples/namespace-tostring/external-namespaces/_config.js @@ -1,28 +1,32 @@ -module.exports = { +module.exports = defineTest({ description: 'adds Symbol.toStringTag property to external namespaces', options: { external(id) { return id.startsWith('external'); }, output: { - namespaceToStringTag: true, + generatedCode: { symbols: true }, interop(id) { switch (id) { - case 'external-auto': + case 'external-auto': { return 'auto'; - case 'external-default': + } + case 'external-default': { return 'default'; - case 'external-defaultOnly': + } + case 'external-defaultOnly': { return 'defaultOnly'; - default: + } + default: { throw new Error(`Unexpected require "${id}"`); + } } } } }, context: { - require(id) { + require() { return { foo: 42 }; } } -}; +}); diff --git a/test/function/samples/namespace-tostring/inlined-namespace/_config.js b/test/function/samples/namespace-tostring/inlined-namespace/_config.js index 62ccb9bf2cc..84f1a0b3d2c 100644 --- a/test/function/samples/namespace-tostring/inlined-namespace/_config.js +++ b/test/function/samples/namespace-tostring/inlined-namespace/_config.js @@ -1,8 +1,8 @@ -module.exports = { +module.exports = defineTest({ description: 'adds Symbol.toStringTag property to inlined namespaces', options: { output: { - namespaceToStringTag: true + generatedCode: { symbols: true } } } -}; +}); diff --git a/test/function/samples/namespace-tostring/interop-property-descriptor/_config.js b/test/function/samples/namespace-tostring/interop-property-descriptor/_config.js new file mode 100644 index 00000000000..37661d70c8f --- /dev/null +++ b/test/function/samples/namespace-tostring/interop-property-descriptor/_config.js @@ -0,0 +1,19 @@ +module.exports = defineTest({ + description: 'generated interop namespaces should have correct Symbol.toStringTag', + context: { + require() { + return { answer: 42 }; + } + }, + options: { + external(id) { + return id.includes('external'); + }, + output: { + generatedCode: { symbols: true }, + interop(id) { + return id.split('-')[1]; + } + } + } +}); diff --git a/test/function/samples/namespace-tostring/interop-property-descriptor/dep.js b/test/function/samples/namespace-tostring/interop-property-descriptor/dep.js new file mode 100644 index 00000000000..123aa5a11dc --- /dev/null +++ b/test/function/samples/namespace-tostring/interop-property-descriptor/dep.js @@ -0,0 +1,2 @@ +export * from 'external-default'; +export const extra = 'extra'; diff --git a/test/function/samples/namespace-tostring/interop-property-descriptor/main.js b/test/function/samples/namespace-tostring/interop-property-descriptor/main.js new file mode 100644 index 00000000000..7240b9002d0 --- /dev/null +++ b/test/function/samples/namespace-tostring/interop-property-descriptor/main.js @@ -0,0 +1,25 @@ +import * as nsDefault from 'external-default'; +import * as nsDefaultOnly from 'external-defaultOnly'; +import * as nsMerged from './dep.js'; + +function verifyNamespace(ns, expected) { + assert.deepStrictEqual(Object.getOwnPropertyDescriptor(ns, Symbol.toStringTag), { + value: 'Module', + configurable: false, + enumerable: false, + writable: false + }); + + const assigned = Object.assign({}, ns); + const spreaded = { ...ns }; + + assert.deepStrictEqual(assigned, expected); + assert.strictEqual(assigned[Symbol.toStringTag], undefined); + + assert.deepStrictEqual(spreaded, expected); + assert.strictEqual(spreaded[Symbol.toStringTag], undefined); +} + +verifyNamespace(nsDefault, { answer: 42, default: { answer: 42 } }); +verifyNamespace(nsDefaultOnly, { default: { answer: 42 } }); +verifyNamespace(nsMerged, { answer: 42, extra: 'extra' }); diff --git a/test/function/samples/namespace-tostring/property-descriptor/_config.js b/test/function/samples/namespace-tostring/property-descriptor/_config.js new file mode 100644 index 00000000000..cd74750611a --- /dev/null +++ b/test/function/samples/namespace-tostring/property-descriptor/_config.js @@ -0,0 +1,8 @@ +module.exports = defineTest({ + description: 'namespace export should have @@toStringTag with correct property descriptors #4336', + options: { + output: { + generatedCode: { symbols: true } + } + } +}); diff --git a/test/function/samples/namespace-tostring/property-descriptor/foo.js b/test/function/samples/namespace-tostring/property-descriptor/foo.js new file mode 100644 index 00000000000..c155820bf77 --- /dev/null +++ b/test/function/samples/namespace-tostring/property-descriptor/foo.js @@ -0,0 +1 @@ +export const foo = 'bar'; diff --git a/test/function/samples/namespace-tostring/property-descriptor/main.js b/test/function/samples/namespace-tostring/property-descriptor/main.js new file mode 100644 index 00000000000..2743d20a176 --- /dev/null +++ b/test/function/samples/namespace-tostring/property-descriptor/main.js @@ -0,0 +1,22 @@ +import * as ns from './foo.js'; + +const { assign, getOwnPropertyDescriptor } = Object; + +const { configurable, enumerable, value, writable } = getOwnPropertyDescriptor( + ns, + Symbol.toStringTag +); + +assert.strictEqual(value, 'Module', 'value'); +assert.strictEqual(configurable, false, 'configurable'); +assert.strictEqual(enumerable, false, 'enumerable'); +assert.strictEqual(writable, false, 'writable'); + +const a = assign({}, ns); +const b = { ...ns }; + +assert.deepStrictEqual(a, { foo: 'bar' }); +assert.strictEqual(a[Symbol.toStringTag], undefined); + +assert.deepStrictEqual(b, { foo: 'bar' }); +assert.strictEqual(b[Symbol.toStringTag], undefined); diff --git a/test/function/samples/namespace-update-import-fails/_config.js b/test/function/samples/namespace-update-import-fails/_config.js index 5edbe40fca3..a3f5191e9ea 100644 --- a/test/function/samples/namespace-update-import-fails/_config.js +++ b/test/function/samples/namespace-update-import-fails/_config.js @@ -1,34 +1,34 @@ -const assert = require('assert'); -const path = require('path'); -const { assertIncludes } = require('../../../utils.js'); +const assert = require('node:assert'); +const path = require('node:path'); +const { assertIncludes } = require('../../../testHelpers.js'); +const ID_MAIN = path.join(__dirname, 'main.js'); -module.exports = { +module.exports = defineTest({ description: 'disallows updates to namespace exports', code(code) { assertIncludes(code, 'foo++'); }, warnings: [ { - code: 'ILLEGAL_NAMESPACE_REASSIGNMENT', - message: `Illegal reassignment to import 'exp'`, - id: path.join(__dirname, 'main.js'), + code: 'ILLEGAL_REASSIGNMENT', + message: 'main.js (3:0): Illegal reassignment of import "exp" in "main.js".', + id: ID_MAIN, pos: 31, loc: { - file: path.join(__dirname, 'main.js'), - line: 3, - column: 0 + column: 0, + file: ID_MAIN, + line: 3 }, frame: ` - 1: import * as exp from './foo'; - 2: - 3: exp['foo']++; - ^ - ` + 1: import * as exp from './foo'; + 2: + 3: exp['foo']++; + ^` } ], runtimeError(error) { assert.strictEqual(error.message, 'Assignment to constant variable.'); } -}; +}); // test copied from https://github.com/esnext/es6-module-transpiler/tree/master/test/examples/namespace-update-import-fails diff --git a/test/function/samples/namespaces-are-frozen/_config.js b/test/function/samples/namespaces-are-frozen/_config.js index 67eb7c4c445..cd3cfa710c5 100644 --- a/test/function/samples/namespaces-are-frozen/_config.js +++ b/test/function/samples/namespaces-are-frozen/_config.js @@ -1,26 +1,12 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'namespaces should be non-extensible and its properties immutatable and non-configurable', exports(exports) { const ns = exports.ns; - function extend(obj) { - 'use strict'; - obj.newProperty = true; - } - - function reconfigure(obj) { - Object.defineProperty(obj, 'a', { value: null }); - } - - function mutate(obj) { - 'use strict'; - obj.a = 2; - } - assert.throws(() => { extend(ns); }); @@ -33,4 +19,18 @@ module.exports = { mutate(ns); }); } -}; +}); + +function extend(object) { + 'use strict'; + object.newProperty = true; +} + +function reconfigure(object) { + Object.defineProperty(object, 'a', { value: null }); +} + +function mutate(object) { + 'use strict'; + object.a = 2; +} diff --git a/test/function/samples/namespaces-have-null-prototype/_config.js b/test/function/samples/namespaces-have-null-prototype/_config.js index d64597e0b9f..bdcb27927b1 100644 --- a/test/function/samples/namespaces-have-null-prototype/_config.js +++ b/test/function/samples/namespaces-have-null-prototype/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'creates namespaces with null prototypes' -}; +}); diff --git a/test/function/samples/namespacing-collisions-2/_config.js b/test/function/samples/namespacing-collisions-2/_config.js index fb3a66c9b61..bc01f4f5e53 100644 --- a/test/function/samples/namespacing-collisions-2/_config.js +++ b/test/function/samples/namespacing-collisions-2/_config.js @@ -1,8 +1,8 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'correctly namespaces when using * exports, take two (#910)', exports(exports) { assert.deepEqual(exports, ['Material', 'MaterialAgain', 'Something', 'SomethingAgain']); } -}; +}); diff --git a/test/function/samples/namespacing-collisions/_config.js b/test/function/samples/namespacing-collisions/_config.js index 3469dcf3dd0..905caf5f41a 100644 --- a/test/function/samples/namespacing-collisions/_config.js +++ b/test/function/samples/namespacing-collisions/_config.js @@ -1,8 +1,8 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'correctly namespaces when using * exports (#910)', exports(exports) { assert.deepStrictEqual(exports, ['Material', 'Something']); } -}; +}); diff --git a/test/function/samples/namespacing-in-sub-functions/_config.js b/test/function/samples/namespacing-in-sub-functions/_config.js index 5b96651c923..5f870676190 100644 --- a/test/function/samples/namespacing-in-sub-functions/_config.js +++ b/test/function/samples/namespacing-in-sub-functions/_config.js @@ -1,8 +1,8 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'correctly namespaces sub-functions (#910)', exports(exports) { assert.equal(exports, 'foobar'); } -}; +}); diff --git a/test/function/samples/nested-and-async-plugin/_config.js b/test/function/samples/nested-and-async-plugin/_config.js new file mode 100644 index 00000000000..4fefef40c11 --- /dev/null +++ b/test/function/samples/nested-and-async-plugin/_config.js @@ -0,0 +1,24 @@ +const pluginA = { + name: 'nested-plugin-1', + options(options) { + options.plugins.push(pluginB); + }, + transform(code) { + return code.replace('foo = 1', 'foo = 2'); + } +}; + +const pluginB = Promise.resolve({ + name: 'async-plugin-2', + transform(code) { + return code.replace('answer = 41', 'answer = 42'); + } +}); + +module.exports = defineTest({ + description: 'works when nested plugin', + options: { + // eslint-disable-next-line no-sparse-arrays + plugins: [[Promise.resolve(pluginA)], [undefined, Promise.resolve([null])], ,] + } +}); diff --git a/test/function/samples/nested-and-async-plugin/main.js b/test/function/samples/nested-and-async-plugin/main.js new file mode 100644 index 00000000000..1eb0e2232b3 --- /dev/null +++ b/test/function/samples/nested-and-async-plugin/main.js @@ -0,0 +1,5 @@ +const foo = 1; +const answer = 41; + +assert.equal(foo, 2); +assert.equal(answer, 42); diff --git a/test/function/samples/nested-foreach/_config.js b/test/function/samples/nested-foreach/_config.js index 9ccde200085..53e8cf59b53 100644 --- a/test/function/samples/nested-foreach/_config.js +++ b/test/function/samples/nested-foreach/_config.js @@ -1,6 +1,6 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'detects side-effects in nested .forEach calls (#3533)', exports: exports => assert.strictEqual(exports.result, 9) -}; +}); diff --git a/test/function/samples/nested-inlined-dynamic-import-1/_config.js b/test/function/samples/nested-inlined-dynamic-import-1/_config.js index ad243453388..57985c03fac 100644 --- a/test/function/samples/nested-inlined-dynamic-import-1/_config.js +++ b/test/function/samples/nested-inlined-dynamic-import-1/_config.js @@ -1,6 +1,6 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'deconflicts variables when nested dynamic imports are inlined via inlineDynamicImports', options: { @@ -9,4 +9,4 @@ module.exports = { exports(exports) { return exports().then(result => assert.strictEqual(result, 43)); } -}; +}); diff --git a/test/function/samples/nested-inlined-dynamic-import-2/_config.js b/test/function/samples/nested-inlined-dynamic-import-2/_config.js index 4a9ba8ce0f3..afeaa07b397 100644 --- a/test/function/samples/nested-inlined-dynamic-import-2/_config.js +++ b/test/function/samples/nested-inlined-dynamic-import-2/_config.js @@ -1,16 +1,18 @@ -const assert = require('assert'); +const assert = require('node:assert'); +const path = require('node:path'); +const ID_LIB1 = path.join(__dirname, 'lib1.js'); +const ID_LIB2 = path.join(__dirname, 'lib2.js'); -module.exports = { +module.exports = defineTest({ description: 'deconflicts variables when nested dynamic imports are inlined', warnings: [ { code: 'CIRCULAR_DEPENDENCY', - cycle: ['lib1.js', 'lib2.js', 'lib1.js'], - importer: 'lib1.js', + ids: [ID_LIB1, ID_LIB2, ID_LIB1], message: 'Circular dependency: lib1.js -> lib2.js -> lib1.js' } ], exports(exports) { return exports().then(result => assert.strictEqual(result, 43)); } -}; +}); diff --git a/test/function/samples/nested-namespace-member-expression/_config.js b/test/function/samples/nested-namespace-member-expression/_config.js index 73981a9fa63..1667bb77f9e 100644 --- a/test/function/samples/nested-namespace-member-expression/_config.js +++ b/test/function/samples/nested-namespace-member-expression/_config.js @@ -1,8 +1,8 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'handles accessing members of namespaces correctly', exports(exports) { assert.strictEqual(exports, false); } -}; +}); diff --git a/test/function/samples/nested-property-call-performance/_config.js b/test/function/samples/nested-property-call-performance/_config.js index 31df4ed7615..bcef3ccdff8 100644 --- a/test/function/samples/nested-property-call-performance/_config.js +++ b/test/function/samples/nested-property-call-performance/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'handles nested property calls with acceptable performance' -}; +}); diff --git a/test/function/samples/new-target-meta/_config.js b/test/function/samples/new-target-meta/_config.js new file mode 100644 index 00000000000..653ce117be9 --- /dev/null +++ b/test/function/samples/new-target-meta/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'does not change new.target usages' +}); diff --git a/test/function/samples/new-target-meta/main.js b/test/function/samples/new-target-meta/main.js new file mode 100644 index 00000000000..1ba94c8d5c9 --- /dev/null +++ b/test/function/samples/new-target-meta/main.js @@ -0,0 +1,5 @@ +function Foo() { + assert.strictEqual(new.target, Foo); +} + +new Foo(); diff --git a/test/function/samples/newline-after-comment/_config.js b/test/function/samples/newline-after-comment/_config.js index fcda8ecd114..0b4b8516b31 100644 --- a/test/function/samples/newline-after-comment/_config.js +++ b/test/function/samples/newline-after-comment/_config.js @@ -1,8 +1,8 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'inserts newline after comment', exports(exports) { assert.equal(exports(), 42); } -}; +}); diff --git a/test/function/samples/no-external-live-bindings-compact/_config.js b/test/function/samples/no-external-live-bindings-compact/_config.js index e94a85a2051..47b8962979f 100644 --- a/test/function/samples/no-external-live-bindings-compact/_config.js +++ b/test/function/samples/no-external-live-bindings-compact/_config.js @@ -1,13 +1,14 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'Allows omitting the code that handles external live bindings', options: { external: () => true, output: { compact: true, externalLiveBindings: false, - name: 'bundle' + name: 'bundle', + dynamicImportInCjs: false } }, context: { @@ -16,7 +17,12 @@ module.exports = { } }, exports(exports) { - assert.deepStrictEqual(Object.keys(exports).sort(), ['dynamic', 'external1', 'external2', 'value']); + assert.deepStrictEqual(Object.keys(exports).sort(), [ + 'dynamic', + 'external1', + 'external2', + 'value' + ]); assert.strictEqual(exports.external1, true); assert.strictEqual(exports.external2, true); assert.strictEqual(exports.value, 'external2'); @@ -29,4 +35,4 @@ module.exports = { }) ); } -}; +}); diff --git a/test/function/samples/no-external-live-bindings/_config.js b/test/function/samples/no-external-live-bindings/_config.js index 8c26c560fe5..c64b44028f0 100644 --- a/test/function/samples/no-external-live-bindings/_config.js +++ b/test/function/samples/no-external-live-bindings/_config.js @@ -1,12 +1,13 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'Allows omitting the code that handles external live bindings', options: { external: () => true, output: { externalLiveBindings: false, - name: 'bundle' + name: 'bundle', + dynamicImportInCjs: false } }, context: { @@ -15,7 +16,12 @@ module.exports = { } }, exports(exports) { - assert.deepStrictEqual(Object.keys(exports).sort(), ['dynamic', 'external1', 'external2', 'value']); + assert.deepStrictEqual(Object.keys(exports).sort(), [ + 'dynamic', + 'external1', + 'external2', + 'value' + ]); assert.strictEqual(exports.external1, true); assert.strictEqual(exports.external2, true); assert.strictEqual(exports.value, 'external2'); @@ -28,4 +34,4 @@ module.exports = { }) ); } -}; +}); diff --git a/test/function/samples/no-imports/_config.js b/test/function/samples/no-imports/_config.js index be6c448555e..5a78cb28118 100644 --- a/test/function/samples/no-imports/_config.js +++ b/test/function/samples/no-imports/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'creates a bundle from a module with no imports' -}; +}); diff --git a/test/function/samples/no-relative-external/_config.js b/test/function/samples/no-relative-external/_config.js index 44f535fc148..37a9d861e3c 100644 --- a/test/function/samples/no-relative-external/_config.js +++ b/test/function/samples/no-relative-external/_config.js @@ -1,10 +1,13 @@ -const path = require('path'); +const path = require('node:path'); +const ID_MAIN = path.join(__dirname, 'main.js'); -module.exports = { +module.exports = defineTest({ description: 'missing relative imports are an error, not a warning', error: { code: 'UNRESOLVED_IMPORT', - message: `Could not resolve './missing.js' from main.js`, - watchFiles: [path.join(__dirname, 'main.js')] + exporter: './missing.js', + id: ID_MAIN, + watchFiles: [ID_MAIN], + message: 'Could not resolve "./missing.js" from "main.js"' } -}; +}); diff --git a/test/function/samples/no-treeshake-react/_config.js b/test/function/samples/no-treeshake-react/_config.js new file mode 100644 index 00000000000..eaf78a74ba0 --- /dev/null +++ b/test/function/samples/no-treeshake-react/_config.js @@ -0,0 +1,10 @@ +module.exports = defineTest({ + description: 'passes when bundling React without tree-shaking', + options: { + treeshake: false, + plugins: [ + require('@rollup/plugin-node-resolve').default(), + require('@rollup/plugin-commonjs')() + ] + } +}); diff --git a/test/function/samples/no-treeshake-react/main.js b/test/function/samples/no-treeshake-react/main.js new file mode 100644 index 00000000000..97c7d2ed1f5 --- /dev/null +++ b/test/function/samples/no-treeshake-react/main.js @@ -0,0 +1,3 @@ +import * as React from 'react'; +const { createContext } = React; +assert(createContext() === 'foo'); diff --git a/test/function/samples/no-treeshake-react/node_modules/react/cjs/react.production.js b/test/function/samples/no-treeshake-react/node_modules/react/cjs/react.production.js new file mode 100644 index 00000000000..ac03d015113 --- /dev/null +++ b/test/function/samples/no-treeshake-react/node_modules/react/cjs/react.production.js @@ -0,0 +1,4 @@ +"use strict"; +exports.createContext = function () { + return 'foo'; +}; diff --git a/test/function/samples/no-treeshake-react/node_modules/react/index.js b/test/function/samples/no-treeshake-react/node_modules/react/index.js new file mode 100644 index 00000000000..33e7d9f26fd --- /dev/null +++ b/test/function/samples/no-treeshake-react/node_modules/react/index.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = require('./cjs/react.production.js'); diff --git a/test/function/samples/no-treeshake-react/node_modules/react/package.json b/test/function/samples/no-treeshake-react/node_modules/react/package.json new file mode 100644 index 00000000000..a90099d620b --- /dev/null +++ b/test/function/samples/no-treeshake-react/node_modules/react/package.json @@ -0,0 +1,8 @@ +{ + "main": "index.js", + "exports": { + ".": { + "default": "./index.js" + } + } +} \ No newline at end of file diff --git a/test/function/samples/non-extension-dot/_config.js b/test/function/samples/non-extension-dot/_config.js index 3f29d797da9..3095f7fe3d6 100644 --- a/test/function/samples/non-extension-dot/_config.js +++ b/test/function/samples/non-extension-dot/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'adds .js to module paths with non-extension dots in them' -}; +}); diff --git a/test/function/samples/non-function-hook-async/_config.js b/test/function/samples/non-function-hook-async/_config.js index d17469d3926..af2e8adf801 100644 --- a/test/function/samples/non-function-hook-async/_config.js +++ b/test/function/samples/non-function-hook-async/_config.js @@ -1,15 +1,13 @@ -module.exports = { +module.exports = defineTest({ description: 'throws when providing a value for an async function hook', options: { - plugins: { - resolveId: 'value' - } + plugins: [{ resolveId: 'value' }] }, error: { - code: 'PLUGIN_ERROR', + code: 'INVALID_PLUGIN_HOOK', hook: 'resolveId', - message: 'Error running plugin hook resolveId for at position 1, expected a function hook.', - plugin: 'at position 1', - pluginCode: 'INVALID_PLUGIN_HOOK' + message: + '[plugin at position 1] Error running plugin hook "resolveId" for plugin "at position 1", expected a function hook or an object with a "handler" function.', + plugin: 'at position 1' } -}; +}); diff --git a/test/function/samples/non-function-hook-sync/_config.js b/test/function/samples/non-function-hook-sync/_config.js index c447f84ec77..5e0e82a45c7 100644 --- a/test/function/samples/non-function-hook-sync/_config.js +++ b/test/function/samples/non-function-hook-sync/_config.js @@ -1,15 +1,17 @@ -module.exports = { +module.exports = defineTest({ description: 'throws when providing a value for a sync function hook', options: { - plugins: { - outputOptions: 'value' - } + plugins: [ + { + outputOptions: 'value' + } + ] }, generateError: { - code: 'PLUGIN_ERROR', + code: 'INVALID_PLUGIN_HOOK', hook: 'outputOptions', - message: 'Error running plugin hook outputOptions for at position 1, expected a function hook.', - plugin: 'at position 1', - pluginCode: 'INVALID_PLUGIN_HOOK' + message: + '[plugin at position 1] Error running plugin hook "outputOptions" for plugin "at position 1", expected a function hook or an object with a "handler" function.', + plugin: 'at position 1' } -}; +}); diff --git a/test/function/samples/non-js-extensions/_config.js b/test/function/samples/non-js-extensions/_config.js index 986858ad4d2..bfa68d294af 100644 --- a/test/function/samples/non-js-extensions/_config.js +++ b/test/function/samples/non-js-extensions/_config.js @@ -1,6 +1,6 @@ -const path = require('path'); +const path = require('node:path'); -module.exports = { +module.exports = defineTest({ description: 'non .js extensions are preserved', options: { plugins: [ @@ -13,4 +13,4 @@ module.exports = { } ] } -}; +}); diff --git a/test/function/samples/nullish-coalescing-operator-tree-shaking/_config.js b/test/function/samples/nullish-coalescing-operator-tree-shaking/_config.js new file mode 100644 index 00000000000..10376ef7b87 --- /dev/null +++ b/test/function/samples/nullish-coalescing-operator-tree-shaking/_config.js @@ -0,0 +1,6 @@ +module.exports = defineTest({ + description: 'Keep nullish coalescing operator', + context: { + unknownGlobal: false + } +}); diff --git a/test/function/samples/nullish-coalescing-operator-tree-shaking/main.js b/test/function/samples/nullish-coalescing-operator-tree-shaking/main.js new file mode 100644 index 00000000000..2bc80caad1a --- /dev/null +++ b/test/function/samples/nullish-coalescing-operator-tree-shaking/main.js @@ -0,0 +1,2 @@ +const a = unknownGlobal ? 0 : null; +assert.strictEqual(a ?? 2, 2); diff --git a/test/function/samples/object-deep-access-effect/_config.js b/test/function/samples/object-deep-access-effect/_config.js new file mode 100644 index 00000000000..bc6d80ea127 --- /dev/null +++ b/test/function/samples/object-deep-access-effect/_config.js @@ -0,0 +1,11 @@ +module.exports = defineTest({ + description: 'throws when an nested property of an unknown object property is accessed', + context: { + require() { + return { unknown: 'prop' }; + } + }, + options: { + external: ['external'] + } +}); diff --git a/test/function/samples/object-deep-access-effect/main.js b/test/function/samples/object-deep-access-effect/main.js new file mode 100644 index 00000000000..4a783c99591 --- /dev/null +++ b/test/function/samples/object-deep-access-effect/main.js @@ -0,0 +1,6 @@ +import { unknown } from 'external'; + +assert.throws(() => { + const obj = {}; + obj[unknown].prop; +}, /^TypeError: Cannot read propert.*'prop'.*$/ ); diff --git a/test/function/samples/object-destructuring-renaming/_config.js b/test/function/samples/object-destructuring-renaming/_config.js index b7d9bb37602..c43e833e21b 100644 --- a/test/function/samples/object-destructuring-renaming/_config.js +++ b/test/function/samples/object-destructuring-renaming/_config.js @@ -1,8 +1,8 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'renaming destructured object properties should request the correct property (#527)', exports(exports) { assert.equal(exports.env, process.env); } -}; +}); diff --git a/test/function/samples/object-dynamic-properties/_config.js b/test/function/samples/object-dynamic-properties/_config.js index 1bcd2fa3611..a54d8060d49 100644 --- a/test/function/samples/object-dynamic-properties/_config.js +++ b/test/function/samples/object-dynamic-properties/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'dynamic object assignments should be imported' -}; +}); diff --git a/test/function/samples/object-expression-shadowed-properties/_config.js b/test/function/samples/object-expression-shadowed-properties/_config.js index 50888ee46c7..b07e9093bde 100644 --- a/test/function/samples/object-expression-shadowed-properties/_config.js +++ b/test/function/samples/object-expression-shadowed-properties/_config.js @@ -1,7 +1,8 @@ -module.exports = { - description: 'do not remove calls to object expression methods that may have side-effects when properties may be shadowed', +module.exports = defineTest({ + description: + 'do not remove calls to object expression methods that may have side-effects when properties may be shadowed', context: { unknownA: 'a', unknownB: 'b' } -}; +}); diff --git a/test/function/samples/object-expression-treeshaking/deconflict-destructured-array-pattern/_config.js b/test/function/samples/object-expression-treeshaking/deconflict-destructured-array-pattern/_config.js new file mode 100644 index 00000000000..cdeea3d02ee --- /dev/null +++ b/test/function/samples/object-expression-treeshaking/deconflict-destructured-array-pattern/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'makes sure to deconflict all variables in an array pattern if included' +}); diff --git a/test/function/samples/object-expression-treeshaking/deconflict-destructured-array-pattern/dep.js b/test/function/samples/object-expression-treeshaking/deconflict-destructured-array-pattern/dep.js new file mode 100644 index 00000000000..9bcefbb3169 --- /dev/null +++ b/test/function/samples/object-expression-treeshaking/deconflict-destructured-array-pattern/dep.js @@ -0,0 +1,2 @@ +const Foo = { ok: true }; +export { Foo as default }; diff --git a/test/function/samples/object-expression-treeshaking/deconflict-destructured-array-pattern/main.js b/test/function/samples/object-expression-treeshaking/deconflict-destructured-array-pattern/main.js new file mode 100644 index 00000000000..473a5dc8d3e --- /dev/null +++ b/test/function/samples/object-expression-treeshaking/deconflict-destructured-array-pattern/main.js @@ -0,0 +1,6 @@ +import bar from './dep.js'; + +const [Foo, Bar] = [1, 2]; + +assert.deepStrictEqual(bar, { ok: true }); +assert.deepStrictEqual(Bar, 2); diff --git a/test/function/samples/object-expression-treeshaking/deconflict-destructured-for-default-side-effects-array/_config.js b/test/function/samples/object-expression-treeshaking/deconflict-destructured-for-default-side-effects-array/_config.js new file mode 100644 index 00000000000..7778227903e --- /dev/null +++ b/test/function/samples/object-expression-treeshaking/deconflict-destructured-for-default-side-effects-array/_config.js @@ -0,0 +1,4 @@ +module.exports = defineTest({ + description: + 'makes sure to deconflict variables that are destructured for side effects in their array pattern default values only' +}); diff --git a/test/function/samples/object-expression-treeshaking/deconflict-destructured-for-default-side-effects-array/dep.js b/test/function/samples/object-expression-treeshaking/deconflict-destructured-for-default-side-effects-array/dep.js new file mode 100644 index 00000000000..9bcefbb3169 --- /dev/null +++ b/test/function/samples/object-expression-treeshaking/deconflict-destructured-for-default-side-effects-array/dep.js @@ -0,0 +1,2 @@ +const Foo = { ok: true }; +export { Foo as default }; diff --git a/test/function/samples/object-expression-treeshaking/deconflict-destructured-for-default-side-effects-array/main.js b/test/function/samples/object-expression-treeshaking/deconflict-destructured-for-default-side-effects-array/main.js new file mode 100644 index 00000000000..cbcf4a15b58 --- /dev/null +++ b/test/function/samples/object-expression-treeshaking/deconflict-destructured-for-default-side-effects-array/main.js @@ -0,0 +1,9 @@ +import bar from './dep.js'; +let mutated = false; +const [ + Foo = (() => { + mutated = true; + })() +] = []; +assert.ok(mutated); +assert.deepStrictEqual(bar, { ok: true }); diff --git a/test/function/samples/object-expression-treeshaking/deconflict-destructured-for-default-side-effects/_config.js b/test/function/samples/object-expression-treeshaking/deconflict-destructured-for-default-side-effects/_config.js new file mode 100644 index 00000000000..df011c9a1ae --- /dev/null +++ b/test/function/samples/object-expression-treeshaking/deconflict-destructured-for-default-side-effects/_config.js @@ -0,0 +1,4 @@ +module.exports = defineTest({ + description: + 'makes sure to deconflict variables that are destructured for side effects in their default values only' +}); diff --git a/test/function/samples/object-expression-treeshaking/deconflict-destructured-for-default-side-effects/dep.js b/test/function/samples/object-expression-treeshaking/deconflict-destructured-for-default-side-effects/dep.js new file mode 100644 index 00000000000..9bcefbb3169 --- /dev/null +++ b/test/function/samples/object-expression-treeshaking/deconflict-destructured-for-default-side-effects/dep.js @@ -0,0 +1,2 @@ +const Foo = { ok: true }; +export { Foo as default }; diff --git a/test/function/samples/object-expression-treeshaking/deconflict-destructured-for-default-side-effects/main.js b/test/function/samples/object-expression-treeshaking/deconflict-destructured-for-default-side-effects/main.js new file mode 100644 index 00000000000..c39128e9fd5 --- /dev/null +++ b/test/function/samples/object-expression-treeshaking/deconflict-destructured-for-default-side-effects/main.js @@ -0,0 +1,9 @@ +import bar from './dep.js'; +let mutated = false; +const { + Foo = (() => { + mutated = true; + })() +} = {}; +assert.ok(mutated); +assert.deepStrictEqual(bar, { ok: true }); diff --git a/test/function/samples/object-expression-treeshaking/deconflict-destructured-for-key-side-effects/_config.js b/test/function/samples/object-expression-treeshaking/deconflict-destructured-for-key-side-effects/_config.js new file mode 100644 index 00000000000..c7e939766f5 --- /dev/null +++ b/test/function/samples/object-expression-treeshaking/deconflict-destructured-for-key-side-effects/_config.js @@ -0,0 +1,4 @@ +module.exports = defineTest({ + description: + 'makes sure to deconflict variables that are destructured for side effects in their key only' +}); diff --git a/test/function/samples/object-expression-treeshaking/deconflict-destructured-for-key-side-effects/dep.js b/test/function/samples/object-expression-treeshaking/deconflict-destructured-for-key-side-effects/dep.js new file mode 100644 index 00000000000..9bcefbb3169 --- /dev/null +++ b/test/function/samples/object-expression-treeshaking/deconflict-destructured-for-key-side-effects/dep.js @@ -0,0 +1,2 @@ +const Foo = { ok: true }; +export { Foo as default }; diff --git a/test/function/samples/object-expression-treeshaking/deconflict-destructured-for-key-side-effects/main.js b/test/function/samples/object-expression-treeshaking/deconflict-destructured-for-key-side-effects/main.js new file mode 100644 index 00000000000..2809a2f9e93 --- /dev/null +++ b/test/function/samples/object-expression-treeshaking/deconflict-destructured-for-key-side-effects/main.js @@ -0,0 +1,10 @@ +import bar from './dep.js'; +let mutated = false; +const { + [(() => { + mutated = true; + return 'Foo'; + })()]: Foo +} = { Foo: true }; +assert.ok(mutated); +assert.deepStrictEqual(bar, { ok: true }); diff --git a/test/function/samples/object-expression-treeshaking/deconflict-destructured-for-side-effects/_config.js b/test/function/samples/object-expression-treeshaking/deconflict-destructured-for-side-effects/_config.js new file mode 100644 index 00000000000..575f09159d4 --- /dev/null +++ b/test/function/samples/object-expression-treeshaking/deconflict-destructured-for-side-effects/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'makes sure to deconflict variables that are destructured for side effects only' +}); diff --git a/test/function/samples/object-expression-treeshaking/deconflict-destructured-for-side-effects/dep.js b/test/function/samples/object-expression-treeshaking/deconflict-destructured-for-side-effects/dep.js new file mode 100644 index 00000000000..9bcefbb3169 --- /dev/null +++ b/test/function/samples/object-expression-treeshaking/deconflict-destructured-for-side-effects/dep.js @@ -0,0 +1,2 @@ +const Foo = { ok: true }; +export { Foo as default }; diff --git a/test/function/samples/object-expression-treeshaking/deconflict-destructured-for-side-effects/main.js b/test/function/samples/object-expression-treeshaking/deconflict-destructured-for-side-effects/main.js new file mode 100644 index 00000000000..29c4a2fc5a3 --- /dev/null +++ b/test/function/samples/object-expression-treeshaking/deconflict-destructured-for-side-effects/main.js @@ -0,0 +1,9 @@ +import bar from './dep.js'; +let mutated = false; +const { Foo } = { + get Foo() { + mutated = true; + } +}; +assert.ok(mutated); +assert.deepStrictEqual(bar, { ok: true }); diff --git a/test/function/samples/object-expression-treeshaking/deoptimize-arguments-via-destructuring/_config.js b/test/function/samples/object-expression-treeshaking/deoptimize-arguments-via-destructuring/_config.js new file mode 100644 index 00000000000..44ddb5912a5 --- /dev/null +++ b/test/function/samples/object-expression-treeshaking/deoptimize-arguments-via-destructuring/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'deoptimizes arguments of calls to destructured functions' +}); diff --git a/test/function/samples/object-expression-treeshaking/deoptimize-arguments-via-destructuring/main.js b/test/function/samples/object-expression-treeshaking/deoptimize-arguments-via-destructuring/main.js new file mode 100644 index 00000000000..95a2287a859 --- /dev/null +++ b/test/function/samples/object-expression-treeshaking/deoptimize-arguments-via-destructuring/main.js @@ -0,0 +1,13 @@ +var { a } = { + a: { + b(x) { + x.mutated = true; + } + }, + b() {} +}; + +var obj = { mutated: false }; +a.b(obj); + +assert.strictEqual(obj.mutated ? 'OK' : 'FAILED', 'OK'); diff --git a/test/function/samples/object-expression-treeshaking/deoptimize-object-via-destructured-getter/_config.js b/test/function/samples/object-expression-treeshaking/deoptimize-object-via-destructured-getter/_config.js new file mode 100644 index 00000000000..d7e2cced939 --- /dev/null +++ b/test/function/samples/object-expression-treeshaking/deoptimize-object-via-destructured-getter/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'deoptimizes the object if a mutating getter is destructured' +}); diff --git a/test/function/samples/object-expression-treeshaking/deoptimize-object-via-destructured-getter/main.js b/test/function/samples/object-expression-treeshaking/deoptimize-object-via-destructured-getter/main.js new file mode 100644 index 00000000000..60b29d3d52c --- /dev/null +++ b/test/function/samples/object-expression-treeshaking/deoptimize-object-via-destructured-getter/main.js @@ -0,0 +1,9 @@ +const { a, b } = { + get a() { + // We cannot remove a as destructuring will trigger this getter + this.b = true; + }, + b: false +}; + +assert.strictEqual(b ? 'OK' : 'FAILED', 'OK'); diff --git a/test/function/samples/object-expression-treeshaking/deoptimized-argument-value/_config.js b/test/function/samples/object-expression-treeshaking/deoptimized-argument-value/_config.js new file mode 100644 index 00000000000..1f04fcd0619 --- /dev/null +++ b/test/function/samples/object-expression-treeshaking/deoptimized-argument-value/_config.js @@ -0,0 +1,4 @@ +module.exports = defineTest({ + description: + 'does not fail if an argument is deoptimized where the value of a nested property is used in a condition' +}); diff --git a/test/function/samples/object-expression-treeshaking/deoptimized-argument-value/main.js b/test/function/samples/object-expression-treeshaking/deoptimized-argument-value/main.js new file mode 100644 index 00000000000..dca3d53ecc3 --- /dev/null +++ b/test/function/samples/object-expression-treeshaking/deoptimized-argument-value/main.js @@ -0,0 +1,9 @@ +function test(x) { + if (x?.y.z) { + return true; + } + return false; +} + +assert.ok(test({ y: { z: true } })); +assert.ok(!test({ y: { z: false } })); diff --git a/test/function/samples/object-expression-treeshaking/do-not-destructure-unused/_config.js b/test/function/samples/object-expression-treeshaking/do-not-destructure-unused/_config.js new file mode 100644 index 00000000000..3941223261b --- /dev/null +++ b/test/function/samples/object-expression-treeshaking/do-not-destructure-unused/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'ensures that unused properties that are potentially removed are not destructure' +}); diff --git a/test/function/samples/object-expression-treeshaking/do-not-destructure-unused/main.js b/test/function/samples/object-expression-treeshaking/do-not-destructure-unused/main.js new file mode 100644 index 00000000000..8ccfd46e627 --- /dev/null +++ b/test/function/samples/object-expression-treeshaking/do-not-destructure-unused/main.js @@ -0,0 +1,17 @@ +const { + x: { + y: { z } + }, + a +} = { x: { y: { z: true } }, a: true }; +assert.ok(a); + +function test({ + x: { + y: { z } + }, + a +}) { + return a; +} +assert.ok(test({ x: { y: { z: true } }, a: true })); diff --git a/test/function/samples/object-expression-treeshaking/exports/_config.js b/test/function/samples/object-expression-treeshaking/exports/_config.js new file mode 100644 index 00000000000..9c660cbb7cf --- /dev/null +++ b/test/function/samples/object-expression-treeshaking/exports/_config.js @@ -0,0 +1,13 @@ +const assert = require('node:assert'); + +module.exports = defineTest({ + description: 'includes all paths of exported objects', + exports(exports) { + assert.deepStrictEqual(exports, { + foo: { + a: 1, + b: { c: 2 } + } + }); + } +}); diff --git a/test/function/samples/object-expression-treeshaking/exports/main.js b/test/function/samples/object-expression-treeshaking/exports/main.js new file mode 100644 index 00000000000..f905aa8f9c7 --- /dev/null +++ b/test/function/samples/object-expression-treeshaking/exports/main.js @@ -0,0 +1,4 @@ +export const foo = { + a: 1, + b: { c: 2 } +}; diff --git a/test/function/samples/object-expression-treeshaking/get-literal-value-via-destructuring/_config.js b/test/function/samples/object-expression-treeshaking/get-literal-value-via-destructuring/_config.js new file mode 100644 index 00000000000..283d1dc5789 --- /dev/null +++ b/test/function/samples/object-expression-treeshaking/get-literal-value-via-destructuring/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'retrieves literal values from destructured variables' +}); diff --git a/test/function/samples/object-expression-treeshaking/get-literal-value-via-destructuring/main.js b/test/function/samples/object-expression-treeshaking/get-literal-value-via-destructuring/main.js new file mode 100644 index 00000000000..fea5611f917 --- /dev/null +++ b/test/function/samples/object-expression-treeshaking/get-literal-value-via-destructuring/main.js @@ -0,0 +1,6 @@ +var { a } = { + a: { b: true }, + b: false +}; + +assert.strictEqual(a.b ? 'OK' : 'FAILED', 'OK'); diff --git a/test/function/samples/object-expression-treeshaking/get-return-expression-via-destructuring/_config.js b/test/function/samples/object-expression-treeshaking/get-return-expression-via-destructuring/_config.js new file mode 100644 index 00000000000..573a3cd4559 --- /dev/null +++ b/test/function/samples/object-expression-treeshaking/get-return-expression-via-destructuring/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'retrieves return expressions from destructured variables' +}); diff --git a/test/function/samples/object-expression-treeshaking/get-return-expression-via-destructuring/main.js b/test/function/samples/object-expression-treeshaking/get-return-expression-via-destructuring/main.js new file mode 100644 index 00000000000..0f800d0832c --- /dev/null +++ b/test/function/samples/object-expression-treeshaking/get-return-expression-via-destructuring/main.js @@ -0,0 +1,6 @@ +var { a } = { + a: { b: () => true }, + b: () => false +}; + +assert.strictEqual(a.b() ? 'OK' : 'FAILED', 'OK'); diff --git a/test/function/samples/object-expression-treeshaking/handle-try-catch/_config.js b/test/function/samples/object-expression-treeshaking/handle-try-catch/_config.js new file mode 100644 index 00000000000..ab0519c6551 --- /dev/null +++ b/test/function/samples/object-expression-treeshaking/handle-try-catch/_config.js @@ -0,0 +1,11 @@ +const assert = require('node:assert'); + +module.exports = defineTest({ + description: 'include properties through try-catch calls', + exports({ getBuilder }) { + const builder = getBuilder(); + assert.deepStrictEqual(builder.buildCall(), 3n); + assert.deepStrictEqual(builder.buildEvent(), 2n); + assert.deepStrictEqual(builder.buildError(), 1n); + } +}); diff --git a/test/function/samples/object-expression-treeshaking/handle-try-catch/main.js b/test/function/samples/object-expression-treeshaking/handle-try-catch/main.js new file mode 100644 index 00000000000..6b01e44851d --- /dev/null +++ b/test/function/samples/object-expression-treeshaking/handle-try-catch/main.js @@ -0,0 +1,21 @@ +export const getBuilder = () => { + const variantShapeId = { + errors: 1n, + events: 2n, + calls: 3n + }; + + const buildVariant = variantType => () => { + try { + return variantShapeId[variantType]; + } catch { + return null; + } + }; + + return { + buildCall: buildVariant('calls'), + buildEvent: buildVariant('events'), + buildError: buildVariant('errors') + }; +}; diff --git a/test/function/samples/object-expression-treeshaking/in-operator/_config.js b/test/function/samples/object-expression-treeshaking/in-operator/_config.js new file mode 100644 index 00000000000..d926de806f7 --- /dev/null +++ b/test/function/samples/object-expression-treeshaking/in-operator/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'includes properties referenced by the "in" operator' +}); diff --git a/test/function/samples/object-expression-treeshaking/in-operator/main.js b/test/function/samples/object-expression-treeshaking/in-operator/main.js new file mode 100644 index 00000000000..75b3f1af9b8 --- /dev/null +++ b/test/function/samples/object-expression-treeshaking/in-operator/main.js @@ -0,0 +1 @@ +assert.ok('foo' in { foo: true, bar: true }); diff --git a/test/function/samples/object-expression-treeshaking/include-call-arguments-path/_config.js b/test/function/samples/object-expression-treeshaking/include-call-arguments-path/_config.js new file mode 100644 index 00000000000..3021ca7249f --- /dev/null +++ b/test/function/samples/object-expression-treeshaking/include-call-arguments-path/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'uses the correct path when including call arguments' +}); diff --git a/test/function/samples/object-expression-treeshaking/include-call-arguments-path/main.js b/test/function/samples/object-expression-treeshaking/include-call-arguments-path/main.js new file mode 100644 index 00000000000..57709cc1a58 --- /dev/null +++ b/test/function/samples/object-expression-treeshaking/include-call-arguments-path/main.js @@ -0,0 +1,9 @@ +let result = null; + +function test() {} +test.a = value => (result = value); + +const { a } = test; +a(1); + +assert.strictEqual(result, 1); diff --git a/test/function/samples/object-expression-treeshaking/include-destructuring-rest/_config.js b/test/function/samples/object-expression-treeshaking/include-destructuring-rest/_config.js new file mode 100644 index 00000000000..a3e2d8dd3a7 --- /dev/null +++ b/test/function/samples/object-expression-treeshaking/include-destructuring-rest/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'includes rest properties in destructuring declarations' +}); diff --git a/test/function/samples/object-expression-treeshaking/include-destructuring-rest/main.js b/test/function/samples/object-expression-treeshaking/include-destructuring-rest/main.js new file mode 100644 index 00000000000..1909f73bbfc --- /dev/null +++ b/test/function/samples/object-expression-treeshaking/include-destructuring-rest/main.js @@ -0,0 +1,15 @@ +const { + a: { e: e1, ...rest1 } +} = { a: { b: { c: 1, d: 1 }, e: 1 }, f: 1 }; +assert.deepStrictEqual(rest1, { b: { c: 1, d: 1 } }); + +const { ...rest2 } = { a: { b: { c: 1, d: 1 }, e: 1 }, f: 1 }; +assert.deepStrictEqual(rest2, { a: { b: { c: 1, d: 1 }, e: 1 }, f: 1 }); + +const { + a: { e: e3, ...rest3 }, + f +} = { a: { b: { c: 1, d: 1 }, e: 1 }, f: 1 }; +assert.strictEqual(e3, 1); +assert.strictEqual(f, 1); +assert.deepStrictEqual(rest3, { b: { c: 1, d: 1 } }); diff --git a/test/function/samples/object-expression-treeshaking/include-dynamic-import-properties-await/_config.js b/test/function/samples/object-expression-treeshaking/include-dynamic-import-properties-await/_config.js new file mode 100644 index 00000000000..8b1109d88ce --- /dev/null +++ b/test/function/samples/object-expression-treeshaking/include-dynamic-import-properties-await/_config.js @@ -0,0 +1,6 @@ +module.exports = defineTest({ + description: 'includes used dynamic import properties with await', + async exports({ assertImport }) { + await assertImport(); + } +}); diff --git a/test/function/samples/object-expression-treeshaking/include-dynamic-import-properties-await/dep.js b/test/function/samples/object-expression-treeshaking/include-dynamic-import-properties-await/dep.js new file mode 100644 index 00000000000..5fb7ac5654a --- /dev/null +++ b/test/function/samples/object-expression-treeshaking/include-dynamic-import-properties-await/dep.js @@ -0,0 +1 @@ +export const foo = { bar: { baz: 42 } }; diff --git a/test/function/samples/object-expression-treeshaking/include-dynamic-import-properties-await/main.js b/test/function/samples/object-expression-treeshaking/include-dynamic-import-properties-await/main.js new file mode 100644 index 00000000000..089c744b120 --- /dev/null +++ b/test/function/samples/object-expression-treeshaking/include-dynamic-import-properties-await/main.js @@ -0,0 +1,4 @@ +export async function assertImport() { + const { foo } = await import('./dep.js'); + assert.strictEqual(foo.bar.baz, 42); +} diff --git a/test/function/samples/object-expression-treeshaking/include-namespace-reexport-path/_config.js b/test/function/samples/object-expression-treeshaking/include-namespace-reexport-path/_config.js new file mode 100644 index 00000000000..38764cd8a99 --- /dev/null +++ b/test/function/samples/object-expression-treeshaking/include-namespace-reexport-path/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'includes paths across namespace reeports' +}); diff --git a/test/function/samples/object-expression-treeshaking/include-namespace-reexport-path/dep.js b/test/function/samples/object-expression-treeshaking/include-namespace-reexport-path/dep.js new file mode 100644 index 00000000000..bc7a2c831c1 --- /dev/null +++ b/test/function/samples/object-expression-treeshaking/include-namespace-reexport-path/dep.js @@ -0,0 +1 @@ +export { default as object } from './object.js'; diff --git a/test/function/samples/object-expression-treeshaking/include-namespace-reexport-path/lib.js b/test/function/samples/object-expression-treeshaking/include-namespace-reexport-path/lib.js new file mode 100644 index 00000000000..00f84aebaf8 --- /dev/null +++ b/test/function/samples/object-expression-treeshaking/include-namespace-reexport-path/lib.js @@ -0,0 +1 @@ +export * as lib from './dep.js'; diff --git a/test/function/samples/object-expression-treeshaking/include-namespace-reexport-path/main.js b/test/function/samples/object-expression-treeshaking/include-namespace-reexport-path/main.js new file mode 100644 index 00000000000..1a7f1eadd65 --- /dev/null +++ b/test/function/samples/object-expression-treeshaking/include-namespace-reexport-path/main.js @@ -0,0 +1,8 @@ +import { lib } from './lib.js'; + +assert.strictEqual(lib.object.a, 'a'); +log(lib); + +function log(lib) { + assert.strictEqual(lib.object.b, 'b'); +} diff --git a/test/function/samples/object-expression-treeshaking/include-namespace-reexport-path/object.js b/test/function/samples/object-expression-treeshaking/include-namespace-reexport-path/object.js new file mode 100644 index 00000000000..657a5ef6861 --- /dev/null +++ b/test/function/samples/object-expression-treeshaking/include-namespace-reexport-path/object.js @@ -0,0 +1,4 @@ +export default { + a: 'a', + b: 'b' +}; diff --git a/test/function/samples/object-expression-treeshaking/include-redeclared-destructured-variable-paths/_config.js b/test/function/samples/object-expression-treeshaking/include-redeclared-destructured-variable-paths/_config.js new file mode 100644 index 00000000000..6fde0ab6695 --- /dev/null +++ b/test/function/samples/object-expression-treeshaking/include-redeclared-destructured-variable-paths/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'includes redeclared destructured variable paths' +}); diff --git a/test/function/samples/object-expression-treeshaking/include-redeclared-destructured-variable-paths/main.js b/test/function/samples/object-expression-treeshaking/include-redeclared-destructured-variable-paths/main.js new file mode 100644 index 00000000000..7959bf5e3d5 --- /dev/null +++ b/test/function/samples/object-expression-treeshaking/include-redeclared-destructured-variable-paths/main.js @@ -0,0 +1,5 @@ +var { a } = { a: { b: 1 } }; +assert.strictEqual(a.b, 1); + +var { a } = { a: { b: 2 } }; +assert.strictEqual(a.b, 2); diff --git a/test/function/samples/object-expression-treeshaking/include-this-unknown-function/_config.js b/test/function/samples/object-expression-treeshaking/include-this-unknown-function/_config.js new file mode 100644 index 00000000000..5d6a6ecac63 --- /dev/null +++ b/test/function/samples/object-expression-treeshaking/include-this-unknown-function/_config.js @@ -0,0 +1,8 @@ +module.exports = defineTest({ + description: 'includes all context properties if the handler is unknown', + context: { + external() { + this.bar(); + } + } +}); diff --git a/test/function/samples/object-expression-treeshaking/include-this-unknown-function/main.js b/test/function/samples/object-expression-treeshaking/include-this-unknown-function/main.js new file mode 100644 index 00000000000..f25e812abbb --- /dev/null +++ b/test/function/samples/object-expression-treeshaking/include-this-unknown-function/main.js @@ -0,0 +1,11 @@ +let mutated = false; + +const obj = { + foo: external, + bar() { + mutated = true; + } +}; + +obj.foo(); +assert.ok(mutated ? true : false); diff --git a/test/function/samples/object-expression-treeshaking/include-unused-destructured-getters-in-assignment/_config.js b/test/function/samples/object-expression-treeshaking/include-unused-destructured-getters-in-assignment/_config.js new file mode 100644 index 00000000000..7669a3d47a6 --- /dev/null +++ b/test/function/samples/object-expression-treeshaking/include-unused-destructured-getters-in-assignment/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'destructures unused properties with getter side effects in assignments' +}); diff --git a/test/function/samples/object-expression-treeshaking/include-unused-destructured-getters-in-assignment/main.js b/test/function/samples/object-expression-treeshaking/include-unused-destructured-getters-in-assignment/main.js new file mode 100644 index 00000000000..3049bcb524f --- /dev/null +++ b/test/function/samples/object-expression-treeshaking/include-unused-destructured-getters-in-assignment/main.js @@ -0,0 +1,36 @@ +const effects1 = []; +let x1; +({ x1 } = { + get x1() { + effects1.push('x1'); + }, + get y1() { + effects1.push('y1'); + } +}); +assert.deepStrictEqual(effects1, ['x1'], 'effects1'); + +const effects2 = []; +let y2; +({ + x2: { y2 } +} = { + x2: { + get y2() { + effects2.push('y2'); + } + } +}); +assert.deepStrictEqual(effects2, ['y2'], 'effects2'); + +const effects3 = []; +let x3, rest3; +({ x3, ...rest3 } = { + get x3() { + effects3.push('x3'); + }, + get y3() { + effects3.push('y3'); + } +}); +assert.deepStrictEqual(effects3, ['x3', 'y3'], 'effects3'); diff --git a/test/function/samples/object-expression-treeshaking/include-unused-destructured-getters-in-calls/_config.js b/test/function/samples/object-expression-treeshaking/include-unused-destructured-getters-in-calls/_config.js new file mode 100644 index 00000000000..7368c76c36c --- /dev/null +++ b/test/function/samples/object-expression-treeshaking/include-unused-destructured-getters-in-calls/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'destructures unused properties with getter side effects in calls' +}); diff --git a/test/function/samples/object-expression-treeshaking/include-unused-destructured-getters-in-calls/main.js b/test/function/samples/object-expression-treeshaking/include-unused-destructured-getters-in-calls/main.js new file mode 100644 index 00000000000..8597d0263ac --- /dev/null +++ b/test/function/samples/object-expression-treeshaking/include-unused-destructured-getters-in-calls/main.js @@ -0,0 +1,34 @@ +const effects1 = []; +function test1({ x1 }) {} +test1({ + get x1() { + effects1.push('x1'); + }, + get y1() { + effects1.push('y1'); + } +}); +assert.deepStrictEqual(effects1, ['x1'], 'effects1'); + +const effects2 = []; +function test2({ x2: { y2 } }) {} +test2({ + x2: { + get y2() { + effects2.push('y2'); + } + } +}); +assert.deepStrictEqual(effects2, ['y2'], 'effects2'); + +const effects3 = []; +function test3( { x3, ...rest3 }){} +test3({ + get x3() { + effects3.push('x3'); + }, + get y3() { + effects3.push('y3'); + } +}); +assert.deepStrictEqual(effects3, ['x3', 'y3'], 'effects3'); diff --git a/test/function/samples/object-expression-treeshaking/include-unused-destructured-getters/_config.js b/test/function/samples/object-expression-treeshaking/include-unused-destructured-getters/_config.js new file mode 100644 index 00000000000..1f855971b6e --- /dev/null +++ b/test/function/samples/object-expression-treeshaking/include-unused-destructured-getters/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'destructures unused properties with getter side effects' +}); diff --git a/test/function/samples/object-expression-treeshaking/include-unused-destructured-getters/main.js b/test/function/samples/object-expression-treeshaking/include-unused-destructured-getters/main.js new file mode 100644 index 00000000000..9750d2228be --- /dev/null +++ b/test/function/samples/object-expression-treeshaking/include-unused-destructured-getters/main.js @@ -0,0 +1,33 @@ +const effects1 = []; +const { x1 } = { + get x1() { + effects1.push('x1'); + }, + get y1() { + effects1.push('y1'); + } +}; +assert.deepStrictEqual(effects1, ['x1'], 'effects1'); + +const effects2 = []; +const { + x2: { y2 } +} = { + x2: { + get y2() { + effects2.push('y2'); + } + } +}; +assert.deepStrictEqual(effects2, ['y2'], 'effects2'); + +const effects3 = []; +const { x3, ...rest3 } = { + get x3() { + effects3.push('x3'); + }, + get y3() { + effects3.push('y3'); + } +}; +assert.deepStrictEqual(effects3, ['x3', 'y3'], 'effects3'); diff --git a/test/function/samples/object-expression-treeshaking/object-side-effects/_config.js b/test/function/samples/object-expression-treeshaking/object-side-effects/_config.js new file mode 100644 index 00000000000..dfb161d6ea9 --- /dev/null +++ b/test/function/samples/object-expression-treeshaking/object-side-effects/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'considers side effects in unused property declarations' +}); diff --git a/test/function/samples/object-expression-treeshaking/object-side-effects/main.js b/test/function/samples/object-expression-treeshaking/object-side-effects/main.js new file mode 100644 index 00000000000..d32c4546ae0 --- /dev/null +++ b/test/function/samples/object-expression-treeshaking/object-side-effects/main.js @@ -0,0 +1,22 @@ +let modified1 = false; +let modified2 = false; + +function effect1() { + modified1 = true; + return 'keyEffect'; +} + +function effect2() { + modified2 = true; + return 4; +} + +const obj = { + used: 1, + unused: 2, + [effect1()]: 3, + valueEffect: effect2() +}; +assert.strictEqual(obj.used, 1); +assert.ok(modified1, 'first'); +assert.ok(modified2, 'second'); diff --git a/test/function/samples/object-expression-treeshaking/retain-property-definition-paths/_config.js b/test/function/samples/object-expression-treeshaking/retain-property-definition-paths/_config.js new file mode 100644 index 00000000000..b9af1759f4f --- /dev/null +++ b/test/function/samples/object-expression-treeshaking/retain-property-definition-paths/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'ensures that paths of property definitions are retained' +}); diff --git a/test/function/samples/object-expression-treeshaking/retain-property-definition-paths/main.js b/test/function/samples/object-expression-treeshaking/retain-property-definition-paths/main.js new file mode 100644 index 00000000000..7110c9874fa --- /dev/null +++ b/test/function/samples/object-expression-treeshaking/retain-property-definition-paths/main.js @@ -0,0 +1,5 @@ +class Test { + foo = { x: 1 }; +} + +assert.strictEqual(new Test().foo.x, 1); diff --git a/test/function/samples/object-expression-treeshaking/throw-object/_config.js b/test/function/samples/object-expression-treeshaking/throw-object/_config.js new file mode 100644 index 00000000000..348d86287cc --- /dev/null +++ b/test/function/samples/object-expression-treeshaking/throw-object/_config.js @@ -0,0 +1,12 @@ +const assert = require('assert'); + +module.exports = defineTest({ + description: 'allows to throw object expressions with all properties', + exports({ test }) { + try { + test(); + } catch (error) { + assert.deepStrictEqual(error, { my: 'info' }); + } + } +}); diff --git a/test/function/samples/object-expression-treeshaking/throw-object/main.js b/test/function/samples/object-expression-treeshaking/throw-object/main.js new file mode 100644 index 00000000000..9a208712705 --- /dev/null +++ b/test/function/samples/object-expression-treeshaking/throw-object/main.js @@ -0,0 +1,3 @@ +export function test() { + throw { my: 'info' }; +} diff --git a/test/function/samples/object-expression-treeshaking/track-access-side-effect-via-destructuring/_config.js b/test/function/samples/object-expression-treeshaking/track-access-side-effect-via-destructuring/_config.js new file mode 100644 index 00000000000..07cdb40b85d --- /dev/null +++ b/test/function/samples/object-expression-treeshaking/track-access-side-effect-via-destructuring/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'tracks property access side effects for destructured variables' +}); diff --git a/test/function/samples/object-expression-treeshaking/track-access-side-effect-via-destructuring/main.js b/test/function/samples/object-expression-treeshaking/track-access-side-effect-via-destructuring/main.js new file mode 100644 index 00000000000..eff4d312437 --- /dev/null +++ b/test/function/samples/object-expression-treeshaking/track-access-side-effect-via-destructuring/main.js @@ -0,0 +1,14 @@ +let mutated = false; + +var { a } = { + a: { + get b() { + mutated = true; + return {}; + } + }, + b: {} +}; + +a.b; +assert.ok(mutated); diff --git a/test/function/samples/object-expression-treeshaking/track-assignment-side-effect-via-destructuring/_config.js b/test/function/samples/object-expression-treeshaking/track-assignment-side-effect-via-destructuring/_config.js new file mode 100644 index 00000000000..5f3148007a8 --- /dev/null +++ b/test/function/samples/object-expression-treeshaking/track-assignment-side-effect-via-destructuring/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'tracks property assignment side effects for destructured variables' +}); diff --git a/test/function/samples/object-expression-treeshaking/track-assignment-side-effect-via-destructuring/main.js b/test/function/samples/object-expression-treeshaking/track-assignment-side-effect-via-destructuring/main.js new file mode 100644 index 00000000000..1fae330532d --- /dev/null +++ b/test/function/samples/object-expression-treeshaking/track-assignment-side-effect-via-destructuring/main.js @@ -0,0 +1,13 @@ +let mutated = false; + +var { a } = { + a: { + set b(value) { + mutated = value; + } + }, + b: {} +}; + +a.b = true; +assert.ok(mutated); diff --git a/test/function/samples/object-expression-treeshaking/track-call-side-effect-via-destructuring/_config.js b/test/function/samples/object-expression-treeshaking/track-call-side-effect-via-destructuring/_config.js new file mode 100644 index 00000000000..993182b7771 --- /dev/null +++ b/test/function/samples/object-expression-treeshaking/track-call-side-effect-via-destructuring/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'tracks call side effects for destructured variables' +}); diff --git a/test/function/samples/object-expression-treeshaking/track-call-side-effect-via-destructuring/main.js b/test/function/samples/object-expression-treeshaking/track-call-side-effect-via-destructuring/main.js new file mode 100644 index 00000000000..09711eded56 --- /dev/null +++ b/test/function/samples/object-expression-treeshaking/track-call-side-effect-via-destructuring/main.js @@ -0,0 +1,13 @@ +let mutated = false; + +var { a } = { + a: { + b() { + mutated = true; + } + }, + b() {} +}; + +a.b(); +assert.ok(mutated); diff --git a/test/function/samples/object-expression-treeshaking/track-destructured-setter/_config.js b/test/function/samples/object-expression-treeshaking/track-destructured-setter/_config.js new file mode 100644 index 00000000000..6268facf730 --- /dev/null +++ b/test/function/samples/object-expression-treeshaking/track-destructured-setter/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'tracks side effects from setters in destructuring assignments' +}); diff --git a/test/function/samples/object-expression-treeshaking/track-destructured-setter/main.js b/test/function/samples/object-expression-treeshaking/track-destructured-setter/main.js new file mode 100644 index 00000000000..58d231674a4 --- /dev/null +++ b/test/function/samples/object-expression-treeshaking/track-destructured-setter/main.js @@ -0,0 +1,8 @@ +let effect = false; +const obj = { + set foo(value) { + effect = value; + } +}; +({ foo: obj.foo } = { foo: 'value' }); +assert.strictEqual(effect, 'value'); diff --git a/test/function/samples/object-expression-treeshaking/try-statement-arguments/_config.js b/test/function/samples/object-expression-treeshaking/try-statement-arguments/_config.js new file mode 100644 index 00000000000..4b50df22d90 --- /dev/null +++ b/test/function/samples/object-expression-treeshaking/try-statement-arguments/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'includes referenced call arguments to functions called from try statements' +}); diff --git a/test/function/samples/object-expression-treeshaking/try-statement-arguments/main.js b/test/function/samples/object-expression-treeshaking/try-statement-arguments/main.js new file mode 100644 index 00000000000..f699e9fb738 --- /dev/null +++ b/test/function/samples/object-expression-treeshaking/try-statement-arguments/main.js @@ -0,0 +1,14 @@ +const safeCall = call => { + call() + try { + return call(); + } catch {} +}; + +const identity = x => x; + +const opts = { foo: 1 }; +assert.deepStrictEqual( + safeCall(() => identity(opts)), + { foo: 1 } +); diff --git a/test/function/samples/object-expression-treeshaking/try-statement-return-properties/_config.js b/test/function/samples/object-expression-treeshaking/try-statement-return-properties/_config.js new file mode 100644 index 00000000000..20c28cfbb43 --- /dev/null +++ b/test/function/samples/object-expression-treeshaking/try-statement-return-properties/_config.js @@ -0,0 +1,8 @@ +module.exports = defineTest({ + description: 'includes properties of return statements in try statements', + options: { + treeshake: { + tryCatchDeoptimization: true + } + } +}); diff --git a/test/function/samples/object-expression-treeshaking/try-statement-return-properties/main.js b/test/function/samples/object-expression-treeshaking/try-statement-return-properties/main.js new file mode 100644 index 00000000000..5ca2f73b384 --- /dev/null +++ b/test/function/samples/object-expression-treeshaking/try-statement-return-properties/main.js @@ -0,0 +1,14 @@ +const options = { + bar: () => 'bar', + car: () => 'car' +}; + +assert.strictEqual(qux(options), 'car'); + +function qux({ bar, car }) { + try { + return car(); + } catch { + return undefined; + } +} diff --git a/test/function/samples/object-properties/_config.js b/test/function/samples/object-properties/_config.js index 46d096af44a..cd8ec59de21 100644 --- a/test/function/samples/object-properties/_config.js +++ b/test/function/samples/object-properties/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'includes object properties in definitions' -}; +}); diff --git a/test/function/samples/object-prototype-properties/_config.js b/test/function/samples/object-prototype-properties/_config.js index 258727cc3bb..4c4c48b8a31 100644 --- a/test/function/samples/object-prototype-properties/_config.js +++ b/test/function/samples/object-prototype-properties/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'handles names conflicting with Object.prototype properties' -}; +}); diff --git a/test/function/samples/object-spread-side-effect/_config.js b/test/function/samples/object-spread-side-effect/_config.js new file mode 100644 index 00000000000..16841b87bc1 --- /dev/null +++ b/test/function/samples/object-spread-side-effect/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'triggers getter side effects when spreading objects' +}); diff --git a/test/function/samples/object-spread-side-effect/main.js b/test/function/samples/object-spread-side-effect/main.js new file mode 100644 index 00000000000..ae997485f8b --- /dev/null +++ b/test/function/samples/object-spread-side-effect/main.js @@ -0,0 +1,9 @@ +let result = 'FAIL'; +const unused = { + ...{ + get prop() { + result = 'PASS'; + } + } +}; +assert.strictEqual(result, 'PASS'); diff --git a/test/function/samples/object-tree-shaking-for-global-assignment/_config.js b/test/function/samples/object-tree-shaking-for-global-assignment/_config.js new file mode 100644 index 00000000000..342682dfe8b --- /dev/null +++ b/test/function/samples/object-tree-shaking-for-global-assignment/_config.js @@ -0,0 +1,6 @@ +module.exports = defineTest({ + description: 'preserve the object on the right side of the global assignment', + context: { + b: {} + } +}); diff --git a/test/function/samples/object-tree-shaking-for-global-assignment/main.js b/test/function/samples/object-tree-shaking-for-global-assignment/main.js new file mode 100644 index 00000000000..2b3e70c2b8c --- /dev/null +++ b/test/function/samples/object-tree-shaking-for-global-assignment/main.js @@ -0,0 +1,6 @@ +function foo() { + const a = (b.c = { e: 1 }); +} +foo(); + +assert.deepEqual(b.c.e, 1); diff --git a/test/function/samples/object-tree-shaking-for-parameter/_config.js b/test/function/samples/object-tree-shaking-for-parameter/_config.js new file mode 100644 index 00000000000..78d27f62591 --- /dev/null +++ b/test/function/samples/object-tree-shaking-for-parameter/_config.js @@ -0,0 +1,8 @@ +module.exports = defineTest({ + description: 'preserve the object argument', + context: { + externalFunc(input) { + return input; + } + } +}); diff --git a/test/function/samples/object-tree-shaking-for-parameter/main.js b/test/function/samples/object-tree-shaking-for-parameter/main.js new file mode 100644 index 00000000000..0d18beb5448 --- /dev/null +++ b/test/function/samples/object-tree-shaking-for-parameter/main.js @@ -0,0 +1,15 @@ +function foo() { + function bar(input2) { + return input2; + } + + function Baz(input) { + this.value = bar(input); + } + + externalFunc(Baz); + + return new Baz({ next: 2 }); +} + +assert.deepEqual(foo().value.next, 2); diff --git a/test/function/samples/object-tree-shaking-in-function-self-call/_config.js b/test/function/samples/object-tree-shaking-in-function-self-call/_config.js new file mode 100644 index 00000000000..0148514e678 --- /dev/null +++ b/test/function/samples/object-tree-shaking-in-function-self-call/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'avoid maximum call stack size exceeded' +}); diff --git a/test/function/samples/object-tree-shaking-in-function-self-call/main.js b/test/function/samples/object-tree-shaking-in-function-self-call/main.js new file mode 100644 index 00000000000..bb5d1b01343 --- /dev/null +++ b/test/function/samples/object-tree-shaking-in-function-self-call/main.js @@ -0,0 +1,7 @@ +function foo(v) { + if (v.a) { + foo(v.b); + foo(v.c); + } +} +foo({ b: 1 }); diff --git a/test/function/samples/object-tree-shaking-with-destructed-export/_config.js b/test/function/samples/object-tree-shaking-with-destructed-export/_config.js new file mode 100644 index 00000000000..7fc0d9a3537 --- /dev/null +++ b/test/function/samples/object-tree-shaking-with-destructed-export/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'export the full object which in the ObjectPattern' +}); diff --git a/test/function/samples/object-tree-shaking-with-destructed-export/main.js b/test/function/samples/object-tree-shaking-with-destructed-export/main.js new file mode 100644 index 00000000000..7d821e50caa --- /dev/null +++ b/test/function/samples/object-tree-shaking-with-destructed-export/main.js @@ -0,0 +1,3 @@ +import { bar } from './module'; + +assert(bar.baz, 1); diff --git a/test/function/samples/object-tree-shaking-with-destructed-export/module.js b/test/function/samples/object-tree-shaking-with-destructed-export/module.js new file mode 100644 index 00000000000..b60c753a2ec --- /dev/null +++ b/test/function/samples/object-tree-shaking-with-destructed-export/module.js @@ -0,0 +1,2 @@ +const foo = { bar: { baz: 1 } }; +export const { bar } = foo; diff --git a/test/function/samples/object-tree-shaking-with-duplicated-function-call/_config.js b/test/function/samples/object-tree-shaking-with-duplicated-function-call/_config.js new file mode 100644 index 00000000000..19f844a1eb7 --- /dev/null +++ b/test/function/samples/object-tree-shaking-with-duplicated-function-call/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'get the full object which as a parameter passed to duplicated function call' +}); diff --git a/test/function/samples/object-tree-shaking-with-duplicated-function-call/main.js b/test/function/samples/object-tree-shaking-with-duplicated-function-call/main.js new file mode 100644 index 00000000000..4a920f168ec --- /dev/null +++ b/test/function/samples/object-tree-shaking-with-duplicated-function-call/main.js @@ -0,0 +1,6 @@ +function foo(c) { + assert.ok(c.a); +} + +foo({ a: 1 }); +foo({ a: 1 }); diff --git a/test/function/samples/object-tree-shaking-with-rest-element-destructed/_config.js b/test/function/samples/object-tree-shaking-with-rest-element-destructed/_config.js new file mode 100644 index 00000000000..a5de162cbad --- /dev/null +++ b/test/function/samples/object-tree-shaking-with-rest-element-destructed/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'include all properties if a rest element is destructed' +}); diff --git a/test/function/samples/object-tree-shaking-with-rest-element-destructed/main.js b/test/function/samples/object-tree-shaking-with-rest-element-destructed/main.js new file mode 100644 index 00000000000..f4eb3aaeeb0 --- /dev/null +++ b/test/function/samples/object-tree-shaking-with-rest-element-destructed/main.js @@ -0,0 +1,3 @@ +const obj = { a: 1, b: 2 }; +const { a: _, ...rest } = obj; +assert.deepStrictEqual(rest, { b: 2 }); diff --git a/test/function/samples/optional-catch-binding/_config.js b/test/function/samples/optional-catch-binding/_config.js index f130a80c0fb..5ecb6a927d4 100644 --- a/test/function/samples/optional-catch-binding/_config.js +++ b/test/function/samples/optional-catch-binding/_config.js @@ -1,8 +1,8 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { - description: 'allows optional catch binding with appropriate acorn settings', +module.exports = defineTest({ + description: 'allows optional catch binding', exports(exports) { assert.equal(exports.foo, true); } -}; +}); diff --git a/test/function/samples/optional-chaining-namespace/_config.js b/test/function/samples/optional-chaining-namespace/_config.js new file mode 100644 index 00000000000..356019bcb55 --- /dev/null +++ b/test/function/samples/optional-chaining-namespace/_config.js @@ -0,0 +1,10 @@ +module.exports = defineTest({ + description: 'handles optional chaining with namespace', + options: { + onLog(_level, log) { + if (log.code !== 'MISSING_EXPORT') { + throw new Error(`Unexpected log code: ${log.code}`); + } + } + } +}); diff --git a/test/function/samples/optional-chaining-namespace/main.js b/test/function/samples/optional-chaining-namespace/main.js new file mode 100644 index 00000000000..19df8ad51f3 --- /dev/null +++ b/test/function/samples/optional-chaining-namespace/main.js @@ -0,0 +1,4 @@ +import * as other from './other.js'; + +assert.ok(other?.default ? true : false); +assert.ok(other?.doesNotExist ? false : true); diff --git a/test/function/samples/optional-chaining-namespace/other.js b/test/function/samples/optional-chaining-namespace/other.js new file mode 100644 index 00000000000..dd7866d4a60 --- /dev/null +++ b/test/function/samples/optional-chaining-namespace/other.js @@ -0,0 +1 @@ +export default { value: 42 }; diff --git a/test/function/samples/optional-chaining-side-effect/_config.js b/test/function/samples/optional-chaining-side-effect/_config.js new file mode 100644 index 00000000000..24d7316b6bb --- /dev/null +++ b/test/function/samples/optional-chaining-side-effect/_config.js @@ -0,0 +1,9 @@ +const assert = require('node:assert'); + +module.exports = defineTest({ + description: 'handles side effects in optional chaining (#4806)', + exports({ get, set }) { + set(['test']); + assert.strictEqual(get('test'), 't'); + } +}); diff --git a/test/function/samples/optional-chaining-side-effect/main.js b/test/function/samples/optional-chaining-side-effect/main.js new file mode 100644 index 00000000000..b2ff44c747d --- /dev/null +++ b/test/function/samples/optional-chaining-side-effect/main.js @@ -0,0 +1,13 @@ +var value; + +export function get(v) { + let g = value?.find(b => v === b); + if (!g) { + return; + } + return g.charAt(0); +} + +export function set(a) { + value = a; +} diff --git a/test/function/samples/optional-chaining-side-effect2/_config.js b/test/function/samples/optional-chaining-side-effect2/_config.js new file mode 100644 index 00000000000..c3847d3d1ce --- /dev/null +++ b/test/function/samples/optional-chaining-side-effect2/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'does not omit side effects in optionally chained calls (#5579)' +}); diff --git a/test/function/samples/optional-chaining-side-effect2/main.js b/test/function/samples/optional-chaining-side-effect2/main.js new file mode 100644 index 00000000000..2b5ffcfa3c9 --- /dev/null +++ b/test/function/samples/optional-chaining-side-effect2/main.js @@ -0,0 +1,9 @@ +let modified = false; + +function sideEffect() { + modified = true; + return null; +} + +sideEffect()?.x; +assert.ok(modified); diff --git a/test/function/samples/options-async-hook/_config.js b/test/function/samples/options-async-hook/_config.js index 07426baa8ed..c9d67b796e8 100644 --- a/test/function/samples/options-async-hook/_config.js +++ b/test/function/samples/options-async-hook/_config.js @@ -1,8 +1,9 @@ -const assert = require('assert'); -const { promises: fs } = require('fs'); +const assert = require('node:assert'); +const { promises: fs } = require('node:fs'); -module.exports = { +module.exports = defineTest({ description: 'resolves promises between sequential options hooks', + verifyAst: false, options: { input: 'super-unused', treeshake: false, @@ -16,18 +17,16 @@ module.exports = { strictDeprecations: true, treeshake: false }); - return Object.assign({}, options, { - input: (await fs.readFile('file.txt', 'utf8')).trim() - }); + return { ...options, input: (await fs.readFile('file.txt', 'utf8')).trim() }; } }, { name: 'test-plugin-2', options(options) { assert.strictEqual(options.input, 'unused'); - return Object.assign({}, options, { input: 'used' }); + return { ...options, input: 'used' }; } } ] } -}; +}); diff --git a/test/function/samples/options-hook/_config.js b/test/function/samples/options-hook/_config.js index 9c9f60220ee..0583b7ffea1 100644 --- a/test/function/samples/options-hook/_config.js +++ b/test/function/samples/options-hook/_config.js @@ -1,53 +1,54 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'allows to read and modify options in the options hook', + verifyAst: false, options: { input: 'unused', treeshake: false, - plugins: { - name: 'test-plugin', - buildStart(options) { - assert.deepStrictEqual(JSON.parse(JSON.stringify(options)), { - acorn: { - allowAwaitOutsideFunction: true, - ecmaVersion: 'latest', - preserveParens: false, - sourceType: 'module' - }, - acornInjectPlugins: [null, null, null], - context: 'undefined', - experimentalCacheExpiry: 10, - input: ['used'], - makeAbsoluteExternalsRelative: true, - perf: false, - plugins: [ - { - name: 'test-plugin' - } - ], - preserveEntrySignatures: 'strict', - preserveSymlinks: false, - shimMissingExports: false, - strictDeprecations: true, - treeshake: false - }); - assert.ok(/^\d+\.\d+\.\d+/.test(this.meta.rollupVersion)); - assert.strictEqual(this.meta.watchMode, false); - }, - options(options) { - assert.deepStrictEqual(JSON.parse(JSON.stringify(options)), { - input: 'unused', - plugins: { - name: 'test-plugin' - }, - strictDeprecations: true, - treeshake: false - }); - assert.ok(/^\d+\.\d+\.\d+/.test(this.meta.rollupVersion)); - assert.strictEqual(this.meta.watchMode, false); - return Object.assign({}, options, { input: 'used' }); + plugins: [ + { + name: 'test-plugin', + buildStart(options) { + // The fs option is not json stringifiable + const { fs, ...restOptions } = options; + assert.ok(fs); + assert.deepStrictEqual(JSON.parse(JSON.stringify(restOptions)), { + context: 'undefined', + experimentalCacheExpiry: 10, + experimentalLogSideEffects: false, + input: ['used'], + jsx: false, + logLevel: 'info', + makeAbsoluteExternalsRelative: 'ifRelativeSource', + maxParallelFileOps: 1000, + perf: false, + plugins: [ + { + name: 'test-plugin' + } + ], + preserveEntrySignatures: 'exports-only', + preserveSymlinks: false, + shimMissingExports: false, + strictDeprecations: true, + treeshake: false + }); + assert.ok(/^\d+\.\d+\.\d+/.test(this.meta.rollupVersion)); + assert.strictEqual(this.meta.watchMode, false); + }, + options(options) { + assert.deepStrictEqual(JSON.parse(JSON.stringify(options)), { + input: 'unused', + plugins: [{ name: 'test-plugin' }], + strictDeprecations: true, + treeshake: false + }); + assert.ok(/^\d+\.\d+\.\d+/.test(this.meta.rollupVersion)); + assert.strictEqual(this.meta.watchMode, false); + return { ...options, input: 'used' }; + } } - } + ] } -}; +}); diff --git a/test/function/samples/options-in-renderstart/_config.js b/test/function/samples/options-in-renderstart/_config.js index 3129a8b36ea..1e4c7b38ba8 100644 --- a/test/function/samples/options-in-renderstart/_config.js +++ b/test/function/samples/options-in-renderstart/_config.js @@ -1,33 +1,37 @@ -const assert = require('assert'); +const assert = require('node:assert'); const checkedOptions = []; -module.exports = { +module.exports = defineTest({ description: 'makes input and output options available in renderStart', options: { context: 'global', - plugins: { - name: 'input-plugin', - renderStart(outputOptions, inputOptions) { - checkedOptions.push('input-plugin', outputOptions.format, inputOptions.context); - } - }, - output: { - plugins: { - name: 'output-plugin', + plugins: [ + { + name: 'input-plugin', renderStart(outputOptions, inputOptions) { - checkedOptions.push('output-plugin', outputOptions.format, inputOptions.context); + checkedOptions.push('input-plugin', outputOptions.format, inputOptions.context); } } + ], + output: { + plugins: [ + { + name: 'output-plugin', + renderStart(outputOptions, inputOptions) { + checkedOptions.push('output-plugin', outputOptions.format, inputOptions.context); + } + } + ] } }, exports: () => { assert.deepStrictEqual(checkedOptions, [ - 'output-plugin', + 'input-plugin', 'cjs', 'global', - 'input-plugin', + 'output-plugin', 'cjs', 'global' ]); } -}; +}); diff --git a/test/function/samples/output-options-hook/_config.js b/test/function/samples/output-options-hook/_config.js index 904cf55577e..c4977453d07 100644 --- a/test/function/samples/output-options-hook/_config.js +++ b/test/function/samples/output-options-hook/_config.js @@ -1,6 +1,6 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'allows to read and modify options in the options hook', exports(exports) { assert.deepStrictEqual(exports, { @@ -12,56 +12,74 @@ module.exports = { output: { banner: "throw new Error('unused')" }, - plugins: { - name: 'test-plugin', - renderChunk(code, chunk, options) { - assert.deepStrictEqual(JSON.parse(JSON.stringify(options)), { - amd: { - define: 'define', - autoId: false - }, - assetFileNames: 'assets/[name]-[hash][extname]', - chunkFileNames: '[name]-[hash].js', - compact: false, - entryFileNames: '[name].js', - esModule: true, - exports: 'auto', - extend: false, - externalLiveBindings: true, - format: 'cjs', - freeze: true, - globals: {}, - hoistTransitiveImports: true, - indent: true, - inlineDynamicImports: false, - manualChunks: {}, - minifyInternalExports: false, - namespaceToStringTag: false, - noConflict: false, - paths: {}, - plugins: [], - preferConst: false, - preserveModules: false, - sourcemap: false, - sourcemapExcludeSources: false, - strict: true, - systemNullSetters: false, - validate: false - }); - assert.strictEqual(options.banner(), 'exports.bar = 43;'); - assert.ok(/^\d+\.\d+\.\d+/.test(this.meta.rollupVersion)); - assert.strictEqual(this.meta.watchMode, false); - }, - outputOptions(options) { - assert.deepStrictEqual(JSON.parse(JSON.stringify(options)), { - banner: "throw new Error('unused')", - exports: 'auto', - format: 'cjs' - }); - assert.ok(/^\d+\.\d+\.\d+/.test(this.meta.rollupVersion)); - assert.strictEqual(this.meta.watchMode, false); - return Object.assign({}, options, { banner: 'exports.bar = 43;' }); + plugins: [ + { + name: 'test-plugin', + renderChunk(code, chunk, options) { + assert.deepStrictEqual(JSON.parse(JSON.stringify(options)), { + amd: { + define: 'define', + autoId: false, + forceJsExtensionForImports: false + }, + assetFileNames: 'assets/[name]-[hash][extname]', + chunkFileNames: '[name]-[hash].js', + compact: false, + dynamicImportInCjs: true, + entryFileNames: '[name].js', + esModule: 'if-default-prop', + experimentalMinChunkSize: 1, + exports: 'auto', + extend: false, + externalImportAssertions: true, + externalImportAttributes: true, + externalLiveBindings: true, + format: 'cjs', + freeze: true, + generatedCode: { + arrowFunctions: false, + constBindings: false, + objectShorthand: false, + reservedNamesAsProps: true, + symbols: false + }, + globals: {}, + hashCharacters: 'base64', + hoistTransitiveImports: true, + importAttributesKey: 'assert', + indent: true, + inlineDynamicImports: false, + manualChunks: {}, + minifyInternalExports: false, + noConflict: false, + onlyExplicitManualChunks: false, + paths: {}, + plugins: [], + preserveModules: false, + reexportProtoFromExternal: true, + sourcemap: false, + sourcemapDebugIds: false, + sourcemapExcludeSources: false, + strict: true, + systemNullSetters: true, + validate: false, + virtualDirname: '_virtual' + }); + assert.strictEqual(options.banner(), 'exports.bar = 43;'); + assert.ok(/^\d+\.\d+\.\d+/.test(this.meta.rollupVersion)); + assert.strictEqual(this.meta.watchMode, false); + }, + outputOptions(options) { + assert.deepStrictEqual(JSON.parse(JSON.stringify(options)), { + banner: "throw new Error('unused')", + exports: 'auto', + format: 'cjs' + }); + assert.ok(/^\d+\.\d+\.\d+/.test(this.meta.rollupVersion)); + assert.strictEqual(this.meta.watchMode, false); + return { ...options, banner: 'exports.bar = 43;' }; + } } - } + ] } -}; +}); diff --git a/test/function/samples/override-external-namespace/_config.js b/test/function/samples/override-external-namespace/_config.js index 48c7480e64f..0ce2f804a5a 100644 --- a/test/function/samples/override-external-namespace/_config.js +++ b/test/function/samples/override-external-namespace/_config.js @@ -1,6 +1,6 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'allows overriding imports of external namespace reexports', options: { external: 'path' @@ -13,4 +13,4 @@ module.exports = { exports.reassign(); assert.strictEqual(exports.resolve, 'defined'); } -}; +}); diff --git a/test/function/samples/override-static-external-namespace/_config.js b/test/function/samples/override-static-external-namespace/_config.js index 71fb2ddc5c3..44409f65263 100644 --- a/test/function/samples/override-static-external-namespace/_config.js +++ b/test/function/samples/override-static-external-namespace/_config.js @@ -1,7 +1,8 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { - description: 'allows overriding imports of external namespace reexports without external live-bindings', +module.exports = defineTest({ + description: + 'allows overriding imports of external namespace reexports without external live-bindings', options: { external: 'path', output: { @@ -16,4 +17,4 @@ module.exports = { exports.reassign(); assert.strictEqual(exports.resolve, 'defined'); } -}; +}); diff --git a/test/function/samples/parameter-defaults/arrays/_config.js b/test/function/samples/parameter-defaults/arrays/_config.js new file mode 100644 index 00000000000..12e61487e58 --- /dev/null +++ b/test/function/samples/parameter-defaults/arrays/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'keeps parameter defaults for array elements' +}); diff --git a/test/function/samples/parameter-defaults/arrays/main.js b/test/function/samples/parameter-defaults/arrays/main.js new file mode 100644 index 00000000000..6bc55609337 --- /dev/null +++ b/test/function/samples/parameter-defaults/arrays/main.js @@ -0,0 +1,6 @@ +const a = (foo = 'fallback a') => assert.strictEqual(foo, 'fallback a'); + +const array = [a, (foo = 'fallback b') => assert.strictEqual(foo, 'fallback b')]; + +array[0](); +array[1](); diff --git a/test/function/samples/parameter-defaults/class-fields/_config.js b/test/function/samples/parameter-defaults/class-fields/_config.js new file mode 100644 index 00000000000..8d2e22acba1 --- /dev/null +++ b/test/function/samples/parameter-defaults/class-fields/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'keeps parameter defaults for class fields' +}); diff --git a/test/function/samples/parameter-defaults/class-fields/main.js b/test/function/samples/parameter-defaults/class-fields/main.js new file mode 100644 index 00000000000..41870a9332d --- /dev/null +++ b/test/function/samples/parameter-defaults/class-fields/main.js @@ -0,0 +1,11 @@ +const a = (foo = 'fallback a') => assert.strictEqual(foo, 'fallback a'); + +const b = (foo = 'fallback b') => assert.strictEqual(foo, 'fallback b'); + +class Test { + static staticField = a; + field = b; +} + +Test.staticField(); +new Test().field(); diff --git a/test/function/samples/parameter-defaults/exported/_config.js b/test/function/samples/parameter-defaults/exported/_config.js new file mode 100644 index 00000000000..63514ca6530 --- /dev/null +++ b/test/function/samples/parameter-defaults/exported/_config.js @@ -0,0 +1,10 @@ +const assert = require('node:assert'); + +module.exports = defineTest({ + description: 'includes default parameters for exported functions', + exports({ funDecl, funExp, arrow }) { + assert.strictEqual(funDecl(), 'defaultValue', 'function declaration'); + assert.strictEqual(funExp(), 'defaultValue', 'function expression'); + assert.strictEqual(arrow(), 'defaultValue', 'arrow function'); + } +}); diff --git a/test/function/samples/parameter-defaults/exported/main.js b/test/function/samples/parameter-defaults/exported/main.js new file mode 100644 index 00000000000..c40f173c19b --- /dev/null +++ b/test/function/samples/parameter-defaults/exported/main.js @@ -0,0 +1,9 @@ +export function funDecl(a = 'defaultValue') { + return a; +} + +export const funExp = function (a = 'defaultValue') { + return a; +}; + +export const arrow = (a = 'defaultValue') => a; diff --git a/test/function/samples/parameter-defaults/function-as-default/_config.js b/test/function/samples/parameter-defaults/function-as-default/_config.js new file mode 100644 index 00000000000..6c3745d9e93 --- /dev/null +++ b/test/function/samples/parameter-defaults/function-as-default/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'deoptimizes functions supplied as default values' +}); diff --git a/test/function/samples/parameter-defaults/function-as-default/main.js b/test/function/samples/parameter-defaults/function-as-default/main.js new file mode 100644 index 00000000000..f11044a0ac5 --- /dev/null +++ b/test/function/samples/parameter-defaults/function-as-default/main.js @@ -0,0 +1,4 @@ +const foo = (a = 'fallback') => a; +const bar = (a = foo) => a; + +assert.strictEqual(bar()(), 'fallback'); diff --git a/test/function/samples/parameter-defaults/function-return/_config.js b/test/function/samples/parameter-defaults/function-return/_config.js new file mode 100644 index 00000000000..d21db6c718e --- /dev/null +++ b/test/function/samples/parameter-defaults/function-return/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'tracks parameter defaults for returned functions' +}); diff --git a/test/function/samples/parameter-defaults/function-return/main.js b/test/function/samples/parameter-defaults/function-return/main.js new file mode 100644 index 00000000000..33187381725 --- /dev/null +++ b/test/function/samples/parameter-defaults/function-return/main.js @@ -0,0 +1,14 @@ +function test1() { + return function (a = 'fallback') { + return a; + }; +} + +assert.strictEqual(test1()(), 'fallback'); + +const test2 = + () => + (_, a = 'fallback') => + a; + +assert.strictEqual(test2````, 'fallback'); diff --git a/test/function/samples/parameter-defaults/logical-expressions/_config.js b/test/function/samples/parameter-defaults/logical-expressions/_config.js new file mode 100644 index 00000000000..99b64bd5eb2 --- /dev/null +++ b/test/function/samples/parameter-defaults/logical-expressions/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'includes default parameters in logical expressios' +}); diff --git a/test/function/samples/parameter-defaults/logical-expressions/main.js b/test/function/samples/parameter-defaults/logical-expressions/main.js new file mode 100644 index 00000000000..9557d0b7f87 --- /dev/null +++ b/test/function/samples/parameter-defaults/logical-expressions/main.js @@ -0,0 +1,2 @@ +const foo = ((a = 'fallback') => a) || false; +assert.strictEqual(foo(), 'fallback'); diff --git a/test/function/samples/parameter-defaults/module-side-effects/_config.js b/test/function/samples/parameter-defaults/module-side-effects/_config.js new file mode 100644 index 00000000000..66497faaa0b --- /dev/null +++ b/test/function/samples/parameter-defaults/module-side-effects/_config.js @@ -0,0 +1,7 @@ +module.exports = defineTest({ + description: + 'does not tree-shake necessary parameter defaults when modulesSideEffects are disabled', + options: { + treeshake: { moduleSideEffects: false } + } +}); diff --git a/test/function/samples/parameter-defaults/module-side-effects/main.js b/test/function/samples/parameter-defaults/module-side-effects/main.js new file mode 100644 index 00000000000..61838adaa51 --- /dev/null +++ b/test/function/samples/parameter-defaults/module-side-effects/main.js @@ -0,0 +1,3 @@ +import { foo } from './other'; + +assert.strictEqual(foo(), 'fallback'); diff --git a/test/function/samples/parameter-defaults/module-side-effects/other.js b/test/function/samples/parameter-defaults/module-side-effects/other.js new file mode 100644 index 00000000000..2bded0cd154 --- /dev/null +++ b/test/function/samples/parameter-defaults/module-side-effects/other.js @@ -0,0 +1 @@ +export const foo = (a = 'fallback') => a; diff --git a/test/function/samples/parameter-defaults/objects/_config.js b/test/function/samples/parameter-defaults/objects/_config.js new file mode 100644 index 00000000000..72f3b276774 --- /dev/null +++ b/test/function/samples/parameter-defaults/objects/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'keeps parameter defaults for methods in objects' +}); diff --git a/test/function/samples/parameter-defaults/objects/main.js b/test/function/samples/parameter-defaults/objects/main.js new file mode 100644 index 00000000000..89e36b76572 --- /dev/null +++ b/test/function/samples/parameter-defaults/objects/main.js @@ -0,0 +1,11 @@ +const a = (foo = 'fallback a') => assert.strictEqual(foo, 'fallback a'); + +const obj = { + a, + b(foo = 'fallback b') { + assert.strictEqual(foo, 'fallback b'); + } +}; + +obj.a(); +obj.b(); diff --git a/test/function/samples/parameter-defaults/return-expressions/_config.js b/test/function/samples/parameter-defaults/return-expressions/_config.js new file mode 100644 index 00000000000..fe72312b818 --- /dev/null +++ b/test/function/samples/parameter-defaults/return-expressions/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'keeps parameter defaults for returned expressions' +}); diff --git a/test/function/samples/parameter-defaults/return-expressions/main.js b/test/function/samples/parameter-defaults/return-expressions/main.js new file mode 100644 index 00000000000..56100f30c07 --- /dev/null +++ b/test/function/samples/parameter-defaults/return-expressions/main.js @@ -0,0 +1,8 @@ +function foo() { + const bar = (options = 'fallback') => { + return options; + }; + return bar; +} + +assert.strictEqual(foo()(), 'fallback'); diff --git a/test/function/samples/parameter-defaults/super-classes/_config.js b/test/function/samples/parameter-defaults/super-classes/_config.js new file mode 100644 index 00000000000..e1df2f59e12 --- /dev/null +++ b/test/function/samples/parameter-defaults/super-classes/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'keeps parameter defaults for super classes' +}); diff --git a/test/function/samples/parameter-defaults/super-classes/main.js b/test/function/samples/parameter-defaults/super-classes/main.js new file mode 100644 index 00000000000..6e82e24b5ae --- /dev/null +++ b/test/function/samples/parameter-defaults/super-classes/main.js @@ -0,0 +1,43 @@ +class A { + constructor(a = 'superConstructorDefault') { + this.a = a; + } + + static staticMethod(b = 'superStaticDefault') { + return b; + } + + method(c = 'superMethodDefault') { + return c; + } +} + +class B extends A { + constructor(a = 'constructorDefault') { + assert.strictEqual(a, 'constructorDefault'); + super(); + } + + static staticMethod(b = 'staticDefault') { + assert.strictEqual(b, 'staticDefault'); + return super.staticMethod(); + } + + method(c = 'methodDefault') { + assert.strictEqual(c, 'methodDefault'); + return super.method(); + } +} + +assert.strictEqual(B.staticMethod(), 'superStaticDefault'); +const b = new B(); +assert.strictEqual(b.a, 'superConstructorDefault'); +assert.strictEqual(b.method(), 'superMethodDefault'); + +function SuperFunction(a = 'functionDefault') { + assert.strictEqual(a, 'functionDefault'); +} + +class C extends SuperFunction {} + +new C(); diff --git a/test/function/samples/parameter-defaults/tagged-templates/_config.js b/test/function/samples/parameter-defaults/tagged-templates/_config.js new file mode 100644 index 00000000000..200eeb118e2 --- /dev/null +++ b/test/function/samples/parameter-defaults/tagged-templates/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'includes necessary default parameters for tagged template literals' +}); diff --git a/test/function/samples/parameter-defaults/tagged-templates/main.js b/test/function/samples/parameter-defaults/tagged-templates/main.js new file mode 100644 index 00000000000..3c0a5f8bd8c --- /dev/null +++ b/test/function/samples/parameter-defaults/tagged-templates/main.js @@ -0,0 +1,6 @@ +const templateTag = ([, a = 'quasiFallback'], b = 'expressionFallback') => { + assert.strictEqual(a, 'quasiFallback'); + assert.strictEqual(b, 'expressionFallback'); +}; + +templateTag``; diff --git a/test/function/samples/parameter-defaults/try-catch/_config.js b/test/function/samples/parameter-defaults/try-catch/_config.js new file mode 100644 index 00000000000..7236445903a --- /dev/null +++ b/test/function/samples/parameter-defaults/try-catch/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'keeps parameter defaults when called from try-statement' +}); diff --git a/test/function/samples/parameter-defaults/try-catch/main.js b/test/function/samples/parameter-defaults/try-catch/main.js new file mode 100644 index 00000000000..f57e731eb4c --- /dev/null +++ b/test/function/samples/parameter-defaults/try-catch/main.js @@ -0,0 +1,9 @@ +const test = (a = 'fallback') => a; + +let returnValue; + +try { + returnValue = test(); +} catch {} + +assert.strictEqual(returnValue, 'fallback'); diff --git a/test/function/samples/parameter-side-effects/_config.js b/test/function/samples/parameter-side-effects/_config.js new file mode 100644 index 00000000000..c9f1ce0fecf --- /dev/null +++ b/test/function/samples/parameter-side-effects/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'retains calls with parameter side effects' +}); diff --git a/test/function/samples/parameter-side-effects/main.js b/test/function/samples/parameter-side-effects/main.js new file mode 100644 index 00000000000..1ab1f23b307 --- /dev/null +++ b/test/function/samples/parameter-side-effects/main.js @@ -0,0 +1,12 @@ +let effect = false; + +function getPatternValueWithEffect() { + effect = true; + return 'value'; +} + +function test({ [getPatternValueWithEffect()]: value }) {} + +test({ value: 'foo' }); + +assert.ok(effect); diff --git a/test/function/samples/parameters-promise-constructor/_config.js b/test/function/samples/parameters-promise-constructor/_config.js new file mode 100644 index 00000000000..735f6d348fc --- /dev/null +++ b/test/function/samples/parameters-promise-constructor/_config.js @@ -0,0 +1,8 @@ +const assert = require('assert'); + +module.exports = defineTest({ + description: 'correctly handles parameters of promise constructor', + async exports({ result }) { + assert.strictEqual(await result, 42); + } +}); diff --git a/test/function/samples/parameters-promise-constructor/main.js b/test/function/samples/parameters-promise-constructor/main.js new file mode 100644 index 00000000000..6e8a38ba805 --- /dev/null +++ b/test/function/samples/parameters-promise-constructor/main.js @@ -0,0 +1,12 @@ +const value = 42; + +export function test(callback) { + return callback ? execute(undefined, callback) : new Promise(execute); + + function execute(resolve) { + if (resolve) resolve(value); + else resolve('FAIL'); + } +} + +export const result = test().then(r => r); diff --git a/test/function/samples/parenthesised-default-export/_config.js b/test/function/samples/parenthesised-default-export/_config.js index 65de328c187..18f4cfef73e 100644 --- a/test/function/samples/parenthesised-default-export/_config.js +++ b/test/function/samples/parenthesised-default-export/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'allows default exports to be enclosed in parentheses' -}; +}); diff --git a/test/function/samples/parse-return-outside-function/_config.js b/test/function/samples/parse-return-outside-function/_config.js new file mode 100644 index 00000000000..2b969e1b86f --- /dev/null +++ b/test/function/samples/parse-return-outside-function/_config.js @@ -0,0 +1,58 @@ +const assert = require('node:assert'); +const { compareError } = require('../../../testHelpers'); + +module.exports = defineTest({ + description: 'supports parsing return statements outside functions via options', + options: { + plugins: [ + { + name: 'test', + buildStart() { + assert.deepStrictEqual( + this.parse('return foo', { + allowReturnOutsideFunction: true + }), + { + type: 'Program', + start: 0, + end: 10, + body: [ + { + type: 'ReturnStatement', + start: 0, + end: 10, + argument: { type: 'Identifier', start: 7, end: 10, name: 'foo' } + } + ], + sourceType: 'module' + } + ); + let expectedError = null; + try { + this.parse('return foo', { + allowReturnOutsideFunction: false + }); + } catch (error) { + expectedError = error; + } + compareError(expectedError, { + code: 'PARSE_ERROR', + message: 'Return statement is not allowed here', + pos: 0 + }); + expectedError = null; + try { + this.parse('return foo'); + } catch (error) { + expectedError = error; + } + compareError(expectedError, { + code: 'PARSE_ERROR', + message: 'Return statement is not allowed here', + pos: 0 + }); + } + } + ] + } +}); diff --git a/test/function/samples/parse-return-outside-function/main.js b/test/function/samples/parse-return-outside-function/main.js new file mode 100644 index 00000000000..69b8f8f7946 --- /dev/null +++ b/test/function/samples/parse-return-outside-function/main.js @@ -0,0 +1,13 @@ +let effect = false; + +var b = { + get a() { + effect = true; + } +}; + +function X() {} +X.prototype = b; +new X().a; + +assert.ok(effect); diff --git a/test/function/samples/pass-namespace-to-function/_config.js b/test/function/samples/pass-namespace-to-function/_config.js index d93fddb6e6b..6995cca2961 100644 --- a/test/function/samples/pass-namespace-to-function/_config.js +++ b/test/function/samples/pass-namespace-to-function/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'allows a namespace to be passed to a function' -}; +}); diff --git a/test/function/samples/paths-are-case-sensitive/_config.js b/test/function/samples/paths-are-case-sensitive/_config.js index b881cc3e830..f6943a314c4 100644 --- a/test/function/samples/paths-are-case-sensitive/_config.js +++ b/test/function/samples/paths-are-case-sensitive/_config.js @@ -1,10 +1,13 @@ -const path = require('path'); +const path = require('node:path'); +const ID_MAIN = path.join(__dirname, 'main.js'); -module.exports = { +module.exports = defineTest({ description: 'insists on correct casing for imports', error: { code: 'UNRESOLVED_IMPORT', - message: `Could not resolve './foo.js' from main.js`, - watchFiles: [path.join(__dirname, 'main.js')] + exporter: './foo.js', + id: ID_MAIN, + watchFiles: [ID_MAIN], + message: 'Could not resolve "./foo.js" from "main.js"' } -}; +}); diff --git a/test/function/samples/per-output-plugins-warn-hooks/_config.js b/test/function/samples/per-output-plugins-warn-hooks/_config.js index 446269bb422..7cbd090f18c 100644 --- a/test/function/samples/per-output-plugins-warn-hooks/_config.js +++ b/test/function/samples/per-output-plugins-warn-hooks/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'warns when input hooks are used in output plugins', options: { output: { @@ -74,4 +74,4 @@ module.exports = { 'The "buildStart" hook used by the output plugin at output position 2 is a build time hook and will not be run for that plugin. Either this plugin cannot be used as an output plugin, or it should have an option to configure it as an output plugin.' } ] -}; +}); diff --git a/test/function/samples/per-output-plugins-warn-hooks/_expected/amd.js b/test/function/samples/per-output-plugins-warn-hooks/_expected/amd.js deleted file mode 100644 index 1d43a8d4670..00000000000 --- a/test/function/samples/per-output-plugins-warn-hooks/_expected/amd.js +++ /dev/null @@ -1,5 +0,0 @@ -define(function () { 'use strict'; - - console.log('amd'); - -}); diff --git a/test/function/samples/per-output-plugins-warn-hooks/_expected/cjs.js b/test/function/samples/per-output-plugins-warn-hooks/_expected/cjs.js deleted file mode 100644 index ff37dabca27..00000000000 --- a/test/function/samples/per-output-plugins-warn-hooks/_expected/cjs.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -console.log('cjs'); diff --git a/test/function/samples/per-output-plugins-warn-hooks/_expected/es.js b/test/function/samples/per-output-plugins-warn-hooks/_expected/es.js deleted file mode 100644 index cbe9810363d..00000000000 --- a/test/function/samples/per-output-plugins-warn-hooks/_expected/es.js +++ /dev/null @@ -1 +0,0 @@ -console.log('es'); diff --git a/test/function/samples/per-output-plugins-warn-hooks/_expected/iife.js b/test/function/samples/per-output-plugins-warn-hooks/_expected/iife.js deleted file mode 100644 index b64ab69e189..00000000000 --- a/test/function/samples/per-output-plugins-warn-hooks/_expected/iife.js +++ /dev/null @@ -1,6 +0,0 @@ -(function () { - 'use strict'; - - console.log('iife'); - -}()); diff --git a/test/function/samples/per-output-plugins-warn-hooks/_expected/system.js b/test/function/samples/per-output-plugins-warn-hooks/_expected/system.js deleted file mode 100644 index 9cd89c4c3a0..00000000000 --- a/test/function/samples/per-output-plugins-warn-hooks/_expected/system.js +++ /dev/null @@ -1,10 +0,0 @@ -System.register([], function () { - 'use strict'; - return { - execute: function () { - - console.log('system'); - - } - }; -}); diff --git a/test/function/samples/per-output-plugins-warn-hooks/_expected/umd.js b/test/function/samples/per-output-plugins-warn-hooks/_expected/umd.js deleted file mode 100644 index cece26c2f48..00000000000 --- a/test/function/samples/per-output-plugins-warn-hooks/_expected/umd.js +++ /dev/null @@ -1,8 +0,0 @@ -(function (factory) { - typeof define === 'function' && define.amd ? define(factory) : - factory(); -}((function () { 'use strict'; - - console.log('umd'); - -}))); diff --git a/test/function/samples/perf-adds-plugin-context-to-plugins/_config.js b/test/function/samples/perf-adds-plugin-context-to-plugins/_config.js new file mode 100644 index 00000000000..677d299eae7 --- /dev/null +++ b/test/function/samples/perf-adds-plugin-context-to-plugins/_config.js @@ -0,0 +1,27 @@ +const assert = require('node:assert'); + +module.exports = defineTest({ + description: 'Adds plugin context to plugins with perf=true', + options: { + perf: true, + plugins: [ + { + load() { + assert.ok(typeof this.parse === 'function'); + }, + + resolveDynamicImport() { + assert.ok(typeof this.parse === 'function'); + }, + + resolveId() { + assert.ok(typeof this.parse === 'function'); + }, + + transform() { + assert.ok(typeof this.parse === 'function'); + } + } + ] + } +}); diff --git a/test/function/samples/perf-adds-plugin-context-to-plugins/foo.js b/test/function/samples/perf-adds-plugin-context-to-plugins/foo.js new file mode 100644 index 00000000000..aaadd073c11 --- /dev/null +++ b/test/function/samples/perf-adds-plugin-context-to-plugins/foo.js @@ -0,0 +1,3 @@ +export default 'foo'; + +console.log('side-effect'); diff --git a/test/function/samples/perf-adds-plugin-context-to-plugins/main.js b/test/function/samples/perf-adds-plugin-context-to-plugins/main.js new file mode 100644 index 00000000000..92c66c7eb7c --- /dev/null +++ b/test/function/samples/perf-adds-plugin-context-to-plugins/main.js @@ -0,0 +1 @@ +import('./foo'); diff --git a/test/function/samples/perf-supports-object-hooks/_config.js b/test/function/samples/perf-supports-object-hooks/_config.js new file mode 100644 index 00000000000..47523617555 --- /dev/null +++ b/test/function/samples/perf-supports-object-hooks/_config.js @@ -0,0 +1,16 @@ +module.exports = defineTest({ + description: 'Supports object hooks with perf=true', + options: { + perf: true, + plugins: [ + { + transform: { + order: 'pre', + handler(code) { + return code.replace('FOO', 'BAR'); + } + } + } + ] + } +}); diff --git a/test/function/samples/perf-supports-object-hooks/main.js b/test/function/samples/perf-supports-object-hooks/main.js new file mode 100644 index 00000000000..b52321a9995 --- /dev/null +++ b/test/function/samples/perf-supports-object-hooks/main.js @@ -0,0 +1 @@ +assert.strictEqual('FOO', 'BAR'); diff --git a/test/function/samples/plugin-cache/anonymous-delete/_config.js b/test/function/samples/plugin-cache/anonymous-delete/_config.js index 8d9a9ef6e1a..c75a26f99a3 100644 --- a/test/function/samples/plugin-cache/anonymous-delete/_config.js +++ b/test/function/samples/plugin-cache/anonymous-delete/_config.js @@ -1,11 +1,13 @@ -module.exports = { +module.exports = defineTest({ description: 'throws for anonymous plugins deleting from the cache', options: { - plugins: { - buildStart() { - this.cache.delete('asdf'); + plugins: [ + { + buildStart() { + this.cache.delete('asdf'); + } } - } + ] }, error: { code: 'PLUGIN_ERROR', @@ -15,4 +17,4 @@ module.exports = { plugin: 'at position 1', pluginCode: 'ANONYMOUS_PLUGIN_CACHE' } -}; +}); diff --git a/test/function/samples/plugin-cache/anonymous-get/_config.js b/test/function/samples/plugin-cache/anonymous-get/_config.js index 9a25655aa12..462bb41ae69 100644 --- a/test/function/samples/plugin-cache/anonymous-get/_config.js +++ b/test/function/samples/plugin-cache/anonymous-get/_config.js @@ -1,11 +1,13 @@ -module.exports = { +module.exports = defineTest({ description: 'throws for anonymous plugins reading the cache', options: { - plugins: { - buildStart() { - this.cache.get('asdf'); + plugins: [ + { + buildStart() { + this.cache.get('asdf'); + } } - } + ] }, error: { code: 'PLUGIN_ERROR', @@ -15,4 +17,4 @@ module.exports = { plugin: 'at position 1', pluginCode: 'ANONYMOUS_PLUGIN_CACHE' } -}; +}); diff --git a/test/function/samples/plugin-cache/anonymous-has/_config.js b/test/function/samples/plugin-cache/anonymous-has/_config.js index f6d37f0485e..1822b951a36 100644 --- a/test/function/samples/plugin-cache/anonymous-has/_config.js +++ b/test/function/samples/plugin-cache/anonymous-has/_config.js @@ -1,11 +1,13 @@ -module.exports = { +module.exports = defineTest({ description: 'throws for anonymous plugins checking the cache', options: { - plugins: { - buildStart() { - this.cache.has('asdf'); + plugins: [ + { + buildStart() { + this.cache.has('asdf'); + } } - } + ] }, error: { code: 'PLUGIN_ERROR', @@ -15,4 +17,4 @@ module.exports = { plugin: 'at position 1', pluginCode: 'ANONYMOUS_PLUGIN_CACHE' } -}; +}); diff --git a/test/function/samples/plugin-cache/anonymous-set/_config.js b/test/function/samples/plugin-cache/anonymous-set/_config.js index c12e533586c..8aee27bf008 100644 --- a/test/function/samples/plugin-cache/anonymous-set/_config.js +++ b/test/function/samples/plugin-cache/anonymous-set/_config.js @@ -1,11 +1,13 @@ -module.exports = { +module.exports = defineTest({ description: 'throws for anonymous plugins adding to the cache', options: { - plugins: { - buildStart() { - this.cache.set('asdf', 'asdf'); + plugins: [ + { + buildStart() { + this.cache.set('asdf', 'asdf'); + } } - } + ] }, error: { code: 'PLUGIN_ERROR', @@ -15,4 +17,4 @@ module.exports = { plugin: 'at position 1', pluginCode: 'ANONYMOUS_PLUGIN_CACHE' } -}; +}); diff --git a/test/function/samples/plugin-cache/duplicate-names-no-cache/_config.js b/test/function/samples/plugin-cache/duplicate-names-no-cache/_config.js index 5acf2e8b233..eb95b812345 100644 --- a/test/function/samples/plugin-cache/duplicate-names-no-cache/_config.js +++ b/test/function/samples/plugin-cache/duplicate-names-no-cache/_config.js @@ -1,15 +1,19 @@ -module.exports = { +module.exports = defineTest({ description: 'allows plugins to have the same name if they do not access the cache', options: { plugins: [ { name: 'test-plugin', - buildStart() {} + buildStart() { + return null; + } }, { name: 'test-plugin', - buildStart() {} + buildStart() { + return null; + } } ] } -}; +}); diff --git a/test/function/samples/plugin-cache/duplicate-names/_config.js b/test/function/samples/plugin-cache/duplicate-names/_config.js index bf9f5a7af39..3a12be306c3 100644 --- a/test/function/samples/plugin-cache/duplicate-names/_config.js +++ b/test/function/samples/plugin-cache/duplicate-names/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'throws if two plugins with the same name and no cache key access the cache', options: { plugins: [ @@ -24,4 +24,4 @@ module.exports = { plugin: 'test-plugin', pluginCode: 'DUPLICATE_PLUGIN_NAME' } -}; +}); diff --git a/test/function/samples/plugin-error-loc-instead-pos/_config.js b/test/function/samples/plugin-error-loc-instead-pos/_config.js index b203d1e5b99..dca00e4a3e4 100644 --- a/test/function/samples/plugin-error-loc-instead-pos/_config.js +++ b/test/function/samples/plugin-error-loc-instead-pos/_config.js @@ -1,12 +1,12 @@ -const path = require('path'); +const path = require('node:path'); -module.exports = { +module.exports = defineTest({ description: '`this.error(...)` accepts { line, column } object as second parameter (#1265)', options: { plugins: [ { name: 'test', - transform(code, id) { + transform() { this.error('nope', { line: 1, column: 22 }); } } @@ -15,7 +15,7 @@ module.exports = { error: { code: 'PLUGIN_ERROR', plugin: 'test', - message: 'nope', + message: '[plugin test] main.js (1:22): nope', hook: 'transform', id: path.join(__dirname, 'main.js'), watchFiles: [path.join(__dirname, 'main.js')], @@ -29,4 +29,4 @@ module.exports = { ^ ` } -}; +}); diff --git a/test/function/samples/plugin-error-module-parsed/_config.js b/test/function/samples/plugin-error-module-parsed/_config.js new file mode 100644 index 00000000000..53a0e53fd8d --- /dev/null +++ b/test/function/samples/plugin-error-module-parsed/_config.js @@ -0,0 +1,22 @@ +const path = require('node:path'); + +module.exports = defineTest({ + description: 'errors in moduleParsed abort the build', + options: { + plugins: [ + { + name: 'testPlugin', + moduleParsed() { + throw new Error('broken'); + } + } + ] + }, + error: { + code: 'PLUGIN_ERROR', + hook: 'moduleParsed', + message: 'broken', + plugin: 'testPlugin', + watchFiles: [path.join(__dirname, 'main.js')] + } +}); diff --git a/test/function/samples/plugin-error-module-parsed/main.js b/test/function/samples/plugin-error-module-parsed/main.js new file mode 100644 index 00000000000..69b8f8f7946 --- /dev/null +++ b/test/function/samples/plugin-error-module-parsed/main.js @@ -0,0 +1,13 @@ +let effect = false; + +var b = { + get a() { + effect = true; + } +}; + +function X() {} +X.prototype = b; +new X().a; + +assert.ok(effect); diff --git a/test/function/samples/plugin-error-only-first-render-chunk/_config.js b/test/function/samples/plugin-error-only-first-render-chunk/_config.js index 98dc260c688..0e328c029c0 100644 --- a/test/function/samples/plugin-error-only-first-render-chunk/_config.js +++ b/test/function/samples/plugin-error-only-first-render-chunk/_config.js @@ -1,17 +1,17 @@ -module.exports = { +module.exports = defineTest({ description: 'throws error only with first plugin renderChunk', options: { plugins: [ { name: 'plugin1', renderChunk() { - throw Error('Something happened 1'); + throw new Error('Something happened 1'); } }, { name: 'plugin2', renderChunk() { - throw Error('Something happened 2'); + throw new Error('Something happened 2'); } } ] @@ -22,4 +22,4 @@ module.exports = { hook: 'renderChunk', message: `Something happened 1` } -}; +}); diff --git a/test/function/samples/plugin-error-only-first-transform/_config.js b/test/function/samples/plugin-error-only-first-transform/_config.js index 174c3cb760d..f36043808d1 100644 --- a/test/function/samples/plugin-error-only-first-transform/_config.js +++ b/test/function/samples/plugin-error-only-first-transform/_config.js @@ -1,19 +1,19 @@ -const path = require('path'); +const path = require('node:path'); -module.exports = { +module.exports = defineTest({ description: 'throws error only with first plugin transform', options: { plugins: [ { name: 'plugin1', transform() { - throw Error('Something happened 1'); + throw new Error('Something happened 1'); } }, { name: 'plugin2', transform() { - throw Error('Something happened 2'); + throw new Error('Something happened 2'); } } ] @@ -26,4 +26,4 @@ module.exports = { id: path.join(__dirname, 'main.js'), watchFiles: [path.join(__dirname, 'main.js')] } -}; +}); diff --git a/test/function/samples/plugin-error-should-transform/_config.js b/test/function/samples/plugin-error-should-transform/_config.js new file mode 100644 index 00000000000..a7417a9b78c --- /dev/null +++ b/test/function/samples/plugin-error-should-transform/_config.js @@ -0,0 +1,44 @@ +const path = require('node:path'); +const acorn = require('acorn'); + +const code = 'export default 42;\n'; +const ID_MAIN = path.join(__dirname, 'main.js'); + +module.exports = defineTest({ + description: 'errors in shouldTransformCachedModule abort the build', + options: { + cache: { + modules: [ + { + id: ID_MAIN, + ast: acorn.parse(code, { + ecmaVersion: 6, + sourceType: 'module' + }), + code, + dependencies: [], + dynamicDependencies: [], + originalCode: code, + resolvedIds: {}, + sourcemapChain: [], + transformDependencies: [] + } + ] + }, + plugins: [ + { + name: 'test', + shouldTransformCachedModule() { + throw new Error('broken'); + } + } + ] + }, + error: { + code: 'PLUGIN_ERROR', + hook: 'shouldTransformCachedModule', + message: 'broken', + plugin: 'test', + watchFiles: [ID_MAIN] + } +}); diff --git a/test/function/samples/plugin-error-should-transform/main.js b/test/function/samples/plugin-error-should-transform/main.js new file mode 100644 index 00000000000..7a4e8a723a4 --- /dev/null +++ b/test/function/samples/plugin-error-should-transform/main.js @@ -0,0 +1 @@ +export default 42; diff --git a/test/function/samples/plugin-error-transform-pos/_config.js b/test/function/samples/plugin-error-transform-pos/_config.js new file mode 100644 index 00000000000..cd1f3a69810 --- /dev/null +++ b/test/function/samples/plugin-error-transform-pos/_config.js @@ -0,0 +1,39 @@ +const path = require('node:path'); +const ID_MAIN = path.join(__dirname, 'main.js'); + +module.exports = defineTest({ + description: '`this.error(...)` accepts number as second parameter (#5044)', + options: { + plugins: [ + { + name: 'plugin1', + transform(code) { + return code + 'bar'; + } + }, + { + name: 'plugin2', + transform() { + this.error(new Error('error'), 26); + } + } + ] + }, + error: { + code: 'PLUGIN_ERROR', + message: 'error', + plugin: 'plugin2', + hook: 'transform', + id: ID_MAIN, + watchFiles: [ID_MAIN], + frame: ` + 1: export const foo = 'foo'bar + ^`, + loc: { + column: 26, + file: ID_MAIN, + line: 1 + }, + pos: 26 + } +}); diff --git a/test/function/samples/plugin-error-transform-pos/main.js b/test/function/samples/plugin-error-transform-pos/main.js new file mode 100644 index 00000000000..ff499a60ea7 --- /dev/null +++ b/test/function/samples/plugin-error-transform-pos/main.js @@ -0,0 +1 @@ +export const foo = 'foo' \ No newline at end of file diff --git a/test/function/samples/plugin-error-with-numeric-code/_config.js b/test/function/samples/plugin-error-with-numeric-code/_config.js new file mode 100644 index 00000000000..8c7acd53cf4 --- /dev/null +++ b/test/function/samples/plugin-error-with-numeric-code/_config.js @@ -0,0 +1,26 @@ +const path = require('node:path'); + +module.exports = defineTest({ + description: 'rollup do not break if get a plugin error that contains numeric code', + options: { + plugins: [ + { + name: 'test', + transform() { + const error = new Error('test message'); + error.code = 100; + throw error; + } + } + ] + }, + error: { + code: 'PLUGIN_ERROR', + hook: 'transform', + id: path.join(__dirname, 'main.js'), + message: 'test message', + plugin: 'test', + pluginCode: 100, + watchFiles: [path.join(__dirname, 'main.js')] + } +}); diff --git a/test/function/samples/plugin-error-with-numeric-code/main.js b/test/function/samples/plugin-error-with-numeric-code/main.js new file mode 100644 index 00000000000..cc1d88a24fa --- /dev/null +++ b/test/function/samples/plugin-error-with-numeric-code/main.js @@ -0,0 +1 @@ +assert.ok(true); diff --git a/test/function/samples/plugin-error/buildEnd/_config.js b/test/function/samples/plugin-error/buildEnd/_config.js index 0f3c27d4143..aa462c719df 100644 --- a/test/function/samples/plugin-error/buildEnd/_config.js +++ b/test/function/samples/plugin-error/buildEnd/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'buildStart hooks can use this.error', options: { plugins: [ @@ -13,7 +13,7 @@ module.exports = { error: { code: 'PLUGIN_ERROR', plugin: 'test', - message: 'nope', + message: '[plugin test] nope', hook: 'buildEnd' } -}; +}); diff --git a/test/function/samples/plugin-error/buildStart/_config.js b/test/function/samples/plugin-error/buildStart/_config.js index 47657147100..fcc14543b60 100644 --- a/test/function/samples/plugin-error/buildStart/_config.js +++ b/test/function/samples/plugin-error/buildStart/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'buildStart hooks can use this.error', options: { plugins: [ @@ -13,7 +13,7 @@ module.exports = { error: { code: 'PLUGIN_ERROR', plugin: 'test', - message: 'nope', + message: '[plugin test] nope', hook: 'buildStart' } -}; +}); diff --git a/test/function/samples/plugin-error/generateBundle/_config.js b/test/function/samples/plugin-error/generateBundle/_config.js index 27ca00e7e9d..73180d5547f 100644 --- a/test/function/samples/plugin-error/generateBundle/_config.js +++ b/test/function/samples/plugin-error/generateBundle/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'buildStart hooks can use this.error', options: { plugins: [ @@ -13,7 +13,7 @@ module.exports = { generateError: { code: 'PLUGIN_ERROR', plugin: 'test', - message: 'nope', + message: '[plugin test] nope', hook: 'generateBundle' } -}; +}); diff --git a/test/function/samples/plugin-error/load/_config.js b/test/function/samples/plugin-error/load/_config.js index b4748a39161..5b25cb5d1cf 100644 --- a/test/function/samples/plugin-error/load/_config.js +++ b/test/function/samples/plugin-error/load/_config.js @@ -1,6 +1,6 @@ -const path = require('path'); +const path = require('node:path'); -module.exports = { +module.exports = defineTest({ description: 'buildStart hooks can use this.error', options: { plugins: [ @@ -15,8 +15,7 @@ module.exports = { error: { code: 'PLUGIN_ERROR', plugin: 'test', - message: `Could not load ${path.join(__dirname, 'main.js')}: nope`, - hook: 'load', - watchFiles: [path.join(__dirname, 'main.js')] + message: `Could not load ${path.join(__dirname, 'main.js')}: [plugin test] nope`, + hook: 'load' } -}; +}); diff --git a/test/function/samples/plugin-error/renderChunk/_config.js b/test/function/samples/plugin-error/renderChunk/_config.js index 3cf2fb6ad5c..31670e2317a 100644 --- a/test/function/samples/plugin-error/renderChunk/_config.js +++ b/test/function/samples/plugin-error/renderChunk/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'buildStart hooks can use this.error', options: { plugins: [ @@ -13,7 +13,7 @@ module.exports = { generateError: { code: 'PLUGIN_ERROR', plugin: 'test', - message: 'nope', + message: '[plugin test] nope', hook: 'renderChunk' } -}; +}); diff --git a/test/function/samples/plugin-error/renderStart/_config.js b/test/function/samples/plugin-error/renderStart/_config.js index 5c7f9551f4f..35f6ed4ea47 100644 --- a/test/function/samples/plugin-error/renderStart/_config.js +++ b/test/function/samples/plugin-error/renderStart/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'buildStart hooks can use this.error', options: { plugins: [ @@ -13,7 +13,7 @@ module.exports = { generateError: { code: 'PLUGIN_ERROR', plugin: 'test', - message: 'nope', + message: '[plugin test] nope', hook: 'renderStart' } -}; +}); diff --git a/test/function/samples/plugin-error/resolveId/_config.js b/test/function/samples/plugin-error/resolveId/_config.js index 640b704e011..7c85f429f58 100644 --- a/test/function/samples/plugin-error/resolveId/_config.js +++ b/test/function/samples/plugin-error/resolveId/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'buildStart hooks can use this.error', options: { plugins: [ @@ -13,7 +13,7 @@ module.exports = { error: { code: 'PLUGIN_ERROR', plugin: 'test', - message: 'nope', + message: '[plugin test] nope', hook: 'resolveId' } -}; +}); diff --git a/test/function/samples/plugin-error/transform/_config.js b/test/function/samples/plugin-error/transform/_config.js index 582fd5ee4f2..f31ea7dc464 100644 --- a/test/function/samples/plugin-error/transform/_config.js +++ b/test/function/samples/plugin-error/transform/_config.js @@ -1,6 +1,6 @@ -const path = require('path'); +const path = require('node:path'); -module.exports = { +module.exports = defineTest({ description: 'plugin transform hooks can use `this.error({...}, char)` (#1140)', options: { plugins: [ @@ -15,7 +15,7 @@ module.exports = { error: { code: 'PLUGIN_ERROR', plugin: 'test', - message: 'nope', + message: '[plugin test] main.js (1:22): nope', hook: 'transform', id: path.join(__dirname, 'main.js'), watchFiles: [path.join(__dirname, 'main.js')], @@ -30,4 +30,4 @@ module.exports = { ^ ` } -}; +}); diff --git a/test/function/samples/plugin-hook-filters/_config.js b/test/function/samples/plugin-hook-filters/_config.js new file mode 100644 index 00000000000..d31f42f7622 --- /dev/null +++ b/test/function/samples/plugin-hook-filters/_config.js @@ -0,0 +1,162 @@ +const assert = require('assert'); +const util = require('util'); +const path = require('path'); + +const idFilterHooks = ['resolveId', 'load']; +const hooks = [...idFilterHooks, 'transform']; + +const calledHooks = {}; +for (const hook of hooks) { + calledHooks[hook] = {}; +} + +const expectedCalledHooks = { + resolveId: { + './bar.js': ['resolveId-{}', 'resolveId-{ id: { exclude: /foo\\.js$/ } }'], + './baz.js': ['resolveId-{}', 'resolveId-{ id: { exclude: /foo\\.js$/ } }'], + './foo.js': ['resolveId-{}', 'resolveId-{ id: /foo\\.js$/ }'] + }, + load: { + 'bar.js': [ + 'load-{}', + 'load-{ id: {} }', + "load-{ id: { include: '**/*.js' } }", + 'load-{ id: { include: /\\.js$/ } }', + "load-{ id: { exclude: '**/foo.js' } }", + "load-{ id: { include: '**/*.js', exclude: '**/foo.*' } }" + ], + 'baz.js': [ + 'load-{}', + 'load-{ id: {} }', + "load-{ id: { include: '**/*.js' } }", + 'load-{ id: { include: /\\.js$/ } }', + "load-{ id: { exclude: '**/foo.js' } }", + "load-{ id: { include: '**/*.js', exclude: '**/foo.*' } }" + ], + 'foo.js': [ + 'load-{}', + 'load-{ id: {} }', + "load-{ id: 'foo.js' }", + "load-{ id: '**/foo.js' }", + "load-{ id: [ '**/foo.js' ] }", + "load-{ id: { include: '**/*.js' } }", + 'load-{ id: { include: /\\.js$/ } }', + "load-{ id: { exclude: '**/ba*.js' } }", + 'load-{ id: { exclude: /ba.*\\.js$/ } }', + 'load-{ id: { exclude: [ /ba.*\\.js$/ ] } }', + "load-{ id: { include: '**/foo.js', exclude: '**/bar.js' } }" + ] + }, + transform: { + 'bar.js': [ + 'transform-{}', + "transform-{ id: { exclude: '**/foo.js' } }", + "transform-{ code: { exclude: 'import.meta.a' } }", + 'transform-{ code: { exclude: /import\\.\\w+\\.a/ } }', + 'transform-{ code: { exclude: [ /import\\.\\w+\\.a/ ] } }', + 'transform-{ code: { include: /import\\.meta\\.\\w+/, exclude: /import\\.\\w+\\.a/ } }' + ], + 'baz.js': [ + 'transform-{}', + "transform-{ id: { exclude: '**/foo.js' } }", + "transform-{ code: 'import.meta.a' }", + "transform-{ code: [ 'import.meta.a' ] }", + "transform-{ code: { include: 'import.meta.a' } }", + 'transform-{ code: { include: /import\\.\\w+\\.a/ } }', + 'transform-{ code: { include: [ /import\\.\\w+\\.a/ ] } }', + "transform-{ code: { include: 'import.meta.a', exclude: 'import.meta.b' } }" + ], + 'foo.js': [ + 'transform-{}', + "transform-{ id: '**/foo.js' }", + "transform-{ code: 'import.meta.a' }", + "transform-{ code: [ 'import.meta.a' ] }", + "transform-{ code: { include: 'import.meta.a' } }", + 'transform-{ code: { include: /import\\.\\w+\\.a/ } }', + 'transform-{ code: { include: [ /import\\.\\w+\\.a/ ] } }', + "transform-{ code: { include: 'import.meta.a', exclude: 'import.meta.b' } }", + "transform-{ id: { exclude: '**/ba*.js' }, code: 'import.meta.a' }", + "transform-{\n id: { include: '**/foo.js', exclude: '**/ba*.js' },\n code: 'import.meta.a'\n}" + ] + } +}; + +const plugins = []; +addPlugin('resolveId', {}); +addPlugin('resolveId', { id: /foo\.js$/ }); +addPlugin('resolveId', { id: { exclude: /foo\.js$/ } }); +addPlugin('load', {}); +addPlugin('load', { id: {} }); +addPlugin('load', { id: 'foo.js' }); +addPlugin('load', { id: '**/foo.js' }); +addPlugin('load', { id: ['**/foo.js'] }); +addPlugin('load', { id: { include: '**/*.js' } }); +addPlugin('load', { id: { include: /\.js$/ } }); +addPlugin('load', { id: { exclude: '**/foo.js' } }); +addPlugin('load', { id: { exclude: '**/ba*.js' } }); +addPlugin('load', { id: { exclude: /ba.*\.js$/ } }); +addPlugin('load', { id: { exclude: [/ba.*\.js$/] } }); +addPlugin('load', { id: { include: '**/foo.js', exclude: '**/bar.js' } }); +// exclude has higher priority so it does not match foo.js +addPlugin('load', { id: { include: '**/*.js', exclude: '**/foo.*' } }); +addPlugin('transform', {}); +addPlugin('transform', { id: '**/foo.js' }); +addPlugin('transform', { id: { exclude: '**/foo.js' } }); +addPlugin('transform', { code: 'import.meta.a' }); +addPlugin('transform', { code: ['import.meta.a'] }); +addPlugin('transform', { code: { include: 'import.meta.a' } }); +addPlugin('transform', { code: { include: /import\.\w+\.a/ } }); +addPlugin('transform', { code: { include: [/import\.\w+\.a/] } }); +addPlugin('transform', { code: { exclude: 'import.meta.a' } }); +addPlugin('transform', { code: { exclude: /import\.\w+\.a/ } }); +addPlugin('transform', { code: { exclude: [/import\.\w+\.a/] } }); +addPlugin('transform', { code: { include: 'import.meta.a', exclude: 'import.meta.b' } }); +// exclude has higher priority so it does not match import.meta.a +addPlugin('transform', { code: { include: /import\.meta\.\w+/, exclude: /import\.\w+\.a/ } }); +addPlugin('transform', { id: { exclude: '**/ba*.js' }, code: 'import.meta.a' }); +addPlugin('transform', { + id: { include: '**/foo.js', exclude: '**/ba*.js' }, + code: 'import.meta.a' +}); + +function addPlugin(hook, filter) { + const name = `${hook}-${util.inspect(filter)}`; + const plugin = { + name, + [hook]: { + filter, + handler(idOrCodeArgument, idArgument) { + let id = hook === 'transform' ? idArgument : idOrCodeArgument; + if (id.includes('main.js')) { + return; + } + id = path.isAbsolute(id) ? path.relative(__dirname, id) : id; + + calledHooks[hook][id] ??= []; + if (!calledHooks[hook][id].includes(name)) { + calledHooks[hook][id].push(name); + } + } + } + }; + plugins.push(plugin); +} + +module.exports = { + description: 'plugin hook filter is supported', + options: { + plugins + }, + exports() { + for (const hook of hooks) { + assert.deepStrictEqual(calledHooks[hook], expectedCalledHooks[hook], hook); + } + }, + warnings: [ + { + code: 'EMPTY_BUNDLE', + message: 'Generated an empty chunk: "main".', + names: ['main'] + } + ] +}; diff --git a/test/function/samples/plugin-hook-filters/bar.js b/test/function/samples/plugin-hook-filters/bar.js new file mode 100644 index 00000000000..a3aeb94b557 --- /dev/null +++ b/test/function/samples/plugin-hook-filters/bar.js @@ -0,0 +1 @@ +import.meta.b diff --git a/test/function/samples/plugin-hook-filters/baz.js b/test/function/samples/plugin-hook-filters/baz.js new file mode 100644 index 00000000000..c740e421c3a --- /dev/null +++ b/test/function/samples/plugin-hook-filters/baz.js @@ -0,0 +1 @@ +import.meta.a diff --git a/test/function/samples/plugin-hook-filters/foo.js b/test/function/samples/plugin-hook-filters/foo.js new file mode 100644 index 00000000000..c740e421c3a --- /dev/null +++ b/test/function/samples/plugin-hook-filters/foo.js @@ -0,0 +1 @@ +import.meta.a diff --git a/test/function/samples/plugin-hook-filters/main.js b/test/function/samples/plugin-hook-filters/main.js new file mode 100644 index 00000000000..0b6e7423afa --- /dev/null +++ b/test/function/samples/plugin-hook-filters/main.js @@ -0,0 +1,3 @@ +import './foo.js' +import './bar.js' +import './baz.js' diff --git a/test/function/samples/plugin-module-information-early-access/_config.js b/test/function/samples/plugin-module-information-early-access/_config.js index 5655d108ed1..16e1e96e0cc 100644 --- a/test/function/samples/plugin-module-information-early-access/_config.js +++ b/test/function/samples/plugin-module-information-early-access/_config.js @@ -1,19 +1,19 @@ -const assert = require('assert'); -const path = require('path'); +const assert = require('node:assert'); +const path = require('node:path'); const ID_MAIN = path.join(__dirname, 'main.js'); -module.exports = { +module.exports = defineTest({ description: 'handles accessing module information via plugins early in a graceful way', options: { external: ['path'], plugins: [ { buildStart() { - assert.deepStrictEqual(Array.from(this.getModuleIds()), []); + assert.deepStrictEqual([...this.getModuleIds()], []); assert.strictEqual(this.getModuleInfo(ID_MAIN), null); } } ] } -}; +}); diff --git a/test/function/samples/plugin-module-information-no-cache/_config.js b/test/function/samples/plugin-module-information-no-cache/_config.js new file mode 100644 index 00000000000..4cfc0906ef8 --- /dev/null +++ b/test/function/samples/plugin-module-information-no-cache/_config.js @@ -0,0 +1,66 @@ +const assert = require('node:assert'); +const path = require('node:path'); + +const ID_MAIN = path.join(__dirname, 'main.js'); + +module.exports = defineTest({ + description: 'handles accessing module information via plugins with cache disabled', + options: { + cache: false, + plugins: [ + { + renderStart() { + const info = this.getModuleInfo(ID_MAIN); + const ast = { + type: 'Program', + start: 0, + end: 19, + body: [ + { + type: 'ExportDefaultDeclaration', + start: 0, + end: 18, + declaration: { + type: 'Literal', + start: 15, + end: 17, + value: 42, + raw: '42' + } + } + ], + sourceType: 'module' + }; + assert.deepStrictEqual(JSON.parse(JSON.stringify(info)), { + attributes: {}, + ast, + code: 'export default 42;\n', + dynamicallyImportedIdResolutions: [], + dynamicallyImportedIds: [], + dynamicImporters: [], + exportedBindings: { + '.': ['default'] + }, + exports: ['default'], + hasDefaultExport: true, + id: ID_MAIN, + implicitlyLoadedAfterOneOf: [], + implicitlyLoadedBefore: [], + importedIdResolutions: [], + importedIds: [], + importers: [], + isEntry: true, + isExternal: false, + isIncluded: true, + meta: {}, + moduleSideEffects: true, + safeVariableNames: null, + syntheticNamedExports: false + }); + // Call AST again to ensure line coverage for cached getter + assert.deepStrictEqual(JSON.parse(JSON.stringify(info.ast)), ast); + } + } + ] + } +}); diff --git a/test/function/samples/plugin-module-information-no-cache/main.js b/test/function/samples/plugin-module-information-no-cache/main.js new file mode 100644 index 00000000000..7a4e8a723a4 --- /dev/null +++ b/test/function/samples/plugin-module-information-no-cache/main.js @@ -0,0 +1 @@ +export default 42; diff --git a/test/function/samples/plugin-module-information/_config.js b/test/function/samples/plugin-module-information/_config.js index a36ae8a13af..6a5a030d1c4 100644 --- a/test/function/samples/plugin-module-information/_config.js +++ b/test/function/samples/plugin-module-information/_config.js @@ -1,5 +1,6 @@ -const assert = require('assert'); -const path = require('path'); +const assert = require('node:assert'); +const path = require('node:path'); +const { getObject } = require('../../../testHelpers'); const ID_MAIN = path.join(__dirname, 'main.js'); const ID_FOO = path.join(__dirname, 'foo.js'); @@ -8,349 +9,464 @@ const ID_PATH = 'path'; let rendered = false; -module.exports = { +module.exports = defineTest({ description: 'provides module information on the plugin context', options: { external: ['path'], - plugins: { - load(id) { - assert.deepStrictEqual(this.getModuleInfo(id), { - ast: null, - code: null, - dynamicImporters: [], - dynamicallyImportedIds: [], - hasModuleSideEffects: true, - id, - implicitlyLoadedAfterOneOf: [], - implicitlyLoadedBefore: [], - importedIds: [], - importers: [], - isEntry: id === ID_MAIN, - isExternal: false, - meta: {}, - syntheticNamedExports: false - }); - }, - renderStart() { - rendered = true; - assert.deepStrictEqual([...this.getModuleIds()], [ID_MAIN, ID_FOO, ID_PATH, ID_NESTED]); - assert.deepStrictEqual( - JSON.parse(JSON.stringify([...this.getModuleIds()].map(id => this.getModuleInfo(id)))), - [ + plugins: [ + { + load(id) { + assert.deepStrictEqual(JSON.parse(JSON.stringify(this.getModuleInfo(id))), { + attributes: {}, + ast: null, + code: null, + dynamicImporters: [], + exportedBindings: { + '.': [] + }, + exports: [], + hasDefaultExport: null, + dynamicallyImportedIdResolutions: [], + dynamicallyImportedIds: [], + moduleSideEffects: true, + id, + implicitlyLoadedAfterOneOf: [], + implicitlyLoadedBefore: [], + importedIdResolutions: [], + importedIds: [], + importers: [], + isEntry: id === ID_MAIN, + isExternal: false, + isIncluded: null, + meta: {}, + safeVariableNames: null, + syntheticNamedExports: false + }); + }, + renderStart() { + rendered = true; + assert.deepStrictEqual( + getObject( + [...this.getModuleIds()].map(id => [ + id, + JSON.parse(JSON.stringify(this.getModuleInfo(id))) + ]) + ), { - ast: { - type: 'Program', - start: 0, - end: 159, - body: [ - { - type: 'ExportNamedDeclaration', - start: 0, - end: 31, - declaration: null, - specifiers: [ - { - type: 'ExportSpecifier', - start: 9, - end: 12, - local: { type: 'Identifier', start: 9, end: 12, name: 'foo' }, - exported: { type: 'Identifier', start: 9, end: 12, name: 'foo' } - } - ], - source: { - type: 'Literal', - start: 20, - end: 30, - value: './foo.js', - raw: "'./foo.js'" + [ID_FOO]: { + id: ID_FOO, + attributes: {}, + ast: { + type: 'Program', + start: 0, + end: 66, + body: [ + { + type: 'ImportDeclaration', + start: 0, + end: 24, + attributes: [], + specifiers: [ + { + type: 'ImportDefaultSpecifier', + start: 7, + end: 11, + local: { type: 'Identifier', start: 7, end: 11, name: 'path' } + } + ], + source: { type: 'Literal', start: 17, end: 23, value: 'path', raw: "'path'" } + }, + { + type: 'ExportNamedDeclaration', + start: 26, + end: 65, + attributes: [], + declaration: { + type: 'VariableDeclaration', + start: 33, + end: 65, + declarations: [ + { + type: 'VariableDeclarator', + start: 39, + end: 64, + id: { type: 'Identifier', start: 39, end: 42, name: 'foo' }, + init: { + type: 'CallExpression', + start: 45, + end: 64, + callee: { + type: 'MemberExpression', + start: 45, + end: 57, + object: { type: 'Identifier', start: 45, end: 49, name: 'path' }, + property: { + type: 'Identifier', + start: 50, + end: 57, + name: 'resolve' + }, + computed: false, + optional: false + }, + arguments: [ + { type: 'Literal', start: 58, end: 63, value: 'foo', raw: "'foo'" } + ], + optional: false + } + } + ], + kind: 'const' + }, + specifiers: [], + source: null } - }, + ], + sourceType: 'module' + }, + code: "import path from 'path';\n\nexport const foo = path.resolve('foo');\n", + dynamicallyImportedIdResolutions: [], + exportedBindings: { '.': ['foo'] }, + exports: ['foo'], + dynamicallyImportedIds: [], + dynamicImporters: [], + hasDefaultExport: false, + moduleSideEffects: true, + implicitlyLoadedAfterOneOf: [], + implicitlyLoadedBefore: [], + importedIdResolutions: [ { - type: 'ExportNamedDeclaration', - start: 32, - end: 80, - declaration: { - type: 'VariableDeclaration', - start: 39, - end: 80, - declarations: [ + attributes: {}, + external: true, + id: ID_PATH, + meta: {}, + moduleSideEffects: true, + resolvedBy: 'rollup', + syntheticNamedExports: false + } + ], + importedIds: [ID_PATH], + importers: [ID_MAIN, ID_NESTED], + isEntry: false, + isExternal: false, + isIncluded: true, + meta: {}, + safeVariableNames: null, + syntheticNamedExports: false + }, + [ID_MAIN]: { + id: ID_MAIN, + attributes: {}, + ast: { + type: 'Program', + start: 0, + end: 159, + body: [ + { + type: 'ExportNamedDeclaration', + start: 0, + end: 31, + attributes: [], + declaration: null, + specifiers: [ { - type: 'VariableDeclarator', - start: 45, - end: 79, - id: { type: 'Identifier', start: 45, end: 51, name: 'nested' }, - init: { - type: 'ImportExpression', - start: 54, + type: 'ExportSpecifier', + start: 9, + end: 12, + local: { type: 'Identifier', start: 9, end: 12, name: 'foo' }, + exported: { type: 'Identifier', start: 9, end: 12, name: 'foo' } + } + ], + source: { + type: 'Literal', + start: 20, + end: 30, + value: './foo.js', + raw: "'./foo.js'" + } + }, + { + type: 'ExportNamedDeclaration', + start: 32, + end: 80, + attributes: [], + declaration: { + type: 'VariableDeclaration', + start: 39, + end: 80, + declarations: [ + { + type: 'VariableDeclarator', + start: 45, end: 79, - source: { - type: 'Literal', - start: 61, - end: 78, - value: './nested/nested', - raw: "'./nested/nested'" + id: { type: 'Identifier', start: 45, end: 51, name: 'nested' }, + init: { + type: 'ImportExpression', + start: 54, + end: 79, + options: null, + source: { + type: 'Literal', + start: 61, + end: 78, + value: './nested/nested', + raw: "'./nested/nested'" + } } } - } - ], - kind: 'const' + ], + kind: 'const' + }, + specifiers: [], + source: null }, - specifiers: [], - source: null - }, - { - type: 'ExportNamedDeclaration', - start: 81, - end: 116, - declaration: { - type: 'VariableDeclaration', - start: 88, + { + type: 'ExportNamedDeclaration', + start: 81, end: 116, - declarations: [ - { - type: 'VariableDeclarator', - start: 94, - end: 115, - id: { type: 'Identifier', start: 94, end: 98, name: 'path' }, - init: { - type: 'ImportExpression', - start: 101, + attributes: [], + declaration: { + type: 'VariableDeclaration', + start: 88, + end: 116, + declarations: [ + { + type: 'VariableDeclarator', + start: 94, end: 115, - source: { - type: 'Literal', - start: 108, - end: 114, - value: 'path', - raw: "'path'" + id: { type: 'Identifier', start: 94, end: 98, name: 'path' }, + init: { + type: 'ImportExpression', + start: 101, + end: 115, + options: null, + source: { + type: 'Literal', + start: 108, + end: 114, + value: 'path', + raw: "'path'" + } } } - } - ], - kind: 'const' + ], + kind: 'const' + }, + specifiers: [], + source: null }, - specifiers: [], - source: null - }, - { - type: 'ExportNamedDeclaration', - start: 117, - end: 158, - declaration: { - type: 'VariableDeclaration', - start: 124, + { + type: 'ExportNamedDeclaration', + start: 117, end: 158, - declarations: [ - { - type: 'VariableDeclarator', - start: 130, - end: 157, - id: { type: 'Identifier', start: 130, end: 139, name: 'pathAgain' }, - init: { - type: 'ImportExpression', - start: 142, + attributes: [], + declaration: { + type: 'VariableDeclaration', + start: 124, + end: 158, + declarations: [ + { + type: 'VariableDeclarator', + start: 130, end: 157, - source: { type: 'Identifier', start: 149, end: 156, name: 'thePath' } + id: { type: 'Identifier', start: 130, end: 139, name: 'pathAgain' }, + init: { + type: 'ImportExpression', + start: 142, + end: 157, + options: null, + source: { type: 'Identifier', start: 149, end: 156, name: 'thePath' } + } } - } - ], - kind: 'const' - }, - specifiers: [], - source: null - } - ], - sourceType: 'module' - }, - code: - "export { foo } from './foo.js';\nexport const nested = import('./nested/nested');\nexport const path = import('path');\nexport const pathAgain = import(thePath);\n", - dynamicallyImportedIds: [ID_NESTED, ID_PATH], - dynamicImporters: [], - hasModuleSideEffects: true, - id: ID_MAIN, - implicitlyLoadedAfterOneOf: [], - implicitlyLoadedBefore: [], - importedIds: [ID_FOO], - importers: [], - isEntry: true, - isExternal: false, - meta: {}, - syntheticNamedExports: false - }, - { - ast: { - type: 'Program', - start: 0, - end: 66, - body: [ + ], + kind: 'const' + }, + specifiers: [], + source: null + } + ], + sourceType: 'module' + }, + code: "export { foo } from './foo.js';\nexport const nested = import('./nested/nested');\nexport const path = import('path');\nexport const pathAgain = import(thePath);\n", + dynamicallyImportedIdResolutions: [ { - type: 'ImportDeclaration', - start: 0, - end: 24, - specifiers: [ - { - type: 'ImportDefaultSpecifier', - start: 7, - end: 11, - local: { type: 'Identifier', start: 7, end: 11, name: 'path' } - } - ], - source: { type: 'Literal', start: 17, end: 23, value: 'path', raw: "'path'" } + attributes: {}, + external: false, + id: ID_NESTED, + meta: {}, + moduleSideEffects: true, + resolvedBy: 'rollup', + syntheticNamedExports: false }, { - type: 'ExportNamedDeclaration', - start: 26, - end: 65, - declaration: { - type: 'VariableDeclaration', - start: 33, - end: 65, - declarations: [ - { - type: 'VariableDeclarator', - start: 39, - end: 64, - id: { type: 'Identifier', start: 39, end: 42, name: 'foo' }, - init: { - type: 'CallExpression', - start: 45, - end: 64, - callee: { - type: 'MemberExpression', - start: 45, - end: 57, - object: { type: 'Identifier', start: 45, end: 49, name: 'path' }, - property: { type: 'Identifier', start: 50, end: 57, name: 'resolve' }, - computed: false, - optional: false - }, - arguments: [ - { type: 'Literal', start: 58, end: 63, value: 'foo', raw: "'foo'" } - ], - optional: false - } - } - ], - kind: 'const' - }, - specifiers: [], - source: null + attributes: {}, + external: true, + id: ID_PATH, + meta: {}, + moduleSideEffects: true, + resolvedBy: 'rollup', + syntheticNamedExports: false } ], - sourceType: 'module' - }, - code: "import path from 'path';\n\nexport const foo = path.resolve('foo');\n", - dynamicallyImportedIds: [], - dynamicImporters: [], - hasModuleSideEffects: true, - id: ID_FOO, - implicitlyLoadedAfterOneOf: [], - implicitlyLoadedBefore: [], - importedIds: [ID_PATH], - importers: [ID_MAIN, ID_NESTED], - isEntry: false, - isExternal: false, - meta: {}, - syntheticNamedExports: false - }, - { - ast: null, - code: null, - dynamicallyImportedIds: [], - dynamicImporters: [ID_MAIN], - hasModuleSideEffects: true, - id: ID_PATH, - implicitlyLoadedAfterOneOf: [], - implicitlyLoadedBefore: [], - importedIds: [], - importers: [ID_FOO], - isEntry: false, - isExternal: true, - meta: {}, - syntheticNamedExports: false - }, - { - ast: { - type: 'Program', - start: 0, - end: 72, - body: [ + dynamicallyImportedIds: [ID_NESTED, ID_PATH], + dynamicImporters: [], + exportedBindings: { + '.': ['nested', 'path', 'pathAgain'], + './foo.js': ['foo'] + }, + exports: ['nested', 'path', 'pathAgain', 'foo'], + hasDefaultExport: false, + moduleSideEffects: true, + implicitlyLoadedAfterOneOf: [], + implicitlyLoadedBefore: [], + importedIdResolutions: [ { - type: 'ImportDeclaration', - start: 0, - end: 32, - specifiers: [ - { - type: 'ImportSpecifier', - start: 9, - end: 12, - imported: { type: 'Identifier', start: 9, end: 12, name: 'foo' }, - local: { type: 'Identifier', start: 9, end: 12, name: 'foo' } + attributes: {}, + external: false, + id: ID_FOO, + meta: {}, + moduleSideEffects: true, + resolvedBy: 'rollup', + syntheticNamedExports: false + } + ], + importedIds: [ID_FOO], + importers: [], + isEntry: true, + isExternal: false, + isIncluded: true, + meta: {}, + safeVariableNames: null, + syntheticNamedExports: false + }, + [ID_NESTED]: { + id: ID_NESTED, + attributes: {}, + ast: { + type: 'Program', + start: 0, + end: 72, + body: [ + { + type: 'ImportDeclaration', + start: 0, + end: 32, + attributes: [], + specifiers: [ + { + type: 'ImportSpecifier', + start: 9, + end: 12, + imported: { type: 'Identifier', start: 9, end: 12, name: 'foo' }, + local: { type: 'Identifier', start: 9, end: 12, name: 'foo' } + } + ], + source: { + type: 'Literal', + start: 20, + end: 31, + value: '../foo.js', + raw: "'../foo.js'" } - ], - source: { - type: 'Literal', - start: 20, - end: 31, - value: '../foo.js', - raw: "'../foo.js'" - } - }, - { - type: 'ExportNamedDeclaration', - start: 34, - end: 71, - declaration: { - type: 'VariableDeclaration', - start: 41, + }, + { + type: 'ExportNamedDeclaration', + start: 34, end: 71, - declarations: [ - { - type: 'VariableDeclarator', - start: 47, - end: 70, - id: { type: 'Identifier', start: 47, end: 53, name: 'nested' }, - init: { - type: 'BinaryExpression', - start: 56, + attributes: [], + declaration: { + type: 'VariableDeclaration', + start: 41, + end: 71, + declarations: [ + { + type: 'VariableDeclarator', + start: 47, end: 70, - left: { - type: 'Literal', + id: { type: 'Identifier', start: 47, end: 53, name: 'nested' }, + init: { + type: 'BinaryExpression', start: 56, - end: 64, - value: 'nested', - raw: "'nested'" - }, - operator: '+', - right: { type: 'Identifier', start: 67, end: 70, name: 'foo' } + end: 70, + left: { + type: 'Literal', + start: 56, + end: 64, + value: 'nested', + raw: "'nested'" + }, + operator: '+', + right: { type: 'Identifier', start: 67, end: 70, name: 'foo' } + } } - } - ], - kind: 'const' - }, - specifiers: [], - source: null + ], + kind: 'const' + }, + specifiers: [], + source: null + } + ], + sourceType: 'module' + }, + code: "import { foo } from '../foo.js';\n\nexport const nested = 'nested' + foo;\n", + dynamicallyImportedIdResolutions: [], + dynamicallyImportedIds: [], + dynamicImporters: [ID_MAIN], + exports: ['nested'], + exportedBindings: { '.': ['nested'] }, + hasDefaultExport: false, + moduleSideEffects: true, + implicitlyLoadedAfterOneOf: [], + implicitlyLoadedBefore: [], + importedIdResolutions: [ + { + attributes: {}, + external: false, + id: ID_FOO, + meta: {}, + moduleSideEffects: true, + resolvedBy: 'rollup', + syntheticNamedExports: false } ], - sourceType: 'module' + importedIds: [ID_FOO], + importers: [], + isEntry: false, + isExternal: false, + isIncluded: true, + meta: {}, + safeVariableNames: null, + syntheticNamedExports: false }, - code: "import { foo } from '../foo.js';\n\nexport const nested = 'nested' + foo;\n", - dynamicallyImportedIds: [], - dynamicImporters: [ID_MAIN], - hasModuleSideEffects: true, - id: ID_NESTED, - implicitlyLoadedAfterOneOf: [], - implicitlyLoadedBefore: [], - importedIds: [ID_FOO], - importers: [], - isEntry: false, - isExternal: false, - meta: {}, - syntheticNamedExports: false + [ID_PATH]: { + id: ID_PATH, + attributes: {}, + ast: null, + code: null, + dynamicallyImportedIdResolutions: [], + dynamicallyImportedIds: [], + dynamicImporters: [ID_MAIN], + exportedBindings: null, + exports: null, + hasDefaultExport: null, + moduleSideEffects: true, + implicitlyLoadedAfterOneOf: [], + implicitlyLoadedBefore: [], + importedIdResolutions: [], + importedIds: [], + importers: [ID_FOO], + isEntry: false, + isExternal: true, + isIncluded: null, + meta: {}, + safeVariableNames: null, + syntheticNamedExports: false + } } - ] - ); + ); + } } - } + ] }, context: { thePath: 'path' @@ -358,4 +474,4 @@ module.exports = { bundle() { assert.ok(rendered); } -}; +}); diff --git a/test/function/samples/plugin-parse-ast-receives-comments/_config.js b/test/function/samples/plugin-parse-ast-receives-comments/_config.js deleted file mode 100644 index 4c45a59f575..00000000000 --- a/test/function/samples/plugin-parse-ast-receives-comments/_config.js +++ /dev/null @@ -1,22 +0,0 @@ -const assert = require('assert'); - -const comments = []; - -module.exports = { - description: 'plugin parse ast receives comments', - options: { - plugins:[{ - transform(code, _id) { - const ast = this.parse(code, { - onComment(...args) { - comments.push(args); - }, - }); - return {ast, code, map: null}; - }, - }], - }, - after() { - assert.ok(comments.length > 0); - }, -}; diff --git a/test/function/samples/plugin-parse-ast-receives-comments/main.js b/test/function/samples/plugin-parse-ast-receives-comments/main.js deleted file mode 100644 index fbc4f47c0e2..00000000000 --- a/test/function/samples/plugin-parse-ast-receives-comments/main.js +++ /dev/null @@ -1,4 +0,0 @@ -/* this is a comment */ -export function main() { - // this is also a comment -} \ No newline at end of file diff --git a/test/function/samples/plugin-parse-ast-remove-sourcemapping/_config.js b/test/function/samples/plugin-parse-ast-remove-sourcemapping/_config.js index 5f971de1c57..a9f1387ca80 100644 --- a/test/function/samples/plugin-parse-ast-remove-sourcemapping/_config.js +++ b/test/function/samples/plugin-parse-ast-remove-sourcemapping/_config.js @@ -1,16 +1,18 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'remove source mapping comment even if code is parsed by PluginContext.parse method', options: { - plugins:[{ - transform(code, _id) { - const ast = this.parse(code); - return {ast, code, map: null}; - }, - }], + plugins: [ + { + transform(code) { + const ast = this.parse(code); + return { ast, code, map: null }; + } + } + ] }, code(code) { assert.ok(code.search(/sourceMappingURL/) === -1); } -}; +}); diff --git a/test/function/samples/plugin-parse-ast-remove-sourcemapping/main.js b/test/function/samples/plugin-parse-ast-remove-sourcemapping/main.js index 10322cc5ab6..6ba9fa79242 100644 --- a/test/function/samples/plugin-parse-ast-remove-sourcemapping/main.js +++ b/test/function/samples/plugin-parse-ast-remove-sourcemapping/main.js @@ -5,7 +5,7 @@ export function main() { //# sourceMappingURL=http://example.com/path/to/your/sourcemap.map export function foo() { - + } /*# sourceMappingURL=http://example.com/path/to/your/sourcemap.map */ diff --git a/test/function/samples/plugin-parse/_config.js b/test/function/samples/plugin-parse/_config.js index f5926da9818..b3e98c64e1e 100644 --- a/test/function/samples/plugin-parse/_config.js +++ b/test/function/samples/plugin-parse/_config.js @@ -1,12 +1,12 @@ const MagicString = require('magic-string'); -module.exports = { +module.exports = defineTest({ description: 'plugin transform hooks can use `this.parse(code, options)`', options: { plugins: [ { name: 'test', - transform(code, id) { + transform(code) { const magicString = new MagicString(code); enforceTheAnswer(this.parse(code), magicString); return magicString.toString(); @@ -14,16 +14,16 @@ module.exports = { } ] } -}; +}); function enforceTheAnswer(ast, magicString) { - ast.body.forEach(node => { + for (const node of ast.body) { if (node.type === 'VariableDeclaration') { - node.declarations.forEach(decl => { + for (const decl of node.declarations) { if (decl.id.name === 'answer') { magicString.overwrite(decl.init.start, decl.init.end, '42'); } - }); + } } - }); + } } diff --git a/test/function/samples/plugin-warn-loc-instead-pos/_config.js b/test/function/samples/plugin-warn-loc-instead-pos/_config.js index 33f196fac7f..7f864ff3008 100644 --- a/test/function/samples/plugin-warn-loc-instead-pos/_config.js +++ b/test/function/samples/plugin-warn-loc-instead-pos/_config.js @@ -1,12 +1,12 @@ -const path = require('path'); +const path = require('node:path'); -module.exports = { +module.exports = defineTest({ description: '`this.warn(...)` accepts { line, column } object as second parameter (#1265)', options: { plugins: [ { name: 'test', - transform(code, id) { + transform() { this.warn('foo', { line: 1, column: 22 }); return 'assert.equal( 21 * 2, 42 );'; } @@ -19,7 +19,7 @@ module.exports = { id: path.join(__dirname, 'main.js'), plugin: 'test', hook: 'transform', - message: 'foo', + message: '[plugin test] main.js (1:22): foo', loc: { file: path.join(__dirname, 'main.js'), line: 1, @@ -31,4 +31,4 @@ module.exports = { ` } ] -}; +}); diff --git a/test/function/samples/plugin-warn/_config.js b/test/function/samples/plugin-warn/_config.js index eee71ea3ab2..ffcddb1eb61 100644 --- a/test/function/samples/plugin-warn/_config.js +++ b/test/function/samples/plugin-warn/_config.js @@ -1,6 +1,6 @@ -const path = require('path'); +const path = require('node:path'); -module.exports = { +module.exports = defineTest({ description: 'plugin transform hooks can use `this.warn({...}, char)` (#1140)', options: { plugins: [ @@ -20,7 +20,7 @@ module.exports = { id: path.join(__dirname, 'main.js'), hook: 'transform', plugin: 'test', - message: 'foo', + message: '[plugin test] main.js: foo', pluginCode: 'CODE' }, { @@ -28,7 +28,7 @@ module.exports = { id: path.join(__dirname, 'main.js'), plugin: 'test', hook: 'transform', - message: 'bar', + message: '[plugin test] main.js (1:22): bar', pos: 22, loc: { file: path.join(__dirname, 'main.js'), @@ -41,4 +41,4 @@ module.exports = { ` } ] -}; +}); diff --git a/test/function/samples/plugins-can-manipulate-options/_config.js b/test/function/samples/plugins-can-manipulate-options/_config.js index 5ef9d0bef6e..90fa3d26b1f 100644 --- a/test/function/samples/plugins-can-manipulate-options/_config.js +++ b/test/function/samples/plugins-can-manipulate-options/_config.js @@ -1,7 +1,7 @@ -const path = require('path'); -const assert = require('assert'); +const assert = require('node:assert'); +const path = require('node:path'); -module.exports = { +module.exports = defineTest({ description: 'plugins can manipulate the options object', options: { plugins: [ @@ -15,4 +15,4 @@ module.exports = { exports(answer) { assert.equal(answer, 42); } -}; +}); diff --git a/test/function/samples/preload-after-build/_config.js b/test/function/samples/preload-after-build/_config.js new file mode 100644 index 00000000000..408fd1998e5 --- /dev/null +++ b/test/function/samples/preload-after-build/_config.js @@ -0,0 +1,23 @@ +const path = require('node:path'); + +module.exports = defineTest({ + description: 'supports this.load() in buildEnd and renderStart', + options: { + plugins: [ + { + name: 'test', + buildEnd() { + this.load({ id: path.join(__dirname, 'other2.js') }); + }, + moduleParsed({ id }) { + if (id.endsWith('main.js')) { + this.load({ id: path.join(__dirname, 'other1.js') }); + } + }, + renderStart() { + this.load({ id: path.join(__dirname, 'other3.js') }); + } + } + ] + } +}); diff --git a/test/function/samples/preload-after-build/main.js b/test/function/samples/preload-after-build/main.js new file mode 100644 index 00000000000..cc1d88a24fa --- /dev/null +++ b/test/function/samples/preload-after-build/main.js @@ -0,0 +1 @@ +assert.ok(true); diff --git a/test/function/samples/preload-after-build/other1.js b/test/function/samples/preload-after-build/other1.js new file mode 100644 index 00000000000..cc1d88a24fa --- /dev/null +++ b/test/function/samples/preload-after-build/other1.js @@ -0,0 +1 @@ +assert.ok(true); diff --git a/test/function/samples/preload-after-build/other2.js b/test/function/samples/preload-after-build/other2.js new file mode 100644 index 00000000000..cc1d88a24fa --- /dev/null +++ b/test/function/samples/preload-after-build/other2.js @@ -0,0 +1 @@ +assert.ok(true); diff --git a/test/function/samples/preload-after-build/other3.js b/test/function/samples/preload-after-build/other3.js new file mode 100644 index 00000000000..cc1d88a24fa --- /dev/null +++ b/test/function/samples/preload-after-build/other3.js @@ -0,0 +1 @@ +assert.ok(true); diff --git a/test/function/samples/preload-cyclic-module/_config.js b/test/function/samples/preload-cyclic-module/_config.js new file mode 100644 index 00000000000..c0e87e3537f --- /dev/null +++ b/test/function/samples/preload-cyclic-module/_config.js @@ -0,0 +1,40 @@ +const path = require('node:path'); +const ID_MAIN = path.join(__dirname, 'main.js'); +const ID_PROXY = path.join(__dirname, 'main.js?proxy'); + +module.exports = defineTest({ + description: 'handles pre-loading a cyclic module in the resolveId hook', + warnings: [ + { + code: 'CIRCULAR_DEPENDENCY', + ids: [ID_MAIN, ID_PROXY, ID_MAIN], + message: 'Circular dependency: main.js -> main.js?proxy -> main.js' + } + ], + options: { + plugins: [ + { + async resolveId(source, importer, options) { + if (!importer || importer.endsWith('?proxy')) { + return null; + } + const resolution = await this.resolve(source, importer, options); + if (resolution && !resolution.external) { + const moduleInfo = await this.load(resolution); + if (moduleInfo.code.includes('/* use proxy */')) { + return `${resolution.id}?proxy`; + } + } + return resolution; + }, + load(id) { + if (id.endsWith('?proxy')) { + const importee = id.slice(0, -'?proxy'.length); + return `export * from ${JSON.stringify(importee)}; export const extra = 'extra';`; + } + return null; + } + } + ] + } +}); diff --git a/test/function/samples/preload-cyclic-module/main.js b/test/function/samples/preload-cyclic-module/main.js new file mode 100644 index 00000000000..57f7fea2ae5 --- /dev/null +++ b/test/function/samples/preload-cyclic-module/main.js @@ -0,0 +1,6 @@ +/* main *//* use proxy */ +import { foo as bar, extra } from './main.js'; +export const foo = 'foo'; +assert.strictEqual(bar, 'foo'); +assert.strictEqual(extra, 'extra'); + diff --git a/test/function/samples/preload-loading-module/_config.js b/test/function/samples/preload-loading-module/_config.js new file mode 100644 index 00000000000..8779dfafa26 --- /dev/null +++ b/test/function/samples/preload-loading-module/_config.js @@ -0,0 +1,20 @@ +const assert = require('node:assert'); + +let preloadedCode; + +module.exports = defineTest({ + description: 'waits for pre-loaded modules that are currently loading', + options: { + plugins: [ + { + name: 'test-plugin', + load(id) { + this.load({ id }).then(({ code }) => (preloadedCode = code)); + }, + buildEnd() { + assert.strictEqual(preloadedCode, 'assert.ok(true);\n'); + } + } + ] + } +}); diff --git a/test/function/samples/preload-loading-module/main.js b/test/function/samples/preload-loading-module/main.js new file mode 100644 index 00000000000..cc1d88a24fa --- /dev/null +++ b/test/function/samples/preload-loading-module/main.js @@ -0,0 +1 @@ +assert.ok(true); diff --git a/test/function/samples/preload-module/_config.js b/test/function/samples/preload-module/_config.js new file mode 100644 index 00000000000..10b4a9d6963 --- /dev/null +++ b/test/function/samples/preload-module/_config.js @@ -0,0 +1,110 @@ +const assert = require('node:assert'); +const path = require('node:path'); +const ID_MAIN = path.join(__dirname, 'main.js'); +const ID_DEP = path.join(__dirname, 'dep.js'); +const ID_OTHER = path.join(__dirname, 'other.js'); + +const loadedModules = []; +const transformedModules = []; +const parsedModules = []; + +module.exports = defineTest({ + description: 'allows pre-loading modules via this.load', + options: { + plugins: [ + { + name: 'test-plugin', + load(id) { + loadedModules.push(id); + }, + async transform(code, id) { + transformedModules.push(id); + }, + moduleParsed({ id }) { + parsedModules.push(id); + }, + async resolveId(source, importer, options) { + if (source.endsWith('main.js')) { + const resolvedId = await this.resolve(source, importer, options); + const { ast, ...moduleInfo } = await this.load({ + ...resolvedId, + meta: { testPlugin: 'first' } + }); + assert.deepStrictEqual(moduleInfo, { + id: ID_MAIN, + attributes: {}, + code: "import './dep';\nassert.ok(true);\n", + dynamicImporters: [], + exportedBindings: { + '.': [] + }, + exports: [], + hasDefaultExport: false, + dynamicallyImportedIdResolutions: [], + dynamicallyImportedIds: [], + moduleSideEffects: true, + implicitlyLoadedAfterOneOf: [], + implicitlyLoadedBefore: [], + importedIdResolutions: [], + importedIds: [], + importers: [], + isEntry: false, + isExternal: false, + isIncluded: null, + meta: { testPlugin: 'first' }, + safeVariableNames: null, + syntheticNamedExports: false + }); + assert.strictEqual(loadedModules.filter(id => id === ID_MAIN).length, 1); + assert.strictEqual(transformedModules.filter(id => id === ID_MAIN).length, 1); + assert.strictEqual(parsedModules.filter(id => id === ID_MAIN).length, 0); + // No dependencies have been loaded yet + assert.deepStrictEqual([...this.getModuleIds()], [ID_MAIN]); + await this.load({ id: ID_OTHER }); + assert.deepStrictEqual([...this.getModuleIds()].sort(), [ID_MAIN, ID_OTHER]); + return resolvedId; + } + }, + async buildEnd(error) { + if (error) { + return; + } + const { ast, ...moduleInfo } = await this.load({ + id: ID_DEP, + // This should be ignored as the module was already loaded + meta: { testPlugin: 'second' } + }); + assert.deepStrictEqual(moduleInfo, { + id: ID_DEP, + attributes: {}, + code: 'assert.ok(true);\n', + dynamicImporters: [], + exportedBindings: { + '.': [] + }, + exports: [], + hasDefaultExport: false, + dynamicallyImportedIdResolutions: [], + dynamicallyImportedIds: [], + moduleSideEffects: true, + implicitlyLoadedAfterOneOf: [], + implicitlyLoadedBefore: [], + importedIdResolutions: [], + importedIds: [], + importers: [ID_MAIN], + isEntry: false, + isExternal: false, + isIncluded: true, + meta: {}, + safeVariableNames: null, + syntheticNamedExports: false + }); + assert.strictEqual(loadedModules.filter(id => id === ID_DEP).length, 1); + assert.strictEqual(transformedModules.filter(id => id === ID_DEP).length, 1); + assert.strictEqual(parsedModules.filter(id => id === ID_DEP).length, 1); + assert.deepStrictEqual([...this.getModuleIds()].sort(), [ID_DEP, ID_MAIN, ID_OTHER]); + } + } + ] + } +}); diff --git a/test/function/samples/preload-module/dep.js b/test/function/samples/preload-module/dep.js new file mode 100644 index 00000000000..cc1d88a24fa --- /dev/null +++ b/test/function/samples/preload-module/dep.js @@ -0,0 +1 @@ +assert.ok(true); diff --git a/test/function/samples/preload-module/main.js b/test/function/samples/preload-module/main.js new file mode 100644 index 00000000000..03c9802af09 --- /dev/null +++ b/test/function/samples/preload-module/main.js @@ -0,0 +1,2 @@ +import './dep'; +assert.ok(true); diff --git a/test/function/samples/preload-module/other-dep.js b/test/function/samples/preload-module/other-dep.js new file mode 100644 index 00000000000..cd6715c9386 --- /dev/null +++ b/test/function/samples/preload-module/other-dep.js @@ -0,0 +1 @@ +throw new Error('Should not be executed'); diff --git a/test/function/samples/preload-module/other.js b/test/function/samples/preload-module/other.js new file mode 100644 index 00000000000..675eabdd86b --- /dev/null +++ b/test/function/samples/preload-module/other.js @@ -0,0 +1,2 @@ +import './other-dep'; +throw new Error('Should not be executed'); diff --git a/test/function/samples/preserve-entry-signatures-empty-facade/_config.js b/test/function/samples/preserve-entry-signatures-empty-facade/_config.js deleted file mode 100644 index 2630a32285d..00000000000 --- a/test/function/samples/preserve-entry-signatures-empty-facade/_config.js +++ /dev/null @@ -1,16 +0,0 @@ -const path = require('path'); - -module.exports = { - description: 'warns when creating an empty facade and "preserveEntrySignatures" is not specified', - options: { - input: ['main.js'] - }, - warnings: [ - { - code: 'EMPTY_FACADE', - id: path.join(__dirname, 'main.js'), - message: `To preserve the export signature of the entry module "main.js", an empty facade chunk was created. This often happens when creating a bundle for a web app where chunks are placed in script tags and exports are ignored. In this case it is recommended to set "preserveEntrySignatures: false" to avoid this and reduce the number of chunks. Otherwise if this is intentional, set "preserveEntrySignatures: 'strict'" explicitly to silence this warning.`, - url: 'https://rollupjs.org/guide/en/#preserveentrysignatures' - } - ] -}; diff --git a/test/function/samples/preserve-entry-signatures-empty-facade/dynamic.js b/test/function/samples/preserve-entry-signatures-empty-facade/dynamic.js deleted file mode 100644 index 71d2c545469..00000000000 --- a/test/function/samples/preserve-entry-signatures-empty-facade/dynamic.js +++ /dev/null @@ -1,2 +0,0 @@ -import { shared } from './lib.js'; -global.shared = shared; diff --git a/test/function/samples/preserve-entry-signatures-empty-facade/lib.js b/test/function/samples/preserve-entry-signatures-empty-facade/lib.js deleted file mode 100644 index cd35843de7a..00000000000 --- a/test/function/samples/preserve-entry-signatures-empty-facade/lib.js +++ /dev/null @@ -1 +0,0 @@ -export const shared = 'shared'; diff --git a/test/function/samples/preserve-entry-signatures-empty-facade/main.js b/test/function/samples/preserve-entry-signatures-empty-facade/main.js deleted file mode 100644 index 27c56080b9b..00000000000 --- a/test/function/samples/preserve-entry-signatures-empty-facade/main.js +++ /dev/null @@ -1,3 +0,0 @@ -import { shared } from './lib.js'; -global.shared = shared; -import('./dynamic.js'); diff --git a/test/function/samples/preserve-exported-object-in-namespace/_config.js b/test/function/samples/preserve-exported-object-in-namespace/_config.js new file mode 100644 index 00000000000..c87382ae0d4 --- /dev/null +++ b/test/function/samples/preserve-exported-object-in-namespace/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'preserve the exported object that imported by namespace' +}); diff --git a/test/function/samples/preserve-exported-object-in-namespace/main.js b/test/function/samples/preserve-exported-object-in-namespace/main.js new file mode 100644 index 00000000000..5963870279a --- /dev/null +++ b/test/function/samples/preserve-exported-object-in-namespace/main.js @@ -0,0 +1,2 @@ +import * as module from './module'; +assert.deepEqual(module.foo.bar, 1); diff --git a/test/function/samples/preserve-exported-object-in-namespace/module.js b/test/function/samples/preserve-exported-object-in-namespace/module.js new file mode 100644 index 00000000000..1399af4bb52 --- /dev/null +++ b/test/function/samples/preserve-exported-object-in-namespace/module.js @@ -0,0 +1 @@ +export const foo = { bar: 1 }; diff --git a/test/function/samples/preserve-for-of-iterable/_config.js b/test/function/samples/preserve-for-of-iterable/_config.js index d2105b0c09a..d9b466ae710 100644 --- a/test/function/samples/preserve-for-of-iterable/_config.js +++ b/test/function/samples/preserve-for-of-iterable/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'preserves for...of loops' -}; +}); diff --git a/test/function/samples/preserve-modules-circular-order/_config.js b/test/function/samples/preserve-modules-circular-order/_config.js index 7bd9f5d3bc5..39b23282274 100644 --- a/test/function/samples/preserve-modules-circular-order/_config.js +++ b/test/function/samples/preserve-modules-circular-order/_config.js @@ -1,7 +1,11 @@ -const assert = require('assert'); +const assert = require('node:assert'); +const path = require('node:path'); +const ID_INDEX = path.join(__dirname, 'index.js'); +const ID_DATA = path.join(__dirname, 'data.js'); +const ID_TAG = path.join(__dirname, 'tag.js'); const executionOrder = []; -module.exports = { +module.exports = defineTest({ description: 'preserves execution order for circular dependencies when preserving modules', options: { output: { preserveModules: true } @@ -20,21 +24,18 @@ module.exports = { warnings: [ { code: 'CIRCULAR_DEPENDENCY', - cycle: ['data.js', 'tag.js', 'data.js'], - importer: 'data.js', + ids: [ID_DATA, ID_TAG, ID_DATA], message: 'Circular dependency: data.js -> tag.js -> data.js' }, { code: 'CIRCULAR_DEPENDENCY', - cycle: ['data.js', 'tag.js', 'index.js', 'data.js'], - importer: 'data.js', + ids: [ID_DATA, ID_TAG, ID_INDEX, ID_DATA], message: 'Circular dependency: data.js -> tag.js -> index.js -> data.js' }, { code: 'CIRCULAR_DEPENDENCY', - cycle: ['tag.js', 'index.js', 'tag.js'], - importer: 'tag.js', + ids: [ID_TAG, ID_INDEX, ID_TAG], message: 'Circular dependency: tag.js -> index.js -> tag.js' } ] -}; +}); diff --git a/test/function/samples/preserve-modules-default-mode-namespace/_config.js b/test/function/samples/preserve-modules-default-mode-namespace/_config.js index 11ec311c5e2..3a1661a514c 100644 --- a/test/function/samples/preserve-modules-default-mode-namespace/_config.js +++ b/test/function/samples/preserve-modules-default-mode-namespace/_config.js @@ -1,6 +1,6 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'import namespace from chunks with default export mode when preserving modules', options: { input: ['main', 'lib'], @@ -11,4 +11,4 @@ module.exports = { exports(exports) { assert.deepStrictEqual(exports, { lib: { __proto__: null, default: 'foo' } }); } -}; +}); diff --git a/test/function/samples/preserve-modules/inline-dynamic-imports/_config.js b/test/function/samples/preserve-modules/inline-dynamic-imports/_config.js index b315aa96fca..a23f486275e 100644 --- a/test/function/samples/preserve-modules/inline-dynamic-imports/_config.js +++ b/test/function/samples/preserve-modules/inline-dynamic-imports/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'Inlining dynamic imports is not supported when preserving modules', options: { input: ['main.js'], @@ -10,6 +10,7 @@ module.exports = { generateError: { code: 'INVALID_OPTION', message: - 'The "output.inlineDynamicImports" option is not supported for "output.preserveModules".' + 'Invalid value for option "output.inlineDynamicImports" - this option is not supported for "output.preserveModules".', + url: 'https://rollupjs.org/configuration-options/#output-inlinedynamicimports' } -}; +}); diff --git a/test/function/samples/preserve-modules/invalid-default-export-mode/_config.js b/test/function/samples/preserve-modules/invalid-default-export-mode/_config.js index 3256f5ca2b8..105e59a7c53 100644 --- a/test/function/samples/preserve-modules/invalid-default-export-mode/_config.js +++ b/test/function/samples/preserve-modules/invalid-default-export-mode/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'throws when using default export mode with named exports', options: { input: ['main.js'], @@ -10,6 +10,7 @@ module.exports = { generateError: { code: 'INVALID_EXPORT_OPTION', message: - '"default" was specified for "output.exports", but entry module "lib.js" has the following exports: value' + '"default" was specified for "output.exports", but entry module "lib.js" has the following exports: "value"', + url: 'https://rollupjs.org/configuration-options/#output-exports' } -}; +}); diff --git a/test/function/samples/preserve-modules/invalid-no-preserve-entry-signatures/_config.js b/test/function/samples/preserve-modules/invalid-no-preserve-entry-signatures/_config.js index dcd159dc9d9..2b32dc41517 100644 --- a/test/function/samples/preserve-modules/invalid-no-preserve-entry-signatures/_config.js +++ b/test/function/samples/preserve-modules/invalid-no-preserve-entry-signatures/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'throws when setting preserveEntrySignatures to false', options: { input: ['main.js'], @@ -8,6 +8,7 @@ module.exports = { generateError: { code: 'INVALID_OPTION', message: - 'Setting "preserveEntrySignatures" to "false" is not supported for "output.preserveModules".' + 'Invalid value for option "preserveEntrySignatures" - setting this option to false is not supported for "output.preserveModules".', + url: 'https://rollupjs.org/configuration-options/#preserveentrysignatures' } -}; +}); diff --git a/test/function/samples/preserve-modules/invalid-none-export-mode/_config.js b/test/function/samples/preserve-modules/invalid-none-export-mode/_config.js index 8dfb14e480d..2f887691bc7 100644 --- a/test/function/samples/preserve-modules/invalid-none-export-mode/_config.js +++ b/test/function/samples/preserve-modules/invalid-none-export-mode/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'throws when using none export mode with named exports', options: { input: ['main.js'], @@ -10,6 +10,7 @@ module.exports = { generateError: { code: 'INVALID_EXPORT_OPTION', message: - '"none" was specified for "output.exports", but entry module "lib.js" has the following exports: value' + '"none" was specified for "output.exports", but entry module "lib.js" has the following exports: "value"', + url: 'https://rollupjs.org/configuration-options/#output-exports' } -}; +}); diff --git a/test/function/samples/preserve-modules/manual-chunks/_config.js b/test/function/samples/preserve-modules/manual-chunks/_config.js index 5f9f2e6ecd0..9bfdc36703d 100644 --- a/test/function/samples/preserve-modules/manual-chunks/_config.js +++ b/test/function/samples/preserve-modules/manual-chunks/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'Assigning manual chunks fails when preserving modules', options: { input: ['main.js'], @@ -11,6 +11,8 @@ module.exports = { }, generateError: { code: 'INVALID_OPTION', - message: 'The "output.manualChunks" option is not supported for "output.preserveModules".' + message: + 'Invalid value for option "output.manualChunks" - this option is not supported for "output.preserveModules".', + url: 'https://rollupjs.org/configuration-options/#output-manualchunks' } -}; +}); diff --git a/test/function/samples/preserve-modules/mixed-exports/_config.js b/test/function/samples/preserve-modules/mixed-exports/_config.js index 523d0c0f19e..1b09118f0bf 100644 --- a/test/function/samples/preserve-modules/mixed-exports/_config.js +++ b/test/function/samples/preserve-modules/mixed-exports/_config.js @@ -1,6 +1,8 @@ -const path = require('path'); +const path = require('node:path'); +const ID_MAIN = path.join(__dirname, 'main.js'); +const ID_LIB1 = path.join(__dirname, 'lib1.js'); -module.exports = { +module.exports = defineTest({ description: 'warns for mixed exports in all chunks when preserving modules', options: { input: ['main.js'], @@ -9,17 +11,17 @@ module.exports = { warnings: [ { code: 'MIXED_EXPORTS', - id: path.join(__dirname, 'main.js'), + id: ID_MAIN, message: - 'Entry module "main.js" is using named and default exports together. Consumers of your bundle will have to use `chunk["default"]` to access the default export, which may not be what you want. Use `output.exports: "named"` to disable this warning', - url: 'https://rollupjs.org/guide/en/#outputexports' + 'Entry module "main.js" is using named and default exports together. Consumers of your bundle will have to use `chunk.default` to access the default export, which may not be what you want. Use `output.exports: "named"` to disable this warning.', + url: 'https://rollupjs.org/configuration-options/#output-exports' }, { code: 'MIXED_EXPORTS', - id: path.join(__dirname, 'lib1.js'), + id: ID_LIB1, message: - 'Entry module "lib1.js" is using named and default exports together. Consumers of your bundle will have to use `chunk["default"]` to access the default export, which may not be what you want. Use `output.exports: "named"` to disable this warning', - url: 'https://rollupjs.org/guide/en/#outputexports' + 'Entry module "lib1.js" is using named and default exports together. Consumers of your bundle will have to use `chunk.default` to access the default export, which may not be what you want. Use `output.exports: "named"` to disable this warning.', + url: 'https://rollupjs.org/configuration-options/#output-exports' } ] -}; +}); diff --git a/test/function/samples/preserve-modules/virtual-modules-conflict/_config.js b/test/function/samples/preserve-modules/virtual-modules-conflict/_config.js index 2138da5c8aa..1ed78a68107 100644 --- a/test/function/samples/preserve-modules/virtual-modules-conflict/_config.js +++ b/test/function/samples/preserve-modules/virtual-modules-conflict/_config.js @@ -1,6 +1,6 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'Generates actual files for virtual modules when preserving modules', options: { plugins: [ @@ -27,4 +27,4 @@ module.exports = { ) ); } -}; +}); diff --git a/test/function/samples/preserve-modules/virtual-modules/_config.js b/test/function/samples/preserve-modules/virtual-modules/_config.js index 8965977575f..b5ea264179c 100644 --- a/test/function/samples/preserve-modules/virtual-modules/_config.js +++ b/test/function/samples/preserve-modules/virtual-modules/_config.js @@ -1,6 +1,6 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'Generates actual files for virtual modules when preserving modules', options: { plugins: [ @@ -23,8 +23,8 @@ module.exports = { return bundle.generate({ format: 'es', preserveModules: true }).then(generated => assert.deepEqual( generated.output.map(chunk => chunk.fileName), - ['main.js', '_virtual/_virtualModule', 'lib/lib.js'] + ['main.js', '_virtual/_virtualModule.js', 'lib/lib.js'] ) ); } -}; +}); diff --git a/test/function/samples/preserve-symlink/_config.js b/test/function/samples/preserve-symlink/_config.js index fa45ed5f2e8..60c64eb5a87 100644 --- a/test/function/samples/preserve-symlink/_config.js +++ b/test/function/samples/preserve-symlink/_config.js @@ -1,7 +1,7 @@ -module.exports = { - skip: process.platform === 'win32', +module.exports = defineTest({ + skipIfWindows: true, description: 'follows symlinks', options: { preserveSymlinks: true } -}; +}); diff --git a/test/function/samples/preserve-var-declaration/_config.js b/test/function/samples/preserve-var-declaration/_config.js new file mode 100644 index 00000000000..5281c9eb6a5 --- /dev/null +++ b/test/function/samples/preserve-var-declaration/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'preserve the variableDeclaration that declared by var' +}); diff --git a/test/function/samples/preserve-var-declaration/main.js b/test/function/samples/preserve-var-declaration/main.js new file mode 100644 index 00000000000..92df84abc14 --- /dev/null +++ b/test/function/samples/preserve-var-declaration/main.js @@ -0,0 +1,5 @@ +{ + var a = { c: 1 }; + var b = { a }; + assert.deepEqual(b.a.c, 1); +} diff --git a/test/function/samples/preserves-catch-argument/_config.js b/test/function/samples/preserves-catch-argument/_config.js index 3ce74663a22..f3e02e49af6 100644 --- a/test/function/samples/preserves-catch-argument/_config.js +++ b/test/function/samples/preserves-catch-argument/_config.js @@ -1,6 +1,6 @@ -module.exports = { +module.exports = defineTest({ description: 'does not replace argument to catch block (#1462)', options: { external: ['path'] } -}; +}); diff --git a/test/function/samples/preserves-default-exports-used-locally/_config.js b/test/function/samples/preserves-default-exports-used-locally/_config.js index 98c090b8cb2..6a5ad4fc865 100644 --- a/test/function/samples/preserves-default-exports-used-locally/_config.js +++ b/test/function/samples/preserves-default-exports-used-locally/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'preserves default exports that are only used locally (#984)' -}; +}); diff --git a/test/function/samples/preserves-function-expression-names/_config.js b/test/function/samples/preserves-function-expression-names/_config.js index 94694b856f0..4a43c05ce18 100644 --- a/test/function/samples/preserves-function-expression-names/_config.js +++ b/test/function/samples/preserves-function-expression-names/_config.js @@ -1,6 +1,6 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'does not rewrite function expression names incorrectly (#1083)', options: { external: ['path'] @@ -9,4 +9,4 @@ module.exports = { assert.ok(!/path/.test(exports.x.name)); assert.equal(exports.y, 'somefile.txt'); } -}; +}); diff --git a/test/function/samples/preserves-var-declarations-in-dead-branches/_config.js b/test/function/samples/preserves-var-declarations-in-dead-branches/_config.js index e0f687ef8fe..6ee480a836c 100644 --- a/test/function/samples/preserves-var-declarations-in-dead-branches/_config.js +++ b/test/function/samples/preserves-var-declarations-in-dead-branches/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'preserves var declarations in dead branches (#977)' -}; +}); diff --git a/test/function/samples/prevent-asi-with-line-comments/_config.js b/test/function/samples/prevent-asi-with-line-comments/_config.js index bbe1bf6dea4..eb22ceada03 100644 --- a/test/function/samples/prevent-asi-with-line-comments/_config.js +++ b/test/function/samples/prevent-asi-with-line-comments/_config.js @@ -1,8 +1,8 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'prevent semicolon insertion for return statements when there are line comments', exports(exports) { assert.strictEqual(exports(), 1); } -}; +}); diff --git a/test/function/samples/prevent-context-resolve-loop/_config.js b/test/function/samples/prevent-context-resolve-loop/_config.js index 80c067ed731..9fad63d3894 100644 --- a/test/function/samples/prevent-context-resolve-loop/_config.js +++ b/test/function/samples/prevent-context-resolve-loop/_config.js @@ -1,5 +1,5 @@ -const path = require('path'); -const assert = require('assert'); +const assert = require('node:assert'); +const path = require('node:path'); const ID_OTHER_1 = path.join(__dirname, 'other1.js'); const ID_OTHER_2 = path.join(__dirname, 'other2.js'); @@ -8,14 +8,14 @@ const ID_OTHER_4 = path.join(__dirname, 'other4.js'); const thirdPluginCalls = new Set(); -module.exports = { +module.exports = defineTest({ description: 'prevents infinite loops when several plugins are calling this.resolve in resolveId', options: { plugins: [ { name: 'first', async resolveId(source, importer) { - const { id } = await this.resolve(source, importer, { skipSelf: true }); + const { id } = await this.resolve(source, importer); if (id === ID_OTHER_1) { return ID_OTHER_4; } @@ -24,19 +24,13 @@ module.exports = { { name: 'second', async resolveId(source, importer) { - const { id } = await this.resolve(source, importer, { skipSelf: true }); + const { id } = await this.resolve(source, importer); if (id === ID_OTHER_2) { // To make this more interesting // The first plugin should resolve everything to 4 - assert.strictEqual( - (await this.resolve('./other1', importer, { skipSelf: true })).id, - ID_OTHER_4 - ); + assert.strictEqual((await this.resolve('./other1', importer)).id, ID_OTHER_4); // The second file should however be resolved by core as this plugin is out of the loop - assert.strictEqual( - (await this.resolve(source, ID_OTHER_1, { skipSelf: true })).id, - ID_OTHER_2 - ); + assert.strictEqual((await this.resolve(source, ID_OTHER_1)).id, ID_OTHER_2); return ID_OTHER_4; } } @@ -59,4 +53,4 @@ module.exports = { } ] } -}; +}); diff --git a/test/function/samples/prevent-tree-shaking-asi/_config.js b/test/function/samples/prevent-tree-shaking-asi/_config.js index c0ce988a450..7431deafbd1 100644 --- a/test/function/samples/prevent-tree-shaking-asi/_config.js +++ b/test/function/samples/prevent-tree-shaking-asi/_config.js @@ -1,6 +1,6 @@ -module.exports = { +module.exports = defineTest({ description: 'prevent automatic semicolon insertion from changing behaviour when tree-shaking', options: { treeshake: { tryCatchDeoptimization: false } } -}; +}); diff --git a/test/function/samples/property-keys-not-renamed/_config.js b/test/function/samples/property-keys-not-renamed/_config.js index d4e1f829b49..bb53d7ef257 100644 --- a/test/function/samples/property-keys-not-renamed/_config.js +++ b/test/function/samples/property-keys-not-renamed/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'does not rename property keys' -}; +}); diff --git a/test/function/samples/propertyReadSideEffects-always/_config.js b/test/function/samples/propertyReadSideEffects-always/_config.js index 8fc38463bc0..09a7f87920f 100644 --- a/test/function/samples/propertyReadSideEffects-always/_config.js +++ b/test/function/samples/propertyReadSideEffects-always/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'verify property accesses are retained for getters with side effects', options: { treeshake: { propertyReadSideEffects: 'always' } } -}; +}); diff --git a/test/function/samples/protect-cjs-globals/_config.js b/test/function/samples/protect-cjs-globals/_config.js index 26fd141de27..e9a4157b03f 100644 --- a/test/function/samples/protect-cjs-globals/_config.js +++ b/test/function/samples/protect-cjs-globals/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'prevent conflicts with cjs module globals' -}; +}); diff --git a/test/function/samples/proto-accessors/_config.js b/test/function/samples/proto-accessors/_config.js new file mode 100644 index 00000000000..795ccf6aa52 --- /dev/null +++ b/test/function/samples/proto-accessors/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'handles getters and setters on __proto__ properties' +}); diff --git a/test/function/samples/proto-accessors/main.js b/test/function/samples/proto-accessors/main.js new file mode 100644 index 00000000000..4c9e0129743 --- /dev/null +++ b/test/function/samples/proto-accessors/main.js @@ -0,0 +1,21 @@ +let getter_effect = 'FAIL'; +let setter_effect = 'FAIL'; +let proto = { + get foo() { + getter_effect = 'PASS'; + }, + set bar(value) { + setter_effect = 'PASS'; + } +}; +let obj1 = { + __proto__: proto +}; +let obj2 = { + __proto__: proto +}; +let unused = obj1.foo; +obj2.bar = 0; + +assert.strictEqual(getter_effect, 'PASS'); +assert.strictEqual(setter_effect, 'PASS'); diff --git a/test/function/samples/re-export-default-import/_config.js b/test/function/samples/re-export-default-import/_config.js index 287c37f6c9b..412ac13e7bd 100644 --- a/test/function/samples/re-export-default-import/_config.js +++ b/test/function/samples/re-export-default-import/_config.js @@ -1,5 +1,5 @@ -module.exports = { +module.exports = defineTest({ description: 're-exports a default import' -}; +}); // test copied from https://github.com/esnext/es6-module-transpiler/tree/master/test/examples/re-export-default-import diff --git a/test/function/samples/re-export-namespace-import/_config.js b/test/function/samples/re-export-namespace-import/_config.js index f13ec5d8c74..36cdfe295ad 100644 --- a/test/function/samples/re-export-namespace-import/_config.js +++ b/test/function/samples/re-export-namespace-import/_config.js @@ -1,5 +1,5 @@ -module.exports = { +module.exports = defineTest({ description: 're-exports a namespace import' -}; +}); // test copied from https://github.com/esnext/es6-module-transpiler/tree/master/test/examples/re-export-namespace-import diff --git a/test/function/samples/re-export-own/_config.js b/test/function/samples/re-export-own/_config.js new file mode 100644 index 00000000000..e0c7fe5b87a --- /dev/null +++ b/test/function/samples/re-export-own/_config.js @@ -0,0 +1,24 @@ +const assert = require('node:assert'); + +module.exports = { + description: 'avoid using export.hasOwnProperty', + options: { + input: './main.js', + external: ['external'], + output: { + paths: { + external: `${__dirname}/external.js` + }, + format: 'cjs' + } + }, + exports(exports) { + assert.strictEqual(exports.hasOwnProperty, null); + assert.strictEqual(exports.name, null); + assert.strictEqual( + typeof Object.getOwnPropertyDescriptor(exports, 'hasOwnProperty').get, + 'function' + ); + assert.strictEqual(typeof Object.getOwnPropertyDescriptor(exports, 'name').get, 'function'); + } +}; diff --git a/test/function/samples/re-export-own/external.js b/test/function/samples/re-export-own/external.js new file mode 100644 index 00000000000..f9418b67533 --- /dev/null +++ b/test/function/samples/re-export-own/external.js @@ -0,0 +1,2 @@ +exports.hasOwnProperty = null; +exports.name = null; \ No newline at end of file diff --git a/test/function/samples/re-export-own/main.js b/test/function/samples/re-export-own/main.js new file mode 100644 index 00000000000..b0c28b94ab1 --- /dev/null +++ b/test/function/samples/re-export-own/main.js @@ -0,0 +1 @@ +export * from 'external'; \ No newline at end of file diff --git a/test/function/samples/reassign-array-literal-elements/_config.js b/test/function/samples/reassign-array-literal-elements/_config.js index cba1867556a..a0e0cc67550 100644 --- a/test/function/samples/reassign-array-literal-elements/_config.js +++ b/test/function/samples/reassign-array-literal-elements/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'makes sure reassignments of array elements are tracked' -}; +}); diff --git a/test/function/samples/reassign-computed-prototype/_config.js b/test/function/samples/reassign-computed-prototype/_config.js index 2af8b68f9aa..768bd663e99 100644 --- a/test/function/samples/reassign-computed-prototype/_config.js +++ b/test/function/samples/reassign-computed-prototype/_config.js @@ -1,6 +1,6 @@ -module.exports = { +module.exports = defineTest({ description: 'reassign function prototype via computed property access', context: { proto: 'prototype' } -}; +}); diff --git a/test/function/samples/reassign-constructor-parameter-property/_config.js b/test/function/samples/reassign-constructor-parameter-property/_config.js index c02ad7871b3..5dd1b893f6c 100644 --- a/test/function/samples/reassign-constructor-parameter-property/_config.js +++ b/test/function/samples/reassign-constructor-parameter-property/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'track reassignments of properties of constructor parameters' -}; +}); diff --git a/test/function/samples/reassign-double-declarations/_config.js b/test/function/samples/reassign-double-declarations/_config.js index 5128c5c83bc..8aa977c0079 100644 --- a/test/function/samples/reassign-double-declarations/_config.js +++ b/test/function/samples/reassign-double-declarations/_config.js @@ -1,3 +1,4 @@ -module.exports = { - description: 'makes sure reassignments of double declared variables and their initializers are tracked' -}; +module.exports = defineTest({ + description: + 'makes sure reassignments of double declared variables and their initializers are tracked' +}); diff --git a/test/function/samples/reassign-empty-objects/_config.js b/test/function/samples/reassign-empty-objects/_config.js index 89f1e63f714..230ac9fb891 100644 --- a/test/function/samples/reassign-empty-objects/_config.js +++ b/test/function/samples/reassign-empty-objects/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'track reassignments of empty objects (#2306)' -}; +}); diff --git a/test/function/samples/reassign-for-loop-declarations/_config.js b/test/function/samples/reassign-for-loop-declarations/_config.js index ffab3a88067..f5afcf4ee06 100644 --- a/test/function/samples/reassign-for-loop-declarations/_config.js +++ b/test/function/samples/reassign-for-loop-declarations/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'reassign for-loop declarations' -}; +}); diff --git a/test/function/samples/reassign-import-fails/_config.js b/test/function/samples/reassign-import-fails/_config.js deleted file mode 100644 index e4aaef4bcc5..00000000000 --- a/test/function/samples/reassign-import-fails/_config.js +++ /dev/null @@ -1,25 +0,0 @@ -const path = require('path'); - -module.exports = { - description: 'disallows assignments to imported bindings', - error: { - code: 'ILLEGAL_REASSIGNMENT', - message: `Illegal reassignment to import 'x'`, - id: path.join(__dirname, 'main.js'), - pos: 113, - watchFiles: [path.join(__dirname, 'main.js'), path.join(__dirname, 'foo.js')], - loc: { - file: path.join(__dirname, 'main.js'), - line: 8, - column: 0 - }, - frame: ` - 6: }); - 7: - 8: x = 10; - ^ - ` - } -}; - -// test copied from https://github.com/esnext/es6-module-transpiler/tree/master/test/examples/reassign-import-fails diff --git a/test/function/samples/reassign-import-not-at-top-level-fails/_config.js b/test/function/samples/reassign-import-not-at-top-level-fails/_config.js deleted file mode 100644 index 43d4f0d4e90..00000000000 --- a/test/function/samples/reassign-import-not-at-top-level-fails/_config.js +++ /dev/null @@ -1,26 +0,0 @@ -const path = require('path'); - -module.exports = { - description: 'disallows assignments to imported bindings not at the top level', - error: { - code: 'ILLEGAL_REASSIGNMENT', - message: `Illegal reassignment to import 'x'`, - id: path.join(__dirname, 'main.js'), - pos: 95, - watchFiles: [path.join(__dirname, 'main.js'), path.join(__dirname, 'foo.js')], - loc: { - file: path.join(__dirname, 'main.js'), - line: 7, - column: 2 - }, - frame: ` - 5: } - 6: export function bar () { - 7: x = 1; - ^ - 8: } - ` - } -}; - -// test copied from https://github.com/esnext/es6-module-transpiler/tree/master/test/examples/reassign-import-fails diff --git a/test/function/samples/reassign-namespace/_config.js b/test/function/samples/reassign-namespace/_config.js index 8bff57992fe..8466a6c756c 100644 --- a/test/function/samples/reassign-namespace/_config.js +++ b/test/function/samples/reassign-namespace/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'members of namespaces are reassigned when the namespace is passed to a function' -}; +}); diff --git a/test/function/samples/reassign-object-literal-1/_config.js b/test/function/samples/reassign-object-literal-1/_config.js index 3b6c0890ed9..49bf74fcc5c 100644 --- a/test/function/samples/reassign-object-literal-1/_config.js +++ b/test/function/samples/reassign-object-literal-1/_config.js @@ -1,3 +1,3 @@ -module.exports = { - description: 'track reassignments through object literals', -}; +module.exports = defineTest({ + description: 'track reassignments through object literals' +}); diff --git a/test/function/samples/reassign-object-literal-2/_config.js b/test/function/samples/reassign-object-literal-2/_config.js index 12977186e04..49bf74fcc5c 100644 --- a/test/function/samples/reassign-object-literal-2/_config.js +++ b/test/function/samples/reassign-object-literal-2/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'track reassignments through object literals' -}; +}); diff --git a/test/function/samples/reassign-parameter-property/_config.js b/test/function/samples/reassign-parameter-property/_config.js index 8d50d4d1fa6..f78a29bf0cc 100644 --- a/test/function/samples/reassign-parameter-property/_config.js +++ b/test/function/samples/reassign-parameter-property/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'track reassignments of properties of function parameters' -}; +}); diff --git a/test/function/samples/reassign-parameter/_config.js b/test/function/samples/reassign-parameter/_config.js index 1701a6f8311..2b73aa449ac 100644 --- a/test/function/samples/reassign-parameter/_config.js +++ b/test/function/samples/reassign-parameter/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'parameters can be reassigned/updated' -}; +}); diff --git a/test/function/samples/reassign-pattern-defaults/_config.js b/test/function/samples/reassign-pattern-defaults/_config.js index cc6fce1a3e1..46ee6049e09 100644 --- a/test/function/samples/reassign-pattern-defaults/_config.js +++ b/test/function/samples/reassign-pattern-defaults/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'makes sure reassignments of pattern defaults are tracked' -}; +}); diff --git a/test/function/samples/reassign-return-expression/_config.js b/test/function/samples/reassign-return-expression/_config.js index d9b72ad5e99..14cf0f453fa 100644 --- a/test/function/samples/reassign-return-expression/_config.js +++ b/test/function/samples/reassign-return-expression/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'track reassignments of single function return expressions' -}; +}); diff --git a/test/function/samples/reassign-return-expressions/_config.js b/test/function/samples/reassign-return-expressions/_config.js index 9b5f1416559..401837c2056 100644 --- a/test/function/samples/reassign-return-expressions/_config.js +++ b/test/function/samples/reassign-return-expressions/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'track reassignments of multiple function return expressions' -}; +}); diff --git a/test/function/samples/reassigned-parameter-side-effect/_config.js b/test/function/samples/reassigned-parameter-side-effect/_config.js new file mode 100644 index 00000000000..a1ffc02b258 --- /dev/null +++ b/test/function/samples/reassigned-parameter-side-effect/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'when a parameter is reassigned, hasEffectsOnInteractionAtPath returns true' +}); diff --git a/test/function/samples/reassigned-parameter-side-effect/main.js b/test/function/samples/reassigned-parameter-side-effect/main.js new file mode 100644 index 00000000000..b8d99e0d21b --- /dev/null +++ b/test/function/samples/reassigned-parameter-side-effect/main.js @@ -0,0 +1,14 @@ +function foo(a) { + a.x; +} +let sideEffect = false +foo({ + x: 1 +}); +foo({ + get x() { + sideEffect = true + }, +}); + +assert.equal(sideEffect, true) diff --git a/test/function/samples/reassigned-parameter/_config.js b/test/function/samples/reassigned-parameter/_config.js new file mode 100644 index 00000000000..5923f0afe5d --- /dev/null +++ b/test/function/samples/reassigned-parameter/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'parameters reassigned/updated should be detected' +}); diff --git a/test/function/samples/reassigned-parameter/main.js b/test/function/samples/reassigned-parameter/main.js new file mode 100644 index 00000000000..f2c6fe7d3f6 --- /dev/null +++ b/test/function/samples/reassigned-parameter/main.js @@ -0,0 +1,21 @@ +function f(a) { + assert.equal(a ? 'OK' : 'FAIL', 'OK'); + a = false; + assert.equal(a ? 'FAIL' : 'OK', 'OK'); +} + +f(true); + +function g(array) { + if (array === null) { + array = []; + } + + if (array) { + return 'OK'; + } + return array; +} + +assert.equal(g(null), 'OK'); + diff --git a/test/function/samples/reassigned-return-expression/_config.js b/test/function/samples/reassigned-return-expression/_config.js index 5223fccf634..96e9bc7acbf 100644 --- a/test/function/samples/reassigned-return-expression/_config.js +++ b/test/function/samples/reassigned-return-expression/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'does not bind return expressions before assignments are bound (#3382)' -}; +}); diff --git a/test/function/samples/recursive-calls-without-treeshake/_config.js b/test/function/samples/recursive-calls-without-treeshake/_config.js new file mode 100644 index 00000000000..9e859a0ff87 --- /dev/null +++ b/test/function/samples/recursive-calls-without-treeshake/_config.js @@ -0,0 +1,6 @@ +module.exports = defineTest({ + description: 'Avoid maximum call stack error with recursive calls when treeshake is disabled', + options: { + treeshake: false + } +}); diff --git a/test/function/samples/recursive-calls-without-treeshake/main.js b/test/function/samples/recursive-calls-without-treeshake/main.js new file mode 100644 index 00000000000..df7cfe3f7fc --- /dev/null +++ b/test/function/samples/recursive-calls-without-treeshake/main.js @@ -0,0 +1,10 @@ +function test(callback, index) { + if (index > 0) { + test(callback, index - 1); + } + callback(); +} + +let count = 0; +test(() => count++, 3); +assert.strictEqual(count, 4); diff --git a/test/function/samples/recursive-parameter-assignments/_config.js b/test/function/samples/recursive-parameter-assignments/_config.js index 80c1cc8f62d..152845f3dd7 100644 --- a/test/function/samples/recursive-parameter-assignments/_config.js +++ b/test/function/samples/recursive-parameter-assignments/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'Avoid maximum call stack error with recursive parameter assignments (#1710).' -}; +}); diff --git a/test/function/samples/recursive-parameter-assignments/main.js b/test/function/samples/recursive-parameter-assignments/main.js index 977b7089787..6b0b0ae7ccb 100644 --- a/test/function/samples/recursive-parameter-assignments/main.js +++ b/test/function/samples/recursive-parameter-assignments/main.js @@ -1,3 +1,5 @@ +let created = false; + class Test { constructor ( name, opts ) { opts = opts || {}; @@ -10,7 +12,10 @@ class Test { this.name = name; this.opts = opts; + // to make the function call not pure + created = true; } } new Test( 'a', {} ); +assert.equal( created, true ); diff --git a/test/function/samples/recursive-parameter-binding/_config.js b/test/function/samples/recursive-parameter-binding/_config.js new file mode 100644 index 00000000000..cfa558bff79 --- /dev/null +++ b/test/function/samples/recursive-parameter-binding/_config.js @@ -0,0 +1,4 @@ +module.exports = defineTest({ + description: + 'Avoid maximum call stack error, make sure parameter value is optimized before hasEffects (#5499).' +}); diff --git a/test/function/samples/recursive-parameter-binding/main.js b/test/function/samples/recursive-parameter-binding/main.js new file mode 100644 index 00000000000..cc7bdf352c3 --- /dev/null +++ b/test/function/samples/recursive-parameter-binding/main.js @@ -0,0 +1,26 @@ +let created = 0; + +function Test(options) { + if (!this) { + return new Test(options); + } + if (options.x) { + return 0; + } + created++; +} + +function Test2(options) { + if (!this) { + return new Test2(options); + } + if (options.x) { + return 0; + } + created++; +} + +new Test({}); +Test2`{}`; + +assert.equal(created, 2); diff --git a/test/function/samples/recursive-property-access/_config.js b/test/function/samples/recursive-property-access/_config.js new file mode 100644 index 00000000000..f9baf190c44 --- /dev/null +++ b/test/function/samples/recursive-property-access/_config.js @@ -0,0 +1,8 @@ +const assert = require('assert'); + +module.exports = defineTest({ + description: 'handles accessing different properties in recursive calls with good performance', + exports(exports) { + assert.strictEqual(exports.test({ u: { s: { w: 42 } } }), 42); + } +}); diff --git a/test/function/samples/recursive-property-access/main.js b/test/function/samples/recursive-property-access/main.js new file mode 100644 index 00000000000..6409ae14d16 --- /dev/null +++ b/test/function/samples/recursive-property-access/main.js @@ -0,0 +1,29 @@ +export function test(arg) { + if (arg.a) return test(arg.a); + if (arg.b) return test(arg.b); + if (arg.c) return test(arg.c); + if (arg.d) return test(arg.d); + if (arg.e) return test(arg.e); + if (arg.f) return test(arg.f); + if (arg.g) return test(arg.g); + if (arg.h) return test(arg.h); + if (arg.i) return test(arg.i); + if (arg.j) return test(arg.j); + if (arg.k) return test(arg.k); + if (arg.l) return test(arg.l); + if (arg.m) return test(arg.m); + if (arg.n) return test(arg.n); + if (arg.o) return test(arg.o); + if (arg.p) return test(arg.p); + if (arg.q) return test(arg.q); + if (arg.r) return test(arg.r); + if (arg.s) return test(arg.s); + if (arg.t) return test(arg.t); + if (arg.u) return test(arg.u); + if (arg.v) return test(arg.v); + if (arg.w) return test(arg.w); + if (arg.x) return test(arg.x); + if (arg.y) return test(arg.y); + if (arg.z) return test(arg.z); + return arg; +} diff --git a/test/function/samples/recursive-reexports/_config.js b/test/function/samples/recursive-reexports/_config.js new file mode 100644 index 00000000000..1fbde929b5e --- /dev/null +++ b/test/function/samples/recursive-reexports/_config.js @@ -0,0 +1,18 @@ +const assert = require('node:assert'); +const path = require('node:path'); +const ID_MAIN = path.join(__dirname, 'main.js'); +const ID_OTHER = path.join(__dirname, 'other.js'); + +module.exports = defineTest({ + description: 'handles recursive namespace reexports', + exports(exports) { + assert.deepStrictEqual(exports, { main: 'main', other: 'other' }); + }, + warnings: [ + { + code: 'CIRCULAR_DEPENDENCY', + ids: [ID_MAIN, ID_OTHER, ID_MAIN], + message: 'Circular dependency: main.js -> other.js -> main.js' + } + ] +}); diff --git a/test/function/samples/recursive-reexports/main.js b/test/function/samples/recursive-reexports/main.js new file mode 100644 index 00000000000..aa89b491fd7 --- /dev/null +++ b/test/function/samples/recursive-reexports/main.js @@ -0,0 +1,2 @@ +export * from './other.js'; +export const main = 'main'; diff --git a/test/function/samples/recursive-reexports/other.js b/test/function/samples/recursive-reexports/other.js new file mode 100644 index 00000000000..3c111285103 --- /dev/null +++ b/test/function/samples/recursive-reexports/other.js @@ -0,0 +1,2 @@ +export * from './main.js'; +export const other = 'other'; diff --git a/test/function/samples/redeclare-parameter/_config.js b/test/function/samples/redeclare-parameter/_config.js index e3d2ff620b0..7209c38dd9c 100644 --- a/test/function/samples/redeclare-parameter/_config.js +++ b/test/function/samples/redeclare-parameter/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'associates redeclared parameters (#2451)' -}; +}); diff --git a/test/function/samples/reexport-from-synthetic/_config.js b/test/function/samples/reexport-from-synthetic/_config.js index 7a0aa62df7a..a3a2728975b 100644 --- a/test/function/samples/reexport-from-synthetic/_config.js +++ b/test/function/samples/reexport-from-synthetic/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'handles reexporting a synthetic namespace from a non-synthetic module', options: { plugins: [ @@ -9,4 +9,4 @@ module.exports = { } ] } -}; +}); diff --git a/test/function/samples/reexport-missing-error/_config.js b/test/function/samples/reexport-missing-error/_config.js index 510b104cec1..f678eaf6783 100644 --- a/test/function/samples/reexport-missing-error/_config.js +++ b/test/function/samples/reexport-missing-error/_config.js @@ -1,22 +1,25 @@ -const path = require('path'); +const path = require('node:path'); +const ID_MAIN = path.join(__dirname, 'main.js'); +const ID_EMPTY = path.join(__dirname, 'empty.js'); -module.exports = { +module.exports = defineTest({ description: 'reexporting a missing identifier should print an error', error: { + binding: 'foo', code: 'MISSING_EXPORT', - message: `'foo' is not exported by empty.js, imported by main.js`, - id: path.join(__dirname, 'main.js'), + exporter: ID_EMPTY, + id: ID_MAIN, + url: 'https://rollupjs.org/troubleshooting/#error-name-is-not-exported-by-module', pos: 9, - watchFiles: [path.join(__dirname, 'main.js'), path.join(__dirname, 'empty.js')], loc: { - file: path.join(__dirname, 'main.js'), - line: 1, - column: 9 + column: 9, + file: ID_MAIN, + line: 1 }, frame: ` 1: export { foo as bar } from './empty.js'; - ^ - `, - url: 'https://rollupjs.org/guide/en/#error-name-is-not-exported-by-module' + ^`, + watchFiles: [ID_EMPTY, ID_MAIN], + message: 'main.js (1:9): "foo" is not exported by "empty.js", imported by "main.js".' } -}; +}); diff --git a/test/function/samples/reexport-ns/_config.js b/test/function/samples/reexport-ns/_config.js index e7c00efb391..251ca56d875 100644 --- a/test/function/samples/reexport-ns/_config.js +++ b/test/function/samples/reexport-ns/_config.js @@ -1,11 +1,11 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'external namespace reexport', options: { external: ['external'], output: { - namespaceToStringTag: true + generatedCode: { symbols: true } } }, exports(exports) { @@ -13,4 +13,4 @@ module.exports = { assert.strictEqual(exports[Symbol.toStringTag], 'Module'); assert.strictEqual(exports.maths.external, true); } -}; +}); diff --git a/test/function/samples/reexports-from-external/_config.js b/test/function/samples/reexports-from-external/_config.js index a95f28df132..a614d7550ff 100644 --- a/test/function/samples/reexports-from-external/_config.js +++ b/test/function/samples/reexports-from-external/_config.js @@ -1,6 +1,6 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 're-exports * from external module (#791)', options: { external: ['external'] @@ -19,4 +19,4 @@ module.exports = { assert.equal(exports.foo, 1); assert.equal(exports.bar, 2); } -}; +}); diff --git a/test/function/samples/relative-external-include-once-nested/_config.js b/test/function/samples/relative-external-include-once-nested/_config.js index bf20b704d91..7826d561b45 100644 --- a/test/function/samples/relative-external-include-once-nested/_config.js +++ b/test/function/samples/relative-external-include-once-nested/_config.js @@ -1,7 +1,7 @@ -const assert = require('assert'); -const path = require('path'); +const assert = require('node:assert'); +const path = require('node:path'); -module.exports = { +module.exports = defineTest({ description: 'includes a relative external module only once (nested version)', options: { external: path.join(__dirname, './first/foo.js') @@ -15,4 +15,4 @@ module.exports = { exports(exports) { assert.equal(exports, 3); } -}; +}); diff --git a/test/function/samples/relative-external-include-once-two-external/_config.js b/test/function/samples/relative-external-include-once-two-external/_config.js index b2f5f33c310..e73c40325f3 100644 --- a/test/function/samples/relative-external-include-once-two-external/_config.js +++ b/test/function/samples/relative-external-include-once-two-external/_config.js @@ -1,18 +1,18 @@ -const assert = require('assert'); -const path = require('path'); +const assert = require('node:assert'); +const path = require('node:path'); -module.exports = { +module.exports = defineTest({ description: 'includes a relative external module only once (two external deps)', options: { external: [path.join(__dirname, './foo.js'), path.join(__dirname, './first/foo.js')] }, context: { require(required) { - assert(['./foo.js', './first/foo.js'].indexOf(required) !== -1, 'required wrong module'); + assert.ok(['./foo.js', './first/foo.js'].includes(required), 'required wrong module'); return required === './foo.js' ? 'a' : 'b'; } }, exports(exports) { - assert(exports === 'ab' || exports === 'ba', 'two different modules should be required'); + assert.ok(exports === 'ab' || exports === 'ba', 'two different modules should be required'); } -}; +}); diff --git a/test/function/samples/relative-external-include-once-up/_config.js b/test/function/samples/relative-external-include-once-up/_config.js index bfbac3af0d8..8c9b1adc025 100644 --- a/test/function/samples/relative-external-include-once-up/_config.js +++ b/test/function/samples/relative-external-include-once-up/_config.js @@ -1,7 +1,7 @@ -const assert = require('assert'); -const path = require('path'); +const assert = require('node:assert'); +const path = require('node:path'); -module.exports = { +module.exports = defineTest({ description: 'includes a relative external module only once (from upper directory too)', options: { input: path.join(__dirname, 'first', 'main.js'), @@ -16,4 +16,4 @@ module.exports = { exports(exports) { assert.equal(exports, 3); } -}; +}); diff --git a/test/function/samples/relative-external-include-once/_config.js b/test/function/samples/relative-external-include-once/_config.js index a8e9bd3a43e..2650715af66 100644 --- a/test/function/samples/relative-external-include-once/_config.js +++ b/test/function/samples/relative-external-include-once/_config.js @@ -1,7 +1,7 @@ -const assert = require('assert'); -const path = require('path'); +const assert = require('node:assert'); +const path = require('node:path'); -module.exports = { +module.exports = defineTest({ description: 'includes a relative external module only once', options: { external: path.join(__dirname, './foo.js') @@ -15,4 +15,4 @@ module.exports = { exports(exports) { assert.equal(exports, 3); } -}; +}); diff --git a/test/function/samples/relative-outside-external/_config.js b/test/function/samples/relative-outside-external/_config.js index 1f9b807717d..eb14033e0a2 100644 --- a/test/function/samples/relative-outside-external/_config.js +++ b/test/function/samples/relative-outside-external/_config.js @@ -1,7 +1,7 @@ -const assert = require('assert'); +const assert = require('node:assert'); const cwd = process.cwd; -module.exports = { +module.exports = defineTest({ description: 'correctly resolves relative external imports from outside directories', options: { external() { @@ -20,4 +20,4 @@ module.exports = { process.cwd = cwd; assert.strictEqual(exports.value, '../../../test.js'); } -}; +}); diff --git a/test/function/samples/removes-empty-exported-vars/_config.js b/test/function/samples/removes-empty-exported-vars/_config.js index df73cc46231..231e6509a45 100644 --- a/test/function/samples/removes-empty-exported-vars/_config.js +++ b/test/function/samples/removes-empty-exported-vars/_config.js @@ -1,8 +1,8 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'removes empty exported var declarations', exports(exports) { assert.equal(exports.foo, 42); } -}; +}); diff --git a/test/function/samples/rename-conditional-expression-children/_config.js b/test/function/samples/rename-conditional-expression-children/_config.js index 7c052c5cd17..81fe5e52797 100644 --- a/test/function/samples/rename-conditional-expression-children/_config.js +++ b/test/function/samples/rename-conditional-expression-children/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'correctly renders children of ConditionalExpressions' -}; +}); diff --git a/test/function/samples/rename-default-export/_config.js b/test/function/samples/rename-default-export/_config.js index 124869aff3d..102b9875260 100644 --- a/test/function/samples/rename-default-export/_config.js +++ b/test/function/samples/rename-default-export/_config.js @@ -1,9 +1,9 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'avoids SyntaxError with default token (#33)', exports(exports) { assert.equal(exports.foo, 42); assert.equal(exports.bar, 42); } -}; +}); diff --git a/test/function/samples/renamed-arguments/_config.js b/test/function/samples/renamed-arguments/_config.js index 4eb31e33ab4..dd3abbc8bf9 100644 --- a/test/function/samples/renamed-arguments/_config.js +++ b/test/function/samples/renamed-arguments/_config.js @@ -1,10 +1,10 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'function arguments are renamed as appropriate (#32)', exports(exports) { - const obj = {}; + const object = {}; assert.strictEqual(exports.foo(), 42); - assert.strictEqual(exports.bar(obj), obj); + assert.strictEqual(exports.bar(object), object); } -}; +}); diff --git a/test/function/samples/render-chunk-async/_config.js b/test/function/samples/render-chunk-async/_config.js index 7fb0f09887c..a64a861caf3 100644 --- a/test/function/samples/render-chunk-async/_config.js +++ b/test/function/samples/render-chunk-async/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'bundle transformers can be asynchronous', options: { plugins: [ @@ -19,4 +19,4 @@ module.exports = { } ] } -}; +}); diff --git a/test/function/samples/resolve-id-object/_config.js b/test/function/samples/resolve-id-object/_config.js index aace40222ef..ebb1f5b500d 100644 --- a/test/function/samples/resolve-id-object/_config.js +++ b/test/function/samples/resolve-id-object/_config.js @@ -1,21 +1,26 @@ -const path = require('path'); +const path = require('node:path'); -module.exports = { +module.exports = defineTest({ description: 'allows resolving an id with an object', options: { - plugins: { - resolveId(importee) { - const fooId = path.join(__dirname, 'foo.js'); - switch (importee) { - case 'internal1': - return { id: fooId }; - case 'internal2': - return { id: fooId, external: false }; - case 'external': - return { id: 'my-external', external: true }; + plugins: [ + { + resolveId(importee) { + const fooId = path.join(__dirname, 'foo.js'); + switch (importee) { + case 'internal1': { + return { id: fooId }; + } + case 'internal2': { + return { id: fooId, external: false }; + } + case 'external': { + return { id: 'my-external', external: true }; + } + } } } - } + ] }, context: { require(id) { @@ -25,4 +30,4 @@ module.exports = { throw new Error(`Unexpected external id ${id}.`); } } -}; +}); diff --git a/test/function/samples/resolve-relative-external-id/_config.js b/test/function/samples/resolve-relative-external-id/_config.js index f6a6d451524..07a900195e1 100644 --- a/test/function/samples/resolve-relative-external-id/_config.js +++ b/test/function/samples/resolve-relative-external-id/_config.js @@ -1,30 +1,36 @@ -const assert = require('assert'); -const path = require('path'); +const assert = require('node:assert'); +const path = require('node:path'); -module.exports = { +module.exports = defineTest({ description: 'resolves relative external ids', options: { external: [path.join(__dirname, 'external.js'), path.join(__dirname, 'nested', 'external.js')], - plugins: { - async buildStart() { - assert.deepStrictEqual(await this.resolve('./external.js'), { - external: true, - id: path.join(__dirname, 'external.js'), - meta: {}, - moduleSideEffects: true, - syntheticNamedExports: false - }); - assert.deepStrictEqual( - await this.resolve('./external.js', path.join(__dirname, 'nested', 'some-file.js')), - { + plugins: [ + { + async buildStart() { + assert.deepStrictEqual(await this.resolve('./external.js'), { + attributes: {}, external: true, - id: path.join(__dirname, 'nested', 'external.js'), + id: path.join(__dirname, 'external.js'), meta: {}, moduleSideEffects: true, + resolvedBy: 'rollup', syntheticNamedExports: false - } - ); + }); + assert.deepStrictEqual( + await this.resolve('./external.js', path.join(__dirname, 'nested', 'some-file.js')), + { + attributes: {}, + external: true, + id: path.join(__dirname, 'nested', 'external.js'), + meta: {}, + moduleSideEffects: true, + resolvedBy: 'rollup', + syntheticNamedExports: false + } + ); + } } - } + ] } -}; +}); diff --git a/test/function/samples/resolve-unordered-assignments-2/_config.js b/test/function/samples/resolve-unordered-assignments-2/_config.js index 9655f7bb525..d429eda511b 100644 --- a/test/function/samples/resolve-unordered-assignments-2/_config.js +++ b/test/function/samples/resolve-unordered-assignments-2/_config.js @@ -1,8 +1,8 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'Assignments should be correctly bound independent of their order', exports(exports) { assert.equal(exports.baz, 'present'); } -}; +}); diff --git a/test/function/samples/resolve-unordered-assignments/_config.js b/test/function/samples/resolve-unordered-assignments/_config.js index 9655f7bb525..d429eda511b 100644 --- a/test/function/samples/resolve-unordered-assignments/_config.js +++ b/test/function/samples/resolve-unordered-assignments/_config.js @@ -1,8 +1,8 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'Assignments should be correctly bound independent of their order', exports(exports) { assert.equal(exports.baz, 'present'); } -}; +}); diff --git a/test/function/samples/resolveid-is-entry/_config.js b/test/function/samples/resolveid-is-entry/_config.js new file mode 100644 index 00000000000..ac7436ef12d --- /dev/null +++ b/test/function/samples/resolveid-is-entry/_config.js @@ -0,0 +1,83 @@ +const assert = require('node:assert'); +const path = require('node:path'); + +const ID_MAIN = path.join(__dirname, 'main.js'); + +module.exports = defineTest({ + description: 'sends correct isEntry information to resolveId hooks', + options: { + plugins: [ + { + async buildStart() { + return Promise.all([ + this.emitFile({ type: 'chunk', id: 'chunkWithoutImporter.js' }), + this.emitFile({ type: 'chunk', id: './chunkWithImporter.js', importer: ID_MAIN }), + this.resolve('./resolutionWithoutImporter'), + this.resolve('./resolutionWithoutImporterEntry', undefined, { isEntry: true }), + this.resolve('./resolutionWithoutImporterNonEntry', undefined, { isEntry: false }), + this.resolve('./resolutionWithImporter', ID_MAIN), + this.resolve('./resolutionWithImporterEntry', ID_MAIN, { isEntry: true }), + this.resolve('./resolutionWithImporterNonEntry', ID_MAIN, { isEntry: false }) + ]); + }, + resolveId(source, importer, { isEntry }) { + switch (source) { + case ID_MAIN: { + assert.strictEqual(importer, undefined, source); + assert.strictEqual(isEntry, true, source); + break; + } + case './dep.js': { + assert.strictEqual(importer, ID_MAIN, source); + assert.strictEqual(isEntry, false, source); + break; + } + case 'chunkWithoutImporter.js': { + assert.strictEqual(importer, undefined, source); + assert.strictEqual(isEntry, true, source); + break; + } + case './chunkWithImporter.js': { + assert.strictEqual(importer, ID_MAIN, source); + assert.strictEqual(isEntry, true, source); + break; + } + case './resolutionWithoutImporter': { + assert.strictEqual(importer, undefined, source); + assert.strictEqual(isEntry, true, source); + break; + } + case './resolutionWithoutImporterEntry': { + assert.strictEqual(importer, undefined, source); + assert.strictEqual(isEntry, true, source); + break; + } + case './resolutionWithoutImporterNonEntry': { + assert.strictEqual(importer, undefined, source); + assert.strictEqual(isEntry, false, source); + break; + } + case './resolutionWithImporter': { + assert.strictEqual(importer, ID_MAIN, source); + assert.strictEqual(isEntry, false, source); + break; + } + case './resolutionWithImporterEntry': { + assert.strictEqual(importer, ID_MAIN, source); + assert.strictEqual(isEntry, true, source); + break; + } + case './resolutionWithImporterNonEntry': { + assert.strictEqual(importer, ID_MAIN, source); + assert.strictEqual(isEntry, false, source); + break; + } + default: { + throw new Error(`Unexpected resolution of ${source}`); + } + } + } + } + ] + } +}); diff --git a/test/function/samples/resolveid-is-entry/chunkWithImporter.js b/test/function/samples/resolveid-is-entry/chunkWithImporter.js new file mode 100644 index 00000000000..090d82c998d --- /dev/null +++ b/test/function/samples/resolveid-is-entry/chunkWithImporter.js @@ -0,0 +1 @@ +console.log('with'); diff --git a/test/function/samples/resolveid-is-entry/chunkWithoutImporter.js b/test/function/samples/resolveid-is-entry/chunkWithoutImporter.js new file mode 100644 index 00000000000..63b0787fe6a --- /dev/null +++ b/test/function/samples/resolveid-is-entry/chunkWithoutImporter.js @@ -0,0 +1 @@ +console.log('without'); diff --git a/test/function/samples/resolveid-is-entry/dep.js b/test/function/samples/resolveid-is-entry/dep.js new file mode 100644 index 00000000000..7a4e8a723a4 --- /dev/null +++ b/test/function/samples/resolveid-is-entry/dep.js @@ -0,0 +1 @@ +export default 42; diff --git a/test/function/samples/resolveid-is-entry/main.js b/test/function/samples/resolveid-is-entry/main.js new file mode 100644 index 00000000000..57c61d3c5f2 --- /dev/null +++ b/test/function/samples/resolveid-is-entry/main.js @@ -0,0 +1,3 @@ +import value from './dep.js'; + +assert.strictEqual(value, 42); diff --git a/test/function/samples/resolveid-is-entry/resolutionWithImporter.js b/test/function/samples/resolveid-is-entry/resolutionWithImporter.js new file mode 100644 index 00000000000..090d82c998d --- /dev/null +++ b/test/function/samples/resolveid-is-entry/resolutionWithImporter.js @@ -0,0 +1 @@ +console.log('with'); diff --git a/test/function/samples/resolveid-is-entry/resolutionWithImporterEntry.js b/test/function/samples/resolveid-is-entry/resolutionWithImporterEntry.js new file mode 100644 index 00000000000..26f0cb2cc4d --- /dev/null +++ b/test/function/samples/resolveid-is-entry/resolutionWithImporterEntry.js @@ -0,0 +1 @@ +console.log('with entry'); diff --git a/test/function/samples/resolveid-is-entry/resolutionWithImporterNonEntry.js b/test/function/samples/resolveid-is-entry/resolutionWithImporterNonEntry.js new file mode 100644 index 00000000000..daa7098b591 --- /dev/null +++ b/test/function/samples/resolveid-is-entry/resolutionWithImporterNonEntry.js @@ -0,0 +1 @@ +console.log('with non entry'); diff --git a/test/function/samples/resolveid-is-entry/resolutionWithoutImporter.js b/test/function/samples/resolveid-is-entry/resolutionWithoutImporter.js new file mode 100644 index 00000000000..63b0787fe6a --- /dev/null +++ b/test/function/samples/resolveid-is-entry/resolutionWithoutImporter.js @@ -0,0 +1 @@ +console.log('without'); diff --git a/test/function/samples/resolveid-is-entry/resolutionWithoutImporterEntry.js b/test/function/samples/resolveid-is-entry/resolutionWithoutImporterEntry.js new file mode 100644 index 00000000000..63d99dd46fa --- /dev/null +++ b/test/function/samples/resolveid-is-entry/resolutionWithoutImporterEntry.js @@ -0,0 +1 @@ +console.log('without entry'); diff --git a/test/function/samples/resolveid-is-entry/resolutionWithoutImporterNonEntry.js b/test/function/samples/resolveid-is-entry/resolutionWithoutImporterNonEntry.js new file mode 100644 index 00000000000..cb47020f873 --- /dev/null +++ b/test/function/samples/resolveid-is-entry/resolutionWithoutImporterNonEntry.js @@ -0,0 +1 @@ +console.log('without non entry'); diff --git a/test/function/samples/resolveid-recursive-call/_config.js b/test/function/samples/resolveid-recursive-call/_config.js new file mode 100644 index 00000000000..68f2be786b6 --- /dev/null +++ b/test/function/samples/resolveid-recursive-call/_config.js @@ -0,0 +1,27 @@ +module.exports = defineTest({ + description: + 'skipSelf: true option in resolveId hook option should skip the plugin if it has been called before with the same id and importer, see #5768 for more details', + options: { + plugins: [ + { + name: 'r1', + async resolveId(id) { + const importer = 'foo'; + return (await this.resolve(id, importer)) ?? 'success'; + }, + load(id) { + if (id === 'success') { + return { code: 'export default 1' }; + } + } + }, + { + name: 'r2', + resolveId(id) { + const importer = 'bar'; + return this.resolve(id, importer); + } + } + ] + } +}); diff --git a/test/function/samples/resolveid-recursive-call/main.js b/test/function/samples/resolveid-recursive-call/main.js new file mode 100644 index 00000000000..545a30f6769 --- /dev/null +++ b/test/function/samples/resolveid-recursive-call/main.js @@ -0,0 +1,3 @@ +import val from 'virtual' + +assert.strictEqual(val, 1) diff --git a/test/function/samples/resolves-namespace-default/_config.js b/test/function/samples/resolves-namespace-default/_config.js index 5b6a733fbf4..0303e9eb5a9 100644 --- a/test/function/samples/resolves-namespace-default/_config.js +++ b/test/function/samples/resolves-namespace-default/_config.js @@ -1,9 +1,9 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: "namespace's 'default' properties should be available", exports(exports) { assert.equal(exports, 42); } -}; +}); diff --git a/test/function/samples/respect-default-export-reexporter-side-effects/_config.js b/test/function/samples/respect-default-export-reexporter-side-effects/_config.js index 7ddf180ef45..23ce63b913f 100644 --- a/test/function/samples/respect-default-export-reexporter-side-effects/_config.js +++ b/test/function/samples/respect-default-export-reexporter-side-effects/_config.js @@ -1,8 +1,8 @@ -module.exports = { +module.exports = defineTest({ description: 'respect side-effects in reexporting modules even if moduleSideEffects are off', options: { treeshake: { moduleSideEffects: false } } -}; +}); diff --git a/test/function/samples/respect-reexporter-side-effects/_config.js b/test/function/samples/respect-reexporter-side-effects/_config.js index 7ddf180ef45..23ce63b913f 100644 --- a/test/function/samples/respect-reexporter-side-effects/_config.js +++ b/test/function/samples/respect-reexporter-side-effects/_config.js @@ -1,8 +1,8 @@ -module.exports = { +module.exports = defineTest({ description: 'respect side-effects in reexporting modules even if moduleSideEffects are off', options: { treeshake: { moduleSideEffects: false } } -}; +}); diff --git a/test/function/samples/respect-synthetic-export-reexporter-side-effects/_config.js b/test/function/samples/respect-synthetic-export-reexporter-side-effects/_config.js index 0afd5749ba1..12962903ccf 100644 --- a/test/function/samples/respect-synthetic-export-reexporter-side-effects/_config.js +++ b/test/function/samples/respect-synthetic-export-reexporter-side-effects/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'respect side-effects in reexporting modules even if moduleSideEffects are off', options: { treeshake: { @@ -12,4 +12,4 @@ module.exports = { } ] } -}; +}); diff --git a/test/function/samples/rest-element-argument/_config.js b/test/function/samples/rest-element-argument/_config.js new file mode 100644 index 00000000000..94ba551608c --- /dev/null +++ b/test/function/samples/rest-element-argument/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'restelement argument should deoptimize parameter value' +}); diff --git a/test/function/samples/rest-element-argument/main.js b/test/function/samples/rest-element-argument/main.js new file mode 100644 index 00000000000..a31e007fe4f --- /dev/null +++ b/test/function/samples/rest-element-argument/main.js @@ -0,0 +1,21 @@ +let hasArg0 = false; +let hasArg1 = false; +let hasArg2 = false; + +function foo(arg0, arg1, arg2) { + if (arg0) { + hasArg0 = true; + } + if (arg1) { + hasArg1 = true; + } + if (arg2) { + hasArg2 = true; + } +} + +foo(...['arg0', 'arg1']); + +assert.equal(hasArg0, true); +assert.equal(hasArg1, true); +assert.equal(hasArg2, false); diff --git a/test/function/samples/retain-unknown-prototype-access/_config.js b/test/function/samples/retain-unknown-prototype-access/_config.js new file mode 100644 index 00000000000..089cb025233 --- /dev/null +++ b/test/function/samples/retain-unknown-prototype-access/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'treats unknown builtin prototype properties as unknown' +}); diff --git a/test/function/samples/retain-unknown-prototype-access/main.js b/test/function/samples/retain-unknown-prototype-access/main.js new file mode 100644 index 00000000000..c7c27ed245f --- /dev/null +++ b/test/function/samples/retain-unknown-prototype-access/main.js @@ -0,0 +1,10 @@ +Object.defineProperty(Array.prototype, 'isEmpty', { + get() { + return this.length === 0; + } +}); + +const array = []; +assert.strictEqual(array.isEmpty ? 'works' : 'broken', 'works'); +array.push('foo'); +assert.strictEqual(array.isEmpty ? 'broken' : 'works', 'works'); diff --git a/test/function/samples/retains-sort-order-b/_config.js b/test/function/samples/retains-sort-order-b/_config.js index ed8307000d9..9a27285e3b8 100644 --- a/test/function/samples/retains-sort-order-b/_config.js +++ b/test/function/samples/retains-sort-order-b/_config.js @@ -1,8 +1,8 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'sorts statements according to their original order within modules, part 2', exports(exports) { assert.equal(exports.answer, 42); } -}; +}); diff --git a/test/function/samples/retains-sort-order/_config.js b/test/function/samples/retains-sort-order/_config.js index 0db772463ee..34c4d65e12c 100644 --- a/test/function/samples/retains-sort-order/_config.js +++ b/test/function/samples/retains-sort-order/_config.js @@ -1,8 +1,8 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'sorts statements according to their original order within modules', exports(exports) { assert.equal(exports, 'GREAT SUCCESS'); } -}; +}); diff --git a/test/function/samples/return-expression-depending-on-conditional/_config.js b/test/function/samples/return-expression-depending-on-conditional/_config.js index 2c6c915c647..a09f7f1414a 100644 --- a/test/function/samples/return-expression-depending-on-conditional/_config.js +++ b/test/function/samples/return-expression-depending-on-conditional/_config.js @@ -1,3 +1,4 @@ -module.exports = { - description: 'tracks return expressions that depend on conditional expressions that are deoptimized at some point' -}; +module.exports = defineTest({ + description: + 'tracks return expressions that depend on conditional expressions that are deoptimized at some point' +}); diff --git a/test/function/samples/returned-array-mutation/_config.js b/test/function/samples/returned-array-mutation/_config.js new file mode 100644 index 00000000000..7aedc8b8dad --- /dev/null +++ b/test/function/samples/returned-array-mutation/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'tracks array mutations' +}); diff --git a/test/function/samples/returned-array-mutation/main.js b/test/function/samples/returned-array-mutation/main.js new file mode 100644 index 00000000000..f680ec45ffc --- /dev/null +++ b/test/function/samples/returned-array-mutation/main.js @@ -0,0 +1,13 @@ +let push = false; + +const getArray = () => { + const array = []; + if (push) { + array.push(true); + } + return array; +}; + +assert.strictEqual(getArray()[0] || false, false); +push = true; +assert.strictEqual(getArray()[0] || false, true); diff --git a/test/function/samples/reuse-resolve-meta/_config.js b/test/function/samples/reuse-resolve-meta/_config.js new file mode 100644 index 00000000000..f402fae46e4 --- /dev/null +++ b/test/function/samples/reuse-resolve-meta/_config.js @@ -0,0 +1,29 @@ +const assert = require('node:assert'); +const path = require('node:path'); +const meta = { plugin: { initial: true } }; + +const ID_MAIN = path.join(__dirname, 'main.js'); + +module.exports = defineTest({ + description: 'does not modify meta objects passed in resolveId', + options: { + plugins: [ + { + async resolveId(source, importer) { + const { id } = await this.resolve(source, importer); + return { id, meta }; + }, + transform(code) { + return { code, meta: { otherPlugin: { ignored: true }, plugin: { replaced: true } } }; + }, + buildEnd() { + assert.deepStrictEqual(meta, { plugin: { initial: true } }); + assert.deepStrictEqual(this.getModuleInfo(ID_MAIN).meta, { + otherPlugin: { ignored: true }, + plugin: { replaced: true } + }); + } + } + ] + } +}); diff --git a/test/function/samples/reuse-resolve-meta/main.js b/test/function/samples/reuse-resolve-meta/main.js new file mode 100644 index 00000000000..cc1d88a24fa --- /dev/null +++ b/test/function/samples/reuse-resolve-meta/main.js @@ -0,0 +1 @@ +assert.ok(true); diff --git a/test/function/samples/rewrite-member-expressions/_config.js b/test/function/samples/rewrite-member-expressions/_config.js index ec5c85601ae..77b6b8b22e6 100644 --- a/test/function/samples/rewrite-member-expressions/_config.js +++ b/test/function/samples/rewrite-member-expressions/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'rewrites identifiers at the head of member expressions' -}; +}); diff --git a/test/function/samples/self-referencing-namespace/_config.js b/test/function/samples/self-referencing-namespace/_config.js new file mode 100644 index 00000000000..23f72813d34 --- /dev/null +++ b/test/function/samples/self-referencing-namespace/_config.js @@ -0,0 +1,23 @@ +const assert = require('node:assert'); +const path = require('node:path'); + +const ID_MAIN = path.join(__dirname, 'main.js'); + +module.exports = defineTest({ + description: 'supports dynamic namespaces that reference themselves', + options: { + output: { generatedCode: { constBindings: true } } + }, + exports(exports) { + assert.strictEqual(exports.foo, 'foo'); + assert.strictEqual(exports.ns.foo, 'foo'); + assert.strictEqual(exports.ns.ns.foo, 'foo'); + }, + warnings: [ + { + code: 'CIRCULAR_DEPENDENCY', + ids: [ID_MAIN, ID_MAIN], + message: 'Circular dependency: main.js -> main.js' + } + ] +}); diff --git a/test/function/samples/self-referencing-namespace/main.js b/test/function/samples/self-referencing-namespace/main.js new file mode 100644 index 00000000000..53ad7e51e54 --- /dev/null +++ b/test/function/samples/self-referencing-namespace/main.js @@ -0,0 +1,2 @@ +export * as ns from './main.js'; +export const foo = 'foo'; diff --git a/test/function/samples/sequence-expression/_config.js b/test/function/samples/sequence-expression/_config.js index fbf4519aace..e23f4ebf348 100644 --- a/test/function/samples/sequence-expression/_config.js +++ b/test/function/samples/sequence-expression/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'do not change context of callable in sequence expressions' -}; +}); diff --git a/test/function/samples/sequence-expressions-template-tag/_config.js b/test/function/samples/sequence-expressions-template-tag/_config.js new file mode 100644 index 00000000000..848adc8d6a6 --- /dev/null +++ b/test/function/samples/sequence-expressions-template-tag/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'uses corrrect "this" for tagged template expressions in simplified sequences' +}); diff --git a/test/function/samples/sequence-expressions-template-tag/main.js b/test/function/samples/sequence-expressions-template-tag/main.js new file mode 100644 index 00000000000..7bcdd059109 --- /dev/null +++ b/test/function/samples/sequence-expressions-template-tag/main.js @@ -0,0 +1,13 @@ +let o = { + f() { + assert.ok(this !== o); + } +}; +(1, o.f)(); +(1, o.f)``; + +(true && o.f)(); +(true && o.f)``; + +(true ? o.f : false)(); +(true ? o.f : false)``; diff --git a/test/function/samples/shadowed-external-export/_config.js b/test/function/samples/shadowed-external-export/_config.js index fc9405b32f1..8a33feb5e79 100644 --- a/test/function/samples/shadowed-external-export/_config.js +++ b/test/function/samples/shadowed-external-export/_config.js @@ -1,6 +1,6 @@ -module.exports = { +module.exports = defineTest({ description: 'external modules are not shadowed', options: { external: ['path'] } -}; +}); diff --git a/test/function/samples/shadowed-namespace-b/_config.js b/test/function/samples/shadowed-namespace-b/_config.js index fba6d0d98e0..902a8a9f973 100644 --- a/test/function/samples/shadowed-namespace-b/_config.js +++ b/test/function/samples/shadowed-namespace-b/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'namespaces are not shadowed (b)' -}; +}); diff --git a/test/function/samples/shadowed-namespace/_config.js b/test/function/samples/shadowed-namespace/_config.js index f0d7f7a4155..e8e90c5ee51 100644 --- a/test/function/samples/shadowed-namespace/_config.js +++ b/test/function/samples/shadowed-namespace/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'namespaces are not shadowed' -}; +}); diff --git a/test/function/samples/shadowed-variables/_config.js b/test/function/samples/shadowed-variables/_config.js index d2455d30459..dffb5dd4307 100644 --- a/test/function/samples/shadowed-variables/_config.js +++ b/test/function/samples/shadowed-variables/_config.js @@ -1,5 +1,5 @@ -module.exports = { +module.exports = defineTest({ description: 'renames shadowed variables correctly' -}; +}); // test copied from https://github.com/esnext/es6-module-transpiler/tree/master/test/examples/named-function-expression diff --git a/test/function/samples/shims-missing-exports/_config.js b/test/function/samples/shims-missing-exports/_config.js index b42cf617173..e824bb64e9e 100644 --- a/test/function/samples/shims-missing-exports/_config.js +++ b/test/function/samples/shims-missing-exports/_config.js @@ -1,14 +1,17 @@ -module.exports = { +const path = require('node:path'); +const ID_DEP1 = path.join(__dirname, 'dep1.js'); + +module.exports = defineTest({ description: 'shims missing exports', options: { shimMissingExports: true }, warnings: [ { + binding: 'missing', code: 'SHIMMED_EXPORT', - message: 'Missing export "missing" has been shimmed in module dep1.js.', - exporter: "dep1.js", - exportName: 'missing' + exporter: ID_DEP1, + message: 'Missing export "missing" has been shimmed in module "dep1.js".' } ] -}; +}); diff --git a/test/function/samples/shims-missing-exports/main.js b/test/function/samples/shims-missing-exports/main.js index cc652c34e2e..7db98642c1c 100644 --- a/test/function/samples/shims-missing-exports/main.js +++ b/test/function/samples/shims-missing-exports/main.js @@ -1,3 +1,3 @@ import { missing } from './dep1.js'; -export {missing} +export { missing }; diff --git a/test/function/samples/side-effect-free-module-function/_config.js b/test/function/samples/side-effect-free-module-function/_config.js index 7338de6c86e..d354e31436b 100644 --- a/test/function/samples/side-effect-free-module-function/_config.js +++ b/test/function/samples/side-effect-free-module-function/_config.js @@ -1,11 +1,13 @@ -module.exports = { +module.exports = defineTest({ description: 'correctly include functions with side effects from side-effect-free modules (#3942)', options: { - plugins: { - transform() { - return { moduleSideEffects: false }; + plugins: [ + { + transform() { + return { moduleSideEffects: false }; + } } - } + ] } -}; +}); diff --git a/test/function/samples/side-effects-only-default-exports/_config.js b/test/function/samples/side-effects-only-default-exports/_config.js index 97601af3786..1aba737cc45 100644 --- a/test/function/samples/side-effects-only-default-exports/_config.js +++ b/test/function/samples/side-effects-only-default-exports/_config.js @@ -1,7 +1,7 @@ -const assert = require('assert'); +const assert = require('node:assert'); const mutated = {}; -module.exports = { +module.exports = defineTest({ description: 'Wraps inlined default exports which are rendered for side-effects only', options: { external: ['external'] @@ -15,4 +15,4 @@ module.exports = { assert.ok(mutated.extremelyMutated); assert.ok(mutated.utterlyMutated); } -}; +}); diff --git a/test/function/samples/simplified-nested-if/_config.js b/test/function/samples/simplified-nested-if/_config.js index 6e442a83103..0697a089652 100644 --- a/test/function/samples/simplified-nested-if/_config.js +++ b/test/function/samples/simplified-nested-if/_config.js @@ -1,7 +1,7 @@ -module.exports = { +module.exports = defineTest({ description: 'do not catch else branches from parent if statements when simplifiying if-statements', context: { unknown: true } -}; +}); diff --git a/test/function/samples/simplify-arrow-expression-with-object/_config.js b/test/function/samples/simplify-arrow-expression-with-object/_config.js index f4acb800e59..7f9cf90e15b 100644 --- a/test/function/samples/simplify-arrow-expression-with-object/_config.js +++ b/test/function/samples/simplify-arrow-expression-with-object/_config.js @@ -1,9 +1,9 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'correctly simplifies arrow expressions where the right hand side becomes an object', exports(exports) { assert.deepStrictEqual(exports.conditional(), { x: 42, y: 43 }); assert.deepStrictEqual(exports.logical(), { x: 42, y: 43 }); } -}; +}); diff --git a/test/function/samples/simplify-class-expression-assignment/_config.js b/test/function/samples/simplify-class-expression-assignment/_config.js index 2e3c44bdbac..49d2640eb71 100644 --- a/test/function/samples/simplify-class-expression-assignment/_config.js +++ b/test/function/samples/simplify-class-expression-assignment/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'wraps class expressions in call expressions in simplified assignments' -}; +}); diff --git a/test/function/samples/simplify-function-expression-assignment/_config.js b/test/function/samples/simplify-function-expression-assignment/_config.js index 173965d0199..6fd7a94a2d6 100644 --- a/test/function/samples/simplify-function-expression-assignment/_config.js +++ b/test/function/samples/simplify-function-expression-assignment/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'wraps function expressions in call expressions in simplified assignments' -}; +}); diff --git a/test/function/samples/simplify-object-expression-assignment/_config.js b/test/function/samples/simplify-object-expression-assignment/_config.js index f8c4f0cf135..b3b2c7db699 100644 --- a/test/function/samples/simplify-object-expression-assignment/_config.js +++ b/test/function/samples/simplify-object-expression-assignment/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'wraps object expressions in call expressions in simplified assignments' -}; +}); diff --git a/test/function/samples/simplify-sequence-expressions/_config.js b/test/function/samples/simplify-sequence-expressions/_config.js new file mode 100644 index 00000000000..bf5617a0fc5 --- /dev/null +++ b/test/function/samples/simplify-sequence-expressions/_config.js @@ -0,0 +1,4 @@ +module.exports = defineTest({ + description: + 'correctly simplify sequence expressions if the new leading element would require parentheses' +}); diff --git a/test/function/samples/simplify-sequence-expressions/main.js b/test/function/samples/simplify-sequence-expressions/main.js new file mode 100644 index 00000000000..fbc070d97f1 --- /dev/null +++ b/test/function/samples/simplify-sequence-expressions/main.js @@ -0,0 +1,31 @@ +let value = 0; + +1, function(){ value = 1 }(); +assert.strictEqual(value, 1); + +1, function(){ value = 2 }(), 2; +assert.strictEqual(value, 2); + +1, {foo: value = 3 }; +assert.strictEqual(value, 3); + +1, {foo: value = 4 }, 2; +assert.strictEqual(value, 4); + +1, true ? function(){ value = 5 }() : false; +assert.strictEqual(value, 5); + +1, true ? function(){ value = 6 }() : false, 2; +assert.strictEqual(value, 6); + +1, function(){ value = 7; return true }() ? true : false; +assert.strictEqual(value, 7); + +1, function(){ value = 8; return true }() ? true : false, 2; +assert.strictEqual(value, 8); + +1, false || function(){ value = 9 }(); +assert.strictEqual(value, 9); + +1, false || function(){ value = 10 }(), 2; +assert.strictEqual(value, 10); diff --git a/test/function/samples/simplify-with-destructuring/_config.js b/test/function/samples/simplify-with-destructuring/_config.js new file mode 100644 index 00000000000..0e2de5021cd --- /dev/null +++ b/test/function/samples/simplify-with-destructuring/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'handle destructuring assignments in simplified sequence expressions' +}); diff --git a/test/function/samples/simplify-with-destructuring/main.js b/test/function/samples/simplify-with-destructuring/main.js new file mode 100644 index 00000000000..636adbac973 --- /dev/null +++ b/test/function/samples/simplify-with-destructuring/main.js @@ -0,0 +1,7 @@ +let foo, unused; +null, { foo } = { foo: 'bar' }; +assert.strictEqual(foo, 'bar'); + +const assign = () => unused = { foo } = { foo: 'baz' }; +assign(); +assert.strictEqual(foo, 'baz'); diff --git a/test/function/samples/simplify-with-function-iife/_config.js b/test/function/samples/simplify-with-function-iife/_config.js new file mode 100644 index 00000000000..74b67dced6b --- /dev/null +++ b/test/function/samples/simplify-with-function-iife/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'correctly uses parentheses when a simplification would put a function IIFE first' +}); diff --git a/test/function/samples/simplify-with-function-iife/main.js b/test/function/samples/simplify-with-function-iife/main.js new file mode 100644 index 00000000000..3dd20d47bdb --- /dev/null +++ b/test/function/samples/simplify-with-function-iife/main.js @@ -0,0 +1,19 @@ +let a = 0; +const _1 = function (){}() ? a = 1 : a = 2; +assert.strictEqual(a, 2); + +let b = 0; +const _2 = function (){}() || (b = 1); +assert.strictEqual(b, 1); + +let c = 0; +const _3 = function (){}() + (c = 1); +assert.strictEqual(c, 1); + +let d = 0; +const _4 = function (){}() || function (){}() || (d = 1); +assert.strictEqual(d, 1); + +let e = 0; +const _5 = function (){}() + function (){}() + (e = 1); +assert.strictEqual(e, 1); diff --git a/test/function/samples/sourcemap-base-url-invalid/_config.js b/test/function/samples/sourcemap-base-url-invalid/_config.js new file mode 100644 index 00000000000..d39d3d8afcf --- /dev/null +++ b/test/function/samples/sourcemap-base-url-invalid/_config.js @@ -0,0 +1,14 @@ +module.exports = defineTest({ + description: 'throws for invalid sourcemapBaseUrl', + options: { + output: { + sourcemapBaseUrl: 'example.com' + } + }, + generateError: { + code: 'INVALID_OPTION', + message: + 'Invalid value for option "output.sourcemapBaseUrl" - must be a valid URL, received "example.com".', + url: 'https://rollupjs.org/configuration-options/#output-sourcemapbaseurl' + } +}); diff --git a/test/function/samples/sourcemap-base-url-invalid/main.js b/test/function/samples/sourcemap-base-url-invalid/main.js new file mode 100644 index 00000000000..5c72ff35124 --- /dev/null +++ b/test/function/samples/sourcemap-base-url-invalid/main.js @@ -0,0 +1 @@ +console.log( 42 ); diff --git a/test/function/samples/sourcemap-inline-generatebundle/_config.js b/test/function/samples/sourcemap-inline-generatebundle/_config.js new file mode 100644 index 00000000000..53e9814887e --- /dev/null +++ b/test/function/samples/sourcemap-inline-generatebundle/_config.js @@ -0,0 +1,26 @@ +const assert = require('node:assert'); + +module.exports = defineTest({ + description: 'includes inline sourcemap comments in generateBundle hook', + options: { + plugins: [ + { + name: 'test', + generateBundle(options, bundle) { + assert.deepStrictEqual(Object.keys(bundle), ['main.js']); + assert.strictEqual( + bundle['main.js'].code, + `'use strict'; + +var main = 42; + +module.exports = main; +//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibWFpbi5qcyIsInNvdXJjZXMiOlsibWFpbi5qcyJdLCJzb3VyY2VzQ29udGVudCI6WyJleHBvcnQgZGVmYXVsdCA0MjtcbiJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLFdBQWUsRUFBRTs7OzsifQ== +` + ); + } + } + ], + output: { sourcemap: 'inline' } + } +}); diff --git a/test/function/samples/sourcemap-inline-generatebundle/main.js b/test/function/samples/sourcemap-inline-generatebundle/main.js new file mode 100644 index 00000000000..7a4e8a723a4 --- /dev/null +++ b/test/function/samples/sourcemap-inline-generatebundle/main.js @@ -0,0 +1 @@ +export default 42; diff --git a/test/function/samples/sourcemap-true-generatebundle/_config.js b/test/function/samples/sourcemap-true-generatebundle/_config.js new file mode 100644 index 00000000000..706335b2fb4 --- /dev/null +++ b/test/function/samples/sourcemap-true-generatebundle/_config.js @@ -0,0 +1,39 @@ +const assert = require('node:assert'); + +module.exports = defineTest({ + description: 'emits sourcemaps before generateBundle hook', + options: { + // TODO should be removed with next major as deprecated properties become non-enumerable + strictDeprecations: false, + plugins: [ + { + name: 'test', + generateBundle(options, bundle) { + assert.deepStrictEqual(Object.keys(bundle), ['main.js', 'main.js.map']); + assert.strictEqual( + bundle['main.js'].code, + `'use strict'; + +var main = 42; + +module.exports = main; +//# sourceMappingURL=main.js.map +` + ); + assert.deepStrictEqual(bundle['main.js.map'], { + fileName: 'main.js.map', + name: undefined, + names: [], + needsCodeReference: false, + originalFileName: null, + originalFileNames: [], + source: + '{"version":3,"file":"main.js","sources":["main.js"],"sourcesContent":["export default 42;\\n"],"names":[],"mappings":";;AAAA,WAAe,EAAE;;;;"}', + type: 'asset' + }); + } + } + ], + output: { sourcemap: true } + } +}); diff --git a/test/function/samples/sourcemap-true-generatebundle/main.js b/test/function/samples/sourcemap-true-generatebundle/main.js new file mode 100644 index 00000000000..7a4e8a723a4 --- /dev/null +++ b/test/function/samples/sourcemap-true-generatebundle/main.js @@ -0,0 +1 @@ +export default 42; diff --git a/test/function/samples/sourcemapping-url-comment/_config.js b/test/function/samples/sourcemapping-url-comment/_config.js index 97c94a2bba3..c1b01a65196 100644 --- a/test/function/samples/sourcemapping-url-comment/_config.js +++ b/test/function/samples/sourcemapping-url-comment/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'only removes valid sourcemapping URL comments (#1132)' -}; +}); diff --git a/test/function/samples/sourcemapping-url-multiline/_config.js b/test/function/samples/sourcemapping-url-multiline/_config.js index 466ea613259..c258c88d9da 100644 --- a/test/function/samples/sourcemapping-url-multiline/_config.js +++ b/test/function/samples/sourcemapping-url-multiline/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'does not mistakenly recognise sourceMappingURL comment with newline' -}; +}); diff --git a/test/function/samples/spread-arguments-unused/_config.js b/test/function/samples/spread-arguments-unused/_config.js index 4ad21b60eac..d67255bcda8 100644 --- a/test/function/samples/spread-arguments-unused/_config.js +++ b/test/function/samples/spread-arguments-unused/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'handles using the spread operator to add arguments when the first argument is unused (#3652)' -}; +}); diff --git a/test/function/samples/statement-order/_config.js b/test/function/samples/statement-order/_config.js index 06562502639..c46b7824f67 100644 --- a/test/function/samples/statement-order/_config.js +++ b/test/function/samples/statement-order/_config.js @@ -1,13 +1,13 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'correct statement order is preserved even in weird edge cases', context: { - getAnswer(obj) { - return obj.answer; + getAnswer(object) { + return object.answer; } }, exports(exports) { assert.equal(exports, 'right'); } -}; +}); diff --git a/test/function/samples/strip-bom-1/_config.js b/test/function/samples/strip-bom-1/_config.js new file mode 100644 index 00000000000..de3ab53cfd4 --- /dev/null +++ b/test/function/samples/strip-bom-1/_config.js @@ -0,0 +1,8 @@ +const commonjs = require('@rollup/plugin-commonjs'); + +module.exports = defineTest({ + description: 'Works correctly with BOM files and the @rollup/plugin-commonjs plugin.', + options: { + plugins: [commonjs()] + } +}); diff --git a/test/function/samples/strip-bom-1/main.js b/test/function/samples/strip-bom-1/main.js new file mode 100644 index 00000000000..5fef2504392 --- /dev/null +++ b/test/function/samples/strip-bom-1/main.js @@ -0,0 +1,12 @@ +(function () { + const foo = 'foo'; + if (typeof define === 'function' && define.amd) { + define([], function () { + return foo; + }); + } else if (typeof module !== 'undefined' && module.exports) { + module.exports = foo; + } else { + this.foo = foo; + } +})(); diff --git a/test/function/samples/strip-bom-2/_config.js b/test/function/samples/strip-bom-2/_config.js new file mode 100644 index 00000000000..7f9e0930dcd --- /dev/null +++ b/test/function/samples/strip-bom-2/_config.js @@ -0,0 +1,18 @@ +const fs = require('node:fs'); +const assert = require('node:assert'); + +module.exports = defineTest({ + description: 'Works correctly with multi BOMs files.', + options: { + plugins: [ + { + load(id) { + const content = fs.readFileSync(id, 'utf8'); + assert.ok(content.charCodeAt(0) === 0xfe_ff); + assert.ok(content.charCodeAt(1) === 0xfe_ff); + return content; + } + } + ] + } +}); diff --git a/test/function/samples/strip-bom-2/main.js b/test/function/samples/strip-bom-2/main.js new file mode 100644 index 00000000000..57d2994fee3 --- /dev/null +++ b/test/function/samples/strip-bom-2/main.js @@ -0,0 +1 @@ +export const msg = 'foo'; diff --git a/test/function/samples/strip-bom/_config.js b/test/function/samples/strip-bom/_config.js new file mode 100644 index 00000000000..9aaa6028981 --- /dev/null +++ b/test/function/samples/strip-bom/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'Works correctly with BOM files.' +}); diff --git a/test/function/samples/strip-bom/main.js b/test/function/samples/strip-bom/main.js new file mode 100644 index 00000000000..15253645c46 --- /dev/null +++ b/test/function/samples/strip-bom/main.js @@ -0,0 +1 @@ +export const msg = 'foo'; diff --git a/test/function/samples/switch-break/_config.js b/test/function/samples/switch-break/_config.js new file mode 100644 index 00000000000..006e24586ff --- /dev/null +++ b/test/function/samples/switch-break/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'if switch does not always throw an error, retain the following break' +}); diff --git a/test/function/samples/switch-break/main.js b/test/function/samples/switch-break/main.js new file mode 100644 index 00000000000..7643a17a0ff --- /dev/null +++ b/test/function/samples/switch-break/main.js @@ -0,0 +1,21 @@ +function issue(obj) { + switch (obj.field1) { + case 'baz': + switch (obj.field2) { + case 'value': { + if (obj.field1) { + if (obj.field1) { + break; + } + } + throw new Error(`error 1`); + } + default: + throw new Error(`error 2`); + } + break; // retained + default: + throw new Error('error 3'); + } +} +issue({ field1: 'baz', field2: 'value' }); diff --git a/test/function/samples/switch-cases-are-deconflicted/_config.js b/test/function/samples/switch-cases-are-deconflicted/_config.js index a64c88ddf29..a1dc6f47510 100644 --- a/test/function/samples/switch-cases-are-deconflicted/_config.js +++ b/test/function/samples/switch-cases-are-deconflicted/_config.js @@ -1,9 +1,9 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'deconflicts variables in switch cases (#1970)', exports(exports) { assert.equal(exports.fn1('1'), 'correct'); assert.equal(exports.fn2('2'), 'correct'); } -}; +}); diff --git a/test/function/samples/switch-scope/_config.js b/test/function/samples/switch-scope/_config.js new file mode 100644 index 00000000000..deab99f886f --- /dev/null +++ b/test/function/samples/switch-scope/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'uses correct scopes for switch statements' +}); diff --git a/test/function/samples/switch-scope/main.js b/test/function/samples/switch-scope/main.js new file mode 100644 index 00000000000..d2b441fe305 --- /dev/null +++ b/test/function/samples/switch-scope/main.js @@ -0,0 +1,10 @@ +const foo = 1; +let triggered = false; + +switch (foo) { + case 1: + const foo = 2; + triggered = true; +} + +assert.ok(triggered); diff --git a/test/function/samples/switch-statement-nested-continue/_config.js b/test/function/samples/switch-statement-nested-continue/_config.js index 3c0f55f0cc5..095bef32b8e 100644 --- a/test/function/samples/switch-statement-nested-continue/_config.js +++ b/test/function/samples/switch-statement-nested-continue/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'treats continue different from break in switch statements' -}; +}); diff --git a/test/function/samples/switch-statement-out-of-order-default/_config.js b/test/function/samples/switch-statement-out-of-order-default/_config.js index 1b6f9d32087..313d2d98f85 100644 --- a/test/function/samples/switch-statement-out-of-order-default/_config.js +++ b/test/function/samples/switch-statement-out-of-order-default/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'handles side-effects in non-ordered defaults of switch statements' -}; +}); diff --git a/test/function/samples/switch-statements-removed-default/_config.js b/test/function/samples/switch-statements-removed-default/_config.js index 2c58f54526d..221a57d8fc6 100644 --- a/test/function/samples/switch-statements-removed-default/_config.js +++ b/test/function/samples/switch-statements-removed-default/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'does not remove code after a switch statement that should be retained' -}; +}); diff --git a/test/function/samples/symlink/_config.js b/test/function/samples/symlink/_config.js index 561b738fc2d..65f9bbbb287 100644 --- a/test/function/samples/symlink/_config.js +++ b/test/function/samples/symlink/_config.js @@ -1,4 +1,4 @@ -module.exports = { - skip: process.platform === 'win32', +module.exports = defineTest({ + skipIfWindows: true, description: 'follows symlinks' -}; +}); diff --git a/test/function/samples/synthetic-named-exports-fallback-es2015/_config.js b/test/function/samples/synthetic-named-exports-fallback-es2015/_config.js new file mode 100644 index 00000000000..87daf9e88b3 --- /dev/null +++ b/test/function/samples/synthetic-named-exports-fallback-es2015/_config.js @@ -0,0 +1,13 @@ +module.exports = defineTest({ + description: 'adds a fallback in case synthetic named exports are falsy', + options: { + output: { generatedCode: 'es2015' }, + plugins: [ + { + transform() { + return { syntheticNamedExports: '__synthetic' }; + } + } + ] + } +}); diff --git a/test/function/samples/synthetic-named-exports-fallback-es2015/array.js b/test/function/samples/synthetic-named-exports-fallback-es2015/array.js new file mode 100644 index 00000000000..308119acd7f --- /dev/null +++ b/test/function/samples/synthetic-named-exports-fallback-es2015/array.js @@ -0,0 +1,2 @@ +export const foo = 'bar'; +export const __synthetic = [1, 2, 3]; diff --git a/test/function/samples/synthetic-named-exports-fallback-es2015/inherited.js b/test/function/samples/synthetic-named-exports-fallback-es2015/inherited.js new file mode 100644 index 00000000000..7db37d74616 --- /dev/null +++ b/test/function/samples/synthetic-named-exports-fallback-es2015/inherited.js @@ -0,0 +1,2 @@ +export const foo = 'bar'; +export const __synthetic = Object.create({ inherited: 'ignored' }); diff --git a/test/function/samples/synthetic-named-exports-fallback-es2015/main.js b/test/function/samples/synthetic-named-exports-fallback-es2015/main.js new file mode 100644 index 00000000000..b451a9c7411 --- /dev/null +++ b/test/function/samples/synthetic-named-exports-fallback-es2015/main.js @@ -0,0 +1,12 @@ +import * as fromNull from './null'; +import * as fromString from './string'; +import * as fromArray from './array'; +import * as fromInherited from './inherited'; + +const expectedNs = { __proto__: null, foo: 'bar' }; +Object.defineProperty(expectedNs, Symbol.toStringTag, { value: 'Module' }); + +assert.deepStrictEqual(fromNull, expectedNs); +assert.deepStrictEqual(fromString, expectedNs); +assert.deepStrictEqual(fromArray, expectedNs); +assert.deepStrictEqual(fromInherited, expectedNs); diff --git a/test/function/samples/synthetic-named-exports-fallback-es2015/null.js b/test/function/samples/synthetic-named-exports-fallback-es2015/null.js new file mode 100644 index 00000000000..c78ae54972f --- /dev/null +++ b/test/function/samples/synthetic-named-exports-fallback-es2015/null.js @@ -0,0 +1,2 @@ +export const foo = 'bar'; +export const __synthetic = null; diff --git a/test/function/samples/synthetic-named-exports-fallback-es2015/string.js b/test/function/samples/synthetic-named-exports-fallback-es2015/string.js new file mode 100644 index 00000000000..eb0e2dc76b7 --- /dev/null +++ b/test/function/samples/synthetic-named-exports-fallback-es2015/string.js @@ -0,0 +1,2 @@ +export const foo = 'bar'; +export const __synthetic = 'some string'; diff --git a/test/function/samples/synthetic-named-exports-fallback/_config.js b/test/function/samples/synthetic-named-exports-fallback/_config.js new file mode 100644 index 00000000000..86d20347037 --- /dev/null +++ b/test/function/samples/synthetic-named-exports-fallback/_config.js @@ -0,0 +1,12 @@ +module.exports = defineTest({ + description: 'adds a fallback in case synthetic named exports are falsy', + options: { + plugins: [ + { + transform() { + return { syntheticNamedExports: '__synthetic' }; + } + } + ] + } +}); diff --git a/test/function/samples/synthetic-named-exports-fallback/array.js b/test/function/samples/synthetic-named-exports-fallback/array.js new file mode 100644 index 00000000000..308119acd7f --- /dev/null +++ b/test/function/samples/synthetic-named-exports-fallback/array.js @@ -0,0 +1,2 @@ +export const foo = 'bar'; +export const __synthetic = [1, 2, 3]; diff --git a/test/function/samples/synthetic-named-exports-fallback/inherited.js b/test/function/samples/synthetic-named-exports-fallback/inherited.js new file mode 100644 index 00000000000..7db37d74616 --- /dev/null +++ b/test/function/samples/synthetic-named-exports-fallback/inherited.js @@ -0,0 +1,2 @@ +export const foo = 'bar'; +export const __synthetic = Object.create({ inherited: 'ignored' }); diff --git a/test/function/samples/synthetic-named-exports-fallback/main.js b/test/function/samples/synthetic-named-exports-fallback/main.js new file mode 100644 index 00000000000..60dc807dbcf --- /dev/null +++ b/test/function/samples/synthetic-named-exports-fallback/main.js @@ -0,0 +1,9 @@ +import * as fromNull from './null'; +import * as fromString from './string'; +import * as fromArray from './array'; +import * as fromInherited from './inherited'; + +assert.deepStrictEqual(fromNull, { __proto__: null, foo: 'bar' }); +assert.deepStrictEqual(fromString, { __proto__: null, foo: 'bar' }); +assert.deepStrictEqual(fromArray, { __proto__: null, foo: 'bar' }); +assert.deepStrictEqual(fromInherited, { __proto__: null, foo: 'bar' }); diff --git a/test/function/samples/synthetic-named-exports-fallback/null.js b/test/function/samples/synthetic-named-exports-fallback/null.js new file mode 100644 index 00000000000..c78ae54972f --- /dev/null +++ b/test/function/samples/synthetic-named-exports-fallback/null.js @@ -0,0 +1,2 @@ +export const foo = 'bar'; +export const __synthetic = null; diff --git a/test/function/samples/synthetic-named-exports-fallback/string.js b/test/function/samples/synthetic-named-exports-fallback/string.js new file mode 100644 index 00000000000..eb0e2dc76b7 --- /dev/null +++ b/test/function/samples/synthetic-named-exports-fallback/string.js @@ -0,0 +1,2 @@ +export const foo = 'bar'; +export const __synthetic = 'some string'; diff --git a/test/function/samples/synthetic-named-exports/circular-synthetic-exports/_config.js b/test/function/samples/synthetic-named-exports/circular-synthetic-exports/_config.js index 35a95977898..b56e4b7d7dd 100644 --- a/test/function/samples/synthetic-named-exports/circular-synthetic-exports/_config.js +++ b/test/function/samples/synthetic-named-exports/circular-synthetic-exports/_config.js @@ -1,6 +1,8 @@ -const path = require('path'); +const path = require('node:path'); +const ID_MAIN = path.join(__dirname, 'main.js'); +const ID_DEP = path.join(__dirname, 'dep.js'); -module.exports = { +module.exports = defineTest({ description: 'handles circular synthetic exports', options: { plugins: [ @@ -14,8 +16,9 @@ module.exports = { }, error: { code: 'SYNTHETIC_NAMED_EXPORTS_NEED_NAMESPACE_EXPORT', - id: path.join(__dirname, 'main.js'), - message: `Module "main.js" that is marked with 'syntheticNamedExports: "__synthetic"' needs an export named "__synthetic" that does not reexport an unresolved named export of the same module.`, - watchFiles: [path.join(__dirname, 'main.js'), path.join(__dirname, 'dep.js')] + exporter: ID_MAIN, + watchFiles: [ID_DEP, ID_MAIN], + message: + 'Module "main.js" that is marked with `syntheticNamedExports: "__synthetic"` needs an explicit export named "__synthetic" that does not reexport an unresolved named export of the same module.' } -}; +}); diff --git a/test/function/samples/synthetic-named-exports/circular-synthetic-exports2/_config.js b/test/function/samples/synthetic-named-exports/circular-synthetic-exports2/_config.js index 5ed72a4ae8a..bd2d738fb2c 100644 --- a/test/function/samples/synthetic-named-exports/circular-synthetic-exports2/_config.js +++ b/test/function/samples/synthetic-named-exports/circular-synthetic-exports2/_config.js @@ -1,11 +1,14 @@ -module.exports = { +const path = require('node:path'); +const ID_DEP1 = path.join(__dirname, 'dep1.js'); +const ID_DEP2 = path.join(__dirname, 'dep2.js'); + +module.exports = defineTest({ description: 'handles circular synthetic exports', warnings: [ { code: 'CIRCULAR_DEPENDENCY', - cycle: ['dep1.js', 'dep2.js', 'dep1.js'], - importer: 'dep1.js', + ids: [ID_DEP1, ID_DEP2, ID_DEP1], message: 'Circular dependency: dep1.js -> dep2.js -> dep1.js' } ] -}; +}); diff --git a/test/function/samples/synthetic-named-exports/dynamic-import/_config.js b/test/function/samples/synthetic-named-exports/dynamic-import/_config.js index 596205484f9..aa0d92e4f08 100644 --- a/test/function/samples/synthetic-named-exports/dynamic-import/_config.js +++ b/test/function/samples/synthetic-named-exports/dynamic-import/_config.js @@ -1,16 +1,17 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'supports dynamically importing a module with synthetic named exports', options: { plugins: [ { + name: 'test-plugin', transform(code, id) { if (id.endsWith('dep.js')) { return { code, syntheticNamedExports: true }; } }, - moduleParsed({id, syntheticNamedExports}) { + moduleParsed({ id, syntheticNamedExports }) { if (id.endsWith('dep.js')) { assert.strictEqual(syntheticNamedExports, true); } @@ -25,4 +26,4 @@ module.exports = { assert.strictEqual(namespace.baz, undefined); assert.deepStrictEqual(namespace.default, { foo: 'foo' }); } -}; +}); diff --git a/test/function/samples/synthetic-named-exports/entry/_config.js b/test/function/samples/synthetic-named-exports/entry/_config.js index b19969ae499..ec3c1902b84 100644 --- a/test/function/samples/synthetic-named-exports/entry/_config.js +++ b/test/function/samples/synthetic-named-exports/entry/_config.js @@ -1,10 +1,11 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'does not expose the synthetic namespace if an entry point uses a string value', options: { plugins: [ { + name: 'test-plugin', transform(code) { return { code, syntheticNamedExports: '__synthetic' }; } @@ -16,4 +17,4 @@ module.exports = { exists: 'exists' }); } -}; +}); diff --git a/test/function/samples/synthetic-named-exports/external-synthetic-exports/_config.js b/test/function/samples/synthetic-named-exports/external-synthetic-exports/_config.js index bd60de83d00..45cb93b3b32 100644 --- a/test/function/samples/synthetic-named-exports/external-synthetic-exports/_config.js +++ b/test/function/samples/synthetic-named-exports/external-synthetic-exports/_config.js @@ -1,8 +1,9 @@ -module.exports = { +module.exports = defineTest({ description: 'external modules can not have syntheticNamedExports', options: { plugins: [ { + name: 'test-plugin', resolveId(id) { if (id === 'dep') { return { @@ -18,9 +19,8 @@ module.exports = { warnings: [ { code: 'EXTERNAL_SYNTHETIC_EXPORTS', - importer: 'main.js', - source: 'dep', - message: "External 'dep' can not have 'syntheticNamedExports' enabled." + exporter: 'dep', + message: 'External "dep" cannot have "syntheticNamedExports" enabled (imported by "main.js").' } ], context: { @@ -28,4 +28,4 @@ module.exports = { return 1; } } -}; +}); diff --git a/test/function/samples/synthetic-named-exports/namespace-object/_config.js b/test/function/samples/synthetic-named-exports/namespace-object/_config.js index 7603006a2ac..ef46e67daf9 100644 --- a/test/function/samples/synthetic-named-exports/namespace-object/_config.js +++ b/test/function/samples/synthetic-named-exports/namespace-object/_config.js @@ -1,6 +1,6 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'does not include named synthetic namespaces in namespace objects', options: { plugins: [ @@ -26,4 +26,4 @@ module.exports = { } }); } -}; +}); diff --git a/test/function/samples/synthetic-named-exports/namespace-overrides/_config.js b/test/function/samples/synthetic-named-exports/namespace-overrides/_config.js index b2204e6309e..7cdbc765e3b 100644 --- a/test/function/samples/synthetic-named-exports/namespace-overrides/_config.js +++ b/test/function/samples/synthetic-named-exports/namespace-overrides/_config.js @@ -1,6 +1,6 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'supports re-exported synthetic exports in namespace objects with correct export precedence', options: { @@ -41,4 +41,4 @@ module.exports = { } }); } -}; +}); diff --git a/test/function/samples/synthetic-named-exports/non-default-export/_config.js b/test/function/samples/synthetic-named-exports/non-default-export/_config.js index c29db5a5bc4..2221ec3c63b 100644 --- a/test/function/samples/synthetic-named-exports/non-default-export/_config.js +++ b/test/function/samples/synthetic-named-exports/non-default-export/_config.js @@ -1,16 +1,17 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'supports providing a named export to generate synthetic exports', options: { plugins: [ { + name: 'test-plugin', transform(code, id) { if (id.endsWith('dep.js')) { return { code, syntheticNamedExports: '__synthetic' }; } }, - moduleParsed({id, syntheticNamedExports}) { + moduleParsed({ id, syntheticNamedExports }) { if (id.endsWith('dep.js')) { assert.strictEqual(syntheticNamedExports, '__synthetic'); } @@ -26,4 +27,4 @@ module.exports = { synthetic: 'synthetic' }); } -}; +}); diff --git a/test/function/samples/synthetic-named-exports/preserve-modules/_config.js b/test/function/samples/synthetic-named-exports/preserve-modules/_config.js new file mode 100644 index 00000000000..c08c3094e3b --- /dev/null +++ b/test/function/samples/synthetic-named-exports/preserve-modules/_config.js @@ -0,0 +1,24 @@ +const assert = require('node:assert'); + +module.exports = defineTest({ + description: 'handles a dynamic import with synthetic named exports in preserveModules mode', + options: { + output: { + preserveModules: true + }, + plugins: [ + { + name: 'test', + transform() { + return { + syntheticNamedExports: '__synthetic' + }; + } + } + ] + }, + async exports(exports) { + const { foo } = await exports.promise; + assert.strictEqual(foo, 'bar'); + } +}); diff --git a/test/function/samples/synthetic-named-exports/preserve-modules/main.js b/test/function/samples/synthetic-named-exports/preserve-modules/main.js new file mode 100644 index 00000000000..176802e3e31 --- /dev/null +++ b/test/function/samples/synthetic-named-exports/preserve-modules/main.js @@ -0,0 +1 @@ +export const promise = import('./other'); diff --git a/test/function/samples/synthetic-named-exports/preserve-modules/other.js b/test/function/samples/synthetic-named-exports/preserve-modules/other.js new file mode 100644 index 00000000000..9ac5ff5d4eb --- /dev/null +++ b/test/function/samples/synthetic-named-exports/preserve-modules/other.js @@ -0,0 +1 @@ +export const __synthetic = { foo: 'bar' }; diff --git a/test/function/samples/synthetic-named-exports/synthetic-exports-need-default/_config.js b/test/function/samples/synthetic-named-exports/synthetic-exports-need-default/_config.js index 0a89c1f782a..53cea010ae5 100644 --- a/test/function/samples/synthetic-named-exports/synthetic-exports-need-default/_config.js +++ b/test/function/samples/synthetic-named-exports/synthetic-exports-need-default/_config.js @@ -1,10 +1,13 @@ -const path = require('path'); +const path = require('node:path'); +const ID_MAIN = path.join(__dirname, 'main.js'); +const ID_DEP = path.join(__dirname, 'dep.js'); -module.exports = { +module.exports = defineTest({ description: 'synthetic named exports modules need a default export', options: { plugins: [ { + name: 'test-plugin', transform() { return { syntheticNamedExports: true }; } @@ -13,8 +16,9 @@ module.exports = { }, error: { code: 'SYNTHETIC_NAMED_EXPORTS_NEED_NAMESPACE_EXPORT', - id: path.join(__dirname, 'dep.js'), - message: `Module "dep.js" that is marked with 'syntheticNamedExports: true' needs a default export that does not reexport an unresolved named export of the same module.`, - watchFiles: [path.join(__dirname, 'main.js'), path.join(__dirname, 'dep.js')] + exporter: ID_DEP, + watchFiles: [ID_DEP, ID_MAIN], + message: + 'Module "dep.js" that is marked with `syntheticNamedExports: true` needs a default export that does not reexport an unresolved named export of the same module.' } -}; +}); diff --git a/test/function/samples/synthetic-named-exports/synthetic-exports-need-fallback-export/_config.js b/test/function/samples/synthetic-named-exports/synthetic-exports-need-fallback-export/_config.js index a11192c4697..f1ee50d90cf 100644 --- a/test/function/samples/synthetic-named-exports/synthetic-exports-need-fallback-export/_config.js +++ b/test/function/samples/synthetic-named-exports/synthetic-exports-need-fallback-export/_config.js @@ -1,11 +1,13 @@ -const path = require('path'); -const DEP_ID = path.join(__dirname, 'dep.js'); +const path = require('node:path'); +const ID_MAIN = path.join(__dirname, 'main.js'); +const ID_DEP = path.join(__dirname, 'dep.js'); -module.exports = { +module.exports = defineTest({ description: 'synthetic named exports modules need their fallback export', options: { plugins: [ { + name: 'test-plugin', transform(code, id) { if (id.endsWith('dep.js')) { return { code, syntheticNamedExports: '__synthetic' }; @@ -16,8 +18,9 @@ module.exports = { }, error: { code: 'SYNTHETIC_NAMED_EXPORTS_NEED_NAMESPACE_EXPORT', - id: DEP_ID, - message: `Module "dep.js" that is marked with 'syntheticNamedExports: "__synthetic"' needs an export named "__synthetic" that does not reexport an unresolved named export of the same module.`, - watchFiles: [path.join(__dirname, 'main.js'), DEP_ID] + exporter: ID_DEP, + watchFiles: [ID_DEP, ID_MAIN], + message: + 'Module "dep.js" that is marked with `syntheticNamedExports: "__synthetic"` needs an explicit export named "__synthetic" that does not reexport an unresolved named export of the same module.' } -}; +}); diff --git a/test/function/samples/synthetic-named-exports/synthetic-named-export-as-default/_config.js b/test/function/samples/synthetic-named-exports/synthetic-named-export-as-default/_config.js index d23377b2df2..7de33d90169 100644 --- a/test/function/samples/synthetic-named-exports/synthetic-named-export-as-default/_config.js +++ b/test/function/samples/synthetic-named-exports/synthetic-named-export-as-default/_config.js @@ -1,10 +1,13 @@ -module.exports = { +module.exports = defineTest({ description: 'makes sure default exports of synthetic named exports are snapshots', options: { - plugins: { - transform() { - return { syntheticNamedExports: '__synthetic' }; + plugins: [ + { + name: 'test-plugin', + transform() { + return { syntheticNamedExports: '__synthetic' }; + } } - } + ] } -}; +}); diff --git a/test/function/samples/synthetic-named-exports/synthetic-named-export-entry/_config.js b/test/function/samples/synthetic-named-exports/synthetic-named-export-entry/_config.js new file mode 100644 index 00000000000..be9caf628e0 --- /dev/null +++ b/test/function/samples/synthetic-named-exports/synthetic-named-export-entry/_config.js @@ -0,0 +1,44 @@ +const assert = require('node:assert'); +const path = require('node:path'); +const ID_MAIN = path.join(__dirname, 'main.js'); +const ID_OVERRIDE = path.join(__dirname, 'override.js'); +const ID_NOOVERRIDE = path.join(__dirname, 'noOverride.js'); +const ID_HIDDENNAMESPACE = path.join(__dirname, 'hiddenNamespace.js'); + +module.exports = defineTest({ + description: 'does not expose synthetic named exports on entry points', + options: { + plugins: [ + { + name: 'test-plugin1', + transform(code, id) { + switch (id) { + case ID_MAIN: { + return { syntheticNamedExports: 'synthMain' }; + } + case ID_OVERRIDE: { + return { syntheticNamedExports: 'synthOverride' }; + } + case ID_NOOVERRIDE: { + return { syntheticNamedExports: 'synthNoOverride' }; + } + case ID_HIDDENNAMESPACE: { + return { syntheticNamedExports: 'synthHiddenNamespace' }; + } + } + } + } + ] + }, + exports(exports) { + assert.deepStrictEqual(exports, { + explicitReexport: { override: true }, + hiddenNamespace: 'hiddenNamespace', + main: 'main', + noOverride: 'noOverride', + override: 'override', + synthHiddenNamespace: 'hidden in override', + synthOverride: 'overridden' + }); + } +}); diff --git a/test/function/samples/synthetic-named-exports/synthetic-named-export-entry/hiddenNamespace.js b/test/function/samples/synthetic-named-exports/synthetic-named-export-entry/hiddenNamespace.js new file mode 100644 index 00000000000..97e81d68bdc --- /dev/null +++ b/test/function/samples/synthetic-named-exports/synthetic-named-export-entry/hiddenNamespace.js @@ -0,0 +1,2 @@ +export const hiddenNamespace = 'hiddenNamespace'; +export const synthHiddenNamespace = { hiddenNamespace: true }; diff --git a/test/function/samples/synthetic-named-exports/synthetic-named-export-entry/main.js b/test/function/samples/synthetic-named-exports/synthetic-named-export-entry/main.js new file mode 100644 index 00000000000..cc7963f49ae --- /dev/null +++ b/test/function/samples/synthetic-named-exports/synthetic-named-export-entry/main.js @@ -0,0 +1,7 @@ +export const main = 'main'; +export const synthMain = { main: true }; +export * from './noOverride.js'; +export * from './override.js'; +export * from './hiddenNamespace.js'; +export const synthOverride = 'overridden'; +export { synthOverride as explicitReexport } from './override.js'; diff --git a/test/function/samples/synthetic-named-exports/synthetic-named-export-entry/noOverride.js b/test/function/samples/synthetic-named-exports/synthetic-named-export-entry/noOverride.js new file mode 100644 index 00000000000..205e87552a5 --- /dev/null +++ b/test/function/samples/synthetic-named-exports/synthetic-named-export-entry/noOverride.js @@ -0,0 +1,2 @@ +export const noOverride = 'noOverride'; +export const synthNoOverride = { noOverride: true }; diff --git a/test/function/samples/synthetic-named-exports/synthetic-named-export-entry/override.js b/test/function/samples/synthetic-named-exports/synthetic-named-export-entry/override.js new file mode 100644 index 00000000000..8f40d7ee6ca --- /dev/null +++ b/test/function/samples/synthetic-named-exports/synthetic-named-export-entry/override.js @@ -0,0 +1,3 @@ +export const override = 'override'; +export const synthOverride = { override: true }; +export const synthHiddenNamespace = 'hidden in override'; diff --git a/test/function/samples/tagged-template-deoptimize/_config.js b/test/function/samples/tagged-template-deoptimize/_config.js new file mode 100644 index 00000000000..04d62a8910b --- /dev/null +++ b/test/function/samples/tagged-template-deoptimize/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'correctly deoptimizes tagged template expressions' +}); diff --git a/test/function/samples/tagged-template-deoptimize/main.js b/test/function/samples/tagged-template-deoptimize/main.js new file mode 100644 index 00000000000..b564677dd8f --- /dev/null +++ b/test/function/samples/tagged-template-deoptimize/main.js @@ -0,0 +1,16 @@ +const tagReturn = 'return'; + +const param = { modified: false }; + +const obj = { + modified: false, + tag(_, param) { + this.modified = true; + param.modified = true; + return tagReturn; + } +}; + +assert.strictEqual(obj.tag`${param}`, 'return'); +assert.ok(obj.modified ? true : false, 'obj'); +assert.ok(param.modified ? true : false, 'param'); diff --git a/test/function/samples/template-element/_config.js b/test/function/samples/template-element/_config.js new file mode 100644 index 00000000000..a482c334f2b --- /dev/null +++ b/test/function/samples/template-element/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'invalid unicode escape sequence in template element should be parsed correctly' +}); diff --git a/test/function/samples/template-element/main.js b/test/function/samples/template-element/main.js new file mode 100644 index 00000000000..7a8900b536a --- /dev/null +++ b/test/function/samples/template-element/main.js @@ -0,0 +1 @@ +assert.ok(String.raw`\update`); diff --git a/test/function/samples/this-not-namespace/_config.js b/test/function/samples/this-not-namespace/_config.js index dd33c64ae9f..d1a051a5b12 100644 --- a/test/function/samples/this-not-namespace/_config.js +++ b/test/function/samples/this-not-namespace/_config.js @@ -1,8 +1,8 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'does not treat this.foo as a possible namespace (#1258)', exports: exports => { assert.equal(typeof exports.Foo, 'function'); } -}; +}); diff --git a/test/function/samples/this-side-effect/_config.js b/test/function/samples/this-side-effect/_config.js new file mode 100644 index 00000000000..0d3de334024 --- /dev/null +++ b/test/function/samples/this-side-effect/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'detects side effects when mutating "this" in a constructor' +}); diff --git a/test/function/samples/this-side-effect/main.js b/test/function/samples/this-side-effect/main.js new file mode 100644 index 00000000000..335d787aa56 --- /dev/null +++ b/test/function/samples/this-side-effect/main.js @@ -0,0 +1,15 @@ +let effect = false; + +class Foo { + constructor() { + Object.defineProperty(this, 'x', { + set() { + effect = true; + } + }); + this.x = 2; + } +} + +new Foo(); +assert.ok(effect); diff --git a/test/function/samples/throws-not-found-module/_config.js b/test/function/samples/throws-not-found-module/_config.js index 5df6a0b9f81..c442e34140c 100644 --- a/test/function/samples/throws-not-found-module/_config.js +++ b/test/function/samples/throws-not-found-module/_config.js @@ -1,10 +1,13 @@ -const path = require('path'); +const path = require('node:path'); +const ID_MAIN = path.join(__dirname, 'main.js'); -module.exports = { +module.exports = defineTest({ description: 'throws error if module is not found', error: { code: 'UNRESOLVED_IMPORT', - message: `Could not resolve './mod' from main.js`, - watchFiles: [path.join(__dirname, 'main.js')] + exporter: './mod', + id: ID_MAIN, + watchFiles: [ID_MAIN], + message: 'Could not resolve "./mod" from "main.js"' } -}; +}); diff --git a/test/function/samples/top-level-arrow-function/_config.js b/test/function/samples/top-level-arrow-function/_config.js index 95d2df90e5a..6ed02c4dea0 100644 --- a/test/function/samples/top-level-arrow-function/_config.js +++ b/test/function/samples/top-level-arrow-function/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'handles naked return value from top-level arrow function expression (#403)' -}; +}); diff --git a/test/function/samples/top-level-block/_config.js b/test/function/samples/top-level-block/_config.js index 1cc39dbebd1..913fa57bdf9 100644 --- a/test/function/samples/top-level-block/_config.js +++ b/test/function/samples/top-level-block/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'allows top-level block' -}; +}); diff --git a/test/function/samples/top-level-side-effect-on-imported/_config.js b/test/function/samples/top-level-side-effect-on-imported/_config.js index f07d5803f16..a9997046d93 100644 --- a/test/function/samples/top-level-side-effect-on-imported/_config.js +++ b/test/function/samples/top-level-side-effect-on-imported/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'top level function calls are preserved' -}; +}); diff --git a/test/function/samples/top-level-side-effects-are-preserved/_config.js b/test/function/samples/top-level-side-effects-are-preserved/_config.js index 7201d855e32..63c7061ff20 100644 --- a/test/function/samples/top-level-side-effects-are-preserved/_config.js +++ b/test/function/samples/top-level-side-effects-are-preserved/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'top level side effects are preserved' -}; +}); diff --git a/test/function/samples/trace-inclusion-of-virtual-literals/_config.js b/test/function/samples/trace-inclusion-of-virtual-literals/_config.js index a9c896b523b..baa4d3807ee 100644 --- a/test/function/samples/trace-inclusion-of-virtual-literals/_config.js +++ b/test/function/samples/trace-inclusion-of-virtual-literals/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'tracks the "included" state of virtual literals with regard to mutating oparations' -}; +}); diff --git a/test/function/samples/track-async-arrow-function-return-value/_config.js b/test/function/samples/track-async-arrow-function-return-value/_config.js new file mode 100644 index 00000000000..303b80bbc43 --- /dev/null +++ b/test/function/samples/track-async-arrow-function-return-value/_config.js @@ -0,0 +1,10 @@ +const assert = require('node:assert'); + +module.exports = defineTest({ + description: 'tracks object mutations of async arrow function return values', + async exports(exports) { + assert.strictEqual(exports.toggled, false); + await exports.test(); + assert.strictEqual(exports.toggled, true); + } +}); diff --git a/test/function/samples/track-async-arrow-function-return-value/main.js b/test/function/samples/track-async-arrow-function-return-value/main.js new file mode 100644 index 00000000000..6f0d2aeb01b --- /dev/null +++ b/test/function/samples/track-async-arrow-function-return-value/main.js @@ -0,0 +1,19 @@ +const fn = async () => { + const obj = { + test() { + if (typeof obj.testfn === 'function') { + obj.testfn(); + } + } + }; + return obj; +}; + +export let toggled = false; + +export const test = async function () { + const obj1 = await fn(); + const obj2 = await fn(); + obj1.testfn = () => (toggled = true); + obj1.test(); +}; diff --git a/test/function/samples/track-async-function-return-value/_config.js b/test/function/samples/track-async-function-return-value/_config.js new file mode 100644 index 00000000000..75aebf0c704 --- /dev/null +++ b/test/function/samples/track-async-function-return-value/_config.js @@ -0,0 +1,10 @@ +const assert = require('node:assert'); + +module.exports = defineTest({ + description: 'tracks object mutations of async function return values', + async exports(exports) { + assert.strictEqual(exports.toggled, false); + await exports.test(); + assert.strictEqual(exports.toggled, true); + } +}); diff --git a/test/function/samples/track-async-function-return-value/main.js b/test/function/samples/track-async-function-return-value/main.js new file mode 100644 index 00000000000..ef9c1bb05d8 --- /dev/null +++ b/test/function/samples/track-async-function-return-value/main.js @@ -0,0 +1,18 @@ +async function fn() { + const obj = { + test() { + if (typeof obj.testfn === 'function') { + obj.testfn(); + } + } + }; + return obj; +} + +export let toggled = false; + +export const test = async function () { + const obj = await fn(); + obj.testfn = () => (toggled = true); + obj.test(); +}; diff --git a/test/function/samples/track-awaited-object/_config.js b/test/function/samples/track-awaited-object/_config.js new file mode 100644 index 00000000000..fc462923571 --- /dev/null +++ b/test/function/samples/track-awaited-object/_config.js @@ -0,0 +1,10 @@ +const assert = require('node:assert'); + +module.exports = defineTest({ + description: 'tracks object mutations through await', + async exports(exports) { + assert.strictEqual(exports.toggled, false); + await exports.test(); + assert.strictEqual(exports.toggled, true); + } +}); diff --git a/test/function/samples/track-awaited-object/main.js b/test/function/samples/track-awaited-object/main.js new file mode 100644 index 00000000000..6a8791e31a7 --- /dev/null +++ b/test/function/samples/track-awaited-object/main.js @@ -0,0 +1,18 @@ +function fn() { + const obj = { + test() { + if (typeof obj.testfn === 'function') { + obj.testfn(); + } + } + }; + return obj; +} + +export let toggled = false; + +export const test = async function () { + const obj = await fn(); + obj.testfn = () => (toggled = true); + obj.test(); +}; diff --git a/test/function/samples/track-conditional-expression-return-reassignments/_config.js b/test/function/samples/track-conditional-expression-return-reassignments/_config.js index 4a727bbfbf5..036e8b6b772 100644 --- a/test/function/samples/track-conditional-expression-return-reassignments/_config.js +++ b/test/function/samples/track-conditional-expression-return-reassignments/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'tracks reassignments of return expressions of conditional expressions' -}; +}); diff --git a/test/function/samples/track-logical-expression-return-reassignments/_config.js b/test/function/samples/track-logical-expression-return-reassignments/_config.js index 621b12db34e..92f3e39b0f0 100644 --- a/test/function/samples/track-logical-expression-return-reassignments/_config.js +++ b/test/function/samples/track-logical-expression-return-reassignments/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'tracks reassignments of return expressions of logical expressions' -}; +}); diff --git a/test/function/samples/track-multiple-return-expression-reassignments/_config.js b/test/function/samples/track-multiple-return-expression-reassignments/_config.js index cf6ff7bef33..70a05fb0674 100644 --- a/test/function/samples/track-multiple-return-expression-reassignments/_config.js +++ b/test/function/samples/track-multiple-return-expression-reassignments/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'tracks reassignments of return expressions of multiple return expressions' -}; +}); diff --git a/test/function/samples/track-mutated-in-callback/_config.js b/test/function/samples/track-mutated-in-callback/_config.js new file mode 100644 index 00000000000..5e4bb352777 --- /dev/null +++ b/test/function/samples/track-mutated-in-callback/_config.js @@ -0,0 +1,8 @@ +module.exports = defineTest({ + description: 'tracks mutations of variables in callbacks passed to globals', + context: { + globalFunction(callback) { + callback(true); + } + } +}); diff --git a/test/function/samples/track-mutated-in-callback/main.js b/test/function/samples/track-mutated-in-callback/main.js new file mode 100644 index 00000000000..afe12d1d9c3 --- /dev/null +++ b/test/function/samples/track-mutated-in-callback/main.js @@ -0,0 +1,10 @@ +const createCallback = box => newValue => { + box[0] = newValue; + return box[0]; +}; + +const box = [null]; +const callback = createCallback(box); +globalFunction(callback); + +assert.ok(box[0] ? true : false); diff --git a/test/function/samples/track-parameter-return-reassignments/_config.js b/test/function/samples/track-parameter-return-reassignments/_config.js index 991743fb8ab..6fdccd79bd5 100644 --- a/test/function/samples/track-parameter-return-reassignments/_config.js +++ b/test/function/samples/track-parameter-return-reassignments/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'tracks reassignments of return expressions of parameters' -}; +}); diff --git a/test/function/samples/track-parameter-return-reassignments/main.js b/test/function/samples/track-parameter-return-reassignments/main.js index 8c6fd6d7dc2..33435727c70 100644 --- a/test/function/samples/track-parameter-return-reassignments/main.js +++ b/test/function/samples/track-parameter-return-reassignments/main.js @@ -12,26 +12,26 @@ if (!obj1.x) { throw new Error('function parameter reassignment not tracked'); } -// arrow function -const bar = getObj => { - getObj().x = true; -}; - -const obj2 = { x: false }; -foo(() => obj2); - -if (!obj2.x) { - throw new Error('function parameter reassignment not tracked'); -} - -// constructor -function Bar(getObj) { - getObj().x = true; -} - -const obj3 = { x: false }; -new Bar(() => obj3); - -if (!obj3.x) { - throw new Error('constructor parameter reassignment not tracked'); -} +// // arrow function +// const bar = getObj => { +// getObj().x = true; +// }; +// +// const obj2 = { x: false }; +// foo(() => obj2); +// +// if (!obj2.x) { +// throw new Error('function parameter reassignment not tracked'); +// } +// +// // constructor +// function Bar(getObj) { +// getObj().x = true; +// } +// +// const obj3 = { x: false }; +// new Bar(() => obj3); +// +// if (!obj3.x) { +// throw new Error('constructor parameter reassignment not tracked'); +// } diff --git a/test/function/samples/track-reassigned-object-expression-return-reassignments/_config.js b/test/function/samples/track-reassigned-object-expression-return-reassignments/_config.js index 08e75a277c9..9e763dd3baa 100644 --- a/test/function/samples/track-reassigned-object-expression-return-reassignments/_config.js +++ b/test/function/samples/track-reassigned-object-expression-return-reassignments/_config.js @@ -1,3 +1,4 @@ -module.exports = { - description: 'tracks reassignments of return expressions of members of reassigned object expressions' -}; +module.exports = defineTest({ + description: + 'tracks reassignments of return expressions of members of reassigned object expressions' +}); diff --git a/test/function/samples/track-reassignments/_config.js b/test/function/samples/track-reassignments/_config.js new file mode 100644 index 00000000000..b850e4b941c --- /dev/null +++ b/test/function/samples/track-reassignments/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'properly track reassignments (#4468)' +}); diff --git a/test/function/samples/track-reassignments/main.js b/test/function/samples/track-reassignments/main.js new file mode 100644 index 00000000000..c5c83c8c8ad --- /dev/null +++ b/test/function/samples/track-reassignments/main.js @@ -0,0 +1,15 @@ +import { patchEventTarget } from './patchEventTarget.js'; + +class EventTarget { + addEventListener(callback) { + callback(); + } +} +global.window = { EventTarget }; + +let patchCalled = false; +patchEventTarget(() => (patchCalled = true)); +const target = new EventTarget(); +target.addEventListener() + +assert.ok(patchCalled, 'patch'); diff --git a/test/function/samples/track-reassignments/patchEventTarget.js b/test/function/samples/track-reassignments/patchEventTarget.js new file mode 100644 index 00000000000..93fff1fcc13 --- /dev/null +++ b/test/function/samples/track-reassignments/patchEventTarget.js @@ -0,0 +1,10 @@ +export function patchEventTarget(callback) { + var proto = window.EventTarget.prototype; + var nativeAddEventListener = proto.addEventListener; + + proto.addEventListener = function () { + return nativeAddEventListener(callback); + }; + + return proto; +} diff --git a/test/function/samples/track-rest-parameter-value/_config.js b/test/function/samples/track-rest-parameter-value/_config.js new file mode 100644 index 00000000000..58ae41ab079 --- /dev/null +++ b/test/function/samples/track-rest-parameter-value/_config.js @@ -0,0 +1,4 @@ +module.exports = defineTest({ + description: + 'determines the correct value of rest parameters when a function is called multiple times' +}); diff --git a/test/function/samples/track-rest-parameter-value/main.js b/test/function/samples/track-rest-parameter-value/main.js new file mode 100644 index 00000000000..e8c5e9cf3a3 --- /dev/null +++ b/test/function/samples/track-rest-parameter-value/main.js @@ -0,0 +1,9 @@ +const getArgsInfo = (...args) => { + if (args.length === 0) { + return 'no args'; + } + return 'has args'; +}; + +assert.strictEqual(getArgsInfo(), 'no args'); +assert.strictEqual(getArgsInfo(1), 'has args'); diff --git a/test/function/samples/tracks-alias-mutations-b/_config.js b/test/function/samples/tracks-alias-mutations-b/_config.js index f78b95e2bb2..222a665c1ed 100644 --- a/test/function/samples/tracks-alias-mutations-b/_config.js +++ b/test/function/samples/tracks-alias-mutations-b/_config.js @@ -1,8 +1,8 @@ -const assert = require('assert'); +const assert = require('node:assert'); const foo = {}; -module.exports = { +module.exports = defineTest({ description: 'tracks mutations of aliased objects', context: { foo @@ -10,4 +10,4 @@ module.exports = { exports() { assert.equal(foo.x, 42); } -}; +}); diff --git a/test/function/samples/tracks-alias-mutations/_config.js b/test/function/samples/tracks-alias-mutations/_config.js index f2faaad0e87..e20a9461154 100644 --- a/test/function/samples/tracks-alias-mutations/_config.js +++ b/test/function/samples/tracks-alias-mutations/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'tracks mutations of aliased objects' -}; +}); diff --git a/test/function/samples/transform-empty-string/_config.js b/test/function/samples/transform-empty-string/_config.js index e6a15ba155f..0af89d97518 100644 --- a/test/function/samples/transform-empty-string/_config.js +++ b/test/function/samples/transform-empty-string/_config.js @@ -1,21 +1,23 @@ -const assert = require('assert'); +const assert = require('node:assert'); const sideEffects = []; -module.exports = { +module.exports = defineTest({ description: 'allows transformers to transform code to an empty string', context: { sideEffects }, exports() { assert.deepStrictEqual(sideEffects, ['this happens']); }, options: { - plugins: { - name: 'test-plugin', - transform(code, id) { - if (id.endsWith('transformed.js')) { - return ''; + plugins: [ + { + name: 'test-plugin', + transform(code, id) { + if (id.endsWith('transformed.js')) { + return ''; + } } } - } + ] } -}; +}); diff --git a/test/function/samples/transform-without-code-warn-ast/_config.js b/test/function/samples/transform-without-code-warn-ast/_config.js index ef751ca124e..405b92e74e1 100644 --- a/test/function/samples/transform-without-code-warn-ast/_config.js +++ b/test/function/samples/transform-without-code-warn-ast/_config.js @@ -1,12 +1,14 @@ -module.exports = { +module.exports = defineTest({ description: 'warns when returning a map but no code from a transform hook', options: { - plugins: { - name: 'test-plugin', - transform() { - return { ast: {} }; + plugins: [ + { + name: 'test-plugin', + transform() { + return { ast: {} }; + } } - } + ] }, warnings: [ { @@ -15,4 +17,4 @@ module.exports = { 'The plugin "test-plugin" returned a "map" or "ast" without returning a "code". This will be ignored.' } ] -}; +}); diff --git a/test/function/samples/transform-without-code-warn-map/_config.js b/test/function/samples/transform-without-code-warn-map/_config.js index c8e3689ab50..4b91262e60e 100644 --- a/test/function/samples/transform-without-code-warn-map/_config.js +++ b/test/function/samples/transform-without-code-warn-map/_config.js @@ -1,12 +1,14 @@ -module.exports = { +module.exports = defineTest({ description: 'warns when returning a map but no code from a transform hook', options: { - plugins: { - name: 'test-plugin', - transform() { - return { map: { mappings: '' } }; + plugins: [ + { + name: 'test-plugin', + transform() { + return { map: { mappings: '' } }; + } } - } + ] }, warnings: [ { @@ -15,4 +17,4 @@ module.exports = { 'The plugin "test-plugin" returned a "map" or "ast" without returning a "code". This will be ignored.' } ] -}; +}); diff --git a/test/function/samples/transform-without-code/_config.js b/test/function/samples/transform-without-code/_config.js index 145768af3b8..71e49ed2f1a 100644 --- a/test/function/samples/transform-without-code/_config.js +++ b/test/function/samples/transform-without-code/_config.js @@ -1,39 +1,43 @@ -const assert = require('assert'); +const assert = require('node:assert'); +const { readFileSync } = require('node:fs'); +const path = require('node:path'); const { SourceMapConsumer } = require('source-map'); -const fs = require('fs'); -const path = require('path'); -module.exports = { +module.exports = defineTest({ description: 'allows using the transform hook for annotations only without returning a code property and breaking sourcemaps', options: { - plugins: { - name: 'test-plugin', - transform(code) { - return { meta: { test: true } }; - }, - async generateBundle(options, bundle) { - const { code, map } = bundle['main.js']; - const line = 3; - const column = 11; - assert.strictEqual(code.split('\n')[line - 1].substr(column, 2), '42'); + plugins: [ + { + name: 'test-plugin', + transform() { + return { meta: { test: true } }; + }, + async generateBundle(options, bundle) { + const { code, map } = bundle['main.js']; + const line = 3; + const column = 11; + assert.strictEqual(code.split('\n')[line - 1].slice(column, column + 2), '42'); - const smc = await new SourceMapConsumer(map); - const originalLoc = smc.originalPositionFor({ line, column }); - assert.notStrictEqual(originalLoc.line, null); - const originalCode = fs.readFileSync(path.join(__dirname, 'main.js'), 'utf8'); - assert.strictEqual( - originalCode.split('\n')[originalLoc.line - 1].substr(originalLoc.column, 2), - '42' - ); + const smc = await new SourceMapConsumer(map); + const originalLoc = smc.originalPositionFor({ line, column }); + assert.notStrictEqual(originalLoc.line, null); + const originalCode = readFileSync(path.join(__dirname, 'main.js'), 'utf8'); + assert.strictEqual( + originalCode + .split('\n') + [originalLoc.line - 1].slice(originalLoc.column, originalLoc.column + 2), + '42' + ); - for (const id of this.getModuleIds()) { - assert.strictEqual(this.getModuleInfo(id).meta.test, true); + for (const id of this.getModuleIds()) { + assert.strictEqual(this.getModuleInfo(id).meta.test, true); + } } } - }, + ], output: { sourcemap: true } } -}; +}); diff --git a/test/function/samples/transform-without-sourcemap-render-chunk/_config.js b/test/function/samples/transform-without-sourcemap-render-chunk/_config.js new file mode 100644 index 00000000000..a6c572f3156 --- /dev/null +++ b/test/function/samples/transform-without-sourcemap-render-chunk/_config.js @@ -0,0 +1,31 @@ +module.exports = defineTest({ + description: 'preserves sourcemap chains when transforming', + options: { + plugins: [ + { + name: 'fake plugin 1', + transform(code) { + return code; + } + }, + { + name: 'fake plugin 2', + transform(code) { + return { code, map: null }; + }, + renderChunk(code) { + return { code, map: null }; + } + } + ], + output: { sourcemap: true } + }, + warnings: [ + { + code: `SOURCEMAP_BROKEN`, + plugin: 'fake plugin 1', + message: `[plugin fake plugin 1] Sourcemap is likely to be incorrect: a plugin (fake plugin 1) was used to transform files, but didn't generate a sourcemap for the transformation. Consult the plugin documentation for help`, + url: `https://rollupjs.org/troubleshooting/#warning-sourcemap-is-likely-to-be-incorrect` + } + ] +}); diff --git a/test/function/samples/transform-without-sourcemap-render-chunk/main.js b/test/function/samples/transform-without-sourcemap-render-chunk/main.js new file mode 100644 index 00000000000..69305ae375a --- /dev/null +++ b/test/function/samples/transform-without-sourcemap-render-chunk/main.js @@ -0,0 +1 @@ +assert.strictEqual(42, 42); diff --git a/test/function/samples/transformer-async/_config.js b/test/function/samples/transformer-async/_config.js index 1457ed86330..79fe2dba9a5 100644 --- a/test/function/samples/transformer-async/_config.js +++ b/test/function/samples/transformer-async/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'transformers can be asynchronous', options: { plugins: [ @@ -19,4 +19,4 @@ module.exports = { } ] } -}; +}); diff --git a/test/function/samples/transformer-multiple/_config.js b/test/function/samples/transformer-multiple/_config.js index 68ef2db6ed0..86824951a32 100644 --- a/test/function/samples/transformer-multiple/_config.js +++ b/test/function/samples/transformer-multiple/_config.js @@ -1,20 +1,18 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'accepts multiple transformer functions', options: { plugins: [ { - transform(code, path) { + transform(code) { return code.replace(/MAGIC_NUMBER/g, 3); } }, { - transform(code, path) { - return code.replace(/\d+/g, (match) => { - return 2 * +match; - }); + transform(code) { + return code.replace(/\d+/g, match => 2 * +match); } } ] @@ -22,4 +20,4 @@ module.exports = { exports(exports) { assert.equal(exports.magicNumber, 6); } -}; +}); diff --git a/test/function/samples/transformer-single/_config.js b/test/function/samples/transformer-single/_config.js index b5585fa92ae..77f1f555bcb 100644 --- a/test/function/samples/transformer-single/_config.js +++ b/test/function/samples/transformer-single/_config.js @@ -1,11 +1,11 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'accepts a single transformer function', options: { plugins: [ { - transform(code, path) { + transform(code) { return code.replace(/MAGIC_NUMBER/g, 3); } } @@ -14,4 +14,4 @@ module.exports = { exports(exports) { assert.equal(exports.magicNumber, 3); } -}; +}); diff --git a/test/function/samples/transparent-dynamic-inlining/_config.js b/test/function/samples/transparent-dynamic-inlining/_config.js index 3e58567557b..4eea7a9c499 100644 --- a/test/function/samples/transparent-dynamic-inlining/_config.js +++ b/test/function/samples/transparent-dynamic-inlining/_config.js @@ -1,12 +1,12 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'Dynamic import inlining when resolution id is a module in the bundle', code(code) { - assert.equal(code.indexOf('import('), -1); - assert.notEqual(code.indexOf('Promise.resolve('), -1); + assert.ok(!code.includes('import(')); + assert.ok(code.includes('Promise.resolve(')); }, exports(exports) { assert.deepEqual(exports, { y: 42 }); } -}; +}); diff --git a/test/function/samples/tree-shake-deterministic-dynamic-import/_config.js b/test/function/samples/tree-shake-deterministic-dynamic-import/_config.js new file mode 100644 index 00000000000..1a8ad6ecf3f --- /dev/null +++ b/test/function/samples/tree-shake-deterministic-dynamic-import/_config.js @@ -0,0 +1,46 @@ +module.exports = { + description: 'treeshakes dynamic imports when the target is deterministic', + options: { + output: { + inlineDynamicImports: true + }, + plugins: [ + { + resolveId(id) { + if (/(bail|effect)-(\d+).js$/.test(id)) { + return id; + } + return null; + }, + load(id) { + const match = /(bail|effect)-(\d+).js$/.exec(id); + if (match) { + if (match[1] === 'bail') + return { + code: [ + `export default '@included-bail-${match[2]}'`, + `export const named${match[2]} = 'bail${match[2]}';` + ].join('\n') + }; + else if (match[1] === 'effect') { + return { + code: [ + 'export function fn() { /* @tree-shaken */ }', + `console.log('@included-effect-${match[2]}');` + ].join('\n') + }; + } + } + return null; + } + } + ] + }, + async exports({ allExports }) { + await allExports(); + }, + context: { + named1: 'named1', + named4: 'named4' + } +}; diff --git a/test/function/samples/tree-shake-deterministic-dynamic-import/main.js b/test/function/samples/tree-shake-deterministic-dynamic-import/main.js new file mode 100644 index 00000000000..32edef50e36 --- /dev/null +++ b/test/function/samples/tree-shake-deterministic-dynamic-import/main.js @@ -0,0 +1,26 @@ +export const allExports = () => Promise.all([ + (async () => { + const value = (await import('./bail-1.js'))[named1] + assert.strictEqual(value, 'bail1'); + })(), + (async () => { + const fn = (exports) => { + assert.deepEqual(exports, { + named2: 'bail2', + default: '@included-bail-2' + }); + } + await import('./bail-2.js').then(fn) + })(), + (async () => { + await import('./bail-3.js').then(({ default: _, ...args }) => { + assert.deepEqual(args, { + named3: 'bail3' + }); + }) + })(), + (async () => { + const { [named4]: value } = await import('./bail-4.js') + assert.strictEqual(value, 'bail4'); + })(), +]); diff --git a/test/function/samples/tree-shake-iterable/_config.js b/test/function/samples/tree-shake-iterable/_config.js new file mode 100644 index 00000000000..19d6004e133 --- /dev/null +++ b/test/function/samples/tree-shake-iterable/_config.js @@ -0,0 +1,3 @@ +module.exports = { + description: 'retain functions that accept a iterable that has side effects on iteration' +}; diff --git a/test/function/samples/tree-shake-iterable/main.js b/test/function/samples/tree-shake-iterable/main.js new file mode 100644 index 00000000000..6ac8d2d2759 --- /dev/null +++ b/test/function/samples/tree-shake-iterable/main.js @@ -0,0 +1,32 @@ +let effects = 0; + +const iterable = { + [Symbol.iterator]() { + return { + next() { + effects++; + return { done: true }; + } + }; + } +}; + +new Map(iterable); +new Set(iterable); +new WeakMap(iterable); +new WeakSet(iterable); +Array.from(iterable); +BigInt64Array.from(iterable); +BigUint64Array.from(iterable); +Float32Array.from(iterable); +Float64Array.from(iterable); +Int16Array.from(iterable); +Int32Array.from(iterable); +Int8Array.from(iterable); +Uint16Array.from(iterable); +Uint32Array.from(iterable); +Uint8Array.from(iterable); +Uint8ClampedArray.from(iterable); +Object.fromEntries(iterable); + +assert.equal(effects, 17); diff --git a/test/function/samples/tree-shake-module-side-effects-dependencies/_config.js b/test/function/samples/tree-shake-module-side-effects-dependencies/_config.js new file mode 100644 index 00000000000..c68ef58f231 --- /dev/null +++ b/test/function/samples/tree-shake-module-side-effects-dependencies/_config.js @@ -0,0 +1,8 @@ +module.exports = defineTest({ + description: 'includes impure dependencies of modules without side effects', + options: { + treeshake: { + moduleSideEffects: id => id.endsWith('effect.js') + } + } +}); diff --git a/test/function/samples/tree-shake-module-side-effects-dependencies/dep.js b/test/function/samples/tree-shake-module-side-effects-dependencies/dep.js new file mode 100644 index 00000000000..1f6bd18502e --- /dev/null +++ b/test/function/samples/tree-shake-module-side-effects-dependencies/dep.js @@ -0,0 +1,2 @@ +import './effect.js'; +export const value = true; diff --git a/test/function/samples/tree-shake-module-side-effects-dependencies/effect.js b/test/function/samples/tree-shake-module-side-effects-dependencies/effect.js new file mode 100644 index 00000000000..c96af349c0d --- /dev/null +++ b/test/function/samples/tree-shake-module-side-effects-dependencies/effect.js @@ -0,0 +1,2 @@ +import { updateSharedValue } from './shared'; +updateSharedValue(); diff --git a/test/function/samples/tree-shake-module-side-effects-dependencies/main.js b/test/function/samples/tree-shake-module-side-effects-dependencies/main.js new file mode 100644 index 00000000000..48ac41d6994 --- /dev/null +++ b/test/function/samples/tree-shake-module-side-effects-dependencies/main.js @@ -0,0 +1,5 @@ +import { value } from './dep.js'; +import { sharedValue } from './shared'; + +assert.ok(value); +assert.strictEqual(sharedValue, 'updated'); diff --git a/test/function/samples/tree-shake-module-side-effects-dependencies/shared.js b/test/function/samples/tree-shake-module-side-effects-dependencies/shared.js new file mode 100644 index 00000000000..3508b49875c --- /dev/null +++ b/test/function/samples/tree-shake-module-side-effects-dependencies/shared.js @@ -0,0 +1,4 @@ +export let sharedValue = 'original'; +export function updateSharedValue() { + sharedValue = 'updated'; +} diff --git a/test/function/samples/tree-shake-module-side-effects-update/_config.js b/test/function/samples/tree-shake-module-side-effects-update/_config.js new file mode 100644 index 00000000000..eb1aadf4046 --- /dev/null +++ b/test/function/samples/tree-shake-module-side-effects-update/_config.js @@ -0,0 +1,8 @@ +module.exports = defineTest({ + description: 'detects variable updates in modules without side effects (#5408)', + options: { + treeshake: { + moduleSideEffects: false + } + } +}); diff --git a/test/function/samples/tree-shake-module-side-effects-update/dep.js b/test/function/samples/tree-shake-module-side-effects-update/dep.js new file mode 100644 index 00000000000..41e4197980a --- /dev/null +++ b/test/function/samples/tree-shake-module-side-effects-update/dep.js @@ -0,0 +1,4 @@ +export let direct = false; +direct = true; + +export {indirect} from './dep2.js'; diff --git a/test/function/samples/tree-shake-module-side-effects-update/dep2.js b/test/function/samples/tree-shake-module-side-effects-update/dep2.js new file mode 100644 index 00000000000..cb08077b030 --- /dev/null +++ b/test/function/samples/tree-shake-module-side-effects-update/dep2.js @@ -0,0 +1,4 @@ +export let indirect = false; +(() => { + indirect = true; +})(); diff --git a/test/function/samples/tree-shake-module-side-effects-update/main.js b/test/function/samples/tree-shake-module-side-effects-update/main.js new file mode 100644 index 00000000000..4d7d1f990ea --- /dev/null +++ b/test/function/samples/tree-shake-module-side-effects-update/main.js @@ -0,0 +1,3 @@ +import { direct, indirect } from './dep.js'; +assert.ok(direct ? true : false, 'direct'); +assert.ok(indirect ? true : false, 'indirect'); diff --git a/test/function/samples/tree-shake-object-expression-assignment/_config.js b/test/function/samples/tree-shake-object-expression-assignment/_config.js index 04340104ccd..de5da93825e 100644 --- a/test/function/samples/tree-shake-object-expression-assignment/_config.js +++ b/test/function/samples/tree-shake-object-expression-assignment/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'renders valid code when the target of an object expression with side-effects is tree-shaken' -}; +}); diff --git a/test/function/samples/tree-shake-variable-declarations-2/_config.js b/test/function/samples/tree-shake-variable-declarations-2/_config.js index 063fba2cb35..7adfe470fd8 100644 --- a/test/function/samples/tree-shake-variable-declarations-2/_config.js +++ b/test/function/samples/tree-shake-variable-declarations-2/_config.js @@ -1,8 +1,8 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'remove unused variables from declarations (#1831)', code(code) { assert.ok(code.search(/var a = 'test'/) >= 0); } -}; +}); diff --git a/test/function/samples/tree-shake-variable-declarations/_config.js b/test/function/samples/tree-shake-variable-declarations/_config.js index bbef48cedad..8f4662e0a9e 100644 --- a/test/function/samples/tree-shake-variable-declarations/_config.js +++ b/test/function/samples/tree-shake-variable-declarations/_config.js @@ -1,8 +1,8 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'remove unused variables from declarations (#1937)', exports(exports) { assert.deepEqual(exports(), [0.07]); } -}; +}); diff --git a/test/function/samples/tree-shaking-proxy-2/_config.js b/test/function/samples/tree-shaking-proxy-2/_config.js new file mode 100644 index 00000000000..00bc2dd504d --- /dev/null +++ b/test/function/samples/tree-shaking-proxy-2/_config.js @@ -0,0 +1,8 @@ +const assert = require('assert'); + +module.exports = defineTest({ + description: 'Make tree-shaking work on the handler of the Proxy', + code(code) { + assert.ok(!code.includes('assert.ok(false)')); + } +}); diff --git a/test/function/samples/tree-shaking-proxy-2/main.js b/test/function/samples/tree-shaking-proxy-2/main.js new file mode 100644 index 00000000000..7801d3fc914 --- /dev/null +++ b/test/function/samples/tree-shaking-proxy-2/main.js @@ -0,0 +1,21 @@ +const report_values = { reason: '' }; +const switchSubmit = state => { + if (state == 1) { + assert.ok(false); + } else if (state == 0) { + assert.ok(true); + } +}; + +const valuesProxy = new Proxy(report_values, { + set() { + if (report_values.reason !== '') { + switchSubmit(1); + } else { + switchSubmit(0); + } + return true; + } +}); + +valuesProxy.reason = 'foo'; diff --git a/test/function/samples/tree-shaking-proxy/_config.js b/test/function/samples/tree-shaking-proxy/_config.js new file mode 100644 index 00000000000..7b3fd526fcf --- /dev/null +++ b/test/function/samples/tree-shaking-proxy/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'Deoptimize the proxied object if its property is reassigned in the set function.' +}); diff --git a/test/function/samples/tree-shaking-proxy/main.js b/test/function/samples/tree-shaking-proxy/main.js new file mode 100644 index 00000000000..55a7c02831b --- /dev/null +++ b/test/function/samples/tree-shaking-proxy/main.js @@ -0,0 +1,41 @@ +const report_values = { reason: '' }; +const switchSubmit = state => { + assert.ok(state === 1); +}; + +const valuesProxy = new Proxy(report_values, { + set(target, property, value) { + target[property] = value; + if (report_values.reason !== '') { + switchSubmit(1); + } else { + switchSubmit(0); + } + return true; + } +}); + +valuesProxy.reason = 'foo'; + +{ + const report_values = { reason: '' }; + const switchSubmit = state => { + assert.ok(state === 1); + }; + + const d = { + set(target, property, value) { + target[property] = value; + if (report_values.reason !== '') { + switchSubmit(1); + } else { + switchSubmit(0); + } + return true; + } + }; + + const valuesProxy = new Proxy(report_values, d); + + valuesProxy.reason = 'foo'; +} diff --git a/test/function/samples/treeshake-logical-expression/_config.js b/test/function/samples/treeshake-logical-expression/_config.js new file mode 100644 index 00000000000..be38d4aed2f --- /dev/null +++ b/test/function/samples/treeshake-logical-expression/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'do not optimize the literal value of logical expression if the cache is deoptimized' +}); diff --git a/test/function/samples/treeshake-logical-expression/main.js b/test/function/samples/treeshake-logical-expression/main.js new file mode 100644 index 00000000000..79980a5d144 --- /dev/null +++ b/test/function/samples/treeshake-logical-expression/main.js @@ -0,0 +1,7 @@ +let count = 0; +let foo = false; +let condition = foo && false; +if (!condition) count++; +foo = true; +if (!condition) count++; +assert.strictEqual(count, 2); \ No newline at end of file diff --git a/test/function/samples/trim-conditional-branches-in-exports/_config.js b/test/function/samples/trim-conditional-branches-in-exports/_config.js index c084f7edd1b..7926ff0237b 100644 --- a/test/function/samples/trim-conditional-branches-in-exports/_config.js +++ b/test/function/samples/trim-conditional-branches-in-exports/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'trims conditional branches with a renamed default export' -}; +}); diff --git a/test/function/samples/try-catch-scoping/_config.js b/test/function/samples/try-catch-scoping/_config.js index 9518d7d678c..99ef3b8beff 100644 --- a/test/function/samples/try-catch-scoping/_config.js +++ b/test/function/samples/try-catch-scoping/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'error parameter in catch clause is correctly scoped' -}; +}); diff --git a/test/function/samples/typescript-enum-no-module-side-effects/_config.js b/test/function/samples/typescript-enum-no-module-side-effects/_config.js new file mode 100644 index 00000000000..d766d8840cb --- /dev/null +++ b/test/function/samples/typescript-enum-no-module-side-effects/_config.js @@ -0,0 +1,8 @@ +module.exports = defineTest({ + description: 'bundles enums when using moduleSideEffects: false', + options: { + treeshake: { + moduleSideEffects: false + } + } +}); diff --git a/test/function/samples/typescript-enum-no-module-side-effects/dep.js b/test/function/samples/typescript-enum-no-module-side-effects/dep.js new file mode 100644 index 00000000000..c47995c9ee7 --- /dev/null +++ b/test/function/samples/typescript-enum-no-module-side-effects/dep.js @@ -0,0 +1,12 @@ +// The problem is that with moduleSideEffects: false, the TDZ detection logic +// fails here and assumes that InjectFlags is truthy in its initializer. While +// this construct is questionable, the correct solution should be to detect +// this case even in modules without side effects. For now, the simpler solution +// is to turn off handling the return value of the IIFE as truthy. +var InjectFlags = /* @__PURE__ */ (function (InjectFlags2) { + InjectFlags2[(InjectFlags2['Default'] = 0)] = 'Default'; + return InjectFlags2; +})(InjectFlags || {}); + +export const value = InjectFlags.Default; + diff --git a/test/function/samples/typescript-enum-no-module-side-effects/main.js b/test/function/samples/typescript-enum-no-module-side-effects/main.js new file mode 100644 index 00000000000..e77f08c1593 --- /dev/null +++ b/test/function/samples/typescript-enum-no-module-side-effects/main.js @@ -0,0 +1,3 @@ +import { value } from './dep.js'; + +assert.strictEqual(value, 0); diff --git a/test/function/samples/unicode-string/_config.js b/test/function/samples/unicode-string/_config.js new file mode 100644 index 00000000000..5e753ae6113 --- /dev/null +++ b/test/function/samples/unicode-string/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'handle unicode string without crash' +}); diff --git a/test/function/samples/unicode-string/main.js b/test/function/samples/unicode-string/main.js new file mode 100644 index 00000000000..1e0a90791a1 --- /dev/null +++ b/test/function/samples/unicode-string/main.js @@ -0,0 +1,2 @@ +const v = "៘"; +assert.equal(v, "៘"); diff --git a/test/function/samples/unknown-for-loop-variables/_config.js b/test/function/samples/unknown-for-loop-variables/_config.js index 3cdd03fec38..f4a546bfde1 100644 --- a/test/function/samples/unknown-for-loop-variables/_config.js +++ b/test/function/samples/unknown-for-loop-variables/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'treat for-in and for-of loop variables as unknown' -}; +}); diff --git a/test/function/samples/unknown-generated-code-preset/_config.js b/test/function/samples/unknown-generated-code-preset/_config.js new file mode 100644 index 00000000000..b98cd3519b7 --- /dev/null +++ b/test/function/samples/unknown-generated-code-preset/_config.js @@ -0,0 +1,17 @@ +module.exports = defineTest({ + description: 'throws for unknown presets for the generatedCode option', + options: { + output: { + generatedCode: { + // @ts-expect-error expected error + preset: 'some-string' + } + } + }, + generateError: { + code: 'INVALID_OPTION', + message: + 'Invalid value "some-string" for option "output.generatedCode.preset" - valid values are "es2015" and "es5".', + url: 'https://rollupjs.org/configuration-options/#output-generatedcode' + } +}); diff --git a/test/function/samples/unknown-generated-code-preset/main.js b/test/function/samples/unknown-generated-code-preset/main.js new file mode 100644 index 00000000000..7e37f689f8e --- /dev/null +++ b/test/function/samples/unknown-generated-code-preset/main.js @@ -0,0 +1 @@ +throw new Error('not executed'); diff --git a/test/function/samples/unknown-generated-code-value/_config.js b/test/function/samples/unknown-generated-code-value/_config.js new file mode 100644 index 00000000000..c010eb4ce3f --- /dev/null +++ b/test/function/samples/unknown-generated-code-value/_config.js @@ -0,0 +1,15 @@ +module.exports = defineTest({ + description: 'throws for unknown string values for the generatedCode option', + options: { + output: { + // @ts-expect-error expected error + generatedCode: 'some-string' + } + }, + generateError: { + code: 'INVALID_OPTION', + message: + 'Invalid value "some-string" for option "output.generatedCode" - valid values are "es2015" and "es5". You can also supply an object for more fine-grained control.', + url: 'https://rollupjs.org/configuration-options/#output-generatedcode' + } +}); diff --git a/test/function/samples/unknown-generated-code-value/main.js b/test/function/samples/unknown-generated-code-value/main.js new file mode 100644 index 00000000000..7e37f689f8e --- /dev/null +++ b/test/function/samples/unknown-generated-code-value/main.js @@ -0,0 +1 @@ +throw new Error('not executed'); diff --git a/test/function/samples/unknown-global-side-effects/_config.js b/test/function/samples/unknown-global-side-effects/_config.js index 41910fe91d2..ca4a3c691d0 100644 --- a/test/function/samples/unknown-global-side-effects/_config.js +++ b/test/function/samples/unknown-global-side-effects/_config.js @@ -1,14 +1,14 @@ -module.exports = { +module.exports = defineTest({ description: 'does not omit side-effects from unknown globals', exports(exports) { let error; try { exports.max(1, 2); - } catch (err) { - error = err; + } catch (error_) { + error = error_; } if (!(error instanceof ReferenceError)) { - throw new Error('Expected a ReferenceError to be thrown.'); + throw new TypeError('Expected a ReferenceError to be thrown.'); } } -}; +}); diff --git a/test/function/samples/unknown-statement/_config.js b/test/function/samples/unknown-statement/_config.js index b52eca19457..56e69822f70 100644 --- a/test/function/samples/unknown-statement/_config.js +++ b/test/function/samples/unknown-statement/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'handles unknown statements' -}; +}); diff --git a/test/function/samples/unknown-treeshake-preset/_config.js b/test/function/samples/unknown-treeshake-preset/_config.js new file mode 100644 index 00000000000..09a96076a26 --- /dev/null +++ b/test/function/samples/unknown-treeshake-preset/_config.js @@ -0,0 +1,15 @@ +module.exports = defineTest({ + description: 'throws for unknown presets for the treeshake option', + options: { + treeshake: { + // @ts-expect-error expected error + preset: 'some-string' + } + }, + error: { + code: 'INVALID_OPTION', + message: + 'Invalid value "some-string" for option "treeshake.preset" - valid values are "recommended", "safest" and "smallest".', + url: 'https://rollupjs.org/configuration-options/#treeshake' + } +}); diff --git a/test/function/samples/unknown-treeshake-preset/main.js b/test/function/samples/unknown-treeshake-preset/main.js new file mode 100644 index 00000000000..7e37f689f8e --- /dev/null +++ b/test/function/samples/unknown-treeshake-preset/main.js @@ -0,0 +1 @@ +throw new Error('not executed'); diff --git a/test/function/samples/unknown-treeshake-value/_config.js b/test/function/samples/unknown-treeshake-value/_config.js new file mode 100644 index 00000000000..9d640033169 --- /dev/null +++ b/test/function/samples/unknown-treeshake-value/_config.js @@ -0,0 +1,13 @@ +module.exports = defineTest({ + description: 'throws for unknown string values for the treeshake option', + options: { + // @ts-expect-error expected error + treeshake: 'some-string' + }, + error: { + code: 'INVALID_OPTION', + message: + 'Invalid value "some-string" for option "treeshake" - valid values are false, true, "recommended", "safest" and "smallest". You can also supply an object for more fine-grained control.', + url: 'https://rollupjs.org/configuration-options/#treeshake' + } +}); diff --git a/test/function/samples/unknown-treeshake-value/main.js b/test/function/samples/unknown-treeshake-value/main.js new file mode 100644 index 00000000000..7e37f689f8e --- /dev/null +++ b/test/function/samples/unknown-treeshake-value/main.js @@ -0,0 +1 @@ +throw new Error('not executed'); diff --git a/test/function/samples/unused-constructor-argument-fallback/_config.js b/test/function/samples/unused-constructor-argument-fallback/_config.js new file mode 100644 index 00000000000..77c5bf24832 --- /dev/null +++ b/test/function/samples/unused-constructor-argument-fallback/_config.js @@ -0,0 +1,8 @@ +const assert = require('node:assert'); + +module.exports = defineTest({ + description: 'handles unused logical expressions as constructor arguments (#4517)', + exports({ create }) { + assert.strictEqual(create().foo, 'foo'); + } +}); diff --git a/test/function/samples/unused-constructor-argument-fallback/main.js b/test/function/samples/unused-constructor-argument-fallback/main.js new file mode 100644 index 00000000000..c1cf3cf7930 --- /dev/null +++ b/test/function/samples/unused-constructor-argument-fallback/main.js @@ -0,0 +1,7 @@ +function Note() { + this.foo = 'foo'; +} + +export function create(data) { + return new Note(data || {}); +} diff --git a/test/function/samples/unused-do-while-loop-declaration/_config.js b/test/function/samples/unused-do-while-loop-declaration/_config.js index 9b51c20745a..d221993e4e6 100644 --- a/test/function/samples/unused-do-while-loop-declaration/_config.js +++ b/test/function/samples/unused-do-while-loop-declaration/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'does not partially tree-shake unused declarations with side-effects in do-while loop bodies' -}; +}); diff --git a/test/function/samples/unused-for-in-loop-declaration/_config.js b/test/function/samples/unused-for-in-loop-declaration/_config.js index 9da0091ef68..670ca9c8ced 100644 --- a/test/function/samples/unused-for-in-loop-declaration/_config.js +++ b/test/function/samples/unused-for-in-loop-declaration/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'does not partially tree-shake unused declarations with side-effects in for-in loop bodies' -}; +}); diff --git a/test/function/samples/unused-for-loop-body-declaration/_config.js b/test/function/samples/unused-for-loop-body-declaration/_config.js index 5912da84ed0..2ca4c8f6d26 100644 --- a/test/function/samples/unused-for-loop-body-declaration/_config.js +++ b/test/function/samples/unused-for-loop-body-declaration/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'does not partially tree-shake unused declarations with side-effects in for loop bodies' -}; +}); diff --git a/test/function/samples/unused-for-loop-init-declaration/_config.js b/test/function/samples/unused-for-loop-init-declaration/_config.js index ed47aec6333..665b538b93c 100644 --- a/test/function/samples/unused-for-loop-init-declaration/_config.js +++ b/test/function/samples/unused-for-loop-init-declaration/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'does not partially tree-shake unused declarations with side-effects in for loops' -}; +}); diff --git a/test/function/samples/unused-for-of-loop-declaration/_config.js b/test/function/samples/unused-for-of-loop-declaration/_config.js index 4741e2c4ceb..5da899464d0 100644 --- a/test/function/samples/unused-for-of-loop-declaration/_config.js +++ b/test/function/samples/unused-for-of-loop-declaration/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'does not partially tree-shake unused declarations with side-effects in for-of loop bodies' -}; +}); diff --git a/test/function/samples/unused-if-statement-declaration/_config.js b/test/function/samples/unused-if-statement-declaration/_config.js index ed47aec6333..665b538b93c 100644 --- a/test/function/samples/unused-if-statement-declaration/_config.js +++ b/test/function/samples/unused-if-statement-declaration/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'does not partially tree-shake unused declarations with side-effects in for loops' -}; +}); diff --git a/test/function/samples/unused-import-2/_config.js b/test/function/samples/unused-import-2/_config.js new file mode 100644 index 00000000000..4526eb7dc83 --- /dev/null +++ b/test/function/samples/unused-import-2/_config.js @@ -0,0 +1,25 @@ +const path = require('node:path'); +const ID_MAIN = path.join(__dirname, 'main.js'); + +module.exports = defineTest({ + description: 'warns on unused imports ([#595])', + options: { + external: ['external'] + }, + context: { + require() { + return { + used: true + }; + } + }, + warnings: [ + { + code: 'UNUSED_EXTERNAL_IMPORT', + exporter: 'external', + ids: [ID_MAIN], + message: '"unused" is imported from external module "external" but never used in "main.js".', + names: ['unused'] + } + ] +}); diff --git a/test/function/samples/unused-import-2/foo.js b/test/function/samples/unused-import-2/foo.js new file mode 100644 index 00000000000..2ea1cd06965 --- /dev/null +++ b/test/function/samples/unused-import-2/foo.js @@ -0,0 +1,2 @@ +import { used } from 'external'; +assert.ok(used); \ No newline at end of file diff --git a/test/function/samples/unused-import-2/main.js b/test/function/samples/unused-import-2/main.js new file mode 100644 index 00000000000..634736c5f91 --- /dev/null +++ b/test/function/samples/unused-import-2/main.js @@ -0,0 +1,2 @@ +import { unused } from 'external'; +import './foo.js'; \ No newline at end of file diff --git a/test/function/samples/unused-import/_config.js b/test/function/samples/unused-import/_config.js index 4d9d8219063..50cae83e3b7 100644 --- a/test/function/samples/unused-import/_config.js +++ b/test/function/samples/unused-import/_config.js @@ -1,19 +1,24 @@ -module.exports = { +const path = require('node:path'); +const ID_MAIN = path.join(__dirname, 'main.js'); + +module.exports = defineTest({ description: 'warns on unused imports ([#595])', options: { external: ['external'] }, context: { - require(id) { + require() { return {}; } }, warnings: [ { code: 'UNUSED_EXTERNAL_IMPORT', - source: 'external', - names: ['notused', 'neverused'], - message: `'notused' and 'neverused' are imported from external module 'external' but never used` + exporter: 'external', + ids: [ID_MAIN], + message: + '"notused" and "neverused" are imported from external module "external" but never used in "main.js".', + names: ['notused', 'neverused'] } ] -}; +}); diff --git a/test/function/samples/unused-parameter-side-effects/_config.js b/test/function/samples/unused-parameter-side-effects/_config.js index f8c2ead51f4..672bc09c157 100644 --- a/test/function/samples/unused-parameter-side-effects/_config.js +++ b/test/function/samples/unused-parameter-side-effects/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'does not tree-shake arguments where the corresponding parameters have side-effects' -}; +}); diff --git a/test/function/samples/unused-parenthesed-assignment/_config.js b/test/function/samples/unused-parenthesed-assignment/_config.js index 24d8c766197..5e091f91b57 100644 --- a/test/function/samples/unused-parenthesed-assignment/_config.js +++ b/test/function/samples/unused-parenthesed-assignment/_config.js @@ -1,6 +1,6 @@ -module.exports = { +module.exports = defineTest({ description: 'correctly simplifies assignments with right-hand-sides in parentheses (#3924)', context: { someObject: { isTrue: true } } -}; +}); diff --git a/test/function/samples/unused-var-a/_config.js b/test/function/samples/unused-var-a/_config.js index 05a2b74ac31..b97c8ce85d5 100644 --- a/test/function/samples/unused-var-a/_config.js +++ b/test/function/samples/unused-var-a/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'omits unused var declaration (a)' -}; +}); diff --git a/test/function/samples/unused-var-b/_config.js b/test/function/samples/unused-var-b/_config.js index 174d9fec4d5..73c5dbd5334 100644 --- a/test/function/samples/unused-var-b/_config.js +++ b/test/function/samples/unused-var-b/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'omits unused var declaration (b)' -}; +}); diff --git a/test/function/samples/unused-var-c/_config.js b/test/function/samples/unused-var-c/_config.js index e40d968afae..9f013bf0c66 100644 --- a/test/function/samples/unused-var-c/_config.js +++ b/test/function/samples/unused-var-c/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'omits unused var declaration (c)' -}; +}); diff --git a/test/function/samples/unused-var-d/_config.js b/test/function/samples/unused-var-d/_config.js index 78379d68b47..0595b4968ce 100644 --- a/test/function/samples/unused-var-d/_config.js +++ b/test/function/samples/unused-var-d/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'omits unused var declaration (d)' -}; +}); diff --git a/test/function/samples/unused-while-loop-declaration/_config.js b/test/function/samples/unused-while-loop-declaration/_config.js index 4f236593d35..430de1bbcd0 100644 --- a/test/function/samples/unused-while-loop-declaration/_config.js +++ b/test/function/samples/unused-while-loop-declaration/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'does not partially tree-shake unused declarations with side-effects in while loop bodies' -}; +}); diff --git a/test/function/samples/update-expression-accessors/_config.js b/test/function/samples/update-expression-accessors/_config.js new file mode 100644 index 00000000000..2532457a2c9 --- /dev/null +++ b/test/function/samples/update-expression-accessors/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'deoptimizes "this" for accessors triggered by update expressions' +}); diff --git a/test/function/samples/update-expression-accessors/main.js b/test/function/samples/update-expression-accessors/main.js new file mode 100644 index 00000000000..a8658cd7bd4 --- /dev/null +++ b/test/function/samples/update-expression-accessors/main.js @@ -0,0 +1,16 @@ +const obj = { + getter: false, + setter: false, + get foo() { + this.getter = true; + return 0; + }, + set foo(value) { + this.setter = true; + } +}; + +obj.foo++; + +assert.ok(obj.getter ? true : false); +assert.ok(obj.setter ? true : false); diff --git a/test/function/samples/update-expression-of-import-fails/_config.js b/test/function/samples/update-expression-of-import-fails/_config.js deleted file mode 100644 index f3596401b98..00000000000 --- a/test/function/samples/update-expression-of-import-fails/_config.js +++ /dev/null @@ -1,25 +0,0 @@ -const path = require('path'); - -module.exports = { - description: 'disallows updates to imported bindings', - error: { - code: 'ILLEGAL_REASSIGNMENT', - message: `Illegal reassignment to import 'a'`, - id: path.join(__dirname, 'main.js'), - pos: 28, - watchFiles: [path.join(__dirname, 'main.js'), path.join(__dirname, 'foo.js')], - loc: { - file: path.join(__dirname, 'main.js'), - line: 3, - column: 0 - }, - frame: ` - 1: import { a } from './foo'; - 2: - 3: a++; - ^ - ` - } -}; - -// test copied from https://github.com/esnext/es6-module-transpiler/tree/master/test/examples/update-expression-of-import-fails diff --git a/test/function/samples/use-class-name-in-static-block/_config.js b/test/function/samples/use-class-name-in-static-block/_config.js new file mode 100644 index 00000000000..e68adda2729 --- /dev/null +++ b/test/function/samples/use-class-name-in-static-block/_config.js @@ -0,0 +1,4 @@ +module.exports = defineTest({ + description: 'use the original class name instead of renderName in class body', + minNodeVersion: 16 +}); diff --git a/test/function/samples/use-class-name-in-static-block/main.js b/test/function/samples/use-class-name-in-static-block/main.js new file mode 100644 index 00000000000..27ceb8b9400 --- /dev/null +++ b/test/function/samples/use-class-name-in-static-block/main.js @@ -0,0 +1,5 @@ +import { Test } from './test1.js'; +import { Test as Test2 } from './test2.js'; + +assert.ok(Test.test); +assert.ok(Test2.test); diff --git a/test/function/samples/use-class-name-in-static-block/test1.js b/test/function/samples/use-class-name-in-static-block/test1.js new file mode 100644 index 00000000000..e6d964bb0e0 --- /dev/null +++ b/test/function/samples/use-class-name-in-static-block/test1.js @@ -0,0 +1,14 @@ +export class Test { + constructor() { + assert.ok(Test.test); + assert.ok(this.getText()); + } + getText() { + return Test.test; + } + static test = 'Test1'; + static { + assert.ok(Test.test); + new Test(); + } +} diff --git a/test/function/samples/use-class-name-in-static-block/test2.js b/test/function/samples/use-class-name-in-static-block/test2.js new file mode 100644 index 00000000000..0ac76f89d2c --- /dev/null +++ b/test/function/samples/use-class-name-in-static-block/test2.js @@ -0,0 +1,14 @@ +export class Test { + constructor() { + assert.ok(Test.test); + assert.ok(this.getText()); + } + getText() { + return Test.test; + } + static test = 'Test2'; + static { + assert.ok(Test.test); + new Test(); + } +} diff --git a/test/function/samples/use-var-before-decl/_config.js b/test/function/samples/use-var-before-decl/_config.js new file mode 100644 index 00000000000..554a6aa1bf7 --- /dev/null +++ b/test/function/samples/use-var-before-decl/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'exercise `var` variables before their declarations' +}); diff --git a/test/function/samples/use-var-before-decl/main.js b/test/function/samples/use-var-before-decl/main.js new file mode 100644 index 00000000000..d333a073c2b --- /dev/null +++ b/test/function/samples/use-var-before-decl/main.js @@ -0,0 +1,61 @@ +var results = [], log = x => results.push(x); + +(function () { + var a = "PASS1"; + for (var b = 2; --b >= 0; ) { + (function() { + var c = function() { + return 1; + }(c && (a = "FAIL1")); + })(); + } + log(a); +})(); + +log(a ? "FAIL2" : "PASS2"); +var a = 1; + +var b = 2; +log(b ? "PASS3" : "FAIL3"); + +log(c ? "FAIL4" : "PASS4"); +var c = 3; +log(c ? "PASS5" : "FAIL5"); + +log(function() { + if (x) return "FAIL6"; + var x = 1; + return "PASS6"; +}()); + +(function () { + var first = state(); + var on = true; + var obj = { + state: state + }; + log(first) + log(obj.state()); + function state() { + return on ? "ON" : "OFF"; + } +})(); + +(function () { + var flag = false; + + function foo() { + if (flag) { + if (!value) log(flag + "1"); + } + var value = true; + log(flag + "2"); + } + + foo(); + + flag = true; + foo(); +})(); + +assert.strictEqual(results.join(" "), "PASS1 PASS2 PASS3 PASS4 PASS5 PASS6 OFF ON false2 true1 true2"); diff --git a/test/function/samples/uses-supplied-ast/_config.js b/test/function/samples/uses-supplied-ast/_config.js index 66f80912006..6ac87f34c6e 100644 --- a/test/function/samples/uses-supplied-ast/_config.js +++ b/test/function/samples/uses-supplied-ast/_config.js @@ -18,9 +18,11 @@ const modules = { baz: 'export default 42;' }; +modules.foo.ast._ignoredProp = {}; -module.exports = { +module.exports = defineTest({ description: 'uses supplied AST', + verifyAst: false, options: { plugins: [ { @@ -38,4 +40,4 @@ module.exports = { } ] } -}; +}); diff --git a/test/function/samples/using-statement-symbol-async-dispose/_config.js b/test/function/samples/using-statement-symbol-async-dispose/_config.js new file mode 100644 index 00000000000..e657b880e19 --- /dev/null +++ b/test/function/samples/using-statement-symbol-async-dispose/_config.js @@ -0,0 +1,7 @@ +module.exports = defineTest({ + description: 'preserves Symbol.asyncDispose side effects when used in an async using statement', + minNodeVersion: 24, + async exports({ run }) { + await run(); + } +}); diff --git a/test/function/samples/using-statement-symbol-async-dispose/main.js b/test/function/samples/using-statement-symbol-async-dispose/main.js new file mode 100644 index 00000000000..1f7ec78de8a --- /dev/null +++ b/test/function/samples/using-statement-symbol-async-dispose/main.js @@ -0,0 +1,11 @@ +let triggered = false; + +async function process() { + await using _ = { + [Symbol.asyncDispose]: () => { + triggered = true; + } + }; +} + +export const run = () => process().then(() => assert.ok(triggered)); diff --git a/test/function/samples/using-statement-symbol-dispose/_config.js b/test/function/samples/using-statement-symbol-dispose/_config.js new file mode 100644 index 00000000000..ef582206c86 --- /dev/null +++ b/test/function/samples/using-statement-symbol-dispose/_config.js @@ -0,0 +1,4 @@ +module.exports = defineTest({ + description: 'preserves Symbol.dispose side effects when used in using statement', + minNodeVersion: 24 +}); diff --git a/test/function/samples/using-statement-symbol-dispose/main.js b/test/function/samples/using-statement-symbol-dispose/main.js new file mode 100644 index 00000000000..2fdc8ed3472 --- /dev/null +++ b/test/function/samples/using-statement-symbol-dispose/main.js @@ -0,0 +1,14 @@ +let triggered = false; + +function process() { + using _ = { + [Symbol.dispose]: () => { + triggered = true; + } + }; +} + +process(); + +assert.ok(triggered); + diff --git a/test/function/samples/validate-output/_config.js b/test/function/samples/validate-output/_config.js index 1dff84eda97..66e974d6165 100644 --- a/test/function/samples/validate-output/_config.js +++ b/test/function/samples/validate-output/_config.js @@ -1,8 +1,8 @@ -module.exports = { +module.exports = defineTest({ description: 'handles validate failure', options: { - onwarn(warning) { - throw warning; + onLog(_level, log) { + throw log; }, output: { outro: '/*', @@ -11,16 +11,15 @@ module.exports = { }, generateError: { code: 'CHUNK_INVALID', - message: 'Chunk "main.js" is not valid JavaScript: Unterminated comment (5:0).', + message: 'main.js (6:0): Chunk "main.js" is not valid JavaScript: Unterminated block comment.', frame: ` -3: throw new Error('Not executed'); 4: -5: /* - ^`, +5: /*`, loc: { column: 0, file: 'main.js', - line: 5 - } + line: 6 + }, + pos: 52 } -}; +}); diff --git a/test/function/samples/validate-resolved-by-logic/_config.js b/test/function/samples/validate-resolved-by-logic/_config.js new file mode 100644 index 00000000000..515fcef4166 --- /dev/null +++ b/test/function/samples/validate-resolved-by-logic/_config.js @@ -0,0 +1,51 @@ +const assert = require('node:assert'); +const path = require('node:path'); + +const FOO_IMPORTED_PATH = './foo.js'; +const BAR_IMPORTED_PATH = './bar.js'; +const OTHER_IMPORTED_PATH = './other.js'; +const MAIN_PATH = path.resolve(__dirname, 'main.js'); + +module.exports = defineTest({ + description: 'validate resolvedBy logic', + options: { + plugins: [ + { + name: 'plugin1', + async resolveId(id) { + if (id === FOO_IMPORTED_PATH) { + return id; + } + } + }, + { + name: 'plugin2', + async resolveId(id) { + if (id === BAR_IMPORTED_PATH) { + return { + id, + resolvedBy: 'barByPlugin2' + }; + } + } + }, + { + name: 'plugin3', + async buildEnd() { + const [resolvedFooId, resolvedBarId, resolvedOtherId, resolvedMainId] = await Promise.all( + [ + this.resolve(FOO_IMPORTED_PATH), + this.resolve(BAR_IMPORTED_PATH), + this.resolve(OTHER_IMPORTED_PATH), + this.resolve(MAIN_PATH) + ] + ); + assert.equal(resolvedFooId.resolvedBy, 'plugin1'); + assert.equal(resolvedBarId.resolvedBy, 'barByPlugin2'); + assert.equal(resolvedOtherId.resolvedBy, 'rollup'); + assert.equal(resolvedMainId.resolvedBy, 'rollup'); + } + } + ] + } +}); diff --git a/test/function/samples/validate-resolved-by-logic/bar.js b/test/function/samples/validate-resolved-by-logic/bar.js new file mode 100644 index 00000000000..aef22247d75 --- /dev/null +++ b/test/function/samples/validate-resolved-by-logic/bar.js @@ -0,0 +1 @@ +export default 1; diff --git a/test/function/samples/validate-resolved-by-logic/foo.js b/test/function/samples/validate-resolved-by-logic/foo.js new file mode 100644 index 00000000000..aef22247d75 --- /dev/null +++ b/test/function/samples/validate-resolved-by-logic/foo.js @@ -0,0 +1 @@ +export default 1; diff --git a/test/function/samples/validate-resolved-by-logic/main.js b/test/function/samples/validate-resolved-by-logic/main.js new file mode 100644 index 00000000000..e07de215d42 --- /dev/null +++ b/test/function/samples/validate-resolved-by-logic/main.js @@ -0,0 +1,5 @@ +import bar from './bar.js'; +import foo from './foo.js'; +import other from './other.js'; + +export default bar + foo + other; diff --git a/test/function/samples/validate-resolved-by-logic/other.js b/test/function/samples/validate-resolved-by-logic/other.js new file mode 100644 index 00000000000..aef22247d75 --- /dev/null +++ b/test/function/samples/validate-resolved-by-logic/other.js @@ -0,0 +1 @@ +export default 1; diff --git a/test/function/samples/vars-in-for-loop-head/_config.js b/test/function/samples/vars-in-for-loop-head/_config.js index 166d6eea4e8..6bad2bceb75 100644 --- a/test/function/samples/vars-in-for-loop-head/_config.js +++ b/test/function/samples/vars-in-for-loop-head/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'does not break apart vars in for loop head' -}; +}); diff --git a/test/function/samples/vars-not-removed-in-if-block/_config.js b/test/function/samples/vars-not-removed-in-if-block/_config.js index c34bcea62e6..8b718ec0d37 100644 --- a/test/function/samples/vars-not-removed-in-if-block/_config.js +++ b/test/function/samples/vars-not-removed-in-if-block/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'preserves var declarations in if blocks (#1113)' -}; +}); diff --git a/test/function/samples/vars-not-removed/_config.js b/test/function/samples/vars-not-removed/_config.js index b3daeeff16a..b590402b3d9 100644 --- a/test/function/samples/vars-not-removed/_config.js +++ b/test/function/samples/vars-not-removed/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'does not erroneously remove var/let/const keywords (#390)' -}; +}); diff --git a/test/function/samples/vars-with-init-in-dead-branch/_config.js b/test/function/samples/vars-with-init-in-dead-branch/_config.js index 897cf3d7a13..7e50dc219d2 100644 --- a/test/function/samples/vars-with-init-in-dead-branch/_config.js +++ b/test/function/samples/vars-with-init-in-dead-branch/_config.js @@ -1,10 +1,10 @@ -module.exports = { +module.exports = defineTest({ description: 'handles vars with init in dead branch (#1198)', warnings: [ { - chunkName: 'main', code: 'EMPTY_BUNDLE', - message: 'Generated an empty chunk: "main"' + message: 'Generated an empty chunk: "main".', + names: ['main'] } ] -}; +}); diff --git a/test/function/samples/warn-implicit-cjs-auto/_config.js b/test/function/samples/warn-implicit-cjs-auto/_config.js deleted file mode 100644 index e515365d8f0..00000000000 --- a/test/function/samples/warn-implicit-cjs-auto/_config.js +++ /dev/null @@ -1,15 +0,0 @@ -const path = require('path'); - -module.exports = { - description: 'warns when using implicit default export mode in CommonJS', - options: { output: { exports: undefined } }, - warnings: [ - { - code: 'PREFER_NAMED_EXPORTS', - id: path.join(__dirname, 'main.js'), - message: - 'Entry module "main.js" is implicitly using "default" export mode, which means for CommonJS output that its default export is assigned to "module.exports". For many tools, such CommonJS output will not be interchangeable with the original ES module. If this is intended, explicitly set "output.exports" to either "auto" or "default", otherwise you might want to consider changing the signature of "main.js" to use named exports only.', - url: 'https://rollupjs.org/guide/en/#outputexports' - } - ] -}; diff --git a/test/function/samples/warn-misplaced-annotations/_config.js b/test/function/samples/warn-misplaced-annotations/_config.js new file mode 100644 index 00000000000..284ff12233d --- /dev/null +++ b/test/function/samples/warn-misplaced-annotations/_config.js @@ -0,0 +1,63 @@ +const path = require('node:path'); +const ID_MAIN = path.join(__dirname, 'main.js'); + +module.exports = defineTest({ + description: 'warns for misplaced annotations', + warnings: [ + { + code: 'INVALID_ANNOTATION', + id: ID_MAIN, + message: + 'main.js (2:0): A comment\n\n"/*@__NO_SIDE_EFFECTS__*/"\n\nin "main.js" contains an annotation that Rollup cannot interpret due to the position of the comment. The comment will be removed to avoid issues.', + url: 'https://rollupjs.org/configuration-options/#no-side-effects', + pos: 45, + loc: { + column: 0, + file: ID_MAIN, + line: 2 + }, + frame: ` + 1: /*@__PURE__*/ const x = () => console.log(); + 2: /*@__NO_SIDE_EFFECTS__*/ const foo = 1, + ^ + 3: bar = () => console.log(); + 4: /*@__NO_SIDE_EFFECTS__*/ assert.ok(true);` + }, + { + code: 'INVALID_ANNOTATION', + id: ID_MAIN, + message: + 'main.js (4:0): A comment\n\n"/*@__NO_SIDE_EFFECTS__*/"\n\nin "main.js" contains an annotation that Rollup cannot interpret due to the position of the comment. The comment will be removed to avoid issues.', + url: 'https://rollupjs.org/configuration-options/#no-side-effects', + pos: 113, + loc: { + column: 0, + file: ID_MAIN, + line: 4 + }, + frame: ` + 2: /*@__NO_SIDE_EFFECTS__*/ const foo = 1, + 3: bar = () => console.log(); + 4: /*@__NO_SIDE_EFFECTS__*/ assert.ok(true); + ^` + }, + { + code: 'INVALID_ANNOTATION', + id: ID_MAIN, + message: + 'main.js (1:0): A comment\n\n"/*@__PURE__*/"\n\nin "main.js" contains an annotation that Rollup cannot interpret due to the position of the comment. The comment will be removed to avoid issues.', + url: 'https://rollupjs.org/configuration-options/#pure', + pos: 0, + loc: { + column: 0, + file: ID_MAIN, + line: 1 + }, + frame: ` + 1: /*@__PURE__*/ const x = () => console.log(); + ^ + 2: /*@__NO_SIDE_EFFECTS__*/ const foo = 1, + 3: bar = () => console.log();` + } + ] +}); diff --git a/test/function/samples/warn-misplaced-annotations/main.js b/test/function/samples/warn-misplaced-annotations/main.js new file mode 100644 index 00000000000..6ca367d289c --- /dev/null +++ b/test/function/samples/warn-misplaced-annotations/main.js @@ -0,0 +1,4 @@ +/*@__PURE__*/ const x = () => console.log(); +/*@__NO_SIDE_EFFECTS__*/ const foo = 1, + bar = () => console.log(); +/*@__NO_SIDE_EFFECTS__*/ assert.ok(true); diff --git a/test/function/samples/warn-missing-iife-name/_config.js b/test/function/samples/warn-missing-iife-name/_config.js index 07c9331fb90..c7b0d38ab8b 100644 --- a/test/function/samples/warn-missing-iife-name/_config.js +++ b/test/function/samples/warn-missing-iife-name/_config.js @@ -1,11 +1,12 @@ -module.exports = { +module.exports = defineTest({ description: 'warns if no name is provided for an IIFE bundle', options: { output: { format: 'iife' } }, warnings: [ { code: 'MISSING_NAME_OPTION_FOR_IIFE_EXPORT', message: - 'If you do not supply "output.name", you may not be able to access the exports of an IIFE bundle.' + 'If you do not supply "output.name", you may not be able to access the exports of an IIFE bundle.', + url: 'https://rollupjs.org/configuration-options/#output-name' } ] -}; +}); diff --git a/test/function/samples/warn-on-auto-named-default-exports/_config.js b/test/function/samples/warn-on-auto-named-default-exports/_config.js index a35384c07eb..5858663b822 100644 --- a/test/function/samples/warn-on-auto-named-default-exports/_config.js +++ b/test/function/samples/warn-on-auto-named-default-exports/_config.js @@ -1,14 +1,15 @@ -const path = require('path'); +const path = require('node:path'); +const ID_MAIN = path.join(__dirname, 'main.js'); -module.exports = { +module.exports = defineTest({ description: 'warns if default and named exports are used in auto mode', warnings: [ { code: 'MIXED_EXPORTS', - id: path.join(__dirname, 'main.js'), + id: ID_MAIN, message: - 'Entry module "main.js" is using named and default exports together. Consumers of your bundle will have to use `chunk["default"]` to access the default export, which may not be what you want. Use `output.exports: "named"` to disable this warning', - url: 'https://rollupjs.org/guide/en/#outputexports' + 'Entry module "main.js" is using named and default exports together. Consumers of your bundle will have to use `chunk.default` to access the default export, which may not be what you want. Use `output.exports: "named"` to disable this warning.', + url: 'https://rollupjs.org/configuration-options/#output-exports' } ] -}; +}); diff --git a/test/function/samples/warn-on-empty-bundle/_config.js b/test/function/samples/warn-on-empty-bundle/_config.js index 2b7303d550f..1edccde24ed 100644 --- a/test/function/samples/warn-on-empty-bundle/_config.js +++ b/test/function/samples/warn-on-empty-bundle/_config.js @@ -1,10 +1,10 @@ -module.exports = { +module.exports = defineTest({ description: 'warns if empty bundle is generated (#444)', warnings: [ { - chunkName: 'main', code: 'EMPTY_BUNDLE', - message: 'Generated an empty chunk: "main"' + message: 'Generated an empty chunk: "main".', + names: ['main'] } ] -}; +}); diff --git a/test/function/samples/warn-on-eval/_config.js b/test/function/samples/warn-on-eval/_config.js index ee1b2f5b875..8c87a38cdc4 100644 --- a/test/function/samples/warn-on-eval/_config.js +++ b/test/function/samples/warn-on-eval/_config.js @@ -1,23 +1,24 @@ -const path = require('path'); +const path = require('node:path'); +const ID_MAIN = path.join(__dirname, 'main.js'); -module.exports = { +module.exports = defineTest({ description: 'warns about use of eval', warnings: [ { code: 'EVAL', - id: path.join(__dirname, 'main.js'), - message: `Use of eval is strongly discouraged, as it poses security risks and may cause issues with minification`, + id: ID_MAIN, + message: + 'main.js (1:13): Use of eval in "main.js" is strongly discouraged as it poses security risks and may cause issues with minification.', + url: 'https://rollupjs.org/troubleshooting/#avoiding-eval', pos: 13, loc: { column: 13, - file: require('path').resolve(__dirname, 'main.js'), + file: ID_MAIN, line: 1 }, frame: ` 1: var result = eval( '1 + 1' ); - ^ - `, - url: 'https://rollupjs.org/guide/en/#avoiding-eval' + ^` } ] -}; +}); diff --git a/test/function/samples/warn-on-namespace-conflict/_config.js b/test/function/samples/warn-on-namespace-conflict/_config.js index 78cd978cddf..c45d904e5aa 100644 --- a/test/function/samples/warn-on-namespace-conflict/_config.js +++ b/test/function/samples/warn-on-namespace-conflict/_config.js @@ -1,14 +1,18 @@ -const path = require('path'); +const path = require('node:path'); +const ID_MAIN = path.join(__dirname, 'main.js'); +const ID_FOO = path.join(__dirname, 'foo.js'); +const ID_BAR = path.join(__dirname, 'bar.js'); -module.exports = { +module.exports = defineTest({ description: 'warns on duplicate export * from', warnings: [ { + binding: 'foo', code: 'NAMESPACE_CONFLICT', - name: 'foo', - reexporter: path.join(__dirname, 'main.js'), - sources: [path.join(__dirname, 'foo.js'), path.join(__dirname, 'deep.js')], - message: `Conflicting namespaces: main.js re-exports 'foo' from both foo.js and deep.js (will be ignored)` + ids: [ID_FOO, ID_BAR], + message: + 'Conflicting namespaces: "main.js" re-exports "foo" from one of the modules "foo.js" and "bar.js" (will be ignored).', + reexporter: ID_MAIN } ] -}; +}); diff --git a/test/function/samples/warn-on-namespace-conflict/main.js b/test/function/samples/warn-on-namespace-conflict/main.js index ae6aade26bd..853b4be0f64 100644 --- a/test/function/samples/warn-on-namespace-conflict/main.js +++ b/test/function/samples/warn-on-namespace-conflict/main.js @@ -1,2 +1,3 @@ export * from './foo.js'; -export * from './bar.js'; \ No newline at end of file +export * from './bar.js'; +export const retained = 1; \ No newline at end of file diff --git a/test/function/samples/warn-on-top-level-this/_config.js b/test/function/samples/warn-on-top-level-this/_config.js index 2548e7e822b..35f3b7c5874 100644 --- a/test/function/samples/warn-on-top-level-this/_config.js +++ b/test/function/samples/warn-on-top-level-this/_config.js @@ -1,13 +1,13 @@ -const path = require('path'); -const assert = require('assert'); +const path = require('node:path'); +const { assertIncludes } = require('../../../testHelpers.js'); -module.exports = { +module.exports = defineTest({ description: 'warns on top-level this (#770)', warnings: [ { code: 'THIS_IS_UNDEFINED', id: path.join(__dirname, 'main.js'), - message: `The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten`, + message: `main.js (3:0): The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten`, pos: 81, loc: { file: path.join(__dirname, 'main.js'), @@ -20,10 +20,11 @@ module.exports = { 3: this.foo = 'bar'; ^ `, - url: `https://rollupjs.org/guide/en/#error-this-is-undefined` + url: `https://rollupjs.org/troubleshooting/#error-this-is-undefined` } ], - runtimeError: err => { - assert.equal(err.message, `Cannot set property 'foo' of undefined`); + runtimeError: error => { + assertIncludes(error.message, 'Cannot set propert'); + assertIncludes(error.message, "'foo'"); } -}; +}); diff --git a/test/function/samples/warn-on-unused-missing-imports/_config.js b/test/function/samples/warn-on-unused-missing-imports/_config.js index 1869ed89cc3..49557fdf7c7 100644 --- a/test/function/samples/warn-on-unused-missing-imports/_config.js +++ b/test/function/samples/warn-on-unused-missing-imports/_config.js @@ -1,26 +1,28 @@ -const path = require('path'); +const path = require('node:path'); +const ID_MAIN = path.join(__dirname, 'main.js'); +const ID_FOO = path.join(__dirname, 'foo.js'); -module.exports = { +module.exports = defineTest({ description: 'warns on missing (but unused) imports', warnings: [ { - code: 'NON_EXISTENT_EXPORT', - id: path.join(__dirname, 'main.js'), - source: path.join(__dirname, 'foo.js'), - name: 'b', - message: `Non-existent export 'b' is imported from foo.js`, + binding: 'b', + code: 'MISSING_EXPORT', + exporter: ID_FOO, + id: ID_MAIN, + message: 'main.js (1:12): "b" is not exported by "foo.js", imported by "main.js".', + url: 'https://rollupjs.org/troubleshooting/#error-name-is-not-exported-by-module', pos: 12, loc: { - file: path.join(__dirname, 'main.js'), - line: 1, - column: 12 + column: 12, + file: ID_MAIN, + line: 1 }, frame: ` 1: import { a, b } from './foo.js'; ^ 2: - 3: assert.equal( a, 42 ); - ` + 3: assert.equal( a, 42 );` } ] -}; +}); diff --git a/test/function/samples/warning-const-reassign/_config.js b/test/function/samples/warning-const-reassign/_config.js new file mode 100644 index 00000000000..0797ce86825 --- /dev/null +++ b/test/function/samples/warning-const-reassign/_config.js @@ -0,0 +1,26 @@ +const path = require('node:path'); +const assert = require('node:assert/strict'); +const MAIN_ID = path.resolve(__dirname, 'main.js'); + +module.exports = defineTest({ + description: 'Cannot reassign a variable declared with `const`', + warnings: [ + { + code: 'CONST_REASSIGN', + frame: ` + 1: const foo = 1;\n2: foo = 2;\n ^ + `, + id: MAIN_ID, + loc: { + column: 0, + file: MAIN_ID, + line: 2 + }, + message: 'main.js (2:0): Cannot reassign a variable declared with `const`', + pos: 15 + } + ], + runtimeError(error) { + assert.equal(error.name, 'TypeError'); + } +}); diff --git a/test/function/samples/warning-const-reassign/main.js b/test/function/samples/warning-const-reassign/main.js new file mode 100644 index 00000000000..28adaacce14 --- /dev/null +++ b/test/function/samples/warning-const-reassign/main.js @@ -0,0 +1,2 @@ +const foo = 1; +foo = 2; diff --git a/test/function/samples/warning-incorrect-sourcemap-location/_config.js b/test/function/samples/warning-incorrect-sourcemap-location/_config.js new file mode 100644 index 00000000000..426e283a876 --- /dev/null +++ b/test/function/samples/warning-incorrect-sourcemap-location/_config.js @@ -0,0 +1,35 @@ +const path = require('node:path'); +const ID_MAIN = path.join(__dirname, 'main.js'); +const ID_CONSTANTS = path.join(__dirname, 'constants.js'); + +module.exports = defineTest({ + description: 'does not fail if a warning has an incorrect location due to missing sourcemaps', + options: { + plugins: [ + { + name: 'test', + transform(code) { + return '/* injected */;\n\n\n\n\n\n\n\n' + code; + } + } + ] + }, + warnings: [ + { + binding: 'NON_EXISTENT', + code: 'MISSING_EXPORT', + exporter: ID_CONSTANTS, + frame: '', + id: ID_MAIN, + loc: { + column: 15, + file: ID_MAIN, + line: 12 + }, + message: + 'main.js (12:15): "NON_EXISTENT" is not exported by "constants.js", imported by "main.js".', + pos: 111, + url: 'https://rollupjs.org/troubleshooting/#error-name-is-not-exported-by-module' + } + ] +}); diff --git a/test/function/samples/warning-incorrect-sourcemap-location/constants.js b/test/function/samples/warning-incorrect-sourcemap-location/constants.js new file mode 100644 index 00000000000..a537ae96c16 --- /dev/null +++ b/test/function/samples/warning-incorrect-sourcemap-location/constants.js @@ -0,0 +1 @@ +export const q = 'Queue'; diff --git a/test/function/samples/warning-incorrect-sourcemap-location/main.js b/test/function/samples/warning-incorrect-sourcemap-location/main.js new file mode 100644 index 00000000000..409d9552d7f --- /dev/null +++ b/test/function/samples/warning-incorrect-sourcemap-location/main.js @@ -0,0 +1,5 @@ +import * as CONSTANTS from './constants'; + +export default class Sample { + x = CONSTANTS.NON_EXISTENT; +} diff --git a/test/function/samples/warning-low-resolution-location/_config.js b/test/function/samples/warning-low-resolution-location/_config.js new file mode 100644 index 00000000000..fb233d2ac4d --- /dev/null +++ b/test/function/samples/warning-low-resolution-location/_config.js @@ -0,0 +1,42 @@ +const path = require('node:path'); +const { encode } = require('@jridgewell/sourcemap-codec'); +const ID_MAIN = path.join(__dirname, 'main.js'); + +module.exports = defineTest({ + description: 'handles when a low resolution sourcemap is used to report an error', + options: { + plugins: [ + { + name: 'test-plugin', + transform() { + // each entry of each line consist of + // [generatedColumn, sourceIndex, sourceLine, sourceColumn]; + // this mapping only maps the first line to itself + const decodedMap = [[[0], [0, 0, 0, 0], [1]]]; + return { + code: 'export default this', + map: { mappings: encode(decodedMap), sources: [] } + }; + } + } + ] + }, + warnings: [ + { + code: 'THIS_IS_UNDEFINED', + frame: ` +1: console.log('original source'); + ^`, + id: ID_MAIN, + loc: { + column: 0, + file: ID_MAIN, + line: 1 + }, + message: + "main.js (1:0): The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten", + pos: 15, + url: 'https://rollupjs.org/troubleshooting/#error-this-is-undefined' + } + ] +}); diff --git a/test/function/samples/warning-low-resolution-location/main.js b/test/function/samples/warning-low-resolution-location/main.js new file mode 100644 index 00000000000..2f40c1f1894 --- /dev/null +++ b/test/function/samples/warning-low-resolution-location/main.js @@ -0,0 +1 @@ +console.log('original source'); diff --git a/test/function/samples/warnings-to-string/_config.js b/test/function/samples/warnings-to-string/_config.js index fc39492df8b..cdad433728a 100644 --- a/test/function/samples/warnings-to-string/_config.js +++ b/test/function/samples/warnings-to-string/_config.js @@ -1,19 +1,21 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'provides a string conversion for warnings', options: { - plugins: { - name: 'test-plugin', - transform(code) { - this.warn('This might be removed', code.indexOf('removed')); + plugins: [ + { + name: 'test-plugin', + transform(code) { + this.warn('This might be removed', code.indexOf('removed')); + } } - } + ] }, warnings(warnings) { assert.deepStrictEqual(warnings.map(String), [ - '(test-plugin plugin) main.js (1:6) This might be removed', - 'Generated an empty chunk: "main"' + '[plugin test-plugin] main.js (1:6): This might be removed', + 'Generated an empty chunk: "main".' ]); } -}; +}); diff --git a/test/function/samples/warns-for-invalid-options/_config.js b/test/function/samples/warns-for-invalid-options/_config.js index d4bdcdbefb7..ea32af5668b 100644 --- a/test/function/samples/warns-for-invalid-options/_config.js +++ b/test/function/samples/warns-for-invalid-options/_config.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = defineTest({ description: 'warns for invalid options', options: { myInvalidInputOption: true, @@ -11,6 +11,7 @@ module.exports = { code: 'UNKNOWN_OPTION', message: 'Unknown input options: myInvalidInputOption. Allowed options: ' + + // @ts-expect-error file outside root require('../../../misc/optionList').input }, { @@ -20,4 +21,4 @@ module.exports = { require('../../../misc/optionList').output } ] -}; +}); diff --git a/test/function/samples/watch-option/_config.js b/test/function/samples/watch-option/_config.js index 6c0b780f634..6b76a77ff71 100644 --- a/test/function/samples/watch-option/_config.js +++ b/test/function/samples/watch-option/_config.js @@ -1,6 +1,6 @@ -module.exports = { +module.exports = defineTest({ description: 'expects watch option', options: { watch: {} } -}; +}); diff --git a/test/function/samples/wellknown-protocols/hasInstance/class-instance/_config.js b/test/function/samples/wellknown-protocols/hasInstance/class-instance/_config.js new file mode 100644 index 00000000000..4b299548dce --- /dev/null +++ b/test/function/samples/wellknown-protocols/hasInstance/class-instance/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'correctly handles Symbol.hasInstance defined on class instances' +}); diff --git a/test/function/samples/wellknown-protocols/hasInstance/class-instance/main.js b/test/function/samples/wellknown-protocols/hasInstance/class-instance/main.js new file mode 100644 index 00000000000..7954f55cdec --- /dev/null +++ b/test/function/samples/wellknown-protocols/hasInstance/class-instance/main.js @@ -0,0 +1,14 @@ +let effect = false; + +class Foo { + [Symbol.hasInstance]() { + return effect = true; + } +} + +const foo = new Foo(); +if (!(null instanceof foo)) { + assert.fail('instanceof not resolved correctly (ignored Symbol.hasInstance)'); +} + +assert.ok(effect); diff --git a/test/function/samples/wellknown-protocols/hasInstance/class-static/_config.js b/test/function/samples/wellknown-protocols/hasInstance/class-static/_config.js new file mode 100644 index 00000000000..dacbe2952a9 --- /dev/null +++ b/test/function/samples/wellknown-protocols/hasInstance/class-static/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'correctly handles static Symbol.hasInstance defined on class' +}); diff --git a/test/function/samples/wellknown-protocols/hasInstance/class-static/main.js b/test/function/samples/wellknown-protocols/hasInstance/class-static/main.js new file mode 100644 index 00000000000..228aac75710 --- /dev/null +++ b/test/function/samples/wellknown-protocols/hasInstance/class-static/main.js @@ -0,0 +1,13 @@ +let effect = false; + +class Foo { + static [Symbol.hasInstance]() { + return effect = true; + } +} + +if (!(null instanceof Foo)) { + assert.fail('instanceof not resolved correctly (ignored Symbol.hasInstance)'); +} + +assert.ok(effect); diff --git a/test/function/samples/wellknown-protocols/hasInstance/object/_config.js b/test/function/samples/wellknown-protocols/hasInstance/object/_config.js new file mode 100644 index 00000000000..566022cdd58 --- /dev/null +++ b/test/function/samples/wellknown-protocols/hasInstance/object/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'correctly handles Symbol.hasInstance defined on objects' +}); diff --git a/test/function/samples/wellknown-protocols/hasInstance/object/main.js b/test/function/samples/wellknown-protocols/hasInstance/object/main.js new file mode 100644 index 00000000000..efe70356aae --- /dev/null +++ b/test/function/samples/wellknown-protocols/hasInstance/object/main.js @@ -0,0 +1,11 @@ +let effect = false; + +const Foo = { + [Symbol.hasInstance]: () => effect = true +} + +if (!(null instanceof Foo)) { + assert.fail('instanceof not resolved correctly (ignored Symbol.hasInstance)'); +} + +assert.ok(effect); diff --git a/test/function/samples/wellknown-protocols/toStringTag/class-instance/_config.js b/test/function/samples/wellknown-protocols/toStringTag/class-instance/_config.js new file mode 100644 index 00000000000..ba8a9f46238 --- /dev/null +++ b/test/function/samples/wellknown-protocols/toStringTag/class-instance/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'correctly handles Symbol.toStringTag defined on class instances' +}); diff --git a/test/function/samples/wellknown-protocols/toStringTag/class-instance/main.js b/test/function/samples/wellknown-protocols/toStringTag/class-instance/main.js new file mode 100644 index 00000000000..11f6c0ae585 --- /dev/null +++ b/test/function/samples/wellknown-protocols/toStringTag/class-instance/main.js @@ -0,0 +1,12 @@ +let effect = false; + +class Foo { + get [Symbol.toStringTag]() { + effect = true; + return "Meow"; + } +} + +const foo = '' + (new Foo()); +assert.strictEqual(foo, "[object Meow]"); +assert.ok(effect); diff --git a/test/function/samples/wellknown-protocols/toStringTag/object/_config.js b/test/function/samples/wellknown-protocols/toStringTag/object/_config.js new file mode 100644 index 00000000000..9913db736b0 --- /dev/null +++ b/test/function/samples/wellknown-protocols/toStringTag/object/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'correctly handles Symbol.toStringTag defined on objects' +}); diff --git a/test/function/samples/wellknown-protocols/toStringTag/object/main.js b/test/function/samples/wellknown-protocols/toStringTag/object/main.js new file mode 100644 index 00000000000..2914159c11d --- /dev/null +++ b/test/function/samples/wellknown-protocols/toStringTag/object/main.js @@ -0,0 +1,12 @@ +let effect = false; + +const Foo = { + get [Symbol.toStringTag] () { + effect = true; + return "Meow"; + } +} + +const foo = '' + Foo; +assert.strictEqual(foo, "[object Meow]"); +assert.ok(effect); diff --git a/test/function/samples/wrap-empty-object-with-double-brackets/_config.js b/test/function/samples/wrap-empty-object-with-double-brackets/_config.js new file mode 100644 index 00000000000..51d3a0c6c32 --- /dev/null +++ b/test/function/samples/wrap-empty-object-with-double-brackets/_config.js @@ -0,0 +1,3 @@ +module.exports = defineTest({ + description: 'wrap double brackets to empty object' +}); diff --git a/test/function/samples/wrap-empty-object-with-double-brackets/main.js b/test/function/samples/wrap-empty-object-with-double-brackets/main.js new file mode 100644 index 00000000000..de9628c9346 --- /dev/null +++ b/test/function/samples/wrap-empty-object-with-double-brackets/main.js @@ -0,0 +1,2 @@ +Object.prototype.customize_fn = () => {}; +const c = {}.customize_fn(); diff --git a/test/function/samples/wraps-object-expressions-as-statements/_config.js b/test/function/samples/wraps-object-expressions-as-statements/_config.js index 0e64ab19194..f3d5c6d7626 100644 --- a/test/function/samples/wraps-object-expressions-as-statements/_config.js +++ b/test/function/samples/wraps-object-expressions-as-statements/_config.js @@ -1,3 +1,3 @@ -module.exports = { +module.exports = defineTest({ description: 'wraps object expressions that have become statements' -}; +}); diff --git a/test/function/samples/wraps-simplified-expressions/_config.js b/test/function/samples/wraps-simplified-expressions/_config.js index 3b13ae71054..481ea4f3841 100644 --- a/test/function/samples/wraps-simplified-expressions/_config.js +++ b/test/function/samples/wraps-simplified-expressions/_config.js @@ -1,6 +1,8 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'wraps simplified expressions that have become callees if necessary', - warnings: warnings => warnings.forEach(warning => assert.equal(warning.code, 'EVAL')) -}; + warnings: warnings => { + for (const warning of warnings) assert.equal(warning.code, 'EVAL'); + } +}); diff --git a/test/function/tsconfig.json b/test/function/tsconfig.json new file mode 100644 index 00000000000..4a26f3ee84c --- /dev/null +++ b/test/function/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": "../tsconfig.base.json", + "include": [ + "**/_config.js", + "./index.js", + "./define.d.ts" + ] +} diff --git a/test/hooks/index.js b/test/hooks/index.js index 30e26bd75a8..4e7f4669140 100644 --- a/test/hooks/index.js +++ b/test/hooks/index.js @@ -1,45 +1,43 @@ -const path = require('path'); -const assert = require('assert'); -const sander = require('sander'); -const { loader } = require('../utils.js'); +const assert = require('node:assert'); +const path = require('node:path'); +const { outputFile, readdir, remove } = require('fs-extra'); +/** + * @type {import("../../src/rollup/types")} Rollup + */ const rollup = require('../../dist/rollup.js'); +const { loader, wait } = require('../testHelpers.js'); const TEMP_DIR = path.join(__dirname, 'tmp'); describe('hooks', () => { - it('allows to replace file with dir in the outputOptions hook', () => - rollup - .rollup({ - input: 'input', - treeshake: false, - plugins: [ - loader({ - input: `console.log('input');import('other');`, - other: `console.log('other');` - }), - { - outputOptions(options) { - const newOptions = Object.assign({}, options, { - dir: TEMP_DIR, - chunkFileNames: 'chunk.js' - }); - delete newOptions.file; - return newOptions; - } + before(() => remove(TEMP_DIR)); + + it('allows to replace file with dir in the outputOptions hook', async () => { + const bundle = await rollup.rollup({ + input: 'input', + treeshake: false, + plugins: [ + loader({ + input: `console.log('input');import('other');`, + other: `console.log('other');` + }), + { + outputOptions(options) { + const newOptions = { ...options, dir: TEMP_DIR, chunkFileNames: 'chunk.js' }; + delete newOptions.file; + return newOptions; } - ] - }) - .then(bundle => - bundle.write({ - file: path.join(TEMP_DIR, 'bundle.js'), - format: 'es' - }) - ) - .then(() => { - const fileNames = sander.readdirSync(TEMP_DIR).sort(); - assert.deepStrictEqual(fileNames, ['chunk.js', 'input.js']); - return sander.rimraf(TEMP_DIR); - })); + } + ] + }); + await bundle.write({ + file: path.join(TEMP_DIR, 'bundle.js'), + format: 'es' + }); + const fileNames = (await readdir(TEMP_DIR)).sort(); + await remove(TEMP_DIR); + assert.deepStrictEqual(fileNames, ['chunk.js', 'input.js']); + }); it('supports buildStart and buildEnd hooks', () => { let buildStartCnt = 0; @@ -63,7 +61,7 @@ describe('hooks', () => { } ] }) - .then(bundle => { + .then(() => { assert.strictEqual(buildStartCnt, 1); assert.strictEqual(buildEndCnt, 1); @@ -82,8 +80,8 @@ describe('hooks', () => { ] }); }) - .catch(err => { - assert.ok(err); + .catch(error => { + assert.ok(error); }) .then(() => { assert.strictEqual(buildStartCnt, 2); @@ -98,10 +96,10 @@ describe('hooks', () => { input: 'input', onwarn(warning) { if (callCnt === 0) { - assert.strictEqual(warning.message, 'build start'); + assert.strictEqual(warning.message, '[plugin at position 2] build start'); callCnt++; } else if (callCnt === 1) { - assert.strictEqual(warning.message, 'build end'); + assert.strictEqual(warning.message, '[plugin at position 2] build end'); callCnt++; } }, @@ -134,7 +132,7 @@ describe('hooks', () => { this.error('build start error'); }, buildEnd(error) { - assert.strictEqual(error.message, 'build start error'); + assert.strictEqual(error.message, '[plugin at position 2] build start error'); handledError = true; } } @@ -142,52 +140,13 @@ describe('hooks', () => { }) .catch(error => { assert.ok(handledError); - assert.strictEqual(error.message, 'build start error'); + assert.strictEqual(error.message, '[plugin at position 2] build start error'); }) .then(() => { assert.ok(handledError); }); }); - it('supports isExternal on plugin context', () => - rollup.rollup({ - input: 'input', - external: ['test'], - plugins: [ - loader({ input: `alert('hello')` }), - { - buildStart() { - assert.strictEqual(this.isExternal('test'), true); - assert.strictEqual(this.isExternal('another'), false); - } - } - ] - })); - - it('supports resolveId on plugin context', () => - rollup - .rollup({ - input: 'input', - plugins: [ - loader({ - input: `import 'test'`, - dep1: `import 'next'`, - dep2: `alert('hello')` - }), - { - resolveId(id) { - if (id === 'test') return 'dep1'; - if (id === 'next') return this.resolveId('final'); - if (id === 'final') return 'dep2'; - } - } - ] - }) - .then(bundle => bundle.generate({ format: 'es' })) - .then(({ output: [output] }) => { - assert.strictEqual(output.code, `alert('hello');\n`); - })); - it('caches chunk emission in transform hook', () => { let cache; return rollup @@ -214,9 +173,9 @@ describe('hooks', () => { .then(({ output }) => { assert.strictEqual( output[0].code, - `var input = new URL('chunk-928cb70b.js', import.meta.url).href;\n\nexport default input;\n` + `var input = new URL('chunk-CnTfOX_8.js', import.meta.url).href;\n\nexport { input as default };\n` ); - assert.strictEqual(output[1].fileName, 'chunk-928cb70b.js'); + assert.strictEqual(output[1].fileName, 'chunk-CnTfOX_8.js'); assert.strictEqual(output[1].code, `console.log('chunk');\n`); return rollup.rollup({ @@ -239,9 +198,9 @@ describe('hooks', () => { .then(({ output }) => { assert.strictEqual( output[0].code, - `var input = new URL('chunk-928cb70b.js', import.meta.url).href;\n\nexport default input;\n` + `var input = new URL('chunk-CnTfOX_8.js', import.meta.url).href;\n\nexport { input as default };\n` ); - assert.strictEqual(output[1].fileName, 'chunk-928cb70b.js'); + assert.strictEqual(output[1].fileName, 'chunk-CnTfOX_8.js'); assert.strictEqual(output[1].code, `console.log('chunk');\n`); return rollup.rollup({ @@ -261,15 +220,15 @@ describe('hooks', () => { .then(({ output }) => { assert.strictEqual( output[0].code, - `var input = new URL('chunk-928cb70b.js', import.meta.url).href;\n\nexport default input;\n` + `var input = new URL('chunk-CnTfOX_8.js', import.meta.url).href;\n\nexport { input as default };\n` ); - assert.strictEqual(output[1].fileName, 'chunk-928cb70b.js'); + assert.strictEqual(output[1].fileName, 'chunk-CnTfOX_8.js'); assert.strictEqual(output[1].code, `console.log('chunk');\n`); }); }); - it('does not overwrite files in other outputs when emitting assets during generate', () => { - return rollup + it('does not overwrite files in other outputs when emitting assets during generate', () => + rollup .rollup({ input: 'input', plugins: [ @@ -294,8 +253,7 @@ describe('hooks', () => { assert.strictEqual(output2.length, 2, 'output2'); assert.strictEqual(output2[1].fileName, 'asset'); assert.strictEqual(output2[1].source, 'cjs'); - }); - }); + })); it('caches asset emission in transform hook', () => { let cache; @@ -322,9 +280,9 @@ describe('hooks', () => { .then(({ output }) => { assert.strictEqual( output[0].code, - `var input = new URL('assets/test-0a676135.ext', import.meta.url).href;\n\nexport default input;\n` + `var input = new URL('assets/test-DHthXMdY.ext', import.meta.url).href;\n\nexport { input as default };\n` ); - assert.strictEqual(output[1].fileName, 'assets/test-0a676135.ext'); + assert.strictEqual(output[1].fileName, 'assets/test-DHthXMdY.ext'); assert.strictEqual(output[1].source, 'hello world'); return rollup.rollup({ @@ -347,9 +305,9 @@ describe('hooks', () => { .then(({ output }) => { assert.strictEqual( output[0].code, - `var input = new URL('assets/test-0a676135.ext', import.meta.url).href;\n\nexport default input;\n` + `var input = new URL('assets/test-DHthXMdY.ext', import.meta.url).href;\n\nexport { input as default };\n` ); - assert.strictEqual(output[1].fileName, 'assets/test-0a676135.ext'); + assert.strictEqual(output[1].fileName, 'assets/test-DHthXMdY.ext'); assert.strictEqual(output[1].source, 'hello world'); return rollup.rollup({ @@ -369,9 +327,9 @@ describe('hooks', () => { .then(({ output }) => { assert.strictEqual( output[0].code, - `var input = new URL('assets/test-0a676135.ext', import.meta.url).href;\n\nexport default input;\n` + `var input = new URL('assets/test-DHthXMdY.ext', import.meta.url).href;\n\nexport { input as default };\n` ); - assert.strictEqual(output[1].fileName, 'assets/test-0a676135.ext'); + assert.strictEqual(output[1].fileName, 'assets/test-DHthXMdY.ext'); assert.strictEqual(output[1].source, 'hello world'); }); }); @@ -417,10 +375,10 @@ describe('hooks', () => { assert.strictEqual( output[0].code, `console.log('imported');\n\n` + - `var input = new URL('assets/test-09aeb845.ext', import.meta.url).href;\n\n` + - `export default input;\n` + `var input = new URL('assets/test-D4aMR-gt.ext', import.meta.url).href;\n\n` + + `export { input as default };\n` ); - assert.strictEqual(output[1].fileName, 'assets/test-09aeb845.ext'); + assert.strictEqual(output[1].fileName, 'assets/test-D4aMR-gt.ext'); assert.strictEqual(output[1].source, 'first run'); return rollup.rollup({ @@ -450,10 +408,10 @@ describe('hooks', () => { assert.strictEqual( output[0].code, `console.log('imported');\n\n` + - `var input = new URL('assets/test-ce5fc71b.ext', import.meta.url).href;\n\n` + - `export default input;\n` + `var input = new URL('assets/test-D40n34Dy.ext', import.meta.url).href;\n\n` + + `export { input as default };\n` ); - assert.strictEqual(output[1].fileName, 'assets/test-ce5fc71b.ext'); + assert.strictEqual(output[1].fileName, 'assets/test-D40n34Dy.ext'); assert.strictEqual(output[1].source, 'second run'); }); }); @@ -488,11 +446,11 @@ describe('hooks', () => { .then(({ output }) => { assert.strictEqual( output[0].code, - `var input = new URL('assets/test-0a676135.ext', import.meta.url).href;\n\nexport default input;\n` + `var input = new URL('assets/test-DHthXMdY.ext', import.meta.url).href;\n\nexport { input as default };\n` ); - assert.strictEqual(output[1].fileName, 'assets/test-0a676135.ext'); + assert.strictEqual(output[1].fileName, 'assets/test-DHthXMdY.ext'); assert.strictEqual(output[1].source, 'hello world'); - assert.strictEqual(output[1].fileName, 'assets/test-0a676135.ext'); + assert.strictEqual(output[1].fileName, 'assets/test-DHthXMdY.ext'); assert.strictEqual(output[1].source, 'hello world'); return rollup.rollup({ @@ -533,52 +491,49 @@ describe('hooks', () => { const chunk = outputBundle['input.js']; // can detect that b has been tree-shaken this way - assert.strictEqual(chunk.modules['dep'].renderedExports[0], 'a'); - assert.strictEqual(chunk.modules['dep'].renderedExports.length, 1); + assert.strictEqual(chunk.modules.dep.renderedExports[0], 'a'); + assert.strictEqual(chunk.modules.dep.renderedExports.length, 1); - assert.strictEqual(chunk.modules['dep'].removedExports[0], 'b'); - assert.strictEqual(chunk.modules['dep'].removedExports.length, 1); + assert.strictEqual(chunk.modules.dep.removedExports[0], 'b'); + assert.strictEqual(chunk.modules.dep.removedExports.length, 1); - assert.strictEqual(chunk.modules['dep'].renderedLength, 10); - assert.strictEqual(chunk.modules['dep'].originalLength, 35); + assert.strictEqual(chunk.modules.dep.renderedLength, 10); + assert.strictEqual(chunk.modules.dep.originalLength, 35); } } ] }) .then(bundle => bundle.generate({ format: 'es' }))); - it('supports writeBundle hook', () => { + it('supports writeBundle hook', async () => { const file = path.join(TEMP_DIR, 'bundle.js'); - let bundle; + let generatedBundle; let callCount = 0; - return rollup - .rollup({ - input: 'input', - plugins: [ - loader({ - input: `export { a as default } from 'dep';`, - dep: `export var a = 1; export var b = 2;` - }), - { - generateBundle(options, outputBundle, isWrite) { - bundle = outputBundle; - assert.strictEqual(isWrite, true); - } - }, - { - writeBundle(options, outputBundle) { - assert.deepStrictEqual(options.file, file); - assert.deepStrictEqual(outputBundle, bundle); - callCount++; - } + const bundle = await rollup.rollup({ + input: 'input', + plugins: [ + loader({ + input: `export { a as default } from 'dep';`, + dep: `export var a = 1; export var b = 2;` + }), + { + generateBundle(options, outputBundle, isWrite) { + generatedBundle = outputBundle; + assert.strictEqual(isWrite, true); } - ] - }) - .then(bundle => bundle.write({ format: 'es', file })) - .then(() => { - assert.strictEqual(callCount, 1); - return sander.rimraf(TEMP_DIR); - }); + }, + { + writeBundle(options, outputBundle) { + assert.deepStrictEqual(options.file, file); + assert.deepStrictEqual(outputBundle, generatedBundle); + callCount++; + } + } + ] + }); + await bundle.write({ format: 'es', file }); + await remove(TEMP_DIR); + assert.strictEqual(callCount, 1); }); it('supports this.cache for plugins', () => @@ -661,7 +616,7 @@ describe('hooks', () => { }) .then(bundle => { let promise = Promise.resolve(); - for (let i = 0; i < 5; i++) + for (let index = 0; index < 5; index++) promise = promise.then(() => rollup.rollup({ cache: bundle.cache, @@ -672,7 +627,7 @@ describe('hooks', () => { { name: 'x', buildStart() { - if (i === 4) assert.strictEqual(this.cache.has('second'), true); + if (index === 4) assert.strictEqual(this.cache.has('second'), true); } } ] @@ -824,7 +779,7 @@ describe('hooks', () => { renderStartCount++; }, renderChunk() { - throw Error('renderChunk error'); + throw new Error('renderChunk error'); }, generateBundle() { generateBundleCount++; @@ -839,8 +794,8 @@ describe('hooks', () => { ] }) .then(bundle => bundle.generate({ format: 'es' })) - .catch(err => { - assert.ok(err); + .catch(error => { + assert.ok(error); }) .then(() => { assert.strictEqual(renderStartCount, 1, 'renderStart count'); @@ -863,10 +818,10 @@ describe('hooks', () => { else if (event.code === 'ERROR') reject(event.error); }); }) - .catch(err => { + .catch(error => { watcher.close(); assert.strictEqual( - err.message, + error.message, 'You must specify "output.file" or "output.dir" for the build.' ); }) @@ -888,11 +843,11 @@ describe('hooks', () => { else if (event.code === 'ERROR') reject(event.error); }); }) - .catch(err => { + .catch(error => { watcher.close(); assert.strictEqual( - err.message, - 'When building multiple chunks, the "output.dir" option must be used, not "output.file". To inline dynamic imports, set the "inlineDynamicImports" option.' + error.message, + 'Invalid value for option "output.file" - when building multiple chunks, the "output.dir" option must be used, not "output.file". To inline dynamic imports, set the "inlineDynamicImports" option.' ); }) .then(() => watcher.close()); @@ -914,11 +869,11 @@ describe('hooks', () => { else if (event.code === 'ERROR') reject(event.error); }); }) - .catch(err => { + .catch(error => { watcher.close(); assert.strictEqual( - err.message, - '"output.sourcemapFile" is only supported for single-file builds.' + error.message, + 'Invalid value for option "output.sourcemapFile" - "output.sourcemapFile" is only supported for single-file builds.' ); }) .then(() => watcher.close()); @@ -938,7 +893,7 @@ describe('hooks', () => { d: `export default {};` }), { - renderChunk(code, chunk, options) { + renderChunk(code, chunk) { chunks.push({ fileName: chunk.fileName, imports: chunk.imports, @@ -967,15 +922,15 @@ describe('hooks', () => { imports: ['generated-c.js'], modules: ['d', 'a'] }, - { - fileName: 'generated-c.js', - imports: [], - modules: ['c'] - }, { fileName: 'generated-b.js', imports: ['generated-c.js'], modules: ['b'] + }, + { + fileName: 'generated-c.js', + imports: [], + modules: ['c'] } ]); }); @@ -1006,34 +961,11 @@ describe('hooks', () => { entryFileNames: '[name]-[hash].js' }) ) - .then(output => { + .then(() => { assert.strictEqual(augmentChunkHashCalls, 1); }); }); - it('passes bundle object to generateBundle hook', () => - rollup - .rollup({ - input: 'input', - plugins: [ - loader({ input: `alert('hello')` }), - { - transform() { - const assetId = this.emitAsset('test.ext', 'hello world'); - return `export default import.meta.ROLLUP_ASSET_URL_${assetId};`; - }, - generateBundle(options, outputBundle, isWrite) { - assert.strictEqual(outputBundle['assets/test-0a676135.ext'].source, 'hello world'); - assert.strictEqual( - outputBundle['input.js'].code, - `var input = new URL('assets/test-0a676135.ext', import.meta.url).href;\n\nexport default input;\n` - ); - } - } - ] - }) - .then(bundle => bundle.generate({ format: 'es' }))); - it('supports closeBundle hook', () => { let closeBundleCalls = 0; return rollup @@ -1092,7 +1024,7 @@ describe('hooks', () => { }) .then(bundle => bundle.close()) .catch(error => { - assert.strictEqual(error.message, 'close bundle error'); + assert.strictEqual(error.message, '[plugin at position 2] close bundle error'); handledError = true; }) .then(() => { @@ -1100,269 +1032,313 @@ describe('hooks', () => { }); }); - describe('deprecated', () => { - it('caches chunk emission in transform hook', () => { - let cache; - return rollup - .rollup({ - input: 'input', - plugins: [ - loader({ input: '', chunk: "console.log('chunk');" }), - { - transform(code, id) { - if (id === 'input') { - return `export default import.meta.ROLLUP_CHUNK_URL_${this.emitChunk('chunk')};`; - } - } + it('passes build error to the closeBundle hook', () => { + let buildError; + return rollup + .rollup({ + input: 'input', + plugins: [ + loader({ input: 'some broken code' }), + { + closeBundle(error) { + buildError = error; } - ] - }) - .then(bundle => { - cache = bundle.cache; - return bundle.generate({ format: 'es' }); - }) - .then(({ output }) => { - assert.strictEqual( - output[0].code, - `var input = new URL('chunk-928cb70b.js', import.meta.url).href;\n\nexport default input;\n` - ); - assert.strictEqual(output[1].fileName, 'chunk-928cb70b.js'); - assert.strictEqual(output[1].code, `console.log('chunk');\n`); - - return rollup.rollup({ - cache, - input: 'input', - plugins: [ - loader({ input: '', chunk: "console.log('chunk');" }), - { - transform() { - assert.fail('Should cache transform'); - } - } - ] - }); - }) - .then(bundle => { - cache = bundle.cache; - return bundle.generate({ format: 'es' }); - }) - .then(({ output }) => { - assert.strictEqual( - output[0].code, - `var input = new URL('chunk-928cb70b.js', import.meta.url).href;\n\nexport default input;\n` - ); - assert.strictEqual(output[1].fileName, 'chunk-928cb70b.js'); - assert.strictEqual(output[1].code, `console.log('chunk');\n`); + } + ] + }) + .then(bundle => bundle.close()) + .catch(error => { + assert.strictEqual( + error.message, + `input (1:5): Expected ';', '}' or (Note that you need plugins to import files that are not JavaScript)` + ); + }) + .then(() => { + assert.ok(buildError); + }); + }); - return rollup.rollup({ - cache, - input: 'input', - plugins: [ - loader({ input: '', chunk: "console.log('chunk');" }), - { - transform() { - assert.fail('Should cache transform'); - } - } - ] - }); - }) - .then(bundle => bundle.generate({ format: 'es' })) - .then(({ output }) => { - assert.strictEqual( - output[0].code, - `var input = new URL('chunk-928cb70b.js', import.meta.url).href;\n\nexport default input;\n` - ); - assert.strictEqual(output[1].fileName, 'chunk-928cb70b.js'); - assert.strictEqual(output[1].code, `console.log('chunk');\n`); - }); - }); + it('passes buildEnd error to the closeBundle hook', () => { + let buildEndError; + return rollup + .rollup({ + input: 'input', + plugins: [ + loader({ input: 'console.log(42);' }), + { + buildEnd() { + this.error('build end error'); + }, + closeBundle(error) { + buildEndError = error; + } + } + ] + }) + .then(bundle => bundle.close()) + .catch(error => { + assert.strictEqual(error.message, '[plugin at position 2] build end error'); + }) + .then(() => { + assert.ok(buildEndError); + }); + }); - it('caches asset emission in transform hook', () => { - let cache; - return rollup - .rollup({ - input: 'input', - plugins: [ - loader({ input: '' }), - { - transform() { - const assetId = this.emitAsset('test.ext', 'hello world'); - return `export default import.meta.ROLLUP_ASSET_URL_${assetId};`; - } + it('merges build and buildEnd errors', () => { + let buildEndError; + return rollup + .rollup({ + input: 'input', + plugins: [ + loader({ input: 'some broken code' }), + { + buildEnd() { + this.error('build end error'); + }, + closeBundle(error) { + buildEndError = error; } - ] - }) - .then(bundle => { - cache = bundle.cache; - return bundle.generate({ format: 'es' }); - }) - .then(({ output }) => { - assert.strictEqual( - output[0].code, - `var input = new URL('assets/test-0a676135.ext', import.meta.url).href;\n\nexport default input;\n` - ); - assert.strictEqual(output[1].fileName, 'assets/test-0a676135.ext'); - assert.strictEqual(output[1].source, 'hello world'); - assert.strictEqual(output[1].fileName, 'assets/test-0a676135.ext'); - assert.strictEqual(output[1].source, 'hello world'); + } + ] + }) + .then(bundle => bundle.close()) + .catch(error => { + // Ensure error correctly copies the original build error + assert.strictEqual(error.cause.message, "Expected ';', '}' or "); + assert.strictEqual(error.code, 'PARSE_ERROR'); + assert.strictEqual(error.frame, '1: some broken code\n ^'); + assert.strictEqual(error.id, 'input'); + assert.deepStrictEqual(error.loc, { file: 'input', line: 1, column: 5 }); + assert.strictEqual( + error.message, + 'There was an error during the build:\n' + + " input (1:5): Expected ';', '}' or (Note that you need plugins to import files that are not JavaScript)\n" + + "Additionally, handling the error in the 'buildEnd' hook caused the following error:\n" + + ' [plugin at position 2] build end error' + ); + assert.strictEqual(error.name, 'RollupError'); + assert.strictEqual(error.pos, 5); + assert.ok(error.stack.startsWith(`${error.name}: ${error.message}\n`)); + }) + .then(() => { + assert.ok(buildEndError); + }); + }); - return rollup.rollup({ - cache, - input: 'input', - plugins: [ - loader({ input: '' }), - { - transform() { - assert.fail('Should cache transform'); - } - } - ] - }); - }) - .then(bundle => { - cache = bundle.cache; - return bundle.generate({ format: 'es' }); + it('supports disabling sanitization for in-memory / in-browser / non-fs builds', () => + rollup + .rollup({ + input: 'input.js', + plugins: [ + { + resolveId: id => id, + load: () => `export default 5` + } + ] + }) + .then(bundle => + bundle.generate({ + format: 'es', + sanitizeFileName: false, + entryFileNames: 'test:[name]' }) - .then(({ output }) => { - assert.strictEqual( - output[0].code, - `var input = new URL('assets/test-0a676135.ext', import.meta.url).href;\n\nexport default input;\n` - ); - assert.strictEqual(output[1].fileName, 'assets/test-0a676135.ext'); - assert.strictEqual(output[1].source, 'hello world'); - assert.strictEqual(output[1].fileName, 'assets/test-0a676135.ext'); - assert.strictEqual(output[1].source, 'hello world'); + ) + .then(({ output }) => { + assert.strictEqual(output[0].fileName, 'test:input'); + })); - return rollup.rollup({ - cache, - input: 'input', - plugins: [ - loader({ input: '' }), - { - transform() { - assert.fail('Should cache transform'); - } - } - ] - }); - }) - .then(bundle => bundle.generate({ format: 'es' })) - .then(({ output }) => { - assert.strictEqual( - output[0].code, - `var input = new URL('assets/test-0a676135.ext', import.meta.url).href;\n\nexport default input;\n` - ); - assert.strictEqual(output[1].fileName, 'assets/test-0a676135.ext'); - assert.strictEqual(output[1].source, 'hello world'); - assert.strictEqual(output[1].fileName, 'assets/test-0a676135.ext'); - assert.strictEqual(output[1].source, 'hello world'); - }); - }); + it('allows to enforce plugin hook order in watch mode', async () => { + const hooks = ['closeBundle', 'closeWatcher', 'renderError', 'watchChange', 'writeBundle']; - it('opts-out transform hook cache for custom cache', () => { - let runs = 0; - let cache; - return rollup - .rollup({ - input: 'input', - plugins: [ - loader({ input: '' }), - { - name: 'x', - transform() { - this.cache.set('asdf', 'asdf'); - runs++; - const assetId = this.emitAsset('test.ext', 'hello world'); - return `export default import.meta.ROLLUP_ASSET_URL_${assetId};`; - } + const calledHooks = {}; + for (const hook of hooks) { + calledHooks[hook] = []; + } + + let first = true; + const plugins = [ + { + name: 'render-error', + renderChunk() { + if (first) { + first = false; + throw new Error('Expected render error'); + } + } + } + ]; + addPlugin(null); + addPlugin('pre'); + addPlugin('post'); + addPlugin('post'); + addPlugin('pre'); + addPlugin(); + + function addPlugin(order) { + const name = `${order}-${plugins.length}`; + const plugin = { name }; + for (const hook of hooks) { + plugin[hook] = { + order, + handler() { + if (!calledHooks[hook].includes(name)) { + calledHooks[hook].push(name); } - ] - }) - .then(bundle => { - cache = bundle.cache; - return bundle.generate({ format: 'es' }); - }) - .then(({ output }) => { - assert.strictEqual( - output[0].code, - `var input = new URL('assets/test-0a676135.ext', import.meta.url).href;\n\nexport default input;\n` - ); - assert.strictEqual(output[1].fileName, 'assets/test-0a676135.ext'); - assert.strictEqual(output[1].source, 'hello world'); - assert.strictEqual(output[1].fileName, 'assets/test-0a676135.ext'); - assert.strictEqual(output[1].source, 'hello world'); + } + }; + } + plugins.push(plugin); + } - return rollup.rollup({ - cache, - input: 'input', - plugins: [ - loader({ input: '' }), - { - name: 'x', - transform() { - runs++; - return `alert('hello world')`; - } - } - ] - }); - }) - .then(bundle => bundle.generate({ format: 'es' })) - .then(({ output }) => { - assert.strictEqual(runs, 2); - assert.strictEqual(output[0].code.trim(), `alert('hello world');`); - assert.strictEqual(output.length, 1); - }); + const ID_MAIN = path.join(TEMP_DIR, 'main.js'); + await outputFile(ID_MAIN, 'console.log(42);'); + await wait(100); + + const watcher = rollup.watch({ + input: ID_MAIN, + output: { + format: 'es', + dir: path.join(TEMP_DIR, 'out') + }, + plugins }); - it('allows setting asset source at generateBundle', () => { - let assetId; - return rollup - .rollup({ - input: 'input', - plugins: [ - loader({ input: `alert('hello')` }), - { - transform() { - return ''; - }, - generateBundle() { - assetId = this.emitAsset('test.ext'); - this.setAssetSource(assetId, 'hello world'); - } - } - ] - }) - .then(bundle => bundle.generate({ format: 'es' })) - .then(({ output: [, output] }) => { - assert.strictEqual(output.source, 'hello world'); - }); + return new Promise((resolve, reject) => { + watcher.on('event', async event => { + if (event.code === 'ERROR') { + if (event.error.message !== 'Expected render error') { + reject(event.error); + } + await wait(300); + await outputFile(ID_MAIN, 'console.log(43);'); + } else if (event.code === 'BUNDLE_END') { + await event.result.close(); + resolve(); + } + }); + }).finally(async () => { + await watcher.close(); + await remove(TEMP_DIR); + for (const hook of hooks) { + assert.deepStrictEqual( + calledHooks[hook], + ['pre-2', 'pre-5', 'null-1', 'undefined-6', 'post-3', 'post-4'], + hook + ); + } }); + }); - it('allows setting asset source separately', () => { - let assetId; - return rollup - .rollup({ - input: 'input', - plugins: [ - loader({ input: `alert('hello')` }), - { - transform() { - assetId = this.emitAsset('test.ext'); - return ''; - }, - generateBundle() { - this.setAssetSource(assetId, 'hello world'); - } + it('allows to enforce sequential plugin hook order in watch mode', async () => { + const hooks = ['closeBundle', 'closeWatcher', 'renderError', 'watchChange', 'writeBundle']; + + const calledHooks = {}; + const activeHooks = {}; + for (const hook of hooks) { + calledHooks[hook] = []; + activeHooks[hook] = new Set(); + } + + let first = true; + const plugins = [ + { + name: 'render-error', + renderChunk() { + if (first) { + first = false; + throw new Error('Expected render error'); + } + } + } + ]; + addPlugin(null, true); + addPlugin('pre', false); + addPlugin('post', false); + addPlugin('post', false); + addPlugin('pre', false); + addPlugin(undefined, true); + addPlugin(null, false); + addPlugin('pre', true); + addPlugin('post', true); + addPlugin('post', true); + addPlugin('pre', true); + addPlugin(undefined, false); + + function addPlugin(order, sequential) { + const name = `${order}-${sequential ? 'seq-' : ''}${plugins.length}`; + const plugin = { name }; + for (const hook of hooks) { + plugin[hook] = { + order, + async handler() { + const active = activeHooks[hook]; + if (!calledHooks[hook].includes(name)) { + calledHooks[hook].push(sequential ? name : [name, [...active]]); } - ] - }) - .then(bundle => bundle.generate({ format: 'es' })) - .then(({ output: [, output] }) => { - assert.strictEqual(output.fileName, 'assets/test-0a676135.ext'); - assert.strictEqual(output.source, 'hello world'); - }); + if (sequential && active.size > 0) { + throw new Error(`Detected parallel hook runs in ${hook}.`); + } + active.add(name); + // A setTimeout always takes longer than any chain of immediately + // resolved promises + await wait(0); + active.delete(name); + }, + sequential + }; + } + plugins.push(plugin); + } + + const ID_MAIN = path.join(TEMP_DIR, 'main.js'); + await outputFile(ID_MAIN, 'console.log(42);'); + await wait(100); + + const watcher = rollup.watch({ + input: ID_MAIN, + output: { + format: 'es', + dir: path.join(TEMP_DIR, 'out') + }, + plugins + }); + + return new Promise((resolve, reject) => { + watcher.on('event', async event => { + if (event.code === 'ERROR') { + if (event.error.message !== 'Expected render error') { + reject(event.error); + } + await wait(300); + await outputFile(ID_MAIN, 'console.log(43);'); + } else if (event.code === 'BUNDLE_END') { + await event.result.close(); + resolve(); + } + }); + }).finally(async () => { + await watcher.close(); + await remove(TEMP_DIR); + for (const hook of hooks) { + assert.deepStrictEqual( + calledHooks[hook], + [ + ['pre-2', []], + ['pre-5', ['pre-2']], + 'pre-seq-8', + 'pre-seq-11', + 'null-seq-1', + 'undefined-seq-6', + ['null-7', []], + ['undefined-12', ['null-7']], + ['post-3', ['null-7', 'undefined-12']], + ['post-4', ['null-7', 'undefined-12', 'post-3']], + 'post-seq-9', + 'post-seq-10' + ], + hook + ); + } }); }); }); diff --git a/test/incremental/index.js b/test/incremental/index.js index 55375856b59..0714db921f0 100644 --- a/test/incremental/index.js +++ b/test/incremental/index.js @@ -1,7 +1,9 @@ -const assert = require('assert'); -const acorn = require('acorn'); -const { executeBundle } = require('../utils.js'); +const assert = require('node:assert'); +/** + * @type {import('../../src/rollup/types')} Rollup + */ const rollup = require('../../dist/rollup'); +const { executeBundle, getBundleCode, getObject } = require('../testHelpers.js'); describe('incremental', () => { let resolveIdCalls; @@ -14,9 +16,7 @@ describe('incremental', () => { return id === 'external' ? false : id; }, - load: id => { - return modules[id]; - }, + load: id => modules[id], transform: code => { transformCalls++; @@ -74,7 +74,7 @@ describe('incremental', () => { cache: bundle }); }) - .then(bundle => { + .then(() => { assert.strictEqual(resolveIdCalls, 3); // +1 for entry point which is resolved every time assert.strictEqual(transformCalls, 2); }); @@ -98,13 +98,13 @@ describe('incremental', () => { cache = bundle.cache; }); }) - .then(() => { - return rollup.rollup({ + .then(() => + rollup.rollup({ input: 'entry', plugins: [plugin], cache - }); - }) + }) + ) .then(bundle => { assert.strictEqual(transformCalls, 3); @@ -133,13 +133,13 @@ describe('incremental', () => { cache = bundle.cache; }); }) - .then(() => { - return rollup.rollup({ + .then(() => + rollup.rollup({ input: 'entry', plugins: [plugin], cache - }); - }) + }) + ) .then(bundle => { assert.strictEqual(resolveIdCalls, 4); @@ -169,13 +169,13 @@ describe('incremental', () => { cache = bundle.cache; }); }) - .then(() => { - return rollup.rollup({ + .then(() => + rollup.rollup({ input: 'entry', plugins: [plugin], cache - }); - }) + }) + ) .then(bundle => { assert.strictEqual(resolveIdCalls, 4); @@ -186,27 +186,85 @@ describe('incremental', () => { }); }); - it('keeps ASTs between runs', () => { - return rollup - .rollup({ - input: 'entry', - plugins: [plugin] - }) - .then(bundle => { - const asts = {}; - bundle.cache.modules.forEach(module => { - asts[module.id] = module.ast; - }); + it('deconflicts variables again if needed', async () => { + modules.entry = `import value from 'foo'; const test = 'main'; export default test + value;`; + modules.foo = `const otherTest = 'foo'; export default otherTest;`; + const firstBundle = await rollup.rollup({ + input: 'entry', + plugins: [plugin] + }); + assert.strictEqual(await executeBundle(firstBundle), 'mainfoo'); - assert.deepEqual( - asts.entry, - acorn.parse(modules.entry, { sourceType: 'module', ecmaVersion: 2020 }) - ); - assert.deepEqual( - asts.foo, - acorn.parse(modules.foo, { sourceType: 'module', ecmaVersion: 2020 }) + // Now we introduce a name conflict + modules.foo = `const test = 'foo'; export default test;`; + const secondBundle = await rollup.rollup({ + input: 'entry', + plugins: [plugin], + cache: firstBundle + }); + assert.strictEqual(await executeBundle(secondBundle), 'mainfoo'); + }); + + it('consistently deconflicts default exports', async () => { + modules.entry = `export default 2; const entry = 1; console.log(entry);`; + const firstBundle = await rollup.rollup({ + input: 'entry', + plugins: [plugin] + }); + const firstCode = await getBundleCode(firstBundle); + assert.strictEqual( + firstCode, + 'var entry_default = 2; const entry = 1; console.log(entry);\n\nexport { entry_default as default };\n', + 'first' + ); + + const secondBundle = await rollup.rollup({ + input: 'entry', + plugins: [plugin], + cache: firstBundle + }); + assert.strictEqual(await getBundleCode(secondBundle), firstCode, 'second'); + }); + + it('uses consistent variable names between formats', async () => { + modules.entry = `{ + const _interopDefault = 1; + const _interopNamespace = 1; + const module = 1; + const require = 1; + const exports = 1; + const document = 1; + const URL = 1; + console.log(_interopDefault, _interopNamespace, module, require, exports, document, URL, import.meta.url); + import('external').then(console.log); +}`; + const FORMATS = ['amd', 'cjs', 'system', 'es', 'iife', 'umd']; + for (const targetFormat of FORMATS) { + const initialCode = await getBundleCode( + await rollup.rollup({ + input: 'entry', + plugins: [plugin] + }), + { format: targetFormat } + ); + for (const otherFormat of FORMATS) { + const firstBundle = await rollup.rollup({ + input: 'entry', + plugins: [plugin] + }); + await getBundleCode(firstBundle, { format: otherFormat }); + const secondBundle = await rollup.rollup({ + input: 'entry', + plugins: [plugin], + cache: firstBundle + }); + assert.strictEqual( + await getBundleCode(secondBundle, { format: targetFormat }), + initialCode, + 'second' ); - }); + } + } }); it('recovers from errors', () => { @@ -226,9 +284,7 @@ describe('incremental', () => { plugins: [plugin], cache }) - .catch(err => { - return cache; - }); + .catch(() => cache); }) .then(cache => { modules.foo = `export default 42;`; @@ -239,9 +295,7 @@ describe('incremental', () => { plugins: [plugin], cache }) - .then(bundle => { - return executeBundle(bundle); - }) + .then(bundle => executeBundle(bundle)) .then(result => { assert.strictEqual(result, 63); }); @@ -267,16 +321,20 @@ describe('incremental', () => { assert.deepEqual(bundle.cache.modules[1].resolvedIds, { foo: { id: 'foo', + attributes: {}, external: false, meta: {}, moduleSideEffects: true, + resolvedBy: 'at position 1', syntheticNamedExports: false }, external: { id: 'external', + attributes: {}, external: true, meta: {}, moduleSideEffects: true, + resolvedBy: 'rollup', syntheticNamedExports: false } }); @@ -293,28 +351,28 @@ describe('incremental', () => { }, load(id) { - assert.deepStrictEqual(this.getModuleInfo(id).meta, { test: { resolved: id } }); return { code: modules[id], meta: { test: { loaded: id } } }; }, transform(code, id) { transformCalls++; - assert.deepStrictEqual(this.getModuleInfo(id).meta, { test: { loaded: id } }); + assert.deepStrictEqual(this.getModuleInfo(id).meta, { test: { loaded: id } }, 'transform'); return { code, meta: { test: { transformed: id } } }; }, moduleParsed({ id, meta }) { - assert.deepStrictEqual(meta, { test: { transformed: id } }); + assert.deepStrictEqual(meta, { test: { transformed: id } }, 'moduleParsed'); moduleParsedCalls++; }, buildEnd() { assert.deepStrictEqual( - [...this.getModuleIds()].map(id => ({ id, meta: this.getModuleInfo(id).meta })), - [ - { id: 'entry', meta: { test: { transformed: 'entry' } } }, - { id: 'foo', meta: { test: { transformed: 'foo' } } } - ] + getObject([...this.getModuleIds()].map(id => [id, this.getModuleInfo(id).meta])), + { + entry: { test: { transformed: 'entry' } }, + foo: { test: { transformed: 'foo' } } + }, + 'buildEnd' ); } }; @@ -336,4 +394,99 @@ describe('incremental', () => { assert.strictEqual(transformCalls, 2); assert.strictEqual(moduleParsedCalls, 4); // should not be cached }); + + it('runs shouldTransformCachedModule when using a cached module', async () => { + modules = { + entry: `import foo from 'foo'; export default foo;`, + foo: `export default import('bar')`, + bar: `export default 42` + }; + let shouldTransformCachedModuleCalls = 0; + + const transformPlugin = { + async shouldTransformCachedModule({ ast, id, meta, resolvedSources, ...other }) { + shouldTransformCachedModuleCalls++; + assert.strictEqual(ast.type, 'Program'); + assert.deepStrictEqual(other, { + code: modules[id], + moduleSideEffects: true, + syntheticNamedExports: false + }); + switch (id) { + case 'foo': { + assert.deepStrictEqual(meta, { transform: { calls: 1, id } }); + assert.deepStrictEqual(resolvedSources, { + __proto__: null, + bar: { + attributes: {}, + external: false, + id: 'bar', + meta: {}, + moduleSideEffects: true, + resolvedBy: 'at position 1', + syntheticNamedExports: false + } + }); + // we return promises to ensure they are awaited + return false; + } + case 'bar': { + assert.deepStrictEqual(meta, { transform: { calls: 2, id } }); + assert.deepStrictEqual(resolvedSources, { __proto__: null }); + return false; + } + case 'entry': { + assert.deepStrictEqual(meta, { transform: { calls: 0, id } }); + assert.deepStrictEqual(resolvedSources, { + __proto__: null, + foo: { + attributes: {}, + external: false, + id: 'foo', + meta: {}, + moduleSideEffects: true, + resolvedBy: 'at position 1', + syntheticNamedExports: false + } + }); + return true; + } + default: { + throw new Error(`Unexpected id ${id}.`); + } + } + }, + transform: (code, id) => ({ meta: { transform: { calls: transformCalls, id } } }) + }; + const cache = await rollup.rollup({ + input: 'entry', + plugins: [transformPlugin, plugin] + }); + assert.strictEqual( + shouldTransformCachedModuleCalls, + 0, + 'initial shouldTransformCachedModule calls' + ); + assert.strictEqual(transformCalls, 3, 'initial transform calls'); + + const { + cache: { modules: cachedModules } + } = await rollup.rollup({ + input: 'entry', + plugins: [transformPlugin, plugin], + cache + }); + assert.strictEqual( + shouldTransformCachedModuleCalls, + 3, + 'final shouldTransformCachedModule calls' + ); + assert.strictEqual(transformCalls, 4, 'final transform calls'); + assert.strictEqual(cachedModules[0].id, 'foo'); + assert.deepStrictEqual(cachedModules[0].meta, { transform: { calls: 1, id: 'foo' } }); + assert.strictEqual(cachedModules[1].id, 'entry'); + assert.deepStrictEqual(cachedModules[1].meta, { transform: { calls: 3, id: 'entry' } }); + assert.strictEqual(cachedModules[2].id, 'bar'); + assert.deepStrictEqual(cachedModules[2].meta, { transform: { calls: 2, id: 'bar' } }); + }); }); diff --git a/test/leak/index.js b/test/leak/index.js index 461fa6a4fb0..628a4e1bbca 100644 --- a/test/leak/index.js +++ b/test/leak/index.js @@ -1,6 +1,10 @@ -const path = require('path'); -const rollup = require('../..'); +const path = require('node:path'); const weak = require('weak-napi'); +/** + * @type {import('../../src/rollup/types')} Rollup + */ +const rollup = require('../..'); +const { wait } = require('../testHelpers'); var shouldCollect = false; var isCollected = false; @@ -9,13 +13,11 @@ function onCollect() { isCollected = true; } -const wait = () => new Promise(resolve => setTimeout(resolve)); - async function waitForGC() { const startTime = process.hrtime(); do { global.gc(); - await wait(); + await wait(0); } while (!isCollected && process.hrtime(startTime)[0] < 3); } @@ -42,7 +44,7 @@ run() console.log('Success: Previous bundle was correctly garbage collected.'); process.exit(0); }) - .catch(err => { - console.error(err.message); + .catch(error => { + console.error(error.message); process.exit(1); }); diff --git a/test/load-config-file/index.js b/test/load-config-file/index.js index 314a7729e89..c73c33f179e 100644 --- a/test/load-config-file/index.js +++ b/test/load-config-file/index.js @@ -1,30 +1,162 @@ -const loadConfigFile = require('../../dist/loadConfigFile.js'); -const assert = require('assert'); -const path = require('path'); +const assert = require('node:assert'); +const path = require('node:path'); +const { loadConfigFile } = require('../../dist/loadConfigFile.js'); +const { compareError, hasEsBuild } = require('../testHelpers'); describe('loadConfigFile', () => { - it('loads a config file', async () => { + const defaultConfigs = [ + { + external: [], + input: 'my-input', + output: [ + { + file: 'my-file', + format: 'es', + plugins: [] + } + ], + plugins: [ + { + name: 'stdin' + } + ] + } + ]; + + it('loads an ESM config file', async () => { + const { options, warnings } = await loadConfigFile( + path.resolve(__dirname, 'samples/esm-via-pkg/rollup.config.js') + ); + assert.strictEqual(warnings.count, 0); + // Remove undefined values and functions before checking + assert.deepStrictEqual(JSON.parse(JSON.stringify(options)), defaultConfigs); + }); + + it('loads an ESM config file with mjs extension', async () => { + const { options, warnings } = await loadConfigFile( + path.resolve(__dirname, 'samples/esm-via-ext/rollup.config.mjs') + ); + assert.strictEqual(warnings.count, 0); + // Remove undefined values and functions before checking + assert.deepStrictEqual(JSON.parse(JSON.stringify(options)), defaultConfigs); + }); + + if (hasEsBuild) { + it('loads an ESM config file exporting a config as a function with defineConfig()', async () => { + const { options, warnings } = await loadConfigFile( + path.resolve(__dirname, 'samples/esm-defineconfig-as-fn/rollup.config.mjs') + ); + assert.strictEqual(warnings.count, 0); + // Remove undefined values and functions before checking + assert.deepStrictEqual(JSON.parse(JSON.stringify(options)), defaultConfigs); + }); + } + + it('loads a CommonJS config file', async () => { + const { options, warnings } = await loadConfigFile( + path.resolve(__dirname, 'samples/cjs-via-pkg/rollup.config.js') + ); + assert.strictEqual(warnings.count, 0); + // Remove undefined values and functions before checking + assert.deepStrictEqual(JSON.parse(JSON.stringify(options)), defaultConfigs); + }); + + it('loads a CommonJS config file with cjs extension', async () => { const { options, warnings } = await loadConfigFile( - path.resolve(__dirname, 'samples/basic/rollup.config.js') + path.resolve(__dirname, 'samples/cjs-via-ext/rollup.config.cjs') ); assert.strictEqual(warnings.count, 0); - assert.deepStrictEqual(JSON.parse(JSON.stringify(options)), [ - { - external: [], - input: 'my-input', - output: [ - { - file: 'my-file', - format: 'es', - plugins: [] - } - ], - plugins: [ - { - name: 'stdin' - } - ] - } - ]); + // Remove undefined values and functions before checking + assert.deepStrictEqual(JSON.parse(JSON.stringify(options)), defaultConfigs); + }); + + it('loads a CommonJS config file exporting a config as a function with defineConfig()', async () => { + const { options, warnings } = await loadConfigFile( + path.resolve(__dirname, 'samples/cjs-defineconfig-as-fn/rollup.config.cjs') + ); + assert.strictEqual(warnings.count, 0); + // Remove undefined values and functions before checking + assert.deepStrictEqual(JSON.parse(JSON.stringify(options)), defaultConfigs); + }); + + it('throws a helpful error when loading an ES module that should actually be CommonJS', async () => { + let caughtError; + try { + await loadConfigFile(path.resolve(__dirname, 'samples/cjs-as-esm/rollup.config.js')); + } catch (error) { + caughtError = error; + } + compareError(caughtError, { + cause: { + message: "Unexpected token 'export'" + }, + code: 'INVALID_CONFIG_MODULE_FORMAT', + message: + 'Node tried to load your configuration file as CommonJS even though it is likely an ES module. To resolve this, change the extension of your configuration to ".mjs", set "type": "module" in your package.json file or pass the "--bundleConfigAsCjs" flag.\n\nOriginal error: Unexpected token \'export\'', + url: 'https://rollupjs.org/command-line-interface/#bundleconfigascjs' + }); + }); + + it('just throws the error if it is not accompanied by the proper warning', async () => { + let caughtError; + try { + const promise = loadConfigFile( + path.resolve(__dirname, 'samples/esm-with-error/rollup.config.js') + ); + process.emit('warning', { message: 'Another warning.' }); + await promise; + } catch (error) { + caughtError = error; + } + compareError(caughtError, { + message: 'Config broken.' + }); + }); + + it('throws a helpful error when loading a CommonJS module that should actually be ES', async () => { + let caughtError; + try { + await loadConfigFile(path.resolve(__dirname, 'samples/esm-as-cjs/rollup.config.js')); + } catch (error) { + caughtError = error; + } + assert.strictEqual( + caughtError.message.slice(0, 256), + 'Node tried to load your configuration as an ES module even though it is likely CommonJS. To resolve this, change the extension of your configuration to ".cjs" or pass the "--bundleConfigAsCjs" flag.\n\nOriginal error: module is not defined in ES module scope' + ); + }); + + it('throws a helpful error when loading a CJS module that should actually be ESM while bundling', async () => { + let caughtError; + try { + await loadConfigFile(path.resolve(__dirname, 'samples/esm-as-cjs/rollup.config.js'), { + configPlugin: '{transform: c => c}' + }); + } catch (error) { + caughtError = error; + } + compareError(caughtError, { + cause: { + message: 'module is not defined in ES module scope' + }, + code: 'INVALID_CONFIG_MODULE_FORMAT', + message: + 'Rollup transpiled your configuration to an ES module even though it appears to contain CommonJS elements. To resolve this, you can pass the "--bundleConfigAsCjs" flag to Rollup or change your configuration to only contain valid ESM code.\n\nOriginal error: module is not defined in ES module scope', + url: 'https://rollupjs.org/command-line-interface/#bundleconfigascjs' + }); + }); + + it('just throws other errors while bundling', async () => { + let caughtError; + try { + await loadConfigFile(path.resolve(__dirname, 'samples/esm-with-error/rollup.config.js'), { + configPlugin: '{transform: c => c}' + }); + } catch (error) { + caughtError = error; + } + compareError(caughtError, { + message: 'Config broken.' + }); }); }); diff --git a/test/load-config-file/samples/basic/rollup.config.js b/test/load-config-file/samples/basic/rollup.config.js deleted file mode 100644 index c9a778d299d..00000000000 --- a/test/load-config-file/samples/basic/rollup.config.js +++ /dev/null @@ -1,7 +0,0 @@ -export default { - input: 'my-input', - output: { - file: 'my-file', - format: 'es' - } -} diff --git a/test/load-config-file/samples/cjs-as-esm/package.json b/test/load-config-file/samples/cjs-as-esm/package.json new file mode 100644 index 00000000000..a0df0c86778 --- /dev/null +++ b/test/load-config-file/samples/cjs-as-esm/package.json @@ -0,0 +1,3 @@ +{ + "type": "commonjs" +} diff --git a/test/load-config-file/samples/cjs-as-esm/rollup.config.js b/test/load-config-file/samples/cjs-as-esm/rollup.config.js new file mode 100644 index 00000000000..0ba62eed7c3 --- /dev/null +++ b/test/load-config-file/samples/cjs-as-esm/rollup.config.js @@ -0,0 +1,7 @@ +export default { + input: 'my-input', + output: { + file: 'my-file', + format: 'es' + } +}; diff --git a/test/load-config-file/samples/cjs-defineconfig-as-fn/rollup.config.cjs b/test/load-config-file/samples/cjs-defineconfig-as-fn/rollup.config.cjs new file mode 100644 index 00000000000..277fad765c0 --- /dev/null +++ b/test/load-config-file/samples/cjs-defineconfig-as-fn/rollup.config.cjs @@ -0,0 +1,10 @@ +// @ts-check +const { defineConfig } = require('../../../../dist/shared/rollup') + +module.exports = defineConfig(args => ({ + input: 'my-input', + output: { + file: 'my-file', + format: 'es' + } +})) diff --git a/test/load-config-file/samples/cjs-via-ext/package.json b/test/load-config-file/samples/cjs-via-ext/package.json new file mode 100644 index 00000000000..bedb411a912 --- /dev/null +++ b/test/load-config-file/samples/cjs-via-ext/package.json @@ -0,0 +1,3 @@ +{ + "type": "module" +} diff --git a/test/load-config-file/samples/cjs-via-ext/rollup.config.cjs b/test/load-config-file/samples/cjs-via-ext/rollup.config.cjs new file mode 100644 index 00000000000..a32b9091003 --- /dev/null +++ b/test/load-config-file/samples/cjs-via-ext/rollup.config.cjs @@ -0,0 +1,7 @@ +module.exports = { + input: 'my-input', + output: { + file: 'my-file', + format: 'es' + } +}; diff --git a/test/load-config-file/samples/cjs-via-pkg/package.json b/test/load-config-file/samples/cjs-via-pkg/package.json new file mode 100644 index 00000000000..a0df0c86778 --- /dev/null +++ b/test/load-config-file/samples/cjs-via-pkg/package.json @@ -0,0 +1,3 @@ +{ + "type": "commonjs" +} diff --git a/test/load-config-file/samples/cjs-via-pkg/rollup.config.js b/test/load-config-file/samples/cjs-via-pkg/rollup.config.js new file mode 100644 index 00000000000..a32b9091003 --- /dev/null +++ b/test/load-config-file/samples/cjs-via-pkg/rollup.config.js @@ -0,0 +1,7 @@ +module.exports = { + input: 'my-input', + output: { + file: 'my-file', + format: 'es' + } +}; diff --git a/test/load-config-file/samples/esm-as-cjs/package.json b/test/load-config-file/samples/esm-as-cjs/package.json new file mode 100644 index 00000000000..bedb411a912 --- /dev/null +++ b/test/load-config-file/samples/esm-as-cjs/package.json @@ -0,0 +1,3 @@ +{ + "type": "module" +} diff --git a/test/load-config-file/samples/esm-as-cjs/rollup.config.js b/test/load-config-file/samples/esm-as-cjs/rollup.config.js new file mode 100644 index 00000000000..a32b9091003 --- /dev/null +++ b/test/load-config-file/samples/esm-as-cjs/rollup.config.js @@ -0,0 +1,7 @@ +module.exports = { + input: 'my-input', + output: { + file: 'my-file', + format: 'es' + } +}; diff --git a/test/load-config-file/samples/esm-defineconfig-as-fn/rollup.config.mjs b/test/load-config-file/samples/esm-defineconfig-as-fn/rollup.config.mjs new file mode 100644 index 00000000000..129c4d9e71b --- /dev/null +++ b/test/load-config-file/samples/esm-defineconfig-as-fn/rollup.config.mjs @@ -0,0 +1,10 @@ +// @ts-check +import { defineConfig } from '../../../../dist/es/rollup.js' + +export default defineConfig(args => ({ + input: 'my-input', + output: { + file: 'my-file', + format: 'es' + } +})) diff --git a/test/load-config-file/samples/esm-via-ext/package.json b/test/load-config-file/samples/esm-via-ext/package.json new file mode 100644 index 00000000000..a0df0c86778 --- /dev/null +++ b/test/load-config-file/samples/esm-via-ext/package.json @@ -0,0 +1,3 @@ +{ + "type": "commonjs" +} diff --git a/test/load-config-file/samples/esm-via-ext/rollup.config.mjs b/test/load-config-file/samples/esm-via-ext/rollup.config.mjs new file mode 100644 index 00000000000..0ba62eed7c3 --- /dev/null +++ b/test/load-config-file/samples/esm-via-ext/rollup.config.mjs @@ -0,0 +1,7 @@ +export default { + input: 'my-input', + output: { + file: 'my-file', + format: 'es' + } +}; diff --git a/test/load-config-file/samples/esm-via-pkg/package.json b/test/load-config-file/samples/esm-via-pkg/package.json new file mode 100644 index 00000000000..bedb411a912 --- /dev/null +++ b/test/load-config-file/samples/esm-via-pkg/package.json @@ -0,0 +1,3 @@ +{ + "type": "module" +} diff --git a/test/load-config-file/samples/esm-via-pkg/rollup.config.js b/test/load-config-file/samples/esm-via-pkg/rollup.config.js new file mode 100644 index 00000000000..0ba62eed7c3 --- /dev/null +++ b/test/load-config-file/samples/esm-via-pkg/rollup.config.js @@ -0,0 +1,7 @@ +export default { + input: 'my-input', + output: { + file: 'my-file', + format: 'es' + } +}; diff --git a/test/load-config-file/samples/esm-with-error/package.json b/test/load-config-file/samples/esm-with-error/package.json new file mode 100644 index 00000000000..bedb411a912 --- /dev/null +++ b/test/load-config-file/samples/esm-with-error/package.json @@ -0,0 +1,3 @@ +{ + "type": "module" +} diff --git a/test/load-config-file/samples/esm-with-error/rollup.config.js b/test/load-config-file/samples/esm-with-error/rollup.config.js new file mode 100644 index 00000000000..36a7414d777 --- /dev/null +++ b/test/load-config-file/samples/esm-with-error/rollup.config.js @@ -0,0 +1 @@ +throw new Error('Config broken.'); diff --git a/test/misc/acorn-plugins.js b/test/misc/acorn-plugins.js deleted file mode 100644 index 9f0510282b6..00000000000 --- a/test/misc/acorn-plugins.js +++ /dev/null @@ -1,45 +0,0 @@ -const assert = require('assert'); -const rollup = require('../../dist/rollup'); -const { executeBundle, loader } = require('../utils.js'); - -describe('acorn plugins', () => { - it('injects plugins passed in acornInjectPlugins', async () => { - let pluginAInjected = false; - let pluginBInjected = false; - - const bundle = await rollup.rollup({ - input: 'x.js', - plugins: [loader({ 'x.js': `export const foo = 42` })], - acornInjectPlugins: [ - function pluginA(Parser) { - assert.equal(typeof Parser.parse, 'function'); - return class extends Parser { - readToken(code) { - pluginAInjected = true; - super.readToken(code); - } - }; - }, - function pluginB(Parser) { - assert.equal(typeof Parser.parse, 'function'); - return class extends Parser { - readToken(code) { - pluginBInjected = true; - super.readToken(code); - } - }; - } - ] - }); - const result = await executeBundle(bundle); - assert.equal(result.foo, 42); - assert( - pluginAInjected, - 'A plugin passed via acornInjectPlugins should inject itself into Acorn.' - ); - assert( - pluginBInjected, - 'A plugin passed via acornInjectPlugins should inject itself into Acorn.' - ); - }); -}); diff --git a/test/misc/bundle-information.js b/test/misc/bundle-information.js index 53fdb648eba..37cfec0807e 100644 --- a/test/misc/bundle-information.js +++ b/test/misc/bundle-information.js @@ -1,10 +1,10 @@ -const assert = require('assert'); +const assert = require('node:assert'); const rollup = require('../../dist/rollup'); -const { loader } = require('../utils.js'); +const { loader } = require('../testHelpers.js'); describe('The bundle object', () => { - it('contains information about the generated chunks', () => { - return rollup + it('contains information about the generated chunks', () => + rollup .rollup({ input: ['input1', 'input2'], plugins: [ @@ -28,14 +28,14 @@ describe('The bundle object', () => { .then(({ output }) => { assert.deepEqual( output.map(chunk => chunk.fileName), - ['input1-ff0de9c1.js', 'input2-28dc81ee.js', 'generated-shared-c4fdd061.js'], + ['input1-BM2OP0FT.js', 'input2-5N8un_JB.js', 'generated-shared-CbVywpjf.js'], 'fileName' ); assert.deepEqual( output.map(chunk => chunk.code), [ - `import { u as used, s as shared } from './generated-shared-c4fdd061.js';\n\nconsole.log("input1", used, shared);const out = true;\n\nexport { out };\n`, - `import './generated-shared-c4fdd061.js';\n\nconsole.log("input2");var input2 = 42;\n\nexport default input2;\n`, + `import { u as used, s as shared } from './generated-shared-CbVywpjf.js';\n\nconsole.log("input1", used, shared);const out = true;\n\nexport { out };\n`, + `import './generated-shared-CbVywpjf.js';\n\nconsole.log("input2");var input2 = 42;\n\nexport { input2 as default };\n`, `console.log("shared");const used = "used"; var shared = "stuff";\n\nexport { shared as s, used as u };\n` ], 'code' @@ -62,14 +62,14 @@ describe('The bundle object', () => { ); assert.deepEqual( output.map(chunk => chunk.imports), - [['generated-shared-c4fdd061.js'], ['generated-shared-c4fdd061.js'], []], + [['generated-shared-CbVywpjf.js'], ['generated-shared-CbVywpjf.js'], []], 'imports' ); assert.deepEqual( output.map(chunk => chunk.importedBindings), [ - { 'generated-shared-c4fdd061.js': ['u', 's'] }, - { 'generated-shared-c4fdd061.js': [] }, + { 'generated-shared-CbVywpjf.js': ['u', 's'] }, + { 'generated-shared-CbVywpjf.js': [] }, {} ], 'importedBindings' @@ -117,11 +117,10 @@ describe('The bundle object', () => { ], 'modules' ); - }); - }); + })); - it('contains information about external imports and reexports', () => { - return rollup + it('contains information about external imports and reexports', () => + rollup .rollup({ input: ['input'], external: ['external1', 'external2', 'external3'], @@ -207,11 +206,10 @@ describe('The bundle object', () => { ], 'modules' ); - }); - }); + })); - it('handles entry facades as entry points but not the facaded chunk', () => { - return rollup + it('handles entry facades as entry points but not the facaded chunk', () => + rollup .rollup({ input: ['input1', 'input2'], plugins: [ @@ -251,11 +249,10 @@ describe('The bundle object', () => { ['input1', 'input2', null], 'facadeModuleId' ); - }); - }); + })); - it('prioritizes the proper facade name over the proper facaded chunk name', () => { - return rollup + it('prioritizes the proper facade name over the proper facaded chunk name', () => + rollup .rollup({ input: ['input1', 'input2'], plugins: [ @@ -286,11 +283,10 @@ describe('The bundle object', () => { ['input1', 'input2', null], 'facadeModuleId' ); - }); - }); + })); - it('marks dynamic entry points but only marks them as normal entry points if they actually are', () => { - return rollup + it('marks dynamic entry points but only marks them as normal entry points if they actually are', () => + rollup .rollup({ input: ['input', 'dynamic1'], plugins: [ @@ -344,11 +340,10 @@ describe('The bundle object', () => { [['dynamic1.js', 'generated-dynamic2.js'], [], []], 'dynamicImports' ); - }); - }); + })); - it('handles tainted dynamic entries', () => { - return rollup + it('handles tainted dynamic entries', () => + rollup .rollup({ input: ['input1', 'input2'], plugins: [ @@ -394,11 +389,10 @@ describe('The bundle object', () => { [['generated-dynamic.js'], [], []], 'dynamicImports' ); - }); - }); + })); - it('removes tree-shaken dynamic imports', () => { - return rollup + it('removes tree-shaken dynamic imports', () => + rollup .rollup({ input: ['input'], plugins: [ @@ -452,14 +446,12 @@ describe('The bundle object', () => { ], 'modules' ); - }); - }); + })); - it('adds correct flags to files when preserving modules', () => { - return rollup + it('adds correct flags to files when preserving modules', () => + rollup .rollup({ input: ['input', 'dynamic1'], - preserveModules: true, plugins: [ loader({ input: `import {other} from "other";console.log(other);Promise.all([import('dynamic1'), import('dynamic2')]).then(([{dynamic1}, {dynamic2}]) => console.log(dynamic1, dynamic2));`, @@ -474,13 +466,19 @@ describe('The bundle object', () => { format: 'es', dir: 'dist', entryFileNames: '[name].js', - chunkFileNames: 'generated-[name].js' + chunkFileNames: 'generated-[name].js', + preserveModules: true }) ) .then(({ output }) => { assert.deepEqual( output.map(chunk => chunk.fileName), - ['_virtual/input', '_virtual/dynamic1', '_virtual/other', '_virtual/dynamic2'], + [ + '_virtual/input.js', + '_virtual/dynamic1.js', + '_virtual/dynamic2.js', + '_virtual/other.js' + ], 'fileName' ); assert.deepEqual( @@ -491,38 +489,38 @@ describe('The bundle object', () => { assert.deepEqual( output.map(chunk => chunk.code), [ - `import { other } from './other'; + `import { other } from './other.js'; -console.log(other);Promise.all([import('./dynamic1'), import('./dynamic2')]).then(([{dynamic1}, {dynamic2}]) => console.log(dynamic1, dynamic2));\n`, +console.log(other);Promise.all([import('./dynamic1.js'), import('./dynamic2.js')]).then(([{dynamic1}, {dynamic2}]) => console.log(dynamic1, dynamic2));\n`, 'const dynamic1 = "dynamic1";\n\nexport { dynamic1 };\n', - 'const other = "other";\n\nexport { other };\n', - 'const dynamic2 = "dynamic2";\n\nexport { dynamic2 };\n' + 'const dynamic2 = "dynamic2";\n\nexport { dynamic2 };\n', + 'const other = "other";\n\nexport { other };\n' ], 'code' ); assert.deepEqual( output.map(chunk => chunk.name), - ['input', 'dynamic1', 'other', 'dynamic2'], + ['_virtual/input', '_virtual/dynamic1', '_virtual/dynamic2', '_virtual/other'], 'name' ); assert.deepEqual( output.map(chunk => chunk.imports), - [['_virtual/other'], [], [], []], + [['_virtual/other.js'], [], [], []], 'imports' ); assert.deepEqual( output.map(chunk => chunk.importedBindings), - [{ '_virtual/other': ['other'] }, {}, {}, {}], + [{ '_virtual/other.js': ['other'] }, {}, {}, {}], 'importedBindings' ); assert.deepEqual( output.map(chunk => chunk.exports), - [[], ['dynamic1'], ['other'], ['dynamic2']], + [[], ['dynamic1'], ['dynamic2'], ['other']], 'exports' ); assert.deepEqual( output.map(chunk => chunk.dynamicImports), - [['_virtual/dynamic1', '_virtual/dynamic2'], [], [], []], + [['_virtual/dynamic1.js', '_virtual/dynamic2.js'], [], [], []], 'dynamicImports' ); assert.deepEqual( @@ -530,11 +528,11 @@ console.log(other);Promise.all([import('./dynamic1'), import('./dynamic2')]).the [ { input: { - code: 'console.log(other);Promise.all([import(\'./dynamic1\'), import(\'./dynamic2\')]).then(([{dynamic1}, {dynamic2}]) => console.log(dynamic1, dynamic2));', + code: "console.log(other);Promise.all([import('./dynamic1.js'), import('./dynamic2.js')]).then(([{dynamic1}, {dynamic2}]) => console.log(dynamic1, dynamic2));", originalLength: 169, removedExports: [], renderedExports: [], - renderedLength: 141 + renderedLength: 151 } }, { @@ -546,15 +544,6 @@ console.log(other);Promise.all([import('./dynamic1'), import('./dynamic2')]).the renderedLength: 28 } }, - { - other: { - code: 'const other = "other";', - originalLength: 28, - removedExports: [], - renderedExports: ['other'], - renderedLength: 22 - } - }, { dynamic2: { code: 'const dynamic2 = "dynamic2";', @@ -563,25 +552,33 @@ console.log(other);Promise.all([import('./dynamic1'), import('./dynamic2')]).the renderedExports: ['dynamic2'], renderedLength: 28 } + }, + { + other: { + code: 'const other = "other";', + originalLength: 28, + removedExports: [], + renderedExports: ['other'], + renderedLength: 22 + } } ], 'modules' ); assert.deepEqual( output.map(chunk => chunk.isDynamicEntry), - [false, true, false, true], + [false, true, true, false], 'isDynamicEntry' ); assert.deepEqual( output.map(chunk => chunk.facadeModuleId), - ['input', 'dynamic1', 'other', 'dynamic2'], + ['input', 'dynamic1', 'dynamic2', 'other'], 'facadeModuleId' ); - }); - }); + })); - it('contains correct information about rendered/removedExports when directly exporting items', () => { - return rollup + it('contains correct information about rendered/removedExports when directly exporting items', () => + rollup .rollup({ input: ['input'], plugins: [ @@ -631,11 +628,10 @@ console.log(other);Promise.all([import('./dynamic1'), import('./dynamic2')]).the }, 'modules' ); - }); - }); + })); - it('contains correct information about rendered/removedExports when using export declaration', () => { - return rollup + it('contains correct information about rendered/removedExports when using export declaration', () => + rollup .rollup({ input: ['input'], plugins: [ @@ -685,6 +681,5 @@ console.log(other);Promise.all([import('./dynamic1'), import('./dynamic2')]).the }, 'modules' ); - }); - }); + })); }); diff --git a/test/misc/deprecations.js b/test/misc/deprecations.js deleted file mode 100644 index adaf27c0119..00000000000 --- a/test/misc/deprecations.js +++ /dev/null @@ -1,14 +0,0 @@ -const assert = require('assert'); -const rollup = require('../../dist/rollup'); -const { loader } = require('../utils.js'); - -describe('deprecations', () => { - it('supports es format alias', () => { - return rollup - .rollup({ input: 'x', plugins: [loader({ x: 'export const x = function () {}' })] }) - .then(bundle => bundle.generate({ format: 'es' })) - .then(({ output: [{ code }] }) => { - assert.equal(code, 'const x = function () {};\n\nexport { x };\n'); - }); - }); -}); diff --git a/test/misc/fs-override.js b/test/misc/fs-override.js new file mode 100644 index 00000000000..f83f9156549 --- /dev/null +++ b/test/misc/fs-override.js @@ -0,0 +1,56 @@ +const assert = require('node:assert'); +const { Volume } = require('memfs'); +const rollup = require('../../dist/rollup'); + +describe('fs-override', () => { + it('uses fs from options', async () => { + const vol = Volume.fromJSON( + { + '/input.js': "console.log('Hello, Rollup!');" + }, + __dirname + ); + const bundle = await rollup.rollup({ + input: '/input.js', + fs: vol.promises + }); + + await bundle.write({ + file: '/output.js', + format: 'esm' + }); + + const generatedCode = vol.readFileSync('/output.js', 'utf8'); + assert.strictEqual(generatedCode.trim(), "console.log('Hello, Rollup!');"); + }); + + it('passes fs from options to plugin context', async () => { + const vol = Volume.fromJSON( + { + '/input.js': "console.log('Hello, Rollup!');" + }, + __dirname + ); + const bundle = await rollup.rollup({ + input: '/input.js', + fs: vol.promises, + plugins: [ + { + name: 'test-plugin', + async transform(code, _id) { + assert.equal(await this.fs.readFile('/input.js'), "console.log('Hello, Rollup!');"); + return { + code, + map: null + }; + } + } + ] + }); + + await bundle.write({ + file: '/output.js', + format: 'esm' + }); + }); +}); diff --git a/test/misc/get-log-filter.js b/test/misc/get-log-filter.js new file mode 100644 index 00000000000..1e342bcdec1 --- /dev/null +++ b/test/misc/get-log-filter.js @@ -0,0 +1,85 @@ +const assert = require('node:assert'); +const { getLogFilter } = require('../../dist/getLogFilter'); + +describe('getLogFilter', () => { + it('does not filter when there are no filters', () => { + const filter = getLogFilter([]); + assert.strictEqual(filter({ code: 'FIRST' }), true); + }); + + it('filters for string matches', () => { + const filter = getLogFilter(['code:FIRST']); + assert.strictEqual(filter({ code: 'FIRST' }), true); + assert.strictEqual(filter({ code: 'SECOND' }), false); + assert.strictEqual(filter({ message: 'no code' }), false); + }); + + it('combines multiple filters with "or"', () => { + const filter = getLogFilter(['code:FIRST', 'message:second']); + assert.strictEqual(filter({ code: 'FIRST', message: 'first' }), true); + assert.strictEqual(filter({ code: 'SECOND', message: 'first' }), false); + assert.strictEqual(filter({ code: 'FIRST', message: 'second' }), true); + assert.strictEqual(filter({ code: 'SECOND', message: 'second' }), true); + }); + + it('supports placeholders', () => { + const filter = getLogFilter(['code:*A', 'code:B*', 'code:*C*', 'code:D*E*F']); + assert.strictEqual(filter({ code: 'xxA' }), true, 'xxA'); + assert.strictEqual(filter({ code: 'xxB' }), false, 'xxB'); + assert.strictEqual(filter({ code: 'Axx' }), false, 'Axx'); + assert.strictEqual(filter({ code: 'Bxx' }), true, 'Bxx'); + assert.strictEqual(filter({ code: 'C' }), true, 'C'); + assert.strictEqual(filter({ code: 'xxCxx' }), true, 'xxCxx'); + assert.strictEqual(filter({ code: 'DxxExxF' }), true, 'DxxExxF'); + }); + + it('supports inverted filters', () => { + const filter = getLogFilter(['!code:FIRST']); + assert.strictEqual(filter({ code: 'FIRST' }), false); + assert.strictEqual(filter({ code: 'SECOND' }), true); + }); + + it('supports AND conditions', () => { + const filter = getLogFilter(['code:FIRST&plugin:my-plugin']); + assert.strictEqual(filter({ code: 'FIRST', plugin: 'my-plugin' }), true); + assert.strictEqual(filter({ code: 'FIRST', plugin: 'other-plugin' }), false); + assert.strictEqual(filter({ code: 'SECOND', plugin: 'my-plugin' }), false); + }); + + it('handles numbers and objects', () => { + const filter = getLogFilter(['foo:1', 'bar:*2*', 'baz:{"a":1}', 'baz:{"b":1,*}']); + assert.strictEqual(filter({ foo: 1 }), true, 'foo:1'); + assert.strictEqual(filter({ foo: 10 }), false, 'foo:10'); + assert.strictEqual(filter({ bar: 123 }), true, 'bar:123'); + assert.strictEqual(filter({ bar: 13 }), false, 'bar:13'); + assert.strictEqual(filter({ baz: { a: 1 } }), true, 'baz:{"a":1}'); + assert.strictEqual(filter({ baz: { a: 1, b: 2 } }), false, 'baz:{"a":1,"b":2}'); + assert.strictEqual(filter({ baz: { b: 1, c: 2 } }), true, 'baz:{"b":1,"c":2}'); + }); + + it('handles edge case filters', () => { + const filter = getLogFilter([ + ':A', // property is "empty string" + 'a:', // value is "empty string" + '', // property and value are "empty string" + 'code:A&', // property and value are "empty string", + 'foo:bar:baz' // second colon is treated literally + ]); + assert.strictEqual(filter({ '': 'A' }), true, ':A'); + assert.strictEqual(filter({ foo: 'A' }), false, 'foo:A'); + assert.strictEqual(filter({ a: '' }), true, 'a:'); + assert.strictEqual(filter({ a: 'foo' }), false, 'a:foo'); + assert.strictEqual(filter({ '': '' }), true, ''); + assert.strictEqual(filter({ code: 'A' }), false, 'code:A'); + assert.strictEqual(filter({ code: 'A', '': '' }), true, 'code:A&'); + assert.strictEqual(filter({ foo: 'bar:baz' }), true, 'foo:bar:baz'); + }); + + it('handles nested properties', () => { + const filter = getLogFilter(['foo.bar:baz']); + assert.strictEqual(filter({ foo: null }), false, 'foo:bar'); + assert.strictEqual(filter({ foo: { bar: 'baz' } }), true, 'foo.bar:baz'); + assert.strictEqual(filter({ foo: { bar: 'qux' } }), false, 'foo.bar:qux'); + assert.strictEqual(filter({ foo: { bar: { baz: 'qux' } } }), false, 'foo.bar.baz:qux'); + }); +}); diff --git a/test/misc/iife.js b/test/misc/iife.js index 6184dd6adb5..b2a8afc22f1 100644 --- a/test/misc/iife.js +++ b/test/misc/iife.js @@ -1,13 +1,13 @@ -const rollup = require('../../dist/rollup'); -const assert = require('assert'); -const { loader } = require('../utils.js'); -const { compareError } = require('../utils.js'); +const assert = require('node:assert'); +const { rollup } = require('../../dist/rollup'); +const { loader } = require('../testHelpers.js'); +const { compareError } = require('../testHelpers.js'); function runTestCode(code, globals) { - const globalsWithAssert = Object.assign({}, globals, { assert }); + const globalsWithAssert = { ...globals, assert }; const globalKeys = Object.keys(globalsWithAssert); - const fn = new Function(globalKeys, code); - fn.apply( + const function_ = new Function(globalKeys, code); + function_.apply( globals, globalKeys.map(key => globalsWithAssert[key]) ); @@ -17,7 +17,7 @@ function runIifeTest(code, outputOptions) { const bundleName = outputOptions.name.split('.')[0]; const globals = { external: 'external', __exports: {} }; runTestCode( - bundleName && bundleName.indexOf('@') === -1 + bundleName && !bundleName.includes('@') ? `${code}if (typeof ${bundleName} !== 'undefined') __exports.${bundleName} = ${bundleName};` : code, globals @@ -29,44 +29,41 @@ function getIifeExports(global, outputOptions) { if (outputOptions.name) { return outputOptions.name .split('.') - .reduce((currentVar, nextKey) => currentVar[nextKey] || {}, global); + .reduce((currentVariable, nextKey) => currentVariable[nextKey] || {}, global); } return {}; } function getIifeCode(inputCode, outputOptions) { - return rollup - .rollup({ - input: 'input', - external: ['external'], - plugins: [loader({ input: inputCode })] - }) + return rollup({ + input: 'input', + external: ['external'], + plugins: [loader({ input: inputCode })] + }) .then(bundle => - bundle.generate( - Object.assign({ format: 'iife', globals: { external: 'external' } }, outputOptions) - ) + bundle.generate({ format: 'iife', globals: { external: 'external' }, ...outputOptions }) ) .then(({ output }) => output[0].code); } function runTestsWithCode(code, outputOptions, expectedExports) { it('works with extend=false', () => { - const options = Object.assign({ extend: false }, outputOptions); + const options = { extend: false, ...outputOptions }; return getIifeCode(code, options).then(code => assert.deepEqual(runIifeTest(code, options), expectedExports, 'expected exports are returned') ); }); it('works with extend=true', () => { - const options = Object.assign({ extend: true }, outputOptions); + const options = { extend: true, ...outputOptions }; return getIifeCode(code, options).then(code => assert.deepEqual(runIifeTest(code, options), expectedExports, 'expected exports are returned') ); }); } -['bundle', '@my.@nested/value.bundle'].forEach(name => - [false, true].forEach(compact => +for (const name of ['bundle', '@my.@nested/value.bundle']) + for (const compact of [false, true]) describe(`The IIFE wrapper with name="${name}", compact=${compact}`, () => { const outputOptions = { compact, name }; @@ -95,9 +92,7 @@ function runTestsWithCode(code, outputOptions, expectedExports) { runTestsWithCode('import value from "external"; export default {value};', outputOptions, { value: 'external' })); - }) - ) -); + }); describe('The IIFE wrapper with an illegal name', () => { it('fails if the name starts with a digit', () => @@ -109,7 +104,8 @@ describe('The IIFE wrapper with an illegal name', () => { compareError(error, { code: 'ILLEGAL_IDENTIFIER_AS_NAME', message: - 'Given name "1name" is not a legal JS identifier. If you need this, you can try "output.extend: true".' + 'Given name "1name" is not a legal JS identifier. If you need this, you can try "output.extend: true".', + url: 'https://rollupjs.org/configuration-options/#output-extend' }) )); @@ -122,7 +118,8 @@ describe('The IIFE wrapper with an illegal name', () => { compareError(error, { code: 'ILLEGAL_IDENTIFIER_AS_NAME', message: - 'Given name "my=name" is not a legal JS identifier. If you need this, you can try "output.extend: true".' + 'Given name "my=name" is not a legal JS identifier. If you need this, you can try "output.extend: true".', + url: 'https://rollupjs.org/configuration-options/#output-extend' }) )); @@ -137,9 +134,24 @@ describe('The IIFE wrapper with an illegal name', () => { '\n' + '\texports.x = x;\n' + '\n' + - "\tObject.defineProperty(exports, '__esModule', { value: true });\n" + - '\n' + - "}(this['my=name'] = this['my=name'] || {}));\n" + '})(this["my=name"] = this["my=name"] || {});\n' ) )); }); + +describe('The IIFE wrapper with output name as reserved keyword', () => { + it('Set output name as toString.value', () => { + getIifeCode('export const x = 42;', { name: 'toString.value' }).then(code => { + assert.deepEqual( + code, + 'this.toString = this.toString || {};\n' + + 'this.toString.value = (function (exports) {\n' + + "'use strict';\n\n" + + 'const x = 42;\n\n' + + 'exports.x = x;\n\n' + + 'return exports;\n\n' + + '})({});' + ); + }); + }); +}); diff --git a/test/misc/in-memory-sourcemaps.js b/test/misc/in-memory-sourcemaps.js index fa5077da71f..06ea7da4eb0 100644 --- a/test/misc/in-memory-sourcemaps.js +++ b/test/misc/in-memory-sourcemaps.js @@ -1,9 +1,8 @@ -const assert = require('assert'); -const path = require('path'); -const rollup = require('../../dist/rollup'); -const { loader } = require('../utils.js'); +const assert = require('node:assert'); +const path = require('node:path'); const { SourceMapConsumer } = require('source-map'); -const { getLocator } = require('locate-character'); +const rollup = require('../../dist/rollup'); +const { loader } = require('../testHelpers.js'); describe('in-memory sourcemaps', () => { it('generates an in-memory sourcemap', async () => { @@ -19,7 +18,9 @@ describe('in-memory sourcemaps', () => { sourcemapFile: path.resolve('bundle.js') }); const smc = await new SourceMapConsumer(generated.map); - const locator = getLocator(generated.code, { offsetLine: 1 }); + const locator = (await import('locate-character')).getLocator(generated.code, { + offsetLine: 1 + }); const loc = smc.originalPositionFor(locator('42')); // 42 assert.equal(loc.source, 'main'); assert.equal(loc.line, 1); diff --git a/test/misc/index.js b/test/misc/index.js index 1cdb683e1e2..8bc305f6193 100644 --- a/test/misc/index.js +++ b/test/misc/index.js @@ -1,6 +1,7 @@ -require('./acorn-plugins'); require('./bundle-information'); -require('./deprecations'); +require('./fs-override'); +require('./get-log-filter'); +require('./parse-ast'); require('./iife'); require('./in-memory-sourcemaps'); require('./misc'); diff --git a/test/misc/misc.js b/test/misc/misc.js index 347cd46f3f5..9025beb3169 100644 --- a/test/misc/misc.js +++ b/test/misc/misc.js @@ -1,6 +1,6 @@ -const assert = require('assert'); +const assert = require('node:assert'); const rollup = require('../../dist/rollup'); -const { assertIncludes, loader } = require('../utils.js'); +const { loader } = require('../testHelpers.js'); describe('misc', () => { it('avoids modification of options or their properties', () => { @@ -16,8 +16,6 @@ describe('misc', () => { load: freeze(() => `export default 0;`) } ]), - acornInjectPlugins: freeze([]), - acorn: freeze({}), treeshake: freeze({}) }) ); @@ -49,7 +47,7 @@ describe('misc', () => { assert.equal(relevantWarnings.length, 1); assert.equal( relevantWarnings[0].message, - `Creating a browser bundle that depends on Node.js built-in module ('util'). You might need to include https://github.com/ionic-team/rollup-plugin-node-polyfills` + `Creating a browser bundle that depends on Node.js built-in modules ("util"). You might need to include https://github.com/FredKSchott/rollup-plugin-polyfill-node` ); }); }); @@ -80,10 +78,11 @@ describe('misc', () => { assert.deepEqual(warnings, [ { code: 'MISSING_GLOBAL_NAME', - guess: '_', + id: 'lodash', message: - "No name was provided for external module 'lodash' in output.globals – guessing '_'", - source: 'lodash' + 'No name was provided for external module "lodash" in "output.globals" – guessing "_".', + names: ['_'], + url: 'https://rollupjs.org/configuration-options/#output-globals' } ]); }); @@ -110,19 +109,77 @@ describe('misc', () => { assert.equal(warnings.length, 0); assert.deepEqual( output.map(({ fileName }) => fileName), - ['main1.js', 'main2.js', 'dep-f8bec8a7.js', 'dyndep-b0a9ee12.js'] + ['main1.js', 'main2.js', 'dep-BED4JKkQ.js', 'dyndep-DOckMt73.js'] ); }); }); + it('applies consistent hashes regardless of chunk transform order', async () => { + const FILES = { + main: ` + import('folder1/dupe').then(({dupe}) => console.log(dupe)); + import('folder2/dupe').then(({dupe}) => console.log(dupe)); + `, + 'folder1/dupe': `export const dupe = 'dupe content';`, + 'folder2/dupe': `export const dupe = 'dupe content';` + }; + + async function buildBundle(delayedChunk) { + const bundle = await rollup.rollup({ + input: 'main', + plugins: [ + loader(FILES), + { + name: 'delay-chunk', + async renderChunk(_, chunk) { + if (chunk.facadeModuleId === delayedChunk) { + await new Promise(resolve => setTimeout(resolve, 100)); + } + return null; + } + } + ] + }); + return bundle.generate({ + format: 'es', + chunkFileNames: '[name]-[hash].js' + }); + } + + const { output: output1 } = await buildBundle('folder1/dupe'); + const { output: output2 } = await buildBundle('folder2/dupe'); + + assert.strictEqual( + output1.length, + output2.length, + 'Both outputs should have the same number of chunks' + ); + + const sortedOutput1 = output1.sort((a, b) => a.fileName.localeCompare(b.fileName)); + const sortedOutput2 = output2.sort((a, b) => a.fileName.localeCompare(b.fileName)); + + for (let index = 0; index < sortedOutput1.length; index++) { + assert.strictEqual( + sortedOutput1[index].fileName, + sortedOutput2[index].fileName, + `Chunk ${index} should have the same filename in both outputs` + ); + assert.strictEqual( + sortedOutput1[index].code, + sortedOutput2[index].code, + `Chunk ${index} should have the same code in both outputs` + ); + } + }); + it('ignores falsy plugins', () => rollup.rollup({ input: 'x', plugins: [loader({ x: `console.log( 42 );` }), null, false, undefined] })); - it('handles different import paths for different outputs', () => { - return rollup + it('handles different import paths for different outputs', () => + rollup .rollup({ input: 'x', external: ['the-answer'], @@ -150,8 +207,7 @@ describe('misc', () => { assert.equal(generated.output[0].code, "import 'the-answer';\n", 'no render path 2') ) ]) - ); - }); + )); it('allows passing the same object to `rollup` and `generate`', () => { const options = { @@ -175,7 +231,10 @@ describe('misc', () => { .rollup(options) .then(bundle => bundle.generate(options)) .then(output => - assert.strictEqual(output.output[0].code, 'var input = 42;\n\nexport default input;\n') + assert.strictEqual( + output.output[0].code, + 'var input = 42;\n\nexport { input as default };\n' + ) ); }); @@ -218,28 +277,59 @@ console.log(x); input: { 'base/main': 'main.js', 'base/main/feature': 'feature.js', - 'base/main/feature/sub': 'subfeature.js' + 'base/main/feature/sub': 'subfeature.js', + 'base/main/feature/sub/sub': 'subsubfeature.js' }, plugins: [ loader({ 'main.js': 'export function fn () { return "main"; } console.log(fn());', 'feature.js': 'import { fn } from "main.js"; console.log(fn() + " feature");', - 'subfeature.js': 'import { fn } from "main.js"; console.log(fn() + " subfeature");' + 'subfeature.js': 'import { fn } from "main.js"; console.log(fn() + " subfeature");', + 'subsubfeature.js': 'import { fn } from "main.js"; console.log(fn() + " subsubfeature");' }) ] }); const { - output: [main, feature, subfeature] + output: [feature, subfeature, subsubfeature, main] } = await bundle.generate({ entryFileNames: `[name]`, chunkFileNames: `[name]`, format: 'es' }); assert.strictEqual(main.fileName, 'base/main'); - assert.ok(main.code.startsWith('function fn')); assert.strictEqual(feature.fileName, 'base/main/feature'); assert.ok(feature.code.startsWith("import { fn } from '../main'")); assert.strictEqual(subfeature.fileName, 'base/main/feature/sub'); assert.ok(subfeature.code.startsWith("import { fn } from '../../main'")); + assert.strictEqual(subsubfeature.fileName, 'base/main/feature/sub/sub'); + assert.ok(subsubfeature.code.startsWith("import { fn } from '../../../main'")); + }); + + it('supports rendering es after rendering iife with inlined dynamic imports', async () => { + const bundle = await rollup.rollup({ + input: 'main.js', + plugins: [ + loader({ + 'main.js': "import('other.js');", + 'other.js': "export const foo = 'bar';" + }) + ] + }); + await bundle.generate({ format: 'iife', inlineDynamicImports: true }); + await bundle.generate({ format: 'es', exports: 'auto' }); + }); + + it('should support `Symbol.asyncDispose` of the rollup bundle and set closed state to true', async () => { + const bundle = await rollup.rollup({ + input: 'main.js', + plugins: [ + loader({ + 'main.js': "console.log('hello')" + }) + ] + }); + + await bundle[Symbol.asyncDispose](); + assert.strictEqual(bundle.closed, true); }); }); diff --git a/test/misc/optionList.js b/test/misc/optionList.js index 72c376d9724..d5871e1e4ae 100644 --- a/test/misc/optionList.js +++ b/test/misc/optionList.js @@ -1,6 +1,6 @@ exports.input = - 'acorn, acornInjectPlugins, cache, context, experimentalCacheExpiry, external, inlineDynamicImports, input, makeAbsoluteExternalsRelative, manualChunks, moduleContext, onwarn, perf, plugins, preserveEntrySignatures, preserveModules, preserveSymlinks, shimMissingExports, strictDeprecations, treeshake, watch'; + 'cache, context, experimentalCacheExpiry, experimentalLogSideEffects, external, fs, input, jsx, logLevel, makeAbsoluteExternalsRelative, maxParallelFileOps, moduleContext, onLog, onwarn, perf, plugins, preserveEntrySignatures, preserveSymlinks, shimMissingExports, strictDeprecations, treeshake, watch'; exports.flags = - 'acorn, acornInjectPlugins, amd, assetFileNames, banner, c, cache, chunkFileNames, compact, config, context, d, dir, dynamicImportFunction, e, entryFileNames, environment, esModule, experimentalCacheExpiry, exports, extend, external, externalLiveBindings, f, failAfterWarnings, file, footer, format, freeze, g, globals, h, hoistTransitiveImports, i, indent, inlineDynamicImports, input, interop, intro, m, makeAbsoluteExternalsRelative, manualChunks, minifyInternalExports, moduleContext, n, name, namespaceToStringTag, noConflict, o, onwarn, outro, p, paths, perf, plugin, plugins, preferConst, preserveEntrySignatures, preserveModules, preserveModulesRoot, preserveSymlinks, shimMissingExports, silent, sourcemap, sourcemapExcludeSources, sourcemapFile, stdin, strict, strictDeprecations, systemNullSetters, treeshake, v, validate, w, waitForBundleInput, watch'; + 'amd, assetFileNames, banner, bundleConfigAsCjs, c, cache, chunkFileNames, compact, config, configImportAttributesKey, configPlugin, context, d, dir, dynamicImportInCjs, e, entryFileNames, environment, esModule, experimentalCacheExpiry, experimentalLogSideEffects, experimentalMinChunkSize, exports, extend, external, externalImportAssertions, externalImportAttributes, externalLiveBindings, f, failAfterWarnings, file, filterLogs, footer, forceExit, format, freeze, g, generatedCode, globals, h, hashCharacters, hoistTransitiveImports, i, importAttributesKey, indent, inlineDynamicImports, input, interop, intro, jsx, logLevel, m, makeAbsoluteExternalsRelative, manualChunks, maxParallelFileOps, minifyInternalExports, moduleContext, n, name, noConflict, o, onLog, onlyExplicitManualChunks, onwarn, outro, p, paths, perf, plugin, plugins, preserveEntrySignatures, preserveModules, preserveModulesRoot, preserveSymlinks, reexportProtoFromExternal, sanitizeFileName, shimMissingExports, silent, sourcemap, sourcemapBaseUrl, sourcemapDebugIds, sourcemapExcludeSources, sourcemapFile, sourcemapFileNames, stdin, strict, strictDeprecations, systemNullSetters, treeshake, v, validate, virtualDirname, w, waitForBundleInput, watch'; exports.output = - 'amd, assetFileNames, banner, chunkFileNames, compact, dir, dynamicImportFunction, entryFileNames, esModule, exports, extend, externalLiveBindings, file, footer, format, freeze, globals, hoistTransitiveImports, indent, inlineDynamicImports, interop, intro, manualChunks, minifyInternalExports, name, namespaceToStringTag, noConflict, outro, paths, plugins, preferConst, preserveModules, preserveModulesRoot, sourcemap, sourcemapExcludeSources, sourcemapFile, sourcemapPathTransform, strict, systemNullSetters, validate'; + 'amd, assetFileNames, banner, chunkFileNames, compact, dir, dynamicImportInCjs, entryFileNames, esModule, experimentalMinChunkSize, exports, extend, externalImportAssertions, externalImportAttributes, externalLiveBindings, file, footer, format, freeze, generatedCode, globals, hashCharacters, hoistTransitiveImports, importAttributesKey, indent, inlineDynamicImports, interop, intro, manualChunks, minifyInternalExports, name, noConflict, onlyExplicitManualChunks, outro, paths, plugins, preserveModules, preserveModulesRoot, reexportProtoFromExternal, sanitizeFileName, sourcemap, sourcemapBaseUrl, sourcemapDebugIds, sourcemapExcludeSources, sourcemapFile, sourcemapFileNames, sourcemapIgnoreList, sourcemapPathTransform, strict, systemNullSetters, validate, virtualDirname'; diff --git a/test/misc/parse-ast.js b/test/misc/parse-ast.js new file mode 100644 index 00000000000..4042c71b534 --- /dev/null +++ b/test/misc/parse-ast.js @@ -0,0 +1,147 @@ +const assert = require('node:assert'); +const { parseAst, parseAstAsync } = require('../../dist/parseAst'); +const { hasEsBuild } = require('../testHelpers'); + +describe('parseAst', () => { + it('parses an AST', async () => { + assert.deepStrictEqual(parseAst('console.log("ok")'), { + type: 'Program', + start: 0, + end: 17, + body: [ + { + type: 'ExpressionStatement', + start: 0, + end: 17, + expression: { + type: 'CallExpression', + start: 0, + end: 17, + arguments: [{ type: 'Literal', start: 12, end: 16, raw: '"ok"', value: 'ok' }], + callee: { + type: 'MemberExpression', + start: 0, + end: 11, + computed: false, + object: { type: 'Identifier', start: 0, end: 7, name: 'console' }, + optional: false, + property: { type: 'Identifier', start: 8, end: 11, name: 'log' } + }, + optional: false + } + } + ], + sourceType: 'module' + }); + }); + + if (hasEsBuild) { + it('works as an ES module', async () => { + const { parseAst: parseEsm } = await import('../../dist/es/parseAst.js'); + assert.deepStrictEqual(parseEsm('console.log("ok")'), { + type: 'Program', + start: 0, + end: 17, + body: [ + { + type: 'ExpressionStatement', + start: 0, + end: 17, + expression: { + type: 'CallExpression', + start: 0, + end: 17, + arguments: [{ type: 'Literal', start: 12, end: 16, raw: '"ok"', value: 'ok' }], + callee: { + type: 'MemberExpression', + start: 0, + end: 11, + computed: false, + object: { type: 'Identifier', start: 0, end: 7, name: 'console' }, + optional: false, + property: { type: 'Identifier', start: 8, end: 11, name: 'log' } + }, + optional: false + } + } + ], + sourceType: 'module' + }); + }); + } + + it('throws on parse errors', async () => { + assert.throws(() => parseAst('<=>'), { + name: 'RollupError', + message: 'Expression expected', + code: 'PARSE_ERROR', + pos: 0 + }); + }); + + it('throws on return outside function by default', async () => { + assert.throws(() => parseAst('return 42;'), { + name: 'RollupError', + message: 'Return statement is not allowed here', + code: 'PARSE_ERROR', + pos: 0 + }); + }); + + it('can handle return outside function if enabled', async () => { + assert.deepStrictEqual(parseAst('return 42;', { allowReturnOutsideFunction: true }), { + type: 'Program', + start: 0, + end: 10, + body: [ + { + type: 'ReturnStatement', + start: 0, + end: 10, + argument: { type: 'Literal', start: 7, end: 9, raw: '42', value: 42 } + } + ], + sourceType: 'module' + }); + }); + + it('uses different references for key and value of a shorthand property', async () => { + const { key, value } = parseAst('({ foo });').body[0].expression.properties[0]; + assert.deepStrictEqual(key, value); + assert.ok(key !== value); + }); +}); + +describe('parseAstAsync', () => { + it('parses an AST', async () => { + assert.deepStrictEqual(await parseAstAsync('console.log("ok")'), { + type: 'Program', + start: 0, + end: 17, + body: [ + { + type: 'ExpressionStatement', + start: 0, + end: 17, + expression: { + type: 'CallExpression', + start: 0, + end: 17, + arguments: [{ type: 'Literal', start: 12, end: 16, raw: '"ok"', value: 'ok' }], + callee: { + type: 'MemberExpression', + start: 0, + end: 11, + computed: false, + object: { type: 'Identifier', start: 0, end: 7, name: 'console' }, + optional: false, + property: { type: 'Identifier', start: 8, end: 11, name: 'log' } + }, + optional: false + } + } + ], + sourceType: 'module' + }); + }); +}); diff --git a/test/misc/sanity-checks.js b/test/misc/sanity-checks.js index ed11742ed42..ef2e5eb905c 100644 --- a/test/misc/sanity-checks.js +++ b/test/misc/sanity-checks.js @@ -1,6 +1,6 @@ -const assert = require('assert'); +const assert = require('node:assert'); const rollup = require('../../dist/rollup'); -const { loader, compareError } = require('../utils.js'); +const { loader, compareError } = require('../testHelpers.js'); describe('sanity checks', () => { it('exists', () => { @@ -22,20 +22,21 @@ describe('sanity checks', () => { }); it('node API passes warning and default handler to custom onwarn function', async () => { - let args; - await rollup.rollup({ + let parameters; + const bundle = await rollup.rollup({ input: 'x', plugins: [loader({ x: `eval(42);` })], onwarn(warning, onwarn) { - args = [warning, onwarn]; + parameters = [warning, onwarn]; } }); - assert.equal(args[0].code, 'EVAL'); + await bundle.generate({ format: 'es' }); + assert.equal(parameters[0].code, 'EVAL'); assert.equal( - args[0].message, - 'Use of eval is strongly discouraged, as it poses security risks and may cause issues with minification' + parameters[0].message, + 'x (1:0): Use of eval in "x" is strongly discouraged as it poses security risks and may cause issues with minification.' ); - assert.equal(typeof args[1], 'function'); + assert.equal(typeof parameters[1], 'function'); }); it('fails without options.input', async () => { @@ -109,7 +110,7 @@ describe('sanity checks', () => { } assert.strictEqual( error && error.message, - 'You must specify "output.format", which can be one of "amd", "cjs", "system", "es", "iife" or "umd".' + 'Invalid value "vanilla" for option "output.format" - Valid values are "amd", "cjs", "system", "es", "iife" or "umd".' ); }); @@ -165,7 +166,7 @@ describe('sanity checks', () => { } assert.strictEqual( error && error.message, - 'When building multiple chunks, the "output.dir" option must be used, not "output.file". To inline dynamic imports, set the "inlineDynamicImports" option.' + 'Invalid value for option "output.file" - when building multiple chunks, the "output.dir" option must be used, not "output.file". To inline dynamic imports, set the "inlineDynamicImports" option.' ); }); @@ -190,17 +191,20 @@ describe('sanity checks', () => { } assert.strictEqual( error && error.message, - 'When building multiple chunks, the "output.dir" option must be used, not "output.file". To inline dynamic imports, set the "inlineDynamicImports" option.' + 'Invalid value for option "output.file" - when building multiple chunks, the "output.dir" option must be used, not "output.file". To inline dynamic imports, set the "inlineDynamicImports" option.' ); }); it('does not throw when using dynamic imports with the "file" option and "inlineDynamicImports"', async () => { const bundle = await rollup.rollup({ input: 'x', - inlineDynamicImports: true, plugins: [loader({ x: 'console.log( "x" );import("y");', y: 'console.log( "y" );' })] }); - await bundle.generate({ file: 'x', format: 'es' }); + await bundle.generate({ + file: 'x', + format: 'es', + inlineDynamicImports: true + }); }); it('throws when using the object form of "input" together with the "file" option', async () => { @@ -216,7 +220,7 @@ describe('sanity checks', () => { } assert.strictEqual( error && error.message, - 'You must set "output.dir" instead of "output.file" when providing named inputs.' + 'Invalid value for option "output.file" - you must set "output.dir" instead of "output.file" when providing named inputs.' ); }); @@ -233,7 +237,7 @@ describe('sanity checks', () => { } assert.strictEqual( error && error.message, - 'You must set "output.dir" instead of "output.file" when using the "output.preserveModules" option.' + 'Invalid value for option "output.file" - you must set "output.dir" instead of "output.file" when using the "output.preserveModules" option.' ); }); @@ -287,7 +291,7 @@ describe('sanity checks', () => { assert.strictEqual( warning && warning.message, - '"output.amd.id" is only properly supported for single-file builds. Use "output.amd.autoId" and "output.amd.basePath".' + 'Invalid value for option "output.amd.id" - this option is only properly supported for single-file builds. Use "output.amd.autoId" and "output.amd.basePath" instead.' ); }); }); diff --git a/test/misc/umd.js b/test/misc/umd.js index b9b78bc75de..9945f63bbc3 100644 --- a/test/misc/umd.js +++ b/test/misc/umd.js @@ -1,15 +1,15 @@ -const rollup = require('../../dist/rollup'); -const assert = require('assert'); -const { loader } = require('../utils.js'); +const assert = require('node:assert'); +const { rollup } = require('../../dist/rollup'); +const { loader } = require('../testHelpers.js'); function runTestCode(code, thisValue, globals) { const globalThisDesc = Object.getOwnPropertyDescriptor(global, 'globalThis'); delete global.globalThis; - const globalsWithAssert = Object.assign({}, globals, { assert }); + const globalsWithAssert = { ...globals, assert }; const globalKeys = Object.keys(globalsWithAssert); - const fn = new Function(globalKeys, code); - fn.apply( + const function_ = new Function(globalKeys, code); + function_.apply( thisValue, globalKeys.map(key => globalsWithAssert[key]) ); @@ -33,34 +33,38 @@ function runNodeTest(code) { return module.exports; } -function runAmdTest(code, outputOptions) { - let defineArgs; - function define(...args) { - defineArgs = args; +function runAmdTest(code) { + let defineArguments; + function define(...parameters) { + defineArguments = parameters; } define.amd = true; runTestCode(code, undefined, { define }); - if (typeof defineArgs[0] === 'function') { - return defineArgs[0]() || {}; + if (typeof defineArguments[0] === 'function') { + return defineArguments[0]() || {}; } const module = { exports: {} }; const result = - defineArgs[1]( - ...defineArgs[0].map(injection => { + defineArguments[1]( + ...defineArguments[0].map(injection => { switch (injection) { - case 'module': + case 'module': { return module; - case 'exports': + } + case 'exports': { return module.exports; - case 'external': + } + case 'external': { return 'external'; - default: + } + default: { throw new Error(`unexpected AMD injection ${injection}`); + } } }) ) || {}; - return defineArgs[0].indexOf('exports') === -1 ? result : module.exports; + return defineArguments[0].includes('exports') ? module.exports : result; } function runIifeTestWithThis(code, outputOptions) { @@ -113,20 +117,22 @@ function getIifeExports(global, outputOptions) { if (outputOptions.name) { return outputOptions.name .split('.') - .reduce((currentVar, nextKey) => currentVar[nextKey] || {}, global); + .reduce((currentVariable, nextKey) => currentVariable[nextKey] || {}, global); } return {}; } async function getUmdCode(inputCode, outputOptions) { - const bundle = await rollup.rollup({ + const bundle = await rollup({ input: 'input', external: ['external'], plugins: [loader({ input: inputCode })] }); - const { output } = await bundle.generate( - Object.assign({ format: 'umd', globals: { external: 'external' } }, outputOptions) - ); + const { output } = await bundle.generate({ + format: 'umd', + globals: { external: 'external' }, + ...outputOptions + }); return output[0].code; } @@ -140,7 +146,7 @@ function runTestsWithCode(code, outputOptions, expectedExports) { return (umdCodePromise = getUmdCode(code, outputOptions)); } - [ + for (const { environmentName, runTest } of [ { environmentName: 'node', runTest: runNodeTest @@ -165,20 +171,19 @@ function runTestsWithCode(code, outputOptions, expectedExports) { environmentName: 'iife with existing globals', runTest: runIifeWithExistingValuesTest } - ].forEach(({ environmentName, runTest }) => + ]) it(`works in ${environmentName} environment`, async () => { assert.deepEqual( runTest(await getUmdCodePromise(), outputOptions), expectedExports, 'expected exports are returned' ); - }) - ); + }); } -['bundle', 'my.@nested/value.bundle'].forEach(name => - [false, true].forEach(compact => - [false, true].forEach(noConflict => +for (const name of ['bundle', 'my.@nested/value.bundle']) + for (const compact of [false, true]) { + for (const noConflict of [false, true]) describe(`The UMD wrapper with name="${name}", compact=${compact}, noConflict=${noConflict}`, () => { const outputOptions = { compact, name, noConflict }; @@ -207,7 +212,22 @@ function runTestsWithCode(code, outputOptions, expectedExports) { runTestsWithCode('import value from "external"; export default {value};', outputOptions, { value: 'external' })); - }) - ) - ) -); + }); + } + +describe('The UMD wrapper with output name as reserved keyword', () => { + it('Set output name as toString.value', () => { + getUmdCode('export const x = 42;', { name: 'toString.value' }).then(code => { + assert.deepEqual( + code, + 'this.toString = this.toString || {};\n' + + 'this.toString.value = (function (exports) {\n' + + "'use strict';\n\n" + + 'const x = 42;\n\n' + + 'exports.x = x;\n\n' + + 'return exports;\n\n' + + '})({});' + ); + }); + }); +}); diff --git a/test/node_modules/external-esm/index.js b/test/node_modules/external-esm/index.js new file mode 100644 index 00000000000..9c87fc2a3c2 --- /dev/null +++ b/test/node_modules/external-esm/index.js @@ -0,0 +1,3 @@ +export default { + external: true +}; diff --git a/test/node_modules/external-esm/package.json b/test/node_modules/external-esm/package.json new file mode 100644 index 00000000000..0203c72855d --- /dev/null +++ b/test/node_modules/external-esm/package.json @@ -0,0 +1,4 @@ +{ + "type": "module", + "main": "index.js" +} diff --git a/test/sourcemaps/define.d.ts b/test/sourcemaps/define.d.ts new file mode 100644 index 00000000000..6de80b661ef --- /dev/null +++ b/test/sourcemaps/define.d.ts @@ -0,0 +1,5 @@ +import type { TestConfigSourcemap } from '../types'; + +declare global { + function defineTest(config: TestConfigSourcemap): TestConfigSourcemap; +} diff --git a/test/sourcemaps/getLocation.js b/test/sourcemaps/getLocation.js index 641340a0548..496d14d43ea 100644 --- a/test/sourcemaps/getLocation.js +++ b/test/sourcemaps/getLocation.js @@ -1,18 +1,23 @@ +/** + * @param {string} source + * @param {string | number} search + * @returns {{ line: number, column: number } | undefined} + */ module.exports = function getLocation(source, search) { var lines = source.split('\n'); - var len = lines.length; + var length_ = lines.length; var lineStart = 0; - var i; + var index; const charIndex = typeof search === 'number' ? search : source.indexOf(search); - for (i = 0; i < len; i += 1) { - var line = lines[i]; + for (index = 0; index < length_; index += 1) { + var line = lines[index]; var lineEnd = lineStart + line.length + 1; // +1 for newline if (lineEnd > charIndex) { - return { line: i + 1, column: charIndex - lineStart }; + return { line: index + 1, column: charIndex - lineStart }; } lineStart = lineEnd; diff --git a/test/sourcemaps/index.js b/test/sourcemaps/index.js index fef092a0749..c415f8ac102 100644 --- a/test/sourcemaps/index.js +++ b/test/sourcemaps/index.js @@ -1,61 +1,67 @@ -const path = require('path'); +const path = require('node:path'); +/** + * @type {import('../../src/rollup/types')} Rollup + */ +// @ts-expect-error not included in types const rollup = require('../../dist/rollup'); -const { compareWarnings, runTestSuiteWithSamples } = require('../utils.js'); +// @ts-expect-error not included in types +const { compareLogs, runTestSuiteWithSamples } = require('../testHelpers.js'); const FORMATS = ['amd', 'cjs', 'system', 'es', 'iife', 'umd']; -runTestSuiteWithSamples('sourcemaps', path.resolve(__dirname, 'samples'), (dir, config) => { - (config.skip ? describe.skip : config.solo ? describe.only : describe)( - path.basename(dir) + ': ' + config.description, - () => { - for (const format of config.formats || FORMATS) { - it('generates ' + format, async () => { - process.chdir(dir); - const warnings = []; - const inputOptions = Object.assign( - { - input: dir + '/main.js', +runTestSuiteWithSamples( + 'sourcemaps', + path.resolve(__dirname, 'samples'), + /** + * @param {import('../types').TestConfigSourcemap} config + */ + (directory, config) => { + (config.skip ? describe.skip : config.solo ? describe.only : describe)( + path.basename(directory) + ': ' + config.description, + () => { + for (const format of config.formats || FORMATS) { + it('generates ' + format, async () => { + process.chdir(directory); + const warnings = []; + const inputOptions = { + input: directory + '/main.js', onwarn: warning => warnings.push(warning), - strictDeprecations: true - }, - config.options || {} - ); - const outputOptions = Object.assign( - { + strictDeprecations: true, + ...config.options + }; + const outputOptions = { exports: 'auto', - file: dir + '/_actual/bundle.' + format + '.js', + file: directory + '/_actual/bundle.' + format + '.js', format, - sourcemap: true - }, - (config.options || {}).output || {} - ); + sourcemap: true, + ...(config.options || {}).output + }; - let bundle = await rollup.rollup(inputOptions); - await generateAndTestBundle(bundle, outputOptions, config, format, warnings); - // cache rebuild does not reemit warnings. - if (config.warnings) { - return; - } - // test cache noop rebuild - bundle = await rollup.rollup(Object.assign({ cache: bundle }, inputOptions)); - await generateAndTestBundle(bundle, outputOptions, config, format, warnings); - }); + let bundle = await rollup.rollup(inputOptions); + await generateAndTestBundle(bundle, outputOptions, config, format, warnings); + // cache rebuild does not reemit warnings. + if (config.warnings) { + return; + } + // test cache noop rebuild + bundle = await rollup.rollup({ cache: bundle, ...inputOptions }); + await generateAndTestBundle(bundle, outputOptions, config, format, warnings); + }); + } } - } - ); -}); + ); + } +); async function generateAndTestBundle(bundle, outputOptions, config, format, warnings) { - await bundle.write(outputOptions); if (config.warnings) { - compareWarnings(warnings, config.warnings); - } else if (warnings.length) { + compareLogs(warnings, config.warnings); + } else if (warnings.length > 0) { throw new Error(`Unexpected warnings`); } - if (config.test) { - const { - output: [{ code, map }] - } = await bundle.generate(outputOptions); - await config.test(code, map, { format }); - } + + const { + output: [{ code, map, fileName, sourcemapFileName }] + } = await bundle.write(outputOptions); + await config.test(code, map, { fileName, sourcemapFileName, format }); } diff --git a/test/sourcemaps/samples/basic-support/_config.js b/test/sourcemaps/samples/basic-support/_config.js index 5e6a58110b3..5ef590e13d4 100644 --- a/test/sourcemaps/samples/basic-support/_config.js +++ b/test/sourcemaps/samples/basic-support/_config.js @@ -1,8 +1,8 @@ -const assert = require('assert'); -const getLocation = require('../../getLocation'); +const assert = require('node:assert'); const { SourceMapConsumer } = require('source-map'); +const getLocation = require('../../getLocation'); -module.exports = { +module.exports = defineTest({ description: 'basic sourcemap support', async test(code, map) { assert.equal(map.version, 3); @@ -36,4 +36,4 @@ module.exports = { assert.equal(originalLoc.column, 1); assert.equal(originalLoc.source, '../bar.js'); } -}; +}); diff --git a/test/sourcemaps/samples/combined-sourcemap-2/_config.js b/test/sourcemaps/samples/combined-sourcemap-2/_config.js new file mode 100644 index 00000000000..fc82dbc5cff --- /dev/null +++ b/test/sourcemaps/samples/combined-sourcemap-2/_config.js @@ -0,0 +1,82 @@ +const assert = require('node:assert'); +const { encode } = require('@jridgewell/sourcemap-codec'); +const terser = require('terser'); +const { SourceMapConsumer } = require('source-map'); +const getLocation = require('../../getLocation'); + +const originalCode = ` +export function App() { + return
{'.'}
; +} +`; + +module.exports = defineTest({ + description: 'get correct combined sourcemap by calling getCombinedSourcemap', + formats: ['es'], + options: { + external: ['react/jsx-runtime'], + plugins: [ + { + resolveId(id) { + return id; + }, + load() { + return { + code: originalCode + }; + } + }, + { + async transform(code) { + return { + code: `import { jsx } from "react/jsx-runtime"; +export function App() { + return /* @__PURE__ */ jsx("div", { children: "." }); +} +`, + map: { + mappings: encode([ + [[0, 0, 2, 9]], + [ + [0, 0, 1, 7], + [16, 0, 1, 16], + [22, 0, 1, 22] + ], + [ + // coarse segment + [0, 0, 2, 2], + [9, 0, 2, 9], + [29, 0, 2, 10], + [38, 0, 2, 15], + [53, 0, 2, 19] + ], + [[0, 0, 3, 0]], + [] + ]), + sourcesContent: [code] + } + }; + } + }, + { + transform(code) { + return terser.minify(code, { + sourceMap: true + }); + } + }, + { + async transform(code) { + const generatedLoc = getLocation(code, code.indexOf('return')); + const map = this.getCombinedSourcemap(); + const smc = await new SourceMapConsumer(map); + const originalLoc = smc.originalPositionFor(generatedLoc); + const expectedOriginalLoc = getLocation(originalCode, originalCode.indexOf('return')); + assert.equal(originalLoc.line, expectedOriginalLoc.line); + assert.equal(originalLoc.column, expectedOriginalLoc.column); + } + } + ] + }, + async test() {} +}); diff --git a/test/sourcemaps/samples/combined-sourcemap-3/_config.js b/test/sourcemaps/samples/combined-sourcemap-3/_config.js new file mode 100644 index 00000000000..4169b67af0b --- /dev/null +++ b/test/sourcemaps/samples/combined-sourcemap-3/_config.js @@ -0,0 +1,91 @@ +const assert = require('node:assert'); +const { encode } = require('@jridgewell/sourcemap-codec'); +const { SourceMapConsumer } = require('source-map'); +const getLocation = require('../../getLocation'); +const originalCode = ` +export function App() { + if (count) { + console.log(count); + } + return
{count}
; +} +`; + +module.exports = defineTest({ + description: 'get correct combined sourcemap of bundled code', + formats: ['es'], + options: { + external: ['react/jsx-runtime'], + plugins: [ + { + resolveId(id) { + return id; + }, + load() { + return { + code: originalCode + }; + } + }, + { + async transform(code) { + // returned code and mappings generated by esbuild@0.25.5 + return { + code: `export function App() { + if (count) { + console.log(count); + } + return /* @__PURE__ */ React.createElement("div", null, count); +} +`, + map: { + mappings: encode([ + [ + [0, 0, 1, 7], + [16, 0, 1, 16], + [22, 0, 1, 22] + ], + [ + [0, 0, 2, 2], + [6, 0, 2, 6], + [13, 0, 2, 13] + ], + [ + [0, 0, 3, 4], + [12, 0, 3, 12], + [16, 0, 3, 16], + [21, 0, 3, 21] + ], + [ + // coarse segment + [0, 0, 3, 21], + [2, 0, 4, 2] + ], + [ + [0, 0, 5, 2], + [9, 0, 5, 9], + [45, 0, 5, 10], + [58, 0, 5, 15], + [63, 0, 5, 21] + ], + [[0, 0, 6, 0]], + [] + ]), + names: [], + sourcesContent: [code] + } + }; + } + } + ] + }, + async test(code, map) { + const generatedLoc = getLocation(code, code.indexOf(' }') + 2); + const smc = await new SourceMapConsumer(map); + const originalLoc = smc.originalPositionFor(generatedLoc); + const expectedOriginalLoc = getLocation(originalCode, originalCode.indexOf(' }') + 2); + console.log(originalLoc, expectedOriginalLoc); + assert.equal(originalLoc.line, expectedOriginalLoc.line); + assert.equal(originalLoc.column, expectedOriginalLoc.column); + } +}); diff --git a/test/sourcemaps/samples/combined-sourcemap-with-loader/_config.js b/test/sourcemaps/samples/combined-sourcemap-with-loader/_config.js index 8812afbd383..3c3d641a8e0 100644 --- a/test/sourcemaps/samples/combined-sourcemap-with-loader/_config.js +++ b/test/sourcemaps/samples/combined-sourcemap-with-loader/_config.js @@ -1,17 +1,18 @@ -const fs = require('fs'); +const assert = require('node:assert'); +const { readFileSync } = require('node:fs'); const buble = require('buble'); -const MagicString = require('magic-string'); -const assert = require('assert'); -const getLocation = require('../../getLocation'); +const MagicString = require('magic-string').default; const { SourceMapConsumer } = require('source-map'); +const getLocation = require('../../getLocation'); -module.exports = { +module.exports = defineTest({ description: 'get combined sourcemap in transforming with loader', options: { plugins: [ { + name: 'test-plugin1', load(id) { - const code = fs.readFileSync(id, 'utf-8'); + const code = readFileSync(id, 'utf8'); const out = buble.transform(code, { transforms: { modules: false }, sourceMap: true, @@ -22,6 +23,7 @@ module.exports = { } }, { + name: 'test-plugin2', async transform(code, id) { const sourcemap = this.getCombinedSourcemap(); const smc = await new SourceMapConsumer(sourcemap); @@ -46,6 +48,7 @@ module.exports = { } }, { + name: 'test-plugin3', async transform(code, id) { const sourcemap = this.getCombinedSourcemap(); const smc = await new SourceMapConsumer(sourcemap); @@ -76,7 +79,7 @@ module.exports = { testFoo(code, smc); testMain(code, smc); } -}; +}); function testFoo(code, smc) { const generatedLoc = getLocation(code, code.indexOf(42)); diff --git a/test/sourcemaps/samples/combined-sourcemap/_config.js b/test/sourcemaps/samples/combined-sourcemap/_config.js index a87fd1a626c..63ee2ec85b8 100644 --- a/test/sourcemaps/samples/combined-sourcemap/_config.js +++ b/test/sourcemaps/samples/combined-sourcemap/_config.js @@ -1,13 +1,14 @@ -const MagicString = require('magic-string'); -const assert = require('assert'); -const getLocation = require('../../getLocation'); +const assert = require('node:assert'); +const MagicString = require('magic-string').default; const { SourceMapConsumer } = require('source-map'); +const getLocation = require('../../getLocation'); -module.exports = { +module.exports = defineTest({ description: 'get combined sourcemap in transforming', options: { plugins: [ { + name: 'test-plugin1', async transform(code, id) { const sourcemap = this.getCombinedSourcemap(); const smc = await new SourceMapConsumer(sourcemap); @@ -32,6 +33,7 @@ module.exports = { } }, { + name: 'test-plugin2', async transform(code, id) { const sourcemap = this.getCombinedSourcemap(); const smc = await new SourceMapConsumer(sourcemap); @@ -62,7 +64,7 @@ module.exports = { testFoo(code, smc); testMain(code, smc); } -}; +}); function testFoo(code, smc) { const generatedLoc = getLocation(code, code.indexOf(42)); diff --git a/test/sourcemaps/samples/debug-ids-with-placeholder/_config.js b/test/sourcemaps/samples/debug-ids-with-placeholder/_config.js new file mode 100644 index 00000000000..1ae276c6fee --- /dev/null +++ b/test/sourcemaps/samples/debug-ids-with-placeholder/_config.js @@ -0,0 +1,22 @@ +const assert = require('node:assert'); + +module.exports = defineTest({ + description: 'are injected into the source and sourcemaps when using placeholders', + options: { + output: { + name: 'myModule', + sourcemapDebugIds: true, + entryFileNames: '[name]-[hash].js' + } + }, + async test(code, map) { + const match = code.match(/\/\/# debugId=([a-fA-F0-9-]+)/); + assert.ok(match, 'Could not find debugId in source'); + const sourceDebugId = match[1]; + assert.equal( + map.debugId, + sourceDebugId, + "debugId in source doesn't match debugId in sourcemap" + ); + } +}); diff --git a/test/sourcemaps/samples/debug-ids-with-placeholder/bar.js b/test/sourcemaps/samples/debug-ids-with-placeholder/bar.js new file mode 100644 index 00000000000..b074af8a4ab --- /dev/null +++ b/test/sourcemaps/samples/debug-ids-with-placeholder/bar.js @@ -0,0 +1 @@ +export default function Foo () {} diff --git a/test/sourcemaps/samples/debug-ids-with-placeholder/foo.js b/test/sourcemaps/samples/debug-ids-with-placeholder/foo.js new file mode 100644 index 00000000000..82616f39faf --- /dev/null +++ b/test/sourcemaps/samples/debug-ids-with-placeholder/foo.js @@ -0,0 +1,5 @@ +import Bar from './bar'; + +export default function Foo () {} + +Foo.prototype = Object.create( Bar.prototype ); diff --git a/test/sourcemaps/samples/debug-ids-with-placeholder/main.js b/test/sourcemaps/samples/debug-ids-with-placeholder/main.js new file mode 100644 index 00000000000..a03af972303 --- /dev/null +++ b/test/sourcemaps/samples/debug-ids-with-placeholder/main.js @@ -0,0 +1 @@ +export { default as Foo } from './foo'; diff --git a/test/sourcemaps/samples/debug-ids/_config.js b/test/sourcemaps/samples/debug-ids/_config.js new file mode 100644 index 00000000000..e087f93000a --- /dev/null +++ b/test/sourcemaps/samples/debug-ids/_config.js @@ -0,0 +1,23 @@ +const assert = require('node:assert'); + +module.exports = defineTest({ + description: 'are injected into the source and sourcemaps', + options: { + output: { + name: 'myModule', + sourcemapDebugIds: true + } + }, + async test(code, map) { + const match = code.match( + /\/\/# debugId=([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})/ + ); + assert.ok(match, 'Could not find debugId in source'); + const sourceDebugId = match[1]; + assert.equal( + map.debugId, + sourceDebugId, + "debugId in source doesn't match debugId in sourcemap" + ); + } +}); diff --git a/test/sourcemaps/samples/debug-ids/bar.js b/test/sourcemaps/samples/debug-ids/bar.js new file mode 100644 index 00000000000..e8f7ac9ffa0 --- /dev/null +++ b/test/sourcemaps/samples/debug-ids/bar.js @@ -0,0 +1 @@ +export default function Foo () { return 19; } diff --git a/test/sourcemaps/samples/debug-ids/foo.js b/test/sourcemaps/samples/debug-ids/foo.js new file mode 100644 index 00000000000..82616f39faf --- /dev/null +++ b/test/sourcemaps/samples/debug-ids/foo.js @@ -0,0 +1,5 @@ +import Bar from './bar'; + +export default function Foo () {} + +Foo.prototype = Object.create( Bar.prototype ); diff --git a/test/sourcemaps/samples/debug-ids/main.js b/test/sourcemaps/samples/debug-ids/main.js new file mode 100644 index 00000000000..a03af972303 --- /dev/null +++ b/test/sourcemaps/samples/debug-ids/main.js @@ -0,0 +1 @@ +export { default as Foo } from './foo'; diff --git a/test/sourcemaps/samples/excludes-plugin-helpers/_config.js b/test/sourcemaps/samples/excludes-plugin-helpers/_config.js index f8fded78f3e..822dfa47b9c 100644 --- a/test/sourcemaps/samples/excludes-plugin-helpers/_config.js +++ b/test/sourcemaps/samples/excludes-plugin-helpers/_config.js @@ -1,10 +1,10 @@ -const fs = require('fs'); -const path = require('path'); -const assert = require('assert'); +const assert = require('node:assert'); +const { readFileSync } = require('node:fs'); +const path = require('node:path'); const HELPER = '\0helper'; -module.exports = { +module.exports = defineTest({ description: 'excludes plugin helpers from sources', options: { output: { @@ -12,13 +12,15 @@ module.exports = { }, plugins: [ { + name: 'test-plugin', + resolveId(id) { if (id === HELPER) return id; }, load(id) { if (id === HELPER) { - return fs.readFileSync(path.join(__dirname, 'helper.js'), 'utf-8'); + return readFileSync(path.join(__dirname, 'helper.js'), 'utf8'); } } } @@ -29,4 +31,4 @@ module.exports = { assert.equal(map.sourcesContent.length, 1); assert.ok(/main/.test(map.sources[0])); } -}; +}); diff --git a/test/sourcemaps/samples/existing-external-sourcemaps-combined/_config.js b/test/sourcemaps/samples/existing-external-sourcemaps-combined/_config.js index 41b40422986..41b38bedd31 100644 --- a/test/sourcemaps/samples/existing-external-sourcemaps-combined/_config.js +++ b/test/sourcemaps/samples/existing-external-sourcemaps-combined/_config.js @@ -1,8 +1,8 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'removes sourcemap comments', async test(code) { - assert.strictEqual(code.indexOf('sourceMappingURL'), -1); + assert.ok(!code.includes('sourceMappingURL=main.js.map')); } -}; +}); diff --git a/test/sourcemaps/samples/existing-inline-sourcemaps-combined/_config.js b/test/sourcemaps/samples/existing-inline-sourcemaps-combined/_config.js index 2457b5690f0..c2cdc0ad9a9 100644 --- a/test/sourcemaps/samples/existing-inline-sourcemaps-combined/_config.js +++ b/test/sourcemaps/samples/existing-inline-sourcemaps-combined/_config.js @@ -1,8 +1,8 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'removes existing inline sourcemaps', async test(code) { - assert.strictEqual(code.indexOf('sourceMappingURL'), -1); + assert.ok(!code.includes('sourceMappingURL=data')); } -}; +}); diff --git a/test/sourcemaps/samples/ignore-list-default/_config.js b/test/sourcemaps/samples/ignore-list-default/_config.js new file mode 100644 index 00000000000..2df5184401a --- /dev/null +++ b/test/sourcemaps/samples/ignore-list-default/_config.js @@ -0,0 +1,17 @@ +const assert = require('node:assert'); +const path = require('node:path'); + +module.exports = defineTest({ + description: 'defaults to adding files within node_modules to the ignore list', + options: { + output: { + name: 'myModule', + file: path.resolve(__dirname, '_actual/bundle.js'), + sourcemapPathTransform: sourcePath => path.basename(sourcePath) + } + }, + test(code, map) { + assert.deepEqual(map.sources, ['lib.js', 'main.js']); + assert.deepEqual(map.x_google_ignoreList, [0]); + } +}); diff --git a/test/sourcemaps/samples/ignore-list-default/main.js b/test/sourcemaps/samples/ignore-list-default/main.js new file mode 100644 index 00000000000..13b6d373771 --- /dev/null +++ b/test/sourcemaps/samples/ignore-list-default/main.js @@ -0,0 +1,3 @@ +import one from './node_modules/lib.js'; + +export default one * 2; diff --git a/test/sourcemaps/samples/ignore-list-default/node_modules/lib.js b/test/sourcemaps/samples/ignore-list-default/node_modules/lib.js new file mode 100644 index 00000000000..aef22247d75 --- /dev/null +++ b/test/sourcemaps/samples/ignore-list-default/node_modules/lib.js @@ -0,0 +1 @@ +export default 1; diff --git a/test/sourcemaps/samples/ignore-list-false/_config.js b/test/sourcemaps/samples/ignore-list-false/_config.js new file mode 100644 index 00000000000..ed87dc8b580 --- /dev/null +++ b/test/sourcemaps/samples/ignore-list-false/_config.js @@ -0,0 +1,19 @@ +const assert = require('node:assert'); +const path = require('node:path'); + +module.exports = defineTest({ + description: + 'accepts false for `sourcemapIgnoreList` to disable the default ignore-listing of node_modules', + options: { + output: { + name: 'myModule', + file: path.resolve(__dirname, '_actual/bundle.js'), + sourcemapPathTransform: sourcePath => path.basename(sourcePath), + sourcemapIgnoreList: false + } + }, + test(code, map) { + assert.deepEqual(map.sources, ['lib.js', 'main.js']); + assert.strictEqual(map.x_google_ignoreList, undefined); + } +}); diff --git a/test/sourcemaps/samples/ignore-list-false/main.js b/test/sourcemaps/samples/ignore-list-false/main.js new file mode 100644 index 00000000000..f09366999a6 --- /dev/null +++ b/test/sourcemaps/samples/ignore-list-false/main.js @@ -0,0 +1,3 @@ +import one from './node_modules/lib.js'; + +export default one * 5; diff --git a/test/sourcemaps/samples/ignore-list-false/node_modules/lib.js b/test/sourcemaps/samples/ignore-list-false/node_modules/lib.js new file mode 100644 index 00000000000..aef22247d75 --- /dev/null +++ b/test/sourcemaps/samples/ignore-list-false/node_modules/lib.js @@ -0,0 +1 @@ +export default 1; diff --git a/test/sourcemaps/samples/ignore-list-source-files/_config.js b/test/sourcemaps/samples/ignore-list-source-files/_config.js new file mode 100644 index 00000000000..b2382971176 --- /dev/null +++ b/test/sourcemaps/samples/ignore-list-source-files/_config.js @@ -0,0 +1,18 @@ +const assert = require('node:assert'); +const path = require('node:path'); + +module.exports = defineTest({ + description: 'populates ignore list', + options: { + output: { + name: 'myModule', + file: path.resolve(__dirname, '_actual/bundle.js'), + sourcemapIgnoreList: sourcePath => sourcePath.includes('lib'), + sourcemapPathTransform: sourcePath => path.basename(sourcePath) + } + }, + test(code, map) { + assert.deepEqual(map.sources, ['lib1.js', 'lib2.js', 'main.js']); + assert.deepEqual(map.x_google_ignoreList, [0, 1]); + } +}); diff --git a/test/sourcemaps/samples/ignore-list-source-files/lib1.js b/test/sourcemaps/samples/ignore-list-source-files/lib1.js new file mode 100644 index 00000000000..aef22247d75 --- /dev/null +++ b/test/sourcemaps/samples/ignore-list-source-files/lib1.js @@ -0,0 +1 @@ +export default 1; diff --git a/test/sourcemaps/samples/ignore-list-source-files/lib2.js b/test/sourcemaps/samples/ignore-list-source-files/lib2.js new file mode 100644 index 00000000000..842e368a0a2 --- /dev/null +++ b/test/sourcemaps/samples/ignore-list-source-files/lib2.js @@ -0,0 +1 @@ +export default 2; diff --git a/test/sourcemaps/samples/ignore-list-source-files/main.js b/test/sourcemaps/samples/ignore-list-source-files/main.js new file mode 100644 index 00000000000..b6752a45f37 --- /dev/null +++ b/test/sourcemaps/samples/ignore-list-source-files/main.js @@ -0,0 +1,4 @@ +import one from './lib1.js'; +import two from './lib2.js'; + +export default one + two; diff --git a/test/sourcemaps/samples/ignore-list-sourcemap-path/_config.js b/test/sourcemaps/samples/ignore-list-sourcemap-path/_config.js new file mode 100644 index 00000000000..d30ad74cdce --- /dev/null +++ b/test/sourcemaps/samples/ignore-list-sourcemap-path/_config.js @@ -0,0 +1,21 @@ +const assert = require('node:assert'); +const path = require('node:path'); + +module.exports = defineTest({ + description: 'correctly passes source map path', + options: { + output: { + name: 'myModule', + file: path.resolve(__dirname, '_actual/output.js'), + sourcemapIgnoreList: (relativeSourcePath, sourcemapPath) => + path.basename(sourcemapPath) === 'output.js.map' && + path.basename(path.dirname(sourcemapPath)) === '_actual' && + path.basename(relativeSourcePath) === 'main.js', + sourcemapPathTransform: relativeSourcePath => path.basename(relativeSourcePath) + } + }, + test(code, map) { + assert.deepEqual(map.sources, ['main.js']); + assert.deepEqual(map.x_google_ignoreList, [0]); + } +}); diff --git a/test/sourcemaps/samples/ignore-list-sourcemap-path/main.js b/test/sourcemaps/samples/ignore-list-sourcemap-path/main.js new file mode 100644 index 00000000000..7a4e8a723a4 --- /dev/null +++ b/test/sourcemaps/samples/ignore-list-sourcemap-path/main.js @@ -0,0 +1 @@ +export default 42; diff --git a/test/sourcemaps/samples/loaders/_config.js b/test/sourcemaps/samples/loaders/_config.js index 532dbb6ad3c..d8ed77c4b57 100644 --- a/test/sourcemaps/samples/loaders/_config.js +++ b/test/sourcemaps/samples/loaders/_config.js @@ -1,10 +1,10 @@ +const assert = require('node:assert'); +const { readFileSync } = require('node:fs'); const buble = require('buble'); -const fs = require('fs'); -const assert = require('assert'); -const getLocation = require('../../getLocation'); const { SourceMapConsumer } = require('source-map'); +const getLocation = require('../../getLocation'); -module.exports = { +module.exports = defineTest({ description: 'preserves sourcemap chains when transforming', options: { plugins: [ @@ -16,7 +16,7 @@ module.exports = { id = id.replace(/bar.js$/, 'foo.js'); } - const code = fs.readFileSync(id, 'utf-8'); + const code = readFileSync(id, 'utf8'); const out = buble.transform(code, { transforms: { modules: false }, @@ -62,4 +62,4 @@ module.exports = { assert.equal(originalLoc.line, 4); assert.equal(originalLoc.column, 19); } -}; +}); diff --git a/test/sourcemaps/samples/names-transformed-render-chunk/_config.js b/test/sourcemaps/samples/names-transformed-render-chunk/_config.js index deaf9c189ba..01583823ee7 100644 --- a/test/sourcemaps/samples/names-transformed-render-chunk/_config.js +++ b/test/sourcemaps/samples/names-transformed-render-chunk/_config.js @@ -1,10 +1,10 @@ -const assert = require('assert'); -const terser = require('terser'); +const assert = require('node:assert'); const MagicString = require('magic-string'); -const getLocation = require('../../getLocation'); const { SourceMapConsumer } = require('source-map'); +const terser = require('terser'); +const getLocation = require('../../getLocation'); -module.exports = { +module.exports = defineTest({ description: 'names are recovered if transforms are used', options: { plugins: [ @@ -59,4 +59,4 @@ module.exports = { name: 'mangleMe' }); } -}; +}); diff --git a/test/sourcemaps/samples/names/_config.js b/test/sourcemaps/samples/names/_config.js index 27e167e44d9..977a30de9bc 100644 --- a/test/sourcemaps/samples/names/_config.js +++ b/test/sourcemaps/samples/names/_config.js @@ -1,8 +1,8 @@ -const assert = require('assert'); -const getLocation = require('../../getLocation'); +const assert = require('node:assert'); const { SourceMapConsumer } = require('source-map'); +const getLocation = require('../../getLocation'); -module.exports = { +module.exports = defineTest({ description: 'names are recovered (https://github.com/rollup/rollup/issues/101)', options: { output: { @@ -12,18 +12,18 @@ module.exports = { async test(code, map) { const smc = await new SourceMapConsumer(map); - let pattern = /Object\.create\( ([\w$\d]+)\.prototype \)/; + let pattern = /Object\.create\( ([\w$]+)\.prototype \)/; let match = pattern.exec(code); let generatedLoc = getLocation(code, match.index + 'Object.create ( '.length); let original = smc.originalPositionFor(generatedLoc); assert.equal(original.name, 'Bar'); - pattern = /function Foo([\w$\d]+)/; + pattern = /function Foo([\w$]+)/; match = pattern.exec(code); generatedLoc = getLocation(code, match.index + 'function '.length); original = smc.originalPositionFor(generatedLoc); assert.equal(original.name, 'Foo'); } -}; +}); diff --git a/test/sourcemaps/samples/reified-namespace/_config.js b/test/sourcemaps/samples/reified-namespace/_config.js index ae009643634..8f6349898b4 100644 --- a/test/sourcemaps/samples/reified-namespace/_config.js +++ b/test/sourcemaps/samples/reified-namespace/_config.js @@ -1,15 +1,15 @@ -const fs = require('fs'); -const path = require('path'); -const assert = require('assert'); -const getLocation = require('../../getLocation'); +const assert = require('node:assert'); +const { readFileSync } = require('node:fs'); +const path = require('node:path'); const { SourceMapConsumer } = require('source-map'); +const getLocation = require('../../getLocation'); -module.exports = { +module.exports = defineTest({ description: 'generates correct sourcemap with reified namespace (#668)', async test(code, map) { const smc = await new SourceMapConsumer(map); - const main = fs.readFileSync(path.join(__dirname, 'main.js'), 'utf-8'); + const main = readFileSync(path.join(__dirname, 'main.js'), 'utf8'); const generatedLoc = getLocation(code, 'deepEqual'); const actual = smc.originalPositionFor(generatedLoc); @@ -19,4 +19,4 @@ module.exports = { assert.equal(actual.column, expected.column); assert.equal(actual.source, '../main.js'); } -}; +}); diff --git a/test/sourcemaps/samples/relative-paths/_config.js b/test/sourcemaps/samples/relative-paths/_config.js index b80dac8c839..b8113a8eaf8 100644 --- a/test/sourcemaps/samples/relative-paths/_config.js +++ b/test/sourcemaps/samples/relative-paths/_config.js @@ -1,7 +1,7 @@ -const path = require('path'); -const assert = require('assert'); +const assert = require('node:assert'); +const path = require('node:path'); -module.exports = { +module.exports = defineTest({ description: 'source paths are relative with relative dest (#344)', options: { output: { @@ -12,4 +12,4 @@ module.exports = { test(code, map) { assert.deepEqual(map.sources, ['../main.js']); } -}; +}); diff --git a/test/sourcemaps/samples/render-chunk-babili/_config.js b/test/sourcemaps/samples/render-chunk-babili/_config.js index b796ba57c1d..85202f9d179 100644 --- a/test/sourcemaps/samples/render-chunk-babili/_config.js +++ b/test/sourcemaps/samples/render-chunk-babili/_config.js @@ -1,13 +1,14 @@ -const babiliResults = require('./babili-results'); -const assert = require('assert'); -const getLocation = require('../../getLocation'); +const assert = require('node:assert'); const { SourceMapConsumer } = require('source-map'); +const getLocation = require('../../getLocation'); +const babiliResults = require('./babili-results'); -module.exports = { +module.exports = defineTest({ description: 'generates valid sourcemap when source could not be determined', options: { plugins: [ { + name: 'test-plugin', renderChunk(code, chunk, options) { const format = options.format; @@ -33,4 +34,4 @@ module.exports = { assert.equal(originalLoc.line, 1); assert.equal(originalLoc.column, 8); } -}; +}); diff --git a/test/sourcemaps/samples/render-chunk/_config.js b/test/sourcemaps/samples/render-chunk/_config.js index 73f7b814ae6..ce41a76c1c5 100644 --- a/test/sourcemaps/samples/render-chunk/_config.js +++ b/test/sourcemaps/samples/render-chunk/_config.js @@ -1,13 +1,14 @@ +const assert = require('node:assert'); +const { SourceMapConsumer } = require('source-map'); const terser = require('terser'); -const assert = require('assert'); const getLocation = require('../../getLocation'); -const { SourceMapConsumer } = require('source-map'); -module.exports = { +module.exports = defineTest({ description: 'preserves sourcemap chains when transforming', options: { plugins: [ { + name: 'test-plugin', renderChunk(code) { const options = { sourceMap: { @@ -36,4 +37,4 @@ module.exports = { assert.equal(originalLoc.line, 1); assert.equal(originalLoc.column, 8); } -}; +}); diff --git a/test/sourcemaps/samples/single-length-segments/_config.js b/test/sourcemaps/samples/single-length-segments/_config.js index 503b9a0caf8..a7fe1044e4d 100644 --- a/test/sourcemaps/samples/single-length-segments/_config.js +++ b/test/sourcemaps/samples/single-length-segments/_config.js @@ -1,20 +1,21 @@ -const fs = require('fs'); -const path = require('path'); -const assert = require('assert'); -const getLocation = require('../../getLocation'); +const assert = require('node:assert'); +const { readFileSync } = require('node:fs'); +const path = require('node:path'); const { SourceMapConsumer } = require('source-map'); +const getLocation = require('../../getLocation'); -const original = fs.readFileSync(path.resolve(__dirname, 'main.js'), 'utf-8'); +const original = readFileSync(path.resolve(__dirname, 'main.js'), 'utf8'); -module.exports = { +module.exports = defineTest({ description: 'handles single-length sourcemap segments', options: { plugins: [ { + name: 'test-plugin', transform() { return { - code: fs.readFileSync(path.resolve(__dirname, 'output.js'), 'utf-8'), - map: fs.readFileSync(path.resolve(__dirname, 'output.js.map'), 'utf-8') + code: readFileSync(path.resolve(__dirname, 'output.js'), 'utf8'), + map: readFileSync(path.resolve(__dirname, 'output.js.map'), 'utf8') }; } } @@ -26,7 +27,7 @@ module.exports = { async test(code, map) { const smc = await new SourceMapConsumer(map); - ['Foo', 'log'].forEach(token => { + for (const token of ['Foo', 'log']) { const generatedLoc = getLocation(code, code.indexOf(token)); const originalLoc = smc.originalPositionFor(generatedLoc); const expectedLoc = getLocation(original, original.indexOf(token)); @@ -34,6 +35,6 @@ module.exports = { assert.ok(/main/.test(originalLoc.source)); assert.equal(originalLoc.line, expectedLoc.line); assert.equal(originalLoc.column, expectedLoc.column); - }); + } } -}; +}); diff --git a/test/sourcemaps/samples/sourcemap-base-url-without-trailing-slash/_config.js b/test/sourcemaps/samples/sourcemap-base-url-without-trailing-slash/_config.js new file mode 100644 index 00000000000..3cce3a22c89 --- /dev/null +++ b/test/sourcemaps/samples/sourcemap-base-url-without-trailing-slash/_config.js @@ -0,0 +1,17 @@ +const assert = require('node:assert'); + +module.exports = defineTest({ + description: 'add a trailing slash automatically if it is missing', + options: { + output: { + sourcemapBaseUrl: 'https://example.com/a' + } + }, + test: (code, map, { format }) => { + const sourceMappingURL = code.split('\n').slice(-2)[0]; + assert.strictEqual( + sourceMappingURL, + `//# sourceMappingURL=https://example.com/a/bundle.${format}.js.map` + ); + } +}); diff --git a/test/sourcemaps/samples/sourcemap-base-url-without-trailing-slash/main.js b/test/sourcemaps/samples/sourcemap-base-url-without-trailing-slash/main.js new file mode 100644 index 00000000000..cc1d88a24fa --- /dev/null +++ b/test/sourcemaps/samples/sourcemap-base-url-without-trailing-slash/main.js @@ -0,0 +1 @@ +assert.ok(true); diff --git a/test/sourcemaps/samples/sourcemap-base-url/_config.js b/test/sourcemaps/samples/sourcemap-base-url/_config.js new file mode 100644 index 00000000000..e8ff4e53c75 --- /dev/null +++ b/test/sourcemaps/samples/sourcemap-base-url/_config.js @@ -0,0 +1,18 @@ +const assert = require('node:assert'); + +module.exports = defineTest({ + description: 'adds a sourcemap base url', + options: { + output: { + sourcemapBaseUrl: 'https://example.com/a/' + } + }, + test: (code, map, { format }) => { + assert.equal(map.file, `bundle.${format}.js`); + const sourceMappingURL = code.split('\n').slice(-2)[0]; + assert.equal( + sourceMappingURL, + `//# sourceMappingURL=https://example.com/a/bundle.${format}.js.map` + ); + } +}); diff --git a/test/sourcemaps/samples/sourcemap-base-url/main.js b/test/sourcemaps/samples/sourcemap-base-url/main.js new file mode 100644 index 00000000000..5c72ff35124 --- /dev/null +++ b/test/sourcemaps/samples/sourcemap-base-url/main.js @@ -0,0 +1 @@ +console.log( 42 ); diff --git a/test/sourcemaps/samples/sourcemap-file-hashed/_config.js b/test/sourcemaps/samples/sourcemap-file-hashed/_config.js new file mode 100644 index 00000000000..82e9387a8f5 --- /dev/null +++ b/test/sourcemaps/samples/sourcemap-file-hashed/_config.js @@ -0,0 +1,15 @@ +const assert = require('node:assert'); + +module.exports = defineTest({ + description: 'populates file property of sourcemap with final name when using hashes', + options: { + output: { + entryFileNames: '[hash].js', + file: null, + dir: '_actual' + } + }, + test: (code, map, { fileName }) => { + assert.strictEqual(map.file, fileName); + } +}); diff --git a/test/sourcemaps/samples/sourcemap-file-hashed/main.js b/test/sourcemaps/samples/sourcemap-file-hashed/main.js new file mode 100644 index 00000000000..5c72ff35124 --- /dev/null +++ b/test/sourcemaps/samples/sourcemap-file-hashed/main.js @@ -0,0 +1 @@ +console.log( 42 ); diff --git a/test/sourcemaps/samples/sourcemap-file/_config.js b/test/sourcemaps/samples/sourcemap-file/_config.js index 3fce9ed7643..6c34ba18e39 100644 --- a/test/sourcemaps/samples/sourcemap-file/_config.js +++ b/test/sourcemaps/samples/sourcemap-file/_config.js @@ -1,15 +1,18 @@ -const assert = require('assert'); +const assert = require('node:assert'); -module.exports = { +module.exports = defineTest({ description: 'populates file property of sourcemap when plugins are used (#986)', options: { plugins: [ { - transform() {} + name: 'test-plugin', + transform() { + return null; + } } ] }, test: (code, map, profile) => { assert.equal(map.file, `bundle.${profile.format}.js`); } -}; +}); diff --git a/test/sourcemaps/samples/transform-full-source-paths/_config.js b/test/sourcemaps/samples/transform-full-source-paths/_config.js index 611f001bca2..5bb70548512 100644 --- a/test/sourcemaps/samples/transform-full-source-paths/_config.js +++ b/test/sourcemaps/samples/transform-full-source-paths/_config.js @@ -1,7 +1,7 @@ -const path = require('path'); -const assert = require('assert'); +const assert = require('node:assert'); +const path = require('node:path'); -module.exports = { +module.exports = defineTest({ description: 'provides the full source map path when transforming source maps', options: { output: { @@ -14,4 +14,4 @@ module.exports = { test(code, map) { assert.deepEqual(map.sources, [path.resolve(__dirname, 'main.js').replace(/\\/g, '/')]); } -}; +}); diff --git a/test/sourcemaps/samples/transform-low-resolution/_config.js b/test/sourcemaps/samples/transform-low-resolution/_config.js new file mode 100644 index 00000000000..1510874e9d5 --- /dev/null +++ b/test/sourcemaps/samples/transform-low-resolution/_config.js @@ -0,0 +1,51 @@ +const assert = require('node:assert'); +const { encode } = require('@jridgewell/sourcemap-codec'); +const MagicString = require('magic-string').default; +const { SourceMapConsumer } = require('source-map'); +const getLocation = require('../../getLocation'); + +module.exports = defineTest({ + description: 'handles combining low-resolution and high-resolution source-maps when transforming', + options: { + output: { name: 'bundle' }, + plugins: [ + { + name: 'test-plugin1', + transform(code) { + // each entry of each line consist of + // [generatedColumn, sourceIndex, sourceLine, sourceColumn]; + // this mapping only maps the second line to the first with no column + // details + /** @type {import('@jridgewell/sourcemap-codec').SourceMapMappings} */ + const decodedMap = [[], [[0, 0, 0, 0]]]; + return { + code: `console.log('added');\n${code}`, + /** @type {any} */ + map: { mappings: encode(decodedMap) } + }; + } + }, + { + name: 'test-plugin2', + transform(code) { + const s = new MagicString(code); + s.prepend("console.log('second');\n"); + + return { + code: s.toString(), + map: s.generateMap({ hires: true }) + }; + } + } + ] + }, + async test(code, map) { + const smc = await new SourceMapConsumer(map); + + const generatedLoc = getLocation(code, code.indexOf("'baz'")); + const originalLoc = smc.originalPositionFor(generatedLoc); + + assert.strictEqual(originalLoc.line, 1); + assert.strictEqual(originalLoc.column, 0); + } +}); diff --git a/test/sourcemaps/samples/transform-low-resolution/main.js b/test/sourcemaps/samples/transform-low-resolution/main.js new file mode 100644 index 00000000000..e4161efb281 --- /dev/null +++ b/test/sourcemaps/samples/transform-low-resolution/main.js @@ -0,0 +1 @@ +export let foo = 'bar'; foo += 'baz'; diff --git a/test/sourcemaps/samples/transform-source-paths/_config.js b/test/sourcemaps/samples/transform-source-paths/_config.js index 536232d181c..439c29f240c 100644 --- a/test/sourcemaps/samples/transform-source-paths/_config.js +++ b/test/sourcemaps/samples/transform-source-paths/_config.js @@ -1,19 +1,16 @@ -const path = require('path'); -const assert = require('assert'); +const assert = require('node:assert'); +const path = require('node:path'); -module.exports = { +module.exports = defineTest({ description: 'transform sourcemap paths (#2168)', options: { output: { name: 'myModule', file: path.resolve(__dirname, '_actual/bundle.js'), - sourcemapPathTransform: sourcePath => sourcePath.replace( - `..${path.sep}`, - '~/pkg-name/' - ) + sourcemapPathTransform: sourcePath => sourcePath.replace(`..${path.sep}`, '~/pkg-name/') } }, test(code, map) { assert.deepEqual(map.sources, ['~/pkg-name/main.js']); } -}; +}); diff --git a/test/sourcemaps/samples/transform-without-sourcemap-render-chunk/_config.js b/test/sourcemaps/samples/transform-without-sourcemap-render-chunk/_config.js deleted file mode 100644 index ca874293a6a..00000000000 --- a/test/sourcemaps/samples/transform-without-sourcemap-render-chunk/_config.js +++ /dev/null @@ -1,30 +0,0 @@ -module.exports = { - description: 'preserves sourcemap chains when transforming', - options: { - plugins: [ - { - name: 'fake plugin 1', - transform(code) { - return code; - } - }, - { - name: 'fake plugin 2', - transform(code) { - return { code, map: null }; - }, - renderChunk(code) { - return { code, map: null }; - } - } - ] - }, - warnings: [ - { - code: `SOURCEMAP_BROKEN`, - plugin: 'fake plugin 1', - message: `Sourcemap is likely to be incorrect: a plugin (fake plugin 1) was used to transform files, but didn't generate a sourcemap for the transformation. Consult the plugin documentation for help`, - url: `https://rollupjs.org/guide/en/#warning-sourcemap-is-likely-to-be-incorrect` - } - ] -}; diff --git a/test/sourcemaps/samples/transforms/_config.js b/test/sourcemaps/samples/transforms/_config.js index c2a74e867cf..f0d005fc354 100644 --- a/test/sourcemaps/samples/transforms/_config.js +++ b/test/sourcemaps/samples/transforms/_config.js @@ -1,15 +1,16 @@ +const assert = require('node:assert'); const buble = require('buble'); -const MagicString = require('magic-string'); -const assert = require('assert'); -const getLocation = require('../../getLocation'); +const MagicString = require('magic-string').default; const { SourceMapConsumer } = require('source-map'); +const getLocation = require('../../getLocation'); -module.exports = { +module.exports = defineTest({ description: 'preserves sourcemap chains when transforming', options: { plugins: [ { - transform(source, id) { + name: 'test-plugin1', + transform(source) { return buble.transform(source, { transforms: { modules: false } }); @@ -17,7 +18,8 @@ module.exports = { }, { - transform(source, id) { + name: 'test-plugin2', + transform(source) { const s = new MagicString(source); s.append('\nassert.equal( 1 + 1, 2 );\nassert.equal( 2 + 2, 4 );'); @@ -46,4 +48,4 @@ module.exports = { assert.equal(originalLoc.line, 3); assert.equal(originalLoc.column, 8); } -}; +}); diff --git a/test/sourcemaps/samples/untransformed-modules/_config.js b/test/sourcemaps/samples/untransformed-modules/_config.js index d70ac4f1f5d..e4d925debe1 100644 --- a/test/sourcemaps/samples/untransformed-modules/_config.js +++ b/test/sourcemaps/samples/untransformed-modules/_config.js @@ -1,11 +1,12 @@ -const assert = require('assert'); -const MagicString = require('magic-string'); +const assert = require('node:assert'); +const MagicString = require('magic-string').default; -module.exports = { +module.exports = defineTest({ description: 'allows sourcemap chains with some untransformed modules (#404)', options: { plugins: [ { + name: 'test-plugin', transform(code, id) { if (/untransformed-modules\/foo/.test(id)) { const s = new MagicString(code); @@ -24,4 +25,4 @@ module.exports = { test() { assert.ok(true); } -}; +}); diff --git a/test/sourcemaps/samples/warning-with-coarse-sourcemap/_config.js b/test/sourcemaps/samples/warning-with-coarse-sourcemap/_config.js new file mode 100644 index 00000000000..3a2f1372dbd --- /dev/null +++ b/test/sourcemaps/samples/warning-with-coarse-sourcemap/_config.js @@ -0,0 +1,77 @@ +const { encode } = require('@jridgewell/sourcemap-codec'); +const terser = require('terser'); +const path = require('node:path'); +const ID_MAIN = path.join(__dirname, 'main.js'); + +const originalCode = ` +console.log( + this + 2 +) +`; + +module.exports = defineTest({ + description: 'get correct mapping location with coarse sourcemap', + formats: ['es'], + options: { + plugins: [ + { + resolveId() { + return ID_MAIN; + }, + load() { + return { + code: originalCode + }; + } + }, + { + transform(code) { + return { + code, + map: { + mappings: encode([ + [], + [ + [0, 0, 1, 0], + [8, 0, 1, 8] + ], + [ + // coarse segment + [0, 0, 2, 2], + [9, 0, 2, 9] + ], + [[0, 0, 3, 0]], + [] + ]), + sourcesContent: [code] + } + }; + } + }, + { + transform(code) { + return terser.minify(code, { + sourceMap: true + }); + } + } + ] + }, + warnings: [ + { + code: 'THIS_IS_UNDEFINED', + message: + "main.js (3:2): The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten", + url: 'https://rollupjs.org/troubleshooting/#error-this-is-undefined', + id: ID_MAIN, + pos: 12, + loc: { + column: 2, + file: ID_MAIN, + line: 3 + }, + frame: ' 1:\n' + '2: console.log(\n' + '3: this + 2\n' + ' ^\n' + '4: )' + } + ], + async test() {} +}); diff --git a/test/sourcemaps/tsconfig.json b/test/sourcemaps/tsconfig.json new file mode 100644 index 00000000000..22ef5710b77 --- /dev/null +++ b/test/sourcemaps/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": "../tsconfig.base.json", + "include": [ + "**/_config.js", + "./*.js", + "./define.d.ts" + ] +} diff --git a/test/test.js b/test/test.js index 119b13391e1..9d8f2dcf307 100644 --- a/test/test.js +++ b/test/test.js @@ -1,7 +1,7 @@ require('source-map-support').install(); describe('rollup', function () { - this.timeout(30000); + this.timeout(30_000); require('./misc/index.js'); require('./function/index.js'); require('./form/index.js'); diff --git a/test/testHelpers.js b/test/testHelpers.js new file mode 100644 index 00000000000..16073099000 --- /dev/null +++ b/test/testHelpers.js @@ -0,0 +1,541 @@ +/** + * @typedef {import('../src/rollup/types').RollupError} RollupError + * @typedef {import('../src/rollup/types').RollupLog} RollupLog + * @typedef {import('../src/rollup/types').LogLevel} LogLevel + * @typedef {import('../src/rollup/types').Plugin} Plugin + * @typedef {import('./types').TestConfigBase} TestConfigBase + */ + +const assert = require('node:assert'); +const { + closeSync, + fsyncSync, + openSync, + readdirSync, + renameSync, + unlinkSync, + rmSync, + writeFileSync, + writeSync, + existsSync +} = require('node:fs'); +const path = require('node:path'); +const { platform, version } = require('node:process'); +const { Parser } = require('acorn'); +const { importAssertions } = require('acorn-import-assertions'); +const jsx = require('acorn-jsx'); +const fixturify = require('fixturify'); + +if (!globalThis.defineTest) { + globalThis.defineTest = config => config; +} + +/** + * @param {number} ms + * @returns {Promise} + */ +exports.wait = function wait(ms) { + return new Promise(fulfil => { + setTimeout(fulfil, ms); + }); +}; + +/** + * @param {Promise} promise + * @param {number} timeoutMs + * @param {() => unknown} onTimeout + * @return {Promise} + */ +exports.withTimeout = function withTimeout(promise, timeoutMs, onTimeout) { + let timeoutId; + return Promise.race([ + promise.then(() => clearTimeout(timeoutId)), + new Promise((resolve, reject) => { + timeoutId = setTimeout(() => { + try { + onTimeout(); + resolve(); + } catch (error) { + reject(error); + } + }, timeoutMs); + }) + ]); +}; + +function normaliseError(error) { + if (!error) { + throw new Error(`Expected an error but got ${JSON.stringify(error)}`); + } + const clone = { ...error, message: error.message }; + delete clone.stack; + delete clone.toString; + if (clone.watchFiles) { + clone.watchFiles.sort(); + } + if (clone.frame) { + clone.frame = clone.frame.replace(/\s+$/gm, ''); + } + if (clone.cause) { + clone.cause = normaliseError(clone.cause); + } + return clone; +} + +/** + * @param {RollupError} actual + * @param {RollupError} expected + */ +exports.compareError = function compareError(actual, expected) { + actual = normaliseError(actual); + if (expected.frame) { + expected.frame = deindent(expected.frame); + } + assert.deepEqual(actual, expected); + if (actual.stack) { + assert.ok(actual.stack.includes(expected.message)); + } +}; + +/** + * @param {(RollupLog & {level: LogLevel})[]} actual + * @param {(RollupLog & {level: LogLevel})[]} expected + */ +exports.compareLogs = function compareLogs(actual, expected) { + const normalizedActual = actual.map(normaliseError); + const sortedActual = normalizedActual.sort(sortLogs); + try { + assert.deepEqual( + sortedActual, + expected + .map(warning => { + if (warning.frame) { + warning.frame = deindent(warning.frame); + } + return warning; + }) + .sort(sortLogs) + ); + } catch (error) { + console.log('Actual logs:', JSON.stringify(normalizedActual)); + throw error; + } +}; + +/** + * @param {RollupLog} a + * @param {RollupLog} b + */ +function sortLogs(a, b) { + return a.message === b.message ? 0 : a.message < b.message ? -1 : 1; +} + +/** + * @param {string} stringValue + */ +function deindent(stringValue) { + return stringValue.slice(1).replace(/^\t+/gm, '').replace(/\s+$/gm, '').trim(); +} + +exports.deindent = deindent; + +exports.getBundleCode = async function getBundleCode(bundle, { format = 'es' } = {}) { + const { + output: [module] + } = await bundle.generate({ + exports: 'auto', + format + }); + return module.code; +}; + +exports.executeBundle = async function executeBundle(bundle, require) { + const wrapper = new Function( + 'module', + 'exports', + 'require', + await exports.getBundleCode(bundle, { format: 'cjs' }) + ); + const module = { exports: {} }; + wrapper(module, module.exports, require); + return module.exports; +}; + +/** + * @param {Iterable<[string, any]>} entries + * @returns {Record} + */ +exports.getObject = function getObject(entries) { + const object = {}; + for (const [key, value] of entries) { + object[key] = value; + } + return object; +}; + +/** + * @param {Record} modules + * @returns {Plugin} + */ +exports.loader = function loader(modules) { + modules = Object.assign(Object.create(null), modules); + return { + name: 'test-plugin-loader', + resolveId(id) { + return id in modules ? id : null; + }, + load(id) { + return modules[id]; + } + }; +}; + +exports.normaliseOutput = function normaliseOutput(code) { + return code.toString().trim().replace(/\r\n/g, '\n'); +}; + +/** + * @template {TestConfigBase} C + * @param {string} suiteName + * @param {string} samplesDirectory + * @param {(directory: string, config: C) => void} runTest + * @param {() => void | Promise} [onTeardown] + */ +function runTestSuiteWithSamples(suiteName, samplesDirectory, runTest, onTeardown) { + describe(suiteName, () => runSamples(samplesDirectory, runTest, onTeardown)); +} + +// You can run only or skip certain kinds of tests by appending .only or .skip +/** + * @template {TestConfigBase} C + * @param {string} suiteName + * @param {string} samplesDirectory + * @param {(directory: string, config: C) => void} runTest + * @param {() => void | Promise} onTeardown + */ +runTestSuiteWithSamples.only = function (suiteName, samplesDirectory, runTest, onTeardown) { + describe.only(suiteName, () => runSamples(samplesDirectory, runTest, onTeardown)); +}; + +/** + * @param {string} suiteName + */ +runTestSuiteWithSamples.skip = function (suiteName) { + describe.skip(suiteName, () => {}); +}; + +exports.runTestSuiteWithSamples = runTestSuiteWithSamples; + +/** + * @template {TestConfigBase} C + * @param {string} samplesDirectory + * @param {(directory: string, config: C) => void} runTest + * @param {Mocha.Func} onTeardown + */ +function runSamples(samplesDirectory, runTest, onTeardown) { + if (onTeardown) { + afterEach(onTeardown); + } + + for (const fileName of readdirSync(samplesDirectory) + .filter(name => name[0] !== '.') + .sort()) { + runTestsInDirectory(path.join(samplesDirectory, fileName), runTest); + } +} + +/** + * @template {TestConfigBase} C + * @param {string} directory + * @param {(directory: string, config: C) => void} runTest + */ +function runTestsInDirectory(directory, runTest) { + const fileNames = getFileNamesAndRemoveOutput(directory); + if (fileNames.includes('_config.js')) { + loadConfigAndRunTest(directory, runTest); + } else if (fileNames.length === 0) { + console.warn(`Removing empty test directory ${directory}`); + rmSync(directory, { + force: true, + recursive: true + }); + } else { + describe(path.basename(directory), () => { + for (const fileName of fileNames.filter(name => name[0] !== '.').sort()) { + runTestsInDirectory(path.join(directory, fileName), runTest); + } + }); + } +} + +/** + * @param {string} directory + */ +function getFileNamesAndRemoveOutput(directory) { + try { + return readdirSync(directory).filter(fileName => { + if (fileName === '_actual') { + rmSync(path.join(directory, '_actual'), { + force: true, + recursive: true + }); + return false; + } + if (fileName.startsWith('_actual.')) { + unlinkSync(path.join(directory, fileName)); + return false; + } + return true; + }); + } catch (error) { + if (error.code === 'ENOTDIR') { + throw new Error( + `${directory} is not located next to a "_config.js" file but is not a directory or old test output either. Please inspect and consider removing the file.` + ); + } + throw error; + } +} + +exports.getFileNamesAndRemoveOutput = getFileNamesAndRemoveOutput; + +/** + * @template {TestConfigBase} C + * @param {string} directory + * @param {(directory: string, config: C) => void} runTest + */ +function loadConfigAndRunTest(directory, runTest) { + const configFile = path.join(directory, '_config.js'); + const config = require(configFile); + if (!config || !config.description) { + throw new Error(`Found invalid config without description: ${configFile}`); + } + if ( + (!config.skipIfWindows || platform !== 'win32') && + (!config.onlyWindows || platform === 'win32') && + (!config.minNodeVersion || config.minNodeVersion <= Number(/^v(\d+)/.exec(version)[1])) + ) { + runTest(directory, config); + } +} + +/** + * @param {string} actualDirectory + * @param {string} expectedDirectory + */ +exports.assertDirectoriesAreEqual = function assertDirectoriesAreEqual( + actualDirectory, + expectedDirectory +) { + const actualFiles = fixturify.readSync(actualDirectory); + + let expectedFiles; + try { + expectedFiles = fixturify.readSync(expectedDirectory); + } catch { + expectedFiles = []; + } + assertFilesAreEqual(actualFiles, expectedFiles); +}; + +function assertFilesAreEqual(actualFiles, expectedFiles, directories = []) { + for (const fileName of Object.keys({ ...actualFiles, ...expectedFiles })) { + const pathSegments = [...directories, fileName]; + if (typeof actualFiles[fileName] === 'object' && typeof expectedFiles[fileName] === 'object') { + assertFilesAreEqual(actualFiles[fileName], expectedFiles[fileName], pathSegments); + continue; + } + + const shortName = pathSegments.join('/'); + assert.strictEqual( + `${shortName}: ${actualFiles[fileName]}`, + `${shortName}: ${expectedFiles[fileName]}` + ); + } +} + +exports.assertFilesAreEqual = assertFilesAreEqual; + +/** + * @param {string} actual + * @param {string} expected + */ +exports.assertIncludes = function assertIncludes(actual, expected) { + try { + assert.ok( + actual.includes(expected), + `${JSON.stringify(actual)}\nshould include\n${JSON.stringify(expected)}` + ); + } catch (error) { + error.actual = actual; + error.expected = expected; + throw error; + } +}; + +/** + * @param {string} actual + * @param {string} expected + */ +exports.assertDoesNotInclude = function assertDoesNotInclude(actual, expected) { + try { + assert.ok( + !actual.includes(expected), + `${JSON.stringify(actual)}\nshould not include\n${JSON.stringify(expected)}` + ); + } catch (error) { + error.actual = actual; + error.expected = expected; + throw error; + } +}; + +/** + * Workaround a race condition in fs.writeFileSync that temporarily creates + * an empty file for a brief moment which may be read by rollup watch - even + * if the content being overwritten is identical. + * + * @param {string} filePath + * @param {string} contents + */ +function atomicWriteFileSync(filePath, contents) { + const stagingPath = filePath + '_'; + writeFileSync(stagingPath, contents); + renameSync(stagingPath, filePath); +} + +exports.atomicWriteFileSync = atomicWriteFileSync; + +/** + * It appears that on macOS, it sometimes takes long for the file system to update + * + * @param {string} filePath + * @param {string} contents + */ +exports.writeAndSync = function writeAndSync(filePath, contents) { + const file = openSync(filePath, 'w'); + writeSync(file, contents); + fsyncSync(file); + closeSync(file); +}; + +/** + * Sometimes, watchers on macOS do not seem to fire. In those cases, it helps + * to write the same content again. This function returns a callback to stop + * further updates. + * + * @param {string} filePath + * @param {string} contents + */ +exports.writeAndRetry = function writeAndRetry(filePath, contents) { + let retries = 0; + let updateRetryTimeout; + + const writeFile = () => { + if (retries > 0) { + console.error(`RETRIED writeFile (${retries})`); + } + retries++; + atomicWriteFileSync(filePath, contents); + updateRetryTimeout = setTimeout(writeFile, 1000); + }; + + writeFile(); + return () => clearTimeout(updateRetryTimeout); +}; + +/** + * @param {any} object + * @param {any} replaced + */ +exports.replaceDirectoryInStringifiedObject = function replaceDirectoryInStringifiedObject( + object, + replaced +) { + return JSON.stringify(object, null, 2).replace( + new RegExp( + JSON.stringify(JSON.stringify(replaced).slice(1, -1)).slice(1, -1) + '[/\\\\]*', + 'g' + ), + '**/' + ); +}; + +/** @type {boolean} */ +exports.hasEsBuild = existsSync(path.join(__dirname, '../dist/es')); + +const acornParser = Parser.extend(importAssertions, jsx()); + +exports.verifyAstPlugin = { + name: 'verify-ast', + moduleParsed: ({ ast, code }) => { + const acornAst = acornParser.parse(code, { ecmaVersion: 'latest', sourceType: 'module' }); + assert.deepStrictEqual( + JSON.parse(JSON.stringify(ast, replaceStringifyValues), reviveStringifyValues), + JSON.parse(JSON.stringify(acornAst, replaceStringifyValues), reviveStringifyValues) + ); + } +}; + +exports.getRandomElement = function getRandomElement(array) { + return array[Math.floor(Math.random() * array.length)]; +}; + +exports.shuffle = function shuffle(array) { + const shuffled = array.slice(); + for (let shuffledIndex = shuffled.length - 1; shuffledIndex > 0; shuffledIndex--) { + const replacedIndex = Math.floor(Math.random() * (shuffledIndex + 1)); + [shuffled[shuffledIndex], shuffled[replacedIndex]] = [ + shuffled[replacedIndex], + shuffled[shuffledIndex] + ]; + } + return shuffled; +}; + +const replaceStringifyValues = (key, value) => { + switch (value?.type) { + case 'ImportDeclaration': + case 'ExportNamedDeclaration': + case 'ExportAllDeclaration': { + const { attributes, ...nonAttributesProperties } = value; + return { + ...nonAttributesProperties, + ...(attributes?.length > 0 ? { assertions: attributes } : {}) + }; + } + case 'ImportExpression': { + const { options, ...nonOptionsProperties } = value; + return { ...nonOptionsProperties, ...(options ? { arguments: [options] } : {}) }; + } + case 'ClassDeclaration': + case 'ClassExpression': + case 'PropertyDefinition': + case 'MethodDefinition': { + const { decorators, ...rest } = value; + return rest; + } + case 'JSXText': { + // raw text is encoded differently in acorn + const { raw, ...nonRawProperties } = value; + return nonRawProperties; + } + } + + return key[0] === '_' + ? undefined + : typeof value == 'bigint' + ? `~BigInt${value.toString()}` + : value instanceof RegExp + ? `~RegExp${JSON.stringify({ flags: value.flags, source: value.source })}` + : value; +}; + +const reviveStringifyValues = (_, value) => + typeof value === 'string' + ? value.startsWith('~BigInt') + ? BigInt(value.slice(7)) + : value.startsWith('~RegExp') + ? new RegExp(JSON.parse(value.slice(7)).source, JSON.parse(value.slice(7)).flags) + : value + : value; diff --git a/test/tsconfig.base.json b/test/tsconfig.base.json new file mode 100644 index 00000000000..4d351d3b743 --- /dev/null +++ b/test/tsconfig.base.json @@ -0,0 +1,15 @@ +{ + "compilerOptions": { + // enable this to capture type errors, or add @ts-check to the top of the file + // "checkJs": true, + "allowJs": true, + "composite": true, + "target": "esnext", + "module": "NodeNext", + "noEmit": true, + "lib": ["esnext"], + "esModuleInterop": true, + "moduleResolution": "NodeNext", + "types": ["node", "mocha"] + } +} diff --git a/test/tsconfig.json b/test/tsconfig.json new file mode 100644 index 00000000000..5462ae24a66 --- /dev/null +++ b/test/tsconfig.json @@ -0,0 +1,29 @@ +{ + "extends": "./tsconfig.base.json", + "compilerOptions": { + "checkJs": true + }, + "include": [ + "./testHelpers.js" + ], + "references": [ + { + "path": "./browser" + }, + { + "path": "./chunking-form" + }, + { + "path": "./file-hashes" + }, + { + "path": "./form" + }, + { + "path": "./function" + }, + { + "path": "./sourcemaps" + } + ] +} diff --git a/test/types.d.ts b/test/types.d.ts new file mode 100644 index 00000000000..6fd16210783 --- /dev/null +++ b/test/types.d.ts @@ -0,0 +1,281 @@ +import type { SourceMap } from 'magic-string'; +import type { RollupBuild, RollupError, RollupLog, RollupOptions } from '../src/rollup/types'; + +export interface TestConfigBase { + /** + * Description of the test. Determines the name of the test in the test + * runner. + */ + description: string; + /** + * Only run this test if the major Node version is high enough. + */ + minNodeVersion?: number; + /** + * Only run this test on Windows. + */ + onlyWindows?: boolean; + /** + * Skip this test. + */ + skip?: boolean; + /** + * Do not run this test on Windows. + */ + skipIfWindows?: boolean; + /** + * Only run this test. Should never be committed. + */ + solo?: boolean; +} + +export interface TestConfigBrowser extends TestConfigBase { + /** + * Expected error when running rollup.rollup() + */ + error?: RollupError; + /** + * Expected warning codes. Any of these warnings will not cause the test to + * fail. + */ + expectedWarnings?: string[]; + /** + * Expected error when running bundle.generate(). + */ + generateError?: RollupError; + /** + * Rollup options for bundling. + */ + options?: RollupOptions; +} + +export interface TestConfigChunkingForm extends TestConfigBase { + /** + * Called after the test is run. + */ + after?: () => void; + /** + * Called before the test is run. + */ + before?: () => void; + /** + * Expected warning codes. Any of these warnings will not cause the test to + * fail. + */ + expectedWarnings?: string[]; + /** + * Output formats. + */ + formats?: string[]; + /** + * Assert the expected logs. + */ + logs?: RollupLog[]; + /** + * The directory to bundle the code in. + */ + nestedDir?: string; + /** + * Rollup options for bundling. + */ + options?: RollupOptions; + /** + * Execute the AMD module. + */ + runAmd?: + | boolean + | { + exports?: (exportObject: any) => void | Promise; + }; +} + +export interface TestConfigCli extends TestConfigBase { + /** + * Assert the stderr stream, return true to abort the test. + */ + abortOnStderr?: (data: string) => boolean | void | Promise; + /** + * Called after the test is run. + */ + after?: (error: Error | null, stdout: string, stderr: string) => void | Promise; + /** + * Called before the test is run. + */ + before?: () => void | Promise; + /** + * Run command in a shell. + * Will be overridden by "spawnArgs" if that is used. + */ + command?: string; + /** + * Run rollup as a child process with the given arguments. + */ + spawnArgs?: string[]; + /** + * Instead of Rollup, run this Node script when spawning a child process. + */ + spawnScript?: string; + cwd?: string; + /** + * Environment variables to set for the test. + */ + env?: Record; + /** + * Test the expected error. Assertions about the test output will only + * be performed afterward if you return "true" or do not supply this option. + */ + error?: (error: Error) => boolean | void; + /** + * Execute the bundled code. + */ + execute?: boolean; + /** + * Run assertions against the exports of the bundle after executing it. + */ + exports?: (exportObject: any) => void | Promise; + repeat?: number; + /** + * Run assertions against the generated code when bundling to stdout. + */ + result?: (code: string) => void; + retry?: boolean; + /** + * Display generated output in console. + */ + show?: boolean; + /** + * Assert the stderr of the build. Assertions about the test output will only + * be performed afterward if you return "true" or do not supply this option. + */ + stderr?: (stderr: string) => boolean | undefined; + /** + * Run assertions after the command has finished. + */ + test?: () => void; +} + +export interface TestConfigFileHash extends TestConfigBase { + options1: RollupOptions; + options2: RollupOptions; +} + +export interface TestConfigForm extends TestConfigBase { + /** + * Called after the test is run. + */ + after?: () => void | Promise; + /** + * Called before the test is run. + */ + before?: () => void | Promise; + /** + * Expected warning codes. Any of these warnings will not cause the test to + * fail. + */ + expectedWarnings?: string[]; + /** + * Output formats to test. + */ + formats?: string[]; + /** + * Assert the expected logs. + */ + logs?: RollupLog[]; + /** + * Rollup options for bundling. + */ + options?: RollupOptions; + /** + * Set to "false" to disable shuffling of output formats. + */ + shuffleFormats?: boolean; + /** + * Verify that the AST returned by SWC is the same as the one returned by + * Acorn. The default behavior is to verify. + */ + verifyAst?: boolean; +} + +export interface TestConfigFunction extends TestConfigBase { + /** + * Called after the test is run. + */ + after?: () => void | Promise; + /** + * Called before the test is run. + */ + before?: () => void | Promise; + /** + * Make assertions against the generated Rollup output object. + */ + bundle?: (bundle: RollupBuild) => void | Promise; + /** + * Make assertions against the generated code. + */ + code?: (code: string | Record) => void; + /** + * Injected global variables and functions. You can also use this to mock + * "require" calls. + */ + context?: Record; + /** + * Expected error when running rollup.rollup() + */ + error?: RollupError; + /** + * Assetions for the exports of the bundle. + */ + exports?: (exportObject: any) => void | Promise; + /** + * Expected error when running bundle.generate(). + */ + generateError?: RollupError; + /** + * Assert the expected logs. + */ + logs?: RollupLog[]; + /** + * Rollup options for bundling. + */ + options?: RollupOptions; + /** + * Make assertions against an expected runtime error. + */ + runtimeError?: (error: Error) => void; + /** + * Display generated output in console. + */ + show?: boolean; + /** + * Make assertions on the expected warnings. + */ + warnings?: RollupError[] | ((warnings: RollupError[]) => boolean | void); + /** + * Verify that the AST returned by SWC is the same as the one returned by + * Acorn. The default behavior is to verify. + */ + verifyAst?: boolean; +} + +export interface TestConfigSourcemap extends TestConfigBase { + /** + * Output formats to test. + */ + formats?: string[]; + /** + * Rollup options for bundling. + */ + options?: RollupOptions; + /** + * Generate the bundle and run assertions. + */ + test: ( + code: string, + map: SourceMap, + options: { fileName: string; format: string } + ) => void | Promise; + /** + * List expected warnings. + */ + warnings?: RollupError[]; +} diff --git a/test/typescript/index.ts b/test/typescript/index.ts index 8d7f18c1188..9b31f982de3 100644 --- a/test/typescript/index.ts +++ b/test/typescript/index.ts @@ -1,21 +1,92 @@ -import * as rollup from './dist/rollup'; +import type * as rollup from './dist/rollup'; // Plugin API interface Options { extensions?: string | string[]; } + const plugin: rollup.PluginImpl = (options = {}) => { - // tslint:disable-next-line:no-unused-variable - const extensions = options.extensions || ['.js']; - return { name: 'my-plugin' }; + const _extensions = options.extensions || ['.js']; + return { + name: 'my-plugin', + resolveId: { + handler(source, _importer, _options) { + // @ts-expect-error source is typed as string + const _s: number = source; + } + } + }; }; plugin(); plugin({ extensions: ['.js', 'json'] }); -const amdOutputOptions: rollup.OutputOptions['amd'][] = [ +const _pluginHooks: rollup.Plugin = { + buildStart: { + handler() {}, + sequential: true + }, + async load(id) { + // @ts-expect-error id is typed as string + const _index: number = id; + await this.resolve('rollup'); + }, + name: 'test', + renderChunk(_code, { modules }) { + for (const id in modules) { + // @ts-expect-error Cannot assign to 'code' because it is a read-only property + modules[id].code += '\n'; + } + }, + resolveId: { + async handler(source, _importer, _options) { + await this.resolve('rollup'); + // @ts-expect-error source is typed as string + const _s: number = source; + }, + // @ts-expect-error sequential is only supported for parallel hooks + sequential: true + } +}; + +const _pluginHookFilters: rollup.Plugin = { + load: { + filter: { + // @ts-expect-error 'code' filter is not supported for load + code: 'bar', + id: 'foo' + }, + handler(_source) {} + }, + name: 'test', + resolveId: { + filter: { + // @ts-expect-error 'code' filter is not supported for resolveId + code: 'bar', + id: /foo/ + }, + handler(_source) {} + }, + transform: { + filter: { + code: 'bar', + id: 'foo' + }, + handler(_code) {} + } +}; + +const _amdOutputOptions: rollup.OutputOptions['amd'][] = [ {}, { + autoId: undefined, + id: undefined + }, + { + id: 'a' + }, + { + autoId: undefined, id: 'a' }, { @@ -29,28 +100,31 @@ const amdOutputOptions: rollup.OutputOptions['amd'][] = [ { autoId: true }, + { + autoId: true, + basePath: undefined, + id: undefined + }, { autoId: false }, { - // @ts-expect-error autoId: false, + // @ts-expect-error for "basePath", "autoId" needs to be true basePath: '', - // @ts-expect-error id: 'a' }, { - // @ts-expect-error autoId: true, - // @ts-expect-error + // @ts-expect-error cannot combine "id" and "autoId" id: 'a' }, { + // @ts-expect-error cannot combine "id" and "basePath" basePath: '', - // @ts-expect-error id: 'a' }, - // @ts-expect-error + // @ts-expect-error needs "autoId" for "basePath" { basePath: '' } diff --git a/test/typescript/tsconfig.json b/test/typescript/tsconfig.json index b4054d39389..3e2a6b926ff 100644 --- a/test/typescript/tsconfig.json +++ b/test/typescript/tsconfig.json @@ -3,7 +3,7 @@ "noEmit": true, "strict": true, "pretty": true, - "lib": ["es2015"], + "lib": ["ESNext"], "types": [] }, "include": ["./dist", "./typings"], diff --git a/test/utils.js b/test/utils.js deleted file mode 100644 index f807df54e30..00000000000 --- a/test/utils.js +++ /dev/null @@ -1,230 +0,0 @@ -const assert = require('assert'); -const path = require('path'); -const sander = require('sander'); -const fixturify = require('fixturify'); - -exports.compareError = compareError; -exports.compareWarnings = compareWarnings; -exports.deindent = deindent; -exports.executeBundle = executeBundle; -exports.getObject = getObject; -exports.loader = loader; -exports.normaliseOutput = normaliseOutput; -exports.runTestSuiteWithSamples = runTestSuiteWithSamples; -exports.assertDirectoriesAreEqual = assertDirectoriesAreEqual; -exports.assertFilesAreEqual = assertFilesAreEqual; -exports.assertIncludes = assertIncludes; - -function normaliseError(error) { - delete error.stack; - delete error.toString; - return Object.assign({}, error, { - message: error.message - }); -} - -function compareError(actual, expected) { - actual = normaliseError(actual); - - if (actual.parserError) { - actual.parserError = normaliseError(actual.parserError); - } - - if (actual.frame) { - actual.frame = actual.frame.replace(/\s+$/gm, ''); - } - - if (expected.frame) { - expected.frame = deindent(expected.frame); - } - - assert.deepEqual(actual, expected); -} - -function compareWarnings(actual, expected) { - assert.deepEqual( - actual.map(warning => { - const clone = Object.assign({}, warning); - delete clone.toString; - - if (clone.frame) { - clone.frame = clone.frame.replace(/\s+$/gm, ''); - } - - return clone; - }), - expected.map(warning => { - if (warning.frame) { - warning.frame = deindent(warning.frame); - } - return warning; - }) - ); -} - -function deindent(str) { - return str.slice(1).replace(/^\t+/gm, '').replace(/\s+$/gm, '').trim(); -} - -async function executeBundle(bundle, require) { - const { - output: [cjs] - } = await bundle.generate({ - exports: 'auto', - format: 'cjs' - }); - const wrapper = new Function('module', 'exports', 'require', cjs.code); - const module = { exports: {} }; - wrapper(module, module.exports, require); - return module.exports; -} - -function getObject(entries) { - const object = {}; - for (const [key, value] of entries) { - object[key] = value; - } - return object; -} - -function loadConfig(configFile) { - try { - return require(configFile); - } catch (err) { - if (err.code === 'MODULE_NOT_FOUND') { - const dir = path.dirname(configFile); - removeOldTest(dir); - } else { - throw new Error(`Failed to load ${configFile}: ${err.message}`); - } - } -} - -function removeOldOutput(dir) { - if (sander.existsSync(path.join(dir, '_actual'))) { - sander.rimrafSync(path.join(dir, '_actual')); - } - if (sander.existsSync(path.join(dir, '_actual.js'))) { - sander.unlinkSync(path.join(dir, '_actual.js')); - } -} - -function removeOldTest(dir) { - removeOldOutput(dir); - console.warn( - `Test configuration in ${dir} not found.\nTrying to clean up no longer existing test...` - ); - sander.rmdirSync(dir); - console.warn('Directory removed.'); -} - -function loader(modules) { - modules = Object.assign(Object.create(null), modules); - return { - resolveId(id) { - return id in modules ? id : null; - }, - - load(id) { - return modules[id]; - } - }; -} - -function normaliseOutput(code) { - return code.toString().trim().replace(/\r\n/g, '\n'); -} - -function runTestSuiteWithSamples(suiteName, samplesDir, runTest, onTeardown) { - describe(suiteName, () => runSamples(samplesDir, runTest, onTeardown)); -} - -// You can run only or skip certain kinds of tests be appending .only or .skip -runTestSuiteWithSamples.only = function (suiteName, samplesDir, runTest, onTeardown) { - describe.only(suiteName, () => runSamples(samplesDir, runTest, onTeardown)); -}; - -runTestSuiteWithSamples.skip = function (suiteName) { - describe.skip(suiteName, () => {}); -}; - -function runSamples(samplesDir, runTest, onTeardown) { - if (onTeardown) { - afterEach(onTeardown); - } - sander - .readdirSync(samplesDir) - .filter(name => name[0] !== '.') - .sort() - .forEach(fileName => runTestsInDir(samplesDir + '/' + fileName, runTest)); -} - -function runTestsInDir(dir, runTest) { - const fileNames = sander.readdirSync(dir); - - if (fileNames.indexOf('_config.js') >= 0) { - removeOldOutput(dir); - loadConfigAndRunTest(dir, runTest); - } else if (fileNames.indexOf('_actual') >= 0 || fileNames.indexOf('_actual.js') >= 0) { - removeOldOutput(dir); - removeOldTest(dir); - } else { - describe(path.basename(dir), () => { - fileNames - .filter(name => name[0] !== '.') - .sort() - .forEach(fileName => runTestsInDir(dir + '/' + fileName, runTest)); - }); - } -} - -function loadConfigAndRunTest(dir, runTest) { - const config = loadConfig(dir + '/_config.js'); - if ( - config && - (!config.skipIfWindows || process.platform !== 'win32') && - (!config.onlyWindows || process.platform === 'win32') && - (!config.minNodeVersion || config.minNodeVersion <= Number(/^v(\d+)/.exec(process.version)[1])) - ) - runTest(dir, config); -} - -function assertDirectoriesAreEqual(actualDir, expectedDir) { - const actualFiles = fixturify.readSync(actualDir); - - let expectedFiles; - try { - expectedFiles = fixturify.readSync(expectedDir); - } catch (err) { - expectedFiles = []; - } - assertFilesAreEqual(actualFiles, expectedFiles); -} - -function assertFilesAreEqual(actualFiles, expectedFiles, dirs = []) { - Object.keys(Object.assign({}, actualFiles, expectedFiles)).forEach(fileName => { - const pathSegments = dirs.concat(fileName); - if (typeof actualFiles[fileName] === 'object' && typeof expectedFiles[fileName] === 'object') { - return assertFilesAreEqual(actualFiles[fileName], expectedFiles[fileName], pathSegments); - } - - const shortName = pathSegments.join('/'); - assert.strictEqual( - `${shortName}: ${actualFiles[fileName]}`, - `${shortName}: ${expectedFiles[fileName]}` - ); - }); -} - -function assertIncludes(actual, expected) { - try { - assert.ok( - actual.includes(expected), - `${JSON.stringify(actual)}\nincludes\n${JSON.stringify(expected)}` - ); - } catch (err) { - err.actual = actual; - err.expected = expected; - throw err; - } -} diff --git a/test/watch/index.js b/test/watch/index.js index f7d9124fb52..168edf7b6f1 100644 --- a/test/watch/index.js +++ b/test/watch/index.js @@ -1,196 +1,207 @@ -const assert = require('assert'); -const path = require('path'); -const sander = require('sander'); +const assert = require('node:assert'); +const { existsSync, readdirSync, readFileSync, rmSync, unlinkSync } = require('node:fs'); +const { rm, unlink, writeFile, mkdir } = require('node:fs/promises'); +const path = require('node:path'); +const { hrtime } = require('node:process'); +const { copy } = require('fs-extra'); +/** + * @type {import("../../src/rollup/types")} Rollup + */ const rollup = require('../../dist/rollup'); +const { atomicWriteFileSync, wait, withTimeout } = require('../testHelpers'); -const cwd = process.cwd(); +const SAMPLES_DIR = path.join(__dirname, 'samples'); +const TEMP_DIR = path.join(__dirname, '../_tmp'); +const INPUT_DIR = path.join(TEMP_DIR, 'input'); +const ENTRY_FILE = path.join(INPUT_DIR, 'main.js'); +const OUTPUT_DIR = path.join(TEMP_DIR, 'output'); +const BUNDLE_FILE = path.join(OUTPUT_DIR, 'bundle.js'); -function wait(ms) { - return new Promise(fulfil => { - setTimeout(fulfil, ms); - }); -} - -describe('rollup.watch', () => { +describe('rollup.watch', function () { + this.timeout(40_000); let watcher; - beforeEach(() => { - process.chdir(cwd); - return sander.rimraf('test/_tmp'); + beforeEach(async () => { + process.chdir(__dirname); + await rm(TEMP_DIR, { + force: true, + recursive: true + }); + await mkdir(INPUT_DIR, { recursive: true }); + process.chdir(INPUT_DIR); }); - afterEach(() => { + afterEach(async () => { if (watcher) { watcher.close(); watcher = null; } }); - function run(file) { - const resolved = require.resolve(file); - delete require.cache[resolved]; - return require(resolved); - } - - function sequence(watcher, events, timeout = 300) { - return new Promise((fulfil, reject) => { - function go(event) { - const next = events.shift(); + it('watches a file and triggers reruns if necessary', async () => { + let triggerRestart = false; - if (!next) { - watcher.close(); - fulfil(); - } else if (typeof next === 'string') { - watcher.once('event', event => { - if (event.code !== next) { - watcher.close(); - if (event.code === 'ERROR') console.log(event.error); - reject(new Error(`Expected ${next} event, got ${event.code}`)); - } else { - go(event); - } - }); - } else { - Promise.resolve() - .then(() => wait(timeout)) // gah, this appears to be necessary to fix random errors - .then(() => next(event)) - .then(go) - .catch(error => { - watcher.close(); - reject(error); - }); + await copy(path.join(SAMPLES_DIR, 'basic'), INPUT_DIR); + watcher = rollup.watch({ + input: ENTRY_FILE, + plugins: { + name: 'test-plugin', + options() { + assert.strictEqual(this.meta.watchMode, true, 'watchMode in options'); + }, + async transform(code) { + assert.strictEqual(this.meta.watchMode, true, 'watchMode in transform'); + if (triggerRestart) { + triggerRestart = false; + await wait(100); + atomicWriteFileSync(ENTRY_FILE, 'export default 44;'); + await wait(100); + return code; + } } + }, + output: { + file: BUNDLE_FILE, + format: 'cjs', + exports: 'auto' } + }); + return sequence(watcher, [ + 'START', + 'BUNDLE_START', + 'BUNDLE_END', + 'END', + () => { + assert.strictEqual(run(BUNDLE_FILE), 42); + triggerRestart = true; + atomicWriteFileSync(ENTRY_FILE, 'export default 43;'); + }, + 'START', + 'BUNDLE_START', + 'BUNDLE_END', + 'END', + 'START', + 'BUNDLE_START', + 'BUNDLE_END', + 'END', + () => { + assert.strictEqual(run(BUNDLE_FILE), 44); + } + ]); + }); - go(); - }).then(() => wait(100)); - } - - function getTimeDiffInMs(previous) { - const [seconds, nanoseconds] = process.hrtime(previous); - return seconds * 1e3 + nanoseconds / 1e6; - } - - it('watches a file and triggers reruns if necessary', () => { - let triggerRestart = false; + it('waits for event listeners', async () => { + let run = 0; + const events = new Set(); - return sander - .copydir('test/watch/samples/basic') - .to('test/_tmp/input') - .then(() => { - watcher = rollup.watch({ - input: 'test/_tmp/input/main.js', - plugins: { - options(options) { - assert.strictEqual(this.meta.watchMode, true, 'watchMode in options'); - }, - transform(code) { - assert.strictEqual(this.meta.watchMode, true, 'watchMode in transform'); - if (triggerRestart) { - triggerRestart = false; - return wait(100) - .then(() => sander.writeFileSync('test/_tmp/input/main.js', 'export default 44;')) - .then(() => wait(100)) - .then(() => code); - } - } - }, - output: { - file: 'test/_tmp/output/bundle.js', - format: 'cjs', - exports: 'auto' + await copy(path.join(SAMPLES_DIR, 'basic'), INPUT_DIR); + watcher = rollup.watch({ + input: ENTRY_FILE, + plugins: { + async writeBundle() { + if (run++ === 0) { + await wait(100); + atomicWriteFileSync(ENTRY_FILE, 'export default 48;'); + await wait(100); } - }); - - return sequence(watcher, [ - 'START', - 'BUNDLE_START', - 'BUNDLE_END', - 'END', - () => { - assert.strictEqual(run('../_tmp/output/bundle.js'), 42); - triggerRestart = true; - sander.writeFileSync('test/_tmp/input/main.js', 'export default 43;'); - }, - 'START', - 'BUNDLE_START', - 'BUNDLE_END', - 'END', - 'START', - 'BUNDLE_START', - 'BUNDLE_END', - 'END', - () => { - assert.strictEqual(run('../_tmp/output/bundle.js'), 44); + if (run === 2) { + watcher.close(); } - ]); - }); + } + }, + output: { + file: BUNDLE_FILE, + format: 'cjs', + exports: 'auto' + } + }); + await new Promise((resolve, reject) => { + let currentEvent = null; + const handleEvent = async (...parameters) => { + events.add(parameters[0]?.code); + if (currentEvent) { + watcher.close(); + return reject( + new Error( + `Event ${JSON.stringify(parameters)} was emitted while handling ${JSON.stringify( + currentEvent + )}.` + ) + ); + } + currentEvent = parameters; + await wait(100); + currentEvent = null; + }; + // This should work but should not have an effect + watcher.off('event', handleEvent); + watcher.on('event', handleEvent); + watcher.on('change', handleEvent); + watcher.on('restart', handleEvent); + watcher.on('close', resolve); + }); + assert.deepStrictEqual([...events], ['START', 'BUNDLE_START', 'BUNDLE_END', 'END', undefined]); }); - it('does not fail for virtual files', () => { - return sander - .copydir('test/watch/samples/basic') - .to('test/_tmp/input') - .then(() => { - watcher = rollup.watch({ - input: 'test/_tmp/input/main.js', - plugins: { - resolveId(id) { - if (id === 'virtual') { - return id; - } - }, - load(id) { - if (id === 'virtual') { - return `export const value = 42;`; - } - } - }, - output: { - file: 'test/_tmp/output/bundle.js', - format: 'cjs', - exports: 'auto' + it('does not fail for virtual files', async () => { + await copy(path.join(SAMPLES_DIR, 'basic'), INPUT_DIR); + watcher = rollup.watch({ + input: ENTRY_FILE, + plugins: { + resolveId(id) { + if (id === 'virtual') { + return id; } - }); - - return sequence(watcher, [ - 'START', - 'BUNDLE_START', - 'BUNDLE_END', - 'END', - () => { - assert.strictEqual(run('../_tmp/output/bundle.js'), 42); - sander.writeFileSync( - 'test/_tmp/input/main.js', - "import {value} from 'virtual';\nexport default value + 1;" - ); - }, - 'START', - 'BUNDLE_START', - 'BUNDLE_END', - 'END', - () => { - assert.strictEqual(run('../_tmp/output/bundle.js'), 43); + }, + load(id) { + if (id === 'virtual') { + return `export const value = 42;`; } - ]); - }); + } + }, + output: { + file: BUNDLE_FILE, + format: 'cjs', + exports: 'auto' + } + }); + return sequence(watcher, [ + 'START', + 'BUNDLE_START', + 'BUNDLE_END', + 'END', + () => { + assert.strictEqual(run(BUNDLE_FILE), 42); + atomicWriteFileSync( + ENTRY_FILE, + "import {value} from 'virtual';\nexport default value + 1;" + ); + }, + 'START', + 'BUNDLE_START', + 'BUNDLE_END', + 'END', + () => { + assert.strictEqual(run(BUNDLE_FILE), 43); + } + ]); }); it('passes file events to the watchChange plugin hook once for each change', async () => { let watchChangeCnt = 0; - await sander.copydir('test/watch/samples/basic').to('test/_tmp/input'); + await copy(path.join(SAMPLES_DIR, 'basic'), INPUT_DIR); await wait(100); watcher = rollup.watch({ - input: 'test/_tmp/input/main.js', + input: ENTRY_FILE, output: { - file: 'test/_tmp/output/bundle.js', + file: BUNDLE_FILE, format: 'cjs', exports: 'auto' }, plugins: { watchChange(id) { watchChangeCnt++; - assert.strictEqual(id, path.resolve('test/_tmp/input/main.js')); + assert.strictEqual(id, ENTRY_FILE); } } }); @@ -202,53 +213,56 @@ describe('rollup.watch', () => { 'END', () => { watchChangeCnt = 0; - assert.strictEqual(run('../_tmp/output/bundle.js'), 42); - sander.writeFileSync('test/_tmp/input/main.js', 'export default 43;'); + assert.strictEqual(run(BUNDLE_FILE), 42); + atomicWriteFileSync(ENTRY_FILE, 'export default 43;'); }, 'START', 'BUNDLE_START', 'BUNDLE_END', 'END', () => { - assert.strictEqual(run('../_tmp/output/bundle.js'), 43); + assert.strictEqual(run(BUNDLE_FILE), 43); assert.strictEqual(watchChangeCnt, 1); - sander.writeFileSync('test/_tmp/input/main.js', 'export default 43;'); + atomicWriteFileSync(ENTRY_FILE, 'export default 43;'); }, 'START', 'BUNDLE_START', 'BUNDLE_END', 'END', () => { - assert.strictEqual(run('../_tmp/output/bundle.js'), 43); + assert.strictEqual(run(BUNDLE_FILE), 43); assert.strictEqual(watchChangeCnt, 2); - sander.writeFileSync('test/_tmp/input/main.js', 'export default 43;'); + atomicWriteFileSync(ENTRY_FILE, 'export default 43;'); }, 'START', 'BUNDLE_START', 'BUNDLE_END', 'END', () => { - assert.strictEqual(run('../_tmp/output/bundle.js'), 43); + assert.strictEqual(run(BUNDLE_FILE), 43); assert.strictEqual(watchChangeCnt, 3); } ]); }); it('passes change parameter to the watchChange plugin hook', async () => { - const WATCHED_ID = path.resolve('test/_tmp/input/watched'); + const WATCHED_ID = path.join(INPUT_DIR, 'watched'); const events = []; let ids; - const expectedIds = [WATCHED_ID, path.resolve('test/_tmp/input/main.js')]; - await sander.copydir('test/watch/samples/watch-files').to('test/_tmp/input'); - await sander.unlink(WATCHED_ID); + const expectedIds = [WATCHED_ID, ENTRY_FILE]; + await copy(path.join(SAMPLES_DIR, 'watch-files'), INPUT_DIR); + await unlink(WATCHED_ID); await wait(100); watcher = rollup.watch({ - input: 'test/_tmp/input/main.js', + input: ENTRY_FILE, output: { - file: 'test/_tmp/output/bundle.js', + file: BUNDLE_FILE, format: 'cjs', exports: 'auto' }, + watch: { + buildDelay: 300 + }, plugins: { buildStart() { this.addWatchFile(WATCHED_ID); @@ -269,37 +283,37 @@ describe('rollup.watch', () => { 'BUNDLE_END', 'END', () => { - assert.strictEqual(run('../_tmp/output/bundle.js'), 42); + assert.strictEqual(run(BUNDLE_FILE), 42); assert.deepStrictEqual(events, []); assert.deepStrictEqual(ids, expectedIds); - sander.writeFileSync(WATCHED_ID, 'first'); + atomicWriteFileSync(WATCHED_ID, 'first'); }, 'START', 'BUNDLE_START', 'BUNDLE_END', 'END', () => { - assert.strictEqual(run('../_tmp/output/bundle.js'), 42); + assert.strictEqual(run(BUNDLE_FILE), 42); assert.deepStrictEqual(events, ['create']); assert.deepStrictEqual(ids, expectedIds); - sander.writeFileSync(WATCHED_ID, 'first'); + atomicWriteFileSync(WATCHED_ID, 'first'); }, 'START', 'BUNDLE_START', 'BUNDLE_END', 'END', () => { - assert.strictEqual(run('../_tmp/output/bundle.js'), 42); + assert.strictEqual(run(BUNDLE_FILE), 42); assert.deepStrictEqual(events, ['create', 'update']); assert.deepStrictEqual(ids, expectedIds); - sander.unlinkSync(WATCHED_ID); + unlinkSync(WATCHED_ID); }, 'START', 'BUNDLE_START', 'BUNDLE_END', 'END', () => { - assert.strictEqual(run('../_tmp/output/bundle.js'), 42); + assert.strictEqual(run(BUNDLE_FILE), 42); assert.deepStrictEqual(events, ['create', 'update', 'delete']); assert.deepStrictEqual(ids, expectedIds); } @@ -307,20 +321,20 @@ describe('rollup.watch', () => { }); it('correctly rewrites change event during build delay', async () => { - const WATCHED_ID = path.resolve('test/_tmp/input/watched'); - const MAIN_ID = path.resolve('test/_tmp/input/main.js'); + const WATCHED_ID = path.join(INPUT_DIR, 'watched'); + const MAIN_ID = ENTRY_FILE; let lastEvent = null; - await sander.copydir('test/watch/samples/watch-files').to('test/_tmp/input'); + await copy(path.join(SAMPLES_DIR, 'watch-files'), INPUT_DIR); await wait(100); watcher = rollup.watch({ - input: 'test/_tmp/input/main.js', + input: ENTRY_FILE, output: { - file: 'test/_tmp/output/bundle.js', + file: BUNDLE_FILE, format: 'cjs', exports: 'auto' }, watch: { - buildDelay: 300, + buildDelay: 600, chokidar: { atomic: false } @@ -345,9 +359,9 @@ describe('rollup.watch', () => { 'END', async () => { assert.strictEqual(lastEvent, null); - sander.writeFileSync(WATCHED_ID, 'another'); + atomicWriteFileSync(WATCHED_ID, 'another'); await wait(100); - sander.unlinkSync(WATCHED_ID); + await unlink(WATCHED_ID); }, 'START', 'BUNDLE_START', @@ -356,11 +370,11 @@ describe('rollup.watch', () => { async () => { assert.strictEqual(lastEvent, 'delete'); lastEvent = null; - sander.writeFileSync(WATCHED_ID, '123'); + atomicWriteFileSync(WATCHED_ID, '123'); await wait(100); - sander.unlinkSync(WATCHED_ID); + await unlink(WATCHED_ID); // To ensure there is always another change to trigger a rebuild - sander.writeFileSync(MAIN_ID, 'export default 43;'); + atomicWriteFileSync(MAIN_ID, 'export default 43;'); }, 'START', 'BUNDLE_START', @@ -368,9 +382,9 @@ describe('rollup.watch', () => { 'END', async () => { assert.strictEqual(lastEvent, null); - sander.writeFileSync(WATCHED_ID, '123'); + atomicWriteFileSync(WATCHED_ID, '123'); await wait(100); - sander.writeFileSync(WATCHED_ID, 'asd'); + atomicWriteFileSync(WATCHED_ID, 'asd'); }, 'START', 'BUNDLE_START', @@ -380,833 +394,824 @@ describe('rollup.watch', () => { assert.strictEqual(lastEvent, 'create'); } ]); - }).timeout(20000); - - it('calls closeWatcher plugin hook', () => { - let calls = 0; - let ctx1; - let ctx2; - return sander - .copydir('test/watch/samples/basic') - .to('test/_tmp/input') - .then(() => { - watcher = rollup.watch({ - input: 'test/_tmp/input/main.js', - output: { - file: 'test/_tmp/output/bundle.js', - format: 'cjs', - exports: 'auto' - }, - plugins: [ - { - buildStart() { - ctx1 = this; - }, - closeWatcher() { - assert.strictEqual(ctx1, this); - calls++; - } - }, - { - buildStart() { - ctx2 = this; - }, - closeWatcher() { - assert.strictEqual(ctx2, this); - calls++; - } - } - ] - }); - - return sequence(watcher, [ - 'START', - 'BUNDLE_START', - 'BUNDLE_END', - 'END', - () => { - assert.strictEqual(run('../_tmp/output/bundle.js'), 42); - assert.ok(ctx1); - assert.ok(ctx2); - watcher.once('close', () => { - assert.strictEqual(calls, 2); - }); - watcher.close(); - } - ]); - }); }); - it('watches a file in code-splitting mode', () => { - return sander - .copydir('test/watch/samples/code-splitting') - .to('test/_tmp/input') - .then(() => { - watcher = rollup.watch({ - input: ['test/_tmp/input/main1.js', 'test/_tmp/input/main2.js'], - output: { - dir: 'test/_tmp/output', - format: 'cjs', - exports: 'auto' - } - }); - - return sequence(watcher, [ - 'START', - 'BUNDLE_START', - 'BUNDLE_END', - 'END', - () => { - assert.strictEqual(run('../_tmp/output/main1.js'), 21); - assert.strictEqual(run('../_tmp/output/main2.js'), 42); - sander.writeFileSync('test/_tmp/input/shared.js', 'export const value = 22;'); + it('calls closeWatcher plugin hook', async () => { + let calls = 0; + let context1; + let context2; + await copy(path.join(SAMPLES_DIR, 'basic'), INPUT_DIR); + watcher = rollup.watch({ + input: ENTRY_FILE, + output: { + file: BUNDLE_FILE, + format: 'cjs', + exports: 'auto' + }, + plugins: [ + { + buildStart() { + // eslint-disable-next-line @typescript-eslint/no-this-alias + context1 = this; }, - 'START', - 'BUNDLE_START', - 'BUNDLE_END', - 'END', - () => { - assert.strictEqual(run('../_tmp/output/main1.js'), 22); - assert.strictEqual(run('../_tmp/output/main2.js'), 44); + closeWatcher() { + assert.strictEqual(context1, this); + calls++; } - ]); - }); - }); - - it('watches a file in code-splitting mode with an input object', () => { - return sander - .copydir('test/watch/samples/code-splitting') - .to('test/_tmp/input') - .then(() => { - watcher = rollup.watch({ - input: { - _main_1: 'test/_tmp/input/main1.js', - 'subfolder/_main_2': 'test/_tmp/input/main2.js' + }, + { + buildStart() { + // eslint-disable-next-line @typescript-eslint/no-this-alias + context2 = this; }, - output: { - dir: 'test/_tmp/output', - format: 'cjs', - exports: 'auto' + closeWatcher() { + assert.strictEqual(context2, this); + calls++; } + } + ] + }); + return sequence(watcher, [ + 'START', + 'BUNDLE_START', + 'BUNDLE_END', + 'END', + () => { + assert.strictEqual(run(BUNDLE_FILE), 42); + assert.ok(context1); + assert.ok(context2); + watcher.once('close', () => { + assert.strictEqual(calls, 2); }); - - return sequence(watcher, [ - 'START', - 'BUNDLE_START', - 'BUNDLE_END', - 'END', - () => { - assert.strictEqual(run('../_tmp/output/_main_1.js'), 21); - assert.strictEqual(run('../_tmp/output/subfolder/_main_2.js'), 42); - sander.writeFileSync('test/_tmp/input/shared.js', 'export const value = 22;'); - }, - 'START', - 'BUNDLE_START', - 'BUNDLE_END', - 'END', - () => { - assert.strictEqual(run('../_tmp/output/_main_1.js'), 22); - assert.strictEqual(run('../_tmp/output/subfolder/_main_2.js'), 44); - } - ]); - }); + watcher.close(); + } + ]); }); - it('recovers from an error', () => { - return sander - .copydir('test/watch/samples/basic') - .to('test/_tmp/input') - .then(() => { - watcher = rollup.watch({ - input: 'test/_tmp/input/main.js', - output: { - file: 'test/_tmp/output/bundle.js', - format: 'cjs', - exports: 'auto' - } - }); - - return sequence(watcher, [ - 'START', - 'BUNDLE_START', - 'BUNDLE_END', - 'END', - () => { - assert.strictEqual(run('../_tmp/output/bundle.js'), 42); - sander.writeFileSync('test/_tmp/input/main.js', 'export nope;'); - }, - 'START', - 'BUNDLE_START', - 'ERROR', - () => { - sander.writeFileSync('test/_tmp/input/main.js', 'export default 43;'); - }, - 'START', - 'BUNDLE_START', - 'BUNDLE_END', - 'END', - () => { - assert.strictEqual(run('../_tmp/output/bundle.js'), 43); - } - ]); - }); + it('watches a file in code-splitting mode', async () => { + await copy(path.join(SAMPLES_DIR, 'code-splitting'), INPUT_DIR); + watcher = rollup.watch({ + input: [path.join(INPUT_DIR, 'main1.js'), path.join(INPUT_DIR, 'main2.js')], + output: { + dir: OUTPUT_DIR, + format: 'cjs', + exports: 'auto' + } + }); + return sequence(watcher, [ + 'START', + 'BUNDLE_START', + 'BUNDLE_END', + 'END', + () => { + assert.strictEqual(run(path.join(OUTPUT_DIR, 'main1.js')), 21); + assert.strictEqual(run(path.join(OUTPUT_DIR, 'main2.js')), 42); + atomicWriteFileSync(path.join(INPUT_DIR, 'shared.js'), 'export const value = 22;'); + }, + 'START', + 'BUNDLE_START', + 'BUNDLE_END', + 'END', + () => { + assert.strictEqual(run(path.join(OUTPUT_DIR, 'main1.js')), 22); + assert.strictEqual(run(path.join(OUTPUT_DIR, 'main2.js')), 44); + } + ]); }); - it('recovers from an error on initial build', () => { - return sander - .copydir('test/watch/samples/error') - .to('test/_tmp/input') - .then(() => { - watcher = rollup.watch({ - input: 'test/_tmp/input/main.js', - output: { - file: 'test/_tmp/output/bundle.js', - format: 'cjs', - exports: 'auto' - } - }); - - return sequence(watcher, [ - 'START', - 'BUNDLE_START', - 'ERROR', - () => { - assert.strictEqual(sander.existsSync('../_tmp/output/bundle.js'), false); - sander.writeFileSync('test/_tmp/input/main.js', 'export default 43;'); - }, - 'START', - 'BUNDLE_START', - 'BUNDLE_END', - 'END', - () => { - assert.strictEqual(run('../_tmp/output/bundle.js'), 43); - } - ]); - }); + it('watches a file in code-splitting mode cover the last slash of path', async () => { + await copy(path.join(SAMPLES_DIR, 'code-splitting'), INPUT_DIR); + watcher = rollup.watch({ + input: [path.join(INPUT_DIR, 'main1.js'), path.join(INPUT_DIR, 'main2.js')], + output: { + dir: OUTPUT_DIR + '/', + format: 'cjs', + exports: 'auto' + } + }); + return sequence(watcher, [ + 'START', + 'BUNDLE_START', + 'BUNDLE_END', + 'END', + () => { + assert.strictEqual(run(path.join(OUTPUT_DIR, 'main1.js')), 21); + assert.strictEqual(run(path.join(OUTPUT_DIR, 'main2.js')), 42); + atomicWriteFileSync(path.join(INPUT_DIR, 'shared.js'), 'export const value = 22;'); + }, + 'START', + 'BUNDLE_START', + 'BUNDLE_END', + 'END', + () => { + assert.strictEqual(run(path.join(OUTPUT_DIR, 'main1.js')), 22); + assert.strictEqual(run(path.join(OUTPUT_DIR, 'main2.js')), 44); + } + ]); }); - it('recovers from a plugin error on initial build', () => { - let count = 0; - return sander - .copydir('test/watch/samples/basic') - .to('test/_tmp/input') - .then(() => { - watcher = rollup.watch({ - input: 'test/_tmp/input/main.js', - plugins: { - transform() { - if (count++ === 0) { - this.error('The first run failed, try again.'); - } - } - }, - output: { - file: 'test/_tmp/output/bundle.js', - format: 'cjs', - exports: 'auto' - } - }); - - return sequence(watcher, [ - 'START', - 'BUNDLE_START', - 'ERROR', - () => { - assert.strictEqual(sander.existsSync('../_tmp/output/bundle.js'), false); - sander.writeFileSync('test/_tmp/input/main.js', 'export default 43;'); - }, - 'START', - 'BUNDLE_START', - 'BUNDLE_END', - 'END', - () => { - assert.strictEqual(run('../_tmp/output/bundle.js'), 43); - } - ]); - }); + it('watches a file in code-splitting mode with an input object', async () => { + await copy(path.join(SAMPLES_DIR, 'code-splitting'), INPUT_DIR); + watcher = rollup.watch({ + input: { + _main_1: path.join(INPUT_DIR, 'main1.js'), + 'subfolder/_main_2': path.join(INPUT_DIR, 'main2.js') + }, + output: { + dir: OUTPUT_DIR, + format: 'cjs', + exports: 'auto' + } + }); + return sequence(watcher, [ + 'START', + 'BUNDLE_START', + 'BUNDLE_END', + 'END', + () => { + assert.strictEqual(run(path.join(OUTPUT_DIR, '_main_1.js')), 21); + assert.strictEqual(run(path.join(OUTPUT_DIR, 'subfolder/_main_2.js')), 42); + atomicWriteFileSync(path.join(INPUT_DIR, 'shared.js'), 'export const value = 22;'); + }, + 'START', + 'BUNDLE_START', + 'BUNDLE_END', + 'END', + () => { + assert.strictEqual(run(path.join(OUTPUT_DIR, '_main_1.js')), 22); + assert.strictEqual(run(path.join(OUTPUT_DIR, 'subfolder/_main_2.js')), 44); + } + ]); }); - it('recovers from an error even when erroring entry was "renamed" (#38)', () => { - return sander - .copydir('test/watch/samples/basic') - .to('test/_tmp/input') - .then(() => { - watcher = rollup.watch({ - input: 'test/_tmp/input/main.js', - output: { - file: 'test/_tmp/output/bundle.js', - format: 'cjs', - exports: 'auto' - } - }); - - return sequence(watcher, [ - 'START', - 'BUNDLE_START', - 'BUNDLE_END', - 'END', - () => { - assert.strictEqual(run('../_tmp/output/bundle.js'), 42); - sander.unlinkSync('test/_tmp/input/main.js'); - sander.writeFileSync('test/_tmp/input/main.js', 'export nope;'); - }, - 'START', - 'BUNDLE_START', - 'ERROR', - () => { - sander.unlinkSync('test/_tmp/input/main.js'); - sander.writeFileSync('test/_tmp/input/main.js', 'export default 43;'); - }, - 'START', - 'BUNDLE_START', - 'BUNDLE_END', - 'END', - () => { - assert.strictEqual(run('../_tmp/output/bundle.js'), 43); - } - ]); - }); + it('recovers from an error', async () => { + await copy(path.join(SAMPLES_DIR, 'basic'), INPUT_DIR); + watcher = rollup.watch({ + input: ENTRY_FILE, + output: { + file: BUNDLE_FILE, + format: 'cjs', + exports: 'auto' + } + }); + return sequence(watcher, [ + 'START', + 'BUNDLE_START', + 'BUNDLE_END', + 'END', + () => { + assert.strictEqual(run(BUNDLE_FILE), 42); + atomicWriteFileSync(ENTRY_FILE, 'export nope;'); + }, + 'START', + 'BUNDLE_START', + "ERROR:main.js (1:7): Expected '{', got 'ident'", + 'END', + () => { + atomicWriteFileSync(ENTRY_FILE, 'export default 43;'); + }, + 'START', + 'BUNDLE_START', + 'BUNDLE_END', + 'END', + () => { + assert.strictEqual(run(BUNDLE_FILE), 43); + } + ]); }); - it('recovers from an error even when erroring dependency was "renamed" (#38)', () => { - return sander - .copydir('test/watch/samples/dependency') - .to('test/_tmp/input') - .then(() => { - watcher = rollup.watch({ - input: 'test/_tmp/input/main.js', - output: { - file: 'test/_tmp/output/bundle.js', - format: 'cjs', - exports: 'auto' - } - }); - - return sequence(watcher, [ - 'START', - 'BUNDLE_START', - 'BUNDLE_END', - 'END', - () => { - assert.strictEqual(run('../_tmp/output/bundle.js'), 43); - sander.unlinkSync('test/_tmp/input/dep.js'); - sander.writeFileSync('test/_tmp/input/dep.js', 'export nope;'); - }, - 'START', - 'BUNDLE_START', - 'ERROR', - () => { - sander.unlinkSync('test/_tmp/input/dep.js'); - sander.writeFileSync('test/_tmp/input/dep.js', 'export const value = 43;'); - }, - 'START', - 'BUNDLE_START', - 'BUNDLE_END', - 'END', - () => { - assert.strictEqual(run('../_tmp/output/bundle.js'), 44); - } - ]); - }); + it('recovers from an error on initial build', async () => { + await copy(path.join(SAMPLES_DIR, 'error'), INPUT_DIR); + watcher = rollup.watch({ + input: ENTRY_FILE, + output: { + file: BUNDLE_FILE, + format: 'cjs', + exports: 'auto' + } + }); + return sequence(watcher, [ + 'START', + 'BUNDLE_START', + 'ERROR:main.js (2:0): Expression expected', + 'END', + () => { + assert.strictEqual(existsSync(BUNDLE_FILE), false); + atomicWriteFileSync(ENTRY_FILE, '' + 'export default 43;'); + }, + 'START', + 'BUNDLE_START', + 'BUNDLE_END', + 'END', + () => { + assert.strictEqual(run(BUNDLE_FILE), 43); + } + ]); }); - it('handles closing the watcher during a build', () => { - return sander - .copydir('test/watch/samples/basic') - .to('test/_tmp/input') - .then(() => { - watcher = rollup.watch({ - input: 'test/_tmp/input/main.js', - plugins: { - load() { - watcher.close(); - } - }, - output: { - file: 'test/_tmp/output/bundle.js', - format: 'cjs', - exports: 'auto' + it('recovers from a plugin error on initial build', async () => { + let error = true; + await copy(path.join(SAMPLES_DIR, 'basic'), INPUT_DIR); + watcher = rollup.watch({ + input: ENTRY_FILE, + plugins: { + transform() { + if (error) { + this.error('This run failed, try again.'); } - }); - const events = []; - watcher.on('event', event => events.push(event.code)); + } + }, + output: { + file: BUNDLE_FILE, + format: 'cjs', + exports: 'auto' + } + }); + return sequence(watcher, [ + 'START', + 'BUNDLE_START', + 'ERROR:[plugin at position 1] main.js: This run failed, try again.', + 'END', + () => { + error = false; + assert.strictEqual(existsSync(BUNDLE_FILE), false); + atomicWriteFileSync(ENTRY_FILE, 'export default 43;'); + }, + 'START', + 'BUNDLE_START', + 'BUNDLE_END', + 'END', + () => { + assert.strictEqual(run(BUNDLE_FILE), 43); + } + ]); + }); - return sequence(watcher, [ - 'START', - 'BUNDLE_START', - () => { - sander.writeFileSync('test/_tmp/input/main.js', 'export default 44;'); - return wait(400).then(() => assert.deepStrictEqual(events, ['START', 'BUNDLE_START'])); + it('awaits and recovers from a plugin error in the watchChange hook', async () => { + let fail = true; + await copy(path.join(SAMPLES_DIR, 'basic'), INPUT_DIR); + watcher = rollup.watch({ + input: ENTRY_FILE, + plugins: { + async watchChange() { + await wait(300); + if (fail) { + this.error('Failed in watchChange'); } - ]); - }); + } + }, + output: { + file: BUNDLE_FILE, + format: 'cjs', + exports: 'auto' + } + }); + return sequence(watcher, [ + 'START', + 'BUNDLE_START', + 'BUNDLE_END', + 'END', + () => { + assert.strictEqual(run(BUNDLE_FILE), 42); + atomicWriteFileSync(ENTRY_FILE, 'export default 21;'); + }, + 'ERROR:[plugin at position 1] Failed in watchChange', + 'END', + () => { + fail = false; + atomicWriteFileSync(ENTRY_FILE, 'export default 43;'); + }, + 'START', + 'BUNDLE_START', + 'BUNDLE_END', + 'END', + () => { + assert.strictEqual(run(BUNDLE_FILE), 43); + } + ]); }); - it('handles closing the watcher during a build even if an error occurred', () => { - return sander - .copydir('test/watch/samples/error') - .to('test/_tmp/input') - .then(() => { - watcher = rollup.watch({ - input: 'test/_tmp/input/main.js', - plugins: { - load() { - watcher.close(); - } - }, - output: { - file: 'test/_tmp/output/bundle.js', - format: 'cjs', - exports: 'auto' - } - }); - const events = []; - watcher.on('event', event => events.push(event.code)); + it('recovers from an error even when erroring entry was "renamed" (#38)', async () => { + await copy(path.join(SAMPLES_DIR, 'basic'), INPUT_DIR); + watcher = rollup.watch({ + input: ENTRY_FILE, + output: { + file: BUNDLE_FILE, + format: 'cjs', + exports: 'auto' + } + }); + return sequence(watcher, [ + 'START', + 'BUNDLE_START', + 'BUNDLE_END', + 'END', + () => { + assert.strictEqual(run(BUNDLE_FILE), 42); + unlinkSync(ENTRY_FILE); + atomicWriteFileSync(ENTRY_FILE, 'export nope;'); + }, + 'START', + 'BUNDLE_START', + "ERROR:main.js (1:7): Expected '{', got 'ident'", + 'END', + () => { + unlinkSync(ENTRY_FILE); + atomicWriteFileSync(ENTRY_FILE, 'export default 43;'); + }, + 'START', + 'BUNDLE_START', + 'BUNDLE_END', + 'END', + () => { + assert.strictEqual(run(BUNDLE_FILE), 43); + } + ]); + }); - return sequence(watcher, [ - 'START', - 'BUNDLE_START', - () => { - sander.writeFileSync('test/_tmp/input/main.js', 'export default 44;'); - return wait(400).then(() => assert.deepStrictEqual(events, ['START', 'BUNDLE_START'])); - } - ]); - }); + it('recovers from an error even when erroring dependency was "renamed" (#38)', async () => { + await copy(path.join(SAMPLES_DIR, 'dependency'), INPUT_DIR); + watcher = rollup.watch({ + input: ENTRY_FILE, + output: { + file: BUNDLE_FILE, + format: 'cjs', + exports: 'auto' + } + }); + return sequence(watcher, [ + 'START', + 'BUNDLE_START', + 'BUNDLE_END', + 'END', + () => { + assert.strictEqual(run(BUNDLE_FILE), 43); + unlinkSync(path.join(INPUT_DIR, 'dep.js')); + atomicWriteFileSync(path.join(INPUT_DIR, 'dep.js'), 'export nope;'); + }, + 'START', + 'BUNDLE_START', + "ERROR:dep.js (1:7): Expected '{', got 'ident'", + 'END', + () => { + unlinkSync(path.join(INPUT_DIR, 'dep.js')); + atomicWriteFileSync(path.join(INPUT_DIR, 'dep.js'), 'export const value = 43;'); + }, + 'START', + 'BUNDLE_START', + 'BUNDLE_END', + 'END', + () => { + assert.strictEqual(run(BUNDLE_FILE), 44); + } + ]); }); - it('stops watching files that are no longer part of the graph', () => { - return sander - .copydir('test/watch/samples/dependency') - .to('test/_tmp/input') - .then(() => { - watcher = rollup.watch({ - input: 'test/_tmp/input/main.js', - output: { - file: 'test/_tmp/output/bundle.js', - format: 'cjs', - exports: 'auto' - } - }); + it('handles closing the watcher during a build', async () => { + await copy(path.join(SAMPLES_DIR, 'basic'), INPUT_DIR); + watcher = rollup.watch({ + input: ENTRY_FILE, + plugins: { + load() { + watcher.close(); + } + }, + output: { + file: BUNDLE_FILE, + format: 'cjs', + exports: 'auto' + } + }); + const events = []; + watcher.on('event', event => events.push(event.code)); + return sequence(watcher, [ + 'START', + 'BUNDLE_START', + async () => { + atomicWriteFileSync(ENTRY_FILE, 'export default 44;'); + await wait(400); + assert.deepStrictEqual(events, ['START', 'BUNDLE_START']); + } + ]); + }); - return sequence(watcher, [ - 'START', - 'BUNDLE_START', - 'BUNDLE_END', - 'END', - () => { - assert.strictEqual(run('../_tmp/output/bundle.js'), 43); - sander.writeFileSync('test/_tmp/input/main.js', 'export default 42;'); - }, - 'START', - 'BUNDLE_START', - 'BUNDLE_END', - 'END', - () => { - assert.strictEqual(run('../_tmp/output/bundle.js'), 42); - let unexpectedEvent = false; - watcher.once('event', event => { - unexpectedEvent = event; - }); - sander.writeFileSync('test/_tmp/input/dep.js', '= invalid'); - return wait(400).then(() => assert.strictEqual(unexpectedEvent, false)); - } - ]); - }); + it('handles closing the watcher during a build even if an error occurred', async () => { + await copy(path.join(SAMPLES_DIR, 'error'), INPUT_DIR); + watcher = rollup.watch({ + input: ENTRY_FILE, + plugins: { + load() { + watcher.close(); + } + }, + output: { + file: BUNDLE_FILE, + format: 'cjs', + exports: 'auto' + } + }); + const events = []; + watcher.on('event', event => events.push(event.code)); + return sequence(watcher, [ + 'START', + 'BUNDLE_START', + async () => { + atomicWriteFileSync(ENTRY_FILE, 'export default 44;'); + await wait(400); + assert.deepStrictEqual(events, ['START', 'BUNDLE_START']); + } + ]); }); - it('refuses to watch the output file (#15)', () => { - return sander - .copydir('test/watch/samples/basic') - .to('test/_tmp/input') - .then(() => { - watcher = rollup.watch({ - input: 'test/_tmp/input/main.js', - output: { - file: 'test/_tmp/output/bundle.js', - format: 'cjs', - exports: 'auto' - } + it('stops watching files that are no longer part of the graph', async () => { + await copy(path.join(SAMPLES_DIR, 'dependency'), INPUT_DIR); + watcher = rollup.watch({ + input: ENTRY_FILE, + output: { + file: BUNDLE_FILE, + format: 'cjs', + exports: 'auto' + } + }); + return sequence(watcher, [ + 'START', + 'BUNDLE_START', + 'BUNDLE_END', + 'END', + () => { + assert.strictEqual(run(BUNDLE_FILE), 43); + atomicWriteFileSync(ENTRY_FILE, 'export default 42;'); + }, + 'START', + 'BUNDLE_START', + 'BUNDLE_END', + 'END', + async () => { + assert.strictEqual(run(BUNDLE_FILE), 42); + let unexpectedEvent = false; + watcher.once('event', event => { + unexpectedEvent = event; }); + atomicWriteFileSync(path.join(INPUT_DIR, 'dep.js'), '= invalid'); + await wait(400); + assert.strictEqual(unexpectedEvent, false); + } + ]); + }); - return sequence(watcher, [ - 'START', - 'BUNDLE_START', - 'BUNDLE_END', - 'END', - () => { - assert.strictEqual(run('../_tmp/output/bundle.js'), 42); - sander.writeFileSync('test/_tmp/input/main.js', `import '../output/bundle.js'`); - }, - 'START', - 'BUNDLE_START', - 'ERROR', - event => { - assert.strictEqual(event.error.message, 'Cannot import the generated bundle'); - sander.writeFileSync('test/_tmp/input/main.js', 'export default 43;'); - }, - 'START', - 'BUNDLE_START', - 'BUNDLE_END', - 'END', - () => { - assert.strictEqual(run('../_tmp/output/bundle.js'), 43); - } - ]); - }); + it('refuses to watch the output file (#15)', async () => { + await copy(path.join(SAMPLES_DIR, 'basic'), INPUT_DIR); + watcher = rollup.watch({ + input: ENTRY_FILE, + output: { + file: BUNDLE_FILE, + format: 'cjs', + exports: 'auto' + } + }); + return sequence(watcher, [ + 'START', + 'BUNDLE_START', + 'BUNDLE_END', + 'END', + () => { + assert.strictEqual(run(BUNDLE_FILE), 42); + atomicWriteFileSync(ENTRY_FILE, `import '../output/bundle.js'`); + }, + 'START', + 'BUNDLE_START', + 'ERROR:Cannot import the generated bundle', + 'END', + () => { + atomicWriteFileSync(ENTRY_FILE, 'export default 43;'); + }, + 'START', + 'BUNDLE_START', + 'BUNDLE_END', + 'END', + () => { + assert.strictEqual(run(BUNDLE_FILE), 43); + } + ]); }); - it('ignores files that are not specified in options.watch.include, if given', () => { - return sander - .copydir('test/watch/samples/ignored') - .to('test/_tmp/input') - .then(() => { - watcher = rollup.watch({ - input: 'test/_tmp/input/main.js', - output: { - file: 'test/_tmp/output/bundle.js', - format: 'cjs', - exports: 'auto' - }, - watch: { - include: ['test/_tmp/input/+(main|foo).js'] - } + it('ignores files that are not specified in options.watch.include, if given', async () => { + await copy(path.join(SAMPLES_DIR, 'ignored'), INPUT_DIR); + watcher = rollup.watch({ + input: ENTRY_FILE, + output: { + file: BUNDLE_FILE, + format: 'cjs', + exports: 'auto' + }, + watch: { + include: [path.join(INPUT_DIR, '+(main|foo).js')] + } + }); + return sequence(watcher, [ + 'START', + 'BUNDLE_START', + 'BUNDLE_END', + 'END', + () => { + assert.deepStrictEqual(run(BUNDLE_FILE), { + foo: 'foo-1', + bar: 'bar-1' + }); + atomicWriteFileSync(path.join(INPUT_DIR, 'foo.js'), `export default 'foo-2';`); + }, + 'START', + 'BUNDLE_START', + 'BUNDLE_END', + 'END', + async () => { + assert.deepStrictEqual(run(BUNDLE_FILE), { + foo: 'foo-2', + bar: 'bar-1' }); - - return sequence(watcher, [ - 'START', - 'BUNDLE_START', - 'BUNDLE_END', - 'END', - () => { - assert.deepStrictEqual(run('../_tmp/output/bundle.js'), { - foo: 'foo-1', - bar: 'bar-1' - }); - sander.writeFileSync('test/_tmp/input/foo.js', `export default 'foo-2';`); - }, - 'START', - 'BUNDLE_START', - 'BUNDLE_END', - 'END', - () => { - assert.deepStrictEqual(run('../_tmp/output/bundle.js'), { - foo: 'foo-2', - bar: 'bar-1' - }); - let unexpectedEvent = false; - watcher.once('event', event => { - unexpectedEvent = event; - }); - sander.writeFileSync('test/_tmp/input/bar.js', "export default 'bar-2';"); - return wait(400).then(() => { - assert.deepStrictEqual(run('../_tmp/output/bundle.js'), { - foo: 'foo-2', - bar: 'bar-1' - }); - assert.strictEqual(unexpectedEvent, false); - }); - } - ]); - }); + let unexpectedEvent = false; + watcher.once('event', event => { + unexpectedEvent = event; + }); + atomicWriteFileSync(path.join(INPUT_DIR, 'bar.js'), "export default 'bar-2';"); + await wait(400); + assert.deepStrictEqual(run(BUNDLE_FILE), { + foo: 'foo-2', + bar: 'bar-1' + }); + assert.strictEqual(unexpectedEvent, false); + } + ]); }); - it('ignores files that are specified in options.watch.exclude, if given', () => { - return sander - .copydir('test/watch/samples/ignored') - .to('test/_tmp/input') - .then(() => { - watcher = rollup.watch({ - input: 'test/_tmp/input/main.js', - output: { - file: 'test/_tmp/output/bundle.js', - format: 'cjs', - exports: 'auto' - }, - watch: { - exclude: ['test/_tmp/input/bar.js'] - } + it('ignores files that are specified in options.watch.exclude, if given', async () => { + await copy(path.join(SAMPLES_DIR, 'ignored'), INPUT_DIR); + watcher = rollup.watch({ + input: ENTRY_FILE, + output: { + file: BUNDLE_FILE, + format: 'cjs', + exports: 'auto' + }, + watch: { + exclude: [path.join(INPUT_DIR, 'bar.js')] + } + }); + return sequence(watcher, [ + 'START', + 'BUNDLE_START', + 'BUNDLE_END', + 'END', + () => { + assert.deepStrictEqual(run(BUNDLE_FILE), { + foo: 'foo-1', + bar: 'bar-1' }); - - return sequence(watcher, [ - 'START', - 'BUNDLE_START', - 'BUNDLE_END', - 'END', - () => { - assert.deepStrictEqual(run('../_tmp/output/bundle.js'), { - foo: 'foo-1', - bar: 'bar-1' - }); - sander.writeFileSync('test/_tmp/input/foo.js', `export default 'foo-2';`); - }, - 'START', - 'BUNDLE_START', - 'BUNDLE_END', - 'END', - () => { - assert.deepStrictEqual(run('../_tmp/output/bundle.js'), { - foo: 'foo-2', - bar: 'bar-1' - }); - let unexpectedEvent = false; - watcher.once('event', event => { - unexpectedEvent = event; - }); - sander.writeFileSync('test/_tmp/input/bar.js', "export default 'bar-2';"); - return wait(400).then(() => { - assert.deepStrictEqual(run('../_tmp/output/bundle.js'), { - foo: 'foo-2', - bar: 'bar-1' - }); - assert.strictEqual(unexpectedEvent, false); - }); - } - ]); - }); + atomicWriteFileSync(path.join(INPUT_DIR, 'foo.js'), `export default 'foo-2';`); + }, + 'START', + 'BUNDLE_START', + 'BUNDLE_END', + 'END', + async () => { + assert.deepStrictEqual(run(BUNDLE_FILE), { + foo: 'foo-2', + bar: 'bar-1' + }); + let unexpectedEvent = false; + watcher.once('event', event => { + unexpectedEvent = event; + }); + atomicWriteFileSync(path.join(INPUT_DIR, 'bar.js'), "export default 'bar-2';"); + await wait(400); + assert.deepStrictEqual(run(BUNDLE_FILE), { + foo: 'foo-2', + bar: 'bar-1' + }); + assert.strictEqual(unexpectedEvent, false); + } + ]); }); - it('only rebuilds the appropriate configs', () => { - return sander - .copydir('test/watch/samples/multiple') - .to('test/_tmp/input') - .then(() => wait(100)) - .then(() => { - watcher = rollup.watch([ - { - input: 'test/_tmp/input/main1.js', - output: { - file: 'test/_tmp/output/bundle1.js', - format: 'cjs', - exports: 'auto' - } - }, - { - input: 'test/_tmp/input/main2.js', - output: { - file: 'test/_tmp/output/bundle2.js', - format: 'cjs', - exports: 'auto' - } - } - ]); - - return sequence(watcher, [ - 'START', - 'BUNDLE_START', - 'BUNDLE_END', - 'BUNDLE_START', - 'BUNDLE_END', - 'END', - () => { - assert.deepStrictEqual(run('../_tmp/output/bundle1.js'), 42); - assert.deepStrictEqual(run('../_tmp/output/bundle2.js'), 43); - sander.writeFileSync('test/_tmp/input/main2.js', 'export default 44'); - }, - 'START', - 'BUNDLE_START', - 'BUNDLE_END', - 'END', - () => { - assert.deepStrictEqual(run('../_tmp/output/bundle1.js'), 42); - assert.deepStrictEqual(run('../_tmp/output/bundle2.js'), 44); - } - ]); - }); + it('only rebuilds the appropriate configs', async () => { + await copy(path.join(SAMPLES_DIR, 'multiple'), INPUT_DIR); + await wait(100); + watcher = rollup.watch([ + { + input: path.join(INPUT_DIR, 'main1.js'), + output: { + file: path.join(OUTPUT_DIR, 'bundle1.js'), + format: 'cjs', + exports: 'auto' + } + }, + { + input: path.join(INPUT_DIR, 'main2.js'), + output: { + file: path.join(OUTPUT_DIR, 'bundle2.js'), + format: 'cjs', + exports: 'auto' + } + } + ]); + return sequence(watcher, [ + 'START', + 'BUNDLE_START', + 'BUNDLE_END', + 'BUNDLE_START', + 'BUNDLE_END', + 'END', + () => { + assert.deepStrictEqual(run(path.join(OUTPUT_DIR, 'bundle1.js')), 42); + assert.deepStrictEqual(run(path.join(OUTPUT_DIR, 'bundle2.js')), 43); + atomicWriteFileSync(path.join(INPUT_DIR, 'main2.js'), 'export default 44'); + }, + 'START', + 'BUNDLE_START', + 'BUNDLE_END', + 'END', + () => { + assert.deepStrictEqual(run(path.join(OUTPUT_DIR, 'bundle1.js')), 42); + assert.deepStrictEqual(run(path.join(OUTPUT_DIR, 'bundle2.js')), 44); + } + ]); }); - it('allows watching only some configs', () => { - return sander - .copydir('test/watch/samples/multiple') - .to('test/_tmp/input') - .then(() => wait(100)) - .then(() => { - watcher = rollup.watch([ - { - input: 'test/_tmp/input/main1.js', - watch: false, - output: { - file: 'test/_tmp/output/bundle1.js', - format: 'cjs', - exports: 'auto' - } - }, - { - input: 'test/_tmp/input/main2.js', - output: { - file: 'test/_tmp/output/bundle2.js', - format: 'cjs', - exports: 'auto' - } - } - ]); - - return sequence(watcher, [ - 'START', - 'BUNDLE_START', - 'BUNDLE_END', - 'END', - () => { - assert.strictEqual( - sander.existsSync(path.resolve(__dirname, '../_tmp/output/bundle1.js')), - false - ); - assert.strictEqual( - sander.existsSync(path.resolve(__dirname, '../_tmp/output/bundle2.js')), - true - ); - assert.deepStrictEqual(run('../_tmp/output/bundle2.js'), 43); - } - ]); - }); + it('allows watching only some configs', async () => { + await copy(path.join(SAMPLES_DIR, 'multiple'), INPUT_DIR); + await wait(100); + watcher = rollup.watch([ + { + input: path.join(INPUT_DIR, 'main1.js'), + watch: false, + output: { + file: path.join(OUTPUT_DIR, 'bundle1.js'), + format: 'cjs', + exports: 'auto' + } + }, + { + input: path.join(INPUT_DIR, 'main2.js'), + output: { + file: path.join(OUTPUT_DIR, 'bundle2.js'), + format: 'cjs', + exports: 'auto' + } + } + ]); + return sequence(watcher, [ + 'START', + 'BUNDLE_START', + 'BUNDLE_END', + 'END', + () => { + assert.strictEqual( + existsSync(path.resolve(__dirname, path.join(OUTPUT_DIR, 'bundle1.js'))), + false + ); + assert.strictEqual( + existsSync(path.resolve(__dirname, path.join(OUTPUT_DIR, 'bundle2.js'))), + true + ); + assert.deepStrictEqual(run(path.join(OUTPUT_DIR, 'bundle2.js')), 43); + } + ]); }); - it('respects output.globals', () => { - return sander - .copydir('test/watch/samples/globals') - .to('test/_tmp/input') - .then(() => { - watcher = rollup.watch({ - input: 'test/_tmp/input/main.js', - output: { - file: 'test/_tmp/output/bundle.js', - format: 'iife', - globals: { - jquery: 'jQuery' - } - }, - external: ['jquery'] + it('respects output.globals', async () => { + await copy(path.join(SAMPLES_DIR, 'globals'), INPUT_DIR); + watcher = rollup.watch({ + input: ENTRY_FILE, + output: { + file: BUNDLE_FILE, + format: 'iife', + globals: { + jquery: 'jQuery' + } + }, + external: ['jquery'] + }); + return sequence(watcher, [ + 'START', + 'BUNDLE_START', + 'BUNDLE_END', + 'END', + () => { + const generated = readFileSync(BUNDLE_FILE, { + encoding: 'utf8' }); - - return sequence(watcher, [ - 'START', - 'BUNDLE_START', - 'BUNDLE_END', - 'END', - () => { - const generated = sander.readFileSync('test/_tmp/output/bundle.js', { - encoding: 'utf-8' - }); - assert.ok(/jQuery/.test(generated)); - } - ]); - }); + assert.ok(/jQuery/.test(generated)); + } + ]); }); - it('treats filenames literally, not as globs', () => { - return sander - .copydir('test/watch/samples/non-glob') - .to('test/_tmp/input') - .then(() => { - watcher = rollup.watch({ - input: 'test/_tmp/input/main.js', - output: { - file: 'test/_tmp/output/bundle.js', - format: 'cjs', - exports: 'auto' - } - }); - - return sequence(watcher, [ - 'START', - 'BUNDLE_START', - 'BUNDLE_END', - 'END', - () => { - assert.strictEqual(run('../_tmp/output/bundle.js'), 42); - sander.writeFileSync('test/_tmp/input/[foo]/bar.js', `export const bar = 43;`); - }, - 'START', - 'BUNDLE_START', - 'BUNDLE_END', - 'END', - () => { - assert.strictEqual(run('../_tmp/output/bundle.js'), 43); - } - ]); - }); + it('treats filenames literally, not as globs', async () => { + await copy(path.join(SAMPLES_DIR, 'non-glob'), INPUT_DIR); + watcher = rollup.watch({ + input: ENTRY_FILE, + output: { + file: BUNDLE_FILE, + format: 'cjs', + exports: 'auto' + } + }); + return sequence(watcher, [ + 'START', + 'BUNDLE_START', + 'BUNDLE_END', + 'END', + () => { + assert.strictEqual(run(BUNDLE_FILE), 42); + atomicWriteFileSync(path.join(INPUT_DIR, '[foo]/bar.js'), `export const bar = 43;`); + }, + 'START', + 'BUNDLE_START', + 'BUNDLE_END', + 'END', + () => { + assert.strictEqual(run(BUNDLE_FILE), 43); + } + ]); }); - it('updates the right hashes on dependency changes', () => { + it('updates the right hashes on dependency changes', async () => { let dynamicName; let staticName; let chunkName; - return sander - .copydir('test/watch/samples/hashing') - .to('test/_tmp/input') - .then(() => { - watcher = rollup.watch({ - input: ['test/_tmp/input/main-static.js', 'test/_tmp/input/main-dynamic.js'], - output: { - dir: 'test/_tmp/output', - format: 'cjs', - exports: 'auto', - entryFileNames: '[name].[hash].js', - chunkFileNames: '[name].[hash].js' - } + await copy(path.join(SAMPLES_DIR, 'hashing'), INPUT_DIR); + watcher = rollup.watch({ + input: [path.join(INPUT_DIR, 'main-static.js'), path.join(INPUT_DIR, 'main-dynamic.js')], + output: { + dir: OUTPUT_DIR, + format: 'cjs', + exports: 'auto', + entryFileNames: '[name].[hash].js', + chunkFileNames: '[name].[hash].js' + } + }); + return sequence(watcher, [ + 'START', + 'BUNDLE_START', + 'BUNDLE_END', + 'END', + () => { + [dynamicName, staticName, chunkName] = readdirSync(OUTPUT_DIR).sort(); + rmSync(OUTPUT_DIR, { + force: true, + recursive: true }); - return sequence(watcher, [ - 'START', - 'BUNDLE_START', - 'BUNDLE_END', - 'END', - () => { - [dynamicName, staticName, chunkName] = sander.readdirSync('test/_tmp/output').sort(); - sander.rimrafSync('test/_tmp/output'); - - // this should only update the hash of that particular entry point - sander.writeFileSync( - 'test/_tmp/input/main-static.js', - "import {value} from './shared';\nexport default 2 * value;" - ); - }, - 'START', - 'BUNDLE_START', - 'BUNDLE_END', - 'END', - () => { - const [newDynamicName, newStaticName, newChunkName] = sander - .readdirSync('test/_tmp/output') - .sort(); - sander.rimrafSync('test/_tmp/output'); - assert.notEqual(newStaticName, staticName); - assert.strictEqual(newDynamicName, dynamicName); - assert.strictEqual(newChunkName, chunkName); - staticName = newStaticName; + // this should only update the hash of that particular entry point + atomicWriteFileSync( + path.join(INPUT_DIR, 'main-static.js'), + "import {value} from './shared';\nexport default 2 * value;" + ); + }, + 'START', + 'BUNDLE_START', + 'BUNDLE_END', + 'END', + () => { + const [newDynamicName, newStaticName, newChunkName] = readdirSync(OUTPUT_DIR).sort(); + rmSync(OUTPUT_DIR, { + force: true, + recursive: true + }); + assert.notEqual(newStaticName, staticName); + assert.strictEqual(newDynamicName, dynamicName); + assert.strictEqual(newChunkName, chunkName); + staticName = newStaticName; - // this should update all hashes - sander.writeFileSync('test/_tmp/input/shared.js', 'export const value = 42;'); - }, - 'START', - 'BUNDLE_START', - 'BUNDLE_END', - 'END', - () => { - const [newDynamicName, newStaticName, newChunkName] = sander - .readdirSync('test/_tmp/output') - .sort(); - assert.notEqual(newStaticName, staticName); - assert.notEqual(newDynamicName, dynamicName); - assert.notEqual(newChunkName, chunkName); - } - ]); - }); + // this should update all hashes + atomicWriteFileSync(path.join(INPUT_DIR, 'shared.js'), 'export const value = 42;'); + }, + 'START', + 'BUNDLE_START', + 'BUNDLE_END', + 'END', + () => { + const [newDynamicName, newStaticName, newChunkName] = readdirSync(OUTPUT_DIR).sort(); + assert.notEqual(newStaticName, staticName); + assert.notEqual(newDynamicName, dynamicName); + assert.notEqual(newChunkName, chunkName); + } + ]); }); - it('runs transforms again on previously erroring files that were changed back', () => { + it('runs transforms again on previously erroring files that were changed back', async () => { const brokenFiles = new Set(); + await copy(path.join(SAMPLES_DIR, 'basic'), INPUT_DIR); const INITIAL_CONTENT = 'export default 42;'; - sander.writeFileSync('test/_tmp/input/main.js', INITIAL_CONTENT); + atomicWriteFileSync(ENTRY_FILE, INITIAL_CONTENT); watcher = rollup.watch({ - input: 'test/_tmp/input/main.js', + input: ENTRY_FILE, plugins: { transform(code, id) { if (code.includes('broken')) { brokenFiles.add(id); throw new Error('Broken in transform'); - } else { - brokenFiles.delete(id); } + brokenFiles.delete(id); }, generateBundle() { if (brokenFiles.size > 0) { @@ -1215,7 +1220,7 @@ describe('rollup.watch', () => { } }, output: { - file: 'test/_tmp/output/bundle.js', + file: BUNDLE_FILE, format: 'cjs', exports: 'auto' } @@ -1226,97 +1231,93 @@ describe('rollup.watch', () => { 'BUNDLE_END', 'END', () => { - assert.strictEqual(run('../_tmp/output/bundle.js'), 42); - sander.writeFileSync('test/_tmp/input/main.js', 'export default "broken";'); + assert.strictEqual(run(BUNDLE_FILE), 42); + atomicWriteFileSync(ENTRY_FILE, 'export default "broken";'); }, 'START', 'BUNDLE_START', - 'ERROR', + 'ERROR:Broken in transform', () => { - sander.writeFileSync('test/_tmp/input/main.js', INITIAL_CONTENT); + atomicWriteFileSync(ENTRY_FILE, INITIAL_CONTENT); }, 'START', 'BUNDLE_START', 'BUNDLE_END', 'END', () => { - assert.strictEqual(run('../_tmp/output/bundle.js'), 42); + assert.strictEqual(run(BUNDLE_FILE), 42); } ]); }); - it('skips filesystem writes when configured', () => { + it('skips filesystem writes when configured', async () => { let watchChangeCnt = 0; - return sander - .copydir('test/watch/samples/skip-writes') - .to('test/_tmp/input') - .then(() => { - watcher = rollup.watch({ - input: 'test/_tmp/input/main.js', - output: { - file: 'test/_tmp/output/bundle.js', - format: 'cjs', - exports: 'auto' - }, - watch: { - skipWrite: true - }, - plugins: { - watchChange(id) { - watchChangeCnt++; - assert.strictEqual(id, path.resolve('test/_tmp/input/main.js')); - } - } - }); - - return sequence(watcher, [ - 'START', - 'BUNDLE_START', - 'BUNDLE_END', - 'END', - () => { - watchChangeCnt = 0; - assert.strictEqual(sander.existsSync('../_tmp/output/bundle.js'), false); - sander.writeFileSync('test/_tmp/input/main.js', 'export default 43;'); - }, - 'START', - 'BUNDLE_START', - 'BUNDLE_END', - 'END', - () => { - assert.strictEqual(sander.existsSync('../_tmp/output/bundle.js'), false); - assert.strictEqual(watchChangeCnt, 1); - sander.writeFileSync('test/_tmp/input/main.js', 'export default 43;'); - }, - 'START', - 'BUNDLE_START', - 'BUNDLE_END', - 'END', - () => { - assert.strictEqual(sander.existsSync('../_tmp/output/bundle.js'), false); - assert.strictEqual(watchChangeCnt, 2); - sander.writeFileSync('test/_tmp/input/main.js', 'export default 43;'); - }, - 'START', - 'BUNDLE_START', - 'BUNDLE_END', - // 'END', - evt => { - assert.strictEqual(sander.existsSync('../_tmp/output/bundle.js'), false); - assert.strictEqual(watchChangeCnt, 3); - // still aware of its output destination - assert.strictEqual(evt.output[0], path.resolve('test/_tmp/output/bundle.js')); - } - ]); - }); + await copy(path.join(SAMPLES_DIR, 'skip-writes'), INPUT_DIR); + watcher = rollup.watch({ + input: ENTRY_FILE, + output: { + file: BUNDLE_FILE, + format: 'cjs', + exports: 'auto' + }, + watch: { + skipWrite: true + }, + plugins: { + watchChange(id) { + watchChangeCnt++; + assert.strictEqual(id, ENTRY_FILE); + } + } + }); + return sequence(watcher, [ + 'START', + 'BUNDLE_START', + 'BUNDLE_END', + 'END', + () => { + watchChangeCnt = 0; + assert.strictEqual(existsSync(BUNDLE_FILE), false); + atomicWriteFileSync(ENTRY_FILE, 'export default 43;'); + }, + 'START', + 'BUNDLE_START', + 'BUNDLE_END', + 'END', + () => { + assert.strictEqual(existsSync(BUNDLE_FILE), false); + assert.strictEqual(watchChangeCnt, 1); + atomicWriteFileSync(ENTRY_FILE, 'export default 43;'); + }, + 'START', + 'BUNDLE_START', + 'BUNDLE_END', + 'END', + () => { + assert.strictEqual(existsSync(BUNDLE_FILE), false); + assert.strictEqual(watchChangeCnt, 2); + atomicWriteFileSync(ENTRY_FILE, 'export default 43;'); + }, + 'START', + 'BUNDLE_START', + 'BUNDLE_END', + // 'END', + event => { + assert.strictEqual(existsSync(BUNDLE_FILE), false); + assert.strictEqual(watchChangeCnt, 3); + // still aware of its output destination + assert.strictEqual(event.output[0], path.resolve(BUNDLE_FILE)); + } + ]); }); it('rebuilds immediately by default', async () => { - await sander.copydir('test/watch/samples/basic').to('test/_tmp/input'); + await copy(path.join(SAMPLES_DIR, 'basic'), INPUT_DIR); + await wait(300); watcher = rollup.watch({ - input: 'test/_tmp/input/main.js', + input: ENTRY_FILE, output: { - file: 'test/_tmp/output/bundle.js', + file: BUNDLE_FILE, format: 'cjs', exports: 'auto' } @@ -1331,59 +1332,59 @@ describe('rollup.watch', () => { 'BUNDLE_END', 'END', () => { - assert.strictEqual(run('../_tmp/output/bundle.js'), 42); - sander.writeFileSync('test/_tmp/input/main.js', 'export default 43;'); - startTime = process.hrtime(); + assert.strictEqual(run(BUNDLE_FILE), 42); + atomicWriteFileSync(ENTRY_FILE, 'export default 43;'); + startTime = hrtime(); }, 'START', 'BUNDLE_START', 'BUNDLE_END', 'END', () => { - assert.strictEqual(run('../_tmp/output/bundle.js'), 43); + assert.strictEqual(run(BUNDLE_FILE), 43); const timeDiff = getTimeDiffInMs(startTime); assert.ok(timeDiff < 400, `Time difference ${timeDiff} < 400`); } ], 0 ); - }); + }).retries(1); it('observes configured build delays', async () => { - await sander.copydir('test/watch/samples/basic').to('test/_tmp/input'); + await copy(path.join(SAMPLES_DIR, 'basic'), INPUT_DIR); watcher = rollup.watch( [ { - input: 'test/_tmp/input/main.js', + input: ENTRY_FILE, output: { - file: 'test/_tmp/output/bundle.js', + file: BUNDLE_FILE, format: 'cjs', exports: 'auto' } }, { - input: 'test/_tmp/input/main.js', + input: ENTRY_FILE, watch: { clearScreen: true }, output: { - file: 'test/_tmp/output/bundle.js', + file: BUNDLE_FILE, format: 'cjs', exports: 'auto' } }, { - input: 'test/_tmp/input/main.js', + input: ENTRY_FILE, watch: { buildDelay: 1000 }, output: { - file: 'test/_tmp/output/bundle.js', + file: BUNDLE_FILE, format: 'cjs', exports: 'auto' } }, { - input: 'test/_tmp/input/main.js', + input: ENTRY_FILE, watch: { buildDelay: 50 }, output: { - file: 'test/_tmp/output/bundle.js', + file: BUNDLE_FILE, format: 'cjs', exports: 'auto' } @@ -1405,424 +1406,573 @@ describe('rollup.watch', () => { 'BUNDLE_END', 'END', () => { - assert.strictEqual(run('../_tmp/output/bundle.js'), 42); - sander.writeFileSync('test/_tmp/input/main.js', 'export default 43;'); - startTime = process.hrtime(); + assert.strictEqual(run(BUNDLE_FILE), 42); + atomicWriteFileSync(ENTRY_FILE, 'export default 43;'); + startTime = hrtime(); + }, + 'START', + 'BUNDLE_START', + 'BUNDLE_END', + 'BUNDLE_START', + 'BUNDLE_END', + 'BUNDLE_START', + 'BUNDLE_END', + 'BUNDLE_START', + 'BUNDLE_END', + 'END', + () => { + assert.strictEqual(run(BUNDLE_FILE), 43); + const timeDiff = getTimeDiffInMs(startTime); + assert.ok(timeDiff > 1000, `Time difference ${timeDiff} > 1000`); + } + ]); + }); + + it('watches the original file name of emitted files', async () => { + await copy(path.join(SAMPLES_DIR, 'watch-files'), INPUT_DIR); + const WATCHED_ID = path.join(INPUT_DIR, 'watched'); + const OUTPUT_FILE_NAME = 'watched.txt'; + const OUTPUT_ID = path.join(OUTPUT_DIR, OUTPUT_FILE_NAME); + watcher = rollup.watch({ + input: ENTRY_FILE, + output: { + file: BUNDLE_FILE, + format: 'cjs', + exports: 'auto' }, + plugins: [ + { + name: 'test', + buildStart() { + this.emitFile({ + type: 'asset', + fileName: OUTPUT_FILE_NAME, + originalFileName: WATCHED_ID, + source: readFileSync(WATCHED_ID).toString().trim() + }); + } + } + ] + }); + return sequence(watcher, [ 'START', 'BUNDLE_START', 'BUNDLE_END', + 'END', + () => { + assert.strictEqual(readFileSync(OUTPUT_ID).toString().trim(), 'initial'); + atomicWriteFileSync(WATCHED_ID, 'next'); + }, + 'START', 'BUNDLE_START', 'BUNDLE_END', + 'END', + () => { + assert.strictEqual(readFileSync(OUTPUT_ID).toString().trim(), 'next'); + } + ]); + }); + + it('watches a file and triggers onInvalidate', async () => { + let onInvalidateCalled = false; + let onInvalidateId = ''; + + await copy(path.join(SAMPLES_DIR, 'basic'), INPUT_DIR); + watcher = rollup.watch({ + input: ENTRY_FILE, + output: { + file: BUNDLE_FILE, + format: 'cjs', + exports: 'auto' + }, + watch: { + onInvalidate(id) { + onInvalidateCalled = true; + onInvalidateId = id; + } + } + }); + return sequence(watcher, [ + 'START', 'BUNDLE_START', 'BUNDLE_END', + 'END', + () => { + atomicWriteFileSync(ENTRY_FILE, 'export default 43;'); + }, + 'START', 'BUNDLE_START', 'BUNDLE_END', 'END', () => { - assert.strictEqual(run('../_tmp/output/bundle.js'), 43); - const timeDiff = getTimeDiffInMs(startTime); - assert.ok(timeDiff > 1000, `Time difference ${timeDiff} > 1000`); + assert.strictEqual(onInvalidateCalled, true); + assert.strictEqual(onInvalidateId, ENTRY_FILE); } ]); }); describe('addWatchFile', () => { - it('supports adding additional watch files in plugin hooks', () => { + it('supports adding additional watch files in plugin hooks', async () => { const watchChangeIds = new Set(); - const buildStartFile = path.resolve('test/_tmp/input/buildStart'); - const loadFile = path.resolve('test/_tmp/input/load'); - const resolveIdFile = path.resolve('test/_tmp/input/resolveId'); - const transformFile = path.resolve('test/_tmp/input/transform'); - const watchFiles = [buildStartFile, loadFile, resolveIdFile, transformFile]; - return sander - .copydir('test/watch/samples/basic') - .to('test/_tmp/input') - .then(() => { - for (const file of watchFiles) sander.writeFileSync(file, 'initial'); - watcher = rollup.watch({ - input: 'test/_tmp/input/main.js', - output: { - file: 'test/_tmp/output/bundle.js', - format: 'cjs', - exports: 'auto' - }, - plugins: { - buildStart() { - this.addWatchFile(buildStartFile); - }, - load() { - this.addWatchFile(loadFile); - }, - resolveId() { - this.addWatchFile(resolveIdFile); - }, - transform() { - this.addWatchFile(transformFile); - }, - watchChange(id) { - watchChangeIds.add(id); - } - } - }); + const buildEndFile = path.resolve(path.join(INPUT_DIR, 'buildEnd')); + const buildStartFile = path.resolve(path.join(INPUT_DIR, 'buildStart')); + const generateBundleFile = path.resolve(path.join(INPUT_DIR, 'generateBUndle')); + const loadFile = path.resolve(path.join(INPUT_DIR, 'load')); + const moduleParsedFile = path.resolve(path.join(INPUT_DIR, 'moduleParsed')); + const renderChunkFile = path.resolve(path.join(INPUT_DIR, 'renderChunk')); + const renderStartFile = path.resolve(path.join(INPUT_DIR, 'renderStart')); + const resolveIdFile = path.resolve(path.join(INPUT_DIR, 'resolveId')); + const transformFile = path.resolve(path.join(INPUT_DIR, 'transform')); + const writeBundleFile = path.resolve(path.join(INPUT_DIR, 'writeBundle')); + const watchFiles = [ + buildEndFile, + buildStartFile, + generateBundleFile, + loadFile, + moduleParsedFile, + renderChunkFile, + renderStartFile, + resolveIdFile, + transformFile, + writeBundleFile + ]; + await copy(path.join(SAMPLES_DIR, 'basic'), INPUT_DIR); + await Promise.all(watchFiles.map(file => writeFile(file, 'initial'))); + + watcher = rollup.watch({ + input: ENTRY_FILE, + output: { + file: BUNDLE_FILE, + format: 'cjs', + exports: 'auto' + }, + plugins: { + buildEnd() { + this.addWatchFile(buildEndFile); + }, + buildStart() { + this.addWatchFile(buildStartFile); + }, + generateBundle() { + this.addWatchFile(generateBundleFile); + }, + load() { + this.addWatchFile(loadFile); + }, + moduleParsed() { + this.addWatchFile(moduleParsedFile); + }, + renderChunk() { + this.addWatchFile(renderChunkFile); + }, + renderStart() { + this.addWatchFile(renderStartFile); + }, + resolveId() { + this.addWatchFile(resolveIdFile); + }, + transform() { + this.addWatchFile(transformFile); + }, + writeBundle() { + this.addWatchFile(writeBundleFile); + }, + watchChange(id) { + watchChangeIds.add(id); + } + } + }); + return sequence(watcher, [ + 'START', + 'BUNDLE_START', + 'BUNDLE_END', + 'END', + async () => { + assert.strictEqual(run(BUNDLE_FILE), 42); + // sometimes the watcher is triggered during the initial run + watchChangeIds.clear(); - return sequence(watcher, [ - 'START', - 'BUNDLE_START', - 'BUNDLE_END', - 'END', - () => { - assert.strictEqual(run('../_tmp/output/bundle.js'), 42); - // sometimes the watcher is triggered during the initial run - watchChangeIds.clear(); - for (const file of watchFiles) sander.writeFileSync(file, 'changed'); - }, - 'START', - 'BUNDLE_START', - 'BUNDLE_END', - 'END', - () => { - assert.strictEqual(run('../_tmp/output/bundle.js'), 42); - assert.deepStrictEqual([...watchChangeIds].sort(), watchFiles.sort()); - } - ]); - }); + await Promise.all(watchFiles.map(file => writeFile(file, 'changed'))); + }, + 'START', + 'BUNDLE_START', + 'BUNDLE_END', + 'END', + () => { + assert.strictEqual(run(BUNDLE_FILE), 42); + assert.deepStrictEqual([...watchChangeIds].sort(), watchFiles.sort()); + } + ]); }); - it('respects changed watched files in the load hook', () => { - const WATCHED_ID = path.resolve('test/_tmp/input/watched'); - return sander - .copydir('test/watch/samples/watch-files') - .to('test/_tmp/input') - .then(() => { - watcher = rollup.watch({ - input: 'test/_tmp/input/main.js', - output: { - file: 'test/_tmp/output/bundle.js', - format: 'cjs', - exports: 'auto' - }, - plugins: { - load() { - this.addWatchFile(WATCHED_ID); - return `export default "${sander.readFileSync(WATCHED_ID).toString().trim()}"`; - } - } - }); - - return sequence(watcher, [ - 'START', - 'BUNDLE_START', - 'BUNDLE_END', - 'END', - () => { - assert.strictEqual(run('../_tmp/output/bundle.js'), 'initial'); - sander.writeFileSync(WATCHED_ID, 'next'); - }, - 'START', - 'BUNDLE_START', - 'BUNDLE_END', - 'END', - () => { - assert.strictEqual(run('../_tmp/output/bundle.js'), 'next'); - } - ]); - }); + it('respects changed watched files in the load hook', async () => { + const WATCHED_ID = path.join(INPUT_DIR, 'watched'); + await copy(path.join(SAMPLES_DIR, 'watch-files'), INPUT_DIR); + watcher = rollup.watch({ + input: ENTRY_FILE, + output: { + file: BUNDLE_FILE, + format: 'cjs', + exports: 'auto' + }, + plugins: { + load() { + this.addWatchFile(WATCHED_ID); + return `export default "${readFileSync(WATCHED_ID).toString().trim()}"`; + } + } + }); + return sequence(watcher, [ + 'START', + 'BUNDLE_START', + 'BUNDLE_END', + 'END', + () => { + assert.strictEqual(run(BUNDLE_FILE), 'initial'); + atomicWriteFileSync(WATCHED_ID, 'next'); + }, + 'START', + 'BUNDLE_START', + 'BUNDLE_END', + 'END', + () => { + assert.strictEqual(run(BUNDLE_FILE), 'next'); + } + ]); }); - it('respects changed watched files in the transform hook and removes them if they are no longer watched', () => { - const WATCHED_ID = path.resolve('test/_tmp/input/watched'); + it('respects changed watched files in the transform hook and removes them if they are no longer watched', async () => { + const WATCHED_ID = path.join(INPUT_DIR, 'watched'); let addWatchFile = true; - return sander - .copydir('test/watch/samples/watch-files') - .to('test/_tmp/input') - .then(() => { - watcher = rollup.watch({ - input: 'test/_tmp/input/main.js', - output: { - file: 'test/_tmp/output/bundle.js', - format: 'cjs', - exports: 'auto' - }, - plugins: { - resolveId(id) { - if (id === 'dep') { - return id; - } - }, - load(id) { - if (id === 'dep') { - return `throw new Error('This should not be executed);`; - } - }, - transform(code, id) { - if (id.endsWith('main.js')) { - return `export { value as default } from 'dep';`; - } else { - if (addWatchFile) { - this.addWatchFile(WATCHED_ID); - } - return `export const value = "${sander - .readFileSync(WATCHED_ID) - .toString() - .trim()}"`; - } - } + await copy(path.join(SAMPLES_DIR, 'watch-files'), INPUT_DIR); + watcher = rollup.watch({ + input: ENTRY_FILE, + output: { + file: BUNDLE_FILE, + format: 'cjs', + exports: 'auto' + }, + plugins: { + resolveId(id) { + if (id === 'dep') { + return id; } - }); - const events = []; - watcher.on('event', event => events.push(event.code)); - - return sequence(watcher, [ - 'START', - 'BUNDLE_START', - 'BUNDLE_END', - 'END', - () => { - assert.strictEqual(run('../_tmp/output/bundle.js'), 'initial'); - addWatchFile = false; - sander.writeFileSync(WATCHED_ID, 'next'); - }, - 'START', - 'BUNDLE_START', - 'BUNDLE_END', - 'END', - () => { - assert.strictEqual(run('../_tmp/output/bundle.js'), 'next'); - sander.writeFileSync(WATCHED_ID, 'other'); - events.length = 0; - return wait(400).then(() => assert.deepStrictEqual(events, [])); + }, + load(id) { + if (id === 'dep') { + return `throw new Error('This should not be executed);`; } - ]); - }); - }); - - it('respects changed watched modules that are already part of the graph in the transform hook', () => { - return sander - .copydir('test/watch/samples/dependencies') - .to('test/_tmp/input') - .then(() => { - watcher = rollup.watch({ - input: 'test/_tmp/input/main.js', - output: { - file: 'test/_tmp/output/bundle.js', - format: 'cjs', - exports: 'auto' - }, - plugins: { - transform(code, id) { - if (id.endsWith('dep1.js')) { - this.addWatchFile(path.resolve('test/_tmp/input/dep2.js')); - const text = sander.readFileSync('test/_tmp/input/dep2.js').toString().trim(); - return `export default ${JSON.stringify(text)}`; - } + }, + transform(code, id) { + if (id.endsWith('main.js')) { + return `export { value as default } from 'dep';`; + } else { + if (addWatchFile) { + this.addWatchFile(WATCHED_ID); } + return `export const value = "${readFileSync(WATCHED_ID).toString().trim()}"`; } - }); + } + } + }); + const events = []; + watcher.on('event', event => events.push(event.code)); + return sequence(watcher, [ + 'START', + 'BUNDLE_START', + 'BUNDLE_END', + 'END', + () => { + assert.strictEqual(run(BUNDLE_FILE), 'initial'); + addWatchFile = false; + atomicWriteFileSync(WATCHED_ID, 'next'); + }, + 'START', + 'BUNDLE_START', + 'BUNDLE_END', + 'END', + async () => { + assert.strictEqual(run(BUNDLE_FILE), 'next'); + atomicWriteFileSync(WATCHED_ID, 'other'); + events.length = 0; + await wait(400); + assert.deepStrictEqual(events, []); + } + ]); + }); - return sequence(watcher, [ - 'START', - 'BUNDLE_START', - 'BUNDLE_END', - 'END', - () => { - assert.strictEqual( - run('../_tmp/output/bundle.js'), - `dep1: "export default 'dep2';", dep2: "dep2"` - ); - sander.writeFileSync('test/_tmp/input/dep2.js', 'export default "next";'); - }, - 'START', - 'BUNDLE_START', - 'BUNDLE_END', - 'END', - () => { - assert.strictEqual( - run('../_tmp/output/bundle.js'), - `dep1: "export default "next";", dep2: "next"` - ); + it('respects changed watched modules that are already part of the graph in the transform hook', async () => { + await copy(path.join(SAMPLES_DIR, 'dependencies'), INPUT_DIR); + watcher = rollup.watch({ + input: ENTRY_FILE, + output: { + file: BUNDLE_FILE, + format: 'cjs', + exports: 'auto' + }, + plugins: { + transform(code, id) { + if (id.endsWith('dep1.js')) { + this.addWatchFile(path.resolve(path.join(INPUT_DIR, 'dep2.js'))); + const text = readFileSync(path.join(INPUT_DIR, 'dep2.js')).toString().trim(); + return `export default ${JSON.stringify(text)}`; } - ]); - }); + } + } + }); + return sequence(watcher, [ + 'START', + 'BUNDLE_START', + 'BUNDLE_END', + 'END', + () => { + assert.strictEqual(run(BUNDLE_FILE), `dep1: "export default 'dep2';", dep2: "dep2"`); + atomicWriteFileSync(path.join(INPUT_DIR, 'dep2.js'), 'export default "next";'); + }, + 'START', + 'BUNDLE_START', + 'BUNDLE_END', + 'END', + () => { + assert.strictEqual(run(BUNDLE_FILE), `dep1: "export default "next";", dep2: "next"`); + } + ]); }); - it('respects changed watched directories in the transform hook', () => { - const WATCHED_ID = path.resolve('test/_tmp/input/watched'); - return sander - .copydir('test/watch/samples/watch-files') - .to('test/_tmp/input') - .then(() => { - watcher = rollup.watch({ - input: 'test/_tmp/input/main.js', - output: { - file: 'test/_tmp/output/bundle.js', - format: 'cjs', - exports: 'auto' - }, - plugins: { - transform() { - this.addWatchFile('test/_tmp/input'); - return `export default ${sander.existsSync(WATCHED_ID)}`; - } - } - }); + it('respects changed watched directories in the transform hook', async () => { + const WATCHED_ID = path.join(INPUT_DIR, 'watched'); + await copy(path.join(SAMPLES_DIR, 'watch-files'), INPUT_DIR); + watcher = rollup.watch({ + input: ENTRY_FILE, + output: { + file: BUNDLE_FILE, + format: 'cjs', + exports: 'auto' + }, + plugins: { + transform() { + this.addWatchFile(INPUT_DIR); + return `export default ${existsSync(WATCHED_ID)}`; + } + } + }); + return sequence(watcher, [ + 'START', + 'BUNDLE_START', + 'BUNDLE_END', + 'END', + () => { + assert.strictEqual(run(BUNDLE_FILE), true); + unlinkSync(WATCHED_ID); + }, + 'START', + 'BUNDLE_START', + 'BUNDLE_END', + 'END', + () => { + assert.strictEqual(run(BUNDLE_FILE), false); + watcher.close(); + } + ]); + }); - return sequence(watcher, [ - 'START', - 'BUNDLE_START', - 'BUNDLE_END', - 'END', - () => { - assert.strictEqual(run('../_tmp/output/bundle.js'), true); - sander.unlinkSync(WATCHED_ID); - }, - 'START', - 'BUNDLE_START', - 'BUNDLE_END', - 'END', - () => { - assert.strictEqual(run('../_tmp/output/bundle.js'), false); - watcher.close(); - } - ]); - }); + it('respects initially missing added watched files', async () => { + await copy(path.join(SAMPLES_DIR, 'basic'), INPUT_DIR); + watcher = rollup.watch({ + input: ENTRY_FILE, + output: { + file: BUNDLE_FILE, + format: 'cjs', + exports: 'auto' + }, + plugins: { + transform() { + this.addWatchFile(path.join(INPUT_DIR, 'dep')); + return `export default ${existsSync(path.join(INPUT_DIR, 'dep'))}`; + } + } + }); + return sequence(watcher, [ + 'START', + 'BUNDLE_START', + 'BUNDLE_END', + 'END', + () => { + assert.strictEqual(run(BUNDLE_FILE), false); + atomicWriteFileSync(path.join(INPUT_DIR, 'dep'), ''); + }, + 'START', + 'BUNDLE_START', + 'BUNDLE_END', + 'END', + () => { + assert.strictEqual(run(BUNDLE_FILE), true); + } + ]); }); - it('respects initially missing added watched files', () => { - return sander - .copydir('test/watch/samples/basic') - .to('test/_tmp/input') - .then(() => { - watcher = rollup.watch({ - input: 'test/_tmp/input/main.js', - output: { - file: 'test/_tmp/output/bundle.js', - format: 'cjs', - exports: 'auto' - }, - plugins: { - transform() { - this.addWatchFile('test/_tmp/input/dep'); - return `export default ${sander.existsSync('test/_tmp/input/dep')}`; - } - } - }); + it('respects unlinked and re-added watched files', async () => { + await copy(path.join(SAMPLES_DIR, 'basic'), INPUT_DIR); + await writeFile(path.join(INPUT_DIR, 'dep'), ''); + watcher = rollup.watch({ + input: ENTRY_FILE, + output: { + file: BUNDLE_FILE, + format: 'cjs', + exports: 'auto' + }, + plugins: { + transform() { + this.addWatchFile(path.join(INPUT_DIR, 'dep')); + return `export default ${existsSync(path.join(INPUT_DIR, 'dep'))}`; + } + } + }); + return sequence(watcher, [ + 'START', + 'BUNDLE_START', + 'BUNDLE_END', + 'END', + () => { + assert.strictEqual(run(BUNDLE_FILE), true); + unlinkSync(path.join(INPUT_DIR, 'dep')); + }, + 'START', + 'BUNDLE_START', + 'BUNDLE_END', + 'END', + () => { + assert.strictEqual(run(BUNDLE_FILE), false); + atomicWriteFileSync(path.join(INPUT_DIR, 'dep'), ''); + }, + 'START', + 'BUNDLE_START', + 'BUNDLE_END', + 'END', + () => { + assert.strictEqual(run(BUNDLE_FILE), true); + } + ]); + }); - return sequence(watcher, [ - 'START', - 'BUNDLE_START', - 'BUNDLE_END', - 'END', - () => { - assert.strictEqual(run('../_tmp/output/bundle.js'), false); - sander.writeFileSync('test/_tmp/input/dep', ''); - }, - 'START', - 'BUNDLE_START', - 'BUNDLE_END', - 'END', - () => { - assert.strictEqual(run('../_tmp/output/bundle.js'), true); - } - ]); - }); + it('does not rerun the transform hook if a non-watched change triggered the re-run', async () => { + const WATCHED_ID = path.join(INPUT_DIR, 'watched'); + let transformRuns = 0; + await copy(path.join(SAMPLES_DIR, 'watch-files'), INPUT_DIR); + await wait(100); + await writeFile(path.join(INPUT_DIR, 'alsoWatched'), 'initial'); + watcher = rollup.watch({ + input: ENTRY_FILE, + output: { + file: BUNDLE_FILE, + format: 'cjs', + exports: 'auto' + }, + plugins: { + buildStart() { + this.addWatchFile(path.join(INPUT_DIR, 'alsoWatched')); + }, + transform() { + transformRuns++; + this.addWatchFile(WATCHED_ID); + return `export default "${readFileSync(WATCHED_ID).toString().trim()}"`; + } + } + }); + return sequence(watcher, [ + 'START', + 'BUNDLE_START', + 'BUNDLE_END', + 'END', + () => { + assert.strictEqual(transformRuns, 1); + atomicWriteFileSync(path.join(INPUT_DIR, 'alsoWatched'), 'next'); + }, + 'START', + 'BUNDLE_START', + 'BUNDLE_END', + 'END', + () => { + assert.strictEqual(transformRuns, 1); + } + ]); }); + }); +}); - it('respects unlinked and re-added watched files', () => { - return sander - .copydir('test/watch/samples/basic') - .to('test/_tmp/input') - .then(() => { - sander.writeFileSync('test/_tmp/input/dep', ''); - watcher = rollup.watch({ - input: 'test/_tmp/input/main.js', - output: { - file: 'test/_tmp/output/bundle.js', - format: 'cjs', - exports: 'auto' - }, - plugins: { - transform() { - this.addWatchFile('test/_tmp/input/dep'); - return `export default ${sander.existsSync('test/_tmp/input/dep')}`; - } - } - }); +function run(file) { + const resolved = require.resolve(file); + delete require.cache[resolved]; + return require(resolved); +} - return sequence(watcher, [ - 'START', - 'BUNDLE_START', - 'BUNDLE_END', - 'END', - () => { - assert.strictEqual(run('../_tmp/output/bundle.js'), true); - sander.unlinkSync('test/_tmp/input/dep'); - }, - 'START', - 'BUNDLE_START', - 'BUNDLE_END', - 'END', - () => { - assert.strictEqual(run('../_tmp/output/bundle.js'), false); - sander.writeFileSync('test/_tmp/input/dep', ''); - }, - 'START', - 'BUNDLE_START', - 'BUNDLE_END', - 'END', - () => { - assert.strictEqual(run('../_tmp/output/bundle.js'), true); - } - ]); +function sequence(watcher, events, timeout = 300) { + const handledEvents = []; + const allEvents = []; + const formatEvents = () => + `\nHandled events:\n${handledEvents.join('\n')}\n\nWatcher events:\n${allEvents.join('\n')}`; + watcher.on('event', event => allEvents.push(JSON.stringify(event))); + const sequencePromise = new Promise((fulfil, reject) => { + function go(event) { + const next = events.shift(); + if (!next) { + handledEvents.push('DONE'); + watcher.close(); + fulfil(); + } else if (typeof next === 'string') { + handledEvents.push(next); + const [eventCode, ...eventMessageParts] = next.split(':'); + const eventMessage = eventMessageParts.join(':'); + watcher.once('event', event => { + if (event.code !== eventCode) { + watcher.close(); + if (event.code === 'ERROR') console.log(event.error); + reject(new Error(`Expected ${eventCode} event, got ${event.code}.${formatEvents()}`)); + } else if ( + eventCode === 'ERROR' && + eventMessage && + event.error.message !== eventMessage + ) { + reject( + new Error( + `Expected to throw "${eventMessage}" but got "${event.error.message}".${formatEvents()}` + ) + ); + } else { + go(event); + } }); - }); - - it('does not rerun the transform hook if a non-watched change triggered the re-run', () => { - const WATCHED_ID = path.resolve('test/_tmp/input/watched'); - let transformRuns = 0; - return sander - .copydir('test/watch/samples/watch-files') - .to('test/_tmp/input') - .then(() => wait(100)) - .then(() => { - sander.writeFileSync('test/_tmp/input/alsoWatched', 'initial'); - watcher = rollup.watch({ - input: 'test/_tmp/input/main.js', - output: { - file: 'test/_tmp/output/bundle.js', - format: 'cjs', - exports: 'auto' - }, - plugins: { - buildStart() { - this.addWatchFile('test/_tmp/input/alsoWatched'); - }, - transform() { - transformRuns++; - this.addWatchFile(WATCHED_ID); - return `export default "${sander.readFileSync(WATCHED_ID).toString().trim()}"`; - } - } + } else { + // "next" is a function + // This solves two problems: + // - Sometimes a change in the function does not trigger a rebuild if + // it happens too quickly, i.e. shorter than 300ms after the previous + // change. + // - On the flipside, sometimes a single change triggers two builds. + // In that case, waiting here "swallows" the second build. + wait(timeout) + .then(() => { + handledEvents.push(`fn: ${JSON.stringify(event)}`); + next(event); + go(); + }) + .catch(error => { + watcher.close(); + error.message += formatEvents(); + reject(error); }); + } + } - return sequence(watcher, [ - 'START', - 'BUNDLE_START', - 'BUNDLE_END', - 'END', - () => { - assert.strictEqual(transformRuns, 1); - sander.writeFileSync('test/_tmp/input/alsoWatched', 'next'); - }, - 'START', - 'BUNDLE_START', - 'BUNDLE_END', - 'END', - () => { - assert.strictEqual(transformRuns, 1); - } - ]); - }); - }); + go(); }); -}).timeout(20000); + + return withTimeout(sequencePromise, 20_000, () => { + throw new Error(`Test timed out.\nHandled events:\n${handledEvents.join('\n')}`); + }).then(() => wait(100)); +} + +function getTimeDiffInMs(previous) { + const [seconds, nanoseconds] = hrtime(previous); + return seconds * 1e3 + nanoseconds / 1e6; +} diff --git a/tsconfig.json b/tsconfig.json index 94397632d03..b6ff2910e93 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,18 +1,42 @@ { - "compilerOptions": { - "allowSyntheticDefaultImports": true, - "diagnostics": true, - "isolatedModules": true, - "module": "ESNext", - "moduleResolution": "Node", - "noEmitOnError": true, - "noUnusedLocals": true, - "noUnusedParameters": true, - "pretty": true, - "skipLibCheck": true, - "strict": true, - "target": "es2018" - }, - "include": ["typings/**/*.d.ts", "src", "cli", "browser"], - "exclude": ["dist", "node_modules", "test/typescript"] + "compilerOptions": { + "allowSyntheticDefaultImports": true, + "allowUnreachableCode": false, + "allowUnusedLabels": false, + "forceConsistentCasingInFileNames": true, + "lib": [ + "ES2022", + "ESNext.Disposable", + "DOM" + ], + "module": "ESNext", + "moduleResolution": "Bundler", + "noEmitOnError": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "paths": { + "rollup": [ + "./node_modules/rollup" + ] + }, + "pretty": true, + "resolveJsonModule": true, + "strict": true, + "target": "ES2022", + "useDefineForClassFields": false + }, + "include": [ + "browser", + "cli", + "native", + "rollup.config.ts", + "src", + "typings" + ], + "exclude": [ + "browser/dist", + "dist", + "node_modules", + "test/typescript" + ] } diff --git a/tslint.json b/tslint.json deleted file mode 100644 index 28b919c9f22..00000000000 --- a/tslint.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "defaultSeverity": "error", - "rules": { - "arrow-return-shorthand": true, - "interface-over-type-literal": true, - "member-ordering": [ - true, - { - "order": "statics-first", - "alphabetize": true - } - ], - "no-angle-bracket-type-assertion": true, - "no-inferrable-types": true, - "no-string-literal": true, - "no-unnecessary-type-assertion": true, - "object-literal-shorthand": true, - "object-literal-sort-keys": [ - true, - "ignore-case" - ], - "ordered-imports": true, - "prefer-const": [true, { "destructuring": "all" }], - "prefer-object-spread": true - } -} diff --git a/typings/declarations.d.ts b/typings/declarations.d.ts deleted file mode 100644 index 16e35c5db26..00000000000 --- a/typings/declarations.d.ts +++ /dev/null @@ -1,190 +0,0 @@ -// internal -declare module 'help.md' { - const str: string; - export default str; -} - -// external libs -declare module 'acorn-class-fields' { - const plugin: (BaseParser: typeof acorn.Parser) => typeof acorn.Parser; - export default plugin; -} - -declare module 'acorn-private-methods' { - const plugin: (BaseParser: typeof acorn.Parser) => typeof acorn.Parser; - export default plugin; -} - -declare module 'acorn-static-class-features' { - const plugin: (BaseParser: typeof acorn.Parser) => typeof acorn.Parser; - export default plugin; -} - -declare module 'fsevents' { - export default {}; -} - -declare module 'acorn-walk' { - type WalkerCallback = (node: acorn.Node, state: TState) => void; - type RecursiveWalkerFn = ( - node: acorn.Node, - state: TState, - callback: WalkerCallback - ) => void; - export type BaseWalker = Record>; - export const base: BaseWalker; -} - -declare module 'is-reference' { - export default function is_reference( - node: NodeWithFieldDefinition, - parent: NodeWithFieldDefinition - ): any; - export type Node = - | import('estree').Identifier - | import('estree').SimpleLiteral - | import('estree').RegExpLiteral - | import('estree').Program - | import('estree').FunctionDeclaration - | import('estree').FunctionExpression - | import('estree').ArrowFunctionExpression - | import('estree').SwitchCase - | import('estree').CatchClause - | import('estree').VariableDeclarator - | import('estree').ExpressionStatement - | import('estree').BlockStatement - | import('estree').EmptyStatement - | import('estree').DebuggerStatement - | import('estree').WithStatement - | import('estree').ReturnStatement - | import('estree').LabeledStatement - | import('estree').BreakStatement - | import('estree').ContinueStatement - | import('estree').IfStatement - | import('estree').SwitchStatement - | import('estree').ThrowStatement - | import('estree').TryStatement - | import('estree').WhileStatement - | import('estree').DoWhileStatement - | import('estree').ForStatement - | import('estree').ForInStatement - | import('estree').ForOfStatement - | import('estree').VariableDeclaration - | import('estree').ClassDeclaration - | import('estree').ThisExpression - | import('estree').ArrayExpression - | import('estree').ObjectExpression - | import('estree').YieldExpression - | import('estree').UnaryExpression - | import('estree').UpdateExpression - | import('estree').BinaryExpression - | import('estree').AssignmentExpression - | import('estree').LogicalExpression - | import('estree').MemberExpression - | import('estree').ConditionalExpression - | import('estree').SimpleCallExpression - | import('estree').NewExpression - | import('estree').SequenceExpression - | import('estree').TemplateLiteral - | import('estree').TaggedTemplateExpression - | import('estree').ClassExpression - | import('estree').MetaProperty - | import('estree').AwaitExpression - | import('estree').ImportExpression - | import('estree').ChainExpression - | import('estree').Property - | import('estree').AssignmentProperty - | import('estree').Super - | import('estree').TemplateElement - | import('estree').SpreadElement - | import('estree').ObjectPattern - | import('estree').ArrayPattern - | import('estree').RestElement - | import('estree').AssignmentPattern - | import('estree').ClassBody - | import('estree').MethodDefinition - | import('estree').ImportDeclaration - | import('estree').ExportNamedDeclaration - | import('estree').ExportDefaultDeclaration - | import('estree').ExportAllDeclaration - | import('estree').ImportSpecifier - | import('estree').ImportDefaultSpecifier - | import('estree').ImportNamespaceSpecifier - | import('estree').ExportSpecifier; - export type NodeWithFieldDefinition = - | import('estree').Identifier - | import('estree').SimpleLiteral - | import('estree').RegExpLiteral - | import('estree').Program - | import('estree').FunctionDeclaration - | import('estree').FunctionExpression - | import('estree').ArrowFunctionExpression - | import('estree').SwitchCase - | import('estree').CatchClause - | import('estree').VariableDeclarator - | import('estree').ExpressionStatement - | import('estree').BlockStatement - | import('estree').EmptyStatement - | import('estree').DebuggerStatement - | import('estree').WithStatement - | import('estree').ReturnStatement - | import('estree').LabeledStatement - | import('estree').BreakStatement - | import('estree').ContinueStatement - | import('estree').IfStatement - | import('estree').SwitchStatement - | import('estree').ThrowStatement - | import('estree').TryStatement - | import('estree').WhileStatement - | import('estree').DoWhileStatement - | import('estree').ForStatement - | import('estree').ForInStatement - | import('estree').ForOfStatement - | import('estree').VariableDeclaration - | import('estree').ClassDeclaration - | import('estree').ThisExpression - | import('estree').ArrayExpression - | import('estree').ObjectExpression - | import('estree').YieldExpression - | import('estree').UnaryExpression - | import('estree').UpdateExpression - | import('estree').BinaryExpression - | import('estree').AssignmentExpression - | import('estree').LogicalExpression - | import('estree').MemberExpression - | import('estree').ConditionalExpression - | import('estree').SimpleCallExpression - | import('estree').NewExpression - | import('estree').SequenceExpression - | import('estree').TemplateLiteral - | import('estree').TaggedTemplateExpression - | import('estree').ClassExpression - | import('estree').MetaProperty - | import('estree').AwaitExpression - | import('estree').ImportExpression - | import('estree').ChainExpression - | import('estree').Property - | import('estree').AssignmentProperty - | import('estree').Super - | import('estree').TemplateElement - | import('estree').SpreadElement - | import('estree').ObjectPattern - | import('estree').ArrayPattern - | import('estree').RestElement - | import('estree').AssignmentPattern - | import('estree').ClassBody - | import('estree').MethodDefinition - | import('estree').ImportDeclaration - | import('estree').ExportNamedDeclaration - | import('estree').ExportDefaultDeclaration - | import('estree').ExportAllDeclaration - | import('estree').ImportSpecifier - | import('estree').ImportDefaultSpecifier - | import('estree').ImportNamespaceSpecifier - | import('estree').ExportSpecifier - | { - computed: boolean; - type: 'FieldDefinition'; - value: Node; - }; -} diff --git a/typings/declarations.ts b/typings/declarations.ts new file mode 100644 index 00000000000..a69e866332a --- /dev/null +++ b/typings/declarations.ts @@ -0,0 +1,99 @@ +// internal +declare module 'help.md' { + const value: string; + export default value; +} + +// external libs +declare module 'acorn-import-assertions' { + export const importAssertions: () => unknown; +} + +declare module 'is-reference' { + import type * as estree from 'estree'; + + export default function is_reference( + node: NodeWithFieldDefinition, + parent: NodeWithFieldDefinition + ): boolean; + + type EstreeNode = + | estree.ArrayExpression + | estree.ArrayPattern + | estree.ArrowFunctionExpression + | estree.AssignmentExpression + | estree.AssignmentPattern + | estree.AssignmentProperty + | estree.AwaitExpression + | estree.BinaryExpression + | estree.BlockStatement + | estree.BreakStatement + | estree.CatchClause + | estree.ChainExpression + | estree.ClassBody + | estree.ClassDeclaration + | estree.ClassExpression + | estree.ConditionalExpression + | estree.ContinueStatement + | estree.DebuggerStatement + | estree.DoWhileStatement + | estree.EmptyStatement + | estree.ExportAllDeclaration + | estree.ExportDefaultDeclaration + | estree.ExportNamedDeclaration + | estree.ExportSpecifier + | estree.ExpressionStatement + | estree.ForInStatement + | estree.ForOfStatement + | estree.ForStatement + | estree.FunctionDeclaration + | estree.FunctionExpression + | estree.IfStatement + | estree.Identifier + | estree.ImportDeclaration + | estree.ImportDefaultSpecifier + | estree.ImportExpression + | estree.ImportNamespaceSpecifier + | estree.ImportSpecifier + | estree.LabeledStatement + | estree.LogicalExpression + | estree.MemberExpression + | estree.MetaProperty + | estree.MethodDefinition + | estree.NewExpression + | estree.ObjectExpression + | estree.ObjectPattern + | estree.Program + | estree.Property + | estree.RegExpLiteral + | estree.RestElement + | estree.ReturnStatement + | estree.SequenceExpression + | estree.SimpleCallExpression + | estree.SimpleLiteral + | estree.SpreadElement + | estree.Super + | estree.SwitchCase + | estree.SwitchStatement + | estree.TaggedTemplateExpression + | estree.TemplateElement + | estree.TemplateLiteral + | estree.ThisExpression + | estree.ThrowStatement + | estree.TryStatement + | estree.UnaryExpression + | estree.UpdateExpression + | estree.VariableDeclaration + | estree.VariableDeclarator + | estree.WhileStatement + | estree.WithStatement + | estree.YieldExpression; + + export type NodeWithFieldDefinition = + | EstreeNode + | { + computed: boolean; + type: 'FieldDefinition'; + value: EstreeNode; + }; +} diff --git a/typings/fsevents.ts b/typings/fsevents.ts new file mode 100644 index 00000000000..8a1900adb37 --- /dev/null +++ b/typings/fsevents.ts @@ -0,0 +1,7 @@ +// 'fsevents' (which also has typings included) is an optional dependency installed on macOS, +// and not installed on linux/windows. this will provide (bogus) type information for +// linux/windows, and overwrite (replace) the types coming with the 'fsevents' module on macOS +declare module 'fsevents' { + const fsevents: object; + export default fsevents; +} diff --git a/typings/hash.js.d.ts b/typings/hash.js.d.ts deleted file mode 100644 index 1b6c018d494..00000000000 --- a/typings/hash.js.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -declare module 'hash.js/lib/hash/sha/256' { - export default function sha256(): { - digest: (format: string) => string; - update: (data: any) => void; - }; -} diff --git a/typings/package.json.d.ts b/typings/package.json.ts similarity index 100% rename from typings/package.json.d.ts rename to typings/package.json.ts diff --git a/wasm/bindings_wasm.d.ts b/wasm/bindings_wasm.d.ts new file mode 100644 index 00000000000..30cac2e01ae --- /dev/null +++ b/wasm/bindings_wasm.d.ts @@ -0,0 +1,46 @@ +/* tslint:disable */ +/* eslint-disable */ + +export function parse(code: string, allow_return_outside_function: boolean, jsx: boolean): Uint8Array; + +export function xxhashBase16(input: Uint8Array): string; + +export function xxhashBase36(input: Uint8Array): string; + +export function xxhashBase64Url(input: Uint8Array): string; + +export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module; + +export interface InitOutput { + readonly memory: WebAssembly.Memory; + readonly parse: (a: number, b: number, c: number, d: number, e: number) => void; + readonly xxhashBase64Url: (a: number, b: number) => void; + readonly xxhashBase36: (a: number, b: number) => void; + readonly xxhashBase16: (a: number, b: number) => void; + readonly __wbindgen_export: (a: number, b: number, c: number) => void; + readonly __wbindgen_export2: (a: number, b: number) => number; + readonly __wbindgen_export3: (a: number, b: number, c: number, d: number) => number; + readonly __wbindgen_add_to_stack_pointer: (a: number) => number; +} + +export type SyncInitInput = BufferSource | WebAssembly.Module; + +/** + * Instantiates the given `module`, which can either be bytes or + * a precompiled `WebAssembly.Module`. + * + * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated. + * + * @returns {InitOutput} + */ +export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput; + +/** + * If `module_or_path` is {RequestInfo} or {URL}, makes a request and + * for everything else, calls `WebAssembly.instantiate` directly. + * + * @param {{ module_or_path: InitInput | Promise }} module_or_path - Passing `InitInput` directly is deprecated. + * + * @returns {Promise} + */ +export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise } | InitInput | Promise): Promise; diff --git a/wasm/bindings_wasm_bg.wasm.d.ts b/wasm/bindings_wasm_bg.wasm.d.ts new file mode 100644 index 00000000000..357cc1d8694 --- /dev/null +++ b/wasm/bindings_wasm_bg.wasm.d.ts @@ -0,0 +1,11 @@ +/* tslint:disable */ +/* eslint-disable */ +export const memory: WebAssembly.Memory; +export const parse: (a: number, b: number, c: number, d: number, e: number) => void; +export const xxhashBase64Url: (a: number, b: number) => void; +export const xxhashBase36: (a: number, b: number) => void; +export const xxhashBase16: (a: number, b: number) => void; +export const __wbindgen_export: (a: number, b: number, c: number) => void; +export const __wbindgen_export2: (a: number, b: number) => number; +export const __wbindgen_export3: (a: number, b: number, c: number, d: number) => number; +export const __wbindgen_add_to_stack_pointer: (a: number) => number;